swig-3.0.2/0000775000175000017500000000000012343706600012346 5ustar williamwilliamswig-3.0.2/LICENSE0000664000175000017500000000206212343605122013350 0ustar williamwilliamSWIG is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See the LICENSE-GPL file for the full terms of the GNU General Public license version 3. Portions of SWIG are also licensed under the terms of the licenses in the file LICENSE-UNIVERSITIES. You must observe the terms of these licenses, as well as the terms of the GNU General Public License, when you distribute SWIG. The SWIG library and examples, under the Lib and Examples top level directories, are distributed under the following terms: You may copy, modify, distribute, and make derivative works based on this software, in source code or object code form, without restriction. If you distribute the software to others, you may do so according to the terms of your choice. This software is offered as is, without warranty of any kind. See the COPYRIGHT file for a list of contributors to SWIG and their copyright notices. swig-3.0.2/ANNOUNCE0000664000175000017500000000221112343605122013470 0ustar williamwilliam*** ANNOUNCE: SWIG 3.0.2 (4 Jun 2014) *** http://www.swig.org We're pleased to announce SWIG-3.0.2, the latest SWIG release. What is SWIG? ============= SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible from other programming languages including Perl, Python, Tcl, Ruby, PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN), D, Ocaml, Pike, Modula-3, Octave, R, Common Lisp (CLISP, Allegro CL, CFFI, UFFI). SWIG can also export its parse tree in the form of XML and Lisp s-expressions. Major applications of SWIG include generation of scripting language extension modules, rapid prototyping, testing, and user interface development for large C/C++ systems. Availability ============ The release is available for download on Sourceforge at http://prdownloads.sourceforge.net/swig/swig-3.0.2.tar.gz A Windows version is also available at http://prdownloads.sourceforge.net/swig/swigwin-3.0.2.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. --- The SWIG Developers swig-3.0.2/configure.ac0000664000175000017500000024214512343605122014641 0ustar williamwilliamdnl Process this file with autoconf to produce a configure script. dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. AC_INIT([swig],[3.0.2],[http://www.swig.org]) dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED dnl definition below can be removed AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) AC_CONFIG_HEADERS([Source/Include/swigconfig.h]) AC_CANONICAL_HOST AM_INIT_AUTOMAKE dnl Some extra defines for the config file AH_BOTTOM([ /* Default language */ #define SWIG_LANG "-tcl" /* Deal with attempt by Microsoft to deprecate C standard runtime functions */ #if defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif ]) dnl Check for programs that a user requires to build SWIG AC_PROG_CC AC_PROG_CXX AC_EXEEXT AC_OBJEXT AM_PROG_CC_C_O # Needed for subdir-objects in AUTOMAKE_OPTIONS AC_COMPILE_WARNINGS # Increase warning levels AC_DEFINE_UNQUOTED(SWIG_CXX, ["$CXX"], [Compiler that built SWIG]) AC_DEFINE_UNQUOTED(SWIG_PLATFORM, ["$host"], [Platform that SWIG is built for]) dnl Checks for header files. AC_HEADER_STDC dnl Checks for types. AC_LANG_PUSH([C++]) AC_CHECK_TYPES([bool]) AC_LANG_POP([C++]) dnl Look for popen AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval") if test x"${with_popen}" = xno ; then AC_MSG_NOTICE([Disabling popen]) else AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen])) fi dnl PCRE dnl AX_PATH_GENERIC() relies on AC_PROG_SED() but it is defined only in dnl autoconf 2.60 so trivially predefine it ourselves for the older versions m4_ifdef([AC_PROG_SED],, [AC_DEFUN([AC_PROG_SED], [AC_PATH_PROG([SED], sed)])]) AC_ARG_WITH([pcre], [AS_HELP_STRING([--without-pcre], [Disable support for regular expressions using PCRE])], [], [with_pcre=yes]) AC_MSG_CHECKING([whether to enable PCRE support]) AC_MSG_RESULT([$with_pcre]) dnl To make configuring easier, check for a locally built PCRE using the Tools/pcre-build.sh script if test x"${with_pcre}" = xyes ; then AC_MSG_CHECKING([whether to use local PCRE]) local_pcre_config=no if test -z $PCRE_CONFIG; then if test -f `pwd`/pcre/pcre-swig-install/bin/pcre-config; then PCRE_CONFIG=`pwd`/pcre/pcre-swig-install/bin/pcre-config local_pcre_config=$PCRE_CONFIG fi fi AC_MSG_RESULT([$local_pcre_config]) fi AS_IF([test "x$with_pcre" != xno], [AX_PATH_GENERIC([pcre], [], dnl Minimal version of PCRE we need -- accept any [], dnl custom sed script for version parsing is not needed [AC_DEFINE([HAVE_PCRE], [1], [Define if you have PCRE library]) LIBS="$LIBS $PCRE_LIBS" CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS" ], [AC_MSG_FAILURE([ Cannot find pcre-config script from PCRE (Perl Compatible Regular Expressions) library package. This dependency is needed for configure to complete, Either: - Install the PCRE developer package on your system (preferred approach). - Download the PCRE source tarball, build and install on your system as you would for any package built from source distribution. - Use the Tools/pcre-build.sh script to build PCRE just for SWIG to statically link against. Run 'Tools/pcre-build.sh --help' for instructions. (quite easy and does not require privileges to install PCRE on your system) - Use configure --without-pcre to disable regular expressions support in SWIG (not recommended).]) ]) ]) dnl CCache AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes]) AC_MSG_CHECKING([whether to enable ccache-swig]) AC_MSG_RESULT([$enable_ccache]) if test "$enable_ccache" = yes; then AC_CONFIG_SUBDIRS(CCache) ENABLE_CCACHE=1 fi AC_SUBST(ENABLE_CCACHE) echo "" echo "Checking packages required for SWIG developers." echo "Note : None of the following packages are required for users to compile and install SWIG from the distributed tarball" echo "" AC_PROG_YACC AC_PROG_RANLIB AC_CHECK_PROGS(AR, ar aal, ar) AC_SUBST(AR) AC_CHECK_PROGS(YODL2MAN, yodl2man) AC_CHECK_PROGS(YODL2HTML, yodl2html) if test -n "$YODL2MAN"; then AC_MSG_CHECKING([yodl2man version >= 2.02]) [yodl_version=`$YODL2MAN --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.*[0-9]*\).*/\1/g'`] AX_COMPARE_VERSION([$yodl_version],[ge],[2.02], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no - $yodl_version found])]) fi if test -n "$YODL2HTML"; then AC_MSG_CHECKING([yodl2html version >= 2.02]) [yodl_version=`$YODL2HTML --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] AX_COMPARE_VERSION([$yodl_version],[ge],[2.02], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no - $yodl_version found])]) fi echo "" echo "Checking for installed target languages and other information in order to compile and run" echo "the examples and test-suite invoked by 'make check'." echo "Note : None of the following packages are required for users to compile and install SWIG from the distributed tarball" echo "" dnl Some test cases require Boost AX_BOOST_BASE(,,,) AC_SUBST(BOOST_CPPFLAGS) dnl How to specify include directories that may be system directories. # -I should not be used on system directories (GCC) if test "$GCC" = yes; then ISYSTEM="-isystem " else ISYSTEM="-I" fi AC_MSG_NOTICE(ISYSTEM: $ISYSTEM) dnl Info for building shared libraries ... in order to run the examples # SO is the extension of shared libraries (including the dot!) AC_MSG_CHECKING(SO) if test -z "$SO" then case $host in *-*-hp*) SO=.sl;; *-*-darwin*) SO=.bundle;; *-*-cygwin* | *-*-mingw*) SO=.dll;; *) SO=.so;; esac fi AC_MSG_RESULT($SO) # LDSHARED is the ld *command* used to create shared library # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into # Python, as opposed to building Python itself as a shared library.) AC_MSG_CHECKING(LDSHARED) if test -z "$LDSHARED" then case $host in *-*-aix*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";; *-*-cygwin* | *-*-mingw*) if test "$GCC" = yes; then LDSHARED="$CC -shared" else if test "cl" = $CC ; then # Microsoft Visual C++ (MSVC) LDSHARED="$CC -nologo -LD" else # Unknown compiler try gcc approach LDSHARED="$CC -shared" fi fi ;; *-*-irix5*) LDSHARED="ld -shared";; *-*-irix6*) LDSHARED="ld ${SGI_ABI} -shared -all";; *-*-sunos4*) LDSHARED="ld";; *-*-solaris*) LDSHARED="ld -G";; *-*-hp*) LDSHARED="ld -b";; *-*-osf*) LDSHARED="ld -shared -expect_unresolved \"*\"";; *-sequent-sysv4) LDSHARED="ld -G";; *-*-next*) if test "$ns_dyld" then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind' else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r' fi if test "$with_next_framework" ; then LDSHARED="$LDSHARED \$(LDLIBRARY)" fi ;; *-*-linux*) LDSHARED="gcc -shared";; *-*-dgux*) LDSHARED="ld -G";; *-*-freebsd3*) LDSHARED="gcc -shared";; *-*-freebsd* | *-*-openbsd*) LDSHARED="ld -Bshareable";; *-*-netbsd*) if [[ "`$CC -dM -E - &1 | grep -i clang >/dev/null && CLANGXX=yes case $host in *-*-darwin11* | *-*-darwin12* |*-*-darwin13* ) if test "$CLANGXX" = "yes"; then PLATCXXFLAGS="$PLATCXXFLAGS -stdlib=libc++" fi;; *) ;; esac # Set info about shared libraries. AC_SUBST(SO) AC_SUBST(LDSHARED) AC_SUBST(CCSHARED) AC_SUBST(CXXSHARED) AC_SUBST(TRYLINKINGWITHCXX) AC_SUBST(RPATH) AC_SUBST(PLATCFLAGS) AC_SUBST(PLATCXXFLAGS) AC_SUBST(HAVE_CXX11_COMPILER) AC_SUBST(LINKFORSHARED) # This variation is needed on OS-X because there is no (apparent) consistency in shared library naming. # Sometimes .bundle works, but sometimes .so is needed. It depends on the target language AC_SUBST(PYTHON_SO) case $host in *-*-mingw*) PYTHON_SO=.pyd;; *-*-darwin*) PYTHON_SO=.so;; *) PYTHON_SO=$SO;; esac AC_SUBST(TCL_SO) case $host in *-*-darwin*) TCL_SO=.dylib;; *) TCL_SO=$SO;; esac AC_SUBST(GUILE_SO) case $host in *-*-darwin*) GUILE_SO=.so;; *) GUILE_SO=$SO;; esac AC_SUBST(PHP_SO) case $host in *-*-darwin*) PHP_SO=.so;; *) PHP_SO=$SO;; esac AC_SUBST(MZSCHEME_SO) case $host in *) MZSCHEME_SO=.so;; esac AC_SUBST(LUA_SO) case $host in *-*-darwin*) LUA_SO=.so;; *) LUA_SO=$SO;; esac # Check for specific libraries. Used for SWIG examples AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX dnl The following three libraries (nsl,inet,socket) are needed on Sequent, dnl and must be checked for in this order since each library depends on the dnl preceding one. dnl dnl Most SVR4 platforms will need -lsocket and -lnsl. However on SGI IRIX 5, dnl these exist but are broken, so we use AC_SEARCH_LIBS which will only try dnl the library if the function isn't already available without it. AC_SEARCH_LIBS(t_open, nsl) # SVR4 AC_SEARCH_LIBS(gethostbyname, inet) # Sequent AC_SEARCH_LIBS(socket, socket) # SVR4 sockets AC_CHECK_LIB(swill, swill_init, [SWIGLIBS="-lswill $LIBS" SWILL="-DSWIG_SWILL"]) AC_SUBST(SWIGLIBS) AC_SUBST(SWILL) # check for --with-libm=... AC_SUBST(LIBM) LIBM=-lm AC_ARG_WITH(libm, [ --with-libm=STRING math library], [ if test "$withval" != yes then LIBM=$withval else AC_MSG_ERROR([proper usage is --with-libm=STRING]) fi]) AC_CHECK_LIB(ieee, main, [LIBM="-lieee $LIBM"]) AC_CHECK_LIB(crypt,crypt, [LIBCRYPT="-lcrypt"]) AC_SUBST(LIBCRYPT) # check for --with-libc=... AC_SUBST(LIBC) AC_ARG_WITH(libc, [ --with-libc=STRING C library], [ if test "$withval" != yes then LIBC=$withval else AC_MSG_ERROR([proper usage is --with-libc=STRING]) fi]) #-------------------------------------------------------------------- # Target languages #-------------------------------------------------------------------- AC_ARG_WITH(alllang, AS_HELP_STRING([--without-alllang], [Disable all languages]), with_alllang="$withval") #-------------------------------------------------------------------- # Look for Tcl #-------------------------------------------------------------------- TCLINCLUDE= TCLLIB= TCLPACKAGE= AC_ARG_WITH(tclconfig, AS_HELP_STRING([--without-tcl], [Disable Tcl]) AS_HELP_STRING([--with-tclconfig=path], [Set location of tclConfig.sh]), [with_tclconfig="$withval"], [with_tclconfig=]) AC_ARG_WITH(tcl, [ --with-tcl=path Set location of Tcl package],[ TCLPACKAGE="$withval"], [TCLPACKAGE=yes]) AC_ARG_WITH(tclincl,[ --with-tclincl=path Set location of Tcl include directory],[ TCLINCLUDE="$ISYSTEM$withval"], [TCLINCLUDE=]) AC_ARG_WITH(tcllib,[ --with-tcllib=path Set location of Tcl library directory],[ TCLLIB="-L$withval"], [TCLLIB=]) # First, check for "--without-tcl" or "--with-tcl=no". if test x"${TCLPACKAGE}" = xno -o x"${with_alllang}" = xno; then AC_MSG_NOTICE([Disabling Tcl]) else AC_MSG_CHECKING([for Tcl configuration]) # First check to see if --with-tclconfig was specified. if test x"${with_tclconfig}" != x ; then if test -f "${with_tclconfig}/tclConfig.sh" ; then TCLCONFIG=`(cd ${with_tclconfig}; pwd)` else AC_MSG_ERROR([${with_tcl} directory does not contain tclConfig.sh]) fi fi # check in a few common install locations if test x"${TCLCONFIG}" = x ; then for i in `ls -d -r /usr/lib*/ 2>/dev/null` \ `ls -d -r /usr/lib*/tcl*/ 2>/dev/null` \ `ls -d -r /usr/local/lib*/ 2>/dev/null` \ `ls -d -r /usr/local/lib*/tcl*/ 2>/dev/null` ; do if test -f $i"tclConfig.sh" ; then TCLCONFIG=`(cd $i; pwd)` break fi done fi if test x"${TCLCONFIG}" = x ; then AC_MSG_RESULT(no) else AC_MSG_RESULT(found $TCLCONFIG/tclConfig.sh) . $TCLCONFIG/tclConfig.sh if test -z "$TCLINCLUDE"; then TCLINCLUDE=`echo $TCL_INCLUDE_SPEC | sed "s/-I/$ISYSTEM/"` fi if test -z "$TCLLIB"; then TCLLIB=$TCL_LIB_SPEC fi fi if test -z "$TCLINCLUDE"; then if test "x$TCLPACKAGE" != xyes; then TCLINCLUDE="$ISYSTEM$TCLPACKAGE/include" fi fi if test -z "$TCLLIB"; then if test "x$TCLPACKAGE" != xyes; then TCLLIB="-L$TCLPACKAGE/lib -ltcl" fi fi AC_MSG_CHECKING(for Tcl header files) if test -z "$TCLINCLUDE"; then AC_TRY_CPP([#include ], , TCLINCLUDE="") if test -z "$TCLINCLUDE"; then dirs="/usr/local/include /usr/include /opt/local/include" for i in $dirs ; do if test -r $i/tcl.h; then AC_MSG_RESULT($i) TCLINCLUDE="$ISYSTEM$i" break fi done fi if test -z "$TCLINCLUDE"; then AC_MSG_RESULT(not found) fi else AC_MSG_RESULT($TCLINCLUDE) fi AC_MSG_CHECKING(for Tcl library) if test -z "$TCLLIB"; then dirs="/usr/local/lib /usr/lib /opt/local/lib" for i in $dirs ; do if test -r $i/libtcl.a; then AC_MSG_RESULT($i) TCLLIB="-L$i -ltcl" break fi done if test -z "$TCLLIB"; then AC_MSG_RESULT(not found) fi else AC_MSG_RESULT($TCLLIB) fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) TCLDYNAMICLINKING="$TCLLIB";; *)TCLDYNAMICLINKING="";; esac case $host in *-*-darwin*) TCLLDSHARED='$(CC) -dynamiclib -undefined suppress -flat_namespace' TCLCXXSHARED='$(CXX) -dynamiclib -undefined suppress -flat_namespace' ;; *) TCLLDSHARED='$(LDSHARED)' TCLCXXSHARED='$(CXXSHARED)' ;; esac fi AC_SUBST(TCLINCLUDE) AC_SUBST(TCLLIB) AC_SUBST(TCLDYNAMICLINKING) AC_SUBST(TCLLDSHARED) AC_SUBST(TCLCXXSHARED) #---------------------------------------------------------------- # Look for Python #---------------------------------------------------------------- PYINCLUDE= PYLIB= PYPACKAGE= AC_ARG_WITH(python, AS_HELP_STRING([--without-python], [Disable Python]) AS_HELP_STRING([--with-python=path], [Set location of Python executable]),[ PYBIN="$withval"], [PYBIN=yes]) # First, check for "--without-python" or "--with-python=no". if test x"${PYBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Python]) else # First figure out the name of the Python executable if test "x$PYBIN" = xyes; then AC_CHECK_PROGS(PYTHON, [python python2.8 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4]) else PYTHON="$PYBIN" fi if test -n "$PYTHON"; then AC_MSG_CHECKING(for Python prefix) PYPREFIX=`($PYTHON -c "import sys; print sys.prefix") 2>/dev/null` AC_MSG_RESULT($PYPREFIX) AC_MSG_CHECKING(for Python exec-prefix) PYEPREFIX=`($PYTHON -c "import sys; print sys.exec_prefix") 2>/dev/null` AC_MSG_RESULT($PYEPREFIX) # Note: I could not think of a standard way to get the version string from different versions. # This trick pulls it out of the file location for a standard library file. AC_MSG_CHECKING(for Python version) # Need to do this hack since autoconf replaces __file__ with the name of the configure file filehack="file__" PYVERSION=`($PYTHON -c "import string,operator,os.path; print operator.getitem(os.path.split(operator.getitem(os.path.split(string.__$filehack),0)),1)")` AC_MSG_RESULT($PYVERSION) # Find the directory for libraries this is necessary to deal with # platforms that can have apps built for multiple archs: e.g. x86_64 AC_MSG_CHECKING(for Python lib dir) PYLIBDIR=`($PYTHON -c "import sys; print sys.lib") 2>/dev/null` if test -z "$PYLIBDIR"; then # Fedora patch Python to add sys.lib, for other distros we assume "lib". PYLIBDIR="lib" fi AC_MSG_RESULT($PYLIBDIR) # Set the include directory AC_MSG_CHECKING(for Python header files) if test -r $PYPREFIX/include/$PYVERSION/Python.h; then PYINCLUDE="-I$PYPREFIX/include/$PYVERSION -I$PYEPREFIX/$PYLIBDIR/$PYVERSION/config" fi if test -z "$PYINCLUDE"; then if test -r $PYPREFIX/include/Py/Python.h; then PYINCLUDE="-I$PYPREFIX/include/Py -I$PYEPREFIX/$PYLIBDIR/python/lib" fi fi AC_MSG_RESULT($PYINCLUDE) # Set the library directory blindly. This probably won't work with older versions AC_MSG_CHECKING(for Python library) dirs="$PYVERSION/config $PYVERSION/$PYLIBDIR python/$PYLIBDIR" for i in $dirs; do if test -d $PYEPREFIX/$PYLIBDIR/$i; then PYLIB="$PYEPREFIX/$PYLIBDIR/$i" break fi done if test -z "$PYLIB"; then AC_MSG_RESULT(Not found) else AC_MSG_RESULT($PYLIB) fi PYLINK="-l$PYVERSION" fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) PYTHONDYNAMICLINKING="-L$PYLIB $PYLINK" DEFS="-DUSE_DL_IMPORT $DEFS" ;; *)PYTHONDYNAMICLINKING="";; esac fi AC_SUBST(PYINCLUDE) AC_SUBST(PYLIB) AC_SUBST(PYLINK) AC_SUBST(PYTHONDYNAMICLINKING) #---------------------------------------------------------------- # Look for Python 3.x #---------------------------------------------------------------- # mostly copy & pasted from "Look for Python" section, # did some trim, fix and rename PY3INCLUDE= PY3LIB= PY3PACKAGE= AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x support]) AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN=yes]) # First, check for "--without-python3" or "--with-python3=no". if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Python 3.x support]) else if test "x$PY3BIN" = xyes; then for py_ver in 3 3.6 3.5 3.4 3.3 3.2 3.1 3.0; do AC_CHECK_PROGS(PYTHON3, [python$py_ver]) if test -n "$PYTHON3"; then AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config]) if test -n "$PY3CONFIG"; then break fi fi done else PYTHON3="$PY3BIN" AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config]) fi if test -n "$PYTHON3" -a -n "$PY3CONFIG"; then AC_MSG_CHECKING([for Python 3.x prefix]) PY3PREFIX=`($PY3CONFIG --prefix) 2>/dev/null` AC_MSG_RESULT($PY3PREFIX) AC_MSG_CHECKING(for Python 3.x exec-prefix) PY3EPREFIX=`($PY3CONFIG --exec-prefix) 2>/dev/null` AC_MSG_RESULT($PY3EPREFIX) # Note: I could not think of a standard way to get the version string from different versions. # This trick pulls it out of the file location for a standard library file. AC_MSG_CHECKING([for Python 3.x version]) # Need to do this hack since autoconf replaces __file__ with the name of the configure file filehack="file__" PY3VERSION=`($PYTHON3 -c "import string,operator,os.path; print(operator.getitem(os.path.split(operator.getitem(os.path.split(string.__$filehack),0)),1))")` AC_MSG_RESULT($PY3VERSION) # Find the directory for libraries this is necessary to deal with # platforms that can have apps built for multiple archs: e.g. x86_64 AC_MSG_CHECKING([for Python 3.x lib dir]) PY3LIBDIR=`($PYTHON3 -c "import sys; print(sys.lib)") 2>/dev/null` if test -z "$PY3LIBDIR"; then # some dists don't have sys.lib so the best we can do is assume lib PY3LIBDIR="lib" fi AC_MSG_RESULT($PY3LIBDIR) # Set the include directory AC_MSG_CHECKING([for Python 3.x header files]) PY3INCLUDE=`($PY3CONFIG --includes) 2>/dev/null` AC_MSG_RESULT($PY3INCLUDE) # Set the library directory blindly. This probably won't work with older versions AC_MSG_CHECKING([for Python 3.x library]) dirs="$PY3VERSION/config $PY3VERSION/$PY3LIBDIR python/$PY3LIBDIR" for i in $dirs; do if test -d $PY3EPREFIX/$PY3LIBDIR/$i; then PY3LIB="$PY3EPREFIX/$PY3LIBDIR/$i" break fi done if test -z "$PY3LIB"; then AC_MSG_RESULT([Not found]) else AC_MSG_RESULT($PY3LIB) fi PY3LINK="-l$PY3VERSION" fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK" DEFS="-DUSE_DL_IMPORT $DEFS" ;; *)PYTHON3DYNAMICLINKING="";; esac fi AC_SUBST(PY3INCLUDE) AC_SUBST(PY3LIB) AC_SUBST(PY3LINK) AC_SUBST(PYTHON3DYNAMICLINKING) #---------------------------------------------------------------- # Look for Perl5 #---------------------------------------------------------------- PERLBIN= AC_ARG_WITH(perl5, AS_HELP_STRING([--without-perl5], [Disable Perl5]) AS_HELP_STRING([--with-perl5=path], [Set location of Perl5 executable]),[ PERLBIN="$withval"], [PERLBIN=yes]) # First, check for "--without-perl5" or "--with-perl5=no". if test x"${PERLBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Perl5]) PERL= else # First figure out what the name of Perl5 is if test "x$PERLBIN" = xyes; then AC_CHECK_PROGS(PERL, perl perl5.6.1 perl5.6.0 perl5.004 perl5.003 perl5.002 perl5.001 perl5 perl) else PERL="$PERLBIN" fi # This could probably be simplified as for all platforms and all versions of Perl the following apparently should be run to get the compilation options: # perl -MExtUtils::Embed -e ccopts AC_MSG_CHECKING(for Perl5 header files) if test -n "$PERL"; then PERL5DIR=`($PERL -e 'use Config; print $Config{archlib}, "\n";') 2>/dev/null` if test -n "$PERL5DIR" ; then dirs="$PERL5DIR $PERL5DIR/CORE" PERL5EXT=none for i in $dirs; do if test -r $i/perl.h; then AC_MSG_RESULT($i) PERL5EXT="$i" break fi done if test "$PERL5EXT" = none; then PERL5EXT="$PERL5DIR/CORE" AC_MSG_RESULT(could not locate perl.h...using $PERL5EXT) fi AC_MSG_CHECKING(for Perl5 library) PERL5LIB=`($PERL -e 'use Config; $_=$Config{libperl}; s/^lib//; s/$Config{_a}$//; s/\.$Config{so}.*//; print $_, "\n"') 2>/dev/null` if test -z "$PERL5LIB" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PERL5LIB) fi AC_MSG_CHECKING(for Perl5 ccflags) PERL5CCFLAGS=`($PERL -e 'use Config; print $Config{ccflags}, "\n"' | sed "s/-Wdeclaration-after-statement//" | sed "s/-I/$ISYSTEM/") 2>/dev/null` if test -z "$PERL5CCFLAGS" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PERL5CCFLAGS) fi AC_MSG_CHECKING(for Perl5 ccdlflags) PERL5CCDLFLAGS=`($PERL -e 'use Config; print $Config{ccdlflags}, "\n"') 2>/dev/null` if test -z "$PERL5CCDLFLAGS" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PERL5CCDLFLAGS) fi AC_MSG_CHECKING(for Perl5 cccdlflags) PERL5CCCDLFLAGS=`($PERL -e 'use Config; print $Config{cccdlflags}, "\n"') 2>/dev/null` if test -z "$PERL5CCCDLFLAGS" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PERL5CCCDLFLAGS) fi AC_MSG_CHECKING(for Perl5 ldflags) PERL5LDFLAGS=`($PERL -e 'use Config; print $Config{ldflags}, "\n"') 2>/dev/null` if test -z "$PERL5LDFLAGS" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PERL5LDFLAGS) fi AC_MSG_CHECKING(for Perl5 Test::More module) # For test-suite PERL5TESTMORE=`($PERL -e 'use Test::More; print "good";') 2>/dev/null` if test -z "$PERL5TESTMORE" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT(found) fi else AC_MSG_RESULT(unable to determine perl5 configuration) PERL5EXT=$PERL5DIR fi else AC_MSG_RESULT(could not figure out how to run perl5) fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) PERL5DYNAMICLINKING="-L$PERL5EXT -l$PERL5LIB";; *)PERL5DYNAMICLINKING="";; esac fi AC_SUBST(PERL) AC_SUBST(PERL5EXT) AC_SUBST(PERL5DYNAMICLINKING) AC_SUBST(PERL5LIB) AC_SUBST(PERL5CCFLAGS) AC_SUBST(PERL5CCDLFLAGS) AC_SUBST(PERL5CCCDLFLAGS) AC_SUBST(PERL5LDFLAGS) #---------------------------------------------------------------- # Look for Octave #---------------------------------------------------------------- OCTAVEBIN= OCTAVE_SO=.oct AC_ARG_WITH(octave, AS_HELP_STRING([--without-octave], [Disable Octave]) AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[OCTAVEBIN="$withval"], [OCTAVEBIN=yes]) # First, check for "--without-octave" or "--with-octave=no". if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Octave]) OCTAVE= # First figure out what the name of Octave is elif test "x$OCTAVEBIN" = xyes; then AC_PATH_PROG(OCTAVE, [octave]) else OCTAVE="$OCTAVEBIN" fi if test -n "$OCTAVE"; then AC_MSG_CHECKING([for mkoctfile]) mkoctfile="`dirname ${OCTAVE}`/mkoctfile" AS_IF([test -x "${mkoctfile}"],[ AC_MSG_RESULT([${mkoctfile}]) ],[ AC_MSG_RESULT([not found, disabling Octave]) OCTAVE= ]) fi if test -n "$OCTAVE"; then AC_MSG_CHECKING([for Octave preprocessor flags]) OCTAVE_CPPFLAGS= for n in CPPFLAGS INCFLAGS; do OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} "`unset CPPFLAGS; ${mkoctfile} -p $n` done AC_MSG_RESULT([$OCTAVE_CPPFLAGS]) AC_MSG_CHECKING([for Octave compiler flags]) OCTAVE_CXXFLAGS= for n in ALL_CXXFLAGS; do OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} "`unset CXXFLAGS; ${mkoctfile} -p $n` done AC_MSG_RESULT([$OCTAVE_CXXFLAGS]) AC_MSG_CHECKING([for Octave linker flags]) OCTAVE_LDFLAGS= for n in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`${mkoctfile} -p $n` done AC_MSG_RESULT([$OCTAVE_LDFLAGS]) for octave_opt in --silent --norc --no-history --no-window-system; do AC_MSG_CHECKING([if Octave option '${octave_opt}' is supported]) octave_out=`${OCTAVE} ${octave_opt} /dev/null 2>&1 | sed -n '1{/unrecognized/p}'` AS_IF([test "x${octave_out}" = x],[ AC_MSG_RESULT([yes]) OCTAVE="${OCTAVE} ${octave_opt}" ],[ AC_MSG_RESULT([no]) ]) done fi AC_SUBST(OCTAVE) AC_SUBST(OCTAVE_SO) AC_SUBST(OCTAVE_CPPFLAGS) AC_SUBST(OCTAVE_CXXFLAGS) AC_SUBST(OCTAVE_LDFLAGS) #---------------------------------------------------------------- # Look for java #---------------------------------------------------------------- AC_ARG_WITH(java, AS_HELP_STRING([--without-java], [Disable Java]) AS_HELP_STRING([--with-java=path], [Set location of java executable]),[JAVABIN="$withval"], [JAVABIN=yes]) AC_ARG_WITH(javac, [ --with-javac=path Set location of javac executable],[JAVACBIN="$withval"], [JAVACBIN=]) # First, check for "--without-java" or "--with-java=no". if test x"${JAVABIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Java]) JAVA= else if test "x$JAVABIN" = xyes; then AC_CHECK_PROGS(JAVA, java kaffe guavac) else JAVA="$JAVABIN" fi if test -z "$JAVACBIN"; then AC_CHECK_PROGS(JAVAC, javac) else JAVAC="$JAVACBIN" fi AC_MSG_CHECKING(for java include file jni.h) AC_ARG_WITH(javaincl, [ --with-javaincl=path Set location of Java include directory], [JAVAINCDIR="$withval"], [JAVAINCDIR=]) if test -z "$JAVAINCDIR" ; then JAVAINCDIR="/usr/j2sdk*/include /usr/local/j2sdk*/include /usr/jdk*/include /usr/local/jdk*/include /opt/j2sdk*/include /opt/jdk*/include /usr/java/include /usr/java/j2sdk*/include /usr/java/jdk*/include /usr/local/java/include /opt/java/include /usr/include/java /usr/local/include/java /usr/lib/java/include /usr/lib/jvm/java*/include /usr/lib64/jvm/java*/include /usr/include/kaffe /usr/local/include/kaffe /usr/include" # Add in default installation directory on Windows for Cygwin case $host in *-*-cygwin* | *-*-mingw*) JAVAINCDIR="c:/Program*Files/Java/jdk*/include d:/Program*Files/Java/jdk*/include c:/j2sdk*/include d:/j2sdk*/include c:/jdk*/include d:/jdk*/include $JAVAINCDIR";; *-*-darwin*) JAVAINCDIR="/System/Library/Frameworks/JavaVM.framework/Headers $JAVAINCDIR";; *);; esac fi JAVAINC="" for d in $JAVAINCDIR ; do if test -r "$d/jni.h" ; then AC_MSG_RESULT($d) JAVAINCDIR=$d JAVAINC=-I\"$d\" break fi done if test "$JAVAINC" = "" ; then AC_MSG_RESULT(not found) else # now look for /jni_md.h AC_MSG_CHECKING(for java include file jni_md.h) JAVAMDDIR=`find "$JAVAINCDIR" -follow -name jni_md.h -print` if test "$JAVAMDDIR" = "" ; then AC_MSG_RESULT(not found) else JAVAMDDIR=`dirname "$JAVAMDDIR" | tail -1` JAVAINC="${JAVAINC} -I\"$JAVAMDDIR\"" AC_MSG_RESULT($JAVAMDDIR) fi fi # java.exe on Cygwin requires the Windows standard (Pascal) calling convention as it is a normal Windows executable and not a Cygwin built executable case $host in *-*-cygwin* | *-*-mingw*) if test "$GCC" = yes; then JAVADYNAMICLINKING=" -mno-cygwin -mthreads -Wl,--add-stdcall-alias" JAVACFLAGS="-mno-cygwin -mthreads" else JAVADYNAMICLINKING="" JAVACFLAGS="" fi ;; *-*-darwin*) JAVADYNAMICLINKING="-dynamiclib -framework JavaVM" JAVACFLAGS="" ;; *) JAVADYNAMICLINKING="" JAVACFLAGS="" ;; esac # Java on Windows platforms including Cygwin doesn't use libname.dll, rather name.dll when loading dlls case $host in *-*-cygwin* | *-*-mingw*) JAVALIBRARYPREFIX="";; *)JAVALIBRARYPREFIX="lib";; esac # Java on Mac OS X tweaks case $host in *-*-darwin*) JAVASO=".jnilib" JAVALDSHARED='$(CC)' JAVACXXSHARED='$(CXX)' ;; *) JAVASO=$SO JAVALDSHARED='$(LDSHARED)' JAVACXXSHARED='$(CXXSHARED)' ;; esac fi AC_SUBST(JAVA) AC_SUBST(JAVAC) AC_SUBST(JAVAINC) AC_SUBST(JAVADYNAMICLINKING) AC_SUBST(JAVALIBRARYPREFIX) AC_SUBST(JAVASO) AC_SUBST(JAVALDSHARED) AC_SUBST(JAVACXXSHARED) AC_SUBST(JAVACFLAGS) #---------------------------------------------------------------- # Look for Javascript #---------------------------------------------------------------- AC_ARG_WITH(javascript, AS_HELP_STRING([--without-javascript], [Disable Javascript]), [with_javascript="$withval"], [with_javascript=yes]) # First, check for "--without-javascript" or "--with-javascript=no". if test x"${with_javascript}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Javascript]) JAVASCRIPT= else JAVASCRIPT=1 #---------------------------------------------------------------- # General Javascript settings shared by JSC and V8 #---------------------------------------------------------------- case $host in *-*-cygwin* | *-*-mingw*) JSLIBRARYPREFIX="" ;; *) JSLIBRARYPREFIX="lib" ;; esac case $host in *-*-darwin*) JSSO=".dylib" JSLDSHARED='$(CC) -dynamiclib' JSCXXSHARED='$(CXX) -dynamiclib' # HACK: didn't manage to get dynamic module loading working with a g++ compiled interpreter JSINTERPRETERCXX='c++' JSINTERPRETERLINKFLAGS='-g -Wl,-search_paths_first -Wl,-headerpad_max_install_names' ;; *) JSSO=$SO JSLDSHARED='$(LDSHARED)' JSCXXSHARED='$(CXXSHARED)' JSINTERPRETERCXX='$(CXX)' JSINTERPRETERLINKFLAGS='-ldl' ;; esac #---------------------------------------------------------------- # Look for Node.js which is the default Javascript engine #---------------------------------------------------------------- AC_CHECK_PROGS(NODEJS, node) if test -n "$NODEJS"; then # node-gyp is needed to run the test-suite/examples AC_CHECK_PROGS(NODEGYP, node-gyp) if test -z "$NODEGYP"; then NODEJS= fi fi #---------------------------------------------------------------- # Look for JavascriptCore (Webkit) settings (JSCOREINCDIR, JSCOREDYNAMICLINKING) #---------------------------------------------------------------- # check for include files AC_MSG_CHECKING(for JavaScriptCore/JavaScript.h) AC_ARG_WITH(jscoreinc, [ --with-jscinc=path Set location of Javascript include directory], [JSCOREINCDIR="$withval"], [JSCOREINCDIR=]) JSCOREVERSION= if test -z "$JSCOREINCDIR"; then JSCOREINCDIR="/usr/include/ /usr/local/include/" # Add in default directory for JavaScriptCore headers for Linux and MacOSX case $host in *-*-linux*) JSCOREINCDIR="/usr/include/webkit-1.0/ /usr/include/webkitgtk-1.0/ /usr/local/include/webkit-1.0/JavaScriptCore/ $JSCOREINCDIR" ;; *-*-darwin*) JSCOREINCDIR="/System/Library/Frameworks/JavaScriptCore.framework/Headers/ $JSCOREINCDIR" ;; *) ;; esac fi for d in $JSCOREINCDIR ; do if test -r "$d/JavaScriptCore/JavaScript.h" || test -r "$d/JavaScript.h" ; then AC_MSG_RESULT($d) JSCOREINCDIR=$d JSCOREINC=-I\"$d\" break fi done if test "$JSCOREINC" = "" ; then AC_MSG_RESULT(not found) fi # check for JavaScriptCore/Webkit libraries AC_ARG_WITH(jscorelib,[ --with-jsclib =path Set location of the JavaScriptCore/Webkit library directory],[JSCORELIB="-L$withval"], [JSCORELIB=]) AC_MSG_CHECKING(for JavaScriptCore/Webkit library) # look for the library when not provided if test -z "$JSCORELIB"; then case $host in *-*-linux*) dirs="/usr/lib64/ /usr/local/lib64/ /usr/lib/ /usr/local/lib/" for i in $dirs ; do if test -r $i/libjavascriptcoregtk-1.0.so; then AC_MSG_RESULT($i) JSCORELIB="-L$i -ljavascriptcoregtk-1.0" JSCOREVERSION=`pkg-config --modversion javascriptcoregtk-1.0` break fi done if test -z "$JSCORELIB"; then AC_MSG_RESULT(not found) JSCENABLED= else JSCOREDYNAMICLINKING="$JSCORELIB" JSCENABLED=1 fi ;; *-*-darwin*) JSCOREDYNAMICLINKING="-framework JavaScriptCore" JSCENABLED=1 ;; *) ;; esac fi #---------------------------------------------------------------- # Look for V8 settings (JSV8INCDIR, JSV8DYNAMICLINKING) #---------------------------------------------------------------- # check for include files AC_MSG_CHECKING(for V8 Javascript v8.h) AC_ARG_WITH(jsv8inc, [ --with-v8inc=path Set location of Javascript v8 include directory], [JSV8INCDIR="$withval"]) # if not include dir is specified we try to find if test -z "$JSV8INCDIR"; then # Add in default directory for JavaScriptCore headers for Linux and MacOSX case $host in *-*-linux*) JSV8INCDIR="/usr/include /usr/local/include/ $JSV8INCDIR" ;; *-*-darwin*) JSV8INCDIR="$JSV8INCDIR" ;; *) ;; esac fi for d in $JSV8INCDIR ; do if test -r "$d/v8.h" ; then JSV8INCDIR=$d JSV8INC=-I\"$d\" break fi done if test "$JSV8INC" = "" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($JSV8INCDIR) fi # check for V8 library AC_MSG_CHECKING(for V8 Javascript library) AC_ARG_WITH(jsv8lib,[ --with-v8lib=path Set location of V8 Javascript library directory],[JSV8LIBDIR="$withval"], [JSV8LIB=]) v8libdirs="$JSV8LIBDIR /usr/lib64/ /usr/local/lib64/ /usr/lib/ /usr/local/lib/" for d in $v8libdirs ; do if test -r $d/libv8.so; then JSV8LIBDIR=$d JSV8LIB="-L$d -lv8" break fi done if test "$JSV8LIB" = "" ; then AC_MSG_RESULT(not found) JSV8ENABLED= else AC_MSG_RESULT($JSV8LIBDIR) JSV8ENABLED=1 fi # linking options case $host in *-*-darwin*) JSV8DYNAMICLINKING="" # TODO: add osx configuration ;; *-*-linux*) JSV8DYNAMICLINKING="$JSV8LIB" ;; *) JSV8DYNAMICLINKING="" ;; esac fi AC_SUBST(JSLIBRARYPREFIX) AC_SUBST(JSSO) AC_SUBST(JSLDSHARED) AC_SUBST(JSCXXSHARED) AC_SUBST(JSINTERPRETERCXX) AC_SUBST(JSINTERPRETERLINKFLAGS) AC_SUBST(JSCOREINC) AC_SUBST(JSCOREDYNAMICLINKING) AC_SUBST(JSCOREVERSION) AC_SUBST(JSV8INC) AC_SUBST(JSV8DYNAMICLINKING) AC_SUBST(JSCENABLED) AC_SUBST(JSV8ENABLED) AC_SUBST(NODEJS) AC_SUBST(NODEGYP) #---------------------------------------------------------------- # Look for gcj #---------------------------------------------------------------- AC_ARG_WITH(gcj, AS_HELP_STRING([--without-gcj], [Disable GCJ]) AS_HELP_STRING([--with-gcj=path], [Set location of gcj executable]),[GCJBIN="$withval"], [GCJBIN=yes]) AC_ARG_WITH(gcjh, [ --with-gcjh=path Set location of gcjh executable],[GCJHBIN="$withval"], [GCJHBIN=]) # First, check for "--without-gcj" or "--with-gcj=no". if test x"${GCJBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling GCJ]) else if test "x$GCJBIN" = xyes; then AC_CHECK_PROGS(GCJ, gcj) else GCJ="$GCJBIN" fi if test -z "$GCJCBIN"; then AC_CHECK_PROGS(GCJH, gcjh) else GCJH="$GCJHBIN" fi fi AC_SUBST(GCJ) AC_SUBST(GCJH) #---------------------------------------------------------------- # Look for Android #---------------------------------------------------------------- AC_ARG_WITH(android, AS_HELP_STRING([--without-android], [Disable Android]) AS_HELP_STRING([--with-android=path], [Set location of android executable]),[ANDROIDBIN="$withval"], [ANDROIDBIN=yes]) AC_ARG_WITH(adb, [ --with-adb=path Set location of adb executable - Android Debug Bridge],[ADBBIN="$withval"], [ADBBIN=]) AC_ARG_WITH(ant, [ --with-ant=path Set location of ant executable for Android],[ANTBIN="$withval"], [ANTBIN=]) AC_ARG_WITH(ndk-build, [ --with-ndk-build=path Set location of Android ndk-build executable],[NDKBUILDBIN="$withval"], [NDKBUILDBIN=]) # First, check for "--without-android" or "--with-android=no". if test x"${ANDROIDBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Android]) ANDROID= else if test "x$ANDROIDBIN" = xyes; then AC_CHECK_PROGS(ANDROID, android) else ANDROID="$ANDROIDBIN" fi if test -z "$ADBBIN"; then AC_CHECK_PROGS(ADB, adb) else ADB="$ADBBIN" fi if test -z "$ANTBIN"; then AC_CHECK_PROGS(ANT, ant) else ANT="$ANTBIN" fi if test -z "$NDKBUILDBIN"; then AC_CHECK_PROGS(NDKBUILD, ndk-build) else NDKBUILD="$NDKBUILDBIN" fi fi AC_SUBST(ANDROID) AC_SUBST(ADB) AC_SUBST(ANT) AC_SUBST(NDKBUILD) #---------------------------------------------------------------- # Look for Guile #---------------------------------------------------------------- GUILE= GUILE_CFLAGS= GUILE_LIBS= AC_ARG_WITH(guile-config, AS_HELP_STRING([--without-guile], [Disable Guile]) AS_HELP_STRING([--with-guile-config=path], [Set location of guile-config]),[ GUILE_CONFIG="$withval"], [GUILE_CONFIG=]) AC_ARG_WITH(guile,[ --with-guile=path Set location of Guile executable],[ GUILE="$withval"], [GUILE=yes]) AC_ARG_WITH(guile-cflags,[ --with-guile-cflags=cflags Set cflags required to compile against Guile],[ GUILE_CFLAGS="$withval"]) AC_ARG_WITH(guile-libs,[ --with-guile-libs=ldflags Set ldflags needed to link with Guile],[ GUILE_LIBS="$withval"]) # First, check for "--without-guile" or "--with-guile=no". if test x"${GUILE}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Guile]) else if test -z "$GUILE_CONFIG" ; then AC_PATH_PROG(GUILE_CONFIG, guile-config) fi if test -n "$GUILE_CONFIG" ; then if test x"$GUILE" = xyes; then AC_MSG_CHECKING([for guile bindir]) guile_bindir="`$GUILE_CONFIG info bindir`" AC_MSG_RESULT([$guile_bindir]) GUILE=$guile_bindir/guile if ! test -f "$GUILE" ; then GUILE= AC_PATH_PROG(GUILE, guile) fi fi if test -f "$GUILE" ; then AC_MSG_CHECKING([for guile version]) guile_version=`$GUILE -c '(display (effective-version))'` AC_MSG_RESULT([$guile_version]) AC_MSG_CHECKING([for guile version >= 1.8]) guile_good_version=`$GUILE -c '(if (>= (string->number (effective-version)) 1.8) (display "yes") (display "no"))'` AC_MSG_RESULT([$guile_good_version]) if test x"$guile_good_version" != xyes ; then GUILE= fi fi if test -z "$GUILE_CFLAGS" ; then AC_MSG_CHECKING([for guile compile flags]) GUILE_CFLAGS="`$GUILE_CONFIG compile`" # Note that this can sometimes be empty AC_MSG_RESULT([$GUILE_CFLAGS]) fi if test -z "$GUILE_LIBS" ; then AC_MSG_CHECKING([for guile link flags]) GUILE_LIBS="`$GUILE_CONFIG link`" AC_MSG_RESULT([$GUILE_LIBS]) fi fi fi AC_SUBST(GUILE) AC_SUBST(GUILE_CFLAGS) AC_SUBST(GUILE_LIBS) #---------------------------------------------------------------- # Look for MzScheme #---------------------------------------------------------------- AC_ARG_WITH(mzscheme, AS_HELP_STRING([--without-mzscheme], [Disable MzScheme]) AS_HELP_STRING([--with-mzscheme=path], [Set location of MzScheme executable]),[ MZSCHEMEBIN="$withval"], [MZSCHEMEBIN=yes]) AC_ARG_WITH(mzc, AS_HELP_STRING([--with-mzc=path], [Set location of MzScheme's mzc]), [ MZCBIN="$withval"], [MZCBIN=]) # First, check for "--without-mzscheme" or "--with-mzscheme=no". if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling MzScheme]) MZC= else if test "x$MZSCHEMEBIN" = xyes; then AC_PATH_PROG(MZSCHEME, mzscheme) else MZSCHEME="$MZSCHEMEBIN" fi if test -z "$MZCBIN"; then AC_PATH_PROG(MZC, mzc) fi if test -n "$MZSCHEME"; then AC_MSG_CHECKING(for MzScheme dynext object) MZDYNOBJ=`$MZSCHEME --eval '(begin (require dynext/link) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (printf "~a" x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` if test -f "$MZDYNOBJ"; then : else # older versions (3.72 approx and earlier) MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` fi if test -f "$MZDYNOBJ"; then AC_MSG_RESULT($MZDYNOBJ) else AC_MSG_RESULT(not found) MZDYNOBJ="" fi fi fi AC_SUBST(MZDYNOBJ) #---------------------------------------------------------------- # Look for Ruby #---------------------------------------------------------------- RUBYBIN= AC_ARG_WITH(ruby, AS_HELP_STRING([--without-ruby], [Disable Ruby]) AS_HELP_STRING([--with-ruby=path], [Set location of Ruby executable]),[ RUBYBIN="$withval"], [RUBYBIN=yes]) # First, check for "--without-ruby" or "--with-ruby=no". if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Ruby]) RUBY= else # First figure out what the name of Ruby is if test "x$RUBYBIN" = xyes; then AC_CHECK_PROGS(RUBY, ruby) else RUBY="$RUBYBIN" fi AC_MSG_CHECKING(for Ruby header files) if test -n "$RUBY"; then # Try Ruby1.9+ first RUBYDIR=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["rubyhdrdir"]] || $rubyhdrdir') 2>/dev/null` if test x"$RUBYDIR" = x"" || test x"$RUBYDIR" = x"nil"; then RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null` else RUBYARCH=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["arch"]] || $arch') 2>/dev/null` fi if test x"$RUBYDIR" != x""; then dirs="$RUBYDIR" RUBYINCLUDE= for i in $dirs; do if test -r $i/ruby.h; then if test x"$RUBYARCH" = x""; then RUBYINCLUDE="-I$i" else RUBYINCLUDE="-I$i -I$i/$RUBYARCH" fi AC_MSG_RESULT($RUBYINCLUDE) break fi done if test x"$RUBYINCLUDE" = x""; then AC_MSG_RESULT(could not locate ruby.h) fi # Find library and path for linking. AC_MSG_CHECKING(for Ruby library) RUBYLIB="" rb_libdir=`($RUBY -rrbconfig -e 'print Config::CONFIG[["libdir"]]') 2>/dev/null` rb_bindir=`($RUBY -rrbconfig -e 'print Config::CONFIG[["bindir"]]') 2>/dev/null` dirs="$dirs $rb_libdir $rb_bindir" rb_libruby=`($RUBY -rrbconfig -e 'print Config::CONFIG[["LIBRUBY_A"]]') 2>/dev/null` RUBYLINK=`($RUBY -rrbconfig -e ' c = Config::CONFIG if c.has_key? "LIBRUBYARG_STATIC" # 1.8.x if c[["LIBRUBY"]] == c[["LIBRUBY_A"]] link = c[["LIBRUBYARG_STATIC"]] else link = c[["LIBRUBYARG_SHARED"]] end else # 1.6.x link = "-l" + c[["RUBY_INSTALL_NAME"]] end # Get the target Ruby was built for target = c[["target"]] if target == "i386-pc-mswin32" # Need to change msvcrt-ruby*.lib to -lmsvcrt-ruby* ext = File.extname(link) # Get index that counts backwards from end of string index = -1 - ext.size # Strip off the extension link = link.slice(0..index) puts "-l#{link}" else puts link end') 2>/dev/null` if test "$rb_libruby" != ""; then for i in $dirs; do if (test -r $i/$rb_libruby;) then RUBYLIB="$i" break fi done fi if test "$RUBYLIB" = ""; then RUBYLIB="$RUBYDIR" AC_MSG_RESULT(not found... using $RUBYDIR) else AC_MSG_RESULT($RUBYLINK in $RUBYLIB) fi else AC_MSG_RESULT(unable to determine ruby configuration) fi case $host in *-*-mingw*) ;; # do nothing, the default windows libraries are already included *) RUBYLINK="$RUBYLINK `($RUBY -rrbconfig -e 'print Config::CONFIG[["LIBS"]]') 2>/dev/null`";; esac RUBYCCDLFLAGS=`($RUBY -rrbconfig -e 'print Config::CONFIG[["CCDLFLAGS"]]') 2>/dev/null` RUBYSO=.`($RUBY -rrbconfig -e 'print Config::CONFIG[["DLEXT"]]') 2>/dev/null` else AC_MSG_RESULT(could not figure out how to run ruby) fi case $host in *-*-cygwin* | *-*-mingw*) RUBYDYNAMICLINKING="-L$RUBYLIB $RUBYLINK";; *) RUBYDYNAMICLINKING="";; esac fi AC_SUBST(RUBYINCLUDE) AC_SUBST(RUBYLIB) AC_SUBST(RUBYLINK) AC_SUBST(RUBYCCDLFLAGS) AC_SUBST(RUBYSO) AC_SUBST(RUBYDYNAMICLINKING) #------------------------------------------------------------------------- # Look for PHP #------------------------------------------------------------------------- PHPBIN= AC_ARG_WITH(php, AS_HELP_STRING([--without-php], [Disable PHP]) AS_HELP_STRING([--with-php=path], [Set location of PHP executable]),[ PHPBIN="$withval"], [PHPBIN=yes]) # First, check for "--without-php" or "--with-php=no". if test x"${PHPBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling PHP]) PHP= else if test "x$PHPBIN" = xyes; then AC_CHECK_PROGS(PHP, [php5 php]) else PHP=$PHPBIN fi AC_MSG_CHECKING(for PHP header files) dnl /usr/bin/php5 -> /usr/bin/php-config5 case $PHP in *5) PHPCONFIG=`echo "$PHP"|sed 's/5$/-config5/'` ;; *) PHPCONFIG=$PHP-config ;; esac php_version=`$PHPCONFIG --version 2>/dev/null` case $php_version in 5*) PHPINC=`$PHPCONFIG --includes 2>/dev/null` if test -n "$PHPINC"; then AC_MSG_RESULT($PHPINC) else AC_MSG_RESULT(not found) fi ;; *) AC_MSG_RESULT([found PHP $version, but only PHP 5 is supported]) ;; esac fi AC_SUBST(PHP) AC_SUBST(PHPINC) #---------------------------------------------------------------- # Look for ocaml #---------------------------------------------------------------- AC_ARG_WITH(ocaml, AS_HELP_STRING([--without-ocaml], [Disable OCaml]) AS_HELP_STRING([--with-ocaml=path], [Set location of ocaml executable]),[ OCAMLBIN="$withval"], [OCAMLBIN=yes]) AC_ARG_WITH(ocamlc,[ --with-ocamlc=path Set location of ocamlc executable],[ OCAMLC="$withval"], [OCAMLC=]) AC_ARG_WITH(ocamldlgen,[ --with-ocamldlgen=path Set location of ocamldlgen],[ OCAMLDLGEN="$withval" ], [OCAMLDLGEN=]) AC_ARG_WITH(ocamlfind,[ --with-ocamlfind=path Set location of ocamlfind],[OCAMLFIND="$withval"],[OCAMLFIND=]) AC_ARG_WITH(ocamlmktop,[ --with-ocamlmktop=path Set location of ocamlmktop executable],[ OCAMLMKTOP="$withval"], [OCAMLMKTOP=]) # First, check for "--without-ocaml" or "--with-ocaml=no". if test x"${OCAMLBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling OCaml]) OCAMLBIN= else AC_MSG_CHECKING(for Ocaml DL load generator) if test -z "$OCAMLDLGEN"; then AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen, :) fi AC_MSG_CHECKING(for Ocaml package tool) if test -z "$OCAMLFIND"; then AC_CHECK_PROGS(OCAMLFIND, ocamlfind, :) fi AC_MSG_CHECKING(for Ocaml compiler) if test -z "$OCAMLC"; then AC_CHECK_PROGS(OCAMLC, ocamlc, :) fi AC_MSG_CHECKING(for Ocaml interpreter) if test "x$OCAMLBIN" = xyes; then AC_CHECK_PROGS(OCAMLBIN, ocaml, :) fi AC_MSG_CHECKING(for Ocaml toplevel creator) if test -z "$OCAMLMKTOP"; then AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, :) fi OCAMLLOC=loc if test "$OCAMLC" != ":" ; then AC_MSG_CHECKING(for Ocaml header files) dirs="/usr/lib/ocaml/caml /usr/local/lib/ocaml/caml" dir="`$OCAMLC -where 2>/dev/null`" if test "$dir"; then dirs="$dir/caml $dirs" fi for i in $dirs; do if test -r $i/mlvalues.h; then AC_MSG_RESULT($i) OCAMLEXT="$i" OCAMLINC="-I$OCAMLEXT" break fi done if test -z "$OCAMLINC"; then AC_MSG_RESULT(not found) fi AC_MSG_CHECKING(for Ocaml version 3.08.2 or higher) OCAMLVER=`$OCAMLC -version | sed -e 's/.*version //g'` AC_COMPARE_VERSION([$OCAMLVER],[3.08.2],[:],[:],[OCAMLLOC=_loc]) AC_MSG_RESULT($OCAMLVER) fi fi # Disabling ocaml export OCAMLLOC export OCAMLVER export OCAMLINC export OCAMLBIN export OCAMLC export OCAMLDLGEN export OCAMLFIND export OCAMLMKTOP AC_SUBST(OCAMLLOC) AC_SUBST(OCAMLVER) AC_SUBST(OCAMLINC) AC_SUBST(OCAMLBIN) AC_SUBST(OCAMLC) AC_SUBST(OCAMLDLGEN) AC_SUBST(OCAMLFIND) AC_SUBST(OCAMLMKTOP) #---------------------------------------------------------------- # Look for Pike #---------------------------------------------------------------- # Identify the name of the Pike executable # Priority: configure option, automatic search PIKEBIN= AC_ARG_WITH(pike, AS_HELP_STRING([--without-pike], [Disable Pike]) AS_HELP_STRING([--with-pike=path], [Set location of Pike executable]),[PIKEBIN="$withval"], [PIKEBIN=yes]) # First, check for "--without-pike" or "--with-pike=no". if test x"${PIKEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Pike]) PIKEBIN= else if test "x$PIKEBIN" = xyes; then AC_CHECK_PROGS(PIKE, pike pike7.8 pike7.6 pike7.4 pike7.2) else PIKE="$PIKEBIN" fi # Check for pike-config # Priority: configure option, guessed from $PIKE, search from list AC_ARG_WITH(pike-config, AS_HELP_STRING([--with-pike-config=path], [Set location of pike-config script]), [PIKECONFIG="$withval"], [PIKECONFIG=""]) if test -z "$PIKECONFIG" -a -n "$PIKE"; then AC_CHECK_PROGS(PIKECONFIG, $PIKE-config pike-config \ pike7.6-config pike7.4-config pike7.2-config) fi # Check for a --with-pikeincl option to configure # Priority: configure option, info from $PIKECONFIG, guessed by pike script AC_ARG_WITH(pikeincl, AS_HELP_STRING([--with-pikeincl=path], [Set location of Pike include directory]), [PIKEINCLUDE="-I$withval"], [PIKEINCLUDE=]) if test -n "$PIKE"; then AC_MSG_CHECKING([for Pike header files]) if test -z "$PIKEINCLUDE" -a -n "$PIKECONFIG"; then PIKEINCLUDE=`$PIKECONFIG --cflags` fi if test -z "$PIKEINCLUDE" -a -n "$PIKE"; then PIKEINCLUDE=`$PIKE -x cflags` if test -z "$PIKEINCLUDE"; then PIKEPATH=`which $PIKE` PIKEINCLUDE=`$PIKE Tools/check-include-path.pike $PIKEPATH` PIKEINCLUDE="-I$PIKEINCLUDE" fi fi if test -z "$PIKEINCLUDE"; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PIKEINCLUDE) fi fi fi AC_SUBST(PIKEINCLUDE) AC_SUBST(PIKECCDLFLAGS) dnl XXX: where is this used/defined? AC_SUBST(PIKEDYNAMICLINKING) dnl XXX: where is this used/defined? #---------------------------------------------------------------- # Look for CHICKEN #---------------------------------------------------------------- CHICKEN= CHICKEN_CONFIG= CHICKENHOME= CHICKENOPTS= CHICKENLIB= AC_ARG_WITH(chicken, AS_HELP_STRING([--without-chicken], [Disable CHICKEN]) AS_HELP_STRING([--with-chicken=path], [Set location of CHICKEN executable]),[ CHICKENBIN="$withval"], [CHICKENBIN=yes]) # First, check for "--without-chicken" or "--with-chicken=no". if test x"${CHICKENBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling CHICKEN]) else if test "x$CHICKENBIN" = xyes; then AC_CHECK_PROGS(CHICKEN, chicken) else CHICKEN="$CHICKENBIN" fi AC_ARG_WITH(chickencsc,[ --with-chickencsc=path Set location of csc executable],[ CHICKEN_CSC="$withval"], [CHICKEN_CSC=]) if test -z "$CHICKEN_CSC"; then AC_CHECK_PROGS(CHICKEN_CSC, csc) # Both the Microsoft C# compiler and chicken have an executable called csc, so check that this csc is really the chicken one if test -n "$CHICKEN_CSC" ; then AC_MSG_CHECKING(whether csc is the chicken compiler) $CHICKEN_CSC -version 2>/dev/null | grep "chicken" > /dev/null || CHICKEN_CSC="" if test -z "$CHICKEN_CSC"; then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi fi fi AC_ARG_WITH(chickencsi,[ --with-chickencsi=path Set location of csi executable],[ CHICKEN_CSI="$withval"], [CHICKEN_CSI=]) if test -z "$CHICKEN_CSI"; then AC_CHECK_PROGS(CHICKEN_CSI, csi) fi if test -n "$CHICKEN_CSC" ; then AC_ARG_WITH(chickenopts,[ --with-chickenopts=args Set compiler options for static CHICKEN generated code],[ CHICKENOPTS="$withval"], [CHICKENOPTS=]) AC_ARG_WITH(chickensharedlib,[ --with-chickensharedlib=args Set linker options for shared CHICKEN generated code],[ CHICKENSHAREDLIB="$withval"], [CHICKENSHAREDLIB=]) AC_ARG_WITH(chickenlib,[ --with-chickenlib=args Set linker options for static CHICKEN generated code],[ CHICKENLIB="$withval"], [CHICKENLIB=]) AC_MSG_CHECKING(for compiler options for static CHICKEN generated code) if test -z "$CHICKENOPTS"; then CHICKENOPTS="`$CHICKEN_CSC -cflags`" else CHICKENOPTS="`$CHICKEN_CSC -cflags` $CHICKENOPTS" fi if test -z "$CHICKENOPTS"; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($CHICKENOPTS) fi AC_MSG_CHECKING(for linker options for shared CHICKEN generated code) if test -z "$CHICKENSHAREDLIB"; then CHICKENSHAREDLIB="`$CHICKEN_CSC -shared -libs`" else CHICKENSHAREDLIB="`$CHICKEN_CSC -shared -libs` $CHICKENSHAREDLIB" fi if test -z "$CHICKENSHAREDLIB"; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($CHICKENSHAREDLIB) fi AC_MSG_CHECKING(for linker options for static CHICKEN generated code) if test -z "$CHICKENLIB"; then CHICKENLIB="`$CHICKEN_CSC -libs`" else CHICKENLIB="`$CHICKEN_CSC -libs` $CHICKENLIB" fi if test -z "$CHICKENLIB"; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($CHICKENLIB) fi fi # have CHICKEN_CONFIG fi # Check for --without-chicken AC_SUBST(CHICKEN) AC_SUBST(CHICKEN_CSC) AC_SUBST(CHICKEN_CSI) AC_SUBST(CHICKENOPTS) AC_SUBST(CHICKENLIB) AC_SUBST(CHICKENSHAREDLIB) #---------------------------------------------------------------- # Look for C# #---------------------------------------------------------------- AC_ARG_WITH(csharp, AS_HELP_STRING([--without-csharp], [Disable CSharp]), [with_csharp="$withval"], [with_csharp=yes]) AC_ARG_WITH(cil-interpreter, [ --with-cil-interpreter=path Set location of CIL interpreter for CSharp],[CSHARPBIN="$withval"], [CSHARPBIN=]) AC_ARG_WITH(csharp-compiler, [ --with-csharp-compiler=path Set location of CSharp compiler],[CSHARPCOMPILERBIN="$withval"], [CSHARPCOMPILERBIN=]) # First, check for "--without-csharp" or "--with-csharp=no". if test x"${with_csharp}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling CSharp]) CSHARPCOMPILER= else if test -z "$CSHARPCOMPILERBIN" ; then case $host in *-*-cygwin* | *-*-mingw*) # prefer Mono gmcs (.NET 2.0) over mcs (.NET 1.1) - note mcs-1.2.3 has major pinvoke bug AC_CHECK_PROGS(CSHARPCOMPILER, csc mono-csc gmcs mcs cscc) if test -n "$CSHARPCOMPILER" && test "$CSHARPCOMPILER" = "csc" ; then AC_MSG_CHECKING(whether csc is the Microsoft CSharp compiler) csc 2>/dev/null | grep "C#" > /dev/null || CSHARPCOMPILER="" if test -z "$CSHARPCOMPILER" ; then AC_MSG_RESULT(no) AC_CHECK_PROGS(CSHARPCOMPILER, mono-csc gmcs mcs cscc) else AC_MSG_RESULT(yes) fi fi ;; *)AC_CHECK_PROGS(CSHARPCOMPILER, mono-csc gmcs mcs cscc);; esac else CSHARPCOMPILER="$CSHARPCOMPILERBIN" fi CSHARPPATHSEPARATOR="/" CSHARPCYGPATH_W=echo if test -z "$CSHARPBIN" ; then CSHARPCILINTERPRETER="" CSHARPCILINTERPRETER_FLAGS="" if test "cscc" = "$CSHARPCOMPILER" ; then AC_CHECK_PROGS(CSHARPCILINTERPRETER, ilrun) else if test "mcs" = "$CSHARPCOMPILER"; then # Check that mcs is the C# compiler and not the Unix mcs utility by examining the output of 'mcs --version' # The Mono compiler should emit: Mono C# compiler version a.b.c.d csharp_version_raw=`(mcs --version) 2>/dev/null` csharp_version_searched=`(mcs --version | sed -e "/C#/b" -e "/Mono/b" -e d) 2>/dev/null` # return string if contains 'Mono' or 'C#' CSHARPCOMPILER="" if test -n "$csharp_version_raw" ; then if test "$csharp_version_raw" = "$csharp_version_searched" ; then CSHARPCOMPILER="mcs" fi fi if test "mcs" != "$CSHARPCOMPILER" ; then echo "mcs is not a working Mono C# compiler" fi fi if test "mcs" = "$CSHARPCOMPILER" || test "gmcs" = "$CSHARPCOMPILER" || test "mono-csc" = "$CSHARPCOMPILER"; then AC_CHECK_PROGS(CSHARPCILINTERPRETER, mono) # Mono JIT CSHARPCILINTERPRETER_FLAGS="--debug" else if test "csc" = "$CSHARPCOMPILER"; then CSHARPPATHSEPARATOR="\\\\" CSHARPCYGPATH_W='cygpath -w' fi fi fi else CSHARPCILINTERPRETER="$CSHARPBIN" fi # Cygwin requires the Windows standard (Pascal) calling convention as it is a Windows executable and not a Cygwin built executable case $host in *-*-cygwin* | *-*-mingw*) if test "$GCC" = yes; then CSHARPDYNAMICLINKING=" -mno-cygwin -mthreads -Wl,--add-stdcall-alias" CSHARPCFLAGS="-mno-cygwin -mthreads" else CSHARPDYNAMICLINKING="" CSHARPCFLAGS="" fi ;; *) CSHARPDYNAMICLINKING="" CSHARPCFLAGS="" ;; esac # CSharp on Windows platforms including Cygwin doesn't use libname.dll, rather name.dll when loading dlls case $host in *-*-cygwin* | *-*-mingw*) CSHARPLIBRARYPREFIX="";; *)CSHARPLIBRARYPREFIX="lib";; esac # C#/Mono on Mac OS X tweaks case $host in *-*-darwin*) CSHARPSO=".so" ;; *) CSHARPSO=$SO ;; esac fi AC_SUBST(CSHARPCILINTERPRETER_FLAGS) AC_SUBST(CSHARPCILINTERPRETER) AC_SUBST(CSHARPPATHSEPARATOR) AC_SUBST(CSHARPCYGPATH_W) AC_SUBST(CSHARPCOMPILER) AC_SUBST(CSHARPDYNAMICLINKING) AC_SUBST(CSHARPLIBRARYPREFIX) # Is this going to be used? AC_SUBST(CSHARPCFLAGS) AC_SUBST(CSHARPSO) #---------------------------------------------------------------- # Look for Lua #---------------------------------------------------------------- LUABIN= LUAINCLUDE= LUALIB= LUADYNAMICLOADLIB= LUAFLAGS= LUALINK= # note: if LUABIN is empty then lua tests will not be done # LUABIN will be cleared if certain dependencies cannot be found AC_ARG_WITH(lua, AS_HELP_STRING([--without-lua], [Disable Lua]) AS_HELP_STRING([--with-lua=path], [Set location of Lua executable]),[ LUABIN="$withval"], [LUABIN=yes]) AC_ARG_WITH(luaincl,[ --with-luaincl=path Set location of Lua include directory],[ LUAINCLUDE="$withval"], [LUAINCLUDE=]) AC_ARG_WITH(lualib,[ --with-lualib=path Set location of Lua library directory],[ LUALIB="$withval"], [LUALIB=]) # First, check for "--without-lua" or "--with-lua=no". if test x"${LUABIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Lua]) else # can we find lua? if test "x$LUABIN" = xyes; then # We look for a versioned Lua binary first, as there can be # multiple versions of Lua installed on some systems (like Debian). # The search order should match the include-file and library search # orders below (a Lua shared library built for one version may not # work with a Lua binary of a different version). AC_PATH_PROGS(LUABIN, [lua5.2 lua5.1 lua]) fi # check version: we need Lua 5.x if test "$LUABIN"; then AC_MSG_CHECKING(Lua version) # if version 5.x LUAV5=`$LUABIN -e 'if string.sub(_VERSION,5,5)=="5" then print "1" end'` # if not version 5.0 LUAV51=`$LUABIN -e 'if string.sub(_VERSION,5,7)~="5.0" then print "1" end'` if test -z "$LUAV5"; then AC_MSG_WARN(Not Lua 5.x, SWIG does not support this version of Lua) LUABIN="" elif test -z "$LUAV51"; then AC_MSG_RESULT(Lua 5.0.x) else AC_MSG_RESULT(Lua 5.1 or later) fi fi if test "$LUABIN"; then AC_MSG_CHECKING(whether Lua dynamic loading is enabled) # using Lua to check Lua # lua 5.0 & 5.1 have different fn names if test -z "$LUAV51"; then LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=loadlib("no_such_lib","") if c~="absent" then print "1" end'` else LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=package.loadlib("no_such_lib","") if c~="absent" then print "1" end'` fi if test -z "$LUADYNAMICLOADLIB"; then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi fi # look for the header files & set LUAFLAGS accordingly # will clear LUABIN if not present if test -n "$LUAINCLUDE"; then AC_CHECK_FILE($LUAINCLUDE/lua.h,[LUAFLAGS="$ISYSTEM$LUAINCLUDE"],[LUABIN=]) else LUA_OK="1" AC_CHECK_HEADER(lua.h,[LUAFLAGS=""],[LUA_OK=""]) # if we didn't get it, going to have to look elsewhere (the hard way) if test -z "$LUA_OK"; then AC_MSG_CHECKING(for lua.h in other locations) # note: Debian/Ubuntu seem to like /usr/include/lua5.1/lua.h # The ordering of the include directories to search should match # the ordering of libraries to search in the library test below. inc=/usr/include dirs="$inc/lua5.2 $inc/lua5.1 $inc/lua51 $inc/lua5.0 $inc/lua50 /usr/local/include" for i in $dirs; do #echo "$i" if test -r $i/lua.h; then AC_MSG_RESULT($i/lua.h) LUAFLAGS="$ISYSTEM$i" break fi done if test -z "$LUAFLAGS"; then AC_MSG_RESULT(not found) LUABIN="" # clear the bin fi fi fi # look for the library files & set LUALINK accordingly # will clear LUABIN if not present lua_save_LIBS=$LIBS # the code seems to disrupt LIBS, so saving if test -n "$LUALIB"; then AC_CHECK_FILE($LUALIB/liblua.a,[LUALINK="-L$LUALIB -llua"],[LUABIN=]) else AC_SEARCH_LIBS(lua_close, [lua lua5.2 lua5.1 lua51 lua5.0 lua50], [LUALINK="-l$ac_lib"],[LUABIN=]) fi # adding lualib for lua 5.0 if test -z "$LUAV51"; then # extra for lua 5.0 LUALINK="$LUALINK -llualib" fi LIBS=$lua_save_LIBS # restore LIBS fi # if not disabled AC_SUBST(LUADYNAMICLINKING) AC_SUBST(LUAFLAGS) AC_SUBST(LUALINK) AC_SUBST(LUABIN) #---------------------------------------------------------------- # Look for Allegro Common Lisp #---------------------------------------------------------------- ALLEGROCLBIN= AC_ARG_WITH(allegrocl, AS_HELP_STRING([--without-allegrocl], [Disable Allegro CL]) AS_HELP_STRING([--with-allegrocl=path], [Set location of Allegro CL executable (alisp)]),[ ALLEGROCLBIN="$withval"], [ALLEGROCLBIN=yes]) # First, check for "--without-allegrocl" or "--with-allegrocl=no". if test x"${ALLEGROCLBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Allegro CL]) ALLEGROCLBIN= else # can we find allegrocl? if test "x$ALLEGROCLBIN" = xyes; then AC_PATH_PROG(ALLEGROCLBIN, alisp) fi fi AC_SUBST(ALLEGROCLBIN) #---------------------------------------------------------------- # Look for GNU CLISP #---------------------------------------------------------------- CLISPBIN= AC_ARG_WITH(clisp, AS_HELP_STRING([--without-clisp], [Disable CLISP]) AS_HELP_STRING([--with-clisp=path], [Set location of CLISP executable (clisp)]),[ CLISPBIN="$withval"], [CLISPBIN=yes]) # First, check for "--without-clisp" or "--with-clisp=no". if test x"${CLISPBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling CLISP]) CLISPBIN= else # can we find clisp? if test "x$CLISPBIN" = xyes; then AC_PATH_PROG(CLISPBIN, clisp) fi fi AC_SUBST(CLISPBIN) #---------------------------------------------------------------- # Look for GNU R #---------------------------------------------------------------- RBIN= AC_ARG_WITH(r, AS_HELP_STRING([--without-r], [Disable R]) AS_HELP_STRING([--with-r=path], [Set location of R executable (r)]),[ RBIN="$withval"], [RBIN=yes]) # First, check for "--without-r" or "--with-r=no". if test x"${RBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling R]) RBIN= else # can we find R? if test "x$RBIN" = xyes; then AC_PATH_PROG(RBIN, R) fi fi AC_SUBST(RBIN) #---------------------------------------------------------------- # Look for Go compilers #---------------------------------------------------------------- AC_ARG_WITH(go, AS_HELP_STRING([--without-go], [Disable Go]) AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval"], [GOBIN=yes]) if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Go]) GO= GOC= GO1=false GO12=false GO13=false GOGCC=false GOOPT= GOVERSIONOPTION= else if test "x$GOBIN" = xyes; then AC_CHECK_PROGS(GO, go 6g 8g gccgo) else GO="$GOBIN" fi GOGCC=false GO1=false GO12=false GO13=false GOOPT= GOVERSIONOPTION= if test -n "$GO" ; then if $GO --help 2>/dev/null | grep gccgo >/dev/null 2>&1 ; then GOGCC=true GOVERSIONOPTION=--version AC_MSG_CHECKING([whether gccgo version is too old]) go_version=[`$GO $GOVERSIONOPTION | sed -n '1p' | sed -e 's/^.* \([0-9.]*\) *$/\1/' -e 's/[.]//g'`] if test "x$go_version" = x; then AC_MSG_RESULT([could not determine gccgo version - disabling Go]) GO= elif test "$go_version" -lt 470; then AC_MSG_RESULT([yes - minimum version is 4.7.0]) GO= else AC_MSG_RESULT([no]) if test "$go_version" -lt 480; then GOOPT="-intgosize 32" else AC_CHECK_SIZEOF([void *], [4]) if test "$ac_cv_sizeof_void_p" = "8"; then GOOPT="-intgosize 64" else GOOPT="-intgosize 32" fi fi fi elif test "`echo $GO | sed -e 's|.*/||'`" = "go"; then GO1=true GOVERSIONOPTION=version GOC=$(sh -c "$(go env) && echo \$GOCHAR")c go_version=$($GO $GOVERSIONOPTION | sed -e 's/go version //') case $go_version in go1.0*) GOOPT="-intgosize 32" ;; *) if test "$GOC" = "6c"; then GOOPT="-intgosize 64" else GOOPT="-intgosize 32" fi ;; esac case $go_version in go1.0* | go1.1*) GOOPT="$GOOPT -use-shlib" ;; go1.2*) GO12=true ;; *) GO13=true ;; esac else GOC=`echo $GO | sed -e 's/g/c/'` GOVERSIONOPTION=-V AC_MSG_CHECKING([whether Go ($GO) version is too old]) go_version=`$GO $GOVERSIONOPTION 2>/dev/null | sed -e 's/.*version.* \([[0-9]]*\).*/\1/'` go_min_version=7077 if test "$go_version" != "" -a "$go_version" -lt $go_min_version; then AC_MSG_RESULT([yes - minimum version is $go_min_version]) GO= else AC_MSG_RESULT([no]) fi GOOPT="-intgosize 32" GO12=false GO13=false fi fi fi AC_SUBST(GOGCC) AC_SUBST(GO) AC_SUBST(GOC) AC_SUBST(GO1) AC_SUBST(GO12) AC_SUBST(GO13) AC_SUBST(GOOPT) AC_SUBST(GOVERSIONOPTION) #---------------------------------------------------------------- # Look for D #---------------------------------------------------------------- AC_ARG_WITH(d, AS_HELP_STRING([--without-d], [Disable D]), [with_d="$withval"], [with_d=yes]) AC_ARG_WITH(d1-compiler, [ --with-d1-compiler=path Set location of D1/Tango compiler (DMD compatible)],[D1COMPILERBIN="$withval"], [D1COMPILERBIN=]) AC_ARG_WITH(d2-compiler, [ --with-d2-compiler=path Set location of D2 compiler (DMD compatible)],[D2COMPILERBIN="$withval"], [D2COMPILERBIN=]) # First, check for "--without-d" or "--with-d=no". if test x"${with_d}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling D]) D1COMPILER= D2COMPILER= else old_ac_ext=$ac_ext ac_ext=d if test -z "$D1COMPILERBIN" ; then AC_CHECK_PROGS(D1COMPILER, dmd ldmd gdmd) if test -n "$D1COMPILER" ; then AC_MSG_CHECKING(whether the D1/Tango compiler works) cat > conftest.$ac_ext <<_ACEOF import tango.io.Stdout; void main() { } _ACEOF rm -f conftest.$ac_objext AS_IF( [_AC_DO_STDERR($D1COMPILER conftest.$ac_ext) && test ! -s conftest.err && test -s conftest.$ac_objext], [AC_MSG_RESULT([yes])], [_AC_MSG_LOG_CONFTEST AC_MSG_RESULT([no]) D1COMPILER=] ) rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi else D1COMPILER="$D1COMPILERBIN" fi if test -z "$D2COMPILERBIN" ; then AC_CHECK_PROGS(D2COMPILER, dmd gdmd) if test -n "$D2COMPILER" ; then AC_MSG_CHECKING(whether the D2 compiler works) cat > conftest.$ac_ext <<_ACEOF import std.algorithm; void main() { } _ACEOF rm -f conftest.$ac_objext AS_IF( [_AC_DO_STDERR($D2COMPILER conftest.$ac_ext) && test ! -s conftest.err && test -s conftest.$ac_objext], [AC_MSG_RESULT([yes])], [_AC_MSG_LOG_CONFTEST AC_MSG_RESULT([no]) D2COMPILER=] ) rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi else D2COMPILER="$D2COMPILERBIN" fi ac_ext=$old_ac_ext fi if test -n "$D1COMPILER"; then DDEFAULTVERSION=1 elif test -n "$D2COMPILER"; then DDEFAULTVERSION=2 fi # Do not prefix library file names with "lib" on Windows. case $host in *-*-cygwin* | *-*-mingw*) DLIBPREFIX="";; *)DLIBPREFIX="lib";; esac AC_SUBST(D1COMPILER) AC_SUBST(D2COMPILER) AC_SUBST(DDEFAULTVERSION) AC_SUBST(DLIBPREFIX) #---------------------------------------------------------------- # Determine which languages to use for examples/test-suite #---------------------------------------------------------------- SKIP_TCL= if test -z "$TCLINCLUDE" || test -z "$TCLLIB" ; then SKIP_TCL="1" fi AC_SUBST(SKIP_TCL) SKIP_PERL5= if test -z "$PERL" || test -z "$PERL5EXT" || test -z "$PERL5TESTMORE"; then SKIP_PERL5="1" fi AC_SUBST(SKIP_PERL5) SKIP_OCTAVE= if test -z "$OCTAVE" ; then SKIP_OCTAVE="1" fi AC_SUBST(SKIP_OCTAVE) SKIP_PYTHON= if (test -z "$PYINCLUDE") && (test -z "$PY3INCLUDE") ; then SKIP_PYTHON="1" fi AC_SUBST(SKIP_PYTHON) SKIP_PYTHON3= if test -z "$PY3INCLUDE" ; then SKIP_PYTHON3="1" fi AC_SUBST(SKIP_PYTHON3) SKIP_JAVA= if test -z "$JAVA" || test -z "$JAVAC" || test -z "$JAVAINC" ; then SKIP_JAVA="1" fi AC_SUBST(SKIP_JAVA) SKIP_JAVASCRIPT= if test -z "$JAVASCRIPT" || ( test -z "$NODEJS" && test -z "$JSCENABLED" && test -z "$JSV8ENABLED" ) ; then SKIP_JAVASCRIPT="1" fi AC_SUBST(SKIP_JAVASCRIPT) SKIP_GUILE= if test -z "$GUILE" || test -z "$GUILE_LIBS" ; then SKIP_GUILE="1" fi AC_SUBST(SKIP_GUILE) SKIP_MZSCHEME= if test -z "$MZC" || test -z "$MZDYNOBJ" ; then SKIP_MZSCHEME="1" fi AC_SUBST(SKIP_MZSCHEME) SKIP_RUBY= if test -z "$RUBY" || test -z "$RUBYINCLUDE" || test -z "$RUBYLIB" ; then SKIP_RUBY="1" fi AC_SUBST(SKIP_RUBY) SKIP_PHP= if test -z "$PHP" || test -z "$PHPINC" ; then SKIP_PHP="1" fi AC_SUBST(SKIP_PHP) SKIP_OCAML= if test -z "$OCAMLBIN" || test -z "$OCAMLINC" ; then SKIP_OCAML="1" fi AC_SUBST(SKIP_OCAML) SKIP_PIKE= if test -z "$PIKE" || test -z "$PIKEINCLUDE" ; then SKIP_PIKE="1" fi AC_SUBST(SKIP_PIKE) SKIP_CHICKEN= if test -z "$CHICKEN_CSC" || test -z "$CHICKEN"; then SKIP_CHICKEN="1" fi AC_SUBST(SKIP_CHICKEN) SKIP_CSHARP= if test -z "$CSHARPCOMPILER" ; then SKIP_CSHARP="1" else if test "cscc" = "$CSHARPCOMPILER" && test -z "$CSHARPCILINTERPRETER" ; then SKIP_CSHARP="1" fi fi AC_SUBST(SKIP_CSHARP) SKIP_MODULA3="1" # Always skipped! AC_SUBST(SKIP_MODULA3) SKIP_LUA= # we need LUABIN & dynamic loading if test -z "$LUABIN" || test -z "$LUADYNAMICLOADLIB"; then SKIP_LUA="1" fi AC_SUBST(SKIP_LUA) SKIP_ALLEGROCL= if test -z "$ALLEGROCLBIN" ; then SKIP_ALLEGROCL="1" fi AC_SUBST(SKIP_ALLEGROCL) SKIP_CLISP= if test -z "$CLISPBIN" ; then SKIP_CLISP="1" fi AC_SUBST(SKIP_CLISP) SKIP_R= if test -z "$RBIN" ; then SKIP_R="1" fi AC_SUBST(SKIP_R) SKIP_CFFI= #if test -z "$CFFIBIN" ; then SKIP_CFFI="1" #fi AC_SUBST(SKIP_CFFI) SKIP_UFFI= #if test -z "$UFFIBIN" ; then SKIP_UFFI="1" #fi AC_SUBST(SKIP_UFFI) SKIP_GO= if test -z "$GO" ; then SKIP_GO="1" fi AC_SUBST(SKIP_GO) SKIP_D= if test -z "$DDEFAULTVERSION" ; then SKIP_D="1" fi AC_SUBST(SKIP_D) #---------------------------------------------------------------- # Additional language dependencies #---------------------------------------------------------------- SKIP_GCJ= if test -z "$GCJ" || test -z "$GCJH" ; then SKIP_GCJ="1" else if test "$GCC" != yes; then SKIP_GCJ="1" fi fi AC_SUBST(SKIP_GCJ) SKIP_ANDROID= if test -z "$ANDROID" || test -z "$ADB" || test -z "$ANT" || test -z "$NDKBUILD" ; then SKIP_ANDROID="1" fi AC_SUBST(SKIP_ANDROID) #---------------------------------------------------------------- # Miscellaneous #---------------------------------------------------------------- # Root directory # Translate path for native Windows compilers for use with 'make check' ROOT_DIR=`pwd` case $host in *-*-cygwin* | *-*-mingw*) if (cygpath --mixed $ROOT_DIR) >/dev/null 2>/dev/null; then ROOT_DIR=`cygpath --mixed $ROOT_DIR` fi # Extra files generated by some Windows compilers EXTRA_CLEAN="*.stackdump *.exp *.lib *.pdb *.ilk" ;; esac AC_SUBST(ROOT_DIR) AC_SUBST(EXTRA_CLEAN) AC_SUBST(ac_aux_dir) # Configure SWIG_LIB path AC_ARG_WITH(swiglibdir,[ --with-swiglibdir=DIR Put SWIG system-independent libraries into DIR.], [swig_lib="$withval"], [swig_lib="${datadir}/swig/${PACKAGE_VERSION}"]) AC_SUBST(swig_lib) AC_DEFINE_DIR(SWIG_LIB, swig_lib, [Directory for SWIG system-independent libraries]) case $build in # Windows does not understand unix directories. Convert into a windows directory with drive letter. *-*-mingw*) SWIG_LIB_WIN_UNIX=`cmd //c echo $SWIG_LIB | sed -e "s/[ ]*$//"`;; # This echo converts unix to mixed paths. Then zap unexpected trailing space. *-*-cygwin*) SWIG_LIB_WIN_UNIX=`cygpath --mixed "$SWIG_LIB"`;; *) SWIG_LIB_WIN_UNIX="";; esac AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, ["$SWIG_LIB_WIN_UNIX"], [Directory for SWIG system-independent libraries (Unix install on native Windows)]) AC_CONFIG_FILES([ Makefile swig.spec Examples/Makefile Examples/xml/Makefile Examples/test-suite/errors/Makefile Examples/test-suite/chicken/Makefile Examples/test-suite/csharp/Makefile Examples/test-suite/d/Makefile Examples/test-suite/guile/Makefile Examples/test-suite/java/Makefile Examples/test-suite/javascript/Makefile Examples/test-suite/mzscheme/Makefile Examples/test-suite/ocaml/Makefile Examples/test-suite/octave/Makefile Examples/test-suite/perl5/Makefile Examples/test-suite/php/Makefile Examples/test-suite/pike/Makefile Examples/test-suite/python/Makefile Examples/test-suite/ruby/Makefile Examples/test-suite/tcl/Makefile Examples/test-suite/lua/Makefile Examples/test-suite/allegrocl/Makefile Examples/test-suite/clisp/Makefile Examples/test-suite/cffi/Makefile Examples/test-suite/uffi/Makefile Examples/test-suite/r/Makefile Examples/test-suite/go/Makefile Source/Makefile Tools/javascript/Makefile ]) AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig]) AC_CONFIG_FILES([CCache/ccache_swig_config.h]) #-------------------------------------------------------------------- # Building Examples/ out of source directory #-------------------------------------------------------------------- # If building out of source tree, replicate Examples/ source tree in # build directory, and copy over Makefiles from source directory. # Prefix each Makefile with a header which sets SRCDIR to the relative # source directory, and provides a rule for updating the Makefile from # its original source. AC_CONFIG_COMMANDS([Examples],[ if test "x${srcdir}" != "x." ; then AC_MSG_NOTICE([generating Examples build tree]) for mkfile in `cd ${srcdir} && find Examples/ -type f -name Makefile`; do dir=`dirname ${mkfile}` d=${dir} reldir=""; while test "x$d" != "x." ; do d=`dirname $d` reldir="${reldir}../" done relsrcdir=${reldir}${srcdir}/ AS_MKDIR_P([${dir}]) cat <${mkfile} # DO NOT EDIT: instead edit ${relsrcdir}${mkfile} # and run (cd ${reldir} && ./config.status) to regenerate SRCDIR = ${relsrcdir}${dir}/ EOF cat ${srcdir}/${mkfile} >>${mkfile} done fi ]) #-------------------------------------------------------------------- AC_OUTPUT langs="" test -n "$SKIP_ALLEGROCL" || langs="${langs}allegrocl " test -n "$SKIP_CFFI" || langs="${langs}cffi " test -n "$SKIP_CHICKEN" || langs="${langs}chicken " test -n "$SKIP_CLISP" || langs="${langs}clisp " test -n "$SKIP_CSHARP" || langs="${langs}csharp " test -n "$SKIP_D" || langs="${langs}d " test -n "$SKIP_GO" || langs="${langs}go " test -n "$SKIP_GUILE" || langs="${langs}guile " test -n "$SKIP_JAVA" || langs="${langs}java " test -n "$SKIP_JAVASCRIPT" || langs="${langs}javascript " test -n "$SKIP_LUA" || langs="${langs}lua " test -n "$SKIP_MODULA3" || langs="${langs}modula3 " test -n "$SKIP_MZSCHEME" || langs="${langs}mzscheme " test -n "$SKIP_OCAML" || langs="${langs}ocaml " test -n "$SKIP_OCTAVE" || langs="${langs}octave " test -n "$SKIP_PERL5" || langs="${langs}perl5 " test -n "$SKIP_PHP" || langs="${langs}php " test -n "$SKIP_PIKE" || langs="${langs}pike " test -n "$SKIP_PYTHON" || langs="${langs}python " test -n "$SKIP_R" || langs="${langs}r " test -n "$SKIP_RUBY" || langs="${langs}ruby " test -n "$SKIP_TCL" || langs="${langs}tcl " test -n "$SKIP_UFFI" || langs="${langs}uffi " echo " The SWIG test-suite and examples are configured for the following languages: $langs " dnl configure.ac ends here swig-3.0.2/RELEASENOTES0000664000175000017500000003717512343605122014174 0ustar williamwilliamThis file contains a brief overview of the changes made in each release. A detailed description of changes are available in the CHANGES.current and CHANGES files. Release Notes ============= SWIG-3.0.2 summary: - Bug fix during install and a couple of other minor changes. SWIG-3.0.1 summary: - Javascript module added. This supports JavascriptCore (Safari/Webkit), v8 (Chromium) and node.js currently. - A few notable regressions introduced in 3.0.0 have been fixed - in Lua, nested classes and parsing of operator <<. - The usual round of bug fixes and minor improvements for: C#, GCJ, Go, Java, Lua, PHP and Python. SWIG-3.0.0 summary: - This is a major new release focusing primarily on C++ improvements. - C++11 support added. Please see documentation for details of supported features: http://www.swig.org/Doc3.0/CPlusPlus11.html - Nested class support added. This has been taken full advantage of in Java and C#. Other languages can use the nested classes, but require further work for a more natural integration into the target language. We urge folk knowledgeable in the other target languages to step forward and help with this effort. - Lua: improved metatables and support for %nspace. - Go 1.3 support added. - Python import improvements including relative imports. - Python 3.3 support completed. - Perl director support added. - C# .NET 2 support is now the minimum. Generated using statements are replaced by fully qualified names. - Bug fixes and improvements to the following languages: C#, Go, Guile, Java, Lua, Perl, PHP, Python, Octave, R, Ruby, Tcl - Various other bug fixes and improvements affecting all languages. - Note that this release contains some backwards incompatible changes in some languages. - Full detailed release notes are in the changes file. SWIG-2.0.12 summary: - This is a maintenance release backporting some fixes from the pending 3.0.0 release. - Octave 3.8 support added. - C++11 support for new versions of erase/insert in the STL containers. - Compilation fixes on some systems for the generated Lua, PHP, Python and R wrappers. SWIG-2.0.11 summary: - Minor bug fixes and enhancements mostly in Python, but also C#, Lua, Ocaml, Octave, Perl, PHP, Python, R, Ruby, Tcl. SWIG-2.0.10 summary: - Ruby 1.9 support is now complete. - Add support for Guile 2.0 and Guile 1.6 support (GH interface) has been dropped. - Various small language neutral improvements and fixes. - Various bug fixes and minor improvements specific to C#, CFFI, D, Java, Octave, PHP, Python, - Minor bug fix in ccache-swig. - Development has moved to Github with Travis continuous integration testing - patches using https://github.com/swig/swig are welcome. SWIG-2.0.9 summary: - Improved typemap matching. - Ruby 1.9 support is much improved. - Various bug fixes and minor improvements in C#, CFFI, Go, Java, Modula3, Octave, Perl, Python, R, Ruby, Tcl and in ccache-swig. SWIG-2.0.8 summary: - Fix a couple of regressions introduced in 2.0.5 and 2.0.7. - Improved using declarations and using directives support. - Minor fixes/enhancements for C#, Java, Octave, Perl and Python. SWIG-2.0.7 summary: - Important regression fixes since 2.0.5 for typemaps in general and in Python. - Fixes and enhancements for Go, Java, Octave and PHP. SWIG-2.0.6 summary: - Regression fix for Python STL wrappers on some systems. SWIG-2.0.5 summary: - Official Android support added including documentation and examples. - Improvements involving templates: 1) Various fixes with templates and typedef types. 2) Some template lookup problems fixed. 3) Templated type fixes to use correct typemaps. - Autodoc documentation generation improvements. - Python STL container wrappers improvements including addition of stepped slicing. - Approximately 70 fixes and minor enhancements for the following target languages: AllegroCL, C#, D, Go, Java, Lua, Ocaml, Octave, Perl, PHP, Python, R, Ruby, Tcl, Xml. SWIG-2.0.4 summary: - This is mainly a Python oriented release including support for Python built-in types for superior performance with the new -builtin option. The -builtin option is especially suitable for performance-critical libraries and applications that call wrapped methods repeatedly. See the python-specific chapter of the SWIG manual for more info. - Python 3.2 support has also been added and various Python bugs have been fixed. - Octave 3.4 support has also been added. - There are also the usual minor generic improvements, as well as bug fixes and enhancements for D, Guile, Lua, Octave, Perl and Tcl. SWIG-2.0.3 summary: - A bug fix release including a couple of fixes for regressions in the 2.0 series. SWIG-2.0.2 summary: - Support for the D language has been added. - Various bug fixes and minor enhancements. - Bug fixes particular to the Clisp, C#, Go, MzScheme, Ocaml, PHP, R, Ruby target languages. SWIG-2.0.1 summary: - Support for the Go language has been added. - New regular expression (regex) encoder for renaming symbols based on the Perl Compatible Regular Expressions (PCRE) library. - Numerous fixes in reporting file and line numbers in error and warning messages. - Various bug fixes and improvements in the C#, Lua, Perl, PHP, Ruby and Python language modules. SWIG-2.0.0 summary: - License changes, see LICENSE file and http://www.swig.org/legal.html. - Much better nested class/struct support. - Much improved template partial specialization and explicit specialization handling. - Namespace support improved with the 'nspace' feature where namespaces can be automatically translated into Java packages or C# namespaces. - Improved typemap and symbol table debugging. - Numerous subtle typemap matching rule changes when using the default (SWIGTYPE) type. These now work much like C++ class template partial specialization matching. - Other small enhancements for typemaps. Typemap fragments are also now official and documented. - Warning and error display refinements. - Wrapping of shared_ptr is improved and documented now. - Numerous C++ unary scope operator (::) fixes. - Better support for boolean expressions. - Various bug fixes and improvements in the Allegrocl, C#, Java, Lua, Octave, PHP, Python, R, Ruby and XML modules. SWIG-1.3.40 summary: - SWIG now supports directors for PHP. - PHP support improved in general. - Octave 3.2 support added. - Various bug fixes/enhancements for Allegrocl, C#, Java, Octave, Perl, Python, Ruby and Tcl. - Other generic fixes and minor new features. SWIG-1.3.39 summary: - Some new small feature enhancements. - Improved C# std::vector wrappers. - Bug fixes: mainly Python, but also Perl, MzScheme, CFFI, Allegrocl and Ruby SWIG-1.3.38 summary: - Output directory regression fix and other minor bug fixes SWIG-1.3.37 summary: - Python 3 support added - SWIG now ships with a version of ccache that can be used with SWIG. This enables the files generated by SWIG to be cached so that repeated use of SWIG on unchanged input files speeds up builds quite considerably. - PHP 4 support removed and PHP support improved in general - Improved C# array support - Numerous Allegro CL improvements - Bug fixes/enhancements for Python, PHP, Java, C#, Chicken, Allegro CL, CFFI, Ruby, Tcl, Perl, R, Lua. - Other minor generic bug fixes and enhancements SWIG-1.3.36 summary: - Enhancement to directors to wrap all protected members - Optimisation feature for objects returned by value - A few bugs fixes in the PHP, Java, Ruby, R, C#, Python, Lua and Perl modules - Other minor generic bug fixes SWIG-1.3.35 summary: - Octave language module added - Bug fixes in Python, Lua, Java, C#, Perl modules - A few other generic bugs and runtime assertions fixed SWIG-1.3.34 summary: - shared_ptr support for Python - Support for latest R - version 2.6 - Various minor improvements/bug fixes for R, Lua, Python, Java, C# - A few other generic bug fixes, mainly for templates and using statements SWIG-1.3.33 summary: - Fix regression for Perl where C++ wrappers would not compile - Fix regression parsing macros SWIG-1.3.32 summary: - shared_ptr support for Java and C# - Enhanced STL support for Ruby - Windows support for R - Fixed long-standing memory leak in PHP Module - Numerous fixes and minor enhancements for Allegrocl, C#, cffi, Chicken, Guile, Java, Lua, Ocaml, Perl, PHP, Python, Ruby, Tcl. - Improved warning support SWIG-1.3.31 summary: - Python modern classes regression fix SWIG-1.3.30 summary: - Python-2.5 support - New language module: R - Director support added for C# - Numerous director fixes and improvements - Improved mingw/msys support - Better constants support in Guile and chicken modules - Support for generating PHP5 class wrappers - Important Java premature garbage collection fix - Minor improvements/fixes in cffi, php, allegrocl, perl, chicken, lua, ruby, ocaml, python, java, c# and guile language modules - Many many other bug fixes SWIG-1.3.29 summary: - Numerous important bug fixes - Few minor new features - Some performance improvements in generated code for Python SWIG-1.3.28 summary: - More powerful renaming (%rename) capability. - More user friendly warning handling. - Add finer control for default constructors and destructors. We discourage the use of the 'nodefault' option, which disables both constructors and destructors, leading to possible memory leaks. Use instead 'nodefaultctor' and/or 'nodefaultdtor'. - Automatic copy constructor wrapper generation via the 'copyctor' option/feature. - Better handling of Windows extensions and types. - Better runtime error reporting. - Add the %catches directive to catch and dispatch exceptions. - Add the %naturalvar directive for more 'natural' variable wrapping. - Better default handling of std::string variables using the %naturalvar directive. - Add the %allowexcept and %exceptionvar directives to handle exceptions when accessing a variable. - Add the %delobject directive to mark methods that act like destructors. - Add the -fastdispatch option to enable smaller and faster overload dispatch mechanism. - Template support for %rename, %feature and %typemap improved. - Add/doc more debug options, such as -dump_module, -debug_typemaps, etc. - Unified typemap library (UTL) potentially providing core typemaps for all scripting languages based on the recently evolving Python typemaps. - New language module: Common Lisp with CFFI. - Python, Ruby, Perl and Tcl use the new UTL, many old reported and hidden errors with typemaps are now fixed. - Initial Java support for languages using the UTL via GCJ, you can now use Java libraries in your favorite script language using gcj + swig. - Tcl support for std::wstring. - PHP4 module update, many error fixes and actively maintained again. - Allegrocl support for C++, also enhanced C support. - Ruby support for bang methods. - Ruby support for user classes as native exceptions. - Perl improved dispatching in overloaded functions via the new cast and rank mechanism. - Perl improved backward compatibility, 5.004 and later tested and working. - Python improved backward compatibility, 1.5.2 and later tested and working. - Python can use the same cast/rank mechanism via the -castmode option. - Python implicit conversion mechanism similar to C++, via the %implicitconv directive (replaces and improves the implicit.i library). - Python threading support added. - Python STL support improved, iterators are supported and STL containers can use now the native PyObject type. - Python many performance options and improvements, try the -O option to test all of them. Python runtime benchmarks show up to 20 times better performance compared to 1.3.27 and older versions. - Python support for 'multi-inheritance' on the python side. - Python simplified proxy classes, now swig doesn't need to generate the additional 'ClassPtr' classes. - Python extended support for smart pointers. - Python better support for static member variables. - Python backward compatibility improved, many projects that used to work only with swig-1.3.21 to swig-1.3.24 are working again with swig-1.3.28 - Python test-suite is now 'valgrinded' before release, and swig also reports memory leaks due to missing destructors. - Minor bug fixes and improvements to the Lua, Ruby, Java, C#, Python, Guile, Chicken, Tcl and Perl modules. SWIG-1.3.27 summary: - Fix bug in anonymous typedef structures which was leading to strange behaviour SWIG-1.3.26 summary: - New language modules: Lua, CLISP and Common Lisp with UFFI. - Big overhaul to the PHP module. - Change to the way 'extern' is handled. - Minor bug fixes specific to C#, Java, Modula3, Ocaml, Allegro CL, XML, Lisp s-expressions, Tcl, Ruby and Python modules. - Other minor improvements and bug fixes. SWIG-1.3.25 summary: - Improved runtime type system. Speed of module loading improved in modules with lots of types. SWIG_RUNTIME_VERSION has been increased from 1 to 2, but the API is exactly the same; only internal changes were made. - The languages that use the runtime type system now support external access to the runtime type system. - Various improvements with typemaps and template handling. - Fewer warnings in generated code. - Improved colour documentation. - Many C# module improvements (exception handling, prevention of early garbage collection, C# attributes support added, more flexible type marshalling/asymmetric types.) - Minor improvements and bug fixes specific to the C#, Java, TCL, Guile, Chicken, MzScheme, Perl, Php, Python, Ruby and Ocaml modules). - Various other bug fixes and memory leak fixes. SWIG-1.3.24 summary: - Improved enum handling - More runtime library options - More bugs fixes for templates and template default arguments, directors and other areas. - Better smart pointer support, including data members, static members and %extend. SWIG-1.3.23 summary: - Improved support for callbacks - Python docstring support and better error handling - C++ default argument support for Java and C# added. - Improved c++ default argument support for the scripting languages plus option to use original (compact) default arguments. - %feature and %ignore/%rename bug fixes and mods - they might need default arguments specified to maintain compatible behaviour when using the new default arguments wrapping. - Runtime library changes: Runtime code can now exist in more than one module and so need not be compiled into just one module - Further improved support for templates and namespaces - Overloaded templated function support added - More powerful default typemaps (mixed default typemaps) - Some important %extend and director code bug fixes - Guile now defaults to using SCM API. The old interface can be obtained by the -gh option. - Various minor improvements and bug fixes for C#, Chicken, Guile, Java, MzScheme, Perl, Python and Ruby - Improved dependencies generation for constructing Makefiles. SWIG-1.3.22 summary: - Improved exception handling and translation of C errors or C++ exceptions into target language exceptions. - Improved enum support, mapping to built-in Java 1.5 enums and C# enums or the typesafe enum pattern for these two languages. - Python - much better STL suppport and support for std::wstring, wchar_t and FILE *. - Initial support for Modula3 and Allegro CL. - 64 bit TCL support. - Java and C#'s proxy classes are now nearly 100% generated from typemaps and/or features for finer control on the generated code. - SWIG runtime library support deprecation. - Improved documentation. SWIG now additionally provides documentation in the form of a single HTML page as well as a pdf document. - Enhanced C++ friend declaration support. - Better support for reference counted classes. - Various %fragment improvements. - RPM fixes. - Various minor improvements and bug fixes for C#, Chicken, Guile, Java, MzScheme, Perl, Php, Python, Ruby and XML. swig-3.0.2/README0000664000175000017500000001202512343605122013223 0ustar williamwilliamSWIG (Simplified Wrapper and Interface Generator) Version: 3.0.2 (4 Jun 2014) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme (Guile, MzScheme/Racket, CHICKEN), Ocaml, Modula-3, Common Lisp (CLISP, Allegro CL, CFFI, UFFI) and Pike. SWIG can also export its parse tree into Lisp s-expressions and XML. SWIG reads annotated C/C++ header files and creates wrapper code (glue code) in order to make the corresponding C/C++ libraries available to the listed languages, or to extend C/C++ programs with a scripting language. Up-to-date SWIG related information can be found at http://www.swig.org A SWIG FAQ and other hints can be found on the SWIG Wiki: http://www.dabeaz.com/cgi-bin/wiki.pl License ======= Please see the LICENSE file for details of the SWIG license. For further insight into the license including the license of SWIG's output code, please visit http://www.swig.org/legal.html Release Notes ============= Please see the CHANGES.current file for a detailed list of bug fixes and new features for the current release. The CHANGES file contains bug fixes and new features for older versions. A summary of changes in each release can be found in the RELEASENOTES file. Documentation ============= The Doc/Manual directory contains the most recent set of updated documentation for this release. The documentation is available in three different formats, each of which contains identical content. These format are, pdf (Doc/Manual/SWIGDocumentation.pdf), single page html (Doc/Manual/SWIGDocumentation.html) or multiple page html (other files in Doc/Manual). Please select your chosen format and copy/install to wherever takes your fancy. There is some technical developer documentation available in the Doc/Devel subdirectory. This is not necessarily up-to-date, but it has some information on SWIG internals. Documentation is also online at http://www.swig.org/doc.html. Backwards Compatibility ======================= The developers strive their best to preserve backwards compatibility between releases, but this is not always possible as the overriding aim is to provide the best wrapping experience. Where backwards compatibility is known to be broken, it is clearly marked as an incompatibility in the CHANGES and CHANGES.current files. See the documentation for details of the SWIG_VERSION preprocessor symbol if you have backward compatibility issues and need to use more than one version of SWIG. Installation ============ Please read the Doc/Manual/Preface.html#Preface_installation for full installation instructions for Windows, Unix and Mac OS X. The INSTALL file has generic build and installation instructions for Unix users. Testing ======= The typical 'make -k check' can be performed on Unix operating systems. Please read Doc/Manual/Preface.html#Preface_testing for details. Examples ======== The Examples directory contains a variety of examples of using SWIG and it has some browsable documentation. Simply point your browser to the file "Example/index.html". The Examples directory also includes Visual C++ project 6 (.dsp) files for building some of the examples on Windows. Later versions of Visual Studio will convert these old style project files into a current solution file. Known Issues ============ There are minor known bugs, details of which are in the bug tracker, see http://www.swig.org/bugs.html. Troubleshooting =============== In order to operate correctly, SWIG relies upon a set of library files. If after building SWIG, you get error messages like this, $ swig foo.i :1. Unable to find 'swig.swg' :3. Unable to find 'tcl8.swg' it means that SWIG has either been incorrectly configured or installed. To fix this: 1. Make sure you remembered to do a 'make install' and that the installation actually worked. Make sure you have write permission on the install directory. 2. If that doesn't work, type 'swig -swiglib' to find out where SWIG thinks its library is located. 3. If the location is not where you expect, perhaps you supplied a bad option to configure. Use ./configure --prefix=pathname to set the SWIG install location. Also, make sure you don't include a shell escape character such as ~ when you specify the path. 4. The SWIG library can be changed by setting the SWIG_LIB environment variable. However, you really shouldn't have to do this. If you are having other troubles, you might look at the SWIG Wiki at http://www.dabeaz.com/cgi-bin/wiki.pl. Participate! ============ Please report any errors and submit patches (if possible)! We only have access to a limited variety of hardware (Linux, Solaris, OS-X, and Windows). All contributions help. If you would like to join the SWIG development team or contribute a language module to the distribution, please contact the swig-devel mailing list, details at http://www.swig.org/mail.html. -- The SWIG Maintainers swig-3.0.2/.travis.yml0000664000175000017500000001502712343605122014461 0ustar williamwilliamlanguage: cpp compiler: - clang - gcc env: - SWIGLANG= matrix: include: - compiler: gcc env: SWIGLANG=csharp - compiler: gcc env: SWIGLANG=go - compiler: gcc env: SWIGLANG=guile - compiler: gcc env: SWIGLANG=java - compiler: gcc env: SWIGLANG=javascript ENGINE=node - compiler: gcc env: SWIGLANG=javascript ENGINE=jsc - compiler: gcc env: SWIGLANG=javascript ENGINE=v8 - compiler: gcc env: SWIGLANG=lua - compiler: gcc env: SWIGLANG=octave SWIGJOBS=-j4 - compiler: gcc env: SWIGLANG=perl5 - compiler: gcc env: SWIGLANG=php - compiler: gcc env: SWIGLANG=python VER=2.4 - compiler: gcc env: SWIGLANG=python VER=2.5 - compiler: gcc env: SWIGLANG=python VER=2.6 - compiler: gcc env: SWIGLANG=python # 2.7 - compiler: gcc env: SWIGLANG=python PY3=3 # 3.2 - compiler: gcc env: SWIGLANG=python PY3=3 VER=3.3 - compiler: gcc env: SWIGLANG=python PY3=3 VER=3.4 - compiler: gcc env: SWIGLANG=ruby - compiler: gcc env: SWIGLANG=tcl allow_failures: # None before_install: - date -u - uname -a - lsb_release -a - sudo apt-get -qq update - time sudo apt-get -qq install libboost-dev - 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" = "go"; then go env | sed -e 's/^/export /' > goenvsetup && source goenvsetup && rm -f goenvsetup; fi # Until configure.ac is fixed - if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "node"; then sudo apt-get install -qq rlwrap python-software-properties && echo 'yes' | sudo add-apt-repository ppa:chris-lea/node.js && sudo apt-get -qq update && sudo apt-get install -qq nodejs && sudo npm install -g node-gyp; fi - if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "jsc"; then sudo apt-get install -qq libwebkitgtk-dev; fi - if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "v8"; then sudo apt-get install -qq libv8-dev; fi - if test "$SWIGLANG" = "guile"; then sudo apt-get -qq install guile-2.0-dev; fi - if test "$SWIGLANG" = "lua"; then sudo apt-get -qq install lua5.1 liblua5.1-dev; fi - if test "$SWIGLANG" = "octave"; then sudo apt-get -qq install octave3.2 octave3.2-headers; fi - if test "$SWIGLANG" = "php"; then sudo apt-get install php5-cli php5-dev; fi - if test "$SWIGLANG" = "python" -a "$PY3" -a -z "$VER"; then sudo apt-get install -qq python3-dev; fi - if test "$SWIGLANG" = "python" -a "$VER"; then sudo add-apt-repository -y ppa:fkrull/deadsnakes && sudo apt-get -qq update && sudo apt-get -qq install python${VER}-dev && export CONFIGOPTS="--with-python${PY3}=python${VER}"; fi - if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic. - declare -A CFLAGS_EXAMPLES && CFLAGS_EXAMPLES=( ["csharp"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["go"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["guile"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["java"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["javascript"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["lua"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["octave"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["perl5"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["php"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["python"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["ruby"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["tcl"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ) - declare -A CXXFLAGS_EXAMPLES && CXXFLAGS_EXAMPLES=( ["csharp"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["go"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["guile"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["java"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["javascript"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["lua"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["octave"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["perl5"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ["php"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["python"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["ruby"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type" ["tcl"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type" ) - $CC --version - $CXX --version script: - echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r' - ./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' - if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples CFLAGS="${CFLAGS_EXAMPLES[$SWIGLANG]}" CXXFLAGS="${CXXFLAGS_EXAMPLES[$SWIGLANG]}"; fi - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi - echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r' - make check-maintainer-clean && ../../configure $CONFIGOPTS - echo -en 'travis_fold:end:script.3\\r' branches: only: - master swig-3.0.2/Lib/0000775000175000017500000000000012343706600013054 5ustar williamwilliamswig-3.0.2/Lib/allkw.swg0000664000175000017500000000141112343605122014702 0ustar williamwilliam#ifndef __Lib_allkw_swg__ #define __Lib_allkw_swg__ /* Include all the known keyword warnings. Very useful for adding test files to the test-suite, or checking if your own library is ok for all the swig supported languages. Use as swig -Wallkw ... If you add a new language, remember to create a separate languagekw.swg file, and add it here. */ %include %include %include %include %include %include %include %include %include %include %include %include %include %include #endif //__Lib_allkw_swg__ swig-3.0.2/Lib/xml/0000775000175000017500000000000012343605122013651 5ustar williamwilliamswig-3.0.2/Lib/xml/xml.swg0000664000175000017500000000002512343605122015170 0ustar williamwilliam/* nothing special */swig-3.0.2/Lib/xml/typemaps.i0000664000175000017500000000026312343605122015666 0ustar williamwilliam// -------------------------------------------------------------------- // Empty file for %include to work // -------------------------------------------------------------------- swig-3.0.2/Lib/r/0000775000175000017500000000000012343605122013312 5ustar williamwilliamswig-3.0.2/Lib/r/rcontainer.swg0000664000175000017500000001260012343605122016177 0ustar williamwilliam // // Common fragments // /**** The python container methods ****/ %fragment("StdSequenceTraits","header",fragment="") { %#include namespace swig { inline size_t check_index(ptrdiff_t i, size_t size, bool insert = false) { if ( i < 0 ) { if ((size_t) (-i) <= size) return (size_t) (i + size); } else if ( (size_t) i < size ) { return (size_t) i; } else if (insert && ((size_t) i == size)) { return size; } throw std::out_of_range("index out of range"); } inline size_t slice_index(ptrdiff_t i, size_t size) { if ( i < 0 ) { if ((size_t) (-i) <= size) { return (size_t) (i + size); } else { throw std::out_of_range("index out of range"); } } else { return ( (size_t) i < size ) ? ((size_t) i) : size; } } template inline typename Sequence::iterator getpos(Sequence* self, Difference i) { typename Sequence::iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline typename Sequence::const_iterator cgetpos(const Sequence* self, Difference i) { typename Sequence::const_iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline Sequence* getslice(const Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::const_iterator vb = self->begin(); typename Sequence::const_iterator ve = self->begin(); std::advance(vb,ii); std::advance(ve,jj); return new Sequence(vb, ve); } else { return new Sequence(); } } template inline void setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj < ii) jj = ii; size_t ssize = jj - ii; if (ssize <= v.size()) { typename Sequence::iterator sb = self->begin(); typename InputSeq::const_iterator vmid = v.begin(); std::advance(sb,ii); std::advance(vmid, jj - ii); self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end()); } else { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); self->insert(sb, v.begin(), v.end()); } } template inline void delslice(Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); } } } } %define %swig_container_methods(Container...) %newobject __getslice__; %extend { bool __nonzero__() const { return !(self->empty()); } size_type __len__() const { return self->size(); } } %enddef %define %swig_sequence_methods_common(Sequence...) // %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) %fragment("StdSequenceTraits"); %extend { value_type pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty container"); Sequence::value_type x = self->back(); self->pop_back(); return x; } Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) { return swig::getslice(self, i, j); } void __setslice__(difference_type i, difference_type j, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { swig::setslice(self, i, j, v); } void __delslice__(difference_type i, difference_type j) throw (std::out_of_range) { swig::delslice(self, i, j); } void __delitem__(difference_type i) throw (std::out_of_range) { self->erase(swig::getpos(self,i)); } } %enddef %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { const value_type& __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __setitem__(difference_type i, const value_type& x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } void append(const value_type& x) { self->push_back(x); } } %enddef %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { value_type __getitem__(difference_type i) throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __setitem__(difference_type i, value_type x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } void append(value_type x) { self->push_back(x); } } %enddef swig-3.0.2/Lib/r/std_map.i0000664000175000017500000000010312343605122015105 0ustar williamwilliam%fragment("StdMapTraits","header") %{ %} %include swig-3.0.2/Lib/r/std_pair.i0000664000175000017500000000010412343605122015264 0ustar williamwilliam%fragment("StdPairTraits","header") %{ %} %include swig-3.0.2/Lib/r/typemaps.i0000664000175000017500000000004112343605122015321 0ustar williamwilliam%include swig-3.0.2/Lib/r/std_container.i0000664000175000017500000000007112343605122016316 0ustar williamwilliam%include %include swig-3.0.2/Lib/r/r.swg0000664000175000017500000001405512343605122014302 0ustar williamwilliam/* */ %insert("header") "swiglabels.swg" %insert("header") "swigerrors.swg" %insert("init") "swiginit.swg" %insert("runtime") "swigrun.swg" %insert("runtime") "rrun.swg" %init %{ SWIGEXPORT void SWIG_init(void) { %} %include #define %Rruntime %insert("s") #define SWIG_Object SEXP #define VOID_Object R_NilValue #define %append_output(obj) SET_VECTOR_ELT($result, $n, obj) %define %set_constant(name, obj) %begin_block SEXP _obj = obj; assign(name, _obj); %end_block %enddef %define %raise(obj,type,desc) return R_NilValue; %enddef %insert("sinit") "srun.swg" %insert("sinitroutine") %{ SWIG_init(); SWIG_InitializeModule(0); %} %include %typemap(in) (double *x, int len) %{ $1 = REAL(x); $2 = Rf_length(x); %} /* XXX Need to worry about inheritance, e.g. if B extends A and we are looking for an A[], then B elements are okay. */ %typemap(scheck) SWIGTYPE[ANY] %{ # assert(length($input) > $1_dim0) assert(all(sapply($input, class) == "$R_class")); %} %typemap(out) void ""; %typemap(in) int *, int[ANY], signed int *, signed int[ANY], unsigned int *, unsigned int[ANY], short *, short[ANY], signed short *, signed short[ANY], unsigned short *, unsigned short[ANY], long *, long[ANY], signed long *, signed long[ANY], unsigned long *, unsigned long[ANY], long long *, long long[ANY], signed long long *, signed long long[ANY], unsigned long long *, unsigned long long[ANY] { { int _rswigi; int _rswiglen = LENGTH($input); $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype); for (_rswigi=0; _rswigi< _rswiglen; _rswigi++) { $1[_rswigi] = INTEGER($input)[_rswigi]; } } } %typemap(in) float *, float[ANY], double *, double[ANY] { { int _rswigi; int _rswiglen = LENGTH($input); $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype); for (_rswigi=0; _rswigi<_rswiglen; _rswigi++) { $1[_rswigi] = REAL($input)[_rswigi]; } } } %typemap(freearg,noblock=1) int *, int[ANY], signed int *, signed int[ANY], unsigned int *, unsigned int[ANY], short *, short[ANY], signed short *, signed short[ANY], unsigned short *, unsigned short[ANY], long *, long[ANY], signed long *, signed long[ANY], unsigned long *, unsigned long[ANY], long long *, long long[ANY], signed long long *, signed long long[ANY], unsigned long long *, unsigned long long[ANY], float *, float[ANY], double *, double[ANY] %{ free($1); %} %typemap(freearg, noblock=1) int *OUTPUT, signed int *OUTPUT, unsigned int *OUTPUT, short *OUTPUT, signed short *OUTPUT, unsigned short *OUTPUT, long *OUTPUT, signed long *OUTPUT, unsigned long *OUTPUT, long long *OUTPUT, signed long long *OUTPUT, unsigned long long *OUTPUT, float *OUTPUT, double *OUTPUT, char *OUTPUT, signed char *OUTPUT, unsigned char *OUTPUT {} /* Should we recycle to make the length correct. And warn if length() > the dimension. */ %typemap(scheck) SWIGTYPE [ANY] %{ # assert(length($input) >= $1_dim0) %} /* Handling vector case to avoid warnings, although we just use the first one. */ %typemap(scheck) unsigned int %{ assert(length($input) == 1 && $input >= 0, "All values must be non-negative"); %} %typemap(scheck) int, long %{ if(length($input) > 1) { warning("using only the first element of $input"); }; %} %include %include %include %include %include %typemap(in,noblock=1) enum SWIGTYPE[ANY] { $1 = %reinterpret_cast(INTEGER($input), $1_ltype); } %typemap(in,noblock=1,fragment="SWIG_strdup") char * { $1 = %reinterpret_cast(SWIG_strdup(CHAR(STRING_ELT($input, 0))), $1_ltype); } %typemap(freearg,noblock=1) char * { free($1); } %typemap(in,noblock=1,fragment="SWIG_strdup") char *[ANY] { $1 = %reinterpret_cast(SWIG_strdup(CHAR(STRING_ELT($input, 0))), $1_ltype); } %typemap(freearg,noblock=1) char *[ANY] { free($1); } %typemap(in,noblock=1,fragment="SWIG_strdup") char[ANY] { $1 = SWIG_strdup(CHAR(STRING_ELT($input, 0))); } %typemap(freearg,noblock=1) char[ANY] { free($1); } %typemap(in,noblock=1,fragment="SWIG_strdup") char[] { $1 = SWIG_strdup(CHAR(STRING_ELT($input, 0))); } %typemap(freearg,noblock=1) char[] { free($1); } %typemap(memberin) char[] %{ if ($input) strcpy($1, $input); else strcpy($1, ""); %} %typemap(globalin) char[] %{ if ($input) strcpy($1, $input); else strcpy($1, ""); %} %typemap(out,noblock=1) char * { $result = $1 ? Rf_mkString(%reinterpret_cast($1,char *)) : R_NilValue; } %typemap(in,noblock=1) char { $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype); } %typemap(out) char { char tmp[2] = "x"; tmp[0] = $1; $result = Rf_mkString(tmp); } %typemap(in,noblock=1) int, long { $1 = %static_cast(INTEGER($input)[0], $1_ltype); } %typemap(out,noblock=1) int, long "$result = Rf_ScalarInteger($1);"; %typemap(in,noblock=1) bool "$1 = LOGICAL($input)[0] ? true : false;"; %typemap(out,noblock=1) bool "$result = Rf_ScalarLogical($1);"; %typemap(in,noblock=1) float, double { $1 = %static_cast(REAL($input)[0], $1_ltype); } /* Why is this here ? */ /* %typemap(out,noblock=1) unsigned int * "$result = ScalarReal(*($1));"; */ %Rruntime %{ setMethod('[', "ExternalReference", function(x,i,j, ..., drop=TRUE) if (!is.null(x$"__getitem__")) sapply(i, function(n) x$"__getitem__"(i=as.integer(n-1)))) setMethod('[<-' , "ExternalReference", function(x,i,j, ..., value) if (!is.null(x$"__setitem__")) { sapply(1:length(i), function(n) x$"__setitem__"(i=as.integer(i[n]-1), x=value[n])) x }) setAs('ExternalReference', 'character', function(from) {if (!is.null(from$"__str__")) from$"__str__"()}) setMethod('print', 'ExternalReference', function(x) {print(as(x, "character"))}) %} swig-3.0.2/Lib/r/cdata.i0000664000175000017500000000003612343605122014537 0ustar williamwilliam%include swig-3.0.2/Lib/r/boost_shared_ptr.i0000664000175000017500000003651412343605122017036 0ustar williamwilliam%include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(out) CONST TYPE { %set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(varout) CONST TYPE { %set_varoutput(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE * { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain reference %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE & { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = *%const_cast(tempshared.get(), $1_ltype); } else { $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer by reference // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); temp = %const_cast(tempshared.get(), $*1_ltype); } else { temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); } $1 = &temp; } %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} %typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { int newmem = 0; void *argp = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varout typemap not implemented" %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); if ($owner) delete $1; } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varout typemap not implemented" %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); temp = &tempshared; $1 = &temp; } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varout typemap not implemented" %} // Typecheck typemaps // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); $1 = SWIG_CheckState(res); } // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.2/Lib/r/rrun.swg0000664000175000017500000002164712343605122015034 0ustar williamwilliam #ifdef __cplusplus #include extern "C" { #endif /* for raw pointer */ #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags) /* Remove global namespace pollution */ #if !defined(SWIG_NO_R_NO_REMAP) # define R_NO_REMAP #endif #if !defined(SWIG_NO_STRICT_R_HEADERS) # define STRICT_R_HEADERS #endif #include #include #include #include #if R_VERSION >= R_Version(2,6,0) #define VMAXTYPE void * #else #define VMAXTYPE char * #endif /* This is mainly a way to avoid having lots of local variables that may conflict with those in the routine. Change name to R_SWIG_Callb.... */ typedef struct RCallbackFunctionData { SEXP fun; SEXP userData; SEXP expr; SEXP retValue; int errorOccurred; SEXP el; /* Temporary pointer used in the construction of the expression to call the R function. */ struct RCallbackFunctionData *previous; /* Stack */ } RCallbackFunctionData; static RCallbackFunctionData *callbackFunctionDataStack; SWIGRUNTIME SEXP R_SWIG_debug_getCallbackFunctionData() { int n, i; SEXP ans; RCallbackFunctionData *p = callbackFunctionDataStack; n = 0; while(p) { n++; p = p->previous; } Rf_protect(ans = Rf_allocVector(VECSXP, n)); for(p = callbackFunctionDataStack, i = 0; i < n; p = p->previous, i++) SET_VECTOR_ELT(ans, i, p->fun); Rf_unprotect(1); return(ans); } SWIGRUNTIME RCallbackFunctionData * R_SWIG_pushCallbackFunctionData(SEXP fun, SEXP userData) { RCallbackFunctionData *el; el = (RCallbackFunctionData *) calloc(1, sizeof(RCallbackFunctionData)); el->fun = fun; el->userData = userData; el->previous = callbackFunctionDataStack; callbackFunctionDataStack = el; return(el); } SWIGRUNTIME SEXP R_SWIG_R_pushCallbackFunctionData(SEXP fun, SEXP userData) { R_SWIG_pushCallbackFunctionData(fun, userData); return R_NilValue; } SWIGRUNTIME RCallbackFunctionData * R_SWIG_getCallbackFunctionData() { if(!callbackFunctionDataStack) { Rf_error("Supposedly impossible error occurred in the SWIG callback mechanism." " No callback function data set."); } return callbackFunctionDataStack; } SWIGRUNTIME void R_SWIG_popCallbackFunctionData(int doFree) { RCallbackFunctionData *el = NULL; if(!callbackFunctionDataStack) return ; /* Error !!! */ el = callbackFunctionDataStack ; callbackFunctionDataStack = callbackFunctionDataStack->previous; if(doFree) free(el); } /* Interface to S function is(obj, type) which is to be used to determine if an external pointer inherits from the right class. Ideally, we would like to be able to do this without an explicit call to the is() function. When the S4 class system uses its own SEXP types, then we will hopefully be able to do this in the C code. Should we make the expression static and preserve it to avoid the overhead of allocating each time. */ SWIGRUNTIME int R_SWIG_checkInherits(SEXP obj, SEXP tag, const char *type) { SEXP e, val; int check_err = 0; Rf_protect(e = Rf_allocVector(LANGSXP, 3)); SETCAR(e, Rf_install("extends")); SETCAR(CDR(e), Rf_mkString(CHAR(PRINTNAME(tag)))); SETCAR(CDR(CDR(e)), Rf_mkString(type)); val = R_tryEval(e, R_GlobalEnv, &check_err); Rf_unprotect(1); if(check_err) return(0); return(LOGICAL(val)[0]); } SWIGRUNTIME void * R_SWIG_resolveExternalRef(SEXP arg, const char * const type, const char * const argName, Rboolean nullOk) { void *ptr; SEXP orig = arg; if(TYPEOF(arg) != EXTPTRSXP) arg = GET_SLOT(arg, Rf_mkString("ref")); if(TYPEOF(arg) != EXTPTRSXP) { Rf_error("argument %s must be an external pointer (from an ExternalReference)", argName); } ptr = R_ExternalPtrAddr(arg); if(ptr == NULL && nullOk == (Rboolean) FALSE) { Rf_error("the external pointer (of type %s) for argument %s has value NULL", argName, type); } if(type[0] && R_ExternalPtrTag(arg) != Rf_install(type) && strcmp(type, "voidRef") && !R_SWIG_checkInherits(orig, R_ExternalPtrTag(arg), type)) { Rf_error("the external pointer for argument %s has tag %s, not the expected value %s", argName, CHAR(PRINTNAME(R_ExternalPtrTag(arg))), type); } return(ptr); } SWIGRUNTIME void R_SWIG_ReferenceFinalizer(SEXP el) { void *ptr = R_SWIG_resolveExternalRef(el, "", "", (Rboolean) 1); fprintf(stderr, "In R_SWIG_ReferenceFinalizer for %p\n", ptr); Rf_PrintValue(el); if(ptr) { if(TYPEOF(el) != EXTPTRSXP) el = GET_SLOT(el, Rf_mkString("ref")); if(TYPEOF(el) == EXTPTRSXP) R_ClearExternalPtr(el); free(ptr); } return; } typedef enum {R_SWIG_EXTERNAL, R_SWIG_OWNER } R_SWIG_Owner; SWIGRUNTIME SEXP SWIG_MakePtr(void *ptr, const char *typeName, R_SWIG_Owner owner) { SEXP external, r_obj; const char *p = typeName; if(typeName[0] == '_') p = typeName + 1; Rf_protect(external = R_MakeExternalPtr(ptr, Rf_install(typeName), R_NilValue)); Rf_protect(r_obj = NEW_OBJECT(MAKE_CLASS((char *) typeName))); if(owner) R_RegisterCFinalizer(external, R_SWIG_ReferenceFinalizer); r_obj = SET_SLOT(r_obj, Rf_mkString((char *) "ref"), external); SET_S4_OBJECT(r_obj); Rf_unprotect(2); return(r_obj); } SWIGRUNTIME SEXP R_SWIG_create_SWIG_R_Array(const char *typeName, SEXP ref, int len) { SEXP arr; /*XXX remove the char * cast when we can. MAKE_CLASS should be declared appropriately. */ Rf_protect(arr = NEW_OBJECT(MAKE_CLASS((char *) typeName))); Rf_protect(arr = R_do_slot_assign(arr, Rf_mkString("ref"), ref)); Rf_protect(arr = R_do_slot_assign(arr, Rf_mkString("dims"), Rf_ScalarInteger(len))); Rf_unprotect(3); SET_S4_OBJECT(arr); return arr; } #define ADD_OUTPUT_ARG(result, pos, value, name) r_ans = AddOutputArgToReturn(pos, value, name, OutputValues); SWIGRUNTIME SEXP AddOutputArgToReturn(int pos, SEXP value, const char *name, SEXP output) { SET_VECTOR_ELT(output, pos, value); return(output); } /* Create a new pointer object */ SWIGRUNTIMEINLINE SEXP SWIG_R_NewPointerObj(void *ptr, swig_type_info *type, int flags) { SEXP rptr = R_MakeExternalPtr(ptr, R_MakeExternalPtr(type, R_NilValue, R_NilValue), R_NilValue); SET_S4_OBJECT(rptr); return rptr; } /* Convert a pointer value */ SWIGRUNTIMEINLINE int SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) { void *vptr; if (!obj) return SWIG_ERROR; if (obj == R_NilValue) { if (ptr) *ptr = NULL; return SWIG_OK; } vptr = R_ExternalPtrAddr(obj); if (ty) { swig_type_info *to = (swig_type_info*) R_ExternalPtrAddr(R_ExternalPtrTag(obj)); if (to == ty) { if (ptr) *ptr = vptr; } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); int newmemory = 0; if (ptr) *ptr = SWIG_TypeCast(tc,vptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } } else { if (ptr) *ptr = vptr; } return SWIG_OK; } SWIGRUNTIME swig_module_info * SWIG_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; return (swig_module_info *) type_pointer; } SWIGRUNTIME void SWIG_SetModule(void *v, swig_module_info *swig_module) { } typedef struct { void *pack; swig_type_info *ty; size_t size; } RSwigPacked; /* Create a new packed object */ SWIGRUNTIMEINLINE SEXP RSwigPacked_New(void *ptr, size_t sz, swig_type_info *ty) { SEXP rptr; RSwigPacked *sobj = (RSwigPacked*) malloc(sizeof(RSwigPacked)); if (sobj) { void *pack = malloc(sz); if (pack) { memcpy(pack, ptr, sz); sobj->pack = pack; sobj->ty = ty; sobj->size = sz; } else { sobj = 0; } } rptr = R_MakeExternalPtr(sobj, R_NilValue, R_NilValue); return rptr; } SWIGRUNTIME swig_type_info * RSwigPacked_UnpackData(SEXP obj, void *ptr, size_t size) { RSwigPacked *sobj = (RSwigPacked *)R_ExternalPtrAddr(obj); if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; } SWIGRUNTIMEINLINE SEXP SWIG_R_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return ptr ? RSwigPacked_New((void *) ptr, sz, type) : R_NilValue; } /* Convert a packed value value */ SWIGRUNTIME int SWIG_R_ConvertPacked(SEXP obj, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = RSwigPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } #ifdef __cplusplus #define SWIG_exception_noreturn(code, msg) do { throw std::runtime_error(msg); } while(0) #else #define SWIG_exception_noreturn(code, msg) do { return result; } while(0) #endif #ifdef __cplusplus } #endif swig-3.0.2/Lib/r/std_common.i0000664000175000017500000000434312343605122015632 0ustar williamwilliam%include /* Generate the traits for a 'primitive' type, such as 'double', for which the SWIG_AsVal and SWIG_From methods are already defined. */ %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval { typedef Type value_type; static int asval(SEXP obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from { typedef Type value_type; static SEXP from(const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit instantiations required using %template). The STL containers define the 'front' method and the typemap below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from required in the generated code for enums. */ %define %traits_enum(Type...) %fragment("SWIG_Traits_enum_"{Type},"header", fragment=SWIG_AsVal_frag(int), fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(SEXP obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; template <> struct traits_from { typedef Type value_type; static SEXP from(const value_type& val) { return SWIG_From(int)((int)val); } }; } } %typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} %enddef %include // // Generates the traits for all the known primitive // C++ types (int, double, ...) // %apply_cpptypes(%traits_ptypen); swig-3.0.2/Lib/r/std_list.i0000664000175000017500000000024712343605122015314 0ustar williamwilliam#define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.2/Lib/r/std_alloc.i0000664000175000017500000000003212343605122015423 0ustar williamwilliam%include swig-3.0.2/Lib/r/exception.i0000664000175000017500000000034112343605122015460 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(switch (code) {case SWIG_IndexError: return Rf_ScalarLogical(NA_LOGICAL); default: %error(code, msg); SWIG_fail;} )) } swig-3.0.2/Lib/r/rfragments.swg0000664000175000017500000001110512343605122016202 0ustar williamwilliam#define SWIG_Error(code, msg) Rf_warning(msg); return Rf_ScalarLogical(NA_LOGICAL) #define SWIG_fail return Rf_ScalarLogical(NA_LOGICAL) /* for raw pointers */ #define SWIG_ConvertPtr(oc, ptr, ty, flags) SWIG_R_ConvertPtr(oc, ptr, ty, flags) #define SWIG_ConvertFunctionPtr(oc, ptr, ty) SWIG_R_ConvertPtr(oc, ptr, ty, 0) #define SWIG_NewPointerObj(ptr, ty, flags) SWIG_R_NewPointerObj(ptr, ty, flags) #define SWIG_NewFunctionPtrObj(ptr, ty) SWIG_R_NewPointerObj(ptr, ty, 0) /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_R_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, ty) SWIG_R_NewPackedObj(ptr, sz, ty) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, ty, flags) SWIG_ConvertPtr(obj, pptr, ty, flags) #define SWIG_NewInstanceObj(ptr, ty, flags) SWIG_NewPointerObj(ptr, ty, flags) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_R_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, ty) SWIG_R_NewPackedObj(ptr, sz, ty) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_R_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_R_SetModule(pointer) %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(long)(long value) { return Rf_ScalarInteger((int)value); } } %fragment(SWIG_AsVal_frag(long),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(long)(SEXP obj, long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } } %fragment(SWIG_From_frag(long long),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(long long)(long long value) { return Rf_ScalarInteger((int)value); } } %fragment(SWIG_AsVal_frag(long long),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(long long)(SEXP obj, long long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned long),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(unsigned long)(unsigned long value) { return Rf_ScalarInteger((int)value); } } %fragment(SWIG_AsVal_frag(unsigned long),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(unsigned long)(SEXP obj, unsigned long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned long long),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(unsigned long long)(unsigned long long value) { return Rf_ScalarInteger((int)value); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(unsigned long long)(SEXP obj, unsigned long long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } } %fragment(SWIG_From_frag(double),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(double)(double value) { return Rf_ScalarReal(value); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(double)(SEXP obj, double *val) { if (val) *val = Rf_asReal(obj); return SWIG_OK; } } %fragment("SWIG_AsCharPtrAndSize", "header") { SWIGINTERN int SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc) { if (cptr && Rf_isString(obj)) { char *cstr = %const_cast(CHAR(STRING_ELT(obj, 0)), char *); int len = strlen(cstr); if (alloc) { if (*alloc == SWIG_NEWOBJ) { *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; } else { *cptr = cstr; } } else { *cptr = %reinterpret_cast(malloc(len + 1), char *); *cptr = strcpy(*cptr, cstr); } if (psize) *psize = len + 1; return SWIG_OK; } return SWIG_TypeError; } } %fragment("SWIG_strdup","header") { SWIGINTERN char * SWIG_strdup(const char *str) { char *newstr = %reinterpret_cast(malloc(strlen(str) + 1), char *); return strcpy(newstr, str); } } # This is modified from the R header files %fragment("SWIG_FromCharPtrAndSize","header") { SWIGINTERN SEXP SWIG_FromCharPtrAndSize(const char* carray, size_t size) { SEXP t, c; if (!carray) return R_NilValue; /* See R internals document 1.10. MkCharLen was introduced in 2.7.0. Use that instead of hand creating vector. Starting in 2.8.0 creating strings via vectors was deprecated in order to allow for use of CHARSXP caches. */ Rf_protect(t = Rf_allocVector(STRSXP, 1)); %#if R_VERSION >= R_Version(2,7,0) c = Rf_mkCharLen(carray, size); %#else c = Rf_allocVector(CHARSXP, size); strncpy((char *)CHAR(c), carray, size); %#endif SET_STRING_ELT(t, 0, c); Rf_unprotect(1); return t; } } swig-3.0.2/Lib/r/rtype.swg0000664000175000017500000002051612343605122015203 0ustar williamwilliam /* These map the primitive C types to the appropriate R type for use in class representations. */ %typemap("rtype") int, int *, int & "integer"; %typemap("rtype") long, long *, long & "integer"; %typemap("rtype") float, float*, float & "numeric"; %typemap("rtype") double, double*, double & "numeric"; %typemap("rtype") char *, char ** "character"; %typemap("rtype") char "character"; %typemap("rtype") string, string *, string & "character"; %typemap("rtype") std::string, std::string *, std::string & "character"; %typemap("rtype") bool, bool * "logical"; %typemap("rtype") enum SWIGTYPE "character"; %typemap("rtype") enum SWIGTYPE * "character"; %typemap("rtype") enum SWIGTYPE *const "character"; %typemap("rtype") enum SWIGTYPE & "character"; %typemap("rtype") enum SWIGTYPE && "character"; %typemap("rtype") SWIGTYPE * "$R_class"; %typemap("rtype") SWIGTYPE *const "$R_class"; %typemap("rtype") SWIGTYPE & "$R_class"; %typemap("rtype") SWIGTYPE && "$R_class"; %typemap("rtype") SWIGTYPE "$&R_class"; %typemap("rtypecheck") int, int &, long, long & %{ (is.integer($arg) || is.numeric($arg)) && length($arg) == 1 %} %typemap("rtypecheck") int *, long * %{ is.integer($arg) || is.numeric($arg) %} %typemap("rtypecheck") float, double %{ is.numeric($arg) && length($arg) == 1 %} %typemap("rtypecheck") float *, double * %{ is.numeric($arg) %} %typemap("rtypecheck") bool, bool & %{ is.logical($arg) && length($arg) == 1 %} %typemap("rtypecheck") bool * %{ is.logical($arg) %} /* Set up type checks to insure overloading precedence. We would like non pointer items to shadow pointer items, so that they get called if length = 1 */ %typecheck(SWIG_TYPECHECK_BOOL) bool {} %typecheck(SWIG_TYPECHECK_UINT32) unsigned int {} %typecheck(SWIG_TYPECHECK_INTEGER) int {} %typecheck(SWIG_TYPECHECK_FLOAT) float {} %typecheck(SWIG_TYPECHECK_DOUBLE) double {} %typecheck(SWIG_TYPECHECK_BOOL_PTR) bool * {} %typecheck(SWIG_TYPECHECK_INT32_PTR) int * {} %typecheck(SWIG_TYPECHECK_FLOAT_PTR) float * {} %typecheck(SWIG_TYPECHECK_DOUBLE_PTR) double * {} %typecheck(SWIG_TYPECHECK_CHAR_PTR) char * {} %typecheck(SWIG_TYPECHECK_INT32_ARRAY) int[ANY] {} %typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) float[ANY] {} %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) double [ANY] {} /* Have to be careful that as(x, "numeric") is different from as.numeric(x). The latter makes a REALSXP, whereas the former leaves an INTSXP as an INTSXP. */ /* Force coercion of integer, since by default R sets all constants to numeric, which means that you can't directly call a function with an integer using an R numercal literal */ %typemap(scoercein) int, int *, int & %{ $input = as.integer($input); %} %typemap(scoercein) long, long *, long & %{ $input = as.integer($input); %} %typemap(scoercein) float, float*, float &, double, double *, double & %{ %} %typemap(scoercein) char, char *, char & %{ $input = as($input, "character"); %} %typemap(scoercein) string, string *, string & %{ $input = as($input, "character"); %} %typemap(scoercein) std::string, std::string *, std::string & %{ $input = as($input, "character"); %} %typemap(scoercein) enum SWIGTYPE %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE & %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE && %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE * %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE *const %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE && %{ if (inherits($input, "ExternalReference")) $input = slot($input,"ref") %} /* %typemap(scoercein) SWIGTYPE *, SWIGTYPE *const %{ $input = coerceIfNotSubclass($input, "$R_class") %} %typemap(scoercein) SWIGTYPE & %{ $input = coerceIfNotSubclass($input, "$R_class") %} %typemap(scoercein) SWIGTYPE && %{ $input = coerceIfNotSubclass($input, "$R_class") %} %typemap(scoercein) SWIGTYPE %{ $input = coerceIfNotSubclass($input, "$&R_class") %} */ %typemap(scoercein) SWIGTYPE[ANY] %{ if(is.list($input)) assert(all(sapply($input, class) == "$R_class")); %} /* **************************************************************** */ %typemap(scoercein) bool, bool *, bool & "$input = as.logical($input);"; %typemap(scoercein) int, int *, int &, long, long *, long & "$input = as.integer($input);"; %typemap(scoercein) char *, string, std::string, string &, std::string & %{ $input = as($input, "character"); %} %typemap(scoerceout) enum SWIGTYPE %{ $result = enumFromInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE & %{ $result = enumFromInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE && %{ $result = enumFromInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE * %{ $result = enumToInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE *const %{ $result = enumToInteger($result, "$R_class"); %} #%typemap(scoerceout) SWIGTYPE # %{ class($result) <- "$&R_class"; %} #%typemap(scoerceout) SWIGTYPE & # %{ class($result) <- "$R_class"; %} #%typemap(scoerceout) SWIGTYPE * # %{ class($result) <- "$R_class"; %} #%typemap(scoerceout) SWIGTYPE *const # %{ class($result) <- "$R_class"; %} %typemap(scoerceout) SEXP %{ %} %typemap(scoerceout) SWIGTYPE %{ $result <- new("$&R_class", ref=$result); %} %typemap(scoerceout) SWIGTYPE & %{ $result <- new("$R_class", ref=$result) ; %} %typemap(scoerceout) SWIGTYPE && %{ $result <- new("$R_class", ref=$result) ; %} %typemap(scoerceout) SWIGTYPE * %{ $result <- new("$R_class", ref=$result) ; %} %typemap(scoerceout) SWIGTYPE *const %{ $result <- new("$R_class", ref=$result) ; %} /* Override the SWIGTYPE * above. */ %typemap(scoerceout) char, char *, char &, float, double, float*, double*, float &, double &, int, int &, long, long &, bool, bool &, string, std::string, string &, std::string &, void, signed int, signed int &, unsigned int, unsigned int &, short, short &, unsigned short, unsigned short &, long long, signed long long, signed long long &, unsigned long long, unsigned long long &, signed long, signed long &, unsigned long, unsigned long &, signed char, signed char &, unsigned char, unsigned char & %{ %} %apply int {size_t, std::size_t, ptrdiff_t, std::ptrdiff_t, signed int, unsigned int, short, unsigned short, signed char, unsigned char} %apply int* {size_t[], std::size_t[], ptrdiff_t[], std::ptrdiff_t[], signed int[], unsigned int[], short[], unsigned short[], signed char[], unsigned char[]} %apply int* {size_t[ANY], std::size_t[ANY], ptrdiff_t[ANY], std::ptrdiff_t[ANY], signed int[ANY], unsigned int[ANY], short[ANY], unsigned short[ANY], signed char[ANY], unsigned char[ANY]} %apply int* {size_t*, std::size_t*, ptrdiff_t*, std::ptrdiff_t*, signed int*, unsigned int*, short*, unsigned short*, signed char*, unsigned char*} %apply long { long long, signed long long, unsigned long long, signed long, unsigned long} %apply long* { long long*, signed long long*, unsigned long long*, signed long*, unsigned long*, long long[], signed long long[], unsigned long long[], signed long[], unsigned long[], long long[ANY], signed long long[ANY], unsigned long long[ANY], signed long[ANY], unsigned long[ANY]} %apply float* { float[], float[ANY] } %apply double * { double[], double[ANY] } %apply bool* { bool[], bool[ANY] } #if 0 Just examining the values for a SWIGTYPE. %typemap(scoerceout) SWIGTYPE %{ name = $1_name type = $1_type ltype = $1_ltype mangle = $1_mangle descriptor = $1_descriptor pointer type = $*1_type pointer ltype = $*1_ltype pointer descriptor = $*1_descriptor basetype = $*_basetype %} #endif swig-3.0.2/Lib/r/srun.swg0000664000175000017500000000747512343605122015040 0ustar williamwilliam# srun.swg # # # This is the basic code that is needed at run time within R to # provide and define the relevant classes. It is included # automatically in the generated code by copying the contents of # srun.swg into the newly created binding code. # This could be provided as a separate run-time library but this # approach allows the code to to be included directly into the # generated bindings and so removes the need to have and install an # additional library. We may however end up with multiple copies of # this and some confusion at run-time as to which class to use. This # is an issue when we use NAMESPACES as we may need to export certain # classes. ###################################################################### if(length(getClassDef("RSWIGStruct")) == 0) setClass("RSWIGStruct", representation("VIRTUAL")) if(length(getClassDef("ExternalReference")) == 0) # Should be virtual but this means it loses its slots currently #representation("VIRTUAL") setClass("ExternalReference", representation( ref = "externalptr")) if(length(getClassDef("NativeRoutinePointer")) == 0) setClass("NativeRoutinePointer", representation(parameterTypes = "character", returnType = "character", "VIRTUAL"), contains = "ExternalReference") if(length(getClassDef("CRoutinePointer")) == 0) setClass("CRoutinePointer", contains = "NativeRoutinePointer") if(length(getClassDef("EnumerationValue")) == 0) setClass("EnumerationValue", contains = "integer") if(!isGeneric("copyToR")) setGeneric("copyToR", function(value, obj = new(gsub("Ref$", "", class(value)))) standardGeneric("copyToR" )) setGeneric("delete", function(obj) standardGeneric("delete")) SWIG_createNewRef = function(className, ..., append = TRUE) { f = get(paste("new", className, sep = "_"), mode = "function") f(...) } if(!isGeneric("copyToC")) setGeneric("copyToC", function(value, obj = RSWIG_createNewRef(class(value))) standardGeneric("copyToC" )) # defineEnumeration = function(name, .values, where = topenv(parent.frame()), suffix = "Value") { # Mirror the class definitions via the E analogous to .__C__ defName = paste(".__E__", name, sep = "") assign(defName, .values, envir = where) if(nchar(suffix)) name = paste(name, suffix, sep = "") setClass(name, contains = "EnumerationValue", where = where) } enumToInteger <- function(name,type) { if (is.character(name)) { ans <- as.integer(get(paste(".__E__", type, sep = ""))[name]) if (is.na(ans)) {warning("enum not found ", name, " ", type)} ans } } enumFromInteger = function(i,type) { itemlist <- get(paste(".__E__", type, sep="")) names(itemlist)[match(i, itemlist)] } coerceIfNotSubclass = function(obj, type) { if(!is(obj, type)) {as(obj, type)} else obj } setClass("SWIGArray", representation(dims = "integer"), contains = "ExternalReference") setMethod("length", "SWIGArray", function(x) x@dims[1]) defineEnumeration("SCopyReferences", .values = c( "FALSE" = 0, "TRUE" = 1, "DEEP" = 2)) assert = function(condition, message = "") { if(!condition) stop(message) TRUE } if(FALSE) { print.SWIGFunction = function(x, ...) { } } ####################################################################### R_SWIG_getCallbackFunctionStack = function() { # No PACKAGE argument as we don't know what the DLL is. .Call("R_SWIG_debug_getCallbackFunctionData") } R_SWIG_addCallbackFunctionStack = function(fun, userData = NULL) { # No PACKAGE argument as we don't know what the DLL is. .Call("R_SWIG_R_pushCallbackFunctionData", fun, userData) } #######################################################################swig-3.0.2/Lib/r/ropers.swg0000664000175000017500000000422412343605122015350 0ustar williamwilliam#ifdef __cplusplus // These are auto-supported by the Perl-module %rename(__plusplus__) *::operator++; %rename(__minmin__) *::operator--; %rename(__add__) *::operator+; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-(); %rename(__neg__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__mod__) *::operator%; %rename(__gt__) *::operator>; %rename(__lt__) *::operator<; %rename(__not__) *::operator!; // These are renamed, but no 'use overload...' is added %rename(__lshift__) *::operator<<; %rename(__rshift__) *::operator>>; %rename(__and__) *::operator&; %rename(__or__) *::operator|; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; %rename(__le__) *::operator<=; %rename(__ge__) *::operator>=; %rename(__call__) *::operator(); %rename(__getitem__) *::operator[]; %rename(__seteq__) *::operator=; %rename(__land__) operator&&; %rename(__lor__) operator||; %rename(__plusplus__) *::operator++; %rename(__minusminus__) *::operator--; %rename(__arrowstar__) *::operator->*; %rename(__index__) *::operator[]; %rename(Equal) operator =; %rename(PlusEqual) operator +=; %rename(MinusEqual) operator -=; %rename(MultiplyEqual) operator *=; %rename(DivideEqual) operator /=; %rename(PercentEqual) operator %=; %rename(Plus) operator +; %rename(Minus) operator -; %rename(Multiply) operator *; %rename(Divide) operator /; %rename(Percent) operator %; %rename(Not) operator !; %rename(IndexIntoConst) operator[](unsigned idx) const; %rename(IndexInto) operator[](unsigned idx); %rename(Functor) operator (); %rename(EqualEqual) operator ==; %rename(NotEqual) operator !=; %rename(LessThan) operator <; %rename(LessThanEqual) operator <=; %rename(GreaterThan) operator >; %rename(GreaterThanEqual) operator >=; %rename(And) operator &&; %rename(Or) operator ||; %rename(PlusPlusPrefix) operator++(); %rename(PlusPlusPostfix) operator++(int); %rename(MinusMinusPrefix) operator--(); %rename(MinusMinusPostfix) operator--(int); #endif swig-3.0.2/Lib/r/rstdcommon.swg0000664000175000017500000001220712343605122016223 0ustar williamwilliam%fragment("StdTraits","header",fragment="StdTraitsCommon") { namespace swig { /* Traits that provides the from method */ template struct traits_from_ptr { static SWIG_Object from(Type *val, int owner = 0) { return SWIG_NewPointerObj(val, type_info(), owner); } }; template struct traits_from { static SWIG_Object from(const Type& val) { return traits_from_ptr::from(new Type(val), 1); } }; template struct traits_from { static SWIG_Object from(Type* val) { return traits_from_ptr::from(val, 0); } }; template inline SWIG_Object from(const Type& val) { return traits_from::from(val); } template inline SWIG_Object from_ptr(Type* val, int owner) { return traits_from_ptr::from(val, owner); } /* Traits that provides the asval/as/check method */ template struct traits_asptr { static int asptr(SWIG_Object obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template inline int asptr(SWIG_Object obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } template struct traits_asval { static int asval(SWIG_Object obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); if (!SWIG_IsOK(res)) return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; if (SWIG_IsNewObj(res)){ %delete(p); res = SWIG_DelNewMask(res); } return res; } else { return SWIG_ERROR; } } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template struct traits_asval { static int asval(SWIG_Object obj, Type **val) { if (val) { typedef typename noconst_traits::noconst_type noconst_type; noconst_type *p = 0; int res = traits_asptr::asptr(obj, &p); if (SWIG_IsOK(res)) { *(const_cast(val)) = p; } return res; } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template inline int asval(SWIG_Object obj, Type *val) { return traits_asval::asval(obj, val); } template struct traits_as { static Type as(SWIG_Object obj, bool throw_error) { Type v; int res = asval(obj, &v); if (!obj || !SWIG_IsOK(res)) { if (throw_error) throw std::invalid_argument("bad type"); } return v; } }; template struct traits_as { static Type as(SWIG_Object obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { Type r(*v); %delete(v); return r; } else { return *v; } } else { // Uninitialized return value, no Type() constructor required. static Type *v_def = (Type*) malloc(sizeof(Type)); if (throw_error) throw std::invalid_argument("bad type"); memset(v_def,0,sizeof(Type)); return *v_def; } } }; template struct traits_as { static Type* as(SWIG_Object obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res)) { return v; } else { if (throw_error) throw std::invalid_argument("bad type"); return 0; } } }; template inline Type as(SWIG_Object obj, bool te = false) { return traits_as::category>::as(obj, te); } template struct traits_check { static bool check(SWIG_Object obj) { int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { static bool check(SWIG_Object obj) { int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template inline bool check(SWIG_Object obj) { return traits_check::category>::check(obj); } } } %define %specialize_std_container(Type,Check,As,From) %{ namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(SWIG_Object obj, value_type *val) { if (Check(obj)) { if (val) *val = As(obj); return SWIG_OK; } return SWIG_ERROR; } }; template <> struct traits_from { typedef Type value_type; static SWIG_Object from(const value_type& val) { return From(val); } }; template <> struct traits_check { static int check(SWIG_Object obj) { int res = Check(obj); return obj && res ? res : 0; } }; } %} %enddef swig-3.0.2/Lib/r/std_vector.i0000664000175000017500000005333412343605122015650 0ustar williamwilliam// R specific swig components /* Vectors */ %fragment("StdVectorTraits","header",fragment="StdSequenceTraits") %{ namespace swig { // vectors of doubles template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(REALSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { NUMERIC_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); } }; // vectors of floats template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(REALSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { NUMERIC_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); } }; // vectors of unsigned int template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(INTSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { INTEGER_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); } }; // vectors of int template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(INTSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { INTEGER_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); } }; // vectors of bool template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(LGLSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { LOGICAL_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); //return SWIG_R_NewPointerObj(val, type_info< std::vector >(), owner); } }; // vectors of strings template <> struct traits_from_ptr > > { static SEXP from (std::vector > *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(STRSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { CHARACTER_POINTER(result)[pos] = Rf_mkChar(((*val)[pos]).c_str()); } UNPROTECT(1); return(result); //return SWIG_R_NewPointerObj(val, type_info< std::vector >(), owner); } }; // catch all that does everything with vectors template struct traits_from_ptr< std::vector< T > > { static SEXP from (std::vector< T > *val, int owner = 0) { return SWIG_R_NewPointerObj(val, type_info< std::vector< T > >(), owner); } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; // not sure how to check the size of the SEXP obj is correct unsigned int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); double *S = NUMERIC_POINTER(obj); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; // not sure how to check the size of the SEXP obj is correct unsigned int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); double *S = NUMERIC_POINTER(obj); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; unsigned int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); SEXP coerced; PROTECT(coerced = Rf_coerceVector(obj, INTSXP)); int *S = INTEGER_POINTER(coerced); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } UNPROTECT(1); return res; } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; // not sure how to check the size of the SEXP obj is correct int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); SEXP coerced; PROTECT(coerced = Rf_coerceVector(obj, INTSXP)); int *S = INTEGER_POINTER(coerced); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } UNPROTECT(1); return res; } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; // not sure how to check the size of the SEXP obj is correct int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); SEXP coerced; PROTECT(coerced = Rf_coerceVector(obj, LGLSXP)); int *S = LOGICAL_POINTER(coerced); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } UNPROTECT(1); return res; } }; // catchall for R to vector conversion template struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; Rprintf("my asptr\n"); int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector >(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; // now for vectors of vectors. These will be represented as lists of vectors on the // catch all that does everything with vectors template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(INTSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { INTEGER_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast(val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(INTSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { INTEGER_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast(val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(REALSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { NUMERIC_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast(val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(REALSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { NUMERIC_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast(val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(LGLSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { LOGICAL_POINTER(VECTOR_ELT(result, pos))[vpos] = (val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template struct traits_from_ptr< std::vector < std::vector< T > > > { static SEXP from (std::vector < std::vector< T > > *val, int owner = 0) { return SWIG_R_NewPointerObj(val, type_info< std::vector < std::vector< T > > >(), owner); } }; // R side template <> struct traits_asptr < std::vector< std::vector > > { static int asptr(SEXP obj, std::vector< std::vector > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(INTEGER_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector< std::vector< int> > > { static int asptr(SEXP obj, std::vector< std::vector< int> > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector< int> > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(INTEGER_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector< std::vector< float> > > { static int asptr(SEXP obj, std::vector< std::vector< float> > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector< float> > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(NUMERIC_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector< std::vector< double> > > { static int asptr(SEXP obj, std::vector< std::vector< double> > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector< double> > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(NUMERIC_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector< std::vector< bool > > > { static int asptr(SEXP obj, std::vector< std::vector< bool> > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector< bool > > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(LOGICAL_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; // catchall template struct traits_asptr < std::vector< std::vector > > { static int asptr(SEXP obj, std::vector< std::vector > **val) { std::vector< std::vector > *p; Rprintf("vector of vectors - unsupported content\n"); int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector< std::vector > > (), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %define %traits_type_name(Type...) %fragment(SWIG_Traits_frag(Type), "header", fragment="StdTraits",fragment="StdVectorTraits") { namespace swig { template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return #Type; } }; } } %enddef %include %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector) %traits_type_name(std::vector) %typemap("rtypecheck") std::vector, std::vector const, std::vector const& %{ is.numeric($arg) %} %typemap("rtype") std::vector "numeric" %typemap("scoercein") std::vector, std::vector const, std::vector const& ""; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector) %traits_type_name(std::vector) %typemap("rtypecheck") std::vector, std::vector const, std::vector const& %{ is.numeric($arg) %} %typemap("rtype") std::vector "numeric" %typemap("scoercein") std::vector, std::vector const, std::vector const& ""; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); %traits_type_name(std::vector); %typemap("rtypecheck") std::vector , std::vector const, std::vector const& %{ is.logical($arg) %} %typemap("rtype") std::vector "logical" %typemap("scoercein") std::vector , std::vector const, std::vector const& "$input = as.logical($input);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); %traits_type_name(std::vector); %typemap("rtypecheck") std::vector , std::vector const, std::vector const& %{ is.integer($arg) || is.numeric($arg) %} %typemap("rtype") std::vector "integer" %typemap("scoercein") std::vector , std::vector const, std::vector const& "$input = as.integer($input);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); %traits_type_name(std::vector); %typemap("rtypecheck") std::vector, std::vector const, std::vector const& %{ is.integer($arg) || is.numeric($arg) %} %typemap("rtype") std::vector "integer" %typemap("scoercein") std::vector, std::vector const, std::vector const& "$input = as.integer($input);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.integer);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.integer);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.numeric);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.numeric);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.logical);"; // we don't want these to be given R classes as they // have already been turned into R vectors. %typemap(scoerceout) std::vector, std::vector *, std::vector &, std::vector, std::vector *, std::vector &, std::vector, std::vector *, std::vector &, // vectors of vectors std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >&, std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >&, std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >&, std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >&, std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >& %{ %} swig-3.0.2/Lib/r/std_string.i0000664000175000017500000000004312343605122015641 0ustar williamwilliam%include swig-3.0.2/Lib/r/std_except.i0000664000175000017500000000004312343605122015623 0ustar williamwilliam%include swig-3.0.2/Lib/r/stl.i0000664000175000017500000000023512343605122014266 0ustar williamwilliam/* initial STL definition. extended as needed in each language */ %include std_common.i %include std_vector.i %include std_pair.i %include std_string.i swig-3.0.2/Lib/r/std_deque.i0000664000175000017500000000003112343605122015433 0ustar williamwilliam%includeswig-3.0.2/Lib/r/rkw.swg0000664000175000017500000000102012343605122014630 0ustar williamwilliam/* Warnings for R keywords, built-in names and bad names. */ #define RKW(x) %keywordwarn("'" `x` "' is a R keyword, renaming to '_" `x`"'", rename="_%s") `x` /* Warnings for R reserved words taken from http://cran.r-project.org/doc/manuals/R-lang.html#Reserved-words */ RKW(if); RKW(else); RKW(repeat); RKW(while); RKW(function); RKW(for); RKW(in); RKW(next); RKW(break); RKW(TRUE); RKW(FALSE); RKW(NULL); RKW(Inf); RKW(NaN); RKW(NA); RKW(NA_integer_); RKW(NA_real_); RKW(NA_complex_); RKW(NA_character_); #undef RKW swig-3.0.2/Lib/pike/0000775000175000017500000000000012343605122014001 5ustar williamwilliamswig-3.0.2/Lib/pike/pikekw.swg0000664000175000017500000000152112343605122016014 0ustar williamwilliam#ifndef PIKE_PIKEKW_SWG_ #define PIKE_PIKEKW_SWG_ /* Warnings for Pike keywords */ #define PIKEKW(x) %namewarn("314: '" #x "' is a pike keyword") #x /* from http://www.http://docs.linux.cz/pike/tutorial_C.html */ PIKEKW(array); PIKEKW(break); PIKEKW(case); PIKEKW(catch); PIKEKW(continue); PIKEKW(default); PIKEKW(do); PIKEKW(else); PIKEKW(float); PIKEKW(for); PIKEKW(foreach); PIKEKW(function); PIKEKW(gauge); PIKEKW(if); PIKEKW(inherit); PIKEKW(inline); PIKEKW(int); PIKEKW(lambda); PIKEKW(mapping); PIKEKW(mixed); PIKEKW(multiset); PIKEKW(nomask); PIKEKW(object); PIKEKW(predef); PIKEKW(private); PIKEKW(program); PIKEKW(protected); PIKEKW(public); PIKEKW(return); PIKEKW(sscanf); PIKEKW(static); PIKEKW(string); PIKEKW(switch); PIKEKW(typeof); PIKEKW(varargs); PIKEKW(void); PIKEKW(while); #undef PIKEKW #endif //PIKE_PIKEKW_SWG_ swig-3.0.2/Lib/pike/pike.swg0000664000175000017500000002254712343605122015465 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pike.swg * * Pike configuration module. * ----------------------------------------------------------------------------- */ %insert(runtime) "swigrun.swg"; // Common C API type-checking code %insert(runtime) "pikerun.swg"; // Pike run-time code %insert(runtime) %{ #ifdef __cplusplus extern "C" { #endif #include #include #include #ifdef __cplusplus } #endif %} /* ----------------------------------------------------------------------------- * standard typemaps * ----------------------------------------------------------------------------- */ /* --- Input arguments --- */ /* Primitive datatypes. */ %typemap(in, pikedesc="tInt") int, unsigned int, short, unsigned short, long, unsigned long, char, signed char, unsigned char, bool, enum SWIGTYPE, long long, unsigned long long { if ($input.type != T_INT) Pike_error("Bad argument: Expected an integer.\n"); $1 = ($1_ltype) $input.u.integer; } %typemap(in, pikedesc="tFloat") float, double { if ($input.type != T_FLOAT) Pike_error("Bad argument: Expected a float.\n"); $1 = ($1_ltype) $input.u.float_number; } %typemap(in, pikedesc="tStr") char *, char [ANY] { if ($input.type != T_STRING) Pike_error("Bad argument: Expected a string.\n"); $1 = ($1_ltype) STR0($input.u.string); } /* Pointers, references and arrays */ %typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "SWIG_ConvertPtr($input.u.object, (void **) &$1, $1_descriptor, 1);" /* Void pointer. Accepts any kind of pointer */ %typemap(in) void * "/* FIXME */"; /* Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_ltype argp) "/* FIXME */"; /* Pointer to a class member */ %typemap(in) SWIGTYPE (CLASS::*) "/* FIXME */"; /* Const primitive references. Passed by value */ %typemap(in, pikedesc="tInt") const int & (int temp), const short & (short temp), const long & (long temp), const unsigned int & (unsigned int temp), const unsigned short & (unsigned short temp), const unsigned long & (unsigned long temp), const char & (char temp), const signed char & (signed char temp), const unsigned char & (unsigned char temp), const bool & (bool temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const enum SWIGTYPE & ($*1_ltype temp), const enum SWIGTYPE && ($*1_ltype temp) { if ($input.type != T_INT) Pike_error("Bad argument: Expected an integer.\n"); temp = ($*1_ltype) $input.u.integer; $1 = &temp; } %typemap(in, pikedesc="tFloat") const float & (float temp), const double & (double temp) { if ($input.type != T_FLOAT) Pike_error("Bad argument: Expected a float.\n"); temp = ($*1_ltype) $input.u.float_number; $1 = &temp; } /* ----------------------------------------------------------------------------- * Output Typemaps * ----------------------------------------------------------------------------- */ %typemap(out, pikedesc="tInt") int, unsigned int, short, unsigned short, long, unsigned long, char, signed char, unsigned char, bool, enum SWIGTYPE "push_int($1);"; %typemap(out, pikedesc="tInt") long long "push_int64($1);"; %typemap(out, pikedesc="tInt") unsigned long long "push_int64($1);"; %typemap(out, pikedesc="tFloat") float, double "push_float($1);"; %typemap(out, pikedesc="tStr") char * "push_text($1);"; /* Pointers, references, and arrays */ %typemap(out, pikedesc="tObj") SWIGTYPE*, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "push_object(SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));"; /* Void return value; don't push anything */ %typemap(out, pikedesc="tVoid") void ""; /* Dynamic casts */ %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC "/* FIXME */"; /* Member pointer */ %typemap(out) SWIGTYPE (CLASS::*) "/* FIXME */"; /* Special typemap for character array return values */ %typemap(out, pikedesc="tStr") char [ANY], const char [ANY] "push_text($1);"; /* Primitive types--return by value */ %typemap(out, pikedesc="tObj") SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; resultptr = new $1_ltype((const $1_ltype &) $1); push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1)); } #else { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1)); } #endif /* References to primitive types. Return by value */ %typemap(out, pikedesc="tInt") const int &, const unsigned int &, const short &, const unsigned short &, const long &, const unsigned long &, const char &, const signed char &, const unsigned char &, const bool &, const long long &, const unsigned long long &, const enum SWIGTYPE & ($*1_ltype temp), const enum SWIGTYPE && ($*1_ltype temp) "push_int(*($1));"; %typemap(out, pikedesc="tFloat") const float &, const double & "push_float(*($1));"; /************************ Constant Typemaps *****************************/ %typemap(constant) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, bool, enum SWIGTYPE, long long, unsigned long long "add_integer_constant(\"$symname\", $1, 0);"; %typemap(constant) char "add_integer_constant(\"$symname\", '$1', 0);"; %typemap(constant) long long, unsigned long long "add_integer_constant(\"$symname\", $1, 0);"; %typemap(constant) float, double "add_float_constant(\"$symname\", $1, 0);"; %typemap(constant) char * "add_string_constant(\"$symname\", \"$1\", 0);"; /* ------------------------------------------------------------ * String & length * ------------------------------------------------------------ */ %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { if ($input.type != T_STRING) Pike_error("Bad argument: Expected a string.\n"); $1 = ($1_ltype) STR0($input.u.string); $2 = ($2_ltype) $input.u.string->length; } /* ------------------------------------------------------------ * ANSI C typemaps * ------------------------------------------------------------ */ %typemap(in, pikedesc="tInt") size_t { if ($input.type != T_INT) Pike_error("Bad argument: Expected an integer.\n"); $1 = ($1_ltype) $input.u.integer; } %typemap(out) size_t = long; /* ------------------------------------------------------------ * Typechecking rules * ------------------------------------------------------------ */ %typecheck(SWIG_TYPECHECK_INTEGER) int, short, long, unsigned int, unsigned short, unsigned long, signed char, unsigned char, long long, unsigned long long, const int &, const short &, const long &, const unsigned int &, const unsigned short &, const unsigned long &, const long long &, const unsigned long long &, enum SWIGTYPE, enum SWIGTYPE &, SWIGTYPE &&, bool, const bool & { $1 = ($input.type == T_INT) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_DOUBLE) float, double, const float &, const double & { $1 = (($input.type == T_FLOAT) || ($input.type == T_INT)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = ($input.type == T_INT) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = ($input.type == T_STRING) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $1_descriptor, 0) == -1) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $&1_descriptor, 0) == -1) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, 0, 0) == -1) { $1 = 0; } else { $1 = 1; } } /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus %rename("`+") *::operator+; %rename("`-") *::operator-; %rename("`*") *::operator*; %rename("`/") *::operator/; %rename("`%") *::operator%; %rename("`<<") *::operator<<; %rename("`>>") *::operator>>; %rename("`&") *::operator&; %rename("`|") *::operator|; %rename("`^") *::operator^; %rename("`~") *::operator~; %rename("`<") *::operator<; %rename("`>") *::operator>; %rename("`==") *::operator==; /* Special cases */ %rename("`()") *::operator(); #endif /* ------------------------------------------------------------ * The start of the Pike initialization function * ------------------------------------------------------------ */ %init "swiginit.swg" %init %{ #ifdef __cplusplus extern "C" #endif PIKE_MODULE_EXIT {} #ifdef __cplusplus extern "C" #endif PIKE_MODULE_INIT { struct program *pr; SWIG_InitializeModule(0); %} /* pike keywords */ %include swig-3.0.2/Lib/pike/pikerun.swg0000664000175000017500000000403712343605122016204 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pikerun.swg * * This file contains the runtime support for Pike modules * and includes code for managing global variables and pointer * type checking. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif #include "pike/object.h" #include "pike/program.h" #ifdef __cplusplus } #endif #include /* Stores information about a wrapped object */ typedef struct swig_object_wrapper { void *self; swig_type_info *type; } swig_object_wrapper; #ifdef THIS #undef THIS #endif #define THIS (((swig_object_wrapper *) Pike_fp->current_storage)->self) #define SWIG_ConvertPtr SWIG_Pike_ConvertPtr #define SWIG_NewPointerObj SWIG_Pike_NewPointerObj #define SWIG_GetModule(clientdata) SWIG_Pike_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Pike_SetModule(pointer) /* These need to be filled in before type sharing between modules will work */ static swig_module_info *SWIG_Pike_GetModule(void *SWIGUNUSEDPARM(clientdata)) { return 0; } static void SWIG_Pike_SetModule(swig_module_info *pointer) { } /* Convert a pointer value */ static int SWIG_Pike_ConvertPtr(struct object *obj, void **ptr, swig_type_info *ty, int flags) { struct program *pr; swig_cast_info *tc; swig_object_wrapper *obj_wrapper; if (ty) { pr = (struct program *) ty->clientdata; obj_wrapper = (swig_object_wrapper *) get_storage(obj, pr); if (obj_wrapper && obj_wrapper->type) { tc = SWIG_TypeCheckStruct(obj_wrapper->type, ty); if (tc) { int newmemory = 0; *ptr = SWIG_TypeCast(tc, obj_wrapper->self, &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return 0; } } } return -1; } /* Create a new pointer object */ static struct object * SWIG_Pike_NewPointerObj(void *ptr, swig_type_info *type, int own) { return 0; } swig-3.0.2/Lib/pike/std_string.i0000664000175000017500000000310712343605122016334 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; class string; /* Overloading check */ %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; %typemap(in, pikedesc="tStr") string { if ($input.type != T_STRING) Pike_error("Bad argument: Expected a string.\n"); $1.assign(STR0($input.u.string)); } %typemap(in, pikedesc="tStr") const string & ($*1_ltype temp) { if ($input.type != T_STRING) Pike_error("Bad argument: Expected a string.\n"); temp.assign(STR0($input.u.string)); $1 = &temp; } %typemap(out, pikedesc="tStr") string "push_text($1.c_str());"; %typemap(out, pikedesc="tStr") const string & "push_text($1->c_str());"; %typemap(directorin) string, const string &, string & "$1.c_str()"; %typemap(directorin) string *, const string * "$1->c_str()"; %typemap(directorout) string { if ($input.type == T_STRING) $result.assign(STR0($input.u.string)); else throw Swig::DirectorTypeMismatchException("string expected"); } %typemap(directorout) const string & ($*1_ltype temp) { if ($input.type == T_STRING) { temp.assign(STR0($input.u.string)); $result = &temp; } else { throw Swig::DirectorTypeMismatchException("string expected"); } } } swig-3.0.2/Lib/d/0000775000175000017500000000000012343605122013274 5ustar williamwilliamswig-3.0.2/Lib/d/dexception.swg0000664000175000017500000000222612343605122016162 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dexception.swg * * Typemaps used for propagating C++ exceptions to D. * ----------------------------------------------------------------------------- */ // Code which is inserted into the dout typemaps and class constructors via // excode if exceptions can be thrown. %define SWIGEXCODE "\n if ($imdmodule.SwigPendingException.isPending) throw $imdmodule.SwigPendingException.retrieve();" %enddef %typemap(throws, canthrow=1) int, long, short, unsigned int, unsigned long, unsigned short %{ char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); SWIG_DSetPendingException(SWIG_DException, error_msg); return $null; %} %typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY], enum SWIGTYPE, const enum SWIGTYPE & %{ (void)$1; SWIG_DSetPendingException(SWIG_DException, "C++ $1_type exception thrown"); return $null; %} %typemap(throws, canthrow=1) char * %{ SWIG_DSetPendingException(SWIG_DException, $1); return $null; %} swig-3.0.2/Lib/d/director.swg0000664000175000017500000000223212343605122015630 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that D proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #if defined(DEBUG_DIRECTOR_OWNED) #include #endif #include #include namespace Swig { // Director base class – not used in D directors. class Director { }; // Base class for director exceptions. class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(const std::string &msg) : swig_msg(msg) { } virtual ~DirectorException() throw() { } const char *what() const throw() { return swig_msg.c_str(); } }; // Exception which is thrown when attempting to call a pure virtual method // from D code through the director layer. class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) { } }; } swig-3.0.2/Lib/d/ddirectives.swg0000664000175000017500000000072212343605122016324 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ddirectives.swg * * D-specifiv directives. * ----------------------------------------------------------------------------- */ #define %dmanifestconst %feature("d:manifestconst") #define %dconstvalue(value) %feature("d:constvalue",value) #define %dmethodmodifiers %feature("d:methodmodifiers") #define %dnothrowexception %feature("except") swig-3.0.2/Lib/d/std_map.i0000664000175000017500000000332112343605122015074 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; } swig-3.0.2/Lib/d/wrapperloader.swg0000664000175000017500000001732712343605122016677 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wrapperloader.swg * * Support code for dynamically linking the C wrapper library from the D * wrapper module. * * The loading code was adapted from the Derelict project and is used with * permission from Michael Parker, the original author. * ----------------------------------------------------------------------------- */ %pragma(d) wrapperloadercode = %{ private { version(linux) { version = Nix; } else version(darwin) { version = Nix; } else version(OSX) { version = Nix; } else version(FreeBSD) { version = Nix; version = freebsd; } else version(freebsd) { version = Nix; } else version(Unix) { version = Nix; } else version(Posix) { version = Nix; } version(Tango) { static import tango.stdc.string; static import tango.stdc.stringz; version (PhobosCompatibility) { } else { alias char[] string; alias wchar[] wstring; alias dchar[] dstring; } } else { version(D_Version2) { static import std.conv; } static import std.string; static import std.c.string; } version(D_Version2) { mixin("alias const(char)* CCPTR;"); } else { alias char* CCPTR; } CCPTR swigToCString(string str) { version(Tango) { return tango.stdc.stringz.toStringz(str); } else { return std.string.toStringz(str); } } string swigToDString(CCPTR cstr) { version(Tango) { return tango.stdc.stringz.fromStringz(cstr); } else { version(D_Version2) { mixin("return std.conv.to!string(cstr);"); } else { return std.c.string.toString(cstr); } } } } class SwigSwigSharedLibLoadException : Exception { this(in string[] libNames, in string[] reasons) { string msg = "Failed to load one or more shared libraries:"; foreach(i, n; libNames) { msg ~= "\n\t" ~ n ~ " - "; if(i < reasons.length) msg ~= reasons[i]; else msg ~= "Unknown"; } super(msg); } } class SwigSymbolLoadException : Exception { this(string SwigSharedLibName, string symbolName) { super("Failed to load symbol " ~ symbolName ~ " from shared library " ~ SwigSharedLibName); _symbolName = symbolName; } string symbolName() { return _symbolName; } private: string _symbolName; } private { version(Nix) { version(freebsd) { // the dl* functions are in libc on FreeBSD } else { pragma(lib, "dl"); } version(Tango) { import tango.sys.Common; } else version(linux) { import std.c.linux.linux; } else { extern(C) { const RTLD_NOW = 2; void *dlopen(CCPTR file, int mode); int dlclose(void* handle); void *dlsym(void* handle, CCPTR name); CCPTR dlerror(); } } alias void* SwigSharedLibHandle; SwigSharedLibHandle swigLoadSharedLib(string libName) { return dlopen(swigToCString(libName), RTLD_NOW); } void swigUnloadSharedLib(SwigSharedLibHandle hlib) { dlclose(hlib); } void* swigGetSymbol(SwigSharedLibHandle hlib, string symbolName) { return dlsym(hlib, swigToCString(symbolName)); } string swigGetErrorStr() { CCPTR err = dlerror(); if (err is null) { return "Unknown Error"; } return swigToDString(err); } } else version(Windows) { alias ushort WORD; alias uint DWORD; alias CCPTR LPCSTR; alias void* HMODULE; alias void* HLOCAL; alias int function() FARPROC; struct VA_LIST {} extern (Windows) { HMODULE LoadLibraryA(LPCSTR); FARPROC GetProcAddress(HMODULE, LPCSTR); void FreeLibrary(HMODULE); DWORD GetLastError(); DWORD FormatMessageA(DWORD, in void*, DWORD, DWORD, LPCSTR, DWORD, VA_LIST*); HLOCAL LocalFree(HLOCAL); } DWORD MAKELANGID(WORD p, WORD s) { return (((cast(WORD)s) << 10) | cast(WORD)p); } enum { LANG_NEUTRAL = 0, SUBLANG_DEFAULT = 1, FORMAT_MESSAGE_ALLOCATE_BUFFER = 256, FORMAT_MESSAGE_IGNORE_INSERTS = 512, FORMAT_MESSAGE_FROM_SYSTEM = 4096 } alias HMODULE SwigSharedLibHandle; SwigSharedLibHandle swigLoadSharedLib(string libName) { return LoadLibraryA(swigToCString(libName)); } void swigUnloadSharedLib(SwigSharedLibHandle hlib) { FreeLibrary(hlib); } void* swigGetSymbol(SwigSharedLibHandle hlib, string symbolName) { return GetProcAddress(hlib, swigToCString(symbolName)); } string swigGetErrorStr() { DWORD errcode = GetLastError(); LPCSTR msgBuf; DWORD i = FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, null, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), cast(LPCSTR)&msgBuf, 0, null); string text = swigToDString(msgBuf); LocalFree(cast(HLOCAL)msgBuf); if (i >= 2) { i -= 2; } return text[0 .. i]; } } else { static assert(0, "Operating system not supported by the wrapper loading code."); } final class SwigSharedLib { void load(string[] names) { if (_hlib !is null) return; string[] failedLibs; string[] reasons; foreach(n; names) { _hlib = swigLoadSharedLib(n); if (_hlib is null) { failedLibs ~= n; reasons ~= swigGetErrorStr(); continue; } _name = n; break; } if (_hlib is null) { throw new SwigSwigSharedLibLoadException(failedLibs, reasons); } } void* loadSymbol(string symbolName, bool doThrow = true) { void* sym = swigGetSymbol(_hlib, symbolName); if(doThrow && (sym is null)) { throw new SwigSymbolLoadException(_name, symbolName); } return sym; } void unload() { if(_hlib !is null) { swigUnloadSharedLib(_hlib); _hlib = null; } } private: string _name; SwigSharedLibHandle _hlib; } } static this() { string[] possibleFileNames; version (Posix) { version (OSX) { possibleFileNames ~= ["lib$wraplibrary.dylib", "lib$wraplibrary.bundle"]; } possibleFileNames ~= ["lib$wraplibrary.so"]; } else version (Windows) { possibleFileNames ~= ["$wraplibrary.dll", "lib$wraplibrary.so"]; } else { static assert(false, "Operating system not supported by the wrapper loading code."); } auto library = new SwigSharedLib; library.load(possibleFileNames); string bindCode(string functionPointer, string symbol) { return functionPointer ~ " = cast(typeof(" ~ functionPointer ~ "))library.loadSymbol(`" ~ symbol ~ "`);"; } //#if !defined(SWIG_D_NO_EXCEPTION_HELPER) mixin(bindCode("swigRegisterExceptionCallbacks$module", "SWIGRegisterExceptionCallbacks_$module")); //#endif // SWIG_D_NO_EXCEPTION_HELPER //#if !defined(SWIG_D_NO_STRING_HELPER) mixin(bindCode("swigRegisterStringCallback$module", "SWIGRegisterStringCallback_$module")); //#endif // SWIG_D_NO_STRING_HELPER $wrapperloaderbindcode } //#if !defined(SWIG_D_NO_EXCEPTION_HELPER) extern(C) void function( SwigExceptionCallback exceptionCallback, SwigExceptionCallback illegalArgumentCallback, SwigExceptionCallback illegalElementCallback, SwigExceptionCallback ioCallback, SwigExceptionCallback noSuchElementCallback) swigRegisterExceptionCallbacks$module; //#endif // SWIG_D_NO_EXCEPTION_HELPER //#if !defined(SWIG_D_NO_STRING_HELPER) extern(C) void function(SwigStringCallback callback) swigRegisterStringCallback$module; //#endif // SWIG_D_NO_STRING_HELPER %} %pragma(d) wrapperloaderbindcommand = %{ mixin(bindCode("$function", "$symbol"));%} swig-3.0.2/Lib/d/dvoid.swg0000664000175000017500000000105712343605122015126 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dvoid.swg * * Typemaps for handling void function return types and empty parameter lists. * ----------------------------------------------------------------------------- */ %typemap(ctype) void "void" %typemap(imtype) void "void" %typemap(dtype, cprimitive="1") void "void" %typemap(out, null="") void "" %typemap(ddirectorin) void "$winput" %typemap(ddirectorout) void "$dcall" %typemap(directorin) void "" %typemap(dout, excode=SWIGEXCODE) void { $imcall;$excode } swig-3.0.2/Lib/d/std_pair.i0000664000175000017500000000127712343605122015262 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T t, U u); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/d/typemaps.i0000664000175000017500000002547712343605122015327 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* INPUT typemaps -------------- These typemaps are used for pointer/reference parameters that are input only and are mapped to a D input parameter. The following typemaps can be applied to turn a pointer or reference into a simple input value. That is, instead of passing a pointer or reference to an object, you would use a real value instead. bool *INPUT, bool &INPUT signed char *INPUT, signed char &INPUT unsigned char *INPUT, unsigned char &INPUT short *INPUT, short &INPUT unsigned short *INPUT, unsigned short &INPUT int *INPUT, int &INPUT unsigned int *INPUT, unsigned int &INPUT long *INPUT, long &INPUT unsigned long *INPUT, unsigned long &INPUT long long *INPUT, long long &INPUT unsigned long long *INPUT, unsigned long long &INPUT float *INPUT, float &INPUT double *INPUT, double &INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); In D you could then use it like this: double answer = fadd(10.0, 20.0); */ %define INPUT_TYPEMAP(TYPE, CTYPE, DTYPE) %typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE" %typemap(imtype, out="void*") TYPE *INPUT, TYPE &INPUT "DTYPE" %typemap(dtype, out="DTYPE*") TYPE *INPUT, TYPE &INPUT "DTYPE" %typemap(din) TYPE *INPUT, TYPE &INPUT "$dinput" %typemap(in) TYPE *INPUT, TYPE &INPUT %{ $1 = ($1_ltype)&$input; %} %typemap(typecheck) TYPE *INPUT = TYPE; %typemap(typecheck) TYPE &INPUT = TYPE; %enddef INPUT_TYPEMAP(bool, unsigned int, bool) //INPUT_TYPEMAP(char, char, char) // Why was this commented out? INPUT_TYPEMAP(signed char, signed char, byte) INPUT_TYPEMAP(unsigned char, unsigned char, ubyte) INPUT_TYPEMAP(short, short, short) INPUT_TYPEMAP(unsigned short, unsigned short, ushort) INPUT_TYPEMAP(int, int, int) INPUT_TYPEMAP(unsigned int, unsigned int, uint) INPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE) INPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE) INPUT_TYPEMAP(long long, long long, long) INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong) INPUT_TYPEMAP(float, float, float) INPUT_TYPEMAP(double, double, double) INPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int) %typemap(dtype) enum SWIGTYPE *INPUT, enum SWIGTYPE &INPUT "$*dclassname" #undef INPUT_TYPEMAP /* OUTPUT typemaps --------------- These typemaps are used for pointer/reference parameters that are output only and are mapped to a D output parameter. The following typemaps can be applied to turn a pointer or reference into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In D, the 'out' keyword is used when passing the parameter to a function that takes an output parameter. bool *OUTPUT, bool &OUTPUT signed char *OUTPUT, signed char &OUTPUT unsigned char *OUTPUT, unsigned char &OUTPUT short *OUTPUT, short &OUTPUT unsigned short *OUTPUT, unsigned short &OUTPUT int *OUTPUT, int &OUTPUT unsigned int *OUTPUT, unsigned int &OUTPUT long *OUTPUT, long &OUTPUT unsigned long *OUTPUT, unsigned long &OUTPUT long long *OUTPUT, long long &OUTPUT unsigned long long *OUTPUT, unsigned long long &OUTPUT float *OUTPUT, float &OUTPUT double *OUTPUT, double &OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters): double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The D output of the function would be the function return value and the value returned in the second output parameter. In D you would use it like this: double dptr; double fraction = modf(5, dptr); */ %define OUTPUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE) %typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *" %typemap(imtype, out="void*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE" %typemap(dtype, out="DTYPE*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE" %typemap(din) TYPE *OUTPUT, TYPE &OUTPUT "$dinput" %typemap(in) TYPE *OUTPUT, TYPE &OUTPUT %{ $1 = ($1_ltype)$input; %} %typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *OUTPUT, TYPE &OUTPUT "" %enddef OUTPUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) //OUTPUT_TYPEMAP(char, char, char, CHAR_PTR) // Why was this commented out? OUTPUT_TYPEMAP(signed char, signed char, byte, INT8_PTR) OUTPUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR) OUTPUT_TYPEMAP(short, short, short, INT16_PTR) OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) OUTPUT_TYPEMAP(int, int, int, INT32_PTR) OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) OUTPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR) OUTPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR) OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR) OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR) OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR) OUTPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR) %typemap(dtype) enum SWIGTYPE *OUTPUT, enum SWIGTYPE &OUTPUT "out $*dclassname" #undef OUTPUT_TYPEMAP %typemap(in) bool *OUTPUT, bool &OUTPUT %{ *$input = 0; $1 = ($1_ltype)$input; %} /* INOUT typemaps -------------- These typemaps are for pointer/reference parameters that are both input and output and are mapped to a D reference parameter. The following typemaps can be applied to turn a pointer or reference into a reference parameters, that is the parameter is both an input and an output. In D, the 'ref' keyword is used for reference parameters. bool *INOUT, bool &INOUT signed char *INOUT, signed char &INOUT unsigned char *INOUT, unsigned char &INOUT short *INOUT, short &INOUT unsigned short *INOUT, unsigned short &INOUT int *INOUT, int &INOUT unsigned int *INOUT, unsigned int &INOUT long *INOUT, long &INOUT unsigned long *INOUT, unsigned long &INOUT long long *INOUT, long long &INOUT unsigned long long *INOUT, unsigned long long &INOUT float *INOUT, float &INOUT double *INOUT, double &INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); The D output of the function would be the new value returned by the reference parameter. In D you would use it like this: double x = 5.0; neg(x); The implementation of the OUTPUT and INOUT typemaps is different to the scripting languages in that the scripting languages will return the output value as part of the function return value. */ %define INOUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE) %typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *" %typemap(imtype, out="void*") TYPE *INOUT, TYPE &INOUT "ref DTYPE" %typemap(dtype, out="DTYPE*") TYPE *INOUT, TYPE &INOUT "ref DTYPE" %typemap(din) TYPE *INOUT, TYPE &INOUT "$dinput" %typemap(in) TYPE *INOUT, TYPE &INOUT %{ $1 = ($1_ltype)$input; %} %typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *INOUT, TYPE &INOUT "" %enddef INOUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) //INOUT_TYPEMAP(char, char, char, CHAR_PTR) INOUT_TYPEMAP(signed char, signed char, byte, INT8_PTR) INOUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR) INOUT_TYPEMAP(short, short, short, INT16_PTR) INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) INOUT_TYPEMAP(int, int, int, INT32_PTR) INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) INOUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR) INOUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR) INOUT_TYPEMAP(long long, long long, long, INT64_PTR) INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) INOUT_TYPEMAP(float, float, float, FLOAT_PTR) INOUT_TYPEMAP(double, double, double, DOUBLE_PTR) INOUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR) %typemap(dtype) enum SWIGTYPE *INOUT, enum SWIGTYPE &INOUT "ref $*dclassname" #undef INOUT_TYPEMAP swig-3.0.2/Lib/d/boost_shared_ptr.i0000664000175000017500000002003612343605122017010 0ustar williamwilliam%include %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ((*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\"))) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // plain value %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{ argp = ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0; if (!argp) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ $result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in, canthrow=1) CONST TYPE & %{ $1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); if (!$1) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type reference is null"); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = (TYPE *)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ if ($input) $1 = *($&1_ltype)$input; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ $result = $1 ? new $1_ltype($1) : 0; %} // shared_ptr by reference %typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) %{ $1 = $input ? ($1_ltype)$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ $result = *$1 ? new $*1_ltype(*$1) : 0; %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) %{ $1 = $input ? ($1_ltype)$input : &tempnull; %} %typemap(out, fragment="SWIG_null_deleter") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ $result = ($1 && *$1) ? new $*1_ltype(*($1_ltype)$1) : 0; if ($owner) delete $1; %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0) %{ temp = $input ? *($1_ltype)&$input : &tempnull; $1 = &temp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void *" %typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void*" %typemap (dtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(dtype, TYPE)" %typemap(din) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(dtype, TYPE).swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) CONST TYPE { auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) CONST TYPE & { auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) CONST TYPE * { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) TYPE *CONST& { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } // For shared pointers, both the derived and the base class have to »own« their // pointer; otherwise the reference count is not decreased properly on destruction. %typemap(dbody) SWIGTYPE %{ private void* swigCPtr; private bool swigCMemOwn; public this(void* cObject, bool ownCObject) { swigCPtr = cObject; swigCMemOwn = ownCObject; } public static void* swigGetCPtr($dclassname obj) { return (obj is null) ? null : obj.swigCPtr; } %} %typemap(dbody_derived) SWIGTYPE %{ private void* swigCPtr; private bool swigCMemOwn; public this(void* cObject, bool ownCObject) { super($imdmodule.$dclazznameSmartPtrUpcast(cObject), ownCObject); swigCPtr = cObject; swigCMemOwn = ownCObject; } public static void* swigGetCPtr($dclassname obj) { return (obj is null) ? null : obj.swigCPtr; } %} %typemap(ddispose, methodname="dispose", methodmodifiers="public") TYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = null; } } } %typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") TYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = null; super.dispose(); } } } %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.2/Lib/d/d.swg0000664000175000017500000000250512343605122014243 0ustar williamwilliam/* ----------------------------------------------------------------------------- * d.swg * * Main library file for the D language module. See the D chapter in the SWIG * manual for explanation on the typemaps, pragmas, etc. used. * ----------------------------------------------------------------------------- */ // Typemaps for exception handling. %include // Typemaps for primitive types. %include // Typemaps for non-primitive types (C/C++ classes and structs). %include // Typemaps for enumeration types. %include // Typemaps for member function pointers. %include // Typemaps for wrapping pointers to/arrays of C chars as D strings. %include // Typemaps for handling void function return types and empty parameter lists. %include // Typemaps containing D code used when generating D proxy classes. %include // Mapping of C++ operator overloading methods to D. %include // Helper code string and exception handling. %include // Wrapper loader code for dynamically linking the C wrapper library from the D // wrapper module. %include // List of all reserved D keywords. %include // D-specific directives. %include swig-3.0.2/Lib/d/carrays.i0000664000175000017500000000501712343605122015115 0ustar williamwilliam/* ----------------------------------------------------------------------------- * carrays.i * * D-specific version of ../carrays.i. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %array_functions(TYPE,NAME) * * Generates functions for creating and accessing elements of a C array * (as pointers). Creates the following functions: * * TYPE *new_NAME(int nelements) * void delete_NAME(TYPE *); * TYPE NAME_getitem(TYPE *, int index); * void NAME_setitem(TYPE *, int index, TYPE value); * * ----------------------------------------------------------------------------- */ %define %array_functions(TYPE,NAME) %{ static TYPE *new_##NAME(int nelements) { %} #ifdef __cplusplus %{ return new TYPE[nelements]; %} #else %{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %} #endif %{} static void delete_##NAME(TYPE *ary) { %} #ifdef __cplusplus %{ delete [] ary; %} #else %{ free(ary); %} #endif %{} static TYPE NAME##_getitem(TYPE *ary, int index) { return ary[index]; } static void NAME##_setitem(TYPE *ary, int index, TYPE value) { ary[index] = value; } %} TYPE *new_##NAME(int nelements); void delete_##NAME(TYPE *ary); TYPE NAME##_getitem(TYPE *ary, int index); void NAME##_setitem(TYPE *ary, int index, TYPE value); %enddef /* ----------------------------------------------------------------------------- * %array_class(TYPE,NAME) * * Generates a class wrapper around a C array. The class has the following * interface: * * struct NAME { * NAME(int nelements); * ~NAME(); * TYPE getitem(int index); * void setitem(int index, TYPE value); * TYPE * ptr(); * static NAME *frompointer(TYPE *t); * } * * ----------------------------------------------------------------------------- */ %define %array_class(TYPE,NAME) %{ typedef TYPE NAME; %} typedef struct {} NAME; %extend NAME { #ifdef __cplusplus NAME(int nelements) { return new TYPE[nelements]; } ~NAME() { delete [] self; } #else NAME(int nelements) { return (TYPE *) calloc(nelements,sizeof(TYPE)); } ~NAME() { free(self); } #endif TYPE getitem(int index) { return self[index]; } void setitem(int index, TYPE value) { self[index] = value; } TYPE * ptr() { return self; } static NAME *frompointer(TYPE *t) { return (NAME *) t; } }; %types(NAME = TYPE); %enddef swig-3.0.2/Lib/d/std_common.i0000664000175000017500000000014612343605122015611 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.2/Lib/d/dmemberfunctionpointers.swg0000664000175000017500000000516312343605122020770 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dmemberfunctionpointers.swg * * Typemaps for member function pointers. * ----------------------------------------------------------------------------- */ %typemap(ctype) SWIGTYPE (CLASS::*) "char *" %typemap(imtype) SWIGTYPE (CLASS::*) "char*" %typemap(dtype) SWIGTYPE (CLASS::*) "$dclassname" %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE (CLASS::*) "" /* * Conversion generation typemaps. */ %typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{ SWIG_UnpackData($input, (void *)&$1, sizeof($1)); %} %typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{ char buf[128]; char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1)); *data = '\0'; $result = SWIG_d_string_callback(buf); %} %typemap(directorin) SWIGTYPE (CLASS::*) "$input = (void *) $1;" %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*) "$result = ($1_ltype)$input;" %typemap(ddirectorin) SWIGTYPE (CLASS::*) "($winput is null) ? null : new $dclassname($winput, false)" %typemap(ddirectorout) SWIGTYPE (CLASS::*) "$dclassname.swigGetCPtr($dcall)" %typemap(din) SWIGTYPE (CLASS::*) "$dclassname.swigGetCMemberPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) { char* cMemberPtr = $imcall; $dclassname ret = (cMemberPtr is null) ? null : new $dclassname(cMemberPtr, $owner);$excode return ret; } /* * Helper functions to pack/unpack arbitrary binary data (member function * pointers in this case) into a string. */ %fragment("SWIG_PackData", "header") { /* Pack binary data into a string */ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; const unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } } %fragment("SWIG_UnPackData", "header") { /* Unpack binary data from a string */ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } } swig-3.0.2/Lib/d/dkw.swg0000664000175000017500000000456512343605122014615 0ustar williamwilliam#ifndef D_DKW_SWG_ #define D_DKW_SWG_ /* Warnings for D keywords */ #define DKEYWORD(x) %keywordwarn("'" `x` "' is a D keyword, renaming to '_" `x` "'",rename="_%s") `x` // Source: http://www.digitalmars.com/d/{1.0,2.0}/lex.html and DKEYWORD(Error); DKEYWORD(Exception); DKEYWORD(Object); DKEYWORD(__FILE__); DKEYWORD(__LINE__); DKEYWORD(__gshared); DKEYWORD(__thread); DKEYWORD(__traits); DKEYWORD(abstract); DKEYWORD(alias); DKEYWORD(align); DKEYWORD(asm); DKEYWORD(assert); DKEYWORD(auto); DKEYWORD(body); DKEYWORD(bool); DKEYWORD(break); DKEYWORD(byte); DKEYWORD(case); DKEYWORD(cast); DKEYWORD(catch); DKEYWORD(cdouble); DKEYWORD(cent); DKEYWORD(cfloat); DKEYWORD(char); DKEYWORD(class); DKEYWORD(const); DKEYWORD(continue); DKEYWORD(creal); DKEYWORD(dchar); DKEYWORD(debug); DKEYWORD(default); DKEYWORD(delegate); DKEYWORD(delete); DKEYWORD(deprecated); DKEYWORD(do); DKEYWORD(double); DKEYWORD(dstring); DKEYWORD(else); DKEYWORD(enum); DKEYWORD(export); DKEYWORD(extern); DKEYWORD(false); DKEYWORD(final); DKEYWORD(finally); DKEYWORD(float); DKEYWORD(for); DKEYWORD(foreach); DKEYWORD(foreach_reverse); DKEYWORD(function); DKEYWORD(goto); DKEYWORD(idouble); DKEYWORD(if); DKEYWORD(ifloat); DKEYWORD(immutable); DKEYWORD(import); DKEYWORD(in); DKEYWORD(inout); DKEYWORD(int); DKEYWORD(interface); DKEYWORD(invariant); DKEYWORD(ireal); DKEYWORD(is); DKEYWORD(lazy); DKEYWORD(long); DKEYWORD(macro); DKEYWORD(mixin); DKEYWORD(module); DKEYWORD(new); DKEYWORD(nothrow); DKEYWORD(null); DKEYWORD(out); DKEYWORD(override); DKEYWORD(package); DKEYWORD(pragma); DKEYWORD(private); DKEYWORD(protected); DKEYWORD(public); DKEYWORD(pure); DKEYWORD(real); DKEYWORD(ref); DKEYWORD(return); DKEYWORD(scope); DKEYWORD(shared); DKEYWORD(short); DKEYWORD(static); DKEYWORD(string); DKEYWORD(struct); DKEYWORD(super); DKEYWORD(switch); DKEYWORD(synchronized); DKEYWORD(template); DKEYWORD(this); DKEYWORD(throw); DKEYWORD(true); DKEYWORD(try); DKEYWORD(typedef); DKEYWORD(typeid); DKEYWORD(typeof); DKEYWORD(ubyte); DKEYWORD(ucent); DKEYWORD(uint); DKEYWORD(ulong); DKEYWORD(union); DKEYWORD(unittest); DKEYWORD(ushort); DKEYWORD(version); DKEYWORD(void); DKEYWORD(volatile); DKEYWORD(wchar); DKEYWORD(while); DKEYWORD(with); DKEYWORD(wstring); // Not really a keyword, but dispose() methods are generated in proxy classes // and it's a special method name for D1/Tango. DKEYWORD(dispose); #undef DKEYWORD #endif //D_DKW_SWG_ swig-3.0.2/Lib/d/dhead.swg0000664000175000017500000002314012343605122015063 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dhead.swg * * Support code for exceptions if the SWIG_D_NO_EXCEPTION_HELPER is not defined * Support code for strings if the SWIG_D_NO_STRING_HELPER is not defined * * Support code for function pointers. ----------------------------------------------------------------------------- */ %insert(runtime) %{ #include #include #include /* Contract support. */ #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_DSetPendingException(SWIG_DException, msg); return nullreturn; } else %} /* * Exception support code. */ #if !defined(SWIG_D_NO_EXCEPTION_HELPER) %insert(runtime) %{ // Support for throwing D exceptions from C/C++. typedef enum { SWIG_DException = 0, SWIG_DIllegalArgumentException, SWIG_DIllegalElementException, SWIG_DIOException, SWIG_DNoSuchElementException, } SWIG_DExceptionCodes; typedef void (* SWIG_DExceptionCallback_t)(const char *); typedef struct { SWIG_DExceptionCodes code; SWIG_DExceptionCallback_t callback; } SWIG_DException_t; static SWIG_DException_t SWIG_d_exceptions[] = { { SWIG_DException, NULL }, { SWIG_DIllegalArgumentException, NULL }, { SWIG_DIllegalElementException, NULL }, { SWIG_DIOException, NULL }, { SWIG_DNoSuchElementException, NULL } }; static void SWIGUNUSED SWIG_DSetPendingException(SWIG_DExceptionCodes code, const char *msg) { if ((size_t)code < sizeof(SWIG_d_exceptions)/sizeof(SWIG_DException_t)) { SWIG_d_exceptions[code].callback(msg); } else { SWIG_d_exceptions[SWIG_DException].callback(msg); } } #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGRegisterExceptionCallbacks_$module( SWIG_DExceptionCallback_t exceptionCallback, SWIG_DExceptionCallback_t illegalArgumentCallback, SWIG_DExceptionCallback_t illegalElementCallback, SWIG_DExceptionCallback_t ioCallback, SWIG_DExceptionCallback_t noSuchElementCallback) { SWIG_d_exceptions[SWIG_DException].callback = exceptionCallback; SWIG_d_exceptions[SWIG_DIllegalArgumentException].callback = illegalArgumentCallback; SWIG_d_exceptions[SWIG_DIllegalElementException].callback = illegalElementCallback; SWIG_d_exceptions[SWIG_DIOException].callback = ioCallback; SWIG_d_exceptions[SWIG_DNoSuchElementException].callback = noSuchElementCallback; } %} #if (SWIG_D_VERSION == 1) %pragma(d) imdmoduleimports=%{ // Exception throwing support currently requires Tango, but there is no reason // why it could not support Phobos. static import tango.core.Exception; static import tango.core.Thread; static import tango.stdc.stringz; %} %pragma(d) imdmodulecode=%{ private class SwigExceptionHelper { static this() { swigRegisterExceptionCallbacks$module( &setException, &setIllegalArgumentException, &setIllegalElementException, &setIOException, &setNoSuchElementException); } static void setException(char* message) { auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } static void setIllegalArgumentException(char* message) { auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } static void setIllegalElementException(char* message) { auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } static void setIOException(char* message) { auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } static void setNoSuchElementException(char* message) { auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } } package class SwigPendingException { public: static this() { m_sPendingCount = 0; m_sPendingException = new ThreadLocalData(null); } static bool isPending() { bool pending = false; if (m_sPendingCount > 0) { if (m_sPendingException.val !is null) { pending = true; } } return pending; } static void set(object.Exception e) { if (m_sPendingException.val !is null) { throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~ "was missed and thus not thrown (" ~ m_sPendingException.val.classinfo.name ~ ": " ~ m_sPendingException.val.msg ~ ")!", e); } m_sPendingException.val = e; synchronized { ++m_sPendingCount; } } static object.Exception retrieve() { object.Exception e = null; if (m_sPendingCount > 0) { if (m_sPendingException.val !is null) { e = m_sPendingException.val; m_sPendingException.val = null; synchronized { --m_sPendingCount; } } } return e; } private: // The pending exception counter is stored thread-global. static int m_sPendingCount; // The reference to the pending exception (if any) is stored thread-local. alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData; static ThreadLocalData m_sPendingException; } alias void function(char* message) SwigExceptionCallback; %} #else %pragma(d) imdmoduleimports=%{ static import std.conv; %} %pragma(d) imdmodulecode=%{ private class SwigExceptionHelper { static this() { // The D1/Tango version maps C++ exceptions to multiple exception types. swigRegisterExceptionCallbacks$module( &setException, &setException, &setException, &setException, &setException ); } static void setException(const char* message) { auto exception = new object.Exception(std.conv.to!string(message).idup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } } package struct SwigPendingException { public: static this() { m_sPendingCount = 0; m_sPendingException = null; } static bool isPending() { bool pending = false; if (m_sPendingCount > 0) { if (m_sPendingException !is null) { pending = true; } } return pending; } static void set(object.Exception e) { if (m_sPendingException !is null) { throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~ "was missed and thus not thrown (" ~ m_sPendingException.classinfo.name ~ ": " ~ m_sPendingException.msg ~ ")!", e); } m_sPendingException = e; synchronized { ++m_sPendingCount; } } static object.Exception retrieve() { object.Exception e = null; if (m_sPendingCount > 0) { if (m_sPendingException !is null) { e = m_sPendingException; m_sPendingException = null; synchronized { --m_sPendingCount; } } } return e; } private: // The pending exception counter is stored thread-global. static shared int m_sPendingCount; // The reference to the pending exception (if any) is stored thread-local. static object.Exception m_sPendingException; } alias void function(const char* message) SwigExceptionCallback; %} #endif // Callback registering function in wrapperloader.swg. #endif // SWIG_D_NO_EXCEPTION_HELPER /* * String support code. */ #if !defined(SWIG_D_NO_STRING_HELPER) %insert(runtime) %{ // Callback for returning strings to D without leaking memory. typedef char * (* SWIG_DStringHelperCallback)(const char *); static SWIG_DStringHelperCallback SWIG_d_string_callback = NULL; #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGRegisterStringCallback_$module(SWIG_DStringHelperCallback callback) { SWIG_d_string_callback = callback; } %} #if (SWIG_D_VERSION == 1) %pragma(d) imdmoduleimports = "static import tango.stdc.stringz;"; %pragma(d) imdmodulecode = %{ private class SwigStringHelper { static this() { swigRegisterStringCallback$module(&createString); } static char* createString(char* cString) { // We are effectively dup'ing the string here. return tango.stdc.stringz.toStringz(tango.stdc.stringz.fromStringz(cString)); } } alias char* function(char* cString) SwigStringCallback; %} #else %pragma(d) imdmoduleimports = %{ static import std.conv; static import std.string; %} %pragma(d) imdmodulecode = %{ private class SwigStringHelper { static this() { swigRegisterStringCallback$module(&createString); } static const(char)* createString(const(char*) cString) { // We are effectively dup'ing the string here. // TODO: Is this also correct for D2/Phobos? return std.string.toStringz(std.conv.to!string(cString)); } } alias const(char)* function(const(char*) cString) SwigStringCallback; %} #endif // Callback registering function in wrapperloader.swg. #endif // SWIG_D_NO_STRING_HELPER /* * Function pointer support code. */ #if (SWIG_D_VERSION == 1) %pragma(d) imdmodulecode = %{ template SwigExternC(T) { static if (is(typeof(*(T.init)) R == return)) { static if (is(typeof(*(T.init)) P == function)) { alias extern(C) R function(P) SwigExternC; } } } %} #else %pragma(d) imdmodulecode = %{ template SwigExternC(T) if (is(typeof(*(T.init)) P == function)) { static if (is(typeof(*(T.init)) R == return)) { static if (is(typeof(*(T.init)) P == function)) { alias extern(C) R function(P) SwigExternC; } } } %} #endif swig-3.0.2/Lib/d/std_shared_ptr.i0000664000175000017500000000010412343605122016446 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.2/Lib/d/std_vector.i0000664000175000017500000004010312343605122015620 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector, D implementation. * * The D wrapper is made to loosely resemble a tango.util.container.more.Vector * and to provide built-in array-like access. * * If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED * macro to obtain enhanced functionality (none yet), for example: * * SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass) * %template(VectKlass) std::vector; * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on * the real file contents! * ----------------------------------------------------------------------------- */ // Warning: Use the typemaps here in the expectation that the macros they are in will change name. %include // MACRO for use within the std::vector class body %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE, CTYPE...) #if (SWIG_D_VERSION == 1) %typemap(dimports) std::vector< CTYPE > "static import tango.core.Exception;" %typemap(dcode) std::vector< CTYPE > %{ public this($typemap(dtype, CTYPE)[] values) { this(); append(values); } alias push_back add; alias push_back push; alias push_back opCatAssign; alias size length; alias opSlice slice; public $typemap(dtype, CTYPE) opIndexAssign($typemap(dtype, CTYPE) value, size_t index) { if (index >= size()) { throw new tango.core.Exception.NoSuchElementException("Tried to assign to element out of vector bounds."); } setElement(index, value); return value; } public $typemap(dtype, CTYPE) opIndex(size_t index) { if (index >= size()) { throw new tango.core.Exception.NoSuchElementException("Tried to read from element out of vector bounds."); } return getElement(index); } public void append($typemap(dtype, CTYPE)[] value...) { foreach (v; value) { add(v); } } public $typemap(dtype, CTYPE)[] opSlice() { $typemap(dtype, CTYPE)[] array = new $typemap(dtype, CTYPE)[size()]; foreach (i, ref value; array) { value = getElement(i); } return array; } public int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) { int result; size_t currentSize = size(); for (size_t i = 0; i < currentSize; ++i) { auto value = getElement(i); result = dg(value); setElement(i, value); } return result; } public int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) { int result; size_t currentSize = size(); for (size_t i = 0; i < currentSize; ++i) { auto value = getElement(i); // Workaround for http://d.puremagic.com/issues/show_bug.cgi?id=2443. auto index = i; result = dg(index, value); setElement(i, value); } return result; } public void capacity(size_t value) { if (value < size()) { throw new tango.core.Exception.IllegalArgumentException("Tried to make the capacity of a vector smaller than its size."); } reserve(value); } %} public: typedef size_t size_type; typedef CTYPE value_type; typedef CONST_REFERENCE const_reference; void clear(); void push_back(CTYPE const& x); size_type size() const; size_type capacity() const; void reserve(size_type n) throw (std::length_error); vector(); vector(const vector &other); %extend { vector(size_type capacity) throw (std::length_error) { std::vector< CTYPE >* pv = 0; pv = new std::vector< CTYPE >(); // Might throw std::length_error. pv->reserve(capacity); return pv; } size_type unused() const { return $self->capacity() - $self->size(); } CONST_REFERENCE remove() throw (std::out_of_range) { if ($self->empty()) { throw std::out_of_range("Tried to remove last element from empty vector."); } std::vector< CTYPE >::const_reference value = $self->back(); $self->pop_back(); return value; } CONST_REFERENCE remove(size_type index) throw (std::out_of_range) { if (index >= $self->size()) { throw std::out_of_range("Tried to remove element with invalid index."); } std::vector< CTYPE >::iterator it = $self->begin() + index; std::vector< CTYPE >::const_reference value = *it; $self->erase(it); return value; } } // Wrappers for setting/getting items with the possibly thrown exception // specified (important for SWIG wrapper generation). %extend { CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to get value of element with invalid index."); } return (*$self)[index]; } } // Use CTYPE const& instead of const_reference to work around SWIG code // generation issue when using const pointers as vector elements (like // std::vector< const int* >). %extend { void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to set value of element with invalid index."); } (*$self)[index] = val; } } %dmethodmodifiers std::vector::getElement "private" %dmethodmodifiers std::vector::setElement "private" %dmethodmodifiers std::vector::reserve "private" #else %typemap(dimports) std::vector< CTYPE > %{ static import std.algorithm; static import std.exception; static import std.range; static import std.traits; %} %typemap(dcode) std::vector< CTYPE > %{ alias size_t KeyType; alias $typemap(dtype, CTYPE) ValueType; this(ValueType[] values...) { this(); reserve(values.length); foreach (e; values) { this ~= e; } } struct Range { private $typemap(dtype, std::vector< CTYPE >) _outer; private size_t _a, _b; this($typemap(dtype, std::vector< CTYPE >) data, size_t a, size_t b) { _outer = data; _a = a; _b = b; } @property bool empty() const { assert((cast($typemap(dtype, std::vector< CTYPE >))_outer).length >= _b); return _a >= _b; } @property Range save() { return this; } @property ValueType front() { std.exception.enforce(!empty); return _outer[_a]; } @property void front(ValueType value) { std.exception.enforce(!empty); _outer[_a] = std.algorithm.move(value); } void popFront() { std.exception.enforce(!empty); ++_a; } void opIndexAssign(ValueType value, size_t i) { i += _a; std.exception.enforce(i < _b && _b <= _outer.length); _outer[i] = value; } void opIndexOpAssign(string op)(ValueType value, size_t i) { std.exception.enforce(_outer && _a + i < _b && _b <= _outer.length); auto element = _outer[i]; mixin("element "~op~"= value;"); _outer[i] = element; } } // TODO: dup? Range opSlice() { return Range(this, 0, length); } Range opSlice(size_t a, size_t b) { std.exception.enforce(a <= b && b <= length); return Range(this, a, b); } size_t opDollar() const { return length; } @property ValueType front() { std.exception.enforce(!empty); return getElement(0); } @property void front(ValueType value) { std.exception.enforce(!empty); setElement(0, value); } @property ValueType back() { std.exception.enforce(!empty); return getElement(length - 1); } @property void back(ValueType value) { std.exception.enforce(!empty); setElement(length - 1, value); } ValueType opIndex(size_t i) { return getElement(i); } void opIndexAssign(ValueType value, size_t i) { setElement(i, value); } void opIndexOpAssign(string op)(ValueType value, size_t i) { auto element = this[i]; mixin("element "~op~"= value;"); this[i] = element; } ValueType[] opBinary(string op, Stuff)(Stuff stuff) if (op == "~") { ValueType[] result; result ~= this[]; assert(result.length == length); result ~= stuff[]; return result; } void opOpAssign(string op, Stuff)(Stuff stuff) if (op == "~") { static if (is(typeof(insertBack(stuff)))) { insertBack(stuff); } else if (is(typeof(insertBack(stuff[])))) { insertBack(stuff[]); } else { static assert(false, "Cannot append " ~ Stuff.stringof ~ " to " ~ typeof(this).stringof); } } alias size length; alias remove removeAny; alias removeAny stableRemoveAny; size_t insertBack(Stuff)(Stuff stuff) if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)){ push_back(stuff); return 1; } size_t insertBack(Stuff)(Stuff stuff) if (std.range.isInputRange!Stuff && std.traits.isImplicitlyConvertible!(std.range.ElementType!Stuff, ValueType)) { size_t itemCount; foreach(item; stuff) { insertBack(item); ++itemCount; } return itemCount; } alias insertBack insert; alias pop_back removeBack; alias pop_back stableRemoveBack; size_t insertBefore(Stuff)(Range r, Stuff stuff) if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)) { std.exception.enforce(r._outer.swigCPtr == swigCPtr && r._a < length); insertAt(r._a, stuff); return 1; } size_t insertBefore(Stuff)(Range r, Stuff stuff) if (std.range.isInputRange!Stuff && std.traits.isImplicitlyConvertible!(ElementType!Stuff, ValueType)) { std.exception.enforce(r._outer.swigCPtr == swigCPtr && r._a <= length); size_t insertCount; foreach(i, item; stuff) { insertAt(r._a + i, item); ++insertCount; } return insertCount; } size_t insertAfter(Stuff)(Range r, Stuff stuff) { // TODO: optimize immutable offset = r._a + r.length; std.exception.enforce(offset <= length); auto result = insertBack(stuff); std.algorithm.bringToFront(this[offset .. length - result], this[length - result .. length]); return result; } size_t replace(Stuff)(Range r, Stuff stuff) if (std.range.isInputRange!Stuff && std.traits.isImplicitlyConvertible!(ElementType!Stuff, ValueType)) { immutable offset = r._a; std.exception.enforce(offset <= length); size_t result; for (; !stuff.empty; stuff.popFront()) { if (r.empty) { // append the rest return result + insertBack(stuff); } r.front = stuff.front; r.popFront(); ++result; } // Remove remaining stuff in r remove(r); return result; } size_t replace(Stuff)(Range r, Stuff stuff) if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)) { if (r.empty) { insertBefore(r, stuff); } else { r.front = stuff; r.popFront(); remove(r); } return 1; } Range linearRemove(Range r) { std.exception.enforce(r._a <= r._b && r._b <= length); immutable tailLength = length - r._b; linearRemove(r._a, r._b); return this[length - tailLength .. length]; } alias remove stableLinearRemove; int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) { int result; size_t currentSize = size(); for (size_t i = 0; i < currentSize; ++i) { auto value = getElement(i); result = dg(value); setElement(i, value); } return result; } int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) { int result; size_t currentSize = size(); for (size_t i = 0; i < currentSize; ++i) { auto value = getElement(i); // Workaround for http://d.puremagic.com/issues/show_bug.cgi?id=2443. auto index = i; result = dg(index, value); setElement(i, value); } return result; } %} public: typedef size_t size_type; typedef CTYPE value_type; typedef CONST_REFERENCE const_reference; bool empty() const; void clear(); void push_back(CTYPE const& x); void pop_back(); size_type size() const; size_type capacity() const; void reserve(size_type n) throw (std::length_error); vector(); vector(const vector &other); %extend { vector(size_type capacity) throw (std::length_error) { std::vector< CTYPE >* pv = 0; pv = new std::vector< CTYPE >(); // Might throw std::length_error. pv->reserve(capacity); return pv; } CONST_REFERENCE remove() throw (std::out_of_range) { if ($self->empty()) { throw std::out_of_range("Tried to remove last element from empty vector."); } std::vector< CTYPE >::const_reference value = $self->back(); $self->pop_back(); return value; } CONST_REFERENCE remove(size_type index) throw (std::out_of_range) { if (index >= $self->size()) { throw std::out_of_range("Tried to remove element with invalid index."); } std::vector< CTYPE >::iterator it = $self->begin() + index; std::vector< CTYPE >::const_reference value = *it; $self->erase(it); return value; } void removeBack(size_type how_many) throw (std::out_of_range) { std::vector< CTYPE >::iterator end = $self->end(); std::vector< CTYPE >::iterator start = end - how_many; $self->erase(start, end); } void linearRemove(size_type start_index, size_type end_index) throw (std::out_of_range) { std::vector< CTYPE >::iterator start = $self->begin() + start_index; std::vector< CTYPE >::iterator end = $self->begin() + end_index; $self->erase(start, end); } void insertAt(size_type index, CTYPE const& x) throw (std::out_of_range) { std::vector< CTYPE >::iterator it = $self->begin() + index; $self->insert(it, x); } } // Wrappers for setting/getting items with the possibly thrown exception // specified (important for SWIG wrapper generation). %extend { CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to get value of element with invalid index."); } return (*$self)[index]; } } // Use CTYPE const& instead of const_reference to work around SWIG code // generation issue when using const pointers as vector elements (like // std::vector< const int* >). %extend { void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to set value of element with invalid index."); } (*$self)[index] = val; } } %dmethodmodifiers std::vector::getElement "private" %dmethodmodifiers std::vector::setElement "private" #endif %enddef // Extra methods added to the collection class if operator== is defined for the class being wrapped // The class will then implement IList<>, which adds extra functionality %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...) %extend { } %enddef // For vararg handling in macros, from swigmacros.swg #define %arg(X...) X // Macros for std::vector class specializations/enhancements %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(%arg(CTYPE const&), %arg(CTYPE)) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } %enddef %{ #include #include %} namespace std { // primary (unspecialized) class template for std::vector // does not require operator== to be defined template class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(T const&, T) }; // specializations for pointers template class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(T *const&, T *) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *) }; // bool is a bit different in the C++ standard - const_reference in particular template<> class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool) }; } // template specializations for std::vector // these provide extra collections methods as operator== is defined SWIG_STD_VECTOR_ENHANCED(char) SWIG_STD_VECTOR_ENHANCED(signed char) SWIG_STD_VECTOR_ENHANCED(unsigned char) SWIG_STD_VECTOR_ENHANCED(short) SWIG_STD_VECTOR_ENHANCED(unsigned short) SWIG_STD_VECTOR_ENHANCED(int) SWIG_STD_VECTOR_ENHANCED(unsigned int) SWIG_STD_VECTOR_ENHANCED(long) SWIG_STD_VECTOR_ENHANCED(unsigned long) SWIG_STD_VECTOR_ENHANCED(long long) SWIG_STD_VECTOR_ENHANCED(unsigned long long) SWIG_STD_VECTOR_ENHANCED(float) SWIG_STD_VECTOR_ENHANCED(double) SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include swig-3.0.2/Lib/d/std_string.i0000664000175000017500000000604512343605122015633 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * Typemaps for std::string and const std::string& * These are mapped to a D char[] and are passed around by value. * * To use non-const std::string references, use the following %apply. Note * that they are passed by value. * %apply const std::string & {std::string &}; * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; class string; %define SWIGD_STD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ) // string %typemap(ctype) string, const string & "char *" %typemap(imtype) string, const string & #DW_STRING_TYPE %typemap(dtype) string, const string & #DP_STRING_TYPE %typemap(in, canthrow=1) string, const string & %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string"); return $null; } $1.assign($input); %} %typemap(in, canthrow=1) const string & %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string"); return $null; } $*1_ltype $1_str($input); $1 = &$1_str; %} %typemap(out) string %{ $result = SWIG_d_string_callback($1.c_str()); %} %typemap(out) const string & %{ $result = SWIG_d_string_callback($1->c_str()); %} %typemap(din) string, const string & "($dinput ? TO_STRINGZ($dinput) : null)" %typemap(dout, excode=SWIGEXCODE) string, const string & { DP_STRING_TYPE ret = FROM_STRINGZ($imcall);$excode return ret; } %typemap(directorin) string, const string & %{ $input = SWIG_d_string_callback($1.c_str()); %} %typemap(directorout, canthrow=1) string %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string"); return $null; } $result.assign($input); %} %typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string"); return $null; } /* possible thread/reentrant code problem */ static $*1_ltype $1_str; $1_str = $input; $result = &$1_str; %} %typemap(ddirectorin) string, const string & "FROM_STRINGZ($winput)" %typemap(ddirectorout) string, const string & "TO_STRINGZ($dcall)" %typemap(throws, canthrow=1) string, const string & %{ SWIG_DSetPendingException(SWIG_DException, $1.c_str()); return $null; %} %typemap(typecheck) string, const string & = char *; %enddef // We need to have the \0-terminated string conversion functions available in // the D proxy modules. #if (SWIG_D_VERSION == 1) // Could be easily extended to support Phobos as well. SWIGD_STD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz) %pragma(d) globalproxyimports = "static import tango.stdc.stringz;"; #else SWIGD_STD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz) %pragma(d) globalproxyimports = %{ static import std.conv; static import std.string; %} #endif #undef SWIGD_STD_STRING_TYPEMAPS } // namespace std swig-3.0.2/Lib/d/dswigtype.swg0000664000175000017500000001213412343605122016036 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dswigtype.swg * * Typemaps for non-primitive types (C/C++ classes and structs). * ----------------------------------------------------------------------------- */ %typemap(ctype) SWIGTYPE "void *" %typemap(imtype) SWIGTYPE "void*" %typemap(dtype) SWIGTYPE "$&dclassname" %typemap(ctype) SWIGTYPE [] "void *" %typemap(imtype) SWIGTYPE [] "void*" %typemap(dtype) SWIGTYPE [] "$dclassname" %typemap(ctype) SWIGTYPE * "void *" %typemap(imtype) SWIGTYPE * "void*" %typemap(dtype, nativepointer="$dtype") SWIGTYPE * "$dclassname" %typemap(ctype) SWIGTYPE & "void *" %typemap(imtype) SWIGTYPE & "void*" %typemap(dtype, nativepointer="$dtype") SWIGTYPE & "$dclassname" %typemap(ctype) SWIGTYPE *const& "void *" %typemap(imtype) SWIGTYPE *const& "void*" %typemap(dtype) SWIGTYPE *const& "$*dclassname" %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE *const& "" /* * By-value conversion typemaps (parameter is converted to a pointer). */ %typemap(in, canthrow=1) SWIGTYPE ($&1_type argp) %{ argp = ($&1_ltype)$input; if (!argp) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{ $result = new $1_ltype((const $1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); $result = $1ptr; } #endif %typemap(directorin) SWIGTYPE "$input = (void *)&$1;" %typemap(directorout) SWIGTYPE %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type"); return $null; } $result = *($&1_ltype)$input; %} %typemap(ddirectorin) SWIGTYPE "new $&dclassname($winput, false)" %typemap(ddirectorout) SWIGTYPE "$&dclassname.swigGetCPtr($dcall)" %typemap(din) SWIGTYPE "$&dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIGTYPE { $&dclassname ret = new $&dclassname($imcall, true);$excode return ret; } /* * Pointer conversion typemaps. */ %typemap(in) SWIGTYPE * "$1 = ($1_ltype)$input;" %typemap(out) SWIGTYPE * "$result = (void *)$1;" %typemap(directorin) SWIGTYPE * "$input = (void *) $1;" %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE * "$result = ($1_ltype)$input;" %typemap(ddirectorin, nativepointer="cast($dtype)$winput" ) SWIGTYPE * "($winput is null) ? null : new $dclassname($winput, false)" %typemap(ddirectorout, nativepointer="cast(void*)$dcall" ) SWIGTYPE * "$dclassname.swigGetCPtr($dcall)" %typemap(din, nativepointer="cast(void*)$dinput" ) SWIGTYPE * "$dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE, nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}" ) SWIGTYPE * { void* cPtr = $imcall; $dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode return ret; } // Use the same typemaps for const pointers. %apply SWIGTYPE * { SWIGTYPE *const } /* * Reference conversion typemaps. */ %typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input; if (!$1) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type type is null"); return $null; } %} %typemap(out) SWIGTYPE & "$result = (void *)$1;" %typemap(directorin) SWIGTYPE & "$input = ($1_ltype) &$1;" %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE & %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type"); return $null; } $result = ($1_ltype)$input; %} %typemap(ddirectorin, nativepointer="cast($dtype)$winput" ) SWIGTYPE & "new $dclassname($winput, false)" %typemap(ddirectorout, nativepointer="cast(void*)$dcall" ) SWIGTYPE & "$dclassname.swigGetCPtr($dcall)" %typemap(din, nativepointer="cast(void*)$dinput" ) SWIGTYPE & "$dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE, nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}") SWIGTYPE & { $dclassname ret = new $dclassname($imcall, $owner);$excode return ret; } /* * Array conversion typemaps. */ %typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %} %typemap(out) SWIGTYPE [] %{ $result = $1; %} %typemap(din) SWIGTYPE [] "$dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIGTYPE [] { void* cPtr = $imcall; $dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode return ret; } // Treat references to arrays like like references to a single element. %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } /* * Pointer reference conversion typemaps. */ %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)$input; $1 = ($1_ltype)&temp; %} %typemap(out) SWIGTYPE *const& %{ $result = (void *)*$1; %} %typemap(din) SWIGTYPE *const& "$*dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIGTYPE *const& { void* cPtr = $imcall; $*dclassname ret = (cPtr is null) ? null : new $*dclassname(cPtr, $owner);$excode return ret; } swig-3.0.2/Lib/d/std_except.i0000664000175000017500000000355512343605122015620 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. These typemaps are * used when methods are declared with an STL exception specification, such as * size_t at() const throw (std::out_of_range); * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %ignore exception; struct exception {}; } %typemap(throws, canthrow=1) std::bad_exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::domain_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::invalid_argument "SWIG_DSetPendingException(SWIG_DIllegalArgumentException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::length_error "SWIG_DSetPendingException(SWIG_DNoSuchElementException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::logic_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::out_of_range "SWIG_DSetPendingException(SWIG_DNoSuchElementException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::overflow_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::range_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::runtime_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::underflow_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" swig-3.0.2/Lib/d/dprimitives.swg0000664000175000017500000001077612343605122016370 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dprimitves.swg * * Typemaps for primitive types. * ----------------------------------------------------------------------------- */ // C long/ulong width depends on the target arch, use stdlib aliases for them. #if (SWIG_D_VERSION == 1) %pragma(d) imdmoduleimports = "static import tango.stdc.config;" %pragma(d) globalproxyimports = "static import tango.stdc.config;" #define SWIG_LONG_DTYPE tango.stdc.config.c_long #define SWIG_ULONG_DTYPE tango.stdc.config.c_ulong #else %pragma(d) imdmoduleimports = "static import core.stdc.config;" %pragma(d) globalproxyimports = "static import core.stdc.config;" #define SWIG_LONG_DTYPE core.stdc.config.c_long #define SWIG_ULONG_DTYPE core.stdc.config.c_ulong #endif /* * The SWIG_D_PRIMITIVE macro is used to define the typemaps for the primitive * types, because are more or less the same for all of them. The few special * cases are handeled below. */ %define SWIG_D_PRIMITIVE(TYPE, DTYPE) %typemap(ctype) TYPE, const TYPE & "TYPE" %typemap(imtype) TYPE, const TYPE & "DTYPE" %typemap(dtype, cprimitive="1") TYPE, const TYPE & "DTYPE" %typemap(in) TYPE "$1 = ($1_ltype)$input;" %typemap(out) TYPE "$result = $1;" %typemap(directorin) TYPE "$input = $1;" %typemap(directorout) TYPE "$result = ($1_ltype)$input;" %typemap(ddirectorin) TYPE "$winput" %typemap(ddirectorout) TYPE "$dcall" %typemap(in) const TYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const TYPE & "$result = *$1;" %typemap(directorin) const TYPE & "$input = $1;" %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const TYPE & %{ static $*1_ltype temp; temp = ($*1_ltype)$input; $result = &temp; %} %typemap(ddirectorin) const TYPE & "$winput" %typemap(ddirectorout) const TYPE & "$dcall" %typemap(din) TYPE, const TYPE & "$dinput" %typemap(dout, excode=SWIGEXCODE) TYPE, const TYPE & { auto ret = $imcall;$excode return ret; } %enddef SWIG_D_PRIMITIVE(bool, bool) SWIG_D_PRIMITIVE(char, char) SWIG_D_PRIMITIVE(signed char, byte) SWIG_D_PRIMITIVE(unsigned char, ubyte) SWIG_D_PRIMITIVE(short, short) SWIG_D_PRIMITIVE(unsigned short, ushort) SWIG_D_PRIMITIVE(int, int) SWIG_D_PRIMITIVE(unsigned int, uint) SWIG_D_PRIMITIVE(long, SWIG_LONG_DTYPE) SWIG_D_PRIMITIVE(unsigned long, SWIG_ULONG_DTYPE) SWIG_D_PRIMITIVE(size_t, size_t) SWIG_D_PRIMITIVE(long long, long) SWIG_D_PRIMITIVE(unsigned long long, ulong) SWIG_D_PRIMITIVE(float, float) SWIG_D_PRIMITIVE(double, double) // The C++ boolean type needs some special casing since it is not part of the // C standard and is thus represented as unsigned int in the C wrapper layer. %typemap(ctype) bool, const bool & "unsigned int" %typemap(imtype) bool, const bool & "uint" %typemap(in) bool "$1 = $input ? true : false;" %typemap(in) const bool & ($*1_ltype temp) %{ temp = $input ? true : false; $1 = &temp; %} %typemap(directorout) bool "$result = $input ? true : false;" %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool & %{ static $*1_ltype temp; temp = $input ? true : false; $result = &temp; %} %typemap(ddirectorin) bool "($winput ? true : false)" %typemap(dout, excode=SWIGEXCODE) bool, const bool & { bool ret = $imcall ? true : false;$excode return ret; } // Judging from the history of the C# module, the explicit casts are needed for // certain versions of VC++. %typemap(out) unsigned long "$result = (unsigned long)$1;" %typemap(out) const unsigned long & "$result = (unsigned long)*$1;" /* * Typecheck typemaps. */ %typecheck(SWIG_TYPECHECK_BOOL) bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) char, const char & "" %typecheck(SWIG_TYPECHECK_INT8) signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_UINT8) unsigned char, const unsigned char & "" %typecheck(SWIG_TYPECHECK_INT16) short, const short & "" %typecheck(SWIG_TYPECHECK_UINT16) unsigned short, const unsigned short & "" %typecheck(SWIG_TYPECHECK_INT32) int, long, const int &, const long & "" %typecheck(SWIG_TYPECHECK_UINT32) unsigned int, unsigned long, const unsigned int &, const unsigned long & "" %typecheck(SWIG_TYPECHECK_INT64) long long, const long long & "" %typecheck(SWIG_TYPECHECK_UINT64) unsigned long long, const unsigned long long & "" %typecheck(SWIG_TYPECHECK_FLOAT) float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) double, const double & "" swig-3.0.2/Lib/d/dstrings.swg0000664000175000017500000000501112343605122015650 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dstrings.swg * * Typemaps for wrapping pointers to/arrays of C chars as D strings. * ----------------------------------------------------------------------------- */ %define SWIGD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ) %typemap(ctype) char *, char *&, char[ANY], char[] "char *" %typemap(imtype) char *, char *&, char[ANY], char[] #DW_STRING_TYPE %typemap(dtype) char *, char *&, char[ANY], char[] #DP_STRING_TYPE /* * char* typemaps. */ %typemap(in) char * %{ $1 = ($1_ltype)$input; %} %typemap(out) char * %{ $result = SWIG_d_string_callback((const char *)$1); %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %} %typemap(directorin) char * %{ $input = SWIG_d_string_callback((const char *)$1); %} %typemap(ddirectorin) char * "FROM_STRINGZ($winput)" %typemap(ddirectorout) char * "TO_STRINGZ($dcall)" /* * char*& typemaps. */ %typemap(in) char *& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) char *& %{ if ($1) $result = SWIG_d_string_callback((const char *)*$1); %} /* * char array typemaps. */ %typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %} %typemap(out) char[ANY], char[] %{ $result = SWIG_d_string_callback((const char *)$1); %} %typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %} %typemap(directorin) char[ANY], char[] %{ $input = SWIG_d_string_callback((const char *)$1); %} %typemap(ddirectorin) char[ANY], char[] "$winput" %typemap(ddirectorout) char[ANY], char[] "$dcall" %typemap(din) char *, char *&, char[ANY], char[] "($dinput ? TO_STRINGZ($dinput) : null)" %typemap(dout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] { DP_STRING_TYPE ret = FROM_STRINGZ ## ($imcall);$excode return ret; } %typecheck(SWIG_TYPECHECK_STRING) char *, char *&, char[ANY], char[] "" %enddef // We need to have the \0-terminated string conversion functions available in // the D proxy modules. #if (SWIG_D_VERSION == 1) // Could be easily extended to support Phobos as well. SWIGD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz) %pragma(d) globalproxyimports = "static import tango.stdc.stringz;"; #else SWIGD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz) %pragma(d) globalproxyimports = %{ static import std.conv; static import std.string; %} #endif #undef SWIGD_STRING_TYPEMAPS swig-3.0.2/Lib/d/stl.i0000664000175000017500000000054512343605122014254 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/d/std_deque.i0000664000175000017500000000003412343605122015420 0ustar williamwilliam%include swig-3.0.2/Lib/d/cpointer.i0000664000175000017500000000663212343605122015300 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cpointer.i * * D-specific version of ../cpointer.i. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %pointer_class(type,name) * * Places a simple proxy around a simple type like 'int', 'float', or whatever. * The proxy provides this interface: * * class type { * public: * type(); * ~type(); * type value(); * void assign(type value); * }; * * Example: * * %pointer_class(int, intp); * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = intp() * >>> a.assign(10) * >>> a.value() * 10 * >>> b = intp() * >>> b.assign(20) * >>> print add(a,b) * 30 * * As a general rule, this macro should not be used on class/structures that * are already defined in the interface. * ----------------------------------------------------------------------------- */ %define %pointer_class(TYPE, NAME) %{ typedef TYPE NAME; %} typedef struct { } NAME; %extend NAME { #ifdef __cplusplus NAME() { return new TYPE(); } ~NAME() { if (self) delete self; } #else NAME() { return (TYPE *) calloc(1,sizeof(TYPE)); } ~NAME() { if (self) free(self); } #endif } %extend NAME { void assign(TYPE value) { *self = value; } TYPE value() { return *self; } TYPE * ptr() { return self; } static NAME * frompointer(TYPE *t) { return (NAME *) t; } } %types(NAME = TYPE); %enddef /* ----------------------------------------------------------------------------- * %pointer_functions(type,name) * * Create functions for allocating/deallocating pointers. This can be used * if you don't want to create a proxy class or if the pointer is complex. * * %pointer_functions(int, intp) * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = copy_intp(10) * >>> intp_value(a) * 10 * >>> b = new_intp() * >>> intp_assign(b,20) * >>> print add(a,b) * 30 * >>> delete_intp(a) * >>> delete_intp(b) * * ----------------------------------------------------------------------------- */ %define %pointer_functions(TYPE,NAME) %{ static TYPE *new_##NAME() { %} #ifdef __cplusplus %{ return new TYPE(); %} #else %{ return (TYPE *) calloc(1,sizeof(TYPE)); %} #endif %{} static TYPE *copy_##NAME(TYPE value) { %} #ifdef __cplusplus %{ return new TYPE(value); %} #else %{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE)); *self = value; return self; %} #endif %{} static void delete_##NAME(TYPE *self) { %} #ifdef __cplusplus %{ if (self) delete self; %} #else %{ if (self) free(self); %} #endif %{} static void NAME ##_assign(TYPE *self, TYPE value) { *self = value; } static TYPE NAME ##_value(TYPE *self) { return *self; } %} TYPE *new_##NAME(); TYPE *copy_##NAME(TYPE value); void delete_##NAME(TYPE *self); void NAME##_assign(TYPE *self, TYPE value); TYPE NAME##_value(TYPE *self); %enddef /* ----------------------------------------------------------------------------- * %pointer_cast(type1,type2,name) * * Generates a pointer casting function. * ----------------------------------------------------------------------------- */ %define %pointer_cast(TYPE1,TYPE2,NAME) %inline %{ TYPE2 NAME(TYPE1 x) { return (TYPE2) x; } %} %enddef swig-3.0.2/Lib/d/doperators.swg0000664000175000017500000001767012343605122016213 0ustar williamwilliam/* ----------------------------------------------------------------------------- * doperators.swg * * Mapping of C++ operator overloading methods to D. * ----------------------------------------------------------------------------- */ #if (SWIG_D_VERSION == 1) %pragma(d) imdmodulecode=%{ template SwigOperatorDefinitions() { public override int opEquals(Object o) { if (auto rhs = cast(typeof(this))o) { if (swigCPtr == rhs.swigCPtr) return 1; static if (is(typeof(swigOpEquals(rhs)))) { return swigOpEquals(rhs) ? 1 : 0; } else { return 0; } } return super.opEquals(o); } %} // opEquals is emitted in pure C mode as well to define two proxy classes // pointing to the same struct as equal. #ifdef __cplusplus %rename(opPos) *::operator+(); %rename(opPos) *::operator+() const; %rename(opNeg) *::operator-(); %rename(opNeg) *::operator-() const; %rename(opCom) *::operator~(); %rename(opCom) *::operator~() const; %rename(opAdd) *::operator+; %rename(opAddAssign) *::operator+=; %rename(opSub) *::operator-; %rename(opSubAssign) *::operator-=; %rename(opMul) *::operator*; %rename(opMulAssign) *::operator*=; %rename(opDiv) *::operator/; %rename(opDivAssign) *::operator/=; %rename(opMod) *::operator%; %rename(opModAssign) *::operator%=; %rename(opAnd) *::operator&; %rename(opAndAssign) *::operator&=; %rename(opOr) *::operator|; %rename(opOrAssign) *::operator|=; %rename(opXor) *::operator^; %rename(opXorAssign) *::operator^=; %rename(opShl) *::operator<<; %rename(opShlAssign) *::operator<<=; %rename(opShr) *::operator>>; %rename(opShrAssign) *::operator>>=; %rename(opIndex) *::operator[](unsigned) const; // opIndexAssign is not currently generated, it needs more extensive support // mechanisms. %rename(opCall) *::operator(); // !a is not overrideable in D1. %ignoreoperator(LNOT) operator!; // opCmp is used in D. %rename(swigOpEquals) *::operator==; %rename(swigOpLt) *::operator<; %rename(swigOpLtEquals) *::operator<=; %rename(swigOpGt) *::operator>; %rename(swigOpGtEquals) *::operator>=; // a != b is rewritten as !a.opEquals(b) in D. %ignoreoperator(NOTEQUAL) operator!=; // The logic operators are not overrideable in D. %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; // ++/--a is rewritten as a +/-= 1 in D1,so ignore the prefix operators. %ignoreoperator(PLUSPLUS) *::operator++(); %ignoreoperator(MINUSMINUS) *::operator--(); %rename(swigOpInc) *::operator++(int); %rename(swigOpDec) *::operator--(int); // The C++ assignment operator does not translate well to D where the proxy // classes have reference semantics. %ignoreoperator(EQ) operator=; %pragma(d) imdmodulecode=%{ public override int opCmp(Object o) { static if (is(typeof(swigOpLt(typeof(this).init) && swigOpEquals(typeof(this).init)))) { if (auto rhs = cast(typeof(this))o) { if (swigOpLt(rhs)) { return -1; } else if (swigOpEquals(rhs)) { return 0; } else { return 1; } } } return super.opCmp(o); } public typeof(this) opPostInc(T = int)(T unused = 0) { static assert( is(typeof(swigOpInc(int.init))), "opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~ "increment operator exists in the corresponding C++ class." ); return swigOpInc(int.init); } public typeof(this) opPostDec(T = int)(T unused = 0) { static assert( is(typeof(swigOpDec(int.init))), "opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~ "decrement operator exists in the corresponding C++ class." ); return swigOpDec(int.init); } %} #endif %pragma(d) imdmodulecode=%{ } %} #else %pragma(d) imdmodulecode=%{ mixin template SwigOperatorDefinitions() { public override bool opEquals(Object o) { if (auto rhs = cast(typeof(this))o) { if (swigCPtr == rhs.swigCPtr) return true; static if (is(typeof(swigOpEquals(rhs)))) { return swigOpEquals(rhs); } else { return false; } } return super.opEquals(o); } %} // opEquals is emitted in pure C mode as well to define two proxy classes // pointing to the same struct as equal. #ifdef __cplusplus %rename(swigOpPos) *::operator+(); %rename(swigOpPos) *::operator+() const; %rename(swigOpNeg) *::operator-(); %rename(swigOpNeg) *::operator-() const; %rename(swigOpCom) *::operator~(); %rename(swigOpCom) *::operator~() const; %rename(swigOpInc) *::operator++(); %rename(swigOpDec) *::operator--(); %ignoreoperator(PLUSPLUS) *::operator++(int); %ignoreoperator(MINUSMINUS) *::operator--(int); // The postfix increment/decrement operators are ignored because they are // rewritten to (auto t = e, ++e, t) in D2. The unary * operator (used for // pointer dereferencing in C/C++) isn't mapped to opUnary("*") by default, // despite this would be possible in D2 – the difference in member access // semantics would only lead to confusion in most cases. %rename(swigOpAdd) *::operator+; %rename(swigOpSub) *::operator-; %rename(swigOpMul) *::operator*; %rename(swigOpDiv) *::operator/; %rename(swigOpMod) *::operator%; %rename(swigOpAnd) *::operator&; %rename(swigOpOr) *::operator|; %rename(swigOpXor) *::operator^; %rename(swigOpShl) *::operator<<; %rename(swigOpShr) *::operator>>; %rename(swigOpAddAssign) *::operator+=; %rename(swigOpSubAssign) *::operator-=; %rename(swigOpMulAssign) *::operator*=; %rename(swigOpDivAssign) *::operator/=; %rename(swigOpModAssign) *::operator%=; %rename(swigOpAndAssign) *::operator&=; %rename(swigOpOrAssign) *::operator|=; %rename(swigOpXorAssign) *::operator^=; %rename(swigOpShlAssign) *::operator<<=; %rename(swigOpShrAssign) *::operator>>=; %rename(opIndex) *::operator[]; // opIndexAssign is not currently generated, it needs more extensive support // mechanisms. %rename(opCall) *::operator(); %rename(swigOpEquals) *::operator==; %rename(swigOpLt) *::operator<; %rename(swigOpLtEquals) *::operator<=; %rename(swigOpGt) *::operator>; %rename(swigOpGtEquals) *::operator>=; // a != b is rewritten as !a.opEquals(b) in D. %ignoreoperator(NOTEQUAL) operator!=; // The logic operators are not overrideable in D. %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; // The C++ assignment operator does not translate well to D where the proxy // classes have reference semantics. %ignoreoperator(EQ) operator=; %pragma(d) imdmodulecode=%{ public override int opCmp(Object o) { static if (__traits(compiles, swigOpLt(typeof(this).init) && swigOpEquals(typeof(this).init))) { if (auto rhs = cast(typeof(this))o) { if (swigOpLt(rhs)) { return -1; } else if (swigOpEquals(rhs)) { return 0; } else { return 1; } } } return super.opCmp(o); } private template swigOpBinary(string operator, string name) { enum swigOpBinary = `public void opOpAssign(string op, T)(T rhs) if (op == "` ~ operator ~ `" && __traits(compiles, swigOp` ~ name ~ `Assign(rhs))) { swigOp` ~ name ~ `Assign(rhs);}` ~ `public auto opBinary(string op, T)(T rhs) if (op == "` ~ operator ~ `" && __traits(compiles, swigOp` ~ name ~ `(rhs))) { return swigOp` ~ name ~ `(rhs);}`; } mixin(swigOpBinary!("+", "Add")); mixin(swigOpBinary!("-", "Sub")); mixin(swigOpBinary!("*", "Mul")); mixin(swigOpBinary!("/", "Div")); mixin(swigOpBinary!("%", "Mod")); mixin(swigOpBinary!("&", "And")); mixin(swigOpBinary!("|", "Or")); mixin(swigOpBinary!("^", "Xor")); mixin(swigOpBinary!("<<", "Shl")); mixin(swigOpBinary!(">>", "Shr")); private template swigOpUnary(string operator, string name) { enum swigOpUnary = `public auto opUnary(string op)() if (op == "` ~ operator ~ `" && __traits(compiles, swigOp` ~ name ~ `())) { return swigOp` ~ name ~ `();}`; } mixin(swigOpUnary!("+", "Pos")); mixin(swigOpUnary!("-", "Neg")); mixin(swigOpUnary!("~", "Com")); mixin(swigOpUnary!("++", "Inc")); mixin(swigOpUnary!("--", "Dec")); %} #endif %pragma(d) imdmodulecode=%{ } %} #endif swig-3.0.2/Lib/d/dclassgen.swg0000664000175000017500000000703712343605122015770 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dclassgen.swg * * Typemaps containing D code used when generating D proxy classes. * ----------------------------------------------------------------------------- */ %typemap(dbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(dclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "class" %typemap(dcode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(dimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(dinterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(dinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" // See . %typemap(dclassmodifiers) enum SWIGTYPE "enum" %typemap(dcode) enum SWIGTYPE "" /* * Proxy classes. */ %typemap(dconstructor, excode=SWIGEXCODE,directorconnect="\n swigDirectorConnect();") SWIGTYPE { this($imcall, true);$excode$directorconnect } %typemap(ddestructor) SWIGTYPE %{ ~this() { dispose(); } %} // We do not use »override« attribute for generated dispose() methods to stay // somewhat compatible to Phobos and older Tango versions where Object.dispose() // does not exist. %typemap(ddispose, methodname="dispose", methodmodifiers="public") SWIGTYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = null; } } } %typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") SWIGTYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = null; super.dispose(); } } } // Unfortunately, the »package« visibility attribute does not work in D when the // module in question is in the root package (happens if no -package is specified // at the SWIG command line), so we are stuck with public visibility for // swigGetCPtr(). %typemap(dbody) SWIGTYPE %{ private void* swigCPtr; protected bool swigCMemOwn; public this(void* cObject, bool ownCObject) { swigCPtr = cObject; swigCMemOwn = ownCObject; } public static void* swigGetCPtr($dclassname obj) { return (obj is null) ? null : obj.swigCPtr; } mixin $imdmodule.SwigOperatorDefinitions; %} %typemap(dbody_derived) SWIGTYPE %{ private void* swigCPtr; public this(void* cObject, bool ownCObject) { super($imdmodule.$dclazznameUpcast(cObject), ownCObject); swigCPtr = cObject; } public static void* swigGetCPtr($dclassname obj) { return (obj is null) ? null : obj.swigCPtr; } mixin $imdmodule.SwigOperatorDefinitions; %} /* * Type wrapper classes. */ %typemap(dbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ private void* swigCPtr; public this(void* cObject, bool futureUse) { swigCPtr = cObject; } protected this() { swigCPtr = null; } public static void* swigGetCPtr($dclassname obj) { return (obj is null) ? null : obj.swigCPtr; } mixin $imdmodule.SwigOperatorDefinitions; %} /* * Member function pointer wrapper classes (see ). */ %typemap(dbody) SWIGTYPE (CLASS::*) %{ private char* swigCPtr; public this(char* cMemberPtr, bool futureUse) { swigCPtr = cMemberPtr; } protected this() { swigCPtr = null; } package static char* swigGetCMemberPtr($dclassname obj) { return (obj is null) ? null : obj.swigCPtr; } mixin $imdmodule.SwigOperatorDefinitions; %} swig-3.0.2/Lib/d/denums.swg0000664000175000017500000000357512343605122015323 0ustar williamwilliam/* ----------------------------------------------------------------------------- * denums.swg * * Typemaps for enumerations. * ----------------------------------------------------------------------------- */ /* * Typemaps for enumeration types. */ %typemap(ctype) enum SWIGTYPE "int" %typemap(imtype) enum SWIGTYPE "int" %typemap(dtype, cprimitive="1") enum SWIGTYPE "$dclassname" %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = $1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(ddirectorin) enum SWIGTYPE "cast($dclassname)$winput" %typemap(ddirectorout) enum SWIGTYPE "cast(int)$dcall" %typemap(din) enum SWIGTYPE "cast(int)$dinput" %typemap(dout, excode=SWIGEXCODE) enum SWIGTYPE { $dclassname ret = cast($dclassname)$imcall;$excode return ret; } /* * Typemaps for (const) references to enumeration types. */ %typemap(ctype) const enum SWIGTYPE & "int" %typemap(imtype) const enum SWIGTYPE & "int" %typemap(dtype) const enum SWIGTYPE & "$*dclassname" %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = *$1; %} %typemap(directorin) const enum SWIGTYPE & "$input = $1;" %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(ddirectorin) const enum SWIGTYPE & "cast($*dclassname)$winput" %typemap(ddirectorout) const enum SWIGTYPE & "cast(int)$dcall" %typemap(din) const enum SWIGTYPE & "cast(int)$dinput" %typemap(dout, excode=SWIGEXCODE) const enum SWIGTYPE & { $*dclassname ret = cast($*dclassname)$imcall;$excode return ret; } swig-3.0.2/Lib/modula3/0000775000175000017500000000000012343605122014415 5ustar williamwilliamswig-3.0.2/Lib/modula3/modula3.swg0000664000175000017500000010564512343605122016516 0ustar williamwilliam/* ----------------------------------------------------------------------------- * modula3.swg * * Modula3 typemaps * ----------------------------------------------------------------------------- */ %include /* The ctype, m3rawtype and m3wraptype typemaps work together and so there should be one of each. * The ctype typemap contains the C type used in the signature of C wrappers for C++ functions. * The m3rawtype typemap contains the M3 type used in the raw interface. * The m3rawintype typemap contains the M3 type used as function argument. * The m3rawrettype typemap contains the M3 type used as return value. * The m3wraptype typemap contains the M3 type used in the M3 type wrapper classes and module class. */ /* Primitive types */ %typemap(ctype) bool, const bool & "bool" %typemap(ctype) char, const char & "char" %typemap(ctype) signed char, const signed char & "signed char" %typemap(ctype) unsigned char, const unsigned char & "unsigned short" %typemap(ctype) short, const short & "short" %typemap(ctype) unsigned short, const unsigned short & "unsigned short" %typemap(ctype) int, const int & "int" %typemap(ctype) unsigned int, const unsigned int & "unsigned int" %typemap(ctype) long, const long & "long" %typemap(ctype) unsigned long, const unsigned long & "unsigned long" %typemap(ctype) long long, const long long & "long long" %typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long" %typemap(ctype) float, const float & "float" %typemap(ctype) double, const double & "double" %typemap(ctype) char * "char *" %typemap(ctype) void "void" %typemap(m3rawtype) bool, const bool & "BOOLEAN" %typemap(m3rawtype) char, const char & "C.char" %typemap(m3rawtype) signed char, const signed char & "C.signed_char" %typemap(m3rawtype) unsigned char, const unsigned char & "C.unsigned_char" %typemap(m3rawtype) short, const short & "C.short" %typemap(m3rawtype) unsigned short, const unsigned short & "C.unsigned_short" %typemap(m3rawtype) int, const int & "C.int" %typemap(m3rawtype) unsigned int, const unsigned int & "C.unsigned_int" %typemap(m3rawtype) long, const long & "C.long" %typemap(m3rawtype) unsigned long, const unsigned long & "C.unsigned_long" %typemap(m3rawtype) long long, const long long & "C.long_long" %typemap(m3rawtype) unsigned long long, const unsigned long long & "C.unsigned_long_long" %typemap(m3rawtype) float, const float & "C.float" %typemap(m3rawtype) double, const double & "C.double" %typemap(m3rawtype) long double, const long double & "C.long_double" %typemap(m3rawtype) char * "C.char_star" %typemap(m3rawtype) void "" %typemap(m3rawtype) FILE "Cstdio.FILE"; %typemap(m3rawtype) FILE * "Cstdio.FILE_star"; %typemap(m3rawintype) bool *, bool &, bool "BOOLEAN" %typemap(m3rawintype) char *, char &, char "C.char" %typemap(m3rawintype) signed char *, signed char &, signed char "C.signed_char" %typemap(m3rawintype) unsigned char *, unsigned char &, unsigned char "C.unsigned_char" %typemap(m3rawintype) short *, short &, short "C.short" %typemap(m3rawintype) unsigned short *, unsigned short &, unsigned short "C.unsigned_short" %typemap(m3rawintype) int *, int &, int "C.int" %typemap(m3rawintype) unsigned int *, unsigned int &, unsigned int "C.unsigned_int" %typemap(m3rawintype) long *, long &, long "C.long" %typemap(m3rawintype) unsigned long *, unsigned long &, unsigned long "C.unsigned_long" %typemap(m3rawintype) long long *, long long &, long long "C.long_long" %typemap(m3rawintype) unsigned long long *, unsigned long long &, unsigned long long "C.unsigned_long_long" %typemap(m3rawintype) float *, float &, float "C.float" %typemap(m3rawintype) double *, double &, double "C.double" %typemap(m3rawintype) long double *, long double &, long double "C.long_double" %typemap(m3rawintype) char * "C.char_star" %typemap(m3rawintype) void "" %typemap(m3rawintype) void * "ADDRESS" %typemap(m3rawintype) FILE "Cstdio.FILE"; %typemap(m3rawintype) FILE * "Cstdio.FILE_star"; %typemap(m3rawinmode) char *, void *, FILE * "" %typemap(m3rawrettype) bool, const bool & "BOOLEAN" %typemap(m3rawrettype) char, const char & "C.char" %typemap(m3rawrettype) signed char, const signed char & "C.signed_char" %typemap(m3rawrettype) unsigned char, const unsigned char & "C.unsigned_char" %typemap(m3rawrettype) short, const short & "C.short" %typemap(m3rawrettype) unsigned short, const unsigned short & "C.unsigned_short" %typemap(m3rawrettype) int, const int & "C.int" %typemap(m3rawrettype) unsigned int, const unsigned int & "C.unsigned_int" %typemap(m3rawrettype) long, const long & "C.long" %typemap(m3rawrettype) unsigned long, const unsigned long & "C.unsigned_long" %typemap(m3rawrettype) long long, const long long & "C.long_long" %typemap(m3rawrettype) unsigned long long, const unsigned long long & "C.unsigned_long_long" %typemap(m3rawrettype) float, const float & "C.float" %typemap(m3rawrettype) double, const double & "C.double" %typemap(m3rawrettype) long double, const long double & "C.long_double" %typemap(m3rawrettype) char * "C.char_star" %typemap(m3rawrettype) void "" %typemap(m3rawrettype) void * "ADDRESS" %typemap(m3rawrettype) FILE "Cstdio.FILE"; %typemap(m3rawrettype) FILE * "Cstdio.FILE_star"; %typemap("m3rawtype:import") char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, long double, const long double &, char * "Ctypes AS C" %typemap("m3rawintype:import") char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, long double, const long double &, char * "Ctypes AS C" %typemap("m3rawrettype:import") char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, long double, const long double &, char * "Ctypes AS C" %typemap("m3rawtype:import") FILE, FILE * "Cstdio"; %typemap("m3rawintype:import") FILE, FILE * "Cstdio"; %typemap("m3rawrettype:import") FILE, FILE * "Cstdio"; %typemap(m3wraptype) bool, const bool & "BOOLEAN" %typemap(m3wraptype) char, const char & "CHAR" %typemap(m3wraptype) signed char, const signed char & "CHAR" %typemap(m3wraptype) unsigned char, const unsigned char & "CHAR" %typemap(m3wraptype) short, const short & "Integer16.T" %typemap(m3wraptype) unsigned short, const unsigned short & "Cardinal16.T" %typemap(m3wraptype) int, const int & "INTEGER" %typemap(m3wraptype) unsigned int, const unsigned int & "CARDINAL" %typemap(m3wraptype) long, const long & "Integer32.T" %typemap(m3wraptype) unsigned long, const unsigned long & "Cardinal32.T" %typemap(m3wraptype) long long, const long long & "Integer64.T" %typemap(m3wraptype) unsigned long long, const unsigned long long & "Cardinal64.T" %typemap(m3wraptype) float, const float & "REAL" %typemap(m3wraptype) double, const double & "LONGREAL" %typemap(m3wraptype) long double, const long double & "EXTENDED" %typemap(m3wraptype) char * "TEXT" %typemap(m3wraptype) void "" %typemap(m3wraptype) FILE "Cstdio.FILE"; %typemap(m3wraptype) FILE * "Cstdio.FILE_star"; %typemap(m3wrapintype) bool, const bool *, const bool & "BOOLEAN" %typemap(m3wrapintype) char, const char *, const char & "CHAR" %typemap(m3wrapintype) signed char, const signed char *, const signed char & "CHAR" %typemap(m3wrapintype) unsigned char, const unsigned char *, const unsigned char & "CHAR" %typemap(m3wrapintype) short, const short *, const short & "INTEGER" %typemap(m3wrapintype) unsigned short, const unsigned short *, const unsigned short & "CARDINAL" %typemap(m3wrapintype) int, const int *, const int & "INTEGER" %typemap(m3wrapintype) unsigned int, const unsigned int *, const unsigned int & "CARDINAL" %typemap(m3wrapintype) long, const long *, const long & "INTEGER" %typemap(m3wrapintype) unsigned long, const unsigned long *, const unsigned long & "CARDINAL" %typemap(m3wrapintype) long long, const long long *, const long long & "INTEGER" %typemap(m3wrapintype) unsigned long long, const unsigned long long *, const unsigned long long & "CARDINAL" %typemap(m3wrapintype) float, const float *, const float & "REAL" %typemap(m3wrapintype) double, const double *, const double & "LONGREAL" %typemap(m3wrapintype) long double, const long double *, const long double & "EXTENDED" %typemap(m3wrapintype) const char *, const char [] "TEXT" %typemap(m3wrapintype,numinputs=0) void "" %typemap(m3wrapintype) FILE "Cstdio.FILE"; %typemap(m3wrapintype) FILE * "Cstdio.FILE_star"; %typemap(m3wrapouttype) bool, bool *, bool & "BOOLEAN" %typemap(m3wrapouttype) char, char *, char & "CHAR" %typemap(m3wrapouttype) signed char, signed char *, signed char & "CHAR" %typemap(m3wrapouttype) unsigned char, unsigned char *, unsigned char & "CHAR" %typemap(m3wrapouttype) short, short *, short & "INTEGER" %typemap(m3wrapouttype) unsigned short, unsigned short *, unsigned short & "CARDINAL" %typemap(m3wrapouttype) int, int *, int & "INTEGER" %typemap(m3wrapouttype) unsigned int, unsigned int *, unsigned int & "CARDINAL" %typemap(m3wrapouttype) long, long *, long & "INTEGER" %typemap(m3wrapouttype) unsigned long, unsigned long *, unsigned long & "CARDINAL" %typemap(m3wrapouttype) long long, long long *, long long & "INTEGER" %typemap(m3wrapouttype) unsigned long long, unsigned long long *, unsigned long long & "CARDINAL" %typemap(m3wrapouttype) float, float *, float & "REAL" %typemap(m3wrapouttype) double, double *, double & "LONGREAL" %typemap(m3wrapouttype) long double, long double *, long double & "EXTENDED" %typemap(m3wrapouttype) char *, char [] "TEXT" %typemap(m3wrapouttype,numinputs=0) void "" %typemap(m3wraprettype) bool, const bool & "BOOLEAN" %typemap(m3wraprettype) char, const char & "CHAR" %typemap(m3wraprettype) signed char, const signed char & "CHAR" %typemap(m3wraprettype) unsigned char, const unsigned char & "CHAR" %typemap(m3wraprettype) short, const short & "INTEGER" %typemap(m3wraprettype) unsigned short, const unsigned short & "CARDINAL" %typemap(m3wraprettype) int, const int & "INTEGER" %typemap(m3wraprettype) unsigned int, const unsigned int & "CARDINAL" %typemap(m3wraprettype) long, const long & "INTEGER" %typemap(m3wraprettype) unsigned long, const unsigned long & "CARDINAL" %typemap(m3wraprettype) long long, const long long & "INTEGER" %typemap(m3wraprettype) unsigned long long, const unsigned long long & "CARDINAL" %typemap(m3wraprettype) float, const float & "REAL" %typemap(m3wraprettype) double, const double & "LONGREAL" %typemap(m3wraprettype) long double, const long double & "EXTENDED" %typemap(m3wraprettype) char * "TEXT" %typemap(m3wraprettype) void "" %typemap(m3wraprettype) FILE "Cstdio.FILE"; %typemap(m3wraprettype) FILE * "Cstdio.FILE_star"; %typemap(ctype) char[ANY] "char *" %typemap(m3rawtype) char[ANY] "C.char_star" %typemap(m3rawintype) char[ANY] "C.char_star" %typemap(m3rawrettype) char[ANY] "C.char_star" %typemap(m3wraptype) char[ANY] "TEXT" %typemap(m3wrapintype) char[ANY] "TEXT" %typemap(m3wrapouttype) char[ANY] "TEXT" %typemap(m3wraprettype) char[ANY] "TEXT" %typemap(m3wrapinmode) const char * %{%} %typemap(m3wrapargvar) const char * %{$1 : C.char_star;%} %typemap(m3wrapinconv) const char * %{$1 := M3toC.SharedTtoS($1_name);%} %typemap(m3wrapfreearg) const char * %{M3toC.FreeSharedS($1_name,$1);%} %typemap(m3wrapargraw) const char * %{$1%} %typemap("m3wrapargvar:import") const char * "Ctypes AS C" %typemap("m3wrapinconv:import") const char * "M3toC" %typemap("m3wrapfreearg:import") const char * "M3toC" %typemap(m3wrapretvar) char * %{result : C.char_star;%} %typemap(m3wrapretraw) char * %{result%} %typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result)%} %typemap("m3wrapretvar:import") char * "Ctypes AS C" %typemap("m3wrapretconv:import") char * "M3toC" %typemap(m3wrapinmode) FILE * %{%} %typemap("m3wraptype:import") FILE, FILE * "Cstdio"; %typemap("m3wrapintype:import") FILE, FILE * "Cstdio"; %typemap("m3wraprettype:import") FILE, FILE * "Cstdio"; /* Composed types */ %typemap(ctype) SWIGTYPE "$1_type" %typemap(m3rawtype) SWIGTYPE "$1_basetype" %typemap(m3rawrettype) SWIGTYPE "UNTRACED REF $1_basetype" %typemap(m3wraptype) SWIGTYPE "$1_basetype" %typemap(m3wrapintype) SWIGTYPE "$1_basetype" %typemap(m3wrapouttype) SWIGTYPE "$1_basetype" %typemap(m3wraprettype) SWIGTYPE "$1_basetype" %typemap(ctype) SWIGTYPE [] "$1_type" %typemap(m3rawtype) const SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" %typemap(m3rawtype) SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" %typemap(m3rawintype) const SWIGTYPE [] "(*ARRAY OF*) $1_basetype" %typemap(m3rawinmode) const SWIGTYPE [] "READONLY" %typemap(m3rawintype) SWIGTYPE [] "(*ARRAY OF*) $1_basetype" %typemap(m3rawinmode) SWIGTYPE [] "VAR" %typemap(m3rawrettype) const SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" %typemap(m3rawrettype) SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" %typemap(m3wraptype) SWIGTYPE [] "$1_basetype" %typemap(m3wrapintype) const SWIGTYPE [] "ARRAY OF $1_basetype" %typemap(m3wrapinmode) const SWIGTYPE [] "READONLY" %typemap(m3wrapintype) SWIGTYPE [] "ARRAY OF $1_basetype" %typemap(m3wrapinmode) SWIGTYPE [] "VAR" %typemap(m3wrapouttype) SWIGTYPE [] "ARRAY OF $1_basetype" %typemap(m3wraprettype) SWIGTYPE [] "REF ARRAY OF $1_basetype" %typemap(ctype) SWIGTYPE * "$1_type" %typemap(m3rawtype) const SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(m3rawtype) SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(m3rawintype) const SWIGTYPE * "$1_basetype" %typemap(m3rawinmode) const SWIGTYPE * "READONLY" %typemap(m3rawintype) SWIGTYPE * "$1_basetype" %typemap(m3rawinmode) SWIGTYPE * "VAR" %typemap(m3rawrettype) const SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(m3rawrettype) SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(m3wraptype) SWIGTYPE * "$1_basetype" %typemap(m3wrapintype) const SWIGTYPE * "$1_basetype" %typemap(m3wrapinmode) const SWIGTYPE * "READONLY" %typemap(m3wrapintype) SWIGTYPE * "$1_basetype" %typemap(m3wrapinmode) SWIGTYPE * "VAR" %typemap(m3wrapouttype) SWIGTYPE * "$1_basetype" %typemap(m3wraprettype) SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(ctype) SWIGTYPE & "$1_type" %typemap(m3rawtype) const SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(m3rawtype) SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(m3rawintype) const SWIGTYPE & "$1_basetype" %typemap(m3rawinmode) const SWIGTYPE & "READONLY" %typemap(m3rawintype) SWIGTYPE & "$1_basetype" %typemap(m3rawinmode) SWIGTYPE & "VAR" %typemap(m3rawrettype) const SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(m3rawrettype) SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(m3wraptype) SWIGTYPE & "$1_basetype" %typemap(m3wrapintype) const SWIGTYPE & "$1_basetype" %typemap(m3wrapinmode) const SWIGTYPE & "READONLY" %typemap(m3wrapintype) SWIGTYPE & "$1_basetype" %typemap(m3wrapinmode) SWIGTYPE & "VAR" %typemap(m3wrapouttype) SWIGTYPE & "$1_basetype" %typemap(m3wraprettype) SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(ctype) SWIGTYPE && "$1_type" %typemap(m3rawtype) const SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(m3rawtype) SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(m3rawintype) const SWIGTYPE && "$1_basetype" %typemap(m3rawinmode) const SWIGTYPE && "READONLY" %typemap(m3rawintype) SWIGTYPE && "$1_basetype" %typemap(m3rawinmode) SWIGTYPE && "VAR" %typemap(m3rawrettype) const SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(m3rawrettype) SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(m3wraptype) SWIGTYPE && "$1_basetype" %typemap(m3wrapintype) const SWIGTYPE && "$1_basetype" %typemap(m3wrapinmode) const SWIGTYPE && "READONLY" %typemap(m3wrapintype) SWIGTYPE && "$1_basetype" %typemap(m3wrapinmode) SWIGTYPE && "VAR" %typemap(m3wrapouttype) SWIGTYPE && "$1_basetype" %typemap(m3wraprettype) SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(ctype) enum SWIGTYPE "$1_type" %typemap(m3rawtype) enum SWIGTYPE "C.int" %typemap(m3rawintype) enum SWIGTYPE "C.int (* $1_type *)" %typemap(m3rawrettype) enum SWIGTYPE "C.int" %typemap(m3wraptype) enum SWIGTYPE "$*1_type" %typemap(m3wrapintype) enum SWIGTYPE "$1_type" %typemap(m3wrapouttype) enum SWIGTYPE "$1_type" %typemap(m3wraprettype) enum SWIGTYPE "$*1_type" /* pointer to a class member */ %typemap(ctype) SWIGTYPE (CLASS::*) "$1_type" %typemap(m3rawtype) SWIGTYPE (CLASS::*) "REFANY" %typemap(m3wraptype) SWIGTYPE (CLASS::*) "$1_basetype" /* The following are the in, out, freearg, argout typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */ /* primitive types */ %typemap(in) bool %{ $1 = $input ? true : false; %} %typemap(in) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) bool %{ $result = $1; %} %typemap(out) char %{ $result = $1; %} %typemap(out) signed char %{ $result = $1; %} %typemap(out) unsigned char %{ $result = $1; %} %typemap(out) short %{ $result = $1; %} %typemap(out) unsigned short %{ $result = $1; %} %typemap(out) int %{ $result = $1; %} %typemap(out) unsigned int %{ $result = $1; %} %typemap(out) long %{ $result = $1; %} %typemap(out) unsigned long %{ $result = $1; %} %typemap(out) long long %{ $result = $1; %} %typemap(out) unsigned long long %{ $result = $1; %} %typemap(out) float %{ $result = $1; %} %typemap(out) double %{ $result = $1; %} %typemap(out) enum SWIGTYPE %{ $result = $1; %} /* char * - treat as String */ %typemap(in) char * { $1 = $input; } //%typemap(freearg) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } //%typemap(out) char * { if($1) $result = JCALL1(NewStringUTF, jenv, $1); } %typemap(out) void "" /* primitive types by const reference */ %typemap(in) const bool & (bool temp) %{ temp = $input ? true : false; $1 = &temp; %} %typemap(in) const char & (char temp), const signed char & (signed char temp), const unsigned char & (unsigned char temp), const short & (short temp), const unsigned short & (unsigned short temp), const int & (int temp), const unsigned int & (unsigned int temp), const long & (long temp), const unsigned long & (unsigned long temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const float & (float temp), const double & (double temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const bool & %{ $result = *$1; %} %typemap(out) const char & %{ $result = *$1; %} %typemap(out) const signed char & %{ $result = *$1; %} %typemap(out) const unsigned char & %{ $result = *$1; %} %typemap(out) const short & %{ $result = *$1; %} %typemap(out) const unsigned short & %{ $result = *$1; %} %typemap(out) const int & %{ $result = *$1; %} %typemap(out) const unsigned int & %{ $result = *$1; %} %typemap(out) const long & %{ $result = *$1; %} %typemap(out) const unsigned long & %{ $result = *$1; %} %typemap(out) const long long & %{ $result = *$1; %} %typemap(out) const unsigned long long & %{ $result = *$1; %} %typemap(out) const float & %{ $result = *$1; %} %typemap(out) const double & %{ $result = *$1; %} /* Default handling. Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_type argp) %{ argp = *($&1_ltype*)&$input; if (!argp) { // SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); RETURN $null; } $1 = *argp; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{*($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); *($&1_ltype*)&$result = $1ptr; } #endif /* Generic pointers and references */ %typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %} %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; if(!$1) { //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); RETURN $null; } %} %typemap(in) SWIGTYPE && %{ $1 = *($&1_ltype)&$input; if(!$1) { //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); RETURN $null; } %} %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE (CLASS::*) %{ *($&1_ltype)&$result = $1; %} /* Default array handling */ %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %} /* char[ANY] - treat as String */ %typemap(in) char[ANY] { $1 = $input; } %typemap(argout) char[ANY] "" %typemap(freearg) char[ANY] ""//{ if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } %typemap(out) char[ANY] { if($1) $result = $1; } /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */ %typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */ bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) /* Java char */ char, const char & "" %typecheck(SWIG_TYPECHECK_INT8) /* Java byte */ signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_INT16) /* Java short */ unsigned char, short, const unsigned char &, const short & "" %typecheck(SWIG_TYPECHECK_INT32) /* Java int */ unsigned short, int, long, const unsigned short &, const int &, const long &, enum SWIGTYPE "" %typecheck(SWIG_TYPECHECK_INT64) /* Java long */ unsigned int, unsigned long, long long, const unsigned int &, const unsigned long &, const long long & "" %typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */ unsigned long long "" %typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */ float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */ double, const double & "" %typecheck(SWIG_TYPECHECK_STRING) /* Java String */ char *, char[ANY] "" %typecheck(SWIG_TYPECHECK_POINTER) /* Default */ SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* Exception handling */ %typemap(throws) int, long, short, unsigned int, unsigned long, unsigned short { char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg); RETURN $null; } %typemap(throws) SWIGTYPE { (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); RETURN $null; } %typemap(throws) char * { SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); RETURN $null; } /* Typemaps for code generation in proxy classes and C# type wrapper classes */ /* The in typemap is used for converting function parameter types from the type * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */ %typemap(m3in) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, char *, char[ANY], enum SWIGTYPE "$input" %typemap(m3in) SWIGTYPE "$&*1_type.getCPtr($input)" %typemap(m3in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "$1_basetype.getCPtr($input)" /* The m3out typemap is used for converting function return types from the return type * used in the PInvoke class to the type returned by the proxy, module or type wrapper class. */ %typemap(m3out) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, char *, char[ANY], enum SWIGTYPE %{$imcall%} %typemap(m3out) void %{$imcall%} %typemap(m3out) SWIGTYPE %{ RETURN NEW(REF $1_basetype, $imcall); %} %typemap(m3out) SWIGTYPE & %{ RETURN NEW($1_basetype, $imcall, $owner); %} %typemap(m3out) SWIGTYPE && %{ RETURN NEW($1_basetype, $imcall, $owner); %} %typemap(m3out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ cPtr := $imcall; RETURN (cPtr = IntPtr.Zero) ? null : NEW($1_basetype, cPtr, $owner); %} /* Properties */ %typemap(m3varin) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ PROCEDURE Set$var (value: $vartype) = BEGIN $imcall; END Set$var; %} %typemap(m3varout) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, char *, char[ANY], enum SWIGTYPE %{ PROCEDURE Get$var (): $vartype = BEGIN RETURN $imcall; END Get$var; %} %typemap(m3varout) void %{ get { $imcall; } %} %typemap(m3varout) SWIGTYPE %{ get { RETURN new $&*1_mangle($imcall, true); } %} %typemap(m3varout) SWIGTYPE & %{ get { RETURN new $1_basetype($imcall, $owner); } %} %typemap(m3varout) SWIGTYPE && %{ get { RETURN new $1_basetype($imcall, $owner); } %} %typemap(m3varout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ get { IntPtr cPtr = $imcall; RETURN (cPtr == IntPtr.Zero) ? null : new $1_basetype(cPtr, $owner); } %} /* Typemaps used for the generation of proxy and type wrapper class code */ %typemap(m3base) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(m3classmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public" %typemap(m3code) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(m3imports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "using System;" %typemap(m3interfaces) SWIGTYPE "IDisposable" %typemap(m3interfaces_derived) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(m3ptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "internal" %typemap(m3finalize) SWIGTYPE %{ ~$1_basetype() { Dispose(); } %} %typemap(m3destruct, methodname="Dispose") SWIGTYPE { if(swigCPtr != IntPtr.Zero && swigCMemOwn) { $imcall; swigCMemOwn = false; } swigCPtr = IntPtr.Zero; GC.SuppressFinalize(this); } %typemap(m3destruct_derived, methodname="Dispose") SWIGTYPE { if(swigCPtr != IntPtr.Zero && swigCMemOwn) { $imcall; swigCMemOwn = false; } swigCPtr = IntPtr.Zero; GC.SuppressFinalize(this); base.Dispose(); } %typemap(m3getcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ internal static IntPtr getCPtr($1_basetype obj) { RETURN (obj == null) ? IntPtr.Zero : obj.swigCPtr; } %} /* M3 specific directives */ #define %m3multiretval %feature("modula3:multiretval") #define %constnumeric(num) %feature("constnumeric","num") %pragma(modula3) moduleimports=%{ IMPORT BlaBla; %} %pragma(modula3) imclassimports=%{ FROM BlaBla IMPORT Bla; %} /* Some ANSI C typemaps */ %apply unsigned long { size_t }; /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } swig-3.0.2/Lib/modula3/typemaps.i0000664000175000017500000001032112343605122016426 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* These typemaps will eventually probably maybe make their way into named typemaps * OUTPUT * and OUTPUT & as they currently break functions that return a pointer or * reference. */ %typemap(ctype) bool *, bool & "bool *" %typemap(ctype) char & "char *" %typemap(ctype) signed char *, signed char & "signed char *" %typemap(ctype) unsigned char *, unsigned char & "unsigned short *" %typemap(ctype) short *, short & "short *" %typemap(ctype) unsigned short *, unsigned short & "unsigned short *" %typemap(ctype) int *, int & "int *" %typemap(ctype) unsigned int *, unsigned int & "unsigned int *" %typemap(ctype) long *, long & "long *" %typemap(ctype) unsigned long *, unsigned long & "unsigned long *" %typemap(ctype) long long *, long long & "long long *" %typemap(ctype) unsigned long long *, unsigned long long & "unsigned long long *" %typemap(ctype) float *, float & "float *" %typemap(ctype) double *, double & "double *" %typemap(imtype) bool *, bool & "ref bool" %typemap(imtype) char & "ref char" %typemap(imtype) signed char *, signed char & "ref sbyte" %typemap(imtype) unsigned char *, unsigned char & "ref byte" %typemap(imtype) short *, short & "ref short" %typemap(imtype) unsigned short *, unsigned short & "ref ushort" %typemap(imtype) int *, int & "ref int" %typemap(imtype) unsigned int *, unsigned int & "ref uint" %typemap(imtype) long *, long & "ref int" %typemap(imtype) unsigned long *, unsigned long & "ref uint" %typemap(imtype) long long *, long long & "ref long" %typemap(imtype) unsigned long long *, unsigned long long & "ref ulong" %typemap(imtype) float *, float & "ref float" %typemap(imtype) double *, double & "ref double" %typemap(cstype) bool *, bool & "ref bool" %typemap(cstype) char & "ref char" %typemap(cstype) signed char *, signed char & "ref sbyte" %typemap(cstype) unsigned char *, unsigned char & "ref byte" %typemap(cstype) short *, short & "ref short" %typemap(cstype) unsigned short *, unsigned short & "ref ushort" %typemap(cstype) int *, int & "ref int" %typemap(cstype) unsigned int *, unsigned int & "ref uint" %typemap(cstype) long *, long & "ref int" %typemap(cstype) unsigned long *, unsigned long & "ref uint" %typemap(cstype) long long *, long long & "ref long" %typemap(cstype) unsigned long long *, unsigned long long & "ref ulong" %typemap(cstype) float *, float & "ref float" %typemap(cstype) double *, double & "ref double" %typemap(csin) bool *, bool &, char &, signed char *, signed char &, unsigned char *, unsigned char &, short *, short &, unsigned short *, unsigned short &, int *, int &, unsigned int *, unsigned int &, long *, long &, unsigned long *, unsigned long &, long long *, long long &, unsigned long long *, unsigned long long &, float *, float &, double *, double & "ref $csinput" swig-3.0.2/Lib/modula3/modula3head.swg0000664000175000017500000000374612343605122017337 0ustar williamwilliam/* ----------------------------------------------------------------------------- * modula3head.swg * * Modula3 support code * ----------------------------------------------------------------------------- */ %insert(runtime) %{ #include #include #include %} #if 0 %insert(runtime) %{ /* Support for throwing Modula3 exceptions */ typedef enum { SWIG_JavaOutOfMemoryError = 1, SWIG_JavaIOException, SWIG_JavaRuntimeException, SWIG_JavaIndexOutOfBoundsException, SWIG_JavaArithmeticException, SWIG_JavaIllegalArgumentException, SWIG_JavaNullPointerException, SWIG_JavaUnknownError } SWIG_JavaExceptionCodes; typedef struct { SWIG_JavaExceptionCodes code; const char *java_exception; } SWIG_JavaExceptions_t; #if defined(SWIG_NOINCLUDE) void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg); #else %} %insert(runtime) { void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { jclass excep; static const SWIG_JavaExceptions_t java_exceptions[] = { { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, { SWIG_JavaIOException, "java/io/IOException" }, { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, { SWIG_JavaUnknownError, "java/lang/UnknownError" }, { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; const SWIG_JavaExceptions_t *except_ptr = java_exceptions; while (except_ptr->code != code && except_ptr->code) except_ptr++; JCALL0(ExceptionClear, jenv); excep = JCALL1(FindClass, jenv, except_ptr->java_exception); if (excep) JCALL2(ThrowNew, jenv, excep, msg); } } %insert(runtime) %{ #endif %} #endif swig-3.0.2/Lib/pointer.i0000664000175000017500000000044612343605122014707 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pointer.i * ----------------------------------------------------------------------------- */ %echo "pointer.i is deprecated. Use cpointer.i instead." %echo "See http://www.swig.org/Doc1.3/Library.html" swig-3.0.2/Lib/python/0000775000175000017500000000000012343605122014372 5ustar williamwilliamswig-3.0.2/Lib/python/std_vectora.i0000664000175000017500000000147512343605122017070 0ustar williamwilliam/* Vectors + allocators */ %fragment("StdVectorATraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { typedef std::vector vector_type; typedef T value_type; static int asptr(PyObject *obj, vector_type **vec) { return traits_asptr_stdseq::asptr(obj, vec); } }; template struct traits_from > { typedef std::vector vector_type; static PyObject *from(const vector_type& vec) { return traits_from_stdseq::from(vec); } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.2/Lib/python/std_unordered_set.i0000664000175000017500000000273612343605122020270 0ustar williamwilliam/* Unordered Sets */ %fragment("StdUnorderedSetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::unordered_set* seq) { // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(PyObject *obj, std::unordered_set **s) { return traits_asptr_stdseq >::asptr(obj, s); } }; template struct traits_from > { static PyObject *from(const std::unordered_set& vec) { return traits_from_stdseq >::from(vec); } }; } %} %define %swig_unordered_set_methods(unordered_set...) %swig_sequence_iterator(unordered_set); %swig_container_methods(unordered_set); %extend { void append(value_type x) { self->insert(x); } bool __contains__(value_type x) { return self->find(x) != self->end(); } value_type __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } }; %enddef %include swig-3.0.2/Lib/python/director.swg0000664000175000017500000002525012343605122016733 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Python proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #ifndef SWIG_DIRECTOR_PYTHON_HEADER_ #define SWIG_DIRECTOR_PYTHON_HEADER_ #include #include #include #include #include /* Use -DSWIG_PYTHON_DIRECTOR_NO_VTABLE if you don't want to generate a 'virtual table', and avoid multiple GetAttr calls to retrieve the python methods. */ #ifndef SWIG_PYTHON_DIRECTOR_NO_VTABLE #ifndef SWIG_PYTHON_DIRECTOR_VTABLE #define SWIG_PYTHON_DIRECTOR_VTABLE #endif #endif /* Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the Undefined Exception Handler provided by swig. */ #ifndef SWIG_DIRECTOR_NO_UEH #ifndef SWIG_DIRECTOR_UEH #define SWIG_DIRECTOR_UEH #endif #endif /* Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the 'Swig' namespace. This could be useful for multi-modules projects. */ #ifdef SWIG_DIRECTOR_STATIC /* Force anonymous (static) namespace */ #define Swig #endif /* Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the native C++ RTTI and dynamic_cast<>. But be aware that directors could stop working when using this option. */ #ifdef SWIG_DIRECTOR_NORTTI /* When we don't use the native C++ RTTI, we implement a minimal one only for Directors. */ # ifndef SWIG_DIRECTOR_RTDIR # define SWIG_DIRECTOR_RTDIR namespace Swig { class Director; SWIGINTERN std::map& get_rtdir_map() { static std::map rtdir_map; return rtdir_map; } SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) { get_rtdir_map()[vptr] = rtdir; } SWIGINTERNINLINE Director *get_rtdir(void *vptr) { std::map::const_iterator pos = get_rtdir_map().find(vptr); Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0; return rtdir; } } # endif /* SWIG_DIRECTOR_RTDIR */ # define SWIG_DIRECTOR_CAST(ARG) Swig::get_rtdir(static_cast(ARG)) # define SWIG_DIRECTOR_RGTR(ARG1, ARG2) Swig::set_rtdir(static_cast(ARG1), ARG2) #else # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) # define SWIG_DIRECTOR_RGTR(ARG1, ARG2) #endif /* SWIG_DIRECTOR_NORTTI */ extern "C" { struct swig_type_info; } namespace Swig { /* memory handler */ struct GCItem { virtual ~GCItem() {} virtual int get_own() const { return 0; } }; struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) { } GCItem_var& operator=(GCItem *item) { GCItem *tmp = _item; _item = item; delete tmp; return *this; } ~GCItem_var() { delete _item; } GCItem * operator->() const { return _item; } private: GCItem *_item; }; struct GCItem_Object : GCItem { GCItem_Object(int own) : _own(own) { } virtual ~GCItem_Object() { } int get_own() const { return _own; } private: int _own; }; template struct GCItem_T : GCItem { GCItem_T(Type *ptr) : _ptr(ptr) { } virtual ~GCItem_T() { delete _ptr; } private: Type *_ptr; }; template struct GCArray_T : GCItem { GCArray_T(Type *ptr) : _ptr(ptr) { } virtual ~GCArray_T() { delete[] _ptr; } private: Type *_ptr; }; /* base class for director exceptions */ class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(PyObject *error, const char *hdr ="", const char *msg ="") : swig_msg(hdr) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (msg[0]) { swig_msg += " "; swig_msg += msg; } if (!PyErr_Occurred()) { PyErr_SetString(error, what()); } SWIG_PYTHON_THREAD_END_BLOCK; } virtual ~DirectorException() throw() { } /* Deprecated, use what() instead */ const char *getMessage() const { return what(); } const char *what() const throw() { return swig_msg.c_str(); } static void raise(PyObject *error, const char *msg) { throw DirectorException(error, msg); } static void raise(const char *msg) { raise(PyExc_RuntimeError, msg); } }; /* unknown exception handler */ class UnknownExceptionHandler { #ifdef SWIG_DIRECTOR_UEH static void handler() { try { throw; } catch (DirectorException& e) { std::cerr << "SWIG Director exception caught:" << std::endl << e.what() << std::endl; } catch (std::exception& e) { std::cerr << "std::exception caught: "<< e.what() << std::endl; } catch (...) { std::cerr << "Unknown exception caught." << std::endl; } std::cerr << std::endl << "Python interpreter traceback:" << std::endl; PyErr_Print(); std::cerr << std::endl; std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl << std::endl << "Exception is being re-thrown, program will likely abort/terminate." << std::endl; throw; } public: std::unexpected_handler old; UnknownExceptionHandler(std::unexpected_handler nh = handler) { old = std::set_unexpected(nh); } ~UnknownExceptionHandler() { std::set_unexpected(old); } #endif }; /* type mismatch in the return value from a python method call */ class DirectorTypeMismatchException : public DirectorException { public: DirectorTypeMismatchException(PyObject *error, const char *msg="") : DirectorException(error, "SWIG director type mismatch", msg) { } DirectorTypeMismatchException(const char *msg="") : DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg) { } static void raise(PyObject *error, const char *msg) { throw DirectorTypeMismatchException(error, msg); } static void raise(const char *msg) { throw DirectorTypeMismatchException(msg); } }; /* any python exception that occurs during a director method call */ class DirectorMethodException : public DirectorException { public: DirectorMethodException(const char *msg = "") : DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg) { } static void raise(const char *msg) { throw DirectorMethodException(msg); } }; /* attempt to call a pure virtual method via a director method */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg = "") : DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg) { } static void raise(const char *msg) { throw DirectorPureVirtualException(msg); } }; #if defined(SWIG_PYTHON_THREADS) /* __THREAD__ is the old macro to activate some thread support */ # if !defined(__THREAD__) # define __THREAD__ 1 # endif #endif #ifdef __THREAD__ # include "pythread.h" class Guard { PyThread_type_lock &mutex_; public: Guard(PyThread_type_lock & mutex) : mutex_(mutex) { PyThread_acquire_lock(mutex_, WAIT_LOCK); } ~Guard() { PyThread_release_lock(mutex_); } }; # define SWIG_GUARD(mutex) Guard _guard(mutex) #else # define SWIG_GUARD(mutex) #endif /* director base class */ class Director { private: /* pointer to the wrapped python object */ PyObject *swig_self; /* flag indicating whether the object is owned by python or c++ */ mutable bool swig_disown_flag; /* decrement the reference count of the wrapped python object */ void swig_decref() const { if (swig_disown_flag) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_DECREF(swig_self); SWIG_PYTHON_THREAD_END_BLOCK; } } public: /* wrap a python object, optionally taking ownership */ Director(PyObject *self) : swig_self(self), swig_disown_flag(false) { swig_incref(); } /* discard our reference at destruction */ virtual ~Director() { swig_decref(); } /* return a pointer to the wrapped python object */ PyObject *swig_get_self() const { return swig_self; } /* acquire ownership of the wrapped python object (the sense of "disown" is from python) */ void swig_disown() const { if (!swig_disown_flag) { swig_disown_flag=true; swig_incref(); } } /* increase the reference count of the wrapped python object */ void swig_incref() const { if (swig_disown_flag) { Py_INCREF(swig_self); } } /* methods to implement pseudo protected director members */ virtual bool swig_get_inner(const char * /* swig_protected_method_name */) const { return true; } virtual void swig_set_inner(const char * /* swig_protected_method_name */, bool /* swig_val */) const { } /* ownership management */ private: typedef std::map swig_ownership_map; mutable swig_ownership_map swig_owner; #ifdef __THREAD__ static PyThread_type_lock swig_mutex_own; #endif public: template void swig_acquire_ownership_array(Type *vptr) const { if (vptr) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCArray_T(vptr); } } template void swig_acquire_ownership(Type *vptr) const { if (vptr) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCItem_T(vptr); } } void swig_acquire_ownership_obj(void *vptr, int own) const { if (vptr && own) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCItem_Object(own); } } int swig_release_ownership(void *vptr) const { int own = 0; if (vptr) { SWIG_GUARD(swig_mutex_own); swig_ownership_map::iterator iter = swig_owner.find(vptr); if (iter != swig_owner.end()) { own = iter->second->get_own(); swig_owner.erase(iter); } } return own; } template static PyObject *swig_pyobj_disown(PyObject *pyobj, PyObject *SWIGUNUSEDPARM(args)) { SwigPyObject *sobj = (SwigPyObject *)pyobj; sobj->own = 0; Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast(sobj->ptr)); if (d) d->swig_disown(); return PyWeakref_NewProxy(pyobj, NULL); } }; #ifdef __THREAD__ PyThread_type_lock Director::swig_mutex_own = PyThread_allocate_lock(); #endif } #endif swig-3.0.2/Lib/python/std_multiset.i0000664000175000017500000000207512343605122017270 0ustar williamwilliam/* Multisets */ %include %fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::multiset* seq) { // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(PyObject *obj, std::multiset **m) { return traits_asptr_stdseq >::asptr(obj, m); } }; template struct traits_from > { static PyObject *from(const std::multiset& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_multiset_methods(Set...) %swig_set_methods(Set) %include swig-3.0.2/Lib/python/README0000664000175000017500000000765612343605122015270 0ustar williamwilliam/* ----------------------------------------------------------------------------- * * User interfaces: include these ones as needed * * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * Special types and user helpers * ----------------------------------------------------------------------------- */ argcargv.i Handler for (int argc, char **argv) attribute.i Convert a pair of set/get methods into a "native" python attribute ccomplex.i C99 complex type complex.i C99 or C++ complex type cstring.i Various forms of C character string handling cwstring.i Various forms of C wchar_t string handling embed.i embedding the Python interpreter in something else embed15.i embedding the Python interpreter in something else file.i FILE C type implicit.i Allow the use of implicit C++ constructors wchar.i wchar_t C type /* ----------------------------------------------------------------------------- * C++ STD + STL * ----------------------------------------------------------------------------- */ std_alloc.i allocator std_basic_string.i basic string std_char_traits.i char traits std_complex.i complex std_deque.i deque std_except.i exceptions std_ios.i ios std_iostream.i istream/ostream std_list.i list std_map.i map std_multimap.i multimap std_multiset.i multiset std_pair.i pair std_set.i set std_sstream.i string stream std_streambuf.i streambuf std_string.i string std_vector.i vector std_wios.i wios std_wiostream.i wistream/wostream std_wsstream.i wstring stream std_wstreambuf.i wstreambuf std_wstring.i wstring /* ----------------------------------------------------------------------------- /* * Implementation files: don't look at them unless you are really drunk * * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * Basic files * ----------------------------------------------------------------------------- */ python.swg Main language file, it just includes what is needed. pyuserdir.swg User visible directives (%pythonnondynamic, etc) pymacros.swg Internal macros used for typemaps pyfragments.swg Allow the user to overload the default fragments pyopers.swg Python operations (+=, *=, etc) pythonkw.swg Python keywords and special names pyinit.swg Python Init method /* ----------------------------------------------------------------------------- * The runtime part * ----------------------------------------------------------------------------- */ pyruntime.swg Main runtime file definition pyapi.swg SWIG/Python API declarations pyrun.swg Python run-time code /* ----------------------------------------------------------------------------- * Internal typemap specializations * ----------------------------------------------------------------------------- */ pyswigtype.swg SWIGTYPE pystrings.swg Char strings (char *) pywstrings.swg Wchar Strings (wchar_t *) pyprimtypes.swg Primitive types (shot,int,double,etc) pycomplex.swg PyComplex and helper for C/C++ complex types pydocs.swg Typemaps documentation /* ----------------------------------------------------------------------------- * C++ STD + STL * ----------------------------------------------------------------------------- */ pycontainer.swg python container iterators std_common.i general common code for the STD/STL implementation std_container.i general common code for the STD/STL containers /*----------------------------------------------------------------------------- * Backward compatibility and deprecated * ----------------------------------------------------------------------------- */ std_vectora.i vector + allocator (allocators are now supported in STD/STL) typemaps.i old in/out typemaps (doesn't need to be included) defarg.swg for processing default arguments with shadow classes swig-3.0.2/Lib/python/pyclasses.swg0000664000175000017500000000614612343605122017131 0ustar williamwilliam#ifdef __cplusplus /* SwigPtr_PyObject is used as a replacement of PyObject *, where the INCREF/DECREF are applied as needed. You can use SwigPtr_PyObject in a container, such as std::vector; or as a member variable: struct A { SwigPtr_PyObject obj; A(PyObject *o) : _obj(o) { } }; or as a input/output value SwigPtr_PyObject func(SwigPtr_PyObject obj) { SwigPtr_PyObject out = PyString_FromFormat("hello %s", PyObject_AsString(obj)); Py_DECREF(out); return out; } just remember to pair the object creation with the proper DECREF, the same as with plain PyObject *ptr, since SwigPtr_PyObject always add one reference at construction. SwigPtr_PyObject is 'visible' at the wrapped side, so you can do: %template(pyvector) std::vector; and all the proper typemaps will be used. */ namespace swig { %ignore SwigPtr_PyObject; struct SwigPtr_PyObject {}; %apply PyObject * {SwigPtr_PyObject}; %apply PyObject * const& {SwigPtr_PyObject const&}; %typemap(typecheck,precedence=SWIG_TYPECHECK_SWIGOBJECT,noblock=1) SwigPtr_PyObject const& "$1 = ($input != 0);"; /* For output */ %typemap(out,noblock=1) SwigPtr_PyObject { $result = (PyObject *)$1; Py_INCREF($result); } %typemap(out,noblock=1) SwigPtr_PyObject const & { $result = (PyObject *)*$1; Py_INCREF($result); } } %{ namespace swig { class SwigPtr_PyObject { protected: PyObject *_obj; public: SwigPtr_PyObject() :_obj(0) { } SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) { Py_XINCREF(_obj); } SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) { if (initial_ref) { Py_XINCREF(_obj); } } SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) { Py_XINCREF(item._obj); Py_XDECREF(_obj); _obj = item._obj; return *this; } ~SwigPtr_PyObject() { Py_XDECREF(_obj); } operator PyObject *() const { return _obj; } PyObject *operator->() const { return _obj; } }; } %} /* SwigVar_PyObject is used to manage 'in the scope' PyObject * variables, as in int func () { SwigVar_PyObject obj = PyString_FromString("hello"); } ie, 'obj' is created and destructed in the same scope from a python object that carries at least one reference value. SwigVar_PyObject just take care of applying the proper Py_DECREF. Hence, this class is purely internal and not visible at the wrapped side. */ namespace swig { %ignore SwigVar_PyObject; struct SwigVar_PyObject {}; %apply PyObject * {SwigVar_PyObject}; %apply PyObject * const& {SwigVar_PyObject const&}; } %{ namespace swig { struct SwigVar_PyObject : SwigPtr_PyObject { SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } SwigVar_PyObject & operator = (PyObject* obj) { Py_XDECREF(_obj); _obj = obj; return *this; } }; } %} #endif swig-3.0.2/Lib/python/pythonkw.swg0000664000175000017500000000442612343605122017005 0ustar williamwilliam/* Warnings for Python keywords, built-in names and bad names. */ #define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword, renaming to '_" `x` "'", rename="_%s") `x` #define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") `x` /* Warnings for Python keywords http://www.fnorb.org/docs/1.2/Fnorb-Guide/node62.html */ PYTHONKW(and); PYTHONKW(assert); PYTHONKW(break); PYTHONKW(class); PYTHONKW(continue); PYTHONKW(def); PYTHONKW(del); PYTHONKW(elif); PYTHONKW(else); PYTHONKW(except); PYTHONKW(exec); PYTHONKW(finally); PYTHONKW(for); PYTHONKW(from); PYTHONKW(global); PYTHONKW(if); PYTHONKW(import); PYTHONKW(in); PYTHONKW(is); PYTHONKW(lambda); PYTHONKW(not); PYTHONKW(or); PYTHONKW(pass); PYTHONKW(print); PYTHONKW(raise); PYTHONKW(return); PYTHONKW(try); PYTHONKW(while); PYTHONKW(yield); /* built-in functions http://www.zvon.org/other/python/doc21/lib/built-in-funcs.html */ PYTHONBN(abs); PYTHONBN(apply); PYTHONBN(bool); PYTHONBN(buffer); PYTHONBN(callable); PYTHONBN(chr); PYTHONBN(classmethod); PYTHONBN(cmp); PYTHONBN(coerce); PYTHONBN(compile); PYTHONBN(complex); PYTHONBN(delattr); PYTHONBN(dict); PYTHONBN(dir); PYTHONBN(divmod); PYTHONBN(enumerate); PYTHONBN(eval); PYTHONBN(execfile); PYTHONBN(file); PYTHONBN(filter); PYTHONBN(float); PYTHONBN(frozenset); PYTHONBN(getattr); PYTHONBN(globals); PYTHONBN(hasattr); PYTHONBN(hash); PYTHONBN(hex); PYTHONBN(id); PYTHONBN(input); PYTHONBN(int); PYTHONBN(intern); PYTHONBN(isinstance); PYTHONBN(issubclass); PYTHONBN(iter); PYTHONBN(len); PYTHONBN(list); PYTHONBN(locals); PYTHONBN(long); PYTHONBN(map); PYTHONBN(max); PYTHONBN(min); PYTHONBN(object); PYTHONBN(oct); PYTHONBN(open); PYTHONBN(ord); PYTHONBN(pow); PYTHONBN(property); PYTHONBN(range); PYTHONBN(raw_input); PYTHONBN(reduce); PYTHONBN(reload); PYTHONBN(repr); PYTHONBN(reversed); PYTHONBN(round); PYTHONBN(set); PYTHONBN(setattr); PYTHONBN(slice); PYTHONBN(sorted); PYTHONBN(staticmethod); PYTHONBN(str); PYTHONBN(sum); PYTHONBN(super); PYTHONBN(tuple); PYTHONBN(type); PYTHONBN(unichr); PYTHONBN(unicode); PYTHONBN(vars); PYTHONBN(xrange); PYTHONBN(zip); /* built-in names boolean type and None */ PYTHONBN(True); PYTHONBN(False); PYTHONKW(None); /* 'self' is also a bad Name */ PYTHONBN(self); #undef PYTHONBN #undef PYTHONKW swig-3.0.2/Lib/python/std_map.i0000664000175000017500000002313212343605122016174 0ustar williamwilliam/* Maps */ %fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { template struct from_key_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v.first); } }; template struct from_value_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v.second); } }; template struct SwigPyMapIterator_T : SwigPyIteratorClosed_T { SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyIteratorClosed_T(curr, first, last, seq) { } }; template > struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T { SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyMapIterator_T(curr, first, last, seq) { } }; template inline SwigPyIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { return new SwigPyMapKeyIterator_T(current, begin, end, seq); } template > struct SwigPyMapValueITerator_T : SwigPyMapIterator_T { SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyMapIterator_T(curr, first, last, seq) { } }; template inline SwigPyIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { return new SwigPyMapValueITerator_T(current, begin, end, seq); } } } %fragment("StdMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::map *map) { typedef typename std::map::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::map map_type; static int asptr(PyObject *obj, map_type **val) { int res = SWIG_ERROR; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); %#if PY_VERSION_HEX >= 0x03000000 /* In Python 3.x the ".items()" method returns a dict_items object */ items = PySequence_Fast(items, ".items() didn't return a sequence!"); %#endif res = traits_asptr_stdseq >::asptr(items, val); } else { map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } SWIG_PYTHON_THREAD_END_BLOCK; return res; } }; template struct traits_from > { typedef std::map map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type; static PyObject *asdict(const map_type& map) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; size_type size = map.size(); int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } SWIG_PYTHON_THREAD_END_BLOCK; return obj; } static PyObject *from(const map_type& map) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_InternalNewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); } else { return asdict(map); } } }; } } %define %swig_map_common(Map...) %swig_sequence_iterator(Map); %swig_container_methods(Map) #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "mp_length", functype="lenfunc") __len__; %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; %feature("python:slot", "tp_iter", functype="getiterfunc") key_iterator; %extend { %newobject iterkeys(PyObject **PYTHON_SELF); swig::SwigPyIterator* iterkeys(PyObject **PYTHON_SELF) { return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject itervalues(PyObject **PYTHON_SELF); swig::SwigPyIterator* itervalues(PyObject **PYTHON_SELF) { return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject iteritems(PyObject **PYTHON_SELF); swig::SwigPyIterator* iteritems(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } #else %extend { %pythoncode {def __iter__(self): return self.key_iterator()} %pythoncode {def iterkeys(self): return self.key_iterator()} %pythoncode {def itervalues(self): return self.value_iterator()} %pythoncode {def iteritems(self): return self.iterator()} } #endif %extend { mapped_type const & __getitem__(const key_type& key) throw (std::out_of_range) { Map::const_iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __delitem__(const key_type& key) throw (std::out_of_range) { Map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const key_type& key) const { Map::const_iterator i = self->find(key); return i != self->end(); } PyObject* keys() { Map::size_type size = self->size(); int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* keyList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (int j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(keyList, j, swig::from(i->first)); } SWIG_PYTHON_THREAD_END_BLOCK; return keyList; } PyObject* values() { Map::size_type size = self->size(); int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* valList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (int j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(valList, j, swig::from(i->second)); } SWIG_PYTHON_THREAD_END_BLOCK; return valList; } PyObject* items() { Map::size_type size = self->size(); int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* itemList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (int j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(itemList, j, swig::from(*i)); } SWIG_PYTHON_THREAD_END_BLOCK; return itemList; } // Python 2.2 methods bool __contains__(const key_type& key) { return self->find(key) != self->end(); } %newobject key_iterator(PyObject **PYTHON_SELF); swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) { return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject value_iterator(PyObject **PYTHON_SELF); swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } %enddef %define %swig_map_methods(Map...) %swig_map_common(Map) #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; #endif %extend { // This will be called through the mp_ass_subscript slot to delete an entry. void __setitem__(const key_type& key) { self->erase(key); } void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { (*self)[key] = x; } PyObject* asdict() { return swig::traits_from< Map >::asdict(*self); } } %enddef %include swig-3.0.2/Lib/python/pyrun.swg0000664000175000017500000014405712343605122016304 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pyrun.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * ----------------------------------------------------------------------------- */ /* Common SWIG API */ /* for raw pointers */ #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) #ifdef SWIGPYTHON_BUILTIN #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) #else #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #endif #define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) #define swig_owntype int /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) #define SWIG_SetErrorObj SWIG_Python_SetErrorObj #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Runtime API implementation */ /* Error manipulation */ SWIGINTERN void SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetObject(errtype, obj); Py_DECREF(obj); SWIG_PYTHON_THREAD_END_BLOCK; } SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(errtype, msg); SWIG_PYTHON_THREAD_END_BLOCK; } #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) /* Set a constant value */ #if defined(SWIGPYTHON_BUILTIN) SWIGINTERN void SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { PyObject *s = PyString_InternFromString(key); PyList_Append(seq, s); Py_DECREF(s); } SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { #if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); #else PyDict_SetItemString(d, name, obj); #endif Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); } #else SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { #if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); #else PyDict_SetItemString(d, name, obj); #endif Py_DECREF(obj); } #endif /* Append a value to the result obj */ SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { #if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyList_Check(result)) { PyObject *o2 = result; result = PyList_New(1); PyList_SetItem(result, 0, o2); } PyList_Append(result,obj); Py_DECREF(obj); } return result; #else PyObject* o2; PyObject* o3; if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyTuple_Check(result)) { o2 = result; result = PyTuple_New(1); PyTuple_SET_ITEM(result, 0, o2); } o3 = PyTuple_New(1); PyTuple_SET_ITEM(o3, 0, obj); o2 = result; result = PySequence_Concat(o2, o3); Py_DECREF(o2); Py_DECREF(o3); } return result; #endif } /* Unpack the argument tuple */ SWIGINTERN int SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { if (!min && !max) { return 1; } else { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", name, (min == max ? "" : "at least "), (int)min); return 0; } } if (!PyTuple_Check(args)) { if (min <= 1 && max >= 1) { int i; objs[0] = args; for (i = 1; i < max; ++i) { objs[i] = 0; } return 2; } PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), (int)min, (int)l); return 0; } else if (l > max) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { int i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } for (; l < max; ++l) { objs[l] = 0; } return i + 1; } } } /* A functor is a function object with one single object argument */ #if PY_VERSION_HEX >= 0x02020000 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); #else #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); #endif /* Helper for static pointer initialization for both C and C++ code, for example static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); */ #ifdef __cplusplus #define SWIG_STATIC_POINTER(var) var #else #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var #endif /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ /* Flags for new pointer objects */ #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) #define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) #define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) #ifdef __cplusplus extern "C" { #endif /* How to access Py_None */ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # ifndef SWIG_PYTHON_NO_BUILD_NONE # ifndef SWIG_PYTHON_BUILD_NONE # define SWIG_PYTHON_BUILD_NONE # endif # endif #endif #ifdef SWIG_PYTHON_BUILD_NONE # ifdef Py_None # undef Py_None # define Py_None SWIG_Py_None() # endif SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { PyObject *none = Py_BuildValue((char*)""); Py_DECREF(none); return none; } SWIGRUNTIME PyObject * SWIG_Py_None(void) { static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); return none; } #endif /* The python void return value */ SWIGRUNTIMEINLINE PyObject * SWIG_Py_Void(void) { PyObject *none = Py_None; Py_INCREF(none); return none; } /* SwigPyClientData */ typedef struct { PyObject *klass; PyObject *newraw; PyObject *newargs; PyObject *destroy; int delargs; int implicitconv; PyTypeObject *pytype; } SwigPyClientData; SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; return data ? data->implicitconv : 0; } SWIGRUNTIMEINLINE PyObject * SWIG_Python_ExceptionType(swig_type_info *desc) { SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; PyObject *klass = data ? data->klass : 0; return (klass ? klass : PyExc_RuntimeError); } SWIGRUNTIME SwigPyClientData * SwigPyClientData_New(PyObject* obj) { if (!obj) { return 0; } else { SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); /* the klass element */ data->klass = obj; Py_INCREF(data->klass); /* the newraw method and newargs arguments used to create a new raw instance */ if (PyClass_Check(obj)) { data->newraw = 0; data->newargs = obj; Py_INCREF(obj); } else { #if (PY_VERSION_HEX < 0x02020000) data->newraw = 0; #else data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); #endif if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); PyTuple_SetItem(data->newargs, 0, obj); } else { data->newargs = obj; } Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; } if (data->destroy) { int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); #ifdef METH_O data->delargs = !(flags & (METH_O)); #else data->delargs = 0; #endif } else { data->delargs = 0; } data->implicitconv = 0; data->pytype = 0; return data; } } SWIGRUNTIME void SwigPyClientData_Del(SwigPyClientData *data) { Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); } /* =============== SwigPyObject =====================*/ typedef struct { PyObject_HEAD void *ptr; swig_type_info *ty; int own; PyObject *next; #ifdef SWIGPYTHON_BUILTIN PyObject *dict; #endif } SwigPyObject; SWIGRUNTIME PyObject * SwigPyObject_long(SwigPyObject *v) { return PyLong_FromVoidPtr(v->ptr); } SWIGRUNTIME PyObject * SwigPyObject_format(const char* fmt, SwigPyObject *v) { PyObject *res = NULL; PyObject *args = PyTuple_New(1); if (args) { if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { PyObject *ofmt = SWIG_Python_str_FromChar(fmt); if (ofmt) { #if PY_VERSION_HEX >= 0x03000000 res = PyUnicode_Format(ofmt,args); #else res = PyString_Format(ofmt,args); #endif Py_DECREF(ofmt); } Py_DECREF(args); } } return res; } SWIGRUNTIME PyObject * SwigPyObject_oct(SwigPyObject *v) { return SwigPyObject_format("%o",v); } SWIGRUNTIME PyObject * SwigPyObject_hex(SwigPyObject *v) { return SwigPyObject_format("%x",v); } SWIGRUNTIME PyObject * #ifdef METH_NOARGS SwigPyObject_repr(SwigPyObject *v) #else SwigPyObject_repr(SwigPyObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); if (v->next) { # ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); # else PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); # endif # if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); Py_DecRef(repr); Py_DecRef(nrep); repr = joined; # else PyString_ConcatAndDel(&repr,nrep); # endif } return repr; } SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { void *i = v->ptr; void *j = w->ptr; return (i < j) ? -1 : ((i > j) ? 1 : 0); } /* Added for Python 3.x, would it also be useful for Python 2.x? */ SWIGRUNTIME PyObject* SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) { PyObject* res; if( op != Py_EQ && op != Py_NE ) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); return res; } SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); #ifdef SWIGPYTHON_BUILTIN static swig_type_info *SwigPyObject_stype = 0; SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { SwigPyClientData *cd; assert(SwigPyObject_stype); cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; assert(cd); assert(cd->pytype); return cd->pytype; } #else SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); return type; } #endif SWIGRUNTIMEINLINE int SwigPyObject_Check(PyObject *op) { #ifdef SWIGPYTHON_BUILTIN PyTypeObject *target_tp = SwigPyObject_type(); if (PyType_IsSubtype(op->ob_type, target_tp)) return 1; return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); #else return (Py_TYPE(op) == SwigPyObject_type()) || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); #endif } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own); SWIGRUNTIME void SwigPyObject_dealloc(PyObject *v) { SwigPyObject *sobj = (SwigPyObject *) v; PyObject *next = sobj->next; if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { /* we need to create a temporary object to carry the destroy operation */ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); res = SWIG_Python_CallFunctor(destroy, tmp); Py_DECREF(tmp); } else { PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); PyObject *mself = PyCFunction_GET_SELF(destroy); res = ((*meth)(mself, v)); } Py_XDECREF(res); } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) else { const char *name = SWIG_TypePrettyName(ty); printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } #endif } Py_XDECREF(next); PyObject_DEL(v); } SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; #ifndef METH_O PyObject *tmp = 0; if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; next = tmp; #endif if (!SwigPyObject_Check(next)) { return NULL; } sobj->next = next; Py_INCREF(next); return SWIG_Py_Void(); } SWIGRUNTIME PyObject* #ifdef METH_NOARGS SwigPyObject_next(PyObject* v) #else SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { Py_INCREF(sobj->next); return sobj->next; } else { return SWIG_Py_Void(); } } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_disown(PyObject *v) #else SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; return SWIG_Py_Void(); } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_acquire(PyObject *v) #else SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; return SWIG_Py_Void(); } SWIGINTERN PyObject* SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) #elif (PY_VERSION_HEX < 0x02050000) if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) #else if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) #endif { return NULL; } else { SwigPyObject *sobj = (SwigPyObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v); } else { SwigPyObject_disown(v); } #else if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v,args); } else { SwigPyObject_disown(v,args); } #endif } return obj; } } #ifdef METH_O static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif #if PY_VERSION_HEX < 0x02020000 SWIGINTERN PyObject * SwigPyObject_getattr(SwigPyObject *sobj,char *name) { return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); } #endif SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void) { static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; static PyNumberMethods SwigPyObject_as_number = { (binaryfunc)0, /*nb_add*/ (binaryfunc)0, /*nb_subtract*/ (binaryfunc)0, /*nb_multiply*/ /* nb_divide removed in Python 3 */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc)0, /*nb_divide*/ #endif (binaryfunc)0, /*nb_remainder*/ (binaryfunc)0, /*nb_divmod*/ (ternaryfunc)0,/*nb_power*/ (unaryfunc)0, /*nb_negative*/ (unaryfunc)0, /*nb_positive*/ (unaryfunc)0, /*nb_absolute*/ (inquiry)0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ #if PY_VERSION_HEX < 0x03000000 0, /*nb_coerce*/ #endif (unaryfunc)SwigPyObject_long, /*nb_int*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_long, /*nb_long*/ #else 0, /*nb_reserved*/ #endif (unaryfunc)0, /*nb_float*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_oct, /*nb_oct*/ (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif #if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; static PyTypeObject swigpyobject_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ 0, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ #else (getattrfunc)0, /* tp_getattr */ #endif (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ #else (cmpfunc)SwigPyObject_compare, /* tp_compare */ #endif (reprfunc)SwigPyObject_repr, /* tp_repr */ &SwigPyObject_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; swigpyobject_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 swigpyobject_type.ob_type = &PyType_Type; #else if (PyType_Ready(&swigpyobject_type) < 0) return NULL; #endif } return &swigpyobject_type; } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own) { SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); if (sobj) { sobj->ptr = ptr; sobj->ty = ty; sobj->own = own; sobj->next = 0; } return (PyObject *)sobj; } /* ----------------------------------------------------------------------------- * Implements a simple Swig Packed type, and use it instead of string * ----------------------------------------------------------------------------- */ typedef struct { PyObject_HEAD void *pack; swig_type_info *ty; size_t size; } SwigPyPacked; SWIGRUNTIME int SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char result[SWIG_BUFFER_SIZE]; fputs("pack, v->size, 0, sizeof(result))) { fputs("at ", fp); fputs(result, fp); } fputs(v->ty->name,fp); fputs(">", fp); return 0; } SWIGRUNTIME PyObject * SwigPyPacked_repr(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { return SWIG_Python_str_FromFormat("", result, v->ty->name); } else { return SWIG_Python_str_FromFormat("", v->ty->name); } } SWIGRUNTIME PyObject * SwigPyPacked_str(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); } else { return SWIG_Python_str_FromChar(v->ty->name); } } SWIGRUNTIME int SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) { size_t i = v->size; size_t j = w->size; int s = (i < j) ? -1 : ((i > j) ? 1 : 0); return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); SWIGRUNTIME PyTypeObject* SwigPyPacked_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); return type; } SWIGRUNTIMEINLINE int SwigPyPacked_Check(PyObject *op) { return ((op)->ob_type == SwigPyPacked_TypeOnce()) || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); } SWIGRUNTIME void SwigPyPacked_dealloc(PyObject *v) { if (SwigPyPacked_Check(v)) { SwigPyPacked *sobj = (SwigPyPacked *) v; free(sobj->pack); } PyObject_DEL(v); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void) { static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; static PyTypeObject swigpypacked_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX>=0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ (printfunc)SwigPyPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 0, /* tp_reserved in 3.0.1 */ #else (cmpfunc)SwigPyPacked_compare, /* tp_compare */ #endif (reprfunc)SwigPyPacked_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ (reprfunc)SwigPyPacked_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigpacked_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; swigpypacked_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 swigpypacked_type.ob_type = &PyType_Type; #else if (PyType_Ready(&swigpypacked_type) < 0) return NULL; #endif } return &swigpypacked_type; } SWIGRUNTIME PyObject * SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) { SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); if (sobj) { void *pack = malloc(size); if (pack) { memcpy(pack, ptr, size); sobj->pack = pack; sobj->ty = ty; sobj->size = size; } else { PyObject_DEL((PyObject *) sobj); sobj = 0; } } return (PyObject *) sobj; } SWIGRUNTIME swig_type_info * SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { if (SwigPyPacked_Check(obj)) { SwigPyPacked *sobj = (SwigPyPacked *)obj; if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; } else { return 0; } } /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIMEINLINE PyObject * _SWIG_This(void) { return SWIG_Python_str_FromChar("this"); } static PyObject *swig_this = NULL; SWIGRUNTIME PyObject * SWIG_This(void) { if (swig_this == NULL) swig_this = _SWIG_This(); return swig_this; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ /* TODO: I don't know how to implement the fast getset in Python 3 right now */ #if PY_VERSION_HEX>=0x03000000 #define SWIG_PYTHON_SLOW_GETSET_THIS #endif SWIGRUNTIME SwigPyObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { PyObject *obj; if (SwigPyObject_Check(pyobj)) return (SwigPyObject *) pyobj; #ifdef SWIGPYTHON_BUILTIN (void)obj; # ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { pyobj = PyWeakref_GET_OBJECT(pyobj); if (pyobj && SwigPyObject_Check(pyobj)) return (SwigPyObject*) pyobj; } # endif return NULL; #else obj = 0; #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { PyObject **dictptr = _PyObject_GetDictPtr(pyobj); if (dictptr != NULL) { PyObject *dict = *dictptr; obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; } else { #ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; } #endif obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } } } #else obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } #endif if (obj && !SwigPyObject_Check(obj)) { /* a PyObject is called 'this', try to get the 'real this' SwigPyObject from it */ return SWIG_Python_GetSwigThis(obj); } return (SwigPyObject *)obj; #endif } /* Acquire a pointer value */ SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { if (own == SWIG_POINTER_OWN) { SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; sobj->own = own; return oldown; } } return 0; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { int res; SwigPyObject *sobj; int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; if (!obj) return SWIG_ERROR; if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; return SWIG_OK; } res = SWIG_ERROR; sobj = SWIG_Python_GetSwigThis(obj); if (own) *own = 0; while (sobj) { void *vptr = sobj->ptr; if (ty) { swig_type_info *to = sobj->ty; if (to == ty) { /* no type cast needed */ if (ptr) *ptr = vptr; break; } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) { sobj = (SwigPyObject *)sobj->next; } else { if (ptr) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } } break; } } } else { if (ptr) *ptr = vptr; break; } } if (sobj) { if (own) *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } res = SWIG_OK; } else { if (implicit_conv) { SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; if (klass) { PyObject *impconv; data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ impconv = SWIG_Python_CallFunctor(klass, obj); data->implicitconv = 0; if (PyErr_Occurred()) { PyErr_Clear(); impconv = 0; } if (impconv) { SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); if (iobj) { void *vptr; res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); if (SWIG_IsOK(res)) { if (ptr) { *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; res = SWIG_AddCast(res); res = SWIG_AddNewMask(res); } else { res = SWIG_AddCast(res); } } } Py_DECREF(impconv); } } } } if (!SWIG_IsOK(res) && obj == Py_None) { if (ptr) *ptr = 0; if (PyErr_Occurred()) PyErr_Clear(); res = SWIG_OK; } } return res; } /* Convert a function ptr value */ SWIGRUNTIME int SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { if (!PyCFunction_Check(obj)) { return SWIG_ConvertPtr(obj, ptr, ty, 0); } else { void *vptr = 0; /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; if (!desc) return SWIG_ERROR; if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); if (tc) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } else { return SWIG_ERROR; } } else { *ptr = vptr; } return SWIG_OK; } } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } /* ----------------------------------------------------------------------------- * Create a new pointer object * ----------------------------------------------------------------------------- */ /* Create a new instance object, without calling __init__, and set the 'this' attribute. */ SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { #if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { inst = PyObject_Call(newraw, data->newargs, NULL); if (inst) { #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { PyObject *dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; PyDict_SetItem(dict, SWIG_This(), swig_this); } } #else PyObject *key = SWIG_This(); PyObject_SetAttr(inst, key, swig_this); #endif } } else { #if PY_VERSION_HEX >= 0x03000000 inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); if (inst) { PyObject_SetAttr(inst, SWIG_This(), swig_this); Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; } #else PyObject *dict = PyDict_New(); if (dict) { PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); } #endif } return inst; #else #if (PY_VERSION_HEX >= 0x02010000) PyObject *inst = 0; PyObject *dict = PyDict_New(); if (dict) { PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); } return (PyObject *) inst; #else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { return NULL; } inst->in_class = (PyClassObject *)data->newargs; Py_INCREF(inst->in_class); inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { Py_DECREF(inst); return NULL; } #ifdef Py_TPFLAGS_HAVE_WEAKREFS inst->in_weakreflist = NULL; #endif #ifdef Py_TPFLAGS_GC PyObject_GC_Init(inst); #endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif #endif } SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { PyObject *dict; #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; } PyDict_SetItem(dict, SWIG_This(), swig_this); return; } #endif dict = PyObject_GetAttrString(inst, (char*)"__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { PyObject *obj[2]; if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { return NULL; } else { SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); if (sthis) { SwigPyObject_append((PyObject*) sthis, obj[1]); } else { SWIG_Python_SetSwigThis(obj[0], obj[1]); } return SWIG_Py_Void(); } } /* Create a new pointer object */ SWIGRUNTIME PyObject * SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { SwigPyClientData *clientdata; PyObject * robj; int own; if (!ptr) return SWIG_Py_Void(); clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; if (clientdata && clientdata->pytype) { SwigPyObject *newobj; if (flags & SWIG_BUILTIN_TP_INIT) { newobj = (SwigPyObject*) self; if (newobj->ptr) { PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); while (newobj->next) newobj = (SwigPyObject *) newobj->next; newobj->next = next_self; newobj = (SwigPyObject *)next_self; } } else { newobj = PyObject_New(SwigPyObject, clientdata->pytype); } if (newobj) { newobj->ptr = ptr; newobj->ty = type; newobj->own = own; newobj->next = 0; #ifdef SWIGPYTHON_BUILTIN newobj->dict = 0; #endif return (PyObject*) newobj; } return SWIG_Py_Void(); } assert(!(flags & SWIG_BUILTIN_TP_INIT)); robj = SwigPyObject_New(ptr, type, own); if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); Py_DECREF(robj); robj = inst; } return robj; } /* Create a new packed object */ SWIGRUNTIMEINLINE PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); } /* -----------------------------------------------------------------------------* * Get type list * -----------------------------------------------------------------------------*/ #ifdef SWIG_LINK_RUNTIME void *SWIG_ReturnGlobalTypeList(void *); #endif SWIGRUNTIME swig_module_info * SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else # ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); # else type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); # endif if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; } #endif } return (swig_module_info *) type_pointer; } #if PY_MAJOR_VERSION < 2 /* PyModule_AddObject function was introduced in Python 2.0. The following function is copied out of Python/modsupport.c in python version 2.3.4 */ SWIGINTERN int PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return SWIG_ERROR; } if (!o) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return SWIG_ERROR; } dict = PyModule_GetDict(m); if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m)); return SWIG_ERROR; } if (PyDict_SetItemString(dict, name, o)) return SWIG_ERROR; Py_DECREF(o); return SWIG_OK; } #endif SWIGRUNTIME void #ifdef SWIGPY_USE_CAPSULE SWIG_Python_DestroyModule(PyObject *obj) #else SWIG_Python_DestroyModule(void *vptr) #endif { #ifdef SWIGPY_USE_CAPSULE swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); #else swig_module_info *swig_module = (swig_module_info *) vptr; #endif swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { swig_type_info *ty = types[i]; if (ty->owndata) { SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; if (data) SwigPyClientData_Del(data); } } Py_DECREF(SWIG_This()); swig_this = NULL; } SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { #if PY_VERSION_HEX >= 0x03000000 /* Add a dummy module object into sys.modules */ PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); #else static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif #ifdef SWIGPY_USE_CAPSULE PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } #else PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } #endif } /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); return cache; } SWIGRUNTIME swig_type_info * SWIG_Python_TypeQuery(const char *type) { PyObject *cache = SWIG_Python_TypeCache(); PyObject *key = SWIG_Python_str_FromChar(type); PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { #ifdef SWIGPY_USE_CAPSULE descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); #else descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); #endif } else { swig_module_info *swig_module = SWIG_GetModule(0); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { #ifdef SWIGPY_USE_CAPSULE obj = PyCapsule_New((void*) descriptor, NULL, NULL); #else obj = PyCObject_FromVoidPtr(descriptor, NULL); #endif PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } } Py_DECREF(key); return descriptor; } /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) SWIGRUNTIME int SWIG_Python_AddErrMesg(const char* mesg, int infront) { if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); } else { PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); } return 1; } else { return 0; } } SWIGRUNTIME int SWIG_Python_ArgFail(int argnum) { if (PyErr_Occurred()) { /* add information about failing argument */ char mesg[256]; PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); return SWIG_Python_AddErrMesg(mesg, 1); } else { return 0; } } SWIGRUNTIMEINLINE const char * SwigPyObject_GetDesc(PyObject *self) { SwigPyObject *v = (SwigPyObject *)self; swig_type_info *ty = v ? v->ty : 0; return ty ? ty->str : ""; } SWIGRUNTIME void SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { #if defined(SWIG_COBJECT_TYPES) if (obj && SwigPyObject_Check(obj)) { const char *otype = (const char *) SwigPyObject_GetDesc(obj); if (otype) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", type, otype); return; } } else #endif { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); SWIG_Python_str_DelForPy3(cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); } Py_XDECREF(str); return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); } else { PyErr_Format(PyExc_TypeError, "unexpected type is received"); } } /* Convert a pointer value, signal an exception on a type mismatch */ SWIGRUNTIME void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); #if SWIG_POINTER_EXCEPTION if (flags) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } #endif } return result; } #ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME int SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { PyTypeObject *tp = obj->ob_type; PyObject *descr; PyObject *encoded_name; descrsetfunc f; int res = -1; # ifdef Py_USING_UNICODE if (PyString_Check(name)) { name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); if (!name) return -1; } else if (!PyUnicode_Check(name)) # else if (!PyString_Check(name)) # endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); return -1; } else { Py_INCREF(name); } if (!tp->tp_dict) { if (PyType_Ready(tp) < 0) goto done; } descr = _PyType_Lookup(tp, name); f = NULL; if (descr != NULL) f = descr->ob_type->tp_descr_set; if (!f) { if (PyString_Check(name)) { encoded_name = name; Py_INCREF(name); } else { encoded_name = PyUnicode_AsUTF8String(name); } PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); Py_DECREF(encoded_name); } else { res = f(descr, obj, value); } done: Py_DECREF(name); return res; } #endif #ifdef __cplusplus } #endif swig-3.0.2/Lib/python/std_unordered_map.i0000664000175000017500000002011312343605122020237 0ustar williamwilliam/* Unordered Maps */ %fragment("StdMapTraits","header",fragment="StdSequenceTraits") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::unordered_map *unordered_map) { typedef typename std::unordered_map::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { unordered_map->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::unordered_map unordered_map_type; static int asptr(PyObject *obj, unordered_map_type **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); %#if PY_VERSION_HEX >= 0x03000000 /* In Python 3.x the ".items()" method return a dict_items object */ items = PySequence_Fast(items, ".items() havn't returned a sequence!"); %#endif res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { unordered_map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::unordered_map unordered_map_type; typedef typename unordered_map_type::const_iterator const_iterator; typedef typename unordered_map_type::size_type size_type; static PyObject *from(const unordered_map_type& unordered_map) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN); } else { size_type size = unordered_map.size(); int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= unordered_map.begin(); i!= unordered_map.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; } } }; template struct from_key_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v.first); } }; template struct from_value_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v.second); } }; template struct SwigPyMapIterator_T : SwigPyIteratorClosed_T { SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyIteratorClosed_T(curr, first, last, seq) { } }; template > struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T { SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyMapIterator_T(curr, first, last, seq) { } }; template inline SwigPyIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { return new SwigPyMapKeyIterator_T(current, begin, end, seq); } template > struct SwigPyMapValueITerator_T : SwigPyMapIterator_T { SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyMapIterator_T(curr, first, last, seq) { } }; template inline SwigPyIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { return new SwigPyMapValueITerator_T(current, begin, end, seq); } } } %define %swig_unordered_map_common(Map...) %swig_sequence_iterator(Map); %swig_container_methods(Map) %extend { mapped_type __getitem__(const key_type& key) const throw (std::out_of_range) { Map::const_iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __delitem__(const key_type& key) throw (std::out_of_range) { Map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const key_type& key) const { Map::const_iterator i = self->find(key); return i != self->end(); } PyObject* keys() { Map::size_type size = self->size(); int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* keyList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (int j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(keyList, j, swig::from(i->first)); } return keyList; } PyObject* values() { Map::size_type size = self->size(); int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* valList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (int j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(valList, j, swig::from(i->second)); } return valList; } PyObject* items() { Map::size_type size = self->size(); int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* itemList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (int j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(itemList, j, swig::from(*i)); } return itemList; } // Python 2.2 methods bool __contains__(const key_type& key) { return self->find(key) != self->end(); } %newobject key_iterator(PyObject **PYTHON_SELF); swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) { return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject value_iterator(PyObject **PYTHON_SELF); swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %pythoncode {def __iter__(self): return self.key_iterator()} %pythoncode {def iterkeys(self): return self.key_iterator()} %pythoncode {def itervalues(self): return self.value_iterator()} %pythoncode {def iteritems(self): return self.iterator()} } %enddef %define %swig_unordered_map_methods(Map...) %swig_unordered_map_common(Map) %extend { void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { (*self)[key] = x; } } %enddef %include swig-3.0.2/Lib/python/pyhead.swg0000664000175000017500000001325512343605122016374 0ustar williamwilliam/* Compatibility macros for Python 3 */ #if PY_VERSION_HEX >= 0x03000000 #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) #define PyInt_FromLong(x) PyLong_FromLong(x) #define PyInt_FromSize_t(x) PyLong_FromSize_t(x) #define PyString_Check(name) PyBytes_Check(name) #define PyString_FromString(x) PyUnicode_FromString(x) #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) #define PyString_AsString(str) PyBytes_AsString(str) #define PyString_Size(str) PyBytes_Size(str) #define PyString_InternFromString(key) PyUnicode_InternFromString(key) #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE #define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) #endif #ifndef Py_TYPE # define Py_TYPE(op) ((op)->ob_type) #endif /* SWIG APIs for compatibility of both Python 2 & 3 */ #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_FromFormat PyUnicode_FromFormat #else # define SWIG_Python_str_FromFormat PyString_FromFormat #endif /* Warning: This function will allocate a new string in Python 3, * so please call SWIG_Python_str_DelForPy3(x) to free the space. */ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03000000 char *cstr; char *newstr; Py_ssize_t len; str = PyUnicode_AsUTF8String(str); PyBytes_AsStringAndSize(str, &cstr, &len); newstr = (char *) malloc(len+1); memcpy(newstr, cstr, len+1); Py_XDECREF(str); return newstr; #else return PyString_AsString(str); #endif } #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) #else # define SWIG_Python_str_DelForPy3(x) #endif SWIGINTERN PyObject* SWIG_Python_str_FromChar(const char *c) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromString(c); #else return PyString_FromString(c); #endif } /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # define PyOS_snprintf _snprintf # else # define PyOS_snprintf snprintf # endif #endif /* A crude PyString_FromFormat implementation for old Pythons */ #if PY_VERSION_HEX < 0x02020000 #ifndef SWIG_PYBUFFER_SIZE # define SWIG_PYBUFFER_SIZE 1024 #endif static PyObject * PyString_FromFormat(const char *fmt, ...) { va_list ap; char buf[SWIG_PYBUFFER_SIZE * 2]; int res; va_start(ap, fmt); res = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); } #endif /* Add PyObject_Del for old Pythons */ #if PY_VERSION_HEX < 0x01060000 # define PyObject_Del(op) PyMem_DEL((op)) #endif #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif /* A crude PyExc_StopIteration exception for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # ifndef PyExc_StopIteration # define PyExc_StopIteration PyExc_RuntimeError # endif # ifndef PyObject_GenericGetAttr # define PyObject_GenericGetAttr 0 # endif #endif /* Py_NotImplemented is defined in 2.1 and up. */ #if PY_VERSION_HEX < 0x02010000 # ifndef Py_NotImplemented # define Py_NotImplemented PyExc_RuntimeError # endif #endif /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 # ifndef PyString_AsStringAndSize # define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} # endif #endif /* PySequence_Size for old Pythons */ #if PY_VERSION_HEX < 0x02000000 # ifndef PySequence_Size # define PySequence_Size PySequence_Length # endif #endif /* PyBool_FromLong for old Pythons */ #if PY_VERSION_HEX < 0x02030000 static PyObject *PyBool_FromLong(long ok) { PyObject *result = ok ? Py_True : Py_False; Py_INCREF(result); return result; } #endif /* Py_ssize_t for old Pythons */ /* This code is as recommended by: */ /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) typedef int Py_ssize_t; # define PY_SSIZE_T_MAX INT_MAX # define PY_SSIZE_T_MIN INT_MIN typedef inquiry lenfunc; typedef intargfunc ssizeargfunc; typedef intintargfunc ssizessizeargfunc; typedef intobjargproc ssizeobjargproc; typedef intintobjargproc ssizessizeobjargproc; typedef getreadbufferproc readbufferproc; typedef getwritebufferproc writebufferproc; typedef getsegcountproc segcountproc; typedef getcharbufferproc charbufferproc; static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) { long result = 0; PyObject *i = PyNumber_Int(x); if (i) { result = PyInt_AsLong(i); Py_DECREF(i); } return result; } #endif #if PY_VERSION_HEX < 0x02050000 #define PyInt_FromSize_t(x) PyInt_FromLong((long)x) #endif #if PY_VERSION_HEX < 0x02040000 #define Py_VISIT(op) \ do { \ if (op) { \ int vret = visit((op), arg); \ if (vret) \ return vret; \ } \ } while (0) #endif #if PY_VERSION_HEX < 0x02030000 typedef struct { PyTypeObject type; PyNumberMethods as_number; PyMappingMethods as_mapping; PySequenceMethods as_sequence; PyBufferProcs as_buffer; PyObject *name, *slots; } PyHeapTypeObject; #endif #if PY_VERSION_HEX < 0x02030000 typedef destructor freefunc; #endif #if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ (PY_MAJOR_VERSION > 3)) # define SWIGPY_USE_CAPSULE # define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) #endif #if PY_VERSION_HEX < 0x03020000 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) #endif swig-3.0.2/Lib/python/python.swg0000664000175000017500000000376312343605122016446 0ustar williamwilliam/* ------------------------------------------------------------ * python.swg * * Python configuration module. * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Inner macros * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The runtime part * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Special user directives * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Typemap specializations * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Warnings for Python keywords * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Python autodoc support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Python classes, for C++ * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Python initialization function * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * For backward compatibility * ------------------------------------------------------------ */ %include swig-3.0.2/Lib/python/pytypemaps.swg0000664000175000017500000000600112343605122017324 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Python * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ #ifdef SWIG_PYTHON_LEGACY_BOOL // Default prior to SWIG 3.0.0 #undef SWIG_TYPECHECK_BOOL %define SWIG_TYPECHECK_BOOL 10000 %enddef #endif /* Include fundamental fragment definitions */ %include /* Look for user fragments file. */ %include /* Python fragments for fundamental types */ %include /* Python fragments for char* strings */ %include /* Backward compatibility output helper */ %fragment("t_output_helper","header") %{ #define t_output_helper SWIG_Python_AppendOutput %} /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* directors are supported in Python */ #ifndef SWIG_DIRECTOR_TYPEMAPS #define SWIG_DIRECTOR_TYPEMAPS #endif /* Python types */ #define SWIG_Object PyObject * #define VOID_Object SWIG_Py_Void() /* Python allows implicit conversion */ #define %implicitconv_flag $implicitconv /* Overload of the output/constant/exception/dirout handling */ /* append output */ #define SWIG_AppendOutput(result, obj) SWIG_Python_AppendOutput(result, obj) /* set constant */ #if defined(SWIGPYTHON_BUILTIN) #define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, name,obj) #else #define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj) #endif /* raise */ #define SWIG_Raise(obj, type, desc) SWIG_Python_Raise(obj, type, desc) /* Include the unified typemap library */ %include /* ------------------------------------------------------------ * Python extra typemaps / typemap overrides * ------------------------------------------------------------ */ /* Get the address of the 'python self' object */ %typemap(in,numinputs=0,noblock=1) PyObject **PYTHON_SELF { $1 = &$self; } /* Consttab, needed for callbacks, it should be removed later */ %typemap(consttab) SWIGTYPE ((*)(ANY)) { SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor } %typemap(constcode) SWIGTYPE ((*)(ANY)) ""; /* Smart Pointers */ %typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER { $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags); } %typemap(ret,noblock=1) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER { if ($result) { PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL); if (robj && !PyErr_Occurred()) { SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result), (PyObject *) SWIG_Python_GetSwigThis(robj)); Py_DECREF(robj); } } } swig-3.0.2/Lib/python/std_iostream.i0000664000175000017500000000015312343605122017240 0ustar williamwilliamnamespace std { %callback(1) endl; %callback(1) ends; %callback(1) flush; } %include swig-3.0.2/Lib/python/pycomplex.swg0000664000175000017500000000430212343605122017133 0ustar williamwilliam/* Defines the As/From converters for double/float complex, you need to provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex accessor methods. See the std_complex.i and ccomplex.i for concret examples. */ /* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header") { SWIGINTERNINLINE PyObject* SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) { return PyComplex_FromDoubles(Real(c), Imag(c)); } } %enddef /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int SWIG_AsVal(Type) (PyObject *o, Type* val) { if (PyComplex_Check(o)) { if (val) *val = Constructor(PyComplex_RealAsDouble(o), PyComplex_ImagAsDouble(o)); return SWIG_OK; } else { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef /* the float case */ %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float)) { SWIGINTERN int SWIG_AsVal(Type)(PyObject *o, Type *val) { if (PyComplex_Check(o)) { double re = PyComplex_RealAsDouble(o); double im = PyComplex_ImagAsDouble(o); if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else { return SWIG_OverflowError; } } else { float re; int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(re, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.2/Lib/python/argcargv.i0000664000175000017500000000512212343605122016340 0ustar williamwilliam/* ------------------------------------------------------------ * --- Argc & Argv --- * ------------------------------------------------------------ */ %fragment("SWIG_AsArgcArgv","header",fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsArgcArgv(PyObject *input, swig_type_info *ppchar_info, size_t *argc, char ***argv, int *owner) { void *vptr; int res = SWIG_ConvertPtr(input, &vptr, ppchar_info, 0); if (!SWIG_IsOK(res)) { int list = 0; PyErr_Clear(); list = PyList_Check(input); if (list || PyTuple_Check(input)) { size_t i = 0; size_t size = list ? PyList_Size(input) : PyTuple_Size(input); if (argc) *argc = size; if (argv) { *argv = %new_array(size + 1, char*); for (; i < size; ++i) { PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); char *cptr = 0; size_t sz = 0; int alloc = 0; res = SWIG_AsCharPtrAndSize(obj, &cptr, &sz, &alloc); if (SWIG_IsOK(res)) { if (cptr && sz) { (*argv)[i] = (alloc == SWIG_NEWOBJ) ? cptr : %new_copy_array(cptr, sz, char); } else { (*argv)[i] = 0; } } else { return SWIG_TypeError; } } (*argv)[i] = 0; if (owner) *owner = 1; } else { for (; i < size; ++i) { PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); res = SWIG_AsCharPtrAndSize(obj, 0, 0, 0); if (!SWIG_IsOK(res)) return SWIG_TypeError; } if (owner) *owner = 0; } return SWIG_OK; } else { return SWIG_TypeError; } } else { /* seems dangerous, but the user asked for it... */ size_t i = 0; if (argv) { while (*argv[i] != 0) ++i;} if (argc) *argc = i; if (owner) *owner = 0; return SWIG_OK; } } } /* This typemap works with either a char **, a python list or a python tuple */ %typemap(in,noblock=0,fragment="SWIG_AsArgcArgv") (int ARGC, char **ARGV) (int res,char **argv = 0, size_t argc = 0, int owner= 0) { res = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &argv, &owner); if (!SWIG_IsOK(res)) { $1 = 0; $2 = 0; %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum); } else { $1 = %static_cast(argc,$1_ltype); $2 = %static_cast(argv, $2_ltype); } } %typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) { int res = SWIG_AsArgcArgv($input, $descriptor(char**), 0, 0, 0); $1 = SWIG_IsOK(res); } %typemap(freearg,noblock=1) (int ARGC, char **ARGV) { if (owner$argnum) { size_t i = argc$argnum; while (i) { %delete_array(argv$argnum[--i]); } %delete_array(argv$argnum); } } swig-3.0.2/Lib/python/wchar.i0000664000175000017500000000027212343605122015651 0ustar williamwilliam#ifdef __cplusplus %{ #include %} #else %{ #include %} #endif %types(wchar_t *); %include /* Enable swig wchar support. */ #define SWIG_WCHAR swig-3.0.2/Lib/python/std_pair.i0000664000175000017500000001345112343605122016355 0ustar williamwilliam/* Pairs */ %include //#define SWIG_STD_PAIR_ASVAL %fragment("StdPairTraits","header",fragment="StdTraits") { namespace swig { #ifdef SWIG_STD_PAIR_ASVAL template struct traits_asval > { typedef std::pair value_type; static int get_pair(PyObject* first, PyObject* second, std::pair *val) { if (val) { T *pfirst = &(val->first); int res1 = swig::asval((PyObject*)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(val->second); int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } else { T *pfirst = 0; int res1 = swig::asval((PyObject*)first, 0); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asval(PyObject *obj, std::pair *val) { int res = SWIG_ERROR; if (PyTuple_Check(obj)) { if (PyTuple_GET_SIZE(obj) == 2) { res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); } } else if (PySequence_Check(obj)) { if (PySequence_Size(obj) == 2) { swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); res = get_pair(first, second, val); } } else { value_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = *p; } return res; } }; #else template struct traits_asptr > { typedef std::pair value_type; static int get_pair(PyObject* first, PyObject* second, std::pair **val) { if (val) { value_type *vp = %new_instance(std::pair); T *pfirst = &(vp->first); int res1 = swig::asval((PyObject*)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(vp->second); int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; *val = vp; return SWIG_AddNewMask(res1 > res2 ? res1 : res2); } else { T *pfirst = 0; int res1 = swig::asval((PyObject*)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asptr(PyObject *obj, std::pair **val) { int res = SWIG_ERROR; if (PyTuple_Check(obj)) { if (PyTuple_GET_SIZE(obj) == 2) { res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); } } else if (PySequence_Check(obj)) { if (PySequence_Size(obj) == 2) { swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); res = get_pair(first, second, val); } } else { value_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; #endif template struct traits_from > { static PyObject *from(const std::pair& val) { PyObject* obj = PyTuple_New(2); PyTuple_SetItem(obj,0,swig::from(val.first)); PyTuple_SetItem(obj,1,swig::from(val.second)); return obj; } }; } #if defined(SWIGPYTHON_BUILTIN) SWIGINTERN Py_ssize_t SwigPython_std_pair_len (PyObject *a) { return 2; } SWIGINTERN PyObject* SwigPython_std_pair_repr (PyObject *o) { PyObject *tuple = PyTuple_New(2); assert(tuple); PyTuple_SET_ITEM(tuple, 0, PyObject_GetAttrString(o, (char*) "first")); PyTuple_SET_ITEM(tuple, 1, PyObject_GetAttrString(o, (char*) "second")); PyObject *result = PyObject_Repr(tuple); Py_DECREF(tuple); return result; } SWIGINTERN PyObject* SwigPython_std_pair_getitem (PyObject *a, Py_ssize_t b) { PyObject *result = PyObject_GetAttrString(a, b % 2 ? (char*) "second" : (char*) "first"); return result; } SWIGINTERN int SwigPython_std_pair_setitem (PyObject *a, Py_ssize_t b, PyObject *c) { int result = PyObject_SetAttrString(a, b % 2 ? (char*) "second" : (char*) "first", c); return result; } #endif } %feature("python:sq_length") std::pair "SwigPython_std_pair_len"; %feature("python:sq_length") std::pair "SwigPython_std_pair_len"; %feature("python:sq_length") std::pair "SwigPython_std_pair_len"; %feature("python:sq_length") std::pair "SwigPython_std_pair_len"; %feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; %feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; %feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; %feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; %feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; %feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; %feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; %feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; %feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; %feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; %feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; %feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; %define %swig_pair_methods(pair...) #if !defined(SWIGPYTHON_BUILTIN) %extend { %pythoncode {def __len__(self): return 2 def __repr__(self): return str((self.first, self.second)) def __getitem__(self, index): if not (index % 2): return self.first else: return self.second def __setitem__(self, index, val): if not (index % 2): self.first = val else: self.second = val} } #endif %enddef %include swig-3.0.2/Lib/python/std_complex.i0000664000175000017500000000072512343605122017071 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.2/Lib/python/pydocs.swg0000664000175000017500000000212012343605122016410 0ustar williamwilliam // Documentation for use with the autodoc feature. #ifdef SWIG_DOC_DOXYGEN_STYLE %typemap(doc) SWIGTYPE "@param $1_name $1_type"; %typemap(doc) SWIGTYPE * "@param $1_name $1_type"; %typemap(doc) const SWIGTYPE & "@param $1_name $1_type"; %typemap(doc) const SWIGTYPE && "@param $1_name $1_type"; %typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type"; %typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "@param $1_name $1_type (input/output)"; %typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "@param $1_name $1_type (input)"; %typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "@param $1_name $1_type (output)"; #else %typemap(doc) SWIGTYPE "$1_name: $1_type"; %typemap(doc) SWIGTYPE * "$1_name: $1_type"; %typemap(doc) const SWIGTYPE & "$1_name: $1_type"; %typemap(doc) const SWIGTYPE && "$1_name: $1_type"; %typemap(doc) enum SWIGTYPE "$1_name: enum $1_type"; %typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "$1_name: $1_type (input/output)"; %typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "$1_name: $1_type (input)"; %typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "$1_name: $1_type (output)"; #endif swig-3.0.2/Lib/python/typemaps.i0000664000175000017500000001054512343605122016413 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * These mappings provide support for input/output arguments and common * uses for C/C++ pointers. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Python tuple. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Python output of the function would be a tuple containing both output values. */ // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Python tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Python). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Python variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %include swig-3.0.2/Lib/python/pytuplehlp.swg0000664000175000017500000000046412343605122017326 0ustar williamwilliam/* Helper function to return output types, now we need to use a list instead of a tuple since all the other types (std::pair,std::vector,std::list,etc) return tuples. */ #warning "Deprecated file: Don't use t_output_helper anymore," #warning "use SWIG_Python_AppendOutput or %append_output instead." swig-3.0.2/Lib/python/pyfragments.swg0000664000175000017500000000104712343605122017455 0ustar williamwilliam/* Create a file with this name, 'pyfragments.swg', in your working directory and add all the %fragments you want to take precedence over the default ones defined by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(PyObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.2/Lib/python/std_wstreambuf.i0000664000175000017500000000004012343605122017567 0ustar williamwilliam%include swig-3.0.2/Lib/python/std_container.i0000664000175000017500000000007212343605122017377 0ustar williamwilliam%include %include swig-3.0.2/Lib/python/cmalloc.i0000664000175000017500000000004012343605122016150 0ustar williamwilliam%include swig-3.0.2/Lib/python/cni.i0000664000175000017500000000005212343605122015312 0ustar williamwilliam%include %include swig-3.0.2/Lib/python/cstring.i0000664000175000017500000000004012343605122016207 0ustar williamwilliam%include swig-3.0.2/Lib/python/std_streambuf.i0000664000175000017500000000003712343605122017406 0ustar williamwilliam%include swig-3.0.2/Lib/python/attribute.i0000664000175000017500000000004212343605122016543 0ustar williamwilliam%include swig-3.0.2/Lib/python/implicit.i0000664000175000017500000000043712343605122016362 0ustar williamwilliam%include %include #warning "This file provides the %implicit directive, which is an old and fragile" #warning "way to implement the C++ implicit conversion mechanism." #warning "Try using the more robust '%implicitconv Type;' directive instead." swig-3.0.2/Lib/python/jstring.i0000664000175000017500000000333712343605122016232 0ustar williamwilliam%include %fragment(SWIG_AsVal_frag(jstring),"header") { SWIGINTERN int SWIG_AsVal(jstring)(PyObject *obj, jstring *val) { if (obj == Py_None) { if (val) *val = 0; return SWIG_OK; } PyObject *tmp = 0; int isunicode = PyUnicode_Check(obj); if (!isunicode && PyString_Check(obj)) { if (val) { obj = tmp = PyUnicode_FromObject(obj); } isunicode = 1; } if (isunicode) { if (val) { if (sizeof(Py_UNICODE) == sizeof(jchar)) { *val = JvNewString((const jchar *) PyUnicode_AS_UNICODE(obj),PyUnicode_GET_SIZE(obj)); return SWIG_NEWOBJ; } else { int len = PyUnicode_GET_SIZE(obj); Py_UNICODE *pchars = PyUnicode_AS_UNICODE(obj); *val = JvAllocString (len); jchar *jchars = JvGetStringChars (*val); for (int i = 0; i < len; ++i) { jchars[i] = pchars[i]; } return SWIG_NEWOBJ; } } Py_XDECREF(tmp); return SWIG_OK; } return SWIG_TypeError; } } %fragment(SWIG_From_frag(jstring),"header") { SWIGINTERNINLINE PyObject * SWIG_From(jstring)(jstring val) { if (!val) { return SWIG_Py_Void(); } if (sizeof(Py_UNICODE) == sizeof(jchar)) { return PyUnicode_FromUnicode((const Py_UNICODE *) JvGetStringChars(val), JvGetStringUTFLength(val)); } else { int len = JvGetStringUTFLength(val); Py_UNICODE pchars[len]; jchar *jchars = JvGetStringChars(val); for (int i = 0; i < len; i++) { pchars[i] = jchars[i]; } return PyUnicode_FromUnicode((const Py_UNICODE *) pchars, len); } } } %typemaps_asvalfrom(%checkcode(STRING), %arg(SWIG_AsVal(jstring)), %arg(SWIG_From(jstring)), %arg(SWIG_AsVal_frag(jstring)), %arg(SWIG_From_frag(jstring)), java::lang::String *); swig-3.0.2/Lib/python/pyerrors.swg0000664000175000017500000000312212343605122016777 0ustar williamwilliam/* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIME PyObject* SWIG_Python_ErrorType(int code) { PyObject* type = 0; switch(code) { case SWIG_MemoryError: type = PyExc_MemoryError; break; case SWIG_IOError: type = PyExc_IOError; break; case SWIG_RuntimeError: type = PyExc_RuntimeError; break; case SWIG_IndexError: type = PyExc_IndexError; break; case SWIG_TypeError: type = PyExc_TypeError; break; case SWIG_DivisionByZero: type = PyExc_ZeroDivisionError; break; case SWIG_OverflowError: type = PyExc_OverflowError; break; case SWIG_SyntaxError: type = PyExc_SyntaxError; break; case SWIG_ValueError: type = PyExc_ValueError; break; case SWIG_SystemError: type = PyExc_SystemError; break; case SWIG_AttributeError: type = PyExc_AttributeError; break; default: type = PyExc_RuntimeError; } return type; } SWIGRUNTIME void SWIG_Python_AddErrorMsg(const char* mesg) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); } else { PyErr_SetString(PyExc_RuntimeError, mesg); } } swig-3.0.2/Lib/python/cdata.i0000664000175000017500000000003612343605122015617 0ustar williamwilliam%include swig-3.0.2/Lib/python/ccomplex.i0000664000175000017500000000137312343605122016362 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ccomplex.i * * C complex typemaps * ISO C99: 7.3 Complex arithmetic * ----------------------------------------------------------------------------- */ %include %{ #include %} /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) %swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); swig-3.0.2/Lib/python/boost_shared_ptr.i0000664000175000017500000003766512343605122020126 0ustar williamwilliam%include // Set SHARED_PTR_DISOWN to $disown if required, for example // #define SHARED_PTR_DISOWN $disown #if !defined(SHARED_PTR_DISOWN) #define SHARED_PTR_DISOWN 0 #endif %fragment("SWIG_null_deleter_python", "header", fragment="SWIG_null_deleter") { %#define SWIG_NO_NULL_DELETER_SWIG_BUILTIN_INIT } // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(out) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(varout) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE * { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain reference %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE & { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = *%const_cast(tempshared.get(), $1_ltype); } else { $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer by reference // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); temp = %const_cast(tempshared.get(), $*1_ltype); } else { temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); } $1 = &temp; } %typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} %typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { int newmem = 0; void *argp = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varout typemap not implemented" %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); if ($owner) delete $1; } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varout typemap not implemented" %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); temp = &tempshared; $1 = &temp; } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varout typemap not implemented" %} // Typecheck typemaps // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); $1 = SWIG_CheckState(res); } // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.2/Lib/python/pyapi.swg0000664000175000017500000000247312343605122016244 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Python API portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; /* ----------------------------------------------------------------------------- * Wrapper of PyInstanceMethod_New() used in Python 3 * It is exported to the generated module, used for -fastproxy * ----------------------------------------------------------------------------- */ #if PY_VERSION_HEX >= 0x03000000 SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { return PyInstanceMethod_New(func); } #else SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) { return NULL; } #endif #ifdef __cplusplus } #endif swig-3.0.2/Lib/python/pystrings.swg0000664000175000017500000000602712343605122017163 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { %#if PY_VERSION_HEX>=0x03000000 if (PyUnicode_Check(obj)) %#else if (PyString_Check(obj)) %#endif { char *cstr; Py_ssize_t len; %#if PY_VERSION_HEX>=0x03000000 if (!alloc && cptr) { /* We can't allow converting without allocation, since the internal representation of string in Python 3 is UCS-2/UCS-4 but we require a UTF-8 representation. TODO(bhy) More detailed explanation */ return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); PyBytes_AsStringAndSize(obj, &cstr, &len); if(alloc) *alloc = SWIG_NEWOBJ; %#else PyString_AsStringAndSize(obj, &cstr, &len); %#endif if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner string representation. To warranty that, if you define SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string buffer is always returned. The default behavior is just to return the pointer value, so, be careful. */ %#if defined(SWIG_PYTHON_SAFE_CSTRINGS) if (*alloc != SWIG_OLDOBJ) %#else if (*alloc == SWIG_NEWOBJ) %#endif { *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { %#if PY_VERSION_HEX>=0x03000000 assert(0); /* Should never reach here in Python 3 */ %#endif *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; %#if PY_VERSION_HEX>=0x03000000 Py_XDECREF(obj); %#endif return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE PyObject * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); return pchar_descriptor ? SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); } else { %#if PY_VERSION_HEX >= 0x03000000 %#if PY_VERSION_HEX >= 0x03010000 return PyUnicode_DecodeUTF8(carray, %numeric_cast(size,int), "surrogateescape"); %#else return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int)); %#endif %#else return PyString_FromStringAndSize(carray, %numeric_cast(size,int)); %#endif } } else { return SWIG_Py_Void(); } } } swig-3.0.2/Lib/python/builtin.swg0000664000175000017500000004027612343605122016573 0ustar williamwilliam#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a) { \ return wrapper(a, NULL); \ } #define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \ SWIGINTERN void \ wrapper##_closure(PyObject *a) { \ SwigPyObject *sobj; \ sobj = (SwigPyObject *)a; \ if (sobj->own) { \ PyObject *o = wrapper(a, NULL); \ Py_XDECREF(o); \ } \ if (PyType_IS_GC(a->ob_type)) { \ PyObject_GC_Del(a); \ } else { \ PyObject_Del(a); \ } \ } #define SWIGPY_INQUIRY_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a) { \ PyObject *pyresult; \ int result; \ pyresult = wrapper(a, NULL); \ result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; \ Py_XDECREF(pyresult); \ return result; \ } #define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, PyObject *b) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(1); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, b); \ Py_XINCREF(b); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } typedef ternaryfunc ternarycallfunc; #define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, b); \ PyTuple_SET_ITEM(tuple, 1, c); \ Py_XINCREF(b); \ Py_XINCREF(c); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *callable_object, PyObject *args, PyObject *) { \ return wrapper(callable_object, args); \ } #define SWIGPY_LENFUNC_CLOSURE(wrapper) \ SWIGINTERN Py_ssize_t \ wrapper##_closure(PyObject *a) { \ PyObject *resultobj; \ Py_ssize_t result; \ resultobj = wrapper(a, NULL); \ result = PyNumber_AsSsize_t(resultobj, NULL); \ Py_DECREF(resultobj); \ return result; \ } #define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \ PyObject *tuple, *resultobj; \ int result; \ tuple = PyTuple_New(d ? 3 : 2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); \ if (d) { \ PyTuple_SET_ITEM(tuple, 2, d); \ Py_INCREF(d); \ } \ resultobj = wrapper(a, tuple); \ result = resultobj ? 0 : -1; \ Py_DECREF(tuple); \ Py_XDECREF(resultobj); \ return result; \ } #define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(1); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b) { \ PyObject *arg, *result; \ arg = _PyLong_FromSsize_t(b); \ result = wrapper(a, arg); \ Py_DECREF(arg); \ return result; \ } #define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \ PyObject *tuple, *resultobj; \ int result; \ tuple = PyTuple_New(2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 1, c); \ Py_XINCREF(c); \ resultobj = wrapper(a, tuple); \ result = resultobj ? 0 : -1; \ Py_XDECREF(resultobj); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ PyObject *tuple, *resultobj; \ int result; \ tuple = PyTuple_New(c ? 2 : 1); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, b); \ Py_XINCREF(b); \ if (c) { \ PyTuple_SET_ITEM(tuple, 1, c); \ Py_XINCREF(c); \ } \ resultobj = wrapper(a, tuple); \ result = resultobj ? 0 : -1; \ Py_XDECREF(resultobj); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_REPRFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a) { \ return wrapper(a, NULL); \ } #define SWIGPY_HASHFUNC_CLOSURE(wrapper) \ SWIGINTERN long \ wrapper##_closure(PyObject *a) { \ PyObject *pyresult; \ long result; \ pyresult = wrapper(a, NULL); \ if (!pyresult || !PyLong_Check(pyresult)) \ return -1; \ result = PyLong_AsLong(pyresult); \ Py_DECREF(pyresult); \ return result; \ } #define SWIGPY_ITERNEXT_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a) { \ PyObject *result; \ result = wrapper(a, NULL); \ if (result && result == Py_None) { \ Py_DECREF(result); \ result = NULL; \ } \ return result; \ } #ifdef __cplusplus extern "C" { #endif SWIGINTERN int SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) { PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name); return -1; } SWIGINTERN void SwigPyBuiltin_BadDealloc(PyObject *pyobj) { SwigPyObject *sobj; sobj = (SwigPyObject *)pyobj; if (sobj->own) { PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", pyobj->ob_type->tp_name); } } typedef struct { PyCFunction get; PyCFunction set; } SwigPyGetSet; SWIGINTERN PyObject * SwigPyBuiltin_GetterClosure (PyObject *obj, void *closure) { SwigPyGetSet *getset; PyObject *tuple, *result; if (!closure) return SWIG_Py_Void(); getset = (SwigPyGetSet *)closure; if (!getset->get) return SWIG_Py_Void(); tuple = PyTuple_New(0); assert(tuple); result = (*getset->get)(obj, tuple); Py_DECREF(tuple); return result; } SWIGINTERN PyObject * SwigPyBuiltin_FunpackGetterClosure (PyObject *obj, void *closure) { SwigPyGetSet *getset; PyObject *result; if (!closure) return SWIG_Py_Void(); getset = (SwigPyGetSet *)closure; if (!getset->get) return SWIG_Py_Void(); result = (*getset->get)(obj, NULL); return result; } SWIGINTERN int SwigPyBuiltin_SetterClosure (PyObject *obj, PyObject *val, void *closure) { SwigPyGetSet *getset; PyObject *tuple, *result; if (!closure) { PyErr_Format(PyExc_TypeError, "Missing getset closure"); return -1; } getset = (SwigPyGetSet *)closure; if (!getset->set) { PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); return -1; } tuple = PyTuple_New(1); assert(tuple); PyTuple_SET_ITEM(tuple, 0, val); Py_XINCREF(val); result = (*getset->set)(obj, tuple); Py_DECREF(tuple); Py_XDECREF(result); return result ? 0 : -1; } SWIGINTERN int SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure) { SwigPyGetSet *getset; PyObject *result; if (!closure) { PyErr_Format(PyExc_TypeError, "Missing getset closure"); return -1; } getset = (SwigPyGetSet *)closure; if (!getset->set) { PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); return -1; } result = (*getset->set)(obj, val); Py_XDECREF(result); return result ? 0 : -1; } SWIGINTERN void SwigPyStaticVar_dealloc(PyDescrObject *descr) { _PyObject_GC_UNTRACK(descr); Py_XDECREF(PyDescr_TYPE(descr)); Py_XDECREF(PyDescr_NAME(descr)); PyObject_GC_Del(descr); } SWIGINTERN PyObject * SwigPyStaticVar_repr(PyGetSetDescrObject *descr) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromFormat("", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); #else return PyString_FromFormat("", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); #endif } SWIGINTERN int SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) { PyDescrObject *descr; descr = (PyDescrObject *)self; Py_VISIT((PyObject*) PyDescr_TYPE(descr)); return 0; } SWIGINTERN PyObject * SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNUSEDPARM(type)) { if (descr->d_getset->get != NULL) return descr->d_getset->get(obj, descr->d_getset->closure); #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); #else PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); #endif return NULL; } SWIGINTERN int SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) { if (descr->d_getset->set != NULL) return descr->d_getset->set(obj, value, descr->d_getset->closure); #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); #else PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); #endif return -1; } SWIGINTERN int SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) { PyObject *attribute; descrsetfunc local_set; attribute = _PyType_Lookup(type, name); if (attribute != NULL) { /* Implement descriptor functionality, if any */ local_set = attribute->ob_type->tp_descr_set; if (local_set != NULL) return local_set(attribute, (PyObject *)type, value); #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400S'", type->tp_name, name); #else PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name)); #endif } else { #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400S'", type->tp_name, name); #else PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name)); #endif } return -1; } SWIGINTERN PyTypeObject* SwigPyStaticVar_Type(void) { static PyTypeObject staticvar_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(&PyType_Type, 0) #else PyObject_HEAD_INIT(&PyType_Type) 0, #endif "swig_static_var_getset_descriptor", sizeof(PyGetSetDescrObject), 0, (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ (reprfunc)SwigPyStaticVar_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ 0, /* tp_doc */ SwigPyStaticVar_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc)SwigPyStaticVar_get, /* tp_descr_get */ (descrsetfunc)SwigPyStaticVar_set, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; staticvar_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 staticvar_type.ob_type = &PyType_Type; #else if (PyType_Ready(&staticvar_type) < 0) return NULL; #endif } return &staticvar_type; } SWIGINTERN PyGetSetDescrObject * SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) { PyGetSetDescrObject *descr; descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0); assert(descr); Py_XINCREF(type); PyDescr_TYPE(descr) = type; PyDescr_NAME(descr) = PyString_InternFromString(getset->name); descr->d_getset = getset; if (PyDescr_NAME(descr) == NULL) { Py_DECREF(descr); descr = NULL; } return descr; } SWIGINTERN void SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) { int base_count = 0; PyTypeObject **b; PyObject *tuple; int i; if (!bases[0]) { bases[0] = SwigPyObject_type(); bases[1] = NULL; } type->tp_base = bases[0]; Py_INCREF((PyObject *)bases[0]); for (b = bases; *b != NULL; ++b) ++base_count; tuple = PyTuple_New(base_count); for (i = 0; i < base_count; ++i) { PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]); Py_INCREF((PyObject *)bases[i]); } type->tp_bases = tuple; } SWIGINTERN PyObject * SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) { PyObject *result; result = (PyObject *)SWIG_Python_GetSwigThis(self); Py_XINCREF(result); return result; } SWIGINTERN void SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) { #if PY_VERSION_HEX >= 0x03000000 type->ob_base.ob_base.ob_type = metatype; #else type->ob_type = metatype; #endif } #ifdef __cplusplus } #endif swig-3.0.2/Lib/python/defarg.swg0000664000175000017500000000220212343605122016340 0ustar williamwilliam/* This file defines an internal function for processing default arguments with proxy classes. There seems to be no straightforward way to write proxy functions involving default arguments. For example : def foo(arg1,arg2,*args): proxyc.foo(arg1,arg2,args) This fails because args is now a tuple and SWIG doesn't know what to do with it. This file allows a different approach : def foo(arg1,arg2,*args): proxyc.__call_defarg(proxyc.foo,(arg1,arg2,)+args) Basically, we form a new tuple from the object, call this special __call_defarg method and it passes control to the real wrapper function. An ugly hack, but it works. */ SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) { PyObject *func; PyObject *parms; if (!PyArg_ParseTuple(args,"OO",&func,&parms)) return NULL; if (!PyCallable_Check(func)) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_TypeError, "__call_defarg : Need a callable object!"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } return PyEval_CallObject(func,parms); } swig-3.0.2/Lib/python/carrays.i0000664000175000017500000000164412343605122016215 0ustar williamwilliam%define %array_class(TYPE,NAME) #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "sq_item", functype="ssizeargfunc") NAME::__getitem__; %feature("python:slot", "sq_ass_item", functype="ssizeobjargproc") NAME::__setitem__; %inline %{ typedef struct { TYPE *el; } NAME; %} %extend NAME { NAME(size_t nelements) { NAME *arr = %new_instance(NAME); arr->el = %new_array(nelements, TYPE); return arr; } ~NAME() { %delete_array(self->el); %delete(self); } TYPE __getitem__(size_t index) { return self->el[index]; } void __setitem__(size_t index, TYPE value) { self->el[index] = value; } TYPE * cast() { return self->el; } static NAME *frompointer(TYPE *t) { return %reinterpret_cast(t, NAME *); } }; %types(NAME = TYPE); #else %array_class_wrap(TYPE,NAME,__getitem__,__setitem__) #endif %enddef %include swig-3.0.2/Lib/python/std_common.i0000664000175000017500000000442412343605122016712 0ustar williamwilliam%include %include /* Generate the traits for a 'primitive' type, such as 'double', for which the SWIG_AsVal and SWIG_From methods are already defined. */ %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval { typedef Type value_type; static int asval(PyObject *obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from { typedef Type value_type; static PyObject *from(const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit instantiations required using %template). The STL containers define the 'front' method and the typemap below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from required in the generated code for enums. */ %define %traits_enum(Type...) %fragment("SWIG_Traits_enum_"{Type},"header", fragment=SWIG_AsVal_frag(int), fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(PyObject *obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; template <> struct traits_from { typedef Type value_type; static PyObject *from(const value_type& val) { return SWIG_From(int)((int)val); } }; } } %typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} %enddef %include // // Generates the traits for all the known primitive // C++ types (int, double, ...) // %apply_cpptypes(%traits_ptypen); swig-3.0.2/Lib/python/std_list.i0000664000175000017500000000123412343605122016371 0ustar williamwilliam/* Lists */ %fragment("StdListTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(PyObject *obj, std::list **lis) { return traits_asptr_stdseq >::asptr(obj, lis); } }; template struct traits_from > { static PyObject *from(const std::list & vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.2/Lib/python/factory.i0000664000175000017500000000004012343605122016205 0ustar williamwilliam%include swig-3.0.2/Lib/python/std_alloc.i0000664000175000017500000000003312343605122016504 0ustar williamwilliam%include swig-3.0.2/Lib/python/exception.i0000664000175000017500000000021312343605122016536 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) } swig-3.0.2/Lib/python/pymacros.swg0000664000175000017500000000004612343605122016751 0ustar williamwilliam%include swig-3.0.2/Lib/python/std_carray.i0000664000175000017500000000305712343605122016704 0ustar williamwilliam%include %fragment("StdCarrayTraits","header",fragment="StdSequenceTraits") { namespace swig { template struct traits_asptr > { static int asptr(PyObject *obj, std::carray **array) { return traits_asptr_stdseq >::asptr(obj, array); } }; } } %warnfilter(SWIGWARN_IGNORE_OPERATOR_INDEX) std::carray::operator[]; %extend std::carray { %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header", fragment="SwigPyIterator_T", fragment=SWIG_Traits_frag(_Type), fragment="StdCarrayTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::carray<" #_Type "," #_Size " >"; } }; } } %typemaps_asptr(SWIG_TYPECHECK_VECTOR, swig::asptr, SWIG_Traits_frag(std::carray<_Type, _Size >), std::carray<_Type, _Size >); %typemap(out,noblock=1) iterator, const_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); } inline size_t __len__() const { return self->size(); } inline const _Type& __getitem__(size_t i) const { return (*self)[i]; } inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; } swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } %include swig-3.0.2/Lib/python/cwstring.i0000664000175000017500000000007412343605122016405 0ustar williamwilliam%include %include swig-3.0.2/Lib/python/complex.i0000664000175000017500000000012012343605122016204 0ustar williamwilliam#ifdef __cplusplus %include #else %include #endif swig-3.0.2/Lib/python/std_set.i0000664000175000017500000000272212343605122016214 0ustar williamwilliam/* Sets */ %fragment("StdSetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::set* seq) { // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(PyObject *obj, std::set **s) { return traits_asptr_stdseq >::asptr(obj, s); } }; template struct traits_from > { static PyObject *from(const std::set& vec) { return traits_from_stdseq >::from(vec); } }; } %} %define %swig_set_methods(set...) %swig_sequence_iterator(set); %swig_container_methods(set); %extend { void append(value_type x) { self->insert(x); } bool __contains__(value_type x) { return self->find(x) != self->end(); } value_type __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void add(value_type x) { self->insert(x); } void discard(value_type x) { self->erase(x); } }; %enddef %include swig-3.0.2/Lib/python/pythreads.swg0000664000175000017500000000546012343605122017124 0ustar williamwilliam#if defined(SWIG_PYTHON_NO_THREADS) # if defined(SWIG_PYTHON_THREADS) # undef SWIG_PYTHON_THREADS # endif #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) # if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ # define SWIG_PYTHON_USE_GIL # endif # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() # endif # ifdef __cplusplus /* C++ code */ class SWIG_Python_Thread_Block { bool status; PyGILState_STATE state; public: void end() { if (status) { PyGILState_Release(state); status = false;} } SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} ~SWIG_Python_Thread_Block() { end(); } }; class SWIG_Python_Thread_Allow { bool status; PyThreadState *save; public: void end() { if (status) { PyEval_RestoreThread(save); status = false; }} SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} ~SWIG_Python_Thread_Allow() { end(); } }; # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow # define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() # else /* C code */ # define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() # define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() # define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) # endif # else /* Old thread way, not implemented, user must provide it */ # if !defined(SWIG_PYTHON_INITIALIZE_THREADS) # define SWIG_PYTHON_INITIALIZE_THREADS # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_END_BLOCK) # define SWIG_PYTHON_THREAD_END_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # endif # if !defined(SWIG_PYTHON_THREAD_END_ALLOW) # define SWIG_PYTHON_THREAD_END_ALLOW # endif # endif #else /* No thread support */ # define SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # define SWIG_PYTHON_THREAD_END_BLOCK # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # define SWIG_PYTHON_THREAD_END_ALLOW #endif swig-3.0.2/Lib/python/std_wiostream.i0000664000175000017500000000024612343605122017432 0ustar williamwilliamnamespace std { %callback(1) wendl; %callback(1) wends; %callback(1) wflush; } %include %include %include swig-3.0.2/Lib/python/file.i0000664000175000017500000000201312343605122015457 0ustar williamwilliam/* ----------------------------------------------------------------------------- * file.i * * Typemaps for FILE* * ----------------------------------------------------------------------------- */ %types(FILE *); /* defining basic methods */ %fragment("SWIG_AsValFilePtr","header") { SWIGINTERN int SWIG_AsValFilePtr(PyObject *obj, FILE **val) { static swig_type_info* desc = 0; void *vptr = 0; if (!desc) desc = SWIG_TypeQuery("FILE *"); if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) { if (val) *val = (FILE *)vptr; return SWIG_OK; } %#if PY_VERSION_HEX < 0x03000000 if (PyFile_Check(obj)) { if (val) *val = PyFile_AsFile(obj); return SWIG_OK; } %#endif return SWIG_TypeError; } } %fragment("SWIG_AsFilePtr","header",fragment="SWIG_AsValFilePtr") { SWIGINTERNINLINE FILE* SWIG_AsFilePtr(PyObject *obj) { FILE *val = 0; SWIG_AsValFilePtr(obj, &val); return val; } } /* defining the typemaps */ %typemaps_asval(%checkcode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*); swig-3.0.2/Lib/python/embed.i0000664000175000017500000000521712343605122015625 0ustar williamwilliam// // embed.i // SWIG file embedding the Python interpreter in something else. // This file is based on Python-1.5. It will not work with // earlier versions. // // This file makes it possible to extend Python and all of its // built-in functions without having to hack its setup script. // #ifdef AUTODOC %subsection "embed.i" %text %{ This module provides support for building a new version of the Python executable. This will be necessary on systems that do not support shared libraries and may be necessary with C++ extensions. This file contains everything you need to build a new version of Python from include files and libraries normally installed with the Python language. This module will automatically grab all of the Python modules present in your current Python executable (including any special purpose modules you have enabled such as Tkinter). Thus, you may need to provide additional link libraries when compiling. This library file only works with Python 1.5. A version compatible with Python 1.4 is available as embed14.i and a Python1.3 version is available as embed13.i. As far as I know, this module is C++ safe. %} #else %echo "embed.i : Using Python 1.5" #endif %wrapper %{ #include #ifdef __cplusplus extern "C" #endif void SWIG_init(); /* Forward reference */ #define _PyImport_Inittab swig_inittab /* Grab Python's inittab[] structure */ #ifdef __cplusplus extern "C" { #endif #include #undef _PyImport_Inittab /* Now define our own version of it. Hopefully someone does not have more than 1000 built-in modules */ struct _inittab SWIG_Import_Inittab[1000]; static int swig_num_modules = 0; /* Function for adding modules to Python */ static void swig_add_module(char *name, void (*initfunc)()) { SWIG_Import_Inittab[swig_num_modules].name = name; SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; swig_num_modules++; SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; SWIG_Import_Inittab[swig_num_modules].initfunc = 0; } /* Function to add all of Python's build in modules to our interpreter */ static void swig_add_builtin() { int i = 0; while (swig_inittab[i].name) { swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); i++; } #ifdef SWIGMODINIT SWIGMODINIT #endif /* Add SWIG builtin function */ swig_add_module(SWIG_name, SWIG_init); } #ifdef __cplusplus } #endif #ifdef __cplusplus extern "C" { #endif extern int Py_Main(int, char **); #ifdef __cplusplus } #endif extern struct _inittab *PyImport_Inittab; int main(int argc, char **argv) { swig_add_builtin(); PyImport_Inittab = SWIG_Import_Inittab; return Py_Main(argc,argv); } %} swig-3.0.2/Lib/python/std_multimap.i0000664000175000017500000000470112343605122017250 0ustar williamwilliam/* Multimaps */ %include %fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::multimap *multimap) { typedef typename std::multimap::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { multimap->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::multimap multimap_type; static int asptr(PyObject *obj, std::multimap **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { multimap_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::multimap multimap_type; typedef typename multimap_type::const_iterator const_iterator; typedef typename multimap_type::size_type size_type; static PyObject *from(const multimap_type& multimap) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_InternalNewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); } else { size_type size = multimap.size(); int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "multimap size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; } } }; } } %define %swig_multimap_methods(Type...) %swig_map_common(Type); %extend { void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { self->insert(Type::value_type(key,x)); } } %enddef %include swig-3.0.2/Lib/python/pyopers.swg0000664000175000017500000002162712343605122016625 0ustar williamwilliam/* ------------------------------------------------------------ * Overloaded operator support The directives in this file apply whether or not you use the -builtin option to SWIG, but operator overloads are particularly attractive when using -builtin, because they are much faster than named methods. If you're using the -builtin option to SWIG, and you want to define python operator overloads beyond the defaults defined in this file, here's what you need to know: There are two ways to define a python slot function: dispatch to a statically defined function; or dispatch to a method defined on the operand. To dispatch to a statically defined function, use %feature("python:"), where is the name of a field in a PyTypeObject, PyNumberMethods, PyMappingMethods, PySequenceMethods, or PyBufferProcs. For example: %{ static long myHashFunc (PyObject *pyobj) { MyClass *cobj; // Convert pyobj to cobj return (cobj->field1 * (cobj->field2 << 7)); } %} %feature("python:tp_hash") MyClass "myHashFunc"; NOTE: It is the responsibility of the programmer (that's you) to ensure that a statically defined slot function has the correct signature. If, instead, you want to dispatch to an instance method, you can use %feature("python:slot"). For example: class MyClass { public: long myHashFunc () const; ... }; %feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc; NOTE: Some python slots use a method signature which does not match the signature of SWIG-wrapped methods. For those slots, SWIG will automatically generate a "closure" function to re-marshall the arguments before dispatching to the wrapped method. Setting the "functype" attribute of the feature enables SWIG to generate a correct closure function. -------------------------------------------------------------- The tp_richcompare slot is a special case: SWIG automatically generates a rich compare function for all wrapped types. If a type defines C++ operator overloads for comparison (operator==, operator<, etc.), they will be called from the generated rich compare function. If you want to explicitly choose a method to handle a certain comparison operation, you may use %feature("python:slot") like this: class MyClass { public: bool lessThan (const MyClass& x) const; ... }; %feature("python:slot", "Py_LT") MyClass::lessThan; ... where "Py_LT" is one of the rich comparison opcodes defined in the python header file object.h. If there's no method defined to handle a particular comparsion operation, the default behavior is to compare pointer values of the wrapped C++ objects. -------------------------------------------------------------- For more information about python slots, including their names and signatures, you may refer to the python documentation : http://docs.python.org/c-api/typeobj.html * ------------------------------------------------------------ */ #ifdef __cplusplus #if defined(SWIGPYTHON_BUILTIN) #define %pybinoperator(pyname,oper,functp,slt) %rename(pyname) oper; %pythonmaybecall oper; %feature("python:slot", #slt, functype=#functp) oper; %feature("python:slot", #slt, functype=#functp) pyname; #define %pycompare(pyname,oper,comptype) %rename(pyname) oper; %pythonmaybecall oper; %feature("python:compare", #comptype) oper; %feature("python:compare", #comptype) pyname; #else #define %pybinoperator(pyname,oper,functp,slt) %rename(pyname) oper; %pythonmaybecall oper #define %pycompare(pyname,oper,comptype) %pybinoperator(pyname,oper,,comptype) #endif %pybinoperator(__add__, *::operator+, binaryfunc, nb_add); %pybinoperator(__pos__, *::operator+(), unaryfunc, nb_positive); %pybinoperator(__pos__, *::operator+() const, unaryfunc, nb_positive); %pybinoperator(__sub__, *::operator-, binaryfunc, nb_subtract); %pybinoperator(__neg__, *::operator-(), unaryfunc, nb_negative); %pybinoperator(__neg__, *::operator-() const, unaryfunc, nb_negative); %pybinoperator(__mul__, *::operator*, binaryfunc, nb_multiply); %pybinoperator(__div__, *::operator/, binaryfunc, nb_div); %pybinoperator(__mod__, *::operator%, binaryfunc, nb_remainder); %pybinoperator(__lshift__, *::operator<<, binaryfunc, nb_lshift); %pybinoperator(__rshift__, *::operator>>, binaryfunc, nb_rshift); %pybinoperator(__and__, *::operator&, binaryfunc, nb_and); %pybinoperator(__or__, *::operator|, binaryfunc, nb_or); %pybinoperator(__xor__, *::operator^, binaryfunc, nb_xor); %pycompare(__lt__, *::operator<, Py_LT); %pycompare(__le__, *::operator<=, Py_LE); %pycompare(__gt__, *::operator>, Py_GT); %pycompare(__ge__, *::operator>=, Py_GE); %pycompare(__eq__, *::operator==, Py_EQ); %pycompare(__ne__, *::operator!=, Py_NE); %feature("python:slot", "nb_truediv", functype="binaryfunc") *::operator/; /* Special cases */ %rename(__invert__) *::operator~; %feature("python:slot", "nb_invert", functype="unaryfunc") *::operator~; %rename(__call__) *::operator(); %feature("python:slot", "tp_call", functype="ternarycallfunc") *::operator(); #if defined(SWIGPYTHON_BUILTIN) %pybinoperator(__nonzero__, *::operator bool, inquiry, nb_nonzero); #else %feature("shadow") *::operator bool %{ def __nonzero__(self): return $action(self) __bool__ = __nonzero__ %}; %rename(__nonzero__) *::operator bool; #endif /* Ignored operators */ %ignoreoperator(LNOT) operator!; %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; %ignoreoperator(EQ) *::operator=; %ignoreoperator(PLUSPLUS) *::operator++; %ignoreoperator(MINUSMINUS) *::operator--; %ignoreoperator(ARROWSTAR) *::operator->*; %ignoreoperator(INDEX) *::operator[]; /* Inplace operator declarations. They translate the inplace C++ operators (+=, -=, ...) into the corresponding python equivalents(__iadd__,__isub__), etc, disabling the ownership of the input 'self' pointer, and assigning it to the returning object: %feature("del") *::Operator; %feature("new") *::Operator; This makes the most common case safe, ie: A& A::operator+=(int i) { ...; return *this; } ^^^^ ^^^^^^ will work fine, even when the resulting python object shares the 'this' pointer with the input one. The input object is usually deleted after the operation, including the shared 'this' pointer, producing 'strange' seg faults, as reported by Lucriz (lucriz@sitilandia.it). If you have an interface that already takes care of that, ie, you already are using inplace operators and you are not getting seg. faults, with the new scheme you could end with 'free' elements that never get deleted (maybe, not sure, it depends). But if that is the case, you could recover the old behaviour using %feature("del","") A::operator+=; %feature("new","") A::operator+=; which recovers the old behaviour for the class 'A', or if you are 100% sure your entire system works fine in the old way, use: %feature("del","") *::operator+=; %feature("new","") *::operator+=; */ #if defined(SWIGPYTHON_BUILTIN) #define %pyinplaceoper(SwigPyOper, Oper, functp, slt) %delobject Oper; %newobject Oper; %feature("python:slot", #slt, functype=#functp) Oper; %rename(SwigPyOper) Oper #else #define %pyinplaceoper(SwigPyOper, Oper, functp, slt) %delobject Oper; %newobject Oper; %rename(SwigPyOper) Oper #endif %pyinplaceoper(__iadd__ , *::operator +=, binaryfunc, nb_inplace_add); %pyinplaceoper(__isub__ , *::operator -=, binaryfunc, nb_inplace_subtract); %pyinplaceoper(__imul__ , *::operator *=, binaryfunc, nb_inplace_multiply); %pyinplaceoper(__idiv__ , *::operator /=, binaryfunc, nb_inplace_divide); %pyinplaceoper(__imod__ , *::operator %=, binaryfunc, nb_inplace_remainder); %pyinplaceoper(__iand__ , *::operator &=, binaryfunc, nb_inplace_and); %pyinplaceoper(__ior__ , *::operator |=, binaryfunc, nb_inplace_or); %pyinplaceoper(__ixor__ , *::operator ^=, binaryfunc, nb_inplace_xor); %pyinplaceoper(__ilshift__, *::operator <<=, binaryfunc, nb_inplace_lshift); %pyinplaceoper(__irshift__, *::operator >>=, binaryfunc, nb_inplace_rshift); /* Finally, in python we need to mark the binary operations to fail as 'maybecall' methods */ #define %pybinopermaybecall(oper) %pythonmaybecall __ ## oper ## __; %pythonmaybecall __r ## oper ## __ %pybinopermaybecall(add); %pybinopermaybecall(pos); %pybinopermaybecall(pos); %pybinopermaybecall(sub); %pybinopermaybecall(neg); %pybinopermaybecall(neg); %pybinopermaybecall(mul); %pybinopermaybecall(div); %pybinopermaybecall(mod); %pybinopermaybecall(lshift); %pybinopermaybecall(rshift); %pybinopermaybecall(and); %pybinopermaybecall(or); %pybinopermaybecall(xor); %pybinopermaybecall(lt); %pybinopermaybecall(le); %pybinopermaybecall(gt); %pybinopermaybecall(ge); %pybinopermaybecall(eq); %pybinopermaybecall(ne); #endif swig-3.0.2/Lib/python/std_shared_ptr.i0000664000175000017500000000010412343605122017544 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.2/Lib/python/pywstrings.swg0000664000175000017500000000377312343605122017357 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for wchar_t strings * ------------------------------------------------------------ */ %{ #if PY_VERSION_HEX >= 0x03020000 # define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj)) #else # define SWIGPY_UNICODE_ARG(obj) ((PyUnicodeObject*) (obj)) #endif %} %fragment("SWIG_AsWCharPtrAndSize","header",fragment="",fragment="SWIG_pwchar_descriptor") { SWIGINTERN int SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) { PyObject *tmp = 0; int isunicode = PyUnicode_Check(obj); %#if PY_VERSION_HEX < 0x03000000 if (!isunicode && PyString_Check(obj)) { obj = tmp = PyUnicode_FromObject(obj); isunicode = 1; } %#endif if (isunicode) { Py_ssize_t len = PyUnicode_GetSize(obj); if (cptr) { *cptr = %new_array(len + 1, wchar_t); PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), *cptr, len); (*cptr)[len] = 0; } if (psize) *psize = (size_t) len + 1; if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0; Py_XDECREF(tmp); return SWIG_OK; } else { swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); if (pwchar_descriptor) { void * vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (wchar_t *)vptr; if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0; return SWIG_OK; } } } return SWIG_TypeError; } } %fragment("SWIG_FromWCharPtrAndSize","header",fragment="",fragment="SWIG_pwchar_descriptor") { SWIGINTERNINLINE PyObject * SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size) { if (carray) { if (size > INT_MAX) { swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); return pwchar_descriptor ? SWIG_InternalNewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : SWIG_Py_Void(); } else { return PyUnicode_FromWideChar(carray, %numeric_cast(size,int)); } } else { return SWIG_Py_Void(); } } } swig-3.0.2/Lib/python/std_ios.i0000664000175000017500000000010212343605122016201 0ustar williamwilliam%rename(ios_base_in) std::ios_base::in; %include swig-3.0.2/Lib/python/std_auto_ptr.i0000664000175000017500000000111112343605122017245 0ustar williamwilliam/* The typemaps here allow to handle functions returning std::auto_ptr<>, which is the most common use of this type. If you have functions taking it as parameter, these typemaps can't be used for them and you need to do something else (e.g. use shared_ptr<> which SWIG supports fully). */ %define %auto_ptr(TYPE) %typemap (out) std::auto_ptr %{ %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags)); %} %template() std::auto_ptr; %enddef namespace std { template class auto_ptr {}; } swig-3.0.2/Lib/python/pyname_compat.i0000664000175000017500000001003412343605122017376 0ustar williamwilliam/* * From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, * since they are inappropriate and discouraged in Python documentation * (from http://www.python.org/doc/2.5.2/api/includes.html): * * "All user visible names defined by Python.h (except those defined by the included * standard headers) have one of the prefixes "Py" or "_Py". Names beginning with * "_Py" are for internal use by the Python implementation and should not be used * by extension writers. Structure member names do not have a reserved prefix. * * Important: user code should never define names that begin with "Py" or "_Py". * This confuses the reader, and jeopardizes the portability of the user code to * future Python versions, which may define additional names beginning with one * of these prefixes." * * This file defined macros to provide backward compatibility for these deprecated * symbols. In the case you have these symbols in your interface file, you can simply * include this file at beginning of it. * * However, this file may be removed in future release of SWIG, so using this file to * keep these inappropriate names in your SWIG interface file is also not recommended. * Instead, we provide a simple tool for converting your interface files to * the new naming convention. You can get the tool from the SWIG distribution: * Tools/pyname_patch.py */ %fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {} %fragment("PySequence_Cont", "header", fragment="SwigPySequence_Cont") {} %fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} %fragment("PyPairBoolOutputIterator", "header", fragment="SwigPyPairBoolOutputIterator") {} %fragment("PySwigIterator", "header", fragment="SwigPyIterator") {} %fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} %inline %{ #define PyMapIterator_T SwigPyMapIterator_T #define PyMapKeyIterator_T SwigPyMapKeyIterator_T #define PyMapValueIterator_T SwigPyMapValueITerator_T #define PyObject_ptr SwigPtr_PyObject #define PyObject_var SwigVar_PyObject #define PyOper SwigPyOper #define PySeq SwigPySeq #define PySequence_ArrowProxy SwigPySequence_ArrowProxy #define PySequence_Cont SwigPySequence_Cont #define PySequence_InputIterator SwigPySequence_InputIterator #define PySequence_Ref SwigPySequence_Ref #define PySwigClientData SwigPyClientData #define PySwigClientData_Del SwigPyClientData_Del #define PySwigClientData_New SwigPyClientData_New #define PySwigIterator SwigPyIterator #define PySwigIteratorClosed_T SwigPyIteratorClosed_T #define PySwigIteratorOpen_T SwigPyIteratorOpen_T #define PySwigIterator_T SwigPyIterator_T #define PySwigObject SwigPyObject #define PySwigObject_Check SwigPyObject_Check #define PySwigObject_GetDesc SwigPyObject_GetDesc #define PySwigObject_New SwigPyObject_New #define PySwigObject_acquire SwigPyObject_acquire #define PySwigObject_append SwigPyObject_append #define PySwigObject_as_number SwigPyObject_as_number #define PySwigObject_compare SwigPyObject_compare #define PySwigObject_dealloc SwigPyObject_dealloc #define PySwigObject_disown SwigPyObject_disown #define PySwigObject_format SwigPyObject_format #define PySwigObject_getattr SwigPyObject_getattr #define PySwigObject_hex SwigPyObject_hex #define PySwigObject_long SwigPyObject_long #define PySwigObject_next SwigPyObject_next #define PySwigObject_oct SwigPyObject_oct #define PySwigObject_own SwigPyObject_own #define PySwigObject_repr SwigPyObject_repr #define PySwigObject_richcompare SwigPyObject_richcompare #define PySwigObject_type SwigPyObject_type #define PySwigPacked SwigPyPacked #define PySwigPacked_Check SwigPyPacked_Check #define PySwigPacked_New SwigPyPacked_New #define PySwigPacked_UnpackData SwigPyPacked_UnpackData #define PySwigPacked_compare SwigPyPacked_compare #define PySwigPacked_dealloc SwigPyPacked_dealloc #define PySwigPacked_print SwigPyPacked_print #define PySwigPacked_repr SwigPyPacked_repr #define PySwigPacked_str SwigPyPacked_str #define PySwigPacked_type SwigPyPacked_type #define pyseq swigpyseq #define pyswigobject_type swigpyobject_type #define pyswigpacked_type swigpypacked_type %} swig-3.0.2/Lib/python/std_vector.i0000664000175000017500000000126312343605122016722 0ustar williamwilliam/* Vectors */ %fragment("StdVectorTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(PyObject *obj, std::vector **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static PyObject *from(const std::vector& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.2/Lib/python/pybackward.swg0000664000175000017500000000221212343605122017240 0ustar williamwilliam/* adding backward compatibility macros */ #define SWIG_arg(x...) %arg(x) #define SWIG_Mangle(x...) %mangle(x) #define SWIG_As_frag(Type...) %fragment_name(As, Type) #define SWIG_As_name(Type...) %symbol_name(As, Type) #define SWIG_As(Type...) SWIG_As_name(Type) SWIG_AS_CALL_ARGS #define SWIG_Check_frag(Type...) %fragment_name(Check, Type) #define SWIG_Check_name(Type...) %symbol_name(Check, Type) #define SWIG_Check(Type...) SWIG_Check_name(Type) SWIG_AS_CALL_ARGS %define %ascheck_methods(Code, Type...) %fragment(SWIG_As_frag(Type),"header", fragment=SWIG_AsVal_frag(Type)) { SWIGINTERNINLINE Type SWIG_As(Type)(PyObject* obj) { Type v; int res = SWIG_AsVal(Type)(obj, &v); if (!SWIG_IsOK(res)) { /* this is needed to make valgrind/purify happier. */ memset((void*)&v, 0, sizeof(Type)); SWIG_Error(res, ""); } return v; } } %fragment(SWIG_Check_frag(Type),"header",fragment=SWIG_AsVal_frag(Type)) { SWIGINTERNINLINE int SWIG_Check(Type)(PyObject* obj) { int res = SWIG_AsVal(Type)(obj, (Type*)0); return SWIG_IsOK(res); } } %enddef %apply_checkctypes(%ascheck_methods) swig-3.0.2/Lib/python/std_string.i0000664000175000017500000000004312343605122016721 0ustar williamwilliam%include swig-3.0.2/Lib/python/pyiterators.swg0000664000175000017500000002462412343605122017511 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pyiterators.swg * * Implement a python 'output' iterator for Python 2.2 or higher. * * Users can derive form the SwigPyIterator to implement their * own iterators. As an example (real one since we use it for STL/STD * containers), the template SwigPyIterator_T does the * implementation for generic C++ iterators. * ----------------------------------------------------------------------------- */ %include %fragment("SwigPyIterator","header",fragment="") { namespace swig { struct stop_iteration { }; struct SwigPyIterator { private: SwigPtr_PyObject _seq; protected: SwigPyIterator(PyObject *seq) : _seq(seq) { } public: virtual ~SwigPyIterator() {} // Access iterator method, required by Python virtual PyObject *value() const = 0; // Forward iterator method, required by Python virtual SwigPyIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python virtual SwigPyIterator *decr(size_t /*n*/ = 1) { throw stop_iteration(); } // Random access iterator methods, but not required in Python virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } virtual bool equal (const SwigPyIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } // C++ common/needed methods virtual SwigPyIterator *copy() const = 0; PyObject *next() { SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads PyObject *obj = value(); incr(); SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads return obj; } /* Make an alias for Python 3.x */ PyObject *__next__() { return next(); } PyObject *previous() { SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads decr(); PyObject *obj = value(); SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads return obj; } SwigPyIterator *advance(ptrdiff_t n) { return (n > 0) ? incr(n) : decr(-n); } bool operator == (const SwigPyIterator& x) const { return equal(x); } bool operator != (const SwigPyIterator& x) const { return ! operator==(x); } SwigPyIterator& operator += (ptrdiff_t n) { return *advance(n); } SwigPyIterator& operator -= (ptrdiff_t n) { return *advance(-n); } SwigPyIterator* operator + (ptrdiff_t n) const { return copy()->advance(n); } SwigPyIterator* operator - (ptrdiff_t n) const { return copy()->advance(-n); } ptrdiff_t operator - (const SwigPyIterator& x) const { return x.distance(*this); } static swig_type_info* descriptor() { static int init = 0; static swig_type_info* desc = 0; if (!init) { desc = SWIG_TypeQuery("swig::SwigPyIterator *"); init = 1; } return desc; } }; %#if defined(SWIGPYTHON_BUILTIN) inline PyObject* make_output_iterator_builtin (PyObject *pyself) { Py_INCREF(pyself); return pyself; } %#endif } } %fragment("SwigPyIterator_T","header",fragment="",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") { namespace swig { template class SwigPyIterator_T : public SwigPyIterator { public: typedef OutIterator out_iterator; typedef typename std::iterator_traits::value_type value_type; typedef SwigPyIterator_T self_type; SwigPyIterator_T(out_iterator curr, PyObject *seq) : SwigPyIterator(seq), current(curr) { } const out_iterator& get_current() const { return current; } bool equal (const SwigPyIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return (current == iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } ptrdiff_t distance(const SwigPyIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return std::distance(current, iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } protected: out_iterator current; }; template struct from_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v); } }; template::value_type, typename FromOper = from_oper > class SwigPyIteratorOpen_T : public SwigPyIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef SwigPyIterator_T base; typedef SwigPyIteratorOpen_T self_type; SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq) : SwigPyIterator_T(curr, seq) { } PyObject *value() const { return from(static_cast(*(base::current))); } SwigPyIterator *copy() const { return new self_type(*this); } SwigPyIterator *incr(size_t n = 1) { while (n--) { ++base::current; } return this; } SwigPyIterator *decr(size_t n = 1) { while (n--) { --base::current; } return this; } }; template::value_type, typename FromOper = from_oper > class SwigPyIteratorClosed_T : public SwigPyIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef SwigPyIterator_T base; typedef SwigPyIteratorClosed_T self_type; SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) : SwigPyIterator_T(curr, seq), begin(first), end(last) { } PyObject *value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } SwigPyIterator *copy() const { return new self_type(*this); } SwigPyIterator *incr(size_t n = 1) { while (n--) { if (base::current == end) { throw stop_iteration(); } else { ++base::current; } } return this; } SwigPyIterator *decr(size_t n = 1) { while (n--) { if (base::current == begin) { throw stop_iteration(); } else { --base::current; } } return this; } private: out_iterator begin; out_iterator end; }; template inline SwigPyIterator* make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0) { return new SwigPyIteratorClosed_T(current, begin, end, seq); } template inline SwigPyIterator* make_output_iterator(const OutIter& current, PyObject *seq = 0) { return new SwigPyIteratorOpen_T(current, seq); } } } %fragment("SwigPyIterator"); namespace swig { /* Throw a StopIteration exception */ %ignore stop_iteration; struct stop_iteration {}; %typemap(throws) stop_iteration { (void)$1; SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void()); SWIG_fail; } /* Mark methods that return new objects */ %newobject SwigPyIterator::copy; %newobject SwigPyIterator::operator + (ptrdiff_t n) const; %newobject SwigPyIterator::operator - (ptrdiff_t n) const; %nodirector SwigPyIterator; #if defined(SWIGPYTHON_BUILTIN) %feature("python:tp_iter") SwigPyIterator "&swig::make_output_iterator_builtin"; %feature("python:slot", "tp_iternext", functype="iternextfunc") SwigPyIterator::__next__; #else %extend SwigPyIterator { %pythoncode {def __iter__(self): return self} } #endif %catches(swig::stop_iteration) SwigPyIterator::value() const; %catches(swig::stop_iteration) SwigPyIterator::incr(size_t n = 1); %catches(swig::stop_iteration) SwigPyIterator::decr(size_t n = 1); %catches(std::invalid_argument) SwigPyIterator::distance(const SwigPyIterator &x) const; %catches(std::invalid_argument) SwigPyIterator::equal (const SwigPyIterator &x) const; %catches(swig::stop_iteration) SwigPyIterator::__next__(); %catches(swig::stop_iteration) SwigPyIterator::next(); %catches(swig::stop_iteration) SwigPyIterator::previous(); %catches(swig::stop_iteration) SwigPyIterator::advance(ptrdiff_t n); %catches(swig::stop_iteration) SwigPyIterator::operator += (ptrdiff_t n); %catches(swig::stop_iteration) SwigPyIterator::operator -= (ptrdiff_t n); %catches(swig::stop_iteration) SwigPyIterator::operator + (ptrdiff_t n) const; %catches(swig::stop_iteration) SwigPyIterator::operator - (ptrdiff_t n) const; struct SwigPyIterator { protected: SwigPyIterator(PyObject *seq); public: virtual ~SwigPyIterator(); // Access iterator method, required by Python virtual PyObject *value() const = 0; // Forward iterator method, required by Python virtual SwigPyIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python virtual SwigPyIterator *decr(size_t n = 1); // Random access iterator methods, but not required in Python virtual ptrdiff_t distance(const SwigPyIterator &x) const; virtual bool equal (const SwigPyIterator &x) const; // C++ common/needed methods virtual SwigPyIterator *copy() const = 0; PyObject *next(); PyObject *__next__(); PyObject *previous(); SwigPyIterator *advance(ptrdiff_t n); bool operator == (const SwigPyIterator& x) const; bool operator != (const SwigPyIterator& x) const; SwigPyIterator& operator += (ptrdiff_t n); SwigPyIterator& operator -= (ptrdiff_t n); SwigPyIterator* operator + (ptrdiff_t n) const; SwigPyIterator* operator - (ptrdiff_t n) const; ptrdiff_t operator - (const SwigPyIterator& x) const; }; } swig-3.0.2/Lib/python/pyabc.i0000664000175000017500000000064112343605122015643 0ustar williamwilliam%define %pythonabc(Type, Abc) %feature("python:abc", #Abc) Type; %enddef %pythoncode {import collections}; %pythonabc(std::vector, collections.MutableSequence); %pythonabc(std::list, collections.MutableSequence); %pythonabc(std::map, collections.MutableMapping); %pythonabc(std::multimap, collections.MutableMapping); %pythonabc(std::set, collections.MutableSet); %pythonabc(std::multiset, collections.MutableSet); swig-3.0.2/Lib/python/std_basic_string.i0000664000175000017500000000540112343605122020065 0ustar williamwilliam#if !defined(SWIG_STD_STRING) #define SWIG_STD_BASIC_STRING %include #define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(PyObject* obj, std::string **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::string *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { PyErr_Clear(); char* buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::string(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } else { PyErr_Clear(); } if (val) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_TypeError,"a string is expected"); SWIG_PYTHON_THREAD_END_BLOCK; } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE PyObject* SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } %include %typemaps_asptrfromn(%checkcode(STRING), std::basic_string); #endif #if !defined(SWIG_STD_WSTRING) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsWCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(PyObject* obj, std::wstring **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::wstring *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { PyErr_Clear(); wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::wstring(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } else { PyErr_Clear(); } if (val) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_TypeError,"a wstring is expected"); SWIG_PYTHON_THREAD_END_BLOCK; } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromWCharPtrAndSize") { SWIGINTERNINLINE PyObject* SWIG_From(std::basic_string)(const std::wstring& s) { return SWIG_FromWCharPtrAndSize(s.data(), s.size()); } } %typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string); #endif swig-3.0.2/Lib/python/std_except.i0000664000175000017500000000004312343605122016703 0ustar williamwilliam%include swig-3.0.2/Lib/python/pyinit.swg0000664000175000017500000003212312343605122016431 0ustar williamwilliam/* ------------------------------------------------------------ * The start of the Python initialization function * ------------------------------------------------------------ */ %insert(init) "swiginit.swg" #if defined(SWIGPYTHON_BUILTIN) %fragment(""); // For offsetof #endif %init %{ #ifdef __cplusplus extern "C" { #endif /* Python-specific SWIG API */ #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(void); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; SWIGINTERN PyObject * swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_InternFromString(""); #else return PyString_FromString(""); #endif } SWIGINTERN PyObject * swig_varlink_str(swig_varlinkobject *v) { #if PY_VERSION_HEX >= 0x03000000 PyObject *str = PyUnicode_InternFromString("("); PyObject *tail; PyObject *joined; swig_globalvar *var; for (var = v->vars; var; var=var->next) { tail = PyUnicode_FromString(var->name); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; if (var->next) { tail = PyUnicode_InternFromString(", "); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; } } tail = PyUnicode_InternFromString(")"); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; #else PyObject *str = PyString_FromString("("); swig_globalvar *var; for (var = v->vars; var; var=var->next) { PyString_ConcatAndDel(&str,PyString_FromString(var->name)); if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); } PyString_ConcatAndDel(&str,PyString_FromString(")")); #endif return str; } SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char *tmp; PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(str); return 0; } SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; while (var) { swig_globalvar *n = var->next; free(var->name); free(var); var = n; } } SWIGINTERN PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { PyObject *res = NULL; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->get_attr)(); break; } var = var->next; } if (res == NULL && !PyErr_Occurred()) { PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } SWIGINTERN int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { int res = 1; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->set_attr)(p); break; } var = var->next; } if (res == 1 && !PyErr_Occurred()) { PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } SWIGINTERN PyTypeObject* swig_varlink_type(void) { static char varlink__doc__[] = "Swig var link object"; static PyTypeObject varlink_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"swigvarlink", /* tp_name */ sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ (printfunc) swig_varlink_print, /* tp_print */ (getattrfunc) swig_varlink_getattr, /* tp_getattr */ (setattrfunc) swig_varlink_setattr, /* tp_setattr */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ (reprfunc) swig_varlink_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ varlink__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; varlink_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 varlink_type.ob_type = &PyType_Type; #else if (PyType_Ready(&varlink_type) < 0) return NULL; #endif } return &varlink_type; } /* Create a variable linking object for use later */ SWIGINTERN PyObject * SWIG_Python_newvarlink(void) { swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); if (result) { result->vars = 0; } return ((PyObject*) result); } SWIGINTERN void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v = (swig_varlinkobject *) p; swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); if (gv) { size_t size = strlen(name)+1; gv->name = (char *)malloc(size); if (gv->name) { strncpy(gv->name,name,size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; } } v->vars = gv; } SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; } /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ SWIGINTERN void SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { PyObject *obj = 0; size_t i; for (i = 0; constants[i].type; ++i) { switch(constants[i].type) { case SWIG_PY_POINTER: obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d, constants[i].name, obj); Py_DECREF(obj); } } } /* -----------------------------------------------------------------------------*/ /* Fix SwigMethods to carry the callback ptrs when needed */ /* -----------------------------------------------------------------------------*/ SWIGINTERN void SWIG_Python_FixMethods(PyMethodDef *methods, swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { const char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; const char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { ci = &(const_table[j]); break; } } if (ci) { void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; if (ptr) { size_t shift = (ci->ptype) - types; swig_type_info *ty = types_initial[shift]; size_t ldoc = (c - methods[i].ml_doc); size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; char *ndoc = (char*)malloc(ldoc + lptr + 10); if (ndoc) { char *buff = ndoc; strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; } } } } } } #ifdef __cplusplus } #endif /* -----------------------------------------------------------------------------* * Partial Init method * -----------------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" #endif SWIGEXPORT #if PY_VERSION_HEX >= 0x03000000 PyObject* #else void #endif SWIG_init(void) { PyObject *m, *d, *md; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { # if PY_VERSION_HEX >= 0x03020000 PyModuleDef_HEAD_INIT, # else { PyObject_HEAD_INIT(NULL) NULL, /* m_init */ 0, /* m_index */ NULL, /* m_copy */ }, # endif (char *) SWIG_name, NULL, -1, SwigMethods, NULL, NULL, NULL, NULL }; #endif #if defined(SWIGPYTHON_BUILTIN) static SwigPyClientData SwigPyObject_clientdata = {0, 0, 0, 0, 0, 0, 0}; static PyGetSetDef this_getset_def = { (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL }; static SwigPyGetSet thisown_getset_closure = { (PyCFunction) SwigPyObject_own, (PyCFunction) SwigPyObject_own }; static PyGetSetDef thisown_getset_def = { (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure }; PyObject *metatype_args; PyTypeObject *builtin_pytype; int builtin_base_count; swig_type_info *builtin_basetype; PyObject *tuple; PyGetSetDescrObject *static_getset; PyTypeObject *metatype; SwigPyClientData *cd; PyObject *public_interface, *public_symbol; PyObject *this_descr; PyObject *thisown_descr; int i; (void)builtin_pytype; (void)builtin_base_count; (void)builtin_basetype; (void)tuple; (void)static_getset; /* metatype is used to implement static member variables. */ metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); assert(metatype_args); metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL); assert(metatype); Py_DECREF(metatype_args); metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; assert(PyType_Ready(metatype) >= 0); #endif /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); #if PY_VERSION_HEX >= 0x03000000 m = PyModule_Create(&SWIG_module); #else m = Py_InitModule((char *) SWIG_name, SwigMethods); #endif md = d = PyModule_GetDict(m); (void)md; SWIG_InitializeModule(0); #ifdef SWIGPYTHON_BUILTIN SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); assert(SwigPyObject_stype); cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; if (!cd) { SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce(); } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) { PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); # if PY_VERSION_HEX >= 0x03000000 return NULL; # else return; # endif } /* All objects have a 'this' attribute */ this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); (void)this_descr; /* All objects have a 'thisown' attribute */ thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); (void)thisown_descr; public_interface = PyList_New(0); public_symbol = 0; (void)public_symbol; PyDict_SetItemString(md, "__all__", public_interface); Py_DECREF(public_interface); for (i = 0; SwigMethods[i].ml_name != NULL; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); for (i = 0; swig_const_table[i].name != 0; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); #endif SWIG_InstallConstants(d,swig_const_table); %} swig-3.0.2/Lib/python/stl.i0000664000175000017500000000026612343605122015352 0ustar williamwilliam/* initial STL definition. extended as needed in each language */ %include %include %include %include %include swig-3.0.2/Lib/python/std_deque.i0000664000175000017500000000124612343605122016524 0ustar williamwilliam/* Deques */ %fragment("StdDequeTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(PyObject *obj, std::deque **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static PyObject *from(const std::deque & vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_deque_methods(Type...) %swig_sequence_methods(Type) #define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.2/Lib/python/pyruntime.swg0000664000175000017500000000143312343605122017151 0ustar williamwilliam%insert(runtime) %{ #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) /* Use debug wrappers with the Python release dll */ # undef _DEBUG # include # define _DEBUG #else # include #endif %} %insert(runtime) "swigrun.swg"; /* SWIG API */ %insert(runtime) "swigerrors.swg"; /* SWIG errors */ %insert(runtime) "pyhead.swg"; /* Python includes and fixes */ %insert(runtime) "pyerrors.swg"; /* Python errors */ %insert(runtime) "pythreads.swg"; /* Python thread code */ %insert(runtime) "pyapi.swg"; /* Python API */ %insert(runtime) "pyrun.swg"; /* Python run-time code */ #if defined(SWIGPYTHON_BUILTIN) %insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */ #endif swig-3.0.2/Lib/python/std_wios.i0000664000175000017500000000003212343605122016372 0ustar williamwilliam%include swig-3.0.2/Lib/python/pybuffer.i0000664000175000017500000000533612343605122016375 0ustar williamwilliam/* Implementing buffer protocol typemaps */ /* %pybuffer_mutable_binary(TYPEMAP, SIZE) * * Macro for functions accept mutable buffer pointer with a size. * This can be used for both input and output. For example: * * %pybuffer_mutable_binary(char *buff, int size); * void foo(char *buff, int size) { * for(int i=0; i swig-3.0.2/Lib/python/std_unordered_multimap.i0000664000175000017500000000534312343605122021322 0ustar williamwilliam/* Unordered Multimaps */ %include %fragment("StdUnorderedMultimapTraits","header",fragment="StdSequenceTraits") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::unordered_multimap *unordered_multimap) { typedef typename std::unordered_multimap::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { unordered_multimap->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::unordered_multimap unordered_multimap_type; static int asptr(PyObject *obj, std::unordered_multimap **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { unordered_multimap_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::unordered_multimap unordered_multimap_type; typedef typename unordered_multimap_type::const_iterator const_iterator; typedef typename unordered_multimap_type::size_type size_type; static PyObject *from(const unordered_multimap_type& unordered_multimap) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN); } else { size_type size = unordered_multimap.size(); int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_multimap size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= unordered_multimap.begin(); i!= unordered_multimap.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; } } }; } } %define %swig_unordered_multimap_methods(Type...) %swig_map_common(Type); %extend { void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { self->insert(Type::value_type(key,x)); } } %enddef %include swig-3.0.2/Lib/python/Makefile.in0000664000175000017500000000656012343605122016446 0ustar williamwilliam# --------------------------------------------------------------- # SWIG Python Makefile # # This file can be used to build various Python extensions with SWIG. # By default this file is set up for dynamic loading, but it can # be easily customized for static extensions by modifying various # portions of the file. # # SRCS = C source files # CXXSRCS = C++ source files # OBJCSRCS = Objective-C source files # OBJS = Additional .o files (compiled previously) # INTERFACE = SWIG interface file # TARGET = Name of target module or executable # # Many portions of this file were created by the SWIG configure # script and should already reflect your machine. #---------------------------------------------------------------- SRCS = CXXSRCS = OBJCSRCS = OBJS = INTERFACE = WRAPFILE = $(INTERFACE:.i=_wrap.c) WRAPOBJ = $(INTERFACE:.i=_wrap.o) TARGET = module@SO@ # Use this kind of target for dynamic loading #TARGET = mypython # Use this target for static linking prefix = @prefix@ exec_prefix = @exec_prefix@ CC = @CC@ CXX = @CXX@ OBJC = @CC@ -Wno-import # -Wno-import needed for gcc CFLAGS = INCLUDES = LIBS = # SWIG Options # SWIG = location of the SWIG executable # SWIGOPT = SWIG compiler options # SWIGCC = Compiler used to compile the wrapper file SWIG = $(exec_prefix)/bin/swig SWIGOPT = -python SWIGCC = $(CC) # SWIG Library files. Uncomment if rebuilding the Python interpreter #SWIGLIBS = -lembed.i # Rules for creating .o files from source. COBJS = $(SRCS:.c=.o) CXXOBJS = $(CXXSRCS:.cxx=.o) OBJCOBJS = $(OBJCSRCS:.m=.o) ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS) # Command that will be used to build the final extension. BUILD = $(SWIGCC) # Uncomment the following if you are using dynamic loading CCSHARED = @CCSHARED@ BUILD = @LDSHARED@ # Uncomment the following if you are using dynamic loading with C++ and # need to provide additional link libraries (this is not always required). #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc # Python installation PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@ PY_LIB = @PYLIB@ # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ # Build options BUILD_LIBS = $(LIBS) # Dynamic loading # Compilation rules for non-SWIG components .SUFFIXES: .c .cxx .m .c.o: $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< .cxx.o: $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $< .m.o: $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< # ---------------------------------------------------------------------- # Rules for building the extension # ---------------------------------------------------------------------- all: $(TARGET) # Convert the wrapper file into an object file $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE) $(WRAPFILE) : $(INTERFACE) $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) clean: rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) swig-3.0.2/Lib/python/embed15.i0000664000175000017500000000546212343605122015775 0ustar williamwilliam/* ----------------------------------------------------------------------------- * embed15.i * * SWIG file embedding the Python interpreter in something else. * This file is based on Python-1.5. It will not work with * earlier versions. * * This file makes it possible to extend Python and all of its * built-in functions without having to hack its setup script. * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %subsection "embed.i" %text %{ This module provides support for building a new version of the Python executable. This will be necessary on systems that do not support shared libraries and may be necessary with C++ extensions. This file contains everything you need to build a new version of Python from include files and libraries normally installed with the Python language. This module will automatically grab all of the Python modules present in your current Python executable (including any special purpose modules you have enabled such as Tkinter). Thus, you may need to provide additional link libraries when compiling. This library file only works with Python 1.5. A version compatible with Python 1.4 is available as embed14.i and a Python1.3 version is available as embed13.i. As far as I know, this module is C++ safe. %} #else %echo "embed.i : Using Python 1.5" #endif %wrapper %{ #include #ifdef __cplusplus extern "C" #endif void SWIG_init(); /* Forward reference */ #define _PyImport_Inittab swig_inittab /* Grab Python's inittab[] structure */ #ifdef __cplusplus extern "C" { #endif #include #undef _PyImport_Inittab /* Now define our own version of it. Hopefully someone does not have more than 1000 built-in modules */ struct _inittab SWIG_Import_Inittab[1000]; static int swig_num_modules = 0; /* Function for adding modules to Python */ static void swig_add_module(char *name, void (*initfunc)()) { SWIG_Import_Inittab[swig_num_modules].name = name; SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; swig_num_modules++; SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; SWIG_Import_Inittab[swig_num_modules].initfunc = 0; } /* Function to add all of Python's build in modules to our interpreter */ static void swig_add_builtin() { int i = 0; while (swig_inittab[i].name) { swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); i++; } #ifdef SWIGMODINIT SWIGMODINIT #endif /* Add SWIG builtin function */ swig_add_module(SWIG_name, SWIG_init); } #ifdef __cplusplus } #endif #ifdef __cplusplus extern "C" { #endif extern int Py_Main(int, char **); #ifdef __cplusplus } #endif extern struct _inittab *PyImport_Inittab; int main(int argc, char **argv) { swig_add_builtin(); PyImport_Inittab = SWIG_Import_Inittab; return Py_Main(argc,argv); } %} swig-3.0.2/Lib/python/std_sstream.i0000664000175000017500000000003512343605122017072 0ustar williamwilliam%include swig-3.0.2/Lib/python/std_wstring.i0000664000175000017500000000007712343605122017117 0ustar williamwilliam%include %include swig-3.0.2/Lib/python/pystdcommon.swg0000664000175000017500000001556412343605122017503 0ustar williamwilliam%fragment("StdTraits","header",fragment="StdTraitsCommon") { namespace swig { /* Traits that provides the from method */ template struct traits_from_ptr { static PyObject *from(Type *val, int owner = 0) { return SWIG_InternalNewPointerObj(val, type_info(), owner); } }; template struct traits_from { static PyObject *from(const Type& val) { return traits_from_ptr::from(new Type(val), 1); } }; template struct traits_from { static PyObject *from(Type* val) { return traits_from_ptr::from(val, 0); } }; template struct traits_from { static PyObject *from(const Type* val) { return traits_from_ptr::from(const_cast(val), 0); } }; template inline PyObject *from(const Type& val) { return traits_from::from(val); } template inline PyObject *from_ptr(Type* val, int owner) { return traits_from_ptr::from(val, owner); } /* Traits that provides the asval/as/check method */ template struct traits_asptr { static int asptr(PyObject *obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template inline int asptr(PyObject *obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } template struct traits_asval { static int asval(PyObject *obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); if (!SWIG_IsOK(res)) return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; if (SWIG_IsNewObj(res)){ %delete(p); res = SWIG_DelNewMask(res); } return res; } else { return SWIG_ERROR; } } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template struct traits_asval { static int asval(PyObject *obj, Type **val) { if (val) { typedef typename noconst_traits::noconst_type noconst_type; noconst_type *p = 0; int res = traits_asptr::asptr(obj, &p); if (SWIG_IsOK(res)) { *(const_cast(val)) = p; } return res; } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template inline int asval(PyObject *obj, Type *val) { return traits_asval::asval(obj, val); } template struct traits_as { static Type as(PyObject *obj, bool throw_error) { Type v; int res = asval(obj, &v); if (!obj || !SWIG_IsOK(res)) { if (!PyErr_Occurred()) { ::%type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); } return v; } }; template struct traits_as { static Type as(PyObject *obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { Type r(*v); %delete(v); return r; } else { return *v; } } else { // Uninitialized return value, no Type() constructor required. static Type *v_def = (Type*) malloc(sizeof(Type)); if (!PyErr_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); memset(v_def,0,sizeof(Type)); return *v_def; } } }; template struct traits_as { static Type* as(PyObject *obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res)) { return v; } else { if (!PyErr_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); return 0; } } }; template inline Type as(PyObject *obj, bool te = false) { return traits_as::category>::as(obj, te); } template struct traits_check { static bool check(PyObject *obj) { int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { static bool check(PyObject *obj) { int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template inline bool check(PyObject *obj) { return traits_check::category>::check(obj); } } } // // Backward compatibility // #ifdef SWIG_PYTHON_BACKWARD_COMP %fragment(""); %{ PyObject* SwigInt_FromBool(bool b) { return PyInt_FromLong(b ? 1L : 0L); } double SwigNumber_Check(PyObject* o) { return PyFloat_Check(o) || PyInt_Check(o) || PyLong_Check(o); } double SwigNumber_AsDouble(PyObject* o) { return PyFloat_Check(o) ? PyFloat_AsDouble(o) : (PyInt_Check(o) ? double(PyInt_AsLong(o)) : double(PyLong_AsLong(o))); } PyObject* SwigString_FromString(const std::string& s) { return PyString_FromStringAndSize(s.data(),s.size()); } std::string SwigString_AsString(PyObject* o) { return std::string(PyString_AsString(o)); } %} #endif %define %specialize_std_container(Type,Check,As,From) %{ namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(PyObject *obj, value_type *val) { if (Check(obj)) { if (val) *val = As(obj); return SWIG_OK; } return SWIG_ERROR; } }; template <> struct traits_from { typedef Type value_type; static PyObject *from(const value_type& val) { return From(val); } }; template <> struct traits_check { static int check(PyObject *obj) { int res = Check(obj); return obj && res ? res : 0; } }; } %} %enddef #define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_unordered_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_unordered_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) swig-3.0.2/Lib/python/std_unordered_multiset.i0000664000175000017500000000226412343605122021337 0ustar williamwilliam/* Unordered Multisets */ %include %fragment("StdUnorderedMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::unordered_multiset* seq) { // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(PyObject *obj, std::unordered_multiset **m) { return traits_asptr_stdseq >::asptr(obj, m); } }; template struct traits_from > { static PyObject *from(const std::unordered_multiset& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_unordered_multiset_methods(Set...) %swig_set_methods(Set) %include swig-3.0.2/Lib/python/pyuserdir.swg0000664000175000017500000001426712343605122017154 0ustar williamwilliam/* ------------------------------------------------------------------------- * Special user directives * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ /* shadow code */ #define %shadow %insert("shadow") #define %pythoncode %insert("python") #define %pythonbegin %insert("pythonbegin") /* ------------------------------------------------------------------------- */ /* Use the "nondynamic" feature to make a wrapped class behave as a "nondynamic" one, ie, a python class that doesn't dynamically add new attributes. For example, for the class %pythonnondynamic A; struct A { int a; int b; }; you will get: aa = A() aa.a = 1 # Ok aa.b = 1 # Ok aa.c = 3 # error Since nondynamic is a feature, if you use it like %pythonnondynamic; it will make all the wrapped classes nondynamic ones. The implementation is based on this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158 and works for modern (-modern) and plain python. We do not use __slots__, so, it works with old python versions. */ #define %pythonnondynamic %feature("python:nondynamic", "1") #define %nopythonnondynamic %feature("python:nondynamic", "0") #define %clearpythonnondynamic %feature("python:nondynamic", "") #define %pythondynamic %nopythonnondynamic /* ------------------------------------------------------------------------- */ /* Use %pythonmaybecall to flag a method like __add__ or __radd__. These don't produce an error when called, they just return NotImplemented. These methods "may be called" if needed. */ #define %pythonmaybecall %feature("python:maybecall", "1") #define %nopythonmaybecall %feature("python:maybecall", "0") #define %clearpythonmaybecall %feature("python:maybecall", "") /* ------------------------------------------------------------------------- */ /* The %pythoncallback feature produce a more natural callback wrapper than the %callback mechanism, ie, it uses the original name for the callback and callable objects. Just use it as %pythoncallback(1) foo; int foo(int a); %pythoncallback(1) A::foo; struct A { static int foo(int a); }; int bar(int, int (*pf)(int)); then, you can use it as: a = foo(1) b = bar(2, foo) c = A.foo(3) d = bar(4, A.foo) If you use it with a member method %pythoncallback(1) A::foom; struct A { int foom(int a); }; then you can use it as r = a.foom(3) # eval the method mptr = A.foom_cb_ptr # returns the callback pointer where the '_cb_ptr' suffix is added for the callback pointer. */ #define %pythoncallback %feature("python:callback") #define %nopythoncallback %feature("python:callback","0") #define %clearpythoncallback %feature("python:callback","") /* ------------------------------------------------------------------------- */ /* Support for the old %callback directive name */ #ifdef %callback #undef %callback #endif #ifdef %nocallback #undef %nocallback #endif #ifdef %clearcallback #undef %clearcallback #endif #define %callback(x) %feature("python:callback",`x`) #define %nocallback %nopythoncallback #define %clearcallback %clearpythoncallback /* ------------------------------------------------------------------------- */ /* Thread support - Advance control */ #define %nothread %feature("nothread") #define %thread %feature("nothread","0") #define %clearnothread %feature("nothread","") #define %nothreadblock %feature("nothreadblock") #define %threadblock %feature("nothreadblock","0") #define %clearnothreadblock %feature("nothreadblock","") #define %nothreadallow %feature("nothreadallow") #define %threadallow %feature("nothreadallow","0") #define %clearnothreadallow %feature("nothreadallow","") /* ------------------------------------------------------------------------- */ /* Implicit Conversion using the C++ constructor mechanism */ #define %implicitconv %feature("implicitconv") #define %noimplicitconv %feature("implicitconv", "0") #define %clearimplicitconv %feature("implicitconv", "") /* ------------------------------------------------------------------------- */ /* Enable keywords paramaters */ #define %kwargs %feature("kwargs") #define %nokwargs %feature("kwargs", "0") #define %clearkwargs %feature("kwargs", "") /* ------------------------------------------------------------------------- */ /* Add python code to the proxy/shadow code %pythonprepend - Add code before the C++ function is called %pythonappend - Add code after the C++ function is called */ #define %pythonprepend %feature("pythonprepend") #define %clearpythonprepend %feature("pythonprepend","") #define %pythonappend %feature("pythonappend") #define %clearpythonappend %feature("pythonappend","") /* ------------------------------------------------------------------------- */ /* %extend_smart_pointer extend the smart pointer support. For example, if you have a smart pointer as: template class RCPtr { public: ... RCPtr(Type *p); Type * operator->() const; ... }; you use the %extend_smart_pointer directive as: %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; then, if you have something like: RCPtr make_ptr(); int foo(A *); you can do the following: a = make_ptr(); b = foo(a); ie, swig will accept a RCPtr object where a 'A *' is expected. Also, when using vectors %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; %template(vector_A) std::vector >; you can type a = A(); v = vector_A(2) v[0] = a ie, an 'A *' object is accepted, via implicit conversion, where a RCPtr object is expected. Additionally x = v[0] returns (and sets 'x' as) a copy of v[0], making reference counting possible and consistent. */ %define %extend_smart_pointer(Type...) %implicitconv Type; %apply const SWIGTYPE& SMARTPOINTER { const Type& }; %apply SWIGTYPE SMARTPOINTER { Type }; %enddef swig-3.0.2/Lib/python/std_wsstream.i0000664000175000017500000000003612343605122017262 0ustar williamwilliam%include swig-3.0.2/Lib/python/pyprimtypes.swg0000664000175000017500000001712212343605122017524 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* boolean */ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE PyObject* SWIG_From_dec(bool)(bool value) { return PyBool_FromLong(value ? 1 : 0); } } #ifdef SWIG_PYTHON_LEGACY_BOOL // Default prior to SWIG 3.0.0 %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(PyObject *obj, bool *val) { int r = PyObject_IsTrue(obj); if (r == -1) return SWIG_ERROR; if (val) *val = r ? true : false; return SWIG_OK; } } #else %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(PyObject *obj, bool *val) { int r; if (!PyBool_Check(obj)) return SWIG_ERROR; r = PyObject_IsTrue(obj); if (r == -1) return SWIG_ERROR; if (val) *val = r ? true : false; return SWIG_OK; } } #endif /* int */ %fragment(SWIG_From_frag(int),"header") { SWIGINTERNINLINE PyObject* SWIG_From_dec(int)(int value) { return PyInt_FromLong((long) value); } } /* unsigned int */ %fragment(SWIG_From_frag(unsigned int),"header") { SWIGINTERNINLINE PyObject* SWIG_From_dec(unsigned int)(unsigned int value) { return PyInt_FromSize_t((size_t) value); } } /* long */ %fragment(SWIG_From_frag(long),"header") { %define_as(SWIG_From_dec(long), PyLong_FromLong) } %fragment(SWIG_AsVal_frag(long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long)(PyObject *obj, long* val) { if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } %#ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; long v = PyInt_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { if (val) *val = (long)(d); return res; } } } %#endif return SWIG_TypeError; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE PyObject* SWIG_From_dec(unsigned long)(unsigned long value) { return (value > LONG_MAX) ? PyLong_FromUnsignedLong(value) : PyLong_FromLong(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) { %#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) { long v = PyInt_AsLong(obj); if (v >= 0) { if (val) *val = v; return SWIG_OK; } else { return SWIG_OverflowError; } } else %#endif if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); %#if PY_VERSION_HEX >= 0x03000000 { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (v < 0) { return SWIG_OverflowError; } } else { PyErr_Clear(); } } %#endif } } %#ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { if (val) *val = (unsigned long)(d); return res; } } } %#endif return SWIG_TypeError; } } /* long long */ %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE PyObject* SWIG_From_dec(long long)(long long value) { return ((value < LONG_MIN) || (value > LONG_MAX)) ? PyLong_FromLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(long long),"header", fragment=SWIG_AsVal_frag(long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(long long)(PyObject *obj, long long *val) { int res = SWIG_TypeError; if (PyLong_Check(obj)) { long long v = PyLong_AsLongLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } else { long v; res = SWIG_AsVal(long)(obj,&v); if (SWIG_IsOK(res)) { if (val) *val = v; return res; } } %#ifdef SWIG_PYTHON_CAST_MODE { const double mant_max = 1LL << DBL_MANT_DIG; const double mant_min = -mant_max; double d; res = SWIG_AsVal(double)(obj,&d); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { if (val) *val = (long long)(d); return SWIG_AddCast(res); } res = SWIG_TypeError; } %#endif return res; } } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="") { SWIGINTERNINLINE PyObject* SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? PyLong_FromUnsignedLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val) { int res = SWIG_TypeError; if (PyLong_Check(obj)) { unsigned long long v = PyLong_AsUnsignedLongLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } else { unsigned long v; res = SWIG_AsVal(unsigned long)(obj,&v); if (SWIG_IsOK(res)) { if (val) *val = v; return res; } } %#ifdef SWIG_PYTHON_CAST_MODE { const double mant_max = 1LL << DBL_MANT_DIG; double d; res = SWIG_AsVal(double)(obj,&d); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { if (val) *val = (unsigned long long)(d); return SWIG_AddCast(res); } res = SWIG_TypeError; } %#endif return res; } } /* double */ %fragment(SWIG_From_frag(double),"header") { %define_as(SWIG_From_dec(double), PyFloat_FromDouble) } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(PyObject *obj, double *val) { int res = SWIG_TypeError; if (PyFloat_Check(obj)) { if (val) *val = PyFloat_AsDouble(obj); return SWIG_OK; } else if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { double v = PyLong_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } %#ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; double d = PyFloat_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = d; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); } else { PyErr_Clear(); } } } %#endif return res; } } swig-3.0.2/Lib/python/pycontainer.swg0000664000175000017500000006665312343605122017467 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pycontainer.swg * * Python sequence <-> C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of * the mapping between C++ and Python, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should * be the case. * ----------------------------------------------------------------------------- */ %{ #include #if PY_VERSION_HEX >= 0x03020000 # define SWIGPY_SLICE_ARG(obj) ((PyObject*) (obj)) #else # define SWIGPY_SLICE_ARG(obj) ((PySliceObject*) (obj)) #endif %} #if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) # if !defined(SWIG_EXPORT_ITERATOR_METHODS) # define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS # endif #endif %include /**** The PySequence C++ Wrap ***/ %fragment(""); %include %fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "SwigPtr_PyObject"; } }; template <> struct traits_from { typedef SwigPtr_PyObject value_type; static PyObject *from(const value_type& val) { PyObject *obj = static_cast(val); Py_XINCREF(obj); return obj; } }; template <> struct traits_check { static bool check(SwigPtr_PyObject) { return true; } }; template <> struct traits_asval { typedef SwigPtr_PyObject value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; } } %fragment(SWIG_Traits_frag(swig::SwigVar_PyObject),"header",fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "SwigVar_PyObject"; } }; template <> struct traits_from { typedef SwigVar_PyObject value_type; static PyObject *from(const value_type& val) { PyObject *obj = static_cast(val); Py_XINCREF(obj); return obj; } }; template <> struct traits_check { static bool check(SwigVar_PyObject) { return true; } }; template <> struct traits_asval { typedef SwigVar_PyObject value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; } } %fragment("SwigPySequence_Base","header",fragment="") { %#include namespace std { template <> struct less : public binary_function { bool operator()(PyObject * v, PyObject *w) const { bool res; SWIG_PYTHON_THREAD_BEGIN_BLOCK; res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false; /* This may fall into a case of inconsistent eg. ObjA > ObjX > ObjB but ObjA < ObjB */ if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) ) { /* Objects can't be compared, this mostly occurred in Python 3.0 */ /* Compare their ptr directly for a workaround */ res = (v < w); PyErr_Clear(); } SWIG_PYTHON_THREAD_END_BLOCK; return res; } }; template <> struct less : public binary_function { bool operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const { return std::less()(v, w); } }; template <> struct less : public binary_function { bool operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const { return std::less()(v, w); } }; } namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "PyObject *"; } }; template <> struct traits_asval { typedef PyObject * value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; template <> struct traits_check { static bool check(PyObject *) { return true; } }; template <> struct traits_from { typedef PyObject * value_type; static PyObject *from(const value_type& val) { Py_XINCREF(val); return val; } }; } namespace swig { template inline size_t check_index(Difference i, size_t size, bool insert = false) { if ( i < 0 ) { if ((size_t) (-i) <= size) return (size_t) (i + size); } else if ( (size_t) i < size ) { return (size_t) i; } else if (insert && ((size_t) i == size)) { return size; } throw std::out_of_range("index out of range"); } template void slice_adjust(Difference i, Difference j, Py_ssize_t step, size_t size, Difference &ii, Difference &jj, bool insert = false) { if (step == 0) { throw std::invalid_argument("slice step cannot be zero"); } else if (step > 0) { // Required range: 0 <= i < size, 0 <= j < size if (i < 0) { ii = 0; } else if (i < (Difference)size) { ii = i; } else if (insert && (i >= (Difference)size)) { ii = (Difference)size; } if ( j < 0 ) { jj = 0; } else { jj = (j < (Difference)size) ? j : (Difference)size; } } else { // Required range: -1 <= i < size-1, -1 <= j < size-1 if (i < -1) { ii = -1; } else if (i < (Difference) size) { ii = i; } else if (i >= (Difference)(size-1)) { ii = (Difference)(size-1); } if (j < -1) { jj = -1; } else { jj = (j < (Difference)size ) ? j : (Difference)(size-1); } } } template inline typename Sequence::iterator getpos(Sequence* self, Difference i) { typename Sequence::iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline typename Sequence::const_iterator cgetpos(const Sequence* self, Difference i) { typename Sequence::const_iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline Sequence* getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) { typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; swig::slice_adjust(i, j, step, size, ii, jj); if (step > 0) { typename Sequence::const_iterator sb = self->begin(); typename Sequence::const_iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); if (step == 1) { return new Sequence(sb, se); } else { Sequence *sequence = new Sequence(); typename Sequence::const_iterator it = sb; while (it!=se) { sequence->push_back(*it); for (Py_ssize_t c=0; c jj) { typename Sequence::const_reverse_iterator sb = self->rbegin(); typename Sequence::const_reverse_iterator se = self->rbegin(); std::advance(sb,size-ii-1); std::advance(se,size-jj-1); typename Sequence::const_reverse_iterator it = sb; while (it!=se) { sequence->push_back(*it); for (Py_ssize_t c=0; c<-step && it!=se; ++c) it++; } } return sequence; } } template inline void setslice(Sequence* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) { typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; swig::slice_adjust(i, j, step, size, ii, jj, true); if (step > 0) { if (jj < ii) jj = ii; if (step == 1) { size_t ssize = jj - ii; if (ssize <= is.size()) { // expanding/staying the same size typename Sequence::iterator sb = self->begin(); typename InputSeq::const_iterator isit = is.begin(); std::advance(sb,ii); std::advance(isit, jj - ii); self->insert(std::copy(is.begin(), isit, sb), isit, is.end()); } else { // shrinking typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); sb = self->begin(); std::advance(sb,ii); self->insert(sb, is.begin(), is.end()); } } else { size_t replacecount = (jj - ii + step - 1) / step; if (is.size() != replacecount) { char msg[1024]; sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); throw std::invalid_argument(msg); } typename Sequence::const_iterator isit = is.begin(); typename Sequence::iterator it = self->begin(); std::advance(it,ii); for (size_t rc=0; rcend(); ++c) it++; } } } else { if (jj > ii) jj = ii; size_t replacecount = (ii - jj - step - 1) / -step; if (is.size() != replacecount) { char msg[1024]; sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); throw std::invalid_argument(msg); } typename Sequence::const_iterator isit = is.begin(); typename Sequence::reverse_iterator it = self->rbegin(); std::advance(it,size-ii-1); for (size_t rc=0; rcrend(); ++c) it++; } } } template inline void delslice(Sequence* self, Difference i, Difference j, Py_ssize_t step) { typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; swig::slice_adjust(i, j, step, size, ii, jj, true); if (step > 0) { if (jj > ii) { typename Sequence::iterator sb = self->begin(); std::advance(sb,ii); if (step == 1) { typename Sequence::iterator se = self->begin(); std::advance(se,jj); self->erase(sb,se); } else { typename Sequence::iterator it = sb; size_t delcount = (jj - ii + step - 1) / step; while (delcount) { it = self->erase(it); for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c) it++; delcount--; } } } } else { if (ii > jj) { typename Sequence::reverse_iterator sb = self->rbegin(); std::advance(sb,size-ii-1); typename Sequence::reverse_iterator it = sb; size_t delcount = (ii - jj - step - 1) / -step; while (delcount) { it = typename Sequence::reverse_iterator(self->erase((++it).base())); for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c) it++; delcount--; } } } } } } %fragment("SwigPySequence_Cont","header", fragment="StdTraits", fragment="SwigPySequence_Base", fragment="SwigPyIterator_T") { namespace swig { template struct SwigPySequence_Ref { SwigPySequence_Ref(PyObject* seq, int index) : _seq(seq), _index(index) { } operator T () const { swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index); try { return swig::as(item, true); } catch (std::exception& e) { char msg[1024]; sprintf(msg, "in sequence element %d ", _index); if (!PyErr_Occurred()) { ::%type_error(swig::type_name()); } SWIG_Python_AddErrorMsg(msg); SWIG_Python_AddErrorMsg(e.what()); throw; } } SwigPySequence_Ref& operator=(const T& v) { PySequence_SetItem(_seq, _index, swig::from(v)); return *this; } private: PyObject* _seq; int _index; }; template struct SwigPySequence_ArrowProxy { SwigPySequence_ArrowProxy(const T& x): m_value(x) {} const T* operator->() const { return &m_value; } operator const T*() const { return &m_value; } T m_value; }; template struct SwigPySequence_InputIterator { typedef SwigPySequence_InputIterator self; typedef std::random_access_iterator_tag iterator_category; typedef Reference reference; typedef T value_type; typedef T* pointer; typedef int difference_type; SwigPySequence_InputIterator() { } SwigPySequence_InputIterator(PyObject* seq, int index) : _seq(seq), _index(index) { } reference operator*() const { return reference(_seq, _index); } SwigPySequence_ArrowProxy operator->() const { return SwigPySequence_ArrowProxy(operator*()); } bool operator==(const self& ri) const { return (_index == ri._index) && (_seq == ri._seq); } bool operator!=(const self& ri) const { return !(operator==(ri)); } self& operator ++ () { ++_index; return *this; } self& operator -- () { --_index; return *this; } self& operator += (difference_type n) { _index += n; return *this; } self operator +(difference_type n) const { return self(_seq, _index + n); } self& operator -= (difference_type n) { _index -= n; return *this; } self operator -(difference_type n) const { return self(_seq, _index - n); } difference_type operator - (const self& ri) const { return _index - ri._index; } bool operator < (const self& ri) const { return _index < ri._index; } reference operator[](difference_type n) const { return reference(_seq, _index + n); } private: PyObject* _seq; difference_type _index; }; template struct SwigPySequence_Cont { typedef SwigPySequence_Ref reference; typedef const SwigPySequence_Ref const_reference; typedef T value_type; typedef T* pointer; typedef int difference_type; typedef int size_type; typedef const pointer const_pointer; typedef SwigPySequence_InputIterator iterator; typedef SwigPySequence_InputIterator const_iterator; SwigPySequence_Cont(PyObject* seq) : _seq(0) { if (!PySequence_Check(seq)) { throw std::invalid_argument("a sequence is expected"); } _seq = seq; Py_INCREF(_seq); } ~SwigPySequence_Cont() { Py_XDECREF(_seq); } size_type size() const { return static_cast(PySequence_Size(_seq)); } bool empty() const { return size() == 0; } iterator begin() { return iterator(_seq, 0); } const_iterator begin() const { return const_iterator(_seq, 0); } iterator end() { return iterator(_seq, size()); } const_iterator end() const { return const_iterator(_seq, size()); } reference operator[](difference_type n) { return reference(_seq, n); } const_reference operator[](difference_type n) const { return const_reference(_seq, n); } bool check(bool set_err = true) const { int s = size(); for (int i = 0; i < s; ++i) { swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i); if (!swig::check(item)) { if (set_err) { char msg[1024]; sprintf(msg, "in sequence element %d", i); SWIG_Error(SWIG_RuntimeError, msg); } return false; } } return true; } private: PyObject* _seq; }; } } %define %swig_sequence_iterator(Sequence...) #if defined(SWIG_EXPORT_ITERATOR_METHODS) class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; %typemap(out,noblock=1,fragment="SwigPySequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); } %typemap(out,noblock=1,fragment="SwigPySequence_Cont") std::pair, std::pair { $result = PyTuple_New(2); PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); } %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SwigPySequence_Cont") {} %typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator") std::pair, std::pair { $result = PyTuple_New(2); PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second)); } %typemap(in,noblock=1,fragment="SwigPySequence_Cont") iterator(swig::SwigPyIterator *iter = 0, int res), reverse_iterator(swig::SwigPyIterator *iter = 0, int res), const_iterator(swig::SwigPyIterator *iter = 0, int res), const_reverse_iterator(swig::SwigPyIterator *iter = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { swig::SwigPyIterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } } } %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SwigPySequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { swig::SwigPyIterator *iter = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } %fragment("SwigPySequence_Cont"); %newobject iterator(PyObject **PYTHON_SELF); %extend { swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "tp_iter", functype="getiterfunc") iterator; #else %pythoncode {def __iter__(self): return self.iterator()} #endif } #endif //SWIG_EXPORT_ITERATOR_METHODS %enddef /**** The python container methods ****/ %define %swig_container_methods(Container...) /* deprecated in Python 2 */ #if 1 %newobject __getslice__; #endif %newobject __getitem__(PySliceObject *slice); #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "nb_nonzero", functype="inquiry") __nonzero__; %feature("python:slot", "sq_length", functype="lenfunc") __len__; #endif // SWIGPYTHON_BUILTIN %extend { bool __nonzero__() const { return !(self->empty()); } /* Alias for Python 3 compatibility */ bool __bool__() const { return !(self->empty()); } size_type __len__() const { return self->size(); } } %enddef %define %swig_sequence_methods_common(Sequence...) %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) %fragment("SwigPySequence_Base"); #if defined(SWIGPYTHON_BUILTIN) //%feature("python:slot", "sq_item", functype="ssizeargfunc") __getitem__; //%feature("python:slot", "sq_slice", functype="ssizessizeargfunc") __getslice__; //%feature("python:slot", "sq_ass_item", functype="ssizeobjargproc") __setitem__; //%feature("python:slot", "sq_ass_slice", functype="ssizessizeobjargproc") __setslice__; %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; #endif // SWIGPYTHON_BUILTIN %extend { value_type pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty container"); Sequence::value_type x = self->back(); self->pop_back(); return x; } /* typemap for slice object support */ %typemap(in) PySliceObject* { if (!PySlice_Check($input)) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } $1 = (PySliceObject *) $input; } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* { $1 = PySlice_Check($input); } /* deprecated in Python 2 */ #if 1 Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { return swig::getslice(self, i, j, 1); } void __setslice__(difference_type i, difference_type j, const Sequence& v = Sequence()) throw (std::out_of_range, std::invalid_argument) { swig::setslice(self, i, j, 1, v); } void __delslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { swig::delslice(self, i, j, 1); } #endif void __delitem__(difference_type i) throw (std::out_of_range) { self->erase(swig::getpos(self,i)); } /* Overloaded methods for Python 3 compatibility * (Also useful in Python 2.x) */ Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return NULL; } PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); Sequence::difference_type id = i; Sequence::difference_type jd = j; return swig::getslice(self, id, jd, step); } void __setitem__(PySliceObject *slice, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return; } PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); Sequence::difference_type id = i; Sequence::difference_type jd = j; swig::setslice(self, id, jd, step, v); } void __setitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return; } PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); Sequence::difference_type id = i; Sequence::difference_type jd = j; swig::delslice(self, id, jd, step); } void __delitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return; } PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); Sequence::difference_type id = i; Sequence::difference_type jd = j; swig::delslice(self, id, jd, step); } } %enddef %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { const value_type& __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __setitem__(difference_type i, const value_type& x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } void append(const value_type& x) { self->push_back(x); } } %enddef %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { value_type __getitem__(difference_type i) throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __setitem__(difference_type i, value_type x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } void append(value_type x) { self->push_back(x); } } %enddef // // Common fragments // %fragment("StdSequenceTraits","header", fragment="StdTraits", fragment="SwigPySequence_Cont") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, Seq* seq) { // seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr_stdseq { typedef Seq sequence; typedef T value_type; static int asptr(PyObject *obj, sequence **seq) { if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) { sequence *p; if (::SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0) == SWIG_OK) { if (seq) *seq = p; return SWIG_OLDOBJ; } } else if (PySequence_Check(obj)) { try { SwigPySequence_Cont swigpyseq(obj); if (seq) { sequence *pseq = new sequence(); assign(swigpyseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { return swigpyseq.check() ? SWIG_OK : SWIG_ERROR; } } catch (std::exception& e) { if (seq) { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, e.what()); } } return SWIG_ERROR; } } return SWIG_ERROR; } }; template struct traits_from_stdseq { typedef Seq sequence; typedef T value_type; typedef typename Seq::size_type size_type; typedef typename sequence::const_iterator const_iterator; static PyObject *from(const sequence& seq) { %#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } %#endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { PyObject *obj = PyTuple_New((int)size); int i = 0; for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) { PyTuple_SetItem(obj,i,swig::from(*it)); } return obj; } else { PyErr_SetString(PyExc_OverflowError,"sequence size not valid in python"); return NULL; } } }; } } swig-3.0.2/Lib/python/std_char_traits.i0000664000175000017500000000004112343605122017714 0ustar williamwilliam%include swig-3.0.2/Lib/octave/0000775000175000017500000000000012343605122014332 5ustar williamwilliamswig-3.0.2/Lib/octave/octcontainer.swg0000664000175000017500000003765212343605122017561 0ustar williamwilliam/* ----------------------------------------------------------------------------- * octcontainer.swg * * Octave cell <-> C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of * the mapping between C++ and Octave, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should * be the case. * ----------------------------------------------------------------------------- */ %{ #include %} #if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) # if !defined(SWIG_EXPORT_ITERATOR_METHODS) # define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS # endif #endif %include // The Octave C++ Wrap %fragment(""); %include %fragment(SWIG_Traits_frag(octave_value),"header",fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "octave_value"; } }; template <> struct traits_from { typedef octave_value value_type; static octave_value from(const value_type& val) { return val; } }; template <> struct traits_check { static bool check(const octave_value&) { return true; } }; template <> struct traits_asval { typedef octave_value value_type; static int asval(const octave_value& obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; } } %fragment("OctSequence_Base","header",fragment="") { %#include namespace std { template <> struct less : public binary_function { bool operator()(const octave_value& v, const octave_value& w) const { octave_value res = do_binary_op(octave_value::op_le,v,w); return res.is_true(); } }; } namespace swig { inline size_t check_index(ptrdiff_t i, size_t size, bool insert = false) { if ( i < 0 ) { if ((size_t) (-i) <= size) return (size_t) (i + size); } else if ( (size_t) i < size ) { return (size_t) i; } else if (insert && ((size_t) i == size)) { return size; } throw std::out_of_range("index out of range"); } inline size_t slice_index(ptrdiff_t i, size_t size) { if ( i < 0 ) { if ((size_t) (-i) <= size) { return (size_t) (i + size); } else { throw std::out_of_range("index out of range"); } } else { return ( (size_t) i < size ) ? ((size_t) i) : size; } } template inline typename Sequence::iterator getpos(Sequence* self, Difference i) { typename Sequence::iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline typename Sequence::const_iterator cgetpos(const Sequence* self, Difference i) { typename Sequence::const_iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline Sequence* getslice(const Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::const_iterator vb = self->begin(); typename Sequence::const_iterator ve = self->begin(); std::advance(vb,ii); std::advance(ve,jj); return new Sequence(vb, ve); } else { return new Sequence(); } } template inline void setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj < ii) jj = ii; size_t ssize = jj - ii; if (ssize <= v.size()) { typename Sequence::iterator sb = self->begin(); typename InputSeq::const_iterator vmid = v.begin(); std::advance(sb,ii); std::advance(vmid, jj - ii); self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end()); } else { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); self->insert(sb, v.begin(), v.end()); } } template inline void delslice(Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); } } } } %fragment("OctSequence_Cont","header", fragment="StdTraits", fragment="OctSequence_Base", fragment="OctSwigIterator_T") { namespace swig { template struct OctSequence_Ref // * octave can't support these, because of how assignment works { OctSequence_Ref(const octave_value& seq, int index) : _seq(seq), _index(index) { } operator T () const { // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, _index); octave_value item; // * todo try { return swig::as(item, true); } catch (std::exception& e) { char msg[1024]; sprintf(msg, "in sequence element %d ", _index); if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } SWIG_Octave_AddErrorMsg(msg); SWIG_Octave_AddErrorMsg(e.what()); throw; } } OctSequence_Ref& operator=(const T& v) { // OctSequence_SetItem(_seq, _index, swig::from(v)); // * todo return *this; } private: octave_value _seq; int _index; }; template struct OctSequence_ArrowProxy { OctSequence_ArrowProxy(const T& x): m_value(x) {} const T* operator->() const { return &m_value; } operator const T*() const { return &m_value; } T m_value; }; template struct OctSequence_InputIterator { typedef OctSequence_InputIterator self; typedef std::random_access_iterator_tag iterator_category; typedef Reference reference; typedef T value_type; typedef T* pointer; typedef int difference_type; OctSequence_InputIterator() { } OctSequence_InputIterator(const octave_value& seq, int index) : _seq(seq), _index(index) { } reference operator*() const { return reference(_seq, _index); } OctSequence_ArrowProxy operator->() const { return OctSequence_ArrowProxy(operator*()); } bool operator==(const self& ri) const { return (_index == ri._index); } bool operator!=(const self& ri) const { return !(operator==(ri)); } self& operator ++ () { ++_index; return *this; } self& operator -- () { --_index; return *this; } self& operator += (difference_type n) { _index += n; return *this; } self operator +(difference_type n) const { return self(_seq, _index + n); } self& operator -= (difference_type n) { _index -= n; return *this; } self operator -(difference_type n) const { return self(_seq, _index - n); } difference_type operator - (const self& ri) const { return _index - ri._index; } bool operator < (const self& ri) const { return _index < ri._index; } reference operator[](difference_type n) const { return reference(_seq, _index + n); } private: octave_value _seq; difference_type _index; }; template struct OctSequence_Cont { typedef OctSequence_Ref reference; typedef const OctSequence_Ref const_reference; typedef T value_type; typedef T* pointer; typedef int difference_type; typedef int size_type; typedef const pointer const_pointer; typedef OctSequence_InputIterator iterator; typedef OctSequence_InputIterator const_iterator; OctSequence_Cont(const octave_value& seq) : _seq(seq) { // * assert that we have map type etc. /* if (!OctSequence_Check(seq)) { throw std::invalid_argument("a sequence is expected"); } _seq = seq; Py_INCREF(_seq); */ } ~OctSequence_Cont() { } size_type size() const { // return static_cast(OctSequence_Size(_seq)); return 0; // * todo } bool empty() const { return size() == 0; } iterator begin() { return iterator(_seq, 0); } const_iterator begin() const { return const_iterator(_seq, 0); } iterator end() { return iterator(_seq, size()); } const_iterator end() const { return const_iterator(_seq, size()); } reference operator[](difference_type n) { return reference(_seq, n); } const_reference operator[](difference_type n) const { return const_reference(_seq, n); } bool check(bool set_err = true) const { int s = size(); for (int i = 0; i < s; ++i) { // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, i); octave_value item; // * todo if (!swig::check(item)) { if (set_err) { char msg[1024]; sprintf(msg, "in sequence element %d", i); SWIG_Error(SWIG_RuntimeError, msg); } return false; } } return true; } private: octave_value _seq; }; } } %define %swig_sequence_iterator(Sequence...) #if defined(SWIG_EXPORT_ITERATOR_METHODS) class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; %typemap(out,noblock=1,fragment="OctSequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)), swig::OctSwigIterator::descriptor(),SWIG_POINTER_OWN); } %typemap(out,fragment="OctSequence_Cont") std::pair, std::pair { octave_value_list tmpc; tmpc.append(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), swig::OctSwigIterator::descriptor(),SWIG_POINTER_OWN)); tmpc.append(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second), swig::OctSwigIterator::descriptor(),SWIG_POINTER_OWN)); $result = Cell(tmpc); } %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="OctSequence_Cont") {} %typemap(out,fragment="OctPairBoolOutputIterator") std::pair, std::pair { octave_value_list tmpc; tmpc.append(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), swig::OctSwigIterator::descriptor(),SWIG_POINTER_OWN)); tmpc.append(SWIG_From(bool)(%static_cast($1,const $type &).second)); $result = Cell(tmpc); } %typemap(in,noblock=1,fragment="OctSequence_Cont") iterator(swig::OctSwigIterator *iter = 0, int res), reverse_iterator(swig::OctSwigIterator *iter = 0, int res), const_iterator(swig::OctSwigIterator *iter = 0, int res), const_reverse_iterator(swig::OctSwigIterator *iter = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::OctSwigIterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { swig::OctSwigIterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } } } %typecheck(%checkcode(ITERATOR),noblock=1,fragment="OctSequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { swig::OctSwigIterator *iter = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::OctSwigIterator::descriptor(), 0); $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } %fragment("OctSequence_Cont"); #endif //SWIG_EXPORT_ITERATOR_METHODS %enddef // The octave container methods %define %swig_container_methods(Container...) %enddef %define %swig_sequence_methods_common(Sequence...) %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) %fragment("OctSequence_Base"); %extend { value_type pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty container"); Sequence::value_type x = self->back(); self->pop_back(); return x; } value_type __paren__(difference_type i) throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __paren_asgn__(difference_type i, value_type x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } void append(value_type x) { self->push_back(x); } } %enddef %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %enddef %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %enddef // // Common fragments // %fragment("StdSequenceTraits","header", fragment="StdTraits", fragment="OctSequence_Cont") { namespace swig { template inline void assign(const OctSeq& octseq, Seq* seq) { %#ifdef SWIG_STD_NOASSIGN_STL typedef typename OctSeq::value_type value_type; typename OctSeq::const_iterator it = octseq.begin(); for (;it != octseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } %#else seq->assign(octseq.begin(), octseq.end()); %#endif } template struct traits_asptr_stdseq { typedef Seq sequence; typedef T value_type; static int asptr(const octave_value& obj, sequence **seq) { if (!obj.is_defined() || Swig::swig_value_deref(obj)) { sequence *p; if (SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0) == SWIG_OK) { if (seq) *seq = p; return SWIG_OLDOBJ; } } else if (obj.is_cell()) { try { OctSequence_Cont octseq(obj); if (seq) { sequence *pseq = new sequence(); assign(octseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { return octseq.check() ? SWIG_OK : SWIG_ERROR; } } catch (std::exception& e) { if (seq&&!error_state) error("swig type error: %s",e.what()); return SWIG_ERROR; } } return SWIG_ERROR; } }; template struct traits_from_stdseq { typedef Seq sequence; typedef T value_type; typedef typename Seq::size_type size_type; typedef typename sequence::const_iterator const_iterator; static octave_value from(const sequence& seq) { #ifdef SWIG_OCTAVE_EXTRA_NATIVE_CONTAINERS swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } #endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { Cell c(size,1); int i = 0; for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) { c(i) = swig::from(*it); } return c; } else { error("swig overflow error: sequence size not valid in octave"); return octave_value(); } return octave_value(); } }; } } swig-3.0.2/Lib/octave/director.swg0000664000175000017500000000572712343605122016702 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that D proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) #include namespace Swig { class Director { octave_swig_type *self; bool swig_disowned; Director(const Director &x); Director &operator=(const Director &rhs); public: Director(void *vptr):self(0), swig_disowned(false) { set_rtdir(vptr, this); } ~Director() { swig_director_destroyed(self, this); if (swig_disowned) self->decref(); } void swig_set_self(octave_swig_type *new_self) { assert(!swig_disowned); self = new_self; } octave_swig_type *swig_get_self() const { return self; } void swig_disown() { if (swig_disowned) return; swig_disowned = true; self->incref(); } }; struct DirectorTypeMismatchException { static void raise(const char *msg) { // ... todo throw(DirectorTypeMismatchException()); } static void raise(const octave_value &ov, const char *msg) { // ... todo raise(msg); } }; struct DirectorPureVirtualException { static void raise(const char *msg) { // ... todo throw(DirectorPureVirtualException()); } static void raise(const octave_value &ov, const char *msg) { // ... todo raise(msg); } }; SWIGINTERN rtdir_map *get_rtdir_map() { static swig_module_info *module = 0; if (!module) module = SWIG_GetModule(0); if (!module) return 0; if (!module->clientdata) module->clientdata = new rtdir_map; return (rtdir_map *) module->clientdata; } SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) { rtdir_map *rm = get_rtdir_map(); if (rm) (*rm)[vptr] = d; } SWIGINTERNINLINE void erase_rtdir(void *vptr) { rtdir_map *rm = get_rtdir_map(); if (rm) (*rm).erase(vptr); } SWIGINTERNINLINE Director *get_rtdir(void *vptr) { rtdir_map *rm = get_rtdir_map(); if (!rm) return 0; rtdir_map::const_iterator pos = rm->find(vptr); Director *rtdir = (pos != rm->end())? pos->second : 0; return rtdir; } SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d) { self->director_destroyed(d); } SWIGRUNTIME octave_swig_type *swig_director_get_self(Director *d) { return d->swig_get_self(); } SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self) { d->swig_set_self(self); } } SWIGRUNTIME void swig_acquire_ownership(void *vptr) { // assert(0); // ... todo } SWIGRUNTIME void swig_acquire_ownership_array(void *vptr) { // assert(0); // ... todo } SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own) { // assert(0); // ... todo } swig-3.0.2/Lib/octave/octuserdir.swg0000664000175000017500000000342612343605122017244 0ustar williamwilliam/* ------------------------------------------------------------------------- * Special user directives * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ /* Implicit Conversion using the C++ constructor mechanism */ #define %implicitconv %feature("implicitconv") #define %noimplicitconv %feature("implicitconv", "0") #define %clearimplicitconv %feature("implicitconv", "") /* ------------------------------------------------------------------------- */ /* %extend_smart_pointer extend the smart pointer support. For example, if you have a smart pointer as: template class RCPtr { public: ... RCPtr(Type *p); Type * operator->() const; ... }; you use the %extend_smart_pointer directive as: %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; then, if you have something like: RCPtr make_ptr(); int foo(A *); you can do the following: a = make_ptr(); b = foo(a); ie, swig will accept a RCPtr object where a 'A *' is expected. Also, when using vectors %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; %template(vector_A) std::vector >; you can type a = A(); v = vector_A(2) v[0] = a ie, an 'A *' object is accepted, via implicit conversion, where a RCPtr object is expected. Additionally x = v[0] returns (and sets 'x' as) a copy of v[0], making reference counting possible and consistent. */ %define %extend_smart_pointer(Type...) %implicitconv Type; %apply const SWIGTYPE& SMARTPOINTER { const Type& }; %apply SWIGTYPE SMARTPOINTER { Type }; %enddef swig-3.0.2/Lib/octave/std_map.i0000664000175000017500000001104612343605122016135 0ustar williamwilliam// Maps %include %fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { template struct from_key_oper { typedef const ValueType& argument_type; typedef octave_value result_type; result_type operator()(argument_type v) const { return swig::from(v.first); } }; template struct from_value_oper { typedef const ValueType& argument_type; typedef octave_value result_type; result_type operator()(argument_type v) const { return swig::from(v.second); } }; template struct OctMapIterator_T : OctSwigIteratorClosed_T { OctMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq) : OctSwigIteratorClosed_T(curr, first, last, seq) { } }; template > struct OctMapKeyIterator_T : OctMapIterator_T { OctMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq) : OctMapIterator_T(curr, first, last, seq) { } }; template inline OctSwigIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value()) { return new OctMapKeyIterator_T(current, begin, end, seq); } template > struct OctMapValueIterator_T : OctMapIterator_T { OctMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq) : OctMapIterator_T(curr, first, last, seq) { } }; template inline OctSwigIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = 0) { return new OctMapValueIterator_T(current, begin, end, seq); } } } %fragment("StdMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const OctSeq& octseq, std::map *map) { typedef typename std::map::value_type value_type; typename OctSeq::const_iterator it = octseq.begin(); for (;it != octseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::map map_type; static int asptr(octave_value obj, map_type **val) { /* int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; */ return SWIG_ERROR; } }; template struct traits_from > { typedef std::map map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type; static octave_value from(const map_type& map) { /* swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); } else { size_type size = map.size(); int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; } */ return octave_value(); } }; } } %define %swig_map_common(Map...) %swig_sequence_iterator(Map); %swig_container_methods(Map); %enddef %define %swig_map_methods(Map...) %swig_map_common(Map) %enddef %include swig-3.0.2/Lib/octave/std_pair.i0000664000175000017500000000607412343605122016320 0ustar williamwilliam// Pairs %include //#define SWIG_STD_PAIR_ASVAL %fragment("StdPairTraits","header",fragment="StdTraits") { namespace swig { #ifdef SWIG_STD_PAIR_ASVAL template struct traits_asval > { typedef std::pair value_type; static int get_pair(const octave_value& first, octave_value second, std::pair *val) { if (val) { T *pfirst = &(val->first); int res1 = swig::asval(first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(val->second); int res2 = swig::asval(second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } else { T *pfirst = 0; int res1 = swig::asval(first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asval(const octave_value& obj, std::pair *val) { if (obj.is_cell()) { Cell c=obj.cell_value(); if (c.numel()<2) { error("pair from Cell array requires at least two elements"); return SWIG_ERROR; } return get_pair(c(0),c(1),val); } else { value_type *p; int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = *p; return res; } return SWIG_ERROR; } }; #else template struct traits_asptr > { typedef std::pair value_type; static int get_pair(const octave_value& first, octave_value second, std::pair **val) { if (val) { value_type *vp = %new_instance(std::pair); T *pfirst = &(vp->first); int res1 = swig::asval(first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(vp->second); int res2 = swig::asval(second, psecond); if (!SWIG_IsOK(res2)) return res2; *val = vp; return SWIG_AddNewMask(res1 > res2 ? res1 : res2); } else { T *pfirst = 0; int res1 = swig::asval(first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval(second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } return SWIG_ERROR; } static int asptr(const octave_value& obj, std::pair **val) { if (obj.is_cell()) { Cell c=obj.cell_value(); if (c.numel()<2) { error("pair from Cell array requires at least two elements"); return SWIG_ERROR; } return get_pair(c(0),c(1),val); } else { value_type *p; int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; return res; } return SWIG_ERROR; } }; #endif template struct traits_from > { static octave_value from(const std::pair& val) { Cell c(1,2); c(0)=swig::from(val.first); c(1)=swig::from(val.second); return c; } }; } } %define %swig_pair_methods(pair...) %enddef %include swig-3.0.2/Lib/octave/std_complex.i0000664000175000017500000000072612343605122017032 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.2/Lib/octave/typemaps.i0000664000175000017500000000004112343605122016341 0ustar williamwilliam%include swig-3.0.2/Lib/octave/octrun.swg0000664000175000017500000012643212343605122016376 0ustar williamwilliam #include // Macro for enabling features which require Octave version >= major.minor.patch #define SWIG_OCTAVE_PREREQ(major, minor, patch) \ ( (OCTAVE_MAJOR_VERSION<<16) + (OCTAVE_MINOR_VERSION<<8) + OCTAVE_PATCH_VERSION >= ((major)<<16) + ((minor)<<8) + (patch) ) // Reconstruct Octave major, minor, and patch versions for releases prior to 3.8.1 #if !defined(OCTAVE_MAJOR_VERSION) # if !defined(OCTAVE_API_VERSION_NUMBER) // Hack to distinguish between Octave 3.8.0, which removed OCTAVE_API_VERSION_NUMBER but did not yet // introduce OCTAVE_MAJOR_VERSION, and Octave <= 3.2, which did not define OCTAVE_API_VERSION_NUMBER # include # if defined(octave_ov_h) # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 8 # define OCTAVE_PATCH_VERSION 0 # else // Hack to distinguish between Octave 3.2 and earlier versions, before OCTAVE_API_VERSION_NUMBER existed # define ComplexLU __ignore # include # undef ComplexLU # if defined(octave_Complex_LU_h) // We know only that this version is prior to Octave 3.2, i.e. OCTAVE_API_VERSION_NUMBER < 37 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 1 # define OCTAVE_PATCH_VERSION 99 # else // OCTAVE_API_VERSION_NUMBER == 37 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 2 # define OCTAVE_PATCH_VERSION 0 # endif // defined(octave_Complex_LU_h) # endif // defined(octave_ov_h) // Correlation between Octave API and version numbers extracted from Octave's // ChangeLogs; version is the *earliest* released Octave with that API number # elif OCTAVE_API_VERSION_NUMBER >= 48 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 6 # define OCTAVE_PATCH_VERSION 0 # elif OCTAVE_API_VERSION_NUMBER >= 45 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 4 # define OCTAVE_PATCH_VERSION 1 # elif OCTAVE_API_VERSION_NUMBER >= 42 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 54 # elif OCTAVE_API_VERSION_NUMBER >= 41 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 53 # elif OCTAVE_API_VERSION_NUMBER >= 40 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 52 # elif OCTAVE_API_VERSION_NUMBER >= 39 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 51 # else // OCTAVE_API_VERSION_NUMBER == 38 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 50 # endif // !defined(OCTAVE_API_VERSION_NUMBER) #endif // !defined(OCTAVE_MAJOR_VERSION) #if !SWIG_OCTAVE_PREREQ(3,2,0) #define SWIG_DEFUN(cname, wname, doc) DEFUNX_DLD(#cname, wname, FS ## cname, args, nargout, doc) #else #define SWIG_DEFUN(cname, wname, doc) DEFUNX_DLD(#cname, wname, G ## cname, args, nargout, doc) #endif SWIGRUNTIME bool SWIG_check_num_args(const char *func_name, int num_args, int max_args, int min_args, int varargs) { if (num_args > max_args && !varargs) error("function %s takes at most %i arguments", func_name, max_args); else if (num_args < min_args) error("function %s requires at least %i arguments", func_name, min_args); else return true; return false; } SWIGRUNTIME octave_value_list *SWIG_Octave_AppendOutput(octave_value_list *ovl, const octave_value &ov) { ovl->append(ov); return ovl; } SWIGRUNTIME octave_value SWIG_ErrorType(int code) { switch (code) { case SWIG_MemoryError: return "SWIG_MemoryError"; case SWIG_IOError: return "SWIG_IOError"; case SWIG_RuntimeError: return "SWIG_RuntimeError"; case SWIG_IndexError: return "SWIG_IndexError"; case SWIG_TypeError: return "SWIG_TypeError"; case SWIG_DivisionByZero: return "SWIG_DivisionByZero"; case SWIG_OverflowError: return "SWIG_OverflowError"; case SWIG_SyntaxError: return "SWIG_SyntaxError"; case SWIG_ValueError: return "SWIG_ValueError"; case SWIG_SystemError: return "SWIG_SystemError"; case SWIG_AttributeError: return "SWIG_AttributeError"; } return "SWIG unknown error"; } SWIGRUNTIME octave_value SWIG_Error(int code, const char *msg) { octave_value type(SWIG_ErrorType(code)); std::string r = msg; r += " (" + type.string_value() + ")"; error(r.c_str()); return octave_value(r); } #define SWIG_fail goto fail #define SWIG_Octave_ConvertPtr(obj, pptr, type, flags) SWIG_Octave_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Octave_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Octave_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Octave_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Octave_NewPointerObj(ptr, type, flags) #define swig_owntype int #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Octave_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Octave_NewPackedObj(ptr, sz, type) #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Octave_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Octave_NewPackedObj(ptr, sz, type) #define SWIG_GetModule(clientdata) SWIG_Octave_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Octave_SetModule(clientdata,pointer); #define SWIG_MODULE_CLIENTDATA_TYPE void* #define Octave_Error_Occurred() 0 #define SWIG_Octave_AddErrorMsg(msg) {;} SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata); SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer); // For backward compatibility only #define SWIG_POINTER_EXCEPTION 0 #define SWIG_arg_fail(arg) 0 // Runtime API implementation #include #include #include typedef octave_value_list(*octave_func) (const octave_value_list &, int); class octave_swig_type; namespace Swig { #ifdef SWIG_DIRECTORS class Director; typedef std::map < void *, Director * > rtdir_map; SWIGINTERN rtdir_map* get_rtdir_map(); SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d); SWIGINTERNINLINE void erase_rtdir(void *vptr); SWIGINTERNINLINE Director *get_rtdir(void *vptr); SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d); SWIGRUNTIME octave_swig_type *swig_director_get_self(Director *d); SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self); #endif SWIGRUNTIME octave_base_value *swig_value_ref(octave_swig_type *ost); SWIGRUNTIME octave_swig_type *swig_value_deref(octave_value ov); SWIGRUNTIME octave_swig_type *swig_value_deref(const octave_base_value &ov); } #ifdef SWIG_DIRECTORS SWIGRUNTIME void swig_acquire_ownership(void *vptr); SWIGRUNTIME void swig_acquire_ownership_array(void *vptr); SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); #endif struct swig_octave_member { const char *name; octave_func method; octave_func get_method; octave_func set_method; int flags; // 1 static, 2 global const char *doc; bool is_static() const { return flags &1; } bool is_global() const { return flags &2; } }; struct swig_octave_class { const char *name; swig_type_info **type; int director; octave_func constructor; const char *constructor_doc; octave_func destructor; const swig_octave_member *members; const char **base_names; const swig_type_info **base; }; // octave_swig_type plays the role of both the shadow class and the class // representation within Octave, since there is no support for classes. // // These should really be decoupled, with the class support added to Octave // and the shadow class given by an m-file script. That would dramatically // reduce the runtime complexity, and be more in line w/ other modules. class octave_swig_type:public octave_base_value { struct cpp_ptr { void *ptr; bool destroyed; cpp_ptr(void *_ptr):ptr(_ptr), destroyed(false) { }}; typedef std::pair < const swig_type_info *, cpp_ptr > type_ptr_pair; mutable swig_module_info *module; const swig_type_info *construct_type; // type of special type object std::vector < type_ptr_pair > types; // our c++ base classes int own; // whether we call c++ destructors when we die typedef std::pair < const swig_octave_member *, octave_value > member_value_pair; typedef std::map < std::string, member_value_pair > member_map; member_map members; bool always_static; const swig_octave_member *find_member(const swig_type_info *type, const std::string &name) { if (!type->clientdata) return 0; swig_octave_class *c = (swig_octave_class *) type->clientdata; const swig_octave_member *m; for (m = c->members; m->name; ++m) if (m->name == name) return m; for (int j = 0; c->base_names[j]; ++j) { if (!c->base[j]) { if (!module) module = SWIG_GetModule(0); assert(module); c->base[j] = SWIG_MangledTypeQueryModule(module, module, c->base_names[j]); } if (!c->base[j]) return 0; if ((m = find_member(c->base[j], name))) return m; } return 0; } member_value_pair *find_member(const std::string &name, bool insert_if_not_found) { member_map::iterator it = members.find(name); if (it != members.end()) return &it->second; const swig_octave_member *m; for (unsigned int j = 0; j < types.size(); ++j) if ((m = find_member(types[j].first, name))) return &members.insert(std::make_pair(name, std::make_pair(m, octave_value()))).first->second; if (!insert_if_not_found) return 0; return &members[name]; } const swig_type_info *find_base(const std::string &name, const swig_type_info *base) { if (!base) { for (unsigned int j = 0; j < types.size(); ++j) { assert(types[j].first->clientdata); swig_octave_class *cj = (swig_octave_class *) types[j].first->clientdata; if (cj->name == name) return types[j].first; } return 0; } assert(base->clientdata); swig_octave_class *c = (swig_octave_class *) base->clientdata; for (int j = 0; c->base_names[j]; ++j) { if (!c->base[j]) { if (!module) module = SWIG_GetModule(0); assert(module); c->base[j] = SWIG_MangledTypeQueryModule(module, module, c->base_names[j]); } if (!c->base[j]) return 0; assert(c->base[j]->clientdata); swig_octave_class *cj = (swig_octave_class *) c->base[j]->clientdata; if (cj->name == name) return c->base[j]; } return 0; } void load_members(const swig_octave_class* c,member_map& out) const { for (const swig_octave_member *m = c->members; m->name; ++m) { if (out.find(m->name) == out.end()) out.insert(std::make_pair(m->name, std::make_pair(m, octave_value()))); } for (int j = 0; c->base_names[j]; ++j) { if (!c->base[j]) { if (!module) module = SWIG_GetModule(0); assert(module); c->base[j] = SWIG_MangledTypeQueryModule(module, module, c->base_names[j]); } if (!c->base[j]) continue; assert(c->base[j]->clientdata); const swig_octave_class *cj = (const swig_octave_class *) c->base[j]->clientdata; load_members(cj,out); } } void load_members(member_map& out) const { out=members; for (unsigned int j = 0; j < types.size(); ++j) if (types[j].first->clientdata) load_members((const swig_octave_class *) types[j].first->clientdata, out); } octave_value_list member_invoke(member_value_pair *m, const octave_value_list &args, int nargout) { if (m->second.is_defined()) return m->second.subsref("(", std::list < octave_value_list > (1, args), nargout); else if (m->first && m->first->method) return m->first->method(args, nargout); error("member not defined or not invocable"); return octave_value_list(); } bool dispatch_unary_op(const std::string &symbol, octave_value &ret) { member_value_pair *m = find_member(symbol, false); if (!m || m->first->is_static() || m->first->is_global()) return false; octave_value_list args; args.append(as_value()); octave_value_list argout(member_invoke(m, args, 1)); if (argout.length() < 1) return false; ret = argout(0); return true; } bool dispatch_binary_op(const std::string &symbol, const octave_base_value &rhs, octave_value &ret) { member_value_pair *m = find_member(symbol, false); if (!m || m->first->is_static() || m->first->is_global()) return false; octave_value_list args; args.append(as_value()); args.append(make_value_hack(rhs)); octave_value_list argout(member_invoke(m, args, 1)); if (argout.length() < 1) return false; ret = argout(0); return true; } bool dispatch_index_op(const std::string &symbol, const octave_value_list &rhs, octave_value_list &ret) { member_value_pair *m = find_member(symbol, false); if (!m || m->first->is_static() || m->first->is_global()) return false; octave_value_list args; args.append(as_value()); args.append(rhs); octave_value_list argout(member_invoke(m, args, 1)); if (argout.length() >= 1) ret = argout(0); return true; } octave_value_list member_deref(member_value_pair *m, const octave_value_list &args) { if (m->second.is_defined()) return m->second; else if (m->first) { if (m->first->get_method) return m->first->get_method(args, 1); else if (m->first->method) return octave_value(new octave_builtin(m->first->method)); } error("undefined member"); return octave_value_list(); } static octave_value make_value_hack(const octave_base_value &x) { ((octave_swig_type &) x).count++; return octave_value((octave_base_value *) &x); } octave_swig_type(const octave_swig_type &x); octave_swig_type &operator=(const octave_swig_type &rhs); public: octave_swig_type(void *_ptr = 0, const swig_type_info *_type = 0, int _own = 0, bool _always_static = false) : module(0), construct_type(_ptr ? 0 : _type), own(_own), always_static(_always_static) { if (_type || _ptr) types.push_back(std::make_pair(_type, _ptr)); #ifdef SWIG_DIRECTORS if (_ptr) { Swig::Director *d = Swig::get_rtdir(_ptr); if (d) Swig::swig_director_set_self(d, this); } #endif } ~octave_swig_type() { if (own) { ++count; for (unsigned int j = 0; j < types.size(); ++j) { if (!types[j].first || !types[j].first->clientdata) continue; swig_octave_class *c = (swig_octave_class *) types[j].first->clientdata; if (c->destructor && !types[j].second.destroyed && types[j].second.ptr) { c->destructor(as_value(), 0); } } } #ifdef SWIG_DIRECTORS for (unsigned int j = 0; j < types.size(); ++j) Swig::erase_rtdir(types[j].second.ptr); #endif } dim_vector dims(void) const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); // Find the __dims__ method of this object member_value_pair *m = nc_this->find_member("__dims__", false); if (!m) return dim_vector(1,1); // Call the __dims__ method of this object octave_value_list inarg; inarg.append(nc_this->as_value()); octave_value_list outarg = nc_this->member_invoke(m, inarg, 1); // __dims__ should return (at least) one output argument if (outarg.length() < 1) return dim_vector(1,1); octave_value & out = outarg(0); // Return value should be cell or matrix of integers if (out.is_cell()) { const Cell & c=out.cell_value(); int ndim = c.rows(); if (ndim==1 && c.columns()!=1) ndim = c.columns(); dim_vector d; d.resize(ndim < 2 ? 2 : ndim); d(0) = d(1) = 1; // Fill in dim_vector for (int k=0;k a = out.int_vector_value(); if (error_state) return dim_vector(1,1); dim_vector d; d.resize(a.numel() < 2 ? 2 : a.numel()); d(0) = d(1) = 1; for (int k=0;kclientdata) return 0; swig_octave_class *c = (swig_octave_class *) types[0].first->clientdata; return c->constructor_doc; } std::string swig_type_name() const { // * need some way to manually name subclasses. // * eg optional first arg to subclass(), or named_subclass() std::string ret; for (unsigned int j = 0; j < types.size(); ++j) { if (j) ret += "_"; if (types[j].first->clientdata) { swig_octave_class *c = (swig_octave_class *) types[j].first->clientdata; ret += c->name; } else ret += types[j].first->name; } return ret; } void merge(octave_swig_type &rhs) { rhs.own = 0; for (unsigned int j = 0; j < rhs.types.size(); ++j) { assert(!rhs.types[j].second.destroyed); #ifdef SWIG_DIRECTORS Swig::Director *d = Swig::get_rtdir(rhs.types[j].second.ptr); if (d) Swig::swig_director_set_self(d, this); #endif } types.insert(types.end(), rhs.types.begin(), rhs.types.end()); members.insert(rhs.members.begin(), rhs.members.end()); rhs.types.clear(); rhs.members.clear(); } typedef member_map::const_iterator swig_member_const_iterator; swig_member_const_iterator swig_members_begin() { return members.begin(); } swig_member_const_iterator swig_members_end() { return members.end(); } void *cast(swig_type_info *type, int *_own, int flags) { if (_own) *_own = own; if (flags &SWIG_POINTER_DISOWN) own = 0; if (!type && types.size()) return types[0].second.ptr; for (unsigned int j = 0; j < types.size(); ++j) if (type == types[j].first) return types[j].second.ptr; for (unsigned int j = 0; j < types.size(); ++j) { swig_cast_info *tc = SWIG_TypeCheck(types[j].first->name, type); if (!tc) continue; int newmemory = 0; void *vptr = SWIG_TypeCast(tc, types[j].second.ptr, &newmemory); assert(!newmemory); // newmemory handling not yet implemented return vptr; } return 0; } bool is_owned() const { return own; } #ifdef SWIG_DIRECTORS void director_destroyed(Swig::Director *d) { bool found = false; for (unsigned int j = 0; j < types.size(); ++j) { Swig::Director *dj = Swig::get_rtdir(types[j].second.ptr); if (dj == d) { types[j].second.destroyed = true; found = true; } } assert(found); } #endif void assign(const std::string &name, const octave_value &ov) { members[name] = std::make_pair((const swig_octave_member *) 0, ov); } void assign(const std::string &name, const swig_octave_member *m) { members[name] = std::make_pair(m, octave_value()); } octave_base_value *clone() const { // pass-by-value is probably not desired, and is harder; // requires calling copy constructors of contained types etc. assert(0); *(int *) 0 = 0; return 0; } octave_base_value *empty_clone() const { return new octave_swig_type(); } bool is_defined() const { return true; } virtual bool is_map() const { return true; } virtual octave_value subsref(const std::string &ops, const std::list < octave_value_list > &idx) { octave_value_list ovl = subsref(ops, idx, 1); return ovl.length()? ovl(0) : octave_value(); } virtual octave_value_list subsref(const std::string &ops, const std::list < octave_value_list > &idx, int nargout) { assert(ops.size() > 0); assert(ops.size() == idx.size()); std::list < octave_value_list >::const_iterator idx_it = idx.begin(); int skip = 0; octave_value_list sub_ovl; // constructor invocation if (ops[skip] == '(' && construct_type) { assert(construct_type->clientdata); swig_octave_class *c = (swig_octave_class *) construct_type->clientdata; if (!c->constructor) { error("cannot create instance"); return octave_value_list(); } octave_value_list args; if (c->director) args.append(Swig::swig_value_ref(new octave_swig_type(this, 0, 0))); args.append(*idx_it++); ++skip; sub_ovl = c->constructor(args, nargout); } // member dereference or invocation else if (ops[skip] == '.') { std::string subname; const swig_type_info *base = 0; // eg, a.base.base_cpp_mem for (;;) { octave_value_list subname_ovl(*idx_it++); ++skip; assert(subname_ovl.length() == 1 && subname_ovl(0).is_string()); subname = subname_ovl(0).string_value(); const swig_type_info *next_base = find_base(subname, base); if (!next_base || skip >= (int) ops.size() || ops[skip] != '.') break; base = next_base; } member_value_pair tmp, *m = &tmp; if (!base || !(m->first = find_member(base, subname))) m = find_member(subname, false); if (!m) { error("member not found"); return octave_value_list(); } octave_value_list args; if (!always_static && (!m->first || (!m->first->is_static() && !m->first->is_global()))) args.append(as_value()); if (skip < (int) ops.size() && ops[skip] == '(' && ((m->first && m->first->method) || m->second.is_function() || m->second.is_function_handle())) { args.append(*idx_it++); ++skip; sub_ovl = member_invoke(m, args, nargout); } else { sub_ovl = member_deref(m, args); } } // index operator else { if (ops[skip] == '(' || ops[skip] == '{') { const char *op_name = ops[skip] == '(' ? "__paren__" : "__brace__"; octave_value_list args; args.append(*idx_it++); ++skip; if (!dispatch_index_op(op_name, args, sub_ovl)) { error("error evaluating index operator"); return octave_value_list(); } } else { error("unsupported subsref"); return octave_value_list(); } } if (skip >= (int) ops.size()) return sub_ovl; if (sub_ovl.length() < 1) { error("bad subs ref"); return octave_value_list(); } return sub_ovl(0).next_subsref(nargout, ops, idx, skip); } octave_value subsasgn(const std::string &ops, const std::list < octave_value_list > &idx, const octave_value &rhs) { assert(ops.size() > 0); assert(ops.size() == idx.size()); std::list < octave_value_list >::const_iterator idx_it = idx.begin(); int skip = 0; if (ops.size() > 1) { std::list < octave_value_list >::const_iterator last = idx.end(); --last; std::list < octave_value_list > next_idx(idx.begin(), last); octave_value next_ov = subsref(ops.substr(0, ops.size() - 1), next_idx); next_ov.subsasgn(ops.substr(ops.size() - 1), std::list < octave_value_list > (1, *last), rhs); } else if (ops[skip] == '(' || ops[skip] == '{') { const char *op_name = ops[skip] == '(' ? "__paren_asgn__" : "__brace_asgn__"; member_value_pair *m = find_member(op_name, false); if (m) { octave_value_list args; args.append(as_value()); args.append(*idx_it); args.append(rhs); member_invoke(m, args, 1); } else error("%s member not found", op_name); } else if (ops[skip] == '.') { octave_value_list subname_ovl(*idx_it++); ++skip; assert(subname_ovl.length() == 1 &&subname_ovl(0).is_string()); std::string subname = subname_ovl(0).string_value(); member_value_pair *m = find_member(subname, true); if (!m->first || !m->first->set_method) { m->first = 0; m->second = rhs; } else if (m->first->set_method) { octave_value_list args; if (!m->first->is_static() && !m->first->is_global()) args.append(as_value()); args.append(rhs); m->first->set_method(args, 1); } else error("member not assignable"); } else error("unsupported subsasgn"); return as_value(); } virtual bool is_object() const { return true; } virtual bool is_string() const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); return !!nc_this->find_member("__str__", false); } virtual std::string string_value(bool force = false) const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); member_value_pair *m = nc_this->find_member("__str__", false); if (!m) { error("__str__ method not defined"); return std::string(); } octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1); if (outarg.length() < 1 || !outarg(0).is_string()) { error("__str__ method did not return a string"); return std::string(); } return outarg(0).string_value(); } #if SWIG_OCTAVE_PREREQ(3,3,52) virtual octave_map map_value() const { return octave_map(); } #else virtual Octave_map map_value() const { return Octave_map(); } #endif virtual string_vector map_keys() const { member_map tmp; load_members(tmp); string_vector keys(tmp.size()); int k = 0; for (member_map::iterator it = tmp.begin(); it != tmp.end(); ++it) keys(k++) = it->first; return keys; } virtual bool save_ascii (std::ostream& os) { return true; } virtual bool load_ascii (std::istream& is) { return true; } virtual bool save_binary (std::ostream& os, bool& save_as_floats) { return true; } virtual bool load_binary (std::istream& is, bool swap, oct_mach_info::float_format fmt) { return true; } #if defined (HAVE_HDF5) virtual bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { return true; } virtual bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { return true; } #endif virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const { return string_value(); } virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const { return string_value(); } static bool dispatch_global_op(const std::string &symbol, const octave_value_list &args, octave_value &ret) { // we assume that SWIG_op_prefix-prefixed functions are installed in global namespace // (rather than any module namespace). octave_function *fcn = is_valid_function(symbol, std::string(), false); if (!fcn) return false; ret = fcn->do_multi_index_op(1, args)(0); return true; } static octave_value dispatch_unary_op(const octave_base_value &x, const char *op_name) { octave_swig_type *ost = Swig::swig_value_deref(x); assert(ost); octave_value ret; if (ost->dispatch_unary_op(std::string("__") + op_name + std::string("__"), ret)) return ret; std::string symbol = SWIG_op_prefix + ost->swig_type_name() + "_" + op_name; octave_value_list args; args.append(make_value_hack(x)); if (dispatch_global_op(symbol, args, ret)) return ret; error("could not dispatch unary operator"); return octave_value(); } static octave_value dispatch_binary_op(const octave_base_value &lhs, const octave_base_value &rhs, const char *op_name) { octave_swig_type *lhs_ost = Swig::swig_value_deref(lhs); octave_swig_type *rhs_ost = Swig::swig_value_deref(rhs); octave_value ret; if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name + std::string("__"), rhs, ret)) return ret; if (rhs_ost) { if (strlen(op_name) == 2 && (op_name[1] == 't' || op_name[1] == 'e')) { if (op_name[0] == 'l' && rhs_ost->dispatch_binary_op(std::string("__g") + op_name[1] + std::string("__"), lhs, ret)) return ret; if (op_name[0] == 'g' && rhs_ost->dispatch_binary_op(std::string("__l") + op_name[1] + std::string("__"), lhs, ret)) return ret; } if (rhs_ost->dispatch_binary_op(std::string("__r") + op_name + std::string("__"), lhs, ret)) return ret; } std::string symbol; octave_value_list args; args.append(make_value_hack(lhs)); args.append(make_value_hack(rhs)); symbol = SWIG_op_prefix; symbol += lhs_ost ? lhs_ost->swig_type_name() : lhs.type_name(); symbol += "_"; symbol += op_name; symbol += "_"; symbol += rhs_ost ? rhs_ost->swig_type_name() : rhs.type_name(); if (dispatch_global_op(symbol, args, ret)) return ret; symbol = SWIG_op_prefix; symbol += lhs_ost ? lhs_ost->swig_type_name() : lhs.type_name(); symbol += "_"; symbol += op_name; symbol += "_"; symbol += "any"; if (dispatch_global_op(symbol, args, ret)) return ret; symbol = SWIG_op_prefix; symbol += "any"; symbol += "_"; symbol += op_name; symbol += "_"; symbol += rhs_ost ? rhs_ost->swig_type_name() : rhs.type_name(); if (dispatch_global_op(symbol, args, ret)) return ret; error("could not dispatch binary operator"); return octave_value(); } void print(std::ostream &os, bool pr_as_read_syntax = false) const { if (is_string()) { os << string_value(); return; } member_map tmp; load_members(tmp); indent(os); os << "{"; newline(os); increment_indent_level(); for (unsigned int j = 0; j < types.size(); ++j) { indent(os); if (types[j].first->clientdata) { const swig_octave_class *c = (const swig_octave_class *) types[j].first->clientdata; os << c->name << ", ptr = " << types[j].second.ptr; newline(os); } else { os << types[j].first->name << ", ptr = " << types[j].second.ptr; newline(os); } } for (member_map::const_iterator it = tmp.begin(); it != tmp.end(); ++it) { indent(os); if (it->second.first) { const char *objtype = it->second.first->method ? "method" : "variable"; const char *modifier = (it->second.first->flags &1) ? "static " : (it->second.first->flags &2) ? "global " : ""; os << it->second.first->name << " (" << modifier << objtype << ")"; newline(os); assert(it->second.first->name == it->first); } else { os << it->first; newline(os); } } decrement_indent_level(); indent(os); os << "}"; newline(os); } }; // Octave tries hard to preserve pass-by-value semantics. Eg, assignments // will call clone() via make_unique() if there is more than one outstanding // reference to the lhs, and forces the clone's reference count to 1 // (so you can't just increment your own count and return this). // // One way to fix this (without modifying Octave) is to add a level of // indirection such that clone copies ref-counted pointer and we keep // pass-by-ref semantics (which are more natural/expected for C++ bindings). // // Supporting both pass-by-{ref,value} and toggling via %feature/option // might be nice. class octave_swig_ref:public octave_base_value { octave_swig_type *ptr; public: octave_swig_ref(octave_swig_type *_ptr = 0) :ptr(_ptr) { } ~octave_swig_ref() { if (ptr) ptr->decref(); } octave_swig_type *get_ptr() const { return ptr; } octave_base_value *clone() const { if (ptr) ptr->incref(); return new octave_swig_ref(ptr); } octave_base_value *empty_clone() const { return new octave_swig_ref(0); } dim_vector dims(void) const { return ptr->dims(); } bool is_defined() const { return ptr->is_defined(); } virtual bool is_map() const { return ptr->is_map(); } virtual octave_value subsref(const std::string &ops, const std::list < octave_value_list > &idx) { return ptr->subsref(ops, idx); } virtual octave_value_list subsref(const std::string &ops, const std::list < octave_value_list > &idx, int nargout) { return ptr->subsref(ops, idx, nargout); } octave_value subsasgn(const std::string &ops, const std::list < octave_value_list > &idx, const octave_value &rhs) { return ptr->subsasgn(ops, idx, rhs); } virtual bool is_object() const { return ptr->is_object(); } virtual bool is_string() const { return ptr->is_string(); } virtual std::string string_value(bool force = false) const { return ptr->string_value(force); } #if SWIG_OCTAVE_PREREQ(3,3,52) virtual octave_map map_value() const { return ptr->map_value(); } #else virtual Octave_map map_value() const { return ptr->map_value(); } #endif virtual string_vector map_keys() const { return ptr->map_keys(); } virtual bool save_ascii (std::ostream& os) { return ptr->save_ascii(os); } virtual bool load_ascii (std::istream& is) { return ptr->load_ascii(is); } virtual bool save_binary (std::ostream& os, bool& save_as_floats) { return ptr->save_binary(os, save_as_floats); } virtual bool load_binary (std::istream& is, bool swap, oct_mach_info::float_format fmt) { return ptr->load_binary(is, swap, fmt); } #if defined (HAVE_HDF5) virtual bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { return ptr->save_hdf5(loc_id, name, save_as_floats); } virtual bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { return ptr->load_hdf5(loc_id, name, have_h5giterate_bug); } #endif virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const { return ptr->convert_to_str(pad, force, type); } virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const { return ptr->convert_to_str_internal(pad, force, type); } void print(std::ostream &os, bool pr_as_read_syntax = false) const { return ptr->print(os, pr_as_read_syntax); } private: DECLARE_OCTAVE_ALLOCATOR; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA; }; DEFINE_OCTAVE_ALLOCATOR(octave_swig_ref); DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_ref, "swig_ref", "swig_ref"); class octave_swig_packed:public octave_base_value { swig_type_info *type; std::vector < char > buf; public: octave_swig_packed(swig_type_info *_type = 0, const void *_buf = 0, size_t _buf_len = 0) : type(_type), buf((const char*)_buf, (const char*)_buf + _buf_len) { } bool copy(swig_type_info *outtype, void *ptr, size_t sz) const { if (outtype && outtype != type) return false; assert(sz <= buf.size()); std::copy(buf.begin(), buf.begin()+sz, (char*)ptr); return true; } octave_base_value *clone() const { return new octave_swig_packed(*this); } octave_base_value *empty_clone() const { return new octave_swig_packed(); } bool is_defined() const { return true; } void print(std::ostream &os, bool pr_as_read_syntax = false) const { indent(os); os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size(); newline(os); } virtual bool save_ascii (std::ostream& os) { return true; } virtual bool load_ascii (std::istream& is) { return true; } virtual bool save_binary (std::ostream& os, bool& save_as_floats) { return true; } virtual bool load_binary (std::istream& is, bool swap, oct_mach_info::float_format fmt) { return true; } #if defined (HAVE_HDF5) virtual bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { return true; } virtual bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { return true; } #endif private: DECLARE_OCTAVE_ALLOCATOR; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA; }; DEFINE_OCTAVE_ALLOCATOR(octave_swig_packed); DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_packed, "swig_packed", "swig_packed"); SWIGRUNTIME octave_value_list octave_set_immutable(const octave_value_list &args, int nargout) { error("attempt to set immutable member variable"); return octave_value_list(); } struct octave_value_ref { const octave_value_list &ovl; int j; octave_value_ref(const octave_value_list &_ovl, int _j) :ovl(_ovl), j(_j) { } operator octave_value() const { return ovl(j); } octave_value operator*() const { return ovl(j); } }; namespace Swig { SWIGRUNTIME octave_base_value *swig_value_ref(octave_swig_type *ost) { return new octave_swig_ref(ost); } SWIGRUNTIME octave_swig_type *swig_value_deref(octave_value ov) { if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); return swig_value_deref(*ov.internal_rep()); } SWIGRUNTIME octave_swig_type *swig_value_deref(const octave_base_value &ov) { if (ov.type_id() != octave_swig_ref::static_type_id()) return 0; const octave_swig_ref *osr = static_cast < const octave_swig_ref *>(&ov); return osr->get_ptr(); } } #define swig_unary_op(name) \ SWIGRUNTIME octave_value swig_unary_op_##name(const octave_base_value &x) { \ return octave_swig_type::dispatch_unary_op(x,#name); \ } #define swig_binary_op(name) \ SWIGRUNTIME octave_value swig_binary_op_##name(const octave_base_value&lhs,const octave_base_value &rhs) { \ return octave_swig_type::dispatch_binary_op(lhs,rhs,#name); \ } #define swigreg_unary_op(name) \ if (!octave_value_typeinfo::lookup_unary_op(octave_value::op_##name,tid)) \ octave_value_typeinfo::register_unary_op(octave_value::op_##name,tid,swig_unary_op_##name); #define swigreg_binary_op(name) \ if (!octave_value_typeinfo::lookup_binary_op(octave_value::op_##name,tid1,tid2)) \ octave_value_typeinfo::register_binary_op(octave_value::op_##name,tid1,tid2,swig_binary_op_##name); swig_unary_op(not); swig_unary_op(uplus); swig_unary_op(uminus); swig_unary_op(transpose); swig_unary_op(hermitian); swig_unary_op(incr); swig_unary_op(decr); swig_binary_op(add); swig_binary_op(sub); swig_binary_op(mul); swig_binary_op(div); swig_binary_op(pow); swig_binary_op(ldiv); swig_binary_op(lshift); swig_binary_op(rshift); swig_binary_op(lt); swig_binary_op(le); swig_binary_op(eq); swig_binary_op(ge); swig_binary_op(gt); swig_binary_op(ne); swig_binary_op(el_mul); swig_binary_op(el_div); swig_binary_op(el_pow); swig_binary_op(el_ldiv); swig_binary_op(el_and); swig_binary_op(el_or); SWIGRUNTIME void SWIG_InstallUnaryOps(int tid) { swigreg_unary_op(not); swigreg_unary_op(uplus); swigreg_unary_op(uminus); swigreg_unary_op(transpose); swigreg_unary_op(hermitian); swigreg_unary_op(incr); swigreg_unary_op(decr); } SWIGRUNTIME void SWIG_InstallBinaryOps(int tid1, int tid2) { swigreg_binary_op(add); swigreg_binary_op(sub); swigreg_binary_op(mul); swigreg_binary_op(div); swigreg_binary_op(pow); swigreg_binary_op(ldiv); swigreg_binary_op(lshift); swigreg_binary_op(rshift); swigreg_binary_op(lt); swigreg_binary_op(le); swigreg_binary_op(eq); swigreg_binary_op(ge); swigreg_binary_op(gt); swigreg_binary_op(ne); swigreg_binary_op(el_mul); swigreg_binary_op(el_div); swigreg_binary_op(el_pow); swigreg_binary_op(el_ldiv); swigreg_binary_op(el_and); swigreg_binary_op(el_or); } SWIGRUNTIME void SWIG_InstallOps(int tid) { // here we assume that tid are conseq integers increasing from zero, and // that our tid is the last one. might be better to have explicit string // list of types we should bind to, and use lookup_type to resolve their tid. SWIG_InstallUnaryOps(tid); SWIG_InstallBinaryOps(tid, tid); for (int j = 0; j < tid; ++j) { SWIG_InstallBinaryOps(j, tid); SWIG_InstallBinaryOps(tid, j); } } SWIGRUNTIME octave_value SWIG_Octave_NewPointerObj(void *ptr, swig_type_info *type, int flags) { int own = (flags &SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; #ifdef SWIG_DIRECTORS Swig::Director *d = Swig::get_rtdir(ptr); if (d && Swig::swig_director_get_self(d)) return Swig::swig_director_get_self(d)->as_value(); #endif return Swig::swig_value_ref(new octave_swig_type(ptr, type, own)); } SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_type_info *type, int flags, int *own) { if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); if (!ov.is_defined() || (ov.is_matrix_type() && ov.rows() == 0 && ov.columns() == 0) ) { if (ptr) *ptr = 0; return SWIG_OK; } if (ov.type_id() != octave_swig_ref::static_type_id()) return SWIG_ERROR; octave_swig_ref *osr = static_cast < octave_swig_ref *>(ov.internal_rep()); octave_swig_type *ost = osr->get_ptr(); void *vptr = ost->cast(type, own, flags); if (!vptr) return SWIG_ERROR; if (ptr) *ptr = vptr; return SWIG_OK; } SWIGRUNTIME octave_value SWIG_Octave_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return new octave_swig_packed(type, (char *) ptr, sz); } SWIGRUNTIME int SWIG_Octave_ConvertPacked(const octave_value &ov, void *ptr, size_t sz, swig_type_info *type) { if (!ov.is_defined()) return SWIG_ERROR; if (ov.type_id() != octave_swig_packed::static_type_id()) return SWIG_ERROR; octave_swig_packed *ost = static_cast < octave_swig_packed *>(ov.internal_rep()); return ost->copy(type, (char *) ptr, sz) ? SWIG_OK : SWIG_ERROR; } SWIGRUNTIMEINLINE void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) { module_ns->assign(name, ov); } SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) { return get_global_value(name, true); } SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) { set_global_value(name, value); } SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) { #if !SWIG_OCTAVE_PREREQ(3,2,0) link_to_global_variable(curr_sym_tab->lookup(name, true)); #else #if !SWIG_OCTAVE_PREREQ(3,8,0) symbol_table::varref(name); #endif symbol_table::mark_global(name); #endif } SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) { octave_value ov = SWIG_Octave_GetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION); if (!ov.is_defined() || ov.type_id() != octave_swig_packed::static_type_id()) return 0; const octave_swig_packed* osp = static_cast < const octave_swig_packed *> (ov.internal_rep()); swig_module_info *pointer = 0; osp->copy(0, &pointer, sizeof(swig_module_info *)); return pointer; } SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) { octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *)); SWIG_Octave_SetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION, ov); } swig-3.0.2/Lib/octave/std_container.i0000664000175000017500000000007312343605122017340 0ustar williamwilliam%include %include swig-3.0.2/Lib/octave/cmalloc.i0000664000175000017500000000004012343605122016110 0ustar williamwilliam%include swig-3.0.2/Lib/octave/octfragments.swg0000664000175000017500000000000112343605122017537 0ustar williamwilliam swig-3.0.2/Lib/octave/attribute.i0000664000175000017500000000004212343605122016503 0ustar williamwilliam%include swig-3.0.2/Lib/octave/implicit.i0000664000175000017500000000043712343605122016322 0ustar williamwilliam%include %include #warning "This file provides the %implicit directive, which is an old and fragile" #warning "way to implement the C++ implicit conversion mechanism." #warning "Try using the more robust '%implicitconv Type;' directive instead." swig-3.0.2/Lib/octave/cdata.i0000664000175000017500000000003612343605122015557 0ustar williamwilliam%include swig-3.0.2/Lib/octave/boost_shared_ptr.i0000664000175000017500000003655012343605122020056 0ustar williamwilliam%include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(out) CONST TYPE { %set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(varout) CONST TYPE { %set_varoutput(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE * { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain reference %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE & { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = *%const_cast(tempshared.get(), $1_ltype); } else { $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer by reference // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); temp = %const_cast(tempshared.get(), $*1_ltype); } else { temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); } $1 = &temp; } %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} %typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { int newmem = 0; void *argp = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varout typemap not implemented" %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); if ($owner) delete $1; } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varout typemap not implemented" %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); temp = &tempshared; $1 = &temp; } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varout typemap not implemented" %} // Typecheck typemaps // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); $1 = SWIG_CheckState(res); } // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.2/Lib/octave/carrays.i0000664000175000017500000000020112343605122016141 0ustar williamwilliam%define %array_class(TYPE,NAME) %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__) %enddef %include swig-3.0.2/Lib/octave/std_common.i0000664000175000017500000000443512343605122016654 0ustar williamwilliam%include %include // Generate the traits for a 'primitive' type, such as 'double', // for which the SWIG_AsVal and SWIG_From methods are already defined. %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval { typedef Type value_type; static int asval(octave_value obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from { typedef Type value_type; static octave_value from(const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit instantiations required using %template). The STL containers define the 'front' method and the typemap below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from required in the generated code for enums. */ %define %traits_enum(Type...) %fragment("SWIG_Traits_enum_"{Type},"header", fragment=SWIG_AsVal_frag(int), fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(octave_value obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; template <> struct traits_from { typedef Type value_type; static octave_value from(const value_type& val) { return SWIG_From(int)((int)val); } }; } } %typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} %enddef %include // // Generates the traits for all the known primitive // C++ types (int, double, ...) // %apply_cpptypes(%traits_ptypen); swig-3.0.2/Lib/octave/std_list.i0000664000175000017500000000124512343605122016333 0ustar williamwilliam// Lists %fragment("StdListTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(const octave_value& obj, std::list **lis) { return traits_asptr_stdseq >::asptr(obj, lis); } }; template struct traits_from > { static octave_value *from(const std::list & vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.2/Lib/octave/octruntime.swg0000664000175000017500000002466112343605122017256 0ustar williamwilliam%insert(runtime) %{ #include #include #include #include #include #include #include #include #include #include #include %} %insert(runtime) "swigrun.swg"; %insert(runtime) "swigerrors.swg"; %insert(runtime) "octrun.swg"; %insert(initbeforefunc) "swiginit.swg" %insert(initbeforefunc) %{ static bool SWIG_init_user(octave_swig_type* module_ns); SWIGINTERN bool SWIG_Octave_LoadModule(std::string name) { bool retn; { #if !SWIG_OCTAVE_PREREQ(3,3,50) unwind_protect::begin_frame("SWIG_Octave_LoadModule"); unwind_protect_int(error_state); unwind_protect_int(warning_state); unwind_protect_bool(discard_error_messages); unwind_protect_bool(discard_warning_messages); #else unwind_protect frame; frame.protect_var(error_state); frame.protect_var(warning_state); frame.protect_var(discard_error_messages); frame.protect_var(discard_warning_messages); #endif error_state = 0; warning_state = 0; discard_error_messages = true; discard_warning_messages = true; feval(name, octave_value_list(), 0); retn = (error_state == 0); #if !SWIG_OCTAVE_PREREQ(3,3,50) unwind_protect::run_frame("SWIG_Octave_LoadModule"); #endif } if (!retn) { error(SWIG_name_d ": could not load module `%s'", name.c_str()); } return retn; } SWIGINTERN bool SWIG_Octave_InstallFunction(octave_function *octloadfcn, std::string name) { bool retn; { #if !SWIG_OCTAVE_PREREQ(3,3,50) unwind_protect::begin_frame("SWIG_Octave_InstallFunction"); unwind_protect_int(error_state); unwind_protect_int(warning_state); unwind_protect_bool(discard_error_messages); unwind_protect_bool(discard_warning_messages); #else unwind_protect frame; frame.protect_var(error_state); frame.protect_var(warning_state); frame.protect_var(discard_error_messages); frame.protect_var(discard_warning_messages); #endif error_state = 0; warning_state = 0; discard_error_messages = true; discard_warning_messages = true; octave_value_list args; args.append(name); args.append(octloadfcn->fcn_file_name()); error_state = 0; feval("autoload", args, 0); retn = (error_state == 0); #if !SWIG_OCTAVE_PREREQ(3,3,50) unwind_protect::run_frame("SWIG_Octave_InstallFunction"); #endif } if (!retn) { error(SWIG_name_d ": could not load function `%s'", name.c_str()); } return retn; } static const char *const subclass_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Function} {} subclass()\n\ @deftypefnx{Loadable Function} {} subclass(@var{swigclass}, @var{name}, @var{fcn}, @dots{})\n\ Subclass a C++ class from within Octave, and provide implementations of its virtual methods.\n\ \n\ See the SWIG manual for usage examples.\n\ @end deftypefn"; DEFUN_DLD( subclass, args, nargout, subclass_usage ) { octave_swig_type *top = new octave_swig_type; for (int j = 0; j < args.length(); ++j) { if (args(j).type_id() == octave_swig_ref::static_type_id()) { octave_swig_ref *osr = static_cast < octave_swig_ref *>(args(j).internal_rep()); octave_swig_type *ost = osr->get_ptr(); if (!ost->is_owned()) { error("subclass: cannot subclass object not constructed on octave side"); return octave_value_list(); } top->merge(*ost); } else if (args(j).is_function_handle()) { top->assign(args(j).fcn_handle_value()->fcn_name(), args(j)); } else if (args(j).is_string()) { if (j + 1 >= args.length()) { error("subclass: member assignments must be of string,value form"); return octave_value_list(); } top->assign(args(j).string_value(), args(j + 1)); ++j; } else { error("subclass: invalid arguments to subclass()"); return octave_value_list(); } } return octave_value(Swig::swig_value_ref(top)); } static const char *const swig_type_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Function} {} swig_type(@var{swigref})\n\ Return the underlying C/C++ type name of a SWIG-wrapped object.\n\ @end deftypefn"; DEFUN_DLD( swig_type, args, nargout, swig_type_usage ) { if (args.length() != 1) { error("swig_type: must be called with only a single object"); return octave_value_list(); } octave_swig_type *ost = Swig::swig_value_deref(args(0)); if (!ost) { error("swig_type: object is not a swig_ref"); return octave_value_list(); } return octave_value(ost->swig_type_name()); } static const char *const swig_typequery_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Function} {} swig_typequery(@var{string})\n\ Return @var{string} if it is a recognised SWIG-wrapped C/C++ type name;\n\ otherwise return `'.\n\ @end deftypefn"; DEFUN_DLD( swig_typequery, args, nargout, swig_typequery_usage ) { if (args.length() != 1 || !args(0).is_string()) { error("swig_typequery: must be called with single string argument"); return octave_value_list(); } swig_module_info *module = SWIG_GetModule(0); swig_type_info *type = SWIG_TypeQueryModule(module, module, args(0).string_value().c_str()); if (!type) return octave_value(""); return octave_value(type->name); } static const char *const swig_this_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Function} {} swig_this(@var{swigref})\n\ Return the underlying C/C++ pointer of a SWIG-wrapped object.\n\ @end deftypefn"; DEFUN_DLD( swig_this, args, nargout, swig_this_usage ) { if (args.length() != 1) { error("swig_this: must be called with only a single object"); return octave_value_list(); } if (args(0).is_matrix_type() && args(0).rows() == 0 && args(0).columns() == 0) return octave_value(octave_uint64(0)); octave_swig_type *ost = Swig::swig_value_deref(args(0)); if (!ost) { error("swig_this: object is not a swig_ref"); return octave_value_list(); } return octave_value(octave_uint64((unsigned long long) ost->swig_this())); } static const char *const SWIG_name_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Module} {} " SWIG_name_d "\n\ Loads the SWIG-generated module `" SWIG_name_d "'.\n\ @end deftypefn"; DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { static octave_swig_type* module_ns = 0; // workaround to prevent octave seg-faulting on exit: set Octave exit function // octave_exit to _Exit, which exits immediately without trying to cleanup memory. // definitely affects version 3.2.*, not sure about 3.3.*, seems to be fixed in // version 3.4.* and above. can be turned off with macro definition. #ifndef SWIG_OCTAVE_NO_SEGFAULT_HACK #if SWIG_OCTAVE_PREREQ(3,2,0) && !SWIG_OCTAVE_PREREQ(3,4,1) octave_exit = ::_Exit; #endif #endif // check for no input and output args if (args.length() != 0 || nargout != 0) { print_usage(); return octave_value_list(); } // create module on first function call if (!module_ns) { // workaround bug in octave where installing global variable of custom type and then // exiting without explicitly clearing the variable causes octave to segfault. #if SWIG_OCTAVE_PREREQ(3,2,0) octave_value_list eval_args; eval_args.append("base"); eval_args.append("function __swig_atexit__; " " if mislocked() " " clear -all; " " else " " mlock(); " " endif; " "endfunction; " "__swig_atexit__; " "atexit(\"__swig_atexit__\", false); " "atexit(\"__swig_atexit__\")"); feval("evalin", eval_args, 0); #endif octave_swig_ref::register_type(); octave_swig_packed::register_type(); SWIG_InitializeModule(0); SWIG_PropagateClientData(); octave_function *me = octave_call_stack::current(); if (!SWIG_Octave_InstallFunction(me, "swig_type")) { return octave_value_list(); } if (!SWIG_Octave_InstallFunction(me, "swig_typequery")) { return octave_value_list(); } if (!SWIG_Octave_InstallFunction(me, "swig_this")) { return octave_value_list(); } if (!SWIG_Octave_InstallFunction(me, "subclass")) { return octave_value_list(); } octave_swig_type* cvar_ns=0; if (std::string(SWIG_global_name) != ".") { cvar_ns=new octave_swig_type; for (int j=0;swig_globals[j].name;++j) if (swig_globals[j].get_method) cvar_ns->assign(swig_globals[j].name,&swig_globals[j]); } module_ns=new octave_swig_type(0, 0, 0, true); if (std::string(SWIG_global_name) != ".") { module_ns->assign(SWIG_global_name,Swig::swig_value_ref(cvar_ns)); } else { for (int j=0;swig_globals[j].name;++j) if (swig_globals[j].get_method) module_ns->assign(swig_globals[j].name,&swig_globals[j]); } for (int j=0;swig_globals[j].name;++j) if (swig_globals[j].method) module_ns->assign(swig_globals[j].name,&swig_globals[j]); // * need better solution here; swig_type -> octave_class mapping is // * really n-to-1, in some cases such as template partial spec, etc. // * see failing tests. for (int j=0;swig_types[j];++j) if (swig_types[j]->clientdata) { swig_octave_class* c=(swig_octave_class*)swig_types[j]->clientdata; module_ns->assign(c->name, Swig::swig_value_ref (new octave_swig_type(0,swig_types[j]))); } if (!SWIG_init_user(module_ns)) { delete module_ns; module_ns=0; return octave_value_list(); } SWIG_InstallOps(octave_swig_ref::static_type_id()); octave_swig_type::swig_member_const_iterator mb; for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) { if (mb->second.first && mb->second.first->method) { if (!SWIG_Octave_InstallFunction(me, mb->first)) { return octave_value_list(); } } } #if !SWIG_OCTAVE_PREREQ(3,2,0) mlock(me->name()); #else mlock(); #endif } octave_swig_type::swig_member_const_iterator mb; for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) { if (mb->second.second.is_defined()) { SWIG_Octave_SetGlobalValue(mb->first, mb->second.second); SWIG_Octave_LinkGlobalValue(mb->first); } } SWIG_Octave_SetGlobalValue(SWIG_name_d, module_ns->as_value()); SWIG_Octave_LinkGlobalValue(SWIG_name_d); return octave_value_list(); } %} swig-3.0.2/Lib/octave/factory.i0000664000175000017500000000004012343605122016145 0ustar williamwilliam%include swig-3.0.2/Lib/octave/octtypemaps.swg0000664000175000017500000000463212343605122017431 0ustar williamwilliam // Include fundamental fragment definitions %include // Look for user fragments file. %include // Octave fragments for primitive types %include // Octave fragments for char* strings //%include #ifndef SWIG_DIRECTOR_TYPEMAPS #define SWIG_DIRECTOR_TYPEMAPS #endif // Octave types #define SWIG_Object octave_value #define VOID_Object octave_value() /* // Octave allows implicit conversion #define %implicitconv_flag $implicitconv */ // append output #define SWIG_AppendOutput(result, obj) SWIG_Octave_AppendOutput(result, obj) // set constant #define SWIG_SetConstant(name, obj) SWIG_Octave_SetConstant(module_ns,name,obj) // raise #define SWIG_Octave_Raise(OBJ, TYPE, DESC) error("C++ side threw an exception of type " TYPE) #define SWIG_Raise(obj, type, desc) SWIG_Octave_Raise(obj, type, desc) // Include the unified typemap library %include %typecheck(SWIG_TYPECHECK_SWIGOBJECT) SWIG_Object "$1 = (*$input).is_defined();"; %typecheck(SWIG_TYPECHECK_SWIGOBJECT) octave_value_list "$1 = true;"; %typemap(in) (octave_value_list varargs,...) { for (int j=$argnum-1;jappend($1); } %typemap(out,noblock=1) octave_map, Octave_map { $result=$1; } %typemap(out,noblock=1) NDArray { $result=$1; } %typemap(out,noblock=1) Cell { $result=$1; } /* // Smart Pointers %typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER { $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags); } %typemap(ret) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER { octave_swig_type* lobj=Swig::swig_value_deref($result); if (lobj) { std::list idx; idx.push_back(octave_value("__deref__")); idx.push_back(octave_value_list()); octave_value_list ovl(lobj->subsref(".(",idx)); octave_swig_type* robj=ovl.length()>=1?Swig::swig_value_deref(ovl(0)):0; if (robj && !error_state) lobj->append(robj); } } */ swig-3.0.2/Lib/octave/std_alloc.i0000664000175000017500000000003312343605122016444 0ustar williamwilliam%include swig-3.0.2/Lib/octave/exception.i0000664000175000017500000000021312343605122016476 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) } swig-3.0.2/Lib/octave/std_carray.i0000664000175000017500000000000012343605122016625 0ustar williamwilliamswig-3.0.2/Lib/octave/octprimtypes.swg0000664000175000017500000001253712343605122017626 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ // boolean %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(bool)(bool value) { return octave_value(value); } } %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(const octave_value& ov, bool *val) { if (!ov.is_bool_type()) return SWIG_ERROR; if (val) *val = ov.bool_value(); return SWIG_OK; } } // long %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(long) (long value) { return octave_value(value); } } %fragment(SWIG_AsVal_frag(long),"header") { SWIGINTERN int SWIG_AsVal_dec(long)(const octave_value& ov, long* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (ov.is_double_type()||ov.is_single_type()) { double v=ov.double_value(); if (v!=floor(v)) return SWIG_TypeError; } if (val) *val = ov.long_value(); return SWIG_OK; } } // unsigned long %fragment(SWIG_From_frag(unsigned long),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(unsigned long) (unsigned long value) { return octave_value(value); } } %fragment(SWIG_AsVal_frag(unsigned long),"header") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(const octave_value& ov, unsigned long* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (ov.is_double_type()||ov.is_single_type()) { double v=ov.double_value(); if (v<0) return SWIG_OverflowError; if (v!=floor(v)) return SWIG_TypeError; } if (ov.is_int8_type()||ov.is_int16_type()|| ov.is_int32_type()) { long v=ov.long_value(); if (v<0) return SWIG_OverflowError; } if (ov.is_int64_type()) { long long v=ov.int64_scalar_value().value(); if (v<0) return SWIG_OverflowError; } if (val) *val = ov.ulong_value(); return SWIG_OK; } } // long long %fragment(SWIG_From_frag(long long),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(long long) (long long value) { return octave_int64(value); } } %fragment(SWIG_AsVal_frag(long long),"header") { SWIGINTERN int SWIG_AsVal_dec(long long)(const octave_value& ov, long long* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (ov.is_double_type()||ov.is_single_type()) { double v=ov.double_value(); if (v!=floor(v)) return SWIG_TypeError; } if (val) { if (ov.is_int64_type()) *val = ov.int64_scalar_value().value(); else if (ov.is_uint64_type()) *val = ov.uint64_scalar_value().value(); else *val = ov.long_value(); } return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned long long),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(unsigned long long) (unsigned long long value) { return octave_uint64(value); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(const octave_value& ov, unsigned long long* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (ov.is_double_type()||ov.is_single_type()) { double v=ov.double_value(); if (v<0) return SWIG_OverflowError; if (v!=floor(v)) return SWIG_TypeError; } if (ov.is_int8_type()||ov.is_int16_type()|| ov.is_int32_type()) { long v=ov.long_value(); if (v<0) return SWIG_OverflowError; } if (ov.is_int64_type()) { long long v=ov.int64_scalar_value().value(); if (v<0) return SWIG_OverflowError; } if (val) { if (ov.is_int64_type()) *val = ov.int64_scalar_value().value(); else if (ov.is_uint64_type()) *val = ov.uint64_scalar_value().value(); else *val = ov.long_value(); } return SWIG_OK; } } // double %fragment(SWIG_From_frag(double),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(double) (double value) { return octave_value(value); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(const octave_value& ov, double* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (val) *val = ov.double_value(); return SWIG_OK; } } // const char* (strings) %fragment("SWIG_AsCharPtrAndSize","header") { SWIGINTERN int SWIG_AsCharPtrAndSize(octave_value ov, char** cptr, size_t* psize, int *alloc) { if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); if (!ov.is_string()) return SWIG_TypeError; std::string str=ov.string_value(); size_t len=str.size(); char* cstr=(char*)str.c_str(); if (alloc) { *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; } else if (cptr) *cptr = cstr; if (psize) *psize = len + 1; return SWIG_OK; } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE octave_value SWIG_FromCharPtrAndSize(const char* carray, size_t size) { return std::string(carray,carray+size); } } swig-3.0.2/Lib/octave/octopers.swg0000664000175000017500000000515712343605122016722 0ustar williamwilliam/* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus // operators supported in Octave, and the methods they are routed to // __brace__ a{args} // __brace_asgn__ a{args} = rhs // __paren__ a(args) // __paren_asgn__ a(args) = rhs // __str__ generates string rep // __not__ !a // __uplus__ +a // __uminus__ -a // __transpose__ a.' // __hermitian__ a' // __incr__ a++ // __decr__ a-- // __add__ a + b // __sub__ a - b // __mul__ a * b // __div__ a / b // __pow__ a ^ b // __ldiv__ a \ b // __lshift__ a << b // __rshift__ a >> b // __lt__ a < b // __le__ a <= b // __eq__ a == b // __ge__ a >= b // __gt__ a > b // __ne__ a != b // __el_mul__ a .* b // __el_div__ a ./ b // __el_pow__ a .^ b // __el_ldiv__ a .\ b // __el_and__ a & b // __el_or__ a | b // operators supported in C++, and the methods that route to them %rename(__add__) *::operator+; %rename(__add__) *::operator+(); %rename(__add__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__uminus__) *::operator-(); %rename(__uminus__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__mod__) *::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(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__not__) *::operator!; %rename(__incr__) *::operator++; %rename(__decr__) *::operator--; %rename(__paren__) *::operator(); %rename(__brace__) *::operator[]; // Ignored inplace operators %ignoreoperator(PLUSEQ) operator+=; %ignoreoperator(MINUSEQ) operator-=; %ignoreoperator(MULEQ) operator*=; %ignoreoperator(DIVEQ) operator/=; %ignoreoperator(MODEQ) operator%=; %ignoreoperator(LSHIFTEQ) operator<<=; %ignoreoperator(RSHIFTEQ) operator>>=; %ignoreoperator(ANDEQ) operator&=; %ignoreoperator(OREQ) operator|=; %ignoreoperator(XOREQ) operator^=; // Ignored operators %ignoreoperator(EQ) operator=; %ignoreoperator(ARROWSTAR) operator->*; #endif /* __cplusplus */ swig-3.0.2/Lib/octave/octave.swg0000664000175000017500000000033612343605122016337 0ustar williamwilliam%include %include %include %include %include %include %define %docstring %feature("docstring") %enddef swig-3.0.2/Lib/octave/std_vector.i0000664000175000017500000000127412343605122016664 0ustar williamwilliam// Vectors %fragment("StdVectorTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(const octave_value& obj, std::vector **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static octave_value from(const std::vector& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.2/Lib/octave/std_string.i0000664000175000017500000000004312343605122016661 0ustar williamwilliam%include swig-3.0.2/Lib/octave/std_basic_string.i0000664000175000017500000000441512343605122020031 0ustar williamwilliam#if !defined(SWIG_STD_STRING) #define SWIG_STD_BASIC_STRING #define SWIG_STD_MODERN_STL %include #define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(octave_value obj, std::string **val) { if (obj.is_string()) { if (val) *val = new std::string(obj.string_value()); return SWIG_NEWOBJ; } if (val) error("a string is expected"); return 0; } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE octave_value SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } %ignore std::basic_string::operator +=; %include %typemaps_asptrfromn(%checkcode(STRING), std::basic_string); #endif #if !defined(SWIG_STD_WSTRING) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsWCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(PyObject* obj, std::wstring **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::wstring *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { PyErr_Clear(); wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::wstring(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } else { PyErr_Clear(); } if (val) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_TypeError,"a wstring is expected"); SWIG_PYTHON_THREAD_END_BLOCK; } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromWCharPtrAndSize") { SWIGINTERNINLINE PyObject* SWIG_From(std::basic_string)(const std::wstring& s) { return SWIG_FromWCharPtrAndSize(s.data(), s.size()); } } %typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string); #endif swig-3.0.2/Lib/octave/std_except.i0000664000175000017500000000004312343605122016643 0ustar williamwilliam%include swig-3.0.2/Lib/octave/octstdcommon.swg0000664000175000017500000001405212343605122017567 0ustar williamwilliam%fragment("StdTraits","header",fragment="StdTraitsCommon") { namespace swig { // Traits that provides the from method template struct traits_from_ptr { static octave_value from(Type *val, int owner = 0) { return SWIG_NewPointerObj(val, type_info(), owner); } }; template struct traits_from { static octave_value from(const Type& val) { return traits_from_ptr::from(new Type(val), 1); } }; template struct traits_from { static octave_value from(Type* val) { return traits_from_ptr::from(val, 0); } }; template struct traits_from { static octave_value from(const Type* val) { return traits_from_ptr::from(const_cast(val), 0); } }; template inline octave_value from(const Type& val) { return traits_from::from(val); } template inline octave_value from_ptr(Type* val, int owner) { return traits_from_ptr::from(val, owner); } // Traits that provides the asval/as/check method template struct traits_asptr { static int asptr(const octave_value& obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template inline int asptr(const octave_value& obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } template struct traits_asval { static int asval(const octave_value& obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); if (!SWIG_IsOK(res)) return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; if (SWIG_IsNewObj(res)){ %delete(p); res = SWIG_DelNewMask(res); } return res; } else { return SWIG_ERROR; } } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template struct traits_asval { static int asval(const octave_value& obj, Type **val) { if (val) { typedef typename noconst_traits::noconst_type noconst_type; noconst_type *p = 0; int res = traits_asptr::asptr(obj, &p); if (SWIG_IsOK(res)) { *(const_cast(val)) = p; } return res; } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template inline int asval(const octave_value& obj, Type *val) { return traits_asval::asval(obj, val); } template struct traits_as { static Type as(const octave_value& obj, bool throw_error) { Type v; int res = asval(obj, &v); if (!obj.is_defined() || !SWIG_IsOK(res)) { if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); } return v; } }; template struct traits_as { static Type as(const octave_value& obj, bool throw_error) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { Type r(*v); %delete(v); return r; } else { return *v; } } else { // Uninitialized return value, no Type() constructor required. static Type *v_def = (Type*) malloc(sizeof(Type)); if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); memset(v_def,0,sizeof(Type)); return *v_def; } } }; template struct traits_as { static Type* as(const octave_value& obj, bool throw_error) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res)) { return v; } else { if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); return 0; } } }; template inline Type as(const octave_value& obj, bool te = false) { return traits_as::category>::as(obj, te); } template struct traits_check { static bool check(const octave_value& obj) { int res = asval(obj, (Type *)(0)); return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { static bool check(const octave_value& obj) { int res = asptr(obj, (Type **)(0)); return SWIG_IsOK(res) ? true : false; } }; template inline bool check(const octave_value& obj) { return traits_check::category>::check(obj); } } } %define %specialize_std_container(Type,Check,As,From) %{ namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(const octave_value& obj, value_type *val) { if (Check(obj)) { if (val) *val = As(obj); return SWIG_OK; } return SWIG_ERROR; } }; template <> struct traits_from { typedef Type value_type; static octave_value from(const value_type& val) { return From(val); } }; template <> struct traits_check { static int check(const octave_value& obj) { int res = Check(obj); return obj && res ? res : 0; } }; } %} %enddef #define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) swig-3.0.2/Lib/octave/stl.i0000664000175000017500000000026512343605122015311 0ustar williamwilliam/* initial STL definition. extended as needed in each language */ %include %include %include %include %include swig-3.0.2/Lib/octave/std_deque.i0000664000175000017500000000124712343605122016465 0ustar williamwilliam// Deques %fragment("StdDequeTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(octave_value obj, std::deque **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static octave_value from(const std::deque & vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_deque_methods(Type...) %swig_sequence_methods(Type) #define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.2/Lib/octave/octcomplex.swg0000664000175000017500000000450012343605122017230 0ustar williamwilliam/* Defines the As/From conversors for double/float complex, you need to provide complex Type, the Name you want to use in the conversors, the complex Constructor method, and the Real and Imag complex accesor methods. See the std_complex.i and ccomplex.i for concrete examples. */ /* the common from conversor */ %define %swig_fromcplx_conv(Type, OctConstructor, Real, Imag) %fragment(SWIG_From_frag(Type),"header") { SWIGINTERNINLINE octave_value SWIG_From(Type)(const Type& c) { return octave_value(OctConstructor(Real(c), Imag(c))); } } %enddef // the double case %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int SWIG_AsVal(Type) (const octave_value& ov, Type* val) { if (ov.is_complex_scalar()) { if (val) { Complex c(ov.complex_value()); *val=Constructor(c.real(),c.imag()); } return SWIG_OK; } else { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(ov, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Complex, Real, Imag); %enddef // the float case %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float)) { SWIGINTERN int SWIG_AsVal(Type) (const octave_value& ov, Type* val) { if (ov.is_complex_scalar()) { if (val) { Complex c(ov.complex_value()); double re = c.real(); double im = c.imag(); if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else return SWIG_OverflowError; } } else { float d; int res = SWIG_AddCast(SWIG_AsVal(float)(ov, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, FloatComplex, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.2/Lib/octave/octiterators.swg0000664000175000017500000002164012343605122017601 0ustar williamwilliam/* ----------------------------------------------------------------------------- * octiterators.swg * * Users can derive form the OctSwigIterator to implemet their * own iterators. As an example (real one since we use it for STL/STD * containers), the template OctSwigIterator_T does the * implementation for generic C++ iterators. * ----------------------------------------------------------------------------- */ %include %fragment("OctSwigIterator","header",fragment="") { namespace swig { struct stop_iteration { }; struct OctSwigIterator { private: octave_value _seq; protected: OctSwigIterator(octave_value seq) : _seq(seq) { } public: virtual ~OctSwigIterator() {} virtual octave_value value() const = 0; virtual OctSwigIterator *incr(size_t n = 1) = 0; virtual OctSwigIterator *decr(size_t n = 1) { throw stop_iteration(); } virtual ptrdiff_t distance(const OctSwigIterator &x) const { throw std::invalid_argument("operation not supported"); } virtual bool equal (const OctSwigIterator &x) const { throw std::invalid_argument("operation not supported"); } virtual OctSwigIterator *copy() const = 0; octave_value next() { octave_value obj = value(); incr(); return obj; } octave_value previous() { decr(); return value(); } OctSwigIterator *advance(ptrdiff_t n) { return (n > 0) ? incr(n) : decr(-n); } bool operator == (const OctSwigIterator& x) const { return equal(x); } bool operator != (const OctSwigIterator& x) const { return ! operator==(x); } OctSwigIterator* operator ++ () { incr(); return this; } OctSwigIterator* operator -- () { decr(); return this; } OctSwigIterator* operator + (ptrdiff_t n) const { return copy()->advance(n); } OctSwigIterator* operator - (ptrdiff_t n) const { return copy()->advance(-n); } ptrdiff_t operator - (const OctSwigIterator& x) const { return x.distance(*this); } static swig_type_info* descriptor() { static int init = 0; static swig_type_info* desc = 0; if (!init) { desc = SWIG_TypeQuery("swig::OctSwigIterator *"); init = 1; } return desc; } }; } } %fragment("OctSwigIterator_T","header",fragment="",fragment="OctSwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") { namespace swig { template class OctSwigIterator_T : public OctSwigIterator { public: typedef OutIterator out_iterator; typedef typename std::iterator_traits::value_type value_type; typedef OctSwigIterator_T self_type; OctSwigIterator_T(out_iterator curr, octave_value seq) : OctSwigIterator(seq), current(curr) { } const out_iterator& get_current() const { return current; } bool equal (const OctSwigIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return (current == iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } ptrdiff_t distance(const OctSwigIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return std::distance(current, iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } protected: out_iterator current; }; template struct from_oper { typedef const ValueType& argument_type; typedef octave_value result_type; result_type operator()(argument_type v) const { return swig::from(v); } }; template::value_type, typename FromOper = from_oper > class OctSwigIteratorOpen_T : public OctSwigIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef OctSwigIterator_T base; typedef OctSwigIteratorOpen_T self_type; OctSwigIteratorOpen_T(out_iterator curr, octave_value seq) : OctSwigIterator_T(curr, seq) { } octave_value value() const { return from(static_cast(*(base::current))); } OctSwigIterator *copy() const { return new self_type(*this); } OctSwigIterator *incr(size_t n = 1) { while (n--) { ++base::current; } return this; } OctSwigIterator *decr(size_t n = 1) { while (n--) { --base::current; } return this; } }; template::value_type, typename FromOper = from_oper > class OctSwigIteratorClosed_T : public OctSwigIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef OctSwigIterator_T base; typedef OctSwigIteratorClosed_T self_type; OctSwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, octave_value seq) : OctSwigIterator_T(curr, seq), begin(first), end(last) { } octave_value value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } OctSwigIterator *copy() const { return new self_type(*this); } OctSwigIterator *incr(size_t n = 1) { while (n--) { if (base::current == end) { throw stop_iteration(); } else { ++base::current; } } return this; } OctSwigIterator *decr(size_t n = 1) { while (n--) { if (base::current == begin) { throw stop_iteration(); } else { --base::current; } } return this; } private: out_iterator begin; out_iterator end; }; template inline OctSwigIterator* make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, octave_value seq = octave_value()) { return new OctSwigIteratorClosed_T(current, begin, end, seq); } template inline OctSwigIterator* make_output_iterator(const OutIter& current, octave_value seq = octave_value()) { return new OctSwigIteratorOpen_T(current, seq); } } } %fragment("OctSwigIterator"); namespace swig { // Throw a StopIteration exception %ignore stop_iteration; struct stop_iteration {}; %typemap(throws) stop_iteration { error("stop_iteration exception"); SWIG_fail; } // Mark methods that return new objects %newobject OctSwigIterator::copy; %newobject OctSwigIterator::operator + (ptrdiff_t n) const; %newobject OctSwigIterator::operator - (ptrdiff_t n) const; %nodirector OctSwigIterator; %catches(swig::stop_iteration) OctSwigIterator::value() const; %catches(swig::stop_iteration) OctSwigIterator::incr(size_t n = 1); %catches(swig::stop_iteration) OctSwigIterator::decr(size_t n = 1); %catches(std::invalid_argument) OctSwigIterator::distance(const OctSwigIterator &x) const; %catches(std::invalid_argument) OctSwigIterator::equal (const OctSwigIterator &x) const; %catches(swig::stop_iteration) OctSwigIterator::next(); %catches(swig::stop_iteration) OctSwigIterator::previous(); %catches(swig::stop_iteration) OctSwigIterator::advance(ptrdiff_t n); %catches(swig::stop_iteration) OctSwigIterator::operator += (ptrdiff_t n); %catches(swig::stop_iteration) OctSwigIterator::operator -= (ptrdiff_t n); %catches(swig::stop_iteration) OctSwigIterator::operator + (ptrdiff_t n) const; %catches(swig::stop_iteration) OctSwigIterator::operator - (ptrdiff_t n) const; struct OctSwigIterator { protected: OctSwigIterator(octave_value seq); public: virtual ~OctSwigIterator(); virtual octave_value value() const = 0; virtual OctSwigIterator *incr(size_t n = 1) = 0; virtual OctSwigIterator *decr(size_t n = 1); virtual ptrdiff_t distance(const OctSwigIterator &x) const; virtual bool equal (const OctSwigIterator &x) const; virtual OctSwigIterator *copy() const = 0; octave_value next(); octave_value previous(); OctSwigIterator *advance(ptrdiff_t n); bool operator == (const OctSwigIterator& x) const; bool operator != (const OctSwigIterator& x) const; OctSwigIterator* operator ++ (); OctSwigIterator* operator -- (); OctSwigIterator* operator + (ptrdiff_t n) const; OctSwigIterator* operator - (ptrdiff_t n) const; ptrdiff_t operator - (const OctSwigIterator& x) const; }; } swig-3.0.2/Lib/octave/std_char_traits.i0000664000175000017500000000004112343605122017654 0ustar williamwilliam%include swig-3.0.2/Lib/swigrun.swg0000664000175000017500000004033212343605122015273 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigrun.swg * * This file contains generic C API SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ #define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE # define SWIG_QUOTE_STRING(x) #x # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else # define SWIG_TYPE_TABLE_NAME #endif /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ #ifndef SWIGRUNTIME # define SWIGRUNTIME SWIGINTERN #endif #ifndef SWIGRUNTIMEINLINE # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE #endif /* Generic buffer size */ #ifndef SWIG_BUFFER_SIZE # define SWIG_BUFFER_SIZE 1024 #endif /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 /* Flags/methods for returning states. The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code } else { //fail code } Now you can be more explicit: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { // success code } else { // fail code } which is the same really, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); if (SWIG_IsOK(res)) { // success code if (SWIG_IsNewObj(res) { ... delete *ptr; } else { ... } } else { // fail code } I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as int SWIG_ConvertPtr(obj, ptr,...) { if () { if () { *ptr = ; return SWIG_NEWOBJ; } else { *ptr = ; return SWIG_OLDOBJ; } } else { return SWIG_BADOBJ; } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the SWIG errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this int food(double) int fooi(int); and you call food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) /* The NewMask denotes the object was created (using new/malloc) */ #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) /* The TmpMask is for in/out typemaps that use temporal objects */ #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) /* Simple returning values */ #define SWIG_BADOBJ (SWIG_ERROR) #define SWIG_OLDOBJ (SWIG_OK) #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) /* Check, add and del mask methods */ #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank # define SWIG_TypeRank unsigned long # endif # ifndef SWIG_MAXCASTRANK /* Default cast allowed */ # define SWIG_MAXCASTRANK (2) # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ # define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif #include #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); /* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ struct swig_cast_info *cast; /* linked list of types that can cast into this type */ void *clientdata; /* language specific type data */ int owndata; /* flag if the structure owns the clientdata */ } swig_type_info; /* Structure to store a type and conversion function used for casting */ typedef struct swig_cast_info { swig_type_info *type; /* pointer to type that is equivalent to this type */ swig_converter_func converter; /* function to cast the void pointers */ struct swig_cast_info *next; /* pointer to next cast in linked list */ struct swig_cast_info *prev; /* pointer to the previous cast */ } swig_cast_info; /* Structure used to store module information * Each module generates one structure like this, and the runtime collects * all of these structures and stores them in a circularly linked list.*/ typedef struct swig_module_info { swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ size_t size; /* Number of types in this module */ struct swig_module_info *next; /* Pointer to next element in circularly linked list */ swig_type_info **type_initial; /* Array of initially generated type structures */ swig_cast_info **cast_initial; /* Array of initially generated casting structures */ void *clientdata; /* Language specific module data */ } swig_module_info; /* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. Return 0 when the two name types are equivalent, as in strncmp, but skipping ' '. */ SWIGRUNTIME int SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } return (int)((l1 - f1) - (l2 - f2)); } /* Check type equivalence in a name list like ||... Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int SWIG_TypeCmp(const char *nb, const char *tb) { int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; } /* Check type equivalence in a name list like ||... Return 0 if not equal, 1 if equal */ SWIGRUNTIME int SWIG_TypeEquiv(const char *nb, const char *tb) { return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (strcmp(iter->type->name, c) == 0) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (iter->type == from) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ SWIGRUNTIMEINLINE const char * SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Return the pretty name associated with this type, that is an unmangled type name in a form presentable to the user. */ SWIGRUNTIME const char * SWIG_TypePrettyName(const swig_type_info *type) { /* The "str" field contains the equivalent pretty names of the type, separated by vertical-bar characters. We choose to print the last name, as it is often (?) the most specific. */ if (!type) return NULL; if (type->str != NULL) { const char *last_name = type->str; const char *s; for (s = type->str; *s; s++) if (*s == '|') last_name = s+1; return last_name; } else return type->name; } /* Set the clientdata field for a type */ SWIGRUNTIME void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } } cast = cast->next; } } SWIGRUNTIME void SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { size_t l = 0; size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { int compare = strcmp(name, iname); if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { r = i - 1; } else { break; } } else if (compare > 0) { l = i + 1; } } else { break; /* should never happen */ } } while (l <= r); } iter = iter->next; } while (iter != end); return 0; } /* Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_TypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); if (ret) { return ret; } else { /* STEP 2: If the type hasn't been found, do a complete search of the str field (the human readable name) */ swig_module_info *iter = start; do { size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; } iter = iter->next; } while (iter != end); } /* neither found a match */ return 0; } /* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; const unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } /* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { char *r = buff; if ((2*sizeof(void *) + 2) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); if (strlen(name) + 1 > (bsz - (r - buff))) return 0; strcpy(r,name); return buff; } SWIGRUNTIME const char * SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { *ptr = (void *) 0; return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sizeof(void *)); } SWIGRUNTIME char * SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { char *r = buff; size_t lname = (name ? strlen(name) : 0); if ((2*sz + 2 + lname) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); if (lname) { strncpy(r,name,lname+1); } else { *r = 0; } return buff; } SWIGRUNTIME const char * SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { memset(ptr,0,sz); return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sz); } #ifdef __cplusplus } #endif swig-3.0.2/Lib/constraints.i0000664000175000017500000001560712343605122015603 0ustar williamwilliam/* ----------------------------------------------------------------------------- * constraints.i * * SWIG constraints library. * * SWIG library file containing typemaps for implementing various kinds of * constraints. Depends upon the SWIG exception library for generating * errors in a language-independent manner. * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %text %{ %include This library provides support for applying constraints to function arguments. Using a constraint, you can restrict arguments to be positive numbers, non-NULL pointers, and so on. The following constraints are available : Number POSITIVE - Positive number (not zero) Number NEGATIVE - Negative number (not zero) Number NONZERO - Nonzero number Number NONNEGATIVE - Positive number (including zero) Number NONPOSITIVE - Negative number (including zero) Pointer NONNULL - Non-NULL pointer Pointer ALIGN8 - 8-byte aligned pointer Pointer ALIGN4 - 4-byte aligned pointer Pointer ALIGN2 - 2-byte aligned pointer To use the constraints, you need to "apply" them to specific function arguments in your code. This is done using the %apply directive. For example : %apply Number NONNEGATIVE { double nonneg }; double sqrt(double nonneg); // Name of argument must match %apply Pointer NONNULL { void *ptr }; void *malloc(int POSITIVE); // May return a NULL pointer void free(void *ptr); // May not accept a NULL pointer Any function argument of the type you specify with the %apply directive will be checked with the appropriate constraint. Multiple types may be specified as follows : %apply Pointer NONNULL { void *, Vector *, List *, double *}; In this case, all of the types listed would be checked for non-NULL pointers. The common datatypes of int, short, long, unsigned int, unsigned long, unsigned short, unsigned char, signed char, float, and double can be checked without using the %apply directive by simply using the constraint name as the parameter name. For example : double sqrt(double NONNEGATIVE); double log(double POSITIVE); If you have used typedef to change type-names, you can also do this : %apply double { Real }; // Make everything defined for doubles // work for Reals. Real sqrt(Real NONNEGATIVE); Real log(Real POSITIVE); %} #endif %include #ifdef SWIGCSHARP // Required attribute for C# exception handling #define SWIGCSHARPCANTHROW , canthrow=1 #else #define SWIGCSHARPCANTHROW #endif // Positive numbers %typemap(check SWIGCSHARPCANTHROW) int POSITIVE, short POSITIVE, long POSITIVE, unsigned int POSITIVE, unsigned short POSITIVE, unsigned long POSITIVE, signed char POSITIVE, unsigned char POSITIVE, float POSITIVE, double POSITIVE, Number POSITIVE { if ($1 <= 0) { SWIG_exception(SWIG_ValueError,"Expected a positive value."); } } // Negative numbers %typemap(check SWIGCSHARPCANTHROW) int NEGATIVE, short NEGATIVE, long NEGATIVE, unsigned int NEGATIVE, unsigned short NEGATIVE, unsigned long NEGATIVE, signed char NEGATIVE, unsigned char NEGATIVE, float NEGATIVE, double NEGATIVE, Number NEGATIVE { if ($1 >= 0) { SWIG_exception(SWIG_ValueError,"Expected a negative value."); } } // Nonzero numbers %typemap(check SWIGCSHARPCANTHROW) int NONZERO, short NONZERO, long NONZERO, unsigned int NONZERO, unsigned short NONZERO, unsigned long NONZERO, signed char NONZERO, unsigned char NONZERO, float NONZERO, double NONZERO, Number NONZERO { if ($1 == 0) { SWIG_exception(SWIG_ValueError,"Expected a nonzero value."); } } // Nonnegative numbers %typemap(check SWIGCSHARPCANTHROW) int NONNEGATIVE, short NONNEGATIVE, long NONNEGATIVE, unsigned int NONNEGATIVE, unsigned short NONNEGATIVE, unsigned long NONNEGATIVE, signed char NONNEGATIVE, unsigned char NONNEGATIVE, float NONNEGATIVE, double NONNEGATIVE, Number NONNEGATIVE { if ($1 < 0) { SWIG_exception(SWIG_ValueError,"Expected a non-negative value."); } } // Nonpositive numbers %typemap(check SWIGCSHARPCANTHROW) int NONPOSITIVE, short NONPOSITIVE, long NONPOSITIVE, unsigned int NONPOSITIVE, unsigned short NONPOSITIVE, unsigned long NONPOSITIVE, signed char NONPOSITIVE, unsigned char NONPOSITIVE, float NONPOSITIVE, double NONPOSITIVE, Number NONPOSITIVE { if ($1 > 0) { SWIG_exception(SWIG_ValueError,"Expected a non-positive value."); } } // Non-NULL pointer %typemap(check SWIGCSHARPCANTHROW) void * NONNULL, Pointer NONNULL { if (!$1) { SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); } } // Aligned pointers %typemap(check SWIGCSHARPCANTHROW) void * ALIGN8, Pointer ALIGN8 { unsigned long long tmp; tmp = (unsigned long long) $1; if (tmp & 7) { SWIG_exception(SWIG_ValueError,"Pointer must be 8-byte aligned."); } } %typemap(check SWIGCSHARPCANTHROW) void * ALIGN4, Pointer ALIGN4 { unsigned long long tmp; tmp = (unsigned long long) $1; if (tmp & 3) { SWIG_exception(SWIG_ValueError,"Pointer must be 4-byte aligned."); } } %typemap(check SWIGCSHARPCANTHROW) void * ALIGN2, Pointer ALIGN2 { unsigned long long tmp; tmp = (unsigned long long) $1; if (tmp & 1) { SWIG_exception(SWIG_ValueError,"Pointer must be 2-byte aligned."); } } swig-3.0.2/Lib/guile/0000775000175000017500000000000012343605122014156 5ustar williamwilliamswig-3.0.2/Lib/guile/guilemain.i0000664000175000017500000000203412343605122016301 0ustar williamwilliam/* ----------------------------------------------------------------------------- * guilemain.i * * The main functions for a user augmented guile * version that can handle wrapped calls as generated by SWIG * ----------------------------------------------------------------------------- */ %{ #include #ifdef __cplusplus extern "C" { #endif /* Debugger interface (don't change the order of the following lines) */ #define GDB_TYPE SCM #include GDB_INTERFACE; static void inner_main(void *closure, int argc, char **argv) { #ifdef SWIGINIT SWIGINIT #else SWIG_init(); /* SWIG init function */ #endif scm_shell(argc, argv); /* scheme interpreter */ /* never reached: scm_shell will perform an exit */ } #ifdef __cplusplus } #endif int main(int argc, char **argv) { /* put any default initialisation code here: e.g. exit handlers */ scm_boot_guile(argc, argv, inner_main, 0); /* make a stack entry for the garbage collector */ return 0; /* never reached, but avoids a warning */ } %} swig-3.0.2/Lib/guile/ports.i0000664000175000017500000000247012343605122015502 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ports.i * * Guile typemaps for handling ports * ----------------------------------------------------------------------------- */ %{ #ifndef _POSIX_SOURCE /* This is needed on Solaris for fdopen(). */ # define _POSIX_SOURCE 199506L #endif #include #include #include %} /* This typemap for FILE * accepts (1) FILE * pointer objects, (2) Scheme file ports. In this case, it creates a temporary C stream which reads or writes from a dup'ed file descriptor. */ %typemap(in, doc="$NAME is a file port or a FILE * pointer") FILE * { if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) != 0) { if (!(SCM_FPORTP($input))) { scm_wrong_type_arg("$symname", $argnum, $input); } else { int fd; if (SCM_OUTPUT_PORT_P($input)) { scm_force_output($input); } fd=dup(SCM_FPORT_FDES($input)); if (fd==-1) { scm_misc_error("$symname", strerror(errno), SCM_EOL); } $1=fdopen(fd, SCM_OUTPUT_PORT_P($input) ? (SCM_INPUT_PORT_P($input) ? "r+" : "w") : "r"); if ($1==NULL) { scm_misc_error("$symname", strerror(errno), SCM_EOL); } } } } %typemap(freearg) FILE* { if ($1) { fclose($1); } } swig-3.0.2/Lib/guile/guile_scm_run.swg0000664000175000017500000003373412343605122017545 0ustar williamwilliam/* ----------------------------------------------------------------------------- * guile_scm_run.swg * ----------------------------------------------------------------------------- */ #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* In the code below, use guile 2.0 compatible functions where possible. Functions that don't exist in older versions will be mapped to a deprecated equivalent for those versions only */ #if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) static SCM scm_module_variable (SCM module, SCM sym) { return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); } #endif #if SCM_MAJOR_VERSION >= 2 /* scm_c_define_gsubr takes a different parameter type depending on the guile version */ typedef scm_t_subr swig_guile_proc; #else typedef SCM (*swig_guile_proc)(); #endif typedef SCM (*guile_destructor)(SCM); typedef struct swig_guile_clientdata { guile_destructor destroy; SCM goops_class; } swig_guile_clientdata; #if SCM_MAJOR_VERSION <= 2 #define scm_to_utf8_string scm_to_locale_string #define scm_from_utf8_string scm_from_locale_string #endif #define SWIG_scm2str(s) \ SWIG_Guile_scm2newstr(s, NULL) #define SWIG_str02scm(str) \ str ? scm_from_utf8_string(str) : SCM_BOOL_F # define SWIG_malloc(size) \ scm_malloc(size) # define SWIG_free(mem) \ free(mem) #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_Guile_ConvertPtr(s, result, type, flags) #define SWIG_MustGetPtr(s, type, argnum, flags) \ SWIG_Guile_MustGetPtr(s, type, argnum, flags, FUNC_NAME) #define SWIG_NewPointerObj(ptr, type, owner) \ SWIG_Guile_NewPointerObj((void*)ptr, type, owner) #define SWIG_PointerAddress(object) \ SWIG_Guile_PointerAddress(object) #define SWIG_PointerType(object) \ SWIG_Guile_PointerType(object) #define SWIG_IsPointerOfType(object, type) \ SWIG_Guile_IsPointerOfType(object, type) #define SWIG_IsPointer(object) \ SWIG_Guile_IsPointer(object) #define SWIG_contract_assert(expr, msg) \ if (!(expr)) \ scm_error(scm_from_locale_symbol("swig-contract-assertion-failed"), \ (char *) FUNC_NAME, (char *) msg, \ SCM_EOL, SCM_BOOL_F); else /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) \ SWIG_Guile_ConvertMember(obj, ptr, sz, ty, FUNC_NAME) #define SWIG_NewMemberObj(ptr, sz, type) \ SWIG_Guile_NewMemberObj(ptr, sz, type, FUNC_NAME) /* Runtime API */ static swig_module_info *SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)); #define SWIG_GetModule(clientdata) SWIG_Guile_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) SWIGINTERN char * SWIG_Guile_scm2newstr(SCM str, size_t *len) { #define FUNC_NAME "SWIG_Guile_scm2newstr" char *ret; SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME); ret = scm_to_utf8_string(str); if (!ret) return NULL; if (len) *len = strlen(ret) - 1; return ret; #undef FUNC_NAME } static int swig_initialized = 0; static scm_t_bits swig_tag = 0; static scm_t_bits swig_collectable_tag = 0; static scm_t_bits swig_destroyed_tag = 0; static scm_t_bits swig_member_function_tag = 0; static SCM swig_make_func = SCM_EOL; static SCM swig_keyword = SCM_EOL; static SCM swig_symbol = SCM_EOL; #define SWIG_Guile_GetSmob(x) \ ( !scm_is_null(x) && SCM_INSTANCEP(x) && scm_is_true(scm_slot_exists_p(x, swig_symbol)) \ ? scm_slot_ref(x, swig_symbol) : (x) ) SWIGINTERN SCM SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner) { if (ptr == NULL) return SCM_EOL; else { SCM smob; swig_guile_clientdata *cdata = (swig_guile_clientdata *) type->clientdata; if (owner) SCM_NEWSMOB2(smob, swig_collectable_tag, ptr, (void *) type); else SCM_NEWSMOB2(smob, swig_tag, ptr, (void *) type); if (!cdata || SCM_NULLP(cdata->goops_class) || swig_make_func == SCM_EOL ) { return smob; } else { /* the scm_make() C function only handles the creation of gf, methods and classes (no instances) the (make ...) function is later redefined in goops.scm. So we need to call that Scheme function. */ return scm_apply(swig_make_func, scm_list_3(cdata->goops_class, swig_keyword, smob), SCM_EOL); } } } SWIGINTERN unsigned long SWIG_Guile_PointerAddress(SCM object) { SCM smob = SWIG_Guile_GetSmob(object); if (SCM_NULLP(smob)) return 0; else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob) || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) { return (unsigned long) (void *) SCM_CELL_WORD_1(smob); } else scm_wrong_type_arg("SWIG-Guile-PointerAddress", 1, object); } SWIGINTERN swig_type_info * SWIG_Guile_PointerType(SCM object) { SCM smob = SWIG_Guile_GetSmob(object); if (SCM_NULLP(smob)) return NULL; else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob) || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) { return (swig_type_info *) SCM_CELL_WORD_2(smob); } else scm_wrong_type_arg("SWIG-Guile-PointerType", 1, object); } SWIGINTERN int SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags) { swig_cast_info *cast; swig_type_info *from; SCM smob = SWIG_Guile_GetSmob(s); if (SCM_NULLP(smob)) { *result = NULL; return SWIG_OK; } else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { /* we do not accept smobs representing destroyed pointers */ from = (swig_type_info *) SCM_CELL_WORD_2(smob); if (!from) return SWIG_ERROR; if (type) { cast = SWIG_TypeCheckStruct(from, type); if (cast) { int newmemory = 0; *result = SWIG_TypeCast(cast, (void *) SCM_CELL_WORD_1(smob), &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return SWIG_OK; } else { return SWIG_ERROR; } } else { *result = (void *) SCM_CELL_WORD_1(smob); return SWIG_OK; } } return SWIG_ERROR; } SWIGINTERNINLINE void * SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type, int argnum, int flags, const char *func_name) { void *result; int res = SWIG_Guile_ConvertPtr(s, &result, type, flags); if (!SWIG_IsOK(res)) { /* type mismatch */ scm_wrong_type_arg((char *) func_name, argnum, s); } return result; } SWIGINTERNINLINE int SWIG_Guile_IsPointerOfType (SCM s, swig_type_info *type) { void *result; if (SWIG_Guile_ConvertPtr(s, &result, type, 0)) { /* type mismatch */ return 0; } else return 1; } SWIGINTERNINLINE int SWIG_Guile_IsPointer (SCM s) { /* module might not be initialized yet, so initialize it */ SWIG_GetModule(0); return SWIG_Guile_IsPointerOfType (s, NULL); } /* Mark a pointer object non-collectable */ SWIGINTERN void SWIG_Guile_MarkPointerNoncollectable(SCM s) { SCM smob = SWIG_Guile_GetSmob(s); if (!SCM_NULLP(smob)) { if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { SCM_SET_CELL_TYPE(smob, swig_tag); } else scm_wrong_type_arg(NULL, 0, s); } } /* Mark a pointer object destroyed */ SWIGINTERN void SWIG_Guile_MarkPointerDestroyed(SCM s) { SCM smob = SWIG_Guile_GetSmob(s); if (!SCM_NULLP(smob)) { if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { SCM_SET_CELL_TYPE(smob, swig_destroyed_tag); } else scm_wrong_type_arg(NULL, 0, s); } } /* Member functions */ SWIGINTERN SCM SWIG_Guile_NewMemberObj(void *ptr, size_t sz, swig_type_info *type, const char *func_name) { SCM smob; void *copy = malloc(sz); memcpy(copy, ptr, sz); SCM_NEWSMOB2(smob, swig_member_function_tag, copy, (void *) type); return smob; } SWIGINTERN int SWIG_Guile_ConvertMember(SCM smob, void *ptr, size_t sz, swig_type_info *type, const char *func_name) { swig_cast_info *cast; swig_type_info *from; if (SCM_SMOB_PREDICATE(swig_member_function_tag, smob)) { from = (swig_type_info *) SCM_CELL_WORD_2(smob); if (!from) return SWIG_ERROR; if (type) { cast = SWIG_TypeCheckStruct(from, type); if (!cast) return SWIG_ERROR; } memcpy(ptr, (void *) SCM_CELL_WORD_1(smob), sz); return SWIG_OK; } return SWIG_ERROR; } /* Init */ SWIGINTERN int print_swig_aux (SCM swig_smob, SCM port, scm_print_state *pstate, const char *attribute) { swig_type_info *type; type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob); if (type) { scm_puts((char *) "#<", port); scm_puts((char *) attribute, port); scm_puts((char *) "swig-pointer ", port); scm_puts((char *) SWIG_TypePrettyName(type), port); scm_puts((char *) " ", port); scm_intprint((long) SCM_CELL_WORD_1(swig_smob), 16, port); scm_puts((char *) ">", port); /* non-zero means success */ return 1; } else { return 0; } } SWIGINTERN int print_swig (SCM swig_smob, SCM port, scm_print_state *pstate) { return print_swig_aux(swig_smob, port, pstate, ""); } SWIGINTERN int print_collectable_swig (SCM swig_smob, SCM port, scm_print_state *pstate) { return print_swig_aux(swig_smob, port, pstate, "collectable-"); } SWIGINTERN int print_destroyed_swig (SCM swig_smob, SCM port, scm_print_state *pstate) { return print_swig_aux(swig_smob, port, pstate, "destroyed-"); } SWIGINTERN int print_member_function_swig (SCM swig_smob, SCM port, scm_print_state *pstate) { swig_type_info *type; type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob); if (type) { scm_puts((char *) "#<", port); scm_puts((char *) "swig-member-function-pointer ", port); scm_puts((char *) SWIG_TypePrettyName(type), port); scm_puts((char *) " >", port); /* non-zero means success */ return 1; } else { return 0; } } SWIGINTERN SCM equalp_swig (SCM A, SCM B) { if (SCM_CELL_WORD_0(A) == SCM_CELL_WORD_0(B) && SCM_CELL_WORD_1(A) == SCM_CELL_WORD_1(B) && SCM_CELL_WORD_2(A) == SCM_CELL_WORD_2(B)) return SCM_BOOL_T; else return SCM_BOOL_F; } SWIGINTERN size_t free_swig(SCM A) { swig_type_info *type = (swig_type_info *) SCM_CELL_WORD_2(A); if (type) { if (type->clientdata && ((swig_guile_clientdata *)type->clientdata)->destroy) ((swig_guile_clientdata *)type->clientdata)->destroy(A); } return 0; } SWIGINTERN size_t free_swig_member_function(SCM A) { free((swig_type_info *) SCM_CELL_WORD_1(A)); return 0; } SWIGINTERN int ensure_smob_tag(SCM swig_module, scm_t_bits *tag_variable, const char *smob_name, const char *scheme_variable_name) { SCM variable = scm_module_variable(swig_module, scm_from_locale_symbol(scheme_variable_name)); if (scm_is_false(variable)) { *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0); scm_c_module_define(swig_module, scheme_variable_name, scm_from_ulong(*tag_variable)); return 1; } else { *tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable)); return 0; } } SWIGINTERN SCM SWIG_Guile_Init () { static SCM swig_module; if (swig_initialized) return swig_module; swig_initialized = 1; swig_module = scm_c_resolve_module("Swig swigrun"); if (ensure_smob_tag(swig_module, &swig_tag, "swig-pointer", "swig-pointer-tag")) { scm_set_smob_print(swig_tag, print_swig); scm_set_smob_equalp(swig_tag, equalp_swig); } if (ensure_smob_tag(swig_module, &swig_collectable_tag, "collectable-swig-pointer", "collectable-swig-pointer-tag")) { scm_set_smob_print(swig_collectable_tag, print_collectable_swig); scm_set_smob_equalp(swig_collectable_tag, equalp_swig); scm_set_smob_free(swig_collectable_tag, free_swig); } if (ensure_smob_tag(swig_module, &swig_destroyed_tag, "destroyed-swig-pointer", "destroyed-swig-pointer-tag")) { scm_set_smob_print(swig_destroyed_tag, print_destroyed_swig); scm_set_smob_equalp(swig_destroyed_tag, equalp_swig); } if (ensure_smob_tag(swig_module, &swig_member_function_tag, "swig-member-function-pointer", "swig-member-function-pointer-tag")) { scm_set_smob_print(swig_member_function_tag, print_member_function_swig); scm_set_smob_free(swig_member_function_tag, free_swig_member_function); } swig_make_func = scm_permanent_object( scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make"))); swig_keyword = scm_permanent_object(scm_from_locale_keyword((char*) "init-smob")); swig_symbol = scm_permanent_object(scm_from_locale_symbol("swig-smob")); #ifdef SWIG_INIT_RUNTIME_MODULE SWIG_INIT_RUNTIME_MODULE #endif return swig_module; } SWIGINTERN swig_module_info * SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) { SCM module = SWIG_Guile_Init(); SCM variable = scm_module_variable(module, scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME)); if (scm_is_false(variable)) { return NULL; } else { return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable)); } } SWIGINTERN void SWIG_Guile_SetModule(swig_module_info *swig_module) { SCM module = SWIG_Guile_Init(); scm_module_define(module, scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), scm_from_ulong((unsigned long) swig_module)); } SWIGINTERN int SWIG_Guile_GetArgs (SCM *dest, SCM rest, int reqargs, int optargs, const char *procname) { int i; int num_args_passed = 0; for (i = 0; i // ------------------------------------------------------------------------ // std::map // // The aim of all that follows would be to integrate std::map with // Guile as much as possible, namely, to allow the user to pass and // be returned Scheme association lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::map), f(const std::map&), f(const std::map*): // the parameter being read-only, either a Scheme alist or a // previously wrapped std::map can be passed. // -- f(std::map&), f(std::map*): // the parameter must be modified; therefore, only a wrapped std::map // can be passed. // -- std::map f(): // the map is returned by copy; therefore, a Scheme alist // is returned which is most easily used in other Scheme functions // -- std::map& f(), std::map* f(), const std::map& f(), // const std::map* f(): // the map is returned by reference; therefore, a wrapped std::map // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { $1 = std::map(); } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; while (!scm_is_null(alist)) { K* k; T* x; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[*k] = *x; alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { temp = std::map(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { K* k; T* x; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[*k] = *x; alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { SCM alist = SCM_EOL; for (std::map::reverse_iterator i=$i.rbegin(); i!=$i.rend(); ++i) { K* key = new K(i->first); T* val = new T(i->second); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); SCM entry = scm_cons(k,x); alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { /* native sequence? */ if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ K* k; T* x; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { /* wrapped map? */ std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { /* native sequence? */ if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ K* k; T* x; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { /* wrapped map? */ std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& __getitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(const K& key, const T& x) { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scm_cons(k,result); } return result; } } }; // specializations for built-ins %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { $1 = std::map(); } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; while (!scm_is_null(alist)) { T* x; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[CONVERT_FROM(key)] = *x; alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { temp = std::map(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { T* x; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[CONVERT_FROM(key)] = *x; alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { SCM alist = SCM_EOL; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { T* val = new T(i->second); SCM k = CONVERT_TO(i->first); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); SCM entry = scm_cons(k,x); alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only T* x; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only T* x; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(K key, const T& x) { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { std::map::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { SCM k = CONVERT_TO(i->first); result = scm_cons(k,result); } return result; } } }; %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { $1 = std::map(); } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; while (!scm_is_null(alist)) { K* k; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[*k] = CONVERT_FROM(val); alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { temp = std::map(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { K* k; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[*k] = CONVERT_FROM(val); alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { SCM alist = SCM_EOL; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = CONVERT_TO(i->second); SCM entry = scm_cons(k,x); alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only K* k; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (CHECK(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only K* k; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (CHECK(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(const K& key, T x) { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scm_cons(k,result); } return result; } } }; %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) template<> class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { $1 = std::map(); } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; while (!scm_is_null(alist)) { SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { temp = std::map(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { SCM alist = SCM_EOL; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { SCM k = CONVERT_K_TO(i->first); SCM x = CONVERT_T_TO(i->second); SCM entry = scm_cons(k,x); alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (CHECK_T(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (CHECK_T(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(K key, T x) { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { std::map::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { SCM k = CONVERT_K_TO(i->first); result = scm_cons(k,result); } return result; } } }; %enddef specialize_std_map_on_key(bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_key(int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_key(short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_key(long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_key(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_key(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_key(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_key(double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_key(float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_key(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_value(bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_value(int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_value(short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_value(long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_value(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_value(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_value(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_value(double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_value(float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_value(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); } swig-3.0.2/Lib/guile/std_pair.i0000664000175000017500000011751112343605122016143 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // // See std_vector.i for the rationale of typemap application // ------------------------------------------------------------------------ %{ #include %} // exported class namespace std { template struct pair { %typemap(in) pair %{ if (scm_is_pair($input)) { T* x; U* y; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(*x,*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } %} %typemap(in) const pair& (std::pair *temp = 0), const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { T* x; U* y; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); temp = new std::pair< T, U >(*x,*y); $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); U* y = new U($1.second); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); $result = scm_cons(first,second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (scm_is_pair($input)) { T* x; U* y; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (scm_is_pair($input)) { T* x; U* y; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // specializations for built-ins %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair %{ if (scm_is_pair($input)) { U* y; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(CONVERT_FROM(first),*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } %} %typemap(in) const pair& (std::pair *temp = 0), const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { U* y; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); temp = new std::pair< T, U >(CONVERT_FROM(first),*y); $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { U* y = new U($1.second); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); $result = scm_cons(CONVERT_TO($1.first),second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (scm_is_pair($input)) { U* y; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (scm_is_pair($input)) { U* y; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair %{ if (scm_is_pair($input)) { T* x; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); $1 = std::make_pair(*x,CONVERT_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } %} %typemap(in) const pair& (std::pair *temp = 0), const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { T* x; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); temp = new std::pair< T, U >(*x,CONVERT_FROM(second)); $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); $result = scm_cons(first,CONVERT_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (scm_is_pair($input)) { T* x; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && CHECK(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (scm_is_pair($input)) { T* x; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && CHECK(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) template<> struct pair { %typemap(in) pair %{ if (scm_is_pair($input)) { SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); $1 = std::make_pair(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } %} %typemap(in) const pair& (std::pair *temp = 0), const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); temp = new std::pair< T, U >(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { $result = scm_cons(CONVERT_T_TO($1.first), CONVERT_U_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (scm_is_pair($input)) { SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (scm_is_pair($input)) { SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef specialize_std_pair_on_first(bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_first(int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_first(short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_first(long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_first(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_first(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_first(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_first(double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_first(float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_first(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_second(bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_second(int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_second(short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_second(long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_second(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_second(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_second(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_second(double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_second(float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_second(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); } swig-3.0.2/Lib/guile/typemaps.i0000664000175000017500000003663212343605122016204 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Guile-specific typemaps * ----------------------------------------------------------------------------- */ /* Pointers */ %typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); } %typemap(freearg) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] ""; %typemap(in) void * { $1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0); } %typemap(freearg) void * ""; %typemap(varin) SWIGTYPE * { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0); } %typemap(varin) SWIGTYPE & { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin) SWIGTYPE && { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin) SWIGTYPE [] { scm_wrong_type_arg((char *) FUNC_NAME, 1, $input); } %typemap(varin) SWIGTYPE [ANY] { void *temp; int ii; $1_basetype *b = 0; temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0); b = ($1_basetype *) $1; for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii); } %typemap(varin) void * { $1 = SWIG_MustGetPtr($input, NULL, 1, 0); } %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { $result = SWIG_NewPointerObj ($1, $descriptor, $owner); } %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); $result = SWIG_NewPointerObj ($1, ty, $owner); } %typemap(varout) SWIGTYPE *, SWIGTYPE [] { $result = SWIG_NewPointerObj ($1, $descriptor, 0); } %typemap(varout) SWIGTYPE & { $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0); } %typemap(varout) SWIGTYPE && { $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0); } %typemap(throws) SWIGTYPE { $<ype temp = new $ltype($1); scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_NewPointerObj(temp, $&descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE & { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_NewPointerObj(&$1, $descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE && { scm_throw(gh_symbol2scm((char *) "swig-exception"), gh_list(SWIG_NewPointerObj(&$1, $descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE * { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE [] { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } /* Change of object ownership, and interaction of destructor-like functions and the garbage-collector */ %typemap(in, doc="$NAME is of type <$type> and gets destroyed by the function") SWIGTYPE *DESTROYED { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); } %typemap(freearg) SWIGTYPE *DESTROYED { SWIG_Guile_MarkPointerDestroyed($input); } %typemap(in, doc="$NAME is of type <$type> and is consumed by the function") SWIGTYPE *CONSUMED { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); SWIG_Guile_MarkPointerNoncollectable($input); } /* Pass-by-value */ %typemap(in) SWIGTYPE($&1_ltype argp) { argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); $1 = *argp; } %typemap(varin) SWIGTYPE { $&1_ltype argp; argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, 1, 0); $1 = *argp; } %typemap(out) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; resultptr = new $1_ltype((const $1_ltype &) $1); $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 1); } #else { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); } #endif %typemap(varout) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; resultptr = new $1_ltype((const $1_ltype&) $1); $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 0); } #else { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); } #endif /* Enums */ %typemap(in) enum SWIGTYPE { $1 = ($1_type) scm_to_int($input); } /* The complicated construction below needed to deal with anonymous enums, which cannot be cast to. */ %typemap(varin) enum SWIGTYPE { if (sizeof(int) != sizeof($1)) { scm_error(scm_from_locale_symbol("swig-error"), (char *) FUNC_NAME, (char *) "enum variable '$name' cannot be set", SCM_EOL, SCM_BOOL_F); } * (int *) &($1) = scm_to_int($input); } %typemap(out) enum SWIGTYPE { $result = scm_from_long($1); } %typemap(varout) enum SWIGTYPE { $result = scm_from_long($1); } %typemap(throws) enum SWIGTYPE { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(scm_from_long($1), SCM_UNDEFINED)); } /* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of typemaps needed for simple types. -- SCM_TO_C_EXPR is a C expression that translates the Scheme value "swig_scm_value" to a C value. -- C_TO_SCM_EXPR is a C expression that translates the C value "swig_c_value" to a Scheme value. */ %define SIMPLE_MAP_WITH_EXPR(C_NAME, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_NAME) %typemap (in, doc="$NAME is of type <" #SCM_NAME ">") C_NAME { SCM swig_scm_value = $input; $1 = SCM_TO_C_EXPR; } %typemap (varin, doc="NEW-VALUE is of type <" #SCM_NAME ">") C_NAME { SCM swig_scm_value = $input; $1 = SCM_TO_C_EXPR; } %typemap (out, doc="<" #SCM_NAME ">") C_NAME { C_NAME swig_c_value = $1; $result = C_TO_SCM_EXPR; } %typemap (varout, doc="<" #SCM_NAME ">") C_NAME { C_NAME swig_c_value = $1; $result = C_TO_SCM_EXPR; } /* INPUT and OUTPUT */ %typemap (in, doc="$NAME is of type <" #SCM_NAME ">)") C_NAME *INPUT(C_NAME temp) { SCM swig_scm_value = $input; temp = (C_NAME) SCM_TO_C_EXPR; $1 = &temp; } %typemap (in,numinputs=0) C_NAME *OUTPUT (C_NAME temp) {$1 = &temp;} %typemap (argout,doc="$name (of type <" #SCM_NAME ">)") C_NAME *OUTPUT { C_NAME swig_c_value = *$1; SWIG_APPEND_VALUE(C_TO_SCM_EXPR); } %typemap (in) C_NAME *BOTH = C_NAME *INPUT; %typemap (argout) C_NAME *BOTH = C_NAME *OUTPUT; %typemap (in) C_NAME *INOUT = C_NAME *INPUT; %typemap (argout) C_NAME *INOUT = C_NAME *OUTPUT; /* Const primitive references. Passed by value */ %typemap(in, doc="$NAME is of type <" #SCM_NAME ">") const C_NAME & (C_NAME temp) { SCM swig_scm_value = $input; temp = SCM_TO_C_EXPR; $1 = &temp; } %typemap(out, doc="<" #SCM_NAME ">") const C_NAME & { C_NAME swig_c_value = *$1; $result = C_TO_SCM_EXPR; } /* Throw typemap */ %typemap(throws) C_NAME { C_NAME swig_c_value = $1; scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(C_TO_SCM_EXPR, SCM_UNDEFINED)); } %enddef /* The SIMPLE_MAP macro below defines the whole set of typemaps needed for simple types. It generates slightly simpler code than the macro above, but it is only suitable for very simple conversion expressions. */ %define SIMPLE_MAP(C_NAME, SCM_TO_C, C_TO_SCM, SCM_NAME) %typemap (in, doc="$NAME is of type <" #SCM_NAME ">") C_NAME {$1 = ($1_ltype) SCM_TO_C($input);} %typemap (varin, doc="NEW-VALUE is of type <" #SCM_NAME ">") C_NAME {$1 = ($1_ltype) SCM_TO_C($input);} %typemap (out, doc="<" #SCM_NAME ">") C_NAME {$result = C_TO_SCM($1);} %typemap (varout, doc="<" #SCM_NAME ">") C_NAME {$result = C_TO_SCM($1);} /* INPUT and OUTPUT */ %typemap (in, doc="$NAME is of type <" #SCM_NAME ">)") C_NAME *INPUT(C_NAME temp), C_NAME &INPUT(C_NAME temp) { temp = (C_NAME) SCM_TO_C($input); $1 = &temp; } %typemap (in,numinputs=0) C_NAME *OUTPUT (C_NAME temp), C_NAME &OUTPUT(C_NAME temp) {$1 = &temp;} %typemap (argout,doc="$name (of type <" #SCM_NAME ">)") C_NAME *OUTPUT, C_NAME &OUTPUT {SWIG_APPEND_VALUE(C_TO_SCM(*$1));} %typemap (in) C_NAME *BOTH = C_NAME *INPUT; %typemap (argout) C_NAME *BOTH = C_NAME *OUTPUT; %typemap (in) C_NAME *INOUT = C_NAME *INPUT; %typemap (argout) C_NAME *INOUT = C_NAME *OUTPUT; %typemap (in) C_NAME &INOUT = C_NAME &INPUT; %typemap (argout) C_NAME &INOUT = C_NAME &OUTPUT; /* Const primitive references. Passed by value */ %typemap(in, doc="$NAME is of type <" #SCM_NAME ">") const C_NAME & (C_NAME temp) { temp = SCM_TO_C($input); $1 = ($1_ltype) &temp; } %typemap(out, doc="<" #SCM_NAME ">") const C_NAME & { $result = C_TO_SCM(*$1); } /* Throw typemap */ %typemap(throws) C_NAME { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(C_TO_SCM($1), SCM_UNDEFINED)); } %enddef SIMPLE_MAP(bool, scm_is_true, scm_from_bool, boolean); SIMPLE_MAP(char, SCM_CHAR, SCM_MAKE_CHAR, char); SIMPLE_MAP(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); SIMPLE_MAP(signed char, SCM_CHAR, SCM_MAKE_CHAR, char); SIMPLE_MAP(int, scm_to_int, scm_from_long, integer); SIMPLE_MAP(short, scm_to_short, scm_from_long, integer); SIMPLE_MAP(long, scm_to_long, scm_from_long, integer); SIMPLE_MAP(ptrdiff_t, scm_to_long, scm_from_long, integer); SIMPLE_MAP(unsigned int, scm_to_uint, scm_from_ulong, integer); SIMPLE_MAP(unsigned short, scm_to_ushort, scm_from_ulong, integer); SIMPLE_MAP(unsigned long, scm_to_ulong, scm_from_ulong, integer); SIMPLE_MAP(size_t, scm_to_ulong, scm_from_ulong, integer); SIMPLE_MAP(float, scm_to_double, scm_from_double, real); SIMPLE_MAP(double, scm_to_double, scm_from_double, real); // SIMPLE_MAP(char *, SWIG_scm2str, SWIG_str02scm, string); // SIMPLE_MAP(const char *, SWIG_scm2str, SWIG_str02scm, string); /* Define long long typemaps -- uses functions that are only defined in recent versions of Guile, availability also depends on Guile's configuration. */ SIMPLE_MAP(long long, scm_to_long_long, scm_from_long_long, integer); SIMPLE_MAP(unsigned long long, scm_to_ulong_long, scm_from_ulong_long, integer); /* Strings */ %typemap (in, doc="$NAME is a string") char *(int must_free = 0) { $1 = ($1_ltype)SWIG_scm2str($input); must_free = 1; } %typemap (varin, doc="NEW-VALUE is a string") char * {$1 = ($1_ltype)SWIG_scm2str($input);} %typemap (out, doc="") char * {$result = SWIG_str02scm((const char *)$1);} %typemap (varout, doc="") char * {$result = SWIG_str02scm($1);} %typemap (in, doc="$NAME is a string") char **INPUT(char * temp, int must_free = 0) { temp = (char *) SWIG_scm2str($input); $1 = &temp; must_free = 1; } %typemap (in,numinputs=0) char **OUTPUT (char * temp) {$1 = &temp;} %typemap (argout,doc="$NAME (a string)") char **OUTPUT {SWIG_APPEND_VALUE(SWIG_str02scm(*$1));} %typemap (in) char **BOTH = char **INPUT; %typemap (argout) char **BOTH = char **OUTPUT; %typemap (in) char **INOUT = char **INPUT; %typemap (argout) char **INOUT = char **OUTPUT; /* SWIG_scm2str makes a malloc'ed copy of the string, so get rid of it after the function call. */ %typemap (freearg) char * "if (must_free$argnum && $1) SWIG_free($1);"; %typemap (freearg) char **INPUT, char **BOTH "if (must_free$argnum && (*$1)) SWIG_free(*$1);" %typemap (freearg) char **OUTPUT "SWIG_free(*$1);" /* But this shall not apply if we try to pass a single char by reference. */ %typemap (freearg) char *OUTPUT, char *BOTH ""; /* If we set a string variable, delete the old result first, unless const. */ %typemap (varin) char * { if ($1) free($1); $1 = ($1_ltype) SWIG_scm2str($input); } %typemap (varin) const char * { $1 = ($1_ltype) SWIG_scm2str($input); } %typemap(throws) char * { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_str02scm($1), SCM_UNDEFINED)); } /* Void */ %typemap (out,doc="") void "gswig_result = SCM_UNSPECIFIED;"; /* SCM is passed through */ typedef unsigned long SCM; %typemap (in) SCM "$1=$input;"; %typemap (out) SCM "$result=$1;"; %typecheck(SWIG_TYPECHECK_POINTER) SCM "$1=1;"; /* ------------------------------------------------------------ * String & length * ------------------------------------------------------------ */ %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { size_t temp; $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp); $2 = ($2_ltype) temp; } /* ------------------------------------------------------------ * CLASS::* (member function pointer) typemaps * taken from typemaps/swigtype.swg * ------------------------------------------------------------ */ #define %set_output(obj) $result = obj #define %set_varoutput(obj) $result = obj #define %argument_fail(code, type, name, argn) scm_wrong_type_arg((char *) FUNC_NAME, argn, $input); #define %as_voidptr(ptr) (void*)(ptr) %typemap(in) SWIGTYPE (CLASS::*) { int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } } %typemap(out,noblock=1) SWIGTYPE (CLASS::*) { %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); } %typemap(varin) SWIGTYPE (CLASS::*) { int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor); if (!SWIG_IsOK(res)) { scm_wrong_type_arg((char *) FUNC_NAME, 1, $input); } } %typemap(varout,noblock=1) SWIGTYPE (CLASS::*) { %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); } /* ------------------------------------------------------------ * Typechecking rules * ------------------------------------------------------------ */ /* adapted from python.swg */ %typecheck(SWIG_TYPECHECK_INTEGER) int, short, long, unsigned int, unsigned short, unsigned long, signed char, unsigned char, long long, unsigned long long, size_t, ptrdiff_t, std::size_t, std::ptrdiff_t, const int &, const short &, const long &, const unsigned int &, const unsigned short &, const unsigned long &, const long long &, const unsigned long long &, const size_t &, const ptrdiff_t &, const std::size_t &, const std::ptrdiff_t &, enum SWIGTYPE { $1 = scm_is_true(scm_integer_p($input)) && scm_is_true(scm_exact_p($input))? 1 : 0; } %typecheck(SWIG_TYPECHECK_BOOL) bool, bool&, const bool& { $1 = SCM_BOOLP($input) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_DOUBLE) float, double, const float &, const double & { $1 = scm_is_true(scm_real_p($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = SCM_CHARP($input) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = scm_is_string($input) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0); $1 = SWIG_CheckState(res); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, 0); $1 = SWIG_CheckState(res); } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; int res = SWIG_ConvertPtr($input, &ptr, 0, 0); $1 = SWIG_CheckState(res); } /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* typemaps.i ends here */ swig-3.0.2/Lib/guile/extra-install.list0000664000175000017500000000004712343605122017643 0ustar williamwilliam# see top-level Makefile.in common.scm swig-3.0.2/Lib/guile/list-vector.i0000664000175000017500000004350212343605122016607 0ustar williamwilliam/* ----------------------------------------------------------------------------- * list_vector.i * * Guile typemaps for converting between arrays and Scheme lists or vectors * ----------------------------------------------------------------------------- */ /* Here is a macro that will define typemaps for converting between C arrays and Scheme lists or vectors when passing arguments to the C function. TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) Supported calling conventions: func(int VECTORLENINPUT, [const] C_TYPE *VECTORINPUT) Scheme wrapper will take one argument, a vector. A temporary C array of elements of type C_TYPE will be allocated and filled with the elements of the vectors, converted to C with the SCM_TO_C function. Length and address of the array are passed to the C function. SCM_TYPE is used to describe the Scheme type of the elements in the Guile procedure documentation. func(int LISTLENINPUT, [const] C_TYPE *LISTINPUT) Likewise, but the Scheme wrapper will take one argument, a list. func(int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) Scheme wrapper will take no arguments. Addresses of an integer and a C_TYPE * variable will be passed to the C function. The C function is expected to return address and length of a freshly allocated array of elements of type C_TYPE through these pointers. The elements of this array are converted to Scheme with the C_TO_SCM function and returned as a Scheme vector. If the function has a void return value, the vector constructed by this typemap becomes the return value of the Scheme wrapper. Otherwise, the function returns multiple values. (See the documentation on how to deal with multiple values.) func(int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) Likewise, but the Scheme wrapper will return a list instead of a vector. It is also allowed to use "size_t LISTLENINPUT" rather than "int LISTLENINPUT". */ %define TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) /* input */ /* We make use of the new multi-dispatch typemaps here. */ %typemap(in, doc="$NAME is a vector of " #SCM_TYPE " values") (int VECTORLENINPUT, C_TYPE *VECTORINPUT), (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT) { SCM_VALIDATE_VECTOR($argnum, $input); $1 = scm_c_vector_length($input); if ($1 > 0) { $1_ltype i; $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); for (i = 0; i<$1; i++) { SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i)); $2[i] = SCM_TO_C_EXPR; } } else $2 = NULL; } %typemap(in, doc="$NAME is a list of " #SCM_TYPE " values") (int LISTLENINPUT, C_TYPE *LISTINPUT), (size_t LISTLENINPUT, C_TYPE *LISTINPUT) { SCM_VALIDATE_LIST($argnum, $input); $1 = scm_to_ulong(scm_length($input)); if ($1 > 0) { $1_ltype i; SCM rest; $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); for (i = 0, rest = $input; i<$1; i++, rest = SCM_CDR(rest)) { SCM swig_scm_value = SCM_CAR(rest); $2[i] = SCM_TO_C_EXPR; } } else $2 = NULL; } /* Do not check for NULL pointers (override checks). */ %typemap(check) (int VECTORLENINPUT, C_TYPE *VECTORINPUT), (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT), (int LISTLENINPUT, C_TYPE *LISTINPUT), (size_t LISTLENINPUT, C_TYPE *LISTINPUT) "/* no check for NULL pointer */"; /* Discard the temporary array after the call. */ %typemap(freearg) (int VECTORLENINPUT, C_TYPE *VECTORINPUT), (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT), (int LISTLENINPUT, C_TYPE *LISTINPUT), (size_t LISTLENINPUT, C_TYPE *LISTINPUT) {if ($2!=NULL) SWIG_free($2);} %enddef /* output */ %define TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) /* First we make temporary variables ARRAYLENTEMP and ARRAYTEMP, whose addresses we pass to the C function. We ignore both arguments for Scheme. */ %typemap(in,numinputs=0) (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) (int arraylentemp, C_TYPE *arraytemp), (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) (int arraylentemp, C_TYPE *arraytemp), (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) (size_t arraylentemp, C_TYPE *arraytemp), (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) (size_t arraylentemp, C_TYPE *arraytemp) %{ $1 = &arraylentemp; $2 = &arraytemp; %} /* In the ARGOUT typemaps, we convert the array into a vector or a list and append it to the results. */ %typemap(argout, doc="$NAME (a vector of " #SCM_TYPE " values)") (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) { $*1_ltype i; SCM res = scm_make_vector(scm_from_long(*$1), SCM_BOOL_F); for (i = 0; i<*$1; i++) { C_TYPE swig_c_value = (*$2)[i]; SCM elt = C_TO_SCM_EXPR; scm_vector_set_x(res, scm_from_long(i), elt); } SWIG_APPEND_VALUE(res); } %typemap(argout, doc="$NAME (a list of " #SCM_TYPE " values)") (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT), (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) { int i; SCM res = SCM_EOL; for (i = ((int)(*$1)) - 1; i>=0; i--) { C_TYPE swig_c_value = (*$2)[i]; SCM elt = C_TO_SCM_EXPR; res = scm_cons(elt, res); } SWIG_APPEND_VALUE(res); } /* In the FREEARG typemaps, get rid of the C vector. (This can be overridden if you want to keep the C vector.) */ %typemap(freearg) (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT), (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) { if ((*$2)!=NULL) free(*$2); } %enddef %define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_TYPE) TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) %enddef %define TYPEMAP_LIST_VECTOR_INPUT(C_TYPE, SCM_TO_C, SCM_TYPE) TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR (C_TYPE, SCM_TO_C(swig_scm_value), SCM_TYPE) %enddef %define TYPEMAP_LIST_VECTOR_OUTPUT(C_TYPE, C_TO_SCM, SCM_TYPE) TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR (C_TYPE, C_TO_SCM(swig_c_value), SCM_TYPE) %enddef %define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) TYPEMAP_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR (C_TYPE, SCM_TO_C(swig_scm_value), C_TO_SCM(swig_c_value), SCM_TYPE) %enddef /* We use the macro to define typemaps for some standard types. */ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); /* For the char *, free all strings after converting */ %typemap(freearg) (int *VECTORLENOUTPUT, char ***VECTOROUTPUT), (size_t *VECTORLENOUTPUT, char ***VECTOROUTPUT), (int *LISTLENOUTPUT, char ***LISTOUTPUT), (size_t *LISTLENOUTPUT, char ***LISTOUTPUT), (int *VECTORLENOUTPUT, const char ***VECTOROUTPUT), (size_t *VECTORLENOUTPUT, const char ***VECTOROUTPUT), (int *LISTLENOUTPUT, const char ***LISTOUTPUT), (size_t *LISTLENOUTPUT, const char ***LISTOUTPUT) { if ((*$2)!=NULL) { int i; for (i = 0; i < *$1; i++) { if ((*$2)[i] != NULL) free((*$2)[i]); } free(*$2); } } %typemap(freearg) (int VECTORLENINPUT, char **VECTORINPUT), (size_t VECTORLENINPUT, char **VECTORINPUT), (int LISTLENINPUT, char **LISTINPUT), (size_t LISTLENINPUT, char **LISTINPUT), (int VECTORLENINPUT, const char **VECTORINPUT), (size_t VECTORLENINPUT, const char **VECTORINPUT), (int LISTLENINPUT, const char **LISTINPUT), (size_t LISTLENINPUT, const char **LISTINPUT) { if (($2)!=NULL) { int i; for (i = 0; i< $1; i++) if (($2)[i] != NULL) free(($2)[i]); free($2); } } /* Following is a macro that emits typemaps that are much more flexible. (They are also messier.) It supports multiple parallel lists and vectors (sharing one length argument each). TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) Supported calling conventions: func(int PARALLEL_VECTORLENINPUT, [const] C_TYPE *PARALLEL_VECTORINPUT, ...) or func([const] C_TYPE *PARALLEL_VECTORINPUT, ..., int PARALLEL_VECTORLENINPUT) func(int PARALLEL_LISTLENINPUT, [const] C_TYPE *PARALLEL_LISTINPUT, ...) or func([const] C_TYPE *PARALLEL_LISTINPUT, ..., int PARALLEL_LISTLENINPUT) func(int *PARALLEL_VECTORLENOUTPUT, C_TYPE **PARALLEL_VECTOROUTPUT, ...) or func(C_TYPE **PARALLEL_VECTOROUTPUT, int *PARALLEL_VECTORLENOUTPUT, ...) func(int *PARALLEL_LISTLENOUTPUT, C_TYPE **PARALLEL_LISTOUTPUT) or func(C_TYPE **PARALLEL_LISTOUTPUT, int *PARALLEL_LISTLENOUTPUT) It is also allowed to use "size_t PARALLEL_LISTLENINPUT" rather than "int PARALLEL_LISTLENINPUT". */ %define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) /* input */ /* Passing data is a little complicated here; just remember: IGNORE typemaps come first, then IN, then CHECK. But if IGNORE is given, IN won't be used for this type. We need to "ignore" one of the parameters because there shall be only one argument on the Scheme side. Here we only initialize the array length to 0 but save its address for a later change. */ %typemap(in,numinputs=0) int PARALLEL_VECTORLENINPUT (int *_global_vector_length), size_t PARALLEL_VECTORLENINPUT (size_t *_global_vector_length) { $1 = 0; _global_vector_length = &$1; } %typemap(in,numinputs=0) int PARALLEL_LISTLENINPUT (int *_global_list_length), size_t PARALLEL_LISTLENINPUT (size_t *_global_list_length) { $1 = 0; _global_list_length = &$1; } /* All the work is done in IN. */ %typemap(in, doc="$NAME is a vector of " #SCM_TYPE " values") C_TYPE *PARALLEL_VECTORINPUT, const C_TYPE *PARALLEL_VECTORINPUT { SCM_VALIDATE_VECTOR($argnum, $input); *_global_vector_length = scm_c_vector_length($input); if (*_global_vector_length > 0) { int i; $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * (*_global_vector_length)); for (i = 0; i<*_global_vector_length; i++) { SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i)); $1[i] = SCM_TO_C_EXPR; } } else $1 = NULL; } %typemap(in, doc="$NAME is a list of " #SCM_TYPE " values") C_TYPE *PARALLEL_LISTINPUT, const C_TYPE *PARALLEL_LISTINPUT { SCM_VALIDATE_LIST($argnum, $input); *_global_list_length = scm_to_ulong(scm_length($input)); if (*_global_list_length > 0) { int i; SCM rest; $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * (*_global_list_length)); for (i = 0, rest = $input; i<*_global_list_length; i++, rest = SCM_CDR(rest)) { SCM swig_scm_value = SCM_CAR(rest); $1[i] = SCM_TO_C_EXPR; } } else $1 = NULL; } /* Don't check for NULL pointers (override checks). */ %typemap(check) C_TYPE *PARALLEL_VECTORINPUT, const C_TYPE *PARALLEL_VECTORINPUT, C_TYPE *PARALLEL_LISTINPUT, const C_TYPE *PARALLEL_LISTINPUT "/* no check for NULL pointer */"; /* Discard the temporary array after the call. */ %typemap(freearg) C_TYPE *PARALLEL_VECTORINPUT, const C_TYPE *PARALLEL_VECTORINPUT, C_TYPE *PARALLEL_LISTINPUT, const C_TYPE *PARALLEL_LISTINPUT {if ($1!=NULL) SWIG_free($1);} %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) /* output */ /* First we make a temporary variable ARRAYLENTEMP, use its address as the ...LENOUTPUT argument for the C function and "ignore" the ...LENOUTPUT argument for Scheme. */ %typemap(in,numinputs=0) int *PARALLEL_VECTORLENOUTPUT (int _global_arraylentemp), size_t *PARALLEL_VECTORLENOUTPUT (size_t _global_arraylentemp), int *PARALLEL_LISTLENOUTPUT (int _global_arraylentemp), size_t *PARALLEL_LISTLENOUTPUT (size_t _global_arraylentemp) "$1 = &_global_arraylentemp;"; /* We also need to ignore the ...OUTPUT argument. */ %typemap(in,numinputs=0) C_TYPE **PARALLEL_VECTOROUTPUT (C_TYPE *arraytemp), C_TYPE **PARALLEL_LISTOUTPUT (C_TYPE *arraytemp) "$1 = &arraytemp;"; /* In the ARGOUT typemaps, we convert the array into a vector or a list and append it to the results. */ %typemap(argout, doc="$NAME (a vector of " #SCM_TYPE " values)") C_TYPE **PARALLEL_VECTOROUTPUT { int i; SCM res = scm_make_vector(scm_from_long(_global_arraylentemp), SCM_BOOL_F); for (i = 0; i<_global_arraylentemp; i++) { C_TYPE swig_c_value = (*$1)[i]; SCM elt = C_TO_SCM_EXPR; scm_vector_set_x(res, scm_from_long(i), elt); } SWIG_APPEND_VALUE(res); } %typemap(argout, doc="$NAME (a list of " #SCM_TYPE " values)") C_TYPE **PARALLEL_LISTOUTPUT { int i; SCM res = SCM_EOL; if (_global_arraylentemp > 0) { for (i = _global_arraylentemp - 1; i>=0; i--) { C_TYPE swig_c_value = (*$1)[i]; SCM elt = C_TO_SCM_EXPR; res = scm_cons(elt, res); } } SWIG_APPEND_VALUE(res); } /* In the FREEARG typemaps, get rid of the C vector. (This can be overridden if you want to keep the C vector.) */ %typemap(freearg) C_TYPE **PARALLEL_VECTOROUTPUT, C_TYPE **PARALLEL_LISTOUTPUT { if ((*$1)!=NULL) free(*$1); } %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT(C_TYPE, SCM_TO_C, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR (C_TYPE, SCM_TO_C(swig_scm_value), SCM_TYPE) %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT(C_TYPE, C_TO_SCM, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR (C_TYPE, C_TO_SCM(swig_c_value), SCM_TYPE) %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR (C_TYPE, SCM_TO_C(swig_scm_value), C_TO_SCM(swig_c_value), SCM_TYPE) %enddef /* We use the macro to define typemaps for some standard types. */ TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); %typemap(freearg) char **PARALLEL_LISTINPUT, char **PARALLEL_VECTORINPUT, const char **PARALLEL_LISTINPUT, const char **PARALLEL_VECTORINPUT { if (($1)!=NULL) { int i; for (i = 0; i<*_global_list_length; i++) if (($1)[i] != NULL) SWIG_free(($1)[i]); SWIG_free($1); } } %typemap(freearg) char ***PARALLEL_LISTOUTPUT, char ***PARALLEL_VECTOROUTPUT, const char ***PARALLEL_LISTOUTPUT, const char ***PARALLEL_VECTOROUTPUT { if ((*$1)!=NULL) { int i; for (i = 0; i<_global_arraylentemp; i++) if ((*$1)[i] != NULL) free((*$1)[i]); free(*$1); } } swig-3.0.2/Lib/guile/guile_scm.swg0000664000175000017500000000230612343605122016650 0ustar williamwilliam/* ----------------------------------------------------------------------------- * guile_scm.swg * * This SWIG interface file is processed if the Guile module is run * with SCM_ flavor. * ----------------------------------------------------------------------------- */ #define SWIGGUILE_SCM %runtime "swigrun.swg" // Common C API type-checking code %runtime "guile_scm_run.swg" %include %runtime %{ #define GUILE_MAYBE_VALUES \ if (gswig_list_p) gswig_result = scm_values(gswig_result); #define GUILE_MAYBE_VECTOR \ if (gswig_list_p) gswig_result = scm_vector(gswig_result); #define SWIG_APPEND_VALUE(object) \ if (gswig_result == SCM_UNSPECIFIED) \ gswig_result = object; \ else { \ if (!gswig_list_p) { \ gswig_list_p = 1; \ gswig_result = scm_listify(gswig_result, object, SCM_UNDEFINED); \ } \ else \ gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED)); \ } %} %insert(init) "swiginit.swg" %init %{ SWIG_GUILE_INIT_STATIC void SWIG_init(void) { SWIG_InitializeModule(0); SWIG_PropagateClientData(); %} swig-3.0.2/Lib/guile/pointer-in-out.i0000664000175000017500000000637512343605122017234 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pointer-in-out.i * * Guile typemaps for passing pointers indirectly * ----------------------------------------------------------------------------- */ /* Here is a macro that will define typemaps for passing C pointers indirectly. TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE) Supported calling conventions (in this example, PTRTYPE is int *): func(int **INPUT) Scheme wrapper will take one argument, a wrapped C pointer. The address of a variable containing this pointer will be passed to the function. func(int **INPUT_CONSUMED) Likewise, but mark the pointer object as not garbage collectable. func(int **INPUT_DESTROYED) Likewise, but mark the pointer object as destroyed. func(int **OUTPUT) Scheme wrapper will take no arguments. The address of an int * variable will be passed to the function. The function is expected to modify the variable; its value is wrapped and becomes an extra return value. (See the documentation on how to deal with multiple values.) func(int **OUTPUT_NONCOLLECTABLE) Likewise, but make the pointer object not garbage collectable. func(int **BOTH) func(int **INOUT) This annotation combines INPUT and OUTPUT. */ %define TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE) %typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE *INPUT(PTRTYPE temp) { if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { scm_wrong_type_arg(FUNC_NAME, $argnum, $input); } $1 = &temp; } %typemap(in, doc="$NAME is of type <" #SCM_TYPE "> and is consumed by the function") PTRTYPE *INPUT_CONSUMED(PTRTYPE temp) { if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { scm_wrong_type_arg(FUNC_NAME, $argnum, $input); } SWIG_Guile_MarkPointerNoncollectable($input); $1 = &temp; } %typemap(in, doc="$NAME is of type <" #SCM_TYPE "> and is consumed by the function") PTRTYPE *INPUT_DESTROYED(PTRTYPE temp) { if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { scm_wrong_type_arg(FUNC_NAME, $argnum, $input); } SWIG_Guile_MarkPointerDestroyed($input); $1 = &temp; } %typemap(in, numinputs=0) PTRTYPE *OUTPUT(PTRTYPE temp), PTRTYPE *OUTPUT_NONCOLLECTABLE(PTRTYPE temp) "$1 = &temp;"; %typemap(argout, doc="<" #SCM_TYPE ">") PTRTYPE *OUTPUT "SWIG_APPEND_VALUE(SWIG_NewPointerObj(*$1, $*descriptor, 1));"; %typemap(argout, doc="<" #SCM_TYPE ">") PTRTYPE *OUTPUT_NONCOLLECTABLE "SWIG_APPEND_VALUE(SWIG_NewPointerObj(*$1, $*descriptor, 0));"; %typemap(in) PTRTYPE *BOTH = PTRTYPE *INPUT; %typemap(argout) PTRTYPE *BOTH = PTRTYPE *OUTPUT; %typemap(in) PTRTYPE *INOUT = PTRTYPE *INPUT; %typemap(argout) PTRTYPE *INOUT = PTRTYPE *OUTPUT; /* As a special convenience measure, also attach docs involving SCM_TYPE to the standard pointer typemaps */ %typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE { if (SWIG_ConvertPtr($input, (void **) &$1, $descriptor, 0)) scm_wrong_type_arg(FUNC_NAME, $argnum, $input); } %typemap(out, doc="<" #SCM_TYPE ">") PTRTYPE { $result = SWIG_NewPointerObj ($1, $descriptor, $owner); } %enddef swig-3.0.2/Lib/guile/common.scm0000664000175000017500000000452012343605122016153 0ustar williamwilliam;;;************************************************************************ ;;;*common.scm ;;;* ;;;* This file contains generic SWIG GOOPS classes for generated ;;;* GOOPS file support ;;;************************************************************************ (define-module (Swig swigrun)) (define-module (Swig common) #:use-module (oop goops) #:use-module (Swig swigrun)) (define-class () (new-function #:init-value #f)) (define-method (initialize (class ) initargs) (slot-set! class 'new-function (get-keyword #:new-function initargs #f)) (next-method)) (define-class () (swig-smob #:init-value #f) #:metaclass ) (define-method (initialize (obj ) initargs) (next-method) (slot-set! obj 'swig-smob (let ((arg (get-keyword #:init-smob initargs #f))) (if arg arg (let ((ret (apply (slot-ref (class-of obj) 'new-function) (get-keyword #:args initargs '())))) ;; if the class is registered with runtime environment, ;; new-Function will return a goops class. In that case, extract the smob ;; from that goops class and set it as the current smob. (if (slot-exists? ret 'swig-smob) (slot-ref ret 'swig-smob) ret)))))) (define (display-address o file) (display (number->string (object-address o) 16) file)) (define (display-pointer-address o file) ;; Don't fail if the function SWIG-PointerAddress is not present. (let ((address (false-if-exception (SWIG-PointerAddress o)))) (if address (begin (display " @ " file) (display (number->string address 16) file))))) (define-method (write (o ) file) ;; We display _two_ addresses to show the object's identity: ;; * first the address of the GOOPS proxy object, ;; * second the pointer address. ;; The reason is that proxy objects are created and discarded on the ;; fly, so different proxy objects for the same C object will appear. (let ((class (class-of o))) (if (slot-bound? class 'name) (begin (display "#<" file) (display (class-name class) file) (display #\space file) (display-address o file) (display-pointer-address o file) (display ">" file)) (next-method)))) (export ) ;;; common.scm ends here swig-3.0.2/Lib/guile/std_common.i0000664000175000017500000000110212343605122016464 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; #define SWIG_bool2scm(b) scm_from_bool(b ? 1 : 0) #define SWIG_string2scm(s) SWIG_str02scm(s.c_str()) %{ #include inline std::string SWIG_scm2string(SCM x) { char* temp; temp = SWIG_scm2str(x); std::string s(temp); if (temp) SWIG_free(temp); return s; } %} swig-3.0.2/Lib/guile/interpreter.i0000664000175000017500000000261512343605122016677 0ustar williamwilliam/* ----------------------------------------------------------------------------- * interpreter.i * * SWIG file for a simple Guile interpreter * ----------------------------------------------------------------------------- */ %{ #include GSCM_status guile_init(); int main(int argc, char **argv) { GSCM_status status; GSCM_top_level toplev; char *eval_answer; char input_str[16384]; int done; /* start a scheme interpreter */ status = gscm_run_scm(argc, argv, 0, stdout, stderr, guile_init, 0, "#t"); if (status != GSCM_OK) { fputs(gscm_error_msg(status), stderr); fputc('\n', stderr); printf("Error in startup.\n"); exit(1); } /* create the top level environment */ status = gscm_create_top_level(&toplev); if (status != GSCM_OK) { fputs(gscm_error_msg(status), stderr); fputc('\n', stderr); exit(1); } /* now sit in a scheme eval loop: I input the expressions, have guile * evaluate them, and then get another expression. */ done = 0; fprintf(stdout,"Guile > "); while (!done) { if (fgets(input_str,16384,stdin) == NULL) { exit(1); } else { if (strncmp(input_str,"quit",4) == 0) exit(1); status = gscm_eval_str(&eval_answer, toplev, input_str); fprintf(stdout,"%s\n", eval_answer); fprintf(stdout,"Guile > "); } } /* now clean up and quit */ gscm_destroy_top_level(toplev); } %} swig-3.0.2/Lib/guile/std_vector.i0000664000175000017500000004064512343605122016515 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // Guile as much as possible, namely, to allow the user to pass and // be returned Guile vectors or lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&), f(const std::vector*): // the parameter being read-only, either a Guile sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(): // the vector is returned by copy; therefore, a Guile vector of T:s // is returned which is most easily used in other Guile functions // -- std::vector& f(), std::vector* f(), const std::vector& f(), // const std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class vector { %typemap(in) vector { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); $1 = std::vector(size); for (unsigned long i=0; i(); } else if (scm_is_pair($input)) { SCM head, tail; $1 = std::vector(); tail = $input; while (!scm_is_null(tail)) { head = SCM_CAR(tail); tail = SCM_CDR(tail); $1.push_back(*((T*)SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const vector& (std::vector temp), const vector* (std::vector temp) { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); temp = std::vector(size); $1 = &temp; for (unsigned long i=0; i(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::vector(); $1 = &temp; SCM head, tail; tail = $input; while (!scm_is_null(tail)) { head = SCM_CAR(tail); tail = SCM_CDR(tail); temp.push_back(*((T*) SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) vector { $result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); for (unsigned int i=0; i<$1.size(); i++) { T* x = new T((($1_type &)$1)[i]); scm_vector_set_x($result,scm_from_long(i), SWIG_NewPointerObj(x, $descriptor(T *), 1)); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ if (scm_is_vector($input)) { unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SCM o = scm_vector_ref($input,scm_from_ulong(0)); T* x; if (SWIG_ConvertPtr(o,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ T* x; SCM head = SCM_CAR($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ if (scm_is_vector($input)) { unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; SCM o = scm_vector_ref($input,scm_from_ulong(0)); if (SWIG_ConvertPtr(o,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ T* x; SCM head = SCM_CAR($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); %rename(length) size; unsigned int size() const; %rename("empty?") empty; bool empty() const; %rename("clear!") clear; void clear(); %rename("set!") set; %rename("pop!") pop; %rename("push!") push_back; void push_back(const T& x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } const T& ref(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { %typemap(in) vector { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); $1 = std::vector(size); for (unsigned long i=0; i(); } else if (scm_is_pair($input)) { SCM v = scm_vector($input); unsigned long size = scm_c_vector_length(v); $1 = std::vector(size); for (unsigned long i=0; i& (std::vector temp), const vector* (std::vector temp) { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); temp = std::vector(size); $1 = &temp; for (unsigned long i=0; i(); $1 = &temp; } else if (scm_is_pair($input)) { SCM v = scm_vector($input); unsigned long size = scm_c_vector_length(v); temp = std::vector(size); $1 = &temp; for (unsigned long i=0; i { $result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); for (unsigned int i=0; i<$1.size(); i++) { SCM x = CONVERT_TO((($1_type &)$1)[i]); scm_vector_set_x($result,scm_from_long(i),x); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ if (scm_is_vector($input)) { unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SCM o = scm_vector_ref($input,scm_from_ulong(0)); $1 = CHECK(o) ? 1 : 0; } } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ SCM head = SCM_CAR($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ std::vector* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) ? 1 : 0; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ if (scm_is_vector($input)) { unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SCM o = scm_vector_ref($input,scm_from_ulong(0)); $1 = CHECK(o) ? 1 : 0; } } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ SCM head = SCM_CAR($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ std::vector* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) ? 1 : 0; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); %rename(length) size; unsigned int size() const; %rename("empty?") empty; bool empty() const; %rename("clear!") clear; void clear(); %rename("set!") set; %rename("pop!") pop; %rename("push!") push_back; void push_back(T x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T ref(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i %{ #include %} namespace std { %naturalvar string; class string; %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; %typemap(in) string (char * tempptr) { if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(in) const string & ($*1_ltype temp, char *tempptr) { if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); temp.assign(tempptr); if (tempptr) SWIG_free(tempptr); $1 = &temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(in) string * (char *tempptr) { if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); $1 = new $*1_ltype(tempptr); if (tempptr) SWIG_free(tempptr); } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(out) string { $result = SWIG_str02scm($1.c_str()); } %typemap(out) const string & { $result = SWIG_str02scm($1->c_str()); } %typemap(out) string * { $result = SWIG_str02scm($1->c_str()); } %typemap(varin) string { if (scm_is_string($input)) { char *tempptr = SWIG_scm2str($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(varout) string { $result = SWIG_str02scm($1.c_str()); } } swig-3.0.2/Lib/guile/swigrun.i0000664000175000017500000000170512343605122016031 0ustar williamwilliam/* -*- mode: c -*- */ %module swigrun #ifdef SWIGGUILE_SCM /* Hook the runtime module initialization into the shared initialization function SWIG_Guile_Init. */ %runtime %{ /* Hook the runtime module initialization into the shared initialization function SWIG_Guile_Init. */ #include #ifdef __cplusplus extern "C" #endif SCM scm_init_Swig_swigrun_module (void); #define SWIG_INIT_RUNTIME_MODULE scm_init_Swig_swigrun_module(); %} /* The runtime type system from common.swg */ typedef struct swig_type_info swig_type_info; const char * SWIG_TypeName(const swig_type_info *type); const char * SWIG_TypePrettyName(const swig_type_info *type); swig_type_info * SWIG_TypeQuery(const char *); /* Language-specific stuff */ %apply bool { int }; int SWIG_IsPointer(SCM object); int SWIG_IsPointerOfType(SCM object, swig_type_info *type); unsigned long SWIG_PointerAddress(SCM object); swig_type_info * SWIG_PointerType(SCM object); #endif swig-3.0.2/Lib/guile/std_except.i0000664000175000017500000000026612343605122016476 0ustar williamwilliam// TODO: STL exception handling // Note that the generic std_except.i file did not work %{ #include %} namespace std { %ignore exception; struct exception { }; } swig-3.0.2/Lib/guile/stl.i0000664000175000017500000000054512343605122015136 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/guile/std_deque.i0000664000175000017500000000003412343605122016302 0ustar williamwilliam%include swig-3.0.2/Lib/guile/Makefile0000664000175000017500000000003512343605122015614 0ustar williamwilliam co: co RCS/*.i* RCS/*.swg* swig-3.0.2/Lib/guile/guile.i0000664000175000017500000000206412343605122015437 0ustar williamwilliam/* ----------------------------------------------------------------------------- * guile.i * * SWIG Configuration File for Guile. * ----------------------------------------------------------------------------- */ /* Macro for inserting Scheme code into the stub */ #define %scheme %insert("scheme") #define %goops %insert("goops") /* Return-styles */ %pragma(guile) return_nothing_doc = "Returns unspecified." %pragma(guile) return_one_doc = "Returns $values." %define %values_as_list %pragma(guile) beforereturn = "" %pragma(guile) return_multi_doc = "Returns a list of $num_values values: $values." %enddef %values_as_list /* the default style */ %define %values_as_vector %pragma(guile) beforereturn = "GUILE_MAYBE_VECTOR" %pragma(guile) return_multi_doc = "Returns a vector of $num_values values: $values." %enddef %define %multiple_values %pragma(guile) beforereturn = "GUILE_MAYBE_VALUES" %pragma(guile) return_multi_doc = "Returns $num_values values: $values." %enddef #define GUILE_APPEND_RESULT SWIG_APPEND_VALUE %include swig-3.0.2/Lib/guile/cplusplus.i0000664000175000017500000000136312343605122016365 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cplusplus.i * * SWIG typemaps for C++ * ----------------------------------------------------------------------------- */ %typemap(guile,out) string, std::string { $result = SWIG_str02scm(const_cast($1.c_str())); } %typemap(guile,in) string, std::string { $1 = SWIG_scm2str($input); } %typemap(guile,out) complex, complex, std::complex { $result = scm_make_rectangular( scm_from_double ($1.real ()), scm_from_double ($1.imag ()) ); } %typemap(guile,in) complex, complex, std::complex { $1 = std::complex( scm_to_double (scm_real_part ($input)), scm_to_double (scm_imag_part ($input)) ); } swig-3.0.2/Lib/gcj/0000775000175000017500000000000012343605122013614 5ustar williamwilliamswig-3.0.2/Lib/gcj/cni.i0000664000175000017500000000166712343605122014551 0ustar williamwilliam%{ #include %} %include extern void JvInitClass (jclass cls); extern jstring JvAllocString (jsize sz); extern jstring JvNewString (const jchar *chars, jsize len); extern jstring JvNewStringLatin1 (const char *bytes, jsize len); extern jstring JvNewStringLatin1 (const char *bytes); extern jchar* JvGetStringChars (jstring str); extern jsize JvGetStringUTFLength (jstring string); extern jsize JvGetStringUTFRegion (jstring str, jsize start, jsize len, char *buf); extern jstring JvNewStringUTF (const char *bytes); extern void *JvMalloc (jsize size); extern void JvFree (void *ptr); extern jint JvCreateJavaVM (JvVMInitArgs* vm_args); extern java::lang::Thread* JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group); extern java::lang::Thread* JvAttachCurrentThreadAsDaemon (jstring name, java::lang::ThreadGroup* group); extern jint JvDetachCurrentThread (void); %include swig-3.0.2/Lib/gcj/cni.swg0000664000175000017500000000043712343605122015113 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cni.swg * ----------------------------------------------------------------------------- */ #ifdef SWIG #define __attribute__(...) %ignore class$; #pragma SWIG nowarn=313,402 %nodefaultdtor; #endif swig-3.0.2/Lib/gcj/javaprims.i0000664000175000017500000002670412343605122015773 0ustar williamwilliam%include typedef int8_t jbyte; typedef int16_t jshort; typedef int32_t jint; typedef int64_t jlong; typedef float jfloat; typedef double jdouble; typedef jint jsize; typedef int8_t jboolean; extern "Java" { namespace java { namespace io { class BufferedInputStream; class BufferedOutputStream; class BufferedReader; class BufferedWriter; class ByteArrayInputStream; class ByteArrayOutputStream; class CharArrayReader; class CharArrayWriter; class CharConversionException; class DataInput; class DataInputStream; class DataOutput; class DataOutputStream; class EOFException; class Externalizable; class File; class FileDescriptor; class FileFilter; class FileInputStream; class FileNotFoundException; class FileOutputStream; class FilePermission; class FileReader; class FileWriter; class FilenameFilter; class FilterInputStream; class FilterOutputStream; class FilterReader; class FilterWriter; class IOException; class InputStream; class InputStreamReader; class InterfaceComparator; class InterruptedIOException; class InvalidClassException; class InvalidObjectException; class LineNumberInputStream; class LineNumberReader; class MemberComparator; class NotActiveException; class NotSerializableException; class ObjectInput; class ObjectInputStream; class ObjectInputStream$GetField; class ObjectInputValidation; class ObjectOutput; class ObjectOutputStream; class ObjectOutputStream$PutField; class ObjectStreamClass; class ObjectStreamConstants; class ObjectStreamException; class ObjectStreamField; class OptionalDataException; class OutputStream; class OutputStreamWriter; class PipedInputStream; class PipedOutputStream; class PipedReader; class PipedWriter; class PrintStream; class PrintWriter; class PushbackInputStream; class PushbackReader; class RandomAccessFile; class Reader; class SequenceInputStream; class Serializable; class SerializablePermission; class StreamCorruptedException; class StreamTokenizer; class StringBufferInputStream; class StringReader; class StringWriter; class SyncFailedException; class UTFDataFormatException; class UnsupportedEncodingException; class VMObjectStreamClass; class ValidatorAndPriority; class WriteAbortedException; class Writer; } namespace lang { class AbstractMethodError; class ArithmeticException; class ArrayIndexOutOfBoundsException; class ArrayStoreException; class AssertionError; class Boolean; class Byte; class CharSequence; class Character; class Character$Subset; class Character$UnicodeBlock; class Class; class ClassCastException; class ClassCircularityError; class ClassFormatError; class ClassLoader; class ClassNotFoundException; class CloneNotSupportedException; class Cloneable; class Comparable; class Compiler; class ConcreteProcess; class Double; class Error; class Exception; class ExceptionInInitializerError; class Float; class IllegalAccessError; class IllegalAccessException; class IllegalArgumentException; class IllegalMonitorStateException; class IllegalStateException; class IllegalThreadStateException; class IncompatibleClassChangeError; class IndexOutOfBoundsException; class InheritableThreadLocal; class InstantiationError; class InstantiationException; class Integer; class InternalError; class InterruptedException; class LinkageError; class Long; class Math; class NegativeArraySizeException; class NoClassDefFoundError; class NoSuchFieldError; class NoSuchFieldException; class NoSuchMethodError; class NoSuchMethodException; class NullPointerException; class Number; class NumberFormatException; class Object; class OutOfMemoryError; class Package; class Process; class Runnable; class Runtime; class RuntimeException; class RuntimePermission; class SecurityContext; class SecurityException; class SecurityManager; class Short; class StackOverflowError; class StackTraceElement; class StrictMath; class String; class String$CaseInsensitiveComparator; class StringBuffer; class StringIndexOutOfBoundsException; class System; class Thread; class ThreadDeath; class ThreadGroup; class ThreadLocal; class Throwable; class UnknownError; class UnsatisfiedLinkError; class UnsupportedClassVersionError; class UnsupportedOperationException; class VMClassLoader; class VMSecurityManager; class VMThrowable; class VerifyError; class VirtualMachineError; class Void; namespace ref { class PhantomReference; class Reference; class ReferenceQueue; class SoftReference; class WeakReference; } namespace reflect { class AccessibleObject; class Array; class Constructor; class Field; class InvocationHandler; class InvocationTargetException; class Member; class Method; class Modifier; class Proxy; class Proxy$ClassFactory; class Proxy$ProxyData; class Proxy$ProxySignature; class Proxy$ProxyType; class ReflectPermission; class UndeclaredThrowableException; } } namespace util { class AbstractCollection; class AbstractList; class AbstractMap; class AbstractMap$BasicMapEntry; class AbstractSequentialList; class AbstractSet; class ArrayList; class Arrays; class Arrays$ArrayList; class BitSet; class Calendar; class Collection; class Collections; class Collections$CopiesList; class Collections$EmptyList; class Collections$EmptyMap; class Collections$EmptySet; class Collections$ReverseComparator; class Collections$SingletonList; class Collections$SingletonMap; class Collections$SingletonSet; class Collections$SynchronizedCollection; class Collections$SynchronizedIterator; class Collections$SynchronizedList; class Collections$SynchronizedListIterator; class Collections$SynchronizedMap; class Collections$SynchronizedMapEntry; class Collections$SynchronizedRandomAccessList; class Collections$SynchronizedSet; class Collections$SynchronizedSortedMap; class Collections$SynchronizedSortedSet; class Collections$UnmodifiableCollection; class Collections$UnmodifiableEntrySet; class Collections$UnmodifiableIterator; class Collections$UnmodifiableList; class Collections$UnmodifiableListIterator; class Collections$UnmodifiableMap; class Collections$UnmodifiableRandomAccessList; class Collections$UnmodifiableSet; class Collections$UnmodifiableSortedMap; class Collections$UnmodifiableSortedSet; class Comparator; class ConcurrentModificationException; class Currency; class Date; class Dictionary; class EmptyStackException; class Enumeration; class EventListener; class EventListenerProxy; class EventObject; class GregorianCalendar; class HashMap; class HashMap$HashEntry; class HashMap$HashIterator; class HashSet; class Hashtable; class Hashtable$Enumerator; class Hashtable$HashEntry; class Hashtable$HashIterator; class IdentityHashMap; class IdentityHashMap$IdentityEntry; class IdentityHashMap$IdentityIterator; class Iterator; class LinkedHashMap; class LinkedHashMap$LinkedHashEntry; class LinkedHashSet; class LinkedList; class LinkedList$Entry; class LinkedList$LinkedListItr; class List; class ListIterator; class ListResourceBundle; class Locale; class Map; class Map$Entry; class Map$Map; class MissingResourceException; class MyResources; class NoSuchElementException; class Observable; class Observer; class Properties; class PropertyPermission; class PropertyPermissionCollection; class PropertyResourceBundle; class Random; class RandomAccess; class RandomAccessSubList; class ResourceBundle; class Set; class SimpleTimeZone; class SortedMap; class SortedSet; class Stack; class StringTokenizer; class SubList; class TimeZone; class Timer; class Timer$Scheduler; class Timer$TaskQueue; class TimerTask; class TooManyListenersException; class TreeMap; class TreeMap$Node; class TreeMap$SubMap; class TreeMap$TreeIterator; class TreeSet; class Vector; class WeakHashMap; class WeakHashMap$WeakBucket; class WeakHashMap$WeakEntry; class WeakHashMap$WeakEntrySet; namespace jar { class Attributes; class Attributes$Name; class JarEntry; class JarException; class JarFile; class JarFile$JarEnumeration; class JarInputStream; class JarOutputStream; class Manifest; } namespace logging { class ConsoleHandler; class ErrorManager; class FileHandler; class Filter; class Formatter; class Handler; class Level; class LogManager; class LogRecord; class Logger; class LoggingPermission; class MemoryHandler; class SimpleFormatter; class SocketHandler; class StreamHandler; class XMLFormatter; } namespace prefs { class AbstractPreferences; class BackingStoreException; class InvalidPreferencesFormatException; class NodeChangeEvent; class NodeChangeListener; class PreferenceChangeEvent; class PreferenceChangeListener; class Preferences; class PreferencesFactory; } namespace regex { class Matcher; class Pattern; class PatternSyntaxException; } namespace zip { class Adler32; class CRC32; class CheckedInputStream; class CheckedOutputStream; class Checksum; class DataFormatException; class Deflater; class DeflaterOutputStream; class GZIPInputStream; class GZIPOutputStream; class Inflater; class InflaterInputStream; class ZipConstants; class ZipEntry; class ZipException; class ZipFile; class ZipFile$PartialInputStream; class ZipFile$ZipEntryEnumeration; class ZipInputStream; class ZipOutputStream; } } } } typedef class java::lang::Object* jobject; typedef class java::lang::Class* jclass; typedef class java::lang::Throwable* jthrowable; typedef class java::lang::String* jstring; %include swig-3.0.2/Lib/go/0000775000175000017500000000000012343605122013456 5ustar williamwilliamswig-3.0.2/Lib/go/std_map.i0000664000175000017500000000333212343605122015260 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; } swig-3.0.2/Lib/go/std_pair.i0000664000175000017500000000131012343605122015430 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/go/typemaps.i0000664000175000017500000002312612343605122015476 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* INPUT typemaps -------------- These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is passed by value instead of reference. The following typemaps can be applied to turn a pointer or reference into a simple input value. That is, instead of passing a pointer or reference to an object, you would use a real value instead. bool *INPUT, bool &INPUT signed char *INPUT, signed char &INPUT unsigned char *INPUT, unsigned char &INPUT short *INPUT, short &INPUT unsigned short *INPUT, unsigned short &INPUT int *INPUT, int &INPUT unsigned int *INPUT, unsigned int &INPUT long *INPUT, long &INPUT unsigned long *INPUT, unsigned long &INPUT long long *INPUT, long long &INPUT unsigned long long *INPUT, unsigned long long &INPUT float *INPUT, float &INPUT double *INPUT, double &INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); In Go you could then use it like this: answer := modulename.Fadd(10.0, 20.0) There are no char *INPUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *INPUT {char *input}; void f(char *input); */ %define INPUT_TYPEMAP(TYPE, GOTYPE) %typemap(gotype) TYPE *INPUT, TYPE &INPUT "GOTYPE" %typemap(in) TYPE *INPUT, TYPE &INPUT %{ $1 = ($1_ltype)&$input; %} %typemap(out) TYPE *INPUT, TYPE &INPUT "" %typemap(freearg) TYPE *INPUT, TYPE &INPUT "" %typemap(argout) TYPE *INPUT, TYPE &INPUT "" // %typemap(typecheck) TYPE *INPUT = TYPE; // %typemap(typecheck) TYPE &INPUT = TYPE; %enddef INPUT_TYPEMAP(bool, bool); INPUT_TYPEMAP(signed char, int8); INPUT_TYPEMAP(char, byte); INPUT_TYPEMAP(unsigned char, byte); INPUT_TYPEMAP(short, int16); INPUT_TYPEMAP(unsigned short, uint16); INPUT_TYPEMAP(int, int); INPUT_TYPEMAP(unsigned int, uint); INPUT_TYPEMAP(long, int64); INPUT_TYPEMAP(unsigned long, uint64); INPUT_TYPEMAP(long long, int64); INPUT_TYPEMAP(unsigned long long, uint64); INPUT_TYPEMAP(float, float32); INPUT_TYPEMAP(double, float64); #undef INPUT_TYPEMAP // OUTPUT typemaps. These typemaps are used for parameters that // are output only. An array replaces the c pointer or reference parameter. // The output value is returned in this array passed in. /* OUTPUT typemaps --------------- The following typemaps can be applied to turn a pointer or reference into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. This works by a Go slice being passed as a parameter where a c pointer or reference is required. As with any Go function, the array is passed by reference so that any modifications to the array will be picked up in the calling function. Note that the array passed in MUST have at least one element, but as the c function does not require any input, the value can be set to anything. bool *OUTPUT, bool &OUTPUT signed char *OUTPUT, signed char &OUTPUT unsigned char *OUTPUT, unsigned char &OUTPUT short *OUTPUT, short &OUTPUT unsigned short *OUTPUT, unsigned short &OUTPUT int *OUTPUT, int &OUTPUT unsigned int *OUTPUT, unsigned int &OUTPUT long *OUTPUT, long &OUTPUT unsigned long *OUTPUT, unsigned long &OUTPUT long long *OUTPUT, long long &OUTPUT unsigned long long *OUTPUT, unsigned long long &OUTPUT float *OUTPUT, float &OUTPUT double *OUTPUT, double &OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters): double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Go output of the function would be the function return value and the value in the single element array. In Go you would use it like this: ptr := []float64{0.0} fraction := modulename.Modf(5.0,ptr) There are no char *OUTPUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *OUTPUT {char *output}; void f(char *output); */ %define OUTPUT_TYPEMAP(TYPE, GOTYPE) %typemap(gotype) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%} %typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp) { if ($input.len == 0) { _swig_gopanic("array must contain at least 1 element"); } $1 = &temp; } %typemap(out) TYPE *OUTPUT, TYPE &OUTPUT "" %typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT "" %typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT { TYPE* a = (TYPE *) $input.array; a[0] = temp$argnum; } %enddef OUTPUT_TYPEMAP(bool, bool); OUTPUT_TYPEMAP(signed char, int8); OUTPUT_TYPEMAP(char, byte); OUTPUT_TYPEMAP(unsigned char, byte); OUTPUT_TYPEMAP(short, int16); OUTPUT_TYPEMAP(unsigned short, uint16); OUTPUT_TYPEMAP(int, int); OUTPUT_TYPEMAP(unsigned int, uint); OUTPUT_TYPEMAP(long, int64); OUTPUT_TYPEMAP(unsigned long, uint64); OUTPUT_TYPEMAP(long long, int64); OUTPUT_TYPEMAP(unsigned long long, uint64); OUTPUT_TYPEMAP(float, float32); OUTPUT_TYPEMAP(double, float64); #undef OUTPUT_TYPEMAP /* INOUT typemaps -------------- Mappings for a parameter that is both an input and an output parameter The following typemaps can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" typemaps described earlier. Output values are returned as an element in a Go slice. bool *INOUT, bool &INOUT signed char *INOUT, signed char &INOUT unsigned char *INOUT, unsigned char &INOUT short *INOUT, short &INOUT unsigned short *INOUT, unsigned short &INOUT int *INOUT, int &INOUT unsigned int *INOUT, unsigned int &INOUT long *INOUT, long &INOUT unsigned long *INOUT, unsigned long &INOUT long long *INOUT, long long &INOUT unsigned long long *INOUT, unsigned long long &INOUT float *INOUT, float &INOUT double *INOUT, double &INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); This works similarly to C in that the mapping directly modifies the input value - the input must be an array with a minimum of one element. The element in the array is the input and the output is the element in the array. x := []float64{5.0} Neg(x); The implementation of the OUTPUT and INOUT typemaps is different to other languages in that other languages will return the output value as part of the function return value. This difference is due to Go being a typed language. There are no char *INOUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *INOUT {char *inout}; void f(char *inout); */ %define INOUT_TYPEMAP(TYPE, GOTYPE) %typemap(gotype) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%} %typemap(in) TYPE *INOUT, TYPE &INOUT { if ($input.len == 0) { _swig_gopanic("array must contain at least 1 element"); } $1 = ($1_ltype) $input.array; } %typemap(out) TYPE *INOUT, TYPE &INOUT "" %typemap(freearg) TYPE *INOUT, TYPE &INOUT "" %typemap(argout) TYPE *INOUT, TYPE &INOUT "" %enddef INOUT_TYPEMAP(bool, bool); INOUT_TYPEMAP(signed char, int8); INOUT_TYPEMAP(char, byte); INOUT_TYPEMAP(unsigned char, byte); INOUT_TYPEMAP(short, int16); INOUT_TYPEMAP(unsigned short, uint16); INOUT_TYPEMAP(int, int); INOUT_TYPEMAP(unsigned int, uint); INOUT_TYPEMAP(long, int64); INOUT_TYPEMAP(unsigned long, uint64); INOUT_TYPEMAP(long long, int64); INOUT_TYPEMAP(unsigned long long, uint64); INOUT_TYPEMAP(float, float32); INOUT_TYPEMAP(double, float64); #undef INOUT_TYPEMAP swig-3.0.2/Lib/go/cdata.i0000664000175000017500000000313712343605122014710 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cdata.i * * SWIG library file containing macros for manipulating raw C data as strings. * ----------------------------------------------------------------------------- */ %{ typedef struct SWIGCDATA { char *data; intgo len; intgo cap; } SWIGCDATA; %} %typemap(gotype) SWIGCDATA %{ []byte %} %typemap(out) SWIGCDATA %{ $result.data = (char*)_swig_goallocate($1.len); memcpy($result.data, $1.data, $1.len); $result.len = (intgo)$1.len; $result.cap = $result.len; %} /* ----------------------------------------------------------------------------- * %cdata(TYPE [, NAME]) * * Convert raw C data to a binary string. * ----------------------------------------------------------------------------- */ %define %cdata(TYPE,NAME...) %insert("header") { #if #NAME == "" static SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements) { #else static SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements) { #endif SWIGCDATA d; d.data = (char *) ptr; #if #TYPE != "void" d.len = nelements*sizeof(TYPE); #else d.len = nelements; #endif return d; } } %typemap(default) int nelements "$1 = 1;" #if #NAME == "" SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements); #else SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements); #endif %enddef %typemap(default) int nelements; %rename(cdata) ::cdata_void(void *ptr, int nelements); %cdata(void); /* Memory move function. Due to multi-argument typemaps this appears to be wrapped as void memmove(void *data, const char *s); */ void memmove(void *data, char *indata, int inlen); swig-3.0.2/Lib/go/std_common.i0000664000175000017500000000014512343605122015772 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.2/Lib/go/std_list.i0000664000175000017500000000170312343605122015456 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %{ #include #include %} namespace std { template > class list { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef Alloc allocator_type; list(); size_type size() const; bool empty() const; %rename(isEmpty) empty; void clear(); void push_front(const value_type& x); void pop_front(); void push_back(const value_type& x); void pop_back(); void remove(value_type x); void reverse(); void unique(); void sort(); void merge(list& x); }; } swig-3.0.2/Lib/go/exception.i0000664000175000017500000000025512343605122015630 0ustar williamwilliam%typemap(throws,noblock=1) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } %insert("runtime") %{ #define SWIG_exception(code, msg) _swig_gopanic(msg) %} swig-3.0.2/Lib/go/go.swg0000664000175000017500000003037412343605122014614 0ustar williamwilliam/* ------------------------------------------------------------ * go.swg * * Go configuration module. * ------------------------------------------------------------ */ /* Code insertion directives */ #define %go_import(...) %insert(go_imports) %{__VA_ARGS__%} /* Basic types */ %typemap(gotype) bool, const bool & "bool" %typemap(gotype) char, const char & "byte" %typemap(gotype) signed char, const signed char & "int8" %typemap(gotype) unsigned char, const unsigned char & "byte" %typemap(gotype) short, const short & "int16" %typemap(gotype) unsigned short, const unsigned short & "uint16" %typemap(gotype) int, const int & "int" %typemap(gotype) unsigned int, const unsigned int & "uint" %typemap(gotype) long, const long & "int64" %typemap(gotype) unsigned long, const unsigned long & "uint64" %typemap(gotype) long long, const long long & "int64" %typemap(gotype) unsigned long long, const unsigned long long & "uint64" %typemap(gotype) float, const float & "float32" %typemap(gotype) double, const double & "float64" %typemap(in) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $1 = ($1_ltype)$input; %} %typemap(in) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long long &, const unsigned long long &, const float &, const double & %{ $1 = ($1_ltype)&$input; %} %typemap(in) const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = ($1_ltype)&temp; %} %typemap(out) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $result = $1; %} %typemap(out) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & %{ $result = ($*1_ltype)*$1; %} %typemap(out) void "" %typemap(directorin) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $input = ($1_ltype)$1; %} %typemap(directorin) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & %{ $input = ($*1_ltype)$1; %} %typemap(directorout) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $result = ($1_ltype)$input; %} %typemap(directorout) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & %{ $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype)); *$result = *($1_ltype)&$input; %} /* The size_t type. */ %typemap(gotype) size_t, const size_t & %{int64%} %typemap(in) size_t %{ $1 = (size_t)$input; %} %typemap(in) const size_t & %{ $1 = ($1_ltype)&$input; %} %typemap(out) size_t %{ $result = $1; %} %typemap(out) const size_t & %{ $result = ($*1_ltype)*$1; %} %typemap(directorin) size_t %{ $input = (size_t)$1; %} %typemap(directorin) const size_t & %{ $input = ($*1_ltype)$1; %} %typemap(directorout) size_t %{ $result = ($1_ltype)$input; %} %typemap(directorout) const size_t & %{ $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype)); *$result = *($1_ltype)$input; %} /* Member pointers. */ %typemap(gotype) SWIGTYPE (CLASS::*) %{$gotypename%} %typemap(in) SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)$input; %} %typemap(out) SWIGTYPE (CLASS::*) %{ $result = _swig_goallocate(sizeof($1_ltype)); *($&1_ltype)$result = $1; %} %typemap(directorin) SWIGTYPE (CLASS::*) %{ $input = *($&1_ltype)$1; %} %typemap(directorout) SWIGTYPE (CLASS::*) %{ $result = _swig_goallocate(sizeof($1_ltype)); *($&1_ltype)$result = $input; %} /* Pointers. */ /* We can't translate pointers using a typemap, so that is handled in the C++ code. */ %typemap(gotype) SWIGTYPE * %{$gotypename%} %typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE * %{ *($&1_ltype)&$result = $1; %} %typemap(directorin) SWIGTYPE * %{ $input = ($1_ltype)$1; %} %typemap(directorout) SWIGTYPE * %{ $result = ($1_ltype)$input; %} %apply SWIGTYPE * { SWIGTYPE *const } /* Pointer references. */ %typemap(gotype) SWIGTYPE *const& %{$gotypename%} %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = *($1_ltype)&$input; $1 = ($1_ltype)&temp; %} %typemap(out) SWIGTYPE *const& %{ *($1_ltype)&$result = *$1; %} /* References. */ /* Converting a C++ reference to Go has to be handled in the C++ code. */ %typemap(gotype) SWIGTYPE & %{$gotypename%} %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE & %{ *($&1_ltype)&$result = $1; %} %typemap(directorin) SWIGTYPE & %{ $input = ($1_ltype)&$1; %} %typemap(directorout) SWIGTYPE & %{ *($&1_ltype)&$result = $input; %} %typemap(gotype) SWIGTYPE && %{$gotypename%} %typemap(in) SWIGTYPE && %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE && %{ *($&1_ltype)&$result = $1; %} %typemap(directorin) SWIGTYPE && %{ $input = ($1_ltype)&$1_name; %} %typemap(directorout) SWIGTYPE && %{ *($&1_ltype)&$result = $input; %} /* C arrays turn into Go pointers. If we know the length we can use a slice. */ %typemap(gotype) SWIGTYPE [] %{$gotypename%} %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %} %typemap(directorin) SWIGTYPE [] %{ $input = *($1_ltype)&$1; %} %typemap(directorout) SWIGTYPE [] %{ *($&1_ltype)&$result = $input; %} /* Strings. */ %typemap(gotype) char *, char *&, char[ANY], char[], signed char *, signed char *&, signed char[ANY], signed char[], unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] "string" /* Needed to avoid confusion with the way the go module handles references. */ %typemap(gotype) char&, unsigned char& "*byte" %typemap(gotype) signed char& "*int8" %typemap(in) char *, char[ANY], char[], signed char *, signed char[ANY], signed char[], unsigned char *, unsigned char[ANY], unsigned char[] %{ $1 = ($1_ltype)$input.p; %} %typemap(in) char *&, signed char *&, unsigned char *& %{ $1 = ($1_ltype)$input.p; %} %typemap(out) char *, char *&, char[ANY], char[], signed char *, signed char *&, signed char[ANY], signed char[], unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] %{ $result = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0); %} %typemap(directorin) char *, char *&, char[ANY], char[], signed char *, signed char *&, signed char[ANY], signed char[], unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] %{ $input = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0); %} %typemap(directorout) char *, char *&, char[ANY], char[], signed char *, signed char *&, signed char[ANY], signed char[], unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] %{ $result = ($1_ltype)$input.p; %} /* String & length */ %typemap(gotype) (char *STRING, size_t LENGTH) "string" %typemap(in) (char *STRING, size_t LENGTH) %{ $1 = ($1_ltype)$input.p; $2 = ($2_ltype)$input.n; %} %typemap(out) (char *STRING, size_t LENGTH) %{ $result = _swig_makegostring((char*)$1, (size_t)$2); %} %typemap(directorin) (char *STRING, size_t LENGTH) %{ $input = _swig_makegostring((char*)$1, $2); %} %typemap(directorout) (char *STRING, size_t LENGTH) %{ $1 = ($1_ltype)$input.p; $2 = ($2_ltype)$input.n; %} /* Enums. We can't do the right thing for enums in typemap(gotype) so we deliberately don't define them. The right thing would be to capitalize the name. This is instead done in go.cxx. */ %typemap(gotype) enum SWIGTYPE %{$gotypename%} %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (intgo)$1; %} %typemap(directorin) enum SWIGTYPE %{ $input = ($1_ltype)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE & (intgo e) %{ e = (intgo)$1; $input = &e; %} %typemap(directorout) enum SWIGTYPE & %{ $*1_ltype f = ($*1_ltype)*$input; $result = ($1_ltype)&f; %} /* Arbitrary type. This is a type passed by value in the C/C++ code. We convert it to a pointer for the Go code. Note that all basic types are explicitly handled above. */ %typemap(gotype) SWIGTYPE %{$gotypename%} %typemap(in) SWIGTYPE ($&1_type argp) %{ argp = ($&1_ltype)$input; if (argp == NULL) { _swig_gopanic("Attempt to dereference null $1_type"); } $1 = ($1_ltype)*argp; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{ *($&1_ltype*)&$result = new $1_ltype($1); %} #else { $&1_ltype $1ptr = ($&1_ltype)malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); *($&1_ltype*)&$result = $1ptr; } #endif %typemap(directorin) SWIGTYPE %{ $input = ($&1_ltype)&$1; %} %typemap(directorout) SWIGTYPE %{ $result = *($&1_ltype)$input; %} /* Exception handling */ %typemap(throws) char * %{ _swig_gopanic($1); %} %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ (void)$1; _swig_gopanic("C++ $1_type exception thrown"); %} /* Typecheck typemaps. The purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in Go as more than one C++ type maps to a single Go type. */ %typecheck(SWIG_TYPECHECK_BOOL) /* Go bool */ bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) /* Go byte */ char, const char &, unsigned char, const unsigned char & "" %typecheck(SWIG_TYPECHECK_INT8) /* Go int8 */ signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_INT16) /* Go int16 */ short, const short & "" %typecheck(SWIG_TYPECHECK_INT16) /* Go uint16 */ unsigned short, const unsigned short & "" %typecheck(SWIG_TYPECHECK_INT32) /* Go int */ int, const int & "" %typecheck(SWIG_TYPECHECK_INT32) /* Go uint */ unsigned int, const unsigned int & "" %typecheck(SWIG_TYPECHECK_INT64) /* Go int64 */ long, const long &, long long, const long long & "" %typecheck(SWIG_TYPECHECK_INT64) /* Go uint64 */ unsigned long, const unsigned long &, unsigned long long, const unsigned long long & "" %typecheck(SWIG_TYPECHECK_FLOAT) /* Go float32 */ float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) /* Go float64 */ double, const double & "" %typecheck(SWIG_TYPECHECK_STRING) /* Go string */ char *, char *&, char[ANY], char [], signed char *, signed char *&, signed char[ANY], signed char [], unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char [] "" %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *const&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* Go keywords. */ %include %include swig-3.0.2/Lib/go/std_vector.i0000664000175000017500000000466712343605122016021 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i %} namespace std { %naturalvar string; class string; %typemap(gotype) string, const string & "string" %typemap(in) string %{ $1.assign($input.p, $input.n); %} %typemap(directorout) string %{ $result.assign($input.p, $input.n); %} %typemap(out) string %{ $result = _swig_makegostring($1.data(), $1.length()); %} %typemap(directorin) string %{ $input = _swig_makegostring($1.data(), $1.length()); %} %typemap(in) const string & %{ $*1_ltype $1_str($input.p, $input.n); $1 = &$1_str; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & %{ static $*1_ltype $1_str; $1_str.assign($input.p, $input.n); $result = &$1_str; %} %typemap(out) const string & %{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %} %typemap(directorin) const string & %{ $input = _swig_makegostring($1.data(), $1.length()); %} } swig-3.0.2/Lib/go/std_except.i0000664000175000017500000000226712343605122016001 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. * These typemaps are used when methods are declared with an STL exception specification, such as * size_t at() const throw (std::out_of_range); * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %ignore exception; struct exception {}; } %typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%} %typemap(throws) std::domain_error %{_swig_gopanic($1.what());%} %typemap(throws) std::exception %{_swig_gopanic($1.what());%} %typemap(throws) std::invalid_argument %{_swig_gopanic($1.what());%} %typemap(throws) std::length_error %{_swig_gopanic($1.what());%} %typemap(throws) std::logic_error %{_swig_gopanic($1.what());%} %typemap(throws) std::out_of_range %{_swig_gopanic($1.what());%} %typemap(throws) std::overflow_error %{_swig_gopanic($1.what());%} %typemap(throws) std::range_error %{_swig_gopanic($1.what());%} %typemap(throws) std::runtime_error %{_swig_gopanic($1.what());%} %typemap(throws) std::underflow_error %{_swig_gopanic($1.what());%} swig-3.0.2/Lib/go/stl.i0000664000175000017500000000044212343605122014432 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/go/std_deque.i0000664000175000017500000000003412343605122015602 0ustar williamwilliam%include swig-3.0.2/Lib/go/gokw.swg0000664000175000017500000000105312343605122015146 0ustar williamwilliam/* Rename keywords. */ #define GOKW(x) %keywordwarn("'" `x` "' is a Go keyword, renaming to 'X"`x`"'",rename="X%s") `x` #define GOBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in Go") "::"`x` GOKW(break); GOKW(case); GOKW(chan); GOKW(const); GOKW(continue); GOKW(default); GOKW(defer); GOKW(else); GOKW(fallthrough); GOKW(for); GOKW(func); GOKW(go); GOKW(goto); GOKW(if); GOKW(import); GOKW(interface); GOKW(package); GOKW(range); GOKW(return); GOKW(select); GOKW(struct); GOKW(switch); GOKW(type); GOKW(var); GOBN(map); #undef GOKW swig-3.0.2/Lib/go/goruntime.swg0000664000175000017500000001155512343605122016220 0ustar williamwilliam/* ------------------------------------------------------------ * goruntime.swg * * Go runtime code for the various generated files. * ------------------------------------------------------------ */ %insert(runtime) %{ #include #include #include #include #include %} #if SWIGGO_INTGO_SIZE == 32 %insert(runtime) %{ typedef int intgo; typedef unsigned int uintgo; %} #elif SWIGGO_INTGO_SIZE == 64 %insert(runtime) %{ typedef long long intgo; typedef unsigned long long uintgo; %} #else %insert(runtime) %{ typedef ptrdiff_t intgo; typedef size_t uintgo; %} #endif %insert(runtime) %{ typedef struct { char *p; intgo n; } _gostring_; typedef struct { void* array; intgo len; intgo cap; } _goslice_; %} #ifndef SWIGGO_GCCGO /* Boilerplate for C/C++ code when using 6g/8g. This code is compiled with gcc. */ %insert(runtime) %{ #define swiggo_size_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1]; #define swiggo_size_assert(t, n) swiggo_size_assert_eq(sizeof(t), n, swiggo_sizeof_##t##_is_not_##n) swiggo_size_assert(char, 1) swiggo_size_assert(short, 2) swiggo_size_assert(int, 4) typedef long long swiggo_long_long; swiggo_size_assert(swiggo_long_long, 8) swiggo_size_assert(float, 4) swiggo_size_assert(double, 8) #ifdef __cplusplus extern "C" { #endif extern void crosscall2(void (*fn)(void *, int), void *, int); extern void _cgo_allocate(void *, int); extern void _cgo_panic(void *, int); #ifdef __cplusplus } #endif static void *_swig_goallocate(size_t len) { struct { size_t len; void *ret; } a; a.len = len; crosscall2(_cgo_allocate, &a, (int) sizeof a); return a.ret; } static void _swig_gopanic(const char *p) { struct { const char *p; } a; a.p = p; crosscall2(_cgo_panic, &a, (int) sizeof a); } %} /* Boilerplate for C code when using 6g/8g. This code is compiled with 6c/8c. */ %insert(gc_header) %{ #include "runtime.h" #include "cgocall.h" #ifdef _64BIT #define SWIG_PARM_SIZE 8 #else #define SWIG_PARM_SIZE 4 #endif %} #else /* Boilerplate for C/C++ code when using gccgo. */ %insert(runtime) %{ #define SWIGGO_GCCGO #ifdef __cplusplus extern "C" { #endif extern void *_cgo_allocate(size_t); extern void _cgo_panic(const char *); /* Implementations of SwigCgocall and friends for different versions of gccgo. The Go code will call these functions using C names with a prefix of the module name. The implementations here call the routine in libgo. The routines to call vary depending on the gccgo version. We assume that the version of gcc used to compile this file is the same as the version of gccgo. */ #define SWIG_GCC_VERSION \ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #if SWIG_GCC_VERSION < 40700 #define SwigDoCgocall() #define SwigDoCgocallDone() #define SwigDoCgocallBack() #define SwigDoCgocallBackDone() #elif SWIG_GCC_VERSION == 40700 void SwigDoCgocall(void) __asm__("libgo_syscall.syscall.Entersyscall"); void SwigDoCgocallDone(void) __asm__("libgo_syscall.syscall.Exitsyscall"); void SwigDoCgocallBack(void) __asm__("libgo_syscall.syscall.Exitsyscall"); void SwigDoCgocallBackDone(void) __asm__("libgo_syscall.syscall.Entersyscall"); #else void SwigDoCgocall(void) __asm__("syscall.Cgocall"); void SwigDoCgocallDone(void) __asm__("syscall.CgocallDone"); void SwigDoCgocallBack(void) __asm__("syscall.CgocallBack"); void SwigDoCgocallBackDone(void) __asm__("syscall.CgocallBackDone"); #endif #define SWIGSTRINGIFY2(s) #s #define SWIGSTRINGIFY(s) SWIGSTRINGIFY2(s) void SwigCgocall() __asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocall"); void SwigCgocall() { SwigDoCgocall(); } void SwigCgocallDone() __asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocallDone"); void SwigCgocallDone() { SwigDoCgocallDone(); } void SwigCgocallBack() __asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocallBack"); void SwigCgocallBack() { SwigDoCgocallBack(); } void SwigCgocallBackDone() __asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocallBackDone"); void SwigCgocallBackDone() { SwigDoCgocallBackDone(); } #undef SWIGSTRINGIFY #undef SWIGSTRINGIFY2 #ifdef __cplusplus } #endif #define _swig_goallocate _cgo_allocate #define _swig_gopanic _cgo_panic %} #endif %insert(runtime) %{ static _gostring_ _swig_makegostring(const char *p, size_t l) { _gostring_ ret; ret.p = (char*)_swig_goallocate(l + 1); memcpy(ret.p, p, l); ret.n = l; return ret; } #define SWIG_contract_assert(expr, msg) \ if (!(expr)) { _swig_gopanic(msg); } else %} #ifndef SWIGGO_GCCGO %go_import("unsafe", _ "runtime/cgo") #else %go_import("syscall", "unsafe") %insert(go_header) %{ type _ syscall.Sockaddr %} #endif %insert(go_header) %{ type _ unsafe.Pointer %} /* Function pointers are translated by the code in go.cxx into _swig_fnptr. Member pointers are translated to _swig_memberptr. */ %insert(go_header) %{ type _swig_fnptr *byte type _swig_memberptr *byte %} swig-3.0.2/Lib/wchar.i0000664000175000017500000000046512343605122014334 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wchar.i * ----------------------------------------------------------------------------- */ /* wchar_t not supported, unless otherwise specified in the target language. */ #if defined(SWIG_WCHAR) #undef SWIG_WCHAR #endif swig-3.0.2/Lib/inttypes.i0000664000175000017500000000451412343605122015106 0ustar williamwilliam/* ----------------------------------------------------------------------------- * inttypes.i * * SWIG library file for ISO C99 types: 7.8 Format conversion of integer types * ----------------------------------------------------------------------------- */ %{ #include %} %include %include #ifdef __cplusplus extern "C" { #endif #ifdef SWIGWORDSIZE64 /* We have to define the `uintmax_t' type using `ldiv_t'. */ typedef struct { long int quot; /* Quotient. */ long int rem; /* Remainder. */ } imaxdiv_t; #else /* We have to define the `uintmax_t' type using `lldiv_t'. */ typedef struct { long long int quot; /* Quotient. */ long long int rem; /* Remainder. */ } imaxdiv_t; #endif /* Compute absolute value of N. */ extern intmax_t imaxabs (intmax_t n); /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ extern imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom); #ifdef SWIG_WCHAR /* Like `wcstol' but convert to `intmax_t'. */ extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base); /* Like `wcstoul' but convert to `uintmax_t'. */ extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t ** endptr, int base); #endif #ifdef SWIGWORDSIZE64 /* Like `strtol' but convert to `intmax_t'. */ extern intmax_t strtoimax (const char *nptr, char **endptr, int base); /* Like `strtoul' but convert to `uintmax_t'. */ extern uintmax_t strtoumax (const char *nptr, char **endptr,int base); #ifdef SWIG_WCHAR /* Like `wcstol' but convert to `intmax_t'. */ extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base); /* Like `wcstoul' but convert to `uintmax_t'. */ extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base); #endif #else /* SWIGWORDSIZE32 */ /* Like `strtol' but convert to `intmax_t'. */ extern intmax_t strtoimax (const char *nptr, char **endptr, int base); /* Like `strtoul' but convert to `uintmax_t'. */ extern uintmax_t strtoumax (const char *nptr, char **endptr, int base); #ifdef SWIG_WCHAR /* Like `wcstol' but convert to `intmax_t'. */ extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base); #endif #endif /* SWIGWORDSIZE64 */ #ifdef __cplusplus } #endif swig-3.0.2/Lib/linkruntime.c0000664000175000017500000000100012343605122015545 0ustar williamwilliam#ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) # define SWIGEXPORT # else # define SWIGEXPORT __declspec(dllexport) # endif # else # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) # define SWIGEXPORT __attribute__ ((visibility("default"))) # else # define SWIGEXPORT # endif # endif #endif static void *ptr = 0; SWIGEXPORT void * SWIG_ReturnGlobalTypeList(void *t) { if (!ptr && !t) ptr = t; return ptr; } swig-3.0.2/Lib/runtime.swg0000664000175000017500000000232412343605122015257 0ustar williamwilliam/* -----------------------------------------------------------------------------* Standard SWIG API for use inside user code. Don't include this file directly, run the command swig -python -external-runtime Also, read the Modules chapter of the SWIG Manual. * -----------------------------------------------------------------------------*/ #ifdef SWIG_MODULE_CLIENTDATA_TYPE SWIGRUNTIMEINLINE swig_type_info * SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { swig_module_info *module = SWIG_GetModule(clientdata); return SWIG_TypeQueryModule(module, module, name); } SWIGRUNTIMEINLINE swig_type_info * SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { swig_module_info *module = SWIG_GetModule(clientdata); return SWIG_MangledTypeQueryModule(module, module, name); } #else SWIGRUNTIMEINLINE swig_type_info * SWIG_TypeQuery(const char *name) { swig_module_info *module = SWIG_GetModule(NULL); return SWIG_TypeQueryModule(module, module, name); } SWIGRUNTIMEINLINE swig_type_info * SWIG_MangledTypeQuery(const char *name) { swig_module_info *module = SWIG_GetModule(NULL); return SWIG_MangledTypeQueryModule(module, module, name); } #endif swig-3.0.2/Lib/cmalloc.i0000664000175000017500000000446212343605122014643 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cmalloc.i * * SWIG library file containing macros that can be used to create objects using * the C malloc function. * ----------------------------------------------------------------------------- */ %{ #include %} /* %malloc(TYPE [, NAME = TYPE]) %calloc(TYPE [, NAME = TYPE]) %realloc(TYPE [, NAME = TYPE]) %free(TYPE [, NAME = TYPE]) %allocators(TYPE [,NAME = TYPE]) Creates functions for allocating/reallocating memory. TYPE *malloc_NAME(int nbytes = sizeof(TYPE); TYPE *calloc_NAME(int nobj=1, int size=sizeof(TYPE)); TYPE *realloc_NAME(TYPE *ptr, int nbytes); void free_NAME(TYPE *ptr); */ %define %malloc(TYPE,NAME...) #if #NAME != "" %rename(malloc_##NAME) ::malloc(int nbytes); #else %rename(malloc_##TYPE) ::malloc(int nbytes); #endif #if #TYPE != "void" %typemap(default) int nbytes "$1 = (int) sizeof(TYPE);" #endif TYPE *malloc(int nbytes); %typemap(default) int nbytes; %enddef %define %calloc(TYPE,NAME...) #if #NAME != "" %rename(calloc_##NAME) ::calloc(int nobj, int sz); #else %rename(calloc_##TYPE) ::calloc(int nobj, int sz); #endif #if #TYPE != "void" %typemap(default) int sz "$1 = (int) sizeof(TYPE);" #else %typemap(default) int sz "$1 = 1;" #endif %typemap(default) int nobj "$1 = 1;" TYPE *calloc(int nobj, int sz); %typemap(default) int sz; %typemap(default) int nobj; %enddef %define %realloc(TYPE,NAME...) %insert("header") { #if #NAME != "" TYPE *realloc_##NAME(TYPE *ptr, int nitems) #else TYPE *realloc_##TYPE(TYPE *ptr, int nitems) #endif { #if #TYPE != "void" return (TYPE *) realloc(ptr, nitems*sizeof(TYPE)); #else return (TYPE *) realloc(ptr, nitems); #endif } } #if #NAME != "" TYPE *realloc_##NAME(TYPE *ptr, int nitems); #else TYPE *realloc_##TYPE(TYPE *ptr, int nitems); #endif %enddef %define %free(TYPE,NAME...) #if #NAME != "" %rename(free_##NAME) ::free(TYPE *ptr); #else %rename(free_##TYPE) ::free(TYPE *ptr); #endif void free(TYPE *ptr); %enddef %define %sizeof(TYPE,NAME...) #if #NAME != "" %constant int sizeof_##NAME = sizeof(TYPE); #else %constant int sizeof_##TYPE = sizeof(TYPE); #endif %enddef %define %allocators(TYPE,NAME...) %malloc(TYPE,NAME) %calloc(TYPE,NAME) %realloc(TYPE,NAME) %free(TYPE,NAME) #if #TYPE != "void" %sizeof(TYPE,NAME) #endif %enddef swig-3.0.2/Lib/cstring.i0000664000175000017500000000050412343605122014673 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cstring.i * ----------------------------------------------------------------------------- */ %echo "cstring.i not implemented for this target" #define SWIG_CSTRING_UNIMPL /* old name keep for compatibility */ #define _CSTRING_UNIMPL swig-3.0.2/Lib/attribute.i0000664000175000017500000000076012343605122015231 0ustar williamwilliam/* ----------------------------------------------------------------------------- * attribute.i * * SWIG library file for implementing attributes. * ----------------------------------------------------------------------------- */ /* we use a simple exception warning here */ %{ #include %} #define %attribute_exception(code,msg) printf("%s\n",msg) #ifndef %arg #define %arg(x...) x #endif #ifndef %mangle #define %mangle(Type...) #@Type #endif %include swig-3.0.2/Lib/swigerrors.swg0000664000175000017500000000076312343605122016007 0ustar williamwilliam/* Errors in SWIG */ #define SWIG_UnknownError -1 #define SWIG_IOError -2 #define SWIG_RuntimeError -3 #define SWIG_IndexError -4 #define SWIG_TypeError -5 #define SWIG_DivisionByZero -6 #define SWIG_OverflowError -7 #define SWIG_SyntaxError -8 #define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 #define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 swig-3.0.2/Lib/lua/0000775000175000017500000000000012343605122013632 5ustar williamwilliamswig-3.0.2/Lib/lua/luatypemaps.swg0000664000175000017500000003365312343605122016732 0ustar williamwilliam/* ----------------------------------------------------------------------------- * luatypemaps.swg * * basic typemaps for Lua. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * standard typemaps * ----------------------------------------------------------------------------- */ /* NEW LANGUAGE NOTE: the 'checkfn' param is something that I added for typemap(in) it is an optional fn call to check the type of the lua object the fn call must be of the form int checkfn(lua_State *L, int index); and return 1/0 depending upon if this is the correct type For the typemap(out), an additional SWIG_arg parameter must be incremented to reflect the number of values returned (normally SWIG_arg++; will do) */ // numbers %typemap(in,checkfn="lua_isnumber") int, short, long, signed char, float, double %{$1 = ($type)lua_tonumber(L, $input);%} // additional check for unsigned numbers, to not permit negative input %typemap(in,checkfn="lua_isnumber") unsigned int, unsigned short, unsigned long, unsigned char %{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative") $1 = ($type)lua_tonumber(L, $input);%} %typemap(out) int,short,long, unsigned int,unsigned short,unsigned long, signed char,unsigned char, float,double %{ lua_pushnumber(L, (lua_Number) $1); SWIG_arg++;%} // we must also provide typemaps for primitives by const reference: // given a function: // int intbyref(const int& i); // SWIG assumes that this code will need a pointer to int to be passed in // (this might be ok for objects by const ref, but not for numeric primitives) // therefore we add a set of typemaps to fix this (for both in & out) %typemap(in,checkfn="lua_isnumber") const int&($basetype temp) %{ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} %typemap(in,checkfn="lua_isnumber") const unsigned int&($basetype temp) %{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative") temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} %typemap(out) const int&, const unsigned int& %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} // for the other numbers we can just use an apply statement to cover them %apply const int & {const short&,const long&,const signed char&, const float&,const double&}; %apply const unsigned int & {const unsigned short&,const unsigned long&, const unsigned char&}; /* enums have to be handled slightly differently VC++ .net will not allow a cast from lua_Number(double) to enum directly. */ %typemap(in,checkfn="lua_isnumber") enum SWIGTYPE %{$1 = ($type)(int)lua_tonumber(L, $input);%} %typemap(out) enum SWIGTYPE %{ lua_pushnumber(L, (lua_Number)(int)($1)); SWIG_arg++;%} // and const refs %typemap(in,checkfn="lua_isnumber") const enum SWIGTYPE &($basetype temp) %{ temp=($basetype)(int)lua_tonumber(L,$input); $1=&temp;%} %typemap(in,checkfn="lua_isnumber") const enum SWIGTYPE &&($basetype temp) %{ temp=($basetype)(int)lua_tonumber(L,$input); $1=&temp;%} %typemap(out) const enum SWIGTYPE & %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} %typemap(out) const enum SWIGTYPE && %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} // boolean (which is a special type in lua) // note: lua_toboolean() returns 1 or 0 // note: 1 & 0 are not booleans in lua, only true & false %typemap(in,checkfn="lua_isboolean") bool %{$1 = (lua_toboolean(L, $input)!=0);%} %typemap(out) bool %{ lua_pushboolean(L,(int)($1!=0)); SWIG_arg++;%} // for const bool&, SWIG treats this as a const bool* so we must dereference it %typemap(in,checkfn="lua_isboolean") const bool& (bool temp) %{temp=(lua_toboolean(L, $input)!=0); $1=&temp;%} %typemap(out) const bool& %{ lua_pushboolean(L,(int)((*$1)!=0)); SWIG_arg++;%} // strings (char * and char[]) %fragment("SWIG_lua_isnilstring", "header") { SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) { int ret = lua_isstring(L, idx); if (!ret) ret = lua_isnil(L, idx); return ret; } } %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char *, char * %{$1 = ($ltype)lua_tostring(L, $input);%} %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char[ANY], char[ANY] %{$1 = ($ltype)lua_tostring(L, $input);%} %typemap(out) const char *, char * %{ lua_pushstring(L,(const char *)$1); SWIG_arg++;%} %typemap(out) const char[ANY], char[ANY] %{ lua_pushstring(L,(const char *)$1); SWIG_arg++;%} // char's // currently treating chars as small strings, not as numbers // (however signed & unsigned char's are numbers...) %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") char %{$1 = (lua_tostring(L, $input))[0];%} %typemap(out) char %{ lua_pushfstring(L,"%c",$1); SWIG_arg++;%} // by const ref %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char& (char temp) %{temp = (lua_tostring(L, $input))[0]; $1=&temp;%} %typemap(out) const char& %{ lua_pushfstring(L,"%c",*$1); SWIG_arg++;%} // pointers and references // under SWIG rules, it is ok, to have a pass in a lua nil, // it should be converted to a SWIG NULL. // This will only be allowed for pointers & arrays, not refs or by value // the checkfn lua_isuserdata will only work for userdata // the checkfn SWIG_isptrtype will work for both userdata and nil %typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE*,SWIGTYPE[] %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){ SWIG_fail_ptr("$symname",$argnum,$descriptor); } %} %typemap(in,checkfn="lua_isuserdata") SWIGTYPE& %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){ SWIG_fail_ptr("$symname",$argnum,$descriptor); } %} %typemap(in,checkfn="lua_isuserdata") SWIGTYPE&& %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){ SWIG_fail_ptr("$symname",$argnum,$descriptor); } %} // out is simple %typemap(out) SWIGTYPE*,SWIGTYPE& %{SWIG_NewPointerObj(L,$1,$descriptor,$owner); SWIG_arg++; %} %typemap(out) SWIGTYPE*,SWIGTYPE&& %{SWIG_NewPointerObj(L,$1,$descriptor,$owner); SWIG_arg++; %} // dynamic casts // this uses the SWIG_TypeDynamicCast() which relies on RTTI to find out what the pointer really is // the we return it as the correct type %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); SWIG_NewPointerObj(L,(void*)$1,ty,$owner); SWIG_arg++; } // passing objects by value // SWIG_ConvertPtr wants an object pointer (the $<ype argp) // then dereferences it to get the object %typemap(in,checkfn="lua_isuserdata") SWIGTYPE ($<ype argp) %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&argp,$&descriptor,0))){ SWIG_fail_ptr("$symname",$argnum,$&descriptor); } $1 = *argp; %} // Also needed for object ptrs by const ref // eg A* const& ref_pointer(A* const& a); // found in mixed_types.i %typemap(in,checkfn="lua_isuserdata") SWIGTYPE *const&($*ltype temp) %{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname"); $1=($1_ltype)&temp;%} %typemap(out) SWIGTYPE *const& %{SWIG_NewPointerObj(L,*$1,$*descriptor,$owner); SWIG_arg++; %} // DISOWN-ing typemaps // if you have an object pointer which must be disowned, use this typemap // eg. for void destroy_foo(Foo* toDie); // use %apply SWIGTYPE* DISOWN {Foo* toDie}; // you could just use %delobject, but this is more flexible %typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE* DISOWN,SWIGTYPE DISOWN[] %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,SWIG_POINTER_DISOWN))){ SWIG_fail_ptr("$symname",$argnum,$descriptor); } %} // Primitive types--return by value // must make a new object, copy the data & return the new object // Note: the brackets are {...} and not %{..%}, because we want them to be included in the wrapper // this is because typemap(out) does not support local variables, like in typemap(in) does // and we need the $&1_ltype resultptr; to be declared #ifdef __cplusplus %typemap(out) SWIGTYPE { $&1_ltype resultptr = new $1_ltype((const $1_ltype &) $1); SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++; } #else %typemap(out) SWIGTYPE { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++; } #endif // member function pointer // a member fn ptr is not 4 bytes like a normal pointer, but 8 bytes (at least on mingw) // so the standard wrapping cannot be done // nor can you cast a member function pointer to a void* (obviously) // therefore a special wrapping functions SWIG_ConvertMember() & SWIG_NewMemberObj() were written #ifdef __cplusplus %typemap(in,checkfn="lua_isuserdata") SWIGTYPE (CLASS::*) %{ if (!SWIG_IsOK(SWIG_ConvertMember(L,$input,(void*)(&$1),sizeof($type),$descriptor))) SWIG_fail_ptr("$symname",$argnum,$descriptor); %} %typemap(out) SWIGTYPE (CLASS::*) %{ SWIG_NewMemberObj(L,(void*)(&$1),sizeof($type),$descriptor); SWIG_arg++; %} #endif // void (must be empty without the SWIG_arg++) %typemap(out) void ""; /* void* is a special case A function void fn(void*) should take any kind of pointer as a parameter (just like C/C++ does) but if its an output, then it should be wrapped like any other SWIG object (using default typemap) */ %typemap(in,checkfn="SWIG_isptrtype") void* %{$1=($1_ltype)SWIG_MustGetPtr(L,$input,0,0,$argnum,"$symname");%} /* long long is another special case: as lua only supports one numeric type (lua_Number), we will just cast it to that & accept the loss of precision. An alternative solution would be a long long struct or class with the relevant operators. */ %apply long {long long, signed long long, unsigned long long}; %apply const long& {const long long&, const signed long long&, const unsigned long long&}; /* It is possible to also pass a lua_State* into a function, so void fn(int a, float b, lua_State* s) is wrappable as > fn(1,4.3) -- note: the state is implicitly passed in */ %typemap(in, numinputs=0) lua_State* %{$1 = L;%} /* ----------------------------------------------------------------------------- * typecheck rules * ----------------------------------------------------------------------------- */ /* These are needed for the overloaded functions These define the detection routines which will spot what parameters match which function */ // unfortunately lua only considers one type of number // so all numbers (int,float,double) match // you could add an advanced fn to get type & check if its integral %typecheck(SWIG_TYPECHECK_INTEGER) int, short, long, unsigned int, unsigned short, unsigned long, signed char, unsigned char, long long, unsigned long long, signed long long, const int &, const short &, const long &, const unsigned int &, const unsigned short &, const unsigned long &, const signed char&, const unsigned char&, const long long &, const unsigned long long &, enum SWIGTYPE, const enum SWIGTYPE&, const enum SWIGTYPE &&, float, double, const float &, const double& { $1 = lua_isnumber(L,$input); } %typecheck(SWIG_TYPECHECK_BOOL) bool, const bool & { $1 = lua_isboolean(L,$input); } // special check for a char (string of length 1) %typecheck(SWIG_TYPECHECK_CHAR,fragment="SWIG_lua_isnilstring") char, const char& { $1 = SWIG_lua_isnilstring(L,$input) && (lua_rawlen(L,$input)==1); } %typecheck(SWIG_TYPECHECK_STRING,fragment="SWIG_lua_isnilstring") char *, char[] { $1 = SWIG_lua_isnilstring(L,$input); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] { void *ptr; if (SWIG_isptrtype(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & { void *ptr; if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE && { void *ptr; if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; if (SWIG_isptrtype(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, 0, 0)) { $1 = 0; } else { $1 = 1; } } // Also needed for object pointers by const ref // eg const A* ref_pointer(A* const& a); // found in mixed_types.i %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const& { void *ptr; if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) { $1 = 0; } else { $1 = 1; } } /* ----------------------------------------------------------------------------- * Others * ----------------------------------------------------------------------------- */ // Array reference typemaps %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } // size_t (which is just a unsigned long) %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; /* ----------------------------------------------------------------------------- * Specials * ----------------------------------------------------------------------------- */ // swig::LANGUAGE_OBJ was added to allow containers of native objects // however its rather difficult to do this in lua, as you cannot hold pointers // to native objects (they are held in the interpreter) // therefore for now: just ignoring this feature #ifdef __cplusplus %ignore swig::LANGUAGE_OBJ; //%inline %{ %{ namespace swig { typedef struct{} LANGUAGE_OBJ; } %} #endif // __cplusplus swig-3.0.2/Lib/lua/std_map.i0000664000175000017500000000333212343605122015434 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; } swig-3.0.2/Lib/lua/wchar.i0000664000175000017500000000210612343605122015107 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wchar.i * * Typemaps for the wchar_t type * These are mapped to a Lua string and are passed around by value. * ----------------------------------------------------------------------------- */ // note: only support for pointer right now, not fixed length strings // TODO: determine how long a const wchar_t* is so we can write wstr2str() // & do the output typemap %{ #include wchar_t* str2wstr(const char *str, int len) { wchar_t* p; if (str==0 || len<1) return 0; p=(wchar_t *)malloc((len+1)*sizeof(wchar_t)); if (p==0) return 0; if (mbstowcs(p, str, len)==(size_t)-1) { free(p); return 0; } p[len]=0; return p; } %} %typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t * %{ $1 = str2wstr(lua_tostring( L, $input ),lua_rawlen( L, $input )); if ($1==0) {SWIG_Lua_pushferrstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} %} %typemap(freearg) wchar_t * %{ free($1); %} %typemap(typecheck) wchar_t * = char *; swig-3.0.2/Lib/lua/std_pair.i0000664000175000017500000000140112343605122015605 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * std::pair typemaps for LUA * ----------------------------------------------------------------------------- */ %{ #include %} /* A really cut down version of the pair class. this is not useful on its own - it needs a %template definition with it eg. namespace std { %template(IntPair) pair; %template(make_IntPair) make_pair; } */ namespace std { template struct pair { typedef T first_type; typedef U second_type; pair(); pair(T first, U second); pair(const pair& p); T first; U second; }; template pair make_pair(const T&,const U&); } swig-3.0.2/Lib/lua/typemaps.i0000664000175000017500000004575312343605122015664 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.swg * * SWIG Library file containing the main typemap code to support Lua modules. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * Basic inout typemaps * ----------------------------------------------------------------------------- */ /* These provide the basic ability for passing in & out of standard numeric data types (int,long,float,double, etc) The basic code looks like this: %typemap(in,checkfn="lua_isnumber") int *INPUT(int temp), int &INPUT(int temp) %{ temp = (int)lua_tonumber(L,$input); $1 = &temp; %} %typemap(in, numinputs=0) int *OUTPUT (int temp) %{ $1 = &temp; %} %typemap(argout) int *OUTPUT %{ lua_pushnumber(L, (double) *$1); SWIG_arg++;%} %typemap(in) int *INOUT = int *INPUT; %typemap(argout) int *INOUT = int *OUTPUT; However the code below is a mixture of #defines & such, so nowhere as easy to read To make you code work correctly its not just a matter of %including this file You also have to give SWIG the hints on which to use where eg extern int add_pointer(int* a1,int* a2); // a1 & a2 are pointer values to be added extern void swap(int* s1, int* s2); // does the swap You will need to either change the argument names extern int add_pointer(int* INPUT,int* INPUT); or provide a %apply statement %apply int* INOUT{ int *s1, int *s2 }; // if SWIG sees int* s1, int* s2, assume they are inout params */ %define SWIG_NUMBER_TYPEMAP(TYPE) %typemap(in,checkfn="lua_isnumber") TYPE *INPUT($*ltype temp), TYPE &INPUT($*ltype temp) %{ temp = ($*ltype)lua_tonumber(L,$input); $1 = &temp; %} %typemap(in, numinputs=0) TYPE *OUTPUT ($*ltype temp) %{ $1 = &temp; %} %typemap(argout) TYPE *OUTPUT %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} %typemap(in) TYPE *INOUT = TYPE *INPUT; %typemap(argout) TYPE *INOUT = TYPE *OUTPUT; %typemap(in) TYPE &OUTPUT = TYPE *OUTPUT; %typemap(argout) TYPE &OUTPUT = TYPE *OUTPUT; %typemap(in) TYPE &INOUT = TYPE *INPUT; %typemap(argout) TYPE &INOUT = TYPE *OUTPUT; // const version (the $*ltype is the basic number without ptr or const's) %typemap(in,checkfn="lua_isnumber") const TYPE *INPUT($*ltype temp) %{ temp = ($*ltype)lua_tonumber(L,$input); $1 = &temp; %} %enddef // now the code SWIG_NUMBER_TYPEMAP(unsigned char); SWIG_NUMBER_TYPEMAP(signed char); SWIG_NUMBER_TYPEMAP(short); SWIG_NUMBER_TYPEMAP(unsigned short); SWIG_NUMBER_TYPEMAP(signed short); SWIG_NUMBER_TYPEMAP(int); SWIG_NUMBER_TYPEMAP(unsigned int); SWIG_NUMBER_TYPEMAP(signed int); SWIG_NUMBER_TYPEMAP(long); SWIG_NUMBER_TYPEMAP(unsigned long); SWIG_NUMBER_TYPEMAP(signed long); SWIG_NUMBER_TYPEMAP(float); SWIG_NUMBER_TYPEMAP(double); SWIG_NUMBER_TYPEMAP(enum SWIGTYPE); // also for long longs's SWIG_NUMBER_TYPEMAP(long long); SWIG_NUMBER_TYPEMAP(unsigned long long); SWIG_NUMBER_TYPEMAP(signed long long); // note we dont do char, as a char* is probably a string not a ptr to a single char // similar for booleans %typemap(in,checkfn="lua_isboolean") bool *INPUT(bool temp), bool &INPUT(bool temp) %{ temp = (lua_toboolean(L,$input)!=0); $1 = &temp; %} %typemap(in, numinputs=0) bool *OUTPUT (bool temp),bool &OUTPUT (bool temp) %{ $1 = &temp; %} %typemap(argout) bool *OUTPUT,bool &OUTPUT %{ lua_pushboolean(L, (int)((*$1)!=0)); SWIG_arg++;%} %typemap(in) bool *INOUT = bool *INPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; /* ----------------------------------------------------------------------------- * Basic Array typemaps * ----------------------------------------------------------------------------- */ /* I have no idea why this kind of code does not exist in SWIG as standard, but here is it. This code will convert to/from 1D numeric arrays. In order to reduce code bloat, there are a few macros and quite a few functions defined (unfortunately this makes it a lot less clear) assuming we have functions void process_array(int arr[3]); // nice fixed size array void process_var_array(float arr[],int len); // variable sized array void process_var_array_inout(double* arr,int len); // variable sized array // data passed in & out void process_enum_inout_array_var(enum Days *arrinout, int len); // using enums void return_array_5(int arrout[5]); // out array only in order to wrap them correctly requires a typemap // inform SWIG of the correct typemap // For fixed length, you must specify it as INPUT[ANY] %apply (int INPUT[ANY]) {(int arr[3])}; // variable length arrays are just the same %apply (float INPUT[],int) {(float arr[],int len)}; // it is also ok, to map the TYPE* instead of a TYPE[] %apply (double *INOUT,int) {(double arr*,int len)}; // for the enum's you must use enum SWIGTYPE %apply (enum SWIGTYPE *INOUT,int) {(enum Days *arrinout, int len)}; // fixed length out if also fine %apply (int OUTPUT[ANY]) {(int arrout[5])}; Generally, you could use %typemap(...)=... but the %apply is neater & easier a few things of note: * all Lua tables are indexed from 1, all C/C++ arrays are indexed from 0 therefore t={6,5,3} -- t[1]==6, t[2]==5, t[3]==3 when passed to process_array(int arr[3]) becomes arr[0]==6, arr[1]==5, arr[2]==3 * for OUTPUT arrays, no array need be passed in, the fn will return a Lua table so for the above mentioned return_array_5() would look like arr=return_array_5() -- no parameters passed in * for INOUT arrays, a table must be passed in, and a new table will be returned (this is consistent with the way that numbers are processed) if you want just use arr={...} arr=process_var_array_inout(arr) -- arr is replaced by the new version The following are not yet supported: * variable length output only array (inout works ok) * multidimensional arrays * arrays of objects/structs * arrays of pointers */ /* The internals of the array management stuff helper fns/macros SWIG_ALLOC_ARRAY(TYPE,LEN) // returns a typed array TYPE[LEN] SWIG_FREE_ARRAY(PTR) // delete the ptr (if not zero) // counts the specified table & gets the size // integer version int SWIG_itable_size(lua_State* L, int index); // other version int SWIG_table_size(lua_State* L, int index); SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE) // this fn declares up 4 functions for helping to read/write tables // these can then be called by the macros ... // all assume the table is an integer indexes from 1 // but the C array is a indexed from 0 // created a fixed size array, reads the specified table // and then fills the array with numbers // returns ptr to the array if ok, or 0 for error // (also pushes a error message to the stack) TYPE* SWIG_get_NAME_num_array_fixed(lua_State* L, int index, int size); // as per SWIG_get_NAME_num_array_fixed() // but reads the entire table & creates an array of the correct size // (if the table is empty, it returns an error rather than a zero length array) TYPE* SWIG_get_NAME_num_array_var(lua_State* L, int index, int* size); // writes a table to Lua with all the specified numbers void SWIG_write_NAME_num_array(lua_State* L,TYPE *array,int size); // read the specified table, and fills the array with numbers // returns 1 of ok (only fails if it doesnt find numbers) // helper fn (called by SWIG_get_NAME_num_array_*() fns) int SWIG_read_NAME_num_array(lua_State* L,int index,TYPE *array,int size); */ /* Reported that you don't need to check for NULL for delete & free There probably is some compiler that its not true for, so the code is left here just in case. #ifdef __cplusplus #define SWIG_ALLOC_ARRAY(TYPE,LEN) new TYPE[LEN] #define SWIG_FREE_ARRAY(PTR) if(PTR){delete[] PTR;} #else #define SWIG_ALLOC_ARRAY(TYPE,LEN) (TYPE *)malloc(LEN*sizeof(TYPE)) #define SWIG_FREE_ARRAY(PTR) if(PTR){free(PTR);} #endif */ %{ #ifdef __cplusplus /* generic alloc/dealloc fns*/ #define SWIG_ALLOC_ARRAY(TYPE,LEN) new TYPE[LEN] #define SWIG_FREE_ARRAY(PTR) delete[] PTR #else #define SWIG_ALLOC_ARRAY(TYPE,LEN) (TYPE *)malloc(LEN*sizeof(TYPE)) #define SWIG_FREE_ARRAY(PTR) free(PTR) #endif /* counting the size of arrays:*/ SWIGINTERN int SWIG_itable_size(lua_State* L, int index) { int n=0; while(1){ lua_rawgeti(L,index,n+1); if (lua_isnil(L,-1))break; ++n; lua_pop(L,1); } lua_pop(L,1); return n; } SWIGINTERN int SWIG_table_size(lua_State* L, int index) { int n=0; lua_pushnil(L); /* first key*/ while (lua_next(L, index) != 0) { ++n; lua_pop(L, 1); /* removes `value'; keeps `key' for next iteration*/ } return n; } /* super macro to declare array typemap helper fns */ #define SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE)\ SWIGINTERN int SWIG_read_##NAME##_num_array(lua_State* L,int index,TYPE *array,int size){\ int i;\ for (i = 0; i < size; i++) {\ lua_rawgeti(L,index,i+1);\ if (lua_isnumber(L,-1)){\ array[i] = (TYPE)lua_tonumber(L,-1);\ } else {\ lua_pop(L,1);\ return 0;\ }\ lua_pop(L,1);\ }\ return 1;\ }\ SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\ TYPE *array;\ if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\ SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\ SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ return array;\ }\ SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_var(lua_State* L, int index, int* size)\ {\ TYPE *array;\ if (!lua_istable(L,index)) {\ SWIG_Lua_pusherrstring(L,"expected a table");\ return 0;\ }\ *size=SWIG_itable_size(L,index);\ if (*size<1){\ SWIG_Lua_pusherrstring(L,"table appears to be empty");\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,*size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\ SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ return array;\ }\ SWIGINTERN void SWIG_write_##NAME##_num_array(lua_State* L,TYPE *array,int size){\ int i;\ lua_newtable(L);\ for (i = 0; i < size; i++){\ lua_pushnumber(L,(lua_Number)array[i]);\ lua_rawseti(L,-2,i+1);/* -1 is the number, -2 is the table*/ \ }\ } %} /* This is one giant macro to define the typemaps & the helpers for array handling */ %define SWIG_TYPEMAP_NUM_ARR(NAME,TYPE) %{SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE)%} // fixed size array's %typemap(in) TYPE INPUT[ANY] %{ $1 = SWIG_get_##NAME##_num_array_fixed(L,$input,$1_dim0); if (!$1) SWIG_fail;%} %typemap(freearg) TYPE INPUT[ANY] %{ SWIG_FREE_ARRAY($1);%} // variable size array's %typemap(in) (TYPE *INPUT,int) %{ $1 = SWIG_get_##NAME##_num_array_var(L,$input,&$2); if (!$1) SWIG_fail;%} %typemap(freearg) (TYPE *INPUT,int) %{ SWIG_FREE_ARRAY($1);%} // out fixed arrays %typemap(in,numinputs=0) TYPE OUTPUT[ANY] %{ $1 = SWIG_ALLOC_ARRAY(TYPE,$1_dim0); %} %typemap(argout) TYPE OUTPUT[ANY] %{ SWIG_write_##NAME##_num_array(L,$1,$1_dim0); SWIG_arg++; %} %typemap(freearg) TYPE OUTPUT[ANY] %{ SWIG_FREE_ARRAY($1); %} // inout fixed arrays %typemap(in) TYPE INOUT[ANY]=TYPE INPUT[ANY]; %typemap(argout) TYPE INOUT[ANY]=TYPE OUTPUT[ANY]; %typemap(freearg) TYPE INOUT[ANY]=TYPE INPUT[ANY]; // inout variable arrays %typemap(in) (TYPE *INOUT,int)=(TYPE *INPUT,int); %typemap(argout) (TYPE *INOUT,int) %{ SWIG_write_##NAME##_num_array(L,$1,$2); SWIG_arg++; %} %typemap(freearg) (TYPE *INOUT,int)=(TYPE *INPUT,int); // TODO out variable arrays (is there a standard form for such things?) // referencing so that (int *INPUT,int) and (int INPUT[],int) are the same %typemap(in) (TYPE INPUT[],int)=(TYPE *INPUT,int); %typemap(freearg) (TYPE INPUT[],int)=(TYPE *INPUT,int); %enddef // the following line of code // declares the C helper fns for the array typemaps // as well as defining typemaps for // fixed len arrays in & out, & variable length arrays in SWIG_TYPEMAP_NUM_ARR(schar,signed char); SWIG_TYPEMAP_NUM_ARR(uchar,unsigned char); SWIG_TYPEMAP_NUM_ARR(int,int); SWIG_TYPEMAP_NUM_ARR(uint,unsigned int); SWIG_TYPEMAP_NUM_ARR(short,short); SWIG_TYPEMAP_NUM_ARR(ushort,unsigned short); SWIG_TYPEMAP_NUM_ARR(long,long); SWIG_TYPEMAP_NUM_ARR(ulong,unsigned long); SWIG_TYPEMAP_NUM_ARR(float,float); SWIG_TYPEMAP_NUM_ARR(double,double); // again enums are a problem so they need their own type // we use the int conversion routine & recast it %typemap(in) enum SWIGTYPE INPUT[ANY] %{ $1 = ($ltype)SWIG_get_int_num_array_fixed(L,$input,$1_dim0); if (!$1) SWIG_fail;%} %typemap(freearg) enum SWIGTYPE INPUT[ANY] %{ SWIG_FREE_ARRAY($1);%} // variable size arrays %typemap(in) (enum SWIGTYPE *INPUT,int) %{ $1 = ($ltype)SWIG_get_int_num_array_var(L,$input,&$2); if (!$1) SWIG_fail;%} %typemap(freearg) (enum SWIGTYPE *INPUT,int) %{ SWIG_FREE_ARRAY($1);%} // out fixed arrays %typemap(in,numinputs=0) enum SWIGTYPE OUTPUT[ANY] %{ $1 = SWIG_ALLOC_ARRAY(enum SWIGTYPE,$1_dim0); %} %typemap(argout) enum SWIGTYPE OUTPUT[ANY] %{ SWIG_write_int_num_array(L,(int*)$1,$1_dim0); SWIG_arg++; %} %typemap(freearg) enum SWIGTYPE OUTPUT[ANY] %{ SWIG_FREE_ARRAY($1); %} // inout fixed arrays %typemap(in) enum SWIGTYPE INOUT[ANY]=enum SWIGTYPE INPUT[ANY]; %typemap(argout) enum SWIGTYPE INOUT[ANY]=enum SWIGTYPE OUTPUT[ANY]; %typemap(freearg) enum SWIGTYPE INOUT[ANY]=enum SWIGTYPE INPUT[ANY]; // inout variable arrays %typemap(in) (enum SWIGTYPE *INOUT,int)=(enum SWIGTYPE *INPUT,int); %typemap(argout) (enum SWIGTYPE *INOUT,int) %{ SWIG_write_int_num_array(L,(int*)$1,$2); SWIG_arg++; %} %typemap(freearg) (enum SWIGTYPE *INOUT,int)=(enum SWIGTYPE *INPUT,int); /* Surprisingly pointer arrays are easier: this is because all ptr arrays become void** so only a few fns are needed & a few casts The function defined are // created a fixed size array, reads the specified table // and then fills the array with pointers (checking the type) // returns ptr to the array if ok, or 0 for error // (also pushes a error message to the stack) void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type); // as per SWIG_get_ptr_array_fixed() // but reads the entire table & creates an array of the correct size // (if the table is empty, it returns an error rather than a zero length array) void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type); // writes a table to Lua with all the specified pointers // all pointers have the ownership value 'own' (normally 0) void SWIG_write_ptr_array(lua_State* L,void **array,int size,int own); // read the specified table, and fills the array with ptrs // returns 1 of ok (only fails if it doesn't find correct type of ptrs) // helper fn (called by SWIG_get_ptr_array_*() fns) int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,swig_type_info *type); The key thing to remember is that it is assumed that there is no modification of pointers ownership in the arrays eg A fn: void pointers_in(TYPE* arr[],int len); will make copies of the pointer into a temp array and then pass it into the fn Lua does not remember that this fn held the pointers, so it is not safe to keep these pointers until later eg A fn: void pointers_out(TYPE* arr[3]); will return a table containing three pointers however these pointers are NOT owned by Lua, merely borrowed so if the C/C++ frees then Lua is not aware */ %{ SWIGINTERN int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,swig_type_info *type){ int i; for (i = 0; i < size; i++) { lua_rawgeti(L,index,i+1); if (!lua_isuserdata(L,-1) || SWIG_ConvertPtr(L,-1,&array[i],type,0)==-1){ lua_pop(L,1); return 0; } lua_pop(L,1); } return 1; } SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){ void **array; if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) { SWIG_Lua_pushferrstring(L,"expected a table of size %d",size); return 0; } array=SWIG_ALLOC_ARRAY(void*,size); if (!SWIG_read_ptr_array(L,index,array,size,type)){ SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } return array; } SWIGINTERN void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){ void **array; if (!lua_istable(L,index)) { SWIG_Lua_pusherrstring(L,"expected a table"); return 0; } *size=SWIG_itable_size(L,index); if (*size<1){ SWIG_Lua_pusherrstring(L,"table appears to be empty"); return 0; } array=SWIG_ALLOC_ARRAY(void*,*size); if (!SWIG_read_ptr_array(L,index,array,*size,type)){ SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } return array; } SWIGINTERN void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_type_info *type,int own){ int i; lua_newtable(L); for (i = 0; i < size; i++){ SWIG_NewPointerObj(L,array[i],type,own); lua_rawseti(L,-2,i+1);/* -1 is the number, -2 is the table*/ } } %} // fixed size array's %typemap(in) SWIGTYPE* INPUT[ANY] %{ $1 = ($ltype)SWIG_get_ptr_array_fixed(L,$input,$1_dim0,$*1_descriptor); if (!$1) SWIG_fail;%} %typemap(freearg) SWIGTYPE* INPUT[ANY] %{ SWIG_FREE_ARRAY($1);%} // variable size array's %typemap(in) (SWIGTYPE **INPUT,int) %{ $1 = ($ltype)SWIG_get_ptr_array_var(L,$input,&$2,$*1_descriptor); if (!$1) SWIG_fail;%} %typemap(freearg) (SWIGTYPE **INPUT,int) %{ SWIG_FREE_ARRAY($1);%} // out fixed arrays %typemap(in,numinputs=0) SWIGTYPE* OUTPUT[ANY] %{ $1 = SWIG_ALLOC_ARRAY($*1_type,$1_dim0); %} %typemap(argout) SWIGTYPE* OUTPUT[ANY] %{ SWIG_write_ptr_array(L,(void**)$1,$1_dim0,$*1_descriptor,0); SWIG_arg++; %} %typemap(freearg) SWIGTYPE* OUTPUT[ANY] %{ SWIG_FREE_ARRAY($1); %} // inout fixed arrays %typemap(in) SWIGTYPE* INOUT[ANY]=SWIGTYPE* INPUT[ANY]; %typemap(argout) SWIGTYPE* INOUT[ANY]=SWIGTYPE* OUTPUT[ANY]; %typemap(freearg) SWIGTYPE* INOUT[ANY]=SWIGTYPE* INPUT[ANY]; // inout variable arrays %typemap(in) (SWIGTYPE** INOUT,int)=(SWIGTYPE** INPUT,int); %typemap(argout) (SWIGTYPE** INOUT,int) %{ SWIG_write_ptr_array(L,(void**)$1,$2,$*1_descriptor,0); SWIG_arg++; %} %typemap(freearg) (SWIGTYPE**INOUT,int)=(SWIGTYPE**INPUT,int); /* ----------------------------------------------------------------------------- * Pointer-Pointer typemaps * ----------------------------------------------------------------------------- */ /* This code is to deal with the issue for pointer-pointer's In particular for factory methods. for example take the following code segment: struct iMath; // some structure int Create_Math(iMath** pptr); // its factory (assume it mallocs) to use it you might have the following C code: iMath* ptr; int ok; ok=Create_Math(&ptr); // do things with ptr //... free(ptr); With the following SWIG code %apply SWIGTYPE** OUTPUT{iMath **pptr }; You can get natural wrapping in Lua as follows: ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int ptr=nil -- the iMath* will be GC'ed as normal */ %typemap(in,numinputs=0) SWIGTYPE** OUTPUT ($*ltype temp) %{ temp = ($*ltype)0; $1 = &temp; %} %typemap(argout) SWIGTYPE** OUTPUT %{SWIG_NewPointerObj(L,*$1,$*descriptor,1); SWIG_arg++; %} swig-3.0.2/Lib/lua/luaruntime.swg0000664000175000017500000000572212343605122016547 0ustar williamwilliam/* ----------------------------------------------------------------------------- * luaruntime.swg * * all the runtime code for . * ----------------------------------------------------------------------------- */ %runtime "swigrun.swg"; /* Common C API type-checking code */ %runtime "luarun.swg"; /* Lua runtime stuff */ %insert(initbeforefunc) "swiginit.swg" %insert(initbeforefunc) %{ /* Forward declaration of where the user's %init{} gets inserted */ void SWIG_init_user(lua_State* L ); #ifdef __cplusplus extern "C" { #endif /* this is the initialization function added at the very end of the code the function is always called SWIG_init, but an earlier #define will rename it */ #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) LUALIB_API int SWIG_init(lua_State* L) #else SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */ #endif { #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */ int i; int globalRegister = 0; /* start with global table */ lua_pushglobaltable (L); /* SWIG's internal initialisation */ SWIG_InitializeModule((void*)L); SWIG_PropagateClientData(); #endif #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) || defined(SWIG_LUA_ELUA_EMULATE) /* add a global fn */ SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type); SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_class_equal); #endif #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* set up base class pointers (the hierarchy) */ for (i = 0; swig_types[i]; i++){ if (swig_types[i]->clientdata){ SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata)); } } #ifdef SWIG_LUA_MODULE_GLOBAL globalRegister = 1; #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) SWIG_Lua_namespace_register(L,&swig_SwigModule, globalRegister); #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) for (i = 0; swig_types[i]; i++){ if (swig_types[i]->clientdata){ SWIG_Lua_elua_class_register_instance(L,(swig_lua_class*)(swig_types[i]->clientdata)); } } #endif #if defined(SWIG_LUA_ELUA_EMULATE) lua_newtable(L); SWIG_Lua_elua_emulate_register(L,swig_SwigModule.ns_methods); SWIG_Lua_elua_emulate_register_clear(L); if(globalRegister) { lua_pushstring(L,swig_SwigModule.name); lua_pushvalue(L,-2); lua_rawset(L,-4); } #endif #endif #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* invoke user-specific initialization */ SWIG_init_user(L); /* end module */ /* Note: We do not clean up the stack here (Lua will do this for us). At this point, we have the globals table and out module table on the stack. Returning one value makes the module table the result of the require command. */ return 1; #else return 0; #endif } #ifdef __cplusplus } #endif %} /* Note: the initialization function is closed after all code is generated */ swig-3.0.2/Lib/lua/carrays.i0000664000175000017500000000040012343605122015442 0ustar williamwilliam/* Small change to the standard carrays.i renaming the field to __getitem & __setitem for operator[] access */ %rename(__getitem) *::getitem; // the v=X[i] (get operator) %rename(__setitem) *::setitem; // the X[i]=v (set operator) %include <../carrays.i> swig-3.0.2/Lib/lua/std_common.i0000664000175000017500000000014612343605122016147 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.2/Lib/lua/_std_common.i0000664000175000017500000000477212343605122016317 0ustar williamwilliam/* ----------------------------------------------------------------------------- * _std_common.i * * std::helpers for LUA * ----------------------------------------------------------------------------- */ %include // the general exceptions /* The basic idea here, is instead of trying to feed SWIG all the horribly templated STL code, to give it a neatened version. These %defines cover some of the more common methods so the class declarations become just a set of %defines */ /* #define for basic container features note: I allow front(), back() & pop_back() to throw exceptions upon empty containers, rather than coredump (as we haven't defined the methods, we can use %extend to add with new features) */ %define %STD_CONTAINER_METHODS(CLASS,T) public: CLASS(); CLASS(const CLASS&); unsigned int size() const; unsigned int max_size() const; bool empty() const; void clear(); %extend { // the extra stuff which must be checked T front()const throw (std::out_of_range){ // only read front & back if (self->empty()) throw std::out_of_range("in "#CLASS"::front()"); return self->front(); } T back()const throw (std::out_of_range){ // not write to them if (self->empty()) throw std::out_of_range("in "#CLASS"::back()"); return self->back(); } } %enddef /* push/pop for front/back also note: front & back are read only methods, not used for writing */ %define %STD_FRONT_ACCESS_METHODS(CLASS,T) public: void push_front(const T& val); %extend { // must check this void pop_front() throw (std::out_of_range){ if (self->empty()) throw std::out_of_range("in "#CLASS"::pop_front()"); self->pop_back(); } } %enddef %define %STD_BACK_ACCESS_METHODS(CLASS,T) public: void push_back(const T& val); %extend { // must check this void pop_back() throw (std::out_of_range){ if (self->empty()) throw std::out_of_range("in "#CLASS"::pop_back()"); self->pop_back(); } } %enddef /* Random access methods */ %define %STD_RANDOM_ACCESS_METHODS(CLASS,T) %extend // this is a extra bit of SWIG code { // [] is replaced by __getitem__ & __setitem__ // simply throws a string, which causes a lua error T __getitem__(unsigned int idx) throw (std::out_of_range){ if (idx>=self->size()) throw std::out_of_range("in "#CLASS"::__getitem__()"); return (*self)[idx]; } void __setitem__(unsigned int idx,const T& val) throw (std::out_of_range){ if (idx>=self->size()) throw std::out_of_range("in "#CLASS"::__setitem__()"); (*self)[idx]=val; } }; %enddef swig-3.0.2/Lib/lua/factory.i0000664000175000017500000000100712343605122015451 0ustar williamwilliam/* A modification of factory.swg from the generic UTL library. */ %include %define %_factory_dispatch(Type) if (!dcast) { Type *dobj = dynamic_cast($1); if (dobj) { dcast = 1; SWIG_NewPointerObj(L, dobj, $descriptor(Type *), $owner); SWIG_arg++; } }%enddef %define %factory(Method,Types...) %typemap(out) Method { int dcast = 0; %formacro(%_factory_dispatch, Types) if (!dcast) { SWIG_NewPointerObj(L, $1, $descriptor, $owner); SWIG_arg++; } }%enddef swig-3.0.2/Lib/lua/luakw.swg0000664000175000017500000000230412343605122015476 0ustar williamwilliam/* Warnings for Lua keywords, built-in names and bad names. */ #define LUAKW(x) %keywordwarn("'" `x` "' is a Lua keyword, renaming to 'c_" `x` "'", rename="c_%s") `x` #define LUABN(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "'" `x` "' conflicts with a basic function in Lua"), %$not %$ismember) `x` /* Warnings for Lua keywords http://www.lua.org/manual/5.2/manual.html#3.1 */ LUAKW(and); LUAKW(break); LUAKW(do); LUAKW(else); LUAKW(elseif); LUAKW(end); LUAKW(false); LUAKW(for); LUAKW(function); LUAKW(goto); LUAKW(if); LUAKW(in); LUAKW(local); LUAKW(nil); LUAKW(not); LUAKW(or); LUAKW(repeat); LUAKW(return); LUAKW(then); LUAKW(true); LUAKW(until); LUAKW(while); /* Basic functions http://www.lua.org/manual/5.2/manual.html#6.1 */ LUABN(assert); LUABN(collectgarbage); LUABN(dofile); LUABN(error); LUABN(_G); // Not actually a function LUABN(getmetatable); LUABN(ipairs); LUABN(load); LUABN(loadfile); LUABN(next); LUABN(pairs); LUABN(pcall); LUABN(print); LUABN(rawequal); LUABN(rawget); LUABN(rawlen); LUABN(rawset); LUABN(select); LUABN(setmetatable); LUABN(tonumber); LUABN(tostring); LUABN(type); LUABN(_VERSION); // Not actually a function LUABN(xpcall); #undef LUABN #undef LUAKW swig-3.0.2/Lib/lua/std_vector.i0000664000175000017500000000601212343605122016157 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * std::vector typemaps for LUA * ----------------------------------------------------------------------------- */ %{ #include %} %include // the general exceptions /* A really cut down version of the vector class. Note: this does not match the true std::vector class but instead is an approximate, so that SWIG knows how to wrapper it. (Eg, all access is by value, not ref, as SWIG turns refs to pointers) And no support for iterators & insert/erase It would be useful to have a vector<->Lua table conversion routine */ namespace std { template class vector { public: vector(); vector(unsigned int); vector(const vector&); vector(unsigned int,T); unsigned int size() const; unsigned int max_size() const; bool empty() const; void clear(); void push_back(T val); void pop_back(); T front()const; // only read front & back T back()const; // not write to them // operator [] given later: %extend // this is a extra bit of SWIG code { // [] is replaced by __getitem__ & __setitem__ // simply throws a string, which causes a lua error T __getitem__(unsigned int idx) throw (std::out_of_range) { if (idx>=self->size()) throw std::out_of_range("in vector::__getitem__()"); return (*self)[idx]; } void __setitem__(unsigned int idx,T val) throw (std::out_of_range) { if (idx>=self->size()) throw std::out_of_range("in vector::__setitem__()"); (*self)[idx]=val; } }; }; } /* Vector<->LuaTable fns These look a bit like the array<->LuaTable fns but are templated, not %defined (you must have template support for STL) */ /* %{ // reads a table into a vector of numbers // lua numbers will be cast into the type required (rounding may occur) // return 0 if non numbers found in the table // returns new'ed ptr if ok template std::vector* SWIG_read_number_vector(lua_State* L,int index) { int i=0; std::vector* vec=new std::vector(); while(1) { lua_rawgeti(L,index,i+1); if (!lua_isnil(L,-1)) { lua_pop(L,1); break; // finished } if (!lua_isnumber(L,-1)) { lua_pop(L,1); delete vec; return 0; // error } vec->push_back((T)lua_tonumber(L,-1)); lua_pop(L,1); ++i; } return vec; // ok } // writes a vector of numbers out as a lua table template int SWIG_write_number_vector(lua_State* L,std::vector *vec) { lua_newtable(L); for(int i=0;isize();++i) { lua_pushnumber(L,(double)((*vec)[i])); lua_rawseti(L,-2,i+1);// -1 is the number, -2 is the table } } %} // then the typemaps %define SWIG_TYPEMAP_NUM_VECTOR(T) // in %typemap(in) std::vector *INPUT %{ $1 = SWIG_read_number_vector(L,$input); if (!$1) SWIG_fail;%} %typemap(freearg) std::vector *INPUT %{ delete $1;%} // out %typemap(argout) std::vector *OUTPUT %{ SWIG_write_number_vector(L,$1); SWIG_arg++; %} %enddef */ swig-3.0.2/Lib/lua/std_string.i0000664000175000017500000000632712343605122016174 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * std::string typemaps for LUA * ----------------------------------------------------------------------------- */ %{ #include %} /* Only std::string and const std::string& are typemapped they are converted to the Lua strings automatically std::string& and std::string* are not they must be explicitly managed (see below) eg. std::string test_value(std::string x) { return x; } can be used as s="hello world" s2=test_value(s) assert(s==s2) */ namespace std { %naturalvar string; /* Bug report #1526022: Lua strings and std::string can contain embedded zero bytes Therefore a standard out typemap should not be: lua_pushstring(L,$1.c_str()); but lua_pushlstring(L,$1.data(),$1.size()); Similarly for getting the string $1 = (char*)lua_tostring(L, $input); becomes $1.assign(lua_tostring(L,$input),lua_rawlen(L,$input)); Not using: lua_tolstring() as this is only found in Lua 5.1 & not 5.0.2 */ %typemap(in,checkfn="lua_isstring") string %{$1.assign(lua_tostring(L,$input),lua_rawlen(L,$input));%} %typemap(out) string %{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_arg++;%} %typemap(in,checkfn="lua_isstring") const string& ($*1_ltype temp) %{temp.assign(lua_tostring(L,$input),lua_rawlen(L,$input)); $1=&temp;%} %typemap(out) const string& %{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%} // for throwing of any kind of string, string ref's and string pointers // we convert all to lua strings %typemap(throws) string, string&, const string& %{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_fail;%} %typemap(throws) string*, const string* %{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_fail;%} %typecheck(SWIG_TYPECHECK_STRING) string, const string& { $1 = lua_isstring(L,$input); } /* std::string& can be wrapped, but you must inform SWIG if it is in or out eg: void fn(std::string& str); Is this an in/out/inout value? Therefore you need the usual %apply (std::string& INOUT) {std::string& str}; or %apply std::string& INOUT {std::string& str}; typemaps to tell SWIG what to do. */ %typemap(in) string &INPUT=const string &; %typemap(in, numinputs=0) string &OUTPUT ($*1_ltype temp) %{ $1 = &temp; %} %typemap(argout) string &OUTPUT %{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%} %typemap(in) string &INOUT =const string &; %typemap(argout) string &INOUT = string &OUTPUT; /* A really cut down version of the string class This provides basic mapping of lua strings <-> std::string and little else (the std::string has a lot of unneeded functions anyway) note: no fn's taking the const string& as this is overloaded by the const char* version */ class string { public: string(); string(const char*); //string(const string&); unsigned int size() const; unsigned int length() const; bool empty() const; // no support for operator[] const char* c_str()const; const char* data()const; // assign does not return a copy of this object // (no point in a scripting language) void assign(const char*); //void assign(const string&); // no support for all the other features // it's probably better to do it in lua }; } swig-3.0.2/Lib/lua/lua_fnptr.i0000664000175000017500000001020412343605122015773 0ustar williamwilliam/* ----------------------------------------------------------------------------- * lua_fnptr.i * * SWIG Library file containing the main typemap code to support Lua modules. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * Basic function pointer support * ----------------------------------------------------------------------------- */ /* The structure: SWIGLUA_FN provides a simple (local only) wrapping for a function. For example if you wanted to have a C/C++ function take a lua function as a parameter. You could declare it as: int my_func(int a, int b, SWIGLUA_FN fn); note: it should be passed by value, not byref or as a pointer. The SWIGLUA_FN holds a pointer to the lua_State, and the stack index where the function is held. The macro SWIGLUA_FN_GET() will put a copy of the lua function at the top of the stack. After that its fairly simple to write the rest of the code (assuming know how to use lua), just push the parameters, call the function and return the result. int my_func(int a, int b, SWIGLUA_FN fn) { SWIGLUA_FN_GET(fn); lua_pushnumber(fn.L,a); lua_pushnumber(fn.L,b); lua_call(fn.L,2,1); // 2 in, 1 out return luaL_checknumber(fn.L,-1); } SWIG will automatically performs the wrapping of the arguments in and out. However: if you wish to store the function between calls, look to the SWIGLUA_REF below. */ // this is for the C code only, we don't want SWIG to wrapper it for us. %{ typedef struct{ lua_State* L; /* the state */ int idx; /* the index on the stack */ }SWIGLUA_FN; #define SWIGLUA_FN_GET(fn) {lua_pushvalue(fn.L,fn.idx);} %} // the actual typemap %typemap(in,checkfn="lua_isfunction") SWIGLUA_FN %{ $1.L=L; $1.idx=$input; %} /* ----------------------------------------------------------------------------- * Storing lua object support * ----------------------------------------------------------------------------- */ /* The structure: SWIGLUA_REF provides a mechanism to store object (usually functions) between calls to the interpreter. For example if you wanted to have a C/C++ function take a lua function as a parameter. Then call it later, You could declare it as: SWIGLUA_REF myref; void set_func(SWIGLUA_REF ref); SWIGLUA_REF get_func(); void call_func(int val); note: it should be passed by value, not byref or as a pointer. The SWIGLUA_REF holds a pointer to the lua_State, and an integer reference to the object. Because it holds a permanent ref to an object, the SWIGLUA_REF must be handled with a bit more care. It should be initialised to {0,0}. The function swiglua_ref_set() should be used to set it. swiglua_ref_clear() should be used to clear it when not in use, and swiglua_ref_get() to get the data back. Note: the typemap does not check that the object is in fact a function, if you need that you must add it yourself. int my_func(int a, int b, SWIGLUA_FN fn) { SWIGLUA_FN_GET(fn); lua_pushnumber(fn.L,a); lua_pushnumber(fn.L,b); lua_call(fn.L,2,1); // 2 in, 1 out return luaL_checknumber(fn.L,-1); } SWIG will automatically performs the wrapping of the arguments in and out. However: if you wish to store the function between calls, look to the SWIGLUA_REF below. */ %{ typedef struct{ lua_State* L; /* the state */ int ref; /* a ref in the lua global index */ }SWIGLUA_REF; void swiglua_ref_clear(SWIGLUA_REF* pref){ if (pref->L!=0 && pref->ref!=LUA_NOREF && pref->ref!=LUA_REFNIL){ luaL_unref(pref->L,LUA_REGISTRYINDEX,pref->ref); } pref->L=0; pref->ref=0; } void swiglua_ref_set(SWIGLUA_REF* pref,lua_State* L,int idx){ pref->L=L; lua_pushvalue(L,idx); /* copy obj to top */ pref->ref=luaL_ref(L,LUA_REGISTRYINDEX); /* remove obj from top & put into registry */ } void swiglua_ref_get(SWIGLUA_REF* pref){ if (pref->L!=0) lua_rawgeti(pref->L,LUA_REGISTRYINDEX,pref->ref); } %} %typemap(in) SWIGLUA_REF %{ swiglua_ref_set(&$1,L,$input); %} %typemap(out) SWIGLUA_REF %{ if ($1.L!=0) {swiglua_ref_get(&$1);} else {lua_pushnil(L);} SWIG_arg++; %} swig-3.0.2/Lib/lua/std_except.i0000664000175000017500000000352712343605122016155 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Typemaps used by the STL wrappers that throw exceptions. * These typemaps are used when methods are declared with an STL exception * specification, such as: * size_t at() const throw (std::out_of_range); * * std_except.i * ----------------------------------------------------------------------------- */ %{ #include %} %include namespace std { %ignore exception; // not sure if I should ignore this... class exception { public: exception() throw() { } virtual ~exception() throw(); virtual const char* what() const throw(); }; } // normally objects which are thrown are returned to the interpreter as errors // (which potentially may have problems if they are not copied) // therefore all classes based upon std::exception are converted to their strings & returned as errors %typemap(throws) std::bad_exception "SWIG_exception(SWIG_RuntimeError, $1.what());" %typemap(throws) std::domain_error "SWIG_exception(SWIG_ValueError, $1.what());" %typemap(throws) std::exception "SWIG_exception(SWIG_SystemError, $1.what());" %typemap(throws) std::invalid_argument "SWIG_exception(SWIG_ValueError, $1.what());" %typemap(throws) std::length_error "SWIG_exception(SWIG_IndexError, $1.what());" %typemap(throws) std::logic_error "SWIG_exception(SWIG_RuntimeError, $1.what());" %typemap(throws) std::out_of_range "SWIG_exception(SWIG_IndexError, $1.what());" %typemap(throws) std::overflow_error "SWIG_exception(SWIG_OverflowError, $1.what());" %typemap(throws) std::range_error "SWIG_exception(SWIG_IndexError, $1.what());" %typemap(throws) std::runtime_error "SWIG_exception(SWIG_RuntimeError, $1.what());" %typemap(throws) std::underflow_error "SWIG_exception(SWIG_RuntimeError, $1.what());" swig-3.0.2/Lib/lua/stl.i0000664000175000017500000000044312343605122014607 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/lua/std_deque.i0000664000175000017500000000003412343605122015756 0ustar williamwilliam%include swig-3.0.2/Lib/lua/luarun.swg0000664000175000017500000020014112343605122015660 0ustar williamwilliam/* ----------------------------------------------------------------------------- * luarun.swg * * This file contains the runtime support for Lua modules * and includes code for managing global variables and pointer * type checking. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif #include "lua.h" #include "lauxlib.h" #include /* for malloc */ #include /* for a few sanity tests */ /* ----------------------------------------------------------------------------- * Lua flavors * ----------------------------------------------------------------------------- */ #define SWIG_LUA_FLAVOR_LUA 1 #define SWIG_LUA_FLAVOR_ELUA 2 #define SWIG_LUA_FLAVOR_ELUAC 3 #if !defined(SWIG_LUA_TARGET) # error SWIG_LUA_TARGET not defined #endif #if defined(SWIG_LUA_ELUA_EMULATE) struct swig_elua_entry; typedef struct swig_elua_key { int type; union { const char* strkey; lua_Number numkey; } key; } swig_elua_key; typedef struct swig_elua_val { int type; union { lua_Number number; const struct swig_elua_entry *table; const char *string; lua_CFunction function; struct { char member; long lvalue; void *pvalue; swig_type_info **ptype; } userdata; } value; } swig_elua_val; typedef struct swig_elua_entry { swig_elua_key key; swig_elua_val value; } swig_elua_entry; #define LSTRKEY(x) {LUA_TSTRING, {.strkey = x} } #define LNUMKEY(x) {LUA_TNUMBER, {.numkey = x} } #define LNILKEY {LUA_TNIL, {.strkey = 0} } #define LNUMVAL(x) {LUA_TNUMBER, {.number = x} } #define LFUNCVAL(x) {LUA_TFUNCTION, {.function = x} } #define LROVAL(x) {LUA_TTABLE, {.table = x} } #define LNILVAL {LUA_TNIL, {.string = 0} } #define LSTRVAL(x) {LUA_TSTRING, {.string = x} } #define LUA_REG_TYPE swig_elua_entry #define SWIG_LUA_ELUA_EMUL_METATABLE_KEY "__metatable" #define lua_pushrotable(L,p)\ lua_newtable(L);\ assert(p);\ SWIG_Lua_elua_emulate_register(L,(swig_elua_entry*)(p)); #define SWIG_LUA_CONSTTAB_POINTER(B,C,D)\ LSTRKEY(B), {LUA_TUSERDATA, { .userdata={0,0,(void*)(C),&D} } } #define SWIG_LUA_CONSTTAB_BINARY(B,S,C,D)\ LSTRKEY(B), {LUA_TUSERDATA, { .userdata={1,S,(void*)(C),&D} } } #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) # define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C) # define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C) # define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C) # define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C) /* Those two types of constants are not supported in elua */ #ifndef SWIG_LUA_CONSTTAB_POINTER #warning eLua does not support pointers as constants. By default, nil will be used as value #define SWIG_LUA_CONSTTAB_POINTER(B,C,D) LSTRKEY(B), LNILVAL #endif #ifndef SWIG_LUA_CONSTTAB_BINARY #warning eLua does not support pointers to member as constants. By default, nil will be used as value #define SWIG_LUA_CONSTTAB_BINARY(B, S, C, D) LSTRKEY(B), LNILVAL #endif #else /* SWIG_LUA_FLAVOR_LUA */ # define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0 # define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0 # define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0 # define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0 # define SWIG_LUA_CONSTTAB_POINTER(B,C,D)\ SWIG_LUA_POINTER, (char *)B, 0, 0, (void *)C, &D # define SWIG_LUA_CONSTTAB_BINARY(B, S, C, D)\ SWIG_LUA_BINARY, (char *)B, S, 0, (void *)C, &D #endif #ifndef SWIG_LUA_ELUA_EMULATE #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) # define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING} # define LSTRVAL LRO_STRVAL #endif #endif /* SWIG_LUA_ELUA_EMULATE*/ #ifndef SWIG_LUA_ELUA_EMULATE #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) #ifndef MIN_OPT_LEVEL #define MIN_OPT_LEVEL 2 #endif #include "lrodefs.h" #include "lrotable.h" #endif #endif /* SWIG_LUA_ELUA_EMULATE*/ /* ----------------------------------------------------------------------------- * compatibility defines * ----------------------------------------------------------------------------- */ /* History of Lua C API length functions: In Lua 5.0 (and before?) there was "lua_strlen". In Lua 5.1, this was renamed "lua_objlen", but a compatibility define of "lua_strlen" was added. In Lua 5.2, this function was again renamed, to "lua_rawlen" (to emphasize that it doesn't call the "__len" metamethod), and the compatibility define of lua_strlen was removed. All SWIG uses have been updated to "lua_rawlen", and we add our own defines of that here for older versions of Lua. */ #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 # define lua_rawlen lua_strlen #elif LUA_VERSION_NUM == 501 # define lua_rawlen lua_objlen #endif /* lua_pushglobaltable is the recommended "future-proof" way to get the global table for Lua 5.2 and later. Here we define lua_pushglobaltable ourselves for Lua versions before 5.2. */ #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 # define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) #endif /* lua_absindex was introduced in Lua 5.2 */ #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 # define lua_absindex(L,i) ((i)>0 || (i) <= LUA_REGISTRYINDEX ? (i) : lua_gettop(L) + (i) + 1) #endif /* lua_rawsetp was introduced in Lua 5.2 */ #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 #define lua_rawsetp(L,index,ptr)\ lua_pushlightuserdata(L,(void*)(ptr));\ lua_insert(L,-2);\ lua_rawset(L,index); #define lua_rawgetp(L,index,ptr)\ lua_pushlightuserdata(L,(void*)(ptr));\ lua_rawget(L,index); #endif /* -------------------------------------------------------------------------- * Helper functions for error handling * -------------------------------------------------------------------------- */ /* Push the string STR on the Lua stack, like lua_pushstring, but prefixed with the the location of the innermost Lua call-point (as formated by luaL_where). */ SWIGRUNTIME void SWIG_Lua_pusherrstring (lua_State *L, const char *str) { luaL_where (L, 1); lua_pushstring (L, str); lua_concat (L, 2); } /* Push a formatted string generated from FMT and following args on the Lua stack, like lua_pushfstring, but prefixed with the the location of the innermost Lua call-point (as formated by luaL_where). */ SWIGRUNTIME void SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...) { va_list argp; va_start(argp, fmt); luaL_where(L, 1); lua_pushvfstring(L, fmt, argp); va_end(argp); lua_concat(L, 2); } /* ----------------------------------------------------------------------------- * global swig types * ----------------------------------------------------------------------------- */ /* Constant table */ #define SWIG_LUA_INT 1 #define SWIG_LUA_FLOAT 2 #define SWIG_LUA_STRING 3 #define SWIG_LUA_POINTER 4 #define SWIG_LUA_BINARY 5 #define SWIG_LUA_CHAR 6 /* Structure for variable linking table */ typedef struct { const char *name; lua_CFunction get; lua_CFunction set; } swig_lua_var_info; #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) typedef const LUA_REG_TYPE swig_lua_method; typedef const LUA_REG_TYPE swig_lua_const_info; #else /* Normal lua */ typedef luaL_Reg swig_lua_method; /* Constant information structure */ typedef struct { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_lua_const_info; #endif typedef struct { const char *name; lua_CFunction getmethod; lua_CFunction setmethod; } swig_lua_attribute; struct swig_lua_class; /* Can be used to create namespaces. Currently used to wrap class static methods/variables/constants */ typedef struct swig_lua_namespace { const char *name; swig_lua_method *ns_methods; swig_lua_attribute *ns_attributes; swig_lua_const_info *ns_constants; struct swig_lua_class **ns_classes; struct swig_lua_namespace **ns_namespaces; } swig_lua_namespace; typedef struct swig_lua_class { const char *name; /* Name that this class has in Lua */ const char *fqname; /* Fully qualified name - Scope + class name */ swig_type_info **type; lua_CFunction constructor; void (*destructor)(void *); swig_lua_method *methods; swig_lua_attribute *attributes; swig_lua_namespace *cls_static; swig_lua_method *metatable; /* 0 for -eluac */ struct swig_lua_class **bases; const char **base_names; } swig_lua_class; /* this is the struct for wrapping all pointers in SwigLua */ typedef struct { swig_type_info *type; int own; /* 1 if owned & must be destroyed */ void *ptr; } swig_lua_userdata; /* this is the struct for wrapping arbitrary packed binary data (currently it is only used for member function pointers) the data ordering is similar to swig_lua_userdata, but it is currently not possible to tell the two structures apart within SWIG, other than by looking at the type */ typedef struct { swig_type_info *type; int own; /* 1 if owned & must be destroyed */ char data[1]; /* arbitary amount of data */ } swig_lua_rawdata; /* Common SWIG API */ #define SWIG_NewPointerObj(L, ptr, type, owner) SWIG_Lua_NewPointerObj(L, (void *)ptr, type, owner) #define SWIG_ConvertPtr(L,idx, ptr, type, flags) SWIG_Lua_ConvertPtr(L,idx,ptr,type,flags) #define SWIG_MustGetPtr(L,idx, type,flags, argnum,fnname) SWIG_Lua_MustGetPtr(L,idx, type,flags, argnum,fnname) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(L, idx, ptr, sz, ty) SWIG_Lua_ConvertPacked(L, idx, ptr, sz, ty) #define SWIG_NewMemberObj(L, ptr, sz, type) SWIG_Lua_NewPackedObj(L, ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Lua_GetModule((lua_State*)(clientdata)) #define SWIG_SetModule(clientdata, pointer) SWIG_Lua_SetModule((lua_State*) (clientdata), pointer) #define SWIG_MODULE_CLIENTDATA_TYPE lua_State* /* Contract support */ #define SWIG_contract_assert(expr, msg) \ if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } else /* helper #defines */ #define SWIG_fail {goto fail;} #define SWIG_fail_arg(func_name,argnum,type) \ {SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\ func_name,argnum,type,SWIG_Lua_typename(L,argnum));\ goto fail;} #define SWIG_fail_ptr(func_name,argnum,type) \ SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*") #define SWIG_check_num_args(func_name,a,b) \ if (lua_gettop(L)b) \ {SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ goto fail;} #define SWIG_Lua_get_table(L,n) \ (lua_pushstring(L, n), lua_rawget(L,-2)) #define SWIG_Lua_add_function(L,n,f) \ (lua_pushstring(L, n), \ lua_pushcfunction(L, f), \ lua_rawset(L,-3)) #define SWIG_Lua_add_boolean(L,n,b) \ (lua_pushstring(L, n), \ lua_pushboolean(L, b), \ lua_rawset(L,-3)) /* special helper for allowing 'nil' for usertypes */ #define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I)) #ifdef __cplusplus /* Special helper for member function pointers it gets the address, casts it, then dereferences it */ /*#define SWIG_mem_fn_as_voidptr(a) (*((char**)&(a))) */ #endif /* storing/access of swig_module_info */ SWIGRUNTIME swig_module_info * SWIG_Lua_GetModule(lua_State *L) { swig_module_info *ret = 0; lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); lua_rawget(L,LUA_REGISTRYINDEX); if (lua_islightuserdata(L,-1)) ret=(swig_module_info*)lua_touserdata(L,-1); lua_pop(L,1); /* tidy */ return ret; } SWIGRUNTIME void SWIG_Lua_SetModule(lua_State *L, swig_module_info *module) { /* add this all into the Lua registry: */ lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); lua_pushlightuserdata(L,(void*)module); lua_rawset(L,LUA_REGISTRYINDEX); } /* ----------------------------------------------------------------------------- * global variable support code: modules * ----------------------------------------------------------------------------- */ /* this function is called when trying to set an immutable. default action is to print an error. This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */ SWIGINTERN int SWIG_Lua_set_immutable(lua_State *L) { /* there should be 1 param passed in: the new value */ #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE lua_pop(L,1); /* remove it */ luaL_error(L,"This variable is immutable"); #endif return 0; /* should not return anything */ } #ifdef SWIG_LUA_ELUA_EMULATE SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L,void *ptr,swig_type_info *type, int own); SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_type_info *type); static int swig_lua_elua_emulate_unique_key; /* This function emulates eLua rotables behaviour. It loads a rotable definition into the usual lua table. */ SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_entry *table) { int i, table_parsed, parsed_tables_array, target_table; assert(lua_istable(L,-1)); target_table = lua_gettop(L); /* Get the registry where we put all parsed tables to avoid loops */ lua_rawgetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key); if(lua_isnil(L,-1)) { lua_pop(L,1); lua_newtable(L); lua_pushvalue(L,-1); lua_rawsetp(L,LUA_REGISTRYINDEX,(void*)(&swig_lua_elua_emulate_unique_key)); } parsed_tables_array = lua_gettop(L); lua_pushvalue(L,target_table); lua_rawsetp(L, parsed_tables_array, table); table_parsed = 0; const int SWIGUNUSED pairs_start = lua_gettop(L); for(i = 0;table[i].key.type != LUA_TNIL || table[i].value.type != LUA_TNIL;i++) { const swig_elua_entry *entry = table + i; int is_metatable = 0; switch(entry->key.type) { case LUA_TSTRING: lua_pushstring(L,entry->key.key.strkey); if(strcmp(entry->key.key.strkey, SWIG_LUA_ELUA_EMUL_METATABLE_KEY) == 0) is_metatable = 1; break; case LUA_TNUMBER: lua_pushnumber(L,entry->key.key.numkey); break; case LUA_TNIL: lua_pushnil(L); break; default: assert(0); } switch(entry->value.type) { case LUA_TSTRING: lua_pushstring(L,entry->value.value.string); break; case LUA_TNUMBER: lua_pushnumber(L,entry->value.value.number); break; case LUA_TFUNCTION: lua_pushcfunction(L,entry->value.value.function); break; case LUA_TTABLE: lua_rawgetp(L,parsed_tables_array, entry->value.value.table); table_parsed = !lua_isnil(L,-1); if(!table_parsed) { lua_pop(L,1); /*remove nil */ lua_newtable(L); SWIG_Lua_elua_emulate_register(L,entry->value.value.table); } if(is_metatable) { assert(lua_istable(L,-1)); lua_pushvalue(L,-1); lua_setmetatable(L,target_table); } break; case LUA_TUSERDATA: if(entry->value.value.userdata.member) SWIG_NewMemberObj(L,entry->value.value.userdata.pvalue, entry->value.value.userdata.lvalue, *(entry->value.value.userdata.ptype)); else SWIG_NewPointerObj(L,entry->value.value.userdata.pvalue, *(entry->value.value.userdata.ptype),0); break; case LUA_TNIL: lua_pushnil(L); break; default: assert(0); } assert(lua_gettop(L) == pairs_start + 2); lua_rawset(L,target_table); } lua_pop(L,1); /* Removing parsed tables storage */ assert(lua_gettop(L) == target_table); } SWIGINTERN void SWIG_Lua_elua_emulate_register_clear(lua_State *L) { lua_pushnil(L); lua_rawsetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key); } SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L); SWIGINTERN int SWIG_Lua_emulate_elua_getmetatable(lua_State *L) { SWIG_check_num_args("getmetatable(SWIG eLua emulation)", 1, 1); SWIG_Lua_get_class_registry(L); lua_getfield(L,-1,"lua_getmetatable"); lua_remove(L,-2); /* remove the registry*/ assert(!lua_isnil(L,-1)); lua_pushvalue(L,1); assert(lua_gettop(L) == 3); /* object | function | object again */ lua_call(L,1,1); if(!lua_isnil(L,-1)) /*There is an ordinary metatable */ return 1; /*if it is a table, then emulate elua behaviour - check for __metatable attribute of a table*/ assert(lua_gettop(L) == 2); if(lua_istable(L,-2)) { lua_pop(L,1); /*remove the nil*/ lua_getfield(L,-1, SWIG_LUA_ELUA_EMUL_METATABLE_KEY); } assert(lua_gettop(L) == 2); return 1; fail: lua_error(L); return 0; } SWIGINTERN void SWIG_Lua_emulate_elua_swap_getmetatable(lua_State *L) { SWIG_Lua_get_class_registry(L); lua_pushglobaltable(L); lua_pushstring(L,"lua_getmetatable"); lua_getfield(L,-2,"getmetatable"); assert(!lua_isnil(L,-1)); lua_rawset(L,-4); lua_pushstring(L, "getmetatable"); lua_pushcfunction(L, SWIG_Lua_emulate_elua_getmetatable); lua_rawset(L,-3); lua_pop(L,2); } /* END OF REMOVE */ #endif /* ----------------------------------------------------------------------------- * global variable support code: namespaces and modules (which are the same thing) * ----------------------------------------------------------------------------- */ SWIGINTERN int SWIG_Lua_namespace_get(lua_State *L) { /* there should be 2 params passed in (1) table (not the meta table) (2) string name of the attribute */ assert(lua_istable(L,-2)); /* just in case */ lua_getmetatable(L,-2); assert(lua_istable(L,-1)); SWIG_Lua_get_table(L,".get"); /* find the .get table */ assert(lua_istable(L,-1)); /* look for the key in the .get table */ lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); lua_remove(L,-2); /* stack tidy, remove .get table */ if (lua_iscfunction(L,-1)) { /* found it so call the fn & return its value */ lua_call(L,0,1); /* 1 value in (userdata),1 out (result) */ lua_remove(L,-2); /* stack tidy, remove metatable */ return 1; } lua_pop(L,1); /* remove whatever was there */ /* ok, so try the .fn table */ SWIG_Lua_get_table(L,".fn"); /* find the .get table */ assert(lua_istable(L,-1)); /* just in case */ lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); /* look for the fn */ lua_remove(L,-2); /* stack tidy, remove .fn table */ if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */ { /* found it so return the fn & let lua call it */ lua_remove(L,-2); /* stack tidy, remove metatable */ return 1; } lua_pop(L,1); /* remove whatever was there */ return 0; } SWIGINTERN int SWIG_Lua_namespace_set(lua_State *L) { /* there should be 3 params passed in (1) table (not the meta table) (2) string name of the attribute (3) any for the new value */ assert(lua_istable(L,1)); lua_getmetatable(L,1); /* get the meta table */ assert(lua_istable(L,-1)); SWIG_Lua_get_table(L,".set"); /* find the .set table */ if (lua_istable(L,-1)) { /* look for the key in the .set table */ lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); if (lua_iscfunction(L,-1)) { /* found it so call the fn & return its value */ lua_pushvalue(L,3); /* value */ lua_call(L,1,0); return 0; } lua_pop(L,1); /* remove the value */ } lua_pop(L,1); /* remove the value .set table */ lua_pop(L,1); /* remote metatable */ lua_rawset(L,-3); return 0; } #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */ SWIGINTERN void SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]); /* forward declaration */ SWIGINTERN void SWIG_Lua_add_variable(lua_State *L,const char *name,lua_CFunction getFn,lua_CFunction setFn); /* forward declaration */ SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss); /* helper function - register namespace methods and attributes into namespace */ SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State *L, swig_lua_namespace *ns) { int i; /* There must be namespace table (not metatable) at the top of the stack */ assert(lua_istable(L,-1)); SWIG_Lua_InstallConstants(L, ns->ns_constants); /* add methods to the namespace/module table */ for(i=0;ns->ns_methods[i].name;i++){ SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].func); } lua_getmetatable(L,-1); /* add fns */ for(i=0;ns->ns_attributes[i].name;i++){ SWIG_Lua_add_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod); } /* clear stack - remove metatble */ lua_pop(L,1); return 0; } /* Register all classes in the namespace */ SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace *ns) { swig_lua_class **classes; /* There must be a module/namespace table at the top of the stack */ assert(lua_istable(L,-1)); classes = ns->ns_classes; if( classes != 0 ) { while(*classes != 0) { SWIG_Lua_class_register(L, *classes); classes++; } } } /* Helper function. Creates namespace table and adds it to module table if 'reg' is true, then will register namespace table to parent one (must be on top of the stack when function is called). Function always returns newly registered table on top of the stack. */ SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg) { swig_lua_namespace **sub_namespace; /* 1 argument - table on the top of the stack */ const int SWIGUNUSED begin = lua_gettop(L); assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */ lua_checkstack(L,5); lua_newtable(L); /* namespace itself */ lua_newtable(L); /* metatable for namespace */ /* add a table called ".get" */ lua_pushstring(L,".get"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".set" */ lua_pushstring(L,".set"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".fn" */ lua_pushstring(L,".fn"); lua_newtable(L); lua_rawset(L,-3); /* add accessor fns for using the .get,.set&.fn */ SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get); SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set); lua_setmetatable(L,-2); /* set metatable */ /* Register all functions, variables etc */ SWIG_Lua_add_namespace_details(L,ns); /* Register classes */ SWIG_Lua_add_namespace_classes(L,ns); sub_namespace = ns->ns_namespaces; if( sub_namespace != 0) { while(*sub_namespace != 0) { SWIG_Lua_namespace_register(L, *sub_namespace, 1); lua_pop(L,1); /* removing sub-namespace table */ sub_namespace++; } } if (reg) { lua_pushstring(L,ns->name); lua_pushvalue(L,-2); lua_rawset(L,-4); /* add namespace to module table */ } assert(lua_gettop(L) == begin+1); } #endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */ /* ----------------------------------------------------------------------------- * global variable support code: classes * ----------------------------------------------------------------------------- */ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname); typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret); SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED swig_type, int first_arg, swig_lua_base_iterator_func func, int *const ret) { /* first_arg - position of the object in stack. Everything that is above are arguments * and is passed to every evocation of the func */ int last_arg = lua_gettop(L);/* position of last argument */ int original_metatable = last_arg + 1; size_t bases_count; int result = SWIG_ERROR; int bases_table; (void)swig_type; lua_getmetatable(L,first_arg); /* initialise base search */ #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) SWIG_Lua_get_table(L,".bases"); assert(lua_istable(L,-1)); bases_count = lua_rawlen(L,-1); bases_table = lua_gettop(L); #else /* In elua .bases table doesn't exist. Use table from swig_lua_class */ (void)bases_table; assert(swig_type!=0); swig_module_info *module=SWIG_GetModule(L); swig_lua_class **bases= ((swig_lua_class*)(swig_type->clientdata))->bases; const char **base_names= ((swig_lua_class*)(swig_type->clientdata))->base_names; bases_count = 0; for(;base_names[bases_count]; bases_count++);/* get length of bases */ #endif if(ret) *ret = 0; if(bases_count>0) { int to_remove; size_t i; int j; int subcall_last_arg; int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */ int valid = 1; swig_type_info *base_swig_type = 0; for(j=first_arg;j<=last_arg;j++) lua_pushvalue(L,j); subcall_last_arg = lua_gettop(L); /* Trick: temporarily replacing original metatable with metatable for base class and call getter */ for(i=0;ifqname); base_swig_type = SWIG_TypeQueryModule(module,module,base_names[i]); assert(base_swig_type != 0); } #endif if(!valid) continue; assert(lua_isuserdata(L, subcall_first_arg)); assert(lua_istable(L,-1)); lua_setmetatable(L,subcall_first_arg); /* Set new metatable */ assert(lua_gettop(L) == subcall_last_arg); result = func(L, base_swig_type,subcall_first_arg, ret); /* Forward call */ if(result != SWIG_ERROR) { break; } } /* Restore original metatable */ lua_pushvalue(L,original_metatable); lua_setmetatable(L,first_arg); /* Clear - remove everything between last_arg and subcall_last_arg including */ to_remove = subcall_last_arg - last_arg; for(j=0;jtype; result = SWIG_Lua_class_do_get(L,type,1,&ret); if(result == SWIG_OK) return ret; return 0; } /* helper for the class.set method, performs the lookup of class attributes * It returns error code. Number of function return values is passed inside 'ret' */ SWIGINTERN int SWIG_Lua_class_do_set(lua_State *L, swig_type_info *type, int first_arg, int *ret) { /* there should be 3 params passed in (1) table (not the meta table) (2) string name of the attribute (3) any for the new value */ int bases_search_result; int substack_start = lua_gettop(L) - 3; lua_checkstack(L,5); assert(lua_isuserdata(L,substack_start+1)); /* just in case */ lua_getmetatable(L,substack_start+1); /* get the meta table */ assert(lua_istable(L,-1)); /* just in case */ if(ret) *ret = 0; /* it is setter - number of return values is always 0 */ SWIG_Lua_get_table(L,".set"); /* find the .set table */ if (lua_istable(L,-1)) { /* look for the key in the .set table */ lua_pushvalue(L,substack_start+2); /* key */ lua_rawget(L,-2); lua_remove(L,-2); /* tidy stack, remove .set table */ if (lua_iscfunction(L,-1)) { /* found it so call the fn & return its value */ lua_pushvalue(L,substack_start+1); /* userdata */ lua_pushvalue(L,substack_start+3); /* value */ lua_call(L,2,0); lua_remove(L,substack_start+4); /*remove metatable*/ return SWIG_OK; } lua_pop(L,1); /* remove the value */ } else { lua_pop(L,1); /* remove the answer for .set table request*/ } /* NEW: looks for the __setitem() fn this is a user provided set fn */ SWIG_Lua_get_table(L,"__setitem"); /* find the fn */ if (lua_iscfunction(L,-1)) /* if its there */ { /* found it so call the fn & return its value */ lua_pushvalue(L,substack_start+1); /* the userdata */ lua_pushvalue(L,substack_start+2); /* the parameter */ lua_pushvalue(L,substack_start+3); /* the value */ lua_call(L,3,0); /* 3 values in ,0 out */ lua_remove(L,-2); /* stack tidy, remove metatable */ return SWIG_OK; } lua_pop(L,1); /* remove value */ lua_pop(L,1); /* remove metatable */ /* Search among bases */ bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret); if(ret) assert(*ret == 0); assert(lua_gettop(L) == substack_start + 3); return bases_search_result; } /* This is the actual method exported to Lua. It calls SWIG_Lua_class_do_set and correctly * handles return values. */ SWIGINTERN int SWIG_Lua_class_set(lua_State *L) { /* There should be 3 params passed in (1) table (not the meta table) (2) string name of the attribute (3) any for the new value */ int ret = 0; int result; swig_lua_userdata *usr; swig_type_info *type; assert(lua_isuserdata(L,1)); usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ type = usr->type; result = SWIG_Lua_class_do_set(L,type,1,&ret); if(result != SWIG_OK) { SWIG_Lua_pushferrstring(L,"Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method."); lua_error(L); } else { assert(ret==0); } return 0; } /* the class.destruct method called by the interpreter */ SWIGINTERN int SWIG_Lua_class_destruct(lua_State *L) { /* there should be 1 params passed in (1) userdata (not the meta table) */ swig_lua_userdata *usr; swig_lua_class *clss; assert(lua_isuserdata(L,-1)); /* just in case */ usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ /* if must be destroyed & has a destructor */ if (usr->own) /* if must be destroyed */ { clss=(swig_lua_class*)usr->type->clientdata; /* get the class */ if (clss && clss->destructor) /* there is a destroy fn */ { clss->destructor(usr->ptr); /* bye bye */ } } return 0; } /* the class.__tostring method called by the interpreter and print */ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) { /* there should be 1 param passed in (1) userdata (not the metatable) */ const char *className; void* userData; assert(lua_isuserdata(L,1)); /* just in case */ userData = lua_touserdata(L,1); /* get the userdata address for later */ lua_getmetatable(L,1); /* get the meta table */ assert(lua_istable(L,-1)); /* just in case */ lua_getfield(L, -1, ".type"); className = lua_tostring(L, -1); lua_pushfstring(L, "<%s userdata: %p>", className, userData); return 1; } /* to manually disown some userdata */ SWIGINTERN int SWIG_Lua_class_disown(lua_State *L) { /* there should be 1 params passed in (1) userdata (not the meta table) */ swig_lua_userdata *usr; assert(lua_isuserdata(L,-1)); /* just in case */ usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ usr->own = 0; /* clear our ownership */ return 0; } /* lua callable function to compare userdata's value the issue is that two userdata may point to the same thing but to lua, they are different objects */ SWIGRUNTIME int SWIG_Lua_class_equal(lua_State *L) { int result; swig_lua_userdata *usr1,*usr2; if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2)) /* just in case */ return 0; /* nil reply */ usr1=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ usr2=(swig_lua_userdata*)lua_touserdata(L,2); /* get data */ /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/ result=(usr1->ptr==usr2->ptr); lua_pushboolean(L,result); return 1; } /* populate table at the top of the stack with metamethods that ought to be inherited */ SWIGINTERN void SWIG_Lua_populate_inheritable_metamethods(lua_State *L) { SWIG_Lua_add_boolean(L, "__add", 1); SWIG_Lua_add_boolean(L, "__sub", 1); SWIG_Lua_add_boolean(L, "__mul", 1); SWIG_Lua_add_boolean(L, "__div", 1); SWIG_Lua_add_boolean(L, "__mod", 1); SWIG_Lua_add_boolean(L, "__pow", 1); SWIG_Lua_add_boolean(L, "__unm", 1); SWIG_Lua_add_boolean(L, "__len", 1 ); SWIG_Lua_add_boolean(L, "__concat", 1 ); SWIG_Lua_add_boolean(L, "__eq", 1); SWIG_Lua_add_boolean(L, "__lt", 1); SWIG_Lua_add_boolean(L, "__le", 1); SWIG_Lua_add_boolean(L, "__call", 1); SWIG_Lua_add_boolean(L, "__tostring", 1); SWIG_Lua_add_boolean(L, "__gc", 0); } /* creates the swig registry */ SWIGINTERN void SWIG_Lua_create_class_registry(lua_State *L) { /* create main SWIG registry table */ lua_pushstring(L,"SWIG"); lua_newtable(L); /* populate it with some predefined data */ /* .library table. Placeholder */ lua_pushstring(L,".library"); lua_newtable(L); { /* list of metamethods that class inherits from its bases */ lua_pushstring(L,"inheritable_metamethods"); lua_newtable(L); /* populate with list of metamethods */ SWIG_Lua_populate_inheritable_metamethods(L); lua_rawset(L,-3); } lua_rawset(L,-3); lua_rawset(L,LUA_REGISTRYINDEX); } /* gets the swig registry (or creates it) */ SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L) { /* add this all into the swig registry: */ lua_pushstring(L,"SWIG"); lua_rawget(L,LUA_REGISTRYINDEX); /* get the registry */ if (!lua_istable(L,-1)) /* not there */ { /* must be first time, so add it */ lua_pop(L,1); /* remove the result */ SWIG_Lua_create_class_registry(L); /* then get it */ lua_pushstring(L,"SWIG"); lua_rawget(L,LUA_REGISTRYINDEX); } } SWIGINTERN void SWIG_Lua_get_inheritable_metamethods(lua_State *L) { SWIG_Lua_get_class_registry(L); lua_pushstring(L, ".library"); lua_rawget(L,-2); assert( !lua_isnil(L,-1) ); lua_pushstring(L, "inheritable_metamethods"); lua_rawget(L,-2); /* Remove class registry and library table */ lua_remove(L,-2); lua_remove(L,-2); } /* Helper function to get the classes metatable from the register */ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname) { SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,cname); /* get the name */ lua_rawget(L,-2); /* get it */ lua_remove(L,-2); /* tidy up (remove registry) */ } /* Set up the base classes pointers. Each class structure has a list of pointers to the base class structures. This function fills them. It cannot be done at compile time, as this will not work with hireachies spread over more than one swig file. Therefore it must be done at runtime, querying the SWIG type system. */ SWIGINTERN void SWIG_Lua_init_base_class(lua_State *L,swig_lua_class *clss) { int i=0; swig_module_info *module=SWIG_GetModule(L); for(i=0;clss->base_names[i];i++) { if (clss->bases[i]==0) /* not found yet */ { /* lookup and cache the base class */ swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]); if (info) clss->bases[i] = (swig_lua_class *) info->clientdata; } } } #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* Merges two tables */ SWIGINTERN int SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source) { /* iterating */ lua_pushnil(L); while (lua_next(L,source) != 0) { /* -1 - value, -2 - index */ /* have to copy to assign */ lua_pushvalue(L,-2); /* copy of index */ lua_pushvalue(L,-2); /* copy of value */ lua_rawset(L, target); lua_pop(L,1); /* only key is left */ } } /* Merges two tables with given name. original - index of target metatable, base - index of source metatable */ SWIGINTERN int SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base) { /* push original[name], then base[name] */ lua_pushstring(L,name); lua_rawget(L,original); int original_table = lua_gettop(L); lua_pushstring(L,name); lua_rawget(L,base); int base_table = lua_gettop(L); SWIG_Lua_merge_tables_by_index(L, original_table, base_table); /* clearing stack */ lua_pop(L,2); } /* Function takes all symbols from base and adds it to derived class. It's just a helper. */ SWIGINTERN int SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls) { /* There is one parameter - original, i.e. 'derived' class metatable */ assert(lua_istable(L,-1)); int original = lua_gettop(L); SWIG_Lua_get_class_metatable(L,base_cls->fqname); int base = lua_gettop(L); SWIG_Lua_merge_tables(L, ".fn", original, base ); SWIG_Lua_merge_tables(L, ".set", original, base ); SWIG_Lua_merge_tables(L, ".get", original, base ); lua_pop(L,1); } /* Function squashes all symbols from 'clss' bases into itself */ SWIGINTERN int SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss) { int i; SWIG_Lua_get_class_metatable(L,clss->fqname); for(i=0;clss->base_names[i];i++) { if (clss->bases[i]==0) /* Somehow it's not found. Skip it */ continue; /* Thing is: all bases are already registered. Thus they have already executed * this function. So we just need to squash them into us, because their bases * are already squashed into them. No need for recursion here! */ SWIG_Lua_class_squash_base(L, clss->bases[i]); } lua_pop(L,1); /*tidy stack*/ } #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */ /* helper add a variable to a registered class */ SWIGINTERN void SWIG_Lua_add_variable(lua_State *L,const char *name,lua_CFunction getFn,lua_CFunction setFn) { assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_get_table(L,".get"); /* find the .get table */ assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_add_function(L,name,getFn); lua_pop(L,1); /* tidy stack (remove table) */ if (setFn) { SWIG_Lua_get_table(L,".set"); /* find the .set table */ assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_add_function(L,name,setFn); lua_pop(L,1); /* tidy stack (remove table) */ } } /* helper to recursively add class static details (static attributes, operations and constants) */ SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State *L, swig_lua_class *clss) { int i = 0; /* The class namespace table must be on the top of the stack */ assert(lua_istable(L,-1)); /* call all the base classes first: we can then override these later: */ for(i=0;clss->bases[i];i++) { SWIG_Lua_add_class_static_details(L,clss->bases[i]); } SWIG_Lua_add_namespace_details(L, clss->cls_static); } SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss); /* forward declaration */ /* helper to recursively add class details (attributes & operations) */ SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss) { int i; size_t bases_count = 0; /* Add bases to .bases table */ SWIG_Lua_get_table(L,".bases"); assert(lua_istable(L,-1)); /* just in case */ for(i=0;clss->bases[i];i++) { SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); /* Base class must be already registered */ assert(lua_istable(L,-1)); lua_rawseti(L,-2,i+1); /* In lua indexing starts from 1 */ bases_count++; } assert(lua_rawlen(L,-1) == bases_count); lua_pop(L,1); /* remove .bases table */ /* add attributes */ for(i=0;clss->attributes[i].name;i++){ SWIG_Lua_add_variable(L,clss->attributes[i].name,clss->attributes[i].getmethod,clss->attributes[i].setmethod); } /* add methods to the metatable */ SWIG_Lua_get_table(L,".fn"); /* find the .fn table */ assert(lua_istable(L,-1)); /* just in case */ for(i=0;clss->methods[i].name;i++){ SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].func); } lua_pop(L,1); /* tidy stack (remove table) */ /* add operator overloads This adds methods from metatable array to metatable. Can mess up garbage collectind if someone defines __gc method */ if(clss->metatable) { for(i=0;clss->metatable[i].name;i++) { SWIG_Lua_add_function(L,clss->metatable[i].name,clss->metatable[i].func); } } #if !defined(SWIG_LUA_SQUASH_BASES) /* Adding metamethods that are defined in base classes. If bases were squashed * then it is obviously unnecessary */ SWIG_Lua_add_class_user_metamethods(L, clss); #endif } /* Helpers to add user defined class metamedhods - __add, __sub etc. The helpers are needed for the following issue: Lua runtime checks for metamethod existence with rawget function ignoring our SWIG-provided __index and __newindex functions. Thus our inheritance-aware method search algorithm doesn't work in such case. (Not to say that Lua runtime queries metamethod directly in metatable and not in object). Current solution is this: if somewhere in hierarchy metamethod __x is defined, then all descendants are automatically given a special proxy __x that calls the real __x method. Obvious idea - to copy __x instead of creating __x-proxy is wrong because if someone changes __x in runtime, those changes must be reflected in all descendants. */ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L); /*forward declaration*/ /* The real function that resolves a metamethod. * Function searches given class and all it's bases(recursively) for first instance of something that is * not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actual metamethod implementation * and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the * answer. * Returns 1 if found, 0 otherwise. * clss is class which metatable we will search for method * metamethod_name_idx is index in L where metamethod name (as string) lies * skip_check allows to skip searching metamethod in givel clss and immideatelly go to searching in bases. skip_check * is not caried to subsequent recursive calls - false is always passed. It is set to true only at first call from * SWIG_Lua_resolve_metamethod * */ SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class *clss, int metamethod_name_idx, int skip_check) { /* This function is called recursively */ int result = 0; int i = 0; if (!skip_check) { SWIG_Lua_get_class_metatable(L, clss->fqname); lua_pushvalue(L, metamethod_name_idx); lua_rawget(L,-2); /* If this is cfunction and it is equal to SWIG_Lua_resolve_metamethod then * this isn't the function we are looking for :) * lua_tocfunction will return NULL if not cfunction */ if (!lua_isnil(L,-1) && lua_tocfunction(L,-1) != SWIG_Lua_resolve_metamethod ) { lua_remove(L,-2); /* removing class metatable */ return 1; } lua_pop(L,2); /* remove class metatable and query result */ } /* Forwarding calls to bases */ for(i=0;clss->bases[i];i++) { result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0); if (result) break; } return result; } /* The proxy function for metamethod. All parameters are passed as cclosure. Searches for actual method * and calls it */ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) { int numargs; int metamethod_name_idx; const swig_lua_class* clss; int result; lua_checkstack(L,5); numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */ /* Get upvalues from closure */ lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/ metamethod_name_idx = lua_gettop(L); lua_pushvalue(L, lua_upvalueindex(2)); clss = (const swig_lua_class*)(lua_touserdata(L,-1)); lua_pop(L,1); /* remove lightuserdata with clss from stack */ /* Actual work */ result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1); if (!result) { SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actual metamethod. Memory corruption is most likely explanation."); lua_error(L); return 0; } lua_remove(L,-2); /* remove metamethod key */ lua_insert(L,1); /* move function to correct position */ lua_call(L, numargs, LUA_MULTRET); return lua_gettop(L); /* return all results */ } /* If given metamethod must be present in given class, then creates appropriate proxy * Returns 1 if successfully added, 0 if not added because no base class has it, -1 * if method is defined in the class metatable itself */ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index) { int key_index; int success = 0; int i = 0; /* metamethod name - on the top of the stack */ assert(lua_isstring(L,-1)); key_index = lua_gettop(L); /* Check whether method is already defined in metatable */ lua_pushvalue(L,key_index); /* copy of the key */ lua_gettable(L,metatable_index); if( !lua_isnil(L,-1) ) { lua_pop(L,1); return -1; } lua_pop(L,1); /* Iterating over immediate bases */ for(i=0;clss->bases[i];i++) { const swig_lua_class *base = clss->bases[i]; SWIG_Lua_get_class_metatable(L, base->fqname); lua_pushvalue(L, key_index); lua_rawget(L, -2); if( !lua_isnil(L,-1) ) { lua_pushvalue(L, key_index); /* Add proxy function */ lua_pushvalue(L, key_index); /* first closure value is function name */ lua_pushlightuserdata(L, clss); /* second closure value is swig_lua_class structure */ lua_pushcclosure(L, SWIG_Lua_resolve_metamethod, 2); lua_rawset(L, metatable_index); success = 1; } lua_pop(L,1); /* remove function or nil */ lua_pop(L,1); /* remove base class metatable */ if( success ) break; } return success; } SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss) { int metatable_index; int metamethods_info_index; int tostring_undefined; int eq_undefined = 0; SWIG_Lua_get_class_metatable(L, clss->fqname); metatable_index = lua_gettop(L); SWIG_Lua_get_inheritable_metamethods(L); assert(lua_istable(L,-1)); metamethods_info_index = lua_gettop(L); lua_pushnil(L); /* first key */ while(lua_next(L, metamethods_info_index) != 0 ) { /* key at index -2, value at index -1 */ const int is_inheritable = lua_toboolean(L,-2); lua_pop(L,1); /* remove value - we don't need it anymore */ if(is_inheritable) { /* if metamethod is inheritable */ SWIG_Lua_add_class_user_metamethod(L,clss,metatable_index); } } lua_pop(L,1); /* remove inheritable metatmethods table */ /* Special handling for __tostring method */ lua_pushstring(L, "__tostring"); lua_pushvalue(L,-1); lua_rawget(L,metatable_index); tostring_undefined = lua_isnil(L,-1); lua_pop(L,1); if( tostring_undefined ) { lua_pushcfunction(L, SWIG_Lua_class_tostring); lua_rawset(L, metatable_index); } else { lua_pop(L,1); /* remove copy of the key */ } /* Special handling for __eq method */ lua_pushstring(L, "__eq"); lua_pushvalue(L,-1); lua_rawget(L,metatable_index); eq_undefined = lua_isnil(L,-1); lua_pop(L,1); if( eq_undefined ) { lua_pushcfunction(L, SWIG_Lua_class_equal); lua_rawset(L, metatable_index); } else { lua_pop(L,1); /* remove copy of the key */ } /* Warning: __index and __newindex are SWIG-defined. For user-defined operator[] * a __getitem/__setitem method should be defined */ lua_pop(L,1); /* pop class metatable */ } /* Register class static methods,attributes etc as well as constructor proxy */ SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *clss) { const int SWIGUNUSED begin = lua_gettop(L); lua_checkstack(L,5); /* just in case */ assert(lua_istable(L,-1)); /* just in case */ assert(strcmp(clss->name, clss->cls_static->name) == 0); /* in class those 2 must be equal */ SWIG_Lua_namespace_register(L,clss->cls_static, 1); assert(lua_istable(L,-1)); /* just in case */ /* add its constructor to module with the name of the class so you can do MyClass(...) as well as new_MyClass(...) BUT only if a constructor is defined (this overcomes the problem of pure virtual classes without constructors)*/ if (clss->constructor) { lua_getmetatable(L,-1); assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_add_function(L,"__call", clss->constructor); lua_pop(L,1); } assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_add_class_static_details(L, clss); /* clear stack */ lua_pop(L,1); assert( lua_gettop(L) == begin ); } /* Performs the instance (non-static) class registration process. Metatable for class is created * and added to the class registry. */ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss) { const int SWIGUNUSED begin = lua_gettop(L); int i; /* if name already there (class is already registered) then do nothing */ SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->fqname); /* get the name */ lua_rawget(L,-2); if(!lua_isnil(L,-1)) { lua_pop(L,2); assert(lua_gettop(L)==begin); return; } lua_pop(L,2); /* tidy stack */ /* Recursively initialize all bases */ for(i=0;clss->bases[i];i++) { SWIG_Lua_class_register_instance(L,clss->bases[i]); } /* Again, get registry and push name */ SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->fqname); /* get the name */ lua_newtable(L); /* create the metatable */ #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* If squashing is requested, then merges all bases metatable into this one. * It would get us all special methods: __getitem, __add etc. * This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away */ { int new_metatable_index = lua_absindex(L,-1); for(i=0;clss->bases[i];i++) { int base_metatable; SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); base_metatable = lua_absindex(L,-1); SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable); lua_pop(L,1); } } /* And now we will overwrite all incorrectly set data */ #endif /* add string of class name called ".type" */ lua_pushstring(L,".type"); lua_pushstring(L,clss->fqname); lua_rawset(L,-3); /* add a table called bases */ lua_pushstring(L,".bases"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".get" */ lua_pushstring(L,".get"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".set" */ lua_pushstring(L,".set"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".fn" */ lua_pushstring(L,".fn"); lua_newtable(L); /* add manual disown method */ SWIG_Lua_add_function(L,"__disown",SWIG_Lua_class_disown); lua_rawset(L,-3); /* add accessor fns for using the .get,.set&.fn */ SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get); SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set); SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct); /* add it */ lua_rawset(L,-3); /* metatable into registry */ lua_pop(L,1); /* tidy stack (remove registry) */ assert(lua_gettop(L) == begin); #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* Now merge all symbols from .fn, .set, .get etc from bases to our tables */ SWIG_Lua_class_squash_bases(L,clss); #endif SWIG_Lua_get_class_metatable(L,clss->fqname); SWIG_Lua_add_class_instance_details(L,clss); /* recursive adding of details (atts & ops) */ lua_pop(L,1); /* tidy stack (remove class metatable) */ assert( lua_gettop(L) == begin ); } SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss) { int SWIGUNUSED begin; assert(lua_istable(L,-1)); /* This is a table (module or namespace) where classes will be added */ SWIG_Lua_class_register_instance(L,clss); SWIG_Lua_class_register_static(L,clss); /* Add links from static part to instance part and vice versa */ /* [SWIG registry] [Module] * "MyClass" ----> [MyClass metatable] <===== "MyClass" -+> [static part] * ".get" ----> ... | | getmetatable()----| * ".set" ----> ... | | | * ".static" --------------)----------------/ [static part metatable] * | ".get" --> ... * | ".set" --> .... * |=============================== ".instance" */ begin = lua_gettop(L); lua_pushstring(L,clss->cls_static->name); lua_rawget(L,-2); /* get class static table */ assert(lua_istable(L,-1)); lua_getmetatable(L,-1); assert(lua_istable(L,-1)); /* get class static metatable */ lua_pushstring(L,".instance"); /* prepare key */ SWIG_Lua_get_class_metatable(L,clss->fqname); /* get class metatable */ assert(lua_istable(L,-1)); lua_pushstring(L,".static"); /* prepare key */ lua_pushvalue(L, -4); /* push static class TABLE */ assert(lua_istable(L,-1)); lua_rawset(L,-3); /* assign static class table(!NOT metatable) as ".static" member of class metatable */ lua_rawset(L,-3); /* assign class metatable as ".instance" member of class static METATABLE */ lua_pop(L,2); assert(lua_gettop(L) == begin); } #endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */ #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) SWIGINTERN void SWIG_Lua_elua_class_register_instance(lua_State *L, swig_lua_class *clss) { const int SWIGUNUSED begin = lua_gettop(L); int i; /* if name already there (class is already registered) then do nothing */ SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->fqname); /* get the name */ lua_rawget(L,-2); if(!lua_isnil(L,-1)) { lua_pop(L,2); assert(lua_gettop(L)==begin); return; } lua_pop(L,2); /* tidy stack */ /* Recursively initialize all bases */ for(i=0;clss->bases[i];i++) { SWIG_Lua_elua_class_register_instance(L,clss->bases[i]); } /* Again, get registry and push name */ SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->fqname); /* get the name */ assert(clss->metatable); lua_pushrotable(L, (void*)(clss->metatable)); /* create the metatable */ lua_rawset(L,-3); lua_pop(L,1); assert(lua_gettop(L) == begin); } #endif /* elua && eluac */ /* ----------------------------------------------------------------------------- * Class/structure conversion fns * ----------------------------------------------------------------------------- */ /* helper to add metatable to new lua object */ SWIGINTERN void SWIG_Lua_AddMetatable(lua_State *L,swig_type_info *type) { if (type->clientdata) /* there is clientdata: so add the metatable */ { SWIG_Lua_get_class_metatable(L,((swig_lua_class*)(type->clientdata))->fqname); if (lua_istable(L,-1)) { lua_setmetatable(L,-2); } else { lua_pop(L,1); } } } /* pushes a new object into the lua stack */ SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L,void *ptr,swig_type_info *type, int own) { swig_lua_userdata *usr; if (!ptr){ lua_pushnil(L); return; } usr=(swig_lua_userdata*)lua_newuserdata(L,sizeof(swig_lua_userdata)); /* get data */ usr->ptr=ptr; /* set the ptr */ usr->type=type; usr->own=own; #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) SWIG_Lua_AddMetatable(L,type); /* add metatable */ #endif } /* takes a object from the lua stack & converts it into an object of the correct type (if possible) */ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type_info *type,int flags) { swig_lua_userdata *usr; swig_cast_info *cast; if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */ usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */ if (usr) { if (flags & SWIG_POINTER_DISOWN) /* must disown the object */ { usr->own=0; } if (!type) /* special cast void*, no casting fn */ { *ptr=usr->ptr; return SWIG_OK; /* ok */ } cast=SWIG_TypeCheckStruct(usr->type,type); /* performs normal type checking */ if (cast) { int newmemory = 0; *ptr=SWIG_TypeCast(cast,usr->ptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return SWIG_OK; /* ok */ } } return SWIG_ERROR; /* error */ } SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State *L,int index,swig_type_info *type,int flags, int argnum,const char *func_name){ void *result; if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){ luaL_error (L,"Error in %s, expected a %s at argument number %d\n", func_name,(type && type->str)?type->str:"void*",argnum); } return result; } /* pushes a packed userdata. user for member fn pointers only */ SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_type_info *type) { swig_lua_rawdata *raw; assert(ptr); /* not acceptable to pass in a NULL value */ raw=(swig_lua_rawdata*)lua_newuserdata(L,sizeof(swig_lua_rawdata)-1+size); /* alloc data */ raw->type=type; raw->own=0; memcpy(raw->data,ptr,size); /* copy the data */ SWIG_Lua_AddMetatable(L,type); /* add metatable */ } /* converts a packed userdata. user for member fn pointers only */ SWIGRUNTIME int SWIG_Lua_ConvertPacked(lua_State *L,int index,void *ptr,size_t size,swig_type_info *type) { swig_lua_rawdata *raw; raw=(swig_lua_rawdata*)lua_touserdata(L,index); /* get data */ if (!raw) return SWIG_ERROR; /* error */ if (type==0 || type==raw->type) /* void* or identical type */ { memcpy(ptr,raw->data,size); /* copy it */ return SWIG_OK; /* ok */ } return SWIG_ERROR; /* error */ } /* a function to get the typestring of a piece of data */ SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp) { swig_lua_userdata *usr; if (lua_isuserdata(L,tp)) { usr=(swig_lua_userdata*)lua_touserdata(L,tp); /* get data */ if (usr && usr->type && usr->type->str) return usr->type->str; return "userdata (unknown type)"; } return lua_typename(L,lua_type(L,tp)); } /* lua callable function to get the userdata's type */ SWIGRUNTIME int SWIG_Lua_type(lua_State *L) { lua_pushstring(L,SWIG_Lua_typename(L,1)); return 1; } /* ----------------------------------------------------------------------------- * global variable support code: class/struct typemap functions * ----------------------------------------------------------------------------- */ #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) /* Install Constants */ SWIGINTERN void SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) { int i; for (i = 0; constants[i].type; i++) { switch(constants[i].type) { case SWIG_LUA_INT: lua_pushstring(L,constants[i].name); lua_pushnumber(L,(lua_Number)constants[i].lvalue); lua_rawset(L,-3); break; case SWIG_LUA_FLOAT: lua_pushstring(L,constants[i].name); lua_pushnumber(L,(lua_Number)constants[i].dvalue); lua_rawset(L,-3); break; case SWIG_LUA_CHAR: lua_pushstring(L,constants[i].name); lua_pushfstring(L,"%c",(char)constants[i].lvalue); lua_rawset(L,-3); break; case SWIG_LUA_STRING: lua_pushstring(L,constants[i].name); lua_pushstring(L,(char *) constants[i].pvalue); lua_rawset(L,-3); break; case SWIG_LUA_POINTER: lua_pushstring(L,constants[i].name); SWIG_NewPointerObj(L,constants[i].pvalue, *(constants[i]).ptype,0); lua_rawset(L,-3); break; case SWIG_LUA_BINARY: lua_pushstring(L,constants[i].name); SWIG_NewMemberObj(L,constants[i].pvalue,constants[i].lvalue,*(constants[i]).ptype); lua_rawset(L,-3); break; default: break; } } } #endif /* ----------------------------------------------------------------------------- * executing lua code from within the wrapper * ----------------------------------------------------------------------------- */ #ifndef SWIG_DOSTRING_FAIL /* Allows redefining of error function */ #define SWIG_DOSTRING_FAIL(S) fprintf(stderr,"%s\n",S) #endif /* Executes a C string in Lua which is a really simple way of calling lua from C Unfortunately lua keeps changing its APIs, so we need a conditional compile In lua 5.0.X it's lua_dostring() In lua 5.1.X it's luaL_dostring() */ SWIGINTERN int SWIG_Lua_dostring(lua_State *L, const char *str) { int ok,top; if (str==0 || str[0]==0) return 0; /* nothing to do */ top=lua_gettop(L); /* save stack */ #if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501)) ok=luaL_dostring(L,str); /* looks like this is lua 5.1.X or later, good */ #else ok=lua_dostring(L,str); /* might be lua 5.0.x, using lua_dostring */ #endif if (ok!=0) { SWIG_DOSTRING_FAIL(lua_tostring(L,-1)); } lua_settop(L,top); /* restore the stack */ return ok; } #ifdef __cplusplus } #endif /* ------------------------------ end luarun.swg ------------------------------ */ swig-3.0.2/Lib/lua/lua.swg0000664000175000017500000002116612343605122015143 0ustar williamwilliam/* ----------------------------------------------------------------------------- * lua.swg * * SWIG Configuration File for Lua. * This file is parsed by SWIG before reading any other interface file. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * includes * ----------------------------------------------------------------------------- */ %include /* The typemaps */ %include /* The runtime stuff */ %include /* Warnings for Lua keywords */ //%include /* ----------------------------------------------------------------------------- * constants typemaps * ----------------------------------------------------------------------------- */ // this basically adds to a table of constants %typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE {SWIG_LUA_CONSTTAB_INT("$symname", $value)} %typemap(consttab) float, double {SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)} %typemap(consttab) long long, unsigned long long, signed long long {SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)} %typemap(consttab) const long long&, const unsigned long long&, const signed long long& {SWIG_LUA_CONSTTAB_FLOAT("$symname", *$value)} %typemap(consttab) char *, const char *, char [], const char [] {SWIG_LUA_CONSTTAB_STRING("$symname", $value)} // note: char is treated as a seperate special type // signed char & unsigned char are numbers %typemap(consttab) char {SWIG_LUA_CONSTTAB_CHAR("$symname", $value)} %typemap(consttab) long long, unsigned long long {SWIG_LUA_CONSTTAB_STRING("$symname", "$value")} %typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { SWIG_LUA_CONSTTAB_POINTER("$symname",$value, $1_descriptor) } // member function pointers %typemap(consttab) SWIGTYPE (CLASS::*) { SWIG_LUA_CONSTTAB_BINARY("$symname", sizeof($type),&$value, $1_descriptor) } /* ----------------------------------------------------------------------------- * Overloaded operator support * ----------------------------------------------------------------------------- */ // lua calls the + operator '__add' // python likes to call it '__add__' // Assuming most SWIGers will probably use the __add__ if they extend their classes // we have two sets of renames // one to rename the operator+() to __add() // (this lets SWIG rename the operator overloads) // another is to rename __add__() to __add() // (this means that people who wrote SWIG code to do that add will also work) #ifdef __cplusplus // this is extra renaming for lua // not all operators are supported, so only those that are, are listed %rename(__add) *::operator+; %rename(__sub) *::operator-; %rename(__mul) *::operator*; %rename(__div) *::operator/; %rename(__unm) *::operator-(); %rename(__unm) *::operator-() const; %rename(__eq) *::operator==; %ignore *::operator!=; // note: Lua does not have a notequal operator // it just uses 'not (a==b)' %rename(__lt) *::operator<; %ignore *::operator>; // ditto less than vs greater than %rename(__le) *::operator<=; %ignore *::operator>=; // ditto less than vs greater than %ignore *::operator!; // does not support not %rename(__call) *::operator(); // the fn call operator // lua does not support overloading of: // logical/bitwise operators // assign operator // +=,-=,*=, etc // therefore ignoring them for now // it also doesn't support non class operators // eg friends or XX operator+(XX,XX) // also ignoring // note: some of these might be better to rename, but not doing that for now %ignore *::operator&&; %ignore operator&&; %ignore *::operator||; %ignore operator||; %ignore *::operator+=; %ignore *::operator-=; %ignore *::operator*=; %ignore *::operator/=; %ignore *::operator%=; %ignore *::operator++; %ignore *::operator--; %ignore *::operator=; // note: this might be better to rename to assign() or similar %ignore operator+; %ignore operator-; %ignore operator*; %ignore operator/; %ignore operator%; %ignore operator[]; %ignore operator>; %ignore operator>=; %ignore operator<; %ignore operator<=; %ignore operator==; %ignore operator!=; // renaming the python operators to be compatible with lua // this means that if a developer has written a fn __add__() // it will be used for the lua + %rename(__add) *::__add__; %rename(__sub) *::__sub__; %rename(__mul) *::__mul__; %rename(__div) *::__div__; %rename(__unm) *::__neg__; // lua calls unary minus,'unm' not 'neg' %rename(__tostring) *::__str__; // both map to __tostring %rename(__tostring) *::__repr__; // both map to __tostring %rename(__pow) *::__pow__; // lua power '^' operator %rename(__concat) *::__concat__; // lua concat '..' operator %rename(__eq) *::__eq__; %rename(__lt) *::__lt__; %rename(__le) *::__le__; %rename(__call) *::__call__; // the fn call operator() // the [] operator has two parts, the get & the set %rename(__getitem) *::__getitem__; // the v=X[i] (get operator) %rename(__setitem) *::__setitem__; // the X[i]=v (set operator) #endif /* ------------------------------------------------------------ * Exceptions * ------------------------------------------------------------ */ /* Confession: I don't really like C++ exceptions The python/lua ones are great, but C++ ones I don't like (mainly because I cannot get the stack trace out of it) Therefore I have not bothered to try doing much in this Therefore currently its just enough to get a few test cases running ok note: if you wish to throw anything related to std::exception use %include instead */ // number as number+error %typemap(throws) int,unsigned int,signed int, long,unsigned long,signed long, short,unsigned short,signed short, float,double, long long,unsigned long long, unsigned char, signed char, int&,unsigned int&,signed int&, long&,unsigned long&,signed long&, short&,unsigned short&,signed short&, float&,double&, long long&,unsigned long long&, unsigned char&, signed char& %{lua_pushnumber(L,(lua_Number)$1);SWIG_fail; %} %typemap(throws) bool,bool& %{lua_pushboolean(L,(int)($1==true));SWIG_fail; %} // enum as number+error %typemap(throws) enum SWIGTYPE %{lua_pushnumber(L,(lua_Number)(int)$1);SWIG_fail; %} // strings are just sent as errors %typemap(throws) char *, const char * %{lua_pushstring(L,$1);SWIG_fail;%} // char is changed to a string %typemap(throws) char %{lua_pushfstring(L,"%c",$1);SWIG_fail;%} /* Throwing object is a serious problem: Assuming some code throws a 'FooBar' There are a few options: - return a pointer to it: but its unclear how long this will last for. - return a copy of it: but not all objects are copyable (see exception_partial_info in the test suite for a case where you cannot do this) - convert to a string & throw that it's not so useful, but it works (this is more lua like). The third option (though not nice) is used For a more useful solution: see std_except for more details */ // basic typemap for structs, classes, pointers & references // convert to string and error %typemap(throws) SWIGTYPE %{(void)$1; /* ignore it */ lua_pushfstring(L,"object exception:%s",SWIG_TypePrettyName($1_descriptor)); SWIG_fail;%} // code to make a copy of the object and return this // if you have a function which throws a FooBar & you want SWIG to return a copy of the object as its error // then use one of the below // %apply SWIGTYPE EXCEPTION_BY_VAL {FooBar}; // %apply SWIGTYPE& EXCEPTION_BY_VAL {FooBar&}; // note: need & twice %typemap(throws) SWIGTYPE EXCEPTION_BY_VAL %{SWIG_NewPointerObj(L,(void *)new $1_ltype(($1_ltype &) $1),$&1_descriptor,1); SWIG_fail;%} // similar for object reference // note: swig typemaps seem a little confused around here, therefore we use $basetype %typemap(throws) SWIGTYPE& EXCEPTION_BY_VAL %{SWIG_NewPointerObj(L,(void *)new $basetype($1),$1_descriptor,1); SWIG_fail;%} // note: no support for object pointers // its not clear how long the pointer is valid for, therefore not supporting it /* ----------------------------------------------------------------------------- * extras * ----------------------------------------------------------------------------- */ // this %define is to allow insertion of lua source code into the wrapper file #define %luacode %insert("luacode") /* ------------------------------ end lua.swg ------------------------------ */ swig-3.0.2/Lib/mzscheme/0000775000175000017500000000000012343605122014664 5ustar williamwilliamswig-3.0.2/Lib/mzscheme/mzrun.swg0000664000175000017500000003447712343605122016600 0ustar williamwilliam/* ----------------------------------------------------------------------------- * mzrun.swg * ----------------------------------------------------------------------------- */ #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* Common SWIG API */ #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_MzScheme_ConvertPtr(s, result, type, flags) #define SWIG_NewPointerObj(ptr, type, owner) \ SWIG_MzScheme_NewPointerObj((void *)ptr, type, owner) #define SWIG_MustGetPtr(s, type, argnum, flags) \ SWIG_MzScheme_MustGetPtr(s, type, argnum, flags, FUNC_NAME, argc, argv) #define SWIG_contract_assert(expr,msg) \ if (!(expr)) { \ char *m=(char *) scheme_malloc(strlen(msg)+1000); \ sprintf(m,"SWIG contract, assertion failed: function=%s, message=%s", \ (char *) FUNC_NAME,(char *) msg); \ scheme_signal_error(m); \ } /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_MzScheme_GetModule((Scheme_Env *)(clientdata)) #define SWIG_SetModule(clientdata, pointer) SWIG_MzScheme_SetModule((Scheme_Env *) (clientdata), pointer) #define SWIG_MODULE_CLIENTDATA_TYPE Scheme_Env * /* MzScheme-specific SWIG API */ #define SWIG_malloc(size) SWIG_MzScheme_Malloc(size, FUNC_NAME) #define SWIG_free(mem) free(mem) #define SWIG_NewStructFromPtr(ptr,type) \ _swig_convert_struct_##type##(ptr) #define MAXVALUES 6 #define swig_make_boolean(b) (b ? scheme_true : scheme_false) static long SWIG_convert_integer(Scheme_Object *o, long lower_bound, long upper_bound, const char *func_name, int argnum, int argc, Scheme_Object **argv) { long value; int status = scheme_get_int_val(o, &value); if (!status) scheme_wrong_type(func_name, "integer", argnum, argc, argv); if (value < lower_bound || value > upper_bound) scheme_wrong_type(func_name, "integer", argnum, argc, argv); return value; } static int SWIG_is_integer(Scheme_Object *o) { long value; return scheme_get_int_val(o, &value); } static unsigned long SWIG_convert_unsigned_integer(Scheme_Object *o, unsigned long lower_bound, unsigned long upper_bound, const char *func_name, int argnum, int argc, Scheme_Object **argv) { unsigned long value; int status = scheme_get_unsigned_int_val(o, &value); if (!status) scheme_wrong_type(func_name, "integer", argnum, argc, argv); if (value < lower_bound || value > upper_bound) scheme_wrong_type(func_name, "integer", argnum, argc, argv); return value; } static int SWIG_is_unsigned_integer(Scheme_Object *o) { unsigned long value; return scheme_get_unsigned_int_val(o, &value); } /* ----------------------------------------------------------------------- * mzscheme 30X support code * ----------------------------------------------------------------------- */ #ifndef SCHEME_STR_VAL #define MZSCHEME30X 1 #endif #ifdef MZSCHEME30X /* * This is MZSCHEME 299.100 or higher (30x). From version 299.100 of * mzscheme upwards, strings are in unicode. These functions convert * to and from utf8 encodings of these strings. NB! strlen(s) will be * the size in bytes of the string, not the actual length. */ #define SCHEME_STR_VAL(obj) SCHEME_BYTE_STR_VAL(scheme_char_string_to_byte_string(obj)) #define SCHEME_STRLEN_VAL(obj) SCHEME_BYTE_STRLEN_VAL(scheme_char_string_to_byte_string(obj)) #define SCHEME_STRINGP(obj) SCHEME_CHAR_STRINGP(obj) #define scheme_make_string(s) scheme_make_utf8_string(s) #define scheme_make_sized_string(s,l) scheme_make_sized_utf8_string(s,l) #define scheme_make_sized_offset_string(s,d,l) \ scheme_make_sized_offset_utf8_string(s,d,l) #define SCHEME_MAKE_STRING(s) scheme_make_utf8_string(s) #else #define SCHEME_MAKE_STRING(s) scheme_make_string_without_copying(s) #endif /* ----------------------------------------------------------------------- * End of mzscheme 30X support code * ----------------------------------------------------------------------- */ struct swig_mz_proxy { Scheme_Type mztype; swig_type_info *type; void *object; }; static Scheme_Type swig_type; static void mz_free_swig(void *p, void *data) { struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) p; if (SCHEME_NULLP((Scheme_Object*)p) || SCHEME_TYPE((Scheme_Object*)p) != swig_type) return; if (proxy->type) { if (proxy->type->clientdata) { ((Scheme_Prim *)proxy->type->clientdata)(1, (Scheme_Object **)&proxy); } } } static Scheme_Object * SWIG_MzScheme_NewPointerObj(void *ptr, swig_type_info *type, int owner) { struct swig_mz_proxy *new_proxy; new_proxy = (struct swig_mz_proxy *) scheme_malloc(sizeof(struct swig_mz_proxy)); new_proxy->mztype = swig_type; new_proxy->type = type; new_proxy->object = ptr; if (owner) { scheme_add_finalizer(new_proxy, mz_free_swig, NULL); } return (Scheme_Object *) new_proxy; } static int SWIG_MzScheme_ConvertPtr(Scheme_Object *s, void **result, swig_type_info *type, int flags) { swig_cast_info *cast; if (SCHEME_NULLP(s)) { *result = NULL; return 0; } else if (SCHEME_TYPE(s) == swig_type) { struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) s; if (type) { cast = SWIG_TypeCheckStruct(proxy->type, type); if (cast) { int newmemory = 0; *result = SWIG_TypeCast(cast, proxy->object, &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return 0; } else { return 1; } } else { *result = proxy->object; return 0; } } return 1; } static SWIGINLINE void * SWIG_MzScheme_MustGetPtr(Scheme_Object *s, swig_type_info *type, int argnum, int flags, const char *func_name, int argc, Scheme_Object **argv) { void *result; if (SWIG_MzScheme_ConvertPtr(s, &result, type, flags)) { scheme_wrong_type(func_name, type->str ? type->str : "void *", argnum - 1, argc, argv); } return result; } static SWIGINLINE void * SWIG_MzScheme_Malloc(size_t size, const char *func_name) { void *p = malloc(size); if (p == NULL) { scheme_signal_error("swig-memory-error"); } else return p; } static Scheme_Object * SWIG_MzScheme_PackageValues(int num, Scheme_Object **values) { /* ignore first value if void */ if (num > 0 && SCHEME_VOIDP(values[0])) num--, values++; if (num == 0) return scheme_void; else if (num == 1) return values[0]; else return scheme_values(num, values); } #ifndef scheme_make_inspector #define scheme_make_inspector(x,y) \ _scheme_apply(scheme_builtin_value("make-inspector"), x, y) #endif /* Function to create a new struct. */ static Scheme_Object * SWIG_MzScheme_new_scheme_struct (Scheme_Env* env, const char* basename, int num_fields, char** field_names) { Scheme_Object *new_type; int count_out, i; Scheme_Object **struct_names; Scheme_Object **vals; Scheme_Object **a = (Scheme_Object**) \ scheme_malloc(num_fields*sizeof(Scheme_Object*)); for (i=0; i #else #include #endif static char **mz_dlopen_libraries=NULL; static void **mz_libraries=NULL; static char **mz_dynload_libpaths=NULL; static void mz_set_dlopen_libraries(const char *_libs) { int i,k,n; int mz_dynload_debug=(1==0); char *extra_paths[1000]; char *EP; { char *dbg=getenv("MZ_DYNLOAD_DEBUG"); if (dbg!=NULL) { mz_dynload_debug=atoi(dbg); } } { char *ep=getenv("MZ_DYNLOAD_LIBPATH"); int i,k,j; k=0; if (ep!=NULL) { EP=strdup(ep); for(i=0,j=0;EP[i]!='\0';i++) { if (EP[i]==':') { EP[i]='\0'; extra_paths[k++]=&EP[j]; j=i+1; } } if (j!=i) { extra_paths[k++]=&EP[j]; } } else { EP=strdup(""); } extra_paths[k]=NULL; k+=1; if (mz_dynload_debug) { fprintf(stderr,"SWIG:mzscheme:MZ_DYNLOAD_LIBPATH=%s\n",(ep==NULL) ? "(null)" : ep); fprintf(stderr,"SWIG:mzscheme:extra_paths[%d]\n",k-1); for(i=0;i %p\n",libp,mz_libraries[i]); } free(libp); } } } } { int i; void *func=NULL; for(i=0;mz_dlopen_libraries[i]!=NULL && func==NULL;i++) { if (mz_libraries[i]!=NULL) { #ifdef __OS_WIN32 func=GetProcAddress(mz_libraries[i],function); #else func=dlsym(mz_libraries[i],function); #endif } if (mz_dynload_debug) { fprintf(stderr, "SWIG:mzscheme:library:%s;dlopen=%p,function=%s,func=%p\n", mz_dlopen_libraries[i],mz_libraries[i],function,func ); } } return func; } } } /* The interpreter will store a pointer to this structure in a global variable called swig-runtime-data-type-pointer. The instance of this struct is only used if no other module has yet been loaded */ struct swig_mzscheme_runtime_data { swig_module_info *module_head; Scheme_Type type; }; static struct swig_mzscheme_runtime_data swig_mzscheme_runtime_data; static swig_module_info * SWIG_MzScheme_GetModule(Scheme_Env *env) { Scheme_Object *pointer, *symbol; struct swig_mzscheme_runtime_data *data; /* first check if pointer already created */ symbol = scheme_intern_symbol("swig-runtime-data-type-pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); pointer = scheme_lookup_global(symbol, env); if (pointer && SCHEME_CPTRP(pointer)) { data = (struct swig_mzscheme_runtime_data *) SCHEME_CPTR_VAL(pointer); swig_type = data->type; return data->module_head; } else { return NULL; } } static void SWIG_MzScheme_SetModule(Scheme_Env *env, swig_module_info *module) { Scheme_Object *pointer, *symbol; struct swig_mzscheme_runtime_data *data; /* first check if pointer already created */ symbol = scheme_intern_symbol("swig-runtime-data-type-pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); pointer = scheme_lookup_global(symbol, env); if (pointer && SCHEME_CPTRP(pointer)) { data = (struct swig_mzscheme_runtime_data *) SCHEME_CPTR_VAL(pointer); swig_type = data->type; data->module_head = module; } else { /* create a new type for wrapped pointer values */ swig_type = scheme_make_type((char *)"swig"); swig_mzscheme_runtime_data.module_head = module; swig_mzscheme_runtime_data.type = swig_type; /* create a new pointer */ #ifndef MZSCHEME30X pointer = scheme_make_cptr((void *) &swig_mzscheme_runtime_data, "swig_mzscheme_runtime_data"); #else pointer = scheme_make_cptr((void *) &swig_mzscheme_runtime_data, scheme_make_byte_string("swig_mzscheme_runtime_data")); #endif scheme_add_global_symbol(symbol, pointer, env); } } #ifdef __cplusplus } #endif swig-3.0.2/Lib/mzscheme/std_map.i0000664000175000017500000017617412343605122016505 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // // The aim of all that follows would be to integrate std::map with // MzScheme as much as possible, namely, to allow the user to pass and // be returned Scheme association lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::map), f(const std::map&), f(const std::map*): // the parameter being read-only, either a Scheme alist or a // previously wrapped std::map can be passed. // -- f(std::map&), f(std::map*): // the parameter must be modified; therefore, only a wrapped std::map // can be passed. // -- std::map f(): // the map is returned by copy; therefore, a Scheme alist // is returned which is most easily used in other Scheme functions // -- std::map& f(), std::map* f(), const std::map& f(), // const std::map* f(): // the map is returned by reference; therefore, a wrapped std::map // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { %typemap(in) map (std::map* m) { if (SCHEME_NULLP($input)) { $1 = std::map(); } else if (SCHEME_PAIRP($input)) { $1 = std::map(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; T* x; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[*k] = *x; alist = scheme_cdr(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (SCHEME_NULLP($input)) { temp = std::map(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::map(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; T* x; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[*k] = *x; alist = scheme_cdr(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { Scheme_Object* alist = scheme_null; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); T* val = new T(i->second); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); Scheme_Object* x = SWIG_NewPointerObj(val,$descriptor(T *), 1); Scheme_Object* entry = scheme_make_pair(k,x); alist = scheme_make_pair(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { /* native sequence? */ if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ K* k; T* x; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) == -1) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { /* wrapped map? */ std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { /* native sequence? */ if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ K* k; T* x; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) == -1) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { /* wrapped map? */ std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(const K& key, const T& x) { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scheme_make_pair(k,result); } return result; } } }; // specializations for built-ins %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { if (SCHEME_NULLP($input)) { $1 = std::map(); } else if (SCHEME_PAIRP($input)) { $1 = std::map(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { T* x; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[CONVERT_FROM(key)] = *x; alist = scheme_cdr(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (SCHEME_NULLP($input)) { temp = std::map(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::map(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { T* x; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[CONVERT_FROM(key)] = *x; alist = scheme_cdr(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { Scheme_Object* alist = scheme_null; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { T* val = new T(i->second); Scheme_Object* k = CONVERT_TO(i->first); Scheme_Object* x = SWIG_NewPointerObj(val,$descriptor(T *), 1); Scheme_Object* entry = scheme_make_pair(k,x); alist = scheme_make_pair(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only T* x; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only T* x; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(K key, const T& x) { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { std::map::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { Scheme_Object* k = CONVERT_TO(i->first); result = scheme_make_pair(k,result); } return result; } } }; %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { if (SCHEME_NULLP($input)) { $1 = std::map(); } else if (SCHEME_PAIRP($input)) { $1 = std::map(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[*k] = CONVERT_FROM(val); alist = scheme_cdr(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (SCHEME_NULLP($input)) { temp = std::map(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::map(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[*k] = CONVERT_FROM(val); alist = scheme_cdr(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { Scheme_Object* alist = scheme_null; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); Scheme_Object* x = CONVERT_TO(i->second); Scheme_Object* entry = scheme_make_pair(k,x); alist = scheme_make_pair(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only K* k; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) == -1) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (CHECK(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only K* k; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) == -1) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (CHECK(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(const K& key, T x) { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scheme_make_pair(k,result); } return result; } } }; %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) template<> class map { %typemap(in) map (std::map* m) { if (SCHEME_NULLP($input)) { $1 = std::map(); } else if (SCHEME_PAIRP($input)) { $1 = std::map(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = scheme_cdr(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (SCHEME_NULLP($input)) { temp = std::map(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::map(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = scheme_cdr(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { Scheme_Object* alist = scheme_null; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { Scheme_Object* k = CONVERT_K_TO(i->first); Scheme_Object* x = CONVERT_T_TO(i->second); Scheme_Object* entry = scheme_make_pair(k,x); alist = scheme_make_pair(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (CHECK_T(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (CHECK_T(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(K key, T x) { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { std::map::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { Scheme_Object* k = CONVERT_K_TO(i->first); result = scheme_make_pair(k,result); } return result; } } }; %enddef specialize_std_map_on_key(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_key(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_key(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_key(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_value(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_value(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_value(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_value(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); } swig-3.0.2/Lib/mzscheme/std_pair.i0000664000175000017500000012541312343605122016651 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // // See std_vector.i for the rationale of typemap application // ------------------------------------------------------------------------ %{ #include %} // exported class namespace std { template struct pair { %typemap(in) pair (std::pair* m) { if (SCHEME_PAIRP($input)) { T* x; U* y; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(*x,*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const pair& (std::pair temp, std::pair* m), const pair* (std::pair temp, std::pair* m) { if (SCHEME_PAIRP($input)) { T* x; U* y; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); temp = std::make_pair(*x,*y); $1 = &temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) pair { T* x = new T($1.first); U* y = new U($1.second); Scheme_Object* first = SWIG_NewPointerObj(x,$descriptor(T *), 1); Scheme_Object* second = SWIG_NewPointerObj(y,$descriptor(U *), 1); $result = scheme_make_pair(first,second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (SCHEME_PAIRP($input)) { T* x; U* y; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) != -1 && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) != -1) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (SCHEME_PAIRP($input)) { T* x; U* y; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) != -1 && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) != -1) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // specializations for built-ins %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair (std::pair* m) { if (SCHEME_PAIRP($input)) { U* y; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(CONVERT_FROM(first),*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const pair& (std::pair temp, std::pair* m), const pair* (std::pair temp, std::pair* m) { if (SCHEME_PAIRP($input)) { U* y; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); temp = std::make_pair(CONVERT_FROM(first),*y); $1 = &temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) pair { U* y = new U($1.second); Scheme_Object* second = SWIG_NewPointerObj(y,$descriptor(U *), 1); $result = scheme_make_pair(CONVERT_TO($1.first),second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (SCHEME_PAIRP($input)) { U* y; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) != -1) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (SCHEME_PAIRP($input)) { U* y; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) != -1) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair (std::pair* m) { if (SCHEME_PAIRP($input)) { T* x; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); $1 = std::make_pair(*x,CONVERT_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const pair& (std::pair temp, std::pair* m), const pair* (std::pair temp, std::pair* m) { if (SCHEME_PAIRP($input)) { T* x; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); temp = std::make_pair(*x,CONVERT_FROM(second)); $1 = &temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) pair { T* x = new T($1.first); Scheme_Object* first = SWIG_NewPointerObj(x,$descriptor(T *), 1); $result = scheme_make_pair(first,CONVERT_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (SCHEME_PAIRP($input)) { T* x; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) != -1 && CHECK(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (SCHEME_PAIRP($input)) { T* x; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) != -1 && CHECK(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) template<> struct pair { %typemap(in) pair (std::pair* m) { if (SCHEME_PAIRP($input)) { Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); $1 = make_pair(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const pair& (std::pair temp, std::pair* m), const pair* (std::pair temp, std::pair* m) { if (SCHEME_PAIRP($input)) { Scheme_Object *first, *second; T *x; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); temp = make_pair(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); $1 = &temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) pair { $result = scheme_make_pair(CONVERT_T_TO($1.first), CONVERT_U_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (SCHEME_PAIRP($input)) { Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (SCHEME_PAIRP($input)) { Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef specialize_std_pair_on_first(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_first(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_first(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_first(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_second(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_second(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_second(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_second(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); } swig-3.0.2/Lib/mzscheme/typemaps.i0000664000175000017500000002432512343605122016706 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * ----------------------------------------------------------------------------- */ /* The MzScheme module handles all types uniformly via typemaps. Here are the definitions. */ /* Pointers */ %typemap(in) SWIGTYPE * { $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); } %typemap(in) void * { $1 = SWIG_MustGetPtr($input, NULL, $argnum, 0); } %typemap(varin) SWIGTYPE * { $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, 1, 0); } %typemap(varin) SWIGTYPE & { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin) SWIGTYPE && { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin) SWIGTYPE [ANY] { void *temp; int ii; $1_basetype *b = 0; temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0); b = ($1_basetype *) $1; for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii); } %typemap(varin) void * { $1 = SWIG_MustGetPtr($input, NULL, 1, 0); } %typemap(out) SWIGTYPE * { $result = SWIG_NewPointerObj ($1, $descriptor, $owner); } %typemap(out) SWIGTYPE *DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); $result = SWIG_NewPointerObj ($1, ty, $owner); } %typemap(varout) SWIGTYPE *, SWIGTYPE [] { $result = SWIG_NewPointerObj ($1, $descriptor, 0); } %typemap(varout) SWIGTYPE & { $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0); } %typemap(varout) SWIGTYPE && { $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0); } /* C++ References */ #ifdef __cplusplus %typemap(in) SWIGTYPE &, SWIGTYPE && { $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); if ($1 == NULL) scheme_signal_error("swig-type-error (null reference)"); } %typemap(out) SWIGTYPE &, SWIGTYPE && { $result = SWIG_NewPointerObj ($1, $descriptor, $owner); } %typemap(out) SWIGTYPE &DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); $result = SWIG_NewPointerObj ($1, ty, $owner); } #endif /* Arrays */ %typemap(in) SWIGTYPE[] { $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); } %typemap(out) SWIGTYPE[] { $result = SWIG_NewPointerObj ($1, $descriptor, $owner); } /* Enums */ %typemap(in) enum SWIGTYPE { if (!SWIG_is_integer($input)) scheme_wrong_type(FUNC_NAME, "integer", $argnum - 1, argc, argv); $1 = ($1_type) SWIG_convert_int($input); } %typemap(varin) enum SWIGTYPE { if (!SWIG_is_integer($input)) scheme_wrong_type(FUNC_NAME, "integer", 0, argc, argv); $1 = ($1_type) SWIG_convert_int($input); } %typemap(out) enum SWIGTYPE "$result = scheme_make_integer_value($1);"; %typemap(varout) enum SWIGTYPE "$result = scheme_make_integer_value($1);"; /* Pass-by-value */ %typemap(in) SWIGTYPE($&1_ltype argp) { argp = ($&1_ltype) SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); $1 = *argp; } %typemap(varin) SWIGTYPE { $&1_ltype argp; argp = ($&1_ltype) SWIG_MustGetPtr($input, $&1_descriptor, 1, 0); $1 = *argp; } %typemap(out) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; resultptr = new $1_ltype(($1_ltype &) $1); $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 1); } #else { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); } #endif %typemap(varout) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; resultptr = new $1_ltype(($1_ltype &) $1); $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 0); } #else { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); } #endif /* The SIMPLE_MAP macro below defines the whole set of typemaps needed for simple types. */ %define SIMPLE_MAP(C_NAME, MZ_PREDICATE, MZ_TO_C, C_TO_MZ, MZ_NAME) %typemap(in) C_NAME { if (!MZ_PREDICATE($input)) scheme_wrong_type(FUNC_NAME, #MZ_NAME, $argnum - 1, argc, argv); $1 = MZ_TO_C($input); } %typemap(varin) C_NAME { if (!MZ_PREDICATE($input)) scheme_wrong_type(FUNC_NAME, #MZ_NAME, 0, argc, argv); $1 = MZ_TO_C($input); } %typemap(out) C_NAME { $result = C_TO_MZ($1); } %typemap(varout) C_NAME { $result = C_TO_MZ($1); } %typemap(in) C_NAME *INPUT (C_NAME temp) { temp = (C_NAME) MZ_TO_C($input); $1 = &temp; } %typemap(in,numinputs=0) C_NAME *OUTPUT (C_NAME temp) { $1 = &temp; } %typemap(argout) C_NAME *OUTPUT { Scheme_Object *s; s = C_TO_MZ(*$1); SWIG_APPEND_VALUE(s); } %typemap(in) C_NAME *BOTH = C_NAME *INPUT; %typemap(argout) C_NAME *BOTH = C_NAME *OUTPUT; %typemap(in) C_NAME *INOUT = C_NAME *INPUT; %typemap(argout) C_NAME *INOUT = C_NAME *OUTPUT; %enddef SIMPLE_MAP(bool, SCHEME_BOOLP, SCHEME_TRUEP, swig_make_boolean, boolean); SIMPLE_MAP(char, SCHEME_CHARP, SCHEME_CHAR_VAL, scheme_make_character, character); SIMPLE_MAP(unsigned char, SCHEME_CHARP, SCHEME_CHAR_VAL, scheme_make_character, character); SIMPLE_MAP(int, SWIG_is_integer, SWIG_convert_int, scheme_make_integer_value, integer); SIMPLE_MAP(short, SWIG_is_integer, SWIG_convert_short, scheme_make_integer_value, integer); SIMPLE_MAP(long, SWIG_is_integer, SWIG_convert_long, scheme_make_integer_value, integer); SIMPLE_MAP(ptrdiff_t, SWIG_is_integer, SWIG_convert_long, scheme_make_integer_value, integer); SIMPLE_MAP(unsigned int, SWIG_is_unsigned_integer, SWIG_convert_unsigned_int, scheme_make_integer_value_from_unsigned, integer); SIMPLE_MAP(unsigned short, SWIG_is_unsigned_integer, SWIG_convert_unsigned_short, scheme_make_integer_value_from_unsigned, integer); SIMPLE_MAP(unsigned long, SWIG_is_unsigned_integer, SWIG_convert_unsigned_long, scheme_make_integer_value_from_unsigned, integer); SIMPLE_MAP(size_t, SWIG_is_unsigned_integer, SWIG_convert_unsigned_long, scheme_make_integer_value_from_unsigned, integer); SIMPLE_MAP(float, SCHEME_REALP, scheme_real_to_double, scheme_make_double, real); SIMPLE_MAP(double, SCHEME_REALP, scheme_real_to_double, scheme_make_double, real); SIMPLE_MAP(char *, SCHEME_STRINGP, SCHEME_STR_VAL, SCHEME_MAKE_STRING, string); SIMPLE_MAP(const char *, SCHEME_STRINGP, SCHEME_STR_VAL, SCHEME_MAKE_STRING, string); /* For MzScheme 30x: Use these typemaps if you are not going to use UTF8 encodings in your C code. SIMPLE_MAP(char *,SCHEME_BYTE_STRINGP, SCHEME_BYTE_STR_VAL, scheme_make_byte_string_without_copying,bytestring); SIMPLE_MAP(const char *,SCHEME_BYTE_STRINGP, SCHEME_BYTE_STR_VAL, scheme_make_byte_string_without_copying,bytestring); */ /* Const primitive references. Passed by value */ %define REF_MAP(C_NAME, MZ_PREDICATE, MZ_TO_C, C_TO_MZ, MZ_NAME) %typemap(in) const C_NAME & (C_NAME temp) { if (!MZ_PREDICATE($input)) scheme_wrong_type(FUNC_NAME, #MZ_NAME, $argnum - 1, argc, argv); temp = MZ_TO_C($input); $1 = &temp; } %typemap(out) const C_NAME & { $result = C_TO_MZ(*$1); } %enddef REF_MAP(bool, SCHEME_BOOLP, SCHEME_TRUEP, swig_make_boolean, boolean); REF_MAP(char, SCHEME_CHARP, SCHEME_CHAR_VAL, scheme_make_character, character); REF_MAP(unsigned char, SCHEME_CHARP, SCHEME_CHAR_VAL, scheme_make_character, character); REF_MAP(int, SWIG_is_integer, SWIG_convert_int, scheme_make_integer_value, integer); REF_MAP(short, SWIG_is_integer, SWIG_convert_short, scheme_make_integer_value, integer); REF_MAP(long, SWIG_is_integer, SWIG_convert_long, scheme_make_integer_value, integer); REF_MAP(unsigned int, SWIG_is_unsigned_integer, SWIG_convert_unsigned_int, scheme_make_integer_value_from_unsigned, integer); REF_MAP(unsigned short, SWIG_is_unsigned_integer, SWIG_convert_unsigned_short, scheme_make_integer_value_from_unsigned, integer); REF_MAP(unsigned long, SWIG_is_unsigned_integer, SWIG_convert_unsigned_long, scheme_make_integer_value_from_unsigned, integer); REF_MAP(float, SCHEME_REALP, scheme_real_to_double, scheme_make_double, real); REF_MAP(double, SCHEME_REALP, scheme_real_to_double, scheme_make_double, real); /* Void */ %typemap(out) void "$result = scheme_void;"; /* Pass through Scheme_Object * */ %typemap (in) Scheme_Object * "$1=$input;"; %typemap (out) Scheme_Object * "$result=$1;"; %typecheck(SWIG_TYPECHECK_POINTER) Scheme_Object * "$1=1;"; /* ------------------------------------------------------------ * String & length * ------------------------------------------------------------ */ //%typemap(in) (char *STRING, int LENGTH) { // int temp; // $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp); // $2 = ($2_ltype) temp; //} /* ------------------------------------------------------------ * Typechecking rules * ------------------------------------------------------------ */ %typecheck(SWIG_TYPECHECK_INTEGER) int, short, long, unsigned int, unsigned short, unsigned long, signed char, unsigned char, long long, unsigned long long, const int &, const short &, const long &, const unsigned int &, const unsigned short &, const unsigned long &, const long long &, const unsigned long long &, enum SWIGTYPE { $1 = (SWIG_is_integer($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_BOOL) bool, bool &, const bool & { $1 = (SCHEME_BOOLP($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_DOUBLE) float, double, const float &, const double & { $1 = (SCHEME_REALP($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_STRING) char { $1 = (SCHEME_STRINGP($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = (SCHEME_STRINGP($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; if (SWIG_ConvertPtr($input, (void **) &ptr, 0, 0)) { $1 = 0; } else { $1 = 1; } } /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } swig-3.0.2/Lib/mzscheme/std_common.i0000664000175000017500000000077712343605122017213 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; %{ #include std::string swig_scm_to_string(Scheme_Object* x) { return std::string(SCHEME_STR_VAL(x)); } Scheme_Object* swig_make_string(const std::string& s) { return scheme_make_string(s.c_str()); } %} swig-3.0.2/Lib/mzscheme/mzscheme.swg0000664000175000017500000000346412343605122017230 0ustar williamwilliam/* ----------------------------------------------------------------------------- * mzscheme.swg * * SWIG Configuration File for MzScheme. * This file is parsed by SWIG before reading any other interface file. * ----------------------------------------------------------------------------- */ /* Include headers */ %runtime "swigrun.swg" // Common C API type-checking code %runtime "mzrun.swg" %define SWIG_APPEND_VALUE(value) values[lenv++] = value %enddef /* Definitions */ #define SWIG_malloc(size) swig_malloc(size, FUNC_NAME) #define SWIG_free(mem) free(mem) #define SWIG_convert_short(o) \ SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)), \ (1 << (8 * sizeof(short) - 1)) - 1, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_int(o) \ SWIG_convert_integer(o, INT_MIN, INT_MAX, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_long(o) \ SWIG_convert_integer(o, LONG_MIN, LONG_MAX, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_unsigned_short(o) \ SWIG_convert_unsigned_integer(o, 0, \ (1 << (8 * sizeof(short))) - 1, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_unsigned_int(o) \ SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_unsigned_long(o) \ SWIG_convert_unsigned_integer(o, 0, ULONG_MAX, \ FUNC_NAME, $argnum-1, argc, argv) /* Guile compatibility kludges */ #define SCM_VALIDATE_VECTOR(argnum, value) (void)0 #define SCM_VALIDATE_LIST(argnum, value) (void)0 /* Read in standard typemaps. */ %include %insert(init) "swiginit.swg" %init %{ Scheme_Object *scheme_reload(Scheme_Env *env) { Scheme_Env *menv = SWIG_MZSCHEME_CREATE_MENV(env); SWIG_InitializeModule((void *) env); %} swig-3.0.2/Lib/mzscheme/std_vector.i0000664000175000017500000004262312343605122017221 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // MzScheme as much as possible, namely, to allow the user to pass and // be returned MzScheme vectors or lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&), f(const std::vector*): // the parameter being read-only, either a MzScheme sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(): // the vector is returned by copy; therefore, a MzScheme vector of T:s // is returned which is most easily used in other MzScheme functions // -- std::vector& f(), std::vector* f(), const std::vector& f(), // const std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class vector { %typemap(in) vector { if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); $1 = std::vector(size); Scheme_Object** items = SCHEME_VEC_ELS($input); for (unsigned int i=0; i(); } else if (SCHEME_PAIRP($input)) { Scheme_Object *head, *tail; $1 = std::vector(); tail = $input; while (!SCHEME_NULLP(tail)) { head = scheme_car(tail); tail = scheme_cdr(tail); $1.push_back(*((T*)SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const vector& (std::vector temp), const vector* (std::vector temp) { if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); temp = std::vector(size); $1 = &temp; Scheme_Object** items = SCHEME_VEC_ELS($input); for (unsigned int i=0; i(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::vector(); $1 = &temp; Scheme_Object *head, *tail; tail = $input; while (!SCHEME_NULLP(tail)) { head = scheme_car(tail); tail = scheme_cdr(tail); temp.push_back(*((T*) SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) vector { $result = scheme_make_vector($1.size(),scheme_undefined); Scheme_Object** els = SCHEME_VEC_ELS($result); for (unsigned int i=0; i<$1.size(); i++) { T* x = new T((($1_type &)$1)[i]); els[i] = SWIG_NewPointerObj(x,$descriptor(T *), 1); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; Scheme_Object** items = SCHEME_VEC_ELS($input); if (SWIG_ConvertPtr(items[0],(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } } else if (SCHEME_NULLP($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ T* x; Scheme_Object *head = scheme_car($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; Scheme_Object** items = SCHEME_VEC_ELS($input); if (SWIG_ConvertPtr(items[0],(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } } else if (SCHEME_NULLP($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ T* x; Scheme_Object *head = scheme_car($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); %rename(length) size; unsigned int size() const; %rename("empty?") empty; bool empty() const; %rename("clear!") clear; void clear(); %rename("set!") set; %rename("pop!") pop; %rename("push!") push_back; void push_back(const T& x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T& ref(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { %typemap(in) vector { if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); $1 = std::vector(size); Scheme_Object** items = SCHEME_VEC_ELS($input); for (unsigned int i=0; i", $argnum - 1, argc, argv); } } else if (SCHEME_NULLP($input)) { $1 = std::vector(); } else if (SCHEME_PAIRP($input)) { Scheme_Object *head, *tail; $1 = std::vector(); tail = $input; while (!SCHEME_NULLP(tail)) { head = scheme_car(tail); tail = scheme_cdr(tail); if (CHECK(head)) $1.push_back((T)(CONVERT_FROM(head))); else scheme_wrong_type(FUNC_NAME, "vector<" #T ">", $argnum - 1, argc, argv); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const vector& (std::vector temp), const vector* (std::vector temp) { if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); temp = std::vector(size); $1 = &temp; Scheme_Object** items = SCHEME_VEC_ELS($input); for (unsigned int i=0; i", $argnum - 1, argc, argv); } } else if (SCHEME_NULLP($input)) { temp = std::vector(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::vector(); $1 = &temp; Scheme_Object *head, *tail; tail = $input; while (!SCHEME_NULLP(tail)) { head = scheme_car(tail); tail = scheme_cdr(tail); if (CHECK(head)) temp.push_back((T)(CONVERT_FROM(head))); else scheme_wrong_type(FUNC_NAME, "vector<" #T ">", $argnum - 1, argc, argv); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum - 1, 0); } } %typemap(out) vector { $result = scheme_make_vector($1.size(),scheme_undefined); Scheme_Object** els = SCHEME_VEC_ELS($result); for (unsigned int i=0; i<$1.size(); i++) els[i] = CONVERT_TO((($1_type &)$1)[i]); } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; Scheme_Object** items = SCHEME_VEC_ELS($input); $1 = CHECK(items[0]) ? 1 : 0; } } else if (SCHEME_NULLP($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ T* x; Scheme_Object *head = scheme_car($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ std::vector* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) ? 1 : 0; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; Scheme_Object** items = SCHEME_VEC_ELS($input); $1 = CHECK(items[0]) ? 1 : 0; } } else if (SCHEME_NULLP($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ T* x; Scheme_Object *head = scheme_car($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ std::vector* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) ? 1 : 0; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); %rename(length) size; unsigned int size() const; %rename("empty?") empty; bool empty() const; %rename("clear!") clear; void clear(); %rename("set!") set; %rename("pop!") pop; %rename("push!") push_back; void push_back(T x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T ref(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i %{ #include %} namespace std { %naturalvar string; class string; /* Overloading check */ %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; %typemap(in) string { if (SCHEME_STRINGP($input)) $1.assign(SCHEME_STR_VAL($input)); else SWIG_exception(SWIG_TypeError, "string expected"); } %typemap(in) const string & ($*1_ltype temp) { if (SCHEME_STRINGP($input)) { temp.assign(SCHEME_STR_VAL($input)); $1 = &temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(out) string { $result = scheme_make_string($1.c_str()); } %typemap(out) const string & { $result = scheme_make_string($1->c_str()); } } swig-3.0.2/Lib/mzscheme/stl.i0000664000175000017500000000054412343605122015643 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/mzscheme/std_deque.i0000664000175000017500000000003412343605122017010 0ustar williamwilliam%include swig-3.0.2/Lib/mzscheme/Makefile0000664000175000017500000000003512343605122016322 0ustar williamwilliam co: co RCS/*.i* RCS/*.swg* swig-3.0.2/Lib/ocaml/0000775000175000017500000000000012343605122014144 5ustar williamwilliamswig-3.0.2/Lib/ocaml/director.swg0000664000175000017500000000574012343605122016507 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Ocaml proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #include #include # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) namespace Swig { /* base class for director exceptions */ class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(const char *msg="") : swig_msg(msg) { } virtual ~DirectorException() throw() { } const char *what() const throw() { return swig_msg.c_str(); } }; /* type mismatch in the return value from a Ocaml method call */ class DirectorTypeMismatchException : public DirectorException { public: DirectorTypeMismatchException(const char *msg="") : DirectorException(msg) { } }; /* any Ocaml exception that occurs during a director method call */ class DirectorMethodException : public DirectorException {}; /* attempt to call a pure virtual method via a director method */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg="") : DirectorException(msg) { } static void raise(const char *msg) { throw DirectorPureVirtualException(msg); } }; /* simple thread abstraction for pthreads on win32 */ #ifdef __THREAD__ #define __PTHREAD__ #if defined(_WIN32) || defined(__WIN32__) #define pthread_mutex_lock EnterCriticalSection #define pthread_mutex_unlock LeaveCriticalSection #define pthread_mutex_t CRITICAL_SECTION #define MUTEX_INIT(var) CRITICAL_SECTION var #else #include #define MUTEX_INIT(var) pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER #endif #endif /* director base class */ class Director { private: /* pointer to the wrapped ocaml object */ CAML_VALUE swig_self; /* flag indicating whether the object is owned by ocaml or c++ */ mutable bool swig_disown_flag; public: /* wrap a ocaml object, optionally taking ownership */ Director(CAML_VALUE self) : swig_self(self), swig_disown_flag(false) { register_global_root(&swig_self); } /* discard our reference at destruction */ virtual ~Director() { remove_global_root(&swig_self); swig_disown(); // Disown is safe here because we're just divorcing a reference that points to us. } /* return a pointer to the wrapped ocaml object */ CAML_VALUE swig_get_self() const { return swig_self; } /* acquire ownership of the wrapped ocaml object (the sense of "disown" is from ocaml) */ void swig_disown() const { if (!swig_disown_flag) { swig_disown_flag=true; callback(*caml_named_value("caml_obj_disown"),swig_self); } } }; } swig-3.0.2/Lib/ocaml/std_map.i0000664000175000017500000000444012343605122015747 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.2/Lib/ocaml/swig.mli0000664000175000017500000000324012343605122015617 0ustar williamwilliam(* -*- tuareg -*- *) type enum = [ `Int of int ] type 'a c_obj_t = C_void | C_bool of bool | C_char of char | C_uchar of char | C_short of int | C_ushort of int | C_int of int | C_uint of int32 | C_int32 of int32 | C_int64 of int64 | C_float of float | C_double of float | C_ptr of int64 * int64 | C_array of 'a c_obj_t array | C_list of 'a c_obj_t list | C_obj of (string -> 'a c_obj_t -> 'a c_obj_t) | C_string of string | C_enum of 'a | C_director_core of 'a c_obj_t * 'a c_obj_t option ref type c_obj = enum c_obj_t exception InvalidDirectorCall of c_obj exception NoSuchClass of string val invoke : ('a c_obj_t) -> (string -> 'a c_obj_t -> 'a c_obj_t) val fnhelper : 'a c_obj_t -> 'a c_obj_t list val get_int : 'a c_obj_t -> int val get_float : 'a c_obj_t -> float val get_string : 'a c_obj_t -> string val get_char : 'a c_obj_t -> char val get_bool : 'a c_obj_t -> bool val make_float : float -> 'a c_obj_t val make_double : float -> 'a c_obj_t val make_string : string -> 'a c_obj_t val make_bool : bool -> 'a c_obj_t val make_char : char -> 'a c_obj_t val make_char_i : int -> 'a c_obj_t val make_uchar : char -> 'a c_obj_t val make_uchar_i : int -> 'a c_obj_t val make_short : int -> 'a c_obj_t val make_ushort : int -> 'a c_obj_t val make_int : int -> 'a c_obj_t val make_uint : int -> 'a c_obj_t val make_int32 : int -> 'a c_obj_t val make_int64 : int -> 'a c_obj_t val new_derived_object: ('a c_obj_t -> 'a c_obj_t) -> ('a c_obj_t -> string -> 'a c_obj_t -> 'a c_obj_t) -> 'a c_obj_t -> 'a c_obj_t val register_class_byname : string -> ('a c_obj_t -> 'a c_obj_t) -> unit val create_class : string -> 'a c_obj_t -> 'a c_obj_t swig-3.0.2/Lib/ocaml/swigp4.ml0000664000175000017500000001477412343605122015730 0ustar williamwilliamopen Camlp4 module Id : Sig.Id = struct let name = "swigp4" let version = "0.1" end module Make (Syntax : Sig.Camlp4Syntax) = struct open Sig include Syntax let _loc = Loc.ghost let lap x y = x :: y let c_ify e loc = match e with <:expr< $int:_$ >> -> <:expr< (C_int $e$) >> | <:expr< $str:_$ >> -> <:expr< (C_string $e$) >> | <:expr< $chr:_$ >> -> <:expr< (C_char $e$) >> | <:expr< $flo:_$ >> -> <:expr< (C_double $e$) >> | <:expr< True >> -> <:expr< (C_bool $e$) >> | <:expr< False >> -> <:expr< (C_bool $e$) >> | _ -> <:expr< $e$ >> let mk_list args loc f = let rec mk_list_inner args loc f = match args with [] -> <:expr< [] >> | x :: xs -> (let loc = Ast.loc_of_expr x in <:expr< [ ($f x _loc$) ] @ ($mk_list_inner xs loc f$) >>) in match args with [] -> <:expr< (Obj.magic C_void) >> | [ a ] -> <:expr< (Obj.magic $f a _loc$) >> | _ -> <:expr< (Obj.magic (C_list ($mk_list_inner args loc f$))) >> ;; EXTEND Gram GLOBAL: expr; expr: LEVEL "top" [ [ e1 = expr ; "'" ; "[" ; e2 = expr ; "]" -> <:expr< (invoke $e1$) "[]" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) $str:l$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) $str:u$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) $s$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "." ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) "()" ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:l$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:u$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke ((invoke $e1$) "->" C_void)) $s$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "++" -> <:expr< (invoke $e1$) "++" C_void >> | e1 = expr ; "'" ; "--" -> <:expr< (invoke $e1$) "--" C_void >> | e1 = expr ; "'" ; "-" ; e2 = expr -> <:expr< (invoke $e1$) "-" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "+" ; e2 = expr -> <:expr< (invoke $e1$) "+" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "*" ; e2 = expr -> <:expr< (invoke $e1$) "*" (C_list [ $c_ify e2 _loc$ ]) >> | "'" ; "&" ; e1 = expr -> <:expr< (invoke $e1$) "&" C_void >> | "'" ; "!" ; e1 = expr -> <:expr< (invoke $e1$) "!" C_void >> | "'" ; "~" ; e1 = expr -> <:expr< (invoke $e1$) "~" C_void >> | e1 = expr ; "'" ; "/" ; e2 = expr -> <:expr< (invoke $e1$) "/" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "%" ; e2 = expr -> <:expr< (invoke $e1$) "%" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "lsl" ; e2 = expr -> <:expr< (invoke $e1$) ("<" ^ "<") (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "lsr" ; e2 = expr -> <:expr< (invoke $e1$) (">" ^ ">") (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "<" ; e2 = expr -> <:expr< (invoke $e1$) "<" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "<=" ; e2 = expr -> <:expr< (invoke $e1$) "<=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; ">" ; e2 = expr -> <:expr< (invoke $e1$) ">" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; ">=" ; e2 = expr -> <:expr< (invoke $e1$) ">=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "==" ; e2 = expr -> <:expr< (invoke $e1$) "==" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "!=" ; e2 = expr -> <:expr< (invoke $e1$) "!=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "&" ; e2 = expr -> <:expr< (invoke $e1$) "&" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "^" ; e2 = expr -> <:expr< (invoke $e1$) "^" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "|" ; e2 = expr -> <:expr< (invoke $e1$) "|" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "&&" ; e2 = expr -> <:expr< (invoke $e1$) "&&" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "||" ; e2 = expr -> <:expr< (invoke $e1$) "||" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "=" ; e2 = expr -> <:expr< (invoke $e1$) "=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "+=" ; e2 = expr -> <:expr< (invoke $e1$) "+=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "-=" ; e2 = expr -> <:expr< (invoke $e1$) "-=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "*=" ; e2 = expr -> <:expr< (invoke $e1$) "*=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "/=" ; e2 = expr -> <:expr< (invoke $e1$) "/=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "%=" ; e2 = expr -> <:expr< (invoke $e1$) "%=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "lsl" ; "=" ; e2 = expr -> <:expr< (invoke $e1$) ("<" ^ "<=") (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "lsr" ; "=" ; e2 = expr -> <:expr< (invoke $e1$) (">" ^ ">=") (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "&=" ; e2 = expr -> <:expr< (invoke $e1$) "&=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "^=" ; e2 = expr -> <:expr< (invoke $e1$) "^=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "|=" ; e2 = expr -> <:expr< (invoke $e1$) "|=" (C_list [ $c_ify e2 _loc$ ]) >> | "'" ; e = expr -> c_ify e _loc | c = expr ; "as" ; id = LIDENT -> <:expr< $lid:"get_" ^ id$ $c$ >> | c = expr ; "to" ; id = LIDENT -> <:expr< $uid:"C_" ^ id$ $c$ >> | "`" ; "`" ; l = LIDENT -> <:expr< C_enum `$lid:l$ >> | "`" ; "`" ; u = UIDENT -> <:expr< C_enum `$uid:u$ >> | f = expr ; "'" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< $f$ ($mk_list args _loc c_ify$) >> ] ] ; END ;; end module M = Register.OCamlSyntaxExtension(Id)(Make) swig-3.0.2/Lib/ocaml/carray.i0000664000175000017500000000626412343605122015607 0ustar williamwilliam%insert(mli) %{ type _value = c_obj %} %insert(ml) %{ type _value = c_obj %} %define %array_tmap_out(type,what,out_f) %typemap(type) what [ANY] { int i; /* $*1_type */ $result = caml_array_new($1_dim0); for( i = 0; i < $1_dim0; i++ ) { caml_array_set($result,i,out_f($1[i])); } } %enddef %define %array_tmap_in(type,what,in_f) %typemap(type) what [ANY] { int i; /* $*1_type */ $1 = ($*1_type *)malloc( $1_size ); for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = in_f(caml_array_nth($input,i)); } } %typemap(free) what [ANY] { free( (void *)$1 ); } %enddef %define %make_simple_array_typemap(type,out_f,in_f) %array_tmap_out(out,type,out_f); %array_tmap_out(varout,type,out_f); %array_tmap_out(directorin,type,out_f); %array_tmap_in(in,type,in_f); %array_tmap_in(varin,type,in_f); %array_tmap_in(directorout,type,in_f); %enddef %make_simple_array_typemap(bool,caml_val_bool,caml_long_val); %make_simple_array_typemap(short,caml_val_short,caml_long_val); %make_simple_array_typemap(unsigned short,caml_val_ushort,caml_long_val); %make_simple_array_typemap(int,caml_val_int,caml_long_val); %make_simple_array_typemap(unsigned int,caml_val_uint,caml_long_val); %make_simple_array_typemap(long,caml_val_long,caml_long_val); %make_simple_array_typemap(unsigned long,caml_val_ulong,caml_long_val); %make_simple_array_typemap(size_t,caml_val_int,caml_long_val); %make_simple_array_typemap(float,caml_val_float,caml_double_val); %make_simple_array_typemap(double,caml_val_double,caml_double_val); #ifdef __cplusplus %typemap(in) SWIGTYPE [] { int i; /* $*1_type */ $1 = new $*1_type [$1_dim0]; for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = *(($*1_ltype *) caml_ptr_val(caml_array_nth($input,i), $*1_descriptor)) ; } } #else %typemap(in) SWIGTYPE [] { int i; /* $*1_type */ $1 = ($*1_type *)malloc( $1_size ); for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = *(($*1_ltype) caml_ptr_val(caml_array_nth($input), $*1_descriptor)); } } #endif %typemap(out) SWIGTYPE [] { int i; CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); $result = caml_array_new($1_dim0); for( i = 0; i < $1_dim0; i++ ) { if( fromval ) { caml_array_set ($result, i, callback(*fromval,caml_val_ptr((void *)&$1[i],$*1_descriptor))); } else { caml_array_set ($result, i, caml_val_ptr ((void *)&$1[i],$&1_descriptor)); } } } %typemap(in) enum SWIGTYPE [] { int i; /* $*1_type */ $1 = ($*1_type *)malloc( $1_size ); for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = ($type) caml_long_val_full(caml_array_nth($input), "$type_marker"); } } %typemap(out) enum SWIGTYPE [] { int i; $result = caml_array_new($1_dim0); for( i = 0; i < $1_dim0; i++ ) { caml_array_set ($result, i, callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"), *caml_named_value("$type_marker"), Val_int($1[i]))); } } #ifdef __cplusplus %typemap(freearg) SWIGTYPE [ANY] { delete [] $1; } #else %typemap(freearg) SWIGTYPE [ANY] { free( (void *)$1 ); } #endif swig-3.0.2/Lib/ocaml/std_pair.i0000664000175000017500000000131012343605122016116 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/ocaml/std_complex.i0000664000175000017500000000301412343605122016635 0ustar williamwilliam// -*- C++ -*- #ifndef SWIG_STD_COMPLEX_I_ #define SWIG_STD_COMPLEX_I_ #ifdef SWIG %{ #include %} namespace std { template class complex; %define specialize_std_complex(T) %typemap(in) complex { if (PyComplex_Check($input)) { $1 = std::complex(PyComplex_RealAsDouble($input), PyComplex_ImagAsDouble($input)); } else if (PyFloat_Check($input)) { $1 = std::complex(PyFloat_AsDouble($input), 0); } else if (PyInt_Check($input)) { $1 = std::complex(PyInt_AsLong($input), 0); } else { PyErr_SetString(PyExc_TypeError,"Expected a complex"); SWIG_fail; } } %typemap(in) const complex& (std::complex temp) { if (PyComplex_Check($input)) { temp = std::complex(PyComplex_RealAsDouble($input), PyComplex_ImagAsDouble($input)); $1 = &temp; } else if (PyFloat_Check($input)) { temp = std::complex(PyFloat_AsDouble($input), 0); $1 = &temp; } else if (PyInt_Check($input)) { temp = std::complex(PyInt_AsLong($input), 0); $1 = &temp; } else { PyErr_SetString(PyExc_TypeError,"Expected a complex"); SWIG_fail; } } %typemap(out) complex { $result = PyComplex_FromDoubles($1.real(), $1.imag()); } %typemap(out) const complex & { $result = PyComplex_FromDoubles($1->real(), $1->imag()); } %enddef specialize_std_complex(double); specialize_std_complex(float); } #endif // SWIG #endif //SWIG_STD_COMPLEX_I_ swig-3.0.2/Lib/ocaml/typemaps.i0000664000175000017500000002354512343605122016171 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * The Ocaml module handles all types uniformly via typemaps. Here * are the definitions. * ----------------------------------------------------------------------------- */ /* Pointers */ %typemap(in) void "" %typemap(out) void "$result = Val_int(0);" %typemap(in) void * { $1 = caml_ptr_val($input,$descriptor); } %typemap(varin) void * { $1 = ($ltype)caml_ptr_val($input,$descriptor); } %typemap(out) void * { $result = caml_val_ptr($1,$descriptor); } %typemap(varout) void * { $result = caml_val_ptr($1,$descriptor); } #ifdef __cplusplus %typemap(in) SWIGTYPE & { /* %typemap(in) SWIGTYPE & */ $1 = ($ltype) caml_ptr_val($input,$1_descriptor); } %typemap(in) SWIGTYPE && { /* %typemap(in) SWIGTYPE && */ $1 = ($ltype) caml_ptr_val($input,$1_descriptor); } %typemap(varin) SWIGTYPE & { /* %typemap(varin) SWIGTYPE & */ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); } %typemap(varin) SWIGTYPE && { /* %typemap(varin) SWIGTYPE && */ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); } %typemap(out) SWIGTYPE & { /* %typemap(out) SWIGTYPE & */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *) &$1,$1_descriptor); } } %typemap(out) SWIGTYPE && { /* %typemap(out) SWIGTYPE && */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *) &$1,$1_descriptor); } } #if 0 %typemap(argout) SWIGTYPE & { CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { swig_result = caml_list_append(swig_result, callback(*fromval,caml_val_ptr((void *) $1, $1_descriptor))); } else { swig_result = caml_list_append(swig_result, caml_val_ptr ((void *) $1,$1_descriptor)); } } %typemap(argout) SWIGTYPE && { CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { swig_result = caml_list_append(swig_result, callback(*fromval,caml_val_ptr((void *) $1, $1_descriptor))); } else { swig_result = caml_list_append(swig_result, caml_val_ptr ((void *) $1,$1_descriptor)); } } #endif %typemap(argout) const SWIGTYPE & { } %typemap(argout) const SWIGTYPE && { } %typemap(in) SWIGTYPE { $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; } %typemap(out) SWIGTYPE { /* %typemap(out) SWIGTYPE */ $&1_ltype temp = new $ltype((const $1_ltype &) $1); CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); } else { $result = caml_val_ptr ((void *)temp,$&1_descriptor); } } %typemap(in) char *& (char *temp) { /* %typemap(in) char *& */ temp = (char*)caml_val_ptr($1,$descriptor); $1 = &temp; } %typemap(argout) char *& { /* %typemap(argout) char *& */ swig_result = caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1))); } #else %typemap(in) SWIGTYPE { $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; } %typemap(out) SWIGTYPE { /* %typemap(out) SWIGTYPE */ void *temp = calloc(1,sizeof($ltype)); CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); memmove( temp, &$1, sizeof( $1_type ) ); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); } else { $result = caml_val_ptr ((void *)temp,$&1_descriptor); } } %apply SWIGTYPE { const SWIGTYPE & }; %apply SWIGTYPE { const SWIGTYPE && }; #endif /* The SIMPLE_MAP macro below defines the whole set of typemaps needed for simple types. */ %define SIMPLE_MAP(C_NAME, C_TO_MZ, MZ_TO_C) /* In */ %typemap(in) C_NAME { $1 = MZ_TO_C($input); } %typemap(varin) C_NAME { $1 = MZ_TO_C($input); } %typemap(in) C_NAME & ($*1_ltype temp) { temp = ($*1_ltype) MZ_TO_C($input); $1 = &temp; } %typemap(varin) C_NAME & { $1 = MZ_TO_C($input); } %typemap(directorout) C_NAME { $1 = MZ_TO_C($input); } %typemap(in) C_NAME *INPUT ($*1_ltype temp) { temp = ($*1_ltype) MZ_TO_C($input); $1 = &temp; } %typemap(in,numinputs=0) C_NAME *OUTPUT ($*1_ltype temp) { $1 = &temp; } /* Out */ %typemap(out) C_NAME { $result = C_TO_MZ($1); } %typemap(varout) C_NAME { $result = C_TO_MZ($1); } %typemap(varout) C_NAME & { /* %typemap(varout) C_NAME & (generic) */ $result = C_TO_MZ($1); } %typemap(argout) C_NAME *OUTPUT { swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); } %typemap(out) C_NAME & { /* %typemap(out) C_NAME & (generic) */ $result = C_TO_MZ(*$1); } %typemap(argout) C_NAME & { swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); } %typemap(directorin) C_NAME { args = caml_list_append(args,C_TO_MZ($1)); } %enddef SIMPLE_MAP(bool, caml_val_bool, caml_long_val); SIMPLE_MAP(oc_bool, caml_val_bool, caml_long_val); SIMPLE_MAP(char, caml_val_char, caml_long_val); SIMPLE_MAP(signed char, caml_val_char, caml_long_val); SIMPLE_MAP(unsigned char, caml_val_uchar, caml_long_val); SIMPLE_MAP(int, caml_val_int, caml_long_val); SIMPLE_MAP(short, caml_val_short, caml_long_val); SIMPLE_MAP(wchar_t, caml_val_short, caml_long_val); SIMPLE_MAP(long, caml_val_long, caml_long_val); SIMPLE_MAP(ptrdiff_t, caml_val_int, caml_long_val); SIMPLE_MAP(unsigned int, caml_val_uint, caml_long_val); SIMPLE_MAP(unsigned short, caml_val_ushort, caml_long_val); SIMPLE_MAP(unsigned long, caml_val_ulong, caml_long_val); SIMPLE_MAP(size_t, caml_val_int, caml_long_val); SIMPLE_MAP(float, caml_val_float, caml_double_val); SIMPLE_MAP(double, caml_val_double, caml_double_val); SIMPLE_MAP(long long,caml_val_ulong,caml_long_val); SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); /* Void */ %typemap(out) void "$result = Val_unit;"; /* Pass through value */ %typemap (in) value,caml::value,CAML_VALUE "$1=$input;"; %typemap (out) value,caml::value,CAML_VALUE "$result=$1;"; /* Arrays */ %typemap(in) ArrayCarrier * { $1 = ($ltype)caml_ptr_val($input,$1_descriptor); } %typemap(out) ArrayCarrier * { CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *)$1,$1_descriptor); } } #if 0 %include #endif /* Handle char arrays as strings */ %define %char_ptr_in(how) %typemap(how) char *, signed char *, unsigned char * { /* %typemap(how) char * ... */ $1 = ($ltype)caml_string_val($input); } /* Again work around the empty array bound bug */ %typemap(how) char [ANY], signed char [ANY], unsigned char [ANY] { /* %typemap(how) char [ANY] ... */ char *temp = caml_string_val($input); strcpy((char *)$1,temp); /* strncpy would be better but we might not have an array size */ } %enddef %char_ptr_in(in); %char_ptr_in(varin); %char_ptr_in(directorout); %define %char_ptr_out(how) %typemap(how) char *, signed char *, unsigned char *, const char *, const signed char *, const unsigned char * { $result = caml_val_string((char *)$1); } /* I'd like to use the length here but can't because it might be empty */ %typemap(how) char [ANY], signed char [ANY], unsigned char [ANY], const char [ANY], const signed char [ANY], const unsigned char [ANY] { $result = caml_val_string((char *)$1); } %enddef %char_ptr_out(out); %char_ptr_out(varout); %char_ptr_out(directorin); %define %swigtype_ptr_in(how) %typemap(how) SWIGTYPE * { /* %typemap(how) SWIGTYPE * */ $1 = ($ltype)caml_ptr_val($input,$1_descriptor); } %typemap(how) SWIGTYPE (CLASS::*) { /* %typemap(how) SWIGTYPE (CLASS::*) */ void *v = caml_ptr_val($input,$1_descriptor); memcpy(& $1, &v, sizeof(v)); } %enddef %define %swigtype_ptr_out(how) %typemap(out) SWIGTYPE * { /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *)$1,$1_descriptor); } } %typemap(how) SWIGTYPE (CLASS::*) { /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ void *v; memcpy(&v,& $1, sizeof(void *)); $result = caml_val_ptr (v,$1_descriptor); } %enddef %swigtype_ptr_in(in); %swigtype_ptr_in(varin); %swigtype_ptr_in(directorout); %swigtype_ptr_out(out); %swigtype_ptr_out(varout); %swigtype_ptr_out(directorin); %define %swigtype_array_fail(how,msg) %typemap(how) SWIGTYPE [] { failwith(msg); } %enddef %swigtype_array_fail(in,"Array arguments for arbitrary types need a typemap"); %swigtype_array_fail(varin,"Assignment to global arrays for arbitrary types need a typemap"); %swigtype_array_fail(out,"Array arguments for arbitrary types need a typemap"); %swigtype_array_fail(varout,"Array variables need a typemap"); %swigtype_array_fail(directorin,"Array results with arbitrary types need a typemap"); %swigtype_array_fail(directorout,"Array arguments with arbitrary types need a typemap"); /* C++ References */ /* Enums */ %define %swig_enum_in(how) %typemap(how) enum SWIGTYPE { $1 = ($type)caml_long_val_full($input,"$type_marker"); } %enddef %define %swig_enum_out(how) %typemap(how) enum SWIGTYPE { $result = callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),*caml_named_value("$type_marker"),Val_int((int)$1)); } %enddef %swig_enum_in(in) %swig_enum_in(varin) %swig_enum_in(directorout) %swig_enum_out(out) %swig_enum_out(varout) %swig_enum_out(directorin) /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } swig-3.0.2/Lib/ocaml/extra-install.list0000664000175000017500000000013512343605122017627 0ustar williamwilliam# see top-level Makefile.in # libswigocaml is not needed anymore. swigp4.ml swig.mli swig.ml swig-3.0.2/Lib/ocaml/ocaml.i0000664000175000017500000000265212343605122015416 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ocaml.i * * SWIG Configuration File for Ocaml * ----------------------------------------------------------------------------- */ %runtime %{ #define SWIGSTATIC static %} /* Insert common stuff */ %insert(runtime) "swigrun.swg" /* Include headers */ %insert(runtime) "ocamldec.swg" /* Type registration */ %insert(init) "swiginit.swg" %insert(init) "typeregister.swg" %insert(mlitail) %{ val swig_val : c_enum_type -> c_obj -> Swig.c_obj %} %insert(mltail) %{ let rec swig_val t v = match v with C_enum e -> enum_to_int t v | C_list l -> Swig.C_list (List.map (swig_val t) l) | C_array a -> Swig.C_array (Array.map (swig_val t) a) | _ -> Obj.magic v %} /*#ifndef SWIG_NOINCLUDE*/ %insert(runtime) "ocaml.swg" /*#endif*/ %insert(classtemplate) "class.swg" /* Definitions */ #define SWIG_malloc(size) swig_malloc(size, FUNC_NAME) #define SWIG_free(mem) free(mem) /* Read in standard typemaps. */ %include %include %include %include %include /* ocaml keywords */ /* There's no need to use this, because of my rewriting machinery. C++ * words never collide with ocaml keywords */ /* still we include the file, but the warning says that the offending name will be properly renamed. Just to let the user to know about it. */ %include swig-3.0.2/Lib/ocaml/class.swg0000664000175000017500000000326612343605122016002 0ustar williamwilliam(*Stream:class_ctors*) let create_$classname_from_ptr raw_ptr = C_obj begin let h = Hashtbl.create 20 in List.iter (fun (nm,fn) -> Hashtbl.replace h nm fn) [ "nop", (fun args -> C_void) ; $classbody "&", (fun args -> raw_ptr) ; ":parents", (fun args -> C_list (let out = ref [] in Hashtbl.iter (fun x y -> out := (x,y) :: !out) h ; (List.map (fun (x,y) -> C_string (String.sub x 2 ((String.length x) - 2))) (List.filter (fun (x,y) -> ((String.length x) > 2) && x.[0] == ':' && x.[1] == ':') !out)))) ; ":classof", (fun args -> C_string "$realname") ; ":methods", (fun args -> C_list (let out = ref [] in Hashtbl.iter (fun x y -> out := (C_string x) :: !out) h ; !out)) ] ; let rec invoke_inner raw_ptr mth arg = begin try let application = Hashtbl.find h mth in application (match arg with C_list l -> (C_list (raw_ptr :: l)) | C_void -> (C_list [ raw_ptr ]) | v -> (C_list [ raw_ptr ; v ])) with Not_found -> (* Try parent classes *) begin let parent_classes = [ $baselist ] in let rec try_parent plist raw_ptr = match plist with p :: tl -> begin try (invoke (p raw_ptr)) mth arg with (BadMethodName (p,m,s)) -> try_parent tl raw_ptr end | [] -> raise (BadMethodName (raw_ptr,mth,"$realname")) in try_parent parent_classes raw_ptr end end in (fun mth arg -> invoke_inner raw_ptr mth arg) end let _ = Callback.register "create_$normalized_from_ptr" create_$classname_from_ptr (*Stream:mli*) val create_$classname_from_ptr : c_obj -> c_obj swig-3.0.2/Lib/ocaml/cstring.i0000664000175000017500000001366712343605122016004 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cstring.i * * This file provides typemaps and macros for dealing with various forms * of C character string handling. The primary use of this module * is in returning character data that has been allocated or changed in * some way. * ----------------------------------------------------------------------------- */ /* %cstring_input_binary(TYPEMAP, SIZE) * * Macro makes a function accept binary string data along with * a size. */ %define %cstring_input_binary(TYPEMAP, SIZE) %apply (char *STRING, int LENGTH) { (TYPEMAP, SIZE) }; %enddef /* * %cstring_bounded_output(TYPEMAP, MAX) * * This macro is used to return a NULL-terminated output string of * some maximum length. For example: * * %cstring_bounded_output(char *outx, 512); * void foo(char *outx) { * sprintf(outx,"blah blah\n"); * } * */ %define %cstring_bounded_output(TYPEMAP,MAX) %typemap(ignore) TYPEMAP(char temp[MAX+1]) { $1 = ($1_ltype) temp; } %typemap(argout) TYPEMAP { $1[MAX] = 0; $result = caml_list_append($result,caml_val_string(str)); } %enddef /* * %cstring_chunk_output(TYPEMAP, SIZE) * * This macro is used to return a chunk of binary string data. * Embedded NULLs are okay. For example: * * %cstring_chunk_output(char *outx, 512); * void foo(char *outx) { * memmove(outx, somedata, 512); * } * */ %define %cstring_chunk_output(TYPEMAP,SIZE) %typemap(ignore) TYPEMAP(char temp[SIZE]) { $1 = ($1_ltype) temp; } %typemap(argout) TYPEMAP { $result = caml_list_append($result,caml_val_string_len($1,SIZE)); } %enddef /* * %cstring_bounded_mutable(TYPEMAP, SIZE) * * This macro is used to wrap a string that's going to mutate. * * %cstring_bounded_mutable(char *in, 512); * void foo(in *x) { * while (*x) { * *x = toupper(*x); * x++; * } * } * */ %define %cstring_bounded_mutable(TYPEMAP,MAX) %typemap(in) TYPEMAP(char temp[MAX+1]) { char *t = (char *)caml_ptr_val($input); strncpy(temp,t,MAX); $1 = ($1_ltype) temp; } %typemap(argout) TYPEMAP { $result = caml_list_append($result,caml_val_string_len($1,MAX)); } %enddef /* * %cstring_mutable(TYPEMAP [, expansion]) * * This macro is used to wrap a string that will mutate in place. * It may change size up to a user-defined expansion. * * %cstring_mutable(char *in); * void foo(in *x) { * while (*x) { * *x = toupper(*x); * x++; * } * } * */ %define %cstring_mutable(TYPEMAP,...) %typemap(in) TYPEMAP { char *t = String_val($input); int n = string_length($input); $1 = ($1_ltype) t; #if #__VA_ARGS__ == "" #ifdef __cplusplus $1 = ($1_ltype) new char[n+1]; #else $1 = ($1_ltype) malloc(n+1); #endif #else #ifdef __cplusplus $1 = ($1_ltype) new char[n+1+__VA_ARGS__]; #else $1 = ($1_ltype) malloc(n+1+__VA_ARGS__); #endif #endif memmove($1,t,n); $1[n] = 0; } %typemap(argout) TYPEMAP { $result = caml_list_append($result,caml_val_string($1)); #ifdef __cplusplus delete[] $1; #else free($1); #endif } %enddef /* * %cstring_output_maxsize(TYPEMAP, SIZE) * * This macro returns data in a string of some user-defined size. * * %cstring_output_maxsize(char *outx, int max) { * void foo(char *outx, int max) { * sprintf(outx,"blah blah\n"); * } */ %define %cstring_output_maxsize(TYPEMAP, SIZE) %typemap(in) (TYPEMAP, SIZE) { $2 = caml_val_long($input); #ifdef __cplusplus $1 = ($1_ltype) new char[$2+1]; #else $1 = ($1_ltype) malloc($2+1); #endif } %typemap(argout) (TYPEMAP,SIZE) { $result = caml_list_append($result,caml_val_string($1)); #ifdef __cplusplus delete [] $1; #else free($1); #endif } %enddef /* * %cstring_output_withsize(TYPEMAP, SIZE) * * This macro is used to return character data along with a size * parameter. * * %cstring_output_maxsize(char *outx, int *max) { * void foo(char *outx, int *max) { * sprintf(outx,"blah blah\n"); * *max = strlen(outx); * } */ %define %cstring_output_withsize(TYPEMAP, SIZE) %typemap(in) (TYPEMAP, SIZE) { int n = caml_val_long($input); #ifdef __cplusplus $1 = ($1_ltype) new char[n+1]; $2 = ($2_ltype) new $*1_ltype; #else $1 = ($1_ltype) malloc(n+1); $2 = ($2_ltype) malloc(sizeof($*1_ltype)); #endif *$2 = n; } %typemap(argout) (TYPEMAP,SIZE) { $result = caml_list_append($result,caml_val_string_len($1,$2)); #ifdef __cplusplus delete [] $1; delete $2; #else free($1); free($2); #endif } %enddef /* * %cstring_output_allocate(TYPEMAP, RELEASE) * * This macro is used to return character data that was * allocated with new or malloc. * * %cstring_output_allocated(char **outx, free($1)); * void foo(char **outx) { * *outx = (char *) malloc(512); * sprintf(outx,"blah blah\n"); * } */ %define %cstring_output_allocate(TYPEMAP, RELEASE) %typemap(ignore) TYPEMAP($*1_ltype temp = 0) { $1 = &temp; } %typemap(argout) TYPEMAP { if (*$1) { $result = caml_list_append($result,caml_val_string($1)); RELEASE; } else { $result = caml_list_append($result,caml_val_ptr($1)); } } %enddef /* * %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) * * This macro is used to return character data that was * allocated with new or malloc. * * %cstring_output_allocated(char **outx, int *sz, free($1)); * void foo(char **outx, int *sz) { * *outx = (char *) malloc(512); * sprintf(outx,"blah blah\n"); * *sz = strlen(outx); * } */ %define %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) %typemap(ignore) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) { $1 = &temp; $2 = &tempn; } %typemap(argout)(TYPEMAP,SIZE) { if (*$1) { $result = caml_list_append($result,caml_val_string_len($1,$2)); RELEASE; } else $result = caml_list_append($result,caml_val_ptr($1)); } %enddef swig-3.0.2/Lib/ocaml/swig.ml0000664000175000017500000001111412343605122015445 0ustar williamwilliam(* -*- tuareg -*- *) open Int32 open Int64 type enum = [ `Int of int ] type 'a c_obj_t = C_void | C_bool of bool | C_char of char | C_uchar of char | C_short of int | C_ushort of int | C_int of int | C_uint of int32 | C_int32 of int32 | C_int64 of int64 | C_float of float | C_double of float | C_ptr of int64 * int64 | C_array of 'a c_obj_t array | C_list of 'a c_obj_t list | C_obj of (string -> 'a c_obj_t -> 'a c_obj_t) | C_string of string | C_enum of 'a | C_director_core of 'a c_obj_t * 'a c_obj_t option ref type c_obj = enum c_obj_t exception BadArgs of string exception BadMethodName of string * string exception NotObject of c_obj exception NotEnumType of c_obj exception LabelNotFromThisEnum of c_obj exception InvalidDirectorCall of c_obj exception NoSuchClass of string let rec invoke obj = match obj with C_obj o -> o | C_director_core (o,r) -> invoke o | _ -> raise (NotObject (Obj.magic obj)) let _ = Callback.register "swig_runmethod" invoke let fnhelper arg = match arg with C_list l -> l | C_void -> [] | _ -> [ arg ] let rec get_int x = match x with C_bool b -> if b then 1 else 0 | C_char c | C_uchar c -> (int_of_char c) | C_short s | C_ushort s | C_int s -> s | C_uint u | C_int32 u -> (Int32.to_int u) | C_int64 u -> (Int64.to_int u) | C_float f -> (int_of_float f) | C_double d -> (int_of_float d) | C_ptr (p,q) -> (Int64.to_int p) | C_obj o -> (try (get_int (o "int" C_void)) with _ -> (get_int (o "&" C_void))) | _ -> raise (Failure "Can't convert to int") let rec get_float x = match x with C_char c | C_uchar c -> (float_of_int (int_of_char c)) | C_short s -> (float_of_int s) | C_ushort s -> (float_of_int s) | C_int s -> (float_of_int s) | C_uint u | C_int32 u -> (float_of_int (Int32.to_int u)) | C_int64 u -> (float_of_int (Int64.to_int u)) | C_float f -> f | C_double d -> d | C_obj o -> (try (get_float (o "float" C_void)) with _ -> (get_float (o "double" C_void))) | _ -> raise (Failure "Can't convert to float") let rec get_char x = (char_of_int (get_int x)) let rec get_string x = match x with C_string str -> str | _ -> raise (Failure "Can't convert to string") let rec get_bool x = match x with C_bool b -> b | _ -> (try if get_int x != 0 then true else false with _ -> raise (Failure "Can't convert to bool")) let disown_object obj = match obj with C_director_core (o,r) -> r := None | _ -> raise (Failure "Not a director core object") let _ = Callback.register "caml_obj_disown" disown_object let addr_of obj = match obj with C_obj _ -> (invoke obj) "&" C_void | C_director_core (self,r) -> (invoke self) "&" C_void | C_ptr _ -> obj | _ -> raise (Failure "Not a pointer.") let _ = Callback.register "caml_obj_ptr" addr_of let make_float f = C_float f let make_double f = C_double f let make_string s = C_string s let make_bool b = C_bool b let make_char c = C_char c let make_char_i c = C_char (char_of_int c) let make_uchar c = C_uchar c let make_uchar_i c = C_uchar (char_of_int c) let make_short i = C_short i let make_ushort i = C_ushort i let make_int i = C_int i let make_uint i = C_uint (Int32.of_int i) let make_int32 i = C_int32 (Int32.of_int i) let make_int64 i = C_int64 (Int64.of_int i) let new_derived_object cfun x_class args = begin let get_object ob = match !ob with None -> raise (NotObject C_void) | Some o -> o in let ob_ref = ref None in let class_fun class_f ob_r = (fun meth args -> class_f (get_object ob_r) meth args) in let new_class = class_fun x_class ob_ref in let dircore = C_director_core (C_obj new_class,ob_ref) in let obj = cfun (match args with C_list argl -> (C_list ((dircore :: argl))) | C_void -> (C_list [ dircore ]) | a -> (C_list [ dircore ; a ])) in ob_ref := Some obj ; obj end let swig_current_type_info = ref C_void let find_type_info obj = !swig_current_type_info let _ = Callback.register "swig_find_type_info" find_type_info let set_type_info obj = match obj with C_ptr _ -> swig_current_type_info := obj ; obj | _ -> raise (Failure "Internal error: passed non pointer to set_type_info") let _ = Callback.register "swig_set_type_info" set_type_info let class_master_list = Hashtbl.create 20 let register_class_byname nm co = Hashtbl.replace class_master_list nm (Obj.magic co) let create_class nm arg = try (Obj.magic (Hashtbl.find class_master_list nm)) arg with _ -> raise (NoSuchClass nm) swig-3.0.2/Lib/ocaml/std_common.i0000664000175000017500000000102312343605122016454 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; %{ #include CAML_VALUE SwigString_FromString(const std::string& s) { return caml_val_string((char *)s.c_str()); } std::string SwigString_AsString(CAML_VALUE o) { return std::string((char *)caml_ptr_val(o,0)); } %} swig-3.0.2/Lib/ocaml/std_list.i0000664000175000017500000001034412343605122016145 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_list.i * * SWIG typemaps for std::list types * ----------------------------------------------------------------------------- */ %include %module std_list %{ #include #include %} namespace std{ template class list { public: typedef T &reference; typedef const T& const_reference; typedef T &iterator; typedef const T& const_iterator; list(); list(unsigned int size, const T& value = T()); list(const list &); ~list(); void assign(unsigned int n, const T& value); void swap(list &x); const_reference front(); const_reference back(); const_iterator begin(); const_iterator end(); void resize(unsigned int n, T c = T()); bool empty() const; void push_front(const T& x); void push_back(const T& x); void pop_front(); void pop_back(); void clear(); unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, const T& value); void remove(const T& value); void unique(); void reverse(); void sort(); %extend { const_reference __getitem__(int i) throw (std::out_of_range) { std::list::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && i::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && i::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && ierase(first); } else throw std::out_of_range("list index out of range"); } std::list __getslice__(int i,int j) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; if (i>=j) i=j; if (i>=0 && i=0) { for (int k=0;k tmp(j-i); if (j>i) std::copy(first,end,tmp.begin()); return tmp; } else throw std::out_of_range("list index out of range"); } void __delslice__(int i,int j) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; for (int k=0;kerase(first,end); } void __setslice__(int i,int j, const std::list& v) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; for (int k=0;kerase(first,end); if (i+1 <= int(self->size())) { first = self->begin(); for (int k=0;kinsert(first,v.begin(),v.end()); } else self->insert(self->end(),v.begin(),v.end()); } } unsigned int __len__() { return self->size(); } bool __nonzero__() { return !(self->empty()); } void append(const T& x) { self->push_back(x); } void pop() { self->pop_back(); } }; }; } swig-3.0.2/Lib/ocaml/preamble.swg0000664000175000017500000000073112343605122016456 0ustar williamwilliam%insert(mli) %{ exception BadArgs of string exception BadMethodName of c_obj * string * string exception NotObject of c_obj exception NotEnumType of c_obj exception LabelNotFromThisEnum of c_obj exception InvalidDirectorCall of c_obj %} %insert(ml) %{ exception BadArgs of string exception BadMethodName of c_obj * string * string exception NotObject of c_obj exception NotEnumType of c_obj exception LabelNotFromThisEnum of c_obj exception InvalidDirectorCall of c_obj %}swig-3.0.2/Lib/ocaml/libswigocaml.h0000664000175000017500000000070612343605122016774 0ustar williamwilliam/* Ocaml runtime support */ #ifdef __cplusplus extern "C" { #endif typedef int oc_bool; extern void *nullptr; extern oc_bool isnull( void *v ); extern void *get_char_ptr( char *str ); extern void *make_ptr_array( int size ); extern void *get_ptr( void *arrayptr, int elt ); extern void set_ptr( void *arrayptr, int elt, void *elt_v ); extern void *offset_ptr( void *ptr, int n ); #ifdef __cplusplus }; #endif swig-3.0.2/Lib/ocaml/ocaml.swg0000664000175000017500000003406612343605122015772 0ustar williamwilliam/* -*-c-*- */ /* SWIG pointer structure */ #include #include #ifdef __cplusplus extern "C" { #endif #define C_bool 0 #define C_char 1 #define C_uchar 2 #define C_short 3 #define C_ushort 4 #define C_int 5 #define C_uint 6 #define C_int32 7 #define C_int64 8 #define C_float 9 #define C_double 10 #define C_ptr 11 #define C_array 12 #define C_list 13 #define C_obj 14 #define C_string 15 #define C_enum 16 #define C_director_core 17 /* Cast a pointer if possible; returns 1 if successful */ SWIGSTATIC int SWIG_Cast (void *source, swig_type_info *source_type, void **ptr, swig_type_info *dest_type) { if( !source ) { // Special case for NULL. This is a popular question // for other modules on the list, so I want an easy way out... *ptr = 0; return 0; } #ifdef TYPE_CAST_VERBOSE fprintf( stderr, "Trying to cast %s to %s\n", source_type ? source_type->str : "", dest_type ? dest_type->str : "" ); #endif if (dest_type != source_type) { /* We have a type mismatch. Will have to look through our type mapping table to figure out whether or not we can accept this datatype. -- Ignore typechecks for void *. Allow any conversion. */ if( !dest_type || !source_type || !strcmp(dest_type->name,"_p_void") || !strcmp(source_type->name,"_p_void") ) { *ptr = source; return 0; } else { swig_cast_info *tc = SWIG_TypeCheckStruct(source_type, dest_type ); #ifdef TYPE_CAST_VERBOSE fprintf( stderr, "Typecheck -> %s\n", tc ? tc->str : "" ); #endif if( tc ) { int newmemory = 0; *ptr = SWIG_TypeCast(tc, source, &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return 0; } else return -1; } } else { *ptr = source; return 0; } } /* Return 0 if successful. */ SWIGSTATIC int SWIG_GetPtr(void *inptr, void **outptr, swig_type_info *intype, swig_type_info *outtype) { if (intype) { return SWIG_Cast(inptr, intype, outptr, outtype) == -1; } else { *outptr = inptr; return 0; } } SWIGSTATIC void caml_print_list( CAML_VALUE v ); SWIGSTATIC void caml_print_val( CAML_VALUE v ) { switch( SWIG_Tag_val(v) ) { case C_bool: if( Bool_val(SWIG_Field(v,0)) ) fprintf( stderr, "true " ); else fprintf( stderr, "false " ); break; case C_char: case C_uchar: fprintf( stderr, "'%c' (\\%03d) ", (Int_val(SWIG_Field(v,0)) >= ' ' && Int_val(SWIG_Field(v,0)) < 127) ? Int_val(SWIG_Field(v,0)) : '.', Int_val(SWIG_Field(v,0)) ); break; case C_short: case C_ushort: case C_int: fprintf( stderr, "%d ", (int)caml_long_val(v) ); break; case C_uint: case C_int32: fprintf( stderr, "%ud ", (unsigned int)caml_long_val(v) ); break; case C_int64: fprintf( stderr, "%ld ", caml_long_val(v) ); break; case C_float: case C_double: fprintf( stderr, "%f ", caml_double_val(v) ); break; case C_ptr: { void *vout = 0; swig_type_info *ty = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1)); caml_ptr_val_internal(v,&vout,0); fprintf( stderr, "PTR(%p,%s) ", vout, ty ? ty->name : "(null)" ); } break; case C_array: { unsigned int i; for( i = 0; i < Wosize_val( SWIG_Field(v,0) ); i++ ) caml_print_val( SWIG_Field(SWIG_Field(v,0),i) ); } break; case C_list: caml_print_list( SWIG_Field(v,0) ); break; case C_obj: fprintf( stderr, "OBJ(%p) ", (void *)SWIG_Field(v,0) ); break; case C_string: { void *cout; caml_ptr_val_internal(v,&cout,0); fprintf( stderr, "'%s' ", (char *)cout ); } break; } } SWIGSTATIC void caml_print_list( CAML_VALUE v ) { CAMLparam1(v); while( v && Is_block(v) ) { fprintf( stderr, "[ " ); caml_print_val( SWIG_Field(v,0) ); fprintf( stderr, "]\n" ); v = SWIG_Field(v,1); } CAMLreturn0; } SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) { CAMLparam1(lst); int i = 0; while( i < n && lst && Is_block(lst) ) { i++; lst = SWIG_Field(lst,1); } if( lst == Val_unit ) CAMLreturn(Val_unit); else CAMLreturn(SWIG_Field(lst,0)); } SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) { CAMLparam2(lst,elt); SWIG_CAMLlocal3(v,vt,lh); lh = Val_unit; v = Val_unit; /* Appending C_void should have no effect */ if( !Is_block(elt) ) return lst; while( lst && Is_block(lst) ) { if( v && v != Val_unit ) { vt = alloc_tuple(2); SWIG_Store_field(v,1,vt); v = vt; } else { v = lh = alloc_tuple(2); } SWIG_Store_field(v,0,SWIG_Field(lst,0)); lst = SWIG_Field(lst,1); } if( v && Is_block(v) ) { vt = alloc_tuple(2); SWIG_Store_field(v,1,vt); v = vt; } else { v = lh = alloc_tuple(2); } SWIG_Store_field(v,0,elt); SWIG_Store_field(v,1,Val_unit); CAMLreturn(lh); } SWIGSTATIC int caml_list_length( CAML_VALUE lst ) { CAMLparam1(lst); int i = 0; while( lst && Is_block(lst) ) { i++; lst = SWIG_Field(lst,1); } CAMLreturn(i); } SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ) { CAMLparam2(arr,item); SWIG_Store_field(SWIG_Field(arr,0),n,item); CAMLreturn0; } SWIGSTATIC value caml_array_nth( CAML_VALUE arr, int n ) { CAMLparam1(arr); if( SWIG_Tag_val(arr) == C_array ) CAMLreturn(SWIG_Field(SWIG_Field(arr,0),n)); else if( SWIG_Tag_val(arr) == C_list ) CAMLreturn(caml_list_nth(arr,0)); else failwith("Need array or list"); } SWIGSTATIC int caml_array_len( CAML_VALUE arr ) { CAMLparam1(arr); if( SWIG_Tag_val(arr) == C_array ) CAMLreturn(Wosize_val(SWIG_Field(arr,0))); else if( SWIG_Tag_val(arr) == C_list ) CAMLreturn(caml_list_length(arr)); else failwith("Need array or list"); } SWIGSTATIC CAML_VALUE caml_swig_alloc(int x,int y) { return caml_alloc(x,y); } SWIGSTATIC value caml_array_new( int n ) { CAMLparam0(); SWIG_CAMLlocal1(vv); vv = caml_swig_alloc(1,C_array); SWIG_Store_field(vv,0,alloc_tuple(n)); CAMLreturn(vv); } SWIGSTATIC CAML_VALUE caml_val_bool( int b ) { CAMLparam0(); SWIG_CAMLlocal1(bv); bv = caml_swig_alloc(1,C_bool); SWIG_Store_field(bv,0,Val_bool(b)); CAMLreturn(bv); } SWIGSTATIC CAML_VALUE caml_val_char( char c ) { CAMLparam0(); SWIG_CAMLlocal1(cv); cv = caml_swig_alloc(1,C_char); SWIG_Store_field(cv,0,Val_int(c)); CAMLreturn(cv); } SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char uc ) { CAMLparam0(); SWIG_CAMLlocal1(ucv); ucv = caml_swig_alloc(1,C_uchar); SWIG_Store_field(ucv,0,Val_int(uc)); CAMLreturn(ucv); } SWIGSTATIC CAML_VALUE caml_val_short( short s ) { CAMLparam0(); SWIG_CAMLlocal1(sv); sv = caml_swig_alloc(1,C_short); SWIG_Store_field(sv,0,Val_int(s)); CAMLreturn(sv); } SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short us ) { CAMLparam0(); SWIG_CAMLlocal1(usv); usv = caml_swig_alloc(1,C_ushort); SWIG_Store_field(usv,0,Val_int(us)); CAMLreturn(usv); } SWIGSTATIC CAML_VALUE caml_val_int( int i ) { CAMLparam0(); SWIG_CAMLlocal1(iv); iv = caml_swig_alloc(1,C_int); SWIG_Store_field(iv,0,Val_int(i)); CAMLreturn(iv); } SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int ui ) { CAMLparam0(); SWIG_CAMLlocal1(uiv); uiv = caml_swig_alloc(1,C_int); SWIG_Store_field(uiv,0,Val_int(ui)); CAMLreturn(uiv); } SWIGSTATIC CAML_VALUE caml_val_long( long l ) { CAMLparam0(); SWIG_CAMLlocal1(lv); lv = caml_swig_alloc(1,C_int64); SWIG_Store_field(lv,0,copy_int64(l)); CAMLreturn(lv); } SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long ul ) { CAMLparam0(); SWIG_CAMLlocal1(ulv); ulv = caml_swig_alloc(1,C_int64); SWIG_Store_field(ulv,0,copy_int64(ul)); CAMLreturn(ulv); } SWIGSTATIC CAML_VALUE caml_val_float( float f ) { CAMLparam0(); SWIG_CAMLlocal1(fv); fv = caml_swig_alloc(1,C_float); SWIG_Store_field(fv,0,copy_double((double)f)); CAMLreturn(fv); } SWIGSTATIC CAML_VALUE caml_val_double( double d ) { CAMLparam0(); SWIG_CAMLlocal1(fv); fv = caml_swig_alloc(1,C_double); SWIG_Store_field(fv,0,copy_double(d)); CAMLreturn(fv); } SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *info ) { CAMLparam0(); SWIG_CAMLlocal1(vv); vv = caml_swig_alloc(2,C_ptr); SWIG_Store_field(vv,0,copy_int64((long)p)); SWIG_Store_field(vv,1,copy_int64((long)info)); CAMLreturn(vv); } SWIGSTATIC CAML_VALUE caml_val_string( const char *p ) { CAMLparam0(); SWIG_CAMLlocal1(vv); if( !p ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); vv = caml_swig_alloc(1,C_string); SWIG_Store_field(vv,0,copy_string(p)); CAMLreturn(vv); } SWIGSTATIC CAML_VALUE caml_val_string_len( const char *p, int len ) { CAMLparam0(); SWIG_CAMLlocal1(vv); if( !p || len < 0 ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); vv = caml_swig_alloc(1,C_string); SWIG_Store_field(vv,0,alloc_string(len)); memcpy(String_val(SWIG_Field(vv,0)),p,len); CAMLreturn(vv); } #define caml_val_obj(v, name) caml_val_obj_helper(v, SWIG_TypeQuery((name)), name) SWIGSTATIC CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) { CAMLparam0(); CAMLreturn(callback2(*caml_named_value("caml_create_object_fn"), caml_val_ptr(v,type), copy_string(name))); } SWIGSTATIC long caml_long_val_full( CAML_VALUE v, char *name ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_bool: case C_char: case C_uchar: case C_short: case C_ushort: case C_int: CAMLreturn(Int_val(SWIG_Field(v,0))); case C_uint: case C_int32: CAMLreturn(Int32_val(SWIG_Field(v,0))); case C_int64: CAMLreturn((long)SWIG_Int64_val(SWIG_Field(v,0))); case C_float: case C_double: CAMLreturn((long)Double_val(SWIG_Field(v,0))); case C_string: CAMLreturn((long)String_val(SWIG_Field(v,0))); case C_ptr: CAMLreturn((long)SWIG_Int64_val(SWIG_Field(SWIG_Field(v,0),0))); case C_enum: { SWIG_CAMLlocal1(ret); CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int"); if( !name ) failwith( "Not an enum conversion" ); ret = callback2(*enum_to_int,*caml_named_value(name),v); CAMLreturn(caml_long_val(ret)); } default: failwith("No conversion to int"); } } SWIGSTATIC long caml_long_val( CAML_VALUE v ) { return caml_long_val_full(v,0); } SWIGSTATIC double caml_double_val( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0.0; switch( SWIG_Tag_val(v) ) { case C_bool: case C_char: case C_uchar: case C_short: case C_ushort: case C_int: CAMLreturn_type(Int_val(SWIG_Field(v,0))); case C_uint: case C_int32: CAMLreturn_type(Int32_val(SWIG_Field(v,0))); case C_int64: CAMLreturn_type(SWIG_Int64_val(SWIG_Field(v,0))); case C_float: case C_double: CAMLreturn_type(Double_val(SWIG_Field(v,0))); default: fprintf( stderr, "Unknown block tag %d\n", SWIG_Tag_val(v) ); failwith("No conversion to double"); } } SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, swig_type_info *descriptor ) { CAMLparam1(v); void *outptr = NULL; swig_type_info *outdescr = NULL; if( v == Val_unit ) { *out = 0; CAMLreturn(0); } if( !Is_block(v) ) return -1; switch( SWIG_Tag_val(v) ) { case C_int: if( !caml_long_val( v ) ) { *out = 0; CAMLreturn(0); } else { *out = 0; CAMLreturn(1); } break; case C_obj: CAMLreturn (caml_ptr_val_internal (callback(*caml_named_value("caml_obj_ptr"),v), out,descriptor)); case C_string: outptr = (void *)String_val(SWIG_Field(v,0)); break; case C_ptr: outptr = (void *)(long)SWIG_Int64_val(SWIG_Field(v,0)); outdescr = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1)); break; default: *out = 0; CAMLreturn(1); break; } CAMLreturn(SWIG_GetPtr(outptr,out,outdescr,descriptor)); } SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) { CAMLparam0(); #ifdef TYPE_CAST_VERBOSE caml_print_val( v ); #endif void *out = NULL; if( !caml_ptr_val_internal( v, &out, descriptor ) ) CAMLreturn_type(out); else failwith( "No appropriate conversion found." ); } SWIGSTATIC char *caml_string_val( CAML_VALUE v ) { return (char *)caml_ptr_val( v, 0 ); } SWIGSTATIC int caml_string_len( CAML_VALUE v ) { switch( SWIG_Tag_val(v) ) { case C_string: return string_length(SWIG_Field(v,0)); default: return strlen((char *)caml_ptr_val(v,0)); } } SWIGSTATIC int caml_bool_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_bool: case C_ptr: case C_string: CAMLreturn(1); default: CAMLreturn(0); } } SWIGSTATIC int caml_int_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_char: case C_uchar: case C_short: case C_ushort: case C_int: case C_uint: case C_int32: case C_int64: CAMLreturn(1); default: CAMLreturn(0); } } SWIGSTATIC int caml_float_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_float: case C_double: CAMLreturn(1); default: CAMLreturn(0); } } SWIGSTATIC int caml_ptr_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_string: case C_ptr: case C_int64: CAMLreturn(1); default: CAMLreturn(0); } } static swig_module_info *SWIG_Ocaml_GetModule(void *SWIGUNUSEDPARM(clientdata)) { CAML_VALUE pointer; pointer = callback(*caml_named_value("swig_find_type_info"), caml_val_int(0)); if (Is_block(pointer) && SWIG_Tag_val(pointer) == C_ptr) { return (swig_module_info *)(void *)(long)SWIG_Int64_val(SWIG_Field(pointer,0)); } return 0; } static void SWIG_Ocaml_SetModule(swig_module_info *pointer) { CAML_VALUE mod_pointer; mod_pointer = caml_val_ptr(pointer, NULL); callback(*caml_named_value("swig_set_type_info"), mod_pointer); } #ifdef __cplusplus } #endif #undef value swig-3.0.2/Lib/ocaml/typecheck.i0000664000175000017500000001115412343605122016277 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typecheck.i * * Typechecking rules * ----------------------------------------------------------------------------- */ %typecheck(SWIG_TYPECHECK_INTEGER) char, signed char, const char &, const signed char & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_char: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, const unsigned char & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_uchar: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) short, signed short, const short &, const signed short &, wchar_t { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_short: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) unsigned short, const unsigned short & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_ushort: $1 = 1; break; default: $1 = 0; break; } } } // XXX arty // Will move enum SWIGTYPE later when I figure out what to do with it... %typecheck(SWIG_TYPECHECK_INTEGER) int, signed int, const int &, const signed int &, enum SWIGTYPE { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_int: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) unsigned int, const unsigned int & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_uint: $1 = 1; break; case C_int32: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) long, signed long, unsigned long, long long, signed long long, unsigned long long, const long &, const signed long &, const unsigned long &, const long long &, const signed long long &, const unsigned long long & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_int64: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) bool, oc_bool, BOOL, const bool &, const oc_bool &, const BOOL & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_bool: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_DOUBLE) float, const float & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_float: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_DOUBLE) double, const double & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_double: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_STRING) char * { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_string: $1 = 1; break; case C_ptr: { swig_type_info *typeinfo = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field($input,1)); $1 = SWIG_TypeCheck("char *",typeinfo) || SWIG_TypeCheck("signed char *",typeinfo) || SWIG_TypeCheck("unsigned char *",typeinfo) || SWIG_TypeCheck("const char *",typeinfo) || SWIG_TypeCheck("const signed char *",typeinfo) || SWIG_TypeCheck("const unsigned char *",typeinfo) || SWIG_TypeCheck("std::string",typeinfo); } break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; $1 = !caml_ptr_val_internal($input, &ptr,$descriptor); } #if 0 %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; $1 = !caml_ptr_val_internal($input, &ptr, $&1_descriptor); } #endif %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; $1 = !caml_ptr_val_internal($input, &ptr, 0); } /* ------------------------------------------------------------ * Exception handling * ------------------------------------------------------------ */ %typemap(throws) int, long, short, unsigned int, unsigned long, unsigned short { SWIG_exception($1,"Thrown exception from C++ (int)"); } %typemap(throws) SWIGTYPE CLASS { $&1_ltype temp = new $1_ltype($1); SWIG_exception((int)temp,"Thrown exception from C++ (object)"); } %typemap(throws) SWIGTYPE { (void)$1; SWIG_exception(0,"Thrown exception from C++ (unknown)"); } %typemap(throws) char * { SWIG_exception(0,$1); } swig-3.0.2/Lib/ocaml/std_vector.i0000664000175000017500000000530212343605122016472 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector types * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // Python as much as possible, namely, to allow the user to pass and // be returned Python tuples or lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&), f(const std::vector*): // the parameter being read-only, either a Python sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(): // the vector is returned by copy; therefore, a Python sequence of T:s // is returned which is most easily used in other Python functions // -- std::vector& f(), std::vector* f(), const std::vector& f(), // const std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class vector { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); unsigned int size() const; bool empty() const; void clear(); void push_back(const T& x); T operator [] ( int f ); vector &operator = ( vector &other ); %extend { void set( int i, const T &x ) { self->resize(i+1); (*self)[i] = x; } }; %extend { T *to_array() { T *array = new T[self->size() + 1]; for( int i = 0; i < self->size(); i++ ) array[i] = (*self)[i]; return array; } }; }; }; %insert(ml) %{ let array_to_vector v argcons array = for i = 0 to (Array.length array) - 1 do (invoke v) "set" (C_list [ C_int i ; (argcons array.(i)) ]) done ; v let vector_to_array v argcons array = for i = 0; to (get_int ((invoke v) "size" C_void)) - 1 do array.(i) <- argcons ((invoke v) "[]" (C_int i)) done ; v %} %insert(mli) %{ val array_to_vector : c_obj -> ('a -> c_obj) -> 'a array -> c_obj val vector_to_array : c_obj -> (c_obj -> 'a) -> 'a array -> c_obj %} swig-3.0.2/Lib/ocaml/std_string.i0000664000175000017500000000620212343605122016476 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string * ----------------------------------------------------------------------------- */ // ------------------------------------------------------------------------ // std::string is typemapped by value // This can prevent exporting methods which return a string // in order for the user to modify it. // However, I think I'll wait until someone asks for it... // ------------------------------------------------------------------------ %{ #include #include %} %include %include namespace std { %naturalvar string; %naturalvar wstring; class string; class wstring; /* Overloading check */ %typemap(in) string { /* %typemap(in) string */ if (caml_ptr_check($input)) $1.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); else SWIG_exception(SWIG_TypeError, "string expected"); } %typemap(in) const string & ($*1_ltype temp) { /* %typemap(in) const string & */ if (caml_ptr_check($input)) { temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); $1 = &temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(in) string & ($*1_ltype temp) { /* %typemap(in) string & */ if (caml_ptr_check($input)) { temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); $1 = &temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(in) string * ($*1_ltype *temp) { /* %typemap(in) string * */ if (caml_ptr_check($input)) { temp = new $*1_ltype((char *)caml_ptr_val($input,0), caml_string_len($input)); $1 = temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(free) string * ($*1_ltype *temp) { delete temp; } %typemap(argout) string & { /* %typemap(argout) string & */ swig_result = caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), (*$1).size())); } %typemap(directorout) string { /* %typemap(directorout) string */ $result.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); } %typemap(out) string { /* %typemap(out) string */ $result = caml_val_string_len($1.c_str(),$1.size()); } %typemap(out) string * { /* %typemap(out) string * */ $result = caml_val_string_len((*$1).c_str(),(*$1).size()); } } #ifdef ENABLE_CHARPTR_ARRAY char **c_charptr_array( const std::vector &str_v ); %{ SWIGEXT char **c_charptr_array( const std::vector &str_v ) { char **out = new char *[str_v.size() + 1]; out[str_v.size()] = 0; for( int i = 0; i < str_v.size(); i++ ) { out[i] = (char *)str_v[i].c_str(); } return out; } %} #endif #ifdef ENABLE_STRING_VECTOR %template (StringVector) std::vector; %insert(ml) %{ (* Some STL convenience items *) let string_array_to_vector sa = let nv = _new_StringVector C_void in array_to_vector nv (fun x -> C_string x) sa ; nv let c_string_array ar = _c_charptr_array (string_array_to_vector ar) %} %insert(mli) %{ val c_string_array: string array -> c_obj %} #endif swig-3.0.2/Lib/ocaml/stl.i0000664000175000017500000000054512343605122015124 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/ocaml/std_deque.i0000664000175000017500000000132212343605122016271 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_deque.i * * Default std_deque wrapper * ----------------------------------------------------------------------------- */ %module std_deque %rename(__getitem__) std::deque::getitem; %rename(__setitem__) std::deque::setitem; %rename(__delitem__) std::deque::delitem; %rename(__getslice__) std::deque::getslice; %rename(__setslice__) std::deque::setslice; %rename(__delslice__) std::deque::delslice; %extend std::deque { int __len__() { return (int) self->size(); } int __nonzero__() { return ! self->empty(); } void append(const T &x) { self->push_back(x); } }; %include swig-3.0.2/Lib/ocaml/ocamlkw.swg0000664000175000017500000000205212343605122016322 0ustar williamwilliam#ifndef OCAML_OCAMLKW_SWG_ #define OCAML_OCAMLKW_SWG_ /* Warnings for Ocaml keywords */ #define OCAMLKW(x) %namewarn("314: '" #x "' is an ocaml keyword and it will be appropriately renamed") #x /* from http://caml.inria.fr/ocaml/htmlman/manual044.html */ OCAMLKW(and); OCAMLKW(as); OCAMLKW(assert); OCAMLKW(begin); OCAMLKW(class); OCAMLKW(constraint); OCAMLKW(do); OCAMLKW(done); OCAMLKW(downto); OCAMLKW(else); OCAMLKW(end); OCAMLKW(exception); OCAMLKW(external); OCAMLKW(false); OCAMLKW(for); OCAMLKW(fun); OCAMLKW(function); OCAMLKW(functor); OCAMLKW(if); OCAMLKW(in); OCAMLKW(include); OCAMLKW(inherit); OCAMLKW(initializer); OCAMLKW(lazy); OCAMLKW(let); OCAMLKW(match); OCAMLKW(method); OCAMLKW(module); OCAMLKW(mutable); OCAMLKW(new); OCAMLKW(object); OCAMLKW(of); OCAMLKW(open); OCAMLKW(or); OCAMLKW(private); OCAMLKW(rec); OCAMLKW(sig); OCAMLKW(struct); OCAMLKW(then); OCAMLKW(to); OCAMLKW(true); OCAMLKW(try); OCAMLKW(type); OCAMLKW(val); OCAMLKW(virtual); OCAMLKW(when); OCAMLKW(while); OCAMLKW(with); #undef OCAMLKW #endif //OCAML_OCAMLKW_SWG_ swig-3.0.2/Lib/ocaml/ocamldec.swg0000664000175000017500000001233212343605122016436 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ocamldec.swg * * Ocaml runtime code -- declarations * ----------------------------------------------------------------------------- */ #include #include #include #ifdef __cplusplus #define SWIGEXT extern "C" SWIGEXT { #else #define SWIGEXT #endif #define value caml_value_t #define CAML_VALUE caml_value_t #include #include #include #include #include #include #include #define caml_array_set swig_caml_array_set // Adapted from memory.h and mlvalues.h #define SWIG_CAMLlocal1(x) \ caml_value_t x = 0; \ CAMLxparam1 (x) #define SWIG_CAMLlocal2(x, y) \ caml_value_t x = 0, y = 0; \ CAMLxparam2 (x, y) #define SWIG_CAMLlocal3(x, y, z) \ caml_value_t x = 0, y = 0, z = 0; \ CAMLxparam3 (x, y, z) #define SWIG_CAMLlocal4(x, y, z, t) \ caml_value_t x = 0, y = 0, z = 0, t = 0; \ CAMLxparam4 (x, y, z, t) #define SWIG_CAMLlocal5(x, y, z, t, u) \ caml_value_t x = 0, y = 0, z = 0, t = 0, u = 0; \ CAMLxparam5 (x, y, z, t, u) #define SWIG_CAMLlocalN(x, size) \ caml_value_t x [(size)] = { 0, /* 0, 0, ... */ }; \ CAMLxparamN (x, (size)) #define SWIG_Field(x, i) (((caml_value_t *)(x)) [i]) /* Also an l-value. */ #define SWIG_Store_field(block, offset, val) do{ \ mlsize_t caml__temp_offset = (offset); \ caml_value_t caml__temp_val = (val); \ modify (&SWIG_Field ((block), caml__temp_offset), caml__temp_val); \ }while(0) #define SWIG_Data_custom_val(v) ((void *) &SWIG_Field((v), 1)) #ifdef ARCH_BIG_ENDIAN #define SWIG_Tag_val(val) (((unsigned char *) (val)) [-1]) /* Also an l-value. */ #define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [sizeof(caml_value_t)-1]) /* Also an l-value. */ #else #define SWIG_Tag_val(val) (((unsigned char *) (val)) [-sizeof(caml_value_t)]) /* Also an l-value. */ #define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [0]) /* Also an l-value. */ #endif #ifdef CAMLreturn0 #undef CAMLreturn0 #endif #define CAMLreturn0 do{ \ caml_local_roots = caml__frame; \ return; \ }while (0) #ifdef CAMLreturn #undef CAMLreturn #endif #define CAMLreturn(result) do{ \ caml_value_t caml__temp_result = (result); \ caml_local_roots = caml__frame; \ return (caml__temp_result); \ }while(0) #define CAMLreturn_type(result) do{ \ caml_local_roots = caml__frame; \ return result; \ }while(0) #ifdef CAMLnoreturn #undef CAMLnoreturn #endif #define CAMLnoreturn ((void) caml__frame) #ifndef ARCH_ALIGN_INT64 #define SWIG_Int64_val(v) (*((int64 *) SWIG_Data_custom_val(v))) #else CAMLextern int64 Int64_val(caml_value_t v); #define SWIG_Int64_val(v) Int64_val(v) #endif #define SWIG_NewPointerObj(p,type,flags) caml_val_ptr(p,type) #define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer) #define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else SWIGSTATIC int SWIG_GetPtr(void *source, void **result, swig_type_info *type, swig_type_info *result_type); SWIGSTATIC void * SWIG_MustGetPtr (CAML_VALUE v, swig_type_info *type); SWIGSTATIC CAML_VALUE _wrap_delete_void( CAML_VALUE ); SWIGSTATIC int enum_to_int( char *name, CAML_VALUE v ); SWIGSTATIC CAML_VALUE int_to_enum( char *name, int v ); SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ); SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ); SWIGSTATIC int caml_list_length( CAML_VALUE lst ); SWIGSTATIC CAML_VALUE caml_array_new( int n ); SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ); SWIGSTATIC CAML_VALUE caml_array_nth( CAML_VALUE arr, int n ); SWIGSTATIC int caml_array_length( CAML_VALUE arr ); SWIGSTATIC CAML_VALUE caml_val_char( char c ); SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char c ); SWIGSTATIC CAML_VALUE caml_val_short( short s ); SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short s ); SWIGSTATIC CAML_VALUE caml_val_int( int x ); SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int x ); SWIGSTATIC CAML_VALUE caml_val_long( long x ); SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long x ); SWIGSTATIC CAML_VALUE caml_val_float( float f ); SWIGSTATIC CAML_VALUE caml_val_double( double d ); SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor ); SWIGSTATIC CAML_VALUE caml_val_string( const char *str ); SWIGSTATIC CAML_VALUE caml_val_string_len( const char *str, int len ); SWIGSTATIC long caml_long_val( CAML_VALUE v ); SWIGSTATIC double caml_double_val( CAML_VALUE v ); SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, swig_type_info *descriptor ); SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ); SWIGSTATIC char *caml_string_val( CAML_VALUE v ); SWIGSTATIC int caml_string_len( CAML_VALUE v ); #ifdef __cplusplus } #endif /* mzschemedec.swg ends here */ swig-3.0.2/Lib/ocaml/typeregister.swg0000664000175000017500000000006712343605122017417 0ustar williamwilliamSWIGEXT void SWIG_init() { SWIG_InitializeModule(0); swig-3.0.2/Lib/cdata.i0000664000175000017500000000576612343605122014315 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cdata.i * * SWIG library file containing macros for manipulating raw C data as strings. * ----------------------------------------------------------------------------- */ %{ typedef struct SWIGCDATA { char *data; int len; } SWIGCDATA; %} /* ----------------------------------------------------------------------------- * Typemaps for returning binary data * ----------------------------------------------------------------------------- */ #if SWIGGUILE %typemap(out) SWIGCDATA { $result = scm_from_locale_stringn($1.data,$1.len); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #elif SWIGCHICKEN %typemap(out) SWIGCDATA { C_word *string_space = C_alloc(C_SIZEOF_STRING($1.len)); $result = C_string(&string_space, $1.len, $1.data); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #elif SWIGPHP %typemap(out) SWIGCDATA { ZVAL_STRINGL($result, $1.data, $1.len, 1); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #elif SWIGJAVA %apply (char *STRING, int LENGTH) { (const void *indata, int inlen) } %typemap(jni) SWIGCDATA "jbyteArray" %typemap(jtype) SWIGCDATA "byte[]" %typemap(jstype) SWIGCDATA "byte[]" %fragment("SWIG_JavaArrayOutCDATA", "header") { static jbyteArray SWIG_JavaArrayOutCDATA(JNIEnv *jenv, char *result, jsize sz) { jbyte *arr; int i; jbyteArray jresult = JCALL1(NewByteArray, jenv, sz); if (!jresult) return NULL; arr = JCALL2(GetByteArrayElements, jenv, jresult, 0); if (!arr) return NULL; for (i=0; i 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ # endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else # define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif /* internal SWIG method */ #ifndef SWIGINTERN # define SWIGINTERN static SWIGUNUSED #endif /* internal inline SWIG method */ #ifndef SWIGINTERNINLINE # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif /* exporting methods */ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) # ifndef GCC_HASCLASSVISIBILITY # define GCC_HASCLASSVISIBILITY # endif #endif #ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) # define SWIGEXPORT # else # define SWIGEXPORT __declspec(dllexport) # endif # else # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) # define SWIGEXPORT __attribute__ ((visibility("default"))) # else # define SWIGEXPORT # endif # endif #endif /* calling conventions for Windows */ #ifndef SWIGSTDCALL # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL # endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) # define _SCL_SECURE_NO_DEPRECATE #endif swig-3.0.2/Lib/swigarch.i0000664000175000017500000000305412343605122015034 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigarch.i * * SWIG library file for 32bit/64bit code specialization and checking. * * Use only in extreme cases, when no arch. independent code can be * generated * * To activate architecture specific code, use * * swig -DSWIGWORDSIZE32 * * or * * swig -DSWIGWORDSIZE64 * * Note that extra checking code will be added to the wrapped code, * which will prevent the compilation in a different architecture. * * If you don't specify the SWIGWORDSIZE (the default case), swig will * generate architecture independent and/or 32bits code, with no extra * checking code added. * ----------------------------------------------------------------------------- */ #if !defined(SWIGWORDSIZE32) && !defined(SWIGWORDSIZE64) # if (__WORDSIZE == 32) # define SWIGWORDSIZE32 # endif #endif #if !defined(SWIGWORDSIZE64) && !defined(SWIGWORDSIZE32) # if defined(__x86_64) || defined(__x86_64__) || (__WORDSIZE == 64) # define SWIGWORDSIZE64 # endif #endif #ifdef SWIGWORDSIZE32 %{ #define SWIGWORDSIZE32 #ifndef LONG_MAX #include #endif #if (__WORDSIZE == 64) || (LONG_MAX != INT_MAX) # error "SWIG wrapped code invalid in 64 bit architecture, regenarete code using -DSWIGWORDSIZE64" #endif %} #endif #ifdef SWIGWORDSIZE64 %{ #define SWIGWORDSIZE64 #ifndef LONG_MAX #include #endif #if (__WORDSIZE == 32) || (LONG_MAX == INT_MAX) # error "SWIG wrapped code invalid in 32 bit architecture, regenarete code using -DSWIGWORDSIZE32" #endif %} #endif swig-3.0.2/Lib/uffi/0000775000175000017500000000000012343605122014002 5ustar williamwilliamswig-3.0.2/Lib/uffi/uffi.swg0000664000175000017500000000621612343605122015462 0ustar williamwilliam/* Define a C preprocessor symbol that can be used in interface files to distinguish between the SWIG language modules. */ #define SWIG_UFFI /* Typespecs for basic types. */ %typemap(ffitype) char ":char"; %typemap(ffitype) unsigned char ":unsigned-char"; %typemap(ffitype) signed char ":char"; %typemap(ffitype) short ":short"; %typemap(ffitype) signed short ":short"; %typemap(ffitype) unsigned short ":unsigned-short"; %typemap(ffitype) int ":int"; %typemap(ffitype) signed int ":int"; %typemap(ffitype) unsigned int ":unsigned-int"; %typemap(ffitype) long ":long"; %typemap(ffitype) signed long ":long"; %typemap(ffitype) unsigned long ":unsigned-long"; %typemap(ffitype) float ":float"; %typemap(ffitype) double ":double"; %typemap(ffitype) char * ":cstring"; %typemap(ffitype) void * ":pointer-void"; %typemap(ffitype) void ":void"; // FIXME: This is guesswork typedef long size_t; %wrapper %{ (eval-when (compile eval) ;;; You can define your own identifier converter if you want. ;;; Use the -identifier-converter command line argument to ;;; specify its name. (defun identifier-convert-null (id &key type) (declare (ignore type)) (read-from-string id)) (defun identifier-convert-lispify (cname &key type) (assert (stringp cname)) (if (eq type :constant) (setf cname (format nil "*~A*" cname))) (setf cname (replace-regexp cname "_" "-")) (let ((lastcase :other) newcase char res) (dotimes (n (length cname)) (setf char (schar cname n)) (if* (alpha-char-p char) then (setf newcase (if (upper-case-p char) :upper :lower)) (when (or (and (eq lastcase :upper) (eq newcase :lower)) (and (eq lastcase :lower) (eq newcase :upper))) ;; case change... add a dash (push #\- res) (setf newcase :other)) (push (char-downcase char) res) (setf lastcase newcase) else (push char res) (setf lastcase :other))) (read-from-string (coerce (nreverse res) 'string)))) (defun identifier-convert-low-level (cname &key type) (assert (stringp cname)) (if (eq type :constant) (setf cname (format nil "+~A+" cname))) (setf cname (substitute #\- #\_ cname)) (if (eq type :operator) (setf cname (format nil "%~A" cname))) (if (eq type :constant-function) nil) (read-from-string cname)) (defmacro swig-defconstant (string value &key (export T)) (let ((symbol (funcall *swig-identifier-converter* string :type :constant))) `(eval-when (compile load eval) (uffi:def-constant ,symbol ,value ,export)))) (defmacro swig-defun (name &rest rest) (let ((symbol (funcall *swig-identifier-converter* name :type :operator))) `(eval-when (compile load eval) (uffi:def-function (,name ,symbol) ,@rest) (export (quote ,symbol))))) (defmacro swig-def-struct (name &rest fields) "Declare a struct object" (let ((symbol (funcall *swig-identifier-converter* name :type :type))) `(eval-when (compile load eval) (uffi:def-struct ,symbol ,@fields) (export (quote ,symbol))))) ) ;; eval-when %} swig-3.0.2/Lib/csharp/0000775000175000017500000000000012343605122014331 5ustar williamwilliamswig-3.0.2/Lib/csharp/enumsimple.swg0000664000175000017500000000547312343605122017242 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enumsimple.swg * * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 * and earlier wrapped global enums with constant integers in the module * class. Enums declared within a C++ class were wrapped by constant integers * in the C# proxy class. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(ctype) const enum SWIGTYPE & "int" %typemap(imtype) const enum SWIGTYPE & "int" %typemap(cstype) const enum SWIGTYPE & "int" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin) const enum SWIGTYPE & "$input = $1;" %typemap(csdirectorin) const enum SWIGTYPE & "$iminput" %typemap(csdirectorout) const enum SWIGTYPE & "$cscall" %typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) const enum SWIGTYPE & "$csinput" %typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { int ret = $imcall;$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{ get { int ret = $imcall;$excode return ret; } %} // enum SWIGTYPE typemaps %typemap(ctype) enum SWIGTYPE "int" %typemap(imtype) enum SWIGTYPE "int" %typemap(cstype) enum SWIGTYPE "int" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(csdirectorin) enum SWIGTYPE "$iminput" %typemap(csdirectorout) enum SWIGTYPE "$cscall" %typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) enum SWIGTYPE "$csinput" %typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { int ret = $imcall;$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{ get { int ret = $imcall;$excode return ret; } %} %typemap(csbase) enum SWIGTYPE "" %typemap(csclassmodifiers) enum SWIGTYPE "" %typemap(cscode) enum SWIGTYPE "" %typemap(csimports) enum SWIGTYPE "" %typemap(csinterfaces) enum SWIGTYPE "" %typemap(csbody) enum SWIGTYPE "" %csenum(simple); swig-3.0.2/Lib/csharp/csharphead.swg0000664000175000017500000003754112343605122017167 0ustar williamwilliam/* ----------------------------------------------------------------------------- * csharphead.swg * * Support code for exceptions if the SWIG_CSHARP_NO_EXCEPTION_HELPER is not defined * Support code for strings if the SWIG_CSHARP_NO_STRING_HELPER is not defined * ----------------------------------------------------------------------------- */ %insert(runtime) %{ #include #include #include %} #if !defined(SWIG_CSHARP_NO_EXCEPTION_HELPER) %insert(runtime) %{ /* Support for throwing C# exceptions from C/C++. There are two types: * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */ typedef enum { SWIG_CSharpApplicationException, SWIG_CSharpArithmeticException, SWIG_CSharpDivideByZeroException, SWIG_CSharpIndexOutOfRangeException, SWIG_CSharpInvalidCastException, SWIG_CSharpInvalidOperationException, SWIG_CSharpIOException, SWIG_CSharpNullReferenceException, SWIG_CSharpOutOfMemoryException, SWIG_CSharpOverflowException, SWIG_CSharpSystemException } SWIG_CSharpExceptionCodes; typedef enum { SWIG_CSharpArgumentException, SWIG_CSharpArgumentNullException, SWIG_CSharpArgumentOutOfRangeException } SWIG_CSharpExceptionArgumentCodes; typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *); typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *); typedef struct { SWIG_CSharpExceptionCodes code; SWIG_CSharpExceptionCallback_t callback; } SWIG_CSharpException_t; typedef struct { SWIG_CSharpExceptionArgumentCodes code; SWIG_CSharpExceptionArgumentCallback_t callback; } SWIG_CSharpExceptionArgument_t; static SWIG_CSharpException_t SWIG_csharp_exceptions[] = { { SWIG_CSharpApplicationException, NULL }, { SWIG_CSharpArithmeticException, NULL }, { SWIG_CSharpDivideByZeroException, NULL }, { SWIG_CSharpIndexOutOfRangeException, NULL }, { SWIG_CSharpInvalidCastException, NULL }, { SWIG_CSharpInvalidOperationException, NULL }, { SWIG_CSharpIOException, NULL }, { SWIG_CSharpNullReferenceException, NULL }, { SWIG_CSharpOutOfMemoryException, NULL }, { SWIG_CSharpOverflowException, NULL }, { SWIG_CSharpSystemException, NULL } }; static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { { SWIG_CSharpArgumentException, NULL }, { SWIG_CSharpArgumentNullException, NULL }, { SWIG_CSharpArgumentOutOfRangeException, NULL } }; static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { callback = SWIG_csharp_exceptions[code].callback; } callback(msg); } static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { callback = SWIG_csharp_exceptions_argument[code].callback; } callback(msg, param_name); } %} %insert(runtime) %{ #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_$module( SWIG_CSharpExceptionCallback_t applicationCallback, SWIG_CSharpExceptionCallback_t arithmeticCallback, SWIG_CSharpExceptionCallback_t divideByZeroCallback, SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback, SWIG_CSharpExceptionCallback_t invalidCastCallback, SWIG_CSharpExceptionCallback_t invalidOperationCallback, SWIG_CSharpExceptionCallback_t ioCallback, SWIG_CSharpExceptionCallback_t nullReferenceCallback, SWIG_CSharpExceptionCallback_t outOfMemoryCallback, SWIG_CSharpExceptionCallback_t overflowCallback, SWIG_CSharpExceptionCallback_t systemCallback) { SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback; SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback; SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback; SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback; SWIG_csharp_exceptions[SWIG_CSharpInvalidCastException].callback = invalidCastCallback; SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback; SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback; SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback; SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback; SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback; SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback; } #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module( SWIG_CSharpExceptionArgumentCallback_t argumentCallback, SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback, SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) { SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback; SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback; SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback; } %} %pragma(csharp) imclasscode=%{ protected class SWIGExceptionHelper { public delegate void ExceptionDelegate(string message); public delegate void ExceptionArgumentDelegate(string message, string paramName); static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException); static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException); static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException); static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException); static ExceptionDelegate invalidCastDelegate = new ExceptionDelegate(SetPendingInvalidCastException); static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException); static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException); static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException); static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException); static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException); static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException); static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException); static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException); static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException); [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionCallbacks_$module")] public static extern void SWIGRegisterExceptionCallbacks_$module( ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate); [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_$module")] public static extern void SWIGRegisterExceptionCallbacksArgument_$module( ExceptionArgumentDelegate argumentDelegate, ExceptionArgumentDelegate argumentNullDelegate, ExceptionArgumentDelegate argumentOutOfRangeDelegate); static void SetPendingApplicationException(string message) { SWIGPendingException.Set(new global::System.ApplicationException(message, SWIGPendingException.Retrieve())); } static void SetPendingArithmeticException(string message) { SWIGPendingException.Set(new global::System.ArithmeticException(message, SWIGPendingException.Retrieve())); } static void SetPendingDivideByZeroException(string message) { SWIGPendingException.Set(new global::System.DivideByZeroException(message, SWIGPendingException.Retrieve())); } static void SetPendingIndexOutOfRangeException(string message) { SWIGPendingException.Set(new global::System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve())); } static void SetPendingInvalidCastException(string message) { SWIGPendingException.Set(new global::System.InvalidCastException(message, SWIGPendingException.Retrieve())); } static void SetPendingInvalidOperationException(string message) { SWIGPendingException.Set(new global::System.InvalidOperationException(message, SWIGPendingException.Retrieve())); } static void SetPendingIOException(string message) { SWIGPendingException.Set(new global::System.IO.IOException(message, SWIGPendingException.Retrieve())); } static void SetPendingNullReferenceException(string message) { SWIGPendingException.Set(new global::System.NullReferenceException(message, SWIGPendingException.Retrieve())); } static void SetPendingOutOfMemoryException(string message) { SWIGPendingException.Set(new global::System.OutOfMemoryException(message, SWIGPendingException.Retrieve())); } static void SetPendingOverflowException(string message) { SWIGPendingException.Set(new global::System.OverflowException(message, SWIGPendingException.Retrieve())); } static void SetPendingSystemException(string message) { SWIGPendingException.Set(new global::System.SystemException(message, SWIGPendingException.Retrieve())); } static void SetPendingArgumentException(string message, string paramName) { SWIGPendingException.Set(new global::System.ArgumentException(message, paramName, SWIGPendingException.Retrieve())); } static void SetPendingArgumentNullException(string message, string paramName) { global::System.Exception e = SWIGPendingException.Retrieve(); if (e != null) message = message + " Inner Exception: " + e.Message; SWIGPendingException.Set(new global::System.ArgumentNullException(paramName, message)); } static void SetPendingArgumentOutOfRangeException(string message, string paramName) { global::System.Exception e = SWIGPendingException.Retrieve(); if (e != null) message = message + " Inner Exception: " + e.Message; SWIGPendingException.Set(new global::System.ArgumentOutOfRangeException(paramName, message)); } static SWIGExceptionHelper() { SWIGRegisterExceptionCallbacks_$module( applicationDelegate, arithmeticDelegate, divideByZeroDelegate, indexOutOfRangeDelegate, invalidCastDelegate, invalidOperationDelegate, ioDelegate, nullReferenceDelegate, outOfMemoryDelegate, overflowDelegate, systemDelegate); SWIGRegisterExceptionCallbacksArgument_$module( argumentDelegate, argumentNullDelegate, argumentOutOfRangeDelegate); } } protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper(); public class SWIGPendingException { [global::System.ThreadStatic] private static global::System.Exception pendingException = null; private static int numExceptionsPending = 0; public static bool Pending { get { bool pending = false; if (numExceptionsPending > 0) if (pendingException != null) pending = true; return pending; } } public static void Set(global::System.Exception e) { if (pendingException != null) throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); pendingException = e; lock(typeof($imclassname)) { numExceptionsPending++; } } public static global::System.Exception Retrieve() { global::System.Exception e = null; if (numExceptionsPending > 0) { if (pendingException != null) { e = pendingException; pendingException = null; lock(typeof($imclassname)) { numExceptionsPending--; } } } return e; } } %} #endif // SWIG_CSHARP_NO_EXCEPTION_HELPER #if !defined(SWIG_CSHARP_NO_STRING_HELPER) %insert(runtime) %{ /* Callback for returning strings to C# without leaking memory */ typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *); static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL; %} %pragma(csharp) imclasscode=%{ protected class SWIGStringHelper { public delegate string SWIGStringDelegate(string message); static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString); [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterStringCallback_$module")] public static extern void SWIGRegisterStringCallback_$module(SWIGStringDelegate stringDelegate); static string CreateString(string cString) { return cString; } static SWIGStringHelper() { SWIGRegisterStringCallback_$module(stringDelegate); } } static protected SWIGStringHelper swigStringHelper = new SWIGStringHelper(); %} %insert(runtime) %{ #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_$module(SWIG_CSharpStringHelperCallback callback) { SWIG_csharp_string_callback = callback; } %} #endif // SWIG_CSHARP_NO_STRING_HELPER #if !defined(SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR) // Ensure the class is not marked beforefieldinit %pragma(csharp) imclasscode=%{ static $imclassname() { } %} #endif %insert(runtime) %{ /* Contract support */ #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else %} swig-3.0.2/Lib/csharp/director.swg0000664000175000017500000000222112343605122016663 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that C# proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #if defined(DEBUG_DIRECTOR_OWNED) #include #endif #include #include namespace Swig { /* Director base class - not currently used in C# directors */ class Director { }; /* Base class for director exceptions */ class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(const char *msg) : swig_msg(msg) { } DirectorException(const std::string &msg) : swig_msg(msg) { } virtual ~DirectorException() throw() { } const char *what() const throw() { return swig_msg.c_str(); } }; /* Pure virtual method exception */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) { } }; } swig-3.0.2/Lib/csharp/std_map.i0000664000175000017500000002526712343605122016146 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map< K, T, C > * * The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>. * * Using this wrapper is fairly simple. For example, to create a map from integers to doubles use: * * %include * %template(MapIntDouble) std::map * * Notes: * 1) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with * C++ std::map wrappers. * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ %{ #include #include #include %} /* K is the C++ key type, T is the C++ value type */ %define SWIG_STD_MAP_INTERNAL(K, T, C) %typemap(csinterfaces) std::map< K, T, C > "global::System.IDisposable \n , global::System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n"; %typemap(cscode) std::map %{ public $typemap(cstype, T) this[$typemap(cstype, K) key] { get { return getitem(key); } set { setitem(key, value); } } public bool TryGetValue($typemap(cstype, K) key, out $typemap(cstype, T) value) { if (this.ContainsKey(key)) { value = this[key]; return true; } value = default($typemap(cstype, T)); return false; } public int Count { get { return (int)size(); } } public bool IsReadOnly { get { return false; } } public global::System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys { get { global::System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new global::System.Collections.Generic.List<$typemap(cstype, K)>(); int size = this.Count; if (size > 0) { global::System.IntPtr iter = create_iterator_begin(); for (int i = 0; i < size; i++) { keys.Add(get_next_key(iter)); } destroy_iterator(iter); } return keys; } } public global::System.Collections.Generic.ICollection<$typemap(cstype, T)> Values { get { global::System.Collections.Generic.ICollection<$typemap(cstype, T)> vals = new global::System.Collections.Generic.List<$typemap(cstype, T)>(); foreach (global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> pair in this) { vals.Add(pair.Value); } return vals; } } public void Add(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { Add(item.Key, item.Value); } public bool Remove(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { if (Contains(item)) { return Remove(item.Key); } else { return false; } } public bool Contains(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { if (this[item.Key] == item.Value) { return true; } else { return false; } } public void CopyTo(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array) { CopyTo(array, 0); } public void CopyTo(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array, int arrayIndex) { if (array == null) throw new global::System.ArgumentNullException("array"); if (arrayIndex < 0) throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); if (array.Rank > 1) throw new global::System.ArgumentException("Multi dimensional array.", "array"); if (arrayIndex+this.Count > array.Length) throw new global::System.ArgumentException("Number of elements to copy is too large."); global::System.Collections.Generic.IList<$typemap(cstype, K)> keyList = new global::System.Collections.Generic.List<$typemap(cstype, K)>(this.Keys); for (int i = 0; i < keyList.Count; i++) { $typemap(cstype, K) currentKey = keyList[i]; array.SetValue(new global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, this[currentKey]), arrayIndex+i); } } global::System.Collections.Generic.IEnumerator> global::System.Collections.Generic.IEnumerable>.GetEnumerator() { return new $csclassnameEnumerator(this); } global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return new $csclassnameEnumerator(this); } public $csclassnameEnumerator GetEnumerator() { return new $csclassnameEnumerator(this); } // Type-safe enumerator /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown /// whenever the collection is modified. This has been done for changes in the size of the /// collection but not when one of the elements of the collection is modified as it is a bit /// tricky to detect unmanaged code that modifies the collection under our feet. public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator, global::System.Collections.Generic.IEnumerator> { private $csclassname collectionRef; private global::System.Collections.Generic.IList<$typemap(cstype, K)> keyCollection; private int currentIndex; private object currentObject; private int currentSize; public $csclassnameEnumerator($csclassname collection) { collectionRef = collection; keyCollection = new global::System.Collections.Generic.List<$typemap(cstype, K)>(collection.Keys); currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; } // Type-safe iterator Current public global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> Current { get { if (currentIndex == -1) throw new global::System.InvalidOperationException("Enumeration not started."); if (currentIndex > currentSize - 1) throw new global::System.InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new global::System.InvalidOperationException("Collection modified."); return (global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>)currentObject; } } // Type-unsafe IEnumerator.Current object global::System.Collections.IEnumerator.Current { get { return Current; } } public bool MoveNext() { int size = collectionRef.Count; bool moveOkay = (currentIndex+1 < size) && (size == currentSize); if (moveOkay) { currentIndex++; $typemap(cstype, K) currentKey = keyCollection[currentIndex]; currentObject = new global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, collectionRef[currentKey]); } else { currentObject = null; } return moveOkay; } public void Reset() { currentIndex = -1; currentObject = null; if (collectionRef.Count != currentSize) { throw new global::System.InvalidOperationException("Collection modified."); } } public void Dispose() { currentIndex = -1; currentObject = null; } } %} public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map< K, T, C > &other); size_type size() const; bool empty() const; %rename(Clear) clear; void clear(); %extend { const mapped_type& getitem(const key_type& key) throw (std::out_of_range) { std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) return iter->second; else throw std::out_of_range("key not found"); } void setitem(const key_type& key, const mapped_type& x) { (*$self)[key] = x; } bool ContainsKey(const key_type& key) { std::map< K, T, C >::iterator iter = $self->find(key); return iter != $self->end(); } void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) { std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) throw std::out_of_range("key already exists"); $self->insert(std::pair< K, T >(key, val)); } bool Remove(const key_type& key) { std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) { $self->erase(iter); return true; } return false; } // create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C# %apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *create_iterator_begin } %apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *swigiterator } std::map< K, T, C >::iterator *create_iterator_begin() { return new std::map< K, T, C >::iterator($self->begin()); } const key_type& get_next_key(std::map< K, T, C >::iterator *swigiterator) { std::map< K, T, C >::iterator iter = *swigiterator; (*swigiterator)++; return (*iter).first; } void destroy_iterator(std::map< K, T, C >::iterator *swigiterator) { delete swigiterator; } } %enddef %csmethodmodifiers std::map::size "private" %csmethodmodifiers std::map::getitem "private" %csmethodmodifiers std::map::setitem "private" %csmethodmodifiers std::map::create_iterator_begin "private" %csmethodmodifiers std::map::get_next_key "private" %csmethodmodifiers std::map::destroy_iterator "private" // Default implementation namespace std { template > class map { SWIG_STD_MAP_INTERNAL(K, T, C) }; } // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef swig-3.0.2/Lib/csharp/wchar.i0000664000175000017500000000651112343605122015612 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wchar.i * * Typemaps for the wchar_t type * These are mapped to a C# String and are passed around by value. * * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER * * ----------------------------------------------------------------------------- */ #if !defined(SWIG_CSHARP_NO_WSTRING_HELPER) #if !defined(SWIG_CSHARP_WSTRING_HELPER_) #define SWIG_CSHARP_WSTRING_HELPER_ %insert(runtime) %{ /* Callback for returning strings to C# without leaking memory */ typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *); static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL; %} %pragma(csharp) imclasscode=%{ protected class SWIGWStringHelper { public delegate string SWIGWStringDelegate(global::System.IntPtr message); static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")] public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate); static string CreateWString([global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]global::System.IntPtr cString) { return global::System.Runtime.InteropServices.Marshal.PtrToStringUni(cString); } static SWIGWStringHelper() { SWIGRegisterWStringCallback_$module(wstringDelegate); } } static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper(); %} %insert(runtime) %{ #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) { SWIG_csharp_wstring_callback = callback; } %} #endif // SWIG_CSHARP_WSTRING_HELPER_ #endif // SWIG_CSHARP_NO_WSTRING_HELPER // wchar_t %typemap(ctype) wchar_t "wchar_t" %typemap(imtype) wchar_t "char" %typemap(cstype) wchar_t "char" %typemap(csin) wchar_t "$csinput" %typemap(csout, excode=SWIGEXCODE) wchar_t { char ret = $imcall;$excode return ret; } %typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{ get { char ret = $imcall;$excode return ret; } %} %typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %} %typemap(out) wchar_t %{ $result = (wchar_t)$1; %} %typemap(typecheck) wchar_t = char; // wchar_t * %typemap(ctype) wchar_t * "wchar_t *" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]", out="global::System.IntPtr" ) wchar_t * "string" %typemap(cstype) wchar_t * "string" %typemap(csin) wchar_t * "$csinput" %typemap(csout, excode=SWIGEXCODE) wchar_t * { string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode return ret; } %typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{ get { string ret = $imcall;$excode return ret; } %} %typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %} %typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %} %typemap(typecheck) wchar_t * = char *; swig-3.0.2/Lib/csharp/csharp.swg0000664000175000017500000011535012343605122016340 0ustar williamwilliam/* ----------------------------------------------------------------------------- * csharp.swg * * C# typemaps * ----------------------------------------------------------------------------- */ %include /* The ctype, imtype and cstype typemaps work together and so there should be one of each. * The ctype typemap contains the PInvoke type used in the PInvoke (C/C++) code. * The imtype typemap contains the C# type used in the intermediary class. * The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */ /* SWIG 3 no longer inserts using directives into generated C# code. For backwards compatibility, the SWIG2_CSHARP macro can be defined to have SWIG 3 generate using directives similar to those generated by SWIG 2. */ #ifdef SWIG2_CSHARP %typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing global::System;\nusing global::System.Runtime.InteropServices;\n" %pragma(csharp) moduleimports=%{ using global::System; using global::System.Runtime.InteropServices; %} %pragma(csharp) imclassimports=%{ using global::System; using global::System.Runtime.InteropServices; %} #endif /* Fragments */ %fragment("SWIG_PackData", "header") { /* Pack binary data into a string */ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; const unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } } %fragment("SWIG_UnPackData", "header") { /* Unpack binary data from a string */ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } } /* Primitive types */ %typemap(ctype) bool, const bool & "unsigned int" %typemap(ctype) char, const char & "char" %typemap(ctype) signed char, const signed char & "signed char" %typemap(ctype) unsigned char, const unsigned char & "unsigned char" %typemap(ctype) short, const short & "short" %typemap(ctype) unsigned short, const unsigned short & "unsigned short" %typemap(ctype) int, const int & "int" %typemap(ctype) unsigned int, const unsigned int & "unsigned int" %typemap(ctype) long, const long & "long" %typemap(ctype) unsigned long, const unsigned long & "unsigned long" %typemap(ctype) long long, const long long & "long long" %typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long" %typemap(ctype) float, const float & "float" %typemap(ctype) double, const double & "double" %typemap(ctype) void "void" %typemap(imtype) bool, const bool & "bool" %typemap(imtype) char, const char & "char" %typemap(imtype) signed char, const signed char & "sbyte" %typemap(imtype) unsigned char, const unsigned char & "byte" %typemap(imtype) short, const short & "short" %typemap(imtype) unsigned short, const unsigned short & "ushort" %typemap(imtype) int, const int & "int" %typemap(imtype) unsigned int, const unsigned int & "uint" %typemap(imtype) long, const long & "int" %typemap(imtype) unsigned long, const unsigned long & "uint" %typemap(imtype) long long, const long long & "long" %typemap(imtype) unsigned long long, const unsigned long long & "ulong" %typemap(imtype) float, const float & "float" %typemap(imtype) double, const double & "double" %typemap(imtype) void "void" %typemap(cstype) bool, const bool & "bool" %typemap(cstype) char, const char & "char" %typemap(cstype) signed char, const signed char & "sbyte" %typemap(cstype) unsigned char, const unsigned char & "byte" %typemap(cstype) short, const short & "short" %typemap(cstype) unsigned short, const unsigned short & "ushort" %typemap(cstype) int, const int & "int" %typemap(cstype) unsigned int, const unsigned int & "uint" %typemap(cstype) long, const long & "int" %typemap(cstype) unsigned long, const unsigned long & "uint" %typemap(cstype) long long, const long long & "long" %typemap(cstype) unsigned long long, const unsigned long long & "ulong" %typemap(cstype) float, const float & "float" %typemap(cstype) double, const double & "double" %typemap(cstype) void "void" %typemap(ctype) char *, char *&, char[ANY], char[] "char *" %typemap(imtype) char *, char *&, char[ANY], char[] "string" %typemap(cstype) char *, char *&, char[ANY], char[] "string" /* Non primitive types */ %typemap(ctype) SWIGTYPE "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE "$&csclassname" %typemap(ctype) SWIGTYPE [] "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE [] "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE [] "$csclassname" %typemap(ctype) SWIGTYPE * "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE * "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE * "$csclassname" %typemap(ctype) SWIGTYPE & "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE & "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE & "$csclassname" %typemap(ctype) SWIGTYPE && "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE && "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE && "$csclassname" /* pointer to a class member */ %typemap(ctype) SWIGTYPE (CLASS::*) "char *" %typemap(imtype) SWIGTYPE (CLASS::*) "string" %typemap(cstype) SWIGTYPE (CLASS::*) "$csclassname" /* The following are the in and out typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */ /* primitive types */ %typemap(in) bool %{ $1 = $input ? true : false; %} %typemap(directorout) bool %{ $result = $input ? true : false; %} %typemap(csdirectorin) bool "$iminput" %typemap(csdirectorout) bool "$cscall" %typemap(in) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $1 = ($1_ltype)$input; %} %typemap(directorout) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $result = ($1_ltype)$input; %} %typemap(directorin) bool "$input = $1;" %typemap(directorin) char "$input = $1;" %typemap(directorin) signed char "$input = $1;" %typemap(directorin) unsigned char "$input = $1;" %typemap(directorin) short "$input = $1;" %typemap(directorin) unsigned short "$input = $1;" %typemap(directorin) int "$input = $1;" %typemap(directorin) unsigned int "$input = $1;" %typemap(directorin) long "$input = $1;" %typemap(directorin) unsigned long "$input = $1;" %typemap(directorin) long long "$input = $1;" %typemap(directorin) unsigned long long "$input = $1;" %typemap(directorin) float "$input = $1;" %typemap(directorin) double "$input = $1;" %typemap(csdirectorin) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double "$iminput" %typemap(csdirectorout) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double "$cscall" %typemap(out) bool %{ $result = $1; %} %typemap(out) char %{ $result = $1; %} %typemap(out) signed char %{ $result = $1; %} %typemap(out) unsigned char %{ $result = $1; %} %typemap(out) short %{ $result = $1; %} %typemap(out) unsigned short %{ $result = $1; %} %typemap(out) int %{ $result = $1; %} %typemap(out) unsigned int %{ $result = $1; %} %typemap(out) long %{ $result = $1; %} %typemap(out) unsigned long %{ $result = (unsigned long)$1; %} %typemap(out) long long %{ $result = $1; %} %typemap(out) unsigned long long %{ $result = $1; %} %typemap(out) float %{ $result = $1; %} %typemap(out) double %{ $result = $1; %} /* char * - treat as String */ %typemap(in) char * %{ $1 = ($1_ltype)$input; %} %typemap(out) char * %{ $result = SWIG_csharp_string_callback((const char *)$1); %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %} %typemap(directorin) char * %{ $input = SWIG_csharp_string_callback((const char *)$1); %} %typemap(csdirectorin) char * "$iminput" %typemap(csdirectorout) char * "$cscall" /* char *& - treat as String */ %typemap(in) char *& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) char *& %{ if ($1) $result = SWIG_csharp_string_callback((const char *)*$1); %} %typemap(out, null="") void "" %typemap(csdirectorin) void "$iminput" %typemap(csdirectorout) void "$cscall" %typemap(directorin) void "" /* primitive types by const reference */ %typemap(in) const bool & ($*1_ltype temp) %{ temp = $input ? true : false; $1 = &temp; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool & %{ static $*1_ltype temp; temp = $input ? true : false; $result = &temp; %} %typemap(csdirectorin) const bool & "$iminput" %typemap(csdirectorout) const bool & "$cscall" %typemap(in) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & %{ static $*1_ltype temp; temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin) const bool & "$input = $1;" %typemap(directorin) const char & "$input = $1;" %typemap(directorin) const signed char & "$input = $1;" %typemap(directorin) const unsigned char & "$input = $1;" %typemap(directorin) const short & "$input = $1;" %typemap(directorin) const unsigned short & "$input = $1;" %typemap(directorin) const int & "$input = $1;" %typemap(directorin) const unsigned int & "$input = $1;" %typemap(directorin) const long & "$input = $1;" %typemap(directorin) const unsigned long & "$input = $1;" %typemap(directorin) const long long & "$input = $1;" %typemap(directorin) const unsigned long long & "$input = $1;" %typemap(directorin) const float & "$input = $1;" %typemap(directorin) const double & "$input = $1;" %typemap(csdirectorin) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) "$iminput" %typemap(csdirectorout) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) "$cscall" %typemap(out) const bool & %{ $result = *$1; %} %typemap(out) const char & %{ $result = *$1; %} %typemap(out) const signed char & %{ $result = *$1; %} %typemap(out) const unsigned char & %{ $result = *$1; %} %typemap(out) const short & %{ $result = *$1; %} %typemap(out) const unsigned short & %{ $result = *$1; %} %typemap(out) const int & %{ $result = *$1; %} %typemap(out) const unsigned int & %{ $result = *$1; %} %typemap(out) const long & %{ $result = *$1; %} %typemap(out) const unsigned long & %{ $result = (unsigned long)*$1; %} %typemap(out) const long long & %{ $result = *$1; %} %typemap(out) const unsigned long long & %{ $result = *$1; %} %typemap(out) const float & %{ $result = *$1; %} %typemap(out) const double & %{ $result = *$1; %} /* Default handling. Object passed by value. Convert to a pointer */ %typemap(in, canthrow=1) SWIGTYPE ($&1_type argp) %{ argp = ($&1_ltype)$input; if (!argp) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); return $null; } $1 = *argp; %} %typemap(directorout) SWIGTYPE %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); return $null; } $result = *($&1_ltype)$input; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{ $result = new $1_ltype((const $1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); $result = $1ptr; } #endif %typemap(directorin) SWIGTYPE %{ $input = (void *)&$1; %} %typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, false)" %typemap(csdirectorout) SWIGTYPE "$&csclassname.getCPtr($cscall).Handle" /* Generic pointers and references */ %typemap(in) SWIGTYPE * %{ $1 = ($1_ltype)$input; %} %typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{ SWIG_UnpackData($input, (void *)&$1, sizeof($1)); %} %typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input; if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0); return $null; } %} %typemap(in, canthrow=1) SWIGTYPE && %{ $1 = ($1_ltype)$input; if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0); return $null; } %} %typemap(out) SWIGTYPE * %{ $result = (void *)$1; %} %typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{ char buf[128]; char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1)); *data = '\0'; $result = SWIG_csharp_string_callback(buf); %} %typemap(out) SWIGTYPE & %{ $result = (void *)$1; %} %typemap(out) SWIGTYPE && %{ $result = (void *)$1; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE * %{ $result = ($1_ltype)$input; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*) %{ $result = ($1_ltype)$input; %} %typemap(directorin) SWIGTYPE * %{ $input = (void *) $1; %} %typemap(directorin) SWIGTYPE (CLASS::*) %{ $input = (void *) $1; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); return $null; } $result = ($1_ltype)$input; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE && %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); return $null; } $result = ($1_ltype)$input; %} %typemap(directorin) SWIGTYPE & %{ $input = ($1_ltype) &$1; %} %typemap(directorin) SWIGTYPE && %{ $input = ($1_ltype) &$1; %} %typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == global::System.IntPtr.Zero) ? null : new $csclassname($iminput, false)" %typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)" %typemap(csdirectorin) SWIGTYPE && "new $csclassname($iminput, false)" %typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, SWIGTYPE && "$csclassname.getCPtr($cscall).Handle" /* Default array handling */ %typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %} %typemap(out) SWIGTYPE [] %{ $result = $1; %} /* char arrays - treat as String */ %typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %} %typemap(out) char[ANY], char[] %{ $result = SWIG_csharp_string_callback((const char *)$1); %} %typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %} %typemap(directorin) char[ANY], char[] %{ $input = SWIG_csharp_string_callback((const char *)$1); %} %typemap(csdirectorin) char[ANY], char[] "$iminput" %typemap(csdirectorout) char[ANY], char[] "$cscall" /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */ %typecheck(SWIG_TYPECHECK_BOOL) bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) char, const char & "" %typecheck(SWIG_TYPECHECK_INT8) signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_UINT8) unsigned char, const unsigned char & "" %typecheck(SWIG_TYPECHECK_INT16) short, const short & "" %typecheck(SWIG_TYPECHECK_UINT16) unsigned short, const unsigned short & "" %typecheck(SWIG_TYPECHECK_INT32) int, long, const int &, const long & "" %typecheck(SWIG_TYPECHECK_UINT32) unsigned int, unsigned long, const unsigned int &, const unsigned long & "" %typecheck(SWIG_TYPECHECK_INT64) long long, const long long & "" %typecheck(SWIG_TYPECHECK_UINT64) unsigned long long, const unsigned long long & "" %typecheck(SWIG_TYPECHECK_FLOAT) float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) double, const double & "" %typecheck(SWIG_TYPECHECK_STRING) char *, char *&, char[ANY], char[] "" %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *const&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* Exception handling */ %typemap(throws, canthrow=1) int, long, short, unsigned int, unsigned long, unsigned short %{ char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg); return $null; %} %typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [ANY] %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(throws, canthrow=1) char * %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1); return $null; %} /* Typemaps for code generation in proxy classes and C# type wrapper classes */ /* The csin typemap is used for converting function parameter types from the type * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */ %typemap(csin) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double & "$csinput" %typemap(csin) char *, char *&, char[ANY], char[] "$csinput" %typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)" %typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "$csclassname.getCPtr($csinput)" %typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)" /* The csout typemap is used for converting function return types from the return type * used in the PInvoke class to the type returned by the proxy, module or type wrapper class. * The $excode special variable is replaced by the excode typemap attribute code if the * method can throw any exceptions from unmanaged code, otherwise replaced by nothing. */ // Macro used by the $excode special variable %define SWIGEXCODE "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef %define SWIGEXCODE2 "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef %typemap(csout, excode=SWIGEXCODE) bool, const bool & { bool ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) char, const char & { char ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) signed char, const signed char & { sbyte ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned char, const unsigned char & { byte ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) short, const short & { short ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned short, const unsigned short & { ushort ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) int, const int & { int ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned int, const unsigned int & { uint ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) long, const long & { int ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned long, const unsigned long & { uint ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) long long, const long long & { long ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned long long, const unsigned long long & { ulong ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) float, const float & { float ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) double, const double & { double ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] { string ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) void { $imcall;$excode } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE { $&csclassname ret = new $&csclassname($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE & { $csclassname ret = new $csclassname($imcall, $owner);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE && { $csclassname ret = new $csclassname($imcall, $owner);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE *, SWIGTYPE [] { global::System.IntPtr cPtr = $imcall; $csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) { string cMemberPtr = $imcall; $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode return ret; } /* Properties */ %typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ set { $imcall;$excode } %} %typemap(csvarin, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) bool, const bool & %{ get { bool ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) char, const char & %{ get { char ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) signed char, const signed char & %{ get { sbyte ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned char, const unsigned char & %{ get { byte ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) short, const short & %{ get { short ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned short, const unsigned short & %{ get { ushort ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) int, const int & %{ get { int ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned int, const unsigned int & %{ get { uint ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) long, const long & %{ get { int ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned long, const unsigned long & %{ get { uint ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) long long, const long long & %{ get { long ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned long long, const unsigned long long & %{ get { ulong ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) float, const float & %{ get { float ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) double, const double & %{ get { double ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{ get { string ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) void %{ get { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE %{ get { $&csclassname ret = new $&csclassname($imcall, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE & %{ get { $csclassname ret = new $csclassname($imcall, $owner);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE && %{ get { $csclassname ret = new $csclassname($imcall, $owner);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [] %{ get { global::System.IntPtr cPtr = $imcall; $csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE (CLASS::*) %{ get { string cMemberPtr = $imcall; $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode return ret; } %} /* Pointer reference typemaps */ %typemap(ctype) SWIGTYPE *const& "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE *const& "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE *const& "$*csclassname" %typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)" %typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& { global::System.IntPtr cPtr = $imcall; $*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode return ret; } %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)$input; $1 = ($1_ltype)&temp; %} %typemap(out) SWIGTYPE *const& %{ $result = (void *)*$1; %} /* Marshal C/C++ pointer to global::System.IntPtr */ %typemap(ctype) void *VOID_INT_PTR "void *" %typemap(imtype) void *VOID_INT_PTR "global::System.IntPtr" %typemap(cstype) void *VOID_INT_PTR "global::System.IntPtr" %typemap(in) void *VOID_INT_PTR %{ $1 = ($1_ltype)$input; %} %typemap(out) void *VOID_INT_PTR %{ $result = (void *)$1; %} %typemap(csin) void *VOID_INT_PTR "$csinput" %typemap(csout, excode=SWIGEXCODE) void *VOID_INT_PTR { global::System.IntPtr ret = $imcall;$excode return ret; } /* Typemaps used for the generation of proxy and type wrapper class code */ %typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" %typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csinterfaces) SWIGTYPE "global::System.IDisposable" %typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" // csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users. %define SWIG_CSBODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Proxy classes (base classes, ie, not derived classes) %typemap(csbody) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; protected bool swigCMemOwn; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %enddef %define SWIG_CSBODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Typewrapper classes %typemap(csbody) TYPE *, TYPE &, TYPE &&, TYPE [] %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool futureUse) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } DEFAULTCTOR_VISIBILITY $csclassname() { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csbody) TYPE (CLASS::*) %{ private string swigCMemberPtr; PTRCTOR_VISIBILITY $csclassname(string cMemberPtr, bool futureUse) { swigCMemberPtr = cMemberPtr; } DEFAULTCTOR_VISIBILITY $csclassname() { swigCMemberPtr = null; } CPTR_VISIBILITY static string getCMemberPtr($csclassname obj) { return obj.swigCMemberPtr; } %} %enddef /* Set the default csbody typemaps to use internal visibility. Use the macros to change to public if using multiple modules. */ SWIG_CSBODY_PROXY(internal, internal, SWIGTYPE) SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE) %typemap(csfinalize) SWIGTYPE %{ ~$csclassname() { Dispose(); } %} %typemap(csconstruct, excode=SWIGEXCODE,directorconnect="\n SwigDirectorConnect();") SWIGTYPE %{: this($imcall, true) {$excode$directorconnect } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); base.Dispose(); } } %typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{ protected void $methodname() { swigCMemOwn = false; $imcall; } %} /* C# specific directives */ #define %csconst(flag) %feature("cs:const","flag") #define %csconstvalue(value) %feature("cs:constvalue",value) #define %csenum(wrapapproach) %feature("cs:enum","wrapapproach") #define %csmethodmodifiers %feature("cs:methodmodifiers") #define %csnothrowexception %feature("except") #define %csattributes %feature("cs:attributes") %pragma(csharp) imclassclassmodifiers="class" %pragma(csharp) moduleclassmodifiers="public class" /* Some ANSI C typemaps */ %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* csharp keywords */ %include // Default enum handling %include // For vararg handling in macros, from swigmacros.swg #define %arg(X...) X /* // Alternative char * typemaps. %pragma(csharp) imclasscode=%{ public class SWIGStringMarshal : global::System.IDisposable { public readonly global::System.Runtime.InteropServices.HandleRef swigCPtr; public SWIGStringMarshal(string str) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, global::System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(str)); } public virtual void Dispose() { global::System.Runtime.InteropServices.Marshal.FreeHGlobal(swigCPtr.Handle); global::System.GC.SuppressFinalize(this); } } %} %typemap(imtype, out="global::System.IntPtr") char *, char[ANY], char[] "global::System.Runtime.InteropServices.HandleRef" %typemap(out) char *, char[ANY], char[] %{ $result = $1; %} %typemap(csin) char *, char[ANY], char[] "new $imclassname.SWIGStringMarshal($csinput).swigCPtr" %typemap(csout, excode=SWIGEXCODE) char *, char[ANY], char[] { string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode return ret; } %typemap(csvarin, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ get { string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode return ret; } %} */ swig-3.0.2/Lib/csharp/std_pair.i0000664000175000017500000000127712343605122016317 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T t, U u); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/csharp/typemaps.i0000664000175000017500000002472312343605122016355 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* INPUT typemaps -------------- These typemaps are used for pointer/reference parameters that are input only and are mapped to a C# input parameter. The following typemaps can be applied to turn a pointer or reference into a simple input value. That is, instead of passing a pointer or reference to an object, you would use a real value instead. bool *INPUT, bool &INPUT signed char *INPUT, signed char &INPUT unsigned char *INPUT, unsigned char &INPUT short *INPUT, short &INPUT unsigned short *INPUT, unsigned short &INPUT int *INPUT, int &INPUT unsigned int *INPUT, unsigned int &INPUT long *INPUT, long &INPUT unsigned long *INPUT, unsigned long &INPUT long long *INPUT, long long &INPUT unsigned long long *INPUT, unsigned long long &INPUT float *INPUT, float &INPUT double *INPUT, double &INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); In C# you could then use it like this: double answer = modulename.fadd(10.0, 20.0); */ %define INPUT_TYPEMAP(TYPE, CTYPE, CSTYPE) %typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE" %typemap(imtype, out="global::System.IntPtr") TYPE *INPUT, TYPE &INPUT "CSTYPE" %typemap(cstype, out="$csclassname") TYPE *INPUT, TYPE &INPUT "CSTYPE" %typemap(csin) TYPE *INPUT, TYPE &INPUT "$csinput" %typemap(in) TYPE *INPUT, TYPE &INPUT %{ $1 = ($1_ltype)&$input; %} %typemap(typecheck) TYPE *INPUT = TYPE; %typemap(typecheck) TYPE &INPUT = TYPE; %enddef INPUT_TYPEMAP(bool, unsigned int, bool) //INPUT_TYPEMAP(char, char, char) INPUT_TYPEMAP(signed char, signed char, sbyte) INPUT_TYPEMAP(unsigned char, unsigned char, byte) INPUT_TYPEMAP(short, short, short) INPUT_TYPEMAP(unsigned short, unsigned short, ushort) INPUT_TYPEMAP(int, int, int) INPUT_TYPEMAP(unsigned int, unsigned int, uint) INPUT_TYPEMAP(long, long, int) INPUT_TYPEMAP(unsigned long, unsigned long, uint) INPUT_TYPEMAP(long long, long long, long) INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong) INPUT_TYPEMAP(float, float, float) INPUT_TYPEMAP(double, double, double) #undef INPUT_TYPEMAP /* OUTPUT typemaps --------------- These typemaps are used for pointer/reference parameters that are output only and are mapped to a C# output parameter. The following typemaps can be applied to turn a pointer or reference into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In C#, the 'out' keyword is used when passing the parameter to a function that takes an output parameter. bool *OUTPUT, bool &OUTPUT signed char *OUTPUT, signed char &OUTPUT unsigned char *OUTPUT, unsigned char &OUTPUT short *OUTPUT, short &OUTPUT unsigned short *OUTPUT, unsigned short &OUTPUT int *OUTPUT, int &OUTPUT unsigned int *OUTPUT, unsigned int &OUTPUT long *OUTPUT, long &OUTPUT unsigned long *OUTPUT, unsigned long &OUTPUT long long *OUTPUT, long long &OUTPUT unsigned long long *OUTPUT, unsigned long long &OUTPUT float *OUTPUT, float &OUTPUT double *OUTPUT, double &OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters): double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The C# output of the function would be the function return value and the value returned in the second output parameter. In C# you would use it like this: double dptr; double fraction = modulename.modf(5, out dptr); */ %define OUTPUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE) %typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *" %typemap(imtype, out="global::System.IntPtr") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE" %typemap(cstype, out="$csclassname") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE" %typemap(csin) TYPE *OUTPUT, TYPE &OUTPUT "out $csinput" %typemap(in) TYPE *OUTPUT, TYPE &OUTPUT %{ $1 = ($1_ltype)$input; %} %typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *OUTPUT, TYPE &OUTPUT "" %enddef OUTPUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) //OUTPUT_TYPEMAP(char, char, char, CHAR_PTR) OUTPUT_TYPEMAP(signed char, signed char, sbyte, INT8_PTR) OUTPUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR) OUTPUT_TYPEMAP(short, short, short, INT16_PTR) OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) OUTPUT_TYPEMAP(int, int, int, INT32_PTR) OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) OUTPUT_TYPEMAP(long, long, int, INT32_PTR) OUTPUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR) OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR) OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR) OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR) #undef OUTPUT_TYPEMAP %typemap(in) bool *OUTPUT, bool &OUTPUT %{ *$input = 0; $1 = ($1_ltype)$input; %} /* INOUT typemaps -------------- These typemaps are for pointer/reference parameters that are both input and output and are mapped to a C# reference parameter. The following typemaps can be applied to turn a pointer or reference into a reference parameters, that is the parameter is both an input and an output. In C#, the 'ref' keyword is used for reference parameters. bool *INOUT, bool &INOUT signed char *INOUT, signed char &INOUT unsigned char *INOUT, unsigned char &INOUT short *INOUT, short &INOUT unsigned short *INOUT, unsigned short &INOUT int *INOUT, int &INOUT unsigned int *INOUT, unsigned int &INOUT long *INOUT, long &INOUT unsigned long *INOUT, unsigned long &INOUT long long *INOUT, long long &INOUT unsigned long long *INOUT, unsigned long long &INOUT float *INOUT, float &INOUT double *INOUT, double &INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); The C# output of the function would be the new value returned by the reference parameter. In C# you would use it like this: double x = 5.0; neg(ref x); The implementation of the OUTPUT and INOUT typemaps is different to the scripting languages in that the scripting languages will return the output value as part of the function return value. */ %define INOUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE) %typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *" %typemap(imtype, out="global::System.IntPtr") TYPE *INOUT, TYPE &INOUT "ref CSTYPE" %typemap(cstype, out="$csclassname") TYPE *INOUT, TYPE &INOUT "ref CSTYPE" %typemap(csin) TYPE *INOUT, TYPE &INOUT "ref $csinput" %typemap(in) TYPE *INOUT, TYPE &INOUT %{ $1 = ($1_ltype)$input; %} %typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *INOUT, TYPE &INOUT "" %enddef INOUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) //INOUT_TYPEMAP(char, char, char, CHAR_PTR) INOUT_TYPEMAP(signed char, signed char, sbyte, INT8_PTR) INOUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR) INOUT_TYPEMAP(short, short, short, INT16_PTR) INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) INOUT_TYPEMAP(int, int, int, INT32_PTR) INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) INOUT_TYPEMAP(long, long, int, INT32_PTR) INOUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR) INOUT_TYPEMAP(long long, long long, long, INT64_PTR) INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) INOUT_TYPEMAP(float, float, float, FLOAT_PTR) INOUT_TYPEMAP(double, double, double, DOUBLE_PTR) #undef INOUT_TYPEMAP swig-3.0.2/Lib/csharp/boost_shared_ptr.i0000664000175000017500000002604312343605122020051 0ustar williamwilliam// Users can provide their own SWIG_SHARED_PTR_TYPEMAPS macro before including this file to change the // visibility of the constructor and getCPtr method if desired to public if using multiple modules. #ifndef SWIG_SHARED_PTR_TYPEMAPS #define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE) #endif %include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{ argp = ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0; if (!argp) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ $result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in, canthrow=1) CONST TYPE & %{ $1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = (TYPE *)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ if ($input) $1 = *($&1_ltype)$input; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ $result = $1 ? new $1_ltype($1) : 0; %} // shared_ptr by reference %typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) %{ $1 = $input ? ($1_ltype)$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ $result = *$1 ? new $*1_ltype(*$1) : 0; %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) %{ $1 = $input ? ($1_ltype)$input : &tempnull; %} %typemap(out, fragment="SWIG_null_deleter") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ $result = ($1 && *$1) ? new $*1_ltype(*($1_ltype)$1) : 0; if ($owner) delete $1; %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0) %{ temp = $input ? *($1_ltype)&$input : &tempnull; $1 = &temp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void *" %typemap (imtype, out="global::System.IntPtr") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef" %typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)" %typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)" %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE & { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE * { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) CONST TYPE & %{ get { $csclassname ret = new $csclassname($imcall, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) CONST TYPE * %{ get { global::System.IntPtr cPtr = $imcall; $csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ get { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ get { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %} // Proxy classes (base classes, ie, not derived classes) %typemap(csbody) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnBase; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnDerived; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); base.Dispose(); } } %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.2/Lib/csharp/swigtype_inout.i0000664000175000017500000000267612343605122017607 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigtype_inout.i * * Pointer pointer and pointer reference handling typemap library for non-primitive types * * These mappings provide support for input/output arguments and common * uses for C/C++ pointer references and pointer to pointers. * * These are named typemaps (OUTPUT) and can be used like any named typemap. * Alternatively they can be made the default by using %apply: * %apply SWIGTYPE *& OUTPUT { SWIGTYPE *& } * ----------------------------------------------------------------------------- */ /* * OUTPUT typemaps. Example usage wrapping: * * void f(XXX *& x) { x = new XXX(111); } * * would be: * * XXX x = null; * f(out x); * // use x * x.Dispose(); // manually clear memory or otherwise leave out and leave it to the garbage collector */ %typemap(ctype) SWIGTYPE *& OUTPUT "void **" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE *& OUTPUT "out global::System.IntPtr" %typemap(cstype) SWIGTYPE *& OUTPUT "out $*csclassname" %typemap(csin, pre=" global::System.IntPtr cPtr_$csinput = global::System.IntPtr.Zero;", post=" $csinput = (cPtr_$csinput == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr_$csinput, true);", cshin="out $csinput") SWIGTYPE *& OUTPUT "out cPtr_$csinput" %typemap(in) SWIGTYPE *& OUTPUT %{ $1 = ($1_ltype)$input; %} %typemap(freearg) SWIGTYPE *& OUTPUT "" swig-3.0.2/Lib/csharp/std_common.i0000664000175000017500000000014612343605122016646 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.2/Lib/csharp/enums.swg0000664000175000017500000000556412343605122016214 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enums.swg * * Include this file in order for C/C++ enums to be wrapped by proper C# enums. * Note that the PINVOKE layer handles the enum as an int. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(ctype) const enum SWIGTYPE & "int" %typemap(imtype) const enum SWIGTYPE & "int" %typemap(cstype) const enum SWIGTYPE & "$*csclassname" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin) const enum SWIGTYPE & "$input = $1;" %typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput" %typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall" %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) const enum SWIGTYPE & "(int)$csinput" %typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { $*csclassname ret = ($*csclassname)$imcall;$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{ get { $*csclassname ret = ($*csclassname)$imcall;$excode return ret; } %} // enum SWIGTYPE typemaps %typemap(ctype) enum SWIGTYPE "int" %typemap(imtype) enum SWIGTYPE "int" %typemap(cstype) enum SWIGTYPE "$csclassname" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput" %typemap(csdirectorout) enum SWIGTYPE "(int)$cscall" %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) enum SWIGTYPE "(int)$csinput" %typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { $csclassname ret = ($csclassname)$imcall;$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{ get { $csclassname ret = ($csclassname)$imcall;$excode return ret; } %} %typemap(csbase) enum SWIGTYPE "" %typemap(csclassmodifiers) enum SWIGTYPE "public enum" %typemap(cscode) enum SWIGTYPE "" %typemap(csimports) enum SWIGTYPE "" %typemap(csinterfaces) enum SWIGTYPE "" %typemap(csbody) enum SWIGTYPE "" %csenum(proper); swig-3.0.2/Lib/csharp/arrays_csharp.i0000664000175000017500000001242612343605122017351 0ustar williamwilliam/* ----------------------------------------------------------------------------- * arrays_csharp.i * * This file contains a two approaches to marshaling arrays. The first uses * default p/invoke marshaling and the second uses pinning of the arrays. * * Default marshaling approach * ---------------------------- * Array typemaps using default p/invoke marshaling. The data is copied to a separately * allocated buffer when passing over the managed-native boundary. * * There are separate typemaps for in, out and inout arrays to enable avoiding * unnecessary copying. * * Example usage: * * %include "arrays_csharp.i" * %apply int INPUT[] { int* sourceArray } * %apply int OUTPUT[] { int* targetArray } * void myArrayCopy( int* sourceArray, int* targetArray, int nitems ); * * %apply int INOUT[] { int* array1, int *array2 } * void myArraySwap( int* array1, int* array2, int nitems ); * * If handling large arrays you should consider using the pinning array typemaps * described next. * * Pinning approach * ---------------- * Array typemaps using pinning. These typemaps pin the managed array given * as parameter and pass a pointer to it to the c/c++ side. This is very * efficient as no copying is done (unlike in the default array marshaling), * but it makes garbage collection more difficult. When considering using * these typemaps, think carefully whether you have callbacks that may cause * the control to re-enter the managed side from within the call (and produce * garbage for the gc) or whether other threads may produce enough garbage to * trigger gc while the call is being executed. In those cases it may be * wiser to use the default marshaling typemaps. * * Please note that when using fixed arrays, you have to mark your corresponding * module class method unsafe using * %csmethodmodifiers "public unsafe" * (the visibility of the method is up to you). * * Example usage: * * %include "arrays_csharp.i" * %apply int FIXED[] { int* sourceArray, int *targetArray } * %csmethodmodifiers myArrayCopy "public unsafe"; * void myArrayCopy( int *sourceArray, int* targetArray, int nitems ); * * ----------------------------------------------------------------------------- */ %define CSHARP_ARRAYS( CTYPE, CSTYPE ) // input only arrays %typemap(ctype) CTYPE INPUT[] "CTYPE*" %typemap(cstype) CTYPE INPUT[] "CSTYPE[]" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE INPUT[] "CSTYPE[]" %typemap(csin) CTYPE INPUT[] "$csinput" %typemap(in) CTYPE INPUT[] "$1 = $input;" %typemap(freearg) CTYPE INPUT[] "" %typemap(argout) CTYPE INPUT[] "" // output only arrays %typemap(ctype) CTYPE OUTPUT[] "CTYPE*" %typemap(cstype) CTYPE OUTPUT[] "CSTYPE[]" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE OUTPUT[] "CSTYPE[]" %typemap(csin) CTYPE OUTPUT[] "$csinput" %typemap(in) CTYPE OUTPUT[] "$1 = $input;" %typemap(freearg) CTYPE OUTPUT[] "" %typemap(argout) CTYPE OUTPUT[] "" // inout arrays %typemap(ctype) CTYPE INOUT[] "CTYPE*" %typemap(cstype) CTYPE INOUT[] "CSTYPE[]" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE INOUT[] "CSTYPE[]" %typemap(csin) CTYPE INOUT[] "$csinput" %typemap(in) CTYPE INOUT[] "$1 = $input;" %typemap(freearg) CTYPE INOUT[] "" %typemap(argout) CTYPE INOUT[] "" %enddef // CSHARP_ARRAYS CSHARP_ARRAYS(signed char, sbyte) CSHARP_ARRAYS(unsigned char, byte) CSHARP_ARRAYS(short, short) CSHARP_ARRAYS(unsigned short, ushort) CSHARP_ARRAYS(int, int) CSHARP_ARRAYS(unsigned int, uint) // FIXME - on Unix 64 bit, long is 8 bytes but is 4 bytes on Windows 64 bit. // How can this be handled sensibly? // See e.g. http://www.xml.com/ldd/chapter/book/ch10.html CSHARP_ARRAYS(long, int) CSHARP_ARRAYS(unsigned long, uint) CSHARP_ARRAYS(long long, long) CSHARP_ARRAYS(unsigned long long, ulong) CSHARP_ARRAYS(float, float) CSHARP_ARRAYS(double, double) %define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE ) %typemap(ctype) CTYPE FIXED[] "CTYPE*" %typemap(imtype) CTYPE FIXED[] "global::System.IntPtr" %typemap(cstype) CTYPE FIXED[] "CSTYPE[]" %typemap(csin, pre= " fixed ( CSTYPE* swig_ptrTo_$csinput = $csinput ) {", terminator=" }") CTYPE FIXED[] "(global::System.IntPtr)swig_ptrTo_$csinput" %typemap(in) CTYPE FIXED[] "$1 = $input;" %typemap(freearg) CTYPE FIXED[] "" %typemap(argout) CTYPE FIXED[] "" %enddef // CSHARP_ARRAYS_FIXED CSHARP_ARRAYS_FIXED(signed char, sbyte) CSHARP_ARRAYS_FIXED(unsigned char, byte) CSHARP_ARRAYS_FIXED(short, short) CSHARP_ARRAYS_FIXED(unsigned short, ushort) CSHARP_ARRAYS_FIXED(int, int) CSHARP_ARRAYS_FIXED(unsigned int, uint) CSHARP_ARRAYS_FIXED(long, int) CSHARP_ARRAYS_FIXED(unsigned long, uint) CSHARP_ARRAYS_FIXED(long long, long) CSHARP_ARRAYS_FIXED(unsigned long long, ulong) CSHARP_ARRAYS_FIXED(float, float) CSHARP_ARRAYS_FIXED(double, double) swig-3.0.2/Lib/csharp/std_shared_ptr.i0000664000175000017500000000010412343605122017503 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.2/Lib/csharp/std_auto_ptr.i0000664000175000017500000000164012343605122017213 0ustar williamwilliam/* The typemaps here allow to handle functions returning std::auto_ptr<>, which is the most common use of this type. If you have functions taking it as parameter, these typemaps can't be used for them and you need to do something else (e.g. use shared_ptr<> which SWIG supports fully). */ %define %auto_ptr(TYPE) %typemap (ctype) std::auto_ptr "void *" %typemap (imtype, out="System.IntPtr") std::auto_ptr "HandleRef" %typemap (cstype) std::auto_ptr "$typemap(cstype, TYPE)" %typemap (out) std::auto_ptr %{ $result = (void *)$1.release(); %} %typemap(csout, excode=SWIGEXCODE) std::auto_ptr { System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %template() std::auto_ptr; %enddef namespace std { template class auto_ptr {}; } swig-3.0.2/Lib/csharp/enumtypesafe.swg0000664000175000017500000001126412343605122017564 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enumtypesafe.swg * * Include this file in order for C/C++ enums to be wrapped by the so called * typesafe enum pattern. Each enum has an equivalent C# class named after the * enum and each enum item is a static instance of this class. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(ctype) const enum SWIGTYPE & "int" %typemap(imtype) const enum SWIGTYPE & "int" %typemap(cstype) const enum SWIGTYPE & "$*csclassname" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin) const enum SWIGTYPE & "$input = $1;" %typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)" %typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue" %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) const enum SWIGTYPE & "$csinput.swigValue" %typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { $*csclassname ret = $*csclassname.swigToEnum($imcall);$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{ get { $*csclassname ret = $*csclassname.swigToEnum($imcall);$excode return ret; } %} // enum SWIGTYPE typemaps %typemap(ctype) enum SWIGTYPE "int" %typemap(imtype) enum SWIGTYPE "int" %typemap(cstype) enum SWIGTYPE "$csclassname" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)" %typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue" %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) enum SWIGTYPE "$csinput.swigValue" %typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { $csclassname ret = $csclassname.swigToEnum($imcall);$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{ get { $csclassname ret = $csclassname.swigToEnum($imcall);$excode return ret; } %} %typemap(csbase) enum SWIGTYPE "" %typemap(csclassmodifiers) enum SWIGTYPE "public sealed class" %typemap(cscode) enum SWIGTYPE "" %typemap(csimports) enum SWIGTYPE "" %typemap(csinterfaces) enum SWIGTYPE "" /* * The swigToEnum method is used to find the C# enum from a C++ enum integer value. The default one here takes * advantage of the fact that most enums do not have initial values specified, so the lookup is fast. If initial * values are specified then a lengthy linear search through all possible enums might occur. Specific typemaps could be * written to possibly optimise this lookup by taking advantage of characteristics peculiar to the targeted enum. * The special variable, $enumvalues, is replaced with a comma separated list of all the enum values. */ %typemap(csbody) enum SWIGTYPE %{ public readonly int swigValue; public static $csclassname swigToEnum(int swigValue) { if (swigValue < swigValues.Length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) return swigValues[swigValue]; for (int i = 0; i < swigValues.Length; i++) if (swigValues[i].swigValue == swigValue) return swigValues[i]; throw new global::System.ArgumentOutOfRangeException("No enum $csclassname with value " + swigValue); } public override string ToString() { return swigName; } private $csclassname(string swigName) { this.swigName = swigName; this.swigValue = swigNext++; } private $csclassname(string swigName, int swigValue) { this.swigName = swigName; this.swigValue = swigValue; swigNext = swigValue+1; } private $csclassname(string swigName, $csclassname swigEnum) { this.swigName = swigName; this.swigValue = swigEnum.swigValue; swigNext = this.swigValue+1; } private static $csclassname[] swigValues = { $enumvalues }; private static int swigNext = 0; private readonly string swigName; %} %csenum(typesafe); swig-3.0.2/Lib/csharp/std_vector.i0000664000175000017500000003410212343605122016657 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector * C# implementation * The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection. * * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with * C++ std::vector wrappers. The IList<> interface is also implemented to provide enhanced functionality * whenever we are confident that the required C++ operator== is available. This is the case for when * T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED * macro to obtain this enhanced functionality, for example: * * SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass) * %template(VectKlass) std::vector; * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ // Warning: Use the typemaps here in the expectation that the macros they are in will change name. %include // MACRO for use within the std::vector class body %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...) %typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable\n , global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n"; %typemap(cscode) std::vector< CTYPE > %{ public $csclassname(global::System.Collections.ICollection c) : this() { if (c == null) throw new global::System.ArgumentNullException("c"); foreach ($typemap(cstype, CTYPE) element in c) { this.Add(element); } } public bool IsFixedSize { get { return false; } } public bool IsReadOnly { get { return false; } } public $typemap(cstype, CTYPE) this[int index] { get { return getitem(index); } set { setitem(index, value); } } public int Capacity { get { return (int)capacity(); } set { if (value < size()) throw new global::System.ArgumentOutOfRangeException("Capacity"); reserve((uint)value); } } public int Count { get { return (int)size(); } } public bool IsSynchronized { get { return false; } } public void CopyTo($typemap(cstype, CTYPE)[] array) { CopyTo(0, array, 0, this.Count); } public void CopyTo($typemap(cstype, CTYPE)[] array, int arrayIndex) { CopyTo(0, array, arrayIndex, this.Count); } public void CopyTo(int index, $typemap(cstype, CTYPE)[] array, int arrayIndex, int count) { if (array == null) throw new global::System.ArgumentNullException("array"); if (index < 0) throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero"); if (arrayIndex < 0) throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); if (count < 0) throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero"); if (array.Rank > 1) throw new global::System.ArgumentException("Multi dimensional array.", "array"); if (index+count > this.Count || arrayIndex+count > array.Length) throw new global::System.ArgumentException("Number of elements to copy is too large."); for (int i=0; i global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() { return new $csclassnameEnumerator(this); } global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return new $csclassnameEnumerator(this); } public $csclassnameEnumerator GetEnumerator() { return new $csclassnameEnumerator(this); } // Type-safe enumerator /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown /// whenever the collection is modified. This has been done for changes in the size of the /// collection but not when one of the elements of the collection is modified as it is a bit /// tricky to detect unmanaged code that modifies the collection under our feet. public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator , global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> { private $csclassname collectionRef; private int currentIndex; private object currentObject; private int currentSize; public $csclassnameEnumerator($csclassname collection) { collectionRef = collection; currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; } // Type-safe iterator Current public $typemap(cstype, CTYPE) Current { get { if (currentIndex == -1) throw new global::System.InvalidOperationException("Enumeration not started."); if (currentIndex > currentSize - 1) throw new global::System.InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new global::System.InvalidOperationException("Collection modified."); return ($typemap(cstype, CTYPE))currentObject; } } // Type-unsafe IEnumerator.Current object global::System.Collections.IEnumerator.Current { get { return Current; } } public bool MoveNext() { int size = collectionRef.Count; bool moveOkay = (currentIndex+1 < size) && (size == currentSize); if (moveOkay) { currentIndex++; currentObject = collectionRef[currentIndex]; } else { currentObject = null; } return moveOkay; } public void Reset() { currentIndex = -1; currentObject = null; if (collectionRef.Count != currentSize) { throw new global::System.InvalidOperationException("Collection modified."); } } public void Dispose() { currentIndex = -1; currentObject = null; } } %} public: typedef size_t size_type; typedef CTYPE value_type; typedef CONST_REFERENCE const_reference; %rename(Clear) clear; void clear(); %rename(Add) push_back; void push_back(CTYPE const& x); size_type size() const; size_type capacity() const; void reserve(size_type n); %newobject GetRange(int index, int count); %newobject Repeat(CTYPE const& value, int count); vector(); vector(const vector &other); %extend { vector(int capacity) throw (std::out_of_range) { std::vector< CTYPE >* pv = 0; if (capacity >= 0) { pv = new std::vector< CTYPE >(); pv->reserve(capacity); } else { throw std::out_of_range("capacity"); } return pv; } CTYPE getitemcopy(int index) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) return (*$self)[index]; else throw std::out_of_range("index"); } CONST_REFERENCE getitem(int index) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) return (*$self)[index]; else throw std::out_of_range("index"); } void setitem(int index, CTYPE const& val) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) (*$self)[index] = val; else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.AddRange void AddRange(const std::vector< CTYPE >& values) { $self->insert($self->end(), values.begin(), values.end()); } // Takes a deep copy of the elements unlike ArrayList.GetRange std::vector< CTYPE > *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) { if (index < 0) throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); return new std::vector< CTYPE >($self->begin()+index, $self->begin()+index+count); } void Insert(int index, CTYPE const& x) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()+1) $self->insert($self->begin()+index, x); else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.InsertRange void InsertRange(int index, const std::vector< CTYPE >& values) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()+1) $self->insert($self->begin()+index, values.begin(), values.end()); else throw std::out_of_range("index"); } void RemoveAt(int index) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) $self->erase($self->begin() + index); else throw std::out_of_range("index"); } void RemoveRange(int index, int count) throw (std::out_of_range, std::invalid_argument) { if (index < 0) throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); $self->erase($self->begin()+index, $self->begin()+index+count); } static std::vector< CTYPE > *Repeat(CTYPE const& value, int count) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("count"); return new std::vector< CTYPE >(count, value); } void Reverse() { std::reverse($self->begin(), $self->end()); } void Reverse(int index, int count) throw (std::out_of_range, std::invalid_argument) { if (index < 0) throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); std::reverse($self->begin()+index, $self->begin()+index+count); } // Takes a deep copy of the elements unlike ArrayList.SetRange void SetRange(int index, const std::vector< CTYPE >& values) throw (std::out_of_range) { if (index < 0) throw std::out_of_range("index"); if (index+values.size() > $self->size()) throw std::out_of_range("index"); std::copy(values.begin(), values.end(), $self->begin()+index); } } %enddef // Extra methods added to the collection class if operator== is defined for the class being wrapped // The class will then implement IList<>, which adds extra functionality %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...) %extend { bool Contains(CTYPE const& value) { return std::find($self->begin(), $self->end(), value) != $self->end(); } int IndexOf(CTYPE const& value) { int index = -1; std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value); if (it != $self->end()) index = (int)(it - $self->begin()); return index; } int LastIndexOf(CTYPE const& value) { int index = -1; std::vector< CTYPE >::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value); if (rit != $self->rend()) index = (int)($self->rend() - 1 - rit); return index; } bool Remove(CTYPE const& value) { std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value); if (it != $self->end()) { $self->erase(it); return true; } return false; } } %enddef // Macros for std::vector class specializations/enhancements %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector< CTYPE > { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, %arg(CTYPE const&), %arg(CTYPE)) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } %enddef // Legacy macros %define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) #warning SWIG_STD_VECTOR_SPECIALIZE macro deprecated, please see csharp/std_vector.i and switch to SWIG_STD_VECTOR_ENHANCED SWIG_STD_VECTOR_ENHANCED(CTYPE) %enddef %define SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE...) #warning SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro deprecated, it is no longer required %enddef %{ #include #include #include %} %csmethodmodifiers std::vector::getitemcopy "private" %csmethodmodifiers std::vector::getitem "private" %csmethodmodifiers std::vector::setitem "private" %csmethodmodifiers std::vector::size "private" %csmethodmodifiers std::vector::capacity "private" %csmethodmodifiers std::vector::reserve "private" namespace std { // primary (unspecialized) class template for std::vector // does not require operator== to be defined template class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, T const&, T) }; // specialization for pointers template class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *) }; // bool is specialized in the C++ standard - const_reference in particular template<> class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool) }; } // template specializations for std::vector // these provide extra collections methods as operator== is defined SWIG_STD_VECTOR_ENHANCED(char) SWIG_STD_VECTOR_ENHANCED(signed char) SWIG_STD_VECTOR_ENHANCED(unsigned char) SWIG_STD_VECTOR_ENHANCED(short) SWIG_STD_VECTOR_ENHANCED(unsigned short) SWIG_STD_VECTOR_ENHANCED(int) SWIG_STD_VECTOR_ENHANCED(unsigned int) SWIG_STD_VECTOR_ENHANCED(long) SWIG_STD_VECTOR_ENHANCED(unsigned long) SWIG_STD_VECTOR_ENHANCED(long long) SWIG_STD_VECTOR_ENHANCED(unsigned long long) SWIG_STD_VECTOR_ENHANCED(float) SWIG_STD_VECTOR_ENHANCED(double) SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include swig-3.0.2/Lib/csharp/std_string.i0000664000175000017500000000614712343605122016673 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * Typemaps for std::string and const std::string& * These are mapped to a C# String and are passed around by value. * * To use non-const std::string references use the following %apply. Note * that they are passed by value. * %apply const std::string & {std::string &}; * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; class string; // string %typemap(ctype) string "char *" %typemap(imtype) string "string" %typemap(cstype) string "string" %typemap(csdirectorin) string "$iminput" %typemap(csdirectorout) string "$cscall" %typemap(in, canthrow=1) string %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; } $1.assign($input); %} %typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %} %typemap(directorout, canthrow=1) string %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; } $result.assign($input); %} %typemap(directorin) string %{ $input = SWIG_csharp_string_callback($1.c_str()); %} %typemap(csin) string "$csinput" %typemap(csout, excode=SWIGEXCODE) string { string ret = $imcall;$excode return ret; } %typemap(typecheck) string = char *; %typemap(throws, canthrow=1) string %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); return $null; %} // const string & %typemap(ctype) const string & "char *" %typemap(imtype) const string & "string" %typemap(cstype) const string & "string" %typemap(csdirectorin) const string & "$iminput" %typemap(csdirectorout) const string & "$cscall" %typemap(in, canthrow=1) const string & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; } $*1_ltype $1_str($input); $1 = &$1_str; %} %typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %} %typemap(csin) const string & "$csinput" %typemap(csout, excode=SWIGEXCODE) const string & { string ret = $imcall;$excode return ret; } %typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; } /* possible thread/reentrant code problem */ static $*1_ltype $1_str; $1_str = $input; $result = &$1_str; %} %typemap(directorin) const string & %{ $input = SWIG_csharp_string_callback($1.c_str()); %} %typemap(csvarin, excode=SWIGEXCODE2) const string & %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) const string & %{ get { string ret = $imcall;$excode return ret; } %} %typemap(typecheck) const string & = char *; %typemap(throws, canthrow=1) const string & %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); return $null; %} } swig-3.0.2/Lib/csharp/csharpkw.swg0000664000175000017500000000350212343605122016675 0ustar williamwilliam#ifndef CSHARP_CSHARPKW_SWG_ #define CSHARP_CSHARPKW_SWG_ /* Warnings for C# keywords */ #define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x` #define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes, class renamed to '_" `x` "'",%$isclass,rename="_%s") `x` /* from http://www.jaggersoft.com/csharp_grammar.html#1.7%20Keywords */ CSHARPKW(abstract); CSHARPKW(as); CSHARPKW(base); CSHARPKW(bool); CSHARPKW(break); CSHARPKW(byte); CSHARPKW(case); CSHARPKW(catch); CSHARPKW(char); CSHARPKW(checked); CSHARPKW(class); CSHARPKW(const); CSHARPKW(continue); CSHARPKW(decimal); CSHARPKW(default); CSHARPKW(delegate); CSHARPKW(do); CSHARPKW(double); CSHARPKW(else); CSHARPKW(enum); CSHARPKW(event); CSHARPKW(explicit); CSHARPKW(extern); CSHARPKW(false); CSHARPKW(finally); CSHARPKW(fixed); CSHARPKW(float); CSHARPKW(for); CSHARPKW(foreach); CSHARPKW(goto); CSHARPKW(if); CSHARPKW(implicit); CSHARPKW(in); CSHARPKW(int); CSHARPKW(interface); CSHARPKW(internal); CSHARPKW(is); CSHARPKW(lock); CSHARPKW(long); CSHARPKW(namespace); CSHARPKW(new); CSHARPKW(null); CSHARPKW(object); CSHARPKW(operator); CSHARPKW(out); CSHARPKW(override); CSHARPKW(params); CSHARPKW(private); CSHARPKW(protected); CSHARPKW(public); CSHARPKW(readonly); CSHARPKW(ref); CSHARPKW(return); CSHARPKW(sbyte); CSHARPKW(sealed); CSHARPKW(short); CSHARPKW(sizeof); CSHARPKW(stackalloc); CSHARPKW(static); CSHARPKW(struct); CSHARPKW(string); CSHARPKW(switch); CSHARPKW(this); CSHARPKW(throw); CSHARPKW(true); CSHARPKW(try); CSHARPKW(typeof); CSHARPKW(uint); CSHARPKW(ulong); CSHARPKW(unchecked); CSHARPKW(unsafe); CSHARPKW(ushort); CSHARPKW(using); CSHARPKW(virtual); CSHARPKW(void); CSHARPKW(volatile); CSHARPKW(while); CSHARPCLASSKW(delete); #undef CSHARPKW #endif //CSHARP_CSHARPKW_SWG_ swig-3.0.2/Lib/csharp/std_except.i0000664000175000017500000000411312343605122016644 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. These typemaps are * used when methods are declared with an STL exception specification, such as * size_t at() const throw (std::out_of_range); * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %ignore exception; struct exception {}; } %typemap(throws, canthrow=1) std::bad_exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::domain_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::invalid_argument "SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentException, $1.what(), \"\");\n return $null;" %typemap(throws, canthrow=1) std::length_error "SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::logic_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::out_of_range "SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, 0, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::overflow_error "SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::range_error "SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::runtime_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::underflow_error "SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, $1.what());\n return $null;" swig-3.0.2/Lib/csharp/stl.i0000664000175000017500000000054512343605122015311 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/csharp/std_deque.i0000664000175000017500000000003412343605122016455 0ustar williamwilliam%include swig-3.0.2/Lib/csharp/std_wstring.i0000664000175000017500000000707612343605122017064 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_wstring.i * * Typemaps for std::wstring and const std::wstring& * These are mapped to a C# String and are passed around by value. * * To use non-const std::wstring references use the following %apply. Note * that they are passed by value. * %apply const std::wstring & {std::wstring &}; * ----------------------------------------------------------------------------- */ %include %{ #include %} namespace std { %naturalvar wstring; class wstring; // wstring %typemap(ctype, out="void *") wstring "wchar_t *" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") wstring "string" %typemap(cstype) wstring "string" %typemap(csdirectorin) wstring "$iminput" %typemap(csdirectorout) wstring "$cscall" %typemap(in, canthrow=1) wstring %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); return $null; } $1.assign($input); %} %typemap(out) wstring %{ $result = SWIG_csharp_wstring_callback($1.c_str()); %} %typemap(directorout, canthrow=1) wstring %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); return $null; } $result.assign($input); %} %typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %} %typemap(csin) wstring "$csinput" %typemap(csout, excode=SWIGEXCODE) wstring { string ret = $imcall;$excode return ret; } %typemap(typecheck) wstring = wchar_t *; %typemap(throws, canthrow=1) wstring %{ std::string message($1.begin(), $1.end()); SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str()); return $null; %} // const wstring & %typemap(ctype, out="void *") const wstring & "wchar_t *" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") const wstring & "string" %typemap(cstype) const wstring & "string" %typemap(csdirectorin) const wstring & "$iminput" %typemap(csdirectorout) const wstring & "$cscall" %typemap(in, canthrow=1) const wstring & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); return $null; } std::wstring $1_str($input); $1 = &$1_str; %} %typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_callback($1->c_str()); %} %typemap(csin) const wstring & "$csinput" %typemap(csout, excode=SWIGEXCODE) const wstring & { string ret = $imcall;$excode return ret; } %typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const wstring & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); return $null; } /* possible thread/reentrant code problem */ static std::wstring $1_str; $1_str = $input; $result = &$1_str; %} %typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %} %typemap(csvarin, excode=SWIGEXCODE2) const wstring & %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) const wstring & %{ get { string ret = $imcall;$excode return ret; } %} %typemap(typecheck) const wstring & = wchar_t *; %typemap(throws, canthrow=1) const wstring & %{ std::string message($1.begin(), $1.end()); SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str()); return $null; %} } swig-3.0.2/Lib/csharp/boost_intrusive_ptr.i0000664000175000017500000005766012343605122020644 0ustar williamwilliam// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the // visibility of the constructor and getCPtr method if desired to public if using multiple modules. #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS #define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE) #endif #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP #define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(internal, internal, CONST, TYPE) #endif %include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE "(void)arg1; delete smartarg1;" // Typemap customisations... %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain value argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); return $null; } $1 = *argp; %} %typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{ //plain value(out) $1_ltype* resultp = new $1_ltype(($1_ltype &)$1); intrusive_ptr_add_ref(resultp); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >()); %} %typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{ //plain pointer(out) #if ($owner) if ($1) { intrusive_ptr_add_ref($1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} %typemap(in, canthrow=1) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain reference $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if(!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); return $null; } %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{ //plain reference(out) #if ($owner) if ($1) { intrusive_ptr_add_ref($1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} %typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer by reference temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{ // plain pointer by reference(out) #if ($owner) if (*$1) { intrusive_ptr_add_ref(*$1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0); #endif %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by value smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if (smartarg) { $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ if ($1) { intrusive_ptr_add_ref($1.get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1.get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by reference if ( $input ) { smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ delete &($1); if ($self) { SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); $1 = *temp; } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ if (*$1) { intrusive_ptr_add_ref($1->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer if ( $input ) { smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ delete $1; if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ if ($1 && *$1) { intrusive_ptr_add_ref($1->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } if ($owner) delete $1; %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer reference smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if ($input) { temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } tempp = &temp; $1 = &tempp; %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ if ($self) $1 = *$input; %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ if (*$1 && **$1) { intrusive_ptr_add_ref((*$1)->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (ctype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "void *" %typemap (imtype, out="global::System.IntPtr") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef" %typemap (cstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)" %typemap(csin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)" %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ get { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >& %{ get { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >* %{ get { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %} %typemap(csout, excode=SWIGEXCODE) CONST TYPE { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE & { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE * { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } // Base proxy classes %typemap(csbody) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnBase; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnDerived; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); base.Dispose(); } } // CONST version needed ???? also for C# %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef" %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef" %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; %enddef ///////////////////////////////////////////////////////////////////// %include %define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods %feature("unref") TYPE "(void)arg1; delete smartarg1;" // plain value %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in, canthrow=1) CONST TYPE & %{ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *" %typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *" %typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)" %typemap (csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($csinput)" %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { global::System.IntPtr cPtr = $imcall; return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); } %typemap(csout, excode=SWIGEXCODE) CONST TYPE { return new $typemap(cstype, TYPE)($imcall, true); } %typemap(csout, excode=SWIGEXCODE) CONST TYPE & { return new $typemap(cstype, TYPE)($imcall, true); } %typemap(csout, excode=SWIGEXCODE) CONST TYPE * { global::System.IntPtr cPtr = $imcall; return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); } %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { global::System.IntPtr cPtr = $imcall; return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); } // Base proxy classes %typemap(csbody) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnBase; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnDerived; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); base.Dispose(); } } // CONST version needed ???? also for C# %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef" %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef" %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.2/Lib/carrays.i0000664000175000017500000000512212343605122014667 0ustar williamwilliam/* ----------------------------------------------------------------------------- * carrays.i * * SWIG library file containing macros that can be used to manipulate simple * pointers as arrays. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %array_functions(TYPE,NAME) * * Generates functions for creating and accessing elements of a C array * (as pointers). Creates the following functions: * * TYPE *new_NAME(int nelements) * void delete_NAME(TYPE *); * TYPE NAME_getitem(TYPE *, int index); * void NAME_setitem(TYPE *, int index, TYPE value); * * ----------------------------------------------------------------------------- */ %define %array_functions(TYPE,NAME) %{ static TYPE *new_##NAME(int nelements) { %} #ifdef __cplusplus %{ return new TYPE[nelements]; %} #else %{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %} #endif %{} static void delete_##NAME(TYPE *ary) { %} #ifdef __cplusplus %{ delete [] ary; %} #else %{ free(ary); %} #endif %{} static TYPE NAME##_getitem(TYPE *ary, int index) { return ary[index]; } static void NAME##_setitem(TYPE *ary, int index, TYPE value) { ary[index] = value; } %} TYPE *new_##NAME(int nelements); void delete_##NAME(TYPE *ary); TYPE NAME##_getitem(TYPE *ary, int index); void NAME##_setitem(TYPE *ary, int index, TYPE value); %enddef /* ----------------------------------------------------------------------------- * %array_class(TYPE,NAME) * * Generates a class wrapper around a C array. The class has the following * interface: * * struct NAME { * NAME(int nelements); * ~NAME(); * TYPE getitem(int index); * void setitem(int index, TYPE value); * TYPE * cast(); * static NAME *frompointer(TYPE *t); * } * * ----------------------------------------------------------------------------- */ %define %array_class(TYPE,NAME) %{ typedef TYPE NAME; %} typedef struct { /* Put language specific enhancements here */ } NAME; %extend NAME { #ifdef __cplusplus NAME(int nelements) { return new TYPE[nelements]; } ~NAME() { delete [] self; } #else NAME(int nelements) { return (TYPE *) calloc(nelements,sizeof(TYPE)); } ~NAME() { free(self); } #endif TYPE getitem(int index) { return self[index]; } void setitem(int index, TYPE value) { self[index] = value; } TYPE * cast() { return self; } static NAME *frompointer(TYPE *t) { return (NAME *) t; } }; %types(NAME = TYPE); %enddef swig-3.0.2/Lib/allegrocl/0000775000175000017500000000000012343605122015015 5ustar williamwilliamswig-3.0.2/Lib/allegrocl/allegrocl.swg0000664000175000017500000005750112343605122017513 0ustar williamwilliam/* Define a C preprocessor symbol that can be used in interface files to distinguish between the SWIG language modules. */ #define SWIG_ALLEGRO_CL #define %ffargs(...) %feature("ffargs", "1", ##__VA_ARGS__) %ffargs(strings_convert="t"); /* typemaps for argument and result type conversions. */ %typemap(lin,numinputs=1) SWIGTYPE "(cl::let (($out $in))\n $body)"; %typemap(lout) bool, char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, enum SWIGTYPE "(cl::setq ACL_ffresult $body)"; %typemap(lout) void "$body"; #ifdef __cplusplus %typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE &, SWIGTYPE && %{ (cl:let* ((address $body) (new-inst (cl:make-instance '$lclass :foreign-address address))) (cl:when (cl:and $owner (cl:not (cl:zerop address))) (excl:schedule-finalization new-inst #'$ldestructor)) (cl:setq ACL_ffresult new-inst)) %} %typemap(lout) SWIGTYPE "(cl::let* ((address $body)\n (new-inst (cl::make-instance '$lclass :foreign-address address)))\n (cl::unless (cl::zerop address)\n (excl:schedule-finalization new-inst #'$ldestructor))\n (cl::setq ACL_ffresult new-inst))"; #else %typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE %{ (cl:let* ((address $body) (new-inst (cl:make-instance '$lclass :foreign-address address))) (cl:setq ACL_ffresult new-inst)) %} #endif %typemap(lisptype) bool, const bool "cl:boolean"; %typemap(lisptype) char, const char "cl:character"; %typemap(lisptype) unsigned char, const unsigned char "cl:integer"; %typemap(lisptype) signed char, const signed char "cl:integer"; %typemap(ffitype) bool, const bool ":int"; %typemap(ffitype) char, const char, signed char, const signed char ":char"; %typemap(ffitype) unsigned char, const unsigned char ":unsigned-char"; %typemap(ffitype) short, const short, signed short, const signed short ":short"; %typemap(ffitype) unsigned short, const unsigned short ":unsigned-short"; %typemap(ffitype) int, const int, signed int, const signed int ":int"; %typemap(ffitype) unsigned int, const unsigned int ":unsigned-int"; %typemap(ffitype) long, const long, signed long, const signed long ":long"; %typemap(ffitype) unsigned long, const unsigned long ":unsigned-long"; %typemap(ffitype) float, const float ":float"; %typemap(ffitype) double, const double ":double"; %typemap(ffitype) char *, const char *, signed char *, const signed char *, signed char &, const signed char & "(* :char)"; %typemap(ffitype) unsigned char *, const unsigned char *, unsigned char &, const unsigned char & "(* :unsigned-char)"; %typemap(ffitype) short *, const short *, short &, const short & "(* :short)"; %typemap(ffitype) unsigned short *, const unsigned short *, unsigned short &, const unsigned short & "(* :unsigned-short)"; %typemap(ffitype) int *, const int *, int &, const int & "(* :int)"; %typemap(ffitype) unsigned int *, const unsigned int *, unsigned int &, const unsigned int & "(* :unsigned-int)"; %typemap(ffitype) void * "(* :void)"; %typemap(ffitype) void ":void"; %typemap(ffitype) enum SWIGTYPE ":int"; %typemap(ffitype) SWIGTYPE & "(* :void)"; %typemap(ffitype) SWIGTYPE && "(* :void)"; /* const typemaps idea: marshall all primitive c types to their respective lisp types to maintain const corretness. For pointers/references, all bets are off if you try to modify them. idea: add a constant-p slot to the base foreign-pointer class. For constant pointer/references check this value when setting (around method?) and error if a setf operation is performed on the address of this object. */ /* %exception %{ try { $action } catch (...) { return $null; } %} */ // %typemap(throws) SWIGTYPE { // (void)$1; // SWIG_fail; // } %typemap(ctype) bool, const bool "int"; %typemap(ctype) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[], SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE &&, const SWIGTYPE "$1_ltype"; %typemap(ctype) SWIGTYPE "$&1_type"; %typemap(in) bool "$1 = (bool)$input;"; %typemap(in) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[], SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1 = $input;"; %typemap(in) SWIGTYPE "$1 = *$input;"; /* We don't need to do any actual C-side typechecking, but need to use the precedence values to choose which overloaded function interfaces to generate when conflicts arise. */ /* predefined precedence values Symbolic Name Precedence Value ------------------------------ ------------------ SWIG_TYPECHECK_POINTER 0 SWIG_TYPECHECK_VOIDPTR 10 SWIG_TYPECHECK_BOOL 15 SWIG_TYPECHECK_UINT8 20 SWIG_TYPECHECK_INT8 25 SWIG_TYPECHECK_UINT16 30 SWIG_TYPECHECK_INT16 35 SWIG_TYPECHECK_UINT32 40 SWIG_TYPECHECK_INT32 45 SWIG_TYPECHECK_UINT64 50 SWIG_TYPECHECK_INT64 55 SWIG_TYPECHECK_UINT128 60 SWIG_TYPECHECK_INT128 65 SWIG_TYPECHECK_INTEGER 70 SWIG_TYPECHECK_FLOAT 80 SWIG_TYPECHECK_DOUBLE 90 SWIG_TYPECHECK_COMPLEX 100 SWIG_TYPECHECK_UNICHAR 110 SWIG_TYPECHECK_UNISTRING 120 SWIG_TYPECHECK_CHAR 130 SWIG_TYPECHECK_STRING 140 SWIG_TYPECHECK_BOOL_ARRAY 1015 SWIG_TYPECHECK_INT8_ARRAY 1025 SWIG_TYPECHECK_INT16_ARRAY 1035 SWIG_TYPECHECK_INT32_ARRAY 1045 SWIG_TYPECHECK_INT64_ARRAY 1055 SWIG_TYPECHECK_INT128_ARRAY 1065 SWIG_TYPECHECK_FLOAT_ARRAY 1080 SWIG_TYPECHECK_DOUBLE_ARRAY 1090 SWIG_TYPECHECK_CHAR_ARRAY 1130 SWIG_TYPECHECK_STRING_ARRAY 1140 */ %typecheck(SWIG_TYPECHECK_BOOL) bool { $1 = 1; }; %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = 1; }; %typecheck(SWIG_TYPECHECK_FLOAT) float { $1 = 1; }; %typecheck(SWIG_TYPECHECK_DOUBLE) double { $1 = 1; }; %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = 1; }; %typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, enum SWIGTYPE { $1 = 1; }; %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE[], SWIGTYPE[ANY], SWIGTYPE { $1 = 1; }; /* This maps C/C++ types to Lisp classes for overload dispatch */ %typemap(lispclass) bool "t"; %typemap(lispclass) char "cl:character"; %typemap(lispclass) unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, enum SWIGTYPE "cl:integer"; %typemap(lispclass) float "cl:single-float"; %typemap(lispclass) double "cl:double-float"; %typemap(lispclass) char * "cl:string"; %typemap(out) void ""; %typemap(out) bool "$result = (int)$1;"; %typemap(out) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$result = $1;"; #ifdef __cplusplus %typemap(out) SWIGTYPE "$result = new $1_ltype($1);"; #else %typemap(out) SWIGTYPE { $result = ($&1_ltype) malloc(sizeof($1_type)); memmove($result, &$1, sizeof($1_type)); } #endif ////////////////////////////////////////////////////////////// // UCS-2 string conversion // should this be SWIG_TYPECHECK_CHAR? %typecheck(SWIG_TYPECHECK_UNICHAR) wchar_t { $1 = 1; }; %typemap(in) wchar_t "$1 = $input;"; %typemap(lin,numinputs=1) wchar_t "(cl::let (($out (cl:char-code $in)))\n $body)"; %typemap(lin,numinputs=1) wchar_t * "(excl:with-native-string ($out $in :external-format #+little-endian :fat-le #-little-endian :fat)\n $body)" %typemap(out) wchar_t "$result = $1;"; %typemap(lout) wchar_t "(cl::setq ACL_ffresult (cl::code-char $body))"; %typemap(lout) wchar_t * "(cl::setq ACL_ffresult (excl:native-to-string $body :external-format #+little-endian :fat-le #-little-endian :fat))"; %typemap(ffitype) wchar_t ":unsigned-short"; %typemap(lisptype) wchar_t ""; %typemap(ctype) wchar_t "wchar_t"; %typemap(lispclass) wchar_t "cl:character"; %typemap(lispclass) wchar_t * "cl:string"; ////////////////////////////////////////////////////////////// /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* name conversion for overloaded operators. */ #ifdef __cplusplus %rename(__add__) *::operator+; %rename(__pos__) *::operator+(); %rename(__pos__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-() const; %rename(__neg__) *::operator-(); %rename(__mul__) *::operator*; %rename(__deref__) *::operator*(); %rename(__deref__) *::operator*() const; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; %rename(__logxor__) *::operator^; %rename(__logand__) *::operator&; %rename(__logior__) *::operator|; %rename(__lognot__) *::operator~(); %rename(__lognot__) *::operator~() const; %rename(__not__) *::operator!(); %rename(__not__) *::operator!() const; %rename(__assign__) *::operator=; %rename(__add_assign__) *::operator+=; %rename(__sub_assign__) *::operator-=; %rename(__mul_assign__) *::operator*=; %rename(__div_assign__) *::operator/=; %rename(__mod_assign__) *::operator%=; %rename(__logxor_assign__) *::operator^=; %rename(__logand_assign__) *::operator&=; %rename(__logior_assign__) *::operator|=; %rename(__lshift__) *::operator<<; %rename(__lshift_assign__) *::operator<<=; %rename(__rshift__) *::operator>>; %rename(__rshift_assign__) *::operator>>=; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__lt__) *::operator<; %rename(__gt__) *::operator>; %rename(__lte__) *::operator<=; %rename(__gte__) *::operator>=; %rename(__and__) *::operator&&; %rename(__or__) *::operator||; %rename(__preincr__) *::operator++(); %rename(__postincr__) *::operator++(int); %rename(__predecr__) *::operator--(); %rename(__postdecr__) *::operator--(int); %rename(__comma__) *::operator,(); %rename(__comma__) *::operator,() const; %rename(__member_ref__) *::operator->; %rename(__member_func_ref__) *::operator->*; %rename(__funcall__) *::operator(); %rename(__aref__) *::operator[]; %rename(__bool__) *::operator bool(); %rename(__bool__) *::operator bool() const; #endif %insert("lisphead") %{ (eval-when (:compile-toplevel :load-toplevel :execute) ;; avoid compiling ef-templates at runtime (excl:find-external-format :fat) (excl:find-external-format :fat-le) ;;; You can define your own identifier converter if you want. ;;; Use the -identifier-converter command line argument to ;;; specify its name. (eval-when (:compile-toplevel :load-toplevel :execute) (cl::defparameter *swig-export-list* nil)) (cl::defconstant *void* :..void..) ;; parsers to aid in finding SWIG definitions in files. (cl::defun scm-p1 (form) (let* ((info (cl::second form)) (id (car info)) (id-args (if (eq (cl::car form) 'swig-dispatcher) (cl::cdr info) (cl::cddr info)))) (cl::apply *swig-identifier-converter* id (cl::progn (cl::when (cl::eq (cl::car form) 'swig-dispatcher) (cl::remf id-args :arities)) id-args)))) (cl::defmacro defswig1 (name (&rest args) &body body) `(cl::progn (cl::defmacro ,name ,args ,@body) (excl::define-simple-parser ,name scm-p1)) ) (cl::defmacro defswig2 (name (&rest args) &body body) `(cl::progn (cl::defmacro ,name ,args ,@body) (excl::define-simple-parser ,name second))) (defun read-symbol-from-string (string) (cl::multiple-value-bind (result position) (cl::read-from-string string nil "eof" :preserve-whitespace t) (cl::if (cl::and (cl::symbolp result) (cl::eql position (cl::length string))) result (cl::multiple-value-bind (sym) (cl::intern string) sym)))) (cl::defun full-name (id type arity class) ; We need some kind of a hack here to handle template classes ; and other synonym types right. We need the original name. (let*( (sym (read-symbol-from-string (if (eq *swig-identifier-converter* 'identifier-convert-lispify) (string-lispify id) id))) (sym-class (find-class sym nil)) (id (cond ( (not sym-class) id ) ( (and sym-class (not (eq (class-name sym-class) sym))) (class-name sym-class) ) ( t id ))) ) (cl::case type (:getter (cl::format nil "~@[~A_~]~A" class id)) (:constructor (cl::format nil "new_~A~@[~A~]" id arity)) (:destructor (cl::format nil "delete_~A" id)) (:type (cl::format nil "ff_~A" id)) (:slot id) (:ff-operator (cl::format nil "ffi_~A" id)) (otherwise (cl::format nil "~@[~A_~]~A~@[~A~]" class id arity))))) (cl::defun identifier-convert-null (id &key type class arity) (cl::if (cl::eq type :setter) `(cl::setf ,(identifier-convert-null id :type :getter :class class :arity arity)) (read-symbol-from-string (full-name id type arity class)))) (cl::defun string-lispify (str) (cl::let ( (cname (excl::replace-regexp str "_" "-")) (lastcase :other) newcase char res ) (cl::dotimes (n (cl::length cname)) (cl::setf char (cl::schar cname n)) (excl::if* (cl::alpha-char-p char) then (cl::setf newcase (cl::if (cl::upper-case-p char) :upper :lower)) (cl::when (cl::and (cl::eq lastcase :lower) (cl::eq newcase :upper)) ;; case change... add a dash (cl::push #\- res) (cl::setf newcase :other)) (cl::push (cl::char-downcase char) res) (cl::setf lastcase newcase) else (cl::push char res) (cl::setf lastcase :other))) (cl::coerce (cl::nreverse res) 'string))) (cl::defun identifier-convert-lispify (cname &key type class arity) (cl::assert (cl::stringp cname)) (cl::when (cl::eq type :setter) (cl::return-from identifier-convert-lispify `(cl::setf ,(identifier-convert-lispify cname :type :getter :class class :arity arity)))) (cl::setq cname (full-name cname type arity class)) (cl::if (cl::eq type :constant) (cl::setf cname (cl::format nil "*~A*" cname))) (read-symbol-from-string (string-lispify cname))) (cl::defun id-convert-and-export (name &rest kwargs) (cl::multiple-value-bind (symbol package) (cl::apply *swig-identifier-converter* name kwargs) (cl::let ((args (cl::list (cl::if (cl::consp symbol) (cl::cadr symbol) symbol) (cl::or package cl::*package*)))) (cl::apply #'cl::export args) (cl::pushnew args *swig-export-list*)) symbol)) (cl::defmacro swig-insert-id (name namespace &key (type :type) class) `(cl::let ((cl::*package* (cl::find-package ,(package-name-for-namespace namespace)))) (id-convert-and-export ,name :type ,type :class ,class))) (defswig2 swig-defconstant (string value) (cl::let ((symbol (id-convert-and-export string :type :constant))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::defconstant ,symbol ,value)))) (cl::defun maybe-reorder-args (funcname arglist) ;; in the foreign setter function the new value will be the last argument ;; in Lisp it needs to be the first (cl::if (cl::consp funcname) (cl::append (cl::last arglist) (cl::butlast arglist)) arglist)) (cl::defun maybe-return-value (funcname arglist) ;; setf functions should return the new value (cl::when (cl::consp funcname) `(,(cl::if (cl::consp (cl::car arglist)) (cl::caar arglist) (cl::car arglist))))) (cl::defun swig-anyvarargs-p (arglist) (cl::member :SWIG__varargs_ arglist)) (defswig1 swig-defun ((name &optional (mangled-name name) &key (type :operator) class arity) arglist kwargs &body body) (cl::let* ((symbol (id-convert-and-export name :type type :arity arity :class class)) (mangle (excl::if* (cl::string-equal name mangled-name) then (id-convert-and-export (cl::cond ((cl::eq type :setter) (cl::format nil "~A-set" name)) ((cl::eq type :getter) (cl::format nil "~A-get" name)) (t name)) :type :ff-operator :arity arity :class class) else (cl::intern mangled-name))) (defun-args (maybe-reorder-args symbol (cl::mapcar #'cl::car (cl::and (cl::not (cl::equal arglist '(:void))) (cl::loop as i in arglist when (cl::eq (cl::car i) :p+) collect (cl::cdr i)))))) (ffargs (cl::if (cl::equal arglist '(:void)) arglist (cl::mapcar #'cl::cdr arglist))) ) (cl::when (swig-anyvarargs-p ffargs) (cl::setq ffargs '())) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (excl::compiler-let ((*record-xref-info* nil)) (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) (cl::macrolet ((swig-ff-call (&rest args) (cl::cons ',mangle args))) (cl::defun ,symbol ,defun-args ,@body ,@(maybe-return-value symbol defun-args)))))) (defswig1 swig-defmethod ((name &optional (mangled-name name) &key (type :operator) class arity) ffargs kwargs &body body) (cl::let* ((symbol (id-convert-and-export name :type type :arity arity :class class)) (mangle (cl::intern mangled-name)) (defmethod-args (maybe-reorder-args symbol (cl::unless (cl::equal ffargs '(:void)) (cl::loop for (lisparg name dispatch) in ffargs when (eq lisparg :p+) collect `(,name ,dispatch))))) (ffargs (cl::if (cl::equal ffargs '(:void)) ffargs (cl::loop for (nil name nil . ffi) in ffargs collect `(,name ,@ffi))))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (excl::compiler-let ((*record-xref-info* nil)) (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) (cl::macrolet ((swig-ff-call (&rest args) (cl::cons ',mangle args))) (cl::defmethod ,symbol ,defmethod-args ,@body ,@(maybe-return-value symbol defmethod-args)))))) (defswig1 swig-dispatcher ((name &key (type :operator) class arities)) (cl::let ((symbol (id-convert-and-export name :type type :class class))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::defun ,symbol (&rest args) (cl::case (cl::length args) ,@(cl::loop for arity in arities for symbol-n = (id-convert-and-export name :type type :class class :arity arity) collect `(,arity (cl::apply #',symbol-n args))) (t (cl::error "No applicable wrapper-methods for foreign call ~a with args ~a of classes ~a" ',symbol args (cl::mapcar #'(cl::lambda (x) (cl::class-name (cl::class-of x))) args))) ))))) (defswig2 swig-def-foreign-stub (name) (cl::let ((lsymbol (id-convert-and-export name :type :class)) (symbol (id-convert-and-export name :type :type))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-type ,symbol (:class )) (cl::defclass ,lsymbol (ff:foreign-pointer) ())))) (defswig2 swig-def-foreign-class (name supers &rest rest) (cl::let ((lsymbol (id-convert-and-export name :type :class)) (symbol (id-convert-and-export name :type :type))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-type ,symbol ,@rest) (cl::defclass ,lsymbol ,supers ((foreign-type :initform ',symbol :initarg :foreign-type :accessor foreign-pointer-type)))))) (defswig2 swig-def-foreign-type (name &rest rest) (cl::let ((symbol (id-convert-and-export name :type :type))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-type ,symbol ,@rest)))) (defswig2 swig-def-synonym-type (synonym of ff-synonym) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::setf (cl::find-class ',synonym) (cl::find-class ',of)) (ff:def-foreign-type ,ff-synonym (:struct )))) (cl::defun package-name-for-namespace (namespace) (excl::list-to-delimited-string (cl::cons *swig-module-name* (cl::mapcar #'(cl::lambda (name) (cl::string (cl::funcall *swig-identifier-converter* name :type :namespace))) namespace)) ".")) (cl::defmacro swig-defpackage (namespace) (cl::let* ((parent-namespaces (cl::maplist #'cl::reverse (cl::cdr (cl::reverse namespace)))) (parent-strings (cl::mapcar #'package-name-for-namespace parent-namespaces)) (string (package-name-for-namespace namespace))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::defpackage ,string (:use :swig :ff #+ignore '(:common-lisp :ff :excl) ,@parent-strings ,*swig-module-name*) (:import-from :cl :* :nil :t))))) (cl::defmacro swig-in-package (namespace) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::in-package ,(package-name-for-namespace namespace)))) (defswig2 swig-defvar (name mangled-name &key type (ftype :unsigned-natural)) (cl::let ((symbol (id-convert-and-export name :type type))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-variable (,symbol ,mangled-name) :type ,ftype)))) ) ;; eval-when (cl::eval-when (:compile-toplevel :execute) (cl::flet ((starts-with-p (str prefix) (cl::and (cl::>= (cl::length str) (cl::length prefix)) (cl::string= str prefix :end1 (cl::length prefix))))) (cl::export (cl::loop for sym being each present-symbol of cl::*package* when (cl::or (starts-with-p (cl::symbol-name sym) (cl::symbol-name :swig-)) (starts-with-p (cl::symbol-name sym) (cl::symbol-name :identifier-convert-))) collect sym)))) %} typedef void *__SWIGACL_FwdReference; %{ #ifdef __cplusplus # define EXTERN extern "C" #else # define EXTERN extern #endif #define EXPORT EXTERN SWIGEXPORT typedef void *__SWIGACL_FwdReference; #include #include %} swig-3.0.2/Lib/allegrocl/inout_typemaps.i0000664000175000017500000001053312343605122020251 0ustar williamwilliam/* inout_typemaps.i Support for INPUT, OUTPUT, and INOUT typemaps. OUTPUT variables are returned as multiple values. */ /* Note that this macro automatically adds a pointer to the type passed in. As a result, INOUT typemaps for char are for 'char *'. The definition of typemaps for 'char' takes advantage of this, believing that it's more likely to see an INOUT argument for strings, than a single char. */ %define INOUT_TYPEMAP(type_, OUTresult_, INbind_) // OUTPUT map. %typemap(lin,numinputs=0) type_ *OUTPUT, type_ &OUTPUT %{(cl::let (($out (ff:allocate-fobject '$*in_fftype :c))) $body OUTresult_ (ff:free-fobject $out)) %} // INPUT map. %typemap(in) type_ *INPUT, type_ &INPUT %{ $1 = &$input; %} %typemap(ctype) type_ *INPUT, type_ &INPUT "$*1_ltype"; // INOUT map. // careful here. the input string is converted to a C string // with length equal to the input string. This should be large // enough to contain whatever OUTPUT value will be stored in it. %typemap(lin,numinputs=1) type_ *INOUT, type_ &INOUT %{(cl::let (($out (ff:allocate-fobject '$*in_fftype :c))) INbind_ $body OUTresult_ (ff:free-fobject $out)) %} %enddef // $in, $out, $lclass, // $in_fftype, $*in_fftype INOUT_TYPEMAP(int, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(short, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(long, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(unsigned int, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(unsigned short, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(unsigned long, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); // char * mapping for passing strings. didn't quite work // INOUT_TYPEMAP(char, // (cl::push (excl:native-to-string $out) ACL_result), // (cl::setf (ff:fslot-value-typed (cl::quote $in_fftype) :c $out) // (excl:string-to-native $in))) INOUT_TYPEMAP(float, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(double, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(bool, (cl::push (not (zerop (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out))) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) (if $in 1 0))); %typemap(lisptype) bool *INPUT, bool &INPUT "boolean"; // long long support not yet complete // INOUT_TYPEMAP(long long); // INOUT_TYPEMAP(unsigned long long); // char *OUTPUT map. // for this to work, swig needs to know how large an array to allocate. // you can fake this by // %typemap(ffitype) char *myarg "(:array :char 30)"; // %apply char *OUTPUT { char *myarg }; %typemap(lin,numinputs=0) char *OUTPUT, char &OUTPUT %{(cl::let (($out (ff:allocate-fobject '$*in_fftype :c))) $body (cl::push (excl:native-to-string $out) ACL_result) (ff:free-fobject $out)) %} // char *INPUT map. %typemap(in) char *INPUT, char &INPUT %{ $1 = &$input; %} %typemap(ctype) char *INPUT, char &INPUT "$*1_ltype"; // char *INOUT map. %typemap(lin,numinputs=1) char *INOUT, char &INOUT %{(cl::let (($out (excl:string-to-native $in))) $body (cl::push (excl:native-to-string $out) ACL_result) (ff:free-fobject $out)) %} // uncomment this if you want INOUT mappings for chars instead of strings. // INOUT_TYPEMAP(char, // (cl::push (code-char (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out)) // ACL_result), // (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); swig-3.0.2/Lib/allegrocl/typemaps.i0000664000175000017500000000012712343605122017031 0ustar williamwilliam/* Unused for Allegro CL module */ %include "inout_typemaps.i" %include "longlongs.i" swig-3.0.2/Lib/allegrocl/std_list.i0000664000175000017500000001136112343605122017016 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_list.i * * SWIG typemaps for std::list types * * To use, add: * * %include "std_list.i" * * to your interface file. You will also need to include a template directive * for each instance of the list container you want to use in your application. * e.g. * * %template (intlist) std::list; * %template (floatlist) std::list; * ----------------------------------------------------------------------------- */ %module std_list %warnfilter(468) std::list; %{ #include #include %} namespace std{ template class list { public: typedef T &reference; typedef const T& const_reference; typedef T &iterator; typedef const T& const_iterator; list(); list(unsigned int size, const T& value = T()); list(const list &); ~list(); void assign(unsigned int n, const T& value); void swap(list &x); const_reference front(); const_reference back(); const_iterator begin(); const_iterator end(); void resize(unsigned int n, T c = T()); bool empty() const; void push_front(const T& INPUT); void push_back(const T& INPUT); void pop_front(); void pop_back(); void clear(); unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, const T& INPUT); void remove(const T& INPUT); void unique(); void reverse(); void sort(); %extend { %typemap(lout) T &__getitem__ "(cl::setq ACL_ffresult (ff:fslot-value-typed '$*out_fftype :c $body))"; %typemap(lout) T *__getitem__ "(cl::setq ACL_ffresult (make-instance '$lclass :foreign-address $body))"; const_reference __getitem__(int i) throw (std::out_of_range) { std::list::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && i::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && i::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && ierase(first); } else throw std::out_of_range("list index out of range"); } std::list __getslice__(int i,int j) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; if (i>=j) i=j; if (i>=0 && i=0) { for (int k=0;k tmp(j-i); if (j>i) std::copy(first,end,tmp.begin()); return tmp; } else throw std::out_of_range("list index out of range"); } void __delslice__(int i,int j) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; for (int k=0;kerase(first,end); } void __setslice__(int i,int j, const std::list& v) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; for (int k=0;kerase(first,end); if (i+1 <= int(self->size())) { first = self->begin(); for (int k=0;kinsert(first,v.begin(),v.end()); } else self->insert(self->end(),v.begin(),v.end()); } } unsigned int __len__() { return self->size(); } bool __nonzero__() { return !(self->empty()); } void append(const T& INPUT) { self->push_back(INPUT); } void pop() { self->pop_back(); } }; }; } swig-3.0.2/Lib/allegrocl/std_string.i0000664000175000017500000001502212343605122017347 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string * ----------------------------------------------------------------------------- */ // ------------------------------------------------------------------------ // std::string is typemapped by value // This can prevent exporting methods which return a string // in order for the user to modify it. // However, I think I'll wait until someone asks for it... // ------------------------------------------------------------------------ // %include %warnfilter(404) std::string; %warnfilter(404) std::wstring; %{ #include %} // %include // %naturalvar std::string; // %naturalvar std::wstring; namespace std { typedef unsigned long size_t; typedef signed long ptrdiff_t; template class basic_string { public: typedef charT *pointer; typedef charT &reference; typedef const charT &const_reference; typedef size_t size_type; typedef ptrdiff_t difference_type; basic_string(); basic_string( charT *str ); size_type size(); charT operator []( int pos ) const; charT *c_str() const; basic_string &operator = ( const basic_string &ws ); basic_string &operator = ( const charT *str ); basic_string &append( const basic_string &other ); basic_string &append( const charT *str ); void push_back( charT c ); void clear(); void reserve( size_type t ); void resize( size_type n, charT c = charT() ); int compare( const basic_string &other ) const; int compare( const charT *str ) const; basic_string &insert( size_type pos, const basic_string &str ); size_type find( const basic_string &other, int pos = 0 ) const; size_type find( charT c, int pos = 0 ) const; %extend { bool operator == ( const basic_string &other ) const { return self->compare( other ) == 0; } bool operator != ( const basic_string &other ) const { return self->compare( other ) != 0; } bool operator < ( const basic_string &other ) const { return self->compare( other ) == -1; } bool operator > ( const basic_string &other ) const { return self->compare( other ) == 1; } bool operator <= ( const basic_string &other ) const { return self->compare( other ) != 1; } bool operator >= ( const basic_string &other ) const { return self->compare( other ) != -1; } } }; %template(string) basic_string; %template(wstring) basic_string; %apply char * { string }; %apply wchar_t * { wstring }; typedef basic_string string; typedef basic_string wstring; // automatically convert constant std::strings to cl:strings %typemap(ctype) string "char *"; %typemap(in) string "$1.assign($input);"; %typemap(out) string "$result = (char *)(&$1)->c_str();"; %typemap(lisptype) string "cl:string"; %typemap(lout) string "(cl::setq ACL_ffresult $body)"; %typemap(ctype) const string *"char *"; %typemap(in) const string * "$1.assign($input);"; %typemap(out) const string * "$result = (char *)($1)->c_str();"; %typemap(lisptype) const string * "cl:string"; %typemap(lout) const string * "(cl::setq ACL_ffresult $body)"; %typemap(ctype) wstring "wchar_t *"; %typemap(in) wstring "$1.assign($input);"; %typemap(out) wstring "$result = (wchar_t *)(&$1)->c_str();"; %typemap(lisptype) wstring "cl:string"; %typemap(lout) wstring "(cl::setq ACL_ffresult (excl:native-to-string $body :external-format #+little-endian :fat-le #-little-endian :fat))"; %typemap(ctype) const wstring *"char *"; %typemap(in) const wstring * "$1.assign($input);"; %typemap(out) const wstring * "$result = (char *)($1)->c_str();"; %typemap(lisptype) const wstring * "cl:string"; %typemap(lout) const wstring * "(cl::setq ACL_ffresult $body)"; /* Overloading check */ // %typemap(in) string { // if (caml_ptr_check($input)) // $1.assign((char *)caml_ptr_val($input,0), // caml_string_len($input)); // else // SWIG_exception(SWIG_TypeError, "string expected"); // } // %typemap(in) const string & ($*1_ltype temp) { // if (caml_ptr_check($input)) { // temp.assign((char *)caml_ptr_val($input,0), // caml_string_len($input)); // $1 = &temp; // } else { // SWIG_exception(SWIG_TypeError, "string expected"); // } // } // %typemap(in) string & ($*1_ltype temp) { // if (caml_ptr_check($input)) { // temp.assign((char *)caml_ptr_val($input,0), // caml_string_len($input)); // $1 = &temp; // } else { // SWIG_exception(SWIG_TypeError, "string expected"); // } // } // %typemap(in) string * ($*1_ltype *temp) { // if (caml_ptr_check($input)) { // temp = new $*1_ltype((char *)caml_ptr_val($input,0), // caml_string_len($input)); // $1 = temp; // } else { // SWIG_exception(SWIG_TypeError, "string expected"); // } // } // %typemap(free) string * ($*1_ltype *temp) { // delete temp; // } // %typemap(argout) string & { // caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), // (*$1).size())); // } // %typemap(directorout) string { // $result.assign((char *)caml_ptr_val($input,0), // caml_string_len($input)); // } // %typemap(out) string { // $result = caml_val_string_len($1.c_str(),$1.size()); // } // %typemap(out) string * { // $result = caml_val_string_len((*$1).c_str(),(*$1).size()); // } } // #ifdef ENABLE_CHARPTR_ARRAY // char **c_charptr_array( const std::vector &str_v ); // %{ // SWIGEXT char **c_charptr_array( const std::vector &str_v ) { // char **out = new char *[str_v.size() + 1]; // out[str_v.size()] = 0; // for( int i = 0; i < str_v.size(); i++ ) { // out[i] = (char *)str_v[i].c_str(); // } // return out; // } // %} // #endif // #ifdef ENABLE_STRING_VECTOR // %template (StringVector) std::vector; // %insert(ml) %{ // (* Some STL convenience items *) // let string_array_to_vector sa = // let nv = _new_StringVector C_void in // array_to_vector nv (fun x -> C_string x) sa ; nv // let c_string_array ar = // _c_charptr_array (string_array_to_vector ar) // %} // %insert(mli) %{ // val c_string_array: string array -> c_obj // %} // #endif swig-3.0.2/Lib/allegrocl/longlongs.i0000664000175000017500000000312512343605122017172 0ustar williamwilliam/* ----------------------------------------------------------------------------- * longlongs.i * * Typemap addition for support of 'long long' type and 'unsigned long long * Makes use of swig-def-foreign-class, so this header should be loaded * after allegrocl.swg and after any custom user identifier-conversion * functions have been defined. * ----------------------------------------------------------------------------- */ #ifdef Acl64Bit %typemap(ctype) long long, unsigned long long "$1_ltype"; %typemap(out) long long, unsigned long long "$result = $1;"; %typemap(ffitype) long long ":nat"; %typemap(ffitype) unsigned long long ":unsigned-nat"; %typemap(lout) long long, unsigned long long " #+64bit (cl::setq ACL_ffresult $body)"; #else %typemap(out) long long, unsigned long long "$result = &$1;"; %typemap(ffitype) long long "(:struct (l1 :long) (l2 :long))"; %typemap(ffitype) unsigned long long "(:struct (l1 :unsigned-long) (l2 :unsigned-long))"; %typemap(lout) long long " (cl::setq ACL_ffresult (make-instance '#.(swig-insert-id \"longlong\" () :type :class) :foreign-address $body))"; %typemap(lout) unsigned long long " (cl:setq ACL_ffresult (make-instance '#.(swig-insert-id \"ulonglong\" () :type :class) :foreign-address $body))"; #endif %typemap(in) long long, unsigned long long "$1 = $input;"; %insert("lisphead") %{ #-64bit (swig-def-foreign-class "longlong" (ff:foreign-pointer) (:struct (l1 :long) (l2 :long))) #-64bit (swig-def-foreign-class "ulonglong" (ff:foreign-pointer) (:struct (l1 :unsigned-long) (l2 :unsigned-long))) %} swig-3.0.2/Lib/chicken/0000775000175000017500000000000012343605122014455 5ustar williamwilliamswig-3.0.2/Lib/chicken/typemaps.i0000664000175000017500000002700312343605122016473 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * * These mappings provide support for input/output arguments and * common uses for C/C++ pointers. INOUT mappings allow for C/C++ * pointer variables in addition to input/output arguments. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Scheme list. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); */ //---------------------------------------------------------------------- // // T_OUTPUT typemap (and helper function) to return multiple argouts as // a tuple instead of a list. // //---------------------------------------------------------------------- // Simple types %define INOUT_TYPEMAP(type_, from_scheme, to_scheme, checker, convtype, storage_) %typemap(in) type_ *INPUT($*1_ltype temp), type_ &INPUT($*1_ltype temp) %{ if (!checker ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'"); } temp = ($*1_ltype) from_scheme ($input); $1 = &temp; %} %typemap(typecheck) type_ *INPUT = type_; %typemap(typecheck) type_ &INPUT = type_; %typemap(in, numinputs=0) type_ *OUTPUT($*1_ltype temp), type_ &OUTPUT($*1_ltype temp) " $1 = &temp;" #if "storage_" == "0" %typemap(argout) type_ *OUTPUT, type_ &OUTPUT %{ if ($1 == NULL) { swig_barf (SWIG_BARF1_ARGUMENT_NULL, "Argument #$argnum must be non-null"); } SWIG_APPEND_VALUE(to_scheme (convtype (*$1))); %} #else %typemap(argout) type_ *OUTPUT, type_ &OUTPUT %{ { C_word *known_space = C_alloc(storage_); if ($1 == NULL) { swig_barf (SWIG_BARF1_ARGUMENT_NULL, "Variable '$1' must be non-null"); } SWIG_APPEND_VALUE(to_scheme (&known_space, convtype (*$1))); } %} #endif %enddef INOUT_TYPEMAP(int, C_num_to_int, C_fix, C_swig_is_number, (int), 0); INOUT_TYPEMAP(enum SWIGTYPE, C_num_to_int, C_fix, C_swig_is_number, (int), 0); INOUT_TYPEMAP(short, C_num_to_int, C_fix, C_swig_is_number, (int), 0); INOUT_TYPEMAP(long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); INOUT_TYPEMAP(long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); INOUT_TYPEMAP(unsigned int, C_num_to_unsigned_int, C_unsigned_int_to_num, C_swig_is_number, (int), C_SIZEOF_FLONUM); INOUT_TYPEMAP(unsigned short, C_num_to_unsigned_int, C_fix, C_swig_is_number, (unsigned int), 0); INOUT_TYPEMAP(unsigned long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); INOUT_TYPEMAP(unsigned long long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); INOUT_TYPEMAP(unsigned char, C_character_code, C_make_character, C_swig_is_char, (unsigned int), 0); INOUT_TYPEMAP(signed char, C_character_code, C_make_character, C_swig_is_char, (int), 0); INOUT_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0); INOUT_TYPEMAP(bool, C_truep, C_mk_bool, C_swig_is_bool, (bool), 0); INOUT_TYPEMAP(float, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); INOUT_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a CHICKEN tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); As well, you can wrap variables with : %include %apply double *INOUT { double *y }; extern double *y; Unlike C, this mapping does not directly modify the input value (since this makes no sense in CHICKEN). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a CHICKEN variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %typemap(in) int *INOUT = int *INPUT; %typemap(in) enum SWIGTYPE *INOUT = enum SWIGTYPE *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) char *INOUT = char *INPUT; %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) int &INOUT = int &INPUT; %typemap(in) enum SWIGTYPE &INOUT = enum SWIGTYPE &INPUT; %typemap(in) short &INOUT = short &INPUT; %typemap(in) long &INOUT = long &INPUT; %typemap(in) long long &INOUT = long long &INPUT; %typemap(in) unsigned &INOUT = unsigned &INPUT; %typemap(in) unsigned short &INOUT = unsigned short &INPUT; %typemap(in) unsigned long &INOUT = unsigned long &INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; %typemap(in) unsigned char &INOUT = unsigned char &INPUT; %typemap(in) char &INOUT = char &INPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(in) float &INOUT = float &INPUT; %typemap(in) double &INOUT = double &INPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) enum SWIGTYPE *INOUT = enum SWIGTYPE *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT = long *OUTPUT; %typemap(argout) long long *INOUT = long long *OUTPUT; %typemap(argout) unsigned *INOUT = unsigned *OUTPUT; %typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT = double *OUTPUT; %typemap(argout) int &INOUT = int &OUTPUT; %typemap(argout) enum SWIGTYPE &INOUT = enum SWIGTYPE &OUTPUT; %typemap(argout) short &INOUT = short &OUTPUT; %typemap(argout) long &INOUT = long &OUTPUT; %typemap(argout) long long &INOUT = long long &OUTPUT; %typemap(argout) unsigned &INOUT = unsigned &OUTPUT; %typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; %typemap(argout) char &INOUT = char &OUTPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; %typemap(argout) float &INOUT = float &OUTPUT; %typemap(argout) double &INOUT = double &OUTPUT; /* Overloading information */ %typemap(typecheck) double *INOUT = double; %typemap(typecheck) bool *INOUT = bool; %typemap(typecheck) char *INOUT = char; %typemap(typecheck) signed char *INOUT = signed char; %typemap(typecheck) unsigned char *INOUT = unsigned char; %typemap(typecheck) unsigned long *INOUT = unsigned long; %typemap(typecheck) unsigned long long *INOUT = unsigned long long; %typemap(typecheck) unsigned short *INOUT = unsigned short; %typemap(typecheck) unsigned int *INOUT = unsigned int; %typemap(typecheck) long *INOUT = long; %typemap(typecheck) long long *INOUT = long long; %typemap(typecheck) short *INOUT = short; %typemap(typecheck) int *INOUT = int; %typemap(typecheck) enum SWIGTYPE *INOUT = enum SWIGTYPE; %typemap(typecheck) float *INOUT = float; %typemap(typecheck) double &INOUT = double; %typemap(typecheck) bool &INOUT = bool; %typemap(typecheck) char &INOUT = char; %typemap(typecheck) signed char &INOUT = signed char; %typemap(typecheck) unsigned char &INOUT = unsigned char; %typemap(typecheck) unsigned long &INOUT = unsigned long; %typemap(typecheck) unsigned long long &INOUT = unsigned long long; %typemap(typecheck) unsigned short &INOUT = unsigned short; %typemap(typecheck) unsigned int &INOUT = unsigned int; %typemap(typecheck) long &INOUT = long; %typemap(typecheck) long long &INOUT = long long; %typemap(typecheck) short &INOUT = short; %typemap(typecheck) int &INOUT = int; %typemap(typecheck) enum SWIGTYPE &INOUT = enum SWIGTYPE; %typemap(typecheck) float &INOUT = float; swig-3.0.2/Lib/chicken/extra-install.list0000664000175000017500000000010212343605122020132 0ustar williamwilliamswigclosprefix.scm multi-generic.scm tinyclos-multi-generic.patch swig-3.0.2/Lib/chicken/chicken.swg0000664000175000017500000005476512343605122016624 0ustar williamwilliam/* ----------------------------------------------------------------------------- * chicken.swg * * CHICKEN configuration module. * ----------------------------------------------------------------------------- */ /* chicken.h has to appear first. */ %insert(runtime) %{ #include #include %} %insert(runtime) "swigrun.swg"; // Common C API type-checking code %insert(runtime) "chickenrun.swg"; // CHICKEN run-time code /* ----------------------------------------------------------------------------- * standard typemaps * ----------------------------------------------------------------------------- */ /* CHICKEN: C ---------- fixnum: int, short, unsigned int, unsigned short, unsigned char, signed char char: char bool: bool flonum: float, double, long, long long, unsigned long, unsigned long long */ /* --- Primitive types --- */ %define SIMPLE_TYPEMAP(type_, from_scheme, to_scheme, checker, convtype, storage_) %typemap(in) type_ %{ if (!checker ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'"); } $1 = ($1_ltype) from_scheme ($input); %} /* Const primitive references. Passed by value */ %typemap(in) const type_ & ($*1_ltype temp) %{ if (!checker ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'"); } temp = ($*1_ltype) from_scheme ($input); $1 = &temp; %} /* --- Variable input --- */ %typemap(varin) type_ %{ if (!checker ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use '$1_ltype' for variable '$name' of type 'type_'"); } $1 = ($1_ltype) from_scheme ($input); %} #if "storage_" == "0" %typemap(out) type_ %{ $result = to_scheme (convtype ($1)); %} /* References to primitive types. Return by value */ %typemap(out) const type_ & %{ $result = to_scheme (convtype (*$1)); %} /* --- Variable output --- */ %typemap(varout) type_ %{ $result = to_scheme (convtype ($varname)); %} %typemap(throws) type_ %{ SWIG_Chicken_ThrowException(to_scheme ( convtype ($1))); %} #else %typemap(out) type_ %{ { C_word *space = C_alloc(storage_); $result = to_scheme (&space, convtype ($1)); } %} /* References to primitive types. Return by value */ %typemap(out) const type_ & %{ { C_word *space = C_alloc(storage_); $result = to_scheme (&space, convtype (*$1)); } %} /* --- Variable output --- */ %typemap(varout) type_ %{ { C_word *space = C_alloc(storage_); $result = to_scheme (&space, convtype ($varname)); } %} %typemap(throws) type_ %{ { C_word *space = C_alloc(storage_); SWIG_Chicken_ThrowException(to_scheme (&space, convtype ($1))); } %} #endif /* --- Constants --- */ %typemap(constcode) type_ "static const $1_type $result = $value;" %enddef SIMPLE_TYPEMAP(int, C_num_to_int, C_fix, C_swig_is_number, (int), 0); //SIMPLE_TYPEMAP(enum SWIGTYPE, C_unfix, C_fix, C_swig_is_fixnum, (int), 0); SIMPLE_TYPEMAP(short, C_num_to_int, C_fix, C_swig_is_number, (int), 0); SIMPLE_TYPEMAP(long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(unsigned int, C_num_to_unsigned_int, C_unsigned_int_to_num, C_swig_is_number, (unsigned int), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(unsigned short, C_num_to_unsigned_int, C_fix, C_swig_is_number, (unsigned int), 0); SIMPLE_TYPEMAP(unsigned long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(unsigned long long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(unsigned char, C_character_code, C_make_character, C_swig_is_char, (unsigned int), 0); SIMPLE_TYPEMAP(signed char, C_character_code, C_make_character, C_swig_is_char, (int), 0); SIMPLE_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0); SIMPLE_TYPEMAP(bool, C_truep, C_mk_bool, C_swig_is_bool, (bool), 0); SIMPLE_TYPEMAP(float, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); /* enum SWIGTYPE */ %apply int { enum SWIGTYPE }; %apply const int& { const enum SWIGTYPE& }; %apply const int& { const enum SWIGTYPE&& }; %typemap(varin) enum SWIGTYPE { if (!C_swig_is_fixnum($input) && sizeof(int) != sizeof($1)) { swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "enum variable '$name' can not be set"); } *((int *)(void *)&$1) = C_unfix($input); } /* --- Input arguments --- */ /* Strings */ %typemap(in) char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else { if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'char *'"); } $1 = ($ltype) SWIG_MakeString ($input); } } %typemap(freearg) char * "if ($1 != NULL) { free ($1); }" /* Pointers, references, and arrays */ %typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, $disown); } %typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *DISOWN { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, SWIG_POINTER_DISOWN); } /* Void pointer. Accepts any kind of pointer */ %typemap(in) void * { $1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0); } %typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE * { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, SWIG_POINTER_DISOWN); } %typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE & { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE && { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin) SWIGTYPE [] { SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "Type error"); } %typemap(varin) SWIGTYPE [ANY] { void *temp; int ii; $1_basetype *b = 0; temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0); b = ($1_basetype *) $1; for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii); } %typemap(varin) void * { $1 = SWIG_MustGetPtr($input, NULL, 1, 0); } %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); $result = SWIG_NewPointerObj($1, $descriptor, $owner); } %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); $result = SWIG_NewPointerObj($1, ty, $owner); } %typemap(varout) SWIGTYPE *, SWIGTYPE [] { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); $result = SWIG_NewPointerObj($varname, $descriptor, 0); } %typemap(varout) SWIGTYPE & { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); $result = SWIG_NewPointerObj((void *) &$varname, $1_descriptor, 0); } %typemap(varout) SWIGTYPE && { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); $result = SWIG_NewPointerObj((void *) &$varname, $1_descriptor, 0); } /* special typemaps for class pointers */ %typemap(in) SWIGTYPE (CLASS::*) { char err_msg[256]; if (C_swig_is_pair($input)) { /* try and convert pointer object */ void *result; if (!SWIG_ConvertPtr(C_block_item($input,1), &result, $descriptor, 0)) { C_word ptr = C_block_item($input,0); if (C_swig_is_string(ptr)) { SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($type)); } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } %typemap(out) SWIGTYPE (CLASS::*) { size_t ptr_size = sizeof($type); C_word *known_space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_STRING(2*ptr_size) + C_SIZEOF_SWIG_POINTER); char *temp = (char *)malloc(2*ptr_size); C_word ptr = SWIG_NewPointerObj((void *) known_space, $descriptor, 0); SWIG_PackData(temp, (void *) &$1, ptr_size); $result = C_pair(&known_space, C_string(&known_space, 2*ptr_size, temp), ptr); free(temp); } %typemap(varin) SWIGTYPE (CLASS::*) { char err_msg[256]; if (C_swig_is_pair($input)) { /* try and convert pointer object */ void *result; if (!SWIG_ConvertPtr(C_block_item($input,1), &result, $descriptor, 0)) { C_word ptr = C_block_item($input,0); if (C_swig_is_string(ptr)) { SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($type)); } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } %typemap(varout) SWIGTYPE (CLASS::*) { size_t ptr_size = sizeof($type); C_word *known_space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_STRING(2*ptr_size) + C_SIZEOF_SWIG_POINTER); char *temp = (char *)malloc(2*ptr_size); C_word ptr = SWIG_NewPointerObj((void *) known_space, $descriptor, 0); SWIG_PackData(temp, (void *) &$varname, ptr_size); $result = C_pair(&known_space, C_string(&known_space, 2*ptr_size, temp), ptr); free(temp); } /* Pass-by-value */ %typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE($&1_ltype argp) { argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); $1 = *argp; } %typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE { $&1_ltype argp; argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, 1, 0); $1 = *argp; } %typemap(out) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); resultptr = new $1_ltype((const $1_ltype &) $1); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); } #else { $&1_ltype resultptr; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); } #endif %typemap(varout) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); resultptr = new $1_ltype((const $1_ltype&) $1); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); } #else { $&1_ltype resultptr; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); } #endif /* --- Output values --- */ /* Strings */ %typemap(out) char * { char *s = (char*) $1; if ($1 == NULL) { $result = C_SCHEME_FALSE; } else { int string_len = strlen ((char *) ($1)); C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); $result = C_string (&string_space, string_len, s); } } %typemap(varout) char * { char *s = (char*) $varname; if ($varname == NULL) { $result = C_SCHEME_FALSE; } else { int string_len = strlen ($varname); C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); $result = C_string (&string_space, string_len, s); } } %typemap(throws) char * { if ($1 == NULL) { SWIG_Chicken_ThrowException(C_SCHEME_FALSE); } else { int string_len = strlen($1); C_word *string_space = C_alloc(C_SIZEOF_STRING(string_len)); SWIG_Chicken_ThrowException(C_string(&string_space, string_len, (char *) $1)); } } /* Void */ %typemap(out) void %{ $result = C_SCHEME_UNDEFINED; %} /* Special typemap for character array return values */ %typemap(out) char [ANY], const char [ANY] %{ if ($1 == NULL) { $result = C_SCHEME_FALSE; } else { const int string_len = strlen ($1); C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); $result = C_string (&string_space, string_len, $1); } %} /* Primitive types--return by value */ /* --- Variable input --- */ /* A string */ #ifdef __cplusplus %typemap(varin) char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); int len = C_header_size ($input); if ($1) delete [] $1; $1 = ($type) new char[len+1]; strncpy((char*)$1, temp, len); ((char*)$1) [len] = 0; } } %typemap(varin,warning="451:Setting const char * variable may leak memory") const char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); int len = C_header_size ($input); $1 = ($type) new char[len+1]; strncpy((char*)$1,temp,len); ((char*)$1) [len] = 0; } } #else %typemap(varin) char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); int len = C_header_size ($input); if ($1) free((char*) $1); $1 = ($type) malloc(len+1); strncpy((char*)$1,temp,len); ((char*)$1) [len] = 0; } } %typemap(varin,warning="451:Setting const char * variable may leak memory") const char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); int len = C_header_size ($input); $1 = ($type) malloc(len+1); strncpy((char*)$1,temp,len); ((char*)$1) [len] = 0; } } #endif %typemap(varin) char [] { swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "C/C++ variable '$name' is read-only"); } /* Special case for string array variables */ %typemap(varin) char [ANY] { if ($input == C_SCHEME_FALSE) { memset($1,0,$1_dim0*sizeof(char)); } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); strncpy($1,temp,$1_dim0*sizeof(char)); } } /* --- Variable output --- */ /* Void */ %typemap(varout) void "$result = C_SCHEME_UNDEFINED;"; /* Special typemap for character array return values */ %typemap(varout) char [ANY], const char [ANY] %{ if ($varname == NULL) { $result = C_SCHEME_FALSE; } else { const int string_len = strlen ($varname); C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); $result = C_string (&string_space, string_len, (char *) $varname); } %} /* --- Constants --- */ %typemap(constcode) char * "static const char *$result = $value;" %typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "static const void *$result = (void*) $value;" /* ------------------------------------------------------------ * String & length * ------------------------------------------------------------ */ %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { if ($input == C_SCHEME_FALSE) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use a null/#f string for a char*, int arguments"); } else if (C_swig_is_string ($input)) { $1 = ($1_ltype) C_c_string ($input); $2 = ($2_ltype) C_header_size ($input); } else { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'string'"); } } /* ------------------------------------------------------------ * CHICKEN types * ------------------------------------------------------------ */ %typemap(in) C_word "$1 = $input;"; %typemap(out) C_word "$result = $1;"; /* ------------------------------------------------------------ * Typechecking rules * ------------------------------------------------------------ */ %typecheck(SWIG_TYPECHECK_INTEGER) bool, const bool & { $1 = C_swig_is_bool ($input); } %typecheck(SWIG_TYPECHECK_INTEGER) int, short, unsigned int, unsigned short, signed char, unsigned char, const int &, const short &, const unsigned int &, const unsigned short &, enum SWIGTYPE { $1 = C_swig_is_fixnum ($input); } %typecheck(SWIG_TYPECHECK_INTEGER) long, unsigned long, long long, unsigned long long, const long &, const unsigned long &, const long long &, const unsigned long long & { $1 = (C_swig_is_bool ($input) || C_swig_is_fixnum ($input) || C_swig_is_flonum ($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_DOUBLE) float, double, const float &, const double & { $1 = C_swig_is_flonum ($input); } %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = C_swig_is_string ($input); } %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = C_swig_is_string ($input); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; $1 = !SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0); } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; $1 = !SWIG_ConvertPtr($input, &ptr, 0, 0); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & { void *ptr = 0; if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) { /* error */ $1 = 0; } else { $1 = (ptr != 0); } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE && { void *ptr = 0; if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) { /* error */ $1 = 0; } else { $1 = (ptr != 0); } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr = 0; if (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0)) { /* error */ $1 = 0; } else { $1 = (ptr != 0); } } /* ------------------------------------------------------------ * Exception handling * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * --- Exception handling --- * ------------------------------------------------------------ */ %typemap(throws) SWIGTYPE { $<ype temp = new $ltype($1); C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj(temp, $&descriptor,1); SWIG_Chicken_ThrowException(ptr); } %typemap(throws) SWIGTYPE * { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0); SWIG_Chicken_ThrowException(ptr); } %typemap(throws) SWIGTYPE [ANY] { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0); SWIG_Chicken_ThrowException(ptr); } %typemap(throws) SWIGTYPE & { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj((void *)&($1),$descriptor,0); SWIG_Chicken_ThrowException(ptr); } %typemap(throws) SWIGTYPE && { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj((void *)&($1),$descriptor,0); SWIG_Chicken_ThrowException(ptr); } /* ------------------------------------------------------------ * ANSI C typemaps * ------------------------------------------------------------ */ %apply unsigned long { size_t }; /* ------------------------------------------------------------ * Various * ------------------------------------------------------------ */ /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus %rename(__add__) *::operator+; %rename(__pos__) *::operator+(); %rename(__pos__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-(); %rename(__neg__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; %rename(__lshift__) *::operator<<; %rename(__rshift__) *::operator>>; %rename(__and__) *::operator&; %rename(__or__) *::operator|; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; %rename(__iadd__) *::operator+=; %rename(__isub__) *::operator-=; %rename(__imul__) *::operator*=; %rename(__idiv__) *::operator/=; %rename(__imod__) *::operator%=; %rename(__ilshift__) *::operator<<=; %rename(__irshift__) *::operator>>=; %rename(__iand__) *::operator&=; %rename(__ior__) *::operator|=; %rename(__ixor__) *::operator^=; %rename(__lt__) *::operator<; %rename(__le__) *::operator<=; %rename(__gt__) *::operator>; %rename(__ge__) *::operator>=; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; /* Special cases */ %rename(__call__) *::operator(); #endif /* Warnings for certain CHICKEN keywords */ %include /* TinyCLOS <--> Low-level CHICKEN */ %typemap("clos_in") SIMPLE_CLOS_OBJECT * "(slot-ref $input (quote this))" %typemap("clos_out") SIMPLE_CLOS_OBJECT * "(make $class (quote this) $1)" %insert(header) %{ #ifdef __cplusplus extern "C" { #endif /* Chicken initialization function */ SWIGEXPORT void SWIG_init(C_word, C_word, C_word) C_noret; #ifdef __cplusplus } #endif %} %insert(closprefix) "swigclosprefix.scm" %insert(init) "swiginit.swg" %insert(init) %{ /* CHICKEN initialization function */ #ifdef __cplusplus extern "C" { #endif SWIGEXPORT void SWIG_init(C_word argc, C_word closure, C_word continuation) { int i; C_word sym; C_word tmp; C_word *a; C_word ret; C_word *return_vec; SWIG_InitializeModule(0); SWIG_PropagateClientData(); ret = C_SCHEME_TRUE; #if $veclength return_vec = C_alloc(C_SIZEOF_VECTOR($veclength)); ret = (C_word) return_vec; *(return_vec++) = C_VECTOR_TYPE | $veclength; #endif a = C_alloc(2*$nummethods$symsize); %} swig-3.0.2/Lib/chicken/chickenrun.swg0000664000175000017500000002547012343605122017340 0ustar williamwilliam/* ----------------------------------------------------------------------------- * chickenrun.swg * ----------------------------------------------------------------------------- */ #include #include #include #include #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf # define snprintf _snprintf # endif #endif #ifdef __cplusplus extern "C" { #endif #define SWIG_malloc(size) \ malloc(size) #define SWIG_free(mem) \ free(mem) #define SWIG_MakeString(c) \ SWIG_Chicken_MakeString(c) #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_Chicken_ConvertPtr(s, result, type, flags) #define SWIG_MustGetPtr(s, type, argnum, flags) \ SWIG_Chicken_MustGetPtr(s, type, argnum, flags) #define SWIG_NewPointerObj(ptr, type, owner) \ SWIG_Chicken_NewPointerObj((void*)ptr, type, owner, &known_space) #define swig_barf SWIG_Chicken_Barf #define SWIG_ThrowException(val) SWIG_Chicken_ThrowException(val) #define SWIG_contract_assert(expr, message) if (!(expr)) { \ SWIG_Chicken_Barf(SWIG_BARF1_CONTRACT_ASSERT, C_text(message)); } else /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Chicken_SetModule(pointer) #define C_swig_is_bool(x) C_truep (C_booleanp (x)) #define C_swig_is_char(x) C_truep (C_charp (x)) #define C_swig_is_fixnum(x) C_truep (C_fixnump (x)) #define C_swig_is_flonum(x) (C_truep (C_blockp (x)) && C_truep (C_flonump (x))) #define C_swig_is_string(x) (C_truep (C_blockp (x)) && C_truep (C_stringp (x))) #define C_swig_is_vector(x) (C_truep (C_blockp (x)) && C_truep (C_vectorp (x))) #define C_swig_is_list(x) (C_truep (C_i_listp (x))) #define C_swig_is_pair(x) (C_truep (C_blockp(x)) && C_truep (C_pairp(x))) #define C_swig_is_ptr(x) (C_truep (C_blockp (x)) && C_truep (C_pointerp (x))) #define C_swig_is_swigpointer(x) (C_truep (C_blockp(x)) && C_truep (C_swigpointerp(x))) #define C_swig_is_closurep(x) (C_truep (C_blockp(x)) && C_truep(C_closurep(x))) #define C_swig_is_number(x) (C_swig_is_fixnum(x) || C_swig_is_flonum(x)) #define C_swig_is_long(x) C_swig_is_number(x) #define C_swig_sizeof_closure(num) (num+1) #define SWIG_Chicken_SetupArgout { \ C_word *a = C_alloc(C_swig_sizeof_closure(2)); \ C_word *closure = a; \ *(a++)=C_CLOSURE_TYPE|2; \ *(a++)=(C_word)SWIG_Chicken_ApplyResults; \ *(a++)=continuation; \ continuation=(C_word)closure; \ } #define SWIG_APPEND_VALUE(obj) { \ C_word val = (C_word)(obj); \ if (val != C_SCHEME_UNDEFINED) { \ C_word *a = C_alloc(C_swig_sizeof_closure(3)); \ C_word *closure = a; \ *(a++)=C_CLOSURE_TYPE|3; \ *(a++)=(C_word)SWIG_Chicken_MultiResultBuild; \ *(a++)=(C_word)continuation; \ *(a++)=val; \ continuation=(C_word)closure; \ } } #define SWIG_Chicken_FindCreateProxy(func,obj) \ if (C_swig_is_swigpointer(obj)) { \ swig_type_info *t = (swig_type_info *) C_block_item(obj, 1); \ if (t && t->clientdata && ((swig_chicken_clientdata *)t->clientdata)->gc_proxy_create) { \ func = CHICKEN_gc_root_ref( ((swig_chicken_clientdata *)t->clientdata)->gc_proxy_create); \ } else { \ func = C_SCHEME_FALSE; \ } \ } else { \ func = C_SCHEME_FALSE; \ } enum { SWIG_BARF1_BAD_ARGUMENT_TYPE /* 1 arg */, SWIG_BARF1_ARGUMENT_NULL /* 1 arg */, SWIG_BARF1_CONTRACT_ASSERT /* 1 arg */, }; typedef C_word (*swig_chicken_destructor)(C_word,C_word,C_word,C_word); typedef struct swig_chicken_clientdata { void *gc_proxy_create; swig_chicken_destructor destroy; } swig_chicken_clientdata; static char * SWIG_Chicken_MakeString(C_word str) { char *ret; size_t l; l = C_header_size(str); ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); if (!ret) return NULL; memcpy(ret, C_c_string(str), l); ret[l] = '\0'; return ret; } static C_word SWIG_Chicken_LookupSymbol(char *name, C_SYMBOL_TABLE *stable) { C_word *a = C_alloc(C_SIZEOF_STRING (strlen (name))); C_word n = C_string2(&a, name); C_word sym = C_find_symbol(n, stable); if (C_truep(sym)) { return C_symbol_value(sym); } else { return C_SCHEME_FALSE; } } /* Just a helper function. Do not export it */ static void SWIG_Chicken_Panic (C_char *) C_noret; static void SWIG_Chicken_Panic (C_char *msg) { C_word *a = C_alloc (C_SIZEOF_STRING (strlen (msg))); C_word scmmsg = C_string2 (&a, msg); C_halt (scmmsg); exit (5); /* should never get here */ } static void SWIG_Chicken_Barf(int code, C_char *msg, ...) C_noret; static void SWIG_Chicken_Barf(int code, C_char *msg, ...) { char *errorhook = C_text("\003syserror-hook"); C_word *a = C_alloc (C_SIZEOF_STRING (strlen (errorhook))); C_word err = C_intern2 (&a, errorhook); int c = -1; int i, barfval; va_list v; C_temporary_stack = C_temporary_stack_bottom; err = C_block_item(err, 0); if(C_immediatep (err)) SWIG_Chicken_Panic (C_text ("`##sys#error-hook' is not defined")); switch (code) { case SWIG_BARF1_BAD_ARGUMENT_TYPE: barfval = C_BAD_ARGUMENT_TYPE_ERROR; c = 1; break; case SWIG_BARF1_ARGUMENT_NULL: barfval = C_BAD_ARGUMENT_TYPE_ERROR; c = 1; break; case SWIG_BARF1_CONTRACT_ASSERT: barfval = C_BAD_ARGUMENT_TYPE_ERROR; c = 1; break; default: SWIG_Chicken_Panic (C_text (msg)); }; if(c > 0 && !C_immediatep (err)) { C_save (C_fix (barfval)); i = c; if (i) { C_word *b = C_alloc (C_SIZEOF_STRING (strlen (msg))); C_word scmmsg = C_string2 (&b, msg); C_save (scmmsg); i--; } va_start (v, msg); while(i--) C_save (va_arg (v, C_word)); va_end (v); C_do_apply (c + 1, err, C_SCHEME_UNDEFINED); /* <- no continuation is passed: '##sys#error-hook' may not return! */ } else if (msg) { SWIG_Chicken_Panic (msg); } else { SWIG_Chicken_Panic (C_text ("unspecified panic")); } } static void SWIG_Chicken_ThrowException(C_word value) C_noret; static void SWIG_Chicken_ThrowException(C_word value) { char *aborthook = C_text("\003sysabort"); C_word *a = C_alloc(C_SIZEOF_STRING(strlen(aborthook))); C_word abort = C_intern2(&a, aborthook); abort = C_block_item(abort, 0); if (C_immediatep(abort)) SWIG_Chicken_Panic(C_text("`##sys#abort' is not defined")); C_save(value); C_do_apply(1, abort, C_SCHEME_UNDEFINED); } static void SWIG_Chicken_Finalizer(C_word argc, C_word closure, C_word continuation, C_word s) { swig_type_info *type; swig_chicken_clientdata *cdata; if (argc == 3 && s != C_SCHEME_FALSE && C_swig_is_swigpointer(s)) { type = (swig_type_info *) C_block_item(s, 1); if (type) { cdata = (swig_chicken_clientdata *) type->clientdata; if (cdata && cdata->destroy) { /* this will not return, but will continue correctly */ cdata->destroy(3,closure,continuation,s); } } } C_kontinue(continuation, C_SCHEME_UNDEFINED); } static C_word finalizer_obj[2] = {(C_word) (C_CLOSURE_TYPE|1), (C_word) SWIG_Chicken_Finalizer}; static C_word SWIG_Chicken_NewPointerObj(void *ptr, swig_type_info *type, int owner, C_word **data) { swig_chicken_clientdata *cdata = (swig_chicken_clientdata *) type->clientdata; if (ptr == NULL) return C_SCHEME_FALSE; else { C_word cptr = C_swigmpointer(data, ptr, type); /* add finalizer to object */ #ifndef SWIG_CHICKEN_NO_COLLECTION if (owner) C_do_register_finalizer(cptr, (C_word) finalizer_obj); #endif return cptr; } } /* Return 0 if successful. */ static int SWIG_Chicken_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags) { swig_cast_info *cast; swig_type_info *from; if (s == C_SCHEME_FALSE) { *result = NULL; } else if (C_swig_is_swigpointer(s)) { /* try and convert type */ from = (swig_type_info *) C_block_item(s, 1); if (!from) return 1; if (type) { cast = SWIG_TypeCheckStruct(from, type); if (cast) { int newmemory = 0; *result = SWIG_TypeCast(cast, (void *) C_block_item(s, 0), &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } else { return 1; } } else { *result = (void *) C_block_item(s, 0); } /* check if we are disowning this object */ if (flags & SWIG_POINTER_DISOWN) { C_do_unregister_finalizer(s); } } else { return 1; } return 0; } static SWIGINLINE void * SWIG_Chicken_MustGetPtr (C_word s, swig_type_info *type, int argnum, int flags) { void *result; char err_msg[256]; if (SWIG_Chicken_ConvertPtr(s, &result, type, flags)) { /* type mismatch */ snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", argnum, (type->str ? type->str : type->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } return result; } static char *chicken_runtimevar_name = "type_pointer" SWIG_TYPE_TABLE_NAME; static swig_module_info * SWIG_Chicken_GetModule(void *SWIGUNUSEDPARM(clientdata)) { swig_module_info *ret = 0; C_word sym; /* lookup the type pointer... it is stored in its own symbol table */ C_SYMBOL_TABLE *stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION); if (stable != NULL) { sym = SWIG_Chicken_LookupSymbol(chicken_runtimevar_name, stable); if (C_truep(sym) && C_swig_is_ptr(sym)) { ret = (swig_module_info *) C_block_item(sym, 0); } } return ret; } static void SWIG_Chicken_SetModule(swig_module_info *module) { C_word *a; C_SYMBOL_TABLE *stable; C_word sym; C_word pointer; static C_word *space = 0; /* type pointer is stored in its own symbol table */ stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION); if (stable == NULL) { stable = C_new_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION, 16); } if (!space) { space = (C_word *) C_malloc((C_SIZEOF_POINTER + C_SIZEOF_INTERNED_SYMBOL(C_strlen(chicken_runtimevar_name))) * sizeof(C_word)); } a = space; pointer = C_mpointer(&a, (void *) module); sym = C_intern_in(&a, C_strlen(chicken_runtimevar_name), chicken_runtimevar_name, stable); C_set_block_item(sym, 0, pointer); } static C_word SWIG_Chicken_MultiResultBuild(C_word num, C_word closure, C_word lst) { C_word cont = C_block_item(closure,1); C_word obj = C_block_item(closure,2); C_word func; SWIG_Chicken_FindCreateProxy(func,obj); if (C_swig_is_closurep(func)) { ((C_proc4)(void *)C_block_item(func, 0))(4,func,cont,obj,lst); } else { C_word *a = C_alloc(C_SIZEOF_PAIR); C_kontinue(cont,C_pair(&a,obj,lst)); } return C_SCHEME_UNDEFINED; /* never reached */ } static C_word SWIG_Chicken_ApplyResults(C_word num, C_word closure, C_word result) { C_apply_values(3,C_SCHEME_UNDEFINED,C_block_item(closure,1),result); return C_SCHEME_UNDEFINED; /* never reached */ } #ifdef __cplusplus } #endif swig-3.0.2/Lib/chicken/chickenkw.swg0000664000175000017500000000124612343605122017150 0ustar williamwilliam#ifndef CHICKEN_CHICKENKW_SWG_ #define CHICKEN_CHICKENKW_SWG_ /* Warnings for certain CHICKEN keywords. From Section 7.1.1 of Revised^5 Report on the Algorithmic Language Scheme */ #define CHICKENKW(x) %namewarn("314: '" #x "' is a R^5RS syntatic keyword") #x CHICKENKW(else); CHICKENKW(=>); CHICKENKW(define); CHICKENKW(unquote); CHICKENKW(unquote-splicing); CHICKENKW(quote); CHICKENKW(lambda); CHICKENKW(if); CHICKENKW(set!); CHICKENKW(begin); CHICKENKW(cond); CHICKENKW(and); CHICKENKW(or); CHICKENKW(case); CHICKENKW(let); CHICKENKW(let*); CHICKENKW(letrec); CHICKENKW(do); CHICKENKW(delay); CHICKENKW(quasiquote); #undef CHICKENKW #endif //CHICKEN_CHICKENKW_SWG_ swig-3.0.2/Lib/chicken/swigclosprefix.scm0000664000175000017500000000221612343605122020232 0ustar williamwilliam(declare (hide swig-initialize)) (define (swig-initialize obj initargs create) (slot-set! obj 'swig-this (if (memq 'swig-this initargs) (cadr initargs) (let ((ret (apply create initargs))) (if (instance? ret) (slot-ref ret 'swig-this) ret))))) (define-class () (void)) (define-method (compute-getter-and-setter (class ) slot allocator) (if (not (memq ':swig-virtual slot)) (call-next-method) (let ((getter (let search-get ((lst slot)) (if (null? lst) #f (if (eq? (car lst) ':swig-get) (cadr lst) (search-get (cdr lst)))))) (setter (let search-set ((lst slot)) (if (null? lst) #f (if (eq? (car lst) ':swig-set) (cadr lst) (search-set (cdr lst))))))) (values (lambda (o) (getter (slot-ref o 'swig-this))) (lambda (o new) (setter (slot-ref o 'swig-this) new) new))))) swig-3.0.2/Lib/chicken/multi-generic.scm0000664000175000017500000001361412343605122017732 0ustar williamwilliam;; This file is no longer necessary with Chicken versions above 1.92 ;; ;; This file overrides two functions inside TinyCLOS to provide support ;; for multi-argument generics. There are many ways of linking this file ;; into your code... all that needs to happen is this file must be ;; executed after loading TinyCLOS but before any SWIG modules are loaded ;; ;; something like the following ;; (require 'tinyclos) ;; (load "multi-generic") ;; (declare (uses swigmod)) ;; ;; An alternative to loading this scheme code directly is to add a ;; (declare (unit multi-generic)) to the top of this file, and then ;; compile this into the final executable or something. Or compile ;; this into an extension. ;; Lastly, to override TinyCLOS method creation, two functions are ;; overridden: see the end of this file for which two are overridden. ;; You might want to remove those two lines and then exert more control over ;; which functions are used when. ;; Comments, bugs, suggestions: send either to chicken-users@nongnu.org or to ;; Most code copied from TinyCLOS (define (make 'name "multi-generic" 'direct-supers (list ) 'direct-slots '())) (letrec ([applicable? (lambda (c arg) (memq c (class-cpl (class-of arg))))] [more-specific? (lambda (c1 c2 arg) (memq c2 (memq c1 (class-cpl (class-of arg)))))] [filter-in (lambda (f l) (if (null? l) '() (let ([h (##sys#slot l 0)] [r (##sys#slot l 1)] ) (if (f h) (cons h (filter-in f r)) (filter-in f r) ) ) ) )]) (add-method compute-apply-generic (make-method (list ) (lambda (call-next-method generic) (lambda args (let ([cam (let ([x (compute-apply-methods generic)] [y ((compute-methods generic) args)] ) (lambda (args) (x y args)) ) ] ) (cam args) ) ) ) ) ) (add-method compute-methods (make-method (list ) (lambda (call-next-method generic) (lambda (args) (let ([applicable (filter-in (lambda (method) (let check-applicable ([list1 (method-specializers method)] [list2 args]) (cond ((null? list1) #t) ((null? list2) #f) (else (and (applicable? (##sys#slot list1 0) (##sys#slot list2 0)) (check-applicable (##sys#slot list1 1) (##sys#slot list2 1))))))) (generic-methods generic) ) ] ) (if (or (null? applicable) (null? (##sys#slot applicable 1))) applicable (let ([cmms (compute-method-more-specific? generic)]) (sort applicable (lambda (m1 m2) (cmms m1 m2 args))) ) ) ) ) ) ) ) (add-method compute-method-more-specific? (make-method (list ) (lambda (call-next-method generic) (lambda (m1 m2 args) (let loop ((specls1 (method-specializers m1)) (specls2 (method-specializers m2)) (args args)) (cond-expand [unsafe (let ((c1 (##sys#slot specls1 0)) (c2 (##sys#slot specls2 0)) (arg (##sys#slot args 0))) (if (eq? c1 c2) (loop (##sys#slot specls1 1) (##sys#slot specls2 1) (##sys#slot args 1)) (more-specific? c1 c2 arg))) ] [else (cond ((and (null? specls1) (null? specls2)) (##sys#error "two methods are equally specific" generic)) ;((or (null? specls1) (null? specls2)) ; (##sys#error "two methods have different number of specializers" generic)) ((null? specls1) #f) ((null? specls2) #t) ((null? args) (##sys#error "fewer arguments than specializers" generic)) (else (let ((c1 (##sys#slot specls1 0)) (c2 (##sys#slot specls2 0)) (arg (##sys#slot args 0))) (if (eq? c1 c2) (loop (##sys#slot specls1 1) (##sys#slot specls2 1) (##sys#slot args 1)) (more-specific? c1 c2 arg)))) ) ] ) ) ) ) ) ) ) ;; end of letrec (define multi-add-method (lambda (generic method) (slot-set! generic 'methods (let filter-in-method ([methods (slot-ref generic 'methods)]) (if (null? methods) (list method) (let ([l1 (length (method-specializers method))] [l2 (length (method-specializers (##sys#slot methods 0)))]) (cond ((> l1 l2) (cons (##sys#slot methods 0) (filter-in-method (##sys#slot methods 1)))) ((< l1 l2) (cons method methods)) (else (let check-method ([ms1 (method-specializers method)] [ms2 (method-specializers (##sys#slot methods 0))]) (cond ((and (null? ms1) (null? ms2)) (cons method (##sys#slot methods 1))) ;; skip the method already in the generic ((eq? (##sys#slot ms1 0) (##sys#slot ms2 0)) (check-method (##sys#slot ms1 1) (##sys#slot ms2 1))) (else (cons (##sys#slot methods 0) (filter-in-method (##sys#slot methods 1)))))))))))) (##sys#setslot (##sys#slot generic (- (##sys#size generic) 2)) 1 (compute-apply-generic generic)) )) (define (multi-add-global-method val sym specializers proc) (let ((generic (if (procedure? val) val (make 'name (##sys#symbol->string sym))))) (multi-add-method generic (make-method specializers proc)) generic)) ;; Might want to remove these, or perhaps do something like ;; (define old-add-method ##tinyclos#add-method) ;; and then you can switch between creating multi-generics and TinyCLOS generics. (set! ##tinyclos#add-method multi-add-method) (set! ##tinyclos#add-global-method multi-add-global-method) swig-3.0.2/Lib/chicken/std_string.i0000664000175000017500000000452712343605122017017 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; %insert(closprefix) %{ (declare (hide )) %} %nodefault string; %rename("std-string") string; class string { public: ~string() {} }; %extend string { char *str; } %{ #define std_string_str_get(s) ((char *)((s)->c_str())) #define std_string_str_set(s,v) (s->assign((char *)(v))) %} %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; %typemap(in) string (char * tempptr) { if ($input == C_SCHEME_FALSE) { $1.resize(0); } else { if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not a string"); } tempptr = SWIG_MakeString($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } } %typemap(in) const string& ($*1_ltype temp, char *tempptr) { if ($input == C_SCHEME_FALSE) { temp.resize(0); $1 = &temp; } else { if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not a string"); } tempptr = SWIG_MakeString($input); temp.assign(tempptr); if (tempptr) SWIG_free(tempptr); $1 = &temp; } } %typemap(out) string { int size = $1.size(); C_word *space = C_alloc (C_SIZEOF_STRING (size)); $result = C_string (&space, size, (char *) $1.c_str()); } %typemap(out) const string& { int size = $1->size(); C_word *space = C_alloc (C_SIZEOF_STRING (size)); $result = C_string (&space, size, (char *) $1->c_str()); } %typemap(varin) string { if ($input == C_SCHEME_FALSE) { $1.resize(0); } else { char *tempptr; if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not a string"); } tempptr = SWIG_MakeString($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } } %typemap(varout) string { int size = $1.size(); C_word *space = C_alloc (C_SIZEOF_STRING (size)); $result = C_string (&space, size, (char *) $1.c_str()); } } swig-3.0.2/Lib/chicken/tinyclos-multi-generic.patch0000664000175000017500000001311312343605122022103 0ustar williamwilliam# This patch is against chicken 1.92, but it should work just fine # with older versions of chicken. It adds support for mulit-argument # generics, that is, generics now correctly handle adding methods # with different lengths of specializer lists # This patch has been committed into the CHICKEN darcs repository, # so chicken versions above 1.92 work fine. # Comments, bugs, suggestions send to chicken-users@nongnu.org # Patch written by John Lenz --- tinyclos.scm.old 2005-04-05 01:13:56.000000000 -0500 +++ tinyclos.scm 2005-04-11 16:37:23.746181489 -0500 @@ -37,8 +37,10 @@ (include "parameters") +(cond-expand [(not chicken-compile-shared) (declare (unit tinyclos))] + [else] ) + (declare - (unit tinyclos) (uses extras) (usual-integrations) (fixnum) @@ -234,7 +236,10 @@ y = C_block_item(y, 1); } } - return(C_block_item(v, i + 1)); + if (x == C_SCHEME_END_OF_LIST && y == C_SCHEME_END_OF_LIST) + return(C_block_item(v, i + 1)); + else + goto mismatch; } else if(free_index == -1) free_index = i; mismatch: @@ -438,7 +443,7 @@ (define hash-arg-list (foreign-lambda* unsigned-int ((scheme-object args) (scheme-object svector)) " C_word tag, h, x; - int n, i, j; + int n, i, j, len = 0; for(i = 0; args != C_SCHEME_END_OF_LIST; args = C_block_item(args, 1)) { x = C_block_item(args, 0); if(C_immediatep(x)) { @@ -481,8 +486,9 @@ default: i += 255; } } + ++len; } - return(i & (C_METHOD_CACHE_SIZE - 1));") ) + return((i + len) & (C_METHOD_CACHE_SIZE - 1));") ) ; @@ -868,13 +874,27 @@ (##tinyclos#slot-set! generic 'methods - (cons method - (filter-in - (lambda (m) - (let ([ms1 (method-specializers m)] - [ms2 (method-specializers method)] ) - (not (every2 (lambda (x y) (eq? x y)) ms1 ms2) ) ) ) - (##tinyclos#slot-ref generic 'methods)))) + (let* ([ms1 (method-specializers method)] + [l1 (length ms1)] ) + (let filter-in-method ([methods (##tinyclos#slot-ref generic 'methods)]) + (if (null? methods) + (list method) + (let* ([mm (##sys#slot methods 0)] + [ms2 (method-specializers mm)] + [l2 (length ms2)]) + (cond ((> l1 l2) + (cons mm (filter-in-method (##sys#slot methods 1)))) + ((< l1 l2) + (cons method methods)) + (else + (let check-method ([ms1 ms1] + [ms2 ms2]) + (cond ((and (null? ms1) (null? ms2)) + (cons method (##sys#slot methods 1))) ;; skip the method already in the generic + ((eq? (##sys#slot ms1 0) (##sys#slot ms2 0)) + (check-method (##sys#slot ms1 1) (##sys#slot ms2 1))) + (else + (cons mm (filter-in-method (##sys#slot methods 1))))))))))))) (if (memq generic generic-invocation-generics) (set! method-cache-tag (vector)) (%entity-cache-set! generic #f) ) @@ -925,11 +945,13 @@ (memq (car args) generic-invocation-generics)) (let ([proc (method-procedure + ; select the first method of one argument (let lp ([lis (generic-methods generic)]) - (let ([tail (##sys#slot lis 1)]) - (if (null? tail) - (##sys#slot lis 0) - (lp tail)) ) ) ) ] ) + (if (null? lis) + (##sys#error "Unable to find original compute-apply-generic") + (if (= (length (method-specializers (##sys#slot lis 0))) 1) + (##sys#slot lis 0) + (lp (##sys#slot lis 1)))))) ] ) (lambda (args) (apply proc #f args)) ) (let ([x (compute-apply-methods generic)] [y ((compute-methods generic) args)] ) @@ -946,9 +968,13 @@ (lambda (args) (let ([applicable (filter-in (lambda (method) - (every2 applicable? - (method-specializers method) - args)) + (let check-applicable ([list1 (method-specializers method)] + [list2 args]) + (cond ((null? list1) #t) + ((null? list2) #f) + (else + (and (applicable? (##sys#slot list1 0) (##sys#slot list2 0)) + (check-applicable (##sys#slot list1 1) (##sys#slot list2 1))))))) (generic-methods generic) ) ] ) (if (or (null? applicable) (null? (##sys#slot applicable 1))) applicable @@ -975,8 +1001,10 @@ [else (cond ((and (null? specls1) (null? specls2)) (##sys#error "two methods are equally specific" generic)) - ((or (null? specls1) (null? specls2)) - (##sys#error "two methods have different number of specializers" generic)) + ;((or (null? specls1) (null? specls2)) + ; (##sys#error "two methods have different number of specializers" generic)) + ((null? specls1) #f) + ((null? specls2) #t) ((null? args) (##sys#error "fewer arguments than specializers" generic)) (else @@ -1210,7 +1238,7 @@ (define (make-primitive-class "structure")) (define (make-primitive-class "procedure" )) (define (make-primitive-class "end-of-file")) -(define (make-primitive-class "environment" )) ; (Benedikt insisted on this) +(define (make-primitive-class "environment" )) (define (make-primitive-class "hash-table" )) (define (make-primitive-class "promise" )) (define (make-primitive-class "queue" )) swig-3.0.2/Lib/exception.i0000664000175000017500000001742312343605122015230 0ustar williamwilliam/* ----------------------------------------------------------------------------- * exception.i * * SWIG library file providing language independent exception handling * ----------------------------------------------------------------------------- */ #if defined(SWIGUTL) #error "This version of exception.i should not be used" #endif %insert("runtime") "swigerrors.swg" #ifdef SWIGPHP %{ #include "zend_exceptions.h" #define SWIG_exception(code, msg) zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC) %} #endif #ifdef SWIGGUILE %{ SWIGINTERN void SWIG_exception_ (int code, const char *msg, const char *subr) { #define ERROR(scmerr) \ scm_error(scm_from_locale_string((char *) (scmerr)), \ (char *) subr, (char *) msg, \ SCM_EOL, SCM_BOOL_F) #define MAP(swigerr, scmerr) \ case swigerr: \ ERROR(scmerr); \ break switch (code) { MAP(SWIG_MemoryError, "swig-memory-error"); MAP(SWIG_IOError, "swig-io-error"); MAP(SWIG_RuntimeError, "swig-runtime-error"); MAP(SWIG_IndexError, "swig-index-error"); MAP(SWIG_TypeError, "swig-type-error"); MAP(SWIG_DivisionByZero, "swig-division-by-zero"); MAP(SWIG_OverflowError, "swig-overflow-error"); MAP(SWIG_SyntaxError, "swig-syntax-error"); MAP(SWIG_ValueError, "swig-value-error"); MAP(SWIG_SystemError, "swig-system-error"); default: ERROR("swig-error"); } #undef ERROR #undef MAP } #define SWIG_exception(a,b) SWIG_exception_(a, b, FUNC_NAME) %} #endif #ifdef SWIGMZSCHEME %{ SWIGINTERN void SWIG_exception_ (int code, const char *msg) { #define ERROR(errname) \ scheme_signal_error(errname " (%s)", msg); #define MAP(swigerr, errname) \ case swigerr: \ ERROR(errname); \ break switch (code) { MAP(SWIG_MemoryError, "swig-memory-error"); MAP(SWIG_IOError, "swig-io-error"); MAP(SWIG_RuntimeError, "swig-runtime-error"); MAP(SWIG_IndexError, "swig-index-error"); MAP(SWIG_TypeError, "swig-type-error"); MAP(SWIG_DivisionByZero, "swig-division-by-zero"); MAP(SWIG_OverflowError, "swig-overflow-error"); MAP(SWIG_SyntaxError, "swig-syntax-error"); MAP(SWIG_ValueError, "swig-value-error"); MAP(SWIG_SystemError, "swig-system-error"); default: ERROR("swig-error"); } #undef ERROR #undef MAP } #define SWIG_exception(a,b) SWIG_exception_(a, b) %} #endif #ifdef SWIGJAVA %{ SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) { SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError; switch(code) { case SWIG_MemoryError: exception_code = SWIG_JavaOutOfMemoryError; break; case SWIG_IOError: exception_code = SWIG_JavaIOException; break; case SWIG_SystemError: case SWIG_RuntimeError: exception_code = SWIG_JavaRuntimeException; break; case SWIG_OverflowError: case SWIG_IndexError: exception_code = SWIG_JavaIndexOutOfBoundsException; break; case SWIG_DivisionByZero: exception_code = SWIG_JavaArithmeticException; break; case SWIG_SyntaxError: case SWIG_ValueError: case SWIG_TypeError: exception_code = SWIG_JavaIllegalArgumentException; break; case SWIG_UnknownError: default: exception_code = SWIG_JavaUnknownError; break; } SWIG_JavaThrowException(jenv, exception_code, msg); } %} #define SWIG_exception(code, msg)\ { SWIG_JavaException(jenv, code, msg); return $null; } #endif // SWIGJAVA #ifdef SWIGOCAML %{ #define OCAML_MSG_BUF_LEN 1024 SWIGINTERN void SWIG_exception_(int code, const char *msg) { char msg_buf[OCAML_MSG_BUF_LEN]; sprintf( msg_buf, "Exception(%d): %s\n", code, msg ); failwith( msg_buf ); } #define SWIG_exception(a,b) SWIG_exception_((a),(b)) %} #endif #ifdef SWIGCHICKEN %{ SWIGINTERN void SWIG_exception_(int code, const char *msg) { C_word *a; C_word scmmsg; C_word list; a = C_alloc (C_SIZEOF_STRING (strlen (msg)) + C_SIZEOF_LIST(2)); scmmsg = C_string2 (&a, (char *) msg); list = C_list(&a, 2, C_fix(code), scmmsg); SWIG_ThrowException(list); } #define SWIG_exception(a,b) SWIG_exception_((a),(b)) %} #endif #ifdef SWIGCSHARP %{ SWIGINTERN void SWIG_CSharpException(int code, const char *msg) { if (code == SWIG_ValueError) { SWIG_CSharpExceptionArgumentCodes exception_code = SWIG_CSharpArgumentOutOfRangeException; SWIG_CSharpSetPendingExceptionArgument(exception_code, msg, 0); } else { SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpApplicationException; switch(code) { case SWIG_MemoryError: exception_code = SWIG_CSharpOutOfMemoryException; break; case SWIG_IndexError: exception_code = SWIG_CSharpIndexOutOfRangeException; break; case SWIG_DivisionByZero: exception_code = SWIG_CSharpDivideByZeroException; break; case SWIG_IOError: exception_code = SWIG_CSharpIOException; break; case SWIG_OverflowError: exception_code = SWIG_CSharpOverflowException; break; case SWIG_RuntimeError: case SWIG_TypeError: case SWIG_SyntaxError: case SWIG_SystemError: case SWIG_UnknownError: default: exception_code = SWIG_CSharpApplicationException; break; } SWIG_CSharpSetPendingException(exception_code, msg); } } %} #define SWIG_exception(code, msg)\ { SWIG_CSharpException(code, msg); return $null; } #endif // SWIGCSHARP #ifdef SWIGLUA %{ #define SWIG_exception(a,b)\ { lua_pushfstring(L,"%s:%s",#a,b);SWIG_fail; } %} #endif // SWIGLUA #ifdef SWIGD %{ SWIGINTERN void SWIG_DThrowException(int code, const char *msg) { SWIG_DExceptionCodes exception_code; switch(code) { case SWIG_IndexError: exception_code = SWIG_DNoSuchElementException; break; case SWIG_IOError: exception_code = SWIG_DIOException; break; case SWIG_ValueError: exception_code = SWIG_DIllegalArgumentException; break; case SWIG_DivisionByZero: case SWIG_MemoryError: case SWIG_OverflowError: case SWIG_RuntimeError: case SWIG_TypeError: case SWIG_SyntaxError: case SWIG_SystemError: case SWIG_UnknownError: default: exception_code = SWIG_DException; break; } SWIG_DSetPendingException(exception_code, msg); } %} #define SWIG_exception(code, msg)\ { SWIG_DThrowException(code, msg); return $null; } #endif // SWIGD #ifdef __cplusplus /* You can use the SWIG_CATCH_STDEXCEPT macro with the %exception directive as follows: %exception { try { $action } catch (my_except& e) { ... } SWIG_CATCH_STDEXCEPT // catch std::exception catch (...) { SWIG_exception(SWIG_UnknownError, "Unknown exception"); } } */ %{ #include %} %define SWIG_CATCH_STDEXCEPT /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception(SWIG_ValueError, e.what() ); } catch (std::domain_error& e) { SWIG_exception(SWIG_ValueError, e.what() ); } catch (std::overflow_error& e) { SWIG_exception(SWIG_OverflowError, e.what() ); } catch (std::out_of_range& e) { SWIG_exception(SWIG_IndexError, e.what() ); } catch (std::length_error& e) { SWIG_exception(SWIG_IndexError, e.what() ); } catch (std::runtime_error& e) { SWIG_exception(SWIG_RuntimeError, e.what() ); } catch (std::exception& e) { SWIG_exception(SWIG_SystemError, e.what() ); } %enddef %define SWIG_CATCH_UNKNOWN catch (std::exception& e) { SWIG_exception(SWIG_SystemError, e.what() ); } catch (...) { SWIG_exception(SWIG_UnknownError, "unknown exception"); } %enddef /* rethrow the unknown exception */ #if defined(SWIGCSHARP) || defined(SWIGD) %typemap(throws,noblock=1, canthrow=1) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } #else %typemap(throws,noblock=1) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } #endif #endif /* __cplusplus */ /* exception.i ends here */ swig-3.0.2/Lib/cffi/0000775000175000017500000000000012343605122013760 5ustar williamwilliamswig-3.0.2/Lib/cffi/cffi.swg0000664000175000017500000002306412343605122015416 0ustar williamwilliam/* Define a C preprocessor symbol that can be used in interface files to distinguish between the SWIG language modules. */ #define SWIG_CFFI /* Typespecs for basic types. */ %typemap(cin) void ":void"; %typemap(cin) char ":char"; %typemap(cin) char * ":string"; %typemap(cin) unsigned char ":unsigned-char"; %typemap(cin) signed char ":char"; %typemap(cin) short ":short"; %typemap(cin) signed short ":short"; %typemap(cin) unsigned short ":unsigned-short"; %typemap(cin) int ":int"; %typemap(cin) signed int ":int"; %typemap(cin) unsigned int ":unsigned-int"; %typemap(cin) long ":long"; %typemap(cin) signed long ":long"; %typemap(cin) unsigned long ":unsigned-long"; %typemap(cin) long long ":long-long"; %typemap(cin) signed long long ":long-long"; %typemap(cin) unsigned long long ":unsigned-long-long"; %typemap(cin) float ":float"; %typemap(cin) double ":double"; %typemap(cin) SWIGTYPE ":pointer"; %typemap(cout) void ":void"; %typemap(cout) char ":char"; %typemap(cout) char * ":string"; %typemap(cout) unsigned char ":unsigned-char"; %typemap(cout) signed char ":char"; %typemap(cout) short ":short"; %typemap(cout) signed short ":short"; %typemap(cout) unsigned short ":unsigned-short"; %typemap(cout) int ":int"; %typemap(cout) signed int ":int"; %typemap(cout) unsigned int ":unsigned-int"; %typemap(cout) long ":long"; %typemap(cout) signed long ":long"; %typemap(cout) unsigned long ":unsigned-long"; %typemap(cout) long long ":long-long"; %typemap(cout) signed long long ":long-long"; %typemap(cout) unsigned long long ":unsigned-long-long"; %typemap(cout) float ":float"; %typemap(cout) double ":double"; %typemap(cout) SWIGTYPE ":pointer"; %typemap(ctype) bool "int"; %typemap(ctype) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1_ltype"; %typemap(ctype) SWIGTYPE "$&1_type"; %typemap(in) bool "$1 = (bool)$input;"; %typemap(in) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1 = $input;"; %typemap(in) SWIGTYPE "$1 = *$input;"; %typemap(out) void ""; %typemap(out) bool "$result = (int)$1;"; %typemap(out) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$result = $1;"; #ifdef __cplusplus %typemap(out) SWIGTYPE "$result = new $1_type($1);"; #else %typemap(out) SWIGTYPE { $result = ($&1_ltype) malloc(sizeof($1_type)); memmove($result, &$1, sizeof($1_type)); } #endif %typecheck(SWIG_TYPECHECK_BOOL) bool { $1 = 1; }; %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = 1; }; %typecheck(SWIG_TYPECHECK_FLOAT) float { $1 = 1; }; %typecheck(SWIG_TYPECHECK_DOUBLE) double { $1 = 1; }; %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = 1; }; %typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, enum SWIGTYPE { $1 = 1; }; %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE[ANY], SWIGTYPE { $1 = 1; }; /* This maps C/C++ types to Lisp classes for overload dispatch */ %typemap(lisptype) bool "cl:boolean"; %typemap(lisptype) char "cl:character"; %typemap(lisptype) unsigned char "cl:integer"; %typemap(lisptype) signed char "cl:integer"; %typemap(lispclass) bool "t"; %typemap(lispclass) char "cl:character"; %typemap(lispclass) unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, enum SWIGTYPE "cl:integer"; /* CLOS methods can't be specialized on single-float or double-float */ %typemap(lispclass) float "cl:number"; %typemap(lispclass) double "cl:number"; %typemap(lispclass) char * "cl:string"; /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } %{ #ifdef __cplusplus # define EXTERN extern "C" #else # define EXTERN extern #endif #define EXPORT EXTERN SWIGEXPORT #include %} %insert("swiglisp") %{ ;;;SWIG wrapper code starts here (cl:defmacro defanonenum (cl:&body enums) "Converts anonymous enums to defconstants." `(cl:progn ,@(cl:loop for value in enums for index = 0 then (cl:1+ index) when (cl:listp value) do (cl:setf index (cl:second value) value (cl:first value)) collect `(cl:defconstant ,value ,index)))) (cl:eval-when (:compile-toplevel :load-toplevel) (cl:unless (cl:fboundp 'swig-lispify) (cl:defun swig-lispify (name flag cl:&optional (package cl:*package*)) (cl:labels ((helper (lst last rest cl:&aux (c (cl:car lst))) (cl:cond ((cl:null lst) rest) ((cl:upper-case-p c) (helper (cl:cdr lst) 'upper (cl:case last ((lower digit) (cl:list* c #\- rest)) (cl:t (cl:cons c rest))))) ((cl:lower-case-p c) (helper (cl:cdr lst) 'lower (cl:cons (cl:char-upcase c) rest))) ((cl:digit-char-p c) (helper (cl:cdr lst) 'digit (cl:case last ((upper lower) (cl:list* c #\- rest)) (cl:t (cl:cons c rest))))) ((cl:char-equal c #\_) (helper (cl:cdr lst) '_ (cl:cons #\- rest))) (cl:t (cl:error "Invalid character: ~A" c))))) (cl:let ((fix (cl:case flag ((constant enumvalue) "+") (variable "*") (cl:t "")))) (cl:intern (cl:concatenate 'cl:string fix (cl:nreverse (helper (cl:concatenate 'cl:list name) cl:nil cl:nil)) fix) package)))))) ;;;SWIG wrapper code ends here %} #ifdef __cplusplus %typemap(out) SWIGTYPE "$result = new $1_type($1);"; #else %typemap(out) SWIGTYPE { $result = ($&1_ltype) malloc(sizeof($1_type)); memmove($result, &$1, sizeof($1_type)); } #endif ////////////////////////////////////////////////////////////// /* name conversion for overloaded operators. */ #ifdef __cplusplus %rename(__add__) *::operator+; %rename(__pos__) *::operator+(); %rename(__pos__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-() const; %rename(__neg__) *::operator-(); %rename(__mul__) *::operator*; %rename(__deref__) *::operator*(); %rename(__deref__) *::operator*() const; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; %rename(__logxor__) *::operator^; %rename(__logand__) *::operator&; %rename(__logior__) *::operator|; %rename(__lognot__) *::operator~(); %rename(__lognot__) *::operator~() const; %rename(__not__) *::operator!(); %rename(__not__) *::operator!() const; %rename(__assign__) *::operator=; %rename(__add_assign__) *::operator+=; %rename(__sub_assign__) *::operator-=; %rename(__mul_assign__) *::operator*=; %rename(__div_assign__) *::operator/=; %rename(__mod_assign__) *::operator%=; %rename(__logxor_assign__) *::operator^=; %rename(__logand_assign__) *::operator&=; %rename(__logior_assign__) *::operator|=; %rename(__lshift__) *::operator<<; %rename(__lshift_assign__) *::operator<<=; %rename(__rshift__) *::operator>>; %rename(__rshift_assign__) *::operator>>=; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__lt__) *::operator<; %rename(__gt__) *::operator>; %rename(__lte__) *::operator<=; %rename(__gte__) *::operator>=; %rename(__and__) *::operator&&; %rename(__or__) *::operator||; %rename(__preincr__) *::operator++(); %rename(__postincr__) *::operator++(int); %rename(__predecr__) *::operator--(); %rename(__postdecr__) *::operator--(int); %rename(__comma__) *::operator,(); %rename(__comma__) *::operator,() const; %rename(__member_ref__) *::operator->; %rename(__member_func_ref__) *::operator->*; %rename(__funcall__) *::operator(); %rename(__aref__) *::operator[]; #endif %{ #ifdef __cplusplus # define EXTERN extern "C" #else # define EXTERN extern #endif #define EXPORT EXTERN SWIGEXPORT #include #include %} swig-3.0.2/Lib/std/0000775000175000017500000000000012343605122013643 5ustar williamwilliamswig-3.0.2/Lib/std/std_vectora.i0000664000175000017500000000022312343605122016327 0ustar williamwilliam// // We keep this file only for backward compatibility, since std_vector.i // now uses the std::allocator parameter. // %include swig-3.0.2/Lib/std/std_unordered_set.i0000664000175000017500000000742312343605122017537 0ustar williamwilliam// // std::unordered_set // Work in progress - the code is not compilable yet: // operator--() and constructor(compare function) not available for unordered_ // types // %include %include // Unordered Set %define %std_unordered_set_methods_common(unordered_set...) unordered_set(); unordered_set( const unordered_set& ); bool empty() const; size_type size() const; void clear(); void swap(unordered_set& v); size_type erase(const key_type& x); size_type count(const key_type& x) const; #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; iterator begin(); iterator end(); %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 void erase(iterator pos) { $self->erase(pos); } void erase(iterator first, iterator last) { $self->erase(first, last); } } iterator find(const key_type& x); std::pair equal_range(const key_type& x); #endif %enddef %define %std_unordered_set_methods(unordered_set...) %std_unordered_set_methods_common(unordered_set); #ifdef SWIG_EXPORT_ITERATOR_METHODS std::pair insert(const value_type& __x); #endif %enddef // ------------------------------------------------------------------------ // std::unordered_set // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::unordered_set), f(const std::unordered_set&): // the parameter being read-only, either a sequence or a // previously wrapped std::unordered_set can be passed. // -- f(std::unordered_set&), f(std::unordered_set*): // the parameter may be modified; therefore, only a wrapped std::unordered_set // can be passed. // -- std::unordered_set f(), const std::unordered_set& f(): // the unordered_set is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::unordered_set& f(), std::unordered_set* f(): // the unordered_set is returned by reference; therefore, a wrapped std::unordered_set // is returned // -- const std::unordered_set* f(), f(const std::unordered_set*): // for consistency, they expect and return a plain unordered_set pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template , class _Compare = std::equal_to<_Key>, class _Alloc = allocator<_Key> > class unordered_set { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Hash hasher; typedef _Key value_type; typedef _Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %fragment(SWIG_Traits_frag(std::unordered_set<_Key, _Hash, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdUnorderedSetTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_set<" #_Key "," #_Hash "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::unordered_set<_Key, _Hash, _Compare, _Alloc >); unordered_set( const _Compare& ); #ifdef %swig_unordered_set_methods // Add swig/language extra methods %swig_unordered_set_methods(std::unordered_set<_Key, _Hash, _Compare, _Alloc >); #endif %std_unordered_set_methods(unordered_set); }; } swig-3.0.2/Lib/std/std_multiset.i0000664000175000017500000000474412343605122016546 0ustar williamwilliam// // std::multiset // %include // Multiset %define %std_multiset_methods(multiset...) %std_set_methods_common(multiset); %enddef // ------------------------------------------------------------------------ // std::multiset // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::multiset), f(const std::multiset&): // the parameter being read-only, either a sequence or a // previously wrapped std::multiset can be passed. // -- f(std::multiset&), f(std::multiset*): // the parameter may be modified; therefore, only a wrapped std::multiset // can be passed. // -- std::multiset f(), const std::multiset& f(): // the set is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::multiset& f(), std::multiset* f(): // the set is returned by reference; therefore, a wrapped std::multiset // is returned // -- const std::multiset* f(), f(const std::multiset*): // for consistency, they expect and return a plain set pointer. // ------------------------------------------------------------------------ // exported classes namespace std { //multiset template , class _Alloc = allocator<_Key> > class multiset { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key value_type; typedef _Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %fragment(SWIG_Traits_frag(std::multiset<_Key, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdMultisetTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::multiset<" #_Key "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset<_Key, _Compare, _Alloc >); multiset( const _Compare& ); #ifdef %swig_multiset_methods // Add swig/language extra methods %swig_multiset_methods(std::multiset<_Key, _Compare, _Alloc >); #endif %std_multiset_methods(multiset); }; } swig-3.0.2/Lib/std/README0000664000175000017500000000117212343605122014524 0ustar williamwilliam/* ----------------------------------------------------------------------------- * C++ STD + STL * ----------------------------------------------------------------------------- */ std_common.i general common code std_container.i general container code std_basic_string.i basic string std_char_traits.i char traits std_complex.i complex std_deque.i deque std_except.i exceptions std_ios.i ios std_iostream.i istream/ostream std_list.i list std_map.i map std_multimap.i multimap std_multiset.i multiset std_pair.i pair std_set.i set std_streambuf.i streambuf std_vector.i vector std_vectora.i vector + allocator swig-3.0.2/Lib/std/std_map.i0000664000175000017500000000713012343605122015445 0ustar williamwilliam// // std::map // %include %include %define %std_map_methods_common(map...) %std_container_methods(map); size_type erase(const key_type& x); size_type count(const key_type& x) const; #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 void erase(iterator position) { $self->erase(position); } void erase(iterator first, iterator last) { $self->erase(first, last); } } iterator find(const key_type& x); iterator lower_bound(const key_type& x); iterator upper_bound(const key_type& x); #endif %enddef %define %std_map_methods(map...) %std_map_methods_common(map); #ifdef SWIG_EXPORT_ITERATOR_METHODS // iterator insert(const value_type& x); #endif %enddef // ------------------------------------------------------------------------ // std::map // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::map), f(const std::map&): // the parameter being read-only, either a sequence or a // previously wrapped std::map can be passed. // -- f(std::map&), f(std::map*): // the parameter may be modified; therefore, only a wrapped std::map // can be passed. // -- std::map f(), const std::map& f(): // the map is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::map& f(), std::map* f(): // the map is returned by reference; therefore, a wrapped std::map // is returned // -- const std::map* f(), f(const std::map*): // for consistency, they expect and return a plain map pointer. // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template, class _Alloc = allocator > > class map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", fragment=SWIG_Traits_frag(_Key), fragment=SWIG_Traits_frag(_Tp), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #_Key "," #_Tp " >"; } }; } } %fragment(SWIG_Traits_frag(std::map<_Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), fragment="StdMapTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map<_Key, _Tp, _Compare, _Alloc >); map( const _Compare& ); #ifdef %swig_map_methods // Add swig/language extra methods %swig_map_methods(std::map<_Key, _Tp, _Compare, _Alloc >); #endif %std_map_methods(map); }; } swig-3.0.2/Lib/std/std_unordered_map.i0000664000175000017500000001013012343605122017506 0ustar williamwilliam// // std::unordered_map // Work in progress - the code is not compilable yet: // operator--() and constructor(compare function) not available for unordered_ // types // %include %include %define %std_unordered_map_methods_common(unordered_map...) %std_container_methods(unordered_map); size_type erase(const key_type& x); size_type count(const key_type& x) const; #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 void erase(iterator position) { $self->erase(position); } void erase(iterator first, iterator last) { $self->erase(first, last); } } iterator find(const key_type& x); iterator lower_bound(const key_type& x); iterator upper_bound(const key_type& x); #endif %enddef %define %std_unordered_map_methods(unordered_map...) %std_unordered_map_methods_common(unordered_map); #ifdef SWIG_EXPORT_ITERATOR_METHODS // iterator insert(const value_type& x); #endif %enddef // ------------------------------------------------------------------------ // std::unordered_map // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::unordered_map), f(const std::unordered_map&): // the parameter being read-only, either a sequence or a // previously wrapped std::unordered_map can be passed. // -- f(std::unordered_map&), f(std::unordered_map*): // the parameter may be modified; therefore, only a wrapped std::unordered_map // can be passed. // -- std::unordered_map f(), const std::unordered_map& f(): // the unordered_map is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::unordered_map& f(), std::unordered_map* f(): // the unordered_map is returned by reference; therefore, a wrapped std::unordered_map // is returned // -- const std::unordered_map* f(), f(const std::unordered_map*): // for consistency, they expect and return a plain unordered_map pointer. // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template, class _Alloc = allocator > > class unordered_map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", fragment=SWIG_Traits_frag(_Key), fragment=SWIG_Traits_frag(_Tp), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #_Key "," #_Tp " >"; } }; } } %fragment(SWIG_Traits_frag(std::unordered_map<_Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), fragment="StdMapTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::unordered_map<_Key, _Tp, _Compare, _Alloc >); unordered_map( const _Compare& ); #ifdef %swig_unordered_map_methods // Add swig/language extra methods %swig_unordered_map_methods(std::unordered_map<_Key, _Tp, _Compare, _Alloc >); #endif %std_unordered_map_methods(unordered_map); }; } swig-3.0.2/Lib/std/std_iostream.i0000664000175000017500000002122512343605122016514 0ustar williamwilliam/* For wchar support, you need to include the wchar.i file before this file, ie: %include %include or equivalently, just include %include */ %include %include %include #if defined(SWIG_WCHAR) %include #endif %{ #include %} namespace std { // 27.6.2.1 Template class basic_ostream template > class basic_ostream : virtual public basic_ios<_CharT, _Traits> { public: // Types (inherited from basic_ios (27.4.4)): typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; // 27.6.2.2 Constructor/destructor: explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __sb); virtual ~basic_ostream(); // 27.6.2.5 Formatted output: // 27.6.2.5.3 basic_ostream::operator<< basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& (*__pf)(basic_ostream<_CharT, _Traits>&)); basic_ostream<_CharT, _Traits>& operator<<(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&)); basic_ostream<_CharT, _Traits>& operator<<(ios_base& (*__pf) (ios_base&)); // 27.6.2.5.2 Arithmetic Inserters basic_ostream<_CharT, _Traits>& operator<<(long __n); basic_ostream<_CharT, _Traits>& operator<<(unsigned long __n); basic_ostream<_CharT, _Traits>& operator<<(bool __n); basic_ostream<_CharT, _Traits>& operator<<(short __n); basic_ostream<_CharT, _Traits>& operator<<(unsigned short __n); basic_ostream<_CharT, _Traits>& operator<<(int __n); basic_ostream<_CharT, _Traits>& operator<<(unsigned int __n); basic_ostream<_CharT, _Traits>& operator<<(long long __n); basic_ostream<_CharT, _Traits>& operator<<(unsigned long long __n); basic_ostream<_CharT, _Traits>& operator<<(double __f); basic_ostream<_CharT, _Traits>& operator<<(float __f); basic_ostream<_CharT, _Traits>& operator<<(long double __f); basic_ostream<_CharT, _Traits>& operator<<(const void* __p); basic_ostream<_CharT, _Traits>& operator<<(basic_streambuf<_CharT, _Traits>* __sb); %extend { std::basic_ostream<_CharT, _Traits >& operator<<(const std::basic_string<_CharT,_Traits, std::allocator<_CharT> >& s) { *self << s; return *self; } } // Unformatted output: basic_ostream<_CharT, _Traits>& put(char_type __c); basic_ostream<_CharT, _Traits>& write(const char_type* __s, streamsize __n); basic_ostream<_CharT, _Traits>& flush(); // Seeks: pos_type tellp(); basic_ostream<_CharT, _Traits>& seekp(pos_type); basic_ostream<_CharT, _Traits>& seekp(off_type, ios_base::seekdir); }; // 27.6.1.1 Template class basic_istream template > class basic_istream : virtual public basic_ios<_CharT, _Traits> { public: // Types (inherited from basic_ios (27.4.4)): typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; public: // 27.6.1.1.1 Constructor/destructor: explicit basic_istream(basic_streambuf<_CharT, _Traits>* __sb); virtual ~basic_istream(); // 27.6.1.2.3 basic_istream::operator>> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& (*__pf)(basic_istream<_CharT, _Traits>&)); basic_istream<_CharT, _Traits>& operator>>(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&)); basic_istream<_CharT, _Traits>& operator>>(ios_base& (*__pf)(ios_base&)); // 27.6.1.2.2 Arithmetic Extractors basic_istream<_CharT, _Traits>& operator>>(bool& __n); basic_istream<_CharT, _Traits>& operator>>(short& __n); basic_istream<_CharT, _Traits>& operator>>(unsigned short& __n); basic_istream<_CharT, _Traits>& operator>>(int& __n); basic_istream<_CharT, _Traits>& operator>>(unsigned int& __n); basic_istream<_CharT, _Traits>& operator>>(long& __n); basic_istream<_CharT, _Traits>& operator>>(unsigned long& __n); basic_istream<_CharT, _Traits>& operator>>(long long& __n); basic_istream<_CharT, _Traits>& operator>>(unsigned long long& __n); basic_istream<_CharT, _Traits>& operator>>(float& __f); basic_istream<_CharT, _Traits>& operator>>(double& __f); basic_istream<_CharT, _Traits>& operator>>(long double& __f); basic_istream<_CharT, _Traits>& operator>>(void*& __p); basic_istream<_CharT, _Traits>& operator>>(basic_streambuf<_CharT, _Traits>* __sb); // 27.6.1.3 Unformatted input: inline streamsize gcount(void) const; int_type get(void); basic_istream<_CharT, _Traits>& get(char_type& __c); basic_istream<_CharT, _Traits>& get(char_type* __s, streamsize __n, char_type __delim); inline basic_istream<_CharT, _Traits>& get(char_type* __s, streamsize __n); basic_istream<_CharT, _Traits>& get(basic_streambuf<_CharT, _Traits>& __sb, char_type __delim); inline basic_istream<_CharT, _Traits>& get(basic_streambuf<_CharT, _Traits>& __sb); basic_istream<_CharT, _Traits>& getline(char_type* __s, streamsize __n, char_type __delim); inline basic_istream<_CharT, _Traits>& getline(char_type* __s, streamsize __n); basic_istream<_CharT, _Traits>& ignore(streamsize __n = 1, int_type __delim = _Traits::eof()); int_type peek(void); basic_istream<_CharT, _Traits>& read(char_type* __s, streamsize __n); streamsize readsome(char_type* __s, streamsize __n); basic_istream<_CharT, _Traits>& putback(char_type __c); basic_istream<_CharT, _Traits>& unget(void); int sync(void); pos_type tellg(void); basic_istream<_CharT, _Traits>& seekg(pos_type); basic_istream<_CharT, _Traits>& seekg(off_type, ios_base::seekdir); }; // 27.6.1.5 Template class basic_iostream template > class basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> { public: typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __sb); virtual ~basic_iostream(); }; typedef basic_ostream ostream ; typedef basic_istream istream; typedef basic_iostream iostream; extern istream cin; extern ostream cout; extern ostream cerr; extern ostream clog; #if defined(SWIG_WCHAR) typedef basic_ostream wostream; typedef basic_istream wistream; typedef basic_iostream wiostream; extern wistream wcin; extern wostream wcout; extern wostream wcerr; extern wostream wclog; #endif template > std::basic_ostream<_CharT, _Traits>& endl(std::basic_ostream<_CharT, _Traits>&); template > std::basic_ostream<_CharT, _Traits>& ends(std::basic_ostream<_CharT, _Traits>&); template > std::basic_ostream<_CharT, _Traits>& flush(std::basic_ostream<_CharT, _Traits>&); } namespace std { %template(ostream) basic_ostream; %template(istream) basic_istream; %template(iostream) basic_iostream; %template(endl) endl >; %template(ends) ends >; %template(flush) flush >; #if defined(SWIG_WCHAR) %template(wostream) basic_ostream; %template(wistream) basic_istream; %template(wiostream) basic_iostream; %template(wendl) endl >; %template(wends) ends >; %template(wflush) flush >; #endif } swig-3.0.2/Lib/std/std_stack.i0000664000175000017500000000663412343605122016005 0ustar williamwilliam/** * @file std_stack.i * @date Sun May 6 01:48:07 2007 * * @brief A wrapping of std::stack for Ruby. * * */ %include // Stack %define %std_stack_methods(stack...) stack(); stack( const _Sequence& ); bool empty() const; size_type size() const; const value_type& top() const; void pop(); void push( const value_type& ); %enddef %define %std_stack_methods_val(stack...) %std_stack_methods(stack) %enddef // ------------------------------------------------------------------------ // std::stack // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::stack), f(const std::stack&): // the parameter being read-only, either a sequence or a // previously wrapped std::stack can be passed. // -- f(std::stack&), f(std::stack*): // the parameter may be modified; therefore, only a wrapped std::stack // can be passed. // -- std::stack f(), const std::stack& f(): // the stack is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::stack& f(), std::stack* f(): // the stack is returned by reference; therefore, a wrapped std::stack // is returned // -- const std::stack* f(), f(const std::stack*): // for consistency, they expect and return a plain stack pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class stack { public: typedef size_t size_type; typedef _Tp value_type; typedef value_type& reference; typedef const value_type& const_reference; typedef _Sequence container_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::stack<_Tp, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdStackTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::stack<" #_Tp "," #_Sequence " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp, _Sequence >); #ifdef %swig_stack_methods // Add swig/language extra methods %swig_stack_methods(std::stack<_Tp, _Sequence >); #endif %std_stack_methods(stack); }; template class stack<_Tp*, _Sequence > { public: typedef size_t size_type; typedef _Sequence::value_type value_type; typedef value_type reference; typedef value_type const_reference; typedef _Sequence container_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::stack<_Tp*, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdStackTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::stack<" #_Tp "," #_Sequence " * >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp*, _Sequence >); #ifdef %swig_stack_methods_val // Add swig/language extra methods %swig_stack_methods_val(std::stack<_Tp*, _Sequence >); #endif %std_stack_methods_val(std::stack<_Tp*, _Sequence >); }; } swig-3.0.2/Lib/std/std_pair.i0000664000175000017500000000714012343605122015624 0ustar williamwilliam%include %{ #include %} namespace std { template struct pair { typedef T first_type; typedef U second_type; %traits_swigtype(T); %traits_swigtype(U); %fragment(SWIG_Traits_frag(std::pair), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T "," #U " >"; } }; } } #ifndef SWIG_STD_PAIR_ASVAL %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair); #else %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair); #endif pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; #ifdef %swig_pair_methods // Add swig/language extra methods %swig_pair_methods(std::pair) #endif }; // *** // The following specializations should disappear or get // simplified when a 'const SWIGTYPE*&' can be defined // *** template struct pair { typedef T first_type; typedef U* second_type; %traits_swigtype(T); %traits_swigtype(U); %fragment(SWIG_Traits_frag(std::pair), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T "," #U " * >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair); pair(); pair(T __a, U* __b); pair(const pair& __p); T first; U* second; #ifdef %swig_pair_methods // Add swig/language extra methods %swig_pair_methods(std::pair) #endif }; template struct pair { typedef T* first_type; typedef U second_type; %traits_swigtype(T); %traits_swigtype(U); %fragment(SWIG_Traits_frag(std::pair), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T " *," #U " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair); pair(); pair(T* __a, U __b); pair(const pair& __p); T* first; U second; #ifdef %swig_pair_methods // Add swig/language extra methods %swig_pair_methods(std::pair) #endif }; template struct pair { typedef T* first_type; typedef U* second_type; %traits_swigtype(T); %traits_swigtype(U); %fragment(SWIG_Traits_frag(std::pair), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T " *," #U " * >"; } }; } } %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair); pair(); pair(T* __a, U* __b); pair(const pair& __p); T* first; U* second; #ifdef %swig_pair_methods // Add swig/language extra methods %swig_pair_methods(std::pair) #endif }; } swig-3.0.2/Lib/std/std_wstreambuf.i0000664000175000017500000000014612343605122017047 0ustar williamwilliam/* Provide 'std_streambuf.i' with wchar support. */ %include %include swig-3.0.2/Lib/std/std_container.i0000664000175000017500000000563012343605122016655 0ustar williamwilliam%include %include %include %{ #include %} // Common container methods %define %std_container_methods(container...) container(); container(const container&); bool empty() const; size_type size() const; void clear(); void swap(container& v); allocator_type get_allocator() const; #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; iterator begin(); iterator end(); reverse_iterator rbegin(); reverse_iterator rend(); #endif %enddef // Common sequence %define %std_sequence_methods_common(sequence) %std_container_methods(%arg(sequence)); sequence(size_type size); void pop_back(); void resize(size_type new_size); #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 iterator erase(iterator pos) { return $self->erase(pos); } iterator erase(iterator first, iterator last) { return $self->erase(first, last); } } #endif %enddef %define %std_sequence_methods(sequence) %std_sequence_methods_common(%arg(sequence)); sequence(size_type size, const value_type& value); void push_back(const value_type& x); const value_type& front() const; const value_type& back() const; void assign(size_type n, const value_type& x); void resize(size_type new_size, const value_type& x); #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 iterator insert(iterator pos, const value_type& x) { return $self->insert(pos, x); } void insert(iterator pos, size_type n, const value_type& x) { $self->insert(pos, n, x); } } #endif %enddef %define %std_sequence_methods_val(sequence...) %std_sequence_methods_common(%arg(sequence)); sequence(size_type size, value_type value); void push_back(value_type x); value_type front() const; value_type back() const; void assign(size_type n, value_type x); void resize(size_type new_size, value_type x); #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 iterator insert(iterator pos, value_type x) { return $self->insert(pos, x); } void insert(iterator pos, size_type n, value_type x) { $self->insert(pos, n, x); } } #endif %enddef // // Ignore member methods for Type with no default constructor // %define %std_nodefconst_type(Type...) %feature("ignore") std::vector::vector(size_type size); %feature("ignore") std::vector::resize(size_type size); %feature("ignore") std::deque::deque(size_type size); %feature("ignore") std::deque::resize(size_type size); %feature("ignore") std::list::list(size_type size); %feature("ignore") std::list::resize(size_type size); %enddef swig-3.0.2/Lib/std/std_streambuf.i0000664000175000017500000000331512343605122016661 0ustar williamwilliam%include %{ #ifndef SWIG_STD_NOMODERN_STL #include #else #include #endif %} namespace std { template > class basic_streambuf { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: virtual ~basic_streambuf(); // Locales: locale pubimbue(const locale &__loc); locale getloc() const; // Buffer and positioning: basic_streambuf<_CharT, _Traits>* pubsetbuf(char_type* __s, streamsize __n); pos_type pubseekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = std::ios_base::in | std::ios_base::out); pos_type pubseekpos(pos_type __sp, ios_base::openmode __mode = std::ios_base::in | std::ios_base::out); int pubsync() ; // Get and put areas: // Get area: streamsize in_avail(); int_type snextc(); int_type sbumpc(); int_type sgetc(); streamsize sgetn(char_type* __s, streamsize __n); // Putback: int_type sputbackc(char_type __c); int_type sungetc(); // Put area: int_type sputc(char_type __c); streamsize sputn(const char_type* __s, streamsize __n); protected: basic_streambuf(); private: basic_streambuf(const basic_streambuf&); }; } namespace std { %template(streambuf) basic_streambuf; #if defined(SWIG_WCHAR) %template(wstreambuf) basic_streambuf; #endif } swig-3.0.2/Lib/std/_std_deque.i0000664000175000017500000001050312343605122016130 0ustar williamwilliam/* ----------------------------------------------------------------------------- * _std_deque.i * * This file contains a generic definition of std::deque along with * some helper functions. Specific language modules should include * this file to generate wrappers. * ----------------------------------------------------------------------------- */ %include %{ #include #include %} /* This macro defines all of the standard methods for a deque. This is defined as a macro to simplify the task of specialization. For example, template<> class deque { public: %std_deque_methods(int); }; */ %define %std_deque_methods_noempty(T) typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; deque(); deque(unsigned int size, const T& value=T()); deque(const deque &); ~deque(); void assign(unsigned int n, const T& value); void swap(deque &x); unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, T c = T()); const_reference front(); const_reference back(); void push_front(const T& x); void push_back(const T& x); void pop_front(); void pop_back(); void clear(); /* Some useful extensions */ %extend { const_reference getitem(int i) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i += size; if (i>=0 && isize()); if (i<0) i+= size; if (i>=0 && isize()); if (i<0) i+= size; if (i>=0 && ierase(self->begin()+i); } else { throw std::out_of_range("deque index out of range"); } } std::deque getslice(int i, int j) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; if (i<0) i = 0; if (j>size) j = size; std::deque tmp(j-i); std::copy(self->begin()+i,self->begin()+j,tmp.begin()); return tmp; } void setslice(int i, int j, const std::deque& v) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; if (i<0) i = 0; if (j>size) j = size; if (int(v.size()) == j-i) { std::copy(v.begin(),v.end(),self->begin()+i); } else { self->erase(self->begin()+i,self->begin()+j); if (i+1 <= size) self->insert(self->begin()+i+1,v.begin(),v.end()); else self->insert(self->end(),v.begin(),v.end()); } } void delslice(int i, int j) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; if (i<0) i = 0; if (j>size) j = size; self->erase(self->begin()+i,self->begin()+j); } }; %enddef #ifdef SWIGPHP %define %std_deque_methods(T) %extend { bool is_empty() const { return self->empty(); } }; %std_deque_methods_noempty(T) %enddef #else %define %std_deque_methods(T) bool empty() const; %std_deque_methods_noempty(T) %enddef #endif namespace std { template class deque { public: %std_deque_methods(T); }; } swig-3.0.2/Lib/std/std_common.i0000664000175000017500000001163612343605122016166 0ustar williamwilliam%include // // Use the following macro with modern STL implementations // //#define SWIG_STD_MODERN_STL // // Use this to deactive the previous definition, when using gcc-2.95 // or similar old compilers. // //#define SWIG_STD_NOMODERN_STL // Here, we identify compilers we know have problems with STL. %{ #if defined(__GNUC__) # if __GNUC__ == 2 && __GNUC_MINOR <= 96 # define SWIG_STD_NOMODERN_STL # endif #endif %} // // Common code for supporting the C++ std namespace // %fragment(""); %fragment(""); %fragment(""); %fragment("StdIteratorTraits","header",fragment="") %{ #if defined(__SUNPRO_CC) && defined(_RWSTD_VER) # if !defined(SWIG_NO_STD_NOITERATOR_TRAITS_STL) # define SWIG_STD_NOITERATOR_TRAITS_STL # endif #endif #if !defined(SWIG_STD_NOITERATOR_TRAITS_STL) #include #else namespace std { template struct iterator_traits { typedef ptrdiff_t difference_type; typedef typename Iterator::value_type value_type; }; template struct iterator_traits<__reverse_bi_iterator > { typedef Distance difference_type; typedef T value_type; }; template struct iterator_traits { typedef T value_type; typedef ptrdiff_t difference_type; }; template inline typename iterator_traits<_InputIterator>::difference_type distance(_InputIterator __first, _InputIterator __last) { typename iterator_traits<_InputIterator>::difference_type __n = 0; while (__first != __last) { ++__first; ++__n; } return __n; } } #endif %} %fragment("StdTraitsCommon","header",fragment="") %{ namespace swig { template struct noconst_traits { typedef Type noconst_type; }; template struct noconst_traits { typedef Type noconst_type; }; /* type categories */ struct pointer_category { }; struct value_category { }; /* General traits that provides type_name and type_info */ template struct traits { }; template inline const char* type_name() { return traits::noconst_type >::type_name(); } template struct traits_info { static swig_type_info *type_query(std::string name) { name += " *"; return SWIG_TypeQuery(name.c_str()); } static swig_type_info *type_info() { static swig_type_info *info = type_query(type_name()); return info; } }; template inline swig_type_info *type_info() { return traits_info::type_info(); } /* Partial specialization for pointers */ template struct traits { typedef pointer_category category; static std::string make_ptr_name(const char* name) { std::string ptrname = name; ptrname += " *"; return ptrname; } static const char* type_name() { static std::string name = make_ptr_name(swig::type_name()); return name.c_str(); } }; template struct traits_as { }; template struct traits_check { }; } %} /* Generate the traits for a swigtype */ %define %traits_swigtype(Type...) %fragment(SWIG_Traits_frag(Type),"header",fragment="StdTraits") { namespace swig { template <> struct traits { typedef pointer_category category; static const char* type_name() { return #Type; } }; } } %enddef /* Generate the typemaps for a class that has 'value' traits */ %define %typemap_traits(Code,Type...) %typemaps_asvalfrom(%arg(Code), %arg(swig::asval), %arg(swig::from), %arg(SWIG_Traits_frag(Type)), %arg(SWIG_Traits_frag(Type)), Type); %enddef /* Generate the typemaps for a class that behaves more like a 'pointer' or plain wrapped Swigtype. */ %define %typemap_traits_ptr(Code,Type...) %typemaps_asptrfrom(%arg(Code), %arg(swig::asptr), %arg(swig::from), %arg(SWIG_Traits_frag(Type)), %arg(SWIG_Traits_frag(Type)), Type); %enddef /* Equality methods */ %define %std_equal_methods(Type...) %extend Type { bool operator == (const Type& v) { return *self == v; } bool operator != (const Type& v) { return *self != v; } } %enddef /* Order methods */ %define %std_order_methods(Type...) %extend Type { bool operator > (const Type& v) { return *self > v; } bool operator < (const Type& v) { return *self < v; } bool operator >= (const Type& v) { return *self >= v; } bool operator <= (const Type& v) { return *self <= v; } } %enddef /* Comparison methods */ %define %std_comp_methods(Type...) %std_equal_methods(Type ) %std_order_methods(Type ) %enddef swig-3.0.2/Lib/std/std_list.i0000664000175000017500000000743012343605122015646 0ustar williamwilliam// // std::list // %include // List %define %std_list_methods(list) %std_sequence_methods(list) void pop_front(); void push_front(const value_type& x); void reverse(); %enddef %define %std_list_methods_val(list) %std_sequence_methods_val(list) void pop_front(); void push_front(value_type x); void remove(value_type x); void unique(); void reverse(); void sort(); void merge(list& x); %enddef // ------------------------------------------------------------------------ // std::list // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::list), f(const std::list&): // the parameter being read-only, either a sequence or a // previously wrapped std::list can be passed. // -- f(std::list&), f(std::list*): // the parameter may be modified; therefore, only a wrapped std::list // can be passed. // -- std::list f(), const std::list& f(): // the list is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::list& f(), std::list* f(): // the list is returned by reference; therefore, a wrapped std::list // is returned // -- const std::list* f(), f(const std::list*): // for consistency, they expect and return a plain list pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class list { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::list<_Tp, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdListTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::list<" #_Tp ", " #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp, _Alloc >); #ifdef %swig_list_methods // Add swig/language extra methods %swig_list_methods(std::list<_Tp, _Alloc >); #endif %std_list_methods(list); }; template class list<_Tp*, _Alloc> { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::list<_Tp*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdListTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::list<" #_Tp " *," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp*, _Alloc >); #ifdef %swig_list_methods_val // Add swig/language extra methods %swig_list_methods_val(std::list<_Tp*, _Alloc >); #endif %std_list_methods_val(list); }; } %define %std_extequal_list(...) %extend std::list<__VA_ARGS__ > { void remove(const value_type& x) { self->remove(x); } void merge(std::list<__VA_ARGS__ >& x){ self->merge(x); } void unique() { self->unique(); } void sort() { self->sort(); } } %enddef swig-3.0.2/Lib/std/std_alloc.i0000664000175000017500000000373712343605122015773 0ustar williamwilliamnamespace std { /** * @brief The "standard" allocator, as per [20.4]. * * The private _Alloc is "SGI" style. (See comments at the top * of stl_alloc.h.) * * The underlying allocator behaves as follows. * - __default_alloc_template is used via two typedefs * - "__single_client_alloc" typedef does no locking for threads * - "__alloc" typedef is threadsafe via the locks * - __new_alloc is used for memory requests * * (See @link Allocators allocators info @endlink for more.) */ template class allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* pointer; typedef const _Tp* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Tp value_type; template struct rebind; allocator() throw(); allocator(const allocator&) throw(); template allocator(const allocator<_Tp1>&) throw(); ~allocator() throw(); pointer address(reference __x) const; const_pointer address(const_reference __x) const; // NB: __n is permitted to be 0. The C++ standard says nothing // about what the return value is when __n == 0. _Tp* allocate(size_type __n, const void* = 0); // __p is not permitted to be a null pointer. void deallocate(pointer __p, size_type __n); size_type max_size() const throw(); void construct(pointer __p, const _Tp& __val); void destroy(pointer __p); }; template<> class allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template struct rebind; }; } // namespace std swig-3.0.2/Lib/std/std_set.i0000664000175000017500000000643212343605122015467 0ustar williamwilliam// // std::set // %include %include // Set %define %std_set_methods_common(set...) set(); set( const set& ); bool empty() const; size_type size() const; void clear(); void swap(set& v); size_type erase(const key_type& x); size_type count(const key_type& x) const; #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; class reverse_iterator; iterator begin(); iterator end(); reverse_iterator rbegin(); reverse_iterator rend(); %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 void erase(iterator pos) { $self->erase(pos); } void erase(iterator first, iterator last) { $self->erase(first, last); } } iterator find(const key_type& x); iterator lower_bound(const key_type& x); iterator upper_bound(const key_type& x); std::pair equal_range(const key_type& x); #endif %enddef %define %std_set_methods(set...) %std_set_methods_common(set); #ifdef SWIG_EXPORT_ITERATOR_METHODS std::pair insert(const value_type& __x); #endif %enddef // ------------------------------------------------------------------------ // std::set // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::set), f(const std::set&): // the parameter being read-only, either a sequence or a // previously wrapped std::set can be passed. // -- f(std::set&), f(std::set*): // the parameter may be modified; therefore, only a wrapped std::set // can be passed. // -- std::set f(), const std::set& f(): // the set is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::set& f(), std::set* f(): // the set is returned by reference; therefore, a wrapped std::set // is returned // -- const std::set* f(), f(const std::set*): // for consistency, they expect and return a plain set pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template , class _Alloc = allocator<_Key> > class set { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key value_type; typedef _Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %fragment(SWIG_Traits_frag(std::set<_Key, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdSetTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::set<" #_Key "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set<_Key, _Compare, _Alloc >); set( const _Compare& ); #ifdef %swig_set_methods // Add swig/language extra methods %swig_set_methods(std::set<_Key, _Compare, _Alloc >); #endif %std_set_methods(set); }; } swig-3.0.2/Lib/std/std_wiostream.i0000664000175000017500000000014412343605122016700 0ustar williamwilliam/* Provide 'std_iostream.i' with wchar support. */ %include %include swig-3.0.2/Lib/std/std_multimap.i0000664000175000017500000000626112343605122016524 0ustar williamwilliam// // std::multimap // %include %define %std_multimap_methods(mmap...) %std_map_methods_common(mmap); #ifdef SWIG_EXPORT_ITERATOR_METHODS std::pair equal_range(const key_type& x); std::pair equal_range(const key_type& x) const; #endif %enddef // ------------------------------------------------------------------------ // std::multimap // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::multimap), f(const std::multimap&): // the parameter being read-only, either a sequence or a // previously wrapped std::multimap can be passed. // -- f(std::multimap&), f(std::multimap*): // the parameter may be modified; therefore, only a wrapped std::multimap // can be passed. // -- std::multimap f(), const std::multimap& f(): // the map is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::multimap& f(), std::multimap* f(): // the map is returned by reference; therefore, a wrapped std::multimap // is returned // -- const std::multimap* f(), f(const std::multimap*): // for consistency, they expect and return a plain map pointer. // ------------------------------------------------------------------------ // exported class namespace std { template, class _Alloc = allocator > > class multimap { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", fragment=SWIG_Traits_frag(_Key), fragment=SWIG_Traits_frag(_Tp), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #_Key "," #_Tp " >"; } }; } } %fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), fragment="StdMultimapTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap<_Key, _Tp, _Compare, _Alloc >); multimap( const _Compare& ); #ifdef %swig_multimap_methods // Add swig/language extra methods %swig_multimap_methods(std::multimap<_Key, _Tp, _Compare, _Alloc >); #endif %std_multimap_methods(multimap); }; } swig-3.0.2/Lib/std/std_ios.i0000664000175000017500000001203212343605122015457 0ustar williamwilliam%include %include %include %{ #ifndef SWIG_STD_NOMODERN_STL # include #else # include #endif %} namespace std { template > class basic_streambuf; template > class basic_istream; template > class basic_ostream; // 27.4.2 Class ios_base typedef size_t streamsize; class locale; class ios_base { public: #ifdef SWIG_NESTED_CLASSES // 27.4.2.1.1 Class ios_base::failure class failure : public exception { public: explicit failure(const string& __str) throw(); }; #endif // 27.4.2.1.2 Type ios_base::fmtflags typedef int fmtflags; // 27.4.2.1.2 Type fmtflags static const fmtflags boolalpha ; static const fmtflags dec ; static const fmtflags fixed ; static const fmtflags hex ; static const fmtflags internal ; static const fmtflags left ; static const fmtflags oct ; static const fmtflags right ; static const fmtflags scientific ; static const fmtflags showbase ; static const fmtflags showpoint ; static const fmtflags showpos ; static const fmtflags skipws ; static const fmtflags unitbuf ; static const fmtflags uppercase ; static const fmtflags adjustfield ; static const fmtflags basefield ; static const fmtflags floatfield ; // 27.4.2.1.3 Type ios_base::iostate typedef int iostate; static const iostate badbit ; static const iostate eofbit ; static const iostate failbit ; static const iostate goodbit ; // 27.4.2.1.4 Type openmode typedef int openmode; static const openmode app ; static const openmode ate ; static const openmode binary ; static const openmode in ; static const openmode out ; static const openmode trunc ; // 27.4.2.1.5 Type seekdir typedef int seekdir; static const seekdir beg ; static const seekdir cur ; static const seekdir end ; // Callbacks; enum event { erase_event, imbue_event, copyfmt_event }; typedef void (*event_callback) (event, ios_base&, int); void register_callback(event_callback __fn, int __index); // Fmtflags state: inline fmtflags flags() const ; inline fmtflags flags(fmtflags __fmtfl); inline fmtflags setf(fmtflags __fmtfl); inline fmtflags setf(fmtflags __fmtfl, fmtflags __mask); inline void unsetf(fmtflags __mask) ; inline streamsize precision() const ; inline streamsize precision(streamsize __prec); inline streamsize width() const ; inline streamsize width(streamsize __wide); static bool sync_with_stdio(bool __sync = true); // Locales: locale imbue(const locale& __loc); inline locale getloc() const { return _M_ios_locale; } // Storage: static int xalloc() throw(); inline long& iword(int __ix); inline void*& pword(int __ix); // Destructor ~ios_base(); protected: ios_base(); //50. Copy constructor and assignment operator of ios_base private: ios_base(const ios_base&); ios_base& operator=(const ios_base&); }; template > class basic_ios : public ios_base { public: // Types: typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; public: iostate rdstate() const; void clear(iostate __state = goodbit); void setstate(iostate __state); bool good() const; bool eof() const; bool fail() const; bool bad() const; iostate exceptions() const; void exceptions(iostate __except); // Constructor/destructor: explicit basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base(); virtual ~basic_ios() ; // Members: basic_ostream<_CharT, _Traits>* tie() const; basic_ostream<_CharT, _Traits>* tie(basic_ostream<_CharT, _Traits>* __tiestr); basic_streambuf<_CharT, _Traits>* rdbuf() const; basic_streambuf<_CharT, _Traits>* rdbuf(basic_streambuf<_CharT, _Traits>* __sb); basic_ios& copyfmt(const basic_ios& __rhs); char_type fill() const; char_type fill(char_type __ch); // Locales: locale imbue(const locale& __loc); char narrow(char_type __c, char __dfault) const; char_type widen(char __c) const; protected: // 27.4.5.1 basic_ios constructors basic_ios(); private: ios_base(const ios_base&); ios_base& operator=(const ios_base&); }; } namespace std { %template(ios) basic_ios; #if defined(SWIG_WCHAR) %template(wios) basic_ios; #endif } swig-3.0.2/Lib/std/std_queue.i0000664000175000017500000000666612343605122016031 0ustar williamwilliam/** * @file std_queue.i * @date Sun May 6 01:48:07 2007 * * @brief A wrapping of std::queue for Ruby. * * */ %include // Queue %define %std_queue_methods(queue...) queue(); queue( const _Sequence& ); bool empty() const; size_type size() const; const value_type& front() const; const value_type& back() const; void pop(); void push( const value_type& ); %enddef %define %std_queue_methods_val(queue...) %std_queue_methods(queue) %enddef // ------------------------------------------------------------------------ // std::queue // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::queue), f(const std::queue&): // the parameter being read-only, either a sequence or a // previously wrapped std::queue can be passed. // -- f(std::queue&), f(std::queue*): // the parameter may be modified; therefore, only a wrapped std::queue // can be passed. // -- std::queue f(), const std::queue& f(): // the queue is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::queue& f(), std::queue* f(): // the queue is returned by reference; therefore, a wrapped std::queue // is returned // -- const std::queue* f(), f(const std::queue*): // for consistency, they expect and return a plain queue pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class queue { public: typedef size_t size_type; typedef _Tp value_type; typedef value_type& reference; typedef const value_type& const_reference; typedef _Sequence container_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::queue<_Tp, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdQueueTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::queue<" #_Tp "," #_Sequence " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp, _Sequence >); #ifdef %swig_queue_methods // Add swig/language extra methods %swig_queue_methods(std::queue<_Tp, _Sequence >); #endif %std_queue_methods(queue); }; template class queue<_Tp*, _Sequence > { public: typedef size_t size_type; typedef _Tp value_type; typedef value_type& reference; typedef const value_type& const_reference; typedef _Sequence container_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::queue<_Tp*, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdQueueTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::queue<" #_Tp "," #_Sequence " * >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp*, _Sequence >); #ifdef %swig_queue_methods_val // Add swig/language extra methods %swig_queue_methods_val(std::queue<_Tp*, _Sequence >); #endif %std_queue_methods_val(std::queue<_Tp*, _Sequence >); }; } swig-3.0.2/Lib/std/std_vector.i0000664000175000017500000001401112343605122016166 0ustar williamwilliam// // std::vector // %include // Vector %define %std_vector_methods(vector...) %std_sequence_methods(vector) void reserve(size_type n); size_type capacity() const; %enddef %define %std_vector_methods_val(vector...) %std_sequence_methods_val(vector) void reserve(size_type n); size_type capacity() const; %enddef // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // as much as possible, namely, to allow the user to pass and // be returned tuples or lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&): // the parameter being read-only, either a sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter may be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(), const std::vector& f(): // the vector is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::vector& f(), std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // -- const std::vector* f(), f(const std::vector*): // for consistency, they expect and return a plain vector pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class vector { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %traits_enum(_Tp); %fragment(SWIG_Traits_frag(std::vector<_Tp, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::vector<" #_Tp "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp, _Alloc >); #ifdef %swig_vector_methods // Add swig/language extra methods %swig_vector_methods(std::vector<_Tp, _Alloc >); #endif %std_vector_methods(vector); }; // *** // This specialization should disappear or get simplified when // a 'const SWIGTYPE*&' can be defined // *** template class vector<_Tp*, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::vector<_Tp*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::vector<" #_Tp " *," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp*, _Alloc >); #ifdef %swig_vector_methods_val // Add swig/language extra methods %swig_vector_methods_val(std::vector<_Tp*, _Alloc >); #endif %std_vector_methods_val(vector); }; // *** // const pointer specialization // *** template class vector<_Tp const *, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp const * value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::vector<_Tp const*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::vector<" #_Tp " const*," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp const*, _Alloc >); #ifdef %swig_vector_methods_val // Add swig/language extra methods %swig_vector_methods_val(std::vector<_Tp const*, _Alloc >); #endif %std_vector_methods_val(vector); }; // *** // bool specialization // *** template class vector { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef bool value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(bool); %fragment(SWIG_Traits_frag(std::vector), "header", fragment=SWIG_Traits_frag(bool), fragment="StdVectorTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::vector"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); #ifdef %swig_vector_methods_val // Add swig/language extra methods %swig_vector_methods_val(std::vector); #endif %std_vector_methods_val(vector); #if defined(SWIG_STD_MODERN_STL) && !defined(SWIG_STD_NOMODERN_STL) void flip(); #endif }; } swig-3.0.2/Lib/std/std_string.i0000664000175000017500000000033312343605122016174 0ustar williamwilliam%include /* plain strings */ namespace std { %std_comp_methods(basic_string); %naturalvar string; typedef basic_string string; } %template(string) std::basic_string; swig-3.0.2/Lib/std/std_basic_string.i0000664000175000017500000001453412343605122017345 0ustar williamwilliam%include %include %include %include %fragment(""); namespace std { %naturalvar basic_string; } namespace std { template , typename _Alloc = allocator<_CharT> > class basic_string { #if !defined(SWIG_STD_MODERN_STL) || defined(SWIG_STD_NOMODERN_STL) %ignore push_back; %ignore clear; %ignore compare; %ignore append; #endif public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _CharT value_type; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; static const size_type npos; #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; #endif %traits_swigtype(_CharT); %fragment(SWIG_Traits_frag(_CharT)); basic_string(const _CharT* __s, size_type __n); // Capacity: size_type length() const; size_type max_size() const; size_type capacity() const; void reserve(size_type __res_arg = 0); // Modifiers: basic_string& append(const basic_string& __str); basic_string& append(const basic_string& __str, size_type __pos, size_type __n); basic_string& append(const _CharT* __s, size_type __n); basic_string& append(size_type __n, _CharT __c); basic_string& assign(const basic_string& __str); basic_string& assign(const basic_string& __str, size_type __pos, size_type __n); basic_string& assign(const _CharT* __s, size_type __n); basic_string& insert(size_type __pos1, const basic_string& __str); basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n); basic_string& insert(size_type __pos, const _CharT* __s, size_type __n); basic_string& insert(size_type __pos, size_type __n, _CharT __c); basic_string& erase(size_type __pos = 0, size_type __n = npos); basic_string& replace(size_type __pos, size_type __n, const basic_string& __str); basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2); basic_string& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2); basic_string& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c); size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const; // String operations: const _CharT* c_str() const; size_type find(const _CharT* __s, size_type __pos, size_type __n) const; size_type find(const basic_string& __str, size_type __pos = 0) const; size_type find(_CharT __c, size_type __pos = 0) const; size_type rfind(const basic_string& __str, size_type __pos = npos) const; size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const; size_type rfind(_CharT __c, size_type __pos = npos) const; size_type find_first_of(const basic_string& __str, size_type __pos = 0) const; size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_first_of(_CharT __c, size_type __pos = 0) const; size_type find_last_of(const basic_string& __str, size_type __pos = npos) const; size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_last_of(_CharT __c, size_type __pos = npos) const; size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const; size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_first_not_of(_CharT __c, size_type __pos = 0) const; size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const; size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_last_not_of(_CharT __c, size_type __pos = npos) const; basic_string substr(size_type __pos = 0, size_type __n = npos) const; int compare(const basic_string& __str) const; int compare(size_type __pos, size_type __n, const basic_string& __str) const; int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const; %ignore pop_back(); %ignore front() const; %ignore back() const; %ignore basic_string(size_type n); %std_sequence_methods_val(basic_string); %ignore pop(); #ifdef %swig_basic_string // Add swig/language extra methods %swig_basic_string(std::basic_string<_CharT, _Traits, _Alloc >); #endif #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; void insert(iterator __p, size_type __n, _CharT __c); basic_string& replace(iterator __i1, iterator __i2, const basic_string& __str); basic_string& replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n); basic_string& replace(iterator __i1, iterator __i2, size_type __n, _CharT __c); basic_string& replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2); basic_string& replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2); #endif basic_string& operator +=(const basic_string& v); %newobject __add__; %newobject __radd__; %extend { std::basic_string<_CharT,_Traits,_Alloc >* __add__(const basic_string& v) { std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(*self); *res += v; return res; } std::basic_string<_CharT,_Traits,_Alloc >* __radd__(const basic_string& v) { std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(v); *res += *self; return res; } std::basic_string<_CharT,_Traits,_Alloc > __str__() { return *self; } std::basic_ostream<_CharT, std::char_traits<_CharT> >& __rlshift__(std::basic_ostream<_CharT, std::char_traits<_CharT> >& out) { out << *self; return out; } } }; } swig-3.0.2/Lib/std/std_except.i0000664000175000017500000000215212343605122016157 0ustar williamwilliam#if defined(SWIGJAVA) || defined(SWIGCSHARP) #error "do not use this version of std_except.i" #endif %{ #include %} #if defined(SWIG_STD_EXCEPTIONS_AS_CLASSES) namespace std { struct exception { virtual ~exception() throw(); virtual const char* what() const throw(); }; struct bad_exception : exception { }; struct logic_error : exception { logic_error(const string& msg); }; struct domain_error : logic_error { domain_error(const string& msg); }; struct invalid_argument : logic_error { invalid_argument(const string& msg); }; struct length_error : logic_error { length_error(const string& msg); }; struct out_of_range : logic_error { out_of_range(const string& msg); }; struct runtime_error : exception { runtime_error(const string& msg); }; struct range_error : runtime_error { range_error(const string& msg); }; struct overflow_error : runtime_error { overflow_error(const string& msg); }; struct underflow_error : runtime_error { underflow_error(const string& msg); }; } #endif swig-3.0.2/Lib/std/std_deque.i0000664000175000017500000000666012343605122016002 0ustar williamwilliam// // std::deque %include // Deque %define %std_deque_methods(deque...) %std_sequence_methods(deque) void pop_front(); void push_front(const value_type& x); %enddef %define %std_deque_methods_val(deque...) %std_sequence_methods_val(deque) void pop_front(); void push_front(value_type x); %enddef // ------------------------------------------------------------------------ // std::deque // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::deque), f(const std::deque&): // the parameter being read-only, either a sequence or a // previously wrapped std::deque can be passed. // -- f(std::deque&), f(std::deque*): // the parameter may be modified; therefore, only a wrapped std::deque // can be passed. // -- std::deque f(), const std::deque& f(): // the deque is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::deque& f(), std::deque* f(): // the deque is returned by reference; therefore, a wrapped std::deque // is returned // -- const std::deque* f(), f(const std::deque*): // for consistency, they expect and return a plain deque pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class deque { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::deque<_Tp, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdDequeTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::deque<" #_Tp " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp, _Alloc >); #ifdef %swig_deque_methods // Add swig/language extra methods %swig_deque_methods(std::deque<_Tp, _Alloc >); #endif %std_deque_methods(deque); }; template class deque<_Tp*, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::deque<_Tp*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdDequeTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::deque<" #_Tp " * >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp*, _Alloc >); #ifdef %swig_deque_methods_val // Add swig/language extra methods %swig_deque_methods_val(std::deque<_Tp*, _Alloc >); #endif %std_deque_methods_val(std::deque<_Tp*, _Alloc >); }; } swig-3.0.2/Lib/std/std_wios.i0000664000175000017500000000013212343605122015644 0ustar williamwilliam/* Provide 'std_ios.i' with wchar support. */ %include %include swig-3.0.2/Lib/std/std_unordered_multimap.i0000664000175000017500000000630512343605122020572 0ustar williamwilliam// // std::unordered_multimap // Work in progress - the code is not compilable yet: // operator--() and constructor(compare function) not available for unordered_ // types // %include %define %std_unordered_multimap_methods(mmap...) %std_map_methods_common(mmap); #ifdef SWIG_EXPORT_ITERATOR_METHODS std::pair equal_range(const key_type& x); std::pair equal_range(const key_type& x) const; #endif %enddef // ------------------------------------------------------------------------ // std::unordered_multimap // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::unordered_multimap), f(const std::unordered_multimap&): // the parameter being read-only, either a sequence or a // previously wrapped std::unordered_multimap can be passed. // -- f(std::unordered_multimap&), f(std::unordered_multimap*): // the parameter may be modified; therefore, only a wrapped std::unordered_multimap // can be passed. // -- std::unordered_multimap f(), const std::unordered_multimap& f(): // the map is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::unordered_multimap& f(), std::unordered_multimap* f(): // the map is returned by reference; therefore, a wrapped std::unordered_multimap // is returned // -- const std::unordered_multimap* f(), f(const std::unordered_multimap*): // for consistency, they expect and return a plain map pointer. // ------------------------------------------------------------------------ // exported class namespace std { template, class _Alloc = allocator > > class unordered_multimap { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::unordered_multimap<_Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), fragment="StdMultimapTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::unordered_multimap<_Key, _Tp, _Compare, _Alloc >); unordered_multimap( const _Compare& ); #ifdef %swig_unordered_multimap_methods // Add swig/language extra methods %swig_unordered_multimap_methods(std::unordered_multimap<_Key, _Tp, _Compare, _Alloc >); #endif %std_unordered_multimap_methods(unordered_multimap); }; } swig-3.0.2/Lib/std/std_sstream.i0000664000175000017500000001231312343605122016345 0ustar williamwilliam/* For wchar support, you need to include the wchar.i file before this file, ie: %include %include or equivalently, just include %include */ %include %include %include %include #if defined(SWIG_WCHAR) %include #endif %include %include %{ #include %} namespace std { template, typename _Alloc = allocator<_CharT> > class basic_stringbuf : public basic_streambuf<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: // Constructors: explicit basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out); explicit basic_stringbuf(const basic_string<_CharT, _Traits, _Alloc>& __str, ios_base::openmode __mode = ios_base::in | ios_base::out); // Get and set: basic_string<_CharT, _Traits, _Alloc> str() const; void str(const basic_string<_CharT, _Traits, _Alloc>& __s); }; // 27.7.2 Template class basic_istringstream template, typename _Alloc = allocator<_CharT> > class basic_istringstream : public basic_istream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: // Constructors: explicit basic_istringstream(ios_base::openmode __mode = ios_base::in); explicit basic_istringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, ios_base::openmode __mode = ios_base::in); ~basic_istringstream(); // Members: basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const; basic_string<_CharT, _Traits, _Alloc> str() const; void str(const basic_string<_CharT, _Traits, _Alloc>& __s); }; // 27.7.3 Template class basic_ostringstream template, typename _Alloc = allocator<_CharT> > class basic_ostringstream : public basic_ostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: // Constructors/destructor: explicit basic_ostringstream(ios_base::openmode __mode = ios_base::out); explicit basic_ostringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, ios_base::openmode __mode = ios_base::out); ~basic_ostringstream(); // Members: basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const; basic_string<_CharT, _Traits, _Alloc> str() const; #if 0 void str(const basic_string<_CharT, _Traits, _Alloc>& __s); #endif }; // 27.7.4 Template class basic_stringstream template, typename _Alloc = allocator<_CharT> > class basic_stringstream : public basic_iostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: // Constructors/destructors explicit basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in); explicit basic_stringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, ios_base::openmode __m = ios_base::out | ios_base::in); ~basic_stringstream(); // Members: basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const; basic_string<_CharT, _Traits, _Alloc> str() const; void str(const basic_string<_CharT, _Traits, _Alloc>& __s); }; } // namespace std namespace std { %template(istringstream) basic_istringstream; %template(ostringstream) basic_ostringstream; %template(stringstream) basic_stringstream; #if defined(SWIG_WCHAR) %template(wistringstream) basic_istringstream; %template(wostringstream) basic_ostringstream; %template(wstringstream) basic_stringstream; #endif } swig-3.0.2/Lib/std/std_wstring.i0000664000175000017500000000037112343605122016365 0ustar williamwilliam%include %include /* wide strings */ namespace std { %std_comp_methods(basic_string); %naturalvar wstring; typedef basic_string wstring; } %template(wstring) std::basic_string; swig-3.0.2/Lib/std/std_unordered_multiset.i0000664000175000017500000000567412343605122020620 0ustar williamwilliam// // std::unordered_multiset // Work in progress - the code is not compilable yet: // operator--() and constructor(compare function) not available for unordered_ // types // %include // Unordered Multiset %define %std_unordered_multiset_methods(unordered_multiset...) %std_unordered_set_methods_common(unordered_multiset); %enddef // ------------------------------------------------------------------------ // std::unordered_multiset // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::unordered_multiset), f(const std::unordered_multiset&): // the parameter being read-only, either a sequence or a // previously wrapped std::unordered_multiset can be passed. // -- f(std::unordered_multiset&), f(std::unordered_multiset*): // the parameter may be modified; therefore, only a wrapped std::unordered_multiset // can be passed. // -- std::unordered_multiset f(), const std::unordered_multiset& f(): // the set is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::unordered_multiset& f(), std::unordered_multiset* f(): // the set is returned by reference; therefore, a wrapped std::unordered_multiset // is returned // -- const std::unordered_multiset* f(), f(const std::unordered_multiset*): // for consistency, they expect and return a plain set pointer. // ------------------------------------------------------------------------ // exported classes namespace std { //unordered_multiset template , class _Alloc = allocator<_Key> > class unordered_multiset { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key value_type; typedef _Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %fragment(SWIG_Traits_frag(std::unordered_multiset<_Key, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdMultisetTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_multiset<" #_Key "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::unordered_multiset<_Key, _Compare, _Alloc >); unordered_multiset( const _Compare& ); #ifdef %swig_unordered_multiset_methods // Add swig/language extra methods %swig_unordered_multiset_methods(std::unordered_multiset<_Key, _Compare, _Alloc >); #endif %std_unordered_multiset_methods(unordered_multiset); }; } swig-3.0.2/Lib/std/std_carray.swg0000664000175000017500000000261012343605122016517 0ustar williamwilliam%{ #include %} // // std::carray - is really an extension to the 'std' namespace. // // A simple fix C array wrapper, more or less as presented in // // "The C++ Standarf Library", by Nicolai M. Josuttis // // which is also derived from the example in // // "The C++ Programming Language", by Bjarne Stroustup. // %inline %{ namespace std { template class carray { public: typedef _Type value_type; typedef size_t size_type; typedef _Type * iterator; typedef const _Type * const_iterator; carray() { } carray(const carray& c) { std::copy(c.v, c.v + size(), v); } template carray(_Iterator first, _Iterator last) { assign(first, last); } iterator begin() { return v; } iterator end() { return v + _Size; } const_iterator begin() const { return v; } const_iterator end() const { return v + _Size; } _Type& operator[](size_t i) { return v[i]; } const _Type& operator[](size_t i) const { return v[i]; } static size_t size() { return _Size; } template void assign(_Iterator first, _Iterator last) { if (std::distance(first,last) == size()) { std::copy(first, last, v); } else { throw std::length_error("bad range length"); } } private: _Type v[_Size]; }; } %} swig-3.0.2/Lib/std/std_wsstream.i0000664000175000017500000000014212343605122016531 0ustar williamwilliam/* Provide 'std_sstream.i' with wchar support. */ %include %include swig-3.0.2/Lib/std/std_char_traits.i0000664000175000017500000000616612343605122017203 0ustar williamwilliam%include #if defined(SWIG_WCHAR) %include #endif namespace std { /// 21.1.2 Basis for explicit _Traits specialization /// NB: That for any given actual character type this definition is /// probably wrong. template struct char_traits { }; /// 21.1.4 char_traits specializations template<> struct char_traits { typedef char char_type; typedef int int_type; typedef streampos pos_type; typedef streamoff off_type; typedef mbstate_t state_type; static void assign(char_type& __c1, const char_type& __c2); static bool eq(const char_type& __c1, const char_type& __c2); static bool lt(const char_type& __c1, const char_type& __c2); static int compare(const char_type* __s1, const char_type* __s2, size_t __n); static size_t length(const char_type* __s); static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* assign(char_type* __s, size_t __n, char_type __a); static char_type to_char_type(const int_type& __c); // To keep both the byte 0xff and the eof symbol 0xffffffff // from ending up as 0xffffffff. static int_type to_int_type(const char_type& __c); static bool eq_int_type(const int_type& __c1, const int_type& __c2); static int_type eof() ; static int_type not_eof(const int_type& __c); }; #if defined(SWIG_WCHAR) template<> struct char_traits { typedef wchar_t char_type; typedef wint_t int_type; typedef streamoff off_type; typedef wstreampos pos_type; typedef mbstate_t state_type; static void assign(char_type& __c1, const char_type& __c2); static bool eq(const char_type& __c1, const char_type& __c2); static bool lt(const char_type& __c1, const char_type& __c2); static int compare(const char_type* __s1, const char_type* __s2, size_t __n); static size_t length(const char_type* __s); static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); static char_type* move(char_type* __s1, const char_type* __s2, int_type __n); static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* assign(char_type* __s, size_t __n, char_type __a); static char_type to_char_type(const int_type& __c) ; static int_type to_int_type(const char_type& __c) ; static bool eq_int_type(const int_type& __c1, const int_type& __c2); static int_type eof() ; static int_type not_eof(const int_type& __c); }; #endif } namespace std { #ifndef SWIG_STL_WRAP_TRAITS %template() char_traits; #if defined(SWIG_WCHAR) %template() char_traits; #endif #else %template(char_traits_c) char_traits; #if defined(SWIG_WCHAR) %template(char_traits_w) char_traits; #endif #endif } swig-3.0.2/Lib/cwstring.i0000664000175000017500000000041112343605122015057 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cwstring.i * ----------------------------------------------------------------------------- */ %echo "cwstring.i not implemented for this target" #define SWIG_CWSTRING_UNIMPL swig-3.0.2/Lib/swigwarnings.swg0000664000175000017500000001566612343605122016333 0ustar williamwilliam/* Include the internal swig macro codes. These macros correspond to the one found in Source/Include/swigwarn.h plus the 'SWIG' prefix. For example, in the include file 'swigwarn.h' you will find #define WARN_TYPEMAP_CHARLEAK ... and in the 'swigwarn.swg' interface, you will see %define SWIGWARN_TYPEMAP_CHARLEAK ... This code can be used in warning filters as follows: %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK); Warnings messages used in typemaps. Message names will be the same as those in Lib/swigwarn.swg but with the suffix _MSG. For example, for the code SWIGWARN_TYPEMAP_CHARLEAK, once you use %typemapmsg(CHARLEAK,); you use the message in your typemap as %typemap(varin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) char * while you suppress the warning using %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK); as described above. */ /* ----------------------------------------------------------------------------- * SWIG warning codes * ----------------------------------------------------------------------------- */ %include /* ----------------------------------------------------------------------------- * Auxiliary macros * ----------------------------------------------------------------------------- */ /* Macro to define warning messages */ #define %_warningmsg(Val, Msg...) `Val`":"Msg #define %warningmsg(Val, Msg...) %_warningmsg(Val, Msg) /* ----------------------------------------------------------------------------- * Typemap related warning messages * ----------------------------------------------------------------------------- */ %define SWIGWARN_TYPEMAP_CHARLEAK_MSG "451:Setting a const char * variable may leak memory." %enddef %define SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG "454:Setting a pointer/reference variable may leak memory." %enddef %define SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG "470:Thread/reentrant unsafe wrapping, consider returning by value instead." %enddef %define SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG "473:Returning a pointer or reference in a director method is not recommended." %enddef %define SWIGWARN_TYPEMAP_INITIALIZER_LIST_MSG "476:Initialization using std::initializer_list." %enddef /* ----------------------------------------------------------------------------- * Operator related warning messages * ----------------------------------------------------------------------------- */ %define SWIGWARN_IGNORE_OPERATOR_NEW_MSG "350:operator new ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_DELETE_MSG "351:operator delete ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_PLUS_MSG "352:operator+ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MINUS_MSG "353:operator- ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MUL_MSG "354:operator* ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_DIV_MSG "355:operator/ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MOD_MSG "356:operator% ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_XOR_MSG "357:operator^ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_AND_MSG "358:operator& ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_OR_MSG "359:operator| ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_NOT_MSG "360:operator~ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LNOT_MSG "361:operator! ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_EQ_MSG "362:operator= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LT_MSG "363:operator< ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_GT_MSG "364:operator> ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_PLUSEQ_MSG "365:operator+= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MINUSEQ_MSG "366:operator-= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MULEQ_MSG "367:operator*= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_DIVEQ_MSG "368:operator/= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MODEQ_MSG "369:operator%= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_XOREQ_MSG "370:operator^= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_ANDEQ_MSG "371:operator&= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_OREQ_MSG "372:operator|= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LSHIFT_MSG "373:operator<< ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_RSHIFT_MSG "374:operator>> ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LSHIFTEQ_MSG "375:operator<<= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_RSHIFTEQ_MSG "376:operator>>= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_EQUALTO_MSG "377:operator== ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_NOTEQUAL_MSG "378:operator!= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LTEQUAL_MSG "379:operator<= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_GTEQUAL_MSG "380:operator>= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LAND_MSG "381:operator&& ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LOR_MSG "382:operator|| ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_PLUSPLUS_MSG "383:operator++ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MINUSMINUS_MSG "384:operator-- ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_COMMA_MSG "385:operator-- ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_ARROWSTAR_MSG "386:operator->* ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_ARROW_MSG "387:operator-> ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_CALL_MSG "388:operator() ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_INDEX_MSG "389:operator[] ignored (consider using %%extend)" %enddef %define SWIGWARN_IGNORE_OPERATOR_UPLUS_MSG "390:operator+ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_UMINUS_MSG "391:operator- ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_UMUL_MSG "392:operator* ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_UAND_MSG "393:operator& ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_NEWARR_MSG "394:operator new[] ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_DELARR_MSG "395:operator delete[] ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_REF_MSG "396:operator*() ignored" %enddef #define %ignoreoperator(Oper) %ignorewarn(SWIGWARN_IGNORE_OPERATOR_##Oper##_MSG) /* ----------------------------------------------------------------------------- * Macros for keyword and built-in names * ----------------------------------------------------------------------------- */ #define %keywordwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_KEYWORD, msg)) #define %builtinwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, msg), %$isfunction) /* ----------------------------------------------------------------------------- * Warning filter feature * ----------------------------------------------------------------------------- */ #define %_warnfilter(filter...) %feature("warnfilter",`filter`) #define %warnfilter(filter...) %_warnfilter(filter) swig-3.0.2/Lib/intrusive_ptr.i0000664000175000017500000000537612343605122016153 0ustar williamwilliam// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1 // For example for std::tr1, use: // #define SWIG_SHARED_PTR_NAMESPACE std // #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 // #define SWIG_INTRUSIVE_PTR_NAMESPACE boost // #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE #if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE) # define SWIG_INTRUSIVE_PTR_NAMESPACE boost #endif #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) # define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE #else # define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE #endif namespace SWIG_INTRUSIVE_PTR_NAMESPACE { #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE { #endif template class intrusive_ptr { }; #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) } #endif } %fragment("SWIG_intrusive_deleter", "header") { template struct SWIG_intrusive_deleter { void operator()(T *p) { if (p) intrusive_ptr_release(p); } }; } %fragment("SWIG_null_deleter", "header") { struct SWIG_null_deleter { void operator() (void const *) const { } }; %#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() %#define SWIG_NO_NULL_DELETER_1 } // Workaround empty first macro argument bug #define SWIGEMPTYHACK // Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types %define %intrusive_ptr(TYPE...) %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } SWIG_INTRUSIVE_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE) SWIG_INTRUSIVE_PTR_TYPEMAPS(const, TYPE) %enddef %define %intrusive_ptr_no_wrap(TYPE...) %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(SWIGEMPTYHACK, TYPE) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(const, TYPE) %enddef // Legacy macros %define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...) #warning "SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead." %intrusive_ptr(TYPE) %enddef %define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) #warning "SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead." %intrusive_ptr(TYPE) %enddef %define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...) #warning "SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead." %intrusive_ptr_no_wrap(TYPE) %enddef %define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...) #warning "SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead." %intrusive_ptr_no_wrap(TYPE) %enddef swig-3.0.2/Lib/swiginit.swg0000664000175000017500000001757112343605122015443 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Type initialization: * This problem is tough by the requirement that no dynamic * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back * to swig_type_info structures, we need some lookup code at initialization. * The idea is that swig generates all the structures that are needed. * The runtime then collects these partially filled structures. * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * * The generated swig_type_info structures are assigned statically to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a * two-dimensional array. Each row corresponds to a type (there are the same * number of rows as there are in the swig_type_initial array). Each entry in * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that * swig_cast_info to the linked list (because the cast->type) pointer will * be correct. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #if 0 } /* c-mode */ #endif #endif #if 0 #define SWIGRUNTIME_DEBUG #endif SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; int found, init; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { /* Initialize the swig_module */ swig_module.type_initial = swig_type_initial; swig_module.cast_initial = swig_cast_initial; swig_module.next = &swig_module; init = 1; } else { init = 0; } /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); if (!module_head) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); module_head = &swig_module; } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ found=0; iter=module_head; do { if (iter==&swig_module) { found=1; break; } iter=iter->next; } while (iter!= module_head); /* if the is found in the list, then all is done and we may leave */ if (found) return; /* otherwise we must add out module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ if (init == 0) return; /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ if (swig_module.next != &swig_module) { type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); } if (type) { /* Overwrite clientdata field */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found type %s\n", type->name); #endif if (swig_module.type_initial[i]->clientdata) { type->clientdata = swig_module.type_initial[i]->clientdata; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); #endif } } else { type = swig_module.type_initial[i]; } /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); #endif if (swig_module.next != &swig_module) { ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); #ifdef SWIGRUNTIME_DEBUG if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); #endif } if (ret) { if (type == swig_module.type_initial[i]) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: skip old type %s\n", ret->name); #endif cast->type = ret; ret = 0; } else { /* Check for casting already in the list */ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); #ifdef SWIGRUNTIME_DEBUG if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); #endif if (!ocast) ret = 0; } } if (!ret) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); #endif if (type->cast) { type->cast->prev = cast; cast->next = type->cast; } type->cast = cast; } cast++; } /* Set entry in modules->types array equal to the type */ swig_module.types[i] = type; } swig_module.types[i] = 0; #ifdef SWIGRUNTIME_DEBUG printf("**** SWIG_InitializeModule: Cast List ******\n"); for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; ++j; } printf("---- Total casts: %d\n",j); } printf("**** SWIG_InitializeModule: Cast List ******\n"); #endif } /* This function will propagate the clientdata field of type to * any new swig_type_info structures that have been added into the list * of equivalent types. It is like calling * SWIG_TypeClientData(type, clientdata) a second time. */ SWIGRUNTIME void SWIG_PropagateClientData(void) { size_t i; swig_cast_info *equiv; static int init_run = 0; if (init_run) return; init_run = 1; for (i = 0; i < swig_module.size; i++) { if (swig_module.types[i]->clientdata) { equiv = swig_module.types[i]->cast; while (equiv) { if (!equiv->converter) { if (equiv->type && !equiv->type->clientdata) SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); } equiv = equiv->next; } } } } #ifdef __cplusplus #if 0 { /* c-mode */ #endif } #endif swig-3.0.2/Lib/php/0000775000175000017500000000000012343605122013640 5ustar williamwilliamswig-3.0.2/Lib/php/director.swg0000664000175000017500000001050312343605122016174 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that PHP proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #ifndef SWIG_DIRECTOR_PHP_HEADER_ #define SWIG_DIRECTOR_PHP_HEADER_ #include #include #include /* Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the 'Swig' namespace. This could be useful for multi-modules projects. */ #ifdef SWIG_DIRECTOR_STATIC /* Force anonymous (static) namespace */ #define Swig #endif namespace Swig { /* memory handler */ struct GCItem { virtual ~GCItem() { } virtual int get_own() const { return 0; } }; struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) { } GCItem_var& operator=(GCItem *item) { GCItem *tmp = _item; _item = item; delete tmp; return *this; } ~GCItem_var() { delete _item; } GCItem * operator->() const { return _item; } private: GCItem *_item; }; struct GCItem_Object : GCItem { GCItem_Object(int own) : _own(own) { } virtual ~GCItem_Object() { } int get_own() const { return _own; } private: int _own; }; template struct GCItem_T : GCItem { GCItem_T(Type *ptr) : _ptr(ptr) { } virtual ~GCItem_T() { delete _ptr; } private: Type *_ptr; }; class Director { protected: zval *swig_self; typedef std::map swig_ownership_map; mutable swig_ownership_map swig_owner; #ifdef ZTS // Store the ZTS context so it's available when C++ calls back to PHP. void *** swig_zts_ctx; #endif public: Director(zval *self TSRMLS_DC) : swig_self(self) { TSRMLS_SET_CTX(swig_zts_ctx); } bool swig_is_overridden_method(char *cname, char *lc_fname) { TSRMLS_FETCH_FROM_CTX(swig_zts_ctx); zend_class_entry **ce; zend_function *mptr; if (zend_lookup_class(cname, strlen(cname), &ce TSRMLS_CC) != SUCCESS) { return false; } if (zend_hash_find(&(*ce)->function_table, lc_fname, strlen(lc_fname) + 1, (void **) &mptr) != SUCCESS) { return false; } // common.scope points to the declaring class return strcmp(mptr->common.scope->name, cname); } template void swig_acquire_ownership(Type *vptr) const { if (vptr) { swig_owner[vptr] = new GCItem_T(vptr); } } }; /* base class for director exceptions */ class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(int code, const char *hdr, const char *msg TSRMLS_DC) : swig_msg(hdr) { if (msg[0]) { swig_msg += " "; swig_msg += msg; } SWIG_ErrorCode() = code; SWIG_ErrorMsg() = swig_msg.c_str(); } virtual ~DirectorException() throw() { } const char *what() const throw() { return swig_msg.c_str(); } static void raise(int code, const char *hdr, const char *msg TSRMLS_DC) { throw DirectorException(code, hdr, msg TSRMLS_CC); } }; /* attempt to call a pure virtual method via a director method */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg TSRMLS_DC) : DirectorException(E_ERROR, "SWIG director pure virtual method called", msg TSRMLS_CC) { } static void raise(const char *msg TSRMLS_DC) { throw DirectorPureVirtualException(msg TSRMLS_CC); } }; /* any php exception that occurs during a director method call */ class DirectorMethodException : public DirectorException { public: DirectorMethodException(const char *msg TSRMLS_DC) : DirectorException(E_ERROR, "SWIG director method error", msg TSRMLS_CC) { } static void raise(const char *msg TSRMLS_DC) { throw DirectorMethodException(msg TSRMLS_CC); } }; } // DirectorMethodException() is documented to be callable with no parameters // so use a macro to insert TSRMLS_CC so any ZTS context gets passed. #define DirectorMethodException() DirectorMethodException("" TSRMLS_CC) #endif swig-3.0.2/Lib/php/std_map.i0000664000175000017500000000453512343605122015450 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } bool is_empty() const { return self->empty(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.2/Lib/php/globalvar.i0000664000175000017500000002141112343605122015762 0ustar williamwilliam/* ----------------------------------------------------------------------------- * globalvar.i * * Global variables - add the variable to PHP * ----------------------------------------------------------------------------- */ %typemap(varinit) char *, char [] { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_STRING; if($1) { z_var->value.str.val = estrdup($1); z_var->value.str.len = strlen($1); } else { z_var->value.str.val = 0; z_var->value.str.len = 0; } zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) int, unsigned int, unsigned short, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_LONG; z_var->value.lval = $1; zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) bool { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_BOOL; z_var->value.lval = ($1)?1:0; zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) float, double { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_DOUBLE; z_var->value.dval = $1; zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) char { zval *z_var; char c[2]; MAKE_STD_ZVAL(z_var); c[0] = $1; c[1] = 0; z_var->type = IS_STRING; z_var->value.str.val = estrndup(c, 1); z_var->value.str.len = 1; zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) SWIGTYPE *, SWIGTYPE [] { zval *z_var; MAKE_STD_ZVAL(z_var); SWIG_SetPointerZval(z_var, (void*)$1, $1_descriptor, 0); zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) SWIGTYPE, SWIGTYPE &, SWIGTYPE && { zval *z_var; MAKE_STD_ZVAL(z_var); SWIG_SetPointerZval(z_var, (void*)&$1, $&1_descriptor, 0); zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL); } %typemap(varinit) char [ANY] { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_STRING; if ($1) { /* varinit char [ANY] */ ZVAL_STRINGL(z_var,(char*)$1, $1_dim0, 1); } zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL); } %typemap(varinit, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = emalloc(sizeof($1)); memcpy(p, &$1, sizeof($1)); zval * resource; MAKE_STD_ZVAL(resource); ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL); } %typemap(varin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_long_ex(z_var); if ($1 != ($1_ltype)((*z_var)->value.lval)) { $1 = Z_LVAL_PP(z_var); } } %typemap(varin) bool { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_boolean_ex(z_var); if ($1 != ($1_ltype)((*z_var)->value.lval)) { $1 = Z_LVAL_PP(z_var); } } %typemap(varin) double,float { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_double_ex(z_var); if ($1 != ($1_ltype)((*z_var)->value.dval)) { $1 = Z_DVAL_PP(z_var); } } %typemap(varin) char { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_string_ex(z_var); if ($1 != *((*z_var)->value.str.val)) { $1 = *((*z_var)->value.str.val); } } %typemap(varin) char * { zval **z_var; char *s1; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_string_ex(z_var); s1 = Z_STRVAL_PP(z_var); if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { if (s1) $1 = estrdup(s1); else $1 = NULL; } } %typemap(varin) SWIGTYPE [] { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1) { SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, $owner); } } %typemap(varin) char [ANY] { zval **z_var; char *s1; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); s1 = Z_STRVAL_PP(z_var); if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { if (s1) strncpy($1, s1, $1_dim0); } } %typemap(varin) SWIGTYPE { zval **z_var; $&1_ltype _temp; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if (SWIG_ConvertPtr(*z_var, (void**)&_temp, $&1_descriptor, 0) < 0) { SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor"); } $1 = *($&1_ltype)_temp; } %typemap(varin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE && { zval **z_var; $1_ltype _temp; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if (SWIG_ConvertPtr(*z_var, (void **)&_temp, $1_descriptor, 0) < 0) { SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor"); } $1 = ($1_ltype)_temp; } %typemap(varin, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); void * p = (void*)zend_fetch_resource(*z_var TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr); memcpy(&$1, p, sizeof($1)); } %typemap(varout) int, unsigned int, unsigned short, short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1 != ($1_ltype)((*z_var)->value.lval)) { (*z_var)->value.lval = (long)$1; } } //SAMFIX need to cast zval->type, what if zend-hash_find fails? etc? %typemap(varout) bool { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1 != ($1_ltype)((*z_var)->value.lval)) { (*z_var)->value.lval = (long)$1; } } %typemap(varout) double, float { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1 != ($1_ltype)((*z_var)->value.dval)) { (*z_var)->value.dval = (double)$1; } } %typemap(varout) char { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1 != *((*z_var)->value.str.val)) { char c[2]; efree((*z_var)->value.str.val); c[0] = $1; c[1] = 0; (*z_var)->value.str.val = estrdup(c); } } %typemap(varout) char * { zval **z_var; char *s1; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); s1 = Z_STRVAL_PP(z_var); if((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { if(s1) efree(s1); if($1) { (*z_var)->value.str.val = estrdup($1); (*z_var)->value.str.len = strlen($1) + 1; } else { (*z_var)->value.str.val = 0; (*z_var)->value.str.len = 0; } } } %typemap(varout) SWIGTYPE { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); SWIG_SetPointerZval(*z_var, (void*)&$1, $&1_descriptor, 0); } %typemap(varout) SWIGTYPE [] { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1) SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); } %typemap(varout) char [ANY] { zval **z_var; char *s1; deliberate error cos this code looks bogus to me zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); s1 = Z_STRVAL_PP(z_var); if((s1 == NULL) || strcmp(s1, $1)) { if($1) { (*z_var)->value.str.val = estrdup($1); (*z_var)->value.str.len = strlen($1) + 1; } else { (*z_var)->value.str.val = 0; (*z_var)->value.str.len = 0; } } } %typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE && { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); } %typemap(varout, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = emalloc(sizeof($1)); memcpy(p, &$1, sizeof($1)); zval * resource; MAKE_STD_ZVAL(resource); ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL); } swig-3.0.2/Lib/php/phprun.swg0000664000175000017500000002155512343605122015706 0ustar williamwilliam/* ----------------------------------------------------------------------------- * phprun.swg * * PHP runtime library * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif #include "zend.h" #include "zend_API.h" #include "zend_exceptions.h" #include "php.h" #include "ext/standard/php_string.h" #include /* for abort(), used in generated code. */ #ifdef ZEND_RAW_FENTRY /* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */ # define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_RAW_FENTRY((char*)#ZN, N, A, 0) #else /* This causes warnings from GCC >= 4.2 (assigning a string literal to char*). * But this seems to be unavoidable without directly assuming knowledge of * the structure, which changed between PHP4 and PHP5. */ # define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A) #endif #ifndef Z_SET_ISREF_P /* For PHP < 5.3 */ # define Z_SET_ISREF_P(z) (z)->is_ref = 1 #endif #ifndef Z_SET_REFCOUNT_P /* For PHP < 5.3 */ # define Z_SET_REFCOUNT_P(z, rc) (z)->refcount = (rc) #endif #define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_DOUBLE_CONSTANT(N, V) zend_register_double_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), (char*)(V), strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_CHAR_CONSTANT(N, V) do {\ static char swig_char = (V);\ zend_register_stringl_constant((char*)#N, sizeof(#N), &swig_char, 1, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);\ } while (0) /* These TSRMLS_ stuff should already be defined now, but with older php under redhat are not... */ #ifndef TSRMLS_D #define TSRMLS_D #endif #ifndef TSRMLS_DC #define TSRMLS_DC #endif #ifndef TSRMLS_C #define TSRMLS_C #endif #ifndef TSRMLS_CC #define TSRMLS_CC #endif #ifdef __cplusplus } #endif /* But in fact SWIG_ConvertPtr is the native interface for getting typed pointer values out of zvals. We need the TSRMLS_ macros for when we make PHP type calls later as we handle php resources */ #define SWIG_ConvertPtr(obj,pp,type,flags) SWIG_ZTS_ConvertPtr(obj,pp,type,flags TSRMLS_CC) #define SWIG_fail goto fail static const char *default_error_msg = "Unknown error occurred"; static int default_error_code = E_ERROR; #define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg #define SWIG_PHP_Error(code,msg) do { SWIG_ErrorCode() = code; SWIG_ErrorMsg() = msg; SWIG_fail; } while (0) #define SWIG_contract_assert(expr,msg) \ if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else /* Standard SWIG API */ #define SWIG_GetModule(clientdata) SWIG_Php_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer) /* used to wrap returned objects in so we know whether they are newobject and need freeing, or not */ typedef struct { void * ptr; int newobject; } swig_object_wrapper; /* empty zend destructor for types without one */ static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) { (void)rsrc; } #define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d TSRMLS_CC) #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) static void SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject TSRMLS_DC) { /* * First test for Null pointers. Return those as PHP native NULL */ if (!ptr ) { ZVAL_NULL(z); return; } if (type->clientdata) { swig_object_wrapper *value; if (! (*(int *)(type->clientdata))) zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); value->ptr=ptr; value->newobject=(newobject & 1); if ((newobject & 2) == 0) { /* Just register the pointer as a resource. */ ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); } else { /* * Wrap the resource in an object, the resource will be accessible * via the "_cPtr" member. This is currently only used by * directorin typemaps. */ zval *resource; zend_class_entry **ce = NULL; const char *type_name = type->name+3; /* +3 so: _p_Foo -> Foo */ size_t type_name_len; int result; const char * p; /* Namespace__Foo -> Foo */ /* FIXME: ugly and goes wrong for classes with __ in their names. */ while ((p = strstr(type_name, "__")) != NULL) { type_name = p + 2; } type_name_len = strlen(type_name); MAKE_STD_ZVAL(resource); ZEND_REGISTER_RESOURCE(resource, value, *(int *)(type->clientdata)); if (SWIG_PREFIX_LEN > 0) { char * classname = (char*)emalloc(SWIG_PREFIX_LEN + type_name_len + 1); strcpy(classname, SWIG_PREFIX); strcpy(classname + SWIG_PREFIX_LEN, type_name); result = zend_lookup_class(classname, SWIG_PREFIX_LEN + type_name_len, &ce TSRMLS_CC); efree(classname); } else { result = zend_lookup_class((char *)type_name, type_name_len, &ce TSRMLS_CC); } if (result != SUCCESS) { /* class does not exist */ object_init(z); } else { object_init_ex(z, *ce); } Z_SET_REFCOUNT_P(z, 1); Z_SET_ISREF_P(z); zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL); } return; } zend_error(E_ERROR, "Type: %s not registered with zend",type->name); } /* This pointer conversion routine takes the native pointer p (along with its type name) and converts it by calling appropriate casting functions according to ty. The resultant pointer is returned, or NULL is returned if the pointer can't be cast. Sadly PHP has no API to find a type name from a type id, only from an instance of a resource of the type id, so we have to pass type_name as well. The two functions which might call this are: SWIG_ZTS_ConvertResourcePtr which gets the type name from the resource and the registered zend destructors for which we have one per type each with the type name hard wired in. */ static void * SWIG_ZTS_ConvertResourceData(void * p, const char *type_name, swig_type_info *ty TSRMLS_DC) { swig_cast_info *tc; void *result = 0; if (!ty) { /* They don't care about the target type, so just pass on the pointer! */ return p; } if (! type_name) { /* can't convert p to ptr type ty if we don't know what type p is */ return NULL; } /* convert and cast p from type_name to ptr as ty. */ tc = SWIG_TypeCheck(type_name, ty); if (tc) { int newmemory = 0; result = SWIG_TypeCast(tc, p, &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } return result; } /* This function returns a pointer of type ty by extracting the pointer and type info from the resource in z. z must be a resource. If it fails, NULL is returned. It uses SWIG_ZTS_ConvertResourceData to do the real work. */ static void * SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) { swig_object_wrapper *value; void *p; int type; const char *type_name; value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type); if (type==-1) return NULL; if (flags & SWIG_POINTER_DISOWN) { value->newobject = 0; } p = value->ptr; type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); return SWIG_ZTS_ConvertResourceData(p, type_name, ty TSRMLS_CC); } /* We allow passing of a RESOURCE pointing to the object or an OBJECT whose _cPtr is a resource pointing to the object */ static int SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { if (z == NULL) { *ptr = 0; return 0; } switch (z->type) { case IS_OBJECT: { zval ** _cPtr; if (zend_hash_find(HASH_OF(z),(char*)"_cPtr",sizeof("_cPtr"),(void**)&_cPtr)==SUCCESS) { if ((*_cPtr)->type==IS_RESOURCE) { *ptr = SWIG_ZTS_ConvertResourcePtr(*_cPtr, ty, flags TSRMLS_CC); return (*ptr == NULL ? -1 : 0); } } break; } case IS_RESOURCE: *ptr = SWIG_ZTS_ConvertResourcePtr(z, ty, flags TSRMLS_CC); return (*ptr == NULL ? -1 : 0); case IS_NULL: *ptr = 0; return 0; } return -1; } static char const_name[] = "swig_runtime_data_type_pointer"; static swig_module_info *SWIG_Php_GetModule() { zval *pointer; swig_module_info *ret = 0; TSRMLS_FETCH(); MAKE_STD_ZVAL(pointer); if (zend_get_constant(const_name, sizeof(const_name) - 1, pointer TSRMLS_CC)) { if (pointer->type == IS_LONG) { ret = (swig_module_info *) pointer->value.lval; } } FREE_ZVAL(pointer); return ret; } static void SWIG_Php_SetModule(swig_module_info *pointer) { TSRMLS_FETCH(); REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); } swig-3.0.2/Lib/php/utils.i0000664000175000017500000000505012343605122015152 0ustar williamwilliam %define CONVERT_BOOL_IN(lvar,t,invar) convert_to_boolean_ex(invar); lvar = (t) Z_LVAL_PP(invar); %enddef %define CONVERT_INT_IN(lvar,t,invar) convert_to_long_ex(invar); lvar = (t) Z_LVAL_PP(invar); %enddef %define CONVERT_LONG_LONG_IN(lvar,t,invar) switch ((*(invar))->type) { case IS_DOUBLE: lvar = (t) (*(invar))->value.dval; break; case IS_STRING: { char * endptr; errno = 0; lvar = (t) strtoll((*(invar))->value.str.val, &endptr, 10); if (*endptr && !errno) break; /* FALL THRU */ } default: convert_to_long_ex(invar); lvar = (t) (*(invar))->value.lval; } %enddef %define CONVERT_UNSIGNED_LONG_LONG_IN(lvar,t,invar) switch ((*(invar))->type) { case IS_DOUBLE: lvar = (t) (*(invar))->value.dval; break; case IS_STRING: { char * endptr; errno = 0; lvar = (t) strtoull((*(invar))->value.str.val, &endptr, 10); if (*endptr && !errno) break; /* FALL THRU */ } default: convert_to_long_ex(invar); lvar = (t) (*(invar))->value.lval; } %enddef %define CONVERT_INT_OUT(lvar,invar) lvar = (t) Z_LVAL_PP(invar); %enddef %define CONVERT_FLOAT_IN(lvar,t,invar) convert_to_double_ex(invar); lvar = (t) Z_DVAL_PP(invar); %enddef %define CONVERT_CHAR_IN(lvar,t,invar) convert_to_string_ex(invar); lvar = (t) *Z_STRVAL_PP(invar); %enddef %define CONVERT_STRING_IN(lvar,t,invar) if ((*invar)->type==IS_NULL) { lvar = (t) 0; } else { convert_to_string_ex(invar); lvar = (t) Z_STRVAL_PP(invar); } %enddef %define %pass_by_val( TYPE, CONVERT_IN ) %typemap(in) TYPE %{ CONVERT_IN($1,$1_ltype,$input); %} %typemap(in) const TYPE & ($*1_ltype temp) %{ CONVERT_IN(temp,$*1_ltype,$input); $1 = &temp; %} %typemap(directorout) TYPE %{ CONVERT_IN($result,$1_ltype,&$input); %} %typemap(directorout) const TYPE & ($*1_ltype temp) %{ CONVERT_IN(temp,$*1_ltype,&$input); $result = &temp; %} %enddef %fragment("t_output_helper","header") %{ static void t_output_helper(zval **target, zval *o TSRMLS_DC) { zval *tmp; if ( (*target)->type == IS_ARRAY ) { /* it's already an array, just append */ add_next_index_zval( *target, o ); return; } if ( (*target)->type == IS_NULL ) { REPLACE_ZVAL_VALUE(target,o,1); FREE_ZVAL(o); return; } ALLOC_INIT_ZVAL(tmp); *tmp = **target; zval_copy_ctor(tmp); array_init(*target); add_next_index_zval( *target, tmp); add_next_index_zval( *target, o); } %} swig-3.0.2/Lib/php/std_pair.i0000664000175000017500000000131012343605122015612 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/php/typemaps.i0000664000175000017500000002427112343605122015662 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i. * * SWIG Typemap library for PHP. * * This library provides standard typemaps for modifying SWIG's behavior. * With enough entries in this file, I hope that very few people actually * ever need to write a typemap. * * Define macros to define the following typemaps: * * TYPE *INPUT. Argument is passed in as native variable by value. * TYPE *OUTPUT. Argument is returned as an array from the function call. * TYPE *INOUT. Argument is passed in by value, and out as part of returned list * TYPE *REFERENCE. Argument is passed in as native variable with value * semantics. Variable value is changed with result. * Use like this: * int foo(int *REFERENCE); * * $a = 0; * $rc = foo($a); * * Even though $a looks like it's passed by value, * its value can be changed by foo(). * ----------------------------------------------------------------------------- */ %define BOOL_TYPEMAP(TYPE) %typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp) %{ convert_to_boolean_ex($input); temp = Z_LVAL_PP($input) ? true : false; $1 = &temp; %} %typemap(argout) TYPE *INPUT, TYPE &INPUT ""; %typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp), TYPE &OUTPUT(TYPE temp) "$1 = &temp;"; %typemap(argout,fragment="t_output_helper") TYPE *OUTPUT, TYPE &OUTPUT { zval *o; MAKE_STD_ZVAL(o); ZVAL_BOOL(o,temp$argnum); t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue) %{ convert_to_boolean_ex($input); lvalue = (*$input)->value.lval ? true : false; $1 = &lvalue; %} %typemap(argout) TYPE *REFERENCE, TYPE &REFERENCE %{ (*$arg)->value.lval = lvalue$argnum ? true : false; (*$arg)->type = IS_BOOL; %} %enddef %define DOUBLE_TYPEMAP(TYPE) %typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp) %{ convert_to_double_ex($input); temp = (TYPE) Z_DVAL_PP($input); $1 = &temp; %} %typemap(argout) TYPE *INPUT, TYPE &INPUT ""; %typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp), TYPE &OUTPUT(TYPE temp) "$1 = &temp;"; %typemap(argout,fragment="t_output_helper") TYPE *OUTPUT, TYPE &OUTPUT { zval *o; MAKE_STD_ZVAL(o); ZVAL_DOUBLE(o,temp$argnum); t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (TYPE dvalue), TYPE &REFERENCE (TYPE dvalue) %{ convert_to_double_ex($input); dvalue = (TYPE) (*$input)->value.dval; $1 = &dvalue; %} %typemap(argout) TYPE *REFERENCE, TYPE &REFERENCE %{ $1->value.dval = (double)(lvalue$argnum); $1->type = IS_DOUBLE; %} %enddef %define INT_TYPEMAP(TYPE) %typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp) %{ convert_to_long_ex($input); temp = (TYPE) Z_LVAL_PP($input); $1 = &temp; %} %typemap(argout) TYPE *INPUT, TYPE &INPUT ""; %typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp), TYPE &OUTPUT(TYPE temp) "$1 = &temp;"; %typemap(argout,fragment="t_output_helper") TYPE *OUTPUT, TYPE &OUTPUT { zval *o; MAKE_STD_ZVAL(o); ZVAL_LONG(o,temp$argnum); t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue) %{ convert_to_long_ex($input); lvalue = (TYPE) (*$input)->value.lval; $1 = &lvalue; %} %typemap(argout) TYPE *REFERENCE, TYPE &REFERENCE %{ (*$arg)->value.lval = (long)(lvalue$argnum); (*$arg)->type = IS_LONG; %} %enddef BOOL_TYPEMAP(bool); DOUBLE_TYPEMAP(float); DOUBLE_TYPEMAP(double); INT_TYPEMAP(int); INT_TYPEMAP(short); INT_TYPEMAP(long); INT_TYPEMAP(unsigned int); INT_TYPEMAP(unsigned short); INT_TYPEMAP(unsigned long); INT_TYPEMAP(unsigned char); INT_TYPEMAP(signed char); INT_TYPEMAP(long long); %typemap(argout,fragment="t_output_helper") long long *OUTPUT { zval *o; MAKE_STD_ZVAL(o); if ((long long)LONG_MIN <= temp$argnum && temp$argnum <= (long long)LONG_MAX) { ZVAL_LONG(o, temp$argnum); } else { char temp[256]; sprintf(temp, "%lld", (long long)temp$argnum); ZVAL_STRING(o, temp, 1); } t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (long long lvalue) %{ CONVERT_LONG_LONG_IN(lvalue, long long, $input) $1 = &lvalue; %} %typemap(argout) long long *REFERENCE %{ if ((long long)LONG_MIN <= lvalue$argnum && lvalue$argnum <= (long long)LONG_MAX) { (*$arg)->value.lval = (long)(lvalue$argnum); (*$arg)->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%lld", (long long)lvalue$argnum); ZVAL_STRING((*$arg), temp, 1); } %} %typemap(argout) long long &OUTPUT %{ if ((long long)LONG_MIN <= *arg$argnum && *arg$argnum <= (long long)LONG_MAX) { ($result)->value.lval = (long)(*arg$argnum); ($result)->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%lld", (long long)(*arg$argnum)); ZVAL_STRING($result, temp, 1); } %} INT_TYPEMAP(unsigned long long); %typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT { zval *o; MAKE_STD_ZVAL(o); if (temp$argnum <= (unsigned long long)LONG_MAX) { ZVAL_LONG(o, temp$argnum); } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)temp$argnum); ZVAL_STRING(o, temp, 1); } t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (unsigned long long lvalue) %{ CONVERT_UNSIGNED_LONG_LONG_IN(lvalue, unsigned long long, $input) $1 = &lvalue; %} %typemap(argout) unsigned long long *REFERENCE %{ if (lvalue$argnum <= (unsigned long long)LONG_MAX) { (*$arg)->value.lval = (long)(lvalue$argnum); (*$arg)->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)lvalue$argnum); ZVAL_STRING((*$arg), temp, 1); } %} %typemap(argout) unsigned long long &OUTPUT %{ if (*arg$argnum <= (unsigned long long)LONG_MAX) { ($result)->value.lval = (long)(*arg$argnum); ($result)->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)(*arg$argnum)); ZVAL_STRING($result, temp, 1); } %} %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) signed char *INOUT = signed char *INPUT; %typemap(in) bool &INOUT = bool *INPUT; %typemap(in) float &INOUT = float *INPUT; %typemap(in) double &INOUT = double *INPUT; %typemap(in) int &INOUT = int *INPUT; %typemap(in) short &INOUT = short *INPUT; %typemap(in) long &INOUT = long *INPUT; %typemap(in) long long &INOUT = long long *INPUT; %typemap(in) long long &INPUT = long long *INPUT; %typemap(in) unsigned &INOUT = unsigned *INPUT; %typemap(in) unsigned short &INOUT = unsigned short *INPUT; %typemap(in) unsigned long &INOUT = unsigned long *INPUT; %typemap(in) unsigned char &INOUT = unsigned char *INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long *INPUT; %typemap(in) unsigned long long &INPUT = unsigned long long *INPUT; %typemap(in) signed char &INOUT = signed char *INPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT= double *OUTPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT= long *OUTPUT; %typemap(argout) long long *INOUT= long long *OUTPUT; %typemap(argout) unsigned short *INOUT= unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) signed char *INOUT = signed char *OUTPUT; %typemap(argout) bool &INOUT = bool *OUTPUT; %typemap(argout) float &INOUT = float *OUTPUT; %typemap(argout) double &INOUT= double *OUTPUT; %typemap(argout) int &INOUT = int *OUTPUT; %typemap(argout) short &INOUT = short *OUTPUT; %typemap(argout) long &INOUT= long *OUTPUT; %typemap(argout) long long &INOUT= long long *OUTPUT; %typemap(argout) unsigned short &INOUT= unsigned short *OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char *OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long *OUTPUT; %typemap(argout) signed char &INOUT = signed char *OUTPUT; %typemap(in) char INPUT[ANY] ( char temp[$1_dim0] ) %{ convert_to_string_ex($input); strncpy(temp,Z_LVAL_PP($input),$1_dim0); $1 = temp; %} %typemap(in,numinputs=0) char OUTPUT[ANY] ( char temp[$1_dim0] ) "$1 = temp;"; %typemap(argout,fragment="t_output_helper") char OUTPUT[ANY] { zval *o; MAKE_STD_ZVAL(o); ZVAL_STRINGL(o,temp$argnum,$1_dim0); t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in,numinputs=0) void **OUTPUT (int force), void *&OUTPUT (int force) %{ /* If they pass NULL by reference, make it into a void* This bit should go in arginit if arginit support init-ing scripting args */ if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { /* wasn't a pre/ref/thing, OR anything like an int thing */ SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); } } force=0; if (arg1==NULL) { #ifdef __cplusplus ptr=new $*1_ltype; #else ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); #endif $1=&ptr; /* have to passback arg$arg too */ force=1; } %} %typemap(argout) void **OUTPUT, void *&OUTPUT %{ if (force$argnum) { /* pass back arg$argnum through params ($arg) if we can */ if (!PZVAL_IS_REF(*$arg)) { SWIG_PHP_Error(E_WARNING, "Parameter $argnum of $symname wasn't passed by reference"); } else { SWIG_SetPointerZval(*$arg, (void *) ptr$argnum, $*1_descriptor, 1); } } %} swig-3.0.2/Lib/php/const.i0000664000175000017500000000271312343605122015143 0ustar williamwilliam/* ----------------------------------------------------------------------------- * const.i * * Typemaps for constants * ----------------------------------------------------------------------------- */ %typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE "SWIG_LONG_CONSTANT($symname, $value);"; %typemap(consttab) float, double "SWIG_DOUBLE_CONSTANT($symname, $value);"; %typemap(consttab) char "SWIG_CHAR_CONSTANT($symname, $value);"; %typemap(consttab) char *, const char *, char [], const char [] "SWIG_STRING_CONSTANT($symname, $value);"; %typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { zval *z_var; zend_constant c; size_t len = sizeof("$symname") - 1; MAKE_STD_ZVAL(z_var); SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0); c.value = *z_var; zval_copy_ctor(&c.value); c.name = zend_strndup("$symname", len); c.name_len = len+1; c.flags = CONST_CS | CONST_PERSISTENT; c.module_number = module_number; zend_register_constant( &c TSRMLS_CC ); } /* Handled as a global variable. */ %typemap(consttab) SWIGTYPE (CLASS::*) ""; swig-3.0.2/Lib/php/phpinit.swg0000664000175000017500000000130212343605122016031 0ustar williamwilliam /* ------------------------------------------------------------ * The start of the PHP initialization function * ------------------------------------------------------------ */ %insert(init) "swiginit.swg" %init %{ SWIG_php_minit { SWIG_InitializeModule(0); %} %fragment("swig_php_init_member_ptr2", "header") { #define SWIG_MEMBER_PTR ((char*)"CLASS::*") static void swig_member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { efree(rsrc->ptr); } static int swig_member_ptr = 0; } %fragment("swig_php_init_member_ptr", "init", fragment="swig_php_init_member_ptr2") { swig_member_ptr = zend_register_list_destructors_ex(swig_member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); } swig-3.0.2/Lib/php/std_common.i0000664000175000017500000000044212343605122016154 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; swig-3.0.2/Lib/php/factory.i0000664000175000017500000000604512343605122015466 0ustar williamwilliam/* Implement a more natural wrap for factory methods, for example, if you have: ---- geometry.h -------- struct Geometry { enum GeomType{ POINT, CIRCLE }; virtual ~Geometry() {} virtual int draw() = 0; // // Factory method for all the Geometry objects // static Geometry *create(GeomType i); }; struct Point : Geometry { int draw() { return 1; } double width() { return 1.0; } }; struct Circle : Geometry { int draw() { return 2; } double radius() { return 1.5; } }; // // Factory method for all the Geometry objects // Geometry *Geometry::create(GeomType type) { switch (type) { case POINT: return new Point(); case CIRCLE: return new Circle(); default: return 0; } } ---- geometry.h -------- You can use the %factory with the Geometry::create method as follows: %newobject Geometry::create; %factory(Geometry *Geometry::create, Point, Circle); %include "geometry.h" and Geometry::create will return a 'Point' or 'Circle' instance instead of the plain 'Geometry' type. For example, in python: circle = Geometry.create(Geometry.CIRCLE) r = circle.radius() where circle is a Circle proxy instance. NOTES: remember to fully qualify all the type names and don't use %factory inside a namespace declaration, ie, instead of namespace Foo { %factory(Geometry *Geometry::create, Point, Circle); } use %factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle); */ /* for loop for macro with one argument */ %define %_formacro_1(macro, arg1,...)macro(arg1) #if #__VA_ARGS__ != "__fordone__" %_formacro_1(macro, __VA_ARGS__) #endif %enddef /* for loop for macro with one argument */ %define %formacro_1(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef %define %formacro(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef /* for loop for macro with two arguments */ %define %_formacro_2(macro, arg1, arg2, ...)macro(arg1, arg2) #if #__VA_ARGS__ != "__fordone__" %_formacro_2(macro, __VA_ARGS__) #endif %enddef /* for loop for macro with two arguments */ %define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef %define %_factory_dispatch(Type) if (!dcast) { Type *dobj = dynamic_cast($1); if (dobj) { dcast = 1; SWIG_SetPointerZval(return_value, SWIG_as_voidptr(dobj),$descriptor(Type *), $owner); } }%enddef %define %factory(Method,Types...) %typemap(out) Method { int dcast = 0; %formacro(%_factory_dispatch, Types) if (!dcast) { SWIG_SetPointerZval(return_value, SWIG_as_voidptr($1),$descriptor, $owner); } }%enddef swig-3.0.2/Lib/php/phpkw.swg0000664000175000017500000005206312343605122015521 0ustar williamwilliam/* ----------------------------------------------------------------------------- * phpkw.swg * ----------------------------------------------------------------------------- */ /* Keyword (case insensitive) */ #define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renaming to 'c_" `x` "'",sourcefmt="%(lower)s",rename="c_%s") `x` /* Class (case insensitive) */ #define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, renaming to 'c_" `x` "'",%$isclass,sourcefmt="%(lower)s",rename="c_%s") `x` /* Constant (case insensitive) */ #define PHPBN1a(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "enum conflicts with a built-in constant '"`x`"' in PHP"),%$isenumitem,sourcefmt="%(lower)s") `x` #define PHPBN1b(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "constant conflicts with a built-in constant '"`x`"' in PHP"),%$isconstant,sourcefmt="%(lower)s") `x` %define PHPBN1(X) PHPBN1a(X); PHPBN1b(X) %enddef /* Constant (case sensitive) */ #define PHPBN2a(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "enum conflicts with a built-in constant '"`x`"' in PHP"),%$isenumitem) `x` #define PHPBN2b(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "constant conflicts with a built-in constant '"`x`"' in PHP"),%$isconstant) `x` %define PHPBN2(X) PHPBN2a(X); PHPBN2b(X) %enddef #define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renaming to 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x` /* From: http://php.net/manual/en/reserved.keywords.php * "You cannot use any of the following words as constants, class names, * function or method names. Using them as variable names is generally OK, but * could lead to confusion." */ /* Check is case insensitive - these *MUST* be listed in lower case here */ PHPKW(__halt_compiler); PHPKW(abstract); PHPKW(and); PHPKW(array); PHPKW(as); PHPKW(break); PHPKW(callable); // As of PHP 5.4 PHPKW(case); PHPKW(catch); PHPKW(class); PHPKW(clone); PHPKW(const); PHPKW(continue); PHPKW(declare); PHPKW(default); PHPKW(die); // "Language construct" PHPKW(do); PHPKW(echo); // "Language construct" PHPKW(else); PHPKW(elseif); PHPKW(empty); // "Language construct" PHPKW(enddeclare); PHPKW(endfor); PHPKW(endforeach); PHPKW(endif); PHPKW(endswitch); PHPKW(endwhile); PHPKW(eval); // "Language construct" PHPKW(exit); // "Language construct" PHPKW(extends); PHPKW(final); PHPKW(finally); // As of PHP 5.5 PHPKW(for); PHPKW(foreach); PHPKW(function); PHPKW(global); PHPKW(goto); // As of PHP 5.3 PHPKW(if); PHPKW(implements); PHPKW(include); // "Language construct" PHPKW(include_once); // "Language construct" PHPKW(instanceof); PHPKW(insteadof); // As of PHP 5.4 PHPKW(interface); PHPKW(isset); // "Language construct" PHPKW(list); // "Language construct" PHPKW(namespace); // As of PHP 5.3 PHPKW(new); PHPKW(or); PHPKW(print); // "Language construct" PHPKW(private); PHPKW(protected); PHPKW(public); PHPKW(require); // "Language construct" PHPKW(require_once); // "Language construct" PHPKW(return); // "Language construct" PHPKW(static); PHPKW(switch); PHPKW(throw); PHPKW(trait); // As of PHP 5.4 PHPKW(try); PHPKW(unset); // "Language construct" PHPKW(use); PHPKW(var); PHPKW(while); PHPKW(xor); PHPKW(yield); // As of PHP 5.5 // Compile-time "magic" constants // From: http://php.net/manual/en/reserved.keywords.php // also at: http://php.net/manual/en/language.constants.predefined.php /* These *MUST* be listed in lower case here */ PHPKW(__class__); PHPKW(__dir__); // As of PHP 5.3 PHPKW(__file__); PHPKW(__function__); PHPKW(__line__); PHPKW(__method__); PHPKW(__namespace__); // As of PHP 5.3 PHPKW(__trait__); // As of PHP 5.4 /* We classify these as built-in names since they conflict, but PHP still runs */ /* Predefined case-insensitive constants */ /* These *MUST* be listed in lower case here */ PHPBN1(null); PHPBN1(true); PHPBN1(false); /* "Core Predefined Constants" from http://php.net/manual/en/reserved.constants.php */ /* These are case sensitive */ PHPBN2(PHP_VERSION); PHPBN2(PHP_MAJOR_VERSION); // As of PHP 5.2.7 PHPBN2(PHP_MINOR_VERSION); // As of PHP 5.2.7 PHPBN2(PHP_RELEASE_VERSION); // As of PHP 5.2.7 PHPBN2(PHP_VERSION_ID); // As of PHP 5.2.7 PHPBN2(PHP_EXTRA_VERSION); // As of PHP 5.2.7 PHPBN2(PHP_ZTS); // As of PHP 5.2.7 PHPBN2(PHP_DEBUG); // As of PHP 5.2.7 PHPBN2(PHP_MAXPATHLEN); // As of PHP 5.3.0 PHPBN2(PHP_OS); PHPBN2(PHP_SAPI); PHPBN2(PHP_EOL); // As of PHP 5.0.2 PHPBN2(PHP_INT_MAX); // As of PHP 5.0.5 PHPBN2(PHP_INT_SIZE); // As of PHP 5.0.5 PHPBN2(DEFAULT_INCLUDE_PATH); PHPBN2(PEAR_INSTALL_DIR); PHPBN2(PEAR_EXTENSION_DIR); PHPBN2(PHP_EXTENSION_DIR); PHPBN2(PHP_PREFIX); PHPBN2(PHP_BINDIR); PHPBN2(PHP_BINARY); // As of PHP 5.4 PHPBN2(PHP_MANDIR); // As of PHP 5.3.7 PHPBN2(PHP_LIBDIR); PHPBN2(PHP_DATADIR); PHPBN2(PHP_SYSCONFDIR); PHPBN2(PHP_LOCALSTATEDIR); PHPBN2(PHP_CONFIG_FILE_PATH); PHPBN2(PHP_CONFIG_FILE_SCAN_DIR); PHPBN2(PHP_SHLIB_SUFFIX); PHPBN2(E_ERROR); PHPBN2(E_WARNING); PHPBN2(E_PARSE); PHPBN2(E_NOTICE); PHPBN2(E_CORE_ERROR); PHPBN2(E_CORE_WARNING); PHPBN2(E_COMPILE_ERROR); PHPBN2(E_COMPILE_WARNING); PHPBN2(E_USER_ERROR); PHPBN2(E_USER_WARNING); PHPBN2(E_USER_NOTICE); PHPBN2(E_DEPRECATED); // As of PHP 5.3.0 PHPBN2(E_USER_DEPRECATED); // As of PHP 5.3.0 PHPBN2(E_ALL); PHPBN2(E_STRICT); PHPBN2(__COMPILER_HALT_OFFSET__); // As of PHP 5.1.0 // TRUE, FALSE, NULL are listed on the same page, but are actually // case-insensitive, whereas all the other constants listed there seem to be // case-sensitive, so we handle TRUE, FALSE, NULL in PHPBN1. PHPBN2(PHP_OUTPUT_HANDLER_START); PHPBN2(PHP_OUTPUT_HANDLER_CONT); PHPBN2(PHP_OUTPUT_HANDLER_END); /* These don't actually seem to be set (tested on Linux, I guess they're * Windows only?) */ PHPBN2(PHP_WINDOWS_NT_DOMAIN_CONTROLLER); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_NT_SERVER); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_NT_WORKSTATION); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_BUILD); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_MAJOR); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_MINOR); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_PLATFORM); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_PRODUCTTYPE); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_SP_MAJOR); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_SP_MINOR); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_SUITEMASK); // As of PHP 5.3 /* "Standard Predefined Constants" from http://php.net/manual/en/reserved.constants.php */ PHPBN2(EXTR_OVERWRITE); PHPBN2(EXTR_SKIP); PHPBN2(EXTR_PREFIX_SAME); PHPBN2(EXTR_PREFIX_ALL); PHPBN2(EXTR_PREFIX_INVALID); PHPBN2(EXTR_PREFIX_IF_EXISTS); PHPBN2(EXTR_IF_EXISTS); PHPBN2(SORT_ASC); PHPBN2(SORT_DESC); PHPBN2(SORT_REGULAR); PHPBN2(SORT_NUMERIC); PHPBN2(SORT_STRING); PHPBN2(CASE_LOWER); PHPBN2(CASE_UPPER); PHPBN2(COUNT_NORMAL); PHPBN2(COUNT_RECURSIVE); PHPBN2(ASSERT_ACTIVE); PHPBN2(ASSERT_CALLBACK); PHPBN2(ASSERT_BAIL); PHPBN2(ASSERT_WARNING); PHPBN2(ASSERT_QUIET_EVAL); PHPBN2(CONNECTION_ABORTED); PHPBN2(CONNECTION_NORMAL); PHPBN2(CONNECTION_TIMEOUT); PHPBN2(INI_USER); PHPBN2(INI_PERDIR); PHPBN2(INI_SYSTEM); PHPBN2(INI_ALL); PHPBN2(INI_SCANNER_NORMAL); // As of PHP 5.3 PHPBN2(INI_SCANNER_RAW); // As of PHP 5.3 PHPBN2(M_E); PHPBN2(M_LOG2E); PHPBN2(M_LOG10E); PHPBN2(M_LN2); PHPBN2(M_LN10); PHPBN2(M_PI); PHPBN2(M_PI_2); PHPBN2(M_PI_4); PHPBN2(M_1_PI); PHPBN2(M_2_PI); PHPBN2(M_2_SQRTPI); PHPBN2(M_SQRT2); PHPBN2(M_SQRT1_2); PHPBN2(M_EULER); // As of PHP 5.2 PHPBN2(M_LNPI); // As of PHP 5.2 PHPBN2(M_SQRT3); // As of PHP 5.2 PHPBN2(M_SQRTPI); // As of PHP 5.2 PHPBN2(CRYPT_SALT_LENGTH); PHPBN2(CRYPT_STD_DES); PHPBN2(CRYPT_EXT_DES); PHPBN2(CRYPT_MD5); PHPBN2(CRYPT_BLOWFISH); PHPBN2(DIRECTORY_SEPARATOR); PHPBN2(SEEK_SET); PHPBN2(SEEK_CUR); PHPBN2(SEEK_END); PHPBN2(LOCK_SH); PHPBN2(LOCK_EX); PHPBN2(LOCK_UN); PHPBN2(LOCK_NB); PHPBN2(HTML_SPECIALCHARS); PHPBN2(HTML_ENTITIES); PHPBN2(ENT_COMPAT); PHPBN2(ENT_QUOTES); PHPBN2(ENT_NOQUOTES); PHPBN2(INFO_GENERAL); PHPBN2(INFO_CREDITS); PHPBN2(INFO_CONFIGURATION); PHPBN2(INFO_MODULES); PHPBN2(INFO_ENVIRONMENT); PHPBN2(INFO_VARIABLES); PHPBN2(INFO_LICENSE); PHPBN2(INFO_ALL); PHPBN2(CREDITS_GROUP); PHPBN2(CREDITS_GENERAL); PHPBN2(CREDITS_SAPI); PHPBN2(CREDITS_MODULES); PHPBN2(CREDITS_DOCS); PHPBN2(CREDITS_FULLPAGE); PHPBN2(CREDITS_QA); PHPBN2(CREDITS_ALL); PHPBN2(STR_PAD_LEFT); PHPBN2(STR_PAD_RIGHT); PHPBN2(STR_PAD_BOTH); PHPBN2(PATHINFO_DIRNAME); PHPBN2(PATHINFO_BASENAME); PHPBN2(PATHINFO_EXTENSION); PHPBN2(PATHINFO_FILENAME); // As of PHP 5.2 PHPBN2(PATH_SEPARATOR); PHPBN2(CHAR_MAX); PHPBN2(LC_CTYPE); PHPBN2(LC_NUMERIC); PHPBN2(LC_TIME); PHPBN2(LC_COLLATE); PHPBN2(LC_MONETARY); PHPBN2(LC_ALL); PHPBN2(LC_MESSAGES); PHPBN2(ABDAY_1); PHPBN2(ABDAY_2); PHPBN2(ABDAY_3); PHPBN2(ABDAY_4); PHPBN2(ABDAY_5); PHPBN2(ABDAY_6); PHPBN2(ABDAY_7); PHPBN2(DAY_1); PHPBN2(DAY_2); PHPBN2(DAY_3); PHPBN2(DAY_4); PHPBN2(DAY_5); PHPBN2(DAY_6); PHPBN2(DAY_7); PHPBN2(ABMON_1); PHPBN2(ABMON_2); PHPBN2(ABMON_3); PHPBN2(ABMON_4); PHPBN2(ABMON_5); PHPBN2(ABMON_6); PHPBN2(ABMON_7); PHPBN2(ABMON_8); PHPBN2(ABMON_9); PHPBN2(ABMON_10); PHPBN2(ABMON_11); PHPBN2(ABMON_12); PHPBN2(MON_1); PHPBN2(MON_2); PHPBN2(MON_3); PHPBN2(MON_4); PHPBN2(MON_5); PHPBN2(MON_6); PHPBN2(MON_7); PHPBN2(MON_8); PHPBN2(MON_9); PHPBN2(MON_10); PHPBN2(MON_11); PHPBN2(MON_12); PHPBN2(AM_STR); PHPBN2(PM_STR); PHPBN2(D_T_FMT); PHPBN2(D_FMT); PHPBN2(T_FMT); PHPBN2(T_FMT_AMPM); PHPBN2(ERA); PHPBN2(ERA_YEAR); PHPBN2(ERA_D_T_FMT); PHPBN2(ERA_D_FMT); PHPBN2(ERA_T_FMT); PHPBN2(ALT_DIGITS); PHPBN2(INT_CURR_SYMBOL); PHPBN2(CURRENCY_SYMBOL); PHPBN2(CRNCYSTR); PHPBN2(MON_DECIMAL_POINT); PHPBN2(MON_THOUSANDS_SEP); PHPBN2(MON_GROUPING); PHPBN2(POSITIVE_SIGN); PHPBN2(NEGATIVE_SIGN); PHPBN2(INT_FRAC_DIGITS); PHPBN2(FRAC_DIGITS); PHPBN2(P_CS_PRECEDES); PHPBN2(P_SEP_BY_SPACE); PHPBN2(N_CS_PRECEDES); PHPBN2(N_SEP_BY_SPACE); PHPBN2(P_SIGN_POSN); PHPBN2(N_SIGN_POSN); PHPBN2(DECIMAL_POINT); PHPBN2(RADIXCHAR); PHPBN2(THOUSANDS_SEP); PHPBN2(THOUSEP); PHPBN2(GROUPING); PHPBN2(YESEXPR); PHPBN2(NOEXPR); PHPBN2(YESSTR); PHPBN2(NOSTR); PHPBN2(CODESET); PHPBN2(LOG_EMERG); PHPBN2(LOG_ALERT); PHPBN2(LOG_CRIT); PHPBN2(LOG_ERR); PHPBN2(LOG_WARNING); PHPBN2(LOG_NOTICE); PHPBN2(LOG_INFO); PHPBN2(LOG_DEBUG); PHPBN2(LOG_KERN); PHPBN2(LOG_USER); PHPBN2(LOG_MAIL); PHPBN2(LOG_DAEMON); PHPBN2(LOG_AUTH); PHPBN2(LOG_SYSLOG); PHPBN2(LOG_LPR); PHPBN2(LOG_NEWS); PHPBN2(LOG_UUCP); PHPBN2(LOG_CRON); PHPBN2(LOG_AUTHPRIV); PHPBN2(LOG_LOCAL0); PHPBN2(LOG_LOCAL1); PHPBN2(LOG_LOCAL2); PHPBN2(LOG_LOCAL3); PHPBN2(LOG_LOCAL4); PHPBN2(LOG_LOCAL5); PHPBN2(LOG_LOCAL6); PHPBN2(LOG_LOCAL7); PHPBN2(LOG_PID); PHPBN2(LOG_CONS); PHPBN2(LOG_ODELAY); PHPBN2(LOG_NDELAY); PHPBN2(LOG_NOWAIT); PHPBN2(LOG_PERROR); /* Added in PHP 5.2 */ PHPBN2(PREG_BACKTRACK_LIMIT_ERROR); PHPBN2(PREG_BAD_UTF8_ERROR); PHPBN2(PREG_INTERNAL_ERROR); PHPBN2(PREG_NO_ERROR); PHPBN2(PREG_RECURSION_LIMIT_ERROR); PHPBN2(UPLOAD_ERR_EXTENSION); PHPBN2(STREAM_SHUT_RD); PHPBN2(STREAM_SHUT_WR); PHPBN2(STREAM_SHUT_RDWR); PHPBN2(CURLE_FILESIZE_EXCEEDED); PHPBN2(CURLE_FTP_SSL_FAILED); PHPBN2(CURLE_LDAP_INVALID_URL); PHPBN2(CURLFTPAUTH_DEFAULT); PHPBN2(CURLFTPAUTH_SSL); PHPBN2(CURLFTPAUTH_TLS); PHPBN2(CURLFTPSSL_ALL); PHPBN2(CURLFTPSSL_CONTROL); PHPBN2(CURLFTPSSL_NONE); PHPBN2(CURLFTPSSL_TRY); PHPBN2(CURLOPT_FTP_SSL); PHPBN2(CURLOPT_FTPSSLAUTH); PHPBN2(CURLOPT_TCP_NODELAY); // Added in PHP 5.2.1 PHPBN2(CURLOPT_TIMEOUT_MS); // Added in PHP 5.2.3 PHPBN2(CURLOPT_CONNECTTIMEOUT_MS); // Added in PHP 5.2.3 PHPBN2(GMP_VERSION); // Added in PHP 5.2.2 PHPBN2(SWFTEXTFIELD_USEFONT); PHPBN2(SWFTEXTFIELD_AUTOSIZE); PHPBN2(SWF_SOUND_NOT_COMPRESSED); PHPBN2(SWF_SOUND_ADPCM_COMPRESSED); PHPBN2(SWF_SOUND_MP3_COMPRESSED); PHPBN2(SWF_SOUND_NOT_COMPRESSED_LE); PHPBN2(SWF_SOUND_NELLY_COMPRESSED); PHPBN2(SWF_SOUND_5KHZ); PHPBN2(SWF_SOUND_11KHZ); PHPBN2(SWF_SOUND_22KHZ); PHPBN2(SWF_SOUND_44KHZ); PHPBN2(SWF_SOUND_8BITS); PHPBN2(SWF_SOUND_16BITS); PHPBN2(SWF_SOUND_MONO); PHPBN2(SWF_SOUND_STEREO); PHPBN2(OPENSSL_VERSION_NUMBER); PHPBN2(SNMP_OID_OUTPUT_FULL); PHPBN2(SNMP_OID_OUTPUT_NUMERIC); PHPBN2(MSG_EAGAIN); PHPBN2(MSG_ENOMSG); /* Added in PHP 5.3 */ PHPBN2(CURLOPT_PROGRESSFUNCTION); PHPBN2(IMG_FILTER_PIXELATE); PHPBN2(JSON_ERROR_CTRL_CHAR); PHPBN2(JSON_ERROR_DEPTH); PHPBN2(JSON_ERROR_NONE); PHPBN2(JSON_ERROR_STATE_MISMATCH); PHPBN2(JSON_ERROR_SYNTAX); PHPBN2(JSON_FORCE_OBJECT); PHPBN2(JSON_HEX_TAG); PHPBN2(JSON_HEX_AMP); PHPBN2(JSON_HEX_APOS); PHPBN2(JSON_HEX_QUOT); PHPBN2(LDAP_OPT_NETWORK_TIMEOUT); PHPBN2(LIBXML_LOADED_VERSION); PHPBN2(PREG_BAD_UTF8_OFFSET_ERROR); PHPBN2(BUS_ADRALN); PHPBN2(BUS_ADRERR); PHPBN2(BUS_OBJERR); PHPBN2(CLD_CONTIUNED); PHPBN2(CLD_DUMPED); PHPBN2(CLD_EXITED); PHPBN2(CLD_KILLED); PHPBN2(CLD_STOPPED); PHPBN2(CLD_TRAPPED); PHPBN2(FPE_FLTDIV); PHPBN2(FPE_FLTINV); PHPBN2(FPE_FLTOVF); PHPBN2(FPE_FLTRES); PHPBN2(FPE_FLTSUB); PHPBN2(FPE_FLTUND); PHPBN2(FPE_INTDIV); PHPBN2(FPE_INTOVF); PHPBN2(ILL_BADSTK); PHPBN2(ILL_COPROC); PHPBN2(ILL_ILLADR); PHPBN2(ILL_ILLOPC); PHPBN2(ILL_ILLOPN); PHPBN2(ILL_ILLTRP); PHPBN2(ILL_PRVOPC); PHPBN2(ILL_PRVREG); PHPBN2(POLL_ERR); PHPBN2(POLL_HUP); PHPBN2(POLL_IN); PHPBN2(POLL_MSG); PHPBN2(POLL_OUT); PHPBN2(POLL_PRI); PHPBN2(SEGV_ACCERR); PHPBN2(SEGV_MAPERR); PHPBN2(SI_ASYNCIO); PHPBN2(SI_KERNEL); PHPBN2(SI_MESGQ); PHPBN2(SI_NOINFO); PHPBN2(SI_QUEUE); PHPBN2(SI_SIGIO); PHPBN2(SI_TIMER); PHPBN2(SI_TKILL); PHPBN2(SI_USER); PHPBN2(SIG_BLOCK); PHPBN2(SIG_SETMASK); PHPBN2(SIG_UNBLOCK); PHPBN2(TRAP_BRKPT); PHPBN2(TRAP_TRACE); /* Added in PHP 5.4 */ PHPBN2(ENT_DISALLOWED); PHPBN2(ENT_HTML401); PHPBN2(ENT_HTML5); PHPBN2(ENT_SUBSTITUTE); PHPBN2(ENT_XML1); PHPBN2(ENT_XHTML); PHPBN2(IPPROTO_IP); PHPBN2(IPPROTO_IPV6); PHPBN2(IPV6_MULTICAST_HOPS); PHPBN2(IPV6_MULTICAST_IF); PHPBN2(IPV6_MULTICAST_LOOP); PHPBN2(IP_MULTICAST_IF); PHPBN2(IP_MULTICAST_LOOP); PHPBN2(IP_MULTICAST_TTL); PHPBN2(MCAST_JOIN_GROUP); PHPBN2(MCAST_LEAVE_GROUP); PHPBN2(MCAST_BLOCK_SOURCE); PHPBN2(MCAST_UNBLOCK_SOURCE); PHPBN2(MCAST_JOIN_SOURCE_GROUP); PHPBN2(MCAST_LEAVE_SOURCE_GROUP); PHPBN2(CURLOPT_MAX_RECV_SPEED_LARGE); PHPBN2(CURLOPT_MAX_SEND_SPEED_LARGE); PHPBN2(LIBXML_HTML_NODEFDTD); PHPBN2(LIBXML_HTML_NOIMPLIED); PHPBN2(LIBXML_PEDANTIC); PHPBN2(OPENSSL_CIPHER_AES_128_CBC); PHPBN2(OPENSSL_CIPHER_AES_192_CBC); PHPBN2(OPENSSL_CIPHER_AES_256_CBC); PHPBN2(OPENSSL_RAW_DATA); PHPBN2(OPENSSL_ZERO_PADDING); PHPBN2(PHP_OUTPUT_HANDLER_CLEAN); PHPBN2(PHP_OUTPUT_HANDLER_CLEANABLE); PHPBN2(PHP_OUTPUT_HANDLER_DISABLED); PHPBN2(PHP_OUTPUT_HANDLER_FINAL); PHPBN2(PHP_OUTPUT_HANDLER_FLUSH); PHPBN2(PHP_OUTPUT_HANDLER_FLUSHABLE); PHPBN2(PHP_OUTPUT_HANDLER_REMOVABLE); PHPBN2(PHP_OUTPUT_HANDLER_STARTED); PHPBN2(PHP_OUTPUT_HANDLER_STDFLAGS); PHPBN2(PHP_OUTPUT_HANDLER_WRITE); PHPBN2(PHP_SESSION_ACTIVE); PHPBN2(PHP_SESSION_DISABLED); PHPBN2(PHP_SESSION_NONE); PHPBN2(STREAM_META_ACCESS); PHPBN2(STREAM_META_GROUP); PHPBN2(STREAM_META_GROUP_NAME); PHPBN2(STREAM_META_OWNER); PHPBN2(STREAM_META_OWNER_NAME); PHPBN2(STREAM_META_TOUCH); PHPBN2(ZLIB_ENCODING_DEFLATE); PHPBN2(ZLIB_ENCODING_GZIP); PHPBN2(ZLIB_ENCODING_RAW); PHPBN2(U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR); PHPBN2(IDNA_CHECK_BIDI); PHPBN2(IDNA_CHECK_CONTEXTJ); PHPBN2(IDNA_NONTRANSITIONAL_TO_ASCII); PHPBN2(IDNA_NONTRANSITIONAL_TO_UNICODE); PHPBN2(INTL_IDNA_VARIANT_2003); PHPBN2(INTL_IDNA_VARIANT_UTS46); PHPBN2(IDNA_ERROR_EMPTY_LABEL); PHPBN2(IDNA_ERROR_LABEL_TOO_LONG); PHPBN2(IDNA_ERROR_DOMAIN_NAME_TOO_LONG); PHPBN2(IDNA_ERROR_LEADING_HYPHEN); PHPBN2(IDNA_ERROR_TRAILING_HYPHEN); PHPBN2(IDNA_ERROR_HYPHEN_3_4); PHPBN2(IDNA_ERROR_LEADING_COMBINING_MARK); PHPBN2(IDNA_ERROR_DISALLOWED); PHPBN2(IDNA_ERROR_PUNYCODE); PHPBN2(IDNA_ERROR_LABEL_HAS_DOT); PHPBN2(IDNA_ERROR_INVALID_ACE_LABEL); PHPBN2(IDNA_ERROR_BIDI); PHPBN2(IDNA_ERROR_CONTEXTJ); PHPBN2(JSON_PRETTY_PRINT); PHPBN2(JSON_UNESCAPED_SLASHES); PHPBN2(JSON_NUMERIC_CHECK); PHPBN2(JSON_UNESCAPED_UNICODE); PHPBN2(JSON_BIGINT_AS_STRING); /* Added in PHP 5.5 */ PHPBN2(IMG_AFFINE_TRANSLATE); PHPBN2(IMG_AFFINE_SCALE); PHPBN2(IMG_AFFINE_ROTATE); PHPBN2(IMG_AFFINE_SHEAR_HORIZONTAL); PHPBN2(IMG_AFFINE_SHEAR_VERTICAL); PHPBN2(IMG_CROP_DEFAULT); PHPBN2(IMG_CROP_TRANSPARENT); PHPBN2(IMG_CROP_BLACK); PHPBN2(IMG_CROP_WHITE); PHPBN2(IMG_CROP_SIDES); PHPBN2(IMG_FLIP_BOTH); PHPBN2(IMG_FLIP_HORIZONTAL); PHPBN2(IMG_FLIP_VERTICAL); PHPBN2(IMG_BELL); PHPBN2(IMG_BESSEL); PHPBN2(IMG_BICUBIC); PHPBN2(IMG_BICUBIC_FIXED); PHPBN2(IMG_BLACKMAN); PHPBN2(IMG_BOX); PHPBN2(IMG_BSPLINE); PHPBN2(IMG_CATMULLROM); PHPBN2(IMG_GAUSSIAN); PHPBN2(IMG_GENERALIZED_CUBIC); PHPBN2(IMG_HERMITE); PHPBN2(IMG_HAMMING); PHPBN2(IMG_HANNING); PHPBN2(IMG_MITCHELL); PHPBN2(IMG_POWER); PHPBN2(IMG_QUADRATIC); PHPBN2(IMG_SINC); PHPBN2(IMG_NEAREST_NEIGHBOUR); PHPBN2(IMG_WEIGHTED4); PHPBN2(IMG_TRIANGLE); PHPBN2(JSON_ERROR_RECURSION); PHPBN2(JSON_ERROR_INF_OR_NAN); PHPBN2(JSON_ERROR_UNSUPPORTED_TYPE); PHPBN2(MYSQLI_SERVER_PUBLIC_KEY); /* Added in PHP 5.6 */ PHPBN2(LDAP_ESCAPE_DN); PHPBN2(LDAP_ESCAPE_FILTER); /* Class names reserved by PHP (case insensitive) */ PHPCN(directory); PHPCN(stdclass); PHPCN(__php_incomplete_class); /* Added in PHP5. */ PHPCN(exception); PHPCN(errorexception); // As of PHP 5.1 PHPCN(php_user_filter); PHPCN(closure); // As of PHP 5.3 PHPCN(generator); // As of PHP 5.5 PHPCN(self); PHPCN(static); PHPCN(parent); /* From extensions (which of these are actually predefined depends which * extensions are loaded by default). */ PHPCN(xmlwriter); PHPCN(libxmlerror); PHPCN(simplexmlelement); PHPCN(soapclient); PHPCN(soapvar); PHPCN(soapserver); PHPCN(soapfault); PHPCN(soapparam); PHPCN(soapheader); PHPCN(recursiveiteratoriterator); PHPCN(filteriterator); PHPCN(recursivefilteriterator); PHPCN(parentiterator); PHPCN(limititerator); PHPCN(cachingiterator); PHPCN(recursivecachingiterator); PHPCN(iteratoriterator); PHPCN(norewinditerator); PHPCN(appenditerator); PHPCN(infiniteiterator); PHPCN(emptyiterator); PHPCN(arrayobject); PHPCN(arrayiterator); PHPCN(recursivearrayiterator); PHPCN(splfileinfo); PHPCN(directoryiterator); PHPCN(recursivedirectoryiterator); PHPCN(splfileobject); PHPCN(spltempfileobject); PHPCN(simplexmliterator); PHPCN(logicexception); PHPCN(badfunctioncallexception); PHPCN(badmethodcallexception); PHPCN(domainexception); PHPCN(invalidargumentexception); PHPCN(lengthexception); PHPCN(outofrangeexception); PHPCN(runtimeexception); PHPCN(outofboundsexception); PHPCN(overflowexception); PHPCN(rangeexception); PHPCN(underflowexception); PHPCN(unexpectedvalueexception); PHPCN(splobjectstorage); PHPCN(reflectionexception); PHPCN(reflection); PHPCN(reflectionfunction); PHPCN(reflectionparameter); PHPCN(reflectionmethod); PHPCN(reflectionclass); PHPCN(reflectionobject); PHPCN(reflectionproperty); PHPCN(reflectionextension); PHPCN(domexception); PHPCN(domstringlist); PHPCN(domnamelist); PHPCN(domimplementationlist); PHPCN(domimplementationsource); PHPCN(domimplementation); PHPCN(domnode); PHPCN(domnamespacenode); PHPCN(domdocumentfragment); PHPCN(domdocument); PHPCN(domnodelist); PHPCN(domnamednodemap); PHPCN(domcharacterdata); PHPCN(domattr); PHPCN(domelement); PHPCN(domtext); PHPCN(domcomment); PHPCN(domtypeinfo); PHPCN(domuserdatahandler); PHPCN(domdomerror); PHPCN(domerrorhandler); PHPCN(domlocator); PHPCN(domconfiguration); PHPCN(domcdatasection); PHPCN(domdocumenttype); PHPCN(domnotation); PHPCN(domentity); PHPCN(domentityreference); PHPCN(domprocessinginstruction); PHPCN(domstringextend); PHPCN(domxpath); PHPCN(xmlreader); PHPCN(sqlitedatabase); PHPCN(sqliteresult); PHPCN(sqliteunbuffered); PHPCN(sqliteexception); PHPCN(datetime); /* Built-in PHP functions (incomplete). */ /* Includes Array Functions - http://php.net/manual/en/ref.array.php */ /* Check is case insensitive - these *MUST* be listed in lower case here */ PHPFN(acos); PHPFN(array_change_key_case); PHPFN(array_chunk); PHPFN(array_column); PHPFN(array_combine); PHPFN(array_count_values); PHPFN(array_diff); PHPFN(array_diff_assoc); PHPFN(array_diff_key); PHPFN(array_diff_uassoc); PHPFN(array_diff_ukey); PHPFN(array_fill); PHPFN(array_fill_keys); PHPFN(array_filter); PHPFN(array_flip); PHPFN(array_intersect); PHPFN(array_intersect_assoc); PHPFN(array_intersect_key); PHPFN(array_intersect_uassoc); PHPFN(array_intersect_ukey); PHPFN(array_key_exists); PHPFN(array_keys); PHPFN(array_map); PHPFN(array_merge); PHPFN(array_merge_recursive); PHPFN(array_multisort); PHPFN(array_pad); PHPFN(array_pop); PHPFN(array_product); PHPFN(array_push); PHPFN(array_rand); PHPFN(array_reduce); PHPFN(array_replace); PHPFN(array_replace_recursive); PHPFN(array_reverse); PHPFN(array_search); PHPFN(array_shift); PHPFN(array_slice); PHPFN(array_splice); PHPFN(array_sum); PHPFN(array_udiff); PHPFN(array_udiff_assoc); PHPFN(array_udiff_uassoc); PHPFN(array_uintersect); PHPFN(array_uintersect_assoc); PHPFN(array_uintersect_uassoc); PHPFN(array_unique); PHPFN(array_unshift); PHPFN(array_values); PHPFN(array_walk); PHPFN(array_walk_recursive); PHPFN(arsort); PHPFN(asin); PHPFN(asort); PHPFN(atan); PHPFN(atan2); PHPFN(ceil); PHPFN(compact); PHPFN(cos); PHPFN(cosh); PHPFN(count); PHPFN(current); PHPFN(each); PHPFN(end); PHPFN(exp); PHPFN(extract); PHPFN(floor); PHPFN(fmod); PHPFN(in_array); PHPFN(key); PHPFN(key_exists); PHPFN(krsort); PHPFN(ksort); PHPFN(log); PHPFN(log10); PHPFN(max); PHPFN(min); PHPFN(natcasesort); PHPFN(natsort); PHPFN(next); PHPFN(pos); PHPFN(pow); PHPFN(prev); PHPFN(range); PHPFN(reset); PHPFN(rsort); PHPFN(shuffle); PHPFN(sin); PHPFN(sinh); PHPFN(sizeof); PHPFN(sort); PHPFN(sqrt); PHPFN(tan); PHPFN(tanh); PHPFN(uasort); PHPFN(uksort); PHPFN(usort); #undef PHPKW #undef PHPBN1a #undef PHPBN1b #undef PHPBN1 #undef PHPBN2a #undef PHPBN2b #undef PHPBN2 #undef PHPCN #undef PHPFN swig-3.0.2/Lib/php/std_vector.i0000664000175000017500000000526012343605122016171 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %include %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); void clear(); %rename(push) push_back; void push_back(const value_type& x); %extend { bool is_empty() const { return $self->empty(); } T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); void clear(); %rename(push) push_back; void push_back(const value_type& x); %extend { bool is_empty() const { return $self->empty(); } bool pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); bool x = self->back(); self->pop_back(); return x; } bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i %{ #include %} namespace std { %naturalvar string; class string; %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string, const string& %{ $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; %} %typemap(in) string %{ convert_to_string_ex($input); $1.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); %} %typemap(directorout) string %{ convert_to_string_ex(&$input); $result.assign(Z_STRVAL_P($input), Z_STRLEN_P($input)); %} %typemap(out) string %{ ZVAL_STRINGL($result, const_cast($1.data()), $1.size(), 1); %} %typemap(directorin) string, const string& %{ ZVAL_STRINGL($input, const_cast($1.data()), $1.size(), 1); %} %typemap(out) const string & %{ ZVAL_STRINGL($result, const_cast($1->data()), $1->size(), 1); %} %typemap(throws) string, const string& %{ zend_throw_exception(NULL, const_cast($1.c_str()), 0 TSRMLS_CC); return; %} /* These next two handle a function which takes a non-const reference to * a std::string and modifies the string. */ %typemap(in) string & ($*1_ltype temp) %{ convert_to_string_ex($input); temp.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); $1 = &temp; %} %typemap(directorout) string & ($*1_ltype *temp) %{ convert_to_string_ex(&$input); temp = new $*1_ltype(Z_STRVAL_P($input), Z_STRLEN_P($input)); swig_acquire_ownership(temp); $result = temp; %} %typemap(argout) string & %{ ZVAL_STRINGL(*($input), const_cast($1->data()), $1->size(), 1); %} /* SWIG will apply the non-const typemap above to const string& without * this more specific typemap. */ %typemap(argout) const string & ""; } swig-3.0.2/Lib/php/phppointers.i0000664000175000017500000000273412343605122016373 0ustar williamwilliam%define %pass_by_ref( TYPE, CONVERT_IN, CONVERT_OUT ) %typemap(in, byref=1) TYPE *REF ($*1_ltype tmp), TYPE &REF ($*1_ltype tmp) %{ /* First Check for SWIG wrapped type */ if ( ZVAL_IS_NULL( *$input ) ) { $1 = 0; } else if ( PZVAL_IS_REF( *$input ) ) { /* Not swig wrapped type, so we check if it's a PHP reference type */ CONVERT_IN( tmp, $*1_ltype, $input ); $1 = &tmp; } else { SWIG_PHP_Error( E_ERROR, SWIG_PHP_Arg_Error_Msg($argnum, Expected a reference) ); } %} %typemap(argout) TYPE *REF, TYPE &REF "CONVERT_OUT(*$input, tmp$argnum );"; %enddef %pass_by_ref( size_t, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( signed int, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( int, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( unsigned int, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( signed short, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( short, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( unsigned short, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( signed long, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( long, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( unsigned long, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( signed char, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( char, CONVERT_CHAR_IN, ZVAL_STRING ); %pass_by_ref( unsigned char, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( float, CONVERT_FLOAT_IN, ZVAL_DOUBLE ); %pass_by_ref( double, CONVERT_FLOAT_IN, ZVAL_DOUBLE ); %pass_by_ref( char *, CONVERT_CHAR_IN, ZVAL_STRING ); swig-3.0.2/Lib/php/stl.i0000664000175000017500000000054512343605122014620 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/php/std_deque.i0000664000175000017500000000003412343605122015764 0ustar williamwilliam%include swig-3.0.2/Lib/php/php.swg0000664000175000017500000003277212343605122015164 0ustar williamwilliam/* ----------------------------------------------------------------------------- * php.swg * * PHP configuration file * ----------------------------------------------------------------------------- */ %runtime "swigrun.swg" // Common C API type-checking code %runtime "phprun.swg" // PHP runtime functions %include // PHP initialization routine. %include // Global variables. %include // use %init %{ "/*code goes here*/ " %} // or %minit %{ "/* code goes here*/ " %} to // insert code in the PHP_MINIT_FUNCTION #define %minit %insert("init") // use %rinit %{ "/* code goes here*/ " %} to // insert code in the PHP_RINIT_FUNCTION #define %rinit %insert("rinit") // use %shutdown %{ " /*code goes here*/ " %} to // insert code in the PHP_MSHUTDOWN_FUNCTION #define %shutdown %insert("shutdown") #define %mshutdown %insert("shutdown") // use %rshutdown %{ " /*code goes here*/" %} to // insert code in the PHP_RSHUTDOWN_FUNCTION #define %rshutdown %insert("rshutdown") /* Typemaps for input parameters by value */ %include %pass_by_val(bool,CONVERT_BOOL_IN); %pass_by_val(size_t, CONVERT_INT_IN); %pass_by_val(enum SWIGTYPE, CONVERT_INT_IN); %pass_by_val(signed int, CONVERT_INT_IN); %pass_by_val(int,CONVERT_INT_IN); %pass_by_val(unsigned int,CONVERT_INT_IN); %pass_by_val(signed short, CONVERT_INT_IN); %pass_by_val(short,CONVERT_INT_IN); %pass_by_val(unsigned short, CONVERT_INT_IN); %pass_by_val(signed long, CONVERT_INT_IN); %pass_by_val(long, CONVERT_INT_IN); %pass_by_val(unsigned long, CONVERT_INT_IN); %pass_by_val(signed long long, CONVERT_LONG_LONG_IN); %pass_by_val(long long, CONVERT_LONG_LONG_IN); %pass_by_val(unsigned long long, CONVERT_UNSIGNED_LONG_LONG_IN); %pass_by_val(signed char, CONVERT_INT_IN); %pass_by_val(char, CONVERT_CHAR_IN); %pass_by_val(unsigned char, CONVERT_INT_IN); %pass_by_val(float, CONVERT_FLOAT_IN); %pass_by_val(double, CONVERT_FLOAT_IN); %pass_by_val(char *, CONVERT_STRING_IN); %typemap(in) char *& = const char *&; %typemap(directorout) char *& = const char *&; // char array can be in/out, though the passed string may not be big enough... // so we have to size it %typemap(in) char[ANY] { convert_to_string_ex($input); $1 = ($1_ltype) Z_STRVAL_PP($input); } %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { convert_to_string_ex($input); $1 = ($1_ltype) Z_STRVAL_PP($input); $2 = ($2_ltype) Z_STRLEN_PP($input); } /* Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_ltype tmp) { if(SWIG_ConvertPtr(*$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); } $1 = *tmp; } %typemap(directorout) SWIGTYPE ($&1_ltype tmp) { if(SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); } $result = *tmp; } %typemap(in) SWIGTYPE *, SWIGTYPE [] { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); } } %typemap(in) SWIGTYPE & { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); } } %typemap(in) SWIGTYPE && { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); } } %typemap(in) SWIGTYPE *const& ($*ltype temp) { if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor"); } $1 = ($1_ltype)&temp; } %typemap(in) SWIGTYPE *DISOWN { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); } } %typemap(argout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE &&; %typemap(in) void * { if(SWIG_ConvertPtr(*$input, (void **) &$1, 0, 0) < 0) { /* Allow NULL from php for void* */ if ((*$input)->type==IS_NULL) $1=0; else SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); } } /* Special case when void* is passed by reference so it can be made to point to opaque api structs */ %typemap(in) void ** ($*1_ltype ptr, int force), void *& ($*1_ltype ptr, int force) { /* If they pass NULL by reference, make it into a void* This bit should go in arginit if arginit support init-ing scripting args */ if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { /* wasn't a pre/ref/thing, OR anything like an int thing */ SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); } } force=0; if (arg1==NULL) { #ifdef __cplusplus ptr=new $*1_ltype; #else ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); #endif $1=&ptr; /* have to passback arg$arg too */ force=1; } } %typemap(argout) void **, void *& { if (force$argnum) { SWIG_SetPointerZval( *$input, (void*) ptr$argnum, $*1_descriptor, 1); } } /* Typemap for output values */ %typemap(out) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, bool, size_t { ZVAL_LONG(return_value,$1); } %typemap(out) enum SWIGTYPE { ZVAL_LONG(return_value, (long)$1); } %typemap(out) long long %{ if ((long long)LONG_MIN <= $1 && $1 <= (long long)LONG_MAX) { return_value->value.lval = (long)($1); return_value->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%lld", (long long)$1); ZVAL_STRING(return_value, temp, 1); } %} %typemap(out) unsigned long long %{ if ($1 <= (unsigned long long)LONG_MAX) { return_value->value.lval = (long)($1); return_value->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)$1); ZVAL_STRING(return_value, temp, 1); } %} %typemap(out) const int &, const unsigned int &, const short &, const unsigned short &, const long &, const unsigned long &, const signed char &, const unsigned char &, const bool &, const size_t & { ZVAL_LONG(return_value,*$1); } %typemap(out) const enum SWIGTYPE & { ZVAL_LONG(return_value, (long)*$1); } %typemap(out) const enum SWIGTYPE && { ZVAL_LONG(return_value, (long)*$1); } %typemap(out) const long long & %{ if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) { return_value->value.lval = (long)(*$1); return_value->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%lld", (long long)(*$1)); ZVAL_STRING(return_value, temp, 1); } %} %typemap(out) const unsigned long long & %{ if (*$1 <= (unsigned long long)LONG_MAX) { return_value->value.lval = (long)(*$1); return_value->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)(*$1)); ZVAL_STRING(return_value, temp, 1); } %} %typemap(directorin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, size_t, enum SWIGTYPE { ZVAL_LONG($input,$1); } %typemap(directorin) enum SWIGTYPE { ZVAL_LONG($input, (long)$1_name); } %typemap(directorin) char *, char [] { if(!$1) { ZVAL_NULL($input); } else { ZVAL_STRING($input, (char *)$1, 1); } } %typemap(out) bool { ZVAL_BOOL(return_value,($1)?1:0); } %typemap(out) const bool & { ZVAL_BOOL(return_value,(*$1)?1:0); } %typemap(directorin) bool { ZVAL_BOOL($input,($1)?1:0); } %typemap(out) float, double { ZVAL_DOUBLE(return_value,$1); } %typemap(out) const float &, const double & { ZVAL_DOUBLE(return_value,*$1); } %typemap(directorin) float, double { ZVAL_DOUBLE($input,$1); } %typemap(out) char { ZVAL_STRINGL(return_value,&$1, 1, 1); } %typemap(out) const char & { ZVAL_STRINGL(return_value,&*$1, 1, 1); } %typemap(out) char *, char [] { if(!$1) { ZVAL_NULL(return_value); } else { ZVAL_STRING(return_value, (char *)$1, 1); } } %typemap(out) char *& { if(!*$1) { ZVAL_NULL(return_value); } else { ZVAL_STRING(return_value, (char *)*$1, 1); } } %typemap(out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && %{ SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); %} %typemap(out) SWIGTYPE *const& %{ SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner); %} %typemap(directorin) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && %{ SWIG_SetPointerZval($input, (void *)&$1, $1_descriptor, ($owner)|2); %} %typemap(out, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = emalloc(sizeof($1)); memcpy(p, &$1, sizeof($1)); zval * resource; MAKE_STD_ZVAL(resource); ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner); } %typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr); memcpy(&$1, p, sizeof($1)); } %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner); } %typemap(out) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultobj = new $1_ltype((const $1_ltype &) $1); SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); } #else { $&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type)); memcpy(resultobj, &$1, sizeof($1_type)); SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); } #endif %typemap(directorin) SWIGTYPE { SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1), $&1_descriptor, 2); } %typemap(out) void ""; %typemap(out) char [ANY] { int len = 0; while (len < $1_dim0 && $1[len]) ++len; RETVAL_STRINGL($1, len, 1); } // This typecheck does hard checking for proper argument type. If you want // an argument to be converted from a different PHP type, you must convert // it yourself before passing it (e.g. (string)4.7 or (int)"6"). %define %php_typecheck(_type,_prec,is) %typemap(typecheck,precedence=_prec) _type, const _type & " $1 = (Z_TYPE_PP($input) == is); " %enddef %php_typecheck(int,SWIG_TYPECHECK_INTEGER,IS_LONG) %php_typecheck(unsigned int,SWIG_TYPECHECK_UINT32,IS_LONG) %php_typecheck(short,SWIG_TYPECHECK_INT16,IS_LONG) %php_typecheck(unsigned short,SWIG_TYPECHECK_UINT16,IS_LONG) %php_typecheck(long,SWIG_TYPECHECK_INT32,IS_LONG) %php_typecheck(unsigned long,SWIG_TYPECHECK_UINT32,IS_LONG) %php_typecheck(long long,SWIG_TYPECHECK_INT64,IS_LONG) %php_typecheck(unsigned long long,SWIG_TYPECHECK_UINT64,IS_LONG) %php_typecheck(signed char,SWIG_TYPECHECK_INT8,IS_LONG) %php_typecheck(unsigned char,SWIG_TYPECHECK_UINT8,IS_LONG) %php_typecheck(size_t,SWIG_TYPECHECK_SIZE,IS_LONG) %php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INTEGER,IS_LONG) %php_typecheck(bool,SWIG_TYPECHECK_BOOL,IS_BOOL) %php_typecheck(float,SWIG_TYPECHECK_FLOAT,IS_DOUBLE) %php_typecheck(double,SWIG_TYPECHECK_DOUBLE,IS_DOUBLE) %php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING) %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char [] " $1 = (Z_TYPE_PP($input) == IS_STRING); " %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *const& { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const& { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $*1_descriptor, 0) >= 0); } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, 0, 0) >= 0); } /* Exception handling */ %typemap(throws) int, long, short, unsigned int, unsigned long, unsigned short { zend_throw_exception(NULL, const_cast("C++ $1_type exception thrown"), $1 TSRMLS_CC); return; } %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ (void)$1; zend_throw_exception(NULL, const_cast("C++ $1_type exception thrown"), 0 TSRMLS_CC); return; %} %typemap(throws) char * %{ zend_throw_exception(NULL, const_cast($1), 0 TSRMLS_CC); return; %} /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* php keywords */ %include swig-3.0.2/Lib/windows.i0000664000175000017500000001005712343605122014720 0ustar williamwilliam/* ----------------------------------------------------------------------------- * windows.i * * SWIG library file to support types found in windows.h as well as Microsoft * integral type extensions. The types are set for 32 bit Windows. * ----------------------------------------------------------------------------- */ // Support for non ISO (Windows) integral types %apply unsigned char { unsigned __int8 }; %apply const unsigned char& { const unsigned __int8& }; %apply signed char { __int8 }; %apply const signed char& { const __int8& }; %apply unsigned short { unsigned __int16 }; %apply const unsigned short& { const unsigned __int16& }; %apply short { __int16 }; %apply const short& { const __int16& }; %apply unsigned int { unsigned __int32 }; %apply const unsigned int& { const unsigned __int32& }; %apply int { __int32 }; %apply const int& { const __int32& }; %apply unsigned long long { unsigned __int64 }; %apply const unsigned long long& { const unsigned __int64& }; %apply long long { __int64 }; %apply const long long& { const __int64& }; // Workaround Microsoft calling conventions #define __cdecl #define __fastcall #define __far #define __forceinline #define __fortran #define __inline #define __pascal #define __stdcall #define __syscall #define _cdecl #define _fastcall #define _inline #define _pascal #define _stdcall #define WINAPI #define __declspec(WINDOWS_EXTENDED_ATTRIBUTE) #define __w64 // Types from windef.h typedef unsigned long ULONG; typedef ULONG *PULONG; typedef unsigned short USHORT; typedef USHORT *PUSHORT; typedef unsigned char UCHAR; typedef UCHAR *PUCHAR; typedef char *PSZ; typedef unsigned long DWORD; typedef int BOOL; typedef unsigned char BYTE; typedef unsigned short WORD; typedef float FLOAT; typedef FLOAT *PFLOAT; typedef BOOL *PBOOL; typedef BOOL *LPBOOL; typedef BYTE *PBYTE; typedef BYTE *LPBYTE; typedef int *PINT; typedef int *LPINT; typedef WORD *PWORD; typedef WORD *LPWORD; typedef long *LPLONG; typedef DWORD *PDWORD; typedef DWORD *LPDWORD; typedef void *LPVOID; typedef const void *LPCVOID; typedef int INT; typedef unsigned int UINT; typedef unsigned int *PUINT; // Types from basetsd.h typedef signed char INT8, *PINT8; typedef signed short INT16, *PINT16; typedef signed int INT32, *PINT32; typedef signed __int64 INT64, *PINT64; typedef unsigned char UINT8, *PUINT8; typedef unsigned short UINT16, *PUINT16; typedef unsigned int UINT32, *PUINT32; typedef unsigned __int64 UINT64, *PUINT64; typedef signed int LONG32, *PLONG32; typedef unsigned int ULONG32, *PULONG32; typedef unsigned int DWORD32, *PDWORD32; typedef __w64 int INT_PTR, *PINT_PTR; typedef __w64 unsigned int UINT_PTR, *PUINT_PTR; typedef __w64 long LONG_PTR, *PLONG_PTR; typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR; typedef unsigned short UHALF_PTR, *PUHALF_PTR; typedef short HALF_PTR, *PHALF_PTR; typedef __w64 long SHANDLE_PTR; typedef __w64 unsigned long HANDLE_PTR; typedef ULONG_PTR SIZE_T, *PSIZE_T; typedef LONG_PTR SSIZE_T, *PSSIZE_T; typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; typedef __int64 LONG64, *PLONG64; typedef unsigned __int64 ULONG64, *PULONG64; typedef unsigned __int64 DWORD64, *PDWORD64; // Types from winnt.h typedef void *PVOID; typedef void *PVOID64; typedef char CHAR; typedef short SHORT; typedef long LONG; typedef CHAR *PCHAR; typedef CHAR *LPCH, *PCH; typedef const CHAR *LPCCH, *PCCH; typedef CHAR *NPSTR; typedef CHAR *LPSTR, *PSTR; typedef const CHAR *LPCSTR, *PCSTR; typedef char TCHAR, *PTCHAR; typedef unsigned char TBYTE , *PTBYTE ; typedef LPSTR LPTCH, PTCH; typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR; typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR; typedef SHORT *PSHORT; typedef LONG *PLONG; typedef void *HANDLE; typedef HANDLE *PHANDLE; typedef BYTE FCHAR; typedef WORD FSHORT; typedef DWORD FLONG; typedef LONG HRESULT; typedef char CCHAR; typedef DWORD LCID; typedef PDWORD PLCID; typedef WORD LANGID; typedef __int64 LONGLONG; typedef unsigned __int64 ULONGLONG; typedef LONGLONG *PLONGLONG; typedef ULONGLONG *PULONGLONG; typedef ULONGLONG DWORDLONG; typedef DWORDLONG *PDWORDLONG; typedef BYTE BOOLEAN; typedef BOOLEAN *PBOOLEAN; swig-3.0.2/Lib/clisp/0000775000175000017500000000000012343605122014163 5ustar williamwilliamswig-3.0.2/Lib/clisp/clisp.swg0000664000175000017500000000163712343605122016026 0ustar williamwilliam/* ----------------------------------------------------------------------------- * clisp.swg * ----------------------------------------------------------------------------- */ /* Define a C preprocessor symbol that can be used in interface files to distinguish between the SWIG language modules. */ #define SWIG_CLISP /* Typespecs for basic types. */ %typemap(in) void "NIL"; %typemap(in) char "character"; %typemap(in) char * "ffi:c-string"; %typemap(in) unsigned char "ffi:uchar"; %typemap(in) signed char "ffi:char"; %typemap(in) short "ffi:short"; %typemap(in) signed short "ffi:short"; %typemap(in) unsigned short "ffi:ushort"; %typemap(in) int "ffi:int"; %typemap(in) signed int "ffi:int"; %typemap(in) unsigned int "ffi:uint"; %typemap(in) long "ffi:long"; %typemap(in) signed long "ffi:long"; %typemap(in) unsigned long "ffi:ulong"; %typemap(in) float "SINGLE-FLOAT"; %typemap(in) double "DOUBLE-FLOAT"; swig-3.0.2/Lib/typemaps/0000775000175000017500000000000012343605122014713 5ustar williamwilliamswig-3.0.2/Lib/typemaps/README0000664000175000017500000000372512343605122015602 0ustar williamwilliamStill in development, but if you are interested into looking around, start with swigtypemaps.swg which is the head file. Also read the docs for %fragments in fragments.swg and follow the definitions in one of the supported languages: python, perl, ruby, tcl /* ----------------------------------------------------------------------------- * Internal typemap specializations * ----------------------------------------------------------------------------- */ carrays.swg Implement the carrays.i library cdata.swg Implement the cdata.i library cmalloc.swg Implement the cmalloc.i library cpointer.swg Implement the cpointer.i library cstring.swg Implement the cstring.i library typemaps for char * cwstring.swg Implement the cstring.i library typemaps for wchar_t * exception.swg Implement the exception.i library implicit.swg Allow the use of implicit C++ constructors string.swg Typemaps for char * string wstring.swg Typemaps for wchar_t * string std_string.swg Typemaps for std::string std_wstring.swg Typemaps for std::wstring swigtype.swg Typemaps for the SWIGTYPE type void.swg Typemaps for the 'void' type enumint.swg Typemaps for enums treated as 'int' swigobject.swg Typemaps for the SWIG_Object as in PyObject, Tcl_Obj, etc. misctypes.swg Typemaps for miscellaneos types (size_t, ptrdiff_t, etc) ptrtypes.swg Typemaps for types with a 'ptr' behavior valtypes.swg Typemaps for 'by value' types inoutlist.swg IN/OUTPUT/INOUT typemaps, where the OUTPUT values are returned in a list primtypes.swg Common macros to manage primitive types (short,int,double,etc) cstrings.swg Common macros to implemented the cstring/cwstring libraries std_strings.swg Common macros to implemented the std::string/std::wstring typemaps strings.swg Common macros and typemaps for string and wstring (char *, wchar_t *) swigmacros.swg Basic macros fragments.swg Macros for fragment manipulations typemaps.swg The old typemaps.i library, not needed anymore swig-3.0.2/Lib/typemaps/factory.swg0000664000175000017500000000461112343605122017106 0ustar williamwilliam/* Implement a more natural wrap for factory methods, for example, if you have: ---- geometry.h -------- struct Geometry { enum GeomType{ POINT, CIRCLE }; virtual ~Geometry() {} virtual int draw() = 0; // // Factory method for all the Geometry objects // static Geometry *create(GeomType i); }; struct Point : Geometry { int draw() { return 1; } double width() { return 1.0; } }; struct Circle : Geometry { int draw() { return 2; } double radius() { return 1.5; } }; // // Factory method for all the Geometry objects // Geometry *Geometry::create(GeomType type) { switch (type) { case POINT: return new Point(); case CIRCLE: return new Circle(); default: return 0; } } ---- geometry.h -------- You can use the %factory with the Geometry::create method as follows: %newobject Geometry::create; %factory(Geometry *Geometry::create, Point, Circle); %include "geometry.h" and Geometry::create will return a 'Point' or 'Circle' instance instead of the plain 'Geometry' type. For example, in python: circle = Geometry.create(Geometry.CIRCLE) r = circle.radius() where circle is a Circle proxy instance. NOTES: remember to fully qualify all the type names and don't use %factory inside a namespace declaration, ie, instead of namespace Foo { %factory(Geometry *Geometry::create, Point, Circle); } use %factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle); */ %define %_factory_dispatch(Type) if (!dcast) { Type *dobj = dynamic_cast($1); if (dobj) { dcast = 1; %set_output(SWIG_NewPointerObj(%as_voidptr(dobj),$descriptor(Type *), $owner | %newpointer_flags)); } }%enddef %define %factory(Method,Types...) %typemap(out) Method { int dcast = 0; %formacro(%_factory_dispatch, Types) if (!dcast) { %set_output(SWIG_NewPointerObj(%as_voidptr($1),$descriptor, $owner | %newpointer_flags)); } }%enddef swig-3.0.2/Lib/typemaps/carrays.swg0000664000175000017500000000517612343605122017112 0ustar williamwilliam/* ----------------------------------------------------------------------------- * carrays.swg * * This library file contains macros that can be used to manipulate simple * pointers as arrays. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %array_functions(TYPE,NAME) * * Generates functions for creating and accessing elements of a C array * (as pointers). Creates the following functions: * * TYPE *new_NAME(int nelements) * void delete_NAME(TYPE *); * TYPE NAME_getitem(TYPE *, int index); * void NAME_setitem(TYPE *, int index, TYPE value); * * ----------------------------------------------------------------------------- */ %define %array_functions(TYPE,NAME) %{ static TYPE *new_##NAME(size_t nelements) { return %new_array(nelements, TYPE); } static void delete_##NAME(TYPE *ary) { %delete_array(ary); } static TYPE NAME##_getitem(TYPE *ary, size_t index) { return ary[index]; } static void NAME##_setitem(TYPE *ary, size_t index, TYPE value) { ary[index] = value; } %} TYPE *new_##NAME(size_t nelements); void delete_##NAME(TYPE *ary); TYPE NAME##_getitem(TYPE *ary, size_t index); void NAME##_setitem(TYPE *ary, size_t index, TYPE value); %enddef /* ----------------------------------------------------------------------------- * %array_class(TYPE,NAME) * * Generates a class wrapper around a C array. The class has the following * interface: * * struct NAME { * NAME(int nelements); * ~NAME(); * TYPE getitem(int index); * void setitem(int index, TYPE value); * TYPE * cast(); * static NAME *frompointer(TYPE *t); * } * * Use * * %array_class_wrap(TYPE,NAME,GET,SET) * * if you want different names for the get/set methods. * ----------------------------------------------------------------------------- */ %define %array_class_wrap(TYPE,NAME,getitem,setitem) %{ typedef TYPE NAME; %} typedef struct { } NAME; %extend NAME { NAME(size_t nelements) { return %new_array(nelements, TYPE); } ~NAME() { %delete_array(self); } TYPE getitem(size_t index) { return self[index]; } void setitem(size_t index, TYPE value) { self[index] = value; } TYPE * cast() { return self; } static NAME *frompointer(TYPE *t) { return %static_cast(t, NAME *); } }; %types(NAME = TYPE); %enddef #ifndef %array_class %define %array_class(TYPE,NAME) %array_class_wrap(TYPE,NAME,getitem,setitem) %enddef #endif swig-3.0.2/Lib/typemaps/std_strings.swg0000664000175000017500000000366512343605122020012 0ustar williamwilliam /* defining the String asptr/from methods */ %define %std_string_asptr(String, Char, SWIG_AsCharPtrAndSize, Frag) %fragment(SWIG_AsPtr_frag(String),"header",fragment=Frag) { SWIGINTERN int SWIG_AsPtr_dec(String)(SWIG_Object obj, String **val) { Char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ; if (SWIG_IsOK((SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc)))) { if (buf) { if (val) *val = new String(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } else { if (val) *val = 0; return SWIG_OLDOBJ; } } else { static int init = 0; static swig_type_info* descriptor = 0; if (!init) { descriptor = SWIG_TypeQuery(#String " *"); init = 1; } if (descriptor) { String *vptr; int res = SWIG_ConvertPtr(obj, (void**)&vptr, descriptor, 0); if (SWIG_IsOK(res) && val) *val = vptr; return res; } } return SWIG_ERROR; } } %enddef %define %std_string_from(String, SWIG_FromCharPtrAndSize, Frag) %fragment(SWIG_From_frag(String),"header",fragment=Frag) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(String)(const String& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } %enddef %define %std_string_asval(String) %fragment(SWIG_AsVal_frag(String),"header", fragment=SWIG_AsPtr_frag(String)) { SWIGINTERN int SWIG_AsVal_dec(String)(SWIG_Object obj, String *val) { String* v = (String *) 0; int res = SWIG_AsPtr(String)(obj, &v); if (!SWIG_IsOK(res)) return res; if (v) { if (val) *val = *v; if (SWIG_IsNewObj(res)) { %delete(v); res = SWIG_DelNewMask(res); } return res; } return SWIG_ERROR; } } %enddef %define %typemaps_std_string(String, Char, AsPtrMethod, FromMethod, CheckCode) %std_string_asptr(String, Char, AsPtrMethod, #AsPtrMethod) %std_string_asval(String) %std_string_from(String, FromMethod, #FromMethod) %typemaps_asptrfromn(%arg(CheckCode), String); %enddef swig-3.0.2/Lib/typemaps/std_string.swg0000664000175000017500000000053312343605122017616 0ustar williamwilliam// // String // #ifndef SWIG_STD_BASIC_STRING #define SWIG_STD_STRING %include %fragment(""); namespace std { %naturalvar string; class string; } %typemaps_std_string(std::string, char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, %checkcode(STDSTRING)); #else %include #endif swig-3.0.2/Lib/typemaps/strings.swg0000664000175000017500000004460012343605122017132 0ustar williamwilliam// // Use the macro SWIG_PRESERVE_CARRAY_SIZE if you prefer to preserve // the size of char arrays, ie // ------------------------------------------ // C Side => Language Side // ------------------------------------------ // char name[5] = "hola" => 'hola\0' // // the default behaviour is // // char name[5] = "hola" => 'hola' // // //#define SWIG_PRESERVE_CARRAY_SIZE /* ------------------------------------------------------------ * String typemaps for type Char (char or wchar_t) * ------------------------------------------------------------ */ %define %_typemap_string(StringCode, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_AsCharPtr, SWIG_FromCharPtr, SWIG_AsCharArray, SWIG_NewCopyCharArray, SWIG_DeleteCharArray) /* in */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char * (int res, Char *buf = 0, int alloc = 0), const Char * (int res, Char *buf = 0, int alloc = 0) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = %reinterpret_cast(buf, $1_ltype); } %typemap(freearg,noblock=1,match="in") Char *, const Char * { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } %typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (int res, Char *buf = 0, int alloc = 0) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = &buf; } %typemap(freearg, noblock=1,match="in") Char const*& { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* out */ %typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * { %set_output(SWIG_FromCharPtr((const Char *)$1)); } %typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char const*& { %set_output(SWIG_FromCharPtr(*$1)); } %typemap(newfree,noblock=1) Char * { SWIG_DeleteCharArray($1); } /* varin */ %typemap(varin,fragment=#SWIG_AsCharPtrAndSize) Char * { Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ; int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc); if (!SWIG_IsOK(res)) { %variable_fail(res,"$type","$name"); } if ($1) SWIG_DeleteCharArray($1); if (alloc == SWIG_NEWOBJ) { $1 = cptr; } else { $1 = csize ? ($1_type)SWIG_NewCopyCharArray(cptr, csize, Char) : 0; } } %typemap(varin,fragment=#SWIG_AsCharPtrAndSize,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * { Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ; int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (alloc == SWIG_NEWOBJ) { $1 = cptr; } else { $1 = csize ? ($1_type)SWIG_NewCopyCharArray(cptr, csize, Char) : 0; } } /* varout */ %typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * { %set_varoutput(SWIG_FromCharPtr($1)); } /* memberin */ %typemap(memberin,noblock=1) Char * { if ($1) SWIG_DeleteCharArray($1); if ($input) { size_t size = SWIG_CharPtrLen(%reinterpret_cast($input, const Char *)) + 1; $1 = ($1_type)SWIG_NewCopyCharArray(%reinterpret_cast($input, const Char *), size, Char); } else { $1 = 0; } } %typemap(memberin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * { if ($input) { size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1; $1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char); } else { $1 = 0; } } /* globalin */ %typemap(globalin,noblock=1) Char * { if ($1) SWIG_DeleteCharArray($1); if ($input) { size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1; $1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char); } else { $1 = 0; } } %typemap(globalin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * { if ($input) { size_t size = SWIG_CharPtrLen($input) + 1; $1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char); } else { $1 = 0; } } /* constant */ %typemap(constcode,noblock=1,fragment=#SWIG_FromCharPtr) Char *, Char const*, Char * const, Char const* const { %set_constant("$symname", SWIG_FromCharPtr($value)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtr) Char *, Char const*, Char *const, Char const *const, Char const *&, Char *const &, Char const *const & { $input = SWIG_FromCharPtr((const Char *)$1); } /* directorout */ %typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char * (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %dirout_fail(res, "$type"); } if (alloc == SWIG_NEWOBJ) { swig_acquire_ownership_array(buf); } $result = %reinterpret_cast(buf, $1_ltype); } %typemap(directorfree,noblock=1) Char * { if (director) { director->swig_release_ownership(%as_voidptr($input)); } } %typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char *const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ), Char const*const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %dirout_fail(res, "$type"); } static $*1_ltype tmp = buf; $result = &tmp; if (alloc == SWIG_NEWOBJ) { swig_acquire_ownership_array(buf); } } %typemap(directorfree,noblock=1) Char * const&, Char const* const& { if (director) { director->swig_release_ownership(%as_voidptr(*$input)); } } #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* typecheck */ %typemap(typecheck,noblock=1,precedence=StringCode, fragment=#SWIG_AsCharPtr) Char *, const Char *, Char const*& { int res = SWIG_AsCharPtr($input, 0, 0); $1 = SWIG_CheckState(res); } /* throws */ %typemap(throws,noblock=1,fragment=#SWIG_FromCharPtr) Char * { %raise(SWIG_FromCharPtr($1), "$type", 0); } /* ------------------------------------------------------------ * Unknown size const Character array Char[ANY] handling * ------------------------------------------------------------ */ %apply Char * { Char [] }; %apply const Char * { const Char [] }; %typemap(varin,noblock=1,warning="462:Unable to set variable of type Char []") Char [] { %variable_fail(SWIG_AttributeError, "$type", "read-only $name"); } /* ------------------------------------------------------------ * Fixed size Character array Char[ANY] handling * ------------------------------------------------------------ */ /* memberin and globalin typemaps */ %typemap(memberin,noblock=1) Char [ANY] { if ($input) memcpy($1,$input,$1_dim0*sizeof(Char)); else memset($1,0,$1_dim0*sizeof(Char)); } %typemap(globalin,noblock=1) Char [ANY] { if ($input) memcpy($1,$input,$1_dim0*sizeof(Char)); else memset($1,0,$1_dim0*sizeof(Char)); } /* in */ %typemap(in,noblock=1,fragment=#SWIG_AsCharArray) Char [ANY] (Char temp[$1_dim0], int res), const Char [ANY](Char temp[$1_dim0], int res) { res = SWIG_AsCharArray($input, temp, $1_dim0); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = %reinterpret_cast(temp, $1_ltype); } %typemap(freearg) Char [ANY], const Char [ANY] ""; %typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0], int res) { res = SWIG_AsCharArray($input, temp, $1_dim0); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = &temp; } %typemap(freearg) const Char (&)[ANY] ""; %typemap(out,fragment=#SWIG_FromCharPtrAndSize,fragment=#SWIG_CharBufLen) Char [ANY], const Char[ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $1_dim0; %#endif %set_output(SWIG_FromCharPtrAndSize($1, size)); } /* varin */ %typemap(varin,fragment=#SWIG_AsCharArray) Char [ANY] { int res = SWIG_AsCharArray($input, $1, $1_dim0); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } } /* varout */ %typemap(varout,noblock=1,fragment=#SWIG_CharBufLen) Char [ANY], const Char [ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $1_dim0; %#endif %set_varoutput(SWIG_FromCharPtrAndSize($1, size)); } /* constant */ %typemap(constcode,fragment=#SWIG_CharBufLen) Char [ANY], const Char [ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $value_dim0; %#endif %set_constant("$symname", SWIG_FromCharPtrAndSize($value,size)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,fragment=#SWIG_CharBufLen) Char [ANY], const Char [ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $1_dim0; %#endif $input = SWIG_FromCharPtrAndSize($1, size); } /* directorout */ %typemap(directorout,noblock=1,fragment=#SWIG_AsCharArray) Char [ANY] (Char temp[$result_dim0]), const Char [ANY] (Char temp[$result_dim0], int res) { res = SWIG_AsCharArray($input, temp, $result_dim0); if (!SWIG_IsOK(res)) { %dirout_fail(res, "$type"); } $result = temp; } #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* typecheck */ %typemap(typecheck,noblock=1,precedence=StringCode, fragment=#SWIG_AsCharArray) Char [ANY], const Char[ANY] { int res = SWIG_AsCharArray($input, (Char *)0, $1_dim0); $1 = SWIG_CheckState(res); } /* throws */ %typemap(throws,fragment=#SWIG_CharBufLen) Char [ANY], const Char[ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $1_dim0; %#endif %raise(SWIG_FromCharPtrAndSize($1, size), "$type", 0); } /* ------------------------------------------------------------------- * --- Really fix size Char arrays, including '\0'chars at the end --- * ------------------------------------------------------------------- */ %typemap(varout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { %set_varoutput(SWIG_FromCharPtrAndSize($1, $1_dim0)); } %typemap(out,noblock=1,fragment=#SWIG_FromCharPtrAndSize) Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { %set_output(SWIG_FromCharPtrAndSize($1, $1_dim0)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) %typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtrAndSize) Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { $input = SWIG_FromCharPtrAndSize($1, $1_dim0); } #endif /* SWIG_DIRECTOR_TYPEMAPS */ %typemap(throws,noblock=1,fragment=#SWIG_FromCharPtrAndSize) Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { %raise(SWIG_FromCharPtrAndSize($1, $1_dim0), "$type", 0); } /* ------------------------------------------------------------ * --- String & length --- * ------------------------------------------------------------ */ /* Here len doesn't include the '0' terminator */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), (const Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = %reinterpret_cast(buf, $1_ltype); $2 = %numeric_cast(size - 1, $2_ltype); } %typemap(freearg,noblock=1,match="in") (Char *STRING, size_t LENGTH) { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* old 'int' form */ %typemap(in) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH); %typemap(freearg) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH); /* Here size includes the '0' terminator */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), (const Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = %reinterpret_cast(buf, $1_ltype); $2 = %numeric_cast(size, $2_ltype); } %typemap(freearg,noblock=1,match="in") (Char *STRING, size_t SIZE) { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* old 'int' form */ %typemap(in) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE); %typemap(freearg) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE); /* reverse order versions */ /* Here len doesn't include the '0' terminator */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (size_t LENGTH, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), (size_t LENGTH, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $2 = %reinterpret_cast(buf, $2_ltype) ; $1 = %numeric_cast(size - 1, $1_ltype) ; } %typemap(freearg, noblock=1, match="in") (size_t LENGTH, Char *STRING) { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* old 'int' form */ %typemap(in) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING); %typemap(freearg) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING); /* Here size includes the '0' terminator */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (size_t SIZE, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), (size_t SIZE, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type",$symname, $argnum); } $2 = %reinterpret_cast(buf, $2_ltype) ; $1 = %numeric_cast(size, $1_ltype) ; } %typemap(freearg, noblock=1, match="in") (size_t SIZE, Char *STRING) { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* old 'int' form */ %typemap(in) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING); %typemap(freearg) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING); %enddef /* ------------------------------------------------------------ * --- String fragment methods --- * ------------------------------------------------------------ */ #ifndef %_typemap2_string %define %_typemap2_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_NewCopyCharArray, SWIG_DeleteCharArray, FragLimits, CHAR_MIN, CHAR_MAX) %fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) { SWIGINTERNINLINE SWIG_Object SWIG_From##CharName##Ptr(const Char *cptr) { return SWIG_FromCharPtrAndSize(cptr, (cptr ? SWIG_CharPtrLen(cptr) : 0)); } } %fragment("SWIG_From"#CharName"Array","header",fragment=#SWIG_FromCharPtrAndSize) { SWIGINTERNINLINE SWIG_Object SWIG_From##CharName##Array(const Char *cptr, size_t size) { return SWIG_FromCharPtrAndSize(cptr, size); } } %fragment("SWIG_As" #CharName "Ptr","header",fragment=#SWIG_AsCharPtrAndSize) { %define_as(SWIG_As##CharName##Ptr(obj, val, alloc), SWIG_AsCharPtrAndSize(obj, val, NULL, alloc)) } %fragment("SWIG_As" #CharName "Array","header",fragment=#SWIG_AsCharPtrAndSize) { SWIGINTERN int SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size) { Char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ; int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc); if (SWIG_IsOK(res)) { /* special case of single char conversion when we don't need space for NUL */ if (size == 1 && csize == 2 && cptr && !cptr[1]) --csize; if (csize <= size) { if (val) { if (csize) memcpy(val, cptr, csize*sizeof(Char)); if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char)); } if (alloc == SWIG_NEWOBJ) { SWIG_DeleteCharArray(cptr); res = SWIG_DelNewMask(res); } return res; } if (alloc == SWIG_NEWOBJ) SWIG_DeleteCharArray(cptr); } return SWIG_TypeError; } } /* Char */ %fragment(SWIG_From_frag(Char),"header",fragment=#SWIG_FromCharPtrAndSize) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(Char)(Char c) { return SWIG_FromCharPtrAndSize(&c,1); } } %fragment(SWIG_AsVal_frag(Char),"header", fragment="SWIG_As"#CharName"Array", fragment=FragLimits, fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val) { int res = SWIG_As##CharName##Array(obj, val, 1); if (!SWIG_IsOK(res)) { long v; res = SWIG_AddCast(SWIG_AsVal(long)(obj, &v)); if (SWIG_IsOK(res)) { if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) { if (val) *val = %numeric_cast(v, Char); } else { res = SWIG_OverflowError; } } } return res; } } %_typemap_string(StringCode, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_As##CharName##Ptr, SWIG_From##CharName##Ptr, SWIG_As##CharName##Array, SWIG_NewCopyCharArray, SWIG_DeleteCharArray) %enddef #endif /* ------------------------------------------------------------ * String typemaps and fragments, with default allocators * ------------------------------------------------------------ */ %define %typemaps_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, FragLimits, CHAR_MIN, CHAR_MAX) %_typemap2_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, %new_copy_array, %delete_array, FragLimits, CHAR_MIN, CHAR_MAX) %enddef /* ------------------------------------------------------------ * String typemaps and fragments, with custom allocators * ------------------------------------------------------------ */ %define %typemaps_string_alloc(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_NewCopyCharArray, SWIG_DeleteCharArray, FragLimits, CHAR_MIN, CHAR_MAX) %_typemap2_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_NewCopyCharArray, SWIG_DeleteCharArray, FragLimits, CHAR_MIN, CHAR_MAX) %enddef swig-3.0.2/Lib/typemaps/cstrings.swg0000664000175000017500000002003612343605122017272 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cstrings.swg * * This file provides typemaps and macros for dealing with various forms * of C character string handling. The primary use of this module * is in returning character data that has been allocated or changed in * some way. * ----------------------------------------------------------------------------- */ %define %typemaps_cstring(Name, Char, SWIG_AsCharPtr, SWIG_AsCharPtrAndSize, SWIG_FromCharPtr, SWIG_FromCharPtrAndSize) /* %cstring_input_binary(TYPEMAP, SIZE) * * Macro makes a function accept binary string data along with * a size. For example: * * %cstring_input_binary(Char *buff, int size); * void foo(Char *buff, int size) { * } * */ %define Name ## _input_binary(TYPEMAP, SIZE) %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (TYPEMAP, SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } $1 = ($1_ltype) buf; $2 = ($2_ltype) size - 1; } %typemap(freearg,noblock=1,match="in") (TYPEMAP, SIZE) { if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum); } %enddef /* * %cstring_bounded_output(TYPEMAP, MAX) * * This macro is used to return a NULL-terminated output string of * some maximum length. For example: * * %cstring_bounded_output(Char *outx, 512); * void foo(Char *outx) { * sprintf(outx,"blah blah\n"); * } * */ %define Name ## _bounded_output(TYPEMAP,MAX) %typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) { $1 = ($1_ltype) temp; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP { $1[MAX] = 0; %append_output(SWIG_FromCharPtr($1)); } %enddef /* * %cstring_chunk_output(TYPEMAP, SIZE) * * This macro is used to return a chunk of binary string data. * Embedded NULLs are okay. For example: * * %cstring_chunk_output(Char *outx, 512); * void foo(Char *outx) { * memmove(outx, somedata, 512); * } * */ %define Name ## _chunk_output(TYPEMAP,SIZE) %typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) { $1 = ($1_ltype) temp; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP { %append_output(SWIG_FromCharPtrAndSize($1,SIZE)); } %enddef /* * %cstring_bounded_mutable(TYPEMAP, SIZE) * * This macro is used to wrap a string that's going to mutate. * * %cstring_bounded_mutable(Char *in, 512); * void foo(in *x) { * while (*x) { * *x = toupper(*x); * x++; * } * } * */ %define Name ## _bounded_mutable(TYPEMAP,MAX) %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP (int res,Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &t, &n, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res, "TYPEMAP", $symname, $argnum); } if ( n > (size_t) MAX ) n = (size_t) MAX; memcpy(temp, t, sizeof(Char)*n); if (alloc == SWIG_NEWOBJ) %delete_array(t); temp[n - 1] = 0; $1 = ($1_ltype) temp; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP { $1[MAX] = 0; %append_output(SWIG_FromCharPtr($1)); } %enddef /* * %cstring_mutable(TYPEMAP [, expansion]) * * This macro is used to wrap a string that will mutate in place. * It may change size up to a user-defined expansion. * * %cstring_mutable(Char *in); * void foo(in *x) { * while (*x) { * *x = toupper(*x); * x++; * } * } * */ %define Name ## _mutable(TYPEMAP,EXP...) %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP (int res, Char *t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) { #if #EXP != "" expansion += EXP; #endif res = SWIG_AsCharPtrAndSize($input, &t, &n, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res, "TYPEMAP", $symname, $argnum); } $1 = %new_array(n+expansion, $*1_ltype); memcpy($1,t,sizeof(Char)*n); if (alloc == SWIG_NEWOBJ) %delete_array(t); $1[n-1] = 0; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP { %append_output(SWIG_FromCharPtr($1)); %delete_array($1); } %enddef /* * %cstring_output_maxsize(TYPEMAP, SIZE) * * This macro returns data in a string of some user-defined size. * * %cstring_output_maxsize(Char *outx, int max) { * void foo(Char *outx, int max) { * sprintf(outx,"blah blah\n"); * } */ %define Name ## _output_maxsize(TYPEMAP, SIZE) %typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (int res, size_t size, Char *buff = 0) { res = SWIG_AsVal(size_t)($input, &size); if (!SWIG_IsOK(res)) { %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } buff= %new_array(size+1, Char); $2 = %numeric_cast(size, $2_ltype); $1 = %static_cast(buff, $1_ltype); } %typemap(freearg,noblock=1,match="in") (TYPEMAP,SIZE) { if (buff$argnum) %delete_array(buff$argnum); } %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) { %append_output(SWIG_FromCharPtr($1)); } %enddef /* * %cstring_output_withsize(TYPEMAP, SIZE) * * This macro is used to return Character data along with a size * parameter. * * %cstring_output_maxsize(Char *outx, int *max) { * void foo(Char *outx, int *max) { * sprintf(outx,"blah blah\n"); * *max = strlen(outx); * } */ %define Name ## _output_withsize(TYPEMAP, SIZE) %typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (int res, size_t n, Char *buff = 0, $*2_ltype size) { res = SWIG_AsVal(size_t)($input, &n); if (!SWIG_IsOK(res)) { %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } buff= %new_array(n+1, Char); $1 = %static_cast(buff, $1_ltype); size = %numeric_cast(n,$*2_ltype); $2 = &size; } %typemap(freearg,noblock=1,match="in")(TYPEMAP,SIZE) { if (buff$argnum) %delete_array(buff$argnum); } %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) { %append_output(SWIG_FromCharPtrAndSize($1,*$2)); } %enddef /* * %cstring_output_allocate(TYPEMAP, RELEASE) * * This macro is used to return Character data that was * allocated with new or malloc. * * %cstring_output_allocated(Char **outx, free($1)); * void foo(Char **outx) { * *outx = (Char *) malloc(512); * sprintf(outx,"blah blah\n"); * } */ %define Name ## _output_allocate(TYPEMAP, RELEASE) %typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) { $1 = &temp; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP { if (*$1) { %append_output(SWIG_FromCharPtr(*$1)); RELEASE; } } %enddef /* * %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) * * This macro is used to return Character data that was * allocated with new or malloc. * * %cstring_output_allocated(Char **outx, int *sz, free($1)); * void foo(Char **outx, int *sz) { * *outx = (Char *) malloc(512); * sprintf(outx,"blah blah\n"); * *sz = strlen(outx); * } */ %define Name ## _output_allocate_size(TYPEMAP, SIZE, RELEASE) %typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) { $1 = &temp; $2 = &tempn; } %typemap(freearg,match="in") (TYPEMAP,SIZE) ""; %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) { if (*$1) { %append_output(SWIG_FromCharPtrAndSize(*$1,*$2)); RELEASE; } } %enddef %enddef swig-3.0.2/Lib/typemaps/string.swg0000664000175000017500000000137612343605122016752 0ustar williamwilliam%ensure_fragment(SWIG_AsCharPtrAndSize) %ensure_fragment(SWIG_FromCharPtrAndSize) %types(char *); %fragment("SWIG_pchar_descriptor","header") { SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) { static int init = 0; static swig_type_info* info = 0; if (!init) { info = SWIG_TypeQuery("_p_char"); init = 1; } return info; } } %fragment("SWIG_strnlen","header",fragment="SWIG_FromCharPtrAndSize") { size_t SWIG_strnlen(const char* s, size_t maxlen) { const char *p; for (p = s; maxlen-- && *p; p++) ; return p - s; } } %include %typemaps_string(%checkcode(STRING), %checkcode(CHAR), char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen, SWIG_strnlen, "", CHAR_MIN, CHAR_MAX) swig-3.0.2/Lib/typemaps/std_wstring.swg0000664000175000017500000000062012343605122020002 0ustar williamwilliam%include #ifndef SWIG_STD_BASIC_STRING #define SWIG_STD_WSTRING %include %{ #include %} %fragment(""); namespace std { %naturalvar wstring; class wstring; } %typemaps_std_string(std::wstring, wchar_t, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, %checkcode(STDUNISTRING)); #else %include #endif swig-3.0.2/Lib/typemaps/cwstring.swg0000664000175000017500000000031712343605122017276 0ustar williamwilliam%include %include %typemaps_cstring(%cwstring, wchar_t, SWIG_AsWCharPtr, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtr, SWIG_FromWCharPtrAndSize); swig-3.0.2/Lib/typemaps/misctypes.swg0000664000175000017500000000072312343605122017457 0ustar williamwilliam /* ------------------------------------------------------------ * --- ANSI/Posix C/C++ types --- * ------------------------------------------------------------ */ #ifdef __cplusplus %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; %apply ptrdiff_t { std::ptrdiff_t }; %apply const ptrdiff_t& { const std::ptrdiff_t& }; #ifndef SWIG_INOUT_NODEF %apply size_t& { std::size_t& }; %apply ptrdiff_t& { std::ptrdiff_t& }; #endif #endif swig-3.0.2/Lib/typemaps/cdata.swg0000664000175000017500000000352012343605122016511 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cdata.swg * * This library file contains macros for manipulating raw C data as strings. * ----------------------------------------------------------------------------- */ %{ typedef struct SWIGCDATA { char *data; size_t len; } SWIGCDATA; %} /* ----------------------------------------------------------------------------- * Typemaps for returning binary data * ----------------------------------------------------------------------------- */ %typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") SWIGCDATA { %set_output(SWIG_FromCharPtrAndSize($1.data,$1.len)); } %typemap(in) (const void *indata, size_t inlen) = (char *STRING, size_t SIZE); /* ----------------------------------------------------------------------------- * %cdata(TYPE [, NAME]) * * Convert raw C data to a binary string. * ----------------------------------------------------------------------------- */ %define %cdata(TYPE,NAME...) %insert("header") { #ifdef __cplusplus extern "C" { #endif #if #NAME == "" static SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements) #else static SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements) #endif { SWIGCDATA d; d.data = (char *) ptr; #if #TYPE != "void" d.len = nelements*sizeof(TYPE); #else d.len = nelements; #endif return d; } #ifdef __cplusplus } #endif } #ifdef __cplusplus extern "C" #endif #if #NAME == "" SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements = 1); #else SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements = 1); #endif %enddef %rename(cdata) ::cdata_void(void *ptr, size_t nelements = 1); %cdata(void); /* Memory move function. Due to multi-argument typemaps this appears to be wrapped as void memmove(void *data, const char *s); */ void memmove(void *data, const void *indata, size_t inlen); swig-3.0.2/Lib/typemaps/valtypes.swg0000664000175000017500000001574312343605122017316 0ustar williamwilliam/*--------------------------------------------------------------------- * Value typemaps (Type, const Type&) for value types, such as * fundamental types (int, double), that define the AsVal/From * methods. * * To apply them, just use one of the following macros: * * %typemaps_from(FromMeth, FromFrag, Type) * %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type) * %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth, AsValFrag, FromFrag, Type) * * or the simpler and normalize form: * * %typemaps_asvalfromn(CheckCode, Type) * * Also, you can use the individual typemap definitions: * * %value_in_typemap(asval_meth,frag,Type) * %value_varin_typemap(asval_meth,frag,Type) * %value_typecheck_typemap(checkcode,asval_meth,frag,Type) * %value_directorout_typemap(asval_meth,frag,Type) * * %value_out_typemap(from_meth,frag,Type) * %value_varout_typemap(from_meth,frag,Type) * %value_constcode_typemap(from_meth,frag,Type) * %value_directorin_typemap(from_meth,frag,Type) * %value_throws_typemap(from_meth,frag,Type) * *---------------------------------------------------------------------*/ /* in */ %define %value_in_typemap(asval_meth,frag,Type...) %typemap(in,noblock=1,fragment=frag) Type (Type val, int ecode = 0) { ecode = asval_meth($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$ltype", $symname, $argnum); } $1 = %static_cast(val,$ltype); } %typemap(freearg) Type ""; %typemap(in,noblock=1,fragment=frag) const Type & ($*ltype temp, Type val, int ecode = 0) { ecode = asval_meth($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$*ltype", $symname, $argnum); } temp = %static_cast(val, $*ltype); $1 = &temp; } %typemap(freearg) const Type& ""; %enddef /* out */ %define %value_out_typemap(from_meth,frag,Type...) %typemap(out,noblock=1,fragment=frag) Type, const Type { %set_output(from_meth(%static_cast($1,Type))); } %typemap(out,noblock=1,fragment=frag) const Type& { %set_output(from_meth(%static_cast(*$1,Type))); } %enddef /* varin */ %define %value_varin_typemap(asval_meth,frag,Type...) %typemap(varin,fragment=frag) Type { Type val; int res = asval_meth($input, &val); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = %static_cast(val,$ltype); } %enddef /* varout */ %define %value_varout_typemap(from_meth,frag,Type...) %typemap(varout,noblock=1,fragment=frag) Type, const Type& { %set_varoutput(from_meth(%static_cast($1,Type))); } %enddef /* constant installation code */ %define %value_constcode_typemap(from_meth,frag,Type...) %typemap(constcode,noblock=1,fragment=frag) Type { %set_constant("$symname", from_meth(%static_cast($value,Type))); } %enddef #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %define %value_directorin_typemap(from_meth,frag,Type...) %typemap(directorin,noblock=1,fragment=frag) Type *DIRECTORIN { $input = from_meth(%static_cast(*$1,Type)); } %typemap(directorin,noblock=1,fragment=frag) Type, const Type& { $input = from_meth(%static_cast($1,Type)); } %enddef /* directorout */ %define %value_directorout_typemap(asval_meth,frag,Type...) %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT(Type swig_val, int swig_res) { swig_res = asval_meth($result, &swig_val); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res, "$type"); } *$1 = swig_val; } %typemap(directorout,noblock=1,fragment=frag) Type { Type swig_val; int swig_res = asval_meth($input, &swig_val); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res, "$type"); } $result = %static_cast(swig_val,$type); } %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const Type& { Type swig_val; int swig_res = asval_meth($input, &swig_val); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res, "$type"); } $basetype *temp = new $basetype(($basetype)swig_val); swig_acquire_ownership(temp); $result = temp; } %typemap(directorfree,noblock=1) const Type & { if (director) { director->swig_release_ownership(%as_voidptr($input)); } } %typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type %enddef #else #define %value_directorin_typemap(from_meth,frag,Type...) #define %value_directorout_typemap(asval_meth,frag,Type...) #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* throws */ %define %value_throws_typemap(from_meth,frag,Type...) %typemap(throws,noblock=1,fragment=frag) Type { %raise(from_meth(%static_cast($1,Type)), "$type", 0); } %enddef /* typecheck */ %define %value_typecheck_typemap(check,asval_meth,frag,Type...) %typemap(typecheck,precedence=check,fragment=frag) Type, const Type& { int res = asval_meth($input, NULL); $1 = SWIG_CheckState(res); } %enddef /*--------------------------------------------------------------------- * typemap definition for types with AsVal methods *---------------------------------------------------------------------*/ %define %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type...) %value_in_typemap(%arg(AsValMeth), %arg(AsValFrag), Type); %value_varin_typemap(%arg(AsValMeth), %arg(AsValFrag), Type); %value_directorout_typemap(%arg(AsValMeth), %arg(AsValFrag), Type); %value_typecheck_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type); %value_input_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with from method *---------------------------------------------------------------------*/ %define %typemaps_from(FromMeth, FromFrag, Type...) %value_out_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_varout_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_constcode_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_directorin_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_throws_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with alval/from method *---------------------------------------------------------------------*/ %define %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...) %typemaps_asval(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type); %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type); %value_inout_typemap(Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with for 'normalized' asval/from methods *---------------------------------------------------------------------*/ %define %typemaps_asvalfromn(CheckCode, Type...) %typemaps_asvalfrom(%arg(CheckCode), SWIG_AsVal(Type), SWIG_From(Type), %arg(SWIG_AsVal_frag(Type)), %arg(SWIG_From_frag(Type)), Type); %enddef swig-3.0.2/Lib/typemaps/primtypes.swg0000664000175000017500000002064012343605122017473 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive type fragments and macros * ------------------------------------------------------------ */ /* This file provide fragments and macros for the C/C++ primitive types. The file defines default fragments for the following types: bool signed char unsigned char signed wchar_t // in C++ unsigned wchar_t // in C++ short unsigned short int unsigned int float size_t ptrdiff_t which can always be redefined in the swig target language if needed. The fragments for the following types, however, always need to be defined in the target language: long unsigned long long long unsigned long long double If they are not provided, an #error directive will appear in the wrapped code. -------------------------------------------------------------------- This file provides the macro %typemaps_primitive(CheckCode, Type) which generates the typemaps for a primitive type with a given checkcode. It is assumed that the primitive type is 'normalized' and the corresponding SWIG_AsVal(Type) and SWIG_From(Type) methods are provided via fragments. The following auxiliary macros (explained with bash pseudo code) are also defined: %apply_ctypes(Macro) for i in C Type do Macro($i) done %apply_cpptypes(Macro) for i in C++ Type do Macro($i) done %apply_ctypes_2(Macro2) for i in C Type do for j in C Type do Macro_2($i, $j) done done %apply_cpptypes_2(Macro2) for i in C++ Type do for j in C++ Type do Macro_2($i, $j) done done %apply_checkctypes(Macro2) for i in Check Type do Macro2(%checkcode($i), $i) done */ /* ------------------------------------------------------------ * Primitive type fragments * ------------------------------------------------------------ */ /* boolean */ %fragment(SWIG_From_frag(bool),"header",fragment=SWIG_From_frag(long)) { SWIGINTERN SWIG_Object SWIG_From_dec(bool)(bool value) { return SWIG_From(long)(value ? 1 : 0); } } %fragment(SWIG_AsVal_frag(bool),"header",fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val) { long v; int res = SWIG_AsVal(long)(obj, val ? &v : 0); if (SWIG_IsOK(res)) { if (val) *val = v ? true : false; return res; } return SWIG_TypeError; } } /* signed/unsigned char */ %numeric_slong(signed char, "", SCHAR_MIN, SCHAR_MAX) %numeric_ulong(unsigned char, "", UCHAR_MAX) /* short/unsigned short */ %numeric_slong(short, "", SHRT_MIN, SHRT_MAX) %numeric_ulong(unsigned short, "", USHRT_MAX) /* int/unsigned int */ %numeric_slong(int, "", INT_MIN, INT_MAX) %numeric_ulong(unsigned int, "", UINT_MAX) /* signed/unsigned wchar_t */ #ifdef __cplusplus %numeric_slong(signed wchar_t, "", WCHAR_MIN, WCHAR_MAX) %numeric_ulong(unsigned wchar_t, "", UWCHAR_MAX) #endif /* float */ %numeric_float(float, "SWIG_Float_Overflow_Check", SWIG_Float_Overflow_Check(v)) /* long/unsigned long */ %ensure_type_fragments(long) %ensure_type_fragments(unsigned long) /* long long/unsigned long long */ %ensure_type_fragments(long long) %ensure_type_fragments(unsigned long long) /* double */ %ensure_type_fragments(double) /* size_t */ %fragment(SWIG_From_frag(size_t),"header",fragment=SWIG_From_frag(unsigned long)) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(size_t)(size_t value) { return SWIG_From(unsigned long)(%numeric_cast(value, unsigned long)); } } %fragment(SWIG_AsVal_frag(size_t),"header",fragment=SWIG_AsVal_frag(unsigned long)) { SWIGINTERNINLINE int SWIG_AsVal_dec(size_t)(SWIG_Object obj, size_t *val) { unsigned long v; int res = SWIG_AsVal(unsigned long)(obj, val ? &v : 0); if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, size_t); return res; } } /* ptrdiff_t */ %fragment(SWIG_From_frag(ptrdiff_t),"header",fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(ptrdiff_t)(ptrdiff_t value) { return SWIG_From(long)(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(ptrdiff_t),"header",fragment=SWIG_AsVal_frag(long)) { SWIGINTERNINLINE int SWIG_AsVal_dec(ptrdiff_t)(SWIG_Object obj, ptrdiff_t *val) { long v; int res = SWIG_AsVal(long)(obj, val ? &v : 0); if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, ptrdiff_t); return res; } } %fragment("SWIG_CanCastAsInteger","header", fragment=SWIG_AsVal_frag(double), fragment="", fragment="") { SWIGINTERNINLINE int SWIG_CanCastAsInteger(double *d, double min, double max) { double x = *d; if ((min <= x && x <= max)) { double fx = floor(x); double cx = ceil(x); double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ if ((errno == EDOM) || (errno == ERANGE)) { errno = 0; } else { double summ, reps, diff; if (rd < x) { diff = x - rd; } else if (rd > x) { diff = rd - x; } else { return 1; } summ = rd + x; reps = diff/summ; if (reps < 8*DBL_EPSILON) { *d = rd; return 1; } } } return 0; } } /* ------------------------------------------------------------ * Generate the typemaps for primitive type * ------------------------------------------------------------ */ #define %typemaps_primitive(Code, Type) %typemaps_asvalfromn(%arg(Code), Type) /* ------------------------------------------------------------ * Primitive Type Macros * ------------------------------------------------------------ */ /* useful macros to derive typemap declarations from primitive types */ %define _apply_macro(macro, arg2, arg1...) #if #arg1 != "" macro(%arg(arg1),arg2); #else macro(arg2); #endif %enddef /* Apply macro to the C-types */ %define %apply_ctypes(Macro, Arg2...) _apply_macro(Macro, bool , Arg2); _apply_macro(Macro, signed char , Arg2); _apply_macro(Macro, unsigned char , Arg2); _apply_macro(Macro, short , Arg2); _apply_macro(Macro, unsigned short , Arg2); _apply_macro(Macro, int , Arg2); _apply_macro(Macro, unsigned int , Arg2); _apply_macro(Macro, long , Arg2); _apply_macro(Macro, unsigned long , Arg2); _apply_macro(Macro, long long , Arg2); _apply_macro(Macro, unsigned long long , Arg2); _apply_macro(Macro, float , Arg2); _apply_macro(Macro, double , Arg2); _apply_macro(Macro, char , Arg2); _apply_macro(Macro, wchar_t , Arg2); _apply_macro(Macro, size_t , Arg2); _apply_macro(Macro, ptrdiff_t , Arg2); %enddef /* apply the Macro2(Type1, Type2) to all C types */ #define %apply_ctypes_2(Macro2) %apply_ctypes(%apply_ctypes, Macro2) /* apply the Macro(Type) to all C++ types */ %define %apply_cpptypes(Macro, Arg2...) %apply_ctypes(Macro, Arg2) _apply_macro(Macro, std::size_t, Arg2); _apply_macro(Macro, std::ptrdiff_t, Arg2); _apply_macro(Macro, std::string, Arg2); _apply_macro(Macro, std::wstring, Arg2); _apply_macro(Macro, std::complex, Arg2); _apply_macro(Macro, std::complex, Arg2); %enddef /* apply the Macro2(Type1, Type2) to all C++ types */ #define %apply_cpptypes_2(Macro2) %apply_cpptypes(%apply_cpptypes, Macro2) /* apply the Macro2(CheckCode,Type) to all Checked Types */ %define %apply_checkctypes(Macro2) Macro2(%checkcode(BOOL), bool); Macro2(%checkcode(INT8), signed char); Macro2(%checkcode(UINT8), unsigned char); Macro2(%checkcode(INT16), short); Macro2(%checkcode(UINT16), unsigned short); Macro2(%checkcode(INT32), int); Macro2(%checkcode(UINT32), unsigned int); Macro2(%checkcode(INT64), long); Macro2(%checkcode(UINT64), unsigned long); Macro2(%checkcode(INT128), long long); Macro2(%checkcode(UINT128), unsigned long long); Macro2(%checkcode(FLOAT), float); Macro2(%checkcode(DOUBLE), double); Macro2(%checkcode(CHAR), char); Macro2(%checkcode(UNICHAR), wchar_t); Macro2(%checkcode(SIZE), size_t); Macro2(%checkcode(PTRDIFF), ptrdiff_t); %enddef /* ------------------------------------------------------------ * Generate the typemaps for all the primitive types with checkcode * ------------------------------------------------------------ */ %apply_checkctypes(%typemaps_primitive); swig-3.0.2/Lib/typemaps/cstring.swg0000664000175000017500000000024712343605122017111 0ustar williamwilliam%include %typemaps_cstring(%cstring, char, SWIG_AsCharPtr, SWIG_AsCharPtrAndSize, SWIG_FromCharPtr, SWIG_FromCharPtrAndSize); swig-3.0.2/Lib/typemaps/swigmacros.swg0000664000175000017500000001755312343605122017626 0ustar williamwilliam/* ----------------------------------------------------------------------------- * SWIG API. Portion only visible from SWIG * ----------------------------------------------------------------------------- */ /* This file implements the internal macros of the 'SWIG API', which are useful to implement all the SWIG target languages. Basic preprocessor macros: -------------------------- %arg(Arg) Safe argument wrap %str(Arg) Stringify the argument %begin_block Begin an execution block %end_block End an execution block %block(Block) Execute Block as an execution block %define_as(Def, Val) Define 'Def' as 'Val', expanding Def and Val first %ifcplusplus(V1, V2) if C++ Mode; then V1; else V2; fi Casting Operations: ------------------- SWIG provides the following casting macros, which implement the corresponding C++ casting operations: %const_cast(a, Type) const_cast(a) %static_cast(a, Type) static_cast(a) %reinterpret_cast(a, Type) reinterpret_cast(a) %numeric_cast(a, Type) static_cast(a) %as_voidptr(a) const_cast(static_cast(a)) %as_voidptrptr(a) reinterpret_cast(a) or their C unsafe versions. In C++ we use the safe version unless SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag). Memory allocation: ------------------ These allocation/freeing macros are safe to use in C or C++ and dispatch the proper new/delete/delete[] or free/malloc calls as needed. %new_instance(Type) Allocate a new instance of given Type %new_copy(value,Type) Allocate and initialize a new instance with 'value' %new_array(size,Type) Allocate a new array with given size and Type %new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr' %delete(cptr) Delete an instance %delete_array(cptr) Delete an array Auxiliary loop macros: ---------------------- %formacro(Macro, Args...) or %formacro_1(Macro, Args...) for i in Args do Macro($i) done %formacro_2(Macro2, Args...) for i,j in Args do Macro2($i, $j) done Flags and conditional macros: ----------------------------- %mark_flag(flag) flag := True %evalif(flag,expr) if flag; then expr fi %evalif_2(flag1 flag2,expr) if flag1 and flag2; then expr fi */ /* ----------------------------------------------------------------------------- * Basic preprocessor macros * ----------------------------------------------------------------------------- */ #define %arg(Arg...) Arg #define %str(Arg) `Arg` #ifndef %begin_block # define %begin_block do { #endif #ifndef %end_block # define %end_block } while(0) #endif #define %block(Block...) %begin_block Block; %end_block /* define a new macro */ %define %define_as(Def, Val...)%#define Def Val %enddef /* include C++ or else value */ %define %ifcplusplus(cppval, nocppval) #ifdef __cplusplus cppval #else nocppval #endif %enddef /* insert the SWIGVERSION in the interface and the wrapper code */ #if SWIG_VERSION %insert("header") { %define_as(SWIGVERSION, SWIG_VERSION) %#define SWIG_VERSION SWIGVERSION } #endif /* ----------------------------------------------------------------------------- * Casting operators * ----------------------------------------------------------------------------- */ #if defined(SWIG_NO_CPLUSPLUS_CAST) /* Disable 'modern' cplusplus casting operators */ # if defined(SWIG_CPLUSPLUS_CAST) # undef SWIG_CPLUSPLUS_CAST # endif #endif #if defined(__cplusplus) && defined(SWIG_CPLUSPLUS_CAST) # define %const_cast(a,Type...) const_cast< Type >(a) # define %static_cast(a,Type...) static_cast< Type >(a) # define %reinterpret_cast(a,Type...) reinterpret_cast< Type >(a) # define %numeric_cast(a,Type...) static_cast< Type >(a) #else /* C case */ # define %const_cast(a,Type...) (Type)(a) # define %static_cast(a,Type...) (Type)(a) # define %reinterpret_cast(a,Type...) (Type)(a) # define %numeric_cast(a,Type...) (Type)(a) #endif /* __cplusplus */ #define %as_voidptr(a) SWIG_as_voidptr(a) #define %as_voidptrptr(a) SWIG_as_voidptrptr(a) %insert("header") { %define_as(SWIG_as_voidptr(a), %const_cast(%static_cast(a,const void *), void *)) %define_as(SWIG_as_voidptrptr(a), ((void)%as_voidptr(*a),%reinterpret_cast(a, void**))) } /* ----------------------------------------------------------------------------- * Allocating/freeing elements * ----------------------------------------------------------------------------- */ #if defined(__cplusplus) # define %new_instance(Type...) (new Type) # define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&))) # define %new_array(size,Type...) (new Type[size]) # define %new_copy_array(ptr,size,Type...) %reinterpret_cast(memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size)), Type*) # define %delete(cptr) delete cptr # define %delete_array(cptr) delete[] cptr #else /* C case */ # define %new_instance(Type...) (Type *)malloc(sizeof(Type)) # define %new_copy(val,Type...) (Type *)memcpy(%new_instance(Type),&val,sizeof(Type)) # define %new_array(size,Type...) (Type *)malloc((size)*sizeof(Type)) # define %new_copy_array(ptr,size,Type...) (Type *)memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size)) # define %delete(cptr) free((char*)cptr) # define %delete_array(cptr) free((char*)cptr) #endif /* __cplusplus */ /* ----------------------------------------------------------------------------- * SWIG names and mangling * ----------------------------------------------------------------------------- */ #define %mangle(Type...) #@Type #define %descriptor(Type...) SWIGTYPE_ ## #@Type #define %string_name(Name) "SWIG_" %str(Name) #define %symbol_name(Name, Type...) SWIG_ ## Name ## _ #@Type #define %checkcode(Code) SWIG_TYPECHECK_ ## Code /* ----------------------------------------------------------------------------- * Auxiliary loop macros * ----------------------------------------------------------------------------- */ /* for loop for macro with one argument */ %define %_formacro_1(macro, arg1,...)macro(arg1) #if #__VA_ARGS__ != "__fordone__" %_formacro_1(macro, __VA_ARGS__) #endif %enddef /* for loop for macro with one argument */ %define %formacro_1(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef %define %formacro(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef /* for loop for macro with two arguments */ %define %_formacro_2(macro, arg1, arg2, ...)macro(arg1, arg2) #if #__VA_ARGS__ != "__fordone__" %_formacro_2(macro, __VA_ARGS__) #endif %enddef /* for loop for macro with two arguments */ %define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef /* ----------------------------------------------------------------------------- * SWIG flags * ----------------------------------------------------------------------------- */ /* mark a flag, ie, define a macro name but ignore it in the interface. the flag can be later used with %evalif */ %define %mark_flag(x) %define x 1 %enddef %enddef /* %evalif and %evalif_2 are use to evaluate or process an expression if the given predicate is 'true' (1). */ %define %_evalif(_x,_expr) #if _x == 1 _expr #endif %enddef %define %_evalif_2(_x,_y,_expr) #if _x == 1 && _y == 1 _expr #endif %enddef %define %evalif(_x,_expr...) %_evalif(%arg(_x),%arg(_expr)) %enddef %define %evalif_2(_x,_y,_expr...) %_evalif_2(%arg(_x),%arg(_y),%arg(_expr)) %enddef swig-3.0.2/Lib/typemaps/enumint.swg0000664000175000017500000000236412343605122017121 0ustar williamwilliam/* ------------------------------------------------------------ * Enums mapped as integer values * ------------------------------------------------------------ */ %apply int { enum SWIGTYPE }; %apply const int& { const enum SWIGTYPE & }; %apply const int& { const enum SWIGTYPE && }; %typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE & (int val, int ecode, $basetype temp) { ecode = SWIG_AsVal(int)($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$type", $symname, $argnum); } else { temp = %static_cast(val,$basetype); $1 = &temp; } } %typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE && (int val, int ecode, $basetype temp) { ecode = SWIG_AsVal(int)($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$type", $symname, $argnum); } else { temp = %static_cast(val,$basetype); $1 = &temp; } } %typemap(varin,fragment=SWIG_AsVal_frag(int),noblock=1) enum SWIGTYPE { if (sizeof(int) != sizeof($1)) { %variable_fail(SWIG_AttributeError,"$type", "arch, read-only $name"); } else { int ecode = SWIG_AsVal(int)($input, %reinterpret_cast(&$1,int*)); if (!SWIG_IsOK(ecode)) { %variable_fail(ecode, "$type", "$name"); } } } swig-3.0.2/Lib/typemaps/swigtypemaps.swg0000664000175000017500000001157412343605122020201 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigtypemaps.swg * * Unified Typemap Library frontend * ----------------------------------------------------------------------------- */ /* This file provides the frontend to the Unified Typemap Library. When using this library in a SWIG target language, you need to define a minimum set of fragments, specialize a couple of macros, and then include this file. Typically you will create a 'mytypemaps.swg' file in each target language, where you will have the following sections: === mytypemaps.swg === // Fragment section %include // Unified typemap section %include // Local typemap section === mytypemaps.swg === While we add more docs, please take a look at the following cases to see how you specialized the unified typemap library for a new target language: Lib/python/pytypemaps.swg Lib/tcl/tcltypemaps.swg Lib/ruby/rubytypemaps.swg Lib/perl5/perltypemaps.swg */ #define SWIGUTL SWIGUTL /* ----------------------------------------------------------------------------- * Language specialization section. * * Tune these macros for each language as needed. * ----------------------------------------------------------------------------- */ /* The SWIG target language object must be provided. For example in python you define: #define SWIG_Object PyObject * */ #if !defined(SWIG_Object) #error "SWIG_Object must be defined as the SWIG target language object" #endif /*==== flags for new/convert methods ====*/ #ifndef %convertptr_flags %define %convertptr_flags 0 %enddef #endif #ifndef %newpointer_flags %define %newpointer_flags 0 %enddef #endif #ifndef %newinstance_flags %define %newinstance_flags 0 %enddef #endif /*==== set output ====*/ #ifndef %set_output /* simple set output operation */ #define %set_output(obj) $result = obj #endif /*==== set variable output ====*/ #ifndef %set_varoutput /* simple set varoutput operation */ #define %set_varoutput(obj) $result = obj #endif /*==== append output ====*/ #ifndef %append_output #if defined(SWIG_AppendOutput) /* simple append operation */ #define %append_output(obj) $result = SWIG_AppendOutput($result,obj) #else #error "Language must define SWIG_AppendOutput or %append_output" #endif #endif /*==== set constant ====*/ #ifndef %set_constant #if defined(SWIG_SetConstant) /* simple set constant operation */ #define %set_constant(name,value) SWIG_SetConstant(name,value) #else #error "Language must define SWIG_SetConstant or %set_constant" #endif #endif /*==== raise an exception ====*/ #ifndef %raise #if defined(SWIG_Raise) /* simple raise operation */ #define %raise(obj, type, desc) SWIG_Raise(obj, type, desc); SWIG_fail #else #error "Language must define SWIG_Raise or %raise" #endif #endif /*==== director output exception ====*/ #if defined(SWIG_DIRECTOR_TYPEMAPS) #ifndef SWIG_DirOutFail #define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg) #endif #endif /* ----------------------------------------------------------------------------- * Language independent definitions * ----------------------------------------------------------------------------- */ #define %error_block(Block...) %block(Block) #define %default_code(code) SWIG_ArgError(code) #define %argument_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %argfail_fmt(type, name, argn)) #define %argument_nullref(type, name, argn) SWIG_exception_fail(SWIG_ValueError, %argnullref_fmt(type, name, argn)) #define %variable_fail(code, type, name) SWIG_exception_fail(%default_code(code), %varfail_fmt(type, name)) #define %variable_nullref(type, name) SWIG_exception_fail(SWIG_ValueError, %varnullref_fmt(type, name)) #if defined(SWIG_DIRECTOR_TYPEMAPS) #define %dirout_fail(code, type) SWIG_DirOutFail(%default_code(code), %outfail_fmt(type)) #define %dirout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type)) #endif /* ----------------------------------------------------------------------------- * All the typemaps * ----------------------------------------------------------------------------- */ %include %include %include %include %include %include %include %include %include %include %include %include swig-3.0.2/Lib/typemaps/std_except.swg0000664000175000017500000000224212343605122017577 0ustar williamwilliam%include /* Mark all of std exception classes as "exception classes" via the "exceptionclass" feature. If needed, you can disable it by using %noexceptionclass. */ %define %std_exception_map(Exception, Code) %exceptionclass Exception; #if !defined(SWIG_STD_EXCEPTIONS_AS_CLASSES) %typemap(throws,noblock=1) Exception { SWIG_exception_fail(Code, $1.what()); } %ignore Exception; struct Exception { }; #endif %enddef namespace std { %std_exception_map(bad_exception, SWIG_SystemError); %std_exception_map(domain_error, SWIG_ValueError); %std_exception_map(exception, SWIG_SystemError); %std_exception_map(invalid_argument, SWIG_ValueError); %std_exception_map(length_error, SWIG_IndexError); %std_exception_map(logic_error, SWIG_RuntimeError); %std_exception_map(out_of_range, SWIG_IndexError); %std_exception_map(overflow_error, SWIG_OverflowError); %std_exception_map(range_error, SWIG_OverflowError); %std_exception_map(runtime_error, SWIG_RuntimeError); %std_exception_map(underflow_error, SWIG_OverflowError); } %include swig-3.0.2/Lib/typemaps/implicit.swg0000664000175000017500000001133212343605122017247 0ustar williamwilliam/* The %implicit macro allows a SwigType (Class) to be accepted as an input parameter and use its implicit constructors when needed. For example: %implicit(A, int, double, B); %inline { struct B { }; struct A { int ii; A(int i) { ii = 1; } A(double d) { ii = 2; } A(const B& b) { ii = 3; } }; int get(A a) { return a.ii; } } Here, you can call 'get' as get(1) ==> get(A(1)) get(2.0) ==> get(A(2.0)) get(B()) ==> get(A(B())) and swig will construct an 'A' temporal variable using the corresponding implicit constructor. The plain implicit macro takes care of simple type list. If it doesn't work because you are passing template types with commas, then use the %implicit_{1,2,3} versions and/or the %arg macro. */ %define %implicit_type(Type...) %traits_swigtype(Type); %enddef %define %implicit_frag(Type...) ,fragment=SWIG_Traits_frag(Type) %enddef %define %implicit_code(Type...) { Type _v; int res = swig::asval(obj, &_v); if (SWIG_IsOK(res)) { if (val) *val = new value_type(static_cast(_v)); return SWIG_AddNewMask(res); } } %enddef /* implicit */ %define %implicit(Type, ...) %formacro_1(%implicit_type,__VA_ARGS__); %fragment(SWIG_Traits_frag(Type),"header", fragment="StdTraits" %formacro_1(%implicit_frag,__VA_ARGS__)) %{ namespace swig { template <> struct traits { typedef pointer_category category; static const char* type_name() { return "Type"; } }; template <> struct traits_asptr< Type > { typedef Type value_type; static int asptr(SWIG_Object obj, value_type **val) { Type *vptr; static swig_type_info* desc = SWIG_TypeQuery("Type *"); int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); if (SWIG_IsOK(res)) { if (val) *val = vptr; return res; } else { %formacro_1(%implicit_code,__VA_ARGS__) } return SWIG_TypeError; } }; } %} %typemap_traits_ptr(%checkcode(POINTER),Type); %enddef /* implicit_1 */ %define %implicit_1(Type, Imp1) %traits_swigtype(Imp1); %fragment(SWIG_Traits_frag(Type),"header", fragment="StdTraits", fragment=SWIG_Traits_frag(Imp1)) %{ namespace swig { template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return "Type"; } }; template <> struct traits_asptr< Type > { typedef Type value_type; static int asptr(SWIG_Object obj, value_type **val) { Type *vptr; static swig_type_info* desc = SWIG_TypeQuery("Type *"); int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); if (SWIG_IsOK(res)) { if (val) *val = vptr; return res; } else { %implicit_code(Imp1); } return SWIG_TypeError; } }; } %} %typemap_traits_ptr(%checkcode(POINTER),Type); %enddef /* implicit_2 */ %define %implicit_2(Type, Imp1, Imp2) %traits_swigtype(Imp1); %traits_swigtype(Imp2); %fragment(SWIG_Traits_frag(Type),"header", fragment="StdTraits", fragment=SWIG_Traits_frag(Imp1), fragment=SWIG_Traits_frag(Imp2)) %{ namespace swig { template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return "Type"; } }; template <> struct traits_asptr< Type > { typedef Type value_type; static int asptr(SWIG_Object obj, value_type **val) { Type *vptr; static swig_type_info* desc = SWIG_TypeQuery("Type *"); int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); if (SWIG_IsOK(res)) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { %implicit_code(Imp1); %implicit_code(Imp2); } return SWIG_TypeError; } }; } %} %typemap_traits_ptr(%checkcode(POINTER),Type); %enddef /* implicit_3 */ %define %implicit_3(Type, Imp1, Imp2, Imp3) %traits_swigtype(Imp1); %traits_swigtype(Imp2); %traits_swigtype(Imp3); %fragment(SWIG_Traits_frag(Type),"header", fragment="StdTraits", fragment=SWIG_Traits_frag(Imp1), fragment=SWIG_Traits_frag(Imp2), fragment=SWIG_Traits_frag(Imp3)) %{ namespace swig { template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return "Type"; } }; template <> struct traits_asptr< Type > { typedef Type value_type; static int asptr(SWIG_Object obj, value_type **val) { Type *vptr; static swig_type_info* desc = SWIG_TypeQuery("Type *"); int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); if (SWIG_IsOK(res)) { if (val) *val = vptr; return res; } else { %implicit_code(Imp1); %implicit_code(Imp2); %implicit_code(Imp3); } return SWIG_TypeError; } }; } %} %typemap_traits_ptr(%checkcode(POINTER),Type); %enddef swig-3.0.2/Lib/typemaps/fragments.swg0000664000175000017500000001757012343605122017435 0ustar williamwilliam/* Fragments ========= See the "Typemap fragments" section in the documentation for understanding fragments. Below is some info on how fragments and automatic type specialization is used. Macros that make the automatic generation of typemaps easier are provided. Consider the following code: %fragment(SWIG_From_frag(bool), "header") { static PyObject* SWIG_From_dec(bool)(bool value) { PyObject *obj = value ? Py_True : Py_False; Py_INCREF(obj); return obj; } } %typemap(out, fragment=SWIG_From_frag(bool)) bool { $result = SWIG_From(bool)($1)); } Here the macros SWIG_From_frag => fragment SWIG_From_dec => declaration SWIG_From => call allow you to define/include a fragment, and declare and call the 'from-bool' method as needed. In the simpler case, these macros just return something like SWIG_From_frag(bool) => "SWIG_From_bool" SWIG_From_dec(bool) => SWIG_From_bool SWIG_From(bool) => SWIG_From_bool But they are specialized for the different languages requirements, such as perl or tcl that requires passing the interpreter pointer, and also they can manage C++ ugly types, for example: SWIG_From_frag(std::complex) => "SWIG_From_std_complex_Sl_double_Sg_" SWIG_From_dec(std::complex) => SWIG_From_std_complex_Sl_double_Sg_ SWIG_From(std::complex) => SWIG_From_std_complex_Sl_double_Sg_ Hence, to declare methods to use with typemaps, always use the SWIG_From* macros. In the same way, the SWIG_AsVal* and SWIG_AsPtr* set of macros are provided. */ /* ----------------------------------------------------------------------------- * Define the basic macros to 'normalize' the type fragments * ----------------------------------------------------------------------------- */ #ifndef SWIG_AS_DECL_ARGS #define SWIG_AS_DECL_ARGS #endif #ifndef SWIG_FROM_DECL_ARGS #define SWIG_FROM_DECL_ARGS #endif #ifndef SWIG_AS_CALL_ARGS #define SWIG_AS_CALL_ARGS #endif #ifndef SWIG_FROM_CALL_ARGS #define SWIG_FROM_CALL_ARGS #endif #define %fragment_name(Name, Type...) %string_name(Name) "_" {Type} #define SWIG_Traits_frag(Type...) %fragment_name(Traits, Type) #define SWIG_AsPtr_frag(Type...) %fragment_name(AsPtr, Type) #define SWIG_AsVal_frag(Type...) %fragment_name(AsVal, Type) #define SWIG_From_frag(Type...) %fragment_name(From, Type) #define SWIG_AsVal_name(Type...) %symbol_name(AsVal, Type) #define SWIG_AsPtr_name(Type...) %symbol_name(AsPtr, Type) #define SWIG_From_name(Type...) %symbol_name(From, Type) #define SWIG_AsVal_dec(Type...) SWIG_AsVal_name(Type) SWIG_AS_DECL_ARGS #define SWIG_AsPtr_dec(Type...) SWIG_AsPtr_name(Type) SWIG_AS_DECL_ARGS #define SWIG_From_dec(Type...) SWIG_From_name(Type) SWIG_FROM_DECL_ARGS #define SWIG_AsVal(Type...) SWIG_AsVal_name(Type) SWIG_AS_CALL_ARGS #define SWIG_AsPtr(Type...) SWIG_AsPtr_name(Type) SWIG_AS_CALL_ARGS #define SWIG_From(Type...) SWIG_From_name(Type) SWIG_FROM_CALL_ARGS /* ------------------------------------------------------------ * common fragments * ------------------------------------------------------------ */ /* Default compiler options for gcc allow long_long but not LLONG_MAX. * Define SWIG_NO_LLONG_MAX if this added limits support is not wanted. */ %fragment("","header") %{ #include #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) # define LLONG_MAX __LONG_LONG_MAX__ # define LLONG_MIN (-LLONG_MAX - 1LL) # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) # endif #endif %} %fragment("","header") %{ #include %} %fragment("","header") %{ #include #include #ifndef WCHAR_MIN # define WCHAR_MIN 0 #endif #ifndef WCHAR_MAX # define WCHAR_MAX 65535 #endif %} %fragment("","header") %{ #include %} %fragment("","header") %{ #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf # define snprintf _snprintf # endif #endif %} %fragment("","header") %{ #include #ifdef _MSC_VER # ifndef strtoull # define strtoull _strtoui64 # endif # ifndef strtoll # define strtoll _strtoi64 # endif #endif %} %fragment("", "header") %{ #include %} %fragment("", "header") %{ #include %} %fragment("", "header") %{ #include %} %fragment("", "header") %{ #include %} %fragment("SWIG_isfinite","header",fragment=",") %{ /* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ #ifndef SWIG_isfinite # if defined(isfinite) # define SWIG_isfinite(X) (isfinite(X)) # elif defined(_MSC_VER) # define SWIG_isfinite(X) (_finite(X)) # elif defined(__sun) && defined(__SVR4) # include # define SWIG_isfinite(X) (finite(X)) # endif #endif %} %fragment("SWIG_Float_Overflow_Check","header",fragment=",SWIG_isfinite") %{ /* Accept infinite as a valid float value unless we are unable to check if a value is finite */ #ifdef SWIG_isfinite # define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X)) #else # define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX)) #endif %} /* ----------------------------------------------------------------------------- * special macros for fragments * ----------------------------------------------------------------------------- */ /* Macros to derive numeric types */ %define %numeric_type_from(Type, Base) %fragment(SWIG_From_frag(Type),"header", fragment=SWIG_From_frag(Base)) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(Type)(Type value) { return SWIG_From(Base)(value); } } %enddef %define %numeric_type_asval(Type, Base, Frag, OverflowCond) %fragment(SWIG_AsVal_frag(Type),"header", fragment=Frag, fragment=SWIG_AsVal_frag(Base)) { SWIGINTERN int SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val) { Base v; int res = SWIG_AsVal(Base)(obj, &v); if (SWIG_IsOK(res)) { if (OverflowCond) { return SWIG_OverflowError; } else { if (val) *val = %numeric_cast(v, Type); } } return res; } } %enddef #define %numeric_signed_type_asval(Type, Base, Frag, Min, Max) \ %numeric_type_asval(Type, Base, Frag, (v < Min || v > Max)) #define %numeric_unsigned_type_asval(Type, Base, Frag, Max) \ %numeric_type_asval(Type, Base, Frag, (v > Max)) /* Macro for 'signed long' derived types */ %define %numeric_slong(Type, Frag, Min, Max) %numeric_type_from(Type, long) %numeric_signed_type_asval(Type, long, Frag , Min, Max) %enddef /* Macro for 'unsigned long' derived types */ %define %numeric_ulong(Type, Frag, Max) %numeric_type_from(Type, unsigned long) %numeric_unsigned_type_asval(Type, unsigned long, Frag, Max) %enddef /* Macro for floating point derived types (original macro) */ %define %numeric_double(Type, Frag, Min, Max) %numeric_type_from(Type, double) %numeric_signed_type_asval(Type, double, Frag , Min, Max) %enddef /* Macro for floating point derived types */ %define %numeric_float(Type, Frag, OverflowCond) %numeric_type_from(Type, double) %numeric_type_asval(Type, double, Frag, OverflowCond) %enddef /* Macros for missing fragments */ %define %ensure_fragment(Fragment) %fragment(`Fragment`,"header") { %#error "SWIG language implementation must provide the Fragment fragment" } %enddef %define %ensure_type_fragments(Type) %fragment(SWIG_From_frag(Type),"header") { %#error "SWIG language implementation must provide a SWIG_From_frag(Type) fragment" } %fragment(SWIG_AsVal_frag(Type),"header") { %#error "SWIG language implementation must provide a SWIG_AsVal_frag(Type) fragment" } %enddef swig-3.0.2/Lib/typemaps/inoutlist.swg0000664000175000017500000002241112343605122017467 0ustar williamwilliam/* ------------------------------------------------------------ * * Define the IN/OUTPUT typemaps assuming the output parameters are * returned in a list, i.e., they are not directly modified. * * The user should provide the %append_output(result, obj) method, * via a macro, which append a particular object to the result. * * * In Tcl, for example, the file is used as: * * #define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj); * %include * * while in Python it is used as: * * #define %append_output(obj) $result = SWIG_Python_AppendResult($result, obj) * %include * * where the method SWIG_Python_AppendResult is defined inside the * %append_output fragment. * * If you forget to define %append_output, this file will generate * an error. * * ------------------------------------------------------------ */ // // Uncomment the following definition if you don't want the in/out // typemaps by default, ie, you prefer to use typemaps.i. // //#define SWIG_INOUT_NODEF // // Use the following definition to enable the INPUT parameters to // accept both 'by value' and 'pointer' objects. // #define SWIG_INPUT_ACCEPT_PTRS // ------------------------------------------------------------------------ // Pointer handling // // These mappings provide support for input/output arguments and common // uses for C/C++ pointers. // ------------------------------------------------------------------------ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ #if defined(SWIG_INPUT_ACCEPT_PTRS) #define %check_input_ptr(input,arg,desc,disown) (SWIG_IsOK((res = SWIG_ConvertPtr(input,%as_voidptrptr(arg),desc,disown)))) #else #define %check_input_ptr(input,arg,desc,disown) (SWIG_IsOK((res = SWIG_ERROR))) #endif %define %_value_input_typemap(code, asval_meth, asval_frag, Type) %typemap(in,noblock=1,fragment=asval_frag) Type *INPUT ($*ltype temp, int res = 0) { if (!%check_input_ptr($input,&$1,$descriptor,$disown)) { Type val; int ecode = asval_meth($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$*ltype",$symname, $argnum); } temp = %static_cast(val, $*ltype); $1 = &temp; res = SWIG_AddTmpMask(ecode); } } %typemap(in,noblock=1,fragment=asval_frag) Type &INPUT($*ltype temp, int res = 0) { if (!%check_input_ptr($input,&$1,$descriptor,$disown)) { Type val; int ecode = asval_meth($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$*ltype",$symname, $argnum); } temp = %static_cast(val, $*ltype); $1 = &temp; res = SWIG_AddTmpMask(ecode); } } %typemap(freearg,noblock=1,match="in") Type *INPUT, Type &INPUT { if (SWIG_IsNewObj(res$argnum)) %delete($1); } %typemap(typecheck,noblock=1,precedence=code,fragment=asval_frag) Type *INPUT, Type &INPUT { void *ptr = 0; int res = asval_meth($input, 0); $1 = SWIG_CheckState(res); if (!$1) { $1 = %check_input_ptr($input,&ptr,$1_descriptor,0); } } %enddef %define %_ptr_input_typemap(code,asptr_meth,asptr_frag,Type) %typemap(in,noblock=1,fragment=asptr_frag) Type *INPUT(int res = 0) { res = asptr_meth($input, &$1); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } res = SWIG_AddTmpMask(res); } %typemap(in,noblock=1,fragment=asptr_frag) Type &INPUT(int res = 0) { res = asptr_meth($input, &$1); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } if (!$1) { %argument_nullref("$type",$symname, $argnum); } res = SWIG_AddTmpMask(res); } %typemap(freearg,noblock=1,match="in") Type *INPUT, Type &INPUT { if (SWIG_IsNewObj(res$argnum)) %delete($1); } %typemap(typecheck,noblock=1,precedence=code,fragment=asptr_frag) Type *INPUT, Type &INPUT { int res = asptr_meth($input, (Type**)0); $1 = SWIG_CheckState(res); } %enddef // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a list. For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters): double modf(double x, double *ip); You could wrap it with SWIG as follows : double modf(double x, double *OUTPUT); or you can use the %apply directive : %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The output of the function would be a list containing both output values. */ %define %_value_output_typemap(from_meth, from_frag, Type) %typemap(in,numinputs=0,noblock=1) Type *OUTPUT ($*1_ltype temp, int res = SWIG_TMPOBJ), Type &OUTPUT ($*1_ltype temp, int res = SWIG_TMPOBJ) { $1 = &temp; } %typemap(argout,noblock=1,fragment=from_frag) Type *OUTPUT, Type &OUTPUT { if (SWIG_IsTmpObj(res$argnum)) { %append_output(from_meth((*$1))); } else { int new_flags = SWIG_IsNewObj(res$argnum) ? (SWIG_POINTER_OWN | %newpointer_flags) : %newpointer_flags; %append_output(SWIG_NewPointerObj((void*)($1), $1_descriptor, new_flags)); } } %enddef // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a list. For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : void neg(double *INOUT); or you can use the %apply directive : %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value. Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %define %_value_inout_typemap(Type) %typemap(in) Type *INOUT = Type *INPUT; %typemap(in) Type &INOUT = Type &INPUT; %typemap(typecheck) Type *INOUT = Type *INPUT; %typemap(typecheck) Type &INOUT = Type &INPUT; %typemap(argout) Type *INOUT = Type *OUTPUT; %typemap(argout) Type &INOUT = Type &OUTPUT; %enddef %define %_ptr_inout_typemap(Type) %_value_inout_typemap(%arg(Type)) %typemap(typecheck) Type *INOUT = Type *INPUT; %typemap(typecheck) Type &INOUT = Type &INPUT; %typemap(freearg) Type *INOUT = Type *INPUT; %typemap(freearg) Type &INOUT = Type &INPUT; %enddef #ifndef SWIG_INOUT_NODEF %define %value_input_typemap(code,asval_meth, asval_frag, Type...) %_value_input_typemap(%arg(code),%arg(asval_meth),%arg(asval_frag),%arg(Type)) %enddef %define %ptr_input_typemap(code,asval_meth,asval_frag,Type...) %_ptr_input_typemap(%arg(code),%arg(asval_meth),%arg(asval_frag),%arg(Type)) %enddef %define %value_output_typemap(from_meth,from_frag,Type...) %_value_output_typemap(%arg(from_meth),%arg(from_frag),%arg(Type)) %enddef #define %value_inout_typemap(Type...) %_value_inout_typemap(%arg(Type)) #define %ptr_inout_typemap(Type...) %_ptr_inout_typemap(%arg(Type)) #else /* You need to include typemaps.i */ #define %value_output_typemap(Type...) #define %value_input_typemap(Type...) #define %value_inout_typemap(Type...) #define %ptr_input_typemap(Type...) #define %ptr_inout_typemap(Type...) #endif /* SWIG_INOUT_DEFAULT */ /*---------------------------------------------------------------------- Front ends. use the following macros to define your own IN/OUTPUT/INOUT typemaps ------------------------------------------------------------------------*/ %define %typemaps_inout(Code, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...) %_value_input_typemap(%arg(Code), %arg(AsValMeth), %arg(AsValFrag), %arg(Type)); %_value_output_typemap(%arg(FromMeth), %arg(FromFrag), %arg(Type)); %_value_inout_typemap(%arg(Type)); %enddef %define %typemaps_inoutn(Code,Type...) %typemaps_inout(%arg(Code), %arg(SWIG_AsVal(Type)), %arg(SWIG_From(Type)), %arg(SWIG_AsVal_frag(Type)), %arg(SWIG_From_frag(Type)), %arg(Type)); %enddef swig-3.0.2/Lib/typemaps/cpointer.swg0000664000175000017500000000627512343605122017272 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cpointer.swg * * This library file contains macros that can be used to manipulate simple * pointer objects. * * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %pointer_class(type,name) * * Places a simple proxy around a simple type like 'int', 'float', or whatever. * The proxy provides this interface: * * class type { * public: * type(); * ~type(); * type value(); * void assign(type value); * }; * * Example: * * %pointer_class(int, intp); * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = intp() * >>> a.assign(10) * >>> a.value() * 10 * >>> b = intp() * >>> b.assign(20) * >>> print add(a,b) * 30 * * As a general rule, this macro should not be used on class/structures that * are already defined in the interface. * ----------------------------------------------------------------------------- */ %define %pointer_class(TYPE, NAME) %{ typedef TYPE NAME; %} typedef struct { } NAME; %extend NAME { NAME() { return %new_instance(TYPE); } ~NAME() { if ($self) %delete($self); } } %extend NAME { void assign(TYPE value) { *$self = value; } TYPE value() { return *$self; } TYPE * cast() { return $self; } static NAME * frompointer(TYPE *t) { return (NAME *) t; } } %types(NAME = TYPE); %enddef /* ----------------------------------------------------------------------------- * %pointer_functions(type,name) * * Create functions for allocating/deallocating pointers. This can be used * if you don't want to create a proxy class or if the pointer is complex. * * %pointer_functions(int, intp) * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = copy_intp(10) * >>> intp_value(a) * 10 * >>> b = new_intp() * >>> intp_assign(b,20) * >>> print add(a,b) * 30 * >>> delete_intp(a) * >>> delete_intp(b) * * ----------------------------------------------------------------------------- */ %define %pointer_functions(TYPE,NAME) %{ static TYPE *new_##NAME() { return %new_instance(TYPE); } static TYPE *copy_##NAME(TYPE value) { return %new_copy(value, TYPE); } static void delete_##NAME(TYPE *obj) { if (obj) %delete(obj); } static void NAME ##_assign(TYPE *obj, TYPE value) { *obj = value; } static TYPE NAME ##_value(TYPE *obj) { return *obj; } %} TYPE *new_##NAME(); TYPE *copy_##NAME(TYPE value); void delete_##NAME(TYPE *obj); void NAME##_assign(TYPE *obj, TYPE value); TYPE NAME##_value(TYPE *obj); %enddef /* ----------------------------------------------------------------------------- * %pointer_cast(type1,type2,name) * * Generates a pointer casting function. * ----------------------------------------------------------------------------- */ %define %pointer_cast(TYPE1,TYPE2,NAME) %inline %{ TYPE2 NAME(TYPE1 x) { return %static_cast(x, TYPE2); } %} %enddef swig-3.0.2/Lib/typemaps/cmalloc.swg0000664000175000017500000000460612343605122017055 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cmalloc.swg * * This library file contains macros that can be used to create objects using * the C malloc function. * ----------------------------------------------------------------------------- */ %{ #include %} /* %malloc(TYPE [, NAME = TYPE]) %calloc(TYPE [, NAME = TYPE]) %realloc(TYPE [, NAME = TYPE]) %free(TYPE [, NAME = TYPE]) %allocators(TYPE [,NAME = TYPE]) Creates functions for allocating/reallocating memory. TYPE *malloc_NAME(size_t nbytes = sizeof(TYPE); TYPE *calloc_NAME(size_t nobj=1, size_t size=sizeof(TYPE)); TYPE *realloc_NAME(TYPE *ptr, size_t nbytes); void free_NAME(TYPE *ptr); */ %define %malloc(TYPE,NAME...) #if #NAME != "" %rename(malloc_##NAME) ::malloc(size_t nbytes); #else %rename(malloc_##TYPE) ::malloc(size_t nbytes); #endif #if #TYPE != "void" %typemap(default) size_t nbytes "$1 = (size_t) sizeof(TYPE);" #endif TYPE *malloc(size_t nbytes); %typemap(default) size_t nbytes; %enddef %define %calloc(TYPE,NAME...) #if #NAME != "" %rename(calloc_##NAME) ::calloc(size_t nobj, size_t sz); #else %rename(calloc_##TYPE) ::calloc(size_t nobj, size_t sz); #endif #if #TYPE != "void" %typemap(default) size_t sz "$1 = (size_t) sizeof(TYPE);" #else %typemap(default) size_t sz "$1 = 1;" #endif %typemap(default) size_t nobj "$1 = 1;" TYPE *calloc(size_t nobj, size_t sz); %typemap(default) size_t sz; %typemap(default) size_t nobj; %enddef %define %realloc(TYPE,NAME...) %insert("header") { #if #NAME != "" TYPE *realloc_##NAME(TYPE *ptr, size_t nitems) #else TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems) #endif { #if #TYPE != "void" return (TYPE *) realloc(ptr, nitems*sizeof(TYPE)); #else return (TYPE *) realloc(ptr, nitems); #endif } } #if #NAME != "" TYPE *realloc_##NAME(TYPE *ptr, size_t nitems); #else TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems); #endif %enddef %define %free(TYPE,NAME...) #if #NAME != "" %rename(free_##NAME) ::free(TYPE *ptr); #else %rename(free_##TYPE) ::free(TYPE *ptr); #endif void free(TYPE *ptr); %enddef %define %sizeof(TYPE,NAME...) #if #NAME != "" %constant size_t sizeof_##NAME = sizeof(TYPE); #else %constant size_t sizeof_##TYPE = sizeof(TYPE); #endif %enddef %define %allocators(TYPE,NAME...) %malloc(TYPE,NAME) %calloc(TYPE,NAME) %realloc(TYPE,NAME) %free(TYPE,NAME) #if #TYPE != "void" %sizeof(TYPE,NAME) #endif %enddef swig-3.0.2/Lib/typemaps/swigobject.swg0000664000175000017500000000157612343605122017606 0ustar williamwilliam/* ------------------------------------------------------------ * Language Object * - Just pass straight through unmodified * ------------------------------------------------------------ */ %typemap(in) SWIG_Object "$1 = $input;"; %typemap(in,noblock=1) SWIG_Object const & ($*ltype temp) { temp = %static_cast($input, $*ltype); $1 = &temp; } %typemap(out,noblock=1) SWIG_Object { %set_output($1); } %typemap(out,noblock=1) SWIG_Object const & { %set_output(*$1); } %typecheck(SWIG_TYPECHECK_SWIGOBJECT) SWIG_Object "$1 = ($input != 0);"; %typemap(throws,noblock=1) SWIG_Object { %raise($1, "$type", 0); } %typemap(constcode,noblock=1) SWIG_Object { %set_constant("$symname", $value); } #if defined(SWIG_DIRECTOR_TYPEMAPS) %typemap(directorin) SWIG_Object "$input = $1;"; %typemap(directorout) SWIG_Object "$result = $input;"; #endif /* SWIG_DIRECTOR_TYPEMAPS */ swig-3.0.2/Lib/typemaps/exception.swg0000664000175000017500000000522712343605122017441 0ustar williamwilliam/* ----------------------------------------------------------------------------- * exceptions.swg * * This SWIG library file provides language independent exception handling * ----------------------------------------------------------------------------- */ %include /* macros for error manipulation */ #define %nullref_fmt() "invalid null reference " #define %varfail_fmt(_type,_name) "in variable '"`_name`"' of type '"`_type`"'" #ifndef %argfail_fmt #define %argfail_fmt(_type,_name,_argn) "in method '" `_name` "', argument " `_argn`" of type '" `_type`"'" #endif #define %outfail_fmt(_type) "in output value of type '"_type"'" #ifndef %argnullref_fmt #define %argnullref_fmt(_type,_name,_argn) %nullref_fmt() %argfail_fmt(_type, _name, _argn) #endif #define %varnullref_fmt(_type,_name) %nullref_fmt() %varfail_fmt(_type, _name) #define %outnullref_fmt(_type) %nullref_fmt() %outfail_fmt(_type) /* setting an error */ #define %error(code,msg...) SWIG_Error(code, msg) #define %type_error(msg...) SWIG_Error(SWIG_TypeError, msg) %insert("runtime") { %define_as(SWIG_exception_fail(code, msg), %block(%error(code, msg); SWIG_fail)) %define_as(SWIG_contract_assert(expr, msg), if (!(expr)) { %error(SWIG_RuntimeError, msg); SWIG_fail; } else) } #ifdef __cplusplus /* You can use the SWIG_CATCH_STDEXCEPT macro with the %exception directive as follows: %exception { try { $action } catch (my_except& e) { ... } SWIG_CATCH_STDEXCEPT // catch std::exception catch (...) { SWIG_exception_fail(SWIG_UnknownError, "Unknown exception"); } } */ %fragment(""); %define SWIG_CATCH_STDEXCEPT /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); } catch (std::domain_error& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); } catch (std::overflow_error& e) { SWIG_exception_fail(SWIG_OverflowError, e.what() ); } catch (std::out_of_range& e) { SWIG_exception_fail(SWIG_IndexError, e.what() ); } catch (std::length_error& e) { SWIG_exception_fail(SWIG_IndexError, e.what() ); } catch (std::runtime_error& e) { SWIG_exception_fail(SWIG_RuntimeError, e.what() ); } catch (std::exception& e) { SWIG_exception_fail(SWIG_SystemError, e.what() ); } %enddef %define SWIG_CATCH_UNKNOWN catch (std::exception& e) { SWIG_exception_fail(SWIG_SystemError, e.what() ); } catch (...) { SWIG_exception_fail(SWIG_UnknownError, "unknown exception"); } %enddef #endif /* __cplusplus */ swig-3.0.2/Lib/typemaps/wstring.swg0000664000175000017500000000143212343605122017132 0ustar williamwilliam%ensure_fragment(SWIG_AsWCharPtrAndSize) %ensure_fragment(SWIG_FromWCharPtrAndSize) %types(wchar_t *); %fragment("SWIG_pwchar_descriptor","header") { SWIGINTERN swig_type_info* SWIG_pwchar_descriptor() { static int init = 0; static swig_type_info* info = 0; if (!init) { info = SWIG_TypeQuery("_p_wchar_t"); init = 1; } return info; } } %fragment("SWIG_wcsnlen","header",fragment="SWIG_FromWCharPtrAndSize") { size_t SWIG_wcsnlen(const wchar_t* s, size_t maxlen) { const wchar_t *p; for (p = s; maxlen-- && *p; p++) ; return p - s; } } %include %typemaps_string(%checkcode(UNISTRING), %checkcode(UNICHAR), wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen, SWIG_wcsnlen, "", WCHAR_MIN, WCHAR_MAX) swig-3.0.2/Lib/typemaps/ptrtypes.swg0000664000175000017500000001470012343605122017331 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ptrtypes.swg * * Value typemaps (Type, const Type&) for "Ptr" types, such as swig * wrapped classes, that define the AsPtr/From methods * * To apply them, just use one of the following macros: * * %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type) * %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type) * * or the simpler and normalize form: * * %typemaps_asptrfromn(CheckCode, Type) * * Also, you can use the individual typemap definitions: * * %ptr_in_typemap(asptr_meth,frag,Type) * %ptr_varin_typemap(asptr_meth,frag,Type) * %ptr_typecheck_typemap(check,asptr_meth,frag,Type) * %ptr_directorout_typemap(asptr_meth,frag,Type) * ----------------------------------------------------------------------------- */ %include /* in */ %define %ptr_in_typemap(asptr_meth,frag,Type...) %typemap(in,fragment=frag) Type { Type *ptr = (Type *)0; int res = asptr_meth($input, &ptr); if (!SWIG_IsOK(res) || !ptr) { %argument_fail((ptr ? res : SWIG_TypeError), "$type", $symname, $argnum); } $1 = *ptr; if (SWIG_IsNewObj(res)) %delete(ptr); } %typemap(freearg) Type ""; %typemap(in,fragment=frag) const Type & (int res = SWIG_OLDOBJ) { Type *ptr = (Type *)0; res = asptr_meth($input, &ptr); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } if (!ptr) { %argument_nullref("$type",$symname, $argnum); } $1 = ptr; } %typemap(freearg,noblock=1) const Type & { if (SWIG_IsNewObj(res$argnum)) %delete($1); } %enddef /* varin */ %define %ptr_varin_typemap(asptr_meth,frag,Type...) %typemap(varin,fragment=frag) Type { Type *ptr = (Type *)0; int res = asptr_meth($input, &ptr); if (!SWIG_IsOK(res) || !ptr) { %variable_fail((ptr ? res : SWIG_TypeError), "$type", "$name"); } $1 = *ptr; if (SWIG_IsNewObj(res)) %delete(ptr); } %enddef #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorout */ %define %ptr_directorout_typemap(asptr_meth,frag,Type...) %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT ($*ltype temp, int swig_ores) { Type *swig_optr = 0; swig_ores = $result ? asptr_meth($result, &swig_optr) : 0; if (!SWIG_IsOK(swig_ores) || !swig_optr) { %dirout_fail((swig_optr ? swig_ores : SWIG_TypeError),"$type"); } temp = *swig_optr; $1 = &temp; if (SWIG_IsNewObj(swig_ores)) %delete(swig_optr); } %typemap(directorout,noblock=1,fragment=frag) Type { Type *swig_optr = 0; int swig_ores = asptr_meth($input, &swig_optr); if (!SWIG_IsOK(swig_ores) || !swig_optr) { %dirout_fail((swig_optr ? swig_ores : SWIG_TypeError),"$type"); } $result = *swig_optr; if (SWIG_IsNewObj(swig_ores)) %delete(swig_optr); } %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Type* { Type *swig_optr = 0; int swig_ores = asptr_meth($input, &swig_optr); if (!SWIG_IsOK(swig_ores)) { %dirout_fail(swig_ores,"$type"); } $result = swig_optr; if (SWIG_IsNewObj(swig_ores)) { swig_acquire_ownership(swig_optr); } } %typemap(directorfree,noblock=1) Type* { if (director) { director->swig_release_ownership(%as_voidptr($input)); } } %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Type& { Type *swig_optr = 0; int swig_ores = asptr_meth($input, &swig_optr); if (!SWIG_IsOK(swig_ores)) { %dirout_fail(swig_ores,"$type"); } else { if (!swig_optr) { %dirout_nullref("$type"); } } $result = swig_optr; if (SWIG_IsNewObj(swig_ores)) { swig_acquire_ownership(swig_optr); } } %typemap(directorfree,noblock=1) Type& { if (director) { director->swig_release_ownership(%as_voidptr($input)); } } %typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type %enddef #else #define %ptr_directorout_typemap(asptr_meth,frag,Type...) #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* typecheck */ %define %ptr_typecheck_typemap(check,asptr_meth,frag,Type...) %typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type * { int res = asptr_meth($input, (Type**)(0)); $1 = SWIG_CheckState(res); } %typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type, const Type& { int res = asptr_meth($input, (Type**)(0)); $1 = SWIG_CheckState(res); } %enddef /*--------------------------------------------------------------------- * typemap definition for types with asptr method *---------------------------------------------------------------------*/ %define %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type...) %fragment(SWIG_AsVal_frag(Type),"header",fragment=SWIG_AsPtr_frag(Type)) { SWIGINTERNINLINE int SWIG_AsVal(Type)(SWIG_Object obj, Type *val) { Type *v = (Type *)0; int res = SWIG_AsPtr(Type)(obj, &v); if (!SWIG_IsOK(res)) return res; if (v) { if (val) *val = *v; if (SWIG_IsNewObj(res)) { %delete(v); res = SWIG_DelNewMask(res); } return res; } return SWIG_ERROR; } } %ptr_in_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type); %ptr_varin_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type); %ptr_directorout_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type); %ptr_typecheck_typemap(%arg(CheckCode), %arg(AsPtrMeth),%arg(AsPtrFrag), Type); %ptr_input_typemap(%arg(CheckCode),%arg(AsPtrMeth),%arg(AsPtrFrag),Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with asptr/from methods *---------------------------------------------------------------------*/ %define %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type...) %typemaps_asptr(%arg(CheckCode), %arg(AsPtrMeth), %arg(AsPtrFrag), Type) %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type); %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type); %ptr_inout_typemap(Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with for 'normalized' asptr/from methods *---------------------------------------------------------------------*/ %define %typemaps_asptrfromn(CheckCode, Type...) %typemaps_asptrfrom(%arg(CheckCode), %arg(SWIG_AsPtr(Type)), %arg(SWIG_From(Type)), %arg(SWIG_AsPtr_frag(Type)), %arg(SWIG_From_frag(Type)), Type); %enddef swig-3.0.2/Lib/typemaps/typemaps.swg0000664000175000017500000001072412343605122017303 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.swg * * Tcl Pointer handling * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Tcl tuple. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Tcl output of the function would be a tuple containing both output values. */ // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Tcl tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Tcl). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Tcl variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ #if defined(SWIG_INOUT_NODEF) %apply_checkctypes(%typemaps_inoutn) %apply size_t& { std::size_t& }; %apply ptrdiff_t& { std::ptrdiff_t& }; #endif swig-3.0.2/Lib/typemaps/traits.swg0000664000175000017500000001662412343605122016754 0ustar williamwilliam// // Use the following macro with modern STL implementations // //#define SWIG_STD_MODERN_STL // // Use this to deactive the previous definition, when using gcc-2.95 // or similar old compilers. // //#define SWIG_STD_NOMODERN_STL // Here, we identify compilers we now have problems with STL. %{ #if defined(__GNUC__) # if __GNUC__ == 2 && __GNUC_MINOR <= 96 # define SWIG_STD_NOMODERN_STL # endif #endif %} // // Common code for supporting the STD C++ namespace // %fragment(""); %fragment(""); %fragment("Traits","header",fragment="") { namespace swig { /* type categories */ struct pointer_category { }; struct value_category { }; /* General traits that provides type_name and type_info */ template struct traits { }; template inline const char* type_name() { return traits::type_name(); } template struct traits_info { static swig_type_info *type_query(std::string name) { name += " *"; return SWIG_TypeQuery(name.c_str()); } static swig_type_info *type_info() { static swig_type_info *info = type_query(type_name()); return info; } }; template inline swig_type_info *type_info() { return traits_info::type_info(); } /* Partial specialization for pointers */ template struct traits { typedef pointer_category category; static std::string make_ptr_name(const char* name) { std::string ptrname = name; ptrname += " *"; return ptrname; } static const char* type_name() { static std::string name = make_ptr_name(swig::type_name()); return name.c_str(); } }; template ::category > struct traits_check { }; /* Traits that provides the from method for an unknown type */ template struct traits_from_ptr { static SWIG_Object from SWIG_FROM_DECL_ARGS(Type *val) { return SWIG_NewPointerObj(val, type_info(), flags); } }; template struct traits_from { static SWIG_Object from SWIG_FROM_DECL_ARGS(const Type& val) { return traits_from_ptr::from(new Type(val)); } }; template struct traits_from { static SWIG_Object from SWIG_FROM_DECL_ARGS(Type* val) { return traits_from_ptr<0, Type>::from(val); } }; template inline SWIG_Object from SWIG_FROM_DECL_ARGS(const Type& val) { return traits_from::from(val); } /* Traits that provides the asptr/asval method for an unknown type */ template struct traits_asptr { static int asptr SWIG_AS_DECL_ARGS (SWIG_Object obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, %as_voidptrptr(&p), type_info(), 0); if (SWIG_IsOK(res) && val) *val = p; return res; } }; template inline int asptr SWIG_AS_DECL_ARGS(SWIG_Object obj, Type **vptr) { return traits_asptr::asptr SWIG_AS_CALL_ARGS(obj, vptr); } template struct traits_asval { static int asval SWIG_AS_DECL_ARGS(SWIG_Object obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr SWIG_AS_CALL_ARGS(obj, &p); if (SWIG_IsOK(res) && p) { *val = *p; if (SWIG_IsNewObj(res)) { %delete(p); res = SWIG_DelNewMask(res); } } return res; } else { return traits_asptr::asptr SWIG_AS_CALL_ARGS(obj, (Type **)(0)); } } }; template inline int asval SWIG_AS_DECL_ARGS (SWIG_Object obj, Type *val) { return traits_asval::asval SWIG_AS_CALL_ARGS(obj, val); } /* Traits that provides the check method for an unknown type */ #define SWIG_CHECK_DECL_ARGS(obj) SWIG_AS_DECL_ARGS(obj, void * = 0) #define SWIG_CHECK_CALL_ARGS(obj) SWIG_AS_CALL_ARGS(obj, 0) template struct traits_checkval { static int check SWIG_CHECK_DECL_ARGS(SWIG_Object obj) { if (obj) { int res = asval SWIG_AS_CALL_ARGS(obj, (Type *)(0)); return SWIG_CheckState(res); } else { return 0; } } }; template struct traits_checkptr { static int check SWIG_CHECK_DECL_ARGS(SWIG_Object obj) { if (obj) { int res = asptr SWIG_AS_CALL_ARGS(obj, (Type **)(0)); return SWIG_CheckState(res); } else { return 0; } } }; template struct traits_check : traits_checkval { }; template struct traits_check : traits_checkptr { }; template inline int check SWIG_CHECK_DECL_ARGS(SWIG_Object obj) { return traits_check::check SWIG_CHECK_CALL_ARGS(obj); } } } /* Generate the traits for an unknown SWIGTYPE */ %define %traits_swigtype(Type...) %fragment(SWIG_Traits_frag(Type),"header",fragment="Traits") { namespace swig { template <> struct traits { typedef pointer_category category; static const char* type_name() { return #Type; } }; } } %enddef /* Generate the traits for a 'value' type, such as 'double', for which the SWIG_AsVal and SWIG_From methods are already defined. */ %define %traits_value(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="Traits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval { typedef Type value_type; static int asval SWIG_AS_DECL_ARGS (SWIG_Object obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from { typedef Type value_type; static SWIG_Object from SWIG_FROM_DECL_ARGS (const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Generate the traits for a 'pointer' type, such as 'std::string', for which the SWIG_AsPtr and SWIG_From methods are already defined. */ %define %traits_pointer(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="Traits") { namespace swig { template <> struct traits { typedef pointer_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asptr { typedef Type value_type; static int asptr SWIG_AS_DECL_ARGS (SWIG_Object obj, value_type **val) { return SWIG_AsPtr(Type)(obj, val); } }; template <> struct traits_from { typedef Type value_type; static SWIG_Object from SWIG_FROM_DECL_ARGS (const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Generate the typemaps for a class that has 'value' traits */ %define %typemap_traits_value(Code,Type...) %typemaps_asvalfrom(%arg(Code), %arg(swig::asval), %arg(swig::from), %arg(SWIG_Traits_frag(Type)), %arg(SWIG_Traits_frag(Type)), Type); %enddef /* Generate the typemaps for a class that has 'pointer' traits */ %define %typemap_traits_pointer(Code,Type...) %typemaps_asptrfrom(%arg(Code), %arg(swig::asptr), %arg(swig::from), %arg(SWIG_Traits_frag(Type)), %arg(SWIG_Traits_frag(Type)), Type); %enddef swig-3.0.2/Lib/typemaps/void.swg0000664000175000017500000000403012343605122016373 0ustar williamwilliam/* ------------------------------------------------------------ * Void * - Accepts any kind of pointer * ------------------------------------------------------------ */ /* in */ %typemap(in,noblock=1) void * (int res) { res = SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } } %typemap(freearg) void * ""; %typemap(in,noblock=1) void * const& ($*ltype temp = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown); if (!SWIG_IsOK(res)) { %argument_fail(res, "Stype", $symname, $argnum); } $1 = &temp; } %typemap(freearg) void * const& ""; /* out */ #if defined(VOID_Object) %typemap(out,noblock=1) void { $result = VOID_Object; } #else %typemap(out,noblock=1) void {} #endif /* varin */ %typemap(varin) void * { void *temp = 0; int res = SWIG_ConvertPtr($input, &temp, 0, SWIG_POINTER_DISOWN); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = ($1_ltype) temp; } /* typecheck */ %typecheck(SWIG_TYPECHECK_VOIDPTR, noblock=1) void * { void *ptr = 0; int res = SWIG_ConvertPtr($input, &ptr, 0, 0); $1 = SWIG_CheckState(res); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1) void *, void const*, void *const, void const *const, void const *&, void *const &, void const *const & { $input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags); } /* directorout */ %typemap(directorout,noblock=1) void * (void *argp, int res) { res = SWIG_ConvertPtr($input, &argp, 0, 0); if (!SWIG_IsOK(res)) { %dirout_fail(res,"$type"); } $result = %reinterpret_cast(argp, $ltype); } %typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) void * const& (void *argp, int res) { res = SWIG_ConvertPtr($input, &argp, 0, $disown); if (!SWIG_IsOK(res)) { %dirout_fail(res,"$type"); } static $*ltype temp = %reinterpret_cast(argp, $*ltype); $result = &temp; } #endif /* SWIG_DIRECTOR_TYPEMAPS */ swig-3.0.2/Lib/typemaps/attribute.swg0000664000175000017500000002301712343605122017443 0ustar williamwilliam/* ----------------------------------------------------------------------------- * attribute.swg * * Attribute implementation * ----------------------------------------------------------------------------- */ /* The following macros convert a pair of set/get methods into a "native" attribute. Use %attribute when you have a pair of get/set methods to a primitive type like in: %attribute(A, int, a, get_a, set_a); struct A { int get_a() const; void set_a(int aa); }; If you don't provide a 'set' method, a 'read-only' attribute is generated, ie, like in: %attribute(A, int, c, get_c); Use %attributeref when you have const/non-const reference access methods for primitive types or class/structs, like in: %attributeref(A, int, b); struct A { const int& b() const; int& b(); }; %attributeref(B, int, c); struct B { int& c(); }; You can also use %attributeref(Class, AttributeType, AttributeName, AccessorMethod) if the internal C++ reference methods have a different name from the attribute you want, so %attributeref(B, int, d, c); is the same as the last example, but instead of the attribute 'c' being called 'c', it is called 'd'. Now you can use the attributes like so: x = A() x.a = 3 # calls A::set_a print x.a # calls A::get_a x.b = 3 # calls A::b() print x.b # calls A::b() const Use %attribute2 instead of %attribute to indicate that reference-pointer translation is required. You use %attribute2 instead of %attribute in cases like this: %attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo); %inline %{ struct MyFoo { int x; }; class MyClass { MyFoo foo; public: MyFoo& GetFoo() { return foo; } void SetFoo(const MyFoo& other) { foo = other; } }; %} Here, the data type of the property is a wrapped type (MyFoo) and on the C++ side it is passed by reference. The problem is that the SWIG wrapper will pass around a pointer (MyFoo *) which is not compatible with the reference type of the accessors (MyFoo &). Therefore, if you use %attribute, you'll get an error from your C/C++ compiler. %attribute2 translates between a pointer and a reference to eliminate the error. In case you're confused, let's make it simple: just use %attribute at first, but if the C/C++ compiler gives an error while compiling the wrapper, try %attribute2 instead. NOTE: remember that if the type contains commas, such as 'std::pair', you need to use the macro like: %attributeref(A, %arg(std::pair), pval); where %arg() 'normalizes' the type to be understood as a single argument, otherwise the macro will get confused by the comma. The %attributeval is the same as %attribute, but should be used when the type is a class/struct (ie a non-primitive type) and when the get and set methods return/pass by value. The following is very similar to the above example, but note that the access is by value rather than reference. %attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo); %attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo); %inline %{ class MyClassVal { MyFoo foo; public: MyFoo GetFoo() { return foo; } void SetFoo(MyFoo other) { foo = other; } }; %} The %attributestring is the same as %attributeval, but should be used for string class types, which are unusual as they are a class on the C++ side, but normally an immutable/primitive type in the target language. Example usage for std::string: %include %attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString); %attributestring(MyStringyClass, std::string, ReadOnlyString, GetString); %inline %{ class MyStringyClass { std::string str; public: MyStringyClass(const std::string &val) : str(val) {} std::string GetString() { return str; } void SetString(std::string other) { str = other; } }; %} The %attributestring also works for class types that have %naturalvar turned on and so is also useful for shared_ptr which has %naturalvar turned on in %shared_ptr. */ // // Define SWIG_ATTRIBUTE_TEMPLATE if you want to use templates instead of macros for the C++ get and set wrapper methods // Does not always generate compileable code, use at your peril! // //#define SWIG_ATTRIBUTE_TEMPLATE %define %attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, GetMethodCall, SetMethodCall) %ignore Class::GetMethod(); %ignore Class::GetMethod() const; #if #SetMethod != #AttributeName %ignore Class::SetMethod; #endif %extend Class { AttributeType AttributeName; } #if defined(__cplusplus) && defined(SWIG_ATTRIBUTE_TEMPLATE) %{ template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(const C* self_) { return GetMethodCall; } template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(C* self_) { return GetMethodCall; } template < class C > inline void %mangle(Class) ##_## AttributeName ## _set(C* self_, AttributeType val_) { SetMethodCall; } %} #else %{ #define %mangle(Class) ##_## AttributeName ## _get(self_) GetMethodCall #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) SetMethodCall %} #endif %enddef %define %attribute_readonly(Class, AttributeType, AttributeName, GetMethod, GetMethodCall) %ignore Class::GetMethod(); %ignore Class::GetMethod() const; %immutable Class::AttributeName; %extend Class { AttributeType AttributeName; } #if defined(__cplusplus) && defined(SWIG_ATTRIBUTE_TEMPLATE) %{ template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(const C* self_) { return GetMethodCall; } template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(C* self_) { return GetMethodCall; } %} #else %{ #define %mangle(Class) ##_## AttributeName ## _get(self_) GetMethodCall %} #endif %enddef // User macros %define %attribute(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_)) #else %attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, self_->GetMethod()) #endif %enddef %define %attribute2(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_)) #else %attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, &self_->GetMethod()) #endif %enddef %define %attributeref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_) #endif %enddef %define %attribute2ref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) #else %attribute_custom(%arg(Class), %arg(AttributeType), AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) #endif %enddef // deprecated (same as %attributeref, but there is an argument order inconsistency) %define %attribute_ref(Class, AttributeType, AccessorMethod, AttributeName...) #if #AttributeName != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else %attribute_custom(%arg(Class), %arg(AttributeType), AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #endif %enddef %define %attributeval(Class, AttributeType, AttributeName, GetMethod, SetMethod...) %{ #define %mangle(Class) ##_## AttributeName ## _get(self_) new AttributeType(self_->GetMethod()) %} #if #SetMethod != "" %{ #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(*val_) %} #if #SetMethod != #AttributeName %ignore Class::SetMethod; #endif #else %immutable Class::AttributeName; #endif %ignore Class::GetMethod(); %ignore Class::GetMethod() const; %newobject Class::AttributeName; %extend Class { AttributeType AttributeName; } %enddef %define %attributestring(Class, AttributeType, AttributeName, GetMethod, SetMethod...) %{ #define %mangle(Class) ##_## AttributeName ## _get(self_) *new AttributeType(self_->GetMethod()) %} #if #SetMethod != "" %{ #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(val_) %} #if #SetMethod != #AttributeName %ignore Class::SetMethod; #endif #else %immutable Class::AttributeName; #endif %ignore Class::GetMethod(); %ignore Class::GetMethod() const; %newobject Class::AttributeName; %typemap(newfree) const AttributeType &AttributeName "delete $1;" %extend Class { AttributeType AttributeName; } %enddef swig-3.0.2/Lib/typemaps/swigtype.swg0000664000175000017500000005420112343605122017312 0ustar williamwilliam/* ----------------------------------------------------------------------------- * --- Input arguments --- * ----------------------------------------------------------------------------- */ /* Pointers and arrays */ %typemap(in, noblock=1) SWIGTYPE *(void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg) SWIGTYPE * ""; %typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg) SWIGTYPE [] ""; %typemap(in, noblock=1) SWIGTYPE *const& (void *argp = 0, int res = 0, $*1_ltype temp) { res = SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$*ltype", $symname, $argnum); } temp = %reinterpret_cast(argp, $*ltype); $1 = %reinterpret_cast(&temp, $1_ltype); } %typemap(freearg) SWIGTYPE *const& ""; /* Reference */ %typemap(in, noblock=1) SWIGTYPE & (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg) SWIGTYPE & ""; #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(in,noblock=1,implicitconv=1) const SWIGTYPE & (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE & { if (SWIG_IsNewObj(res$argnum)) %delete($1); } #else %typemap(in,noblock=1) const SWIGTYPE & (void *argp, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } #endif /* Rvalue reference */ %typemap(in, noblock=1) SWIGTYPE && (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg) SWIGTYPE && ""; #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(in,noblock=1,implicitconv=1) const SWIGTYPE && (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE && { if (SWIG_IsNewObj(res$argnum)) %delete($1); } #else %typemap(in,noblock=1) const SWIGTYPE && (void *argp, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } #endif /* By value */ #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(in,implicitconv=1) SWIGTYPE (void *argp, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $<ype temp = %reinterpret_cast(argp, $<ype); $1 = *temp; if (SWIG_IsNewObj(res)) %delete(temp); } } #else %typemap(in) SWIGTYPE (void *argp, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, $<ype)); } } #endif /* ----------------------------------------------------------------------------- * --- Output arguments --- * ----------------------------------------------------------------------------- */ /* Pointers, references */ %typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE[] { %set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags)); } %typemap(out, noblock=1) SWIGTYPE *const& { %set_output(SWIG_NewPointerObj(%as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags)); } /* Return by value */ %typemap(out, noblock=1) SWIGTYPE { %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags)); } /* ----------------------------------------------------------------------------- * --- Variable input --- * ----------------------------------------------------------------------------- */ /* memberin/globalin/varin, for fix arrays. */ %typemap(memberin) SWIGTYPE [ANY] { if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) *($1_basetype *)&$1[ii] = *(($1_basetype *)$input + ii); } else { %variable_nullref("$type","$name"); } } %typemap(globalin) SWIGTYPE [ANY] { if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) *($1_basetype *)&$1[ii] = *(($1_basetype *)$input + ii); } else { %variable_nullref("$type","$name"); } } %typemap(varin) SWIGTYPE [ANY] { $basetype *inp = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } else if (inp) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) *($1_basetype *)&$1[ii] = *(($1_basetype *)inp + ii); } else { %variable_nullref("$type", "$name"); } } /* memberin/globalin/varin, for fix double arrays. */ %typemap(memberin) SWIGTYPE [ANY][ANY] { if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) { if ($input[ii]) { size_t jj = 0; for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } else { %variable_nullref("$type","$name"); } } } else { %variable_nullref("$type","$name"); } } %typemap(globalin) SWIGTYPE [ANY][ANY] { if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) { if ($input[ii]) { size_t jj = 0; for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } else { %variable_nullref("$type","$name"); } } } else { %variable_nullref("$type","$name"); } } %typemap(varin) SWIGTYPE [ANY][ANY] { $basetype (*inp)[$1_dim1] = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } else if (inp) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) { if (inp[ii]) { size_t jj = 0; for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = inp[ii][jj]; } else { %variable_nullref("$type", "$name"); } } } else { %variable_nullref("$type", "$name"); } } /* Pointers, references, and variable size arrays */ %typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE * { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(varin,noblock=1,warning="462:Unable to set dimensionless array variable") SWIGTYPE [] { %variable_fail(SWIG_AttributeError, "$type", "read-only $name"); } %typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE & { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } $1 = *(%reinterpret_cast(argp, $ltype)); } %typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE && { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } $1 = *(%reinterpret_cast(argp, $ltype)); } #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(varin,implicitconv=1) SWIGTYPE { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } else { $&type temp; temp = %reinterpret_cast(argp, $&type); $1 = *temp; if (SWIG_IsNewObj(res)) %delete(temp); } } #else %typemap(varin) SWIGTYPE { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, $&type)); } } #endif /* ----------------------------------------------------------------------------- * --- Variable output --- * ----------------------------------------------------------------------------- */ /* Pointers and arrays */ %typemap(varout, noblock=1) SWIGTYPE * { %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags)); } %typemap(varout, noblock=1) SWIGTYPE [] { %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags)); } /* References */ %typemap(varout, noblock=1) SWIGTYPE & { %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags)); } %typemap(varout, noblock=1) SWIGTYPE && { %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags)); } /* Value */ %typemap(varout, noblock=1) SWIGTYPE { %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags)); } /* ------------------------------------------------------------ * --- Typechecking rules --- * ------------------------------------------------------------ */ %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE * { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE *const& { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $*descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE && { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE & { int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE && { int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) SWIGTYPE { int res = SWIG_ConvertPtr($input, 0, $&descriptor, %implicitconv_flag); $1 = SWIG_CheckState(res); } #else %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE & { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE && { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $&descriptor, 0); $1 = SWIG_CheckState(res); } #endif /* ----------------------------------------------------------------------------- * --- Director typemaps --- * * ----------------------------------------------------------------------------- */ #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1) SWIGTYPE *, SWIGTYPE *const& { $input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags); } %typemap(directorin,noblock=1) SWIGTYPE { $input = SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags); } %typemap(directorin,noblock=1) SWIGTYPE & { $input = SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags); } %typemap(directorin,noblock=1) SWIGTYPE && { $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags); } /* directorout */ #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(directorout,noblock=1,implicitconv=1) SWIGTYPE (void * swig_argp, int swig_res = 0) { swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } $result = *(%reinterpret_cast(swig_argp, $<ype)); if (SWIG_IsNewObj(swig_res)) %delete(%reinterpret_cast(swig_argp, $<ype)); } #else %typemap(directorout,noblock=1) SWIGTYPE (void * swig_argp, int swig_res = 0) { swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } $result = *(%reinterpret_cast(swig_argp, $<ype)); } #endif %typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *(void *swig_argp, int swig_res, swig_owntype own) { swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } $result = %reinterpret_cast(swig_argp, $ltype); swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */); } %typemap(directorfree,noblock=1,match="directorout") SWIGTYPE * { if (director) { SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input))); } } %typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &(void *swig_argp, int swig_res, swig_owntype own) { swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } if (!swig_argp) { %dirout_nullref("$type"); } $result = %reinterpret_cast(swig_argp, $ltype); swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */); } %typemap(directorfree,noblock=1,match="directorout") SWIGTYPE & { if (director) { SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input))); } } %typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &&(void *swig_argp, int swig_res, swig_owntype own) { swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } if (!swig_argp) { %dirout_nullref("$type"); } $result = %reinterpret_cast(swig_argp, $ltype); swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */); } %typemap(directorfree,noblock=1,match="directorout") SWIGTYPE && { if (director) { SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input))); } } #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* ------------------------------------------------------------ * --- Constants --- * ------------------------------------------------------------ */ %typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags)); } %typemap(constcode,noblock=1) SWIGTYPE { %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr(&$value),$&descriptor,%newpointer_flags)); } /* ------------------------------------------------------------ * --- Exception handling --- * ------------------------------------------------------------ */ %typemap(throws,noblock=1) SWIGTYPE { %raise(SWIG_NewPointerObj(%new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN), "$type", $&descriptor); } %typemap(throws,noblock=1) SWIGTYPE * { %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor); } %typemap(throws,noblock=1) SWIGTYPE [ANY] { %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor); } %typemap(throws,noblock=1) SWIGTYPE & { %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor); } %typemap(throws,noblock=1) SWIGTYPE && { %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor); } %typemap(throws,noblock=1) (...) { SWIG_exception_fail(SWIG_RuntimeError,"unknown exception"); } /* ------------------------------------------------------------ * --- CLASS::* typemaps --- * ------------------------------------------------------------ */ %typemap(in) SWIGTYPE (CLASS::*) { int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } } %typemap(out,noblock=1) SWIGTYPE (CLASS::*) { %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); } %typemap(varin) SWIGTYPE (CLASS::*) { int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } } %typemap(varout,noblock=1) SWIGTYPE (CLASS::*) { %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); } %typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) { %set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($type), $descriptor)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1) SWIGTYPE (CLASS::*) { $input = SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor); } /* directorout */ %typemap(directorout) SWIGTYPE (CLASS::*) { int swig_res = SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($type), $descriptor); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } } #endif /* ------------------------------------------------------------ * --- function ptr typemaps --- * ------------------------------------------------------------ */ /* ISO C++ doesn't allow direct casting of a function ptr to a object ptr. So, maybe the ptr sizes are not the same, and we need to take some providences. */ %typemap(in) SWIGTYPE ((*)(ANY)) { int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } } %typecheck(SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE ((*)(ANY)) { void *ptr = 0; int res = SWIG_ConvertFunctionPtr($input, &ptr, $descriptor); $1 = SWIG_CheckState(res); } %typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) { %set_output(SWIG_NewFunctionPtrObj((void *)($1), $descriptor)); } %typemap(varin) SWIGTYPE ((*)(ANY)) { int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } } %typemap(varout,noblock=1) SWIGTYPE ((*)(ANY)) { %set_varoutput(SWIG_NewFunctionPtrObj((void *)($1), $descriptor)); } %typemap(constcode, noblock=1) SWIGTYPE ((*)(ANY)){ %set_constant("$symname", SWIG_NewFunctionPtrObj((void *)$value, $descriptor)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1) SWIGTYPE ((*)(ANY)) { $input = SWIG_NewFunctionPtrObj((void*)($1), $descriptor); } /* directorout */ %typemap(directorout) SWIGTYPE ((*)(ANY)) { int swig_res = SWIG_ConvertFunctionPtr($input,(void**)(&$result),$descriptor); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } } #endif %apply SWIGTYPE * { SWIGTYPE *const } /* ------------------------------------------------------------ * --- Special typemaps --- * ------------------------------------------------------------ */ /* DISOWN typemap */ %typemap(in, noblock=1) SWIGTYPE *DISOWN (int res = 0) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type", $symname, $argnum); } } %typemap(varin) SWIGTYPE *DISOWN { void *temp = 0; int res = SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = ($ltype) temp; } /* DYNAMIC typemap */ %typemap(out,noblock=1) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { %set_output(SWIG_NewPointerObj(%as_voidptr($1), SWIG_TypeDynamicCast($descriptor, %as_voidptrptr(&$1)), $owner | %newpointer_flags)); } /* INSTANCE typemap */ %typemap(out,noblock=1) SWIGTYPE INSTANCE { %set_output(SWIG_NewInstanceObj(%new_copy($1, $1_ltype), $&1_descriptor, SWIG_POINTER_OWN | %newinstance_flags)); } %typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] { %set_output(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, $owner | %newinstance_flags)); } %typemap(varout,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE INSTANCE[] { %set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags)); } %typemap(varout,noblock=1) SWIGTYPE &INSTANCE { %set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags)); } %typemap(varout,noblock=1) SWIGTYPE INSTANCE { %set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags)); } swig-3.0.2/Lib/swig.swg0000664000175000017500000006032512343605122014552 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swig.swg * * Common macro definitions for various SWIG directives. This file is always * included at the top of each input file. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * User Directives * ----------------------------------------------------------------------------- */ /* Deprecated SWIG-1.1 directives */ #define %disabledoc %warn "104:%disabledoc is deprecated" #define %enabledoc %warn "105:%enabledoc is deprecated" #define %doconly %warn "106:%doconly is deprecated" #define %style %warn "107:%style is deprecated" /##/ #define %localstyle %warn "108:%localstyle is deprecated" /##/ #define %title %warn "109:%title is deprecated" /##/ #define %section %warn "110:%section is deprecated" /##/ #define %subsection %warn "111:%subsection is deprecated" /##/ #define %subsubsection %warn "112:%subsubsection is deprecated" /##/ #define %new %warn "117:%new is deprecated. Use %newobject" #define %text %insert("null") /* Code insertion directives such as %wrapper %{ ... %} */ #define %begin %insert("begin") #define %runtime %insert("runtime") #define %header %insert("header") #define %wrapper %insert("wrapper") #define %init %insert("init") /* Class extension */ #define %addmethods %warn "113:%addmethods is now %extend" %extend /* %ignore directive */ #define %ignore %rename($ignore) #define %ignorewarn(x) %rename("$ignore:" x) /* Access control directives */ #define %readonly %warn "114:%readonly is deprecated. Use %immutable; " %feature("immutable"); #define %readwrite %warn "115:%readwrite is deprecated. Use %mutable; " %feature("immutable",""); #define %immutable %feature("immutable") #define %noimmutable %feature("immutable","0") #define %clearimmutable %feature("immutable","") #define %mutable %clearimmutable /* Generation of default constructors/destructors (old form, don't use) */ #define %nodefault %feature("nodefault","1") #define %default %feature("nodefault","0") #define %clearnodefault %feature("nodefault","") #define %makedefault %clearnodefault /* Disable the generation of implicit default constructor */ #define %nodefaultctor %feature("nodefaultctor","1") #define %defaultctor %feature("nodefaultctor","0") #define %clearnodefaultctor %feature("nodefaultctor","") /* Disable the generation of implicit default destructor (dangerous) */ #define %nodefaultdtor %feature("nodefaultdtor","1") #define %defaultdtor %feature("nodefaultdtor","0") #define %clearnodefaultdtor %feature("nodefaultdtor","") /* Enable the generation of copy constructor */ #define %copyctor %feature("copyctor","1") #define %nocopyctor %feature("copyctor","0") #define %clearcopyctor %feature("copyctor","") /* Force the old nodefault behavior, ie disable both constructor and destructor */ #define %oldnodefault %feature("oldnodefault","1") #define %nooldnodefault %feature("oldnodefault","0") #define %clearoldnodefault %feature("oldnodefault","") /* the %exception directive */ #if defined(SWIGCSHARP) || defined(SWIGD) #define %exception %feature("except", canthrow=1) #else #define %exception %feature("except") #endif #define %noexception %feature("except","0") #define %clearexception %feature("except","") /* the %allowexception directive allows the %exception feature to be applied to set/get variable methods */ #define %allowexception %feature("allowexcept") #define %noallowexception %feature("allowexcept","0") #define %clearallowexception %feature("allowexcept","") /* the %exceptionvar directive, as %exception but it is only applied to set/get variable methods. You don't need to use the %allowexception directive when using %exceptionvar. */ #if defined(SWIGCSHARP) || defined(SWIGD) #define %exceptionvar %feature("exceptvar", canthrow=1) #else #define %exceptionvar %feature("exceptvar") #endif #define %noexceptionvar %feature("exceptvar","0") #define %clearexceptionvar %feature("exceptvar","") /* the %catches directive */ #define %catches(tlist...) %feature("catches","("`tlist`")") #define %clearcatches %feature("catches","") /* the %exceptionclass directive */ #define %exceptionclass %feature("exceptionclass") #define %noexceptionclass %feature("exceptionclass","0") #define %clearexceptionclass %feature("exceptionclass","") /* the %newobject directive */ #define %newobject %feature("new") #define %nonewobject %feature("new","0") #define %clearnewobject %feature("new","") /* the %delobject directive */ #define %delobject %feature("del") #define %nodelobject %feature("del","0") #define %cleardelobject %feature("del","") /* the %refobject/%unrefobject directives */ #define %refobject %feature("ref") #define %norefobject %feature("ref","0") #define %clearrefobject %feature("ref","") #define %unrefobject %feature("unref") #define %nounrefobject %feature("unref","0") #define %clearunrefobject %feature("unref","") /* Directives for callback functions (experimental) */ #define %callback(x) %feature("callback",`x`) #define %nocallback %feature("callback","0") #define %clearcallback %feature("callback","") /* the %nestedworkaround directive (deprecated) */ #define %nestedworkaround %feature("nestedworkaround") #define %nonestedworkaround %feature("nestedworkaround","0") #define %clearnestedworkaround %feature("nestedworkaround","") /* the %flatnested directive */ #define %flatnested %feature("flatnested") #define %noflatnested %feature("flatnested","0") #define %clearflatnested %feature("flatnested","") /* the %fastdispatch directive */ #define %fastdispatch %feature("fastdispatch") #define %nofastdispatch %feature("fastdispatch","0") #define %clearfastdispatch %feature("fastdispatch","") /* directors directives */ #define %director %feature("director") #define %nodirector %feature("director","0") #define %cleardirector %feature("director","") /* naturalvar directives */ #define %naturalvar %feature("naturalvar") #define %nonaturalvar %feature("naturalvar","0") #define %clearnaturalvar %feature("naturalvar","") /* nspace directives */ #define %nspace %feature("nspace") #define %nonspace %feature("nspace","0") #define %clearnspace %feature("nspace","") /* valuewrapper directives */ #define %valuewrapper %feature("valuewrapper") #define %clearvaluewrapper %feature("valuewrapper","") #define %novaluewrapper %feature("novaluewrapper") #define %clearnovaluewrapper %feature("novaluewrapper","") /* Contract support - Experimental and undocumented */ #define %contract %feature("contract") #define %nocontract %feature("contract","0") #define %clearcontract %feature("contract","") /* Macro for setting a dynamic cast function */ %define DYNAMIC_CAST(mangle,func) %init %{ mangle->dcast = (swig_dycast_func) func; %} %enddef /* aggregation support */ /* This macro performs constant aggregation. Basically the idea of constant aggregation is that you can group a collection of constants together. For example, suppose you have some code like this: #define UP 1 #define DOWN 2 #define LEFT 3 #define RIGHT 4 Now, suppose you had a function like this: int move(int direction) In this case, you might want to restrict the direction argument to one of the supplied constant names. To do this, you could write some typemap code by hand. Alternatively, you can use the %aggregate_check macro defined here to create a simple check function for you. Here is an example: %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT); Now, using a typemap %typemap(check) int direction { if (!check_direction($1)) SWIG_exception(SWIG_ValueError,"Bad direction."); } or a contract (better) %contract move(int x) { require: check_direction(x); } */ %define %aggregate_check(TYPE, NAME, FIRST, ...) %wrapper %{ static int NAME(TYPE x) { static TYPE values[] = { FIRST, ##__VA_ARGS__ }; static int size = sizeof(values); int i,j; for (i = 0, j = 0; i < size; i+=sizeof(TYPE),j++) { if (x == values[j]) return 1; } return 0; } %} %enddef /* ----------------------------------------------------------------------------- * %rename predicates * ----------------------------------------------------------------------------- */ /* Predicates to be used with %rename, for example: - to rename all the functions: %rename("%(utitle)s", %$isfunction) ""; - to rename only the member methods: %rename("m_%(utitle)s", %$isfunction, %$ismember) ""; - to rename only the global functions: %rename("m_%(utitle)s", %$isfunction, %$not %$ismember) ""; or %rename("g_%(utitle)s", %$isfunction, %$isglobal) ""; - to ignore the enumitems in a given class: %rename("$ignore", %$isenumitem, %$classname="MyClass") ""; we use the prefix '%$' to avoid clashes with other swig macros/directives. */ %define %$not "not" %enddef %define %$isenum "match"="enum" %enddef %define %$isenumitem "match"="enumitem" %enddef %define %$isaccess "match"="access" %enddef %define %$isclass "match"="class","notmatch$template$templatetype"="class" %enddef %define %$isextend "match"="extend" %enddef %define %$isconstructor "match"="constructor" %enddef %define %$isdestructor "match"="destructor" %enddef %define %$isnamespace "match"="namespace" %enddef %define %$istemplate "match"="template" %enddef %define %$isconstant "match"="constant" %enddef /* %constant definition */ %define %$isunion "match$kind"="union" %enddef %define %$isfunction "match$kind"="function" %enddef %define %$isvariable "match$kind"="variable" %enddef %define %$isimmutable "match$feature:immutable"="1" %enddef %define %$hasconsttype "match$hasconsttype"="1" %enddef %define %$hasvalue "match$hasvalue"="1" %enddef %define %$isextension "match$isextension"="1" %enddef %define %$isstatic "match$storage"="static" %enddef %define %$isfriend "match$storage"="friend" %enddef %define %$istypedef "match$storage"="typedef" %enddef %define %$isvirtual "match$storage"="virtual" %enddef %define %$isexplicit "match$storage"="explicit" %enddef %define %$isextern "match$storage"="extern" %enddef %define %$ismember "match$ismember"="1" %enddef %define %$isglobal %$not %$ismember %enddef %define %$isextendmember "match$isextendmember"="1" %enddef %define %$innamespace "match$parentNode$nodeType"="namespace" %enddef %define %$ispublic "match$access"="public" %enddef %define %$isprotected "match$access"="protected" %enddef %define %$isprivate "match$access"="private" %enddef %define %$ismemberget "match$memberget"="1" %enddef %define %$ismemberset "match$memberset"="1" %enddef %define %$classname %$ismember,"match$parentNode$name" %enddef %define %$isnested "match$nested"="1" %enddef /* ----------------------------------------------------------------------------- * Include all the warnings labels and macros * ----------------------------------------------------------------------------- */ %include /* ----------------------------------------------------------------------------- * Overloading support * ----------------------------------------------------------------------------- */ /* * Function/method overloading support. This is done through typemaps, * but also involves a precedence level. */ /* Macro for overload resolution */ %define %typecheck(_x...) %typemap(typecheck, precedence=_x) %enddef /* Macros for precedence levels */ %define SWIG_TYPECHECK_POINTER 0 %enddef %define SWIG_TYPECHECK_ITERATOR 5 %enddef %define SWIG_TYPECHECK_VOIDPTR 10 %enddef %define SWIG_TYPECHECK_BOOL 15 %enddef %define SWIG_TYPECHECK_UINT8 20 %enddef %define SWIG_TYPECHECK_INT8 25 %enddef %define SWIG_TYPECHECK_UINT16 30 %enddef %define SWIG_TYPECHECK_INT16 35 %enddef %define SWIG_TYPECHECK_UINT32 40 %enddef %define SWIG_TYPECHECK_INT32 45 %enddef %define SWIG_TYPECHECK_SIZE 47 %enddef %define SWIG_TYPECHECK_PTRDIFF 48 %enddef %define SWIG_TYPECHECK_UINT64 50 %enddef %define SWIG_TYPECHECK_INT64 55 %enddef %define SWIG_TYPECHECK_UINT128 60 %enddef %define SWIG_TYPECHECK_INT128 65 %enddef %define SWIG_TYPECHECK_INTEGER 70 %enddef %define SWIG_TYPECHECK_FLOAT 80 %enddef %define SWIG_TYPECHECK_DOUBLE 90 %enddef %define SWIG_TYPECHECK_CPLXFLT 95 %enddef %define SWIG_TYPECHECK_CPLXDBL 100 %enddef %define SWIG_TYPECHECK_COMPLEX 105 %enddef %define SWIG_TYPECHECK_UNICHAR 110 %enddef %define SWIG_TYPECHECK_STDUNISTRING 115 %enddef %define SWIG_TYPECHECK_UNISTRING 120 %enddef %define SWIG_TYPECHECK_CHAR 130 %enddef %define SWIG_TYPECHECK_STDSTRING 135 %enddef %define SWIG_TYPECHECK_STRING 140 %enddef %define SWIG_TYPECHECK_PAIR 150 %enddef %define SWIG_TYPECHECK_VECTOR 160 %enddef %define SWIG_TYPECHECK_DEQUE 170 %enddef %define SWIG_TYPECHECK_LIST 180 %enddef %define SWIG_TYPECHECK_SET 190 %enddef %define SWIG_TYPECHECK_MULTISET 200 %enddef %define SWIG_TYPECHECK_MAP 210 %enddef %define SWIG_TYPECHECK_MULTIMAP 220 %enddef %define SWIG_TYPECHECK_STACK 230 %enddef %define SWIG_TYPECHECK_QUEUE 240 %enddef %define SWIG_TYPECHECK_BOOL_ARRAY 1015 %enddef %define SWIG_TYPECHECK_INT8_ARRAY 1025 %enddef %define SWIG_TYPECHECK_INT16_ARRAY 1035 %enddef %define SWIG_TYPECHECK_INT32_ARRAY 1045 %enddef %define SWIG_TYPECHECK_INT64_ARRAY 1055 %enddef %define SWIG_TYPECHECK_INT128_ARRAY 1065 %enddef %define SWIG_TYPECHECK_FLOAT_ARRAY 1080 %enddef %define SWIG_TYPECHECK_DOUBLE_ARRAY 1090 %enddef %define SWIG_TYPECHECK_CHAR_ARRAY 1130 %enddef %define SWIG_TYPECHECK_STRING_ARRAY 1140 %enddef %define SWIG_TYPECHECK_OBJECT_ARRAY 1150 %enddef %define SWIG_TYPECHECK_BOOL_PTR 2015 %enddef %define SWIG_TYPECHECK_UINT8_PTR 2020 %enddef %define SWIG_TYPECHECK_INT8_PTR 2025 %enddef %define SWIG_TYPECHECK_UINT16_PTR 2030 %enddef %define SWIG_TYPECHECK_INT16_PTR 2035 %enddef %define SWIG_TYPECHECK_UINT32_PTR 2040 %enddef %define SWIG_TYPECHECK_INT32_PTR 2045 %enddef %define SWIG_TYPECHECK_UINT64_PTR 2050 %enddef %define SWIG_TYPECHECK_INT64_PTR 2055 %enddef %define SWIG_TYPECHECK_FLOAT_PTR 2080 %enddef %define SWIG_TYPECHECK_DOUBLE_PTR 2090 %enddef %define SWIG_TYPECHECK_CHAR_PTR 2130 %enddef %define SWIG_TYPECHECK_SWIGOBJECT 5000 %enddef /* ----------------------------------------------------------------------------- * Default handling of certain overloaded operators * ----------------------------------------------------------------------------- */ #ifdef __cplusplus %ignoreoperator(NEW) operator new; %ignoreoperator(DELETE) operator delete; %ignoreoperator(NEWARR) operator new[]; %ignoreoperator(DELARR) operator delete[]; /* add C++ operator aliases */ %rename("operator &&") operator and; // `and' `&&' %rename("operator ||") operator or; // `or' `||' %rename("operator !") operator not; // `not' `!' %rename("operator &=") operator and_eq; // `and_eq' `&=' %rename("operator &") operator bitand; // `bitand' `&' %rename("operator |") operator bitor; // `bitor' `|' %rename("operator ~") operator compl; // `compl' `~' %rename("operator !=") operator not_eq; // `not_eq' `!=' %rename("operator |=") operator or_eq; // `or_eq' `|=' %rename("operator ^") operator xor; // `xor' `^' %rename("operator ^=") operator xor_eq; // `xor_eq' `^=' /* Smart pointer handling */ %rename(__deref__) *::operator->; %rename(__ref__) *::operator*(); %rename(__ref__) *::operator*() const; /* Define std namespace */ namespace std { /* Warn about std::initializer_list usage. The constructor/method where used should probably be ignored. See docs. */ template class initializer_list {}; %typemap(in, warning=SWIGWARN_TYPEMAP_INITIALIZER_LIST_MSG) initializer_list "" %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) initializer_list "" } #endif /* ----------------------------------------------------------------------------- * Default char * and C array typemaps * ----------------------------------------------------------------------------- */ /* Set up the typemap for handling new return strings */ #ifdef __cplusplus %typemap(newfree) char * "delete [] $1;"; #else %typemap(newfree) char * "free($1);"; #endif /* Default typemap for handling char * members */ #ifdef __cplusplus %typemap(memberin) char * { delete [] $1; if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(globalin) char * { delete [] $1; if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } #else %typemap(memberin) char * { free($1); if ($input) { $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { if ($input) { $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(globalin) char * { free($1); if ($input) { $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { if ($input) { $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } #endif /* Character array handling */ %typemap(memberin) char [ANY] { if($input) { strncpy((char*)$1, (const char *)$input, $1_dim0-1); $1[$1_dim0-1] = 0; } else { $1[0] = 0; } } %typemap(globalin) char [ANY] { if($input) { strncpy((char*)$1, (const char *)$input, $1_dim0-1); $1[$1_dim0-1] = 0; } else { $1[0] = 0; } } %typemap(memberin) char [] { if ($input) strcpy((char *)$1, (const char *)$input); else $1[0] = 0; } %typemap(globalin) char [] { if ($input) strcpy((char *)$1, (const char *)$input); else $1[0] = 0; } /* memberin/globalin typemap for arrays. */ %typemap(memberin) SWIGTYPE [ANY] { size_t ii; $1_basetype *b = ($1_basetype *) $1; for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii); } %typemap(globalin) SWIGTYPE [ANY] { size_t ii; $1_basetype *b = ($1_basetype *) $1; for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii); } /* memberin/globalin typemap for double arrays. */ %typemap(memberin) SWIGTYPE [ANY][ANY] { $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); size_t ii = 0; for (; ii < $1_dim0; ++ii) { $basetype *ip = inp[ii]; $basetype *dp = dest[ii]; size_t jj = 0; for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj]; } } %typemap(globalin) SWIGTYPE [ANY][ANY] { $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); size_t ii = 0; for (; ii < $1_dim0; ++ii) { $basetype *ip = inp[ii]; $basetype *dp = dest[ii]; size_t jj = 0; for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj]; } } /* ----------------------------------------------------------------------------- * Runtime code * ----------------------------------------------------------------------------- */ /* The SwigValueWrapper class */ /* * This template wrapper is used to handle C++ objects that are passed or * returned by value. This is necessary to handle objects that define * no default-constructor (making it difficult for SWIG to properly declare * local variables). * * The wrapper is used as follows. First consider a function like this: * * Vector cross_product(Vector a, Vector b) * * Now, if Vector is defined as a C++ class with no default constructor, * code is generated as follows: * * Vector *wrap_cross_product(Vector *inarg1, Vector *inarg2) { * SwigValueWrapper arg1; * SwigValueWrapper arg2; * SwigValueWrapper result; * * arg1 = *inarg1; * arg2 = *inarg2; * ... * result = cross_product(arg1,arg2); * ... * return new Vector(result); * } * * In the wrappers, the template SwigValueWrapper simply provides a thin * layer around a Vector *. However, it does this in a way that allows * the object to be bound after the variable declaration (which is not possible * with the bare object when it lacks a default constructor). * * An observant reader will notice that the code after the variable declarations * is *identical* to the code used for classes that do define default constructors. * Thus, this neat trick allows us to fix this special case without having to * make massive changes to typemaps and other parts of the SWIG code generator. * * Note: this code is not included when SWIG runs in C-mode, when classes * define default constructors, or when pointers and references are used. * SWIG tries to avoid doing this except in very special circumstances. * * Note: This solution suffers from making a large number of copies * of the underlying object. However, this is needed in the interest of * safety and in order to cover all of the possible ways in which a value * might be assigned. For example: * * arg1 = *inarg1; // Assignment from a pointer * arg1 = Vector(1,2,3); // Assignment from a value * * The class offers a strong guarantee of exception safety. * With regards to the implementation, the private SwigMovePointer nested class is * a simple smart pointer with move semantics, much like std::auto_ptr. * * This wrapping technique was suggested by William Fulton and is henceforth * known as the "Fulton Transform" :-). */ #ifdef __cplusplus %insert("runtime") %{ #ifdef __cplusplus /* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { struct SwigMovePointer { T *ptr; SwigMovePointer(T *p) : ptr(p) { } ~SwigMovePointer() { delete ptr; } SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } } pointer; SwigValueWrapper& operator=(const SwigValueWrapper& rhs); SwigValueWrapper(const SwigValueWrapper& rhs); public: SwigValueWrapper() : pointer(0) { } SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } operator T&() const { return *pointer.ptr; } T *operator&() { return pointer.ptr; } };%} /* * SwigValueInit() is a generic initialisation solution as the following approach: * * T c_result = T(); * * doesn't compile for all types for example: * * unsigned int c_result = unsigned int(); */ %insert("runtime") %{ template T SwigValueInit() { return T(); } #endif %} #endif /* The swiglabels */ %insert("runtime") "swiglabels.swg" swig-3.0.2/Lib/stdint.i0000664000175000017500000000450012343605122014527 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stdint.i * * SWIG library file for ISO C99 types: 7.18 Integer types * ----------------------------------------------------------------------------- */ %{ #include // Use the C99 official header %} %include /* Exact integral types. */ /* Signed. */ typedef signed char int8_t; typedef short int int16_t; typedef int int32_t; #if defined(SWIGWORDSIZE64) typedef long int int64_t; #else typedef long long int int64_t; #endif /* Unsigned. */ typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; #if defined(SWIGWORDSIZE64) typedef unsigned long int uint64_t; #else typedef unsigned long long int uint64_t; #endif /* Small types. */ /* Signed. */ typedef signed char int_least8_t; typedef short int int_least16_t; typedef int int_least32_t; #if defined(SWIGWORDSIZE64) typedef long int int_least64_t; #else typedef long long int int_least64_t; #endif /* Unsigned. */ typedef unsigned char uint_least8_t; typedef unsigned short int uint_least16_t; typedef unsigned int uint_least32_t; #if defined(SWIGWORDSIZE64) typedef unsigned long int uint_least64_t; #else typedef unsigned long long int uint_least64_t; #endif /* Fast types. */ /* Signed. */ typedef signed char int_fast8_t; #if defined(SWIGWORDSIZE64) typedef long int int_fast16_t; typedef long int int_fast32_t; typedef long int int_fast64_t; #else typedef int int_fast16_t; typedef int int_fast32_t; typedef long long int int_fast64_t; #endif /* Unsigned. */ typedef unsigned char uint_fast8_t; #if defined(SWIGWORDSIZE64) typedef unsigned long int uint_fast16_t; typedef unsigned long int uint_fast32_t; typedef unsigned long int uint_fast64_t; #else typedef unsigned int uint_fast16_t; typedef unsigned int uint_fast32_t; typedef unsigned long long int uint_fast64_t; #endif /* Types for `void *' pointers. */ #if defined(SWIGWORDSIZE64) typedef long int intptr_t; typedef unsigned long int uintptr_t; #else typedef int intptr_t; typedef unsigned int uintptr_t; #endif /* Largest integral types. */ #if defined(SWIGWORDSIZE64) typedef long int intmax_t; typedef unsigned long int uintmax_t; #else typedef long long int intmax_t; typedef unsigned long long int uintmax_t; #endif swig-3.0.2/Lib/math.i0000664000175000017500000000404612343605122014160 0ustar williamwilliam/* ----------------------------------------------------------------------------- * math.i * * SWIG library file for floating point operations. * ----------------------------------------------------------------------------- */ %module math %{ #include %} extern double cos(double x); /* Cosine of x */ extern double sin(double x); /* Sine of x */ extern double tan(double x); /* Tangent of x */ extern double acos(double x); /* Inverse cosine in range [-PI/2,PI/2], x in [-1,1]. */ extern double asin(double x); /* Inverse sine in range [0,PI], x in [-1,1]. */ extern double atan(double x); /* Inverse tangent in range [-PI/2,PI/2]. */ extern double atan2(double y, double x); /* Inverse tangent of y/x in range [-PI,PI]. */ extern double cosh(double x); /* Hyperbolic cosine of x */ extern double sinh(double x); /* Hyperbolic sine of x */ extern double tanh(double x); /* Hyperbolic tangent of x */ extern double exp(double x); /* Natural exponential function e^x */ extern double log(double x); /* Natural logarithm ln(x), x > 0 */ extern double log10(double x); /* Base 10 logarithm, x > 0 */ extern double pow(double x, double y); /* Power function x^y. */ extern double sqrt(double x); /* Square root. x >= 0 */ extern double fabs(double x); /* Absolute value of x */ extern double ceil(double x); /* Smallest integer not less than x, as a double */ extern double floor(double x); /* Largest integer not greater than x, as a double */ extern double fmod(double x, double y); /* Floating-point remainder of x/y, with the same sign as x. */ #define M_E 2.7182818284590452354 #define M_LOG2E 1.4426950408889634074 #define M_LOG10E 0.43429448190325182765 #define M_LN2 0.69314718055994530942 #define M_LN10 2.30258509299404568402 #define M_PI 3.14159265358979323846 #define M_PI_2 1.57079632679489661923 #define M_PI_4 0.78539816339744830962 #define M_1_PI 0.31830988618379067154 #define M_2_PI 0.63661977236758134308 #define M_2_SQRTPI 1.12837916709551257390 #define M_SQRT2 1.41421356237309504880 #define M_SQRT1_2 0.70710678118654752440 swig-3.0.2/Lib/perl5/0000775000175000017500000000000012343605122014100 5ustar williamwilliamswig-3.0.2/Lib/perl5/director.swg0000664000175000017500000001621412343605122016441 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Perl proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #ifndef SWIG_DIRECTOR_PERL_HEADER_ #define SWIG_DIRECTOR_PERL_HEADER_ #include #include #include #include #include /* Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the native C++ RTTI and dynamic_cast<>. But be aware that directors could stop working when using this option. */ #ifdef SWIG_DIRECTOR_NORTTI /* When we don't use the native C++ RTTI, we implement a minimal one only for Directors. */ # ifndef SWIG_DIRECTOR_RTDIR # define SWIG_DIRECTOR_RTDIR namespace Swig { class Director; SWIGINTERN std::map& get_rtdir_map() { static std::map rtdir_map; return rtdir_map; } SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) { get_rtdir_map()[vptr] = rtdir; } SWIGINTERNINLINE Director *get_rtdir(void *vptr) { std::map::const_iterator pos = get_rtdir_map().find(vptr); Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0; return rtdir; } } # endif /* SWIG_DIRECTOR_RTDIR */ # define SWIG_DIRECTOR_CAST(ARG) Swig::get_rtdir(static_cast(ARG)) # define SWIG_DIRECTOR_RGTR(ARG1, ARG2) Swig::set_rtdir(static_cast(ARG1), ARG2) #else # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) # define SWIG_DIRECTOR_RGTR(ARG1, ARG2) #endif /* SWIG_DIRECTOR_NORTTI */ extern "C" { struct swig_type_info; } namespace Swig { /* memory handler */ struct GCItem { virtual ~GCItem() {} virtual int get_own() const { return 0; } }; struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) { } GCItem_var& operator=(GCItem *item) { GCItem *tmp = _item; _item = item; delete tmp; return *this; } ~GCItem_var() { delete _item; } GCItem *operator->() const { return _item; } private: GCItem *_item; }; struct GCItem_Object : GCItem { GCItem_Object(int own) : _own(own) { } virtual ~GCItem_Object() { } int get_own() const { return _own; } private: int _own; }; template struct GCItem_T : GCItem { GCItem_T(Type *ptr) : _ptr(ptr) { } virtual ~GCItem_T() { delete _ptr; } private: Type *_ptr; }; template struct GCArray_T : GCItem { GCArray_T(Type *ptr) : _ptr(ptr) { } virtual ~GCArray_T() { delete[] _ptr; } private: Type *_ptr; }; /* base class for director exceptions */ class DirectorException : public std::exception { public: virtual SV *getNative() const = 0; }; /* exceptions emitted by Perl */ class DirectorMethodException : public DirectorException { protected: SV *err; public: DirectorMethodException(SV *sv = sv_mortalcopy(ERRSV)) : err(sv) { SvREFCNT_inc(err); } const char *what() const throw() { return SvPV_nolen(err); } SV *getNative() const { return sv_2mortal(newSVsv(err)); } static void raise(SV *sv) { throw DirectorMethodException(sv); } }; /* exceptions emitted by wrap code */ class DirectorWrapException : public DirectorException { protected: std::string msg; DirectorWrapException(const char *str) : msg(str) { } public: virtual ~DirectorWrapException() throw() { } const char *what() const throw() { return msg.c_str(); } virtual SV *getNative() const { return sv_2mortal(newSVpvn(msg.data(), msg.size())); } }; class DirectorTypeMismatchException : public DirectorWrapException { public: DirectorTypeMismatchException(const char *str) : DirectorWrapException(str) { } static void raise(const char *type, const char *msg) { std::string err = std::string(type); err += ": "; err += msg; throw DirectorTypeMismatchException(err.c_str()); } }; class DirectorPureVirtualException : public DirectorWrapException { public: DirectorPureVirtualException(const char *name) : DirectorWrapException("SWIG director pure virtual method called: ") { msg += name; } static void raise(const char *name) { throw DirectorPureVirtualException(name); } }; /* director base class */ class Director { private: /* pointer to the wrapped perl object */ SV *swig_self; /* class of wrapped perl object */ std::string swig_class; /* flag indicating whether the object is owned by perl or c++ */ mutable bool swig_disown_flag; /* decrement the reference count of the wrapped perl object */ void swig_decref() const { if (swig_disown_flag) { SvREFCNT_dec(swig_self); } } public: /* wrap a Perl object, optionally taking ownership */ Director(SV *pkg) : swig_disown_flag(false) { STRLEN len; char *str = SvPV(pkg, len); swig_class = std::string(str, len); swig_self = newRV_inc((SV *)newHV()); swig_incref(); } /* discard our reference at destruction */ virtual ~Director() { swig_decref(); } /* return a pointer to the wrapped Perl object */ SV *swig_get_self() const { return swig_self; } const char *swig_get_class() const { return swig_class.c_str(); } /* acquire ownership of the wrapped Perl object (the sense of "disown" is from perl) */ void swig_disown() const { if (!swig_disown_flag) { swig_disown_flag=true; swig_incref(); } } /* increase the reference count of the wrapped Perl object */ void swig_incref() const { if (swig_disown_flag) { SvREFCNT_inc(swig_self); } } /* methods to implement pseudo protected director members */ virtual bool swig_get_inner(const char * /* swig_protected_method_name */) const { return true; } virtual void swig_set_inner(const char * /* swig_protected_method_name */, bool /* swig_val */) const { } /* ownership management */ private: typedef std::map swig_ownership_map; mutable swig_ownership_map swig_owner; public: template void swig_acquire_ownership_array(Type *vptr) const { if (vptr) { swig_owner[vptr] = new GCArray_T(vptr); } } template void swig_acquire_ownership(Type *vptr) const { if (vptr) { swig_owner[vptr] = new GCItem_T(vptr); } } void swig_acquire_ownership_obj(void *vptr, int own) const { if (vptr && own) { swig_owner[vptr] = new GCItem_Object(own); } } int swig_release_ownership(void *vptr) const { int own = 0; if (vptr) { swig_ownership_map::iterator iter = swig_owner.find(vptr); if (iter != swig_owner.end()) { own = iter->second->get_own(); swig_owner.erase(iter); } } return own; } }; } #endif swig-3.0.2/Lib/perl5/std_map.i0000664000175000017500000000445312343605122015707 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.2/Lib/perl5/perlprimtypes.swg0000664000175000017500000001674112343605122017552 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* bool */ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(bool)(bool value) { return boolSV(value); } } %fragment(SWIG_AsVal_frag(bool),"header") { SWIGINTERN int SWIG_AsVal_dec(bool)(SV *obj, bool* val) { if (obj == &PL_sv_yes) { if (val) *val = true; return SWIG_OK; } else if (obj == &PL_sv_no) { if (val) *val = false; return SWIG_OK; } else { if (val) *val = SvTRUE(obj) ? true : false; return SWIG_AddCast(SWIG_OK); } } } /* long */ %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(long)(long value) { SV *sv; if (value >= IV_MIN && value <= IV_MAX) sv = newSViv(value); else sv = newSVpvf("%ld", value); return sv_2mortal(sv); } } %fragment(SWIG_AsVal_frag(long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long)(SV *obj, long* val) { if (SvUOK(obj)) { UV v = SvUV(obj); if (v <= LONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else if (SvIOK(obj)) { IV v = SvIV(obj); if (v >= LONG_MIN && v <= LONG_MAX) { if(val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else { int dispatch = 0; const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; long v; errno = 0; v = strtol(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { if (val) *val = (long)(d); return res; } } } return SWIG_TypeError; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(unsigned long)(unsigned long value) { SV *sv; if (value <= UV_MAX) sv = newSVuv(value); else sv = newSVpvf("%lu", value); return sv_2mortal(sv); } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val) { if (SvUOK(obj)) { UV v = SvUV(obj); if (v <= ULONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else if (SvIOK(obj)) { IV v = SvIV(obj); if (v >= 0 && v <= ULONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else { int dispatch = 0; const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; unsigned long v; errno = 0; v = strtoul(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { if (val) *val = (unsigned long)(d); return res; } } } return SWIG_TypeError; } } /* long long */ %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="", fragment="") { SWIGINTERNINLINE SV * SWIG_From_dec(long long)(long long value) { SV *sv; if (value >= IV_MIN && value <= IV_MAX) sv = newSViv((IV)(value)); else { //sv = newSVpvf("%lld", value); doesn't work in non 64bit Perl char temp[256]; sprintf(temp, "%lld", value); sv = newSVpv(temp, 0); } return sv_2mortal(sv); } } %fragment(SWIG_AsVal_frag(long long),"header", fragment="", fragment="", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long long)(SV *obj, long long *val) { if (SvUOK(obj)) { UV v = SvUV(obj); if (v < LLONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else if (SvIOK(obj)) { IV v = SvIV(obj); if (v >= LLONG_MIN && v <= LLONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else { int dispatch = 0; const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; long long v; errno = 0; v = strtoll(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } if (!dispatch) { const double mant_max = 1LL << DBL_MANT_DIG; const double mant_min = -mant_max; double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { if (val) *val = (long long)(d); return res; } } } return SWIG_TypeError; } } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="", fragment="") { SWIGINTERNINLINE SV * SWIG_From_dec(unsigned long long)(unsigned long long value) { SV *sv; if (value <= UV_MAX) sv = newSVuv((UV)(value)); else { //sv = newSVpvf("%llu", value); doesn't work in non 64bit Perl char temp[256]; sprintf(temp, "%llu", value); sv = newSVpv(temp, 0); } return sv_2mortal(sv); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment="", fragment="", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val) { if (SvUOK(obj)) { if (val) *val = SvUV(obj); return SWIG_OK; } else if (SvIOK(obj)) { IV v = SvIV(obj); if (v >= 0 && v <= ULLONG_MAX) { if (val) *val = v; return SWIG_OK; } else { return SWIG_OverflowError; } } else { int dispatch = 0; const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; unsigned long long v; errno = 0; v = strtoull(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } if (!dispatch) { const double mant_max = 1LL << DBL_MANT_DIG; double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { if (val) *val = (unsigned long long)(d); return res; } } } return SWIG_TypeError; } } /* double */ %fragment(SWIG_From_frag(double),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(double)(double value) { return sv_2mortal(newSVnv(value)); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(SV *obj, double *val) { if (SvNIOK(obj)) { if (val) *val = SvNV(obj); return SWIG_OK; } else if (SvIOK(obj)) { if (val) *val = (double) SvIV(obj); return SWIG_AddCast(SWIG_OK); } else { const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; double v; errno = 0; v = strtod(nptr, &endptr); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } } return SWIG_TypeError; } } swig-3.0.2/Lib/perl5/perlrun.swg0000664000175000017500000003462112343605122016317 0ustar williamwilliam/* ----------------------------------------------------------------------------- * perlrun.swg * * This file contains the runtime support for Perl modules * and includes code for managing global variables and pointer * type checking. * ----------------------------------------------------------------------------- */ #ifdef PERL_OBJECT #define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), #define SWIG_PERL_OBJECT_CALL pPerl, #else #define SWIG_PERL_OBJECT_DECL #define SWIG_PERL_OBJECT_CALL #endif /* Common SWIG API */ /* for raw pointers */ #define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) #define SWIG_ConvertPtrAndOwn(obj, pp, type, flags,own) SWIG_Perl_ConvertPtrAndOwn(SWIG_PERL_OBJECT_CALL obj, pp, type, flags, own) #define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) #define swig_owntype int /* for raw packed data */ #define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) #define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Perl_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) #define SWIG_Error(code, msg) sv_setpvf(get_sv("@", GV_ADD), "%s %s", SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Perl-specific SWIG API */ #define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) #define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) #define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) #define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) #define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) #define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) #define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #ifdef __cplusplus extern "C" { #endif #define SWIG_OWNER SWIG_POINTER_OWN #define SWIG_SHADOW SWIG_OWNER << 1 #define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL /* SWIG Perl macros */ /* Macro to declare an XS function */ #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif /* Macro to call an XS function */ #ifdef PERL_OBJECT # define SWIG_CALLXS(_name) _name(cv,pPerl) #else # ifndef MULTIPLICITY # define SWIG_CALLXS(_name) _name(cv) # else # define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) # endif #endif #ifdef PERL_OBJECT #define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; #ifdef __cplusplus extern "C" { #endif typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus } #endif #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) #define SWIGCLASS_STATIC #else /* PERL_OBJECT */ #define MAGIC_PPERL #define SWIGCLASS_STATIC static SWIGUNUSED #ifndef MULTIPLICITY #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) #ifdef __cplusplus extern "C" { #endif typedef int (*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus } #endif #else /* MULTIPLICITY */ #define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) #ifdef __cplusplus extern "C" { #endif typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); #ifdef __cplusplus } #endif #endif /* MULTIPLICITY */ #endif /* PERL_OBJECT */ # ifdef PERL_OBJECT # define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) static void SWIG_Perl_croak_null(CPerlObj *pPerl) # else static void SWIG_croak_null() # endif { SV *err = get_sv("@", GV_ADD); # if (PERL_VERSION < 6) croak("%_", err); # else if (sv_isobject(err)) croak(0); else croak("%s", SvPV_nolen(err)); # endif } /* Define how strict is the cast between strings and integers/doubles when overloading between these types occurs. The default is making it as strict as possible by using SWIG_AddCast when needed. You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to disable the SWIG_AddCast, making the casting between string and numbers less strict. In the end, we try to solve the overloading between strings and numerical types in the more natural way, but if you can avoid it, well, avoid it using %rename, for example. */ #ifndef SWIG_PERL_NO_STRICT_STR2NUM # ifndef SWIG_PERL_STRICT_STR2NUM # define SWIG_PERL_STRICT_STR2NUM # endif #endif #ifdef SWIG_PERL_STRICT_STR2NUM /* string takes precedence */ #define SWIG_Str2NumCast(x) SWIG_AddCast(x) #else /* number takes precedence */ #define SWIG_Str2NumCast(x) x #endif #include SWIGRUNTIME const char * SWIG_Perl_TypeProxyName(const swig_type_info *type) { if (!type) return NULL; if (type->clientdata != NULL) { return (const char*) type->clientdata; } else { return type->name; } } /* Identical to SWIG_TypeCheck, except for strcmp comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (strcmp(SWIG_Perl_TypeProxyName(iter->type), c) == 0) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Function for getting a pointer value */ SWIGRUNTIME int SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags, int *own) { swig_cast_info *tc; void *voidptr = (void *)0; SV *tsv = 0; if (own) *own = 0; /* If magical, apply more magic */ if (SvGMAGICAL(sv)) mg_get(sv); /* Check to see if this is an object */ if (sv_isobject(sv)) { IV tmp = 0; tsv = (SV*) SvRV(sv); if ((SvTYPE(tsv) == SVt_PVHV)) { MAGIC *mg; if (SvMAGICAL(tsv)) { mg = mg_find(tsv,'P'); if (mg) { sv = mg->mg_obj; if (sv_isobject(sv)) { tsv = (SV*)SvRV(sv); tmp = SvIV(tsv); } } } else { return SWIG_ERROR; } } else { tmp = SvIV(tsv); } voidptr = INT2PTR(void *,tmp); } else if (! SvOK(sv)) { /* Check for undef */ *(ptr) = (void *) 0; return SWIG_OK; } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ if (!SvROK(sv)) { /* In Perl 5.12 and later, SVt_RV == SVt_IV, so sv could be a valid integer value. */ if (SvIOK(sv)) { return SWIG_ERROR; } else { /* NULL pointer (reference to undef). */ *(ptr) = (void *) 0; return SWIG_OK; } } else { return SWIG_ERROR; } } else { /* Don't know what it is */ return SWIG_ERROR; } if (_t) { /* Now see if the types match */ char *_c = HvNAME(SvSTASH(SvRV(sv))); tc = SWIG_TypeProxyCheck(_c,_t); #ifdef SWIG_DIRECTORS if (!tc && !sv_derived_from(sv,SWIG_Perl_TypeProxyName(_t))) { #else if (!tc) { #endif return SWIG_ERROR; } { int newmemory = 0; *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } } } else { *ptr = voidptr; } /* * DISOWN implementation: we need a perl guru to check this one. */ if (tsv && (flags & SWIG_POINTER_DISOWN)) { /* * almost copy paste code from below SWIG_POINTER_OWN setting */ SV *obj = sv; HV *stash = SvSTASH(SvRV(obj)); GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE); if (isGV(gv)) { HV *hv = GvHVn(gv); /* * To set ownership (see below), a newSViv(1) entry is added. * Hence, to remove ownership, we delete the entry. */ if (hv_exists_ent(hv, obj, 0)) { hv_delete_ent(hv, obj, 0, 0); } } } return SWIG_OK; } SWIGRUNTIME int SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { return SWIG_Perl_ConvertPtrAndOwn(sv, ptr, _t, flags, 0); } SWIGRUNTIME void SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) { SV *self; SV *obj=newSV(0); HV *hash=newHV(); HV *stash; sv_setref_pv(obj, SWIG_Perl_TypeProxyName(t), ptr); stash=SvSTASH(SvRV(obj)); if (flags & SWIG_POINTER_OWN) { HV *hv; GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE); if (!isGV(gv)) gv_init(gv, stash, "OWNER", 5, FALSE); hv=GvHVn(gv); hv_store_ent(hv, obj, newSViv(1), 0); } sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); SvREFCNT_dec(obj); self=newRV_noinc((SV *)hash); sv_setsv(sv, self); SvREFCNT_dec((SV *)self); sv_bless(sv, stash); } else { sv_setref_pv(sv, SWIG_Perl_TypeProxyName(t), ptr); } } SWIGRUNTIMEINLINE SV * SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { SV *result = sv_newmortal(); SWIG_MakePtr(result, ptr, t, flags); return result; } SWIGRUNTIME void SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); strcpy(r,SWIG_Perl_TypeProxyName(type)); sv_setpv(sv, result); } SWIGRUNTIME SV * SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { SV *result = sv_newmortal(); SWIG_Perl_MakePackedObj(result, ptr, sz, type); return result; } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; const char *c = 0; if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; c = SvPV_nolen(obj); /* Pointer values must start with leading underscore */ if (*c != '_') return SWIG_ERROR; c++; c = SWIG_UnpackData(c,ptr,sz); if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) return SWIG_ERROR; } return SWIG_OK; } /* Macros for low-level exception handling */ #define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } typedef XSPROTO(SwigPerlWrapper); typedef SwigPerlWrapper *SwigPerlWrapperPtr; /* Structure for command table */ typedef struct { const char *name; SwigPerlWrapperPtr wrapper; } swig_command_info; /* Information for constant table */ #define SWIG_INT 1 #define SWIG_FLOAT 2 #define SWIG_STRING 3 #define SWIG_POINTER 4 #define SWIG_BINARY 5 /* Constant information structure */ typedef struct swig_constant_info { int type; const char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_constant_info; /* Structure for variable table */ typedef struct { const char *name; SwigMagicFunc set; SwigMagicFunc get; swig_type_info **type; } swig_variable_info; /* Magic variable code */ #ifndef PERL_OBJECT # ifdef __cplusplus # define swig_create_magic(s,a,b,c) _swig_create_magic(s,const_cast(a),b,c) # else # define swig_create_magic(s,a,b,c) _swig_create_magic(s,(char*)(a),b,c) # endif # ifndef MULTIPLICITY SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) # else SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) # endif #else # define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) #endif { MAGIC *mg; sv_magic(sv,sv,'U',name,strlen(name)); mg = mg_find(sv,'U'); mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); mg->mg_virtual->svt_get = (SwigMagicFunc) get; mg->mg_virtual->svt_set = (SwigMagicFunc) set; mg->mg_virtual->svt_len = 0; mg->mg_virtual->svt_clear = 0; mg->mg_virtual->svt_free = 0; } SWIGRUNTIME swig_module_info * SWIG_Perl_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; SV *pointer; /* first check if pointer already created */ if (!type_pointer) { pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE | GV_ADDMULTI); if (pointer && SvOK(pointer)) { type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); } } return (swig_module_info *) type_pointer; } SWIGRUNTIME void SWIG_Perl_SetModule(swig_module_info *module) { SV *pointer; /* create a new pointer */ pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE | GV_ADDMULTI); sv_setiv(pointer, PTR2IV(module)); } #ifdef __cplusplus } #endif swig-3.0.2/Lib/perl5/std_pair.i0000664000175000017500000000127712343605122016066 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T t, U u); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/perl5/typemaps.i0000664000175000017500000003075712343605122016130 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * The SWIG typemap library provides a language independent mechanism for * supporting output arguments, input values, and other C function * calling mechanisms. The primary use of the library is to provide a * better interface to certain C function--especially those involving * pointers. * ----------------------------------------------------------------------------- */ #if !defined(SWIG_USE_OLD_TYPEMAPS) %include #else // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include typemaps.i double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include typemaps.i %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ %define INPUT_TYPEMAP(type, converter) %typemap(in) type *INPUT(type temp), type &INPUT(type temp) { temp = (type) converter($input); $1 = &temp; } %typemap(typecheck) type *INPUT = type; %typemap(typecheck) type &INPUT = type; %enddef INPUT_TYPEMAP(float, SvNV); INPUT_TYPEMAP(double, SvNV); INPUT_TYPEMAP(int, SvIV); INPUT_TYPEMAP(long, SvIV); INPUT_TYPEMAP(short, SvIV); INPUT_TYPEMAP(signed char, SvIV); INPUT_TYPEMAP(unsigned int, SvUV); INPUT_TYPEMAP(unsigned long, SvUV); INPUT_TYPEMAP(unsigned short, SvUV); INPUT_TYPEMAP(unsigned char, SvUV); %typemap(in) bool *INPUT(bool temp), bool &INPUT(bool temp) { temp = SvIV($input) ? true : false; $1 = &temp; } %typemap(typecheck) bool *INPUT = bool; %typemap(typecheck) bool &INPUT = bool; %typemap(in) long long *INPUT($*1_ltype temp), long long &INPUT($*1_ltype temp) { temp = strtoll(SvPV_nolen($input), 0, 0); $1 = &temp; } %typemap(typecheck) long long *INPUT = long long; %typemap(typecheck) long long &INPUT = long long; %typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) { temp = strtoull(SvPV_nolen($input), 0, 0); $1 = &temp; } %typemap(typecheck) unsigned long long *INPUT = unsigned long long; %typemap(typecheck) unsigned long long &INPUT = unsigned long long; #undef INPUT_TYPEMAP // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, functions will return a Perl array. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include typemaps.i double modf(double x, double *OUTPUT); or you can use the %apply directive : %include typemaps.i %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Perl output of the function would be an array containing both output values. */ // Force the argument to be ignored. %typemap(in,numinputs=0) int *OUTPUT(int temp), int &OUTPUT(int temp), short *OUTPUT(short temp), short &OUTPUT(short temp), long *OUTPUT(long temp), long &OUTPUT(long temp), unsigned int *OUTPUT(unsigned int temp), unsigned int &OUTPUT(unsigned int temp), unsigned short *OUTPUT(unsigned short temp), unsigned short &OUTPUT(unsigned short temp), unsigned long *OUTPUT(unsigned long temp), unsigned long &OUTPUT(unsigned long temp), unsigned char *OUTPUT(unsigned char temp), unsigned char &OUTPUT(unsigned char temp), signed char *OUTPUT(signed char temp), signed char &OUTPUT(signed char temp), bool *OUTPUT(bool temp), bool &OUTPUT(bool temp), float *OUTPUT(float temp), float &OUTPUT(float temp), double *OUTPUT(double temp), double &OUTPUT(double temp), long long *OUTPUT($*1_ltype temp), long long &OUTPUT($*1_ltype temp), unsigned long long *OUTPUT($*1_ltype temp), unsigned long long &OUTPUT($*1_ltype temp) "$1 = &temp;"; %typemap(argout) int *OUTPUT, int &OUTPUT, short *OUTPUT, short &OUTPUT, long *OUTPUT, long &OUTPUT, signed char *OUTPUT, signed char &OUTPUT, bool *OUTPUT, bool &OUTPUT { if (argvi >= items) { EXTEND(sp,1); } $result = sv_newmortal(); sv_setiv($result,(IV) *($1)); argvi++; } %typemap(argout) unsigned int *OUTPUT, unsigned int &OUTPUT, unsigned short *OUTPUT, unsigned short &OUTPUT, unsigned long *OUTPUT, unsigned long &OUTPUT, unsigned char *OUTPUT, unsigned char &OUTPUT { if (argvi >= items) { EXTEND(sp,1); } $result = sv_newmortal(); sv_setuv($result,(UV) *($1)); argvi++; } %typemap(argout) float *OUTPUT, float &OUTPUT, double *OUTPUT, double &OUTPUT { if (argvi >= items) { EXTEND(sp,1); } $result = sv_newmortal(); sv_setnv($result,(double) *($1)); argvi++; } %typemap(argout) long long *OUTPUT, long long &OUTPUT { char temp[256]; if (argvi >= items) { EXTEND(sp,1); } sprintf(temp,"%lld", (long long)*($1)); $result = sv_newmortal(); sv_setpv($result,temp); argvi++; } %typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { char temp[256]; if (argvi >= items) { EXTEND(sp,1); } sprintf(temp,"%llu", (unsigned long long)*($1)); $result = sv_newmortal(); sv_setpv($result,temp); argvi++; } // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Perl array. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include typemaps.i void neg(double *INOUT); or you can use the %apply directive : %include typemaps.i %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value. Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Perl variable you might do this : $x = neg($x); */ %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) signed char *INOUT = signed char *INPUT; %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) int &INOUT = int &INPUT; %typemap(in) short &INOUT = short &INPUT; %typemap(in) long &INOUT = long &INPUT; %typemap(in) unsigned &INOUT = unsigned &INPUT; %typemap(in) unsigned short &INOUT = unsigned short &INPUT; %typemap(in) unsigned long &INOUT = unsigned long &INPUT; %typemap(in) unsigned char &INOUT = unsigned char &INPUT; %typemap(in) signed char &INOUT = signed char &INPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(in) float &INOUT = float &INPUT; %typemap(in) double &INOUT = double &INPUT; %typemap(in) long long &INOUT = long long &INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT = long *OUTPUT; %typemap(argout) unsigned *INOUT = unsigned *OUTPUT; %typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) signed char *INOUT = signed char *OUTPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT = double *OUTPUT; %typemap(argout) long long *INOUT = long long *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) int &INOUT = int &OUTPUT; %typemap(argout) short &INOUT = short &OUTPUT; %typemap(argout) long &INOUT = long &OUTPUT; %typemap(argout) unsigned &INOUT = unsigned &OUTPUT; %typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; %typemap(argout) signed char &INOUT = signed char &OUTPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; %typemap(argout) float &INOUT = float &OUTPUT; %typemap(argout) double &INOUT = double &OUTPUT; %typemap(argout) long long &INOUT = long long &OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; /* Overloading information */ %typemap(typecheck) double *INOUT = double; %typemap(typecheck) bool *INOUT = bool; %typemap(typecheck) signed char *INOUT = signed char; %typemap(typecheck) unsigned char *INOUT = unsigned char; %typemap(typecheck) unsigned long *INOUT = unsigned long; %typemap(typecheck) unsigned short *INOUT = unsigned short; %typemap(typecheck) unsigned int *INOUT = unsigned int; %typemap(typecheck) long *INOUT = long; %typemap(typecheck) short *INOUT = short; %typemap(typecheck) int *INOUT = int; %typemap(typecheck) float *INOUT = float; %typemap(typecheck) long long *INOUT = long long; %typemap(typecheck) unsigned long long *INOUT = unsigned long long; %typemap(typecheck) double &INOUT = double; %typemap(typecheck) bool &INOUT = bool; %typemap(typecheck) signed char &INOUT = signed char; %typemap(typecheck) unsigned char &INOUT = unsigned char; %typemap(typecheck) unsigned long &INOUT = unsigned long; %typemap(typecheck) unsigned short &INOUT = unsigned short; %typemap(typecheck) unsigned int &INOUT = unsigned int; %typemap(typecheck) long &INOUT = long; %typemap(typecheck) short &INOUT = short; %typemap(typecheck) int &INOUT = int; %typemap(typecheck) float &INOUT = float; %typemap(typecheck) long long &INOUT = long long; %typemap(typecheck) unsigned long long &INOUT = unsigned long long; #endif // -------------------------------------------------------------------- // Special types // -------------------------------------------------------------------- %include swig-3.0.2/Lib/perl5/extra-install.list0000664000175000017500000000006212343605122017562 0ustar williamwilliam# see top-level Makefile.in Makefile.pl noembed.h swig-3.0.2/Lib/perl5/perlinit.swg0000664000175000017500000000370412343605122016454 0ustar williamwilliam /* Export the SWIG initialization function */ %header %{ #ifdef __cplusplus extern "C" #endif #ifndef PERL_OBJECT #ifndef MULTIPLICITY SWIGEXPORT void SWIG_init (CV* cv); #else SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); #endif #else SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); #endif %} /* Module initialization function */ %insert(init) "swiginit.swg" %init %{ #ifdef __cplusplus extern "C" #endif XS(SWIG_init) { dXSARGS; int i; SWIG_InitializeModule(0); /* Install commands */ for (i = 0; swig_commands[i].name; i++) { /* Casts only needed for Perl < 5.10. */ #ifdef __cplusplus newXS(const_cast(swig_commands[i].name), swig_commands[i].wrapper, const_cast(__FILE__)); #else newXS((char*)swig_commands[i].name, swig_commands[i].wrapper, (char*)__FILE__); #endif } /* Install variables */ for (i = 0; swig_variables[i].name; i++) { SV *sv; sv = get_sv(swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); if (swig_variables[i].type) { SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); } else { sv_setiv(sv,(IV) 0); } swig_create_magic(sv, swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); } /* Install constant */ for (i = 0; swig_constants[i].type; i++) { SV *sv; sv = get_sv(swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); switch(swig_constants[i].type) { case SWIG_INT: sv_setiv(sv, (IV) swig_constants[i].lvalue); break; case SWIG_FLOAT: sv_setnv(sv, (double) swig_constants[i].dvalue); break; case SWIG_STRING: sv_setpv(sv, (const char *) swig_constants[i].pvalue); break; case SWIG_POINTER: SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); break; case SWIG_BINARY: SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); break; default: break; } SvREADONLY_on(sv); } %} swig-3.0.2/Lib/perl5/cmalloc.i0000664000175000017500000000004012343605122015656 0ustar williamwilliam%include swig-3.0.2/Lib/perl5/cni.i0000664000175000017500000000022612343605122015023 0ustar williamwilliam%warnfilter(SWIGWARN_PARSE_KEYWORD) java::lang::ref; %{ #undef STATIC %} %include %{ #undef TRUE #define TRUE 1 %} %include swig-3.0.2/Lib/perl5/perlopers.swg0000664000175000017500000000352012343605122016635 0ustar williamwilliam/* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus // These are auto-supported by the Perl-module %rename(__plusplus__) *::operator++; %rename(__minmin__) *::operator--; %rename(__add__) *::operator+; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-(); %rename(__neg__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__mod__) *::operator%; %rename(__gt__) *::operator>; %rename(__lt__) *::operator<; %rename(__not__) *::operator!; %rename(__le__) *::operator<=; %rename(__ge__) *::operator>=; %rename(__and__) *::operator&; %rename(__or__) *::operator|; %rename(__iadd__) *::operator+=; %rename(__isub__) *::operator-=; // These are renamed, but no test exists in operator_overload_runme.pl %ignoreoperator(EQ) operator=; // These are renamed, but no 'use overload...' is added %rename(__lshift__) *::operator<<; %rename(__rshift__) *::operator>>; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; %rename(__call__) *::operator(); /* Ignored operators */ %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; %ignoreoperator(MULEQ) operator*=; %ignoreoperator(DIVEQ) operator/=; %ignoreoperator(MODEQ) operator%=; %ignoreoperator(LSHIFTEQ) operator<<=; %ignoreoperator(RSHIFTEQ) operator>>=; %ignoreoperator(ANDEQ) operator&=; %ignoreoperator(OREQ) operator|=; %ignoreoperator(XOREQ) operator^=; %ignoreoperator(ARROWSTAR) operator->*; %ignoreoperator(INDEX) operator[]; #endif /* __cplusplus */ swig-3.0.2/Lib/perl5/cstring.i0000664000175000017500000000004012343605122015715 0ustar williamwilliam%include swig-3.0.2/Lib/perl5/attribute.i0000664000175000017500000000004212343605122016251 0ustar williamwilliam%include swig-3.0.2/Lib/perl5/jstring.i0000664000175000017500000000202612343605122015732 0ustar williamwilliam%include %fragment(SWIG_AsVal_frag(jstring),"header") { SWIGINTERN int SWIG_AsVal_dec(jstring)(SV *obj, jstring *val) { if (SvPOK(obj)) { if (val) { STRLEN len = 0; char *cstr = SvPV(obj, len); *val = JvNewStringLatin1(cstr, len); } return SWIG_OK; } return SWIG_ERROR; } } %fragment(SWIG_From_frag(jstring),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(jstring)(jstring val) { SV *obj = sv_newmortal(); if (!val) { sv_setsv(obj, &PL_sv_undef); } else { jsize len = JvGetStringUTFLength(val); if (!len) { sv_setsv(obj, &PL_sv_undef); } else { char *tmp = %new_array(len, char); JvGetStringUTFRegion(val, 0, len, tmp); sv_setpvn(obj, tmp, len); SvUTF8_on(obj); %delete_array(tmp); } } return obj; } } %typemaps_asvalfrom(%checkcode(STRING), %arg(SWIG_AsVal(jstring)), %arg(SWIG_From(jstring)), %arg(SWIG_AsVal_frag(jstring)), %arg(SWIG_From_frag(jstring)), java::lang::String *); swig-3.0.2/Lib/perl5/cdata.i0000664000175000017500000000003612343605122015325 0ustar williamwilliam%include swig-3.0.2/Lib/perl5/perlfragments.swg0000664000175000017500000000105412343605122017473 0ustar williamwilliam/* Create a file with this name, 'perlfragments.swg', in your working directory and add all the %fragments you want to take precedence over the ones defined by default by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(PyObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.2/Lib/perl5/perluserdir.swg0000664000175000017500000000004412343605122017160 0ustar williamwilliam#define %perlcode %insert("perl") swig-3.0.2/Lib/perl5/noembed.h0000664000175000017500000000305312343605122015663 0ustar williamwilliam/* Workaround perl5 global namespace pollution. Note that undefining library * functions like fopen will not solve the problem on all platforms as fopen * might be a macro on Windows but not necessarily on other operating systems. */ #ifdef do_open #undef do_open #endif #ifdef do_close #undef do_close #endif #ifdef do_exec #undef do_exec #endif #ifdef scalar #undef scalar #endif #ifdef list #undef list #endif #ifdef apply #undef apply #endif #ifdef convert #undef convert #endif #ifdef Error #undef Error #endif #ifdef form #undef form #endif #ifdef vform #undef vform #endif #ifdef LABEL #undef LABEL #endif #ifdef METHOD #undef METHOD #endif #ifdef Move #undef Move #endif #ifdef yylex #undef yylex #endif #ifdef yyparse #undef yyparse #endif #ifdef yyerror #undef yyerror #endif #ifdef invert #undef invert #endif #ifdef ref #undef ref #endif #ifdef read #undef read #endif #ifdef write #undef write #endif #ifdef eof #undef eof #endif #ifdef close #undef close #endif #ifdef rewind #undef rewind #endif #ifdef free #undef free #endif #ifdef malloc #undef malloc #endif #ifdef calloc #undef calloc #endif #ifdef Stat #undef Stat #endif #ifdef check #undef check #endif #ifdef seekdir #undef seekdir #endif #ifdef open #undef open #endif #ifdef readdir #undef readdir #endif #ifdef bind #undef bind #endif #ifdef access #undef access #endif #ifdef stat #undef stat #endif #ifdef bool /* Leave if macro is from C99 stdbool.h */ #ifndef __bool_true_false_are_defined #undef bool #endif #endif swig-3.0.2/Lib/perl5/carrays.i0000664000175000017500000000004112343605122015711 0ustar williamwilliam%include swig-3.0.2/Lib/perl5/std_common.i0000664000175000017500000000115512343605122016416 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; %fragment(""); %{ double SwigSvToNumber(SV* sv) { return SvIOK(sv) ? double(SvIVX(sv)) : SvNVX(sv); } std::string SwigSvToString(SV* sv) { STRLEN len; char *ptr = SvPV(sv, len); return std::string(ptr, len); } void SwigSvFromString(SV* sv, const std::string& s) { sv_setpvn(sv,s.data(),s.size()); } %} swig-3.0.2/Lib/perl5/std_list.i0000664000175000017500000003406712343605122016111 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_list.i * * SWIG typemaps for std::list types * ----------------------------------------------------------------------------- */ %include %include // containers // ------------------------------------------------------------------------ // std::list // // The aim of all that follows would be to integrate std::list with // Perl as much as possible, namely, to allow the user to pass and // be returned Perl arrays. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::list), f(const std::list&), f(const std::list*): // the parameter being read-only, either a Perl sequence or a // previously wrapped std::list can be passed. // -- f(std::list&), f(std::list*): // the parameter must be modified; therefore, only a wrapped std::list // can be passed. // -- std::list f(): // the list is returned by copy; therefore, a Perl sequence of T:s // is returned which is most easily used in other Perl functions // -- std::list& f(), std::list* f(), const std::list& f(), // const std::list* f(): // the list is returned by reference; therefore, a wrapped std::list // is returned // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template class list { %typemap(in) list (std::list* v) { if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,1) != -1) { $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i& (std::list temp, std::list* v), const list* (std::list temp, std::list* v) { if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,1) != -1) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i { std::list::const_iterator i; unsigned int j; int len = $1.size(); SV **svs = new SV*[len]; for (i=$1.begin(), j=0; i!=$1.end(); i++, j++) { T* ptr = new T(*i); svs[j] = sv_newmortal(); SWIG_MakePtr(svs[j], (void*) ptr, $descriptor(T *), $shadow|$owner); } AV *myav = av_make(len, svs); delete[] svs; $result = newRV_noinc((SV*) myav); sv_2mortal($result); argvi++; } %typecheck(SWIG_TYPECHECK_LIST) list { { /* wrapped list? */ std::list* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_&descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { SV **tv; I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* obj; tv = av_fetch(av, 0, 0); if (SWIG_ConvertPtr(*tv, (void **)&obj, $descriptor(T *),0) != -1) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_LIST) const list&, const list* { { /* wrapped list? */ std::list* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { SV **tv; I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* obj; tv = av_fetch(av, 0, 0); if (SWIG_ConvertPtr(*tv, (void **)&obj, $descriptor(T *),0) != -1) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; list(); list(const list &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(const T& x); }; // specializations for built-ins %define specialize_std_list(T,CHECK_T,TO_T,FROM_T) template<> class list { %typemap(in) list (std::list* v) { if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,1) != -1){ $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; for (int i=0; i& (std::list temp, std::list* v), const list* (std::list temp, std::list* v) { if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,1) != -1) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i { std::list::const_iterator i; unsigned int j; int len = $1.size(); SV **svs = new SV*[len]; for (i=$1.begin(), j=0; i!=$1.end(); i++, j++) { svs[j] = sv_newmortal(); FROM_T(svs[j], *i); } AV *myav = av_make(len, svs); delete[] svs; $result = newRV_noinc((SV*) myav); sv_2mortal($result); argvi++; } %typecheck(SWIG_TYPECHECK_LIST) list { { /* wrapped list? */ std::list* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_&descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { SV **tv; I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ tv = av_fetch(av, 0, 0); if (CHECK_T(*tv)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_LIST) const list&, const list* { { /* wrapped list? */ std::list* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { SV **tv; I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ tv = av_fetch(av, 0, 0); if (CHECK_T(*tv)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; list(); list(const list &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(T x); }; %enddef specialize_std_list(bool,SvIOK,SvIVX,sv_setiv); specialize_std_list(char,SvIOK,SvIVX,sv_setiv); specialize_std_list(int,SvIOK,SvIVX,sv_setiv); specialize_std_list(short,SvIOK,SvIVX,sv_setiv); specialize_std_list(long,SvIOK,SvIVX,sv_setiv); specialize_std_list(unsigned char,SvIOK,SvIVX,sv_setiv); specialize_std_list(unsigned int,SvIOK,SvIVX,sv_setiv); specialize_std_list(unsigned short,SvIOK,SvIVX,sv_setiv); specialize_std_list(unsigned long,SvIOK,SvIVX,sv_setiv); specialize_std_list(float,SvNIOK,SwigSvToNumber,sv_setnv); specialize_std_list(double,SvNIOK,SwigSvToNumber,sv_setnv); specialize_std_list(std::string,SvPOK,SvPVX,SwigSvFromString); } swig-3.0.2/Lib/perl5/factory.i0000664000175000017500000000004012343605122015713 0ustar williamwilliam%include swig-3.0.2/Lib/perl5/reference.i0000664000175000017500000001611712343605122016216 0ustar williamwilliam/* ----------------------------------------------------------------------------- * reference.i * * Accept Perl references as pointers * ----------------------------------------------------------------------------- */ /* The following methods make Perl references work like simple C pointers. References can only be used for simple input/output values, not C arrays however. It should also be noted that REFERENCES are specific to Perl and not supported in other scripting languages at this time. int *REFERENCE short *REFERENCE long *REFERENCE unsigned int *REFERENCE unsigned short *REFERENCE unsigned long *REFERENCE unsigned char *REFERENCE float *REFERENCE double *REFERENCE For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include reference.i void neg(double *REFERENCE); or you can use the %apply directive : %include reference.i %apply double *REFERENCE { double *x }; void neg(double *x); Unlike the INOUT mapping described in typemaps.i, this approach directly modifies the value of a Perl reference. Thus, you could use it as follows : $x = 3; neg(\$x); print "$x\n"; # Should print out -3. */ %typemap(in) double *REFERENCE (double dvalue), double &REFERENCE(double dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { printf("Received %d\n", SvTYPE(tempsv)); SWIG_croak("Expected a double reference."); } dvalue = SvNV(tempsv); $1 = &dvalue; } %typemap(in) float *REFERENCE (float dvalue), float &REFERENCE(float dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { SWIG_croak("expected a double reference"); } dvalue = (float) SvNV(tempsv); $1 = &dvalue; } %typemap(in) int *REFERENCE (int dvalue), int &REFERENCE (int dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if (!SvIOK(tempsv)) { SWIG_croak("expected an integer reference"); } dvalue = SvIV(tempsv); $1 = &dvalue; } %typemap(in) short *REFERENCE (short dvalue), short &REFERENCE(short dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if (!SvIOK(tempsv)) { SWIG_croak("expected an integer reference"); } dvalue = (short) SvIV(tempsv); $1 = &dvalue; } %typemap(in) long *REFERENCE (long dvalue), long &REFERENCE(long dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if (!SvIOK(tempsv)) { SWIG_croak("expected an integer reference"); } dvalue = (long) SvIV(tempsv); $1 = &dvalue; } %typemap(in) unsigned int *REFERENCE (unsigned int dvalue), unsigned int &REFERENCE(unsigned int dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if (!SvIOK(tempsv)) { SWIG_croak("expected an integer reference"); } dvalue = (unsigned int) SvUV(tempsv); $1 = &dvalue; } %typemap(in) unsigned short *REFERENCE (unsigned short dvalue), unsigned short &REFERENCE(unsigned short dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if (!SvIOK(tempsv)) { SWIG_croak("expected an integer reference"); } dvalue = (unsigned short) SvUV(tempsv); $1 = &dvalue; } %typemap(in) unsigned long *REFERENCE (unsigned long dvalue), unsigned long &REFERENCE(unsigned long dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if (!SvIOK(tempsv)) { SWIG_croak("expected an integer reference"); } dvalue = (unsigned long) SvUV(tempsv); $1 = &dvalue; } %typemap(in) unsigned char *REFERENCE (unsigned char dvalue), unsigned char &REFERENCE(unsigned char dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if (!SvIOK(tempsv)) { SWIG_croak("expected an integer reference"); } dvalue = (unsigned char) SvUV(tempsv); $1 = &dvalue; } %typemap(in) signed char *REFERENCE (signed char dvalue), signed char &REFERENCE(signed char dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if (!SvIOK(tempsv)) { SWIG_croak("expected an integer reference"); } dvalue = (signed char) SvIV(tempsv); $1 = &dvalue; } %typemap(in) bool *REFERENCE (bool dvalue), bool &REFERENCE(bool dvalue) { SV *tempsv; if (!SvROK($input)) { SWIG_croak("expected a reference"); } tempsv = SvRV($input); if (!SvIOK(tempsv)) { SWIG_croak("expected an integer reference"); } dvalue = SvIV(tempsv) ? true : false; $1 = &dvalue; } %typemap(typecheck) int *REFERENCE, int &REFERENCE, short *REFERENCE, short &REFERENCE, long *REFERENCE, long &REFERENCE, signed char *REFERENCE, signed char &REFERENCE, bool *REFERENCE, bool &REFERENCE { $1 = SvROK($input) && SvIOK(SvRV($input)); } %typemap(typecheck) double *REFERENCE, double &REFERENCE, float *REFERENCE, float &REFERENCE { $1 = SvROK($input); if($1) { SV *tmpsv = SvRV($input); $1 = SvNOK(tmpsv) || SvIOK(tmpsv); } } %typemap(typecheck) unsigned int *REFERENCE, unsigned int &REFERENCE, unsigned short *REFERENCE, unsigned short &REFERENCE, unsigned long *REFERENCE, unsigned long &REFERENCE, unsigned char *REFERENCE, unsigned char &REFERENCE { $1 = SvROK($input); if($1) { SV *tmpsv = SvRV($input); $1 = SvUOK(tmpsv) || SvIOK(tmpsv); } } %typemap(argout) double *REFERENCE, double &REFERENCE, float *REFERENCE, float &REFERENCE { SV *tempsv; tempsv = SvRV($arg); if (!$1) SWIG_croak("expected a reference"); sv_setnv(tempsv, (double) *$1); } %typemap(argout) int *REFERENCE, int &REFERENCE, short *REFERENCE, short &REFERENCE, long *REFERENCE, long &REFERENCE, signed char *REFERENCE, signed char &REFERENCE, bool *REFERENCE, bool &REFERENCE { SV *tempsv; tempsv = SvRV($input); if (!$1) SWIG_croak("expected a reference"); sv_setiv(tempsv, (IV) *$1); } %typemap(argout) unsigned int *REFERENCE, unsigned int &REFERENCE, unsigned short *REFERENCE, unsigned short &REFERENCE, unsigned long *REFERENCE, unsigned long &REFERENCE, unsigned char *REFERENCE, unsigned char &REFERENCE { SV *tempsv; tempsv = SvRV($input); if (!$1) SWIG_croak("expected a reference"); sv_setuv(tempsv, (UV) *$1); } swig-3.0.2/Lib/perl5/exception.i0000664000175000017500000000021212343605122016243 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) } swig-3.0.2/Lib/perl5/perlerrors.swg0000664000175000017500000000154712343605122017030 0ustar williamwilliam/* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ SWIGINTERN const char* SWIG_Perl_ErrorType(int code) { switch(code) { case SWIG_MemoryError: return "MemoryError"; case SWIG_IOError: return "IOError"; case SWIG_RuntimeError: return "RuntimeError"; case SWIG_IndexError: return "IndexError"; case SWIG_TypeError: return "TypeError"; case SWIG_DivisionByZero: return "ZeroDivisionError"; case SWIG_OverflowError: return "OverflowError"; case SWIG_SyntaxError: return "SyntaxError"; case SWIG_ValueError: return "ValueError"; case SWIG_SystemError: return "SystemError"; case SWIG_AttributeError: return "AttributeError"; default: return "RuntimeError"; } } swig-3.0.2/Lib/perl5/perltypemaps.swg0000664000175000017500000000553712343605122017361 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Perl * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* in Perl we need to pass the CPerlObj value, sometimes, so, we define the decl/call macros as needed. */ #define SWIG_AS_DECL_ARGS SWIG_PERL_DECL_ARGS_2 #define SWIG_AS_CALL_ARGS SWIG_PERL_CALL_ARGS_2 #define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1 #define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1 /* Include fundamental fragment definitions */ %include /* Look for user fragments file. */ %include /* Perl fragments for primitive types */ %include /* Perl fragments for char* strings */ %include /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* director support in Perl is experimental */ #ifndef SWIG_DIRECTOR_TYPEMAPS #define SWIG_DIRECTOR_TYPEMAPS #endif /* Perl types */ #define SWIG_Object SV * #define VOID_Object sv_newmortal() /* Perl $shadow flag */ #define %newpointer_flags $shadow #define %newinstance_flags $shadow /* Complete overload of the output/constant/exception macros */ /* output */ %define %set_output(obj) $result = obj; argvi++ %enddef /* append output */ %define %append_output(obj) if (argvi >= items) EXTEND(sp,1); %set_output(obj) %enddef /* variable output */ %define %set_varoutput(obj) sv_setsv($result,obj) %enddef /* constant */ %define %set_constant(name, obj) %begin_block SV *sv = get_sv((char*) SWIG_prefix name, TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, obj); SvREADONLY_on(sv); %end_block %enddef /* raise exception */ %define %raise(obj, type, desc) sv_setsv(get_sv("@", GV_ADD), obj); SWIG_fail %enddef /* Include the unified typemap library */ %include /* ------------------------------------------------------------ * Perl extra typemaps / typemap overrides * ------------------------------------------------------------ */ %typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE [] "sv_setiv(SvRV($result),PTR2IV($1));"; %typemap(varout,type="$1_descriptor") SWIGTYPE & "sv_setiv(SvRV($result),PTR2IV(&$1));"; %typemap(varout,type="$1_descriptor") SWIGTYPE && "sv_setiv(SvRV($result),PTR2IV(&$1));"; %typemap(varout,type="$&1_descriptor") SWIGTYPE "sv_setiv(SvRV($result), PTR2IV(&$1));"; %typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) { SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor); } %typemap(varout) SWIGTYPE *const = SWIGTYPE *; swig-3.0.2/Lib/perl5/Makefile.pl0000664000175000017500000000126012343605122016151 0ustar williamwilliam# File : Makefile.pl # MakeMaker file for a SWIG module. Use this file if you are # producing a module for general use or distribution. # # 1. Modify the file as appropriate. Replace $module with the # real name of your module and wrapper file. # 2. Run perl as 'perl Makefile.pl' # 3. Type 'make' to build your module # 4. Type 'make install' to install your module. # # See "Programming Perl", 2nd. Ed, for more gory details than # you ever wanted to know. use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => '$module', # Name of your module 'LIBS' => [''], # Custom libraries (if any) 'OBJECT' => '$module_wrap.o' # Object files ); swig-3.0.2/Lib/perl5/perlruntime.swg0000664000175000017500000000050612343605122017171 0ustar williamwilliam %runtime "swigrun.swg" // Common C API type-checking code %runtime "swigerrors.swg" // SWIG errors %runtime "perlhead.swg" // Perl includes and fixes %runtime "perlerrors.swg" // Perl errors %runtime "perlrun.swg" // Perl runtime functions %runtime "noembed.h" // undefine Perl5 macros swig-3.0.2/Lib/perl5/perlmain.i0000664000175000017500000000370212343605122016063 0ustar williamwilliam/* ----------------------------------------------------------------------------- * perlmain.i * * Code to statically rebuild perl5. * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %subsection "perlmain.i" %text %{ This module provides support for building a new version of the Perl executable. This will be necessary on systems that do not support shared libraries and may be necessary with C++ extensions. This module may only build a stripped down version of the Perl executable. Thus, it may be necessary (or desirable) to hand-edit this file for your particular application. To do this, simply copy this file from swig_lib/perl5/perlmain.i to your working directory and make the appropriate modifications. This library file works with Perl 5.003. It may work with earlier versions, but it hasn't been tested. As far as I know, this library is C++ safe. %} #endif %{ static void xs_init _((pTHX)); static PerlInterpreter *my_perl; int perl_eval(char *string) { char *argv[2]; argv[0] = string; argv[1] = (char *) 0; return perl_call_argv("eval",0,argv); } int main(int argc, char **argv, char **env) { int exitstatus; my_perl = perl_alloc(); if (!my_perl) exit(1); perl_construct( my_perl ); exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL ); if (exitstatus) exit( exitstatus ); /* Initialize all of the module variables */ exitstatus = perl_run( my_perl ); perl_destruct( my_perl ); perl_free( my_perl ); exit( exitstatus ); } /* Register any extra external extensions */ /* Do not delete this line--writemain depends on it */ /* EXTERN_C void boot_DynaLoader _((CV* cv)); */ static void xs_init(pTHX) { /* dXSUB_SYS; */ char *file = __FILE__; { /* newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); */ newXS(SWIG_name, SWIG_init, file); #ifdef SWIGMODINIT SWIGMODINIT #endif } } %} swig-3.0.2/Lib/perl5/std_vector.i0000664000175000017500000005447412343605122016444 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector types * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // Perl as much as possible, namely, to allow the user to pass and // be returned Perl arrays. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&), f(const std::vector*): // the parameter being read-only, either a Perl sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(): // the vector is returned by copy; therefore, a Perl sequence of T:s // is returned which is most easily used in other Perl functions // -- std::vector& f(), std::vector* f(), const std::vector& f(), // const std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template class vector { %typemap(in) vector (std::vector* v) { if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,1) != -1) { $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i& (std::vector temp, std::vector* v), const vector* (std::vector temp, std::vector* v) { if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,1) != -1) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i { size_t len = $1.size(); SV **svs = new SV*[len]; for (size_t i=0; i { { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* obj; SV **tv = av_fetch(av, 0, 0); if (SWIG_ConvertPtr(*tv, (void **)&obj, $descriptor(T *),0) != -1) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* obj; SV **tv = av_fetch(av, 0, 0); if (SWIG_ConvertPtr(*tv, (void **)&obj, $descriptor(T *),0) != -1) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(const T& x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T& get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { %typemap(in) vector (std::vector* v) { int res = SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0); if (SWIG_IsOK(res)){ $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); I32 len = av_len(av) + 1; for (int i=0; i& (std::vector temp,std::vector* v), const vector* (std::vector temp,std::vector* v) { int res = SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0); if (SWIG_IsOK(res)) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); I32 len = av_len(av) + 1; for (int i=0; i { size_t len = $1.size(); SV **svs = new SV*[len]; for (size_t i=0; i { { /* wrapped vector? */ std::vector* v; int res = SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0); if (SWIG_IsOK(res)) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ void *v; SV **tv = av_fetch(av, 0, 0); int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); if (SWIG_IsOK(res)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&,const vector* { { /* wrapped vector? */ std::vector *v; int res = SWIG_ConvertPtr($input,%as_voidptrptr(&v), $1_descriptor,0); if (SWIG_IsOK(res)) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ void *v; SV **tv = av_fetch(av, 0, 0); int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); if (SWIG_IsOK(res)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(unsigned int size = 0); vector(unsigned int size, T *value); vector(const vector &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(T *x); %extend { T *pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T *x = self->back(); self->pop_back(); return x; } T *get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { %typemap(in) vector (std::vector* v) { if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,1) != -1){ $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; for (int i=0; i& (std::vector temp, std::vector* v), const vector* (std::vector temp, std::vector* v) { if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,1) != -1) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; for (int i=0; i { size_t len = $1.size(); SV **svs = new SV*[len]; for (size_t i=0; i { { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SV **tv = av_fetch(av, 0, 0); if (CHECK_T(*tv)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SV **tv = av_fetch(av, 0, 0); if (CHECK_T(*tv)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(unsigned int size = 0); vector(unsigned int size, T value); vector(const vector &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(T x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i %include swig-3.0.2/Lib/perl5/perlstrings.swg0000664000175000017500000000262112343605122017177 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) { if (SvMAGICAL(obj)) { SV *tmp = sv_newmortal(); SvSetSV(tmp, obj); obj = tmp; } if (SvPOK(obj)) { STRLEN len = 0; char *cstr = SvPV(obj, len); size_t size = len + 1; if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { *cptr = %new_copy_array(cstr, size, char); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } } if (psize) *psize = size; return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { char* vptr = 0; if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = vptr; if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } } %fragment("SWIG_FromCharPtrAndSize","header") { SWIGINTERNINLINE SV * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { SV *obj = sv_newmortal(); if (carray) { sv_setpvn(obj, carray, size); } else { sv_setsv(obj, &PL_sv_undef); } return obj; } } swig-3.0.2/Lib/perl5/std_except.i0000664000175000017500000000004312343605122016411 0ustar williamwilliam%include swig-3.0.2/Lib/perl5/stl.i0000664000175000017500000000054412343605122015057 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/perl5/std_deque.i0000664000175000017500000000003412343605122016224 0ustar williamwilliam%include swig-3.0.2/Lib/perl5/perl5.swg0000664000175000017500000000270412343605122015654 0ustar williamwilliam/* ------------------------------------------------------------ * perl.swg * * Perl configuration module. * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Inner macros * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The runtime part * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Special user directives * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Typemap specializations * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Warnings for Perl keywords * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Perl initialization function * ------------------------------------------------------------ */ %include swig-3.0.2/Lib/perl5/cpointer.i0000664000175000017500000000004112343605122016070 0ustar williamwilliam%include swig-3.0.2/Lib/perl5/Makefile.in0000664000175000017500000000664412343605122016157 0ustar williamwilliam# --------------------------------------------------------------- # SWIG Perl5 Makefile # # This file can be used to build various Perl5 extensions with SWIG. # By default this file is set up for dynamic loading, but it can # be easily customized for static extensions by modifying various # portions of the file. # # SRCS = C source files # CXXSRCS = C++ source files # OBJCSRCS = Objective-C source files # OBJS = Additional .o files (compiled previously) # INTERFACE = SWIG interface file # TARGET = Name of target module or executable # # Many portions of this file were created by the SWIG configure # script and should already reflect your machine. #---------------------------------------------------------------- SRCS = CXXSRCS = OBJCSRCS = OBJS = INTERFACE = WRAPFILE = $(INTERFACE:.i=_wrap.c) WRAPOBJ = $(INTERFACE:.i=_wrap.o) TARGET = module@SO@ # Use this kind of target for dynamic loading #TARGET = myperl # Use this target for static linking prefix = @prefix@ exec_prefix = @exec_prefix@ CC = @CC@ CXX = @CXX@ OBJC = @CC@ -Wno-import # -Wno-import needed for gcc CFLAGS = INCLUDES = LIBS = # SWIG Options # SWIG = location of the SWIG executable # SWIGOPT = SWIG compiler options # SWIGCC = Compiler used to compile the wrapper file SWIG = $(exec_prefix)/bin/swig SWIGOPT = -perl5 SWIGCC = $(CC) # SWIG Library files. Uncomment this to statically rebuild Perl #SWIGLIBS = -static -lperlmain.i # Rules for creating .o files from source. COBJS = $(SRCS:.c=.o) CXXOBJS = $(CXXSRCS:.cxx=.o) OBJCOBJS = $(OBJCSRCS:.m=.o) ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS) # Command that will be used to build the final extension. BUILD = $(SWIGCC) # Uncomment the following if you are using dynamic loading CCSHARED = @CCSHARED@ BUILD = @LDSHARED@ # Uncomment the following if you are using dynamic loading with C++ and # need to provide additional link libraries (this is not always required). #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc # Perl installation PERL_INCLUDE = -I@PERL5EXT@ PERL_LIB = -L@PERL5EXT@ -lperl PERL_FLAGS = -Dbool=char -Dexplicit= # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ # Build options BUILD_LIBS = $(LIBS) # Dynamic loading # Compilation rules for non-SWIG components .SUFFIXES: .c .cxx .m .c.o: $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< .cxx.o: $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $< .m.o: $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< # ---------------------------------------------------------------------- # Rules for building the extension # ---------------------------------------------------------------------- all: $(TARGET) # Convert the wrapper file into an object file $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(PERL_INCLUDE) $(PERL_FLAGS) $(WRAPFILE) $(WRAPFILE) : $(INTERFACE) $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) clean: rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) swig-3.0.2/Lib/perl5/perlkw.swg0000664000175000017500000000743612343605122016140 0ustar williamwilliam/* Warnings for Perl keywords */ #define PERLKW(x) %keywordwarn("'" `x` "' is a perl keyword") `x` #define PERLBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in perl") "::" `x` /* From http://www.rocketaware.com/perl/perlfunc/ */ /* Functions for SCALARs or strings*/ PERLBN(chomp); PERLBN(chop); PERLBN(chr); PERLBN(crypt); PERLBN(hex); PERLBN(index); PERLBN(lc); PERLBN(lcfirst); PERLBN(length); PERLBN(oct); PERLBN(ord); PERLBN(pack); PERLBN(reverse); PERLBN(rindex); PERLBN(sprintf); PERLBN(substr); PERLBN(uc); PERLBN(ucfirst); /* Regular expressions and pattern matching */ PERLBN(m); PERLBN(pos); PERLBN(quotemeta); PERLBN(split); PERLBN(study); /* Numeric functions */ PERLBN(abs); PERLBN(atan2); PERLBN(cos); PERLBN(exp); PERLBN(hex); PERLBN(int); PERLBN(log); PERLBN(oct); PERLBN(rand); PERLBN(sin); PERLBN(sqrt); PERLBN(srand); /* Functions for real @ARRAYs*/ PERLBN(pop); PERLBN(push); PERLBN(shift); PERLBN(splice); PERLBN(unshift); /* Functions for list data*/ PERLBN(grep); PERLBN(join); PERLBN(map); PERLBN(qw); PERLBN(reverse); PERLBN(sort); PERLBN(unpack); /* Functions for real %HASHes*/ PERLBN(delete); PERLBN(each); PERLBN(exists); PERLBN(keys); PERLBN(values); /* Input and output functions*/ PERLBN(binmode); PERLBN(close); PERLBN(closedir); PERLBN(dbmclose); PERLBN(dbmopen); PERLBN(die); PERLBN(eof); PERLBN(fileno); PERLBN(flock); PERLBN(format); PERLBN(getc); PERLBN(print); PERLBN(printf); PERLBN(read); PERLBN(readdir); PERLBN(rewinddir); PERLBN(seek); PERLBN(seekdir); PERLBN(select); PERLBN(syscall); PERLBN(sysread); PERLBN(sysseek); PERLBN(syswrite); PERLBN(tell); PERLBN(telldir); PERLBN(truncate); PERLBN(warn); PERLBN(write); /* Functions for fixed length data or records*/ PERLBN(pack); PERLBN(read); PERLBN(syscall); PERLBN(sysread); PERLBN(syswrite); PERLBN(unpack); PERLBN(vec); /* Functions for filehandles, files, or directories */ PERLBN(chdir); PERLBN(chmod); PERLBN(chown); PERLBN(chroot); PERLBN(fcntl); PERLBN(glob); PERLBN(ioctl); PERLBN(link); PERLBN(lstat); PERLBN(mkdir); PERLBN(open); PERLBN(opendir); PERLBN(readlink); PERLBN(rename); PERLBN(rmdir); PERLBN(stat); PERLBN(symlink); PERLBN(umask); PERLBN(unlink); PERLBN(utime); /* Keywords related to the control flow of your perl program */ PERLKW(caller); PERLKW(continue); PERLKW(die); PERLKW(do); PERLKW(dump); PERLKW(eval); PERLKW(exit); PERLKW(goto); PERLKW(last); PERLKW(next); PERLKW(redo); PERLKW(return); PERLKW(sub); PERLKW(wantarray); /* Keywords related to scoping */ PERLKW(caller); PERLKW(import); PERLKW(local); PERLKW(my); PERLKW(package); PERLKW(use); /* Miscellaneous functions */ PERLBN("defined"); PERLBN(dump); PERLBN(eval); PERLBN(formline); PERLBN(local); PERLBN(my); PERLBN(reset); PERLBN(scalar); PERLBN(undef); PERLBN(wantarray); /* Functions for processes and process groups */ PERLBN(alarm); PERLBN(exec); PERLBN(fork); PERLBN(getpgrp); PERLBN(getppid); PERLBN(getpriority); PERLBN(kill); PERLBN(pipe); PERLBN(setpgrp); PERLBN(setpriority); PERLBN(sleep); PERLBN(system); PERLBN(times); PERLBN(wait); PERLBN(waitpid); /* Keywords related to perl modules */ PERLKW(do); PERLKW(import); PERLKW(no); PERLKW(package); PERLKW(require); PERLKW(use); /* Keywords related to classes and object-orientedness */ PERLKW(bless); PERLKW(dbmclose); PERLKW(dbmopen); PERLKW(package); PERLKW(ref); PERLKW(tie); PERLKW(tied); PERLKW(untie); PERLKW(use); /* Functions new in perl5 */ PERLBN(abs); PERLBN(bless); PERLBN(chomp); PERLBN(chr); PERLBN(exists); PERLBN(formline); PERLBN(glob); PERLBN(import); PERLBN(lc); PERLBN(lcfirst); PERLBN(map); PERLBN(my); PERLBN(no); PERLBN(prototype); PERLBN(qx); PERLBN(qw); PERLBN(readline); PERLBN(readpipe); PERLBN(ref); PERLBN(sub); PERLBN(sysopen); PERLBN(tie); PERLBN(tied); PERLBN(uc); PERLBN(ucfirst); PERLBN(untie); PERLBN(use); #undef PERLKW #undef PERLBN swig-3.0.2/Lib/perl5/perlhead.swg0000664000175000017500000000506612343605122016415 0ustar williamwilliam#ifdef __cplusplus /* Needed on some windows machines---since MS plays funny games with the header files under C++ */ #include #include extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" /* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ /* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION # endif #endif #if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) #define PerlIO_exportFILE(fh,fl) (FILE*)(fh) #endif #ifndef SvIOK_UV # define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) #endif #ifndef SvUOK # define SvUOK(sv) SvIOK_UV(sv) #endif #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) # define PL_sv_undef sv_undef # define PL_na na # define PL_errgv errgv # define PL_sv_no sv_no # define PL_sv_yes sv_yes # define PL_markstack_ptr markstack_ptr #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif # define NUM2PTR(any,d) (any)(PTRV)(d) # define PTR2IV(p) INT2PTR(IV,p) # define PTR2UV(p) INT2PTR(UV,p) # define PTR2NV(p) NUM2PTR(NV,p) # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif /* !INT2PTR */ #ifndef SvPV_nolen # define SvPV_nolen(x) SvPV(x,PL_na) #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif #ifndef pTHX_ #define pTHX_ #endif #include #ifdef __cplusplus } #endif swig-3.0.2/Lib/perl5/perlmacros.swg0000664000175000017500000000004412343605122016767 0ustar williamwilliam%include swig-3.0.2/Lib/swigrun.i0000664000175000017500000000040012343605122014713 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigrun.i * * Empty module (for now). Placeholder for runtime libs * ----------------------------------------------------------------------------- */ %module swigrun swig-3.0.2/Lib/swigwarn.swg0000664000175000017500000003312112343706600015437 0ustar williamwilliam/* SWIG warning codes */ %define SWIGWARN_NONE 0 %enddef /* -- Deprecated features -- */ %define SWIGWARN_DEPRECATED_EXTERN 101 %enddef %define SWIGWARN_DEPRECATED_VAL 102 %enddef %define SWIGWARN_DEPRECATED_OUT 103 %enddef %define SWIGWARN_DEPRECATED_DISABLEDOC 104 %enddef %define SWIGWARN_DEPRECATED_ENABLEDOC 105 %enddef %define SWIGWARN_DEPRECATED_DOCONLY 106 %enddef %define SWIGWARN_DEPRECATED_STYLE 107 %enddef %define SWIGWARN_DEPRECATED_LOCALSTYLE 108 %enddef %define SWIGWARN_DEPRECATED_TITLE 109 %enddef %define SWIGWARN_DEPRECATED_SECTION 110 %enddef %define SWIGWARN_DEPRECATED_SUBSECTION 111 %enddef %define SWIGWARN_DEPRECATED_SUBSUBSECTION 112 %enddef %define SWIGWARN_DEPRECATED_ADDMETHODS 113 %enddef %define SWIGWARN_DEPRECATED_READONLY 114 %enddef %define SWIGWARN_DEPRECATED_READWRITE 115 %enddef %define SWIGWARN_DEPRECATED_EXCEPT 116 %enddef %define SWIGWARN_DEPRECATED_NEW 117 %enddef %define SWIGWARN_DEPRECATED_EXCEPT_TM 118 %enddef %define SWIGWARN_DEPRECATED_IGNORE_TM 119 %enddef %define SWIGWARN_DEPRECATED_OPTC 120 %enddef %define SWIGWARN_DEPRECATED_NAME 121 %enddef %define SWIGWARN_DEPRECATED_NOEXTERN 122 %enddef %define SWIGWARN_DEPRECATED_NODEFAULT 123 %enddef %define SWIGWARN_DEPRECATED_TYPEMAP_LANG 124 %enddef %define SWIGWARN_DEPRECATED_INPUT_FILE 125 %enddef %define SWIGWARN_DEPRECATED_NESTED_WORKAROUND 126 %enddef /* -- Preprocessor -- */ %define SWIGWARN_PP_MISSING_FILE 201 %enddef %define SWIGWARN_PP_EVALUATION 202 %enddef %define SWIGWARN_PP_INCLUDEALL_IMPORTALL 203 %enddef %define SWIGWARN_PP_CPP_WARNING 204 %enddef %define SWIGWARN_PP_CPP_ERROR 205 %enddef %define SWIGWARN_PP_UNEXPECTED_TOKENS 206 %enddef /* -- C/C++ Parser -- */ %define SWIGWARN_PARSE_CLASS_KEYWORD 301 %enddef %define SWIGWARN_PARSE_REDEFINED 302 %enddef %define SWIGWARN_PARSE_EXTEND_UNDEF 303 %enddef %define SWIGWARN_PARSE_UNSUPPORTED_VALUE 304 %enddef %define SWIGWARN_PARSE_BAD_VALUE 305 %enddef %define SWIGWARN_PARSE_PRIVATE 306 %enddef %define SWIGWARN_PARSE_BAD_DEFAULT 307 %enddef %define SWIGWARN_PARSE_NAMESPACE_ALIAS 308 %enddef %define SWIGWARN_PARSE_PRIVATE_INHERIT 309 %enddef %define SWIGWARN_PARSE_TEMPLATE_REPEAT 310 %enddef %define SWIGWARN_PARSE_TEMPLATE_PARTIAL 311 %enddef %define SWIGWARN_PARSE_UNNAMED_NESTED_CLASS 312 %enddef %define SWIGWARN_PARSE_UNDEFINED_EXTERN 313 %enddef %define SWIGWARN_PARSE_KEYWORD 314 %enddef %define SWIGWARN_PARSE_USING_UNDEF 315 %enddef %define SWIGWARN_PARSE_MODULE_REPEAT 316 %enddef %define SWIGWARN_PARSE_TEMPLATE_SP_UNDEF 317 %enddef %define SWIGWARN_PARSE_TEMPLATE_AMBIG 318 %enddef %define SWIGWARN_PARSE_NO_ACCESS 319 %enddef %define SWIGWARN_PARSE_EXPLICIT_TEMPLATE 320 %enddef %define SWIGWARN_PARSE_BUILTIN_NAME 321 %enddef %define SWIGWARN_PARSE_REDUNDANT 322 %enddef %define SWIGWARN_PARSE_REC_INHERITANCE 323 %enddef %define SWIGWARN_PARSE_NESTED_TEMPLATE 324 %enddef %define SWIGWARN_PARSE_NAMED_NESTED_CLASS 325 %enddef %define SWIGWARN_PARSE_EXTEND_NAME 326 %enddef %define SWIGWARN_CPP11_LAMBDA 340 %enddef %define SWIGWARN_CPP11_ALIAS_DECLARATION 341 %enddef %define SWIGWARN_CPP11_ALIAS_TEMPLATE 342 %enddef %define SWIGWARN_CPP11_VARIADIC_TEMPLATE 343 %enddef %define SWIGWARN_IGNORE_OPERATOR_NEW 350 %enddef /* new */ %define SWIGWARN_IGNORE_OPERATOR_DELETE 351 %enddef /* delete */ %define SWIGWARN_IGNORE_OPERATOR_PLUS 352 %enddef /* + */ %define SWIGWARN_IGNORE_OPERATOR_MINUS 353 %enddef /* - */ %define SWIGWARN_IGNORE_OPERATOR_MUL 354 %enddef /* * */ %define SWIGWARN_IGNORE_OPERATOR_DIV 355 %enddef /* / */ %define SWIGWARN_IGNORE_OPERATOR_MOD 356 %enddef /* % */ %define SWIGWARN_IGNORE_OPERATOR_XOR 357 %enddef /* ^ */ %define SWIGWARN_IGNORE_OPERATOR_AND 358 %enddef /* & */ %define SWIGWARN_IGNORE_OPERATOR_OR 359 %enddef /* | */ %define SWIGWARN_IGNORE_OPERATOR_NOT 360 %enddef /* ~ */ %define SWIGWARN_IGNORE_OPERATOR_LNOT 361 %enddef /* ! */ %define SWIGWARN_IGNORE_OPERATOR_EQ 362 %enddef /* = */ %define SWIGWARN_IGNORE_OPERATOR_LT 363 %enddef /* < */ %define SWIGWARN_IGNORE_OPERATOR_GT 364 %enddef /* > */ %define SWIGWARN_IGNORE_OPERATOR_PLUSEQ 365 %enddef /* += */ %define SWIGWARN_IGNORE_OPERATOR_MINUSEQ 366 %enddef /* -= */ %define SWIGWARN_IGNORE_OPERATOR_MULEQ 367 %enddef /* *= */ %define SWIGWARN_IGNORE_OPERATOR_DIVEQ 368 %enddef /* /= */ %define SWIGWARN_IGNORE_OPERATOR_MODEQ 369 %enddef /* %= */ %define SWIGWARN_IGNORE_OPERATOR_XOREQ 370 %enddef /* ^= */ %define SWIGWARN_IGNORE_OPERATOR_ANDEQ 371 %enddef /* &= */ %define SWIGWARN_IGNORE_OPERATOR_OREQ 372 %enddef /* |= */ %define SWIGWARN_IGNORE_OPERATOR_LSHIFT 373 %enddef /* << */ %define SWIGWARN_IGNORE_OPERATOR_RSHIFT 374 %enddef /* >> */ %define SWIGWARN_IGNORE_OPERATOR_LSHIFTEQ 375 %enddef /* <<= */ %define SWIGWARN_IGNORE_OPERATOR_RSHIFTEQ 376 %enddef /* >>= */ %define SWIGWARN_IGNORE_OPERATOR_EQUALTO 377 %enddef /* == */ %define SWIGWARN_IGNORE_OPERATOR_NOTEQUAL 378 %enddef /* != */ %define SWIGWARN_IGNORE_OPERATOR_LTEQUAL 379 %enddef /* <= */ %define SWIGWARN_IGNORE_OPERATOR_GTEQUAL 380 %enddef /* >= */ %define SWIGWARN_IGNORE_OPERATOR_LAND 381 %enddef /* && */ %define SWIGWARN_IGNORE_OPERATOR_LOR 382 %enddef /* || */ %define SWIGWARN_IGNORE_OPERATOR_PLUSPLUS 383 %enddef /* ++ */ %define SWIGWARN_IGNORE_OPERATOR_MINUSMINUS 384 %enddef /* -- */ %define SWIGWARN_IGNORE_OPERATOR_COMMA 385 %enddef /* , */ %define SWIGWARN_IGNORE_OPERATOR_ARROWSTAR 386 %enddef /* ->* */ %define SWIGWARN_IGNORE_OPERATOR_ARROW 387 %enddef /* -> */ %define SWIGWARN_IGNORE_OPERATOR_CALL 388 %enddef /* () */ %define SWIGWARN_IGNORE_OPERATOR_INDEX 389 %enddef /* [] */ %define SWIGWARN_IGNORE_OPERATOR_UPLUS 390 %enddef /* + */ %define SWIGWARN_IGNORE_OPERATOR_UMINUS 391 %enddef /* - */ %define SWIGWARN_IGNORE_OPERATOR_UMUL 392 %enddef /* * */ %define SWIGWARN_IGNORE_OPERATOR_UAND 393 %enddef /* & */ %define SWIGWARN_IGNORE_OPERATOR_NEWARR 394 %enddef /* new [] */ %define SWIGWARN_IGNORE_OPERATOR_DELARR 395 %enddef /* delete [] */ %define SWIGWARN_IGNORE_OPERATOR_REF 396 %enddef /* operator *() */ /* 394-399 are reserved */ /* -- Type system and typemaps -- */ %define SWIGWARN_TYPE_UNDEFINED_CLASS 401 %enddef %define SWIGWARN_TYPE_INCOMPLETE 402 %enddef %define SWIGWARN_TYPE_ABSTRACT 403 %enddef %define SWIGWARN_TYPE_REDEFINED 404 %enddef %define SWIGWARN_TYPEMAP_SOURCETARGET 450 %enddef %define SWIGWARN_TYPEMAP_CHARLEAK 451 %enddef %define SWIGWARN_TYPEMAP_SWIGTYPE 452 %enddef %define SWIGWARN_TYPEMAP_APPLY_UNDEF 453 %enddef %define SWIGWARN_TYPEMAP_SWIGTYPELEAK 454 %enddef %define SWIGWARN_TYPEMAP_IN_UNDEF 460 %enddef %define SWIGWARN_TYPEMAP_OUT_UNDEF 461 %enddef %define SWIGWARN_TYPEMAP_VARIN_UNDEF 462 %enddef %define SWIGWARN_TYPEMAP_VAROUT_UNDEF 463 %enddef %define SWIGWARN_TYPEMAP_CONST_UNDEF 464 %enddef %define SWIGWARN_TYPEMAP_UNDEF 465 %enddef %define SWIGWARN_TYPEMAP_VAR_UNDEF 466 %enddef %define SWIGWARN_TYPEMAP_TYPECHECK 467 %enddef %define SWIGWARN_TYPEMAP_THROW 468 %enddef %define SWIGWARN_TYPEMAP_DIRECTORIN_UNDEF 469 %enddef %define SWIGWARN_TYPEMAP_THREAD_UNSAFE 470 %enddef /* mostly used in directorout typemaps */ %define SWIGWARN_TYPEMAP_DIRECTOROUT_UNDEF 471 %enddef %define SWIGWARN_TYPEMAP_TYPECHECK_UNDEF 472 %enddef %define SWIGWARN_TYPEMAP_DIRECTOROUT_PTR 473 %enddef %define SWIGWARN_TYPEMAP_OUT_OPTIMAL_IGNORED 474 %enddef %define SWIGWARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE 475 %enddef %define SWIGWARN_TYPEMAP_INITIALIZER_LIST 476 %enddef %define SWIGWARN_TYPEMAP_DIRECTORTHROWS_UNDEF 477 %enddef /* -- Fragments -- */ %define SWIGWARN_FRAGMENT_NOT_FOUND 490 %enddef /* -- General code generation -- */ %define SWIGWARN_LANG_OVERLOAD_DECL 501 %enddef %define SWIGWARN_LANG_OVERLOAD_CONSTRUCT 502 %enddef %define SWIGWARN_LANG_IDENTIFIER 503 %enddef %define SWIGWARN_LANG_RETURN_TYPE 504 %enddef %define SWIGWARN_LANG_VARARGS 505 %enddef %define SWIGWARN_LANG_VARARGS_KEYWORD 506 %enddef %define SWIGWARN_LANG_NATIVE_UNIMPL 507 %enddef %define SWIGWARN_LANG_DEREF_SHADOW 508 %enddef %define SWIGWARN_LANG_OVERLOAD_SHADOW 509 %enddef %define SWIGWARN_LANG_FRIEND_IGNORE 510 %enddef %define SWIGWARN_LANG_OVERLOAD_KEYWORD 511 %enddef %define SWIGWARN_LANG_OVERLOAD_CONST 512 %enddef %define SWIGWARN_LANG_CLASS_UNNAMED 513 %enddef %define SWIGWARN_LANG_DIRECTOR_VDESTRUCT 514 %enddef %define SWIGWARN_LANG_DISCARD_CONST 515 %enddef %define SWIGWARN_LANG_OVERLOAD_IGNORED 516 %enddef %define SWIGWARN_LANG_DIRECTOR_ABSTRACT 517 %enddef %define SWIGWARN_LANG_PORTABILITY_FILENAME 518 %enddef %define SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE 519 %enddef %define SWIGWARN_LANG_SMARTPTR_MISSING 520 %enddef %define SWIGWARN_LANG_ILLEGAL_DESTRUCTOR 521 %enddef %define SWIGWARN_LANG_EXTEND_CONSTRUCTOR 522 %enddef %define SWIGWARN_LANG_EXTEND_DESTRUCTOR 523 %enddef /* -- Reserved (600-799) -- */ /* -- Language module specific warnings (700 - 899) -- */ %define SWIGWARN_D_TYPEMAP_CTYPE_UNDEF 700 %enddef %define SWIGWARN_D_TYPEMAP_IMTYPE_UNDEF 701 %enddef %define SWIGWARN_D_TYPEMAP_DTYPE_UNDEF 702 %enddef %define SWIGWARN_D_MULTIPLE_INHERITANCE 703 %enddef %define SWIGWARN_D_TYPEMAP_CLASSMOD_UNDEF 704 %enddef %define SWIGWARN_D_TYPEMAP_DBODY_UNDEF 705 %enddef %define SWIGWARN_D_TYPEMAP_DOUT_UNDEF 706 %enddef %define SWIGWARN_D_TYPEMAP_DIN_UNDEF 707 %enddef %define SWIGWARN_D_TYPEMAP_DDIRECTORIN_UNDEF 708 %enddef %define SWIGWARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF 709 %enddef %define SWIGWARN_D_EXCODE_MISSING 710 %enddef %define SWIGWARN_D_CANTHROW_MISSING 711 %enddef %define SWIGWARN_D_NO_DIRECTORCONNECT_ATTR 712 %enddef %define SWIGWARN_D_NAME_COLLISION 713 %enddef /* please leave 700-719 free for D */ %define SWIGWARN_RUBY_WRONG_NAME 801 %enddef %define SWIGWARN_RUBY_MULTIPLE_INHERITANCE 802 %enddef /* please leave 800-809 free for Ruby */ %define SWIGWARN_JAVA_TYPEMAP_JNI_UNDEF 810 %enddef %define SWIGWARN_JAVA_TYPEMAP_JTYPE_UNDEF 811 %enddef %define SWIGWARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812 %enddef %define SWIGWARN_JAVA_MULTIPLE_INHERITANCE 813 %enddef %define SWIGWARN_JAVA_TYPEMAP_GETCPTR_UNDEF 814 %enddef %define SWIGWARN_JAVA_TYPEMAP_CLASSMOD_UNDEF 815 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVABODY_UNDEF 816 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVAOUT_UNDEF 817 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVAIN_UNDEF 818 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF 819 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVADIRECTOROUT_UNDEF 820 %enddef %define SWIGWARN_JAVA_COVARIANT_RET 822 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF 823 %enddef %define SWIGWARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824 %enddef %define SWIGWARN_JAVA_NO_DIRECTORCONNECT_ATTR 825 %enddef %define SWIGWARN_JAVA_NSPACE_WITHOUT_PACKAGE 826 %enddef /* please leave 810-829 free for Java */ %define SWIGWARN_CSHARP_TYPEMAP_CTYPE_UNDEF 830 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSTYPE_UNDEF 831 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF 832 %enddef %define SWIGWARN_CSHARP_MULTIPLE_INHERITANCE 833 %enddef %define SWIGWARN_CSHARP_TYPEMAP_GETCPTR_UNDEF 834 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF 835 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSBODY_UNDEF 836 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSOUT_UNDEF 837 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSIN_UNDEF 838 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF 839 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSDIRECTOROUT_UNDEF 840 %enddef %define SWIGWARN_CSHARP_COVARIANT_RET 842 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF 843 %enddef %define SWIGWARN_CSHARP_EXCODE 844 %enddef %define SWIGWARN_CSHARP_CANTHROW 845 %enddef %define SWIGWARN_CSHARP_NO_DIRECTORCONNECT_ATTR 846 %enddef /* please leave 830-849 free for C# */ %define SWIGWARN_MODULA3_TYPEMAP_TYPE_UNDEF 850 %enddef %define SWIGWARN_MODULA3_TYPEMAP_GETCPTR_UNDEF 851 %enddef %define SWIGWARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF 852 %enddef %define SWIGWARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF 853 %enddef %define SWIGWARN_MODULA3_TYPEMAP_MULTIPLE_RETURN 854 %enddef %define SWIGWARN_MODULA3_MULTIPLE_INHERITANCE 855 %enddef %define SWIGWARN_MODULA3_TYPECONSTRUCTOR_UNKNOWN 856 %enddef %define SWIGWARN_MODULA3_UNKNOWN_PRAGMA 857 %enddef %define SWIGWARN_MODULA3_BAD_ENUMERATION 858 %enddef %define SWIGWARN_MODULA3_DOUBLE_ID 859 %enddef %define SWIGWARN_MODULA3_BAD_IMPORT 860 %enddef /* please leave 850-869 free for Modula 3 */ %define SWIGWARN_PHP_MULTIPLE_INHERITANCE 870 %enddef %define SWIGWARN_PHP_UNKNOWN_PRAGMA 871 %enddef %define SWIGWARN_PHP_PUBLIC_BASE 872 %enddef /* please leave 870-889 free for PHP */ %define SWIGWARN_GO_NAME_CONFLICT 890 %enddef /* please leave 890-899 free for Go */ /* -- User defined warnings (900 - 999) -- */ swig-3.0.2/Lib/std_except.i0000664000175000017500000000371712343605122015375 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * SWIG library file with typemaps to handle and throw STD exceptions in a * language and STL independent way, i.e., the target language doesn't * require to support STL but only the 'exception.i' mechanism. * * These typemaps are used when methods are declared with an STD * exception specification, such as * * size_t at() const throw (std::out_of_range); * * The typemaps here are based on the language independent * 'exception.i' library. If that is working in your target language, * this file will work. * * If the target language doesn't implement a robust 'exception.i' * mechanism, or you prefer other ways to map the STD exceptions, write * a new std_except.i file in the target library directory. * ----------------------------------------------------------------------------- */ #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL) || defined(SWIGD) #error "This version of std_except.i should not be used" #endif %{ #include %} %include %define %std_exception_map(Exception, Code) %typemap(throws,noblock=1) Exception { SWIG_exception(Code, $1.what()); } %ignore Exception; struct Exception { }; %enddef namespace std { %std_exception_map(bad_exception, SWIG_SystemError); %std_exception_map(domain_error, SWIG_ValueError); %std_exception_map(exception, SWIG_SystemError); %std_exception_map(invalid_argument, SWIG_ValueError); %std_exception_map(length_error, SWIG_IndexError); %std_exception_map(logic_error, SWIG_RuntimeError); %std_exception_map(out_of_range, SWIG_IndexError); %std_exception_map(overflow_error, SWIG_OverflowError); %std_exception_map(range_error, SWIG_OverflowError); %std_exception_map(runtime_error, SWIG_RuntimeError); %std_exception_map(underflow_error, SWIG_OverflowError); } swig-3.0.2/Lib/java/0000775000175000017500000000000012343605122013772 5ustar williamwilliamswig-3.0.2/Lib/java/enumsimple.swg0000664000175000017500000000501712343605122016675 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enumsimple.swg * * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 * and earlier wrapped global enums with constant integers in the module class * or Constants interface. Enums declared within a C++ class were wrapped by * constant integers in the Java proxy class. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(jni) const enum SWIGTYPE & "jint" %typemap(jtype) const enum SWIGTYPE & "int" %typemap(jstype) const enum SWIGTYPE & "int" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1;" %typemap(javadirectorin) const enum SWIGTYPE & "$jniinput" %typemap(javadirectorout) const enum SWIGTYPE & "$javacall" %typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" %typemap(throws) const enum SWIGTYPE & %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) const enum SWIGTYPE & "$javainput" %typemap(javaout) const enum SWIGTYPE & { return $jnicall; } // enum SWIGTYPE typemaps %typemap(jni) enum SWIGTYPE "jint" %typemap(jtype) enum SWIGTYPE "int" %typemap(jstype) enum SWIGTYPE "int" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;" %typemap(javadirectorin) enum SWIGTYPE "$jniinput" %typemap(javadirectorout) enum SWIGTYPE "$javacall" %typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" %typemap(throws) enum SWIGTYPE %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) enum SWIGTYPE "$javainput" %typemap(javaout) enum SWIGTYPE { return $jnicall; } %typemap(javaclassmodifiers) enum SWIGTYPE "" %typemap(javabase) enum SWIGTYPE "" %typemap(javacode) enum SWIGTYPE "" %typemap(javaimports) enum SWIGTYPE "" %typemap(javainterfaces) enum SWIGTYPE "" %typemap(javabody) enum SWIGTYPE "" %javaenum(simple); swig-3.0.2/Lib/java/java.swg0000664000175000017500000013516612343605122015451 0ustar williamwilliam/* ----------------------------------------------------------------------------- * java.swg * * Java typemaps * ----------------------------------------------------------------------------- */ %include /* The jni, jtype and jstype typemaps work together and so there should be one of each. * The jni typemap contains the JNI type used in the JNI (C/C++) code. * The jtype typemap contains the Java type used in the JNI intermediary class. * The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */ /* Fragments */ %fragment("SWIG_PackData", "header") { /* Pack binary data into a string */ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; const unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } } %fragment("SWIG_UnPackData", "header") { /* Unpack binary data from a string */ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } } /* Primitive types */ %typemap(jni) bool, const bool & "jboolean" %typemap(jni) char, const char & "jchar" %typemap(jni) signed char, const signed char & "jbyte" %typemap(jni) unsigned char, const unsigned char & "jshort" %typemap(jni) short, const short & "jshort" %typemap(jni) unsigned short, const unsigned short & "jint" %typemap(jni) int, const int & "jint" %typemap(jni) unsigned int, const unsigned int & "jlong" %typemap(jni) long, const long & "jint" %typemap(jni) unsigned long, const unsigned long & "jlong" %typemap(jni) long long, const long long & "jlong" %typemap(jni) unsigned long long, const unsigned long long & "jobject" %typemap(jni) float, const float & "jfloat" %typemap(jni) double, const double & "jdouble" %typemap(jni) void "void" %typemap(jtype) bool, const bool & "boolean" %typemap(jtype) char, const char & "char" %typemap(jtype) signed char, const signed char & "byte" %typemap(jtype) unsigned char, const unsigned char & "short" %typemap(jtype) short, const short & "short" %typemap(jtype) unsigned short, const unsigned short & "int" %typemap(jtype) int, const int & "int" %typemap(jtype) unsigned int, const unsigned int & "long" %typemap(jtype) long, const long & "int" %typemap(jtype) unsigned long, const unsigned long & "long" %typemap(jtype) long long, const long long & "long" %typemap(jtype) unsigned long long, const unsigned long long & "java.math.BigInteger" %typemap(jtype) float, const float & "float" %typemap(jtype) double, const double & "double" %typemap(jtype) void "void" %typemap(jstype) bool, const bool & "boolean" %typemap(jstype) char, const char & "char" %typemap(jstype) signed char, const signed char & "byte" %typemap(jstype) unsigned char, const unsigned char & "short" %typemap(jstype) short, const short & "short" %typemap(jstype) unsigned short, const unsigned short & "int" %typemap(jstype) int, const int & "int" %typemap(jstype) unsigned int, const unsigned int & "long" %typemap(jstype) long, const long & "int" %typemap(jstype) unsigned long, const unsigned long & "long" %typemap(jstype) long long, const long long & "long" %typemap(jstype) unsigned long long, const unsigned long long & "java.math.BigInteger" %typemap(jstype) float, const float & "float" %typemap(jstype) double, const double & "double" %typemap(jstype) void "void" %typemap(jni) char *, char *&, char[ANY], char[] "jstring" %typemap(jtype) char *, char *&, char[ANY], char[] "String" %typemap(jstype) char *, char *&, char[ANY], char[] "String" /* JNI types */ %typemap(jni) jboolean "jboolean" %typemap(jni) jchar "jchar" %typemap(jni) jbyte "jbyte" %typemap(jni) jshort "jshort" %typemap(jni) jint "jint" %typemap(jni) jlong "jlong" %typemap(jni) jfloat "jfloat" %typemap(jni) jdouble "jdouble" %typemap(jni) jstring "jstring" %typemap(jni) jobject "jobject" %typemap(jni) jbooleanArray "jbooleanArray" %typemap(jni) jcharArray "jcharArray" %typemap(jni) jbyteArray "jbyteArray" %typemap(jni) jshortArray "jshortArray" %typemap(jni) jintArray "jintArray" %typemap(jni) jlongArray "jlongArray" %typemap(jni) jfloatArray "jfloatArray" %typemap(jni) jdoubleArray "jdoubleArray" %typemap(jni) jobjectArray "jobjectArray" %typemap(jtype) jboolean "boolean" %typemap(jtype) jchar "char" %typemap(jtype) jbyte "byte" %typemap(jtype) jshort "short" %typemap(jtype) jint "int" %typemap(jtype) jlong "long" %typemap(jtype) jfloat "float" %typemap(jtype) jdouble "double" %typemap(jtype) jstring "String" %typemap(jtype) jobject "Object" %typemap(jtype) jbooleanArray "boolean[]" %typemap(jtype) jcharArray "char[]" %typemap(jtype) jbyteArray "byte[]" %typemap(jtype) jshortArray "short[]" %typemap(jtype) jintArray "int[]" %typemap(jtype) jlongArray "long[]" %typemap(jtype) jfloatArray "float[]" %typemap(jtype) jdoubleArray "double[]" %typemap(jtype) jobjectArray "Object[]" %typemap(jstype) jboolean "boolean" %typemap(jstype) jchar "char" %typemap(jstype) jbyte "byte" %typemap(jstype) jshort "short" %typemap(jstype) jint "int" %typemap(jstype) jlong "long" %typemap(jstype) jfloat "float" %typemap(jstype) jdouble "double" %typemap(jstype) jstring "String" %typemap(jstype) jobject "Object" %typemap(jstype) jbooleanArray "boolean[]" %typemap(jstype) jcharArray "char[]" %typemap(jstype) jbyteArray "byte[]" %typemap(jstype) jshortArray "short[]" %typemap(jstype) jintArray "int[]" %typemap(jstype) jlongArray "long[]" %typemap(jstype) jfloatArray "float[]" %typemap(jstype) jdoubleArray "double[]" %typemap(jstype) jobjectArray "Object[]" /* Non primitive types */ %typemap(jni) SWIGTYPE "jlong" %typemap(jtype) SWIGTYPE "long" %typemap(jstype) SWIGTYPE "$&javaclassname" %typemap(jni) SWIGTYPE [] "jlong" %typemap(jtype) SWIGTYPE [] "long" %typemap(jstype) SWIGTYPE [] "$javaclassname" %typemap(jni) SWIGTYPE * "jlong" %typemap(jtype) SWIGTYPE * "long" %typemap(jstype) SWIGTYPE * "$javaclassname" %typemap(jni) SWIGTYPE & "jlong" %typemap(jtype) SWIGTYPE & "long" %typemap(jstype) SWIGTYPE & "$javaclassname" %typemap(jni) SWIGTYPE && "jlong" %typemap(jtype) SWIGTYPE && "long" %typemap(jstype) SWIGTYPE && "$javaclassname" /* pointer to a class member */ %typemap(jni) SWIGTYPE (CLASS::*) "jstring" %typemap(jtype) SWIGTYPE (CLASS::*) "String" %typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname" /* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */ /* primitive types */ %typemap(in) bool %{ $1 = $input ? true : false; %} %typemap(directorout) bool %{ $result = $input ? true : false; %} %typemap(javadirectorin) bool "$jniinput" %typemap(javadirectorout) bool "$javacall" %typemap(in) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, float, double %{ $1 = ($1_ltype)$input; %} %typemap(directorout) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, float, double %{ $result = ($1_ltype)$input; %} %typemap(directorin, descriptor="Z") bool "$input = (jboolean) $1;" %typemap(directorin, descriptor="C") char "$input = (jint) $1;" %typemap(directorin, descriptor="B") signed char "$input = (jbyte) $1;" %typemap(directorin, descriptor="S") unsigned char "$input = (jshort) $1;" %typemap(directorin, descriptor="S") short "$input = (jshort) $1;" %typemap(directorin, descriptor="I") unsigned short "$input = (jint) $1;" %typemap(directorin, descriptor="I") int "$input = (jint) $1;" %typemap(directorin, descriptor="J") unsigned int "$input = (jlong) $1;" %typemap(directorin, descriptor="I") long "$input = (jint) $1;" %typemap(directorin, descriptor="J") unsigned long "$input = (jlong) $1;" %typemap(directorin, descriptor="J") long long "$input = (jlong) $1;" %typemap(directorin, descriptor="F") float "$input = (jfloat) $1;" %typemap(directorin, descriptor="D") double "$input = (jdouble) $1;" %typemap(javadirectorin) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, float, double "$jniinput" %typemap(javadirectorout) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, float, double "$javacall" %typemap(out) bool %{ $result = (jboolean)$1; %} %typemap(out) char %{ $result = (jchar)$1; %} %typemap(out) signed char %{ $result = (jbyte)$1; %} %typemap(out) unsigned char %{ $result = (jshort)$1; %} %typemap(out) short %{ $result = (jshort)$1; %} %typemap(out) unsigned short %{ $result = (jint)$1; %} %typemap(out) int %{ $result = (jint)$1; %} %typemap(out) unsigned int %{ $result = (jlong)$1; %} %typemap(out) long %{ $result = (jint)$1; %} %typemap(out) unsigned long %{ $result = (jlong)$1; %} %typemap(out) long long %{ $result = (jlong)$1; %} %typemap(out) float %{ $result = (jfloat)$1; %} %typemap(out) double %{ $result = (jdouble)$1; %} /* unsigned long long */ /* Convert from BigInteger using the toByteArray member function */ %typemap(in) unsigned long long { jclass clazz; jmethodID mid; jbyteArray ba; jbyte* bae; jsize sz; int i; if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); return $null; } clazz = JCALL1(GetObjectClass, jenv, $input); mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); bae = JCALL2(GetByteArrayElements, jenv, ba, 0); sz = JCALL1(GetArrayLength, jenv, ba); $1 = 0; for(i=0; i", "([B)V"); jobject bigint; int i; bae[0] = 0; for(i=1; i<9; i++ ) { bae[i] = (jbyte)($1>>8*(8-i)); } JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); bigint = JCALL3(NewObject, jenv, clazz, mid, ba); $result = bigint; } /* Convert to BigInteger (see out typemap) */ %typemap(directorin, descriptor="Ljava/math/BigInteger;") unsigned long long, const unsigned long long & { jbyteArray ba = JCALL1(NewByteArray, jenv, 9); jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "", "([B)V"); jobject bigint; int swig_i; bae[0] = 0; for(swig_i=1; swig_i<9; swig_i++ ) { bae[swig_i] = (jbyte)($1>>8*(8-swig_i)); } JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); bigint = JCALL3(NewObject, jenv, clazz, mid, ba); $input = bigint; } %typemap(javadirectorin) unsigned long long "$jniinput" %typemap(javadirectorout) unsigned long long "$javacall" /* char * - treat as String */ %typemap(in, noblock=1) char * { $1 = 0; if ($input) { $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!$1) return $null; } } %typemap(directorout, noblock=1, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * { $1 = 0; if ($input) { $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!$result) return $null; } } %typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * { $input = 0; if ($1) { $input = JCALL1(NewStringUTF, jenv, (const char *)$1); if (!$input) return $null; } } %typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } %typemap(out, noblock=1) char * { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } %typemap(javadirectorin) char * "$jniinput" %typemap(javadirectorout) char * "$javacall" /* char *& - treat as String */ %typemap(in, noblock=1) char *& ($*1_ltype temp = 0) { $1 = 0; if ($input) { temp = ($*1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!temp) return $null; } $1 = &temp; } %typemap(freearg, noblock=1) char *& { if ($1 && *$1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)*$1); } %typemap(out, noblock=1) char *& { if (*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); } %typemap(out) void "" %typemap(javadirectorin) void "$jniinput" %typemap(javadirectorout) void "$javacall" %typemap(directorin, descriptor="V") void "" /* primitive types by reference */ %typemap(in) const bool & ($*1_ltype temp) %{ temp = $input ? true : false; $1 = &temp; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool & %{ static $*1_ltype temp; temp = $input ? true : false; $result = &temp; %} %typemap(javadirectorin) const bool & "$jniinput" %typemap(javadirectorout) const bool & "$javacall" %typemap(in) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const float &, const double & %{ static $*1_ltype temp; temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin, descriptor="Z") const bool & "$input = (jboolean)$1;" %typemap(directorin, descriptor="C") const char & "$input = (jchar)$1;" %typemap(directorin, descriptor="B") const signed char & "$input = (jbyte)$1;" %typemap(directorin, descriptor="S") const unsigned char & "$input = (jshort)$1;" %typemap(directorin, descriptor="S") const short & "$input = (jshort)$1;" %typemap(directorin, descriptor="I") const unsigned short & "$input = (jint)$1;" %typemap(directorin, descriptor="I") const int & "$input = (jint)$1;" %typemap(directorin, descriptor="J") const unsigned int & "$input = (jlong)$1;" %typemap(directorin, descriptor="I") const long & "$input = (jint)$1;" %typemap(directorin, descriptor="J") const unsigned long & "$input = (jlong)$1;" %typemap(directorin, descriptor="J") const long long & "$input = (jlong)$1;" %typemap(directorin, descriptor="F") const float & "$input = (jfloat)$1;" %typemap(directorin, descriptor="D") const double & "$input = (jdouble)$1;" %typemap(javadirectorin) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) "$jniinput" %typemap(javadirectorout) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) "$javacall" %typemap(out) const bool & %{ $result = (jboolean)*$1; %} %typemap(out) const char & %{ $result = (jchar)*$1; %} %typemap(out) const signed char & %{ $result = (jbyte)*$1; %} %typemap(out) const unsigned char & %{ $result = (jshort)*$1; %} %typemap(out) const short & %{ $result = (jshort)*$1; %} %typemap(out) const unsigned short & %{ $result = (jint)*$1; %} %typemap(out) const int & %{ $result = (jint)*$1; %} %typemap(out) const unsigned int & %{ $result = (jlong)*$1; %} %typemap(out) const long & %{ $result = (jint)*$1; %} %typemap(out) const unsigned long & %{ $result = (jlong)*$1; %} %typemap(out) const long long & %{ $result = (jlong)*$1; %} %typemap(out) const float & %{ $result = (jfloat)*$1; %} %typemap(out) const double & %{ $result = (jdouble)*$1; %} /* const unsigned long long & */ /* Similar to unsigned long long */ %typemap(in) const unsigned long long & ($*1_ltype temp) { jclass clazz; jmethodID mid; jbyteArray ba; jbyte* bae; jsize sz; int i; if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); return $null; } clazz = JCALL1(GetObjectClass, jenv, $input); mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); bae = JCALL2(GetByteArrayElements, jenv, ba, 0); sz = JCALL1(GetArrayLength, jenv, ba); $1 = &temp; temp = 0; for(i=0; i", "([B)V"); jobject bigint; int i; bae[0] = 0; for(i=1; i<9; i++ ) { bae[i] = (jbyte)(*$1>>8*(8-i)); } JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); bigint = JCALL3(NewObject, jenv, clazz, mid, ba); $result = bigint; } %typemap(javadirectorin) const unsigned long long & "$jniinput" %typemap(javadirectorout) const unsigned long long & "$javacall" /* Default handling. Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_type argp) %{ argp = *($&1_ltype*)&$input; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(directorout) SWIGTYPE ($&1_type argp) %{ argp = *($&1_ltype*)&$input; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type"); return $null; } $result = *argp; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{ *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); *($&1_ltype*)&$result = $1ptr; } #endif %typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE %{ $input = 0; *(($&1_ltype*)&$input) = &$1; %} %typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, false)" %typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)" /* Generic pointers and references */ %typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %} %typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) { const char *temp = 0; if ($input) { temp = JCALL2(GetStringUTFChars, jenv, $input, 0); if (!temp) return $null; } SWIG_UnpackData(temp, (void *)&$1, sizeof($1)); } %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(in) SWIGTYPE && %{ $1 = *($&1_ltype)&$input; if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(out) SWIGTYPE * %{ *($&1_ltype)&$result = $1; %} %typemap(out, fragment="SWIG_PackData", noblock=1) SWIGTYPE (CLASS::*) { char buf[128]; char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1)); *data = '\0'; $result = JCALL1(NewStringUTF, jenv, buf); } %typemap(out) SWIGTYPE & %{ *($&1_ltype)&$result = $1; %} %typemap(out) SWIGTYPE && %{ *($&1_ltype)&$result = $1; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE * %{ $result = *($&1_ltype)&$input; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*) %{ $result = *($&1_ltype)&$input; %} %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE * %{ *(($&1_ltype)&$input) = ($1_ltype) $1; %} %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE (CLASS::*) %{ *(($&1_ltype)&$input) = ($1_ltype) $1; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE & %{ if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type"); return $null; } $result = *($&1_ltype)&$input; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE && %{ if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type"); return $null; } $result = *($&1_ltype)&$input; %} %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE & %{ *($&1_ltype)&$input = ($1_ltype) &$1; %} %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE && %{ *($&1_ltype)&$input = ($1_ltype) &$1; %} %typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($jniinput == 0) ? null : new $javaclassname($jniinput, false)" %typemap(javadirectorin) SWIGTYPE & "new $javaclassname($jniinput, false)" %typemap(javadirectorin) SWIGTYPE && "new $javaclassname($jniinput, false)" %typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, SWIGTYPE && "$javaclassname.getCPtr($javacall)" /* Default array handling */ %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %} %typemap(freearg) SWIGTYPE [ANY], SWIGTYPE [] "" /* char arrays - treat as String */ %typemap(in, noblock=1) char[ANY], char[] { $1 = 0; if ($input) { $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!$1) return $null; } } %typemap(directorout, noblock=1) char[ANY], char[] { $1 = 0; if ($input) { $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!$result) return $null; } } %typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char[ANY], char[] { $input = 0; if ($1) { $input = JCALL1(NewStringUTF, jenv, (const char *)$1); if (!$input) return $null; } } %typemap(argout) char[ANY], char[] "" %typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } %typemap(out, noblock=1) char[ANY], char[] { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } %typemap(javadirectorin) char[ANY], char[] "$jniinput" %typemap(javadirectorout) char[ANY], char[] "$javacall" /* JNI types */ %typemap(in) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray %{ $1 = $input; %} %typemap(directorout) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray %{ $result = $input; %} %typemap(out) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray %{ $result = $1; %} %typemap(directorin,descriptor="Z") jboolean "$input = $1;" %typemap(directorin,descriptor="C") jchar "$input = $1;" %typemap(directorin,descriptor="B") jbyte "$input = $1;" %typemap(directorin,descriptor="S") jshort "$input = $1;" %typemap(directorin,descriptor="I") jint "$input = $1;" %typemap(directorin,descriptor="J") jlong "$input = $1;" %typemap(directorin,descriptor="F") jfloat "$input = $1;" %typemap(directorin,descriptor="D") jdouble "$input = $1;" %typemap(directorin,descriptor="Ljava/lang/String;") jstring "$input = $1;" %typemap(directorin,descriptor="Ljava/lang/Object;",nouse="1") jobject "$input = $1;" %typemap(directorin,descriptor="[Z") jbooleanArray "$input = $1;" %typemap(directorin,descriptor="[C") jcharArray "$input = $1;" %typemap(directorin,descriptor="[B") jbyteArray "$input = $1;" %typemap(directorin,descriptor="[S") jshortArray "$input = $1;" %typemap(directorin,descriptor="[I") jintArray "$input = $1;" %typemap(directorin,descriptor="[J") jlongArray "$input = $1;" %typemap(directorin,descriptor="[F") jfloatArray "$input = $1;" %typemap(directorin,descriptor="[D") jdoubleArray "$input = $1;" %typemap(directorin,descriptor="[Ljava/lang/Object;",nouse="1") jobjectArray "$input = $1;" %typemap(javadirectorin) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray "$jniinput" %typemap(javadirectorout) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray "$javacall" /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions * that cannot be overloaded in Java as more than one C++ type maps to a single Java type */ %typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */ jboolean, bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) /* Java char */ jchar, char, const char & "" %typecheck(SWIG_TYPECHECK_INT8) /* Java byte */ jbyte, signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_INT16) /* Java short */ jshort, unsigned char, short, const unsigned char &, const short & "" %typecheck(SWIG_TYPECHECK_INT32) /* Java int */ jint, unsigned short, int, long, const unsigned short &, const int &, const long & "" %typecheck(SWIG_TYPECHECK_INT64) /* Java long */ jlong, unsigned int, unsigned long, long long, const unsigned int &, const unsigned long &, const long long & "" %typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */ unsigned long long, const unsigned long long & "" %typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */ jfloat, float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */ jdouble, double, const double & "" %typecheck(SWIG_TYPECHECK_STRING) /* Java String */ jstring, char *, char *&, char[ANY], char [] "" %typecheck(SWIG_TYPECHECK_BOOL_ARRAY) /* Java boolean[] */ jbooleanArray "" %typecheck(SWIG_TYPECHECK_CHAR_ARRAY) /* Java char[] */ jcharArray "" %typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */ jbyteArray "" %typecheck(SWIG_TYPECHECK_INT16_ARRAY) /* Java short[] */ jshortArray "" %typecheck(SWIG_TYPECHECK_INT32_ARRAY) /* Java int[] */ jintArray "" %typecheck(SWIG_TYPECHECK_INT64_ARRAY) /* Java long[] */ jlongArray "" %typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) /* Java float[] */ jfloatArray "" %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) /* Java double[] */ jdoubleArray "" %typecheck(SWIG_TYPECHECK_OBJECT_ARRAY) /* Java jobject[] */ jobjectArray "" %typecheck(SWIG_TYPECHECK_POINTER) /* Default */ SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *const&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* Exception handling */ %typemap(throws) int, long, short, unsigned int, unsigned long, unsigned short %{ char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg); return $null; %} %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); return $null; %} %typemap(throws) char * %{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); return $null; %} /* Typemaps for code generation in proxy classes and Java type wrapper classes */ /* The javain typemap is used for converting function parameter types from the type * used in the proxy, module or type wrapper class to the type used in the JNI class. */ %typemap(javain) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double & "$javainput" %typemap(javain) char *, char *&, char[ANY], char[] "$javainput" %typemap(javain) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray "$javainput" %typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)" %typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "$javaclassname.getCPtr($javainput)" %typemap(javain) SWIGTYPE (CLASS::*) "$javaclassname.getCMemberPtr($javainput)" /* The javaout typemap is used for converting function return types from the return type * used in the JNI class to the type returned by the proxy, module or type wrapper class. */ %typemap(javaout) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double & { return $jnicall; } %typemap(javaout) char *, char *&, char[ANY], char[] { return $jnicall; } %typemap(javaout) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray { return $jnicall; } %typemap(javaout) void { $jnicall; } %typemap(javaout) SWIGTYPE { return new $&javaclassname($jnicall, true); } %typemap(javaout) SWIGTYPE & { return new $javaclassname($jnicall, $owner); } %typemap(javaout) SWIGTYPE && { return new $javaclassname($jnicall, $owner); } %typemap(javaout) SWIGTYPE *, SWIGTYPE [] { long cPtr = $jnicall; return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner); } %typemap(javaout) SWIGTYPE (CLASS::*) { String cMemberPtr = $jnicall; return (cMemberPtr == null) ? null : new $javaclassname(cMemberPtr, $owner); } /* Pointer reference typemaps */ %typemap(jni) SWIGTYPE *const& "jlong" %typemap(jtype) SWIGTYPE *const& "long" %typemap(jstype) SWIGTYPE *const& "$*javaclassname" %typemap(javain) SWIGTYPE *const& "$*javaclassname.getCPtr($javainput)" %typemap(javaout) SWIGTYPE *const& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $*javaclassname(cPtr, $owner); } %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = *($1_ltype)&$input; $1 = ($1_ltype)&temp; %} %typemap(out) SWIGTYPE *const& %{ *($1_ltype)&$result = *$1; %} /* Typemaps used for the generation of proxy and type wrapper class code */ %typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" %typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* javabody typemaps */ %define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE) %enddef // legacy name %define SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Base proxy classes %typemap(javabody) TYPE %{ private long swigCPtr; protected boolean swigCMemOwn; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} // Derived proxy classes %typemap(javabody_derived) TYPE %{ private long swigCPtr; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %enddef %define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Typewrapper classes %typemap(javabody) TYPE *, TYPE &, TYPE &&, TYPE [] %{ private long swigCPtr; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean futureUse) { swigCPtr = cPtr; } DEFAULTCTOR_VISIBILITY $javaclassname() { swigCPtr = 0; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javabody) TYPE (CLASS::*) %{ private String swigCMemberPtr; PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, boolean futureUse) { swigCMemberPtr = cMemberPtr; } DEFAULTCTOR_VISIBILITY $javaclassname() { swigCMemberPtr = null; } CPTR_VISIBILITY static String getCMemberPtr($javaclassname obj) { return obj.swigCMemberPtr; } %} %enddef /* Set the default javabody typemaps to use protected visibility. Use the macros to change to public if using multiple modules. */ SWIG_JAVABODY_PROXY(protected, protected, SWIGTYPE) SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE) %typemap(javafinalize) SWIGTYPE %{ protected void finalize() { delete(); } %} /* * Java constructor typemaps: * * The javaconstruct typemap is inserted when a proxy class's constructor is generated. * This typemap allows control over what code is executed in the constructor as * well as specifying who owns the underlying C/C++ object. Normally, Java has * ownership and the underlying C/C++ object is deallocated when the Java object * is finalized (swigCMemOwn is true.) If swigCMemOwn is false, C/C++ is * ultimately responsible for deallocating the underlying object's memory. * * The SWIG_PROXY_CONSTRUCTOR macro defines the javaconstruct typemap for a proxy * class for a particular TYPENAME. OWNERSHIP is passed as the value of * swigCMemOwn to the pointer constructor method. WEAKREF determines which kind * of Java object reference will be used by the C++ director class (WeakGlobalRef * vs. GlobalRef.) * * The SWIG_DIRECTOR_OWNED macro sets the ownership of director-based proxy * classes and the weak reference flag to false, meaning that the underlying C++ * object will be reclaimed by C++. */ %define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...) %typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME { this($imcall, OWNERSHIP);$directorconnect } %enddef %define SWIG_DIRECTOR_OWNED(TYPENAME...) SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME) %enddef // Set the default for SWIGTYPE: Java owns the C/C++ object. SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; $jnicall; } swigCPtr = 0; } } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; $jnicall; } swigCPtr = 0; } super.delete(); } %typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{ protected void $methodname() { swigCMemOwn = false; $jnicall; } %} %typemap(directorowner_release, methodname="swigReleaseOwnership") SWIGTYPE %{ public void $methodname() { swigCMemOwn = false; $jnicall; } %} %typemap(directorowner_take, methodname="swigTakeOwnership") SWIGTYPE %{ public void $methodname() { swigCMemOwn = true; $jnicall; } %} /* Java specific directives */ #define %javaconst(flag) %feature("java:const","flag") #define %javaconstvalue(value) %feature("java:constvalue",value) #define %javaenum(wrapapproach) %feature("java:enum","wrapapproach") #define %javamethodmodifiers %feature("java:methodmodifiers") #define %javaexception(exceptionclasses) %feature("except",throws=exceptionclasses) #define %nojavaexception %feature("except","0",throws="") #define %clearjavaexception %feature("except","",throws="") %pragma(java) jniclassclassmodifiers="public class" %pragma(java) moduleclassmodifiers="public class" /* Some ANSI C typemaps */ %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* String & length */ %typemap(jni) (char *STRING, size_t LENGTH) "jbyteArray" %typemap(jtype) (char *STRING, size_t LENGTH) "byte[]" %typemap(jstype) (char *STRING, size_t LENGTH) "byte[]" %typemap(javain) (char *STRING, size_t LENGTH) "$javainput" %typemap(freearg) (char *STRING, size_t LENGTH) "" %typemap(in) (char *STRING, size_t LENGTH) { if ($input) { $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0); $2 = (size_t) JCALL1(GetArrayLength, jenv, $input); } else { $1 = 0; $2 = 0; } } %typemap(argout) (char *STRING, size_t LENGTH) { if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); } %typemap(directorin, descriptor="[B") (char *STRING, size_t LENGTH) { jbyteArray jb = (jenv)->NewByteArray($2); (jenv)->SetByteArrayRegion(jb, 0, $2, (jbyte *)$1); $input = jb; } %typemap(directorargout) (char *STRING, size_t LENGTH) %{(jenv)->GetByteArrayRegion($input, 0, $2, (jbyte *)$1); %} %apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) } /* java keywords */ %include // Default enum handling %include swig-3.0.2/Lib/java/director.swg0000664000175000017500000003051112343605122016327 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Java proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION) #include #endif #include namespace Swig { /* Java object wrapper */ class JObjectWrapper { public: JObjectWrapper() : jthis_(NULL), weak_global_(true) { } ~JObjectWrapper() { jthis_ = NULL; weak_global_ = true; } bool set(JNIEnv *jenv, jobject jobj, bool mem_own, bool weak_global) { if (!jthis_) { weak_global_ = weak_global || !mem_own; // hold as weak global if explicitly requested or not owned if (jobj) jthis_ = weak_global_ ? jenv->NewWeakGlobalRef(jobj) : jenv->NewGlobalRef(jobj); #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> " << jthis_ << std::endl; #endif return true; } else { #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> already set" << std::endl; #endif return false; } } jobject get(JNIEnv *jenv) const { #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "JObjectWrapper::get("; if (jthis_) std::cout << jthis_; else std::cout << "null"; std::cout << ") -> return new local ref" << std::endl; #endif return (jthis_ ? jenv->NewLocalRef(jthis_) : jthis_); } void release(JNIEnv *jenv) { #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "JObjectWrapper::release(" << jthis_ << "): " << (weak_global_ ? "weak global ref" : "global ref") << std::endl; #endif if (jthis_) { if (weak_global_) { if (jenv->IsSameObject(jthis_, NULL) == JNI_FALSE) jenv->DeleteWeakGlobalRef((jweak)jthis_); } else jenv->DeleteGlobalRef(jthis_); } jthis_ = NULL; weak_global_ = true; } /* Only call peek if you know what you are doing wrt to weak/global references */ jobject peek() { return jthis_; } /* Java proxy releases ownership of C++ object, C++ object is now responsible for destruction (creates NewGlobalRef to pin Java proxy) */ void java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) { if (take_or_release) { /* Java takes ownership of C++ object's lifetime. */ if (!weak_global_) { jenv->DeleteGlobalRef(jthis_); jthis_ = jenv->NewWeakGlobalRef(jself); weak_global_ = true; } } else { /* Java releases ownership of C++ object's lifetime */ if (weak_global_) { jenv->DeleteWeakGlobalRef((jweak)jthis_); jthis_ = jenv->NewGlobalRef(jself); weak_global_ = false; } } } private: /* pointer to Java object */ jobject jthis_; /* Local or global reference flag */ bool weak_global_; }; /* director base class */ class Director { /* pointer to Java virtual machine */ JavaVM *swig_jvm_; protected: #if defined (_MSC_VER) && (_MSC_VER<1300) class JNIEnvWrapper; friend class JNIEnvWrapper; #endif /* Utility class for managing the JNI environment */ class JNIEnvWrapper { const Director *director_; JNIEnv *jenv_; int env_status; public: JNIEnvWrapper(const Director *director) : director_(director), jenv_(0), env_status(0) { #if defined(__ANDROID__) JNIEnv **jenv = &jenv_; #else void **jenv = (void **)&jenv_; #endif env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2); #if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON) // Attach a daemon thread to the JVM. Useful when the JVM should not wait for // the thread to exit upon shutdown. Only for jdk-1.4 and later. director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL); #else director_->swig_jvm_->AttachCurrentThread(jenv, NULL); #endif } ~JNIEnvWrapper() { #if !defined(SWIG_JAVA_NO_DETACH_CURRENT_THREAD) // Some JVMs, eg jdk-1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call. // However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak. if (env_status == JNI_EDETACHED) director_->swig_jvm_->DetachCurrentThread(); #endif } JNIEnv *getJNIEnv() const { return jenv_; } }; /* Java object wrapper */ JObjectWrapper swig_self_; /* Disconnect director from Java object */ void swig_disconnect_director_self(const char *disconn_method) { JNIEnvWrapper jnienv(this) ; JNIEnv *jenv = jnienv.getJNIEnv() ; jobject jobj = swig_self_.get(jenv); #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "Swig::Director::disconnect_director_self(" << jobj << ")" << std::endl; #endif if (jobj && jenv->IsSameObject(jobj, NULL) == JNI_FALSE) { jmethodID disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(jobj), disconn_method, "()V"); if (disconn_meth) { #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "Swig::Director::disconnect_director_self upcall to " << disconn_method << std::endl; #endif jenv->CallVoidMethod(jobj, disconn_meth); } } jenv->DeleteLocalRef(jobj); } public: Director(JNIEnv *jenv) : swig_jvm_((JavaVM *) NULL), swig_self_() { /* Acquire the Java VM pointer */ jenv->GetJavaVM(&swig_jvm_); } virtual ~Director() { JNIEnvWrapper jnienv(this) ; JNIEnv *jenv = jnienv.getJNIEnv() ; swig_self_.release(jenv); } bool swig_set_self(JNIEnv *jenv, jobject jself, bool mem_own, bool weak_global) { return swig_self_.set(jenv, jself, mem_own, weak_global); } jobject swig_get_self(JNIEnv *jenv) const { return swig_self_.get(jenv); } // Change C++ object's ownership, relative to Java void swig_java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) { swig_self_.java_change_ownership(jenv, jself, take_or_release); } }; // Utility classes and functions for exception handling. // Simple holder for a Java string during exception handling, providing access to a c-style string class JavaString { public: JavaString(JNIEnv *jenv, jstring jstr) : jenv_(jenv), jstr_(jstr), cstr_(0) { if (jenv_ && jstr_) cstr_ = (const char *) jenv_->GetStringUTFChars(jstr_, NULL); } ~JavaString() { if (jenv_ && jstr_ && cstr_) jenv_->ReleaseStringUTFChars(jstr_, cstr_); } const char *c_str(const char *null_string = "null JavaString") const { return cstr_ ? cstr_ : null_string; } private: // non-copyable JavaString(const JavaString &); JavaString &operator=(const JavaString &); JNIEnv *jenv_; jstring jstr_; const char *cstr_; }; // Helper class to extract the exception message from a Java throwable class JavaExceptionMessage { public: JavaExceptionMessage(JNIEnv *jenv, jthrowable throwable) : message_(jenv, exceptionMessageFromThrowable(jenv, throwable)) { } const char *message() const { return message_.c_str("Could not get exception message in JavaExceptionMessage"); } private: // non-copyable JavaExceptionMessage(const JavaExceptionMessage &); JavaExceptionMessage &operator=(const JavaExceptionMessage &); // Get exception message by calling Java method Throwable.getMessage() static jstring exceptionMessageFromThrowable(JNIEnv *jenv, jthrowable throwable) { jstring jmsg = NULL; if (jenv && throwable) { jenv->ExceptionClear(); // Cannot invoke methods with any pending exceptions jclass throwclz = jenv->GetObjectClass(throwable); if (throwclz) { // All Throwable classes have a getMessage() method, so call it to extract the exception message jmethodID getMessageMethodID = jenv->GetMethodID(throwclz, "getMessage", "()Ljava/lang/String;"); if (getMessageMethodID) jmsg = (jstring)jenv->CallObjectMethod(throwable, getMessageMethodID); } if (jmsg == NULL && jenv->ExceptionCheck()) jenv->ExceptionClear(); } return jmsg; } JavaString message_; }; // C++ Exception class for handling Java exceptions thrown during a director method Java upcall class DirectorException : public std::exception { public: // Construct exception from a Java throwable DirectorException(JNIEnv *jenv, jthrowable throwable) : classname_(0), msg_(0) { // Call Java method Object.getClass().getName() to obtain the throwable's class name (delimited by '/') if (throwable) { jclass throwclz = jenv->GetObjectClass(throwable); if (throwclz) { jclass clzclz = jenv->GetObjectClass(throwclz); if (clzclz) { jmethodID getNameMethodID = jenv->GetMethodID(clzclz, "getName", "()Ljava/lang/String;"); if (getNameMethodID) { jstring jstr_classname = (jstring)(jenv->CallObjectMethod(throwclz, getNameMethodID)); // Copy strings, since there is no guarantee that jenv will be active when handled if (jstr_classname) { JavaString jsclassname(jenv, jstr_classname); const char *classname = jsclassname.c_str(0); if (classname) classname_ = copypath(classname); } } } } } JavaExceptionMessage exceptionmsg(jenv, throwable); msg_ = copystr(exceptionmsg.message()); } // More general constructor for handling as a java.lang.RuntimeException DirectorException(const char *msg) : classname_(0), msg_(copystr(msg ? msg : "Unspecified DirectorException message")) { } ~DirectorException() throw() { delete[] classname_; delete[] msg_; } const char *what() const throw() { return msg_; } // Reconstruct and raise/throw the Java Exception that caused the DirectorException // Note that any error in the JNI exception handling results in a Java RuntimeException void raiseJavaException(JNIEnv *jenv) const { if (jenv) { jenv->ExceptionClear(); jmethodID ctorMethodID = 0; jclass throwableclass = 0; if (classname_) { throwableclass = jenv->FindClass(classname_); if (throwableclass) ctorMethodID = jenv->GetMethodID(throwableclass, "", "(Ljava/lang/String;)V"); } if (ctorMethodID) { jenv->ThrowNew(throwableclass, what()); } else { SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, what()); } } } private: static char *copypath(const char *srcmsg) { char *target = copystr(srcmsg); for (char *c=target; *c; ++c) { if ('.' == *c) *c = '/'; } return target; } static char *copystr(const char *srcmsg) { char *target = 0; if (srcmsg) { int msglen = strlen(srcmsg) + 1; target = new char[msglen]; strncpy(target, srcmsg, msglen); } return target; } const char *classname_; const char *msg_; }; // Helper method to determine if a Java throwable matches a particular Java class type bool ExceptionMatches(JNIEnv *jenv, jthrowable throwable, const char *classname) { bool matches = false; if (throwable && jenv && classname) { // Exceptions need to be cleared for correct behavior. // The caller of ExceptionMatches should restore pending exceptions if desired - // the caller already has the throwable. jenv->ExceptionClear(); jclass clz = jenv->FindClass(classname); if (clz) { jclass classclz = jenv->GetObjectClass(clz); jmethodID isInstanceMethodID = jenv->GetMethodID(classclz, "isInstance", "(Ljava/lang/Object;)Z"); if (isInstanceMethodID) { matches = jenv->CallBooleanMethod(clz, isInstanceMethodID, throwable) != 0; } } #if defined(DEBUG_DIRECTOR_EXCEPTION) if (jenv->ExceptionCheck()) { // Typically occurs when an invalid classname argument is passed resulting in a ClassNotFoundException JavaExceptionMessage exc(jenv, jenv->ExceptionOccurred()); std::cout << "Error: ExceptionMatches: class '" << classname << "' : " << exc.message() << std::endl; } #endif } return matches; } } swig-3.0.2/Lib/java/std_map.i0000664000175000017500000000444112343605122015576 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.2/Lib/java/javakw.swg0000664000175000017500000000236612343605122016006 0ustar williamwilliam#ifndef JAVA_JAVAKW_SWG_ #define JAVA_JAVAKW_SWG_ /* Warnings for Java keywords */ #define JAVAKW(x) %keywordwarn("'" `x` "' is a java keyword, renaming to '_"`x`"'",rename="_%s") `x` /* from http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html */ JAVAKW(abstract); JAVAKW(double); JAVAKW(int); JAVAKW(strictfp); JAVAKW(boolean); JAVAKW(else); JAVAKW(interface); JAVAKW(super); JAVAKW(break); JAVAKW(extends); JAVAKW(long); JAVAKW(switch); JAVAKW(byte); JAVAKW(final); JAVAKW(native); JAVAKW(synchronized); JAVAKW(case); JAVAKW(finally); JAVAKW(new); JAVAKW(this); JAVAKW(catch); JAVAKW(float); JAVAKW(package); JAVAKW(throw); JAVAKW(char); JAVAKW(for); JAVAKW(private); JAVAKW(throws); JAVAKW(class); JAVAKW(goto); JAVAKW(protected); JAVAKW(transient); JAVAKW(const); JAVAKW(if); JAVAKW(public); JAVAKW(try); JAVAKW(continue); JAVAKW(implements); JAVAKW(return); JAVAKW(void); JAVAKW(default); JAVAKW(import); JAVAKW(short); JAVAKW(volatile); JAVAKW(do); JAVAKW(instanceof); JAVAKW(static); JAVAKW(while); /* others bad names */ /* Note here that only *::clone() is bad, and *::clone(int) is ok */ %namewarn("321:clone() is a java bad method name") *::clone(); #undef JAVAKW #endif //JAVA_JAVAKW_SWG_ swig-3.0.2/Lib/java/std_pair.i0000664000175000017500000000131012343605122015744 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/java/typemaps.i0000664000175000017500000004122012343605122016005 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* INPUT typemaps -------------- These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is passed by value instead of reference. The following typemaps can be applied to turn a pointer or reference into a simple input value. That is, instead of passing a pointer or reference to an object, you would use a real value instead. bool *INPUT, bool &INPUT signed char *INPUT, signed char &INPUT unsigned char *INPUT, unsigned char &INPUT short *INPUT, short &INPUT unsigned short *INPUT, unsigned short &INPUT int *INPUT, int &INPUT unsigned int *INPUT, unsigned int &INPUT long *INPUT, long &INPUT unsigned long *INPUT, unsigned long &INPUT long long *INPUT, long long &INPUT unsigned long long *INPUT, unsigned long long &INPUT float *INPUT, float &INPUT double *INPUT, double &INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); In Java you could then use it like this: double answer = modulename.fadd(10.0, 20.0); There are no char *INPUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *INPUT {char *input}; void f(char *input); */ %define INPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JNIDESC) %typemap(jni) TYPE *INPUT, TYPE &INPUT "JNITYPE" %typemap(jtype) TYPE *INPUT, TYPE &INPUT "JTYPE" %typemap(jstype) TYPE *INPUT, TYPE &INPUT "JTYPE" %typemap(javain) TYPE *INPUT, TYPE &INPUT "$javainput" %typemap(in) TYPE *INPUT, TYPE &INPUT %{ $1 = ($1_ltype)&$input; %} %typemap(freearg) TYPE *INPUT, TYPE &INPUT "" %typemap(typecheck) TYPE *INPUT = TYPE; %typemap(typecheck) TYPE &INPUT = TYPE; %enddef INPUT_TYPEMAP(bool, jboolean, boolean, "Z"); INPUT_TYPEMAP(signed char, jbyte, byte, "B"); INPUT_TYPEMAP(unsigned char, jshort, short, "S"); INPUT_TYPEMAP(short, jshort, short, "S"); INPUT_TYPEMAP(unsigned short, jint, int, "I"); INPUT_TYPEMAP(int, jint, int, "I"); INPUT_TYPEMAP(unsigned int, jlong, long, "J"); INPUT_TYPEMAP(long, jint, int, "I"); INPUT_TYPEMAP(unsigned long, jlong, long, "J"); INPUT_TYPEMAP(long long, jlong, long, "J"); INPUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, "Ljava/math/BigInteger;"); INPUT_TYPEMAP(float, jfloat, float, "F"); INPUT_TYPEMAP(double, jdouble, double, "D"); #undef INPUT_TYPEMAP /* Convert from BigInteger using the toByteArray member function */ /* Overrides the typemap in the INPUT_TYPEMAP macro */ %typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) { jclass clazz; jmethodID mid; jbyteArray ba; jbyte* bae; jsize sz; int i; if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); return $null; } clazz = JCALL1(GetObjectClass, jenv, $input); mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); bae = JCALL2(GetByteArrayElements, jenv, ba, 0); sz = JCALL1(GetArrayLength, jenv, ba); temp = 0; for(i=0; i double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Java output of the function would be the function return value and the value in the single element array. In Java you would use it like this: double[] ptr = {0.0}; double fraction = modulename.modf(5.0,ptr); There are no char *OUTPUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *OUTPUT {char *output}; void f(char *output); */ /* Java BigInteger[] */ %typecheck(SWIG_TYPECHECK_INT128_ARRAY) SWIGBIGINTEGERARRAY "" %define OUTPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE) %typemap(jni) TYPE *OUTPUT, TYPE &OUTPUT %{JNITYPE##Array%} %typemap(jtype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]" %typemap(jstype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]" %typemap(javain) TYPE *OUTPUT, TYPE &OUTPUT "$javainput" %typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp) { if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } temp = ($*1_ltype)0; $1 = &temp; } %typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT "" %typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT { JNITYPE jvalue = (JNITYPE)temp$argnum; JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &jvalue); } %typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE; %typemap(typecheck) TYPE &OUTPUT = TYPECHECKTYPE; %enddef OUTPUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray); OUTPUT_TYPEMAP(signed char, jbyte, byte, Byte, "[Ljava/lang/Byte;", jbyteArray); OUTPUT_TYPEMAP(unsigned char, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); OUTPUT_TYPEMAP(short, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); OUTPUT_TYPEMAP(unsigned short, jint, int, Int, "[Ljava/lang/Integer;", jintArray); OUTPUT_TYPEMAP(int, jint, int, Int, "[Ljava/lang/Integer;", jintArray); OUTPUT_TYPEMAP(unsigned int, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); OUTPUT_TYPEMAP(long, jint, int, Int, "[Ljava/lang/Integer;", jintArray); OUTPUT_TYPEMAP(unsigned long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); OUTPUT_TYPEMAP(long long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); OUTPUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, NOTUSED, "[Ljava/lang/BigInteger;", SWIGBIGINTEGERARRAY); OUTPUT_TYPEMAP(float, jfloat, float, Float, "[Ljava/lang/Float;", jfloatArray); OUTPUT_TYPEMAP(double, jdouble, double, Double, "[Ljava/lang/Double;", jdoubleArray); #undef OUTPUT_TYPEMAP %typemap(in) bool *OUTPUT($*1_ltype temp), bool &OUTPUT($*1_ltype temp) { if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } temp = false; $1 = &temp; } /* Convert to BigInteger - byte array holds number in 2's complement big endian format */ /* Use first element in BigInteger array for output */ /* Overrides the typemap in the OUTPUT_TYPEMAP macro */ %typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { jbyteArray ba = JCALL1(NewByteArray, jenv, 9); jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "", "([B)V"); jobject bigint; int i; bae[0] = 0; for(i=1; i<9; i++ ) { bae[i] = (jbyte)(temp$argnum>>8*(8-i)); } JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); bigint = JCALL3(NewObject, jenv, clazz, mid, ba); JCALL3(SetObjectArrayElement, jenv, $input, 0, bigint); } /* INOUT typemaps -------------- Mappings for a parameter that is both an input and an output parameter The following typemaps can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" typemaps described earlier. Output values are returned as an element in a Java array. bool *INOUT, bool &INOUT signed char *INOUT, signed char &INOUT unsigned char *INOUT, unsigned char &INOUT short *INOUT, short &INOUT unsigned short *INOUT, unsigned short &INOUT int *INOUT, int &INOUT unsigned int *INOUT, unsigned int &INOUT long *INOUT, long &INOUT unsigned long *INOUT, unsigned long &INOUT long long *INOUT, long long &INOUT unsigned long long *INOUT, unsigned long long &INOUT float *INOUT, float &INOUT double *INOUT, double &INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); This works similarly to C in that the mapping directly modifies the input value - the input must be an array with a minimum of one element. The element in the array is the input and the output is the element in the array. double x[] = {5.0}; neg(x); The implementation of the OUTPUT and INOUT typemaps is different to other languages in that other languages will return the output value as part of the function return value. This difference is due to Java being a typed language. There are no char *INOUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *INOUT {char *inout}; void f(char *inout); */ %define INOUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE) %typemap(jni) TYPE *INOUT, TYPE &INOUT %{JNITYPE##Array%} %typemap(jtype) TYPE *INOUT, TYPE &INOUT "JTYPE[]" %typemap(jstype) TYPE *INOUT, TYPE &INOUT "JTYPE[]" %typemap(javain) TYPE *INOUT, TYPE &INOUT "$javainput" %typemap(in) TYPE *INOUT, TYPE &INOUT { if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } $1 = ($1_ltype) JCALL2(Get##JAVATYPE##ArrayElements, jenv, $input, 0); } %typemap(freearg) TYPE *INOUT, TYPE &INOUT "" %typemap(argout) TYPE *INOUT, TYPE &INOUT { JCALL3(Release##JAVATYPE##ArrayElements, jenv, $input, (JNITYPE *)$1, 0); } %typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE; %typemap(typecheck) TYPE &INOUT = TYPECHECKTYPE; %enddef INOUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray); INOUT_TYPEMAP(signed char, jbyte, byte, Byte, "[Ljava/lang/Byte;", jbyteArray); INOUT_TYPEMAP(unsigned char, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); INOUT_TYPEMAP(short, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); INOUT_TYPEMAP(unsigned short, jint, int, Int, "[Ljava/lang/Integer;", jintArray); INOUT_TYPEMAP(int, jint, int, Int, "[Ljava/lang/Integer;", jintArray); INOUT_TYPEMAP(unsigned int, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); INOUT_TYPEMAP(long, jint, int, Int, "[Ljava/lang/Integer;", jintArray); INOUT_TYPEMAP(unsigned long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); INOUT_TYPEMAP(long long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); INOUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, NOTUSED, "[Ljava.math.BigInteger;", SWIGBIGINTEGERARRAY); INOUT_TYPEMAP(float, jfloat, float, Float, "[Ljava/lang/Float;", jfloatArray); INOUT_TYPEMAP(double, jdouble, double, Double, "[Ljava/lang/Double;", jdoubleArray); #undef INOUT_TYPEMAP /* Override typemaps in the INOUT_TYPEMAP macro for booleans to fix casts as a jboolean isn't always the same size as a bool */ %typemap(in) bool *INOUT (bool btemp, jboolean *jbtemp), bool &INOUT (bool btemp, jboolean *jbtemp) { if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } jbtemp = JCALL2(GetBooleanArrayElements, jenv, $input, 0); btemp = (*jbtemp) ? true : false; $1 = &btemp; } %typemap(argout) bool *INOUT, bool &INOUT { *jbtemp$argnum = btemp$argnum ? (jboolean)1 : (jboolean)0; JCALL3(ReleaseBooleanArrayElements, jenv, $input , (jboolean *)jbtemp$argnum, 0); } /* Override the typemap in the INOUT_TYPEMAP macro for unsigned long long */ %typemap(in) unsigned long long *INOUT ($*1_ltype temp), unsigned long long &INOUT ($*1_ltype temp) { jobject bigint; jclass clazz; jmethodID mid; jbyteArray ba; jbyte* bae; jsize sz; int i; if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } bigint = JCALL2(GetObjectArrayElement, jenv, $input, 0); if (!bigint) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array element null"); return $null; } clazz = JCALL1(GetObjectClass, jenv, bigint); mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, bigint, mid); bae = JCALL2(GetByteArrayElements, jenv, ba, 0); sz = JCALL1(GetArrayLength, jenv, ba); temp = 0; for(i=0; i * %inline %{ * short FiddleSticks[3]; * %} * * Use from Java like this: * * short[] fs = new short[] {10, 11, 12}; * example.setFiddleSticks(fs); * fs = example.getFiddleSticks(); * ----------------------------------------------------------------------------- */ /* Primitive array support is a combination of SWIG macros and functions in order to reduce * code bloat and aid maintainability. The SWIG preprocessor expands the macros into functions * for inclusion in the generated code. */ /* Array support functions declarations macro */ %define JAVA_ARRAYS_DECL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME) %{ static int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input); static void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input); static JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize sz); %} %enddef /* Array support functions macro */ %define JAVA_ARRAYS_IMPL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME) %{ /* CTYPE[] support */ static int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input) { int i; jsize sz; if (!input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); return 0; } sz = JCALL1(GetArrayLength, jenv, input); *jarr = JCALL2(Get##JAVATYPE##ArrayElements, jenv, input, 0); if (!*jarr) return 0; %} #ifdef __cplusplus %{ *carr = new CTYPE[sz]; %} #else %{ *carr = (CTYPE*) calloc(sz, sizeof(CTYPE)); %} #endif %{ if (!*carr) { SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); return 0; } for (i=0; i // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in) CONST TYPE ($&1_type argp = 0) %{ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in) CONST TYPE & %{ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = (TYPE *)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ($&1_type argp) %{ argp = *($&1_ltype*)&$input; if (argp) $1 = *argp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) %{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ *($&1_ltype)&$result = *$1 ? new $*1_ltype(*$1) : 0; %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) %{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ *($&1_ltype)&$result = ($1 && *$1) ? new $*1_ltype(*$1) : 0; if ($owner) delete $1; %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0) %{ temp = $input ? *($1_ltype)&$input : &tempnull; $1 = &temp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "jlong" %typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "long" %typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)" %typemap(javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)" %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) CONST TYPE { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE & { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) TYPE *CONST& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } // Base proxy classes %typemap(javabody) TYPE %{ private long swigCPtr; private boolean swigCMemOwn; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} // Derived proxy classes %typemap(javabody_derived) TYPE %{ private long swigCPtr; private boolean swigCMemOwnDerived; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true); swigCMemOwnDerived = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; $jnicall; } swigCPtr = 0; } } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { if (swigCPtr != 0) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $jnicall; } swigCPtr = 0; } super.delete(); } %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.2/Lib/java/enumtypeunsafe.swg0000664000175000017500000000524312343605122017570 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enumtypeunsafe.swg * * Include this file in order for C/C++ enums to be wrapped by integers values. * Each enum has an equivalent class named after the enum and the enum items are * wrapped by constant integers within this class. The enum items are not * typesafe as they are all integers. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(jni) const enum SWIGTYPE & "jint" %typemap(jtype) const enum SWIGTYPE & "int" %typemap(jstype) const enum SWIGTYPE & "int" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1;" %typemap(javadirectorin) const enum SWIGTYPE & "$jniinput" %typemap(javadirectorout) const enum SWIGTYPE & "$javacall" %typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" %typemap(throws) const enum SWIGTYPE & %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) const enum SWIGTYPE & "$javainput" %typemap(javaout) const enum SWIGTYPE & { return $jnicall; } // enum SWIGTYPE typemaps %typemap(jni) enum SWIGTYPE "jint" %typemap(jtype) enum SWIGTYPE "int" %typemap(jstype) enum SWIGTYPE "int" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;" %typemap(javadirectorin) enum SWIGTYPE "$jniinput" %typemap(javadirectorout) enum SWIGTYPE "$javacall" %typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" %typemap(throws) enum SWIGTYPE %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) enum SWIGTYPE "$javainput" %typemap(javaout) enum SWIGTYPE { return $jnicall; } // '$static' will be replaced with either 'static' or nothing depending on whether the enum is an inner Java class or not %typemap(javaclassmodifiers) enum SWIGTYPE "public final $static class" %typemap(javabase) enum SWIGTYPE "" %typemap(javacode) enum SWIGTYPE "" %typemap(javaimports) enum SWIGTYPE "" %typemap(javainterfaces) enum SWIGTYPE "" %typemap(javabody) enum SWIGTYPE "" %javaenum(typeunsafe); swig-3.0.2/Lib/java/std_common.i0000664000175000017500000000014612343605122016307 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.2/Lib/java/various.i0000664000175000017500000001047112343605122015637 0ustar williamwilliam/* ----------------------------------------------------------------------------- * various.i * * SWIG Typemap library for Java. * Various useful typemaps. * ----------------------------------------------------------------------------- */ /* * char **STRING_ARRAY typemaps. * These typemaps are for C String arrays which are NULL terminated. * char *values[] = { "one", "two", "three", NULL }; // note NULL * char ** is mapped to a Java String[]. * * Example usage wrapping: * %apply char **STRING_ARRAY { char **input }; * char ** foo(char **input); * * Java usage: * String numbers[] = { "one", "two", "three" }; * String[] ret = modulename.foo( numbers }; */ %typemap(jni) char **STRING_ARRAY "jobjectArray" %typemap(jtype) char **STRING_ARRAY "String[]" %typemap(jstype) char **STRING_ARRAY "String[]" %typemap(in) char **STRING_ARRAY (jint size) { int i = 0; if ($input) { size = JCALL1(GetArrayLength, jenv, $input); #ifdef __cplusplus $1 = new char*[size+1]; #else $1 = (char **)calloc(size+1, sizeof(char *)); #endif for (i = 0; i= 0 && swigValues[swigValue].swigValue == swigValue) return swigValues[swigValue]; for ($javaclassname swigEnum : swigValues) if (swigEnum.swigValue == swigValue) return swigEnum; throw new IllegalArgumentException("No enum " + $javaclassname.class + " with value " + swigValue); } @SuppressWarnings("unused") private $javaclassname() { this.swigValue = SwigNext.next++; } @SuppressWarnings("unused") private $javaclassname(int swigValue) { this.swigValue = swigValue; SwigNext.next = swigValue+1; } @SuppressWarnings("unused") private $javaclassname($javaclassname swigEnum) { this.swigValue = swigEnum.swigValue; SwigNext.next = this.swigValue+1; } private final int swigValue; private static class SwigNext { private static int next = 0; } %} %javaenum(proper); swig-3.0.2/Lib/java/javahead.swg0000664000175000017500000001012512343605122016256 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javahead.swg * * Java support code * ----------------------------------------------------------------------------- */ /* JNI function calls require different calling conventions for C and C++. These JCALL macros are used so * that the same typemaps can be used for generating code for both C and C++. The SWIG preprocessor can expand * the macros thereby generating the correct calling convention. It is thus essential that all typemaps that * use the macros are not within %{ %} brackets as they won't be run through the SWIG preprocessor. */ #ifdef __cplusplus # define JCALL0(func, jenv) jenv->func() # define JCALL1(func, jenv, ar1) jenv->func(ar1) # define JCALL2(func, jenv, ar1, ar2) jenv->func(ar1, ar2) # define JCALL3(func, jenv, ar1, ar2, ar3) jenv->func(ar1, ar2, ar3) # define JCALL4(func, jenv, ar1, ar2, ar3, ar4) jenv->func(ar1, ar2, ar3, ar4) # define JCALL5(func, jenv, ar1, ar2, ar3, ar4, ar5) jenv->func(ar1, ar2, ar3, ar4, ar5) # define JCALL6(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6) jenv->func(ar1, ar2, ar3, ar4, ar5, ar6) # define JCALL7(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) jenv->func(ar1, ar2, ar3, ar4, ar5, ar6, ar7) #else # define JCALL0(func, jenv) (*jenv)->func(jenv) # define JCALL1(func, jenv, ar1) (*jenv)->func(jenv, ar1) # define JCALL2(func, jenv, ar1, ar2) (*jenv)->func(jenv, ar1, ar2) # define JCALL3(func, jenv, ar1, ar2, ar3) (*jenv)->func(jenv, ar1, ar2, ar3) # define JCALL4(func, jenv, ar1, ar2, ar3, ar4) (*jenv)->func(jenv, ar1, ar2, ar3, ar4) # define JCALL5(func, jenv, ar1, ar2, ar3, ar4, ar5) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5) # define JCALL6(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5, ar6) # define JCALL7(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) #endif %insert(runtime) %{ /* Fix for jlong on some versions of gcc on Windows */ #if defined(__GNUC__) && !defined(__INTEL_COMPILER) typedef long long __int64; #endif /* Fix for jlong on 64-bit x86 Solaris */ #if defined(__x86_64) # ifdef _LP64 # undef _LP64 # endif #endif #include #include #include %} %insert(runtime) %{ /* Support for throwing Java exceptions */ typedef enum { SWIG_JavaOutOfMemoryError = 1, SWIG_JavaIOException, SWIG_JavaRuntimeException, SWIG_JavaIndexOutOfBoundsException, SWIG_JavaArithmeticException, SWIG_JavaIllegalArgumentException, SWIG_JavaNullPointerException, SWIG_JavaDirectorPureVirtual, SWIG_JavaUnknownError } SWIG_JavaExceptionCodes; typedef struct { SWIG_JavaExceptionCodes code; const char *java_exception; } SWIG_JavaExceptions_t; %} %insert(runtime) { static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { jclass excep; static const SWIG_JavaExceptions_t java_exceptions[] = { { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, { SWIG_JavaIOException, "java/io/IOException" }, { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, { SWIG_JavaUnknownError, "java/lang/UnknownError" }, { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; const SWIG_JavaExceptions_t *except_ptr = java_exceptions; while (except_ptr->code != code && except_ptr->code) except_ptr++; JCALL0(ExceptionClear, jenv); excep = JCALL1(FindClass, jenv, except_ptr->java_exception); if (excep) JCALL2(ThrowNew, jenv, excep, msg); } } %insert(runtime) %{ /* Contract support */ #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else %} swig-3.0.2/Lib/java/std_shared_ptr.i0000664000175000017500000000010412343605122017144 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.2/Lib/java/std_auto_ptr.i0000664000175000017500000000151612343605122016656 0ustar williamwilliam/* The typemaps here allow to handle functions returning std::auto_ptr<>, which is the most common use of this type. If you have functions taking it as parameter, these typemaps can't be used for them and you need to do something else (e.g. use shared_ptr<> which SWIG supports fully). */ %define %auto_ptr(TYPE) %typemap (jni) std::auto_ptr "jlong" %typemap (jtype) std::auto_ptr "long" %typemap (jstype) std::auto_ptr "$typemap(jstype, TYPE)" %typemap (out) std::auto_ptr %{ jlong lpp = 0; *(TYPE**) &lpp = $1.release(); $result = lpp; %} %typemap(javaout) std::auto_ptr { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %template() std::auto_ptr; %enddef namespace std { template class auto_ptr {}; } swig-3.0.2/Lib/java/enumtypesafe.swg0000664000175000017500000001103112343605122017215 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enumtypesafe.swg * * Include this file in order for C/C++ enums to be wrapped by the so called * typesafe enum pattern. Each enum has an equivalent Java class named after the * enum and each enum item is a static instance of this class. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(jni) const enum SWIGTYPE & "jint" %typemap(jtype) const enum SWIGTYPE & "int" %typemap(jstype) const enum SWIGTYPE & "$*javaclassname" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin, descriptor="L$packagepath/$*javaclassname;") const enum SWIGTYPE & "$input = (jint)$1;" %typemap(javadirectorin) const enum SWIGTYPE & "$*javaclassname.swigToEnum($jniinput)" %typemap(javadirectorout) const enum SWIGTYPE & "($javacall).swigValue()" %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" %typemap(throws) const enum SWIGTYPE & %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) const enum SWIGTYPE & "$javainput.swigValue()" %typemap(javaout) const enum SWIGTYPE & { return $*javaclassname.swigToEnum($jnicall); } // enum SWIGTYPE typemaps %typemap(jni) enum SWIGTYPE "jint" %typemap(jtype) enum SWIGTYPE "int" %typemap(jstype) enum SWIGTYPE "$javaclassname" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin, descriptor="L$packagepath/$javaclassname;") enum SWIGTYPE "$input = (jint) $1;" %typemap(javadirectorin) enum SWIGTYPE "$javaclassname.swigToEnum($jniinput)" %typemap(javadirectorout) enum SWIGTYPE "($javacall).swigValue()" %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" %typemap(throws) enum SWIGTYPE %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) enum SWIGTYPE "$javainput.swigValue()" %typemap(javaout) enum SWIGTYPE { return $javaclassname.swigToEnum($jnicall); } // '$static' will be replaced with either 'static' or nothing depending on whether the enum is an inner Java class or not %typemap(javaclassmodifiers) enum SWIGTYPE "public final $static class" %typemap(javabase) enum SWIGTYPE "" %typemap(javacode) enum SWIGTYPE "" %typemap(javaimports) enum SWIGTYPE "" %typemap(javainterfaces) enum SWIGTYPE "" /* * The swigToEnum method is used to find the Java enum from a C++ enum integer value. The default one here takes * advantage of the fact that most enums do not have initial values specified, so the lookup is fast. If initial * values are specified then a lengthy linear search through all possible enums might occur. Specific typemaps could be * written to possibly optimise this lookup by taking advantage of characteristics peculiar to the targeted enum. * The special variable, $enumvalues, is replaced with a comma separated list of all the enum values. */ %typemap(javabody) enum SWIGTYPE %{ public final int swigValue() { return swigValue; } public String toString() { return swigName; } public static $javaclassname swigToEnum(int swigValue) { if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) return swigValues[swigValue]; for (int i = 0; i < swigValues.length; i++) if (swigValues[i].swigValue == swigValue) return swigValues[i]; throw new IllegalArgumentException("No enum " + $javaclassname.class + " with value " + swigValue); } private $javaclassname(String swigName) { this.swigName = swigName; this.swigValue = swigNext++; } private $javaclassname(String swigName, int swigValue) { this.swigName = swigName; this.swigValue = swigValue; swigNext = swigValue+1; } private $javaclassname(String swigName, $javaclassname swigEnum) { this.swigName = swigName; this.swigValue = swigEnum.swigValue; swigNext = this.swigValue+1; } private static $javaclassname[] swigValues = { $enumvalues }; private static int swigNext = 0; private final int swigValue; private final String swigName; %} %javaenum(typesafe); swig-3.0.2/Lib/java/std_vector.i0000664000175000017500000000511112343605122016316 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %include %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i %} namespace std { %naturalvar string; class string; // string %typemap(jni) string "jstring" %typemap(jtype) string "String" %typemap(jstype) string "String" %typemap(javadirectorin) string "$jniinput" %typemap(javadirectorout) string "$javacall" %typemap(in) string %{ if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); return $null; } const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); if (!$1_pstr) return $null; $1.assign($1_pstr); jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorout) string %{ if(!$input) { if (!jenv->ExceptionCheck()) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); } return $null; } const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); if (!$1_pstr) return $null; $result.assign($1_pstr); jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") string %{ $input = jenv->NewStringUTF($1.c_str()); %} %typemap(out) string %{ $result = jenv->NewStringUTF($1.c_str()); %} %typemap(javain) string "$javainput" %typemap(javaout) string { return $jnicall; } %typemap(typecheck) string = char *; %typemap(throws) string %{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); return $null; %} // const string & %typemap(jni) const string & "jstring" %typemap(jtype) const string & "String" %typemap(jstype) const string & "String" %typemap(javadirectorin) const string & "$jniinput" %typemap(javadirectorout) const string & "$javacall" %typemap(in) const string & %{ if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); return $null; } const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); if (!$1_pstr) return $null; $*1_ltype $1_str($1_pstr); $1 = &$1_str; jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & %{ if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); return $null; } const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); if (!$1_pstr) return $null; /* possible thread/reentrant code problem */ static $*1_ltype $1_str; $1_str = $1_pstr; $result = &$1_str; jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") const string & %{ $input = jenv->NewStringUTF($1.c_str()); %} %typemap(out) const string & %{ $result = jenv->NewStringUTF($1->c_str()); %} %typemap(javain) const string & "$javainput" %typemap(javaout) const string & { return $jnicall; } %typemap(typecheck) const string & = char *; %typemap(throws) const string & %{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); return $null; %} } swig-3.0.2/Lib/java/std_except.i0000664000175000017500000000360412343605122016311 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. * These typemaps are used when methods are declared with an STL exception specification, such as * size_t at() const throw (std::out_of_range); * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %ignore exception; struct exception {}; } %typemap(throws) std::bad_exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::domain_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::invalid_argument "SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, $1.what());\n return $null;" %typemap(throws) std::length_error "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;" %typemap(throws) std::logic_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::out_of_range "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;" %typemap(throws) std::overflow_error "SWIG_JavaThrowException(jenv, SWIG_JavaArithmeticException, $1.what());\n return $null;" %typemap(throws) std::range_error "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;" %typemap(throws) std::runtime_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::underflow_error "SWIG_JavaThrowException(jenv, SWIG_JavaArithmeticException, $1.what());\n return $null;" swig-3.0.2/Lib/java/stl.i0000664000175000017500000000044312343605122014747 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/java/std_deque.i0000664000175000017500000000003412343605122016116 0ustar williamwilliam%include swig-3.0.2/Lib/java/std_wstring.i0000664000175000017500000001150512343605122016515 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_wstring.i * * Typemaps for std::wstring and const std::wstring& * * These are mapped to a Java String and are passed around by value. * Warning: Unicode / multibyte characters are handled differently on different * OSs so the std::wstring typemaps may not always work as intended. * * To use non-const std::wstring references use the following %apply. Note * that they are passed by value. * %apply const std::wstring & {std::wstring &}; * ----------------------------------------------------------------------------- */ namespace std { %naturalvar wstring; class wstring; // wstring %typemap(jni) wstring "jstring" %typemap(jtype) wstring "String" %typemap(jstype) wstring "String" %typemap(javadirectorin) wstring "$jniinput" %typemap(javadirectorout) wstring "$javacall" %typemap(in) wstring %{if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); return $null; } const jchar *$1_pstr = jenv->GetStringChars($input, 0); if (!$1_pstr) return $null; jsize $1_len = jenv->GetStringLength($input); if ($1_len) { $1.reserve($1_len); for (jsize i = 0; i < $1_len; ++i) { $1.push_back((wchar_t)$1_pstr[i]); } } jenv->ReleaseStringChars($input, $1_pstr); %} %typemap(directorout) wstring %{if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); return $null; } const jchar *$1_pstr = jenv->GetStringChars($input, 0); if (!$1_pstr) return $null; jsize $1_len = jenv->GetStringLength($input); if ($1_len) { $result.reserve($1_len); for (jsize i = 0; i < $1_len; ++i) { $result.push_back((wchar_t)$1_pstr[i]); } } jenv->ReleaseStringChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") wstring { jsize $1_len = $1.length(); jchar *conv_buf = new jchar[$1_len]; for (jsize i = 0; i < $1_len; ++i) { conv_buf[i] = (jchar)$1[i]; } $input = jenv->NewString(conv_buf, $1_len); delete [] conv_buf; } %typemap(out) wstring %{jsize $1_len = $1.length(); jchar *conv_buf = new jchar[$1_len]; for (jsize i = 0; i < $1_len; ++i) { conv_buf[i] = (jchar)$1[i]; } $result = jenv->NewString(conv_buf, $1_len); delete [] conv_buf; %} %typemap(javain) wstring "$javainput" %typemap(javaout) wstring { return $jnicall; } //%typemap(typecheck) wstring = wchar_t *; %typemap(throws) wstring %{ std::string message($1.begin(), $1.end()); SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, message.c_str()); return $null; %} // const wstring & %typemap(jni) const wstring & "jstring" %typemap(jtype) const wstring & "String" %typemap(jstype) const wstring & "String" %typemap(javadirectorin) const wstring & "$jniinput" %typemap(javadirectorout) const wstring & "$javacall" %typemap(in) const wstring & %{if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); return $null; } const jchar *$1_pstr = jenv->GetStringChars($input, 0); if (!$1_pstr) return $null; jsize $1_len = jenv->GetStringLength($input); std::wstring $1_str; if ($1_len) { $1_str.reserve($1_len); for (jsize i = 0; i < $1_len; ++i) { $1_str.push_back((wchar_t)$1_pstr[i]); } } $1 = &$1_str; jenv->ReleaseStringChars($input, $1_pstr); %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const wstring & %{if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); return $null; } const jchar *$1_pstr = jenv->GetStringChars($input, 0); if (!$1_pstr) return $null; jsize $1_len = jenv->GetStringLength($input); /* possible thread/reentrant code problem */ static std::wstring $1_str; if ($1_len) { $1_str.reserve($1_len); for (jsize i = 0; i < $1_len; ++i) { $1_str.push_back((wchar_t)$1_pstr[i]); } } $result = &$1_str; jenv->ReleaseStringChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") const wstring & { jsize $1_len = $1.length(); jchar *conv_buf = new jchar[$1_len]; for (jsize i = 0; i < $1_len; ++i) { conv_buf[i] = (jchar)($1)[i]; } $input = jenv->NewString(conv_buf, $1_len); delete [] conv_buf; } %typemap(out) const wstring & %{jsize $1_len = $1->length(); jchar *conv_buf = new jchar[$1_len]; for (jsize i = 0; i < $1_len; ++i) { conv_buf[i] = (jchar)(*$1)[i]; } $result = jenv->NewString(conv_buf, $1_len); delete [] conv_buf; %} %typemap(javain) const wstring & "$javainput" %typemap(javaout) const wstring & { return $jnicall; } //%typemap(typecheck) const wstring & = wchar_t *; %typemap(throws) const wstring & %{ std::string message($1.begin(), $1.end()); SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, message.c_str()); return $null; %} } swig-3.0.2/Lib/java/boost_intrusive_ptr.i0000664000175000017500000004727412343605122020305 0ustar williamwilliam// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the // visibility of the constructor and getCPtr method if desired to public if using multiple modules. #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP #define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(protected, protected, CONST, TYPE) #endif #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS #define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(protected, protected, CONST, TYPE) #endif %include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE "(void)arg1; delete smartarg1;" // Typemap customisations... %typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain value argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{ //plain value(out) $1_ltype* resultp = new $1_ltype(($1_ltype &)$1); intrusive_ptr_add_ref(resultp); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >()); %} %typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{ //plain pointer(out) #if ($owner) if ($1) { intrusive_ptr_add_ref($1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} %typemap(in) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain reference $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if(!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{ //plain reference(out) #if ($owner) if ($1) { intrusive_ptr_add_ref($1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} %typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer by reference temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{ // plain pointer by reference(out) #if ($owner) if (*$1) { intrusive_ptr_add_ref(*$1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0); #endif %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by value smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if (smartarg) { $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ if ($1) { intrusive_ptr_add_ref(result.get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by reference if ( $input ) { smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ delete &($1); if ($self) { SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); $1 = *temp; } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ if (*$1) { intrusive_ptr_add_ref($1->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer if ( $input ) { smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ delete $1; if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ if ($1 && *$1) { intrusive_ptr_add_ref($1->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } if ($owner) delete $1; %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer reference smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if ($input) { temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } tempp = &temp; $1 = &tempp; %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ if ($self) $1 = *$input; %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ if (*$1 && **$1) { intrusive_ptr_add_ref((*$1)->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "jlong" %typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "long" %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)" %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)" %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) CONST TYPE { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE & { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) TYPE *CONST& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } // Base proxy classes %typemap(javabody) TYPE %{ private long swigCPtr; private boolean swigCMemOwnBase; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} // Derived proxy classes %typemap(javabody_derived) TYPE %{ private long swigCPtr; private boolean swigCMemOwnDerived; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true); swigCMemOwnDerived = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { if(swigCPtr != 0 && swigCMemOwnBase) { swigCMemOwnBase = false; $jnicall; } swigCPtr = 0; } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { if(swigCPtr != 0 && swigCMemOwnDerived) { swigCMemOwnDerived = false; $jnicall; } swigCPtr = 0; super.delete(); } // CONST version needed ???? also for C# %typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" %typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; %enddef ///////////////////////////////////////////////////////////////////// %include %define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods %feature("unref") TYPE "(void)arg1; delete smartarg1;" // plain value %typemap(in) CONST TYPE ($&1_type argp = 0) %{ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in) CONST TYPE & %{ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "jlong" %typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "long" %typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE)" %typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE).getCPtr($javainput)" %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) CONST TYPE { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE & { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) TYPE *CONST& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } // Base proxy classes %typemap(javabody) TYPE %{ private long swigCPtr; private boolean swigCMemOwnBase; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} // Derived proxy classes %typemap(javabody_derived) TYPE %{ private long swigCPtr; private boolean swigCMemOwnDerived; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true); swigCMemOwnDerived = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { if (swigCPtr != 0) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $jnicall; } swigCPtr = 0; } } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { if (swigCPtr != 0) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $jnicall; } swigCPtr = 0; } super.delete(); } // CONST version needed ???? also for C# %typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" %typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.2/Lib/stl.i0000664000175000017500000000037112343605122014026 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ #warning "stl.i not implemented for this target" #define SWIG_STL_UNIMPL swig-3.0.2/Lib/cpointer.i0000664000175000017500000000673712343605122015063 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cpointer.i * * SWIG library file containing macros that can be used to manipulate simple * pointer objects. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %pointer_class(type,name) * * Places a simple proxy around a simple type like 'int', 'float', or whatever. * The proxy provides this interface: * * class type { * public: * type(); * ~type(); * type value(); * void assign(type value); * }; * * Example: * * %pointer_class(int, intp); * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = intp() * >>> a.assign(10) * >>> a.value() * 10 * >>> b = intp() * >>> b.assign(20) * >>> print add(a,b) * 30 * * As a general rule, this macro should not be used on class/structures that * are already defined in the interface. * ----------------------------------------------------------------------------- */ %define %pointer_class(TYPE, NAME) %{ typedef TYPE NAME; %} typedef struct { } NAME; %extend NAME { #ifdef __cplusplus NAME() { return new TYPE(); } ~NAME() { if ($self) delete $self; } #else NAME() { return (TYPE *) calloc(1,sizeof(TYPE)); } ~NAME() { if ($self) free($self); } #endif } %extend NAME { void assign(TYPE value) { *$self = value; } TYPE value() { return *$self; } TYPE * cast() { return $self; } static NAME * frompointer(TYPE *t) { return (NAME *) t; } } %types(NAME = TYPE); %enddef /* ----------------------------------------------------------------------------- * %pointer_functions(type,name) * * Create functions for allocating/deallocating pointers. This can be used * if you don't want to create a proxy class or if the pointer is complex. * * %pointer_functions(int, intp) * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = copy_intp(10) * >>> intp_value(a) * 10 * >>> b = new_intp() * >>> intp_assign(b,20) * >>> print add(a,b) * 30 * >>> delete_intp(a) * >>> delete_intp(b) * * ----------------------------------------------------------------------------- */ %define %pointer_functions(TYPE,NAME) %{ static TYPE *new_##NAME() { %} #ifdef __cplusplus %{ return new TYPE(); %} #else %{ return (TYPE *) calloc(1,sizeof(TYPE)); %} #endif %{} static TYPE *copy_##NAME(TYPE value) { %} #ifdef __cplusplus %{ return new TYPE(value); %} #else %{ TYPE *obj = (TYPE *) calloc(1,sizeof(TYPE)); *obj = value; return obj; %} #endif %{} static void delete_##NAME(TYPE *obj) { %} #ifdef __cplusplus %{ if (obj) delete obj; %} #else %{ if (obj) free(obj); %} #endif %{} static void NAME ##_assign(TYPE *obj, TYPE value) { *obj = value; } static TYPE NAME ##_value(TYPE *obj) { return *obj; } %} TYPE *new_##NAME(); TYPE *copy_##NAME(TYPE value); void delete_##NAME(TYPE *obj); void NAME##_assign(TYPE *obj, TYPE value); TYPE NAME##_value(TYPE *obj); %enddef /* ----------------------------------------------------------------------------- * %pointer_cast(type1,type2,name) * * Generates a pointer casting function. * ----------------------------------------------------------------------------- */ %define %pointer_cast(TYPE1,TYPE2,NAME) %inline %{ TYPE2 NAME(TYPE1 x) { return (TYPE2) x; } %} %enddef swig-3.0.2/Lib/ruby/0000775000175000017500000000000012343605122014032 5ustar williamwilliamswig-3.0.2/Lib/ruby/rubystdautodoc.swg0000664000175000017500000000343312343605122017632 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubystdautodoc.swg * * This file contains autodocs for standard STL functions. * ----------------------------------------------------------------------------- */ // // For STL autodocumentation // AUTODOC(c_str, "Convert class to a String representation"); AUTODOC(begin, "Return an iterator to the beginning of the $class"); AUTODOC(end, "Return an iterator to past the end of the $class"); AUTODOC(rbegin, "Return a reverse iterator to the beginning (the end) of the $class"); AUTODOC(rend, "Return a reverse iterator to past the end (past the beginning) of the $class"); AUTODOC(length, "Size or Length of the $class"); AUTODOC(replace, "Replace all or a portion of the $class"); AUTODOC(resize, "Resize the size of the $class"); AUTODOC(capacity, "Reserved capacity of the $class"); AUTODOC(reserve, "Reserve memory in the $class for a number of elements"); AUTODOC(erase, "Delete a portion of the $class"); AUTODOC(max_size, "Maximum size of elements allowed in the $class"); AUTODOC(iterator, "Return an iterator to the $class"); AUTODOC(empty, "Check if the $class is empty or not"); AUTODOC(rfind, "Find an element in reverse usually starting from the end of the $class"); AUTODOC(assign, "Assign a new $class or portion of it"); AUTODOC(front, "Return the first element in $class"); AUTODOC(back, "Return the last element in $class"); AUTODOC(second, "Return the second element in $class"); AUTODOC(push_front, "Add an element at the beginning of the $class"); AUTODOC(push_back, "Add an element at the end of the $class"); AUTODOC(pop_front, "Remove and return element at the beginning of the $class"); AUTODOC(pop_back, "Remove and return an element at the end of the $class"); AUTODOC(clear, "Clear $class contents"); swig-3.0.2/Lib/ruby/std_vectora.i0000664000175000017500000000166612343605122016532 0ustar williamwilliam/* Vectors + allocators */ %fragment("StdVectorATraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { typedef std::vector vector_type; typedef T value_type; static int asptr(VALUE obj, vector_type **vec) { return traits_asptr_stdseq::asptr(obj, vec); } }; template struct traits_from > { typedef std::vector vector_type; static VALUE from(const vector_type& vec) { return traits_from_stdseq::from(vec); } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %mixin std::vector "Enumerable"; %ignore std::vector::push_back; %ignore std::vector::pop_back; %alias std::vector::push "<<"; %include swig-3.0.2/Lib/ruby/rubyfragments.swg0000664000175000017500000000105012343605122017440 0ustar williamwilliam/* Create a file with this name, 'rubyfragments.swg', in your working directory and add all the %fragments you want to take precedence over the ones defined by default by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(VALUE obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.2/Lib/ruby/director.swg0000664000175000017500000001766712343605122016410 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Ruby proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ /* Use -DSWIG_DIRECTOR_NOUEH if you prefer to avoid the use of the Undefined Exception Handler provided by swig. */ #ifndef SWIG_DIRECTOR_NOUEH #ifndef SWIG_DIRECTOR_UEH #define SWIG_DIRECTOR_UEH #endif #endif #include #include #include #include # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) namespace Swig { /* memory handler */ struct GCItem { virtual ~GCItem() { } virtual ruby_owntype get_own() const { return 0; } }; struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) { } GCItem_var& operator=(GCItem *item) { GCItem *tmp = _item; _item = item; delete tmp; return *this; } ~GCItem_var() { delete _item; } GCItem *operator->() const { return _item; } private: GCItem *_item; }; template struct GCItem_T : GCItem { GCItem_T(Type *ptr) : _ptr(ptr) { } virtual ~GCItem_T() { delete _ptr; } private: Type *_ptr; }; struct GCItem_Object : GCItem { GCItem_Object(ruby_owntype own) : _own(own) { } virtual ~GCItem_Object() { } ruby_owntype get_own() const { return _own; } private: ruby_owntype _own; }; template struct GCArray_T : GCItem { GCArray_T(Type *ptr) : _ptr(ptr) { } virtual ~GCArray_T() { delete[] _ptr; } private: Type *_ptr; }; /* body args */ struct body_args { VALUE recv; ID id; int argc; VALUE *argv; }; /* Base class for director exceptions */ class DirectorException : public std::exception { protected: VALUE swig_error; std::string swig_msg; protected: DirectorException(VALUE error) : swig_error(error) { } DirectorException(VALUE error, const char *hdr, const char *msg ="") : swig_error(error), swig_msg(hdr) { if (msg[0]) { swig_msg += " "; swig_msg += msg; } if (swig_msg.size()) { VALUE str = rb_str_new(swig_msg.data(), swig_msg.size()); swig_error = rb_exc_new3(error, str); } else { swig_error = error; } } public: virtual ~DirectorException() throw() { } VALUE getType() const { return CLASS_OF(swig_error); } VALUE getError() const { return swig_error; } /* Deprecated, use what() instead */ const std::string& getMessage() const { return swig_msg; } const char *what() const throw() { return swig_msg.c_str(); } }; /* unknown exception handler */ class UnknownExceptionHandler { #ifdef SWIG_DIRECTOR_UEH static void handler() { try { throw; } catch (DirectorException& e) { std::cerr << "SWIG Director exception caught:" << std::endl << e.what() << std::endl; } catch (std::exception& e) { std::cerr << "std::exception caught: "<< e.what() << std::endl; } catch (...) { std::cerr << "Unknown exception caught." << std::endl; } std::cerr << std::endl << "Ruby interpreter traceback:" << std::endl; std::cerr << std::endl; std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl << std::endl << "Exception is being re-thrown, program will like abort/terminate." << std::endl; throw; } public: std::unexpected_handler old; UnknownExceptionHandler(std::unexpected_handler nh = handler) { old = std::set_unexpected(nh); } ~UnknownExceptionHandler() { std::set_unexpected(old); } #endif }; /* Type mismatch in the return value from a Ruby method call */ class DirectorTypeMismatchException : public DirectorException { public: DirectorTypeMismatchException(VALUE error, const char *msg="") : DirectorException(error, "SWIG director type mismatch", msg) { } DirectorTypeMismatchException(const char *msg="") : DirectorException(rb_eTypeError, "SWIG director type mismatch", msg) { } static void raise(VALUE error, const char *msg) { throw DirectorTypeMismatchException(error, msg); } static void raise(const char *msg) { throw DirectorTypeMismatchException(msg); } }; /* Any Ruby exception that occurs during a director method call */ class DirectorMethodException : public DirectorException { public: DirectorMethodException(VALUE error) : DirectorException(error) { } DirectorMethodException(const char *msg = "") : DirectorException(rb_eRuntimeError, "SWIG director method error.", msg) { } static void raise(VALUE error) { throw DirectorMethodException(error); } }; /* Attempted to call a pure virtual method via a director method */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg = "") : DirectorException(rb_eRuntimeError, "SWIG director pure virtual method called", msg) { } static void raise(const char *msg) { throw DirectorPureVirtualException(msg); } }; /* Simple thread abstraction for pthreads on win32 */ #ifdef __THREAD__ # define __PTHREAD__ # if defined(_WIN32) || defined(__WIN32__) # define pthread_mutex_lock EnterCriticalSection # define pthread_mutex_unlock LeaveCriticalSection # define pthread_mutex_t CRITICAL_SECTION # define SWIG_MUTEX_INIT(var) var # else # include # define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER # endif #endif #ifdef __PTHREAD__ struct Guard { pthread_mutex_t *_mutex; Guard(pthread_mutex_t &mutex) : _mutex(&mutex) { pthread_mutex_lock(_mutex); } ~Guard() { pthread_mutex_unlock(_mutex); } }; # define SWIG_GUARD(mutex) Guard _guard(mutex) #else # define SWIG_GUARD(mutex) #endif /* director base class */ class Director { private: /* pointer to the wrapped Ruby object */ VALUE swig_self; /* flag indicating whether the object is owned by Ruby or c++ */ mutable bool swig_disown_flag; public: /* wrap a Ruby object, optionally taking ownership */ Director(VALUE self) : swig_self(self), swig_disown_flag(false) { } /* discard our reference at destruction */ virtual ~Director() { } /* return a pointer to the wrapped Ruby object */ VALUE swig_get_self() const { return swig_self; } /* acquire ownership of the wrapped Ruby object (the sense of "disown" is from Ruby) */ void swig_disown() const { if (!swig_disown_flag) { swig_disown_flag = true; } } /* ownership management */ private: typedef std::map swig_ownership_map; mutable swig_ownership_map swig_owner; #ifdef __PTHREAD__ static pthread_mutex_t swig_mutex_own; #endif public: template void swig_acquire_ownership_array(Type *vptr) const { if (vptr) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCArray_T(vptr); } } template void swig_acquire_ownership(Type *vptr) const { if (vptr) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCItem_T(vptr); } } void swig_acquire_ownership_obj(void *vptr, ruby_owntype own) const { if (vptr && own) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCItem_Object(own); } } ruby_owntype swig_release_ownership(void *vptr) const { ruby_owntype own = 0; if (vptr) { SWIG_GUARD(swig_mutex_own); swig_ownership_map::iterator iter = swig_owner.find(vptr); if (iter != swig_owner.end()) { own = iter->second->get_own(); swig_owner.erase(iter); } } return own; } }; } swig-3.0.2/Lib/ruby/std_multiset.i0000664000175000017500000000257312343605122016733 0ustar williamwilliam/* Multisets */ %include %fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const RubySeq& rubyseq, std::multiset* seq) { // seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(VALUE obj, std::multiset **m) { return traits_asptr_stdseq >::asptr(obj, m); } }; template struct traits_from > { static VALUE from(const std::multiset& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_multiset_methods(Set...) %swig_set_methods(Set) %rename("delete") std::multiset::__delete__; %rename("reject!") std::multiset::reject_bang; %rename("map!") std::multiset::map_bang; %rename("empty?") std::multiset::empty; %rename("include?" ) std::multiset::__contains__ const; %rename("has_key?" ) std::multiset::has_key const; %alias std::multiset::push "<<"; %include swig-3.0.2/Lib/ruby/rubycomplex.swg0000664000175000017500000000742412343605122017134 0ustar williamwilliam/* Defines the As/From conversors for double/float complex, you need to provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex accessor methods. See the std_complex.i and ccomplex.i for concrete examples. */ %fragment("rb_complex_new","header") { %#if !defined(T_COMPLEX) /* Ruby versions prior to 1.9 did not have native complex numbers. They were an extension in the STD library. */ SWIGINTERN VALUE rb_complex_new(VALUE x, VALUE y) { static ID new_id = rb_intern("new"); static VALUE cComplex = rb_const_get(rb_cObject, rb_intern("Complex")); return rb_funcall(cComplex, new_id, 2, x, y); } %#endif } %fragment("SWIG_Complex_Numbers","header") { %#if !defined(T_COMPLEX) SWIGINTERN int SWIG_Is_Complex( VALUE obj ) { static ID real_id = rb_intern("real"); static ID imag_id = rb_intern("imag"); return ( (rb_respond_to( obj, real_id ) ) && (rb_respond_to( obj, imag_id ) ) ); } %#else SWIGINTERN int SWIG_Is_Complex( VALUE obj ) { return TYPE(obj) == T_COMPLEX; } %#endif SWIGINTERN VALUE SWIG_Complex_Real(VALUE obj) { static ID real_id = rb_intern("real"); return rb_funcall(obj, real_id, 0); } SWIGINTERN VALUE SWIG_Complex_Imaginary(VALUE obj) { static ID imag_id = rb_intern("imag"); return rb_funcall(obj, imag_id, 0); } } %init { %#if !defined(T_COMPLEX) rb_require("complex"); %#endif } /* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header",fragment="rb_complex_new") { SWIGINTERNINLINE VALUE SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) { VALUE re = rb_float_new(Real(c)); VALUE im = rb_float_new(Imag(c)); return rb_complex_new(re, im); } } %enddef /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double), fragment="SWIG_Complex_Numbers") { SWIGINTERN int SWIG_AsVal(Type) (VALUE o, Type* val) { if ( SWIG_Is_Complex( o ) ) { if (val) { VALUE real = SWIG_Complex_Real(o); VALUE imag = SWIG_Complex_Imaginary(o); double re = 0; SWIG_AsVal_double( real, &re ); double im = 0; SWIG_AsVal_double( imag, &im ); *val = Constructor(re, im); } return SWIG_OK; } else { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef /* the float case */ %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float), fragment=SWIG_AsVal_frag(double), fragment="SWIG_Complex_Numbers") { SWIGINTERN int SWIG_AsVal(Type)(VALUE o, Type *val) { if ( SWIG_Is_Complex( o ) ) { VALUE real = SWIG_Complex_Real(o); VALUE imag = SWIG_Complex_Imaginary(o); double re = 0; SWIG_AsVal_double( real, &re ); double im = 0; SWIG_AsVal_double( imag, &im ); if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else { return SWIG_OverflowError; } } else { float re; int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(re, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.2/Lib/ruby/std_map.i0000664000175000017500000002576012343605122015645 0ustar williamwilliam// // Maps // %fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { template struct from_key_oper { typedef const ValueType& argument_type; typedef VALUE result_type; result_type operator()(argument_type v) const { return swig::from(v.first); } }; template struct from_value_oper { typedef const ValueType& argument_type; typedef VALUE result_type; result_type operator()(argument_type v) const { return swig::from(v.second); } }; template struct MapIterator_T : ConstIteratorClosed_T { MapIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq) : ConstIteratorClosed_T(curr, first, last, seq) { } }; template > struct MapKeyIterator_T : MapIterator_T { MapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq) : MapIterator_T(curr, first, last, seq) { } }; template inline ConstIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, VALUE seq = 0) { return new MapKeyIterator_T(current, begin, end, seq); } template > struct MapValueIterator_T : MapIterator_T { MapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq) : MapIterator_T(curr, first, last, seq) { } }; template inline ConstIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, VALUE seq = 0) { return new MapValueIterator_T(current, begin, end, seq); } } } %fragment("StdMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const RubySeq& rubyseq, std::map *map) { typedef typename std::map::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::map map_type; static int asptr(VALUE obj, map_type **val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_HASH ) { static ID id_to_a = rb_intern("to_a"); VALUE items = rb_funcall(obj, id_to_a, 0); res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::map map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type; static VALUE from(const map_type& map) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); } else { size_type size = map.size(); int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise( rb_eRuntimeError, "map size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE obj = rb_hash_new(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { VALUE key = swig::from(i->first); VALUE val = swig::from(i->second); rb_hash_aset(obj, key, val); } return obj; } } }; } } %define %swig_map_common(Map...) %swig_container_methods(%arg(Map)); // %swig_sequence_iterator(%arg(Map)); %extend { VALUE __delete__(const key_type& key) { Map::iterator i = self->find(key); if (i != self->end()) { self->erase(i); return swig::from( key ); } else { return Qnil; } } bool has_key(const key_type& key) const { Map::const_iterator i = self->find(key); return i != self->end(); } VALUE keys() { Map::size_type size = self->size(); int rubysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise(rb_eRuntimeError, "map size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE ary = rb_ary_new2(rubysize); Map::const_iterator i = self->begin(); Map::const_iterator e = self->end(); for ( ; i != e; ++i ) { rb_ary_push( ary, swig::from(i->first) ); } return ary; } Map* each() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given"); VALUE k, v; Map::iterator i = self->begin(); Map::iterator e = self->end(); for ( ; i != e; ++i ) { const Map::key_type& key = i->first; const Map::mapped_type& val = i->second; k = swig::from(key); v = swig::from(val); rb_yield_values(2, k, v); } return self; } %newobject select; Map* select() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); Map* r = new Map; Map::iterator i = $self->begin(); Map::iterator e = $self->end(); for ( ; i != e; ++i ) { VALUE k = swig::from(i->first); VALUE v = swig::from(i->second); if ( RTEST( rb_yield_values(2, k, v) ) ) $self->insert(r->end(), *i); } return r; } %typemap(in) (int argc, VALUE* argv) { $1 = argc; $2 = argv; } VALUE values_at(int argc, VALUE* argv, ...) { VALUE r = rb_ary_new(); ID id = rb_intern("[]"); swig_type_info* type = swig::type_info< Map >(); VALUE me = SWIG_NewPointerObj( $self, type, 0 ); for ( int i = 0; i < argc; ++i ) { VALUE key = argv[i]; VALUE tmp = rb_funcall( me, id, 1, key ); rb_ary_push( r, tmp ); } return r; } Map* each_key() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given"); VALUE r; Map::iterator i = self->begin(); Map::iterator e = self->end(); for ( ; i != e; ++i ) { r = swig::from( i->first ); rb_yield(r); } return self; } VALUE values() { Map::size_type size = self->size(); int rubysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise(rb_eRuntimeError, "map size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE ary = rb_ary_new2(rubysize); Map::const_iterator i = self->begin(); Map::const_iterator e = self->end(); for ( ; i != e; ++i ) { rb_ary_push( ary, swig::from(i->second) ); } return ary; } Map* each_value() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given"); VALUE r; Map::iterator i = self->begin(); Map::iterator e = self->end(); for ( ; i != e; ++i ) { r = swig::from( i->second ); rb_yield(r); } return self; } VALUE entries() { Map::size_type size = self->size(); int rubysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise(rb_eRuntimeError, "map size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE ary = rb_ary_new2(rubysize); Map::const_iterator i = self->begin(); Map::const_iterator e = self->end(); for ( ; i != e; ++i ) { rb_ary_push( ary, swig::from >(*i) ); } return ary; } bool __contains__(const key_type& key) { return self->find(key) != self->end(); } %newobject key_iterator(VALUE *RUBY_SELF); swig::ConstIterator* key_iterator(VALUE *RUBY_SELF) { return swig::make_output_key_iterator($self->begin(), $self->begin(), $self->end(), *RUBY_SELF); } %newobject value_iterator(VALUE *RUBY_SELF); swig::ConstIterator* value_iterator(VALUE *RUBY_SELF) { return swig::make_output_value_iterator($self->begin(), $self->begin(), $self->end(), *RUBY_SELF); } } %enddef %define %swig_map_methods(Map...) %swig_map_common(Map) %extend { VALUE __getitem__(const key_type& key) const { Map::const_iterator i = self->find(key); if ( i != self->end() ) return swig::from( i->second ); else return Qnil; } void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { (*self)[key] = x; } VALUE inspect() { Map::const_iterator i = $self->begin(); Map::const_iterator e = $self->end(); const char *type_name = swig::type_name< Map >(); VALUE str = rb_str_new2( type_name ); str = rb_str_cat2( str, " {" ); bool comma = false; VALUE tmp; for ( ; i != e; ++i, comma = true ) { if (comma) str = rb_str_cat2( str, "," ); tmp = swig::from< Map::key_type >( i->first ); tmp = rb_inspect( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, "=>" ); tmp = swig::from< Map::mapped_type >( i->second ); tmp = rb_inspect( tmp ); str = rb_str_buf_append( str, tmp ); } str = rb_str_cat2( str, "}" ); return str; } VALUE to_a() { Map::const_iterator i = $self->begin(); Map::const_iterator e = $self->end(); VALUE ary = rb_ary_new2( std::distance( i, e ) ); VALUE tmp; for ( ; i != e; ++i ) { // @todo: improve -- this should just be swig::from(*i) tmp = swig::from< std::pair >( *i ); rb_ary_push( ary, tmp ); } return ary; } VALUE to_s() { Map::iterator i = $self->begin(); Map::iterator e = $self->end(); VALUE str = rb_str_new2( "" ); VALUE tmp; for ( ; i != e; ++i ) { // @todo: improve -- this should just be swig::from(*i) tmp = swig::from< std::pair >( *i ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); } return str; } } %enddef %mixin std::map "Enumerable"; %rename("delete") std::map::__delete__; %rename("reject!") std::map::reject_bang; %rename("map!") std::map::map_bang; %rename("empty?") std::map::empty; %rename("include?" ) std::map::__contains__ const; %rename("has_key?" ) std::map::has_key const; %alias std::map::push "<<"; %include swig-3.0.2/Lib/ruby/std_iostream.i0000664000175000017500000000034312343605122016701 0ustar williamwilliamnamespace std { %callback("%s") endl; %callback("%s") ends; %callback("%s") flush; } %warnfilter(365) operator+=; %warnfilter(802) std::basic_iostream; // turn off multiple inheritance warning %include swig-3.0.2/Lib/ruby/rubystrings.swg0000664000175000017500000000304112343605122017145 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) { if (TYPE(obj) == T_STRING) { char *cstr = StringValuePtr(obj); size_t size = RSTRING_LEN(obj) + 1; if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { *cptr = %new_copy_array(cstr, size, char); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } } if (psize) *psize = size; return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *)vptr; if (psize) *psize = vptr ? (strlen((char*)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE VALUE SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > LONG_MAX) { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); return pchar_descriptor ? SWIG_NewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : Qnil; } else { return rb_str_new(carray, %numeric_cast(size,long)); } } else { return Qnil; } } } swig-3.0.2/Lib/ruby/rubyclasses.swg0000664000175000017500000002615112343605122017120 0ustar williamwilliam#ifdef __cplusplus /* GC_VALUE is used as a replacement of Ruby's VALUE. GC_VALUE automatically handles registering and unregistering of the underlying Ruby object with the GC. It can be used if you want to create STL containers of VALUEs, such as: std::vector< GC_VALUE >; or as a member variable: struct A { GC_VALUE _obj; A(VALUE o) : _obj(o) { } }; or as a input/output value (not much use for this, as VALUE works just as well here, thou): GC_VALUE func(GC_VALUE obj) { GC_VALUE out = rb_obj_classname(obj); return out; } GC_VALUE is 'visible' at the wrapped side, so you can do: %template(RubyVector) std::vector; and all the proper typemaps will be used. */ %fragment("GC_VALUE_definition","header") { namespace swig { class SwigGCReferences { // Hash of all GC_VALUE's currently in use static SwigGCReferences s_references; VALUE _hash; SwigGCReferences() : _hash(Qnil) { } ~SwigGCReferences() { if (_hash != Qnil) rb_gc_unregister_address(&_hash); } static void EndProcHandler(VALUE) { // Ruby interpreter ending - _hash can no longer be accessed. s_references._hash = Qnil; } public: static SwigGCReferences& instance() { return s_references; } static void initialize() { if (s_references._hash == Qnil) { rb_set_end_proc(&EndProcHandler, Qnil); s_references._hash = rb_hash_new(); rb_gc_register_address(&s_references._hash); } } void GC_register(VALUE& obj) { if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) return; if (_hash != Qnil) { VALUE val = rb_hash_aref(_hash, obj); unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0; ++n; rb_hash_aset(_hash, obj, INT2NUM(n)); } } void GC_unregister(const VALUE& obj) { if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) return; // this test should not be needed but I've noticed some very erratic // behavior of none being unregistered in some very rare situations. if (BUILTIN_TYPE(obj) == T_NONE) return; if (_hash != Qnil) { VALUE val = rb_hash_aref(s_references._hash, obj); unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1; --n; if (n) rb_hash_aset(s_references._hash, obj, INT2NUM(n)); else rb_hash_delete(s_references._hash, obj); } } }; class GC_VALUE { protected: VALUE _obj; static ID hash_id; static ID lt_id; static ID gt_id; static ID eq_id; static ID le_id; static ID ge_id; static ID pos_id; static ID neg_id; static ID inv_id; static ID add_id; static ID sub_id; static ID mul_id; static ID div_id; static ID mod_id; static ID and_id; static ID or_id; static ID xor_id; static ID lshift_id; static ID rshift_id; struct OpArgs { VALUE src; ID id; int nargs; VALUE target; }; public: GC_VALUE() : _obj(Qnil) { } GC_VALUE(const GC_VALUE& item) : _obj(item._obj) { SwigGCReferences::instance().GC_register(_obj); } GC_VALUE(VALUE obj) :_obj(obj) { SwigGCReferences::instance().GC_register(_obj); } ~GC_VALUE() { SwigGCReferences::instance().GC_unregister(_obj); } GC_VALUE & operator=(const GC_VALUE& item) { SwigGCReferences::instance().GC_unregister(_obj); _obj = item._obj; SwigGCReferences::instance().GC_register(_obj); return *this; } operator VALUE() const { return _obj; } VALUE inspect() const { return rb_inspect(_obj); } VALUE to_s() const { return rb_inspect(_obj); } static VALUE swig_rescue_swallow(VALUE) { /* VALUE errstr = rb_obj_as_string(rb_errinfo()); printf("Swallowing error: '%s'\n", RSTRING_PTR(StringValue(errstr))); */ return Qnil; /* Swallow Ruby exception */ } static VALUE swig_rescue_funcall(VALUE p) { OpArgs* args = (OpArgs*) p; return rb_funcall(args->src, args->id, args->nargs, args->target); } bool relational_equal_op(const GC_VALUE& other, const ID& op_id, bool (*op_func)(const VALUE& a, const VALUE& b)) const { if (FIXNUM_P(_obj) && FIXNUM_P(other._obj)) { return op_func(_obj, other._obj); } bool res = false; VALUE ret = Qnil; SWIG_RUBY_THREAD_BEGIN_BLOCK; if (rb_respond_to(_obj, op_id)) { OpArgs args; args.src = _obj; args.id = op_id; args.nargs = 1; args.target = VALUE(other); ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); } if (ret == Qnil) { VALUE a = rb_funcall( _obj, hash_id, 0 ); VALUE b = rb_funcall( VALUE(other), hash_id, 0 ); res = op_func(a, b); } else { res = RTEST(ret); } SWIG_RUBY_THREAD_END_BLOCK; return res; } static bool operator_eq(const VALUE& a, const VALUE& b) { return a == b; } static bool operator_lt(const VALUE& a, const VALUE& b) { return a < b; } static bool operator_le(const VALUE& a, const VALUE& b) { return a <= b; } static bool operator_gt(const VALUE& a, const VALUE& b) { return a > b; } static bool operator_ge(const VALUE& a, const VALUE& b) { return a >= b; } bool operator==(const GC_VALUE& other) const { return relational_equal_op(other, eq_id, operator_eq); } bool operator<(const GC_VALUE& other) const { return relational_equal_op(other, lt_id, operator_lt); } bool operator<=(const GC_VALUE& other) const { return relational_equal_op(other, le_id, operator_le); } bool operator>(const GC_VALUE& other) const { return relational_equal_op(other, gt_id, operator_gt); } bool operator>=(const GC_VALUE& other) const { return relational_equal_op(other, ge_id, operator_ge); } bool operator!=(const GC_VALUE& other) const { return !(this->operator==(other)); } GC_VALUE unary_op(const ID& op_id) const { VALUE ret = Qnil; SWIG_RUBY_THREAD_BEGIN_BLOCK; OpArgs args; args.src = _obj; args.id = op_id; args.nargs = 0; args.target = Qnil; ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); SWIG_RUBY_THREAD_END_BLOCK; return ret; } GC_VALUE operator+() const { return unary_op(pos_id); } GC_VALUE operator-() const { return unary_op(neg_id); } GC_VALUE operator~() const { return unary_op(inv_id); } GC_VALUE binary_op(const GC_VALUE& other, const ID& op_id) const { VALUE ret = Qnil; SWIG_RUBY_THREAD_BEGIN_BLOCK; OpArgs args; args.src = _obj; args.id = op_id; args.nargs = 1; args.target = VALUE(other); ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); SWIG_RUBY_THREAD_END_BLOCK; return GC_VALUE(ret); } GC_VALUE operator+(const GC_VALUE& other) const { return binary_op(other, add_id); } GC_VALUE operator-(const GC_VALUE& other) const { return binary_op(other, sub_id); } GC_VALUE operator*(const GC_VALUE& other) const { return binary_op(other, mul_id); } GC_VALUE operator/(const GC_VALUE& other) const { return binary_op(other, div_id); } GC_VALUE operator%(const GC_VALUE& other) const { return binary_op(other, mod_id); } GC_VALUE operator&(const GC_VALUE& other) const { return binary_op(other, and_id); } GC_VALUE operator^(const GC_VALUE& other) const { return binary_op(other, xor_id); } GC_VALUE operator|(const GC_VALUE& other) const { return binary_op(other, or_id); } GC_VALUE operator<<(const GC_VALUE& other) const { return binary_op(other, lshift_id); } GC_VALUE operator>>(const GC_VALUE& other) const { return binary_op(other, rshift_id); } }; ID GC_VALUE::hash_id = rb_intern("hash"); ID GC_VALUE::lt_id = rb_intern("<"); ID GC_VALUE::gt_id = rb_intern(">"); ID GC_VALUE::eq_id = rb_intern("=="); ID GC_VALUE::le_id = rb_intern("<="); ID GC_VALUE::ge_id = rb_intern(">="); ID GC_VALUE::pos_id = rb_intern("+@"); ID GC_VALUE::neg_id = rb_intern("-@"); ID GC_VALUE::inv_id = rb_intern("~"); ID GC_VALUE::add_id = rb_intern("+"); ID GC_VALUE::sub_id = rb_intern("-"); ID GC_VALUE::mul_id = rb_intern("*"); ID GC_VALUE::div_id = rb_intern("/"); ID GC_VALUE::mod_id = rb_intern("%"); ID GC_VALUE::and_id = rb_intern("&"); ID GC_VALUE::or_id = rb_intern("|"); ID GC_VALUE::xor_id = rb_intern("^"); ID GC_VALUE::lshift_id = rb_intern("<<"); ID GC_VALUE::rshift_id = rb_intern(">>"); SwigGCReferences SwigGCReferences::s_references; typedef GC_VALUE LANGUAGE_OBJ; } // namespace swig } // %fragment(GC_VALUE_definition) namespace swig { %apply VALUE {GC_VALUE}; // Make sure this is the last typecheck done %typecheck(999999,fragment="GC_VALUE_definition",noblock=1) GC_VALUE, GC_VALUE&, const GC_VALUE& { $1 = 1; }; /* For input */ %typemap(in,fragment="GC_VALUE_definition",noblock=1) GC_VALUE* (GC_VALUE r), GC_VALUE& (GC_VALUE r) { r = $input; $1 = &r; } /* For output */ %typemap(out,fragment="GC_VALUE_definition",noblock=1) GC_VALUE { $result = (VALUE)$1; } %typemap(out,fragment="GC_VALUE_definition",noblock=1) GC_VALUE*, GC_VALUE const & { $result = (VALUE)*$1; } %nodirector GC_VALUE; // We ignore the constructor so that user can never create a GC_VALUE // manually %ignore GC_VALUE::GC_VALUE; struct GC_VALUE { VALUE inspect() const; VALUE to_s() const; GC_VALUE(); protected: GC_VALUE(const GC_VALUE&); ~GC_VALUE(); }; %exception GC_VALUE {}; %ignore LANGUAGE_OBJ; typedef GC_VALUE LANGUAGE_OBJ; } %init { swig::SwigGCReferences::initialize(); } // // Fragment that contains traits to properly deal with GC_VALUE. // These functions may be invoked as a need of the from(), asval(), // asptr() and as() template functors, usually used in %typemaps. // %fragment(SWIG_Traits_frag(swig::GC_VALUE),"header",fragment="StdTraits",fragment="GC_VALUE_definition") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "GC_VALUE"; } }; template <> struct traits_from { typedef GC_VALUE value_type; static VALUE from(const value_type& val) { return static_cast(val); } }; template <> struct traits_check { static bool check(GC_VALUE) { return true; } }; template <> struct traits_asval { typedef GC_VALUE value_type; static int asval(VALUE obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; } // swig } // %fragment(traits for swig::GC_VALUE) #endif // __cplusplus swig-3.0.2/Lib/ruby/rubycontainer_extended.swg0000664000175000017500000000672412343605122021331 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubycontainer_extended.swg * * This file contains additional functions that make containers * behave closer to ruby primitive types. * However, some of these functions place some restrictions on * the underlying object inside of the container and the iterator * (that it has to have an == comparison function, that it has to have * an = assignment operator, etc). * ----------------------------------------------------------------------------- */ /** * Macro used to add extend functions that require operator== in object. * * @param Container STL container * @param Type class inside container * */ %define %swig_container_with_equal_operator( Container, Type ) VALUE __delete__( const Type& val ) { VALUE r = Qnil; Container::iterator e = $self->end(); Container::iterator i = std::remove( $self->begin(), e, val ); // remove dangling elements now $self->erase( i, e ); if ( i != e ) r = swig::from< Type >( val ); else if ( rb_block_given_p() ) r = rb_yield(Qnil); return r; } %enddef // end of %swig_container_with_equal_operator /** * Macro used to add extend functions that require the assignment * operator (ie. = ) of contained class * * @param Container STL container * @param Type class inside container * */ %define %swig_container_with_assignment( Container, Type ) // // map! -- the equivalent of std::transform // Container< Type >* map_bang() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "No block given" ); VALUE r = Qnil; Container< Type >::iterator i = $self->begin(); Container< Type >::iterator e = $self->end(); try { for ( ; i != e; ++i ) { r = swig::from< Type >( *i ); r = rb_yield( r ); *i = swig::as< Type >( r ); } } catch ( const std::invalid_argument& ) { rb_raise(rb_eTypeError, "Yield block did not return a valid element for " "Container"); } return $self; } %enddef // end of %swig_container_with_assignment /** * Macro used to add all extended functions to a container * * @param Container STL container * @param Type class inside container * */ %define %swig_container_extend( Container, Type ) %extend Container< Type > { %swig_container_with_assignment( %arg(Container), Type ); %swig_container_with_equal_operator( %arg(Container), Type ); } %enddef /** * Private macro used to add all extended functions to C/C++ * primitive types * * @param Container an STL container, like std::vector (with no class template) * */ %define %__swig_container_extend_primtypes( Container ) %swig_container_extend( %arg( Container ), bool ); %swig_container_extend( %arg( Container ), char ); %swig_container_extend( %arg( Container ), short ); %swig_container_extend( %arg( Container ), int ); %swig_container_extend( %arg( Container ), unsigned short ); %swig_container_extend( %arg( Container ), unsigned int ); %swig_container_extend( %arg( Container ), float ); %swig_container_extend( %arg( Container ), double ); %swig_container_extend( %arg( Container ), std::complex ); %swig_container_extend( %arg( Container ), std::string ); %swig_container_extend( %arg( Container ), swig::GC_VALUE ); %enddef %__swig_container_extend_primtypes( std::vector ); %__swig_container_extend_primtypes( std::deque ); %__swig_container_extend_primtypes( std::list ); swig-3.0.2/Lib/ruby/argcargv.i0000664000175000017500000000231312343605122015777 0ustar williamwilliam/* ------------------------------------------------------------ * --- Argc & Argv --- * ------------------------------------------------------------ */ /* ------------------------------------------------------------ Use it as follow: %apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) } %inline %{ int mainApp(size_t argc, const char **argv) { return argc; } then in the ruby side: args = ["asdf", "asdf2"] mainApp(args); * ------------------------------------------------------------ */ %typemap(in) (int ARGC, char **ARGV) { if (rb_obj_is_kind_of($input,rb_cArray)) { int i; int size = RARRAY_LEN($input); $1 = ($1_ltype) size; $2 = (char **) malloc((size+1)*sizeof(char *)); VALUE *ptr = RARRAY_PTR($input); for (i=0; i < size; i++, ptr++) { $2[i]= StringValuePtr(*ptr); } $2[i]=NULL; } else { $1 = 0; $2 = 0; %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum); } } %typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) { $1 = rb_obj_is_kind_of($input,rb_cArray); } %typemap(freearg) (int ARGC, char **ARGV) { free((char *) $2); } swig-3.0.2/Lib/ruby/std_stack.i0000664000175000017500000000152512343605122016166 0ustar williamwilliam/* Stacks */ %fragment("StdStackTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::stack **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static VALUE from(const std::stack & vec) { return traits_from_stdseq >::from(vec); } }; } %} %rename("delete") std::stack::__delete__; %rename("reject!") std::stack::reject_bang; %rename("map!") std::stack::map_bang; %rename("empty?") std::stack::empty; %rename("include?" ) std::stack::__contains__ const; %rename("has_key?" ) std::stack::has_key const; %alias std::stack::push "<<"; %include swig-3.0.2/Lib/ruby/std_pair.i0000664000175000017500000001233312343605122016013 0ustar williamwilliam/* Pairs */ %include //#define SWIG_STD_PAIR_ASVAL %fragment("StdPairTraits","header",fragment="StdTraits") { namespace swig { template struct traits_asval > { typedef std::pair value_type; static int get_pair(VALUE first, VALUE second, std::pair *val) { if (val) { T *pfirst = &(val->first); int res1 = swig::asval((VALUE)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(val->second); int res2 = swig::asval((VALUE)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } else { T *pfirst = 0; int res1 = swig::asval((VALUE)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((VALUE)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asval(VALUE obj, std::pair *val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_ARRAY ) { if (RARRAY_LEN(obj) == 2) { VALUE first = rb_ary_entry(obj,0); VALUE second = rb_ary_entry(obj,1); res = get_pair(first, second, val); } } else { value_type *p; res = SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = *p; } return res; } }; template struct traits_asptr > { typedef std::pair value_type; static int get_pair(VALUE first, VALUE second, std::pair **val) { if (val) { value_type *vp = %new_instance(std::pair); T *pfirst = &(vp->first); int res1 = swig::asval((VALUE)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(vp->second); int res2 = swig::asval((VALUE)second, psecond); if (!SWIG_IsOK(res2)) return res2; *val = vp; return SWIG_AddNewMask(res1 > res2 ? res1 : res2); } else { T *pfirst = 0; int res1 = swig::asval((VALUE)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((VALUE)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asptr(VALUE obj, std::pair **val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_ARRAY ) { if ( RARRAY_LEN(obj) == 2) { VALUE first = rb_ary_entry(obj,0); VALUE second = rb_ary_entry(obj,1); res = get_pair(first, second, val); } } else { value_type *p; res = SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { static VALUE _wrap_pair_second( VALUE self ) { std::pair< typename swig::noconst_traits::noconst_type,U>* p = NULL; swig::asptr( self, &p ); return swig::from( p->second ); } static VALUE _wrap_pair_second_eq( VALUE self, VALUE arg ) { std::pair< typename swig::noconst_traits::noconst_type,U>* p = NULL; swig::asptr( self, &p ); return swig::from( p->second ); } static VALUE from(const std::pair& val) { VALUE obj = rb_ary_new2(2); rb_ary_push(obj, swig::from::noconst_type>(val.first)); rb_ary_push(obj, swig::from(val.second)); rb_define_singleton_method(obj, "second", VALUEFUNC(_wrap_pair_second), 0 ); rb_define_singleton_method(obj, "second=", VALUEFUNC(_wrap_pair_second_eq), 1 ); rb_obj_freeze(obj); // treat as immutable tuple return obj; } }; } } // Missing typemap %typemap(in) std::pair* (int res) { res = swig::asptr( $input, &$1 ); if (!SWIG_IsOK(res)) %argument_fail(res, "$1_type", $symname, $argnum); } %define %swig_pair_methods(pair...) %extend { VALUE inspect() const { VALUE tmp; const char *type_name = swig::type_name< pair >(); VALUE str = rb_str_new2( type_name ); str = rb_str_cat2( str, " (" ); tmp = swig::from( $self->first ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, "," ); tmp = swig::from( $self->second ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, ")" ); return str; } VALUE to_s() const { VALUE tmp; VALUE str = rb_str_new2( "(" ); tmp = swig::from( $self->first ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, "," ); tmp = swig::from( $self->second ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, ")" ); return str; } VALUE __getitem__( int index ) { if (( index % 2 ) == 0 ) return swig::from( $self->first ); else return swig::from( $self->second ); } VALUE __setitem__( int index, VALUE obj ) { int res; if (( index % 2 ) == 0 ) { res = swig::asval( obj, &($self->first) ); } else { res = swig::asval(obj, &($self->second) ); } if (!SWIG_IsOK(res)) rb_raise( rb_eArgError, "invalid item for " #pair ); return obj; } } // extend %enddef %include swig-3.0.2/Lib/ruby/std_complex.i0000664000175000017500000000072712343605122016533 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.2/Lib/ruby/typemaps.i0000664000175000017500000002606212343605122016054 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * * These mappings provide support for input/output arguments and * common uses for C/C++ pointers. INOUT mappings allow for C/C++ * pointer variables in addition to input/output arguments. * ----------------------------------------------------------------------------- */ #if !defined(SWIG_USE_OLD_TYPEMAPS) %include #else /* The SWIG typemap library provides a language independent mechanism for supporting output arguments, input values, and other C function calling mechanisms. The primary use of the library is to provide a better interface to certain C function--especially those involving pointers. */ // ------------------------------------------------------------------------ // Pointer handling // // These mappings provide support for input/output arguments and common // uses for C/C++ pointers. // ------------------------------------------------------------------------ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include typemaps.i double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include typemaps.i %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ %define INPUT_TYPEMAP(type, converter) %typemap(in) type *INPUT($*1_ltype temp), type &INPUT($*1_ltype temp) { temp = ($*1_ltype) converter($input); $1 = &temp; } %typemap(typecheck) type *INPUT = type; %typemap(typecheck) type &INPUT = type; %enddef INPUT_TYPEMAP(float, NUM2DBL); INPUT_TYPEMAP(double, NUM2DBL); INPUT_TYPEMAP(int, NUM2INT); INPUT_TYPEMAP(short, NUM2SHRT); INPUT_TYPEMAP(long, NUM2LONG); INPUT_TYPEMAP(long long, NUM2LL); INPUT_TYPEMAP(unsigned int, NUM2UINT); INPUT_TYPEMAP(unsigned short, NUM2USHRT); INPUT_TYPEMAP(unsigned long, NUM2ULONG); INPUT_TYPEMAP(unsigned long long, NUM2ULL); INPUT_TYPEMAP(unsigned char, NUM2UINT); INPUT_TYPEMAP(signed char, NUM2INT); INPUT_TYPEMAP(bool, RTEST); #undef INPUT_TYPEMAP // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a array element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Ruby Array. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include typemaps.i double modf(double x, double *OUTPUT); or you can use the %apply directive : %include typemaps.i %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Ruby output of the function would be a Array containing both output values. */ %define OUTPUT_TYPEMAP(type, converter, convtype) %typemap(in,numinputs=0) type *OUTPUT($*1_ltype temp), type &OUTPUT($*1_ltype temp) "$1 = &temp;"; %typemap(argout, fragment="output_helper") type *OUTPUT, type &OUTPUT { VALUE o = converter(convtype (*$1)); $result = output_helper($result, o); } %enddef OUTPUT_TYPEMAP(int, INT2NUM, (int)); OUTPUT_TYPEMAP(short, INT2NUM, (int)); OUTPUT_TYPEMAP(long, INT2NUM, (long)); OUTPUT_TYPEMAP(long long, LL2NUM, (long long)); OUTPUT_TYPEMAP(unsigned int, UINT2NUM, (unsigned int)); OUTPUT_TYPEMAP(unsigned short, UINT2NUM, (unsigned int)); OUTPUT_TYPEMAP(unsigned long, UINT2NUM, (unsigned long)); OUTPUT_TYPEMAP(unsigned long long, ULL2NUM, (unsigned long long)); OUTPUT_TYPEMAP(unsigned char, UINT2NUM, (unsigned int)); OUTPUT_TYPEMAP(signed char, INT2NUM, (int)); OUTPUT_TYPEMAP(float, rb_float_new, (double)); OUTPUT_TYPEMAP(double, rb_float_new, (double)); #undef OUTPUT_TYPEMAP %typemap(in,numinputs=0) bool *OUTPUT(bool temp), bool &OUTPUT(bool temp) "$1 = &temp;"; %typemap(argout, fragment="output_helper") bool *OUTPUT, bool &OUTPUT { VALUE o = (*$1) ? Qtrue : Qfalse; $result = output_helper($result, o); } // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Ruby array. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include typemaps.i void neg(double *INOUT); or you can use the %apply directive : %include typemaps.i %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Ruby). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Ruby variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) signed char *INOUT = signed char *INPUT; %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) int &INOUT = int &INPUT; %typemap(in) short &INOUT = short &INPUT; %typemap(in) long &INOUT = long &INPUT; %typemap(in) long long &INOUT = long long &INPUT; %typemap(in) unsigned &INOUT = unsigned &INPUT; %typemap(in) unsigned short &INOUT = unsigned short &INPUT; %typemap(in) unsigned long &INOUT = unsigned long &INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; %typemap(in) unsigned char &INOUT = unsigned char &INPUT; %typemap(in) signed char &INOUT = signed char &INPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(in) float &INOUT = float &INPUT; %typemap(in) double &INOUT = double &INPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT = long *OUTPUT; %typemap(argout) long long *INOUT = long long *OUTPUT; %typemap(argout) unsigned *INOUT = unsigned *OUTPUT; %typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) signed char *INOUT = signed char *OUTPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT = double *OUTPUT; %typemap(argout) int &INOUT = int &OUTPUT; %typemap(argout) short &INOUT = short &OUTPUT; %typemap(argout) long &INOUT = long &OUTPUT; %typemap(argout) long long &INOUT = long long &OUTPUT; %typemap(argout) unsigned &INOUT = unsigned &OUTPUT; %typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; %typemap(argout) signed char &INOUT = signed char &OUTPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; %typemap(argout) float &INOUT = float &OUTPUT; %typemap(argout) double &INOUT = double &OUTPUT; /* Overloading information */ %typemap(typecheck) double *INOUT = double; %typemap(typecheck) signed char *INOUT = signed char; %typemap(typecheck) unsigned char *INOUT = unsigned char; %typemap(typecheck) unsigned long *INOUT = unsigned long; %typemap(typecheck) unsigned long long *INOUT = unsigned long long; %typemap(typecheck) unsigned short *INOUT = unsigned short; %typemap(typecheck) unsigned int *INOUT = unsigned int; %typemap(typecheck) long *INOUT = long; %typemap(typecheck) long long *INOUT = long long; %typemap(typecheck) short *INOUT = short; %typemap(typecheck) int *INOUT = int; %typemap(typecheck) float *INOUT = float; %typemap(typecheck) double &INOUT = double; %typemap(typecheck) signed char &INOUT = signed char; %typemap(typecheck) unsigned char &INOUT = unsigned char; %typemap(typecheck) unsigned long &INOUT = unsigned long; %typemap(typecheck) unsigned long long &INOUT = unsigned long long; %typemap(typecheck) unsigned short &INOUT = unsigned short; %typemap(typecheck) unsigned int &INOUT = unsigned int; %typemap(typecheck) long &INOUT = long; %typemap(typecheck) long long &INOUT = long long; %typemap(typecheck) short &INOUT = short; %typemap(typecheck) int &INOUT = int; %typemap(typecheck) float &INOUT = float; #endif // -------------------------------------------------------------------- // Special types // -------------------------------------------------------------------- %include %include %include swig-3.0.2/Lib/ruby/extra-install.list0000664000175000017500000000006512343605122017517 0ustar williamwilliam# see top-level Makefile.in Makefile.swig extconf.rb swig-3.0.2/Lib/ruby/std_container.i0000664000175000017500000000007412343605122017041 0ustar williamwilliam%include %include swig-3.0.2/Lib/ruby/rubyinit.swg0000664000175000017500000000004712343605122016422 0ustar williamwilliam%insert(initbeforefunc) "swiginit.swg" swig-3.0.2/Lib/ruby/cmalloc.i0000664000175000017500000000004012343605122015610 0ustar williamwilliam%include swig-3.0.2/Lib/ruby/cni.i0000664000175000017500000000005212343605122014752 0ustar williamwilliam%include %include swig-3.0.2/Lib/ruby/ruby.swg0000664000175000017500000000513512343605122015541 0ustar williamwilliam/* ------------------------------------------------------------ * ruby.swg * * Ruby configuration module. * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * The Ruby auto rename rules * ------------------------------------------------------------ */ #if defined(SWIG_RUBY_AUTORENAME) /* Class names are CamelCase */ %rename("%(camelcase)s", %$isclass) ""; /* Constants created by %constant or #define are UPPER_CASE */ %rename("%(uppercase)s", %$isconstant) ""; /* SWIG only considers static class members with inline intializers to be constants. For examples of what is and isn't considered a constant by SWIG see naming.i in the Ruby test suite. */ %rename("%(uppercase)s", %$ismember, %$isvariable,%$isimmutable,%$isstatic,%$hasvalue,%$hasconsttype) ""; /* Enums are mapped to constants but all we do is make sure the first letter is uppercase */ %rename("%(firstuppercase)s", %$isenumitem) ""; /* Method names should be lower_case_with_underscores */ %rename("%(undercase)s", %$isfunction, %$not %$ismemberget, %$not %$ismemberset) ""; #endif /* ------------------------------------------------------------ * Inner macros * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The runtime part * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Special user directives * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Typemap specializations * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Warnings for Ruby keywords * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Documentation for common Ruby methods * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Ruby initialization function * ------------------------------------------------------------ */ %include swig-3.0.2/Lib/ruby/cstring.i0000664000175000017500000000004012343605122015647 0ustar williamwilliam%include swig-3.0.2/Lib/ruby/rubyiterators.swg0000664000175000017500000005444712343605122017510 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubyiterators.swg * * Implement a C++ 'output' iterator for Ruby. * * Users can derive form the Iterator to implemet their * own iterators. As an example (real one since we use it for STL/STD * containers), the template Iterator_T does the * implementation for generic C++ iterators. * ----------------------------------------------------------------------------- */ %include %fragment("ConstIterator","header",fragment="",fragment="GC_VALUE_definition") { namespace swig { struct stop_iteration { }; /** * Abstract base class used to represent all iterators of STL containers. */ struct ConstIterator { public: typedef ConstIterator self_type; protected: GC_VALUE _seq; protected: ConstIterator(VALUE seq) : _seq(seq) { } // Random access iterator methods, but not required in Ruby virtual ptrdiff_t distance(const ConstIterator &x) const { throw std::invalid_argument("distance not supported"); } virtual bool equal (const ConstIterator &x) const { throw std::invalid_argument("equal not supported"); } virtual self_type* advance(ptrdiff_t n) { throw std::invalid_argument("advance not supported"); } public: virtual ~ConstIterator() {} // Access iterator method, required by Ruby virtual VALUE value() const { throw std::invalid_argument("value not supported"); return Qnil; }; virtual VALUE setValue( const VALUE& v ) { throw std::invalid_argument("value= not supported"); return Qnil; } virtual self_type* next( size_t n = 1 ) { return this->advance( n ); } virtual self_type* previous( size_t n = 1 ) { ptrdiff_t nn = n; return this->advance( -nn ); } virtual VALUE to_s() const { throw std::invalid_argument("to_s not supported"); return Qnil; } virtual VALUE inspect() const { throw std::invalid_argument("inspect not supported"); return Qnil; } virtual ConstIterator *dup() const { throw std::invalid_argument("dup not supported"); return NULL; } // // C++ common/needed methods. We emulate a bidirectional // operator, to be compatible with all the STL. // The iterator traits will then tell the STL what type of // iterator we really are. // ConstIterator() : _seq( Qnil ) { } ConstIterator( const self_type& b ) : _seq( b._seq ) { } self_type& operator=( const self_type& b ) { _seq = b._seq; return *this; } bool operator == (const ConstIterator& x) const { return equal(x); } bool operator != (const ConstIterator& x) const { return ! operator==(x); } // Pre-decrement operator self_type& operator--() { return *previous(); } // Pre-increment operator self_type& operator++() { return *next(); } // Post-decrement operator self_type operator--(int) { self_type r = *this; previous(); return r; } // Post-increment operator self_type operator++(int) { self_type r = *this; next(); return r; } ConstIterator& operator += (ptrdiff_t n) { return *advance(n); } ConstIterator& operator -= (ptrdiff_t n) { return *advance(-n); } ConstIterator* operator + (ptrdiff_t n) const { return dup()->advance(n); } ConstIterator* operator - (ptrdiff_t n) const { return dup()->advance(-n); } ptrdiff_t operator - (const ConstIterator& x) const { return x.distance(*this); } static swig_type_info* descriptor() { static int init = 0; static swig_type_info* desc = 0; if (!init) { desc = SWIG_TypeQuery("swig::ConstIterator *"); init = 1; } return desc; } }; /** * Abstract base class used to represent all non-const iterators of STL containers. * */ struct Iterator : public ConstIterator { public: typedef Iterator self_type; protected: Iterator(VALUE seq) : ConstIterator(seq) { } virtual self_type* advance(ptrdiff_t n) { throw std::invalid_argument("operation not supported"); } public: static swig_type_info* descriptor() { static int init = 0; static swig_type_info* desc = 0; if (!init) { desc = SWIG_TypeQuery("swig::Iterator *"); init = 1; } return desc; } virtual Iterator *dup() const { throw std::invalid_argument("dup not supported"); return NULL; } virtual self_type* next( size_t n = 1 ) { return this->advance( n ); } virtual self_type* previous( size_t n = 1 ) { ptrdiff_t nn = n; return this->advance( -nn ); } bool operator == (const ConstIterator& x) const { return equal(x); } bool operator != (const Iterator& x) const { return ! operator==(x); } Iterator& operator += (ptrdiff_t n) { return *advance(n); } Iterator& operator -= (ptrdiff_t n) { return *advance(-n); } Iterator* operator + (ptrdiff_t n) const { return dup()->advance(n); } Iterator* operator - (ptrdiff_t n) const { return dup()->advance(-n); } ptrdiff_t operator - (const Iterator& x) const { return x.distance(*this); } }; } } %fragment("ConstIterator_T","header",fragment="",fragment="ConstIterator",fragment="StdTraits",fragment="StdIteratorTraits") { namespace swig { /** * Templated base classes for all custom const_iterators. * */ template class ConstIterator_T : public ConstIterator { public: typedef OutConstIterator const_iter; typedef typename std::iterator_traits::value_type value_type; typedef ConstIterator_T self_type; protected: virtual bool equal (const ConstIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return (current == iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } virtual ptrdiff_t distance(const ConstIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return std::distance(current, iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } virtual ConstIterator* advance(ptrdiff_t n) { std::advance( current, n ); return this; } public: ConstIterator_T() : ConstIterator(Qnil) { } ConstIterator_T(const_iter curr, VALUE seq = Qnil) : ConstIterator(seq), current(curr) { } const const_iter& get_current() const { return current; } const value_type& operator*() const { return *current; } virtual VALUE inspect() const { VALUE ret = rb_str_new2("#<"); ret = rb_str_cat2( ret, rb_obj_classname(_seq) ); ret = rb_str_cat2( ret, "::const_iterator " ); VALUE cur = value(); ret = rb_str_concat( ret, rb_inspect(cur) ); ret = rb_str_cat2( ret, ">" ); return ret; } virtual VALUE to_s() const { VALUE ret = rb_str_new2( rb_obj_classname(_seq) ); ret = rb_str_cat2( ret, "::const_iterator " ); VALUE cur = value(); ret = rb_str_concat( ret, rb_obj_as_string(cur) ); return ret; } protected: const_iter current; }; /** * Templated base classes for all custom non-const iterators. * */ template class Iterator_T : public Iterator { public: typedef InOutIterator nonconst_iter; // Make this class iterator STL compatible, by using iterator_traits typedef typename std::iterator_traits::iterator_category iterator_category; typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::pointer pointer; typedef typename std::iterator_traits::reference reference; typedef Iterator base; typedef Iterator_T< nonconst_iter > self_type; protected: virtual bool equal (const ConstIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return (current == iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } virtual ptrdiff_t distance(const ConstIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return std::distance(current, iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } virtual Iterator* advance(ptrdiff_t n) { std::advance( current, n ); return this; } public: Iterator_T(nonconst_iter curr, VALUE seq = Qnil) : Iterator(seq), current(curr) { } const nonconst_iter& get_current() const { return current; } self_type& operator=( const self_type& b ) { base::operator=( b ); return *this; } self_type& operator=( const value_type& b ) { *current = b; return *this; } const value_type& operator*() const { return *current; } value_type& operator*() { return *current; } virtual VALUE inspect() const { VALUE ret = rb_str_new2("#<"); ret = rb_str_cat2( ret, rb_obj_classname(_seq) ); ret = rb_str_cat2( ret, "::iterator " ); VALUE cur = value(); ret = rb_str_concat( ret, rb_inspect(cur) ); ret = rb_str_cat2( ret, ">" ); return ret; } virtual VALUE to_s() const { VALUE ret = rb_str_new2( rb_obj_classname(_seq) ); ret = rb_str_cat2( ret, "::iterator " ); VALUE cur = value(); ret = rb_str_concat( ret, rb_obj_as_string(cur) ); return ret; } protected: nonconst_iter current; }; /** * Auxiliary functor to store the value of a ruby object inside * a reference of a compatible C++ type. ie: Ruby -> C++ * */ template struct asval_oper { typedef ValueType value_type; typedef bool result_type; bool operator()(VALUE obj, value_type& v) const { return ( swig::asval< value_type >(obj, &v) == SWIG_OK ); } }; /** * Auxiliary functor to return a ruby object from a C++ type. * ie: C++ -> Ruby * */ template struct from_oper { typedef const ValueType& argument_type; typedef VALUE result_type; result_type operator()(argument_type v) const { return swig::from(v); } }; /** * ConstIterator class for a const_iterator with no end() boundaries. * */ template::value_type, typename FromOper = from_oper > class ConstIteratorOpen_T : public ConstIterator_T { public: FromOper from; typedef OutConstIterator const_iter; typedef ValueType value_type; typedef ConstIterator_T base; typedef ConstIteratorOpen_T self_type; ConstIteratorOpen_T(const_iter curr, VALUE seq = Qnil) : ConstIterator_T(curr, seq) { } virtual VALUE value() const { return from(static_cast(*(base::current))); } ConstIterator *dup() const { return new self_type(*this); } }; /** * Iterator class for an iterator with no end() boundaries. * */ template::value_type, typename FromOper = from_oper, typename AsvalOper = asval_oper > class IteratorOpen_T : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef ValueType value_type; typedef Iterator_T base; typedef IteratorOpen_T self_type; public: IteratorOpen_T(nonconst_iter curr, VALUE seq = Qnil) : Iterator_T(curr, seq) { } virtual VALUE value() const { return from(static_cast(*(base::current))); } virtual VALUE setValue( const VALUE& v ) { value_type& dst = *base::current; if ( asval(v, dst) ) return v; return Qnil; } Iterator *dup() const { return new self_type(*this); } }; /** * ConstIterator class for a const_iterator where begin() and end() boundaries are known. * */ template::value_type, typename FromOper = from_oper > class ConstIteratorClosed_T : public ConstIterator_T { public: FromOper from; typedef OutConstIterator const_iter; typedef ValueType value_type; typedef ConstIterator_T base; typedef ConstIteratorClosed_T self_type; protected: virtual ConstIterator* advance(ptrdiff_t n) { std::advance( base::current, n ); if ( base::current == end ) throw stop_iteration(); return this; } public: ConstIteratorClosed_T(const_iter curr, const_iter first, const_iter last, VALUE seq = Qnil) : ConstIterator_T(curr, seq), begin(first), end(last) { } virtual VALUE value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } ConstIterator *dup() const { return new self_type(*this); } private: const_iter begin; const_iter end; }; /** * Iterator class for a iterator where begin() and end() boundaries are known. * */ template::value_type, typename FromOper = from_oper, typename AsvalOper = asval_oper > class IteratorClosed_T : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef ValueType value_type; typedef Iterator_T base; typedef IteratorClosed_T self_type; protected: virtual Iterator* advance(ptrdiff_t n) { std::advance( base::current, n ); if ( base::current == end ) throw stop_iteration(); return this; } public: IteratorClosed_T(nonconst_iter curr, nonconst_iter first, nonconst_iter last, VALUE seq = Qnil) : Iterator_T(curr, seq), begin(first), end(last) { } virtual VALUE value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } // Iterator setter method, required by Ruby virtual VALUE setValue( const VALUE& v ) { if (base::current == end) throw stop_iteration(); value_type& dst = *base::current; if ( asval( v, dst ) ) return v; return Qnil; } Iterator *dup() const { return new self_type(*this); } private: nonconst_iter begin; nonconst_iter end; }; /* Partial specialization for bools which don't allow de-referencing */ template< typename InOutIterator, typename FromOper, typename AsvalOper > class IteratorOpen_T< InOutIterator, bool, FromOper, AsvalOper > : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef bool value_type; typedef Iterator_T base; typedef IteratorOpen_T self_type; IteratorOpen_T(nonconst_iter curr, VALUE seq = Qnil) : Iterator_T(curr, seq) { } virtual VALUE value() const { return from(static_cast(*(base::current))); } virtual VALUE setValue( const VALUE& v ) { bool tmp = *base::current; if ( asval( v, tmp ) ) { *base::current = tmp; return v; } return Qnil; } Iterator *dup() const { return new self_type(*this); } }; /* Partial specialization for bools which don't allow de-referencing */ template< typename InOutIterator, typename FromOper, typename AsvalOper > class IteratorClosed_T< InOutIterator, bool, FromOper, AsvalOper > : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef bool value_type; typedef Iterator_T base; typedef IteratorClosed_T self_type; protected: virtual Iterator* advance(ptrdiff_t n) { std::advance( base::current, n ); if ( base::current == end ) throw stop_iteration(); return this; } public: IteratorClosed_T(nonconst_iter curr, nonconst_iter first, nonconst_iter last, VALUE seq = Qnil) : Iterator_T(curr, seq), begin(first), end(last) { } virtual VALUE value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } virtual VALUE setValue( const VALUE& v ) { if (base::current == end) throw stop_iteration(); bool tmp = *base::current; if ( asval( v, tmp ) ) { *base::current = tmp; return v; } return Qnil; } Iterator *dup() const { return new self_type(*this); } private: nonconst_iter begin; nonconst_iter end; }; /** * Helper function used to wrap a bounded const_iterator. This is to be used in * a %typemap(out), for example. * */ template inline Iterator* make_nonconst_iterator(const InOutIter& current, const InOutIter& begin, const InOutIter& end, VALUE seq = Qnil) { return new IteratorClosed_T(current, begin, end, seq); } /** * Helper function used to wrap an unbounded const_iterator. This is to be used in * a %typemap(out), for example. * */ template inline Iterator* make_nonconst_iterator(const InOutIter& current, VALUE seq = Qnil) { return new IteratorOpen_T(current, seq); } /** * Helper function used to wrap a bounded const_iterator. This is to be used in * a %typemap(out), for example. * */ template inline ConstIterator* make_const_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, VALUE seq = Qnil) { return new ConstIteratorClosed_T(current, begin, end, seq); } /** * Helper function used to wrap an unbounded const_iterator. This is to be used in * a %typemap(out), for example. * */ template inline ConstIterator* make_const_iterator(const OutIter& current, VALUE seq = Qnil) { return new ConstIteratorOpen_T(current, seq); } } } %fragment("ConstIterator"); // // This part is just so SWIG is aware of the base abstract iterator class. // namespace swig { /* Throw a StopIteration exception */ %ignore stop_iteration; struct stop_iteration {}; %typemap(throws) stop_iteration { (void)$1; SWIG_Ruby_ExceptionType(NULL, Qnil); SWIG_fail; } /* Mark methods that return new objects */ %newobject ConstIterator::dup; %newobject ConstIterator::operator + (ptrdiff_t n) const; %newobject ConstIterator::operator - (ptrdiff_t n) const; %nodirector ConstIterator; %catches(swig::stop_iteration) ConstIterator::value() const; %catches(swig::stop_iteration) ConstIterator::incr(size_t n = 1); %catches(swig::stop_iteration) ConstIterator::decr(size_t n = 1); %catches(std::invalid_argument) ConstIterator::distance(const ConstIterator &x) const; %catches(std::invalid_argument) ConstIterator::equal (const ConstIterator &x) const; %catches(swig::stop_iteration) ConstIterator::next(); %catches(swig::stop_iteration) ConstIterator::previous(); %catches(swig::stop_iteration) ConstIterator::advance(ptrdiff_t n); %catches(swig::stop_iteration) ConstIterator::operator += (ptrdiff_t n); %catches(swig::stop_iteration) ConstIterator::operator -= (ptrdiff_t n); %catches(swig::stop_iteration) ConstIterator::operator + (ptrdiff_t n) const; %catches(swig::stop_iteration) ConstIterator::operator - (ptrdiff_t n) const; struct ConstIterator { protected: ConstIterator(VALUE seq); public: virtual ~ConstIterator(); // Access iterator method, required by Ruby virtual VALUE value() const; // C++ common/needed methods virtual ConstIterator *dup() const; virtual VALUE inspect() const; virtual VALUE to_s() const; virtual ConstIterator* next(size_t n = 1); virtual ConstIterator* previous(size_t n = 1); bool operator == (const ConstIterator& x) const; ConstIterator* operator + (ptrdiff_t n) const; ConstIterator* operator - (ptrdiff_t n) const; ptrdiff_t operator - (const ConstIterator& x) const; }; struct Iterator : public ConstIterator { %rename("value=") setValue( const VALUE& v ); virtual VALUE setValue( const VALUE& v ); virtual Iterator *dup() const; virtual Iterator* next(size_t n = 1); virtual Iterator* previous(size_t n = 1); virtual VALUE inspect() const; virtual VALUE to_s() const; bool operator == (const Iterator& x) const; Iterator* operator + (ptrdiff_t n) const; Iterator* operator - (ptrdiff_t n) const; ptrdiff_t operator - (const Iterator& x) const; }; } swig-3.0.2/Lib/ruby/rubystdcommon.swg0000664000175000017500000001201512343605122017460 0ustar williamwilliam /* ------------------------------------------------------------ * The Ruby classes, for C++ * ------------------------------------------------------------ */ %include %fragment("StdTraits","header",fragment="StdTraitsCommon") { namespace swig { /* Traits that provides the from method */ template struct traits_from_ptr { static VALUE from(Type *val, int owner = 0) { return SWIG_NewPointerObj(val, type_info(), owner); } }; template struct traits_from { static VALUE from(const Type& val) { return traits_from_ptr::from(new Type(val), 1); } }; template struct traits_from { static VALUE from(Type* val) { return traits_from_ptr::from(val, 0); } }; template struct traits_from { static VALUE from(const Type* val) { return traits_from_ptr::from(const_cast(val), 0); } }; template inline VALUE from(const Type& val) { return traits_from::from(val); } template inline VALUE from_ptr(Type* val, int owner) { return traits_from_ptr::from(val, owner); } /* Traits that provides the asval/as/check method */ template struct traits_asptr { static int asptr(VALUE obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template inline int asptr(VALUE obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } template struct traits_asval { static int asval(VALUE obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); if (!SWIG_IsOK(res)) return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; if (SWIG_IsNewObj(res)){ %delete(p); res = SWIG_DelNewMask(res); } return res; } else { return SWIG_ERROR; } } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template struct traits_asval { static int asval(VALUE obj, Type **val) { if (val) { typedef typename noconst_traits::noconst_type noconst_type; noconst_type *p = 0; int res = traits_asptr::asptr(obj, &p); if (SWIG_IsOK(res)) { *(const_cast(val)) = p; } return res; } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template inline int asval(VALUE obj, Type *val) { return traits_asval::asval(obj, val); } template struct traits_as { static Type as(VALUE obj, bool throw_error) { Type v; int res = asval(obj, &v); if (!obj || !SWIG_IsOK(res)) { if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { %type_error(swig::type_name()); } } return v; } }; template struct traits_as { static Type as(VALUE obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { Type r(*v); %delete(v); return r; } else { return *v; } } else { // Uninitialized return value, no Type() constructor required. if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { %type_error(swig::type_name()); } static Type *v_def = (Type*) malloc(sizeof(Type)); memset(v_def,0,sizeof(Type)); return *v_def; } } }; template struct traits_as { static Type* as(VALUE obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res)) { return v; } else { if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { %type_error(swig::type_name()); } return 0; } } }; template inline Type as(VALUE obj, bool te = false) { return traits_as< Type, typename traits< Type >::category >::as(obj, te); } template struct traits_check { static bool check(VALUE obj) { int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { static bool check(VALUE obj) { int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template inline bool check(VALUE obj) { return traits_check::category>::check(obj); } } } swig-3.0.2/Lib/ruby/std_streambuf.i0000664000175000017500000000003712343605122017046 0ustar williamwilliam%include swig-3.0.2/Lib/ruby/attribute.i0000664000175000017500000000004212343605122016203 0ustar williamwilliam%include swig-3.0.2/Lib/ruby/jstring.i0000664000175000017500000000167012343605122015670 0ustar williamwilliam%include %fragment(SWIG_AsVal_frag(jstring),"header") { SWIGINTERN int SWIG_AsVal(jstring)(VALUE obj, jstring *val) { if (NIL_P(obj)){ if (val) *val = 0; return SWIG_OK; } if (TYPE(obj) == T_STRING) { if (val) { char *cstr = rb_string_value_ptr(&(obj)); jsize len = RSTRING_LEN(obj); *val = JvNewStringLatin1(cstr, len); } return SWIG_NEWOBJ; } return SWIG_TypeError; } } %fragment(SWIG_From_frag(jstring),"header") { SWIGINTERNINLINE VALUE SWIG_From(jstring)(jstring val) { if (!val) { return Qnil; } else { jint len = JvGetStringUTFLength(val); char buf[len]; JvGetStringUTFRegion(val, 0, len, buf); return rb_str_new(buf,len); } } } %typemaps_asvalfrom(%checkcode(STRING), %arg(SWIG_AsVal(jstring)), %arg(SWIG_From(jstring)), %arg(SWIG_AsVal_frag(jstring)), %arg(SWIG_From_frag(jstring)), java::lang::String *); swig-3.0.2/Lib/ruby/rubykw.swg0000664000175000017500000000223112343605122016075 0ustar williamwilliam#ifndef RUBY_RUBYKW_SWG_ #define RUBY_RUBYKW_SWG_ /* Warnings for Ruby keywords */ #define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, renaming to 'C_" `x` "'",rename="C_%s",fullname=1) `x` /* from http://www.rubycentral.com/book/language.html */ RUBYKW(BEGIN); RUBYKW(END); RUBYKW(alias); RUBYKW(and); RUBYKW(begin); RUBYKW(break); RUBYKW(case); RUBYKW(class); RUBYKW(def); RUBYKW("defined"); RUBYKW(do); RUBYKW(else); RUBYKW(elsif); RUBYKW(end); RUBYKW(ensure); RUBYKW(false); RUBYKW(fatal); RUBYKW(for); RUBYKW(if); RUBYKW(in); RUBYKW(module); RUBYKW(next); RUBYKW(nil); RUBYKW(not); RUBYKW(or); RUBYKW(redo); RUBYKW(rescue); RUBYKW(retry); RUBYKW(return); RUBYKW(self); RUBYKW(super); RUBYKW(then); RUBYKW(true); RUBYKW(undef); RUBYKW(unless); RUBYKW(until); RUBYKW(when); RUBYKW(while); RUBYKW(yield); // RUBYKW(FalseClass); // RUBYKW(TrueClass); // RUBYKW(Numeric); // RUBYKW(Integer); // RUBYKW(Fixnum); // RUBYKW(Float); // RUBYKW(Range); // RUBYKW(Array); // RUBYKW(String); // RUBYKW(IO); // RUBYKW(File); // RUBYKW(FileUtils); // RUBYKW(Find); // RUBYKW(Struct); // RUBYKW(OpenStruct); // RUBYKW(Regexp); #undef RUBYKW #endif //RUBY_RUBYKW_SWG_ swig-3.0.2/Lib/ruby/cdata.i0000664000175000017500000000003612343605122015257 0ustar williamwilliam%include swig-3.0.2/Lib/ruby/rubycontainer.swg0000664000175000017500000006467212343605122017457 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubycontainer.swg * * Ruby sequence <-> C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of * the mapping between C++ and Ruby, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should * be the case. * ----------------------------------------------------------------------------- */ %{ #include %} #if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) # if !defined(SWIG_EXPORT_ITERATOR_METHODS) # define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS # endif #endif %include /**** The RubySequence C++ Wrap ***/ %fragment(""); %include %fragment("RubySequence_Base","header") { %#include namespace swig { template < class T > struct yield : public std::unary_function< T, bool > { bool operator()( const T& v ) const { return RTEST( rb_yield( swig::from< T >(v) ) ); } }; inline size_t check_index(ptrdiff_t i, size_t size, bool insert = false) { if ( i < 0 ) { if ((size_t) (-i) <= size) return (size_t) (i + size); } else if ( (size_t) i < size ) { return (size_t) i; } else if (insert && ((size_t) i == size)) { return size; } throw std::out_of_range("index out of range"); } inline size_t slice_index(ptrdiff_t i, size_t size) { if ( i < 0 ) { if ((size_t) (-i) <= size) { return (size_t) (i + size); } else { throw std::out_of_range("index out of range"); } } else { return ( (size_t) i < size ) ? ((size_t) i) : size; } } template inline typename Sequence::iterator getpos(Sequence* self, Difference i) { typename Sequence::iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline typename Sequence::const_iterator cgetpos(const Sequence* self, Difference i) { typename Sequence::const_iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline Sequence* getslice(const Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::const_iterator vb = self->begin(); typename Sequence::const_iterator ve = self->begin(); std::advance(vb,ii); std::advance(ve,jj); return new Sequence(vb, ve); } else { return new Sequence(); } } template inline void setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj < ii) jj = ii; size_t ssize = jj - ii; if (ssize <= v.size()) { typename Sequence::iterator sb = self->begin(); typename InputSeq::const_iterator vmid = v.begin(); std::advance(sb,ii); std::advance(vmid, jj - ii); self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end()); } else { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); self->insert(sb, v.begin(), v.end()); } } template inline void delslice(Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); } } } } %fragment("RubySequence_Cont","header", fragment="", fragment="StdTraits", fragment="RubySequence_Base", fragment="ConstIterator_T") { namespace swig { /** * This class is a proxy class for references, used to return and set values * of an element of a Ruby Array of stuff. * It can be used by RubySequence_InputIterator to make it work with STL * algorithms. * */ template struct RubySequence_Ref { RubySequence_Ref(VALUE seq, int index) : _seq(seq), _index(index) { } operator T () const { VALUE item = rb_ary_entry(_seq, _index ); try { return swig::as(item, true); } catch (std::exception& e) { char msg[1024]; sprintf(msg, "in sequence element %d ", _index); VALUE lastErr = rb_gv_get("$!"); if ( lastErr == Qnil ) { %type_error(swig::type_name()); } VALUE str = rb_str_new2(msg); str = rb_str_cat2( str, e.what() ); SWIG_Ruby_ExceptionType( NULL, str ); throw; } } RubySequence_Ref& operator=(const T& v) { rb_ary_set(_seq, _index, swig::from< T >(v)); return *this; } private: VALUE _seq; int _index; }; /** * This class is a proxy to return a pointer to a class, usually * RubySequence_Ref. * It can be used by RubySequence_InputIterator to make it work with STL * algorithms. * */ template struct RubySequence_ArrowProxy { RubySequence_ArrowProxy(const T& x): m_value(x) {} const T* operator->() const { return &m_value; } operator const T*() const { return &m_value; } T m_value; }; /** * Input Iterator. This adapator class is a random access iterator that * allows you to use STL algorithms with a Ruby class (a Ruby Array by default). * */ template > struct RubySequence_InputIterator { typedef RubySequence_InputIterator self; typedef std::random_access_iterator_tag iterator_category; typedef Reference reference; typedef T value_type; typedef T* pointer; typedef ptrdiff_t difference_type; RubySequence_InputIterator() { } RubySequence_InputIterator(VALUE seq, int index) : _seq(seq), _index(index) { } reference operator*() const { return reference(_seq, _index); } RubySequence_ArrowProxy operator->() const { return RubySequence_ArrowProxy(operator*()); } bool operator==(const self& ri) const { return (_index == ri._index) && (_seq == ri._seq); } bool operator!=(const self& ri) const { return !(operator==(ri)); } self& operator ++ () { ++_index; return *this; } self& operator -- () { --_index; return *this; } self& operator += (difference_type n) { _index += n; return *this; } self operator +(difference_type n) const { return self(_seq, _index + n); } self& operator -= (difference_type n) { _index -= n; return *this; } self operator -(difference_type n) const { return self(_seq, _index - n); } difference_type operator - (const self& ri) const { return _index - ri._index; } bool operator < (const self& ri) const { return _index < ri._index; } reference operator[](difference_type n) const { return reference(_seq, _index + n); } private: VALUE _seq; difference_type _index; }; /** * This adaptor class allows you to use a Ruby Array as if it was an STL * container, giving it begin(), end(), and iterators. * */ template struct RubySequence_Cont { typedef RubySequence_Ref reference; typedef const RubySequence_Ref const_reference; typedef T value_type; typedef T* pointer; typedef int difference_type; typedef int size_type; typedef const pointer const_pointer; typedef RubySequence_InputIterator iterator; typedef RubySequence_InputIterator const_iterator; RubySequence_Cont(VALUE seq) : _seq(0) { if (!rb_obj_is_kind_of(seq, rb_cArray)) { throw std::invalid_argument("an Array is expected"); } _seq = seq; } ~RubySequence_Cont() { } size_type size() const { return RARRAY_LEN(_seq); } bool empty() const { return size() == 0; } iterator begin() { return iterator(_seq, 0); } const_iterator begin() const { return const_iterator(_seq, 0); } iterator end() { return iterator(_seq, size()); } const_iterator end() const { return const_iterator(_seq, size()); } reference operator[](difference_type n) { return reference(_seq, n); } const_reference operator[](difference_type n) const { return const_reference(_seq, n); } bool check(bool set_err = false) const { int s = (int) size(); for (int i = 0; i < s; ++i) { VALUE item = rb_ary_entry(_seq, i ); if (!swig::check(item)) { if (set_err) { char msg[1024]; sprintf(msg, "in sequence element %d", i); SWIG_Error(SWIG_RuntimeError, msg); } return false; } } return true; } private: VALUE _seq; }; } } /** * Macros used to typemap an STL iterator -> SWIGIterator conversion. * */ %define %swig_sequence_iterator(Sequence...) #if defined(SWIG_EXPORT_ITERATOR_METHODS) %typemap(out,noblock=1,fragment="RubySequence_Cont") const_iterator, const_reverse_iterator { $result = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &), self), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); } %typemap(out,noblock=1,fragment="RubySequence_Cont") iterator, reverse_iterator { $result = SWIG_NewPointerObj(swig::make_nonconst_iterator(%static_cast($1,const $type &), self), swig::Iterator::descriptor(),SWIG_POINTER_OWN); } %typemap(out,noblock=1,fragment="RubySequence_Cont") std::pair { $result = rb_ary_new2(2); rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); } // std::map/multimap/set allow returning std::pair< iterator, iterator > from // equal_range, but we cannot still modify the key, so the iterator is // const. %typemap(out,noblock=1,fragment="RubySequence_Cont") std::pair { $result = rb_ary_new2(2); rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); } %typemap(in,noblock=1,fragment="RubySequence_Cont") const_iterator(swig::ConstIterator *iter = 0, int res), const_reverse_iterator(swig::ConstIterator *iter = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::ConstIterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { swig::ConstIterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } } } %typemap(in,noblock=1,fragment="RubySequence_Cont") iterator(swig::Iterator *iter = 0, int res), reverse_iterator(swig::Iterator *iter = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::Iterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { swig::Iterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } } } %typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont") const_iterator, const_reverse_iterator { swig::ConstIterator *iter = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::ConstIterator::descriptor(), 0); $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } %typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont") iterator, reverse_iterator { swig::ConstIterator *iter = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::Iterator::descriptor(), 0); $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } %fragment("RubySequence_Cont"); // %newobject iterator; // %newobject const_iterator; // %extend { // swig::Iterator* iterator(VALUE* RUBY_SELF) { // return swig::make_nonconst_iterator($self->begin(), $self->begin(), // $self->end(), *RUBY_SELF); // } // swig::ConstIterator* const_iterator(VALUE* RUBY_SELF) { // return swig::make_const_iterator($self->begin(), $self->begin(), // $self->end(), *RUBY_SELF); // } // } #endif //SWIG_EXPORT_ITERATOR_METHODS %enddef /**** The Ruby container methods ****/ %define %swig_container_methods(Container...) %extend { %newobject dup; Container* dup() { return new Container(*$self); } } %enddef /** * Macro used to define common Ruby printing methods for STL container * */ %define %swig_sequence_printing_methods(Sequence...) %extend { VALUE inspect() { Sequence::const_iterator i = $self->begin(); Sequence::const_iterator e = $self->end(); const char *type_name = swig::type_name< Sequence >(); VALUE str = rb_str_new2(type_name); str = rb_str_cat2( str, " [" ); bool comma = false; VALUE tmp; for ( ; i != e; ++i, comma = true ) { if (comma) str = rb_str_cat2( str, "," ); tmp = swig::from< Sequence::value_type >( *i ); tmp = rb_inspect( tmp ); str = rb_str_buf_append( str, tmp ); } str = rb_str_cat2( str, "]" ); return str; } VALUE to_a() { Sequence::const_iterator i = $self->begin(); Sequence::const_iterator e = $self->end(); VALUE ary = rb_ary_new2( std::distance( i, e ) ); VALUE tmp; for ( ; i != e; ++i ) { tmp = swig::from< Sequence::value_type >( *i ); rb_ary_push( ary, tmp ); } return ary; } VALUE to_s() { Sequence::iterator i = $self->begin(); Sequence::iterator e = $self->end(); VALUE str = rb_str_new2( "" ); VALUE tmp; for ( ; i != e; ++i ) { tmp = swig::from< Sequence::value_type >( *i ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); } return str; } } %enddef /** * Macro used to add common methods to all STL sequence-type containers * */ %define %swig_sequence_methods_common(Sequence...) %swig_container_methods(%arg(Sequence)) %swig_sequence_iterator(%arg(Sequence)) %swig_sequence_printing_methods(%arg(Sequence)) %fragment("RubySequence_Base"); %extend { VALUE slice( difference_type i, difference_type j ) { if ( j <= 0 ) return Qnil; std::size_t len = $self->size(); if ( i < 0 ) i = len - i; j += i; if ( static_cast(j) >= len ) j = len-1; VALUE r = Qnil; try { r = swig::from< const Sequence* >( swig::getslice(self, i, j) ); } catch( std::out_of_range ) { } return r; } Sequence* each() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given"); VALUE r; Sequence::const_iterator i = self->begin(); Sequence::const_iterator e = self->end(); for ( ; i != e; ++i ) { r = swig::from< Sequence::value_type >(*i); rb_yield(r); } return self; } %newobject select; Sequence* select() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); Sequence* r = new Sequence; Sequence::const_iterator i = $self->begin(); Sequence::const_iterator e = $self->end(); for ( ; i != e; ++i ) { VALUE v = swig::from< Sequence::value_type >(*i); if ( RTEST( rb_yield(v) ) ) $self->insert( r->end(), *i); } return r; } VALUE delete_at(difference_type i) { VALUE r = Qnil; try { Sequence::iterator at = swig::getpos(self, i); r = swig::from< Sequence::value_type >( *(at) ); $self->erase(at); } catch (std::out_of_range) { } return r; } VALUE __delete2__(const value_type& i) { VALUE r = Qnil; return r; } } %enddef /** * Macro used to add functions for back insertion of values in * STL Sequence containers * */ %define %swig_sequence_back_inserters( Sequence... ) %extend { VALUE pop() { if ($self->empty()) return Qnil; Sequence::value_type x = self->back(); $self->pop_back(); return swig::from< Sequence::value_type >( x ); } %alias push "<<"; const value_type push( const value_type& e ) { $self->push_back( e ); return e; } %newobject reject; Sequence* reject() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); Sequence* r = new Sequence; std::remove_copy_if( $self->begin(), $self->end(), std::back_inserter(*r), swig::yield< Sequence::value_type >() ); return r; } } %enddef %define %swig_sequence_methods_extra(Sequence...) %extend { %alias reject_bang "delete_if"; Sequence* reject_bang() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); $self->erase( std::remove_if( $self->begin(), $self->end(), swig::yield< Sequence::value_type >() ), $self->end() ); return $self; } } %enddef /** * Macro used to add functions for Sequences * */ %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_common(%arg(Sequence)); %swig_sequence_methods_extra(%arg(Sequence)); %swig_sequence_back_inserters(%arg(Sequence)); %extend { VALUE at(difference_type i) const { VALUE r = Qnil; try { r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); } catch( std::out_of_range ) { } return r; } VALUE __getitem__(difference_type i, difference_type j) const { if ( j <= 0 ) return Qnil; std::size_t len = $self->size(); if ( i < 0 ) i = len - i; j += i; if ( static_cast(j) >= len ) j = len-1; VALUE r = Qnil; try { r = swig::from< const Sequence* >( swig::getslice(self, i, j) ); } catch( std::out_of_range ) { } return r; } VALUE __getitem__(difference_type i) const { VALUE r = Qnil; try { r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); } catch( std::out_of_range ) { } return r; } VALUE __getitem__(VALUE i) const { if ( rb_obj_is_kind_of( i, rb_cRange ) == Qfalse ) { rb_raise( rb_eTypeError, "not a valid index or range" ); } static ID id_end = rb_intern("end"); static ID id_start = rb_intern("begin"); static ID id_noend = rb_intern("exclude_end?"); VALUE start = rb_funcall( i, id_start, 0 ); VALUE end = rb_funcall( i, id_end, 0 ); bool noend = ( rb_funcall( i, id_noend, 0 ) == Qtrue ); int len = $self->size(); int s = NUM2INT( start ); if ( s < 0 ) s = len + s; else if ( s >= len ) return Qnil; int e = NUM2INT( end ); if ( e < 0 ) e = len + e; if ( e < s ) return Qnil; //std::swap( s, e ); if ( noend ) e -= 1; if ( e >= len ) e = len - 1; return swig::from< Sequence* >( swig::getslice(self, s, e+1) ); } VALUE __setitem__(difference_type i, const value_type& x) { std::size_t len = $self->size(); if ( i < 0 ) i = len - i; else if ( static_cast(i) >= len ) $self->resize( i+1, x ); else *(swig::getpos(self,i)) = x; return swig::from< Sequence::value_type >( x ); } VALUE __setitem__(difference_type i, difference_type j, const Sequence& v) throw (std::invalid_argument) { if ( j <= 0 ) return Qnil; std::size_t len = $self->size(); if ( i < 0 ) i = len - i; j += i; if ( static_cast(j) >= len ) { $self->resize( j+1, *(v.begin()) ); j = len-1; } VALUE r = Qnil; swig::setslice(self, i, j, v); r = swig::from< const Sequence* >( &v ); return r; } } %enddef %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods(%arg(Sequence)) %enddef /** * Macro used to add functions for front insertion of * elements in STL sequence containers that support it. * */ %define %swig_sequence_front_inserters( Sequence... ) %extend { VALUE shift() { if ($self->empty()) return Qnil; Sequence::value_type x = self->front(); $self->erase( $self->begin() ); return swig::from< Sequence::value_type >( x ); } %typemap(in) (int argc, VALUE* argv) { $1 = argc - 1; $2 = argv + 1; } Sequence* insert( difference_type pos, int argc, VALUE* argv, ... ) { std::size_t len = $self->size(); std::size_t i = swig::check_index( pos, len, true ); Sequence::iterator start; VALUE elem = argv[0]; int idx = 0; try { Sequence::value_type val = swig::as( elem, true ); if ( i >= len ) { $self->resize(i-1, val); return $self; } start = $self->begin(); std::advance( start, i ); $self->insert( start++, val ); for ( ++idx; idx < argc; ++idx ) { elem = argv[idx]; val = swig::as( elem ); $self->insert( start++, val ); } } catch( std::invalid_argument ) { rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", swig::type_name(), __FUNCTION__, idx+2, elem )); } return $self; } %typemap(in) (int argc, VALUE* argv) { $1 = argc; $2 = argv; } Sequence* unshift( int argc, VALUE* argv, ... ) { for ( int idx = argc-1; idx >= 0; --idx ) { Sequence::iterator start = $self->begin(); VALUE elem = argv[idx]; try { Sequence::value_type val = swig::as( elem, true ); $self->insert( start, val ); } catch( std::invalid_argument ) { rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", swig::type_name(), __FUNCTION__, idx+2, elem )); } } return $self; } } %enddef // // Common fragments // %fragment("StdSequenceTraits","header", fragment="StdTraits", fragment="RubySequence_Cont", fragment="GC_VALUE_definition") { namespace swig { template inline void assign(const RubySeq& rubyseq, Seq* seq) { // seq->assign(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr_stdseq { typedef Seq sequence; typedef T value_type; static int asptr(VALUE obj, sequence **seq) { if (rb_obj_is_kind_of(obj, rb_cArray) == Qtrue) { try { RubySequence_Cont rubyseq(obj); if (seq) { sequence *pseq = new sequence(); assign(rubyseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { return rubyseq.check() ? SWIG_OK : SWIG_ERROR; } } catch (std::exception& e) { if (seq) { VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { rb_raise(rb_eTypeError, "%s", e.what()); } } return SWIG_ERROR; } } else { sequence *p; if (SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0) == SWIG_OK) { if (seq) *seq = p; return SWIG_OLDOBJ; } } return SWIG_ERROR; } }; // Partial specialization for GC_VALUE's. No need to typecheck each // element. template< class Seq > struct traits_asptr_stdseq< Seq, swig::GC_VALUE > { typedef Seq sequence; typedef swig::GC_VALUE value_type; static int asptr(VALUE obj, sequence **seq) { if (rb_obj_is_kind_of(obj, rb_cArray) == Qtrue) { try { if (seq) { RubySequence_Cont rubyseq(obj); sequence *pseq = new sequence(); assign(rubyseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { return true; } } catch (std::exception& e) { if (seq) { VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { rb_raise(rb_eTypeError, "%s", e.what()); } } return SWIG_ERROR; } } else { sequence *p; if (SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0) == SWIG_OK) { if (seq) *seq = p; return SWIG_OLDOBJ; } } return SWIG_ERROR; } }; template struct traits_from_stdseq { typedef Seq sequence; typedef T value_type; typedef typename Seq::size_type size_type; typedef typename sequence::const_iterator const_iterator; static VALUE from(const sequence& seq) { #ifdef SWIG_RUBY_EXTRA_NATIVE_CONTAINERS swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } #endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { VALUE obj = rb_ary_new2((int)size); int i = 0; for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) { rb_ary_push(obj, swig::from< value_type >(*it)); } rb_obj_freeze(obj); // treat as immutable result return obj; } else { rb_raise(rb_eRangeError,"sequence size not valid in ruby"); return Qnil; } } }; } } %include swig-3.0.2/Lib/ruby/std_functors.i0000664000175000017500000000140012343605122016714 0ustar williamwilliam/** * @file std_functors.i * @date Sun May 6 00:44:33 2007 * * @brief This file provides unary and binary functors for STL * containers, that will invoke a Ruby proc or method to do * their operation. * * You can use them in a swig file like: * * %include * %include * * %template< IntSet > std::set< int, swig::BinaryPredicate >; * * * which will then allow calling them from Ruby either like: * * # order of set is defined by C++ default * a = IntSet.new * * # sort order defined by Ruby proc * b = IntSet.new( proc { |a,b| a > b } ) * */ %include %fragment("StdFunctors"); swig-3.0.2/Lib/ruby/carrays.i0000664000175000017500000000020112343605122015641 0ustar williamwilliam%define %array_class(TYPE,NAME) %array_class_wrap(TYPE,NAME,__getitem__,__setitem__) %enddef %include swig-3.0.2/Lib/ruby/std_common.i0000664000175000017500000000444312343605122016353 0ustar williamwilliam%include %include %include /* Generate the traits for a 'primitive' type, such as 'double', for which the SWIG_AsVal and SWIG_From methods are already defined. */ %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval { typedef Type value_type; static int asval(VALUE obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from { typedef Type value_type; static VALUE from(const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit instantiations required using %template). The STL containers define the 'front' method and the typemap below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from required in the generated code for enums. */ %define %traits_enum(Type...) %fragment("SWIG_Traits_enum_"{Type},"header", fragment=SWIG_AsVal_frag(int), fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(VALUE obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; template <> struct traits_from { typedef Type value_type; static VALUE from(const value_type& val) { return SWIG_From(int)((int)val); } }; } } %typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} %enddef %include // // Generates the traits for all the known primitive // C++ types (int, double, ...) // %apply_cpptypes(%traits_ptypen); swig-3.0.2/Lib/ruby/std_list.i0000664000175000017500000000201512343605122016027 0ustar williamwilliam/* Lists */ %fragment("StdListTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::list **lis) { return traits_asptr_stdseq >::asptr(obj, lis); } }; template struct traits_from > { static VALUE from(const std::list & vec) { return traits_from_stdseq >::from(vec); } }; } %} %ignore std::list::push_back; %ignore std::list::pop_back; #define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %rename("delete") std::list::__delete__; %rename("reject!") std::list::reject_bang; %rename("map!") std::list::map_bang; %rename("empty?") std::list::empty; %rename("include?" ) std::list::__contains__ const; %rename("has_key?" ) std::list::has_key const; %alias std::list::push "<<"; %include swig-3.0.2/Lib/ruby/factory.i0000664000175000017500000000004012343605122015645 0ustar williamwilliam%include swig-3.0.2/Lib/ruby/std_alloc.i0000664000175000017500000000003312343605122016144 0ustar williamwilliam%include swig-3.0.2/Lib/ruby/exception.i0000664000175000017500000000017612343605122016206 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg);)) } swig-3.0.2/Lib/ruby/rubyopers.swg0000664000175000017500000000347412343605122016616 0ustar williamwilliam/* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus %rename(__add__) *::operator+; %rename(__pos__) *::operator+(); %rename(__pos__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-(); %rename(__neg__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; %rename(__lshift__) *::operator<<; %rename(__rshift__) *::operator>>; %rename(__and__) *::operator&; %rename(__or__) *::operator|; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; %rename(__lt__) *::operator<; %rename(__le__) *::operator<=; %rename(__gt__) *::operator>; %rename(__ge__) *::operator>=; %rename(__eq__) *::operator==; /* Special cases */ %rename(__call__) *::operator(); /* Ignored inplace operators */ %ignoreoperator(NOTEQUAL) operator!=; %ignoreoperator(PLUSEQ) operator+=; %ignoreoperator(MINUSEQ) operator-=; %ignoreoperator(MULEQ) operator*=; %ignoreoperator(DIVEQ) operator/=; %ignoreoperator(MODEQ) operator%=; %ignoreoperator(LSHIFTEQ) operator<<=; %ignoreoperator(RSHIFTEQ) operator>>=; %ignoreoperator(ANDEQ) operator&=; %ignoreoperator(OREQ) operator|=; %ignoreoperator(XOREQ) operator^=; /* Ignored operators */ %ignoreoperator(LNOT) operator!; %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; %ignoreoperator(EQ) operator=; %ignoreoperator(PLUSPLUS) operator++; %ignoreoperator(MINUSMINUS) operator--; %ignoreoperator(ARROWSTAR) operator->*; %ignoreoperator(INDEX) operator[]; #endif /* __cplusplus */ swig-3.0.2/Lib/ruby/rubywstrings.swg0000664000175000017500000000473712343605122017351 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubywstrings.swg * * Currently, Ruby does not support Unicode or WChar properly, so these * are still treated as char arrays for now. * There are other libraries available that add support to this in * ruby including WString, FXString, etc. * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * utility methods for wchar_t strings * ------------------------------------------------------------ */ %fragment("SWIG_AsWCharPtrAndSize","header",fragment="",fragment="SWIG_pwchar_descriptor",fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc) { return SWIG_AsCharPtrAndSize( obj, (char**)cptr, psize, alloc); // VALUE tmp = 0; // bool ok = false; // if ( TYPE(obj) == T_STRING ) { // if (cptr) { // obj = tmp = SWIG_Unicode_FromObject(obj); // ok = true; // } // } // if (ok) { // Py_ssize_t len = PyUnicode_GetSize(obj); // rb_notimplement(); // if (cptr) { // *cptr = %new_array(len + 1, wchar_t); // SWIG_Unicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len); // (*cptr)[len] = 0; // } // if (psize) *psize = (size_t) len + 1; // if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0; // return SWIG_OK; // } else { // swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); // if (pwchar_descriptor) { // void * vptr = 0; // if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) { // if (cptr) *cptr = (wchar_t *)vptr; // if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0; // return SWIG_OK; // } // } // } // return SWIG_TypeError; } } %fragment("SWIG_FromWCharPtrAndSize","header",fragment="",fragment="SWIG_pwchar_descriptor",fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE VALUE SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size) { return SWIG_FromCharPtrAndSize( (const char*)carray, size); // if (carray) { // if (size > INT_MAX) { // swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); // return pwchar_descriptor ? // SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : Qnil; // } else { // return SWIG_Unicode_FromWideChar(carray, %numeric_cast(size,int)); // } // } else { // return Qnil; // } } } swig-3.0.2/Lib/ruby/rubystdfunctors.swg0000664000175000017500000001014312343605122020033 0ustar williamwilliam/** * @file rubystdfunctors.swg * @date Sun May 6 00:44:33 2007 * * @brief This file provides unary and binary functors for STL * containers, that will invoke a Ruby proc or method to do * their operation. * * You can use them in a swig file like: * * %include * %include * * %template< IntSet > std::set< int, swig::BinaryPredicate<> >; * * * which will then allow calling them from Ruby either like: * * # order of set is defined by C++ default * a = IntSet.new * * # sort order defined by Ruby proc * b = IntSet.new( proc { |a,b| a > b } ) * */ %include rubyclasses.swg namespace swig { %apply GC_VALUE { UnaryPredicate, BinaryPredicate, UnaryFunction, BinaryFunction }; %typecheck(SWIG_TYPECHECK_POINTER,noblock=1) UnaryPredicate, UnaryPredicate&, UnaryFunction, UnaryFunction& { $1 = SWIG_Ruby_isCallable($input) && SWIG_Ruby_arity($input, 1); } %typecheck(SWIG_TYPECHECK_POINTER,noblock=1) BinaryPredicate, BinaryPredicate&, BinaryFunction, BinaryFunction& { $1 = SWIG_Ruby_isCallable($input) && SWIG_Ruby_arity($input, 2); } %typemap(in,noblock=1) BinaryFunction&, BinaryFunction { $1 = new swig::BinaryFunction< >($input); } %typemap(in,noblock=1) UnaryFunction&, UnaryFunction { $1 = new swig::UnaryFunction< >($input); } %typemap(in,noblock=1) BinaryPredicate&, BinaryPredicate { $1 = new swig::BinaryPredicate<>($input); } %typemap(in,noblock=1) UnaryPredicate&, UnaryPredicate { $1 = new swig::UnaryPredicate< >($input); } %ignore BinaryFunction; template< class _T = GC_VALUE > struct BinaryFunction { }; %ignore UnaryFunction; template< class _T = GC_VALUE > struct UnaryFunction { }; %ignore BinaryPredicate; template< class _T = GC_VALUE > struct BinaryPredicate { }; %ignore UnaryPredicate; template< class _T = GC_VALUE > struct UnaryPredicate { }; } %fragment("StdFunctors","header",fragment="StdTraits",fragment="GC_VALUE_definition") { namespace swig { static ID call_id = rb_intern("call"); template > struct BinaryPredicate : GC_VALUE, std::binary_function< _T, _T, bool > { BinaryPredicate(VALUE obj = Qnil) : GC_VALUE(obj) { } bool operator()(_T a, _T b) const { if (_obj != Qnil) { SWIG_RUBY_THREAD_BEGIN_BLOCK; VALUE arg1 = swig::from(a); VALUE arg2 = swig::from(b); VALUE res = rb_funcall( _obj, swig::call_id, 2, arg1, arg2); SWIG_RUBY_THREAD_END_BLOCK; return RTEST(res); } else { return _DefaultFunc()(a, b); } } }; template > struct BinaryFunction : GC_VALUE, std::binary_function< _T, _T, _T > { BinaryFunction(VALUE obj = Qnil) : GC_VALUE(obj) { } _T operator()(_T a, _T b) const { if (_obj != Qnil) { SWIG_RUBY_THREAD_BEGIN_BLOCK; VALUE arg1 = swig::from(a); VALUE arg2 = swig::from(b); VALUE res = rb_funcall( _obj, swig::call_id, 2, arg1, arg2); SWIG_RUBY_THREAD_END_BLOCK; return swig::as<_T >(res); } else { return _DefaultFunc()(a, b); } } }; template< class _T = GC_VALUE > struct UnaryPredicate : GC_VALUE, std::unary_function< _T, bool > { UnaryPredicate(VALUE obj = Qnil) : GC_VALUE(obj) { } bool operator()(_T a) const { SWIG_RUBY_THREAD_BEGIN_BLOCK; VALUE arg1 = swig::from<_T >(a); VALUE res = rb_funcall( _obj, swig::call_id, 1, arg1); SWIG_RUBY_THREAD_END_BLOCK; return RTEST(res); } }; template< class _T = GC_VALUE > struct UnaryFunction : GC_VALUE, std::unary_function< _T, _T > { UnaryFunction(VALUE obj = Qnil) : GC_VALUE(obj) { } _T operator()(_T a) const { SWIG_RUBY_THREAD_BEGIN_BLOCK; VALUE arg1 = swig::from(a); VALUE res = rb_funcall( _obj, swig::call_id, 1, VALUE(arg1)); SWIG_RUBY_THREAD_END_BLOCK; return swig::as< _T >(res); } }; } // namespace swig } swig-3.0.2/Lib/ruby/rubyautodoc.swg0000664000175000017500000001041712343605122017117 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubyautodoc.swg * * This file implements autodoc typemaps for some common ruby methods. * ----------------------------------------------------------------------------- */ %define AUTODOC(func, str) %feature("autodoc", str) func; %enddef AUTODOC(to_i, "Convert $class to an Integer"); AUTODOC(to_f, "Convert $class to a Float"); AUTODOC(coerce, "Coerce class to a number"); AUTODOC(to_a, "Convert $class to an Array"); AUTODOC(to_s, "Convert class to a String representation"); AUTODOC(inspect, "Inspect class and its contents"); AUTODOC(at, "Return element at a certain index"); AUTODOC(__getitem__, "Element accessor/slicing"); AUTODOC(__setitem__, "Element setter/slicing"); AUTODOC(slice, "Return a slice (portion of) the $class"); AUTODOC(push, "Add an element at the end of the $class"); AUTODOC(pop, "Remove and return element at the end of the $class"); AUTODOC(shift, "Remove and return element at the beginning of the $class"); AUTODOC(unshift, "Add one or more elements at the beginning of the $class"); AUTODOC(first, "Return the first element in $class"); AUTODOC(last, "Return the last element in $class"); // // Common Object methods // AUTODOC(hash, "Hashing function for class"); AUTODOC(dup, "Create a duplicate of the class and unfreeze it if needed"); AUTODOC(clone, "Create a duplicate of the class"); // // Container methods // AUTODOC(empty, "Check if $class is empty"); AUTODOC(size, "Size or Length of the $class"); AUTODOC(insert, "Insert one or more new elements in the $class"); // // Iterator methods (block) // AUTODOC(each, "Iterate thru each element in the $class. A block must be provided"); AUTODOC(find, "Find an element in the class"); AUTODOC(each_key, "Iterate thru each key element in the $class. A block must be provided"); AUTODOC(each_value, "Iterate thru each key element in the $class. A block must be provided"); AUTODOC(reject, "Iterate thru each element in the $class and reject those that fail a condition returning a new $class. A block must be provided"); AUTODOC(reject_bang, "Iterate thru each element in the $class and reject those that fail a condition. A block must be provided. $class is modified in place"); AUTODOC(select, "Iterate thru each element in the $class and select those that match a condition. A block must be provided"); AUTODOC(delete_at, "Delete an element at a certain index"); AUTODOC(__delete__, "Delete a matching element"); // // Hash methods // AUTODOC(keys, "Return an Array of key elements"); AUTODOC(values, "Return an Array of value elements"); AUTODOC(values_at, "Return an Array of value elements matching the conditions"); // // Operators // #ifdef __cplusplus AUTODOC(operator==, "Equality comparison operator"); AUTODOC(operator<=, "Lower or equal comparison operator"); AUTODOC(operator>=, "Higher or equal comparison operator"); AUTODOC(operator<, "Lower than comparison operator"); AUTODOC(operator>, "Higher than comparison operator"); AUTODOC(operator<<, "Left shifting or appending operator"); AUTODOC(operator>>, "Right shifting operator or extracting operator"); AUTODOC(operator+, "Add operator"); AUTODOC(operator-, "Substraction operator"); AUTODOC(operator+(), "Positive operator"); AUTODOC(operator-(), "Negation operator"); AUTODOC(operator&, "AND operator"); AUTODOC(operator|, "OR operator"); AUTODOC(operator^, "XOR operator"); AUTODOC(operator~, "Invert operator"); #endif AUTODOC(__eq__, "Equality comparison operator"); AUTODOC(__le__, "Lower or equal comparison operator"); AUTODOC(__ge__, "Higher or equal comparison operator"); AUTODOC(__lt__, "Lower than comparison operator"); AUTODOC(__gt__, "Higher than comparison operator"); AUTODOC(__lshift__, "Left shifting or appending operator"); AUTODOC(__rshift__, "Right shifting operator or extracting operator"); AUTODOC(__add___, "Add operator"); AUTODOC(__sub__, "Substraction operator"); AUTODOC(__pos__, "Positive operator"); AUTODOC(__neg__, "Negation operator"); AUTODOC(__and__, "AND operator"); AUTODOC(__or__, "OR operator"); AUTODOC(__xor__, "XOR operator"); AUTODOC(__negate__, "Invert operator"); AUTODOC(__pow__, "Exponential operator"); AUTODOC(__divmod__, "Modulo of division"); AUTODOC(__cmp__, "Comparison operator. Returns < 0 for less than, 0 for equal or > 1 for higher than."); swig-3.0.2/Lib/ruby/std_set.i0000664000175000017500000001460312343605122015655 0ustar williamwilliam/* Sets */ %fragment("StdSetTraits","header",fragment="",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const RubySeq& rubyseq, std::set* seq) { // seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(VALUE obj, std::set **s) { return traits_asptr_stdseq >::asptr(obj, s); } }; template struct traits_from > { static VALUE from(const std::set& vec) { return traits_from_stdseq >::from(vec); } }; /** * Set Iterator class for an iterator with no end() boundaries. * */ template::value_type, typename FromOper = from_oper, typename AsvalOper = asval_oper > class SetIteratorOpen_T : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef ValueType value_type; typedef Iterator_T base; typedef SetIteratorOpen_T self_type; public: SetIteratorOpen_T(nonconst_iter curr, VALUE seq = Qnil) : Iterator_T(curr, seq) { } virtual VALUE value() const { return from(static_cast(*(base::current))); } // no setValue allowed Iterator *dup() const { return new self_type(*this); } }; /** * Set Iterator class for a iterator where begin() and end() boundaries are known. * */ template::value_type, typename FromOper = from_oper, typename AsvalOper = asval_oper > class SetIteratorClosed_T : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef ValueType value_type; typedef Iterator_T base; typedef SetIteratorClosed_T self_type; protected: virtual Iterator* advance(ptrdiff_t n) { std::advance( base::current, n ); if ( base::current == end ) throw stop_iteration(); return this; } public: SetIteratorClosed_T(nonconst_iter curr, nonconst_iter first, nonconst_iter last, VALUE seq = Qnil) : Iterator_T(curr, seq), begin(first), end(last) { } virtual VALUE value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } // no setValue allowed Iterator *dup() const { return new self_type(*this); } private: nonconst_iter begin; nonconst_iter end; }; // Template specialization to construct a closed iterator for sets // this turns a nonconst iterator into a const one for ruby to avoid // allowing the user to change the value template< typename InOutIter > inline Iterator* make_set_nonconst_iterator(const InOutIter& current, const InOutIter& begin, const InOutIter& end, VALUE seq = Qnil) { return new SetIteratorClosed_T< InOutIter >(current, begin, end, seq); } // Template specialization to construct an open iterator for sets // this turns a nonconst iterator into a const one for ruby to avoid // allowing the user to change the value template< typename InOutIter > inline Iterator* make_set_nonconst_iterator(const InOutIter& current, VALUE seq = Qnil) { return new SetIteratorOpen_T< InOutIter >(current, seq); } } %} %define %swig_sequence_methods_extra_set(Sequence...) %extend { %alias reject_bang "delete_if"; Sequence* reject_bang() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); for ( Sequence::iterator i = $self->begin(); i != $self->end(); ) { VALUE r = swig::from< Sequence::value_type >(*i); Sequence::iterator current = i++; if ( RTEST( rb_yield(r) ) ) $self->erase(current); } return self; } } %enddef %define %swig_set_methods(set...) %swig_sequence_methods_common(%arg(set)); %swig_sequence_methods_extra_set(%arg(set)); %fragment("RubyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="RubySequence_Cont") {} // Redefine std::set iterator/reverse_iterator typemap %typemap(out,noblock=1) iterator, reverse_iterator { $result = SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,const $type &), self), swig::Iterator::descriptor(),SWIG_POINTER_OWN); } // Redefine std::set std::pair typemap %typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator") std::pair { $result = rb_ary_new2(2); rb_ary_push($result, SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first), swig::Iterator::descriptor(),SWIG_POINTER_OWN)); rb_ary_push($result, SWIG_From(bool)(%static_cast($1,const $type &).second)); } %extend { %alias push "<<"; value_type push(const value_type& x) { self->insert(x); return x; } bool __contains__(const value_type& x) { return self->find(x) != self->end(); } value_type __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } }; %enddef %mixin std::set "Enumerable"; %rename("delete") std::set::__delete__; %rename("reject!") std::set::reject_bang; %rename("map!") std::set::map_bang; %rename("empty?") std::set::empty; %rename("include?" ) std::set::__contains__ const; %rename("has_key?" ) std::set::has_key const; %alias std::set::push "<<"; %include swig-3.0.2/Lib/ruby/Makefile.swig0000664000175000017500000000165612343605122016452 0ustar williamwilliam# File : Makefile.swig # Makefile for a SWIG module. Use this file if you are # producing a Ruby extension for general use or distribution. # # 1. Prepare extconf.rb. # 2. Modify this file as appropriate. # 3. Type 'make -f Makefile.swig' to generate wrapper code and Makefile. # 4. Type 'make' to build your extension. # 5. Type 'make install' to install your extension. # MODULE = yourmodule FEATURE = $(MODULE) INTERFACE = $(MODULE).i RUBY = ruby SWIG = swig # for C extension SWIGOPT = -ruby WRAPPER = $(MODULE)_wrap.c ## for C++ extension #SWIGOPT = -ruby -c++ #WRAPPER = $(MODULE)_wrap.cc swigall: $(WRAPPER) Makefile $(WRAPPER): $(INTERFACE) $(SWIG) $(SWIGOPT) -o $@ $(INTERFACE) Makefile: extconf.rb $(RUBY) extconf.rb @if [ -f Makefile ] ; then\ echo "include Makefile.swig" >> Makefile;\ fi swigclean: @if [ -f Makefile ] ; then\ make -f Makefile clean;\ fi rm -f Makefile $(WRAPPER) swig-3.0.2/Lib/ruby/rubytracking.swg0000664000175000017500000001204412343605122017261 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubytracking.swg * * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) # define NUM2SWIG(x) (unsigned long)NUM2LONG(x) #elif SIZEOF_VOIDP == SIZEOF_LONG_LONG # define SWIG2NUM(v) LL2NUM((unsigned long long)v) # define NUM2SWIG(x) (unsigned long long)NUM2LL(x) #else # error sizeof(void*) is not the same as long or long long #endif /* Global Ruby hash table to store Trackings from C/C++ structs to Ruby Objects. */ static VALUE swig_ruby_trackings = Qnil; /* Global variable that stores a reference to the ruby hash table delete function. */ static ID swig_ruby_hash_delete; /* Setup a Ruby hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { /* Create a ruby hash table to store Trackings from C++ objects to Ruby objects. */ /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ ID trackings_id = rb_intern( "@__trackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); /* No, it hasn't. Create one ourselves */ if ( swig_ruby_trackings == Qnil ) { swig_ruby_trackings = rb_hash_new(); rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); } /* Now store a reference to the hash table delete function so that we only have to look it up once.*/ swig_ruby_hash_delete = rb_intern("delete"); } /* Get a Ruby number to reference a pointer */ SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { /* We cast the pointer to an unsigned long and then store a reference to it using a Ruby number object. */ /* Convert the pointer to a Ruby number */ return SWIG2NUM(ptr); } /* Get a Ruby number to reference an object */ SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { /* We cast the object to an unsigned long and then store a reference to it using a Ruby number object. */ /* Convert the Object to a Ruby number */ return SWIG2NUM(object); } /* Get a Ruby object from a previously stored reference */ SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { /* The provided Ruby number object is a reference to the Ruby object we want.*/ /* Convert the Ruby number to a Ruby object */ return NUM2SWIG(reference); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { /* In a Ruby hash table we store the pointer and the associated Ruby object. The trick here is that we cannot store the Ruby object directly - if we do then it cannot be garbage collected. So instead we typecast it as a unsigned long and convert it to a Ruby number object.*/ /* Get a reference to the pointer as a Ruby number */ VALUE key = SWIG_RubyPtrToReference(ptr); /* Get a reference to the Ruby object as a Ruby number */ VALUE value = SWIG_RubyObjectToReference(object); /* Store the mapping to the global hash table. */ rb_hash_aset(swig_ruby_trackings, key, value); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { /* Get a reference to the pointer as a Ruby number */ VALUE key = SWIG_RubyPtrToReference(ptr); /* Now lookup the value stored in the global hash table */ VALUE value = rb_hash_aref(swig_ruby_trackings, key); if (value == Qnil) { /* No object exists - return nil. */ return Qnil; } else { /* Convert this value to Ruby object */ return SWIG_RubyReferenceToObject(value); } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It is very important to remove objects once they are destroyed since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { /* Get a reference to the pointer as a Ruby number */ VALUE key = SWIG_RubyPtrToReference(ptr); /* Delete the object from the hash table by calling Ruby's do this we need to call the Hash.delete method.*/ rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the Ruby object is longer than the C++ object */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { DATA_PTR(object) = 0; } } #ifdef __cplusplus } #endif swig-3.0.2/Lib/ruby/file.i0000664000175000017500000000120212343605122015116 0ustar williamwilliam// FILE * %{ #ifdef __cplusplus extern "C" { #endif /* Ruby 1.9 changed the file name of this header */ #ifdef HAVE_RUBY_IO_H #include "ruby/io.h" #else #include "rubyio.h" #endif #ifdef __cplusplus } #endif %} %typemap(in) FILE *READ { OpenFile *of; GetOpenFile($input, of); rb_io_check_readable(of); $1 = GetReadFile(of); rb_read_check($1); } %typemap(in) FILE *READ_NOCHECK { OpenFile *of; GetOpenFile($input, of); rb_io_check_readable(of); $1 = GetReadFile(of); } %typemap(in) FILE *WRITE { OpenFile *of; GetOpenFile($input, of); rb_io_check_writable(of); $1 = GetWriteFile(of); } swig-3.0.2/Lib/ruby/progargcargv.i0000664000175000017500000000140212343605122016665 0ustar williamwilliam/* int PROG_ARGC char **PROG_ARGV Some C function receive argc and argv from C main function. This typemap provides ignore typemap which pass Ruby ARGV contents as argc and argv to C function. */ // argc and argv %typemap(in,numinputs=0) int PROG_ARGC { $1 = RARRAY_LEN(rb_argv) + 1; } %typemap(in,numinputs=0) char **PROG_ARGV { int i, n; VALUE ary = rb_eval_string("[$0] + ARGV"); n = RARRAY_LEN(ary); $1 = (char **)malloc(n + 1); for (i = 0; i < n; i++) { VALUE v = rb_obj_as_string(RARRAY_PTR(ary)[i]); $1[i] = (char *)malloc(RSTRING_LEN(v) + 1); strcpy($1[i], RSTRING_PTR(v)); } } %typemap(freearg) char **PROG_ARGV { int i, n = RARRAY_LEN(rb_argv) + 1; for (i = 0; i < n; i++) free($1[i]); free($1); } swig-3.0.2/Lib/ruby/embed.i0000664000175000017500000000025112343605122015256 0ustar williamwilliam%wrapper %{ #include int main(argc, argv) int argc; char **argv; { ruby_init(); ruby_options(argc, argv); ruby_run(); return 0; } %} swig-3.0.2/Lib/ruby/std_multimap.i0000664000175000017500000001370512343605122016714 0ustar williamwilliam/* Multimaps */ %include %fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const RubySeq& rubyseq, std::multimap *multimap) { typedef typename std::multimap::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { multimap->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::multimap multimap_type; static int asptr(VALUE obj, std::multimap **val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_HASH ) { static ID id_to_a = rb_intern("to_a"); VALUE items = rb_funcall(obj, id_to_a, 0); return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { multimap_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::multimap multimap_type; typedef typename multimap_type::const_iterator const_iterator; typedef typename multimap_type::size_type size_type; static VALUE from(const multimap_type& multimap) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); } else { size_type size = multimap.size(); int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise(rb_eRuntimeError, "multimap size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE obj = rb_hash_new(); for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { VALUE key = swig::from(i->first); VALUE val = swig::from(i->second); VALUE oldval = rb_hash_aref( obj, key ); if ( oldval == Qnil ) rb_hash_aset(obj, key, val); else { // Multiple values for this key, create array if needed // and add a new element to it. VALUE ary; if ( TYPE(oldval) == T_ARRAY ) ary = oldval; else { ary = rb_ary_new2(2); rb_ary_push( ary, oldval ); rb_hash_aset( obj, key, ary ); } rb_ary_push( ary, val ); } } return obj; } } }; } } %define %swig_multimap_methods(MultiMap...) %swig_map_common(%arg(MultiMap)); %extend { VALUE __getitem__(const key_type& key) const { MultiMap::const_iterator i = self->find(key); if ( i != self->end() ) { MultiMap::const_iterator e = $self->upper_bound(key); VALUE ary = rb_ary_new(); for ( ; i != e; ++i ) { rb_ary_push( ary, swig::from( i->second ) ); } if ( RARRAY_LEN(ary) == 1 ) return RARRAY_PTR(ary)[0]; return ary; } else return Qnil; } void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { self->insert(MultiMap::value_type(key,x)); } VALUE inspect() { MultiMap::iterator i = $self->begin(); MultiMap::iterator e = $self->end(); const char *type_name = swig::type_name< MultiMap >(); VALUE str = rb_str_new2( type_name ); str = rb_str_cat2( str, " {" ); VALUE tmp; while ( i != e ) { const MultiMap::key_type& key = i->first; const MultiMap::key_type& oldkey = key; tmp = swig::from( key ); str = rb_str_buf_append( str, rb_inspect(tmp) ); str = rb_str_cat2( str, "=>" ); VALUE vals = rb_ary_new(); for ( ; i != e && key == oldkey; ++i ) { const MultiMap::mapped_type& val = i->second; tmp = swig::from( val ); rb_ary_push( vals, tmp ); } if ( RARRAY_LEN(vals) == 1 ) { str = rb_str_buf_append( str, rb_inspect(tmp) ); } else { str = rb_str_buf_append( str, rb_inspect(vals) ); } } str = rb_str_cat2( str, "}" ); return str; } VALUE to_a() { MultiMap::const_iterator i = $self->begin(); MultiMap::const_iterator e = $self->end(); VALUE ary = rb_ary_new2( std::distance( i, e ) ); VALUE tmp; while ( i != e ) { const MultiMap::key_type& key = i->first; const MultiMap::key_type& oldkey = key; tmp = swig::from( key ); rb_ary_push( ary, tmp ); VALUE vals = rb_ary_new(); for ( ; i != e && key == oldkey; ++i ) { const MultiMap::mapped_type& val = i->second; tmp = swig::from( val ); rb_ary_push( vals, tmp ); } if ( RARRAY_LEN(vals) == 1 ) { rb_ary_push( ary, tmp ); } else { rb_ary_push( ary, vals ); } } return ary; } VALUE to_s() { MultiMap::iterator i = $self->begin(); MultiMap::iterator e = $self->end(); VALUE str = rb_str_new2( "" ); VALUE tmp; while ( i != e ) { const MultiMap::key_type& key = i->first; const MultiMap::key_type& oldkey = key; tmp = swig::from( key ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); VALUE vals = rb_ary_new(); for ( ; i != e && key == oldkey; ++i ) { const MultiMap::mapped_type& val = i->second; tmp = swig::from( val ); rb_ary_push( vals, tmp ); } tmp = rb_obj_as_string( vals ); str = rb_str_buf_append( str, tmp ); } return str; } } %enddef %mixin std::multimap "Enumerable"; %rename("delete") std::multimap::__delete__; %rename("reject!") std::multimap::reject_bang; %rename("map!") std::multimap::map_bang; %rename("empty?") std::multimap::empty; %rename("include?" ) std::multimap::__contains__ const; %rename("has_key?" ) std::multimap::has_key const; %alias std::multimap::push "<<"; %include swig-3.0.2/Lib/ruby/rubyrun.swg0000664000175000017500000003233312343605122016266 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubyrun.swg * * This file contains the runtime support for Ruby modules * and includes code for managing global variables and pointer * type checking. * ----------------------------------------------------------------------------- */ /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 /* for raw pointers */ #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) #define swig_owntype ruby_owntype /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) #define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), "%s", msg) #define SWIG_fail goto fail /* Ruby-specific SWIG API */ #define SWIG_InitRuntime() SWIG_Ruby_InitRuntime() #define SWIG_define_class(ty) SWIG_Ruby_define_class(ty) #define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty) #define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value) #define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty) #include "assert.h" /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif typedef struct { VALUE klass; VALUE mImpl; void (*mark)(void *); void (*destroy)(void *); int trackObjects; } swig_class; /* Global pointer used to keep some internal SWIG stuff */ static VALUE _cSWIG_Pointer = Qnil; static VALUE swig_runtime_data_type_pointer = Qnil; /* Global IDs used to keep some internal SWIG stuff */ static ID swig_arity_id = 0; static ID swig_call_id = 0; /* If your swig extension is to be run within an embedded ruby and has director callbacks, you should set -DRUBY_EMBEDDED during compilation. This will reset ruby's stack frame on each entry point from the main program the first time a virtual director function is invoked (in a non-recursive way). If this is not done, you run the risk of Ruby trashing the stack. */ #ifdef RUBY_EMBEDDED # define SWIG_INIT_STACK \ if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \ ++swig_virtual_calls; # define SWIG_RELEASE_STACK --swig_virtual_calls; # define Ruby_DirectorTypeMismatchException(x) \ rb_raise( rb_eTypeError, "%s", x ); return c_result; static unsigned int swig_virtual_calls = 0; #else /* normal non-embedded extension */ # define SWIG_INIT_STACK # define SWIG_RELEASE_STACK # define Ruby_DirectorTypeMismatchException(x) \ throw Swig::DirectorTypeMismatchException( x ); #endif /* RUBY_EMBEDDED */ SWIGRUNTIME VALUE getExceptionClass(void) { static int init = 0; static VALUE rubyExceptionClass ; if (!init) { init = 1; rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception")); } return rubyExceptionClass; } /* This code checks to see if the Ruby object being raised as part of an exception inherits from the Ruby class Exception. If so, the object is simply returned. If not, then a new Ruby exception object is created and that will be returned to Ruby.*/ SWIGRUNTIME VALUE SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) { VALUE exceptionClass = getExceptionClass(); if (rb_obj_is_kind_of(obj, exceptionClass)) { return obj; } else { return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)); } } /* Initialize Ruby runtime support */ SWIGRUNTIME void SWIG_Ruby_InitRuntime(void) { if (_mSWIG == Qnil) { _mSWIG = rb_define_module("SWIG"); swig_call_id = rb_intern("call"); swig_arity_id = rb_intern("arity"); } } /* Define Ruby class for C type */ SWIGRUNTIME void SWIG_Ruby_define_class(swig_type_info *type) { char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); sprintf(klass_name, "TYPE%s", type->name); if (NIL_P(_cSWIG_Pointer)) { _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); } rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); free((void *) klass_name); } /* Create a new pointer object */ SWIGRUNTIME VALUE SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) { int own = flags & SWIG_POINTER_OWN; int track; char *klass_name; swig_class *sklass; VALUE klass; VALUE obj; if (!ptr) return Qnil; if (type->clientdata) { sklass = (swig_class *) type->clientdata; /* Are we tracking this class and have we already returned this Ruby object? */ track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ if (obj != Qnil) { VALUE value = rb_iv_get(obj, "@__swigtype__"); const char* type_name = RSTRING_PTR(value); if (strcmp(type->name, type_name) == 0) { return obj; } } } /* Create a new Ruby object */ obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), ( own ? VOIDFUNC(sklass->destroy) : (track ? VOIDFUNC(SWIG_RubyRemoveTracking) : 0 ) ), ptr); /* If tracking is on for this class then track this object. */ if (track) { SWIG_RubyAddTracking(ptr, obj); } } else { klass_name = (char *) malloc(4 + strlen(type->name) + 1); sprintf(klass_name, "TYPE%s", type->name); klass = rb_const_get(_mSWIG, rb_intern(klass_name)); free((void *) klass_name); obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); return obj; } /* Create a new class instance (always owned) */ SWIGRUNTIME VALUE SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type) { VALUE obj; swig_class *sklass = (swig_class *) type->clientdata; obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0); rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); return obj; } /* Get type mangle from class name */ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); return StringValuePtr(stype); } /* Acquire a pointer value */ typedef void (*ruby_owntype)(void*); SWIGRUNTIME ruby_owntype SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { if (obj) { ruby_owntype oldown = RDATA(obj)->dfree; RDATA(obj)->dfree = own; return oldown; } else { return 0; } } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) { char *c; swig_cast_info *tc; void *vptr = 0; /* Grab the pointer */ if (NIL_P(obj)) { *ptr = 0; return SWIG_OK; } else { if (TYPE(obj) != T_DATA) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } if (own) *own = RDATA(obj)->dfree; /* Check to see if the input object is giving up ownership of the underlying C struct or C++ object. If so then we need to reset the destructor since the Ruby object no longer owns the underlying C++ object.*/ if (flags & SWIG_POINTER_DISOWN) { /* Is tracking on for this class? */ int track = 0; if (ty && ty->clientdata) { swig_class *sklass = (swig_class *) ty->clientdata; track = sklass->trackObjects; } if (track) { /* We are tracking objects for this class. Thus we change the destructor * to SWIG_RubyRemoveTracking. This allows us to * remove the mapping from the C++ to Ruby object * when the Ruby object is garbage collected. If we don't * do this, then it is possible we will return a reference * to a Ruby object that no longer exists thereby crashing Ruby. */ RDATA(obj)->dfree = SWIG_RubyRemoveTracking; } else { RDATA(obj)->dfree = 0; } } /* Do type-checking if type info was provided */ if (ty) { if (ty->clientdata) { if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { if (vptr == 0) { /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } *ptr = vptr; return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { return SWIG_ERROR; } tc = SWIG_TypeCheck(c, ty); if (!tc) { return SWIG_ERROR; } else { int newmemory = 0; *ptr = SWIG_TypeCast(tc, vptr, &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } } else { *ptr = vptr; } return SWIG_OK; } /* Check convert */ SWIGRUNTIMEINLINE int SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty) { char *c = SWIG_MangleStr(obj); if (!c) return 0; return SWIG_TypeCheck(c,ty) != 0; } SWIGRUNTIME VALUE SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; *(r++) = '_'; r = SWIG_PackData(r, ptr, sz); strcpy(r, type->name); return rb_str_new2(result); } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; const char *c; if (TYPE(obj) != T_STRING) goto type_error; c = StringValuePtr(obj); /* Pointer values must start with leading underscore */ if (*c != '_') goto type_error; c++; c = SWIG_UnpackData(c, ptr, sz); if (ty) { tc = SWIG_TypeCheck(c, ty); if (!tc) goto type_error; } return SWIG_OK; type_error: return SWIG_ERROR; } SWIGRUNTIME swig_module_info * SWIG_Ruby_GetModule(void *SWIGUNUSEDPARM(clientdata)) { VALUE pointer; swig_module_info *ret = 0; VALUE verbose = rb_gv_get("VERBOSE"); /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */ rb_gv_set("VERBOSE", Qfalse); /* first check if pointer already created */ pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); if (pointer != Qnil) { Data_Get_Struct(pointer, swig_module_info, ret); } /* reinstate warnings */ rb_gv_set("VERBOSE", verbose); return ret; } SWIGRUNTIME void SWIG_Ruby_SetModule(swig_module_info *pointer) { /* register a new class */ VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); /* create and store the structure pointer to a global variable */ swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer); } /* This function can be used to check whether a proc or method or similarly callable function has been passed. Usually used in a %typecheck, like: %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) { $result = SWIG_Ruby_isCallable( $input ); } */ SWIGINTERN int SWIG_Ruby_isCallable( VALUE proc ) { if ( rb_respond_to( proc, swig_call_id ) ) return 1; return 0; } /* This function can be used to check the arity (number of arguments) a proc or method can take. Usually used in a %typecheck. Valid arities will be that equal to minimal or those < 0 which indicate a variable number of parameters at the end. */ SWIGINTERN int SWIG_Ruby_arity( VALUE proc, int minimal ) { if ( rb_respond_to( proc, swig_arity_id ) ) { VALUE num = rb_funcall( proc, swig_arity_id, 0 ); int arity = NUM2INT(num); if ( arity < 0 && (arity+1) < -minimal ) return 1; if ( arity == minimal ) return 1; return 1; } return 0; } #ifdef __cplusplus } #endif swig-3.0.2/Lib/ruby/std_ios.i0000664000175000017500000000057412343605122015656 0ustar williamwilliam #pragma SWIG nowarn=801 %rename(ios_base_in) std::ios_base::in; AUTODOC(cerr, "Standard C++ error stream"); AUTODOC(cout, "Standard C++ output stream"); AUTODOC(cin, "Standard C++ input stream"); AUTODOC(clog, "Standard C++ logging stream"); AUTODOC(endl, "Add an end line to stream"); AUTODOC(ends, "Ends stream"); AUTODOC(flush, "Flush stream"); %include swig-3.0.2/Lib/ruby/rubyruntime.swg0000664000175000017500000000064712343605122017150 0ustar williamwilliam %runtime "swiglabels.swg" /* Common C API type-checking code */ %runtime "swigrun.swg" /* Common C API type-checking code */ %runtime "swigerrors.swg" /* SWIG errors */ %runtime "rubyhead.swg" /* Ruby includes and fixes */ %runtime "rubyerrors.swg" /* Ruby errors */ %runtime "rubytracking.swg" /* API for tracking C++ classes to Ruby objects */ %runtime "rubyapi.swg" %runtime "rubyrun.swg" swig-3.0.2/Lib/ruby/std_queue.i0000664000175000017500000000152312343605122016203 0ustar williamwilliam/* Queues */ %fragment("StdQueueTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::queue **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static VALUE from(const std::queue & vec) { return traits_from_stdseq >::from(vec); } }; } %} %rename("delete") std::queue::__delete__; %rename("reject!") std::queue::reject_bang; %rename("map!") std::queue::map_bang; %rename("empty?") std::queue::empty; %rename("include?" ) std::queue::__contains__ const; %rename("has_key?" ) std::queue::has_key const; %alias std::queue::push "<<"; %include swig-3.0.2/Lib/ruby/std_vector.i0000664000175000017500000000230212343605122016355 0ustar williamwilliam/* Vectors */ %fragment("StdVectorTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::vector **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static VALUE from(const std::vector& vec) { return traits_from_stdseq >::from(vec); } }; } %} %define %swig_vector_methods(Type...) %swig_sequence_methods(Type) %swig_sequence_front_inserters(Type); %enddef %define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %swig_sequence_front_inserters(Type); %enddef %mixin std::vector "Enumerable"; %ignore std::vector::push_back; %ignore std::vector::pop_back; %rename("delete") std::vector::__delete__; %rename("reject!") std::vector::reject_bang; %rename("map!") std::vector::map_bang; %rename("empty?") std::vector::empty; %rename("include?" ) std::vector::__contains__ const; %rename("has_key?" ) std::vector::has_key const; %alias std::vector::push "<<"; %include swig-3.0.2/Lib/ruby/std_string.i0000664000175000017500000000027612343605122016371 0ustar williamwilliam %warnfilter(801) std::string; // wrong class name %warnfilter(378) std::basic_string::operator!=; AUTODOC(substr, "Return a portion of the String"); %include swig-3.0.2/Lib/ruby/extconf.rb0000664000175000017500000000035212343605122016025 0ustar williamwilliamrequire 'mkmf' dir_config('yourlib') if have_header('yourlib.h') and have_library('yourlib', 'yourlib_init') # If you use swig -c option, you may have to link libswigrb. # have_library('swigrb') create_makefile('yourlib') end swig-3.0.2/Lib/ruby/rubytypemaps.swg0000664000175000017500000000342012343605122017317 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Ruby * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* bool is dangerous in Ruby, change precedence */ #undef SWIG_TYPECHECK_BOOL %define SWIG_TYPECHECK_BOOL 10000 %enddef /* Include fundamental fragment definitions */ %include /* Look for user fragments file. */ %include /* Ruby fragments for primitive types */ %include /* Ruby fragments for char* strings */ %include /* Backward compatibility output helper */ %fragment("output_helper","header") %{ #define output_helper SWIG_Ruby_AppendOutput %} /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* Directors are supported in Ruby */ #ifndef SWIG_DIRECTOR_TYPEMAPS #define SWIG_DIRECTOR_TYPEMAPS #endif /* Ruby types */ #define SWIG_Object VALUE #define VOID_Object Qnil /* Overload of the output/constant/exception handling */ /* append output */ #define SWIG_AppendOutput(result,obj) SWIG_Ruby_AppendOutput(result, obj) /* set constant */ #define SWIG_SetConstant(name, obj) rb_define_const($module, name, obj) /* raise */ #define SWIG_Raise(obj, type, desc) rb_exc_raise(SWIG_Ruby_ExceptionType(desc, obj)) /* Get the address of the 'Ruby self' object */ %typemap(in,numinputs=0,noblock=1) VALUE* RUBY_SELF { $1 = &self; } /* Include the unified typemap library */ %include swig-3.0.2/Lib/ruby/std_basic_string.i0000664000175000017500000000512012343605122017523 0ustar williamwilliam#if !defined(SWIG_STD_STRING) #define SWIG_STD_BASIC_STRING %include #define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) %traits_swigtype(std::basic_string); %fragment(SWIG_Traits_frag(std::basic_string)); %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(VALUE obj, std::string **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::string *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { char* buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::string(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } if (val) { rb_raise( rb_eTypeError, "a string is expected"); } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE VALUE SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } %include %typemaps_asptrfromn(%checkcode(STRING), std::basic_string); #endif #if !defined(SWIG_STD_WSTRING) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsWCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(VALUE obj, std::wstring **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::wstring *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::wstring(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } if (val) { rb_raise( rb_eTypeError, "a string is expected"); } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromWCharPtrAndSize") { SWIGINTERNINLINE VALUE SWIG_From(std::basic_string)(const std::wstring& s) { return SWIG_FromWCharPtrAndSize(s.data(), s.size()); } } %typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string); #endif swig-3.0.2/Lib/ruby/std_except.i0000664000175000017500000000004312343605122016343 0ustar williamwilliam%include swig-3.0.2/Lib/ruby/stl.i0000664000175000017500000000054512343605122015012 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/ruby/timeval.i0000664000175000017500000000223412343605122015646 0ustar williamwilliam/* struct timeval * time_t Ruby has builtin class Time. INPUT/OUTPUT typemap for timeval and time_t is provided. */ %{ #ifdef __cplusplus extern "C" { #endif #ifdef HAVE_SYS_TIME_H # include struct timeval rb_time_timeval(VALUE); #endif #ifdef __cplusplus } #endif %} %typemap(in) struct timeval *INPUT (struct timeval temp) { if (NIL_P($input)) $1 = NULL; else { temp = rb_time_timeval($input); $1 = &temp; } } %typemap(in,numinputs=0) struct timeval *OUTPUT(struct timeval temp) { $1 = &temp; } %typemap(argout) struct timeval *OUTPUT { $result = rb_time_new($1->tv_sec, $1->tv_usec); } %typemap(out) struct timeval * { $result = rb_time_new($1->tv_sec, $1->tv_usec); } %typemap(out) struct timespec * { $result = rb_time_new($1->tv_sec, $1->tv_nsec / 1000); } // time_t %typemap(in) time_t { if (NIL_P($input)) $1 = (time_t)-1; else $1 = NUM2LONG(rb_funcall($input, rb_intern("tv_sec"), 0)); } %typemap(typecheck) time_t { $1 = (NIL_P($input) || TYPE(rb_funcall($input, rb_intern("respond_to?"), 1, ID2SYM(rb_intern("tv_sec")))) == T_TRUE); } %typemap(out) time_t { $result = rb_time_new($1, 0); } swig-3.0.2/Lib/ruby/std_deque.i0000664000175000017500000000133412343605122016162 0ustar williamwilliam/* Deques */ %fragment("StdDequeTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::deque **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static VALUE from(const std::deque & vec) { return traits_from_stdseq >::from(vec); } }; } %} %ignore std::deque::push_back; %ignore std::deque::pop_back; #define %swig_deque_methods(Type...) %swig_sequence_methods(Type) #define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.2/Lib/ruby/rubyprimtypes.swg0000664000175000017500000001215412343605122017515 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubyprimtypes.swg * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* auxiliary ruby fail method */ %fragment("SWIG_ruby_failed","header") { SWIGINTERN VALUE SWIG_ruby_failed(void) { return Qnil; } } %define %ruby_aux_method(Type, Method, Action) SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE *args) { VALUE obj = args[0]; VALUE type = TYPE(obj); Type *res = (Type *)(args[1]); *res = Action; return obj; } %enddef /* boolean */ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE VALUE SWIG_From_dec(bool)(bool value) { return value ? Qtrue : Qfalse; } } %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(int)) { SWIGINTERN int SWIG_AsVal_dec(bool)(VALUE obj, bool *val) { if (obj == Qtrue) { if (val) *val = true; return SWIG_OK; } else if (obj == Qfalse) { if (val) *val = false; return SWIG_OK; } else { int res = 0; if (SWIG_AsVal(int)(obj, &res) == SWIG_OK) { if (val) *val = res ? true : false; return SWIG_OK; } } return SWIG_TypeError; } } /* long */ %fragment(SWIG_From_frag(long),"header", fragment="") { %define_as(SWIG_From_dec(long), LONG2NUM) } %fragment(SWIG_AsVal_frag(long),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(long, NUM2LONG, type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj)) SWIGINTERN int SWIG_AsVal_dec(long)(VALUE obj, long* val) { VALUE type = TYPE(obj); if ((type == T_FIXNUM) || (type == T_BIGNUM)) { long v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE VALUE SWIG_From_dec(unsigned long)(unsigned long value) { return ULONG2NUM(value); } } %fragment(SWIG_AsVal_frag(unsigned long),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(unsigned long, NUM2ULONG, type == T_FIXNUM ? NUM2ULONG(obj) : rb_big2ulong(obj)) SWIGINTERN int SWIG_AsVal_dec(unsigned long)(VALUE obj, unsigned long *val) { VALUE type = TYPE(obj); if ((type == T_FIXNUM) || (type == T_BIGNUM)) { unsigned long v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } /* long long */ %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE VALUE SWIG_From_dec(long long)(long long value) { return LL2NUM(value); } } %fragment(SWIG_AsVal_frag(long long),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(long long, NUM2LL, type == T_FIXNUM ? NUM2LL(obj) : rb_big2ll(obj)) SWIGINTERN int SWIG_AsVal_dec(long long)(VALUE obj, long long *val) { VALUE type = TYPE(obj); if ((type == T_FIXNUM) || (type == T_BIGNUM)) { long long v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="") { SWIGINTERNINLINE VALUE SWIG_From_dec(unsigned long long)(unsigned long long value) { return ULL2NUM(value); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(long long, NUM2ULL, type == T_FIXNUM ? NUM2ULL(obj) : rb_big2ull(obj)) SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val) { VALUE type = TYPE(obj); if ((type == T_FIXNUM) || (type == T_BIGNUM)) { unsigned long long v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } /* double */ %fragment(SWIG_From_frag(double),"header") { %define_as(SWIG_From_dec(double), rb_float_new) } %fragment(SWIG_AsVal_frag(double),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(double, NUM2DBL, NUM2DBL(obj); (void)type) SWIGINTERN int SWIG_AsVal_dec(double)(VALUE obj, double *val) { VALUE type = TYPE(obj); if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) { double v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } swig-3.0.2/Lib/ruby/rubyuserdir.swg0000664000175000017500000000122112343605122017127 0ustar williamwilliam#define %alias %feature("alias") #define %freefunc %feature("freefunc") #define %markfunc %feature("markfunc") #define %mixin %feature("mixin") #define %predicate %feature("predicate", "1") #define %bang %feature("bang", "1") #define %trackobjects %feature("trackobjects") #define %nooutput %feature("outputs","0") #define %initstack %feature("initstack", "1") #define %ignorestack %feature("initstack", "0") /* ------------------------------------------------------------------------- */ /* Enable keywords paramaters */ #define %kwargs %feature("kwargs") #define %nokwargs %feature("kwargs", "0") #define %clearkwargs %feature("kwargs", "") swig-3.0.2/Lib/ruby/cpointer.i0000664000175000017500000000004112343605122016022 0ustar williamwilliam%include swig-3.0.2/Lib/ruby/std_sstream.i0000664000175000017500000000003612343605122016533 0ustar williamwilliam %include swig-3.0.2/Lib/ruby/std_wstring.i0000664000175000017500000000010112343605122016543 0ustar williamwilliam%include %include swig-3.0.2/Lib/ruby/rubydef.swg0000664000175000017500000000005212343605122016211 0ustar williamwilliam/* empty file added for backward comp. */ swig-3.0.2/Lib/ruby/rubyhead.swg0000664000175000017500000001027112343605122016360 0ustar williamwilliam#include /* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which * breaks using rb_intern as an lvalue, as SWIG does. We work around this * issue for now by disabling this. * https://sourceforge.net/tracker/?func=detail&aid=2859614&group_id=1645&atid=101645 */ #ifdef rb_intern # undef rb_intern #endif /* Remove global macros defined in Ruby's win32.h */ #ifdef write # undef write #endif #ifdef read # undef read #endif #ifdef bind # undef bind #endif #ifdef close # undef close #endif #ifdef connect # undef connect #endif /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ #ifndef NUM2LL #define NUM2LL(x) NUM2LONG((x)) #endif #ifndef LL2NUM #define LL2NUM(x) INT2NUM((long) (x)) #endif #ifndef ULL2NUM #define ULL2NUM(x) UINT2NUM((unsigned long) (x)) #endif /* Ruby 1.7 doesn't (yet) define NUM2ULL() */ #ifndef NUM2ULL #ifdef HAVE_LONG_LONG #define NUM2ULL(x) rb_num2ull((x)) #else #define NUM2ULL(x) NUM2ULONG(x) #endif #endif /* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */ /* Define these for older versions so we can just write code the new way */ #ifndef RSTRING_LEN # define RSTRING_LEN(x) RSTRING(x)->len #endif #ifndef RSTRING_PTR # define RSTRING_PTR(x) RSTRING(x)->ptr #endif #ifndef RSTRING_END # define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x)) #endif #ifndef RARRAY_LEN # define RARRAY_LEN(x) RARRAY(x)->len #endif #ifndef RARRAY_PTR # define RARRAY_PTR(x) RARRAY(x)->ptr #endif #ifndef RFLOAT_VALUE # define RFLOAT_VALUE(x) RFLOAT(x)->value #endif #ifndef DOUBLE2NUM # define DOUBLE2NUM(x) rb_float_new(x) #endif #ifndef RHASH_TBL # define RHASH_TBL(x) (RHASH(x)->tbl) #endif #ifndef RHASH_ITER_LEV # define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev) #endif #ifndef RHASH_IFNONE # define RHASH_IFNONE(x) (RHASH(x)->ifnone) #endif #ifndef RHASH_SIZE # define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries) #endif #ifndef RHASH_EMPTY_P # define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0) #endif #ifndef RSTRUCT_LEN # define RSTRUCT_LEN(x) RSTRUCT(x)->len #endif #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif /* * Need to be very careful about how these macros are defined, especially * when compiling C++ code or C code with an ANSI C compiler. * * VALUEFUNC(f) is a macro used to typecast a C function that implements * a Ruby method so that it can be passed as an argument to API functions * like rb_define_method() and rb_define_singleton_method(). * * VOIDFUNC(f) is a macro used to typecast a C function that implements * either the "mark" or "free" stuff for a Ruby Data object, so that it * can be passed as an argument to API functions like Data_Wrap_Struct() * and Data_Make_Struct(). */ #ifdef __cplusplus # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ # define PROTECTFUNC(f) ((VALUE (*)()) f) # define VALUEFUNC(f) ((VALUE (*)()) f) # define VOIDFUNC(f) ((void (*)()) f) # else # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ # define PROTECTFUNC(f) ((VALUE (*)()) f) # define VALUEFUNC(f) ((VALUE (*)()) f) # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) # else /* These definitions should work for Ruby 1.7+ */ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) # endif # endif #else # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) #endif /* Don't use for expressions have side effect */ #ifndef RB_STRING_VALUE #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s))) #endif #ifndef StringValue #define StringValue(s) RB_STRING_VALUE(s) #endif #ifndef StringValuePtr #define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s)) #endif #ifndef StringValueLen #define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s)) #endif #ifndef SafeStringValue #define SafeStringValue(v) do {\ StringValue(v);\ rb_check_safe_str(v);\ } while (0) #endif #ifndef HAVE_RB_DEFINE_ALLOC_FUNC #define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) #define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") #endif static VALUE _mSWIG = Qnil; swig-3.0.2/Lib/ruby/rubyapi.swg0000664000175000017500000000144112343605122016227 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Ruby API portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif SWIGINTERN VALUE SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { if (NIL_P(target)) { target = o; } else { if (TYPE(target) != T_ARRAY) { VALUE o2 = target; target = rb_ary_new(); rb_ary_push(target, o2); } rb_ary_push(target, o); } return target; } /* For ruby1.8.4 and earlier. */ #ifndef RUBY_INIT_STACK RUBY_EXTERN void Init_stack(VALUE* addr); # define RUBY_INIT_STACK \ VALUE variable_in_this_stack_frame; \ Init_stack(&variable_in_this_stack_frame); #endif #ifdef __cplusplus } #endif swig-3.0.2/Lib/ruby/rubymacros.swg0000664000175000017500000000071012343605122016740 0ustar williamwilliam // Redefine these macros so argument index for ruby is done properly, // ignoring self and we get some more info about the input. #define %argfail_fmt(_type,_name,_argn) Ruby_Format_TypeError( "", _type, #_name, _argn, $input ) #define %argnullref_fmt(_type,_name,_argn) Ruby_Format_TypeError(%nullref_fmt(), _type, #_name, _argn, $input) %{ #define SWIG_RUBY_THREAD_BEGIN_BLOCK #define SWIG_RUBY_THREAD_END_BLOCK %} %include swig-3.0.2/Lib/ruby/rubyerrors.swg0000664000175000017500000000720212343605122016773 0ustar williamwilliam/* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ /* Define some additional error types */ #define SWIG_ObjectPreviouslyDeletedError -100 /* Define custom exceptions for errors that do not map to existing Ruby exceptions. Note this only works for C++ since a global cannot be initialized by a function in C. For C, fallback to rb_eRuntimeError.*/ SWIGINTERN VALUE getNullReferenceError(void) { static int init = 0; static VALUE rb_eNullReferenceError ; if (!init) { init = 1; rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError); } return rb_eNullReferenceError; } SWIGINTERN VALUE getObjectPreviouslyDeletedError(void) { static int init = 0; static VALUE rb_eObjectPreviouslyDeleted ; if (!init) { init = 1; rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError); } return rb_eObjectPreviouslyDeleted; } SWIGINTERN VALUE SWIG_Ruby_ErrorType(int SWIG_code) { VALUE type; switch (SWIG_code) { case SWIG_MemoryError: type = rb_eNoMemError; break; case SWIG_IOError: type = rb_eIOError; break; case SWIG_RuntimeError: type = rb_eRuntimeError; break; case SWIG_IndexError: type = rb_eIndexError; break; case SWIG_TypeError: type = rb_eTypeError; break; case SWIG_DivisionByZero: type = rb_eZeroDivError; break; case SWIG_OverflowError: type = rb_eRangeError; break; case SWIG_SyntaxError: type = rb_eSyntaxError; break; case SWIG_ValueError: type = rb_eArgError; break; case SWIG_SystemError: type = rb_eFatal; break; case SWIG_AttributeError: type = rb_eRuntimeError; break; case SWIG_NullReferenceError: type = getNullReferenceError(); break; case SWIG_ObjectPreviouslyDeletedError: type = getObjectPreviouslyDeletedError(); break; case SWIG_UnknownError: type = rb_eRuntimeError; break; default: type = rb_eRuntimeError; } return type; } /* This function is called when a user inputs a wrong argument to a method. */ SWIGINTERN const char* Ruby_Format_TypeError( const char* msg, const char* type, const char* name, const int argn, VALUE input ) { char buf[128]; VALUE str; VALUE asStr; if ( msg && *msg ) { str = rb_str_new2(msg); } else { str = rb_str_new(NULL, 0); } str = rb_str_cat2( str, "Expected argument " ); sprintf( buf, "%d of type ", argn-1 ); str = rb_str_cat2( str, buf ); str = rb_str_cat2( str, type ); str = rb_str_cat2( str, ", but got " ); str = rb_str_cat2( str, rb_obj_classname(input) ); str = rb_str_cat2( str, " " ); asStr = rb_inspect(input); if ( RSTRING_LEN(asStr) > 30 ) { str = rb_str_cat( str, StringValuePtr(asStr), 30 ); str = rb_str_cat2( str, "..." ); } else { str = rb_str_append( str, asStr ); } if ( name ) { str = rb_str_cat2( str, "\n\tin SWIG method '" ); str = rb_str_cat2( str, name ); str = rb_str_cat2( str, "'" ); } return StringValuePtr( str ); } /* This function is called when an overloaded method fails */ SWIGINTERN void Ruby_Format_OverloadedError( const int argc, const int maxargs, const char* method, const char* prototypes ) { const char* msg = "Wrong # of arguments"; if ( argc <= maxargs ) msg = "Wrong arguments"; rb_raise(rb_eArgError,"%s for overloaded method '%s'.\n" "Possible C/C++ prototypes are:\n%s", msg, method, prototypes); } swig-3.0.2/Lib/ruby/std_char_traits.i0000664000175000017500000000004112343605122017354 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/0000775000175000017500000000000012343605122013633 5ustar williamwilliamswig-3.0.2/Lib/tcl/tclopers.swg0000664000175000017500000000275012343605122016214 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclopers.swg * * C++ overloaded operators. * * These declarations define how SWIG is going to rename C++ * overloaded operators in Tcl. Since Tcl allows identifiers * to be essentially any valid string, we'll just use the * normal operator names. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus %rename("+") *::operator+; //%rename("u+") *::operator+(); // Unary + //%rename("u+") *::operator+() const; // Unary + %rename("-") *::operator-; //%rename("u-") *::operator-(); // Unary - //%rename("u-") *::operator-() const; // Unary - %rename("*") *::operator*; %rename("/") *::operator/; %rename("<<") *::operator<<; %rename(">>") *::operator>>; %rename("&") *::operator&; %rename("|") *::operator|; %rename("^") *::operator^; %rename("%") *::operator%; %rename("=") *::operator=; /* Ignored operators */ %ignoreoperator(NOTEQUAL) operator!=; %ignoreoperator(PLUSEQ) operator+=; %ignoreoperator(MINUSEQ) operator-=; %ignoreoperator(MULEQ) operator*=; %ignoreoperator(DIVEQ) operator/=; %ignoreoperator(MODEQ) operator%=; %ignoreoperator(LSHIFTEQ) operator<<=; %ignoreoperator(RSHIFTEQ) operator>>=; %ignoreoperator(ANDEQ) operator&=; %ignoreoperator(OREQ) operator|=; %ignoreoperator(XOREQ) operator^=; #endif swig-3.0.2/Lib/tcl/tclerrors.swg0000664000175000017500000000323712343605122016401 0ustar williamwilliam/* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ SWIGINTERN const char* SWIG_Tcl_ErrorType(int code) { const char* type = 0; switch(code) { case SWIG_MemoryError: type = "MemoryError"; break; case SWIG_IOError: type = "IOError"; break; case SWIG_RuntimeError: type = "RuntimeError"; break; case SWIG_IndexError: type = "IndexError"; break; case SWIG_TypeError: type = "TypeError"; break; case SWIG_DivisionByZero: type = "ZeroDivisionError"; break; case SWIG_OverflowError: type = "OverflowError"; break; case SWIG_SyntaxError: type = "SyntaxError"; break; case SWIG_ValueError: type = "ValueError"; break; case SWIG_SystemError: type = "SystemError"; break; case SWIG_AttributeError: type = "AttributeError"; break; default: type = "RuntimeError"; } return type; } SWIGINTERN void SWIG_Tcl_SetErrorObj(Tcl_Interp *interp, const char *ctype, Tcl_Obj *obj) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, obj); Tcl_SetErrorCode(interp, "SWIG", ctype, NULL); } SWIGINTERN void SWIG_Tcl_SetErrorMsg(Tcl_Interp *interp, const char *ctype, const char *mesg) { Tcl_ResetResult(interp); Tcl_SetErrorCode(interp, "SWIG", ctype, NULL); Tcl_AppendResult(interp, ctype, " ", mesg, NULL); /* Tcl_AddErrorInfo(interp, ctype); Tcl_AddErrorInfo(interp, " "); Tcl_AddErrorInfo(interp, mesg); */ } SWIGINTERNINLINE void SWIG_Tcl_AddErrorMsg(Tcl_Interp *interp, const char* mesg) { Tcl_AddErrorInfo(interp, mesg); } swig-3.0.2/Lib/tcl/tclwstrings.swg0000664000175000017500000000345412343605122016746 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclwstrings.wg * * Utility methods for wchar strings * ----------------------------------------------------------------------------- */ %{ #include %} %fragment("SWIG_AsWCharPtrAndSize","header") { SWIGINTERN int SWIG_AsWCharPtrAndSize(Tcl_Obj *obj, wchar_t** cptr, size_t* psize, int *alloc) { int len = 0; Tcl_UniChar *ustr = Tcl_GetUnicodeFromObj(obj, &len); if (ustr) { if (cptr) { Tcl_Encoding encoding = NULL; char *src = (char *) ustr; int srcLen = (len)*sizeof(Tcl_UniChar); int dstLen = sizeof(wchar_t)*(len + 1); char *dst = %new_array(dstLen, char); int flags = 0; Tcl_EncodingState *statePtr = 0; int srcRead = 0; int dstWrote = 0; int dstChars = 0; Tcl_UtfToExternal(0, encoding, src, srcLen, flags, statePtr, dst, dstLen, &srcRead, &dstWrote, &dstChars); if (alloc) *alloc = SWIG_NEWOBJ; } if (psize) *psize = len + 1; return SWIG_OK; } return SWIG_TypeError; } } %fragment("SWIG_FromWCharPtrAndSize","header") { SWIGINTERNINLINE Tcl_Obj * SWIG_FromWCharPtrAndSize(const wchar_t* carray, size_t size) { Tcl_Obj *res = NULL; if (size < INT_MAX) { Tcl_Encoding encoding = NULL; char *src = (char *) carray; int srcLen = (int)(size*sizeof(wchar_t)); int dstLen = (int)(size*sizeof(Tcl_UniChar)); char *dst = %new_array(dstLen, char); int flags = 0; Tcl_EncodingState *statePtr = 0; int srcRead = 0; int dstWrote = 0; int dstChars = 0; Tcl_ExternalToUtf(0, encoding, src, srcLen, flags, statePtr, dst, dstLen, &srcRead, &dstWrote, &dstChars); res = Tcl_NewUnicodeObj((Tcl_UniChar*)dst, (int)size); %delete_array(dst); } return res; } } swig-3.0.2/Lib/tcl/tclstrings.swg0000664000175000017500000000143112343605122016550 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header") { SWIGINTERN int SWIG_AsCharPtrAndSize(Tcl_Obj *obj, char** cptr, size_t* psize, int *alloc) { int len = 0; char *cstr = Tcl_GetStringFromObj(obj, &len); if (cstr) { if (cptr) *cptr = cstr; if (psize) *psize = len + 1; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } return SWIG_TypeError; } } %fragment("SWIG_FromCharPtrAndSize","header", fragment="") { SWIGINTERNINLINE Tcl_Obj * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { return (size < INT_MAX) ? Tcl_NewStringObj(carray, %numeric_cast(size,int)) : NULL; } } swig-3.0.2/Lib/tcl/std_map.i0000664000175000017500000000426412343605122015442 0ustar williamwilliam// // SWIG typemaps for std::map // Luigi Ballabio // Jan. 2003 // // Common implementation %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.2/Lib/tcl/tclruntime.swg0000664000175000017500000000074412343605122016550 0ustar williamwilliam/* tcl.h has to appear first */ %insert(runtime) %{ #include #include #include #include #include #include %} %insert(runtime) "swigrun.swg"; /* Common C API type-checking code */ %insert(runtime) "swigerrors.swg" /* SWIG errors */ %insert(runtime) "tclerrors.swg"; /* Tcl Errors */ %insert(runtime) "tclapi.swg"; /* Tcl API */ %insert(runtime) "tclrun.swg"; /* Tcl run-time code */ swig-3.0.2/Lib/tcl/tclkw.swg0000664000175000017500000000036712343605122015507 0ustar williamwilliam#ifndef TCL_TCLKW_SWG_ #define TCL_TCLKW_SWG_ // Some special reserved words in classes %keywordwarn("cget is a tcl reserved method name") *::cget; %keywordwarn("configure is a tcl reserved method name") *::configure; #endif //_TCL_TCLKW_SWG_ swig-3.0.2/Lib/tcl/tclresult.i0000664000175000017500000000125412343605122016030 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclresult.i * ----------------------------------------------------------------------------- */ /* int Tcl_Result Makes the integer return code of a function the return value of a SWIG generated wrapper function. For example : int foo() { ... do stuff ... return TCL_OK; } could be wrapped as follows : %include typemaps.i %apply int Tcl_Result { int foo }; int foo(); */ // If return code is a Tcl_Result, simply pass it on %typemap(out) int Tcl_Result { return $1; } swig-3.0.2/Lib/tcl/std_pair.i0000664000175000017500000000130312343605122015607 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * Typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/tcl/typemaps.i0000664000175000017500000003727212343605122015662 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * SWIG typemap library for Tcl8. This file contains various sorts * of typemaps for modifying SWIG's code generation. * ----------------------------------------------------------------------------- */ #if !defined(SWIG_USE_OLD_TYPEMAPS) %include #else /* The SWIG typemap library provides a language independent mechanism for supporting output arguments, input values, and other C function calling mechanisms. The primary use of the library is to provide a better interface to certain C function--especially those involving pointers. */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include typemaps.i double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include typemaps.i %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ %typemap(in) double *INPUT(double temp), double &INPUT(double temp) { if (Tcl_GetDoubleFromObj(interp,$input,&temp) == TCL_ERROR) { SWIG_fail; } $1 = &temp; } %typemap(in) float *INPUT(double dvalue, float temp), float &INPUT(double dvalue, float temp) { if (Tcl_GetDoubleFromObj(interp,$input,&dvalue) == TCL_ERROR) { SWIG_fail; } temp = (float) dvalue; $1 = &temp; } %typemap(in) int *INPUT(int temp), int &INPUT(int temp) { if (Tcl_GetIntFromObj(interp,$input,&temp) == TCL_ERROR) { SWIG_fail; } $1 = &temp; } %typemap(in) short *INPUT(int ivalue, short temp), short &INPUT(int ivalue, short temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (short) ivalue; $1 = &temp; } %typemap(in) long *INPUT(int ivalue, long temp), long &INPUT(int ivalue, long temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (long) ivalue; $1 = &temp; } %typemap(in) unsigned int *INPUT(int ivalue, unsigned int temp), unsigned int &INPUT(int ivalue, unsigned int temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (unsigned int) ivalue; $1 = &temp; } %typemap(in) unsigned short *INPUT(int ivalue, unsigned short temp), unsigned short &INPUT(int ivalue, unsigned short temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (unsigned short) ivalue; $1 = &temp; } %typemap(in) unsigned long *INPUT(int ivalue, unsigned long temp), unsigned long &INPUT(int ivalue, unsigned long temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (unsigned long) ivalue; $1 = &temp; } %typemap(in) unsigned char *INPUT(int ivalue, unsigned char temp), unsigned char &INPUT(int ivalue, unsigned char temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (unsigned char) ivalue; $1 = &temp; } %typemap(in) signed char *INPUT(int ivalue, signed char temp), signed char &INPUT(int ivalue, signed char temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (signed char) ivalue; $1 = &temp; } %typemap(in) bool *INPUT(int ivalue, bool temp), bool &INPUT(int ivalue, bool temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = ivalue ? true : false; $1 = &temp; } %typemap(in) long long *INPUT($*1_ltype temp), long long &INPUT($*1_ltype temp) { temp = ($*1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0); $1 = &temp; } %typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) { temp = ($*1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL),0,0); $1 = &temp; } // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Tcl list. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include typemaps.i double modf(double x, double *OUTPUT); or you can use the %apply directive : %include typemaps.i %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Tcl output of the function would be a list containing both output values. */ %typemap(in,numinputs=0) int *OUTPUT(int temp), short *OUTPUT(short temp), long *OUTPUT(long temp), unsigned int *OUTPUT(unsigned int temp), unsigned short *OUTPUT(unsigned short temp), unsigned long *OUTPUT(unsigned long temp), unsigned char *OUTPUT(unsigned char temp), signed char *OUTPUT(signed char temp), bool *OUTPUT(bool temp), float *OUTPUT(float temp), double *OUTPUT(double temp), long long *OUTPUT($*1_ltype temp), unsigned long long *OUTPUT($*1_ltype temp), int &OUTPUT(int temp), short &OUTPUT(short temp), long &OUTPUT(long temp), unsigned int &OUTPUT(unsigned int temp), unsigned short &OUTPUT(unsigned short temp), unsigned long &OUTPUT(unsigned long temp), signed char &OUTPUT(signed char temp), bool &OUTPUT(bool temp), unsigned char &OUTPUT(unsigned char temp), float &OUTPUT(float temp), double &OUTPUT(double temp), long long &OUTPUT($*1_ltype temp), unsigned long long &OUTPUT($*1_ltype temp) "$1 = &temp;"; %typemap(argout) int *OUTPUT, int &OUTPUT, short *OUTPUT, short &OUTPUT, long *OUTPUT, long &OUTPUT, unsigned int *OUTPUT, unsigned int &OUTPUT, unsigned short *OUTPUT, unsigned short &OUTPUT, unsigned long *OUTPUT, unsigned long &OUTPUT, unsigned char *OUTPUT, unsigned char &OUTPUT, signed char *OUTPUT, signed char &OUTPUT, bool *OUTPUT, bool &OUTPUT { Tcl_Obj *o; o = Tcl_NewIntObj((int) *($1)); Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); } %typemap(argout) float *OUTPUT, float &OUTPUT, double *OUTPUT, double &OUTPUT { Tcl_Obj *o; o = Tcl_NewDoubleObj((double) *($1)); Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); } %typemap(argout) long long *OUTPUT, long long &OUTPUT { char temp[256]; Tcl_Obj *o; sprintf(temp,"%lld",(long long)*($1)); o = Tcl_NewStringObj(temp,-1); Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); } %typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { char temp[256]; Tcl_Obj *o; sprintf(temp,"%llu",(unsigned long long)*($1)); o = Tcl_NewStringObj(temp,-1); Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); } // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Tcl list. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include typemaps.i void neg(double *INOUT); or you can use the %apply directive : %include typemaps.i %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Tcl). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Tcl variable you might do this : set x [neg $x] */ %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) unsigned int *INOUT = unsigned int *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) signed char *INOUT = signed char *INPUT; %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) int &INOUT = int &INPUT; %typemap(in) short &INOUT = short &INPUT; %typemap(in) long &INOUT = long &INPUT; %typemap(in) unsigned int &INOUT = unsigned int &INPUT; %typemap(in) unsigned short &INOUT = unsigned short &INPUT; %typemap(in) unsigned long &INOUT = unsigned long &INPUT; %typemap(in) unsigned char &INOUT = unsigned char &INPUT; %typemap(in) signed char &INOUT = signed char &INPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(in) float &INOUT = float &INPUT; %typemap(in) double &INOUT = double &INPUT; %typemap(in) long long &INOUT = long long &INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT = long *OUTPUT; %typemap(argout) unsigned int *INOUT = unsigned int *OUTPUT; %typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) signed char *INOUT = signed char *OUTPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT = double *OUTPUT; %typemap(argout) long long *INOUT = long long *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) int &INOUT = int &OUTPUT; %typemap(argout) short &INOUT = short &OUTPUT; %typemap(argout) long &INOUT = long &OUTPUT; %typemap(argout) unsigned int &INOUT = unsigned int &OUTPUT; %typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; %typemap(argout) signed char &INOUT = signed char &OUTPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; %typemap(argout) float &INOUT = float &OUTPUT; %typemap(argout) double &INOUT = double &OUTPUT; %typemap(argout) long long &INOUT = long long &OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; /* Overloading information */ %typemap(typecheck) double *INPUT = double; %typemap(typecheck) bool *INPUT = bool; %typemap(typecheck) signed char *INPUT = signed char; %typemap(typecheck) unsigned char *INPUT = unsigned char; %typemap(typecheck) unsigned long *INPUT = unsigned long; %typemap(typecheck) unsigned short *INPUT = unsigned short; %typemap(typecheck) unsigned int *INPUT = unsigned int; %typemap(typecheck) long *INPUT = long; %typemap(typecheck) short *INPUT = short; %typemap(typecheck) int *INPUT = int; %typemap(typecheck) float *INPUT = float; %typemap(typecheck) long long *INPUT = long long; %typemap(typecheck) unsigned long long *INPUT = unsigned long long; %typemap(typecheck) double &INPUT = double; %typemap(typecheck) bool &INPUT = bool; %typemap(typecheck) signed char &INPUT = signed char; %typemap(typecheck) unsigned char &INPUT = unsigned char; %typemap(typecheck) unsigned long &INPUT = unsigned long; %typemap(typecheck) unsigned short &INPUT = unsigned short; %typemap(typecheck) unsigned int &INPUT = unsigned int; %typemap(typecheck) long &INPUT = long; %typemap(typecheck) short &INPUT = short; %typemap(typecheck) int &INPUT = int; %typemap(typecheck) float &INPUT = float; %typemap(typecheck) long long &INPUT = long long; %typemap(typecheck) unsigned long long &INPUT = unsigned long long; %typemap(typecheck) double *INOUT = double; %typemap(typecheck) bool *INOUT = bool; %typemap(typecheck) signed char *INOUT = signed char; %typemap(typecheck) unsigned char *INOUT = unsigned char; %typemap(typecheck) unsigned long *INOUT = unsigned long; %typemap(typecheck) unsigned short *INOUT = unsigned short; %typemap(typecheck) unsigned int *INOUT = unsigned int; %typemap(typecheck) long *INOUT = long; %typemap(typecheck) short *INOUT = short; %typemap(typecheck) int *INOUT = int; %typemap(typecheck) float *INOUT = float; %typemap(typecheck) long long *INOUT = long long; %typemap(typecheck) unsigned long long *INOUT = unsigned long long; %typemap(typecheck) double &INOUT = double; %typemap(typecheck) bool &INOUT = bool; %typemap(typecheck) signed char &INOUT = signed char; %typemap(typecheck) unsigned char &INOUT = unsigned char; %typemap(typecheck) unsigned long &INOUT = unsigned long; %typemap(typecheck) unsigned short &INOUT = unsigned short; %typemap(typecheck) unsigned int &INOUT = unsigned int; %typemap(typecheck) long &INOUT = long; %typemap(typecheck) short &INOUT = short; %typemap(typecheck) int &INOUT = int; %typemap(typecheck) float &INOUT = float; %typemap(typecheck) long long &INOUT = long long; %typemap(typecheck) unsigned long long &INOUT = unsigned long long; #endif // -------------------------------------------------------------------- // Special types // -------------------------------------------------------------------- %include %include swig-3.0.2/Lib/tcl/tclapi.swg0000664000175000017500000000603412343605122015634 0ustar williamwilliam/* ----------------------------------------------------------------------------- * SWIG API. Portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_TCL_POINTER 4 #define SWIG_TCL_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; typedef int (*swig_wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []); typedef int (*swig_wrapper_func)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []); typedef char *(*swig_variable_func)(ClientData, Tcl_Interp *, char *, char *, int); typedef void (*swig_delete_func)(ClientData); typedef struct swig_method { const char *name; swig_wrapper method; } swig_method; typedef struct swig_attribute { const char *name; swig_wrapper getmethod; swig_wrapper setmethod; } swig_attribute; typedef struct swig_class { const char *name; swig_type_info **type; swig_wrapper constructor; void (*destructor)(void *); swig_method *methods; swig_attribute *attributes; struct swig_class **bases; const char **base_names; swig_module_info *module; Tcl_HashTable hashtable; } swig_class; typedef struct swig_instance { Tcl_Obj *thisptr; void *thisvalue; swig_class *classptr; int destroy; Tcl_Command cmdtok; } swig_instance; /* Structure for command table */ typedef struct { const char *name; int (*wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []); ClientData clientdata; } swig_command_info; /* Structure for variable linking table */ typedef struct { const char *name; void *addr; char * (*get)(ClientData, Tcl_Interp *, char *, char *, int); char * (*set)(ClientData, Tcl_Interp *, char *, char *, int); } swig_var_info; /* -----------------------------------------------------------------------------* * Install a constant object * -----------------------------------------------------------------------------*/ static Tcl_HashTable swigconstTable; static int swigconstTableinit = 0; SWIGINTERN void SWIG_Tcl_SetConstantObj(Tcl_Interp *interp, const char* name, Tcl_Obj *obj) { int newobj; Tcl_ObjSetVar2(interp,Tcl_NewStringObj(name,-1), NULL, obj, TCL_GLOBAL_ONLY); Tcl_SetHashValue(Tcl_CreateHashEntry(&swigconstTable, name, &newobj), (ClientData) obj); } SWIGINTERN Tcl_Obj * SWIG_Tcl_GetConstantObj(const char *key) { Tcl_HashEntry *entryPtr; if (!swigconstTableinit) return 0; entryPtr = Tcl_FindHashEntry(&swigconstTable, key); if (entryPtr) { return (Tcl_Obj *) Tcl_GetHashValue(entryPtr); } return 0; } #ifdef __cplusplus } #endif swig-3.0.2/Lib/tcl/tcluserdir.swg0000664000175000017500000000030312343605122016531 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Special user directives * ----------------------------------------------------------------------------- */ swig-3.0.2/Lib/tcl/tcl8.swg0000664000175000017500000000273412343605122015235 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tcl8.swg * * Tcl configuration module. * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * Inner macros * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The runtime part * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Special user directives * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Typemap specializations * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Warnings for Tcl keywords * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Tcl initialization function * ------------------------------------------------------------ */ %include swig-3.0.2/Lib/tcl/cmalloc.i0000664000175000017500000000004012343605122015411 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/cni.i0000664000175000017500000000005212343605122014553 0ustar williamwilliam%include %include swig-3.0.2/Lib/tcl/cstring.i0000664000175000017500000000004012343605122015450 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/attribute.i0000664000175000017500000000004212343605122016004 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/jstring.i0000664000175000017500000000175012343605122015470 0ustar williamwilliam%include %fragment(SWIG_AsVal_frag(jstring),"header") { SWIGINTERN int SWIG_AsVal_dec(jstring)(Tcl_Obj * obj, jstring *val) { int len = 0; const char *cstr = Tcl_GetStringFromObj(obj, &len); if (!cstr || (strcmp(cstr,"NULL") == 0)) { if (val) *val = 0; return SWIG_OK; } else { int len = 0; const Tcl_UniChar *ucstr = Tcl_GetUnicodeFromObj(obj,&len); if (val) { *val = JvNewString((const jchar*)ucstr, len); } } return SWIG_NEWOBJ; } } %fragment(SWIG_From_frag(jstring),"header") { SWIGINTERNINLINE Tcl_Obj * SWIG_From_dec(jstring)(jstring val) { if (!val) { return Tcl_NewStringObj("NULL",-1); } else { return Tcl_NewUnicodeObj((Tcl_UniChar *)JvGetStringChars(val),JvGetStringUTFLength(val)); } } } %typemaps_asvalfrom(%checkcode(STRING), %arg(SWIG_AsVal(jstring)), %arg(SWIG_From(jstring)), %arg(SWIG_AsVal_frag(jstring)), %arg(SWIG_From_frag(jstring)), java::lang::String *); swig-3.0.2/Lib/tcl/cdata.i0000664000175000017500000000003612343605122015060 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/carrays.i0000664000175000017500000000004312343605122015446 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/std_common.i0000664000175000017500000000072312343605122016151 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %types(std::size_t); %apply size_t { std::size_t }; %apply const unsigned long& { const std::size_t& }; %types(std::ptrdiff_t); %apply long { std::ptrdiff_t }; %apply const long& { const std::ptrdiff_t& }; swig-3.0.2/Lib/tcl/factory.i0000664000175000017500000000004012343605122015446 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/exception.i0000664000175000017500000000022112343605122015776 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); return TCL_ERROR;)) } swig-3.0.2/Lib/tcl/tcltypemaps.swg0000664000175000017500000000543712343605122016733 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Tcl * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* In Tcl we need to pass the interp value, so we define the decl/call macros as needed. */ #define SWIG_AS_DECL_ARGS SWIG_TCL_DECL_ARGS_2 #define SWIG_AS_CALL_ARGS SWIG_TCL_CALL_ARGS_2 /* Include fundamental fragment definitions */ %include /* Look for user fragments file. */ %include /* Tcl fragments for primitive types */ %include /* Tcl fragments for char* strings */ %include /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* No director support in Tcl */ #ifdef SWIG_DIRECTOR_TYPEMAPS #undef SWIG_DIRECTOR_TYPEMAPS #endif /* Tcl types */ #define SWIG_Object Tcl_Obj * /* Overload of the output/constant/exception handling */ /* output */ #define %set_output(obj) Tcl_SetObjResult(interp,obj) /* append output */ #define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj) /* set constant */ #define SWIG_SetConstant(name, obj) SWIG_Tcl_SetConstantObj(interp, name, obj) /* raise */ #define SWIG_Raise(obj,type,desc) SWIG_Tcl_SetErrorObj(interp,type,obj) /* Include the unified typemap library */ %include /* ------------------------------------------------------------ * Tcl extra typemaps / typemap overrides * ------------------------------------------------------------ */ #if 1 // Old 1.3.25 typemaps needed to avoid premature object deletion %typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE &&INSTANCE, SWIGTYPE INSTANCE[] { Tcl_SetObjResult(interp, SWIG_NewInstanceObj( %as_voidptr($1), $1_descriptor,0)); } %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,%as_voidptrptr(&$1)); Tcl_SetObjResult(interp,SWIG_NewInstanceObj(%as_voidptr($1), ty,0)); } #endif %typemap(throws,noblock=1) SWIGTYPE CLASS { SWIG_set_result(SWIG_NewInstanceObj(%as_voidptr(SWIG_new_copy($1, $1_ltype)), $&1_descriptor, 1)); SWIG_fail; } %typemap(out) SWIGTYPE = SWIGTYPE INSTANCE; %typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE; %typemap(out) SWIGTYPE *const = SWIGTYPE *; %typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE; %typemap(out) SWIGTYPE && = SWIGTYPE &&INSTANCE; %typemap(out) SWIGTYPE [] = SWIGTYPE INSTANCE[]; %typemap(varout) SWIGTYPE = SWIGTYPE INSTANCE; swig-3.0.2/Lib/tcl/wish.i0000664000175000017500000000655412343605122014771 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wish.i * * SWIG File for making wish * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %subsection "wish.i" %text %{ This module provides the Tk_AppInit() function needed to build a new version of the wish executable. Like tclsh.i, this file should not be used with dynamic loading. To make an interface file work with both static and dynamic loading, put something like this in your interface file : #ifdef STATIC %include #endif A startup file may be specified by defining the symbol SWIG_RcFileName as follows (this should be included in a code-block) : #define SWIG_RcFileName "~/.mywishrc" %} #endif %{ /* Initialization code for wish */ #include #ifndef SWIG_RcFileName char *SWIG_RcFileName = "~/.wishrc"; #endif #ifdef MAC_TCL extern int MacintoshInit _ANSI_ARGS_((void)); extern int SetupMainInterp _ANSI_ARGS_((Tcl_Interp *interp)); #endif /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in interp->result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(Tcl_Interp *interp) { #ifndef MAC_TCL Tk_Window main; main = Tk_MainWindow(interp); #endif /* * Call the init procedures for included packages. Each call should * look like this: * * if (Mod_Init(interp) == TCL_ERROR) { * return TCL_ERROR; * } * * where "Mod" is the name of the module. */ if (Tcl_Init(interp) == TCL_ERROR) { return TCL_ERROR; } if (Tk_Init(interp) == TCL_ERROR) { return TCL_ERROR; } /* * Call Tcl_CreateCommand for application-specific commands, if * they weren't already created by the init procedures called above. */ if (SWIG_init(interp) == TCL_ERROR) { return TCL_ERROR; } #ifdef MAC_TCL SetupMainInterp(interp); #endif /* * Specify a user-specific startup file to invoke if the application * is run interactively. Typically the startup file is "~/.apprc" * where "app" is the name of the application. If this line is deleted * then no user-specific startup file will be run under any conditions. */ #if TCL_MAJOR_VERSION >= 8 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5 Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY); #else tcl_RcFileName = SWIG_RcFileName; #endif /* For Macintosh might also want this */ #ifdef MAC_TCL #ifdef SWIG_RcRsrcName Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL_ONLY); #endif #endif return TCL_OK; } #if TK_MAJOR_VERSION >= 4 int main(int argc, char **argv) { #ifdef MAC_TCL char *newArgv[2]; if (MacintoshInit() != TCL_OK) { Tcl_Exit(1); } argc = 1; newArgv[0] = "Wish"; newArgv[1] = NULL; argv = newArgv; #endif Tk_Main(argc, argv, Tcl_AppInit); return(0); } #else extern int main(); #endif %} swig-3.0.2/Lib/tcl/cwstring.i0000664000175000017500000000007412343605122015646 0ustar williamwilliam%include %include swig-3.0.2/Lib/tcl/tclinterp.i0000664000175000017500000000115112343605122016007 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclinterp.i * * Tcl_Interp *interp * * Passes the current Tcl_Interp value directly to a C function. * This can be used to work with existing wrapper functions or * if you just need the interp value for some reason. When used, * the 'interp' parameter becomes hidden in the Tcl interface--that * is, you don't specify it explicitly. SWIG fills in its value * automatically. * ----------------------------------------------------------------------------- */ %typemap(in,numinputs=0) Tcl_Interp *interp { $1 = interp; } swig-3.0.2/Lib/tcl/tclfragments.swg0000664000175000017500000000105312343605122017045 0ustar williamwilliam/* Create a file with this name, 'tclfragments.swg', in your working directory and add all the %fragments you want to take precedence over the ones defined by default by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(int)(TclObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.2/Lib/tcl/std_vector.i0000664000175000017500000003641412343605122016171 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // Tcl as much as possible, namely, to allow the user to pass and // be returned Tcl lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector< T >), f(const std::vector< T >&), f(const std::vector< T >*): // the parameter being read-only, either a Tcl list or a // previously wrapped std::vector< T > can be passed. // -- f(std::vector< T >&), f(std::vector< T >*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector< T > f(): // the vector is returned by copy; therefore, a Tcl list of T:s // is returned which is most easily used in other Tcl functions procs // -- std::vector< T >& f(), std::vector< T >* f(), const std::vector< T >& f(), // const std::vector< T >* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %fragment(""); %fragment(""); %fragment(""); %{ #include Tcl_Obj* SwigString_FromString(const std::string &s) { return Tcl_NewStringObj(s.data(), (int)s.length()); } int Tcl_GetBoolFromObj(Tcl_Interp *interp, Tcl_Obj *o, bool *val) { int v; int res = Tcl_GetBooleanFromObj(interp, o, &v); if (res == TCL_OK) { *val = v ? true : false; } return res; } int SwigString_AsString(Tcl_Interp *interp, Tcl_Obj *o, std::string *val) { int len; const char* temp = Tcl_GetStringFromObj(o, &len); if (temp == NULL) return TCL_ERROR; val->assign(temp, len); return TCL_OK; } // behaviour of this is such as the real Tcl_GetIntFromObj template int SwigInt_As(Tcl_Interp *interp, Tcl_Obj *o, Type *val) { int temp_val, return_val; return_val = Tcl_GetIntFromObj(interp, o, &temp_val); *val = (Type) temp_val; return return_val; } // behaviour of this is such as the real Tcl_GetDoubleFromObj template int SwigDouble_As(Tcl_Interp *interp, Tcl_Obj *o, Type *val) { int return_val; double temp_val; return_val = Tcl_GetDoubleFromObj(interp, o, &temp_val); *val = (Type) temp_val; return return_val; } %} // exported class namespace std { template class vector { %typemap(in) vector< T > (std::vector< T > *v) { Tcl_Obj **listobjv; int nitems; int i; T* temp; if (SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0){ $1 = *v; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, \ &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; $1 = std::vector< T >(); for (i = 0; i < nitems; i++) { if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp, $descriptor(T *),0)) != 0) { char message[] = "list of " #T " expected"; Tcl_SetResult(interp, message, TCL_VOLATILE); return TCL_ERROR; } $1.push_back(*temp); } } } %typemap(in) const vector< T >* (std::vector< T > *v, std::vector< T > w), const vector< T >& (std::vector< T > *v, std::vector< T > w) { Tcl_Obj **listobjv; int nitems; int i; T* temp; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0) { $1 = v; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; w = std::vector< T >(); for (i = 0; i < nitems; i++) { if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp, $descriptor(T *),0)) != 0) { char message[] = "list of " #T " expected"; Tcl_SetResult(interp, message, TCL_VOLATILE); return TCL_ERROR; } w.push_back(*temp); } $1 = &w; } } %typemap(out) vector< T > { for (unsigned int i=0; i<$1.size(); i++) { T* ptr = new T((($1_type &)$1)[i]); Tcl_ListObjAppendElement(interp, $result, \ SWIG_NewInstanceObj(ptr, $descriptor(T *), 0)); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector< T > { Tcl_Obj **listobjv; int nitems; T* temp; std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0) { /* wrapped vector */ $1 = 1; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; else if (nitems == 0) $1 = 1; //check the first value to see if it is of correct type else if ((SWIG_ConvertPtr(listobjv[0], (void **) &temp, $descriptor(T *),0)) != 0) $1 = 0; else $1 = 1; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector< T >&, const vector< T >* { Tcl_Obj **listobjv; int nitems; T* temp; std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $1_descriptor, 0) == 0){ /* wrapped vector */ $1 = 1; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; else if (nitems == 0) $1 = 1; //check the first value to see if it is of correct type else if ((SWIG_ConvertPtr(listobjv[0], (void **) &temp, $descriptor(T *),0)) != 0) $1 = 0; else $1 = 1; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector< T > &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(const T& x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T& get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i += size; if (i>=0 && isize()); if (i<0) i+= size; if (i>=0 && i class vector< T > { %typemap(in) vector< T > (std::vector< T > *v){ Tcl_Obj **listobjv; int nitems; int i; T temp; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0) { $1 = *v; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; $1 = std::vector< T >(); for (i = 0; i < nitems; i++) { if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR) return TCL_ERROR; $1.push_back(temp); } } } %typemap(in) const vector< T >& (std::vector< T > *v,std::vector< T > w), const vector< T >* (std::vector< T > *v,std::vector< T > w) { Tcl_Obj **listobjv; int nitems; int i; T temp; if(SWIG_ConvertPtr($input, (void **) &v, \ $1_descriptor, 0) == 0) { $1 = v; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; w = std::vector< T >(); for (i = 0; i < nitems; i++) { if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR) return TCL_ERROR; w.push_back(temp); } $1 = &w; } } %typemap(out) vector< T > { for (unsigned int i=0; i<$1.size(); i++) { Tcl_ListObjAppendElement(interp, $result, \ CONVERT_TO((($1_type &)$1)[i])); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector< T > { Tcl_Obj **listobjv; int nitems; T temp; std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0){ /* wrapped vector */ $1 = 1; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; else if (nitems == 0) $1 = 1; //check the first value to see if it is of correct type if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR) $1 = 0; else $1 = 1; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector< T >&, const vector< T >*{ Tcl_Obj **listobjv; int nitems; T temp; std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $1_descriptor, 0) == 0){ /* wrapped vector */ $1 = 1; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; else if (nitems == 0) $1 = 1; //check the first value to see if it is of correct type if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR) $1 = 0; else $1 = 1; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector< T > &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(T x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i += size; if (i>=0 && isize()); if (i<0) i+= size; if (i>=0 && i,Tcl_NewIntObj); specialize_std_vector(int, Tcl_GetIntFromObj,Tcl_NewIntObj); specialize_std_vector(short, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(long, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(unsigned char, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(unsigned int, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(unsigned short, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(unsigned long, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(double, Tcl_GetDoubleFromObj, Tcl_NewDoubleObj); specialize_std_vector(float, SwigDouble_As, Tcl_NewDoubleObj); specialize_std_vector(std::string, SwigString_AsString, SwigString_FromString); } swig-3.0.2/Lib/tcl/std_string.i0000664000175000017500000000004412343605122016163 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/tclsh.i0000664000175000017500000000351712343605122015130 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclsh.i * * SWIG File for building new tclsh program * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %subsection "tclsh.i" %text %{ This module provides the Tcl_AppInit() function needed to build a new version of the tclsh executable. This file should not be used when using dynamic loading. To make an interface file work with both static and dynamic loading, put something like this in your interface file : #ifdef STATIC %include #endif %} #endif %{ /* A TCL_AppInit() function that lets you build a new copy * of tclsh. * * The macro SWIG_init contains the name of the initialization * function in the wrapper file. */ #ifndef SWIG_RcFileName char *SWIG_RcFileName = "~/.myapprc"; #endif #ifdef MAC_TCL extern int MacintoshInit _ANSI_ARGS_((void)); #endif int Tcl_AppInit(Tcl_Interp *interp){ if (Tcl_Init(interp) == TCL_ERROR) return TCL_ERROR; /* Now initialize our functions */ if (SWIG_init(interp) == TCL_ERROR) return TCL_ERROR; #if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5 Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY); #else tcl_RcFileName = SWIG_RcFileName; #endif #ifdef SWIG_RcRsrcName Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL); #endif return TCL_OK; } #if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 4 int main(int argc, char **argv) { #ifdef MAC_TCL char *newArgv[2]; if (MacintoshInit() != TCL_OK) { Tcl_Exit(1); } argc = 1; newArgv[0] = "tclsh"; newArgv[1] = NULL; argv = newArgv; #endif Tcl_Main(argc, argv, Tcl_AppInit); return(0); } #else extern int main(); #endif %} swig-3.0.2/Lib/tcl/std_except.i0000664000175000017500000000004312343605122016144 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/stl.i0000664000175000017500000000054512343605122014613 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ /* initial STL definition. extended as needed in each language */ %include %include %include %include %include swig-3.0.2/Lib/tcl/mactkinit.c0000664000175000017500000001236612343605122015772 0ustar williamwilliam/* ----------------------------------------------------------------------------- * mactkinit.c * * This is a support file needed to build a new version of Wish. * Normally, this capability is found in TkAppInit.c, but this creates * tons of namespace problems for many applications. * ----------------------------------------------------------------------------- */ #include #include #include #include #include #include #include "tk.h" #include "tkInt.h" #include "tkMacInt.h" typedef int (*TclMacConvertEventPtr) _ANSI_ARGS_((EventRecord *eventPtr)); Tcl_Interp *gStdoutInterp = NULL; void TclMacSetEventProc _ANSI_ARGS_((TclMacConvertEventPtr procPtr)); int TkMacConvertEvent _ANSI_ARGS_((EventRecord *eventPtr)); /* * Prototypes for functions the ANSI library needs to link against. */ short InstallConsole _ANSI_ARGS_((short fd)); void RemoveConsole _ANSI_ARGS_((void)); long WriteCharsToConsole _ANSI_ARGS_((char *buff, long n)); long ReadCharsFromConsole _ANSI_ARGS_((char *buff, long n)); char * __ttyname _ANSI_ARGS_((long fildes)); short SIOUXHandleOneEvent _ANSI_ARGS_((EventRecord *event)); /* * Forward declarations for procedures defined later in this file: */ /* *---------------------------------------------------------------------- * * MacintoshInit -- * * This procedure calls Mac specific initilization calls. Most of * these calls must be made as soon as possible in the startup * process. * * Results: * Returns TCL_OK if everything went fine. If it didn't the * application should probably fail. * * Side effects: * Inits the application. * *---------------------------------------------------------------------- */ int MacintoshInit() { int i; long result, mask = 0x0700; /* mask = system 7.x */ /* * Tk needs us to set the qd pointer it uses. This is needed * so Tk doesn't have to assume the availablity of the qd global * variable. Which in turn allows Tk to be used in code resources. */ tcl_macQdPtr = &qd; InitGraf(&tcl_macQdPtr->thePort); InitFonts(); InitWindows(); InitMenus(); InitDialogs((long) NULL); InitCursor(); /* * Make sure we are running on system 7 or higher */ if ((NGetTrapAddress(_Gestalt, ToolTrap) == NGetTrapAddress(_Unimplemented, ToolTrap)) || (((Gestalt(gestaltSystemVersion, &result) != noErr) || (mask != (result & mask))))) { panic("Tcl/Tk requires System 7 or higher."); } /* * Make sure we have color quick draw * (this means we can't run on 68000 macs) */ if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr) || (result < gestalt32BitQD13))) { panic("Tk requires Color QuickDraw."); } FlushEvents(everyEvent, 0); SetEventMask(everyEvent); /* * Set up stack & heap sizes */ /* TODO: stack size size = StackSpace(); SetAppLimit(GetAppLimit() - 8192); */ MaxApplZone(); for (i = 0; i < 4; i++) { (void) MoreMasters(); } TclMacSetEventProc(TkMacConvertEvent); TkConsoleCreate(); return TCL_OK; } /* *---------------------------------------------------------------------- * * SetupMainInterp -- * * This procedure calls initalization routines require a Tcl * interp as an argument. This call effectively makes the passed * iterpreter the "main" interpreter for the application. * * Results: * Returns TCL_OK if everything went fine. If it didn't the * application should probably fail. * * Side effects: * More initilization. * *---------------------------------------------------------------------- */ int SetupMainInterp( Tcl_Interp *interp) { /* * Initialize the console only if we are running as an interactive * application. */ TkMacInitAppleEvents(interp); TkMacInitMenus(interp); if (strcmp(Tcl_GetVar(interp, "tcl_interactive", TCL_GLOBAL_ONLY), "1") == 0) { if (TkConsoleInit(interp) == TCL_ERROR) { goto error; } } /* * Attach the global interpreter to tk's expected global console */ gStdoutInterp = interp; return TCL_OK; error: panic(interp->result); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * InstallConsole, RemoveConsole, etc. -- * * The following functions provide the UI for the console package. * Users wishing to replace SIOUX with their own console package * need only provide the four functions below in a library. * * Results: * See SIOUX documentation for details. * * Side effects: * See SIOUX documentation for details. * *---------------------------------------------------------------------- */ short InstallConsole(short fd) { #pragma unused (fd) return 0; } void RemoveConsole(void) { } long WriteCharsToConsole(char *buffer, long n) { TkConsolePrint(gStdoutInterp, TCL_STDOUT, buffer, n); return n; } long ReadCharsFromConsole(char *buffer, long n) { return 0; } extern char * __ttyname(long fildes) { static char *devicename = "null device"; if (fildes >= 0 && fildes <= 2) { return (devicename); } return (0L); } short SIOUXHandleOneEvent(EventRecord *event) { return 0; } swig-3.0.2/Lib/tcl/std_deque.i0000664000175000017500000000003412343605122015757 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/cpointer.i0000664000175000017500000000004112343605122015623 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/tclmacros.swg0000664000175000017500000000004612343605122016344 0ustar williamwilliam%include swig-3.0.2/Lib/tcl/Makefile.in0000664000175000017500000000704712343605122015710 0ustar williamwilliam# --------------------------------------------------------------- # SWIG Tcl Makefile # # This file can be used to build various Tcl extensions with SWIG. # By default this file is set up for dynamic loading, but it can # be easily customized for static extensions by modifying various # portions of the file. # # SRCS = C source files # CXXSRCS = C++ source files # OBJCSRCS = Objective-C source files # OBJS = Additional .o files (compiled previously) # INTERFACE = SWIG interface file # TARGET = Name of target module or executable # # Many portions of this file were created by the SWIG configure # script and should already reflect your machine. However, you # may need to modify the Makefile to reflect your specific # application. #---------------------------------------------------------------- SRCS = CXXSRCS = OBJCSRCS = OBJS = INTERFACE = WRAPFILE = $(INTERFACE:.i=_wrap.c) WRAPOBJ = $(INTERFACE:.i=_wrap.o) TARGET = module@SO@ # Use this kind of target for dynamic loading #TARGET = my_tclsh # Use this target for static linking prefix = @prefix@ exec_prefix = @exec_prefix@ CC = @CC@ CXX = @CXX@ OBJC = @CC@ -Wno-import # -Wno-import needed for gcc CFLAGS = INCLUDES = LIBS = # SWIG Options # SWIG = location of the SWIG executable # SWIGOPT = SWIG compiler options # SWIGCC = Compiler used to compile the wrapper file SWIG = $(exec_prefix)/bin/swig SWIGOPT = -tcl # use -tcl8 for Tcl 8.0 SWIGCC = $(CC) # SWIG Library files. Uncomment if rebuilding tclsh #SWIGLIBS = -ltclsh.i # Rules for creating .o files from source. COBJS = $(SRCS:.c=.o) CXXOBJS = $(CXXSRCS:.cxx=.o) OBJCOBJS = $(OBJCSRCS:.m=.o) ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS) # Command that will be used to build the final extension. BUILD = $(SWIGCC) # Uncomment the following if you are using dynamic loading CCSHARED = @CCSHARED@ BUILD = @LDSHARED@ # Uncomment the following if you are using dynamic loading with C++ and # need to provide additional link libraries (this is not always required). #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc # Tcl installation (where is Tcl located) TCL_INCLUDE = @TCLINCLUDE@ TCL_LIB = @TCLLIB@ # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ # Build options (uncomment only one of these) BUILD_LIBS = $(LIBS) # Dynamic loading #BUILD_LIBS = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh # Compilation rules for non-SWIG components .SUFFIXES: .c .cxx .m .c.o: $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< .cxx.o: $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $< .m.o: $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< # ---------------------------------------------------------------------- # Rules for building the extension # ---------------------------------------------------------------------- all: $(TARGET) # Convert the wrapper file into an object file $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(TCL_INCLUDE) $(WRAPFILE) : $(INTERFACE) $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) clean: rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) swig-3.0.2/Lib/tcl/std_wstring.i0000664000175000017500000000007712343605122016360 0ustar williamwilliam%include %include swig-3.0.2/Lib/tcl/tclrun.swg0000664000175000017500000005303612343605122015673 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclrun.swg * * This file contains the runtime support for Tcl modules and includes * code for managing global variables and pointer type checking. * ----------------------------------------------------------------------------- */ /* Common SWIG API */ /* for raw pointers */ #define SWIG_ConvertPtr(oc, ptr, ty, flags) SWIG_Tcl_ConvertPtr(interp, oc, ptr, ty, flags) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Tcl_NewPointerObj(ptr, type, flags) /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Tcl_ConvertPacked(interp, obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, flags) #define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_Tcl_NewInstanceObj(interp, thisvalue, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Tcl_NewPointerObj(ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Tcl_ConvertPacked(interp,obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Tcl_GetModule((Tcl_Interp *) (clientdata)) #define SWIG_SetModule(clientdata, pointer) SWIG_Tcl_SetModule((Tcl_Interp *) (clientdata), pointer) /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Tcl_ErrorType(code) #define SWIG_Error(code, msg) SWIG_Tcl_SetErrorMsg(interp, SWIG_Tcl_ErrorType(code), msg) #define SWIG_fail goto fail /* Tcl-specific SWIG API */ #define SWIG_Acquire(ptr) SWIG_Tcl_Acquire(ptr) #define SWIG_MethodCommand SWIG_Tcl_MethodCommand #define SWIG_Disown(ptr) SWIG_Tcl_Disown(ptr) #define SWIG_ConvertPtrFromString(c, ptr, ty, flags) SWIG_Tcl_ConvertPtrFromString(interp, c, ptr, ty, flags) #define SWIG_MakePtr(c, ptr, ty, flags) SWIG_Tcl_MakePtr(c, ptr, ty, flags) #define SWIG_PointerTypeFromString(c) SWIG_Tcl_PointerTypeFromString(c) #define SWIG_GetArgs SWIG_Tcl_GetArgs #define SWIG_GetConstantObj(key) SWIG_Tcl_GetConstantObj(key) #define SWIG_ObjectConstructor SWIG_Tcl_ObjectConstructor #define SWIG_Thisown(ptr) SWIG_Tcl_Thisown(ptr) #define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete #define SWIG_TCL_DECL_ARGS_2(arg1, arg2) (Tcl_Interp *interp SWIGUNUSED, arg1, arg2) #define SWIG_TCL_CALL_ARGS_2(arg1, arg2) (interp, arg1, arg2) /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #define SWIG_GetConstant SWIG_GetConstantObj #define SWIG_Tcl_GetConstant SWIG_Tcl_GetConstantObj #include "assert.h" #ifdef __cplusplus extern "C" { #endif /* Object support */ SWIGRUNTIME Tcl_HashTable* SWIG_Tcl_ObjectTable(void) { static Tcl_HashTable swigobjectTable; static int swigobjectTableinit = 0; if (!swigobjectTableinit) { Tcl_InitHashTable(&swigobjectTable, TCL_ONE_WORD_KEYS); swigobjectTableinit = 1; } return &swigobjectTable; } /* Acquire ownership of a pointer */ SWIGRUNTIME void SWIG_Tcl_Acquire(void *ptr) { int newobj; Tcl_CreateHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr, &newobj); } SWIGRUNTIME int SWIG_Tcl_Thisown(void *ptr) { if (Tcl_FindHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr)) { return 1; } return 0; } /* Disown a pointer. Returns 1 if we owned it to begin with */ SWIGRUNTIME int SWIG_Tcl_Disown(void *ptr) { Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr); if (entryPtr) { Tcl_DeleteHashEntry(entryPtr); return 1; } return 0; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swig_type_info *ty, int flags) { swig_cast_info *tc; /* Pointer values must start with leading underscore */ while (*c != '_') { *ptr = (void *) 0; if (strcmp(c,"NULL") == 0) return SWIG_OK; /* Empty string: not a pointer */ if (*c == 0) return SWIG_ERROR; /* Hmmm. It could be an object name. */ /* Check if this is a command at all. Prevents cget -this */ /* from being called when c is not a command, firing the unknown proc */ if (Tcl_VarEval(interp,"info commands ", c, (char *) NULL) == TCL_OK) { Tcl_Obj *result = Tcl_GetObjResult(interp); if (*(Tcl_GetStringFromObj(result, NULL)) == 0) { /* It's not a command, so it can't be a pointer */ Tcl_ResetResult(interp); return SWIG_ERROR; } } else { /* This will only fail if the argument is multiple words. */ /* Multiple words are also not commands. */ Tcl_ResetResult(interp); return SWIG_ERROR; } /* Check if this is really a SWIG pointer */ if (Tcl_VarEval(interp,c," cget -this", (char *) NULL) != TCL_OK) { Tcl_ResetResult(interp); return SWIG_ERROR; } c = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), NULL); } c++; c = SWIG_UnpackData(c,ptr,sizeof(void *)); if (ty) { tc = c ? SWIG_TypeCheck(c,ty) : 0; if (!tc) { return SWIG_ERROR; } if (flags & SWIG_POINTER_DISOWN) { SWIG_Disown((void *) *ptr); } { int newmemory = 0; *ptr = SWIG_TypeCast(tc,(void *) *ptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } } return SWIG_OK; } /* Convert a pointer value */ SWIGRUNTIMEINLINE int SWIG_Tcl_ConvertPtr(Tcl_Interp *interp, Tcl_Obj *oc, void **ptr, swig_type_info *ty, int flags) { return SWIG_Tcl_ConvertPtrFromString(interp, Tcl_GetStringFromObj(oc,NULL), ptr, ty, flags); } /* Convert a pointer value */ SWIGRUNTIME char * SWIG_Tcl_PointerTypeFromString(char *c) { char d; /* Pointer values must start with leading underscore. NULL has no type */ if (*c != '_') { return 0; } c++; /* Extract hex value from pointer */ while ((d = *c)) { if (!(((d >= '0') && (d <= '9')) || ((d >= 'a') && (d <= 'f')))) break; c++; } return c; } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Tcl_ConvertPacked(Tcl_Interp *SWIGUNUSEDPARM(interp) , Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; const char *c; if (!obj) goto type_error; c = Tcl_GetStringFromObj(obj,NULL); /* Pointer values must start with leading underscore */ if (*c != '_') goto type_error; c++; c = SWIG_UnpackData(c,ptr,sz); if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; } return SWIG_OK; type_error: return SWIG_ERROR; } /* Take a pointer and convert it to a string */ SWIGRUNTIME void SWIG_Tcl_MakePtr(char *c, void *ptr, swig_type_info *ty, int flags) { if (ptr) { *(c++) = '_'; c = SWIG_PackData(c,&ptr,sizeof(void *)); strcpy(c,ty->name); } else { strcpy(c,(char *)"NULL"); } flags = 0; } /* Create a new pointer object */ SWIGRUNTIMEINLINE Tcl_Obj * SWIG_Tcl_NewPointerObj(void *ptr, swig_type_info *type, int flags) { Tcl_Obj *robj; char result[SWIG_BUFFER_SIZE]; SWIG_MakePtr(result,ptr,type,flags); robj = Tcl_NewStringObj(result,-1); return robj; } SWIGRUNTIME Tcl_Obj * SWIG_Tcl_NewPackedObj(void *ptr, int sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); strcpy(r,type->name); return Tcl_NewStringObj(result,-1); } /* -----------------------------------------------------------------------------* * Get type list * -----------------------------------------------------------------------------*/ SWIGRUNTIME swig_module_info * SWIG_Tcl_GetModule(Tcl_Interp *interp) { const char *data; swig_module_info *ret = 0; /* first check if pointer already created */ data = Tcl_GetVar(interp, (char *)"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TCL_GLOBAL_ONLY); if (data) { SWIG_UnpackData(data, &ret, sizeof(swig_type_info **)); } return ret; } SWIGRUNTIME void SWIG_Tcl_SetModule(Tcl_Interp *interp, swig_module_info *module) { char buf[SWIG_BUFFER_SIZE]; char *data; /* create a new pointer */ data = SWIG_PackData(buf, &module, sizeof(swig_type_info **)); *data = 0; Tcl_SetVar(interp, (char *)"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, TCL_GLOBAL_ONLY); } /* -----------------------------------------------------------------------------* * Object auxiliars * -----------------------------------------------------------------------------*/ SWIGRUNTIME void SWIG_Tcl_ObjectDelete(ClientData clientData) { swig_instance *si = (swig_instance *) clientData; if ((si) && (si->destroy) && (SWIG_Disown(si->thisvalue))) { if (si->classptr->destructor) { (si->classptr->destructor)(si->thisvalue); } } Tcl_DecrRefCount(si->thisptr); free(si); } /* Function to invoke object methods given an instance */ SWIGRUNTIME int SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST _objv[]) { char *method, *attrname; swig_instance *inst = (swig_instance *) clientData; swig_method *meth; swig_attribute *attr; Tcl_Obj *oldarg; Tcl_Obj **objv; int rcode; swig_class *cls; swig_class *cls_stack[64]; int cls_stack_bi[64]; int cls_stack_top = 0; int numconf = 2; int bi; objv = (Tcl_Obj **) _objv; if (objc < 2) { Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); return TCL_ERROR; } method = Tcl_GetStringFromObj(objv[1],NULL); if (strcmp(method,"-acquire") == 0) { inst->destroy = 1; SWIG_Acquire(inst->thisvalue); return TCL_OK; } if (strcmp(method,"-disown") == 0) { if (inst->destroy) { SWIG_Disown(inst->thisvalue); } inst->destroy = 0; return TCL_OK; } if (strcmp(method,"-delete") == 0) { Tcl_DeleteCommandFromToken(interp,inst->cmdtok); return TCL_OK; } cls_stack[cls_stack_top] = inst->classptr; cls_stack_bi[cls_stack_top] = -1; cls = inst->classptr; while (1) { Tcl_HashEntry* hashentry; bi = cls_stack_bi[cls_stack_top]; cls = cls_stack[cls_stack_top]; if (bi != -1) { if (!cls->bases[bi] && cls->base_names[bi]) { /* lookup and cache the base class */ swig_type_info *info = SWIG_TypeQueryModule(cls->module, cls->module, cls->base_names[bi]); if (info) cls->bases[bi] = (swig_class *) info->clientdata; } cls = cls->bases[bi]; if (cls) { cls_stack_bi[cls_stack_top]++; cls_stack_top++; cls_stack[cls_stack_top] = cls; cls_stack_bi[cls_stack_top] = -1; continue; } } if (!cls) { cls_stack_top--; if (cls_stack_top < 0) break; else continue; } cls_stack_bi[cls_stack_top]++; hashentry = Tcl_FindHashEntry(&(cls->hashtable), method); if (hashentry) { ClientData cd = Tcl_GetHashValue(hashentry); swig_wrapper method_wrapper = (swig_wrapper)cd; oldarg = objv[1]; objv[1] = inst->thisptr; Tcl_IncrRefCount(inst->thisptr); rcode = (method_wrapper)(clientData,interp,objc,objv); objv[1] = oldarg; Tcl_DecrRefCount(inst->thisptr); return rcode; } /* Check class methods for a match */ if (strcmp(method,"cget") == 0) { if (objc < 3) { Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); return TCL_ERROR; } attrname = Tcl_GetStringFromObj(objv[2],NULL); attr = cls->attributes; while (attr && attr->name) { if ((strcmp(attr->name, attrname) == 0) && (attr->getmethod)) { oldarg = objv[1]; objv[1] = inst->thisptr; Tcl_IncrRefCount(inst->thisptr); rcode = (*attr->getmethod)(clientData,interp,2, objv); objv[1] = oldarg; Tcl_DecrRefCount(inst->thisptr); return rcode; } attr++; } if (strcmp(attrname, "-this") == 0) { Tcl_SetObjResult(interp, Tcl_DuplicateObj(inst->thisptr)); return TCL_OK; } if (strcmp(attrname, "-thisown") == 0) { if (SWIG_Thisown(inst->thisvalue)) { Tcl_SetResult(interp,(char*)"1",TCL_STATIC); } else { Tcl_SetResult(interp,(char*)"0",TCL_STATIC); } return TCL_OK; } } else if (strcmp(method, "configure") == 0) { int i; if (objc < 4) { Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); return TCL_ERROR; } i = 2; while (i < objc) { attrname = Tcl_GetStringFromObj(objv[i],NULL); attr = cls->attributes; while (attr && attr->name) { if ((strcmp(attr->name, attrname) == 0) && (attr->setmethod)) { oldarg = objv[i]; objv[i] = inst->thisptr; Tcl_IncrRefCount(inst->thisptr); rcode = (*attr->setmethod)(clientData,interp,3, &objv[i-1]); objv[i] = oldarg; Tcl_DecrRefCount(inst->thisptr); if (rcode != TCL_OK) return rcode; numconf += 2; } attr++; } i+=2; } } } if (strcmp(method,"configure") == 0) { if (numconf >= objc) { return TCL_OK; } else { Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC); return TCL_ERROR; } } if (strcmp(method,"cget") == 0) { Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC); return TCL_ERROR; } Tcl_SetResult(interp, (char *) "Invalid method. Must be one of: configure cget -acquire -disown -delete", TCL_STATIC); cls = inst->classptr; bi = 0; while (cls) { meth = cls->methods; while (meth && meth->name) { char *cr = (char *) Tcl_GetStringResult(interp); size_t meth_len = strlen(meth->name); char* where = strchr(cr,':'); while(where) { where = strstr(where, meth->name); if(where) { if(where[-1] == ' ' && (where[meth_len] == ' ' || where[meth_len]==0)) { break; } else { where++; } } } if (!where) Tcl_AppendElement(interp, (char *) meth->name); meth++; } cls = inst->classptr->bases[bi++]; } return TCL_ERROR; } /* This function takes the current result and turns it into an object command */ SWIGRUNTIME Tcl_Obj * SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *type, int flags) { Tcl_Obj *robj = SWIG_NewPointerObj(thisvalue, type,0); /* Check to see if this pointer belongs to a class or not */ if (thisvalue && (type->clientdata) && (interp)) { Tcl_CmdInfo ci; char *name; name = Tcl_GetStringFromObj(robj,NULL); if (!Tcl_GetCommandInfo(interp,name, &ci) || (flags)) { swig_instance *newinst = (swig_instance *) malloc(sizeof(swig_instance)); newinst->thisptr = Tcl_DuplicateObj(robj); Tcl_IncrRefCount(newinst->thisptr); newinst->thisvalue = thisvalue; newinst->classptr = (swig_class *) type->clientdata; newinst->destroy = flags; newinst->cmdtok = Tcl_CreateObjCommand(interp, Tcl_GetStringFromObj(robj,NULL), (swig_wrapper_func) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete); if (flags) { SWIG_Acquire(thisvalue); } } } return robj; } /* Function to create objects */ SWIGRUNTIME int SWIG_Tcl_ObjectConstructor(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *newObj = 0; void *thisvalue = 0; swig_instance *newinst = 0; swig_class *classptr = (swig_class *) clientData; swig_wrapper cons = 0; char *name = 0; int firstarg = 0; int thisarg = 0; int destroy = 1; if (!classptr) { Tcl_SetResult(interp, (char *) "swig: internal runtime error. No class object defined.", TCL_STATIC); return TCL_ERROR; } cons = classptr->constructor; if (objc > 1) { char *s = Tcl_GetStringFromObj(objv[1],NULL); if (strcmp(s,"-this") == 0) { thisarg = 2; cons = 0; } else if (strcmp(s,"-args") == 0) { firstarg = 1; } else if (objc == 2) { firstarg = 1; name = s; } else if (objc >= 3) { char *s1; name = s; s1 = Tcl_GetStringFromObj(objv[2],NULL); if (strcmp(s1,"-this") == 0) { thisarg = 3; cons = 0; } else { firstarg = 1; } } } if (cons) { int result; result = (*cons)(0, interp, objc-firstarg, &objv[firstarg]); if (result != TCL_OK) { return result; } newObj = Tcl_DuplicateObj(Tcl_GetObjResult(interp)); if (!name) name = Tcl_GetStringFromObj(newObj,NULL); } else if (thisarg > 0) { if (thisarg < objc) { destroy = 0; newObj = Tcl_DuplicateObj(objv[thisarg]); if (!name) name = Tcl_GetStringFromObj(newObj,NULL); } else { Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); return TCL_ERROR; } } else { Tcl_SetResult(interp, (char *) "No constructor available.", TCL_STATIC); return TCL_ERROR; } if (SWIG_Tcl_ConvertPtr(interp,newObj, (void **) &thisvalue, *(classptr->type), 0) != SWIG_OK) { Tcl_DecrRefCount(newObj); return TCL_ERROR; } newinst = (swig_instance *) malloc(sizeof(swig_instance)); newinst->thisptr = newObj; Tcl_IncrRefCount(newObj); newinst->thisvalue = thisvalue; newinst->classptr = classptr; newinst->destroy = destroy; if (destroy) { SWIG_Acquire(thisvalue); } newinst->cmdtok = Tcl_CreateObjCommand(interp,name, (swig_wrapper) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete); return TCL_OK; } /* -----------------------------------------------------------------------------* * Get arguments * -----------------------------------------------------------------------------*/ SWIGRUNTIME int SWIG_Tcl_GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], const char *fmt, ...) { int argno = 0, opt = 0; long tempi; double tempd; const char *c; va_list ap; void *vptr; Tcl_Obj *obj = 0; swig_type_info *ty; va_start(ap,fmt); for (c = fmt; (*c && (*c != ':') && (*c != ';')); c++,argno++) { if (*c == '|') { opt = 1; c++; } if (argno >= (objc-1)) { if (!opt) { Tcl_SetResult(interp, (char *) "Wrong number of arguments ", TCL_STATIC); goto argerror; } else { va_end(ap); return TCL_OK; } } vptr = va_arg(ap,void *); if (vptr) { if (isupper(*c)) { obj = SWIG_Tcl_GetConstantObj(Tcl_GetStringFromObj(objv[argno+1],0)); if (!obj) obj = objv[argno+1]; } else { obj = objv[argno+1]; } switch(*c) { case 'i': case 'I': case 'l': case 'L': case 'h': case 'H': case 'b': case 'B': if (Tcl_GetLongFromObj(interp,obj,&tempi) != TCL_OK) goto argerror; if ((*c == 'i') || (*c == 'I')) *((int *)vptr) = (int)tempi; else if ((*c == 'l') || (*c == 'L')) *((long *)vptr) = (long)tempi; else if ((*c == 'h') || (*c == 'H')) *((short*)vptr) = (short)tempi; else if ((*c == 'b') || (*c == 'B')) *((unsigned char *)vptr) = (unsigned char)tempi; break; case 'f': case 'F': case 'd': case 'D': if (Tcl_GetDoubleFromObj(interp,obj,&tempd) != TCL_OK) goto argerror; if ((*c == 'f') || (*c == 'F')) *((float *) vptr) = (float)tempd; else if ((*c == 'd') || (*c == 'D')) *((double*) vptr) = tempd; break; case 's': case 'S': if (*(c+1) == '#') { int *vlptr = (int *) va_arg(ap, void *); *((char **) vptr) = Tcl_GetStringFromObj(obj, vlptr); c++; } else { *((char **)vptr) = Tcl_GetStringFromObj(obj,NULL); } break; case 'c': case 'C': *((char *)vptr) = *(Tcl_GetStringFromObj(obj,NULL)); break; case 'p': case 'P': ty = (swig_type_info *) va_arg(ap, void *); if (SWIG_Tcl_ConvertPtr(interp, obj, (void **) vptr, ty, 0) != SWIG_OK) goto argerror; break; case 'o': case 'O': *((Tcl_Obj **)vptr) = objv[argno+1]; break; default: break; } } } if ((*c != ';') && ((objc-1) > argno)) { Tcl_SetResult(interp, (char *) "Wrong # args.", TCL_STATIC); goto argerror; } va_end(ap); return TCL_OK; argerror: { char temp[32]; sprintf(temp,"%d", argno+1); c = strchr(fmt,':'); if (!c) c = strchr(fmt,';'); if (!c) c = (char *)""; Tcl_AppendResult(interp,c," argument ", temp, NULL); va_end(ap); return TCL_ERROR; } } #ifdef __cplusplus } #endif swig-3.0.2/Lib/tcl/tclinit.swg0000664000175000017500000000774312343605122016036 0ustar williamwilliam/* ------------------------------------------------------------ * The start of the Tcl initialization function * ------------------------------------------------------------ */ %insert(init) "swiginit.swg" /* This initialization code exports the module initialization function */ %header %{ #ifdef __cplusplus extern "C" { #endif #ifdef MAC_TCL #pragma export on #endif SWIGEXPORT int SWIG_init(Tcl_Interp *); #ifdef MAC_TCL #pragma export off #endif #ifdef __cplusplus } #endif /* Compatibility version for TCL stubs */ #ifndef SWIG_TCL_STUBS_VERSION #define SWIG_TCL_STUBS_VERSION "8.1" #endif %} %init %{ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ SWIGINTERN void SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) { size_t i; Tcl_Obj *obj; if (!swigconstTableinit) { Tcl_InitHashTable(&swigconstTable, TCL_STRING_KEYS); swigconstTableinit = 1; } for (i = 0; constants[i].type; i++) { switch(constants[i].type) { case SWIG_TCL_POINTER: obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_TCL_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { SWIG_Tcl_SetConstantObj(interp, constants[i].name, obj); } } } /* Create fast method lookup tables */ SWIGINTERN void SWIG_Tcl_InstallMethodLookupTables(void) { size_t i; for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = swig_module.type_initial[i]; if (type->clientdata) { swig_class* klass = (swig_class*) type->clientdata; swig_method* meth; Tcl_InitHashTable(&(klass->hashtable), TCL_STRING_KEYS); for (meth = klass->methods; meth && meth->name; ++meth) { int newEntry; Tcl_HashEntry* hashentry = Tcl_CreateHashEntry(&(klass->hashtable), meth->name, &newEntry); Tcl_SetHashValue(hashentry, (ClientData)meth->method); } } } } #ifdef __cplusplus } #endif /* -----------------------------------------------------------------------------* * Partial Init method * -----------------------------------------------------------------------------*/ SWIGEXPORT int SWIG_init(Tcl_Interp *interp) { size_t i; if (interp == 0) return TCL_ERROR; #ifdef USE_TCL_STUBS /* (char*) cast is required to avoid compiler warning/error for Tcl < 8.4. */ if (Tcl_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) { return TCL_ERROR; } #endif #ifdef USE_TK_STUBS /* (char*) cast is required to avoid compiler warning/error. */ if (Tk_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) { return TCL_ERROR; } #endif Tcl_PkgProvide(interp, (char*)SWIG_name, (char*)SWIG_version); #ifdef SWIG_namespace Tcl_Eval(interp, "namespace eval " SWIG_namespace " { }"); #endif SWIG_InitializeModule((void *) interp); SWIG_PropagateClientData(); for (i = 0; swig_commands[i].name; i++) { Tcl_CreateObjCommand(interp, (char *) swig_commands[i].name, (swig_wrapper_func) swig_commands[i].wrapper, swig_commands[i].clientdata, NULL); } for (i = 0; swig_variables[i].name; i++) { Tcl_SetVar(interp, (char *) swig_variables[i].name, (char *) "", TCL_GLOBAL_ONLY); Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY, (Tcl_VarTraceProc *) swig_variables[i].get, (ClientData) swig_variables[i].addr); Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, (Tcl_VarTraceProc *) swig_variables[i].set, (ClientData) swig_variables[i].addr); } SWIG_Tcl_InstallConstants(interp, swig_constants); SWIG_Tcl_InstallMethodLookupTables(); %} /* Note: the initialization function is closed after all code is generated */ swig-3.0.2/Lib/tcl/tclprimtypes.swg0000664000175000017500000001274612343605122017126 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* boolean */ %fragment(SWIG_From_frag(bool),"header") { %define_as(SWIG_From_dec(bool), Tcl_NewBooleanObj) } %fragment(SWIG_AsVal_frag(bool),"header") { SWIGINTERN int SWIG_AsVal_dec(bool)(Tcl_Obj *obj, bool *val) { int v; if (Tcl_GetBooleanFromObj(0, obj, &v) == TCL_OK) { if (val) *val = v ? true : false; return SWIG_OK; } return SWIG_TypeError; } } /* long */ %fragment(SWIG_From_frag(long),"header", fragment="") { SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(long)(long value) { if (((long) INT_MIN <= value) && (value <= (long) INT_MAX)) { return Tcl_NewIntObj(%numeric_cast(value,int)); } else { return Tcl_NewLongObj(value); } } } %fragment(SWIG_AsVal_frag(long),"header") { SWIGINTERN int SWIG_AsVal_dec(long)(Tcl_Obj *obj, long* val) { long v; if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { if (val) *val = (long) v; return SWIG_OK; } return SWIG_TypeError; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(unsigned long)(unsigned long value) { if (value < (unsigned long) LONG_MAX) { return SWIG_From(long)(%numeric_cast(value, long)); } else { char temp[256]; sprintf(temp, "%lu", value); return Tcl_NewStringObj(temp,-1); } } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(Tcl_Obj *obj, unsigned long *val) { long v; if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { if (v >= 0) { if (val) *val = (unsigned long) v; return SWIG_OK; } /* If v is negative, then this could be a negative number, or an unsigned value which doesn't fit in a signed long, so try to get it as a string so we can distinguish these cases. */ } { int len = 0; const char *nptr = Tcl_GetStringFromObj(obj, &len); if (nptr && len > 0) { char *endptr; unsigned long v; if (*nptr == '-') return SWIG_OverflowError; errno = 0; v = strtoul(nptr, &endptr,0); if (nptr[0] == '\0' || *endptr != '\0') return SWIG_TypeError; if (v == ULONG_MAX && errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_OK; } } } } return SWIG_TypeError; } } /* long long */ %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="", fragment="") { SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(long long)(long long value) { if (((long long) LONG_MIN <= value) && (value <= (long long) LONG_MAX)) { return SWIG_From(long)(%numeric_cast(value,long)); } else { char temp[256]; sprintf(temp, "%lld", value); return Tcl_NewStringObj(temp,-1); } } } %fragment(SWIG_AsVal_frag(long long),"header", fragment="", fragment="") { SWIGINTERN int SWIG_AsVal_dec(long long)(Tcl_Obj *obj, long long *val) { long v; if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { if (val) *val = v; return SWIG_OK; } else { int len = 0; const char *nptr = Tcl_GetStringFromObj(obj, &len); if (nptr && len > 0) { char *endptr; long long v; errno = 0; v = strtoll(nptr, &endptr,0); if (nptr[0] == '\0' || *endptr != '\0') return SWIG_TypeError; if ((v == LLONG_MAX || v == LLONG_MIN) && errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_OK; } } } } return SWIG_TypeError; } } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="", fragment="") { SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(unsigned long long)(unsigned long long value) { if (value < (unsigned long long) LONG_MAX) { return SWIG_From(long long)(%numeric_cast(value, long long)); } else { char temp[256]; sprintf(temp, "%llu", value); return Tcl_NewStringObj(temp,-1); } } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(Tcl_Obj *obj, unsigned long long *val) { long v; if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { if (val) *val = (unsigned long) v; return SWIG_OK; } else { int len = 0; const char *nptr = Tcl_GetStringFromObj(obj, &len); if (nptr && len > 0) { char *endptr; unsigned long long v; if (*nptr == '-') return SWIG_OverflowError; errno = 0; v = strtoull(nptr, &endptr,0); if (nptr[0] == '\0' || *endptr != '\0') return SWIG_TypeError; if (v == ULLONG_MAX && errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_OK; } } } } return SWIG_TypeError; } } /* double */ %fragment(SWIG_From_frag(double),"header") { %define_as(SWIG_From(double), Tcl_NewDoubleObj) } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(Tcl_Obj *obj, double *val) { double v; if (Tcl_GetDoubleFromObj(0, obj, &v) == TCL_OK) { if (val) *val = v; return SWIG_OK; } return SWIG_TypeError; } } swig-3.0.2/Lib/shared_ptr.i0000664000175000017500000000414412343605122015361 0ustar williamwilliam// This is a helper file for shared_ptr and should not be included directly. // The main implementation detail in using this smart pointer of a type is to customise the code generated // to use a pointer to the smart pointer of the type, rather than the usual pointer to the underlying type. // So for some type T, shared_ptr * is used rather than T *. // shared_ptr namespaces could be boost or std or std::tr1 // For example for std::tr1, use: // #define SWIG_SHARED_PTR_NAMESPACE std // #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 #if !defined(SWIG_SHARED_PTR_NAMESPACE) # define SWIG_SHARED_PTR_NAMESPACE boost #endif #if defined(SWIG_SHARED_PTR_SUBNAMESPACE) # define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE::SWIG_SHARED_PTR_SUBNAMESPACE #else # define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE #endif namespace SWIG_SHARED_PTR_NAMESPACE { #if defined(SWIG_SHARED_PTR_SUBNAMESPACE) namespace SWIG_SHARED_PTR_SUBNAMESPACE { #endif template class shared_ptr { }; #if defined(SWIG_SHARED_PTR_SUBNAMESPACE) } #endif } %fragment("SWIG_null_deleter", "header") { struct SWIG_null_deleter { void operator() (void const *) const { } }; %#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() %#define SWIG_NO_NULL_DELETER_1 %#define SWIG_NO_NULL_DELETER_SWIG_POINTER_NEW %#define SWIG_NO_NULL_DELETER_SWIG_POINTER_OWN } // Workaround empty first macro argument bug #define SWIGEMPTYHACK // Main user macro for defining shared_ptr typemaps for both const and non-const pointer types %define %shared_ptr(TYPE...) %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } SWIG_SHARED_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE) SWIG_SHARED_PTR_TYPEMAPS(const, TYPE) %enddef // Legacy macros %define SWIG_SHARED_PTR(PROXYCLASS, TYPE...) #warning "SWIG_SHARED_PTR(PROXYCLASS, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead." %shared_ptr(TYPE) %enddef %define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) #warning "SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead." %shared_ptr(TYPE) %enddef swig-3.0.2/Lib/javascript/0000775000175000017500000000000012343605122015217 5ustar williamwilliamswig-3.0.2/Lib/javascript/jsc/0000775000175000017500000000000012343605122015776 5ustar williamwilliamswig-3.0.2/Lib/javascript/jsc/javascriptinit.swg0000664000175000017500000000402012343605122021546 0ustar williamwilliam%insert(init) %{ SWIGRUNTIME void SWIG_JSC_SetModule(swig_module_info *swig_module) {} SWIGRUNTIME swig_module_info * SWIG_JSC_GetModule(void) { return 0; } #define SWIG_GetModule(clientdata) SWIG_JSC_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_JSC_SetModule(pointer) %} %insert(init) "swiginit.swg" %fragment ("js_initializer_define", "templates") %{ #define SWIGJSC_INIT $jsname_initialize %} // Open the initializer function %insert(init) %{ #ifdef __cplusplus extern "C" { #endif bool SWIGJSC_INIT (JSGlobalContextRef context, JSObjectRef *exports) { SWIG_InitializeModule(0); %} /* ----------------------------------------------------------------------------- * js_initializer: template for the module initializer function * - $jsname: module name * - $jscreatenamespaces: part with code for creating namespace objects * - $jscreateclasses: part with code for creating classes * - $jsregisternamespaces: part with code for registration of namespaces * ----------------------------------------------------------------------------- */ %fragment ("js_initializer", "templates") %{ /* Initialize the base swig type object */ _SwigObject_objectDefinition.staticFunctions = _SwigObject_functions; _SwigObject_objectDefinition.staticValues = _SwigObject_values; _SwigObject_classRef = JSClassCreate(&_SwigObject_objectDefinition); /* Initialize the PackedData class */ _SwigPackedData_objectDefinition.staticFunctions = _SwigPackedData_functions; _SwigPackedData_objectDefinition.staticValues = _SwigPackedData_values; _SwigPackedData_objectDefinition.finalize = _wrap_SwigPackedData_delete; _SwigPackedData_classRef = JSClassCreate(&_SwigPackedData_objectDefinition); /* Create objects for namespaces */ $jscreatenamespaces /* Register classes */ $jsregisterclasses /* Register namespaces */ $jsregisternamespaces *exports = exports_object; return true; } #ifdef __cplusplus } #endif %} swig-3.0.2/Lib/javascript/jsc/javascriptfragments.swg0000664000175000017500000000105712343605122022600 0ustar williamwilliam/* Create a file with this name, 'javascriptfragments.swg', in your working directory and add all the %fragments you want to take precedence over the default ones defined by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(PyObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.2/Lib/javascript/jsc/std_map.i0000664000175000017500000000444112343605122017602 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.2/Lib/javascript/jsc/javascriptkw.swg0000664000175000017500000000176712343605122021243 0ustar williamwilliam#ifndef JAVASCRIPT_JAVASCRIPTKW_SWG_ #define JAVASCRIPT_JAVASCRIPTKW_SWG_ /* Warnings for Java keywords */ #define JAVASCRIPTKW(x) %keywordwarn("'" `x` "' is a javascript keyword, renaming to '_"`x`"'",rename="_%s") `x` /* Taken from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Reserved_Words */ JAVASCRIPTKW(break); JAVASCRIPTKW(case); JAVASCRIPTKW(catch); JAVASCRIPTKW(continue); JAVASCRIPTKW(default); JAVASCRIPTKW(delete); JAVASCRIPTKW(do); JAVASCRIPTKW(else); JAVASCRIPTKW(finally); JAVASCRIPTKW(for); JAVASCRIPTKW(function); JAVASCRIPTKW(if); JAVASCRIPTKW(in); JAVASCRIPTKW(instanceof); JAVASCRIPTKW(new); JAVASCRIPTKW(return); JAVASCRIPTKW(switch); JAVASCRIPTKW(this); JAVASCRIPTKW(throw); JAVASCRIPTKW(try); JAVASCRIPTKW(typeof); JAVASCRIPTKW(var); JAVASCRIPTKW(void); JAVASCRIPTKW(while); JAVASCRIPTKW(with); /* others bad names if any*/ // for example %namewarn("321:clone() is a javascript bad method name") *::clone(); #undef JAVASCRIPTKW #endif //JAVASCRIPT_JAVASCRIPTKW_SWG_ swig-3.0.2/Lib/javascript/jsc/javascriptcomplex.swg0000664000175000017500000000721512343605122022263 0ustar williamwilliam/* Defines the As/From converters for double/float complex, you need to provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex accessor methods. See the std_complex.i and ccomplex.i for concret examples. */ /* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header", fragment=SWIG_From_frag(double)) { SWIGINTERNINLINE JSObjectRef SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) { JSValueRef vals[2]; vals[0] = SWIG_From(double)(Real(c)); vals[1] = SWIG_From(double)(Imag(c)); return JSObjectMakeArray(context, 2, vals, NULL); } } %enddef /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int SWIG_AsVal_dec(Type) (JSValueRef o, Type* val) { if (JSValueIsObject(context, o)) { JSObjectRef array; JSValueRef exception, js_re, js_im; double re, im; int res; exception = 0; res = 0; array = JSValueToObject(context, o, &exception); if(exception != 0) return SWIG_TypeError; js_re = JSObjectGetPropertyAtIndex(context, array, 0, &exception); if(exception != 0) return SWIG_TypeError; js_im = JSObjectGetPropertyAtIndex(context, array, 1, &exception); if(exception != 0) return SWIG_TypeError; res = SWIG_AsVal(double)(js_re, &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } res = SWIG_AsVal(double)(js_im, &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } if (val) *val = Constructor(re, im); return SWIG_OK; } else { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef /* the float case */ %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float)) { SWIGINTERN int SWIG_AsVal_dec(Type)(JSValueRef o, Type *val) { if (JSValueIsObject(context, o)) { JSObjectRef array; JSValueRef exception, js_re, js_im; double re, im; int res; exception = 0; res = 0; array = JSValueToObject(context, o, &exception); if(exception != 0) return SWIG_TypeError; js_re = JSObjectGetPropertyAtIndex(context, array, 0, &exception); if(exception != 0) return SWIG_TypeError; js_im = JSObjectGetPropertyAtIndex(context, array, 1, &exception); if(exception != 0) return SWIG_TypeError; res = SWIG_AsVal(double)(js_re, &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } res = SWIG_AsVal(double)(js_im, &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else { return SWIG_OverflowError; } } else { float re; int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(re, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.2/Lib/javascript/jsc/std_pair.i0000664000175000017500000000131012343605122017750 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/javascript/jsc/std_complex.i0000664000175000017500000000073212343605122020473 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.2/Lib/javascript/jsc/typemaps.i0000664000175000017500000001047612343605122020022 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * These mappings provide support for input/output arguments and common * uses for C/C++ pointers. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Python tuple. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Python output of the function would be a tuple containing both output values. */ // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Python tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Python). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Python variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %include swig-3.0.2/Lib/javascript/jsc/javascripttypemaps.swg0000664000175000017500000000367412343605122022463 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Javascript * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* These macros are necessary to provide an extra parameter to SWIG_AsVal_dec functions (JSContextRef context). They must be defined before including `typemaps/fragments.swg` */ #define SWIG_FROM_DECL_ARGS SWIG_JSC_FROM_DECL_ARGS #define SWIG_FROM_CALL_ARGS SWIG_JSC_FROM_CALL_ARGS #define SWIG_AS_DECL_ARGS SWIG_JSC_AS_DECL_ARGS #define SWIG_AS_CALL_ARGS SWIG_JSC_AS_CALL_ARGS /* Include fundamental fragemt definitions */ %include /* Look for user fragments file. */ %include /* Javascript fragments for fundamental types */ %include /* Javascript fragments for char* strings */ %include /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ #define SWIG_Object JSValueRef #define VOID_Object JSValueMakeUndefined(context) /* append output */ #define SWIG_AppendOutput(result, obj) SWIGJSC_AppendOutput(context, result, obj) /* set constant */ #define SWIG_SetConstant(name, obj) /* raise */ #define SWIG_Raise(obj, type, desc) SWIG_Javascript_Raise(context, exception, type) %insert("runtime") %{ #define SWIG_JSC_FROM_DECL_ARGS(arg1) (JSContextRef context, arg1) #define SWIG_JSC_FROM_CALL_ARGS(arg1) (context, arg1) #define SWIG_JSC_AS_DECL_ARGS(arg1, arg2) (JSContextRef context, arg1, arg2) #define SWIG_JSC_AS_CALL_ARGS(arg1, arg2) (context, arg1, arg2) %} /* Include the unified typemap library */ %include swig-3.0.2/Lib/javascript/jsc/javascriptruntime.swg0000664000175000017500000000105512343605122022273 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javascriptruntime.swg * * Javascript support code * ----------------------------------------------------------------------------- */ %insert(runtime) %{ #include #include #include #include #include #include %} %insert(runtime) "swigrun.swg"; /* SWIG API */ %insert(runtime) "swigerrors.swg"; /* SWIG errors */ %insert(runtime) "javascriptrun.swg"; /* SWIG errors */ swig-3.0.2/Lib/javascript/jsc/cdata.i0000664000175000017500000000003612343605122017223 0ustar williamwilliam%include swig-3.0.2/Lib/javascript/jsc/ccomplex.i0000664000175000017500000000140312343605122017760 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ccomplex.i * * C complex typemaps * ISO C99: 7.3 Complex arithmetic * ----------------------------------------------------------------------------- */ %include %{ #include %} /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) %swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); swig-3.0.2/Lib/javascript/jsc/javascriptstrings.swg0000664000175000017500000001346212343605122022306 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_JSC_AsCharPtrAndSize(JSContextRef context, JSValueRef valRef, char** cptr, size_t* psize, int *alloc) { if(JSValueIsString(context, valRef)) { JSStringRef js_str = JSValueToStringCopy(context, valRef, NULL); size_t len = JSStringGetMaximumUTF8CStringSize(js_str); char* cstr = (char*) %new_array(len, char); /* JSStringGetUTF8CString returns the length including 0-terminator */ len = JSStringGetUTF8CString(js_str, cstr, len); if(alloc) *alloc = SWIG_NEWOBJ; if(psize) *psize = len; if(cptr) *cptr = cstr; return SWIG_OK; } else { if(JSValueIsObject(context, valRef)) { JSObjectRef obj = JSValueToObject(context, valRef, NULL); // try if the object is a wrapped char[] swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } return SWIG_TypeError; } else { return SWIG_TypeError; } } } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE JSValueRef SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { // TODO: handle extra long strings //swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); //return pchar_descriptor ? // SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); return JSValueMakeUndefined(context); } else { JSStringRef jsstring; if(size < 2) { char c[2]; int i; for(i=0;i LONG_MAX) ? JSValueMakeNumber(context, value) : JSValueMakeNumber(context, %numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(JSValueRef obj, unsigned long *val) { if(!JSValueIsNumber(context, obj)) { return SWIG_TypeError; } long longVal = (long) JSValueToNumber(context, obj, NULL); if(longVal < 0) { return SWIG_OverflowError; } if(val) *val = longVal; return SWIG_OK; } } /* long long */ // Note: these are copied from 'long' and probably need fixing %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE JSValueRef SWIG_From_dec(long long)(long long value) { return JSValueMakeNumber(context, value); } } %fragment(SWIG_AsVal_frag(long long),"header", fragment=SWIG_AsVal_frag(long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(long long)(JSValueRef obj, long long* val) { if (!JSValueIsNumber(context, obj)) { return SWIG_TypeError; } if(val) *val = (long long) JSValueToNumber(context, obj, NULL); return SWIG_OK; } } /* unsigned long long */ // Note: these are copied from 'unsigned long' and probably need fixing %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="") { SWIGINTERN JSValueRef SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? JSValueMakeNumber(context, value) : JSValueMakeNumber(context, %numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(JSValueRef obj, unsigned long long *val) { if(!JSValueIsNumber(context, obj)) { return SWIG_TypeError; } long long longVal = (unsigned long long) JSValueToNumber(context, obj, NULL); if(longVal < 0) { return SWIG_OverflowError; } if(val) *val = longVal; return SWIG_OK; } } /* double */ %fragment(SWIG_From_frag(double),"header") { SWIGINTERN JSValueRef SWIG_From_dec(double) (double val) { return JSValueMakeNumber(context, val); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(JSValueRef obj, double *val) { if(!JSValueIsNumber(context, obj)) { return SWIG_TypeError; } if(val) *val = JSValueToNumber(context, obj, NULL); return SWIG_OK; } } swig-3.0.2/Lib/javascript/jsc/std_common.i0000664000175000017500000000014612343605122020313 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.2/Lib/javascript/jsc/exception.i0000664000175000017500000000004212343605122020142 0ustar williamwilliam%include swig-3.0.2/Lib/javascript/jsc/javascripthelpers.swg0000664000175000017500000000450412343605122022254 0ustar williamwilliam%insert(wrapper) %{ SWIGINTERN bool JS_registerClass(JSGlobalContextRef context, JSObjectRef parentObject, const char* className, JSClassDefinition* definition) { JSStringRef js_className = JSStringCreateWithUTF8CString(className); JSObjectRef classObject = JSObjectMake(context, JSClassCreate(definition), NULL); JSObjectSetProperty(context, parentObject, js_className, classObject, kJSPropertyAttributeNone, NULL); JSStringRelease(js_className); return true; } SWIGINTERN bool JS_registerNamespace(JSGlobalContextRef context, JSObjectRef namespaceObj, JSObjectRef parentNamespace, const char* name) { JSStringRef js_name = JSStringCreateWithUTF8CString(name); JSObjectSetProperty(context, parentNamespace, js_name, namespaceObj, kJSPropertyAttributeNone, NULL); JSStringRelease(js_name); return true; } SWIGINTERN bool JS_registerFunction(JSGlobalContextRef context, JSObjectRef object, const char* functionName, JSObjectCallAsFunctionCallback callback) { JSStringRef js_functionName = JSStringCreateWithUTF8CString(functionName); JSObjectSetProperty(context, object, js_functionName, JSObjectMakeFunctionWithCallback(context, js_functionName, callback), kJSPropertyAttributeNone, NULL); JSStringRelease(js_functionName); return true; } SWIGINTERN bool JS_veto_set_variable(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { char buffer[256]; char msg[512]; int res; JSStringGetUTF8CString(propertyName, buffer, 256); res = sprintf(msg, "Tried to write read-only variable: %s.", buffer); if(res<0) { SWIG_exception(SWIG_ERROR, "Tried to write read-only variable."); } else { SWIG_exception(SWIG_ERROR, msg); } return false; } SWIGINTERN JSValueRef JS_CharPtrToJSValue(JSContextRef context, char* cstr) { JSValueRef val; JSStringRef jsstring = JSStringCreateWithUTF8CString((char*) cstr); val = JSValueMakeString(context, jsstring); JSStringRelease(jsstring); return val; } %} swig-3.0.2/Lib/javascript/jsc/complex.i0000664000175000017500000000012012343605122017610 0ustar williamwilliam#ifdef __cplusplus %include #else %include #endif swig-3.0.2/Lib/javascript/jsc/javascriptcode.swg0000664000175000017500000003665312343605122021536 0ustar williamwilliam/* ----------------------------------------------------------------------------- * js_ctor: template for wrapping a ctor. * - $jswrapper: wrapper of called ctor * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * - $jsargcount: number of arguments * - $jsmangledtype: mangled type of class * ----------------------------------------------------------------------------- */ %fragment ("js_ctor", "templates") %{ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { $jslocals if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); goto fail; fail: return NULL; } %} /* ----------------------------------------------------------------------------- * js_veto_ctor: a vetoing ctor for abstract classes * - $jswrapper: name of wrapper * - $jsname: class name * ----------------------------------------------------------------------------- */ %fragment ("js_veto_ctor", "templates") %{ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated"); return 0; } %} /* ----------------------------------------------------------------------------- * js_ctor_dispatcher: dispatcher for overloaded constructors * - $jswrapper: name of wrapper * - $jsname: class name * - $jsdispatchcases: part containing code for dispatching * ----------------------------------------------------------------------------- */ %fragment ("js_ctor_dispatcher", "templates") %{ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { JSObjectRef thisObject = NULL; // switch all cases by means of series of if-returns. $jsdispatchcases // default: SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for construction of $jsname"); fail: return thisObject; } %} /* ----------------------------------------------------------------------------- * js_overloaded_ctor: template for wrapping a ctor. * - $jswrapper: wrapper of called ctor * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * - $jsargcount: number of arguments * - $jsmangledtype: mangled type of class * ----------------------------------------------------------------------------- */ %fragment ("js_overloaded_ctor", "templates") %{ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { $jslocals $jscode return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); goto fail; fail: return NULL; } %} /* ----------------------------------------------------------------------------- * js_ctor_dispatch_case: template for a dispatch case for calling an overloaded ctor. * - $jsargcount: number of arguments of called ctor * - $jswrapper: wrapper of called ctor * * Note: a try-catch-like mechanism is used to switch cases * ----------------------------------------------------------------------------- */ %fragment ("js_ctor_dispatch_case", "templates") %{ if(argc == $jsargcount) { thisObject = $jswrapper(context, NULL, argc, argv, exception); if(thisObject != NULL) { *exception=0; return thisObject; } /* reset exception and return */ } %} /* ----------------------------------------------------------------------------- * js_dtor: template for a destructor wrapper * - $jsmangledname: mangled class name * - $jstype: class type * ----------------------------------------------------------------------------- */ %fragment ("js_dtor", "templates") %{ static void $jswrapper(JSObjectRef thisObject) { SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject); if(t) { if (t->swigCMemOwn) { free (($jstype)t->swigCObject); } JSObjectSetPrivate(thisObject, NULL); free(t); } } %} /* ----------------------------------------------------------------------------- * js_dtor: template for a destructor wrapper * - $jsmangledname: mangled class name * - $jstype: class type * - ${destructor_action}: The custom destructor action to invoke. * ----------------------------------------------------------------------------- */ %fragment ("js_dtoroverride", "templates") %{ static void $jswrapper(JSObjectRef thisObject) { SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject); if(t) { if (t->swigCMemOwn) { $jstype arg1 = ($jstype)t->swigCObject; ${destructor_action} } /* remove the private data to make sure that it isn't accessed elsewhere */ JSObjectSetPrivate(thisObject, NULL); free(t); } } %} /* ----------------------------------------------------------------------------- * js_getter: template for getter function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_getter", "templates") %{ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) { $jslocals JSValueRef jsresult; $jscode return jsresult; goto fail; fail: return JSValueMakeUndefined(context); } %} /* ----------------------------------------------------------------------------- * js_setter: template for setter function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_setter", "templates") %{ static bool $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { $jslocals $jscode return true; goto fail; fail: return false; } %} /* ----------------------------------------------------------------------------- * js_function: template for function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_function", "templates") %{ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { $jslocals JSValueRef jsresult; if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode return jsresult; goto fail; fail: return JSValueMakeUndefined(context); } %} /* ----------------------------------------------------------------------------- * js_function_dispatcher: template for a function dispatcher for overloaded functions * - $jswrapper: wrapper function name * - $jsname: name of the wrapped function * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_function_dispatcher", "templates") %{ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { $jslocals JSValueRef jsresult; int res; $jscode SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname."); return jsresult; goto fail; fail: return JSValueMakeUndefined(context); } %} /* ----------------------------------------------------------------------------- * js_overloaded_function: template for a overloaded function * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_overloaded_function", "templates") %{ static int $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception, JSValueRef* p_result) { $jslocals JSValueRef jsresult; if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode *p_result = jsresult; return SWIG_OK; goto fail; fail: return SWIG_TypeError; } %} /* ----------------------------------------------------------------------------- * js_function_dispatch_case: template for a case used in the function dispatcher * - $jswrapper: wrapper function name * - $jsargcount: number of arguments of overloaded function * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_function_dispatch_case", "templates") %{ if(argc == $jsargcount) { res = $jswrapper(context, function, thisObject, argc, argv, exception, &jsresult); if(res == SWIG_OK) { *exception = 0; return jsresult; } } %} /* ----------------------------------------------------------------------------- * jsc_variable_declaration: template for a variable table entry * - $jsname: name of the variable * - $jsgetter: wrapper of getter function * - $jssetter: wrapper of setter function * ----------------------------------------------------------------------------- */ %fragment ("jsc_variable_declaration", "templates") %{ {"$jsname", $jsgetter, $jssetter, kJSPropertyAttributeNone}, %} /* ----------------------------------------------------------------------------- * jsc_function_declaration: template for a function table entry * - $jsname: name of the variable * - $jswrapper: wrapper function * ----------------------------------------------------------------------------- */ %fragment ("jsc_function_declaration", "templates") %{ {"$jsname", $jswrapper, kJSPropertyAttributeNone}, %} /* ----------------------------------------------------------------------------- * jsc_classtemplate_declaration: template for a namespace declaration * - $jsmangledname: mangled class name * ----------------------------------------------------------------------------- */ %fragment ("jsc_class_declaration", "templates") %{ static JSClassDefinition $jsmangledname_classDefinition; static JSClassDefinition $jsmangledname_objectDefinition; static JSClassRef $jsmangledname_classRef; %} /* ----------------------------------------------------------------------------- * jsc_class_tables: template for a namespace declaration * - $jsmangledname: mangled class name * - $jsstaticclassvariables: list of static variable entries * - $jsstaticclassfunctions: list of static function entries * - $jsclassvariables: list of member variable entries * - $jsclassfunctions: list of member function entries * ----------------------------------------------------------------------------- */ %fragment ("jsc_class_tables", "templates") %{ static JSStaticValue $jsmangledname_staticValues[] = { $jsstaticclassvariables { 0, 0, 0, 0 } }; static JSStaticFunction $jsmangledname_staticFunctions[] = { $jsstaticclassfunctions { 0, 0, 0 } }; static JSStaticValue $jsmangledname_values[] = { $jsclassvariables { 0, 0, 0, 0 } }; static JSStaticFunction $jsmangledname_functions[] = { $jsclassfunctions { 0, 0, 0 } }; %} /* ----------------------------------------------------------------------------- * jsc_define_class_template: template for defining a class template * - $jsmangledname: mangled class name * - $jsmangledtype: mangled class type * - $jsctor: wrapper of ctor * - $jsbaseclass: mangled name of base class * ----------------------------------------------------------------------------- */ %fragment ("jsc_class_definition", "templates") %{ $jsmangledname_classDefinition.staticFunctions = $jsmangledname_staticFunctions; $jsmangledname_classDefinition.staticValues = $jsmangledname_staticValues; $jsmangledname_classDefinition.callAsConstructor = $jsctor; $jsmangledname_objectDefinition.finalize = $jsdtor; $jsmangledname_objectDefinition.staticValues = $jsmangledname_values; $jsmangledname_objectDefinition.staticFunctions = $jsmangledname_functions; $jsclass_inheritance JSClassRef $jsmangledname_classRef = JSClassCreate(&$jsmangledname_objectDefinition); SWIGTYPE_$jsmangledtype->clientdata = $jsmangledname_classRef; %} %fragment ("jsc_class_inherit", templates) %{ if (SWIGTYPE_p$jsbaseclassmangled != NULL) { $jsmangledname_objectDefinition.parentClass = (JSClassRef) SWIGTYPE_p$jsbaseclassmangled->clientdata; } %} %fragment ("jsc_class_noinherit", templates) %{ $jsmangledname_objectDefinition.parentClass = _SwigObject_classRef; %} /* ----------------------------------------------------------------------------- * jsc_register_class: template for registration of a class * - $jsname: class name * - $jsmangledname: mangled class name * - $jsnspace: mangled name of namespace * ----------------------------------------------------------------------------- */ %fragment ("jsc_class_registration", "templates") %{ JS_registerClass(context, $jsnspace_object, "$jsname", &$jsmangledname_classDefinition); %} /* ----------------------------------------------------------------------------- * jsc_nspace_declaration: template for a namespace declaration * - $jsnspace: mangled name of the namespace * - $jsglobalvariables: list of variable entries * - $jsglobalfunctions: list if fuction entries * ----------------------------------------------------------------------------- */ %fragment ("jsc_nspace_declaration", "templates") %{ static JSStaticValue $jsnspace_values[] = { $jsglobalvariables { 0, 0, 0, 0 } }; static JSStaticFunction $jsnspace_functions[] = { $jsglobalfunctions { 0, 0, 0 } }; static JSClassDefinition $jsnspace_classDefinition; %} /* ----------------------------------------------------------------------------- * jsc_nspace_definition: template for definition of a namespace object * - $jsmangledname: mangled name of namespace * ----------------------------------------------------------------------------- */ %fragment ("jsc_nspace_definition", "templates") %{ $jsmangledname_classDefinition.staticFunctions = $jsmangledname_functions; $jsmangledname_classDefinition.staticValues = $jsmangledname_values; JSObjectRef $jsmangledname_object = JSObjectMake(context, JSClassCreate(&$jsmangledname_classDefinition), NULL); %} /* ----------------------------------------------------------------------------- * jsc_nspace_registration: template for registration of a namespace object * - $jsname: name of namespace * - $jsmangledname: mangled name of namespace * - $jsparent: mangled name of parent namespace * ----------------------------------------------------------------------------- */ %fragment ("jsc_nspace_registration", "templates") %{ JS_registerNamespace(context, $jsmangledname_object, $jsparent_object, "$jsname"); %} swig-3.0.2/Lib/javascript/jsc/javascript.swg0000664000175000017500000000066712343605122020677 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javascript.swg * * Javascript typemaps * ----------------------------------------------------------------------------- */ %include %include %include %include %include %include %include swig-3.0.2/Lib/javascript/jsc/std_vector.i0000664000175000017500000000511112343605122020322 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %include %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i swig-3.0.2/Lib/javascript/jsc/std_except.i0000664000175000017500000000004312343605122020307 0ustar williamwilliam%include swig-3.0.2/Lib/javascript/jsc/stl.i0000664000175000017500000000044312343605122016753 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/javascript/jsc/std_deque.i0000664000175000017500000000003412343605122020122 0ustar williamwilliam%include swig-3.0.2/Lib/javascript/jsc/arrays_javascript.i0000664000175000017500000000643112343605122021703 0ustar williamwilliam/* ----------------------------------------------------------------------------- * arrays_javascript.i * * These typemaps give more natural support for arrays. The typemaps are not efficient * as there is a lot of copying of the array values whenever the array is passed to C/C++ * from JavaScript and vice versa. The JavaScript array is expected to be the same size as the C array. * An exception is thrown if they are not. * * Example usage: * Wrapping: * * %include * %inline %{ * extern int FiddleSticks[3]; * %} * * Use from JavaScript like this: * * var fs = [10, 11, 12]; * example.FiddleSticks = fs; * fs = example.FiddleSticks; * ----------------------------------------------------------------------------- */ %fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {} %fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_frag(double)) {} %typemap(in, fragment="SWIG_JSCGetIntProperty") int[], int[ANY] (int length = 0, JSObjectRef array, JSValueRef jsvalue, int i = 0, int res = 0, $*1_ltype temp) { if (JSValueIsObject(context, $input)) { // Convert into Array array = JSValueToObject(context, $input, NULL); length = $1_dim0; $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length); // Get each element from array for (i = 0; i < length; i++) { jsvalue = JSObjectGetPropertyAtIndex(context, array, i, NULL); // Get primitive value from JSObject res = SWIG_AsVal(int)(jsvalue, &temp); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double"); } arg$argnum[i] = temp; } } else { SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef"); } } %typemap(freearg) int[], int[ANY] { free($1); } %typemap(out, fragment=SWIG_From_frag(int)) int[], int[ANY] (int length = 0, int i = 0) { length = $1_dim0; JSValueRef values[length]; for (i = 0; i < length; i++) { values[i] = SWIG_From(int)($1[i]); } $result = JSObjectMakeArray(context, length, values, NULL); } %typemap(in, fragment="SWIG_JSCGetNumberProperty") double[], double[ANY] (int length = 0, JSObjectRef array, JSValueRef jsvalue, int i = 0, int res = 0, $*1_ltype temp) { if (JSValueIsObject(context, $input)) { // Convert into Array array = JSValueToObject(context, $input, NULL); length = $1_dim0; $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length); // Get each element from array for (i = 0; i < length; i++) { jsvalue = JSObjectGetPropertyAtIndex(context, array, i, NULL); // Get primitive value from JSObject res = SWIG_AsVal(double)(jsvalue, &temp); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double"); } arg$argnum[i] = temp; } } else { SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef"); } } %typemap(freearg) double[], double[ANY] { free($1); } %typemap(out, fragment=SWIG_From_frag(double)) double[], double[ANY] (int length = 0, int i = 0) { length = $1_dim0; JSValueRef values[length]; for (i = 0; i < length; i++) { values[i] = SWIG_From(double)($1[i]); } $result = JSObjectMakeArray(context, length, values, NULL); } swig-3.0.2/Lib/javascript/jsc/javascriptrun.swg0000664000175000017500000002373512343605122021425 0ustar williamwilliam/* ---------------------------------------------------------------------------- * Errors and exceptions * * ---------------------------------------------------------------------------*/ #define SWIG_Error(code, msg) SWIG_JSC_exception(context, exception, code, msg) #define SWIG_exception(code, msg) SWIG_JSC_exception(context, exception, code, msg) #define SWIG_fail goto fail SWIGRUNTIME void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) { JSStringRef message = JSStringCreateWithUTF8CString(type); JSValueRef error_arguments[1]; JSObjectRef exception_object; JSValueRef exception_value; exception_value = JSValueMakeString(context, message); /* Converting the result to an object will let JavascriptCore add "sourceURL" (file) and "line" (number) and "message" to the exception, instead of just returning a raw string. This is extremely important for debugging your errors. Using JSObjectMakeError is better than JSValueToObject because the latter only populates "sourceURL" and "line", but not "message" or any others I don't know about. */ error_arguments[0] = exception_value; exception_object = JSObjectMakeError(context, 1, error_arguments, NULL); /* Return the exception_object */ *exception = exception_object; JSStringRelease(message); } SWIGRUNTIME void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) { SWIG_Javascript_Raise(context, exception, msg); } /* ---------------------------------------------------------------------------- * The parent class of all Proxies * * ---------------------------------------------------------------------------*/ typedef struct { bool swigCMemOwn; void *swigCObject; swig_type_info *info; } SwigPrivData; SWIGRUNTIME JSValueRef _wrap_SwigObject_disown(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { JSValueRef jsresult; JSObjectRef obj = JSValueToObject(context, thisObject, NULL); SwigPrivData *cdata = (SwigPrivData *) JSObjectGetPrivate(obj); cdata->swigCMemOwn = false; jsresult = JSValueMakeUndefined(context); return jsresult; } SWIGRUNTIME JSValueRef _wrap_SwigObject_getCPtr(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { JSValueRef jsresult; long result; JSObjectRef obj = JSValueToObject(context, thisObject, NULL); SwigPrivData *cdata = (SwigPrivData*) JSObjectGetPrivate(obj); result = (long) cdata->swigCObject; jsresult = JSValueMakeNumber(context, result); return jsresult; } SWIGRUNTIME JSValueRef _wrap_SwigObject_equals(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { JSValueRef jsresult; bool result; JSObjectRef obj = JSValueToObject(context, thisObject, NULL); SwigPrivData *cdata = (SwigPrivData*) JSObjectGetPrivate(obj); JSObjectRef obj2 = JSValueToObject(context, argv[0], NULL); SwigPrivData *cdata2 = (SwigPrivData*) JSObjectGetPrivate(obj2); result = (cdata->swigCObject == cdata2->swigCObject); jsresult = JSValueMakeBoolean(context, result); return jsresult; } SWIGRUNTIME JSStaticValue _SwigObject_values[] = { { 0, 0, 0, 0 } }; SWIGRUNTIME JSStaticFunction _SwigObject_functions[] = { { "disown",_wrap_SwigObject_disown, kJSPropertyAttributeNone }, { "equals",_wrap_SwigObject_equals, kJSPropertyAttributeNone }, { "getCPtr",_wrap_SwigObject_getCPtr, kJSPropertyAttributeNone }, { 0, 0, 0 } }; SWIGRUNTIME JSClassDefinition _SwigObject_objectDefinition; SWIGRUNTIME JSClassRef _SwigObject_classRef; SWIGRUNTIME int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef objRef, void** ptr, swig_type_info *info, int flags) { SwigPrivData *cdata; cdata = (SwigPrivData *) JSObjectGetPrivate(objRef); if(cdata == NULL) { return SWIG_ERROR; } if(cdata->info != info) { bool type_valid = false; swig_cast_info *t = info->cast; while(t != NULL) { if(t->type == cdata->info) { type_valid = true; break; } t = t->next; } if(!type_valid) { return SWIG_TypeError; } } *ptr = cdata->swigCObject; if(flags & SWIG_POINTER_DISOWN) { cdata->swigCMemOwn = false; } return SWIG_OK; } SWIGRUNTIME int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, void** ptr, swig_type_info *info, int flags) { JSObjectRef objRef; /* special case: JavaScript null => C NULL pointer */ if(JSValueIsNull(context, valRef)) { *ptr=0; return SWIG_OK; } if(!JSValueIsObject(context, valRef)) { return SWIG_TypeError; } objRef = JSValueToObject(context, valRef, NULL); if(objRef == NULL) { return SWIG_ERROR; } return SWIG_JSC_ConvertInstancePtr(context, objRef, ptr, info, flags); } SWIGRUNTIME JSObjectRef SWIG_JSC_NewPointerObj(JSContextRef context, void *ptr, swig_type_info *info, int flags) { JSClassRef classRef; JSObjectRef result; SwigPrivData *cdata; if (ptr == NULL) { // HACK: it is not possible to use JSValueToObject (causing seg-fault) // This static cast turned out to be a workaround // In future, we should change the interface of this method // to return JSValueRef instead of JSObjectRef. return (JSObjectRef) JSValueMakeNull(context); } if(info->clientdata == NULL) { classRef = _SwigObject_classRef; } else { classRef = (JSClassRef) info->clientdata; } result = JSObjectMake(context, classRef, NULL); cdata = (SwigPrivData*) malloc(sizeof(SwigPrivData)); cdata->swigCObject = ptr; cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0; cdata->info = info; JSObjectSetPrivate(result, cdata); return result; } #define SWIG_ConvertPtr(obj, ptr, info, flags) SWIG_JSC_ConvertPtr(context, obj, ptr, info, flags) #define SWIG_NewPointerObj(ptr, info, flags) SWIG_JSC_NewPointerObj(context, ptr, info, flags) #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_JSC_ConvertInstancePtr(context, obj, pptr, type, flags) #define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_JSC_NewPointerObj(context, thisvalue, type, flags) #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_JSC_ConvertPtr(context, obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_JSC_NewPointerObj(context, ptr, type, 0) /* ---------------------------------------------------------------------------- * A class for packed data * * ---------------------------------------------------------------------------*/ typedef struct { void *data; size_t size; swig_type_info *type; } SwigPackedData; SWIGRUNTIME JSStaticValue _SwigPackedData_values[] = { { 0, 0, 0, 0 } }; SWIGRUNTIME JSStaticFunction _SwigPackedData_functions[] = { { 0, 0, 0 } }; SWIGRUNTIME JSClassDefinition _SwigPackedData_objectDefinition; SWIGRUNTIME JSClassRef _SwigPackedData_classRef; SWIGRUNTIMEINLINE int SwigJSCPacked_Check(JSContextRef context, JSValueRef valRef) { return JSValueIsObjectOfClass(context, valRef, _SwigPackedData_classRef); } SWIGRUNTIME swig_type_info* SwigJSCPacked_UnpackData(JSContextRef context, JSValueRef valRef, void *ptr, size_t size) { if (SwigJSCPacked_Check(context, valRef)) { JSObjectRef objRef = JSValueToObject(context, valRef, NULL); SwigPackedData *sobj = (SwigPackedData *) JSObjectGetPrivate(objRef); if (sobj->size != size) return 0; memcpy(ptr, sobj->data, size); return sobj->type; } else { return 0; } } SWIGRUNTIME int SWIG_JSC_ConvertPacked(JSContextRef context, JSValueRef valRef, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigJSCPacked_UnpackData(context, valRef, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } SWIGRUNTIME JSValueRef SWIG_JSC_NewPackedObj(JSContextRef context, void *data, size_t size, swig_type_info *type) { JSClassRef classRef = _SwigObject_classRef; JSObjectRef result = JSObjectMake(context, classRef, NULL); SwigPackedData* cdata = (SwigPackedData*) malloc(sizeof(SwigPackedData)); cdata->data = data; cdata->size = size; cdata->type = type; JSObjectSetPrivate(result, cdata); return result; } /* SwigPackedData wrappers */ SWIGRUNTIME void _wrap_SwigPackedData_delete(JSObjectRef obj) { SwigPackedData* cdata = (SwigPackedData*) JSObjectGetPrivate(obj); if (cdata) { free(cdata->data); } } /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_JSC_ConvertPacked(context, obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_JSC_NewPackedObj(context, ptr, sz, type) /* --------------------------------------------------------------------------- * Support for IN/OUTPUT typemaps (see Lib/typemaps/inoutlist.swg) * * ---------------------------------------------------------------------------*/ SWIGRUNTIME unsigned int SWIGJSC_ArrayLength(JSContextRef context, JSObjectRef arr) { static JSStringRef LENGTH = 0; JSValueRef exception = NULL; JSValueRef js_length; double length; if (LENGTH == 0) { LENGTH = JSStringCreateWithUTF8CString("length"); } js_length = JSObjectGetProperty(context, arr, LENGTH, &exception); if (exception == 0 && JSValueIsNumber(context, js_length)) { length = JSValueToNumber(context, js_length, 0); return (unsigned int) length; } else { return 0; } } SWIGRUNTIME JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueRef obj) { JSObjectRef arr; unsigned int length; if (JSValueIsUndefined(context, value)) { arr = JSObjectMakeArray(context, 0, 0, 0); } else { arr = JSValueToObject(context, value, 0); } length = SWIGJSC_ArrayLength(context, arr); JSObjectSetPropertyAtIndex(context, arr, length, obj, 0); return arr; } swig-3.0.2/Lib/javascript/v8/0000775000175000017500000000000012343605122015554 5ustar williamwilliamswig-3.0.2/Lib/javascript/v8/javascriptinit.swg0000664000175000017500000000714112343605122021333 0ustar williamwilliam%insert(init) %{ #include SWIGRUNTIME void SWIG_V8_SetModule(void *, swig_module_info *swig_module) { v8::Local global_obj = v8::Context::GetCurrent()->Global(); v8::Local mod = v8::External::New(swig_module); assert(!mod.IsEmpty()); global_obj->SetHiddenValue(v8::String::New("swig_module_info_data"), mod); } SWIGRUNTIME swig_module_info * SWIG_V8_GetModule(void *) { v8::Local global_obj = v8::Context::GetCurrent()->Global(); v8::Local moduleinfo = global_obj->GetHiddenValue(v8::String::New("swig_module_info_data")); if (moduleinfo.IsEmpty()) { // It's not yet loaded return 0; } v8::Local moduleinfo_extern = v8::Local::Cast(moduleinfo); if (moduleinfo_extern.IsEmpty()) { // Something's not right return 0; } void *ptr = moduleinfo_extern->Value(); assert(ptr); swig_module_info *retptr = static_cast(ptr); assert(retptr); return retptr; } #define SWIG_GetModule(clientdata) SWIG_V8_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_V8_SetModule(clientdata, pointer) %} %insert(init) "swiginit.swg" // Open the initializer function definition here %fragment ("js_initializer_define", "templates") %{ #define SWIGV8_INIT $jsname_initialize %} %insert(init) %{ // Note: 'extern "C"'' disables name mangling which makes it easier to load the symbol manually // TODO: is it ok to do that? extern "C" #if (NODE_MODULE_VERSION < 0x000C) void SWIGV8_INIT (v8::Handle exports) #else void SWIGV8_INIT (v8::Handle exports, v8::Handle /*module*/) #endif { SWIG_InitializeModule(static_cast(&exports)); v8::HandleScope scope; v8::Handle exports_obj = exports; %} /* ----------------------------------------------------------------------------- * js_initializer: template for the module initializer function * - $jsname: module name * - $jsv8nspaces: part with code creating namespace objects * - $jsv8classtemplates: part with code creating class templates * - $jsv8wrappers: part with code that registers wrapper functions * - $jsv8inheritance: part with inherit statements * - $jsv8classinstances: part with code creating class objects * - $jsv8staticwrappers: part with code adding static functions to class objects * - $jsv8registerclasses: part with code that registers class objects in namespaces * - $jsv8registernspaces: part with code that registers namespaces in parent namespaces * ----------------------------------------------------------------------------- */ %fragment("js_initializer", "templates") %{ // a class template for creating proxies of undefined types #if (SWIG_V8_VERSION < 0x031900) SWIGV8_SWIGTYPE_Proxy_class_templ = v8::Persistent::New(SWIGV8_CreateClassTemplate("SwigProxy")); #else SWIGV8_SWIGTYPE_Proxy_class_templ.Reset(v8::Isolate::GetCurrent(), SWIGV8_CreateClassTemplate("SwigProxy")); #endif /* create objects for namespaces */ $jsv8nspaces /* create class templates */ $jsv8classtemplates /* register wrapper functions */ $jsv8wrappers /* setup inheritances */ $jsv8inheritance /* class instances */ $jsv8classinstances /* add static class functions and variables */ $jsv8staticwrappers /* register classes */ $jsv8registerclasses /* create and register namespace objects */ $jsv8registernspaces } #if defined(BUILDING_NODE_EXTENSION) NODE_MODULE($jsname, $jsname_initialize) #endif %} swig-3.0.2/Lib/javascript/v8/javascriptfragments.swg0000664000175000017500000000105712343605122022356 0ustar williamwilliam/* Create a file with this name, 'javascriptfragments.swg', in your working directory and add all the %fragments you want to take precedence over the default ones defined by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(PyObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.2/Lib/javascript/v8/std_map.i0000664000175000017500000000444112343605122017360 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.2/Lib/javascript/v8/javascriptkw.swg0000664000175000017500000000176712343605122021021 0ustar williamwilliam#ifndef JAVASCRIPT_JAVASCRIPTKW_SWG_ #define JAVASCRIPT_JAVASCRIPTKW_SWG_ /* Warnings for Java keywords */ #define JAVASCRIPTKW(x) %keywordwarn("'" `x` "' is a javascript keyword, renaming to '_"`x`"'",rename="_%s") `x` /* Taken from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Reserved_Words */ JAVASCRIPTKW(break); JAVASCRIPTKW(case); JAVASCRIPTKW(catch); JAVASCRIPTKW(continue); JAVASCRIPTKW(default); JAVASCRIPTKW(delete); JAVASCRIPTKW(do); JAVASCRIPTKW(else); JAVASCRIPTKW(finally); JAVASCRIPTKW(for); JAVASCRIPTKW(function); JAVASCRIPTKW(if); JAVASCRIPTKW(in); JAVASCRIPTKW(instanceof); JAVASCRIPTKW(new); JAVASCRIPTKW(return); JAVASCRIPTKW(switch); JAVASCRIPTKW(this); JAVASCRIPTKW(throw); JAVASCRIPTKW(try); JAVASCRIPTKW(typeof); JAVASCRIPTKW(var); JAVASCRIPTKW(void); JAVASCRIPTKW(while); JAVASCRIPTKW(with); /* others bad names if any*/ // for example %namewarn("321:clone() is a javascript bad method name") *::clone(); #undef JAVASCRIPTKW #endif //JAVASCRIPT_JAVASCRIPTKW_SWG_ swig-3.0.2/Lib/javascript/v8/javascriptcomplex.swg0000664000175000017500000000640012343605122022034 0ustar williamwilliam/* Defines the As/From converters for double/float complex, you need to provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex accessor methods. See the std_complex.i and ccomplex.i for concret examples. */ /* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header", fragment=SWIG_From_frag(double)) { SWIGINTERNINLINE v8::Handle SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) { v8::HandleScope scope; v8::Local vals = v8::Array::New(2); vals->Set(0, SWIG_From(double)(Real(c))); vals->Set(1, SWIG_From(double)(Imag(c))); return scope.Close(vals); } } %enddef /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int SWIG_AsVal_dec(Type) (v8::Handle o, Type* val) { v8::HandleScope scope; if (o->IsArray()) { v8::Handle array = v8::Handle::Cast(o); if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2]."); double re, im; int res; res = SWIG_AsVal(double)(array->Get(0), &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } res = SWIG_AsVal(double)(array->Get(1), &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } if (val) *val = Constructor(re, im); return SWIG_OK; } else if(o->IsNumber()){ double d; int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef /* the float case */ %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float)) { SWIGINTERN int SWIG_AsVal_dec(Type) (v8::Handle o, Type* val) { v8::HandleScope scope; if (o->IsArray()) { v8::Handle array = v8::Handle::Cast(o); if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2]."); double re, im; int res; res = SWIG_AsVal(double)(array->Get(0), &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } res = SWIG_AsVal(double)(array->Get(1), &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else { return SWIG_OverflowError; } } else if(o->IsNumber()){ float re; int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(re, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.2/Lib/javascript/v8/std_pair.i0000664000175000017500000000126112343605122017533 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.2/Lib/javascript/v8/std_complex.i0000664000175000017500000000073212343605122020251 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.2/Lib/javascript/v8/typemaps.i0000664000175000017500000001047612343605122017600 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * These mappings provide support for input/output arguments and common * uses for C/C++ pointers. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Python tuple. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Python output of the function would be a tuple containing both output values. */ // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Python tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Python). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Python variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %include swig-3.0.2/Lib/javascript/v8/javascripttypemaps.swg0000664000175000017500000000244012343605122022227 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Javascript * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* Include fundamental fragemt definitions */ %include /* Look for user fragments file. */ %include /* Javascript fragments for fundamental types */ %include /* Javascript fragments for char* strings */ %include /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* Javascript types */ #define SWIG_Object v8::Handle #define VOID_Object v8::Undefined() /* Overload of the output/constant/exception/dirout handling */ /* append output */ #define SWIG_AppendOutput(result, obj) SWIGV8_AppendOutput(result, obj) /* set constant */ #define SWIG_SetConstant(name, obj) /* raise */ #define SWIG_Raise(obj, type, desc) SWIG_V8_Raise(type) /* Include the unified typemap library */ %include swig-3.0.2/Lib/javascript/v8/javascriptruntime.swg0000664000175000017500000000235212343605122022052 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javascriptruntime.swg * * ----------------------------------------------------------------------------- */ // V8 Version Macro // ---------------- // v8 does not (until now) provide a version macro - which is still discussed and may come soon. // Until then, we set a default version which can be overridden via command line using V8_VERSION: // swig -javascript -v8 -DV8_VERSION=0x031110 // Or code in the interface file using SWIG_V8_VERSION: // %begin %{#define SWIG_V8_VERSION 0x031110%} %define %swig_v8_define_version(version) %insert("runtime") %{ #ifndef SWIG_V8_VERSION #define SWIG_V8_VERSION version #endif %} %enddef #ifdef V8_VERSION %swig_v8_define_version(V8_VERSION) #else // HACK: defining a default version %swig_v8_define_version(0x031110) #endif // Node support // ------------ #ifdef BUILDING_NODE_EXTENSION %insert("runtime") %{ #include %} #endif // V8 runtime // ---------- %insert(runtime) %{ #include #include #include #include %} %insert(runtime) "swigrun.swg"; /* SWIG API */ %insert(runtime) "swigerrors.swg"; /* SWIG errors */ %insert(runtime) "javascriptrun.swg" swig-3.0.2/Lib/javascript/v8/cdata.i0000664000175000017500000000003612343605122017001 0ustar williamwilliam%include swig-3.0.2/Lib/javascript/v8/ccomplex.i0000664000175000017500000000140212343605122017535 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ccomplex.i * * C complex typemaps * ISO C99: 7.3 Complex arithmetic * ----------------------------------------------------------------------------- */ %include %{ #include %} /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) %swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); swig-3.0.2/Lib/javascript/v8/javascriptstrings.swg0000664000175000017500000000332012343605122022054 0ustar williamwilliam /* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize", "header", fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_AsCharPtrAndSize(v8::Handle valRef, char** cptr, size_t* psize, int *alloc) { if(valRef->IsString()) { v8::Handle js_str = valRef->ToString(); size_t len = js_str->Utf8Length() + 1; char* cstr = new char[len]; js_str->WriteUtf8(cstr, len); if(alloc) *alloc = SWIG_NEWOBJ; if(psize) *psize = len; if(cptr) *cptr = cstr; return SWIG_OK; } else { if(valRef->IsObject()) { v8::Handle obj = valRef->ToObject(); // try if the object is a wrapped char[] swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } return SWIG_TypeError; } else { return SWIG_TypeError; } } } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE v8::Handle SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { // TODO: handle extra long strings return v8::Undefined(); } else { v8::Handle js_str = v8::String::New(carray, size); return js_str; } } else { return v8::Undefined(); } } } swig-3.0.2/Lib/javascript/v8/javascriptprimtypes.swg0000664000175000017500000001016412343605122022423 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* boolean */ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(bool)(bool value) { return v8::Boolean::New(value); } } %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(v8::Handle obj, bool *val) { if(!obj->IsBoolean()) { return SWIG_ERROR; } if (val) *val = obj->BooleanValue(); return SWIG_OK; } } /* int */ %fragment(SWIG_From_frag(int),"header") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(int)(int value) { return v8::Int32::New(value); } } %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERN int SWIG_AsVal_dec(int)(v8::Handle valRef, int* val) { if (!valRef->IsNumber()) { return SWIG_TypeError; } if(val) *val = valRef->IntegerValue(); return SWIG_OK; } } /* long */ %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(long)(long value) { return v8::Number::New(value); } } %fragment(SWIG_AsVal_frag(long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long)(v8::Handle obj, long* val) { if (!obj->IsNumber()) { return SWIG_TypeError; } if(val) *val = (long) obj->IntegerValue(); return SWIG_OK; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE v8::Handle SWIG_From_dec(unsigned long)(unsigned long value) { return (value > LONG_MAX) ? v8::Integer::NewFromUnsigned(value) : v8::Integer::New(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(v8::Handle obj, unsigned long *val) { if(!obj->IsNumber()) { return SWIG_TypeError; } long longVal = (long) obj->NumberValue(); if(longVal < 0) { return SWIG_OverflowError; } if(val) *val = longVal; return SWIG_OK; } } /* long long */ // Note: these are copied from 'long' and probably need fixing %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(long long)(long long value) { return v8::Number::New(value); } } %fragment(SWIG_AsVal_frag(long long),"header", fragment=SWIG_AsVal_frag(long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(long long)(v8::Handle obj, long long* val) { if (!obj->IsNumber()) { return SWIG_TypeError; } if(val) *val = (long long) obj->IntegerValue(); return SWIG_OK; } } /* unsigned long long */ // Note: these are copied from 'unsigned long' and probably need fixing %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? v8::Integer::NewFromUnsigned(value) : v8::Integer::New(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(v8::Handle obj, unsigned long long *val) { if(!obj->IsNumber()) { return SWIG_TypeError; } long long longVal = (long long) obj->NumberValue(); if(longVal < 0) { return SWIG_OverflowError; } if(val) *val = longVal; return SWIG_OK; } } /* double */ %fragment(SWIG_From_frag(double),"header") { SWIGINTERN v8::Handle SWIG_From_dec(double) (double val) { return v8::Number::New(val); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(v8::Handle obj, double *val) { if(!obj->IsNumber()) { return SWIG_TypeError; } if(val) *val = obj->NumberValue(); return SWIG_OK; } } swig-3.0.2/Lib/javascript/v8/std_common.i0000664000175000017500000000014612343605122020071 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.2/Lib/javascript/v8/exception.i0000664000175000017500000000004212343605122017720 0ustar williamwilliam%include swig-3.0.2/Lib/javascript/v8/javascripthelpers.swg0000664000175000017500000000663312343605122022037 0ustar williamwilliam%insert(runtime) %{ // Note: since 3.19 there are new CallBack types, since 03.21.9 the old ones have been removed #if SWIG_V8_VERSION < 0x031900 typedef v8::InvocationCallback SwigV8FunctionCallback; typedef v8::AccessorGetter SwigV8AccessorGetterCallback; typedef v8::AccessorSetter SwigV8AccessorSetterCallback; typedef v8::AccessorInfo SwigV8PropertyCallbackInfoVoid; #else typedef v8::FunctionCallback SwigV8FunctionCallback; typedef v8::AccessorGetterCallback SwigV8AccessorGetterCallback; typedef v8::AccessorSetterCallback SwigV8AccessorSetterCallback; typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfoVoid; #endif /** * Creates a class template for a class with specified initialization function. */ SWIGRUNTIME v8::Handle SWIGV8_CreateClassTemplate(const char* symbol) { v8::HandleScope scope; v8::Local class_templ = v8::FunctionTemplate::New(); class_templ->SetClassName(v8::String::NewSymbol(symbol)); v8::Handle inst_templ = class_templ->InstanceTemplate(); inst_templ->SetInternalFieldCount(1); v8::Handle equals_templ = class_templ->PrototypeTemplate(); equals_templ->Set(v8::String::NewSymbol("equals"), v8::FunctionTemplate::New(_SWIGV8_wrap_equals)); v8::Handle cptr_templ = class_templ->PrototypeTemplate(); cptr_templ->Set(v8::String::NewSymbol("getCPtr"), v8::FunctionTemplate::New(_wrap_getCPtr)); return scope.Close(class_templ); } /** * Registers a class method with given name for a given class template. */ SWIGRUNTIME void SWIGV8_AddMemberFunction(v8::Handle class_templ, const char* symbol, SwigV8FunctionCallback _func) { v8::Handle proto_templ = class_templ->PrototypeTemplate(); proto_templ->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func)); } /** * Registers a class property with given name for a given class template. */ SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Handle class_templ, const char* symbol, SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) { v8::Handle proto_templ = class_templ->InstanceTemplate(); proto_templ->SetAccessor(v8::String::NewSymbol(symbol), getter, setter); } /** * Registers a class method with given name for a given object. */ SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle obj, const char* symbol, const SwigV8FunctionCallback& _func) { obj->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func)->GetFunction()); } /** * Registers a class method with given name for a given object. */ SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Handle obj, const char* symbol, SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) { obj->SetAccessor(v8::String::NewSymbol(symbol), getter, setter); } SWIGRUNTIME void JS_veto_set_variable(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid& info) { char buffer[256]; char msg[512]; int res; property->WriteUtf8(buffer, 256); res = sprintf(msg, "Tried to write read-only variable: %s.", buffer); if(res<0) { SWIG_exception(SWIG_ERROR, "Tried to write read-only variable."); } else { SWIG_exception(SWIG_ERROR, msg); } } %} // v8_helper_functions swig-3.0.2/Lib/javascript/v8/complex.i0000664000175000017500000000012012343605122017366 0ustar williamwilliam#ifdef __cplusplus %include #else %include #endif swig-3.0.2/Lib/javascript/v8/javascriptcode.swg0000664000175000017500000004167412343605122021313 0ustar williamwilliam/* ----------------------------------------------------------------------------- * js_ctor: template for wrapping a ctor. * - $jswrapper: wrapper of called ctor * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * - $jsargcount: number of arguments * - $jsmangledtype: mangled type of class * ----------------------------------------------------------------------------- */ %fragment("js_ctor", "templates") %{ SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) { v8::HandleScope scope; v8::Handle self = args.Holder(); $jslocals if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); SWIGV8_RETURN(self); goto fail; fail: SWIGV8_RETURN(v8::Undefined()); } %} /* ----------------------------------------------------------------------------- * js_veto_ctor: a vetoing ctor for abstract classes * - $jswrapper: name of wrapper * - $jsname: class name * ----------------------------------------------------------------------------- */ %fragment ("js_veto_ctor", "templates") %{ SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) { v8::HandleScope scope; SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated"); SWIGV8_RETURN(v8::Undefined()); } %} /* ----------------------------------------------------------------------------- * js_ctor_dispatcher: dispatcher for overloaded constructors * - $jswrapper: name of wrapper * - $jsname: class name * - $jsdispatchcases: part containing code for dispatching * ----------------------------------------------------------------------------- */ %fragment ("js_ctor_dispatcher", "templates") %{ SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) { v8::HandleScope scope; OverloadErrorHandler errorHandler; v8::Handle self; // switch all cases by means of series of if-returns. $jsdispatchcases // default: SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for construction of $jsmangledname"); fail: SWIGV8_RETURN(v8::Undefined()); } %} /* ----------------------------------------------------------------------------- * js_overloaded_ctor: template for wrapping a ctor. * - $jswrapper: wrapper of called ctor * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * - $jsargcount: number of arguments * - $jsmangledtype: mangled type of class * ----------------------------------------------------------------------------- */ %fragment("js_overloaded_ctor", "templates") %{ SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler) { v8::HandleScope scope; v8::Handle self = args.Holder(); $jslocals if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); SWIGV8_RETURN(self); goto fail; fail: SWIGV8_RETURN(v8::Undefined()); } %} /* ----------------------------------------------------------------------------- * js_ctor_dispatch_case: template for a dispatch case for calling an overloaded ctor. * - $jsargcount: number of arguments of called ctor * - $jswrapper: wrapper of called ctor * * Note: a try-catch-like mechanism is used to switch cases * ----------------------------------------------------------------------------- */ %fragment ("js_ctor_dispatch_case", "templates") %{ if(args.Length() == $jsargcount) { errorHandler.err.Clear(); #if SWIG_V8_VERSION < 0x031900 self = $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { return scope.Close(self); } #else $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { return; } #endif } %} /* ----------------------------------------------------------------------------- * js_dtor: template for a destructor wrapper * - $jsmangledname: mangled class name * - $jstype: class type * ----------------------------------------------------------------------------- */ %fragment ("js_dtor", "templates") %{ #if (SWIG_V8_VERSION < 0x031900) void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); #else void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy) { #endif if(proxy->swigCMemOwn && proxy->swigCObject) { #ifdef SWIGRUNTIME_DEBUG printf("Deleting wrapped instance: %s\n", proxy->info->name); #endif $jsfree proxy->swigCObject; } delete proxy; object.Clear(); #if (SWIG_V8_VERSION < 0x031900) object.Dispose(); #elif (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); #else object->Dispose(); #endif } %} /* ----------------------------------------------------------------------------- * js_dtoroverride: template for a destructor wrapper * - $jsmangledname: mangled class name * - $jstype: class type * - ${destructor_action}: The custom destructor action to invoke. * ----------------------------------------------------------------------------- */ %fragment ("js_dtoroverride", "templates") %{ #if (SWIG_V8_VERSION < 0x031900) void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); #else void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy) { #endif if(proxy->swigCMemOwn && proxy->swigCObject) { $jstype arg1 = ($jstype)proxy->swigCObject; ${destructor_action} } delete proxy; #if (SWIG_V8_VERSION < 0x031900) object.Dispose(); #elif (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); #else object->Dispose(); #endif } %} /* ----------------------------------------------------------------------------- * js_getter: template for getter function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment("js_getter", "templates") %{ SwigV8ReturnValue $jswrapper(v8::Local property, const SwigV8PropertyCallbackInfo& info) { v8::HandleScope scope; v8::Handle jsresult; $jslocals $jscode SWIGV8_RETURN_INFO(jsresult, info); goto fail; fail: SWIGV8_RETURN_INFO(v8::Undefined(), info); } %} /* ----------------------------------------------------------------------------- * js_setter: template for setter function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment("js_setter", "templates") %{ void $jswrapper(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid& info) { v8::HandleScope scope; $jslocals $jscode goto fail; fail: return; } %} /* ----------------------------------------------------------------------------- * js_function: template for function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment("js_function", "templates") %{ SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) { v8::HandleScope scope; v8::Handle jsresult; $jslocals if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode SWIGV8_RETURN(jsresult); goto fail; fail: SWIGV8_RETURN(v8::Undefined()); } %} /* ----------------------------------------------------------------------------- * js_function_dispatcher: template for a function dispatcher for overloaded functions * - $jswrapper: wrapper function name * - $jsname: name of the wrapped function * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment("js_function_dispatcher", "templates") %{ SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) { v8::HandleScope scope; v8::Handle jsresult; OverloadErrorHandler errorHandler; $jscode SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname."); goto fail; fail: SWIGV8_RETURN(v8::Undefined()); } %} /* ----------------------------------------------------------------------------- * js_overloaded_function: template for a overloaded function * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_overloaded_function", "templates") %{ SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler) { v8::HandleScope scope; v8::Handle jsresult; $jslocals $jscode SWIGV8_RETURN(jsresult); goto fail; fail: SWIGV8_RETURN(v8::Undefined()); } %} /* ----------------------------------------------------------------------------- * js_function_dispatch_case: template for a case used in the function dispatcher * - $jswrapper: wrapper function name * - $jsargcount: number of arguments of overloaded function * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_function_dispatch_case", "templates") %{ if(args.Length() == $jsargcount) { errorHandler.err.Clear(); #if (SWIG_V8_VERSION < 0x031900) jsresult = $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { return scope.Close(jsresult); } #else $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { return; } #endif } %} /* ----------------------------------------------------------------------------- * jsv8_declare_class_template: template for a class template declaration. * - $jsmangledname: mangled class name * ----------------------------------------------------------------------------- */ %fragment("jsv8_declare_class_template", "templates") %{ SWIGV8_ClientData $jsmangledname_clientData; %} /* ----------------------------------------------------------------------------- * jsv8_define_class_template: template for a class template definition. * - $jsmangledname: mangled class name * - $jsmangledtype: mangled class type * - $jsdtor: the dtor wrapper * ----------------------------------------------------------------------------- */ %fragment("jsv8_define_class_template", "templates") %{ v8::Handle $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname"); #if (SWIG_V8_VERSION < 0x031900) $jsmangledname_clientData.class_templ = v8::Persistent::New($jsmangledname_class); #else $jsmangledname_clientData.class_templ.Reset(v8::Isolate::GetCurrent(), $jsmangledname_class); #endif $jsmangledname_clientData.dtor = $jsdtor; if (SWIGTYPE_$jsmangledtype->clientdata == 0) { SWIGTYPE_$jsmangledtype->clientdata = &$jsmangledname_clientData; } %} /* ----------------------------------------------------------------------------- * jsv8_inherit: template for an class inherit statement. * - $jsmangledname: mangled class name * - $jsbaseclass: mangled name of the base class * ----------------------------------------------------------------------------- */ %fragment("jsv8_inherit", "templates") %{ if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty())) { #if (SWIG_V8_VERSION < 0x031900) $jsmangledname_class->Inherit(static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ); #else $jsmangledname_class->Inherit( v8::Handle::New( v8::Isolate::GetCurrent(), static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ) ); #endif #ifdef SWIGRUNTIME_DEBUG printf("Inheritance successful $jsmangledname $jsbaseclass\n"); #endif } else { #ifdef SWIGRUNTIME_DEBUG printf("Unable to inherit baseclass, it didn't exist $jsmangledname $jsbaseclass\n"); #endif } %} /* ----------------------------------------------------------------------------- * jsv8_create_class_instance: template for creating an class object. * - $jsname: class name * - $jsmangledname: mangled class name * ----------------------------------------------------------------------------- */ %fragment("jsv8_create_class_instance", "templates") %{ v8::Handle $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname"); $jsmangledname_class_0->SetCallHandler($jsctor); $jsmangledname_class_0->Inherit($jsmangledname_class); $jsmangledname_class_0->SetHiddenPrototype(true); v8::Handle $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); %} /* ----------------------------------------------------------------------------- * jsv8_register_class: template for a statement that registers a class in a parent namespace. * - $jsname: class name * - $jsmangledname: mangled class name * - $jsparent: mangled name of parent namespace * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_class", "templates") %{ $jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj); %} /* ----------------------------------------------------------------------------- * jsv8_create_namespace: template for a statement that creates a namespace object. * - $jsmangledname: mangled namespace name * ----------------------------------------------------------------------------- */ %fragment("jsv8_create_namespace", "templates") %{ v8::Handle $jsmangledname_obj = v8::Object::New(); %} /* ----------------------------------------------------------------------------- * jsv8_register_namespace: template for a statement that registers a namespace in a parent namespace. * - $jsname: name of namespace * - $jsmangledname: mangled name of namespace * - $jsparent: mangled name of parent namespace * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_namespace", "templates") %{ $jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj); %} /* ----------------------------------------------------------------------------- * jsv8_register_member_function: template for a statement that registers a member function. * - $jsmangledname: mangled class name * - $jsname: name of the function * - $jswrapper: wrapper of the member function * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_member_function", "templates") %{ SWIGV8_AddMemberFunction($jsmangledname_class, "$jsname", $jswrapper); %} /* ----------------------------------------------------------------------------- * jsv8_register_member_variable: template for a statement that registers a member variable. * - $jsmangledname: mangled class name * - $jsname: name of the function * - $jsgetter: wrapper of the getter function * - $jssetter: wrapper of the setter function * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_member_variable", "templates") %{ SWIGV8_AddMemberVariable($jsmangledname_class, "$jsname", $jsgetter, $jssetter); %} /* ----------------------------------------------------------------------------- * jsv8_register_static_function: template for a statement that registers a static class function. * - $jsname: function name * - $jswrapper: wrapper of the function * - $jsparent: mangled name of parent namespace * * Note: this template is also used for global functions. * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_static_function", "templates") %{ SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper); %} /* ----------------------------------------------------------------------------- * jsv8_register_static_variable: template for a statement that registers a static variable. * - $jsname: variable name * - $jsparent: mangled name of parent namespace * - $jsgetter: wrapper of the getter function * - $jssetter: wrapper of the setter function * * Note: this template is also used for global variables. * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_static_variable", "templates") %{ SWIGV8_AddStaticVariable($jsparent_obj, "$jsname", $jsgetter, $jssetter); %} swig-3.0.2/Lib/javascript/v8/javascript.swg0000664000175000017500000000066712343605122020455 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javascript.swg * * Javascript typemaps * ----------------------------------------------------------------------------- */ %include %include %include %include %include %include %include swig-3.0.2/Lib/javascript/v8/std_vector.i0000664000175000017500000000511112343605122020100 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %include %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i swig-3.0.2/Lib/javascript/v8/std_except.i0000664000175000017500000000004312343605122020065 0ustar williamwilliam%include swig-3.0.2/Lib/javascript/v8/stl.i0000664000175000017500000000044312343605122016531 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.2/Lib/javascript/v8/std_deque.i0000664000175000017500000000003412343605122017700 0ustar williamwilliam%include swig-3.0.2/Lib/javascript/v8/arrays_javascript.i0000664000175000017500000000626312343605122021464 0ustar williamwilliam/* ----------------------------------------------------------------------------- * arrays_javascript.i * * These typemaps give more natural support for arrays. The typemaps are not efficient * as there is a lot of copying of the array values whenever the array is passed to C/C++ * from JavaScript and vice versa. The JavaScript array is expected to be the same size as the C array. * An exception is thrown if they are not. * * Example usage: * Wrapping: * * %include * %inline %{ * extern int FiddleSticks[3]; * %} * * Use from JavaScript like this: * * var fs = [10, 11, 12]; * example.FiddleSticks = fs; * fs = example.FiddleSticks; * ----------------------------------------------------------------------------- */ %fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {} %fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_frag(double)) {} %typemap(in, fragment="SWIG_JSCGetIntProperty") int[], int[ANY] (int length = 0, v8::Local array, v8::Local jsvalue, int i = 0, int res = 0, $*1_ltype temp) { if ($input->IsArray()) { // Convert into Array array = v8::Local::Cast($input); length = $1_dim0; $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length); // Get each element from array for (i = 0; i < length; i++) { jsvalue = array->Get(i); // Get primitive value from JSObject res = SWIG_AsVal(int)(jsvalue, &temp); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double"); } arg$argnum[i] = temp; } } else { SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef"); } } %typemap(freearg) int[], int[ANY] { free($1); } %typemap(out, fragment=SWIG_From_frag(int)) int[], int[ANY] (int length = 0, int i = 0) { length = $1_dim0; v8::Local array = v8::Array::New(length); for (i = 0; i < length; i++) { array->Set(i, SWIG_From(int)($1[i])); } $result = array; } %typemap(in, fragment="SWIG_JSCGetNumberProperty") double[], double[ANY] (int length = 0, v8::Local array, v8::Local jsvalue, int i = 0, int res = 0, $*1_ltype temp) { if ($input->IsArray()) { // Convert into Array array = v8::Local::Cast($input); length = $1_dim0; $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length); // Get each element from array for (i = 0; i < length; i++) { jsvalue = array->Get(i); // Get primitive value from JSObject res = SWIG_AsVal(double)(jsvalue, &temp); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double"); } arg$argnum[i] = temp; } } else { SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef"); } } %typemap(freearg) double[], double[ANY] { free($1); } %typemap(out, fragment=SWIG_From_frag(double)) double[], double[ANY] (int length = 0, int i = 0) { length = $1_dim0; v8::Local array = v8::Array::New(length); for (i = 0; i < length; i++) { array->Set(i, SWIG_From(double)($1[i])); } $result = array; } swig-3.0.2/Lib/javascript/v8/javascriptrun.swg0000664000175000017500000003446012343605122021200 0ustar williamwilliam/* --------------------------------------------------------------------------- * Error handling * * ---------------------------------------------------------------------------*/ #define SWIG_Error(code, msg) SWIGV8_ErrorHandler.error(code, msg) #define SWIG_exception(code, msg) SWIGV8_ErrorHandler.error(code, msg) #define SWIG_fail goto fail #define SWIGV8_OVERLOAD false void SWIG_V8_Raise(const char* msg) { v8::ThrowException(v8::Exception::Error(v8::String::New(msg))); } /* Note: There are two contexts for handling errors. A static V8ErrorHandler is used in not overloaded methods. For overloaded methods the throwing type checking mechanism is used during dispatching. As V8 exceptions can not be resetted properly the trick is to use a dynamic ErrorHandler with same local name as the global one. - See defintion of SWIG_Error above. - See code templates 'JS_function_dispatcher', 'JS_functionwrapper_overload', and 'JS_function_dispatch_case' in javascriptcode.swg */ class V8ErrorHandler { public: virtual ~V8ErrorHandler() {} virtual void error(int code, const char* msg) { SWIG_V8_Raise(msg); } }; // this is used in usually V8ErrorHandler SWIGV8_ErrorHandler; // instances of this are used in overloaded functions class OverloadErrorHandler: public V8ErrorHandler { public: virtual void error(int code, const char* msg) { err = v8::Exception::Error(v8::String::New(msg)); if(code != SWIG_TypeError) { v8::ThrowException(err); } } v8::Handle err; }; // Note: these typedefs and defines are used to deal with v8 API changes since version 3.19.00 #if (SWIG_V8_VERSION < 0x031900) typedef v8::Handle SwigV8ReturnValue; typedef v8::Arguments SwigV8Arguments; typedef v8::AccessorInfo SwigV8PropertyCallbackInfo; #define SWIGV8_RETURN(val) return scope.Close(val) #define SWIGV8_RETURN_INFO(val, info) return scope.Close(val) #else typedef void SwigV8ReturnValue; typedef v8::FunctionCallbackInfo SwigV8Arguments; typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return #define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return #endif /* --------------------------------------------------------------------------- * Basic Proxy object * * ---------------------------------------------------------------------------*/ // Note: to trigger the v8 gc more often one can tell v8 about the memory consumption // TODO: we could add a v8 specific parameter to control this value #define SWIGV8_AVG_OBJ_SIZE 1000 class SWIGV8_Proxy { public: SWIGV8_Proxy(): swigCMemOwn(false), swigCObject(0), info(0) { v8::V8::AdjustAmountOfExternalAllocatedMemory(SWIGV8_AVG_OBJ_SIZE); }; ~SWIGV8_Proxy() { #if (SWIG_V8_VERSION < 0x031900 || SWIG_V8_VERSION >= 0x032100) handle.ClearWeak(); handle.Dispose(); #else handle.ClearWeak(v8::Isolate::GetCurrent()); handle.Dispose(v8::Isolate::GetCurrent()); #endif handle.Clear(); v8::V8::AdjustAmountOfExternalAllocatedMemory(-SWIGV8_AVG_OBJ_SIZE); } bool swigCMemOwn; void *swigCObject; swig_type_info *info; v8::Persistent handle; }; class SWIGV8_ClientData { public: v8::Persistent class_templ; #if (SWIG_V8_VERSION < 0x031900) void (*dtor) (v8::Persistent< v8::Value> object, void *parameter); #else void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy); #endif }; v8::Persistent SWIGV8_SWIGTYPE_Proxy_class_templ; int SWIG_V8_ConvertInstancePtr(v8::Handle objRef, void** ptr, swig_type_info *info, int flags) { v8::HandleScope scope; if(objRef->InternalFieldCount() < 1) return SWIG_ERROR; #if (SWIG_V8_VERSION < 0x031900) v8::Handle cdataRef = objRef->GetInternalField(0); SWIGV8_Proxy *cdata = static_cast(v8::External::Unwrap(cdataRef)); #else SWIGV8_Proxy *cdata = static_cast(objRef->GetAlignedPointerFromInternalField(0)); #endif if(cdata == NULL) { return SWIG_ERROR; } if(cdata->info != info) { swig_cast_info *tc = SWIG_TypeCheckStruct(cdata->info, info); if (!tc && cdata->info->name) { tc = SWIG_TypeCheck(cdata->info->name, info); } bool type_valid = tc != 0; if(!type_valid) { return SWIG_TypeError; } } *ptr = cdata->swigCObject; if(flags & SWIG_POINTER_DISOWN) { cdata->swigCMemOwn = false; } return SWIG_OK; } #if (SWIG_V8_VERSION < 0x031900) void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter) #else void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) #endif { #if (SWIG_V8_VERSION < 0x031900) SWIGV8_Proxy *proxy = static_cast(parameter); #endif delete proxy; } int SWIG_V8_GetInstancePtr(v8::Handle valRef, void** ptr) { if(!valRef->IsObject()) { return SWIG_TypeError; } v8::Handle objRef = valRef->ToObject(); if(objRef->InternalFieldCount() < 1) return SWIG_ERROR; #if (SWIG_V8_VERSION < 0x031900) v8::Handle cdataRef = objRef->GetInternalField(0); SWIGV8_Proxy *cdata = static_cast(v8::External::Unwrap(cdataRef)); #else SWIGV8_Proxy *cdata = static_cast(objRef->GetAlignedPointerFromInternalField(0)); #endif if(cdata == NULL) { return SWIG_ERROR; } *ptr = cdata->swigCObject; return SWIG_OK; } void SWIGV8_SetPrivateData(v8::Handle obj, void* ptr, swig_type_info *info, int flags) { SWIGV8_Proxy* cdata = new SWIGV8_Proxy(); cdata->swigCObject = ptr; cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0; cdata->info = info; #if (SWIG_V8_VERSION < 0x031900) obj->SetPointerInInternalField(0, cdata); cdata->handle = v8::Persistent::New(obj); #else obj->SetAlignedPointerInInternalField(0, cdata); cdata->handle.Reset(v8::Isolate::GetCurrent(), obj); #endif #if (SWIG_V8_VERSION < 0x031900) // clientdata must be set for owned data as we need to register the dtor if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor); } cdata->handle.MarkIndependent(); #else if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, SWIGV8_Proxy_DefaultDtor); } #if (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); #else cdata->handle.MarkIndependent(); #endif #endif } int SWIG_V8_ConvertPtr(v8::Handle valRef, void** ptr, swig_type_info *info, int flags) { v8::HandleScope scope; /* special case: JavaScript null => C NULL pointer */ if(valRef->IsNull()) { *ptr=0; return SWIG_OK; } if(!valRef->IsObject()) { return SWIG_TypeError; } v8::Handle objRef = valRef->ToObject(); return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags); } v8::Handle SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) { v8::HandleScope scope; v8::Handle class_templ; if (ptr == NULL) { return scope.Close(v8::Null()); } #if (SWIG_V8_VERSION < 0x031900) if(info->clientdata != 0) { class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ; } else { class_templ = SWIGV8_SWIGTYPE_Proxy_class_templ; } #else v8::Isolate *iso = v8::Isolate::GetCurrent(); if(info->clientdata != 0) { class_templ = v8::Handle::New(iso, ((SWIGV8_ClientData*) info->clientdata)->class_templ); } else { class_templ = v8::Handle::New(iso, SWIGV8_SWIGTYPE_Proxy_class_templ); } #endif v8::Handle result = class_templ->InstanceTemplate()->NewInstance(); SWIGV8_SetPrivateData(result, ptr, info, flags); return scope.Close(result); } #define SWIG_ConvertPtr(obj, ptr, info, flags) SWIG_V8_ConvertPtr(obj, ptr, info, flags) #define SWIG_NewPointerObj(ptr, info, flags) SWIG_V8_NewPointerObj(ptr, info, flags) #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_V8_ConvertInstancePtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_V8_NewPointerObj(thisvalue, type, flags) #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_V8_ConvertPtr(obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_V8_NewPointerObj(ptr, type, 0) #define SWIG_GetInstancePtr(obj, ptr) SWIG_V8_GetInstancePtr(obj, ptr) #if (SWIG_V8_VERSION < 0x031900) v8::Handle _SWIGV8_wrap_equals(const v8::Arguments &args) { #else void _SWIGV8_wrap_equals(const v8::FunctionCallbackInfo& args) { #endif v8::HandleScope scope; v8::Handle jsresult; void *arg1 = (void *) 0 ; void *arg2 = (void *) 0 ; bool result; int res1; int res2; if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for equals."); res1 = SWIG_GetInstancePtr(args.Holder(), &arg1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ERROR, "Could not get pointer from 'this' object for equals."); } res2 = SWIG_GetInstancePtr(args[0], &arg2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "equals" "', argument " "1"" of type '" "void *""'"); } result = (bool)(arg1 == arg2); jsresult = v8::Boolean::New(result); SWIGV8_RETURN(jsresult); goto fail; fail: SWIGV8_RETURN(v8::Undefined()); } #if (SWIG_V8_VERSION < 0x031900) v8::Handle _wrap_getCPtr(const v8::Arguments &args) { #else void _wrap_getCPtr(const v8::FunctionCallbackInfo& args) { #endif v8::HandleScope scope; v8::Handle jsresult; void *arg1 = (void *) 0 ; long result; int res1; res1 = SWIG_GetInstancePtr(args.Holder(), &arg1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getCPtr" "', argument " "1"" of type '" "void *""'"); } result = (long)arg1; jsresult = v8::Number::New(result); SWIGV8_RETURN(jsresult); goto fail; fail: SWIGV8_RETURN(v8::Undefined()); } /* --------------------------------------------------------------------------- * PackedData object * * ---------------------------------------------------------------------------*/ class SwigV8PackedData { public: SwigV8PackedData(void *data, size_t size, swig_type_info *type): data(data), size(size), type(type) {}; ~SwigV8PackedData() { }; void* data; size_t size; swig_type_info *type; v8::Persistent handle; }; SWIGRUNTIMEINLINE int SwigV8Packed_Check(v8::Handle valRef) { v8::HandleScope scope; v8::Handle objRef = valRef->ToObject(); if(objRef->InternalFieldCount() < 1) return false; v8::Handle flag = objRef->GetHiddenValue(v8::String::New("__swig__packed_data__")); return (flag->IsBoolean() && flag->BooleanValue()); } SWIGRUNTIME swig_type_info* SwigV8Packed_UnpackData(v8::Handle valRef, void *ptr, size_t size) { if (SwigV8Packed_Check(valRef)) { v8::HandleScope scope; SwigV8PackedData *sobj; v8::Handle objRef = valRef->ToObject(); #if (SWIG_V8_VERSION < 0x031900) v8::Handle cdataRef = objRef->GetInternalField(0); sobj = static_cast(v8::External::Unwrap(cdataRef)); #else sobj = static_cast(objRef->GetAlignedPointerFromInternalField(0)); #endif if (sobj == NULL || sobj->size != size) return 0; memcpy(ptr, sobj->data, size); return sobj->type; } else { return 0; } } SWIGRUNTIME int SWIGV8_ConvertPacked(v8::Handle valRef, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigV8Packed_UnpackData(valRef, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } #if (SWIG_V8_VERSION < 0x031900) void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter) { SwigV8PackedData *cdata = static_cast(parameter); #else void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SwigV8PackedData *cdata) { #endif delete cdata; #if (SWIG_V8_VERSION < 0x031900) object.Clear(); object.Dispose(); #elif (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); #else object->Dispose(); #endif } SWIGRUNTIME v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) { v8::HandleScope scope; SwigV8PackedData* cdata = new SwigV8PackedData(data, size, type); v8::Handle obj = v8::Object::New(); obj->SetHiddenValue(v8::String::New("__swig__packed_data__"), v8::Boolean::New(true)); #if (SWIG_V8_VERSION < 0x031900) obj->SetPointerInInternalField(0, cdata); cdata->handle = v8::Persistent::New(obj); #else obj->SetAlignedPointerInInternalField(0, cdata); cdata->handle.Reset(v8::Isolate::GetCurrent(), obj); #endif #if (SWIG_V8_VERSION < 0x031900) cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete); cdata->handle.MarkIndependent(); #else cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete); # if (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); # else cdata->handle.MarkIndependent(); # endif #endif return scope.Close(obj); } #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIGV8_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIGV8_NewPackedObj(ptr, sz, type) /* --------------------------------------------------------------------------- * Support for IN/OUTPUT typemaps (see Lib/typemaps/inoutlist.swg) * * ---------------------------------------------------------------------------*/ SWIGRUNTIME v8::Handle SWIGV8_AppendOutput(v8::Handle result, v8::Handle obj) { v8::HandleScope scope; if (result->IsUndefined()) { result = v8::Array::New(); } v8::Handle arr = v8::Handle::Cast(result); arr->Set(arr->Length(), obj); return scope.Close(arr); } swig-3.0.2/CHANGES.current0000664000175000017500000000150612343605122015021 0ustar williamwilliamBelow 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.2 (4 Jun 2014) =========================== 2014-06-02: v-for-vandal [Lua] Pull request #176: If class has no __eq implemented, then default __eq is generated. Default __eq compares actual pointers stored inside Lua userdata. 2014-06-02: vkalinin Fix #183 - %extend and unnamed nested structs 2014-05-28: kwwette Fix install failure when using an 'out of source' build using the shipped tarball - regression introduced in swig-3.0.1. 2014-05-24: kwwette [Octave] Remove deprecated -global/-noglobal command-line arguments *** POTENTIAL INCOMPATIBILITY *** swig-3.0.2/Doc/0000775000175000017500000000000012343605122013050 5ustar williamwilliamswig-3.0.2/Doc/README0000664000175000017500000000040012343605122013722 0ustar williamwilliamDoc/Manual - Latest version of the SWIG user manual Doc/Devel - Developer documentation concerning SWIG internals. (not necessarily up to date) Open the index.html file in each of these directories with a web browser. swig-3.0.2/Doc/Devel/0000775000175000017500000000000012343605122014107 5ustar williamwilliamswig-3.0.2/Doc/Devel/cmdopt.html0000664000175000017500000000433112343605122016264 0ustar williamwilliam SWIG Command Line Handling

SWIG Command Line Handling

David M. Beazley
dave-swig@dabeaz.com
December, 2006

Introduction

This document describes the functions related to the handling of command line options passed to SWIG. These functions are defined in the header file Source/Swig/swigopt.h. This API is considered to be stable.

Initialization

Upon SWIG startup, the following function is called:

void Swig_init_args(int argc, char **argv_)

Registers command line options with the SWIG core. This creates an internal array that is used by other functions to mark whether or not a particular command line option was used. This is ultimately used to issue error messages about unused or unknown command line options. This function is currently invoked in the SWIG main() function that is found in Source/Modules/swigmain.cxx.

Argument Marking

As command line options are processed by language modules, the following functions are used to mark the arguments as used:

void Swig_mark_arg(int n)

Mark argument number n as used.

int Swig_check_marked(int n)

Check to see if argument n has been marked. Returns 0 or 1.

Argument Checking

The following function is used to check all of the command line options after parsing. It looks at the marked list and issues an error message if any unconsumed arguments are found.

void Swig_check_options()

Checks all command line options to see if they have all been processed. If not, an error message is generated and execution terminates with a call to exit(). This function is currently invoked in Source/Modules/main.cxx just before SWIG starts any processing of input files.

Utility Function

void Swig_arg_error())

A generic function that issues an error message about being unable to parse command line options. SWIG is terminated by a call to exit(). swig-3.0.2/Doc/Devel/internals.html0000664000175000017500000011566012343605122017005 0ustar williamwilliam SWIG Internals

SWIG Internals Manual

(Note : This is a work in progress.)

Table of Contents

1. Introduction

This document details SWIG internals: architecture and sometimes implementation. The first few sections concentrate on data structures, interfaces, conventions and code shared by all language targets. Subsequent sections focus on a particular language.

The audience is assumed to be SWIG developers (who should also read the SWIG Engineering Manual before starting to code).

1.1 Directory Guide

Doc HTML documentation. If you find a documentation bug, please let us know.
Examples This subdir tree contains examples of using SWIG w/ different scripting languages, including makefiles. Typically, there are the "simple" and "class" examples, w/ some languages offering additional examples. See the README more index.html file in each directory for more info. [FIXME: Ref SWIG user manual.]
Lib These are the .i (interface) files that form the SWIG installed library. Language-specific files are in subdirectories (for example, guile/typemaps.i). Each language also has a .swg file implementing runtime type support for that language. The SWIG library is not versioned.
Misc Currently this subdir only contains file fileheader. See the Engineering Manual for more info.
Source The C and C++ source code for the swig executable is in this subdir tree.
DOH C library providing memory allocation, file access and generic containers.
Include Configuration .h files
CParse Parser (lex / yacc) files and support
Modules Language-specific callbacks that does actual code generation (each language has a .cxx and a .h file).
Preprocessor SWIG-specialized C/C++ preprocessor.
Swig This directory contains the ANSI C core of the system and contains generic functions related to types, file handling, scanning, and so forth.
Tools The mkdist.py script and other tools. Win This improperly-named (spit spit) subdir only has README.txt.

1.2 Overall Program Flow

Here is the general control flow and where under subdir Source to look for code:
  • Modules/swigmain.cxx:main() is the program entry point. It parses the language-specifying command-line option (for example, -java), creating a new language-specific wrapping object (each language is a C++ class derived from base class Language). This object and the command-line is passed to SWIG_main(), whose return value is the program exit value.
  • Modules/main.cxx:SWIG_main() is the "real" main. It initializes the preprocessor and typemap machinery, defines some preprocessor symbols, locates the SWIG library, processes common command-line options, and then calls the language-specific command-line parser. From here there are three paths: "help", "checkout" and everything else.
    • In "help" mode, clean up open files and exit.
    • In "checkout" mode, copy specified files from the SWIG library to the current directory. Errors cause error messages but no non-local exits.
    • Otherwise, do wrapping: determine output file name(s), define some preprocessor symbols and run the preprocessor, initialize the interface-definition parser, set up the typemap for handling new return strings, and finally do the language-specific parse (by calling the language object's parse() method), which creates output files by side-effect.
    Afterwards, remove temporary files, and clean up. If the command-line included -freeze, go into an infinite loop; otherwise return the error count.
  • The language-specific parse() (and all other language-specific code) lives in Modules/foo.{h,cxx} for language Foo. Typically, FOO::parse() calls FOO::headers() and then the global function yyparse(), which uses the callbacks registered by SWIG_main() above.

2. DOH

DOH is a collection of low-level objects such as strings, lists, and hash tables upon which the rest of SWIG is built. The name 'DOH' unofficially stands for "Dave's Object Hack", but it's also a good expletive to use when things don't work (as in "SWIG core dumped---DOH!").

2.1 Motivation and Background

The development of DOH is influenced heavily by the problems encountered during earlier attempts to create a C++ based version of SWIG2.0. In each of these attempts (over a 3 year period), the resulting system always ended up growing into a colossal nightmare of large inheritance hierarchies and dozens of specialized classes for different types of objects (functions, variables, constants, etc.). The end result was that the system was tremendously complicated, difficult to understand, difficult to maintain, and fairly inflexible in the grand scheme of things.

DOH takes a different approach to tackling the complexity problem. First, rather than going overboard with dozens of types and class definitions, DOH only defines a handful of simple yet very useful objects that are easy to remember. Second, DOH uses dynamic typing---one of the features that make scripting languages so useful and which make it possible to accomplish things with much less code. Finally, DOH utilizes a few coding tricks that allow it to perform a limited form of function overloading for certain C datatypes (more on that a little later).

The key point to using DOH is that instead of thinking about code in terms of highly specialized C data structures, just about everything ends up being represented in terms of a just a few datatypes. For example, structures are replaced by DOH hash tables whereas arrays are replaced by DOH lists. At first, this is probably a little strange to most C/C++ programmers, but in the long run in makes the system extremely flexible and highly extensible. Also, in terms of coding, many of the newly DOH-based subsystems are less than half the size (in lines of code) of the earlier C++ implementation.

2.2 Basic Types

The following built-in types are currently provided by DOH:
  • String. A string of characters with automatic memory management and high-level operations such as string replacement. In addition, strings support file I/O operations that make it possible to use them just about anyplace a file can be used.

  • List. A list of arbitrary DOH objects (of possibly mixed types).

  • Hash. A hash table that maps a set of string keys to a set of arbitrary DOH objects. The DOH version of an associative array for all of you Perl fans.

  • File. A DOH wrapper around the C FILE * structure. This is provided since other objects sometimes want to behave like files (strings for instance).

  • Void. A DOH wrapper around an arbitrary C pointer. This can be used if you want to place arbitrary C data structures in DOH lists and hash tables.
Due to dynamic typing, all of the objects in DOH are represented by pointers of type DOH *. Furthermore, all objects are completely opaque--that means that the only way to access the internals of an object is through a well-defined public API. For convenience, the following symbolic names are sometimes used to improve readability:
  • DOHString *. A String object.
  • DOHList *. A list object.
  • DOHHash *. A hash object.
  • DOHFile *. A file object.
  • DOHVoid *. A void object.
  • DOHString_or_char *. A DOH String object or a raw C "char *".
It should be stressed that all of these names are merely symbolic aliases to the type DOH * and that no compile-time type checking is performed (of course, a runtime error may occur if you screw up).

2.3 Creating, Copying, and Destroying Objects

The following functions can be used to create new DOH objects
  • NewString(DOHString_or_char *value)
    Create a new string object with contents initially set to value. value can be either a C string or a DOH string object.

  • NewStringf(char *fmt, ...)
    Create a new string object with contents initially set to a formatted string. Think of this as being sprintf() combined with an object constructor.

  • NewList()
    Create a new list object that is initially empty.

  • NewHash()
    Create a new hash object that is initially empty.

  • NewFile(DOHString_or_char *filename, char *mode)
    Open a file and return a file object. This is a wrapper around the C fopen() library call.

  • NewFileFromFile(FILE *f)
    Create a new file object given an already opened FILE * object.

  • NewVoid(void *obj, void (*del)(void *))
    Create a new DOH object that is a wrapper around an arbitrary C pointer. del is an optional destructor function that will be called when the object is destroyed.
Any object can be copied using the Copy() function. For example:
DOH *a, *b, *c, *d;
a = NewString("Hello World");
b = NewList();
c = Copy(a);         /* Copy the string a */
d = Copy(b);         /* Copy the list b */
Copies of lists and hash tables are shallow. That is, their contents are only copied by reference.

Objects can be deleted using the Delete() function. For example:

DOH *a = NewString("Hello World");
...
Delete(a);              /* Destroy a */
All objects are referenced counted and given a reference count of 1 when initially created. The Delete() function only destroys an object when the reference count reaches zero. When an object is placed in a list or hash table, its reference count is automatically increased. For example:
DOH *a, *b;
a = NewString("Hello World");
b = NewList();
Append(b,a);         /* Increases refcnt of a to 2 */
Delete(a);           /* Decreases refcnt of a to 1 */
Delete(b);           /* Destroys b, and destroys a */
Should it ever be necessary to manually increase the reference count of an object, the DohIncref() function can be used:
DOH *a = NewString("Hello");
DohIncref(a);

2.4 A Word About Mutability and Copying

All DOH objects are mutable regardless of their current reference count. For example, if you create a string and then create a 1000 references to it (in lists and hash tables), changes to the string will be reflected in all of the references. Therefore, if you need to make any kind of local change, you should first make a copy using the Copy() function. Caveat: when copying lists and hash tables, elements are copied by reference.

2.5 Strings

The DOH String type is perhaps the most flexible object. First, it supports a variety of string-oriented operations. Second, it supports many of the same operations as lists. Finally, strings provide file I/O operations that allow them to be used interchangeably with DOH file objects. [ TODO ]

2.6 Lists

Example usage of lists:

/* Create and populate */
List *list = NewList();
Append(list, NewString("listval1"));
Append(list, NewString("listval2"));
Append(list, NewString("listval3"));
Append(list, NewString("listval4"));
Append(list, NewString("listval5"));

/* Size */
Printf(stdout, "list len: %d\n", Len(list));

/* Delete */
Delitem(list, 3);

/* Replace */
Setitem(list, 0, NewString("newlistval1"));

/* Get */
String *item = Getitem(list,1);
if (item)
  Printf(stdout, "get: %s\n", item);
else
  Printf(stdout, "get: [non-existent]\n");

/* Iterate through the container */
int len = Len(list);
for (int i=0; i<len; i++) {
  String *item = Getitem(list,i);
  Printf(stdout, "list item: %s\n", item);
}

Resulting output:

hash len: 5
get: hashval2
hash item: hashval5 [h5]
hash item: hashval1 [h1]
hash item: hashval2 [h2]
hash item: hashval3 [h3]

2.7 Hash tables

Example usage of hash tables:

/* Create and populate */
Hash *hash = NewHash();
Setattr(hash, "h1", NewString("hashval1"));
Setattr(hash, "h2", NewString("hashval2"));
Setattr(hash, "h3", NewString("hashval3"));
Setattr(hash, "h4", NewString("hashval4"));
Setattr(hash, "h5", NewString("hashval5"));

/* Size */
Printf(stdout, "hash len: %d\n", Len(hash));

/* Delete */
Delattr(hash, "h4");

/* Get */
String *item = Getattr(hash, "h2");
if (item)
  Printf(stdout, "get: %s\n", item);
else
  Printf(stdout, "get: [non-existent]\n");

/* Iterate through the container */
Iterator it;
for (it = First(hash); it.key; it= Next(it))
  Printf(stdout, "hash item: %s [%s]\n", (it.item), (it.key));

Resulting output:

list len: 5
get: listval2
list item: newlistval1
list item: listval2
list item: listval3
list item: listval5

2.8 Files

[ TODO ]

2.9 Void objects

[ TODO ]

2.10 Utility functions

[ TODO ]

3. Types and Typemaps

The representation and manipulation of types is currently in the process of being reorganized and (hopefully) simplified. The following list describes the current set of functions that are used to manipulate datatypes.

  • SwigType_str(SwigType *t, char *name).
    This function produces the exact string representation of the datatype t. name is an optional parameter that specifies a declaration name. This is used when dealing with more complicated datatypes such as arrays and pointers to functions where the output might look something like "int (*name)(int, double)".

  • SwigType_lstr(SwigType *t, char *name).
    This function produces a string representation of a datatype that can be safely be assigned a value (i.e., can be used as the "lvalue" of an expression). To do this, qualifiers such as "const", arrays, and references are stripped away or converted into pointers. For example:
    Original Datatype              lstr()
    ------------------             --------
    const char *a                  char *a
    double a[20]                   double *a
    double a[20][30]               double *a
    double &a                      double *a
    
    The intent of the lstr() function is to produce local variables inside wrapper functions--all of which must be reassignable types since they are the targets of conversions from a scripting representation.

  • SwigType_rcaststr(SwigType *t, char *name).
    This function produces a string that casts a type produced by the lstr() function to the type produced by the str() function. You might view it as the inverse of lstr(). This function only produces output when it needs to (when str() and lstr() produce different results). Furthermore, an optional name can be supplied when the cast is to be applied to a specific name. Examples:
    Original Datatype             rcaststr()
    ------------------            ---------
    char *a                       
    const char *a                 (const char *) name
    double a[20]                  (double *) name
    double a[20][30]              (double (*)[30]) name
    double &a                     (double &) *name
    

  • SwigType_lcaststr(SwigType *t, char *name).
    This function produces a string that casts a type produced by the str() function to the type produced by the lstr() function. This function only produces output when it needs to (when str() and lstr() produce different results). Furthermore, an optional name can be supplied when the cast is to be applied to a specific name.
    Original Datatype             lcaststr()
    ------------------            ---------
    char *a                       
    const char *a                 (char *) name
    double a[20]                  (double *) name
    double a[20][30]              (double *) name
    double &a                     (double *) &name
    

  • SwigType_manglestr(SwigType *t).
    Produces a type-string that is used to identify this datatype in the target scripting language. Usually this string looks something like "_p_p_double" although the target language may redefine the output for its own purposes. Normally this function strips all qualifiers, references, and arrays---producing a mangled version of the type produced by the lstr() function.
The following example illustrates the intended use of the above functions when creating wrapper functions using shorthand pseudocode. Suppose you had a function like this:
int foo(int a, double b[20][30], const char *c, double &d);
Here's how a wrapper function would be generated using the type generation functions above:
wrapper_foo() {
   lstr("int","result")
   lstr("int","arg0")
   lstr("double [20][30]", "arg1")
   lstr("const char *", "arg2")
   lstr("double &", "arg3")
   ...
   get arguments
   ...
   result = (lcaststr("int"))  foo(rcaststr("int","arg0"),
                               rcaststr("double [20][30]","arg1"),
                               rcaststr("const char *", "arg2"),
                               rcaststr("double &", "arg3"))
   ...
}
Here's how it would look with the corresponding output filled in:
wrapper_foo() {
   int      result;
   int      arg0;
   double  *arg1;
   char    *arg2;
   double  *arg3;
   ...
   get arguments
   ...
   result = (int) foo(arg0,
                      (double (*)[30]) arg1,
                      (const char *) arg2,
                      (double &) *arg3);
   ...
}
Notes:
  • For convenience, the string generation functions return a "char *" that points to statically allocated memory living inside the type library. Therefore, it is never necessary (and it's an error) to free the pointer returned by the functions. Also, if you need to save the result, you should make a copy of it. However, with that said, it is probably worth nothing that these functions do cache the last 8 results. Therefore, it's fairly safe to make a handful of repeated calls without making any copies.
[TODO]

4. Parsing

[TODO]

5. The C/C++ Wrapping Layer

Added: Dave Beazley (July 22, 2000)

When SWIG generates wrappers, it tries to provide a mostly seamless integration with the original code. However, there are a number of problematic features of C/C++ programs that complicate this interface.

  • Passing and returning structures by value. When used, SWIG converts all pass-by-value functions into wrappers that pass by reference. For example:
    double dot_product(Vector a, Vector b);
    
    gets turned into a wrapper like this:
    double wrap_dot_product(Vector *a, Vector *b) {
         return dot_product(*a,*b);
    }
    
    Functions that return by value require a memory allocation to store the result. For example:
    Vector cross_product(Vector *a, Vector *b);
    
    become
    Vector *wrap_cross_product(Vector *a, Vector *b) {
       Vector *result = (Vector *) malloc(sizeof(Vector));
       *result = cross_product(a,b);
       return result;
    }
    
    Note: If C++ is being wrapped, the default copy constructor is used instead of malloc() to create a copy of the return result.

  • C++ references. C++ references are handled exactly the same as pass/return by value except that a memory allocation is not made for functions that return a reference.

  • Qualifiers such as "const" and "volatile". SWIG strips all qualifiers from the interface presented to the target language. Besides, what in the heck is "const" in Perl anyways?

  • Instance Methods. Method invocations are handled as a function call in which a pointer to the object (the "this" pointer) appears as the first argument. For example, in the following class:
    class Foo {
    public:
        double bar(double);
    };
    
    The "bar" method is wrapped by a function like this:
    double Foo_bar(Foo *self, double arg0) {
       return self->bar(arg0);
    }
    

  • Structure/class data members. Data members are handled by creating a pair of wrapper functions that set and get the value respectively. For example:
    struct Foo {
        int x;
    };
    
    gets wrapped as follows:
    int Foo_x_get(Foo *self) {
        return self->x;
    }
    int Foo_x_set(Foo *self, int value) {
        return (self->x = value);
    }
    

  • Constructors. Constructors for C/C++ data structures are wrapped by a function like this:
    Foo *new_Foo() {
        return new Foo;
    }
    
    Note: For C, new objects are created using the calloc() function.

  • Destructors. Destructors for C/C++ data structures are wrapper like this:
    void delete_Foo(Foo *self) {
        delete self;
    }
    
    Note: For C, objects are destroyed using free().
The creation of wrappers and various type transformations are handled by a collection of functions found in the file Source/Swig/cwrap.c.
  • char *Swig_clocal(DataType *t, char *name, char *value)
    This function creates a string containing the declaration of a local variable with type t, name name, and default value value. This local variable is stripped of all qualifiers and will be a pointer if the type is a reference or user defined type.

  • DataType *Swig_clocal_type(DataType *t)
    Returns a type object corresponding to the type string produced by the Swig_clocal() function.

  • char *Swig_clocal_deref(DataType *t, char *name)
    This function is the inverse of the clocal() function. Given a type and a name, it produces a string containing the code needed to cast/convert the type produced by Swig_clocal() back into its original type.

  • char *Swig_clocal_assign(DataType *t, char *name)
    Given a type and name, this produces a string containing the code (and an optional cast) needed to make an assignment from the real datatype to the local datatype produced by Swig_clocal(). Kind of the opposite of deref().

  • int Swig_cargs(Wrapper *w, ParmList *l)
    Given a wrapper function object and a list of parameters, this function declares a set of local variables for holding all of the parameter values (using Swig_clocal()). Returns the number of parameters. In addition, this function sets the local name of each parameter which can be retrieved using the Parm_Getlname() function.

  • void Swig_cresult(Wrapper *w, DataType *t, char *resultname, char *decl)
    Generates the code needed to set the result of a wrapper function and performs all of the needed memory allocations for ANSI C (if necessary). t is the type of the result, resultname is the name of the result variable, and decl is a string that contains the C code which produces the result.

  • void Swig_cppresult(Wrapper *w, DataType *t, char *resultname, char *decl)
    Generates the code needed to set the result of a wrapper function and performs all of the needed memory allocations for C++ (if necessary). t is the type of the result, resultname is the name of the result variable, and decl is a string that contains the C code which produces the result.

  • Wrapper *Swig_cfunction_wrapper(char *fname, DataType *rtype, ParmList *parms, char *code)
    Create a wrapper around a normal function declaration. fname is the name of the wrapper, rtype is the return type, parms are the function parameters, and code is a string containing the code in the function body.

  • Wrapper *Swig_cmethod_wrapper(char *classname, char *methodname, DataType *rtype, DataType *parms, char *code)

  • char *Swig_cfunction_call(char *name, ParmList *parms) This function produces a string containing the code needed to call a C function. The string that is produced contains all of the transformations needed to convert pass-by-value into pass-by-reference as well as handle C++ references. Produces a string like "name(arg0, arg1, ..., argn)".
Here is a short example showing how these functions could be used. Suppose you had a C function like this:
double dot_product(Vector a, Vector b);
Here's how you might write a really simple wrapper function
ParmList *l = ... parameter list of the function ...
DataType *t = ... return type of the function ...
char     *name = ... name of the function ...
Wrapper *w = NewWrapper();
Printf(w->def,"void wrap_%s() {\n", name);

/* Declare all of the local variables */
Swig_cargs(w, l);

/* Convert all of the arguments */
...

/* Make the function call and declare the result variable */
Swig_cresult(w,t,"result",Swig_cfunction(name,l));

/* Convert the result into whatever */
...

Printf(w->code,"}\n");
Wrapper_print(w,out);
The output of this would appear as follows:
void wrap_dot_product() {
    Vector *arg0;
    Vector *arg1;
    double  result;

    ...
    result = dot_product(*arg0, *arg1);
    ...
}
Notice that the Swig_cargs(), Swig_cresult(), and Swig_cfunction() functions have taken care of the type conversions for the Vector type automatically.

Notes:

  • The intent of these functions is to provide consistent handling of function parameters and return values so that language module writers don't have to worry about it too much.

  • These functions may be superseded by features in the new typemap system which provide hooks for specifying local variable declarations and argument conversions.

6. Symbol Naming Guidelines for Generated C/C++ Code

The C++ standard (ISO/IEC 14882:1998(E)) states:

17.4.3.1.2 Global names [lib.global.names]

1 Certain sets of names and function signatures are always reserved to the implementation:

    * Each name that contains a double underscore (__) or begins with an underscore followed 
      by an upper case letter (2.11) is reserved to the implementation for any use.
    * Each name that begins with an underscore is reserved to the implementation for use as 
      a name in the global namespace.165)

    165) Such names are also reserved in namespace ::std (17.4.3.1). [back to text] 

When generating code it is important not to generate symbols that might clash with the code being wrapped. It is tempting to flout the standard or just use a symbol which starts with a single underscore followed by a lowercase letter in order to avoid name clashes. However even these legal symbols can also clash with symbols being wrapped. The following guidelines should be used when generating code in order to meet the standard and make it highly unlikely that symbol clashes will occur:

For C++ code that doesn't attempt to mangle a symbol being wrapped (for example SWIG convenience functions):

  • Put symbols in the Swig namespace, for example class Swig::Director. Qualify using the Swig namespace whenever the symbol is referenced, even within the Swig namespace, for example new Swig::Director() not new Director().
  • Use swig_ as a prefix for all member variables and member functions that are involved in an inheritance chain with wrapped classes, for example Swig::Director::swig_get_up() and bool Swig::Director::swig_up.
  • Alternatively class names can be prefixed with Swig in the global namespace for example template<class T> class SwigValueWrapper.

For code compiled as C or C++ that doesn't attempt to mangle a symbol being wrapped (for example SWIG convenience functions):

  • Use SWIG_ as a prefix for structures for example SWIG_JavaExceptions_t.
  • Use SWIG_ as a prefix for global functions for example SWIG_TypeRegister.
  • Use SWIG_ as a prefix for macros for example #define SWIG_PY_INT 1
For code compiled as C or C++ that attempts to mangle a wrapped symbol:
  • Use SWIGxxx or Swigxxx as a prefix where xxx is chosen which would make SWIGxxx/Swigxxx a unique symbol in the global namespace, for example class SwigDirectorFoo when wrapping class Foo. Don't use a trailing underscore for the prefix as this may generate a double underscore when wrapping a symbol which starts with a single underscore.
In the past SWIG has generated many symbols which flout the standard especially double underscores. In fact they may not all be rooted out yet, so please fix them when you see them.

7. Debugging SWIG

The DOH types used in the SWIG source code are all typedefined to void. Consequently, it is impossible for debuggers to automatically extract any information about DOH objects. The easiest approach to debugging and viewing the contents of DOH objects is to make a call into one of the family of SWIG print functions from the debugger. The "Debugging Functions" section in SWIG Parse Tree Handling lists them. It is sometimes easier to debug by placing a few calls to these functions in code of interest and recompile, especially if your debugger cannot easily make calls into functions within a debugged binary.

The SWIG distribution comes with some additional support for the gdb debugger in the Tools/swig.gdb file. Follow the instructions in this file for 'installing'. This support file provides an easy way to call into some of the family of SWIG print functions via additional user-defined gdb commands. Some usage of the swigprint and locswigprint user-defined commands are demonstrated below.

More often than not, a parse tree node needs to be examined. The session below displays the node n in one of the Java language module wrapper functions. The swigprint method is used to show the symbol name (symname - a DOH String type) and the node (n - a DOH Hash type).

Breakpoint 1, JAVA::functionWrapper (this=0x97ea5f0, n=0xb7d2afc8) at Modules/java.cxx:799
799	    String *symname = Getattr(n, "sym:name");
(gdb) next
800	    SwigType *t = Getattr(n, "type");
(gdb) swigprint symname
Shape_x_set
(gdb) swigprint n
Hash(0xb7d2afc8) {
  'membervariableHandler:view' : variableHandler, 
  'feature:except' : 0, 
  'name' : x, 
  'ismember' : 1, 
  'sym:symtab' : Hash(0xb7d2aca8) {......}, 
  'nodeType' : cdecl, 
  'nextSibling' : Hash(0xb7d2af98) {.............}, 
  'kind' : variable, 
  'variableHandler:feature:immutable' : <Object 'VoidObj' at 0xb7cfa008>, 
  'sym:name' : Shape_x_set, 
  'view' : membervariableHandler, 
  'membervariableHandler:sym:name' : x, 
  'membervariableHandler:type' : double, 
  'membervariableHandler:parms' : <Object 'VoidObj' at 0xb7cfa008>, 
  'parentNode' : Hash(0xb7d2abc8) {..............................}, 
  'feature:java:enum' : typesafe, 
  'access' : public, 
  'parms' : Hash(0xb7cb9408) {......}, 
  'wrap:action' : if (arg1) (arg1)->x = arg2;, 
  'type' : void, 
  'memberset' : 1, 
  'sym:overname' : __SWIG_0, 
  'membervariableHandler:name' : x, 
}

Note that all the attributes in the Hash are shown, including the 'sym:name' attribute which was assigned to the symname variable.

Hash types can be shown either expanded or collapsed. When a Hash is shown expanded, all the attributes are displayed along with their values, otherwise a '.' replaces each attribute when collapsed. Therefore a count of the dots provides the number of attributes within an unexpanded Hash. Below shows the 'parms' Hash being displayed with the default Hash expansion of 1, then with 2 provided as the second argument to swigprint to expand to two Hash levels in order to view the contents of the collapsed 'nextSibling' Hash.

(gdb) swigprint 0xb7cb9408
Hash(0xb7cb9408) {
  'name' : self, 
  'type' : p.Shape, 
  'self' : 1, 
  'nextSibling' : Hash(0xb7cb9498) {...}, 
  'hidden' : 1, 
  'nodeType' : parm, 
}
(gdb) swigprint 0xb7cb9408 2
Hash(0xb7cb9408) {
  'name' : self, 
  'type' : p.Shape, 
  'self' : 1, 
  'nextSibling' : Hash(0xb7cb9498) {
    'name' : x, 
    'type' : double, 
    'nodeType' : parm, 
  }, 
  'hidden' : 1, 
  'nodeType' : parm, 
}

The same Hash can also be displayed with file and line location information via the locswigprint command.

(gdb) locswigprint 0xb7cb9408
example.h:11: [Hash(0xb7cb9408) {
Hash(0xb7cb9408) {
  'name' : self, 
  'type' : p.Shape, 
  'self' : 1, 
  'nextSibling' : Hash(0xb7cb9498) {...}, 
  'hidden' : 1, 
  'nodeType' : parm, 
}]

Tip: Commands in gdb can be shortened with whatever makes them unique and can be command completed with the tab key. Thus swigprint can usually be shortened to sw and locswigprint to loc. The help for each command can also be obtained within the debugging session, for example, 'help swigprint'.

The sub-section below gives pointers for debugging DOH objects using casts and provides an insight into why it can be hard to debug SWIG without the family of print functions.

7.1 Debugging DOH Types The Hard Way

The DOH types used in SWIG are all typedefined to void and hence the lack of type information for inspecting types within a debugger. Most debuggers will however be able to display useful variable information when an object is cast to the appropriate type. Getting at the underlying C string within DOH types is cumbersome, but possible with appropriate casts. The casts below can be used in a debugger windows, but be sure to compile with compiler optimisations turned off before attempting the casts else they are unlikely to work. Even displaying the underlying string in a String * doesn't work straight off in all debuggers due to the multiple definitions of String as a struct and a void.

Below are a list of common SWIG types. With each is the cast that can be used in the debugger to extract the underlying type information and the underlying char * string.

  • String *s;
  • (struct String *)((DohBase *)s)->data
    The underlying char * string can be displayed with
    (*(struct String *)(((DohBase *)s)->data)).str

  • SwigType *t;
  • (struct String *)((DohBase *)t)->data
    The underlying char * string can be displayed with
    (*(struct String *)(((DohBase *)t)->data)).str

  • const_String_or_char_ptr sc;
  • Either
    (*(struct String *)(((DohBase *)sc)->data)).str
    or
    (char *)sc
    will work depending on whether the underlying type is really a String * or char *.

7.2 Debugging DOH memory allocation problems

The DOH objects are reference counted and use pools for memory allocation. The implementation is in memory.c. When there are memory corruption problems, various memory allocator tools are normally used to diagnose problems. These can be used on SWIG and can be very useful. However, they won't necessarily find use of stale DOH objects, that is, DOH objects that are used after they have been deleted. This is because the DOH memory allocator grabs a chunk of memory from the C memory allocator and manages the usage internally. Stale DOH object usage can be checked for by defining DOH_DEBUG_MEMORY_POOLS in memory.c. If an attempt to use an object is made after the reference count is zero, an assertion is triggered instead of quietly re-using the stale object...

swig: DOH/memory.c:91: DohCheck: Assertion `!DOH_object_already_deleted' failed.

This can be memory intensive as previously used memory in the pool is not re-used so is only recommended for diagnosing memory corruption problems.


Copyright (C) 1999-2010 SWIG Development Team. swig-3.0.2/Doc/Devel/wrapobj.html0000664000175000017500000001663112343605122016450 0ustar williamwilliam Wrapper Objects

Wrapper Objects

David M. Beazley
dave-swig@dabeaz.com
January 15, 2007

Introduction

This document describes the functions related to management of wrapper objects. A wrapper object is a low-level data structure used to contain the C/C++ code that is emitted during the wrapping process. It contains not only the emitted code, but information about local variables. These objects are a critical component of almost all SWIG target language modules.

The functions described here are declared in Source/Swig/swigwrap.h. This API is considered to be stable.

Creating and Destroying Wrappers

The following functions create and destroy wrapper objects.

Wrapper *NewWrapper()

Creates a new wrapper object.

void DelWrapper(Wrapper *w)

Destroys a wrapper object.

Wrapper Objects

The Wrapper object returned by NewWrapper() has three public attributes.
typedef struct Wrapper {
    String *def;
    String *locals;
    String *code;
} Wrapper;
The def attribute is a string that holds the function definition line. This line declares the function name, return type, and parameters. Language modules create this declaration by simply printing the appropriate text into this attribute.

The locals attribute is a string that holds the code related to any local variables declaration. Normally, language modules do not emit code to this string directly. They use Wrapper_add_local() or Wrapper_new_local() to do this.

The code attribute is a string that holds code related to the body of the function. Almost all code emitted by SWIG language modules is printed into this attribute.

Creating Local Variables

Perhaps the most useful aspect of Wrapper objects is the management of local variables. When creating a wrapper, it is often necessary to emit local variables related to the API of the target language. In addition to this, typemaps and other aspects of SWIG rely upon their own local variables. The following functions are used to create local variables, but also provide support for renaming variables in order to avoid name clashes.

int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl)

Adds a new local variable to the wrapper object. name is the name of the local variable. decl is a string containing the actual variable declaration code. For example, if you wanted to declare a variable "int x = 42;", you would set name to "x" and decl to "int x = 42;". On success, the text in decl is added to the locals attribute of w and 0 is returned. -1 is returned if a variable with the given name has already been declared.

int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...)

The same as Wrapper_add_local() except that instead of passing a single string for the declaration, a NULL-terminated list of strings can be passed. These strings are joined together when producing the output. This convention turns out to be fairly useful since language modules often create their output into pieces.

char * Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl)

The same as Wrapper_add_local() except that if a local variable with the given name already exists, this function picks a new name and adds the declaration using the new name. The actual name used for the variable is returned. This function is used when generating code originating from typemaps. For instance, if a typemap declares a local variable, that variable might have to be renamed if the same typemap is used more than once in the same function.

char * Wrapper_new_localv(Wrapper *w, const String_or_char *name,...)

The same as Wrapper_new_localv(), but accepts a NULL-terminated list of strings as code output.

int Wrapper_check_local(Wrapper *w, const String_or_char *name)

Checks to see if a local variable with name name has been declared. Returns 1 if the local is defined, 0 otherwise.

Output

void Wrapper_print(Wrapper *w, File *f)

This function is used to format a wrapper function for output. The formatted wrapper function is emitted to f which may be any file-like object including a FILE * object or a String * object. When emitting the wrapper, the code printed to the wrapper object is automatically formatted. By default, the formatting is done according to a "pretty printing" style in which lines are split onto multiple lines and indented according to reasonable C formatting rules. This produces code that is moderately readable should you want to look at the wrapper code output. An alternative output mode is "compact printing" in which lines are collected and compacted. This may result in multiple C statements appearing on the same line. This mode is sometimes used when the size of a wrapper file is too large for certain compilers. For example, some compilers might impose a limit of 65536 lines per source file.

void Wrapper_compact_print_mode_set(int flag)

Sets the output mode of the Wrapper_print() function. If flag is set to 1, then wrapper code is formatted to be compact.

void Wrapper_pretty_print(String *str, File *f)

Utility function that reformats a string containing C/C++ code and outputs it to the file-like object f. The formatting process indents the code and structures it according to reasonable C formatting rules.

void Wrapper_compact_print(String *str, File *f)

Utility function that reformats a string containing C/C++ code and outputs it to the file-like object f. The formatting process tries to make the code as compact as possible, without going completely overboard. For example, multiple C statements may be combined onto a single line and braces may be aligned to not use up extra lines.

An Example

Here is a simple example of how these functions are used. Suppose you wanted to emit the following C function:
void foo(int n) {
   int i;
   for (i = 0; i < n; i++) {
       printf("%d\n", i);
   }
}
Here is code that generates the above function:
Wrapper *w = NewWrapper();
Printf(w->def,"void foo(int n) {");
Wrapper_add_local(w,"n","");         /* parameter n */
Wrapper_add_local(w,"i", "int i;");  /* local i */
Printv(w->code,"for (i = 0; i < n; i++) {",
               "printf(\"%d\n",i);",
               "}\n", NIL);
Printf(w->code,"}\n");

/* Emit wrapper code */
Wrapper_print(w,outf);
DelWrapper(w);
Within different language modules, this process is obviously much more involved. However, this example shows the basic idea of how C/C++ code is prepared for output. swig-3.0.2/Doc/Devel/migrate.txt0000664000175000017500000001122712343605122016303 0ustar williamwilliamSWIG1.3 Migration Guide (The not entirely complete guide to updating language modules to work with SWIG1.3). Dave Beazley August 15, 2000 1. Introduction --------------- Virtually all of SWIG's internal data structures have now been rewritten. Take everything you thought you knew about SWIG1.1 and throw it out. 2. DataTypes ------------ The old 'DataType' data structure is gone. Therefore, direct manipulation of 'is_pointer', 'implicit_ptr', and 'arraystr' attributes no longer applies. Sorry. Datatypes are now represented by the type 'SwigType' which has no public attributes. Actually, if you look at it closely, 'SwigType' is really just an alias for 'void' and if you look at it even closer than that you will realize that it's nothing more than a string! The string encoding of types is described in more detail in the file Source/Swig/stype.c and is not so important here. What is important is the functions used to produce various types of output: SwigType_str(type,name = 0); This produces an exact C representation of the datatype with all qualifiers, arrays, references, and so forth. name is an optional name that is given if you wanted to associate the type with a parameter name or something. SwigType_lstr(type,name = 0); This function takes a type and produces a C string containing a type suitable for assignment (appearing as an lvalue in an expression). To do this, certain things such as 'const', arrays, and references are stripped away or converted into pointers. SwigType_ltype(type); Returns a SwigType object corresponding to the type created by SwigType_lstr(). SwigType_lcaststr(type,name); Produces a string casting a value 'name' from the real datatype to the assignable type created by SwigType_lstr(). SwigType_rcaststr(type,name) Produces a string that casts a value 'name' from the type created by SwigType_lstr() to the real datatype. SwigType_manglestr(type) Produces the 'mangled' version of a datatype. Getting the 'type' code. Most language modules still operate by looking at special integer type codes. This interface is a little ragged and will probably go away at some point. However, for now the following function can be used to get the type code: int SwigType_type(type) The codes are the same as the before, except that there are a few special codes: T_STRING - The 'char *' type and variations. T_POINTER - Any pointer type (not char * though) T_REFERENCE - Any C++ reference T_ARRAY - Any array T_FUNCTION - A function (this is usually an error). Because of the special codes, it is no longer necessary to have code like this: if ((t->is_pointer == 1) and (t->type == T_CHAR)) { ... get a string ... } Instead, just use the type code above like this: switch(SwigType_type(type)) { case T_STRING: ... get a string ... break; case T_POINTER: ... get a pointer ... break; } There are about 2-dozen type manipulation functions that could also be useful. See Source/Swig/swig.h and Source/Swig/stype.c. 3. Parameter Lists ------------------ The ParmList data structure is gone. In reality, parameter lists are nothing more than a linked list of parameters. The proper way to iterate over this list and get parameter values is as follows: ParmList *l; Parm *p; for (p = l; p; p = Getnext(p)) { SwigType *pt = Gettype(p); /* Get parameter type */ String *pn = Getname(p); /* Get parameter name */ String *value = Getvalue(p); /* Get parameter value */ ... do whatever ... } 4. Typemaps ----------- Typemaps more or less work. However, the interface has changed slightly. Instead of typemap_lookup("in","python",type,pname,"$source","$target",wrapper); the function is Swig_typemap_lookup("in",type,pname,"$source","$target",wrapper); There are a variety of other changes to typemaps (see CHANGES). 5. Use of new types ------------------- When possible, language modules should try to use the built in String, List, and Hash objects instead of C arrays or 'char *'. This will probably require a detailed pass through the code with an eye towards cleanup. 6. Miscellaneous ---------------- Language modules no longer need to concern themselves with formatting the wrapper code they produce (provided you are using the special Wrapper object). The function Wrapper_print() passes everything through a pretty-printer that automatically performs indentation and tries to clean things up. This especially works well when there are lots of typemaps. swig-3.0.2/Doc/Devel/engineering.html0000664000175000017500000003146712343605122017302 0ustar williamwilliam SWIG Engineering Manual

SWIG Engineering Manual

David Beazley

(Note : This is a work in progress.)

Table of Contents

1. Introduction

The purpose of this document is to describe various coding conventions and organizational aspects for SWIG developers. The idea for this document is largely borrowed from John Ousterhout's Tcl/Tk Engineering Manual. It is not my intent to overly managerial about matters--rather I'm hoping to make life a little less chaotic for everyone.

First a little background: SWIG was started in 1995 as a one-person project and continued in this mode of operation until about 1998. Most of this development was driven by ideas submitted by early SWIG users as opposed to being motivated by a grand design. As a result, the code ended up being a pretty horrible C++ coding disaster. A mostly working disaster perhaps, but a disaster nonetheless.

With that said, the primary goal of future SWIG development is to reengineer the original system, fix most of its inherent design flaws, and to produce what I hope will become a highly extensible and modular interface compiler framework. To this do this, there are a few critical areas of work. First, I want to restructure SWIG as a collection of loosely coupled modules written in either ANSI C or an scripting language. Second, I want the system to be minimalistic in its use of data structures and interconnections. The primary reason for this is that the fewer data structures there are, the less users will have to remember. This will also make the system more accessible to non-experts. Finally, I want to reevaluate the whole idea of a SWIG module is and expand the definition to include just about anything from parsers, preprocessors, optimizers, interface editors, and code generators.

The rest of this document outlines a few general rules of how code should be developed within the SWIG project. These rules are primarily drawn from my own experience developing software and observing the practices of other successful projects.

2. Programming Languages and Libraries

All SWIG modules must be written in either ANSI C or one of the scripting languages for which SWIG can generate an interface (e.g., Perl, Python, or Tcl). C++ is currently being used to write SWIG modules, but it is only being utilized to avoid working with a lot of pointers to functions. Advanced C++ features like namespaces, templates, and overloading should not be used..

Module writers should make every attempt to use only those functions described in the POSIX.1 standard. This includes most of the functions contained the Kernighan and Ritchie C programming book. Use of operating system dependent functionality such as socket libraries should always be included inside a conditional compilation block so that it can be omitted on problematic platforms. If you are unsure about a library call, check the man page or contact Dave.

3. The Source Directory and Module Names

All SWIG modules are contained within the "Source" directory. Within this directory, each module is placed into its own subdirectory. The name of this subdirectory should exactly match the name of the module. For example, if you are creating a module called "Tcl", all of your files should be placed in a directory "Tcl".

When choosing a module name, please pick a name that is not currently in use. As a general convention, the first letter of a module name is capitalized such as "Perl". Alternatives such as "perl" or "PERL" should be avoided. In certain instances, the first two letters may be capitalized as in "CParse." The exact usage of this is somewhat inconsistent and isn't terribly important--just make sure the first letter is capitalized. Also, module names should not start with numbers, include underscores or any other special non-alphanumeric characters.

5. File Structure

Each file in a module should be given a filename that is all lowercase letters such as "parser.c", not "Parser.c" or "PARSER.c". Please note that filenames are case-insensitive on Windows so this convention will prevent you from inadvertently creating two files that differ in case-only.

Each file should include a short abstract and license information like this:

/* -----------------------------------------------------------------------------
 * This file is part of SWIG, which is licensed as a whole under version 3 
 * (or any later version) of the GNU General Public License. Some additional
 * terms also apply to certain portions of SWIG. The full details of the SWIG
 * license and copyrights can be found in the LICENSE and COPYRIGHT files
 * included with the SWIG source code as distributed by the SWIG developers
 * and at http://www.swig.org/legal.html.
 *
 * xxx.c
 *
 * This file defines ...
 * ----------------------------------------------------------------------------- */

#include "swig.h"

/* Declarations */
typedef struct {
   int x, y;
} Foo;

...

/* Private Declarations (used only in this file) */
static int  avariable;

...

/* Functions */
... 

As a general rule, files start to get unmanageable once they exceed about 2000 lines. Files larger than this should be broken up into multiple files. Similarly, you should avoid the temptation to create many small files as this increases compilation time and makes the directory structure too complicated.

6. Bottom-Up Design

Within each source file, the preferred organization is to use what is known as "bottom-up" design. Under this scheme, lower-level functions appear first and the highest level function appears last. The easy way to remember is that the "main" function of your module should always appear last in the source file. For example:
/* Simple bottom-up program */
#include <stdio.h>

int foo(int x, int y) {
    /* Implement foo */
    ...
}

int bar() {
    ...
    foo(i,j);
    ...
}

...
int main(int argc, char **argv) {
    ...
    bar();   
    ...
}
This choice of design is somewhat arbitrary however it has a number of benefits particular to C. In particular, a bottom-up design generally eliminates the need to include forward references--resulting in cleaner code and fewer compilation errors.

7. Functions

All functions should have a function header that gives the function name and a short description like this:
/* -------------------------------------------------------------------------
 * Swig_add_directory()
 *
 * Adds a directory to the SWIG search path.
 * ------------------------------------------------------------------------- */

void 
Swig_add_directory(DOH *dirname) {
...

}
In the function declaration, the return type and any specifiers (extern or static) should appear on a separate line followed by the function name and arguments as shown above. The left curly brace should appear on the same line as the function name.

Function declarations should NOT use the pre-ANSI function declaration syntax. The ANSI standard has been around long enough for this to be a non-issue.

8. Naming Conventions

The following conventions are used to name various objects throughout SWIG.

Functions

Functions should consist of the module name and the function name separated by an underscore like this:
Preprocessor_define()
Swig_add_directory()
In general, the module name should match the name of the module subdirectory and the function name should be in all lowercase with words separated by underscores.

Structures and Types

If your module defines new structures, the structure name should include the name of the module and the name of the structure appended together like this:
typedef struct SwigScanner {
   ...
} SwigScanner;

typedef struct LParseType {
   ...
} LParseType;
In this case, both the name of the module and the type should be capitalized. Also, whenever possible, you should use the "typedef struct Name { ... } Name" form when defining new data structures.

Global Variables

Global variables should be avoided if at all possible. However, if you must use a global variable, please prepend the module name and use the same naming scheme as for functions.

Constants

Constants should be created using #define and should be in all caps like this:
#define   SWIG_TOKEN_LPAREN  1
Separate words in a constant should be separated by underscores as with functions.

Structure members

Structure members should be in all lower-case and follow the same word-separation convention as for function names. However, the module name does not have to be included. For example:
typedef struct SwigScanner {
  DOH           *text;           /* Current token value */
  DOH           *scanobjs;       /* Objects being scanned */
  DOH           *str;            /* Current object being scanned */
  char          *idstart;        /* Optional identifier start characters */
  int            next_token;     /* Next token to be returned */
  int            start_line;     /* Starting line of certain declarations */
  int            yylen;          /* Length of text pushed into text */
  DOH           *file;           /* Current file name */
} SwigScanner;

Static Functions and Variables

Static declarations are free to use any naming convention that is appropriate. However, most existing parts of SWIG use lower-case names and follow the same convention as described for functions.

9. Visibility

Modules should keep the following rules in mind when exposing their internals:
  • Only publicly accessible functions should be included in the module header file.
  • All non-static declarations must be prepended with some form of the module name to avoid potential linker namespace conflicts with other modules.
  • Modules should not expose global variables or use global variables in their public interface.
  • Similarly, modules should discourage the direct manipulation of data contained within data structures in favor of using function calls instead. For example, instead of providing a user with a structure like this:
    typedef struct Foo {
       int line;
    } Foo;
    
    It is better to hide the implementation of Foo and provide an function-call interface like this:
    typedef struct Foo Foo;
    extern int  Foo_getline(Foo *f);
    extern void Foo_setline(Foo *f, int line);
    
    Although this results in worse performance, there are many practical reasons for doing this. The most important reason is that it allows you to change the internal representation of Foo without breaking all of the other modules or having to recompile the entire universe after making your changes.

10. Miscellaneous Coding Guidelines

These are largely covered in the main documentation in the Extending.html file.

11. Git Tagging Conventions

Use git tag to declare some set of file revisions as related in some symbolic way. This eases reference, retrieval and manipulation of these files later. At the moment (2001/01/16 14:02:53), the conventions are very simple; let's hope they stay that way!

There are two types of tags, internal (aka personal) and external. Internal tags are used by SWIG developers primarily, whereas external tags are used when communicating with people w/ anonymous git access.

  • Internal tags should start with the developer name and a hyphen.
  • External tags should start with "rel-".
That's all there is to it. Some example tags:
  • ttn-pre-xml-patch
  • ttn-post-xml-patch
  • ttn-going-on-vacation-so-dutifully-tagging-now
  • rel-1.3.40
  • rel-2.0.9

Copyright (C) 1999-2004 SWIG Development Team. swig-3.0.2/Doc/Devel/tree.html0000664000175000017500000002176112343605122015743 0ustar williamwilliam SWIG Parse Tree Handling

SWIG Parse Tree Handling

Introduction

This document describes the functions related to the handling of parse trees in SWIG. The structure of SWIG parse trees has been influenced heavily by ideas from XML-DOM trees. In fact, the functions in the API and attribute names are nearly identical. The header file Source/swig/swigtree.h contains the functions and macros described in this document. This API is considered to be stable.

Parse tree navigation

The following macros are used to navigate the parse tree.

nodeType(n)

Returns the type of a node as a String object. The type is stored in the "nodeType" attribute of n.

parentNode(n)

Returns the parent of a node. This is found in the "parentNode" attribute of n.

previousSibling(n)

Returns the previous sibling of a node (if any). This is found in the "previousSibling" attribute of n.

nextSibling(n)

Returns the next sibling of a node (if any). This is found in the "nextSibling" attribute of n.

firstChild(n)

Returns the first child of a node (if any). This is found in the "firstChild" attribute of n.

lastChild(n)

Returns the last child of a node (if any). This is found in the "lastChild" attribute of n.

Parse Tree Construction

The following macros are used to construct parse trees.

set_nodeType(n, val)

Sets the nodeType attribute of n. val is a string containing the type.

set_parentNode(n, parent)

Sets the parent of node n.

set_previousSibling(n, prev)

Sets the previous sibling of node n.

set_nextSibling(n, next)

Sets the next sibling of node n.

set_firstChild(n, chd)

Sets the first child of node n.

set_lastChild(n, chd)

Sets the last child of node n.

Tree Management Functions

The following functions are used to help with the management and construction of parse trees.

void appendChild(Node *node, Node *child)

Adds a new child to node. This function takes care of adjusting the "firstChild" and "lastChild" attributes of node to appropriate values. After calling this function, the "lastChild" attribute will point to child.

void prependChild(Node *node, Node *child)

Prepends a new child to node. The new child is added so that it becomes the first child of node.

void removeNode(Node *node)

Removes a node from the parse tree. The removal process detaches a node from its parent by removing it from the parent's child list. Upon return, node will have no parent and no siblings. This function does NOT delete node or modify children of node. If desired, node could be reattached to a different part of the parse tree.

Node *copyNode(Node *node)

Copies a node, but only copies those attributes that are simple strings. Thus, the new node will not contain any references to other nodes, lists, hashes, or other complex data structures. This function may be useful if you want to copy the data contents of a node in the process of creating a new parse tree node.

Attribute Checking

The following utility is provided since this is an extremely common operation.

int checkAttribute(Node *n, const String_or_char *name, const String_or_char *value)

This function checks to see whether node n has a given attribute name and that the attribute has a given value. Returns 0 or 1.

Node Transformation

In the course of processing, SWIG often applies a transform to a node. This transformation process made modify many of the attributes--even changing the type of a node. The following functions are used to help manage this transformation process. In addition to provide sanity checks, they save the old contents of the node so that they can be restored later.

void Swig_save(const char *namespace, Node *n, ...)

This function takes a node and a list of attribute names and saves their contents in a specified namespace. For example, the call
Swig_save("temp",n,"type","parms","name",NIL)
takes the attributes "type","parms", and "name" and saves their contents under the attribute names "temp:type","temp:parms","temp:name". In addition, this function sets an attribute "view" to hold the name of the current namespace. In this example, the "view" attribute would be set to "temp". The attribute names specified are all optional. If one or more of the attributes don't exist, this function merely records that those attributes did not exist in the original node.

void Swig_require(const char *namespace, Node *n, ...)

This function is similar to Swig_save() except that adds additional attribute checking. There are different interpretations of the attribute names. A name of "attr" merely requests that the function check for the presence of an attribute. If the attribute is missing, SWIG will exit with a failed assertion. An attribute name of "?attr" specifies that the attribute "attr" is optional and that its old value must be saved (if any). An attribute name of "*attr" specifies that the attribute is required and that its value must be saved. The saving of attributes is performed in the same manner as with Swig_save(). Here is an example:
Swig_require("temp",n,"type","*name","?parms",NIL);

void Swig_restore(Node *n)

This function restores a node to the state it was in prior to the last Swig_save() or Swig_require() call. This is used to undo node transformations.

Debugging Functions

The following functions can be used to help debug any SWIG DOH object.

void Swig_print(DOH *object, int count = -1)
Prints to stdout a string representation of any DOH type. The number of nested Hash types to expand is set by count (default is 1 if count<0). See Swig_set_max_hash_expand() to change default.

void Swig_print_with_location(DOH *object, int count = -1)
Prints to stdout a string representation of any DOH type, within [] brackets for Hash and List types, prefixed by line and file information. The number of nested Hash types to expand is set by count (default is 1 if count<0). See Swig_set_max_hash_expand() to change default.

The following functions can be used to help debug SWIG parse trees.

void Swig_print_tags(Node *node, String_or_char *prefix)

Prints the tag-structure of the parse tree to standard output. node is the top-level parse tree node. prefix is a string prefix thats added to the start of each line. Normally, you would specify the empty string or NIL for prefix. This function is called by the -debug-tags option to SWIG.
% swig -debug-tags -python example.i
 . top (:1)
 . top . include (/Users/beazley/Projects/share/swig/1.3.31/swig.swg:0)
 . top . include . include (/Users/beazley/Projects/share/swig/1.3.31/swigwarnings.swg:0)
 . top . include . include . include (/Users/beazley/Projects/share/swig/1.3.31/swigwarn.swg:0)
...
...
 . top . include (example.i:0)
 . top . include . module (example.i:2)
 . top . include . insert (example.i:7)
 . top . include . cdecl (example.i:5)
 . top . include . cdecl (example.i:6)
Since many language modules include hundreds of typemaps and other information, the output of this can be significantly more complicated than you might expect.

void Swig_print_node(Node *node)

Prints the contents of a parse tree node, including all children, to standard output. The output includes all attributes and other details.

void Swig_print_tree(Node *node)

Prints the same output as Swig_print_node() except that it also processes all of the siblings of node. This can be used to dump the entire parse tree to standard output. The command line options -debug-module and -debug-top use this function to display the parse tree for a SWIG input file.
swig-3.0.2/Doc/Devel/parm.html0000664000175000017500000000507612343605122015744 0ustar williamwilliam SWIG Parameter Handling

SWIG Parameter Handling

David M. Beazley
dave-swig@dabeaz.com
January 9, 2007

Introduction

This document describes the functions related to management of function parameters and parameter lists in the SWIG core. These functions are declared in Source/Swig/swigparm.h. This API is considered to be stable.

Parameters

The following utility functions are used to create and copy individual parameters. In their most basic form, a parameter merely contains a type, a name, and an optional default value.

Parm *NewParm(SwigType *type, const String_or_char *name)

Creates a new parameter object with type type and name name. The type is stored in the attribute "type" and the name is stored in the attribute "name".

Parm *CopyParm(Parm *p)

Copies a parameter object. All string attributes are copied in the process of making the copy. However, no complex attributes (lists, hashes, etc.) are copied.

Parameter Lists

ParmList *CopyParmList(ParmList *p)

Creates a copy of a parameter list. A parameter list is merely a linked list of parameters created by NewParm().

ParmList *CopyParmListMax(ParmList *p, int count)

Copies at most count parameters from the parameter list p.

int ParmList_len(ParmList *p)

Returns the total number of parameters in a parameter list.

int ParmList_numrequired(ParmList *p)

Returns the number of required parameters in a parameter list. This pertains to invoking a function/method in C/C++.

int ParmList_has_defaultargs(ParmList *p)

Returns 1 if the parameter list has any default arguments. Otherwise returns 0.

Code Generation Functions

String *ParmList_str(ParmList *p)

Creates a C prototype string of the parameters, but without any default values.

String *ParmList_str_defaultargs(ParmList *p)

Creates a C prototype string of the parameters and includes the default values (if any).

String *ParmList_protostr(ParmList *p)

Creates a C prototype string of the parameters.
swig-3.0.2/Doc/Devel/index.html0000664000175000017500000000155412343605122016111 0ustar williamwilliam SWIG Documentation This directory contains SWIG documentation: The following documentation describe the internal APIs used by SWIG. These may be useful to module developers.
Copyright (C) 1999-2007 SWIG Development Team. swig-3.0.2/Doc/Devel/cpp11.html0000664000175000017500000010524212343605122015725 0ustar williamwilliam

C++0x/C++11 support for SWIG

Summary

This is a technical overview of the C++0x/C++11 support for the Swig. This area of Swig is a work in progress. Initial C++0x/C++11 support for Swig was written during the Google Summer of Code 2009 period by Matevž Jekovec.

SVN branch

branches/gsoc2009-matevz

New C++11 features status

Wikipedia article: http://en.wikipedia.org/wiki/C%2B%2B0x

Rvalue reference and move semantics [done]

The Rvalues are used in practice to speed up the move operations on different containers.

In the following example, we want to swap the given elements:

template <class T> swap(T& a, T& b) {
    T tmp(a);   // now we have two copies of a
    a = b;      // now we have two copies of b
    b = tmp;    // now we have two copies of tmp (aka a)
}

This can now be solved using the new function std::move():

template <class T> swap(T& a, T& b) {
    T tmp(std::move(a));
    a = std::move(b);   
    b = std::move(tmp);
}

For the move function to take effect, user needs to reimplement the move constructor (taking ClassType&& as an argument) and operator=(ClassType&&):

class MyClass {
  MyClass(MyClass&& p) : ptr(p.ptr) {p.ptr = 0;}
  MyClass& operator=(MyClass&& p) {
    std::swap(ptr, p.ptr);
    return *this;
  }
};

In practice, the Rvalues are used for temporaries (when passing the result of one function as an argument to another).

Done: Added type&& to Swig parser. Added testcase cpp11_rvalue_reference.i. Operator && is treated the same as operator &. R11450

Article: http://www.artima.com/cppsource/rvalue.html

Generalized constant expressions [done]

In C++11 you can define functions as constant expressions. Functions need to return constant value in form "return expr", where expr is a constant expression.

A keyword "constexpr" is introduced for this. eg.: constexpr int getNumber() { return 5; } const int MY_CONSTANT = getNumber();

Constants are treated as normal variables in interpreted languages because they are not compiled into the executable. Java "final" constants are defined runtime as well. C++ constants need to be declared in the header file and defined in the implementation file, so swig doesn't need to know about the constant values when parsing the header file.

Done: Added the “constexpr “ keyword to Swig. Added testcase cpp11_constexpr. R11322

Problem: No compilers were known to support constexpr yet, so the testcase was temporarily commented out in common.mk.

Extern template [done]

Extern template forces the GCC compiler to not instantiate the template in the translation unit at that time. It's a feature specifically aimed at compilers to speed up the compilation process.

Done: Added support for 'extern template class std::vector<MyClass>;'. Added testcase cpp11_template_explicit. R11385 , R11386

Initializer lists [done]

Initializer list is a new type in standard library: std::initializer_list<T>. New symbols {} are introduced for the initializer lists.

One can now use:

 class A {
 public:
   A( std::initializer_list<int> );
 };
 A a1 = {1,2,3,4};

Languages like Java, C# and Python already support direct creation of lists natively.

Problem: initializer_list cannot be treated as an ordinary list. The constructor containing initializer_list can only be accessed by assigning the value using the {} brackets. I also don't think there is a simple way to convert an ordinary list or a vector to the initializer_list.

Done: Ignored the constructor having initializer_list as its argument. Show warning to the user. Added testcase cpp11_initializer_list. R11450

Article: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1919.pdf

Uniform initialization [done]

The new C++11 standard will allow the following:

struct IdString {
  std::string name;
  int identifier;
};
 
IdString GetString() {
  return {"SomeName", 4}; //Note the lack of explicit type.
}

The feature works exactly as it did now for POD types only (eg. int a[] = {1,2,3};). The following declarations are the same in the new C++11:

IdString str1 = {„SomeName“, 4};
IdString str2{„SomeName“, 4};

The new way of using uniform initialization allows the following:

struct BasicStruct {
 int x;
 double y;
};
 
struct AltStruct {
  AltStruct(int x, double y) : x_{x}, y_{y} {}
 
private:
  int x_;
  double y_;
};
 
BasicStruct var1{5, 3.2}; // only fills the struct components
AltStruct var2{2, 4.3};   // calls the constructor

The new syntax is specific to C++. Java, C# and scripting languages do not support this behaviour, but always need constructors. They support {} brackets for declaration of arrays as C does + they add support for creation of arrays on-the-fly (what C++11 introduced with this feature and more).

Done: Added syntax for {} member initialization in class constructor. Added testcase cpp11_uniform_initialization. R11413

Type inference [partially done]

A new keyword 'auto' is introduced in C++11:

auto a1 = 100;
auto a2 = myFunc();

The type of a1 and a2 is automatically determined according to the initialization value during the semantic phase of the compiler.

Another macro 'decltype()' is introduced. The macro takes the concrete object as an argument and returns its type. User could use this as:

int i = 100;
decltype(i) j = 200; // decltype(i) = int

Calling operators are allowed as well:

decltype(i+j) k = 300;

Done: Added support for decltype() syntax. Test cases for normal decltype members and alternate function members work fine. Currently only syntax in form decltype(variable name) work. No support for custom expresions eg. decltype(i+j) yet. R11525

TODO: William proposed to support the hidden variables as well (ones not parsed by Swig and added to symbol table). This also allows Swig to parse custom expressions like decltype(i+j). The idea is to introduce a new SwigType for this.

Range-based for-loop [ignored]

This feature is always present inside the implementation block only.

Lambda functions and expressions [done]

C++11 introduces lambda functions defined as:

[](int x, int y) -> int { return x + y; }

If the lambda function contains a single return statement only or the function doesn't return any type, the return type '->' can be omitted. Lambda functions are function objects.

The following example prints the number of items stored in a list:

std::vector<int> someList;
int total = 0;
std::for_each( someList.begin(), someList.end(), [&total](int x) {total += x} );
std::cout << total;

Parameters inside the [] are the visible parameters of the lambda functions. These can be & (references), = (copies), variable name (variable copy), &variable name (variable reference) or this (copy of the current object).

Lambda functions can be stored using:

auto myLambdaFunc = [this]() { this->SomePrivateMemberFunction() };

Proposal: Lambda functions are most commonly used inside the function block to quickly define how the sort, find and similar functions should work (the other way would be overriding a class – the Java style). The latest GCC does not support lambda functions yet so it is difficult to test the feature once implemented. I would implement the syntax support for this feature, but produce no wrapper code. Lambda functions still work inside the function block though.

Article: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2550.pdf

Done: Added syntax support for the lambda functions. Added testcase cpp11_lambda_functions.i. R11491, R11492

Alternate function syntax [done]

The problem with decltype() is that the parameters need to be defined before the decltype. The following syntax is not valid, because lhs and rhs hasn't been defined at the time of decltype:

template< typename LHS, typename RHS> 
  decltype(lhs+rhs) AddingFunc(const LHS &lhs, const RHS &rhs) {return lhs + rhs;} //Not legal C++11

The solution C++11 offers is the combination of the 'auto' keyword before and '-> rettype' after the function declaration:

template< typename LHS, typename RHS> 
  auto AddingFunc(const LHS &lhs, const RHS &rhs) -> decltype(lhs+rhs) {return lhs + rhs;}

The new syntax only makes the job for the C++ compilers easier when parsing such functions. The new syntax can be used for ordinary functions as well:

struct SomeStruct {
  auto FuncName(int x, int y) -> int;
};
 
auto SomeStruct::FuncName(int x, int y) -> int {
  return x + y;
}

Done: Added support for the 'auto' return type. Added support for the '-> type' after the funtion declaration. Added testcases cpp11_alternate_function_syntax.i and cpp11_alternate_function_syntax_runme.py. R11414

Concepts, Axioms [ignored]

In C++ there is a common problem when you use a template in the class which doesn't support all the operations the functions in the class actually do on the type. Compiler errors are usually very long and unreadable. C++11 adds support for the "concepts". The idea is to define what operations and attributes should the template have. In contrast to class inheritance and polimorphism, all lookups are done in compile-time.

Basic syntax (note LessThanComparable? instead of "class" or "typename"):

 template<LessThanComparable? T>
 const T& min(const T &x, const T &y) {
   return y < x ? y : x;
 }

Extended syntax (requires conditions are separated with &&, || or !):

 template< typename T> requires LessThanComparable?<T>
 const T& min(const T &x, const T &y) {
   return y < x ? y : x;
 }

Definition of the concepts:

 concept LessThanComparable?< typename T > {
   bool operator<(T,T);
   requires GreaterThanComparable?<T>;
   typename value_type;
   typename reference;
 };

Concept maps allow usage of a specific type:

 template< typename T>
 concept_map InputIterator?<T*> {
   typedef T value_type ;
   typedef T& reference ;
   typedef T* pointer ;
   typedef std::ptrdiff_t difference_type ;
 };

Concept maps can act as mini-types, with function definitions and other constructs commonly associated with classes:

 concept Stack< typename X> {
   typename value_type;
   void push(X&, const value_type&);
   void pop(X&);
   value_type top(const X&);
   bool empty(const X&);
 };
 template< typename T>
 concept_map Stack<std::vector<T> > {
   typedef T value_type;
   void push(std::vector<T>& v, const T& x) { v.push_back(x); }
   void pop(std::vector<T>& v) { v.pop_back(); }
   T top(const std::vector<T>& v) { return v.back(); }
   bool empty(const std::vector<T>& v) { return v.empty(); }
 };

Axioms are a facility pertaining to concepts supplied by C++11 to express the semantic properties of concepts. For example, the concept Semigroup can be defined with an axiom Associativity as:

 concept Semigroup< typename Op, typename T> : CopyConstructible?<T> {
   T operator()(Op, T, T);
   axiom Associativity(Op op, T x, T y, T z) {
     op(x, op(y, z)) == op(op(x, y), z);
   }
 };

Axioms are more like hints to the compiler to speed-up the process of compilation.

Ignored: Concepts and axioms were removed from the C++11 standard.

Object construction improvement [done]

This feature allows classes constructors to call other constructors with different arguments (similar to Java and C# behaviour).

The syntax is as follows:

 class SomeType {
  int number;
 public:
   SomeType(int newNumber) : number(newNumber) {}
   SomeType() : SomeType(42) {}
 };

Also when using the inheritance, the feature introduces inheritance of all superclass constructors without being defined separately in the inherited class:

 class BaseClass {
 public:
   BaseClass(int iValue);
 };
 class DerivedClass: public BaseClass {
   public:
   using BaseClass::BaseClass; // Adds DerivedClass(int) constructor
 };

Swig already correctly parses and produces the correct wrapper for the “using†keyword.

Done: Added testcase cpp11_constructors.i which covers both constructor delegation and constructor inheritance. R11532

Problem: Constructor delegation and constructor inheritance is not supported by any compiler yet, so it's impossible to try and test this feature.

Null pointer constant [done]

nullptr is part of the standard library.

It's defined as typedef decltype(nullptr) nullptr_t;

nullptr_t is defined in <cstddef>.

As far as the C++ is compatible with 0 as the pointer value, swig values will work for the C++. And the other way around, nullptr behaves as the ordinary pointer (false, if empty, true, if not empty), so it's ok for swig to compare it.

Done: Written a testcase cpp11_null_pointer_constant.i and cpp11_null_pointer_constant_runme.py to prove the nullptr functionality. R11484

Strongly typed enumerations [partially done]

C++11 introduces a new syntax for strongly typed enum declaration:

 enum class Enumeration {
  Val1,
  Val2,
  Val3 = 100,
  Val4 /* = 101 */
 };

Typing if (Val4 == 101) will result in compilation error.

The enum itself can now be explicitely of type int, long, unsigned int etc.:

 enum class Enum2 : unsigned int {Val1, Val2};

And it can be forward declared as well:

 enum Enum1;                   //Illegal in C++ and C++11; no size is explicitly specified.
 enum Enum2 : unsigned int;    //Legal in C++11.
 enum class Enum3;             //Legal in C++11, because enum class declarations have a default type of "int".
 enum class Enum4: unsigned int; //Legal C++11.
 enum Enum2 : unsigned short;  //Illegal in C++11, because Enum2 was previously declared with a different type.

Done: Added syntax 'enum class Name' and forward declarators 'enum Name : inherited type' or 'enum class Name : inherited type' in R11449.

TODO: Add semantic support for enum elements not clashing with enum elements in other enum classes. See cpp11_strongly_typed_enums.i warnings.

Problem: Swig currently doesn't support nested classes. This feature should be implemented using a new nested class when using “enum class†with a single anonymous “enum {elements}†element inside. For example:

class A { enum class EA { a,b,c,d }; };

should be mapped to

class A { class EA { enum {a,b,c,d}; }; };

Angle bracket [done]

Support for right angled brackets was implemented using the following article as a base: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html

Done: Added support for angle brackets. Used the preferred "Approach 1". Added a testcase named cpp11_template_double_brackets. R11245

Explicit conversion operators [done]

This is used when converting one type to another (eg. if (myObject) {}, where myObject is your custom class converted to bool).

Requires both operator and function overloading which is not supported in any target language (eg. python, php).

Done: Swig already supports the keyword "explicit" for function types as well. Added test case cpp11_explicit_conversion_operators. R11323

Template typedefs [partially done]

The new C++11 will allow creation of wrapper around the template. For example, if we want to do this:

template< typename first, typename second, int third>
class SomeType;
 
template< typename second>
typedef SomeType<OtherType, second, 5> TypedefName; //Illegal in C++

This is still illegal! But we can now use the new syntax for achieving the same effect:

template< typename first, typename second, int third>
class SomeType;

template< typename second>
using TypedefName = SomeType<OtherType, second, 5>;

Here we created a new wrapper TypedefName taking one template argument <second> which creates a type SomeType<OtherType, second, 5>. OtherType and 5 are predefined here and hidden from the user – the user only uses TypedefName type.

The same goes for the following example:

typedef void (*PFD)(double);            // Old style
using PF = void (*)(double);            // New introduced syntax

Swig supports parsing typedefs for templates as well for example:

typedef List<int> intList;

Done: Expanded support for the new 'using' syntax and template aliasing. Added testcase cpp11_template_typedefs. R11533

TODO: Make Swig aware of the newly defined typedef. The TYPEDEF keyword is part of the storage_class rule and type+declarator (see c_decl rule) is the right part of the definition – for example void (*PFD)(double) cannot be transformed to void *(double) easily. To fully support the new 'using' form, we'll probably have to change the type, type_right rules and declarator, direct_declarator, notso_direct_declarator etc., which is PITA.

Unrestricted unions [done]

C++ currently offers usage of unions for types with trivial constructors only. The new C++11 standard allows usage of types with non-trivial constructors as well:

 struct point {
  point() {}
  point(int x, int y): x_(x), y_(y) {}
  int x_, y_;
 };
 union P {
  int z;
  double w;
  point p;  // Illegal in C++; point has a non-trivial constructor.  However, this is legal in C++11.
 } p1;

Swig already parses the given syntax.

Done: Added testcase cpp11_unrestricted_unions. R11435, R11447

Problem: GCC doesn't support unrestricted unions yet so there is no way to actually test, if it works.

Variadic templates [partially done]

The new C++11 offers the following syntax:

template<typename... Values> class tuple;

This can be used for example:

class tuple<int, std::vector<int>, std::map<std::string, std::vector<int>>> someInstanceName;

The ... is used in two cases. One is in the template header where it marks on the left the keywords 'typename' or 'class' and a type name on the right. The second case is usually in the function block to decompose typename on the left of the ... . For example:

void printf(const char *s) {
  while (*s) {
    if (*s == '%' && *(++s) != '%')
      throw std::runtime_error("invalid format string: missing arguments");
    std::cout << *s++;
  }
}
 
template<typename T, typename... Args>
void printf(const char* s, T value, Args... args) { // recursive action – split previous args to value + args
  while (*s) {
    if (*s == '%' && *(++s) != '%') {
      std::cout << value;
      printf(*s ? ++s : s, args...); // call even when *s == 0 to detect extra arguments
      return;
    }
    std::cout << *s++;
  }
  throw std::logic_error("extra arguments provided to printf");
}

The tricky part is that variadic templates can unpack actually anywhere – including the class inheritance :(

template <typename... BaseClasses> class ClassName : public BaseClasses... {
public:
 
   ClassName (BaseClasses&&... baseClasses) : BaseClasses(baseClasses)... {}
}

A new extension to sizeof is also introduced with this feature. The ... after sizeof returns number of arguments:

template<typename ...Args> struct SomeStruct {
  static const int size = sizeof...(Args);
}
// SomeStruct<Type1, Type2>::size is 2 and SomeStruct<>::size is 0

Done: Added syntax support for 'typename' or 'class' + ... + id. Added testcase cpp11_variadic_templates. R11458

Done: Added syntax support for BaseClass + ..., type + ... + id in parameters and baseclass + ... for intializers after constructor. Extended Swig syntax to support sizeof...(Args). R11467

Done: Fixed %template to support variadic number of templates.

TODO: Only (if present) first variadically defined argument is currently used in %template directive. The next ones are ignored.

New string literals [partially done]

Beside the implementation, the new C++11 Unicode and custom delimeter constants can occur in templates in the header file.

Done: Added symbols 'u', 'u8' and 'U' to mark the beginning of the UTF string. Also added test case cpp11_raw_string_literals. R11327

Done: Added R"DELIMITER[, ]DELIMITER" for a custom delimiter for the beginning/end of the string. R11328

TODO: Fix the Swig's C++ preprocessor bug when parsing an odd number of “ inside the string brackets. See Source/Preprocessor/cpp.c.

User-defined literals [partially done]

C++ has different suffix literals. eg. 12.5f marks the number 12.5 as float.

C++11 allows user to define his own suffix for the strings always starting with the underscore (_). eg. int a = "hello"_mySuffix;

The syntax is similar to other operator overloading functions:

 OutputType operator "" _mySuffix(const char * string_values);

The null terminated const char* is the string between the "". The _mySuffix is the name of the suffix operator. And the OutputType is the outputType the operator returns.

Other forms are:

 OutputType operator "" _mySuffix(const char * string_values, size_t num_chars);
 OutputType operator "" _mySuffix(const wchar_t * string_values, size_t num_chars);
 OutputType operator "" _mySuffix(const char16_t * string_values, size_t num_chars);
 OutputType operator "" _mySuffix(const char32_t * string_values, size_t num_chars);
 OutputType operator "" _mySuffix(int value); /* cooked version - ie. atoi() of string */

Another possibility is to use variadic templates:

 template<char...> OutputType operator "" _mySuffix();
 OutputType someVariable = "1234"_mySuffix;

This instantiates the literal processing function as operator""_Suffix<'1', '2', '3', '4'>. In this form, there is no terminating null character to the string. The main purpose to doing this is to use C++11's constexpr keyword and the compiler to allow the literal to be transformed entirely at compile time, assuming OutputType is a constexpr-constructable and copyable type, and the literal processing function is a constexpr function.

Article: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf

Done: Added syntax support for userdefined literals. Added testcase cpp11_userdefined_literals.i. R11494

TODO: %rename doesn't parse operatorâ€â€ yet.

Thread-local storage [done]

New C++11 introduces keyword "thread_local" which marks the following variable dynamically located depending on the current thread when using the address-of (&) operator.

Syntax:

 struct A {
   thread_local int val;
 };

Done: Add "thread_local" keyword to Swig. Added testcase cpp11_thread_local. R11393

Defaulting/deleting of standard functions on C++ objects [done]

C++ automatically creates default constructor with empty parameters, copy constructor, operator= and destructor for any class. Sometimes user wants to explicitly remove one of them or enable them (eg. default constructor with empty parameters doesn't work any more, if any other constructor is defined).

Words "default" and "delete" are introduced. The syntax is similar to declaration of pure virtual function:

 struct NonCopyable {
   NonCopyable & operator=(const NonCopyable&) = delete; /* Removes operator= */
   NonCopyable(const NonCopyable&) = delete; /* Removed copy constructor */
   NonCopyable() = default; /* Explicitly allows the empty constructor */
   void *operator new(std::size_t) = delete; /* Removes new NonCopyable */
 };

User has the ability by using keyword delete to disallow calling of the standard functions brought by C++ itself.

 struct A1 {
   void f(int i);
   void f(double i) = delete;  /* Don't cast double to int. Compiler returns an error */
 };
 struct A2 {
   void f(int i);
   template<class T> void f(T) = delete; /* Only accept int */
 };

Ignored: Swig already parses the keywords "= delete" and "= default". These keywords are used for built-in functions (copy constructor, operator= etc.), which are ignored by Swig anyway.

Done: Added testcase cpp11_default_delete. R11535

Type long long int [done]

Type long long int is an integer type that has at least 64 useful bits. C99 added it to its standard, but the C++ didn't adopt it until C++11. Most C++ compilers supported it though.

Done: Swig already parses the C code including the long long type.

Static assertions [done]

static_assert() can be used at class scope as well eg.:

 template <typename T>
 struct Check {
  static_assert(sizeof(int) <= sizeof(T), "not big enough");
 };

Done: Added syntax support for "static_assert()". Added test case cpp11_static_assert. R11369

Allow sizeof to work on members of classes without an explicit object [done]

C++11 allows calls of sizeof to concrete objects as well:

 struct A { int member; };
 sizeof(A::member); //Does not work with C++03. Okay with C++11

This kind of syntax is already supported by Swig.

Done: Added testcase cpp11_sizeof_objects. R11538

Threading facilities [ignored]

C++11 will add the following classes to the standard library:

 * std::thread
 * std::mutex, std::recursive_mutex
 * std::condition_variable, std::condition_variable_any
 * std::lock_guard, std::unique_lock
 * std::packaged_task

Ignored: No changes to the language itself is made.

Tuple types [TODO]

Tuple is array of various types. C++11 introduced this feature using variadic templates. Tuple is defined as:

template <class ...Types> class tuple;

Constructor is automatically generated filling the tuple elements. get<X> function is introduced to get the Xth element in the tuple.

typedef tuple< int, double, long &, const char * > test_tuple ;
long lengthy = 12 ;
test_tuple proof( 18, 6.5, lengthy, "Ciao!" ) ;
lengthy = get<0>(proof) ;  // Assign to 'lengthy' the value 18.
get<3>(proof) = " Beautiful!" ;  // Modify the tuple’s fourth element.

Tuples can be copied to each other, if all the elements are copiable:

typedef tuple< int , double, string       > tuple_1 t1 ;
typedef tuple< char, short , const char * > tuple_2 t2( 'X', 2, "Hola!" ) ;
t1 = t2 ;  // Ok, first two elements can be converted,
           // the third one can be constructed from a 'const char *'.

TODO: Implement wrappers for the tuplet<> class.

Hash tables [TODO]

C++11 introduces the "unordered" version of existing types, which in practice work faster than the linear types:

 - unordered set
 - unordered multiset
 - unordered map
 - unordered multimap

Swig should use the "unordered" types exactly the same as the original linear types.

Problem: Unordered types do not contain exactly same members as ordered ones (eg. _Hashtable_iterator does not offer operator--() and constructor with compare function which is required). So simply aliasing unordered classes to ordered ones doesn't work.

TODO: Implement wrappers for unordered_ types. Initial work is already done in Lib/std/unordered_*.i files.

Regular expressions [ignored]

Two new classes are introduced in C++11: basic_regex and match_results. Both are defined in regex header file.

Ignored: The new feature extends the standardy library only. No changes to Swig needed.

General-purpose smart pointers [done]

This feature deprecates auto_ptr and adds shared_ptr, weak_ptr and unique_ptr to the standard library.

This feature only adds the smart pointers to the standard library and doesn't effect the C++ syntax.

Done: Added test case which uses all three smart pointers in the class. R11394

Problem: GCC standard library doesn't contain the new smart pointers yet.

Extensible random number facility [ignored]

This feature standardize the pseudo random number algorithm (currently, the random number generator was dependent on the platform/compiler). It adds functions linear_congruential, subtract_with_carry and mersenne_twister and symbols uniform_int_distribution, bernoulli_distribution, geometric_distribution, poisson_distribution, binomial_distribution, uniform_real_distribution, exponential_distribution, normal_distribution and gamma_distribution to the standard library.

Ignored: The new feature extends the standardy library only. No changes to Swig needed.

Wrapper reference [ignored]

This feature adds ref and cref classes to the standard library (#include <utility>) usually used in tempalte functions.

Ignored: The new feature extends the standardy library only. No changes to Swig needed.

Polymorphous wrappers for function objects [done]

Two features are introduced:

  • The function template wrapper:

 function<int ( int, int )> pF;
  • and the function object:

 struct Test {
   bool operator()( short x, short y );
 };

Swig already supports the two.

Done: Added a runtime testcase for function objects cpp11_function_objects. R11419.

Type traits for metaprogramming [ignored]

C++11 adds a new header file <type_traits> which includes helper functions to determine the template type while initializing the object at compile time.

Swig already supports the following code:

 template< int B, int N >
 struct Pow {
  // recursive call and recombination.
  enum{ value = B*Pow< B, N-1 >::value };
 };
 template< int B > struct Pow< B, 0 >  // N == 0 condition of termination.
 {
  enum{ value = 1 };
 };
 int quartic_of_three = Pow< 3, 4 >::value ;

Functions is_convertible, is_integral, is_integral_const etc. are part of the new header:

// First way of operating.
template< bool B > struct algorithm {
  template< class T1, class T2 > int do_it( T1 &, T2 & )  { /*...*/ }
};
// Second way of operating.
template<> struct algorithm<true> {
  template< class T1, class T2 > int do_it( T1, T2 )  { /*...*/ }
};
// Instantiating 'elaborate' will automatically instantiate the correct way to operate.
template< class T1, class T2 > int elaborate( T1 A, T2 B ) {
  // Use the second way only if 'T1' is an integer and if 'T2' is
  // in floating point, otherwise use the first way.
  return algorithm< is_integral<T1>::value && is_floating_point<T2>::value >::do_it( A, B );
}

Swig correctly parses the syntax for template<bool>, template<class T> and template<>.

Ignored: Swig requires explicitly defined template class (%template directive) to export it to the target language.

Uniform method for computing return type of function objects [partially done]

The template function is introduced: std::result_of() which depends on decltype:

template< class Obj >
class calculus_ver2 {
 public:
   template< class Arg >
   typename std::result_of<Obj(Arg)>::type operator()( Arg& a ) const { 
     return member(a);
   }
 private:
   Obj member;
};

Swig correctly parses the result_of class.

TODO: The return type (the result_of::type member) is not calculated by Swig. This needs a much more complex semantic parser.

Done: Added testcase cpp11_result_of. R11534

swig-3.0.2/Doc/Devel/scanner.html0000664000175000017500000002420112343605122016425 0ustar williamwilliam SWIG C Scanner

SWIG C/C++ Scanning

David M. Beazley
dave-swig@dabeaz.com
January 11, 2007

Introduction

This document describes functions that can be used to tokenize C/C++ input text. These functions are relatively low-level and are meant to be used in the implementation of scanners that can be plugged into yacc or used for other purposes. For instance, the preprocessor uses these functions to evaluate and test constant expressions.

All of these functions are declared in Source/Swig/swigscan.h. This API is considered to be stable.

Creation and Deletion of Scanners

The following functions are used to create and destroy a scanner object. More than one scanner object can be created and used as necessary.

Scanner *NewScanner()

Creates a new scanner object. The scanner contains initially contains no text. To feed text to the scanner use Scanner_push().

Scanner *DelScanner()

Deletes a scanner object.

Scanner Functions

void Scanner_clear(Scanner *s)

Clears all text from the scanner. This can be used to reset a scanner to its initial state, ready to receive new input text.

void Scanner_push(Scanner *s, String *text)

Pushes an input string into the scanner. Subsequent tokens will be returned from the new string. If the scanner is already processing a string, the pushed string takes precedence--in effect, interrupting the scanning of the previous string. This behavior is used to implement certain SWIG features such as the %inline directive. Once the pushed string has been completely scanned, the scanner will return to scanning the previous string (if any). The scanning of text relies upon the DOH file interface to strings (Getc(), Ungetc(), etc.). Prior to calling this function, the input string should be set so that its file pointer is in the location where you want scanning to begin. You may have to use Seek() to set the file pointer back to the beginning of a string prior to using this function.

void Scanner_pushtoken(Scanner *s, int tokvalue, String_or_char *val)

Pushes a token into the scanner. This exact token will be returned by the next call to Scanner_token(). tokvalue is the integer token value to return and val is the token text to return. This function is only used to handle very special parsing cases. For instance, if you need the scanner to return a fictitious token into order to enter a special parsing case.

int Scanner_token(Scanner *s)

Returns the next token. An integer token code is returned (see table below) on success. If no more input text is available 0 is returned. If a scanning error occurred, -1 is returned. In this case, error information can be obtained using Scanner_errinfo().

String *Scanner_text(Scanner *s)

Returns the scanned text corresponding to the last token returned by Scanner_token(). The returned string is only valid until the next call to Scanner_token(). If you need to save it, make a copy.

void Scanner_skip_line(Scanner *s)

Skips to the end of the current line. The text skipped can be obtained using Scanner_text() afterwards.

void Scanner_skip_balanced(Scanner *s, int startchar, int endchar)

Skips to the end of a block of text denoted by starting and ending characters. For example, { and }. The function is smart about how it skips text. String literals and comments are ignored. The function also is aware of nesting. The skipped text can be obtained using Scanner_text() afterwards. Returns 0 on success, -1 if no matching endchar could be found.

void Scanner_set_location(Scanner *s, int startchar, int endchar)

Changes the current filename and line number of the scanner.

String *Scanner_file(Scanner *s)

Gets the current filename associated with text in the scanner.

int Scanner_line(Scanner *s)

Gets the current line number associated with text in the scanner.

int Scanner_start_line(Scanner *s)

Gets the starting line number of the last token returned by the scanner.

void Scanner_idstart(Scanner *s, char *idchar)

Sets additional characters (other than the C default) that may be used to start C identifiers. idchar is a string containing the characters (e.g., "%@"). The purpose of this function is to up special keywords such as "%module" or "@directive" as simple identifiers.

String *Scanner_errmsg(Scanner *s)

Returns the error message associated with the last scanner error (if any). This will only return a meaningful result if Scanner_token() returned -1.

int Scanner_errline(Scanner *s)

Returns the line number associated with the last scanner error (if any). This will only return a meaningful result if Scanner_token() returned -1. The line number usually corresponds to the starting line number of a particular token (e.g., for unterminated strings, comments, etc.).

int Scanner_isoperator(int tokval)

A convenience function that returns 0 or 1 depending on whether tokval is a valid C/C++ operator (i.e., a candidate for operator overloading).

void Scanner_freeze_line(int val)

Freezes the current line number depending upon whether or not val is 1 or 0. When the line number is frozen, newline characters will not result in updates to the line number. This is sometimes useful in tracking line numbers through complicated macro expansions.

Token Codes

The following table shows token codes returned by the scanner. These are integer codes returned by the Scanner_token() function.
Token code                   C Token
-------------------------    -------------
SWIG_TOKEN_LPAREN            (
SWIG_TOKEN_RPAREN            )
SWIG_TOKEN_SEMI              ; 
SWIG_TOKEN_COMMA             , 
SWIG_TOKEN_STAR              * 
SWIG_TOKEN_TIMES             *
SWIG_TOKEN_LBRACE            { 
SWIG_TOKEN_RBRACE            } 
SWIG_TOKEN_EQUAL             = 
SWIG_TOKEN_EQUALTO           == 
SWIG_TOKEN_NOTEQUAL          != 
SWIG_TOKEN_PLUS              + 
SWIG_TOKEN_MINUS             - 
SWIG_TOKEN_AND               & 
SWIG_TOKEN_LAND              && 
SWIG_TOKEN_OR                | 
SWIG_TOKEN_LOR               || 
SWIG_TOKEN_XOR               ^ 
SWIG_TOKEN_LESSTHAN          < 
SWIG_TOKEN_GREATERTHAN       > 
SWIG_TOKEN_LTEQUAL           <= 
SWIG_TOKEN_GTEQUAL           >= 
SWIG_TOKEN_NOT               ~ 
SWIG_TOKEN_LNOT              ! 
SWIG_TOKEN_LBRACKET          [ 
SWIG_TOKEN_RBRACKET          ] 
SWIG_TOKEN_SLASH             / 
SWIG_TOKEN_DIVIDE            /
SWIG_TOKEN_BACKSLASH         \ 
SWIG_TOKEN_POUND             # 
SWIG_TOKEN_PERCENT           % 
SWIG_TOKEN_MODULO            %
SWIG_TOKEN_COLON             : 
SWIG_TOKEN_DCOLON            :: 
SWIG_TOKEN_DCOLONSTAR        ::*
SWIG_TOKEN_LSHIFT            << 
SWIG_TOKEN_RSHIFT            >> 
SWIG_TOKEN_QUESTION          ? 
SWIG_TOKEN_PLUSPLUS          ++ 
SWIG_TOKEN_MINUSMINUS        -- 
SWIG_TOKEN_PLUSEQUAL         += 
SWIG_TOKEN_MINUSEQUAL        -= 
SWIG_TOKEN_TIMESEQUAL        *= 
SWIG_TOKEN_DIVEQUAL          /= 
SWIG_TOKEN_ANDEQUAL          &= 
SWIG_TOKEN_OREQUAL           |= 
SWIG_TOKEN_XOREQUAL          ^= 
SWIG_TOKEN_LSEQUAL           <<= 
SWIG_TOKEN_RSEQUAL           >>= 
SWIG_TOKEN_MODEQUAL          %= 
SWIG_TOKEN_ARROW             -> 
SWIG_TOKEN_ARROWSTAR         ->* 
SWIG_TOKEN_PERIOD            . 
SWIG_TOKEN_AT                @ 
SWIG_TOKEN_DOLLAR            $ 
SWIG_TOKEN_ENDLINE           Literal newline
SWIG_TOKEN_ID                identifier 
SWIG_TOKEN_FLOAT             Floating point with F suffix (e.g., 3.1415F)
SWIG_TOKEN_DOUBLE            Floating point (e.g., 3.1415 )
SWIG_TOKEN_INT               Integer (e.g., 314)
SWIG_TOKEN_UINT              Unsigned integer (e.g., 314U)
SWIG_TOKEN_LONG              Long integer (e.g., 314L) 
SWIG_TOKEN_ULONG             Unsigned long integer (e.g., 314UL)
SWIG_TOKEN_LONGLONG          Long long integer (e.g., 314LL )
SWIG_TOKEN_ULONGLONG         Unsigned long long integer (e.g., 314ULL) 
SWIG_TOKEN_CHAR              Character literal in single quotes ('c')
SWIG_TOKEN_STRING            String literal in double quotes ("str")
SWIG_TOKEN_RSTRING           Reverse quote string (`str`)
SWIG_TOKEN_CODEBLOCK         SWIG code literal block %{ ... %}
SWIG_TOKEN_COMMENT           C or C++ comment  (// or /* ... */)
SWIG_TOKEN_ILLEGAL           Illegal character
Notes
  • When more than one token code exist for the same token text, those codes are identical (e.g., SWIG_TOKEN_STAR and SWIG_TOKEN_TIMES).

  • String literals are returned in their exact representation in which escape codes (if any) have been interpreted.

  • All C identifiers and keywords are simply returned as SWIG_TOKEN_ID. To check for specific keywords, you will need to add extra checking on the returned text.

  • C and C++ comments include the comment starting and ending text (e.g., "//", "/*").

  • The maximum token integer value is found in the constant SWIG_MAXTOKENS. This can be used if you wanted to create an array or table for the purposes of remapping tokens to a different set of codes. For instance, if you are using these functions to write a yacc-compatible lexer.
swig-3.0.2/Doc/Devel/file.html0000664000175000017500000001330212343605122015713 0ustar williamwilliam SWIG File Handling

SWIG File Handling

David M. Beazley
dave-swig@dabeaz.com
December, 2006

Introduction

This document describes the functions related to file and filename handling in the SWIG core. These functions are defined in the header file Source/Swig/swigfile.h. This API is considered to be stable.

File Search Path

These functions manipulate the search path for locating files.

List *Swig_add_directory(const String_or_char *dirname)

Adds a new directory to the system search path. The directory is appended to the end of the search path. Returns a list containing the current system search path.

void Swig_push_directory(const String_or_char *dirname)

Pushes a temporary directory onto the search path. This directory is searched before directories added with Swig_add_directory() except when including a system file explicitly (either using #include <file> or calling Swig_include_sys()). This function is normally used by the preprocessor to add temporary directories when processing #include statements.

void Swig_pop_directory()

Pops off the last pushed directory with Swig_push_directory()

int Swig_get_push_dir()

Returns a flag that indicates whether directory pushing is enabled or not.

void Swig_set_push_dir(int dopush)

Enables or disables directory pushing. By default, it is turned on. However, the -I- command line option to SWIG disables it.

List *Swig_search_path()

Returns the current search path.

File access functions

FILE *Swig_open(const String_or_char *name)

Opens a file, using the applicable search paths, and returns an open FILE * object if found. Returns NULL if the file is not found.

String *Swig_read_file(FILE *f)

Reads all of the data from an open file into a string which is returned.

String *Swig_include(const String_or_char *name)

Searches for an include file name and returns its contents as a string if found. Returns NULL if not found. All of the applicable search paths are searched when trying to locate the file.

String *Swig_include_sys(const String_or_char *name)

Searches for an include file name and returns its contents as a string if found. Returns NULL if not found. All of the applicable search paths are searched when trying to locate the file, but preference is given to system paths first. This mimics the behavior of #include <file> in the preprocessor.

int Swig_insert_file(const String_or_char *name, File *outfile)

Searches for a file name and dumps its contents to outfile if found. Returns 0 on success, -1 if the file couldn't be found.

Query functions

String *Swig_last_file()

Returns the full pathname of the file last opened or included.

Named files

void *Swig_register_filebyname(const String_or_char *filename, File *outfile)

Registers a file object outfile with a specific name filename. This function is used to implement the SWIG %insert directive and to manage different sections of the output file such as "runtime","header","wrapper","init", etc. Different language modules may add their own sections for generating Python code, Perl code, etc.

File *Swig_filebyname(const String_or_char *filename)

This looks up a file object previously registered using Swig_register_filebyname(). This is used to implement the %insert directive.

Filename utilities

char *Swig_file_suffix(const String_or_char *filename)

Returns the suffix of a filename. For instance, if the filename is "foo.txt", it returns ".txt".

char *Swig_file_basename(const String_or_char *filename)

Returns the filename without the suffix attached to it. For instance, if the filename is "foo.txt", it returns "foo". The result is stored in a static variable. If you need to save it, make your own copy.

char *Swig_file_filename(const String_or_char *filename)

Returns the filename without any leading directories. For instance, if the filename is "/bar/spam/foo.txt", it returns "foo.txt". This function is aware of local naming conventions on the machine (e.g., forward versus back slashes on Unix and Windows). The result is stored in a static variable. If you need to save the value, make a copy.

char *Swig_file_dirname(const String_or_char *filename)

Returns the directory name (if any). For instance, if the filename is "/bar/spam/foo.txt", it returns "/bar/spam/". This function is aware of local naming conventions on the machine (e.g., forward versus back slashes on Unix and Windows). The result is stored in a static variable. If you need to save the value, make a copy.

SWIG_FILE_DELIMITER

This macro contains the file delimiter string for the local machine. On Unix it is "/", on Windows it is "\\".
swig-3.0.2/Doc/Devel/runtime.txt0000664000175000017500000001753312343605122016344 0ustar williamwilliamThis file describes the necessary functions and interfaces a language module needs to implement to take advantage of the run time type system. I assume you have read the run-time section of the Typemaps chapter in the SWIG documentation. Last updated: February 23, 2005 The file we are concerned with here should be named langrun.swg. A good example of a simple file is the Lib/mzscheme/mzrun.swg file. First, a few requirements and notes: 1) Every function in this file should be declared static. 2) It should be inserted into the runtime section of the _wrap file from your config file. The Lib/swigrun.swg file should be included before this file. That is, you need to have %runtime "swigrun.swg" %runtime "langrun.swg" 3) You must also include the swiginit.swg file in the init section of the wrapper. That is, you should have %insert(init) "swiginit.swg" 4) From module.cxx, you need to call the SwigType_emit_type_table function, as well as register types with SwigType_remember or SwigType_remember_clientdata 5) By convention, all functions in this file are of the form SWIG_Language_Whatever, and #defines are used to rename SWIG API functions to these function names 6) You need to call void SWIG_InitializeModule(void *clientdata) from your init function. 7) You need to implement the runtimeCode() and defaultExternalRuntimeFilename() functions inside module.cxx. runtimeCode should return all the language specific runtime code as a string, and defaultExternalRuntimeFilename should return a string for the default name of the external runtime header. This is usually "swigpyrun.h", where "py" is replaced by the language name. These two functions are used by the -external-runtime argument. ------------------------------------------------------------------------------- Required Functions ------------------------------------------------------------------------------- swig_module_info *SWIG_GetModule(void *clientdata); void SWIG_SetModule(void *clientdata, swig_module_info *mod); The SetModule function should store the mod argument into some globally accessible variable in the target language. The action of these two functions is to provide a way for multiple modules to share information. The SetModule function should create a new global var named something like "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION is currently defined as "2", and SWIG_TYPE_TABLE_NAME is defined by the -DSWIG_TYPE_TABLE=mytable option when compiling the wrapper. Alternatively, if the language supports modules, a module named "swig_runtime_data" SWIG_RUNTIME_VERSION can be created, and a global variable named "type_table" SWIG_TYPE_TABLE_NAME can be created inside it. The most common approach is to store the mod pointer in some global variable in the target language, but if the language provides an alternative place to store data (like the chicken module), then that is good too. The way the code is set up, SetModule should only be called when GetModule returns NULL, and if SetModule is called a second time, the behavior is undefined. Just make sure it doesn't crash in the random chance occurrence that SetModule is called twice. There are two options here. 1) The preferred approach is for GetModule and SetModule to not require a clientdata pointer. If you can at all avoid it, please do so. Here, you would write swig_module_info *SWIG_Language_GetModule(); void SWIG_Language_SetModule(swig_module_info *mod); and then add #define SWIG_GetModule(clientdata) SWIG_Language_GetModule() #define SWIG_SetModule(cd, ptr) SWIG_Language_SetModule(ptr) You would then call SWIG_InitializeModule(0) 2) If GetModule and SetModule need to take a custom pointer (most notably an environment pointer, see tcl or mzscheme), then you should write swig_module_info *SWIG_Language_GetModule(void *clientdata) void SWIG_Language_SetModule(void *clientdata, swig_module_info *mod); and also define #define SWIG_GetModule(cd) SWIG_Language_GetModule(cd) #define SWIG_SetModule(cd, ptr) SWIG_Language_SetModule(cd, ptr) #define SWIG_MODULE_CLIENTDATA_TYPE Whatever SWIG_MODULE_CLIENTDATA_TYPE should be defined to whatever the type of clientdata is. You would then call SWIG_InitializeModule(clientdata), and clientdata would get passed to GetModule and SetModule. clientdata will not be stored and will only be referenced during the InitializeModule call. After InitializeModule returns, clientdata does not need to be valid any more. This method is not preferred, because it makes external access to the type system more complicated. See the Modules chapter of the documentation, and read the "External access to the run-time" section. Then take a look at Lib/runtime.swg. Anybody that calls SWIG_TypeQuery needs to pass along the clientdata pointer, and that is the reason for defining SWIG_MODULE_CLIENTDATA_TYPE. ------------------------------------------------------------------------------- Standard Functions ------------------------------------------------------------------------------- These functions are not required and their API is not formalized, but almost all language modules implement them for consistency across languages. Throughout this discussion, I will use LangType to represent the underlying language type (C_word in chicken, Scheme_Object * in mzscheme, PyObject * in python, etc) LangObj SWIG_NewPointerObj(void *ptr, swig_type_info *type, int flags); Create and return a new pointer object that has both ptr and type. For almost all language modules, flags is used for ownership. If flags==1, then the created pointer should be registered to be garbage collected. int SWIG_ConvertPtr(LangType obj, void **result, swig_type_info *type, int flags); Convert a language wrapped pointer into a void *. The pointer is returned in result, and the function should return 0 on success, non-zero on error. A sample ConvertPtr is given here: swig_cast_info *cast; if () { cast = SWIG_TypeCheck(, type); cast = SWIG_TypeCheckStruct(, type); if (cast) { *result = SWIG_TypeCast(cast, ); return 0; } } return 1; Either TypeCheck or TypeCheckStruct can be called, depending on how the pointer is wrapped in langtype. If obj stores the void pointer and the type name, then the TypeCheck function should be used, while if obj stores the void pointer and a pointer to the swig_type_info structure, then the TypeCheckStruct function should be called. The TypeCheckStruct is slightly faster, since it does a pointer comparison instead of a strcmp. The flag argument to ConvertPtr is used in some languages for disowning a pointer. If the wrapped C function is taking ownership of the pointer (that means, the wrapped C function is responsible for deleting the object), then that pointer should be removed from the garbage collector. We do that in the ConvertPtr function. The pointer is still valid in the target language, but when the target language type is garbage collected, it will not call the associated destructor. Languages have a special typemap called DISOWN that can be applied which passes this argument. All the languages have the flags argument for consistency, and the flags argument can be ignored or used for some other purpose. void *SWIG_MustGetPtr(LangType obj, swig_type_info *type, int flags, int argnum, const char *func_name) { void *result; if (SWIG_ConvertPtr(s, &result, type, flags)) { generate runtime type error ("Error in func_name, expected a" + type->str ? type->str : "void *" + "at argument number" + argnum); } return result; } This function is optional, and the number and type of parameters can be different, but is useful for typemap purposes: %typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, 0, $argnum, FUNC_NAME); } swig-3.0.2/Doc/Manual/0000775000175000017500000000000012343706605014275 5ustar williamwilliamswig-3.0.2/Doc/Manual/Python.html0000664000175000017500000050161312343706602016447 0ustar williamwilliam SWIG and Python

36 SWIG and Python

Caution: This chapter is under repair!

This chapter describes SWIG's support of Python. SWIG is compatible with most recent Python versions including Python 3.0 and Python 2.6, as well as older versions dating back to Python 2.0. For the best results, consider using Python 2.3 or newer.

This chapter covers most SWIG features, but certain low-level details are covered in less depth than in earlier chapters. At the very least, make sure you read the "SWIG Basics" chapter.

36.1 Overview

To build Python extension modules, SWIG uses a layered approach in which parts of the extension module are defined in C and other parts are defined in Python. The C layer contains low-level wrappers whereas Python code is used to define high-level features.

This layered approach recognizes the fact that certain aspects of extension building are better accomplished in each language (instead of trying to do everything in C or C++). Furthermore, by generating code in both languages, you get a lot more flexibility since you can enhance the extension module with support code in either language.

In describing the Python interface, this chapter starts by covering the basics of configuration, compiling, and installing Python modules. Next, the Python interface to common C and C++ programming features is described. Advanced customization features such as typemaps are then described followed by a discussion of low-level implementation details.

36.2 Preliminaries

36.2.1 Running SWIG

Suppose that you defined a SWIG module such as the following:

/* File: example.i */
%module example

%{
#define SWIG_FILE_WITH_INIT
#include "example.h"
%}

int fact(int n);

The #define SWIG_FILE_WITH_INIT line inserts a macro that specifies that the resulting C file should be built as a python extension, inserting the module init code. This .i file wraps the following simple C file:

/* File: example.c */

#include "example.h"

int fact(int n) {
    if (n < 0){ /* This should probably return an error, but this is simpler */
        return 0;
    }
    if (n == 0) {
        return 1;
    }
    else {
        /* testing for overflow would be a good idea here */
        return n * fact(n-1);
    }
}

With the header file:

/* File: example.h */

int fact(int n);

To build a Python module, run SWIG using the -python option:

$ swig -python example.i

If building a C++ extension, add the -c++ option:

$ swig -c++ -python example.i

This creates two different files; a C/C++ source file example_wrap.c or example_wrap.cxx and a Python source file example.py. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module. The Python source file contains high-level support code. This is the file that you will import to use the module.

The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The name of the Python file is derived from the module name specified with %module. If the module name is example, then a file example.py is created.

The following sections have further practical examples and details on how you might go about compiling and using the generated files.

36.2.2 Using distutils

The preferred approach to building an extension module for python is to compile it with distutils, which comes with all recent versions of python (Distutils Docs).

Distutils takes care of making sure that your extension is built with all the correct flags, headers, etc. for the version of Python it is run with. Distutils will compile your extension into a shared object file or DLL (.so on Linux, .pyd on Windows, etc). In addition, distutils can handle installing your package into site-packages, if that is desired. A configuration file (conventionally called: setup.py) describes the extension (and related python modules). The distutils will then generate all the right compiler directives to build it for you.

Here is a sample setup.py file for the above example:

#!/usr/bin/env python

"""
setup.py file for SWIG example
"""

from distutils.core import setup, Extension


example_module = Extension('_example',
                           sources=['example_wrap.c', 'example.c'],
                           )

setup (name = 'example',
       version = '0.1',
       author      = "SWIG Docs",
       description = """Simple swig example from docs""",
       ext_modules = [example_module],
       py_modules = ["example"],
       )

In this example, the line: example_module = Extension(....) creates an Extension module object, defining the name as _example, and using the source code files: example_wrap.c, generated by swig, and example.c, your original c source. The swig (and other python extension modules) tradition is for the compiled extension to have the name of the python portion, prefixed by an underscore. If the name of your python module is "example.py", then the name of the corresponding object file will be"_example.so"

The setup call then sets up distutils to build your package, defining some meta data, and passing in your extension module object. Once this is saved as setup.py, you can build your extension with these commands:

$ swig -python example.i
$ python setup.py build_ext --inplace

And a .so, or .pyd or... will be created for you. It will build a version that matches the python that you run the command with. Taking apart the command line:

  • python -- the version of python you want to build for
  • setup.py -- the name of your setup script (it can be called anything, but setup.py is the tradition)
  • build_ext -- telling distutils to build extensions
  • --inplace -- this tells distutils to put the extension lib in the current dir. Otherwise, it will put it inside a build hierarchy, and you'd have to move it to use it.

The distutils have many other features, consult the python distutils docs for details.

This same approach works on all platforms if the appropriate compiler is installed. (it can even build extensions to the standard Windows Python using MingGW)

36.2.3 Hand compiling a dynamic module

While the preferred approach to building an extension module is to use the distutils, some people like to integrate building extensions with a larger build system, and thus may wish to compile their modules without the distutils. To do this, you need to compile your program using commands like this (shown for Linux):

$ swig -python example.i
$ gcc -O2 -fPIC -c example.c
$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/include/python2.5
$ gcc -shared example.o example_wrap.o -o _example.so

The exact commands for doing this vary from platform to platform. However, SWIG tries to guess the right options when it is installed. Therefore, you may want to start with one of the examples in the SWIG/Examples/python directory. If that doesn't work, you will need to read the man-pages for your compiler and linker to get the right set of options. You might also check the SWIG Wiki for additional information.

When linking the module, the name of the output file has to match the name of the module prefixed by an underscore. If the name of your module is "example", then the name of the corresponding object file should be "_example.so" or "_examplemodule.so". The name of the module is specified using the %module directive or the -module command line option.

Compatibility Note: In SWIG-1.3.13 and earlier releases, module names did not include the leading underscore. This is because modules were normally created as C-only extensions without the extra Python support file (instead, creating Python code was supported as an optional feature). This has been changed in SWIG-1.3.14 and is consistent with other Python extension modules. For example, the socket module actually consists of two files; socket.py and _socket.so. Many other built-in Python modules follow a similar convention.

36.2.4 Static linking

An alternative approach to dynamic linking is to rebuild the Python interpreter with your extension module added to it. In the past, this approach was sometimes necessary due to limitations in dynamic loading support on certain machines. However, the situation has improved greatly over the last few years and you should not consider this approach unless there is really no other option.

The usual procedure for adding a new module to Python involves finding the Python source, adding an entry to the Modules/Setup file, and rebuilding the interpreter using the Python Makefile. However, newer Python versions have changed the build process. You may need to edit the 'setup.py' file in the Python distribution instead.

In earlier versions of SWIG, the embed.i library file could be used to rebuild the interpreter. For example:

%module example

%inline %{
extern int fact(int);
extern int mod(int, int);
extern double My_variable;
%}

%include "embed.i"       // Include code for a static version of Python

The embed.i library file includes supporting code that contains everything needed to rebuild Python. To rebuild the interpreter, you simply do something like this:

$ swig -python example.i
$ gcc example.c example_wrap.c \
        -Xlinker -export-dynamic \
        -DHAVE_CONFIG_H -I/usr/local/include/python2.1 \
	-I/usr/local/lib/python2.1/config \
	-L/usr/local/lib/python2.1/config -lpython2.1 -lm -ldl \
	-o mypython

You will need to supply the same libraries that were used to build Python the first time. This may include system libraries such as -lsocket, -lnsl, and -lpthread. Assuming this actually works, the new version of Python should be identical to the default version except that your extension module will be a built-in part of the interpreter.

Comment: In practice, you should probably try to avoid static linking if possible. Some programmers may be inclined to use static linking in the interest of getting better performance. However, the performance gained by static linking tends to be rather minimal in most situations (and quite frankly not worth the extra hassle in the opinion of this author).

Compatibility note: The embed.i library file is deprecated and has not been maintained for several years. Even though it appears to "work" with Python 2.1, no future support is guaranteed. If using static linking, you might want to rely on a different approach (perhaps using distutils).

36.2.5 Using your module

To use your module, simply use the Python import statement. If all goes well, you will be able to this:

$ python
>>> import example
>>> example.fact(4)
24
>>>

A common error received by first-time users is the following:

>>> import example
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "example.py", line 2, in ?
    import _example
ImportError: No module named _example

If you get this message, it means that you either forgot to compile the wrapper code into an extension module or you didn't give the extension module the right name. Make sure that you compiled the wrappers into a module called _example.so. And don't forget the leading underscore (_).

Another possible error is the following:

>>> import example
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: dynamic module does not define init function (init_example)
>>>                                                               

This error is almost always caused when a bad name is given to the shared object file. For example, if you created a file example.so instead of _example.so you would get this error. Alternatively, this error could arise if the name of the module is inconsistent with the module name supplied with the %module directive. Double-check the interface to make sure the module name and the shared object filename match. Another possible cause of this error is forgetting to link the SWIG-generated wrapper code with the rest of your application when creating the extension module.

Another common error is something similar to the following:

Traceback (most recent call last):
  File "example.py", line 3, in ?
    import example
ImportError: ./_example.so: undefined symbol: fact

This error usually indicates that you forgot to include some object files or libraries in the linking of the shared library file. Make sure you compile both the SWIG wrapper file and your original program into a shared library file. Make sure you pass all of the required libraries to the linker.

Sometimes unresolved symbols occur because a wrapper has been created for a function that doesn't actually exist in a library. This usually occurs when a header file includes a declaration for a function that was never actually implemented or it was removed from a library without updating the header file. To fix this, you can either edit the SWIG input file to remove the offending declaration or you can use the %ignore directive to ignore the declaration.

Finally, suppose that your extension module is linked with another library like this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -o _example.so

If the foo library is compiled as a shared library, you might encounter the following problem when you try to use your module:

>>> import example
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: libfoo.so: cannot open shared object file: No such file or directory
>>>                 

This error is generated because the dynamic linker can't locate the libfoo.so library. When shared libraries are loaded, the system normally only checks a few standard locations such as /usr/lib and /usr/local/lib. To fix this problem, there are several things you can do. First, you can recompile your extension module with extra path information. For example, on Linux you can do this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -Xlinker -rpath /home/beazley/projects/lib  \
      -o _example.so

Alternatively, you can set the LD_LIBRARY_PATH environment variable to include the directory with your shared libraries. If setting LD_LIBRARY_PATH, be aware that setting this variable can introduce a noticeable performance impact on all other applications that you run. To set it only for Python, you might want to do this instead:

$ env LD_LIBRARY_PATH=/home/beazley/projects/lib python

Finally, you can use a command such as ldconfig (Linux) or crle (Solaris) to add additional search paths to the default system configuration (this requires root access and you will need to read the man pages).

36.2.6 Compilation of C++ extensions

Compilation of C++ extensions has traditionally been a tricky problem. Since the Python interpreter is written in C, you need to take steps to make sure C++ is properly initialized and that modules are compiled correctly. This should be a non-issue if you're using distutils, as it takes care of all that for you. The following is included for historical reasons, and in case you need to compile on your own.

On most machines, C++ extension modules should be linked using the C++ compiler. For example:

$ swig -c++ -python example.i
$ g++ -O2 -fPIC -c example.cxx
$ g++ -O2 -fPIC -c example_wrap.cxx -I/usr/local/include/python2.5
$ g++ -shared example.o example_wrap.o -o _example.so

The -fPIC option tells GCC to generate position-independent code (PIC) which is required for most architectures (it's not vital on x86, but still a good idea as it allows code pages from the library to be shared between processes). Other compilers may need a different option specified instead of -fPIC.

In addition to this, you may need to include additional library files to make it work. For example, if you are using the Sun C++ compiler on Solaris, you often need to add an extra library -lCrun like this:

$ swig -c++ -python example.i
$ CC -c example.cxx
$ CC -c example_wrap.cxx -I/usr/local/include/python2.5
$ CC -G example.o example_wrap.o -L/opt/SUNWspro/lib -o _example.so -lCrun

Of course, the extra libraries to use are completely non-portable---you will probably need to do some experimentation.

Sometimes people have suggested that it is necessary to relink the Python interpreter using the C++ compiler to make C++ extension modules work. In the experience of this author, this has never actually appeared to be necessary. Relinking the interpreter with C++ really only includes the special run-time libraries described above---as long as you link your extension modules with these libraries, it should not be necessary to rebuild Python.

If you aren't entirely sure about the linking of a C++ extension, you might look at an existing C++ program. On many Unix machines, the ldd command will list library dependencies. This should give you some clues about what you might have to include when you link your extension module. For example:

$ ldd swig
        libstdc++-libc6.1-1.so.2 => /usr/lib/libstdc++-libc6.1-1.so.2 (0x40019000)
        libm.so.6 => /lib/libm.so.6 (0x4005b000)
        libc.so.6 => /lib/libc.so.6 (0x40077000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

As a final complication, a major weakness of C++ is that it does not define any sort of standard for binary linking of libraries. This means that C++ code compiled by different compilers will not link together properly as libraries nor is the memory layout of classes and data structures implemented in any kind of portable manner. In a monolithic C++ program, this problem may be unnoticed. However, in Python, it is possible for different extension modules to be compiled with different C++ compilers. As long as these modules are self-contained, this probably won't matter. However, if these modules start sharing data, you will need to take steps to avoid segmentation faults and other erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

36.2.7 Compiling for 64-bit platforms

On platforms that support 64-bit applications (Solaris, Irix, etc.), special care is required when building extension modules. On these machines, 64-bit applications are compiled and linked using a different set of compiler/linker options. In addition, it is not generally possible to mix 32-bit and 64-bit code together in the same application.

To utilize 64-bits, the Python executable will need to be recompiled as a 64-bit application. In addition, all libraries, wrapper code, and every other part of your application will need to be compiled for 64-bits. If you plan to use other third-party extension modules, they will also have to be recompiled as 64-bit extensions.

If you are wrapping commercial software for which you have no source code, you will be forced to use the same linking standard as used by that software. This may prevent the use of 64-bit extensions. It may also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

On the Linux x86_64 platform (Opteron or EM64T), besides of the required compiler option -fPIC discussed above, you will need to be careful about the libraries you link with or the library path you use. In general, a Linux distribution will have two set of libraries, one for native x86_64 programs (under /usr/lib64), and another for 32 bits compatibility (under /usr/lib). Also, the compiler options -m32 and -m64 allow you to choose the desired binary format for your python extension.

36.2.8 Building Python Extensions under Windows

Building a SWIG extension to Python under Windows is roughly similar to the process used with Unix. Using the distutils, it is essentially identical. If you have the same version of the MS compiler that Python was built with (the python2.4 and python2.5 distributed by python.org are built with Visual Studio 2003), the standard python setup.py build should just work.

As of python2.5, the distutils support building extensions with MingGW out of the box. Following the instruction here: Building Python extensions for Windows with only free tools should get you started.

If you need to build it on your own, the following notes are provided:

You will need to create a DLL that can be loaded into the interpreter. This section briefly describes the use of SWIG with Microsoft Visual C++. As a starting point, many of SWIG's examples include project files (.dsp files) for Visual C++ 6. These can be opened by more recent versions of Visual Studio. You might want to take a quick look at these examples in addition to reading this section.

In Developer Studio, SWIG should be invoked as a custom build option. This is usually done as follows:

  • Open up a new workspace and use the AppWizard to select a DLL project.
  • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (ie. example_wrap.c). Note : If using C++, choose a different suffix for the wrapper file such as example_wrap.cxx. Don't worry if the wrapper file doesn't exist yet--Developer Studio keeps a reference to it.
  • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
  • Enter "SWIG" in the description field.
  • Enter "swig -python -o $(ProjDir)\$(InputName)_wrap.c $(InputPath)" in the "Build command(s) field"
  • Enter "$(ProjDir)\$(InputName)_wrap.c" in the "Output files(s) field".
  • Next, select the settings for the entire project and go to "C++:Preprocessor". Add the include directories for your Python installation under "Additional include directories".
  • Define the symbol __WIN32__ under preprocessor options.
  • Finally, select the settings for the entire project and go to "Link Options". Add the Python library file to your link libraries. For example "python21.lib". Also, set the name of the output file to match the name of your Python module, ie. _example.pyd - Note that _example.dll also worked with Python-2.4 and earlier.
  • Build your project.

If all went well, SWIG will be automatically invoked whenever you build your project. Any changes made to the interface file will result in SWIG being automatically executed to produce a new version of the wrapper file.

To run your new Python extension, simply run Python and use the import command as normal. For example :

$ python
>>> import example
>>> print example.fact(4)
24
>>>

If you get an ImportError exception when importing the module, you may have forgotten to include additional library files when you built your module. If you get an access violation or some kind of general protection fault immediately upon import, you have a more serious problem. This is often caused by linking your extension module against the wrong set of Win32 debug or thread libraries. You will have to fiddle around with the build options of project to try and track this down.

A 'Debug' build of the wrappers requires a debug build of the Python interpreter. This normally requires building the Python interpreter from source, which is not a job for the feint-hearted. Alternatively you can use the 'Release' build of the Python interpreter with a 'Debug' build of your wrappers by defining the SWIG_PYTHON_INTERPRETER_NO_DEBUG symbol under the preprocessor options. Or you can ensure this macro is defined at the beginning of the wrapper code using the following in your interface file, where _MSC_VER ensures it is only used by the Visual Studio compiler:

%begin %{
#ifdef _MSC_VER
#define SWIG_PYTHON_INTERPRETER_NO_DEBUG
#endif
%}

Some users have reported success in building extension modules using Cygwin and other compilers. However, the problem of building usable DLLs with these compilers tends to be rather problematic. For the latest information, you may want to consult the SWIG Wiki.

36.3 A tour of basic C/C++ wrapping

By default, SWIG tries to build a very natural Python interface to your C/C++ code. Functions are wrapped as functions, classes are wrapped as classes, and so forth. This section briefly covers the essential aspects of this wrapping.

36.3.1 Modules

The SWIG %module directive specifies the name of the Python module. If you specify `%module example', then everything is wrapped into a Python 'example' module. Underneath the covers, this module consists of a Python source file example.py and a low-level extension module _example.so. When choosing a module name, make sure you don't use the same name as a built-in Python command or standard module name.

36.3.2 Functions

Global functions are wrapped as new Python built-in functions. For example,

%module example
int fact(int n);

creates a built-in function example.fact(n) that works exactly like you think it does:

>>> import example
>>> print example.fact(4)
24
>>>

36.3.3 Global variables

C/C++ global variables are fully supported by SWIG. However, the underlying mechanism is somewhat different than you might expect due to the way that Python assignment works. When you type the following in Python

a = 3.4

"a" becomes a name for an object containing the value 3.4. If you later type

b = a

then "a" and "b" are both names for the object containing the value 3.4. Thus, there is only one object containing 3.4 and "a" and "b" are both names that refer to it. This is quite different than C where a variable name refers to a memory location in which a value is stored (and assignment copies data into that location). Because of this, there is no direct way to map variable assignment in C to variable assignment in Python.

To provide access to C global variables, SWIG creates a special object called `cvar' that is added to each SWIG generated module. Global variables are then accessed as attributes of this object. For example, consider this interface

// SWIG interface file with global variables
%module example
...
%inline %{
extern int My_variable;
extern double density;
%}
...

Now look at the Python interface:

>>> import example
>>> # Print out value of a C global variable
>>> print example.cvar.My_variable
4
>>> # Set the value of a C global variable
>>> example.cvar.density = 0.8442
>>> # Use in a math operation
>>> example.cvar.density = example.cvar.density*1.10

If you make an error in variable assignment, you will receive an error message. For example:

>>> example.cvar.density = "Hello"
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: C variable 'density (double )'
>>> 

If a variable is declared as const, it is wrapped as a read-only variable. Attempts to modify its value will result in an error.

To make ordinary variables read-only, you can use the %immutable directive. For example:

%{
extern char *path;
%}
%immutable;
extern char *path;
%mutable;

The %immutable directive stays in effect until it is explicitly disabled or cleared using %mutable. See the Creating read-only variables section for further details.

If you just want to make a specific variable immutable, supply a declaration name. For example:

%{
extern char *path;
%}
%immutable path;
...
extern char *path;      // Read-only (due to %immutable)

If you would like to access variables using a name other than "cvar", it can be changed using the -globals option :

$ swig -python -globals myvar example.i

Some care is in order when importing multiple SWIG modules. If you use the "from <file> import *" style of importing, you will get a name clash on the variable `cvar' and you will only be able to access global variables from the last module loaded. To prevent this, you might consider renaming cvar or making it private to the module by giving it a name that starts with a leading underscore. SWIG does not create cvar if there are no global variables in a module.

36.3.4 Constants and enums

C/C++ constants are installed as Python objects containing the appropriate value. To create a constant, use #define, enum, or the %constant directive. For example:

#define PI 3.14159
#define VERSION "1.0"

enum Beverage { ALE, LAGER, STOUT, PILSNER };

%constant int FOO = 42;
%constant const char *path = "/usr/local";

For enums, make sure that the definition of the enumeration actually appears in a header file or in the wrapper file somehow---if you just stick an enum in a SWIG interface without also telling the C compiler about it, the wrapper code won't compile.

Note: declarations declared as const are wrapped as read-only variables and will be accessed using the cvar object described in the previous section. They are not wrapped as constants. For further discussion about this, see the SWIG Basics chapter.

Constants are not guaranteed to remain constant in Python---the name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

36.3.5 Pointers

C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Here is a rather simple interface:

%module example

FILE *fopen(const char *filename, const char *mode);
int fputs(const char *, FILE *);
int fclose(FILE *);

When wrapped, you will be able to use the functions in a natural way from Python. For example:

>>> import example
>>> f = example.fopen("junk","w")
>>> example.fputs("Hello World\n", f)
>>> example.fclose(f)

If this makes you uneasy, rest assured that there is no deep magic involved. Underneath the covers, pointers to C/C++ objects are simply represented as opaque values using an especial python container object:

>>> print f
<Swig Object of type 'FILE *' at 0xb7d6f470>

This pointer value can be freely passed around to different C functions that expect to receive an object of type FILE *. The only thing you can't do is dereference the pointer from Python. Of course, that isn't much of a concern in this example.

In older versions of SWIG (1.3.22 or older), pointers were represented using a plain string object. If you have an old package that still requires that representation, or you just feel nostalgic, you can always retrieve it by casting the pointer object to a string:

>>> print str(f)
_c0671108_p_FILE

Also, if you need to pass the raw pointer value to some external python library, you can do it by casting the pointer object to an integer:

>>> print int(f)
135833352

However, the inverse operation is not possible, i.e., you can't build a SWIG pointer object from a raw integer value.

Note also that the '0' or NULL pointer is always represented by None, no matter what type swig is addressing. In the previous example, you can call:

>>> example.fclose(None)

and that will be equivalent to the following, but not really useful, C code:

FILE *f = NULL;
fclose(f);

As much as you might be inclined to modify a pointer value directly from Python, don't. The hexadecimal encoding is not necessarily the same as the logical memory address of the underlying object. Instead it is the raw byte encoding of the pointer value. The encoding will vary depending on the native byte-ordering of the platform (i.e., big-endian vs. little-endian). Similarly, don't try to manually cast a pointer to a new type by simply replacing the type-string. This may not work like you expect, it is particularly dangerous when casting C++ objects. If you need to cast a pointer or change its value, consider writing some helper functions instead. For example:

%inline %{
/* C-style cast */
Bar *FooToBar(Foo *f) {
   return (Bar *) f;
}

/* C++-style cast */
Foo *BarToFoo(Bar *b) {
   return dynamic_cast<Foo*>(b);
}

Foo *IncrFoo(Foo *f, int i) {
    return f+i;
}
%}

Also, if working with C++, you should always try to use the new C++ style casts. For example, in the above code, the C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

36.3.6 Structures

If you wrap a C structure, it is wrapped by a Python class. This provides a very natural interface. For example,

struct Vector {
	double x,y,z;
};

is used as follows:

>>> v = example.Vector()
>>> v.x = 3.5
>>> v.y = 7.2
>>> print v.x, v.y, v.z
7.8 -4.5 0.0
>>> 

Similar access is provided for unions and the data members of C++ classes.

If you print out the value of v in the above example, you will see something like this:

>>> print v
<C Vector instance at _18e31408_p_Vector>

This object is actually a Python instance that has been wrapped around a pointer to the low-level C structure. This instance doesn't actually do anything--it just serves as a proxy. The pointer to the C object can be found in the .this attribute. For example:

>>> print v.this
_18e31408_p_Vector
>>>

Further details about the Python proxy class are covered a little later.

const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive. For example:

struct Foo {
   ...
   %immutable;
   int x;        /* Read-only members */
   char *name;
   %mutable;
   ...
};

When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run with the -c++ option). When the structure member is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described later).

If a structure contains arrays, access to those arrays is managed through pointers. For example, consider this:

struct Bar {
    int  x[16];
};

If accessed in Python, you will see behavior like this:

>>> b = example.Bar()
>>> print b.x
_801861a4_p_int
>>> 

This pointer can be passed around to functions that expect to receive an int * (just like C). You can also set the value of an array member using another pointer. For example:

>>> c = example.Bar()
>>> c.x = b.x             # Copy contents of b.x to c.x

For array assignment, SWIG copies the entire contents of the array starting with the data pointed to by b.x. In this example, 16 integers would be copied. Like C, SWIG makes no assumptions about bounds checking---if you pass a bad pointer, you may get a segmentation fault or access violation.

When a member of a structure is itself a structure, it is handled as a pointer. For example, suppose you have two structures like this:

struct Foo {
   int a;
};

struct Bar {
   Foo f;
};

Now, suppose that you access the f attribute of Bar like this:

>>> b = Bar()
>>> x = b.f

In this case, x is a pointer that points to the Foo that is inside b. This is the same value as generated by this C code:

Bar b;
Foo *x = &b->f;       /* Points inside b */

Because the pointer points inside the structure, you can modify the contents and everything works just like you would expect. For example:

>>> b = Bar()
>>> b.f.a = 3               # Modify attribute of structure member
>>> x = b.f                   
>>> x.a = 3                 # Modifies the same structure

36.3.7 C++ classes

C++ classes are wrapped by Python classes as well. For example, if you have this class,

class List {
public:
  List();
  ~List();
  int  search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int  length;
};

you can use it in Python like this:

>>> l = example.List()
>>> l.insert("Ale")
>>> l.insert("Stout")
>>> l.insert("Lager")
>>> l.get(1)
'Stout'
>>> print l.length
3
>>>

Class data members are accessed in the same manner as C structures.

Static class members present a special problem for Python. Prior to Python-2.2, Python classes had no support for static methods and no version of Python supports static member variables in a manner that SWIG can utilize. Therefore, SWIG generates wrappers that try to work around some of these issues. To illustrate, suppose you have a class like this:

class Spam {
public:
   static void foo();
   static int bar;

};

In Python, the static member can be access in three different ways:

>>> example.Spam_foo()    # Spam::foo()
>>> s = example.Spam()
>>> s.foo()               # Spam::foo() via an instance
>>> example.Spam.foo()    # Spam::foo(). Python-2.2 only

The first two methods of access are supported in all versions of Python. The last technique is only available in Python-2.2 and later versions.

Static member variables are currently accessed as global variables. This means, they are accessed through cvar like this:

>>> print example.cvar.Spam_bar
7

36.3.8 C++ inheritance

SWIG is fully aware of issues related to C++ inheritance. Therefore, if you have classes like this

class Foo {
...
};

class Bar : public Foo {
...
};

those classes are wrapped into a hierarchy of Python classes that reflect the same inheritance structure. All of the usual Python utility functions work normally:

>>> b = Bar()
>>> instance(b,Foo)
1
>>> issubclass(Bar,Foo)
1
>>> issubclass(Foo,Bar)
0

Furthermore, if you have functions like this

void spam(Foo *f);

then the function spam() accepts Foo * or a pointer to any class derived from Foo.

It is safe to use multiple inheritance with SWIG.

36.3.9 Pointers, references, values, and arrays

In C++, there are many different ways a function might receive and manipulate objects. For example:

void spam1(Foo *x);      // Pass by pointer
void spam2(Foo &x);      // Pass by reference
void spam3(const Foo &x);// Pass by const reference
void spam4(Foo x);       // Pass by value
void spam5(Foo x[]);     // Array of objects

In Python, there is no detailed distinction like this--specifically, there are only "objects". There are no pointers, references, arrays, and so forth. Because of this, SWIG unifies all of these types together in the wrapper code. For instance, if you actually had the above functions, it is perfectly legal to do this:

>>> f = Foo()           # Create a Foo
>>> spam1(f)            # Ok. Pointer
>>> spam2(f)            # Ok. Reference
>>> spam3(f)            # Ok. Const reference
>>> spam4(f)            # Ok. Value.
>>> spam5(f)            # Ok. Array (1 element)

Similar behavior occurs for return values. For example, if you had functions like this,

Foo *spam6();
Foo &spam7();
Foo  spam8();
const Foo &spam9();

then all three functions will return a pointer to some Foo object. Since the third function (spam8) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Python will release this memory when the return value is garbage collected). The fourth case (spam9) which returns a const reference, in most of the cases will be treated as a returning value, and it will follow the same allocation/deallocation process.

36.3.10 C++ overloaded functions

C++ overloaded functions, methods, and constructors are mostly supported by SWIG. For example, if you have two functions like this:

void foo(int);
void foo(char *c);

You can use them in Python in a straightforward manner:

>>> foo(3)           # foo(int)
>>> foo("Hello")     # foo(char *c)

Similarly, if you have a class like this,

class Foo {
public:
    Foo();
    Foo(const Foo &);
    ...
};

you can write Python code like this:

>>> f = Foo()          # Create a Foo
>>> g = Foo(f)         # Copy f

Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG can't disambiguate. For example:

void spam(int);
void spam(short);

or

void foo(Bar *b);
void foo(Bar &b);

If declarations such as these appear, you will get a warning message like this:

example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).

To fix this, you either need to ignore or rename one of the methods. For example:

%rename(spam_short) spam(short);
...
void spam(int);    
void spam(short);   // Accessed as spam_short

or

%ignore spam(short);
...
void spam(int);    
void spam(short);   // Ignored

SWIG resolves overloaded functions and methods using a disambiguation scheme that ranks and sorts declarations according to a set of type-precedence rules. The order in which declarations appear in the input does not matter except in situations where ambiguity arises--in this case, the first declaration takes precedence.

Please refer to the "SWIG and C++" chapter for more information about overloading.

36.3.11 C++ operators

Certain C++ overloaded operators can be handled automatically by SWIG. For example, consider a class like this:

class Complex {
private:
  double rpart, ipart;
public:
  Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
  Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
  Complex &operator=(const Complex &c);

  Complex operator+=(const Complex &c) const;
  Complex operator+(const Complex &c) const;
  Complex operator-(const Complex &c) const;
  Complex operator*(const Complex &c) const;
  Complex operator-() const;
  
  double re() const { return rpart; }
  double im() const { return ipart; }
};

When wrapped, it works like you expect:

>>> c = Complex(3,4)
>>> d = Complex(7,8)
>>> e = c + d
>>> e.re()
10.0
>>> e.im()
12.0
>>> c += d
>>> c.re()
10.0
>>> c.im()
12.0

One restriction with operator overloading support is that SWIG is not able to fully handle operators that aren't defined as part of the class. For example, if you had code like this

class Complex {
...
friend Complex operator+(double, const Complex &c);
...
};

then SWIG ignores it and issues a warning. You can still wrap the operator, but you may have to encapsulate it in a special function. For example:

%rename(Complex_add_dc) operator+(double, const Complex &);

There are ways to make this operator appear as part of the class using the %extend directive. Keep reading.

Also, be aware that certain operators don't map cleanly to Python. For instance, overloaded assignment operators don't map to Python semantics and will be ignored.

36.3.12 C++ namespaces

SWIG is aware of C++ namespaces, but namespace names do not appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

%module example

namespace foo {
   int fact(int n);
   struct Vector {
       double x,y,z;
   };
};

it works in Python as follows:

>>> import example
>>> example.fact(3)
6
>>> v = example.Vector()
>>> v.x = 3.4
>>> print v.y
0.0
>>>

If your program has more than one namespace, name conflicts (if any) can be resolved using %rename For example:

%rename(Bar_spam) Bar::spam;

namespace Foo {
    int spam();
}

namespace Bar {
    int spam();
}

If you have more than one namespace and your want to keep their symbols separate, consider wrapping them as separate SWIG modules. For example, make the module name the same as the namespace and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

36.3.13 C++ templates

C++ templates don't present a huge problem for SWIG. However, in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the %template directive. For example:

%module example
%{
#include "pair.h"
%}

template<class T1, class T2>
struct pair {
   typedef T1 first_type;
   typedef T2 second_type;
   T1 first;
   T2 second;
   pair();
   pair(const T1&, const T2&);
  ~pair();
};

%template(pairii) pair<int,int>;

In Python:

>>> import example
>>> p = example.pairii(3,4)
>>> p.first
3
>>> p.second
4

Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.

36.3.14 C++ Smart Pointers

In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

template<class T> class SmartPtr {
   ...
   T *operator->();
   ...
}

Then, if you have a class like this,

class Foo {
public:
     int x;
     int bar();
};

A smart pointer would be used in C++ as follows:

SmartPtr<Foo> p = CreateFoo();   // Created somehow (not shown)
...
p->x = 3;                        // Foo::x
int y = p->bar();                // Foo::bar

To wrap this in Python, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using %template if necessary. For example:

%module example
...
%template(SmartPtrFoo) SmartPtr<Foo>;
...

Now, in Python, everything should just "work":

>>> p = example.CreateFoo()          # Create a smart-pointer somehow
>>> p.x = 3                          # Foo::x
>>> p.bar()                          # Foo::bar

If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

>>> f = p.__deref__()     # Returns underlying Foo *

36.3.15 C++ reference counted objects

The C++ reference counted objects section contains Python examples of memory management using referencing counting.

36.4 Further details on the Python class interface

In the previous section, a high-level view of Python wrapping was presented. A key component of this wrapping is that structures and classes are wrapped by Python proxy classes. This provides a very natural Python interface and allows SWIG to support a number of advanced features such as operator overloading. However, a number of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

New in SWIG version 2.0.4: The use of Python proxy classes has performance implications that may be unacceptable for a high-performance library. The new -builtin option instructs SWIG to forego the use of proxy classes, and instead create wrapped types as new built-in Python types. When this option is used, the following section ("Proxy classes") does not apply. Details on the use of the -builtin option are in the Built-in Types section.

36.4.1 Proxy classes

In the "SWIG basics" and "SWIG and C++" chapters, details of low-level structure and class wrapping are described. To summarize those chapters, if you have a class like this

class Foo {
public:
     int x;
     int spam(int);
     ...

then SWIG transforms it into a set of low-level procedural wrappers. For example:

Foo *new_Foo() {
    return new Foo();
}
void delete_Foo(Foo *f) {
    delete f;
}
int Foo_x_get(Foo *f) {
    return f->x;
}
void Foo_x_set(Foo *f, int value) {
    f->x = value;
}
int Foo_spam(Foo *f, int arg1) {
    return f->spam(arg1);
}

These wrappers can be found in the low-level extension module (e.g., _example).

Using these wrappers, SWIG generates a high-level Python proxy class (also known as a shadow class) like this (shown for Python 2.2):

import _example

class Foo(object):
     def __init__(self):
         self.this = _example.new_Foo()
         self.thisown = 1
     def __del__(self):
         if self.thisown:
               _example.delete_Foo(self.this)
     def spam(self,arg1):
         return _example.Foo_spam(self.this,arg1)
     x = property(_example.Foo_x_get, _example.Foo_x_set)

This class merely holds a pointer to the underlying C++ object (.this) and dispatches methods and member variable access to that object using the low-level accessor functions. From a user's point of view, it makes the class work normally:

>>> f = example.Foo()
>>> f.x = 3
>>> y = f.spam(5)

The fact that the class has been wrapped by a real Python class offers certain advantages. For instance, you can attach new Python methods to the class and you can even inherit from it (something not supported by Python built-in types until Python 2.2).

36.4.2 Built-in Types

The -builtin option provides a significant performance improvement in the wrapped code. To understand the difference between proxy classes and built-in types, let's take a look at what a wrapped object looks like under both circumstances.

When proxy classes are used, each wrapped object in python is an instance of a pure python class. As a reminder, here is what the __init__ method looks like in a proxy class:

class Foo(object):
     def __init__(self):
         self.this = _example.new_Foo()
         self.thisown = 1

When a Foo instance is created, the call to _example.new_Foo() creates a new C++ Foo instance; wraps that C++ instance inside an instance of a python built-in type called SwigPyObject; and stores the SwigPyObject instance in the 'this' field of the python Foo object. Did you get all that? So, the python Foo object is composed of three parts:

  • The python Foo instance, which contains...
  • ... an instance of struct SwigPyObject, which contains...
  • ... a C++ Foo instance

When -builtin is used, the pure python layer is stripped off. Each wrapped class is turned into a new python built-in type which inherits from SwigPyObject, and SwigPyObject instances are returned directly from the wrapped methods. For more information about python built-in extensions, please refer to the python documentation:

http://docs.python.org/extending/newtypes.html

36.4.2.1 Limitations

Use of the -builtin option implies a couple of limitations:

  • python version support:

    • Versions 2.5 and up are fully supported
    • Versions 2.3 and 2.4 are mostly supported; there are problems with director classes and/or sub-classing a wrapped type in python.
    • Versions older than 2.3 are not supported.
  • Some legacy syntax is no longer supported; in particular:

    • The functional interface is no longer exposed. For example, you may no longer call Whizzo.new_CrunchyFrog(). Instead, you must use Whizzo.CrunchyFrog().
    • Static member variables are no longer accessed through the 'cvar' field (e.g., Dances.cvar.FishSlap). They are instead accessed in the idiomatic way (Dances.FishSlap).
  • Wrapped types may not be raised as python exceptions. Here's why: the python internals expect that all sub-classes of Exception will have this struct layout:

    typedef struct {
        PyObject_HEAD
        PyObject *dict;
        PyObject *args;
        PyObject *message;
    } PyBaseExceptionObject;
    

    But swig-generated wrappers expect that all swig-wrapped classes will have this struct layout:

    typedef struct {
        PyObject_HEAD
        void *ptr;
        swig_type_info *ty;
        int own;
        PyObject *next;
        PyObject *dict;
    } SwigPyObject;
    

    There are workarounds for this. For example, if you wrap this class:

    class MyException {
    public:
        MyException (const char *msg_);
        ~MyException ();
    
        const char *what () const;
    
    private:
        char *msg;
    };
    

    ... you can define this python class, which may be raised as an exception:

    class MyPyException (Exception) :
        def __init__(self, msg, *args) :
            Exception.__init__(self, *args)
            self.myexc = MyException(msg)
        def what (self) :
            return self.myexc.what()
    
  • Reverse binary operators (e.g., __radd__) are not supported.

    To illustrate this point, if you have a wrapped class called MyString, and you want to use instances of MyString interchangeably with native python strings, you can define an 'operator+ (const char*)' method :

    class MyString {
    public:
        MyString (const char *init);
        MyString operator+ (const char *other) const;
        ...
    };
    

    SWIG will automatically create an operator overload in python that will allow this:

    from MyModule import MyString
    
    mystr = MyString("No one expects")
    episode = mystr + " the Spanish Inquisition"
    

    This works because the first operand (mystr) defines a way to add a native string to itself. However, the following will not work:

    from MyModule import MyString
    
    mystr = MyString("Parrot")
    episode = "Dead " + mystr
    

    The above code fails, because the first operand -- a native python string -- doesn't know how to add an instance of MyString to itself.

  • If you have multiple SWIG modules that share type information (more info), the -builtin option requires a bit of extra discipline to ensure that base classes are initialized before derived classes. Specifically:

    • There must be an unambiguous dependency graph for the modules.

    • Module dependencies must be explicitly stated with %import statements in the SWIG interface file.

    As an example, suppose module A has this interface in A.i :

    %module "A";
    
    class Base {
    ...
    };
    

    If you want to wrap another module containing a class that inherits from A, this is how it would look :

    %module "B";
    
    %import "A.i"
    
    class Derived : public Base {
    ...
    };
    

    The import "A.i" statement is required, because module B depends on module A.

    As long as you obey these requirements, your python code may import the modules in any order :

    import B
    import A
    
    assert(issubclass(B.Derived, A.Base))
    

36.4.2.2 Operator overloads -- use them!

The entire justification for the -builtin option is improved performance. To that end, the best way to squeeze maximum performance out of your wrappers is to use operator overloads. Named method dispatch is slow in python, even when compared to other scripting languages. However, python built-in types have a large number of "slots", analogous to C++ operator overloads, which allow you to short-circuit named method dispatch for certain common operations.

By default, SWIG will translate most C++ arithmetic operator overloads into python slot entries. For example, suppose you have this class:

class Twit {
public:
    Twit operator+ (const Twit& twit) const;

    // Forward to operator+
    Twit add (const Twit& twit) const
    { return *this + twit; }
};

SWIG will automatically register operator+ as a python slot operator for addition. You may write python code like this:

from MyModule import Twit

nigel = Twit()
emily = Twit()
percival = nigel + emily
percival = nigel.add(emily)

The last two lines of the python code are equivalent, but the line that uses the '+' operator is much faster.

In-place operators (e.g., operator+=) and comparison operators (operator==, operator<, etc.) are also converted to python slot operators. For a complete list of C++ operators that are automatically converted to python slot operators, refer to the file python/pyopers.swig in the SWIG library.

There are other very useful python slots that you may explicitly define using %feature directives. For example, suppose you want to use instances of a wrapped class as keys in a native python dict. That will work as long as you define a hash function for instances of your class, and use it to define the python tp_hash slot:

%feature("python:slot", "tp_hash", functype="hashfunc") Cheese::cheeseHashFunc;

class Cheese {
public:
    Cheese (const char *name);
    long cheeseHashFunc () const;
};

This will allow you to write python code like this:

from my MyPackage import Cheese

inventory = {
    Cheese("cheddar") : 0,
    Cheese("gouda") : 0,
    Cheese("camembert") : 0
}

Because you defined the tp_hash slot, Cheese objects may be used as hash keys; and when the cheeseHashFunc method is invoked by a python dict, it will not go through named method dispatch. A more detailed discussion about %feature("python:slot") can be found in the file python/pyopers.swig in the SWIG library. You can read about all of the available python slots here:

http://docs.python.org/c-api/typeobj.html

You may override (almost) all of the slots defined in the PyTypeObject, PyNumberMethods, PyMappingMethods, PySequenceMethods, and PyBufferProcs structs.

36.4.3 Memory management

NOTE: Although this section refers to proxy objects, everything here also applies when the -builtin option is used.

Associated with proxy object, is an ownership flag .thisown The value of this flag determines who is responsible for deleting the underlying C++ object. If set to 1, the Python interpreter will destroy the C++ object when the proxy class is garbage collected. If set to 0 (or if the attribute is missing), then the destruction of the proxy class has no effect on the C++ object.

When an object is created by a constructor or returned by value, Python automatically takes ownership of the result. For example:

class Foo {
public:
    Foo();
    Foo bar();
};

In Python:

>>> f = Foo()
>>> f.thisown
1
>>> g = f.bar()
>>> g.thisown
1

On the other hand, when pointers are returned to Python, there is often no way to know where they came from. Therefore, the ownership is set to zero. For example:

class Foo {
public:
    ...
    Foo *spam();
    ...
};

>>> f = Foo()
>>> s = f.spam()
>>> print s.thisown
0
>>>

This behavior is especially important for classes that act as containers. For example, if a method returns a pointer to an object that is contained inside another object, you definitely don't want Python to assume ownership and destroy it!

A good way to indicate that ownership should be set for a returned pointer is to use the %newobject directive.

Related to containers, ownership issues can arise whenever an object is assigned to a member or global variable. For example, consider this interface:

%module example

struct Foo {
    int  value;
    Foo  *next;
};

Foo *head = 0;

When wrapped in Python, careful observation will reveal that ownership changes whenever an object is assigned to a global variable. For example:

>>> f = example.Foo()
>>> f.thisown
1
>>> example.cvar.head = f           
>>> f.thisown
0
>>>

In this case, C is now holding a reference to the object---you probably don't want Python to destroy it. Similarly, this occurs for members. For example:

>>> f = example.Foo()
>>> g = example.Foo()
>>> f.thisown
1
>>> g.thisown
1
>>> f.next = g
>>> g.thisown
0
>>>

For the most part, memory management issues remain hidden. However, there are occasionally situations where you might have to manually change the ownership of an object. For instance, consider code like this:

class Node {
   Object *value;
public:
   void set_value(Object *v) { value = v; }
   ...
};

Now, consider the following Python code:

>>> v = Object()           # Create an object
>>> n = Node()             # Create a node
>>> n.set_value(v)         # Set value
>>> v.thisown
1
>>> del v

In this case, the object n is holding a reference to v internally. However, SWIG has no way to know that this has occurred. Therefore, Python still thinks that it has ownership of the object. Should the proxy object be destroyed, then the C++ destructor will be invoked and n will be holding a stale-pointer. If you're lucky, you will only get a segmentation fault.

To work around this, it is always possible to flip the ownership flag. For example,

>>> v.thisown = 0

It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

36.4.4 Python 2.2 and classic classes

SWIG makes every attempt to preserve backwards compatibility with older versions of Python to the extent that it is possible. However, in Python-2.2, an entirely new type of class system was introduced. This new-style class system offers many enhancements including static member functions, properties (managed attributes), and class methods. Details about all of these changes can be found on www.python.org and is not repeated here.

To address differences between Python versions, SWIG currently emits dual-mode proxy class wrappers. In Python-2.2 and newer releases, these wrappers encapsulate C++ objects in new-style classes that take advantage of new features (static methods and properties). However, if these very same wrappers are imported into an older version of Python, old-style classes are used instead.

This dual-nature of the wrapper code means that you can create extension modules with SWIG and those modules will work with all versions of Python ranging from Python-1.4 to the very latest release. Moreover, the wrappers take advantage of Python-2.2 features when available.

For the most part, the interface presented to users is the same regardless of what version of Python is used. The only incompatibility lies in the handling of static member functions. In Python-2.2, they can be accessed via the class itself. In Python-2.1 and earlier, they have to be accessed as a global function or through an instance (see the earlier section).

36.5 Cross language polymorphism

Proxy classes provide a more natural, object-oriented way to access extension classes. As described above, each proxy instance has an associated C++ instance, and method calls to the proxy are passed to the C++ instance transparently via C wrapper functions.

This arrangement is asymmetric in the sense that no corresponding mechanism exists to pass method calls down the inheritance chain from C++ to Python. In particular, if a C++ class has been extended in Python (by extending the proxy class), these extensions will not be visible from C++ code. Virtual method calls from C++ are thus not able access the lowest implementation in the inheritance chain.

Changes have been made to SWIG 1.3.18 to address this problem and make the relationship between C++ classes and proxy classes more symmetric. To achieve this goal, new classes called directors are introduced at the bottom of the C++ inheritance chain. The job of the directors is to route method calls correctly, either to C++ implementations higher in the inheritance chain or to Python implementations lower in the inheritance chain. The upshot is that C++ classes can be extended in Python and from C++ these extensions look exactly like native C++ classes. Neither C++ code nor Python code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

36.5.1 Enabling directors

The director feature is disabled by default. To use directors you must make two changes to the interface file. First, add the "directors" option to the %module directive, like this:

%module(directors="1") modulename

Without this option no director code will be generated. Second, you must use the %feature("director") directive to tell SWIG which classes and methods should get directors. The %feature directive can be applied globally, to specific classes, and to specific methods, like this:

// generate directors for all classes that have virtual methods
%feature("director");         

// generate directors for all virtual methods in class Foo
%feature("director") Foo;      

You can use the %feature("nodirector") directive to turn off directors for specific classes or methods. So for example,

%feature("director") Foo;
%feature("nodirector") Foo::bar;

will generate directors for all virtual methods of class Foo except bar().

Directors can also be generated implicitly through inheritance. In the following, class Bar will get a director class that handles the methods one() and two() (but not three()):

%feature("director") Foo;
class Foo {
public:
    Foo(int foo);
    virtual void one();
    virtual void two();
};

class Bar: public Foo {
public:
    virtual void three();
};

then at the python side you can define

import mymodule

class MyFoo(mymodule.Foo):
  def __init__(self, foo):
     mymodule.Foo(self, foo)  

  def one(self):
     print "one from python"

36.5.2 Director classes

For each class that has directors enabled, SWIG generates a new class that derives from both the class in question and a special Swig::Director class. These new classes, referred to as director classes, can be loosely thought of as the C++ equivalent of the Python proxy classes. The director classes store a pointer to their underlying Python object and handle various issues related to object ownership. Indeed, this is quite similar to the "this" and "thisown" members of the Python proxy classes.

For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). Thus all virtual method calls, whether they originate in C++ or in Python via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate place" we mean the method that would have been called if the C++ base class and its extensions in Python were seamlessly integrated. That seamless integration is exactly what the director classes provide, transparently skipping over all the messy extension API glue that binds the two languages together.

In reality, the "appropriate place" is one of only two possibilities: C++ or Python. Once this decision is made, the rest is fairly easy. If the correct implementation is in C++, then the lowest implementation of the method in the C++ inheritance chain is called explicitly. If the correct implementation is in Python, the Python API is used to call the method of the underlying Python object (after which the usual virtual method resolution in Python automatically finds the right implementation).

Now how does the director decide which language should handle the method call? The basic rule is to handle the method in Python, unless there's a good reason not to. The reason for this is simple: Python has the most "extended" implementation of the method. This assertion is guaranteed, since at a minimum the Python proxy class implements the method. If the method in question has been extended by a class derived from the proxy class, that extended implementation will execute exactly as it should. If not, the proxy class will route the method call into a C wrapper function, expecting that the method will be resolved in C++. The wrapper will call the virtual method of the C++ instance, and since the director extends this the call will end up right back in the director method. Now comes the "good reason not to" part. If the director method were to blindly call the Python method again, it would get stuck in an infinite loop. We avoid this situation by adding special code to the C wrapper function that tells the director method to not do this. The C wrapper function compares the pointer to the Python object that called the wrapper function to the pointer stored by the director. If these are the same, then the C wrapper function tells the director to resolve the method by calling up the C++ inheritance chain, preventing an infinite loop.

One more point needs to be made about the relationship between director classes and proxy classes. When a proxy class instance is created in Python, SWIG creates an instance of the original C++ class and assigns it to .this. This is exactly what happens without directors and is true even if directors are enabled for the particular class in question. When a class derived from a proxy class is created, however, SWIG then creates an instance of the corresponding C++ director class. The reason for this difference is that user-defined subclasses may override or extend methods of the original class, so the director class is needed to route calls to these methods correctly. For unmodified proxy classes, all methods are ultimately implemented in C++ so there is no need for the extra overhead involved with routing the calls through Python.

36.5.3 Ownership and object destruction

Memory management issues are slightly more complicated with directors than for proxy classes alone. Python instances hold a pointer to the associated C++ director object, and the director in turn holds a pointer back to the Python object. By default, proxy classes own their C++ director object and take care of deleting it when they are garbage collected.

This relationship can be reversed by calling the special __disown__() method of the proxy class. After calling this method, the .thisown flag is set to zero, and the director class increments the reference count of the Python object. When the director class is deleted it decrements the reference count. Assuming no outstanding references to the Python object remain, the Python object will be destroyed at the same time. This is a good thing, since directors and proxies refer to each other and so must be created and destroyed together. Destroying one without destroying the other will likely cause your program to segfault.

To help ensure that no references to the Python object remain after calling __disown__(), this method returns a weak reference to the Python object. Weak references are only available in Python versions 2.1 and higher, so for older versions you must explicitly delete all references. Here is an example:

class Foo {
public:
    ...
};
class FooContainer {
public:
    void addFoo(Foo *);
    ...
};

>>> c = FooContainer()
>>> a = Foo().__disown__()
>>> c.addFoo(a)
>>> b = Foo()
>>> b = b.__disown__()
>>> c.addFoo(b)
>>> c.addFoo(Foo().__disown__())

In this example, we are assuming that FooContainer will take care of deleting all the Foo pointers it contains at some point. Note that no hard references to the Foo objects remain in Python.

36.5.4 Exception unrolling

With directors routing method calls to Python, and proxies routing them to C++, the handling of exceptions is an important concern. By default, the directors ignore exceptions that occur during method calls that are resolved in Python. To handle such exceptions correctly, it is necessary to temporarily translate them into C++ exceptions. This can be done with the %feature("director:except") directive. The following code should suffice in most cases:

%feature("director:except") {
    if ($error != NULL) {
        throw Swig::DirectorMethodException();
    }
}

This code will check the Python error state after each method call from a director into Python, and throw a C++ exception if an error occurred. This exception can be caught in C++ to implement an error handler. Currently no information about the Python error is stored in the Swig::DirectorMethodException object, but this will likely change in the future.

It may be the case that a method call originates in Python, travels up to C++ through a proxy class, and then back into Python via a director method. If an exception occurs in Python at this point, it would be nice for that exception to find its way back to the original caller. This can be done by combining a normal %exception directive with the director:except handler shown above. Here is an example of a suitable exception handler:

%exception {
    try { $action }
    catch (Swig::DirectorException &e) { SWIG_fail; }
}

The class Swig::DirectorException used in this example is actually a base class of Swig::DirectorMethodException, so it will trap this exception. Because the Python error state is still set when Swig::DirectorMethodException is thrown, Python will register the exception as soon as the C wrapper function returns.

36.5.5 Overhead and code bloat

Enabling directors for a class will generate a new director method for every virtual method in the class' inheritance chain. This alone can generate a lot of code bloat for large hierarchies. Method arguments that require complex conversions to and from target language types can result in large director methods. For this reason it is recommended that you selectively enable directors only for specific classes that are likely to be extended in Python and used in C++.

Compared to classes that do not use directors, the call routing in the director methods does add some overhead. In particular, at least one dynamic cast and one extra function call occurs per method call from Python. Relative to the speed of Python execution this is probably completely negligible. For worst case routing, a method call that ultimately resolves in C++ may take one extra detour through Python in order to ensure that the method does not have an extended Python implementation. This could result in a noticeable overhead in some cases.

Although directors make it natural to mix native C++ objects with Python objects (as director objects) via a common base class pointer, one should be aware of the obvious fact that method calls to Python objects will be much slower than calls to C++ objects. This situation can be optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in Python.

36.5.6 Typemaps

Typemaps for input and output of most of the basic types from director classes have been written. These are roughly the reverse of the usual input and output typemaps used by the wrapper code. The typemap operation names are 'directorin', 'directorout', and 'directorargout'. The director code does not currently use any of the other kinds of typemaps. It is not clear at this point which kinds are appropriate and need to be supported.

36.5.7 Miscellaneous

Director typemaps for STL classes are in place, and hence you should be able to use std::vector, std::string, etc., as you would any other type.

Note: The director typemaps for return types based in const references, such as

class Foo {
…
    virtual const int& bar();
…
};

will work only for simple call scenarios. Usually the resulting code is neither thread or reentrant safe. Hence, the user is advised to avoid returning const references in director methods. For example, the user could modify the method interface to use lvalue return types, wherever possible, for example

class Foo {
…
    virtual int bar();
…
};

If that is not possible, the user should avoid enabling the director feature for reentrant, recursive or threaded member methods that return const references.

36.6 Common customization features

The last section presented the absolute basics of C/C++ wrapping. If you do nothing but feed SWIG a header file, you will get an interface that mimics the behavior described. However, sometimes this isn't enough to produce a nice module. Certain types of functionality might be missing or the interface to certain functions might be awkward. This section describes some common SWIG features that are used to improve your the interface to an extension module.

36.6.1 C/C++ helper functions

Sometimes when you create a module, it is missing certain bits of functionality. For example, if you had a function like this

void set_transform(Image *im, double m[4][4]);

it would be accessible from Python, but there may be no easy way to call it. For example, you might get errors like this:

>>> a = [
...   [1,0,0,0],
...   [0,1,0,0],
...   [0,0,1,0],
...   [0,0,0,1]]
>>> set_transform(im,a)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: Type error. Expected _p_a_4__double

The problem here is that there is no easy way to construct and manipulate a suitable double [4][4] value to use. To fix this, you can write some extra C helper functions. Just use the %inline directive. For example:

%inline %{
/* Note: double[4][4] is equivalent to a pointer to an array double (*)[4] */
double (*new_mat44())[4] {
   return (double (*)[4]) malloc(16*sizeof(double));
}
void free_mat44(double (*x)[4]) {
   free(x);
}
void mat44_set(double x[4][4], int i, int j, double v) {
   x[i][j] = v;
}
double mat44_get(double x[4][4], int i, int j) {
   return x[i][j];
}
%}

From Python, you could then write code like this:

>>> a = new_mat44()
>>> mat44_set(a,0,0,1.0)
>>> mat44_set(a,1,1,1.0)
>>> mat44_set(a,2,2,1.0)
...
>>> set_transform(im,a)
>>>

Admittedly, this is not the most elegant looking approach. However, it works and it wasn't too hard to implement. It is possible to clean this up using Python code, typemaps, and other customization features as covered in later sections.

36.6.2 Adding additional Python code

If writing support code in C isn't enough, it is also possible to write code in Python. This code gets inserted in to the .py file created by SWIG. One use of Python code might be to supply a high-level interface to certain functions. For example:

void set_transform(Image *im, double x[4][4]);

...
/* Rewrite the high level interface to set_transform */
%pythoncode %{
def set_transform(im,x):
   a = new_mat44()
   for i in range(4):
       for j in range(4):
           mat44_set(a,i,j,x[i][j])
   _example.set_transform(im,a)
   free_mat44(a)
%}

In this example, set_transform() provides a high-level Python interface built on top of low-level helper functions. For example, this code now seems to work:

>>> a = [
...   [1,0,0,0],
...   [0,1,0,0],
...   [0,0,1,0],
...   [0,0,0,1]]
>>> set_transform(im,a)
>>>

Admittedly, this whole scheme for wrapping the two-dimension array argument is rather ad-hoc. Besides, shouldn't a Python list or a Numeric Python array just work normally? We'll get to those examples soon enough. For now, think of this example as an illustration of what can be done without having to rely on any of the more advanced customization features.

There is also %pythonbegin which is another directive very similar to %pythoncode, but generates the given Python code at the beginning of the .py file. This directive works in the same way as %pythoncode, except the code is copied just after the SWIG banner (comment) at the top of the file, before any real code. This provides an opportunity to add your own description in a comment near the top of the file as well as Python imports that have to appear at the top of the file, such as "from __future__ import" statements.

The following shows example usage for Python 2.6 to use print as it can in Python 3, that is, as a function instead of a statement:

%pythonbegin %{
# This module provides wrappers to the Whizz Bang library
%}

%pythonbegin %{
from __future__ import print_function
print("Loading", "Whizz", "Bang", sep=' ... ')
%}

which can be seen when viewing the first few lines of the generated .py file:

# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.11
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.

# This module provides wrappers to the Whizz Bang library

from __future__ import print_function
print("Loading", "Whizz", "Bang", sep=' ... ')

Sometimes you may want to replace or modify the wrapper function that SWIG creates in the proxy .py file. The Python module in SWIG provides some features that enable you to do this. First, to entirely replace a proxy function you can use %feature("shadow"). For example:

%module example

// Rewrite bar() python code

%feature("shadow") Foo::bar(int) %{
def bar(*args):
    #do something before
    $action
    #do something after
%}
    
class Foo {
public:
    int bar(int x);
}

where $action will be replaced by the call to the C/C++ proper method.

Often the proxy function created by SWIG is fine, but you simply want to add code to it without touching the rest of the generated function body. For these cases SWIG provides the pythonprepend and pythonappend features which do exactly as their names suggest. The pythonprepend feature will insert its value at the beginning of the proxy function, and pythonappend will insert code at the end of the proxy, just before the return statement.

%module example

// Add python code to bar() 

%feature("pythonprepend") Foo::bar(int) %{
   #do something before C++ call
%}

%feature("pythonappend") Foo::bar(int) %{
   #do something after C++ call
%}

    
class Foo {
public:
    int bar(int x);
}

Notes: Usually the pythonappend and pythonprepend features are safer to use than the shadow feature. Also, from SWIG version 1.3.28 you can use the directive forms %pythonappend and %pythonprepend as follows:

%module example

// Add python code to bar() 

%pythonprepend Foo::bar(int) %{
   #do something before C++ call
%}

%pythonappend Foo::bar(int) %{
   #do something after C++ call
%}

    
class Foo {
public:
    int bar(int x);
}

Note that when the underlying C++ method is overloaded, there is only one proxy Python method for multiple C++ methods. In this case, only one of parsed methods is examined for the feature. You are better off specifying the feature without the argument list to ensure it will get used, as it will then get attached to all the overloaded C++ methods. For example:

%module example

// Add python code to bar()

%pythonprepend Foo::bar %{
   #do something before C++ call
%}

%pythonappend Foo::bar %{
   #do something after C++ call
%}


class Foo {
public:
    int bar(int x);
    int bar();
}

The same applies for overloaded constructors.

36.6.3 Class extension with %extend

One of the more interesting features of SWIG is that it can extend structures and classes with new methods--at least in the Python interface. Here is a simple example:

%module example
%{
#include "someheader.h"
%}

struct Vector {
   double x,y,z;
};

%extend Vector {
   char *__str__() {
       static char tmp[1024];
       sprintf(tmp,"Vector(%g,%g,%g)", $self->x,$self->y,$self->z);
       return tmp;
   }
   Vector(double x, double y, double z) {
       Vector *v = (Vector *) malloc(sizeof(Vector));
       v->x = x;
       v->y = y;
       v->z = z;
       return v;
   }
};

Now, in Python

>>> v = example.Vector(2,3,4)
>>> print v
Vector(2,3,4)
>>>

%extend can be used for many more tasks than this. For example, if you wanted to overload a Python operator, you might do this:

%extend Vector {
    Vector __add__(Vector *other) {
         Vector v;
         v.x = $self->x + other->x;
         v.y = $self->y + other->y;
         v.z = $self->z + other->z;
         return v;
    }
};

Use it like this:

>>> import example
>>> v = example.Vector(2,3,4)
>>> w = example.Vector(10,11,12)
>>> print v+w
Vector(12,14,16)
>>> 

%extend works with both C and C++ code. It does not modify the underlying object in any way---the extensions only show up in the Python interface.

36.6.4 Exception handling with %exception

If a C or C++ function throws an error, you may want to convert that error into a Python exception. To do this, you can use the %exception directive. %exception simply lets you rewrite part of the generated wrapper code to include an error check.

In C, a function often indicates an error by returning a status code (a negative number or a NULL pointer perhaps). Here is a simple example of how you might handle that:

%exception malloc {
  $action
  if (!result) {
     PyErr_SetString(PyExc_MemoryError,"Not enough memory");
     return NULL;
  }
}
void *malloc(size_t nbytes);

In Python,

>>> a = example.malloc(2000000000)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
MemoryError: Not enough memory
>>>

If a library provides some kind of general error handling framework, you can also use that. For example:

%exception {
   $action
   if (err_occurred()) {
      PyErr_SetString(PyExc_RuntimeError, err_message());
      return NULL;
   }
}

No declaration name is given to %exception, it is applied to all wrapper functions.

C++ exceptions are also easy to handle. For example, you can write code like this:

%exception getitem {
   try {
      $action
   } catch (std::out_of_range &e) {
      PyErr_SetString(PyExc_IndexError, const_cast<char*>(e.what()));
      return NULL;
   }
}

class Base {
public:
     Foo *getitem(int index);      // Exception handled added
     ...
};

When raising a Python exception from C, use the PyErr_SetString() function as shown above. The following exception types can be used as the first argument.

PyExc_ArithmeticError
PyExc_AssertionError
PyExc_AttributeError
PyExc_EnvironmentError
PyExc_EOFError
PyExc_Exception
PyExc_FloatingPointError
PyExc_ImportError
PyExc_IndexError
PyExc_IOError
PyExc_KeyError
PyExc_KeyboardInterrupt
PyExc_LookupError
PyExc_MemoryError
PyExc_NameError
PyExc_NotImplementedError
PyExc_OSError
PyExc_OverflowError
PyExc_RuntimeError
PyExc_StandardError
PyExc_SyntaxError
PyExc_SystemError
PyExc_TypeError
PyExc_UnicodeError
PyExc_ValueError
PyExc_ZeroDivisionError

The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

36.7 Tips and techniques

Although SWIG is largely automatic, there are certain types of wrapping problems that require additional user input. Examples include dealing with output parameters, strings, binary data, and arrays. This chapter discusses the common techniques for solving these problems.

36.7.1 Input and output parameters

A common problem in some C programs is handling parameters passed as simple pointers. For example:

void add(int x, int y, int *result) {
   *result = x + y;
}

or perhaps

int sub(int *x, int *y) {
   return *x-*y;
}

The easiest way to handle these situations is to use the typemaps.i file. For example:

%module example
%include "typemaps.i"

void add(int, int, int *OUTPUT);
int  sub(int *INPUT, int *INPUT);

In Python, this allows you to pass simple values. For example:

>>> a = add(3,4)
>>> print a
7
>>> b = sub(7,4)
>>> print b
3
>>>

Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter creates a return result.

If you don't want to use the names INPUT or OUTPUT, use the %apply directive. For example:

%module example
%include "typemaps.i"

%apply int *OUTPUT { int *result };
%apply int *INPUT  { int *x, int *y};

void add(int x, int y, int *result);
int  sub(int *x, int *y);

If a function mutates one of its parameters like this,

void negate(int *x) {
   *x = -(*x);
}

you can use INOUT like this:

%include "typemaps.i"
...
void negate(int *INOUT);

In Python, a mutated parameter shows up as a return value. For example:

>>> a = negate(3)
>>> print a
-3
>>>

Note: Since most primitive Python objects are immutable, it is not possible to perform in-place modification of a Python object passed as a parameter.

The most common use of these special typemap rules is to handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

/* send message, return number of bytes sent, along with success code */
int send_message(char *text, int len, int *success);

To wrap such a function, simply use the OUTPUT rule above. For example:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *success };
...
int send_message(char *text, int *success);

When used in Python, the function will return multiple values.

bytes, success = send_message("Hello World")
if not success:
    print "Whoa!"
else:
    print "Sent", bytes

Another common use of multiple return values are in query functions. For example:

void get_dimensions(Matrix *m, int *rows, int *columns);

To wrap this, you might use the following:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *rows, int *columns };
...
void get_dimensions(Matrix *m, int *rows, *columns);

Now, in Python:

>>> r,c = get_dimensions(m)

Be aware that the primary purpose of the typemaps.i file is to support primitive datatypes. Writing a function like this

void foo(Bar *OUTPUT);

may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

36.7.2 Simple pointers

If you must work with simple pointers such as int * or double * and you don't want to use typemaps.i, consider using the cpointer.i library file. For example:

%module example
%include "cpointer.i"

%inline %{
extern void add(int x, int y, int *result);
%}

%pointer_functions(int, intp);

The %pointer_functions(type,name) macro generates five helper functions that can be used to create, destroy, copy, assign, and dereference a pointer. In this case, the functions are as follows:

int  *new_intp();
int  *copy_intp(int *x);
void  delete_intp(int *x);
void  intp_assign(int *x, int value);
int   intp_value(int *x);

In Python, you would use the functions like this:

>>> result = new_intp()
>>> print result
_108fea8_p_int
>>> add(3,4,result)
>>> print intp_value(result)
7
>>>

If you replace %pointer_functions() by %pointer_class(type,name), the interface is more class-like.

>>> result = intp()
>>> add(3,4,result)
>>> print result.value()
7

See the SWIG Library chapter for further details.

36.7.3 Unbounded C Arrays

Sometimes a C function expects an array to be passed as a pointer. For example,

int sumitems(int *first, int nitems) {
    int i, sum = 0;
    for (i = 0; i < nitems; i++) {
        sum += first[i];
    }
    return sum;
}

To wrap this into Python, you need to pass an array pointer as the first argument. A simple way to do this is to use the carrays.i library file. For example:

%include "carrays.i"
%array_class(int, intArray);

The %array_class(type, name) macro creates wrappers for an unbounded array object that can be passed around as a simple pointer like int * or double *. For instance, you will be able to do this in Python:

>>> a = intArray(10000000)         # Array of 10-million integers
>>> for i in xrange(10000):        # Set some values
...     a[i] = i
>>> sumitems(a,10000)
49995000
>>>

The array "object" created by %array_class() does not encapsulate pointers inside a special array object. In fact, there is no bounds checking or safety of any kind (just like in C). Because of this, the arrays created by this library are extremely low-level indeed. You can't iterate over them nor can you even query their length. In fact, any valid memory address can be accessed if you want (negative indices, indices beyond the end of the array, etc.). Needless to say, this approach is not going to suit all applications. On the other hand, this low-level approach is extremely efficient and well suited for applications in which you need to create buffers, package binary data, etc.

36.7.4 String handling

If a C function has an argument of char *, then a Python string can be passed as input. For example:

// C
void foo(char *s);
# Python
>>> foo("Hello")

When a Python string is passed as a parameter, the C function receives a pointer to the raw data contained in the string. Since Python strings are immutable, it is illegal for your program to change the value. In fact, doing so will probably crash the Python interpreter.

If your program modifies the input parameter or uses it to return data, consider using the cstring.i library file described in the SWIG Library chapter.

When functions return a char *, it is assumed to be a NULL-terminated string. Data is copied into a new Python string and returned.

If your program needs to work with binary data, you can use a typemap to expand a Python string into a pointer/length argument pair. As luck would have it, just such a typemap is already defined. Just do this:

%apply (char *STRING, int LENGTH) { (char *data, int size) };
...
int parity(char *data, int size, int initial);

Now in Python:

>>> parity("e\x09ffss\x00\x00\x01\nx", 0)

If you need to return binary data, you might use the cstring.i library file. The cdata.i library can also be used to extra binary data from arbitrary pointers.

36.8 Typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Python C API as well as the material in the "Typemaps" chapter.

Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the primitive C-Python interface or if you want to elevate your guru status.

36.8.1 What is a typemap?

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Python to C, you might define a typemap like this:

%module example

%typemap(in) int {
	$1 = (int) PyLong_AsLong($input);
	printf("Received an integer : %d\n",$1);
}
%inline %{
extern int fact(int n);
%}

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input variable is the input object of type PyObject *.

When this example is compiled into a Python module, it operates as follows:

>>> from example import *
>>> fact(6)
Received an integer : 6
720

In this example, the typemap is applied to all occurrences of the int datatype. You can refine this by supplying an optional parameter name. For example:

%module example

%typemap(in) int nonnegative {
	$1 = (int) PyLong_AsLong($input);
        if ($1 < 0) {
           PyErr_SetString(PyExc_ValueError,"Expected a nonnegative value.");
           return NULL;
        }
}
%inline %{
extern int fact(int nonnegative);
%}

In this case, the typemap code is only attached to arguments that exactly match int nonnegative.

The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG C++ type-system. When you define a typemap for int, that typemap applies to int and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

%typemap(in) int n {
	$1 = (int) PyLong_AsLong($input);
	printf("n = %d\n",$1);
}
%inline %{
typedef int Integer;
extern int fact(Integer n);    // Above typemap is applied
%}

Typemaps can also be defined for groups of consecutive arguments. For example:

%typemap(in) (char *str, int len) {
    $1 = PyString_AsString($input);
    $2 = PyString_Size($input);
};

int count(char c, char *str, int len);

When a multi-argument typemap is defined, the arguments are always handled as a single Python object. This allows the function to be used like this (notice how the length parameter is omitted):

>>> example.count('e','Hello World')
1
>>>

36.8.2 Python typemaps

The previous section illustrated an "in" typemap for converting Python objects to C. A variety of different typemap methods are defined by the Python module. For example, to convert a C integer back into a Python object, you might define an "out" typemap like this:

%typemap(out) int {
    $result = PyInt_FromLong((long) $1);
}

A detailed list of available methods can be found in the "Typemaps" chapter.

However, the best source of typemap information (and examples) is probably the Python module itself. In fact, all of SWIG's default type handling is defined by typemaps. You can view these typemaps by looking at the files in the SWIG library. Just take into account that in the latest versions of swig (1.3.22+), the library files are not very pristine clear for the casual reader, as they used to be. The extensive use of macros and other ugly techniques in the latest version produce a very powerful and consistent python typemap library, but at the cost of simplicity and pedagogic value.

To learn how to write a simple or your first typemap, you better take a look at the SWIG library version 1.3.20 or so.

36.8.3 Typemap variables

Within typemap code, a number of special variables prefaced with a $ may appear. A full list of variables can be found in the "Typemaps" chapter. This is a list of the most common variables:

$1

A C local variable corresponding to the actual type specified in the %typemap directive. For input values, this is a C local variable that's supposed to hold an argument value. For output values, this is the raw result that's supposed to be returned to Python.

$input

A PyObject * holding a raw Python object with an argument or variable value.

$result

A PyObject * that holds the result to be returned to Python.

$1_name

The parameter name that was matched.

$1_type

The actual C datatype matched by the typemap.

$1_ltype

An assignable version of the datatype matched by the typemap (a type that can appear on the left-hand-side of a C assignment operation). This type is stripped of qualifiers and may be an altered version of $1_type. All arguments and local variables in wrapper functions are declared using this type so that their values can be properly assigned.

$symname

The Python name of the wrapper function being created.

36.8.4 Useful Python Functions

When you write a typemap, you usually have to work directly with Python objects. The following functions may prove to be useful.

Python Integer Functions

PyObject *PyInt_FromLong(long l);
long      PyInt_AsLong(PyObject *);
int       PyInt_Check(PyObject *);

Python Floating Point Functions

PyObject *PyFloat_FromDouble(double);
double    PyFloat_AsDouble(PyObject *);
int       PyFloat_Check(PyObject *);

Python String Functions

PyObject *PyString_FromString(char *);
PyObject *PyString_FromStringAndSize(char *, lint len);
int       PyString_Size(PyObject *);
char     *PyString_AsString(PyObject *);
int       PyString_Check(PyObject *);

Python List Functions

PyObject *PyList_New(int size);
int       PyList_Size(PyObject *list);
PyObject *PyList_GetItem(PyObject *list, int i);
int       PyList_SetItem(PyObject *list, int i, PyObject *item);
int       PyList_Insert(PyObject *list, int i, PyObject *item);
int       PyList_Append(PyObject *list, PyObject *item);
PyObject *PyList_GetSlice(PyObject *list, int i, int j);
int       PyList_SetSlice(PyObject *list, int i, int , PyObject *list2);
int       PyList_Sort(PyObject *list);
int       PyList_Reverse(PyObject *list);
PyObject *PyList_AsTuple(PyObject *list);
int       PyList_Check(PyObject *);

Python Tuple Functions

PyObject *PyTuple_New(int size);
int       PyTuple_Size(PyObject *);
PyObject *PyTuple_GetItem(PyObject *, int i);
int       PyTuple_SetItem(PyObject *, int i, PyObject *item);
PyObject *PyTuple_GetSlice(PyObject *t, int i, int j);
int       PyTuple_Check(PyObject *);

Python Dictionary Functions

PyObject *PyDict_New();
int       PyDict_Check(PyObject *);
int       PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val);
int       PyDict_SetItemString(PyObject *p, const char *key, PyObject *val);
int       PyDict_DelItem(PyObject *p, PyObject *key);
int       PyDict_DelItemString(PyObject *p, char *key);
PyObject* PyDict_Keys(PyObject *p);
PyObject* PyDict_Values(PyObject *p);
PyObject* PyDict_GetItem(PyObject *p, PyObject *key);
PyObject* PyDict_GetItemString(PyObject *p, const char *key);
int       PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue);
Py_ssize_t PyDict_Size(PyObject *p);
int       PyDict_Update(PyObject *a, PyObject *b);
int       PyDict_Merge(PyObject *a, PyObject *b, int override);
PyObject* PyDict_Items(PyObject *p);

Python File Conversion Functions

PyObject *PyFile_FromFile(FILE *f);
FILE     *PyFile_AsFile(PyObject *);
int       PyFile_Check(PyObject *);

Abstract Object Interface

write me

36.9 Typemap Examples

This section includes a few examples of typemaps. For more examples, you might look at the files "python.swg" and "typemaps.i" in the SWIG library.

36.9.1 Converting Python list to a char **

A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Python list object to be used as a char ** object.

%module argv

// This tells SWIG to treat char ** as a special case
%typemap(in) char ** {
  /* Check if is a list */
  if (PyList_Check($input)) {
    int size = PyList_Size($input);
    int i = 0;
    $1 = (char **) malloc((size+1)*sizeof(char *));
    for (i = 0; i < size; i++) {
      PyObject *o = PyList_GetItem($input,i);
      if (PyString_Check(o))
	$1[i] = PyString_AsString(PyList_GetItem($input,i));
      else {
	PyErr_SetString(PyExc_TypeError,"list must contain strings");
	free($1);
	return NULL;
      }
    }
    $1[i] = 0;
  } else {
    PyErr_SetString(PyExc_TypeError,"not a list");
    return NULL;
  }
}

// This cleans up the char ** array we malloc'd before the function call
%typemap(freearg) char ** {
  free((char *) $1);
}

// Now a test function
%inline %{
int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
         printf("argv[%d] = %s\n", i,argv[i]);
         i++;
    }
    return i;
}
%}

When this module is compiled, the wrapped C function now operates as follows :

>>> from argv import *
>>> print_args(["Dave","Mike","Mary","Jane","John"])
argv[0] = Dave
argv[1] = Mike
argv[2] = Mary
argv[3] = Jane
argv[4] = John
5

In the example, two different typemaps are used. The "in" typemap is used to receive an input argument and convert it to a C array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

36.9.2 Expanding a Python object into multiple arguments

Suppose that you had a collection of C functions with arguments such as the following:

int foo(int argc, char **argv);

In the previous example, a typemap was written to pass a Python list as the char **argv. This allows the function to be used from Python as follows:

>>> foo(4, ["foo","bar","spam","1"])

Although this works, it's a little awkward to specify the argument count. To fix this, a multi-argument typemap can be defined. This is not very difficult--you only have to make slight modifications to the previous example:

%typemap(in) (int argc, char **argv) {
  /* Check if is a list */
  if (PyList_Check($input)) {
    int i;
    $1 = PyList_Size($input);
    $2 = (char **) malloc(($1+1)*sizeof(char *));
    for (i = 0; i < $1; i++) {
      PyObject *o = PyList_GetItem($input,i);
      if (PyString_Check(o))
	$2[i] = PyString_AsString(PyList_GetItem($input,i));
      else {
	PyErr_SetString(PyExc_TypeError,"list must contain strings");
	free($2);
	return NULL;
      }
    }
    $2[i] = 0;
  } else {
    PyErr_SetString(PyExc_TypeError,"not a list");
    return NULL;
  }
}

%typemap(freearg) (int argc, char **argv) {
  free((char *) $2);
}

When writing a multiple-argument typemap, each of the types is referenced by a variable such as $1 or $2. The typemap code simply fills in the appropriate values from the supplied Python object.

With the above typemap in place, you will find it no longer necessary to supply the argument count. This is automatically set by the typemap code. For example:

>>> foo(["foo","bar","spam","1"])

36.9.3 Using typemaps to return arguments

A common problem in some C programs is that values may be returned in arguments rather than in the return value of a function. For example:

/* Returns a status value and two values in out1 and out2 */
int spam(double a, double b, double *out1, double *out2) {
	... Do a bunch of stuff ...
	*out1 = result1;
	*out2 = result2;
	return status;
}

A typemap can be used to handle this case as follows :

%module outarg

// This tells SWIG to treat an double * argument with name 'OutValue' as
// an output value.  We'll append the value to the current result which 
// is guaranteed to be a List object by SWIG.

%typemap(argout) double *OutValue {
    PyObject *o, *o2, *o3;
    o = PyFloat_FromDouble(*$1);
    if ((!$result) || ($result == Py_None)) {
        $result = o;
    } else {
        if (!PyTuple_Check($result)) {
            PyObject *o2 = $result;
            $result = PyTuple_New(1);
            PyTuple_SetItem(target,0,o2);
        }
        o3 = PyTuple_New(1);
        PyTuple_SetItem(o3,0,o);
        o2 = $result;
        $result = PySequence_Concat(o2,o3);
        Py_DECREF(o2);
        Py_DECREF(o3);
    }
}

int spam(double a, double b, double *OutValue, double *OutValue);

The typemap works as follows. First, a check is made to see if any previous result exists. If so, it is turned into a tuple and the new output value is concatenated to it. Otherwise, the result is returned normally. For the sample function spam(), there are three output values--meaning that the function will return a 3-tuple of the results.

As written, the function must accept 4 arguments as input values, last two being pointers to doubles. If these arguments are only used to hold output values (and have no meaningful input value), an additional typemap can be written. For example:

%typemap(in,numinputs=0) double *OutValue(double temp) {
    $1 = &temp;
}

By specifying numinputs=0, the input value is ignored. However, since the argument still has to be set to some meaningful value before calling C, it is set to point to a local variable temp. When the function stores its output value, it will simply be placed in this local variable. As a result, the function can now be used as follows:

>>> a = spam(4,5)
>>> print a
(0, 2.45, 5.0)
>>> x,y,z = spam(4,5)
>>>

36.9.4 Mapping Python tuples into small arrays

In some applications, it is sometimes desirable to pass small arrays of numbers as arguments. For example :

extern void set_direction(double a[4]);       // Set direction vector

This too, can be handled used typemaps as follows :

// Grab a 4 element array as a Python 4-tuple
%typemap(in) double[4](double temp[4]) {   // temp[4] becomes a local variable
  int i;
  if (PyTuple_Check($input)) {
    if (!PyArg_ParseTuple($input,"dddd",temp,temp+1,temp+2,temp+3)) {
      PyErr_SetString(PyExc_TypeError,"tuple must have 4 elements");
      return NULL;
    }
    $1 = &temp[0];
  } else {
    PyErr_SetString(PyExc_TypeError,"expected a tuple.");
    return NULL;
  }
}

This allows our set_direction function to be called from Python as follows :

>>> set_direction((0.5,0.0,1.0,-0.25))

Since our mapping copies the contents of a Python tuple into a C array, such an approach would not be recommended for huge arrays, but for small structures, this approach works fine.

36.9.5 Mapping sequences to C arrays

Suppose that you wanted to generalize the previous example to handle C arrays of different sizes. To do this, you might write a typemap as follows:

// Map a Python sequence into any sized C double array
%typemap(in) double[ANY](double temp[$1_dim0]) {
  int i;
  if (!PySequence_Check($input)) {
      PyErr_SetString(PyExc_TypeError,"Expecting a sequence");
      return NULL;
  }
  if (PyObject_Length($input) != $1_dim0) {
      PyErr_SetString(PyExc_ValueError,"Expecting a sequence with $1_dim0 elements");
      return NULL;
  }
  for (i =0; i < $1_dim0; i++) {
      PyObject *o = PySequence_GetItem($input,i);
      if (!PyFloat_Check(o)) {
         Py_XDECREF(o);
         PyErr_SetString(PyExc_ValueError,"Expecting a sequence of floats");
         return NULL;
      }
      temp[i] = PyFloat_AsDouble(o);
      Py_DECREF(o);
  }
  $1 = &temp[0];
}

In this case, the variable $1_dim0 is expanded to match the array dimensions actually used in the C code. This allows the typemap to be applied to types such as:

void foo(double x[10]);
void bar(double a[4], double b[8]);

Since the above typemap code gets inserted into every wrapper function where used, it might make sense to use a helper function instead. This will greatly reduce the amount of wrapper code. For example:

%{
static int convert_darray(PyObject *input, double *ptr, int size) {
  int i;
  if (!PySequence_Check(input)) {
      PyErr_SetString(PyExc_TypeError,"Expecting a sequence");
      return 0;
  }
  if (PyObject_Length(input) != size) {
      PyErr_SetString(PyExc_ValueError,"Sequence size mismatch");
      return 0;
  }
  for (i =0; i < size; i++) {
      PyObject *o = PySequence_GetItem(input,i);
      if (!PyFloat_Check(o)) {
         Py_XDECREF(o);
         PyErr_SetString(PyExc_ValueError,"Expecting a sequence of floats");
         return 0;
      }
      ptr[i] = PyFloat_AsDouble(o);
      Py_DECREF(o);
  }
  return 1;
}
%}

%typemap(in) double [ANY](double temp[$1_dim0]) {
   if (!convert_darray($input,temp,$1_dim0)) {
      return NULL;
   }
   $1 = &temp[0];
}

36.9.6 Pointer handling

Occasionally, it might be necessary to convert pointer values that have been stored using the SWIG typed-pointer representation. Since there are several ways in which pointers can be represented, the following two functions are used to safely perform this conversion:

int SWIG_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags)

Converts a Python object obj to a C pointer. The result of the conversion is placed into the pointer located at ptr. ty is a SWIG type descriptor structure. flags is used to handle error checking and other aspects of conversion. It is the bitwise-or of several flag values including SWIG_POINTER_EXCEPTION and SWIG_POINTER_DISOWN. The first flag makes the function raise an exception on type error. The second flag additionally steals ownership of an object. Returns 0 on success and -1 on error.

PyObject *SWIG_NewPointerObj(void *ptr, swig_type_info *ty, int own)

Creates a new Python pointer object. ptr is the pointer to convert, ty is the SWIG type descriptor structure that describes the type, and own is a flag that indicates whether or not Python should take ownership of the pointer.

Both of these functions require the use of a special SWIG type-descriptor structure. This structure contains information about the mangled name of the datatype, type-equivalence information, as well as information about converting pointer values under C++ inheritance. For a type of Foo *, the type descriptor structure is usually accessed as follows:

Foo *f;
if (SWIG_ConvertPtr($input, (void **) &f, SWIGTYPE_p_Foo, SWIG_POINTER_EXCEPTION) == -1)
  return NULL;

PyObject *obj;
obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);

In a typemap, the type descriptor should always be accessed using the special typemap variable $1_descriptor. For example:

%typemap(in) Foo * {
if ((SWIG_ConvertPtr($input,(void **) &$1, $1_descriptor,SWIG_POINTER_EXCEPTION)) == -1)
  return NULL;
}

If necessary, the descriptor for any type can be obtained using the $descriptor() macro in a typemap. For example:

%typemap(in) Foo * {
if ((SWIG_ConvertPtr($input,(void **) &$1, $descriptor(Foo *), 
                                               SWIG_POINTER_EXCEPTION)) == -1)
  return NULL;
}

Although the pointer handling functions are primarily intended for manipulating low-level pointers, both functions are fully aware of Python proxy classes. Specifically, SWIG_ConvertPtr() will retrieve a pointer from any object that has a this attribute. In addition, SWIG_NewPointerObj() can automatically generate a proxy class object (if applicable).

36.10 Docstring Features

Using docstrings in Python code is becoming more and more important and more tools are coming on the scene that take advantage of them, everything from full-blown documentation generators to class browsers and popup call-tips in Python-aware IDEs. Given the way that SWIG generates the proxy code by default, your users will normally get something like "function_name(*args)" in the popup calltip of their IDE which is next to useless when the real function prototype might be something like this:

bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);

The features described in this section make it easy for you to add docstrings to your modules, functions and methods that can then be used by the various tools out there to make the programming experience of your users much simpler.

36.10.1 Module docstring

Python allows a docstring at the beginning of the .py file before any other statements, and it is typically used to give a general description of the entire module. SWIG supports this by setting an option of the %module directive. For example:

%module(docstring="This is the example module's docstring") example

When you have more than just a line or so then you can retain the easy readability of the %module directive by using a macro. For example:

%define DOCSTRING
"The `XmlResource` class allows program resources defining menus, 
layout of controls on a panel, etc. to be loaded from an XML file."
%enddef

%module(docstring=DOCSTRING) xrc

36.10.2 %feature("autodoc")

As alluded to above SWIG will generate all the function and method proxy wrappers with just "*args" (or "*args, **kwargs" if the -keyword option is used) for a parameter list and will then sort out the individual parameters in the C wrapper code. This is nice and simple for the wrapper code, but makes it difficult to be programmer and tool friendly as anyone looking at the .py file will not be able to find out anything about the parameters that the functions accept.

But since SWIG does know everything about the function it is possible to generate a docstring containing the parameter types, names and default values. Since many of the docstring tools are adopting a standard of recognizing if the first thing in the docstring is a function prototype then using that instead of what they found from introspection, then life is good once more.

SWIG's Python module provides support for the "autodoc" feature, which when attached to a node in the parse tree will cause a docstring to be generated that includes the name of the function, parameter names, default values if any, and return type if any. There are also four levels for autodoc controlled by the value given to the feature, %feature("autodoc", "level"). The four values for level are covered in the following sub-sections.

36.10.2.1 %feature("autodoc", "0")

When level "0" is used then the types of the parameters will not be included in the autodoc string. For example, given this function prototype:

%feature("autodoc", "0");
bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);

Then Python code like this will be generated:

def function_name(*args, **kwargs):
    """function_name(x, y, foo=None, bar=None) -> bool"""
    ...

36.10.2.2 %feature("autodoc", "1")

When level "1" is used then the parameter types will be used in the autodoc string. In addition, an attempt is made to simplify the type name such that it makes more sense to the Python user. Pointer, reference and const info is removed if the associated type is has an associated Python type (%rename's are thus shown correctly). This works most of the time, otherwise a C/C++ type will be used. See the next section for the "docstring" feature for tweaking the docstrings to your liking. Given the example above, then turning on the parameter types with level "1" will result in Python code like this:

def function_name(*args, **kwargs):
    """function_name(int x, int y, Foo foo=None, Bar bar=None) -> bool"""
    ...

36.10.2.3 %feature("autodoc", "2")

Level "2" results in the function prototype as per level "0". In addition, a line of documentation is generated for each parameter. Using the previous example, the generated code will be:

def function_name(*args, **kwargs):
    """
    function_name(x, y, foo=None, bar=None) -> bool

    Parameters:
        x: int
        y: int
        foo: Foo *
        bar: Bar *

    """
    ...

Note that the documentation for each parameter is sourced from the "doc" typemap which by default shows the C/C++ type rather than the simplified Python type name described earlier for level "1". Typemaps can of course change the output for any particular type, for example the int x parameter:

%feature("autodoc", "2");
%typemap("doc") int x "$1_name (C++ type: $1_type) -- Input $1_name dimension"
bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);

resulting in

def function_name(*args, **kwargs):
  """
    function_name(x, y, foo=None, bar=None) -> bool

    Parameters:
        x (C++ type: int) -- Input x dimension
        y: int
        foo: Foo *
        bar: Bar *

    """

36.10.2.4 %feature("autodoc", "3")

Level "3" results in the function prototype as per level "1" but also contains the same additional line of documentation for each parameter as per level "2". Using our earlier example again, the generated code will be:

def function_name(*args, **kwargs):
    """
    function_name(int x, int y, Foo foo=None, Bar bar=None) -> bool

    Parameters:
        x: int
        y: int
        foo: Foo *
        bar: Bar *

    """
    ...

36.10.2.5 %feature("autodoc", "docstring")

Finally, there are times when the automatically generated autodoc string will make no sense for a Python programmer, particularly when a typemap is involved. So if you give an explicit value for the autodoc feature then that string will be used in place of the automatically generated string. For example:

%feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
void GetPosition(int* OUTPUT, int* OUTPUT);

36.10.3 %feature("docstring")

In addition to the autodoc strings described above, you can also attach any arbitrary descriptive text to a node in the parse tree with the "docstring" feature. When the proxy module is generated then any docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together. If the docstring is all on a single line then it is output like this::

"""This is the docstring"""

Otherwise, to aid readability it is output like this:

"""
This is a multi-line docstring
with more than one line.
"""

36.11 Python Packages

Python has concepts of modules and packages. Modules are separate units of code and may be grouped together to form a package. Packages may be nested, that is they may contain subpackages. This leads to tree-like hierarchy, with packages as intermediate nodes and modules as leaf nodes.

The hierarchy of Python packages/modules follows the hierarchy of *.py files found in a source tree (or, more generally, in the Python path). Normally, the developer creates new module by placing a *.py file somewhere under Python path; the module is then named after that *.py file. A package is created by placing an __init__.py file within a directory; the package is then named after that directory. For example, the following source tree:

mod1.py
pkg1/__init__.py
pkg1/mod2.py
pkg1/pkg2/__init__.py
pkg1/pkg2/mod3.py

defines the following Python packages and modules:

pkg1            # package
pkg1.pkg2       # package
mod1            # module
pkg1.mod2       # module
pkg1.pkg2.mod3  # module

The purpose of an __init__.py file is two-fold. First, the existence of __init__.py in a directory informs the Python interpreter that this directory contains a Python package. Second, the code in __init__.py is loaded/executed automatically when the package is initialized (when it or its submodule/subpackage gets import'ed). By default, SWIG generates proxy Python code – one *.py file for each *.i interface. The __init__.py files, however, are not generated by SWIG. They should be created by other means. Both files (module *.py and __init__.py) should be installed in appropriate destination directories in order to obtain a desirable package/module hierarchy.

The way Python defines its modules and packages impacts SWIG users. Some users may need to use special features such as the package option in the %module directive or import related command line options. These are explained in the following sections.

36.11.1 Setting the Python package

Using the package option in the %module directive allows you to specify a Python package that the module will be in when installed.

%module(package="wx") xrc

This is useful when the .i file is %imported by another .i file. By default SWIG will assume that the importer is able to find the importee with just the module name, but if they live in separate Python packages then this won't work. However if the importee specifies what its package is with the %module option then the Python code generated for the importer will use that package name when importing the other module and in base class declarations, etc..

SWIG assumes that the package option provided to %module together with the module name (that is, wx.xrc in the above example) forms a fully qualified (absolute) name of a module (in Python terms). This is important especially for Python 3, where absolute imports are used by default. It's up to you to place the generated module files (.py, .so) in appropriate subdirectories. For example, if you have an interface file foo.i with:

%module(package="pkg1.pkg2") foo

then the resulting directory layout should be

pkg1/
pkg1/__init__.py
pkg1/pkg2/__init__.py
pkg1/pkg2/foo.py        # (generated by SWIG)
pkg1/pkg2/_foo.so       # (shared library built from C/C++ code generated by SWIG)

36.11.2 Absolute and relative imports

Suppose, we have the following hierarchy of files:

pkg1/
pkg1/__init__.py
pkg1/mod2.py
pkg1/pkg2/__init__.py
pkg1/pkg2/mod3.py

Let the contents of pkg1/pkg2/mod3.py be

class M3: pass

We edit pkg1/mod2.py and want to import module pkg1/pkg2/mod3.py in order to derive from class M3. We can write appropriate Python code in several ways, for example:

  1. Using "import <>" syntax with absolute package name:

    # pkg1/mod2.py
    import pkg1.pkg2.mod3
    class M2(pkg1.pkg2.mod3.M3): pass
    
  2. Using "import <>" syntax with package name relative to pkg1 (only in Python 2.7 and earlier):

    # pkg1/mod2.py
    import pkg2.mod3
    class M2(pkg2.mod3.M3): pass
    
  3. Using "from <> import <>" syntax (relative import syntax, only in Python 2.5 and later):

    # pkg1/mod2.py
    from .pkg2 import mod3
    class M2(mod3.M3): pass
    
  4. Other variants, for example the following construction in order to have the pkg2.mod3.M3 symbol available in mod2 as in point 2 above (but now under Python 3):

    # pkg1/mod2.py
    from . import pkg2
    from .pkg2 import mod3
    class M2(pkg2.mod3.M3): pass
    

Now suppose we have mod2.i with

// mod2.i
%module (package="pkg1") mod2
%import "mod3.i"
// ...

and mod3.i with

// mod3.i
%module (package="pkg1.pkg2") mod3
// ...

By default, SWIG would generate mod2.py proxy file with import directive as in point 1. This can be changed with the -relativeimport command line option. The -relativeimport instructs SWIG to organize imports as in point 2 (for Python 2.x) or as in point 4 (for Python 3, that is when the -py3 command line option is enabled). In short, if you have mod2.i and mod3.i as above, then without -relativeimport SWIG will write

import pkg1.pkg2.mod3

to mod2.py proxy file, and with -relativeimport it will write

import pkg2.mod3

if -py3 is not used, or

from . import pkg2
import pkg1.pkg2.mod3

when -py3 is used.

You should avoid using relative imports and use absolute ones whenever possible. There are some cases, however, when relative imports may be necessary. The first example is, when some (legacy) Python code refers entities imported by proxy files generated by SWIG, and it assumes that the proxy file uses relative imports. Second case is, when one puts import directives in __init__.py to import symbols from submodules or subpackages and the submodule depends on other submodules (discussed later).

36.11.3 Enforcing absolute import semantics

As you may know, there is an incompatibility in import semantics (for the import <> syntax) between Python 2 and 3. In Python 2.4 and earlier it is not clear whether

import foo

refers to a top-level module or to another module inside the current package. In Python 3 it always refers to a top-level module (see PEP 328). To instruct Python 2.5 through 2.7 to use new semantics (that is import foo is interpreted as absolute import), one has to put the following line

from __future__ import absolute_import

at the very beginning of his proxy *.py file. In SWIG, it may be accomplished with %pythonbegin directive as follows:

%pythonbegin %{
from __future__ import absolute_import
%}

36.11.4 Importing from __init__.py

Imports in __init__.py are handy when you want to populate a package's namespace with names imported from other modules. In SWIG based projects this approach may also be used to split large pieces of code into smaller modules, compile them in parallel and then re-assemble everything at runtime by importing submodules' contents in __init__.py, for example.

Unfortunately import directives in __init__.py may cause problems, especially if they refer to a package's submodules. This is caused by the way Python initializes packages. If you spot problems with imports from __init__.py try using -relativeimport option. Below we explain in detail one issue, for which the -relativeimport workaround may be helpful.

Consider the following example (Python 3):

pkg1/__init__.py        # (empty)
pkg1/pkg2/__init__.py   # (imports something from bar.py)
pkg1/pkg2/foo.py
pkg1/pkg2/bar.py        # (imports foo.py)

If the file contents are:

  • pkg1/pkg2/__init__.py:

    # pkg1/pkg2/__init__.py
    from .bar import Bar
    
  • pkg1/pkg2/foo.py:

    # pkg1/pkg2/foo.py
    class Foo: pass
    
  • pkg1/pkg2/bar.py:

    # pkg1/pkg2/bar.py
    import pkg1.pkg2.foo
    class Bar(pkg1.pkg2.foo.Foo): pass
    

Now if one simply used import pkg1.pkg2, it will usually fail:

>>> import pkg1.pkg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./pkg1/pkg2/__init__.py", line 2, in <module>
    from .bar import Bar
  File "./pkg1/pkg2/bar.py", line 3, in <module>
    class Bar(pkg1.pkg2.foo.Foo): pass
AttributeError: 'module' object has no attribute 'pkg2'

Surprisingly, if we execute the import pkg1.pkg2 directive for the second time, it succeeds. The reason seems to be following: when Python spots the from .bar import Bar directive in pkg1/pkg2/__init__.py it starts loading pkg1/pkg2/bar.py. This module imports pkg1.pkg2.foo in turn and tries to use pkg1.pkg2.foo.Foo, but the package pkg1 is not fully initialized yet (the initialization procedure is actually in progress) and it seems like the effect of the already seen import pkg1.pkg2.pkg3.foo is "delayed" or ignored. Exactly the same may happen to a proxy module generated by SWIG.

One workaround for this case is to use a relative import in pkg1/pkg2/bar.py. If we change bar.py to be:

from .pkg3 import foo
class Bar(foo.Foo): pass

or

from . import pkg3
from .pkg3 import foo
class Bar(pkg3.foo.Foo): pass

then the example works again. With SWIG, you need to enable the -relativeimport option in order to have the above workaround in effect (note, that the Python 2 case also needs the -relativeimport workaround).

36.12 Python 3 Support

SWIG is able to support Python 3.0. The wrapper code generated by SWIG can be compiled with both Python 2.x or 3.0. Further more, by passing the -py3 command line option to SWIG, wrapper code with some Python 3 specific features can be generated (see below subsections for details of these features). The -py3 option also disables some incompatible features for Python 3, such as -classic.

There is a list of known-to-be-broken features in Python 3:

  • No more support for FILE* typemaps, because PyFile_AsFile has been dropped in Python 3.
  • The -apply command line option is removed and generating code using apply() is no longer supported.

The following are Python 3.0 new features that are currently supported by SWIG.

36.12.1 Function annotation

The -py3 option will enable function annotation support. When used SWIG is able to generate proxy method definitions like this:

  def foo(self, bar : "int"=0) -> "void" : ...

Also, even if without passing SWIG the -py3 option, the parameter list still could be generated:

  def foo(self, bar=0): ...

But for overloaded function or method, the parameter list would fallback to *args or self, *args, and **kwargs may be append depend on whether you enabled the keyword argument. This fallback is due to all overloaded functions share the same function in SWIG generated proxy class.

For detailed usage of function annotation, see PEP 3107.

36.12.2 Buffer interface

Buffer protocols were revised in Python 3. SWIG also gains a series of new typemaps to support buffer interfaces. These typemap macros are defined in pybuffer.i, which must be included in order to use them. By using these typemaps, your wrapped function will be able to accept any Python object that exposes a suitable buffer interface.

For example, the get_path() function puts the path string into the memory pointed to by its argument:

void get_path(char *s);

Then you can write a typemap like this: (the following example is applied to both Python 3.0 and 2.6, since the bytearray type is backported to 2.6.

%include <pybuffer.i>
%pybuffer_mutable_string(char *str);
void get_path(char *s);

And then on the Python side the wrapped get_path could be used in this way:

>>> p = bytearray(10)
>>> get_path(p)
>>> print(p)
bytearray(b'/Foo/Bar/\x00')

The macros defined in pybuffer.i are similar to those in cstring.i:

%pybuffer_mutable_binary(parm, size_parm)

The macro can be used to generate a typemap which maps a buffer of an object to a pointer provided by parm and a size argument provided by size_parm. For example:

%pybuffer_mutable_binary(char *str, size_t size);
...
int snprintf(char *str, size_t size, const char *format, ...);

In Python:

>>> buf = bytearray(6)
>>> snprintf(buf, "Hello world!")
>>> print(buf)
bytearray(b'Hello\x00')
>>> 

%pybuffer_mutable_string(parm)

This typemap macro requires the buffer to be a zero terminated string, and maps the pointer of the buffer to parm. For example:

%pybuffer_mutable_string(char *str);
...
size_t make_upper(char *str);

In Python:

>>> buf = bytearray(b'foo\x00')
>>> make_upper(buf)
>>> print(buf)
bytearray(b'FOO\x00')
>>>

Both %pybuffer_mutable_binary and %pybuffer_mutable_string require the provided buffer to be mutable, eg. they can accept a bytearray type but can't accept an immutable byte type.

%pybuffer_binary(parm, size_parm)

This macro maps an object's buffer to a pointer parm and a size size_parm. It is similar to %pybuffer_mutable_binary, except the %pybuffer_binary an accept both mutable and immutable buffers. As a result, the wrapped function should not modify the buffer.

%pybuffer_string(parm)

This macro maps an object's buffer as a string pointer parm. It is similar to %pybuffer_mutable_string but the buffer could be both mutable and immutable. And your function should not modify the buffer.

36.12.3 Abstract base classes

By including pyabc.i and using the -py3 command line option when calling SWIG, the proxy classes of the STL containers will automatically gain an appropriate abstract base class. For example, the following SWIG interface:

%include <pyabc.i>
%include <std_map.i>
%include <std_list.i>

namespace std {
  %template(Mapii) map<int, int>;
  %template(IntList) list<int>;
}

will generate a Python proxy class Mapii inheriting from collections.MutableMap and a proxy class IntList inheriting from collections.MutableSequence.

pyabc.i also provides a macro %pythonabc that could be used to define an abstract base class for your own C++ class:

%pythonabc(MySet, collections.MutableSet);

For details of abstract base class, please see PEP 3119.

36.12.4 Byte string output conversion

By default, any byte string (char* or std::string) returned from C or C++ code is decoded to text as UTF-8. This decoding uses the surrogateescape error handler under Python 3.1 or higher -- this error handler decodes invalid byte sequences to high surrogate characters in the range U+DC80 to U+DCFF. As an example, consider the following SWIG interface, which exposes a byte string that cannot be completely decoded as UTF-8:

%module example

%include <std_string.i>

%inline %{

const char* non_utf8_c_str(void) {
        return "h\xe9llo w\xc3\xb6rld";
}

%}

When this method is called from Python 3, the return value is the following text string:

>>> s = example.non_utf8_c_str()
>>> s
'h\udce9llo wörld'

Since the C string contains bytes that cannot be decoded as UTF-8, those raw bytes are represented as high surrogate characters that can be used to obtain the original byte sequence:

>>> b = s.encode('utf-8', errors='surrogateescape')
>>> b
b'h\xe9llo w\xc3\xb6rld'

One can then attempt a different encoding, if desired (or simply leave the byte string as a raw sequence of bytes for use in binary protocols):

>>> b.decode('latin-1')
'héllo wörld'

Note, however, that text strings containing surrogate characters are rejected with the default strict codec error handler. For example:

>>> with open('test', 'w') as f:
...     print(s, file=f)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode character '\udce9' in position 1: surrogates not allowed

This requires the user to check most strings returned by SWIG bindings, but the alternative is for a non-UTF8 byte string to be completely inaccessible in Python 3 code.

For more details about the surrogateescape error handler, please see PEP 383.

swig-3.0.2/Doc/Manual/Lisp.html0000664000175000017500000005607212343706601016100 0ustar williamwilliam SWIG and Common Lisp

27 SWIG and Common Lisp

Common Lisp is a high-level, all-purpose, object-oriented, dynamic, functional programming language with long history. Common Lisp is used in many fields, ranging from web development to finance, and also common in computer science education. There are more than 9 different implementations of common lisp which are available, all have different foreign function interfaces. SWIG currently supports only the Allegro Common Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI foreign function interfaces.

27.1 Allegro Common Lisp

Allegro Common Lisp support in SWIG has been updated to include support for both C and C++. You can read about the interface here

27.2 Common Foreign Function Interface(CFFI)

CFFI, the Common Foreign Function Interface, is a portable foreign function interface for ANSI Common Lisp systems, similar in spirit to UFFI. Unlike UFFI, CFFI requires only a small set of low-level functionality from the Lisp implementation, such as calling a foreign function by name, allocating foreign memory, and dereferencing pointers.

To run the cffi module of SWIG requires very little effort, you just need to run:

swig -cffi -module module-name   file-name 

But a better was of using all the power of SWIG is to write SWIG interface files. Below we will explain how to write interface files and the various things which you can do with them.

27.2.1 Additional Commandline Options

The following table list the additional commandline options available for the CLISP module. They can also be seen by using:

swig -cffi -help 

CFFI specific options
-generate-typedef If this option is given then defctype will be used to generate
shortcuts according to the typedefs in the input.
-[no]cwrap Turn on or turn off generation of an intermediate C file when
creating a C interface. By default this is only done for C++ code.
-[no]swig-lisp Turns on or off generation of code for helper lisp macro, functions, etc. which SWIG uses while generating wrappers. These macros, functions may still be used by generated wrapper code.

27.2.2 Generating CFFI bindings

As we mentioned earlier the ideal way to use SWIG is to use interface files. To illustrate the use of it, let's assume that we have a file named test.h with the following C code:
#define y 5
#define x (y >>  1)

typedef int days;

struct bar {
  short p, q;
    char a, b;
    int *z[1000];
    struct bar * n;
};
  
struct   bar * my_struct;

struct foo {
    int a;
    struct foo * b[100];
  
};

int pointer_func(void (*ClosureFun)( void* _fun, void* _data, void* _evt ), int p);

int func123(div_t * p,int **q[100],int r[][1000][10]);

void lispsort_double (int n, double * array);

enum color { RED, BLUE, GREEN};
Corresponding to this we will write a simple interface file:
%module test

%include "test.h"

The generated SWIG Code will be:
;;;SWIG wrapper code starts here

(cl:defmacro defanonenum (&body enums)
   "Converts anonymous enums to defconstants."
  `(cl:progn ,@(cl:loop for value in enums
                        for index = 0 then (cl:1+ index)
                        when (cl:listp value) do (cl:setf index (cl:second value)
                                                          value (cl:first value))
                        collect `(cl:defconstant ,value ,index))))

(cl:eval-when (:compile-toplevel :load-toplevel)
  (cl:unless (cl:fboundp 'swig-lispify)
    (cl:defun swig-lispify (name flag cl:&optional (package cl:*package*))
      (cl:labels ((helper (lst last rest cl:&aux (c (cl:car lst)))
                    (cl:cond
                      ((cl:null lst)
                       rest)
                      ((cl:upper-case-p c)
                       (helper (cl:cdr lst) 'upper
                               (cl:case last
                                 ((lower digit) (cl:list* c #\- rest))
                                 (cl:t (cl:cons c rest)))))
                      ((cl:lower-case-p c)
                       (helper (cl:cdr lst) 'lower (cl:cons (cl:char-upcase c) rest)))
                      ((cl:digit-char-p c)
                       (helper (cl:cdr lst) 'digit 
                               (cl:case last
                                 ((upper lower) (cl:list* c #\- rest))
                                 (cl:t (cl:cons c rest)))))
                      ((cl:char-equal c #\_)
                       (helper (cl:cdr lst) '_ (cl:cons #\- rest)))
                      (cl:t
                       (cl:error "Invalid character: ~A" c)))))
        (cl:let ((fix (cl:case flag
                        ((constant enumvalue) "+")
                        (variable "*")
                        (cl:t ""))))
          (cl:intern
           (cl:concatenate
            'cl:string
            fix
            (cl:nreverse (helper (cl:concatenate 'cl:list name) cl:nil cl:nil))
            fix)
           package))))))

;;;SWIG wrapper code ends here


(cl:defconstant y 5)

(cl:defconstant x (cl:ash 5 -1))

(cffi:defcstruct bar
	(p :short)
	(q :short)
	(a :char)
	(b :char)
	(z :pointer)
	(n :pointer))

(cffi:defcvar ("my_struct" my_struct)
 :pointer)

(cffi:defcstruct foo
	(a :int)
	(b :pointer))

(cffi:defcfun ("pointer_func" pointer_func) :int
  (ClosureFun :pointer)
  (p :int))

(cffi:defcfun ("func123" func123) :int
  (p :pointer)
  (q :pointer)
  (r :pointer))

(cffi:defcfun ("lispsort_double" lispsort_double) :void
  (n :int)
  (array :pointer))

(cffi:defcenum color
	:RED
	:BLUE
	:GREEN)

The SWIG wrapper code refers to the special code which SWIG may need to use while wrapping C code. You can turn on/off the generation of this code by using the -[no]swig-lisp option. You must have noticed that SWIG goes one extra step to ensure that CFFI does not do automatic lispification of the C function names. The reason SWIG does this is because quite often developers want to build a nice CLOS based lispy API, and this one to one correspondence between C function names and lisp function name helps.

Maybe you want to have your own convention for generating lisp function names for corresponding C function names, or you just want to lispify the names, also, before we forget you want to export the generated lisp names. To do this, we will use the SWIG feature directive. Let's edit the interface file such that the C type "div_t*" is changed to Lisp type ":my-pointer", we lispify all names, export everything, and do some more stuff.

%module test

%typemap(cin) div_t* ":my-pointer";

%feature("intern_function","1");
%feature("export");

%feature("inline") lispsort_double;

%feature("intern_function", "my-lispify") lispsort_double;
%rename func123 renamed_cool_func;
%ignore "pointer_func";

%include "test.h"

The typemap(cin) ensures that for all arguments which are input to C with the type "div_t*", the ":my-pointer" type be used. Similarly typemap(cout) are used for all types which are returned from C.

The feature intern_function ensures that all C names are interned using the swig-lispify function. The "1" given to the feature is optional. The use of feature like %feature("intern_function","1"); globally enables interning for everything. If you want to target a single function, or declaration then use the targeted version of feature, %feature("intern_function", "my-lispify") lispsort_double;, here we are using an additional feature which allows us to use our lispify function.

The export feature allows us to export the symbols. The inline feature declaims the declared function as inline. The rename directive allows us to change the name(it is useful when generating C wrapper code for handling overloaded functions). The ignore directive ignores a certain declaration.

There are several other things which are possible, to see some example of usage of SWIG look at the Lispbuilder and wxCL projects. The generated code with 'noswig-lisp' option is:

(cl:defconstant #.(swig-lispify "y" 'constant) 5)

(cl:export '#.(swig-lispify "y" 'constant))

(cl:defconstant #.(swig-lispify "x" 'constant) (cl:ash 5 -1))

(cl:export '#.(swig-lispify "x" 'constant))

(cffi:defcstruct #.(swig-lispify "bar" 'classname)
	(#.(swig-lispify "p" 'slotname) :short)
	(#.(swig-lispify "q" 'slotname) :short)
	(#.(swig-lispify "a" 'slotname) :char)
	(#.(swig-lispify "b" 'slotname) :char)
	(#.(swig-lispify "z" 'slotname) :pointer)
	(#.(swig-lispify "n" 'slotname) :pointer))

(cl:export '#.(swig-lispify "bar" 'classname))

(cl:export '#.(swig-lispify "p" 'slotname))

(cl:export '#.(swig-lispify "q" 'slotname))

(cl:export '#.(swig-lispify "a" 'slotname))

(cl:export '#.(swig-lispify "b" 'slotname))

(cl:export '#.(swig-lispify "z" 'slotname))

(cl:export '#.(swig-lispify "n" 'slotname))

(cffi:defcvar ("my_struct" #.(swig-lispify "my_struct" 'variable))
 :pointer)

(cl:export '#.(swig-lispify "my_struct" 'variable))

(cffi:defcstruct #.(swig-lispify "foo" 'classname)
	(#.(swig-lispify "a" 'slotname) :int)
	(#.(swig-lispify "b" 'slotname) :pointer))

(cl:export '#.(swig-lispify "foo" 'classname))

(cl:export '#.(swig-lispify "a" 'slotname))

(cl:export '#.(swig-lispify "b" 'slotname))

(cffi:defcfun ("renamed_cool_func" #.(swig-lispify "renamed_cool_func" 'function)) :int
  (p :my-pointer)
  (q :pointer)
  (r :pointer))

(cl:export '#.(swig-lispify "renamed_cool_func" 'function))

(cl:declaim (cl:inline #.(my-lispify "lispsort_double" 'function)))

(cffi:defcfun ("lispsort_double" #.(my-lispify "lispsort_double" 'function)) :void
  (n :int)
  (array :pointer))

(cl:export '#.(my-lispify "lispsort_double" 'function))

(cffi:defcenum #.(swig-lispify "color" 'enumname)
	#.(swig-lispify "RED" 'enumvalue :keyword)
	#.(swig-lispify "BLUE" 'enumvalue :keyword)
	#.(swig-lispify "GREEN" 'enumvalue :keyword))

(cl:export '#.(swig-lispify "color" 'enumname))

27.2.3 Generating CFFI bindings for C++ code

This feature to SWIG (for CFFI) is very new and still far from complete. Pitch in with your patches, bug reports and feature requests to improve it.

Generating bindings for C++ code, requires -c++ option to be present and it first generates C binding which will wrap the C++ code, and then generates the corresponding CFFI wrapper code. In the generated C wrapper code, you will often want to put your own C code, such as the code to include various files. This can be done by making use of "%{" and "%}" as shown below.

%{
 #include "Test/test.h"
%}

Also, while parsing the C++ file and generating C wrapper code SWIG may need to be able to understand various symbols used in other header files. To help SWIG in doing this while ensuring that wrapper code is generated for the target file, use the "import" directive. The "include" directive specifies the target file for which wrapper code will be generated.


%import "ancillary/header.h"

%include "target/header.h"

Various features which were available for C headers can also be used here. The target header which we are going to use here is:
namespace OpenDemo {
  class Test
    {
    public:
        float x;
        // constructors
        Test (void) {x = 0;}
        Test (float X) {x = X;}

        // vector addition
        Test operator+ (const Test& v) const {return Test (x+v.x);}

      // length squared
        float lengthSquared (void) const {return this->dot (*this);}

        static float distance (const Test& a, const Test& b){return(a-b).length();}

        inline Test parallelComponent (const Test& unitBasis) const {
          return unitBasis * projection;
        }

        Test setYtoZero (void) const {return Test (this->x);}

        static const Test zero;
    };


   inline Test operator* (float s, const Test& v) {return v*s;}


    inline std::ostream& operator<< (std::ostream& o, const Test& v)
    {
        return o << "(" << v.x << ")";
    }


    inline Test RandomUnitVectorOnXZPlane (void)
    {
        return RandomVectorInUnitRadiusSphere().setYtoZero().normalize();
    }
}

The interface used is:

%module test
%include "test.cpp"
SWIG generates 3 files, the first one is a C wrap which we don't show, the second is the plain CFFI wrapper which is as shown below:
(cffi:defcfun ("_wrap_Test_x_set" Test_x_set) :void
  (self :pointer)
  (x :float))

(cffi:defcfun ("_wrap_Test_x_get" Test_x_get) :float
  (self :pointer))

(cffi:defcfun ("_wrap_new_Test__SWIG_0" new_Test) :pointer)

(cffi:defcfun ("_wrap_new_Test__SWIG_1" new_Test) :pointer
  (X :float))

(cffi:defcfun ("_wrap_Test___add__" Test___add__) :pointer
  (self :pointer)
  (v :pointer))

(cffi:defcfun ("_wrap_Test_lengthSquared" Test_lengthSquared) :float
  (self :pointer))

(cffi:defcfun ("_wrap_Test_distance" Test_distance) :float
  (a :pointer)
  (b :pointer))

(cffi:defcfun ("_wrap_Test_parallelComponent" Test_parallelComponent) :pointer
  (self :pointer)
  (unitBasis :pointer))

(cffi:defcfun ("_wrap_Test_setYtoZero" Test_setYtoZero) :pointer
  (self :pointer))

(cffi:defcvar ("Test_zero" Test_zero)
 :pointer)

(cffi:defcfun ("_wrap_delete_Test" delete_Test) :void
  (self :pointer))

(cffi:defcfun ("_wrap___mul__" __mul__) :pointer
  (s :float)
  (v :pointer))

(cffi:defcfun ("_wrap___lshift__" __lshift__) :pointer
  (o :pointer)
  (v :pointer))

(cffi:defcfun ("_wrap_RandomUnitVectorOnXZPlane" RandomUnitVectorOnXZPlane) :pointer)
The output is pretty good but it fails in disambiguating overloaded functions such as the constructor, in this case. One way of resolving this problem is to make the interface use the rename directiv, but hopefully there are better solutions. In addition SWIG also generates, a CLOS file
(clos:defclass test()
  ((ff :reader ff-pointer)))

(clos:defmethod (cl:setf x) (arg0 (obj test))
  (Test_x_set (ff-pointer obj) arg0))

(clos:defmethod x ((obj test))
  (Test_x_get (ff-pointer obj)))

(cl:shadow "+")
(clos:defmethod + ((obj test) (self test) (v test))
  (Test___add__ (ff-pointer obj) (ff-pointer self) (ff-pointer v)))

(clos:defmethod length-squared ((obj test) (self test))
  (Test_lengthSquared (ff-pointer obj) (ff-pointer self)))

(clos:defmethod parallel-component ((obj test) (self test) (unitBasis test))
  (Test_parallelComponent (ff-pointer obj) (ff-pointer self) (ff-pointer unitBasis)))

(clos:defmethod set-yto-zero ((obj test) (self test))
  (Test_setYtoZero (ff-pointer obj) (ff-pointer self)))

I agree that the CFFI C++ module needs lot more work. But I hope it provides a starting point, on which you can base your work of importing C++ libraries to Lisp.

If you have any questions, suggestions, patches, etc., related to CFFI module feel free to contact us on the SWIG mailing list, and also please add a "[CFFI]" tag in the subject line.

27.2.4 Inserting user code into generated files

It is often necessary to include user-defined code into the automatically generated interface files. For example, when building a C++ interface, example_wrap.cxx will likely not compile unless you add a #include "header.h" directive. This can be done using the SWIG %insert(section) %{ ...code... %} directive:

%module example

%{
#include "header.h"
%}

%include "header.h"

int fact(int n);

Additional sections have been added for inserting into the generated lisp interface file:

  • lisphead - inserts before type declarations
  • swiglisp - inserts after type declarations according to where it appears in the .i file

Note that the block %{ ... %} is effectively a shortcut for %insert("header") %{ ... %}.

27.3 CLISP

CLISP is a feature-loaded implementation of common lisp which is portable across most of the operating system environments and hardware. CLISP includes an interpreter, a compiler, a debugger, CLOS, MOP, a foreign language interface, i18n, regular expressions, a socket interface, and more. An X11 interface is available through CLX, Garnet and CLUE/CLIO. Command line editing is provided by readline. CLISP runs Maxima, ACL2 and many other Common Lisp packages.

To run the clisp module of SWIG requires very little effort, you just need to execute:

swig -clisp -module module-name   file-name 

Because of the high level nature of the CLISP FFI, the bindings generated by SWIG may not be absolutely correct, and you may need to modify them. The good thing is that you don't need to complex interface file for the CLISP module. The CLISP module tries to produce code which is both human readable and easily modifyable.

27.3.1 Additional Commandline Options

The following table list the additional commandline options available for the CLISP module. They can also be seen by using:

swig -clisp -help 

CLISP specific options
-extern-all If this option is given then clisp definitions for all the functions
and global variables will be created otherwise only definitions for
externed functions and variables are created.
-generate-typedef If this option is given then def-c-type will be used to generate
shortcuts according to the typedefs in the input.

27.3.2 Details on CLISP bindings

As mentioned earlier the CLISP bindings generated by SWIG may need some modifications. The clisp module creates a lisp file with the same name as the module name. This lisp file contains a 'defpackage' declaration, with the package name same as the module name. This package uses the 'common-lisp' and 'ffi' packages. Also, package exports all the functions, structures and variables for which an ffi binding was generated.
After generating the defpackage statement, the clisp module also sets the default language.

(defpackage :test
    (:use :common-lisp :ffi)
  (:export
   :make-bar
   :bar-x
   :bar-y
   :bar-a
   :bar-b
   :bar-z
   :bar-n
   :pointer_func
   :func123
   :make-cfunr
   :lispsort_double
   :test123))

(in-package :test)

(default-foreign-language :stdc)

The ffi wrappers for functions and variables are generated as shown below. When functions have arguments of type "double * array", SWIG doesn't knows whether it is an 'out' argument or it is an array which will be passed, so SWIG plays it safe by declaring it as an '(array (ffi:c-ptr DOUBLE-FLOAT))'. For arguments of type "int **z[100]" where SWIG has more information, i.e., it knows that 'z' is an array of pointers to pointers of integers, SWIG defines it to be '(z (ffi:c-ptr (ffi:c-array (ffi:c-ptr (ffi:c-ptr ffi:int)) 100)))'

extern "C" {
int pointer_func(void (*ClosureFun)( void* _fun, void* _data, void* _evt ), int y);

int func123(div_t * x,int **z[100],int y[][1000][10]);

void lispsort_double (int n, double * array);

void test123(float x , double y);

}
(ffi:def-call-out pointer_func
    (:name "pointer_func")
  (:arguments (ClosureFun (ffi:c-function (:arguments (arg0 (ffi:c-pointer NIL))
						      (arg1 (ffi:c-pointer NIL))
						      (arg2 (ffi:c-pointer NIL)))
					  (:return-type NIL)))
	      (y ffi:int))
  (:return-type ffi:int)
  (:library +library-name+))

(ffi:def-call-out func123
    (:name "func123")
  (:arguments (x (ffi:c-pointer div_t))
	      (z (ffi:c-ptr (ffi:c-array (ffi:c-ptr (ffi:c-ptr ffi:int)) 100)))
	      (y (ffi:c-ptr (ffi:c-ptr (ffi:c-array ffi:int (1000 10))))))
  (:return-type ffi:int)
  (:library +library-name+))


(ffi:def-call-out lispsort_double
    (:name "lispsort_double")
  (:arguments (n ffi:int)
	      (array (ffi:c-ptr DOUBLE-FLOAT)))
  (:return-type NIL)
  (:library +library-name+))

(ffi:def-call-out test123
    (:name "test")
  (:arguments (x SINGLE-FLOAT)
	      (y DOUBLE-FLOAT))
  (:return-type NIL)
  (:library +library-name+))

The module also handles strutcures and #define constants as shown below. SWIG automatically adds the constructors and accessors created for the struct to the list of symbols exported by the package.

struct bar {
    short x, y;
    char a, b;
    int *z[1000];
    struct bar * n;
};

#define max 1000
(ffi:def-c-struct bar
    (x :type ffi:short)
  (y :type ffi:short)
  (a :type character)
  (b :type character)
  (z :type (ffi:c-array (ffi:c-ptr ffi:int) 1000))
  (n :type (ffi:c-pointer bar)))

(defconstant max 1000)

27.4 UFFI

swig-3.0.2/Doc/Manual/Varargs.html0000664000175000017500000007504312343706601016575 0ustar williamwilliam Variable Length Arguments

14 Variable Length Arguments

(a.k.a, "The horror. The horror.")

This chapter describes the problem of wrapping functions that take a variable number of arguments. For instance, generating wrappers for the C printf() family of functions.

This topic is sufficiently advanced to merit its own chapter. In fact, support for varargs is an often requested feature that was first added in SWIG-1.3.12. Most other wrapper generation tools have wisely chosen to avoid this issue.

14.1 Introduction

Some C and C++ programs may include functions that accept a variable number of arguments. For example, most programmers are familiar with functions from the C library such as the following:

int printf(const char *fmt, ...)
int fprintf(FILE *, const char *fmt, ...);
int sprintf(char *s, const char *fmt, ...);

Although there is probably little practical purpose in wrapping these specific C library functions in a scripting language (what would be the point?), a library may include its own set of special functions based on a similar API. For example:

int  traceprintf(const char *fmt, ...);

In this case, you may want to have some kind of access from the target language.

Before describing the SWIG implementation, it is important to discuss the common uses of varargs that you are likely to encounter in real programs. Obviously, there are the printf() style output functions as shown. Closely related to this would be scanf() style input functions that accept a format string and a list of pointers into which return values are placed. However, variable length arguments are also sometimes used to write functions that accept a NULL-terminated list of pointers. A good example of this would be a function like this:

int execlp(const char *path, const char *arg1, ...);
...

/* Example */
execlp("ls","ls","-l",NULL);

In addition, varargs is sometimes used to fake default arguments in older C libraries. For instance, the low level open() system call is often declared as a varargs function so that it will accept two or three arguments:

int open(const char *path, int oflag, ...);
...

/* Examples */
f = open("foo", O_RDONLY);
g = open("bar", O_WRONLY | O_CREAT, 0644);

Finally, to implement a varargs function, recall that you have to use the C library functions defined in <stdarg.h>. For example:

List make_list(const char *s, ...) {
    va_list ap;
    List    x;
    ...
    va_start(ap, s);
    while (s) {
       x.append(s);
       s = va_arg(ap, const char *);
    }
    va_end(ap);
    return x;
}

14.2 The Problem

Generating wrappers for a variable length argument function presents a number of special challenges. Although C provides support for implementing functions that receive variable length arguments, there are no functions that can go in the other direction. Specifically, you can't write a function that dynamically creates a list of arguments and which invokes a varargs function on your behalf.

Although it is possible to write functions that accept the special type va_list, this is something entirely different. You can't take a va_list structure and pass it in place of the variable length arguments to another varargs function. It just doesn't work.

The reason this doesn't work has to do with the way that function calls get compiled. For example, suppose that your program has a function call like this:

printf("Hello %s. Your number is %d\n", name, num);

When the compiler looks at this, it knows that you are calling printf() with exactly three arguments. Furthermore, it knows that the number of arguments as well are their types and sizes is never going to change during program execution. Therefore, this gets turned to machine code that sets up a three-argument stack frame followed by a call to printf().

In contrast, suppose you attempted to make some kind of wrapper around printf() using code like this:

int wrap_printf(const char *fmt, ...) {
   va_list ap;
   va_start(ap,fmt);
   ...
   printf(fmt,ap);
   ...
   va_end(ap);
};

Although this code might compile, it won't do what you expect. This is because the call to printf() is compiled as a procedure call involving only two arguments. However, clearly a two-argument configuration of the call stack is completely wrong if your intent is to pass an arbitrary number of arguments to the real printf(). Needless to say, it won't work.

Unfortunately, the situation just described is exactly the problem faced by wrapper generation tools. In general, the number of passed arguments will not be known until run-time. To make matters even worse, you won't know the types and sizes of arguments until run-time as well. Needless to say, there is no obvious way to make the C compiler generate code for a function call involving an unknown number of arguments of unknown types.

In theory, it is possible to write a wrapper that does the right thing. However, this involves knowing the underlying ABI for the target platform and language as well as writing special purpose code that manually constructed the call stack before making a procedure call. Unfortunately, both of these tasks require the use of inline assembly code. Clearly, that's the kind of solution you would much rather avoid.

With this nastiness in mind, SWIG provides a number of solutions to the varargs wrapping problem. Most of these solutions are compromises that provide limited varargs support without having to resort to assembly language. However, SWIG can also support real varargs wrapping (with stack-frame manipulation) if you are willing to get hands dirty. Keep reading.

14.3 Default varargs support

When variable length arguments appear in an interface, the default behavior is to drop the variable argument list entirely, replacing them with a single NULL pointer. For example, if you had this function,

void traceprintf(const char *fmt, ...);

it would be wrapped as if it had been declared as follows:

void traceprintf(const char *fmt);

When the function is called inside the wrappers, it is called as follows:

traceprintf(arg1, NULL);

Arguably, this approach seems to defeat the whole point of variable length arguments. However, this actually provides enough support for many simple kinds of varargs functions to still be useful, however it does come with a caveat. For instance, you could make function calls like this (in Python):

>>> traceprintf("Hello World")
>>> traceprintf("Hello %s. Your number is %d\n" % (name, num))
>>> traceprintf("Your result is 90%%.")

Notice how string formatting is being done in Python instead of C. The caveat is the strings passed must be safe to use in C though. For example if name was to contain a "%" it should be double escaped in order to avoid unpredictable behaviour:

>>> traceprintf("Your result is 90%.\n")  # unpredictable behaviour
>>> traceprintf("Your result is 90%%.\n") # good

Read on for further solutions.

14.4 Argument replacement using %varargs

Instead of dropping the variable length arguments, an alternative approach is to replace (...) with a set of suitable arguments. SWIG provides a special %varargs directive that can be used to do this. For example,

%varargs(int mode = 0) open;
...
int open(const char *path, int oflags, ...);

is equivalent to this:

int open(const char *path, int oflags, int mode = 0);

In this case, %varargs is simply providing more specific information about the extra arguments that might be passed to a function. If the arguments to a varargs function are of uniform type, %varargs can also accept a numerical argument count as follows:

%varargs(3, char *str = NULL) execlp;
...
int execlp(const char *path, const char *arg, ...);

and is effectively seen as:

int execlp(const char *path, const char *arg, 
           char *str1 = NULL, 
           char *str2 = NULL, 
           char *str3 = NULL);

This would wrap execlp() as a function that accepted up to 3 optional arguments. Depending on the application, this may be more than enough for practical purposes.

The handling of default arguments can be changed via the compactdefaultargs feature. If this feature is used, for example

%feature("compactdefaultargs") execlp;
%varargs(3, char *str = NULL) execlp;
...
int execlp(const char *path, const char *arg, ...);

a call from the target language which does not provide the maximum number of arguments, such as, execlp("a", "b", "c") will generate C code which includes the missing default values, that is, execlp("a", "b", "c", NULL, NULL). If compactdefaultargs is not used, then the generated code will be execlp("a", "b", "c"). The former is useful for helping providing a sentinel to terminate the argument list. However, this is not guaranteed, for example when a user passes a non-NULL value for all the parameters. When using compactdefaultargs it is possible to guarantee the NULL sentinel is passed through the, numinputs=0 'in' typemap attribute, naming the last parameter. For example,

%feature("compactdefaultargs") execlp;
%varargs(3, char *str = NULL) execlp;
%typemap(in, numinputs=0) char *str3 ""
...
int execlp(const char *path, const char *arg, ...);

Note that str3 is the name of the last argument, as we have used %varargs with 3. Now execlp("a", "b", "c", "d", "e") will result in an error as one too many arguments has been passed, as now only 2 additional 'str' arguments can be passed with the 3rd one always using the specified default NULL.

Argument replacement is most appropriate in cases where the types of the extra arguments are uniform and the maximum number of arguments are known. Argument replacement is not as useful when working with functions that accept mixed argument types such as printf(). Providing general purpose wrappers to such functions presents special problems (covered shortly).

14.5 Varargs and typemaps

Variable length arguments may be used in typemap specifications. For example:

%typemap(in) (...) {
    // Get variable length arguments (somehow)
    ...
}

%typemap(in) (const char *fmt, ...) {
    // Multi-argument typemap
}

However, this immediately raises the question of what "type" is actually used to represent (...). For lack of a better alternative, the type of (...) is set to void *. Since there is no way to dynamically pass arguments to a varargs function (as previously described), the void * argument value is intended to serve as a place holder for storing some kind of information about the extra arguments (if any). In addition, the default behavior of SWIG is to pass the void * value as an argument to the function. Therefore, you could use the pointer to hold a valid argument value if you wanted.

To illustrate, here is a safer version of wrapping printf() in Python:

%typemap(in) (const char *fmt, ...) {
    $1 = "%s";                                /* Fix format string to %s */
    $2 = (void *) PyString_AsString($input);  /* Get string argument */
};
...
int printf(const char *fmt, ...);

In this example, the format string is implicitly set to "%s". This prevents a program from passing a bogus format string to the extension. Then, the passed input object is decoded and placed in the void * argument defined for the (...) argument. When the actual function call is made, the underlying wrapper code will look roughly like this:

wrap_printf() {
   char *arg1;
   void *arg2;
   int   result;

   arg1 = "%s";
   arg2 = (void *) PyString_AsString(arg2obj);
   ...
   result = printf(arg1,arg2);
   ...
}

Notice how both arguments are passed to the function and it does what you would expect.

The next example illustrates a more advanced kind of varargs typemap. Disclaimer: this requires special support in the target language module and is not guaranteed to work with all SWIG modules at this time. It also starts to illustrate some of the more fundamental problems with supporting varargs in more generality.

If a typemap is defined for any form of (...), many SWIG modules will generate wrappers that accept a variable number of arguments as input and will make these arguments available in some form. The precise details of this depends on the language module being used (consult the appropriate chapter for more details). However, suppose that you wanted to create a Python wrapper for the execlp() function shown earlier. To do this using a typemap instead of using %varargs, you might first write a typemap like this:

%typemap(in) (...)(char *vargs[10]) {
  int i;
  int argc;
  for (i = 0; i < 10; i++) vargs[i] = 0;
  argc = PyTuple_Size(varargs);
  if (argc > 10) {
    PyErr_SetString(PyExc_ValueError, "Too many arguments");
    return NULL;
  }
  for (i = 0; i < argc; i++) {
    PyObject *pyobj = PyTuple_GetItem(varargs, i);
    char *str = 0;
%#if PY_VERSION_HEX>=0x03000000
    PyObject *pystr;
    if (!PyUnicode_Check(pyobj)) {
       PyErr_SetString(PyExc_ValueError, "Expected a string");
       return NULL;
    }
    pystr = PyUnicode_AsUTF8String(pyobj);
    str = strdup(PyBytes_AsString(pystr));
    Py_XDECREF(pystr);
%#else  
    if (!PyString_Check(pyobj)) {
       PyErr_SetString(PyExc_ValueError, "Expected a string");
       return NULL;
    }
    str = PyString_AsString(pyobj);
%#endif
    vargs[i] = str;
  }
  $1 = (void *)vargs;
}

%typemap(freearg) (...) {
%#if PY_VERSION_HEX>=0x03000000
  int i;
  for (i = 0; i < 10; i++) {
    free(vargs$argnum[i]);
  }
%#endif
}

In the 'in' typemap, the special variable varargs is a tuple holding all of the extra arguments passed (this is specific to the Python module). The typemap then pulls this apart and sticks the values into the array of strings args. Then, the array is assigned to $1 (recall that this is the void * variable corresponding to (...)). However, this assignment is only half of the picture----clearly this alone is not enough to make the function work. The 'freearg' typemap cleans up memory allocated in the 'in' typemap; this code is generated to be called after the execlp function is called. To patch everything up, you have to rewrite the underlying action code using the %feature directive like this:

%feature("action") execlp {
  char **vargs = (char **) arg3;
  result = execlp(arg1, arg2, vargs[0], vargs[1], vargs[2], vargs[3], vargs[4],
                  vargs[5], vargs[6], vargs[7], vargs[8], vargs[9], NULL);
}

int execlp(const char *path, const char *arg, ...);

This patches everything up and creates a function that more or less works. However, don't try explaining this to your coworkers unless you know for certain that they've had several cups of coffee. If you really want to elevate your guru status and increase your job security, continue to the next section.

14.6 Varargs wrapping with libffi

All of the previous examples have relied on features of SWIG that are portable and which don't rely upon any low-level machine-level details. In many ways, they have all dodged the real issue of variable length arguments by recasting a varargs function into some weaker variation with a fixed number of arguments of known types. In many cases, this works perfectly fine. However, if you want more generality than this, you need to bring out some bigger guns.

One way to do this is to use a special purpose library such as libffi (http://sources.redhat.com/libffi). libffi is a library that allows you to dynamically construct call-stacks and invoke procedures in a relatively platform independent manner. Details about the library can be found in the libffi distribution and are not repeated here.

To illustrate the use of libffi, suppose that you really wanted to create a wrapper for execlp() that accepted any number of arguments. To do this, you might make a few adjustments to the previous example. For example:

/* Take an arbitrary number of extra arguments and place into an array
   of strings */

%typemap(in) (...) {
   char **argv;
   int    argc;
   int    i;

   argc = PyTuple_Size(varargs);
   argv = (char **) malloc(sizeof(char *)*(argc+1));
   for (i = 0; i < argc; i++) {
      PyObject *o = PyTuple_GetItem(varargs,i);
      if (!PyString_Check(o)) {
          PyErr_SetString(PyExc_ValueError,"Expected a string");
	  free(argv);
          return NULL;
      }
      argv[i] = PyString_AsString(o);
   }
   argv[i] = NULL;
   $1 = (void *) argv;
}

/* Rewrite the function call, using libffi */    

%feature("action") execlp {
  int       i, vc;
  ffi_cif   cif;
  ffi_type  **types;
  void      **values;
  char      **args;

  vc = PyTuple_Size(varargs);
  types  = (ffi_type **) malloc((vc+3)*sizeof(ffi_type *));
  values = (void **) malloc((vc+3)*sizeof(void *));
  args   = (char **) arg3;

  /* Set up path parameter */
  types[0] = &ffi_type_pointer;
  values[0] = &arg1;
  
  /* Set up first argument */
  types[1] = &ffi_type_pointer;
  values[1] = &arg2;

  /* Set up rest of parameters */
  for (i = 0; i <= vc; i++) {
    types[2+i] = &ffi_type_pointer;
    values[2+i] = &args[i];
  }
  if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, vc+3,
                   &ffi_type_uint, types) == FFI_OK) {
    ffi_call(&cif, (void (*)()) execlp, &result, values);
  } else {
    PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
    free(types);
    free(values);
    free(arg3);
    return NULL;
  }
  free(types);
  free(values);
  free(arg3);
}

/* Declare the function. Whew! */
int execlp(const char *path, const char *arg1, ...);

Looking at this example, you may start to wonder if SWIG is making life any easier. Given the amount of code involved, you might also wonder why you didn't just write a hand-crafted wrapper! Either that or you're wondering "why in the hell am I trying to wrap this varargs function in the first place?!?" Obviously, those are questions you'll have to answer for yourself.

As a more extreme example of libffi, here is some code that attempts to wrap printf(),

/* A wrapper for printf() using libffi */

%{
/* Structure for holding passed arguments after conversion */
  typedef struct {
    int type;
    union {
      int    ivalue;
      double dvalue;
      void   *pvalue;
    } val;
  } vtype;
  enum { VT_INT, VT_DOUBLE, VT_POINTER };
%}

%typemap(in) (const char *fmt, ...) {
  vtype *argv;
  int    argc;
  int    i;

  /* Format string */
  $1 = PyString_AsString($input);

  /* Variable length arguments */
  argc = PyTuple_Size(varargs);
  argv = (vtype *) malloc(argc*sizeof(vtype));
  for (i = 0; i < argc; i++) {
    PyObject *o = PyTuple_GetItem(varargs,i);
    if (PyInt_Check(o)) {
      argv[i].type = VT_INT;
      argv[i].val.ivalue = PyInt_AsLong(o);
    } else if (PyFloat_Check(o)) {
      argv[i].type = VT_DOUBLE;
      argv[i].val.dvalue = PyFloat_AsDouble(o);
    } else if (PyString_Check(o)) {
      argv[i].type = VT_POINTER;
      argv[i].val.pvalue = (void *) PyString_AsString(o);
    } else {
      PyErr_SetString(PyExc_ValueError,"Unsupported argument type");
      free(argv);
      return NULL;
    }
  }
  $2 = (void *) argv;
}

/* Rewrite the function call using libffi */    
%feature("action") printf {
  int       i, vc;
  ffi_cif   cif;
  ffi_type  **types;
  void      **values;
  vtype     *args;

  vc = PyTuple_Size(varargs);
  types  = (ffi_type **) malloc((vc+1)*sizeof(ffi_type *));
  values = (void **) malloc((vc+1)*sizeof(void *));
  args   = (vtype *) arg2;

  /* Set up fmt parameter */
  types[0] = &ffi_type_pointer;
  values[0] = &arg1;

  /* Set up rest of parameters */
  for (i = 0; i < vc; i++) {
    switch(args[i].type) {
    case VT_INT:
      types[1+i] = &ffi_type_uint;
      values[1+i] = &args[i].val.ivalue;
      break;
    case VT_DOUBLE:
      types[1+i] = &ffi_type_double;
      values[1+i] = &args[i].val.dvalue;
      break;
    case VT_POINTER:
      types[1+i] = &ffi_type_pointer;
      values[1+i] = &args[i].val.pvalue;
      break;
    default:
      abort();    /* Whoa! We're seriously hosed */
      break;   
    }
  }
  if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, vc+1,
                   &ffi_type_uint, types) == FFI_OK) {
    ffi_call(&cif, (void (*)()) printf, &result, values);
  } else {
    PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
    free(types);
    free(values);
    free(args);
    return NULL;
  }
  free(types);
  free(values);
  free(args);
}

/* The function */
int printf(const char *fmt, ...);

Much to your amazement, it even seems to work if you try it:

>>> import example
>>> example.printf("Grade: %s   %d/60 = %0.2f%%\n", "Dave", 47, 47.0*100/60)
Grade: Dave   47/60 = 78.33%
>>>

Of course, there are still some limitations to consider:

>>> example.printf("la de da de da %s", 42)
Segmentation fault (core dumped)

And, on this note, we leave further exploration of libffi to the reader as an exercise. Although Python has been used as an example, most of the techniques in this section can be extrapolated to other language modules with a bit of work. The only details you need to know is how the extra arguments are accessed in each target language. For example, in the Python module, we used the special varargs variable to get these arguments. Modules such as Tcl8 and Perl5 simply provide an argument number for the first extra argument. This can be used to index into an array of passed arguments to get values. Please consult the chapter on each language module for more details.

14.7 Wrapping of va_list

Closely related to variable length argument wrapping, you may encounter functions that accept a parameter of type va_list. For example:

int vprintf(const char *fmt, va_list ap);

As far as we know, there is no obvious way to wrap these functions with SWIG. This is because there is no documented way to assemble the proper va_list structure (there are no C library functions to do it and the contents of va_list are opaque). Not only that, the contents of a va_list structure are closely tied to the underlying call-stack. It's not clear that exporting a va_list would have any use or that it would work at all.

A workaround can be implemented by writing a simple varargs C wrapper and then using the techniques discussed earlier in this chapter for varargs. Below is a simple wrapper for vprintf renamed so that it can still be called as vprintf from your target language. The %varargs used in the example restricts the function to taking one string argument.

%{
int vprintf(const char *fmt, va_list ap);
%}

%varargs(const char *) my_vprintf;
%rename(vprintf) my_vprintf;

%inline %{
int my_vprintf(const char *fmt, ...) {
  va_list ap;
  int result;

  va_start(ap, fmt);
  result = vprintf(fmt, ap);
  va_end(ap);
  return result;
}
%}

14.8 C++ Issues

Wrapping of C++ member functions that accept a variable number of arguments presents a number of challenges. By far, the easiest way to handle this is to use the %varargs directive. This is portable and it fully supports classes much like the %rename directive. For example:

%varargs (10, char * = NULL) Foo::bar;

class Foo {
public:
     virtual void bar(char *arg, ...);   // gets varargs above
};

class Spam: public Foo {
public:
     virtual void bar(char *arg, ...);   // gets varargs above
};

%varargs also works with constructors, operators, and any other C++ programming construct that accepts variable arguments.

Doing anything more advanced than this is likely to involve a serious world of pain. In order to use a library like libffi, you will need to know the underlying calling conventions and details of the C++ ABI. For instance, the details of how this is passed to member functions as well as any hidden arguments that might be used to pass additional information. These details are implementation specific and may differ between compilers and even different versions of the same compiler. Also, be aware that invoking a member function is further complicated if it is a virtual method. In this case, invocation might require a table lookup to obtain the proper function address (although you might be able to obtain an address by casting a bound pointer to a pointer to function as described in the C++ ARM section 18.3.4).

If you do decide to change the underlying action code, be aware that SWIG always places the this pointer in arg1. Other arguments are placed in arg2, arg3, and so forth. For example:

%feature("action") Foo::bar {
   ...
   result = arg1->bar(arg2, arg3, etc.);
   ...
}

Given the potential to shoot yourself in the foot, it is probably easier to reconsider your design or to provide an alternative interface using a helper function than it is to create a fully general wrapper to a varargs C++ member function.

14.9 Discussion

This chapter has provided a number of techniques that can be used to address the problem of variable length argument wrapping. If you care about portability and ease of use, the %varargs directive is probably the easiest way to tackle the problem. However, using typemaps, it is possible to do some very advanced kinds of wrapping.

One point of discussion concerns the structure of the libffi examples in the previous section. Looking at that code, it is not at all clear that this is the easiest way to solve the problem. However, there are a number of subtle aspects of the solution to consider--mostly concerning the way in which the problem has been decomposed. First, the example is structured in a way that tries to maintain separation between wrapper-specific information and the declaration of the function itself. The idea here is that you might structure your interface like this:

%typemap(const char *fmt, ...) {
   ...
}
%feature("action") traceprintf {
   ...
}

/* Include some header file with traceprintf in it */
%include "someheader.h"

Second, careful scrutiny will reveal that the typemaps involving (...) have nothing whatsoever to do with the libffi library. In fact, they are generic with respect to the way in which the function is actually called. This decoupling means that it will be much easier to consider other library alternatives for making the function call. For instance, if libffi wasn't supported on a certain platform, you might be able to use something else instead. You could use conditional compilation to control this:

#ifdef USE_LIBFFI
%feature("action") printf {
   ...
}
#endif
#ifdef USE_OTHERFFI
%feature("action") printf {
...
}
#endif

Finally, even though you might be inclined to just write a hand-written wrapper for varargs functions, the techniques used in the previous section have the advantage of being compatible with all other features of SWIG such as exception handling.

As a final word, some C programmers seem to have the assumption that the wrapping of variable length argument functions is an easily solved problem. However, this section has hopefully dispelled some of these myths. All things being equal, you are better off avoiding variable length arguments if you can. If you can't avoid them, please consider some of the simple solutions first. If you can't live with a simple solution, proceed with caution. At the very least, make sure you carefully read the section "A7.3.2 Function Calls" in Kernighan and Ritchie and make sure you fully understand the parameter passing conventions used for varargs. Also, be aware of the platform dependencies and reliability issues that this will introduce. Good luck.

swig-3.0.2/Doc/Manual/Perl5.html0000664000175000017500000026076212343706602016164 0ustar williamwilliam SWIG and Perl5

33 SWIG and Perl5

Caution: This chapter is under repair!

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.

33.1 Overview

To build Perl extension modules, SWIG uses a layered approach. At the lowest level, simple procedural wrappers are generated for functions, classes, methods, and other declarations in the input file. Then, for structures and classes, an optional collection of Perl proxy classes can be generated in order to provide a more natural object oriented Perl interface. These proxy classes simply build upon the low-level interface.

In describing the Perl interface, this chapter begins by covering the essentials. First, the problem of configuration, compiling, and installing Perl modules is discussed. Next, the low-level procedural interface is presented. Finally, proxy classes are described. Advanced customization features, typemaps, and other options are found near the end of the chapter.

33.2 Preliminaries

To build a Perl5 module, run SWIG using the -perl option as follows:

swig -perl example.i

This produces two files. The first file, example_wrap.c contains all of the C code needed to build a Perl5 module. The second file, example.pm contains supporting Perl code needed to properly load the module.

To build the module, you will need to compile the file example_wrap.c and link it with the rest of your program.

33.2.1 Getting the right header files

In order to compile, SWIG extensions need the following Perl5 header files:

#include "Extern.h"
#include "perl.h"
#include "XSUB.h"

These are typically located in a directory like this

/usr/lib/perl/5.14/CORE

The SWIG configuration script automatically tries to locate this directory so that it can compile examples. However, if you need to find out where the directory is located, an easy way to find out is to ask Perl itself:

$ perl -e 'use Config; print "$Config{archlib}\n";'
/usr/lib/perl/5.14

33.2.2 Compiling a dynamic module

The preferred approach to building an extension module is to compile it into a shared object file or DLL. Assuming you have code you need to link to in a file called example.c, you will need to compile your program using commands like this (shown for Linux):

$ swig -perl example.i
$ gcc -fPIC example.c
$ gcc -fPIC -c example_wrap.c -I/usr/lib/perl/5.14/CORE -Dbool=char
$ gcc -shared example.o example_wrap.o -o example.so

The exact compiler options vary from platform to platform. SWIG tries to guess the right options when it is installed. Therefore, you may want to start with one of the examples in the SWIG/Examples/perl5 directory. If that doesn't work, you will need to read the man-pages for your compiler and linker to get the right set of options. You might also check the SWIG Wiki for additional information.

When linking the module, the name of the shared object file must match the module name used in the SWIG interface file. If you used `%module example', then the target should be named `example.so', `example.sl', or the appropriate dynamic module name on your system.

33.2.3 Building a dynamic module with MakeMaker

It is also possible to use Perl to build dynamically loadable modules for you using the MakeMaker utility. To do this, write a Perl script such as the following:

# File : Makefile.PL
use ExtUtils::MakeMaker;
WriteMakefile(
	`NAME'    => `example',                  # Name of package
	`LIBS'    => [`-lm'],                    # Name of custom libraries
	`OBJECT'  => `example.o example_wrap.o'  # Object files
);

Now, to build a module, simply follow these steps:

$ perl Makefile.PL
$ make
$ make install

If you are planning to distribute a SWIG-generated module, this is the preferred approach to compilation. More information about MakeMaker can be found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen, and Randal Schwartz.

33.2.4 Building a static version of Perl

If you machine does not support dynamic loading or if you've tried to use it without success, you can build a new version of the Perl interpreter with your SWIG extensions added to it. To build a static extension, you first need to invoke SWIG as follows:

$ swig -perl -static example.i

By default SWIG includes code for dynamic loading, but the -static option takes it out.

Next, you will need to supply a main() function that initializes your extension and starts the Perl interpreter. While, this may sound daunting, SWIG can do this for you automatically as follows:

%module example

%inline %{
extern double My_variable;
extern int fact(int);
%}

// Include code for rebuilding Perl
%include <perlmain.i>

The same thing can be accomplished by running SWIG as follows:

$ swig -perl -static -lperlmain.i example.i

The perlmain.i file inserts Perl's main() function into the wrapper code and automatically initializes the SWIG generated module. If you just want to make a quick a dirty module, this may be the easiest way. By default, the perlmain.i code does not initialize any other Perl extensions. If you need to use other packages, you will need to modify it appropriately. You can do this by just copying perlmain.i out of the SWIG library, placing it in your own directory, and modifying it to suit your purposes.

To build your new Perl executable, follow the exact same procedure as for a dynamic module, but change the link line to something like this:

$ gcc example.o example_wrap.o -L/usr/lib/perl/5.14/CORE \
	-lperl -lsocket -lnsl -lm -o myperl

This will produce a new version of Perl called myperl. It should be functionality identical to Perl with your C/C++ extension added to it. Depending on your machine, you may need to link with additional libraries such as -lsocket, -lnsl, -ldl, etc.

33.2.5 Using the module

To use the module, simply use the Perl use statement. If all goes well, you will be able to do this:

$ perl
use example;
print example::fact(4),"\n";
24

A common error received by first-time users is the following:

use example;
Can't locate example.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at - line 1.
BEGIN failed--compilation aborted at - line 1.

This error is almost caused when the name of the shared object file you created doesn't match the module name you specified with the %module directive.

A somewhat related, but slightly different error is this:

use example;
Can't find 'boot_example' symbol in ./example.so
 at - line 1
BEGIN failed--compilation aborted at - line 1.

This error is generated because Perl can't locate the module bootstrap function in the SWIG extension module. This could be caused by a mismatch between the module name and the shared library name. However, another possible cause is forgetting to link the SWIG-generated wrapper code with the rest of your application when you linked the extension module.

Another common error is the following:

use example;
Can't load './example.so' for module example: ./example.so: 
undefined symbol: Foo at /usr/lib/perl/5.14/i386-linux/DynaLoader.pm line 169.

 at - line 1
BEGIN failed--compilation aborted at - line 1.

This error usually indicates that you forgot to include some object files or libraries in the linking of the shared library file. Make sure you compile both the SWIG wrapper file and your original program into a shared library file. Make sure you pass all of the required libraries to the linker.

Sometimes unresolved symbols occur because a wrapper has been created for a function that doesn't actually exist in a library. This usually occurs when a header file includes a declaration for a function that was never actually implemented or it was removed from a library without updating the header file. To fix this, you can either edit the SWIG input file to remove the offending declaration or you can use the %ignore directive to ignore the declaration. Better yet, update the header file so that it doesn't have an undefined declaration.

Finally, suppose that your extension module is linked with another library like this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -o example.so

If the foo library is compiled as a shared library, you might get the following error when you try to use your module:

use example;
Can't load './example.so' for module example: libfoo.so: cannot open shared object file: 
No such file or directory at /usr/lib/perl/5.14/i386-linux/DynaLoader.pm line 169.

 at - line 1
BEGIN failed--compilation aborted at - line 1.
>>>                 

This error is generated because the dynamic linker can't locate the libfoo.so library. When shared libraries are loaded, the system normally only checks a few standard locations such as /usr/lib and /usr/local/lib. To get the loader to look in other locations, there are several things you can do. First, you can recompile your extension module with extra path information. For example, on Linux you can do this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -Xlinker -rpath /home/beazley/projects/lib \
      -o example.so

Alternatively, you can set the LD_LIBRARY_PATH environment variable to include the directory with your shared libraries. If setting LD_LIBRARY_PATH, be aware that setting this variable can introduce a noticeable performance impact on all other applications that you run. To set it only for Perl, you might want to do this instead:

$ env LD_LIBRARY_PATH=/home/beazley/projects/lib perl

Finally, you can use a command such as ldconfig (Linux) or crle (Solaris) to add additional search paths to the default system configuration (this requires root access and you will need to read the man pages).

33.2.6 Compilation problems and compiling with C++

Compilation of C++ extensions has traditionally been a tricky problem. Since the Perl interpreter is written in C, you need to take steps to make sure C++ is properly initialized and that modules are compiled correctly.

On most machines, C++ extension modules should be linked using the C++ compiler. For example:

$ swig -c++ -perl example.i
$ g++ -fPIC -c example.cxx
$ g++ -fPIC -c example_wrap.cxx -I/usr/lib/perl/5.14/i386-linux/CORE
$ g++ -shared example.o example_wrap.o -o example.so

In addition to this, you may need to include additional library files to make it work. For example, if you are using the Sun C++ compiler on Solaris, you often need to add an extra library -lCrun like this:

$ swig -c++ -perl example.i
$ CC -Kpic -c example.cxx
$ CC -Kpic -c example_wrap.cxx -I/usr/lib/perl/5.14/i386-linux/CORE
$ CC -shared example.o example_wrap.o -o example.so -lCrun

Of course, the names of the extra libraries are completely non-portable---you will probably need to do some experimentation.

Another possible compile problem comes from recent versions of Perl (5.8.0) and the GNU tools. If you see errors having to do with _crypt_struct, that means _GNU_SOURCE is not defined and it needs to be. So you should compile the wrapper like:

$ g++ -fPIC -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE -D_GNU_SOURCE

-D_GNU_SOURCE is also included in the Perl ccflags, which can be found by running

$ perl -e 'use Config; print "$Config{ccflags}\n";'

So you could also compile the wrapper like

$ g++ -fPIC -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE \
`perl -MConfig -e 'print $Config{ccflags}'`

Sometimes people have suggested that it is necessary to relink the Perl interpreter using the C++ compiler to make C++ extension modules work. In the experience of this author, this has never actually appeared to be necessary on most platforms. Relinking the interpreter with C++ really only includes the special run-time libraries described above---as long as you link your extension modules with these libraries, it should not be necessary to rebuild Perl.

If you aren't entirely sure about the linking of a C++ extension, you might look at an existing C++ program. On many Unix machines, the ldd command will list library dependencies. This should give you some clues about what you might have to include when you link your extension module. For example, notice the first line of output here:

$ ldd swig
        libstdc++-libc6.1-1.so.2 => /usr/lib/libstdc++-libc6.1-1.so.2 (0x40019000)
        libm.so.6 => /lib/libm.so.6 (0x4005b000)
        libc.so.6 => /lib/libc.so.6 (0x40077000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
$

If linking wasn't enough of a problem, another major complication of C++ is that it does not define any sort of standard for binary linking of libraries. This means that C++ code compiled by different compilers will not link together properly as libraries nor is the memory layout of classes and data structures implemented in any kind of portable manner. In a monolithic C++ program, this problem may be unnoticed. However, in Perl, it is possible for different extension modules to be compiled with different C++ compilers. As long as these modules are self-contained, this probably won't matter. However, if these modules start sharing data, you will need to take steps to avoid segmentation faults and other erratic program behavior. Also, be aware that certain C++ features, especially RTTI, can behave strangely when working with multiple modules.

It should be noted that you may get a lot of error messages about the 'bool' datatype when compiling a C++ Perl module. If you experience this problem, you can try the following:

  • Use -DHAS_BOOL when compiling the SWIG wrapper code
  • Or use -Dbool=char when compiling.

Finally, recent versions of Perl (5.8.0) have namespace conflict problems. Perl defines a bunch of short macros to make the Perl API function names shorter. For example, in /usr/lib/perl/5.8.0/CORE/embed.h there is a line:

#define do_open Perl_do_open

The problem is, in the <iostream> header from GNU libstdc++v3 there is a private function named do_open. If <iostream> is included after the perl headers, then the Perl macro causes the iostream do_open to be renamed, which causes compile errors. Hopefully in the future Perl will support a PERL_NO_SHORT_NAMES flag, but for now the only solution is to undef the macros that conflict. Lib/perl5/noembed.h in the SWIG source has a list of macros that are known to conflict with either standard headers or other headers. But if you get macro type conflicts from other macros not included in Lib/perl5/noembed.h while compiling the wrapper, you will have to find the macro that conflicts and add an #undef into the .i file. Please report any conflicting macros you find to swig-user mailing list.

33.2.7 Compiling for 64-bit platforms

On platforms that support 64-bit applications (Solaris, Irix, etc.), special care is required when building extension modules. On these machines, 64-bit applications are compiled and linked using a different set of compiler/linker options. In addition, it is not generally possible to mix 32-bit and 64-bit code together in the same application.

To utilize 64-bits, the Perl executable will need to be recompiled as a 64-bit application. In addition, all libraries, wrapper code, and every other part of your application will need to be compiled for 64-bits. If you plan to use other third-party extension modules, they will also have to be recompiled as 64-bit extensions.

If you are wrapping commercial software for which you have no source code, you will be forced to use the same linking standard as used by that software. This may prevent the use of 64-bit extensions. It may also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

33.3 Building Perl Extensions under Windows

Building a SWIG extension to Perl under Windows is roughly similar to the process used with Unix. Normally, you will want to produce a DLL that can be loaded into the Perl interpreter. This section assumes you are using SWIG with Microsoft Visual C++ although the procedure may be similar with other compilers.

33.3.1 Running SWIG from Developer Studio

If you are developing your application within Microsoft developer studio, SWIG can be invoked as a custom build option. The process roughly requires these steps:

  • Open up a new workspace and use the AppWizard to select a DLL project.
  • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (ie. example_wrap.c). Note: If using C++, choose a different suffix for the wrapper file such as example_wrap.cxx. Don't worry if the wrapper file doesn't exist yet--Developer studio will keep a reference to it around.
  • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
  • Enter "SWIG" in the description field.
  • Enter "swig -perl5 -o $(ProjDir)\$(InputName)_wrap.cxx $(InputPath)" in the "Build command(s) field"
  • Enter "$(ProjDir)\$(InputName)_wrap.cxx" in the "Output files(s) field".
  • Next, select the settings for the entire project and go to "C++:Preprocessor". Add the include directories for your Perl 5 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.
  • Finally, select the settings for the entire project and go to "Link Options". Add the Perl library file to your link libraries. For example "perl.lib". Also, set the name of the output file to match the name of your Perl module (ie. example.dll).
  • Build your project.

Now, assuming you made it this far, SWIG will be automatically invoked when you build your project. Any changes made to the interface file will result in SWIG being automatically invoked to produce a new version of the wrapper file. To run your new Perl extension, simply run Perl and use the use command as normal. For example:

DOS > perl
use example;
$a = example::fact(4);
print "$a\n";

33.3.2 Using other compilers

SWIG is known to work with Cygwin and may work with other compilers on Windows. For general hints and suggestions refer to the Windows chapter.

33.4 The low-level interface

At its core, the Perl module uses a simple low-level interface to C function, variables, constants, and classes. This low-level interface can be used to control your application. However, it is also used to construct more user-friendly proxy classes as described in the next section.

33.4.1 Functions

C functions are converted into new Perl built-in commands (or subroutines). For example:

%module example
int fact(int a);
...

Now, in Perl:

use example;
$a = &example::fact(2);

33.4.2 Global variables

Global variables are handled using Perl's magic variable mechanism. SWIG generates a pair of functions that intercept read/write operations and attaches them to a Perl variable with the same name as the C global variable. Thus, an interface like this

%module example;
...
double Spam;
...

is accessed as follows:

use example;
print $example::Spam,"\n";
$example::Spam = $example::Spam + 4
# ... etc ...

If a variable is declared as const, it is wrapped as a read-only variable. Attempts to modify its value will result in an error.

To make ordinary variables read-only, you can also use the %immutable directive. For example:

%{
extern char *path;
%}
%immutable;
extern char *path;
%mutable;

The %immutable directive stays in effect until it is explicitly disabled or cleared using %mutable. See the Creating read-only variables section for further details.

It is also possible to tag a specific variable as read-only like this:

%{
extern char *path;
%}
%immutable path; 
...
...
extern char *path;       // Declared later in the input

33.4.3 Constants

By default, constants are wrapped as read-only Perl variables. For example:

%module example

#define FOO 42

In Perl:

use example;
print $example::FOO,"\n";    # OK
$example::FOO = 2;           # Error

Alternatively, if you use swig's -const option, constants are wrapped such that the leading $ isn't required (by using a constant subroutine), which usually gives a more natural Perl interface, for example:

use example;
print example::FOO,"\n";

33.4.4 Pointers

SWIG represents pointers as blessed references. A blessed reference is the same as a Perl reference except that it has additional information attached to it indicating what kind of reference it is. That is, if you have a C declaration like this:

Matrix *new_Matrix(int n, int m);

The module returns a value generated as follows:

$ptr = new_Matrix(int n, int m);     # Save pointer return result
bless $ptr, "p_Matrix";              # Bless it as a pointer to Matrix

SWIG uses the "blessing" to check the datatype of various pointers. In the event of a mismatch, an error or warning message is generated.

To check to see if a value is the NULL pointer, use the defined() command:

if (defined($ptr)) {
	print "Not a NULL pointer.";
} else {
	print "Is a NULL pointer.";
}

To create a NULL pointer, you should pass the undef value to a function.

The "value" of a Perl reference is not the same as the underlying C pointer that SWIG wrapper functions return. Suppose that $a and $b are two references that point to the same C object. In general, $a and $b will be different--since they are different references. Thus, it is a mistake to check the equality of $a and $b to check the equality of two C pointers. The correct method to check equality of C pointers is to dereference them as follows:

if ($$a == $$b) {
	print "a and b point to the same thing in C";
} else {
	print "a and b point to different objects.";
}

As much as you might be inclined to modify a pointer value directly from Perl, don't. Manipulating pointer values is architecture dependent and could cause your program to crash. Similarly, don't try to manually cast a pointer to a new type by reblessing a pointer. This may not work like you expect and it is particularly dangerous when casting C++ objects. If you need to cast a pointer or change its value, consider writing some helper functions instead. For example:

%inline %{
/* C-style cast */
Bar *FooToBar(Foo *f) {
   return (Bar *) f;
}

/* C++-style cast */
Foo *BarToFoo(Bar *b) {
   return dynamic_cast<Foo*>(b);
}

Foo *IncrFoo(Foo *f, int i) {
    return f+i;
}
%}

Also, if working with C++, you should always try to use the new C++ style casts. For example, in the above code, the C-style cast may return a bogus result whereas as the C++-style cast will return NULL if the conversion can't be performed.

Compatibility Note: In earlier versions, SWIG tried to preserve the same pointer naming conventions as XS and xsubpp. Given the advancement of the SWIG typesystem and the growing differences between SWIG and XS, this is no longer supported.

33.4.5 Structures

Access to the contents of a structure are provided through a set of low-level accessor functions as described in the "SWIG Basics" chapter. For example,

struct Vector {
	double x,y,z;
};

gets mapped into the following collection of accessor functions:

struct Vector *new_Vector();
void           delete_Vector(Vector *v);
double         Vector_x_get(Vector *obj)
void           Vector_x_set(Vector *obj, double x)
double         Vector_y_get(Vector *obj)
void           Vector_y_set(Vector *obj, double y)
double         Vector_z_get(Vector *obj)
void           Vector_z_set(Vector *obj, double z)

These functions are then used to access structure data from Perl as follows:

$v = example::new_Vector();
print example::Vector_x_get($v),"\n";    # Get x component
example::Vector_x_set($v,7.8);          # Change x component

Similar access is provided for unions and the data members of C++ classes.

const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive. For example:

struct Foo {
   ...
   %immutable;
   int x;        /* Read-only members */
   char *name;
   %mutable;
   ...
};

When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run with the -c++ option). When the structure member is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described later).

Array members are normally wrapped as read-only. For example,

struct Foo {
   int  x[50];
};

produces a single accessor function like this:

int *Foo_x_get(Foo *self) {
    return self->x;
};

If you want to set an array member, you will need to supply a "memberin" typemap described later in this chapter. As a special case, SWIG does generate code to set array members of type char (allowing you to store a Python string in the structure).

When structure members are wrapped, they are handled as pointers. For example,

struct Foo {
   ...
};

struct Bar {
   Foo f;
};

generates accessor functions such as this:

Foo *Bar_f_get(Bar *b) {
    return &b->f;
}

void Bar_f_set(Bar *b, Foo *val) {
    b->f = *val;
}

33.4.6 C++ classes

C++ classes are wrapped by building a set of low level accessor functions. Consider the following class:

class List {
public:
  List();
  ~List();
  int  search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int  length;
static void print(List *l);
};

When wrapped by SWIG, the following functions are created:

List    *new_List();
void     delete_List(List *l);
int      List_search(List *l, char *item);
void     List_insert(List *l, char *item);
void     List_remove(List *l, char *item);
char    *List_get(List *l, int n);
int      List_length_get(List *l);
void     List_length_set(List *l, int n);
void     List_print(List *l);

In Perl, these functions are used in a straightforward manner:

use example;
$l = example::new_List();
example::List_insert($l,"Ale");
example::List_insert($l,"Stout");
example::List_insert($l,"Lager")
example::List_print($l)
Lager
Stout
Ale
print example::List_length_get($l),"\n";
3

At this low level, C++ objects are really just typed pointers. Member functions are accessed by calling a C-like wrapper with an instance pointer as the first argument. Although this interface is fairly primitive, it provides direct access to C++ objects. A higher level interface using Perl proxy classes can be built using these low-level accessors. This is described shortly.

33.4.7 C++ classes and type-checking

The SWIG type-checker is fully aware of C++ inheritance. Therefore, if you have classes like this

class Foo {
...
};

class Bar : public Foo {
...
};

and a function

void spam(Foo *f);

then the function spam() accepts Foo * or a pointer to any class derived from Foo. If necessary, the type-checker also adjusts the value of the pointer (as is necessary when multiple inheritance is used).

33.4.8 C++ overloaded functions

If you have a C++ program with overloaded functions or methods, you will need to disambiguate those methods using %rename. For example:

/* Forward renaming declarations */
%rename(foo_i) foo(int); 
%rename(foo_d) foo(double);
...
void foo(int);           // Becomes 'foo_i'
void foo(char *c);       // Stays 'foo' (not renamed)

class Spam {
public:
   void foo(int);      // Becomes 'foo_i'
   void foo(double);   // Becomes 'foo_d'
   ...
};

Now, in Perl, the methods are accessed as follows:

use example;
example::foo_i(3);
$s = example::new_Spam();
example::Spam_foo_i($s,3);
example::Spam_foo_d($s,3.14);

Please refer to the "SWIG Basics" chapter for more information.

33.4.9 Operators

As of version 1.3.27 SWIG automatically renames the most common C++ operators, and maps them into the perl module with the proper 'use overload ...' so you don't need to do any work.

The following C++ operators are currently supported by the Perl module:

  • operator++
  • operator--
  • operator+
  • operator-
  • operator*
  • operator/
  • operator==
  • operator!=
  • operator%
  • operator>
  • operator<
  • operator and
  • operator or

33.4.10 Modules and packages

When you create a SWIG extension, everything gets placed into a single Perl module. The name of the module is determined by the %module directive. To use the module, do the following:

$ perl5
use example;                      # load the example module
print example::fact(4),"\n"       # Call a function in it
24

Usually, a module consists of a collection of code that is contained within a single file. A package, on the other hand, is the Perl equivalent of a namespace. A package is a lot like a module, except that it is independent of files. Any number of files may be part of the same package--or a package may be broken up into a collection of modules if you prefer to think about it in this way.

SWIG installs its functions into a package with the same name as the module.

Incompatible Change: previous versions of SWIG enabled you to change the name of the package by using the -package option, this feature has been removed in order to properly support modules that used nested namespaces, e.g. Foo::Bar::Baz. To give your module a nested namespace simply provide the fully qualified name in your %module directive:

%module "Foo::Bar::Baz"

NOTE: the double quotes are necessary.

Using the package option of the %module directive allows you to specify what Perl namespace that the module will be living in when installed. This is useful in the situation where a module maintainer wants to split a large module into smaller pieces to make maintenance easier, but doesn't want to have that affect the module name used by applications. So for example, if I wanted to split XML::Xerces into XML::Xerces::SAX, etc. , but I wanted all the applications to be able to access the classes using the XML::Xerces namespace I could use:

%module(package="XML::Xerces") "XML::Xerces::SAX

And now all the applications could use the class XML::Xerces::SAXParser. Without the package directive splitting the module would force applications to use the class XML::Xerces::SAX::SAXParser. This could break compatibility for existing applications that are already using the class under the name XML::Xerces::SAXParser.

33.5 Input and output parameters

A common problem in some C programs is handling parameters passed as simple pointers. For example:

void add(int x, int y, int *result) {
   *result = x + y;
}

or perhaps

int sub(int *x, int *y) {
   return *x+*y;
}

The easiest way to handle these situations is to use the typemaps.i file. For example:

%module example
%include "typemaps.i"

void add(int, int, int *OUTPUT);
int  sub(int *INPUT, int *INPUT);

In Perl, this allows you to pass simple values. For example:

$a = example::add(3,4);
print "$a\n";
7
$b = example::sub(7,4);
print "$b\n";
3

Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter creates a return result.

If you don't want to use the names INPUT or OUTPUT, use the %apply directive. For example:

%module example
%include "typemaps.i"

%apply int *OUTPUT { int *result };
%apply int *INPUT  { int *x, int *y};

void add(int x, int y, int *result);
int  sub(int *x, int *y);

If a function mutates one of its parameters like this,

void negate(int *x) {
   *x = -(*x);
}

you can use INOUT like this:

%include "typemaps.i"
...
void negate(int *INOUT);

In Perl, a mutated parameter shows up as a return value. For example:

$a = example::negate(3);
print "$a\n";
-3

The most common use of these special typemap rules is to handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

/* send message, return number of bytes sent, along with success code */
int send_message(char *text, int len, int *success);

To wrap such a function, simply use the OUTPUT rule above. For example:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *success };
...
int send_message(char *text, int *success);

When used in Perl, the function will return multiple values.

($bytes, $success) = example::send_message("Hello World");

Another common use of multiple return values are in query functions. For example:

void get_dimensions(Matrix *m, int *rows, int *columns);

To wrap this, you might use the following:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *rows, int *columns };
...
void get_dimensions(Matrix *m, int *rows, *columns);

Now, in Perl:

($r,$c) = example::get_dimensions($m);

In certain cases, it is possible to treat Perl references as C pointers. To do this, use the REFERENCE typemap. For example:

%module example
%include "typemaps.i"

void add(int x, int y, int *REFERENCE);

In Perl:

use example;
$c = 0.0;
example::add(3,4,\$c);
print "$c\n";
7

Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).

33.6 Exception handling

The SWIG %exception directive can be used to create a user-definable exception handler for converting exceptions in your C/C++ program into Perl exceptions. The chapter on customization features contains more details, but suppose you have a C++ class like the following:

class RangeError {};   // Used for an exception

class DoubleArray {
  private:
    int n;
    double *ptr;
  public:
    // Create a new array of fixed size
    DoubleArray(int size) {
      ptr = new double[size];
      n = size;
    }
    // Destroy an array
    ~DoubleArray() {
       delete ptr;
    }
    // Return the length of the array
    int   length() {
      return n;
    }

    // Get an item from the array and perform bounds checking.
    double getitem(int i) {
      if ((i >= 0) && (i < n))
        return ptr[i];
      else
        throw RangeError();
    }

    // Set an item in the array and perform bounds checking.
    void setitem(int i, double val) {
      if ((i >= 0) && (i < n))
        ptr[i] = val;
      else {
        throw RangeError();
      }
    }
  };

Since several methods in this class can throw an exception for an out-of-bounds access, you might want to catch this in the Perl extension by writing the following in an interface file:

%exception {
  try {
    $action
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}

class DoubleArray {
...
};

The exception handling code is inserted directly into generated wrapper functions. The $action variable is replaced with the C/C++ code being executed by the wrapper. When an exception handler is defined, errors can be caught and used to gracefully generate a Perl error instead of forcing the entire program to terminate with an uncaught error.

As shown, the exception handling code will be added to every wrapper function. Since this is somewhat inefficient. You might consider refining the exception handler to only apply to specific methods like this:

%exception getitem {
  try {
    $action
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}

%exception setitem {
  try {
    $action
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}

In this case, the exception handler is only attached to methods and functions named getitem and setitem.

If you had a lot of different methods, you can avoid extra typing by using a macro. For example:

%define RANGE_ERROR
{
  try {
    $action
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}
%enddef

%exception getitem RANGE_ERROR;
%exception setitem RANGE_ERROR;

Since SWIG's exception handling is user-definable, you are not limited to C++ exception handling. See the chapter on "Customization features" for more examples.

Compatibility note: In SWIG1.1, exceptions were defined using the older %except directive:

%except(python) {
  try {
    $function
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}

This is still supported, but it is deprecated. The newer %exception directive provides the same functionality, but it has additional capabilities that make it more powerful.

33.7 Remapping datatypes with typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Perl C API as well as the material in the "Typemaps" chapter.

Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the primitive C-Perl interface.

33.7.1 A simple typemap example

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Perl to C, you might define a typemap like this:

%module example

%typemap(in) int {
	$1 = (int) SvIV($input);
	printf("Received an integer : %d\n", $1);
}
...
%inline %{
extern int fact(int n);
%}

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input variable is the input object (usually a SV *).

When this example is used in Perl5, it will operate as follows:

use example;
$n = example::fact(6);
print "$n\n";
...

Output:
Received an integer : 6
720

The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG type-system. When you define a typemap for int, that typemap applies to int and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

%typemap(in) int n {
	$1 = (int) SvIV($input);
	printf("n = %d\n",$1);
}
%inline %{
typedef int Integer;
extern int fact(Integer n);    // Above typemap is applied
%}

It should be noted that the matching of typedef only occurs in one direction. If you defined a typemap for Integer, it is not applied to arguments of type int.

Typemaps can also be defined for groups of consecutive arguments. For example:

%typemap(in) (char *str, unsigned len) {
    $1 = SvPV($input,$2);
};

int count(char c, char *str, unsigned len);

When a multi-argument typemap is defined, the arguments are always handled as a single Perl object. This allows the function to be used like this (notice how the length parameter is omitted):

example::count("e","Hello World");
1
>>>

33.7.2 Perl5 typemaps

The previous section illustrated an "in" typemap for converting Perl objects to C. A variety of different typemap methods are defined by the Perl module. For example, to convert a C integer back into a Perl object, you might define an "out" typemap like this:

%typemap(out) int {
    $result = sv_newmortal();
    set_setiv($result, (IV) $1);
    argvi++;
}

The following typemap methods are available:

%typemap(in)

Converts Perl5 object to input function arguments.

%typemap(out)

Converts function return value to a Perl5 value.

%typemap(varin)

Converts a Perl5 object to a global variable.

%typemap(varout)

Converts a global variable to a Perl5 object.

%typemap(freearg)

Cleans up a function argument after a function call

%typemap(argout)

Output argument handling

%typemap(ret)

Clean up return value from a function.

%typemap(memberin)

Setting of C++ member data (all languages).

%typemap(memberout)

Return of C++ member data (all languages).

%typemap(check)

Check value of input parameter.

33.7.3 Typemap variables

Within typemap code, a number of special variables prefaced with a $ may appear. A full list of variables can be found in the "Typemaps" chapter. This is a list of the most common variables:

$1

A C local variable corresponding to the actual type specified in the %typemap directive. For input values, this is a C local variable that's supposed to hold an argument value. For output values, this is the raw result that's supposed to be returned to Perl.

$input

A Perl object holding the value of an argument of variable value.

$result

A Perl object that holds the result to be returned to Perl.

$1_name

The parameter name that was matched.

$1_type

The actual C datatype matched by the typemap.

$1_ltype

An assignable version of the datatype matched by the typemap (a type that can appear on the left-hand-side of a C assignment operation). This type is stripped of qualifiers and may be an altered version of $1_type. All arguments and local variables in wrapper functions are declared using this type so that their values can be properly assigned.

$symname

The Perl name of the wrapper function being created.

33.7.4 Useful functions

When writing typemaps, it is necessary to work directly with Perl5 objects. This, unfortunately, can be a daunting task. Consult the "perlguts" man-page for all of the really ugly details. A short summary of commonly used functions is provided here for reference. It should be stressed that SWIG can be used quite effectively without knowing any of these details--especially now that there are typemap libraries that can already been written.

Perl Integer Functions

int   SvIV(SV *);
void  sv_setiv(SV *sv, IV value);
SV   *newSViv(IV value);
int   SvIOK(SV *);

Perl Floating Point Functions

double SvNV(SV *);
void   sv_setnv(SV *, double value);
SV    *newSVnv(double value);
int    SvNOK(SV *);

Perl String Functions

char     *SvPV(SV *, STRLEN len);
void      sv_setpv(SV *, char *val);
void      sv_setpvn(SV *, char *val, STRLEN len);
SV       *newSVpv(char *value, STRLEN len);
int       SvPOK(SV *);
void      sv_catpv(SV *, char *);
void      sv_catpvn(SV *, char *, STRLEN);

Perl References

void      sv_setref_pv(SV *, char *, void *ptr);
int       sv_isobject(SV *);
SV       *SvRV(SV *);
int       sv_isa(SV *, char *0;

33.8 Typemap Examples

This section includes a few examples of typemaps. For more examples, you might look at the files "perl5.swg" and "typemaps.i" in the SWIG library.

33.8.1 Converting a Perl5 array to a char **

A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Perl5 array reference to be used as a char ** datatype.

%module argv

// This tells SWIG to treat char ** as a special case
%typemap(in) char ** {
	AV *tempav;
	I32 len;
	int i;
	SV  **tv;
	if (!SvROK($input))
	    croak("Argument $argnum is not a reference.");
        if (SvTYPE(SvRV($input)) != SVt_PVAV)
	    croak("Argument $argnum is not an array.");
        tempav = (AV*)SvRV($input);
	len = av_len(tempav);
	$1 = (char **) malloc((len+2)*sizeof(char *));
	for (i = 0; i <= len; i++) {
	    tv = av_fetch(tempav, i, 0);	
	    $1[i] = (char *) SvPV(*tv,PL_na);
        }
	$1[i] = NULL;
};

// This cleans up the char ** array after the function call
%typemap(freearg) char ** {
	free($1);
}

// Creates a new Perl array and places a NULL-terminated char ** into it
%typemap(out) char ** {
	AV *myav;
	SV **svs;
	int i = 0,len = 0;
	/* Figure out how many elements we have */
	while ($1[len])
	   len++;
	svs = (SV **) malloc(len*sizeof(SV *));
	for (i = 0; i < len ; i++) {
	    svs[i] = sv_newmortal();
	    sv_setpv((SV*)svs[i],$1[i]);
	};
	myav =	av_make(len,svs);
	free(svs);
        $result = newRV_noinc((SV*)myav);
        sv_2mortal($result);
        argvi++;
}

// Now a few test functions
%inline %{
int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
         printf("argv[%d] = %s\n", i,argv[i]);
         i++;
    }
    return i;
}

// Returns a char ** list 
char **get_args() {
    static char *values[] = { "Dave", "Mike", "Susan", "John", "Michelle", 0};
    return &values[0];
}
%}

When this module is compiled, the wrapped C functions can be used in a Perl script as follows:

use argv;
@a = ("Dave", "Mike", "John", "Mary");           # Create an array of strings
argv::print_args(\@a);                           # Pass it to our C function
$b = argv::get_args();                           # Get array of strings from C
print @$b,"\n";                                  # Print it out

33.8.2 Return values

Return values are placed on the argument stack of each wrapper function. The current value of the argument stack pointer is contained in a variable argvi. Whenever a new output value is added, it is critical that this value be incremented. For multiple output values, the final value of argvi should be the total number of output values.

The total number of return values should not exceed the number of input values unless you explicitly extend the argument stack. This can be done using the EXTEND() macro as in:

%typemap(argout) int *OUTPUT {
	if (argvi >= items) {            
		EXTEND(sp,1);              /* Extend the stack by 1 object */
	}
	$result = sv_newmortal();
	sv_setiv($target,(IV) *($1));
	argvi++;
}

33.8.3 Returning values from arguments

Sometimes it is desirable for a function to return a value in one of its arguments. This example describes the implementation of the OUTPUT typemap.

%module return

// This tells SWIG to treat an double * argument with name 'OutDouble' as
// an output value.  

%typemap(argout) double *OUTPUT {
	$result = sv_newmortal();
	sv_setnv($result, *$input);
	argvi++;                     /* Increment return count -- important! */
}

// We don't care what the input value is. Ignore, but set to a temporary variable

%typemap(in,numinputs=0) double *OUTPUT(double junk) {
	$1 = &junk;
}

// Now a function to test it
%{
/* Returns the first two input arguments */
int multout(double a, double b, double *out1, double *out2) {
	*out1 = a;
	*out2 = b;
	return 0;
};
%}

// If we name both parameters OutDouble both will be output

int multout(double a, double b, double *OUTPUT, double *OUTPUT);
...

When this function is called, the output arguments are appended to the stack used to return results. This shows up an array in Perl. For example:

@r = multout(7,13);
print "multout(7,13) = @r\n";
($x,$y) = multout(7,13);

33.8.4 Accessing array structure members

Consider the following data structure:

#define SIZE  8
typedef struct {
    int   values[SIZE];
    ...
} Foo;

By default, SWIG doesn't know how to the handle the values structure member it's an array, not a pointer. In this case, SWIG makes the array member read-only. Reading will simply return a pointer to the first item in the array. To make the member writable, a "memberin" typemap can be used.

%typemap(memberin) int [SIZE] {
    int i;
    for (i = 0; i < SIZE; i++) {
        $1[i] = $input[i];
    }
}

Whenever a int [SIZE] member is encountered in a structure or class, this typemap provides a safe mechanism for setting its value.

As in the previous example, the typemap can be generalized for any dimension. For example:

%typemap(memberin) int [ANY] {
   int i;
   for (i = 0; i < $1_dim0; i++) {
      $1[i] = $input[i];
   }
}

When setting structure members, the input object is always assumed to be a C array of values that have already been converted from the target language. Because of this, the memberin typemap is almost always combined with the use of an "in" typemap. For example, the "in" typemap in the previous section would be used to convert an int[] array to C whereas the "memberin" typemap would be used to copy the converted array into a C data structure.

33.8.5 Turning Perl references into C pointers

A frequent confusion on the SWIG mailing list is errors caused by the mixing of Perl references and C pointers. For example, suppose you have a C function that modifies its arguments like this:

void add(double a, double b, double *c) {
	*c = a + b;
}

A common misinterpretation of this function is the following Perl script:

# Perl script
$a = 3.5;
$b = 7.5;
$c = 0.0;          # Output value
add($a,$b,\$c);    # Place result in c (Except that it doesn't work)

To make this work with a reference, you can use a typemap such as this:

%typemap(in) double * (double dvalue) {
  SV* tempsv;
  if (!SvROK($input)) {
    croak("expected a reference\n");
  }
  tempsv = SvRV($input);
  if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
    croak("expected a double reference\n");
  }
  dvalue = SvNV(tempsv);
  $1 = &dvalue;
}

%typemap(argout) double * {
  SV *tempsv;
  tempsv = SvRV($input);
  sv_setnv(tempsv, *$1);
}

Now, if you place this before the add function, you can do this:

$a = 3.5;
$b = 7.5;
$c = 0.0;
add($a,$b,\$c);            # Now it works!
print "$c\n";

33.8.6 Pointer handling

Occasionally, it might be necessary to convert pointer values that have been stored using the SWIG typed-pointer representation. To convert a pointer from Perl to C, the following function is used:

int SWIG_ConvertPtr(SV *obj, void **ptr, swig_type_info *ty, int flags)

Converts a Perl object obj to a C pointer. The result of the conversion is placed into the pointer located at ptr. ty is a SWIG type descriptor structure. flags is used to handle error checking and other aspects of conversion. flags is currently undefined and reserved for future expansion. Returns 0 on success and -1 on error.

void *SWIG_MakePtr(SV *obj, void *ptr, swig_type_info *ty, int flags)

Creates a new Perl pointer object. obj is a Perl SV that has been initialized to hold the result, ptr is the pointer to convert, ty is the SWIG type descriptor structure that describes the type, and flags is a flag that controls properties of the conversion. flags is currently undefined and reserved.

Both of these functions require the use of a special SWIG type-descriptor structure. This structure contains information about the mangled name of the datatype, type-equivalence information, as well as information about converting pointer values under C++ inheritance. For a type of Foo *, the type descriptor structure is usually accessed as follows:

Foo *f;
if (SWIG_ConvertPtr($input, (void **) &f, SWIGTYPE_p_Foo, 0) == -1) return NULL;

SV *sv = sv_newmortal();
SWIG_MakePtr(sv, f, SWIGTYPE_p_Foo, 0);

In a typemap, the type descriptor should always be accessed using the special typemap variable $1_descriptor. For example:

%typemap(in) Foo * {
   if ((SWIG_ConvertPtr($input,(void **) &$1, $1_descriptor,0)) == -1) return NULL;
}

If necessary, the descriptor for any type can be obtained using the $descriptor() macro in a typemap. For example:

%typemap(in) Foo * {
   if ((SWIG_ConvertPtr($input,(void **) &$1, $descriptor(Foo *), 0)) == -1) return NULL;
}

33.9 Proxy classes

Out of date. Needs update.

Using the low-level procedural interface, SWIG can also construct a high-level object oriented interface to C structures and C++ classes. This is done by constructing a Perl proxy class (also known as a shadow class) that provides an OO wrapper to the underlying code. This section describes the implementation details of the proxy interface.

33.9.1 Preliminaries

Proxy classes, are generated by default. If you want to turn them off, use the -noproxy command line option. For example:

$ swig -c++ -perl -noproxy example.i

When proxy classes are used, SWIG moves all of the low-level procedural wrappers to another package name. By default, this package is named 'modulec' where 'module' is the name of the module you provided with the %module directive. Then, in place of the original module, SWIG creates a collection of high-level Perl wrappers. In your scripts, you will use these high level wrappers. The wrappers, in turn, interact with the low-level procedural module.

33.9.2 Structure and class wrappers

Suppose you have the following SWIG interface file:

%module example
struct Vector {
	Vector(double x, double y, double z);
	~Vector();
	double x,y,z;
};

When wrapped, SWIG creates the following set of low-level accessor functions as described in previous sections.

Vector *new_Vector(double x, double y, double z);
void    delete_Vector(Vector *v);
double  Vector_x_get(Vector *v);
double  Vector_x_set(Vector *v, double value);
double  Vector_y_get(Vector *v);
double  Vector_y_set(Vector *v, double value);
double  Vector_z_get(Vector *v);
double  Vector_z_set(Vector *v, double value);

However, when proxy classes are enabled, these accessor functions are wrapped inside a Perl class like this:

package example::Vector;
@ISA = qw( example );
%OWNER = ();
%BLESSEDMEMBERS = ();

sub new () {
    my $self = shift;
    my @args = @_;
    $self = vectorc::new_Vector(@args);
    return undef if (!defined($self));
    bless $self, "example::Vector";
    $OWNER{$self} = 1;
    my %retval;
    tie %retval, "example::Vector", $self;
    return bless \%retval,"Vector";
}

sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
	 examplec::delete_Vector($self));
	 delete $OWNER{$self};
}

sub FETCH {
    my ($self,$field) = @_;
    my $member_func = "vectorc::Vector_${field}_get";
    my $val = &$member_func($self);
    if (exists $BLESSEDMEMBERS{$field}) {
        return undef if (!defined($val));
        my %retval;
        tie %retval,$BLESSEDMEMBERS{$field},$val;
        return bless \%retval, $BLESSEDMEMBERS{$field};
    }
    return $val;
}

sub STORE {
    my ($self,$field,$newval) = @_;
    my $member_func = "vectorc::Vector_${field}_set";
    if (exists $BLESSEDMEMBERS{$field}) {
        &$member_func($self,tied(%{$newval}));
    } else {
        &$member_func($self,$newval);
    }
}

Each structure or class is mapped into a Perl package of the same name. The C++ constructors and destructors are mapped into 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.

To use our new proxy class we can simply do the following:

# Perl code using Vector class
$v = new Vector(2,3,4);
$w = Vector->new(-1,-2,-3);

# Assignment of a single member
$v->{x} = 7.5;

# Assignment of all members
%$v = ( x=>3,
	 y=>9,
	 z=>-2);

# Reading members
$x = $v->{x};

# Destruction
$v->DESTROY();

33.9.3 Object Ownership

In order for proxy classes to work properly, it is necessary for Perl to manage some mechanism of object ownership. Here's the crux of the problem---suppose you had a function like this:

Vector *Vector_get(Vector *v, int index) {
	return &v[i];
}

This function takes a Vector pointer and returns a pointer to another Vector. Such a function might be used to manage arrays or lists of vectors (in C). Now contrast this function with the constructor for a Vector object:

Vector *new_Vector(double x, double y, double z) {
	Vector *v;
	v = new Vector(x,y,z);        // Call C++ constructor
	return v;
}

Both functions return a Vector, but the constructor is returning a brand-new Vector while the other function is returning a Vector that was already created (hopefully). In Perl, both vectors will be indistinguishable---clearly a problem considering that we would probably like the newly created Vector to be destroyed when we are done with it.

To manage these problems, each class contains two methods that access an internal hash table called %OWNER. This hash keeps a list of all of the objects that Perl knows that it has created. This happens in two cases: (1) when the constructor has been called, and (2) when a function implicitly creates a new object (as is done when SWIG needs to return a complex datatype by value). When the destructor is invoked, the Perl proxy class module checks the %OWNER hash to see if Perl created the object. If so, the C/C++ destructor is invoked. If not, we simply destroy the Perl object and leave the underlying C object alone (under the assumption that someone else must have created it).

This scheme works remarkably well in practice but it isn't foolproof. In fact, it will fail if you create a new C object in Perl, pass it on 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.

# Perl code to change ownership of an object
$v = new Vector(x,y,z);
$v->DISOWN();     

To acquire ownership of an object, the ACQUIRE method can be used.

# Given Perl ownership of a file
$u = Vector_get($v);
$u->ACQUIRE();

As always, a little care is in order. SWIG does not provide reference counting, garbage collection, or advanced features one might find in sophisticated languages.

33.9.4 Nested Objects

Suppose that we have a new object that looks like this:

struct Particle {
	Vector r;
	Vector v;
	Vector f;
	int	type;
}

In this case, the members of the structure are complex objects that have already been encapsulated in a Perl proxy class. To handle these correctly, we use the %BLESSEDMEMBERS hash which would look like this (along with some supporting code):

package Particle;
...
%BLESSEDMEMBERS = (
	r => `Vector',
	v => `Vector',
	f => `Vector',
);

When fetching members from the structure, %BLESSEDMEMBERS is checked. If the requested field is present, we create a tied-hash table and return it. If not, we just return the corresponding member unmodified.

This implementation allows us to operate on nested structures as follows:

# Perl access of nested structure
$p = new Particle();
$p->{f}->{x} = 0.0;
%${$p->{v}} = ( x=>0, y=>0, z=>0);         

33.9.5 Proxy Functions

When functions take arguments involving a complex object, it is sometimes necessary to write a proxy function. For example:

double dot_product(Vector *v1, Vector *v2);

Since Vector is an object already wrapped into a proxy class, we need to modify this function to accept arguments that are given in the form of tied hash tables. This is done by creating a Perl function like this:

sub dot_product {
    my @args = @_;
    $args[0] = tied(%{$args[0]});         # Get the real pointer values
    $args[1] = tied(%{$args[1]});
    my $result = vectorc::dot_product(@args);
    return $result;
}

This function replaces the original function, but operates in an identical manner.

33.9.6 Inheritance

Simple C++ inheritance is handled using the Perl @ISA array in each class package. For example, if you have the following interface file:

// shapes.i
// SWIG interface file for shapes class
%module shapes
%{
#include "shapes.h"
%}

class Shape {
public:
	virtual double area() = 0;
	virtual double perimeter() = 0;
	void    set_location(double x, double y);
};
class Circle : public Shape {
public:
	Circle(double radius);
	~Circle();
	double area();
	double perimeter();
};
class Square : public Shape {
public:
	Square(double size);
	~Square();
	double area();
	double perimeter();
}

The resulting, Perl wrapper class will create the following code:

Package Shape;
@ISA = (shapes);
...
Package Circle;
@ISA = (shapes Shape);
...
Package Square;
@ISA = (shapes Shape);

The @ISA array determines where to look for methods of a particular class. In this case, both the Circle and Square classes inherit functions from Shape so we'll want to look in the Shape base class for them. All classes also inherit from the top-level module shapes. This is because certain common operations needed to implement proxy classes are implemented only once and reused in the wrapper code for various classes and structures.

Since SWIG proxy classes are implemented in Perl, it is easy to subclass from any SWIG generated class. To do this, simply put the name of a SWIG class in the @ISA array for your new class. However, be forewarned that this is not a trivial problem. In particular, inheritance of data members is extremely tricky (and I'm not even sure if it really works).

33.9.7 Modifying the proxy methods

It is possible to override the SWIG generated proxy/shadow methods, using %feature("shadow"). It works like all the other %feature directives. Here is a simple example showing how to add some Perl debug code to the constructor:

/* Let's make the constructor of the class Square more verbose */
%feature("shadow") Square(double w)
%{
  sub new {
    my $pkg = shift;
    my $self = examplec::new_Square(@_);
    print STDERR "Constructed an @{[ref($self)]}\n";
    bless $self, $pkg if defined($self);
  }
%}

class Square {
public:
  Square(double w);
  ...
};

33.10 Adding additional Perl code

If writing support code in C isn't enough, it is also possible to write code in Perl. This code gets inserted in to the .pm file created by SWIG. One use of Perl code might be to supply a high-level interface to certain functions. For example:

void set_transform(Image *im, double x[4][4]);

...
/* Rewrite the high level interface to set_transform */
%perlcode %{
sub set_transform
{
  my ($im, $x) = @_;
  my $a = new_mat44();
  for (my $i = 0; $i < 4, $i++)
  {
    for (my $j = 0; $j < 4, $j++)
    {
      mat44_set($a, $i, $j, $x->[i][j])
      }
  }
  example.set_transform($im, $a);
  free_mat44($a);
}
%}

In this example, set_transform() provides a high-level Perl interface built on top of low-level helper functions. For example, this code now seems to work:

my $a =
  [[1,0,0,0],
   [0,1,0,0],
   [0,0,1,0],
   [0,0,0,1]];
set_transform($im, $a);

33.11 Cross language polymorphism

Proxy classes provide a more natural, object-oriented way to access extension classes. As described above, each proxy instance has an associated C++ instance, and method calls to the proxy are passed to the C++ instance transparently via C wrapper functions.

This arrangement is asymmetric in the sense that no corresponding mechanism exists to pass method calls down the inheritance chain from C++ to Perl. In particular, if a C++ class has been extended in Perl (by extending the proxy class), these extensions will not be visible from C++ code. Virtual method calls from C++ are thus not able access the lowest implementation in the inheritance chain.

Changes have been made to SWIG to address this problem and make the relationship between C++ classes and proxy classes more symmetric. To achieve this goal, new classes called directors are introduced at the bottom of the C++ inheritance chain. The job of the directors is to route method calls correctly, either to C++ implementations higher in the inheritance chain or to Perl implementations lower in the inheritance chain. The upshot is that C++ classes can be extended in Perl and from C++ these extensions look exactly like native C++ classes. Neither C++ code nor Perl code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

33.11.1 Enabling directors

The director feature is disabled by default. To use directors you must make two changes to the interface file. First, add the "directors" option to the %module directive, like this:

%module(directors="1") modulename

Without this option no director code will be generated. Second, you must use the %feature("director") directive to tell SWIG which classes and methods should get directors. The %feature directive can be applied globally, to specific classes, and to specific methods, like this:

// generate directors for all classes that have virtual methods
%feature("director");         

// generate directors for all virtual methods in class Foo
%feature("director") Foo;      

You can use the %feature("nodirector") directive to turn off directors for specific classes or methods. So for example,

%feature("director") Foo;
%feature("nodirector") Foo::bar;

will generate directors for all virtual methods of class Foo except bar().

Directors can also be generated implicitly through inheritance. In the following, class Bar will get a director class that handles the methods one() and two() (but not three()):

%feature("director") Foo;
class Foo {
public:
    Foo(int foo);
    virtual void one();
    virtual void two();
};

class Bar: public Foo {
public:
    virtual void three();
};

then at the Perl side you can define

use mymodule;

package MyFoo;
use base 'mymodule::Foo';

sub one {
  print "one from Perl\n";
}

33.11.2 Director classes

For each class that has directors enabled, SWIG generates a new class that derives from both the class in question and a special Swig::Director class. These new classes, referred to as director classes, can be loosely thought of as the C++ equivalent of the Perl proxy classes. The director classes store a pointer to their underlying Perl object and handle various issues related to object ownership.

For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). Thus all virtual method calls, whether they originate in C++ or in Perl via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate place" we mean the method that would have been called if the C++ base class and its extensions in Perl were seamlessly integrated. That seamless integration is exactly what the director classes provide, transparently skipping over all the messy extension API glue that binds the two languages together.

In reality, the "appropriate place" is one of only two possibilities: C++ or Perl. Once this decision is made, the rest is fairly easy. If the correct implementation is in C++, then the lowest implementation of the method in the C++ inheritance chain is called explicitly. If the correct implementation is in Perl, the Perl API is used to call the method of the underlying Perl object (after which the usual virtual method resolution in Perl automatically finds the right implementation).

Now how does the director decide which language should handle the method call? The basic rule is to handle the method in Perl, unless there's a good reason not to. The reason for this is simple: Perl has the most "extended" implementation of the method. This assertion is guaranteed, since at a minimum the Perl proxy class implements the method. If the method in question has been extended by a class derived from the proxy class, that extended implementation will execute exactly as it should. If not, the proxy class will route the method call into a C wrapper function, expecting that the method will be resolved in C++. The wrapper will call the virtual method of the C++ instance, and since the director extends this the call will end up right back in the director method. Now comes the "good reason not to" part. If the director method were to blindly call the Perl method again, it would get stuck in an infinite loop. We avoid this situation by adding special code to the C wrapper function that tells the director method to not do this. The C wrapper function compares the pointer to the Perl object that called the wrapper function to the pointer stored by the director. If these are the same, then the C wrapper function tells the director to resolve the method by calling up the C++ inheritance chain, preventing an infinite loop.

One more point needs to be made about the relationship between director classes and proxy classes. When a proxy class instance is created in Perl, SWIG creates an instance of the original C++ class. This is exactly what happens without directors and is true even if directors are enabled for the particular class in question. When a class derived from a proxy class is created, however, SWIG then creates an instance of the corresponding C++ director class. The reason for this difference is that user-defined subclasses may override or extend methods of the original class, so the director class is needed to route calls to these methods correctly. For unmodified proxy classes, all methods are ultimately implemented in C++ so there is no need for the extra overhead involved with routing the calls through Perl.

33.11.3 Ownership and object destruction

Memory management issues are slightly more complicated with directors than for proxy classes alone. Perl instances hold a pointer to the associated C++ director object, and the director in turn holds a pointer back to a Perl object. By default, proxy classes own their C++ director object and take care of deleting it when they are garbage collected.

This relationship can be reversed by calling the special DISOWN() method of the proxy class. After calling this method the director class increments the reference count of the Perl object. When the director class is deleted it decrements the reference count. Assuming no outstanding references to the Perl object remain, the Perl object will be destroyed at the same time. This is a good thing, since directors and proxies refer to each other and so must be created and destroyed together. Destroying one without destroying the other will likely cause your program to segfault.

Also note that due to the proxy implementation, the DESTROY() method on directors can be called for several reasons, many of which have little to do with the teardown of an object instance. To help disambiguate this, a second argument is added to the DESTROY() call when a C++ director object is being released. So, to avoid running your clean-up code when an object is not really going away, or after it has already been reclaimed, it is suggested that custom destructors in Perl subclasses looks something like:

sub DESTROY {
  my($self, $final) = @_;
  if($final) {
    # real teardown code
  }
  shift->SUPER::DESTROY(@_);
}

33.11.4 Exception unrolling

With directors routing method calls to Perl, and proxies routing them to C++, the handling of exceptions is an important concern. By default, the directors ignore exceptions that occur during method calls that are resolved in Perl. To handle such exceptions correctly, it is necessary to temporarily translate them into C++ exceptions. This can be done with the %feature("director:except") directive. The following code should suffice in most cases:

%feature("director:except") {
    if ($error != NULL) {
        throw Swig::DirectorMethodException();
    }
}

This code will check the Perl error state after each method call from a director into Perl, and throw a C++ exception if an error occurred. This exception can be caught in C++ to implement an error handler.

It may be the case that a method call originates in Perl, travels up to C++ through a proxy class, and then back into Perl via a director method. If an exception occurs in Perl at this point, it would be nice for that exception to find its way back to the original caller. This can be done by combining a normal %exception directive with the director:except handler shown above. Here is an example of a suitable exception handler:

%exception {
    try { $action }
    catch (Swig::DirectorException &e) { SWIG_fail; }
}

The class Swig::DirectorException used in this example is actually a base class of Swig::DirectorMethodException, so it will trap this exception. Because the Perl error state is still set when Swig::DirectorMethodException is thrown, Perl will register the exception as soon as the C wrapper function returns.

33.11.5 Overhead and code bloat

Enabling directors for a class will generate a new director method for every virtual method in the class' inheritance chain. This alone can generate a lot of code bloat for large hierarchies. Method arguments that require complex conversions to and from target language types can result in large director methods. For this reason it is recommended that you selectively enable directors only for specific classes that are likely to be extended in Perl and used in C++.

Compared to classes that do not use directors, the call routing in the director methods does add some overhead. In particular, at least one dynamic cast and one extra function call occurs per method call from Perl. Relative to the speed of Perl execution this is probably completely negligible. For worst case routing, a method call that ultimately resolves in C++ may take one extra detour through Perl in order to ensure that the method does not have an extended Perl implementation. This could result in a noticeable overhead in some cases.

Although directors make it natural to mix native C++ objects with Perl objects (as director objects) via a common base class pointer, one should be aware of the obvious fact that method calls to Perl objects will be much slower than calls to C++ objects. This situation can be optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in Perl.

33.11.6 Typemaps

Typemaps for input and output of most of the basic types from director classes have been written. These are roughly the reverse of the usual input and output typemaps used by the wrapper code. The typemap operation names are 'directorin', 'directorout', and 'directorargout'. The director code does not currently use any of the other kinds of typemaps. It is not clear at this point which kinds are appropriate and need to be supported.

swig-3.0.2/Doc/Manual/Extending.html0000664000175000017500000034707112343706602017121 0ustar williamwilliam Extending SWIG to support new languages

40 Extending SWIG to support new languages

40.1 Introduction

This chapter describes SWIG's internal organization and the process by which new target languages can be developed. First, a brief word of warning---SWIG is continually evolving. The information in this chapter is mostly up to date, but changes are ongoing. Expect a few inconsistencies.

Also, this chapter is not meant to be a hand-holding tutorial. As a starting point, you should probably look at one of SWIG's existing modules.

40.2 Prerequisites

In order to extend SWIG, it is useful to have the following background:

  • An understanding of the C API for the target language.
  • A good grasp of the C++ type system.
  • An understanding of typemaps and some of SWIG's advanced features.
  • Some familiarity with writing C++ (language modules are currently written in C++).

Since SWIG is essentially a specialized C++ compiler, it may be useful to have some prior experience with compiler design (perhaps even a compilers course) to better understand certain parts of the system. A number of books will also be useful. For example, "The C Programming Language" by Kernighan and Ritchie (a.k.a, "K&R") and the C++ standard, "ISO/IEC 14882 Programming Languages - C++" will be of great use.

Also, it is useful to keep in mind that SWIG primarily operates as an extension of the C++ type system. At first glance, this might not be obvious, but almost all SWIG directives as well as the low-level generation of wrapper code are driven by C++ datatypes.

40.3 The Big Picture

SWIG is a special purpose compiler that parses C++ declarations to generate wrapper code. To make this conversion possible, SWIG makes three fundamental extensions to the C++ language:

  • Typemaps. Typemaps are used to define the conversion/marshalling behavior of specific C++ datatypes. All type conversion in SWIG is based on typemaps. Furthermore, the association of typemaps to datatypes utilizes an advanced pattern matching mechanism that is fully integrated with the C++ type system.
  • Declaration Annotation. To customize wrapper code generation, most declarations can be annotated with special features. For example, you can make a variable read-only, you can ignore a declaration, you can rename a member function, you can add exception handling, and so forth. Virtually all of these customizations are built on top of a low-level declaration annotator that can attach arbitrary attributes to any declaration. Code generation modules can look for these attributes to guide the wrapping process.
  • Class extension. SWIG allows classes and structures to be extended with new methods and attributes (the %extend directive). This has the effect of altering the API in the target language and can be used to generate OO interfaces to C libraries.

It is important to emphasize that virtually all SWIG features reduce to one of these three fundamental concepts. The type system and pattern matching rules also play a critical role in making the system work. For example, both typemaps and declaration annotation are based on pattern matching and interact heavily with the underlying type system.

40.4 Execution Model

When you run SWIG on an interface, processing is handled in stages by a series of system components:

  • An integrated C preprocessor reads a collection of configuration files and the specified interface file into memory. The preprocessor performs the usual functions including macro expansion and file inclusion. However, the preprocessor also performs some transformations of the interface. For instance, #define statements are sometimes transformed into %constant declarations. In addition, information related to file/line number tracking is inserted.
  • A C/C++ parser reads the preprocessed input and generates a full parse tree of all of the SWIG directives and C declarations found. The parser is responsible for many aspects of the system including renaming, declaration annotation, and template expansion. However, the parser does not produce any output nor does it interact with the target language module as it runs. SWIG is not a one-pass compiler.
  • A type-checking pass is made. This adjusts all of the C++ typenames to properly handle namespaces, typedefs, nested classes, and other issues related to type scoping.
  • A semantic pass is made on the parse tree to collect information related to properties of the C++ interface. For example, this pass would determine whether or not a class allows a default constructor.
  • A code generation pass is made using a specific target language module. This phase is responsible for generating the actual wrapper code. All of SWIG's user-defined modules are invoked during this latter stage of compilation.

The next few sections briefly describe some of these stages.

40.4.1 Preprocessing

The preprocessor plays a critical role in the SWIG implementation. This is because a lot of SWIG's processing and internal configuration is managed not by code written in C, but by configuration files in the SWIG library. In fact, when you run SWIG, parsing starts with a small interface file like this (note: this explains the cryptic error messages that new users sometimes get when SWIG is misconfigured or installed incorrectly):

%include "swig.swg"             // Global SWIG configuration
%include "langconfig.swg"       // Language specific configuration
%include "yourinterface.i"      // Your interface file

The swig.swg file contains global configuration information. In addition, this file defines many of SWIG's standard directives as macros. For instance, part of of swig.swg looks like this:

...
/* Code insertion directives such as %wrapper %{ ... %} */

#define %begin       %insert("begin")
#define %runtime     %insert("runtime")
#define %header      %insert("header")
#define %wrapper     %insert("wrapper")
#define %init        %insert("init")

/* Access control directives */

#define %immutable   %feature("immutable","1")
#define %mutable     %feature("immutable")

/* Directives for callback functions */

#define %callback(x) %feature("callback") `x`;
#define %nocallback  %feature("callback");

/* %ignore directive */

#define %ignore         %rename($ignore)
#define %ignorewarn(x)  %rename("$ignore:" x)
...

The fact that most of the standard SWIG directives are macros is intended to simplify the implementation of the internals. For instance, rather than having to support dozens of special directives, it is easier to have a few basic primitives such as %feature or %insert.

The langconfig.swg file is supplied by the target language. This file contains language-specific configuration information. More often than not, this file provides run-time wrapper support code (e.g., the type-checker) as well as a collection of typemaps that define the default wrapping behavior. Note: the name of this file depends on the target language and is usually something like python.swg or perl5.swg.

As a debugging aide, the text that SWIG feeds to its C++ parser can be obtained by running swig -E interface.i. This output probably isn't too useful in general, but it will show how macros have been expanded as well as everything else that goes into the low-level construction of the wrapper code.

40.4.2 Parsing

The current C++ parser handles a subset of C++. Most incompatibilities with C are due to subtle aspects of how SWIG parses declarations. Specifically, SWIG expects all C/C++ declarations to follow this general form:

storage type declarator initializer;

storage is a keyword such as extern, static, typedef, or virtual. type is a primitive datatype such as int or void. type may be optionally qualified with a qualifier such as const or volatile. declarator is a name with additional type-construction modifiers attached to it (pointers, arrays, references, functions, etc.). Examples of declarators include *x, **x, x[20], and (*x)(int,double). The initializer may be a value assigned using = or body of code enclosed in braces { ... }.

This declaration format covers most common C++ declarations. However, the C++ standard is somewhat more flexible in the placement of the parts. For example, it is technically legal, although uncommon to write something like int typedef const a in your program. SWIG simply doesn't bother to deal with this case.

The other significant difference between C++ and SWIG is in the treatment of typenames. In C++, if you have a declaration like this,

int blah(Foo *x, Bar *y);

it won't parse correctly unless Foo and Bar have been previously defined as types either using a class definition or a typedef. The reasons for this are subtle, but this treatment of typenames is normally integrated at the level of the C tokenizer---when a typename appears, a different token is returned to the parser instead of an identifier.

SWIG does not operate in this manner--any legal identifier can be used as a type name. The reason for this is primarily motivated by the use of SWIG with partially defined data. Specifically, SWIG is supposed to be easy to use on interfaces with missing type information.

Because of the different treatment of typenames, the most serious limitation of the SWIG parser is that it can't process type declarations where an extra (and unnecessary) grouping operator is used. For example:

int (x);         /* A variable x */
int (y)(int);    /* A function y */

The placing of extra parentheses in type declarations like this is already recognized by the C++ community as a potential source of strange programming errors. For example, Scott Meyers "Effective STL" discusses this problem in a section on avoiding C++'s "most vexing parse."

The parser is also unable to handle declarations with no return type or bare argument names. For example, in an old C program, you might see things like this:

foo(a,b) {
...
}

In this case, the return type as well as the types of the arguments are taken by the C compiler to be an int. However, SWIG interprets the above code as an abstract declarator for a function returning a foo and taking types a and b as arguments).

40.4.3 Parse Trees

The SWIG parser produces a complete parse tree of the input file before any wrapper code is actually generated. Each item in the tree is known as a "Node". Each node is identified by a symbolic tag. Furthermore, a node may have an arbitrary number of children. The parse tree structure and tag names of an interface can be displayed using swig -debug-tags. For example:

$ swig -c++ -python -debug-tags example.i
 . top (example.i:1)
 . top . include (example.i:1)
 . top . include . typemap (/r0/beazley/Projects/lib/swig1.3/swig.swg:71)
 . top . include . typemap . typemapitem (/r0/beazley/Projects/lib/swig1.3/swig.swg:71)
 . top . include . typemap (/r0/beazley/Projects/lib/swig1.3/swig.swg:83)
 . top . include . typemap . typemapitem (/r0/beazley/Projects/lib/swig1.3/swig.swg:83)
 . top . include (example.i:4)
 . top . include . insert (/r0/beazley/Projects/lib/swig1.3/python/python.swg:7)
 . top . include . insert (/r0/beazley/Projects/lib/swig1.3/python/python.swg:8)
 . top . include . typemap (/r0/beazley/Projects/lib/swig1.3/python/python.swg:19)
...
 . top . include (example.i:6)
 . top . include . module (example.i:2)
 . top . include . insert (example.i:6)
 . top . include . include (example.i:9)
 . top . include . include . class (example.h:3)
 . top . include . include . class . access (example.h:4)
 . top . include . include . class . constructor (example.h:7)
 . top . include . include . class . destructor (example.h:10)
 . top . include . include . class . cdecl (example.h:11)
 . top . include . include . class . cdecl (example.h:11)
 . top . include . include . class . cdecl (example.h:12)
 . top . include . include . class . cdecl (example.h:13)
 . top . include . include . class . cdecl (example.h:14)
 . top . include . include . class . cdecl (example.h:15)
 . top . include . include . class (example.h:18)
 . top . include . include . class . access (example.h:19)
 . top . include . include . class . cdecl (example.h:20)
 . top . include . include . class . access (example.h:21)
 . top . include . include . class . constructor (example.h:22)
 . top . include . include . class . cdecl (example.h:23)
 . top . include . include . class . cdecl (example.h:24)
 . top . include . include . class (example.h:27)
 . top . include . include . class . access (example.h:28)
 . top . include . include . class . cdecl (example.h:29)
 . top . include . include . class . access (example.h:30)
 . top . include . include . class . constructor (example.h:31)
 . top . include . include . class . cdecl (example.h:32)
 . top . include . include . class . cdecl (example.h:33)

Even for the most simple interface, the parse tree structure is larger than you might expect. For example, in the above output, a substantial number of nodes are actually generated by the python.swg configuration file which defines typemaps and other directives. The contents of the user-supplied input file don't appear until the end of the output.

The contents of each parse tree node consist of a collection of attribute/value pairs. Internally, the nodes are simply represented by hash tables. A display of the entire parse-tree structure can be obtained using swig -debug-top <n>, where n is the stage being processed. There are a number of other parse tree display options, for example, swig -debug-module <n> will avoid displaying system parse information and only display the parse tree pertaining to the user's module at stage n of processing.

$ swig -c++ -python -debug-module 4 example.i
      +++ include ----------------------------------------
      | name         - "example.i"

            +++ module ----------------------------------------
            | name         - "example"
            |
            +++ insert ----------------------------------------
            | code         - "\n#include \"example.h\"\n"
            |
            +++ include ----------------------------------------
            | name         - "example.h"

                  +++ class ----------------------------------------
                  | abstract     - "1"
                  | sym:name     - "Shape"
                  | name         - "Shape"
                  | kind         - "class"
                  | symtab       - 0x40194140
                  | sym:symtab   - 0x40191078

                        +++ access ----------------------------------------
                        | kind         - "public"
                        |
                        +++ constructor ----------------------------------------
                        | sym:name     - "Shape"
                        | name         - "Shape"
                        | decl         - "f()."
                        | code         - "{\n    nshapes++;\n  }"
                        | sym:symtab   - 0x40194140
                        |
                        +++ destructor ----------------------------------------
                        | sym:name     - "~Shape"
                        | name         - "~Shape"
                        | storage      - "virtual"
                        | code         - "{\n    nshapes--;\n  }"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "x"
                        | name         - "x"
                        | decl         - ""
                        | type         - "double"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "y"
                        | name         - "y"
                        | decl         - ""
                        | type         - "double"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "move"
                        | name         - "move"
                        | decl         - "f(double,double)."
                        | parms        - double ,double
                        | type         - "void"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "area"
                        | name         - "area"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | value        - "0"
                        | type         - "double"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "perimeter"
                        | name         - "perimeter"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | value        - "0"
                        | type         - "double"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "nshapes"
                        | name         - "nshapes"
                        | decl         - ""
                        | storage      - "static"
                        | type         - "int"
                        | sym:symtab   - 0x40194140
                        |
                  +++ class ----------------------------------------
                  | sym:name     - "Circle"
                  | name         - "Circle"
                  | kind         - "class"
                  | bases        - 0x40194510
                  | symtab       - 0x40194538
                  | sym:symtab   - 0x40191078

                        +++ access ----------------------------------------
                        | kind         - "private"
                        |
                        +++ cdecl ----------------------------------------
                        | name         - "radius"
                        | decl         - ""
                        | type         - "double"
                        |
                        +++ access ----------------------------------------
                        | kind         - "public"
                        |
                        +++ constructor ----------------------------------------
                        | sym:name     - "Circle"
                        | name         - "Circle"
                        | parms        - double
                        | decl         - "f(double)."
                        | code         - "{ }"
                        | sym:symtab   - 0x40194538
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "area"
                        | name         - "area"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | type         - "double"
                        | sym:symtab   - 0x40194538
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "perimeter"
                        | name         - "perimeter"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | type         - "double"
                        | sym:symtab   - 0x40194538
                        |
                  +++ class ----------------------------------------
                  | sym:name     - "Square"
                  | name         - "Square"
                  | kind         - "class"
                  | bases        - 0x40194760
                  | symtab       - 0x40194788
                  | sym:symtab   - 0x40191078

                        +++ access ----------------------------------------
                        | kind         - "private"
                        |
                        +++ cdecl ----------------------------------------
                        | name         - "width"
                        | decl         - ""
                        | type         - "double"
                        |
                        +++ access ----------------------------------------
                        | kind         - "public"
                        |
                        +++ constructor ----------------------------------------
                        | sym:name     - "Square"
                        | name         - "Square"
                        | parms        - double
                        | decl         - "f(double)."
                        | code         - "{ }"
                        | sym:symtab   - 0x40194788
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "area"
                        | name         - "area"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | type         - "double"
                        | sym:symtab   - 0x40194788
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "perimeter"
                        | name         - "perimeter"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | type         - "double"
                        | sym:symtab   - 0x40194788

40.4.4 Attribute namespaces

Attributes of parse tree nodes are often prepended with a namespace qualifier. For example, the attributes sym:name and sym:symtab are attributes related to symbol table management and are prefixed with sym:. As a general rule, only those attributes which are directly related to the raw declaration appear without a prefix (type, name, declarator, etc.).

Target language modules may add additional attributes to nodes to assist the generation of wrapper code. The convention for doing this is to place these attributes in a namespace that matches the name of the target language. For example, python:foo or perl:foo.

40.4.5 Symbol Tables

During parsing, all symbols are managed in the space of the target language. The sym:name attribute of each node contains the symbol name selected by the parser. Normally, sym:name and name are the same. However, the %rename directive can be used to change the value of sym:name. You can see the effect of %rename by trying it on a simple interface and dumping the parse tree. For example:

%rename(foo_i) foo(int);
%rename(foo_d) foo(double);

void foo(int);
void foo(double);
void foo(Bar *b);

There are various debug- options that can be useful for debugging and analysing the parse tree. For example, the debug-top <n> or debug-module <n> options will dump the entire/top of the parse tree or the module subtree at one of the four n stages of processing. The parse tree can be viewed after the final stage of processing by running SWIG:

$ swig -debug-top 4 example.i
...
            +++ cdecl ----------------------------------------
            | sym:name     - "foo_i"
            | name         - "foo"
            | decl         - "f(int)."
            | parms        - int
            | type         - "void"
            | sym:symtab   - 0x40165078
            |
            +++ cdecl ----------------------------------------
            | sym:name     - "foo_d"
            | name         - "foo"
            | decl         - "f(double)."
            | parms        - double
            | type         - "void"
            | sym:symtab   - 0x40165078
            |
            +++ cdecl ----------------------------------------
            | sym:name     - "foo"
            | name         - "foo"
            | decl         - "f(p.Bar)."
            | parms        - Bar *
            | type         - "void"
            | sym:symtab   - 0x40165078

All symbol-related conflicts and complaints about overloading are based on sym:name values. For instance, the following example uses %rename in reverse to generate a name clash.

%rename(foo) foo_i(int);
%rename(foo) foo_d(double;

void foo_i(int);
void foo_d(double);
void foo(Bar *b);

When you run SWIG on this you now get:

$ ./swig example.i
example.i:6. Overloaded declaration ignored.  foo_d(double )
example.i:5. Previous declaration is foo_i(int )
example.i:7. Overloaded declaration ignored.  foo(Bar *)
example.i:5. Previous declaration is foo_i(int )

40.4.6 The %feature directive

A number of SWIG directives such as %exception are implemented using the low-level %feature directive. For example:

%feature("except") getitem(int) {
  try {
     $action
  } catch (badindex) {
     ...
  }
}

...
class Foo {
public:
    Object *getitem(int index) throws(badindex);
    ...
};

The behavior of %feature is very easy to describe--it simply attaches a new attribute to any parse tree node that matches the given prototype. When a feature is added, it shows up as an attribute in the feature: namespace. You can see this when running with the -debug-top 4 option. For example:

 +++ cdecl ----------------------------------------
 | sym:name     - "getitem"
 | name         - "getitem"
 | decl         - "f(int).p."
 | parms        - int
 | type         - "Object"
 | feature:except - "{\n    try {\n       $action\n    } catc..."
 | sym:symtab   - 0x40168ac8
 |

Feature names are completely arbitrary and a target language module can be programmed to respond to any feature name that it wants to recognize. The data stored in a feature attribute is usually just a raw unparsed string. For example, the exception code above is simply stored without any modifications.

40.4.7 Code Generation

Language modules work by defining handler functions that know how to respond to different types of parse-tree nodes. These handlers simply look at the attributes of each node in order to produce low-level code.

In reality, the generation of code is somewhat more subtle than simply invoking handler functions. This is because parse-tree nodes might be transformed. For example, suppose you are wrapping a class like this:

class Foo {
public:
    virtual int *bar(int x);
};

When the parser constructs a node for the member bar, it creates a raw "cdecl" node with the following attributes:

nodeType    : cdecl
name        : bar
type        : int
decl        : f(int).p
parms       : int x
storage     : virtual
sym:name    : bar

To produce wrapper code, this "cdecl" node undergoes a number of transformations. First, the node is recognized as a function declaration. This adjusts some of the type information--specifically, the declarator is joined with the base datatype to produce this:

nodeType    : cdecl
name        : bar
type        : p.int        <-- Notice change in return type
decl        : f(int).p
parms       : int x
storage     : virtual
sym:name    : bar

Next, the context of the node indicates that the node is really a member function. This produces a transformation to a low-level accessor function like this:

nodeType    : cdecl
name        : bar
type        : int.p
decl        : f(int).p
parms       : Foo *self, int x            <-- Added parameter
storage     : virtual
wrap:action : result = (arg1)->bar(arg2)  <-- Action code added
sym:name    : Foo_bar                     <-- Symbol name changed

In this transformation, notice how an additional parameter was added to the parameter list and how the symbol name of the node has suddenly changed into an accessor using the naming scheme described in the "SWIG Basics" chapter. A small fragment of "action" code has also been generated--notice how the wrap:action attribute defines the access to the underlying method. The data in this transformed node is then used to generate a wrapper.

Language modules work by registering handler functions for dealing with various types of nodes at different stages of transformation. This is done by inheriting from a special Language class and defining a collection of virtual methods. For example, the Python module defines a class as follows:

class PYTHON : public Language {
protected:
public :
  virtual void main(int, char *argv[]);
  virtual int  top(Node *);
  virtual int  functionWrapper(Node *);
  virtual int  constantWrapper(Node *);
  virtual int  variableWrapper(Node *);
  virtual int  nativeWrapper(Node *);
  virtual int  membervariableHandler(Node *);
  virtual int  memberconstantHandler(Node *);
  virtual int  memberfunctionHandler(Node *);
  virtual int  constructorHandler(Node *);
  virtual int  destructorHandler(Node *);
  virtual int  classHandler(Node *);
  virtual int  classforwardDeclaration(Node *);
  virtual int  insertDirective(Node *);
  virtual int  importDirective(Node *);
};

The role of these functions is described shortly.

40.4.8 SWIG and XML

Much of SWIG's current parser design was originally motivated by interest in using XML to represent SWIG parse trees. Although XML is not currently used in any direct manner, the parse tree structure, use of node tags, attributes, and attribute namespaces are all influenced by aspects of XML parsing. Therefore, in trying to understand SWIG's internal data structures, it may be useful to keep XML in the back of your mind as a model.

40.5 Primitive Data Structures

Most of SWIG is constructed using three basic data structures: strings, hashes, and lists. These data structures are dynamic in same way as similar structures found in many scripting languages. For instance, you can have containers (lists and hash tables) of mixed types and certain operations are polymorphic.

This section briefly describes the basic structures so that later sections of this chapter make more sense.

When describing the low-level API, the following type name conventions are used:

  • String. A string object.
  • Hash. A hash object.
  • List. A list object.
  • String_or_char. A string object or a char *.
  • Object_or_char. An object or a char *.
  • Object. Any object (string, hash, list, etc.)

In most cases, other typenames in the source are aliases for one of these primitive types. Specifically:

typedef String SwigType;
typedef Hash   Parm;
typedef Hash   ParmList;
typedef Hash   Node;
typedef Hash   Symtab;
typedef Hash   Typetab;

40.5.1 Strings

String *NewString(const String_or_char *val)

Creates a new string with initial value val. val may be a char * or another String object. If you want to create an empty string, use "" for val.

String *NewStringf(const char *fmt, ...)

Creates a new string whose initial value is set according to a C printf style format string in fmt. Additional arguments follow depending on fmt.

String *Copy(String *s)

Make a copy of the string s.

void Delete(String *s)

Deletes s.

int Len(const String_or_char *s)

Returns the length of the string.

char *Char(const String_or_char *s)

Returns a pointer to the first character in a string.

void Append(String *s, const String_or_char *t)

Appends t to the end of string s.

void Insert(String *s, int pos, const String_or_char *t)

Inserts t into s at position pos. The contents of s are shifted accordingly. The special value DOH_END can be used for pos to indicate insertion at the end of the string (appending).

int Strcmp(const String_or_char *s, const String_or_char *t)

Compare strings s and t. Same as the C strcmp() function.

int Strncmp(const String_or_char *s, const String_or_char *t, int len)

Compare the first len characters of strings s and t. Same as the C strncmp() function.

char *Strstr(const String_or_char *s, const String_or_char *pat)

Returns a pointer to the first occurrence of pat in s. Same as the C strstr() function.

char *Strchr(const String_or_char *s, char ch)

Returns a pointer to the first occurrence of character ch in s. Same as the C strchr() function.

void Chop(String *s)

Chops trailing whitespace off the end of s.

int Replace(String *s, const String_or_char *pat, const String_or_char *rep, int flags)

Replaces the pattern pat with rep in string s. flags is a combination of the following flags:

DOH_REPLACE_ANY       - Replace all occurrences
DOH_REPLACE_ID        - Valid C identifiers only
DOH_REPLACE_NOQUOTE   - Don't replace in quoted strings
DOH_REPLACE_FIRST     - Replace first occurrence only.

Returns the number of replacements made (if any).

40.5.2 Hashes

Hash *NewHash()

Creates a new empty hash table.

Hash *Copy(Hash *h)

Make a shallow copy of the hash h.

void Delete(Hash *h)

Deletes h.

int Len(Hash *h)

Returns the number of items in h.

Object *Getattr(Hash *h, const String_or_char *key)

Gets an object from h. key may be a string or a simple char * string. Returns NULL if not found.

int Setattr(Hash *h, const String_or_char *key, const Object_or_char *val)

Stores val in h. key may be a string or a simple char *. If val is not a standard object (String, Hash, or List) it is assumed to be a char * in which case it is used to construct a String that is stored in the hash. If val is NULL, the object is deleted. Increases the reference count of val. Returns 1 if this operation replaced an existing hash entry, 0 otherwise.

int Delattr(Hash *h, const String_or_char *key)

Deletes the hash item referenced by key. Decreases the reference count on the corresponding object (if any). Returns 1 if an object was removed, 0 otherwise.

List *Keys(Hash *h)

Returns the list of hash table keys.

40.5.3 Lists

List *NewList()

Creates a new empty list.

List *Copy(List *x)

Make a shallow copy of the List x.

void Delete(List *x)

Deletes x.

int Len(List *x)

Returns the number of items in x.

Object *Getitem(List *x, int n)

Returns an object from x with index n. If n is beyond the end of the list, the last item is returned. If n is negative, the first item is returned.

int *Setitem(List *x, int n, const Object_or_char *val)

Stores val in x. If val is not a standard object (String, Hash, or List) it is assumed to be a char * in which case it is used to construct a String that is stored in the list. n must be in range. Otherwise, an assertion will be raised.

int *Delitem(List *x, int n)

Deletes item n from the list, shifting items down if necessary. To delete the last item in the list, use the special value DOH_END for n.

void Append(List *x, const Object_or_char *t)

Appends t to the end of x. If t is not a standard object, it is assumed to be a char * and is used to create a String object.

void Insert(String *s, int pos, const Object_or_char *t)

Inserts t into s at position pos. The contents of s are shifted accordingly. The special value DOH_END can be used for pos to indicate insertion at the end of the list (appending). If t is not a standard object, it is assumed to be a char * and is used to create a String object.

40.5.4 Common operations

The following operations are applicable to all datatypes.

Object *Copy(Object *x)

Make a copy of the object x.

void Delete(Object *x)

Deletes x.

void Setfile(Object *x, String_or_char *f)

Sets the filename associated with x. Used to track objects and report errors.

String *Getfile(Object *x)

Gets the filename associated with x.

void Setline(Object *x, int n)

Sets the line number associated with x. Used to track objects and report errors.

int Getline(Object *x)

Gets the line number associated with x.

40.5.5 Iterating over Lists and Hashes

To iterate over the elements of a list or a hash table, the following functions are used:

Iterator First(Object *x)

Returns an iterator object that points to the first item in a list or hash table. The item attribute of the Iterator object is a pointer to the item. For hash tables, the key attribute of the Iterator object additionally points to the corresponding Hash table key. The item and key attributes are NULL if the object contains no items or if there are no more items.

Iterator Next(Iterator i)

Returns an iterator that points to the next item in a list or hash table. Here are two examples of iteration:

List *l = (some list);
Iterator i;

for (i = First(l); i.item; i = Next(i)) {
    Printf(stdout,"%s\n", i.item);
}

Hash *h = (some hash);
Iterator j;

for (j = First(j); j.item; j= Next(j)) {
    Printf(stdout,"%s : %s\n", j.key, j.item);
}

40.5.6 I/O

Special I/O functions are used for all internal I/O. These operations work on C FILE * objects, String objects, and special File objects (which are merely a wrapper around FILE *).

int Printf(String_or_FILE *f, const char *fmt, ...)

Formatted I/O. Same as the C fprintf() function except that output can also be directed to a string object. Note: the %s format specifier works with both strings and char *. All other format operators have the same meaning.

int Printv(String_or_FILE *f, String_or_char *arg1,..., NULL)

Prints a variable number of strings arguments to the output. The last argument to this function must be NULL. The other arguments can either be char * or string objects.

int Putc(int ch, String_or_FILE *f)

Same as the C fputc() function.

int Write(String_or_FILE *f, void *buf, int len)

Same as the C write() function.

int Read(String_or_FILE *f, void *buf, int maxlen)

Same as the C read() function.

int Getc(String_or_FILE *f)

Same as the C fgetc() function.

int Ungetc(int ch, String_or_FILE *f)

Same as the C ungetc() function.

int Seek(String_or_FILE *f, int offset, int whence)

Same as the C seek() function. offset is the number of bytes. whence is one of SEEK_SET,SEEK_CUR, or SEEK_END..

long Tell(String_or_FILE *f)

Same as the C tell() function.

File *NewFile(const char *filename, const char *mode, List *newfiles)

Create a File object using the fopen() library call. This file differs from FILE * in that it can be placed in the standard SWIG containers (lists, hashes, etc.). The filename is added to the newfiles list if newfiles is non-zero and the file was created successfully.

File *NewFileFromFile(FILE *f)

Create a File object wrapper around an existing FILE * object.

There's no explicit function to close a file, just call Delete(f) - this decreases the reference count, and the file will be closed when the reference count reaches zero.

The use of the above I/O functions and strings play a critical role in SWIG. It is common to see small code fragments of code generated using code like this:

/* Print into a string */
String *s = NewString("");
Printf(s,"Hello\n");
for (i = 0; i < 10; i++) {
    Printf(s,"%d\n", i);
}
...
/* Print string into a file */
Printf(f, "%s\n", s);

Similarly, the preprocessor and parser all operate on string-files.

40.6 Navigating and manipulating parse trees

Parse trees are built as collections of hash tables. Each node is a hash table in which arbitrary attributes can be stored. Certain attributes in the hash table provide links to other parse tree nodes. The following macros can be used to move around the parse tree.

String *nodeType(Node *n)

Returns the node type tag as a string. The returned string indicates the type of parse tree node.

Node *nextSibling(Node *n)

Returns the next node in the parse tree. For example, the next C declaration.

Node *previousSibling(Node *n)

Returns the previous node in the parse tree. For example, the previous C declaration.

Node *firstChild(Node *n)

Returns the first child node. For example, if n was a C++ class node, this would return the node for the first class member.

Node *lastChild(Node *n)

Returns the last child node. You might use this if you wanted to append a new node to the of a class.

Node *parentNode(Node *n)

Returns the parent of node n. Use this to move up the pass tree.

The following macros can be used to change all of the above attributes. Normally, these functions are only used by the parser. Changing them without knowing what you are doing is likely to be dangerous.

void set_nodeType(Node *n, const String_or_char)

Change the node type. tree node.

void set_nextSibling(Node *n, Node *s)

Set the next sibling.

void set_previousSibling(Node *n, Node *s)

Set the previous sibling.

void set_firstChild(Node *n, Node *c)

Set the first child node.

void set_lastChild(Node *n, Node *c)

Set the last child node.

void set_parentNode(Node *n, Node *p)

Set the parent node.

The following utility functions are used to alter the parse tree (at your own risk)

void appendChild(Node *parent, Node *child)

Append a child to parent. The appended node becomes the last child.

void deleteNode(Node *node)

Deletes a node from the parse tree. Deletion reconnects siblings and properly updates the parent so that sibling nodes are unaffected.

40.7 Working with attributes

Since parse tree nodes are just hash tables, attributes are accessed using the Getattr(), Setattr(), and Delattr() operations. For example:

int functionHandler(Node *n) {
    String *name    = Getattr(n,"name");
    String *symname = Getattr(n,"sym:name");
    SwigType *type  = Getattr(n,"type");
    ...
}

New attributes can be freely attached to a node as needed. However, when new attributes are attached during code generation, they should be prepended with a namespace prefix. For example:

...
Setattr(n,"python:docstring", doc);     /* Store docstring */
...

A quick way to check the value of an attribute is to use the checkAttribute() function like this:

if (checkAttribute(n,"storage","virtual")) {
   /* n is virtual */
   ...
}

Changing the values of existing attributes is allowed and is sometimes done to implement node transformations. However, if a function/method modifies a node, it is required to restore modified attributes to their original values. To simplify the task of saving/restoring attributes, the following functions are used:

int Swig_save(const char *ns, Node *n, const char *name1, const char *name2, ..., NIL)

Saves a copy of attributes name1, name2, etc. from node n. Copies of the attributes are actually resaved in the node in a different namespace which is set by the ns argument. For example, if you call Swig_save("foo",n,"type",NIL), then the "type" attribute will be copied and saved as "foo:type". The namespace name itself is stored in the "view" attribute of the node. If necessary, this can be examined to find out where previous values of attributes might have been saved.

int Swig_restore(Node *n)

Restores the attributes saved by the previous call to Swig_save(). Those attributes that were supplied to Swig_save() will be restored to their original values.

The Swig_save() and Swig_restore() functions must always be used as a pair. That is, every call to Swig_save() must have a matching call to Swig_restore(). Calls can be nested if necessary. Here is an example that shows how the functions might be used:

int variableHandler(Node *n) {
    Swig_save("variableHandler",n,"type","sym:name",NIL);
    String *symname = Getattr(n,"sym:name");
    SwigType *type  = Getattr(n,"type");
    ...
    Append(symname,"_global");         // Change symbol name
    SwigType_add_pointer(type);        // Add pointer
    ...
    generate wrappers
    ...
    Swig_restore(n);                  // Restore original values
    return SWIG_OK;
}

int Swig_require(const char *ns, Node *n, const char *name1, const char *name2, ..., NIL)

This is an enhanced version of Swig_save() that adds error checking. If an attribute name is not present in n, a failed assertion results and SWIG terminates with a fatal error. Optionally, if an attribute name is specified as "*name", a copy of the attribute is saved as with Swig_save(). If an attribute is specified as "?name", the attribute is optional. Swig_restore() must always be called after using this function.

40.8 Type system

SWIG implements the complete C++ type system including typedef, inheritance, pointers, references, and pointers to members. A detailed discussion of type theory is impossible here. However, let's cover the highlights.

40.8.1 String encoding of types

All types in SWIG consist of a base datatype and a collection of type operators that are applied to the base. A base datatype is almost always some kind of primitive type such as int or double. The operators consist of things like pointers, references, arrays, and so forth. Internally, types are represented as strings that are constructed in a very precise manner. Here are some examples:

C datatype                     SWIG encoding (strings)
-----------------------------  --------------------------
int                            "int"
int *                          "p.int"
const int *                    "p.q(const).int"
int (*x)(int,double)           "p.f(int,double).int"
int [20][30]                   "a(20).a(30).int"
int (F::*)(int)                "m(F).f(int).int"
vector<int> *                  "p.vector<(int)>"

Reading the SWIG encoding is often easier than figuring out the C code---just read it from left to right. For a type of "p.f(int,double).int" is a "pointer to a function(int,double) that returns int".

The following operator encodings are used in type strings:

Operator              Meaning
-------------------   -------------------------------
p.                    Pointer to
a(n).                 Array of dimension n
r.                    C++ reference
m(class).             Member pointer to class
f(args).              Function.
q(qlist).             Qualifiers

In addition, type names may be parameterized by templates. This is represented by enclosing the template parameters in <( ... )>. Variable length arguments are represented by the special base type of v(...).

If you want to experiment with type encodings, the raw type strings can be inserted into an interface file using backticks `` wherever a type is expected. For instance, here is an extremely perverted example:

`p.a(10).p.f(int,p.f(int).int)` foo(int, int (*x)(int));

This corresponds to the immediately obvious C declaration:

(*(*foo(int,int (*)(int)))[10])(int,int (*)(int));

Aside from the potential use of this declaration on a C programming quiz, it motivates the use of the special SWIG encoding of types. The SWIG encoding is much easier to work with because types can be easily examined, modified, and constructed using simple string operations (comparison, substrings, concatenation, etc.). For example, in the parser, a declaration like this

int *a[30];

is processed in a few pieces. In this case, you have the base type "int" and the declarator of type "a(30).p.". To make the final type, the two parts are just joined together using string concatenation.

40.8.2 Type construction

The following functions are used to construct types. You should use these functions instead of trying to build the type strings yourself.

void SwigType_add_pointer(SwigType *ty)

Adds a pointer to ty.

void SwigType_del_pointer(SwigType *ty)

Removes a single pointer from ty.

void SwigType_add_reference(SwigType *ty)

Adds a reference to ty.

void SwigType_add_array(SwigType *ty, const String_or_char *size)

Adds an array with dimension dim to ty.

void SwigType_del_array(SwigType *ty)

Removes a single array dimension from ty.

int SwigType_array_ndim(SwigType *ty)

Returns number of array dimensions of ty.

String* SwigType_array_getdim(SwigType *ty,int n)

Returns nth array dimension of ty.

void SwigType_array_setdim(SwigType *ty, int n, const String_or_char *rep)

Sets nth array dimensions of ty to rep.

void SwigType_add_qualifier(SwigType *ty, const String_or_char *q)

Adds a type qualifier q to ty. q is typically "const" or "volatile".

void SwigType_add_memberpointer(SwigType *ty, const String_or_char *cls)

Adds a pointer to a member of class cls to ty.

void SwigType_add_function(SwigType *ty, ParmList *p)

Adds a function to ty. p is a linked-list of parameter nodes as generated by the parser. See the section on parameter lists for details about the representation.

void SwigType_add_template(SwigType *ty, ParmList *p)

Adds a template to ty. p is a linked-list of parameter nodes as generated by the parser. See the section on parameter lists for details about the representation.

SwigType *SwigType_pop(SwigType *ty)

Removes the last type constructor from ty and returns it. ty is modified.

void SwigType_push(SwigType *ty, SwigType *op)

Pushes the type operators in op onto type ty. The opposite of SwigType_pop().

SwigType *SwigType_pop_arrays(SwigType *ty)

Removes all leading array operators from ty and returns them. ty is modified. For example, if ty is "a(20).a(10).p.int", then this function would return "a(20).a(10)." and modify ty so that it has the value "p.int".

SwigType *SwigType_pop_function(SwigType *ty)

Removes a function operator from ty including any qualification. ty is modified. For example, if ty is "f(int).int", then this function would return "f(int)." and modify ty so that it has the value "int".

SwigType *SwigType_base(SwigType *ty)

Returns the base type of a type. For example, if ty is "p.a(20).int", this function would return "int". ty is unmodified.

SwigType *SwigType_prefix(SwigType *ty)

Returns the prefix of a type. For example, if ty is "p.a(20).int", this function would return "p.a(20).". ty is unmodified.

40.8.3 Type tests

The following functions can be used to test properties of a datatype.

int SwigType_ispointer(SwigType *ty)

Checks if ty is a standard pointer.

int SwigType_ismemberpointer(SwigType *ty)

Checks if ty is a member pointer.

int SwigType_isreference(SwigType *ty)

Checks if ty is a C++ reference.

int SwigType_isarray(SwigType *ty)

Checks if ty is an array.

int SwigType_isfunction(SwigType *ty)

Checks if ty is a function.

int SwigType_isqualifier(SwigType *ty)

Checks if ty is a qualifier.

int SwigType_issimple(SwigType *ty)

Checks if ty is a simple type. No operators applied.

int SwigType_isconst(SwigType *ty)

Checks if ty is a const type.

int SwigType_isvarargs(SwigType *ty)

Checks if ty is a varargs type.

int SwigType_istemplate(SwigType *ty)

Checks if ty is a templatized type.

40.8.4 Typedef and inheritance

The behavior of typedef declaration is to introduce a type alias. For instance, typedef int Integer makes the identifier Integer an alias for int. The treatment of typedef in SWIG is somewhat complicated due to the pattern matching rules that get applied in typemaps and the fact that SWIG prefers to generate wrapper code that closely matches the input to simplify debugging (a user will see the typedef names used in their program instead of the low-level primitive C datatypes).

To handle typedef, SWIG builds a collection of trees containing typedef relations. For example,

typedef int Integer;
typedef Integer *IntegerPtr;
typedef int Number;
typedef int Size;

produces two trees like this:

                 int               p.Integer
               ^  ^  ^                 ^
              /   |   \                |
             /    |    \               |
        Integer  Size   Number    IntegerPtr

To resolve a single typedef relationship, the following function is used:

SwigType *SwigType_typedef_resolve(SwigType *ty)

Checks if ty can be reduced to a new type via typedef. If so, returns the new type. If not, returns NULL.

Typedefs are only resolved in simple typenames that appear in a type. For example, the type base name and in function parameters. When resolving types, the process starts in the leaf nodes and moves up the tree towards the root. Here are a few examples that show how it works:

Original type            After typedef_resolve()
------------------------ -----------------------
Integer                  int
a(30).Integer            int
p.IntegerPtr             p.p.Integer
p.p.Integer              p.p.int

For complicated types, the process can be quite involved. Here is the reduction of a function pointer:

p.f(Integer, p.IntegerPtr, Size).Integer          : Start
p.f(Integer, p.IntegerPtr, Size).int
p.f(int, p.IntegerPtr, Size).int
p.f(int, p.p.Integer, Size).int
p.f(int, p.p.int, Size).int
p.f(int, p.p.int, int).int                        : End

Two types are equivalent if their full type reductions are the same. The following function will fully reduce a datatype:

SwigType *SwigType_typedef_resolve_all(SwigType *ty)

Fully reduces ty according to typedef rules. Resulting datatype will consist only of primitive typenames.

40.8.5 Lvalues

When generating wrapper code, it is necessary to emit datatypes that can be used on the left-hand side of an assignment operator (an lvalue). However, not all C datatypes can be used in this way---especially arrays and const-qualified types. To generate a type that can be used as an lvalue, use the following function:

SwigType *SwigType_ltype(SwigType *ty)

Converts type ty to a type that can be used as an lvalue in assignment. The resulting type is stripped of qualifiers and arrays are converted to a pointers.

The creation of lvalues is fully aware of typedef and other aspects of the type system. Therefore, the creation of an lvalue may result in unexpected results. Here are a few examples:

typedef double Matrix4[4][4];
Matrix4 x;    // type = 'Matrix4', ltype='p.a(4).double'

typedef const char * Literal;
Literal y;    // type = 'Literal', ltype='p.char'

40.8.6 Output functions

The following functions produce strings that are suitable for output.

String *SwigType_str(SwigType *ty, const String_or_char *id = 0)

Generates a C string for a datatype. id is an optional declarator. For example, if ty is "p.f(int).int" and id is "foo", then this function produces "int (*foo)(int)". This function is used to convert string-encoded types back into a form that is valid C syntax.

String *SwigType_lstr(SwigType *ty, const String_or_char *id = 0)

This is the same as SwigType_str() except that the result is generated from the type's lvalue (as generated from SwigType_ltype).

String *SwigType_lcaststr(SwigType *ty, const String_or_char *id = 0)

Generates a casting operation that converts from type ty to its lvalue. id is an optional name to include in the cast. For example, if ty is "q(const).p.char" and id is "foo", this function produces the string "(char *) foo".

String *SwigType_rcaststr(SwigType *ty, const String_or_char *id = 0)

Generates a casting operation that converts from a type's lvalue to a type equivalent to ty. id is an optional name to include in the cast. For example, if ty is "q(const).p.char" and id is "foo", this function produces the string "(const char *) foo".

String *SwigType_manglestr(SwigType *ty)

Generates a mangled string encoding of type ty. The mangled string only contains characters that are part of a valid C identifier. The resulting string is used in various parts of SWIG, but is most commonly associated with type-descriptor objects that appear in wrappers (e.g., SWIGTYPE_p_double).

40.9 Parameters

Several type-related functions involve parameter lists. These include functions and templates. Parameter list are represented as a list of nodes with the following attributes:

"type"        -  Parameter type  (required)
"name"        -  Parameter name  (optional)
"value"       -  Initializer     (optional)

Typically parameters are denoted in the source by using a typename of Parm * or ParmList *. To walk a parameter list, simply use code like this:

Parm *parms;
Parm *p;
for (p = parms; p; p = nextSibling(p)) {
    SwigType *type  = Getattr(p,"type");
    String   *name  = Getattr(p,"name");
    String   *value = Getattr(p,"value");
    ...
}

Note: this code is exactly the same as what you would use to walk parse tree nodes.

An empty list of parameters is denoted by a NULL pointer.

Since parameter lists are fairly common, the following utility functions are provided to manipulate them:

Parm *CopyParm(Parm *p);

Copies a single parameter.

ParmList *CopyParmList(ParmList *p);

Copies an entire list of parameters.

int ParmList_len(ParmList *p);

Returns the number of parameters in a parameter list.

String *ParmList_str(ParmList *p);

Converts a parameter list into a C string. For example, produces a string like "(int *p, int n, double x);".

String *ParmList_protostr(ParmList *p);

The same as ParmList_str() except that parameter names are not included. Used to emit prototypes.

int ParmList_numrequired(ParmList *p);

Returns the number of required (non-optional) arguments in p.

40.10 Writing a Language Module

One of the easiest routes to supporting a new language module is to copy an already supported language module implementation and modify it. Be sure to choose a language that is similar in nature to the new language. All language modules follow a similar structure and this section briefly outlines the steps needed to create a bare-bones language module from scratch. Since the code is relatively easy to read, this section describes the creation of a minimal Python module. You should be able to extrapolate this to other languages.

40.10.1 Execution model

Code generation modules are defined by inheriting from the Language class, currently defined in the Source/Modules directory of SWIG. Starting from the parsing of command line options, all aspects of code generation are controlled by different methods of the Language that must be defined by your module.

40.10.2 Starting out

To define a new language module, first create a minimal implementation using this example as a guide:

#include "swigmod.h"

class PYTHON : public Language {
public:

  virtual void main(int argc, char *argv[]) {
    printf("I'm the Python module.\n");
  }

  virtual int top(Node *n) {
    printf("Generating code.\n");
    return SWIG_OK;
  }

};

extern "C" Language *
swig_python(void) {
  return new PYTHON();
}

The "swigmod.h" header file contains, among other things, the declaration of the Language base class and so you should include it at the top of your language module's source file. Similarly, the "swigconfig.h" header file contains some other useful definitions that you may need. Note that you should not include any header files that are installed with the target language. That is to say, the implementation of the SWIG Python module shouldn't have any dependencies on the Python header files. The wrapper code generated by SWIG will almost always depend on some language-specific C/C++ header files, but SWIG itself does not.

Give your language class a reasonable name, usually the same as the target language. By convention, these class names are all uppercase (e.g. "PYTHON" for the Python language module) but this is not a requirement. This class will ultimately consist of a number of overrides of the virtual functions declared in the Language base class, in addition to any language-specific member functions and data you need. For now, just use the dummy implementations shown above.

The language module ends with a factory function, swig_python(), that simply returns a new instance of the language class. As shown, it should be declared with the extern "C" storage qualifier so that it can be called from C code. It should also return a pointer to the base class (Language) so that only the interface (and not the implementation) of your language module is exposed to the rest of SWIG.

Save the code for your language module in a file named "python.cxx" and. place this file in the Source/Modules directory of the SWIG distribution. To ensure that your module is compiled into SWIG along with the other language modules, modify the file Source/Modules/Makefile.am to include the additional source files. In addition, modify the file Source/Modules/swigmain.cxx with an additional command line option that activates the module. Read the source---it's straightforward.

Next, at the top level of the SWIG distribution, re-run the autogen.sh script to regenerate the various build files:

$ ./autogen.sh

Next re-run configure to regenerate all of the Makefiles:

$ ./configure

Finally, rebuild SWIG with your module added:

$ make

Once it finishes compiling, try running SWIG with the command-line option that activates your module. For example, swig -python foo.i. The messages from your new module should appear.

40.10.3 Command line options

When SWIG starts, the command line options are passed to your language module. This occurs before any other processing occurs (preprocessing, parsing, etc.). To capture the command line options, simply use code similar to this:

void Language::main(int argc, char *argv[]) {
  for (int i = 1; i < argc; i++) {
      if (argv[i]) {
          if(strcmp(argv[i],"-interface") == 0) {
            if (argv[i+1]) {
              interface = NewString(argv[i+1]);
              Swig_mark_arg(i);
              Swig_mark_arg(i+1);
              i++;
            } else {
              Swig_arg_error();
            }
          } else if (strcmp(argv[i],"-globals") == 0) {
            if (argv[i+1]) {
              global_name = NewString(argv[i+1]);
              Swig_mark_arg(i);
              Swig_mark_arg(i+1);
              i++;
            } else {
              Swig_arg_error();
            }
          } else if ( (strcmp(argv[i],"-proxy") == 0)) {
            proxy_flag = 1;
            Swig_mark_arg(i);
          } else if (strcmp(argv[i],"-keyword") == 0) {
            use_kw = 1;
            Swig_mark_arg(i);
          } else if (strcmp(argv[i],"-help") == 0) {
            fputs(usage,stderr);
          }
          ...
      }
  }
}

The exact set of options depends on what you want to do in your module. Generally, you would use the options to change code generation modes or to print diagnostic information.

If a module recognizes an option, it should always call Swig_mark_arg() to mark the option as valid. If you forget to do this, SWIG will terminate with an unrecognized command line option error.

40.10.4 Configuration and preprocessing

In addition to looking at command line options, the main() method is responsible for some initial configuration of the SWIG library and preprocessor. To do this, insert some code like this:

void main(int argc, char *argv[]) {
   ... command line options ...

   /* Set language-specific subdirectory in SWIG library */
   SWIG_library_directory("python");

   /* Set language-specific preprocessing symbol */
   Preprocessor_define("SWIGPYTHON 1", 0);

   /* Set language-specific configuration file */
   SWIG_config_file("python.swg");

   /* Set typemap language (historical) */
   SWIG_typemap_lang("python");
}

The above code does several things--it registers the name of the language module with the core, it supplies some preprocessor macro definitions for use in input files (so that they can determine the target language), and it registers a start-up file. In this case, the file python.swg will be parsed before any part of the user-supplied input file.

Before proceeding any further, create a directory for your module in the SWIG library (The Lib directory). Now, create a configuration file in the directory. For example, python.swg.

Just to review, your language module should now consist of two files-- an implementation file python.cxx and a configuration file python.swg.

40.10.5 Entry point to code generation

SWIG is a multi-pass compiler. Once the main() method has been invoked, the language module does not execute again until preprocessing, parsing, and a variety of semantic analysis passes have been performed. When the core is ready to start generating wrappers, it invokes the top() method of your language class. The argument to top is a single parse tree node that corresponds to the top of the entire parse tree.

To get the code generation process started, the top() procedure needs to do several things:

  • Initialize the wrapper code output.
  • Set the module name.
  • Emit common initialization code.
  • Emit code for all of the child nodes.
  • Finalize the wrapper module and cleanup.

An outline of top() might be as follows:

int Python::top(Node *n) {

   /* Get the module name */
   String *module = Getattr(n,"name");

   /* Get the output file name */
   String *outfile = Getattr(n,"outfile");

   /* Initialize I/O (see next section) */
   ...

   /* Output module initialization code */
   ...

   /* Emit code for children */
   Language::top(n);

   ...
   /* Cleanup files */
   ...

   return SWIG_OK;
}

40.10.6 Module I/O and wrapper skeleton

Within SWIG wrappers, there are five main sections. These are (in order)

  • begin: This section is a placeholder for users to put code at the beginning of the C/C++ wrapper file.
  • runtime: This section has most of the common SWIG runtime code.
  • header: This section holds declarations and inclusions from the .i file.
  • wrapper: This section holds all the wrapper code.
  • init: This section holds the module initialisation function (the entry point for the interpreter).

Different parts of the SWIG code will fill different sections, then upon completion of the wrappering all the sections will be saved to the wrapper file.

To perform this will require several additions to the code in various places, such as:

class PYTHON : public Language {
protected:
   /* General DOH objects used for holding the strings */
   File *f_begin;
   File *f_runtime;
   File *f_header;
   File *f_wrappers;
   File *f_init;

public:
   ...

};

int Python::top(Node *n) {

   ...

   /* Initialize I/O */
   f_begin = NewFile(outfile, "w", SWIG_output_files());
   if (!f_begin) {
      FileErrorDisplay(outfile);
      SWIG_exit(EXIT_FAILURE);
   }
   f_runtime = NewString("");
   f_init = NewString("");
   f_header = NewString("");
   f_wrappers = NewString("");

   /* Register file targets with the SWIG file handler */
   Swig_register_filebyname("begin", f_begin);
   Swig_register_filebyname("header", f_header);
   Swig_register_filebyname("wrapper", f_wrappers);
   Swig_register_filebyname("runtime", f_runtime);
   Swig_register_filebyname("init", f_init);

   /* Output module initialization code */
   Swig_banner(f_begin);
   ...

   /* Emit code for children */
   Language::top(n);

   ...
   /* Write all to the file */
   Dump(f_runtime, f_begin);
   Dump(f_header, f_begin);
   Dump(f_wrappers, f_begin);
   Wrapper_pretty_print(f_init, f_begin);

   /* Cleanup files */
   Delete(f_runtime);
   Delete(f_header);
   Delete(f_wrappers);
   Delete(f_init);
   Delete(f_begin);

   return SWIG_OK;
}

Using this to process a file will generate a wrapper file, however the wrapper will only consist of the common SWIG code as well as any inline code which was written in the .i file. It does not contain any wrappers for any of the functions or classes.

The code to generate the wrappers are the various member functions, which currently have not been touched. We will look at functionWrapper() as this is the most commonly used function. In fact many of the other wrapper routines will call this to do their work.

A simple modification to write some basic details to the wrapper looks like this:

int Python::functionWrapper(Node *n) {
  /* Get some useful attributes of this function */
  String   *name   = Getattr(n,"sym:name");
  SwigType *type   = Getattr(n,"type");
  ParmList *parms  = Getattr(n,"parms");
  String   *parmstr= ParmList_str_defaultargs(parms); // to string
  String   *func   = SwigType_str(type, NewStringf("%s(%s)", name, parmstr));
  String   *action = Getattr(n,"wrap:action");

  Printf(f_wrappers,"functionWrapper   : %s\n", func);
  Printf(f_wrappers,"           action : %s\n", action);
  return SWIG_OK;
}

This will now produce some useful information within your wrapper file.

functionWrapper   : void delete_Shape(Shape *self)
           action : delete arg1;

functionWrapper   : void Shape_x_set(Shape *self,double x)
           action : if (arg1) (arg1)->x = arg2;

functionWrapper   : double Shape_x_get(Shape *self)
           action : result = (double) ((arg1)->x);

functionWrapper   : void Shape_y_set(Shape *self,double y)
           action : if (arg1) (arg1)->y = arg2;
...

40.10.7 Low-level code generators

As ingenious as SWIG is, and despite all its capabilities and the power of its parser, the Low-level code generation takes a lot of work to write properly. Mainly because every language insists on its own manner of interfacing to C/C++. To write the code generators you will need a good understanding of how to manually write an interface to your chosen language, so make sure you have your documentation handy.

At this point it is also probably a good idea to take a very simple file (just one function), and try letting SWIG generate wrappers for many different languages. Take a look at all of the wrappers generated, and decide which one looks closest to the language you are trying to wrap. This may help you to decide which code to look at.

In general most language wrappers look a little like this:

/* wrapper for TYPE3 some_function(TYPE1,TYPE2); */
RETURN_TYPE _wrap_some_function(ARGS){
  TYPE1 arg1;
  TYPE2 arg2;
  TYPE3 result;

  if(ARG1 is not of TYPE1) goto fail;
  arg1=(convert ARG1);
  if(ARG2 is not of TYPE2) goto fail;
  arg2=(convert ARG2);

  result=some_function(arg1,arg2);

  convert 'result' to whatever the language wants;

  do any tidy up;

  return ALL_OK;

  fail:
  do any tidy up;
  return ERROR;
}

Yes, it is rather vague and not very clear. But each language works differently so this will have to do for now.

Tackling this problem will be done in two stages:

  • The skeleton: the function wrapper, and call, but without the conversion
  • The conversion: converting the arguments to-from what the language wants

The first step will be done in the code, the second will be done in typemaps.

Our first step will be to write the code for functionWrapper(). What is shown below is NOT the solution, merely a step in the right direction. There are a lot of issues to address.

  • Variable length and default parameters
  • Typechecking and number of argument checks
  • Overloaded functions
  • Inout and Output only arguments
virtual int functionWrapper(Node *n) {
  /* get useful attributes */
  String   *name   = Getattr(n,"sym:name");
  SwigType *type   = Getattr(n,"type");
  ParmList *parms  = Getattr(n,"parms");
  ...

  /* create the wrapper object */
  Wrapper *wrapper = NewWrapper();

  /* create the functions wrappered name */
  String *wname = Swig_name_wrapper(iname);

  /* deal with overloading */
  ....

  /* write the wrapper function definition */
  Printv(wrapper->def,"RETURN_TYPE ", wname, "(ARGS) {",NIL);

  /* if any additional local variable needed, add them now */
  ...

  /* write the list of locals/arguments required */
  emit_args(type, parms, wrapper);

  /* check arguments */
  ...

  /* write typemaps(in) */
  ....

  /* write constraints */
  ....

  /* Emit the function call */
  emit_action(n,wrapper);

  /* return value if necessary  */
  ....

  /* write typemaps(out) */
  ....

  /* add cleanup code */
  ....

  /* Close the function(ok) */
  Printv(wrapper->code, "return ALL_OK;\n", NIL);

  /* add the failure cleanup code */
  ...

  /* Close the function(error) */
  Printv(wrapper->code, "return ERROR;\n", "}\n", NIL);

  /* final substititions if applicable */
  ...

  /* Dump the function out */
  Wrapper_print(wrapper,f_wrappers);

  /* tidy up */
  Delete(wname);
  DelWrapper(wrapper);

  return SWIG_OK;
}

Executing this code will produce wrappers which have our basic skeleton but without the typemaps, there is still work to do.

40.10.8 Configuration files

At the time of this writing, SWIG supports nearly twenty languages, which means that for continued sanity in maintaining the configuration files, the language modules need to follow some conventions. These are outlined here along with the admission that, yes it is ok to violate these conventions in minor ways, as long as you know where to apply the proper kludge to keep the overall system regular and running. Engineering is the art of compromise, see...

Much of the maintenance regularity depends on choosing a suitable nickname for your language module (and then using it in a controlled way). Nicknames should be all lower case letters with an optional numeric suffix (no underscores, no dashes, no spaces). Some examples are: foo, bar, qux99.

The numeric suffix variant, as in the last example, is somewhat tricky to work with because sometimes people expect to refer to the language without this number but sometimes that number is extremely relevant (especially when it corresponds to language implementation versions with incompatible interfaces). New language modules that unavoidably require a numeric suffix in their nickname should include that number in all uses, or be prepared to kludge.

The nickname is used in four places:

usagetransform
"skip" tag(none)
Examples/ subdir name(none)
Examples/test-suite/ subdir name(none)

As you can see, most usages are direct.

configure.ac
This file is processed by

autoconf to generate the configure script. This is where you need to add shell script fragments and autoconf macros to detect the presence of whatever development support your language module requires, typically directories where headers and libraries can be found, and/or utility programs useful for integrating the generated wrapper code.

Use the AC_ARG_WITH, AC_MSG_CHECKING, AC_SUBST macros and so forth (see other languages for examples). Avoid using the [ and ] character in shell script fragments. The variable names passed to AC_SUBST should begin with the nickname, entirely upcased.

At the end of the new section is the place to put the aforementioned nickname kludges (should they be needed). See Perl5 for examples of what to do. [If this is still unclear after you've read the code, ping me and I'll expand on this further. --ttn]

Makefile.in

Some of the variables AC_SUBSTituted are essential to the support of your language module. Fashion these into a shell script "test" clause and assign that to a skip tag using "-z" and "-o":

skip-qux99 = [ -z "@QUX99INCLUDE@" -o -z "@QUX99LIBS" ]

This means if those vars should ever be empty, qux99 support should be considered absent and so it would be a good idea to skip actions that might rely on it.

Here is where you may also define an alias (but then you'll need to kludge --- don't do this):

skip-qux = $(skip-qux99)

Lastly, you need to modify each of check-aliveness, check-examples, check-test-suite and lib-languages (var). Use the nickname for these, not the alias. Note that you can do this even before you have any tests or examples set up; the Makefile rules do some sanity checking and skip around these kinds of problems.

Examples/Makefile.in
Nothing special here; see comments at top the of this file and look to the existing languages for examples.
Examples/qux99/check.list
Do cp ../python/check.list . and modify to taste. One subdir per line.
Lib/qux99/extra-install.list
If you add your language to the top-level Makefile.in var lib-languages, then make install will install all *.i and *.swg files from the language-specific subdirectory of Lib. Use (optional) file extra-install.list in that directory to name additional files to install (see ruby for example).
Source/Modules/Makefile.am
Add appropriate files to this Automake file. That's it!

When you have modified these files, please make sure that the new language module is completely ignored if it is not installed and detected on a box, that is, make check-examples and make check-test-suite politely displays the ignoring language message.

40.10.9 Runtime support

Discuss the kinds of functions typically needed for SWIG runtime support (e.g. SWIG_ConvertPtr() and SWIG_NewPointerObj()) and the names of the SWIG files that implement those functions.

40.10.10 Standard library files

The standard library files that most languages supply keeps growing as SWIG matures. The following are the minimum that are usually supported:

  • typemaps.i
  • std_string.i
  • std_vector.i
  • stl.i

Please copy these and modify for any new language.

40.10.11 User examples

Each of the language modules provides one or more examples. These examples are used to demonstrate different features of the language module to SWIG end-users, but you'll find that they're useful during development and testing of your language module as well. You can use examples from the existing SWIG language modules for inspiration.

Each example is self-contained and consists of (at least) a Makefile, a SWIG interface file for the example module, and a 'runme' script that demonstrates the functionality for that module. All of these files are stored in the same subdirectory under the Examples/[lang] directory. There are two classic examples which should be the first to convert to a new language module. These are the "simple" C example and the "class" C++ example. These can be found, for example for Python, in Examples/python/simple and Examples/python/class.

By default, all of the examples are built and run when the user types make check. To ensure that your examples are automatically run during this process, see the section on configuration files.

40.10.12 Test driven development and the test-suite

A test driven development approach is central to the improvement and development of SWIG. Most modifications to SWIG are accompanied by additional regression tests and checking all tests to ensure that no regressions have been introduced.

The regression testing is carried out by the SWIG test-suite. The test-suite consists of numerous testcase interface files in the Examples/test-suite directory as well as target language specific runtime tests in the Examples/test-suite/[lang] directory. When a testcase is run, it will execute the following steps for each testcase:

  1. Execute SWIG passing it the testcase interface file.
  2. Compile the resulting generated C/C++ code with either the C or C++ compiler into object files.
  3. Link the object files into a dynamic library (dll/shared object).
  4. Compile any generated and any runtime test target language code with the target language compiler, if the target language supports compilation. This step thus does not apply to the interpreted languages.
  5. Execute a runtime test if one exists.

For example, the ret_by_value testcase consists of two components. The first component is the Examples/test-suite/ret_by_value.i interface file. The name of the SWIG module must always be the name of the testcase, so the ret_by_value.i interface file thus begins with:

%module ret_by_value

The testcase code will then follow the module declaration, usually within a %inline %{ ... %} section for the majority of the tests.

The second component is the optional runtime tests. Any runtime tests are named using the following convention: [testcase]_runme.[ext], where [testcase] is the testcase name and [ext] is the normal extension for the target language file. In this case, the Java and Python target languages implement a runtime test, so their files are respectively, Examples/test-suite/java/ret_by_value_runme.java and Examples/test-suite/python/ret_by_value_runme.py.

The goal of the test-suite is to test as much as possible in a silent manner. This way any SWIG or compiler errors or warnings are easily visible. Should there be any warnings, changes must be made to either fix them (preferably) or suppress them. Compilation or runtime errors result in a testcase failure and will be immediately visible. It is therefore essential that the runtime tests are written in a manner that displays nothing to stdout/stderr on success but error/exception out with an error message on stderr on failure.

40.10.12.1 Running the test-suite

In order for the test-suite to work for a particular target language, the language must be correctly detected and configured during the configure stage so that the correct Makefiles are generated. Most development occurs on Linux, so usually it is a matter of installing the development packages for the target language and simply configuring as outlined earlier.

If when running the test-suite commands that follow, you get a message that the test was skipped, it indicates that the configure stage is missing information in order to compile and run everything for that language.

The test-suite can be run in a number of ways. The first group of commands are for running multiple testcases in one run and should be executed in the top level directory. To run the entire test-suite (can take a long time):

make -k check-test-suite

To run the test-suite just for target language [lang], replace [lang] with one of csharp, java, perl5, python, ruby, tcl etc:

make check-[lang]-test-suite

Note that if a runtime test is available, a message "(with run test)" is displayed when run. For example:

$ make check-python-test-suite
checking python test-suite
checking python testcase argcargvtest (with run test)
checking python testcase python_autodoc
checking python testcase python_append (with run test)
checking python testcase callback (with run test)

The files generated on a previous run can be deleted using the clean targets, either the whole test-suite or for a particular language:

make clean-test-suite
make clean-[lang]-test-suite

The test-suite can be run in a partialcheck mode where just SWIG is executed, that is, the compile, link and running of the testcases is not performed. Note that the partialcheck does not require the target language to be correctly configured and detected and unlike the other test-suite make targets, is never skipped. Once again, either all the languages can be executed or just a chosen language:

make partialcheck-test-suite
make partialcheck-[lang]-test-suite

If your computer has more than one CPU, you are strongly advised to use parallel make to speed up the execution speed. This can be done with any of the make targets that execute more than one testcase. For example, a dual core processor can efficiently use 2 parallel jobs:

make -j2 check-test-suite
make -j2 check-python-test-suite
make -j2 partialcheck-java-test-suite

The second group of commands are for running individual testcases and should be executed in the appropriate target language directory, Examples/test-suite/[lang]. Testcases can contain either C or C++ code and when one is written, a decision must be made as to which of these input languages is to be used. Replace [testcase] in the commands below with the name of the testcase.

For a C language testcase, add the testcase under the C_TEST_CASES list in Examples/test-suite/common.mk and execute individually as:

make -s [testcase].ctest

For a C++ language testcase, add the testcase under the CPP_TEST_CASES list in Examples/test-suite/common.mk and execute individually as:

make -s [testcase].cpptest

A third category of tests are C++ language testcases testing multiple modules (the %import directive). These require more than one shared library (dll/shared object) to be built and so are separated out from the normal C++ testcases. Add the testcase under the MULTI_CPP_TEST_CASES list in Examples/test-suite/common.mk and execute individually as:

make -s [testcase].multicpptest

To delete the generated files, execute:

make -s [testcase].clean

If you would like to see the exact commands being executed, drop the -s option:

make [testcase].ctest
make [testcase].cpptest
make [testcase].multicpptest

Some real examples of each:

make -s ret_by_value.clean
make -s ret_by_value.ctest
make -s bools.cpptest
make -s imports.multicpptest

Advanced usage of the test-suite facilitates running tools on some of the five stages. The make variables SWIGTOOL and RUNTOOL are used to specify a tool to respectively, invoke SWIG and the execution of the runtime test. You are advised to view the Examples/test-suite/common.mk file for details but for a short summary, the classic usage is to use Valgrind for memory checking. For example, checking for memory leaks when running the runtime test in the target language interpreter:

make ret_by_value.ctest RUNTOOL="valgrind --leak-check=full"

This will probably make more sense if you look at the output of the above as it will show the exact commands being executed. SWIG can be analyzed for bad memory accesses using:

make ret_by_value.ctest SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"

A debugger can also be invoked easily on an individual test, for example gdb:

make ret_by_value.ctest RUNTOOL="gdb --args"

SWIG reads the SWIG_FEATURES environment variable to obtain options in addition to those passed on the command line. This is particularly useful as the entire test-suite or a particular testcase can be run customized by using additional arguments, for example the -O optimization flag can be added in, as shown below for the bash shell:

env SWIG_FEATURES=-O make check-python-test-suite

The syntax for setting environment variables varies from one shell to the next, but it also works as shown in the example below, where some typemap debugging is added in:

make ret_by_value.ctest SWIG_FEATURES="-debug-tmsearch"

There is also a special 'errors' test-suite which is a set of regression tests checking SWIG warning and error messages. It can be run in the same way as the other language test-suites, replacing [lang] with errors, such as make check-errors-test-suite. The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

40.10.13 Documentation

Don't forget to write end-user documentation for your language module. Currently, each language module has a dedicated chapter You shouldn't rehash things that are already covered in sufficient detail in the SWIG Basics and SWIG and C++ chapters. There is no fixed format for what, exactly, you should document about your language module, but you'll obviously want to cover issues that are unique to your language.

Some topics that you'll want to be sure to address include:

  • Command line options unique to your language module.
  • Non-obvious mappings between C/C++ and target language concepts. For example, if your target language provides a single floating point type, it should be no big surprise to find that C/C++ float and double types are mapped to it. On the other hand, if your target language doesn't provide support for "classes" or something similar, you'd want to discuss how C++ classes are handled.
  • How to compile the SWIG-generated wrapper code into shared libraries that can actually be used. For some languages, there are well-defined procedures for doing this, but for others it's an ad hoc process. Provide as much detail as appropriate, and links to other resources if available.

40.10.14 Prerequisites for adding a new language module to the SWIG distribution

If you wish for a new language module to be distributed with SWIG, which we encourage for all popular languages, there are a few requirements. While we appreciate that getting all aspects of a new language working won't happen at the outset, there are a set of minimum requirements before a module can be committed into the official Github repository for distribution with future versions of SWIG. The following are really a summary of this whole section with details being outlined earlier on.

  1. Demonstrate basic C code working by porting the "simple" example including a runtime test, see for example Examples/python/simple.
  2. Demonstrate basic C++ code working by porting the "class" example including a runtime test, see for example Examples/python/class.
  3. Modify configure.ac, Makefile.in and Examples/Makefile.in to run these examples. Please make sure that if the new language is not installed properly on a box, make -k check should still work by skipping the tests and examples for the new language module.
  4. Get the test-suite running for the new language (make check-[lang]-test-suite). While the test-suite tests many corner cases, we'd expect the majority of it to work by compiling the generated code correctly as most of the corner cases are covered in the SWIG core. Get at least one C and one C++ runtime test running in the test-suite.
  5. Provide a chapter in the html documentation on the basics of using the language module.
  6. Ensure your source code is formatted according to the coding style guidelines.
  7. Finally, email the SWIG developers with a patch and a demonstration of commitment to maintaining the language module, certainly in the short term and ideally long term.

Once accepted into the official Git repository, development efforts should concentrate on getting the entire test-suite to work with plenty of runtime tests. Runtime tests should be for existing testcases and new test cases should be added should there be an area not already covered by the existing tests.

40.10.15 Coding style guidelines

The coding guidelines for the C/C++ source code are pretty much K&R C style. The style can be inferred from the existing code base and is largely dictated by the indent code beautifier tool set to K&R style. The code can formatted using the make targets in the Source directory. Below is an example of how to format the emit.cxx file:

$ cd Source
$ make beautify-file INDENTFILE=Modules/emit.cxx

Of particular note is indentation is set to 2 spaces and a tab is used instead of 8 spaces. The generated C/C++ code should also follow this style as close as possible. However, tabs should be avoided as unlike the SWIG developers, users will never have consistent tab settings.

40.11 Debugging Options

There are various command line options which can aid debugging a SWIG interface as well as debugging the development of a language module. These are as follows:

-debug-classes    - Display information about the classes found in the interface
-debug-module <n> - Display module parse tree at stages 1-4, <n> is a csv list of stages
-debug-symtabs    - Display symbol tables information
-debug-symbols    - Display target language symbols in the symbol tables
-debug-csymbols   - Display C symbols in the symbol tables
-debug-lsymbols   - Display target language layer symbols
-debug-tags       - Display information about the tags found in the interface
-debug-template   - Display information for debugging templates
-debug-top <n>    - Display entire parse tree at stages 1-4, <n> is a csv list of stages
-debug-typedef    - Display information about the types and typedefs in the interface
-debug-typemap    - Display information for debugging typemaps
-debug-tmsearch   - Display typemap search debugging information
-debug-tmused     - Display typemaps used debugging information

The complete list of command line options for SWIG are available by running swig -help.

40.12 Guide to parse tree nodes

This section describes the different parse tree nodes and their attributes.

cdecl

Describes general C declarations including variables, functions, and typedefs. A declaration is parsed as "storage T D" where storage is a storage class, T is a base type, and D is a declarator.

"name"          - Declarator name
"type"          - Base type T
"decl"          - Declarator type (abstract)
"storage"       - Storage class (static, extern, typedef, etc.)
"parms"         - Function parameters (if a function)
"code"          - Function body code (if supplied)
"value"         - Default value (if supplied)

constructor

C++ constructor declaration.

"name"          - Name of constructor
"parms"         - Parameters
"decl"          - Declarator (function with parameters)
"code"          - Function body code (if any)
"feature:new"   - Set to indicate return of new object.

destructor

C++ destructor declaration.

"name"          - Name of destructor
"code"          - Function body code (if any)
"storage"       - Storage class (set if virtual)
"value"         - Default value (set if pure virtual).

access

C++ access change.

"kind"          - public, protected, private

constant

Constant created by %constant or #define.

"name"          - Name of constant.
"type"          - Base type.
"value"         - Value.
"storage"       - Set to %constant
"feature:immutable" - Set to indicate read-only

class

C++ class definition or C structure definition.

"name"          - Name of the class.
"kind"          - Class kind ("struct", "union", "class")
"symtab"        - Enclosing symbol table.
"tdname"        - Typedef name. Use for typedef struct { ... } A.
"abstract"      - Set if class has pure virtual methods.
"baselist"      - List of base class names.
"storage"       - Storage class (if any)
"unnamed"       - Set if class is unnamed.

enum

Enumeration.

"name"          - Name of the enum (if supplied).
"storage"       - Storage class (if any)
"tdname"        - Typedef name (typedef enum { ... } name).
"unnamed"       - Set if enum is unnamed.

enumitem

Enumeration value.

"name"          - Name of the enum value.
"type"          - Type (integer or char)
"value"         - Enum value (if given)
"feature:immutable" - Set to indicate read-only

namespace

C++ namespace.

"name"          - Name of the namespace.
"symtab"        - Symbol table for enclosed scope.
"unnamed"       - Set if unnamed namespace
"alias"         - Alias name. Set for namespace A = B;

using

C++ using directive.

"name"          - Name of the object being referred to.
"uname"         - Qualified name actually given to using.
"node"          - Node being referenced.
"namespace"     - Namespace name being reference (using namespace name)

classforward

A forward C++ class declaration.

"name"          - Name of the class.
"kind"          - Class kind ("union", "struct", "class")

insert

Code insertion directive. For example, %{ ... %} or %insert(section).

"code"          - Inserted code
"section"       - Section name ("header", "wrapper", etc.)

top

Top of the parse tree.

"module"        - Module name

extend

%extend directive.

"name"          - Module name
"symtab"        - Symbol table of enclosed scope.

apply

%apply pattern { patternlist }.

"pattern"       - Source pattern.
"symtab"        - Symbol table of enclosed scope.

clear

%clear patternlist;

"firstChild"    - Patterns to clear

include

%include directive.

"name"         - Filename
"firstChild"   - Children

import

%import directive.

"name"         - Filename
"firstChild"   - Children

module

%module directive.

"name"         - Name of the module

typemap

%typemap directive.

"method"       - Typemap method name.
"code"         - Typemap code.
"kwargs"       - Keyword arguments (if any)
"firstChild"   - Typemap patterns

typemapcopy

%typemap directive with copy.

"method"       - Typemap method name.
"pattern"      - Typemap source pattern.
"firstChild"   - Typemap patterns

typemapitem

%typemap pattern. Used with %apply, %clear, %typemap.

"pattern"      - Typemap pattern (a parameter list)
"parms"        - Typemap parameters.

types

%types directive.

"parms"        - List of parameter types.
"convcode"     - Code which replaces the default casting / conversion code

extern

extern "X" { ... } declaration.

"name"       - Name "C", "Fortran", etc.

40.13 Further Development Information

There is further documentation available on the internals of SWIG, API documentation and debugging information. This is shipped with SWIG in the Doc/Devel directory.

swig-3.0.2/Doc/Manual/Mzscheme.html0000664000175000017500000001165412343706602016742 0ustar williamwilliam SWIG and MzScheme/Racket

30 SWIG and MzScheme/Racket

This section contains information on SWIG's support of Racket, formally known as MzScheme.

30.1 Creating native structures

Example interface file:

/* define a macro for the struct creation */
%define handle_ptr(TYPE,NAME)
%typemap(argout) TYPE *NAME{
    Scheme_Object *o = SWIG_NewStructFromPtr($1, $*1_mangle);
    SWIG_APPEND_VALUE(o);
}

%typemap(in,numinputs=0) TYPE *NAME (TYPE temp) {
    $1 = &temp;
}
%enddef

/* setup the typemaps for the pointer to an output parameter cntrs */
handle_ptr(struct diag_cntrs, cntrs);

Then in scheme, you can use regular struct access procedures like

	; suppose a function created a struct foo as 
	; (define foo (make-diag-cntrs (#x1 #x2 #x3) (make-inspector))
	; Then you can do
	(format "0x~x" (diag-cntrs-field1 foo))
	(format "0x~x" (diag-cntrs-field2 foo))
	;etc...

30.2 Simple example

A few examples are available in the Examples/mzscheme directory. The code and log of a session using SWIG below should help getting started.

C header file:

// example.h
int fact(int n);

C source code:

// File: example.c
#include "example.h"

int fact(int n) {
  if (n < 0) { /* This should probably return an error, but this is simpler */
    return 0;
  }
  if (n == 0) {
    return 1;
  }
  else {
    /* testing for overflow would be a good idea here */
    return n * fact(n-1);
  }
}

SWIG interface file:

/* File: example.i */
%module example

%{
#include "example.h"
%}

int fact(int n);

The session below using the above files is on an OS X machine, but the points to be made are more general. On OS X, libtool is the tool which creates libraries, which are named .dylib, rather than .so on other unixes, or .dll on Windows.

% swig -mzscheme -declaremodule example.i
% gcc -c -m32 -o example.o example.c # force 32-bit object file (mzscheme is 32-bit only)
% libtool -dynamic -o libexample.dylib example.o # make it into a library
% ls # what've we got so far?
example.c example.o
example.h example_wrap.c
example.i libexample.dylib*
% mzc --cgc --cc example_wrap.c # compile the wrapping code
% LDFLAGS="-L. -lexample" mzc --ld example_wrap.dylib example_wrap.o # ...and link it
% mzscheme -e '(path->string (build-path "compiled" "native" (system-library-subpath)))'
"compiled/native/i386-macosx/3m"
% mkdir -p compiled/native/i386-macosx/3m # move the extension library to a magic place
% mv example_wrap.dylib compiled/native/i386-macosx/3m/example_ss.dylib
% mzscheme
Welcome to MzScheme v4.2.4 [3m], Copyright (c) 2004-2010 PLT Scheme Inc.
> (require "example.ss")
> (fact 5)
120
> ^D
% echo 'It works!'

Some points of interest:

  • This is on a 64-bit machine, so we have to include the -m32 option when building the object file
  • If you want to declare a scheme module (and you probably do), it's important that you include the -declaremodule option to swig (if you miss this out, it'll appear to work, but fail later).
  • Use mzc to compile and then link the wrapped code. You'll probably need to adjust the link flags to refer to the library you're wrapping (you can either do this with an LDFLAGS declaration, as here, or with multiple ++ldf options to mzc).
  • Create the directory with path (build-path "compiled" "native" (system-library-subpath)) and move the freshly-generated .dylib to there, changing its name to module-name_ss.dylib. After that, you can REQUIRE the new module with (require "module-name.ss").
  • The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.

30.3 External documentation

See the C API for more description of using the mechanism for adding extensions. The main documentation is here.

Tip: mzc's --vv option is very useful for debugging the inevitable library problems you'll encounter.

swig-3.0.2/Doc/Manual/Scripting.html0000664000175000017500000003430712343706600017127 0ustar williamwilliam Scripting Languages

4 Scripting Languages

This chapter provides a brief overview of scripting language extension programming and the mechanisms by which scripting language interpreters access C and C++ code.

4.1 The two language view of the world

When a scripting language is used to control a C program, the resulting system tends to look as follows:

Scripting language input - C/C++ functions output

In this programming model, the scripting language interpreter is used for high level control whereas the underlying functionality of the C/C++ program is accessed through special scripting language "commands." If you have ever tried to write your own simple command interpreter, you might view the scripting language approach to be a highly advanced implementation of that. Likewise, If you have ever used a package such as MATLAB or IDL, it is a very similar model--the interpreter executes user commands and scripts. However, most of the underlying functionality is written in a low-level language like C or Fortran.

The two-language model of computing is extremely powerful because it exploits the strengths of each language. C/C++ can be used for maximal performance and complicated systems programming tasks. Scripting languages can be used for rapid prototyping, interactive debugging, scripting, and access to high-level data structures such associative arrays.

4.2 How does a scripting language talk to C?

Scripting languages are built around a parser that knows how to execute commands and scripts. Within this parser, there is a mechanism for executing commands and accessing variables. Normally, this is used to implement the builtin features of the language. However, by extending the interpreter, it is usually possible to add new commands and variables. To do this, most languages define a special API for adding new commands. Furthermore, a special foreign function interface defines how these new commands are supposed to hook into the interpreter.

Typically, when you add a new command to a scripting interpreter you need to do two things; first you need to write a special "wrapper" function that serves as the glue between the interpreter and the underlying C function. Then you need to give the interpreter information about the wrapper by providing details about the name of the function, arguments, and so forth. The next few sections illustrate the process.

4.2.1 Wrapper functions

Suppose you have an ordinary C function like this :

int fact(int n) {
	if (n <= 1) return 1;
	else return n*fact(n-1);
}

In order to access this function from a scripting language, it is necessary to write a special "wrapper" function that serves as the glue between the scripting language and the underlying C function. A wrapper function must do three things :

  • Gather function arguments and make sure they are valid.
  • Call the C function.
  • Convert the return value into a form recognized by the scripting language.

As an example, the Tcl wrapper function for the fact() function above example might look like the following :

int wrap_fact(ClientData clientData, Tcl_Interp *interp,
		int argc, char *argv[]) {
	int result;
	int arg0;
	if (argc != 2) {
		interp->result = "wrong # args";
		return TCL_ERROR;
	}
	arg0 = atoi(argv[1]);
	result = fact(arg0);
	sprintf(interp->result,"%d", result);
	return TCL_OK;
}

Once you have created a wrapper function, the final step is to tell the scripting language about the new function. This is usually done in an initialization function called by the language when the module is loaded. For example, adding the above function to the Tcl interpreter requires code like the following :

int Wrap_Init(Tcl_Interp *interp) {
	Tcl_CreateCommand(interp, "fact", wrap_fact, (ClientData) NULL,
				(Tcl_CmdDeleteProc *) NULL);
	return TCL_OK;
}

When executed, Tcl will now have a new command called "fact" that you can use like any other Tcl command.

Although the process of adding a new function to Tcl has been illustrated, the procedure is almost identical for Perl and Python. Both require special wrappers to be written and both need additional initialization code. Only the specific details are different.

4.2.2 Variable linking

Variable linking refers to the problem of mapping a C/C++ global variable to a variable in the scripting language interpreter. For example, suppose you had the following variable:

double Foo = 3.5;

It might be nice to access it from a script as follows (shown for Perl):

$a = $Foo * 2.3;   # Evaluation
$Foo = $a + 2.0;   # Assignment

To provide such access, variables are commonly manipulated using a pair of get/set functions. For example, whenever the value of a variable is read, a "get" function is invoked. Similarly, whenever the value of a variable is changed, a "set" function is called.

In many languages, calls to the get/set functions can be attached to evaluation and assignment operators. Therefore, evaluating a variable such as $Foo might implicitly call the get function. Similarly, typing $Foo = 4 would call the underlying set function to change the value.

4.2.3 Constants

In many cases, a C program or library may define a large collection of constants. For example:

#define RED   0xff0000
#define BLUE  0x0000ff
#define GREEN 0x00ff00

To make constants available, their values can be stored in scripting language variables such as $RED, $BLUE, and $GREEN. Virtually all scripting languages provide C functions for creating variables so installing constants is usually a trivial exercise.

4.2.4 Structures and classes

Although scripting languages have no trouble accessing simple functions and variables, accessing C/C++ structures and classes present a different problem. This is because the implementation of structures is largely related to the problem of data representation and layout. Furthermore, certain language features are difficult to map to an interpreter. For instance, what does C++ inheritance mean in a Perl interface?

The most straightforward technique for handling structures is to implement a collection of accessor functions that hide the underlying representation of a structure. For example,

struct Vector {
	Vector();
	~Vector();
	double x,y,z;
};

can be transformed into the following set of functions :

Vector *new_Vector();
void delete_Vector(Vector *v);
double Vector_x_get(Vector *v);
double Vector_y_get(Vector *v);
double Vector_z_get(Vector *v);
void Vector_x_set(Vector *v, double x);
void Vector_y_set(Vector *v, double y);
void Vector_z_set(Vector *v, double z);

Now, from an interpreter these function might be used as follows:

% set v [new_Vector]
% Vector_x_set $v 3.5
% Vector_y_get $v
% delete_Vector $v
% ...

Since accessor functions provide a mechanism for accessing the internals of an object, the interpreter does not need to know anything about the actual representation of a Vector.

4.2.5 Proxy classes

In certain cases, it is possible to use the low-level accessor functions to create a proxy class, also known as a shadow class. A proxy class is a special kind of object that gets created in a scripting language to access a C/C++ class (or struct) in a way that looks like the original structure (that is, it proxies the real C++ class). For example, if you have the following C++ definition :

class Vector {
public:
	Vector();
	~Vector();
	double x,y,z;
};

A proxy classing mechanism would allow you to access the structure in a more natural manner from the interpreter. For example, in Python, you might want to do this:

>>> v = Vector()
>>> v.x = 3
>>> v.y = 4
>>> v.z = -13
>>> ...
>>> del v

Similarly, in Perl5 you may want the interface to work like this:

$v = new Vector;
$v->{x} = 3;
$v->{y} = 4;
$v->{z} = -13;

Finally, in Tcl :

Vector v
v configure -x 3 -y 4 -z -13

When proxy classes are used, two objects are really at work--one in the scripting language, and an underlying C/C++ object. Operations affect both objects equally and for all practical purposes, it appears as if you are simply manipulating a C/C++ object.

4.3 Building scripting language extensions

The final step in using a scripting language with your C/C++ application is adding your extensions to the scripting language itself. There are two primary approaches for doing this. The preferred technique is to build a dynamically loadable extension in the form of a shared library. Alternatively, you can recompile the scripting language interpreter with your extensions added to it.

4.3.1 Shared libraries and dynamic loading

To create a shared library or DLL, you often need to look at the manual pages for your compiler and linker. However, the procedure for a few common platforms is shown below:

# Build a shared library for Solaris
gcc -fpic -c example.c example_wrap.c -I/usr/local/include
ld -G example.o example_wrap.o -o example.so

# Build a shared library for Linux
gcc -fpic -c example.c example_wrap.c -I/usr/local/include
gcc -shared example.o example_wrap.o -o example.so

To use your shared library, you simply use the corresponding command in the scripting language (load, import, use, etc...). This will import your module and allow you to start using it. For example:

% load ./example.so
% fact 4
24
%

When working with C++ codes, the process of building shared libraries may be more complicated--primarily due to the fact that C++ modules may need additional code in order to operate correctly. On many machines, you can build a shared C++ module by following the above procedures, but changing the link line to the following :

c++ -shared example.o example_wrap.o -o example.so

4.3.2 Linking with shared libraries

When building extensions as shared libraries, it is not uncommon for your extension to rely upon other shared libraries on your machine. In order for the extension to work, it needs to be able to find all of these libraries at run-time. Otherwise, you may get an error such as the following :

>>> import graph
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/home/sci/data1/beazley/graph/graph.py", line 2, in ?
    import graphc
ImportError:  1101:/home/sci/data1/beazley/bin/python: rld: Fatal Error: cannot 
successfully map soname 'libgraph.so' under any of the filenames /usr/lib/libgraph.so:/
lib/libgraph.so:/lib/cmplrs/cc/libgraph.so:/usr/lib/cmplrs/cc/libgraph.so:
>>>

What this error means is that the extension module created by SWIG depends upon a shared library called "libgraph.so" that the system was unable to locate. To fix this problem, there are a few approaches you can take.

  • Link your extension and explicitly tell the linker where the required libraries are located. Often times, this can be done with a special linker flag such as -R, -rpath, etc. This is not implemented in a standard manner so read the man pages for your linker to find out more about how to set the search path for shared libraries.
  • Put shared libraries in the same directory as the executable. This technique is sometimes required for correct operation on non-Unix platforms.
  • Set the UNIX environment variable LD_LIBRARY_PATH to the directory where shared libraries are located before running Python. Although this is an easy solution, it is not recommended. Consider setting the path using linker options instead.

4.3.3 Static linking

With static linking, you rebuild the scripting language interpreter with extensions. The process usually involves compiling a short main program that adds your customized commands to the language and starts the interpreter. You then link your program with a library to produce a new scripting language executable.

Although static linking is supported on all platforms, this is not the preferred technique for building scripting language extensions. In fact, there are very few practical reasons for doing this--consider using shared libraries instead.

swig-3.0.2/Doc/Manual/Php.html0000664000175000017500000010305412343706602015712 0ustar williamwilliam SWIG and PHP

34 SWIG and PHP

SWIG supports generating wrappers for PHP5. Support for PHP4 was removed in SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases, and won't even be patching critical security issues after 2008-08-08, so it doesn't make much sense for SWIG to continue to support PHP4 now. If you really need to continue to use PHP4, just stick with SWIG 1.3.36.

Currently any PHP5 release should work, but we don't regularly test with PHP < 5.3.

In this chapter, we discuss SWIG's support of PHP. The PHP module was extensively rewritten in release 1.3.26, and support for generating OO wrappers for PHP5 was added in 1.3.30. The PHP module now supports most of the features available in some of the other languages.

In order to use this module, you will need to have a copy of the PHP5 include files to compile the SWIG generated files. If you installed PHP from a binary package, you may need to install a "php-dev" or "php-devel" 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 will need either the php binary or the Apache php module. If you want to build your extension into php directly, you will need the complete PHP source tree available.

34.1 Generating PHP Extensions

To build a PHP extension, run swig using the -php option as follows:

swig -php example.i

This will produce 3 files example_wrap.c, php_example.h and example.php. The first file, example_wrap.c contains all of the C code needed to build a PHP extension. The second file, php_example.h contains the header information needed if you wish to statically link the extension into the php interpreter. The third file, example.php can be included by PHP scripts. It attempts to dynamically load the extension and contains extra php code specified in the interface file. If wrapping C++ code with PHP classes, it will also contain PHP5 class wrappers.

SWIG can generate PHP extensions from C++ libraries as well when given the -c++ option. The support for C++ is discussed in more detail in section 27.2.6.

The usual (and recommended) way is to build the extension as a separate dynamically loaded module (which is supported by all modern operating systems). You can then specify that this be loaded automatically in php.ini or load it explicitly for any script which needs it.

It is also possible to rebuild PHP from source so that your module is statically linked into the php executable/library. This is a lot more work, and also requires a full rebuild of PHP to update your module, and it doesn't play nicely with package system. We don't recommend this approach, or provide explicit support for it.

34.1.1 Building a loadable extension

To build your module as a dynamically loadable extension, use compilation commands like these (if you aren't using GCC, the commands will be different, and there may be some variation between platforms - these commands should at least work for Linux though):

	gcc `php-config --includes` -fpic -c example_wrap.c
	gcc -shared example_wrap.o -o example.so

34.1.2 Using PHP Extensions

To test the extension from a PHP script, you need to load it first. You can load it for every script by adding this line to the [PHP] section of php.ini:

	extension=/path/to/modulename.so

Alternatively, you can load it explicitly only for scripts which need it by adding this line to the start of each such PHP script::

	dl("/path/to/modulename.so");	// Load the module

SWIG also generates a php module, which attempts to do the dl() call for you:

	include("example.php");

34.2 Basic PHP interface

It is important to understand that PHP uses a single global namespace into which all symbols from extension modules are loaded. It is quite possible for names of symbols in one extension module to clash with other symbols unless care is taken to %rename them. At present SWIG doesn't have support for the namespace feature added in PHP 5.3.

34.2.1 Constants

These work in much the same way as in C/C++. Constants can be defined by using either the normal C pre-processor declarations, or the %constant SWIG directive. These will then be available from your PHP script as a PHP constant, (i.e. no dollar sign is needed to access them.) For example, with a swig interface file like this,

%module example

#define PI 3.14159

%constant int E  = 2.71828

you can access the constants in your PHP script like this,

include("example.php");

echo "PI = " . PI . "\n";

echo "E = " . E . "\n";

There's one peculiarity of how constants work in PHP which it is useful to note (this is not specific to SWIG though) - if you try to use an undeclared constant, PHP will issue a warning and then expand the constant to a string version of the constant's name. The warning will often be missed though as if you're using PHP in a webserver, it will probably end up in error.log or similar.

For example,

%module example

#define EASY_TO_MISPELL	0

accessed incorrectly in PHP,

include("example.php");

if(EASY_TO_MISPEL) {
	....
} else {
	....
}

The mis-spelled constant will become the string 'EASY_TO_MISPEL', which is treated as true by the if test, when the value of the intended constant would be treated as false!

34.2.2 Global Variables

Because PHP does not provide a mechanism to intercept access and assignment of global variables, global variables are supported through the use of automatically generated accessor functions.

%module example;

%inline %{
  double seki = 2;
  void print_seki() {
    zend_printf("seki is now %f\n",seki);
  }
%}

is accessed as follows:

include("example.php");
print seki_get();
seki_set( seki_get() * 2);	# The C variable is now 4.
print seki_get();

SWIG supports global variables of all C datatypes including pointers and complex objects. Additional types can be supported by using the varinit typemap.

SWIG honors the %immutable modifier by not generating code for the _set method. This provides read-only access to the variable from the php script. Attempting to access the _set method will result in a php fatal error because the function is undefined.

At this time SWIG does not support custom accessor methods.

34.2.3 Functions

C functions are converted into PHP functions. Default/optional arguments are also allowed. An interface file like this :

%module example
int foo(int a);
double bar(double, double b = 3.0);
...

Will be accessed in PHP like this :

include("example.php");
$a = foo(2);
$b = bar(3.5, -1.5);
$c = bar(3.5);		# Use default argument for 2nd parameter

34.2.4 Overloading

Although PHP does not support overloading functions natively, swig will generate dispatch functions which will use %typecheck typemaps to allow overloading. This dispatch function's operation and precedence is described in Wrapping Overloaded Functions and Methods.

34.2.5 Pointers and References

Pointers to C/C++ objects are represented as PHP resources, rather like MySQL connection handles.

There are multiple ways to wrap pointers to simple types. Given the following C method:

  void add( int *in1, int *in2, int *result);

One can include cpointer.i to generate PHP wrappers to int *.

%module example
%include "cpointer.i"
%pointer_functions(int,intp)

void add( int *in1, int *in2, int *result);

This will result in the following usage in PHP:

<?php

include("example.php");

$in1=copy_intp(3);
$in2=copy_intp(5);
$result=new_intp();

add( $in1, $in2, $result );

echo "The sum " . intp_value($in1) . " + " . intp_value($in2) . " = " . intp_value( $result) . "\n";
?>

An alternative would be to use the include typemaps.i which defines named typemaps for INPUT, OUTPUT and INOUT variables. One needs to either %apply the appropriate typemap or adjust the parameter names as appropriate.

%module example
%include "typemaps.i"

void add( int *INPUT, int *INPUT, int *OUTPUT);

This will result in the following usage in PHP:

<?php

include("example.php");

$in1 = 3;
$in2 = 5;
$result= add($in1,$in2);  # Note using variables for the input is unnecessary.

echo "The sum $in1 + $in2 = $result\n";
?>

Because PHP has a native concept of reference, it may seem more natural to the PHP developer to use references to pass pointers. To enable this, one needs to include phppointers.i which defines the named typemap REF.

Prior to SWIG 3.0, the REF typemaps relied on PHP's call-time pass-by-reference, which was deprecated in PHP 5.3 and removed in PHP 5.4. So if you use these REF typemaps, you should ensure that SWIG≥3.0 is used to generate wrappers from your interface file.

In case you write your own typemaps, SWIG supports an attribute called byref: if you set that, then SWIG will make sure that the generated wrapper function will want the input parameter as a reference.

%module example
%include "phppointers.i"

void add( int *REF, int *REF, int *REF);

This will result in the following usage in PHP:

<?php

include("example.php");

$in1 = 3;
$in2 = 5;
$result = 0;
add($in1,$in2,$result);

echo "The sum $in1 + $in2 = $result\n";
?>

It is important to note that a php variable which is NULL when passed by reference would end up passing a NULL pointer into the function. In PHP, an unassigned variable (i.e. where the first reference to the variable is not an assignment) is NULL. In the above example, if any of the three variables had not been assigned, a NULL pointer would have been passed into add. Depending on the implementation of the function, this may or may not be a good thing.

We chose to allow passing NULL pointers into functions because that is sometimes required in C libraries. A NULL pointer can be created in PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

34.2.6 Structures and C++ classes

SWIG defaults to wrapping C++ structs and classes with PHP classes - this is done by generating a PHP wrapper script which defines proxy classes which calls a set of flat functions which actually wrap the C++ class. You can disable this wrapper layer by passing the command-line option "-noproxy" in which case you'll just get the flat functions.

This interface file

%module vector

class Vector {
public:
	double x,y,z;
	Vector();
	~Vector();
	double magnitude();
};

struct Complex {
 double re, im;
};

Would be used in the following way from PHP5:

<?php
  require "vector.php";

  $v = new Vector();
  $v->x = 3;
  $v->y = 4;
  $v->z = 5;

  echo "Magnitude of ($v->x,$v->y,$v->z) = " . $v->magnitude() . "\n";

  $v = NULL;   # destructor called.

  $c = new Complex();

  $c->re = 0;
  $c->im = 0;

  # $c destructor called when $c goes out of scope.
?>

Member variables and methods are accessed using the -> operator.

34.2.6.1 Using -noproxy

The -noproxy option flattens the object structure and generates collections of named functions (these are the functions which the PHP5 class wrappers call). The above example results in the following PHP functions:

new_Vector();
Vector_x_set($obj,$d);
Vector_x_get($obj);
Vector_y_set($obj,$d);
Vector_y_get($obj);
Vector_z_set($obj,$d);
Vector_z_get($obj);
Vector_magnitude($obj);
new_Complex();
Complex_re_set($obj,$d);
Complex_re_get($obj);
Complex_im_set($obj,$d);
Complex_im_get($obj);

34.2.6.2 Constructors and Destructors

The constructor is called when new Object() (or new_Object() if using -noproxy) is used to create an instance of the object. If multiple constructors are defined for an object, function overloading will be used to determine which constructor to execute.

Because PHP uses reference counting to manage resources, simple assignment of one variable to another such as:

$ref = $v;

causes the symbol $ref to refer to the same underlying object as $v. This does not result in a call to the C++ copy constructor or copy assignment operator.

One can force execution of the copy constructor by using:

$o_copy = new Object($o);

Destructors are automatically called when all variables referencing the instance are reassigned or go out of scope. The destructor is not available to be called manually. To force a destructor to be called the programmer can either reassign the variable or call unset($v)

34.2.6.3 Static Member Variables

Static member variables in C++ are not wrapped as such in PHP as it does not appear to be possible to intercept accesses to such variables. Therefore, static member variables are wrapped using a class function with the same name, which returns the current value of the class variable. For example

%module example

class Ko {
	static int threats;
};

would be accessed in PHP as,

include("example.php");

echo "There have now been " . Ko::threats() . " threats\n";

To set the static member variable, pass the value as the argument to the class function, e.g.


Ko::threats(10);

echo "There have now been " . Ko::threats() . " threats\n";

34.2.6.4 Static Member Functions

Static member functions are supported in PHP using the class::function() syntax. For example

%module example
class Ko {
  static void threats();
};
would be executed in PHP as,
include("example.php");
Ko::threats();

34.2.7 PHP Pragmas, Startup and Shutdown code

To place PHP code in the generated "example.php" file one can use the code pragma. The code is inserted after loading the shared object.

%module example
%pragma(php) code="
# This code is inserted into example.php
echo \"example.php execution\\n\";
"

Results in the following in "example.php"

# This code is inserted into example.php
echo "example.php execution\n";

The include pragma is a short cut to add include statements to the example.php file.

%module example
%pragma(php) code="
include \"include.php\";
"
%pragma(php) include="include.php"   // equivalent.

The phpinfo pragma inserts code in the PHP_MINFO_FUNCTION which is called from PHP's phpinfo() function.

%module example;
%pragma(php) phpinfo="
  zend_printf("An example of PHP support through SWIG\n");
  php_info_print_table_start();
  php_info_print_table_header(2, \"Directive\", \"Value\");
  php_info_print_table_row(2, \"Example support\", \"enabled\");
  php_info_print_table_end();
"

To insert code into the PHP_MINIT_FUNCTION, one can use either %init or %minit.

%module example;
%init {
  zend_printf("Inserted into PHP_MINIT_FUNCTION\n");
}
%minit {
  zend_printf("Inserted into PHP_MINIT_FUNCTION\n");
}

To insert code into the PHP_MSHUTDOWN_FUNCTION, one can use either %shutdown or %mshutdown.

%module example;
%mshutdown {
  zend_printf("Inserted into PHP_MSHUTDOWN_FUNCTION\n");
}

The %rinit and %rshutdown statements are very similar but insert code into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.

34.3 Cross language polymorphism

Proxy classes provide a more natural, object-oriented way to access extension classes. As described above, each proxy instance has an associated C++ instance, and method calls to the proxy are passed to the C++ instance transparently via C wrapper functions.

This arrangement is asymmetric in the sense that no corresponding mechanism exists to pass method calls down the inheritance chain from C++ to PHP. In particular, if a C++ class has been extended in PHP (by extending the proxy class), these extensions will not be visible from C++ code. Virtual method calls from C++ are thus not able access the lowest implementation in the inheritance chain.

Changes have been made to SWIG 1.3.18 to address this problem and make the relationship between C++ classes and proxy classes more symmetric. To achieve this goal, new classes called directors are introduced at the bottom of the C++ inheritance chain. Support for generating PHP classes has been added in SWIG 1.3.40. The job of the directors is to route method calls correctly, either to C++ implementations higher in the inheritance chain or to PHP implementations lower in the inheritance chain. The upshot is that C++ classes can be extended in PHP and from C++ these extensions look exactly like native C++ classes. Neither C++ code nor PHP code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

34.3.1 Enabling directors

The director feature is disabled by default. To use directors you must make two changes to the interface file. First, add the "directors" option to the %module directive, like this:

%module(directors="1") modulename

Without this option no director code will be generated. Second, you must use the %feature("director") directive to tell SWIG which classes and methods should get directors. The %feature directive can be applied globally, to specific classes, and to specific methods, like this:

// generate directors for all classes that have virtual methods
%feature("director");         

// generate directors for all virtual methods in class Foo
%feature("director") Foo;      

You can use the %feature("nodirector") directive to turn off directors for specific classes or methods. So for example,

%feature("director") Foo;
%feature("nodirector") Foo::bar;

will generate directors for all virtual methods of class Foo except bar().

Directors can also be generated implicitly through inheritance. In the following, class Bar will get a director class that handles the methods one() and two() (but not three()):

%feature("director") Foo;
class Foo {
public:
    Foo(int foo);
    virtual void one();
    virtual void two();
};

class Bar: public Foo {
public:
    virtual void three();
};

then at the PHP side you can define

require("mymodule.php");

class MyFoo extends Foo {
  function one() {
     print "one from php\n";
  }
}

34.3.2 Director classes

For each class that has directors enabled, SWIG generates a new class that derives from both the class in question and a special Swig::Director class. These new classes, referred to as director classes, can be loosely thought of as the C++ equivalent of the PHP proxy classes. The director classes store a pointer to their underlying PHP object. Indeed, this is quite similar to the "_cPtr" and "thisown" members of the PHP proxy classes.

For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). Thus all virtual method calls, whether they originate in C++ or in PHP via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate place" we mean the method that would have been called if the C++ base class and its extensions in PHP were seamlessly integrated. That seamless integration is exactly what the director classes provide, transparently skipping over all the messy extension API glue that binds the two languages together.

In reality, the "appropriate place" is one of only two possibilities: C++ or PHP. Once this decision is made, the rest is fairly easy. If the correct implementation is in C++, then the lowest implementation of the method in the C++ inheritance chain is called explicitly. If the correct implementation is in PHP, the Zend API is used to call the method of the underlying PHP object (after which the usual virtual method resolution in PHP automatically finds the right implementation).

Now how does the director decide which language should handle the method call? The basic rule is to handle the method in PHP, unless there's a good reason not to. The reason for this is simple: PHP has the most "extended" implementation of the method. This assertion is guaranteed, since at a minimum the PHP proxy class implements the method. If the method in question has been extended by a class derived from the proxy class, that extended implementation will execute exactly as it should. If not, the proxy class will route the method call into a C wrapper function, expecting that the method will be resolved in C++. The wrapper will call the virtual method of the C++ instance, and since the director extends this the call will end up right back in the director method. Now comes the "good reason not to" part. If the director method were to blindly call the PHP method again, it would get stuck in an infinite loop. We avoid this situation by adding special code to the C wrapper function that tells the director method to not do this. The C wrapper function compares the called and the declaring class name of the given method. If these are not the same, then the C wrapper function tells the director to resolve the method by calling up the C++ inheritance chain, preventing an infinite loop.

One more point needs to be made about the relationship between director classes and proxy classes. When a proxy class instance is created in PHP, SWIG creates an instance of the original C++ class and assigns it to ->_cPtr. This is exactly what happens without directors and is true even if directors are enabled for the particular class in question. When a class derived from a proxy class is created, however, SWIG then creates an instance of the corresponding C++ director class. The reason for this difference is that user-defined subclasses may override or extend methods of the original class, so the director class is needed to route calls to these methods correctly. For unmodified proxy classes, all methods are ultimately implemented in C++ so there is no need for the extra overhead involved with routing the calls through PHP.

34.3.3 Ownership and object destruction

Memory management issues are slightly more complicated with directors than for proxy classes alone. PHP instances hold a pointer to the associated C++ director object, and the director in turn holds a pointer back to the PHP object. By default, proxy classes own their C++ director object and take care of deleting it when they are garbage collected.

This relationship can be reversed by calling the special ->thisown property of the proxy class. After setting this property to 0, the director class no longer destroys the PHP object. Assuming no outstanding references to the PHP object remain, the PHP object will be destroyed at the same time. This is a good thing, since directors and proxies refer to each other and so must be created and destroyed together. Destroying one without destroying the other will likely cause your program to segfault.

Here is an example:

class Foo {
public:
    ...
};
class FooContainer {
public:
    void addFoo(Foo *);
    ...
};

$c = new FooContainer();
$a = new Foo();
$a->thisown = 0;
$c->addFoo($a);

In this example, we are assuming that FooContainer will take care of deleting all the Foo pointers it contains at some point.

34.3.4 Exception unrolling

With directors routing method calls to PHP, and proxies routing them to C++, the handling of exceptions is an important concern. By default, the directors ignore exceptions that occur during method calls that are resolved in PHP. To handle such exceptions correctly, it is necessary to temporarily translate them into C++ exceptions. This can be done with the %feature("director:except") directive. The following code should suffice in most cases:

%feature("director:except") {
    if ($error == FAILURE) {
        throw Swig::DirectorMethodException();
    }
}

This code will check the PHP error state after each method call from a director into PHP, and throw a C++ exception if an error occurred. This exception can be caught in C++ to implement an error handler. Currently no information about the PHP error is stored in the Swig::DirectorMethodException object, but this will likely change in the future.

It may be the case that a method call originates in PHP, travels up to C++ through a proxy class, and then back into PHP via a director method. If an exception occurs in PHP at this point, it would be nice for that exception to find its way back to the original caller. This can be done by combining a normal %exception directive with the director:except handler shown above. Here is an example of a suitable exception handler:

%exception {
    try { $action }
    catch (Swig::DirectorException &e) { SWIG_fail; }
}

The class Swig::DirectorException used in this example is actually a base class of Swig::DirectorMethodException, so it will trap this exception. Because the PHP error state is still set when Swig::DirectorMethodException is thrown, PHP will register the exception as soon as the C wrapper function returns.

34.3.5 Overhead and code bloat

Enabling directors for a class will generate a new director method for every virtual method in the class' inheritance chain. This alone can generate a lot of code bloat for large hierarchies. Method arguments that require complex conversions to and from target language types can result in large director methods. For this reason it is recommended that you selectively enable directors only for specific classes that are likely to be extended in PHP and used in C++.

Compared to classes that do not use directors, the call routing in the director methods does add some overhead. In particular, at least one dynamic cast and one extra function call occurs per method call from PHP. Relative to the speed of PHP execution this is probably completely negligible. For worst case routing, a method call that ultimately resolves in C++ may take one extra detour through PHP in order to ensure that the method does not have an extended PHP implementation. This could result in a noticeable overhead in some cases.

Although directors make it natural to mix native C++ objects with PHP objects (as director objects) via a common base class pointer, one should be aware of the obvious fact that method calls to PHP objects will be much slower than calls to C++ objects. This situation can be optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in PHP.

34.3.6 Typemaps

Typemaps for input and output of most of the basic types from director classes have been written. These are roughly the reverse of the usual input and output typemaps used by the wrapper code. The typemap operation names are 'directorin', 'directorout', and 'directorargout'. The director code does not currently use any of the other kinds of typemaps. It is not clear at this point which kinds are appropriate and need to be supported.

34.3.7 Miscellaneous

Director typemaps for STL classes are mostly in place, and hence you should be able to use std::string, etc., as you would any other type.

swig-3.0.2/Doc/Manual/README0000664000175000017500000000152212343605122015145 0ustar williamwilliamThis directory contains the HTML for the SWIG users manual. All of this HTML is hand-written. However, section numbering, indices, and the table of contents are generated automatically by the 'maketoc.py' script. The Makefile has further information on how the various alternative forms of the documentation are generated from the hand-written HTML. There are 4 types of boxes that code or whatever can be inside: -
...
This is for text that shows the output of running commands on the shell. -
...
This is for either C, C++, or SWIG code -
...
This is for code in a target scripting language -
...
This is for text that is not code or a shell The general format is
whatever here
swig-3.0.2/Doc/Manual/R.html0000664000175000017500000001070512343706602015364 0ustar williamwilliam SWIG and R

37 SWIG and R

R is a GPL'ed open source statistical and plotting environment. Information about R can be found at www.r-project.org. The R bindings are under active development. They have been used to compile and run an R interface to QuantLib running on Mandriva Linux with gcc. The R bindings also work on Microsoft Windows using Visual C++.

37.1 Bugs

Currently the following features are not implemented or broken:

  • Garbage collection of created objects
  • C Array wrappings

37.2 Using R and SWIG

To use R and SWIG in C mode, execute the following commands where example.c is the name of the file with the functions in them

swig -r example.i
R CMD SHLIB example_wrap.c example.c

The corresponding options for C++ mode are

swig -c++ -r -o example_wrap.cpp example.i
R CMD SHLIB example_wrap.cpp example.cpp

Note that R is sensitive to the names of the files. The name of the wrapper file must be the name of the library unless you use the -o option to R when building the library, for example:

swig -c++ -r -o example_wrap.cpp example.i
R CMD SHLIB -o example.so example_wrap.cpp example.cpp

R is also sensitive to the name of the file extension in C and C++ mode. In C++ mode, the file extension must be .cpp rather than .cxx for the R compile command to recognize it. If your C++ code is in a file using something other than a .cpp extension, then it may still work using PKG_LIBS:

swig -c++ -r -o example_wrap.cpp example.i
PKG_LIBS="example.cxx" R CMD SHLIB -o example example_wrap.cpp

The commands produces two files. A dynamic shared object file called example.so, or example.dll, and an R wrapper file called example.R. To load these files, start up R and type in the following commands

dyn.load(paste("example", .Platform$dynlib.ext, sep=""))
source("example.R")
cacheMetaData(1)
The cacheMetaData(1) will cause R to refresh its object tables. Without it, inheritance of wrapped objects may fail.

These two files can be loaded in any order

37.3 Precompiling large R files

In cases where the R file is large, one make save a lot of loading time by precompiling the R wrapper. This can be done by creating the file makeRData.R which contains the following
source('BigFile.R')
save(list=ls(all=TRUE),file="BigFile.RData", compress=TRUE)
q(save="no")
This will generate a compiled R file called BigFile.RData that will save a large amount of loading time.

37.4 General policy

The general policy of the module is to treat the C/C++ as a basic wrapping over the underlying functions and rely on the R type system to provide R syntax.

37.5 Language conventions

getitem and setitem use C++ conventions (i.e. zero based indices). [<- and [ are overloaded to allow for R syntax (one based indices and slices)

37.6 C++ classes

C++ objects are implemented as external pointer objects with the class being the mangled name of the class. The C++ classes are encapsulated as an SEXP with an external pointer type. The class is the mangled name of the class. The nice thing about R is that is allows you to keep track of the pointer object which removes the necessity for a lot of the proxy class baggage you see in other languages.

37.7 Enumerations

enumerations are characters which are then converted back and forth to ints before calling the C routines. All of the enumeration code is done in R.

swig-3.0.2/Doc/Manual/linkchecker.config0000664000175000017500000000010412343605122017731 0ustar williamwilliam[checking] anchors=1 [filtering] ignorewarnings=http-robots-denied swig-3.0.2/Doc/Manual/maketoc.py0000664000175000017500000000110312343605122016255 0ustar williamwilliam#!/usr/bin/env python import sys import os chs = open("chapters").readlines() f = open("Contents.html","w") print >>f, """ SWIG Users Manual

SWIG Users Manual

""" f.close() num = 1 for c in chs: c = c.strip() print "Processing %s" % c if c: os.system("python makechap.py %s %d >> Contents.html" % (c,num)) num += 1 f = open("Contents.html","a") print >>f, """ """ swig-3.0.2/Doc/Manual/Contract.html0000664000175000017500000001447312343706601016745 0ustar williamwilliam Contract Checking

13 Contracts

A common problem that arises when wrapping C libraries is that of maintaining reliability and checking for errors. The fact of the matter is that many C programs are notorious for not providing error checks. Not only that, when you expose the internals of an application as a library, it often becomes possible to crash it simply by providing bad inputs or using it in a way that wasn't intended.

This chapter describes SWIG's support for software contracts. In the context of SWIG, a contract can be viewed as a runtime constraint that is attached to a declaration. For example, you can easily attach argument checking rules, check the output values of a function and more. When one of the rules is violated by a script, a runtime exception is generated rather than having the program continue to execute.

13.1 The %contract directive

Contracts are added to a declaration using the %contract directive. Here is a simple example:

%contract sqrt(double x) {
require:
    x >= 0;
ensure:
    sqrt >= 0;
}

...
double sqrt(double);

In this case, a contract is being added to the sqrt() function. The %contract directive must always appear before the declaration in question. Within the contract there are two sections, both of which are optional. The require: section specifies conditions that must hold before the function is called. Typically, this is used to check argument values. The ensure: section specifies conditions that must hold after the function is called. This is often used to check return values or the state of the program. In both cases, the conditions that must hold must be specified as boolean expressions.

In the above example, we're simply making sure that sqrt() returns a non-negative number (if it didn't, then it would be broken in some way).

Once a contract has been specified, it modifies the behavior of the resulting module. For example:

>>> example.sqrt(2)
1.4142135623730951
>>> example.sqrt(-2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
RuntimeError: Contract violation: require: (arg1>=0)
>>>

13.2 %contract and classes

The %contract directive can also be applied to class methods and constructors. For example:

%contract Foo::bar(int x, int y) {
require:
   x > 0;
ensure:
   bar > 0;
}

%contract Foo::Foo(int a) {
require:
   a > 0;
}

class Foo {
public:
    Foo(int);
    int bar(int, int);
};

The way in which %contract is applied is exactly the same as the %feature directive. Thus, any contract that you specified for a base class will also be attached to inherited methods. For example:

class Spam : public Foo {
public:
   int bar(int,int);    // Gets contract defined for Foo::bar(int,int)
};

In addition to this, separate contracts can be applied to both the base class and a derived class. For example:

%contract Foo::bar(int x, int) {
require:
    x > 0;
}

%contract Spam::bar(int, int y) {
require:
    y > 0;
}

class Foo {
public:
    int bar(int,int);   // Gets Foo::bar contract.
};

class Spam : public Foo {
public:
     int bar(int,int);   // Gets Foo::bar and Spam::bar contract
};

When more than one contract is applied, the conditions specified in a "require:" section are combined together using a logical-AND operation. In other words conditions specified for the base class and conditions specified for the derived class all must hold. In the above example, this means that both the arguments to Spam::bar must be positive.

13.3 Constant aggregation and %aggregate_check

Consider an interface file that contains the following code:

#define  UP     1
#define  DOWN   2
#define  RIGHT  3
#define  LEFT   4

void move(SomeObject *, int direction, int distance);

One thing you might want to do is impose a constraint on the direction parameter to make sure it's one of a few accepted values. To do that, SWIG provides an easy to use macro %aggregate_check() that works like this:

%aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT);

This merely defines a utility function of the form

int check_direction(int x);

That checks the argument x to see if it is one of the values listed. This utility function can be used in contracts. For example:

%aggregate_check(int, check_direction, UP, DOWN, RIGHT, LEFT);

%contract move(SomeObject *, int direction, in) {
require:
     check_direction(direction);
}

#define  UP     1
#define  DOWN   2
#define  RIGHT  3
#define  LEFT   4

void move(SomeObject *, int direction, int distance);

Alternatively, it can be used in typemaps and other directives. For example:

%aggregate_check(int, check_direction, UP, DOWN, RIGHT, LEFT);

%typemap(check) int direction {
    if (!check_direction($1)) SWIG_exception(SWIG_ValueError, "Bad direction");
}

#define  UP     1
#define  DOWN   2
#define  RIGHT  3
#define  LEFT   4

void move(SomeObject *, int direction, int distance);

Regrettably, there is no automatic way to perform similar checks with enums values. Maybe in a future release.

13.4 Notes

Contract support was implemented by Songyan (Tiger) Feng and first appeared in SWIG-1.3.20.

swig-3.0.2/Doc/Manual/Pike.html0000664000175000017500000001407212343706602016054 0ustar williamwilliam SWIG and Pike

35 SWIG and Pike

This chapter describes SWIG support for Pike. As of this writing, the SWIG Pike module is still under development and is not considered ready for prime time. The Pike module is being developed against the Pike 7.4.10 release and may not be compatible with previous versions of Pike.

This chapter covers most SWIG features, but certain low-level details are covered in less depth than in earlier chapters. At the very least, make sure you read the "SWIG Basics" chapter.

35.1 Preliminaries

35.1.1 Running SWIG

Suppose that you defined a SWIG module such as the following:

%module example

%{
#include "example.h"
%}

int fact(int n);

To build a C extension module for Pike, run SWIG using the -pike option :

$ swig -pike example.i

If you're building a C++ extension, be sure to add the -c++ option:

$ swig -c++ -pike example.i

This creates a single source file named example_wrap.c (or example_wrap.cxx, if you ran SWIG with the -c++ option). The SWIG-generated source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.

The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option:

$ swig -pike -o pseudonym.c example.i

35.1.2 Getting the right header files

In order to compile the C/C++ wrappers, the compiler needs to know the path to the Pike header files. These files are usually contained in a directory such as

/usr/local/pike/7.4.10/include/pike

There doesn't seem to be any way to get Pike itself to reveal the location of these files, so you may need to hunt around for them. You're looking for files with the names global.h, program.h and so on.

35.1.3 Using your module

To use your module, simply use Pike's import statement:

$ pike
Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend)
> import example;
> fact(4);
(1) Result: 24

35.2 Basic C/C++ Mapping

35.2.1 Modules

All of the code for a given SWIG module is wrapped into a single Pike module. Since the name of the shared library that implements your module ultimately determines the module's name (as far as Pike is concerned), SWIG's %module directive doesn't really have any significance.

35.2.2 Functions

Global functions are wrapped as new Pike built-in functions. For example,

%module example

int fact(int n);

creates a new built-in function example.fact(n) that works exactly as you'd expect it to:

> import example;
> fact(4);
(1) Result: 24

35.2.3 Global variables

Global variables are currently wrapped as a pair of functions, one to get the current value of the variable and another to set it. For example, the declaration

%module example

double Foo;

will result in two functions, Foo_get() and Foo_set():

> import example;
> Foo_get();
(1) Result: 3.000000
> Foo_set(3.14159);
(2) Result: 0
> Foo_get();
(3) Result: 3.141590

35.2.4 Constants and enumerated types

Enumerated types in C/C++ declarations are wrapped as Pike constants, not as Pike enums.

35.2.5 Constructors and Destructors

Constructors are wrapped as create() methods, and destructors are wrapped as destroy() methods, for Pike classes.

35.2.6 Static Members

Since Pike doesn't support static methods or data for Pike classes, static member functions in your C++ classes are wrapped as regular functions and static member variables are wrapped as pairs of functions (one to get the value of the static member variable, and another to set it). The names of these functions are prepended with the name of the class. For example, given this C++ class declaration:

class Shape
{
public:
    static void print();
    static int nshapes;
};

SWIG will generate a Shape_print() method that invokes the static Shape::print() member function, as well as a pair of methods, Shape_nshapes_get() and Shape_nshapes_set(), to get and set the value of Shape::nshapes.

swig-3.0.2/Doc/Manual/fixstyle.py0000664000175000017500000000072612343605122016513 0ustar williamwilliam#!/usr/bin/python # Adds the SWIG stylesheet to the generated documentation on a single page import sys import string filename = sys.argv[1] data = open(filename).read() open(filename+".bak","w").write(data) swigstyle = "\n" + open("style.css").read() lines = data.splitlines() result = [ ] for s in lines: if s == "
SWIG-3.0 Documentation

SWIG-3.0 Documentation



Table of Contents



SWIG-3.0 Documentation 1 Preface 2 Introduction 3 Getting started on Windows 4 Scripting Languages 5 SWIG Basics 6 SWIG and C++ 7 SWIG and C++11 8 Preprocessing 9 SWIG library 10 Argument Handling 11 Typemaps 12 Customization Features 13 Contracts 14 Variable Length Arguments 15 Warning Messages 16 Working with Modules 17 Using SWIG with ccache - ccache-swig(1) manpage 18 SWIG and Allegro Common Lisp 19 SWIG and Android 20 SWIG and C# 21 SWIG and Chicken 22 SWIG and D 23 SWIG and Go 24 SWIG and Guile 25 SWIG and Java 26 SWIG and Javascript 27 SWIG and Common Lisp 28 SWIG and Lua 29 SWIG and Modula-3 30 SWIG and MzScheme/Racket 31 SWIG and Ocaml 32 SWIG and Octave 33 SWIG and Perl5 34 SWIG and PHP 35 SWIG and Pike 36 SWIG and Python 37 SWIG and R 38 SWIG and Ruby 39 SWIG and Tcl 40 Extending SWIG to support new languages

SWIG-3.0 Documentation

Last update : SWIG-3.0.2 (4 Jun 2014)

Sections

SWIG Core Documentation

Language Module Documentation

Developer Documentation


1 Preface

1.1 Introduction

SWIG (Simplified Wrapper and Interface Generator) is a software development tool for building scripting language interfaces to C and C++ programs. Originally developed in 1995, SWIG was first used by scientists in the Theoretical Physics Division at Los Alamos National Laboratory for building user interfaces to simulation codes running on the Connection Machine 5 supercomputer. In this environment, scientists needed to work with huge amounts of simulation data, complex hardware, and a constantly changing code base. The use of a scripting language interface provided a simple yet highly flexible foundation for solving these types of problems. SWIG simplifies development by largely automating the task of scripting language integration--allowing developers and users to focus on more important problems.

Although SWIG was originally developed for scientific applications, it has since evolved into a general purpose tool that is used in a wide variety of applications--in fact almost anything where C/C++ programming is involved.

1.2 SWIG Versions

In the late 1990's, the most stable version of SWIG was release 1.1p5. Versions 1.3.x were officially development versions and these were released over a period of 10 years starting from the year 2000. The final version in the 1.3.x series was 1.3.40, but in truth the 1.3.x series had been stable for many years. An official stable version was released along with the decision to make SWIG license changes and this gave rise to version 2.0.0 in 2010.

1.3 SWIG License

The LICENSE file shipped with SWIG in the top level directory contains the SWIG license. For further insight into the license including the license of SWIG's output code, please visit the SWIG legal page - http://www.swig.org/legal.html.

The license was clarified in version 2.0.0 so that the code that SWIG generated could be distributed under license terms of the user's choice/requirements and at the same time the SWIG source was placed under the GNU General Public License version 3.

1.4 SWIG resources

The official location of SWIG related material is

This site contains the latest version of the software, users guide, and information regarding bugs, installation problems, and implementation tricks.

You can also subscribe to the swig-user mailing list by visiting the page

The mailing list often discusses some of the more technical aspects of SWIG along with information about beta releases and future work.

Git and Subversion access to the latest version of SWIG is also available. More information about this can be obtained at:

1.5 Prerequisites

This manual assumes that you know how to write C/C++ programs and that you have at least heard of scripting languages such as Tcl, Python, and Perl. A detailed knowledge of these scripting languages is not required although some familiarity won't hurt. No prior experience with building C extensions to these languages is required---after all, this is what SWIG does automatically. However, you should be reasonably familiar with the use of compilers, linkers, and makefiles since making scripting language extensions is somewhat more complicated than writing a normal C program.

Over time SWIG releases have become significantly more capable in their C++ handling--especially support for advanced features like namespaces, overloaded operators, and templates. Whenever possible, this manual tries to cover the technicalities of this interface. However, this isn't meant to be a tutorial on C++ programming. For many of the gory details, you will almost certainly want to consult a good C++ reference. If you don't program in C++, you may just want to skip those parts of the manual.

1.6 Organization of this manual

The first few chapters of this manual describe SWIG in general and provide an overview of its capabilities. The remaining chapters are devoted to specific SWIG language modules and are self contained. Thus, if you are using SWIG to build Python interfaces, you can probably skip to that chapter and find almost everything you need to know.

1.7 How to avoid reading the manual

If you hate reading manuals, glance at the "Introduction" which contains a few simple examples. These examples contain about 95% of everything you need to know to use SWIG. After that, simply use the language-specific chapters as a reference. The SWIG distribution also comes with a large directory of examples that illustrate different topics.

1.8 Backwards compatibility

If you are a previous user of SWIG, don't expect SWIG to provide complete backwards compatibility. Although the developers strive to the utmost to keep backwards compatibility, this isn't always possible as the primary goal over time is to make SWIG better---a process that would simply be impossible if the developers are constantly bogged down with backwards compatibility issues. Potential incompatibilities are clearly marked in the detailed release notes.

If you need to work with different versions of SWIG and backwards compatibility is an issue, you can use the SWIG_VERSION preprocessor symbol which holds the version of SWIG being executed. SWIG_VERSION is a hexadecimal integer such as 0x010311 (corresponding to SWIG-1.3.11). This can be used in an interface file to define different typemaps, take advantage of different features etc:

#if SWIG_VERSION >= 0x010311
/* Use some fancy new feature */
#endif

Note: The version symbol is not defined in the generated SWIG wrapper file. The SWIG preprocessor has defined SWIG_VERSION since SWIG-1.3.11.

1.9 Release notes

The CHANGES.current, CHANGES and RELEASENOTES files shipped with SWIG in the top level directory contain, respectively, detailed release notes for the current version, detailed release notes for previous releases and summary release notes from SWIG-1.3.22 onwards.

1.10 Credits

SWIG is an unfunded project that would not be possible without the contributions of many people working in their spare time. If you have benefitted from using SWIG, please consider Donating to SWIG to keep development going. There have been a large varied number of people who have made contributions at all levels over time. Contributors are mentioned either in the COPYRIGHT file or CHANGES files shipped with SWIG or in submitted bugs.

1.11 Bug reports

Although every attempt has been made to make SWIG bug-free, we are also trying to make feature improvements that may introduce bugs. To report a bug, either send mail to the SWIG developer list at the swig-devel mailing list or report a bug at the SWIG bug tracker. In your report, be as specific as possible, including (if applicable), error messages, tracebacks (if a core dump occurred), corresponding portions of the SWIG interface file used, and any important pieces of the SWIG generated wrapper code. We can only fix bugs if we know about them.

1.12 Installation

1.12.1 Windows installation

Please see the dedicated Windows chapter for instructions on installing SWIG on Windows and running the examples. The Windows distribution is called swigwin and includes a prebuilt SWIG executable, swig.exe, included in the top level directory. Otherwise it is exactly the same as the main SWIG distribution. There is no need to download anything else.

1.12.2 Unix installation

You must use GNU make to build and install SWIG.

PCRE needs to be installed on your system to build SWIG, in particular pcre-config must be available. If you have PCRE headers and libraries but not pcre-config itself or, alternatively, wish to override the compiler or linker flags returned by pcre-config, you may set PCRE_LIBS and PCRE_CFLAGS variables to be used instead. And if you don't have PCRE at all, the configure script will provide instructions for obtaining it.

To build and install SWIG, simply type the following:

$ ./configure
$ make
$ make install

By default SWIG installs itself in /usr/local. If you need to install SWIG in a different location or in your home directory, use the --prefix option to ./configure. For example:

$ ./configure --prefix=/home/yourname/projects
$ make
$ make install

Note: the directory given to --prefix must be an absolute pathname. Do not use the ~ shell-escape to refer to your home directory. SWIG won't work properly if you do this.

The INSTALL file shipped in the top level directory details more about using configure. Also try

$ ./configure --help.

The configure script will attempt to locate various packages on your machine including Tcl, Perl5, Python and all the other target languages that SWIG supports. Don't panic if you get 'not found' messages -- SWIG does not need these packages to compile or run. The configure script is actually looking for these packages so that you can try out the SWIG examples contained in the 'Examples' directory without having to hack Makefiles. Note that the --without-xxx options, where xxx is a target language, have minimal effect. All they do is reduce the amount of testing done with 'make check'. The SWIG executable and library files installed cannot currently be configured with a subset of target languages.

SWIG used to include a set of runtime libraries for some languages for working with multiple modules. These are no longer built during the installation stage. However, users can build them just like any wrapper module as described in the Modules chapter. The CHANGES file shipped with SWIG in the top level directory also lists some examples which build the runtime library.

Note:

  • If you checked the code out via Git, you will have to run ./autogen.sh before ./configure. In addition, a full build of SWIG requires a number of packages to be installed. Full instructions at SWIG bleeding edge.

1.12.3 Macintosh OS X installation

SWIG is known to work on various flavors of OS X. Follow the Unix installation instructions above. However, as of this writing, there is still great deal of inconsistency with how shared libaries are handled by various scripting languages on OS X.

Users of OS X should be aware that Darwin handles shared libraries and linking in a radically different way than most Unix systems. In order to test SWIG and run the examples, SWIG configures itself to use flat namespaces and to allow undefined symbols (-flat_namespace -undefined suppress). This mostly closely follows the Unix model and makes it more likely that the SWIG examples will work with whatever installation of software you might have. However, this is generally not the recommended technique for building larger extension modules. Instead, you should utilize Darwin's two-level namespaces. Some details about this can be found here http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/TwoLevelNamespaces.html .

Needless to say, you might have to experiment a bit to get things working at first.

1.12.4 Testing

If you want to test SWIG after building it, a check can be performed on Unix operating systems. Type the following:

    $ make -k check

This step can be performed either before or after installation. The check requires at least one of the target languages to be installed. If it fails, it may mean that you have an uninstalled language module or that the file 'Examples/Makefile' has been incorrectly configured. It may also fail due to compiler issues such as a broken C++ compiler. Even if the check fails, there is a pretty good chance SWIG still works correctly --- you will just have to mess around with one of the examples and some makefiles to get it to work. Some tests may also fail due to missing dependency packages, eg PCRE or Boost, but this will require careful analysis of the configure output done during configuration.

The test suite executed by the check is designed to stress-test many parts of the implementation including obscure corner cases. If some of these tests fail or generate warning messages, there is no reason for alarm --- the test may be related to some new SWIG feature or a difficult bug that we're trying to resolve. Chances are that SWIG will work just fine for you. Note that if you have more than one CPU/core, then you can use parallel make to speed up the check as it does take quite some time to run, for example:

    $ make -j2 -k check

Also, SWIG's support for C++ is sufficiently advanced that certain tests may fail on older C++ compilers (for instance if your compiler does not support member templates). These errors are harmless if you don't intend to use these features in your own programs.

Note: The test-suite currently contains over 500 tests. If you have many different target languages installed and a slow machine, it might take more than an hour to run the test-suite.

1.12.5 Examples

The Examples directory contains a variety of examples of using SWIG and it has some browsable documentation. Simply point your browser to the file "Example/index.html".

The Examples directory also includes Visual C++ project 6 (.dsp) files for building some of the examples on Windows. Later versions of Visual Studio will convert these old style project files into a current solution file.


2 Introduction

2.1 What is SWIG?

SWIG is a software development tool that simplifies the task of interfacing different languages to C and C++ programs. In a nutshell, SWIG is a compiler that takes C/C++ declarations and creates the wrappers needed to access those declarations from other languages including Perl, Python, Tcl, Ruby, Guile, and Java. SWIG normally requires no modifications to existing code and can often be used to build a usable interface in only a few minutes. Possible applications of SWIG include:

  • Building interpreted interfaces to existing C programs.
  • Rapid prototyping and application development.
  • Interactive debugging.
  • Reengineering or refactoring of legacy software into scripting language components.
  • Making a graphical user interface (using Tk for example).
  • Testing of C libraries and programs (using scripts).
  • Building high performance C modules for scripting languages.
  • Making C programming more enjoyable (or tolerable depending on your point of view).
  • Impressing your friends.
  • Obtaining vast sums of research funding (although obviously not applicable to the author).

SWIG was originally designed to make it extremely easy for scientists and engineers to build extensible scientific software without having to get a degree in software engineering. Because of this, the use of SWIG tends to be somewhat informal and ad-hoc (e.g., SWIG does not require users to provide formal interface specifications as you would find in a dedicated IDL compiler). Although this style of development isn't appropriate for every project, it is particularly well suited to software development in the small; especially the research and development work that is commonly found in scientific and engineering projects. However, nowadays SWIG is known to be used in many large open source and commercial projects.

2.2 Why use SWIG?

As stated in the previous section, the primary purpose of SWIG is to simplify the task of integrating C/C++ with other programming languages. However, why would anyone want to do that? To answer that question, it is useful to list a few strengths of C/C++ programming:

  • Excellent support for writing programming libraries.
  • High performance (number crunching, data processing, graphics, etc.).
  • Systems programming and systems integration.
  • Large user community and software base.

Next, let's list a few problems with C/C++ programming

  • Writing a user interface is rather painful (i.e., consider programming with MFC, X11, GTK, or any number of other libraries).
  • Testing is time consuming (the compile/debug cycle).
  • Not easy to reconfigure or customize without recompilation.
  • Modularization can be tricky.
  • Security concerns (buffer overflows for instance).

To address these limitations, many programmers have arrived at the conclusion that it is much easier to use different programming languages for different tasks. For instance, writing a graphical user interface may be significantly easier in a scripting language like Python or Tcl (consider the reasons why millions of programmers have used languages like Visual Basic if you need more proof). An interactive interpreter might also serve as a useful debugging and testing tool. Other languages like Java might greatly simplify the task of writing distributed computing software. The key point is that different programming languages offer different strengths and weaknesses. Moreover, it is extremely unlikely that any programming is ever going to be perfect. Therefore, by combining languages together, you can utilize the best features of each language and greatly simplify certain aspects of software development.

From the standpoint of C/C++, a lot of people use SWIG because they want to break out of the traditional monolithic C programming model which usually results in programs that resemble this:

  • A collection of functions and variables that do something useful.
  • A main() program that starts everything.
  • A horrible collection of hacks that form some kind of user interface (but which no-one really wants to touch).

Instead of going down that route, incorporating C/C++ into a higher level language often results in a more modular design, less code, better flexibility, and increased programmer productivity.

SWIG tries to make the problem of C/C++ integration as painless as possible. This allows you to focus on the underlying C program and using the high-level language interface, but not the tedious and complex chore of making the two languages talk to each other. At the same time, SWIG recognizes that all applications are different. Therefore, it provides a wide variety of customization features that let you change almost every aspect of the language bindings. This is the main reason why SWIG has such a large user manual ;-).

2.3 A SWIG example

The best way to illustrate SWIG is with a simple example. Consider the following C code:

/* File : example.c */

double  My_variable  = 3.0;

/* Compute factorial of n */
int  fact(int n) {
	if (n <= 1) return 1;
	else return n*fact(n-1);
}

/* Compute n mod m */
int my_mod(int n, int m) {
	return(n % m);
}

Suppose that you wanted to access these functions and the global variable My_variable from Tcl. You start by making a SWIG interface file as shown below (by convention, these files carry a .i suffix) :

2.3.1 SWIG interface file

/* File : example.i */
%module example
%{
/* Put headers and other declarations here */
extern double My_variable;
extern int    fact(int);
extern int    my_mod(int n, int m);
%}

extern double My_variable;
extern int    fact(int);
extern int    my_mod(int n, int m);

The interface file contains ANSI C function prototypes and variable declarations. The %module directive defines the name of the module that will be created by SWIG. The %{ %} block provides a location for inserting additional code, such as C header files or additional C declarations, into the generated C wrapper code.

2.3.2 The swig command

SWIG is invoked using the swig command. We can use this to build a Tcl module (under Linux) as follows :

unix > swig -tcl example.i
unix > gcc -c -fpic example.c example_wrap.c -I/usr/local/include
unix > gcc -shared example.o example_wrap.o -o example.so
unix > tclsh
% load ./example.so
% fact 4
24
% my_mod 23 7
2
% expr $My_variable + 4.5
7.5
%

The swig command produced a new file called example_wrap.c that should be compiled along with the example.c file. Most operating systems and scripting languages now support dynamic loading of modules. In our example, our Tcl module has been compiled into a shared library that can be loaded into Tcl. When loaded, Tcl can now access the functions and variables declared in the SWIG interface. A look at the file example_wrap.c reveals a hideous mess. However, you almost never need to worry about it.

2.3.3 Building a Perl5 module

Now, let's turn these functions into a Perl5 module. Without making any changes type the following (shown for Solaris):

unix > swig -perl5 example.i
unix > gcc -c example.c example_wrap.c \
	-I/usr/local/lib/perl5/sun4-solaris/5.003/CORE
unix > ld -G example.o example_wrap.o -o example.so		# This is for Solaris
unix > perl5.003
use example;
print example::fact(4), "\n";
print example::my_mod(23,7), "\n";
print $example::My_variable + 4.5, "\n";
<ctrl-d>
24
2
7.5
unix >

2.3.4 Building a Python module

Finally, let's build a module for Python (shown for Irix).

unix > swig -python example.i
unix > gcc -c -fpic example.c example_wrap.c -I/usr/local/include/python2.0
unix > gcc -shared example.o example_wrap.o -o _example.so
unix > python
Python 2.0 (#6, Feb 21 2001, 13:29:45)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.     
>>> import example
>>> example.fact(4)
24
>>> example.my_mod(23,7)
2
>>> example.cvar.My_variable + 4.5
7.5

2.3.5 Shortcuts

To the truly lazy programmer, one may wonder why we needed the extra interface file at all. As it turns out, you can often do without it. For example, you could also build a Perl5 module by just running SWIG on the C header file and specifying a module name as follows

unix > swig -perl5 -module example example.h
unix > gcc -c example.c example_wrap.c \
	-I/usr/local/lib/perl5/sun4-solaris/5.003/CORE
unix > ld -G example.o example_wrap.o -o example.so
unix > perl5.003
use example;
print example::fact(4), "\n";
print example::my_mod(23,7), "\n";
print $example::My_variable + 4.5, "\n";
<ctrl-d>
24
2
7.5

2.4 Supported C/C++ language features

A primary goal of the SWIG project is to make the language binding process extremely easy. Although a few simple examples have been shown, SWIG is quite capable in supporting most of C++. Some of the major features include:

  • Full C99 preprocessing.
  • All ANSI C and C++ datatypes.
  • Functions, variables, and constants.
  • Classes.
  • Single and multiple inheritance.
  • Overloaded functions and methods.
  • Overloaded operators.
  • C++ templates (including member templates, specialization, and partial specialization).
  • Namespaces.
  • Variable length arguments.
  • C++ smart pointers.

Currently, the only major C++ feature not supported is nested classes--a limitation that should be removed in a future release, but has some workarounds for the moment.

It is important to stress that SWIG is not a simplistic C++ lexing tool like several apparently similar wrapper generation tools. SWIG not only parses C++, it implements the full C++ type system and it is able to understand C++ semantics. SWIG generates its wrappers with full knowledge of this information. As a result, you will find SWIG to be just as capable of dealing with nasty corner cases as it is in wrapping simple C++ code. In fact, SWIG is able to handle C++ code that stresses the very limits of many C++ compilers.

2.5 Non-intrusive interface building

When used as intended, SWIG requires minimal (if any) modification to existing C or C++ code. This makes SWIG extremely easy to use with existing packages and promotes software reuse and modularity. By making the C/C++ code independent of the high level interface, you can change the interface and reuse the code in other applications. It is also possible to support different types of interfaces depending on the application.

2.6 Incorporating SWIG into a build system

SWIG is a command line tool and as such can be incorporated into any build system that supports invoking external tools/compilers. SWIG is most commonly invoked from within a Makefile, but is also known to be invoked from popular IDEs such as Microsoft Visual Studio.

If you are using the GNU Autotools ( Autoconf/ Automake / Libtool) to configure SWIG use in your project, the SWIG Autoconf macros can be used. The primary macro is ax_pkg_swig, see http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html#ax_pkg_swig . The ax_python_devel macro is also helpful for generating Python extensions. See the Autoconf Archive for further information on this and other Autoconf macros.

There is growing support for SWIG in some build tools, for example CMake is a cross-platform, open-source build manager with built in support for SWIG. CMake can detect the SWIG executable and many of the target language libraries for linking against. CMake knows how to build shared libraries and loadable modules on many different operating systems. This allows easy cross platform SWIG development. It can also generate the custom commands necessary for driving SWIG from IDEs and makefiles. All of this can be done from a single cross platform input file. The following example is a CMake input file for creating a python wrapper for the SWIG interface file, example.i:


# This is a CMake example for Python

FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})

FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

SET(CMAKE_SWIG_FLAGS "")

SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES SWIG_FLAGS "-includeall")
SWIG_ADD_MODULE(example python example.i example.cxx)
SWIG_LINK_LIBRARIES(example ${PYTHON_LIBRARIES})

The above example will generate native build files such as makefiles, nmake files and Visual Studio projects which will invoke SWIG and compile the generated C++ files into _example.so (UNIX) or _example.pyd (Windows). For other target languages on Windows a dll, instead of a .pyd file, is usually generated.

2.7 Hands off code generation

SWIG is designed to produce working code that needs no hand-modification (in fact, if you look at the output, you probably won't want to modify it). You should think of your target language interface being defined entirely by the input to SWIG, not the resulting output file. While this approach may limit flexibility for hard-core hackers, it allows others to forget about the low-level implementation details.

2.8 SWIG and freedom

No, this isn't a special section on the sorry state of world politics. However, it may be useful to know that SWIG was written with a certain "philosophy" about programming---namely that programmers are smart and that tools should just stay out of their way. Because of that, you will find that SWIG is extremely permissive in what it lets you get away with. In fact, you can use SWIG to go well beyond "shooting yourself in the foot" if dangerous programming is your goal. On the other hand, this kind of freedom may be exactly what is needed to work with complicated and unusual C/C++ applications.

Ironically, the freedom that SWIG provides is countered by an extremely conservative approach to code generation. At its core, SWIG tries to distill even the most advanced C++ code down to a small well-defined set of interface building techniques based on ANSI C programming. Because of this, you will find that SWIG interfaces can be easily compiled by virtually every C/C++ compiler and that they can 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.


3 Getting started on Windows

This chapter describes SWIG usage on Microsoft Windows. Installing SWIG and running the examples is covered as well as building the SWIG executable. Usage within the Unix like environments MinGW and Cygwin is also detailed.

3.1 Installation on Windows

SWIG does not come with the usual Windows type installation program, however it is quite easy to get started. The main steps are:

  • Download the swigwin zip package from the SWIG website and unzip into a directory. This is all that needs downloading for the Windows platform.
  • Set environment variables as described in the SWIG Windows Examples section in order to run examples using Visual C++.

3.1.1 Windows Executable

The swigwin distribution contains the SWIG Windows executable, swig.exe, which will run on 32 bit versions of Windows, ie Windows 95 and later. If you want to build your own swig.exe have a look at Building swig.exe on Windows.

3.2 SWIG Windows Examples

Using Microsoft Visual C++ is the most common approach to compiling and linking SWIG's output. The Examples directory has a few Visual C++ project files (.dsp files). These were produced by Visual C++ 6. Newer versions of Visual Studio should be able to open and convert these project files. Each C# example comes with a Visual Studio 2005 solution and associated project files instead of Visual C++ 6 project files. The project files have been set up to execute SWIG in a custom build rule for the SWIG interface (.i) file. Alternatively run the examples using Cygwin.

More information on each of the examples is available with the examples distributed with SWIG (Examples/index.html).

3.2.1 Instructions for using the Examples with Visual Studio

Ensure the SWIG executable is as supplied in the SWIG root directory in order for the examples to work. Most languages require some environment variables to be set before running Visual C++. Note that Visual C++ must be re-started to pick up any changes in environment variables. Open up an example .dsp file, Visual C++ will create a workspace for you (.dsw file). Ensure the Release build is selected then do a Rebuild All from the Build menu. The required environment variables are displayed with their current values.

The list of required environment variables for each module language is also listed below. They are usually set from the Control Panel and System properties, but this depends on which flavour of Windows you are running. If you don't want to use environment variables then change all occurrences of the environment variables in the .dsp files with hard coded values. If you are interested in how the project files are set up there is explanatory information in some of the language module's documentation.

3.2.1.1 C#

The C# examples do not require any environment variables to be set as a C# project file is included. Just open up the .sln solution file in Visual Studio .NET 2003 or later, select Release Build, and do a Rebuild All from the Build menu. The accompanying C# and C++ project files are automatically used by the solution file.

3.2.1.2 Java

JAVA_INCLUDE : Set this to the directory containing jni.h
JAVA_BIN : Set this to the bin directory containing javac.exe

Example using JDK1.3:
JAVA_INCLUDE: D:\jdk1.3\include
JAVA_BIN: D:\jdk1.3\bin

3.2.1.3 Perl

PERL5_INCLUDE : Set this to the directory containing perl.h
PERL5_LIB : Set this to the Perl library including path for linking

Example using nsPerl 5.004_04:

PERL5_INCLUDE: D:\nsPerl5.004_04\lib\CORE
PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib

3.2.1.4 Python

PYTHON_INCLUDE : Set this to the directory that contains Python.h
PYTHON_LIB : Set this to the python library including path for linking

Example using Python 2.1.1:
PYTHON_INCLUDE: D:\python21\include
PYTHON_LIB: D:\python21\libs\python21.lib

3.2.1.5 TCL

TCL_INCLUDE : Set this to the directory containing tcl.h
TCL_LIB : Set this to the TCL library including path for linking

Example using ActiveTcl 8.3.3.3
TCL_INCLUDE: D:\tcl\include
TCL_LIB: D:\tcl\lib\tcl83.lib

3.2.1.6 R

R_INCLUDE : Set this to the directory containing R.h
R_LIB : Set this to the R library (Rdll.lib) including path for linking. The library needs to be built as described in the R README.packages file (the pexports.exe approach is the easiest).

Example using R 2.5.1:
R_INCLUDE: C:\Program Files\R\R-2.5.1\include
R_LIB: C:\Program Files\R\R-2.5.1\bin\Rdll.lib

3.2.1.7 Ruby

RUBY_INCLUDE : Set this to the directory containing ruby.h
RUBY_LIB : Set this to the ruby library including path for linking

Example using Ruby 1.6.4:
RUBY_INCLUDE: D:\ruby\lib\ruby\1.6\i586-mswin32
RUBY_LIB: D:\ruby\lib\mswin32-ruby16.lib

3.2.2 Instructions for using the Examples with other compilers

If you do not have access to Visual C++ you will have to set up project files / Makefiles for your chosen compiler. There is a section in each of the language modules detailing what needs setting up using Visual C++ which may be of some guidance. Alternatively you may want to use Cygwin as described in the following section.

3.3 SWIG on Cygwin and MinGW

SWIG can also be compiled and run using Cygwin or MinGW which provides a Unix like front end to Windows and comes free with gcc, an ANSI C/C++ compiler. However, this is not a recommended approach as the prebuilt executable is supplied.

3.3.1 Building swig.exe on Windows

If you want to replicate the build of swig.exe that comes with the download, follow the MinGW instructions below. This is not necessary to use the supplied swig.exe. This information is provided for those that want to modify the SWIG source code in a Windows environment. Normally this is not needed, so most people will want to ignore this section.

3.3.1.1 Building swig.exe using MinGW and MSYS

The short abbreviated instructions follow...

  • Install MinGW and MSYS from the MinGW site. This provides a Unix environment on Windows.
  • Follow the usual Unix instructions in the README file in the SWIG root directory to build swig.exe from the MinGW command prompt.

The step by step instructions to download and install MinGW and MSYS, then download and build the latest version of SWIG from Github follow... Note that the instructions for obtaining SWIG from Github are also online at SWIG Bleeding Edge.

Pitfall note: Execute the steps in the order shown and don't use spaces in path names. In fact it is best to use the default installation directories.

  1. Download the following packages from the MinGW download page or MinGW SourceForge download page. Note that at the time of writing, the majority of these are in the Current release list and some are in the Snapshot or Previous release list.
    • MinGW-3.1.0-1.exe
    • MSYS-1.0.11-2004.04.30-1.exe
    • msysDTK-1.0.1.exe
    • bison-2.0-MSYS.tar.gz
    • msys-autoconf-2.59.tar.bz2
    • msys-automake-1.8.2.tar.bz2
  2. Install MinGW-3.1.0-1.exe (C:\MinGW is default location.)
  3. Install MSYS-1.0.11-2004.04.30-1.exe. Make sure you install it on the same windows drive letter as MinGW (C:\msys\1.0 is default). In the post install script,
    • Answer y to the "do you wish to continue with the post install?"
    • Answer y to the "do you have MinGW installed?"
    • Type in the folder in which you installed MinGW (C:/MinGW is default)
  4. Install msysDTK-1.0.1.exe to the same folder that you installed MSYS (C:\msys\1.0 is default).
  5. Copy the following to the MSYS install folder (C:\msys\1.0 is default):
    • msys-automake-1.8.2.tar.bz2
    • msys-autoconf-2.59.tar.bz2
    • bison-2.0-MSYS.tar.gz
  6. Start the MSYS command prompt and execute:
    cd /
    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   
    
  7. The very latest development version of SWIG is available from SWIG on Github and can be downloaded as a zip file or if you have Git installed, via Git. Either download the latest Zip file snapshot and unzip and rename the top level folder to /usr/src/swig. Otherwise if using Git, type in the following:
    mkdir /usr/src
    cd /usr/src
    git clone https://github.com/swig/swig.git
    
    Pitfall note: If you want to place SWIG in a different folder to the proposed /usr/src/swig, do not use MSYS emulated windows drive letters, because the autotools will fail miserably on those.
  8. The PCRE third party library needs to be built next. Download the latest PCRE source tarball, such as pcre-8.10.tar.bz2, from PCRE and place in the /usr/src/swig directory. Build PCRE as a static library using the Tools/pcre-build.sh script as follows:
    cd /usr/src/swig
    Tools/pcre-build.sh
    
  9. You are now ready to build SWIG. Execute the following commands to build swig.exe:
    cd /usr/src/swig
    ./autogen.sh
    ./configure
    make
    

3.3.1.2 Building swig.exe using Cygwin

Note that SWIG can also be built using Cygwin. However, SWIG will then require the Cygwin DLL when executing. Follow the Unix instructions in the README file in the SWIG root directory. Note that the Cygwin environment will also allow one to regenerate the autotool generated files which are supplied with the release distribution. These files are generated using the autogen.sh script and will only need regenerating in circumstances such as changing the build system.

3.3.1.3 Building swig.exe alternatives

If you don't want to install Cygwin or MinGW, use a different compiler to build SWIG. For example, all the source code files can be added to a Visual C++ project file in order to build swig.exe from the Visual C++ IDE.

3.3.2 Running the examples on Windows using Cygwin

The examples and test-suite work as successfully on Cygwin as on any other Unix operating system. The modules which are known to work are Python, Tcl, Perl, Ruby, Java and C#. Follow the Unix instructions in the README file in the SWIG root directory to build the examples.

3.4 Microsoft extensions and other Windows quirks

A common problem when using SWIG on Windows are the Microsoft function calling conventions which are not in the C++ standard. SWIG parses ISO C/C++ so cannot deal with proprietary conventions such as __declspec(dllimport), __stdcall etc. There is a Windows interface file, windows.i, to deal with these calling conventions though. The file also contains typemaps for handling commonly used Windows specific types such as __int64, BOOL , DWORD etc. Include it like you would any other interface file, for example:

%include <windows.i>

__declspec(dllexport) ULONG __stdcall foo(DWORD, __int32);

4 Scripting Languages

This chapter provides a brief overview of scripting language extension programming and the mechanisms by which scripting language interpreters access C and C++ code.

4.1 The two language view of the world

When a scripting language is used to control a C program, the resulting system tends to look as follows:

Scripting language input - C/C++ functions output

In this programming model, the scripting language interpreter is used for high level control whereas the underlying functionality of the C/C++ program is accessed through special scripting language "commands." If you have ever tried to write your own simple command interpreter, you might view the scripting language approach to be a highly advanced implementation of that. Likewise, If you have ever used a package such as MATLAB or IDL, it is a very similar model--the interpreter executes user commands and scripts. However, most of the underlying functionality is written in a low-level language like C or Fortran.

The two-language model of computing is extremely powerful because it exploits the strengths of each language. C/C++ can be used for maximal performance and complicated systems programming tasks. Scripting languages can be used for rapid prototyping, interactive debugging, scripting, and access to high-level data structures such associative arrays.

4.2 How does a scripting language talk to C?

Scripting languages are built around a parser that knows how to execute commands and scripts. Within this parser, there is a mechanism for executing commands and accessing variables. Normally, this is used to implement the builtin features of the language. However, by extending the interpreter, it is usually possible to add new commands and variables. To do this, most languages define a special API for adding new commands. Furthermore, a special foreign function interface defines how these new commands are supposed to hook into the interpreter.

Typically, when you add a new command to a scripting interpreter you need to do two things; first you need to write a special "wrapper" function that serves as the glue between the interpreter and the underlying C function. Then you need to give the interpreter information about the wrapper by providing details about the name of the function, arguments, and so forth. The next few sections illustrate the process.

4.2.1 Wrapper functions

Suppose you have an ordinary C function like this :

int fact(int n) {
	if (n <= 1) return 1;
	else return n*fact(n-1);
}

In order to access this function from a scripting language, it is necessary to write a special "wrapper" function that serves as the glue between the scripting language and the underlying C function. A wrapper function must do three things :

  • Gather function arguments and make sure they are valid.
  • Call the C function.
  • Convert the return value into a form recognized by the scripting language.

As an example, the Tcl wrapper function for the fact() function above example might look like the following :

int wrap_fact(ClientData clientData, Tcl_Interp *interp,
		int argc, char *argv[]) {
	int result;
	int arg0;
	if (argc != 2) {
		interp->result = "wrong # args";
		return TCL_ERROR;
	}
	arg0 = atoi(argv[1]);
	result = fact(arg0);
	sprintf(interp->result,"%d", result);
	return TCL_OK;
}

Once you have created a wrapper function, the final step is to tell the scripting language about the new function. This is usually done in an initialization function called by the language when the module is loaded. For example, adding the above function to the Tcl interpreter requires code like the following :

int Wrap_Init(Tcl_Interp *interp) {
	Tcl_CreateCommand(interp, "fact", wrap_fact, (ClientData) NULL,
				(Tcl_CmdDeleteProc *) NULL);
	return TCL_OK;
}

When executed, Tcl will now have a new command called "fact " that you can use like any other Tcl command.

Although the process of adding a new function to Tcl has been illustrated, the procedure is almost identical for Perl and Python. Both require special wrappers to be written and both need additional initialization code. Only the specific details are different.

4.2.2 Variable linking

Variable linking refers to the problem of mapping a C/C++ global variable to a variable in the scripting language interpreter. For example, suppose you had the following variable:

double Foo = 3.5;

It might be nice to access it from a script as follows (shown for Perl):

$a = $Foo * 2.3;   # Evaluation
$Foo = $a + 2.0;   # Assignment

To provide such access, variables are commonly manipulated using a pair of get/set functions. For example, whenever the value of a variable is read, a "get" function is invoked. Similarly, whenever the value of a variable is changed, a "set" function is called.

In many languages, calls to the get/set functions can be attached to evaluation and assignment operators. Therefore, evaluating a variable such as $Foo might implicitly call the get function. Similarly, typing $Foo = 4 would call the underlying set function to change the value.

4.2.3 Constants

In many cases, a C program or library may define a large collection of constants. For example:

#define RED   0xff0000
#define BLUE  0x0000ff
#define GREEN 0x00ff00

To make constants available, their values can be stored in scripting language variables such as $RED, $BLUE, and $GREEN. Virtually all scripting languages provide C functions for creating variables so installing constants is usually a trivial exercise.

4.2.4 Structures and classes

Although scripting languages have no trouble accessing simple functions and variables, accessing C/C++ structures and classes present a different problem. This is because the implementation of structures is largely related to the problem of data representation and layout. Furthermore, certain language features are difficult to map to an interpreter. For instance, what does C++ inheritance mean in a Perl interface?

The most straightforward technique for handling structures is to implement a collection of accessor functions that hide the underlying representation of a structure. For example,

struct Vector {
	Vector();
	~Vector();
	double x,y,z;
};

can be transformed into the following set of functions :

Vector *new_Vector();
void delete_Vector(Vector *v);
double Vector_x_get(Vector *v);
double Vector_y_get(Vector *v);
double Vector_z_get(Vector *v);
void Vector_x_set(Vector *v, double x);
void Vector_y_set(Vector *v, double y);
void Vector_z_set(Vector *v, double z);

Now, from an interpreter these function might be used as follows:

% set v [new_Vector]
% Vector_x_set $v 3.5
% Vector_y_get $v
% delete_Vector $v
% ...

Since accessor functions provide a mechanism for accessing the internals of an object, the interpreter does not need to know anything about the actual representation of a Vector.

4.2.5 Proxy classes

In certain cases, it is possible to use the low-level accessor functions to create a proxy class, also known as a shadow class. A proxy class is a special kind of object that gets created in a scripting language to access a C/C++ class (or struct) in a way that looks like the original structure (that is, it proxies the real C++ class). For example, if you have the following C++ definition :

class Vector {
public:
	Vector();
	~Vector();
	double x,y,z;
};

A proxy classing mechanism would allow you to access the structure in a more natural manner from the interpreter. For example, in Python, you might want to do this:

>>> v = Vector()
>>> v.x = 3
>>> v.y = 4
>>> v.z = -13
>>> ...
>>> del v

Similarly, in Perl5 you may want the interface to work like this:

$v = new Vector;
$v->{x} = 3;
$v->{y} = 4;
$v->{z} = -13;

Finally, in Tcl :

Vector v
v configure -x 3 -y 4 -z -13

When proxy classes are used, two objects are really at work--one in the scripting language, and an underlying C/C++ object. Operations affect both objects equally and for all practical purposes, it appears as if you are simply manipulating a C/C++ object.

4.3 Building scripting language extensions

The final step in using a scripting language with your C/C++ application is adding your extensions to the scripting language itself. There are two primary approaches for doing this. The preferred technique is to build a dynamically loadable extension in the form of a shared library. Alternatively, you can recompile the scripting language interpreter with your extensions added to it.

4.3.1 Shared libraries and dynamic loading

To create a shared library or DLL, you often need to look at the manual pages for your compiler and linker. However, the procedure for a few common platforms is shown below:

# Build a shared library for Solaris
gcc -fpic -c example.c example_wrap.c -I/usr/local/include
ld -G example.o example_wrap.o -o example.so

# Build a shared library for Linux
gcc -fpic -c example.c example_wrap.c -I/usr/local/include
gcc -shared example.o example_wrap.o -o example.so

To use your shared library, you simply use the corresponding command in the scripting language (load, import, use, etc...). This will import your module and allow you to start using it. For example:

% load ./example.so
% fact 4
24
%

When working with C++ codes, the process of building shared libraries may be more complicated--primarily due to the fact that C++ modules may need additional code in order to operate correctly. On many machines, you can build a shared C++ module by following the above procedures, but changing the link line to the following :

c++ -shared example.o example_wrap.o -o example.so

4.3.2 Linking with shared libraries

When building extensions as shared libraries, it is not uncommon for your extension to rely upon other shared libraries on your machine. In order for the extension to work, it needs to be able to find all of these libraries at run-time. Otherwise, you may get an error such as the following :

>>> import graph
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/home/sci/data1/beazley/graph/graph.py", line 2, in ?
    import graphc
ImportError:  1101:/home/sci/data1/beazley/bin/python: rld: Fatal Error: cannot 
successfully map soname 'libgraph.so' under any of the filenames /usr/lib/libgraph.so:/
lib/libgraph.so:/lib/cmplrs/cc/libgraph.so:/usr/lib/cmplrs/cc/libgraph.so:
>>>

What this error means is that the extension module created by SWIG depends upon a shared library called "libgraph.so" that the system was unable to locate. To fix this problem, there are a few approaches you can take.

  • Link your extension and explicitly tell the linker where the required libraries are located. Often times, this can be done with a special linker flag such as -R, -rpath, etc. This is not implemented in a standard manner so read the man pages for your linker to find out more about how to set the search path for shared libraries.
  • Put shared libraries in the same directory as the executable. This technique is sometimes required for correct operation on non-Unix platforms.
  • Set the UNIX environment variable LD_LIBRARY_PATH to the directory where shared libraries are located before running Python. Although this is an easy solution, it is not recommended. Consider setting the path using linker options instead.

4.3.3 Static linking

With static linking, you rebuild the scripting language interpreter with extensions. The process usually involves compiling a short main program that adds your customized commands to the language and starts the interpreter. You then link your program with a library to produce a new scripting language executable.

Although static linking is supported on all platforms, this is not the preferred technique for building scripting language extensions. In fact, there are very few practical reasons for doing this--consider using shared libraries instead.


5 SWIG Basics

This chapter describes the basic operation of SWIG, the structure of its input files, and how it handles standard ANSI C declarations. C++ support is described in the next chapter. However, C++ programmers should still read this chapter to understand the basics. Specific details about each target language are described in later chapters.

5.1 Running SWIG

To run SWIG, use the swig command with options and a filename like this:

swig [ options ] filename

where filename is a SWIG interface file or a C/C++ header file. Below is a subset of options that can be used. Additional options are also defined for each target language. A full list can be obtained by typing swig -help or swig - lang -help.

-allegrocl            Generate ALLEGROCL wrappers
-chicken              Generate CHICKEN wrappers
-clisp                Generate CLISP wrappers
-cffi                 Generate CFFI wrappers
-csharp               Generate C# wrappers
-go                   Generate Go wrappers
-guile                Generate Guile wrappers
-java                 Generate Java wrappers
-lua                  Generate Lua wrappers
-modula3              Generate Modula 3 wrappers
-mzscheme             Generate Mzscheme wrappers
-ocaml                Generate Ocaml wrappers
-perl                 Generate Perl wrappers
-php                  Generate PHP wrappers
-pike                 Generate Pike wrappers
-python               Generate Python wrappers
-r                    Generate R (aka GNU S) wrappers
-ruby                 Generate Ruby wrappers
-sexp                 Generate Lisp S-Expressions wrappers
-tcl                  Generate Tcl wrappers
-uffi                 Generate Common Lisp / UFFI wrappers
-xml                  Generate XML wrappers

-c++                  Enable C++ parsing
-Dsymbol              Define a preprocessor symbol
-Fstandard            Display error/warning messages in commonly used format
-Fmicrosoft           Display error/warning messages in Microsoft format
-help                 Display all options
-Idir                 Add a directory to the file include path
-lfile                Include a SWIG library file.
-module name          Set the name of the SWIG module
-o outfile            Name of output file
-outcurrentdir	      Set default output dir to current dir instead of input file's path
-outdir dir           Set language specific files output directory
-pcreversion          Display PCRE version information
-swiglib              Show location of SWIG library
-version              Show SWIG version number

5.1.1 Input format

As input, SWIG expects a file containing ANSI C/C++ declarations and special SWIG directives. More often than not, this is a special SWIG interface file which is usually denoted with a special .i or .swg suffix. In certain cases, SWIG can be used directly on raw header files or source files. However, this is not the most typical case and there are several reasons why you might not want to do this (described later).

The most common format of a SWIG interface is as follows:

%module mymodule 
%{
#include "myheader.h"
%}
// Now list ANSI C/C++ declarations
int foo;
int bar(int x);
...

The module name is supplied using the special %module directive. Modules are described further in the Modules Introduction section.

Everything in the %{ ... %} block is simply copied verbatim to the resulting wrapper file created by SWIG. This section is almost always used to include header files and other declarations that are required to make the generated wrapper code compile. It is important to emphasize that just because you include a declaration in a SWIG input file, that declaration does not automatically appear in the generated wrapper code---therefore you need to make sure you include the proper header files in the %{ ... %} section. It should be noted that the text enclosed in %{ ... %} is not parsed or interpreted by SWIG. The %{...%} syntax and semantics in SWIG is analogous to that of the declarations section used in input files to parser generation tools such as yacc or bison.

5.1.2 SWIG Output

The output of SWIG is a C/C++ file that contains all of the wrapper code needed to build an extension module. SWIG may generate some additional files depending on the target language. By default, an input file with the name file.i is transformed into a file file_wrap.c or file_wrap.cxx (depending on whether or not the -c++ option has been used). The name of the output file can be changed using the -o 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 -o option to change the suffix of the SWIG-generated wrapper file if you want something different than the default. For example:

$ swig -c++ -python -o example_wrap.cpp example.i

The C/C++ output file created by SWIG often contains everything that is needed to construct an extension module for the target scripting language. SWIG is not a stub compiler nor is it usually necessary to edit the output file (and if you look at the output, you probably won't want to). To build the final extension module, the SWIG output file is compiled and linked with the rest of your C/C++ program to create a shared library.

For many target languages SWIG will also generate proxy class files in the target language. The default output directory for these language specific files is the same directory as the generated C/C++ file. This can be modified using the -outdir option. For example:

$ swig -c++ -python -outdir pyfiles -o cppfiles/example_wrap.cpp example.i

If the directories cppfiles and pyfiles exist, the following will be generated:

cppfiles/example_wrap.cpp
pyfiles/example.py

If the -outcurrentdir option is used (without -o) then SWIG behaves like a typical C/C++ compiler and the default output directory is then the current directory. Without this option the default output directory is the path to the input file. If -o and -outcurrentdir are used together, -outcurrentdir is effectively ignored as the output directory for the language files is the same directory as the generated C/C++ file if not overridden with -outdir.

5.1.3 Comments

C and C++ style comments may appear anywhere in interface files. In previous versions of SWIG, comments were used to generate documentation files. However, this feature is currently under repair and will reappear in a later SWIG release.

5.1.4 C Preprocessor

Like C, SWIG preprocesses all input files through an enhanced version of the C preprocessor. All standard preprocessor features are supported including file inclusion, conditional compilation and macros. However, #include statements are ignored unless the -includeall command line option has been supplied. The reason for disabling includes is that SWIG is sometimes used to process raw C header files. In this case, you usually only want the extension module to include functions in the supplied header file rather than everything that might be included by that header file (i.e., system headers, C library functions, etc.).

It should also be noted that the SWIG preprocessor skips all text enclosed inside a %{...%} block. In addition, the preprocessor includes a number of macro handling enhancements that make it more powerful than the normal C preprocessor. These extensions are described in the "Preprocessor" chapter.

5.1.5 SWIG Directives

Most of SWIG's operation is controlled by special directives that are always preceded by a "%" to distinguish them from normal C declarations. These directives are used to give SWIG hints or to alter SWIG's parsing behavior in some manner.

Since SWIG directives are not legal C syntax, it is generally not possible to include them in header files. However, SWIG directives can be included in C header files using conditional compilation like this:

/* header.h  --- Some header file */

/* SWIG directives -- only seen if SWIG is running */ 
#ifdef SWIG
%module foo
#endif

SWIG is a special preprocessing symbol defined by SWIG when it is parsing an input file.

5.1.6 Parser Limitations

Although SWIG can parse most C/C++ declarations, it does not provide a complete C/C++ parser implementation. Most of these limitations pertain to very complicated type declarations and certain advanced C++ features. Specifically, the following features are not currently supported:

  • Non-conventional type declarations. For example, SWIG does not support declarations such as the following (even though this is legal C):

    /* Non-conventional placement of storage specifier (extern) */
    const int extern Number;
    
    /* Extra declarator grouping */
    Matrix (foo);    // A global variable
    
    /* Extra declarator grouping in parameters */
    void bar(Spam (Grok)(Doh));
    
    

    In practice, few (if any) C programmers actually write code like this since this style is never featured in programming books. However, if you're feeling particularly obfuscated, you can certainly break SWIG (although why would you want to?).

  • Running SWIG on C++ source files (the code in a .C, .cpp or .cxx file) is not recommended. The usual approach is to feed SWIG header files for parsing C++ definitions and declarations. The main reason is if SWIG parses a scoped definition or declaration (as is normal for C++ source files), it is ignored, unless a declaration for the symbol was parsed earlier. For example

    /* bar not wrapped unless foo has been defined and 
       the declaration of bar within foo has already been parsed */
    int foo::bar(int) {
        ... whatever ...
    }
    
  • Certain advanced features of C++ such as nested classes are not yet fully supported. Please see the C++ Nested classes section for more information.

In the event of a parsing error, conditional compilation can be used to skip offending code. For example:

#ifndef SWIG
... some bad declarations ...
#endif

Alternatively, you can just delete the offending code from the interface file.

One of the reasons why SWIG does not provide a full C++ parser implementation is that it has been designed to work with incomplete specifications and to be very permissive in its handling of C/C++ datatypes (e.g., SWIG can generate interfaces even when there are missing class declarations or opaque datatypes). Unfortunately, this approach makes it extremely difficult to implement certain parts of a C/C++ parser as most compilers use type information to assist in the parsing of more complex declarations (for the truly curious, the primary complication in the implementation is that the SWIG parser does not utilize a separate typedef-name terminal symbol as described on p. 234 of K&R).

5.2 Wrapping Simple C Declarations

SWIG wraps simple C declarations by creating an interface that closely matches the way in which the declarations would be used in a C program. For example, consider the following interface file:

%module example

%inline %{
extern double sin(double x);
extern int strcmp(const char *, const char *);
extern int Foo;
%}
#define STATUS 50
#define VERSION "1.1"

In this file, there are two functions sin() and strcmp(), a global variable Foo, and two constants STATUS and VERSION. When SWIG creates an extension module, these declarations are accessible as scripting language functions, variables, and constants respectively. For example, in Tcl:

% sin 3
5.2335956
% strcmp Dave Mike
-1
% puts $Foo
42
% puts $STATUS
50
% puts $VERSION
1.1

Or in Python:

>>> example.sin(3)
5.2335956
>>> example.strcmp('Dave','Mike')
-1
>>> print example.cvar.Foo
42
>>> print example.STATUS
50
>>> print example.VERSION
1.1

Whenever possible, SWIG creates an interface that closely matches the underlying C/C++ code. However, due to subtle differences between languages, run-time environments, and semantics, it is not always possible to do so. The next few sections describe various aspects of this mapping.

5.2.1 Basic Type Handling

In order to build an interface, SWIG has to convert C/C++ datatypes to equivalent types in the target language. Generally, scripting languages provide a more limited set of primitive types than C. Therefore, this conversion process involves a certain amount of type coercion.

Most scripting languages provide a single integer type that is implemented using the int or long datatype in C. The following list shows all of the C datatypes that SWIG will convert to and from integers in the target language:

int
short
long
unsigned
signed
unsigned short
unsigned long
unsigned char
signed char
bool

When an integral value is converted from C, a cast is used to convert it to the representation in the target language. Thus, a 16 bit short in C may be promoted to a 32 bit integer. When integers are converted in the other direction, the value is cast back into the original C type. If the value is too large to fit, it is silently truncated.

unsigned char and signed char are special cases that are handled as small 8-bit integers. Normally, the char datatype is mapped as a one-character ASCII string.

The bool datatype is cast to and from an integer value of 0 and 1 unless the target language provides a special boolean type.

Some care is required when working with large integer values. Most scripting languages use 32-bit integers so mapping a 64-bit long integer may lead to truncation errors. Similar problems may arise with 32 bit unsigned integers (which may appear as large negative numbers). As a rule of thumb, the int datatype and all variations of char and short datatypes are safe to use. For unsigned int and long datatypes, you will need to carefully check the correct operation of your program after it has been wrapped with SWIG.

Although the SWIG parser supports the long long datatype, not all language modules support it. This is because long long usually exceeds the integer precision available in the target language. In certain modules such as Tcl and Perl5, long long integers are encoded as strings. This allows the full range of these numbers to be represented. However, it does not allow long long values to be used in arithmetic expressions. It should also be noted that although long long is part of the ISO C99 standard, it is not universally supported by all C compilers. Make sure you are using a compiler that supports long long before trying to use this type with SWIG.

SWIG recognizes the following floating point types :

float
double

Floating point numbers are mapped to and from the natural representation of floats in the target language. This is almost always a C double. The rarely used datatype of long double is not supported by SWIG.

The char datatype is mapped into a NULL terminated ASCII string with a single character. When used in a scripting language it shows up as a tiny string containing the character value. When converting the value back into C, SWIG takes a character string from the scripting language and strips off the first character as the char value. Thus if the value "foo" is assigned to a char datatype, it gets the value `f'.

The char * datatype is handled as a NULL-terminated ASCII string. SWIG maps this into a 8-bit character string in the target scripting language. SWIG converts character strings in the target language to NULL terminated strings before passing them into C/C++. The default handling of these strings does not allow them to have embedded NULL bytes. Therefore, the char * datatype is not generally suitable for passing binary data. However, it is possible to change this behavior by defining a SWIG typemap. See the chapter on Typemaps for details about this.

At this time, SWIG provides limited support for Unicode and wide-character strings (the C wchar_t type). Some languages provide typemaps for wchar_t, but bear in mind these might not be portable across different operating systems. This is a delicate topic that is poorly understood by many programmers and not implemented in a consistent manner across languages. For those scripting languages that provide Unicode support, Unicode strings are often available in an 8-bit representation such as UTF-8 that can be mapped to the char * type (in which case the SWIG interface will probably work). If the program you are wrapping uses Unicode, there is no guarantee that Unicode characters in the target language will use the same internal representation (e.g., UCS-2 vs. UCS-4). You may need to write some special conversion functions.

5.2.2 Global Variables

Whenever possible, SWIG maps C/C++ global variables into scripting language variables. For example,

%module example
double foo;

results in a scripting language variable like this:

# Tcl
set foo [3.5]                   ;# Set foo to 3.5
puts $foo                       ;# Print the value of foo

# Python
cvar.foo = 3.5                  # Set foo to 3.5
print cvar.foo                  # Print value of foo

# Perl
$foo = 3.5;                     # Set foo to 3.5
print $foo,"\n";                # Print value of foo

# Ruby
Module.foo = 3.5               # Set foo to 3.5
print Module.foo, "\n"         # Print value of foo

Whenever the scripting language variable is used, the underlying C global variable is accessed. Although SWIG makes every attempt to make global variables work like scripting language variables, it is not always possible to do so. For instance, in Python, all global variables must be accessed through a special variable object known as cvar (shown above). In Ruby, variables are accessed as attributes of the module. Other languages may convert variables to a pair of accessor functions. For example, the Java module generates a pair of functions double get_foo() and set_foo(double val) that are used to manipulate the value.

Finally, if a global variable has been declared as const, it only supports read-only access. Note: this behavior is new to SWIG-1.3. Earlier versions of SWIG incorrectly handled const and created constants instead.

5.2.3 Constants

Constants can be created using #define, enumerations, or a special %constant directive. The following interface file shows a few valid constant declarations :

#define I_CONST       5               // An integer constant
#define PI            3.14159         // A Floating point constant
#define S_CONST       "hello world"   // A string constant
#define NEWLINE       '\n'            // Character constant

enum boolean {NO=0, YES=1};
enum months {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG,
             SEP, OCT, NOV, DEC};
%constant double BLAH = 42.37;
#define PI_4 PI/4
#define FLAGS 0x04 | 0x08 | 0x40

In #define declarations, the type of a constant is inferred by syntax. For example, a number with a decimal point is assumed to be floating point. In addition, SWIG must be able to fully resolve all of the symbols used in a #define in order for a constant to actually be created. This restriction is necessary because #define is also used to define preprocessor macros that are definitely not meant to be part of the scripting language interface. For example:

#define EXTERN extern

EXTERN void foo();

In this case, you probably don't want to create a constant called EXTERN (what would the value be?). In general, SWIG will not create constants for macros unless the value can be completely determined by the preprocessor. For instance, in the above example, the declaration

#define PI_4  PI/4

defines a constant because PI was already defined as a constant and the value is known. However, for the same conservative reasons even a constant with a simple cast will be ignored, such as

#define F_CONST (double) 5            // A floating point constant with cast

The use of constant expressions is allowed, but SWIG does not evaluate them. Rather, it passes them through to the output file and lets the C compiler perform the final evaluation (SWIG does perform a limited form of type-checking however).

For enumerations, it is critical that the original enum definition be included somewhere in the interface file (either in a header file or in the %{,%} block). SWIG only translates the enumeration into code needed to add the constants to a scripting language. It needs the original enumeration declaration in order to get the correct enum values as assigned by the C compiler.

The %constant directive is used to more precisely create constants corresponding to different C datatypes. Although it is not usually needed for simple values, it is more useful when working with pointers and other more complex datatypes. Typically, %constant is only used when you want to add constants to the scripting language interface that are not defined in the original header file.

5.2.4 A brief word about const

A common confusion with C programming is the semantic meaning of the const qualifier in declarations--especially when it is mixed with pointers and other type modifiers. In fact, previous versions of SWIG handled const incorrectly--a situation that SWIG-1.3.7 and newer releases have fixed.

Starting with SWIG-1.3, all variable declarations, regardless of any use of const, are wrapped as global variables. If a declaration happens to be declared as const, it is wrapped as a read-only variable. To tell if a variable is const or not, you need to look at the right-most occurrence of the const qualifier (that appears before the variable name). If the right-most const occurs after all other type modifiers (such as pointers), then the variable is const. Otherwise, it is not.

Here are some examples of const declarations.

const char a;           // A constant character
char const b;           // A constant character (the same)
char *const c;          // A constant pointer to a character
const char *const d;    // A constant pointer to a constant character

Here is an example of a declaration that is not const:

const char *e;          // A pointer to a constant character.  The pointer
                        // may be modified.

In this case, the pointer e can change---it's only the value being pointed to that is read-only.

Please note that for const parameters or return types used in a function, SWIG pretty much ignores the fact that these are const, see the section on const-correctness for more information.

Compatibility Note: One reason for changing SWIG to handle const declarations as read-only variables is that there are many situations where the value of a const variable might change. For example, a library might export a symbol as const in its public API to discourage modification, but still allow the value to change through some other kind of internal mechanism. Furthermore, programmers often overlook the fact that with a constant declaration like char *const, the underlying data being pointed to can be modified--it's only the pointer itself that is constant. In an embedded system, a const declaration might refer to a read-only memory address such as the location of a memory-mapped I/O device port (where the value changes, but writing to the port is not supported by the hardware). Rather than trying to build a bunch of special cases into the const qualifier, the new interpretation of const as "read-only" is simple and exactly matches the actual semantics of const in C/C++. If you really want to create a constant as in older versions of SWIG, use the %constant directive instead. For example:

%constant double PI = 3.14159;

or

#ifdef SWIG
#define const %constant
#endif
const double foo = 3.4;
const double bar = 23.4;
const int    spam = 42;
#ifdef SWIG
#undef const
#endif
...

5.2.5 A cautionary tale of char *

Before going any further, there is one bit of caution involving char * that must now be mentioned. When strings are passed from a scripting language to a C char *, the pointer usually points to string data stored inside the interpreter. It is almost always a really bad idea to modify this data. Furthermore, some languages may explicitly disallow it. For instance, in Python, strings are supposed to be immutable. If you violate this, you will probably receive a vast amount of wrath when you unleash your module on the world.

The primary source of problems are functions that might modify string data in place. A classic example would be a function like this:

char *strcat(char *s, const char *t)

Although SWIG will certainly generate a wrapper for this, its behavior will be undefined. In fact, it will probably cause your application to crash with a segmentation fault or other memory related problem. This is because s refers to some internal data in the target language---data that you shouldn't be touching.

The bottom line: don't rely on char * for anything other than read-only input values. However, it must be noted that you could change the behavior of SWIG using typemaps.

5.3 Pointers and complex objects

Most C programs manipulate arrays, structures, and other types of objects. This section discusses the handling of these datatypes.

5.3.1 Simple pointers

Pointers to primitive C datatypes such as

int *
double ***
char **

are fully supported by SWIG. Rather than trying to convert the data being pointed to into a scripting representation, SWIG simply encodes the pointer itself into a representation that contains the actual value of the pointer and a type-tag. Thus, the SWIG representation of the above pointers (in Tcl), might look like this:

_10081012_p_int
_1008e124_ppp_double
_f8ac_pp_char

A NULL pointer is represented by the string "NULL" or the value 0 encoded with type information.

All pointers are treated as opaque objects by SWIG. Thus, a pointer may be returned by a function and passed around to other C functions as needed. For all practical purposes, the scripting language interface works in exactly the same way as you would use the pointer in a C program. The only difference is that there is no mechanism for dereferencing the pointer since this would require the target language to understand the memory layout of the underlying object.

The scripting language representation of a pointer value should never be manipulated directly. Even though the values shown look like hexadecimal addresses, the numbers used may differ from the actual machine address (e.g., on little-endian machines, the digits may appear in reverse order). Furthermore, SWIG does not normally map pointers into high-level objects such as associative arrays or lists (for example, converting an int * into an list of integers). There are several reasons why SWIG does not do this:

  • There is not enough information in a C declaration to properly map pointers into higher level constructs. For example, an int * may indeed be an array of integers, but if it contains ten million elements, converting it into a list object is probably a bad idea.
  • The underlying semantics associated with a pointer is not known by SWIG. For instance, an int * might not be an array at all--perhaps it is an output value!
  • By handling all pointers in a consistent manner, the implementation of SWIG is greatly simplified and less prone to error.

5.3.2 Run time pointer type checking

By allowing pointers to be manipulated from a scripting language, extension modules effectively bypass compile-time type checking in the C/C++ compiler. To prevent errors, a type signature is encoded into all pointer values and is used to perform run-time type checking. This type-checking process is an integral part of SWIG and can not be disabled or modified without using typemaps (described in later chapters).

Like C, void * matches any kind of pointer. Furthermore, NULL pointers can be passed to any function that expects to receive a pointer. Although this has the potential to cause a crash, NULL pointers are also sometimes used as sentinel values or to denote a missing/empty value. Therefore, SWIG leaves NULL pointer checking up to the application.

5.3.3 Derived types, structs, and classes

For everything else (structs, classes, arrays, etc...) SWIG applies a very simple rule :

Everything else is a pointer

In other words, SWIG manipulates everything else by reference. This model makes sense because most C/C++ programs make heavy use of pointers and SWIG can use the type-checked pointer mechanism already present for handling pointers to basic datatypes.

Although this probably sounds complicated, it's really quite simple. Suppose you have an interface file like this :

%module fileio
FILE *fopen(char *, char *);
int fclose(FILE *);
unsigned fread(void *ptr, unsigned size, unsigned nobj, FILE *);
unsigned fwrite(void *ptr, unsigned size, unsigned nobj, FILE *);
void *malloc(int nbytes);
void free(void *);

In this file, SWIG doesn't know what a FILE is, but since it's used as a pointer, so it doesn't really matter what it is. If you wrapped this module into Python, you can use the functions just like you expect :

# Copy a file 
def filecopy(source,target):
	f1 = fopen(source,"r")
	f2 = fopen(target,"w")
	buffer = malloc(8192)
	nbytes = fread(buffer,8192,1,f1)
	while (nbytes > 0):
		fwrite(buffer,8192,1,f2)
		nbytes = fread(buffer,8192,1,f1)
	free(buffer)

In this case f1, f2, and buffer are all opaque objects containing C pointers. It doesn't matter what value they contain--our program works just fine without this knowledge.

5.3.4 Undefined datatypes

When SWIG encounters an undeclared datatype, it automatically assumes that it is a structure or class. For example, suppose the following function appeared in a SWIG input file:

void matrix_multiply(Matrix *a, Matrix *b, Matrix *c);

SWIG has no idea what a "Matrix" is. However, it is obviously a pointer to something so SWIG generates a wrapper using its generic pointer handling code.

Unlike C or C++, SWIG does not actually care whether Matrix has been previously defined in the interface file or not. This allows SWIG to generate interfaces from only partial or limited information. In some cases, you may not care what a Matrix really is as long as you can pass an opaque reference to one around in the scripting language interface.

An important detail to mention is that SWIG will gladly generate wrappers for an interface when there are unspecified type names. However, all unspecified types are internally handled as pointers to structures or classes! For example, consider the following declaration:

void foo(size_t num);

If size_t is undeclared, SWIG generates wrappers that expect to receive a type of size_t * (this mapping is described shortly). As a result, the scripting interface might behave strangely. For example:

foo(40);
TypeError: expected a _p_size_t.

The only way to fix this problem is to make sure you properly declare type names using typedef.

5.3.5 Typedef

Like C, typedef can be used to define new type names in SWIG. For example:

typedef unsigned int size_t;

typedef definitions appearing in a SWIG interface are not propagated to the generated wrapper code. Therefore, they either need to be defined in an included header file or placed in the declarations section like this:

%{
/* Include in the generated wrapper file */
typedef unsigned int size_t;
%}
/* Tell SWIG about it */
typedef unsigned int size_t;

or

%inline %{
typedef unsigned int size_t;
%}

In certain cases, you might be able to include other header files to collect type information. For example:

%module example
%import "sys/types.h"

In this case, you might run SWIG as follows:

$ swig -I/usr/include -includeall example.i

It should be noted that your mileage will vary greatly here. System headers are notoriously complicated and may rely upon a variety of non-standard C coding extensions (e.g., such as special directives to GCC). Unless you exactly specify the right include directories and preprocessor symbols, this may not work correctly (you will have to experiment).

SWIG tracks typedef declarations and uses this information for run-time type checking. For instance, if you use the above typedef and had the following function declaration:

void foo(unsigned int *ptr);

The corresponding wrapper function will accept arguments of type unsigned int * or size_t *.

5.4 Other Practicalities

So far, this chapter has presented almost everything you need to know to use SWIG for simple interfaces. However, some C programs use idioms that are somewhat more difficult to map to a scripting language interface. This section describes some of these issues.

5.4.1 Passing structures by value

Sometimes a C function takes structure parameters that are passed by value. For example, consider the following function:

double dot_product(Vector a, Vector b);

To deal with this, SWIG transforms the function to use pointers by creating a wrapper equivalent to the following:

double wrap_dot_product(Vector *a, Vector *b) {
    Vector x = *a;
    Vector y = *b;
    return dot_product(x,y);
}

In the target language, the dot_product() function now accepts pointers to Vectors instead of Vectors. For the most part, this transformation is transparent so you might not notice.

5.4.2 Return by value

C functions that return structures or classes datatypes by value are more difficult to handle. Consider the following function:

Vector cross_product(Vector v1, Vector v2);

This function wants to return Vector, but SWIG only really supports pointers. As a result, SWIG creates a wrapper like this:

Vector *wrap_cross_product(Vector *v1, Vector *v2) {
        Vector x = *v1;
        Vector y = *v2;
        Vector *result;
        result = (Vector *) malloc(sizeof(Vector));
        *(result) = cross(x,y);
        return result;
}

or if SWIG was run with the -c++ option:

Vector *wrap_cross(Vector *v1, Vector *v2) {
        Vector x = *v1;
        Vector y = *v2;
        Vector *result = new Vector(cross(x,y)); // Uses default copy constructor
        return result;
}

In both cases, SWIG allocates a new object and returns a reference to it. It is up to the user to delete the returned object when it is no longer in use. Clearly, this will leak memory if you are unaware of the implicit memory allocation and don't take steps to free the result. That said, it should be noted that some language modules can now automatically track newly created objects and reclaim memory for you. Consult the documentation for each language module for more details.

It should also be noted that the handling of pass/return by value in C++ has some special cases. For example, the above code fragments don't work correctly if Vector doesn't define a default constructor. The section on SWIG and C++ has more information about this case.

5.4.3 Linking to structure variables

When global variables or class members involving structures are encountered, SWIG handles them as pointers. For example, a global variable like this

Vector unit_i;

gets mapped to an underlying pair of set/get functions like this :

Vector *unit_i_get() {
	return &unit_i;
}
void unit_i_set(Vector *value) {
	unit_i = *value;
}

Again some caution is in order. A global variable created in this manner will show up as a pointer in the target scripting language. It would be an extremely bad idea to free or destroy such a pointer. Also, C++ classes must supply a properly defined copy constructor in order for assignment to work correctly.

5.4.4 Linking to char *

When a global variable of type char * appears, SWIG uses malloc() or new to allocate memory for the new value. Specifically, if you have a variable like this

char *foo;

SWIG generates the following code:

/* C mode */
void foo_set(char *value) {
   if (foo) free(foo);
   foo = (char *) malloc(strlen(value)+1);
   strcpy(foo,value);
}

/* C++ mode.  When -c++ option is used */
void foo_set(char *value) {
   if (foo) delete [] foo;
   foo = new char[strlen(value)+1];
   strcpy(foo,value);
}

If this is not the behavior that you want, consider making the variable read-only using the %immutable directive. Alternatively, you might write a short assist-function to set the value exactly like you want. For example:

%inline %{
  void set_foo(char *value) {
       strncpy(foo,value, 50);
   }
%}

Note: If you write an assist function like this, you will have to call it as a function from the target scripting language (it does not work like a variable). For example, in Python you will have to write:

>>> set_foo("Hello World")

A common mistake with char * variables is to link to a variable declared like this:

char *VERSION = "1.0";

In this case, the variable will be readable, but any attempt to change the value results in a segmentation or general protection fault. This is due to the fact that SWIG is trying to release the old value using free or delete when the string literal value currently assigned to the variable wasn't allocated using malloc() or new. To fix this behavior, you can either mark the variable as read-only, write a typemap (as described in Chapter 6), or write a special set function as shown. Another alternative is to declare the variable as an array:

char VERSION[64] = "1.0";

When variables of type const char * are declared, SWIG still generates functions for setting and getting the value. However, the default behavior does not release the previous contents (resulting in a possible memory leak). In fact, you may get a warning message such as this when wrapping such a variable:

example.i:20. Typemap warning. Setting const char * variable may leak memory

The reason for this behavior is that const char * variables are often used to point to string literals. For example:

const char *foo = "Hello World\n";

Therefore, it's a really bad idea to call free() on such a pointer. On the other hand, it is legal to change the pointer to point to some other value. When setting a variable of this type, SWIG allocates a new string (using malloc or new) and changes the pointer to point to the new value. However, repeated modifications of the value will result in a memory leak since the old value is not released.

5.4.5 Arrays

Arrays are fully supported by SWIG, but they are always handled as pointers instead of mapping them to a special array object or list in the target language. Thus, the following declarations :

int foobar(int a[40]);
void grok(char *argv[]);
void transpose(double a[20][20]);

are processed as if they were really declared like this:

int foobar(int *a);
void grok(char **argv);
void transpose(double (*a)[20]);

Like C, SWIG does not perform array bounds checking. It is up to the user to make sure the pointer points to a suitably allocated region of memory.

Multi-dimensional arrays are transformed into a pointer to an array of one less dimension. For example:

int [10];         // Maps to int *
int [10][20];     // Maps to int (*)[20]
int [10][20][30]; // Maps to int (*)[20][30]

It is important to note that in the C type system, a multidimensional array a[][] is NOT equivalent to a single pointer *a or a double pointer such as **a. Instead, a pointer to an array is used (as shown above) where the actual value of the pointer is the starting memory location of the array. The reader is strongly advised to dust off their C book and re-read the section on arrays before using them with SWIG.

Array variables are supported, but are read-only by default. For example:

int   a[100][200];

In this case, reading the variable 'a' returns a pointer of type int (*)[200] that points to the first element of the array &a[0][0]. Trying to modify 'a' results in an error. This is because SWIG does not know how to copy data from the target language into the array. To work around this limitation, you may want to write a few simple assist functions like this:

%inline %{
void a_set(int i, int j, int val) {
   a[i][j] = val;
}
int a_get(int i, int j) {
   return a[i][j];
}
%}

To dynamically create arrays of various sizes and shapes, it may be useful to write some helper functions in your interface. For example:

// Some array helpers
%inline %{
  /* Create any sort of [size] array */
  int *int_array(int size) {
     return (int *) malloc(size*sizeof(int));
  }
  /* Create a two-dimension array [size][10] */
  int (*int_array_10(int size))[10] {
     return (int (*)[10]) malloc(size*10*sizeof(int));
  }
%}

Arrays of char are handled as a special case by SWIG. In this case, strings in the target language can be stored in the array. For example, if you have a declaration like this,

char pathname[256];

SWIG generates functions for both getting and setting the value that are equivalent to the following code:

char *pathname_get() {
   return pathname;
}
void pathname_set(char *value) {
   strncpy(pathname,value,256);
}

In the target language, the value can be set like a normal variable.

5.4.6 Creating read-only variables

A read-only variable can be created by using the %immutable directive as shown :

// File : interface.i

int 	a; 			// Can read/write
%immutable;
int	b,c,d			// Read only variables
%mutable;
double	x,y			// read/write

The %immutable directive enables read-only mode until it is explicitly disabled using the %mutable directive. As an alternative to turning read-only mode off and on like this, individual declarations can also be tagged as immutable. For example:

%immutable x;                   // Make x read-only
...
double x;                       // Read-only (from earlier %immutable directive)
double y;                       // Read-write
...

The %mutable and %immutable directives are actually %feature directives defined like this:

#define %immutable   %feature("immutable")
#define %mutable     %feature("immutable","")

If you wanted to make all wrapped variables read-only, barring one or two, it might be easier to take this approach:

%immutable;                     // Make all variables read-only
%feature("immutable","0") x;    // except, make x read/write
...
double x;
double y;
double z;
...

Read-only variables are also created when declarations are declared as const. For example:

const int foo;               /* Read only variable */
char * const version="1.0";  /* Read only variable */

Compatibility note: Read-only access used to be controlled by a pair of directives %readonly and %readwrite. Although these directives still work, they generate a warning message. Simply change the directives to %immutable; and %mutable; to silence the warning. Don't forget the extra semicolon!

5.4.7 Renaming and ignoring declarations

5.4.7.1 Simple renaming of specific identifiers

Normally, the name of a C declaration is used when that declaration is wrapped into the target language. However, this may generate a conflict with a keyword or already existing function in the scripting language. To resolve a name conflict, you can use the %rename directive as shown :

// interface.i

%rename(my_print) print;
extern void print(const char *);

%rename(foo) a_really_long_and_annoying_name;
extern int a_really_long_and_annoying_name;

SWIG still calls the correct C function, but in this case the function print() will really be called "my_print()" in the target language.

The placement of the %rename directive is arbitrary as long as it appears before the declarations to be renamed. A common technique is to write code for wrapping a header file like this:

// interface.i

%rename(my_print) print;
%rename(foo) a_really_long_and_annoying_name;

%include "header.h"

%rename applies a renaming operation to all future occurrences of a name. The renaming applies to functions, variables, class and structure names, member functions, and member data. For example, if you had two-dozen C++ classes, all with a member function named `print' (which is a keyword in Python), you could rename them all to `output' by specifying :

%rename(output) print; // Rename all `print' functions to `output'

SWIG does not normally perform any checks to see if the functions it wraps are already defined in the target scripting language. However, if you are careful about namespaces and your use of modules, you can usually avoid these problems.

Closely related to %rename is the %ignore directive. %ignore instructs SWIG to ignore declarations that match a given identifier. For example:

%ignore print;         // Ignore all declarations named print
%ignore MYMACRO;       // Ignore a macro
...
#define MYMACRO 123
void print(const char *);
...

Any function, variable etc which matches %ignore will not be wrapped and therefore will not be available from the target language. A common usage of %ignore is to selectively remove certain declarations from a header file without having to add conditional compilation to the header. However, it should be stressed that this only works for simple declarations. If you need to remove a whole section of problematic code, the SWIG preprocessor should be used instead.

Compatibility note: Older versions of SWIG provided a special %name directive for renaming declarations. For example:

%name(output) extern void print(const char *);

This directive is still supported, but it is deprecated and should probably be avoided. The %rename directive is more powerful and better supports wrapping of raw header file information.

5.4.7.2 Advanced renaming support

While writing %rename for specific declarations is simple enough, sometimes the same renaming rule needs to be applied to many, maybe all, identifiers in the SWIG input. For example, it may be necessary to apply some transformation to all the names in the target language to better follow its naming conventions, like adding a specific prefix to all wrapped functions. Doing it individually for each function is impractical so SWIG supports applying a renaming rule to all declarations if the name of the identifier to be renamed is not specified:

%rename("myprefix_%s") ""; // print -> myprefix_print

This also shows that the argument of %rename doesn't have to be a literal string but can be a printf()-like format string. In the simplest form, "%s" is replaced with the name of the original declaration, as shown above. However this is not always enough and SWIG provides extensions to the usual format string syntax to allow applying a (SWIG-defined) function to the argument. For example, to wrap all C functions do_something_long() as more Java-like doSomethingLong() you can use the "lowercamelcase" extended format specifier like this:

%rename("%(lowercamelcase)s") ""; // foo_bar -> fooBar; FooBar -> fooBar

Some functions can be parametrized, for example the "strip" one strips the provided prefix from its argument. The prefix is specified as part of the format string, following a colon after the function name:

%rename("%(strip:[wx])s") ""; // wxHello -> Hello; FooBar -> FooBar

Below is the table summarizing all currently defined functions with an example of applying each one. Note that some of them have two names, a shorter one and a more descriptive one, but the two functions are otherwise equivalent:

FunctionReturnsExample (in/out)
uppercase or upperUpper case version of the string.PrintPRINT
lowercase or lowerLower case version of the string.Printprint
titleString with first letter capitalized and the rest in lower case.printPrint
firstuppercaseString with the first letter capitalized and the rest unchanged.printIt PrintIt
firstlowercaseString with the first letter in lower case and the rest unchanged.PrintIt printIt
camelcase or ctitleString with capitalized first letter and any letter following an underscore (which are removed in the process) and rest in lower case. print_itPrintIt
lowercamelcase or lctitleString with every letter following an underscore (which is removed in the process) capitalized and rest, including the first letter, in lower case. print_itprintIt
undercase or utitleLower case string with underscores inserted before every upper case letter in the original string and any number not at the end of string. Logically, this is the reverse of camelcase.PrintIt print_it
schemifyString with all underscores replaced with dashes, resulting in more Lispers/Schemers-pleasing name. print_itprint-it
strip:[prefix]String without the given prefix or the original string if it doesn't start with this prefix. Note that square brackets should be used literally, e.g. %rename("strip:[wx]")wxPrintPrint
regex:/pattern/subst/String after (Perl-like) regex substitution operation. This function allows to apply arbitrary regular expressions to the identifier names. The pattern part is a regular expression in Perl syntax (as supported by the Perl Compatible Regular Expressions (PCRE)) library and the subst string can contain back-references of the form \N where N is a digit from 0 to 9, or one of the following escape sequences: \l, \L, \u, \U or \E. The back-references are replaced with the contents of the corresponding capture group while the escape sequences perform the case conversion in the substitution string: \l and \L convert to the lower case, while \u and \U convert to the upper case. The difference between the elements of each pair is that \l and \u change the case of the next character only, while \L and \U do it for all the remaining characters or until \E is encountered. Finally please notice that backslashes need to be escaped in C strings, so in practice "\\" must be used in all these escape sequences. For example, to remove any alphabetic prefix before an underscore and capitalize the remaining part you could use the following directive: %rename("regex:/(\\w+)_(.*)/\\u\\2/") prefix_printPrint
command:cmdOutput of an external command cmd with the string passed to it as input. Notice that this function is extremely slow compared to all the other ones as it involves spawning a separate process and using it for many declarations is not recommended. The cmd is not enclosed in square brackets but must be terminated with a triple '<' sign, e.g. %rename("command:tr -d aeiou <<<") (nonsensical example removing all vowels)PrintPrnt

The most general function of all of the above ones (not counting command which is even more powerful in principle but which should generally be avoided because of performance considerations) is the regex one. Here are some more examples of its use:

// Strip the wx prefix from all identifiers except those starting with wxEVT
%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; // wxSomeWidget -> SomeWidget
                                             // wxEVT_PAINT -> wxEVT_PAINT

// Apply a rule for renaming the enum elements to avoid the common prefixes
// which are redundant in C#/Java
%rename("%(regex:/^([A-Z][a-z]+)+_(.*)/\\2/)s", %$isenumitem) ""; // Colour_Red -> Red

// Remove all "Set/Get" prefixes.
%rename("%(regex:/^(Set|Get)(.*)/\\2/)s") ""; // SetValue -> Value
                                              // GetValue -> Value

As before, everything that was said above about %rename also applies to %ignore. In fact, the latter is just a special case of the former and ignoring an identifier is the same as renaming it to the special "$ignore" value. So the following snippets

%ignore print;

and

%rename("$ignore") print;

are exactly equivalent and %rename can be used to selectively ignore multiple declarations using the previously described matching possibilities.

5.4.7.3 Limiting global renaming rules

As explained in the previous sections, it is possible to either rename individual declarations or apply a rename rule to all of them at once. In practice, the latter is however rarely appropriate as there are always some exceptions to the general rules. To deal with them, the scope of an unnamed %rename can be limited using subsequent match parameters. They can be applied to any of the attributes associated by SWIG with the declarations appearing in its input. For example:

%rename("foo", match$name="bar") "";

can be used to achieve the same effect as the simpler

%rename("foo") bar;

and so is not very interesting on its own. However match can also be applied to the declaration type, for example match="class" restricts the match to class declarations only (in C++) and match="enumitem" restricts it to the enum elements. SWIG also provides convenience macros for such match expressions, for example

%rename("%(title)s", %$isenumitem) "";

will capitalize the names of all the enum elements but not change the case of the other declarations. Similarly, %$isclass, %$isfunction, %$isconstructor, %$isunion, %$istemplate, and %$isvariable can be used. Many other checks are possible and this documentation is not exhaustive, see the "%rename predicates" section in swig.swg for the full list of supported match expressions.

In addition to literally matching some string with match you can also use regexmatch or notregexmatch to match a string against a regular expression. For example, to ignore all functions having "Old" as a suffix you could use

%rename("$ignore", regexmatch$name="Old$") "";

For simple cases like this, specifying the regular expression for the declaration name directly can be preferable and can also be done using regextarget:

%rename("$ignore", regextarget=1) "Old$";

Notice that the check is done only against the name of the declaration itself, if you need to match the full name of a C++ declaration you must use fullname attribute:

%rename("$ignore", regextarget=1, fullname=1) "NameSpace::ClassName::.*Old$";

As for notregexmatch, it restricts the match only to the strings not matching the specified regular expression. So to rename all declarations to lower case except those consisting of capital letters only:

%rename("$(lower)s", notregexmatch$name="^[A-Z]+$") "";

Finally, variants of %rename and %ignore directives can be used to help wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the Ambiguity resolution and renaming section in the C++ chapter.

5.4.7.4 Ignoring everything then wrapping a few selected symbols

Using the techniques described above it is possible to ignore everything in a header and then selectively wrap a few chosen methods or classes. For example, consider a header, myheader.h which has many classes in it and just the one class called Star is wanted within this header, the following approach could be taken:

%ignore ""; // Ignore everything

// Unignore chosen class 'Star'
%rename("%s") Star;

// As the ignore everything will include the constructor, destructor, methods etc
// in the class, these have to be explicitly unignored too:
%rename("%s") Star::Star;
%rename("%s") Star::~Star;
%rename("%s") Star::shine; // named method

%include "myheader.h"

Another approach which might be more suitable as it does not require naming all the methods in the chosen class is to begin by ignoring just the classes. This does not add an explicit ignore to any members of the class, so when the chosen class is unignored, all of its methods will be wrapped.

%rename($ignore, %$isclass) ""; // Only ignore all classes
%rename("%s") Star; // Unignore 'Star'
%include "myheader.h"

5.4.8 Default/optional arguments

SWIG supports default arguments in both C and C++ code. For example:

int plot(double x, double y, int color=WHITE);

In this case, SWIG generates wrapper code where the default arguments are optional in the target language. For example, this function could be used in Tcl as follows :

% plot -3.4 7.5 				# Use default value
% plot -3.4 7.5 10				# set color to 10 instead

Although the ANSI C standard does not allow default arguments, default arguments specified in a SWIG interface work with both C and C++.

Note: There is a subtle semantic issue concerning the use of default arguments and the SWIG generated wrapper code. When default arguments are used in C code, the default values are emitted into the wrappers and the function is invoked with a full set of arguments. This is different to when wrapping C++ where an overloaded wrapper method is generated for each defaulted argument. Please refer to the section on default arguments in the C++ chapter for further details.

5.4.9 Pointers to functions and callbacks

Occasionally, a C library may include functions that expect to receive pointers to functions--possibly to serve as callbacks. SWIG provides full support for function pointers provided that the callback functions are defined in C and not in the target language. For example, consider a function like this:

int binary_op(int a, int b, int (*op)(int,int));

When you first wrap something like this into an extension module, you may find the function to be impossible to use. For instance, in Python:

>>> def add(x,y):
...     return x+y
...
>>> binary_op(3,4,add)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: Type error. Expected _p_f_int_int__int
>>>

The reason for this error is that SWIG doesn't know how to map a scripting language function into a C callback. However, existing C functions can be used as arguments provided you install them as constants. One way to do this is to use the %constant directive like this:

/* Function with a callback */
int binary_op(int a, int b, int (*op)(int,int));

/* Some callback functions */
%constant int add(int,int);
%constant int sub(int,int);
%constant int mul(int,int);

In this case, add, sub, and mul become function pointer constants in the target scripting language. This allows you to use them as follows:

>>> binary_op(3,4,add)
7
>>> binary_op(3,4,mul)
12
>>>

Unfortunately, by declaring the callback functions as constants, they are no longer accessible as functions. For example:

>>> add(3,4)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: object is not callable: '_ff020efc_p_f_int_int__int'
>>>

If you want to make a function available as both a callback function and a function, you can use the %callback and %nocallback directives like this:

/* Function with a callback */
int binary_op(int a, int b, int (*op)(int,int));

/* Some callback functions */
%callback("%s_cb");
int add(int,int);
int sub(int,int);
int mul(int,int);
%nocallback;

The argument to %callback is a printf-style format string that specifies the naming convention for the callback constants (%s gets replaced by the function name). The callback mode remains in effect until it is explicitly disabled using %nocallback. When you do this, the interface now works as follows:

>>> binary_op(3,4,add_cb)
7
>>> binary_op(3,4,mul_cb)
12
>>> add(3,4)
7
>>> mul(3,4)
12

Notice that when the function is used as a callback, special names such as add_cb are used instead. To call the function normally, just use the original function name such as add().

SWIG provides a number of extensions to standard C printf formatting that may be useful in this context. For instance, the following variation installs the callbacks as all upper case constants such as ADD, SUB, and MUL:

/* Some callback functions */
%callback("%(uppercase)s");
int add(int,int);
int sub(int,int);
int mul(int,int);
%nocallback;

A format string of "%(lowercase)s" converts all characters to lower case. A string of "%(title)s" capitalizes the first character and converts the rest to lower case.

And now, a final note about function pointer support. Although SWIG does not normally allow callback functions to be written in the target language, this can be accomplished with the use of typemaps and other advanced SWIG features. See the Typemaps chapter for more about typemaps and individual target language chapters for more on callbacks and the 'director' feature.

5.5 Structures and unions

This section describes the behavior of SWIG when processing ANSI C structures and union declarations. Extensions to handle C++ are described in the next section.

If SWIG encounters the definition of a structure or union, it creates a set of accessor functions. Although SWIG does not need structure definitions to build an interface, providing definitions makes it possible to access structure members. The accessor functions generated by SWIG simply take a pointer to an object and allow access to an individual member. For example, the declaration :

struct Vector {
	double x,y,z;
}

gets transformed into the following set of accessor functions :

double Vector_x_get(struct Vector *obj) {
	return obj->x;
}
double Vector_y_get(struct Vector *obj) { 
	return obj->y;
}
double Vector_z_get(struct Vector *obj) { 
	return obj->z;
}
void Vector_x_set(struct Vector *obj, double value) {
	obj->x = value;
}
void Vector_y_set(struct Vector *obj, double value) {
	obj->y = value;
}
void Vector_z_set(struct Vector *obj, double value) {
	obj->z = value;
}

In addition, SWIG creates default constructor and destructor functions if none are defined in the interface. For example:

struct Vector *new_Vector() {
    return (Vector *) calloc(1,sizeof(struct Vector));
}
void delete_Vector(struct Vector *obj) {
    free(obj);
}

Using these low-level accessor functions, an object can be minimally manipulated from the target language using code like this:

v = new_Vector()
Vector_x_set(v,2)
Vector_y_set(v,10)
Vector_z_set(v,-5)
...
delete_Vector(v)

However, most of SWIG's language modules also provide a high-level interface that is more convenient. Keep reading.

5.5.1 Typedef and structures

SWIG supports the following construct which is quite common in C programs :

typedef struct {
	double x,y,z;
} Vector;

When encountered, SWIG assumes that the name of the object is `Vector' and creates accessor functions like before. The only difference is that the use of typedef allows SWIG to drop the struct keyword on its generated code. For example:

double Vector_x_get(Vector *obj) {
	return obj->x;
}

If two different names are used like this :

typedef struct vector_struct {
	double x,y,z;
} Vector;

the name Vector is used instead of vector_struct since this is more typical C programming style. If declarations defined later in the interface use the type struct vector_struct, SWIG knows that this is the same as Vector and it generates the appropriate type-checking code.

5.5.2 Character strings and structures

Structures involving character strings require some care. SWIG assumes that all members of type char * have been dynamically allocated using malloc() and that they are NULL-terminated ASCII strings. When such a member is modified, the previous contents will be released, and the new contents allocated. For example :

%module mymodule
...
struct Foo {
	char *name;
	...
}

This results in the following accessor functions :

char *Foo_name_get(Foo *obj) {
	return Foo->name;
}

char *Foo_name_set(Foo *obj, char *c) {
	if (obj->name) free(obj->name);
	obj->name = (char *) malloc(strlen(c)+1);
	strcpy(obj->name,c);
	return obj->name;
}

If this behavior differs from what you need in your applications, the SWIG "memberin" typemap can be used to change it. See the typemaps chapter for further details.

Note: If the -c++ option is used, new and delete are used to perform memory allocation.

5.5.3 Array members

Arrays may appear as the members of structures, but they will be read-only. SWIG will write an accessor function that returns the pointer to the first element of the array, but will not write a function to change the contents of the array itself. When this situation is detected, SWIG may generate a warning message such as the following :

interface.i:116. Warning. Array member will be read-only

To eliminate the warning message, typemaps can be used, but this is discussed in a later chapter. In many cases, the warning message is harmless.

5.5.4 Structure data members

Occasionally, a structure will contain data members that are themselves structures. For example:

typedef struct Foo {
   int x;
} Foo;

typedef struct Bar {
   int y;
   Foo f;           /* struct member */
} Bar;

When a structure member is wrapped, it is handled as a pointer, unless the %naturalvar directive is used where it is handled more like a C++ reference (see C++ Member data). The accessors to the member variable as a pointer are effectively wrapped as follows:

Foo *Bar_f_get(Bar *b) {
   return &b->f;
}
void Bar_f_set(Bar *b, Foo *value) {
   b->f = *value;
}

The reasons for this are somewhat subtle but have to do with the problem of modifying and accessing data inside the data member. For example, suppose you wanted to modify the value of f.x of a Bar object like this:

Bar *b;
b->f.x = 37;

Translating this assignment to function calls (as would be used inside the scripting language interface) results in the following code:

Bar *b;
Foo_x_set(Bar_f_get(b),37);

In this code, if the Bar_f_get() function were to return a Foo instead of a Foo *, then the resulting modification would be applied to a copy of f and not the data member f itself. Clearly that's not what you want!

It should be noted that this transformation to pointers only occurs if SWIG knows that a data member is a structure or class. For instance, if you had a structure like this,

struct Foo {
   WORD   w;
};

and nothing was known about WORD, then SWIG will generate more normal accessor functions like this:

WORD Foo_w_get(Foo *f) {
    return f->w;
}
void Foo_w_set(FOO *f, WORD value) {
    f->w = value;
}

Compatibility Note: SWIG-1.3.11 and earlier releases transformed all non-primitive member datatypes to pointers. Starting in SWIG-1.3.12, this transformation only occurs if a datatype is known to be a structure, class, or union. This is unlikely to break existing code. However, if you need to tell SWIG that an undeclared datatype is really a struct, simply use a forward struct declaration such as "struct Foo;".

5.5.5 C constructors and destructors

When wrapping structures, it is generally useful to have a mechanism for creating and destroying objects. If you don't do anything, SWIG will automatically generate functions for creating and destroying objects using malloc() and free(). Note: the use of malloc() only applies when SWIG is used on C code (i.e., when the -c++ option is not supplied on the command line). C++ is handled differently.

If you don't want SWIG to generate default constructors for your interfaces, you can use the %nodefaultctor directive or the -nodefaultctor command line option. For example:

swig -nodefaultctor example.i 

or

%module foo
...
%nodefaultctor;        // Don't create default constructors
... declarations ...
%clearnodefaultctor;   // Re-enable default constructors

If you need more precise control, %nodefaultctor can selectively target individual structure definitions. For example:

%nodefaultctor Foo;      // No default constructor for Foo
...
struct Foo {             // No default constructor generated.
};

struct Bar {             // Default constructor generated.
};

Since ignoring the implicit or default destructors most of the time produces memory leaks, SWIG will always try to generate them. If needed, however, you can selectively disable the generation of the default/implicit destructor by using %nodefaultdtor

%nodefaultdtor Foo; // No default/implicit destructor for Foo
...
struct Foo {              // No default destructor is generated.
};

struct Bar {              // Default destructor generated.
};

Compatibility note: Prior to SWIG-1.3.7, SWIG did not generate default constructors or destructors unless you explicitly turned them on using -make_default. However, it appears that most users want to have constructor and destructor functions so it has now been enabled as the default behavior.

Note: There are also the -nodefault option and %nodefault directive, which disable both the default or implicit destructor generation. This could lead to memory leaks across the target languages, and it is highly recommended you don't use them.

5.5.6 Adding member functions to C structures

Most languages provide a mechanism for creating classes and supporting object oriented programming. From a C standpoint, object oriented programming really just boils down to the process of attaching functions to structures. These functions normally operate on an instance of the structure (or object). Although there is a natural mapping of C++ to such a scheme, there is no direct mechanism for utilizing it with C code. However, SWIG provides a special %extend directive that makes it possible to attach methods to C structures for purposes of building an object oriented interface. Suppose you have a C header file with the following declaration :

/* file : vector.h */
...
typedef struct Vector {
	double x,y,z;
} Vector;

You can make a Vector look a lot like a class by writing a SWIG interface like this:

// file : vector.i
%module mymodule
%{
#include "vector.h"
%}

%include "vector.h"          // Just grab original C header file
%extend Vector {             // Attach these functions to struct Vector
	Vector(double x, double y, double z) {
		Vector *v;
		v = (Vector *) malloc(sizeof(Vector));
		v->x = x;
		v->y = y;
		v->z = z;
		return v;
	}
	~Vector() {
		free($self);
	}
	double magnitude() {
		return sqrt($self->x*$self->x+$self->y*$self->y+$self->z*$self->z);
	}
	void print() {
		printf("Vector [%g, %g, %g]\n", $self->x,$self->y,$self->z);
	}
};

Note the usage of the $self special variable. Its usage is identical to a C++ 'this' pointer and should be used whenever access to the struct instance is required. Also note that C++ constructor and destructor syntax has been used to simulate a constructor and destructor, even for C code. There is one subtle difference to a normal C++ constructor implementation though and that is although the constructor declaration is as per a normal C++ constructor, the newly constructed object must be returned as if the constructor declaration had a return value, a Vector * in this case.

Now, when used with proxy classes in Python, you can do things like this :

>>> v = Vector(3,4,0)                 # Create a new vector
>>> print v.magnitude()                # Print magnitude
5.0
>>> v.print()                  # Print it out
[ 3, 4, 0 ]
>>> del v                      # Destroy it

The %extend directive can also be used inside the definition of the Vector structure. For example:

// file : vector.i
%module mymodule
%{
#include "vector.h"
%}

typedef struct Vector {
	double x,y,z;
	%extend {
		Vector(double x, double y, double z) { ... }
		~Vector() { ... }
		...
	}
} Vector;

Note that %extend can be used to access externally written functions provided they follow the naming convention used in this example :

/* File : vector.c */
/* Vector methods */
#include "vector.h"
Vector *new_Vector(double x, double y, double z) {
	Vector *v;
	v = (Vector *) malloc(sizeof(Vector));
	v->x = x;
	v->y = y;
	v->z = z;
	return v;
}
void delete_Vector(Vector *v) {
	free(v);
}

double Vector_magnitude(Vector *v) {
	return sqrt(v->x*v->x+v->y*v->y+v->z*v->z);
}

// File : vector.i
// Interface file
%module mymodule
%{
#include "vector.h"
%}

typedef struct Vector {
	double x,y,z;
	%extend {
                Vector(int,int,int); // This calls new_Vector()
               ~Vector();            // This calls delete_Vector()
		double magnitude();  // This will call Vector_magnitude()
		...
	}
} Vector;

The name used for %extend should be the name of the struct and not the name of any typedef to the struct. For example:

typedef struct Integer {
	int value;
} Int;
%extend Integer { ...  } /* Correct name */
%extend Int { ...  } /* Incorrect name */

struct Float {
	float value;
};
typedef struct Float FloatValue;
%extend Float { ...  } /* Correct name */
%extend FloatValue { ...  } /* Incorrect name */

There is one exception to this rule and that is when the struct is anonymously named such as:

typedef struct {
	double value;
} Double;
%extend Double { ...  } /* Okay */

A little known feature of the %extend directive is that it can also be used to add synthesized attributes or to modify the behavior of existing data attributes. For example, suppose you wanted to make magnitude a read-only attribute of Vector instead of a method. To do this, you might write some code like this:

// Add a new attribute to Vector
%extend Vector {
    const double magnitude;
}
// Now supply the implementation of the Vector_magnitude_get function
%{
const double Vector_magnitude_get(Vector *v) {
  return (const double) sqrt(v->x*v->x+v->y*v->y+v->z*v->z);
}
%}

Now, for all practical purposes, magnitude will appear like an attribute of the object.

A similar technique can also be used to work with data members that you want to process. For example, consider this interface:

typedef struct Person {
  char name[50];
  ...
} Person;

Say you wanted to ensure name was always upper case, you can rewrite the interface as follows to ensure this occurs whenever a name is read or written to:

typedef struct Person {
  %extend {
    char name[50];
  }
  ...
} Person;

%{
#include <string.h>
#include <ctype.h>

void make_upper(char *name) {
  char *c;
  for (c = name; *c; ++c)
    *c = (char)toupper((int)*c);
}

/* Specific implementation of set/get functions forcing capitalization */

char *Person_name_get(Person *p) {
  make_upper(p->name);
  return p->name;
}

void Person_name_set(Person *p, char *val) {
  strncpy(p->name,val,50);
  make_upper(p->name);
}
%}

Finally, it should be stressed that even though %extend can be used to add new data members, these new members can not require the allocation of additional storage in the object (e.g., their values must be entirely synthesized from existing attributes of the structure or obtained elsewhere).

Compatibility note: The %extend directive is a new name for the %addmethods directive. Since %addmethods could be used to extend a structure with more than just methods, a more suitable directive name has been chosen.

5.5.7 Nested structures

Occasionally, a C program will involve structures like this :

typedef struct Object {
	int objtype;
	union {
		int 	ivalue;
		double	dvalue;
		char	*strvalue;
		void	*ptrvalue;
	} intRep;
} Object;

When SWIG encounters this, it performs a structure splitting operation that transforms the declaration into the equivalent of the following:

typedef union {
	int 		ivalue;
	double		dvalue;
	char		*strvalue;
	void		*ptrvalue;
} Object_intRep;

typedef struct Object {
	int objType;
	Object_intRep intRep;
} Object;

SWIG will then create an Object_intRep structure for use inside the interface file. Accessor functions will be created for both structures. In this case, functions like this would be created :

Object_intRep *Object_intRep_get(Object *o) {
	return (Object_intRep *) &o->intRep;
}
int Object_intRep_ivalue_get(Object_intRep *o) {
	return o->ivalue;
}
int Object_intRep_ivalue_set(Object_intRep *o, int value) {
	return (o->ivalue = value);
}
double Object_intRep_dvalue_get(Object_intRep *o) {
	return o->dvalue;
}
... etc ...

Although this process is a little hairy, it works like you would expect in the target scripting language--especially when proxy classes are used. For instance, in Perl:

# Perl5 script for accessing nested member
$o = CreateObject();                    # Create an object somehow
$o->{intRep}->{ivalue} = 7              # Change value of o.intRep.ivalue

If you have a lot of nested structure declarations, it is advisable to double-check them after running SWIG. Although, there is a good chance that they will work, you may have to modify the interface file in certain cases.

Finally, note that nesting is handled differently in C++ mode, see Nested classes.

5.5.8 Other things to note about structure wrapping

SWIG doesn't care if the declaration of a structure in a .i file exactly matches that used in the underlying C code (except in the case of nested structures). For this reason, there are no problems omitting problematic members or simply omitting the structure definition altogether. If you are happy passing pointers around, this can be done without ever giving SWIG a structure definition.

Starting with SWIG1.3, a number of improvements have been made to SWIG's code generator. Specifically, even though structure access has been described in terms of high-level accessor functions such as this,

double Vector_x_get(Vector *v) {
   return v->x;
}

most of the generated code is actually inlined directly into wrapper functions. Therefore, no function Vector_x_get() actually exists in the generated wrapper file. For example, when creating a Tcl module, the following function is generated instead:

static int
_wrap_Vector_x_get(ClientData clientData, Tcl_Interp *interp, 
                   int objc, Tcl_Obj *CONST objv[]) {
    struct Vector *arg1 ;
    double result ;
    
    if (SWIG_GetArgs(interp, objc, objv,"p:Vector_x_get self ",&arg0,
                     SWIGTYPE_p_Vector) == TCL_ERROR)
         return TCL_ERROR;
    result = (double ) (arg1->x);
    Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) result));
    return TCL_OK;
}

The only exception to this rule are methods defined with %extend . In this case, the added code is contained in a separate function.

Finally, it is important to note that most language modules may choose to build a more advanced interface. Although you may never use the low-level interface described here, most of SWIG's language modules use it in some way or another.

5.6 Code Insertion

Sometimes it is necessary to insert special code into the resulting wrapper file generated by SWIG. For example, you may want to include additional C code to perform initialization or other operations. There are four common ways to insert code, but it's useful to know how the output of SWIG is structured first.

5.6.1 The output of SWIG

When SWIG creates its output file, it is broken up into five sections corresponding to runtime code, headers, wrapper functions, and module initialization code (in that order).

  • Begin section.
    A placeholder for users to put code at the beginning of the C/C++ wrapper file. This is most often used to define preprocessor macros that are used in later sections.
  • Runtime code.
    This code is internal to SWIG and is used to include type-checking and other support functions that are used by the rest of the module.
  • Header section.
    This is user-defined support code that has been included by the %{ ... %} directive. Usually this consists of header files and other helper functions.
  • Wrapper code.
    These are the wrappers generated automatically by SWIG.
  • Module initialization.
    The function generated by SWIG to initialize the module upon loading.

5.6.2 Code insertion blocks

Code is inserted into the appropriate code section by using one of the code insertion directives listed below. The order of the sections in the wrapper file is as shown:

%begin %{
   ... code in begin section ...
%}

%runtime %{
   ... code in runtime section ...
%}

%header %{
   ... code in header section ...
%}

%wrapper %{
   ... code in wrapper section ...
%}

%init %{
   ... code in init section ...
%}

The bare %{ ... %} directive is a shortcut that is the same as %header %{ ... %}.

The %begin section is effectively empty as it just contains the SWIG banner by default. This section is provided as a way for users to insert code at the top of the wrapper file before any other code is generated. Everything in a code insertion block is copied verbatim into the output file and is not parsed by SWIG. Most SWIG input files have at least one such block to include header files and support C code. Additional code blocks may be placed anywhere in a SWIG file as needed.

%module mymodule
%{
#include "my_header.h"
%}
... Declare functions here
%{

void some_extra_function() {
  ...
}
%}

A common use for code blocks is to write "helper" functions. These are functions that are used specifically for the purpose of building an interface, but which are generally not visible to the normal C program. For example :

%{
/* Create a new vector */
static Vector *new_Vector() {
	return (Vector *) malloc(sizeof(Vector));
}

%}
// Now wrap it 
Vector *new_Vector();

5.6.3 Inlined code blocks

Since the process of writing helper functions is fairly common, there is a special inlined form of code block that is used as follows :

%inline %{
/* Create a new vector */
Vector *new_Vector() {
	return (Vector *) malloc(sizeof(Vector));
}
%}

The %inline directive inserts all of the code that follows verbatim into the header portion of an interface file. The code is then parsed by both the SWIG preprocessor and parser. Thus, the above example creates a new command new_Vector using only one declaration. Since the code inside an %inline %{ ... %} block is given to both the C compiler and SWIG, it is illegal to include any SWIG directives inside a %{ ... %} block.

5.6.4 Initialization blocks

When code is included in the %init section, it is copied directly into the module initialization function. For example, if you needed to perform some extra initialization on module loading, you could write this:

%init %{
	init_variables();
%}

5.7 An Interface Building Strategy

This section describes the general approach for building interfaces with SWIG. The specifics related to a particular scripting language are found in later chapters.

5.7.1 Preparing a C program for SWIG

SWIG doesn't require modifications to your C code, but if you feed it a collection of raw C header files or source code, the results might not be what you expect---in fact, they might be awful. Here's a series of steps you can follow to make an interface for a C program :

  • Identify the functions that you want to wrap. It's probably not necessary to access every single function of a C program--thus, a little forethought can dramatically simplify the resulting scripting language interface. C header files are a particularly good source for finding things to wrap.
  • Create a new interface file to describe the scripting language interface to your program.
  • Copy the appropriate declarations into the interface file or use SWIG's %include directive to process an entire C source/header file.
  • Make sure everything in the interface file uses ANSI C/C++ syntax.
  • Make sure all necessary `typedef' declarations and type-information is available in the interface file. In particular, ensure that the type information is specified in the correct order as required by a C/C++ compiler. Most importantly, define a type before it is used! A C compiler will tell you if the full type information is not available if it is needed, whereas SWIG will usually not warn or error out as it is designed to work without full type information. However, if type information is not specified correctly, the wrappers can be sub-optimal and even result in uncompileable C/C++ code.
  • If your program has a main() function, you may need to rename it (read on).
  • Run SWIG and compile.

Although this may sound complicated, the process turns out to be fairly easy once you get the hang of it.

In the process of building an interface, SWIG may encounter syntax errors or other problems. The best way to deal with this is to simply copy the offending code into a separate interface file and edit it. However, the SWIG developers have worked very hard to improve the SWIG parser--you should report parsing errors to the swig-devel mailing list or to the SWIG bug tracker.

5.7.2 The SWIG interface file

The preferred method of using SWIG is to generate a separate interface file. Suppose you have the following C header file :

/* File : header.h */

#include <stdio.h>
#include <math.h>

extern int foo(double);
extern double bar(int, int);
extern void dump(FILE *f);

A typical SWIG interface file for this header file would look like the following :

/* File : interface.i */
%module mymodule
%{
#include "header.h"
%}
extern int foo(double);
extern double bar(int, int);
extern void dump(FILE *f);

Of course, in this case, our header file is pretty simple so we could use a simpler approach and use an interface file like this:

/* File : interface.i */
%module mymodule
%{
#include "header.h"
%}
%include "header.h"

The main advantage of this approach is minimal maintenance of an interface file for when the header file changes in the future. In more complex projects, an interface file containing numerous %include and #include statements like this is one of the most common approaches to interface file design due to lower maintenance overhead.

5.7.3 Why use separate interface files?

Although SWIG can parse many header files, it is more common to write a special .i file defining the interface to a package. There are several reasons why you might want to do this:

  • It is rarely necessary to access every single function in a large package. Many C functions might have little or no use in a scripted environment. Therefore, why wrap them?
  • Separate interface files provide an opportunity to provide more precise rules about how an interface is to be constructed.
  • Interface files can provide more structure and organization.
  • SWIG can't parse certain definitions that appear in header files. Having a separate file allows you to eliminate or work around these problems.
  • Interface files provide a more precise definition of what the interface is. Users wanting to extend the system can go to the interface file and immediately see what is available without having to dig it out of header files.

5.7.4 Getting the right header files

Sometimes, it is necessary to use certain header files in order for the code generated by SWIG to compile properly. Make sure you include certain header files by using a %{,%} block like this:

%module graphics
%{
#include <GL/gl.h>
#include <GL/glu.h>
%}

// Put the rest of the declarations here
...

5.7.5 What to do with main()

If your program defines a main() function, you may need to get rid of it or rename it in order to use a scripting language. Most scripting languages define their own main() procedure that is called instead. main() also makes no sense when working with dynamic loading. There are a few approaches to solving the main() conflict :

  • Get rid of main() entirely.
  • Rename main() to something else. You can do this by compiling your C program with an option like -Dmain=oldmain.
  • Use conditional compilation to only include main() when not using a scripting language.

Getting rid of main() may cause potential initialization problems of a program. To handle this problem, you may consider writing a special function called program_init() that initializes your program upon startup. This function could then be called either from the scripting language as the first operation, or when the SWIG generated module is loaded.

As a general note, many C programs only use the main() function to parse command line options and to set parameters. However, by using a scripting language, you are probably trying to create a program that is more interactive. In many cases, the old main() program can be completely replaced by a Perl, Python, or Tcl script.

Note: In some cases, you might be inclined to create a scripting language wrapper for main(). If you do this, the compilation will probably work and your module might even load correctly. The only trouble is that when you call your main() wrapper, you will find that it actually invokes the main() of the scripting language interpreter itself! This behavior is a side effect of the symbol binding mechanism used in the dynamic linker. The bottom line: don't do this.


6 SWIG and C++

This chapter describes SWIG's support for wrapping C++. As a prerequisite, you should first read the chapter SWIG Basics to see how SWIG wraps ANSI C. Support for C++ builds upon ANSI C wrapping and that material will be useful in understanding this chapter.

6.1 Comments on C++ Wrapping

Because of its complexity and the fact that C++ can be difficult to integrate with itself let alone other languages, SWIG only provides support for a subset of C++ features. Fortunately, this is now a rather large subset.

In part, the problem with C++ wrapping is that there is no semantically obvious (or automatic ) way to map many of its advanced features into other languages. As a simple example, consider the problem of wrapping C++ multiple inheritance to a target language with no such support. Similarly, the use of overloaded operators and overloaded functions can be problematic when no such capability exists in a target language.

A more subtle issue with C++ has to do with the way that some C++ programmers think about programming libraries. In the world of SWIG, you are really trying to create binary-level software components for use in other languages. In order for this to work, a "component" has to contain real executable instructions and there has to be some kind of binary linking mechanism for accessing its functionality. In contrast, C++ has increasingly relied upon generic programming and templates for much of its functionality. Although templates are a powerful feature, they are largely orthogonal to the whole notion of binary components and libraries. For example, an STL vector does not define any kind of binary object for which SWIG can just create a wrapper. To further complicate matters, these libraries often utilize a lot of behind the scenes magic in which the semantics of seemingly basic operations (e.g., pointer dereferencing, procedure call, etc.) can be changed in dramatic and sometimes non-obvious ways. Although this "magic" may present few problems in a C++-only universe, it greatly complicates the problem of crossing language boundaries and provides many opportunities to shoot yourself in the foot. You will just have to be careful.

6.2 Approach

To wrap C++, SWIG uses a layered approach to code generation. At the lowest level, SWIG generates a collection of procedural ANSI-C style wrappers. These wrappers take care of basic type conversion, type checking, error handling, and other low-level details of the C++ binding. These wrappers are also sufficient to bind C++ into any target language that supports built-in procedures. In some sense, you might view this layer of wrapping as providing a C library interface to C++. On top of the low-level procedural (flattened) interface, SWIG generates proxy classes that provide a natural object-oriented (OO) interface to the underlying code. The proxy classes are typically written in the target language itself. For instance, in Python, a real Python class is used to provide a wrapper around the underlying C++ object.

It is important to emphasize that SWIG takes a deliberately conservative and non-intrusive approach to C++ wrapping. SWIG does not encapsulate C++ classes inside a special C++ adaptor, it does not rely upon templates, nor does it add in additional C++ inheritance when generating wrappers. The last thing that most C++ programs need is even more compiler magic. Therefore, SWIG tries to maintain a very strict and clean separation between the implementation of your C++ application and the resulting wrapper code. You might say that SWIG has been written to follow the principle of least surprise--it does not play sneaky tricks with the C++ type system, it doesn't mess with your class hierarchies, and it doesn't introduce new semantics. Although this approach might not provide the most seamless integration with C++, it is safe, simple, portable, and debuggable.

Some of this chapter focuses on the low-level procedural interface to C++ that is used as the foundation for all language modules. Keep in mind that the target languages also provide the high-level OO interface via proxy classes. More detailed coverage can be found in the documentation for each target language.

6.3 Supported C++ features

SWIG currently supports most C++ features including the following:

  • Classes
  • Constructors and destructors
  • Virtual functions
  • Public inheritance (including multiple inheritance)
  • Static functions
  • Function and method overloading
  • Operator overloading for many standard operators
  • References
  • Templates (including specialization and member templates)
  • Pointers to members
  • Namespaces
  • Default parameters
  • Smart pointers

The following C++ features are not currently supported:

  • Overloaded versions of certain operators (new, delete, etc.)

As a rule of thumb, SWIG should not be used on raw C++ source files, use header files only.

SWIG's C++ support is an ongoing project so some of these limitations may be lifted in future releases. However, we make no promises. Also, submitting a bug report is a very good way to get problems fixed (wink).

6.4 Command line options and compilation

When wrapping C++ code, it is critical that SWIG be called with the `-c++' option. This changes the way a number of critical features such as memory management are handled. It also enables the recognition of C++ keywords. Without the -c++ flag, SWIG will either issue a warning or a large number of syntax errors if it encounters C++ code in an interface file.

When compiling and linking the resulting wrapper file, it is normal to use the C++ compiler. For example:

$ swig -c++ -tcl example.i
$ c++ -fPIC -c example_wrap.cxx 
$ c++ example_wrap.o $(OBJS) -o example.so

Unfortunately, the process varies slightly on each platform. Make sure you refer to the documentation on each target language for further details. The SWIG Wiki also has further details.

Compatibility Note: Early versions of SWIG generated just a flattened low-level C style API to C++ classes by default. The -noproxy commandline option is recognised by many target languages and will generate just this interface as in earlier versions.

6.5 Proxy classes

In order to provide a natural mapping from C++ classes to the target language classes, SWIG's target languages mostly wrap C++ classes with special proxy classes. These proxy classes are typically implemented in the target language itself. For example, if you're building a Python module, each C++ class is wrapped by a Python proxy class. Or if you're building a Java module, each C++ class is wrapped by a Java proxy class.

6.5.1 Construction of proxy classes

Proxy classes are always constructed as an extra layer of wrapping that uses low-level accessor functions. To illustrate, suppose you had a C++ class like this:

class Foo {
public:
      Foo();
     ~Foo();
      int  bar(int x);
      int  x;
};

Using C++ as pseudocode, a proxy class looks something like this:

class FooProxy {
private:
      Foo    *self;
public:
      FooProxy() {
            self = new_Foo();
      }
     ~FooProxy() {
            delete_Foo(self);
      }
      int bar(int x) {
            return Foo_bar(self,x);
      }
      int x_get() {
            return Foo_x_get(self);
      }
      void x_set(int x) {
            Foo_x_set(self,x);
      }
};

Of course, always keep in mind that the real proxy class is written in the target language. For example, in Python, the proxy might look roughly like this:

class Foo:
    def __init__(self):
         self.this = new_Foo()
    def __del__(self):
         delete_Foo(self.this)
    def bar(self,x):
         return Foo_bar(self.this,x)
    def __getattr__(self,name):
         if name == 'x':
              return Foo_x_get(self.this)
         ...
    def __setattr__(self,name,value):
         if name == 'x':
              Foo_x_set(self.this,value)
         ...

Again, it's important to emphasize that the low-level accessor functions are always used by the proxy classes. Whenever possible, proxies try to take advantage of language features that are similar to C++. This might include operator overloading, exception handling, and other features.

6.5.2 Resource management in proxies

A major issue with proxies concerns the memory management of wrapped objects. Consider the following C++ code:

class Foo {
public:
      Foo();
     ~Foo();
      int bar(int x);
      int x;
};

class Spam {
public:
      Foo *value;
      ...
};

Consider some script code that uses these classes:

f = Foo()               # Creates a new Foo
s = Spam()              # Creates a new Spam
s.value = f             # Stores a reference to f inside s
g = s.value             # Returns stored reference
g = 4                   # Reassign g to some other value
del f                   # Destroy f 

Now, ponder the resulting memory management issues. When objects are created in the script, the objects are wrapped by newly created proxy classes. That is, there is both a new proxy class instance and a new instance of the underlying C++ class. In this example, both f and s are created in this way. However, the statement s.value is rather curious---when executed, a pointer to f is stored inside another object. This means that the scripting proxy class AND another C++ class share a reference to the same object. To make matters even more interesting, consider the statement g = s.value. When executed, this creates a new proxy class g that provides a wrapper around the C++ object stored in s.value . In general, there is no way to know where this object came from---it could have been created by the script, but it could also have been generated internally. In this particular example, the assignment of g results in a second proxy class for f. In other words, a reference to f is now shared by two proxy classes and a C++ class.

Finally, consider what happens when objects are destroyed. In the statement, g=4, the variable g is reassigned. In many languages, this makes the old value of g available for garbage collection. Therefore, this causes one of the proxy classes to be destroyed. Later on, the statement del f destroys the other proxy class. Of course, there is still a reference to the original object stored inside another C++ object. What happens to it? Is the object still valid?

To deal with memory management problems, proxy classes provide an API for controlling ownership. In C++ pseudocode, ownership control might look roughly like this:

class FooProxy {
public:
      Foo    *self;
      int     thisown;

      FooProxy() {
            self = new_Foo();
            thisown = 1;       // Newly created object
      }
     ~FooProxy() {
            if (thisown) delete_Foo(self);
      }
      ...
      // Ownership control API
      void disown() {
           thisown = 0;
      }
      void acquire() {
           thisown = 1;
      }
};

class FooPtrProxy: public FooProxy {
public:
      FooPtrProxy(Foo *s) {
          self = s;
          thisown = 0;
      }
};

class SpamProxy {
     ...
     FooProxy *value_get() {
          return FooPtrProxy(Spam_value_get(self));
     }
     void value_set(FooProxy *v) {
          Spam_value_set(self,v->self);
          v->disown();
     }
     ...
};

Looking at this code, there are a few central features:

  • Each proxy class keeps an extra flag to indicate ownership. C++ objects are only destroyed if the ownership flag is set.
  • When new objects are created in the target language, the ownership flag is set.
  • When a reference to an internal C++ object is returned, it is wrapped by a proxy class, but the proxy class does not have ownership.
  • In certain cases, ownership is adjusted. For instance, when a value is assigned to the member of a class, ownership is lost.
  • Manual ownership control is provided by special disown() and acquire() methods.

Given the tricky nature of C++ memory management, it is impossible for proxy classes to automatically handle every possible memory management problem. However, proxies do provide a mechanism for manual control that can be used (if necessary) to address some of the more tricky memory management problems.

6.5.3 Language specific details

Language specific details on proxy classes are contained in the chapters describing each target language. This chapter has merely introduced the topic in a very general way.

6.6 Simple C++ wrapping

The following code shows a SWIG interface file for a simple C++ class.

%module list
%{
#include "list.h"
%}

// Very simple C++ example for linked list

class List {
public:
  List();
  ~List();
  int  search(char *value);
  void insert(char *);
  void remove(char *);
  char *get(int n);
  int  length;
static void print(List *l);
};

To generate wrappers for this class, SWIG first reduces the class to a collection of low-level C-style accessor functions which are then used by the proxy classes.

6.6.1 Constructors and destructors

C++ constructors and destructors are translated into accessor functions such as the following :

List * new_List(void) {
	return new List;
}
void delete_List(List *l) {
	delete l;
}

6.6.2 Default constructors, copy constructors and implicit destructors

Following the C++ rules for implicit constructor and destructors, SWIG will automatically assume there is one even when they are not explicitly declared in the class interface.

In general then:

  • If a C++ class does not declare any explicit constructor, SWIG will automatically generate a wrapper for one.
  • If a C++ class does not declare an explicit copy constructor, SWIG will automatically generate a wrapper for one if the %copyctor is used.
  • If a C++ class does not declare an explicit destructor, SWIG will automatically generate a wrapper for one.

And as in C++, a few rules that alters the previous behavior:

  • A default constructor is not created if a class already defines a constructor with arguments.
  • Default constructors are not generated for classes with pure virtual methods or for classes that inherit from an abstract class, but don't provide definitions for all of the pure methods.
  • A default constructor is not created unless all base classes support a default constructor.
  • Default constructors and implicit destructors are not created if a class defines them in a private or protected section.
  • Default constructors and implicit destructors are not created if any base class defines a non-public default constructor or destructor.

SWIG should never generate a default constructor, copy constructor or default destructor wrapper for a class in which it is illegal to do so. In some cases, however, it could be necessary (if the complete class declaration is not visible from SWIG, and one of the above rules is violated) or desired (to reduce the size of the final interface) by manually disabling the implicit constructor/destructor generation.

To manually disable these, the %nodefaultctor and %nodefaultdtor feature flag directives can be used. Note that these directives only affects the implicit generation, and they have no effect if the default/copy constructors or destructor are explicitly declared in the class interface.

For example:

%nodefaultctor Foo;  // Disable the default constructor for class Foo.
class Foo {          // No default constructor is generated, unless one is declared
...
};
class Bar {          // A default constructor is generated, if possible
...
};

The directive %nodefaultctor can also be applied "globally", as in:

%nodefaultctor; // Disable creation of default constructors
class Foo {     // No default constructor is generated, unless one is declared
...
};
class Bar {   
public:
  Bar();        // The default constructor is generated, since one is declared
};
%clearnodefaultctor; // Enable the creation of default constructors again

The corresponding %nodefaultdtor directive can be used to disable the generation of the default or implicit destructor, if needed. Be aware, however, that this could lead to memory leaks in the target language. Hence, it is recommended to use this directive only in well known cases. For example:

%nodefaultdtor Foo;   // Disable the implicit/default destructor for class Foo.
class Foo {           // No destructor is generated, unless one is declared
...
};

Compatibility Note: The generation of default constructors/implicit destructors was made the default behavior in SWIG 1.3.7. This may break certain older modules, but the old behavior can be easily restored using %nodefault or the -nodefault command line option. Furthermore, in order for SWIG to properly generate (or not generate) default constructors, it must be able to gather information from both the private and protected sections (specifically, it needs to know if a private or protected constructor/destructor is defined). In older versions of SWIG, it was fairly common to simply remove or comment out the private and protected sections of a class due to parser limitations. However, this removal may now cause SWIG to erroneously generate constructors for classes that define a constructor in those sections. Consider restoring those sections in the interface or using %nodefault to fix the problem.

Note: The %nodefault directive/-nodefault options described above, which disable both the default constructor and the implicit destructors, could lead to memory leaks, and so it is strongly recommended to not use them.

6.6.3 When constructor wrappers aren't created

If a class defines a constructor, SWIG normally tries to generate a wrapper for it. However, SWIG will not generate a constructor wrapper if it thinks that it will result in illegal wrapper code. There are really two cases where this might show up.

First, SWIG won't generate wrappers for protected or private constructors. For example:

class Foo {
protected:
     Foo();         // Not wrapped.
public:
      ...
};

Next, SWIG won't generate wrappers for a class if it appears to be abstract--that is, it has undefined pure virtual methods. Here are some examples:

class Bar {
public:
     Bar();               // Not wrapped.  Bar is abstract.
     virtual void spam(void) = 0; 
};

class Grok : public Bar {
public:
      Grok();            // Not wrapped. No implementation of abstract spam().
};

Some users are surprised (or confused) to find missing constructor wrappers in their interfaces. In almost all cases, this is caused when classes are determined to be abstract. To see if this is the case, run SWIG with all of its warnings turned on:

% swig -Wall -python module.i

In this mode, SWIG will issue a warning for all abstract classes. It is possible to force a class to be non-abstract using this:

%feature("notabstract") Foo;

class Foo : public Bar {
public:
     Foo();    // Generated no matter what---not abstract. 
     ...
};

More information about %feature can be found in the Customization features chapter.

6.6.4 Copy constructors

If a class defines more than one constructor, its behavior depends on the capabilities of the target language. If overloading is supported, the copy constructor is accessible using the normal constructor function. For example, if you have this:

class List {
public:
    List();    
    List(const List &);      // Copy constructor
    ...
};

then the copy constructor can be used as follows:

x = List()               # Create a list
y = List(x)              # Copy list x

If the target language does not support overloading, then the copy constructor is available through a special function like this:

List *copy_List(List *f) {
    return new List(*f);
}

Note: For a class X, SWIG only treats a constructor as a copy constructor if it can be applied to an object of type X or X *. If more than one copy constructor is defined, only the first definition that appears is used as the copy constructor--other definitions will result in a name-clash. Constructors such as X(const X &), X(X &), and X(X *) are handled as copy constructors in SWIG.

Note: SWIG does not generate a copy constructor wrapper unless one is explicitly declared in the class. This differs from the treatment of default constructors and destructors. However, copy constructor wrappers can be generated if using the copyctor feature flag. For example:

%copyctor List;

class List {
public:
    List();    
};

Will generate a copy constructor wrapper for List.

Compatibility note: Special support for copy constructors was not added until SWIG-1.3.12. In previous versions, copy constructors could be wrapped, but they had to be renamed. For example:

class Foo {
public:
    Foo();
  %name(CopyFoo) Foo(const Foo &);
    ...
};

For backwards compatibility, SWIG does not perform any special copy-constructor handling if the constructor has been manually renamed. For instance, in the above example, the name of the constructor is set to new_CopyFoo(). This is the same as in older versions.

6.6.5 Member functions

All member functions are roughly translated into accessor functions like this :

int List_search(List *obj, char *value) {
	return obj->search(value);
}

This translation is the same even if the member function has been declared as virtual.

It should be noted that SWIG does not actually create a C accessor function in the code it generates. Instead, member access such as obj->search(value) is directly inlined into the generated wrapper functions. However, the name and calling convention of the low-level procedural wrappers match the accessor function prototype described above.

6.6.6 Static members

Static member functions are called directly without making any special transformations. For example, the static member function print(List *l) directly invokes List::print(List *l) in the generated wrapper code.

6.6.7 Member data

Member data is handled in exactly the same manner as for C structures. A pair of accessor functions are effectively created. For example :

int List_length_get(List *obj) {
	return obj->length;
}
int List_length_set(List *obj, int value) {
	obj->length = value;
	return value;
}

A read-only member can be created using the %immutable and %mutable feature flag directive. For example, we probably wouldn't want the user to change the length of a list so we could do the following to make the value available, but read-only.

class List {
public:
...
%immutable;
	int length;
%mutable;
...
};

Alternatively, you can specify an immutable member in advance like this:

%immutable List::length;
...
class List {
   ...
   int length;         // Immutable by above directive
   ...
};

Similarly, all data attributes declared as const are wrapped as read-only members.

By default, SWIG uses the const reference typemaps for members that are primitive types. There are some subtle issues when wrapping data members that are not primitive types, such as classes. For instance, if you had another class like this,

class Foo {
public:
    List items;
    ...

then the low-level accessor to the items member actually uses pointers. For example:

List *Foo_items_get(Foo *self) {
    return &self->items;
}
void Foo_items_set(Foo *self, List *value) {
    self->items = *value;
}

More information about this can be found in the SWIG Basics chapter, Structure data members section.

The wrapper code to generate the accessors for classes comes from the pointer typemaps. This can be somewhat unnatural for some types. For example, a user would expect the STL std::string class member variables to be wrapped as a string in the target language, rather than a pointer to this class. The const reference typemaps offer this type of marshalling, so there is a feature to tell SWIG to use the const reference typemaps rather than the pointer typemaps. It is the naturalvar feature and can be used to effectively change the way accessors are generated to the following:

const List &Foo_items_get(Foo *self) {
    return self->items;
}
void Foo_items_set(Foo *self, const List &value) {
    self->items = value;
}

The %naturalvar directive is a macro for, and hence equivalent to, %feature("naturalvar"). It can be used as follows:

// All List variables will use const List& typemaps
%naturalvar List;

// Only Foo::myList will use const List& typemaps
%naturalvar Foo::myList;
struct Foo {
  List myList;
};

// All non-primitive types will use const reference typemaps
%naturalvar;

The observant reader will notice that %naturalvar works like any other feature flag directive but with some extra flexibility. The first of the example usages above shows %naturalvar attaching to the myList 's variable type, that is the List class. The second usage shows %naturalvar attaching to the variable name. Hence the naturalvar feature can be used on either the variable's name or type. Note that using the naturalvar feature on a variable's name overrides any naturalvar feature attached to the variable's type.

It is generally a good idea to use this feature globally as the reference typemaps have extra NULL checking compared to the pointer typemaps. A pointer can be NULL, whereas a reference cannot, so the extra checking ensures that the target language user does not pass in a value that translates to a NULL pointer and thereby preventing any potential NULL pointer dereferences. The %naturalvar feature will apply to global variables in addition to member variables in some language modules, eg C# and Java.

The naturalvar behavior can also be turned on as a global setting via the -naturalvar commandline option or the module mode option, %module(naturalvar=1). However, any use of %feature("naturalvar") will override the global setting.

Compatibility note: The %naturalvar feature was introduced in SWIG-1.3.28, prior to which it was necessary to manually apply the const reference typemaps, eg %apply const std::string & { std::string * }, but this example would also apply the typemaps to methods taking a std::string pointer.

Compatibility note: Read-only access used to be controlled by a pair of directives %readonly and %readwrite. Although these directives still work, they generate a warning message. Simply change the directives to %immutable; and %mutable; to silence the warning. Don't forget the extra semicolon!

Compatibility note: Prior to SWIG-1.3.12, all members of unknown type were wrapped into accessor functions using pointers. For example, if you had a structure like this

struct Foo {
   size_t  len;
};

and nothing was known about size_t, then accessors would be written to work with size_t *. Starting in SWIG-1.3.12, this behavior has been modified. Specifically, pointers will only be used if SWIG knows that a datatype corresponds to a structure or class. Therefore, the above code would be wrapped into accessors involving size_t. This change is subtle, but it smooths over a few problems related to structure wrapping and some of SWIG's customization features.

6.7 Default arguments

SWIG will wrap all types of functions that have default arguments. For example member functions:

class Foo {
public:
    void bar(int x, int y = 3, int z = 4);
};

SWIG handles default arguments by generating an extra overloaded method for each defaulted argument. SWIG is effectively handling methods with default arguments as if it was wrapping the equivalent overloaded methods. Thus for the example above, it is as if we had instead given the following to SWIG:

class Foo {
public:
    void bar(int x, int y, int z);
    void bar(int x, int y);
    void bar(int x);
};

The wrappers produced are exactly the same as if the above code was instead fed into SWIG. Details of this are covered later in the Wrapping Overloaded Functions and Methods section. This approach allows SWIG to wrap all possible default arguments, but can be verbose. For example if a method has ten default arguments, then eleven wrapper methods are generated.

Please see the Features and default arguments section for more information on using %feature with functions with default arguments. The Ambiguity resolution and renaming section also deals with using %rename and %ignore on methods with default arguments. If you are writing your own typemaps for types used in methods with default arguments, you may also need to write a typecheck typemap. See the Typemaps and overloading section for details or otherwise use the compactdefaultargs feature flag as mentioned below.

Compatibility note: Versions of SWIG prior to SWIG-1.3.23 wrapped default arguments slightly differently. Instead a single wrapper method was generated and the default values were copied into the C++ wrappers so that the method being wrapped was then called with all the arguments specified. If the size of the wrappers are a concern then this approach to wrapping methods with default arguments can be re-activated by using the compactdefaultargs feature flag.

%feature("compactdefaultargs") Foo::bar;
class Foo {
public:
    void bar(int x, int y = 3, int z = 4);
};

This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages, such as C# and Java, which don't have optional arguments in the language, Another restriction of this feature is that it cannot handle default arguments that are not public. The following example illustrates this:

class Foo {
private:
   static const int spam;
public:
   void bar(int x, int y = spam);   // Won't work with %feature("compactdefaultargs") -
                                    // private default value
};

This produces uncompileable wrapper code because default values in C++ are evaluated in the same scope as the member function whereas SWIG evaluates them in the scope of a wrapper function (meaning that the values have to be public).

This feature is automatically turned on when wrapping C code with default arguments and whenever keyword arguments (kwargs) are specified for either C or C++ code. Keyword arguments are a language feature of some scripting languages, for example Ruby and Python. SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used.

6.8 Protection

SWIG wraps class members that are public following the C++ conventions, i.e., by explicit public declaration or by the use of the using directive. In general, anything specified in a private or protected section will be ignored, although the internal code generator sometimes looks at the contents of the private and protected sections so that it can properly generate code for default constructors and destructors. Directors could also modify the way non-public virtual protected members are treated.

By default, members of a class definition are assumed to be private until you explicitly give a `public:' declaration (This is the same convention used by C++).

6.9 Enums and constants

Enumerations and constants are handled differently by the different language modules and are described in detail in the appropriate language chapter. However, many languages map enums and constants in a class definition into constants with the classname as a prefix. For example :

class Swig {
public:
	enum {ALE, LAGER, PORTER, STOUT};
};

Generates the following set of constants in the target scripting language :

Swig_ALE = Swig::ALE
Swig_LAGER = Swig::LAGER
Swig_PORTER = Swig::PORTER
Swig_STOUT = Swig::STOUT

Members declared as const are wrapped as read-only members and do not create constants.

6.10 Friends

Friend declarations are recognised by SWIG. For example, if you have this code:

class Foo {
public:
     ...
     friend void blah(Foo *f);
     ...
};

then the friend declaration does result in a wrapper code equivalent to one generated for the following declaration

class Foo {
public:
    ...
};

void blah(Foo *f);    

A friend declaration, as in C++, is understood to be in the same scope where the class is declared, hence, you can have


%ignore bar::blah(Foo *f);

namespace bar {

  class Foo {
  public:
     ...
     friend void blah(Foo *f);
     ...
  };
}

and a wrapper for the method 'blah' will not be generated.

6.11 References and pointers

C++ references are supported, but SWIG transforms them back into pointers. For example, a declaration like this :

class Foo {
public:
	double bar(double &a);
}

has a low-level accessor

double Foo_bar(Foo *obj, double *a) {
	obj->bar(*a);
}

As a special case, most language modules pass const references to primitive datatypes (int, short, float, etc.) by value instead of pointers. For example, if you have a function like this,

void foo(const int &x);

it is called from a script as follows:

foo(3)              # Notice pass by value

Functions that return a reference are remapped to return a pointer instead. For example:

class Bar {
public:
     Foo &spam();
};

Generates an accessor like this:

Foo *Bar_spam(Bar *obj) {
   Foo &result = obj->spam();
   return &result;
}

However, functions that return const references to primitive datatypes (int, short, etc.) normally return the result as a value rather than a pointer. For example, a function like this,

const int &bar();

will return integers such as 37 or 42 in the target scripting language rather than a pointer to an integer.

Don't return references to objects allocated as local variables on the stack. SWIG doesn't make a copy of the objects so this will probably cause your program to crash.

Note: The special treatment for references to primitive datatypes is necessary to provide more seamless integration with more advanced C++ wrapping applications---especially related to templates and the STL. This was first added in SWIG-1.3.12.

6.12 Pass and return by value

Occasionally, a C++ program will pass and return class objects by value. For example, a function like this might appear:

Vector cross_product(Vector a, Vector b);

If no information is supplied about Vector, SWIG creates a wrapper function similar to the following:

Vector *wrap_cross_product(Vector *a, Vector *b) {
   Vector x = *a;
   Vector y = *b;
   Vector r = cross_product(x,y);
   return new Vector(r);
}

In order for the wrapper code to compile, Vector must define a copy constructor and a default constructor.

If Vector is defined as a class in the interface, but it does not support a default constructor, SWIG changes the wrapper code by encapsulating the arguments inside a special C++ template wrapper class, through a process called the "Fulton Transform". This produces a wrapper that looks like this:

Vector cross_product(Vector *a, Vector *b) {
   SwigValueWrapper<Vector> x = *a;
   SwigValueWrapper<Vector> y = *b;
   SwigValueWrapper<Vector> r = cross_product(x,y);
   return new Vector(r);
}

This transformation is a little sneaky, but it provides support for pass-by-value even when a class does not provide a default constructor and it makes it possible to properly support a number of SWIG's customization options. The definition of SwigValueWrapper can be found by reading the SWIG wrapper code. This class is really nothing more than a thin wrapper around a pointer.

Although SWIG usually detects the classes to which the Fulton Transform should be applied, in some situations it's necessary to override it. That's done with %feature("valuewrapper") to ensure it is used and %feature("novaluewrapper") to ensure it is not used:

%feature("novaluewrapper") A;    
class A;

%feature("valuewrapper") B;
struct B { 
    B();
    // ....
};   

It is well worth considering turning this feature on for classes that do have a default constructor. It will remove a redundant constructor call at the point of the variable declaration in the wrapper, so will generate notably better performance for large objects or for classes with expensive construction. Alternatively consider returning a reference or a pointer.

Note: this transformation has no effect on typemaps or any other part of SWIG---it should be transparent except that you may see this code when reading the SWIG output file.

Note: This template transformation is new in SWIG-1.3.11 and may be refined in future SWIG releases. In practice, it is only absolutely necessary to do this for classes that don't define a default constructor.

Note: The use of this template only occurs when objects are passed or returned by value. It is not used for C++ pointers or references.

6.13 Inheritance

SWIG supports C++ inheritance of classes and allows both single and multiple inheritance, as limited or allowed by the target language. The SWIG type-checker knows about the relationship between base and derived classes and allows pointers to any object of a derived class to be used in functions of a base class. The type-checker properly casts pointer values and is safe to use with multiple inheritance.

SWIG treats private or protected inheritance as close to the C++ spirit, and target language capabilities, as possible. In most cases, this means that SWIG will parse the non-public inheritance declarations, but that will have no effect in the generated code, besides the implicit policies derived for constructors and destructors.

The following example shows how SWIG handles inheritance. For clarity, the full C++ code has been omitted.

// shapes.i
%module shapes
%{
#include "shapes.h"
%}

class Shape {
public:
        double x,y;
	virtual double area() = 0;
	virtual double perimeter() = 0;
	void    set_location(double x, double y);
};
class Circle : public Shape {
public:
	Circle(double radius);
	~Circle();
	double area();
	double perimeter();
};
class Square : public Shape {
public:
	Square(double size);
	~Square();
	double area();
	double perimeter();
}

When wrapped into Python, we can perform the following operations (shown using the low level Python accessors):

$ python
>>> import shapes
>>> circle = shapes.new_Circle(7)
>>> square = shapes.new_Square(10)
>>> print shapes.Circle_area(circle)
153.93804004599999757
>>> print shapes.Shape_area(circle)
153.93804004599999757
>>> print shapes.Shape_area(square)
100.00000000000000000
>>> shapes.Shape_set_location(square,2,-3)
>>> print shapes.Shape_perimeter(square)
40.00000000000000000
>>>

In this example, Circle and Square objects have been created. Member functions can be invoked on each object by making calls to Circle_area, Square_area, and so on. However, the same results can be accomplished by simply using the Shape_area function on either object.

One important point concerning inheritance is that the low-level accessor functions are only generated for classes in which they are actually declared. For instance, in the above example, the method set_location() is only accessible as Shape_set_location() and not as Circle_set_location() or Square_set_location() . Of course, the Shape_set_location() function will accept any kind of object derived from Shape. Similarly, accessor functions for the attributes x and y are generated as Shape_x_get(), Shape_x_set(), Shape_y_get(), and Shape_y_set(). Functions such as Circle_x_get() are not available--instead you should use Shape_x_get().

Note that there is a one to one correlation between the low-level accessor functions and the proxy methods and therefore there is also a one to one correlation between the C++ class methods and the generated proxy class methods.

Note: For the best results, SWIG requires all base classes to be defined in an interface. Otherwise, you may get a warning message like this:

example.i:18: Warning 401: Nothing known about base class 'Foo'. Ignored.

If any base class is undefined, SWIG still generates correct type relationships. For instance, a function accepting a Foo * will accept any object derived from Foo regardless of whether or not SWIG actually wrapped the Foo class. If you really don't want to generate wrappers for the base class, but you want to silence the warning, you might consider using the %import directive to include the file that defines Foo. %import simply gathers type information, but doesn't generate wrappers. Alternatively, you could just define Foo as an empty class in the SWIG interface or use warning suppression .

Note: typedef-names can be used as base classes. For example:

class Foo {
...
};

typedef Foo FooObj;
class Bar : public FooObj {     // Ok.  Base class is Foo
...
};

Similarly, typedef allows unnamed structures to be used as base classes. For example:

typedef struct {
   ...
} Foo;

class Bar : public Foo {    // Ok. 
...
};

Compatibility Note: Starting in version 1.3.7, SWIG only generates low-level accessor wrappers for the declarations that are actually defined in each class. This differs from SWIG1.1 which used to inherit all of the declarations defined in base classes and regenerate specialized accessor functions such as Circle_x_get(), Square_x_get(), Circle_set_location(), and Square_set_location(). This behavior resulted in huge amounts of replicated code for large class hierarchies and made it awkward to build applications spread across multiple modules (since accessor functions are duplicated in every single module). It is also unnecessary to have such wrappers when advanced features like proxy classes are used. Note: Further optimizations are enabled when using the -fvirtual option, which avoids the regenerating of wrapper functions for virtual members that are already defined in a base class.

6.14 A brief discussion of multiple inheritance, pointers, and type checking

When a target scripting language refers to a C++ object, it normally uses a tagged pointer object that contains both the value of the pointer and a type string. For example, in Tcl, a C++ pointer might be encoded as a string like this:

_808fea88_p_Circle

A somewhat common question is whether or not the type-tag could be safely removed from the pointer. For instance, to get better performance, could you strip all type tags and just use simple integers instead?

In general, the answer to this question is no. In the wrappers, all pointers are converted into a common data representation in the target language. Typically this is the equivalent of casting a pointer to void *. This means that any C++ type information associated with the pointer is lost in the conversion.

The problem with losing type information is that it is needed to properly support many advanced C++ features--especially multiple inheritance. For example, suppose you had code like this:

class A {
public:
   int x;
};

class B {
public:
   int y;
};

class C : public A, public B {
};

int A_function(A *a) {
   return a->x;
}

int B_function(B *b) {
   return b->y;
}

Now, consider the following code that uses void *.

C *c = new C();
void *p = (void *) c;
...
int x = A_function((A *) p);
int y = B_function((B *) p);

In this code, both A_function() and B_function() may legally accept an object of type C * (via inheritance). However, one of the functions will always return the wrong result when used as shown. The reason for this is that even though p points to an object of type C, the casting operation doesn't work like you would expect. Internally, this has to do with the data representation of C. With multiple inheritance, the data from each base class is stacked together. For example:

             ------------    <--- (C *),  (A *)
            |     A      |
            |------------|   <--- (B *)
            |     B      |
             ------------   

Because of this stacking, a pointer of type C * may change value when it is converted to a A * or B *. However, this adjustment does not occur if you are converting from a void *.

The use of type tags marks all pointers with the real type of the underlying object. This extra information is then used by SWIG generated wrappers to correctly cast pointer values under inheritance (avoiding the above problem).

Some of the language modules are able to solve the problem by storing multiple instances of the pointer, for example, A *, in the A proxy class as well as C * in the C proxy class. The correct cast can then be made by choosing the correct void * pointer to use and is guaranteed to work as the cast to a void pointer and back to the same type does not lose any type information:

C *c = new C();
void *p = (void *) c;
void *pA = (void *) c;
void *pB = (void *) c;
...
int x = A_function((A *) pA);
int y = B_function((B *) pB);

In practice, the pointer is held as an integral number in the target language proxy class.

6.15 Wrapping Overloaded Functions and Methods

In many language modules, SWIG provides partial support for overloaded functions, methods, and constructors. For example, if you supply SWIG with overloaded functions like this:

void foo(int x) {
   printf("x is %d\n", x);
}
void foo(char *x) {
   printf("x is '%s'\n", x);
}

The function is used in a completely natural way. For example:

>>> foo(3)
x is 3
>>> foo("hello")
x is 'hello'
>>>

Overloading works in a similar manner for methods and constructors. For example if you have this code,

class Foo {
public:
     Foo();
     Foo(const Foo &);   // Copy constructor
     void bar(int x);
     void bar(char *s, int y);
};

it might be used like this

>>> f = Foo()          # Create a Foo
>>> f.bar(3)
>>> g = Foo(f)         # Copy Foo
>>> f.bar("hello",2)

6.15.1 Dispatch function generation

The implementation of overloaded functions and methods is somewhat complicated due to the dynamic nature of scripting languages. Unlike C++, which binds overloaded methods at compile time, SWIG must determine the proper function as a runtime check for scripting language targets. This check is further complicated by the typeless nature of certain scripting languages. For instance, in Tcl, all types are simply strings. Therefore, if you have two overloaded functions like this,

void foo(char *x);
void foo(int x);

the order in which the arguments are checked plays a rather critical role.

For statically typed languages, SWIG uses the language's method overloading mechanism. To implement overloading for the scripting languages, SWIG generates a dispatch function that checks the number of passed arguments and their types. To create this function, SWIG first examines all of the overloaded methods and ranks them according to the following rules:

  1. Number of required arguments. Methods are sorted by increasing number of required arguments.
  2. Argument type precedence. All C++ datatypes are assigned a numeric type precedence value (which is determined by the language module).

    Type              Precedence
    ----------------  ----------
    TYPE *            0     (High)
    void *            20
    Integers          40
    Floating point    60
    char              80
    Strings           100   (Low)
    

    Using these precedence values, overloaded methods with the same number of required arguments are sorted in increased order of precedence values.

This may sound very confusing, but an example will help. Consider the following collection of overloaded methods:

void foo(double);
void foo(int);
void foo(Bar *);
void foo();
void foo(int x, int y, int z, int w);
void foo(int x, int y, int z = 3);
void foo(double x, double y);
void foo(double x, Bar *z);

The first rule simply ranks the functions by required argument count. This would produce the following list:

rank
-----
[0]   foo()
[1]   foo(double);
[2]   foo(int);
[3]   foo(Bar *);
[4]   foo(int x, int y, int z = 3);
[5]   foo(double x, double y)
[6]   foo(double x, Bar *z)
[7]   foo(int x, int y, int z, int w);

The second rule, simply refines the ranking by looking at argument type precedence values.

rank
-----
[0]   foo()
[1]   foo(Bar *);
[2]   foo(int);
[3]   foo(double);
[4]   foo(int x, int y, int z = 3);
[5]   foo(double x, Bar *z)
[6]   foo(double x, double y)
[7]   foo(int x, int y, int z, int w);

Finally, to generate the dispatch function, the arguments passed to an overloaded method are simply checked in the same order as they appear in this ranking.

If you're still confused, don't worry about it---SWIG is probably doing the right thing.

6.15.2 Ambiguity in Overloading

Regrettably, SWIG is not able to support every possible use of valid C++ overloading. Consider the following example:

void foo(int x);
void foo(long x);

In C++, this is perfectly legal. However, in a scripting language, there is generally only one kind of integer object. Therefore, which one of these functions do you pick? Clearly, there is no way to truly make a distinction just by looking at the value of the integer itself ( int and long may even be the same precision). Therefore, when SWIG encounters this situation, it may generate a warning message like this for scripting languages:

example.i:4: Warning 509: Overloaded method foo(long) effectively ignored,
example.i:3: Warning 509: as it is shadowed by foo(int).

or for statically typed languages like Java:

example.i:4: Warning 516: Overloaded method foo(long) ignored,
example.i:3: Warning 516: using foo(int) instead.
at example.i:3 used.

This means that the second overloaded function will be inaccessible from a scripting interface or the method won't be wrapped at all. This is done as SWIG does not know how to disambiguate it from an earlier method.

Ambiguity problems are known to arise in the following situations:

  • Integer conversions. Datatypes such as int, long, and short cannot be disambiguated in some languages. Shown above.
  • Floating point conversion. float and double can not be disambiguated in some languages.
  • Pointers and references. For example, Foo * and Foo & .
  • Pointers and arrays. For example, Foo * and Foo [4] .
  • Pointers and instances. For example, Foo and Foo * . Note: SWIG converts all instances to pointers.
  • Qualifiers. For example, const Foo * and Foo *.
  • Default vs. non default arguments. For example, foo(int a, int b) and foo(int a, int b = 3).

When an ambiguity arises, methods are checked in the same order as they appear in the interface file. Therefore, earlier methods will shadow methods that appear later.

When wrapping an overloaded function, there is a chance that you will get an error message like this:

example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking
rule for 'int').

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 SWIG bug tracking database.

If you get an error message such as the following,

foo.i:6. Overloaded declaration ignored.  Spam::foo(double )
foo.i:5. Previous declaration is Spam::foo(int )
foo.i:7. Overloaded declaration ignored.  Spam::foo(Bar *,Spam *,int )
foo.i:5. Previous declaration is Spam::foo(int )

it means that the target language module has not yet implemented support for overloaded functions and methods. The only way to fix the problem is to read the next section.

6.15.3 Ambiguity resolution and renaming

If an ambiguity in overload resolution occurs or if a module doesn't allow overloading, there are a few strategies for dealing with the problem. First, you can tell SWIG to ignore one of the methods. This is easy---simply use the %ignore directive. For example:

%ignore foo(long);

void foo(int);
void foo(long);       // Ignored.  Oh well.

The other alternative is to rename one of the methods. This can be done using %rename. For example:

%rename("foo_short") foo(short);
%rename(foo_long) foo(long);

void foo(int);
void foo(short);      // Accessed as foo_short()
void foo(long);       // Accessed as foo_long()

Note that the quotes around the new name are optional, however, should the new name be a C/C++ keyword they would be essential in order to avoid a parsing error. The %ignore and %rename directives are both rather powerful in their ability to match declarations. When used in their simple form, they apply to both global functions and methods. For example:

/* Forward renaming declarations */
%rename(foo_i) foo(int); 
%rename(foo_d) foo(double);
...
void foo(int);           // Becomes 'foo_i'
void foo(char *c);       // Stays 'foo' (not renamed)

class Spam {
public:
   void foo(int);      // Becomes 'foo_i'
   void foo(double);   // Becomes 'foo_d'
   ...
};

If you only want the renaming to apply to a certain scope, the C++ scope resolution operator (::) can be used. For example:

%rename(foo_i) ::foo(int);      // Only rename foo(int) in the global scope.
                                // (will not rename class members)

%rename(foo_i) Spam::foo(int);  // Only rename foo(int) in class Spam

When a renaming operator is applied to a class as in Spam::foo(int), it is applied to that class and all derived classes. This can be used to apply a consistent renaming across an entire class hierarchy with only a few declarations. For example:

%rename(foo_i) Spam::foo(int);
%rename(foo_d) Spam::foo(double);

class Spam {
public:
   virtual void foo(int);      // Renamed to foo_i
   virtual void foo(double);   // Renamed to foo_d
   ...
};

class Bar : public Spam {
public:
   virtual void foo(int);      // Renamed to foo_i
   virtual void foo(double);   // Renamed to foo_d
...
};

class Grok : public Bar {
public:
   virtual void foo(int);      // Renamed to foo_i
   virtual void foo(double);   // Renamed to foo_d
...
};

It is also possible to include %rename specifications in the class definition itself. For example:

class Spam {
   %rename(foo_i) foo(int);
   %rename(foo_d) foo(double);
public:
   virtual void foo(int);      // Renamed to foo_i
   virtual void foo(double);   // Renamed to foo_d
   ...
};

class Bar : public Spam {
public:
   virtual void foo(int);      // Renamed to foo_i
   virtual void foo(double);   // Renamed to foo_d
...
};

In this case, the %rename directives still get applied across the entire inheritance hierarchy, but it's no longer necessary to explicitly specify the class prefix Spam::.

A special form of %rename can be used to apply a renaming just to class members (of all classes):

%rename(foo_i) *::foo(int);   // Only rename foo(int) if it appears in a class.

Note: the *:: syntax is non-standard C++, but the '*' is meant to be a wildcard that matches any class name (we couldn't think of a better alternative so if you have a better idea, send email to the swig-devel mailing list.

Although this discussion has primarily focused on %rename all of the same rules also apply to %ignore. For example:

%ignore foo(double);          // Ignore all foo(double)
%ignore Spam::foo;            // Ignore foo in class Spam
%ignore Spam::foo(double);    // Ignore foo(double) in class Spam
%ignore *::foo(double);       // Ignore foo(double) in all classes

When applied to a base class, %ignore forces all definitions in derived classes to disappear. For example, %ignore Spam::foo(double) will eliminate foo(double) in Spam and all classes derived from Spam.

Notes on %rename and %ignore:

  • Since, the %rename declaration is used to declare a renaming in advance, it can be placed at the start of an interface file. This makes it possible to apply a consistent name resolution without having to modify header files. For example:

    %module foo
    
    /* Rename these overloaded functions */
    %rename(foo_i) foo(int); 
    %rename(foo_d) foo(double);
    
    %include "header.h"
    
  • The scope qualifier (::) can also be used on simple names. For example:

    %rename(bar) ::foo;       // Rename foo to bar in global scope only
    %rename(bar) Spam::foo;   // Rename foo to bar in class Spam only
    %rename(bar) *::foo;      // Rename foo in classes only
    
  • Name matching tries to find the most specific match that is defined. A qualified name such as Spam::foo always has higher precedence than an unqualified name foo. Spam::foo has higher precedence than *::foo and *::foo has higher precedence than foo. A parameterized name has higher precedence than an unparameterized name within the same scope level. However, an unparameterized name with a scope qualifier has higher precedence than a parameterized name in global scope (e.g., a renaming of Spam::foo takes precedence over a renaming of foo(int) ).

  • The order in which %rename directives are defined does not matter as long as they appear before the declarations to be renamed. Thus, there is no difference between saying:

    %rename(bar) foo;
    %rename(foo_i) Spam::foo(int);
    %rename(Foo) Spam::foo;
    

    and this

    %rename(Foo) Spam::foo;
    %rename(bar) foo;
    %rename(foo_i) Spam::foo(int);
    

    (the declarations are not stored in a linked list and order has no importance). Of course, a repeated %rename directive will change the setting for a previous %rename directive if exactly the same name, scope, and parameters are supplied.

  • For multiple inheritance where renaming rules are defined for multiple base classes, the first renaming rule found on a depth-first traversal of the class hierarchy is used.
  • The name matching rules strictly follow member qualification rules. For example, if you have a class like this:

    class Spam {
    public:
       ...
       void bar() const;
       ...
    };
    

    the declaration

    %rename(name) Spam::bar();
    

    will not apply as there is no unqualified member bar(). The following will apply as the qualifier matches correctly:

    %rename(name) Spam::bar() const;
    

    An often overlooked C++ feature is that classes can define two different overloaded members that differ only in their qualifiers, like this:

    class Spam {
    public:
       ...
       void bar();         // Unqualified member
       void bar() const;   // Qualified member
       ...
    };
    

    %rename can then be used to target each of the overloaded methods individually. For example we can give them separate names in the target language:

    %rename(name1) Spam::bar();
    %rename(name2) Spam::bar() const;
    

    Similarly, if you merely wanted to ignore one of the declarations, use %ignore with the full qualification. For example, the following directive would tell SWIG to ignore the const version of bar() above:

    %ignore Spam::bar() const;   // Ignore bar() const, but leave other bar() alone
    
  • Currently no resolution is performed in order to match function parameters. This means function parameter types must match exactly. For example, namespace qualifiers and typedefs will not work. The following usage of typedefs demonstrates this:

    typedef int Integer;
    
    %rename(foo_i) foo(int);
    
    class Spam {
    public:
       void foo(Integer);  // Stays 'foo' (not renamed)
    };
    class Ham {
    public:
       void foo(int);      // Renamed to foo_i
    };
    

  • The name matching rules also use default arguments for finer control when wrapping methods that have default arguments. Recall that methods with default arguments are wrapped as if the equivalent overloaded methods had been parsed (Default arguments section). Let's consider the following example class:

    class Spam {
    public:
       ...
       void bar(int i=-1, double d=0.0);
       ...
    };
    

    The following %rename will match exactly and apply to all the target language overloaded methods because the declaration with the default arguments exactly matches the wrapped method:

    %rename(newbar) Spam::bar(int i=-1, double d=0.0);
    

    The C++ method can then be called from the target language with the new name no matter how many arguments are specified, for example: newbar(2, 2.0), newbar(2) or newbar(). However, if the %rename does not contain the default arguments, it will only apply to the single equivalent target language overloaded method. So if instead we have:

    %rename(newbar) Spam::bar(int i, double d);
    

    The C++ method must then be called from the target language with the new name newbar(2, 2.0) when both arguments are supplied or with the original name as bar(2) (one argument) or bar() (no arguments). In fact it is possible to use %rename on the equivalent overloaded methods, to rename all the equivalent overloaded methods:

    %rename(bar_2args)   Spam::bar(int i, double d);
    %rename(bar_1arg)    Spam::bar(int i);
    %rename(bar_default) Spam::bar();
    

    Similarly, the extra overloaded methods can be selectively ignored using %ignore.

    Compatibility note: The %rename directive introduced the default argument matching rules in SWIG-1.3.23 at the same time as the changes to wrapping methods with default arguments was introduced.

6.15.4 Comments on overloading

Support for overloaded methods was first added in SWIG-1.3.14. The implementation is somewhat unusual when compared to similar tools. For instance, the order in which declarations appear is largely irrelevant in SWIG. Furthermore, SWIG does not rely upon trial execution or exception handling to figure out which method to invoke.

Internally, the overloading mechanism is completely configurable by the target language module. Therefore, the degree of overloading support may vary from language to language. As a general rule, statically typed languages like Java are able to provide more support than dynamically typed languages like Perl, Python, Ruby, and Tcl.

6.16 Wrapping overloaded operators

C++ overloaded operator declarations can be wrapped. For example, consider a class like this:

class Complex {
private:
  double rpart, ipart;
public:
  Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
  Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
  Complex &operator=(const Complex &c) {
    rpart = c.rpart;
    ipart = c.ipart;
    return *this;
  }
  Complex operator+(const Complex &c) const {
    return Complex(rpart+c.rpart, ipart+c.ipart);
  }
  Complex operator-(const Complex &c) const {
    return Complex(rpart-c.rpart, ipart-c.ipart);
  }
  Complex operator*(const Complex &c) const {
    return Complex(rpart*c.rpart - ipart*c.ipart,
		   rpart*c.ipart + c.rpart*ipart);
  }
  Complex operator-() const {
    return Complex(-rpart, -ipart);
  }
  double re() const { return rpart; }
  double im() const { return ipart; }
};

When operator declarations appear, they are handled in exactly the same manner as regular methods. However, the names of these methods are set to strings like "operator +" or "operator -". The problem with these names is that they are illegal identifiers in most scripting languages. For instance, you can't just create a method called "operator +" in Python--there won't be any way to call it.

Some language modules already know how to automatically handle certain operators (mapping them into operators in the target language). However, the underlying implementation of this is really managed in a very general way using the %rename directive. For example, in Python a declaration similar to this is used:

%rename(__add__) Complex::operator+;

This binds the + operator to a method called __add__ (which is conveniently the same name used to implement the Python + operator). Internally, the generated wrapper code for a wrapped operator will look something like this pseudocode:

_wrap_Complex___add__(args) {
   ... get args ...
   obj->operator+(args);
   ...
}

When used in the target language, it may now be possible to use the overloaded operator normally. For example:

>>> a = Complex(3,4)
>>> b = Complex(5,2)
>>> c = a + b           # Invokes __add__ method

It is important to realize that there is nothing magical happening here. The %rename directive really only picks a valid method name. If you wrote this:

%rename(add) operator+;

The resulting scripting interface might work like this:

a = Complex(3,4)
b = Complex(5,2)
c = a.add(b)      # Call a.operator+(b)

All of the techniques described to deal with overloaded functions also apply to operators. For example:

%ignore Complex::operator=;             // Ignore = in class Complex
%ignore *::operator=;                   // Ignore = in all classes
%ignore operator=;                      // Ignore = everywhere.

%rename(__sub__) Complex::operator-; 
%rename(__neg__) Complex::operator-();  // Unary - 

The last part of this example illustrates how multiple definitions of the operator- method might be handled.

Handling operators in this manner is mostly straightforward. However, there are a few subtle issues to keep in mind:

  • In C++, it is fairly common to define different versions of the operators to account for different types. For example, a class might also include a friend function like this:

    class Complex {
    public:
      friend Complex operator+(Complex &, double);
    };
    Complex operator+(Complex &, double);
    

    SWIG simply ignores all friend declarations. Furthermore, it doesn't know how to associate the associated operator+ with the class (because it's not a member of the class).

    It's still possible to make a wrapper for this operator, but you'll have to handle it like a normal function. For example:

    %rename(add_complex_double) operator+(Complex &, double);
    
  • Certain operators are ignored by default. For instance, new and delete operators are ignored as well as conversion operators.

  • The semantics of certain C++ operators may not match those in the target language.

6.17 Class extension

New methods can be added to a class using the %extend directive. This directive is primarily used in conjunction with proxy classes to add additional functionality to an existing class. For example :

%module vector
%{
#include "vector.h"
%}

class Vector {
public:
	double x,y,z;
	Vector();
	~Vector();
	... bunch of C++ methods ...
	%extend {
		char *__str__() {
			static char temp[256];
			sprintf(temp,"[ %g, %g, %g ]", $self->x,$self->y,$self->z);
			return &temp[0];
		}
	}
};

This code adds a __str__ method to our class for producing a string representation of the object. In Python, such a method would allow us to print the value of an object using the print command.

>>>
>>> v = Vector();
>>> v.x = 3
>>> v.y = 4
>>> v.z = 0
>>> print(v)
[ 3.0, 4.0, 0.0 ]
>>>

The C++ 'this' pointer is often needed to access member variables, methods etc. The $self special variable should be used wherever you could use 'this'. The example above demonstrates this for accessing member variables. Note that the members dereferenced by $self must be public members as the code is ultimately generated into a global function and so will not have any access to non-public members. The implicit 'this' pointer that is present in C++ methods is not present in %extend methods. In order to access anything in the extended class or its base class, an explicit 'this' is required. The following example shows how one could access base class members:

struct Base {
  virtual void method(int v) {
    ...
  }
  int value;
};
struct Derived : Base {
};
%extend Derived {
  virtual void method(int v) {
    $self->Base::method(v); // akin to this->Base::method(v);
    $self->value = v;       // akin to this->value = v;
    ...
  }
}

The following special variables are expanded if used within a %extend block: $name, $symname, $overname, $decl, $fulldecl, $parentname and $parentsymname. The Special variables section provides more information each of these special variables.

The %extend directive follows all of the same conventions as its use with C structures. Please refer to the Adding member functions to C structures section for further details.

Compatibility note: The %extend directive is a new name for the %addmethods directive in SWIG1.1. Since %addmethods could be used to extend a structure with more than just methods, a more suitable directive name has been chosen.

6.18 Templates

Template type names may appear anywhere a type is expected in an interface file. For example:

void foo(vector<int> *a, int n);
void bar(list<int,100> *x);

There are some restrictions on the use of non-type arguments. Simple literals are supported, and so are some constant expressions. However, use of '<' and '>' within a constant expressions currently is not supported by SWIG ('<=' and '>=' are though). For example:

void bar(list<int,100> *x);                // OK
void bar(list<int,2*50> *x);               // OK
void bar(list<int,(2>1 ? 100 : 50)> *x)    // Not supported

The type system is smart enough to figure out clever games you might try to play with typedef. For instance, consider this code:

typedef int Integer;
void foo(vector<int> *x, vector<Integer> *y);

In this case, vector<Integer> is exactly the same type as vector<int>. The wrapper for foo() will accept either variant.

Starting with SWIG-1.3.7, simple C++ template declarations can also be wrapped. SWIG-1.3.12 greatly expands upon the earlier implementation. Before discussing this any further, there are a few things you need to know about template wrapping. First, a bare C++ template does not define any sort of runnable object-code for which SWIG can normally create a wrapper. Therefore, in order to wrap a template, you need to give SWIG information about a particular template instantiation (e.g., vector<int>, array<double>, etc.). Second, an instantiation name such as vector<int> is generally not a valid identifier name in most target languages. Thus, you will need to give the template instantiation a more suitable name such as intvector when creating a wrapper.

To illustrate, consider the following template definition:

template<class T> class List {
private:
    T *data;
    int nitems;
    int maxitems;
public:
    List(int max) {
      data = new T [max];
      nitems = 0;
      maxitems = max;
    }
    ~List() {
      delete [] data;
    };
    void append(T obj) {
      if (nitems < maxitems) {
        data[nitems++] = obj;
      }
    }
    int length() {
      return nitems;
    }
    T get(int n) {
      return data[n];
    }
};

By itself, this template declaration is useless--SWIG simply ignores it because it doesn't know how to generate any code until unless a definition of T is provided.

One way to create wrappers for a specific template instantiation is to simply provide an expanded version of the class directly like this:

%rename(intList) List<int>;       // Rename to a suitable identifier
class List<int> {
private:
    int *data;
    int nitems;
    int maxitems;
public:
    List(int max);
    ~List();
    void append(int obj);
    int length();
    int get(int n);
};

The %rename directive is needed to give the template class an appropriate identifier name in the target language (most languages would not recognize C++ template syntax as a valid class name). The rest of the code is the same as what would appear in a normal class definition.

Since manual expansion of templates gets old in a hurry, the %template directive can be used to create instantiations of a template class. Semantically, %template is simply a shortcut---it expands template code in exactly the same way as shown above. Here are some examples:

/* Instantiate a few different versions of the template */
%template(intList) List<int>;
%template(doubleList) List<double>;

The argument to %template() is the name of the instantiation in the target language. The name you choose should not conflict with any other declarations in the interface file with one exception---it is okay for the template name to match that of a typedef declaration. For example:

%template(intList) List<int>;
...
typedef List<int> intList;    // OK

SWIG can also generate wrappers for function templates using a similar technique. For example:

// Function template
template<class T> T max(T a, T b) { return a > b ? a : b; }

// Make some different versions of this function
%template(maxint) max<int>;
%template(maxdouble) max<double>;

In this case, maxint and maxdouble become unique names for specific instantiations of the function.

The number of arguments supplied to %template should match that in the original template definition. Template default arguments are supported. For example:

template vector<typename T, int max=100> class vector {
...
};

%template(intvec) vector<int>;           // OK
%template(vec1000) vector<int,1000>;     // OK

The %template directive should not be used to wrap the same template instantiation more than once in the same scope. This will generate an error. For example:

%template(intList) List<int>;
%template(Listint) List<int>;    // Error.   Template already wrapped.

This error is caused because the template expansion results in two identical classes with the same name. This generates a symbol table conflict. Besides, it probably more efficient to only wrap a specific instantiation only once in order to reduce the potential for code bloat.

Since the type system knows how to handle typedef, it is generally not necessary to instantiate different versions of a template for typenames that are equivalent. For instance, consider this code:

%template(intList) vector<int>;
typedef int Integer;
...
void foo(vector<Integer> *x);

In this case, vector<Integer> is exactly the same type as vector<int>. Any use of Vector<Integer> is mapped back to the instantiation of vector<int> created earlier. Therefore, it is not necessary to instantiate a new class for the type Integer (doing so is redundant and will simply result in code bloat).

When a template is instantiated using %template, information about that class is saved by SWIG and used elsewhere in the program. For example, if you wrote code like this,

...
%template(intList) List<int>;
...
class UltraList : public List<int> {
   ...
};

then SWIG knows that List<int> was already wrapped as a class called intList and arranges to handle the inheritance correctly. If, on the other hand, nothing is known about List<int> , you will get a warning message similar to this:

example.h:42: Warning 401. Nothing known about class 'List<int >'. Ignored. 
example.h:42: Warning 401. Maybe you forgot to instantiate 'List<int >' using %template. 

If a template class inherits from another template class, you need to make sure that base classes are instantiated before derived classes. For example:

template<class T> class Foo {
...
};

template<class T> class Bar : public Foo<T> {
...
};

// Instantiate base classes first 
%template(intFoo) Foo<int>;
%template(doubleFoo) Foo<double>;

// Now instantiate derived classes
%template(intBar) Bar<int>;
%template(doubleBar) Bar<double>;

The order is important since SWIG uses the instantiation names to properly set up the inheritance hierarchy in the resulting wrapper code (and base classes need to be wrapped before derived classes). Don't worry--if you get the order wrong, SWIG should generate a warning message.

Occasionally, you may need to tell SWIG about base classes that are defined by templates, but which aren't supposed to be wrapped. Since SWIG is not able to automatically instantiate templates for this purpose, you must do it manually. To do this, simply use the empty template instantiation, that is, %template with no name. For example:

// Instantiate traits<double,double>, but don't wrap it.
%template() traits<double,double>;

If you have to instantiate a lot of different classes for many different types, you might consider writing a SWIG macro. For example:

%define TEMPLATE_WRAP(prefix, T...) 
%template(prefix ## Foo) Foo<T >;
%template(prefix ## Bar) Bar<T >;
...
%enddef

TEMPLATE_WRAP(int, int)
TEMPLATE_WRAP(double, double)
TEMPLATE_WRAP(String, char *)
TEMPLATE_WRAP(PairStringInt, std::pair<string, int>)
...

Note the use of a vararg macro for the type T. If this wasn't used, the comma in the templated type in the last example would not be possible.

The SWIG template mechanism does support specialization. For instance, if you define a class like this,

template<> class List<int> {
private:
    int *data;
    int nitems;
    int maxitems;
public:
    List(int max);
    ~List();
    void append(int obj);
    int length();
    int get(int n);
};

then SWIG will use this code whenever the user expands List<int> . In practice, this may have very little effect on the underlying wrapper code since specialization is often used to provide slightly modified method bodies (which are ignored by SWIG). However, special SWIG directives such as %typemap, %extend, and so forth can be attached to a specialization to provide customization for specific types.

Partial template specialization is partially supported by SWIG. For example, this code defines a template that is applied when the template argument is a pointer.

template<class T> class List<T*> {
private:
    T *data;
    int nitems;
    int maxitems;
public:
    List(int max);
    ~List();
    void append(int obj);
    int length();
    T get(int n);
};

SWIG supports both template explicit specialization and partial specialization. Consider:

template<class T1, class T2> class Foo { };                     // (1) primary template
template<>                   class Foo<double *, int *> { };    // (2) explicit specialization
template<class T1, class T2> class Foo<T1, T2 *> { };           // (3) partial specialization

SWIG is able to properly match explicit instantiations:

Foo<double *, int *>     // explicit specialization matching (2)

SWIG implements template argument deduction so that the following partial specialization examples work just like they would with a C++ compiler:

Foo<int *, int *>        // partial specialization matching (3)
Foo<int *, const int *>  // partial specialization matching (3)
Foo<int *, int **>       // partial specialization matching (3)

Member function templates are supported. The underlying principle is the same as for normal templates--SWIG can't create a wrapper unless you provide more information about types. For example, a class with a member template might look like this:

class Foo {
public:
     template<class T> void bar(T x, T y) { ... };
     ...
};

To expand the template, simply use %template inside the class.

class Foo {
public:
     template<class T> void bar(T x, T y) { ... };
     ...
     %template(barint)    bar<int>;
     %template(bardouble) bar<double>;
};

Or, if you want to leave the original class definition alone, just do this:

class Foo {
public:
     template<class T> void bar(T x, T y) { ... };
     ...
};
...
%extend Foo {
     %template(barint)    bar<int>;
     %template(bardouble) bar<double>;
};

or simply

class Foo {
public:
     template<class T> void bar(T x, T y) { ... };
     ...
};
...

%template(bari) Foo::bar<int>;
%template(bard) Foo::bar<double>;

In this case, the %extend directive is not needed, and %template does exactly the same job, i.e., it adds two new methods to the Foo class.

Note: because of the way that templates are handled, the %template directive must always appear after the definition of the template to be expanded.

Now, if your target language supports overloading, you can even try

%template(bar) Foo::bar<int>;
%template(bar) Foo::bar<double>;

and since the two new wrapped methods have the same name 'bar', they will be overloaded, and when called, the correct method will be dispatched depending on the argument type.

When used with members, the %template directive may be placed in another template class. Here is a slightly perverse example:

// A template
template<class T> class Foo {
public:
     // A member template
     template<class S> T bar(S x, S y) { ... };
     ...
};

// Expand a few member templates
%extend Foo {
  %template(bari) bar<int>;
  %template(bard) bar<double>;
}

// Create some wrappers for the template
%template(Fooi) Foo<int>;
%template(Food) Foo<double>;

Miraculously, you will find that each expansion of Foo has member functions bari() and bard() added.

A common use of member templates is to define constructors for copies and conversions. For example:

template<class T1, class T2> struct pair {
   T1 first;
   T2 second;
   pair() : first(T1()), second(T2()) { }
   pair(const T1 &x, const T2 &y) : first(x), second(y) { }
   template<class U1, class U2> pair(const pair<U1,U2> &x) 
                                        : first(x.first),second(x.second) { }
};

This declaration is perfectly acceptable to SWIG, but the constructor template will be ignored unless you explicitly expand it. To do that, you could expand a few versions of the constructor in the template class itself. For example:

%extend pair {
   %template(pair) pair<T1,T2>;        // Generate default copy constructor
};

When using %extend in this manner, notice how you can still use the template parameters in the original template definition.

Alternatively, you could expand the constructor template in selected instantiations. For example:

// Instantiate a few versions
%template(pairii) pair<int,int>;
%template(pairdd) pair<double,double>;

// Create a default constructor only 
%extend pair<int,int> {
   %template(paird) pair<int,int>;         // Default constructor
};

// Create default and conversion constructors 
%extend pair<double,double> {
   %template(paird) pair<double,dobule>;   // Default constructor
   %template(pairc) pair<int,int>;         // Conversion constructor
};

And if your target language supports overloading, then you can try instead:

// Create default and conversion constructors 
%extend pair<double,double> {
   %template(pair) pair<double,dobule>;   // Default constructor
   %template(pair) pair<int,int>;         // Conversion constructor
};

In this case, the default and conversion constructors have the same name. Hence, SWIG will overload them and define an unique visible constructor, that will dispatch the proper call depending on the argument type.

If all of this isn't quite enough and you really want to make someone's head explode, SWIG directives such as %rename, %extend, and %typemap can be included directly in template definitions. For example:

// File : list.h
template<class T> class List {
   ...
public:
    %rename(__getitem__) get(int);
    List(int max);
    ~List();
    ...
    T get(int index);
    %extend {
        char *__str__() {
            /* Make a string representation */
            ...
        }
    }
};

In this example, the extra SWIG directives are propagated to every template instantiation.

It is also possible to separate these declarations from the template class. For example:

%rename(__getitem__) List::get;
%extend List {
    char *__str__() {
        /* Make a string representation */
        ...
    }
    /* Make a copy */
    T *__copy__() {
       return new List<T>(*$self);
    }
};

...
template<class T> class List {
    ...
    public:
    List() { };
    T get(int index);
    ...
};

When %extend is decoupled from the class definition, it is legal to use the same template parameters as provided in the class definition. These are replaced when the template is expanded. In addition, the %extend directive can be used to add additional methods to a specific instantiation. For example:

%template(intList) List<int>;

%extend List<int> {
    void blah() {
          printf("Hey, I'm an List<int>!\n");
    }
};

SWIG even supports overloaded templated functions. As usual the %template directive is used to wrap templated functions. For example:

template<class T> void foo(T x) { };
template<class T> void foo(T x, T y) { };

%template(foo) foo<int>;

This will generate two overloaded wrapper methods, the first will take a single integer as an argument and the second will take two integer arguments.

Needless to say, SWIG's template support provides plenty of opportunities to break the universe. That said, an important final point is that SWIG does not perform extensive error checking of templates! Specifically, SWIG does not perform type checking nor does it check to see if the actual contents of the template declaration make any sense. Since the C++ compiler will hopefully check this when it compiles the resulting wrapper file, there is no practical reason for SWIG to duplicate this functionality (besides, none of the SWIG developers are masochistic enough to want to implement this right now).

Compatibility Note: The first implementation of template support relied heavily on macro expansion in the preprocessor. Templates have been more tightly integrated into the parser and type system in SWIG-1.3.12 and the preprocessor is no longer used. Code that relied on preprocessing features in template expansion will no longer work. However, SWIG still allows the # operator to be used to generate a string from a template argument.

Compatibility Note: In earlier versions of SWIG, the %template directive introduced a new class name. This name could then be used with other directives. For example:

%template(vectori) vector<int>;
%extend vectori {
    void somemethod() { }
};

This behavior is no longer supported. Instead, you should use the original template name as the class name. For example:

%template(vectori) vector<int>;
%extend vector<int> {
    void somemethod() { }
};

Similar changes apply to typemaps and other customization features.

6.19 Namespaces

Support for C++ namespaces is comprehensive, but by default simple, however, some target languages can turn on more advanced namespace support via the nspace feature, described later. Code within unnamed namespaces is ignored as there is no external access to symbols declared within the unnamed namespace. Before detailing the default implementation for named namespaces, it is worth noting that the semantics of C++ namespaces is extremely non-trivial--especially with regard to the C++ type system and class machinery. At a most basic level, namespaces are sometimes used to encapsulate common functionality. For example:

namespace math {
   double sin(double);
   double cos(double);

   class Complex {
      double im,re;
   public:
      ...
   };
   ...
};

Members of the namespace are accessed in C++ by prepending the namespace prefix to names. For example:

double x = math::sin(1.0);
double magnitude(math::Complex *c);
math::Complex c;
...

At this level, namespaces are relatively easy to manage. However, things start to get very ugly when you throw in the other ways a namespace can be used. For example, selective symbols can be exported from a namespace with using.

using math::Complex;
double magnitude(Complex *c);       // Namespace prefix stripped

Similarly, the contents of an entire namespace can be made available like this:

using namespace math;
double x = sin(1.0);
double magnitude(Complex *c);

Alternatively, a namespace can be aliased:

namespace M = math;
double x = M::sin(1.0);
double magnitude(M::Complex *c);

Using combinations of these features, it is possible to write head-exploding code like this:

namespace A {
  class Foo {
  };
}

namespace B {
   namespace C {
      using namespace A;
   }
   typedef C::Foo FooClass;
}

namespace BIGB = B;

namespace D {
   using BIGB::FooClass;
   class Bar : public FooClass {
   }
};

class Spam : public D::Bar {
};

void evil(A::Foo *a, B::FooClass *b, B::C::Foo *c, BIGB::FooClass *d,
          BIGB::C::Foo *e, D::FooClass *f);

Given the possibility for such perversion, it's hard to imagine how every C++ programmer might want such code wrapped into the target language. Clearly this code defines three different classes. However, one of those classes is accessible under at least six different names!

SWIG fully supports C++ namespaces in its internal type system and class handling code. If you feed SWIG the above code, it will be parsed correctly, it will generate compilable wrapper code, and it will produce a working scripting language module. However, the default wrapping behavior is to flatten namespaces in the target language. This means that the contents of all namespaces are merged together in the resulting scripting language module. For example, if you have code like this,

%module foo
namespace foo {
   void bar(int);
   void spam();
}

namespace bar {
   void blah();
}

then SWIG simply creates three wrapper functions bar(), spam(), and blah() in the target language. SWIG does not prepend the names with a namespace prefix nor are the functions packaged in any kind of nested scope.

There is some rationale for taking this approach. Since C++ namespaces are often used to define modules in C++, there is a natural correlation between the likely contents of a SWIG module and the contents of a namespace. For instance, it would not be unreasonable to assume that a programmer might make a separate extension module for each C++ namespace. In this case, it would be redundant to prepend everything with an additional namespace prefix when the module itself already serves as a namespace in the target language. Or put another way, if you want SWIG to keep namespaces separate, simply wrap each namespace with its own SWIG interface.

Because namespaces are flattened, it is possible for symbols defined in different namespaces to generate a name conflict in the target language. For example:

namespace A {
   void foo(int);
}
namespace B {
   void foo(double);
}

When this conflict occurs, you will get an error message that resembles this:

example.i:26. Error. 'foo' is multiply defined in the generated target language module.
example.i:23. Previous declaration of 'foo'

To resolve this error, simply use %rename to disambiguate the declarations. For example:

%rename(B_foo) B::foo;
...
namespace A {
   void foo(int);
}
namespace B {
   void foo(double);     // Gets renamed to B_foo
}

Similarly, %ignore can be used to ignore declarations.

using declarations do not have any effect on the generated wrapper code. They are ignored by SWIG language modules and they do not result in any code. However, these declarations are used by the internal type system to track type-names. Therefore, if you have code like this:

namespace A {
   typedef int Integer;
}
using namespace A;
void foo(Integer x);

SWIG knows that Integer is the same as A::Integer which is the same as int.

Namespaces may be combined with templates. If necessary, the %template directive can be used to expand a template defined in a different namespace. For example:

namespace foo {
    template<typename T> T max(T a, T b) { return a > b ? a : b; }
}

using foo::max;

%template(maxint)   max<int>;           // Okay.
%template(maxfloat) foo::max<float>;    // Okay (qualified name).

namespace bar {
    using namespace foo;
    %template(maxdouble)  max<double>;    // Okay.
}

The combination of namespaces and other SWIG directives may introduce subtle scope-related problems. The key thing to keep in mind is that all SWIG generated wrappers are produced in the global namespace. Symbols from other namespaces are always accessed using fully qualified names---names are never imported into the global space unless the interface happens to do so with a using declaration. In almost all cases, SWIG adjusts typenames and symbols to be fully qualified. However, this is not done in code fragments such as function bodies, typemaps, exception handlers, and so forth. For example, consider the following:

namespace foo {
    typedef int Integer;
    class bar {
    public:
       ...
    };
}

%extend foo::bar {
   Integer add(Integer x, Integer y) {
       Integer r = x + y;        // Error. Integer not defined in this scope
       return r;
   }
};

In this case, SWIG correctly resolves the added method parameters and return type to foo::Integer. However, since function bodies aren't parsed and such code is emitted in the global namespace, this code produces a compiler error about Integer. To fix the problem, make sure you use fully qualified names. For example:

%extend foo::bar {
   Integer add(Integer x, Integer y) {
       foo::Integer r = x + y;        // Ok.
       return r;
   }
};

Note: SWIG does not propagate using declarations to the resulting wrapper code. If these declarations appear in an interface, they should also appear in any header files that might have been included in a %{ ... %} section. In other words, don't insert extra using declarations into a SWIG interface unless they also appear in the underlying C++ code.

Note: Code inclusion directives such as %{ ... %} or %inline %{ ... %} should not be placed inside a namespace declaration. The code emitted by these directives will not be enclosed in a namespace and you may get very strange results. If you need to use namespaces with these directives, consider the following:

// Good version
%inline %{
namespace foo {
     void bar(int) { ... }
     ...
}
%}

// Bad version.  Emitted code not placed in namespace.
namespace foo {
%inline %{
     void bar(int) { ... }   /* I'm bad */
     ...
%}
}

Note: When the %extend directive is used inside a namespace, the namespace name is included in the generated functions. For example, if you have code like this,

namespace foo {
   class bar {
   public:
        %extend {
           int blah(int x);
        };
   };
}

the added method blah() is mapped to a function int foo_bar_blah(foo::bar *self, int x). This function resides in the global namespace.

Note: Although namespaces are flattened in the target language, the SWIG generated wrapper code observes the same namespace conventions as used in the input file. Thus, if there are no symbol conflicts in the input, there will be no conflicts in the generated code.

Note: In the same way that no resolution is performed on parameters, a conversion operator name must match exactly to how it is defined. Do not change the qualification of the operator. For example, suppose you had an interface like this:

namespace foo {
   class bar;
   class spam {
   public:
        ...
        operator bar();      // Conversion of spam -> bar
        ...
   };
}

The following is how the feature is expected to be written for a successful match:

%rename(tofoo) foo::spam::operator bar();

The following does not work as no namespace resolution is performed in the matching of conversion operator names:

%rename(tofoo) foo::spam::operator foo::bar();

Note, however, that if the operator is defined using a qualifier in its name, then the feature must use it too...

%rename(tofoo) foo::spam::operator bar();      // will not match
%rename(tofoo) foo::spam::operator foo::bar(); // will match
namespace foo {
   class bar;
   class spam {
   public:
        ...
        operator foo::bar();
        ...
   };
}

Compatibility Note: Versions of SWIG prior to 1.3.32 were inconsistent in this approach. A fully qualified name was usually required, but would not work in some situations.

Note: The flattening of namespaces is only intended to serve as a basic namespace implementation. None of the target language modules are currently programmed with any namespace awareness. In the future, language modules may or may not provide more advanced namespace support.

6.19.1 The nspace feature for namespaces

Some target languages provide support for the nspace feature. The feature can be applied to any class, struct, union or enum declared within a named namespace. The feature wraps the type within the target language specific concept of a namespace, for example, a Java package or C# namespace. Please see the language specific sections to see if the target language you are interested in supports the nspace feature.

The feature is demonstrated below for C# using the following example:

%feature("nspace") MyWorld::Material::Color;
%nspace MyWorld::Wrapping::Color; // %nspace is a macro for %feature("nspace")

namespace MyWorld {
  namespace Material {
    class Color {
    ...
    };
  }
  namespace Wrapping {
    class Color {
    ...
    };
  }
}

Without the nspace feature directives above or %rename , you would get the following warning resulting in just one of the Color classes being available for use from the target language:

example.i:9: Error: 'Color' is multiply defined in the generated target language module.
example.i:5: Error: Previous declaration of 'Color'

With the nspace feature the two Color classes are wrapped into the equivalent C# namespaces. A fully qualified constructor call of each these two types in C# is then:

MyWorld.Material.Color materialColor = new MyWorld.Material.Color();
MyWorld.Wrapping.Color wrappingColor = new MyWorld.Wrapping.Color();

Note that the nspace feature does not apply to variables and functions simply declared in a namespace. For example, the following symbols cannot co-exist in the target language without renaming. This may change in a future version.

namespace MyWorld {
  namespace Material {
    int quantity;
    void dispatch();
  }
  namespace Wrapping {
    int quantity;
    void dispatch();
  }
}

Compatibility Note: The nspace feature was first introduced in SWIG-2.0.0.

6.20 Renaming templated types in namespaces

As has been mentioned, when %rename includes parameters, the parameter types must match exactly (no typedef or namespace resolution is performed). SWIG treats templated types slightly differently and has an additional matching rule so unlike non-templated types, an exact match is not always required. If the fully qualified templated type is specified, it will have a higher precedence over the generic template type. In the example below, the generic template type is used to rename to bbb and the fully qualified type is used to rename to ccc.

%rename(bbb) Space::ABC::aaa(T t);                  // will match but with lower precedence than ccc
%rename(ccc) Space::ABC<Space::XYZ>::aaa(Space::XYZ t);// will match but with higher precedence
                                                             // than bbb

namespace Space {
  class XYZ {};
  template<typename T> struct ABC {
    void aaa(T t) {}
  };
}
%template(ABCXYZ) Space::ABC<Space::XYZ>;

It should now be apparent that there are many ways to achieve a renaming with %rename. This is demonstrated by the following two examples, which are effectively the same as the above example. Below shows how %rename can be placed inside a namespace.

namespace Space {
  %rename(bbb) ABC::aaa(T t);                     // will match but with lower precedence than ccc
  %rename(ccc) ABC<Space::XYZ>::aaa(Space::XYZ t);// will match but with higher precedence than bbb
  %rename(ddd) ABC<Space::XYZ>::aaa(XYZ t);       // will not match
}

namespace Space {
  class XYZ {};
  template<typename T> struct ABC {
    void aaa(T t) {}
  };
}
%template(ABCXYZ) Space::ABC<Space::XYZ>;

Note that ddd does not match as there is no namespace resolution for parameter types and the fully qualified type must be specified for template type expansion. The following example shows how %rename can be placed within %extend.

namespace Space {
  %extend ABC {
    %rename(bbb) aaa(T t);         // will match but with lower precedence than ccc
  }
  %extend ABC<Space::XYZ> {
    %rename(ccc) aaa(Space::XYZ t);// will match but with higher precedence than bbb
    %rename(ddd) aaa(XYZ t);       // will not match
  }
}

namespace Space {
  class XYZ {};
  template<typename T> struct ABC {
    void aaa(T t) {}
  };
}
%template(ABCXYZ) Space::ABC<Space::XYZ>;

6.21 Exception specifications

When C++ programs utilize exceptions, exceptional behavior is sometimes specified as part of a function or method declaration. For example:

class Error { };

class Foo {
public:
    ...
    void blah() throw(Error);
    ...
};

If an exception specification is used, SWIG automatically generates wrapper code for catching the indicated exception and, when possible, rethrowing it into the target language, or converting it into an error in the target language otherwise. For example, in Python, you can write code like this:

f = Foo()
try:
    f.blah()
except Error,e:
     # e is a wrapped instance of "Error"

Details of how to tailor code for handling the caught C++ exception and converting it into the target language's exception/error handling mechanism is outlined in the "throws" typemap section.

Since exception specifications are sometimes only used sparingly, this alone may not be enough to properly handle C++ exceptions. To do that, a different set of special SWIG directives are used. Consult the "Exception handling with %exception " section for details. The next section details a way of simulating an exception specification or replacing an existing one.

6.22 Exception handling with %catches

Exceptions are automatically handled for methods with an exception specification. Similar handling can be achieved for methods without exception specifications through the %catches feature. It is also possible to replace any declared exception specification using the %catches feature. In fact, %catches uses the same "throws" typemaps that SWIG uses for exception specifications in handling exceptions. The %catches feature must contain a list of possible types that can be thrown. For each type that is in the list, SWIG will generate a catch handler, in the same way that it would for types declared in the exception specification. Note that the list can also include the catch all specification "...". For example,

struct EBase { virtual ~EBase(); };
struct Error1 : EBase { };
struct Error2 : EBase { };
struct Error3 : EBase { };
struct Error4 : EBase { };

%catches(Error1,Error2,...) Foo::bar();
%catches(EBase) Foo::blah();

class Foo {
public:
    ...
    void bar();
    void blah() throw(Error1,Error2,Error3,Error4);
    ...
};

For the Foo::bar() method, which can throw anything, SWIG will generate catch handlers for Error1, Error2 as well as a catch all handler (...). Each catch handler will convert the caught exception and convert it into a target language error/exception. The catch all handler will convert the caught exception into an unknown error/exception.

Without the %catches feature being attached to Foo::blah(), SWIG will generate catch handlers for all of the types in the exception specification, that is, Error1, Error2, Error3, Error4. However, with the %catches feature above, just a single catch handler for the base class, EBase will be generated to convert the C++ exception into a target language error/exception.

6.23 Pointers to Members

Starting with SWIG-1.3.7, there is limited parsing support for pointers to C++ class members. For example:

double do_op(Object *o, double (Object::*callback)(double,double));
extern double (Object::*fooptr)(double,double);
%constant double (Object::*FOO)(double,double) = &Object::foo;

Although these kinds of pointers can be parsed and represented by the SWIG type system, few language modules know how to handle them due to implementation differences from standard C pointers. Readers are strongly advised to consult an advanced text such as the "The Annotated C++ Manual" for specific details.

When pointers to members are supported, the pointer value might appear as a special string like this:

>>> print example.FOO
_ff0d54a800000000_m_Object__f_double_double__double
>>>

In this case, the hexadecimal digits represent the entire value of the pointer which is usually the contents of a small C++ structure on most machines.

SWIG's type-checking mechanism is also more limited when working with member pointers. Normally SWIG tries to keep track of inheritance when checking types. However, no such support is currently provided for member pointers.

6.24 Smart pointers and operator->()

In some C++ programs, objects are often encapsulated by smart-pointers or proxy classes. This is sometimes done to implement automatic memory management (reference counting) or persistence. Typically a smart-pointer is defined by a template class where the -> operator has been overloaded. This class is then wrapped around some other class. For example:

// Smart-pointer class
template<class T> class SmartPtr {
    T *pointee;
public:
    SmartPtr(T *p) : pointee(p) { ... }
    T *operator->() {
        return pointee;
    }
    ...
};

// Ordinary class
class Foo_Impl {
public:
    int x;
    virtual void bar();
    ...
};

// Smart-pointer wrapper
typedef SmartPtr<Foo_Impl> Foo;

// Create smart pointer Foo
Foo make_Foo() {
    return SmartPtr<Foo_Impl>(new Foo_Impl());
}

// Do something with smart pointer Foo
void do_something(Foo f) {
    printf("x = %d\n", f->x);
    f->bar();
}

// Call the wrapped smart pointer proxy class in the target language 'Foo'
%template(Foo) SmartPtr<Foo_Impl>;

A key feature of this approach is that by defining operator-> the methods and attributes of the object wrapped by a smart pointer are transparently accessible. For example, expressions such as these (from the previous example),

f->x
f->bar()

are transparently mapped to the following

(f.operator->())->x;
(f.operator->())->bar();

When generating wrappers, SWIG tries to emulate this functionality to the extent that it is possible. To do this, whenever operator->() is encountered in a class, SWIG looks at its returned type and uses it to generate wrappers for accessing attributes of the underlying object. For example, wrapping the above code produces wrappers like this:

int Foo_x_get(Foo *f) {
   return (*f)->x;
}
void Foo_x_set(Foo *f, int value) {
   (*f)->x = value;
}
void Foo_bar(Foo *f) {
   (*f)->bar();
}

These wrappers take a smart-pointer instance as an argument, but dereference it in a way to gain access to the object returned by operator->(). You should carefully compare these wrappers to those in the first part of this chapter (they are slightly different).

The end result is that access looks very similar to C++. For example, you could do this in Python:

>>> f = make_Foo()
>>> print f.x
0
>>> f.bar()
>>>

When generating wrappers through a smart-pointer, SWIG tries to generate wrappers for all methods and attributes that might be accessible through operator->(). This includes any methods that might be accessible through inheritance. However, there are a number of restrictions:

  • Member variables and methods are wrapped through a smart pointer. Enumerations, constructors, and destructors are not wrapped.
  • If the smart-pointer class and the underlying object both define a method or variable of the same name, then the smart-pointer version has precedence. For example, if you have this code

    class Foo {
    public:
        int x;
    };
    
    class Bar {
    public:
        int x;       
        Foo *operator->();
    };
    

    then the wrapper for Bar::x accesses the x defined in Bar, and not the x defined in Foo.

If your intent is to only expose the smart-pointer class in the interface, it is not necessary to wrap both the smart-pointer class and the class for the underlying object. However, you must still tell SWIG about both classes if you want the technique described in this section to work. To only generate wrappers for the smart-pointer class, you can use the %ignore directive. For example:

%ignore Foo;
class Foo {       // Ignored
};

class Bar {
public:
   Foo *operator->();
   ...
};

Alternatively, you can import the definition of Foo from a separate file using %import.

Note: When a class defines operator->(), the operator itself is wrapped as a method __deref__(). For example:

f = Foo()               # Smart-pointer
p = f.__deref__()       # Raw pointer from operator->

Note: To disable the smart-pointer behavior, use %ignore to ignore operator->(). For example:

%ignore Bar::operator->;

Note: Smart pointer support was first added in SWIG-1.3.14.

6.25 C++ reference counted objects - ref/unref feature

Another similar idiom in C++ is the use of reference counted objects. Consider for example:

class RCObj  {
  // implement the ref counting mechanism
  int add_ref();
  int del_ref();
  int ref_count();

public:
  virtual ~RCObj() = 0;

  int ref() const {
    return add_ref();
  }

  int unref() const   {
    if (ref_count() == 0 || del_ref() == 0 ) {
	delete this;
	return 0;
      } 
    return ref_count();
  }
};


class A : RCObj {
public:
  A();
  int foo();
};


class B {
  A *_a;

public:
  B(A *a) : _a(a) { 
    a->ref(); 
  }

  ~B() { 
    a->unref(); 
  }
};

int main() {
  A *a  = new A();       // (count: 0)
  a->ref();           // 'a' ref here (count: 1)

  B *b1 = new B(a);   // 'a' ref here (count: 2)
  if (1 + 1 == 2) {
    B *b2 = new B(a); // 'a' ref here (count: 3)
    delete b2;        // 'a' unref, but not deleted (count: 2)
  }

  delete b1;          // 'a' unref, but not deleted (count: 1)
  a->unref();         // 'a' unref and deleted (count: 0)
}

In the example above, the 'A' class instance 'a' is a reference counted object, which can't be deleted arbitrarily since it is shared between the objects 'b1' and 'b2'. 'A' is derived from a Reference Counted Object 'RCObj', which implements the ref/unref idiom.

To tell SWIG that 'RCObj' and all its derived classes are reference counted objects, use the "ref" and "unref" features. These are also available as %refobject and %unrefobject, respectively. For example:

%module example
...

%feature("ref")   RCObj "$this->ref();"
%feature("unref") RCObj "$this->unref();"

%include "rcobj.h"
%include "A.h"
...

where the code passed to the "ref" and "unref" features will be executed as needed whenever a new object is passed to python, or when python tries to release the proxy object instance, respectively.

On the python side, the use of a reference counted object is no different to any other regular instance:

def create_A():
  a = A()         # SWIG ref 'a' - new object is passed to python (count: 1)
  b1 = B(a)       # C++ ref 'a (count: 2)
  if 1 + 1 == 2:
     b2 = B(a)    # C++ ref 'a' (count: 3)
  return a        # 'b1' and 'b2' are released and deleted, C++ unref 'a' twice (count: 1)

a = create_A()    # (count: 1)
exit              # 'a' is released, SWIG unref 'a' called in the destructor wrapper (count: 0)

Note that the user doesn't explicitly need to call 'a->ref()' nor 'a->unref()' (and neither 'delete a'). Instead, SWIG takes cares of executing the "ref" and "unref" calls as needed. If the user doesn't specify the "ref/unref" feature for a type, SWIG will produce code equivalent to defining these features:

%feature("ref")   ""
%feature("unref") "delete $this;"

In other words, SWIG will not do anything special when a new object is passed to python, and it will always 'delete' the underlying object when python releases the proxy instance.

The %newobject feature is designed to indicate to the target language that it should take ownership of the returned object. When used in conjunction with a type that has the "ref" feature associated with it, it additionally emits the code in the "ref" feature into the C++ wrapper. Consider wrapping the following factory function in addition to the above:

%newobject AFactory;
A *AFactory() {
  return new A();
}

The AFactory function now acts much like a call to the A constructor with respect to memory handling:

a = AFactory()    # SWIG ref 'a' due to %newobject (count: 1)
exit              # 'a' is released, SWIG unref 'a' called in the destructor wrapper (count: 0)

6.26 Using declarations and inheritance

using declarations are sometimes used to adjust access to members of base classes. For example:

class Foo {
public:
      int  blah(int x);
};

class Bar {
public:
      double blah(double x);
};

class FooBar : public Foo, public Bar {
public:
      using Foo::blah;  
      using Bar::blah;
      char *blah(const char *x);
};

In this example, the using declarations make different versions of the overloaded blah() method accessible from the derived class. For example:

FooBar *f;
f->blah(3);         // Ok. Invokes Foo::blah(int)
f->blah(3.5);       // Ok. Invokes Bar::blah(double)
f->blah("hello");   // Ok. Invokes FooBar::blah(const char *);

SWIG emulates the same functionality when creating wrappers. For example, if you wrap this code in Python, the module works just like you would expect:

>>> import example
>>> f = example.FooBar()
>>> f.blah(3)
>>> f.blah(3.5)
>>> f.blah("hello")

using declarations can also be used to change access when applicable. For example:

class Foo {
protected:
    int x;
    int blah(int x);
};

class Bar : public Foo {
public:
    using Foo::x;       // Make x public
    using Foo::blah;    // Make blah public
};

This also works in SWIG---the exposed declarations will be wrapped normally.

When using declarations are used as shown in these examples, declarations from the base classes are copied into the derived class and wrapped normally. When copied, the declarations retain any properties that might have been attached using %rename , %ignore, or %feature. Thus, if a method is ignored in a base class, it will also be ignored by a using declaration.

Because a using declaration does not provide fine-grained control over the declarations that get imported, it may be difficult to manage such declarations in applications that make heavy use of SWIG customization features. If you can't get using to work correctly, you can always change the interface to the following:


class FooBar : public Foo, public Bar {
public:
#ifndef SWIG
      using Foo::blah;  
      using Bar::blah;
#else
      int blah(int x);         // explicitly tell SWIG about other declarations
      double blah(double x);
#endif

      char *blah(const char *x);
};

Notes:

  • If a derived class redefines a method defined in a base class, then a using declaration won't cause a conflict. For example:

    class Foo {
    public:
           int blah(int );
           double blah(double);
    };
    
    class Bar : public Foo {
    public:
           using Foo::blah;    // Only imports blah(double);
           int blah(int);
    };
    
  • Resolving ambiguity in overloading may prevent declarations from being imported by using. For example:

    %rename(blah_long) Foo::blah(long);
    class Foo {
    public:
         int blah(int);
         long blah(long);  // Renamed to blah_long
    };
    
    class Bar : public Foo {
    public:
         using Foo::blah;     // Only imports blah(int)
         double blah(double x);
    };
    

6.27 Nested classes

If the target language supports the nested classes concept (like Java), the nested C++ classes are wrapped as nested target language proxy classes. (In case of Java - "static" nested classes.) Only public nested classes are wrapped. Otherwise there is little difference between nested and normal classes.

If the target language doesn't support nested classes directly, or the support is not implemented in the language module (like for python currently), then the visible nested classes are moved to the same name space as the containing class (nesting hierarchy is "flattened"). The same behaviour may be turned on for C# and Java by the %feature ("flatnested"); If there is a class with the same name in the outer namespace the inner class (or the global one) may be renamed or ignored:

%rename (Bar_Foo) Bar::Foo;
class Foo {};
class Bar {
  public:
  class Foo {};
};

Compatibility Note: Prior to SWIG-3.0.0, there was limited nested class support. Nested classes were treated as opaque pointers. However, there was a workaround for nested class support in these older versions requiring the user to replicate the nested class in the global scope, adding in a typedef for the nested class in the global scope and using the "nestedworkaround" feature on the nested class. This resulted in approximately the same behaviour as the "flatnested" feature. With proper nested class support now available in SWIG-3.0.0, this feature has been deprecated and no longer works requiring code changes. If you see the following warning:

example.i:8: Warning 126: The nestedworkaround feature is deprecated

consider using the "flatnested" feature discussed above which generates a non-nested proxy class, like the "nestedworkaround" feature did. Alternatively, use the default nested class code generation, which may generate an equivalent to a nested proxy class in the target language, depending on the target language support.

SWIG-1.3.40 and earlier versions did not have the nestedworkaround feature and the generated code resulting from parsing nested classes did not always compile. Nested class warnings could also not be suppressed using %warnfilter.

6.28 A brief rant about const-correctness

A common issue when working with C++ programs is dealing with all possible ways in which the const qualifier (or lack thereof) will break your program, all programs linked against your program, and all programs linked against those programs.

Although SWIG knows how to correctly deal with const in its internal type system and it knows how to generate wrappers that are free of const-related warnings, SWIG does not make any attempt to preserve const-correctness in the target language. Thus, it is possible to pass const qualified objects to non-const methods and functions. For example, consider the following code in C++:

const Object * foo();
void bar(Object *);

...
// C++ code
void blah() {
   bar(foo());         // Error: bar discards const
};

Now, consider the behavior when wrapped into a Python module:

>>> bar(foo())         # Okay
>>> 

Although this is clearly a violation of the C++ type-system, fixing the problem doesn't seem to be worth the added implementation complexity that would be required to support it in the SWIG run-time type system. There are no plans to change this in future releases (although we'll never rule anything out entirely).

The bottom line is that this particular issue does not appear to be a problem for most SWIG projects. Of course, you might want to consider using another tool if maintaining constness is the most important part of your project.

6.29 Where to go for more information

If you're wrapping serious C++ code, you might want to pick up a copy of "The Annotated C++ Reference Manual" by Ellis and Stroustrup. This is the reference document we use to guide a lot of SWIG's C++ support.


7 SWIG and C++11

7.1 Introduction

This chapter gives you a brief overview about the SWIG implementation of the C++11 standard. This part of SWIG is still a work in progress.

SWIG supports the new C++ syntax changes with some minor limitations in some areas such as decltype expressions and variadic templates. Wrappers for the new STL types (unordered_ containers, result_of, tuples) are incomplete. The wrappers for the new containers would work much like the C++03 containers and users are welcome to help by adapting the existing container interface files and submitting them as a patch for inclusion in future versions of SWIG.

7.2 Core language changes

7.2.1 Rvalue reference and move semantics

SWIG correctly parses the rvalue reference syntax '&&', for example the typical usage of it in the move constructor and move assignment operator below:

class MyClass {
...
  std::vector<int> numbers;
public:
  MyClass(MyClass &&other) : numbers(std::move(other.numbers)) {}
  MyClass & operator=(MyClass &&other) {
    numbers = std::move(other.numbers);
    return *this;
  }
};

Rvalue references are designed for C++ temporaries and so are not very useful when used from non-C++ target languages. Generally you would just ignore them via %ignore before parsing the class. For example, ignore the move constructor:

%ignore MyClass::MyClass(MyClass &&);

The plan is to ignore move constructors by default in a future version of SWIG. Note that both normal assignment operators as well as move assignment operators are ignored by default in most target languages with the following warning:

example.i:18: Warning 503: Can't wrap 'operator =' unless renamed to a valid identifier.

7.2.2 Generalized constant expressions

SWIG parses and identifies the keyword constexpr, but cannot fully utilise it. These C++ compile time constants are usable as runtime constants from the target languages. Below shows example usage for assigning a C++ compile time constant from a compile time constant function:

constexpr int XXX() { return 10; }
constexpr int YYY = XXX() + 100;

When either of these is used from a target language, a runtime call is made to obtain the underlying constant.

7.2.3 Extern template

SWIG correctly parses the keywords extern template. 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.

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

7.2.4 Initializer lists

Initializer lists are very much a C++ compiler construct and are not very accessible from wrappers as they are intended for compile time initialization of classes using the special std::initializer_list type. SWIG detects usage of initializer lists and will emit a special informative warning each time one is used:

example.i:33: Warning 476: Initialization using std::initializer_list.

Initializer lists usually appear in constructors but can appear in any function or method. They often appear in constructors which are overloaded with alternative approaches to initializing a class, such as the std container's push_back method for adding elements to a container. The recommended approach then is to simply ignore the initializer-list constructor, for example:

%ignore Container::Container(std::initializer_list<int>);
class Container {
public:
  Container(std::initializer_list<int>); // initializer-list constructor
  Container();
  void push_back(const int &);
  ...
};

Alternatively you could modify the class and add another constructor for initialization by some other means, for example by a std::vector:

%include <std_vector.i>
class Container {
public:
  Container(const std::vector<int> &);
  Container(std::initializer_list<int>); // initializer-list constructor
  Container();
  void push_back(const int &);
  ...
};

And then call this constructor from your target language, for example, in Python, the following will call the constructor taking the std::vector:

>>> c = Container( [1,2,3,4] )

If you are unable to modify the class being wrapped, consider ignoring the initializer-list constructor and using %extend to add in an alternative constructor:

%include <std_vector.i>
%extend Container {
  Container(const std::vector<int> &elements) {
    Container *c = new Container();
    for (int element : elements)
      c->push_back(element);
    return c;
  }
}

%ignore Container::Container(std::initializer_list<int>);

class Container {
public:
  Container(std::initializer_list<int>); // initializer-list constructor
  Container();
  void push_back(const int &);
  ...
};

The above makes the wrappers look is as if the class had been declared as follows:

%include <std_vector.i>
class Container {
public:
  Container(const std::vector<int> &);
//  Container(std::initializer_list<int>); // initializer-list constructor (ignored)
  Container();
  void push_back(const int &);
  ...
};

std::initializer_list is simply a container that can only be initialized at compile time. As it is just a C++ type, it is possible to write typemaps for a target language container to map onto std::initializer_list. However, this can only be done for a fixed number of elements as initializer lists are not designed to be constructed with a variable number of arguments at runtime. The example below is a very simple approach which ignores any parameters passed in and merely initializes with a fixed list of fixed integer values chosen at compile time:

%typemap(in) std::initializer_list<int> {
  $1 = {10, 20, 30, 40, 50};
}
class Container {
public:
  Container(std::initializer_list<int>); // initializer-list constructor
  Container();
  void push_back(const int &);
  ...
};

Any attempt at passing in values from the target language will be ignored and be replaced by {10, 20, 30, 40, 50}. Needless to say, this approach is very limited, but could be improved upon, but only slightly. A typemap could be written to map a fixed number of elements on to the std::initializer_list, but with values decided at runtime. The typemaps would be target language specific.

Note that the default typemap for std::initializer_list does nothing but issue the warning and hence any user supplied typemaps will override it and suppress the warning.

7.2.5 Uniform initialization

The curly brackets {} for member initialization are fully supported by SWIG:

struct BasicStruct {
 int x;
 double y;
};
 
struct AltStruct {
  AltStruct(int x, double y) : x_{x}, y_{y} {}
 
  int x_;
  double y_;
};

BasicStruct var1{5, 3.2}; // only fills the struct components
AltStruct var2{2, 4.3};   // calls the constructor

Uniform initialization does not affect usage from the target language, for example in Python:

>>> a = AltStruct(10, 142.15)
>>> a.x_
10
>>> a.y_
142.15

7.2.6 Type inference

SWIG supports decltype() with some limitations. Single variables are allowed, however, expressions are not supported yet. For example, the following code will work:

int i;
decltype(i) j;

However, using an expression inside the decltype results in syntax error:

int i; int j;
decltype(i+j) k;  // syntax error

7.2.7 Range-based for-loop

This feature is part of the implementation block only. SWIG ignores it.

7.2.8 Lambda functions and expressions

SWIG correctly parses most of the Lambda functions syntax. For example:

auto val = [] { return something; };
auto sum = [](int x, int y) { return x+y; };
auto sum = [](int x, int y) -> int { return x+y; };

The lambda functions are removed from the wrappers for now, because of the lack of support for closures (scope of the lambda functions) in the target languages.

Lambda functions used to create variables can also be parsed, but due to limited support of auto when the type is deduced from the expression, the variables are simply ignored.

auto six = [](int x, int y) { return x+y; }(4, 2);

Better support should be available in a later release.

7.2.9 Alternate function syntax

SWIG fully supports the new definition of functions. For example:

struct SomeStruct {
  int FuncName(int x, int y);
};

can now be written as in C++11:

struct SomeStruct {
  auto FuncName(int x, int y) -> int;
};
 
auto SomeStruct::FuncName(int x, int y) -> int {
  return x + y;
}

The usage in the target languages remains the same, for example in Python:

>>> a = SomeStruct()
>>> a.FuncName(10,5)
15

SWIG will also deal with type inference for the return type, as per the limitations described earlier. For example:

auto square(float a, float b) -> decltype(a);

7.2.10 Object construction improvement

There are three parts to object construction improvement. The first improvement is constructor delegation such as the following:

class A {
public:
  int a;
  int b;
  int c;

  A() : A(10) {}
  A(int aa) : A(aa, 20) {}
  A(int aa, int bb) : A(aa, bb, 30) {}
  A(int aa, int bb, int cc) { a=aa; b=bb; c=cc; }
};

where peer constructors can be called. SWIG handles this without any issue.

The second improvement is constructor inheritance via a using declaration. This is parsed correctly, but the additional constructors are not currently added to the derived proxy class in the target language. An example is shown below:

class BaseClass {
public:
  BaseClass(int iValue);
};

class DerivedClass: public BaseClass {
  public:
  using BaseClass::BaseClass; // Adds DerivedClass(int) constructor
};

The final part is member initialization at the site of the declaration. This kind of initialization is handled by SWIG.

class SomeClass {
public:
    SomeClass() {}
    explicit SomeClass(int new_value) : value(new_value) {}

    int value = 5;
};

7.2.11 Explicit overrides and final

The special identifiers final and override can be used on methods and destructors, such as in the following example:

struct BaseStruct {
  virtual void ab() const = 0;
  virtual void cd();
  virtual void ef();
  virtual ~BaseStruct();
};
struct DerivedStruct : BaseStruct {
  virtual void ab() const override;
  virtual void cd() final;
  virtual void ef() final override;
  virtual ~DerivedStruct() override;
};

7.2.12 Null pointer constant

The nullptr constant is mostly unimportant in wrappers. In the few places it has an effect, it is treated like NULL.

7.2.13 Strongly typed enumerations

SWIG parses the new enum class syntax and forward declarator for the enums:

enum class MyEnum : unsigned int;

The strongly typed enumerations are treated the same as the ordinary and anonymous enums. This is because the required nested class support in SWIG is new and has not yet been incorporated into the wrapping of these strongly typed enum classes. This is usually not a problem, however, there may be some name clashes. For example, the following code:

class Color {
  enum class PrintingColors : unsigned int {
    Cyan, Magenta, Yellow, Black
  };
  
  enum class BasicColors {
    Red, Green, Blue
  };
  
  enum class AllColors {
    // produces warnings because of duplicate names
    Yellow, Orange, Red, Magenta, Blue, Cyan, Green, Pink, Black, White
  };
};

A workaround is to write these as a series of separate classes containing anonymous enums:

class PrintingColors {
  enum : unsigned int {
    Cyan, Magenta, Yellow, Black
  };
};

class BasicColors {
  enum : unsigned int {
    Red, Green, Blue
  };
};

class AllColors {
  enum : unsigned int {
    Yellow, Orange, Red, Magenta, Blue, Cyan, Green, Pink, Black, White
  };
};

Expect to see this improved in a future version of SWIG.

7.2.14 Double angle brackets

SWIG correctly parses the symbols >> as closing the template block, if found inside it at the top level, or as the right shift operator >> otherwise.

std::vector<std::vector<int>> myIntTable;

7.2.15 Explicit conversion operators

SWIG correctly parses the keyword explicit for operators in addition to constructors now. For example:

class U {
public:
  int u;
};

class V {
public:
  int v;
};

class TestClass {
public:
  //implicit converting constructor
  TestClass(U const &val) { t=val.u; }

  // explicit constructor
  explicit TestClass(V const &val) { t=val.v; }

  int t;
};

struct Testable {
  // explicit conversion operator
  explicit operator bool() const {
    return false;
  }
};

The effect of explicit constructors and operators has little relevance for the proxy classes as target languages don't have the same concepts of implicit conversions as C++. Conversion operators either with or without explicit need renaming to a valid identifier name in order to make them available as a normal proxy method.

7.2.16 Alias templates

The following is an example of an alias template:

template< typename T1, typename T2, int >
class SomeType {
  T1 a;
  T2 b;
  int c;
};

template< typename T2 >
using TypedefName = SomeType<char*, T2, 5>;

These are partially supported as SWIG will parse these and identify them, however, they are ignored as they are not added to the type system. A warning such as the following is issued:

example.i:13: Warning 342: The 'using' keyword in template aliasing is not fully supported yet.

Similarly for non-template type aliasing:

using PFD = void (*)(double); // New introduced syntax

A warning will be issued:

example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.

The equivalent old style typedefs can be used as a workaround:

typedef void (*PFD)(double);  // The old style

7.2.17 Unrestricted unions

SWIG fully supports any type inside a union even if it does not define a trivial constructor. For example, the wrapper for the following code correctly provides access to all members in the union:

struct point {
  point() {}
  point(int x, int y) : x_(x), y_(y) {}
  int x_, y_;
};

#include <new> // For placement 'new' in the constructor below
union P {
  int z;
  double w;
  point p; // Illegal in C++03; legal in C++11.
  // Due to the point member, a constructor definition is required.
  P() {
    new(&p) point();
  }
} p1;

7.2.18 Variadic templates

SWIG supports the variadic templates syntax (inside the <> block, variadic class inheritance and variadic constructor and initializers) with some limitations. The following code is correctly parsed:

template <typename... BaseClasses> class ClassName : public BaseClasses... {
public:
   ClassName (BaseClasses &&... baseClasses) : BaseClasses(baseClasses)... {}
}

For now however, the %template directive only accepts one parameter substitution for the variable template parameters.

%template(MyVariant1) ClassName<>         // zero argument not supported yet
%template(MyVariant2) ClassName<int>      // ok
%template(MyVariant3) ClassName<int, int> // too many arguments not supported yet

Support for the variadic sizeof() function is correctly parsed:

const int SIZE = sizeof...(ClassName<int, int>);

In the above example SIZE is of course wrapped as a constant.

7.2.19 New string literals

SWIG supports wide string and Unicode string constants and raw string literals.

// New string literals
wstring         aa =  L"Wide string";
const char     *bb = u8"UTF-8 string";
const char16_t *cc =  u"UTF-16 string";
const char32_t *dd =  U"UTF-32 string";

// Raw string literals
const char      *xx =        ")I'm an \"ascii\" \\ string.";
const char      *ee =   R"XXX()I'm an "ascii" \ string.)XXX"; // same as xx
wstring          ff =  LR"XXX(I'm a "raw wide" \ string.)XXX";
const char      *gg = u8R"XXX(I'm a "raw UTF-8" \ string.)XXX";
const char16_t  *hh =  uR"XXX(I'm a "raw UTF-16" \ string.)XXX";
const char32_t  *ii =  UR"XXX(I'm a "raw UTF-32" \ string.)XXX";

Non-ASCII string support varies quite a bit among the various target languages though.

Note: There is a bug currently where SWIG's preprocessor incorrectly parses an odd number of double quotes inside raw string literals.

7.2.20 User-defined literals

SWIG parses the declaration of user-defined literals, that is, the operator "" _mysuffix() function syntax.

Some examples are the raw literal:

OutputType operator "" _myRawLiteral(const char * value);

numeric cooked literals:

OutputType operator "" _mySuffixIntegral(unsigned long long);
OutputType operator "" _mySuffixFloat(long double);

and cooked string literals:

OutputType operator "" _mySuffix(const char * string_values, size_t num_chars);
OutputType operator "" _mySuffix(const wchar_t * string_values, size_t num_chars);
OutputType operator "" _mySuffix(const char16_t * string_values, size_t num_chars);
OutputType operator "" _mySuffix(const char32_t * string_values, size_t num_chars);

Like other operators that SWIG parses, a warning is given about renaming the operator in order for it to be wrapped:

example.i:27: Warning 503: Can't wrap 'operator "" _myRawLiteral' unless renamed to a valid identifier.

If %rename is used, then it can be called like any other wrapped method. Currently you need to specify the full declaration including parameters for %rename:

%rename(MyRawLiteral)  operator"" _myRawLiteral(const char * value);

Or if you just wish to ignore it altogether:

%ignore operator "" _myRawLiteral(const char * value);

Note that use of user-defined literals such as the following still give a syntax error:

OutputType var1 = "1234"_suffix;
OutputType var2 = 1234_suffix;
OutputType var3 = 3.1416_suffix;

7.2.21 Thread-local storage

SWIG correctly parses the thread_local keyword. For example, variables reachable by the current thread can be defined as:

struct A {
   static thread_local int val;
};
thread_local int global_val;

The use of the thread_local storage specifier does not affect the wrapping process; it does not modify the wrapper code compared to when it is not specified. A variable will be thread local if accessed from different threads from the target language in the same way that it will be thread local if accessed from C++ code.

7.2.22 Explicitly defaulted functions and deleted functions

SWIG handles explicitly defaulted functions, that is, = default added to a function declaration. Deleted definitions, which are also called deleted functions, have = delete added to the function declaration. For example:

struct NonCopyable {
  NonCopyable & operator=(const NonCopyable &) = delete; /* Removes operator= */
  NonCopyable(const NonCopyable &) = delete;             /* Removes copy constructor */
  NonCopyable() = default;                               /* Explicitly allows the empty constructor */
};

Wrappers for deleted functions will not be available in the target language. Wrappers for defaulted functions will of course be available in the target language. Explicitly defaulted functions have no direct effect for SWIG wrapping as the declaration is handled much like any other method declaration parsed by SWIG.

Deleted functions are also designed to prevent implicit conversions when calling the function. For example, the C++ compiler will not compile any code which attempts to use an int as the type of the parameter passed to f below:

struct NoInt {
    void f(double i);
    void f(int) = delete;
};

This is a C++ compile time check and SWIG does not make any attempt to detect if the target language is using an int instead of a double though, so in this case it is entirely possible to pass an int instead of a double to f from Java, Python etc.

7.2.23 Type long long int

SWIG correctly parses and uses the new long long type already introduced in C99 some time ago.

7.2.24 Static assertions

SWIG correctly parses the new static_assert declarations. This is a C++ compile time directive so there isn't anything useful that SWIG can do with it.

template <typename T>
struct Check {
  static_assert(sizeof(int) <= sizeof(T), "not big enough");
};

7.2.25 Allow sizeof to work on members of classes without an explicit object

SWIG can parse the new sizeof() on types as well as on objects. For example:

struct A {
  int member;
};

const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++11

In Python:

>>> SIZE
8

7.2.26 Exception specifications and noexcept

C++11 added in the noexcept specification to exception specifications to indicate that a function simply may or may not throw an exception, without actually naming any exception. SWIG understands these, although there isn't any useful way that this information can be taken advantage of by target languages, so it is as good as ignored during the wrapping process. Below are some examples of noexcept in function declarations:

static void noex1() noexcept;
int noex2(int) noexcept(true);
int noex3(int, bool) noexcept(false);

7.2.27 Control and query object alignment

An alignof operator is used mostly within C++ to return alignment in number of bytes, but could be used to initialize a variable as shown below. The variable's value will be available for access by the target language as any other variable's compile time initialised value.

const int align1 = alignof(A::member);

The alignas specifier for variable alignment is not yet supported. Example usage:

struct alignas(16) S {
  int num;
};
alignas(double) unsigned char c[sizeof(double)];

Use the preprocessor to work around this for now:

#define alignas(T)

7.2.28 Attributes

Attributes such as those shown below, are not yet supported and will give a syntax error.

int [[attr1]] i [[attr2, attr3]];

[[noreturn, nothrow]] void f [[noreturn]] ();

7.3 Standard library changes

7.3.1 Threading facilities

SWIG does not currently wrap or use any of the new threading classes introduced (thread, mutex, locks, condition variables, task). The main reason is that SWIG target languages offer their own threading facilities so there is limited use for them.

7.3.2 Tuple types

SWIG does not provide library files for the new tuple types yet. Variadic template support requires further work to provide substantial tuple wrappers.

7.3.3 Hash tables

The new hash tables in the STL are unordered_set, unordered_multiset, unordered_map, unordered_multimap . These are not available in SWIG, but in principle should be easily implemented by adapting the current STL containers.

7.3.4 Regular expressions

While SWIG could provide wrappers for the new C++11 regular expressions classes, there is little need as the target languages have their own regular expression facilities.

7.3.5 General-purpose smart pointers

SWIG provides special smart pointer handling for std::shared_ptr in the same way it has support for boost::shared_ptr. Please see the shared_ptr smart pointer library section. There is no special smart pointer handling available for std::weak_ptr and std::unique_ptr yet.

7.3.6 Extensible random number facility

This feature extends and standardizes the standard library only and does not effect the C++ language nor SWIG.

7.3.7 Wrapper reference

Wrapper references are similar to normal C++ references but are copy-constructible and copy-assignable. They could conceivably be used in public APIs. There is no special support for std::reference_wrapper in SWIG though. Users would need to write their own typemaps if wrapper references are being used and these would be similar to the plain C++ reference typemaps.

7.3.8 Polymorphous wrappers for function objects

SWIG supports functor classes in a few languages in a very natural way. However nothing is provided yet for the new std::function template. SWIG will parse usage of the template like any other template.

%rename(__call__) Test::operator(); // Default renaming used for Python

struct Test {
  bool operator()(int x, int y); // function object
};

#include <functional>
std::function<void (int, int)> pF = Test;   // function template wrapper

Example of supported usage of the plain functor from Python is shown below. It does not involve std::function.

t = Test()
b = t(1,2) # invoke C++ function object

7.3.9 Type traits for metaprogramming

The type_traits functions to support C++ metaprogramming is useful at compile time and is aimed specifically at C++ development:

#include <type_traits>

// First way of operating.
template< bool B > struct algorithm {
  template< class T1, class T2 > static int do_it(T1 &, T2 &)  { /*...*/ return 1; }
};

// Second way of operating.
template<> struct algorithm<true> {
  template< class T1, class T2 > static int do_it(T1, T2)  { /*...*/ return 2; }
};

// Instantiating 'elaborate' will automatically instantiate the correct way to operate, depending on the types used.
template< class T1, class T2 > int elaborate(T1 A, T2 B) {
  // Use the second way only if 'T1' is an integer and if 'T2' is a floating point,
  // otherwise use the first way.
  return algorithm< std::is_integral<T1>::value && std::is_floating_point<T2>::value >::do_it(A, B);
}

SWIG correctly parses the template specialization, template types etc. However, metaprogramming and the additional support in the type_traits header is really for compile time and is not much use at runtime for the target languages. For example, as SWIG requires explicit instantiation of templates via %template, there isn't much that std::is_integral<int> is going to provide by itself. However, template functions using such metaprogramming techniques might be useful to wrap. For example, the following instantiations could be made:

%template(Elaborate) elaborate<int, int>;
%template(Elaborate) elaborate<int, double>;

Then the appropriate algorithm can be called for the subset of types given by the above %template instantiations from a target language, such as Python:

>>> Elaborate(0, 0)
1
>>> Elaborate(0, 0.0)
2

7.3.10 Uniform method for computing return type of function objects

The new std::result_of class introduced in the <functional> header provides a generic way to obtain the return type of a function type via std::result_of::type. There isn't any library interface file to support this type. With a bit of work, SWIG will deduce the return type of functions when used in std::result_of using the approach shown below. The technique basically forward declares the std::result_of template class, then partially specializes it for the function types of interest. SWIG will use the partial specialization and hence correctly use the std::result_of::type provided in the partial specialization.

%inline %{
#include <functional>
typedef double(*fn_ptr)(double);
%}

namespace std {
  // Forward declaration of result_of
  template<typename Func> struct result_of;
  // Add in a partial specialization of result_of
  template<> struct result_of< fn_ptr(double) > {
    typedef double type;
  };
}

%template() std::result_of< fn_ptr(double) >;

%inline %{

double square(double x) {
  return (x * x);
}

template<class Fun, class Arg>
typename std::result_of<Fun(Arg)>::type test_result_impl(Fun fun, Arg arg) {
  return fun(arg);
}
%}

%template(test_result) test_result_impl< fn_ptr, double >;
%constant double (*SQUARE)(double) = square;

Note the first use of %template which SWIG requires to instantiate the template. The empty template instantiation suffices as no proxy class is required for std::result_of<Fun(Arg)>::type as this type is really just a double. The second %template instantiates the template function which is being wrapped for use as a callback. The %constant can then be used for any callback function as described in Pointers to functions and callbacks.

Example usage from Python should give the not too surprising result:

>>> test_result(SQUARE, 5.0)
25.0

Phew, that is a lot of hard work to get a callback working. You could just go with the more attractive option of just using double as the return type in the function declaration instead of result_of !


8 Preprocessing

SWIG includes its own enhanced version of the C preprocessor. The preprocessor supports the standard preprocessor directives and macro expansion rules. However, a number of modifications and enhancements have been made. This chapter describes some of these modifications.

8.1 File inclusion

To include another file into a SWIG interface, use the %include directive like this:

%include "pointer.i"

Unlike, #include, %include includes each file once (and will not reload the file on subsequent %include declarations). Therefore, it is not necessary to use include-guards in SWIG interfaces.

By default, the #include is ignored unless you run SWIG with the -includeall option. The reason for ignoring traditional includes is that you often don't want SWIG to try and wrap everything included in standard header system headers and auxiliary files.

8.2 File imports

SWIG provides another file inclusion directive with the %import directive. For example:

%import "foo.i"

The purpose of %import is to collect certain information from another SWIG interface file or a header file without actually generating any wrapper code. Such information generally includes type declarations (e.g., typedef) as well as C++ classes that might be used as base-classes for class declarations in the interface. The use of %import is also important when SWIG is used to generate extensions as a collection of related modules. This is an advanced topic and is described in later in the Working with Modules chapter.

The -importall directive tells SWIG to follow all #include statements as imports. This might be useful if you want to extract type definitions from system header files without generating any wrappers.

8.3 Conditional Compilation

SWIG fully supports the use of #if, #ifdef, #ifndef, #else, #endif to conditionally include parts of an interface. The following symbols are predefined by SWIG when it is parsing the interface:

SWIG                            Always defined when SWIG is processing a file
SWIGIMPORTED                    Defined when SWIG is importing a file with %import
SWIG_VERSION                    Hexadecimal (binary-coded decimal) number containing SWIG version,
                                such as 0x010311 (corresponding to SWIG-1.3.11).

SWIGALLEGROCL                   Defined when using Allegro CL
SWIGCFFI                        Defined when using CFFI
SWIGCHICKEN                     Defined when using CHICKEN
SWIGCLISP                       Defined when using CLISP
SWIGCSHARP                      Defined when using C#
SWIGGUILE                       Defined when using Guile
SWIGJAVA                        Defined when using Java
SWIGJAVASCRIPT                  Defined when using Javascript
SWIG_JAVASCRIPT_JSC             Defined when using Javascript for JavascriptCore
SWIG_JAVASCRIPT_V8              Defined when using Javascript for v8 or node.js 
SWIGLUA                         Defined when using Lua
SWIGMODULA3                     Defined when using Modula-3
SWIGMZSCHEME                    Defined when using Mzscheme        
SWIGOCAML                       Defined when using Ocaml
SWIGOCTAVE                      Defined when using Octave
SWIGPERL                        Defined when using Perl
SWIGPHP                         Defined when using PHP
SWIGPIKE                        Defined when using Pike
SWIGPYTHON                      Defined when using Python
SWIGR                           Defined when using R
SWIGRUBY                        Defined when using Ruby
SWIGSEXP                        Defined when using S-expressions
SWIGTCL                         Defined when using Tcl
SWIGXML                         Defined when using XML

In addition, SWIG defines the following set of standard C/C++ macros:

__LINE__                        Current line number
__FILE__                        Current file name
__STDC__                        Defined to indicate ANSI C
__cplusplus                     Defined when -c++ option used

Interface files can look at these symbols as necessary to change the way in which an interface is generated or to mix SWIG directives with C code. These symbols are also defined within the C code generated by SWIG (except for the symbol `SWIG' which is only defined within the SWIG compiler).

8.4 Macro Expansion

Traditional preprocessor macros can be used in SWIG interfaces. Be aware that the #define statement is also used to try and detect constants. Therefore, if you have something like this in your file,

#ifndef _FOO_H 1
#define _FOO_H 1
...
#endif

you may get some extra constants such as _FOO_H showing up in the scripting interface.

More complex macros can be defined in the standard way. For example:

#define EXTERN extern
#ifdef __STDC__
#define _ANSI(args)   (args)
#else
#define _ANSI(args) ()
#endif

The following operators can appear in macro definitions:

  • #x
    Converts macro argument x to a string surrounded by double quotes ("x").
  • x ## y
    Concatenates x and y together to form xy.
  • `x`
    If x is a string surrounded by double quotes, do nothing. Otherwise, turn into a string like #x. This is a non-standard SWIG extension.

8.5 SWIG Macros

SWIG provides an enhanced macro capability with the %define and %enddef directives. For example:

%define ARRAYHELPER(type,name)
%inline %{
type *new_ ## name (int nitems) {
   return (type *) malloc(sizeof(type)*nitems);
}
void delete_ ## name(type *t) {
   free(t);
}
type name ## _get(type *t, int index) {
   return t[index];
}
void name ## _set(type *t, int index, type val) {
   t[index] = val;
}
%}
%enddef

ARRAYHELPER(int, IntArray)
ARRAYHELPER(double, DoubleArray)

The primary purpose of %define is to define large macros of code. Unlike normal C preprocessor macros, it is not necessary to terminate each line with a continuation character (\)--the macro definition extends to the first occurrence of %enddef. Furthermore, when such macros are expanded, they are reparsed through the C preprocessor. Thus, SWIG macros can contain all other preprocessor directives except for nested %define statements.

The SWIG macro capability is a very quick and easy way to generate large amounts of code. In fact, many of SWIG's advanced features and libraries are built using this mechanism (such as C++ template support).

8.6 C99 and GNU Extensions

SWIG-1.3.12 and newer releases support variadic preprocessor macros. For example:

#define DEBUGF(fmt,...)   fprintf(stderr,fmt,__VA_ARGS__)

When used, any extra arguments to ... are placed into the special variable __VA_ARGS__. This also works with special SWIG macros defined using %define.

SWIG allows a variable number of arguments to be empty. However, this often results in an extra comma (,) and syntax error in the resulting expansion. For example:

DEBUGF("hello");   --> fprintf(stderr,"hello",);

To get rid of the extra comma, use ## like this:

#define DEBUGF(fmt,...)   fprintf(stderr,fmt, ##__VA_ARGS__)

SWIG also supports GNU-style variadic macros. For example:

#define DEBUGF(fmt, args...)  fprintf(stdout,fmt,args)

Comment: It's not entirely clear how variadic macros might be useful to interface building. However, they are used internally to implement a number of SWIG directives and are provided to make SWIG more compatible with C99 code.

8.7 Preprocessing and delimiters

The preprocessor handles { }, " " and %{ %} delimiters differently.

8.7.1 Preprocessing and %{ ... %} & " ... " delimiters

The SWIG preprocessor does not process any text enclosed in a code block %{ ... %}. Therefore, if you write code like this,

%{
#ifdef NEED_BLAH
int blah() {
   ...
}
#endif
%}

the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

8.7.2 Preprocessing and { ... } delimiters

SWIG always runs the preprocessor on text appearing inside { ... }. However, sometimes it is desirable to make a preprocessor directive pass through to the output file. For example:

%extend Foo {
   void bar() {
      #ifdef DEBUG
       printf("I'm in bar\n");
      #endif
   }
}

By default, SWIG will interpret the #ifdef DEBUG statement. However, if you really wanted that code to actually go into the wrapper file, prefix the preprocessor directives with % like this:

%extend Foo {
   void bar() {
      %#ifdef DEBUG
       printf("I'm in bar\n");
      %#endif
   }
}

SWIG will strip the extra % and leave the preprocessor directive in the code.

8.8 Preprocessor and Typemaps

Typemaps support a special attribute called noblock where the { ... } delimiters can be used, but the delimiters are not actually generated into the code. The effect is then similar to using "" or %{ %} delimiters but the code is run through the preprocessor. For example:

#define SWIG_macro(CAST) (CAST)$input
%typemap(in) Int {$1= SWIG_macro(int);}

might generate

  {
    arg1=(int)jarg1;
  }

whereas

#define SWIG_macro(CAST) (CAST)$input
%typemap(in,noblock=1) Int {$1= SWIG_macro(int);}

might generate

  arg1=(int)jarg1;

and

#define SWIG_macro(CAST) (CAST)$input
%typemap(in) Int %{$1=SWIG_macro(int);%}

would generate

  arg1=SWIG_macro(int);

8.9 Viewing preprocessor output

Like many compilers, SWIG supports a -E command line option to display the output from the preprocessor. When the -E switch is used, SWIG will not generate any wrappers. Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

8.10 The #error and #warning directives

SWIG supports the commonly used #warning and #error preprocessor directives. The #warning directive will cause SWIG to issue a warning then continue processing. The #error directive will cause SWIG to exit with a fatal error. Example usage:

#error "This is a fatal error message"
#warning "This is a warning message"

The #error behaviour can be made to work like #warning if the -cpperraswarn commandline option is used. Alternatively, the #pragma directive can be used to the same effect, for example:

  /* Modified behaviour: #error does not cause SWIG to exit with error */
  #pragma SWIG cpperraswarn=1
  /* Normal behaviour: #error does cause SWIG to exit with error */
  #pragma SWIG cpperraswarn=0

9 SWIG library

To help build extension modules, SWIG is packaged with a library of support files that you can include in your own interfaces. These files often define new SWIG directives or provide utility functions that can be used to access parts of the standard C and C++ libraries. This chapter provides a reference to the current set of supported library files.

Compatibility note: Older versions of SWIG included a number of library files for manipulating pointers, arrays, and other structures. Most these files are now deprecated and have been removed from the distribution. Alternative libraries provide similar functionality. Please read this chapter carefully if you used the old libraries.

9.1 The %include directive and library search path

Library files are included using the %include directive. When searching for files, directories are searched in the following order:

  1. The current directory
  2. Directories specified with the -I command line option
  3. ./swig_lib
  4. SWIG library install location as reported by swig -swiglib, for example /usr/local/share/swig/1.3.30
  5. On Windows, a directory Lib relative to the location of swig.exe is also searched.

Within directories mentioned in points 3-5, SWIG first looks for a subdirectory corresponding to a target language (e.g., python, tcl, etc.). If found, SWIG will search the language specific directory first. This allows for language-specific implementations of library files.

You can ignore the installed SWIG library by setting the SWIG_LIB environment variable. Set the environment variable to hold an alternative library directory.

The directories that are searched are displayed when using -verbose commandline option.

9.2 C Arrays and Pointers

This section describes library modules for manipulating low-level C arrays and pointers. The primary use of these modules is in supporting C declarations that manipulate bare pointers such as int *, double *, or void *. The modules can be used to allocate memory, manufacture pointers, dereference memory, and wrap pointers as class-like objects. Since these functions provide direct access to memory, their use is potentially unsafe and you should exercise caution.

9.2.1 cpointer.i

The cpointer.i module defines macros that can be used to used to generate wrappers around simple C pointers. The primary use of this module is in generating pointers to primitive datatypes such as int and double.

%pointer_functions(type,name)

Generates a collection of four functions for manipulating a pointer type *:

type *new_name()

Creates a new object of type type and returns a pointer to it. In C, the object is created using calloc(). In C++, new is used.

type *copy_name(type value)

Creates a new object of type type and returns a pointer to it. An initial value is set by copying it from value. In C, the object is created using calloc(). In C++, new is used.

type *delete_name(type *obj)

Deletes an object type type.

void name_assign(type *obj, type value)

Assigns *obj = value.

type name_value(type *obj)

Returns the value of *obj.

When using this macro, type may be any type and name must be a legal identifier in the target language. name should not correspond to any other name used in the interface file.

Here is a simple example of using %pointer_functions():

%module example
%include "cpointer.i"

/* Create some functions for working with "int *" */
%pointer_functions(int, intp);

/* A function that uses an "int *" */
void add(int x, int y, int *result);

Now, in Python:

>>> import example
>>> c = example.new_intp()     # Create an "int" for storing result
>>> example.add(3,4,c)         # Call function
>>> example.intp_value(c)      # Dereference
7
>>> example.delete_intp(c)     # Delete

%pointer_class(type,name)

Wraps a pointer of type * inside a class-based interface. This interface is as follows:

struct name {
   name();                            // Create pointer object
  ~name();                            // Delete pointer object
   void assign(type value);           // Assign value
   type value();                      // Get value
   type *cast();                      // Cast the pointer to original type
   static name *frompointer(type *);  // Create class wrapper from existing
                                      // pointer
};

When using this macro, type is restricted to a simple type name like int, float, or Foo. Pointers and other complicated types are not allowed. name must be a valid identifier not already in use. When a pointer is wrapped as a class, the "class" may be transparently passed to any function that expects the pointer.

If the target language does not support proxy classes, the use of this macro will produce the example same functions as %pointer_functions() macro.

It should be noted that the class interface does introduce a new object or wrap a pointer inside a special structure. Instead, the raw pointer is used directly.

Here is the same example using a class instead:

%module example
%include "cpointer.i"

/* Wrap a class interface around an "int *" */
%pointer_class(int, intp);

/* A function that uses an "int *" */
void add(int x, int y, int *result);

Now, in Python (using proxy classes)

>>> import example
>>> c = example.intp()         # Create an "int" for storing result
>>> example.add(3,4,c)         # Call function
>>> c.value()                  # Dereference
7

Of the two macros, %pointer_class is probably the most convenient when working with simple pointers. This is because the pointers are access like objects and they can be easily garbage collected (destruction of the pointer object destroys the underlying object).

%pointer_cast(type1, type2, name)

Creates a casting function that converts type1 to type2 . The name of the function is name. For example:

%pointer_cast(int *, unsigned int *, int_to_uint);

In this example, the function int_to_uint() would be used to cast types in the target language.

Note: None of these macros can be used to safely work with strings (char * or char **).

Note: When working with simple pointers, typemaps can often be used to provide more seamless operation.

9.2.2 carrays.i

This module defines macros that assist in wrapping ordinary C pointers as arrays. The module does not provide any safety or an extra layer of wrapping--it merely provides functionality for creating, destroying, and modifying the contents of raw C array data.

%array_functions(type,name)

Creates four functions.

type *new_name(int nelements)

Creates a new array of objects of type type. In C, the array is allocated using calloc(). In C++, new [] is used.

type *delete_name(type *ary)

Deletes an array. In C, free() is used. In C++, delete [] is used.

type name_getitem(type *ary, int index)

Returns the value ary[index].

void name_setitem(type *ary, int index, type value)

Assigns ary[index] = value.

When using this macro, type may be any type and name must be a legal identifier in the target language. name should not correspond to any other name used in the interface file.

Here is an example of %array_functions(). Suppose you had a function like this:

void print_array(double x[10]) {
   int i;
   for (i = 0; i < 10; i++) {
      printf("[%d] = %g\n", i, x[i]);
   }
}

To wrap it, you might write this:

%module example

%include "carrays.i"
%array_functions(double, doubleArray);

void print_array(double x[10]);

Now, in a scripting language, you might write this:

a = new_doubleArray(10)           # Create an array
for i in range(0,10):
    doubleArray_setitem(a,i,2*i)  # Set a value
print_array(a)                    # Pass to C
delete_doubleArray(a)             # Destroy array

%array_class(type,name)

Wraps a pointer of type * inside a class-based interface. This interface is as follows:

struct name {
   name(int nelements);                  // Create an array
  ~name();                               // Delete array
   type getitem(int index);              // Return item
   void setitem(int index, type value);  // Set item
   type *cast();                         // Cast to original type
   static name *frompointer(type *);     // Create class wrapper from
                                         // existing pointer
};

When using this macro, type is restricted to a simple type name like int or float. Pointers and other complicated types are not allowed. name must be a valid identifier not already in use. When a pointer is wrapped as a class, it can be transparently passed to any function that expects the pointer.

When combined with proxy classes, the %array_class() macro can be especially useful. For example:

%module example
%include "carrays.i"
%array_class(double, doubleArray);

void print_array(double x[10]);

Allows you to do this:

import example
c = example.doubleArray(10)  # Create double[10]
for i in range(0,10):
    c[i] = 2*i               # Assign values
example.print_array(c)       # Pass to C

Note: These macros do not encapsulate C arrays inside a special data structure or proxy. There is no bounds checking or safety of any kind. If you want this, you should consider using a special array object rather than a bare pointer.

Note: %array_functions() and %array_class() should not be used with types of char or char *.

9.2.3 cmalloc.i

This module defines macros for wrapping the low-level C memory allocation functions malloc(), calloc(), realloc(), and free().

%malloc(type [,name=type])

Creates a wrapper around malloc() with the following prototype:

type *malloc_name(int nbytes = sizeof(type));

If type is void, then the size parameter nbytes is required. The name parameter only needs to be specified when wrapping a type that is not a valid identifier (e.g., " int *", "double **", etc.).

%calloc(type [,name=type])

Creates a wrapper around calloc() with the following prototype:

type *calloc_name(int nobj =1, int sz = sizeof(type));

If type is void, then the size parameter sz is required.

%realloc(type [,name=type])

Creates a wrapper around realloc() with the following prototype:

type *realloc_name(type *ptr, int nitems);

Note: unlike the C realloc(), the wrapper generated by this macro implicitly includes the size of the corresponding type. For example, realloc_int(p, 100) reallocates p so that it holds 100 integers.

%free(type [,name=type])

Creates a wrapper around free() with the following prototype:

void free_name(type *ptr);

%sizeof(type [,name=type])

Creates the constant:

%constant int sizeof_name = sizeof(type);

%allocators(type [,name=type])

Generates wrappers for all five of the above operations.

Here is a simple example that illustrates the use of these macros:

// SWIG interface
%module example
%include "cmalloc.i"

%malloc(int);
%free(int);

%malloc(int *, intp);
%free(int *, intp);

%allocators(double);

Now, in a script:

>>> from example import *
>>> a = malloc_int()
>>> a
'_000efa70_p_int'
>>> free_int(a)
>>> b = malloc_intp()
>>> b
'_000efb20_p_p_int'
>>> free_intp(b)
>>> c = calloc_double(50)
>>> c
'_000fab98_p_double'
>>> c = realloc_double(100000)
>>> free_double(c)
>>> print sizeof_double
8
>>>

9.2.4 cdata.i

The cdata.i module defines functions for converting raw C data to and from strings in the target language. The primary applications of this module would be packing/unpacking of binary data structures---for instance, if you needed to extract data from a buffer. The target language must support strings with embedded binary data in order for this to work.

const char *cdata(void *ptr, size_t nbytes)

Converts nbytes of data at ptr into a string. ptr can be any pointer.

void memmove(void *ptr, const char *s)

Copies all of the string data in s into the memory pointed to by ptr. The string may contain embedded NULL bytes. This is actually a wrapper to the standard C library memmove function, which is declared as void memmove(void *ptr, const void *src, size_t n). The src and length n parameters are extracted from the language specific string s in the underlying wrapper code.

One use of these functions is packing and unpacking data from memory. Here is a short example:

// SWIG interface
%module example
%include "carrays.i"
%include "cdata.i"

%array_class(int, intArray);

Python example:

>>> a = intArray(10)
>>> for i in range(0,10):
...    a[i] = i
>>> b = cdata(a,40)
>>> b
'\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04
\x00\x00\x00\x05\x00\x00\x00\x06\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\t'
>>> c = intArray(10)
>>> memmove(c,b)
>>> print c[4]
4
>>>

Since the size of data is not always known, the following macro is also defined:

%cdata(type [,name=type])

Generates the following function for extracting C data for a given type.

char *cdata_name(type* ptr, int nitems)

nitems is the number of items of the given type to extract.

Note: These functions provide direct access to memory and can be used to overwrite data. Clearly they are unsafe.

9.3 C String Handling

A common problem when working with C programs is dealing with functions that manipulate raw character data using char *. In part, problems arise because there are different interpretations of char *---it could be a NULL-terminated string or it could point to binary data. Moreover, functions that manipulate raw strings may mutate data, perform implicit memory allocations, or utilize fixed-sized buffers.

The problems (and perils) of using char * are well-known. However, SWIG is not in the business of enforcing morality. The modules in this section provide basic functionality for manipulating raw C strings.

9.3.1 Default string handling

Suppose you have a C function with this prototype:

char *foo(char *s);

The default wrapping behavior for this function is to set s to a raw char * that refers to the internal string data in the target language. In other words, if you were using a language like Tcl, and you wrote this,

% foo Hello

then s would point to the representation of "Hello" inside the Tcl interpreter. When returning a char *, SWIG assumes that it is a NULL-terminated string and makes a copy of it. This gives the target language its own copy of the result.

There are obvious problems with the default behavior. First, since a char * argument points to data inside the target language, it is NOT safe for a function to modify this data (doing so may corrupt the interpreter and lead to a crash). Furthermore, the default behavior does not work well with binary data. Instead, strings are assumed to be NULL-terminated.

9.3.2 Passing binary data

If you have a function that expects binary data,

size_t parity(char *str, size_t len, size_t initial);

you can wrap the parameters (char *str, size_t len) as a single argument using a typemap. Just do this:

%apply (char *STRING, size_t LENGTH) { (char *str, size_t len) };
...
size_t parity(char *str, size_t len, size_t initial);

Now, in the target language, you can use binary string data like this:

>>> s = "H\x00\x15eg\x09\x20"
>>> parity(s,0)

In the wrapper function, the passed string will be expanded to a pointer and length parameter. The (char *STRING, int LENGTH) multi-argument typemap is also available in addition to (char *STRING, size_t LENGTH).

9.3.3 Using %newobject to release memory

If you have a function that allocates memory like this,

char *foo() {
   char *result = (char *) malloc(...);
   ...
   return result;
}

then the SWIG generated wrappers will have a memory leak--the returned data will be copied into a string object and the old contents ignored.

To fix the memory leak, use the %newobject directive.

%newobject foo;
...
char *foo();

This will release the result if the appropriate target language support is available. SWIG provides the appropriate "newfree" typemap for char * so that the memory is released, however, you may need to provide your own "newfree" typemap for other types. See Object ownership and %newobject for more details.

9.3.4 cstring.i

The cstring.i library file provides a collection of macros for dealing with functions that either mutate string arguments or which try to output string data through their arguments. An example of such a function might be this rather questionable implementation:

void get_path(char *s) {
    // Potential buffer overflow---uh, oh.
    sprintf(s,"%s/%s", base_directory, sub_directory);
}
...
// Somewhere else in the C program
{
    char path[1024];
    ...
    get_path(path);
    ...
}

(Off topic rant: If your program really has functions like this, you would be well-advised to replace them with safer alternatives involving bounds checking).

The macros defined in this module all expand to various combinations of typemaps. Therefore, the same pattern matching rules and ideas apply.

%cstring_bounded_output(parm, maxsize)

Turns parameter parm into an output value. The output string is assumed to be NULL-terminated and smaller than maxsize characters. Here is an example:

%cstring_bounded_output(char *path, 1024);
...
void get_path(char *path);

In the target language:

>>> get_path()
/home/beazley/packages/Foo/Bar
>>>

Internally, the wrapper function allocates a small buffer (on the stack) of the requested size and passes it as the pointer value. Data stored in the buffer is then returned as a function return value. If the function already returns a value, then the return value and the output string are returned together (multiple return values). If more than maxsize bytes are written, your program will crash with a buffer overflow!

%cstring_chunk_output(parm, chunksize)

Turns parameter parm into an output value. The output string is always chunksize and may contain binary data. Here is an example:

%cstring_chunk_output(char *packet, PACKETSIZE);
...
void get_packet(char *packet);

In the target language:

>>> get_packet()
'\xa9Y:\xf6\xd7\xe1\x87\xdbH;y\x97\x7f\xd3\x99\x14V\xec\x06\xea\xa2\x88'
>>>

This macro is essentially identical to %cstring_bounded_output . The only difference is that the result is always chunksize characters. Furthermore, the result can contain binary data. If more than maxsize bytes are written, your program will crash with a buffer overflow!

%cstring_bounded_mutable(parm, maxsize)

Turns parameter parm into a mutable string argument. The input string is assumed to be NULL-terminated and smaller than maxsize characters. The output string is also assumed to be NULL-terminated and less than maxsize characters.

%cstring_bounded_mutable(char *ustr, 1024);
...
void make_upper(char *ustr);

In the target language:

>>> make_upper("hello world")
'HELLO WORLD'
>>>

Internally, this macro is almost exactly the same as %cstring_bounded_output. The only difference is that the parameter accepts an input value that is used to initialize the internal buffer. It is important to emphasize that this function does not mutate the string value passed---instead it makes a copy of the input value, mutates it, and returns it as a result. If more than maxsize bytes are written, your program will crash with a buffer overflow!

%cstring_mutable(parm [, expansion])

Turns parameter parm into a mutable string argument. The input string is assumed to be NULL-terminated. An optional parameter expansion specifies the number of extra characters by which the string might grow when it is modified. The output string is assumed to be NULL-terminated and less than the size of the input string plus any expansion characters.

%cstring_mutable(char *ustr);
...
void make_upper(char *ustr);

%cstring_mutable(char *hstr, HEADER_SIZE);
...
void attach_header(char *hstr);

In the target language:

>>> make_upper("hello world")
'HELLO WORLD'
>>> attach_header("Hello world")
'header: Hello world'
>>>

This macro differs from %cstring_bounded_mutable() in that a buffer is dynamically allocated (on the heap using malloc/new ). This buffer is always large enough to store a copy of the input value plus any expansion bytes that might have been requested. It is important to emphasize that this function does not directly mutate the string value passed---instead it makes a copy of the input value, mutates it, and returns it as a result. If the function expands the result by more than expansion extra bytes, then the program will crash with a buffer overflow!

%cstring_output_maxsize(parm, maxparm)

This macro is used to handle bounded character output functions where both a char * and a maximum length parameter are provided. As input, a user simply supplies the maximum length. The return value is assumed to be a NULL-terminated string.

%cstring_output_maxsize(char *path, int maxpath);
...
void get_path(char *path, int maxpath);

In the target language:

>>> get_path(1024)
'/home/beazley/Packages/Foo/Bar'
>>>

This macro provides a safer alternative for functions that need to write string data into a buffer. User supplied buffer size is used to dynamically allocate memory on heap. Results are placed into that buffer and returned as a string object.

%cstring_output_withsize(parm, maxparm)

This macro is used to handle bounded character output functions where both a char * and a pointer int * are passed. Initially, the int * parameter points to a value containing the maximum size. On return, this value is assumed to contain the actual number of bytes. As input, a user simply supplies the maximum length. The output value is a string that may contain binary data.

%cstring_output_withsize(char *data, int *maxdata);
...
void get_data(char *data, int *maxdata);

In the target language:

>>> get_data(1024)
'x627388912'
>>> get_data(1024)
'xyzzy'
>>>

This macro is a somewhat more powerful version of %cstring_output_chunk(). Memory is dynamically allocated and can be arbitrary large. Furthermore, a function can control how much data is actually returned by changing the value of the maxparm argument.

%cstring_output_allocate(parm, release)

This macro is used to return strings that are allocated within the program and returned in a parameter of type char **. For example:

void foo(char **s) {
    *s = (char *) malloc(64);
    sprintf(*s, "Hello world\n");
}

The returned string is assumed to be NULL-terminated. release specifies how the allocated memory is to be released (if applicable). Here is an example:

%cstring_output_allocate(char **s, free(*$1));
...
void foo(char **s);

In the target language:

>>> foo()
'Hello world\n'
>>>

%cstring_output_allocate_size(parm, szparm, release)

This macro is used to return strings that are allocated within the program and returned in two parameters of type char ** and int *. For example:

void foo(char **s, int *sz) {
    *s = (char *) malloc(64);
    *sz = 64;
    // Write some binary data
    ...
}

The returned string may contain binary data. release specifies how the allocated memory is to be released (if applicable). Here is an example:

%cstring_output_allocate_size(char **s, int *slen, free(*$1));
...
void foo(char **s, int *slen);

In the target language:

>>> foo()
'\xa9Y:\xf6\xd7\xe1\x87\xdbH;y\x97\x7f\xd3\x99\x14V\xec\x06\xea\xa2\x88'
>>>

This is the safest and most reliable way to return binary string data in SWIG. If you have functions that conform to another prototype, you might consider wrapping them with a helper function. For example, if you had this:

char  *get_data(int *len);

You could wrap it with a function like this:

void my_get_data(char **result, int *len) {
   *result = get_data(len);
}

Comments:

  • Support for the cstring.i module depends on the target language. Not all SWIG modules currently support this library.
  • Reliable handling of raw C strings is a delicate topic. There are many ways to accomplish this in SWIG. This library provides support for a few common techniques.
  • If used in C++, this library uses new and delete [] for memory allocation. If using ANSI C, the library uses malloc() and free().
  • Rather than manipulating char * directly, you might consider using a special string structure or class instead.

9.4 STL/C++ Library

The library modules in this section provide access to parts of the standard C++ library including the STL. SWIG support for the STL is an ongoing effort. Support is quite comprehensive for some language modules but some of the lesser used modules do not have quite as much library code written.

The following table shows which C++ classes are supported and the equivalent SWIG interface library file for the C++ library.

C++ classC++ Library file SWIG Interface library file
std::auto_ptrmemorystd_auto_ptr.i
std::dequedequestd_deque.i
std::listliststd_list.i
std::mapmapstd_map.i
std::pairutilitystd_pair.i
std::setsetstd_set.i
std::stringstringstd_string.i
std::vectorvectorstd_vector.i
std::shared_ptrshared_ptrstd_shared_ptr.i

The list is by no means complete; some language modules support a subset of the above and some support additional STL classes. Please look for the library files in the appropriate language library directory.

9.4.1 std::string

The std_string.i library provides typemaps for converting C++ std::string objects to and from strings in the target scripting language. For example:

%module example
%include "std_string.i"

std::string foo();
void        bar(const std::string &x);

In the target language:

x = foo();                # Returns a string object
bar("Hello World");       # Pass string as std::string

A common problem that people encounter is that of classes/structures containing a std::string. This can be overcome by defining a typemap. For example:

%module example
%include "std_string.i"

%apply const std::string& {std::string* foo};

struct my_struct
{
  std::string foo;
};

In the target language:

x = my_struct();
x.foo="Hello World";      # assign with string
print x.foo;              # print as string

This module only supports types std::string and const std::string &. Pointers and non-const references are left unmodified and returned as SWIG pointers.

This library file is fully aware of C++ namespaces. If you export std::string or rename it with a typedef, make sure you include those declarations in your interface. For example:

%module example
%include "std_string.i"

using namespace std;
typedef std::string String;
...
void foo(string s, const String &t);     // std_string typemaps still applied

9.4.2 std::vector

The std_vector.i library provides support for the C++ std::vector class in the STL. Using this library involves the use of the %template directive. All you need to do is to instantiate different versions of vector for the types that you want to use. For example:

%module example
%include "std_vector.i"

namespace std {
   %template(vectori) vector<int>;
   %template(vectord) vector<double>;
};

When a template vector<X> is instantiated a number of things happen:

  • A class that exposes the C++ API is created in the target language . This can be used to create objects, invoke methods, etc. This class is currently a subset of the real STL vector class.
  • Input typemaps are defined for vector<X>, const vector<X> &, and const vector<X> *. For each of these, a pointer vector<X> * may be passed or a native list object in the target language.
  • An output typemap is defined for vector<X>. In this case, the values in the vector are expanded into a list object in the target language.
  • For all other variations of the type, the wrappers expect to receive a vector<X> * object in the usual manner.
  • An exception handler for std::out_of_range is defined.
  • Optionally, special methods for indexing, item retrieval, slicing, and element assignment may be defined. This depends on the target language.

To illustrate the use of this library, consider the following functions:

/* File : example.h */

#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>

double average(std::vector<int> v) {
    return std::accumulate(v.begin(),v.end(),0.0)/v.size();
}

std::vector<double> half(const std::vector<double>& v) {
    std::vector<double> w(v);
    for (unsigned int i=0; i<w.size(); i++)
        w[i] /= 2.0;
    return w;
}

void halve_in_place(std::vector<double>& v) {
    std::transform(v.begin(),v.end(),v.begin(),
                   std::bind2nd(std::divides<double>(),2.0));
}

To wrap with SWIG, you might write the following:

%module example
%{
#include "example.h"
%}

%include "std_vector.i"
// Instantiate templates used by example
namespace std {
   %template(IntVector) vector<int>;
   %template(DoubleVector) vector<double>;
}

// Include the header file with above prototypes
%include "example.h"

Now, to illustrate the behavior in the scripting interpreter, consider this Python example:

>>> from example import *
>>> iv = IntVector(4)         # Create an vector<int>
>>> for i in range(0,4):
...      iv[i] = i
>>> average(iv)               # Call method
1.5
>>> average([0,1,2,3])        # Call with list
1.5
>>> half([1,2,3])             # Half a list
(0.5,1.0,1.5)
>>> halve_in_place([1,2,3])   # Oops
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: Type error. Expected _p_std__vectorTdouble_t
>>> dv = DoubleVector(4)
>>> for i in range(0,4):
...       dv[i] = i
>>> halve_in_place(dv)       # Ok
>>> for i in dv:
...       print i
...
0.0
0.5
1.0
1.5
>>> dv[20] = 4.5
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "example.py", line 81, in __setitem__
    def __setitem__(*args): return apply(examplec.DoubleVector___setitem__,args)
IndexError: vector index out of range
>>>

This library module is fully aware of C++ namespaces. If you use vectors with other names, make sure you include the appropriate using or typedef directives. For example:

%include "std_vector.i"

namespace std {
    %template(IntVector) vector<int>;
}

using namespace std;
typedef std::vector Vector;

void foo(vector<int> *x, const Vector &x);

Note: This module makes use of several advanced SWIG features including templatized typemaps and template partial specialization. If you are trying to wrap other C++ code with templates, you might look at the code contained in std_vector.i. Alternatively, you can show them the code if you want to make their head explode.

Note: This module is defined for all SWIG target languages. However argument conversion details and the public API exposed to the interpreter vary.

9.4.3 STL exceptions

Many of the STL wrapper functions add parameter checking and will throw a language dependent error/exception should the values not be valid. The classic example is array bounds checking. The library wrappers are written to throw a C++ exception in the case of error. The C++ exception in turn gets converted into an appropriate error/exception for the target language. By and large this handling should not need customising, however, customisation can easily be achieved by supplying appropriate "throws" typemaps. For example:

%module example
%include "std_vector.i"
%typemap(throws) std::out_of_range {
  // custom exception handler
}
%template(VectInt) std::vector<int>;

The custom exception handler might, for example, log the exception then convert it into a specific error/exception for the target language.

When using the STL it is advisable to add in an exception handler to catch all STL exceptions. The %exception directive can be used by placing the following code before any other methods or libraries to be wrapped:

%include "exception.i"

%exception {
  try {
    $action
  } catch (const std::exception& e) {
    SWIG_exception(SWIG_RuntimeError, e.what());
  }
}

Any thrown STL exceptions will then be gracefully handled instead of causing a crash.

9.4.4 shared_ptr smart pointer

Some target languages have support for handling the shared_ptr reference counted smart pointer. This smart pointer is available in the standard C++11 library as std::shared_ptr. It was also in TR1 as std::tr1::shared_ptr before it was fully standardized. Support for the widely used boost::shared_ptr is also available.

In order to use std::shared_ptr, the std_shared_ptr.i library file should be included:

%include <std_shared_ptr.i>

The pre-standard std::tr1::shared_ptr can be used by including the following macro before including the std_shared_ptr.i library file:

#define SWIG_SHARED_PTR_SUBNAMESPACE tr1
%include <std_shared_ptr.i>

In order to use boost::shared_ptr, the boost_shared_ptr.i library file should be included:

%include <boost_shared_ptr.i>

You can only use one of these variants of shared_ptr in your interface file at a time. and all three variants must be used in conjunction with the %shared_ptr(T) macro, where T is the underlying pointer type equating to usage shared_ptr<T>. The type T must be non-primitive. A simple example demonstrates usage:

%module example
%include <boost_shared_ptr.i>
%shared_ptr(IntValue)

%inline %{
#include <boost/shared_ptr.hpp>

struct IntValue {
  int value;
  IntValue(int v) : value(v) {}
};

static int extractValue(const IntValue &t) {
  return t.value;
}

static int extractValueSmart(boost::shared_ptr<IntValue> t) {
  return t->value;
}
%}

Note that the %shared_ptr(IntValue) declaration occurs after the inclusion of the boost_shared_ptr.i library which provides the macro and, very importantly, before any usage or declaration of the type, IntValue. The %shared_ptr macro provides, a few things for handling this smart pointer, but mostly a number of typemaps. These typemaps override the default typemaps so that the underlying proxy class is stored and passed around as a pointer to a shared_ptr instead of a plain pointer to the underlying type. This approach means that any instantiation of the type can be passed to methods taking the type by value, reference, pointer or as a smart pointer. The interested reader might want to look at the generated code, however, usage is simple and no different handling is required from the target language. For example, a simple use case of the above code from Java would be:

IntValue iv = new IntValue(1234);
int val1 = example.extractValue(iv);
int val2 = example.extractValueSmart(iv);
System.out.println(val1 + " " + val2);

This shared_ptr library works quite differently to SWIG's normal, but somewhat limited, smart pointer handling. The shared_ptr library does not generate extra wrappers, just for smart pointer handling, in addition to the proxy class. The normal proxy class including inheritance relationships is generated as usual. The only real change introduced by the %shared_ptr macro is that the proxy class stores a pointer to the shared_ptr instance instead of a raw pointer to the instance. A proxy class derived from a base which is being wrapped with shared_ptr can and must be wrapped as a shared_ptr too. In other words all classes in an inheritance hierarchy must all be used with the %shared_ptr macro. For example the following code can be used with the base class shown earlier:

%shared_ptr(DerivedIntValue)
%inline %{
struct DerivedIntValue : IntValue {
  DerivedIntValue(int value) : IntValue(value) {}
  ...
};
%}

A shared_ptr of the derived class can now be passed to a method where the base is expected in the target language, just as it can in C++:

DerivedIntValue div = new DerivedIntValue(5678);
int val3 = example.extractValue(div);
int val4 = example.extractValueSmart(div);

If the %shared_ptr macro is omitted for any class in the inheritance hierarchy, SWIG will warn about this and the generated code may or may not result in a C++ compilation error. For example, the following input:

%include "boost_shared_ptr.i"
%shared_ptr(Parent);

%inline %{
  #include <boost/shared_ptr.hpp>
  struct GrandParent {
    virtual ~GrandParent() {}
  };

  struct Parent : GrandParent {
    virtual ~Parent() {}
  };

  struct Child : Parent {
    virtual ~Child() {}
  };
%}

warns about the missing smart pointer information:

example.i:12: Warning 520: Base class 'GrandParent' of 'Parent' is not similarly marked as a smart pointer.
example.i:16: Warning 520: Derived class 'Child' of 'Parent' is not similarly marked as a smart pointer.

Adding the missing %shared_ptr macros will fix this:

%include "boost_shared_ptr.i"
%shared_ptr(GrandParent);
%shared_ptr(Parent);
%shared_ptr(Child);

... as before ...

Note: There is currently no support for %shared_ptr and the director feature.

9.4.5 auto_ptr smart pointer

While std::auto_ptr is deprecated in C++11, some existing code may still be using it, so SWIG provides limited support for this class: std_auto_ptr.i defines the typemaps which apply to the functions returning objects of this type. Any other use of std_auto_ptr.i is not directly supported.

A typical example of use would be

%include <std_auto_ptr.i>

%auto_ptr(Klass)
%inline %{
class Klass {
public:
  // Factory function creating objects of this class:
  static std::auto_ptr<Klass> Create(int value) {
    return std::auto_ptr<Klass>(new Klass(value));
  }

  int getValue() const { return m_value; }

private:
  DerivedIntValue(int value) : m_value(value) {}
  int m_value;
};
%}

The returned objects can be used naturally from the target language, e.g. from C#:

Klass k = Klass.Create(17);
int value = k.getValue();

9.5 Utility Libraries

9.5.1 exception.i

The exception.i library provides a language-independent function for raising a run-time exception in the target language. This library is largely used by the SWIG library writers. If possible, use the error handling scheme available to your target language as there is greater flexibility in what errors/exceptions can be thrown.

SWIG_exception(int code, const char *message)

Raises an exception in the target language. code is one of the following symbolic constants:

SWIG_MemoryError
SWIG_IOError
SWIG_RuntimeError
SWIG_IndexError
SWIG_TypeError
SWIG_DivisionByZero
SWIG_OverflowError
SWIG_SyntaxError
SWIG_ValueError
SWIG_SystemError

message is a string indicating more information about the problem.

The primary use of this module is in writing language-independent exception handlers. For example:

%include "exception.i"
%exception std::vector::getitem {
    try {
        $action
    } catch (std::out_of_range& e) {
        SWIG_exception(SWIG_IndexError,const_cast<char*>(e.what()));
    }
}

10 Argument Handling

In Chapter 3, SWIG's treatment of basic datatypes and pointers was described. In particular, primitive types such as int and double are mapped to corresponding types in the target language. For everything else, pointers are used to refer to structures, classes, arrays, and other user-defined datatypes. However, in certain applications it is desirable to change SWIG's handling of a specific datatype. For example, you might want to return multiple values through the arguments of a function. This chapter describes some of the techniques for doing this.

10.1 The typemaps.i library

This section describes the typemaps.i library file--commonly used to change certain properties of argument conversion.

10.1.1 Introduction

Suppose you had a C function like this:

void add(double a, double b, double *result) {
	*result = a + b;
}

From reading the source code, it is clear that the function is storing a value in the double *result parameter. However, since SWIG does not examine function bodies, it has no way to know that this is the underlying behavior.

One way to deal with this is to use the typemaps.i library file and write interface code like this:

// Simple example using typemaps
%module example
%include "typemaps.i"

%apply double *OUTPUT { double *result };
%inline %{
extern void add(double a, double b, double *result);
%}

The %apply directive tells SWIG that you are going to apply a special type handling rule to a type. The "double *OUTPUT" specification is the name of a rule that defines how to return an output value from an argument of type double *. This rule gets applied to all of the datatypes listed in curly braces-- in this case " double *result".

When the resulting module is created, you can now use the function like this (shown for Python):

>>> a = add(3,4)
>>> print a
7
>>>

In this case, you can see how the output value normally returned in the third argument has magically been transformed into a function return value. Clearly this makes the function much easier to use since it is no longer necessary to manufacture a special double * object and pass it to the function somehow.

Once a typemap has been applied to a type, it stays in effect for all future occurrences of the type and name. For example, you could write the following:

%module example
%include "typemaps.i"

%apply double *OUTPUT { double *result };

%inline %{
extern void add(double a, double b, double *result);
extern void sub(double a, double b, double *result);
extern void mul(double a, double b, double *result);
extern void div(double a, double b, double *result);
%}
...

In this case, the double *OUTPUT rule is applied to all of the functions that follow.

Typemap transformations can even be extended to multiple return values. For example, consider this code:

%include "typemaps.i"
%apply int *OUTPUT { int *width, int *height };

// Returns a pair (width,height)
void getwinsize(int winid, int *width, int *height);

In this case, the function returns multiple values, allowing it to be used like this:

>>> w,h = genwinsize(wid)
>>> print w
400
>>> print h
300
>>>

It should also be noted that although the %apply directive is used to associate typemap rules to datatypes, you can also use the rule names directly in arguments. For example, you could write this:

// Simple example using typemaps
%module example
%include "typemaps.i"

%{
extern void add(double a, double b, double *OUTPUT);
%}
extern void add(double a, double b, double *OUTPUT);

Typemaps stay in effect until they are explicitly deleted or redefined to something else. To clear a typemap, the %clear directive should be used. For example:

%clear double *result;      // Remove all typemaps for double *result

10.1.2 Input parameters

The following typemaps instruct SWIG that a pointer really only holds a single input value:

int *INPUT		
short *INPUT
long *INPUT
unsigned int *INPUT
unsigned short *INPUT
unsigned long *INPUT
double *INPUT
float *INPUT

When used, it allows values to be passed instead of pointers. For example, consider this function:

double add(double *a, double *b) {
	return *a+*b;
}

Now, consider this SWIG interface:

%module example
%include "typemaps.i"
...
%{
extern double add(double *, double *);
%}
extern double add(double *INPUT, double *INPUT);

When the function is used in the scripting language interpreter, it will work like this:

result = add(3,4)

10.1.3 Output parameters

The following typemap rules tell SWIG that pointer is the output value of a function. When used, you do not need to supply the argument when calling the function. Instead, one or more output values are returned.

int *OUTPUT
short *OUTPUT
long *OUTPUT
unsigned int *OUTPUT
unsigned short *OUTPUT
unsigned long *OUTPUT
double *OUTPUT
float *OUTPUT

These methods can be used as shown in an earlier example. For example, if you have this C function :

void add(double a, double b, double *c) {
	*c = a+b;
}

A SWIG interface file might look like this :

%module example
%include "typemaps.i"
...
%inline %{
extern void add(double a, double b, double *OUTPUT);
%}

In this case, only a single output value is returned, but this is not a restriction. An arbitrary number of output values can be returned by applying the output rules to more than one argument (as shown previously).

If the function also returns a value, it is returned along with the argument. For example, if you had this:

extern int foo(double a, double b, double *OUTPUT);

The function will return two values like this:

iresult, dresult = foo(3.5, 2)

10.1.4 Input/Output parameters

When a pointer serves as both an input and output value you can use the following typemaps :

int *INOUT
short *INOUT
long *INOUT
unsigned int *INOUT
unsigned short *INOUT
unsigned long *INOUT
double *INOUT
float *INOUT

A C function that uses this might be something like this:

void negate(double *x) {
	*x = -(*x);
}

To make x function as both and input and output value, declare the function like this in an interface file :

%module example
%include "typemaps.i"
...
%{
extern void negate(double *);
%}
extern void negate(double *INOUT);

Now within a script, you can simply call the function normally :

a = negate(3);         # a = -3 after calling this

One subtle point of the INOUT rule is that many scripting languages enforce mutability constraints on primitive objects (meaning that simple objects like integers and strings aren't supposed to change). Because of this, you can't just modify the object's value in place as the underlying C function does in this example. Therefore, the INOUT rule returns the modified value as a new object rather than directly overwriting the value of the original input object.

Compatibility note : The INOUT rule used to be known as BOTH in earlier versions of SWIG. Backwards compatibility is preserved, but deprecated.

10.1.5 Using different names

As previously shown, the %apply directive can be used to apply the INPUT, OUTPUT, and INOUT typemaps to different argument names. For example:

// Make double *result an output value
%apply double *OUTPUT { double *result };

// Make Int32 *in an input value
%apply int *INPUT { Int32 *in };

// Make long *x inout
%apply long *INOUT {long *x};

To clear a rule, the %clear directive is used:

%clear double *result;
%clear Int32 *in, long *x;

Typemap declarations are lexically scoped so a typemap takes effect from the point of definition to the end of the file or a matching %clear declaration.

10.2 Applying constraints to input values

In addition to changing the handling of various input values, it is also possible to use typemaps to apply constraints. For example, maybe you want to insure that a value is positive, or that a pointer is non-NULL. This can be accomplished including the constraints.i library file.

10.2.1 Simple constraint example

The constraints library is best illustrated by the following interface file :

// Interface file with constraints
%module example
%include "constraints.i"

double exp(double x);
double log(double POSITIVE);         // Allow only positive values
double sqrt(double NONNEGATIVE);     // Non-negative values only
double inv(double NONZERO);          // Non-zero values
void   free(void *NONNULL);          // Non-NULL pointers only

The behavior of this file is exactly as you would expect. If any of the arguments violate the constraint condition, a scripting language exception will be raised. As a result, it is possible to catch bad values, prevent mysterious program crashes and so on.

10.2.2 Constraint methods

The following constraints are currently available

POSITIVE                     Any number > 0 (not zero)
NEGATIVE                     Any number < 0 (not zero)
NONNEGATIVE                  Any number >= 0
NONPOSITIVE                  Any number <= 0
NONZERO                      Nonzero number
NONNULL                      Non-NULL pointer (pointers only).

10.2.3 Applying constraints to new datatypes

The constraints library only supports the primitive C datatypes, but it is easy to apply it to new datatypes using %apply. For example :

// Apply a constraint to a Real variable
%apply Number POSITIVE { Real in };

// Apply a constraint to a pointer type
%apply Pointer NONNULL { Vector * };

The special types of "Number" and "Pointer" can be applied to any numeric and pointer variable type respectively. To later remove a constraint, the %clear directive can be used :

%clear Real in;
%clear Vector *;

11 Typemaps

11.1 Introduction

Chances are, you are reading this chapter for one of two reasons; you either want to customize SWIG's behavior or you overheard someone mumbling some incomprehensible drivel about "typemaps" and you asked yourself "typemaps, what are those?" That said, let's start with a short disclaimer that "typemaps" are an advanced customization feature that provide direct access to SWIG's low-level code generator. Not only that, they are an integral part of the SWIG C++ type system (a non-trivial topic of its own). Typemaps are generally not a required part of using SWIG. Therefore, you might want to re-read the earlier chapters if you have found your way to this chapter with only a vague idea of what SWIG already does by default.

11.1.1 Type conversion

One of the most important problems in wrapper code generation is the conversion or marshalling of datatypes between programming languages. Specifically, for every C/C++ declaration, SWIG must somehow generate wrapper code that allows values to be passed back and forth between languages. Since every programming language represents data differently, this is not a simple of matter of simply linking code together with the C linker. Instead, SWIG has to know something about how data is represented in each language and how it can be manipulated.

To illustrate, suppose you had a simple C function like this:

int factorial(int n);

To access this function from Python, a pair of Python API functions are used to convert integer values. For example:

long PyInt_AsLong(PyObject *obj);      /* Python --> C */
PyObject *PyInt_FromLong(long x);      /* C --> Python */

The first function is used to convert the input argument from a Python integer object to C long. The second function is used to convert a value from C back into a Python integer object.

Inside the wrapper function, you might see these functions used like this:

PyObject *wrap_factorial(PyObject *self, PyObject *args) {
    int       arg1;
    int       result;
    PyObject *obj1;
    PyObject *resultobj;

    if (!PyArg_ParseTuple("O:factorial", &obj1)) return NULL;
    arg1 = PyInt_AsLong(obj1);
    result = factorial(arg1);
    resultobj = PyInt_FromLong(result);
    return resultobj;
}

Every target language supported by SWIG has functions that work in a similar manner. For example, in Perl, the following functions are used:

IV SvIV(SV *sv);                     /* Perl --> C */
void sv_setiv(SV *sv, IV val);       /* C --> Perl */

In Tcl:

int Tcl_GetLongFromObj(Tcl_Interp *interp, Tcl_Obj *obj, long *value);
Tcl_Obj *Tcl_NewIntObj(long value);

The precise details are not so important. What is important is that all of the underlying type conversion is handled by collections of utility functions and short bits of C code like this---you simply have to read the extension documentation for your favorite language to know how it works (an exercise left to the reader).

11.1.2 Typemaps

Since type handling is so central to wrapper code generation, SWIG allows it to be completely defined (or redefined) by the user. To do this, a special %typemap directive is used. For example:

/* Convert from Python --> C */
%typemap(in) int {
    $1 = PyInt_AsLong($input);
}

/* Convert from C --> Python */
%typemap(out) int {
    $result = PyInt_FromLong($1);
}

At first glance, this code will look a little confusing. However, there is really not much to it. The first typemap (the "in" typemap) is used to convert a value from the target language to C. The second typemap (the "out" typemap) is used to convert in the other direction. The content of each typemap is a small fragment of code that is inserted directly into the SWIG generated wrapper functions. The code is usually C or C++ code which will be generated into the C/C++ wrapper functions. Note that this isn't always the case as some target language modules allow target language code within the typemaps which gets generated into target language specific files. Within this code, a number of special variables prefixed with a $ are expanded. These are really just placeholders for C/C++ variables that are generated in the course of creating the wrapper function. In this case, $input refers to an input object that needs to be converted to C/C++ and $result refers to an object that is going to be returned by a wrapper function. $1 refers to a C/C++ variable that has the same type as specified in the typemap declaration (an int in this example).

A short example might make this a little more clear. If you were wrapping a function like this:

int gcd(int x, int y);

A wrapper function would look approximately like this:

PyObject *wrap_gcd(PyObject *self, PyObject *args) {
   int arg1;
   int arg2;
   int result;
   PyObject *obj1;
   PyObject *obj2;
   PyObject *resultobj;

   if (!PyArg_ParseTuple("OO:gcd", &obj1, &obj2)) return NULL;

   /* "in" typemap, argument 1 */   
   {
      arg1 = PyInt_AsLong(obj1);
   }

   /* "in" typemap, argument 2 */
   {
      arg2 = PyInt_AsLong(obj2);
   }

   result = gcd(arg1,arg2);

   /* "out" typemap, return value */
   {
      resultobj = PyInt_FromLong(result);
   }

   return resultobj;
}

In this code, you can see how the typemap code has been inserted into the function. You can also see how the special $ variables have been expanded to match certain variable names inside the wrapper function. This is really the whole idea behind typemaps--they simply let you insert arbitrary code into different parts of the generated wrapper functions. Because arbitrary code can be inserted, it possible to completely change the way in which values are converted.

11.1.3 Pattern matching

As the name implies, the purpose of a typemap is to "map" C datatypes to types in the target language. Once a typemap is defined for a C datatype, it is applied to all future occurrences of that type in the input file. For example:

/* Convert from Perl --> C */
%typemap(in) int {
   $1 = SvIV($input);
}

...
int factorial(int n);
int gcd(int x, int y);
int count(char *s, char *t, int max);

The matching of typemaps to C datatypes is more than a simple textual match. In fact, typemaps are fully built into the underlying type system. Therefore, typemaps are unaffected by typedef, namespaces, and other declarations that might hide the underlying type. For example, you could have code like this:

/* Convert from Ruby--> C */
%typemap(in) int {
   $1 = NUM2INT($input);
}
...
typedef int Integer;
namespace foo {
    typedef Integer Number;
};

int foo(int x);
int bar(Integer y);
int spam(foo::Number a, foo::Number b);

In this case, the typemap is still applied to the proper arguments even though typenames don't always match the text "int". This ability to track types is a critical part of SWIG--in fact, all of the target language modules work merely define a set of typemaps for the basic types. Yet, it is never necessary to write new typemaps for typenames introduced by typedef.

In addition to tracking typenames, typemaps may also be specialized to match against a specific argument name. For example, you could write a typemap like this:

%typemap(in) double nonnegative {
   $1 = PyFloat_AsDouble($input);
   if ($1 < 0) {
        PyErr_SetString(PyExc_ValueError,"argument must be nonnegative.");
        return NULL;
   }
}

...
double sin(double x);
double cos(double x);
double sqrt(double nonnegative);

typedef double Real;
double log(Real nonnegative);
...

For certain tasks such as input argument conversion, typemaps can be defined for sequences of consecutive arguments. For example:

%typemap(in) (char *str, int len) {
    $1 = PyString_AsString($input);   /* char *str */
    $2 = PyString_Size($input);       /* int len   */
}
...
int count(char *str, int len, char c);

In this case, a single input object is expanded into a pair of C arguments. This example also provides a hint to the unusual variable naming scheme involving $1, $2, and so forth.

11.1.4 Reusing typemaps

Typemaps are normally defined for specific type and argument name patterns. However, typemaps can also be copied and reused. One way to do this is to use assignment like this:

%typemap(in) Integer = int;   
%typemap(in) (char *buffer, int size) = (char *str, int len);

A more general form of copying is found in the %apply directive like this:

%typemap(in) int {
   /* Convert an integer argument */
   ...
}
%typemap(out) int {
   /* Return an integer value */
   ...
}

/* Apply all of the integer typemaps to size_t */
%apply int { size_t };    

%apply merely takes all of the typemaps that are defined for one type and applies them to other types. Note: you can include a comma separated set of types in the { ... } part of %apply.

It should be noted that it is not necessary to copy typemaps for types that are related by typedef. For example, if you have this,

typedef int size_t;

then SWIG already knows that the int typemaps apply. You don't have to do anything.

11.1.5 What can be done with typemaps?

The primary use of typemaps is for defining wrapper generation behavior at the level of individual C/C++ datatypes. There are currently six general categories of problems that typemaps address:

Argument handling

int foo(int x, double y, char *s);
  • Input argument conversion ("in" typemap).
  • Input argument type checking ("typecheck" typemap).
  • Output argument handling ("argout" typemap).
  • Input argument value checking ("check" typemap).
  • Input argument initialization ("arginit" typemap).
  • Default arguments ("default" typemap).
  • Input argument resource management ("freearg" typemap).

Return value handling

int foo(int x, double y, char *s);
  • Function return value conversion ("out" typemap).
  • Return value resource management ("ret" typemap).
  • Resource management for newly allocated objects ("newfree" typemap).

Exception handling

int foo(int x, double y, char *s) throw(MemoryError, IndexError);
  • Handling of C++ exception specifications. ("throw" typemap).

Global variables

int foo;
  • Assignment of a global variable. ("varin" typemap).
  • Reading a global variable. ("varout" typemap).

Member variables

struct Foo {
    int x[20];
};
  • Assignment of data to a class/structure member. ("memberin" typemap).

Constant creation

#define FOO 3
%constant int BAR = 42;
enum { ALE, LAGER, STOUT };
  • Creation of constant values. ("consttab" or "constcode" typemap).

Details of each of these typemaps will be covered shortly. Also, certain language modules may define additional typemaps that expand upon this list. For example, the Java module defines a variety of typemaps for controlling additional aspects of the Java bindings. Consult language specific documentation for further details.

11.1.6 What can't be done with typemaps?

Typemaps can't be used to define properties that apply to C/C++ declarations as a whole. For example, suppose you had a declaration like this,

Foo *make_Foo(int n);

and you wanted to tell SWIG that make_Foo(int n) returned a newly allocated object (for the purposes of providing better memory management). Clearly, this property of make_Foo(int n) is not a property that would be associated with the datatype Foo * by itself. Therefore, a completely different SWIG customization mechanism (%feature) is used for this purpose. Consult the Customization Features chapter for more information about that.

Typemaps also can't be used to rearrange or transform the order of arguments. For example, if you had a function like this:

void foo(int, char *);

you can't use typemaps to interchange the arguments, allowing you to call the function like this:

foo("hello",3)          # Reversed arguments

If you want to change the calling conventions of a function, write a helper function instead. For example:

%rename(foo) wrap_foo;
%inline %{
void wrap_foo(char *s, int x) {
   foo(x,s);
}
%}

11.1.7 Similarities to Aspect Oriented Programming

SWIG has parallels to Aspect Oriented Software Development (AOP). The AOP terminology with respect to SWIG typemaps can be viewed as follows:

  • Cross-cutting concerns: The cross-cutting concerns are the modularization of the functionality that the typemaps implement, which is primarily marshalling of types from/to the target language and C/C++.
  • Advice: The typemap body contains code which is executed whenever the marshalling is required.
  • Pointcut: The pointcuts are the positions in the wrapper code that the typemap code is generated into.
  • Aspect: Aspects are the combination of the pointcut and the advice, hence each typemap is an aspect.

SWIG can also be viewed as has having a second set of aspects based around %feature. Features such as %exception are also cross-cutting concerns as they encapsulate code that can be used to add logging or exception handling to any function.

11.1.8 The rest of this chapter

The rest of this chapter provides detailed information for people who want to write new typemaps. This information is of particular importance to anyone who intends to write a new SWIG target language module. Power users can also use this information to write application specific type conversion rules.

Since typemaps are strongly tied to the underlying C++ type system, subsequent sections assume that you are reasonably familiar with the basic details of values, pointers, references, arrays, type qualifiers (e.g., const), structures, namespaces, templates, and memory management in C/C++. If not, you would be well-advised to consult a copy of "The C Programming Language" by Kernighan and Ritchie or "The C++ Programming Language" by Stroustrup before going any further.

11.2 Typemap specifications

This section describes the behavior of the %typemap directive itself.

11.2.1 Defining a typemap

New typemaps are defined using the %typemap declaration. The general form of this declaration is as follows (parts enclosed in [ ... ] are optional):

%typemap(method [, modifiers]) typelist code ;

method is a simply a name that specifies what kind of typemap is being defined. It is usually a name like "in", "out", or "argout". The purpose of these methods is described later.

modifiers is an optional comma separated list of name="value" values. These are sometimes to attach extra information to a typemap and is often target-language dependent. They are also known as typemap attributes.

typelist is a list of the C++ type patterns that the typemap will match. The general form of this list is as follows:

typelist    :  typepattern [, typepattern, typepattern, ... ] ;

typepattern :  type [ (parms) ]
            |  type name [ (parms) ]
            |  ( typelist ) [ (parms) ]

Each type pattern is either a simple type, a simple type and argument name, or a list of types in the case of multi-argument typemaps. In addition, each type pattern can be parameterized with a list of temporary variables (parms). The purpose of these variables will be explained shortly.

code specifies the code used in the typemap. Usually this is C/C++ code, but in the statically typed target languages, such as Java and C#, this can contain target language code for certain typemaps. It can take any one of the following forms:

code       : { ... }
           | " ... "
           | %{ ... %}

Note that the preprocessor will expand code within the {} delimiters, but not in the last two styles of delimiters, see Preprocessor and Typemaps. Here are some examples of valid typemap specifications:

/* Simple typemap declarations */
%typemap(in) int {
   $1 = PyInt_AsLong($input);
}
%typemap(in) int "$1 = PyInt_AsLong($input);";
%typemap(in) int %{ 
   $1 = PyInt_AsLong($input);
%}

/* Typemap with extra argument name */
%typemap(in) int nonnegative {
   ...
}

/* Multiple types in one typemap */
%typemap(in) int, short, long { 
   $1 = SvIV($input);
}

/* Typemap with modifiers */
%typemap(in,doc="integer") int "$1 = scm_to_int($input);";

/* Typemap applied to patterns of multiple arguments */
%typemap(in) (char *str, int len),
             (char *buffer, int size)
{
   $1 = PyString_AsString($input);
   $2 = PyString_Size($input);
}

/* Typemap with extra pattern parameters */
%typemap(in, numinputs=0) int *output (int temp),
                          long *output (long temp)
{
   $1 = &temp;
}

Admittedly, it's not the most readable syntax at first glance. However, the purpose of the individual pieces will become clear.

11.2.2 Typemap scope

Once defined, a typemap remains in effect for all of the declarations that follow. A typemap may be redefined for different sections of an input file. For example:

// typemap1
%typemap(in) int {
...
}

int fact(int);                    // typemap1
int gcd(int x, int y);            // typemap1

// typemap2
%typemap(in) int {
...
}

int isprime(int);                 // typemap2

One exception to the typemap scoping rules pertains to the %extend declaration. %extend is used to attach new declarations to a class or structure definition. Because of this, all of the declarations in an %extend block are subject to the typemap rules that are in effect at the point where the class itself is defined. For example:

class Foo {
   ...
};

%typemap(in) int {
 ...
}

%extend Foo {
   int blah(int x);    // typemap has no effect.  Declaration is attached to Foo which 
                       // appears before the %typemap declaration.
};

11.2.3 Copying a typemap

A typemap is copied by using assignment. For example:

%typemap(in) Integer = int;

or this:

%typemap(in) Integer, Number, int32_t = int;

Types are often managed by a collection of different typemaps. For example:

%typemap(in)     int { ... }
%typemap(out)    int { ... }
%typemap(varin)  int { ... }
%typemap(varout) int { ... }

To copy all of these typemaps to a new type, use %apply. For example:

%apply int { Integer };            // Copy all int typemaps to Integer
%apply int { Integer, Number };    // Copy all int typemaps to both Integer and Number

The patterns for %apply follow the same rules as for %typemap. For example:

%apply int *output { Integer *output };                    // Typemap with name
%apply (char *buf, int len) { (char *buffer, int size) };  // Multiple arguments

11.2.4 Deleting a typemap

A typemap can be deleted by simply defining no code. For example:

%typemap(in) int;               // Clears typemap for int
%typemap(in) int, long, short;  // Clears typemap for int, long, short
%typemap(in) int *output;       

The %clear directive clears all typemaps for a given type. For example:

%clear int;                     // Removes all types for int
%clear int *output, long *output;

Note: Since SWIG's default behavior is defined by typemaps, clearing a fundamental type like int will make that type unusable unless you also define a new set of typemaps immediately after the clear operation.

11.2.5 Placement of typemaps

Typemap declarations can be declared in the global scope, within a C++ namespace, and within a C++ class. For example:

%typemap(in) int {
   ...
}

namespace std {
    class string;
    %typemap(in) string {
        ...
    }
}

class Bar {
public:
    typedef const int & const_reference;
    %typemap(out) const_reference {
         ...
    }
};

When a typemap appears inside a namespace or class, it stays in effect until the end of the SWIG input (just like before). However, the typemap takes the local scope into account. Therefore, this code

namespace std {
    class string;
    %typemap(in) string {
       ...
    }
}

is really defining a typemap for the type std::string. You could have code like this:

namespace std {
    class string;
    %typemap(in) string {          /* std::string */
       ...
    }
}

namespace Foo {
    class string;
    %typemap(in) string {          /* Foo::string */
       ...
    }
}

In this case, there are two completely distinct typemaps that apply to two completely different types (std::string and Foo::string).

It should be noted that for scoping to work, SWIG has to know that string is a typename defined within a particular namespace. In this example, this is done using the forward class declaration class string.

11.3 Pattern matching rules

The section describes the pattern matching rules by which C/C++ datatypes are associated with typemaps. The matching rules can be observed in practice by using the debugging options also described.

11.3.1 Basic matching rules

Typemaps are matched using both a type and a name (typically the name of a argument). For a given TYPE NAME pair, the following rules are applied, in order, to find a match. The first typemap found is used.

  • Typemaps that exactly match TYPE and NAME.
  • Typemaps that exactly match TYPE only.
  • If TYPE is a C++ template of type T< TPARMS >, where TPARMS are the template parameters, the type is stripped of the template parameters and the following checks are then made:
    • Typemaps that exactly match T and NAME.
    • Typemaps that exactly match T only.

If TYPE includes qualifiers (const, volatile, etc.), each qualifier is stripped one at a time to form a new stripped type and the matching rules above are repeated on the stripped type. The left-most qualifier is stripped first, resulting in the right-most (or top-level) qualifier being stripped last. For example int const*const is first stripped to int *const then int *.

If TYPE is an array. The following transformation is made:

  • Replace all dimensions to [ANY] and look for a generic array typemap.

To illustrate, suppose that you had a function like this:

int foo(const char *s);

To find a typemap for the argument const char *s, SWIG will search for the following typemaps:

const char *s           Exact type and name match
const char *            Exact type match
char *s                 Type and name match (qualifier stripped)
char *                  Type match (qualifier stripped)

When more than one typemap rule might be defined, only the first match found is actually used. Here is an example that shows how some of the basic rules are applied:

%typemap(in) int *x {
   ... typemap 1
}

%typemap(in) int * {
   ... typemap 2
}

%typemap(in) const int *z {
   ... typemap 3
}

%typemap(in) int [4] {
   ... typemap 4
}

%typemap(in) int [ANY] {
   ... typemap 5
}

void A(int *x);        // int *x rule       (typemap 1)
void B(int *y);        // int * rule        (typemap 2)
void C(const int *x);  // int *x rule       (typemap 1)
void D(const int *z);  // const int *z rule (typemap 3)
void E(int x[4]);      // int [4] rule      (typemap 4)
void F(int x[1000]);   // int [ANY] rule    (typemap 5)

Compatibility note: SWIG-2.0.0 introduced stripping the qualifiers one step at a time. Prior versions stripped all qualifiers in one step.

11.3.2 Typedef reductions matching

If no match is found using the rules in the previous section, SWIG applies a typedef reduction to the type and repeats the typemap search for the reduced type. To illustrate, suppose you had code like this:

%typemap(in) int {
   ... typemap 1
}

typedef int Integer;
void blah(Integer x);

To find the typemap for Integer x, SWIG will first search for the following typemaps:

Integer x
Integer

Finding no match, it then applies a reduction Integer -> int to the type and repeats the search.

int x
int      --> match: typemap 1

Even though two types might be the same via typedef, SWIG allows typemaps to be defined for each typename independently. This allows for interesting customization possibilities based solely on the typename itself. For example, you could write code like this:

typedef double  pdouble;     // Positive double

// typemap 1
%typemap(in) double {
   ... get a double ...
}
// typemap 2
%typemap(in) pdouble {
   ... get a positive double ...
}
double sin(double x);           // typemap 1
pdouble sqrt(pdouble x);        // typemap 2

When reducing the type, only one typedef reduction is applied at a time. The search process continues to apply reductions until a match is found or until no more reductions can be made.

For complicated types, the reduction process can generate a long list of patterns. Consider the following:

typedef int Integer;
typedef Integer Row4[4];
void foo(Row4 rows[10]);

To find a match for the Row4 rows[10] argument, SWIG would check the following patterns, stopping only when it found a match:

Row4 rows[10]
Row4 [10]
Row4 rows[ANY]
Row4 [ANY]

# Reduce Row4 --> Integer[4]
Integer rows[10][4]
Integer [10][4]
Integer rows[ANY][ANY]
Integer [ANY][ANY]

# Reduce Integer --> int
int rows[10][4]
int [10][4]
int rows[ANY][ANY]
int [ANY][ANY]

For parameterized types like templates, the situation is even more complicated. Suppose you had some declarations like this:

typedef int Integer;
typedef foo<Integer,Integer> fooii;
void blah(fooii *x);

In this case, the following typemap patterns are searched for the argument fooii *x:

fooii *x
fooii *

# Reduce fooii --> foo<Integer,Integer>
foo<Integer,Integer> *x
foo<Integer,Integer> *

# Reduce Integer -> int
foo<int, Integer> *x
foo<int, Integer> *

# Reduce Integer -> int
foo<int, int> *x
foo<int, int> *

Typemap reductions are always applied to the left-most type that appears. Only when no reductions can be made to the left-most type are reductions made to other parts of the type. This behavior means that you could define a typemap for foo<int,Integer>, but a typemap for foo<Integer,int> would never be matched. Admittedly, this is rather esoteric--there's little practical reason to write a typemap quite like that. Of course, you could rely on this to confuse your coworkers even more.

As a point of clarification, it is worth emphasizing that typedef matching is a typedef reduction process only, that is, SWIG does not search for every single possible typedef. Given a type in a declaration, it will only reduce the type, it won't build it up looking for typedefs. For example, given the type Struct, the typemap below will not be used for the aStruct parameter, because Struct is fully reduced:

struct Struct {...};
typedef Struct StructTypedef;

%typemap(in) StructTypedef { 
  ...
}

void go(Struct aStruct);

11.3.3 Default typemap matching rules

If the basic pattern matching rules result in no match being made, even after typedef reductions, the default typemap matching rules are used to look for a suitable typemap match. These rules match a generic typemap based on the reserved SWIGTYPE base type. For example pointers will use SWIGTYPE * and references will use SWIGTYPE &. More precisely, the rules are based on the C++ class template partial specialization matching rules used by C++ compilers when looking for an appropriate partial template specialization. This means that a match is chosen from the most specialized set of generic typemap types available. For example, when looking for a match to int const *, the rules will prefer to match SWIGTYPE const * if available before matching SWIGTYPE *, before matching SWIGTYPE.

Most SWIG language modules use typemaps to define the default behavior of the C primitive types. This is entirely straightforward. For example, a set of typemaps for primitives marshalled by value or const reference are written like this:

%typemap(in) int           "... convert to int ...";
%typemap(in) short         "... convert to short ...";
%typemap(in) float         "... convert to float ...";
...
%typemap(in) const int &   "... convert ...";
%typemap(in) const short & "... convert ...";
%typemap(in) const float & "... convert ...";
...

Since typemap matching follows all typedef declarations, any sort of type that is mapped to a primitive type by value or const reference through typedef will be picked up by one of these primitive typemaps. Most language modules also define typemaps for char pointers and char arrays to handle strings, so these non-default types will also be used in preference as the basic typemap matching rules provide a better match than the default typemap matching rules.

Below is a list of the typical default types supplied by language modules, showing what the "in" typemap would look like:

%typemap(in) SWIGTYPE &            { ... default reference handling ...                       };
%typemap(in) SWIGTYPE *            { ... default pointer handling ...                         };
%typemap(in) SWIGTYPE *const       { ... default pointer const handling ...                   };
%typemap(in) SWIGTYPE *const&      { ... default pointer const reference handling ...         };
%typemap(in) SWIGTYPE[ANY]         { ... 1D fixed size arrays handlling ...                   };
%typemap(in) SWIGTYPE []           { ... unknown sized array handling ...                     };
%typemap(in) enum SWIGTYPE         { ... default handling for enum values ...                 };
%typemap(in) const enum SWIGTYPE & { ... default handling for const enum reference values ... };
%typemap(in) SWIGTYPE (CLASS::*)   { ... default pointer member handling ...                  };
%typemap(in) SWIGTYPE              { ... simple default handling ...                          };

If you wanted to change SWIG's default handling for simple pointers, you would simply redefine the rule for SWIGTYPE *. Note, the simple default typemap rule is used to match against simple types that don't match any other rules:

%typemap(in) SWIGTYPE              { ... simple default handling ...                          } 

This typemap is important because it is the rule that gets triggered when call or return by value is used. For instance, if you have a declaration like this:

double dot_product(Vector a, Vector b);

The Vector type will usually just get matched against SWIGTYPE. The default implementation of SWIGTYPE is to convert the value into pointers (as described in this earlier section).

By redefining SWIGTYPE it may be possible to implement other behavior. For example, if you cleared all typemaps for SWIGTYPE, SWIG simply won't wrap any unknown datatype (which might be useful for debugging). Alternatively, you might modify SWIGTYPE to marshal objects into strings instead of converting them to pointers.

Let's consider an example where the following typemaps are defined and SWIG is looking for the best match for the enum shown below:

%typemap(in) const Hello &          { ... }
%typemap(in) const enum SWIGTYPE &  { ... }
%typemap(in) enum SWIGTYPE &        { ... }
%typemap(in) SWIGTYPE &             { ... }
%typemap(in) SWIGTYPE               { ... }

enum Hello {};
const Hello &hi;

The typemap at the top of the list will be chosen, not because it is defined first, but because it is the closest match for the type being wrapped. If any of the typemaps in the above list were not defined, then the next one on the list would have precedence.

The best way to explore the default typemaps is to look at the ones already defined for a particular language module. Typemap definitions are usually found in the SWIG library in a file such as java.swg , csharp.swg etc. However, for many of the target languages the typemaps are hidden behind complicated macros, so the best way to view the default typemaps, or any typemaps for that matter, is to look at the preprocessed output by running swig -E on any interface file. Finally the best way to view the typemap matching rules in action is via the debugging typemap pattern matching options covered later on.

Compatibility note: The default typemap matching rules were modified in SWIG-2.0.0 from a slightly simpler scheme to match the current C++ class template partial specialization matching rules.

11.3.4 Multi-arguments typemaps

When multi-argument typemaps are specified, they take precedence over any typemaps specified for a single type. For example:

%typemap(in) (char *buffer, int len) {
   // typemap 1
}

%typemap(in) char *buffer {
   // typemap 2
}

void foo(char *buffer, int len, int count); // (char *buffer, int len)
void bar(char *buffer, int blah);           // char *buffer

Multi-argument typemaps are also more restrictive in the way that they are matched. Currently, the first argument follows the matching rules described in the previous section, but all subsequent arguments must match exactly.

11.3.5 Matching rules compared to C++ templates

For those intimately familiar with C++ templates, a comparison of the typemap matching rules and template type deduction is interesting. The two areas considered are firstly the default typemaps and their similarities to partial template specialization and secondly, non-default typemaps and their similarities to full template specialization.

For default (SWIGTYPE) typemaps the rules are inspired by C++ class template partial specialization. For example, given partial specialization for T const& :

template <typename T> struct X             { void a(); };
template <typename T> struct X< T const& > { void b(); };

The full (unspecialized) template is matched with most types, such as:

X< int & >            x1;  x1.a();

and the following all match the T const& partial specialization:

X< int *const& >      x2;  x2.b();
X< int const*const& > x3;  x3.b();
X< int const& >       x4;  x4.b();

Now, given just these two default typemaps, where T is analogous to SWIGTYPE:

%typemap(...) SWIGTYPE        { ... }
%typemap(...) SWIGTYPE const& { ... }

The generic default typemap SWIGTYPE is used with most types, such as

int &

and the following all match the SWIGTYPE const& typemap, just like the partial template matching:

int *const&
int const*const&
int const&

Note that the template and typemap matching rules are not identical for all default typemaps though, for example, with arrays.

For non-default typemaps, one might expect SWIG to follow the fully specialized template rules. This is nearly the case, but not quite. Consider a very similar example to the earlier partially specialized template but this time there is a fully specialized template:

template <typename T> struct Y       { void a(); };
template <> struct Y< int const & >  { void b(); };

Only the one type matches the specialized template exactly:

Y< int & >             y1;  y1.a();
Y< int *const& >       y2;  y2.a();
Y< int const *const& > y3;  y3.a();
Y< int const& >        y4;  y4.b(); // fully specialized match

Given typemaps with the same types used for the template declared above, where T is again analogous to SWIGTYPE:

%typemap(...) SWIGTYPE        { ... }
%typemap(...) int const&      { ... }

The comparison between non-default typemaps and fully specialized single parameter templates turns out to be the same, as just the one type will match the non-default typemap:

int &
int *const&
int const*const&
int const&        // matches non-default typemap int const&

However, if a non-const type is used instead:

%typemap(...) SWIGTYPE        { ... }
%typemap(...) int &           { ... }

then there is a clear difference to template matching as both the const and non-const types match the typemap:

int &             // matches non-default typemap int &
int *const&
int const*const&
int const&        // matches non-default typemap int &

There are other subtle differences such as typedef handling, but at least it should be clear that the typemap matching rules are similar to those for specialized template handling.

11.3.6 Debugging typemap pattern matching

There are two useful debug command line options available for debugging typemaps, -debug-tmsearch and -debug-tmused .

The -debug-tmsearch option is a verbose option for debugging typemap searches. This can be very useful for watching the pattern matching process in action and for debugging which typemaps are used. The option displays all the typemaps and types that are looked for until a successful pattern match is made. As the display includes searches for each and every type needed for wrapping, the amount of information displayed can be large. Normally you would manually search through the displayed information for the particular type that you are interested in.

For example, consider some of the code used in the Typedef reductions section already covered:

typedef int Integer;
typedef Integer Row4[4];
void foo(Row4 rows[10]);

A sample of the debugging output is shown below for the "in" typemap:

swig -perl -debug-tmsearch example.i
...
example.h:3: Searching for a suitable 'in' typemap for: Row4 rows[10]
  Looking for: Row4 rows[10]
  Looking for: Row4 [10]
  Looking for: Row4 rows[ANY]
  Looking for: Row4 [ANY]
  Looking for: Integer rows[10][4]
  Looking for: Integer [10][4]
  Looking for: Integer rows[ANY][ANY]
  Looking for: Integer [ANY][ANY]
  Looking for: int rows[10][4]
  Looking for: int [10][4]
  Looking for: int rows[ANY][ANY]
  Looking for: int [ANY][ANY]
  Looking for: SWIGTYPE rows[ANY][ANY]
  Looking for: SWIGTYPE [ANY][ANY]
  Looking for: SWIGTYPE rows[ANY][]
  Looking for: SWIGTYPE [ANY][]
  Looking for: SWIGTYPE *rows[ANY]
  Looking for: SWIGTYPE *[ANY]
  Looking for: SWIGTYPE rows[ANY]
  Looking for: SWIGTYPE [ANY]
  Looking for: SWIGTYPE rows[]
  Looking for: SWIGTYPE []
  Using: %typemap(in) SWIGTYPE []
...

showing that the best default match supplied by SWIG is the SWIGTYPE [] typemap. As the example shows, the successful match displays the used typemap source including typemap method, type and optional name in one of these simplified formats:

  • Using: %typemap(method) type name
  • Using: %typemap(method) type name = type2 name2
  • Using: %apply type2 name2 { type name }

This information might meet your debugging needs, however, you might want to analyze further. If you next invoke SWIG with the -E option to display the preprocessed output, and search for the particular typemap used, you'll find the full typemap contents (example shown below for Python):

%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) {
  res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown |  0 );
  if (!SWIG_IsOK(res)) { 
    SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument "
                       "$argnum"" of type '" "$type""'"); 
  } 
  $1 = ($ltype)(argp);
}

The generated code for the foo wrapper will then contain the snippets of the typemap with the special variables expanded. The rest of this chapter will need reading though to fully understand all of this, however, the relevant parts of the generated code for the above typemap can be seen below:

SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
...
  void *argp1 = 0 ;
  int res1 = 0 ;
...
  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_a_4__int, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "foo" "', argument "
                       "1"" of type '" "int [10][4]""'"); 
  } 
  arg1 = (int (*)[4])(argp1);
...
}

Searches for multi-argument typemaps are not mentioned unless a matching multi-argument typemap does actually exist. For example, the output for the code in the earlier multi-arguments section is as follows:

...
example.h:39: Searching for a suitable 'in' typemap for: char *buffer
  Looking for: char *buffer
  Multi-argument typemap found...
  Using: %typemap(in) (char *buffer,int len)
...

The second option for debugging is -debug-tmused and this displays the typemaps used. This option is a less verbose version of the -debug-tmsearch option as it only displays each successfully found typemap on a separate single line. The output displays the type, and name if present, the typemap method in brackets and then the actual typemap used in the same simplified format output by the -debug-tmsearch option. Below is the output for the example code at the start of this section on debugging.

$ swig -perl -debug-tmused example.i
example.h:3: Typemap for Row4 rows[10] (in) : %typemap(in) SWIGTYPE []
example.h:3: Typemap for Row4 rows[10] (typecheck) : %typemap(typecheck) SWIGTYPE *
example.h:3: Typemap for Row4 rows[10] (freearg) : %typemap(freearg) SWIGTYPE []
example.h:3: Typemap for void foo (out) : %typemap(out) void

Now, consider the following interface file:

%module example

%{
void set_value(const char* val) {}
%}

%typemap(check) char *NON_NULL {
  if (!$1) {
    /* ... error handling ... */
  }
}

// use default pointer handling instead of strings
%apply SWIGTYPE * { const char* val, const char* another_value }

%typemap(check) const char* val = char* NON_NULL;

%typemap(arginit, noblock=1) const char* val {
   $1 = "";
}

void set_value(const char* val);

and the output debug:

swig -perl5 -debug-tmused example.i
example.i:21: Typemap for char const *val (arginit) : %typemap(arginit) char const *val
example.i:21: Typemap for char const *val (in) : %apply SWIGTYPE * { char const *val }
example.i:21: Typemap for char const *val (typecheck) : %apply SWIGTYPE * { char const *val }
example.i:21: Typemap for char const *val (check) : %typemap(check) char const *val = char *NON_NULL
example.i:21: Typemap for char const *val (freearg) : %apply SWIGTYPE * { char const *val }
example.i:21: Typemap for void set_value (out) : %typemap(out) void

The following observations about what is displayed can be noted (the same applies for -debug-tmsearch):

  • The relevant typemap is shown, but for typemap copying, the appropriate %typemap or %apply is displayed, for example, the "check" and "in" typemaps.
  • The typemap modifiers are not shown, eg the noblock=1 modifier in the "arginit" typemap.
  • The exact %apply statement might look different to what is in the actual code. For example, the const char* another_value is not shown as it is not relevant here. Also the types may be displayed slightly differently - char const * and not const char*.

11.4 Code generation rules

This section describes rules by which typemap code is inserted into the generated wrapper code.

11.4.1 Scope

When a typemap is defined like this:

%typemap(in) int {
   $1 = PyInt_AsLong($input);
}

the typemap code is inserted into the wrapper function using a new block scope. In other words, the wrapper code will look like this:

wrap_whatever() {
    ...
    // Typemap code
    {                    
       arg1 = PyInt_AsLong(obj1);
    }
    ...
}

Because the typemap code is enclosed in its own block, it is legal to declare temporary variables for use during typemap execution. For example:

%typemap(in) short {
   long temp;          /* Temporary value */
   if (Tcl_GetLongFromObj(interp, $input, &temp) != TCL_OK) {
      return TCL_ERROR;
   }
   $1 = (short) temp;
}

Of course, any variables that you declare inside a typemap are destroyed as soon as the typemap code has executed (they are not visible to other parts of the wrapper function or other typemaps that might use the same variable names).

Occasionally, typemap code will be specified using a few alternative forms. For example:

%typemap(in) int "$1 = PyInt_AsLong($input);";
%typemap(in) int %{
$1 = PyInt_AsLong($input);
%}
%typemap(in, noblock=1) int {
$1 = PyInt_AsLong($input);
}

These three forms are mainly used for cosmetics--the specified code is not enclosed inside a block scope when it is emitted. This sometimes results in a less complicated looking wrapper function. Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.

11.4.2 Declaring new local variables

Sometimes it is useful to declare a new local variable that exists within the scope of the entire wrapper function. A good example of this might be an application in which you wanted to marshal strings. Suppose you had a C++ function like this

int foo(std::string *s);

and you wanted to pass a native string in the target language as an argument. For instance, in Perl, you wanted the function to work like this:

$x = foo("Hello World");

To do this, you can't just pass a raw Perl string as the std::string * argument. Instead, you have to create a temporary std::string object, copy the Perl string data into it, and then pass a pointer to the object. To do this, simply specify the typemap with an extra parameter like this:

%typemap(in) std::string * (std::string temp) {
    unsigned int len;
    char        *s;
    s = SvPV($input,len);         /* Extract string data */
    temp.assign(s,len);           /* Assign to temp */
    $1 = &temp;                   /* Set argument to point to temp */
}

In this case, temp becomes a local variable in the scope of the entire wrapper function. For example:

wrap_foo() {
   std::string temp;    <--- Declaration of temp goes here
   ...

   /* Typemap code */
   {
      ...
      temp.assign(s,len);
      ...
   } 
   ...
}

When you set temp to a value, it persists for the duration of the wrapper function and gets cleaned up automatically on exit.

It is perfectly safe to use more than one typemap involving local variables in the same declaration. For example, you could declare a function as :

void foo(std::string *x, std::string *y, std::string *z);

This is safely handled because SWIG actually renames all local variable references by appending an argument number suffix. Therefore, the generated code would actually look like this:

wrap_foo() {
   int *arg1;    /* Actual arguments */
   int *arg2;
   int *arg3;
   std::string temp1;    /* Locals declared in the typemap */
   std::string temp2;
   std::string temp3;
   ...
   {
       char *s;
       unsigned int len;
       ...
       temp1.assign(s,len);
       arg1 = *temp1;
   }
   {
       char *s;
       unsigned int len;
       ...
       temp2.assign(s,len);
       arg2 = &temp2;
   }
   {
       char *s;
       unsigned int len;
       ...
       temp3.assign(s,len);
       arg3 = &temp3;
   }
   ...
}

Some typemaps do not recognize local variables (or they may simply not apply). At this time, only typemaps that apply to argument conversion support this (input typemaps such as the "in" typemap).

Note:

When declaring a typemap for multiple types, each type must have its own local variable declaration.

%typemap(in) const std::string *, std::string * (std::string temp) // NO!
// only std::string * has a local variable
// const std::string * does not (oops)
....

%typemap(in) const std::string * (std::string temp), std::string * (std::string temp) // Correct
....

11.4.3 Special variables

Within all typemaps, the following special variables are expanded. This is by no means a complete list as some target languages have additional special variables which are documented in the language specific chapters.

VariableMeaning
$n A C local variable corresponding to type n in the typemap pattern.
$argnumArgument number. Only available in typemaps related to argument conversion
$n_nameArgument name
$n_typeReal C datatype of type n.
$n_ltypeltype of type n
$n_mangleMangled form of type n. For example _p_Foo
$n_descriptorType descriptor structure for type n. For example SWIGTYPE_p_Foo. This is primarily used when interacting with the run-time type checker (described later).
$*n_typeReal C datatype of type n with one pointer removed.
$*n_ltypeltype of type n with one pointer removed.
$*n_mangleMangled form of type n with one pointer removed.
$*n_descriptorType descriptor structure for type n with one pointer removed.
$&n_typeReal C datatype of type n with one pointer added.
$&n_ltypeltype of type n with one pointer added.
$&n_mangleMangled form of type n with one pointer added.
$&n_descriptorType descriptor structure for type n with one pointer added.
$n_basetypeBase typename with all pointers and qualifiers stripped.

Within the table, $n refers to a specific type within the typemap specification. For example, if you write this

%typemap(in) int *INPUT {

}

then $1 refers to int *INPUT. If you have a typemap like this,

%typemap(in) (int argc, char *argv[]) {
  ...
}

then $1 refers to int argc and $2 refers to char *argv[].

Substitutions related to types and names always fill in values from the actual code that was matched. This is useful when a typemap might match multiple C datatype. For example:

%typemap(in)  int, short, long {
   $1 = ($1_ltype) PyInt_AsLong($input);
}

In this case, $1_ltype is replaced with the datatype that is actually matched.

When typemap code is emitted, the C/C++ datatype of the special variables $1 and $2 is always an "ltype." An "ltype" is simply a type that can legally appear on the left-hand side of a C assignment operation. Here are a few examples of types and ltypes:

type              ltype
------            ----------------
int               int
const int         int
const int *       int *
int [4]           int *
int [4][5]        int (*)[5]

In most cases a ltype is simply the C datatype with qualifiers stripped off. In addition, arrays are converted into pointers.

Variables such as $&1_type and $*1_type are used to safely modify the type by removing or adding pointers. Although not needed in most typemaps, these substitutions are sometimes needed to properly work with typemaps that convert values between pointers and values.

If necessary, type related substitutions can also be used when declaring locals. For example:

%typemap(in) int * ($*1_type temp) {
    temp = PyInt_AsLong($input);
    $1 = &temp;
}

There is one word of caution about declaring local variables in this manner. If you declare a local variable using a type substitution such as $1_ltype temp, it won't work like you expect for arrays and certain kinds of pointers. For example, if you wrote this,

%typemap(in) int [10][20] {
   $1_ltype temp;
}

then the declaration of temp will be expanded as

int (*)[20] temp;

This is illegal C syntax and won't compile. There is currently no straightforward way to work around this problem in SWIG due to the way that typemap code is expanded and processed. However, one possible workaround is to simply pick an alternative type such as void * and use casts to get the correct type when needed. For example:

%typemap(in) int [10][20] {
   void *temp;
   ...
   (($1_ltype) temp)[i][j] = x;    /* set a value */
   ...
}

Another approach, which only works for arrays is to use the $1_basetype substitution. For example:

%typemap(in) int [10][20] {
   $1_basetype temp[10][20];
   ...
   temp[i][j] = x;    /* set a value */
   ...
}

11.4.4 Special variable macros

Special variable macros are like macro functions in that they take one or more input arguments which are used for the macro expansion. They look like macro/function calls but use the special variable $ prefix to the macro name. Note that unlike normal macros, the expansion is not done by the preprocessor, it is done during the SWIG parsing/compilation stages. The following special variable macros are available across all language modules.

11.4.4.1 $descriptor(type)

This macro expands into the type descriptor structure for any C/C++ type specified in type. It behaves like the $1_descriptor special variable described above except that the type to expand is taken from the macro argument rather than inferred from the typemap type. For example, $descriptor(std::vector<int> *) will expand into SWIGTYPE_p_std__vectorT_int_t. This macro is mostly used in the scripting target languages and is demonstrated later in the Run-time type checker usage section.

11.4.4.2 $typemap(method, typepattern)

This macro uses the pattern matching rules described earlier to lookup and then substitute the special variable macro with the code in the matched typemap. The typemap to search for is specified by the arguments, where method is the typemap method name and typepattern is a type pattern as per the %typemap specification in the Defining a typemap section.

The special variables within the matched typemap are expanded into those for the matched typemap type, not the typemap within which the macro is called. In practice, there is little use for this macro in the scripting target languages. It is mostly used in the target languages that are statically typed as a way to obtain the target language type given the C/C++ type and more commonly only when the C++ type is a template parameter.

The example below is for C# only and uses some typemap method names documented in the C# chapter, but it shows some of the possible syntax variations.

%typemap(cstype) unsigned long    "uint"
%typemap(cstype) unsigned long bb "bool"
%typemap(cscode) BarClass %{
  void foo($typemap(cstype, unsigned long aa) var1,
           $typemap(cstype, unsigned long bb) var2,
           $typemap(cstype, (unsigned long bb)) var3,
           $typemap(cstype, unsigned long) var4)
  {
    // do something
  }
%}

The result is the following expansion

%typemap(cstype) unsigned long    "uint"
%typemap(cstype) unsigned long bb "bool"
%typemap(cscode) BarClass %{
  void foo(uint var1,
           bool var2,
           bool var3,
           uint var4)
  {
    // do something
  }
%}

11.5 Common typemap methods

The set of typemaps recognized by a language module may vary. However, the following typemap methods are nearly universal:

11.5.1 "in" typemap

The "in" typemap is used to convert function arguments from the target language to C. For example:

%typemap(in) int {
   $1 = PyInt_AsLong($input);
}

The following special variables are available:

$input            - Input object holding value to be converted.
$symname          - Name of function/method being wrapped

This is probably the most commonly redefined typemap because it can be used to implement customized conversions.

In addition, the "in" typemap allows the number of converted arguments to be specified. The numinputs attributes facilitates this. For example:

// Ignored argument.
%typemap(in, numinputs=0) int *out (int temp) {
    $1 = &temp;
}

At this time, only zero or one arguments may be converted. When numinputs is set to 0, the argument is effectively ignored and cannot be supplied from the target language. The argument is still required when making the C/C++ call and the above typemap shows the value used is instead obtained from a locally declared variable called temp. Usually numinputs is not specified, whereupon the default value is 1, that is, there is a one to one mapping of the number of arguments when used from the target language to the C/C++ call. Multi-argument typemaps provide a similar concept where the number of arguments mapped from the target language to C/C++ can be changed for multiple adjacent C/C++ arguments.

Compatibility note: Specifying numinputs=0 is the same as the old "ignore" typemap.

11.5.2 "typecheck" typemap

The "typecheck" typemap is used to support overloaded functions and methods. It merely checks an argument to see whether or not it matches a specific type. For example:

%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) int {
   $1 = PyInt_Check($input) ? 1 : 0;
}

For typechecking, the $1 variable is always a simple integer that is set to 1 or 0 depending on whether or not the input argument is the correct type.

If you define new "in" typemaps and your program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in the Typemaps and overloading section.

11.5.3 "out" typemap

The "out" typemap is used to convert function/method return values from C into the target language. For example:

%typemap(out) int {
   $result = PyInt_FromLong($1);
}

The following special variables are available.

$result           - Result object returned to target language.
$symname          - Name of function/method being wrapped

The "out" typemap supports an optional attribute flag called "optimal". This is for code optimisation and is detailed in the Optimal code generation when returning by value section.

11.5.4 "arginit" typemap

The "arginit" typemap is used to set the initial value of a function argument--before any conversion has occurred. This is not normally necessary, but might be useful in highly specialized applications. For example:

// Set argument to NULL before any conversion occurs
%typemap(arginit) int *data {
   $1 = NULL;
}

11.5.5 "default" typemap

The "default" typemap is used to turn an argument into a default argument. For example:

%typemap(default) int flags {
   $1 = DEFAULT_FLAGS;
}
...
int foo(int x, int y, int flags);

The primary use of this typemap is to either change the wrapping of default arguments or specify a default argument in a language where they aren't supported (like C). Target languages that do not support optional arguments, such as Java and C#, effectively ignore the value specified by this typemap as all arguments must be given.

Once a default typemap has been applied to an argument, all arguments that follow must have default values. See the Default/optional arguments section for further information on default argument wrapping.

11.5.6 "check" typemap

The "check" typemap is used to supply value checking code during argument conversion. The typemap is applied after arguments have been converted. For example:

%typemap(check) int positive {
   if ($1 <= 0) {
       SWIG_exception(SWIG_ValueError,"Expected positive value.");
   }
}

11.5.7 "argout" typemap

The "argout" typemap is used to return values from arguments. This is most commonly used to write wrappers for C/C++ functions that need to return multiple values. The "argout" typemap is almost always combined with an "in" typemap---possibly to ignore the input value. For example:

/* Set the input argument to point to a temporary variable */
%typemap(in, numinputs=0) int *out (int temp) {
   $1 = &temp;
}

%typemap(argout) int *out {
   // Append output value $1 to $result
   ...
}

The following special variables are available.

$result           - Result object returned to target language.
$input            - The original input object passed.
$symname          - Name of function/method being wrapped

The code supplied to the "argout" typemap is always placed after the "out" typemap. If multiple return values are used, the extra return values are often appended to return value of the function.

See the typemaps.i library file for examples.

11.5.8 "freearg" typemap

The "freearg" typemap is used to cleanup argument data. It is only used when an argument might have allocated resources that need to be cleaned up when the wrapper function exits. The "freearg" typemap usually cleans up argument resources allocated by the "in" typemap. For example:

// Get a list of integers
%typemap(in) int *items {
   int nitems = Length($input);    
   $1 = (int *) malloc(sizeof(int)*nitems);
}
// Free the list 
%typemap(freearg) int *items {
   free($1);
}

The "freearg" typemap inserted at the end of the wrapper function, just before control is returned back to the target language. This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.

11.5.9 "newfree" typemap

The "newfree" typemap is used in conjunction with the %newobject directive and is used to deallocate memory used by the return result of a function. For example:

%typemap(newfree) string * {
   delete $1;
}
%typemap(out) string * {
   $result = PyString_FromString($1->c_str());
}
...

%newobject foo;
...
string *foo();

See Object ownership and %newobject for further details.

11.5.10 "memberin" typemap

The "memberin" typemap is used to copy data from an already converted input value into a structure member. It is typically used to handle array members and other special cases. For example:

%typemap(memberin) int [4] {
   memmove($1, $input, 4*sizeof(int));
}

It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

11.5.11 "varin" typemap

The "varin" typemap is used to convert objects in the target language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

11.5.12 "varout" typemap

The "varout" typemap is used to convert a C/C++ object to an object in the target language when reading a C/C++ global variable. This is implementation specific.

11.5.13 "throws" typemap

The "throws" typemap is only used when SWIG parses a C++ method with an exception specification or has the %catches feature attached to the method. It provides a default mechanism for handling C++ methods that have declared the exceptions they will throw. The purpose of this typemap is to convert a C++ exception into an error or exception in the target language. It is slightly different to the other typemaps as it is based around the exception type rather than the type of a parameter or variable. For example:

%typemap(throws) const char * %{
  PyErr_SetString(PyExc_RuntimeError, $1);
  SWIG_fail;
%}
void bar() throw (const char *);

As can be seen from the generated code below, SWIG generates an exception handler with the catch block comprising the "throws" typemap content.

...
try {
    bar();
}
catch(char const *_e) {
    PyErr_SetString(PyExc_RuntimeError, _e);
    SWIG_fail;
    
}
...

Note that if your methods do not have an exception specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.

11.6 Some typemap examples

This section contains a few examples. Consult language module documentation for more examples.

11.6.1 Typemaps for arrays

A common use of typemaps is to provide support for C arrays appearing both as arguments to functions and as structure members.

For example, suppose you had a function like this:

void set_vector(int type, float value[4]);

If you wanted to handle float value[4] as a list of floats, you might write a typemap similar to this:


%typemap(in) float value[4] (float temp[4]) {
  int i;
  if (!PySequence_Check($input)) {
    PyErr_SetString(PyExc_ValueError,"Expected a sequence");
    return NULL;
  }
  if (PySequence_Length($input) != 4) {
    PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected 4 elements");
    return NULL;
  }
  for (i = 0; i < 4; i++) {
    PyObject *o = PySequence_GetItem($input,i);
    if (PyNumber_Check(o)) {
      temp[i] = (float) PyFloat_AsDouble(o);
    } else {
      PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");      
      return NULL;
    }
  }
  $1 = temp;
}

In this example, the variable temp allocates a small array on the C stack. The typemap then populates this array and passes it to the underlying C function.

When used from Python, the typemap allows the following type of function call:

>>> set_vector(type, [ 1, 2.5, 5, 20 ])

If you wanted to generalize the typemap to apply to arrays of all dimensions you might write this:

%typemap(in) float value[ANY] (float temp[$1_dim0]) {
  int i;
  if (!PySequence_Check($input)) {
    PyErr_SetString(PyExc_ValueError,"Expected a sequence");
    return NULL;
  }
  if (PySequence_Length($input) != $1_dim0) {
    PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");
    return NULL;
  }
  for (i = 0; i < $1_dim0; i++) {
    PyObject *o = PySequence_GetItem($input,i);
    if (PyNumber_Check(o)) {
      temp[i] = (float) PyFloat_AsDouble(o);
    } else {
      PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");      
      return NULL;
    }
  }
  $1 = temp;
}

In this example, the special variable $1_dim0 is expanded with the actual array dimensions. Multidimensional arrays can be matched in a similar manner. For example:

%typemap(in) float matrix[ANY][ANY] (float temp[$1_dim0][$1_dim1]) {
   ... convert a 2d array ...
}

For large arrays, it may be impractical to allocate storage on the stack using a temporary variable as shown. To work with heap allocated data, the following technique can be used.

%typemap(in) float value[ANY] {
  int i;
  if (!PySequence_Check($input)) {
    PyErr_SetString(PyExc_ValueError,"Expected a sequence");
    return NULL;
  }
  if (PySequence_Length($input) != $1_dim0) {
    PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");
    return NULL;
  }
  $1 = (float *) malloc($1_dim0*sizeof(float));
  for (i = 0; i < $1_dim0; i++) {
    PyObject *o = PySequence_GetItem($input,i);
    if (PyNumber_Check(o)) {
      $1[i] = (float) PyFloat_AsDouble(o);
    } else {
      PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");      
      free($1);
      return NULL;
    }
  }
}
%typemap(freearg) float value[ANY] {
   if ($1) free($1);
}

In this case, an array is allocated using malloc. The freearg typemap is then used to release the argument after the function has been called.

Another common use of array typemaps is to provide support for array structure members. Due to subtle differences between pointers and arrays in C, you can't just "assign" to a array structure member. Instead, you have to explicitly copy elements into the array. For example, suppose you had a structure like this:

struct SomeObject {
	float  value[4];
        ...
};

When SWIG runs, it won't produce any code to set the vec member. You may even get a warning message like this:

$ swig -python  example.i
example.i:10: Warning 462: Unable to set variable of type float [4].

These warning messages indicate that SWIG does not know how you want to set the vec field.

To fix this, you can supply a special "memberin" typemap like this:

%typemap(memberin) float [ANY] {
  int i;
  for (i = 0; i < $1_dim0; i++) {
      $1[i] = $input[i];
  }
}

The memberin typemap is used to set a structure member from data that has already been converted from the target language to C. In this case, $input is the local variable in which converted input data is stored. This typemap then copies this data into the structure.

When combined with the earlier typemaps for arrays, the combination of the "in" and "memberin" typemap allows the following usage:

>>> s = SomeObject()
>>> s.x = [1, 2.5, 5, 10]

Related to structure member input, it may be desirable to return structure members as a new kind of object. For example, in this example, you will get very odd program behavior where the structure member can be set nicely, but reading the member simply returns a pointer:

>>> s = SomeObject()
>>> s.x = [1, 2.5, 5, 10]
>>> print s.x
_1008fea8_p_float
>>> 

To fix this, you can write an "out" typemap. For example:

%typemap(out) float [ANY] {
  int i;
  $result = PyList_New($1_dim0);
  for (i = 0; i < $1_dim0; i++) {
    PyObject *o = PyFloat_FromDouble((double) $1[i]);
    PyList_SetItem($result,i,o);
  }
}

Now, you will find that member access is quite nice:

>>> s = SomeObject()
>>> s.x = [1, 2.5, 5, 10]
>>> print s.x
[ 1, 2.5, 5, 10]

Compatibility Note: SWIG1.1 used to provide a special "memberout" typemap. However, it was mostly useless and has since been eliminated. To return structure members, simply use the "out" typemap.

11.6.2 Implementing constraints with typemaps

One particularly interesting application of typemaps is the implementation of argument constraints. This can be done with the "check" typemap. When used, this allows you to provide code for checking the values of function arguments. For example:

%module math

%typemap(check) double posdouble {
	if ($1 < 0) {
		croak("Expecting a positive number");
	}
}

...
double sqrt(double posdouble);

This provides a sanity check to your wrapper function. If a negative number is passed to this function, a Perl exception will be raised and your program terminated with an error message.

This kind of checking can be particularly useful when working with pointers. For example:

%typemap(check) Vector * {
    if ($1 == 0) {
        PyErr_SetString(PyExc_TypeError,"NULL Pointer not allowed");
        return NULL;
   }
}

will prevent any function involving a Vector * from accepting a NULL pointer. As a result, SWIG can often prevent a potential segmentation faults or other run-time problems by raising an exception rather than blindly passing values to the underlying C/C++ program.

11.7 Typemaps for multiple target languages

The code within typemaps is usually language dependent, however, many target languages support the same typemaps. In order to distinguish typemaps across different languages, the preprocessor should be used. For example, the "in" typemap for Perl and Ruby could be written as:

#if defined(SWIGPERL)
  %typemap(in) int "$1 = ($1_ltype) SvIV($input);"
#elif defined(SWIGRUBY)
  %typemap(in) int "$1 = NUM2INT($input);"
#else
  #warning no "in" typemap defined
#endif

The full set of language specific macros is defined in the Conditional Compilation section. The example above also shows a common approach of issuing a warning for an as yet unsupported language.

Compatibility note: In SWIG-1.1 different languages could be distinguished with the language name being put within the %typemap directive, for example,
%typemap(ruby,in) int "$1 = NUM2INT($input);".

11.8 Optimal code generation when returning by value

The "out" typemap is the main typemap for return types. This typemap supports an optional attribute flag called "optimal", which is for reducing temporary variables and the amount of generated code, thereby giving the compiler the opportunity to use return value optimization for generating faster executing code. It only really makes a difference when returning objects by value and has some limitations on usage, as explained later on.

When a function returns an object by value, SWIG generates code that instantiates the default type on the stack then assigns the value returned by the function call to it. A copy of this object is then made on the heap and this is what is ultimately stored and used from the target language. This will be clearer considering an example. Consider running the following code through SWIG:

%typemap(out) SWIGTYPE %{
  $result = new $1_ltype((const $1_ltype &)$1);
%}

%inline %{
#include <iostream>
using namespace std;

struct XX {
  XX() { cout << "XX()" << endl; }
  XX(int i) { cout << "XX(" << i << ")" << endl; }
  XX(const XX &other) { cout << "XX(const XX &)" << endl; }
  XX & operator =(const XX &other) { cout << "operator=(const XX &)" << endl; return *this; }
  ~XX() { cout << "~XX()" << endl; }
  static XX create() { 
    return XX(0);
  }
};
%}

The "out" typemap shown is the default typemap for C# when returning objects by value. When making a call to XX::create() from C#, the output is as follows:

XX()
XX(0)
operator=(const XX &)
~XX()
XX(const XX &)
~XX()
~XX()

Note that three objects are being created as well as an assignment. Wouldn't it be great if the XX::create() method was the only time a constructor was called? As the method returns by value, this is asking a lot and the code that SWIG generates by default makes it impossible for the compiler to use return value optimisation (RVO) . However, this is where the "optimal" attribute in the "out" typemap can help out. If the typemap code is kept the same and just the "optimal" attribute specified like this:

%typemap(out, optimal="1") SWIGTYPE %{
  $result = new $1_ltype((const $1_ltype &)$1);
%}

then when the code is run again, the output is simply:

XX(0)
~XX()

How the "optimal" attribute works is best explained using the generated code. Without "optimal", the generated code is:

SWIGEXPORT void * SWIGSTDCALL CSharp_XX_create() {
  void * jresult ;
  XX result;
  result = XX::create();
  jresult = new XX((const XX &)result);
  return jresult;
}

With the "optimal" attribute, the code is:

SWIGEXPORT void * SWIGSTDCALL CSharp_XX_create() {
  void * jresult ;
  jresult = new XX((const XX &)XX::create());
  return jresult;
}

The major difference is the result temporary variable holding the value returned from XX::create() is no longer generated and instead the copy constructor call is made directly from the value returned by XX::create(). With modern compilers implementing RVO, the copy is not actually done, in fact the object is never created on the stack in XX::create() at all, it is simply created directly on the heap. In the first instance, the $1 special variable in the typemap is expanded into result. In the second instance, $1 is expanded into XX::create() and this is essentially what the "optimal" attribute is telling SWIG to do.

The "optimal" attribute optimisation is not turned on by default as it has a number of restrictions. Firstly, some code cannot be condensed into a simple call for passing into the copy constructor. One common occurrence is when %exception is used. Consider adding the following %exception to the example:

%exception XX::create() %{
try {
  $action
} catch(const std::exception &e) {
  cout << e.what() << endl;
}
%}

SWIG can detect when the "optimal" attribute cannot be used and will ignore it and in this case will issue the following warning:

example.i:28: Warning 474: Method XX::create() usage of the optimal attribute ignored
example.i:14: Warning 474: in the out typemap as the following cannot be used to generate
optimal code: 
try {
  result = XX::create();
} catch(const std::exception &e) {
  cout << e.what() << endl;
}

It should be clear that the above code cannot be used as the argument to the copy constructor call, that is, for the $1 substitution.

Secondly, if the typemaps uses $1 more than once, then multiple calls to the wrapped function will be made. Obviously that is not very optimal. In fact SWIG attempts to detect this and will issue a warning something like:

example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to
example.i:7: Warning 475: optimal attribute usage in the out typemap.

However, it doesn't always get it right, for example when $1 is within some commented out code.

11.9 Multi-argument typemaps

So far, the typemaps presented have focused on the problem of dealing with single values. For example, converting a single input object to a single argument in a function call. However, certain conversion problems are difficult to handle in this manner. As an example, consider the example at the very beginning of this chapter:

int foo(int argc, char *argv[]);

Suppose that you wanted to wrap this function so that it accepted a single list of strings like this:

>>> foo(["ale","lager","stout"])

To do this, you not only need to map a list of strings to char *argv[], but the value of int argc is implicitly determined by the length of the list. Using only simple typemaps, this type of conversion is possible, but extremely painful. Multi-argument typemaps help in this situation.

A multi-argument typemap is a conversion rule that specifies how to convert a single object in the target language to a set of consecutive function arguments in C/C++. For example, the following multi-argument maps perform the conversion described for the above example:

%typemap(in) (int argc, char *argv[]) {
  int i;
  if (!PyList_Check($input)) {
    PyErr_SetString(PyExc_ValueError, "Expecting a list");
    return NULL;
  }
  $1 = PyList_Size($input);
  $2 = (char **) malloc(($1+1)*sizeof(char *));
  for (i = 0; i < $1; i++) {
    PyObject *s = PyList_GetItem($input,i);
    if (!PyString_Check(s)) {
        free($2);
        PyErr_SetString(PyExc_ValueError, "List items must be strings");
        return NULL;
    }
    $2[i] = PyString_AsString(s);
  }
  $2[i] = 0;
}

%typemap(freearg) (int argc, char *argv[]) {
   if ($2) free($2);
}

A multi-argument map is always specified by surrounding the arguments with parentheses as shown. For example:

%typemap(in) (int argc, char *argv[]) { ... }

Within the typemap code, the variables $1, $2, and so forth refer to each type in the map. All of the usual substitutions apply--just use the appropriate $1 or $2 prefix on the variable name (e.g., $2_type, $1_ltype, etc.)

Multi-argument typemaps always have precedence over simple typemaps and SWIG always performs longest-match searching. Therefore, you will get the following behavior:

%typemap(in) int argc                              { ... typemap 1 ... }
%typemap(in) (int argc, char *argv[])              { ... typemap 2 ... }
%typemap(in) (int argc, char *argv[], char *env[]) { ... typemap 3 ... }

int foo(int argc, char *argv[]);                   // Uses typemap 2
int bar(int argc, int x);                          // Uses typemap 1
int spam(int argc, char *argv[], char *env[]);     // Uses typemap 3

It should be stressed that multi-argument typemaps can appear anywhere in a function declaration and can appear more than once. For example, you could write this:

%typemap(in) (int scount, char *swords[]) { ... }
%typemap(in) (int wcount, char *words[]) { ... }

void search_words(int scount, char *swords[], int wcount, char *words[], int maxcount);

Other directives such as %apply and %clear also work with multi-argument maps. For example:

%apply (int argc, char *argv[]) {
    (int scount, char *swords[]),
    (int wcount, char *words[])
};
...
%clear (int scount, char *swords[]), (int wcount, char *words[]);
...

Although multi-argument typemaps may seem like an exotic, little used feature, there are several situations where they make sense. First, suppose you wanted to wrap functions similar to the low-level read() and write() system calls. For example:

typedef unsigned int size_t;

int read(int fd, void *rbuffer, size_t len);
int write(int fd, void *wbuffer, size_t len);

As is, the only way to use the functions would be to allocate memory and pass some kind of pointer as the second argument---a process that might require the use of a helper function. However, using multi-argument maps, the functions can be transformed into something more natural. For example, you might write typemaps like this:

// typemap for an outgoing buffer
%typemap(in) (void *wbuffer, size_t len) {
   if (!PyString_Check($input)) {
       PyErr_SetString(PyExc_ValueError, "Expecting a string");
       return NULL;
   }
   $1 = (void *) PyString_AsString($input);
   $2 = PyString_Size($input);
}

// typemap for an incoming buffer
%typemap(in) (void *rbuffer, size_t len) {
   if (!PyInt_Check($input)) {
       PyErr_SetString(PyExc_ValueError, "Expecting an integer");
       return NULL;
   }
   $2 = PyInt_AsLong($input);
   if ($2 < 0) {
       PyErr_SetString(PyExc_ValueError, "Positive integer expected");
       return NULL;
   }
   $1 = (void *) malloc($2);
}

// Return the buffer.  Discarding any previous return result
%typemap(argout) (void *rbuffer, size_t len) {
   Py_XDECREF($result);   /* Blow away any previous result */
   if (result < 0) {      /* Check for I/O error */
       free($1);
       PyErr_SetFromErrno(PyExc_IOError);
       return NULL;
   }
   $result = PyString_FromStringAndSize($1,result);
   free($1);
}

(note: In the above example, $result and result are two different variables. result is the real C datatype that was returned by the function. $result is the scripting language object being returned to the interpreter.).

Now, in a script, you can write code that simply passes buffers as strings like this:

>>> f = example.open("Makefile")
>>> example.read(f,40)
'TOP        = ../..\nSWIG       = $(TOP)/.'
>>> example.read(f,40)
'./swig\nSRCS       = example.c\nTARGET    '
>>> example.close(f)
0
>>> g = example.open("foo", example.O_WRONLY | example.O_CREAT, 0644)
>>> example.write(g,"Hello world\n")
12
>>> example.write(g,"This is a test\n")
15
>>> example.close(g)
0
>>>

A number of multi-argument typemap problems also arise in libraries that perform matrix-calculations--especially if they are mapped onto low-level Fortran or C code. For example, you might have a function like this:

int is_symmetric(double *mat, int rows, int columns);

In this case, you might want to pass some kind of higher-level object as an matrix. To do this, you could write a multi-argument typemap like this:

%typemap(in) (double *mat, int rows, int columns) {
    MatrixObject *a;
    a = GetMatrixFromObject($input);     /* Get matrix somehow */

    /* Get matrix properties */
    $1 = GetPointer(a);
    $2 = GetRows(a);
    $3 = GetColumns(a);
}

This kind of technique can be used to hook into scripting-language matrix packages such as Numeric Python. However, it should also be stressed that some care is in order. For example, when crossing languages you may need to worry about issues such as row-major vs. column-major ordering (and perform conversions if needed). Note that multi-argument typemaps cannot deal with non-consecutive C/C++ arguments; a workaround such as a helper function re-ordering the arguments to make them consecutive will need to be written.

11.10 Typemap warnings

Warnings can be added to typemaps so that SWIG generates a warning message whenever the typemap is used. See the information in the issuing warnings section.

11.11 Typemap fragments

The primary purpose of fragments is to reduce code bloat that repeated use of typemap code can lead to. Fragments are snippets of code that can be thought of as code dependencies of a typemap. If a fragment is used by more than one typemap, then the snippet of code within the fragment is only generated once. Code bloat is typically reduced by moving typemap code into a support function and then placing the support function into a fragment.

For example, if you have a very long typemap

%typemap(in) MyClass * {
  MyClass *value = 0;

  ... many lines of marshalling code  ...

  $result = value;
}

the same marshalling code is often repeated in several typemaps, such as "in", "varin", "directorout", etc. SWIG copies the code for each argument that requires the typemap code, easily leading to code bloat in the generated code. To eliminate this, define a fragment that includes the common marshalling code:

%fragment("AsMyClass", "header") {
  MyClass *AsMyClass(PyObject *obj) {
    MyClass *value = 0;

    ... many lines of marshalling code  ...

    return value;
  }
}

%typemap(in, fragment="AsMyClass") MyClass * {
  $result = AsMyClass($input);
}

%typemap(varin, fragment="AsMyClass") MyClass * {
  $result = AsMyClass($input);
}

When the "in" or "varin" typemaps for MyClass are required, the contents of the fragment called "AsMyClass" is added to the "header" section within the generated code, and then the typemap code is emitted. Hence, the method AsMyClass will be generated into the wrapper code before any typemap code that calls it.

To define a fragment you need a fragment name, a section name for generating the fragment code into, and the code itself. See Code insertion blocks for a full list of section names. Usually the section name used is "header". Different delimiters can be used:

%fragment("my_name", "header") %{ ... %}
%fragment("my_name", "header") { ... }
%fragment("my_name", "header") " ... "

and these follow the usual preprocessing rules mentioned in the Preprocessing delimiters section. The following are some rules and guidelines for using fragments:

  1. A fragment is added to the wrapping code only once. When using the MyClass * typemaps above and wrapping the method:

    void foo(MyClass *a, MyClass *b);
    

    the generated code will look something like:

    MyClass *AsMyClass(PyObject *obj) {
      ...
    }
    
    void _wrap_foo(...) {
      ....
      arg1 = AsMyClass(obj1);
      arg2 = AsMyClass(obj2);
      ...
      foo(arg1, arg2);
    }
    

    even as there is duplicated typemap code to process both a and b, the AsMyClass method will be defined only once.

  2. A fragment should only be defined once. If there is more than one definition, the first definition is the one used. All other definitions are silently ignored. For example, if you have

    %fragment("AsMyClass", "header") { ...definition 1... }
    ....
    %fragment("AsMyClass", "header") { ...definition 2... }
    

    only the first definition is used. In this way you can override the default fragments in a SWIG library by defining your fragment before the library %include. Note that this behavior is the opposite to typemaps, where the last typemap defined/applied prevails. Fragments follow the first-in-first-out convention since they are intended to be global, while typemaps are intended to be locally specialized.

  3. Fragment names cannot contain commas.

  4. A fragment can use one or more additional fragments, for example:

    %fragment("<limits.h>", "header") {
      %#include <limits.h>
    }
    
    
    %fragment("AsMyClass", "header", fragment="<limits.h>") {
      MyClass *AsMyClass(PyObject *obj) {
        MyClass *value = 0;
    
        ... some marshalling code  ...
    
        if  (ival < CHAR_MIN /*defined in <limits.h>*/) {
           ...
        } else {
           ...
        }
        ...
        return value;
      }
    }
    

    in this case, when the "AsMyClass" fragment is emitted, it also triggers the inclusion of the "<limits.h>" fragment.

  5. A fragment can have dependencies on a number of other fragments, for example:

    %fragment("bigfragment", "header", fragment="frag1", fragment="frag2", fragment="frag3") "";
    

    When the "bigfragment" is used, the three dependent fragments "frag1", "frag2" and "frag3" are also pulled in. Note that as "bigframent" is empty (the empty string - ""), it does not add any code itself, but merely triggers the inclusion of the other fragments.

  6. A typemap can also use more than one fragment, but since the syntax is different, you need to specify the dependent fragments in a comma separated list. Consider:

    %typemap(in, fragment="frag1,frag2,frag3") {...}
    

    which is equivalent to:

    %typemap(in, fragment="bigfragment") {...}
    

    when used with the "bigfragment" defined above.

  7. Finally, you can force the inclusion of a fragment at any point in the generated code as follows:

    %fragment("bigfragment");
    

    which is very useful inside a template class, for example.

Most readers will probably want to skip the next two sub-sections on advanced fragment usage unless a desire to really get to grips with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.

11.11.1 Fragment type specialization

Fragments can be type specialized. The syntax is as follows:

%fragment("name", "header") { ...a type independent fragment... }
%fragment("name"{type}, "header") { ...a type dependent fragment...  }

where type is a C/C++ type. Like typemaps, fragments can also be used inside templates, for example:

template <class T>
struct A {
  %fragment("incode"{A<T>}, "header") {
    ... 'incode' specialized fragment ...
  }

  %typemap(in, fragment="incode"{A<T>}) {
     ... here we use the 'type specialized' fragment "incode"{A<T>} ...
  }
};

11.11.2 Fragments and automatic typemap specialization

Since fragments can be type specialized, they can be elegantly used to specialize typemaps. For example, if you have something like:

%fragment("incode"{float}, "header") {
  float in_method_float(PyObject *obj) {
    ...
  }
}

%fragment("incode"{long}, "header") {
  float in_method_long(PyObject *obj) {
    ...
  }
}

// %my_typemaps macro definition
%define %my_typemaps(Type) 
%typemap(in, fragment="incode"{Type}) Type {
  value = in_method_##Type(obj);
}
%enddef

%my_typemaps(float);
%my_typemaps(long);

then the proper "incode"{float} or "incode"{long} fragment will be used, and the in_method_float and in_method_long methods will be called whenever the float or long types are used as input parameters.

This feature is used a lot in the typemaps shipped in the SWIG library for some scripting languages. The interested (or very brave) reader can take a look at the fragments.swg file shipped with SWIG to see this in action.

11.12 The run-time type checker

Most scripting languages need type information at run-time. This type information can include how to construct types, how to garbage collect types, and the inheritance relationships between types. If the language interface does not provide its own type information storage, the generated SWIG code needs to provide it.

Requirements for the type system:

  • Store inheritance and type equivalence information and be able to correctly re-create the type pointer.
  • Share type information between modules.
  • Modules can be loaded in any order, regardless of actual type dependency.
  • Avoid the use of dynamically allocated memory, and library/system calls in general.
  • Provide a reasonably fast implementation, minimizing the lookup time for all language modules.
  • Custom, language specific information can be attached to types.
  • Modules can be unloaded from the type system.

11.12.1 Implementation

The run-time type checker is used by many, but not all, of SWIG's supported target languages. The run-time type checker features are not required and are thus not used for statically typed languages such as Java and C#. The scripting and scheme based languages rely on it and it forms a critical part of SWIG's operation for these languages.

When pointers, arrays, and objects are wrapped by SWIG, they are normally converted into typed pointer objects. For example, an instance of Foo * might be a string encoded like this:

_108e688_p_Foo

At a basic level, the type checker simply restores some type-safety to extension modules. However, the type checker is also responsible for making sure that wrapped C++ classes are handled correctly---especially when inheritance is used. This is especially important when an extension module makes use of multiple inheritance. For example:

class Foo {
   int x;
};

class Bar {
   int y;
};

class FooBar : public Foo, public Bar {
   int z;
};

When the class FooBar is organized in memory, it contains the contents of the classes Foo and Bar as well as its own data members. For example:

FooBar --> | -----------|  <-- Foo
           |   int x    |
           |------------|  <-- Bar
           |   int y    |
           |------------|
           |   int z    |
           |------------|

Because of the way that base class data is stacked together, the casting of a Foobar * to either of the base classes may change the actual value of the pointer. This means that it is generally not safe to represent pointers using a simple integer or a bare void * ---type tags are needed to implement correct handling of pointer values (and to make adjustments when needed).

In the wrapper code generated for each language, pointers are handled through the use of special type descriptors and conversion functions. For example, if you look at the wrapper code for Python, you will see code like this:

if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Foo,1)) == -1) return NULL;

In this code, SWIGTYPE_p_Foo is the type descriptor that describes Foo *. The type descriptor is actually a pointer to a structure that contains information about the type name to use in the target language, a list of equivalent typenames (via typedef or inheritance), and pointer value handling information (if applicable). The SWIG_ConvertPtr() function is simply a utility function that takes a pointer object in the target language and a type-descriptor objects and uses this information to generate a C++ pointer. However, the exact name and calling conventions of the conversion function depends on the target language (see language specific chapters for details).

The actual type code is in swigrun.swg, and gets inserted near the top of the generated swig wrapper file. The phrase "a type X that can cast into a type Y" means that given a type X, it can be converted into a type Y. In other words, X is a derived class of Y or X is a typedef of Y. The structure to store type information looks like this:

/* Structure to store information on one type */
typedef struct swig_type_info {
  const char *name;             /* mangled name of this type */
  const char *str;              /* human readable name for this type */
  swig_dycast_func dcast;       /* dynamic cast function down a hierarchy */
  struct swig_cast_info *cast;  /* Linked list of types that can cast into this type */
  void *clientdata;             /* Language specific type data */
} swig_type_info;

/* Structure to store a type and conversion function used for casting */
typedef struct swig_cast_info {
  swig_type_info *type;          /* pointer to type that is equivalent to this type */
  swig_converter_func converter; /* function to cast the void pointers */
  struct swig_cast_info *next;   /* pointer to next cast in linked list */
  struct swig_cast_info *prev;   /* pointer to the previous cast */
} swig_cast_info;

Each swig_type_info stores a linked list of types that it is equivalent to. Each entry in this doubly linked list stores a pointer back to another swig_type_info structure, along with a pointer to a conversion function. This conversion function is used to solve the above problem of the FooBar class, correctly returning a pointer to the type we want.

The basic problem we need to solve is verifying and building arguments passed to functions. So going back to the SWIG_ConvertPtr() function example from above, we are expecting a Foo * and need to check if obj0 is in fact a Foo * . From before, SWIGTYPE_p_Foo is just a pointer to the swig_type_info structure describing Foo *. So we loop through the linked list of swig_cast_info structures attached to SWIGTYPE_p_Foo. If we see that the type of obj0 is in the linked list, we pass the object through the associated conversion function and then return a positive. If we reach the end of the linked list without a match, then obj0 can not be converted to a Foo * and an error is generated.

Another issue needing to be addressed is sharing type information between multiple modules. More explicitly, we need to have ONE swig_type_info for each type. If two modules both use the type, the second module loaded must lookup and use the swig_type_info structure from the module already loaded. Because no dynamic memory is used and the circular dependencies of the casting information, loading the type information is somewhat tricky, and not explained here. A complete description is in the Lib/swiginit.swg file (and near the top of any generated file).

Each module has one swig_module_info structure which looks like this:

/* Structure used to store module information
 * Each module generates one structure like this, and the runtime collects
 * all of these structures and stores them in a circularly linked list.*/
typedef struct swig_module_info {
  swig_type_info **types;         /* Array of pointers to swig_type_info structs in this module */
  int size;                       /* Number of types in this module */
  struct swig_module_info *next;  /* Pointer to next element in circularly linked list */
  swig_type_info **type_initial;  /* Array of initially generated type structures */
  swig_cast_info **cast_initial;  /* Array of initially generated casting structures */
  void *clientdata;               /* Language specific module data */
} swig_module_info;

Each module stores an array of pointers to swig_type_info structures and the number of types in this module. So when a second module is loaded, it finds the swig_module_info structure for the first module and searches the array of types. If any of its own types are in the first module and have already been loaded, it uses those swig_type_info structures rather than creating new ones. These swig_module_info structures are chained together in a circularly linked list.

11.12.2 Usage

This section covers how to use these functions from typemaps. To learn how to call these functions from external files (not the generated _wrap.c file), see the External access to the run-time system section.

When pointers are converted in a typemap, the typemap code often looks similar to this:

%typemap(in) Foo * {
  if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor)) == -1) return NULL;
}

The most critical part is the typemap is the use of the $1_descriptor special variable. When placed in a typemap, this is expanded into the SWIGTYPE_* type descriptor object above. As a general rule, you should always use $1_descriptor instead of trying to hard-code the type descriptor name directly.

There is another reason why you should always use the $1_descriptor variable. When this special variable is expanded, SWIG marks the corresponding type as "in use." When type-tables and type information is emitted in the wrapper file, descriptor information is only generated for those datatypes that were actually used in the interface. This greatly reduces the size of the type tables and improves efficiency.

Occasionally, you might need to write a typemap that needs to convert pointers of other types. To handle this, the special variable macro $descriptor(type) covered earlier can be used to generate the SWIG type descriptor name for any C datatype. For example:

%typemap(in) Foo * {
  if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor)) == -1) {
     Bar *temp;
     if ((SWIG_ConvertPtr($input, (void **) &temp, $descriptor(Bar *)) == -1) {
         return NULL;
     }
     $1 = (Foo *) temp;
  }
}

The primary use of $descriptor(type) is when writing typemaps for container objects and other complex data structures. There are some restrictions on the argument---namely it must be a fully defined C datatype. It can not be any of the special typemap variables.

In certain cases, SWIG may not generate type-descriptors like you expect. For example, if you are converting pointers in some non-standard way or working with an unusual combination of interface files and modules, you may find that SWIG omits information for a specific type descriptor. To fix this, you may need to use the %types directive. For example:

%types(int *, short *, long *, float *, double *);

When %types is used, SWIG generates type-descriptor information even if those datatypes never appear elsewhere in the interface file.

Further details about the run-time type checking can be found in the documentation for individual language modules. Reading the source code may also help. The file Lib/swigrun.swg in the SWIG library contains all of the source of the generated code for type-checking. This code is also included in every generated wrapped file so you probably just look at the output of SWIG to get a better sense for how types are managed.

11.13 Typemaps and overloading

This section does not apply to the statically typed languages like Java and C#, where overloading of the types is handled much like C++ by generating overloaded methods in the target language. In many of the other target languages, SWIG still fully supports C++ overloaded methods and functions. For example, if you have a collection of functions like this:

int foo(int x);
int foo(double x);
int foo(char *s, int y);

You can access the functions in a normal way from the scripting interpreter:

# Python
foo(3)           # foo(int)
foo(3.5)         # foo(double)
foo("hello",5)   # foo(char *, int)

# Tcl
foo 3            # foo(int)
foo 3.5          # foo(double)
foo hello 5      # foo(char *, int)

To implement overloading, SWIG generates a separate wrapper function for each overloaded method. For example, the above functions would produce something roughly like this:

// wrapper pseudocode
_wrap_foo_0(argc, args[]) {       // foo(int)
   int arg1;
   int result;
   ...
   arg1 = FromInteger(args[0]);
   result = foo(arg1);
   return ToInteger(result);
}

_wrap_foo_1(argc, args[]) {       // foo(double)
   double arg1;
   int result;
   ...
   arg1 = FromDouble(args[0]);
   result = foo(arg1);
   return ToInteger(result);
}

_wrap_foo_2(argc, args[]) {       // foo(char *, int)
   char *arg1;
   int   arg2;
   int result;
   ...
   arg1 = FromString(args[0]);
   arg2 = FromInteger(args[1]);
   result = foo(arg1,arg2);
   return ToInteger(result);
}

Next, a dynamic dispatch function is generated:

_wrap_foo(argc, args[]) {
   if (argc == 1) {
       if (IsInteger(args[0])) {
           return _wrap_foo_0(argc,args);
       } 
       if (IsDouble(args[0])) {
           return _wrap_foo_1(argc,args);
       }
   }
   if (argc == 2) {
       if (IsString(args[0]) && IsInteger(args[1])) {
          return _wrap_foo_2(argc,args);
       }
   }
   error("No matching function!\n");
}

The purpose of the dynamic dispatch function is to select the appropriate C++ function based on argument types---a task that must be performed at runtime in most of SWIG's target languages.

The generation of the dynamic dispatch function is a relatively tricky affair. Not only must input typemaps be taken into account (these typemaps can radically change the types of arguments accepted), but overloaded methods must also be sorted and checked in a very specific order to resolve potential ambiguity. A high-level overview of this ranking process is found in the "SWIG and C++ " chapter. What isn't mentioned in that chapter is the mechanism by which it is implemented---as a collection of typemaps.

To support dynamic dispatch, SWIG first defines a general purpose type hierarchy as follows:

Symbolic Name                   Precedence Value
------------------------------  ------------------
SWIG_TYPECHECK_POINTER           0  
SWIG_TYPECHECK_VOIDPTR           10 
SWIG_TYPECHECK_BOOL              15 
SWIG_TYPECHECK_UINT8             20 
SWIG_TYPECHECK_INT8              25 
SWIG_TYPECHECK_UINT16            30 
SWIG_TYPECHECK_INT16             35 
SWIG_TYPECHECK_UINT32            40 
SWIG_TYPECHECK_INT32             45 
SWIG_TYPECHECK_UINT64            50 
SWIG_TYPECHECK_INT64             55 
SWIG_TYPECHECK_UINT128           60 
SWIG_TYPECHECK_INT128            65 
SWIG_TYPECHECK_INTEGER           70 
SWIG_TYPECHECK_FLOAT             80 
SWIG_TYPECHECK_DOUBLE            90 
SWIG_TYPECHECK_COMPLEX           100 
SWIG_TYPECHECK_UNICHAR           110 
SWIG_TYPECHECK_UNISTRING         120 
SWIG_TYPECHECK_CHAR              130 
SWIG_TYPECHECK_STRING            140 
SWIG_TYPECHECK_BOOL_ARRAY        1015 
SWIG_TYPECHECK_INT8_ARRAY        1025 
SWIG_TYPECHECK_INT16_ARRAY       1035 
SWIG_TYPECHECK_INT32_ARRAY       1045 
SWIG_TYPECHECK_INT64_ARRAY       1055 
SWIG_TYPECHECK_INT128_ARRAY      1065 
SWIG_TYPECHECK_FLOAT_ARRAY       1080 
SWIG_TYPECHECK_DOUBLE_ARRAY      1090 
SWIG_TYPECHECK_CHAR_ARRAY        1130 
SWIG_TYPECHECK_STRING_ARRAY      1140 

(These precedence levels are defined in swig.swg, a library file that's included by all target language modules.)

In this table, the precedence-level determines the order in which types are going to be checked. Low values are always checked before higher values. For example, integers are checked before floats, single values are checked before arrays, and so forth.

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:

/* Python type checking rules */
/* Note:  %typecheck(X) is a macro for %typemap(typecheck,precedence=X) */

%typecheck(SWIG_TYPECHECK_INTEGER)
	 int, short, long,
 	 unsigned int, unsigned short, unsigned long,
	 signed char, unsigned char,
	 long long, unsigned long long,
	 const int &, const short &, const long &,
 	 const unsigned int &, const unsigned short &, const unsigned long &,
	 const long long &, const unsigned long long &,
	 enum SWIGTYPE,
         bool, const bool & 
{
  $1 = (PyInt_Check($input) || PyLong_Check($input)) ? 1 : 0;
}

%typecheck(SWIG_TYPECHECK_DOUBLE)
	float, double,
	const float &, const double &
{
  $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) ? 1 : 0;
}

%typecheck(SWIG_TYPECHECK_CHAR) char {
  $1 = (PyString_Check($input) && (PyString_Size($input) == 1)) ? 1 : 0;
}

%typecheck(SWIG_TYPECHECK_STRING) char * {
  $1 = PyString_Check($input) ? 1 : 0;
}

%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
  void *ptr;
  if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0) == -1) {
    $1 = 0;
    PyErr_Clear();
  } else {
    $1 = 1;
  }
}

%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
  void *ptr;
  if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0) == -1) {
    $1 = 0;
    PyErr_Clear();
  } else {
    $1 = 1;
  }
}

%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
  void *ptr;
  if (SWIG_ConvertPtr($input, (void **) &ptr, 0, 0) == -1) {
    $1 = 0;
    PyErr_Clear();
  } else {
    $1 = 1;
  }
}

%typecheck(SWIG_TYPECHECK_POINTER) PyObject *
{
  $1 = ($input != 0);
}

It might take a bit of contemplation, but this code has merely organized all of the basic C++ types, provided some simple type-checking code, and assigned each type a precedence value.

Finally, to generate the dynamic dispatch function, SWIG uses the following algorithm:

  • Overloaded methods are first sorted by the number of required arguments.
  • Methods with the same number of arguments are then sorted by precedence values of argument types.
  • Typecheck typemaps are then emitted to produce a dispatch function that checks arguments in the correct order.

If you haven't written any typemaps of your own, it is unnecessary to worry about the typechecking rules. However, if you have written new input typemaps, you might have to supply a typechecking rule as well. An easy way to do this is to simply copy one of the existing typechecking rules. Here is an example,

// Typemap for a C++ string
%typemap(in) std::string {
    if (PyString_Check($input)) {
         $1 = std::string(PyString_AsString($input));
     } else {
         SWIG_exception(SWIG_TypeError, "string expected");
     }
}
// Copy the typecheck code for "char *".  
%typemap(typecheck) std::string = char *;

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.

Notes:

  • Typecheck typemaps are not used for non-overloaded methods. Because of this, it is still always necessary to check types in any "in" typemaps.
  • The dynamic dispatch process is only meant to be a heuristic. There are many corner cases where SWIG simply can't disambiguate types to the same degree as C++. The only way to resolve this ambiguity is to use the %rename directive to rename one of the overloaded methods (effectively eliminating overloading).
  • Typechecking may be partial. For example, if working with arrays, the typecheck code might simply check the type of the first array element and use that to dispatch to the correct function. Subsequent "in" typemaps would then perform more extensive type-checking.
  • Make sure you read the section on overloading in the " SWIG and C++" chapter.

11.14 More about %apply and %clear

In order to implement certain kinds of program behavior, it is sometimes necessary to write sets of typemaps. For example, to support output arguments, one often writes a set of typemaps like this:

%typemap(in,numinputs=0) int *OUTPUT (int temp) {
   $1 = &temp;
}
%typemap(argout) int *OUTPUT {
   // return value somehow
}

To make it easier to apply the typemap to different argument types and names, the %apply directive performs a copy of all typemaps from one type to another. For example, if you specify this,

%apply int *OUTPUT { int *retvalue, int32 *output };

then all of the int *OUTPUT typemaps are copied to int *retvalue and int32 *output.

However, there is a subtle aspect of %apply that needs more description. Namely, %apply does not overwrite a typemap rule if it is already defined for the target datatype. This behavior allows you to do two things:

  • You can specialize parts of a complex typemap rule by first defining a few typemaps and then using %apply to incorporate the remaining pieces.
  • Sets of different typemaps can be applied to the same datatype using repeated %apply directives.

For example:

%typemap(in) int *INPUT (int temp) {
   temp = ... get value from $input ...;
   $1 = &temp;
}

%typemap(check) int *POSITIVE {
   if (*$1 <= 0) {
      SWIG_exception(SWIG_ValueError,"Expected a positive number!\n");
      return NULL;
   }
}

...
%apply int *INPUT     { int *invalue };
%apply int *POSITIVE  { int *invalue };

Since %apply does not overwrite or replace any existing rules, the only way to reset behavior is to use the %clear directive. %clear removes all typemap rules defined for a specific datatype. For example:

%clear int *invalue;

11.15 Passing data between typemaps

It is also important to note that the primary use of local variables is to create stack-allocated objects for temporary use inside a wrapper function (this is faster and less-prone to error than allocating data on the heap). In general, the variables are not intended to pass information between different types of typemaps. However, this can be done if you realize that local names have the argument number appended to them. For example, you could do this:

%typemap(in) int *(int temp) {
   temp = (int) PyInt_AsLong($input);
   $1 = &temp;
}

%typemap(argout) int * {
   PyObject *o = PyInt_FromLong(temp$argnum);
   ...
}

In this case, the $argnum variable is expanded into the argument number. Therefore, the code will reference the appropriate local such as temp1 and temp2. It should be noted that there are plenty of opportunities to break the universe here and that accessing locals in this manner should probably be avoided. At the very least, you should make sure that the typemaps sharing information have exactly the same types and names.

11.16 C++ "this" pointer

All the rules discussed for typemaps apply to C++ as well as C. However in addition C++ passes an extra parameter into every non-static class method -- the this pointer. Occasionally it can be useful to apply a typemap to this pointer (for example to check and make sure this is non-null before deferencing). Actually, C also has an the equivalent of the this pointer which is used when accessing variables in a C struct.

In order to customise the this pointer handling, target a variable named self in your typemaps. self is the name SWIG uses to refer to the extra parameter in wrapped functions.

For example, if wrapping for Java generation:

%typemap(check) SWIGTYPE *self %{
if (!$1) {
  SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException,
    "invalid native object; delete() likely already called");
  return $null;
}
%}

In the above case, the $1 variable is expanded into the argument name that SWIG is using as the this pointer. SWIG will then insert the check code before the actual C++ class method is called, and will raise an exception rather than crash the Java virtual machine. The generated code will look something like:

  if (!arg1) {
    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException,
      "invalid native object; delete() likely already called");
    return ;
  }
  (arg1)->wrappedFunction(...);

Note that if you have a parameter named self then it will also match the typemap. One work around is to create an interface file that wraps the method, but gives the argument a name other than self.

11.17 Where to go for more information?

The best place to find out more information about writing typemaps is to look in the SWIG library. Most language modules define all of their default behavior using typemaps. These are found in files such as python.swg, perl5.swg, tcl8.swg and so forth. The typemaps.i file in the library also contains numerous examples. You should look at these files to get a feel for how to define typemaps of your own. Some of the language modules support additional typemaps and further information is available in the individual chapters for each target language. There you may also find more hands-on practical examples.


12 Customization Features

In many cases, it is desirable to change the default wrapping of particular declarations in an interface. For example, you might want to provide hooks for catching C++ exceptions, add assertions, or provide hints to the underlying code generator. This chapter describes some of these customization techniques. First, a discussion of exception handling is presented. Then, a more general-purpose customization mechanism known as "features" is described.

12.1 Exception handling with %exception

The %exception directive allows you to define a general purpose exception handler. For example, you can specify the following:

%exception {
    try {
        $action
    }
    catch (RangeError) {
        ... handle error ...
    }
}

How the exception is handled depends on the target language, for example, Python:

%exception {
    try {
        $action
    }
    catch (RangeError) {
        PyErr_SetString(PyExc_IndexError,"index out-of-bounds");
        SWIG_fail;
    }
}

When defined, the code enclosed in braces is inserted directly into the low-level wrapper functions. The special variable $action is one of a few %exception special variables supported and gets replaced with the actual operation to be performed (a function call, method invocation, attribute access, etc.). An exception handler remains in effect until it is explicitly deleted. This is done by using either %exception or %noexception with no code. For example:

%exception;   // Deletes any previously defined handler

Compatibility note: Previous versions of SWIG used a special directive %except for exception handling. That directive is deprecated--%exception provides the same functionality, but is substantially more flexible.

12.1.1 Handling exceptions in C code

C has no formal exception handling mechanism so there are several approaches that might be used. A somewhat common technique is to simply set a special error code. For example:

/* File : except.c */

static char error_message[256];
static int error_status = 0;

void throw_exception(char *msg) {
	strncpy(error_message,msg,256);
	error_status = 1;
}

void clear_exception() {
	error_status = 0;
}
char *check_exception() {
	if (error_status) return error_message;
	else return NULL;
}

To use these functions, functions simply call throw_exception() to indicate an error occurred. For example :

double inv(double x) {
	if (x != 0) return 1.0/x;
	else {
		throw_exception("Division by zero");
		return 0;
	}
}

To catch the exception, you can write a simple exception handler such as the following (shown for Perl5) :

%exception {
    char *err;
    clear_exception();
    $action
    if ((err = check_exception())) {
       croak(err);
    }
}

In this case, when an error occurs, it is translated into a Perl error. Each target language has its own approach to creating a runtime error/exception in and for Perl it is the croak method shown above.

12.1.2 Exception handling with longjmp()

Exception handling can also be added to C code using the <setjmp.h> library. Here is a minimalistic implementation that relies on the C preprocessor :

/* File : except.c
   Just the declaration of a few global variables we're going to use */

#include <setjmp.h>
jmp_buf exception_buffer;
int exception_status;

/* File : except.h */
#include <setjmp.h>
extern jmp_buf exception_buffer;
extern int exception_status;

#define try if ((exception_status = setjmp(exception_buffer)) == 0)
#define catch(val) else if (exception_status == val)
#define throw(val) longjmp(exception_buffer,val)
#define finally else

/* Exception codes */

#define RangeError     1
#define DivisionByZero 2
#define OutOfMemory    3

Now, within a C program, you can do the following :

double inv(double x) {
	if (x) return 1.0/x;
	else throw(DivisionByZero);
}

Finally, to create a SWIG exception handler, write the following :

%{
#include "except.h"
%}

%exception {
	try {
		$action
	} catch(RangeError) {
		croak("Range Error");
	} catch(DivisionByZero) {
		croak("Division by zero");
	} catch(OutOfMemory) {
		croak("Out of memory");
	} finally {
		croak("Unknown exception");
	}
}

Note: This implementation is only intended to illustrate the general idea. To make it work better, you'll need to modify it to handle nested try declarations.

12.1.3 Handling C++ exceptions

Handling C++ exceptions is also straightforward. For example:

%exception {
	try {
		$action
	} catch(RangeError) {
		croak("Range Error");
	} catch(DivisionByZero) {
		croak("Division by zero");
	} catch(OutOfMemory) {
		croak("Out of memory");
	} catch(...) {
		croak("Unknown exception");
	}
}

The exception types need to be declared as classes elsewhere, possibly in a header file :

class RangeError {};
class DivisionByZero {};
class OutOfMemory {};

12.1.4 Exception handlers for variables

By default all variables will ignore %exception, so it is effectively turned off for all variables wrappers. This applies to global variables, member variables and static member variables. The approach is certainly a logical one when wrapping variables in C. However, in C++, it is quite possible for an exception to be thrown while the variable is being assigned. To ensure %exception is used when wrapping variables, it needs to be 'turned on' using the %allowexception feature. Note that %allowexception is just a macro for %feature("allowexcept"), that is, it is a feature called "allowexcept". Any variable which has this feature attached to it, will then use the %exception feature, but of course, only if there is a %exception attached to the variable in the first place. The %allowexception feature works like any other feature and so can be used globally or for selective variables.

%allowexception;                // turn on globally
%allowexception Klass::MyVar;   // turn on for a specific variable

%noallowexception Klass::MyVar; // turn off for a specific variable
%noallowexception;              // turn off globally

12.1.5 Defining different exception handlers

By default, the %exception directive creates an exception handler that is used for all wrapper functions that follow it. Unless there is a well-defined (and simple) error handling mechanism in place, defining one universal exception handler may be unwieldy and result in excessive code bloat since the handler is inlined into each wrapper function.

To fix this, you can be more selective about how you use the %exception directive. One approach is to only place it around critical pieces of code. For example:

%exception {
	... your exception handler ...
}
/* Define critical operations that can throw exceptions here */

%exception;

/* Define non-critical operations that don't throw exceptions */

More precise control over exception handling can be obtained by attaching an exception handler to specific declaration name. For example:

%exception allocate {
    try {
        $action
    } 
    catch (MemoryError) {
        croak("Out of memory");
    }
}

In this case, the exception handler is only attached to declarations named "allocate". This would include both global and member functions. The names supplied to %exception follow the same rules as for %rename described in the section on Ambiguity resolution and renaming. For example, if you wanted to define an exception handler for a specific class, you might write this:

%exception Object::allocate {
    try {
        $action
    } 
    catch (MemoryError) {
        croak("Out of memory");
    }
}

When a class prefix is supplied, the exception handler is applied to the corresponding declaration in the specified class as well as for identically named functions appearing in derived classes.

%exception can even be used to pinpoint a precise declaration when overloading is used. For example:

%exception Object::allocate(int) {
    try {
        $action
    } 
    catch (MemoryError) {
        croak("Out of memory");
    }
}

Attaching exceptions to specific declarations is a good way to reduce code bloat. It can also be a useful way to attach exceptions to specific parts of a header file. For example:

%module example
%{
#include "someheader.h"
%}

// Define a few exception handlers for specific declarations
%exception Object::allocate(int) {
    try {
        $action
    } 
    catch (MemoryError) {
        croak("Out of memory");
    }
}

%exception Object::getitem {
    try {
       $action
    }
    catch (RangeError) {
       croak("Index out of range");
    }
}
...
// Read a raw header file
%include "someheader.h"

Compatibility note: The %exception directive replaces the functionality provided by the deprecated "except" typemap. The typemap would allow exceptions to be thrown in the target language based on the return type of a function and was intended to be a mechanism for pinpointing specific declarations. However, it never really worked that well and the new %exception directive is much better.

12.1.6 Special variables for %exception

The %exception directive supports a few special variables which are placeholders for code substitution. The following table shows the available special variables and details what the special variables are replaced with.

$actionThe actual operation to be performed (a function call, method invocation, variable access, etc.)
$nameThe C/C++ symbol name for the function.
$symnameThe symbol name used internally by SWIG
$overnameThe extra mangling used in the symbol name for overloaded method. Expands to nothing if the wrapped method is not overloaded.
$wrapnameThe language specific wrapper name (usually a C function name exported from the shared object/dll)
$declThe fully qualified C/C++ declaration of the method being wrapped without the return type
$fulldeclThe fully qualified C/C++ declaration of the method being wrapped including the return type
$parentnameThe parent class name (if any) for a method.
$parentsymnameThe target language parent class name (if any) for a method.

The special variables are often used in situations where method calls are logged. Exactly which form of the method call needs logging is up to individual requirements, but the example code below shows all the possible expansions, plus how an exception message could be tailored to show the C++ method declaration:

%exception Special::something {
  log("symname: $symname");
  log("overname: $overname");
  log("wrapname: $wrapname");
  log("decl: $decl");
  log("fulldecl: $fulldecl");
  try {
    $action
  } 
  catch (MemoryError) {
      croak("Out of memory in $decl");
  }
}
void log(const char *message);
struct Special {
  void something(const char *c);
  void something(int i);
};

Below shows the expansions for the 1st of the overloaded something wrapper methods for Perl:

  log("symname: Special_something");
  log("overname: __SWIG_0");
  log("wrapname: _wrap_Special_something__SWIG_0");
  log("decl: Special::something(char const *)");
  log("fulldecl: void Special::something(char const *)");
  try {
    (arg1)->something((char const *)arg2);
  } 
  catch (MemoryError) {
    croak("Out of memory in Special::something(char const *)");
  }

12.1.7 Using The SWIG exception library

The exception.i library file provides support for creating language independent exceptions in your interfaces. To use it, simply put an "%include exception.i" in your interface file. This creates a function SWIG_exception() that can be used to raise common scripting language exceptions in a portable manner. For example :

// Language independent exception handler
%include exception.i       

%exception {
    try {
        $action
    } catch(RangeError) {
        SWIG_exception(SWIG_ValueError, "Range Error");
    } catch(DivisionByZero) {
        SWIG_exception(SWIG_DivisionByZero, "Division by zero");
    } catch(OutOfMemory) {
        SWIG_exception(SWIG_MemoryError, "Out of memory");
    } catch(...) {
        SWIG_exception(SWIG_RuntimeError,"Unknown exception");
    }
}

As arguments, SWIG_exception() takes an error type code (an integer) and an error message string. The currently supported error types are :

SWIG_UnknownError
SWIG_IOError
SWIG_RuntimeError
SWIG_IndexError
SWIG_TypeError
SWIG_DivisionByZero
SWIG_OverflowError
SWIG_SyntaxError
SWIG_ValueError
SWIG_SystemError
SWIG_AttributeError
SWIG_MemoryError
SWIG_NullReferenceError

The SWIG_exception() function can also be used in typemaps.

12.2 Object ownership and %newobject

A common problem in some applications is managing proper ownership of objects. For example, consider a function like this:

Foo *blah() {
   Foo *f = new Foo();
   return f;
}

If you wrap the function blah(), SWIG has no idea that the return value is a newly allocated object. As a result, the resulting extension module may produce a memory leak (SWIG is conservative and will never delete objects unless it knows for certain that the returned object was newly created).

To fix this, you can provide an extra hint to the code generator using the %newobject directive. For example:

%newobject blah;
Foo *blah();

%newobject works exactly like %rename and %exception. In other words, you can attach it to class members and parameterized declarations as before. For example:

%newobject ::blah();                   // Only applies to global blah
%newobject Object::blah(int,double);   // Only blah(int,double) in Object
%newobject *::copy;                    // Copy method in all classes
...

When %newobject is supplied, many language modules will arrange to take ownership of the return value. This allows the value to be automatically garbage-collected when it is no longer in use. However, this depends entirely on the target language (a language module may also choose to ignore the %newobject directive).

Closely related to %newobject is a special typemap. The "newfree" typemap can be used to deallocate a newly allocated return value. It is only available on methods for which %newobject has been applied and is commonly used to clean-up string results. For example:

%typemap(newfree) char * "free($1);";
...
%newobject strdup;
...
char *strdup(const char *s);

In this case, the result of the function is a string in the target language. Since this string is a copy of the original result, the data returned by strdup() is no longer needed. The "newfree" typemap in the example simply releases this memory.

As a complement to the %newobject, from SWIG 1.3.28, you can use the %delobject directive. For example, if you have two methods, one to create objects and one to destroy them, you can use:

%newobject create_foo;
%delobject destroy_foo;
...
Foo *create_foo();
void destroy_foo(Foo *foo);

or in a member method as:

%delobject Foo::destroy;

class Foo {
public:
  void destroy() { delete this;}

private:
  ~Foo();
};

%delobject instructs SWIG that the first argument passed to the method will be destroyed, and therefore, the target language should not attempt to deallocate it twice. This is similar to use the DISOWN typemap in the first method argument, and in fact, it also depends on the target language on implementing the 'disown' mechanism properly.

The use of %newobject is also integrated with reference counting and is covered in the C++ reference counted objects section.

Compatibility note: Previous versions of SWIG had a special %new directive. However, unlike %newobject, it only applied to the next declaration. For example:

%new char *strdup(const char *s);

For now this is still supported but is deprecated.

How to shoot yourself in the foot: The %newobject directive is not a declaration modifier like the old %new directive. Don't write code like this:

%newobject
char *strdup(const char *s);

The results might not be what you expect.

12.3 Features and the %feature directive

Both %exception and %newobject are examples of a more general purpose customization mechanism known as "features." A feature is simply a user-definable property that is attached to specific declarations. Features are attached using the %feature directive. For example:

%feature("except") Object::allocate {
    try {
        $action
    } 
    catch (MemoryError) {
        croak("Out of memory");
    }
}

%feature("new","1") *::copy;

In fact, the %exception and %newobject directives are really nothing more than macros involving %feature:

#define %exception %feature("except")
#define %newobject %feature("new","1")

The name matching rules outlined in the Ambiguity resolution and renaming section applies to all %feature directives. In fact the %rename directive is just a special form of %feature. The matching rules mean that features are very flexible and can be applied with pinpoint accuracy to specific declarations if needed. Additionally, if no declaration name is given, a global feature is said to be defined. This feature is then attached to every declaration that follows. This is how global exception handlers are defined. For example:

/* Define a global exception handler */
%feature("except") {
   try {
     $action
   }
   ...
}

... bunch of declarations ...

The %feature directive can be used with different syntax. The following are all equivalent:

%feature("except") Object::method { $action };
%feature("except") Object::method %{ $action %};
%feature("except") Object::method " $action ";
%feature("except","$action") Object::method;

The syntax in the first variation will generate the { } delimiters used whereas the other variations will not.

12.3.1 Feature attributes

The %feature directive also accepts XML style attributes in the same way that typemaps do. Any number of attributes can be specified. The following is the generic syntax for features:

%feature("name","value", attribute1="AttributeValue1") symbol;
%feature("name", attribute1="AttributeValue1") symbol {value};
%feature("name", attribute1="AttributeValue1") symbol %{value%};
%feature("name", attribute1="AttributeValue1") symbol "value";

More than one attribute can be specified using a comma separated list. The Java module is an example that uses attributes in %feature("except"). The throws attribute specifies the name of a Java class to add to a proxy method's throws clause. In the following example, MyExceptionClass is the name of the Java class for adding to the throws clause.

%feature("except", throws="MyExceptionClass") Object::method { 
   try {
     $action
   } catch (...) {
     ... code to throw a MyExceptionClass Java exception ...
   }
};

Further details can be obtained from the Java exception handling section.

12.3.2 Feature flags

Feature flags are used to enable or disable a particular feature. Feature flags are a common but simple usage of %feature and the feature value should be either 1 to enable or 0 to disable the feature.

%feature("featurename")          // enables feature
%feature("featurename", "1")     // enables feature
%feature("featurename", "x")     // enables feature
%feature("featurename", "0")     // disables feature
%feature("featurename", "")      // clears feature

Actually any value other than zero will enable the feature. Note that if the value is omitted completely, the default value becomes 1, thereby enabling the feature. A feature is cleared by specifying no value, see Clearing features. The %immutable directive described in the Creating read-only variables section, is just a macro for %feature("immutable"), and can be used to demonstrates feature flags:

                                // features are disabled by default
int red;                        // mutable

%feature("immutable");          // global enable
int orange;                     // immutable

%feature("immutable","0");      // global disable
int yellow;                     // mutable

%feature("immutable","1");      // another form of global enable
int green;                      // immutable

%feature("immutable","");       // clears the global feature
int blue;                       // mutable

Note that features are disabled by default and must be explicitly enabled either globally or by specifying a targeted declaration. The above intersperses SWIG directives with C code. Of course you can target features explicitly, so the above could also be rewritten as:

%feature("immutable","1") orange;
%feature("immutable","1") green;
int red;                        // mutable
int orange;                     // immutable
int yellow;                     // mutable
int green;                      // immutable
int blue;                       // mutable

The above approach allows for the C declarations to be separated from the SWIG directives for when the C declarations are parsed from a C header file. The logic above can of course be inverted and rewritten as:

%feature("immutable","1");
%feature("immutable","0") red;
%feature("immutable","0") yellow;
%feature("immutable","0") blue;
int red;                        // mutable
int orange;                     // immutable
int yellow;                     // mutable
int green;                      // immutable
int blue;                       // mutable

As hinted above for %immutable, most feature flags can also be specified via alternative syntax. The alternative syntax is just a macro in the swig.swg Library file. The following shows the alternative syntax for the imaginary featurename feature:

%featurename       // equivalent to %feature("featurename", "1") ie enables feature
%nofeaturename     // equivalent to %feature("featurename", "0") ie disables feature
%clearfeaturename  // equivalent to %feature("featurename", "")  ie clears feature

The concept of clearing features is discussed next.

12.3.3 Clearing features

A feature stays in effect until it is explicitly cleared. A feature is cleared by supplying a %feature directive with no value. For example %feature("name",""). A cleared feature means that any feature exactly matching any previously defined feature is no longer used in the name matching rules. So if a feature is cleared, it might mean that another name matching rule will apply. To clarify, let's consider the except feature again (%exception):

// Define global exception handler
%feature("except") {
    try {
        $action
    } catch (...) {
        croak("Unknown C++ exception");
    }
}

// Define exception handler for all clone methods to log the method calls
%feature("except") *::clone() {
    try {
        logger.info("$action");
        $action
    } catch (...) {
        croak("Unknown C++ exception");
    }
}

... initial set of class declarations with clone methods ...

// clear the previously defined feature
%feature("except","") *::clone();

... final set of class declarations with clone methods ...

In the above scenario, the initial set of clone methods will log all method invocations from the target language. This specific feature is cleared for the final set of clone methods. However, these clone methods will still have an exception handler (without logging) as the next best feature match for them is the global exception handler.

Note that clearing a feature is not always the same as disabling it. Clearing the feature above with %feature("except","") *::clone() is not the same as specifying %feature("except","0") *::clone() . The former will disable the feature for clone methods - the feature is still a better match than the global feature. If on the other hand, no global exception handler had been defined at all, then clearing the feature would be the same as disabling it as no other feature would have matched.

Note that the feature must match exactly for it to be cleared by any previously defined feature. For example the following attempt to clear the initial feature will not work:

%feature("except") clone() { logger.info("$action"); $action }
%feature("except","") *::clone();

but this will:

%feature("except") clone() { logger.info("$action"); $action }
%feature("except","") clone();

SWIG provides macros for disabling and clearing features. Many of these can be found in the swig.swg library file. The typical pattern is to define three macros; one to define the feature itself, one to disable the feature and one to clear the feature. The three macros below show this for the "except" feature:

#define %exception      %feature("except")
#define %noexception    %feature("except","0")
#define %clearexception %feature("except","")

12.3.4 Features and default arguments

SWIG treats methods with default arguments as separate overloaded methods as detailed in the default arguments section. Any %feature targeting a method with default arguments will apply to all the extra overloaded methods that SWIG generates if the default arguments are specified in the feature. If the default arguments are not specified in the feature, then the feature will match that exact wrapper method only and not the extra overloaded methods that SWIG generates. For example:

%feature("except") void hello(int i=0, double d=0.0) { ... }
void hello(int i=0, double d=0.0);

will apply the feature to all three wrapper methods, that is:

void hello(int i, double d);
void hello(int i);
void hello();

If the default arguments are not specified in the feature:

%feature("except") void hello(int i, double d) { ... }
void hello(int i=0, double d=0.0);

then the feature will only apply to this wrapper method:

void hello(int i, double d);

and not these wrapper methods:

void hello(int i);
void hello();

If compactdefaultargs are being used, then the difference between specifying or not specifying default arguments in a feature is not applicable as just one wrapper is generated.

Compatibility note: The different behaviour of features specified with or without default arguments was introduced in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.

12.3.5 Feature example

As has been shown earlier, the intended use for the %feature directive is as a highly flexible customization mechanism that can be used to annotate declarations with additional information for use by specific target language modules. Another example is in the Python module. You might use %feature to rewrite proxy/shadow class code as follows:

%module example
%rename(bar_id) bar(int,double);

// Rewrite bar() to allow some nice overloading

%feature("shadow") Foo::bar(int) %{
def bar(*args):
    if len(args) == 3:
         return apply(examplec.Foo_bar_id,args)
    return apply(examplec.Foo_bar,args)
%}
    
class Foo {
public:
    int bar(int x);
    int bar(int x, double y);
}

Further details of %feature usage is described in the documentation for specific language modules.


13 Contracts

A common problem that arises when wrapping C libraries is that of maintaining reliability and checking for errors. The fact of the matter is that many C programs are notorious for not providing error checks. Not only that, when you expose the internals of an application as a library, it often becomes possible to crash it simply by providing bad inputs or using it in a way that wasn't intended.

This chapter describes SWIG's support for software contracts. In the context of SWIG, a contract can be viewed as a runtime constraint that is attached to a declaration. For example, you can easily attach argument checking rules, check the output values of a function and more. When one of the rules is violated by a script, a runtime exception is generated rather than having the program continue to execute.

13.1 The %contract directive

Contracts are added to a declaration using the %contract directive. Here is a simple example:

%contract sqrt(double x) {
require:
    x >= 0;
ensure:
    sqrt >= 0;
}

...
double sqrt(double);

In this case, a contract is being added to the sqrt() function. The %contract directive must always appear before the declaration in question. Within the contract there are two sections, both of which are optional. The require: section specifies conditions that must hold before the function is called. Typically, this is used to check argument values. The ensure: section specifies conditions that must hold after the function is called. This is often used to check return values or the state of the program. In both cases, the conditions that must hold must be specified as boolean expressions.

In the above example, we're simply making sure that sqrt() returns a non-negative number (if it didn't, then it would be broken in some way).

Once a contract has been specified, it modifies the behavior of the resulting module. For example:

>>> example.sqrt(2)
1.4142135623730951
>>> example.sqrt(-2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
RuntimeError: Contract violation: require: (arg1>=0)
>>>

13.2 %contract and classes

The %contract directive can also be applied to class methods and constructors. For example:

%contract Foo::bar(int x, int y) {
require:
   x > 0;
ensure:
   bar > 0;
}

%contract Foo::Foo(int a) {
require:
   a > 0;
}

class Foo {
public:
    Foo(int);
    int bar(int, int);
};

The way in which %contract is applied is exactly the same as the %feature directive. Thus, any contract that you specified for a base class will also be attached to inherited methods. For example:

class Spam : public Foo {
public:
   int bar(int,int);    // Gets contract defined for Foo::bar(int,int)
};

In addition to this, separate contracts can be applied to both the base class and a derived class. For example:

%contract Foo::bar(int x, int) {
require:
    x > 0;
}

%contract Spam::bar(int, int y) {
require:
    y > 0;
}

class Foo {
public:
    int bar(int,int);   // Gets Foo::bar contract.
};

class Spam : public Foo {
public:
     int bar(int,int);   // Gets Foo::bar and Spam::bar contract
};

When more than one contract is applied, the conditions specified in a "require:" section are combined together using a logical-AND operation. In other words conditions specified for the base class and conditions specified for the derived class all must hold. In the above example, this means that both the arguments to Spam::bar must be positive.

13.3 Constant aggregation and %aggregate_check

Consider an interface file that contains the following code:

#define  UP     1
#define  DOWN   2
#define  RIGHT  3
#define  LEFT   4

void move(SomeObject *, int direction, int distance);

One thing you might want to do is impose a constraint on the direction parameter to make sure it's one of a few accepted values. To do that, SWIG provides an easy to use macro %aggregate_check() that works like this:

%aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT);

This merely defines a utility function of the form

int check_direction(int x);

That checks the argument x to see if it is one of the values listed. This utility function can be used in contracts. For example:

%aggregate_check(int, check_direction, UP, DOWN, RIGHT, LEFT);

%contract move(SomeObject *, int direction, in) {
require:
     check_direction(direction);
}

#define  UP     1
#define  DOWN   2
#define  RIGHT  3
#define  LEFT   4

void move(SomeObject *, int direction, int distance);

Alternatively, it can be used in typemaps and other directives. For example:

%aggregate_check(int, check_direction, UP, DOWN, RIGHT, LEFT);

%typemap(check) int direction {
    if (!check_direction($1)) SWIG_exception(SWIG_ValueError, "Bad direction");
}

#define  UP     1
#define  DOWN   2
#define  RIGHT  3
#define  LEFT   4

void move(SomeObject *, int direction, int distance);

Regrettably, there is no automatic way to perform similar checks with enums values. Maybe in a future release.

13.4 Notes

Contract support was implemented by Songyan (Tiger) Feng and first appeared in SWIG-1.3.20.


14 Variable Length Arguments

(a.k.a, "The horror. The horror.")

This chapter describes the problem of wrapping functions that take a variable number of arguments. For instance, generating wrappers for the C printf() family of functions.

This topic is sufficiently advanced to merit its own chapter. In fact, support for varargs is an often requested feature that was first added in SWIG-1.3.12. Most other wrapper generation tools have wisely chosen to avoid this issue.

14.1 Introduction

Some C and C++ programs may include functions that accept a variable number of arguments. For example, most programmers are familiar with functions from the C library such as the following:

int printf(const char *fmt, ...)
int fprintf(FILE *, const char *fmt, ...);
int sprintf(char *s, const char *fmt, ...);

Although there is probably little practical purpose in wrapping these specific C library functions in a scripting language (what would be the point?), a library may include its own set of special functions based on a similar API. For example:

int  traceprintf(const char *fmt, ...);

In this case, you may want to have some kind of access from the target language.

Before describing the SWIG implementation, it is important to discuss the common uses of varargs that you are likely to encounter in real programs. Obviously, there are the printf() style output functions as shown. Closely related to this would be scanf() style input functions that accept a format string and a list of pointers into which return values are placed. However, variable length arguments are also sometimes used to write functions that accept a NULL-terminated list of pointers. A good example of this would be a function like this:

int execlp(const char *path, const char *arg1, ...);
...

/* Example */
execlp("ls","ls","-l",NULL);

In addition, varargs is sometimes used to fake default arguments in older C libraries. For instance, the low level open() system call is often declared as a varargs function so that it will accept two or three arguments:

int open(const char *path, int oflag, ...);
...

/* Examples */
f = open("foo", O_RDONLY);
g = open("bar", O_WRONLY | O_CREAT, 0644);

Finally, to implement a varargs function, recall that you have to use the C library functions defined in <stdarg.h>. For example:

List make_list(const char *s, ...) {
    va_list ap;
    List    x;
    ...
    va_start(ap, s);
    while (s) {
       x.append(s);
       s = va_arg(ap, const char *);
    }
    va_end(ap);
    return x;
}

14.2 The Problem

Generating wrappers for a variable length argument function presents a number of special challenges. Although C provides support for implementing functions that receive variable length arguments, there are no functions that can go in the other direction. Specifically, you can't write a function that dynamically creates a list of arguments and which invokes a varargs function on your behalf.

Although it is possible to write functions that accept the special type va_list, this is something entirely different. You can't take a va_list structure and pass it in place of the variable length arguments to another varargs function. It just doesn't work.

The reason this doesn't work has to do with the way that function calls get compiled. For example, suppose that your program has a function call like this:

printf("Hello %s. Your number is %d\n", name, num);

When the compiler looks at this, it knows that you are calling printf() with exactly three arguments. Furthermore, it knows that the number of arguments as well are their types and sizes is never going to change during program execution. Therefore, this gets turned to machine code that sets up a three-argument stack frame followed by a call to printf().

In contrast, suppose you attempted to make some kind of wrapper around printf() using code like this:

int wrap_printf(const char *fmt, ...) {
   va_list ap;
   va_start(ap,fmt);
   ...
   printf(fmt,ap);
   ...
   va_end(ap);
};

Although this code might compile, it won't do what you expect. This is because the call to printf() is compiled as a procedure call involving only two arguments. However, clearly a two-argument configuration of the call stack is completely wrong if your intent is to pass an arbitrary number of arguments to the real printf(). Needless to say, it won't work.

Unfortunately, the situation just described is exactly the problem faced by wrapper generation tools. In general, the number of passed arguments will not be known until run-time. To make matters even worse, you won't know the types and sizes of arguments until run-time as well. Needless to say, there is no obvious way to make the C compiler generate code for a function call involving an unknown number of arguments of unknown types.

In theory, it is possible to write a wrapper that does the right thing. However, this involves knowing the underlying ABI for the target platform and language as well as writing special purpose code that manually constructed the call stack before making a procedure call. Unfortunately, both of these tasks require the use of inline assembly code. Clearly, that's the kind of solution you would much rather avoid.

With this nastiness in mind, SWIG provides a number of solutions to the varargs wrapping problem. Most of these solutions are compromises that provide limited varargs support without having to resort to assembly language. However, SWIG can also support real varargs wrapping (with stack-frame manipulation) if you are willing to get hands dirty. Keep reading.

14.3 Default varargs support

When variable length arguments appear in an interface, the default behavior is to drop the variable argument list entirely, replacing them with a single NULL pointer. For example, if you had this function,

void traceprintf(const char *fmt, ...);

it would be wrapped as if it had been declared as follows:

void traceprintf(const char *fmt);

When the function is called inside the wrappers, it is called as follows:

traceprintf(arg1, NULL);

Arguably, this approach seems to defeat the whole point of variable length arguments. However, this actually provides enough support for many simple kinds of varargs functions to still be useful, however it does come with a caveat. For instance, you could make function calls like this (in Python):

>>> traceprintf("Hello World")
>>> traceprintf("Hello %s. Your number is %d\n" % (name, num))
>>> traceprintf("Your result is 90%%.")

Notice how string formatting is being done in Python instead of C. The caveat is the strings passed must be safe to use in C though. For example if name was to contain a "%" it should be double escaped in order to avoid unpredictable behaviour:

>>> traceprintf("Your result is 90%.\n")  # unpredictable behaviour
>>> traceprintf("Your result is 90%%.\n") # good

Read on for further solutions.

14.4 Argument replacement using %varargs

Instead of dropping the variable length arguments, an alternative approach is to replace (...) with a set of suitable arguments. SWIG provides a special %varargs directive that can be used to do this. For example,

%varargs(int mode = 0) open;
...
int open(const char *path, int oflags, ...);

is equivalent to this:

int open(const char *path, int oflags, int mode = 0);

In this case, %varargs is simply providing more specific information about the extra arguments that might be passed to a function. If the arguments to a varargs function are of uniform type, %varargs can also accept a numerical argument count as follows:

%varargs(3, char *str = NULL) execlp;
...
int execlp(const char *path, const char *arg, ...);

and is effectively seen as:

int execlp(const char *path, const char *arg, 
           char *str1 = NULL, 
           char *str2 = NULL, 
           char *str3 = NULL);

This would wrap execlp() as a function that accepted up to 3 optional arguments. Depending on the application, this may be more than enough for practical purposes.

The handling of default arguments can be changed via the compactdefaultargs feature. If this feature is used, for example

%feature("compactdefaultargs") execlp;
%varargs(3, char *str = NULL) execlp;
...
int execlp(const char *path, const char *arg, ...);

a call from the target language which does not provide the maximum number of arguments, such as, execlp("a", "b", "c") will generate C code which includes the missing default values, that is, execlp("a", "b", "c", NULL, NULL). If compactdefaultargs is not used, then the generated code will be execlp("a", "b", "c") . The former is useful for helping providing a sentinel to terminate the argument list. However, this is not guaranteed, for example when a user passes a non-NULL value for all the parameters. When using compactdefaultargs it is possible to guarantee the NULL sentinel is passed through the, numinputs=0 'in' typemap attribute, naming the last parameter. For example,

%feature("compactdefaultargs") execlp;
%varargs(3, char *str = NULL) execlp;
%typemap(in, numinputs=0) char *str3 ""
...
int execlp(const char *path, const char *arg, ...);

Note that str3 is the name of the last argument, as we have used %varargs with 3. Now execlp("a", "b", "c", "d", "e") will result in an error as one too many arguments has been passed, as now only 2 additional 'str' arguments can be passed with the 3rd one always using the specified default NULL.

Argument replacement is most appropriate in cases where the types of the extra arguments are uniform and the maximum number of arguments are known. Argument replacement is not as useful when working with functions that accept mixed argument types such as printf(). Providing general purpose wrappers to such functions presents special problems (covered shortly).

14.5 Varargs and typemaps

Variable length arguments may be used in typemap specifications. For example:

%typemap(in) (...) {
    // Get variable length arguments (somehow)
    ...
}

%typemap(in) (const char *fmt, ...) {
    // Multi-argument typemap
}

However, this immediately raises the question of what "type" is actually used to represent (...). For lack of a better alternative, the type of (...) is set to void *. Since there is no way to dynamically pass arguments to a varargs function (as previously described), the void * argument value is intended to serve as a place holder for storing some kind of information about the extra arguments (if any). In addition, the default behavior of SWIG is to pass the void * value as an argument to the function. Therefore, you could use the pointer to hold a valid argument value if you wanted.

To illustrate, here is a safer version of wrapping printf() in Python:

%typemap(in) (const char *fmt, ...) {
    $1 = "%s";                                /* Fix format string to %s */
    $2 = (void *) PyString_AsString($input);  /* Get string argument */
};
...
int printf(const char *fmt, ...);

In this example, the format string is implicitly set to "%s" . This prevents a program from passing a bogus format string to the extension. Then, the passed input object is decoded and placed in the void * argument defined for the (...) argument. When the actual function call is made, the underlying wrapper code will look roughly like this:

wrap_printf() {
   char *arg1;
   void *arg2;
   int   result;

   arg1 = "%s";
   arg2 = (void *) PyString_AsString(arg2obj);
   ...
   result = printf(arg1,arg2);
   ...
}

Notice how both arguments are passed to the function and it does what you would expect.

The next example illustrates a more advanced kind of varargs typemap. Disclaimer: this requires special support in the target language module and is not guaranteed to work with all SWIG modules at this time. It also starts to illustrate some of the more fundamental problems with supporting varargs in more generality.

If a typemap is defined for any form of (...), many SWIG modules will generate wrappers that accept a variable number of arguments as input and will make these arguments available in some form. The precise details of this depends on the language module being used (consult the appropriate chapter for more details). However, suppose that you wanted to create a Python wrapper for the execlp() function shown earlier. To do this using a typemap instead of using %varargs, you might first write a typemap like this:

%typemap(in) (...)(char *vargs[10]) {
  int i;
  int argc;
  for (i = 0; i < 10; i++) vargs[i] = 0;
  argc = PyTuple_Size(varargs);
  if (argc > 10) {
    PyErr_SetString(PyExc_ValueError, "Too many arguments");
    return NULL;
  }
  for (i = 0; i < argc; i++) {
    PyObject *pyobj = PyTuple_GetItem(varargs, i);
    char *str = 0;
%#if PY_VERSION_HEX>=0x03000000
    PyObject *pystr;
    if (!PyUnicode_Check(pyobj)) {
       PyErr_SetString(PyExc_ValueError, "Expected a string");
       return NULL;
    }
    pystr = PyUnicode_AsUTF8String(pyobj);
    str = strdup(PyBytes_AsString(pystr));
    Py_XDECREF(pystr);
%#else  
    if (!PyString_Check(pyobj)) {
       PyErr_SetString(PyExc_ValueError, "Expected a string");
       return NULL;
    }
    str = PyString_AsString(pyobj);
%#endif
    vargs[i] = str;
  }
  $1 = (void *)vargs;
}

%typemap(freearg) (...) {
%#if PY_VERSION_HEX>=0x03000000
  int i;
  for (i = 0; i < 10; i++) {
    free(vargs$argnum[i]);
  }
%#endif
}

In the 'in' typemap, the special variable varargs is a tuple holding all of the extra arguments passed (this is specific to the Python module). The typemap then pulls this apart and sticks the values into the array of strings args. Then, the array is assigned to $1 (recall that this is the void * variable corresponding to (...)). However, this assignment is only half of the picture----clearly this alone is not enough to make the function work. The 'freearg' typemap cleans up memory allocated in the 'in' typemap; this code is generated to be called after the execlp function is called. To patch everything up, you have to rewrite the underlying action code using the %feature directive like this:

%feature("action") execlp {
  char **vargs = (char **) arg3;
  result = execlp(arg1, arg2, vargs[0], vargs[1], vargs[2], vargs[3], vargs[4],
                  vargs[5], vargs[6], vargs[7], vargs[8], vargs[9], NULL);
}

int execlp(const char *path, const char *arg, ...);

This patches everything up and creates a function that more or less works. However, don't try explaining this to your coworkers unless you know for certain that they've had several cups of coffee. If you really want to elevate your guru status and increase your job security, continue to the next section.

14.6 Varargs wrapping with libffi

All of the previous examples have relied on features of SWIG that are portable and which don't rely upon any low-level machine-level details. In many ways, they have all dodged the real issue of variable length arguments by recasting a varargs function into some weaker variation with a fixed number of arguments of known types. In many cases, this works perfectly fine. However, if you want more generality than this, you need to bring out some bigger guns.

One way to do this is to use a special purpose library such as libffi ( http://sources.redhat.com/libffi). libffi is a library that allows you to dynamically construct call-stacks and invoke procedures in a relatively platform independent manner. Details about the library can be found in the libffi distribution and are not repeated here.

To illustrate the use of libffi, suppose that you really wanted to create a wrapper for execlp() that accepted any number of arguments. To do this, you might make a few adjustments to the previous example. For example:

/* Take an arbitrary number of extra arguments and place into an array
   of strings */

%typemap(in) (...) {
   char **argv;
   int    argc;
   int    i;

   argc = PyTuple_Size(varargs);
   argv = (char **) malloc(sizeof(char *)*(argc+1));
   for (i = 0; i < argc; i++) {
      PyObject *o = PyTuple_GetItem(varargs,i);
      if (!PyString_Check(o)) {
          PyErr_SetString(PyExc_ValueError,"Expected a string");
	  free(argv);
          return NULL;
      }
      argv[i] = PyString_AsString(o);
   }
   argv[i] = NULL;
   $1 = (void *) argv;
}

/* Rewrite the function call, using libffi */    

%feature("action") execlp {
  int       i, vc;
  ffi_cif   cif;
  ffi_type  **types;
  void      **values;
  char      **args;

  vc = PyTuple_Size(varargs);
  types  = (ffi_type **) malloc((vc+3)*sizeof(ffi_type *));
  values = (void **) malloc((vc+3)*sizeof(void *));
  args   = (char **) arg3;

  /* Set up path parameter */
  types[0] = &ffi_type_pointer;
  values[0] = &arg1;
  
  /* Set up first argument */
  types[1] = &ffi_type_pointer;
  values[1] = &arg2;

  /* Set up rest of parameters */
  for (i = 0; i <= vc; i++) {
    types[2+i] = &ffi_type_pointer;
    values[2+i] = &args[i];
  }
  if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, vc+3,
                   &ffi_type_uint, types) == FFI_OK) {
    ffi_call(&cif, (void (*)()) execlp, &result, values);
  } else {
    PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
    free(types);
    free(values);
    free(arg3);
    return NULL;
  }
  free(types);
  free(values);
  free(arg3);
}

/* Declare the function. Whew! */
int execlp(const char *path, const char *arg1, ...);

Looking at this example, you may start to wonder if SWIG is making life any easier. Given the amount of code involved, you might also wonder why you didn't just write a hand-crafted wrapper! Either that or you're wondering "why in the hell am I trying to wrap this varargs function in the first place?!?" Obviously, those are questions you'll have to answer for yourself.

As a more extreme example of libffi, here is some code that attempts to wrap printf(),

/* A wrapper for printf() using libffi */

%{
/* Structure for holding passed arguments after conversion */
  typedef struct {
    int type;
    union {
      int    ivalue;
      double dvalue;
      void   *pvalue;
    } val;
  } vtype;
  enum { VT_INT, VT_DOUBLE, VT_POINTER };
%}

%typemap(in) (const char *fmt, ...) {
  vtype *argv;
  int    argc;
  int    i;

  /* Format string */
  $1 = PyString_AsString($input);

  /* Variable length arguments */
  argc = PyTuple_Size(varargs);
  argv = (vtype *) malloc(argc*sizeof(vtype));
  for (i = 0; i < argc; i++) {
    PyObject *o = PyTuple_GetItem(varargs,i);
    if (PyInt_Check(o)) {
      argv[i].type = VT_INT;
      argv[i].val.ivalue = PyInt_AsLong(o);
    } else if (PyFloat_Check(o)) {
      argv[i].type = VT_DOUBLE;
      argv[i].val.dvalue = PyFloat_AsDouble(o);
    } else if (PyString_Check(o)) {
      argv[i].type = VT_POINTER;
      argv[i].val.pvalue = (void *) PyString_AsString(o);
    } else {
      PyErr_SetString(PyExc_ValueError,"Unsupported argument type");
      free(argv);
      return NULL;
    }
  }
  $2 = (void *) argv;
}

/* Rewrite the function call using libffi */    
%feature("action") printf {
  int       i, vc;
  ffi_cif   cif;
  ffi_type  **types;
  void      **values;
  vtype     *args;

  vc = PyTuple_Size(varargs);
  types  = (ffi_type **) malloc((vc+1)*sizeof(ffi_type *));
  values = (void **) malloc((vc+1)*sizeof(void *));
  args   = (vtype *) arg2;

  /* Set up fmt parameter */
  types[0] = &ffi_type_pointer;
  values[0] = &arg1;

  /* Set up rest of parameters */
  for (i = 0; i < vc; i++) {
    switch(args[i].type) {
    case VT_INT:
      types[1+i] = &ffi_type_uint;
      values[1+i] = &args[i].val.ivalue;
      break;
    case VT_DOUBLE:
      types[1+i] = &ffi_type_double;
      values[1+i] = &args[i].val.dvalue;
      break;
    case VT_POINTER:
      types[1+i] = &ffi_type_pointer;
      values[1+i] = &args[i].val.pvalue;
      break;
    default:
      abort();    /* Whoa! We're seriously hosed */
      break;   
    }
  }
  if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, vc+1,
                   &ffi_type_uint, types) == FFI_OK) {
    ffi_call(&cif, (void (*)()) printf, &result, values);
  } else {
    PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
    free(types);
    free(values);
    free(args);
    return NULL;
  }
  free(types);
  free(values);
  free(args);
}

/* The function */
int printf(const char *fmt, ...);

Much to your amazement, it even seems to work if you try it:

>>> import example
>>> example.printf("Grade: %s   %d/60 = %0.2f%%\n", "Dave", 47, 47.0*100/60)
Grade: Dave   47/60 = 78.33%
>>>

Of course, there are still some limitations to consider:

>>> example.printf("la de da de da %s", 42)
Segmentation fault (core dumped)

And, on this note, we leave further exploration of libffi to the reader as an exercise. Although Python has been used as an example, most of the techniques in this section can be extrapolated to other language modules with a bit of work. The only details you need to know is how the extra arguments are accessed in each target language. For example, in the Python module, we used the special varargs variable to get these arguments. Modules such as Tcl8 and Perl5 simply provide an argument number for the first extra argument. This can be used to index into an array of passed arguments to get values. Please consult the chapter on each language module for more details.

14.7 Wrapping of va_list

Closely related to variable length argument wrapping, you may encounter functions that accept a parameter of type va_list. For example:

int vprintf(const char *fmt, va_list ap);

As far as we know, there is no obvious way to wrap these functions with SWIG. This is because there is no documented way to assemble the proper va_list structure (there are no C library functions to do it and the contents of va_list are opaque). Not only that, the contents of a va_list structure are closely tied to the underlying call-stack. It's not clear that exporting a va_list would have any use or that it would work at all.

A workaround can be implemented by writing a simple varargs C wrapper and then using the techniques discussed earlier in this chapter for varargs. Below is a simple wrapper for vprintf renamed so that it can still be called as vprintf from your target language. The %varargs used in the example restricts the function to taking one string argument.

%{
int vprintf(const char *fmt, va_list ap);
%}

%varargs(const char *) my_vprintf;
%rename(vprintf) my_vprintf;

%inline %{
int my_vprintf(const char *fmt, ...) {
  va_list ap;
  int result;

  va_start(ap, fmt);
  result = vprintf(fmt, ap);
  va_end(ap);
  return result;
}
%}

14.8 C++ Issues

Wrapping of C++ member functions that accept a variable number of arguments presents a number of challenges. By far, the easiest way to handle this is to use the %varargs directive. This is portable and it fully supports classes much like the %rename directive. For example:

%varargs (10, char * = NULL) Foo::bar;

class Foo {
public:
     virtual void bar(char *arg, ...);   // gets varargs above
};

class Spam: public Foo {
public:
     virtual void bar(char *arg, ...);   // gets varargs above
};

%varargs also works with constructors, operators, and any other C++ programming construct that accepts variable arguments.

Doing anything more advanced than this is likely to involve a serious world of pain. In order to use a library like libffi, you will need to know the underlying calling conventions and details of the C++ ABI. For instance, the details of how this is passed to member functions as well as any hidden arguments that might be used to pass additional information. These details are implementation specific and may differ between compilers and even different versions of the same compiler. Also, be aware that invoking a member function is further complicated if it is a virtual method. In this case, invocation might require a table lookup to obtain the proper function address (although you might be able to obtain an address by casting a bound pointer to a pointer to function as described in the C++ ARM section 18.3.4).

If you do decide to change the underlying action code, be aware that SWIG always places the this pointer in arg1. Other arguments are placed in arg2, arg3, and so forth. For example:

%feature("action") Foo::bar {
   ...
   result = arg1->bar(arg2, arg3, etc.);
   ...
}

Given the potential to shoot yourself in the foot, it is probably easier to reconsider your design or to provide an alternative interface using a helper function than it is to create a fully general wrapper to a varargs C++ member function.

14.9 Discussion

This chapter has provided a number of techniques that can be used to address the problem of variable length argument wrapping. If you care about portability and ease of use, the %varargs directive is probably the easiest way to tackle the problem. However, using typemaps, it is possible to do some very advanced kinds of wrapping.

One point of discussion concerns the structure of the libffi examples in the previous section. Looking at that code, it is not at all clear that this is the easiest way to solve the problem. However, there are a number of subtle aspects of the solution to consider--mostly concerning the way in which the problem has been decomposed. First, the example is structured in a way that tries to maintain separation between wrapper-specific information and the declaration of the function itself. The idea here is that you might structure your interface like this:

%typemap(const char *fmt, ...) {
   ...
}
%feature("action") traceprintf {
   ...
}

/* Include some header file with traceprintf in it */
%include "someheader.h"

Second, careful scrutiny will reveal that the typemaps involving (...) have nothing whatsoever to do with the libffi library. In fact, they are generic with respect to the way in which the function is actually called. This decoupling means that it will be much easier to consider other library alternatives for making the function call. For instance, if libffi wasn't supported on a certain platform, you might be able to use something else instead. You could use conditional compilation to control this:

#ifdef USE_LIBFFI
%feature("action") printf {
   ...
}
#endif
#ifdef USE_OTHERFFI
%feature("action") printf {
...
}
#endif

Finally, even though you might be inclined to just write a hand-written wrapper for varargs functions, the techniques used in the previous section have the advantage of being compatible with all other features of SWIG such as exception handling.

As a final word, some C programmers seem to have the assumption that the wrapping of variable length argument functions is an easily solved problem. However, this section has hopefully dispelled some of these myths. All things being equal, you are better off avoiding variable length arguments if you can. If you can't avoid them, please consider some of the simple solutions first. If you can't live with a simple solution, proceed with caution. At the very least, make sure you carefully read the section "A7.3.2 Function Calls" in Kernighan and Ritchie and make sure you fully understand the parameter passing conventions used for varargs. Also, be aware of the platform dependencies and reliability issues that this will introduce. Good luck.


15 Warning Messages

15.1 Introduction

During compilation, SWIG may generate a variety of warning messages. For example:

example.i:16: Warning 501: Overloaded declaration ignored.  bar(double)
example.i:15: Warning 501: Previous declaration is bar(int)

Typically, warning messages indicate non-fatal problems with the input where the generated wrapper code will probably compile, but it may not work like you expect.

15.2 Warning message suppression

All warning messages have a numeric code that is shown in the warning message itself. To suppress the printing of a warning message, a number of techniques can be used. First, you can run SWIG with the -w command line option. For example:

% swig -python -w501 example.i
% swig -python -w501,505,401 example.i

Alternatively, warnings can be suppressed by inserting a special preprocessor pragma into the input file:

%module example
#pragma SWIG nowarn=501
#pragma SWIG nowarn=501,505,401

Finally, code-generation warnings can be disabled on a declaration by declaration basis using the %warnfilter directive. For example:

%module example
%warnfilter(501) foo;
...
int foo(int);
int foo(double);              // Silently ignored.

The %warnfilter directive has the same semantics as other declaration modifiers like %rename, %ignore and %feature, see the %feature directive section. For example, if you wanted to suppress a warning for a method in a class hierarchy, you could do this:

%warnfilter(501) Object::foo;
class Object {
public:
   int foo(int);
   int foo(double);      // Silently ignored
   ...
};

class Derived : public Object {
public:
   int foo(int);
   int foo(double);      // Silently ignored
   ...
};

Warnings can be suppressed for an entire class by supplying a class name. For example:

%warnfilter(501) Object;

class Object {
public:
   ...                      // All 501 warnings ignored in class
};

There is no option to suppress all SWIG warning messages. The warning messages are there for a reason---to tell you that something may be broken in your interface. Ignore the warning messages at your own peril.

15.3 Enabling extra warnings

Some warning messages are disabled by default and are generated only to provide additional diagnostics. These warnings can be turned on using the -Wextra option. For example:

% swig -Wextra -python example.i

To selectively turn on extra warning messages, you can use the directives and options in the previous section--simply add a "+" to all warning numbers. For example:

% swig -w+309,+452 example.i

or in your interface file use either

#pragma SWIG nowarn=+309,+452

or

%warnfilter(+309,+452) foo;

Note: selective enabling of warnings with %warnfilter overrides any global settings you might have made using -w or #pragma.

You can of course also enable all warnings and suppress a select few, for example:

% swig -Wextra -w309,452 example.i

The warnings on the right take precedence over the warnings on the left, so in the above example -Wextra adds numerous warnings including 452, but then -w309,452 overrides this and so 452 is suppressesed.

If you would like all warnings to appear, regardless of the warning filters used, then use the -Wall option. The -Wall option also turns on the extra warnings that -Wextra adds, however, it is subtely different. When -Wall is used, it also disables all other warning filters, that is, any warnings suppressed or added in %warnfilter, #pragma SWIG nowarn or the -w option.

15.4 Issuing a warning message

Warning messages can be issued from an interface file using a number of directives. The %warn directive is the most simple:

%warn "900:This is your last warning!"

All warning messages are optionally prefixed by the warning number to use. If you are generating your own warnings, make sure you don't use numbers defined in the table at the end of this section.

The %ignorewarn directive is the same as %ignore except that it issues a warning message whenever a matching declaration is found. For example:

%ignorewarn("362:operator= ignored") operator=;

Warning messages can be associated with typemaps using the warning attribute of a typemap declaration. For example:

%typemap(in, warning="901:You are really going to regret this usage of $1_type $1_name") blah * {
   ...
}

In this case, the warning message will be printed whenever the typemap is actually used and the special variables will be expanded as appropriate, for example:

example.i:23: Warning 901: You are really going to regret this usage of blah * self
example.i:24: Warning 901: You are really going to regret this usage of blah * stuff

15.5 Symbolic symbols

The swigwarn.swg file that is installed with SWIG contains symbol constants that could also be used in %warnfilter and #pragma SWIG nowarn. For example this file contains the following line:

%define SWIGWARN_TYPE_UNDEFINED_CLASS 401 %enddef

so SWIGWARN_TYPE_UNDEFINED_CLASS could be used instead of 401, for example:

#pragma SWIG nowarn=SWIGWARN_TYPE_UNDEFINED_CLASS

or

%warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Foo;

15.6 Commentary

The ability to suppress warning messages is really only provided for advanced users and is not recommended in normal use. You are advised to modify your interface to fix the problems highlighted by the warnings wherever possible instead of suppressing warnings.

Certain types of SWIG problems are errors. These usually arise due to parsing errors (bad syntax) or semantic problems for which there is no obvious recovery. There is no mechanism for suppressing error messages.

15.7 Warnings as errors

Warnings can be handled as errors by using the -Werror command line option. This will cause SWIG to exit with a non successful exit code if a warning is encountered.

15.8 Message output format

The output format for both warnings and errors can be selected for integration with your favourite IDE/editor. Editors and IDEs can usually parse error messages and if in the appropriate format will easily take you directly to the source of the error. The standard format is used by default except on Windows where the Microsoft format is used by default. These can be overridden using command line options, for example:

$ swig -python -Fstandard example.i
example.i:4: Syntax error in input.
$ swig -python -Fmicrosoft example.i
example.i(4) : Syntax error in input.

15.9 Warning number reference

15.9.1 Deprecated features (100-199)

  • 101. Deprecated %extern directive.
  • 102. Deprecated %val directive.
  • 103. Deprecated %out directive.
  • 104. Deprecated %disabledoc directive.
  • 105. Deprecated %enabledoc directive.
  • 106. Deprecated %doconly directive.
  • 107. Deprecated %style directive.
  • 108. Deprecated %localstyle directive.
  • 109. Deprecated %title directive.
  • 110. Deprecated %section directive.
  • 111. Deprecated %subsection directive.
  • 112. Deprecated %subsubsection directive.
  • 113. Deprecated %addmethods directive.
  • 114. Deprecated %readonly directive.
  • 115. Deprecated %readwrite directive.
  • 116. Deprecated %except directive.
  • 117. Deprecated %new directive.
  • 118. Deprecated %typemap(except).
  • 119. Deprecated %typemap(ignore).
  • 120. Deprecated command line option (-runtime, -noruntime).
  • 121. Deprecated %name directive.
  • 126. The 'nestedworkaround' feature is deprecated.

15.9.2 Preprocessor (200-299)

  • 201. Unable to find filename.
  • 202. Could not evaluate expression expr.
  • 203. Both includeall and importall are defined: using includeall.
  • 204. CPP #warning, "warning".
  • 205. CPP #error, "error".
  • 206. Unexpected tokens after #directive directive.

15.9.3 C/C++ Parser (300-399)

  • 301. class keyword used, but not in C++ mode.
  • 302. Identifier 'name' redefined (ignored).
  • 303. %extend defined for an undeclared class 'name '.
  • 304. Unsupported constant value (ignored).
  • 305. Bad constant value (ignored).
  • 306. 'identifier' is private in this context.
  • 307. Can't set default argument value (ignored)
  • 308. Namespace alias 'name' not allowed here. Assuming ' name'
  • 309. [private | protected] inheritance ignored.
  • 310. Template 'name' was already wrapped as 'name' (ignored)
  • 312. Unnamed nested class not currently supported (ignored).
  • 313. Unrecognized extern type "name" (ignored).
  • 314. 'identifier' is a lang keyword.
  • 315. Nothing known about 'identifier'.
  • 316. Repeated %module directive.
  • 317. Specialization of non-template 'name'.
  • 318. Instantiation of template 'name' is ambiguous, instantiation templ used, instantiation templ ignored.
  • 319. No access specifier given for base class name (ignored).
  • 320. Explicit template instantiation ignored.
  • 321. identifier conflicts with a built-in name.
  • 322. Redundant redeclaration of 'name'.
  • 323. Recursive scope inheritance of 'name'.
  • 324. Named nested template instantiations not supported. Processing as if no name was given to %template().
  • 325. Nested kind not currently supported (name ignored).
  • 326. Deprecated %extend name used - the kind name 'name ' should be used instead of the typedef name 'name'.
  • 350. operator new ignored.
  • 351. operator delete ignored.
  • 352. operator+ ignored.
  • 353. operator- ignored.
  • 354. operator* ignored.
  • 355. operator/ ignored.
  • 356. operator% ignored.
  • 357. operator^ ignored.
  • 358. operator& ignored.
  • 359. operator| ignored.
  • 360. operator~ ignored.
  • 361. operator! ignored.
  • 362. operator= ignored.
  • 363. operator< ignored.
  • 364. operator> ignored.
  • 365. operator+= ignored.
  • 366. operator-= ignored.
  • 367. operator*= ignored.
  • 368. operator/= ignored.
  • 369. operator%= ignored.
  • 370. operator^= ignored.
  • 371. operator&= ignored.
  • 372. operator|= ignored.
  • 373. operator<< ignored.
  • 374. operator>>ignored.
  • 375. operator<<= ignored.
  • 376. operator>>= ignored.
  • 377. operator== ignored.
  • 378. operator!= ignored.
  • 379. operator<= ignored.
  • 380. operator>= ignored.
  • 381. operator&& ignored.
  • 382. operator|| ignored.
  • 383. operator++ ignored.
  • 384. operator-- ignored.
  • 385. operator, ignored.
  • 386. operator-<* ignored.
  • 387. operator-< ignored.
  • 388. operator() ignored.
  • 389. operator[] ignored.
  • 390. operator+ ignored (unary).
  • 391. operator- ignored (unary).
  • 392. operator* ignored (unary).
  • 393. operator& ignored (unary).
  • 394. operator new[] ignored.
  • 395. operator delete[] ignored.

15.9.4 Types and typemaps (400-499)

  • 401. Nothing known about class 'name'. Ignored.
  • 402. Base class 'name' is incomplete.
  • 403. Class 'name' might be abstract.
  • 450. Deprecated typemap feature ($source/$target).
  • 451. Setting const char * variable may leak memory.
  • 452. Reserved
  • 453. Can't apply (pattern). No typemaps are defined.
  • 460. Unable to use type type as a function argument.
  • 461. Unable to use return type type in function name .
  • 462. Unable to set variable of type type.
  • 463. Unable to read variable of type type.
  • 464. Unsupported constant value.
  • 465. Unable to handle type type.
  • 466. Unsupported variable type type.
  • 467. Overloaded declaration not supported (no type checking rule for 'type')
  • 468. No 'throw' typemap defined for exception type type
  • 469. No or improper directorin typemap defined for type
  • 470. Thread/reentrant unsafe wrapping, consider returning by value instead.
  • 471. Unable to use return type type in director method
  • 474. Method method usage of the optimal attribute ignored in the out typemap as the following cannot be used to generate optimal code: code
  • 475. Multiple calls to method might be generated due to optimal attribute usage in the out typemap.
  • 476. Initialization using std::initializer_list.
  • 477. No directorthrows typemap defined for type

15.9.5 Code generation (500-599)

  • 501. Overloaded declaration ignored. decl. Previous declaration is decl.
  • 502. Overloaded constructor ignored. decl. Previous declaration is decl.
  • 503. Can't wrap 'identifier' unless renamed to a valid identifier.
  • 504. Function name must have a return type. Ignored.
  • 505. Variable length arguments discarded.
  • 506. Can't wrap varargs with keyword arguments enabled.
  • 507. Adding native function name not supported (ignored).
  • 508. Declaration of 'name' shadows declaration accessible via operator->(), previous declaration of'declaration'.
  • 509. Overloaded method declaration effectively ignored, as it is shadowed by declaration.
  • 510. Friend function 'name' ignored.
  • 511. Can't use keyword arguments with overloaded functions.
  • 512. Overloaded method declaration ignored, using non-const method declaration instead.
  • 513. Can't generate wrappers for unnamed struct/class.
  • 514.
  • 515.
  • 516. Overloaded method declaration ignored, using declaration instead.
  • 517.
  • 518. Portability warning: File file1 will be overwritten by file2 on case insensitive filesystems such as Windows' FAT32 and NTFS unless the class/module name is renamed.
  • 519. %template() contains no name. Template method ignored: declaration
  • 520. Base/Derived class 'classname1' of ' classname2' is not similarly marked as a smart pointer.
  • 521. Illegal destructor name name. Ignored.
  • 522. Use of an illegal constructor name 'name' in %extend is deprecated, the constructor name should be 'name'.
  • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'.

15.9.6 Language module specific (700-899)

  • 801. Wrong name (corrected to 'name'). (Ruby).
  • 810. No jni typemap defined for type (Java).
  • 811. No jtype typemap defined for type (Java).
  • 812. No jstype typemap defined for type (Java).
  • 813. Warning for classname: Base baseclass ignored. Multiple inheritance is not supported in Java. (Java).
  • 814.
  • 815. No javafinalize typemap defined for type (Java).
  • 816. No javabody typemap defined for type (Java).
  • 817. No javaout typemap defined for type (Java).
  • 818. No javain typemap defined for type (Java).
  • 819. No javadirectorin typemap defined for type (Java).
  • 820. No javadirectorout typemap defined for type (Java).
  • 821.
  • 822. Covariant return types not supported in Java. Proxy method will return basetype (Java).
  • 823. No javaconstruct typemap defined for type (Java).
  • 824. Missing JNI descriptor in directorin typemap defined for type (Java).
  • 825. "directorconnect" attribute missing in type "javaconstruct" typemap. (Java).
  • 826. The nspace feature is used on 'type' without -package. The generated code may not compile as Java does not support types declared in a named package accessing types declared in an unnamed package. (Java).
  • 830. No ctype typemap defined for type (C#).
  • 831. No cstype typemap defined for type (C#).
  • 832. No cswtype typemap defined for type (C#).
  • 833. Warning for classname: Base baseclass ignored. Multiple inheritance is not supported in C#. (C#).
  • 834.
  • 835. No csfinalize typemap defined for type (C#).
  • 836. No csbody typemap defined for type (C#).
  • 837. No csout typemap defined for type (C#).
  • 838. No csin typemap defined for type (C#).
  • 839.
  • 840.
  • 841.
  • 842. Covariant return types not supported in C#. Proxy method will return basetype (C#).
  • 843. No csconstruct typemap defined for type (C#).
  • 844. C# exception may not be thrown - no $excode or excode attribute in typemap typemap. (C#).
  • 845. Unmanaged code contains a call to a SWIG_CSharpSetPendingException method and C# code does not handle pending exceptions via the canthrow attribute. (C#).
  • 870. Warning for classname: Base baseclass ignored. Multiple inheritance is not supported in PHP.
  • 871. Unrecognized pragma pragma. (Php).

15.9.7 User defined (900-999)

These numbers can be used by your own application.

15.10 History

The ability to control warning messages was first added to SWIG-1.3.12.


16 Working with Modules

16.1 Modules Introduction

Each invocation of SWIG requires a module name to be specified. The module name is used to name the resulting target language extension module. Exactly what this means and what the name is used for depends on the target language, for example the name can define a target language namespace or merely be a useful name for naming files or helper classes. Essentially, a module comprises target language wrappers for a chosen collection of global variables/functions, structs/classes and other C/C++ types.

The module name can be supplied in one of two ways. The first is to specify it with the special %module directive. This directive must appear at the beginning of the interface file. The general form of this directive is:

%module(option1="value1",option2="value2",...) modulename

where the modulename is mandatory and the options add one or more optional additional features. Typically no options are specified, for example:

%module mymodule

The second way to specify the module name is with the -module command line option, for example -module mymodule. If the module name is supplied on the command line, it overrides the name specified by the %module directive.

When first working with SWIG, users commonly start by creating a single module. That is, you might define a single SWIG interface that wraps some set of C/C++ code. You then compile all of the generated wrapper code together and use it. For large applications, however, this approach is problematic---the size of the generated wrapper code can be rather large. Moreover, it is probably easier to manage the target language interface when it is broken up into smaller pieces.

This chapter describes the problem of using SWIG in programs where you want to create a collection of modules. Each module in the collection is created via separate invocations of SWIG.

16.2 Basics

The basic usage case with multiple modules is when modules do not have cross-references (ie. when wrapping multiple independent C APIs). In that case, swig input files should just work out of the box - you simply create multiple wrapper .cxx files, link them into your application, and insert/load each in the scripting language runtime as you would do for the single module case.

A bit more complex is the case in which modules need to share information. For example, when one module extends the class of another by deriving from it:

// File: base.h
class base {
public:
  int foo();
};
 
// File: base_module.i
%module base_module

%{
#include "base.h"
%}
%include "base.h"
 
// File: derived_module.i
%module derived_module

%import "base_module.i"

%inline %{
class derived : public base {
public:
  int bar();
};
%}

To create the wrapper properly, module derived_module needs to know about the base class and that its interface is covered in another module. The line %import "base_module.i" lets SWIG know exactly that. Often the .h file is passed to %import instead of the .i, which unfortunately doesn't work for all language modules. For example, Python requires the name of module that the base class exists in so that the proxy classes can fully inherit the base class's methods. Typically you will get a warning when the module name is missing, eg:

derived_module.i:8: Warning 401: Base class 'base' ignored - unknown module name for base. Either
import
the appropriate module interface file or specify the name of the module in the %import directive.

It is sometimes desirable to import the header file rather than the interface file and overcome the above warning. For example in the case of the imported interface being quite large, it may be desirable to simplify matters and just import a small header file of dependent types. This can be done by specifying the optional module attribute in the %import directive. The derived_module.i file shown above could be replaced with the following:

// File: derived_module.i
%module derived_module

%import(module="base_module") "base.h"

%inline %{
class derived : public base {
public:
  int bar();
};

Note that "base_module" is the module name and is the same as that specified in %module in base_module.i as well as the %import in derived_module.i.

Another issue to beware of is that multiple dependent wrappers should not be linked/loaded in parallel from multiple threads as SWIG provides no locking - for more on that issue, read on.

16.3 The SWIG runtime code

Many of SWIG's target languages generate a set of functions commonly known as the "SWIG runtime." These functions are primarily related to the runtime type system which checks pointer types and performs other tasks such as proper casting of pointer values in C++. As a general rule, the statically typed target languages, such as Java, use the language's built in static type checking and have no need for a SWIG runtime. All the dynamically typed / interpreted languages rely on the SWIG runtime.

The runtime functions are private to each SWIG-generated module. That is, the runtime functions are declared with "static" linkage and are visible only to the wrapper functions defined in that module. The only problem with this approach is that when more than one SWIG module is used in the same application, those modules often need to share type information. This is especially true for C++ programs where SWIG must collect and share information about inheritance relationships that cross module boundaries.

To solve the problem of sharing information across modules, a pointer to the type information is stored in a global variable in the target language namespace. During module initialization, type information is loaded into the global data structure of type information from all modules.

There are a few trade offs with this approach. This type information is global across all SWIG modules loaded, and can cause type conflicts between modules that were not designed to work together. To solve this approach, the SWIG runtime code uses a define SWIG_TYPE_TABLE to provide a unique type table. This behavior can be enabled when compiling the generated _wrap.cxx or _wrap.c file by adding -DSWIG_TYPE_TABLE=myprojectname to the command line argument.

Then, only modules compiled with SWIG_TYPE_TABLE set to myprojectname will share type information. So if your project has three modules, all three should be compiled with -DSWIG_TYPE_TABLE=myprojectname, and then these three modules will share type information. But any other project's types will not interfere or clash with the types in your module.

Another issue relating to the global type table is thread safety. If two modules try and load at the same time, the type information can become corrupt. SWIG currently does not provide any locking, and if you use threads, you must make sure that modules are loaded serially. Be careful if you use threads and the automatic module loading that some scripting languages provide. One solution is to load all modules before spawning any threads, or use SWIG_TYPE_TABLE to separate type tables so they do not clash with each other.

Lastly, SWIG uses a #define SWIG_RUNTIME_VERSION, located in Lib/swigrun.swg and near the top of every generated module. This number gets incremented when the data structures change, so that SWIG modules generated with different versions can peacefully coexist. So the type structures are separated by the (SWIG_TYPE_TABLE, SWIG_RUNTIME_VERSION) pair, where by default SWIG_TYPE_TABLE is empty. Only modules compiled with the same pair will share type information.

16.4 External access to the runtime

As described in The run-time type checker, the functions SWIG_TypeQuery, SWIG_NewPointerObj, and others sometimes need to be called. Calling these functions from a typemap is supported, since the typemap code is embedded into the _wrap.c 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:

$ swig -python -external-runtime <filename>

The filename argument is optional and if it is not passed, then the default filename will be something like swigpyrun.h, depending on the language. This header file should be treated like any of the other _wrap.c output files, and should be regenerated when the _wrap files are. After including this header, your code will be able to call SWIG_TypeQuery, SWIG_NewPointerObj, SWIG_ConvertPtr and others. The exact argument parameters for these functions might differ between language modules; please check the language module chapters for more information.

Inside this header the functions are declared static and are included inline into the file, and thus the file does not need to be linked against any SWIG libraries or code (you might still need to link against the language libraries like libpython-2.3). Data is shared between this file and the _wrap.c files through a global variable in the scripting language. It is also possible to copy this header file along with the generated wrapper files into your own package, so that you can distribute a package that can be compiled without SWIG installed (this works because the header file is self-contained, and does not need to link with anything).

This header will also use the -DSWIG_TYPE_TABLE described above, so when compiling any code which includes the generated header file should define the SWIG_TYPE_TABLE to be the same as the module whose types you are trying to access.

16.5 A word of caution about static libraries

When working with multiple SWIG modules, you should take care not to use static libraries. For example, if you have a static library libfoo.a and you link a collection of SWIG modules with that library, each module will get its own private copy of the library code inserted into it. This is very often NOT what you want and it can lead to unexpected or bizarre program behavior. When working with dynamically loadable modules, you should try to work exclusively with shared libraries.

16.6 References

Due to the complexity of working with shared libraries and multiple modules, it might be a good idea to consult an outside reference. John Levine's "Linkers and Loaders" is highly recommended.

16.7 Reducing the wrapper file size

Using multiple modules with the %import directive is the most common approach to modularising large projects. In this way a number of different wrapper files can be generated, thereby avoiding the generation of a single large wrapper file. There are a couple of alternative solutions for reducing the size of a wrapper file through the use of command line options and features.

-fcompact
This command line option will compact the size of the wrapper file without changing the code generated into the wrapper file. It simply removes blank lines and joins lines of code together. This is useful for compilers that have a maximum file size that can be handled.

-fvirtual
This command line option will remove the generation of superfluous virtual method wrappers. Consider the following inheritance hierarchy:

struct Base {
  virtual void method();
  ...
};

struct Derived : Base {
  virtual void method();
  ...
};

Normally wrappers are generated for both methods, whereas this command line option will suppress the generation of a wrapper for Derived::method. Normal polymorphic behaviour remains as Derived::method will still be called should you have a Derived instance and call the wrapper for Base::method.

%feature("compactdefaultargs")
This feature can reduce the number of wrapper methods when wrapping methods with default arguments. The section on default arguments discusses the feature and its limitations.


17 Using SWIG with ccache - ccache-swig(1) manpage

17.1 NAME

ccache-swig - a fast compiler cache

17.2 SYNOPSIS

ccache-swig [OPTION]

ccache-swig <compiler> [COMPILER OPTIONS]

<compiler> [COMPILER OPTIONS]

17.3 DESCRIPTION

ccache-swig is a compiler cache. It speeds up re-compilation of C/C++/SWIG code by caching previous compiles and detecting when the same compile is being done again. ccache-swig is ccache plus support for SWIG. ccache and ccache-swig are used interchangeably in this document.

17.4 OPTIONS SUMMARY

Here is a summary of the options to ccache-swig.


-s                      show statistics summary
-z                      zero statistics
-c                      run a cache cleanup
-C                      clear the cache completely
-F <n>                  set maximum files in cache
-M <n>                  set maximum size of cache (use G, M or K)
-h                      this help page
-V                      print version number

17.5 OPTIONS

These options only apply when you invoke ccache as "ccache-swig". When invoked as a compiler none of these options apply. In that case your normal compiler options apply and you should refer to your compilers documentation.

-h
Print a options summary page

-s
Print the current statistics summary for the cache. The statistics are stored spread across the subdirectories of the cache. Using "ccache-swig -s" adds up the statistics across all subdirectories and prints the totals.

-z
Zero the cache statistics.

-V
Print the ccache version number

-c
Clean the cache and re-calculate the cache file count and size totals. Normally the -c option should not be necessary as ccache keeps the cache below the specified limits at runtime and keeps statistics up to date on each compile. This option is mostly useful if you manually modify the cache contents or believe that the cache size statistics may be inaccurate.

-C
Clear the entire cache, removing all cached files.

-F <maxfiles>
This sets the maximum number of files allowed in the cache. The value is stored inside the cache directory and applies to all future compiles. Due to the way the value is stored the actual value used is always rounded down to the nearest multiple of 16.

-M <maxsize>
This sets the maximum cache size. You can specify a value in gigabytes, megabytes or kilobytes by appending a G, M or K to the value. The default is gigabytes. The actual value stored is rounded down to the nearest multiple of 16 kilobytes.

17.6 INSTALLATION

There are two ways to use ccache. You can either prefix your compile commands with "ccache-swig" or you can create a symbolic link between ccache-swig and the names of your compilers. The first method is most convenient if you just want to try out ccache or wish to use it for some specific projects. The second method is most useful for when you wish to use ccache for all your compiles.

To install for usage by the first method just copy ccache-swig to somewhere in your path.

To install for the second method do something like this:


  cp ccache-swig /usr/local/bin/
  ln -s /usr/local/bin/ccache-swig /usr/local/bin/gcc
  ln -s /usr/local/bin/ccache-swig /usr/local/bin/g++
  ln -s /usr/local/bin/ccache-swig /usr/local/bin/cc
  ln -s /usr/local/bin/ccache-swig /usr/local/bin/swig

This will work as long as /usr/local/bin comes before the path to gcc (which is usually in /usr/bin). After installing you may wish to run "which gcc" to make sure that the correct link is being used.

Note! Do not use a hard link, use a symbolic link. A hardlink will cause "interesting" problems.

17.7 EXTRA OPTIONS

When run as a compiler front end ccache usually just takes the same command line options as the compiler you are using. The only exception to this is the option '--ccache-skip'. That option can be used to tell ccache that the next option is definitely not a input filename, and should be passed along to the compiler as-is.

The reason this can be important is that ccache does need to parse the command line and determine what is an input filename and what is a compiler option, as it needs the input filename to determine the name of the resulting object file (among other things). The heuristic ccache uses in this parse is that any string on the command line that exists as a file is treated as an input file name (usually a C file). By using --ccache-skip you can force an option to not be treated as an input file name and instead be passed along to the compiler as a command line option.

17.8 ENVIRONMENT VARIABLES

ccache uses a number of environment variables to control operation. In most cases you won't need any of these as the defaults will be fine.

CCACHE_DIR
the CCACHE_DIR environment variable specifies where ccache will keep its cached compiler output. The default is "$HOME/.ccache".

CCACHE_TEMPDIR
the CCACHE_TEMPDIR environment variable specifies where ccache will put temporary files. The default is the same as CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same filesystem as the CCACHE_DIR path, so that renames of files between the two directories can work.

CCACHE_LOGFILE
If you set the CCACHE_LOGFILE environment variable then ccache will write some log information on cache hits and misses in that file. This is useful for tracking down problems.

CCACHE_VERBOSE
If you set the CCACHE_VERBOSE environment variable then ccache will display on stdout all the compiler invocations that it makes. This can useful for debugging unexpected problems.

CCACHE_PATH
You can optionally set CCACHE_PATH to a colon separated path where ccache will look for the real compilers. If you don't do this then ccache will look for the first executable matching the compiler name in the normal PATH that isn't a symbolic link to ccache itself.

CCACHE_CC
You can optionally set CCACHE_CC to force the name of the compiler to use. If you don't do this then ccache works it out from the command line.

CCACHE_PREFIX
This option adds a prefix to the command line that ccache runs when invoking the compiler. Also see the section below on using ccache with distcc.

CCACHE_DISABLE
If you set the environment variable CCACHE_DISABLE then ccache will just call the real compiler, bypassing the cache completely.

CCACHE_READONLY
the CCACHE_READONLY environment variable tells ccache to attempt to use existing cached object files, but not to try to add anything new to the cache. If you are using this because your CCACHE_DIR is read-only, then you may find that you also need to set CCACHE_TEMPDIR as otherwise ccache will fail to create the temporary files.

CCACHE_CPP2
If you set the environment variable CCACHE_CPP2 then ccache will not use the optimisation of avoiding the 2nd call to the pre-processor by compiling the pre-processed output that was used for finding the hash in the case of a cache miss. This is primarily a debugging option, although it is possible that some unusual compilers will have problems with the intermediate filename extensions used in this optimisation, in which case this option could allow ccache to be used.

CCACHE_NOCOMPRESS
If you set the environment variable CCACHE_NOCOMPRESS then there is no compression used on files that go into the cache. However, this setting has no effect on how files are retrieved from the cache, compressed results will still be usable.

CCACHE_NOSTATS
If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile.

CCACHE_NLEVELS
The environment variable CCACHE_NLEVELS allows you to choose the number of levels of hash in the cache directory. The default is 2. The minimum is 1 and the maximum is 8.

CCACHE_HARDLINK
If you set the environment variable CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy. Using hard links is faster, but can confuse programs like 'make' that rely on modification times. Hard links are never made for compressed cache files.

CCACHE_RECACHE
This forces ccache to not use any cached results, even if it finds them. New results are still cached, but existing cache entries are ignored.

CCACHE_UMASK
This sets the umask for ccache and all child processes (such as the compiler). This is mostly useful when you wish to share your cache with other users. Note that this also affects the file permissions set on the object files created from your compilations.

CCACHE_HASHDIR
This tells ccache to hash the current working directory when calculating the hash that is used to distinguish two compiles. This prevents a problem with the storage of the current working directory in the debug info of a object file, which can lead ccache to give a cached object file that has the working directory in the debug info set incorrectly. This option is off by default as the incorrect setting of this debug info rarely causes problems. If you strike problems with gdb not using the correct directory then enable this option.

CCACHE_UNIFY
If you set the environment variable CCACHE_UNIFY then ccache will use the C/C++ unifier when hashing the pre-processor output if -g is not used in the compile. The unifier is slower than a normal hash, so setting this environment variable loses a little bit of speed, but it means that ccache can take advantage of not recompiling when the changes to the source code consist of reformatting only. Note that using CCACHE_UNIFY changes the hash, so cached compiles with CCACHE_UNIFY set cannot be used when CCACHE_UNIFY is not set and vice versa. The reason the unifier is off by default is that it can give incorrect line number information in compiler warning messages.

CCACHE_EXTENSION
Normally ccache tries to automatically determine the extension to use for intermediate C pre-processor files based on the type of file being compiled. Unfortunately this sometimes doesn't work, for example when using the aCC compiler on HP-UX. On systems like this you can use the CCACHE_EXTENSION option to override the default. On HP-UX set this environment variable to "i" if you use the aCC compiler.

CCACHE_STRIPC
If you set the environment variable CCACHE_STRIPC then ccache will strip the -c option when invoking the preprocessor. This option is primarily for the Sun Workshop C++ compiler as without this option an unwarranted warning is displayed: CC: Warning: "-E" redefines product from "object" to "source (stdout)" when -E and -c is used together.

CCACHE_SWIG
When using SWIG as the compiler and it does not have 'swig' in the executable name, then the CCACHE_SWIG environment variable needs to be set in order for ccache to work correctly with SWIG. The use of CCACHE_CPP2 is also recommended for SWIG due to some preprocessor quirks, however, use of CCACHE_CPP2 can often be skipped -- check your generated code with and without this option set. Known problems are using preprocessor directives within %inline blocks and the use of '#pragma SWIG'.

17.9 CACHE SIZE MANAGEMENT

By default ccache has a one gigabyte limit on the cache size and no maximum number of files. You can set a different limit using the "ccache -M" and "ccache -F" options, which set the size and number of files limits.

When these limits are reached ccache will reduce the cache to 20% below the numbers you specified in order to avoid doing the cache clean operation too often.

17.10 CACHE COMPRESSION

By default on most platforms ccache will compress all files it puts into the cache using the zlib compression. While this involves a negligible performance slowdown, it significantly increases the number of files that fit in the cache. You can turn off compression setting the CCACHE_NOCOMPRESS environment variable.

17.11 HOW IT WORKS

The basic idea is to detect when you are compiling exactly the same code a 2nd time and use the previously compiled output. You detect that it is the same code by forming a hash of:

  • the pre-processor output from running the compiler with -E
  • the command line options
  • the real compilers size and modification time
  • any stderr output generated by the compiler

These are hashed using md4 (a strong hash) and a cache file is formed based on that hash result. When the same compilation is done a second time ccache is able to supply the correct compiler output (including all warnings etc) from the cache.

ccache has been carefully written to always produce exactly the same compiler output that you would get without the cache. If you ever discover a case where ccache changes the output of your compiler then please let me know.

17.12 USING CCACHE WITH DISTCC

distcc is a very useful program for distributing compilation across a range of compiler servers. It is often useful to combine distcc with ccache, so that compiles that are done are sped up by distcc, but that ccache avoids the compile completely where possible.

To use distcc with ccache I recommend using the CCACHE_PREFIX option. You just need to set the environment variable CCACHE_PREFIX to 'distcc' and ccache will prefix the command line used with the compiler with the command 'distcc'.

17.13 SHARING A CACHE

A group of developers can increase the cache hit rate by sharing a cache directory. The hard links however cause unwanted side effects, as all links to a cached file share the file's modification timestamp. This results in false dependencies to be triggered by timestamp-based build systems whenever another user links to an existing file. Typically, users will see that their libraries and binaries are relinked without reason. To share a cache without side effects, the following conditions need to be met:

  • Use the same CCACHE_DIR environment variable setting
  • Unset the CCACHE_HARDLINK environment variable
  • Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in the group.
  • Make sure that all users have write permission in the entire cache directory (and that you trust all users of the shared cache).
  • Make sure that the setgid bit is set on all directories in the cache. This tells the filesystem to inherit group ownership for new directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might be useful for this.
  • Set CCACHE_NOCOMPRESS for all users, if there are users with versions of ccache that do not support compression.

17.14 HISTORY

ccache was inspired by the compilercache shell script script written by Erik Thiele and I would like to thank him for an excellent piece of work. See http://www.erikyyy.de/compilercache/ for the Erik's scripts. ccache-swig is a port of the original ccache with support added for use with SWIG.

I wrote ccache because I wanted to get a bit more speed out of a compiler cache and I wanted to remove some of the limitations of the shell-script version.

17.15 DIFFERENCES FROM COMPILERCACHE

The biggest differences between Erik's compilercache script and ccache are:

  • ccache is written in C, which makes it a bit faster (calling out to external programs is mostly what slowed down the scripts).
  • ccache can automatically find the real compiler
  • ccache keeps statistics on hits/misses
  • ccache can do automatic cache management
  • ccache can cache compiler output that includes warnings. In many cases this gives ccache a much higher cache hit rate.
  • ccache can handle a much wider ranger of compiler options
  • ccache avoids a double call to cpp on a cache miss

17.16 CREDITS

Thanks to the following people for their contributions to ccache

  • Erik Thiele for the original compilercache script
  • Luciano Rocha for the idea of compiling the pre-processor output to avoid a 2nd cpp pass
  • Paul Russell for many suggestions and the debian packaging

17.17 AUTHOR

ccache was written by Andrew Tridgell http://samba.org/~tridge/. ccache was adapted to create ccache-swig for use with SWIG by William Fulton.

If you wish to report a problem or make a suggestion then please email the SWIG developers on the swig-devel mailing list, see http://www.swig.org/mail.html

ccache is released under the GNU General Public License version 2 or later. Please see the file COPYING for license details.


18 SWIG and Allegro Common Lisp

This chapter describes SWIG's support of Allegro Common Lisp. Allegro CL is a full-featured implementation of the Common Lisp language standard that includes many vendor-specific enhancements and add-on modules for increased usability.

One such module included in Allegro CL is the Foreign Functions Interface (FFI). This module, tailored primarily toward interfacing with C/C++ and, historically, Fortran, provides a means by which compiled foreign code can be loaded into a running lisp environment and executed. The interface supports the calling of foreign functions and methods, allows for executing lisp routines from foreign code (callbacks), and the passing of data between foreign and lisp code.

The goal of this module is to make it possible to quickly generate the necessary foreign function definitions so one can make use of C/C++ foreign libraries directly from lisp without the tedium of having to code them by hand. When necessary, it will also generate further C/C++ code that will need to be linked with the intended library for proper interfacing from lisp. It has been designed with an eye toward flexibility. Some foreign function calls may release the heap, while other should not. Some foreign functions should automatically convert lisp strings into native strings, while others should not. These adjustments and many more are possible with the current module.

It is significant to note that, while this is a vendor-specific module, we would like to acknowledge the current and ongoing work by developers in the open source lisp community that are working on similar interfaces to implementation-independent foreign function interfaces (UFFI or CFFI, for example). Such work can only benefit the lisp community, and we would not be unhappy to see some enterprising folk use this work to add to it.

18.1 Basics

18.1.1 Running SWIG

If you're reading this, you must have some library you need to generate an interface for. In order for SWIG to do this work, however, it needs a bit of information about how it should go about creating your interface, and what you are interfacing to.

SWIG expects a description of what in the foreign interface you wish to connect to. It must consisting of C/C++ declarations and special SWIG directives. SWIG can be furnished with a header file, but an interface can also be generated without library headers by supplying a simple text file--called the interface file, which is typically named with a .i extension--containing any foreign declarations of identifiers you wish to use. The most common approach is to use a an interface file with directives to parse the needed headers. A straight parse of library headers will result in usable code, but SWIG directives provides much freedom in how a user might tailor the generated code to their needs or style of coding.

Note that SWIG does not require any function definitions; the declarations of those functions is all that is necessary. Be careful when tuning the interface as it is quite possible to generate code that will not load or compile.

An example interface file is shown below. It makes use of two SWIG directives, one of which requests that the declarations in a header file be used to generate part of the interface, and also includes an additional declaration to be added.

example.i
%module example

%include "header.h"

int fact(int n);

The contents of header.h are very simple:

header.h
int fact(char *statement);   // pass it a fact, and it will rate it.

The contents of example.cl will look like this:

example.cl
(defpackage :example
  (:use :common-lisp :swig :ff :excl))

  ... helper routines for defining the interface ...

(swig-in-package ())

(swig-defun ("fact")
  ((PARM0_statement cl:string (* :char) ))
  (:returning (:int )
   :strings-convert t)
  (let ((SWIG_arg0 PARM0_statement))
  (swig-ff-call SWIG_arg0)))

(swig-defun ("fact")
  ((PARM0_n cl:integer :int ))
  (:returning (:int )
   :strings-convert t)
  (let ((SWIG_arg0 PARM0_n))
  (swig-ff-call SWIG_arg0)))

(swig-dispatcher ("fact" :type :function :arities (1)))

The generated file contains calls to internal swig helper functions. In this case there are two calls to swig-defun. These calls will expand into code that will make the appropriate definitions using the Allegro FFI. Note also, that this code is erroneous. Function overloading is not supported in C, and this code will not compile even though SWIG did not complain.

In order to generate a C interface to Allegro CL using this code run swig using the -allegrocl option, as below:

% swig -allegrocl example.i

When building an interface to C++ code, include the -c++ option:

% swig -allegrocl -c++ example.i

As a result of running one of the above commands, a file named example.cl will be generated containing the lisp side of the interface. As well, a file example_wrap.cxx is also generated, containing C/C++ wrapper code to facilitate access to C++ methods, enumeration values, and constant values. Wrapper functions are necessary in C++ due to the lack of a standard for mangling the names of symbols across all C++ compilers. These wrapper functions are exported from the shared library as appropriate, using the C name mangling convention. The lisp code that is generated will interface to your foreign library through these wrappers.

It is possible to disable the creation of the .cxx file when generating a C interface by using the -nocwrap command-line argument. For interfaces that don't contain complex enum or constant expressions, contain nested struct/union declarations, or doesn't need to use many of the SWIG customization featuers, this will result in a more streamlined, direct interface to the intended module.

The generated wrapper file is below. It contains very simple wrappers by default, that simply pass the arguments to the actual function.

example_wrap.i
   ... lots of SWIG internals ...

EXPORT int ACL___fact__SWIG_0 (char *larg1) {
    int lresult = (int)0 ;
    char *arg1 = (char *) 0 ;
    int result;
    
    arg1 = larg1;
    try {
        result = (int)fact(arg1);
        
        lresult = result;
        return lresult;
    } catch (...) {
        return (int)0;
    }
}


EXPORT int ACL___fact__SWIG_1 (int larg1) {
    int lresult = (int)0 ;
    int arg1 ;
    int result;
    
    arg1 = larg1;
    try {
        result = (int)fact(arg1);
        
        lresult = result;
        return lresult;
    } catch (...) {
        return (int)0;
    }
}

And again, the generated lisp code. Note that it differs from what is generated when parsing C code:

   ...

(swig-in-package ())

(swig-defmethod ("fact" "ACL___fact__SWIG_0" :type :function :arity 1)
  ((PARM0_statement cl:string (* :char) ))
  (:returning (:int )
   :strings-convert t)
  (let ((SWIG_arg0 PARM0_statement))
  (swig-ff-call SWIG_arg0)))

(swig-defmethod ("fact" "ACL___fact__SWIG_1" :type :function :arity 1)
  ((PARM0_n cl:integer :int ))
  (:returning (:int )
   :strings-convert t)
  (let ((SWIG_arg0 PARM0_n))
  (swig-ff-call SWIG_arg0)))

(swig-dispatcher ("fact" :type :function :arities (1)))

In this case, the interface generates two swig-defmethod forms and a swig-dispatcher form. This provides a single functional interface for all overloaded routines. A more detailed description of this features is to be found in the section titled Function overloading/Parameter defaulting.

In order to load a C++ interface, you will need to build a shared library from example_wrap.cxx. Be sure to link in the actual library you created the interface for, as well as any other dependent shared libraries. For example, if you intend to be able to call back into lisp, you will also need to link in the Allegro shared library. The library you create from the C++ wrapper will be what you then load into Allegro CL.

18.1.2 Command Line Options

There are three Allegro CL specific command-line option:

swig -allegrocl [ options ] filename

   -identifier-converter [name] - Binds the variable swig:*swig-identifier-convert* 
                                  in the generated .cl file to name.
				  This function is used to generate symbols
				  for the lisp side of the interface. 

   -cwrap - [default] Generate a .cxx file containing C wrapper function when
            wrapping C code. The interface generated is similar to what is
	    done for C++ code.
   -nocwrap - Explicitly turn off generation of .cxx wrappers for C code. Reasonable
              for modules with simple interfaces. Can not handle all legal enum
	      and constant constructs, or take advantage of SWIG customization features.

   -isolate - With this command-line argument, all lisp helper functions are defined
              in a unique package named swig.<module-name> rather than
	      swig. This prevents conflicts when the module is
	      intended to be used with other swig generated interfaces that may, 
	      for instance, make use of different identifier converters.

See Section 17.5 Identifier converter functions for more details.

18.1.3 Inserting user code into generated files

It is often necessary to include user-defined code into the automatically generated interface files. For example, when building a C++ interface, example_wrap.cxx will likely not compile unless you add a #include "header.h" directive. This can be done using the SWIG %insert(section) %{ ...code... %} directive:

%module example

%{
#include "header.h"
%}

%include "header.h"

int fact(int n);

Additional sections have been added for inserting into the generated lisp interface file

  • lisphead - inserts before type declarations
  • lisp - inserts after type declarations according to where it appears in the .i file

Note that the block %{ ... %} is effectively a shortcut for %insert("header") %{ ... %}.

18.2 Wrapping Overview

New users to SWIG are encouraged to read SWIG Basics , and SWIG and C++, for those interested in generating an interface to C++.

18.2.1 Function Wrapping

Writing lisp code that directly invokes functions at the foreign function interface level can be cumbersome. Data must often be translated between lisp and foreign types, data extracted from objects, foreign objects allocated and freed upon completion of the foreign call. Dealing with pointers can be unwieldy when it comes to keeping them distinct from other valid integer values.

We make an attempt to ease some of these burdens by making the interface to foreign code much more lisp-like, rather than C like. How this is done is described in later chapters. The layers themselves, appear as follows:

        ______________
       |              |  (foreign side)
       | Foreign Code |  What we're generating an interface to.
       |______________|
               |
	       |
        _______v______
       |              |  (foreign side)
       | Wrapper code |  extern "C" wrappers calling C++ 
       |______________|  functions and methods.
               |
    .  . . - - + - - . .  .
        _______v______
       |              |  (lisp side)
       |  FFI Layer   |  Low level lisp interface. ff:def-foreign-call,
       |______________|  ff:def-foreign-variable
               |
	       +----------------------------
        _______v______              _______v______
       |              |            |              | (lisp side)    
       |    Defuns    |            |  Defmethods  | wrapper for overloaded
       |______________|            |______________| functions or those with
        (lisp side)                        |        defaulted arguments
	Wrapper for non-overloaded         |
	functions and methods       _______v______
	                           |              | (lisp side)
				   |    Defuns    | dispatch function
				   |______________| to overloads based
				                    on arity
  

18.2.2 Foreign Wrappers

These wrappers are as generated by SWIG default. The types of function parameters can be transformed in place using the CTYPE typemap. This is use for converting pass-by-value parameters to pass-by-reference where necessary. All wrapper parameters are then bound to local variables for possible transformation of values (see LIN typemap). Return values can be transformed via the OUT typemap.

18.2.3 FFI Wrappers

These are the generated ff:def-foreign-call forms. No typemaps are applicable to this layer, but the %ffargs directive is available for use in .i files, to specify which keyword arguments should be specified for a given function.

ffargs.i:
%module ffargs

%ffargs(strings_convert="nil",call_direct="t") foo;
%ffargs(strings_convert="nil",release_heap=":never",optimize_for_space="t") bar;

int foo(float f1, float f2);
int foo(float f1, char c2);

void bar(void *lisp_fn);

char *xxx();
  

Generates:

ffargs.cl:
(swig-in-package ())

(swig-defmethod ("foo" "ACL___foo__SWIG_0" :type :function :arity 2)
  ((PARM0_f1 cl:single-float :float )
   (PARM1_f2 cl:single-float :float ))
  (:returning (:int )
   :call-direct t
   :strings-convert nil)
  (let ((SWIG_arg0 PARM0_f1))
  (let ((SWIG_arg1 PARM1_f2))
  (swig-ff-call SWIG_arg0 SWIG_arg1))))

(swig-defmethod ("foo" "ACL___foo__SWIG_1" :type :function :arity 2)
  ((PARM0_f1 cl:single-float :float )
   (PARM1_c2 cl:character :char character))
  (:returning (:int )
   :call-direct t
   :strings-convert nil)
  (let ((SWIG_arg0 PARM0_f1))
  (let ((SWIG_arg1 PARM1_c2))
  (swig-ff-call SWIG_arg0 SWIG_arg1))))

(swig-dispatcher ("foo" :type :function :arities (2)))
(swig-defun ("bar" "ACL___bar__SWIG_0" :type :function)
  ((PARM0_lisp_fn  (* :void) ))
  (:returning (:void )
   :release-heap :never
   :optimize-for-space t
   :strings-convert nil)
  (let ((SWIG_arg0 PARM0_lisp_fn))
  (swig-ff-call SWIG_arg0)))


(swig-defun ("xxx" "ACL___xxx__SWIG_0" :type :function)
  (:void)
  (:returning ((* :char) )
   :strings-convert t)
  (swig-ff-call))
  
%ffargs(strings_convert="t");

Is the only default value specified in allegrocl.swg to force the muffling of warnings about automatic string conversion when defining ff:def-foreign-call's.

18.2.4 Non-overloaded Defuns

These are simple defuns. There is no typechecking of arguments. Parameters are bound to local variables for possible transformation of values, such as pulling values out of instance slots or allocating temporary stack allocated structures, via the lin typemap. These arguments are then passed to the foreign-call (where typechecking may occur). The return value from this function can be manipulated via the lout typemap.

18.2.5 Overloaded Defuns

In the case of overloaded functions, mulitple layers are generated. First, all the overloads for a given name are separated out into groups based on arity, and are wrapped in defmethods. Each method calls a distinct wrapper function, but are themselves distinguished by the types of their arguments (see lispclass typemap). These are further wrapped in a dispatching function (defun) which will invoke the appropriate generic-function based on arity. This provides a single functional interface to all overloads. The return value from this function can be manipulated via the lout typemap.

18.2.6 What about constant and variable access?

Along with the described functional layering, when creating a .cxx wrapper, this module will generate getter and--if not immutable--setter, functions for variables and constants. If the -nocwrap option is used, defconstant and ff:def-foreign-variable forms will be generated for accessing constants and global variables. These, along with the defuns listed above are the intended API for calling into the foreign module.

18.2.7 Object Wrapping

All non-primitive types (Classes, structs, unions, and typedefs involving same) have a corresponding foreign-type defined on the lisp side via ff:def-foreign-type.

All non-primitive types are further represented by a CLOS class, created via defclass. An attempt is made to create the same class hierarchy, with all classes inheriting directly or indirectly from ff:foreign-pointer. Further, wherever it is apparent, all pointers returned from foreign code are wrapped in a CLOS instance of the appropriate class. For ff:def-foreign-calls that have been defined to expect a :foreign-address type as argument, these CLOS instances can legally be passed and the pointer to the C++ object automatically extracted. This is a natural feature of Allegro's foreign function interface.

18.3 Wrapping Details

In this section is described how particular C/C++ constructs are translated into lisp.

18.3.1 Namespaces

C++ namespaces are translated into Lisp packages by SWIG. The Global namespace is mapped to a package named by the %module directive or the -module command-line argument. Further namespaces are generated by the swig-defpackage utility function and given names based on Allegro CLs nested namespace convention. For example:

foo.i:
%module foo

%{
#include "foo.h"
%}

%include "foo.h"

namespace car {
   ...
   namespace tires {
      int do_something(int n);
   }
}
    

Generates the following code.

foo.cl
(defpackage :foo
  (:use :common-lisp :swig :ff :excl))

...

(swig-defpackage ("car"))
(swig-defpackage ("car" "tires"))

...

(swig-in-package ("car" "tires"))
(swig-defun ("do_something" "ACL_car_tires__do_something__SWIG_0" :type :function)
  ((PARM0_n  :int ))
  (:returning (:int )
   :strings-convert t)
  (let ((SWIG_arg0 PARM0_n))
  (swig-ff-call SWIG_arg0)))
    

The above interface file would cause packages foo, foo.car, and foo.car.tires to be created. One would find the function wrapper for do_something defined in the foo.car.tires package(*).

(*) Except for the package named by the module, all namespace names are passed to the identifier-converter-function as strings with a :type of :namespace. It is the job of this function to generate the desired symbol, accounting for case preferences, additional naming cues, etc.

Note that packages created by swig-defpackage do not use the COMMON-LISP or EXCL package. This reduces possible conflicts when defining foreign types via the SWIG interface in all but the toplevel modules package. This may lead to confusion if, for example, the current package is foo.car.tires and you attempt to use a common-lisp function such as (car '(1 2 3).

18.3.2 Constants

Constants, as declared by the preprocessor #define macro or SWIG %constant directive, are included in SWIG's parse tree when it can be determined that they are, or could be reduced to, a literal value. Such values are translated into defconstant forms in the generated lisp wrapper when the -nocwrap command-line options is used. Else, wrapper functions are generated as in the case of variable access (see section below).

Here are examples of simple preprocessor constants when using -nocwrap.

#define A 1                    => (swig-defconstant "A" 1)  
#define B 'c'                  => (swig-defconstant "B" #\c)
#define C B                    => (swig-defconstant "C" #\c)
#define D 1.0e2                => (swig-defconstant "D" 1.0d2)
#define E 2222                 => (swig-defconstant "E" 2222)
#define F (unsigned int)2222   => no code generated
#define G 1.02e2f              => (swig-defconstant "G" 1.02f2)
#define H foo                  => no code generated
      

Note that where SWIG is unable to determine if a constant is a literal, no node is added to the SWIG parse tree, and so no values can be generated.

For preprocessor constants containing expressions which can be reduced to literal values, nodes are created, but with no simplification of the constant value. A very very simple infix to prefix converter has been implemented that tries to do the right thing for simple cases, but does not for more complex expressions. If the literal parser determines that something is wrong, a warning will be generated and the literal expression will be included in the generated code, but commented out.

#define I A + E                => (swig-defconstant "I" (+ 1 2222))
#define J 1|2                  => (swig-defconstant "J" (logior 1 2))
#define Y 1 + 2 * 3 + 4        => (swig-defconstant "Y" (* (+ 1 2) (+ 3 4)))
#define Y1 (1 + 2) * (3 + 4)   => (swig-defconstant "Y1" (* (+ 1 2) (+ 3 4)))
#define Y2 1 * 2 + 3 * 4       => (swig-defconstant "Y2" (* 1 (+ 2 3) 4))  ;; WRONG
#define Y3 (1 * 2) + (3 * 4)   => (swig-defconstant "Y3" (* 1 (+ 2 3) 4))  ;; WRONG
#define Z 1 + 2 - 3 + 4 * 5    => (swig-defconstant "Z" (* (+ 1 (- 2 3) 4) 5)) ;; WRONG
      

Users are cautioned to get to know their constants before use, or not use the -nocwrap command-line option.

18.3.3 Variables

For C wrapping, a def-foreign-variable call is generated for access to global variables.

When wrapping C++ code, both global and member variables, getter wrappers are generated for accessing their value, and if not immutable, setter wrappers as well. In the example below, note the lack of a setter wrapper for global_var, defined as const.

vars.h
namespace nnn {
  int const global_var = 2;
  float glob_float = 2.0;
}
    

Generated code:

vars.cl
(swig-in-package ("nnn"))
(swig-defun ("global_var" "ACL_nnn__global_var_get__SWIG_0" :type :getter)
  (:void)
  (:returning (:int )
   :strings-convert t)
  (swig-ff-call))


(swig-defun ("glob_float" "ACL_nnn__glob_float_set__SWIG_0" :type :setter)
  ((PARM0_glob_float  :float ))
  (:returning (:void )
   :strings-convert t)
  (let ((SWIG_arg0 PARM0_glob_float))
  (swig-ff-call SWIG_arg0)))


(swig-defun ("glob_float" "ACL_nnn__glob_float_get__SWIG_0" :type :getter)
  (:void)
  (:returning (:float )
   :strings-convert t)
  (swig-ff-call))
    

Note also, that where applicable, setter wrappers are implemented as setf methods on the getter function, providing a lispy interface to the foreign code.

user> (load "globalvar.dll")
; Foreign loading globalvar.dll.
t
user> (load "globalvar.cl")
; Loading c:\mikel\src\swig\test\globalvar.cl
t
user> 
globalvar> (globalvar.nnn::global_var)
2
globalvar> (globalvar.nnn::glob_float)
2.0
globalvar> (setf (globalvar.nnn::glob_float) 3.0)
3.0
globalvar> (globalvar.nnn::glob_float)
3.0
    

18.3.4 Enumerations

In C, an enumeration value is an integer value, while in C++ an enumeration value is implicitly convertible to an integer value, but can also be distinguished by its enum type. For each enum declaration a def-foreign-type is generated, assigning the enum a default type of :int. Users may adjust the foreign type of enums via SWIG typemaps .

Enum values are a bit trickier as they can be initialized using any valid C/C++ expression. In C with the -nocwrap command-line option, we handle the typical cases (simple integer initialization) and generate a defconstant form for each enum value. This has the advantage of it not being necessary to probe into foreign space to retrieve enum values. When generating a .cxx wrapper file, a more general solution is employed. A wrapper variable is created in the module_wrap.cxx file, and a ff:def-foreign-variable call is generated to retrieve its value into lisp.

For example, the following header file

enum.h:
enum COL { RED, GREEN, BLUE };	
enum FOO { FOO1 = 10, FOO2, FOO3 };
      

In -nocwrap mode, generates

enum.cl:
(swig-def-foreign-type "COL" :int)
(swig-defconstant "RED" 0)
(swig-defconstant "GREEN" (+ #.(swig-insert-id "RED" () :type :constant) 1))
(swig-defconstant "BLUE" (+ #.(swig-insert-id "GREEN" () :type :constant) 1))

(swig-def-foreign-type "FOO" :int)
(swig-defconstant "FOO1" 10)
(swig-defconstant "FOO2" (+ #.(swig-insert-id "FOO1" () :type :constant) 1))
(swig-defconstant "FOO3" (+ #.(swig-insert-id "FOO2" () :type :constant) 1))
      

And when generating a .cxx wrapper

enum_wrap.cxx:
EXPORT const int ACL_ENUM___RED__SWIG_0 = RED;
EXPORT const int ACL_ENUM___GREEN__SWIG_0 = GREEN;
EXPORT const int ACL_ENUM___BLUE__SWIG_0 = BLUE;
EXPORT const int ACL_ENUM___FOO1__SWIG_0 = FOO1;
EXPORT const int ACL_ENUM___FOO2__SWIG_0 = FOO2;
EXPORT const int ACL_ENUM___FOO3__SWIG_0 = FOO3;
      

and

enum.cl:
(swig-def-foreign-type "COL" :int)
(swig-defvar "RED" "ACL_ENUM___RED__SWIG_0" :type :constant)
(swig-defvar "GREEN" "ACL_ENUM___GREEN__SWIG_0" :type :constant)
(swig-defvar "BLUE" "ACL_ENUM___BLUE__SWIG_0" :type :constant)

(swig-def-foreign-type "FOO" :int)
(swig-defvar "FOO1" "ACL_ENUM___FOO1__SWIG_0" :type :constant)
(swig-defvar "FOO2" "ACL_ENUM___FOO2__SWIG_0" :type :constant)
(swig-defvar "FOO3" "ACL_ENUM___FOO3__SWIG_0" :type :constant)

      

18.3.5 Arrays

One limitation in the Allegro CL foreign-types module, is that, without macrology, expressions may not be used to specify the dimensions of an array declaration. This is not a horrible drawback unless it is necessary to allocate foreign structures based on the array declaration using ff:allocate-fobject. When it can be determined that an array bound is a valid numeric value, SWIG will include this in the generated array declaration on the lisp side, otherwise the value will be included, but commented out.

Below is a comprehensive example, showing a number of legal C/C++ array declarations and how they are translated into foreign-type specifications in the generated lisp code.

array.h
#define MAX_BUF_SIZE 1024

namespace FOO {
  int global_var1[13];
  float global_var2[MAX_BUF_SIZE];

}

enum COLOR { RED = 10, GREEN = 20, BLUE, PURPLE = 50, CYAN };

namespace BAR {
  char global_var3[MAX_BUF_SIZE + 1];
  float global_var4[MAX_BUF_SIZE][13];
  signed short global_var5[MAX_BUF_SIZE + MAX_BUF_SIZE];

  int enum_var5[GREEN];
  int enum_var6[CYAN];

  COLOR enum_var7[CYAN][MAX_BUF_SIZE];
}
    

Generates:

array.cl
(in-package #.*swig-module-name*)

(swig-defpackage ("FOO"))
(swig-defpackage ("BAR"))

(swig-in-package ())
(swig-def-foreign-type "COLOR" :int)
(swig-defvar "RED" "ACL_ENUM___RED__SWIG_0" :type :constant)
(swig-defvar "GREEN" "ACL_ENUM___GREEN__SWIG_0" :type :constant)
(swig-defvar "BLUE" "ACL_ENUM___BLUE__SWIG_0" :type :constant)
(swig-defvar "PURPLE" "ACL_ENUM___PURPLE__SWIG_0" :type :constant)
(swig-defvar "CYAN" "ACL_ENUM___CYAN__SWIG_0" :type :constant)

(swig-in-package ())

(swig-defconstant "MAX_BUF_SIZE" 1024)
(swig-in-package ("FOO"))

(swig-defun ("global_var1" "ACL_FOO__global_var1_get__SWIG_0" :type :getter)
  (:void)
  (:returning ((* :int) )
   :strings-convert t)
  (make-instance 'ff:foreign-pointer :foreign-address (swig-ff-call)))


(swig-defun ("global_var2" "ACL_FOO__global_var2_set__SWIG_0" :type :setter)
  ((global_var2  (:array :float 1024) ))
  (:returning (:void )
   :strings-convert t)
  (let ((SWIG_arg0 global_var2))
  (swig-ff-call SWIG_arg0)))


(swig-in-package ())
(swig-in-package ("BAR"))
(swig-defun ("global_var3" "ACL_BAR__global_var3_set__SWIG_0" :type :setter)
  ((global_var3  (:array :char #|1024+1|#) ))
  (:returning (:void )
   :strings-convert t)
  (let ((SWIG_arg0 global_var3))
  (swig-ff-call SWIG_arg0)))


(swig-defun ("global_var4" "ACL_BAR__global_var4_set__SWIG_0" :type :setter)
  ((global_var4  (:array (:array :float 13) 1024) ))
  (:returning (:void )
   :strings-convert t)
  (let ((SWIG_arg0 global_var4))
  (swig-ff-call SWIG_arg0)))


(swig-defun ("global_var4" "ACL_BAR__global_var4_get__SWIG_0" :type :getter)
  (:void)
  (:returning ((* (:array :float 13)) )
   :strings-convert t)
  (make-instance 'ff:foreign-pointer :foreign-address (swig-ff-call)))


(swig-defun ("global_var5" "ACL_BAR__global_var5_set__SWIG_0" :type :setter)
  ((global_var5  (:array :short #|1024+1024|#) ))
  (:returning (:void )
   :strings-convert t)
  (let ((SWIG_arg0 global_var5))
  (swig-ff-call SWIG_arg0)))


(swig-defun ("enum_var5" "ACL_BAR__enum_var5_set__SWIG_0" :type :setter)
  ((enum_var5  (:array :int #|GREEN|#) ))
  (:returning (:void )
   :strings-convert t)
  (let ((SWIG_arg0 enum_var5))
  (swig-ff-call SWIG_arg0)))


(swig-defun ("enum_var6" "ACL_BAR__enum_var6_set__SWIG_0" :type :setter)
  ((enum_var6  (:array :int #|CYAN|#) ))
  (:returning (:void )
   :strings-convert t)
  (let ((SWIG_arg0 enum_var6))
  (swig-ff-call SWIG_arg0)))


(swig-defun ("enum_var7" "ACL_BAR__enum_var7_set__SWIG_0" :type :setter)
  ((enum_var7  (:array (:array #.(swig-insert-id "COLOR" ()) 1024) #|CYAN|#) ))
  (:returning (:void )
   :strings-convert t)
  (let ((SWIG_arg0 enum_var7))
  (swig-ff-call SWIG_arg0)))


(swig-defun ("enum_var7" "ACL_BAR__enum_var7_get__SWIG_0" :type :getter)
  (:void)
  (:returning ((* (:array #.(swig-insert-id "COLOR" ()) 1024)) )
   :strings-convert t)
  (make-instance 'ff:foreign-pointer :foreign-address (swig-ff-call)))
    

18.3.6 Classes and Structs and Unions (oh my!)

18.3.6.1 CLOS wrapping of

Classes, unions, and structs are all treated the same way by the interface generator. For any of these objects, a def-foreign-type and a defclass form are generated. For every function that returns an object (or pointer/reference) of C/C++ type X, the wrapping defun (or defmethod) on the Lisp side will automatically wrap the pointer returned in an instance of the appropriate class. This makes it much easier to write and debug code than if pointers were passed around as a jumble of integer values.

18.3.6.2 CLOS Inheritance

The CLOS class schema generated by the interface mirrors the inheritance of the classes in foreign code, with the ff:foreign-pointer class at its root. ff:foreign-pointer is a thin wrapper for pointers that is made available by the foreign function interface. Its key benefit is that it may be passed as an argument to any ff:def-foreign-call that is expecting a pointer as the parameter.

18.3.6.3 Member fields and functions

All public fields will have accessor getter/setter functions generated for them, as appropriate. All public member functions will have wrapper functions generated.

We currently ignore anything that isn't public (i.e. private or protected), because the C++ compiler won't allow the wrapper functions to access such fields. Likewise, the interface does nothing for friend directives,

18.3.6.4 Why not directly access C++ classes using foreign types?

The def-foreign-type generated by the SWIG interface is currently incomplete. We can reliably generate the object layout of simple structs and unions; they can be allocated via ff:allocate-fobject, and their member variables accessed directly using the various ff:fslot-value-* functions. However, the layout of C++ classes is more complicated. Different compilers adjust class layout based on inheritance patterns, and the presence of virtual member functions. The size of member function pointers vary across compilers as well. As a result, it is recommended that users of any generated interface not attempt to access C++ instances via the foreign type system, but instead use the more robust wrapper functions.

18.3.7 Templates

18.3.7.1 Generating wrapper code for templates

SWIG provides support for dealing with templates, but by default, it will not generate any member variable or function wrappers for templated classes. In order to create these wrappers, you need to explicitly tell SWIG to instantiate them. This is done via the %template directive.

18.3.7.2 Implicit Template instantiation

While no wrapper code is generated for accessing member variables, or calling member functions, type code is generated to include these templated classes in the foreign-type and CLOS class schema.

18.3.8 Typedef, Templates, and Synonym Types

In C/C++ it is possible, via typedef, to have many names refer to the same type. In general, this is not a problem, though it can lead to confusion. Assume the below C++ header file:

synonyms.h
class A { 
   int x;
   int y;
};

typedef A Foo;

A *xxx(int i);         /* sets A->x = A->y = i */
Foo *yyy(int i);       /* sets Foo->x = Foo->y = i */

int zzz(A *inst = 0);  /* return inst->x + inst->y */
    

The function zzz is an overloaded functions; the foreign function call to it will be wrapped in a generic-function whose argument will be checked against a type of A. Assuming a simple implementation, a call to xxx(1) will return a pointer to an A object, which will be wrapped in a CLOS instance of class A , and a call to yyy(1) will result in a CLOS instance of type Foo being returned. Without establishing a clear type relationship between Foo and A, an attempt to call zzz(yyy(1)) will result in an error.

We resolve this issue, by noting synonym relationships between types while generating the interface. A Primary type is selected (more on this below) from the candidate list of synonyms. For all other synonyms, intead of generating a distinct CLOS class definition, we generate a form that expands to:

(setf (find-class <synonym>) <primary>)

The result is that all references to synonym types in foreign code, are wrapped in the same CLOS wrapper, and, in particular, method specialization in wrapping generic functions works as expected.

Given the above header file, synonym.h, a Lisp session would appear as follows:

CL-USER> (load "synonym.dll")
; Foreign loading synonym.dll.
t
CL-USER> (load "synonym.cl")
; Loading c:\mikel\src\swig\test\synonym.cl
t
CL-USER> 
synonym> (setf a (xxx 3))
#<A nil #x3261a0 @ #x207299da>
synonym> (setf foo (yyy 10))
#<A nil #x3291d0 @ #x2072e982>
synonym> (zzz a)
6
synonym> (zzz foo)
20
synonym> 
    

18.3.8.1 Choosing a primary type

The choice of a primary type is selected by the following criteria from a set of synonym types.

  • If a synonym type has a class definition, it is the primary type.
  • If a synonym type is a class template and has been explicitly instantiated via %template, it is the primary type.
  • For all other sets of synonymous types, the synonym which is parsed first becomes the primary type.

18.3.9 Function overloading/Parameter defaulting

For each possible argument combination, a distinct wrapper function is created in the .cxx file. On the Lisp side, a generic functions is defined for each possible arity the overloaded/defaulted call may have. Each distinct wrapper is then called from within a defmethod on the appropriate generic function. These are further wrapped inside a dispatch function that checks the number of arguments it is called with and passes them via apply to the appropriate generic-function. This allows for a single entry point to overloaded functions on the lisp side.

Example:

overload.h:

class A {
 public:
  int x;
  int y;
};

float xxx(int i, int x = 0);   /* return i * x */
float xxx(A *inst, int x);     /* return x + A->x + A->y */
    

Creates the following three wrappers, for each of the possible argument combinations

overload_wrap.cxx
EXPORT void ACL___delete_A__SWIG_0 (A *larg1) {
    A *arg1 = (A *) 0 ;
    
    arg1 = larg1;
    try {
        delete arg1;
        
    } catch (...) {
        
    }
}


EXPORT float ACL___xxx__SWIG_0 (int larg1, int larg2) {
    float lresult = (float)0 ;
    int arg1 ;
    int arg2 ;
    float result;
    
    arg1 = larg1;
    arg2 = larg2;
    try {
        result = (float)xxx(arg1,arg2);
        
        lresult = result;
        return lresult;
    } catch (...) {
        return (float)0;
    }
}


EXPORT float ACL___xxx__SWIG_1 (int larg1) {
    float lresult = (float)0 ;
    int arg1 ;
    float result;
    
    arg1 = larg1;
    try {
        result = (float)xxx(arg1);
        
        lresult = result;
        return lresult;
    } catch (...) {
        return (float)0;
    }
}


EXPORT float ACL___xxx__SWIG_2 (A *larg1, int larg2) {
    float lresult = (float)0 ;
    A *arg1 = (A *) 0 ;
    int arg2 ;
    float result;
    
    arg1 = larg1;
    arg2 = larg2;
    try {
        result = (float)xxx(arg1,arg2);
        
        lresult = result;
        return lresult;
    } catch (...) {
        return (float)0;
    }
}
    

And the following foreign-function-call and method definitions on the lisp side:

overload.cl
(swig-defmethod ("xxx" "ACL___xxx__SWIG_0" :type :function :arity 2)
  ((PARM0_i cl:integer :int )
   (PARM1_x cl:integer :int ))
  (:returning (:float )
   :strings-convert t)
  (let ((SWIG_arg0 PARM0_i))
  (let ((SWIG_arg1 PARM1_x))
  (swig-ff-call SWIG_arg0 SWIG_arg1))))

(swig-defmethod ("xxx" "ACL___xxx__SWIG_1" :type :function :arity 1)
  ((PARM0_i cl:integer :int ))
  (:returning (:float )
   :strings-convert t)
  (let ((SWIG_arg0 PARM0_i))
  (swig-ff-call SWIG_arg0)))

(swig-defmethod ("xxx" "ACL___xxx__SWIG_2" :type :function :arity 2)
  ((PARM0_inst #.(swig-insert-id "A" () :type :class) (* #.(swig-insert-id "A" ())) )
   (PARM1_x cl:integer :int ))
  (:returning (:float )
   :strings-convert t)
  (let ((SWIG_arg0 PARM0_inst))
  (let ((SWIG_arg1 PARM1_x))
  (swig-ff-call SWIG_arg0 SWIG_arg1))))

(swig-dispatcher ("xxx" :type :function :arities (1 2)))
    

And their usage in a sample lisp session:

overload> (setf a (new_A))
#<A nil #x329268 @ #x206cf612>
overload> (setf (A_x a) 10)
10
overload> (setf (A_y a) 20)
20
overload> (xxx 1)
0.0
overload> (xxx 3 10)
30.0
overload> (xxx a 1)
31.0
overload> (xxx a 2)
32.0
overload> 
    

18.3.10 Operator wrapping and Operator overloading

Wrappers to defined C++ Operators are automatically renamed, using %rename, to the following defaults:

/* name conversion for overloaded operators. */
#ifdef __cplusplus
%rename(__add__)	     *::operator+;
%rename(__pos__)	     *::operator+();
%rename(__pos__)	     *::operator+() const;

%rename(__sub__)	     *::operator-;
%rename(__neg__)	     *::operator-() const;
%rename(__neg__)	     *::operator-();

%rename(__mul__)	     *::operator*;
%rename(__deref__)	     *::operator*();
%rename(__deref__)	     *::operator*() const;

%rename(__div__)	     *::operator/;
%rename(__mod__)	     *::operator%;
%rename(__logxor__)	     *::operator^;
%rename(__logand__)	     *::operator&;
%rename(__logior__)	     *::operator|;
%rename(__lognot__)	     *::operator~();
%rename(__lognot__)	     *::operator~() const;

%rename(__not__)	     *::operator!();
%rename(__not__)	     *::operator!() const;

%rename(__assign__)	     *::operator=;

%rename(__add_assign__)      *::operator+=;
%rename(__sub_assign__)	     *::operator-=;
%rename(__mul_assign__)	     *::operator*=;
%rename(__div_assign__)	     *::operator/=;
%rename(__mod_assign__)	     *::operator%=;
%rename(__logxor_assign__)   *::operator^=;
%rename(__logand_assign__)   *::operator&=;
%rename(__logior_assign__)   *::operator|=;

%rename(__lshift__)	     *::operator<<;
%rename(__lshift_assign__)   *::operator<<=;
%rename(__rshift__)	     *::operator>>;
%rename(__rshift_assign__)   *::operator>>=;

%rename(__eq__)		     *::operator==;
%rename(__ne__)		     *::operator!=;
%rename(__lt__)		     *::operator<;
%rename(__gt__)		     *::operator>;
%rename(__lte__)	     *::operator<=;
%rename(__gte__)	     *::operator>=;

%rename(__and__)	     *::operator&&;
%rename(__or__)		     *::operator||;

%rename(__preincr__)	     *::operator++();
%rename(__postincr__)	     *::operator++(int);
%rename(__predecr__)	     *::operator--();
%rename(__postdecr__)	     *::operator--(int);

%rename(__comma__)	     *::operator,();
%rename(__comma__)	     *::operator,() const;

%rename(__member_ref__)      *::operator->;
%rename(__member_func_ref__) *::operator->*;

%rename(__funcall__)	     *::operator();
%rename(__aref__)	     *::operator[];
    

Name mangling occurs on all such renamed identifiers, so that wrapper name generated by B::operator= will be B___eq__ , i.e. <class-or-namespace>_ has been added. Users may modify these default names by adding %rename directives in their own .i files.

Operator overloading can be achieved by adding functions based on the mangled names of the function. In the following example, a class B is defined with a Operator== method defined. The swig %extend directive is used to add an overload method on Operator==.

opoverload.h
class B {
 public:
  int x;
  int y;
  bool operator==(B const& other) const;
};
    

and

opoverload.i
%module opoverload

%{
#include <fstream>
#include "opoverload.h"
%}

%{
bool B___eq__(B const *inst, int const x)
{
  // insert the function definition into the wrapper code before
  // the wrapper for it.
  // ... do stuff ...
}
%}

%include "opoverload.h"

%extend B {
 public:
  bool __eq__(int const x) const;
};
    

Either operator can be called via a single call to the dispatch function:

opoverload> (B___eq__ x1 x2)
nil
opoverload> (B___eq__ x1 3)
nil
opoverload> 
    

18.3.11 Varargs

Variable length argument lists are not supported, by default. If such a function is encountered, a warning will generated to stderr. Varargs are supported via the SWIG %varargs directive. This directive allows you to specify a (finite) argument list which will be inserted into the wrapper in place of the variable length argument indicator. As an example, consider the function printf(). Its declaration would appear as follows:

See the following section on Variable Length arguments provides examples on how %varargs can be used, along with other ways such functions can be wrapped.

18.3.12 C++ Exceptions

Each C++ wrapper includes a handler to catch any exceptions that may be thrown while in foreign code. This helps prevent simple C++ errors from killing the entire lisp process. There is currently no mechanism to have these exceptions forwarded to the lisp condition system, nor has any explicit support of the exception related SWIG typemaps been implemented.

18.3.13 Pass by value, pass by reference

Allegro CL does not support the passing of non-primitive foreign structures by value. As a result, SWIG must automatically detect and convert function parameters and return values to pointers whenever necessary. This is done via the use of typemaps, and should not require any fine tuning by the user, even for newly defined types.

18.4 Typemaps

SWIG Typemaps provide a powerful tool for automatically generating code to handle various menial tasks required of writing an interface to foreign code. The purpose of this section is to describe each of the typemaps used by the Allegro CL module. Please read the chapter on Typemaps for more information.

18.4.1 Code Generation in the C++ Wrapper

Every C++ wrapper generated by SWIG takes the following form:

return-val wrapper-name(parm0, parm1, ..., parmN)
{
   return-val lresult;   /* return value from wrapper */
   <local-declaration>
   ... results;          /* return value from function call */

   <binding locals to parameters>

   try {
      result = function-name(local0, local1, ..., localN);

      <convert and bind result to lresult>

      return lresult;
   catch (...) {
      return (int)0;
   }
    

18.4.1.1 IN Typemap

the in typemap is used to generate code to convert parameters passed to C++ wrapper functions into the arguments desired for the call being wrapped. That is, it fills in the code for the <binding locals to parameters> section above. We use this map to automatically convert parameters passed by reference to the wrapper function into by-value arguments for the wrapped call, and also to convert boolean values, which are passed as integers from lisp (by default), into the appropriate type for the language of code being wrapped.

These are the default specifications for the IN typemap. Here, $input refers to the parameter code is being generated for, and $1 is the local variable to which it is being assigned. The default settings of this typemap are as follows:

%typemap(in) bool                          "$1 = (bool)$input;";
%typemap(in) char, unsigned char, signed char,
             short, signed short, unsigned short,
             int, signed int, unsigned int,
             long, signed long, unsigned long,
             float, double, long double, char *, void *, void,
             enum SWIGTYPE, SWIGTYPE *,
             SWIGTYPE[ANY], SWIGTYPE &     "$1 = $input;";
%typemap(in) SWIGTYPE                      "$1 = *$input;";
    

18.4.1.2 OUT Typemap

The out typemap is used to generate code to form the return value of the wrapper from the return value of the wrapped function. This code is placed in the <convert and bind result to lresult> section of the above code diagram. Its default mapping is as follows:

%typemap(out) bool                          "$result = (int)$1;";
%typemap(out) char, unsigned char, signed char,
              short, signed short, unsigned short,
              int, signed int, unsigned int,
              long, signed long, unsigned long,
              float, double, long double, char *, void *, void,
              enum SWIGTYPE, SWIGTYPE *,
              SWIGTYPE[ANY], SWIGTYPE &    "$result = $1;";
%typemap(out) SWIGTYPE                     "$result = new $1_type($1);";
    

18.4.1.3 CTYPE Typemap

This typemap is not used for code generation, but purely for the transformation of types in the parameter list of the wrapper function. Its primary use is to handle by-value to by-reference conversion in the wrappers parameter list. Its default settings are:

%typemap(ctype) bool                       "int";
%typemap(ctype) char, unsigned char, signed char,
                short, signed short, unsigned short,
                int, signed int, unsigned int,
                long, signed long, unsigned long,
                float, double, long double, char *, void *, void,
                enum SWIGTYPE, SWIGTYPE *,
                SWIGTYPE[ANY], SWIGTYPE &  "$1_ltype";
%typemap(ctype) SWIGTYPE                   "$&1_type";
    

These three typemaps are specifically employed by the Allegro CL interface generator. SWIG also implements a number of other typemaps that can be used for generating code in the C/C++ wrappers. You can read about these common typemaps here.

18.4.2 Code generation in Lisp wrappers

A number of custom typemaps have also been added to facilitate the generation of code in the lisp side of the interface. These are described below. The basic code generation structure is applied as a series of nested expressions, one for each parameter, then one for manipulating the return value, and last, the foreign function call itself.

Note that the typemaps below use fully qualified symbols where necessary. Users writing their own typemaps should do likewise. See the explanation in the last paragraph of 16.3.1 Namespaces for details.

18.4.2.1 LIN Typemap

The LIN typemap allows for the manipulating the lisp objects passed as arguments to the wrapping defun before passing them to the foreign function call. For example, when passing lisp strings to foreign code, it is often necessary to copy the string into a foreign structure of type (:char *) of appropriate size, and pass this copy to the foreign call. Using the LIN typemap, one could arrange for the stack-allocation of a foreign char array, copy your string into it, and not have to worry about freeing the copy after the function returns.

The LIN typemap accepts the following $variable references.

  • $in - expands to the name of the parameter being applied to this typemap
  • $out - expands to the name of the local variable assigned to this typemap
  • $in_fftype - the foreign function type of the C type.
  • $*in_fftype - the foreign function type of the C type with one pointer removed. If there is no pointer, then $*in_fftype is the same as $in_fftype.
  • $body - very important. Instructs SWIG where subsequent code generation steps should be inserted into the current typemap. Leaving out a $body reference will result in lisp wrappers that do very little by way of calling into foreign code. Not recommended.
%typemap(lin)	SWIGTYPE 	"(cl:let (($out $in))\n  $body)";
    

18.4.2.2 LOUT Typemap

The LOUT typemap is the means by which we effect the wrapping of foreign pointers in CLOS instances. It is applied after all LIN typemaps, and immediately before the actual foreign-call.

The LOUT typemap uses the following $variable

  • $lclass - Expands to the CLOS class that represents foreign-objects of the return type matching this typemap.
  • $body - Same as for the LIN map. Place this variable where you want the foreign-function call to occur.
  • $ldestructor - Expands to the symbol naming the destructor for this class ($lclass) of object. Allows you to insert finalization or automatic garbage collection into the wrapper code (see default mappings below).
%typemap(lout) bool, char, unsigned char, signed char,
               short, signed short, unsigned short,
               int, signed int, unsigned int,
               long, signed long, unsigned long,
               float, double, long double, char *, void *, void,
               enum SWIGTYPE    "$body";
%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *,
               SWIGTYPE &       "(cl:make-instance '$lclass :foreign-address $body)";
%typemap(lout) SWIGTYPE    "(cl:let* ((address $body)\n
                            (ACL_result (cl:make-instance '$lclass :foreign-address address)))\n
                            (cl:unless (cl::zerop address)\n
                            (excl:schedule-finalization ACL_result #'$ldestructor))\n
                             ACL_result)";
    

18.4.2.3 FFITYPE Typemap

The FFITYPE typemap works as a helper for a body of code that converts C/C++ type specifications into Allegro CL foreign-type specifications. These foreign-type specifications appear in ff:def-foreing-type declarations, and in the argument list and return values of ff:def-foreign-calls. You would modify this typemap if you want to change how the FFI passes through arguments of a given type. For example, if you know that a particular compiler represents booleans as a single byte, you might add an entry for:

%typemap(ffitype) bool ":unsigned-char";
    

Note that this typemap is pure type transformation, and is not used in any code generations step the way the LIN and LOUT typemaps are. The default mappings for this typemap are:

%typemap(ffitype) bool ":int";
%typemap(ffitype) char ":char";
%typemap(ffitype) unsigned char ":unsigned-char";
%typemap(ffitype) signed char ":char";
%typemap(ffitype) short, signed short ":short";
%typemap(ffitype) unsigned short ":unsigned-short";
%typemap(ffitype) int, signed int ":int";
%typemap(ffitype) unsigned int ":unsigned-int";
%typemap(ffitype) long, signed long ":long";
%typemap(ffitype) unsigned long ":unsigned-long";
%typemap(ffitype) float ":float";
%typemap(ffitype) double ":double";
%typemap(ffitype) char * "(* :char)";
%typemap(ffitype) void * "(* :void)";
%typemap(ffitype) void ":void";
%typemap(ffitype) enum SWIGTYPE ":int";
%typemap(ffitype) SWIGTYPE & "(* :void)";
    

18.4.2.4 LISPTYPE Typemap

This is another type only transformation map, and is used to provide the lisp-type, which is the optional third argument in argument specifier in a ff:def-foreign-call form. Specifying a lisp-type allows the foreign call to perform type checking on the arguments passed in. The default entries in this typemap are:

%typemap(lisptype) bool "cl:boolean";
%typemap(lisptype) char "cl:character";
%typemap(lisptype) unsigned char "cl:integer";
%typemap(lisptype) signed char "cl:integer";
    

18.4.2.5 LISPCLASS Typemap

The LISPCLASS typemap is used to generate the method signatures for the generic-functions which wrap overloaded functions and functions with defaulted arguments. The default entries are:

%typemap(lispclass) bool "t";
%typemap(lispclass) char "cl:character";
%typemap(lispclass) unsigned char, signed char,
                    short, signed short, unsigned short,
                    int, signed int, unsigned int,
                    long, signed long, unsigned long,
                    enum SWIGTYPE       "cl:integer";
%typemap(lispclass) float "cl:single-float";
%typemap(lispclass) double "cl:double-float";
%typemap(lispclass) char * "cl:string";
    

18.4.3 Modifying SWIG behavior using typemaps

The following example shows how we made use of the above typemaps to add support for the wchar_t type.

%typecheck(SWIG_TYPECHECK_UNICHAR) wchar_t { $1 = 1; };

%typemap(in)        wchar_t "$1 = $input;";
%typemap(lin)       wchar_t "(cl:let (($out (cl:char-code $in)))\n  $body)";
%typemap(lin)       wchar_t* "(excl:with-native-string
                                         ($out $in
                                          :external-format #+little-endian :fat-le 
                                                           #-little-endian :fat)\n
                                 $body)"

%typemap(out)       wchar_t "$result = $1;";
%typemap(lout)      wchar_t "(cl:code-char $body)";
%typemap(lout)      wchar_t* "(excl:native-to-string $body
                                          :external-format #+little-endian :fat-le
                                                           #-little-endian :fat)";

%typemap(ffitype)   wchar_t ":unsigned-short";
%typemap(lisptype)  wchar_t "";
%typemap(ctype)     wchar_t "wchar_t";
%typemap(lispclass) wchar_t "cl:character";
%typemap(lispclass) wchar_t* "cl:string";
    

18.5 Identifier Converter functions

18.5.1 Creating symbols in the lisp environment

Various symbols must be generated in the lisp environment to which class definitions, functions, constants, variables, etc. must be bound. Rather than force a particular convention for naming these symbols, an identifier (to symbol) conversion function is used. A user-defined identifier-converter can then implement any symbol naming, case-modifying, scheme desired.

In generated SWIG code, whenever some interface object must be referenced by its lisp symbol, a macro is inserted that calls the identifier-converter function to generate the appropriate symbol reference. It is therefore expected that the identifier-converter function reliably return the same (eq) symbol given the same set of arguments.

18.5.2 Existing identifier-converter functions

Two basic identifier routines have been defined.

18.5.2.1 identifier-convert-null

No modification of the identifier string is performed. Based on other arguments, the identifier may be concatenated with other strings, from which a symbol will be created.

18.5.2.2 identifier-convert-lispify

All underscores in the identifier string are converted to hyphens. Otherwise, identifier-convert-lispify performs the same symbol transformations.

18.5.2.3 Default identifier to symbol conversions

Check the definitions of the above two default identifier-converters in Lib/allegrocl/allegrocl.swg for default naming conventions.

18.5.3 Defining your own identifier-converter

A user-defined identifier-converter function should conform to the following specification:

(defun identifier-convert-fn (id &key type class arity) ...body...)
result ==> symbol or (setf symbol)

The ID argument is a string representing an identifier in the foreign environment.

The :type keyword argument provides more information on the type of identifier. Its value is a symbol. This allows the identifier-converter to apply different heuristics when mapping different types of identifiers to symbols. SWIG will generate calls to your identifier-converter using the following types.

  • :class - names a CLOS class.
  • :constant - names a defconstant
  • :constructor - names a function for creating a foreign object
  • :destructor - names a function for freeing a foreign object
  • :function - names a CLOS wrapping defmethod or defun.
  • :ff-operator - names a foreign call defined via ff:def-foreign-call
  • :getter - getter function
  • :namespace - names a C++ namespace
  • :setter - names a setter function. May return a (setf symbol) reference
  • :operator - names a C++ operator, such as Operator=, Operator*.
  • :slot - names a slot in a struct/class/union declaration.
  • :type - names a foreign-type defined via ff:def-foreign-type.
  • :variable - names a variable defined via ff:def-foreign-variable.

The :class keyword argument is a string naming a foreign class. When non-nil, it indicates that the current identifier has scope in the specified class.

The :arity keyword argument only appears in swig:swig-defmethod forms generated for overloaded functions. Its value is an integer indicating the number of arguments passed to the routine indicated by this identifier.

18.5.4 Instructing SWIG to use a particular identifier-converter

By default, SWIG will use identifier-converter-null. To specify another convert function, use the -identifier-converter command-line argument. The value should be a string naming the function you wish the interface to use instead, when generating symbols. ex:

% swig -allegrocl -c++ -module mymodule -identifier-converter my-identifier-converter

19 SWIG and Android

This chapter describes SWIG's support of Android.

19.1 Overview

The Android chapter is fairly short as support for Android is the same as for Java, where the Java Native Interface (JNI) is used to call from Android Java into C or C++ compiled code. Everything in the Java chapter applies to generating code for access from Android Java code. This chapter contains a few Android specific notes and examples.

19.2 Android examples

19.2.1 Examples introduction

The examples require the Android SDK and Android NDK which can be installed as per instructions in the links. The Eclipse version is not required for these examples as just the command line tools are used (shown for Linux as the host, but Windows will be very similar, if not identical in most places). Add the SDK tools and NDK tools to your path and create a directory somewhere for your Android projects (adjust PATH as necessary to where you installed the tools):

$ export PATH=$HOME/android/android-sdk-linux_x86/tools:$HOME/android/android-sdk-linux_x86/platform-tools:$HOME/android/android-ndk-r6b:$PATH
$ mkdir AndroidApps 
$ cd AnrdoidApps

The examples use a target id of 1. This might need changing depending on your setup. After installation of the Android SDK, the available target ids can be viewed by running the command below. Please adjust the id to suit your target device.

$ android list targets

The following examples are shipped with SWIG under the Examples/android directory and include a Makefile to build and install each example.

19.2.2 Simple C example

This simple C example shows how to call a C function as well as read and modify a global variable. First we'll create and build a pure Java Android app. Afterwards the JNI code will be generated by SWIG and built into the app. First create and build an app called SwigSimple in a subdirectory called simple using the commands below. Adjust the --target id as mentioned earlier in the Examples introduction. Managing Projects from the Command Line on the Android developer's site is a useful reference for these steps.

$ android create project --target 1 --name SwigSimple --path ./simple --activity SwigSimple --package org.swig.simple
$ cd simple
$ ant debug

Modify src/org/swig/simple/SwigSimple.java from the default to:

package org.swig.simple;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ScrollView;
import android.text.method.ScrollingMovementMethod;

public class SwigSimple extends Activity
{
    TextView outputText = null;
    ScrollView scroller = null;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        outputText = (TextView)findViewById(R.id.OutputText);
        outputText.setText("Press 'Run' to start...\n");
        outputText.setMovementMethod(new ScrollingMovementMethod());

        scroller = (ScrollView)findViewById(R.id.Scroller);
    }

    public void onRunButtonClick(View view)
    {
      outputText.append("Started...\n");
      nativeCall();
      outputText.append("Finished!\n");
      
      // Ensure scroll to end of text
      scroller.post(new Runnable() {
        public void run() {
          scroller.fullScroll(ScrollView.FOCUS_DOWN);
        }
      });
    }

    /** Calls into C/C++ code */
    public void nativeCall()
    {
        // TODO
    }
}

The above simply adds a Run button and scrollable text view as the GUI aspects of the program. The associated resources need to be created, modify res/layout/main.xml as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<Button
    android:id="@+id/RunButton"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:text="Run..."  
    android:onClick="onRunButtonClick"
    />
<ScrollView
    android:id="@+id/Scroller"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:id="@+id/OutputText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
</ScrollView>
</LinearLayout>

Rebuild the project with your changes:

$ ant debug

Although there are no native function calls in the code, yet, you may want to check that this simple pure Java app runs before adding in the native calls. First, set up your Android device for hardware debugging, see Using hardware devices on the Android developer's site. When complete your device should be listed in those attached, something like:

$ adb devices
List of devices attached 
A32-6DBE0001-9FF80000-015D62C3-02018028	device

This means you are now ready to install the application...

$ adb install bin/SwigSimple-debug.apk 
95 KB/s (4834 bytes in 0.049s)
	pkg: /data/local/tmp/SwigSimple-debug.apk
Success

The newly installed 'SwigSimple' app will be amongst all your other applications on the home screen. Run the app and it will show a Run button text box below it. Press the Run button to see the simple text output.

The application can be uninstalled like any other application and in fact must be uninstalled before installing an updated version. Uninstalling is quite easy too from your host computer:

$ adb uninstall org.swig.simple
Success

Now that you have a pure Java Android app working, let's add some JNI code generated from SWIG.

First create a jni subdirectory and then create some C source code in jni/example.c:

/* File : example.c */

/* A global variable */
double Foo = 3.0;

/* Compute the greatest common divisor of positive integers */
int gcd(int x, int y) {
  int g;
  g = y;
  while (x > 0) {
    g = x;
    x = y % x;
    y = g;
  }
  return g;
}

Create a SWIG interface file for this C code, jni/example.i :

/* File : example.i */
%module example

%inline %{
extern int    gcd(int x, int y);
extern double Foo;
%}

Invoke SWIG as follows:

$ swig -java -package org.swig.simple -outdir src/org/swig/simple -o jni/example_wrap.c jni/example.i

SWIG generates the following files:

  • src/org/swig/simple/exampleJNI.java
  • src/org/swig/simple/example.java
  • jni/example_wrap.c

Next we need to create a standard Android NDK build system file jni/Android.mk:

# File: Android.mk
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := example
LOCAL_SRC_FILES := example_wrap.c example.c

include $(BUILD_SHARED_LIBRARY)

See the Android NDK documentation for more on the NDK build system and getting started with the NDK. A simple invocation of ndk-build will compile the .c files and generate a shared object/system library. Output will be similar to:

$ ndk-build
Compile thumb  : example <= example_wrap.c
Compile thumb  : example <= example.c
SharedLibrary  : libexample.so
Install        : libexample.so => libs/armeabi/libexample.so

Now that the C JNI layer has been built, we can write Java code to call into the this layer. Modify the nativeCall method in src/org/swig/simple/SwigSimple.java to call the JNI code as follows and add the static constructor to load the system library containing the compiled JNI C code:

    /** Calls into C/C++ code */
    public void nativeCall()
    {
      // Call our gcd() function
      
      int x = 42;
      int y = 105;
      int g = example.gcd(x,y);
      outputText.append("The greatest common divisor of " + x + " and " + y + " is " + g + "\n");

      // Manipulate the Foo global variable

      // Output its current value
      double foo = example.getFoo();
      outputText.append("Foo = " + foo + "\n");

      // Change its value
      example.setFoo(3.1415926);

      // See if the change took effect
      outputText.append("Foo = " + example.getFoo() + "\n");

      // Restore value
      example.setFoo(foo);
    }

    /** static constructor */
    static {
        System.loadLibrary("example");
    }

Compile the Java code as usual, uninstall the old version of the app if still installed and re-install the new app:

$ ant debug
$ adb uninstall org.swig.simple
$ adb install bin/SwigSimple-debug.apk 

Run the app again and this time you will see the output pictured below, showing the result of calls into the C code:

Android screenshot of SwigSimple example

19.2.3 C++ class example

The steps for calling C++ code are almost identical to those in the previous C code example. All the steps required to compile and use a simple hierarchy of classes for shapes are shown in this example.

First create an Android project called SwigClass in a subdirectory called class. The steps below create and build a the JNI C++ app. Adjust the --target id as mentioned earlier in the Examples introduction.

$ android create project --target 1 --name SwigClass --path ./class --activity SwigClass --package org.swig.classexample
$ cd class

Now create a jni subdirectory and then create a C++ header file jni/example.h which defines our hierarchy of shape classes:

/* File : example.h */

class Shape {
public:
  Shape() {
    nshapes++;
  }
  virtual ~Shape() {
    nshapes--;
  }
  double  x, y;   
  void    move(double dx, double dy);
  virtual double area() = 0;
  virtual double perimeter() = 0;
  static  int nshapes;
};

class Circle : public Shape {
private:
  double radius;
public:
  Circle(double r) : radius(r) { }
  virtual double area();
  virtual double perimeter();
};

class Square : public Shape {
private:
  double width;
public:
  Square(double w) : width(w) { }
  virtual double area();
  virtual double perimeter();
};

and create the implementation in the jni/example.cpp file:

/* File : example.cpp */

#include "example.h"
#define M_PI 3.14159265358979323846

/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
  x += dx;
  y += dy;
}

int Shape::nshapes = 0;

double Circle::area() {
  return M_PI*radius*radius;
}

double Circle::perimeter() {
  return 2*M_PI*radius;
}

double Square::area() {
  return width*width;
}

double Square::perimeter() {
  return 4*width;
}

Create a SWIG interface file for this C++ code in jni/example.i :

/* File : example.i */
%module example

%{
#include "example.h"
%}

/* Let's just grab the original header file here */
%include "example.h"

Invoke SWIG as follows, note that the -c++ option is required for C++ code:

$ swig -c++ -java -package org.swig.classexample -outdir src/org/swig/classexample -o jni/example_wrap.cpp jni/example.i

SWIG generates the following files:

  • src/org/swig/classexample/Square.java
  • src/org/swig/classexample/exampleJNI.java
  • src/org/swig/classexample/example.java
  • src/org/swig/classexample/Circle.java
  • src/org/swig/classexample/Shape.java
  • jni/example_wrap.cpp

Next we need to create an Android NDK build system file for compiling the C++ code jni/Android.mk. The -frtti compiler flag isn't strictly needed for this example, but is needed for any code that uses C++ RTTI:

# File: Android.mk
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := example
LOCAL_SRC_FILES := example_wrap.cpp example.cpp
LOCAL_CFLAGS    := -frtti

include $(BUILD_SHARED_LIBRARY)

A simple invocation of ndk-build will compile the .cpp files and generate a shared object/system library. Output will be similar to:

$ ndk-build
Compile++ thumb  : example <= example_wrap.cpp
Compile++ thumb  : example <= example.cpp
StaticLibrary  : libstdc++.a
SharedLibrary  : libexample.so
Install        : libexample.so => libs/armeabi/libexample.so

Now that the C JNI layer has been built, we can write Java code to call into this layer. Modify src/org/swig/classexample/SwigClass.java from the default to:

package org.swig.classexample;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ScrollView;
import android.text.method.ScrollingMovementMethod;

public class SwigClass extends Activity
{
    TextView outputText = null;
    ScrollView scroller = null;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        outputText = (TextView)findViewById(R.id.OutputText);
        outputText.setText("Press 'Run' to start...\n");
        outputText.setMovementMethod(new ScrollingMovementMethod());

        scroller = (ScrollView)findViewById(R.id.Scroller);
    }

    public void onRunButtonClick(View view)
    {
      outputText.append("Started...\n");
      nativeCall();
      outputText.append("Finished!\n");
      
      // Ensure scroll to end of text
      scroller.post(new Runnable() {
        public void run() {
          scroller.fullScroll(ScrollView.FOCUS_DOWN);
        }
      });
    }

    /** Calls into C/C++ code */
    public void nativeCall()
    {
      // ----- Object creation -----

      outputText.append( "Creating some objects:\n" );
      Circle c = new Circle(10);
      outputText.append( "    Created circle " + c + "\n");
      Square s = new Square(10);
      outputText.append( "    Created square " + s + "\n");

      // ----- Access a static member -----

      outputText.append( "\nA total of " + Shape.getNshapes() + " shapes were created\n" );

      // ----- Member data access -----

      // Notice how we can do this using functions specific to
      // the 'Circle' class.
      c.setX(20);
      c.setY(30);

      // Now use the same functions in the base class
      Shape shape = s;
      shape.setX(-10);
      shape.setY(5);

      outputText.append( "\nHere is their current position:\n" );
      outputText.append( "    Circle = (" + c.getX() + " " + c.getY() + ")\n" );
      outputText.append( "    Square = (" + s.getX() + " " + s.getY() + ")\n" );

      // ----- Call some methods -----

      outputText.append( "\nHere are some properties of the shapes:\n" );
      Shape[] shapes = {c,s};
      for (int i=0; i<shapes.length; i++)
      {
        outputText.append( "   " + shapes[i].toString() + "\n" );
        outputText.append( "        area      = " + shapes[i].area() + "\n" );
        outputText.append( "        perimeter = " + shapes[i].perimeter() + "\n" );
      }

      // Notice how the area() and perimeter() functions really
      // invoke the appropriate virtual method on each object.

      // ----- Delete everything -----

      outputText.append( "\nGuess I'll clean up now\n" );

      // Note: this invokes the virtual destructor
      // You could leave this to the garbage collector
      c.delete();
      s.delete();

      outputText.append( Shape.getNshapes() + " shapes remain\n" );
      outputText.append( "Goodbye\n" );
    }

    /** static constructor */
    static {
        System.loadLibrary("example");
    }
}

Note the static constructor and the interesting JNI code is in the nativeCall method. The remaining code deals with the GUI aspects which are identical to the previous C simple example. Modify res/layout/main.xml to contain the xml for the 'Run' button and scrollable text view:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<Button
    android:id="@+id/RunButton"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:text="Run..."  
    android:onClick="onRunButtonClick"
    />
<ScrollView
    android:id="@+id/Scroller"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:id="@+id/OutputText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
</ScrollView>
</LinearLayout>

Compile the Java code as usual, uninstall the old version of the app if installed and re-install the new app:

$ ant debug
$ adb uninstall org.swig.classexample
$ adb install bin/SwigClass-debug.apk 

Run the app to see the result of calling the C++ code from Java:

Android screenshot of SwigClass example

19.2.4 Other examples

The Examples/android directory contains further examples which can be run and installed in a similar manner to the previous two examples.

Note that the 'extend' example is demonstrates the directors feature. Normally C++ exception handling and the STL is not available by default in the version of g++ shipped with Android, but this example turns these features on as described in the next section.

19.3 C++ STL

Should the C++ Standard Template Library (STL) be required, an Application.mk file needs to be created in the same directory as the Android.mk directory containing information about the STL to use. See the NDK documentation in the $NDKROOT/docs folder especially CPLUSPLUS-SUPPORT.html. Below is an example of the Application.mk file to make the STLport static library available for use:

# File: Application.mk
APP_STL := gnustl_static

20 SWIG and C#

20.1 Introduction

The purpose of the C# module is to offer an automated way of accessing existing C/C++ code from .NET languages. The wrapper code implementation uses C# and the Platform Invoke (PInvoke) interface to access natively compiled C/C++ code. The PInvoke interface has been chosen over Microsoft's Managed C++ interface as it is portable to both Microsoft Windows and non-Microsoft platforms. PInvoke is part of the ECMA/ISO C# specification. It is also better suited for robust production environments due to the Managed C++ flaw called the Mixed DLL Loading Problem. SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using Mono and Portable.NET.

To get the most out of this chapter an understanding of interop is required. The Microsoft Developer Network (MSDN) has a good reference guide in a section titled "Interop Marshaling". Monodoc, available from the Mono project, has a very useful section titled Interop with native libraries.

20.1.1 SWIG 2 Compatibility

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 using directives in generated code. This breaks backwards compatibility with typemaps, pragmas, etc written for use with SWIG 2 that assume the presence of using System; or using System.Runtime.InteropServices; directives in the intermediate class imports, module imports, or proxy imports. SWIG 3 supports backwards compatibility though the use of the SWIG2_CSHARP macro. If SWIG2_CSHARP is defined, SWIG 3 generates using 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 -DSWIG2_CSHARP commandline parameter when executing swig.

20.2 Differences to the Java module

The C# module is very similar to the Java module, so until some more complete documentation has been written, please use the Java documentation as a guide to using SWIG with C#. The C# module has the same major SWIG features as the Java module. The rest of this section should be read in conjunction with the Java documentation as it lists the main differences. The most notable differences to Java are the following:

  • When invoking SWIG use the -csharp command line option instead of -java.
  • The -nopgcpp command line option does not exist.
  • The -package command line option does not exist.
  • The -namespace <name> commandline option will generate all code into the namespace specified by <name>. C# supports nested namespaces that are not lexically nested, so nested namespaces will of course also work. For example: -namespace com.bloggs.widget , will generate code into C# namespaces:
    namespace com.bloggs.widget {
      ...
    }
    
    Note that by default, the generated C# classes have no namespace and the module name is unrelated to namespaces. The module name is just like in Java and is merely used to name some of the generated classes.
  • The nspace feature is also supported as described in this general section with a C# example. Unlike Java which requires the use of the -package option when using the nspace feature, the -namespace option is not mandatory for C#.
  • The -dllimport <name> commandline option specifies the name of the DLL for the DllImport attribute for every PInvoke method. If this commandline option is not given, the DllImport DLL name is the same as the module name. This option is useful for when one wants to invoke SWIG multiple times on different modules, yet compile all the resulting code into a single DLL.
  • C/C++ variables are wrapped with C# properties and not JavaBean style getters and setters.
  • Global constants are generated into the module class. There is no constants interface.
  • There is no implementation for type unsafe enums - not deemed necessary.
  • The default enum wrapping approach is proper C# enums, not typesafe enums.
    Note that %csconst(0) will be ignored when wrapping C/C++ enums with proper C# enums. This is because C# enum items must be initialised from a compile time constant. If an enum item has an initialiser and the initialiser doesn't compile as C# code, then the %csconstvalue directive must be used as %csconst(0) will have no effect. If it was used, it would generate an illegal runtime initialisation via a PInvoke call.
  • C# doesn't support the notion of throws clauses. Therefore there is no 'throws' typemap attribute support for adding exception classes to a throws clause. Likewise there is no need for an equivalent to %javaexception. In fact, throwing C# exceptions works quite differently, see C# Exceptions below.
  • The majority of the typemaps are in csharp.swg, not java.swg.
  • Typemap equivalent names:

    jni                         -> ctype
    jtype                       -> imtype
    jstype                      -> cstype
    javain                      -> csin
    javaout                     -> csout
    javadirectorin              -> csdirectorin
    javadirectorout             -> csdirectorout
    javainterfaces              -> csinterfaces and csinterfaces_derived
    javabase                    -> csbase
    javaclassmodifiers          -> csclassmodifiers
    javacode                    -> cscode
    javaimports                 -> csimports
    javabody                    -> csbody
    javafinalize                -> csfinalize
    javadestruct                -> csdestruct
    javadestruct_derived        -> csdestruct_derived
    
  • Typemap macros:

    SWIG_JAVABODY_PROXY         -> SWIG_CSBODY_PROXY
    SWIG_JAVABODY_TYPEWRAPPER   -> SWIG_CSBODY_TYPEWRAPPER
    
  • Additional typemaps:

    csvarin                     C# code property set typemap
    csvarout                    C# code property get typemap
    csattributes                C# attributes for attaching to proxy classes/enums
    
  • Additional typemap attributes:

    The "null" attribute in the "out" typemap can be specified to provide a value for $null to expand into for wrapped functions that return non-void. Normally the default value of 0 is used. For example this is needed if you change the return type to void:

    %typemap(ctype) Status "void"
    %typemap(out, null="") Status { ... }
    
  • Feature equivalent names:

    %javaconst                  -> %csconst
    %javaconstvalue             -> %csconstvalue
    %javamethodmodifiers        -> %csmethodmodifiers
    
  • Pragma equivalent names:

    %pragma(java)               -> %pragma(csharp)
    jniclassbase                -> imclassbase
    jniclassclassmodifiers      -> imclassclassmodifiers
    jniclasscode                -> imclasscode
    jniclassimports             -> imclassimports
    jniclassinterfaces          -> imclassinterfaces
    
  • Special variable equivalent names:

    $javaclassname              -> $csclassname
    $&javaclassname             -> $&csclassname
    $*javaclassname             -> $*csclassname
    $javaclazzname              -> $csclazzname
    $javainput                  -> $csinput
    $jnicall                    -> $imcall
    
  • Unlike the "javain" typemap, the "csin" typemap does not support the 'pgcpp' attribute as the C# module does not have a premature garbage collection prevention parameter. The "csin" typemap supports additional optional attributes called 'cshin' and 'terminator'. The "csdirectorin" typemap supports additional optional attributes called 'terminator'. The 'cshin' attribute should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. The 'terminator' attribute normally just contains a closing brace for when the 'pre' attribute contains an opening brace, such as when a C# using or fixed block is started. Note that 'pre', 'post', 'terminator' and 'cshin' attributes are not used for marshalling the property set. Please see the Date marshalling example and Date marshalling of properties example for further understanding of these "csin" applicable attributes. Please see the Date marshalling director example for further understanding of the "csdirectorin" attributes.

  • Support for asymmetric type marshalling. The 'ctype', 'imtype' and 'cstype' typemaps support an optional out attribute which is used for output types. If this typemap attribute is specified, then the type specified in the attribute is used for output types and the type specified in the typemap itself is used for the input type. If this typemap attribute is not specified, then the type used for both input and output is the type specified in the typemap. An example shows that char * could be marshalled in different ways,

    %typemap(imtype, out="global::System.IntPtr") char * "string"
    char * function(char *);
    

    The output type is thus IntPtr and the input type is string. The resulting intermediary C# code is:

    public static extern global::System.IntPtr function(string jarg1);
    
  • Support for type attributes. The 'imtype' and 'cstype' typemaps can have an optional inattributes and outattributes typemap attribute. The 'imtype' typemap can also have an optional directorinattributes and directoroutattributes typemap attribute which attaches to director delegates, an implementation detail of directors, see directors implementation. Note that there are C# attributes and typemap attributes, don't get confused between the two!! The C# attributes specified in these typemap attributes are generated wherever the type is used in the C# wrappers. These can be used to specify any C# attribute associated with a C/C++ type, but are more typically used for the C# MarshalAs attribute. For example:

    %typemap(imtype,
             inattributes="[global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPStr)]",
             outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPStr)]") const char * "String"
    
    const char * GetMsg() {}
    void SetMsg(const char *msg) {}
    

    The intermediary class will then have the marshalling as specified by everything in the 'imtype' typemap:

    class examplePINVOKE {
      ...
      [global::System.Runtime.InteropServices.DllImport("example", EntryPoint="CSharp_GetMsg")]
      [return: global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPStr)]
      public static extern String GetMsg();
    
      [global::System.Runtime.InteropServices.DllImport("example", EntryPoint="CSharp_SetMsg")]
      public static extern void SetMsg([global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPStr)]String jarg1);
    }
    

    Note that the DllImport attribute is always generated, irrespective of any additional attributes specified.

    These attributes are associated with the C/C++ parameter type or return type, which is subtly different to the attribute features and typemaps covered next. Note that all these different C# attributes can be combined so that a method has more than one attribute.

    The directorinattributes and directoroutattributes typemap attribute are attached to the delegates in the director class, for example, the SwigDelegateBase_0

  • Support for attaching C# attributes to wrapped methods, variables and enum values. This is done using the %csattributes feature, see %feature directives. Note that C# attributes are attached to proxy classes and enums using the csattributes typemap. For example, imagine we have a custom attribute class, ThreadSafeAttribute, for labelling thread safety. The following SWIG code shows how to attach this C# attribute to some methods and the class declaration itself:

    %typemap(csattributes) AClass          "[ThreadSafe]"
    %csattributes AClass::AClass(double d) "[ThreadSafe(false)]"
    %csattributes AClass::AMethod()        "[ThreadSafe(true)]"
    
    %inline %{
    class AClass {
    public:
      AClass(double a) {}
      void AMethod() {}
    };
    %}
    

    will generate a C# proxy class:

    [ThreadSafe]
    public class AClass : global::System.IDisposable {
      ...
      [ThreadSafe(false)]
      public AClass(double a) ...
    
      [ThreadSafe(true)]
      public void AMethod() ...
    }
    

    If C# attributes need adding to the set or get part of C# properties, when wrapping C/C++ variables, they can be added using the 'csvarin' and 'csvarout' typemaps respectively. Note that the type used for the property is specified in the 'cstype' typemap. If the 'out' attribute exists in this typemap, then the type used is from the 'out' attribute.

    An example for attaching attributes to the enum and enum values is shown below.

    %typemap(csattributes) Couleur "[global::System.ComponentModel.Description(\"Colours\")]"
    %csattributes Rouge "[global::System.ComponentModel.Description(\"Red\")]"
    %csattributes Vert "[global::System.ComponentModel.Description(\"Green\")]"
    %inline %{
      enum Couleur { Rouge, Orange, Vert };
    %}
    

    which will result in the following C# enum:

    [global::System.ComponentModel.Description("Colours")]
    public enum Couleur {
      [global::System.ComponentModel.Description("Red")]
      Rouge,
      Orange,
      [global::System.ComponentModel.Description("Green")]
      Vert
    }
    
  • The intermediary classname has PINVOKE appended after the module name instead of JNI, for example modulenamePINVOKE .

  • The %csmethodmodifiers feature can also be applied to variables as well as methods. In addition to the default public modifier that SWIG generates when %csmethodmodifiers is not specified, the feature will also replace the virtual/new /override modifiers that SWIG thinks is appropriate. This feature is useful for some obscure cases where SWIG might get the virtual/new/override modifiers incorrect, for example with multiple inheritance.

  • The name of the intermediary class can be changed from its default, that is, the module name with PINVOKE appended after it. The module directive attribute imclassname is used to achieve this:

    %module (imclassname="name") modulename
    

    If name is the same as modulename then the module class name gets changed from modulename to modulenameModule.

  • There is no additional 'premature garbage collection prevention parameter' as the marshalling of the HandleRef object takes care of ensuring a reference to the proxy class is held until the unmanaged call completed.

$dllimport
This is a C# only special variable that can be used in typemaps, pragmas, features etc. The special variable will get translated into the value specified by the -dllimport commandline option if specified, otherwise it is equivalent to the $module special variable.

$imclassname
This special variable expands to the intermediary class name. For C# this is usually the same as '$modulePINVOKE' ('$moduleJNI' for Java), unless the imclassname attribute is specified in the %module directive.

The directory Examples/csharp has a number of simple examples. Visual Studio .NET 2003 solution and project files are available for compiling with the Microsoft .NET C# compiler on Windows. If your SWIG installation went well on a Unix environment and your C# compiler was detected, you should be able to type make in each example directory, then ilrun runme.exe (Portable.NET C# compiler) or mono runme.exe (Mono C# compiler) to run the examples. Windows users can also get the examples working using a Cygwin or MinGW environment for automatic configuration of the example makefiles. Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path.

20.3 Void pointers

By default SWIG treats void * as any other pointer and hence marshalls it as a type wrapper class called SWIGTYPE_p_void . If you want to marshall with the .NET System.IntPtr type instead, there is a simple set of named typemaps called void *VOID_INT_PTR that can be used. They can be applied like any other named typemaps:

%apply void *VOID_INT_PTR { void * }
void * f(void *v);

20.4 C# Arrays

There are various ways to pass arrays from C# to C/C++. The default wrapping treats arrays as pointers and as such simple type wrapper classes are generated, eg SWIGTYPE_p_int when wrapping the C type int [] or int *. This gives a rather restricted use of the underlying unmanaged code and the most practical way to use arrays is to enhance or customise with one of the following three approaches; namely the SWIG C arrays library, P/Invoke default array marshalling or pinned arrays.

20.4.1 The SWIG C arrays library

The C arrays library keeps all the array memory in the unmanaged layer. The library is available to all language modules and is documented in the carrays.i library section. Please refer to this section for details, but for convenience, the C# usage for the two examples outlined there is shown below.

For the %array_functions example, the equivalent usage would be:

SWIGTYPE_p_double a = example.new_doubleArray(10);  // Create an array
for (int i=0; i<10; i++)
  example.doubleArray_setitem(a,i,2*i);             // Set a value
example.print_array(a);                             // Pass to C
example.delete_doubleArray(a);                      // Destroy array

and for the %array_class example, the equivalent usage would be:

doubleArray c = new doubleArray(10);    // Create double[10]
for (int i=0; i<10; i++)
  c.setitem(i, 2*i);                    // Assign values
example.print_array(c.cast());          // Pass to C

20.4.2 Managed arrays using P/Invoke default array marshalling

In the P/Invoke default marshalling scheme, one needs to designate whether the invoked function will treat a managed array parameter as input, output, or both. When the function is invoked, the CLR allocates a separate chunk of memory as big as the given managed array, which is automatically released at the end of the function call. If the array parameter is marked as being input, the content of the managed array is copied into this buffer when the call is made. Correspondingly, if the array parameter is marked as being output, the contents of the reserved buffer are copied back into the managed array after the call returns. A pointer to this buffer is passed to the native function.

The reason for allocating a separate buffer is to leave the CLR free to relocate the managed array object during garbage collection. If the overhead caused by the copying is causing a significant performance penalty, consider pinning the managed array and passing a direct reference as described in the next section.

For more information on the subject, see the Default Marshaling for Arrays article on MSDN.

The P/Invoke default marshalling is supported by the arrays_csharp.i library via the INPUT, OUTPUT and INOUT typemaps. Let's look at some example usage. Consider the following C function:

void myArrayCopy(int *sourceArray, int *targetArray, int nitems);

We can now instruct SWIG to use the default marshalling typemaps by

%include "arrays_csharp.i"

%apply int INPUT[]  {int *sourceArray}
%apply int OUTPUT[] {int *targetArray}

As a result, we get the following method in the module class:

public static void myArrayCopy(int[] sourceArray, int[] targetArray, int nitems) {
    examplePINVOKE.myArrayCopy(sourceArray, targetArray, nitems);
}

If we look beneath the surface at the corresponding intermediary class code, we see that SWIG has generated code that uses attributes (from the System.Runtime.InteropServices namespace) to tell the CLR to use default marshalling for the arrays:

[global::System.Runtime.InteropServices.DllImport("example", EntryPoint="CSharp_myArrayCopy")]
public static extern void myArrayCopy([global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPArray)]int[] jarg1, 
                                      [global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPArray)]int[] jarg2,
                                       int jarg3);

As an example of passing an inout array (i.e. the target function will both read from and write to the array), consider this C function that swaps a given number of elements in the given arrays:

void myArraySwap(int *array1, int *array2, int nitems);

Now, we can instruct SWIG to wrap this by

%include "arrays_csharp.i"

%apply int INOUT[] {int *array1}
%apply int INOUT[] {int *array2}

This results in the module class method

  public static void myArraySwap(int[] array1, int[] array2, int nitems) {
    examplePINVOKE.myArraySwap(array1, array2, nitems);
  }

and intermediary class method

  [global::System.Runtime.InteropServices.DllImport("example", EntryPoint="CSharp_myArraySwap")]
  public static extern void myArraySwap([global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPArray)]int[] jarg1, 
                                        [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPArray)]int[] jarg2,
                                         int jarg3);

20.4.3 Managed arrays using pinning

It is also possible to pin a given array in memory (i.e. fix its location in memory), obtain a direct pointer to it, and then pass this pointer to the wrapped C/C++ function. This approach involves no copying, but it makes the work of the garbage collector harder as the managed array object can not be relocated before the fix on the array is released. You should avoid fixing arrays in memory in cases where the control may re-enter the managed side via a callback and/or another thread may produce enough garbage to trigger garbage collection.

For more information, see the fixed statement in the C# language reference.

Now let's look at an example using pinning, thus avoiding the CLR making copies of the arrays passed as parameters. The arrays_csharp.i library file again provides the required support via the FIXED typemaps. Let's use the same function from the previous section:

void myArrayCopy(int *sourceArray, int *targetArray, int nitems);

We now need to declare the module class method unsafe, as we are using pointers:

%csmethodmodifiers myArrayCopy "public unsafe";
 

Apply the appropriate typemaps to the array parameters:

%include "arrays_csharp.i"

%apply int FIXED[] {int *sourceArray}
%apply int FIXED[] {int *targetArray}

Notice that there is no need for separate in, out or inout typemaps as is the case when using P/Invoke default marshalling.

As a result, we get the following method in the module class:

  public unsafe static void myArrayCopy(int[] sourceArray, int[] targetArray, int nitems) {
    fixed ( int *swig_ptrTo_sourceArray = sourceArray ) {
    fixed ( int *swig_ptrTo_targetArray = targetArray ) {
    {
      examplePINVOKE.myArrayCopy((global::System.IntPtr)swig_ptrTo_sourceArray, (global::System.IntPtr)swig_ptrTo_targetArray,
                                 nitems);
    }
    }
    }
  }

On the method signature level the only difference to the version using P/Invoke default marshalling is the "unsafe" quantifier, which is required because we are handling pointers.

Also the intermediary class method looks a little different from the default marshalling example - the method is expecting an IntPtr as the parameter type.

[global::System.Runtime.InteropServices.DllImport("example", EntryPoint="CSharp_myArrayCopy")]
public static extern void myArrayCopy(global::System.IntPtr jarg1, global::System.IntPtr jarg2, int jarg3);

20.5 C# Exceptions

It is possible to throw a C# Exception from C/C++ code. SWIG already provides the framework for throwing C# exceptions if it is able to detect that a C++ exception could be thrown. Automatically detecting that a C++ exception could be thrown is only possible when a C++ exception specification is used, see Exception specifications. The Exception handling with %exception section details the %exception feature. Customised code for handling exceptions with or without a C++ exception specification is possible and the details follow. However anyone wishing to do this should be familiar with the contents of the sections referred to above.

Unfortunately a C# exception cannot simply be thrown from unmanaged code for a variety of reasons. Most notably being that throwing a C# exception results in exceptions being thrown across the C PInvoke interface and C does not understand exceptions. The design revolves around a C# exception being constructed and stored as a pending exception, to be thrown only when the unmanaged code has completed. Implementing this is a tad involved and there are thus some unusual typemap constructs. Some practical examples follow and they should be read in conjunction with the rest of this section.

First some details about the design that must be followed. Each typemap or feature that generates unmanaged code supports an attribute called canthrow. This is simply a flag which when set indicates that the code in the typemap/feature has code which might want to throw a C# exception. The code in the typemap/feature can then raise a C# exception by calling one of the C functions, SWIG_CSharpSetPendingException() or SWIG_CSharpSetPendingExceptionArgument(). When called, the function makes a callback into the managed world via a delegate. The callback creates and stores an exception ready for throwing when the unmanaged code has finished. The typemap/feature unmanaged code is then expected to force an immediate return from the unmanaged wrapper function, so that the pending managed exception can then be thrown. The support code has been carefully designed to be efficient as well as thread-safe. However to achieve the goal of efficiency requires some optional code generation in the managed code typemaps. Code to check for pending exceptions is generated if and only if the unmanaged code has code to set a pending exception, that is if the canthrow attribute is set. The optional managed code is generated using the excode typemap attribute and $excode special variable in the relevant managed code typemaps. Simply, if any relevant unmanaged code has the canthrow attribute set, then any occurrences of $excode is replaced with the code in the excode attribute. If the canthrow attribute is not set, then any occurrences of $excode are replaced with nothing.

The prototypes for the SWIG_CSharpSetPendingException() and SWIG_CSharpSetPendingExceptionArgument() functions are

static void SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code,
                                           const char *msg);

static void SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code,
                                                   const char *msg,
                                                   const char *param_name);

The first parameter defines which .NET exceptions can be thrown:

typedef enum {
  SWIG_CSharpApplicationException,
  SWIG_CSharpArithmeticException,
  SWIG_CSharpDivideByZeroException,
  SWIG_CSharpIndexOutOfRangeException,
  SWIG_CSharpInvalidCastException,
  SWIG_CSharpInvalidOperationException,
  SWIG_CSharpIOException,
  SWIG_CSharpNullReferenceException,
  SWIG_CSharpOutOfMemoryException,
  SWIG_CSharpOverflowException,
  SWIG_CSharpSystemException
} SWIG_CSharpExceptionCodes;

typedef enum {
  SWIG_CSharpArgumentException,
  SWIG_CSharpArgumentNullException,
  SWIG_CSharpArgumentOutOfRangeException,
} SWIG_CSharpExceptionArgumentCodes;

where, for example, SWIG_CSharpApplicationException corresponds to the .NET exception, ApplicationException. The msg and param_name parameters contain the C# exception message and parameter name associated with the exception.

The %exception feature in C# has the canthrow attribute set. The %csnothrowexception feature is like %exception, but it does not have the canthrow attribute set so should only be used when a C# exception is not created.

20.5.1 C# exception example using "check" typemap

Let's say we have the following simple C++ method:

void positivesonly(int number);

and we want to check that the input number is always positive and if not throw a C# ArgumentOutOfRangeException. The "check" typemap is designed for checking input parameters. Below you will see the canthrow attribute is set because the code contains a call to SWIG_CSharpSetPendingExceptionArgument(). The full example follows:

%module example

%typemap(check, canthrow=1) int number %{
if ($1 < 0) {
  SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException,
                                         "only positive numbers accepted", "number");
  return $null;
}
// SWIGEXCODE is a macro used by many other csout typemaps
%define SWIGEXCODE
 "\n    if ($modulePINVOKE.SWIGPendingException.Pending)"
 "\n      throw $modulePINVOKE.SWIGPendingException.Retrieve();"
%enddef
%typemap(csout, excode=SWIGEXCODE) void {
    $imcall;$excode
  }
%}

%inline %{

void positivesonly(int number) {
}

%}

When the following C# code is executed:

public class runme {
    static void Main() {
      example.positivesonly(-1);
    }
}

The exception is thrown:

Unhandled Exception: System.ArgumentOutOfRangeException: only positive numbers accepted
Parameter name: number
in <0x00034> example:positivesonly (int)
in <0x0000c> runme:Main ()

Now let's analyse the generated code to gain a fuller understanding of the typemaps. The generated unmanaged C++ code is:

SWIGEXPORT void SWIGSTDCALL CSharp_positivesonly(int jarg1) {
    int arg1 ;
    
    arg1 = (int)jarg1; 
    
    if (arg1 < 0) {
        SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException,
                                               "only positive numbers accepted", "number");
        return ;
    }
    
    positivesonly(arg1);
    
}

This largely comes from the "check" typemap. The managed code in the module class is:

public class example {
  public static void positivesonly(int number) {
    examplePINVOKE.positivesonly(number);
    if (examplePINVOKE.SWIGPendingException.Pending)
      throw examplePINVOKE.SWIGPendingException.Retrieve();
  }

}

This comes largely from the "csout" typemap.

The "csout" typemap is the same as the default void "csout" typemap so is not strictly necessary for the example. However, it is shown to demonstrate what managed output code typemaps should contain, that is, a $excode special variable and an excode attribute. Also note that $excode is expanded into the code held in the excode attribute. The $imcall as always expands into examplePINVOKE.positivesonly(number). The exception support code in the intermediary class, examplePINVOKE, is not shown, but is contained within the inner classes, SWIGPendingException and SWIGExceptionHelper and is always generated. These classes can be seen in any of the generated wrappers. However, all that is required of a user is as demonstrated in the "csin" typemap above. That is, is to check SWIGPendingException.Pending and to throw the exception returned by SWIGPendingException.Retrieve().

If the "check" typemap did not exist, then the following module class would instead be generated:

public class example {
  public static void positivesonly(int number) {
    examplePINVOKE.positivesonly(number);
  }

}

Here we see the pending exception checking code is omitted. In fact, the code above would be generated if the canthrow attribute was not in the "check" typemap, such as:

%typemap(check) int number %{
if ($1 < 0) {
  SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException,
                                         "only positive numbers accepted", "number");
  return $null;
}
%}

Note that if SWIG detects you have used SWIG_CSharpSetPendingException() or SWIG_CSharpSetPendingExceptionArgument() without setting the canthrow attribute you will get a warning message similar to

example.i:21: Warning 845: Unmanaged code contains a call to a SWIG_CSharpSetPendingException
method and C# code does not handle pending exceptions via the canthrow attribute.

Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.

20.5.2 C# exception example using %exception

Let's consider a similar, but more common example that throws a C++ exception from within a wrapped function. We can use %exception as mentioned in Exception handling with %exception.

%exception negativesonly(int value) %{
try {
  $action
} catch (std::out_of_range e) {
  SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, e.what());
}
%}

%inline %{
#include <stdexcept>
void negativesonly(int value) {
  if (value >= 0)
    throw std::out_of_range("number should be negative");
}
%}

The generated unmanaged code this time catches the C++ exception and converts it into a C# ApplicationException.

SWIGEXPORT void SWIGSTDCALL CSharp_negativesonly(int jarg1) {
    int arg1 ;
    
    arg1 = (int)jarg1; 
    
    try {
        negativesonly(arg1);
        
    } catch (std::out_of_range e) {
        SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, e.what());
        return ;
    }
    
}

The managed code generated does check for the pending exception as mentioned earlier as the C# version of %exception has the canthrow attribute set by default:

  public static void negativesonly(int value) {
    examplePINVOKE.negativesonly(value);
    if (examplePINVOKE.SWIGPendingException.Pending)
      throw examplePINVOKE.SWIGPendingException.Retrieve();
  }

20.5.3 C# exception example using exception specifications

When C++ exception specifications are used, SWIG is able to detect that the method might throw an exception. By default SWIG will automatically generate code to catch the exception and convert it into a managed ApplicationException, as defined by the default "throws" typemaps. The following example has a user supplied "throws" typemap which is used whenever an exception specification contains a std::out_of_range, such as the evensonly method below.

%typemap(throws, canthrow=1) std::out_of_range {
  SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentException, $1.what(), NULL);
  return $null;
}

%inline %{
#include <stdexcept>
void evensonly(int input) throw (std::out_of_range) {
  if (input%2 != 0)
    throw std::out_of_range("number is not even");
}
%}

Note that the type for the throws typemap is the type in the exception specification. SWIG generates a try catch block with the throws typemap code in the catch handler.

SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) {
    int arg1 ;
    
    arg1 = (int)jarg1; 
    try {
        evensonly(arg1);
    }
    catch(std::out_of_range &_e) {
      {
          SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentException, (&_e)->what(), NULL);
          return ;
      }
    }
    
}

Multiple catch handlers are generated should there be more than one exception specifications declared.

20.5.4 Custom C# ApplicationException example

This example involves a user defined exception. The conventional .NET exception handling approach is to create a custom ApplicationException and throw it in your application. The goal in this example is to convert the STL std::out_of_range exception into one of these custom .NET exceptions.

The default exception handling is quite easy to use as the SWIG_CSharpSetPendingException() and SWIG_CSharpSetPendingExceptionArgument() methods are provided by SWIG. However, for a custom C# exception, the boiler plate code that supports these functions needs replicating. In essence this consists of some C/C++ code and C# code. The C/C++ code can be generated into the wrapper file using the %insert(runtime) directive and the C# code can be generated into the intermediary class using the imclasscode pragma as follows:

%insert(runtime) %{
  // Code to handle throwing of C# CustomApplicationException from C/C++ code.
  // The equivalent delegate to the callback, CSharpExceptionCallback_t, is CustomExceptionDelegate
  // and the equivalent customExceptionCallback instance is customDelegate
  typedef void (SWIGSTDCALL* CSharpExceptionCallback_t)(const char *);
  CSharpExceptionCallback_t customExceptionCallback = NULL;

  extern "C" SWIGEXPORT
  void SWIGSTDCALL CustomExceptionRegisterCallback(CSharpExceptionCallback_t customCallback) {
    customExceptionCallback = customCallback;
  }

  // Note that SWIG detects any method calls named starting with
  // SWIG_CSharpSetPendingException for warning 845
  static void SWIG_CSharpSetPendingExceptionCustom(const char *msg) {
    customExceptionCallback(msg);
  }
%}

%pragma(csharp) imclasscode=%{
  class CustomExceptionHelper {
    // C# delegate for the C/C++ customExceptionCallback
    public delegate void CustomExceptionDelegate(string message);
    static CustomExceptionDelegate customDelegate =
                                   new CustomExceptionDelegate(SetPendingCustomException);

    [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="CustomExceptionRegisterCallback")]
    public static extern
           void CustomExceptionRegisterCallback(CustomExceptionDelegate customCallback);

    static void SetPendingCustomException(string message) {
      SWIGPendingException.Set(new CustomApplicationException(message));
    }

    static CustomExceptionHelper() {
      CustomExceptionRegisterCallback(customDelegate);
    }
  }
  static CustomExceptionHelper exceptionHelper = new CustomExceptionHelper();
%}

The method stored in the C# delegate instance, customDelegate is what gets called by the C/C++ callback. However, the equivalent to the C# delegate, that is the C/C++ callback, needs to be assigned before any unmanaged code is executed. This is achieved by putting the initialisation code in the intermediary class. Recall that the intermediary class contains all the PInvoke methods, so the static variables in the intermediary class will be initialised before any of the PInvoke methods in this class are called. The exceptionHelper static variable ensures the C/C++ callback is initialised with the value in customDelegate by calling the CustomExceptionRegisterCallback method in the CustomExceptionHelper static constructor. Once this has been done, unmanaged code can make callbacks into the managed world as customExceptionCallback will be initialised with a valid callback/delegate. Any calls to SWIG_CSharpSetPendingExceptionCustom() will make the callback to create the pending exception in the same way that SWIG_CSharpSetPendingException() and SWIG_CSharpSetPendingExceptionArgument() does. In fact the method has been similarly named so that SWIG can issue the warning about missing canthrow attributes as discussed earlier. It is an invaluable warning as it is easy to forget the canthrow attribute when writing typemaps/features.

The SWIGPendingException helper class is not shown, but is generated as an inner class into the intermediary class. It stores the pending exception in Thread Local Storage so that the exception handling mechanism is thread safe.

The boiler plate code above must be used in addition to a handcrafted CustomApplicationException:

// Custom C# Exception
class CustomApplicationException : global::System.ApplicationException {
  public CustomApplicationException(string message) 
    : base(message) {
  }
}

and the SWIG interface code:

%typemap(throws, canthrow=1) std::out_of_range {
  SWIG_CSharpSetPendingExceptionCustom($1.what());
  return $null;
}

%inline %{
void oddsonly(int input) throw (std::out_of_range) {
  if (input%2 != 1)
    throw std::out_of_range("number is not odd");
}
%}

The "throws" typemap now simply calls our new SWIG_CSharpSetPendingExceptionCustom() function so that the exception can be caught, as such:

try {
  example.oddsonly(2);
} catch (CustomApplicationException e) {
  ...
}

20.6 C# Directors

The SWIG directors feature adds extra code to the generated C# proxy classes that enable these classes to be used in cross-language polymorphism. Essentially, it enables unmanaged C++ code to call back into managed code for virtual methods so that a C# class can derive from a wrapped C++ class.

The following sections provide information on the C# director implementation and contain most of the information required to use the C# directors. However, the Java directors section should also be read in order to gain more insight into directors.

20.6.1 Directors example

Imagine we are wrapping a C++ base class, Base, from which we would like to inherit in C#. Such a class is shown below as well as another class, Caller, which calls the virtual method UIntMethod from pure unmanaged C++ code.

// file: example.h
class Base {
public:
  virtual ~Base() {}

  virtual unsigned int UIntMethod(unsigned int x) {
    std::cout << "Base - UIntMethod(" << x << ")" << std::endl;
    return x;
  }
  virtual void BaseBoolMethod(const Base &b, bool flag) {}
};

class Caller {
public:
  Caller(): m_base(0) {}
  ~Caller() { delBase(); }
  void set(Base *b) { delBase(); m_base = b; }
  void reset() { m_base = 0; }
  unsigned int UIntMethodCall(unsigned int x) { return m_base->UIntMethod(x); }

private:
  Base *m_base;
  void delBase() { delete m_base; m_base = 0; }
};

The director feature is turned off by default and the following simple interface file shows how directors are enabled for the class Base.

/* File : example.i */
%module(directors="1") example
%{
#include "example.h"
%}

%feature("director") Base;

%include "example.h"

The following is a C# class inheriting from Base:

public class CSharpDerived : Base
{
  public override uint UIntMethod(uint x)
  {
    Console.WriteLine("CSharpDerived - UIntMethod({0})", x);
    return x;
  }
}

The Caller class can demonstrate the UIntMethod method being called from unmanaged code using the following C# code:

public class runme
{
  static void Main() 
  {
    Caller myCaller = new Caller();

    // Test pure C++ class
    using (Base myBase = new Base())
    {
      makeCalls(myCaller, myBase);
    }

    // Test director / C# derived class
    using (Base myBase = new CSharpDerived())
    {
      makeCalls(myCaller, myBase);
    }
  }

  static void makeCalls(Caller myCaller, Base myBase)
  {
    myCaller.set(myBase);
    myCaller.UIntMethodCall(123);
    myCaller.reset();
  }
}

If the above is run, the output is then:

Base - UIntMethod(123)
CSharpDerived - UIntMethod(123)

20.6.2 Directors implementation

The previous section demonstrated a simple example where the virtual UIntMethod method was called from C++ code, even when the overridden method is implemented in C#. The intention of this section is to gain an insight into how the director feature works. It shows the generated code for the two virtual methods, UIntMethod and BaseBoolMethod, when the director feature is enabled for the Base class.

Below is the generated C# Base director class.

public class Base : global::System.IDisposable {
  private global::System.Runtime.InteropServices.HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal Base(global::System.IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
  }

  internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Base obj) {
    return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
  }

  ~Base() {
    Dispose();
  }

  public virtual void Dispose() {
    lock(this) {
      if(swigCPtr.Handle != global::System.IntPtr.Zero && swigCMemOwn) {
        swigCMemOwn = false;
        examplePINVOKE.delete_Base(swigCPtr);
      }
      swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
      global::System.GC.SuppressFinalize(this);
    }
  }

  public virtual uint UIntMethod(uint x) {
    uint ret = examplePINVOKE.Base_UIntMethod(swigCPtr, x);
    return ret;
  }

  public virtual void BaseBoolMethod(Base b, bool flag) {
    examplePINVOKE.Base_BaseBoolMethod(swigCPtr, Base.getCPtr(b), flag);
    if (examplePINVOKE.SWIGPendingException.Pending)
      throw examplePINVOKE.SWIGPendingException.Retrieve();
  }

  public Base() : this(examplePINVOKE.new_Base(), true) {
    SwigDirectorConnect();
  }

  private void SwigDirectorConnect() {
    if (SwigDerivedClassHasMethod("UIntMethod", swigMethodTypes0))
      swigDelegate0 = new SwigDelegateBase_0(SwigDirectorUIntMethod);
    if (SwigDerivedClassHasMethod("BaseBoolMethod", swigMethodTypes1))
      swigDelegate1 = new SwigDelegateBase_1(SwigDirectorBaseBoolMethod);
    examplePINVOKE.Base_director_connect(swigCPtr, swigDelegate0, swigDelegate1);
  }

  private bool SwigDerivedClassHasMethod(string methodName, global::System.global::System.Type[] methodTypes) {
    System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, methodTypes);
    bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(Base));
    return hasDerivedMethod;
  }

  private uint SwigDirectorUIntMethod(uint x) {
    return UIntMethod(x);
  }

  private void SwigDirectorBaseBoolMethod(global::System.IntPtr b, bool flag) {
    BaseBoolMethod(new Base(b, false), flag);
  }

  internal delegate uint SwigDelegateBase_0(uint x);
  internal delegate void SwigDelegateBase_1(global::System.IntPtr b, bool flag);

  private SwigDelegateBase_0 swigDelegate0;
  private SwigDelegateBase_1 swigDelegate1;

  private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { typeof(uint) };
  private static global::System.Type[] swigMethodTypes1 = new global::System.Type[] { typeof(Base), typeof(bool) };
}

Everything from the SwigDirectorConnect() method and below is code that is only generated when directors are enabled. The design comprises a C# delegate being initialised for each virtual method on construction of the class. Let's examine the BaseBoolMethod.

In the Base constructor a call is made to SwigDirectorConnect() which contains the initialisation code for all the virtual methods. It uses a support method, SwigDerivedClassHasMethod(), which simply uses reflection to determine if the named method, BaseBoolMethod, with the list of required parameter types, exists in a subclass. If it does not exist, the delegate is not initialised as there is no need for unmanaged code to call back into managed C# code. However, if there is an overridden method in any subclass, the delegate is required. It is then initialised to the SwigDirectorBaseBoolMethod which in turn will call BaseBoolMethod if invoked. The delegate is not initialised to the BaseBoolMethod directly as quite often types will need marshalling from the unmanaged type to the managed type in which case an intermediary method (SwigDirectorBaseBoolMethod ) is required for the marshalling. In this case, the C# Base class needs to be created from the unmanaged IntPtr type.

The last thing that SwigDirectorConnect() does is to pass the delegates to the unmanaged code. It calls the intermediary method Base_director_connect() which is really a call to the C function CSharp_Base_director_connect(). This method simply maps each C# delegate onto a C function pointer.

SWIGEXPORT void SWIGSTDCALL CSharp_Base_director_connect(void *objarg, 
                                        SwigDirector_Base::SWIG_Callback0_t callback0,
                                        SwigDirector_Base::SWIG_Callback1_t callback1) {
  Base *obj = (Base *)objarg;
  SwigDirector_Base *director = dynamic_cast<SwigDirector_Base *>(obj);
  if (director) {
    director->swig_connect_director(callback0, callback1);
  }
}

class SwigDirector_Base : public Base, public Swig::Director {
public:
    SwigDirector_Base();
    virtual unsigned int UIntMethod(unsigned int x);
    virtual ~SwigDirector_Base();
    virtual void BaseBoolMethod(Base const &b, bool flag);

    typedef unsigned int (SWIGSTDCALL* SWIG_Callback0_t)(unsigned int);
    typedef void (SWIGSTDCALL* SWIG_Callback1_t)(void *, unsigned int);
    void swig_connect_director(SWIG_Callback0_t callbackUIntMethod, 
                               SWIG_Callback1_t callbackBaseBoolMethod);

private:
    SWIG_Callback0_t swig_callbackUIntMethod;
    SWIG_Callback1_t swig_callbackBaseBoolMethod;
    void swig_init_callbacks();
};

void SwigDirector_Base::swig_connect_director(SWIG_Callback0_t callbackUIntMethod, 
                                              SWIG_Callback1_t callbackBaseBoolMethod) {
  swig_callbackUIntMethod = callbackUIntMethod;
  swig_callbackBaseBoolMethod = callbackBaseBoolMethod;
}

Note that for each director class SWIG creates an unmanaged director class for making the callbacks. For example Base has SwigDirector_Base and SwigDirector_Base is derived from Base. Should a C# class be derived from Base, the underlying C++ SwigDirector_Base is created rather than Base. The SwigDirector_Base class then implements all the virtual methods, redirecting calls up to managed code if the callback/delegate is non-zero. The implementation of SwigDirector_Base::BaseBoolMethod shows this - the callback is made by invoking the swig_callbackBaseBoolMethod function pointer:

void SwigDirector_Base::BaseBoolMethod(Base const &b, bool flag) {
  void * jb = 0 ;
  unsigned int jflag  ;
  
  if (!swig_callbackBaseBoolMethod) {
    Base::BaseBoolMethod(b,flag);
    return;
  } else {
    jb = (Base *) &b; 
    jflag = flag;
    swig_callbackBaseBoolMethod(jb, jflag);
  }
}

20.6.3 Director caveats

There is a subtle gotcha with directors. If default parameters are used, it is recommended to follow a pattern of always calling a single method in any C# derived class. An example will clarify this and the reasoning behind the recommendation. Consider the following C++ class wrapped as a director class:

class Defaults {
public:
  virtual ~Defaults();
  virtual void DefaultMethod(int a=-100);
};

Recall that C++ methods with default parameters generate overloaded methods for each defaulted parameter, so a C# derived class can be created with two DefaultMethod override methods:

public class CSharpDefaults : Defaults
{
  public override void DefaultMethod()
  {
    DefaultMethod(-100); // note C++ default value used
  }
  public override void DefaultMethod(int x)
  {
  }
}

It may not be clear at first, but should a user intend to call CSharpDefaults.DefaultMethod() from C++, a call is actually made to CSharpDefaults.DefaultMethod(int). This is because the initial call is made in C++ and therefore the DefaultMethod(int) method will be called as is expected with C++ calls to methods with defaults, with the default being set to -100. The callback/delegate matching this method is of course the overloaded method DefaultMethod(int). However, a call from C# to CSharpDefaults.DefaultMethod() will of course call this exact method and in order for behaviour to be consistent with calls from C++, the implementation should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.

20.7 Multiples modules

When using multiple modules it is is possible to compile each SWIG generated wrapper into a different assembly. However, by default the generated code may not compile if generated classes in one assembly use generated classes in another assembly. The visibility of the getCPtr() and pointer constructor generated from the csbody typemaps needs changing. The default visibility is internal but it needs to be public for access from a different assembly. Just changing 'internal' to 'public' in the typemap achieves this. Two macros are available in csharp.swg to make this easier and using them is the preferred approach over simply copying the typemaps and modifying as this is forward compatible with any changes in the csbody typemap in future versions of SWIG. The macros are for the proxy and typewrapper classes and can respectively be used to to make the method and constructor public:

  SWIG_CSBODY_PROXY(public, public, SWIGTYPE)
  SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE)

Alternatively, instead of exposing these as public, consider using the [assembly:InternalsVisibleTo("Name")] attribute available in the .NET framework when you know which assemblies these can be exposed to. Another approach would be to make these public, but also to hide them from intellisense by using the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] attribute if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.

20.8 C# Typemap examples

This section includes a few examples of typemaps. For more examples, you might look at the files "csharp.swg" and "typemaps.i " in the SWIG library.

20.8.1 Memory management when returning references to member variables

This example shows how to prevent premature garbage collection of objects when the underlying C++ class returns a pointer or reference to a member variable. The example is a direct equivalent to this Java equivalent.

Consider the following C++ code:

struct Wheel {
  int size;
  Wheel(int sz) : size(sz) {}
};

class Bike {
  Wheel wheel;
public:
  Bike(int val) : wheel(val) {}
  Wheel& getWheel() { return wheel; }
};

and the following usage from C# after running the code through SWIG:

      Wheel wheel = new Bike(10).getWheel();
      Console.WriteLine("wheel size: " + wheel.size);
      // Simulate a garbage collection
      global::System.GC.Collect();
      global::System.GC.WaitForPendingFinalizers();
      global::System.Console.WriteLine("wheel size: " + wheel.size);

Don't be surprised that if the resulting output gives strange results such as...

wheel size: 10
wheel size: 135019664

What has happened here is the garbage collector has collected the Bike instance as it doesn't think it is needed any more. The proxy instance, wheel, contains a reference to memory that was deleted when the Bike instance was collected. In order to prevent the garbage collector from collecting the Bike instance a reference to the Bike must be added to the wheel instance. You can do this by adding the reference when the getWheel() method is called using the following typemaps.

%typemap(cscode) Wheel %{
  // Ensure that the GC doesn't collect any Bike instance set from C#
  private Bike bikeReference;
  internal void addReference(Bike bike) {
    bikeReference = bike;
  }
%}

// Add a C# reference to prevent premature garbage collection and resulting use
// of dangling C++ pointer. Intended for methods that return pointers or
// references to a member variable.
%typemap(csout, excode=SWIGEXCODE) Wheel& getWheel {
    global::System.IntPtr cPtr = $imcall;$excode
    $csclassname ret = null;
    if (cPtr != global::System.IntPtr.Zero) {
      ret = new $csclassname(cPtr, $owner);
      ret.addReference(this);
    }
    return ret;
  }

The code in the first typemap gets added to the Wheel proxy class. The code in the second typemap constitutes the bulk of the code in the generated getWheel() function:

public class Wheel : global::System.IDisposable {
  ...
  // Ensure that the GC doesn't collect any Bike instance set from C#
  private Bike bikeReference;
  internal void addReference(Bike bike) {
    bikeReference = bike;
  }
}

public class Bike : global::System.IDisposable {
  ...
  public Wheel getWheel() {
    global::System.IntPtr cPtr = examplePINVOKE.Bike_getWheel(swigCPtr);
    Wheel ret = null;
    if (cPtr != global::System.IntPtr.Zero) {
      ret = new Wheel(cPtr, false);
      ret.addReference(this);
    }
    return ret;
  }
}

Note the addReference call.

20.8.2 Memory management for objects passed to the C++ layer

The example is a direct equivalent to this Java equivalent. Managing memory can be tricky when using C++ and C# proxy classes. The previous example shows one such case and this example looks at memory management for a class passed to a C++ method which expects the object to remain in scope after the function has returned. Consider the following two C++ classes:

struct Element {
  int value;
  Element(int val) : value(val) {}
};
class Container {
  Element* element;
public:
  Container() : element(0) {}
  void setElement(Element* e) { element = e; }
  Element* getElement() { return element; }
};

and usage from C++

    Container container;
    Element element(20);
    container.setElement(&element);
    cout << "element.value: " << container.getElement()->value << endl;

and more or less equivalent usage from C#

      Container container = new Container();
      Element element = new Element(20);
      container.setElement(element);

The C++ code will always print out 20, but the value printed out may not be this in the C# equivalent code. In order to understand why, consider a garbage collection occuring...

      Container container = new Container();
      Element element = new Element(20);
      container.setElement(element);
      Console.WriteLine("element.value: " + container.getElement().value);
      // Simulate a garbage collection
      global::System.GC.Collect();
      global::System.GC.WaitForPendingFinalizers();
      global::System.Console.WriteLine("element.value: " + container.getElement().value);

The temporary element created with new Element(20) could get garbage collected which ultimately means the container variable is holding a dangling pointer, thereby printing out any old random value instead of the expected value of 20. One solution is to add in the appropriate references in the C# layer...

public class Container : global::System.IDisposable {

  ...

  // Ensure that the GC doesn't collect any Element set from C#
  // as the underlying C++ class stores a shallow copy
  private Element elementReference;
  private global::System.Runtime.InteropServices.HandleRef getCPtrAndAddReference(Element element) {
    elementReference = element;
    return Element.getCPtr(element);
  }

  public void setElement(Element e) {
    examplePINVOKE.Container_setElement(swigCPtr, getCPtrAndAddReference(e));
  }
}

The following typemaps will generate the desired code. The 'csin' typemap matches the input parameter type for the setElement method. The 'cscode' typemap simply adds in the specified code into the C# proxy class.

%typemap(csin) Element *e "getCPtrAndAddReference($csinput)"

%typemap(cscode) Container %{
  // Ensure that the GC doesn't collect any Element set from C#
  // as the underlying C++ class stores a shallow copy
  private Element elementReference;
  private global::System.Runtime.InteropServices.HandleRef getCPtrAndAddReference(Element element) {
    elementReference = element;
    return Element.getCPtr(element);
  }
%}

20.8.3 Date marshalling using the csin typemap and associated attributes

The NaN Exception example is a simple example of the "javain" typemap and its 'pre' attribute. This example demonstrates how a C++ date class, say CDate, can be mapped onto the standard .NET date class, System.DateTime by using the 'pre', 'post' and 'pgcppname' attributes of the "csin" typemap (the C# equivalent to the "javain" typemap). The example is an equivalent to the Java Date marshalling example. The idea is that the System.DateTime is used wherever the C++ API uses a CDate. Let's assume the code being wrapped is as follows:

class CDate {
public:
  CDate();
  CDate(int year, int month, int day);
  int getYear();
  int getMonth();
  int getDay();
  ...
};
struct Action {
  static int doSomething(const CDate &dateIn, CDate &dateOut);
  Action(const CDate &date, CDate &dateOut);
};

Note that dateIn is const and therefore read only and dateOut is a non-const output type.

First let's look at the code that is generated by default, where the C# proxy class CDate is used in the proxy interface:

public class Action : global::System.IDisposable {
  ...
  public Action(CDate dateIn, CDate dateOut) 
      : this(examplePINVOKE.new_Action(CDate.getCPtr(dateIn), CDate.getCPtr(dateOut)), true) {
    if (examplePINVOKE.SWIGPendingException.Pending) 
      throw examplePINVOKE.SWIGPendingException.Retrieve();
  }

  public int doSomething(CDate dateIn, CDate dateOut) {
    int ret = examplePINVOKE.Action_doSomething(swigCPtr, 
                                                CDate.getCPtr(dateIn), 
                                                CDate.getCPtr(dateOut));
    if (examplePINVOKE.SWIGPendingException.Pending) 
      throw examplePINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }
}

The CDate & and const CDate & C# code is generated from the following two default typemaps:

%typemap(cstype) SWIGTYPE & "$csclassname"
%typemap(csin) SWIGTYPE & "$csclassname.getCPtr($csinput)"

where '$csclassname' is translated into the proxy class name, CDate and '$csinput' is translated into the name of the parameter, eg dateIn. From C#, the intention is then to call into a modifed API with something like:

System.DateTime dateIn = new System.DateTime(2011, 4, 13);
System.DateTime dateOut = new System.DateTime();

// Note in calls below, dateIn remains unchanged and dateOut 
// is set to a new value by the C++ call
Action action = new Action(dateIn, out dateOut);
dateIn = new System.DateTime(2012, 7, 14);

To achieve this mapping, we need to alter the default code generation slightly so that at the C# layer, a System.DateTime is converted into a CDate. The intermediary layer will still take a pointer to the underlying CDate class. The typemaps to achieve this are shown below.

%typemap(cstype) const CDate & "System.DateTime"
%typemap(csin, 
         pre="    CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
        ) const CDate &
         "$csclassname.getCPtr(temp$csinput)"

%typemap(cstype) CDate & "out System.DateTime"
%typemap(csin, 
         pre="    CDate temp$csinput = new CDate();", 
         post="      $csinput = new System.DateTime(temp$csinput.getYear(),"
              " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", 
         cshin="out $csinput"
        ) CDate &
         "$csclassname.getCPtr(temp$csinput)"

The resulting generated proxy code in the Action class follows:

public class Action : global::System.IDisposable {
  ...
  public int doSomething(System.DateTime dateIn, out System.DateTime dateOut) {
    CDate tempdateIn = new CDate(dateIn.Year, dateIn.Month, dateIn.Day);
    CDate tempdateOut = new CDate();
    try {
      int ret = examplePINVOKE.Action_doSomething(swigCPtr, 
                                                  CDate.getCPtr(tempdateIn), 
                                                  CDate.getCPtr(tempdateOut));
      if (examplePINVOKE.SWIGPendingException.Pending) 
        throw examplePINVOKE.SWIGPendingException.Retrieve();
      return ret;
    } finally {
      dateOut = new System.DateTime(tempdateOut.getYear(), 
                                    tempdateOut.getMonth(), tempdateOut.getDay(), 0, 0, 0);
    }
  }

  static private global::System.IntPtr SwigConstructAction(System.DateTime dateIn, out System.DateTime dateOut) {
    CDate tempdateIn = new CDate(dateIn.Year, dateIn.Month, dateIn.Day);
    CDate tempdateOut = new CDate();
    try {
      return examplePINVOKE.new_Action(CDate.getCPtr(tempdateIn), CDate.getCPtr(tempdateOut));
    } finally {
      dateOut = new System.DateTime(tempdateOut.getYear(), 
                                    tempdateOut.getMonth(), tempdateOut.getDay(), 0, 0, 0);
    }
  }

  public Action(System.DateTime dateIn, out System.DateTime dateOut) 
      : this(Action.SwigConstructAction(dateIn, out dateOut), true) {
    if (examplePINVOKE.SWIGPendingException.Pending) 
      throw examplePINVOKE.SWIGPendingException.Retrieve();
  }
}

A few things to note:

  • The "cstype" typemap has changed the parameter type to System.DateTime instead of the default generated CDate proxy.
  • The non-const CDate & type is marshalled as a reference parameter in C# as the date cannot be explicitly set once the object has been created, so a new object is created instead.
  • The code in the 'pre' attribute appears before the intermediary call (examplePINVOKE.new_Action / examplePINVOKE.Action_doSomething).
  • The code in the 'post' attribute appears after the intermediary call.
  • A try .. finally block is generated with the intermediary call in the try block and 'post' code in the finally block. The alternative of just using a temporary variable for the return value from the intermediary call and the 'post' code being inserted before the return statement is not possible given that the intermediary call and method return comes from a single source (the "csout" typemap).
  • The temporary variables in the "csin" typemaps are called temp$csin, where "$csin" is replaced with the parameter name. "$csin" is used to mangle the variable name so that more than one CDate & type can be used as a parameter in a method, otherwise two or more local variables with the same name would be generated.
  • The use of the "csin" typemap causes a constructor helper function (SwigConstructAction) to be generated. This allows C# code to be called before the intermediary call made in the constructor initialization list.
  • The 'cshin' attribute is required for the SwigConstructAction constructor helper function so that the 2nd parameter is declared as out dateOut instead of just dateOut.

So far we have considered the date as an input only and an output only type. Now let's consider CDate * used as an input/output type. Consider the following C++ function which modifies the date passed in:

void addYears(CDate *pDate, int years) {
  *pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay());
}

If usage of CDate * commonly follows this input/output pattern, usage from C# like the following

System.DateTime christmasEve = new System.DateTime(2000, 12, 24);
example.addYears(ref christmasEve, 10); // christmasEve now contains 2010-12-24

will be possible with the following CDate * typemaps

%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime"

%typemap(csin,
         pre="    CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
         post="      $csinput = new System.DateTime(temp$csinput.getYear(),"
              " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", 
         cshin="ref $csinput"
        ) CDate *
         "$csclassname.getCPtr(temp$csinput)"

Globals are wrapped by the module class and for a module called example, the typemaps result in the following code:

public class example {
  public static void addYears(ref System.DateTime pDate, int years) {
    CDate temppDate = new CDate(pDate.Year, pDate.Month, pDate.Day);
    try {
      examplePINVOKE.addYears(CDate.getCPtr(temppDate), years);
    } finally {
      pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(),
                                  0, 0, 0);
    }
  }
  ...
}

The following typemap is the same as the previous but demonstrates how a using block can be used for the temporary variable. The only change to the previous typemap is the introduction of the 'terminator' attribute to terminate the using block. The subtractYears method is nearly identical to the above addYears method.

%typemap(csin,
  pre="    using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
  post="      $csinput = new System.DateTime(temp$csinput.getYear(),"
       " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", 
  terminator="    } // terminate temp$csinput using block",
  cshin="ref $csinput"
 ) CDate *
  "$csclassname.getCPtr(temp$csinput)"

void subtractYears(CDate *pDate, int years) {
  *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
}

The resulting generated code shows the termination of the using block:

public class example {
  public static void subtractYears(ref System.DateTime pDate, int years) {
    using (CDate temppDate = new CDate(pDate.Year, pDate.Month, pDate.Day)) {
    try {
      examplePINVOKE.subtractYears(CDate.getCPtr(temppDate), years);
    } finally {
      pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(),
                                  0, 0, 0);
    }
    } // terminate temppDate using block
  }
  ...
}

20.8.4 A date example demonstrating marshalling of C# properties

The previous section looked at converting a C++ date class to System.DateTime for parameters. This section extends this idea so that the correct marshalling is obtained when wrapping C++ variables. Consider the same CDate class from the previous section and a global variable:

CDate ImportantDate = CDate(1999, 12, 31);

The aim is to use System.DateTime from C# when accessing this date as shown in the following usage where the module name is 'example':

example.ImportantDate = new System.DateTime(2000, 11, 22);
System.DateTime importantDate = example.ImportantDate;
Console.WriteLine("Important date: " + importantDate);

When SWIG wraps a variable that is a class/struct/union, it is wrapped using a pointer to the type for the reasons given in Structure data members. The typemap type required is thus CDate *. Given that the previous section already designed CDate * typemaps, we'll use those same typemaps plus the 'csvarin' and 'csvarout' typemaps.

%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime"

%typemap(csin,
         pre="    CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
         post="      $csinput = new System.DateTime(temp$csinput.getYear(),"
              " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", 
         cshin="ref $csinput"
        ) CDate *
         "$csclassname.getCPtr(temp$csinput)"

%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
    /* csvarin typemap code */
    set {
      CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);
      $imcall;$excode
    } %}

%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{
    /* csvarout typemap code */
    get {
      global::System.IntPtr cPtr = $imcall;
      CDate tempDate = (cPtr == global::System.IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode
      return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(),
                                 0, 0, 0);
    } %}

For a module called example, the typemaps result in the following code:

public class example {
  public static System.DateTime ImportantDate {
    /* csvarin typemap code */
    set {
      CDate tempvalue = new CDate(value.Year, value.Month, value.Day);
      examplePINVOKE.ImportantDate_set(CDate.getCPtr(tempvalue));
    } 
    /* csvarout typemap code */
    get {
      global::System.IntPtr cPtr = examplePINVOKE.ImportantDate_get();
      CDate tempDate = (cPtr == global::System.IntPtr.Zero) ? null : new CDate(cPtr, false);
      return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(),
                                 0, 0, 0);
    } 
  }
  ...
}

Some points to note:

  • The property set comes from the 'csvarin' typemap and the property get comes from the 'csvarout' typemap.
  • The type used for the property comes from the 'cstype' typemap. This particular example has the 'out' attribute set in the typemap and as it is specified, it is used in preference to the type in the typemap body. This is because the type in the 'out' attribute can never include modifiers such as 'ref', thereby avoiding code such as public static ref System.DateTime ImportantDate { ..., which would of course not compile.
  • The $excode special variable expands to nothing as there are no exception handlers specified in any of the unmanaged code typemaps (in fact the marshalling was done using the default unmanaged code typemaps.)
  • The $imcall typemap expands to the appropriate intermediary method call in the examplePINVOKE class.
  • The $csinput special variable in the 'csin' typemap always expands to value for properties. In this case $csclassname.getCPtr(temp$csinput) expands to CDate.getCPtr(tempvalue).
  • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute.

20.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

The 'pre' and 'post' attributes in the "csdirectorin" typemap act like the attributes of the same name in the "csin" typemap. For example if we modify the Date marshalling example like this:

class CDate {
  ...
  void setYear(int);
  void setMonth(int);
  void setDay(int);
};
struct Action {
  virtual void someCallback(CDate &date);
  virtual ~Action();
  ...
};

and declare %feature ("director") for the Action class, we would have to define additional marshalling rules for CDate & parameter. The typemap may look like this:

%typemap(csdirectorin,
         pre="System.DateTime temp$iminput = new System.DateTime();",
         post="CDate temp2$iminput = new CDate($iminput, false);\n"
              "temp2$iminput.setYear(tempdate.Year);\n"
              "temp2$iminput.setMonth(tempdate.Month);\n"
              "temp2$iminput.setDay(tempdate.Day);"
         ) CDate &date "out temp$iminput"

The generated proxy class code will then contain the following wrapper for calling user-overloaded someCallback():

...
  private void SwigDirectorsomeCallback(global::System.IntPtr date) {
    System.DateTime tempdate = new System.DateTime();
    try {
      someCallback(out tempdate);
    } finally {
      // we create a managed wrapper around the existing C reference, just for convenience
      CDate temp2date = new CDate(date, false);
      temp2date.setYear(tempdate.Year);
      temp2date.setMonth(tempdate.Month);
      temp2date.setDay(tempdate.Day);
    }
  }
...

Pay special attention to the memory management issues, using these attributes.

20.8.6 Turning wrapped classes into partial classes

C# supports the notion of partial classes whereby a class definition can be split into more than one file. It is possible to turn the wrapped C++ class into a partial C# class using the csclassmodifiers typemap. Consider a C++ class called ExtendMe :

class ExtendMe {
public:
  int Part1() { return 1; }
};

The default C# proxy class generated is:

public class ExtendMe : global::System.IDisposable {
  ...
  public int Part1() {
    ...
  }
}

The default csclassmodifiers typemap shipped with SWIG is

%typemap(csclassmodifiers) SWIGTYPE "public class"

Note that the type used is the special catch all type SWIGTYPE . If instead we use the following typemap to override this for just the ExtendMe class:

%typemap(csclassmodifiers) ExtendMe "public partial class"

The C# proxy class becomes a partial class:

public partial class ExtendMe : global::System.IDisposable {
  ...
  public int Part1() {
    ...
  }
}

You can then of course declare another part of the partial class elsewhere, for example:

public partial class ExtendMe : global::System.IDisposable {
  public int Part2() {
    return 2;
  }
}

and compile the following code:

ExtendMe em = new ExtendMe();
Console.WriteLine("part1: {0}", em.Part1());
Console.WriteLine("part2: {0}", em.Part2());

demonstrating that the class contains methods calling both unmanaged code - Part1() and managed code - Part2(). The following example is an alternative approach to adding managed code to the generated proxy class.

20.8.7 Extending proxy classes with additional C# code

The previous example showed how to use partial classes to add functionality to a generated C# proxy class. It is also possible to extend a wrapped struct/class with C/C++ code by using the %extend directive. A third approach is to add some C# methods into the generated proxy class with the cscode typemap. If we declare the following typemap before SWIG parses the ExtendMe class used in the previous example

%typemap(cscode) ExtendMe %{
  public int Part3() {
    return 3;
  }
%}

The generated C# proxy class will instead be:

public class ExtendMe : global::System.IDisposable {
  ...
  public int Part3() {
    return 3;
  }
  public int Part1() {
    ...
  }
}

20.8.8 Underlying type for enums

C# enums use int as the underlying type for each enum item. If you wish to change the underlying type to something else, then use the csbase typemap. For example when your C++ code uses a value larget than int, this is necessary as the C# compiler will not compile values which are too large to fit into an int. Here is an example:

%typemap(csbase) BigNumbers "uint"
%inline %{
  enum BigNumbers { big=0x80000000, bigger };
%}

The generated enum will then use the given underlying type and compile correctly:

public enum BigNumbers : uint {
  big = 0x80000000,
  bigger
}

21 SWIG and Chicken

This chapter describes SWIG's support of CHICKEN. CHICKEN is a Scheme-to-C compiler supporting most of the language features as defined in the Revised^5 Report on Scheme. Its main attributes are that it

  1. generates portable C code
  2. includes a customizable interpreter
  3. links to C libraries with a simple Foreign Function Interface
  4. supports full tail-recursion and first-class continuations

When confronted with a large C library, CHICKEN users can use SWIG to generate CHICKEN wrappers for the C library. However, the real advantages of using SWIG with CHICKEN are its support for C++ -- object-oriented code is difficult to wrap by hand in CHICKEN -- and its typed pointer representation, essential for C and C++ libraries involving structures or classes.

21.1 Preliminaries

CHICKEN support was introduced to SWIG in version 1.3.18. SWIG relies on some recent additions to CHICKEN, which are only present in releases of CHICKEN with version number greater than or equal to 1.89. To use a chicken version between 1.40 and 1.89, see the Garbage collection section below.

You may want to look at any of the examples in Examples/chicken/ directory for the basic steps to run SWIG CHICKEN.

21.1.1 Running SWIG in C mode

To run SWIG CHICKEN in C mode, use the -chicken option.

% swig -chicken example.i

To allow the wrapper to take advantage of future CHICKEN code generation improvements, part of the wrapper is direct CHICKEN function calls (example_wrap.c) and part is CHICKEN Scheme ( example.scm). The basic Scheme code must be compiled to C using your system's CHICKEN compiler or both files can be compiled directly using the much simpler csc.

% chicken example.scm -output-file oexample.c

So for the C mode of SWIG CHICKEN, example_wrap.c and oexample.c are the files that must be compiled to object files and linked into your project.

21.1.2 Running SWIG in C++ mode

To run SWIG CHICKEN in C++ mode, use the -chicken -c++ option.

% swig -chicken -c++ example.i

This will generate example_wrap.cxx and example.scm . The basic Scheme code must be compiled to C using your system's CHICKEN compiler or both files can be compiled directly using the much simpler csc.

% chicken example.scm -output-file oexample.c

So for the C++ mode of SWIG CHICKEN, example_wrap.cxx and oexample.c are the files that must be compiled to object files and linked into your project.

21.2 Code Generation

21.2.1 Naming Conventions

Given a C variable, function or constant declaration named Foo_Bar, the declaration will be available in CHICKEN as an identifier ending with Foo-Bar. That is, an underscore is converted to a dash.

You may control what the CHICKEN identifier will be by using the %rename SWIG directive in the SWIG interface file.

21.2.2 Modules

The name of the module must be declared one of two ways:

  • Placing %module example in the SWIG interface file.
  • Using -module example on the SWIG command line.

The generated example.scm file then exports (declare (unit modulename)). If you do not want SWIG to export the (declare (unit modulename)), pass the -nounit option to SWIG.

CHICKEN will be able to access the module using the (declare (uses modulename)) CHICKEN Scheme form.

21.2.3 Constants and Variables

Constants may be created using any of the four constructs in the interface file:

  1. #define MYCONSTANT1 ...
  2. %constant int MYCONSTANT2 = ...
  3. const int MYCONSTANT3 = ...
  4. enum { MYCONSTANT4 = ... };

In all cases, the constants may be accessed from within CHICKEN using the form (MYCONSTANT1); that is, the constants may be accessed using the read-only parameter form.

Variables are accessed using the full parameter form. For example, to set the C variable "int my_variable;", use the Scheme form (my-variable 2345). To get the C variable, use (my-variable) .

The %feature("constasvar") can be applied to any constant or immutable variable. Instead of exporting the constant as a function that must be called, the constant will appear as a scheme variable. This causes the generated .scm file to just contain the code (set! MYCONSTANT1 (MYCONSTANT1)). See Features and the %feature directive for info on how to apply the %feature.

21.2.4 Functions

C functions declared in the SWIG interface file will have corresponding CHICKEN Scheme procedures. For example, the C function "int sqrt(double x);" will be available using the Scheme form (sqrt 2345.0). A void return value will give C_SCHEME_UNDEFINED as a result.

A function may return more than one value by using the OUTPUT specifier (see Lib/chicken/typemaps.i). They will be returned as multiple values using (values) if there is more than one result (that is, a non-void return value and at least one argout parameter, or a void return value and at least two argout parameters). The return values can then be accessed with (call-with-values) .

21.2.5 Exceptions

The SWIG chicken module has support for exceptions thrown from C or C++ code to be caught in scheme. See Exception handling with %exception for more information about declaring exceptions in the interface file.

Chicken supports both the SWIG_exception(int code, const char *msg) interface as well as a SWIG_ThrowException(C_word val) function for throwing exceptions from inside the %exception blocks. SWIG_exception will throw a list consisting of the code (as an integer) and the message. Both of these will throw an exception using (abort), which can be handled by (handle-exceptions). See the Chicken manual on Exceptions and SFRI-12. Since the exception values are thrown directly, if (condition-case) is used to catch an exception the exception will come through in the val () case.

The following simple module

%module exception_test

%inline %{
  void test_throw(int i) throws (int) { 
    if (i == 1) throw 15; 
  }
%}

could be run with

(handle-exceptions exvar 
  (if (= exvar 15)
    (print "Correct!") 
    (print "Threw something else " exvar))
  (test-throw 1))

21.3 TinyCLOS

The author of TinyCLOS, Gregor Kiczales, describes TinyCLOS as: "Tiny CLOS is a Scheme implementation of a `kernelized' CLOS, with a metaobject protocol. The implementation is even simpler than the simple CLOS found in `The Art of the Metaobject Protocol,' weighing in at around 850 lines of code, including (some) comments and documentation."

Almost all good Scheme books describe how to use metaobjects and generic procedures to implement an object-oriented Scheme system. Please consult a Scheme book if you are unfamiliar with the concept.

CHICKEN has a modified version of TinyCLOS, which SWIG CHICKEN uses if the -proxy argument is given. If -proxy is passed, then the generated example.scm file will contain TinyCLOS class definitions. A class named Foo is declared as <Foo>, and each member variable is allocated a slot. Member functions are exported as generic functions.

Primitive symbols and functions (the interface that would be presented if -proxy was not passed) are hidden and no longer accessible. If the -unhideprimitive command line argument is passed to SWIG, then the primitive symbols will be available, but each will be prefixed by the string "primitive:"

The exported symbol names can be controlled with the -closprefix and -useclassprefix arguments. If -useclassprefix is passed to SWIG, every member function will be generated with the class name as a prefix. If the -closprefix mymod: argument is passed to SWIG, then the exported functions will be prefixed by the string "mymod:". If -useclassprefix is passed, -closprefix is ignored.

21.4 Linkage

Please refer to CHICKEN - A practical and portable Scheme system - User's manual for detailed help on how to link object files to create a CHICKEN Scheme program. Briefly, to link object files, be sure to add `chicken-config -extra-libs -libs` or `chicken-config -shared -extra-libs -libs`to your linker options. Use the -shared option if you want to create a dynamically loadable module. You might also want to use the much simpler csc or csc.bat.

Each scheme file that is generated by SWIG contains (declare (uses modname)). This means that to load the module from scheme code, the code must include (declare (uses modname )).

21.4.1 Static binary or shared library linked at compile time

We can easily use csc to build a static binary.

$ swig -chicken example.i
$ csc -v example.scm example_impl.c example_wrap.c test_script.scm -o example
$ ./example

Similar to the above, any number of module.scm files could be compiled into a shared library, and then that shared library linked when compiling the main application.

$ swig -chicken example.i
$ csc -sv example.scm example_wrap.c example_impl.c -o example.so

The example.so file can then linked with test_script.scm when it is compiled, in which case test_script.scm must have (declare (uses example)). Multiple SWIG modules could have been linked into example.so and each one accessed with a (declare (uses ... )).

$ csc -v test_script.scm -lexample

An alternative is that the test_script.scm can have the code (load-library 'example "example.so"), in which case the test script does not need to be linked with example.so. The test_script.scm file can then be run with csi.

21.4.2 Building chicken extension libraries

Building a shared library like in the above section only works if the library is linked at compile time with a script containing (declare (uses ...)) or is loaded explicitly with (load-library 'example "example.so"). It is not the format that CHICKEN expects for extension libraries and eggs. The problem is the (declare (unit modname)) inside the modname.scm file. There are two possible solutions to this.

First, SWIG accepts a -nounit argument, in which case the (declare (unit modname)) is not generated. Then, the modname.scm and modname_wrap.c files must be compiled into their own shared library.

$ csc -sv modname.scm modname_wrap.c modname_impl.c -o modname.so

This library can then be loaded by scheme code with the (require 'modname) function. See the Loading-extension-libraries in the eval unit inside the CHICKEN manual for more information.

Another alternative is to run SWIG normally and create a scheme file that contains (declare (uses modname)) and then compile that file into the shared library as well. For example, inside the mod_load.scm file,

(declare (uses mod1))
(declare (uses mod2))

Which would then be compiled with

$ swig -chicken mod1.i
$ swig -chicken mod2.i
$ csc -sv mod_load.scm mod1.scm mod2.scm mod1_wrap.c mod2_wrap.c mod1_impl.c mod2_impl.c -o mod.so

Then the extension library can be loaded with (require 'mod) . As we can see here, mod_load.scm contains the code that gets executed when the module is loaded. All this code does is load both mod1 and mod2. As we can see, this technique is more useful when you want to combine a few SWIG modules into one chicken extension library, especially if modules are related by %import

In either method, the files that are compiled into the shared library could also be packaged into an egg. The mod1_wrap.c and mod2_wrap.c files that are created by SWIG are stand alone and do not need SWIG to be installed to be compiled. Thus the egg could be distributed and used by anyone, even if SWIG is not installed.

See the Examples/chicken/egg directory in the SWIG source for an example that builds two eggs, one using the first method and one using the second method.

21.4.3 Linking multiple SWIG modules with TinyCLOS

Linking together multiple modules that share type information using the %import directive while also using -proxy is more complicated. For example, if mod2.i imports mod1.i , then the mod2.scm file contains references to symbols declared in mod1.scm, and thus a (declare (uses mod1 )) or (require 'mod1) must be exported to the top of mod2.scm. By default, when SWIG encounters an %import "modname.i" directive, it exports (declare (uses modname)) into the scm file. This works fine unless mod1 was compiled with the -nounit argument or was compiled into an extension library with other modules under a different name.

One option is to override the automatic generation of (declare (uses mod1)) by passing the -noclosuses option to SWIG when compiling mod2.i. SWIG then provides the %insert(closprefix) %{ %} directive. Any scheme code inside that directive is inserted into the generated .scm file, and if mod1 was compiled with -nounit, the directive should contain (require 'mod1). This option allows for mixed loading as well, where some modules are imported with (declare (uses modname )) (which means they were compiled without -nounit) and some are imported with (require 'modname).

The other option is to use the second idea in the above section. Compile all the modules normally, without any %insert(closprefix) , -nounit, or -noclosuses. Then the modules will import each other correctly with (declare (uses ...)). To create an extension library or an egg, just create a module_load.scm file that (declare (uses ...)) all the modules.

21.5 Typemaps

The Chicken module handles all types via typemaps. This information is read from Lib/chicken/typemaps.i and Lib/chicken/chicken.swg.

21.6 Pointers

For pointer types, SWIG uses CHICKEN tagged pointers. A tagged pointer is an ordinary CHICKEN pointer with an extra slot for a void *. With SWIG CHICKEN, this void * is a pointer to a type-info structure. So each pointer used as input or output from the SWIG-generated CHICKEN wrappers will have type information attached to it. This will let the wrappers correctly determine which method should be called according to the object type hierarchy exposed in the SWIG interface files.

To construct a Scheme object from a C pointer, the wrapper code calls the function SWIG_NewPointerObj(void *ptr, swig_type_info *type, int owner), The function that calls SWIG_NewPointerObj must have a variable declared C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); It is ok to call SWIG_NewPointerObj more than once, just make sure known_space has enough space for all the created pointers.

To get the pointer represented by a CHICKEN tagged pointer, the wrapper code calls the function SWIG_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags), passing a pointer to a struct representing the expected pointer type. flags is either zero or SWIG_POINTER_DISOWN (see below).

21.6.1 Garbage collection

If the owner flag passed to SWIG_NewPointerObj is 1, NewPointerObj will add a finalizer to the type which will call the destructor or delete method of that type. The destructor and delete functions are no longer exported for use in scheme code, instead SWIG and chicken manage pointers. In situations where SWIG knows that a function is returning a type that should be garbage collected, SWIG will automatically set the owner flag to 1. For other functions, the %newobject directive must be specified for functions whose return values should be garbage collected. See Object ownership and %newobject for more information.

In situations where a C or C++ function will assume ownership of a pointer, and thus chicken should no longer garbage collect it, SWIG provides the DISOWN input typemap. After applying this typemap (see the Typemaps chapter for more information on how to apply typemaps), any pointer that gets passed in will no longer be garbage collected. An object is disowned by passing the SWIG_POINTER_DISOWN flag to SWIG_ConvertPtr . Warning: Since the lifetime of the object is now controlled by the underlying code, the object might get deleted while the scheme code still holds a pointer to it. Further use of this pointer can lead to a crash.

Adding a finalizer function from C code was added to chicken in the 1.89 release, so garbage collection does not work for chicken versions below 1.89. If you would like the SWIG generated code to work with chicken 1.40 to 1.89, pass the -nocollection argument to SWIG. This will not export code inside the _wrap.c file to register finalizers, and will then export destructor functions which must be called manually.

21.7 Unsupported features and known problems

  • No director support.
  • No support for c++ standard types like std::vector.
  • The TinyCLOS wrappers for overloaded functions will not work correctly when using %feature(compactdefaultargs).

21.7.1 TinyCLOS problems with Chicken version <= 1.92

In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods with different number of specializers: TinyCLOS assumes that every method added to a generic function will have the same number of specializers. SWIG generates functions with different lengths of specializers when C/C++ functions are overloaded. For example, the code

class Foo {};
int foo(int a, Foo *b);
int foo(int a);

will produce scheme code

(define-method (foo (arg0 <top>) (arg1 <Foo>)) (call primitive function))
(define-method (foo (arg0 <top>)) (call primitive function))

Using unpatched TinyCLOS, the second (define-method) will replace the first one, so calling (foo 3 f) will produce an error.

There are three solutions to this. The easist is to upgrade to the latest Chicken version. Otherwise, the file Lib/chicken/tinyclos-multi-generic.patch in the SWIG source contains a patch against tinyclos.scm inside the 1.92 chicken source to add support into TinyCLOS for multi-argument generics. (This patch was accepted into Chicken) This requires chicken to be rebuilt and custom install of chicken. An alternative is the Lib/chicken/multi-generic.scm file in the SWIG source. This file can be loaded after TinyCLOS is loaded, and it will override some functions inside TinyCLOS to correctly support multi-argument generics. Please see the comments at the top of both files for more information.


22 SWIG and D

22.1 Introduction

From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

Well, besides the obvious downside that the C header files have to be manually converted to D modules for this to work, there is one major inconvenience with this approach: D code usually is on a higher abstraction level than C, and many of the features that make D interesting are simply not available when dealing with C libraries, requiring you e.g. to manually convert strings between pointers to \0-terminated char arrays and D char arrays, making the algorithms from the D2 standard library unusable with C arrays and data structures, and so on.

While these issues can be worked around relatively easy by hand-coding a thin wrapper layer around the C library in question, there is another issue where writing wrapper code per hand is not feasible: C++ libraries. D did not support interfacing to C++ in version 1 at all, and even if extern(C++) has been added to D2, the support is still very limited, and a custom wrapper layer is still required in many cases.

To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

22.2 Command line invocation

To activate the D module, pass the -d option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:

-d2

By default, SWIG generates code for D1/Tango. Use the -d2 flag to target D2/Phobos instead.

-splitproxy

By default, SWIG generates two D modules: the proxy module, named like the source module (either specified via the %module directive or via the module command line switch), which contains all the proxy classes, functions, enums, etc., and the intermediary module (named like the proxy module, but suffixed with _im), which contains all the extern(C) function declarations and other private parts only used internally by the proxy module.

If the split proxy mode is enabled by passing this switch at the command line, all proxy classes and enums are emitted to their own D module instead. The main proxy module only contains free functions and constants in this case.

-package <pkg>

By default, the proxy D modules and the intermediary D module are written to the root package. Using this option, you can specify another target package instead.

-wrapperlibrary <wl>

The code SWIG generates to dynamically load the C/C++ wrapper layer looks for a library called $module_wrap by default. With this switch, you can override the name of the file the wrapper code loads at runtime (the lib prefix and the suffix for shared libraries are appended automatically, depending on the OS).

This might especially be useful if you want to invoke SWIG several times on separate modules, but compile the resulting code into a single shared library.

22.3 Typemaps

22.3.1 C# <-> D name comparison

If you already know the SWIG C# module, you might find the following name comparison table useful:

 ctype                  <->  ctype
 imtype                 <->  imtype
 cstype                 <->  dtype
 csin                   <->  din
 csout                  <->  dout
 csdirectorin           <->  ddirectorin
 csdirectorout          <->  ddirectorout
 csinterfaces           <->  dinterfaces
 csinterfaces_derived   <->  dinterfaces_derived
 csbase                 <->  dbase
 csclassmodifiers       <->  dclassmodifiers
 cscode                 <->  dcode
 csimports              <->  dimports
 csbody                 <->  dbody
 csfinalize             <->  ddestructor
 csdestruct             <->  ddispose
 csdestruct_derived     <->  ddispose_derived

22.3.2 ctype, imtype, dtype

Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.

22.3.3 in, out, directorin, directorout

Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

The code from the in typemap is used to convert arguments to the C wrapper function to the type used in the wrapped code (ctype ->original C++ type), the out typemap is utilized to convert values from the wrapped code to wrapper function return types (original C++ type->ctype).

The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

22.3.4 din, dout, ddirectorin, ddirectorout

Typemaps for code generation in D proxy and type wrapper classes.

The din typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the $dinput macro is replaced). To inject further parameter processing code before or after the call to the intermediary layer, the pre, post and terminator attributes can be used (please refer to the C# date marshalling example for more information on these).

The dout typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The $excode special variable in dout typemaps is replaced by the excode typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the $imcall and $owner macros are replaced).

The code from the ddirectorin and ddirectorout typemaps is used for conversion in director callback functions. Arguments are converted to the type used in the proxy class method they are calling by using the code from ddirectorin, the proxy class method return value is converted to the type the C++ code expects via the ddirectorout typemap (the $dcall and $winput macros are replaced).

The full chain of type conversions when a director callback is invoked looks like this:

      type              CPPClass::method(type a)
        ↑                       ↓
   <directorout>          <directorin>
        ↑                       ↓
      ctype             methodCallback(ctype a)           C++
 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
      imtype            methodCallback(imtype a)           D
        ↑                       ↓
  <ddirectorout>          <ddirectorin>
        ↑                       ↓
      dtype             DClass.method(dtype a)

22.3.5 typecheck typemaps

Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

22.3.6 Code injection typemaps

These typemaps are used for generating the skeleton of proxy classes for C++ types.

By overriding dbase, dinterfaces or dinterfaces_derived, the inheritance chain of the generated proxy class for a type can be modified. dclassmodifiers allows you to add any custom modifiers around the class keyword.

Using dcode and dimports, you can specify additional D code which will be emitted into the class body respectively the imports section of the D module the class is written to.

dconstructor, ddestructor , ddispose and ddispose_derived are used to generate the class constructor, destructor and dispose() method, respectively. The auxiliary code for handling the pointer to the C++ object is stored in dbody and dbody_derived. You can override them for specific types.

22.3.7 Special variable macros

The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation , for example $1, $input, $result etc.

When generating D wrappers, a few additional macros are available:

$dclassname (C#: $csclassname)

This special variable works similar to $n_type in that it returns the name of a type - it expands to the D proxy class name of the type being wrapped. If the type does not have an associated proxy class, it expands to the type wrapper class name, for example, SWIGTYPE_p_p_SomeCppClass is generated when wrapping SomeCppClass **.

There are two other variants available, $&dclassname and $*dclassname. The former adds a level of indirection, while the latter removes one. For instance, when wrapping Foo **, $*dclassname would be replaced by the proxy class name corresponding to Foo *.

$dclazzname (C#: $csclazzname)

This special variable expands the fully qualified C++ class into the package name, if used by the nspace feature, and the proxy class name, mangled for use as a function name. For example, Namespace1::Namespace2::Klass is expanded into Namespace1_Namespace2_Klass_.

This special variable might be useful for calling certain functions in the wrapper layer (e.g. upcast wrappers) which are mangled like this.

$null

In code inserted into the generated C/C++ wrapper functions, this variable is replaced by either 0 or nothing at all, depending on whether the function has a return value or not. It can be used to bail out early e.g. in case of errors (return $null;).

$dinput (C#: $csinput)

This variable is used in din typemaps and is replaced by the expression which is to be passed to C/C++.

For example, this input

%typemap(din) SomeClass * "SomeClass.getCPointer($dinput)"

%inline %{
  class SomeClass {};
  void foo(SomeClass *arg);
%}

leads to the following D proxy code being generated:

void foo(SomeClass arg) {
  example_im.foo(SomeClass.getCPointer(arg));
}
$imcall and $owner (C#: $imcall )

These variables are used in dout typemaps. $imcall contains the call to the intermediary module which provides the value to be used, and $owner signals if the caller is responsible for managing the object lifetime (that is, if the called method is a constructor or has been marked via %newobject ).

Consider the following example:

%typemap(dout) SomeClass * {
  return new SomeClass($imcall, $owner);
}

%inline %{
  class SomeClass;
  SomeClass *foo();

  %newobject bar();
  SomeClass *bar();
%}

The code generated for foo() and bar() looks like this:

SomeClass foo() {
  return new SomeClass(example_im.foo(), false);
}

SomeClass bar() {
  return new SomeClass(example_im.bar(), true);
}
$dcall and $winput (C#: $cscall, $iminput)

These variables are used in the director-specific typemaps ddirectorin and ddirectorout. They are more or less the reverse of the $imcall and $dinput macros: $dcall contains the invocation of the D proxy method of which the return value is to be passed back to C++, $winput contains the parameter value from C++.

$excode

This variable is used in dout and dconstructor typemaps and is filled with the contents of the excode typemap attribute if an exception could be thrown from the C++ side. See the C# documentation for details.

$dbaseclass

Currently for internal use only, it contains the D name of the C++ base class (if any) inside proxy classes.

$directorconnect

This macro is only valid inside the dconstructor typemap and contains the value of the dconstructor typemap attribute if the currently wrapped class has directors enabled.

This is how the default dconstructor typemap looks like (you usually do not want to specify a custom one):

%typemap(dconstructor, excode=SWIGEXCODE,
         directorconnect="\n  swigDirectorConnect();") SWIGTYPE {
  this($imcall, true);$excode$directorconnect
}
$importtype(SomeDType)

This macro is used in the dimports typemap if a dependency on another D type generated by SWIG is added by a custom typemap.

Consider the following code snippet:

%typemap(dinterfaces) SomeClass "AnInterface, AnotherInterface";

This causes SWIG to add AnInterface and AnotherInterface to the base class list of SomeClass:

class SomeClass : AnInterface, AnotherInterface {
  ...
}

For this to work, AnInterface and AnotherInterface have to be in scope. If SWIG is not in split proxy mode, this is already the case, but it it is, they have to be added to the import list via the dimports typemap. Additionally, the import statement depends on the package SWIG is configured to emit the modules to.

The $importtype macro helps you to elegantly solve this problem:

%typemap(dimports) RemoteMpe %{
$importtype(AnInterface)
$importtype(AnotherInterface)
%}

If SWIG is in split proxy mode, it expands to an import statement for the specified type, to nothing if not.

$module

Expands to the name of the main proxy D module.

$imdmodule

Contains the fully qualified name of the intermediary D module.

22.4 %features

The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

%dmanifestconst and %dconstvalue(value)

Out of the box, SWIG generates accessor methods for C #defines and C++ constants. The %dmanifestconst directive enables wrapping these constants as D manifest constants (const in D1, enum in D2).

For this to work, the C/C++ code for the constant value must directly compile as D code, though. If this is not the case, you can manually override the expression written to the D proxy module using the %dconstvalue directive, passing the new value as parameter.

For enums, again %dconstvalue can be used to override the value of an enum item if the initializer should not compile in D.

%dmethodmodifiers

This directive can be used to override the modifiers for a proxy function. For instance, you could make a public C++ member function private in D like this:

%dmethodmodifiers A::foo "private";

%inline %{
struct A {
  void foo();
};
%}

22.5 Pragmas

There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

%pragma(d) imdmodulecode

The passed text (D code) is copied verbatim to the intermediary D module. For example, it can be (and is, internally) used to emit additional private helper code for the use by proxy typemaps.

%pragma(d) imdmoduleimports

Additional code to be emitted to the imports section of the intermediary D module (the $importtype macro can be used here). You probably want to use this in conjunction with the imdmodulecode pragma.

%pragma(d) proxydmodulecode

Just like proxydmodulecode, the argument is copied to the proxy D module (if SWIG is in split proxy mode and/or the nspace feature is used, it is emitted to the main proxy D module only).

%pragma(d) globalproxyimports

The D module currently does not support specifying dependencies on external modules (e.g. from the standard library) for the D typemaps. To add the import statements to the proxy modules (resp. to all proxy modules if in split proxy mode), you can use the globalproxyimports directive.

For example:

%typemap(din) char[] "($dinput ? tango.stdc.stringz.toStringz($dinput) : null)"
%pragma(d) globalproxyimports = "static import tango.stdc.stringz;";
%pragma(d) wrapperloadercode

The D code for loading the wrapper library (it is copied to the intermediary D module). The $wrapperloaderbindcode variable is replaced by the list of commands for binding the functions from the wrapper library to the symbols in the intermediary D module.

Each time this pragma is specified, the previous value is overwritten.

%pragma(d) wrapperloaderbindcommand

The D command to use for binding the wrapper functions from the C/C++ library to the symbols in the intermediary D module. The $function variable contains the name of the D function in the wrap module, the $symbol variable is replaced by the name of the symbol in the library.

Each time this pragma is specified, the previous value is overwritten.

22.6 D Exceptions

Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

The implementation details of this are a bit crude, but the SWIG D module automatically takes care of this, as long as it is able to detect that an exception could potentially be thrown (e.g. because the C++ method has a throw(...) exception specification).

As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

22.7 D Directors

When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

There is no D specific documentation yet, but the way the feature is implemented is very similar to how it is done in Java and C#.

22.8 Other features

22.8.1 Extended namespace support (nspace )

By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.

22.8.2 Native pointer support

Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

Central to this custom pointer handling scheme are two typemap attributes: the cprimitive attribute on the dtype typemap and the nativepointer attribute on all the typemaps which influence the D side of the code (dtype, din, dout, ...). When a D typemap is looked up, the following happens behind the scenes:

First, the matching typemap is determined by the usual typemap lookup rules. Then, it is checked if the result has the nativepointer attribute set. If it is present, it means that its value should replace the typemap value if and only if the actual type the typemap is looked up for is a primitive type, a pointer to a primitive type (through an arbitrary level of indirections), or a function pointer with only primitive types in its signature.

To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).

22.8.3 Operator overloading

The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:

The first key difference is that C++ supports free functions as operators (along with argument-dependent lookup), while D requires operators to be member functions of the class they are operating on. SWIG can only automatically generate wrapping code for member function operators; if you want to use operators defined as free functions in D, you need to handle them manually.

Another set of differences between C++ and D concerns individual operators. For example, there are quite a few operators which are overloadable in C++, but not in D, for example && and || , but also !, and prefix increment/decrement operators in D1 resp. their postfix pendants in D2.

There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this ). Despite the lack of automatic support, manually handling these cases should be perfectly possible.

22.8.4 Running the test-suite

As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2 .

Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib,...) statement.

22.9 D Typemap examples

There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

22.10 Work in progress and planned features

There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

  • Static linking: Currently, the C wrapper code is compiled into a dynamic library, out of which the symbol addresses are looked up at runtime by the D part. If statically linking the different languages into one binary was supported, a tool-chain capable of performing IPO at link time could inline the wrapping code, effectively reducing the overhead for simple calls to zero.
  • C array handling: Many data structures in some C/C++ libraries contain array containing of a pointer to the first element and the element count. Currently, one must manually writing wrapper code to be able to access these from D. It should be possible to add a set of SWIG macros to semi-automatically generate conversion code.

Some generated code might also be a bit rough around the edges, particularly in the following areas:

  • Memory management: Although the currently generated wrapper code works fine with regard to the GC for the test-suite, there might be issues coming up in real-world multi-threaded usage.
  • D2 support: Originally, the module has been developed for the use with D1, D2/Phobos support has been added in later. The basic features should work equally well for both, but there could be issues concerning const-correctness etc.

23 SWIG and Go

This chapter describes SWIG's support of Go. For more information on the Go programming language see golang.org .

23.1 Overview

Go is a compiled language, not a scripting language. However, it does not support direct calling of functions written in C/C++. The cgo program may be used to generate wrappers to call C code from Go, but there is no convenient way to call C++ code. SWIG fills this gap.

There are (at least) two different Go compilers. One is the gc compiler, normally invoked via the go tool. The other 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. SWIG supports both, selected by a command line option.

Because Go is a type-safe compiled language, SWIG's runtime type checking and runtime library are not used with Go. This should be borne in mind when reading the rest of the SWIG documentation.

23.2 Running SWIG with Go

To generate Go code, use the -go option with SWIG. By default SWIG will generate code for the gc compilers. To generate code for gccgo, you should also use the -gccgo option.

23.2.1 Additional Commandline Options

These are the command line options for SWIG's Go module. They can also be seen by using:

swig -go -help
Go specific options
-intgosize <s>Set the size for the Go type int . This controls the size that the C/C++ code expects to see. The <s> argument should be 32 or 64. This option is currently required during the transition from Go 1.0 to Go 1.1, as the size of int on 64-bit x86 systems changes between those releases (from 32 bits to 64 bits). In the future the option may become optional, and SWIG will assume that the size of int is the size of a C pointer.
-gccgoGenerate code for gccgo. The default is to generate code for the gc compiler.
-package <name>Set the name of the Go package to <name>. The default package name is the SWIG module name.
-use-shlibTell SWIG to emit code that uses a shared library. This is only meaningful for the gc compiler, which needs to know at compile time whether a shared library will be used.
-soname <name>Set the runtime name of the shared library that the dynamic linker should include at runtime. The default is the package name with ".so" appended. This is only used when generating code for the gc compiler; when using gccgo, the equivalent name will be taken from the -soname option passed to the linker. Using this option implies the -use-shlib option.
-go-pkgpath <pkgpath>When generating code for gccgo, set the pkgpath to use. This corresponds to the -fgo-pkgpath option to gccgo.
-go-prefix <prefix>When generating code for gccgo, set the prefix to use. This corresponds to the -fgo-prefix option to gccgo. If -go-pkgpath is used, -go-prefix will be ignored.

23.2.2 Go Output Files

When generating Go code, SWIG will generate the following files:

  • 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.
  • 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.
  • 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.
  • 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.

Most Go programs are built using the go tool. The go tool has limited 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.

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 sequence when using the gc compiler would look like this:

% swig -go 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 gc compiler before version 1.2 this is the only supported option. A typical command sequence for this approach would look like this:

% swig -go -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

23.3 A tour of basic C/C++ wrapping

By default, SWIG attempts to build a natural Go interface to your C/C++ code. However, the languages are somewhat different, so some modifications have to occur. This section briefly covers the essential aspects of this wrapping.

23.3.1 Go Package Name

All Go source code lives in a package. The name of this package will default to the name of the module from SWIG's %module directive. You may override this by using SWIG's -package command line option.

23.3.2 Go Names

In Go, a function is only visible outside the current package if the first letter of the name is uppercase. This is quite different from C/C++. Because of this, C/C++ names are modified when generating the Go interface: the first letter is forced to be uppercase if it is not already. This affects the names of functions, methods, variables, constants, enums, and classes.

C/C++ variables are wrapped with setter and getter functions in Go. First the first letter of the variable name will be forced to uppercase, and then Get or Set will be prepended. For example, if the C/C++ variable is called var, then SWIG will define the functions GetVar and SetVar. If a variable is declared as const, or if SWIG's %immutable directive is used for the variable, then only the getter will be defined.

C++ classes will be discussed further below. Here we'll note that the first letter of the class name will be forced to uppercase to give the name of a type in Go. A constructor will be named New followed by that name, and the destructor will be named Delete followed by that name.

23.3.3 Go Constants

C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration.

23.3.4 Go Enumerations

C/C++ enumeration types will cause SWIG to define an integer type with the name of the enumeration (with first letter forced to uppercase as usual). The values of the enumeration will become variables in Go; code should avoid modifying those variables.

23.3.5 Go Classes

Go has interfaces, methods and inheritance, but it does not have classes in the same sense as C++. This sections describes how SWIG represents C++ classes represented in Go.

For a C++ class ClassName, SWIG will define two types in Go: an underlying type, which will just hold a pointer to the C++ type, and an interface type. The interface type will be named ClassName . SWIG will define a function NewClassName which will take any constructor arguments and return a value of the interface type ClassName. SWIG will also define a destructor DeleteClassName .

SWIG will represent any methods of the C++ class as methods on the underlying type, and also as methods of the interface type. Thus C++ methods may be invoked directly using the usual val.MethodName syntax. Public members of the C++ class will be given getter and setter functions defined as methods of the class.

SWIG will represent static methods of C++ classes as ordinary Go functions. SWIG will use names like ClassNameMethodName. SWIG will give static members getter and setter functions with names like GetClassName_VarName.

Given a value of the interface type, Go code can retrieve the pointer to the C++ type by calling the Swigcptr method. This will return a value of type SwigcptrClassName, which is just a name for uintptr. A Go type conversion can be used to convert this value to a different C++ type, but note that this conversion will not be type checked and is essentially equivalent to reinterpret_cast. This should only be used for very special cases, such as where C++ would use a dynamic_cast.

Note that C++ pointers to compound objects are represented in go as objects themselves, not as go pointers. So, for example, if you wrap the following function:

class MyClass {
  int MyMethod();
  static MyClass *MyFactoryFunction();
};

You will get go code that looks like this:

type MyClass interface {
  Swigcptr() uintptr
  SwigIsMyClass()
  MyMethod() int
}

MyClassMyFactoryFunction() MyClass {
  // swig magic here
}

Note that the factory function does not return a go pointer; it actually returns a go interface. If the returned pointer can be null, you can check for this by calling the Swigcptr() method.

23.3.5.1 Go Class Inheritance

C++ class inheritance is automatically represented in Go due to its use of interfaces. The interface for a child class will be a superset of the interface of its parent class. Thus a value of the child class type in Go may be passed to a function which expects the parent class. Doing the reverse will require an explicit type assertion, which will be checked dynamically.

23.3.6 Go Templates

In order to use C++ templates in Go, you must tell SWIG to create wrappers for a particular template instantation. To do this, use the %template directive.

23.3.7 Go Director Classes

SWIG's director feature permits a Go type to act as the subclass of a C++ class with virtual methods. This is complicated by the fact that C++ and Go define inheritance differently. In Go, structs can inherit methods via anonymous field embedding. However, when a method is called for an embedded struct, if that method calls any other methods, they are called for the embedded struct, not for the original type. Therefore, SWIG must use Go interfaces to represent C++ inheritance.

In order to use the director feature in Go, you must define a type in your Go code. You must then add methods for the type. Define a method in Go for each C++ virtual function that you want to override. You must then create a value of your new type, and pass a pointer to it to the function NewDirectorClassName, where ClassName is the name of the C++ class. That will return a value of type ClassName.

For example:

type GoClass struct { }
func (p *GoClass) VirtualFunction() { }
func MakeClass() ClassName {
	return NewDirectorClassName(&GoClass{})
}

Any call in C++ code to the virtual function will wind up calling the method defined in Go. The Go code may of course call other methods on itself, and those methods may be defined either in Go or in C++.

23.3.8 Default Go primitive type mappings

The following table lists the default type mapping from C/C++ to Go. This table will tell you which Go type to expect for a function which uses a given C/C++ type.

C/C++ typeGo type
boolbool
charbyte
signed charint8
unsigned charbyte
shortint16
unsigned shortuint16
intint
unsigned intuint
longint64
unsigned longuint64
long longint64
unsigned long longuint64
floatfloat32
doublefloat64
char *
char []
string

Note that SWIG wraps the C char type as a character. Pointers and arrays of this type are wrapped as strings. The signed char type can be used if you want to treat char as a signed number rather than a character. Also note that all const references to primitive types are treated as if they are passed by value.

These type mappings are defined by the "gotype" typemap. You may change that typemap, or add new values, to control how C/C++ types are mapped into Go types.

23.3.9 Output arguments

Because of limitations in the way output arguments are processed in swig, a function with output arguments will not have multiple return values. Instead, you must pass a pointer into the C++ function to tell it where to store the output value. In go, you supply a slice in the place of the output argument.

For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters):

double modf(double x, double *ip);

You could wrap it with SWIG as follows:

%include <typemaps.i>
double modf(double x, double *OUTPUT);

or you can use the %apply directive:

%include <typemaps.i>
%apply double *OUTPUT { double *ip };
double modf(double x, double *ip);

In Go you would use it like this:

ptr := []float64{0.0}
fraction := modulename.Modf(5.0, ptr)

Since this is ugly, you may want to wrap the swig-generated API with some additional functions written in go that hide the ugly details.

There are no char *OUTPUT typemaps. However you can apply the signed char * typemaps instead:

%include <typemaps.i>
%apply signed char *OUTPUT {char *output};
void f(char *output);

23.3.10 Adding additional go code

Often the APIs generated by swig are not very natural in go, especially if there are output arguments. You can insert additional go wrapping code to add new APIs with %insert(go_wrapper), like this:

%include <typemaps.i>
// Change name of what swig generates to Wrapped_modf.  This function will
// have the following signature in go:
//   func Wrapped_modf(float64, []float64) float64
%rename(wrapped_modf) modf(double x, double *ip);

%apply double *OUTPUT { double *ip };
double modf(double x, double *ip);

%insert(go_wrapper) %{

// The improved go interface to this function, which has two return values,
// in the more natural go idiom:
func Modf(x float64) (fracPart float64, intPart float64) {
  ip := []float64{0.0}
  fracPart = Wrapped_modf(x, ip)
  intPart = ip[0]
  return
}

%}

For classes, since swig generates an interface, you can add additional methods by defining another interface that includes the swig-generated interface. For example,

%rename(Wrapped_MyClass) MyClass;
%rename(Wrapped_GetAValue) MyClass::GetAValue(int *x);
%apply int *OUTPUT { int *x };

class MyClass {
 public:
  MyClass();
  int AFineMethod(const char *arg); // Swig's wrapping is fine for this one.
  bool GetAValue(int *x);
};

%insert(go_wrapper) %{

type MyClass interface {
  Wrapped_MyClass
  GetAValue() (int, bool)
}

func (arg SwigcptrWrapped_MyClass) GetAValue() (int, bool) {
  ip := []int{0}
  ok := arg.Wrapped_GetAValue(ip)
  return ip[0], ok
}

%}

Of course, if you have to rewrite most of the methods, instead of just a few, then you might as well define your own struct that includes the swig-wrapped object, instead of adding methods to the swig-generated object.

If you need to import other go packages, you can do this with %go_import. For example,

%go_import("fmt", _ "unusedPackage", rp "renamed/package")

%insert(go_wrapper) %{

func foo() {
  fmt.Println("Some string:", rp.GetString())
}

// Importing the same package twice is permitted,
// Go code will be generated with only the first instance of the import.
%go_import("fmt")

%insert(go_wrapper) %{

func bar() {
  fmt.Println("Hello world!")
}

%}

24 SWIG and Guile

This section details guile-specific support in SWIG.

24.1 Supported Guile Versions

SWIG works with Guile versions 1.8.x and 2.0.x. Support for version 1.6.x has been dropped. The last version of SWIG that still works with Guile version 1.6.x is SWIG 2.0.9.

Note that starting with guile 2.0, the guile sources can be compiled for improved performance. This is currently not tested with swig so your mileage may vary. To be safe set environment variable GUILE_AUTO_COMPILE to 0 when using swig generated guile code.

24.2 Meaning of "Module"

There are three different concepts of "module" involved, defined separately for SWIG, Guile, and Libtool. To avoid horrible confusion, we explicitly prefix the context, e.g., "guile-module".

24.3 Old GH Guile API

Guile 1.8 and older could be interfaced using two different api's, the SCM or the GH API. The GH interface to guile is deprecated. Read more about why in the Guile manual.

Support for the guile GH wrapper code generation has been dropped from SWIG. The last version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please use that version if you really need the GH wrapper code.

24.4 Linkage

Guile support is complicated by a lack of user community cohesiveness, which manifests in multiple shared-library usage conventions. A set of policies implementing a usage convention is called a linkage.

24.4.1 Simple Linkage

The default linkage is the simplest; nothing special is done. In this case the function SWIG_init() is exported. Simple linkage can be used in several ways:

  • Embedded Guile, no modules. You want to embed a Guile interpreter into your program; all bindings made by SWIG shall show up in the root module. Then call SWIG_init() in the inner_main() function. See the "simple" and "matrix" examples under Examples/guile.
  • Dynamic module mix-in. You want to create a Guile module using define-module, containing both Scheme code and bindings made by SWIG; you want to load the SWIG modules as shared libraries into Guile.

    (define-module (my module))
    (define my-so (dynamic-link "./libexample.so"))
    (dynamic-call "SWIG_init" my-so) ; make SWIG bindings
    ;; Scheme definitions can go here
    

    Newer Guile versions provide a shorthand for dynamic-link and dynamic-call:

    (load-extension "./libexample.so" "SWIG_init")
    

    A more portable approach would be to drop the shared library extension:

    (load-extension "./libexample" "SWIG_init")
    

    You need to explicitly export those bindings made by SWIG that you want to import into other modules:

    (export foo bar)
    

    In this example, the procedures foo and bar would be exported. Alternatively, you can export all bindings with the following module-system hack:

    (module-map (lambda (sym var)
    	      (module-export! (current-module) (list sym)))
    	    (current-module))
    

    SWIG can also generate this Scheme stub (from define-module up to export) semi-automagically if you pass it the command-line argument -scmstub. The code will be exported in a file called module.scm in the directory specified by -outdir or the current directory if -outdir is not specified. Since SWIG doesn't know how to load your extension module (with dynamic-link or load-extension), you need to supply this information by including a directive like this in the interface file:

    %scheme %{ (load-extension "./libexample.so" "SWIG_init") %}
    

    (The %scheme directive allows to insert arbitrary Scheme code into the generated file module.scm; it is placed between the define-module form and the export form.)

If you want to include several SWIG modules, you would need to rename SWIG_init via a preprocessor define to avoid symbol clashes. For this case, however, passive linkage is available.

24.4.2 Passive Linkage

Passive linkage is just like simple linkage, but it generates an initialization function whose name is derived from the module and package name (see below).

You should use passive linkage rather than simple linkage when you are using multiple modules.

24.4.3 Native Guile Module Linkage

SWIG can also generate wrapper code that does all the Guile module declarations on its own if you pass it the -Linkage module command-line option.

The module name is set with the -package and -module command-line options. Suppose you want to define a module with name (my lib foo); then you would have to pass the options -package my/lib -module foo . Note that the last part of the name can also be set via the SWIG directive %module.

You can use this linkage in several ways:

  • Embedded Guile with SWIG modules. You want to embed a Guile interpreter into your program; the SWIG bindings shall be put into different modules. Simply call the function scm_init_my _modules_foo_module in the inner_main() function.
  • Dynamic Guile modules. You want to load the SWIG modules as shared libraries into Guile; all bindings are automatically put in newly created Guile modules.
    (define my-so (dynamic-link "./libfoo"))
    ;; create new module and put bindings there:
    (dynamic-call "scm_init_my_modules_foo_module" my-so) 
    
    Newer Guile versions have a shorthand procedure for this:
    (load-extension "./libfoo.so" "scm_init_my_modules_foo_module")
    

24.4.4 Old Auto-Loading Guile Module Linkage

Guile used to support an autoloading facility for object-code modules. This support has been marked deprecated in version 1.4.1 and is going to disappear sooner or later. SWIG still supports building auto-loading modules if you pass it the -Linkage ltdlmod command-line option.

Auto-loading worked like this: Suppose a module with name (my lib foo) is required and not loaded yet. Guile will then search all directories in its search path for a Scheme file my/modules/foo.scm or a shared library my/ modules/libfoo.so (or my/ modules/libfoo.la; see the GNU libtool documentation). If a shared library is found that contains the symbol scm_init_my_modules_foo_module, the library is loaded, and the function at that symbol is called with no arguments in order to initialize the module.

When invoked with the -Linkage ltdlmod command-line option, SWIG generates an exported module initialization function with an appropriate name.

24.4.5 Hobbit4D Linkage

The only other linkage supported at this time creates shared object libraries suitable for use by hobbit's (hobbit4d link) guile module. This is called the "hobbit" linkage, and requires also using the "-package" command line option to set the part of the module name before the last symbol. For example, both command lines:

swig -guile -package my/lib foo.i
swig -guile -package my/lib -module foo foo.i

would create module (my lib foo) (assuming in the first case foo.i declares the module to be "foo"). The installed files are my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very experimental; the (hobbit4d link) conventions are not well understood.

24.5 Underscore Folding

Underscores are converted to dashes in identifiers. Guile support may grow an option to inhibit this folding in the future, but no one has complained so far.

You can use the SWIG directives %name and %rename to specify the Guile name of the wrapped functions and variables (see CHANGES).

24.6 Typemaps

The Guile module handles all types via typemaps. This information is read from Lib/guile/typemaps.i. Some non-standard typemap substitutions are supported:

  • $descriptor expands to a type descriptor for use with the SWIG_NewPointerObj() and SWIG_ConvertPtr functions.
  • For pointer types, $*descriptor expands to a descriptor for the direct base type (i.e., one pointer is stripped), whereas $basedescriptor expands to a descriptor for the base type (i.e., all pointers are stripped).

A function returning void (more precisely, a function whose out typemap returns SCM_UNSPECIFIED) is treated as returning no values. In argout typemaps, one can use the macro GUILE_APPEND_RESULT in order to append a value to the list of function return values.

Multiple values can be passed up to Scheme in one of three ways:

  • Multiple values as lists. By default, if more than one value is to be returned, a list of the values is created and returned; to switch back to this behavior, use

    %values_as_list;
  • Multiple values as vectors. By issuing

    %values_as_vector;

    vectors instead of lists will be used.

  • Multiple values for multiple-value continuations. This is the most elegant way. By issuing

    %multiple_values;

    multiple values are passed to the multiple-value continuation, as created by call-with-values or the convenience macro receive. The latter is available if you issue (use-modules (srfi srfi-8)). Assuming that your divide function wants to return two values, a quotient and a remainder, you can write:

    (receive (quotient remainder)
        (divide 35 17)
      body...)
    

    In body, the first result of divide will be bound to the variable quotient, and the second result to remainder.

See also the "multivalue" example.

Constants are exported as a function that returns the value. The %feature("constasvar") can be applied to any constant, immutable variable, or enum. Instead of exporting the constant as a function that must be called, the constant will appear as a scheme variable. See Features and the %feature directive for info on how to apply the %feature.

24.7 Representation of pointers as smobs

For pointer types, SWIG uses Guile smobs. SWIG smobs print like this: #<swig struct xyzzy * 0x1234affe> Two of them are equal? if and only if they have the same type and value.

To construct a Scheme object from a C pointer, the wrapper code calls the function SWIG_NewPointerObj(), passing a pointer to a struct representing the pointer type. The type index to store in the upper half of the CAR is read from this struct. To get the pointer represented by a smob, the wrapper code calls the function SWIG_ConvertPtr(), passing a pointer to a struct representing the expected pointer type. See also The run-time type checker. If the Scheme object passed was not a SWIG smob representing a compatible pointer, a wrong-type-arg exception is raised.

24.7.1 Smobs

In earlier versions of SWIG, C pointers were represented as Scheme strings containing a hexadecimal rendering of the pointer value and a mangled type name. As Guile allows registering user types, so-called "smobs" (small objects), a much cleaner representation has been implemented now. The details will be discussed in the following.

The whole type system, when it is first initialized, creates two smobs named "swig" and "collected_swig". The swig smob is used for non-garbage collected smobs, while the collected_swig smob is used as described below. Each smob has the same format, which is a double cell created by SCM_NEWSMOB2() The first word of data is the pointer to the object and the second word of data is the swig_type_info * structure describing this type. If a generated GOOPS module has been loaded, smobs will be wrapped by the corresponding GOOPS class.

24.7.2 Garbage Collection

Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, it is automatically included. Garbage collection works like this. Every swig_type_info structure stores in its clientdata field a pointer to the destructor for this type. The destructor is the generated wrapper around the delete function. So swig still exports a wrapper for the destructor, it just does not call scm_c_define_gsubr() for the wrapped delete function. So the only way to delete an object is from the garbage collector, since the delete function is not available to scripts. How swig determines if a type should be garbage collected is exactly like described in Object ownership and %newobject in the SWIG manual. All typemaps use an $owner var, and the guile module replaces $owner with 0 or 1 depending on feature:new.

24.8 Exception Handling

SWIG code calls scm_error on exception, using the following mapping:

      MAP(SWIG_MemoryError,	"swig-memory-error");
      MAP(SWIG_IOError,		"swig-io-error");
      MAP(SWIG_RuntimeError,	"swig-runtime-error");
      MAP(SWIG_IndexError,	"swig-index-error");
      MAP(SWIG_TypeError,	"swig-type-error");
      MAP(SWIG_DivisionByZero,	"swig-division-by-zero");
      MAP(SWIG_OverflowError,	"swig-overflow-error");
      MAP(SWIG_SyntaxError,	"swig-syntax-error");
      MAP(SWIG_ValueError,	"swig-value-error");
      MAP(SWIG_SystemError,	"swig-system-error");

The default when not specified here is to use "swig-error". See Lib/exception.i for details.

24.9 Procedure documentation

If invoked with the command-line option -procdoc file , SWIG creates documentation strings for the generated wrapper functions, describing the procedure signature and return value, and writes them to file.

SWIG can generate documentation strings in three formats, which are selected via the command-line option -procdocformat format :

  • guile-1.4 (default): Generates a format suitable for Guile 1.4.
  • plain: Generates a format suitable for Guile 1.4.1 and later.
  • texinfo: Generates texinfo source, which must be run through texinfo in order to get a format suitable for Guile 1.4.1 and later.

You need to register the generated documentation file with Guile like this:

(use-modules (ice-9 documentation))
(set! documentation-files 
      (cons "file" documentation-files))

Documentation strings can be configured using the Guile-specific typemap argument doc. See Lib/guile/typemaps.i for details.

24.10 Procedures with setters

For global variables, SWIG creates a single wrapper procedure ( variable :optional value), which is used for both getting and setting the value. For struct members, SWIG creates two wrapper procedures (struct-member-get pointer) and (struct-member-set pointer value).

If invoked with the command-line option -emit-setters ( recommended), SWIG will additionally create procedures with setters. For global variables, the procedure-with-setter variable is created, so you can use (variable ) to get the value and (set! (variable) value) to set it. For struct members, the procedure-with-setter struct-member is created, so you can use (struct-member pointer) to get the value and (set! (struct -member pointer) value) to set it.

If invoked with the command-line option -only-setters, SWIG will only create procedures with setters, i.e., for struct members, the procedures (struct-member -get pointer) and (struct-member-set pointer value) are not generated.

24.11 GOOPS Proxy Classes

SWIG can also generate classes and generic functions for use with Guile's Object-Oriented Programming System (GOOPS). GOOPS is a sophisticated object system in the spirit of the Common Lisp Object System (CLOS).

To enable GOOPS support, pass the -proxy argument to swig. This will export the GOOPS wrapper definitions into the module.scm file in the directory specified by -outdir or the current directory. GOOPS support requires either passive or module linkage.

The generated file will contain definitions of GOOPS classes mimicking the C++ class hierarchy.

Enabling GOOPS support implies -emit-setters.

If -emit-slot-accessors is also passed as an argument, then the generated file will contain accessor methods for all the slots in the classes and for global variables. The input class

  class Foo {
    public:
      Foo(int i) : a(i) {}
      int a;
      int getMultBy(int i) { return a * i; }
      Foo getFooMultBy(int i) { return Foo(a * i); }
  }; 
  Foo getFooPlus(int i) { return Foo(a + i); }

will produce (if -emit-slot-accessors is not passed as a parameter)

(define-class <Foo> (<swig>)
  (a #:allocation #:swig-virtual 
     #:slot-ref primitive:Foo-a-get 
     #:slot-set! primitive:Foo-a-set)
  #:metaclass <swig-metaclass>
  #:new-function primitive:new-Foo
)
(define-method (getMultBy (swig_smob <Foo>) i)
  (primitive:Foo-getMultBy  (slot-ref swig_smob 'smob) i))
(define-method (getFooMultBy (swig_smob <Foo>) i)
  (make <Foo> #:init-smob (primitive:Foo-getFooMultBy  (slot-ref swig_smob 'smob) i)))

(define-method (getFooPlus i)
  (make <Foo> #:init-smob (primitive:getFooPlus i)))

(export <Foo> getMultBy getFooMultBy getFooPlus )

and will produce (if -emit-slot-accessors is passed as a parameter)

(define-class <Foo> (<swig>)
  (a #:allocation #:swig-virtual 
     #:slot-ref primitive:Foo-a-get 
     #:slot-set! primitive:Foo-a-set 
     #:accessor a)
  #:metaclass <swig-metaclass>
  #:new-function primitive:new-Foo
)
(define-method (getMultBy (swig_smob <Foo>) i)
  (primitive:Foo-getMultBy  (slot-ref swig_smob 'smob) i))
(define-method (getFooMultBy (swig_smob <Foo>) i)
  (make <Foo> #:init-smob (primitive:Foo-getFooMultBy  (slot-ref swig_smob 'smob) i)))

(define-method (getFooPlus i)
  (make <Foo> #:init-smob (primitive:getFooPlus i)))

(export <Foo> a getMultBy getFooMultBy getFooPlus )

which can then be used by this code

;; not using getters and setters
(define foo (make <Foo> #:args '(45)))
(slot-ref foo 'a)
(slot-set! foo 'a 3)
(getMultBy foo 4)
(define foo2 (getFooMultBy foo 7))
(slot-ref foo 'a)
(slot-ref (getFooPlus foo 4) 'a)

;; using getters and setters
(define foo (make <Foo> #:args '(45)))
(a foo)
(set! (a foo) 5)
(getMultBy foo 4)
(a (getFooMultBy foo 7))

Notice that constructor arguments are passed as a list after the #:args keyword. Hopefully in the future the following will be valid (make <Foo> #:a 5 #:b 4)

Also note that the order the declarations occur in the .i file make a difference. For example,

%module test

%{ #include "foo.h" %}

%inline %{
  int someFunc(Foo &a) {
    ...
  }
%}

%include "foo.h"

This is a valid SWIG file it will work as you think it will for primitive support, but the generated GOOPS file will be broken. Since the someFunc definition is parsed by SWIG before all the declarations in foo.h, the generated GOOPS file will contain the definition of someFunc() before the definition of <Foo>. The generated GOOPS file would look like

;;...

(define-method (someFunc (swig_smob <Foo>))
  (primitive:someFunc (slot-ref swig_smob 'smob)))

;;...

(define-class <Foo> (<swig>)
  ;;...
)

;;...

Notice that <Foo> is used before it is defined. The fix is to just put the %import "foo.h" before the %inline block.

24.11.1 Naming Issues

As you can see in the example above, there are potential naming conflicts. The default exported accessor for the Foo::a variable is named a. The name of the wrapper global function is getFooPlus. If the -useclassprefix option is passed to swig, the name of all accessors and member functions will be prepended with the class name. So the accessor will be called Foo-a and the member functions will be called Foo-getMultBy. Also, if the -goopsprefix goops: argument is passed to swig, every identifier will be prefixed by goops:

Two guile-modules are created by SWIG. The first module contains the primitive definitions of all the wrapped functions and variables, and is located either in the _wrap.cxx file (with -Linkage module ) or in the scmstub file (if -Linkage passive -scmstub). The name of this guile-module is the swig-module name (given on the command line with the -module argument or with the %module directive) concatenated with the string "-primitive". For example, if %module Test is set in the swig interface file, the name of the guile-module in the scmstub or -Linkage module will be Test-primitive. Also, the scmstub file will be named Test-primitive.scm. The string "primitive" can be changed by the -primsuffix swig argument. So the same interface, with the -primsuffix base will produce a module called Test-base . The second generated guile-module contains all the GOOPS class definitions and is located in a file named module.scm in the directory specified with -outdir or the current directory. The name of this guile-module is the name of the swig-module (given on the command line or with the %module directive). In the previous example, the GOOPS definitions will be in a file named Test.scm.

Because of the naming conflicts, you can't in general use both the -primitive and the GOOPS guile-modules at the same time. To do this, you need to rename the exported symbols from one or both guile-modules. For example,

(use-modules ((Test-primitive) #:renamer (symbol-prefix-proc 'primitive:)))
(use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))

24.11.2 Linking

The guile-modules generated above all need to be linked together. GOOPS support requires either passive or module linkage. The exported GOOPS guile-module will be the name of the swig-module and should be located in a file called Module.scm. This should be installed on the autoload path for guile, so that (use-modules (Package Module)) will load everything needed. Thus, the top of the GOOPS guile-module will contain code to load everything needed by the interface (the shared library, the scmstub module, etc.). The %goops directive inserts arbitrary code into the generated GOOPS guile-module, and should be used to load the dependent libraries.

This breaks up into three cases

  • Passive Linkage without -scmstub: Note that this linkage style has the potential for naming conflicts, since the primitive exported function and variable names are not wrapped in a guile-module and might conflict with names from the GOOPS guile-module (see above). Pass the -goopsprefix argument to solve this problem. If the -exportprimitive option is passed to SWIG the (export ...) code that would be exported into the scmstub file is exported at the bottom of the generated GOOPS guile-module. The %goops directive should contain code to load the shared library.
    %goops %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
    

    Produces the following code at the top of the generated GOOPS guile-module (with the -package my/modules -module foo command line arguments)

    (define-module (my modules foo))
    
    ;; %goops directive goes here
    (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") 
    
    (use-modules (oop goops) (Swig common))
    
  • Passive Linkage with -scmstub: Here, the name of the scmstub file should be Module-primitive.scm (with primitive replaced with whatever is given with the -primsuffix argument. The code to load the shared library should be located in the %scheme directive, which will then be added to the scmstub file. SWIG will automatically generate the line (use-modules ( Package Module-primitive)) into the GOOPS guile-module. So if Module-primitive.scm is on the autoload path for guile, the %goops directive can be empty. Otherwise, the %goops directive should contain whatever code is needed to load the Module-primitive.scm file into guile.

    %scheme %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
    // only include the following definition if (my modules foo) cannot
    // be loaded automatically
    %goops %{ 
      (primitive-load "/path/to/foo-primitive.scm") 
      (primitive-load "/path/to/Swig/common.scm")
    %}
    

    Produces the following code at the top of the generated GOOPS guile-module

    (define-module (my modules foo))
    
    ;; %goops directive goes here (if any)
    (primitive-load "/path/to/foo-primitive.scm")
    (primitive-load "/path/to/Swig/common.scm")
    
    (use-modules (oop goops) (Swig common))
    (use-modules ((my modules foo-primitive) :renamer (symbol-prefix-proc
                                                           'primitive:)))
    
    
  • Module Linkage: This is very similar to passive linkage with a scmstub file. SWIG will also automatically generate the line (use-modules (Package Module-primitive)) into the GOOPS guile-module. Again the %goops directive should contain whatever code is needed to get that module loaded into guile.

    %goops %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
    

    Produces the following code at the top of the generated GOOPS guile-module

    (define-module (my modules foo))
    
    ;; %goops directive goes here (if any)
    (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") 
    
    (use-modules (oop goops) (Swig common))
    (use-modules ((my modules foo-primitive) :renamer (symbol-prefix-proc
                                                             'primitive:)))
    
    

(Swig common): The generated GOOPS guile-module also imports definitions from the (Swig common) guile-module. This module is included with SWIG and should be installed by SWIG into the autoload path for guile (based on the configure script and whatever arguments are passed). If it is not, then the %goops directive also needs to contain code to load the common.scm file into guile. Also note that if you are trying to install the generated wrappers on a computer without SWIG installed, you will need to include the common.swg file along with the install.

Multiple Modules: Type dependencies between modules is supported. For example, if mod1 includes definitions of some classes, and mod2 includes some classes derived from classes in mod1, the generated GOOPS file for mod2 will declare the correct superclasses. The only problem is that since mod2 uses symbols from mod1, the mod2 GOOPS file must include a (use-modules (mod2)). Currently, SWIG does not automatically export this line; it must be included in the %goops directive of mod2. Maybe in the future SWIG can detect dependencies and export this line. (how do other language modules handle this problem?)


25 SWIG and Java

This chapter describes SWIG's support of Java. It covers most SWIG features, but certain low-level details are covered in less depth than in earlier chapters.

25.1 Overview

The 100% Pure Java effort is a commendable concept, however in the real world programmers often either need to re-use their existing code or in some situations want to take advantage of Java but are forced into using some native (C/C++) code. The Java extension to SWIG makes it very easy to plumb in existing C/C++ code for access from Java, as SWIG writes the Java Native Interface (JNI) code for you. It is different to using the 'javah' tool as SWIG will wrap existing C/C++ code, whereas javah takes 'native' Java function declarations and creates C/C++ function prototypes. SWIG wraps C/C++ code using Java proxy classes and is very useful if you want to have access to large amounts of C/C++ code from Java. If only one or two JNI functions are needed then using SWIG may be overkill. SWIG enables a Java program to easily call into C/C++ code from Java. Historically, SWIG was not able to generate any code to call into Java code from C++. However, SWIG now supports full cross language polymorphism and code is generated to call up from C++ to Java when wrapping C++ virtual methods via the director feature.

Java is one of the few non-scripting language modules in SWIG. As SWIG utilizes the type safety that the Java language offers, it takes a somewhat different approach to that used for scripting languages. In particular runtime type checking and the runtime library are not used by Java. This should be borne in mind when reading the rest of the SWIG documentation. This chapter on Java is relatively self contained and will provide you with nearly everything you need for using SWIG and Java. However, the "SWIG Basics" chapter will be a useful read in conjunction with this one.

This chapter starts with a few practicalities on running SWIG and compiling the generated code. If you are looking for the minimum amount to read, have a look at the sections up to and including the tour of basic C/C++ wrapping section which explains how to call the various C/C++ code constructs from Java. Following this section are details of the C/C++ code and Java classes that SWIG generates. Due to the complexities of C and C++ there are different ways in which C/C++ code could be wrapped and called from Java. SWIG is a powerful tool and the rest of the chapter details how the default code wrapping can be tailored. Various customisation tips and techniques using SWIG directives are covered. The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.

25.2 Preliminaries

SWIG 1.1 works with JDKs from JDK 1.1 to JDK1.4 (Java 2 SDK1.4) and should also work with any later versions. Given the choice, you should probably use the latest version of Sun's JDK. The SWIG Java module is known to work using Sun's JVM on Solaris, Linux and the various flavours of Microsoft Windows including Cygwin. The Kaffe JVM is known to give a few problems and at the time of writing was not a fully fledged JVM with full JNI support. The generated code is also known to work on vxWorks using WindRiver's PJava 3.1. The best way to determine whether your combination of operating system and JDK will work is to test the examples and test-suite that comes with SWIG. Run make -k check from the SWIG root directory after installing SWIG on Unix systems.

The Java module requires your system to support shared libraries and dynamic loading. This is the commonly used method to load JNI code so your system will more than likely support this.

Android uses Java JNI and also works with SWIG. Please read the Android chapter in conjunction with this one if you are targeting Android.

25.2.1 Running SWIG

Suppose that you defined a SWIG module such as the following:

/* File: example.i */
%module test
%{
#include "stuff.h"
%}
int fact(int n);

To build a Java module, run SWIG using the -java option :

%swig -java example.i

If building C++, add the -c++ option:

$ swig -c++ -java example.i

This creates two different files; a C/C++ source file example_wrap.c or example_wrap.cxx and numerous Java files. The generated C/C++ source file contains the JNI wrapper code that needs to be compiled and linked with the rest of your C/C++ application.

The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. It is also possible to change the output directory that the Java files are generated into using -outdir.

The module name, specified with %module, determines the name of various generated classes as discussed later. Note that the module name does not define a Java package and by default, the generated Java classes do not have a Java package. The -package option described below can specify a Java package name to use.

The following sections have further practical examples and details on how you might go about compiling and using the generated files.

25.2.2 Additional Commandline Options

The following table list the additional commandline options available for the Java module. They can also be seen by using:

swig -java -help 
Java specific options
-nopgcppsuppress the premature garbage collection prevention parameter
-noproxygenerate the low-level functional interface instead of proxy classes
-package <name>set name of the Java package to <name>

Their use will become clearer by the time you have finished reading this section on SWIG and Java.

25.2.3 Getting the right header files

In order to compile the C/C++ wrappers, the compiler needs the jni.h and jni_md.h header files which are part of the JDK. They are usually in directories like this:

/usr/java/include
/usr/java/include/<operating_system>

The exact location may vary on your machine, but the above locations are typical.

25.2.4 Compiling a dynamic module

The JNI code exists in a dynamic module or shared library (DLL on Windows) and gets loaded by the JVM. Assuming you have code you need to link to in a file called example.c, in order to build a shared library file, you need to compile your module in a manner similar to the following (shown for Solaris):

$ swig -java example.i
$ gcc -fPIC -c example_wrap.c -I/usr/java/include -I/usr/java/include/solaris
$ gcc -fPIC -c example.c
$ ld -G example_wrap.o example.o -o libexample.so

The exact commands for doing this vary from platform to platform. However, SWIG tries to guess the right options when it is installed. Therefore, you may want to start with one of the examples in the Examples/java directory. If that doesn't work, you will need to read the man-pages for your compiler and linker to get the right set of options. You might also check the SWIG Wiki for additional information. JNI compilation is a useful reference for compiling on different platforms.

Important
If you are going to use optimisations turned on with gcc (for example -O2), ensure you also compile with -fno-strict-aliasing. The GCC optimisations have become more aggressive from gcc-4.0 onwards and will result in code that fails with strict aliasing optimisations turned on. See the C/C++ to Java typemaps section for more details.

The name of the shared library output file is important. If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information). The name of the module is specified using the %module directive or -module command line option.

25.2.5 Using your module

To load your shared native library module in Java, simply use Java's System.loadLibrary method in a Java class:

// runme.java

public class runme {
  static {
    System.loadLibrary("example");
  }

  public static void main(String argv[]) {
    System.out.println(example.fact(4));
  }
}

Compile all the Java files and run:

$ javac *.java
$ java runme
24
$

If it doesn't work have a look at the following section which discusses problems loading the shared library.

25.2.6 Dynamic linking problems

As shown in the previous section the code to load a native library (shared library) is System.loadLibrary("name"). This can fail with an UnsatisfiedLinkError exception and can be due to a number of reasons.

You may get an exception similar to this:

$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: no example in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1312)
        at java.lang.Runtime.loadLibrary0(Runtime.java:749)
        at java.lang.System.loadLibrary(System.java:820)
        at runme.<clinit>(runme.java:5)

The most common cause for this is an incorrect naming of the native library for the name passed to the loadLibrary function. The string passed to the loadLibrary function must not include the file extension name in the string, that is .dll or .so. The string must be name and not libname for all platforms. On Windows the native library must then be called name.dll and on most Unix systems it must be called libname.so .

Another common reason for the native library not loading is because it is not in your path. On Windows make sure the path environment variable contains the path to the native library. On Unix make sure that your LD_LIBRARY_PATH contains the path to the native library. Adding paths to LD_LIBRARY_PATH can slow down other programs on your system so you may want to consider alternative approaches. For example you could recompile your native library with extra path information using -rpath if you're using GNU, see the GNU linker documentation (ld man page). You could use a command such as ldconfig (Linux) or crle (Solaris) to add additional search paths to the default system configuration (this requires root access and you will need to read the man pages).

The native library will also not load if there are any unresolved symbols in the compiled C/C++ code. The following exception is indicative of this:

$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: libexample.so: undefined
symbol: fact
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java, Compiled Code)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java, Compiled Code)
        at java.lang.Runtime.loadLibrary0(Runtime.java, Compiled Code)
        at java.lang.System.loadLibrary(System.java, Compiled Code)
        at runme.<clinit>(runme.java:5)
$

This error usually indicates that you forgot to include some object files or libraries in the linking of the native library file. Make sure you compile both the SWIG wrapper file and the code you are wrapping into the native library file. If you forget to compile and link in the SWIG wrapper file into your native library file, you will get a message similar to the following:

$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: exampleJNI.gcd(II)I
	at exampleJNI.gcd(Native Method)
	at example.gcd(example.java:12)
	at runme.main(runme.java:18)

where gcd is the missing JNI function that SWIG generated into the wrapper file. Also make sure you pass all of the required libraries to the linker. The java -verbose:jni commandline switch is also a great way to get more information on unresolved symbols. One last piece of advice is to beware of the common faux pas of having more than one native library version in your path.

In summary, ensure that you are using the correct C/C++ compiler and linker combination and options for successful native library loading. If you are using the examples that ship with SWIG, then the Examples/Makefile must have these set up correctly for your system. The SWIG installation package makes a best attempt at getting these correct but does not get it right 100% of the time. The SWIG Wiki also has some settings for commonly used compiler and operating system combinations. The following section also contains some C++ specific linking problems and solutions.

25.2.7 Compilation problems and compiling with C++

On most machines, shared library files should be linked using the C++ compiler. For example:

% swig -c++ -java example.i
% g++ -c -fpic example.cxx
% g++ -c -fpic example_wrap.cxx -I/usr/java/j2sdk1.4.1/include -I/usr/java/j2sdk1.4.1/include/linux
% g++ -shared example.o example_wrap.o -o libexample.so

In addition to this, you may need to include additional library files to make it work. For example, if you are using the Sun C++ compiler on Solaris, you often need to add an extra library -lCrun like this:

% swig -c++ -java example.i
% CC -c example.cxx
% CC -c example_wrap.cxx -I/usr/java/include -I/usr/java/include/solaris
% CC -G example.o example_wrap.o -L/opt/SUNWspro/lib -o libexample.so -lCrun

If you aren't entirely sure about the linking for C++, you might look at an existing C++ program. On many Unix machines, the ldd command will list library dependencies. This should give you some clues about what you might have to include when you link your shared library. For example:

$ ldd swig
        libstdc++-libc6.1-1.so.2 => /usr/lib/libstdc++-libc6.1-1.so.2 (0x40019000)
        libm.so.6 => /lib/libm.so.6 (0x4005b000)
        libc.so.6 => /lib/libc.so.6 (0x40077000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
$

Finally make sure the version of JDK header files matches the version of Java that you are running as incompatibilities could lead to compilation problems or unpredictable behaviour.

25.2.8 Building on Windows

Building on Windows is roughly similar to the process used with Unix. You will want to produce a DLL that can be loaded by the Java Virtual Machine. This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers. In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.

25.2.8.1 Running SWIG from Visual Studio

If you are developing your application within Microsoft Visual studio, SWIG can be invoked as a custom build option. The Examples\java directory has a few Windows Examples containing Visual Studio project (.dsp) files. The process to re-create the project files for a C project are roughly:

  • Open up a new workspace and use the AppWizard to select a DLL project.
  • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (ie. example_wrap.c). Don't worry if the wrapper file doesn't exist yet--Visual Studio will keep a reference to it.
  • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
  • Enter "SWIG" in the description field.
  • Enter "swig -java -o $(ProjDir)\$(InputName)_wrap.c $(InputPath) " in the "Build command(s) field"
  • Enter "$(ProjDir)\$(InputName)_wrap.c" in the "Output files(s) field".
  • Next, select the settings for the entire project and go to C/C++ tab and select the Preprocessor category . Add the include directories to the JNI header files under "Additional include directories", eg "C:\jdk1.3\include,C:\jdk1.3\include\win32".
  • Next, select the settings for the entire project and go to Link tab and select the General category. Set the name of the output file to match the name of your Java module (ie. example.dll).
  • Next, select the example.c and example_wrap.c files and go to the C/C++ tab and select the Precompiled Headers tab in the project settings. Disabling precompiled headers for these files will overcome any precompiled header errors while building.
  • Finally, add the java compilation as a post build rule in the Post-build step tab in project settings, eg, "c:\jdk1.3\bin\javac *.java"
  • Build your project.

Note: If using C++, choose a C++ suffix for the wrapper file, for example example_wrap.cxx. Use _wrap.cxx instead of _wrap.c in the instructions above and add -c++ when invoking swig.

Now, assuming all went well, SWIG will be automatically invoked when you build your project. When doing a build, any changes made to the interface file will result in SWIG being automatically invoked to produce a new version of the wrapper file.

The Java classes that SWIG output should also be compiled into .class files. To run the native code in the DLL (example.dll), make sure that it is in your path then run your Java program which uses it, as described in the previous section. If the library fails to load have a look at Dynamic linking problems.

25.2.8.2 Using NMAKE

Alternatively, a Makefile for use by NMAKE can be written. Make sure the environment variables for MSVC++ are available and the MSVC++ tools are in your path. Now, just write a short Makefile like this :

# Makefile for using SWIG and Java for C code

SRCS          = example.c
IFILE         = example
INTERFACE     = $(IFILE).i
WRAPFILE      = $(IFILE)_wrap.c

# Location of the Visual C++ tools (32 bit assumed)

TOOLS         = c:\msdev
TARGET        = example.dll
CC            = $(TOOLS)\bin\cl.exe
LINK          = $(TOOLS)\bin\link.exe
INCLUDE32     = -I$(TOOLS)\include
MACHINE       = IX86

# C Library needed to build a DLL

DLLIBC        = msvcrt.lib oldnames.lib  

# Windows libraries that are apparently needed
WINLIB        = kernel32.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib

# Libraries common to all DLLs
LIBS          = $(DLLIBC) $(WINLIB) 

# Linker options
LOPT      = -debug:full -debugtype:cv /NODEFAULTLIB /RELEASE /NOLOGO \
             /MACHINE:$(MACHINE) -entry:_DllMainCRTStartup@12 -dll

# C compiler flags

CFLAGS        = /Z7 /Od /c /nologo
JAVA_INCLUDE    = -ID:\jdk1.3\include -ID:\jdk1.3\include\win32

java::
	swig -java -o $(WRAPFILE) $(INTERFACE)
	$(CC) $(CFLAGS) $(JAVA_INCLUDE) $(SRCS) $(WRAPFILE)
	set LIB=$(TOOLS)\lib
	$(LINK) $(LOPT) -out:example.dll $(LIBS) example.obj example_wrap.obj
	javac *.java

To build the DLL and compile the java code, run NMAKE (you may need to run vcvars32 first). This is a pretty simplistic Makefile, but hopefully its enough to get you started. Of course you may want to make changes for it to work for C++ by adding in the -c++ command line switch for swig and replacing .c with .cxx.

25.3 A tour of basic C/C++ wrapping

By default, SWIG attempts to build a natural Java interface to your C/C++ code. Functions are wrapped as functions, classes are wrapped as classes, variables are wrapped with JavaBean type getters and setters and so forth. This section briefly covers the essential aspects of this wrapping.

25.3.1 Modules, packages and generated Java classes

The SWIG %module directive specifies the name of the Java module. When you specify `%module example', the module name determines the name of some of the generated files in the module. The generated code consists of a module class file example.java , an intermediary JNI class file, exampleJNI.java as well as numerous other Java proxy class files. Each proxy class is named after the structs, unions and classes you are wrapping. You may also get a constants interface file if you are wrapping any unnamed enumerations or constants, for example exampleConstants.java. When choosing a module name, make sure you don't use the same name as one of the generated proxy class files nor a Java keyword. Sometimes a C/C++ type cannot be wrapped by a proxy class, for example a pointer to a primitive type. In these situations a type wrapper class is generated. Wrapping an enum generates an enum class, either a proper Java enum or a Java class that simulates the enums pattern. Details of all these generated classes will unfold as you read this section.

The JNI (C/C++) code is generated into a file which also contains the module name, for example example_wrap.cxx or example_wrap.c. These C or C++ files complete the contents of the module.

The generated Java classes can be placed into a Java package by using the -package commandline option. This is often combined with the -outdir to specify a package directory for generating the Java files.

swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i

SWIG won't create the directory, so make sure it exists beforehand.

25.3.2 Functions

There is no such thing as a global Java function so global C functions are wrapped as static methods in the module class. For example,

%module example
int fact(int n);

creates a static function that works exactly like you think it might:

public class example {
  public static int fact(int n) {
    // makes call using JNI to the C function
  }
}

The Java class example is the module class. The function can be used as follows from Java:

System.out.println(example.fact(4));

25.3.3 Global variables

C/C++ global variables are fully supported by SWIG. Java does not allow the overriding of the dot operator so all variables are accessed through getters and setters. Again because there is no such thing as a Java global variable, access to C/C++ global variables is done through static getter and setter functions in the module class.

// SWIG interface file with global variables
%module example
...
%inline %{
extern int My_variable;
extern double density;
%}
...

Now in Java :

// Print out value of a C global variable
System.out.println("My_variable = " + example.getMy_variable());
// Set the value of a C global variable
example.setDensity(0.8442);

The value returned by the getter will always be up to date even if the value is changed in C. Note that the getters and setters produced follow the JavaBean property design pattern. That is the first letter of the variable name is capitalized and preceded with set or get. If you have the misfortune of wrapping two variables that differ only in the capitalization of their first letters, use %rename to change one of the variable names. For example:

%rename Clash RenamedClash;
float Clash;
int clash;

If a variable is declared as const, it is wrapped as a read-only variable. That is only a getter is produced.

To make ordinary variables read-only, you can use the %immutable directive. For example:

%{
extern char *path;
%}
%immutable;
extern char *path;
%mutable;

The %immutable directive stays in effect until it is explicitly disabled or cleared using %mutable. See the Creating read-only variables section for further details.

If you just want to make a specific variable immutable, supply a declaration name. For example:

%{
extern char *path;
%}
%immutable path;
...
extern char *path;      // Read-only (due to %immutable)

25.3.4 Constants

C/C++ constants are wrapped as Java static final variables. To create a constant, use #define or the %constant directive. For example:

#define PI 3.14159
#define VERSION "1.0"
%constant int FOO = 42;
%constant const char *path = "/usr/local";

By default the generated static final variables are initialized by making a JNI call to get their value. The constants are generated into the constants interface and look like this:

public interface exampleConstants {
  public final static double PI = exampleJNI.PI_get();
  public final static String VERSION = exampleJNI.VERSION_get();
  public final static int FOO = exampleJNI.FOO_get();
  public final static String path = exampleJNI.path_get();
}

Note that SWIG has inferred the C type and used an appropriate Java type that will fit the range of all possible values for the C type. By default SWIG generates runtime constants. They are not compiler constants that can, for example, be used in a switch statement. This can be changed by using the %javaconst(flag) directive. It works like all the other %feature directives. The default is %javaconst(0). It is possible to initialize all wrapped constants from pure Java code by placing a %javaconst(1) before SWIG parses the constants. Putting it at the top of your interface file would ensure this. Here is an example:

%javaconst(1);
%javaconst(0) BIG;
%javaconst(0) LARGE;

#define EXPRESSION (0x100+5)
#define BIG 1000LL
#define LARGE 2000ULL

generates:

public interface exampleConstants {
  public final static int EXPRESSION = (0x100+5);
  public final static long BIG = exampleJNI.BIG_get();
  public final static java.math.BigInteger LARGE = exampleJNI.LARGE_get();
}

Note that SWIG has inferred the C long long type from BIG and used an appropriate Java type (long) as a Java long is the smallest sized Java type that will take all possible values for a C long long. Similarly for LARGE.

Be careful using the %javaconst(1) directive as not all C code will compile as Java code. For example neither the 1000LL value for BIG nor 2000ULL for LARGE above would generate valid Java code. The example demonstrates how you can target particular constants (BIG and LARGE) with %javaconst. SWIG doesn't use %javaconst(1) as the default as it tries to generate code that will always compile. However, using a %javaconst(1) at the top of your interface file is strongly recommended as the preferred compile time constants will be generated and most C constants will compile as Java code and in any case the odd constant that doesn't can be fixed using %javaconst(0).

There is an alternative directive which can be used for these rare constant values that won't compile as Java code. This is the %javaconstvalue(value) directive, where value is a Java code replacement for the C constant and can be either a string or a number. This is useful if you do not want to use either the parsed C value nor a JNI call, such as when the C parsed value will not compile as Java code and a compile time constant is required. The same example demonstrates this:

%javaconst(1);
%javaconstvalue("new java.math.BigInteger(\"2000\")") LARGE;
%javaconstvalue(1000) BIG;

#define EXPRESSION (0x100+5)
#define BIG 1000LL
#define LARGE 2000ULL

Note the string quotes for "2000" are escaped. The following is then generated:

public interface exampleConstants {
  public final static int EXPRESSION = (0x100+5);
  public final static long BIG = 1000;
  public final static java.math.BigInteger LARGE = new java.math.BigInteger("2000");
}

Note: declarations declared as const are wrapped as read-only variables and will be accessed using a getter as described in the previous section. They are not wrapped as constants. The exception to this rule are static const integral values defined within a class/struct, where they are wrapped as constants, eg:.

struct Maths {
  static const int FIVE = 5;
};

Compatibility Note: In SWIG-1.3.19 and earlier releases, the constants were generated into the module class and the constants interface didn't exist. Backwards compatibility is maintained as the module class implements the constants interface (even though some consider this type of interface implementation to be bad practice):

public class example implements exampleConstants {
}

You thus have the choice of accessing these constants from either the module class or the constants interface, for example, example.EXPRESSION or exampleConstants.EXPRESSION. Or if you decide this practice isn't so bad and your own class implements exampleConstants, you can of course just use EXPRESSION.

25.3.5 Enumerations

SWIG handles both named and unnamed (anonymous) enumerations. There is a choice of approaches to wrapping named C/C++ enums. This is due to historical reasons as SWIG's initial support for enums was limited and Java did not originally have support for enums. Each approach has advantages and disadvantages and it is important for the user to decide which is the most appropriate solution. There are four approaches of which the first is the default approach based on the so called Java typesafe enum pattern. The second generates proper Java enums. The final two approaches use simple integers for each enum item. Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.

25.3.5.1 Anonymous enums

There is no name for anonymous enums and so they are handled like constants. For example:

enum { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

is wrapped into the constants interface, in a similar manner as constants (see previous section):

public interface exampleConstants {
  public final static int ALE = exampleJNI.ALE_get();
  public final static int LAGER = exampleJNI.LAGER_get();
  public final static int STOUT = exampleJNI.STOUT_get();
  public final static int PILSNER = exampleJNI.PILSNER_get();
  public final static int PILZ = exampleJNI.PILZ_get();
}

The %javaconst(flag) and %javaconstvalue(value) directive introduced in the previous section on constants can also be used with enums. As is the case for constants, the default is %javaconst(0) as not all C values will compile as Java code. However, it is strongly recommended to add in a %javaconst(1) directive at the top of your interface file as it is only on very rare occasions that this will produce code that won't compile under Java. Using %javaconst(1) will ensure compile time constants are generated, thereby allowing the enum values to be used in Java switch statements. Example usage:

%javaconst(1);
%javaconst(0) PILSNER;
enum { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

generates:

public interface exampleConstants {
  public final static int ALE = 0;
  public final static int LAGER = 10;
  public final static int STOUT = LAGER + 1;
  public final static int PILSNER = exampleJNI.PILSNER_get();
  public final static int PILZ = PILSNER;
}

As in the case of constants, you can access them through either the module class or the constants interface, for example, example.ALE or exampleConstants.ALE.

25.3.5.2 Typesafe enums

This is the default approach to wrapping named enums. The typesafe enum pattern is a relatively well known construct to work around the lack of enums in versions of Java prior to JDK 1.5. It basically defines a class for the enumeration and permits a limited number of final static instances of the class. Each instance equates to an enum item within the enumeration. The implementation is in the "enumtypesafe.swg" file. Let's look at an example:

%include "enumtypesafe.swg" // optional as typesafe enums are the default
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

will generate:

public final class Beverage {
  public final static Beverage ALE = new Beverage("ALE");
  public final static Beverage LAGER = new Beverage("LAGER", exampleJNI.LAGER_get());
  public final static Beverage STOUT = new Beverage("STOUT");
  public final static Beverage PILSNER = new Beverage("PILSNER");
  public final static Beverage PILZ = new Beverage("PILZ", exampleJNI.PILZ_get());
  [... additional support methods omitted for brevity ...]
}

See Typesafe enum classes to see the omitted support methods. Note that the enum item with an initializer (LAGER) is initialized with the enum value obtained via a JNI call. However, as with anonymous enums and constants, use of the %javaconst directive is strongly recommended to change this behaviour:

%include "enumtypesafe.swg" // optional as typesafe enums are the default
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

will generate:

public final class Beverage {
  public final static Beverage ALE = new Beverage("ALE");
  public final static Beverage LAGER = new Beverage("LAGER", 10);
  public final static Beverage STOUT = new Beverage("STOUT");
  public final static Beverage PILSNER = new Beverage("PILSNER");
  public final static Beverage PILZ = new Beverage("PILZ", PILSNER);
  [... additional support methods omitted for brevity ...]
}

The generated code is easier to read and more efficient as a true constant is used instead of a JNI call. As is the case for constants, the default is %javaconst(0) as not all C values will compile as Java code. However, it is recommended to add in a %javaconst(1) directive at the top of your interface file as it is only on very rare occasions that this will produce code that won't compile under Java. The %javaconstvalue(value) directive can also be used for typesafe enums. Note that global enums are generated into a Java class within whatever package you are using. C++ enums defined within a C++ class are generated into a static final inner Java class within the Java proxy class.

Typesafe enums have their advantages over using plain integers in that they can be used in a typesafe manner. However, there are limitations. For example, they cannot be used in switch statements and serialization is an issue. Please look at the following references for further information: http://java.sun.com/developer/Books/shiftintojava/page1.html#replaceenums Replace Enums with Classes in Effective Java Programming on the Sun website, Create enumerated constants in Java JavaWorld article, Java Tip 133: More on typesafe enums and Java Tip 122: Beware of Java typesafe enumerations JavaWorld tips.

Note that the syntax required for using typesafe enums is the same as that for proper Java enums. This is useful during the period that a project has to support legacy versions of Java. When upgrading to JDK 1.5 or later, proper Java enums could be used instead, without users having to change their code. The following section details proper Java enum generation.

25.3.5.3 Proper Java enums

Proper Java enums were only introduced in JDK 1.5 so this approach is only compatible with more recent versions of Java. Java enums have been designed to overcome all the limitations of both typesafe and type unsafe enums and should be the choice solution, provided older versions of Java do not have to be supported. In this approach, each named C/C++ enum is wrapped by a Java enum. Java enums, by default, do not support enums with initializers. Java enums are in many respects similar to Java classes in that they can be customised with additional methods. SWIG takes advantage of this feature to facilitate wrapping C/C++ enums that have initializers. In order to wrap all possible C/C++ enums using proper Java enums, the "enums.swg" file must be used. Let's take a look at an example.

%include "enums.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

will generate:

public enum Beverage {
  ALE,
  LAGER(10),
  STOUT,
  PILSNER,
  PILZ(PILSNER);
  [... additional support methods omitted for brevity ...]
}

See Proper Java enum classes to see the omitted support methods. The generated Java enum has numerous additional methods to support enums with initializers, such as LAGER above. Note that as with the typesafe enum pattern, enum items with initializers are by default initialized with the enum value obtained via a JNI call. However, this is not the case above as we have used the recommended %javaconst(1) to avoid the JNI call. The %javaconstvalue(value) directive covered in the Constants section can also be used for proper Java enums.

The additional support methods need not be generated if none of the enum items have initializers and this is covered later in the Simpler Java enums for enums without initializers section.

25.3.5.4 Type unsafe enums

In this approach each enum item in a named enumeration is wrapped as a static final integer in a class named after the C/C++ enum name. This is a commonly used pattern in Java to simulate C/C++ enums, but it is not typesafe. However, the main advantage over the typesafe enum pattern is enum items can be used in switch statements. In order to use this approach, the "enumtypeunsafe.swg" file must be used. Let's take a look at an example.

%include "enumtypeunsafe.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

will generate:

public final class Beverage {
  public final static int ALE = 0;
  public final static int LAGER = 10;
  public final static int STOUT = LAGER + 1;
  public final static int PILSNER = STOUT + 1;
  public final static int PILZ = PILSNER;
}

As is the case previously, the default is %javaconst(0) as not all C/C++ values will compile as Java code. However, again it is recommended to add in a %javaconst(1) directive. and the %javaconstvalue(value) directive covered in the Constants section can also be used for type unsafe enums. Note that global enums are generated into a Java class within whatever package you are using. C++ enums defined within a C++ class are generated into a static final inner Java class within the Java proxy class.

Note that unlike typesafe enums, this approach requires users to mostly use different syntax compared with proper Java enums. Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.

25.3.5.5 Simple enums

This approach is similar to the type unsafe approach. Each enum item is also wrapped as a static final integer. However, these integers are not generated into a class named after the C/C++ enum. Instead, global enums are generated into the constants interface. Also, enums defined in a C++ class have their enum items generated directly into the Java proxy class rather than an inner class within the Java proxy class. In fact, this approach is effectively wrapping the enums as if they were anonymous enums and the resulting code is as per anonymous enums. The implementation is in the "enumsimple.swg" file.

Compatibility Note: SWIG-1.3.21 and earlier versions wrapped all enums using this approach. The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.

25.3.6 Pointers

C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Here is a rather simple interface:

%module example

FILE *fopen(const char *filename, const char *mode);
int fputs(const char *, FILE *);
int fclose(FILE *);

When wrapped, you will be able to use the functions in a natural way from Java. For example:

SWIGTYPE_p_FILE f = example.fopen("junk","w");
example.fputs("Hello World\n", f);
example.fclose(f);

C pointers in the Java module are stored in a Java long and cross the JNI boundary held within this 64 bit number. Many other SWIG language modules use an encoding of the pointer in a string. These scripting languages use the SWIG runtime type checker for dynamic type checking as they do not support static type checking by a compiler. In order to implement static type checking of pointers within Java, they are wrapped by a simple Java class. In the example above the FILE * pointer is wrapped with a type wrapper class called SWIGTYPE_p_FILE.

Once obtained, a type wrapper object can be freely passed around to different C functions that expect to receive an object of that type. The only thing you can't do is dereference the pointer from Java. Of course, that isn't much of a concern in this example.

As much as you might be inclined to modify a pointer value directly from Java, don't. The value is not necessarily the same as the logical memory address of the underlying object. The value will vary depending on the native byte-ordering of the platform (i.e., big-endian vs. little-endian). Most JVMs are 32 bit applications so any JNI code must also be compiled as 32 bit. The net result is pointers in JNI code are also 32 bits and are stored in the high order 4 bytes on big-endian machines and in the low order 4 bytes on little-endian machines. By design it is also not possible to manually cast a pointer to a new type by using Java casts as it is particularly dangerous especially when casting C++ objects. If you need to cast a pointer or change its value, consider writing some helper functions instead. For example:

%inline %{
/* C-style cast */
Bar *FooToBar(Foo *f) {
   return (Bar *) f;
}

/* C++-style cast */
Foo *BarToFoo(Bar *b) {
   return dynamic_cast<Foo*>(b);
}

Foo *IncrFoo(Foo *f, int i) {
    return f+i;
}
%}

Also, if working with C++, you should always try to use the new C++ style casts. For example, in the above code, the C-style cast may return a bogus result whereas as the C++-style cast will return a NULL pointer if the conversion can't be performed.

25.3.7 Structures

If you wrap a C structure, it is wrapped by a Java class with getters and setters for access to the member variables. For example,

struct Vector {
	double x,y,z;
};

is used as follows:

Vector v = new Vector();
v.setX(3.5);
v.setY(7.2);
double x = v.getX();
double y = v.getY();

The variable setters and getters are also based on the JavaBean design pattern already covered under the Global variables section. Similar access is provided for unions and the public data members of C++ classes.

This object is actually an instance of a Java class that has been wrapped around a pointer to the C structure. This instance doesn't actually do anything--it just serves as a proxy. The pointer to the C object is held in the Java proxy class in much the same way as pointers are held by type wrapper classes. Further details about Java proxy classes are covered a little later.

const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive. For example:

struct Foo {
   ...
   %immutable;
   int x;        /* Read-only members */
   char *name;
   %mutable;
   ...
};

When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run with the -c++ option). When the structure member is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described later).

If a structure contains arrays, access to those arrays is managed through pointers. For example, consider this:

struct Bar {
    int  x[16];
};

If accessed in Java, you will see behavior like this:

Bar b = new Bar();
SWIGTYPE_p_int x = b.getX();

This pointer can be passed around to functions that expect to receive an int * (just like C). You can also set the value of an array member using another pointer. For example:

Bar b = new Bar();
SWIGTYPE_p_int x = b.getX();
Bar c = new Bar();
c.setX(x);                    // Copy contents of b.x to c.x

For array assignment (setters not getters), SWIG copies the entire contents of the array starting with the data pointed to by b.x . In this example, 16 integers would be copied. Like C, SWIG makes no assumptions about bounds checking---if you pass a bad pointer, you may get a segmentation fault or access violation. The default wrapping makes it hard to set or get just one element of the array and so array access from Java is somewhat limited. This can be changed easily though by using the approach outlined later in the Wrapping C arrays with Java arrays and Unbounded C Arrays sections.

When a member of a structure is itself a structure, it is handled as a pointer. For example, suppose you have two structures like this:

struct Foo {
   int a;
};

struct Bar {
   Foo f;
};

Now, suppose that you access the f member of Bar like this:

Bar b = new Bar();
Foo x = b.getF();

In this case, x is a pointer that points to the Foo that is inside b. This is the same value as generated by this C code:

Bar b;
Foo *x = &b->f;       /* Points inside b */

Because the pointer points inside the structure, you can modify the contents and everything works just like you would expect. For example:

Bar b = new Bar();
b.getF().setA(3);   // Modify b.f.a
Foo x = b.getF();                   
x.setA(3);          // Modify x.a - this is the same as b.f.a

25.3.8 C++ classes

C++ classes are wrapped by Java classes as well. For example, if you have this class,

class List {
public:
  List();
  ~List();
  int  search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int  length;
};

you can use it in Java like this:

List l = new List();
l.insert("Ale");
l.insert("Stout");
l.insert("Lager");
String item = l.get(2);
int length = l.getLength();

Class data members are accessed in the same manner as C structures.

Static class members are unsurprisingly wrapped as static members of the Java class:

class Spam {
public:
   static void foo();
   static int bar;
};

The static members work like any other Java static member:

Spam.foo();
int bar = Spam.getBar();

25.3.9 C++ inheritance

SWIG is fully aware of issues related to C++ inheritance. Therefore, if you have classes like this

class Foo {
...
};

class Bar : public Foo {
...
};

those classes are wrapped into a hierarchy of Java classes that reflect the same inheritance structure:

Bar b = new Bar();
Class c = b.getClass();
System.out.println(c.getSuperclass().getName());

will of course display:

Foo

Furthermore, if you have functions like this

void spam(Foo *f);

then the Java function spam() accepts instances of Foo or instances of any other proxy classes derived from Foo.

Note that Java does not support multiple inheritance so any multiple inheritance in the C++ code is not going to work. A warning is given when multiple inheritance is detected and only the first base class is used.

25.3.10 Pointers, references, arrays and pass by value

In C++, there are many different ways a function might receive and manipulate objects. For example:

void spam1(Foo *x);      // Pass by pointer
void spam2(Foo &x);      // Pass by reference
void spam3(Foo x);       // Pass by value
void spam4(Foo x[]);     // Array of objects

In Java, there is no detailed distinction like this--specifically, there are only instances of classes. There are no pointers nor references. Because of this, SWIG unifies all of these types together in the wrapper code. For instance, if you actually had the above functions, it is perfectly legal to do this from Java:

Foo f = new Foo();  // Create a Foo
example.spam1(f);   // Ok. Pointer
example.spam2(f);   // Ok. Reference
example.spam3(f);   // Ok. Value.
example.spam4(f);   // Ok. Array (1 element)

Similar behavior occurs for return values. For example, if you had functions like this,

Foo *spam5();
Foo &spam6();
Foo  spam7();

then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Java will release this memory when the returned object's finalizer is run by the garbage collector).

25.3.10.1 Null pointers

Working with null pointers is easy. A Java null can be used whenever a method expects a proxy class or typewrapper class. However, it is not possible to pass null to C/C++ functions that take parameters by value or by reference. If you try you will get a NullPointerException.

example.spam1(null);   // Pointer - ok
example.spam2(null);   // Reference - NullPointerException
example.spam3(null);   // Value - NullPointerException
example.spam4(null);   // Array - ok

For spam1 and spam4 above the Java null gets translated into a NULL pointer for passing to the C/C++ function. The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.

25.3.11 C++ overloaded functions

C++ overloaded functions, methods, and constructors are mostly supported by SWIG. For example, if you have two functions like this:

%module example

void foo(int);
void foo(char *c);

You can use them in Java in a straightforward manner:

example.foo(3);           // foo(int)
example.foo("Hello");     // foo(char *c)

Similarly, if you have a class like this,

class Foo {
public:
    Foo();
    Foo(const Foo &);
    ...
};

you can write Java code like this:

Foo f = new Foo();        // Create a Foo
Foo g = new Foo(f);       // Copy f

Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG cannot disambiguate as there can be more than one C++ type mapping onto a single Java type. For example:

void spam(int);
void spam(unsigned short);

Here both int and unsigned short map onto a Java int. Here is another example:

void foo(Bar *b);
void foo(Bar &b);

If declarations such as these appear, you will get a warning message like this:

example.i:12: Warning 515: Overloaded method spam(unsigned short) ignored.
Method spam(int) at example.i:11 used.

To fix this, you either need to either rename or ignore one of the methods. For example:

%rename(spam_ushort) spam(unsigned short);
...
void spam(int);    
void spam(unsigned short);   // Now renamed to spam_ushort

or

%ignore spam(unsigned short);
...
void spam(int);    
void spam(unsigned short);   // Ignored

25.3.12 C++ default arguments

Any function with a default argument is wrapped by generating an additional function for each argument that is defaulted. For example, if we have the following C++:

%module example

void defaults(double d=10.0, int i=0);

The following methods are generated in the Java module class:

public class example {
  public static void defaults(double d, int i) { ... }
  public static void defaults(double d) { ... }
  public static void defaults() { ... }
}

It is as if SWIG had parsed three separate overloaded methods. The same approach is taken for static methods, constructors and member methods.

Compatibility note: Versions of SWIG prior to SWIG-1.3.23 wrapped these with a single wrapper method and so the default values could not be taken advantage of from Java. Further details on default arguments and how to restore this approach are given in the more general Default arguments section.

25.3.13 C++ namespaces

SWIG is aware of named C++ namespaces and they can be mapped to Java packages, however, the default wrapping flattens the namespaces, effectively ignoring them. So by default, the namespace names do not appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

%module example

namespace foo {
   int fact(int n);
   struct Vector {
       double x,y,z;
   };
};

it works in Java as follows:

int f = example.fact(3);
Vector v = new Vector();
v.setX(3.4);
double y = v.getY();

If your program has more than one namespace, name conflicts (if any) can be resolved using %rename For example:

%rename(Bar_spam) Bar::spam;

namespace Foo {
    int spam();
}

namespace Bar {
    int spam();
}

If you have more than one namespace and you want to keep their symbols separate, consider wrapping them as separate SWIG modules. Each SWIG module can be placed into a separate package.

The default behaviour described above can be improved via the nspace feature. Note that it only works for classes, structs, unions and enums declared within a named C++ namespace. When the nspace feature is used, the C++ namespaces are converted into Java packages of the same name. Proxy classes are thus declared within a package and this proxy makes numerous calls to the JNI intermediary class which is declared in the unnamed package by default. As Java does not support types declared in a named package accessing types declared in an unnamed package, the -package commandline option described earlier generally should be used to provide a parent package. So if SWIG is run using the -package com.myco option, a wrapped class, MyWorld::Material::Color, can then be accessed as com.myco.MyWorld.Material.Color. If you don't specify a package, you will get the following warning:

example.i:16: Warning 826: The nspace feature is used on 'MyWorld::Material::Color' without -package. The generated code 
may not compile as Java does not support types declared in a named package accessing types declared in an unnamed package.

If it is undesirable to have a single top level package, the nspace feature may be used without the -package commandline option (and the resulting warning ignored) if all of the types exposed using SWIG are placed in a package using the nspace feature and the 'jniclasspackage' pragma is used to specify a package for the JNI intermediary class.

If the resulting use of the nspace feature and hence packages results in a proxy class in one package deriving or using a proxy class from another package, you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

25.3.14 C++ templates

C++ templates don't present a huge problem for SWIG. However, in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the %template directive. For example:

%module example
%{
#include <utility>
%}

template<class T1, class T2>
struct pair {
   typedef T1 first_type;
   typedef T2 second_type;
   T1 first;
   T2 second;
   pair();
   pair(const T1&, const T2&);
  ~pair();
};

%template(pairii) pair<int,int>;

In Java:

pairii p = new pairii(3,4);
int first = p.getFirst();
int second = p.getSecond();

Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.

25.3.15 C++ Smart Pointers

In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

template<class T> class SmartPtr {
   ...
   T *operator->();
   ...
}

Then, if you have a class like this,

class Foo {
public:
     int x;
     int bar();
};

A smart pointer would be used in C++ as follows:

SmartPtr<Foo> p = CreateFoo();   // Created somehow (not shown)
...
p->x = 3;                        // Foo::x
int y = p->bar();                // Foo::bar

To wrap this in Java, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using %template if necessary. For example:

%module example
...
%template(SmartPtrFoo) SmartPtr<Foo>;
...

Now, in Java, everything should just "work":

SmartPtrFoo p = example.CreateFoo(); // Create a smart-pointer somehow
p.setX(3);                           // Foo::x
int y = p.bar();                     // Foo::bar

If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

Foo f = p.__deref__();               // Returns underlying Foo *

25.4 Further details on the generated Java classes

In the previous section, a high-level view of Java wrapping was presented. A key component of this wrapping is that structures and classes are wrapped by Java proxy classes and type wrapper classes are used in situations where no proxies are generated. This provides a very natural, type safe Java interface to the C/C++ code and fits in with the Java programming paradigm. However, a number of low-level details were omitted. This section provides a brief overview of how the proxy classes work and then covers the type wrapper classes. Finally enum classes are covered. First, the crucial intermediary JNI class is considered.

25.4.1 The intermediary JNI class

In the "SWIG basics" and "SWIG and C++" chapters, details of low-level structure and class wrapping are described. To summarize those chapters, if you have a global function and class like this

class Foo {
public:
     int x;
     int spam(int num, Foo* foo);
};
void egg(Foo* chips);

then SWIG transforms the class into a set of low-level procedural wrappers. These procedural wrappers essentially perform the equivalent of this C++ code:

Foo *new_Foo() {
    return new Foo();
}
void delete_Foo(Foo *f) {
    delete f;
}
int Foo_x_get(Foo *f) {
    return f->x;
}
void Foo_x_set(Foo *f, int value) {
    f->x = value;
}
int Foo_spam(Foo *f, int num, Foo* foo) {
    return f->spam(num, foo);
}

These procedural function names don't actually exist, but their functionality appears inside the generated JNI functions. The JNI functions have to follow a particular naming convention so the function names are actually:

SWIGEXPORT jlong JNICALL Java_exampleJNI_new_1Foo(JNIEnv *jenv, jclass jcls);
SWIGEXPORT void JNICALL Java_exampleJNI_delete_1Foo(JNIEnv *jenv, jclass jcls,
                                                    jlong jarg1);
SWIGEXPORT void JNICALL Java_exampleJNI_Foo_1x_1set(JNIEnv *jenv, jclass jcls,
                                                    jlong jarg1, jobject jarg1_, jint jarg2);
SWIGEXPORT jint JNICALL Java_exampleJNI_Foo_1x_1get(JNIEnv *jenv, jclass jcls,
                                                    jlong jarg1, jobject jarg1_);
SWIGEXPORT jint JNICALL Java_exampleJNI_Foo_1spam(JNIEnv *jenv, jclass jcls,
                                                  jlong jarg1, jobject jarg1_, jint jarg2,
                                                  jlong jarg3, jobject jarg3_);
SWIGEXPORT void JNICALL Java_exampleJNI_egg(JNIEnv *jenv, jclass jcls,
                                            jlong jarg1, jobject jarg1_);

For every JNI C function there has to be a static native Java function. These appear in the intermediary JNI class:

class exampleJNI {
  public final static native long new_Foo();
  public final static native void delete_Foo(long jarg1);
  public final static native void Foo_x_set(long jarg1, Foo jarg1_, int jarg2);
  public final static native int Foo_x_get(long jarg1, Foo jarg1_);
  public final static native int Foo_spam(long jarg1, Foo jarg1_, int jarg2,
                                          long jarg3, Foo jarg3_);
  public final static native void egg(long jarg1, Foo jarg1_);
}

This class contains the complete Java - C/C++ interface so all function calls go via this class. As this class acts as a go-between for all JNI calls to C/C++ code from the Java proxy classes, type wrapper classes and module class, it is known as the intermediary JNI class.

You may notice that SWIG uses a Java long wherever a pointer or class object needs to be marshalled across the Java-C/C++ boundary. This approach leads to minimal JNI code which makes for better performance as JNI code involves a lot of string manipulation. SWIG favours generating Java code over JNI code as Java code is compiled into byte code and avoids the costly string operations needed in JNI code. This approach has a downside though as the proxy class might get collected before the native method has completed. You might notice above that there is an additional parameters with a underscore postfix, eg jarg1_. These are added in order to prevent premature garbage collection when marshalling proxy classes.

The functions in the intermediary JNI class cannot be accessed outside of its package. Access to them is gained through the module class for globals otherwise the appropriate proxy class.

The name of the intermediary JNI class can be changed from its default, that is, the module name with JNI appended after it. The module directive attribute jniclassname is used to achieve this:

%module (jniclassname="name") modulename

If name is the same as modulename then the module class name gets changed from modulename to modulenameModule.

25.4.1.1 The intermediary JNI class pragmas

The intermediary JNI class can be tailored through the use of pragmas, but is not commonly done. The pragmas for this class are:

PragmaDescription
jniclassbaseBase class for the intermediary JNI class
jniclasspackagePackage in which to place the intermediary JNI class
jniclassclassmodifiersClass modifiers and class type for the intermediary JNI class
jniclasscodeJava code is copied verbatim into the intermediary JNI class
jniclassimportsJava code, usually one or more import statements, placed before the intermediary JNI class definition
jniclassinterfacesComma separated interface classes for the intermediary JNI class

The pragma code appears in the generated intermediary JNI class where you would expect:

[ jniclassimports pragma ]
[ jniclassclassmodifiers pragma ] jniclassname extends [ jniclassbase pragma ]
                                          implements [ jniclassinterfaces pragma ] {
[ jniclasscode pragma ]
... SWIG generated native methods ...
}

The jniclasscode pragma is quite useful for adding in a static block for loading the shared library / dynamic link library and demonstrates how pragmas work:

%pragma(java) jniclasscode=%{
  static {
    try {
        System.loadLibrary("example");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load. \n" + e);
      System.exit(1);
    }
  }
%}

Pragmas will take either "" or %{ %} as delimiters. For example, let's change the intermediary JNI class access to just the default package-private access.

%pragma(java) jniclassclassmodifiers="class"

All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

25.4.2 The Java module class

All global functions and variable getters/setters appear in the module class. For our example, there is just one function:

public class example {
  public static void egg(Foo chips) {
    exampleJNI.egg(Foo.getCPtr(chips), chips);
  }
}

The module class is necessary as there is no such thing as a global in Java so all the C globals are put into this class. They are generated as static functions and so must be accessed as such by using the module name in the static function call:

example.egg(new Foo());

The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.

25.4.2.1 The Java module class pragmas

The module class can be tailored through the use of pragmas, in the same manner as the intermediary JNI class. The pragmas are similarly named and are used in the same way. The complete list follows:

PragmaDescription
modulebaseBase class for the module class
moduleclassmodifiersClass modifiers and class type for the module class
modulecodeJava code is copied verbatim into the module class
moduleimportsJava code, usually one or more import statements, placed before the module class definition
moduleinterfacesComma separated interface classes for the module class

The pragma code appears in the generated module class like this:

[ moduleimports pragma ]
[ modulemodifiers pragma ] modulename extends [ modulebase pragma ]
                                      implements [ moduleinterfaces pragma ] {
[ modulecode pragma ]
... SWIG generated wrapper functions ...
}

See The intermediary JNI class pragmas section for further details on using pragmas.

25.4.3 Java proxy classes

A Java proxy class is generated for each structure, union or C++ class that is wrapped. Proxy classes have also been called peer classes. The default proxy class for our previous example looks like this:

public class Foo {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected Foo(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Foo obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      exampleJNI.delete_Foo(swigCPtr);
    }
    swigCPtr = 0;
  }

  public void setX(int value) {
    exampleJNI.Foo_x_set(swigCPtr, this, value);
  }

  public int getX() {
    return exampleJNI.Foo_x_get(swigCPtr, this);
  }

  public int spam(int num, Foo foo) {
    return exampleJNI.Foo_spam(swigCPtr, this, num, Foo.getCPtr(foo), foo);
  }

  public Foo() {
    this(exampleJNI.new_Foo(), true);
  }

}

This class merely holds a pointer to the underlying C++ object ( swigCPtr). It also contains all the methods in the C++ class it is proxying plus getters and setters for public member variables. These functions call the native methods in the intermediary JNI class. The advantage of having this extra layer is the type safety that the proxy class functions offer. It adds static type checking which leads to fewer surprises at runtime. For example, you can see that if you attempt to use the spam() function it will only compile when the parameters passed are an int and a Foo. From a user's point of view, it makes the class work as if it were a Java class:

Foo f = new Foo();
f.setX(3);
int y = f.spam(5, new Foo());

25.4.3.1 Memory management

Each proxy class has an ownership flag swigCMemOwn. The value of this flag determines who is responsible for deleting the underlying C++ object. If set to true, the proxy class's finalizer will destroy the C++ object when the proxy class is garbage collected. If set to false, then the destruction of the proxy class has no effect on the C++ object.

When an object is created by a constructor or returned by value, Java automatically takes ownership of the result. On the other hand, when pointers or references are returned to Java, there is often no way to know where they came from. Therefore, the ownership is set to false. For example:

class Foo {
public:
    Foo();
    Foo bar1();
    Foo &bar2();
    Foo *bar2();
};

In Java:

Foo f = new Foo();   //  f.swigCMemOwn = true
Foo f1 = f.bar1();   // f1.swigCMemOwn = true
Foo f2 = f.bar2();   // f2.swigCMemOwn = false
Foo f3 = f.bar3();   // f3.swigCMemOwn = false

This behavior for pointers and references is especially important for classes that act as containers. For example, if a method returns a pointer to an object that is contained inside another object, you definitely don't want Java to assume ownership and destroy it!

For the most part, memory management issues remain hidden. However, there are situations where you might have to manually change the ownership of an object. For instance, consider code like this:

class Obj {};
class Node {
   Obj *value;
public:
   void set_value(Obj *v) { value = v; }
};

Now, consider the following Java code:

Node n = new Node();    // Create a node
{
  Obj o = new Obj();    // Create an object
  n.set_value(o);       // Set value
}                       // o goes out of scope

In this case, the Node n is holding a reference to o internally. However, SWIG has no way to know that this has occurred. The Java proxy class still thinks that it has ownership of o. As o has gone out of scope, it could be garbage collected in which case the C++ destructor will be invoked and n will then be holding a stale-pointer to o. If you're lucky, you will only get a segmentation fault.

To work around this, the ownership flag of o needs changing to false. The ownership flag is a private member variable of the proxy class so this is not possible without some customization of the proxy class. This can be achieved by using a typemap to customise the proxy class with pure Java code as detailed later in the section on Java typemaps.

Sometimes a function will create memory and return a pointer to a newly allocated object. SWIG has no way of knowing this so by default the proxy class does not manage the returned object. However, you can tell the proxy class to manage the memory if you specify the %newobject directive. Consider:

class Obj {...};
class Factory {
public:
    static Obj *createObj() { return new Obj(); }
};

If we call the factory function, then we have to manually delete the memory:

Obj obj = Factory.createObj();   // obj.swigCMemOwn = false
...
obj.delete();

Now add in the %newobject directive:

%newobject Factory::createObj();

class Obj {...};
class Factory {
public:
    static Obj *createObj() { return new Obj(); }
};

A call to delete() is no longer necessary as the garbage collector will make the C++ destructor call because swigCMemOwn is now true.

Obj obj = Factory.createObj();   // obj.swigCMemOwn = true;
...

Some memory management issues are quite tricky to fix and may only be noticeable after using for a long time. One such issue is premature garbage collection of an object created from Java and resultant usage from C++ code. The section on typemap examples cover two such scenarios, Memory management for objects passed to the C++ layer and Memory management when returning references to member variables

25.4.3.2 Inheritance

Java proxy classes will mirror C++ inheritance chains. For example, given the base class Base and its derived class Derived :

class Base {
public:
  virtual double foo();
};

class Derived : public Base {
public:
  virtual double foo();
};

The base class is generated much like any other proxy class seen so far:

public class Base {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected Base(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Base obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      exampleJNI.delete_Base(swigCPtr);
    }
    swigCPtr = 0;
  }

  public double foo() {
    return exampleJNI.Base_foo(swigCPtr, this);
  }

  public Base() {
    this(exampleJNI.new_Base(), true);
  }

}

The Derived class extends Base mirroring the C++ class inheritance hierarchy.

public class Derived extends Base {
  private long swigCPtr;

  protected Derived(long cPtr, boolean cMemoryOwn) {
    super(exampleJNI.SWIGDerivedUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Derived obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      exampleJNI.delete_Derived(swigCPtr);
    }
    swigCPtr = 0;
    super.delete();
  }

  public double foo() {
    return exampleJNI.Derived_foo(swigCPtr, this);
  }

  public Derived() {
    this(exampleJNI.new_Derived(), true);
  }

}

Note the memory ownership is controlled by the base class. However each class in the inheritance hierarchy has its own pointer value which is obtained during construction. The SWIGDerivedUpcast() call converts the pointer from a Derived * to a Base *. This is a necessity as C++ compilers are free to implement pointers in the inheritance hierarchy with different values.

It is of course possible to extend Base using your own Java classes. If Derived is provided by the C++ code, you could for example add in a pure Java class Extended derived from Base. There is a caveat and that is any C++ code will not know about your pure Java class Extended so this type of derivation is restricted. However, true cross language polymorphism can be achieved using the directors feature.

25.4.3.3 Proxy classes and garbage collection

By default each proxy class has a delete() and a finalize() method. The finalize() method calls delete() which frees any malloc'd memory for wrapped C structs or calls the C++ class destructors. The idea is for delete() to be called when you have finished with the C/C++ object. Ideally you need not call delete(), but rather leave it to the garbage collector to call it from the finalizer. When a program exits, the garbage collector does not guarantee to call all finalizers. An insight into the reasoning behind this can be obtained from Hans Boehm's Destructors, Finalizers, and Synchronization paper. Depending on what the finalizers do and which operating system you use, this may or may not be a problem.

If the delete() call into JNI code is just for memory handling, there is not a problem when run on most operating systems, for example Windows and Unix. Say your JNI code creates memory on the heap which your finalizers should clean up, the finalizers may or may not be called before the program exits. In Windows and Unix all memory that a process uses is returned to the system on exit, so this isn't a problem. This is not the case in some operating systems like vxWorks. If however, your finalizer calls into JNI code invoking the C++ destructor which in turn releases a TCP/IP socket for example, there is no guarantee that it will be released. Note that with long running programs the garbage collector will eventually run, thereby calling any unreferenced object's finalizers.

Some not so ideal solutions are:

  1. Call the System.runFinalizersOnExit(true) or Runtime.getRuntime().runFinalizersOnExit(true) to ensure the finalizers are called before the program exits. The catch is that this is a deprecated function call as the documentation says:

    This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.

    In many cases you will be lucky and find that it works, but it is not to be advocated. Have a look at Java web site and search for runFinalizersOnExit.

  2. From jdk1.3 onwards a new function, addShutdownHook(), was introduced which is guaranteed to be called when your program exits. You can encourage the garbage collector to call the finalizers, for example, add this static block to the class that has the main() function:

      static {
        Runtime.getRuntime().addShutdownHook( 
          new Thread() {
            public void run() { System.gc(); System.runFinalization(); }
          }
        );
      }
    

    Although this usually works, the documentation doesn't guarantee that runFinalization() will actually call the finalizers. As the shutdown hook is guaranteed you could also make a JNI call to clean up any resources that are being tracked by the C/C++ code.

  3. Call the delete() function manually which will immediately invoke the C++ destructor. As a suggestion it may be a good idea to set the object to null so that should the object be inadvertently used again a Java null pointer exception is thrown, the alternative would crash the JVM by using a null C pointer. For example given a SWIG generated class A:

    A myA = new A();
    // use myA ...
    myA.delete();
    // any use of myA here would crash the JVM 
    myA=null;
    // any use of myA here would cause a Java null pointer exception to be thrown
    

    The SWIG generated code ensures that the memory is not deleted twice, in the event the finalizers get called in addition to the manual delete() call.

  4. Write your own object manager in Java. You could derive all SWIG classes from a single base class which could track which objects have had their finalizers run, then call the rest of them on program termination. The section on Java typemaps details how to specify a pure Java base class.

See the How to Handle Java Finalization's Memory-Retention Issues article for alternative approaches to managing memory by avoiding finalizers altogether.

25.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

As covered earlier, the C/C++ struct/class pointer is stored in the proxy class as a Java long and when needed is passed into the native method where it is cast into the appropriate type. This approach provides very fast marshalling but could be susceptible to premature garbage collection. Consider the following C++ code:

class Wibble {
};
void wobble(Wibble &w);

The module class contains the Java wrapper for the global wobble method:

public class example {
  ...
  public static void wobble(Wibble w) {
    exampleJNI.wobble(Wibble.getCPtr(w), w);
  }
}

where example is the name of the module. All native methods go through the intermediary class which has the native method declared as such:

public class exampleJNI {
  ...
  public final static native void wobble(long jarg1, Wibble jarg1_);
}

The second parameter, jarg1_, is the premature garbage collection prevention parameter and is added to the native method parameter list whenever a C/C++ struct or class is marshalled as a Java long. In order to understand why, consider the alternative where the intermediary class method is declared without the additional parameter:

public class exampleJNI {
  ...
  public final static native void wobble(long jarg1);
}

and the following simple call to wobble:

{
  Wibble w = new Wibble();
  example.wobble(w);
}

The hotspot compiler effectively sees something like:

{
  Wibble w = new Wibble();
  long w_ptr = Wibble.getCPtr(w);
  // w is no longer reachable
  exampleJNI.wobble(w_ptr);
}

The Wibble object is no longer reachable after the point shown as in this bit of code, the Wibble object is not referenced again after this point. This means that it is a candidate for garbage collection. Should wobble be a long running method, it is quite likely that the finalizer for the Wibble instance will be called. This in turn will call its underlying C++ destructor which is obviously disastrous while the method wobble is running using this object. Even if wobble is not a long running method, it is possible for the Wibble instance to be finalized. By passing the Wibble instance into the native method, it will not be finalized as the JVM guarantees not to finalize any objects until the native method returns. Effectively, the code then becomes

{
  Wibble w = new Wibble();
  long w_ptr = Wibble.getCPtr(w);
  exampleJNI.wobble(w_ptr, w);
  // w is no longer reachable
}

and therefore there is no possibility of premature garbage collection. In practice, this premature garbage collection was only ever observed in Sun's server JVM from jdk-1.3 onwards and in Sun's client JVM from jdk-1.6 onwards.

The premature garbage collection prevention parameter for proxy classes is generated by default whenever proxy classes are passed by value, reference or with a pointer. The implementation for this extra parameter generation requires the "jtype" typemap to contain long and the "jstype" typemap to contain the name of a proxy class.

The additional parameter does impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option. More selective suppression is possible with the 'nopgcpp' attribute in the "jtype" Java typemap. The attribute is a flag and so should be set to "1" to enable the suppression, or it can be omitted or set to "0" to disable. For example:

%typemap(jtype, nopgcpp="1") Wibble & "long"

Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

25.4.3.5 Single threaded applications and thread safety

Single threaded Java applications using JNI need to consider thread safety. The same applies for the C# module where the .NET wrappers use PInvoke. Consider the C++ class:

class Test {
  string str;
public:
  Test() : str("initial") {}
};

and the Java proxy class generated by SWIG:

public class Test {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected Test(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Test obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  // Call C++ destructor
  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      exampleJNI.delete_Test(swigCPtr);
    }
    swigCPtr = 0;
  }

  // Call C++ constructor
  public Test() {
    this(exampleJNI.new_Test(), true);
  }

}

It has two methods that call JNI methods, namely, exampleJNI.new_Test() for the C++ constructor and exampleJNI.delete_Test() for the C++ destructor. If the garbage collector collects an instance of this class, ie delete() is not explicitly called, then the C++ destructor will be run in a different thread to the main thread. This is because when an object is marked for garbage collection, any objects with finalizers are added to a finalization queue and the objects in the finalization queue have their finalize() methods run in a separate finalization thread. Therefore, if the C memory allocator is not thread safe, then the heap will get corrupted sooner or later, when a concurrent C++ delete and new are executed. It is thus essential, even in single threaded usage, to link to the C multi-thread runtime libraries, for example, use the /MD option for Visual C++ on Windows. Alternatively, lock all access to C++ functions that have heap allocation/deallocation.

Note that some of the STL in Visual C++ 6 is not thread safe, so although code might be linked to the multithread runtime libraries, undefined behaviour might still occur in a single threaded Java program. Similarly some older versions of Sun Studio have bugs in the multi-threaded implementation of the std::string class and so will lead to undefined behaviour in these supposedly single threaded Java applications.

The following innocuous Java usage of Test is an example that will crash very quickly on a multiprocessor machine if the JNI compiled code is linked against the single thread C runtime libraries.

for (int i=0; i<100000; i++) {
  System.out.println("Iteration " + i);
  for (int k=0; k<10; k++) {
    Test test = new Test();
  }
  System.gc();
}

25.4.4 Type wrapper classes

The generated type wrapper class, for say an int *, looks like this:

public class SWIGTYPE_p_int {
  private long swigCPtr;

  protected SWIGTYPE_p_int(long cPtr, boolean bFutureUse) {
    swigCPtr = cPtr;
  }

  protected SWIGTYPE_p_int() {
    swigCPtr = 0;
  }

  protected static long getCPtr(SWIGTYPE_p_int obj) {
    return obj.swigCPtr;
  }
}

The methods do not have public access, so by default it is impossible to do anything with objects of this class other than pass them around. The methods in the class are part of the inner workings of SWIG. If you need to mess around with pointers you will have to use some typemaps specific to the Java module to achieve this. The section on Java typemaps details how to modify the generated code.

Note that if you use a pointer or reference to a proxy class in a function then no type wrapper class is generated because the proxy class can be used as the function parameter. If however, you need anything more complicated like a pointer to a pointer to a proxy class then a typewrapper class is generated for your use.

Note that SWIG generates a type wrapper class and not a proxy class when it has not parsed the definition of a type that gets used. For example, say SWIG has not parsed the definition of class Snazzy because it is in a header file that you may have forgotten to use the %include directive on. Should SWIG parse Snazzy * being used in a function parameter, it will then generates a type wrapper class around a Snazzy pointer. Also recall from earlier that SWIG will use a pointer when a class is passed by value or by reference:

void spam(Snazzy *x, Snazzy &y, Snazzy z);

Should SWIG not know anything about Snazzy then a SWIGTYPE_p_Snazzy must be used for all 3 parameters in the spam function. The Java function generated is:

public static void spam(SWIGTYPE_p_Snazzy x, SWIGTYPE_p_Snazzy y, SWIGTYPE_p_Snazzy z) {
 ...
}

Note that typedefs are tracked by SWIG and the typedef name is used to construct the type wrapper class name. For example, consider the case where Snazzy is a typedef to an int which SWIG does parse:

typedef int Snazzy;
void spam(Snazzy *x, Snazzy &y, Snazzy z);

Because the typedefs have been tracked the Java function generated is:

public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... }

25.4.5 Enum classes

SWIG can generate three types of enum classes. The Enumerations section discussed these but omitted all the details. The following sub-sections detail the various types of enum classes that can be generated.

25.4.5.1 Typesafe enum classes

The following example demonstrates the typesafe enum classes which SWIG generates:

%include "enumtypesafe.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

The following is the code that SWIG generates:

public final class Beverage {
  public final static Beverage ALE = new Beverage("ALE");
  public final static Beverage LAGER = new Beverage("LAGER", 10);
  public final static Beverage STOUT = new Beverage("STOUT");
  public final static Beverage PILSNER = new Beverage("PILSNER");
  public final static Beverage PILZ = new Beverage("PILZ", PILSNER);

  public final int swigValue() {
    return swigValue;
  }

  public String toString() {
    return swigName;
  }

  public static Beverage swigToEnum(int swigValue) {
    if (swigValue < swigValues.length && swigValue >= 0 &&
        swigValues[swigValue].swigValue == swigValue)
      return swigValues[swigValue];
    for (int i = 0; i < swigValues.length; i++)
      if (swigValues[i].swigValue == swigValue)
        return swigValues[i];
    throw new IllegalArgumentException("No enum " + Beverage.class + " with value " +
                                                                         swigValue);
  }

  private Beverage(String swigName) {
    this.swigName = swigName;
    this.swigValue = swigNext++;
  }

  private Beverage(String swigName, int swigValue) {
    this.swigName = swigName;
    this.swigValue = swigValue;
    swigNext = swigValue+1;
  }

  private Beverage(String swigName, Beverage swigEnum) {
    this.swigName = swigName;
    this.swigValue = swigEnum.swigValue;
    swigNext = this.swigValue+1;
  }

  private static Beverage[] swigValues = { ALE, LAGER, STOUT, PILSNER, PILZ };
  private static int swigNext = 0;
  private final int swigValue;
  private final String swigName;
}

As can be seen, there are a fair number of support methods for the typesafe enum pattern. The typesafe enum pattern involves creating a fixed number of static instances of the enum class. The constructors are private to enforce this. Three constructors are available - two for C/C++ enums with an initializer and one for those without an initializer. Note that the two enums with initializers, LAGER and PILZ, each call one the two different initializer constructors. In order to use one of these typesafe enums, the swigToEnum static method must be called to return a reference to one of the static instances. The JNI layer returns the enum value from the C/C++ world as an integer and this method is used to find the appropriate Java enum static instance. The swigValue method is used for marshalling in the other direction. The toString method is overridden so that the enum name is available.

25.4.5.2 Proper Java enum classes

The following example demonstrates the Java enums approach:

%include "enums.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

SWIG will generate the following Java enum:

public enum Beverage {
  ALE,
  LAGER(10),
  STOUT,
  PILSNER,
  PILZ(PILSNER);

  public final int swigValue() {
    return swigValue;
  }

  public static Beverage swigToEnum(int swigValue) {
    Beverage[] swigValues = Beverage.class.getEnumConstants();
    if (swigValue < swigValues.length && swigValue >= 0 &&
        swigValues[swigValue].swigValue == swigValue)
      return swigValues[swigValue];
    for (Beverage swigEnum : swigValues)
      if (swigEnum.swigValue == swigValue)
        return swigEnum;
    throw new IllegalArgumentException("No enum " + Beverage.class +
                                       " with value " + swigValue);
  }

  private Beverage() {
    this.swigValue = SwigNext.next++;
  }

  private Beverage(int swigValue) {
    this.swigValue = swigValue;
    SwigNext.next = swigValue+1;
  }

  private Beverage(Beverage swigEnum) {
    this.swigValue = swigEnum.swigValue;
    SwigNext.next = this.swigValue+1;
  }

  private final int swigValue;

  private static class SwigNext {
    private static int next = 0;
  }
}

The enum items appear first. Like the typesafe enum pattern, the constructors are private. The constructors are required to handle C/C++ enums with initializers. The next variable is in the SwigNext inner class rather than in the enum class as static primitive variables cannot be modified from within enum constructors. Marshalling between Java enums and the C/C++ enum integer value is handled via the swigToEnum and swigValue methods. All the constructors and methods in the Java enum are required just to handle C/C++ enums with initializers. These needn't be generated if the enum being wrapped does not have any initializers and the Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.

25.4.5.3 Type unsafe enum classes

The following example demonstrates type unsafe enums:

%include "enumtypeunsafe.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

SWIG will generate the following simple class:

public final class Beverage {
  public final static int ALE = 0;
  public final static int LAGER = 10;
  public final static int STOUT = LAGER + 1;
  public final static int PILSNER = STOUT + 1;
  public final static int PILZ = PILSNER;
}

25.5 Cross language polymorphism using directors

Proxy classes provide a natural, object-oriented way to wrap C++ classes. as described earlier, each proxy instance has an associated C++ instance, and method calls from Java to the proxy are passed to the C++ instance transparently via C wrapper functions.

This arrangement is asymmetric in the sense that no corresponding mechanism exists to pass method calls down the inheritance chain from C++ to Java. In particular, if a C++ class has been extended in Java (by deriving from the proxy class), these classes will not be visible from C++ code. Virtual method calls from C++ are thus not able to access the lowest implementation in the inheritance chain.

SWIG can address this problem and make the relationship between C++ classes and proxy classes more symmetric. To achieve this goal, new classes called directors are introduced at the bottom of the C++ inheritance chain. The job of the directors is to route method calls correctly, either to C++ implementations higher in the inheritance chain or to Java implementations lower in the inheritance chain. The upshot is that C++ classes can be extended in Java and from C++ these extensions look exactly like native C++ classes. Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.

25.5.1 Enabling directors

The director feature is disabled by default. To use directors you must make two changes to the interface file. First, add the "directors" option to the %module directive, like this:

%module(directors="1") modulename

Without this option no director code will be generated. Second, you must use the %feature("director") directive to tell SWIG which classes and methods should get directors. The %feature directive can be applied globally, to specific classes, and to specific methods, like this:

// generate directors for all classes that have virtual methods
%feature("director");         

// generate directors for all virtual methods in class Foo
%feature("director") Foo;      

You can use the %feature("nodirector") directive to turn off directors for specific classes or methods. So for example,

%feature("director") Foo;
%feature("nodirector") Foo::bar;

will generate directors for all virtual methods of class Foo except bar().

Directors can also be generated implicitly through inheritance. In the following, class Bar will get a director class that handles the methods one() and two() (but not three()):

%feature("director") Foo;
class Foo {
public:
    virtual void one();
    virtual void two();
};

class Bar: public Foo {
public:
    virtual void three();
};

25.5.2 Director classes

For each class that has directors enabled, SWIG generates a new class that derives from both the class in question and a special Swig::Director class. These new classes, referred to as director classes, can be loosely thought of as the C++ equivalent of the Java proxy classes. The director classes store a pointer to their underlying Java proxy classes.

For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). Thus all virtual method calls, whether they originate in C++ or in Java via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate place" we mean the method that would have been called if the C++ base class and its Java derived classes were seamlessly integrated. That seamless integration is exactly what the director classes provide, transparently skipping over all the messy JNI glue code that binds the two languages together.

In reality, the "appropriate place" is one of only two possibilities: C++ or Java. Once this decision is made, the rest is fairly easy. If the correct implementation is in C++, then the lowest implementation of the method in the C++ inheritance chain is called explicitly. If the correct implementation is in Java, the Java API is used to call the method of the underlying Java object (after which the usual virtual method resolution in Java automatically finds the right implementation).

25.5.3 Overhead and code bloat

Enabling directors for a class will generate a new director method for every virtual method in the class' inheritance chain. This alone can generate a lot of code bloat for large hierarchies. Method arguments that require complex conversions to and from Java types can result in large director methods. For this reason it is recommended that directors are selectively enabled only for specific classes that are likely to be extended in Java and used in C++.

Although directors make it natural to mix native C++ objects with Java objects (as director objects), one should be aware of the obvious fact that method calls to Java objects from C++ will be much slower than calls to C++ objects. Additionally, compared to classes that do not use directors, the call routing in the director methods adds a small overhead. This situation can be optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in Java.

25.5.4 Simple directors example

Consider the following SWIG interface file:

%module(directors="1") example;

%feature("director") DirectorBase;

class DirectorBase {
public:
  virtual ~DirectorBase() {}
  virtual void upcall_method() {}
};

void callup(DirectorBase *director) {
  director->upcall_method();
}

The following DirectorDerived Java class is derived from the Java proxy class DirectorBase and overrides upcall_method(). When C++ code invokes upcall_method() , the SWIG-generated C++ code redirects the call via JNI to the Java DirectorDerived subclass. Naturally, the SWIG generated C++ code and the generated Java intermediary class marshal and convert arguments between C++ and Java when needed.

public class DirectorDerived extends DirectorBase {
  public DirectorDerived() {
  }

  public void upcall_method() {
    System.out.println("DirectorDerived::upcall_method() invoked.");
  }
}

Running the following Java code

DirectorDerived director = new DirectorDerived();
example.callup(director);

will result in the following being output:

DirectorDerived::upcall_method() invoked.

25.5.5 Director threading issues

Depending on your operating system and version of Java and how you are using threads, you might find the JVM hangs on exit. There are a couple of solutions to try out. The preferred solution requires jdk-1.4 and later and uses AttachCurrentThreadAsDaemon instead of AttachCurrentThread whenever a call into the JVM is required. This can be enabled by defining the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro when compiling the C++ wrapper code. For older JVMs define SWIG_JAVA_NO_DETACH_CURRENT_THREAD instead, to avoid the DetachCurrentThread call but this will result in a memory leak instead. For further details inspect the source code in the java/director.swg library file.

Macros can be defined on the commandline when compiling your C++ code, or alternatively added to the C++ wrapper file as shown below:

%insert("runtime") %{
#define SWIG_JAVA_NO_DETACH_CURRENT_THREAD
%}

25.5.6 Director performance tuning

When a new instance of a director (or subclass) is created in Java, the C++ side of the director performs a runtime check per director method to determine if that particular method is overridden in Java or if it should invoke the C++ base implementation directly. Although this makes initialization slightly more expensive, it is generally a good overall tradeoff.

However, if all director methods are expected to usually be overridden by Java subclasses, then initialization can be made faster by avoiding these checks via the assumeoverride attribute. For example:

%feature("director", assumeoverride=1) Foo;

The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

25.5.7 Java exceptions from directors

With directors routing method calls to Java, and proxies routing them to C++, the handling of exceptions is an important concern. The default behavior from SWIG 3.0 onwards is to convert the thrown Java exception into a SWIG defined DirectorException C++ exception. SWIG 2.0 and earlier versions didn't provide any mechanism to handle the Java director method exceptions in C++.

Converting Java exceptions into C++ exceptions can be done in two different ways using the director:except feature. In the simplest approach, a code block is attached to each director method to handle the mapping of Java exceptions into C++ exceptions.

%feature("director:except") MyClass::method(int x) {
  jthrowable $error = jenv->ExceptionOccurred();
  if ($error) {
    jenv->ExceptionClear();
    if (Swig::ExceptionMatches(jenv, $error, "java/lang/IndexOutOfBoundsException"))
      throw std::out_of_range(Swig::JavaExceptionMessage(jenv, $error).message());
    if (Swig::ExceptionMatches(jenv, $error, "$packagepath/MyJavaException"))
      throw MyCppException(Swig::JavaExceptionMessage(jenv, $error).message());
    throw std::runtime_error("Unexpected exception thrown in MyClass::method");
  }
}

class MyClass {
  /** Throws either a std::out_of_range or MyCppException on error */
  void method(int x);
}

This approach allows a flexible mapping of Java exceptions thrown by director methods into C++ exceptions expected by a C++ caller. There need not be any C++ exception specifications on the C++ method. The utility function Swig::ExceptionMatches and class Swig::JavaExceptionMessage are provided to simplify writing code for wrappers that use the director:except feature. The function Swig::ExceptionMatches matches the type of the jthrowable thrown against a fully qualified JNI style class name, such as "java/lang/IOError". If the throwable class is the same type, or derives from the given type, Swig::ExceptionMatches will return true. Care must be taken to provide the correct fully qualified name, since for wrapped exceptions the generated proxy class will have additional package qualification, depending on the '-package' argument and use of the nspace feature. The special variable $error is expanded by SWIG into a unique variable name and should be used for the assignment of the exception that occurred. The special variable $packagepath is replaced by the outer package provided for SWIG generation by the -package option. The utility class Swig::JavaExceptionMessage is a holder providing access to the message from the thrown Java exception. The message() method returns the exception message as a const char *, which is only valid during the lifetime of the holder. Any code using this message needs to copy it, for example into a std::string or a newly constructed C++ exception.

Using the above approach to write handlers for a large number of methods will require repetitive duplication of the director:except feature code. To mitigate this, an alternative approach is provided via typemaps in a fashion analagous to the "throws" typemap. The "throws" typemap provides an approach to automatically map all the C++ exceptions listed in a method's defined exceptions (either from a C++ exception specification or a %catches feature) into Java exceptions. The "directorthrows" typemap provides the inverse mapping and should contain code to convert a suitably matching Java exception into a C++ exception. The example below converts a Java java.lang.IndexOutOfBoundsException exception to the typemap's type, that is std::out_of_range :

%typemap(directorthrows) std::out_of_range %{
  if (Swig::ExceptionMatches(jenv, $error, "java/lang/IndexOutOfBoundsException")) {
    throw std::out_of_range(Swig::JavaExceptionMessage(jenv, $error).message());
  }
%}

The "directorthrows" typemap is then used in conjunction with the director:except feature if the $directorthrowshandlers special variable is used in the feature code. Consider the following, which also happens to be the default:

%feature("director:except") %{
   jthrowable $error = jenv->ExceptionOccurred();
   if ($error) {
     jenv->ExceptionClear();
     $directorthrowshandlers
     throw Swig::DirectorException(jenv, $error);
   }
%}

The code generated using the director:except feature replaces the $directorthrowshandlers special variable with the code in the "directorthrows" typemaps, for each and every exception defined for the method. The possible exceptions can be defined either with a C++ exception specification or %catches as described for the "throws" typemap.

Consider the following director method:

  ...
  virtual void doSomething(int index) throw (std::out_of_range);
  ...

When combined with the default director:except feature and the "directorthrows" typemap above, the resulting code generated in the director method after calling up to Java will be:

jthrowable swigerror = jenv->ExceptionOccurred();
if (swigerror) {
  jenv->ExceptionClear();
  if (Swig::ExceptionMatches(jenv, swigerror, "java/lang/IndexOutOfBoundsException")) {
    throw std::out_of_range(Swig::JavaExceptionMessage(jenv, swigerror).message());
  }
  
  throw Swig::DirectorException(jenv, swigerror);
}

Note: Beware of using exception specifications as the SWIG director methods will be generated with the same exception specifications and if the director method throws an exception that is not specified it is likely to terminate your program. See the C++ standard for more details. Using the %catches feature instead to define the handled exceptions does not suffer this potential fate.

Because the default code generation maps any unhandled Java exceptions to Swig::DirectorException, any director methods that have exception specifications may cause program termination. To simply ignore unexpected exceptions, the default handling can be changed with:

%feature("director:except") %{
   jthrowable $error = jenv->ExceptionOccurred();
   if ($error) {
     jenv->ExceptionClear();
     $directorthrowshandlers
     return $null; // exception is ignored
   }
%}

Alternatively an exception compatible with the existing director method exception specifications can be thrown. Assuming that all methods allow std::runtime_error to be thrown, the return $null; could be changed to:

   throw std::runtime_error(Swig::JavaExceptionMessage(jenv, $error).message());

In more complex situations, a separate director:except feature may need to be attached to specific methods.

Below is a complete example demonstrating the use of the "directorthrows" typemaps. In this example, a generic "directorthrows" typemap is appropriate for all three exceptions - all take single string constructors. If the exceptions had different constructors, it would be neccessary to have separate typemaps for each exception type.

%module(directors="1") example

%{
  #include <string>
  #include <stdexcept>
%}

// Define exceptions in header section using std::runtime_error
%define DEFINE_EXCEPTION(NAME)
%{
  namespace MyNS {
    struct NAME : public std::runtime_error { NAME(const std::string &what) : runtime_error(what) {} };
  }
%}
%enddef

// Expose C++ exceptions as Java Exceptions by changing the Java base class and providing a getMessage()
%define DECLARE_EXCEPTION(NAME)
%typemap(javabase) MyNS::NAME "java.lang.Exception";
%rename(getMessage) MyNS::NAME::what;
namespace MyNS {
  struct NAME {
    NAME(const std::string& what);
    const char * what();
  };
}
%enddef

DEFINE_EXCEPTION(ExceptionA)
DEFINE_EXCEPTION(ExceptionB)
DEFINE_EXCEPTION(Unexpected)

// Mark three methods to map director thrown exceptions.
%feature("director:except") MyClass::meth1(int);
%feature("director:except") MyClass::meth2;
%feature("director:except") meth3;

%typemap(directorthrows) MyNS::ExceptionA, MyNS::ExceptionB, MyNS::Unexpected %{
  if (Swig::ExceptionMatches(jenv, $error, "$packagepath/$javaclassname"))
    throw $1_type(Swig::JavaExceptionMessage(jenv, $error).message());
%}

DECLARE_EXCEPTION(ExceptionA)
DECLARE_EXCEPTION(ExceptionB)
DECLARE_EXCEPTION(Unexpected)

%catches(MyNS::ExceptionA, MyNS::ExceptionB, MyNS::Unexpected) MyClass::meth2();

%inline {
  class MyClass {
  public:
    virtual void meth1(int x) throw(MyNS::ExceptionA, MyNS::ExceptionB) = 0;
    virtual void meth2() = 0;   /* throws MyNS::ExceptionA, MyNS::ExceptionB, MyNS::Unexpected */
    virtual void meth3(float x) throw(MyNS::Unexpected) = 0;
    virtual ~MyClass() {}
  };
}

In this case the three different "directorthrows" typemaps will be used to generate the three different exception handlers for meth1 , meth2 and meth3. The generated handlers will have "if" blocks for each exception type specified, in the exception specification or %catches feature.

Note that the "directorthrows" typemaps are important only if it is important for the the exceptions passed through the C++ layer to be mapped to distinct C++ exceptions. If director methods are being called by C++ code that is itself wrapped in a SWIG generated Java wrapper and access is always through this wrapper, the default Swig::DirectorException class provides enough information to reconstruct the original exception. In this case removing the $directorthrowshandlers special variable from the default director:except feature and simply always throwing a Swig::DirectorException will achieve the desired result. Along with this a generic exception feature is added to convert any caught Swig::DirectorExceptions back into the underlying Java exceptions via the Swig::DirectorException::raiseJavaException method, as demonstrated with %javaexception below:

%javaexception("Exception") MyClass::myMethod %{
  try {
    $action
  } catch (Swig::DirectorException &e) {
    // raise/throw the Java exception that originally caused the DirectorException
    e.raiseJavaException(jenv);
    return $null;
  }
%}

See the Exception handling with %exception and %javaexception section for more on converting C++ exceptions to Java exceptions.

25.6 Accessing protected members

When using directors, the protected virtual methods are also wrapped. These methods are wrapped with a protected Java proxy method, so the only way that Java code can access these is from within a Java class derived from the director class.

Members which are protected and non-virtual can also be accessed when using the 'allprotected' mode. The allprotected mode requires directors and is turned on by setting the allprotected option in addition to the directors option in the %module directive, like this:

%module(directors="1", allprotected="1") modulename

Protected member variables and methods (both static and non-static) will then be wrapped with protected access in the Java proxy class.

Note: Neither the directors option nor the allprotected mode support types defined with protected scope. This includes any enums or typedefs declared in the protected section of the C++ class.

The following simple example is a class with numerous protected members, including the constructor and destructor:

%module(directors="1", allprotected="1") example

%feature("director") ProtectedBase;

// Ignore use of unsupported types (those defined in the protected section)
%ignore ProtectedBase::typedefs;

%inline %{

class ProtectedBase {
protected:
  ProtectedBase() {}
  virtual ~ProtectedBase() {}
  virtual void virtualMethod() const {}
  void nonStaticMethod(double d) const {}
  static void staticMethod(int i) {}
  int instanceMemberVariable;
  static int staticMemberVariable;

  // unsupported: types defined with protected access and the methods/variables which use them
  typedef int IntegerType;
  IntegerType typedefs(IntegerType it) { return it; }
};
int ProtectedBase::staticMemberVariable = 10;

%}

Note that the IntegerType has protected scope and the members which use this type must be ignored as they cannot be wrapped.

The proxy methods are protected, so the only way the protected members can be accessed is within a class that derives from the director class, such as the following:

class MyProtectedBase extends ProtectedBase
{
  public MyProtectedBase() {
  }

  public void accessProtected() {
    virtualMethod();
    nonStaticMethod(1.2);
    staticMethod(99);

    setInstanceMemberVariable(5);
    int i = getInstanceMemberVariable();

    setStaticMemberVariable(10);
    i = getStaticMemberVariable();
  }
}

25.7 Common customization features

An earlier section presented the absolute basics of C/C++ wrapping. If you do nothing but feed SWIG a header file, you will get an interface that mimics the behavior described. However, sometimes this isn't enough to produce a nice module. Certain types of functionality might be missing or the interface to certain functions might be awkward. This section describes some common SWIG features that are used to improve the interface to existing C/C++ code.

25.7.1 C/C++ helper functions

Sometimes when you create a module, it is missing certain bits of functionality. For example, if you had a function like this

typedef struct Image {...};
void set_transform(Image *im, double m[4][4]);

it would be accessible from Java, but there may be no easy way to call it. The problem here is that a type wrapper class is generated for the two dimensional array parameter so there is no easy way to construct and manipulate a suitable double [4][4] value. To fix this, you can write some extra C helper functions. Just use the %inline directive. For example:

%inline %{
/* Note: double[4][4] is equivalent to a pointer to an array double (*)[4] */
double (*new_mat44())[4] {
   return (double (*)[4]) malloc(16*sizeof(double));
}
void free_mat44(double (*x)[4]) {
   free(x);
}
void mat44_set(double x[4][4], int i, int j, double v) {
   x[i][j] = v;
}
double mat44_get(double x[4][4], int i, int j) {
   return x[i][j];
}
%}

From Java, you could then write code like this:

Image im = new Image();
SWIGTYPE_p_a_4__double a = example.new_mat44();
example.mat44_set(a,0,0,1.0);
example.mat44_set(a,1,1,1.0);
example.mat44_set(a,2,2,1.0);
...
example.set_transform(im,a);
example.free_mat44(a);

Admittedly, this is not the most elegant looking approach. However, it works and it wasn't too hard to implement. It is possible to improve on this using Java code, typemaps, and other customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.

25.7.2 Class extension with %extend

One of the more interesting features of SWIG is that it can extend structures and classes with new methods or constructors. Here is a simple example:

%module example
%{
#include "someheader.h"
%}

struct Vector {
   double x,y,z;
};

%extend Vector {
   char *toString() {
       static char tmp[1024];
       sprintf(tmp,"Vector(%g,%g,%g)", $self->x,$self->y,$self->z);
       return tmp;
   }
   Vector(double x, double y, double z) {
       Vector *v = (Vector *) malloc(sizeof(Vector));
       v->x = x;
       v->y = y;
       v->z = z;
       return v;
   }
};

Now, in Java

Vector v = new Vector(2,3,4);
System.out.println(v);

will display

Vector(2,3,4)

%extend works with both C and C++ code. It does not modify the underlying object in any way---the extensions only show up in the Java interface.

25.7.3 Exception handling with %exception and %javaexception

If a C or C++ function throws an error, you may want to convert that error into a Java exception. To do this, you can use the %exception directive. The %exception directive simply lets you rewrite part of the generated wrapper code to include an error check. It is detailed in full in the Exception handling with %exception section.

In C, a function often indicates an error by returning a status code (a negative number or a NULL pointer perhaps). Here is a simple example of how you might handle that:

%exception malloc {
  $action
  if (!result) {
    jclass clazz = (*jenv)->FindClass(jenv, "java/lang/OutOfMemoryError");
    (*jenv)->ThrowNew(jenv, clazz, "Not enough memory");
    return $null;
  }
}
void *malloc(size_t nbytes);

In Java,

SWIGTYPE_p_void a = example.malloc(2000000000);

will produce a familiar looking Java exception:

Exception in thread "main" java.lang.OutOfMemoryError: Not enough memory
        at exampleJNI.malloc(Native Method)
        at example.malloc(example.java:16)
        at runme.main(runme.java:112)

If a library provides some kind of general error handling framework, you can also use that. For example:

%exception malloc {
  $action
  if (err_occurred()) {
    jclass clazz = (*jenv)->FindClass(jenv, "java/lang/OutOfMemoryError");
    (*jenv)->ThrowNew(jenv, clazz, "Not enough memory");
    return $null;
  }
}
void *malloc(size_t nbytes);

If no declaration name is given to %exception, it is applied to all wrapper functions. The $action is a SWIG special variable and is replaced by the C/C++ function call being wrapped. The return $null; handles all native method return types, namely those that have a void return and those that do not. This is useful for typemaps that will be used in native method returning all return types. See the section on Java special variables for further explanation.

C++ exceptions are also easy to handle. We can catch the C++ exception and rethrow it as a Java exception like this:

%exception getitem {
  try {
     $action
  } catch (std::out_of_range &e) {
    jclass clazz = jenv->FindClass("java/lang/Exception");
    jenv->ThrowNew(clazz, "Range error");
    return $null;
   }
}

class FooClass {
public:
     FooClass *getitem(int index);      // Might throw std::out_of_range exception
     ...
};

In the example above, java.lang.Exception is a checked exception class and so ought to be declared in the throws clause of getitem. Classes can be specified for adding to the throws clause using %javaexception(classes) instead of %exception, where classes is a string containing one or more comma separated Java classes. The %clearjavaexception feature is the equivalent to %clearexception and clears previously declared exception handlers. The %nojavaexception feature is the equivalent to %noexception and disables the exception handler. See Clearing features for the difference on disabling and clearing features.

%javaexception("java.lang.Exception") getitem {
  try {
     $action
  } catch (std::out_of_range &e) {
    jclass clazz = jenv->FindClass("java/lang/Exception");
    jenv->ThrowNew(clazz, "Range error");
    return $null;
   }
}

class FooClass {
public:
     FooClass *getitem(int index);      // Might throw std::out_of_range exception
     ...
};

The generated proxy method now generates a throws clause containing java.lang.Exception:

public class FooClass {
  ...
  public FooClass getitem(int index) throws java.lang.Exception { ... }
  ...
}

The examples above first use the C JNI calling syntax then the C++ JNI calling syntax. The C++ calling syntax will not compile as C and also vice versa. It is however possible to write JNI calls which will compile under both C and C++ and is covered in the Typemaps for both C and C++ compilation section.

The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter. The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities.

25.7.4 Method access with %javamethodmodifiers

A Java feature called %javamethodmodifiers can be used to change the method modifiers from the default public. It applies to both module class methods and proxy class methods. For example:

%javamethodmodifiers protect_me() "protected";
void protect_me();

Will produce the method in the module class with protected access.

protected static void protect_me() {
  exampleJNI.protect_me();
}

25.8 Tips and techniques

Although SWIG is largely automatic, there are certain types of wrapping problems that require additional user input. Examples include dealing with output parameters, strings and arrays. This chapter discusses the common techniques for solving these problems.

25.8.1 Input and output parameters using primitive pointers and references

A common problem in some C programs is handling parameters passed as simple pointers or references. For example:

void add(int x, int y, int *result) {
   *result = x + y;
}

or perhaps

int sub(int *x, int *y) {
   return *x-*y;
}

The typemaps.i library file will help in these situations. For example:

%module example
%include "typemaps.i"

void add(int, int, int *OUTPUT);
int  sub(int *INPUT, int *INPUT);

In Java, this allows you to pass simple values. For example:

int result = example.sub(7,4);
System.out.println("7 - 4 = " + result);
int[] sum = {0};
example.add(3,4,sum);
System.out.println("3 + 4 = " + sum[0]);

Which will display:

7 - 4 = 3
3 + 4 = 7

Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter will return the result in the first element of the integer array.

If you don't want to use the names INPUT or OUTPUT , use the %apply directive. For example:

%module example
%include "typemaps.i"

%apply int *OUTPUT { int *result };
%apply int *INPUT  { int *x, int *y};

void add(int x, int y, int *result);
int  sub(int *x, int *y);

If a function mutates one of its parameters like this,

void negate(int *x) {
   *x = -(*x);
}

you can use INOUT like this:

%include "typemaps.i"
...
void negate(int *INOUT);

In Java, the input parameter is the first element in a 1 element array and is replaced by the output of the function. For example:

int[] neg = {3};
example.negate(neg);
System.out.println("Negative of 3 = " + neg[0]);

And no prizes for guessing the output:

Negative of 3 = -3

These typemaps can also be applied to C++ references. The above examples would work the same if they had been defined using references instead of pointers. For example, the Java code to use the negate function would be the same if it were defined either as it is above:

void negate(int *INOUT);

or using a reference:

void negate(int &INOUT);

Note: Since most Java primitive types are immutable and are passed by value, it is not possible to perform in-place modification of a type passed as a parameter.

Be aware that the primary purpose of the typemaps.i file is to support primitive datatypes. Writing a function like this

void foo(Bar *OUTPUT);

will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

25.8.2 Simple pointers

If you must work with simple pointers such as int * or double * another approach to using typemaps.i is to use the cpointer.i pointer library file. For example:

%module example
%include "cpointer.i"

%inline %{
extern void add(int x, int y, int *result);
%}

%pointer_functions(int, intp);

The %pointer_functions(type,name) macro generates five helper functions that can be used to create, destroy, copy, assign, and dereference a pointer. In this case, the functions are as follows:

int  *new_intp();
int  *copy_intp(int *x);
void  delete_intp(int *x);
void  intp_assign(int *x, int value);
int   intp_value(int *x);

In Java, you would use the functions like this:

SWIGTYPE_p_int intPtr = example.new_intp();
example.add(3,4,intPtr);
int result = example.intp_value(intPtr);
System.out.println("3 + 4 = " + result);

If you replace %pointer_functions(int,intp) by %pointer_class(int,intp), the interface is more class-like.

intp intPtr = new intp();
example.add(3,4,intPtr.cast());
int result = intPtr.value();
System.out.println("3 + 4 = " + result);

See the SWIG Library chapter for further details.

25.8.3 Wrapping C arrays with Java arrays

SWIG can wrap arrays in a more natural Java manner than the default by using the arrays_java.i library file. Let's consider an example:

%include "arrays_java.i";
int array[4];
void populate(int x[]) {
    int i;
    for (i=0; i<4; i++)
        x[i] = 100 + i;
}

These one dimensional arrays can then be used as if they were Java arrays:

int[] array = new int[4];
example.populate(array);

System.out.print("array: ");
for (int i=0; i<array.length; i++)
    System.out.print(array[i] + " ");

example.setArray(array);

int[] global_array = example.getArray();

System.out.print("\nglobal_array: ");
for (int i=0; i<array.length; i++)
    System.out.print(global_array[i] + " ");

Java arrays are always passed by reference, so any changes a function makes to the array will be seen by the calling function. Here is the output after running this code:

array: 100 101 102 103
global_array: 100 101 102 103

Note that for assigning array variables the length of the C variable is used, so it is possible to use a Java array that is bigger than the C code will cope with. Only the number of elements in the C array will be used. However, if the Java array is not large enough then you are likely to get a segmentation fault or access violation, just like you would in C. When arrays are used in functions like populate, the size of the C array passed to the function is determined by the size of the Java array.

Please be aware that the typemaps in this library are not efficient as all the elements are copied from the Java array to a C array whenever the array is passed to and from JNI code. There is an alternative approach using the SWIG array library and this is covered in the next section.

25.8.4 Unbounded C Arrays

Sometimes a C function expects an array to be passed as a pointer. For example,

int sumitems(int *first, int nitems) {
    int i, sum = 0;
    for (i = 0; i < nitems; i++) {
        sum += first[i];
    }
    return sum;
}

One of the ways to wrap this is to apply the Java array typemaps that come in the arrays_java.i library file:

%include "arrays_java.i"
%apply int[] {int *};

The ANY size will ensure the typemap is applied to arrays of all sizes. You could narrow the typemap matching rules by specifying a particular array size. Now you can use a pure Java array and pass it to the C code:

int[] array = new int[10000000];          // Array of 10-million integers
for (int i=0; i<array.length; i++) {      // Set some values
  array[i] = i;
}
int sum = example.sumitems(array,10000);
System.out.println("Sum = " + sum);

and the sum would be displayed:

Sum = 49995000

This approach is probably the most natural way to use arrays. However, it suffers from performance problems when using large arrays as a lot of copying of the elements occurs in transferring the array from the Java world to the C++ world. An alternative approach to using Java arrays for C arrays is to use an alternative SWIG library file carrays.i. This approach can be more efficient for large arrays as the array is accessed one element at a time. For example:

%include "carrays.i"
%array_functions(int, intArray);

The %array_functions(type,name) macro generates four helper functions that can be used to create and destroy arrays and operate on elements. In this case, the functions are as follows:

int *new_intArray(int nelements);
void delete_intArray(int *x);
int intArray_getitem(int *x, int index);
void intArray_setitem(int *x, int index, int value);

In Java, you would use the functions like this:

SWIGTYPE_p_int array = example.new_intArray(10000000);  // Array of 10-million integers
for (int i=0; i<10000; i++) {                           // Set some values
    example.intArray_setitem(array,i,i);
}
int sum = example.sumitems(array,10000);
System.out.println("Sum = " + sum);

If you replace %array_functions(int,intp) by %array_class(int,intp), the interface is more class-like and a couple more helper functions are available for casting between the array and the type wrapper class.

%include "carrays.i"
%array_class(int, intArray);

The %array_class(type, name) macro creates wrappers for an unbounded array object that can be passed around as a simple pointer like int * or double *. For instance, you will be able to do this in Java:

intArray array = new intArray(10000000);  // Array of 10-million integers
for (int i=0; i<10000; i++) {             // Set some values
    array.setitem(i,i);
}
int sum = example.sumitems(array.cast(),10000);
System.out.println("Sum = " + sum);

The array "object" created by %array_class() does not encapsulate pointers inside a special array object. In fact, there is no bounds checking or safety of any kind (just like in C). Because of this, the arrays created by this library are extremely low-level indeed. You can't iterate over them nor can you even query their length. In fact, any valid memory address can be accessed if you want (negative indices, indices beyond the end of the array, etc.). Needless to say, this approach is not going to suit all applications. On the other hand, this low-level approach is extremely efficient and well suited for applications in which you need to create buffers, package binary data, etc.

25.8.5 Binary data vs Strings

By default SWIG handles char * as a string but there is a handy multi-argument typemap available as mentioned in Passing binary data. The following simple example demonstrates using a byte array instead of passing the default string type and length to the wrapped function.

%apply (char *STRING, size_t LENGTH) { (const char data[], size_t len) }
%inline %{
void binaryChar1(const char data[], size_t len) {
  printf("len: %d data: ", len);
  for (size_t i=0; i<len; ++i)
    printf("%x ", data[i]);
  printf("\n");
}
%}

Calling from Java requires just the byte array to be passed in as the multi-argument typemap being applied reduces the number of arguments in the target language to one, from the original two:

byte[] data = "hi\0jk".getBytes();
example.binaryChar1(data);     

resulting in the output

$ java runme
len: 5 data: 68 69 0 6a 6b

25.8.6 Overriding new and delete to allocate from Java heap

Unlike some languages supported by SWIG, Java has a true garbage collection subsystem. Other languages will free SWIG wrapped objects when their reference count reaches zero. Java only schedules these objects for finalization, which may not occur for some time. Because SWIG objects are allocated on the C heap, Java users may find the JVM memory use quickly exceeds the assigned limits, as memory fills with unfinalized proxy objects. Forcing garbage collection is clearly an undesirable solution.

An elegant fix for C++ users is to override new and delete using the following code (here shown included in a SWIG interface file)

/* File: java_heap.i */
%module test
%{
#include <stdexcept>
#include "jni.h"

/**
 *  A stash area embedded in each allocation to hold java handles
 */
struct Jalloc {
  jbyteArray jba;
  jobject ref;
};

static JavaVM *cached_jvm = 0;

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
  cached_jvm = jvm;
  return JNI_VERSION_1_2;
}

static JNIEnv * JNU_GetEnv() {
  JNIEnv *env;
  jint rc = cached_jvm->GetEnv((void **)&env, JNI_VERSION_1_2);
  if (rc == JNI_EDETACHED)
    throw std::runtime_error("current thread not attached");
  if (rc == JNI_EVERSION)
    throw std::runtime_error("jni version not supported");
  return env;
}

void * operator new(size_t t) {
  if (cached_jvm != 0) {
    JNIEnv *env = JNU_GetEnv();
    jbyteArray jba = env->NewByteArray((int) t + sizeof(Jalloc));
    if (env->ExceptionOccurred())
      throw bad_alloc();
    void *jbuffer = static_cast<void *>(env->GetByteArrayElements(jba, 0));
    if (env->ExceptionOccurred())
      throw bad_alloc();
    Jalloc *pJalloc = static_cast<Jalloc *>(jbuffer);
    pJalloc->jba = jba;
    /* Assign a global reference so byte array will persist until delete'ed */
    pJalloc->ref = env->NewGlobalRef(jba);
    if (env->ExceptionOccurred())
      throw bad_alloc();
    return static_cast<void *>(static_cast<char *>(jbuffer) + sizeof(Jalloc));
  }
  else { /* JNI_OnLoad not called, use malloc and mark as special */
    Jalloc *pJalloc = static_cast<Jalloc *>(malloc((int) t + sizeof(Jalloc)));
    if (!pJalloc)
      throw bad_alloc();
    pJalloc->ref = 0;
    return static_cast<void *>(
        static_cast<char *>(static_cast<void *>(pJalloc)) + sizeof(Jalloc));
  }
}

void operator delete(void *v) {
  if (v != 0) {
    void *buffer = static_cast<void *>( static_cast<char *>(v) - sizeof(Jalloc));
    Jalloc *pJalloc = static_cast<Jalloc *>(buffer);
    if (pJalloc->ref) {
      JNIEnv *env = JNU_GetEnv();
      env->DeleteGlobalRef(pJalloc->ref);
      env->ReleaseByteArrayElements(pJalloc->jba, static_cast<jbyte *>(buffer), 0);
    }
    else {
      free(buffer);
    }
  }
}
%}
...

This code caches the Java environment during initialization, and when new is called, a Java ByteArray is allocated to provide the SWIG objects with space in the Java heap. This has the combined effect of re-asserting the Java virtual machine's limit on memory allocation, and puts additional pressure on the garbage collection system to run more frequently. This code is made slightly more complicated because allowances must be made if new is called before the JNI_OnLoad is executed. This can happen during static class initialization, for example.

Unfortunately, because most Java implementations call malloc and free, this solution will not work for C wrapped structures. However, you are free to make functions that allocate and free memory from the Java heap using this model and use these functions in place of malloc and free in your own code.

25.9 Java typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. You are advised to be familiar with the material in the " Typemaps" chapter. While not absolutely essential knowledge, this section assumes some familiarity with the Java Native Interface (JNI). JNI documentation can be consulted either online at Sun's Java web site or from a good JNI book. The following two books are recommended:

  • Title: 'Essential JNI: Java Native Interface.' Author: Rob Gordon. Publisher: Prentice Hall. ISBN: 0-13-679895-0.
  • Title: 'The Java Native Interface: Programmer's Guide and Specification.' Author: Sheng Liang. Publisher: Addison-Wesley. ISBN: 0-201-32577-2. Also available online at the Sun Developer Network.

Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the generated code.

25.9.1 Default primitive type mappings

The following table lists the default type mapping from Java to C/C++.

C/C++ typeJava typeJNI type
bool
const bool &
booleanjboolean
char
const char &
charjchar
signed char
const signed char &
bytejbyte
unsigned char
const unsigned char &
shortjshort
short
const short &
shortjshort
unsigned short
const unsigned short &
intjint
int
const int &
intjint
unsigned int
const unsigned int &
longjlong
long
const long &
intjint
unsigned long
const unsigned long &
longjlong
long long
const long long &
longjlong
unsigned long long
const unsigned long long &
java.math.BigInteger jobject
float
const float &
floatjfloat
double
const double &
doublejdouble
char *
char []
Stringjstring

Note that SWIG wraps the C char type as a character. Pointers and arrays of this type are wrapped as strings. The signed char type can be used if you want to treat char as a signed number rather than a character. Also note that all const references to primitive types are treated as if they are passed by value.

Given the following C function:

void func(unsigned short a, char *b, const long &c, unsigned long long d);

The module class method would be:

public static void func(int a, String b, int c, java.math.BigInteger d) {...}

The intermediary JNI class would use the same types:

public final static native void func(int jarg1, String jarg2, int jarg3,
                                     java.math.BigInteger jarg4);

and the JNI function would look like this:

SWIGEXPORT void JNICALL Java_exampleJNI_func(JNIEnv *jenv, jclass jcls,
                jint jarg1, jstring jarg2, jint jarg3, jobject jarg4) {...}

The mappings for C int and C long are appropriate for 32 bit applications which are used in the 32 bit JVMs. There is no perfect mapping between Java and C as Java doesn't support all the unsigned C data types. However, the mappings allow the full range of values for each C type from Java.

25.9.2 Default typemaps for non-primitive types

The previous section covered the primitive type mappings. Non-primitive types such as classes and structs are mapped using pointers on the C/C++ side and storing the pointer into a Java long variable which is held by the proxy class or type wrapper class. This applies whether the type is marshalled as a pointer, by reference or by value. It also applies for any unknown/incomplete types which use type wrapper classes.

So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit Java long type and therefore the JNI type is a jlong. The Java type is either the proxy class or type wrapper class.

25.9.3 Sixty four bit JVMs

If you are using a 64 bit JVM you may have to override the C long, but probably not C int default mappings. Mappings will be system dependent, for example long will need remapping on Unix LP64 systems (long, pointer 64 bits, int 32 bits), but not on Microsoft 64 bit Windows which will be using a P64 IL32 (pointer 64 bits and int, long 32 bits) model. This may be automated in a future version of SWIG. Note that the Java write once run anywhere philosophy holds true for all pure Java code when moving to a 64 bit JVM. Unfortunately it won't of course hold true for JNI code.

25.9.4 What is a typemap?

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Java to C, you might define a typemap like this:

%module example

%typemap(in) int {
  $1 = $input;
  printf("Received an integer : %d\n",  $1);
}
%inline %{
extern int fact(int nonnegative);
%}

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variables prefaced by a $ are used. The $1 variable is a placeholder for a local variable of type int. The $input variable contains the Java data, the JNI jint in this case.

When this example is compiled into a Java module, it can be used as follows:

System.out.println(example.fact(6));

and the output will be:

Received an integer : 6
720

In this example, the typemap is applied to all occurrences of the int datatype. You can refine this by supplying an optional parameter name. For example:

%module example

%typemap(in) int nonnegative {
  $1 = $input;
  printf("Received an integer : %d\n",  $1);
}

%inline %{
extern int fact(int nonnegative);
%}

In this case, the typemap code is only attached to arguments that exactly match int nonnegative.

The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG C++ type-system. When you define a typemap for int, that typemap applies to int and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

%typemap(in) int nonnegative {
  $1 = $input;
  printf("Received an integer : %d\n",  $1);
}
%inline %{
typedef int Integer;
extern int fact(Integer nonnegative);    // Above typemap is applied
%}

However, the matching of typedef only occurs in one direction. If you defined a typemap for Integer, it is not applied to arguments of type int.

Typemaps can also be defined for groups of consecutive arguments. For example:

%typemap(in) (char *str, int len) {
...
};

int count(char c, char *str, int len);

When a multi-argument typemap is defined, the arguments are always handled as a single Java parameter. This allows the function to be used like this (notice how the length parameter is omitted):

int c = example.count('e',"Hello World");

25.9.5 Typemaps for mapping C/C++ types to Java types

The typemaps available to the Java module include the common typemaps listed in the main typemaps section. There are a number of additional typemaps which are necessary for using SWIG with Java. The most important of these implement the mapping of C/C++ types to Java types:


 
TypemapDescription
jniJNI C types. These provide the default mapping of types from C/C++ to JNI for use in the JNI (C/C++) code.
jtypeJava intermediary types. These provide the default mapping of types from C/C++ to Java for use in the native functions in the intermediary JNI class. The type must be the equivalent Java type for the JNI C type specified in the "jni" typemap.
jstypeJava types. These provide the default mapping of types from C/C++ to Java for use in the Java module class, proxy classes and type wrapper classes.
javainConversion from jstype to jtype. These are Java code typemaps which transform the type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap) to the type used in the Java intermediary JNI class (as specified in the "jtype" typemap). In other words the typemap provides the conversion to the native method call parameter types.
javaoutConversion from jtype to jstype. These are Java code typemaps which transform the type used in the Java intermediary JNI class (as specified in the "jtype" typemap) to the Java type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap). In other words the typemap provides the conversion from the native method call return type.
javadirectorinConversion from jtype to jstype for director methods. These are Java code typemaps which transform the type used in the Java intermediary JNI class (as specified in the "jtype" typemap) to the Java type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap). This typemap provides the conversion for the parameters in the director methods when calling up from C++ to Java. See Director typemaps.
javadirectoroutConversion from jstype to jtype for director methods. These are Java code typemaps which transform the type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap) to the type used in the Java intermediary JNI class (as specified in the "jtype" typemap). This typemap provides the conversion for the return type in the director methods when returning from the C++ to Java upcall. See Director typemaps.
directorinConversion from C++ type to jni type for director methods. These are C++ typemaps which convert the parameters used in the C++ director method to the appropriate JNI intermediary type. The conversion is done in JNI code prior to calling the Java function from the JNI code. See Director typemaps.
directoroutConversion from jni type to C++ type for director methods. These are C++ typemaps which convert the JNI return type used in the C++ director method to the appropriate C++ return type. The conversion is done in JNI code after calling the Java function from the JNI code. See Director typemaps.

If you are writing your own typemaps to handle a particular type, you will normally have to write a collection of them. The default typemaps are in "java.swg" and so might be a good place for finding typemaps to base any new ones on.

The "jni", "jtype" and "jstype" typemaps are usually defined together to handle the Java to C/C++ type mapping. An "in" typemap should be accompanied by a "javain" typemap and likewise an "out" typemap by a "javaout" typemap. If an "in" typemap is written, a "freearg" and "argout" typemap may also need to be written as some types have a default "freearg" and/or "argout" typemap which may need overriding. The "freearg" typemap sometimes releases memory allocated by the "in" typemap. The "argout" typemap sometimes sets values in function parameters which are passed by reference in Java.

Note that the "in" typemap marshals the JNI type held in the "jni" typemap to the real C/C++ type and for the opposite direction, the "out" typemap marshals the real C/C++ type to the JNI type held in the "jni" typemap. For non-primitive types the "in" and "out" typemaps are responsible for casting between the C/C++ pointer and the 64 bit jlong type. There is no portable way to cast a pointer into a 64 bit integer type and the approach taken by SWIG is mostly portable, but breaks C/C++ aliasing rules. In summary, these rules state that a pointer to any type must never be dereferenced by a pointer to any other incompatible type. The following code snippet might aid in understand aliasing rules better:

    short a;
    short* pa = 0;
    int i = 0x1234;

    a = (short)i;    /* okay */
    a = *(short*)&i; /* breaks aliasing rules */

An email posting, Aliasing, pointer casts and gcc 3.3 elaborates further on the subject. In SWIG, the "in" and "out" typemaps for pointers are typically

    %typemap(in) struct Foo * %{
      $1 = *(struct Foo **)&$input; /* cast jlong into C ptr */
    %}
    %typemap(out) struct Bar * %{
      *(struct Bar **)&$result = $1; /* cast C ptr into jlong */
    %} 
    struct Bar {...};
    struct Foo {...};
    struct Bar * FooBar(struct Foo *f);

resulting in the following code which breaks the aliasing rules:

SWIGEXPORT jlong JNICALL Java_exampleJNI_FooBar(JNIEnv *jenv, jclass jcls,
                                                jlong jarg1, jobject jarg1_) {
  jlong jresult = 0 ;
  struct Foo *arg1 = (struct Foo *) 0 ;
  struct Bar *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  (void)jarg1_;
  arg1 = *(struct Foo **)&jarg1; 
  result = (struct Bar *)FooBar(arg1);
  *(struct Bar **)&jresult = result; 
  return jresult;
}

If you are using gcc as your C compiler, you might get a "dereferencing type-punned pointer will break strict-aliasing rules" warning about this. Please see Compiling a dynamic module to avoid runtime problems with these strict aliasing rules.

The default code generated by SWIG for the Java module comes from the typemaps in the "java.swg" library file which implements the Default primitive type mappings and Default typemaps for non-primitive types covered earlier. There are other type mapping typemaps in the Java library. These are listed below:


 
C TypeTypemap FileKindJava Type Function
primitive pointers and referencesINPUT typemaps.iinputJava basic typesAllows values to be used for C functions taking pointers for data input.
primitive pointers and referencesOUTPUT typemaps.ioutputJava basic type arraysAllows values held within an array to be used for C functions taking pointers for data output.
primitive pointers and referencesINOUT typemaps.iinput
output
Java basic type arraysAllows values held within an array to be used for C functions taking pointers for data input and output.
string
wstring
[unnamed]std_string.iinput
output
StringUse for std::string mapping to Java String.
arrays of primitive types[unnamed] arrays_java.iinput
output
arrays of primitive Java typesUse for mapping C arrays to Java arrays.
arrays of classes/structs/unionsJAVA_ARRAYSOFCLASSES macroarrays_java.iinput
output
arrays of proxy classesUse for mapping C arrays to Java arrays.
arrays of enumsARRAYSOFENUMSarrays_java.i input
output
int[]Use for mapping C arrays to Java arrays (typeunsafe and simple enum wrapping approaches only).
char *BYTEvarious.iinput byte[]Java byte array is converted to char array
char **STRING_ARRAYvarious.iinput
output
String[]Use for mapping NULL terminated arrays of C strings to Java String arrays

25.9.6 Java typemap attributes

There are a few additional typemap attributes that the Java module supports.

The first of these is the 'throws' attribute. The throws attribute is optional and specified after the typemap name and contains one or more comma separated classes for adding to the throws clause for any methods that use that typemap. It is analogous to the %javaexception feature's throws attribute.

%typemap(typemapname, throws="ExceptionClass1, ExceptionClass2") type { ... }

The attribute is necessary for supporting Java checked exceptions and can be added to just about any typemap. The list of typemaps include all the C/C++ (JNI) typemaps in the " Typemaps" chapter and the Java specific typemaps listed in the previous section, barring the "jni", "jtype" and "jstype" typemaps as they could never contain code to throw an exception.

The throws clause is generated for the proxy method as well as the JNI method in the JNI intermediary class. If a method uses more than one typemap and each of those typemaps have classes specified in the throws clause, the union of the exception classes is added to the throws clause ensuring there are no duplicate classes. See the NaN exception example for further usage.

The "jtype" typemap has the optional 'nopgcpp' attribute which can be used to suppress the generation of the premature garbage collection prevention parameter.

The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. These are used for generating code before and after the JNI call in the proxy class or module class. The 'pre' attribute contains code that is generated before the JNI call and the 'post' attribute contains code generated after the JNI call. The 'pgcppname' attribute is used to change the premature garbage collection prevention parameter name passed to the JNI function. This is sometimes needed when the 'pre' typemap creates a temporary variable which is then passed to the JNI function.

Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.

25.9.7 Java special variables

The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation , for example $1, $input,$result etc.

The Java module uses a few additional special variables:

$javaclassname
This special variable works like the other special variables and $javaclassname is similar to $1_type. It expands to the class name for use in Java given a pointer. SWIG wraps unions, structs and classes using pointers and in this case it expands to the Java proxy class name. For example, $javaclassname is replaced by the proxy classname Foo when wrapping a Foo * and $&javaclassname expands to the proxy classname when wrapping the C/C++ type Foo and $*javaclassname expands to the proxy classname when wrapping Foo *&. If the type does not have an associated proxy class, it expands to the type wrapper class name, for example, SWIGTYPE_p_unsigned_short is generated when wrapping unsigned short *.

$javaclazzname
This special variable works like $javaclassname, but expands the fully qualified C++ class into the package name, if used by the nspace feature, and the proxy class name, mangled for use as a function name. For example, Namespace1::Namespace2::Klass is expanded into Namespace1_Namespace2_Klass_. This special variable is usually used for making calls to a function in the intermediary JNI class, as they are mangled with this prefix.

$null
Used in input typemaps to return early from JNI functions that have either void or a non-void return type. Example:

%typemap(check) int * %{ 
  if (error) {
    SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array element error");
    return $null;
  }
%}

If the typemap gets put into a function with void as return, $null will expand to nothing:

SWIGEXPORT void JNICALL Java_jnifn(...) {
    if (error) {
      SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array element error");
      return ;
    }
  ...
}

otherwise $null expands to NULL

SWIGEXPORT jobject JNICALL Java_jnifn(...) {
    if (error) {
      SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array element error");
      return NULL;
    }
  ...
}

$javainput, $jnicall and $owner
The $javainput special variable is used in "javain" typemaps and $jnicall and $owner are used in "javaout" typemaps. $jnicall is analogous to $action in %exception. It is replaced by the call to the native method in the intermediary JNI class. $owner is replaced by either true if %newobject has been used, otherwise false . $javainput is analogous to the $input special variable. It is replaced by the parameter name.

Here is an example:

%typemap(javain) Class "Class.getCPtr($javainput)"
%typemap(javain) unsigned short "$javainput"
%typemap(javaout) Class * {
    return new Class($jnicall, $owner);
  }

%inline %{
    class Class {...};
    Class * bar(Class cls, unsigned short ush) { return new Class(); };
%}

The generated proxy code is then:

public static Class bar(Class cls, int ush) {
  return new Class(exampleJNI.bar(Class.getCPtr(cls), cls, ush), false);
}

Here $javainput has been replaced by cls and ush. $jnicall has been replaced by the native method call, exampleJNI.bar(...) and $owner has been replaced by false. If %newobject is used by adding the following at the beginning of our example:

%newobject bar(Class cls, unsigned short ush);

The generated code constructs the return type using true indicating the proxy class Class is responsible for destroying the C++ memory allocated for it in bar:

public static Class bar(Class cls, int ush) {
  return new Class(exampleJNI.bar(Class.getCPtr(cls), cls, ush), true);
}

$static
This special variable expands to either static or nothing depending on whether the class is an inner Java class or not. It is used in the "javaclassmodifiers" typemap so that global classes can be wrapped as Java proxy classes and nested C++ classes/enums can be wrapped with the Java equivalent, that is, static inner proxy classes.

$error, $jniinput, $javacall and $packagepath
These special variables are used in the directors typemaps. See Director specific typemaps for details.

$module
This special variable expands to the module name, as specified by %module or the -module commandline option.

$imclassname
This special variable expands to the intermediary class name. Usually this is the same as '$moduleJNI', unless the jniclassname attribute is specified in the %module directive.

25.9.8 Typemaps for both C and C++ compilation

JNI calls must be written differently depending on whether the code is being compiled as C or C++. For example C compilation requires the pointer to a function pointer struct member syntax like

const jclass clazz = (*jenv)->FindClass(jenv, "java/lang/String");

whereas C++ code compilation of the same function call is a member function call using a class pointer like

const jclass clazz = jenv->FindClass("java/lang/String");

To enable typemaps to be used for either C or C++ compilation, a set of JCALLx macros have been defined in Lib/java/javahead.swg, where x is the number of arguments in the C++ version of the JNI call. The above JNI calls would be written in a typemap like this

const jclass clazz = JCALL1(FindClass, jenv, "java/lang/String");

Note that the SWIG preprocessor expands these into the appropriate C or C++ JNI calling convention. The C calling convention is emitted by default and the C++ calling convention is emitted when using the -c++ SWIG commandline option. If you do not intend your code to be targeting both C and C++ then your typemaps can use the appropriate JNI calling convention and need not use the JCALLx macros.

25.9.9 Java code typemaps

Most of SWIG's typemaps are used for the generation of C/C++ code. The typemaps in this section are used solely for the generation of Java code. Elements of proxy classes and type wrapper classes come from the following typemaps (the defaults).

%typemap(javabase)

base (extends) for Java class: empty default
Note that this typemap accepts a replace attribute as an optional flag. When set to "1", it will replace/override any C++ base classes that might have been parsed. If this flag is not specified and there are C++ base classes, then a multiple inheritance warning is issued and the code in the typemap is ignored. The typemap also accepts a notderived attribute as an optional flag. When set to "1", it will not apply to classes that are derived from a C++ base. When used with the SWIGTYPE type, it is useful for giving a common base for all proxy classes, that is, providing a base class that sits in between all proxy classes and the Java base class Object for example: %typemap(javabase, notderived="1") SWIGTYPE "CommonBase".

%typemap(javabody)

the essential support body for proxy classes (proxy base classes only), typewrapper classes and enum classes. Default contains extra constructors, memory ownership control member variables (swigCMemOwn, swigCPtr), the getCPtr method etc.

%typemap(javabody_derived)

the essential support body for proxy classes (derived classes only). Same as "javabody" typemap, but only used for proxy derived classes.

%typemap(javaclassmodifiers)

class modifiers for the Java class: default is "public class"

%typemap(javacode)

Java code is copied verbatim to the Java class: empty default

%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized")

destructor wrapper - the delete() method (proxy classes only), used for all proxy classes except those which have a base class : default calls C++ destructor (or frees C memory) and resets swigCPtr and swigCMemOwn flags

Note that the delete() method name is configurable and is specified by the methodname attribute. The method modifiers are also configurable via the methodmodifiers attribute.

%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized")

destructor wrapper - the delete() method (proxy classes only), same as "javadestruct" but only used for derived proxy classes : default calls C++ destructor (or frees C memory) and resets swigCPtr and swigCMemOwn flags

Note that the delete() method name is configurable and is specified by the methodname attribute. The method modifiers are also configurable via the methodmodifiers attribute.

%typemap(javaimports)

import statements for Java class: empty default

%typemap(javainterfaces)

interfaces (implements) for Java class: empty default

%typemap(javafinalize)

the finalize() method (proxy classes only): default calls the delete() method

Note that the default javafinalize typemap must contain the full implementation of the finalize method. Any customization to this typemap must still declare a java finalize method with the correct signature. Note also that the name of the generated "delete" method may be affected by javadestruct and javadestruct_derived typemaps. Below shows an example modifying the finalizer, assuming the delete method has been renamed to swig_delete.

%typemap(javafinalize) SWIGTYPE %{
   protected void finalize() {
     swig_delete();  // renamed to prevent conflict with existing delete method
   }
]%

Compatibility Note: In SWIG-1.3.21 and earlier releases, typemaps called "javagetcptr" and "javaptrconstructormodifiers" were available. These are deprecated and the "javabody" typemap can be used instead.

In summary the contents of the typemaps make up a proxy class like this:

[ javaimports typemap ]
[ javaclassmodifiers typemap ] javaclassname extends [ javabase typemap ]
                                             implements [ javainterfaces typemap ] {
[ javabody or javabody_derived typemap ]
[ javafinalize typemap ]
public synchronized void delete() [ javadestruct OR javadestruct_derived typemap ]
[ javacode typemap ]
... proxy functions ...
}

Note the delete() methodname and method modifiers are configurable, see "javadestruct" and "javadestruct_derived" typemaps above.

The type wrapper class is similar in construction:

[ javaimports typemap ]
[ javaclassmodifiers typemap ] javaclassname extends [ javabase typemap ]
                                             implements [ javainterfaces typemap ] {
[ javabody typemap ]
[ javacode typemap ]
}

The enum class is also similar in construction:

[ javaimports typemap ]
[ javaclassmodifiers typemap ] javaclassname extends [ javabase typemap ]
                                             implements [ javainterfaces typemap ] {
... Enum values ...
[ javabody typemap ]
[ javacode typemap ]
}

The "javaimports" typemap is ignored if the enum class is wrapped by an inner Java class, that is when wrapping an enum declared within a C++ class.

The defaults can be overridden to tailor these classes. Here is an example which will change the getCPtr method and constructor from the default public access to protected access. If the classes in one package are not using the classes in another package, then these methods need not be public and removing access to these low level implementation details, is a good thing. If you are invoking SWIG more than once and generating the wrapped classes into different packages in each invocation, then you cannot do this as you will then have different packages.

%typemap(javabody) SWIGTYPE %{
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr($javaclassname obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }
%}

The typemap code is the same that is in "java.swg", barring the last two method modifiers. Note that SWIGTYPE will target all proxy classes, but not the type wrapper classes. Also the above typemap is only used for proxy classes that are potential base classes. To target proxy classes that are derived from a wrapped class as well, the "javabody_derived" typemap should also be overridden.

For the typemap to be used in all type wrapper classes, all the different types that type wrapper classes could be used for should be targeted:

%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  private long swigCPtr;

  protected $javaclassname(long cPtr, boolean bFutureUse) {
    swigCPtr = cPtr;
  }

  protected $javaclassname() {
    swigCPtr = 0;
  }

  protected static long getCPtr($javaclassname obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }
%}

Again this is the same that is in "java.swg", barring the method modifier for getCPtr.

When using multiple modules or the nspace feature it is common to invoke SWIG with a different -package command line option for each module. However, by default the generated code may not compile if generated classes in one package use generated classes in another package. The visibility of the getCPtr() and pointer constructor generated from the javabody typemaps needs changing. The default visibility is protected but it needs to be public for access from a different package. Just changing 'protected' to 'public' in the typemap achieves this. Two macros are available in java.swg to make this easier and using them is the preferred approach over simply copying the typemaps and modifying as this is forward compatible with any changes in the javabody typemap in future versions of SWIG. The macros are for the proxy and typewrapper classes and can respectively be used to to make the method and constructor public:

  SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
  SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)

25.9.10 Director specific typemaps

The Java directors feature requires the "javadirectorin", "javadirectorout", "directorin" and the "directorout" typemaps in order to work properly. The "javapackage" typemap is an optional typemap used to identify the Java package path for individual SWIG generated proxy classes used in director methods.

%typemap(directorin)

The "directorin" typemap is used for converting arguments in the C++ director class to the appropriate JNI type before the upcall to Java. This typemap also specifies the JNI field descriptor for the type in the "descriptor" attribute. For example, integers are converted as follows:

%typemap(directorin,descriptor="I") int "$input = (jint) $1;"

$input is the SWIG name of the JNI temporary variable passed to Java in the upcall. The descriptor="I" will put an I into the JNI field descriptor that identifies the Java method that will be called from C++. For more about JNI field descriptors and their importance, refer to the JNI documentation mentioned earlier. A typemap for C character strings is:

%typemap(directorin,descriptor="Ljava/lang/String;") char *
  %{ $input = jenv->NewStringUTF($1); %}

User-defined types have the default "descriptor" attribute " L$packagepath/$javaclassname;" where $packagepath is the package name passed from the SWIG command line and $javaclassname is the Java proxy class' name. If the -package commandline option is not used to specify the package, then '$packagepath/' will be removed from the resulting output JNI field descriptor. Do not forget the terminating ';' for JNI field descriptors starting with 'L'. If the ';' is left out, Java will generate a "method not found" runtime error. Note that the $packagepath substitution always uses the path separator '/' when expanded. The $javaclassname expansion can be confusing as it is normally expanded using the '.' separator. However, $javaclassname is expanded using the path separator '/' in typemap's "descriptor" attribute as well as in the "directorthrows" typemap.

%typemap(directorout)

The "directorout" typemap is used for converting the JNI return type in the C++ director class to the appropriate C++ type after the upcall to Java. For example, integers are converted as follows:

%typemap(directorout) int %{ $result = (int)$input; %}

$input is the SWIG name of the JNI temporary variable returned from Java after the upcall. $result is the resulting output. A typemap for C character strings is:

%typemap(directorout) char * {
  $1 = 0;
  if ($input) {
    $result = (char *)jenv->GetStringUTFChars($input, 0);
    if (!$1) return $null;
  }
}

%typemap(javadirectorin)

Conversion from jtype to jstype for director methods. These are Java code typemaps which transform the type used in the Java intermediary JNI class (as specified in the "jtype" typemap) to the Java type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap). This typemap provides the conversion for the parameters in the director methods when calling up from C++ to Java.

For primitive types, this typemap is usually specified as:

%typemap(javadirectorin) int "$jniinput"

The $jniinput special variable is analogous to $javainput special variable. It is replaced by the input parameter name.

%typemap(javadirectorout)

Conversion from jstype to jtype for director methods. These are Java code typemaps which transform the type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap) to the type used in the Java intermediary JNI class (as specified in the "jtype" typemap). This typemap provides the conversion for the return type in the director methods when returning from the C++ to Java upcall.

For primitive types, this typemap is usually specified as:

%typemap(javadirectorout) int "$javacall"

The $javacall special variable is analogous to the $jnicall special variable. It is replaced by the call to the target Java method. The target method is the method in the Java proxy class which overrides the virtual C++ method in the C++ base class.

%typemap(directorthrows)

Conversion of Java exceptions to C++ exceptions in director method's exception handling. This typemap is expected to test the $error special variable for a matching Java exception and if successful convert and throw it into a C++ exception given by the typemap's type. The $error special variable is of type jthrowable and is substituted with a unique variable name in the generated code.

The example below converts a Java java.lang.IndexOutOfBoundsException exception to the typemap's type, that is std::out_of_range:

%typemap(directorthrows) std::out_of_range %{
  if (Swig::ExceptionMatches(jenv, $error, "java/lang/IndexOutOfBoundsException")) {
    throw std::out_of_range(Swig::JavaExceptionMessage(jenv, $error).message());
  }
%}

The utility function Swig::ExceptionMatches and class Swig::JavaExceptionMessage are helpers available when using directors and are described in the Java Exceptions from Directors section.

%typemap(javapackage)

The "javapackage" typemap is optional; it serves to identify a class's Java package. This typemap should be used in conjunction with classes that are defined outside of the current SWIG interface file. The typemap is only used if the type is used in a director method, that is, in a virtual method in a director class. For example:

// class Foo is handled in a different interface file:
%import "Foo.i"

%feature("director") Example;

%inline {
  class Bar { };

  class Example {
  public:
    virtual ~Example();
    virtual void ping(Foo *arg1, Bar *arg2);
  };
}

Assume that the Foo class is part of the Java package com.wombat.foo but the above interface file is part of the Java package com.wombat.example. Without the "javapackage" typemap, SWIG will assume that the Foo class belongs to com.wombat.example class. The corrected interface file looks like:

// class Foo is handled in a different interface file:
%import "Foo.i"
%typemap("javapackage") Foo, Foo *, Foo & "com.wombat.foo";
%feature("director") Example;

%inline {
  class Bar { };

  class Example {
  public:
    virtual ~Example();
    virtual void ping(Foo *arg1, Bar *arg2);
  };
}

SWIG looks up the package based on the actual type (plain Foo, Foo pointer and Foo reference), so it is important to associate all three types with the desired package. Practically speaking, you should create a separate SWIG interface file, which is %import-ed into each SWIG interface file, when you have multiple Java packages. Note the helper macros below, OTHER_PACKAGE_SPEC and ANOTHER_PACKAGE_SPEC, which reduce the amount of extra typing. " TYPE..." is useful when passing templated types to the macro, since multiargument template types appear to the SWIG preprocessor as multiple macro arguments.

%typemap("javapackage") SWIGTYPE, SWIGTYPE *, SWIGTYPE &
                                            "package.for.most.classes";

%define OTHER_PACKAGE_SPEC(TYPE...)
%typemap("javapackage") TYPE, TYPE *, TYPE & "package.for.other.classes";
%enddef

%define ANOTHER_PACKAGE_SPEC(TYPE...)
%typemap("javapackage") TYPE, TYPE *, TYPE & "package.for.another.set";
%enddef

OTHER_PACKAGE_SPEC(Package_2_class_one)
ANOTHER_PACKAGE_SPEC(Package_3_class_two)
/* etc */

The basic strategy here is to provide a default package typemap for the majority of the classes, only providing "javapackage" typemaps for the exceptions.

25.10 Typemap Examples

This section includes a few examples of typemaps. For more examples, you might look at the files "java.swg" and "typemaps.i " in the SWIG library.

25.10.1 Simpler Java enums for enums without initializers

The default Proper Java enums approach to wrapping enums is somewhat verbose. This is to handle all possible C/C++ enums, in particular enums with initializers. The generated code can be simplified if the enum being wrapped does not have any initializers.

The following shows how to remove the support methods that are generated by default and instead use the methods in the Java enum base class java.lang.Enum and java.lang.Class for marshalling enums between C/C++ and Java. The type used for the typemaps below is enum SWIGTYPE which is the default type used for all enums. The "enums.swg" file should be examined in order to see the original overridden versions of the typemaps.

%include "enums.swg"

%typemap(javain) enum SWIGTYPE "$javainput.ordinal()"
%typemap(javaout) enum SWIGTYPE {
    return $javaclassname.class.getEnumConstants()[$jnicall];
  }
%typemap(javabody) enum SWIGTYPE ""

%inline %{
  enum HairType { blonde, ginger, brunette };
  void setHair(HairType h);
  HairType getHair();
%}

SWIG will generate the following Java enum, which is somewhat simpler than the default:

public enum HairType {
  blonde,
  ginger,
  brunette;
}

and the two Java proxy methods will be:

public static void setHair(HairType h) {
  exampleJNI.setHair(h.ordinal());
}

public static HairType getHair() {
  return HairType.class.getEnumConstants()[exampleJNI.getHair()];
}

For marshalling Java enums to C/C++ enums, the ordinal method is used to convert the Java enum into an integer value for passing to the JNI layer, see the "javain" typemap. For marshalling C/C++ enums to Java enums, the C/C++ enum value is cast to an integer in the C/C++ typemaps (not shown). This integer value is then used to index into the array of enum constants that the Java language provides. See the getEnumConstants method in the "javaout" typemap.

These typemaps can often be used as the default for wrapping enums as in many cases there won't be any enum initializers. In fact a good strategy is to always use these typemaps and to specifically handle enums with initializers using %apply. This would be done by using the original versions of these typemaps in "enums.swg" under another typemap name for applying using %apply.

25.10.2 Handling C++ exception specifications as Java exceptions

This example demonstrates various ways in which C++ exceptions can be tailored and converted into Java exceptions. Let's consider a simple file class SimpleFile and an exception class FileException which it may throw on error:

%include "std_string.i" // for std::string typemaps
#include <string>

class FileException {
  std::string message;
public:
  FileException(const std::string& msg) : message(msg) {}
  std::string what() {
    return message;
  }
};

class SimpleFile {
  std::string filename;
public:
  SimpleFile(const std::string& filename) : filename(filename) {}
  void open() throw(FileException) {
  ...
  }
};

As the open method has a C++ exception specification, SWIG will parse this and know that the method can throw an exception. The "throws" typemap is then used when SWIG encounters an exception specification. The default generic "throws" typemap looks like this:

%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] %{
  SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException,
                          "C++ $1_type exception thrown");
  return $null;
%}

Basically SWIG will generate a C++ try catch block and the body of the "throws" typemap constitutes the catch block. The above typemap calls a SWIG supplied method which throws a java.lang.RuntimeException. This exception class is a runtime exception and therefore not a checked exception. If, however, we wanted to throw a checked exception, say java.io.IOException, then we could use the following typemap:

%typemap(throws, throws="java.io.IOException") FileException {
  jclass excep = jenv->FindClass("java/io/IOException");
  if (excep)
    jenv->ThrowNew(excep, $1.what().c_str());
  return $null;
}

Note that this typemap uses the 'throws' typemap attribute to ensure a throws clause is generated. The generated proxy method then specifies the checked exception by containing java.io.IOException in the throws clause:

public class SimpleFile {
  ...
  public void open() throws java.io.IOException { ... }
}

Lastly, if you don't want to map your C++ exception into one of the standard Java exceptions, the C++ class can be wrapped and turned into a custom Java exception class. If we go back to our example, the first thing we must do is get SWIG to wrap FileException and ensure that it derives from java.lang.Exception. Additionally, we might want to override the java.lang.Exception.getMessage() method. The typemaps to use then are as follows:

%typemap(javabase) FileException "java.lang.Exception";
%typemap(javacode) FileException %{
  public String getMessage() {
    return what();
  }
%}

This generates:

public class FileException extends java.lang.Exception {
  ...
  public String getMessage() {
    return what();
  }

  public FileException(String msg) { ... }

  public String what() {
    return exampleJNI.FileException_what(swigCPtr, this);
  }
}

We could alternatively have used %rename to rename what() into getMessage().

25.10.3 NaN Exception - exception handling for a particular type

A Java exception can be thrown from any Java or JNI code. Therefore, as most typemaps contain either Java or JNI code, just about any typemap could throw an exception. The following example demonstrates exception handling on a type by type basis by checking for 'Not a number' (NaN) whenever a parameter of type float is wrapped.

Consider the following C++ code:

bool calculate(float first, float second);

To validate every float being passed to C++, we could precede the code being wrapped by the following typemap which throws a runtime exception whenever the float is 'Not a Number':

%module example
%typemap(javain) float "$module.CheckForNaN($javainput)"
%pragma(java) modulecode=%{
  /** Simply returns the input value unless it is not a number,
      whereupon an exception is thrown. */
  static protected float CheckForNaN(float num) {
    if (Float.isNaN(num))
      throw new RuntimeException("Not a number");
    return num;
  }
%}

Note that the CheckForNaN support method has been added to the module class using the modulecode pragma. The following shows the generated code of interest:

public class example {
  ...

  /** Simply returns the input value unless it is not a number,
      whereupon an exception is thrown. */
  static protected float CheckForNaN(float num) {
    if (Float.isNaN(num))
      throw new RuntimeException("Not a number");
    return num;
  }

  public static boolean calculate(float first, float second) {
    return exampleJNI.calculate(example.CheckForNaN(first), example.CheckForNaN(second));
  }
}

Note that the "javain" typemap is used for every occurrence of a float being used as an input. Of course, we could have targeted the typemap at a particular parameter by using float first, say, instead of just float.

The exception checking could alternatively have been placed into the 'pre' attribute that the "javain" typemap supports. The "javain" typemap above could be replaced with the following:

%typemap(javain, pre="    $module.CheckForNaN($javainput);") float "$javainput"

which would modify the calculate function to instead be generated as:

public class example {
  ...
  public static boolean calculate(float first, float second) {
    example.CheckForNaN(first);
    example.CheckForNaN(second);
    {
      return exampleJNI.calculate(first, second);
    }
  }
}

See the Date marshalling example for an example using further "javain" typemap attributes.

If we decide that what we actually want is a checked exception instead of a runtime exception, we can change this easily enough. The proxy method that uses float as an input, must then add the exception class to the throws clause. SWIG can handle this as it supports the 'throws' typemap attribute for specifying classes for the throws clause. Thus we can modify the pragma and the typemap for the throws clause:

%typemap(javain, throws="java.lang.Exception") float "$module.CheckForNaN($javainput)"
%pragma(java) modulecode=%{
  /** Simply returns the input value unless it is not a number,
      whereupon an exception is thrown. */
  static protected float CheckForNaN(float num) throws java.lang.Exception {
    if (Float.isNaN(num))
      throw new RuntimeException("Not a number");
    return num;
  }
%}

The calculate method now has a throws clause and even though the typemap is used twice for both float first and float second, the throws clause contains a single instance of java.lang.Exception:

public class example {
  ...

  /** Simply returns the input value unless it is not a number,
      whereupon an exception is thrown. */
  static protected float CheckForNaN(float num) throws java.lang.Exception {
    if (Float.isNaN(num))
      throw new RuntimeException("Not a number");
    return num;
  }

  public static boolean calculate(float first, float second) throws java.lang.Exception {
    return exampleJNI.calculate(example.CheckForNaN(first), example.CheckForNaN(second));
  }
}

If we were a martyr to the JNI cause, we could replace the succinct code within the "javain" typemap with a few pages of JNI code. If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.

25.10.4 Converting Java String arrays to char **

A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Java String array to be used as a char ** object.

%module example

/* This tells SWIG to treat char ** as a special case when used as a parameter
   in a function call */
%typemap(in) char ** (jint size) {
    int i = 0;
    size = (*jenv)->GetArrayLength(jenv, $input);
    $1 = (char **) malloc((size+1)*sizeof(char *));
    /* make a copy of each string */
    for (i = 0; i<size; i++) {
        jstring j_string = (jstring)(*jenv)->GetObjectArrayElement(jenv, $input, i);
        const char * c_string = (*jenv)->GetStringUTFChars(jenv, j_string, 0);
        $1[i] = malloc((strlen(c_string)+1)*sizeof(char));
        strcpy($1[i], c_string);
        (*jenv)->ReleaseStringUTFChars(jenv, j_string, c_string);
        (*jenv)->DeleteLocalRef(jenv, j_string);
    }
    $1[i] = 0;
}

/* This cleans up the memory we malloc'd before the function call */
%typemap(freearg) char ** {
    int i;
    for (i=0; i<size$argnum-1; i++)
      free($1[i]);
    free($1);
}

/* This allows a C function to return a char ** as a Java String array */
%typemap(out) char ** {
    int i;
    int len=0;
    jstring temp_string;
    const jclass clazz = (*jenv)->FindClass(jenv, "java/lang/String");

    while ($1[len]) len++;    
    jresult = (*jenv)->NewObjectArray(jenv, len, clazz, NULL);
    /* exception checking omitted */

    for (i=0; i<len; i++) {
      temp_string = (*jenv)->NewStringUTF(jenv, *result++);
      (*jenv)->SetObjectArrayElement(jenv, jresult, i, temp_string);
      (*jenv)->DeleteLocalRef(jenv, temp_string);
    }
}

/* These 3 typemaps tell SWIG what JNI and Java types to use */
%typemap(jni) char ** "jobjectArray"
%typemap(jtype) char ** "String[]"
%typemap(jstype) char ** "String[]"

/* These 2 typemaps handle the conversion of the jtype to jstype typemap type
   and vice versa */
%typemap(javain) char ** "$javainput"
%typemap(javaout) char ** {
    return $jnicall;
  }

/* Now a few test functions */
%inline %{

int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
         printf("argv[%d] = %s\n", i, argv[i]);
         i++;
    }
    return i;
}

char **get_args() {
  static char *values[] = { "Dave", "Mike", "Susan", "John", "Michelle", 0};
  return &values[0];
}

%}

Note that the 'C' JNI calling convention is used. Checking for any thrown exceptions after JNI function calls has been omitted. When this module is compiled, our wrapped C functions can be used by the following Java program:

// File runme.java

public class runme {

  static {
    try {
      System.loadLibrary("example");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load. " + e);
      System.exit(1);
    }
  }

  public static void main(String argv[]) {
    String animals[] = {"Cat","Dog","Cow","Goat"};
    example.print_args(animals);
    String args[] = example.get_args();
    for (int i=0; i<args.length; i++)
        System.out.println(i + ":" + args[i]);
  }
}

When compiled and run we get:

$ java runme
argv[0] = Cat
argv[1] = Dog
argv[2] = Cow
argv[3] = Goat
0:Dave
1:Mike
2:Susan
3:John
4:Michelle

In the example, a few different typemaps are used. The "in" typemap is used to receive an input argument and convert it to a C array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function. The "out" typemap is used for function return values. Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

25.10.5 Expanding a Java object to multiple arguments

Suppose that you had a collection of C functions with arguments such as the following:

int foo(int argc, char **argv);

In the previous example, a typemap was written to pass a Java String array as the char **argv. This allows the function to be used from Java as follows:

example.foo(4, new String[]{"red", "green", "blue", "white"});

Although this works, it's a little awkward to specify the argument count. To fix this, a multi-argument typemap can be defined. This is not very difficult--you only have to make slight modifications to the previous example's typemaps:

%typemap(in) (int argc, char **argv) {
    int i = 0;
    $1 = (*jenv)->GetArrayLength(jenv, $input);
    $2 = (char **) malloc(($1+1)*sizeof(char *));
    /* make a copy of each string */
    for (i = 0; i<$1; i++) {
        jstring j_string = (jstring)(*jenv)->GetObjectArrayElement(jenv, $input, i);
        const char * c_string = (*jenv)->GetStringUTFChars(jenv, j_string, 0);
        $2[i] = malloc((strlen(c_string)+1)*sizeof(char));
        strcpy($2[i], c_string);
        (*jenv)->ReleaseStringUTFChars(jenv, j_string, c_string);
        (*jenv)->DeleteLocalRef(jenv, j_string);
    }
    $2[i] = 0;
}

%typemap(freearg) (int argc, char **argv) {
    int i;
    for (i=0; i<$1-1; i++)
      free($2[i]);
    free($2);
}

%typemap(jni) (int argc, char **argv) "jobjectArray"
%typemap(jtype) (int argc, char **argv) "String[]"
%typemap(jstype) (int argc, char **argv) "String[]"

%typemap(javain) (int argc, char **argv) "$javainput"

When writing a multiple-argument typemap, each of the types is referenced by a variable such as $1 or $2. The typemap code simply fills in the appropriate values from the supplied Java parameter.

With the above typemap in place, you will find it no longer necessary to supply the argument count. This is automatically set by the typemap code. For example:

example.foo(new String[]{"red", "green", "blue", "white"});

25.10.6 Using typemaps to return arguments

A common problem in some C programs is that values may be returned in function parameters rather than in the return value of a function. The typemaps.i file defines INPUT, OUTPUT and INOUT typemaps which can be used to solve some instances of this problem. This library file uses an array as a means of moving data to and from Java when wrapping a C function that takes non const pointers or non const references as parameters.

Now we are going to outline an alternative approach to using arrays for C pointers. The INOUT typemap uses a double[] array for receiving and returning the double* parameters. In this approach we are able to use a Java class myDouble instead of double[] arrays where the C pointer double* is required.

Here is our example function:

/* Returns a status value and two values in out1 and out2 */
int spam(double a, double b, double *out1, double *out2);

If we define a structure MyDouble containing a double member variable and use some typemaps we can solve this problem. For example we could put the following through SWIG:

%module example

/* Define a new structure to use instead of double * */
%inline %{
typedef struct {
    double value;
} MyDouble;
%}


%{
/* Returns a status value and two values in out1 and out2 */
int spam(double a, double b, double *out1, double *out2) {
  int status = 1;
  *out1 = a*10.0;
  *out2 = b*100.0;
  return status;
}
%}

/* 
This typemap will make any double * function parameters with name OUTVALUE take an
argument of MyDouble instead of double *. This will 
allow the calling function to read the double * value after returning from the function.
*/
%typemap(in) double *OUTVALUE {
    jclass clazz = jenv->FindClass("MyDouble");
    jfieldID fid = jenv->GetFieldID(clazz, "swigCPtr", "J");
    jlong cPtr = jenv->GetLongField($input, fid);
    MyDouble *pMyDouble = NULL;
    *(MyDouble **)&pMyDouble = *(MyDouble **)&cPtr;
    $1 = &pMyDouble->value;
}

%typemap(jtype) double *OUTVALUE "MyDouble"
%typemap(jstype) double *OUTVALUE "MyDouble"
%typemap(jni) double *OUTVALUE "jobject"

%typemap(javain) double *OUTVALUE "$javainput"

/* Now we apply the typemap to the named variables */
%apply double *OUTVALUE { double *out1, double *out2 };
int spam(double a, double b, double *out1, double *out2);

Note that the C++ JNI calling convention has been used this time and so must be compiled as C++ and the -c++ commandline must be passed to SWIG. JNI error checking has been omitted for clarity.

What the typemaps do are make the named double* function parameters use our new MyDouble wrapper structure. The "in" typemap takes this structure, gets the C++ pointer to it, takes the double value member variable and passes it to the C++ spam function. In Java, when the function returns, we use the SWIG created getValue() function to get the output value. The following Java program demonstrates this:

// File: runme.java

public class runme {

  static {
    try {
      System.loadLibrary("example");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load. " + e);
      System.exit(1);
    }
  }

  public static void main(String argv[]) {
    MyDouble out1 = new MyDouble();
    MyDouble out2 = new MyDouble();
    int ret = example.spam(1.2, 3.4, out1, out2);
    System.out.println(ret + "  " + out1.getValue() + "  " + out2.getValue());
  }
}

When compiled and run we get:

$ java runme
1 12.0  340.0

25.10.7 Adding Java downcasts to polymorphic return types

SWIG support for polymorphism works in that the appropriate virtual function is called. However, the default generated code does not allow for downcasting. Let's examine this with the following code:

%include "std_string.i"

#include <iostream>
using namespace std;
class Vehicle {
public:
    virtual void start() = 0;
...
};

class Ambulance : public Vehicle {
    string vol;
public:
    Ambulance(string volume) : vol(volume) {}
    virtual void start() {
        cout << "Ambulance started" << endl;
    }
    void sound_siren() {
        cout << vol << " siren sounded!" << endl;
    }
...
};

Vehicle *vehicle_factory() {
    return new Ambulance("Very loud");
}

If we execute the following Java code:

Vehicle vehicle = example.vehicle_factory();
vehicle.start();

Ambulance ambulance = (Ambulance)vehicle;
ambulance.sound_siren();

We get:

Ambulance started
java.lang.ClassCastException
        at runme.main(runme.java:16)

Even though we know from examination of the C++ code that vehicle_factory returns an object of type Ambulance, we are not able to use this knowledge to perform the downcast in Java. This occurs because the runtime type information is not completely passed from C++ to Java when returning the type from vehicle_factory(). Usually this is not a problem as virtual functions do work by default, such as in the case of start(). There are a few solutions to getting downcasts to work.

The first is not to use a Java cast but a call to C++ to make the cast. Add this to your code:

%exception Ambulance::dynamic_cast(Vehicle *vehicle) {
    $action
    if (!result) {
        jclass excep = jenv->FindClass("java/lang/ClassCastException");
        if (excep) {
            jenv->ThrowNew(excep, "dynamic_cast exception");
        }
    }
}
%extend Ambulance {
    static Ambulance *dynamic_cast(Vehicle *vehicle) {
        return dynamic_cast<Ambulance *>(vehicle);
    }
};

It would then be used from Java like this

Ambulance ambulance = Ambulance.dynamic_cast(vehicle);
ambulance.sound_siren();

Should vehicle not be of type ambulance then a Java ClassCastException is thrown. The next solution is a purer solution in that Java downcasts can be performed on the types. Add the following before the definition of vehicle_factory:

%typemap(out) Vehicle * {
    Ambulance *downcast = dynamic_cast<Ambulance *>($1);
    *(Ambulance **)&$result = downcast;
}

%typemap(javaout) Vehicle * {
    return new Ambulance($jnicall, $owner);
  }

Here we are using our knowledge that vehicle_factory always returns type Ambulance so that the Java proxy is created as a type Ambulance. If vehicle_factory can manufacture any type of Vehicle and we want to be able to downcast using Java casts for any of these types, then a different approach is needed. Consider expanding our example with a new Vehicle type and a more flexible factory function:

class FireEngine : public Vehicle {
public:
    FireEngine() {}
    virtual void start() {
        cout << "FireEngine started" << endl;
    }
    void roll_out_hose() {
        cout << "Hose rolled out" << endl;
    }
 ...
};
Vehicle *vehicle_factory(int vehicle_number) {
    if (vehicle_number == 0)
        return new Ambulance("Very loud");
    else
        return new FireEngine();
}

To be able to downcast with this sort of Java code:

FireEngine fireengine = (FireEngine)example.vehicle_factory(1);
fireengine.roll_out_hose();
Ambulance ambulance = (Ambulance)example.vehicle_factory(0);
ambulance.sound_siren();

the following typemaps targeted at the vehicle_factory function will achieve this. Note that in this case, the Java class is constructed using JNI code rather than passing a pointer across the JNI boundary in a Java long for construction in Java code.

%typemap(jni) Vehicle *vehicle_factory "jobject"
%typemap(jtype) Vehicle *vehicle_factory "Vehicle"
%typemap(jstype) Vehicle *vehicle_factory "Vehicle"
%typemap(javaout) Vehicle *vehicle_factory {
    return $jnicall;
  }

%typemap(out) Vehicle *vehicle_factory {
    Ambulance *ambulance = dynamic_cast<Ambulance *>($1);
    FireEngine *fireengine = dynamic_cast<FireEngine *>($1);
    if (ambulance) {
        // call the Ambulance(long cPtr, boolean cMemoryOwn) constructor
        jclass clazz = jenv->FindClass("Ambulance");
        if (clazz) {
            jmethodID mid = jenv->GetMethodID(clazz, "<init>", "(JZ)V");
            if (mid) {
                jlong cptr = 0;
                *(Ambulance **)&cptr = ambulance; 
                $result = jenv->NewObject(clazz, mid, cptr, false);
            }
        }
    } else if (fireengine) {
        // call the FireEngine(long cPtr, boolean cMemoryOwn) constructor
        jclass clazz = jenv->FindClass("FireEngine");
        if (clazz) {
            jmethodID mid = jenv->GetMethodID(clazz, "<init>", "(JZ)V");
            if (mid) {
                jlong cptr = 0;
                *(FireEngine **)&cptr = fireengine; 
                $result = jenv->NewObject(clazz, mid, cptr, false);
            }
        }
    }
    else {
        cout << "Unexpected type " << endl;
    }

    if (!$result)
        cout << "Failed to create new java object" << endl;
}

Better error handling would need to be added into this code. There are other solutions to this problem, but this last example demonstrates some more involved JNI code. SWIG usually generates code which constructs the proxy classes using Java code as it is easier to handle error conditions and is faster. Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.

25.10.8 Adding an equals method to the Java classes

When a pointer is returned from a JNI function, it is wrapped using a new Java proxy class or type wrapper class. Even when the pointers are the same, it will not be possible to know that the two Java classes containing those pointers are actually the same object. It is common in Java to use the equals() method to check whether two objects are equivalent. The equals() method is usually accompanied by a hashCode() method in order to fulfill the requirement that the hash code is equal for equal objects. Pure Java code methods like these can be easily added:

%typemap(javacode) SWIGTYPE %{
  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof $javaclassname)
      equal = ((($javaclassname)obj).swigCPtr == this.swigCPtr);
    return equal;
  }
  public int hashCode() {
     return (int)getPointer();
  }
%}

class Foo { };
Foo* returnFoo(Foo *foo) { return foo; }

The following would display false without the javacode typemap above. With the typemap defining the equals method the result is true.

Foo foo1 = new Foo();
Foo foo2 = example.returnFoo(foo1);
System.out.println("foo1? " + foo1.equals(foo2));

25.10.9 Void pointers and a common Java base class

One might wonder why the common code that SWIG emits for the proxy and type wrapper classes is not pushed into a base class. The reason is that although swigCPtr could be put into a common base class for all classes wrapping C structures, it would not work for C++ classes involved in an inheritance chain. Each class derived from a base needs a separate swigCPtr because C++ compilers sometimes use a different pointer value when casting a derived class to a base. Additionally as Java only supports single inheritance, it would not be possible to derive wrapped classes from your own pure Java classes if the base class has been 'used up' by SWIG. However, you may want to move some of the common code into a base class. Here is an example which uses a common base class for all proxy classes and type wrapper classes:

%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], 
                                                         SWIGTYPE (CLASS::*) "SWIG"

%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], 
                                                         SWIGTYPE (CLASS::*) %{
  protected long getPointer() {
    return swigCPtr;
  }
%}

Define new base class called SWIG:

public abstract class SWIG {
  protected abstract long getPointer();

  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof SWIG)
      equal = (((SWIG)obj).getPointer() == this.getPointer());
    return equal;
  }
  
  SWIGTYPE_p_void getVoidPointer() {
    return new SWIGTYPE_p_void(getPointer(), false);
  }
}

This example contains some useful functionality which you may want in your code.

  • It has an equals() method. Unlike the previous example, the method code isn't replicated in all classes.
  • It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer.

25.10.10 Struct pointer to pointer

Pointers to pointers are often used as output parameters in C factory type functions. These are a bit more tricky to handle. Consider the following situation where a Butler can be hired and fired:

typedef struct {
  int hoursAvailable;
  char *greeting;
} Butler;

// Note: HireButler will allocate the memory 
// The caller must free the memory by calling FireButler()!!
extern int HireButler(Butler **ppButler);
extern void FireButler(Butler *pButler);

C code implementation:

int HireButler(Butler **ppButler) {
  Butler *pButler = (Butler *)malloc(sizeof(Butler));
  pButler->hoursAvailable = 24;
  pButler->greeting = (char *)malloc(32);
  strcpy(pButler->greeting, "At your service Sir");
  *ppButler = pButler;
  return 1;
}
void FireButler(Butler *pButler) {
  free(pButler->greeting);
  free(pButler);
}

Let's take two approaches to wrapping this code. The first is to provide a functional interface, much like the original C interface. The following Java code shows how we intend the code to be used:

    Butler jeeves = new Butler();
    example.HireButler(jeeves);
    System.out.println("Greeting:     " + jeeves.getGreeting());
    System.out.println("Availability: " + jeeves.getHoursAvailable() + " hours per day");
    example.FireButler(jeeves);

Resulting in the following output when run:

Greeting:     At your service Sir
Availability: 24 hours per day

Note the usage is very much like it would be used if we were writing C code, that is, explicit memory management is needed. No C memory is allocated in the construction of the Butler proxy class and the proxy class will not destroy the underlying C memory when it is collected. A number of typemaps and features are needed to implement this approach. The following interface file code should be placed before SWIG parses the above C code.

%module example

// Do not generate the default proxy constructor or destructor
%nodefaultctor Butler;
%nodefaultdtor Butler;

// Add in pure Java code proxy constructor
%typemap(javacode) Butler %{
  /** This constructor creates the proxy which initially does not create nor own any C memory */
  public Butler() {
    this(0, false);
  }
%}

// Type typemaps for marshalling Butler **
%typemap(jni) Butler ** "jobject"
%typemap(jtype) Butler ** "Butler"
%typemap(jstype) Butler ** "Butler"

// Typemaps for Butler ** as a parameter output type
%typemap(in) Butler ** (Butler *ppButler = 0) %{
  $1 = &ppButler;
%}
%typemap(argout) Butler ** {
  // Give Java proxy the C pointer (of newly created object)
  jclass clazz = (*jenv)->FindClass(jenv, "Butler");
  jfieldID fid = (*jenv)->GetFieldID(jenv, clazz, "swigCPtr", "J");
  jlong cPtr = 0;
  *(Butler **)&cPtr = *$1;
  (*jenv)->SetLongField(jenv, $input, fid, cPtr);
}
%typemap(javain) Butler ** "$javainput"

Note that the JNI code sets the proxy's swigCPtr member variable to point to the newly created object. The swigCMemOwn remains unchanged (at false), so that the proxy does not own the memory.

Note: The old %nodefault directive disabled the default constructor and destructor at the same time. This is unsafe in most of the cases, and you can use the explicit %nodefaultctor and %nodefaultdtor directives to achieve the same result if needed.

The second approach offers a more object oriented interface to the Java user. We do this by making the Java proxy class's constructor call the HireButler() method to create the underlying C object. Additionally we get the proxy to take ownership of the memory so that the finalizer will call the FireButler() function. The proxy class will thus take ownership of the memory and clean it up when no longer needed. We will also prevent the user from being able to explicitly call the HireButler() and FireButler() functions. Usage from Java will simply be:

Butler jeeves = new Butler();
System.out.println("Greeting:     " + jeeves.getGreeting());
System.out.println("Availability: " + jeeves.getHoursAvailable() + " hours per day");

Note that the Butler class is used just like any other Java class and no extra coding by the user needs to be written to clear up the underlying C memory as the finalizer will be called by the garbage collector which in turn will call the FireButler() function. To implement this, we use the above interface file code but remove the javacode typemap and add the following:

// Don't expose the memory allocation/de-allocation functions
%ignore FireButler(Butler *pButler);
%ignore HireButler(Butler **ppButler);

// Add in a custom proxy constructor and destructor
%extend Butler {
  Butler() {
    Butler *pButler = 0;
    HireButler(&pButler);
    return pButler;
  }
  ~Butler() {
     FireButler($self);
   }
}

Note that the code in %extend is using a C++ type constructor and destructor, yet the generated code will still compile as C code, see Adding member functions to C structures. The C functional interface has been completely morphed into an object-oriented interface and the Butler class would behave much like any pure Java class and feel more natural to Java users.

25.10.11 Memory management when returning references to member variables

This example shows how to prevent premature garbage collection of objects when the underlying C++ class returns a pointer or reference to a member variable.

Consider the following C++ code:

struct Wheel {
  int size;
  Wheel(int sz) : size(sz) {}
};

class Bike {
  Wheel wheel;
public:
  Bike(int val) : wheel(val) {}
  Wheel& getWheel() { return wheel; }
};

and the following usage from Java after running the code through SWIG:

    Wheel wheel = new Bike(10).getWheel();
    System.out.println("wheel size: " + wheel.getSize());
    // Simulate a garbage collection
    System.gc();
    System.runFinalization();
    System.out.println("wheel size: " + wheel.getSize());

Don't be surprised that if the resulting output gives strange results such as...

wheel size: 10
wheel size: 135019664

What has happened here is the garbage collector has collected the Bike instance as it doesn't think it is needed any more. The proxy instance, wheel, contains a reference to memory that was deleted when the Bike instance was collected. In order to prevent the garbage collector from collecting the Bike instance a reference to the Bike must be added to the wheel instance. You can do this by adding the reference when the getWheel() method is called using the following typemaps.

%typemap(javacode) Wheel %{
  // Ensure that the GC doesn't collect any Bike instance set from Java
  private Bike bikeReference;
  protected void addReference(Bike bike) {
    bikeReference = bike;
  }
%}

// Add a Java reference to prevent premature garbage collection and resulting use
// of dangling C++ pointer. Intended for methods that return pointers or
// references to a member variable.
%typemap(javaout) Wheel& getWheel {
    long cPtr = $jnicall;
    $javaclassname ret = null;
    if (cPtr != 0) {
      ret = new $javaclassname(cPtr, $owner);
      ret.addReference(this);
    }
    return ret;
  }

The code in the first typemap gets added to the Wheel proxy class. The code in the second typemap constitutes the bulk of the code in the generated getWheel() function:

public class Wheel {
  ...
  // Ensure that the GC doesn't collect any bike set from Java 
  private Bike bikeReference;
  protected void addReference(Bike bike) {
    bikeReference = bike;
  }
}

public class Bike {
  ...
  public Wheel getWheel() {
    long cPtr = exampleJNI.Bike_getWheel(swigCPtr, this);
    Wheel ret = null;
    if (cPtr != 0) {
      ret = new Wheel(cPtr, false);
      ret.addReference(this);
    }
    return ret;
  }
}

Note the addReference call.

25.10.12 Memory management for objects passed to the C++ layer

Managing memory can be tricky when using C++ and Java proxy classes. The previous example shows one such case and this example looks at memory management for a class passed to a C++ method which expects the object to remain in scope after the function has returned. Consider the following two C++ classes:

struct Element {
  int value;
  Element(int val) : value(val) {}
};
class Container {
  Element* element;
public:
  Container() : element(0) {}
  void setElement(Element* e) { element = e; }
  Element* getElement() { return element; }
};

and usage from C++

    Container container;
    Element element(20);
    container.setElement(&element);
    cout << "element.value: " << container.getElement()->value << endl;

and more or less equivalent usage from Java

    Container container = new Container();
    container.setElement(new Element(20));
    System.out.println("element value: " + container.getElement().getValue());

The C++ code will always print out 20, but the value printed out may not be this in the Java equivalent code. In order to understand why, consider a garbage collection occuring...

    Container container = new Container();
    container.setElement(new Element(20));
    // Simulate a garbage collection
    System.gc();
    System.runFinalization();
    System.out.println("element value: " + container.getElement().getValue());

The temporary element created with new Element(20) could get garbage collected which ultimately means the container variable is holding a dangling pointer, thereby printing out any old random value instead of the expected value of 20. One solution is to add in the appropriate references in the Java layer...

public class Container {

  ...

  // Ensure that the GC doesn't collect any Element set from Java
  // as the underlying C++ class stores a shallow copy
  private Element elementReference;
  private long getCPtrAndAddReference(Element element) {
    elementReference = element;
    return Element.getCPtr(element);
  }

  public void setElement(Element e) {
    exampleJNI.Container_setElement(swigCPtr, this, getCPtrAndAddReference(e), e);
  }
}

The following typemaps will generate the desired code. The 'javain' typemap matches the input parameter type for the setElement method. The 'javacode' typemap simply adds in the specified code into the Java proxy class.

%typemap(javain) Element *e "getCPtrAndAddReference($javainput)"

%typemap(javacode) Container %{
  // Ensure that the GC doesn't collect any element set from Java
  // as the underlying C++ class stores a shallow copy
  private Element elementReference;
  private long getCPtrAndAddReference(Element element) {
    elementReference = element;
    return Element.getCPtr(element);
  }
%}

25.10.13 Date marshalling using the javain typemap and associated attributes

The NaN Exception example is a simple example of the "javain" typemap and its 'pre' attribute. This example demonstrates how a C++ date class, say CDate, can be mapped onto the standard Java date class, java.util.GregorianCalendar by using the 'pre', 'post' and 'pgcppname' attributes of the "javain" typemap. The idea is that the GregorianCalendar is used wherever the C++ API uses a CDate . Let's assume the code being wrapped is as follows:

class CDate {
public:
  CDate(int year, int month, int day);
  int getYear();
  int getMonth();
  int getDay();
  ...
};
struct Action {
  static int doSomething(const CDate &dateIn, CDate &dateOut);
  Action(const CDate &date, CDate &dateOut);
};

Note that dateIn is const and therefore read only and dateOut is a non-const output type.

First let's look at the code that is generated by default, where the Java proxy class CDate is used in the proxy interface:

public class Action {
  ...
  public static int doSomething(CDate dateIn, CDate dateOut) {
    return exampleJNI.Action_doSomething(CDate.getCPtr(dateIn), dateIn, 
                                         CDate.getCPtr(dateOut), dateOut);
  }

  public Action(CDate date, CDate dateOut) {
    this(exampleJNI.new_Action(CDate.getCPtr(date), date, 
                               CDate.getCPtr(dateOut), dateOut), true);
  }
}

The CDate & and const CDate & Java code is generated from the following two default typemaps:

%typemap(jstype) SWIGTYPE & "$javaclassname"
%typemap(javain) SWIGTYPE & "$javaclassname.getCPtr($javainput)"

where '$javaclassname' is translated into the proxy class name, CDate and '$javainput' is translated into the name of the parameter, eg dateIn. From Java, the intention is then to call into a modifed API with something like:

java.util.GregorianCalendar calendarIn = 
    new java.util.GregorianCalendar(2011, java.util.Calendar.APRIL, 13, 0, 0, 0);
java.util.GregorianCalendar calendarOut = new java.util.GregorianCalendar();

// Note in calls below, calendarIn remains unchanged and calendarOut 
// is set to a new value by the C++ call
Action.doSomething(calendarIn, calendarOut);
Action action = new Action(calendarIn, calendarOut);

To achieve this mapping, we need to alter the default code generation slightly so that at the Java layer, a GregorianCalendar is converted into a CDate. The JNI intermediary layer will still take a pointer to the underlying CDate class. The typemaps to achieve this are shown below.

%typemap(jstype) const CDate& "java.util.GregorianCalendar"
%typemap(javain, 
         pre="    CDate temp$javainput = new CDate($javainput.get(java.util.Calendar.YEAR), "
             "$javainput.get(java.util.Calendar.MONTH), $javainput.get(java.util.Calendar.DATE));", 
         pgcppname="temp$javainput") const CDate &
         "$javaclassname.getCPtr(temp$javainput)"

%typemap(jstype) CDate& "java.util.Calendar"
%typemap(javain, 
         pre="    CDate temp$javainput = new CDate($javainput.get(java.util.Calendar.YEAR), "
             "$javainput.get(java.util.Calendar.MONTH), $javainput.get(java.util.Calendar.DATE));", 
         post="      $javainput.set(temp$javainput.getYear(), temp$javainput.getMonth(), "
              "temp$javainput.getDay(), 0, 0, 0);", 
         pgcppname="temp$javainput") CDate &
         "$javaclassname.getCPtr(temp$javainput)"

The resulting generated proxy code in the Action class follows:

public class Action {
  ...
  public static int doSomething(java.util.GregorianCalendar dateIn, 
                                java.util.Calendar dateOut) {
    CDate tempdateIn = new CDate(dateIn.get(java.util.Calendar.YEAR), 
                                 dateIn.get(java.util.Calendar.MONTH), 
                                 dateIn.get(java.util.Calendar.DATE));
    CDate tempdateOut = new CDate(dateOut.get(java.util.Calendar.YEAR), 
                                  dateOut.get(java.util.Calendar.MONTH), 
                                  dateOut.get(java.util.Calendar.DATE));
    try {
      return exampleJNI.Action_doSomething(CDate.getCPtr(tempdateIn), tempdateIn, 
                                           CDate.getCPtr(tempdateOut), tempdateOut);
    } finally {
      dateOut.set(tempdateOut.getYear(), tempdateOut.getMonth(), tempdateOut.getDay(), 0, 0, 0);
    }
  }

  static private long SwigConstructAction(java.util.GregorianCalendar date, 
                                          java.util.Calendar dateOut) {
    CDate tempdate = new CDate(date.get(java.util.Calendar.YEAR), 
                               date.get(java.util.Calendar.MONTH), 
                               date.get(java.util.Calendar.DATE));
    CDate tempdateOut = new CDate(dateOut.get(java.util.Calendar.YEAR), 
                                  dateOut.get(java.util.Calendar.MONTH), 
                                  dateOut.get(java.util.Calendar.DATE));
    try {
      return exampleJNI.new_Action(CDate.getCPtr(tempdate), tempdate, 
                                   CDate.getCPtr(tempdateOut), tempdateOut);
    } finally {
      dateOut.set(tempdateOut.getYear(), tempdateOut.getMonth(), tempdateOut.getDay(), 0, 0, 0);
    }
  }

  public Action(java.util.GregorianCalendar date, java.util.Calendar dateOut) {
    this(Action.SwigConstructAction(date, dateOut), true);
  }
}

A few things to note:

  • The "javatype" typemap has changed the parameter type to java.util.GregorianCalendar or java.util.Calendar instead of the default generated CDate proxy.
  • The code in the 'pre' attribute appears before the JNI call ( exampleJNI.new_Action / exampleJNI.Action_doSomething).
  • The code in the 'post' attribute appears after the JNI call.
  • A try .. finally block is generated with the JNI call in the try block and 'post' code in the finally block. The alternative of just using a temporary variable for the return value from the JNI call and the 'post' code being generated before the return statement is not possible given that the JNI call is in one line and comes from the "javaout" typemap.
  • The temporary variables in the "javain" typemaps are called temp$javain, where "$javain" is replaced with the parameter name. "$javain" is used to mangle the variable name so that more than one CDate & type can be used as a parameter in a method, otherwise two or more local variables with the same name would be generated.
  • The use of the "javain" typemap causes a constructor helper function (SwigConstructAction) to be generated. This allows Java code to be called before the JNI call and is required as the Java compiler won't compile code inserted before the 'this' call.
  • The 'pgcppname' attribute is used to modify the object being passed as the premature garbage collection prevention parameter (the 2nd and 4th parameters in the JNI calls).

25.11 Living with Java Directors

This section is intended to address frequently asked questions and frequently encountered problems when using Java directors.

  1. When my program starts up, it complains that method_foo cannot be found in a Java method called swig_module_init. How do I fix this?

    Open up the C++ wrapper source code file and look for "method_foo" (include the double quotes, they are important!) Look at the JNI field descriptor and make sure that each class that occurs in the descriptor has the correct package name in front of it. If the package name is incorrect, put a "javapackage" typemap in your SWIG interface file.

  2. I'm compiling my code and I'm using templates. I provided a javapackage typemap, but SWIG doesn't generate the right JNI field descriptor.

    Use the template's renamed name as the argument to the "javapackage" typemap:

    %typemap(javapackage)  std::vector<int>  "your.package.here"
    %template(VectorOfInt) std::vector<int>;
    
  3. When I pass class pointers or references through a C++ upcall and I try to type cast them, Java complains with a ClassCastException. What am I doing wrong?

    Normally, a non-director generated Java proxy class creates temporary Java objects as follows:

    public static void MyClass_method_upcall(MyClass self, long jarg1)
    {
      Foo darg1 = new Foo(jarg1, false);
    
      self.method_upcall(darg1);
    }
    

    Unfortunately, this loses the Java type information that is part of the underlying Foo director proxy class's Java object pointer causing the type cast to fail. The SWIG Java module's director code attempts to correct the problem, but only for director-enabled classes, since the director class retains a global reference to its Java object. Thus, for director-enabled classes and only for director-enabled classes, the generated proxy Java code looks something like:

    public static void MyClass_method_upcall(MyClass self, long jarg1,
                                             Foo jarg1_object)
    {
      Foo darg1 = (jarg1_object != null ? jarg1_object : new Foo(jarg1, false));
    
      self.method_upcall(darg1);
    }
    

    When you import a SWIG interface file containing class definitions, the classes you want to be director-enabled must be have the feature("director") enabled for type symmetry to work. This applies even when the class being wrapped isn't a director-enabled class but takes parameters that are director-enabled classes.

    The current "type symmetry" design will work for simple C++ inheritance, but will most likely fail for anything more complicated such as tree or diamond C++ inheritance hierarchies. Those who are interested in challenging problems are more than welcome to hack the Java::Java_director_declaration method in Source/Modules/java.cxx.

    If all else fails, you can use the downcastXXXXX() method to attempt to recover the director class's Java object pointer. For the Java Foo proxy class, the Foo director class's java object pointer can be accessed through the javaObjectFoo() method. The generated method's signature is:

      public static Foo javaObjectFoo(Foo obj);
    

    From your code, this method is invoked as follows:

    public class MyClassDerived {
      public void method_upcall(Foo foo_object)
      {
        FooDerived    derived = (foo_object != null ?
                     (FooDerived) Foo.downcastFoo(foo_object) : null);
        /* rest of your code here */
      }
    }
    

    An good approach for managing downcasting is placing a static method in each derived class that performs the downcast from the superclass, e.g.,

    public class FooDerived extends Foo {
      /* ... */
      public static FooDerived downcastFooDerived(Foo foo_object)
      {
        try {
         return (foo_object != null ? (FooDerived) Foo.downcastFoo(foo_object);
        }
    
        catch (ClassCastException exc) {
          // Wasn't a FooDerived object, some other subclass of Foo
          return null;
        }
      }
    }
    

    Then change the code in MyClassDerived as follows:

    public class MyClassDerived extends MyClass {
      /* ... */
      public void method_upcall(Foo foo_object)
      {
        FooDerived    derived = FooDerived.downcastFooDerived(foo_object);
        /* rest of your code here */
      }
    }
    
  4. Why isn't the proxy class declared abstract? Why aren't the director upcall methods in the proxy class declared abstract?

    Declaring the proxy class and its methods abstract would break the JNI argument marshalling and SWIG's downcall functionality (going from Java to C++.) Create an abstract Java subclass that inherits from the director-enabled class instead. Using the previous Foo class example:

    public abstract class UserVisibleFoo extends Foo {
      /** Make sure user overrides this method, it's where the upcall
       * happens.
       */
      public abstract void method_upcall(Foo foo_object);
    
      /// Downcast from Foo to UserVisibleFoo
      public static UserVisibleFoo downcastUserVisibleFoo(Foo foo_object)
      {
        try {
         return (foo_object != null ? (FooDerived) Foo.downcastFoo(foo_object) : null);
        }
    
        catch (ClassCastException exc) {
          // Wasn't a FooDerived object, some other subclass of Foo
          return null;
        }
      }
    }
    

    This doesn't prevent the user from creating subclasses derived from Foo, however, UserVisibleFoo provides the safety net that reminds the user to override the method_upcall() method.

25.12 Odds and ends

25.12.1 JavaDoc comments

The SWIG documentation system is currently deprecated. When it is resurrected JavaDoc comments will be fully supported. If you can't wait for the full documentation system a couple of workarounds are available. The %javamethodmodifiers feature can be used for adding proxy class method comments and module class method comments. The "javaimports" typemap can be hijacked for adding in proxy class JavaDoc comments. The jniclassimports or jniclassclassmodifiers pragmas can also be used for adding intermediary JNI class comments and likewise the moduleimports or moduleclassmodifiers pragmas for the module class. Here is an example adding in a proxy class and method comment:

%javamethodmodifiers Barmy::lose_marbles() "
  /**
    * Calling this method will make you mad.
    * Use with <b>utmost</b> caution. 
    */
  public";

%typemap(javaimports) Barmy "
/** The crazy class. Use as a last resort. */"

class Barmy {
public:
  void lose_marbles() {}
};

Note the "public" added at the end of the %javamethodmodifiers as this is the default for this feature. The generated proxy class with JavaDoc comments is then as follows:

/** The crazy class. Use as a last resort. */
public class Barmy {
...
  /**
    * Calling this method will make you mad.
    * Use with <b>utmost</b> caution. 
    */
  public void lose_marbles() {
    ...
  }
...
}

25.12.2 Functional interface without proxy classes

It is possible to run SWIG in a mode that does not produce proxy classes by using the -noproxy commandline option. The interface is rather primitive when wrapping structures or classes and is accessed through function calls to the module class. All the functions in the module class are wrapped by functions with identical names as those in the intermediary JNI class.

Consider the example we looked at when examining proxy classes:

class Foo {
public:
     int x;
     int spam(int num, Foo* foo);
};

When using -noproxy, type wrapper classes are generated instead of proxy classes. Access to all the functions and variables is through a C like set of functions where the first parameter passed is the pointer to the class, that is an instance of a type wrapper class. Here is what the module class looks like:

public class example {
  public static void Foo_x_get(SWIGTYPE_p_Foo self, int x) {...}
  public static int Foo_x_get(SWIGTYPE_p_Foo self) {...}
  public static int Foo_spam(SWIGTYPE_p_Foo self, int num, SWIGTYPE_p_Foo foo) {...}
  public static SWIGTYPE_p_Foo new_Foo() {...}
  public static void delete_Foo(SWIGTYPE_p_Foo self) {...}
}

This approach is not nearly as natural as using proxy classes as the functions need to be used like this:

SWIGTYPE_p_Foo foo = example.new_Foo();
example.Foo_x_set(foo, 10);
int var = example.Foo_x_get(foo);
example.Foo_spam(foo, 20, foo);
example.delete_Foo(foo);

Unlike proxy classes, there is no attempt at tracking memory. All destructors have to be called manually for example the delete_Foo(foo) call above.

25.12.3 Using your own JNI functions

You may have some hand written JNI functions that you want to use in addition to the SWIG generated JNI functions. Adding these to your SWIG generated package is possible using the %native directive. If you don't want SWIG to wrap your JNI function then of course you can simply use the %ignore directive. However, if you want SWIG to generate just the Java code for a JNI function then use the %native directive. The C types for the parameters and return type must be specified in place of the JNI types and the function name must be the native method name. For example:

%native (HandRolled) void HandRolled(int, char *);
%{
JNIEXPORT void JNICALL Java_packageName_moduleName_HandRolled(JNIEnv *, jclass,
                                                              jlong, jstring);
%}

No C JNI function will be generated and the Java_packageName_moduleName_HandRolled function will be accessible using the SWIG generated Java native method call in the intermediary JNI class which will look like this:

  public final static native void HandRolled(int jarg1, String jarg2);

and as usual this function is wrapped by another which for a global C function would appear in the module class:

  public static void HandRolled(int arg0, String arg1) {
    exampleJNI.HandRolled(arg0, arg1);
  }

The packageName and moduleName must of course be correct else you will get linker errors when the JVM dynamically loads the JNI function. You may have to add in some "jtype", "jstype", "javain" and "javaout" typemaps when wrapping some JNI types. Here the default typemaps work for int and char *.

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.

25.12.4 Performance concerns and hints

If you're directly manipulating huge arrays of complex objects from Java, performance may suffer greatly when using the array functions in arrays_java.i. Try and minimise the expensive JNI calls to C/C++ functions, perhaps by using temporary Java variables instead of accessing the information directly from the C/C++ object.

Java classes without any finalizers generally speed up code execution as there is less for the garbage collector to do. Finalizer generation can be stopped by using an empty javafinalize typemap:

%typemap(javafinalize) SWIGTYPE ""

However, you will have to be careful about memory management and make sure that you code in a call to the delete() member function. This method normally calls the C++ destructor or free() for C code.

25.12.5 Debugging

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, where it is possible to step from Java code into a JNI method within one environment.

Alternatively, debugging can involve placing debug printout statements in the JNI layer using the %exception directive. See the special variables for %exception section. Many of the default typemaps can also be overridden and modified for adding in extra logging/debug display information.

The -Xcheck:jni and -Xcheck:nabounds Java executable options are useful for debugging to make sure the JNI code is behaving. The -verbose:jni and -verbose:gc are also useful options for monitoring code behaviour.

25.13 Java Examples

The directory Examples/java has a number of further examples. Take a look at these if you want to see some of the techniques described in action. The Examples/index.html file in the parent directory contains the SWIG Examples Documentation and is a useful starting point. If your SWIG installation went well Unix users should be able to type make in each example directory, then java main to see them running. For the benefit of Windows users, there are also Visual C++ project files in a couple of the Windows Examples . There are also many regression tests in the Examples/test-suite directory. Many of these have runtime tests in the java subdirectory.


26 SWIG and Javascript

This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.

26.1 Overview

Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. Javascript has gone beyond being a browser-based scripting language and with node.js, it is also used as a backend development language.

Native Javascript extensions can be used for applications that embed a web-browser view or that embed a Javascript engine (such as node.js). Extending a general purpose web-browser is not possible as this would be a severe security issue.

SWIG Javascript currently supports JavascriptCore, the Javascript engine used by Safari/Webkit, and v8, which is used by Chromium and node.js.

WebKit is a modern browser implementation available as open-source which can be embedded into an application. With node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

26.2 Preliminaries

26.2.1 Running SWIG

Suppose that you defined a SWIG module such as the following:

%module example
%{
#include "example.h"
%}
int gcd(int x, int y);
extern double Foo;

To build a Javascript module, run SWIG using the -javascript option and a desired target engine -jsc, -v8, or -node. The generator for node is essentially delegating to the v8 generator and adds some necessary preprocessor definitions.

$ swig -javascript -jsc example.i

If building a C++ extension, add the -c++ option:

$ swig -c++ -javascript -jsc example.i

This creates a C/C++ source file example_wrap.c or example_wrap.cxx. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.

The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrapped module will export one function which must be called to register the module with the Javascript interpreter. For example, if your module is named example the corresponding initializer for JavascriptCore would be

bool example_initialize(JSGlobalContextRef context, JSObjectRef *exports)

and for v8:

void example_initialize(v8::Handle<v8::Object> exports)

Note: be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.

26.2.2 Running Tests and Examples

The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.

The default interpreter is node.js as it is available on all platforms and convenient to use.

Running the examples with JavascriptCore requires libjavascriptcoregtk-1.0 to be installed, e.g., under Ubuntu with

$ sudo apt-get install libjavascriptcoregtk-1.0-dev

Running with V8 requires libv8:

$ sudo apt-get install libv8-dev

Examples can be run using

$ make check-javascript-examples ENGINE=jsc

ENGINE can be node, jsc, or v8.

The test-suite can be run using

$ make check-javascript-test-suite ENGINE=jsc

26.2.3 Known Issues

At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.

  • Default optional arguments do not work for all targeted interpreters

  • Multiple output arguments do not work for JSC

  • C89 incompatibily: the JSC generator might still generate C89 violating code

  • long long is not supported

  • %native is not supported

  • Javascript callbacks are not supported

  • instanceOf does not work under JSC

The primary development environment has been Linux (Ubuntu 12.04). Windows and OSX have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

26.3 Integration

This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.

26.3.1 Creating node.js Extensions

To install node.js you can download an installer from their web-site for OSX and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs

As v8 is written in C++ and comes as a C++ library it is crucial to compile your module using the same compiler flags as used for building v8. To make things easier, node.js provides a build tool called node-gyp.

You have to install it using npm:

$ sudo npm install -g node-gyp

node-gyp expects a configuration file named binding.gyp which is basically in JSON format and conforms to the same format that is used with Google's build-tool gyp.

binding.gyp:

{
  "targets": [
    {
      "target_name": "example",
      "sources": [ "example.cxx", "example_wrap.cxx" ]
    }
  ]
}

First create the wrapper using SWIG:

$ swig -javascript -node -c++ example.cxx

Then run node-gyp

$ node-gyp

This will create a build folder containing the native module. To use the extension you need to 'require' it in your Javascript source file:

require("./build/Release/example")

A more detailed explanation is given in the Examples section.

26.3.1.1 Troubleshooting

  • 'module' object has no attribute 'script_main'

This error happens when gyp is installed as a distribution package. It seems to be outdated. Removing it resolves the problem.

$ sudo apt-get remove gyp

26.3.2 Embedded Webkit

Webkit is pre-installed on OSX and available as a library for GTK.

26.3.2.1 OSX

There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

An integration of a native extension 'example' would look like this:

#import "appDelegate.h"

extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports);


@implementation ExampleAppDelegate

@synthesize webView;

- (void)addGlobalObject:(JSContextRef) context:(NSString *)objectName:(JSObjectRef) theObject {
  JSObjectRef global = JSContextGetGlobalObject(context);
  JSStringRef objectJSName = JSStringCreateWithCFString( (CFStringRef) objectName )
  if ( objectJSName != NULL ) {
    JSObjectSetProperty(context, global, objectJSName, theObject, kJSPropertyAttributeReadOnly, NULL);
    JSStringRelease( objectJSName );
  }
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

  // Start a webview with the bundled index.html file
  NSString *path = [[NSBundle mainBundle] bundlePath];
  NSString *url =  [NSString stringWithFormat: @"file://%@/Contents/Assets/index.html", path];

  WebFrame *webframe = [webView mainFrame];
  JSGlobalContextRef context = [webframe globalContext];

  JSObjectRef example;
  example_initialize(context, &example);
  [self addGlobalObject:context:@"example":example]

  JSObjectSetProperty(context, global, JSStringRef propertyName, example, JSPropertyAttributes attributes, NULL);

  [ [webView mainFrame] loadRequest:
    [NSURLRequest requestWithURL: [NSURL URLWithString:url] ]
  ];
}

@end

26.3.2.2 GTK

There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

An integration of a native extension 'example' would look like this:

#include <gtk/gtk.h>
#include <webkit/webkit.h>

extern bool example_initialize(JSGlobalContextRef context);

int main(int argc, char* argv[])
{
    // Initialize GTK+
    gtk_init(&argc, &argv);

    ...

    // Create a browser instance
    WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
    WebFrame *webframe = webkit_web_view_get_main_frame(webView);
    JSGlobalContextRef context = webkit_web_frame_get_global_context(webFrame);
    JSObjectRef global = JSContextGetGlobalObject(context);

    JSObjectRef exampleModule;
    example_initialize(context, &exampleModule);
    JSStringRef jsName = JSStringCreateWithUTF8CString("example");
    JSObjectSetProperty(context, global, jsName, exampleModule, kJSPropertyAttributeReadOnly, NULL);
    JSStringRelease(jsName);

    ...

    // Load a web page into the browser instance
    webkit_web_view_load_uri(webView, "http://www.webkitgtk.org/");

    ...

    // Run the main GTK+ event loop
    gtk_main();

    return 0;
}

26.3.3 Creating Applications with node-webkit

To get started with node-webkit there is a very informative set of wiki pages.

Similar to node.js, node-webkit is started from command line within a node.js project directory. Native extensions are created in the very same way as for node.js , except that a customized gyp derivate has to be used: nw-gyp.

A simple example would have the following structure:

- package.json
- app.html
- app.js
- node_modules
  / example
  ... (as known from node.js)

The configuration file essentially conforms to node.js syntax. It has some extras to configure node-webkit. See the Manifest specification for more details.

package.json:

{
  "name": "example"
  "main": "app.html"
  "window": {
    "show": true,
    "width": 800,
    "height": 600
  }
}

The 'main' property of package.json specifies a web-page to be rendered in the main window.

app.html:

<html>
  <head>
    <script src="app.js"></script>
  </head>
  <body>
    <div>
      The greatest common divisor of
      <span id="x"></span> and
      <span id="y"></span> is
      <span id="z"></span>.
    </div>
  </body>
</html>

As known from node.js one can use require to load javascript modules. Additionally, node-webkit provides an API that allows to manipulate the window's menu, open new windows, and many more things.

app.js:

window.onload = function() {
  var example = require("example");
  var x = 18;
  var y = 24;
  var z = example.gcd(x,y);
  document.querySelector('#x').innerHTML = x;
  document.querySelector('#y').innerHTML = y;
  document.querySelector('#z').innerHTML = z;
};

26.4 Examples

Some basic examples are shown here in more detail.

26.4.1 Simple

The common example simple looks like this:

/* File : example.i */
%module example

%inline %{
extern int    gcd(int x, int y);
extern double Foo;
%}

To make this available as a node extension a binding.gyp has to be created:

{
  "targets": [
    {
      "target_name": "example",
      "sources": [ "example.cxx", "example_wrap.cxx" ]
    }
  ]
}

Then node-gyp is used to build the extension:

$ node-gyp configure build

From a 'nodejs` application the extension would be used like this:

// import the extension via require
var example = require("./build/Release/example");

// calling the global method
var x = 42;
var y = 105;
var g = example.gcd(x,y);

// Accessing the globak variable
var f = example.Foo;
example.Foo = 3.1415926;

First the module example is loaded from the previously built extension. Global methods and variables are available in the scope of the module.

Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.

26.4.2 Class

The common example class defines three classes, Shape, Circle, and Square:

class Shape {
public:
  Shape() {
    nshapes++;
  }
  virtual ~Shape() {
    nshapes--;
  };
  double  x, y;
  void    move(double dx, double dy);
  virtual double area(void) = 0;
  virtual double perimeter(void) = 0;
  static  int nshapes;
};

class Circle : public Shape {
private:
  double radius;
public:
  Circle(double r) : radius(r) { };
  virtual double area(void);
  virtual double perimeter(void);
};

class Square : public Shape {
private:
  double width;
public:
  Square(double w) : width(w) { };
  virtual double area(void);
  virtual double perimeter(void);
};

Circle and Square inherit from Shape . Shape has a static variable nshapes, a function move that can't be overridden (non-virtual), and two abstract functions area and perimeter (pure virtual) that must be overridden by the sub-classes.

A nodejs extension is built the same way as for the simple example.

In Javascript it can be used as follows:

var example = require("./build/Release/example");

// local aliases for convenience
var Shape = example.Shape;
var Circle = example.Circle;
var Square = example.Square;

// creating new instances using the 'new' operator
var c = new Circle(10);
var s = new Square(10);

// accessing a static member
Shape.nshapes;

// accessing member variables
c.x = 20;
c.y = 30;
s.x = -10;
s.y = 5;

// calling some methods
c.area();
c.perimeter();
s.area();
s.perimeter();

// instantiation of Shape is not permitted
new Shape();

Running these commands in an interactive node shell results in the following output:

$ node -i
& var example = require("./build/Release/example");
undefined
& var Shape = example.Shape;
undefined
& var Circle = example.Circle;
undefined
& var Square = example.Square;
undefined
& var c = new Circle(10);
undefined
& var s = new Square(10);
undefined
& Shape.nshapes;
2
& c.x = 20;
20
& c.y = 30;
30
& s.x = -10;
-10
& s.y = 5;
5
& c.area();
314.1592653589793
& c.perimeter();
62.83185307179586
& s.area();
100
& s.perimeter();
40
& c.move(40, 40)
undefined
& c.x
60
& c.y
70
& new Shape()
Error: Class Shape can not be instantiated
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:98:17)
at emitKey (readline.js:1095:12)

Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

26.5 Implementation

The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.

26.5.1 Source Code

The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template , for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:

// module wide defines

#define NAME "name"
...

// ###############################
// #  Helper class declarations

class JSEmitterState { ... };

class Template { ... };

// ###############################
// # JSEmitter declaration

class JSEmitter { ... };

// Emitter factory declarations

JSEmitter *swig_javascript_create_JSCEmitter();
JSEmitter *swig_javascript_create_V8Emitter();

// ###############################
// # Javascript module

// Javascript module declaration

class JAVASCRIPT:public Language { ... };

// Javascript module implementation

int JAVASCRIPT::functionWrapper(Node *n) { ... }
...

// Module factory implementation

static Language *new_swig_javascript() { ... }

extern "C" Language *swig_javascript(void) { ... }

// ###############################
// # JSEmitter base implementation

JSEmitter::JSEmitter() { ... }

Template JSEmitter::getTemplate(const String *name) { ... }
...

// ###############################
// # JSCEmitter

// JSCEmitter declaration

class JSCEmitter: public JSEmitter { ... };

// JSCEmitter implementation

JSCEmitter::JSCEmitter() { ... }

void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static) { ... }
...

// JSCEmitter factory

JSEmitter *swig_javascript_create_JSCEmitter() { ... }


// ###############################
// # V8Emitter

// V8Emitter declaration

class V8Emitter: public JSEmitter { ... };

// V8Emitter implementation

V8Emitter::V8Emitter() { ... }

int V8Emitter::initialize(Node *n) { ... }

// V8Emitter factory

JSEmitter *swig_javascript_create_V8Emitter() { ... }


// ###############################
// # Helper implementation (JSEmitterState, Template)

JSEmitterState::JSEmitterState() { ... }
...

Template::Template(const String *code_) { ... }
...

26.5.2 Code Templates

All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.

To track the originating code template for generated code you can run

$ swig -javascript -jsc -debug-codetemplates

which wraps generated code with a descriptive comment

/* begin fragment("template_name") */

...generated code ...

/* end fragment("template_name") */

The Template class is used like this:

Template t_register = getTemplate("jsv8_register_static_variable");
t_register.replace("$jsparent", state.clazz(NAME_MANGLED))
    .replace("$jsname", state.variable(NAME))
    .replace("$jsgetter", state.variable(GETTER))
    .replace("$jssetter", state.variable(SETTER))
    .trim().
    print(f_init_static_wrappers);

A code template is registered with the JSEmitter via fragment(name, "template"), e.g.,

%fragment ("jsc_variable_declaration", "templates")
%{
  {"$jsname", $jsgetter, $jssetter, kJSPropertyAttributeNone},
%}

Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.

26.5.3 Emitter

The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:

class JSEmitter {
  ...

  /**
   * Opens output files and temporary output DOHs.
   */
  virtual int initialize(Node *n);

  /**
   * Writes all collected code into the output file(s).
   */
  virtual int dump(Node *n) = 0;

  /**
   * Cleans up all open output DOHs.
   */
  virtual int close() = 0;

  ...

  /**
   * Invoked at the beginning of the classHandler.
   */
  virtual int enterClass(Node *);

  /**
   * Invoked at the end of the classHandler.
   */
  virtual int exitClass(Node *) {
    return SWIG_OK;
  };

  /**
   * Invoked at the beginning of the variableHandler.
   */
  virtual int enterVariable(Node *);

  /**
   * Invoked at the end of the variableHandler.
   */
  virtual int exitVariable(Node *) {
    return SWIG_OK;
  };

  /**
   * Invoked at the beginning of the functionHandler.
   */
  virtual int enterFunction(Node *);

  /**
   * Invoked at the end of the functionHandler.
   */
  virtual int exitFunction(Node *) {
    return SWIG_OK;
  };

  /**
   * Invoked by functionWrapper callback after call to Language::functionWrapper.
   */
  virtual int emitWrapperFunction(Node *n);

  /**
   * Invoked from constantWrapper after call to Language::constantWrapper.
   **/
  virtual int emitConstant(Node *n);

  /**
   * Registers a given code snippet for a given key name.
   *
   * This method is called by the fragmentDirective handler
   * of the JAVASCRIPT language module.
   **/
  int registerTemplate(const String *name, const String *code);

  /**
   * Retrieve the code template registered for a given name.
   */
  Template getTemplate(const String *name);

  State &getState();

  ...

}

The module calls initialize, dump, and close from within the top method:

int JAVASCRIPT::top(Node *n) {
  emitter->initialize(n);

  Language::top(n);

  emitter->dump(n);
  emitter->close();

  return SWIG_OK;
}

The methods enterClass and exitClass are called from within the classHandler method:

int JAVASCRIPT::classHandler(Node *n) {

  emitter->enterClass(n);
  Language::classHandler(n);
  emitter->exitClass(n);

  return SWIG_OK;
}

In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.

26.5.4 Emitter states

For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.

class JSEmitterState {

public:

  JSEmitterState();

  ~JSEmitterState();

  DOH *global();

  DOH *global(const char* key, DOH *initial = 0);

  DOH *clazz(bool reset = false);

  DOH *clazz(const char* key, DOH *initial = 0);

  DOH *function(bool reset = false);

  DOH *function(const char* key, DOH *initial = 0);

  DOH *variable(bool reset = false);

  DOH *variable(const char* key, DOH *initial = 0);

  static int IsSet(DOH *val);

  ...
};

When entering a scope, such as in enterClass, the corresponding state is reset and new data is stored:

state.clazz(RESET);
state.clazz(NAME, Getattr(n, "sym:name"));

State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.

26.5.5 Handling Exceptions in JavascriptCore

Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.

void script_exception_to_string(JSContextRef js_context,JSValueRef exception_value_ref,char* return_error_string, int return_error_string_max_length)
{
  JSObjectRef exception_object;
  JSValueRef value_ref;
  JSStringRef jsstring_property_name = NULL;
  JSValueRef temporary_exception = NULL;
  JSStringRef js_return_string = NULL;
  size_t bytes_needed;
  char* c_result_string = NULL;
  exception_object = JSValueToObject(js_context, exception_value_ref, NULL);

  /* source url */
  strcpy(return_error_string,"[");
  jsstring_property_name = JSStringCreateWithUTF8CString("sourceURL");
  value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception);
  JSStringRelease(jsstring_property_name);
  js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
  bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
  c_result_string = (char*)calloc(bytes_needed, sizeof(char));
  JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
  JSStringRelease(js_return_string);
  strncat(return_error_string, c_result_string, return_error_string_max_length-1);
  free(c_result_string);

  strncat(return_error_string, ":", return_error_string_max_length-1);

  /* line number */

  jsstring_property_name = JSStringCreateWithUTF8CString("line");
  value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception);
  JSStringRelease(jsstring_property_name);
  js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
  bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
  c_result_string = (char*)calloc(bytes_needed, sizeof(char));
  JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
  JSStringRelease(js_return_string);
  strncat(return_error_string, c_result_string, return_error_string_max_length-1);
  free(c_result_string);

  strncat(return_error_string, "]", return_error_string_max_length-1);

  /* error message */

  jsstring_property_name = JSStringCreateWithUTF8CString("message");
  value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception);
  JSStringRelease(jsstring_property_name);
  if(NULL == value_ref)
  {
    strncat(return_error_string, "Unknown Error", return_error_string_max_length-1);
  }
  else
  {
    js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
    bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
    c_result_string = (char*)calloc(bytes_needed, sizeof(char));
    JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
    JSStringRelease(js_return_string);
    strncat(return_error_string, c_result_string, return_error_string_max_length-1);
    free(c_result_string);
  }
}

It would be used in the following way:

if(js_exception)
{
  char return_error_string[256];
  script_exception_to_string(js_context, js_exception, return_error_string, 256);
  printf("Compile error is %s", return_error_string);
}

27 SWIG and Common Lisp

Common Lisp is a high-level, all-purpose, object-oriented, dynamic, functional programming language with long history. Common Lisp is used in many fields, ranging from web development to finance, and also common in computer science education. There are more than 9 different implementations of common lisp which are available, all have different foreign function interfaces. SWIG currently supports only the Allegro Common Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI foreign function interfaces.

27.1 Allegro Common Lisp

Allegro Common Lisp support in SWIG has been updated to include support for both C and C++. You can read about the interface here

27.2 Common Foreign Function Interface(CFFI)

CFFI, the Common Foreign Function Interface, is a portable foreign function interface for ANSI Common Lisp systems, similar in spirit to UFFI. Unlike UFFI, CFFI requires only a small set of low-level functionality from the Lisp implementation, such as calling a foreign function by name, allocating foreign memory, and dereferencing pointers.

To run the cffi module of SWIG requires very little effort, you just need to run:

swig -cffi -module module-name   file-name 

But a better was of using all the power of SWIG is to write SWIG interface files. Below we will explain how to write interface files and the various things which you can do with them.

27.2.1 Additional Commandline Options

The following table list the additional commandline options available for the CLISP module. They can also be seen by using:

swig -cffi -help 

CFFI specific options
-generate-typedefIf this option is given then defctype will be used to generate
shortcuts according to the typedefs in the input.
-[no]cwrapTurn on or turn off generation of an intermediate C file when
creating a C interface. By default this is only done for C++ code.
-[no]swig-lispTurns on or off generation of code for helper lisp macro, functions, etc. which SWIG uses while generating wrappers. These macros, functions may still be used by generated wrapper code.

27.2.2 Generating CFFI bindings

As we mentioned earlier the ideal way to use SWIG is to use interface files. To illustrate the use of it, let's assume that we have a file named test.h with the following C code:
#define y 5
#define x (y >>  1)

typedef int days;

struct bar {
  short p, q;
    char a, b;
    int *z[1000];
    struct bar * n;
};
  
struct   bar * my_struct;

struct foo {
    int a;
    struct foo * b[100];
  
};

int pointer_func(void (*ClosureFun)( void* _fun, void* _data, void* _evt ), int p);

int func123(div_t * p,int **q[100],int r[][1000][10]);

void lispsort_double (int n, double * array);

enum color { RED, BLUE, GREEN};
Corresponding to this we will write a simple interface file:
%module test

%include "test.h"

The generated SWIG Code will be:
;;;SWIG wrapper code starts here

(cl:defmacro defanonenum (&body enums)
   "Converts anonymous enums to defconstants."
  `(cl:progn ,@(cl:loop for value in enums
                        for index = 0 then (cl:1+ index)
                        when (cl:listp value) do (cl:setf index (cl:second value)
                                                          value (cl:first value))
                        collect `(cl:defconstant ,value ,index))))

(cl:eval-when (:compile-toplevel :load-toplevel)
  (cl:unless (cl:fboundp 'swig-lispify)
    (cl:defun swig-lispify (name flag cl:&optional (package cl:*package*))
      (cl:labels ((helper (lst last rest cl:&aux (c (cl:car lst)))
                    (cl:cond
                      ((cl:null lst)
                       rest)
                      ((cl:upper-case-p c)
                       (helper (cl:cdr lst) 'upper
                               (cl:case last
                                 ((lower digit) (cl:list* c #\- rest))
                                 (cl:t (cl:cons c rest)))))
                      ((cl:lower-case-p c)
                       (helper (cl:cdr lst) 'lower (cl:cons (cl:char-upcase c) rest)))
                      ((cl:digit-char-p c)
                       (helper (cl:cdr lst) 'digit 
                               (cl:case last
                                 ((upper lower) (cl:list* c #\- rest))
                                 (cl:t (cl:cons c rest)))))
                      ((cl:char-equal c #\_)
                       (helper (cl:cdr lst) '_ (cl:cons #\- rest)))
                      (cl:t
                       (cl:error "Invalid character: ~A" c)))))
        (cl:let ((fix (cl:case flag
                        ((constant enumvalue) "+")
                        (variable "*")
                        (cl:t ""))))
          (cl:intern
           (cl:concatenate
            'cl:string
            fix
            (cl:nreverse (helper (cl:concatenate 'cl:list name) cl:nil cl:nil))
            fix)
           package))))))

;;;SWIG wrapper code ends here


(cl:defconstant y 5)

(cl:defconstant x (cl:ash 5 -1))

(cffi:defcstruct bar
	(p :short)
	(q :short)
	(a :char)
	(b :char)
	(z :pointer)
	(n :pointer))

(cffi:defcvar ("my_struct" my_struct)
 :pointer)

(cffi:defcstruct foo
	(a :int)
	(b :pointer))

(cffi:defcfun ("pointer_func" pointer_func) :int
  (ClosureFun :pointer)
  (p :int))

(cffi:defcfun ("func123" func123) :int
  (p :pointer)
  (q :pointer)
  (r :pointer))

(cffi:defcfun ("lispsort_double" lispsort_double) :void
  (n :int)
  (array :pointer))

(cffi:defcenum color
	:RED
	:BLUE
	:GREEN)

The SWIG wrapper code refers to the special code which SWIG may need to use while wrapping C code. You can turn on/off the generation of this code by using the -[no]swig-lisp option. You must have noticed that SWIG goes one extra step to ensure that CFFI does not do automatic lispification of the C function names. The reason SWIG does this is because quite often developers want to build a nice CLOS based lispy API, and this one to one correspondence between C function names and lisp function name helps.

Maybe you want to have your own convention for generating lisp function names for corresponding C function names, or you just want to lispify the names, also, before we forget you want to export the generated lisp names. To do this, we will use the SWIG feature directive. Let's edit the interface file such that the C type "div_t*" is changed to Lisp type ":my-pointer", we lispify all names, export everything, and do some more stuff.

%module test

%typemap(cin) div_t* ":my-pointer";

%feature("intern_function","1");
%feature("export");

%feature("inline") lispsort_double;

%feature("intern_function", "my-lispify") lispsort_double;
%rename func123 renamed_cool_func;
%ignore "pointer_func";

%include "test.h"

The typemap(cin) ensures that for all arguments which are input to C with the type "div_t*", the ":my-pointer" type be used. Similarly typemap(cout) are used for all types which are returned from C.

The feature intern_function ensures that all C names are interned using the swig-lispify function. The "1" given to the feature is optional. The use of feature like %feature("intern_function","1"); globally enables interning for everything. If you want to target a single function, or declaration then use the targeted version of feature, %feature("intern_function", "my-lispify") lispsort_double;, here we are using an additional feature which allows us to use our lispify function.

The export feature allows us to export the symbols. The inline feature declaims the declared function as inline. The rename directive allows us to change the name(it is useful when generating C wrapper code for handling overloaded functions). The ignore directive ignores a certain declaration.

There are several other things which are possible, to see some example of usage of SWIG look at the Lispbuilder and wxCL projects. The generated code with 'noswig-lisp' option is:

(cl:defconstant #.(swig-lispify "y" 'constant) 5)

(cl:export '#.(swig-lispify "y" 'constant))

(cl:defconstant #.(swig-lispify "x" 'constant) (cl:ash 5 -1))

(cl:export '#.(swig-lispify "x" 'constant))

(cffi:defcstruct #.(swig-lispify "bar" 'classname)
	(#.(swig-lispify "p" 'slotname) :short)
	(#.(swig-lispify "q" 'slotname) :short)
	(#.(swig-lispify "a" 'slotname) :char)
	(#.(swig-lispify "b" 'slotname) :char)
	(#.(swig-lispify "z" 'slotname) :pointer)
	(#.(swig-lispify "n" 'slotname) :pointer))

(cl:export '#.(swig-lispify "bar" 'classname))

(cl:export '#.(swig-lispify "p" 'slotname))

(cl:export '#.(swig-lispify "q" 'slotname))

(cl:export '#.(swig-lispify "a" 'slotname))

(cl:export '#.(swig-lispify "b" 'slotname))

(cl:export '#.(swig-lispify "z" 'slotname))

(cl:export '#.(swig-lispify "n" 'slotname))

(cffi:defcvar ("my_struct" #.(swig-lispify "my_struct" 'variable))
 :pointer)

(cl:export '#.(swig-lispify "my_struct" 'variable))

(cffi:defcstruct #.(swig-lispify "foo" 'classname)
	(#.(swig-lispify "a" 'slotname) :int)
	(#.(swig-lispify "b" 'slotname) :pointer))

(cl:export '#.(swig-lispify "foo" 'classname))

(cl:export '#.(swig-lispify "a" 'slotname))

(cl:export '#.(swig-lispify "b" 'slotname))

(cffi:defcfun ("renamed_cool_func" #.(swig-lispify "renamed_cool_func" 'function)) :int
  (p :my-pointer)
  (q :pointer)
  (r :pointer))

(cl:export '#.(swig-lispify "renamed_cool_func" 'function))

(cl:declaim (cl:inline #.(my-lispify "lispsort_double" 'function)))

(cffi:defcfun ("lispsort_double" #.(my-lispify "lispsort_double" 'function)) :void
  (n :int)
  (array :pointer))

(cl:export '#.(my-lispify "lispsort_double" 'function))

(cffi:defcenum #.(swig-lispify "color" 'enumname)
	#.(swig-lispify "RED" 'enumvalue :keyword)
	#.(swig-lispify "BLUE" 'enumvalue :keyword)
	#.(swig-lispify "GREEN" 'enumvalue :keyword))

(cl:export '#.(swig-lispify "color" 'enumname))

27.2.3 Generating CFFI bindings for C++ code

This feature to SWIG (for CFFI) is very new and still far from complete. Pitch in with your patches, bug reports and feature requests to improve it.

Generating bindings for C++ code, requires -c++ option to be present and it first generates C binding which will wrap the C++ code, and then generates the corresponding CFFI wrapper code. In the generated C wrapper code, you will often want to put your own C code, such as the code to include various files. This can be done by making use of "%{" and "%}" as shown below.

%{
 #include "Test/test.h"
%}

Also, while parsing the C++ file and generating C wrapper code SWIG may need to be able to understand various symbols used in other header files. To help SWIG in doing this while ensuring that wrapper code is generated for the target file, use the "import" directive. The "include" directive specifies the target file for which wrapper code will be generated.


%import "ancillary/header.h"

%include "target/header.h"

Various features which were available for C headers can also be used here. The target header which we are going to use here is:
namespace OpenDemo {
  class Test
    {
    public:
        float x;
        // constructors
        Test (void) {x = 0;}
        Test (float X) {x = X;}

        // vector addition
        Test operator+ (const Test& v) const {return Test (x+v.x);}

      // length squared
        float lengthSquared (void) const {return this->dot (*this);}

        static float distance (const Test& a, const Test& b){return(a-b).length();}

        inline Test parallelComponent (const Test& unitBasis) const {
          return unitBasis * projection;
        }

        Test setYtoZero (void) const {return Test (this->x);}

        static const Test zero;
    };


   inline Test operator* (float s, const Test& v) {return v*s;}


    inline std::ostream& operator<< (std::ostream& o, const Test& v)
    {
        return o << "(" << v.x << ")";
    }


    inline Test RandomUnitVectorOnXZPlane (void)
    {
        return RandomVectorInUnitRadiusSphere().setYtoZero().normalize();
    }
}

The interface used is:

%module test
%include "test.cpp"
SWIG generates 3 files, the first one is a C wrap which we don't show, the second is the plain CFFI wrapper which is as shown below:
(cffi:defcfun ("_wrap_Test_x_set" Test_x_set) :void
  (self :pointer)
  (x :float))

(cffi:defcfun ("_wrap_Test_x_get" Test_x_get) :float
  (self :pointer))

(cffi:defcfun ("_wrap_new_Test__SWIG_0" new_Test) :pointer)

(cffi:defcfun ("_wrap_new_Test__SWIG_1" new_Test) :pointer
  (X :float))

(cffi:defcfun ("_wrap_Test___add__" Test___add__) :pointer
  (self :pointer)
  (v :pointer))

(cffi:defcfun ("_wrap_Test_lengthSquared" Test_lengthSquared) :float
  (self :pointer))

(cffi:defcfun ("_wrap_Test_distance" Test_distance) :float
  (a :pointer)
  (b :pointer))

(cffi:defcfun ("_wrap_Test_parallelComponent" Test_parallelComponent) :pointer
  (self :pointer)
  (unitBasis :pointer))

(cffi:defcfun ("_wrap_Test_setYtoZero" Test_setYtoZero) :pointer
  (self :pointer))

(cffi:defcvar ("Test_zero" Test_zero)
 :pointer)

(cffi:defcfun ("_wrap_delete_Test" delete_Test) :void
  (self :pointer))

(cffi:defcfun ("_wrap___mul__" __mul__) :pointer
  (s :float)
  (v :pointer))

(cffi:defcfun ("_wrap___lshift__" __lshift__) :pointer
  (o :pointer)
  (v :pointer))

(cffi:defcfun ("_wrap_RandomUnitVectorOnXZPlane" RandomUnitVectorOnXZPlane) :pointer)
The output is pretty good but it fails in disambiguating overloaded functions such as the constructor, in this case. One way of resolving this problem is to make the interface use the rename directiv, but hopefully there are better solutions. In addition SWIG also generates, a CLOS file
(clos:defclass test()
  ((ff :reader ff-pointer)))

(clos:defmethod (cl:setf x) (arg0 (obj test))
  (Test_x_set (ff-pointer obj) arg0))

(clos:defmethod x ((obj test))
  (Test_x_get (ff-pointer obj)))

(cl:shadow "+")
(clos:defmethod + ((obj test) (self test) (v test))
  (Test___add__ (ff-pointer obj) (ff-pointer self) (ff-pointer v)))

(clos:defmethod length-squared ((obj test) (self test))
  (Test_lengthSquared (ff-pointer obj) (ff-pointer self)))

(clos:defmethod parallel-component ((obj test) (self test) (unitBasis test))
  (Test_parallelComponent (ff-pointer obj) (ff-pointer self) (ff-pointer unitBasis)))

(clos:defmethod set-yto-zero ((obj test) (self test))
  (Test_setYtoZero (ff-pointer obj) (ff-pointer self)))

I agree that the CFFI C++ module needs lot more work. But I hope it provides a starting point, on which you can base your work of importing C++ libraries to Lisp.

If you have any questions, suggestions, patches, etc., related to CFFI module feel free to contact us on the SWIG mailing list, and also please add a "[CFFI]" tag in the subject line.

27.2.4 Inserting user code into generated files

It is often necessary to include user-defined code into the automatically generated interface files. For example, when building a C++ interface, example_wrap.cxx will likely not compile unless you add a #include "header.h" directive. This can be done using the SWIG %insert(section) %{ ...code... %} directive:

%module example

%{
#include "header.h"
%}

%include "header.h"

int fact(int n);

Additional sections have been added for inserting into the generated lisp interface file:

  • lisphead - inserts before type declarations
  • swiglisp - inserts after type declarations according to where it appears in the .i file

Note that the block %{ ... %} is effectively a shortcut for %insert("header") %{ ... %}.

27.3 CLISP

CLISP is a feature-loaded implementation of common lisp which is portable across most of the operating system environments and hardware. CLISP includes an interpreter, a compiler, a debugger, CLOS, MOP, a foreign language interface, i18n, regular expressions, a socket interface, and more. An X11 interface is available through CLX, Garnet and CLUE/CLIO. Command line editing is provided by readline. CLISP runs Maxima, ACL2 and many other Common Lisp packages.

To run the clisp module of SWIG requires very little effort, you just need to execute:

swig -clisp -module module-name   file-name 

Because of the high level nature of the CLISP FFI, the bindings generated by SWIG may not be absolutely correct, and you may need to modify them. The good thing is that you don't need to complex interface file for the CLISP module. The CLISP module tries to produce code which is both human readable and easily modifyable.

27.3.1 Additional Commandline Options

The following table list the additional commandline options available for the CLISP module. They can also be seen by using:

swig -clisp -help 

CLISP specific options
-extern-allIf this option is given then clisp definitions for all the functions
and global variables will be created otherwise only definitions for
externed functions and variables are created.
-generate-typedefIf this option is given then def-c-type will be used to generate
shortcuts according to the typedefs in the input.

27.3.2 Details on CLISP bindings

As mentioned earlier the CLISP bindings generated by SWIG may need some modifications. The clisp module creates a lisp file with the same name as the module name. This lisp file contains a 'defpackage' declaration, with the package name same as the module name. This package uses the 'common-lisp' and 'ffi' packages. Also, package exports all the functions, structures and variables for which an ffi binding was generated.
After generating the defpackage statement, the clisp module also sets the default language.

(defpackage :test
    (:use :common-lisp :ffi)
  (:export
   :make-bar
   :bar-x
   :bar-y
   :bar-a
   :bar-b
   :bar-z
   :bar-n
   :pointer_func
   :func123
   :make-cfunr
   :lispsort_double
   :test123))

(in-package :test)

(default-foreign-language :stdc)

The ffi wrappers for functions and variables are generated as shown below. When functions have arguments of type "double * array", SWIG doesn't knows whether it is an 'out' argument or it is an array which will be passed, so SWIG plays it safe by declaring it as an '(array (ffi:c-ptr DOUBLE-FLOAT))'. For arguments of type "int **z[100]" where SWIG has more information, i.e., it knows that 'z' is an array of pointers to pointers of integers, SWIG defines it to be '(z (ffi:c-ptr (ffi:c-array (ffi:c-ptr (ffi:c-ptr ffi:int)) 100)))'

extern "C" {
int pointer_func(void (*ClosureFun)( void* _fun, void* _data, void* _evt ), int y);

int func123(div_t * x,int **z[100],int y[][1000][10]);

void lispsort_double (int n, double * array);

void test123(float x , double y);

}
(ffi:def-call-out pointer_func
    (:name "pointer_func")
  (:arguments (ClosureFun (ffi:c-function (:arguments (arg0 (ffi:c-pointer NIL))
						      (arg1 (ffi:c-pointer NIL))
						      (arg2 (ffi:c-pointer NIL)))
					  (:return-type NIL)))
	      (y ffi:int))
  (:return-type ffi:int)
  (:library +library-name+))

(ffi:def-call-out func123
    (:name "func123")
  (:arguments (x (ffi:c-pointer div_t))
	      (z (ffi:c-ptr (ffi:c-array (ffi:c-ptr (ffi:c-ptr ffi:int)) 100)))
	      (y (ffi:c-ptr (ffi:c-ptr (ffi:c-array ffi:int (1000 10))))))
  (:return-type ffi:int)
  (:library +library-name+))


(ffi:def-call-out lispsort_double
    (:name "lispsort_double")
  (:arguments (n ffi:int)
	      (array (ffi:c-ptr DOUBLE-FLOAT)))
  (:return-type NIL)
  (:library +library-name+))

(ffi:def-call-out test123
    (:name "test")
  (:arguments (x SINGLE-FLOAT)
	      (y DOUBLE-FLOAT))
  (:return-type NIL)
  (:library +library-name+))

The module also handles strutcures and #define constants as shown below. SWIG automatically adds the constructors and accessors created for the struct to the list of symbols exported by the package.

struct bar {
    short x, y;
    char a, b;
    int *z[1000];
    struct bar * n;
};

#define max 1000
(ffi:def-c-struct bar
    (x :type ffi:short)
  (y :type ffi:short)
  (a :type character)
  (b :type character)
  (z :type (ffi:c-array (ffi:c-ptr ffi:int) 1000))
  (n :type (ffi:c-pointer bar)))

(defconstant max 1000)

27.4 UFFI


28 SWIG and Lua

Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). It's also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org

eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net

28.1 Preliminaries

The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.

28.2 Running SWIG

Suppose that you defined a SWIG module such as the following:

%module example
%{
#include "example.h"
%}
int gcd(int x, int y);
extern double Foo;

To build a Lua module, run SWIG using the -lua option.

$ swig -lua example.i

If building a C++ extension, add the -c++ option:

$ swig -c++ -lua example.i

This creates a C/C++ source file example_wrap.c or example_wrap.cxx. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.

The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrapped module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.

To build an eLua module, run SWIG using -lua and add either -elua or -eluac.

$ swig -lua -elua example.i

or

$ swig -lua -eluac example.i

The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.

28.2.1 Additional command line options

The following table list the additional commandline options available for the Lua module. They can also be seen by using:

swig -lua -help 
Lua specific options
-eluaGenerates LTR compatible wrappers for smaller devices running elua.
-eluacLTR compatible wrappers in "crass compress" mode for elua.
-nomoduleglobalDo not register the module name as a global variable but return the module table from calls to require.
-no-old-metatable-bindingsDisable backward compatibility: old-style binding names generations and a few other things. Explanations are included in appropriate later sections.
-squash-basesSquashes symbols from all inheritance tree of a given class into itself. Emulates pre-SWIG3.0 inheritance. Insignificantly speeds things up, but increases memory consumption.

28.2.2 Compiling and Linking and Interpreter

Normally Lua is embedded into another program and will be statically linked. An extremely simple stand-alone interpreter (min.c) is given below:

#include <stdio.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"

extern int luaopen_example(lua_State* L); // declare the wrapped module

int main(int argc,char* argv[])
{
 lua_State *L;
 if (argc<2)
 {
  printf("%s: <filename.lua>\n",argv[0]);
  return 0;
 }
 L=lua_open();
 luaopen_base(L);	// load basic libs (eg. print)
 luaopen_example(L);	// load the wrapped module
 if (luaL_loadfile(L,argv[1])==0) // load and run the file
  lua_pcall(L,0,0,0);
 else
  printf("unable to load %s\n",argv[1]);
 lua_close(L);
 return 0;
}

A much improved set of code can be found in the Lua distribution src/lua/lua.c. Include your module, just add the external declaration & add a #define LUA_EXTRALIBS {"example",luaopen_example}, at the relevant place.

The exact commands for compiling and linking vary from platform to platform. Here is a possible set of commands of doing this:

$ swig -lua example.i -o example_wrap.c
$ gcc -I/usr/include/lua -c min.c -o min.o
$ gcc -I/usr/include/lua -c example_wrap.c -o example_wrap.o
$ gcc -c example.c -o example.o
$ gcc -I/usr/include/lua -L/usr/lib/lua min.o example_wrap.o example.o -o my_lua

For eLua, the source must be built along with the wrappers generated by SWIG. Make sure the eLua source files platform_conf.h and auxmods.h are updated with the entries of your new module. Please note: "mod" is the module name.

/* Sample platform_conf.h */
#define LUA_PLATFORM_LIBS_ROM\
  _ROM( AUXLIB_PIO, luaopen_pio, pio_map )\
  _ROM( AUXLIB_TMR, luaopen_tmr, tmr_map )\
  _ROM( AUXLIB_MOD, luaopen_mod, mod_map )\
  ....
/* Sample auxmods.h */
#define AUXLIB_PIO       "pio"
LUALIB_API int ( luaopen_pio )(lua_State *L );

#define AUXLIB_MOD       "mod"
LUALIB_API int ( luaopen_mod )(lua_State *L );
....

More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html

28.2.3 Compiling a dynamic module

Most, but not all platforms support the dynamic loading of modules (Windows & Linux do). Refer to the Lua manual to determine if your platform supports it. For compiling a dynamically loaded module the same wrapper can be used. Assuming you have code you need to link to in a file called example.c, the commands will be something like this:

$ swig -lua example.i -o example_wrap.c
$ gcc -fPIC -I/usr/include/lua -c example_wrap.c -o example_wrap.o
$ gcc -fPIC -c example.c -o example.o
$ gcc -shared -I/usr/include/lua -L/usr/lib/lua example_wrap.o example.o -o example.so

The wrappers produced by SWIG can be compiled and linked with Lua 5.1.x and later. The loading is extremely simple.

require("example")

For those using Lua 5.0.x, you will also need an interpreter with the loadlib function (such as the default interpreter compiled with Lua). In order to dynamically load a module you must call the loadlib function with two parameters: the filename of the shared library, and the function exported by SWIG. Calling loadlib should return the function, which you then call to initialise the module

my_init=loadlib("example.so","luaopen_example") -- for Unix/Linux
--my_init=loadlib("example.dll","luaopen_example") -- for Windows
assert(my_init) -- make sure it's not nil
my_init()       -- call the init fn of the lib

Or can be done in a single line of Lua code

assert(loadlib("example.so","luaopen_example"))()

If the code didn't work, don't panic. The best thing to do is to copy the module and your interpreter into a single directory and then execute the interpreter and try to manually load the module (take care, all this code is case sensitive).

a,b,c=package.loadlib("example.so","luaopen_example") -- for Unix/Linux
--a,b,c=package.loadlib("example.dll","luaopen_example") -- for Windows
print(a,b,c)

Note: for Lua 5.0:
The loadlib() function is in the global namespace, not in a package. So it's just loadlib().

if 'a' is a function, this is all working fine, all you need to do is call it

  a()

to load your library which will add a table 'example' with all the functions added.

If it doesn't work, look at the error messages, in particular message 'b'
The specified module could not be found.
Means that is cannot find the module, check your the location and spelling of the module.
The specified procedure could not be found.
Means that it loaded the module, but cannot find the named function. Again check the spelling, and if possible check to make sure the functions were exported correctly.
'loadlib' not installed/supported
Is quite obvious (Go back and consult the Lua documents on how to enable loadlib for your platform).

28.2.4 Using your module

Assuming all goes well, you will be able to this:

$ ./my_lua
> print(example.gcd(4,6))
2
> print(example.Foo)
3
> example.Foo=4
> print(example.Foo)
4
>

28.3 A tour of basic C/C++ wrapping

By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.

28.3.1 Modules

The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.

28.3.2 Functions

Global functions are wrapped as new Lua built-in functions. For example,

%module example
int fact(int n);

creates a built-in function example.fact(n) that works exactly like you think it does:

> print example.fact(4)
24
>

To avoid name collisions, SWIG create a Lua table which keeps all the functions, constants, classes and global variables in. It is possible to copy the functions, constants and classes (but not variables) out of this and into the global environment with the following code. This can easily overwrite existing functions, so this must be used with care. This option is considered deprecated and will be removed in the near future.

> for k,v in pairs(example) do _G[k]=v end
> print(fact(4))
24
>

It is also possible to rename the module with an assignment.

> e=example
> print(e.fact(4))
24
> print(example.fact(4))
24

28.3.3 Global variables

Global variables (which are linked to C code) are supported, and appear to be just another variable in Lua. However the actual mechanism is more complex. Given a global variable:

%module example
extern double Foo;

SWIG will effectively generate two functions example.Foo_set() and example.Foo_get(). It then adds a metatable to the table 'example' to call these functions at the correct time (when you attempt to set or get examples.Foo). Therefore if you were to attempt to assign the global to another variable, you will get a local copy within the interpreter, which is no longer linked to the C code.

> print(example.Foo)
3
> c=example.Foo   -- c is a COPY of example.Foo, not the same thing
> example.Foo=4
> print(c)
3
> c=5 -- this will not effect the original example.Foo
> print(example.Foo,c)
4    5

It is therefore not possible to 'move' the global variable into the global namespace as it is with functions. It is however, possible to rename the module with an assignment, to make it more convenient.

> e=example
> -- e and example are the same table
> -- so e.Foo and example.Foo are the same thing
> example.Foo=4
> print(e.Foo)
4

If a variable is marked with the %immutable directive then any attempts to set this variable will cause a Lua error. Given a global variable:

%module example
%immutable;
extern double Foo;
%mutable;

SWIG will allow the reading of Foo but when a set attempt is made, an error function will be called.

> print(e.Foo) -- reading works ok
4
> example.Foo=40 -- but writing does not
This variable is immutable
stack traceback:
        [C]: ?
        [C]: ?
        stdin:1: in main chunk
        [C]: ?

For those people who would rather that SWIG silently ignore the setting of immutables (as previous versions of the Lua bindings did), adding a -DSWIGLUA_IGNORE_SET_IMMUTABLE compile option will remove this.

Unlike earlier versions of the binding, it is now possible to add new functions or variables to the module, just as if it were a normal table. This also allows the user to rename/remove existing functions and constants (but not linked variables, mutable or immutable). Therefore users are recommended to be careful when doing so.

> -- example.PI does not exist
> print(example.PI)
nil
> example.PI=3.142 -- new value added
> print(example.PI)
3.142

If you have used the -eluac option for your eLua module, you will have to follow a different approach while manipulating global variables. (This is not applicable for wrappers generated with -elua)

> -- Applicable only with -eluac. (num is defined)
> print(example.num_get())
20
> example.num_set(50) -- new value added
> print(example.num_get())
50

In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.

28.3.4 Constants and enums

Because Lua doesn't really have the concept of constants, C/C++ constants are not really constant in Lua. They are actually just a copy of the value into the Lua interpreter. Therefore they can be changed just as any other value. For example given some constants:

%module example
%constant int ICONST=42;
#define    SCONST      "Hello World"
enum Days{SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};

This is 'effectively' converted into the following Lua code:

example.ICONST=42
example.SCONST="Hello World"
example.SUNDAY=0
....

Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

If you're using eLua and have used -elua or -eluac to generate your wrapper, macro constants and enums should be accessed through a rotable called "const". In eLua, macro constants and enums are guaranteed to remain constants since they are all contained within a rotable. A regular C constant is accessed from eLua just as if it were a regular global variable, just that the property of value immutability is demonstrated if an attempt at modifying a C constant is made.

> print(example.ICONST)
10
> print(example.const.SUNDAY)
0
> print(example.const.SCONST)
Hello World

28.3.4.1 Constants/enums and classes/structures

Enums are exported into a class table. For example, given some enums:

%module example
enum Days { SUNDAY = 0, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY };
struct Test {
    enum { TEST1 = 10, TEST2 = 20 };
#ifdef __cplusplus // There are no static members in C
    static const int ICONST = 12;
#endif
};

There is a slight difference in behaviour wrapping C and C++ code due to the different scoping rules of C and C++. The wrapped C++ code is used as follows from Lua code:

> print(example.SUNDAY)
0
> print(example.Test.TEST1)
10
> print(example.Test.ICONST)
12

Enums within a C struct are in the global namespace and are used as follows from Lua

> print(example.SUNDAY)
0
> -- See the difference here
> print(example.TEST1)
10

Compatibility Note: Versions of SWIG prior to SWIG-3.0.0 did not generate the class table members above. There is no change in the C wrappers, but the following code was the only way to access these constants/enums when wrapping C++ member constants:

> print(example.Test_TEST1)
10
> print(example.Test_ICONST)
12

The old-style bindings are still generated in addition to the new ones. If the -no-old-metatable-bindings option is used, then these old-style bindings are not generated.

It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.

28.3.5 Pointers

C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Given a wrapping of the <file.h> interface:

%module example

FILE *fopen(const char *filename, const char *mode);
int fputs(const char *, FILE *);
int fclose(FILE *);

When wrapped, you will be able to use the functions in a natural way from Lua. For example:

> f=example.fopen("junk","w")
> example.fputs("Hello World",f)
> example.fclose(f)

Unlike many scripting languages, Lua has had support for pointers to C/C++ object built in for a long time. They are called 'userdata'. Unlike many other SWIG versions which use some kind of encoded character string, all objects will be represented as a userdata. The SWIG-Lua bindings provides a special function swig_type(), which if given a userdata object will return the type of object pointed to as a string (assuming it was a SWIG wrapped object).

> print(f)
userdata: 003FDA80
> print(swig_type(f))
FILE * -- it's a FILE*

Lua enforces the integrity of its userdata, so it is virtually impossible to corrupt the data. But as the user of the pointer, you are responsible for freeing it, or closing any resources associated with it (just as you would in a C program). This does not apply so strictly to classes & structs (see below). One final note: if a function returns a NULL pointer, this is not encoded as a userdata, but as a Lua nil.

> f=example.fopen("not there","r") -- this will return a NULL in C
> print(f)
nil

28.3.6 Structures

If you wrap a C structure, it is also mapped to a Lua userdata. By adding a metatable to the userdata, this provides a very natural interface. For example,

struct Point{
  int x,y;
};

is used as follows:

> p=example.new_Point()
> p.x=3
> p.y=5
> print(p.x,p.y)
3       5
>

Similar access is provided for unions and the data members of C++ classes.
C structures can be created using a function new_Point(), and both C structures and C++ classes can be created using just the name Point().

If you print out the value of p in the above example, you will see something like this:

> print(p)
userdata: 003FA320

Like the pointer in the previous section, this is held as a userdata. However, additional features have been added to make this more usable. SWIG effectively creates some accessor/mutator functions to get and set the data. These functions will be added to the userdata's metatable. This provides the natural access to the member variables that were shown above (see end of the document for full details).

const members of a structure are read-only. Data members can also be forced to be read-only using the immutable directive. As with other immutables, setting attempts will be cause an error. For example:

struct Foo {
   ...
   %immutable;
   int x;        // Read-only members
   char *name;
   %mutable;
   ...
};

The mechanism for managing char* members as well as array members is similar to other languages. It is somewhat cumbersome and should probably be better handled by defining of typemaps (described later).

When a member of a structure is itself a structure, it is handled as a pointer. For example, suppose you have two structures like this:

struct Foo {
   int a;
};

struct Bar {
   Foo f;
};

Now, suppose that you access the f attribute of Bar like this:

> b = Bar()
> x = b.f

In this case, x is a pointer that points to the Foo that is inside b. This is the same value as generated by this C code:

Bar b;
Foo *x = &b->f;       // Points inside b

Because the pointer points inside the structure, you can modify the contents and everything works just like you would expect. For example:

> b = Bar()
> b.f.a = 3               -- Modify attribute of structure member
> x = b.f
> x.a = 3                 -- Modifies the same structure

For eLua with the -eluac option, structure manipulation has to be performed with specific structure functions generated by SWIG. Let's say you have the following structure definition:

struct data {
   int x, y;
   double z;
};

> --From eLua
> a = example.new_data()
> example.data_x_set(a, 10)
> example.data_y_set(a, 20)
> print(example.data_x_get(a), example.data_y_get(a))
10 20

In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)

28.3.7 C++ classes

C++ classes are wrapped by a Lua userdata as well. For example, if you have this class,

class List {
public:
  List();
  ~List();
  int  search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int  length;
};

you can use it in Lua like this:

> l = example.List()
> l:insert("Ale")
> l:insert("Stout")
> l:insert("Lager")
> print(l:get(1))
Stout
> print(l:length)
3
>

(Note: for calling methods of a class, you use class:method(args), not class.method(args), it's an easy mistake to make. However for data attributes it is class.attribute )

Class data members are accessed in the same manner as C structures. Static class members present a special problem for Lua, as Lua doesn't have support for such features. Therefore, SWIG generates wrappers that try to work around some of these issues. To illustrate, suppose you have a class like this:

class Spam {
public:
   static void foo();
   static int bar;
};

In Lua, C++ static members can be accessed as follows:

> example.Spam.foo()            -- calling Spam::foo()
> a=example.Spam.bar            -- reading Spam::bar 
> example.Spam.bar=b            -- writing to Spam::bar

It is not (currently) possible to access static members of an instance:

> s=example.Spam()              -- s is a Spam instance
> s.foo()                       -- Spam::foo() via an instance
                                -- does NOT work

Compatibility Note: In versions prior to SWIG-3.0.0 only the following names would work:

> example.Spam_foo()            -- calling Spam::foo()
> a=example.Spam_bar            -- reading Spam::bar 
> example.Spam_bar=b            -- writing to Spam::bar

Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.

28.3.8 C++ inheritance

SWIG is fully aware of issues related to C++ inheritance. Therefore, if you have classes like this

class Foo {
...
};

class Bar : public Foo {
...
};

And if you have functions like this

void spam(Foo *f);

then the function spam() accepts a Foo pointer or a pointer to any class derived from Foo.

It is safe to use multiple inheritance with SWIG.

28.3.9 Pointers, references, values, and arrays

In C++, there are many different ways a function might receive and manipulate objects. For example:

void spam1(Foo *x);      // Pass by pointer
void spam2(Foo &x);      // Pass by reference
void spam3(Foo x);       // Pass by value
void spam4(Foo x[]);     // Array of objects

In SWIG, there is no detailed distinction like this--specifically, there are only "objects". There are no pointers, references, arrays, and so forth. Because of this, SWIG unifies all of these types together in the wrapper code. For instance, if you actually had the above functions, it is perfectly legal to do this:

> f = Foo()           -- Create a Foo
> spam1(f)            -- Ok. Pointer
> spam2(f)            -- Ok. Reference
> spam3(f)            -- Ok. Value.
> spam4(f)            -- Ok. Array (1 element)

Similar behaviour occurs for return values. For example, if you had functions like this,

Foo *spam5();
Foo &spam6();
Foo  spam7();

then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.

28.3.10 C++ overloaded functions

C++ overloaded functions, methods, and constructors are mostly supported by SWIG. For example, if you have two functions like this:

void foo(int);
void foo(char *c);

You can use them in Lua in a straightforward manner:

> foo(3)           -- foo(int)
> foo("Hello")     -- foo(char *c)

However due to Lua's coercion mechanism is can sometimes do strange things.

> foo("3")           -- "3" can be coerced into an int, so it calls foo(int)!

As this coercion mechanism is an integral part of Lua, there is no easy way to get around this other than renaming of functions (see below).

Similarly, if you have a class like this,

class Foo {
public:
    Foo();
    Foo(const Foo &);
    ...
};

you can write Lua code like this:

> f = Foo()          -- Create a Foo
> g = Foo(f)         -- Copy f

Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG can't disambiguate. For example:

void spam(int);
void spam(short);

or

VOID FOO(bAR *B);
void foo(Bar &b);

If declarations such as these appear, you will get a warning message like this:

example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).

To fix this, you either need to ignore or rename one of the methods. For example:

%rename(spam_short) spam(short);
...
void spam(int);
void spam(short);   // Accessed as spam_short

or

%ignore spam(short);
...
void spam(int);
void spam(short);   // Ignored

SWIG resolves overloaded functions and methods using a disambiguation scheme that ranks and sorts declarations according to a set of type-precedence rules. The order in which declarations appear in the input does not matter except in situations where ambiguity arises--in this case, the first declaration takes precedence.

Please refer to the "SWIG and C++" chapter for more information about overloading.

Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.

28.3.11 C++ operators

Certain C++ overloaded operators can be handled automatically by SWIG. For example, consider a class like this:

class Complex {
private:
  double rpart, ipart;
public:
  Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
  Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
  Complex &operator=(const Complex &c);
  Complex operator+(const Complex &c) const;
  Complex operator-(const Complex &c) const;
  Complex operator*(const Complex &c) const;
  Complex operator-() const;

  double re() const { return rpart; }
  double im() const { return ipart; }
};

When wrapped, it works like you expect:

> c = Complex(3,4)
> d = Complex(7,8)
> e = c + d
> e:re()
10.0
> e:im()
12.0

One restriction with operator overloading support is that SWIG is not able to fully handle operators that aren't defined as part of the class. For example, if you had code like this

class Complex {
...
friend Complex operator+(double, const Complex &c);
...
};

then SWIG doesn't know what to do with the friend function--in fact, it simply ignores it and issues a warning. You can still wrap the operator, but you may have to encapsulate it in a special function. For example:

%rename(Complex_add_dc) operator+(double, const Complex &);
...
Complex operator+(double, const Complex &c);

There are ways to make this operator appear as part of the class using the %extend directive. Keep reading.

Also, be aware that certain operators don't map cleanly to Lua, and some Lua operators don't map cleanly to C++ operators. For instance, overloaded assignment operators don't map to Lua semantics and will be ignored, and C++ doesn't support Lua's concatenation operator (.. ).

In order to keep maximum compatibility within the different languages in SWIG, the Lua bindings uses the same set of operator names as python. Although internally it renames the functions to something else (on order to work with Lua).

The current list of operators which can be overloaded (and the alternative function names) are:

  • __add__ operator+
  • __sub__ operator-
  • __mul__ operator *
  • __div__ operator/
  • __unm__ unary minus
  • __call__ operator() (often used in functor classes)
  • __pow__ the exponential fn (no C++ equivalent, Lua uses ^)
  • __concat__ the concatenation operator (Lua's ..)
  • __eq__ operator==
  • __lt__ operator<
  • __le__ operator<=

Note: in Lua, only the equals, less than, and less than equals operators are defined. The other operators (!=,>,>=) are achieved by using a logical not applied to the results of other operators.

The following operators cannot be overloaded (mainly because they are not supported in Lua)

  • ++ and --
  • +=,-=,*= etc
  • % operator (you have to use math.mod)
  • assignment operator
  • all bitwise/logical operations

SWIG also accepts the __str__() member function which converts an object to a string. This function should return a const char*, preferably to static memory. This will be used for the print() and tostring() functions in Lua. Assuming the complex class has a function

const char* __str__()
{
        static char buffer[255];
        sprintf(buffer,"Complex(%g,%g)",this->re(),this->im());
        return buffer;
}

Then this will support the following code in Lua

> c = Complex(3,4)
> d = Complex(7,8)
> e = c + d
> print(e)
Complex(10,12)
> s=tostring(e) -- s is the number in string form
> print(s)
Complex(10,12)

It is also possible to overload the operator[], but currently this cannot be automatically performed. To overload the operator[] you need to provide two functions, __getitem__() and __setitem__()

class Complex
{
        //....
        double __getitem__(int i)const; // i is the index, returns the data
        void __setitem__(int i,double d); // i is the index, d is the data
};

C++ operators are mapped to Lua predefined metafunctions. Class inherits from its bases the following list of metafunctions ( thus inheriting the folloging operators and pseudo-operators):

  • __add__
  • __sub__
  • __mul__
  • __div__
  • __unm__
  • __mod__
  • __call__
  • __pow__
  • __concat__
  • __eq__
  • __lt__
  • __le__
  • __len__
  • __getitem__
  • __setitem__
  • __tostring used internally by Lua for tostring() function. __str__ is mapped to this function

No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.

28.3.12 Class extension with %extend

One of the more interesting features of SWIG is that it can extend structures and classes with new methods. In the previous section, the Complex class would have benefited greatly from an __str__() method as well as some repairs to the operator overloading. It can also be used to add additional functions to the class if they are needed.

Take the original Complex class

class Complex {
private:
  double rpart, ipart;
public:
  Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
  Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
  Complex &operator=(const Complex &c);
  Complex operator+(const Complex &c) const;
  Complex operator-(const Complex &c) const;
  Complex operator*(const Complex &c) const;
  Complex operator-() const;

  double re() const { return rpart; }
  double im() const { return ipart; }
};

Now we extend it with some new code

%extend Complex {
   const char *__str__() {
       static char tmp[1024];
       sprintf(tmp,"Complex(%g,%g)", $self->re(),$self->im());
       return tmp;
   }
   bool operator==(const Complex& c)
   {    return ($self->re()==c.re() && $self->im()==c.im());}
};

Now, in Lua

> c = Complex(3,4)
> d = Complex(7,8)
> e = c + d
> print(e)      -- print uses __str__ to get the string form to print
Complex(10,12)
> print(e==Complex(10,12))      -- testing the == operator
true
> print(e!=Complex(12,12))  -- the != uses the == operator
true

Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).

28.3.13 Using %newobject to release memory

If you have a function that allocates memory like this,

char *foo() {
   char *result = (char *) malloc(...);
   ...
   return result;
}

then the SWIG generated wrappers will have a memory leak--the returned data will be copied into a string object and the old contents ignored.

To fix the memory leak, use the %newobject directive.

%newobject foo;
...
char *foo();

This will release the allocated memory.

28.3.14 C++ templates

C++ templates don't present a huge problem for SWIG. However, in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the template directive. For example:

%module example
%{
#include "pair.h"
%}

template<class T1, class T2>
struct pair {
   typedef T1 first_type;
   typedef T2 second_type;
   T1 first;
   T2 second;
   pair();
   pair(const T1&, const T2&);
  ~pair();
};

%template(pairii) pair<int,int>;

In Lua:

> p = example.pairii(3,4)
> print(p.first,p.second)
3    4

Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.

28.3.15 C++ Smart Pointers

In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

template<class T> class SmartPtr {
   ...
   T *operator->();
   ...
}

Then, if you have a class like this,

class Foo {
public:
     int x;
     int bar();
};

A smart pointer would be used in C++ as follows:

SmartPtr<Foo> p = CreateFoo();   // Created somehow (not shown)
...
p->x = 3;                        // Foo::x
int y = p->bar();                // Foo::bar

To wrap this, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using template if necessary. For example:

%module example
...
%template(SmartPtrFoo) SmartPtr<Foo>;
...

Now, in Lua, everything should just "work":

> p = example.CreateFoo()          -- Create a smart-pointer somehow
> p.x = 3                          -- Foo::x
> print(p:bar())                   -- Foo::bar

If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

> f = p:__deref__()     -- Returns underlying Foo *

28.3.16 C++ Exceptions

Lua does not natively support exceptions, but it has errors which are similar. When a Lua function terminates with an error it returns one value back to the caller. SWIG automatically maps any basic type which is thrown into a Lua error. Therefore for a function:

int message() throw(const char *) {
  throw("I died.");
  return 1;
}

SWIG will automatically convert this to a Lua error.

> message()
I died.
stack traceback:
        [C]: in function 'message'
        stdin:1: in main chunk
        [C]: ?
>

If you want to catch an exception, you must use either pcall() or xpcall(), which are documented in the Lua manual. Using xpcall will allow you to obtain additional debug information (such as a stacktrace).

> function a() b() end -- function a() calls function b()
> function b() message() end -- function b() calls C++ function message(), which throws 
> ok,res=pcall(a)  -- call the function
> print(ok,res)
false   I died.
> ok,res=xpcall(a,debug.traceback)  -- call the function
> print(ok,res)
false   I died.
stack traceback:
        [C]: in function 'message'
        runme.lua:70: in function 'b'
        runme.lua:67: in function <runme.lua:66>
        [C]: in function 'xpcall'
        runme.lua:95: in main chunk
        [C]: ?

SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. It has also written typemaps for std::exception and its derived classes, which convert the exception into an error string.

However it's not so simple to throw other types of objects. Thrown objects are not valid outside the 'catch' block. Therefore they cannot be returned to the interpreter. The obvious ways to overcome this would be to either return a copy of the object, or to convert the object to a string and return that. Though it seems obvious to perform the former, in some cases this is not possible, most notably when SWIG has no information about the object, or the object is not copyable/creatable.

Therefore by default SWIG converts all thrown object into strings and returns them. So given a function:

void throw_A() throw(A*) {
  throw new A();
}

SWIG will just convert it (poorly) to a string and use that as its error. (This is not that useful, but it always works).

> throw_A()
object exception:A *
stack traceback:
        [C]: in function 'unknown'
        stdin:1: in main chunk
        [C]: ?
>

To get a more useful behaviour out of SWIG you must either: provide a way to convert your exceptions into strings, or throw objects which can be copied.

If you have your own class which you want output as a string you will need to add a typemap something like this:

%typemap(throws) my_except
%{ 
  lua_pushstring(L,$1.what()); // assuming my_except::what() returns a const char* message
  SWIG_fail; // trigger the error handler
%}

If you wish your exception to be returned to the interpreter, it must firstly be copyable. Then you must have an additional %apply statement, to tell SWIG to return a copy of this object to the interpreter. For example:

%apply SWIGTYPE EXCEPTION_BY_VAL {Exc}; // tell SWIG to return Exc by value to interpreter

class Exc {
public:
  Exc(int c, const char *m) {
    code = c;
    strncpy(msg,m,256);
  }
  int code;
  char msg[256];
};

void throw_exc() throw(Exc) {
  throw(Exc(42,"Hosed"));
} 

Then the following code can be used (note: we use pcall to catch the error so we can process the exception).

> ok,res=pcall(throw_exc)
> print(ok)
false
> print(res)
userdata: 0003D880
> print(res.code,res.msg)
42      Hosed
>

Note: it is also possible (though tedious) to have a function throw several different kinds of exceptions. To process this will require a pcall, followed by a set of if statements checking the type of the error.

All of this code assumes that your C++ code uses exception specification (which a lot doesn't). If it doesn't consult the " Exception handling with %catches" section and the " Exception handling with %exception" section, for more details on how to add exception specification to functions or globally (respectively).

28.3.17 Namespaces

Since SWIG-3.0.0 C++ namespaces are supported via the %nspace feature.

Namespaces are mapped into Lua tables. Each of those tables contains names that were defined within appropriate namespace. Namespaces structure (a.k.a nested namespaces) is preserved. Consider the following C++ code:

%module example
%nspace MyWorld::Nested::Dweller;
%nspace MyWorld::World;

int module_function() { return 7; }
int module_variable = 9;

namespace MyWorld {
  class World {
  public:
    World() : world_max_count(9) {}
    int create_world() { return 17; }
    const int world_max_count; // = 9
  };
  namespace Nested {
    class Dweller {
      public:
        enum Gender { MALE = 0, FEMALE = 1 };
        static int count() { return 19; }
    };
  }
}

Now, from Lua usage is as follows:

> print(example.module_function())
7
> print(example.module_variable)
9
> print(example.MyWorld.World():create_world())
17
> print(example.MyWorld.World.world_max_count)
9
> print(example.MyWorld.Nested.Dweller.MALE)
0
> print(example.MyWorld.Nested.Dweller.count())
19
>

28.3.17.1 Compatibility Note

If SWIG is running in a backwards compatible way, i.e. without the -no-old-metatable-bindings option, then additional old-style names are generated (notice the underscore):

9
> print(example.MyWorld.Nested.Dweller_MALE)
0
> print(example.MyWorld.Nested.Dweller_count())
11
>

28.3.17.2 Names

If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries to generate additional names for static functions, class static constants and class enums. Those names are in a form $classname_$symbolname and are added to the scope surrounding the class. If %nspace is enabled, then class namespace is taken as scope. If there is no namespace, or %nspace is disabled, then module is considered a class namespace.

Consider the following C++ code

%module example
%nspace MyWorld::Test;
namespace MyWorld {
class Test {
  public:
  enum { TEST1 = 10, TEST2 }
  static const int ICONST = 12;
};
class Test2 {
  public:
  enum { TEST3 = 20, TEST4 }
  static const int ICONST2 = 23;
}

When in backward compatible mode, in addition to the usual names, the following ones will be generated (notice the underscore):

9
> print(example.MyWorld.Test_TEST1) -- Test has %nspace enabled
10
> print(example.MyWorld.Test_ICONST) -- Test has %nspace enabled
12
> print(example.Test2_TEST3) -- Test2 doesn't have %nspace enabled
20
> print(example.Test2_ICONST2) -- Test2 doesn't have %nspace enabled
23
>

There is a slight difference with enums when in C mode. As per C standard, enums from C structures are exported to surrounding scope without any prefixing. Pretending that Test2 is a struct, not class, that would be:

> print(example.TEST3) -- NOT Test2_TEST3
20
>

28.3.17.3 Inheritance

The internal organization of inheritance has changed. Consider the following C++ code:

%module example
class Base {
  public:
  int base_func()
};
class Derived : public Base {
  public:
  int derived_func()
}

Lets assume for a moment that class member functions are stored in .fn table. Previously, when classes were exported to Lua during module initialization, for every derived class all service tables ST(i.e. ".fn") were squashed and added to corresponding derived class ST: Everything from .fn table of class Base was copied to .fn table of class Derived and so on. This was a recursive procedure, so in the end the whole inheritance tree of derived class was squashed into derived class.

That means that any changes done to class Base after module initialization wouldn't affect class Derived:

base = example.Base()
der = example.Derived()
> print(base.base_func)
function: 0x1367940
> getmetatable(base)[".fn"].new_func = function (x) return x -- Adding new function to class Base (to class, not to an instance!)
> print(base.new_func) -- Checking this function
function
> print(der.new_func) -- Wouldn't work. Derived doesn't check Base any more.
nil
>

This behaviour was changed. Now unless -squash-bases option is provided, Derived store a list of it's bases and if some symbol is not found in it's own service tables then its bases are searched for it. Option -squash-bases will effectively return old behaviour.

> print(der.new_func) -- Now it works
function
>

28.4 Typemaps

This section explains what typemaps are and how to use them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect

28.4.1 What is a typemap?

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:

%module example

%typemap(in) int {
	$1 = (int) lua_tonumber(L,$input);
	printf("Received an integer : %d\n",$1);
}
%inline %{
extern int fact(int n);
%}

Note: you shouldn't use this typemap, as SWIG already has a typemap for this task. This is purely for example.

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input is the index on the Lua stack for the value to be used.

When this example is compiled into a Lua module, it operates as follows:

> require "example"
> print(example.fact(6))
Received an integer : 6
720

28.4.2 Using typemaps

There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.

However for more complex functions which use input/output parameters or arrays, you will need to make use of <typemaps.i>, which contains typemaps for these situations. For example, consider these functions:

void add(int x, int y, int *result) {
   *result = x + y;
}

int sub(int *x1, int *y1) {
   return *x1-*y1;
}

void swap(int *sx, int *sy) {
   int t=*sx;
   *sx=*sy;
   *sy=t;
}

It is clear to the programmer, that 'result' is an output parameter, 'x1' and 'y1' are input parameters and 'sx' and 'sy' are input/output parameters. However is not apparent to SWIG, so SWIG must to informed about which kind they are, so it can wrapper accordingly.

One means would be to rename the argument name to help SWIG, eg void add(int x, int y, int *OUTPUT), however it is easier to use the %apply to achieve the same result, as shown below.

%include <typemaps.i>
%apply int* OUTPUT {int *result}; // int *result is output
%apply int* INPUT {int *x1, int *y1}; // int *x1 and int *y1 are input
%apply int* INOUT {int *sx, int *sy}; // int *sx and int *sy are input and output

void add(int x, int y, int *result);
int sub(int *x1, int *y1);
void swap(int *sx, int *sy);

When wrapped, it gives the following results:

> require "example"
> print(example.add(1,2))
3
> print(demo.sub(1,2))
-1
> a,b=1,2
> c,d=demo.swap(a,b)
> print(a,b,c,d)
1       2       2       1

Notice, that 'result' is not required in the arguments to call the function, as it an output parameter only. For 'sx' and 'sy' they must be passed in (as they are input), but the original value is not modified (Lua does not have a pass by reference feature). The modified results are then returned as two return values. All INPUT/OUTPUT/INOUT arguments will behave in a similar manner.

Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a const int& as an input parameter (since that it obviously input).

28.4.3 Typemaps and arrays

Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor does SWIG have any indication of how large an array should be. However with the proper guidance SWIG can easily wrapper arrays for convenient usage.

Given the functions:

extern void sort_int(int* arr, int len);
extern void sort_double(double* arr, int len);

There are basically two ways that SWIG can deal with this. The first way, uses the <carrays.i> library to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but it's a bit tedious. More details can be found in the carrays.i documentation.

The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %apply in the correct manner.

The wrapper file below, shows both the use of carrays as well as the use of the typemap to wrap arrays.

// using the C-array
%include <carrays.i>
// this declares a batch of function for manipulating C integer arrays
%array_functions(int,int)

extern void sort_int(int* arr, int len); // the function to wrap

// using typemaps
%include <typemaps.i>
%apply (double *INOUT,int) {(double* arr,int len)};

extern void sort_double(double* arr, int len); // the function to wrap

Once wrapped, the functions can both be called, though with different ease of use:

require "example"
ARRAY_SIZE=10

-- passing a C array to the sort_int()
arr=example.new_int(ARRAY_SIZE) -- create the array
for i=0,ARRAY_SIZE-1 do -- index 0..9 (just like C)
    example.int_setitem(arr,i,math.random(1000))
end
example.sort_int(arr,ARRAY_SIZE)  -- call the function
example.delete_int(arr) -- must delete the allocated memory

-- use a typemap to call with a Lua-table
-- one item of note: the typemap creates a copy, rather than edit-in-place
t={} -- a Lua table
for i=1,ARRAY_SIZE do -- index 1..10 (Lua style)
    t[i]=math.random(1000)/10
end
t=example.sort_double(t) -- replace t with the result

Obviously the first version could be made less tedious by writing a Lua function to perform the conversion from a table to a C-array. The %luacode directive is good for this. See SWIG\Examples\lua\arrays for an example of this.

Warning: in C indexes start at ZERO, in Lua indexes start at ONE. SWIG expects C-arrays to be filled for 0..N-1 and Lua tables to be 1..N, (the indexing follows the norm for the language). In the typemap when it converts the table to an array it quietly changes the indexing accordingly. Take note of this behaviour if you have a C function which returns indexes.

Note: SWIG also can support arrays of pointers in a similar manner.

28.4.4 Typemaps and pointer-pointer functions

Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:

struct iMath;    // some structure
int Create_Math(iMath** pptr); // its creator (assume it mallocs)

Which would be used with the following C code:

iMath* ptr;
int ok;
ok=Create_Math(&ptr);
// do things with ptr
//...
free(ptr); // dispose of iMath

SWIG has a ready written typemap to deal with such a kind of function in <typemaps.i>. It provides the correct wrapping as well as setting the flag to inform Lua that the object in question should be garbage collected. Therefore the code is simply:

%include <typemaps.i>
%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG it's an output

struct iMath;    // some structure
int Create_Math(iMath** pptr); // its creator (assume it mallocs)

The usage is as follows:

ok,ptr=Create_Math() -- ptr is an iMath* which is returned with the int (ok)
ptr=nil -- the iMath* will be GC'ed as normal

28.5 Writing typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps " chapter.

Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrapping, or to achieve an effect which in not available with the default bindings.

Before proceeding, you should read the previous section on using typemaps, and look at the existing typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you an idea to base your work on).

28.5.1 Typemaps you can write

There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.

  • in this is for input arguments to functions
  • out this is for return types from functions
  • argout this is for a function argument which is actually returning something
  • typecheck this is used to determine which overloaded function should be called (the syntax for the typecheck is different from the typemap, see typemaps for details).

28.5.2 SWIG's Lua-C API

This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.

int SWIG_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags);

This is the standard function used for converting a Lua userdata to a void*. It takes the value at the given index in the Lua state and converts it to a userdata. It will then provide the necessary type checks, confirming that the pointer is compatible with the type given in 'type'. Then finally setting '*ptr' to the pointer. If flags is set to SWIG_POINTER_DISOWN, this is will clear any ownership flag set on the object.
The returns a value which can be checked with the macro SWIG_IsOK()

void SWIG_NewPointerObj(lua_State* L,void* ptr,swig_type_info *type,int own);

This is the opposite of SWIG_ConvertPtr, as it pushes a new userdata which wrappers the pointer 'ptr' of type 'type'. The parameter 'own' specifies if the object is owned be Lua and if it is 1 then Lua will GC the object when the userdata is disposed of.

void* SWIG_MustGetPtr(lua_State* L,int index,swig_type_info *type,int flags,int argnum,const char* func_name);

This function is a version of SWIG_ConvertPtr(), except that it will either work, or it will trigger a lua_error() with a text error message. This function is rarely used, and may be deprecated in the future.

SWIG_fail

This macro, when called within the context of a SWIG wrapped function, will jump to the error handler code. This will call any cleanup code (freeing any temp variables) and then triggers a lua_error.
A common use for this code is:
if (!SWIG_IsOK(SWIG_ConvertPtr( .....)){
 lua_pushstring(L,"something bad happened");
 SWIG_fail;
}

SWIG_fail_arg(char* func_name,int argnum,char* type)

This macro, when called within the context of a SWIG wrapped function, will display the error message and jump to the error handler code. The error message is of the form
"Error in func_name (arg argnum), expected 'type' got 'whatever the type was'"

SWIG_fail_ptr(const char* fn_name,int argnum,swig_type_info* type);

Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.

28.6 Customization of your Bindings

This section covers adding of some small extra bits to your module to add the last finishing touches.

28.6.1 Writing your own custom wrappers

Sometimes, it may be necessary to add your own special functions, which bypass the normal SWIG wrapper method, and just use the native Lua API calls. These 'native' functions allow direct adding of your own code into the module. This is performed with the %native directive as follows:

%native(my_func) int native_function(lua_State*L);  // registers native_function() with SWIG
...
%{
int native_function(lua_State*L) // my native code
{
 ...
}
%}

The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

28.6.2 Adding additional Lua code

As well as adding additional C/C++ code, it's also possible to add your own Lua code to the module as well. This code is executed once all other initialisation, including the %init code has been called.

The directive %luacode adds code into the module which is executed upon loading. Normally you would use this to add your own functions to the module. Though you could easily perform other tasks.

%module example;

%luacode {
  function example.greet() 
    print "hello world" 
  end

  print "Module loaded ok"
}
...
%}

Notice that the code is not part of the module table. Therefore any references to the module must have the module name added.

Should there be an error in the Lua code, this will not stop loading of the module. The default behaviour of SWIG is to print an error message to stderr and then continue. It is possible to change this behaviour by using a #define SWIG_DOSTRING_FAIL(STR) to define a different behaviour should the code fail.

Good uses for this feature is adding of new code, or writing helper functions to simplify some of the code. See Examples/lua/arrays for an example of this code.

28.7 Details on the Lua binding

In the previous section, a high-level view of Lua wrapping was presented. Obviously a lot of stuff happens behind the scenes to make this happen. This section will explain some of the low-level details on how this is achieved.

If you just want to use SWIG and don't care how it works, then stop reading here. This is going into the guts of the code and how it works. It's mainly for people who need to know what's going on within the code.

28.7.1 Binding global data into the module.

Assuming that you had some global data that you wanted to share between C and Lua. How does SWIG do it?

%module example;
extern double Foo;

SWIG will effectively generate the pair of functions

void Foo_set(double);
double Foo_get();

At initialisation time, it will then add to the interpreter a table called 'example', which represents the module. It will then add all its functions to the module. (Note: older versions of SWIG actually added the Foo_set() and Foo_get() functions, current implementation does not add these functions any more.) But it also adds a metatable to this table, which has two functions (__index and __newindex ) as well as two tables (.get and .set) The following Lua code will show these hidden features.

> print(example)
table: 003F8F90
> m=getmetatable(example)
> table.foreach(m,print)
.set    table: 003F9088
.get    table: 003F9038
__index function: 003F8FE0
__newindex      function: 003F8FF8
> g=m['.get']
> table.foreach(g,print)
Foo     function: 003FAFD8
>

The .get and .set tables are lookups connecting the variable name 'Foo' to the accessor/mutator functions (Foo_set,Foo_get)

The Lua equivalent of the code for the __index and __newindex looks a bit like this

function __index(mod,name)
        local g=getmetatable(mod)['.get'] -- gets the table
        if not g then return nil end
        local f=g[name] -- looks for the function
        -- calls it & returns the value
        if type(f)=="function" then return f() end
        return nil
end

function __newindex(mod,name,value)
        local s=getmetatable(mod)['.set'] -- gets the table
        if not s then return end
        local f=s[name] -- looks for the function
        -- calls it to set the value
        if type(f)=="function" then f(value)
        else rawset(mod,name,value) end
end

That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.

28.7.2 Userdata and Metatables

As mentioned earlier, classes and structures, are all held as pointer, using the Lua 'userdata' structure. This structure is actually a pointer to a C structure 'swig_lua_userdata', which contains the pointer to the data, a pointer to the swig_type_info (an internal SWIG struct) and a flag which marks if the object is to be disposed of when the interpreter no longer needs it. The actual accessing of the object is done via the metatable attached to this userdata.

The metatable is a Lua 5.0 feature (which is also why SWIG cannot wrap Lua 4.0). It's a table which holds a list of functions, operators and attributes. This is what gives the userdata the feeling that it is a real object and not just a hunk of memory.

Given a class

%module excpp;

class Point
{
public:
 int x,y;
 Point(){x=y=0;}
 ~Point(){}
 virtual void Print(){printf("Point @%p (%d,%d)\n",this,x,y);}
};

SWIG will create a module excpp, with all the various functions inside. However to allow the intuitive use of the userdata, SWIG also creates up a set of metatables. As seen in the above section on global variables, use of the metatables allows for wrappers to be used intuitively. To save effort, the code creates one metatable per class and stores it inside Lua's registry. Then when a new object is instantiated, the metatable is found in the registry and the userdata associated with the metatable. Currently, derived classes make a complete copy of the base class' table and then add on their own additional functions.

Some of the internals can be seen by looking at the metatable of a class:

> p=excpp.Point()
> print(p)
userdata: 003FDB28
> m=getmetatable(p)
> table.foreach(m,print)
.type   Point
__gc    function: 003FB6C8
__newindex      function: 003FB6B0
__index function: 003FB698
.get    table: 003FB4D8
.set    table: 003FB500
.fn     table: 003FB528

The '.type' attribute is the name of the class. The '.get' and '.set' tables work in a similar manner to the modules, the main difference is the '.fn' table which also holds all the member functions. (The '__gc' function is the class' destructor function)

The Lua equivalent of the code for enabling functions looks a little like this

function __index(obj,name)
        local m=getmetatable(obj) -- gets the metatable
        if not m then return nil end
        local g=m['.get'] -- gets the attribute table
        if not g then return nil end
        local f=g[name] -- looks for the get_attribute function
        -- calls it & returns the value
        if type(f)=="function" then return f() end
        -- ok, so it not an attribute, maybe it's a function
        local fn=m['.fn'] -- gets the function table
        if not fn then return nil end
        local f=fn[name] -- looks for the function
        -- if found the fn then return the function
        -- so the interpreter can call it
        if type(f)=="function" then return f end
        return nil
end

So when 'p:Print()' is called, the __index looks on the object metatable for a 'Print' attribute, then looks for a 'Print' function. When it finds the function, it returns the function, and then interpreter can call 'Point_Print(p)'

In theory, you can play with this usertable & add new features, but remember that it is a shared table between all instances of one class, and you could very easily corrupt the functions in all the instances.

Note: Both the opaque structures (like the FILE*) and normal wrapped classes/structs use the same 'swig_lua_userdata' structure. Though the opaque structures has do not have a metatable attached, or any information on how to dispose of them when the interpreter has finished with them.

Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.

28.7.3 Memory management

Lua is very helpful with the memory management. The 'swig_lua_userdata' is fully managed by the interpreter itself. This means that neither the C code nor the Lua code can damage it. Once a piece of userdata has no references to it, it is not instantly collected, but will be collected when Lua deems is necessary. (You can force collection by calling the Lua function collectgarbage() ). Once the userdata is about to be free'ed, the interpreter will check the userdata for a metatable and for a function '__gc'. If this exists this is called. For all complete types (ie normal wrapped classes & structs) this should exist. The '__gc' function will check the 'swig_lua_userdata' to check for the 'own' field and if this is true (which is will be for all owned data) it will then call the destructor on the pointer.

It is currently not recommended to edit this field or add some user code, to change the behaviour. Though for those who wish to try, here is where to look.

It is also currently not possible to change the ownership flag on the data (unlike most other scripting languages, Lua does not permit access to the data from within the interpreter).


29 SWIG and Modula-3

This chapter describes SWIG's support for Modula-3. You should be familiar with the basics of SWIG, especially typemaps.

29.1 Overview

Modula-3 is a compiled language in the tradition of Niklaus Wirth's Modula 2, which is in turn a successor to Pascal.

SWIG's Modula-3 support is currently very basic and highly experimental! Many features are still not designed satisfyingly and I need more discussion about the odds and ends. Don't rely on any feature, incompatible changes are likely in the future! However, the Modula-3 generator was already useful for interfacing to the libraries:

  1. PLPlot
  2. FFTW

29.1.1 Motivation

Although it is possible to write Modula-3 code that performs as well as C/C++ most existing libraries are not written in Modula-3 but in C or C++, and even libraries in other languages may provide C header files.

Fortunately Modula-3 can call C functions, but you have to write Modula-3 interfaces to them, and to make things comfortable you will also need wrappers that convert between high-level features of Modula-3 (garbage collecting, exceptions) and the explicit tracking of allocated memory and exception codes used by C APIs.

SWIG converts C headers to Modula-3 interfaces for you, and using typemaps you can pass TEXTs or open arrays, and convert error return codes into exceptions.

If the library API is ill designed writing appropriate typemaps can still be time-consuming. E.g. C programmers are very creative to work-around missing data types like (real) enumerations and sets. You should turn such work-arounds back to the Modula-3 way otherwise you lose static safety and consistency.

Without SWIG you would probably never consider trying to call C++ libraries from Modula-3, but with SWIG this is becomes feasible. SWIG can generate C wrappers to C++ functions and object methods that may throw exceptions, and then wrap these C wrappers for Modula-3. To make it complete you can then hide the C interface with Modula-3 classes and exceptions.

SWIG allows you to call C and C++ libraries from Modula-3 (even with call back functions), but it doesn't allow you to easily integrate a Modula-3 module into a C/C++ project.

29.2 Conception

29.2.1 Interfaces to C libraries

Modula-3 has integrated support for calling C functions. This is also extensively used by the standard Modula-3 libraries to call OS functions. The Modula-3 part of SWIG and the corresponding SWIG library modula3.swg contain code that uses these features. Because of the built-in support there is no need for calling the SWIG kernel to generate wrappers written in C. All conversion and argument checking can be done in Modula-3 and the interfacing is quite efficient. All you have to do is to write pieces of Modula-3 code that SWIG puts together.

C library support integrated in Modula-3
Pragma <* EXTERNAL *>Precedes a declaration of a PROCEDURE that is implemented in an external library instead of a Modula-3 module.
Pragma <* CALLBACK *>Precedes a declaration of a PROCEDURE that should be called by external library code.
Module CtypesContains Modula-3 types that match some basic C types.
Module M3toCContains routines that convert between Modula-3's TEXT type and C's char * type.

In each run of SWIG the Modula-3 part generates several files:

Module name schemeIdentifier for %insert Description
ModuleRaw.i3m3rawintf Declaration of types that are equivalent to those of the C library, EXTERNAL procedures as interface to the C library functions
ModuleRaw.m3m3rawimplAlmost empty.
Module.i3m3wrapintf Declaration of comfortable wrappers to the C library functions.
Module.m3m3wrapimpl Implementation of the wrappers that convert between Modula-3 and C types, check for validity of values, hand-over resource management to the garbage collector using WeakRefs and raises exceptions.
m3makefilem3makefileAdd the modules above to the Modula-3 project and specify the name of the Modula-3 wrapper library to be generated. Today I'm not sure if it is a good idea to create a m3makefile in each run, because SWIG must be started for each Modula-3 module it creates. Thus the m3makefile is overwritten each time. :-(

Here's a scheme of how the function calls to Modula-3 wrappers are redirected to C library functions:

Modula-3 wrapper
Module.i3
generated by Modula-3 part of SWIG
|
v
Modula-3 interface to C
ModuleRaw.i3
generated by Modula-3 part of SWIG
--> C library

I have still no good conception how one can split C library interfaces into type oriented interfaces. A Module in Modula-3 represents an Abstract DataType (or call it a static classes, i.e. a class without virtual methods). E.g. if you have a principal type, say Database, it is good Modula-3 style to set up one Module with the name Database where the database type is declared with the name T and where all functions are declared that operates on it.

The normal operation of SWIG is to generate a fixed set of files per call. To generate multiple modules one has to write one SWIG interface (different SWIG interfaces can share common data) per module. Identifiers belonging to a different module may ignored (%ignore ) and the principal type must be renamed (%typemap).

29.2.2 Interfaces to C++ libraries

Interfaces to C++ files are much more complicated and there are some more design decisions that are not made, yet. Modula-3 has no support for C++ functions but C++ compilers should support generating C++ functions with a C interface.

Here's a scheme of how the function calls to Modula-3 wrappers are redirected to C library functions:

Modula-3 wrapper
Module.i3
generated by Modula-3 part of SWIG
C++ library
|
v
^
|
Modula-3 interface to C
ModuleRaw.i3
generated by Modula-3 part of SWIG
--> C interface to C++
module_wrap.cxx
generated by the SWIG core

Wrapping C++ libraries arises additional problems:

  • Is it sensible to wrap C++ classes with Modula-3 classes?
  • How to find the wrapping Modula-3 class for a class pointer that is returned by a C++ routine?
  • How to deal with multiple inheritance which was neglected for Modula-3 for good reasons?
  • Is it possible to sub-class C++ classes with Modula-3 code? This issue is addressed by directors, a feature that was experimentally added to some Language modules like Java and Python.
  • How to manage storage with the garbage collector of Modula-3? Support for %newobject and %typemap(newfree) isn't implemented, yet. What's about resources that are managed by the garbage collector but shall be passed back to the storage management of the C++ library? This is a general issue which is not solved in a satisfying fashion as far as I know.
  • How to turn C++ exceptions into Modula-3 exceptions? There's also no support for %exception , yet.

Be warned: There is no C++ library I wrote a SWIG interface for, so I'm not sure if this is possible or sensible, yet.

29.3 Preliminaries

29.3.1 Compilers

There are different Modula-3 compilers around: cm3, pm3, ezm3, Klagenfurth Modula-3, Cambridge Modula-3. SWIG itself does not contain compiler specific code but the modula3.swg library file may do so. For testing examples I use Critical Mass cm3.

29.3.2 Additional Commandline Options

There are some experimental command line options that prevent SWIG from generating interface files. Instead files are emitted that may assist you when writing SWIG interface files.

Modula-3 specific optionsDescription
-generateconst <file> Disable generation of interfaces and wrappers. Instead write code for computing numeric values of constants to the specified file.
C code may contain several constant definitions written as preprocessor macros. Other language modules of SWIG use compute-once-use-readonly variables or functions to wrap such definitions. All of them can invoke C code dynamically for computing the macro values. But if one wants to turn them into Modula-3 integer constants, enumerations or set types, the values of these expressions has to be known statically. Although definitions like (1 << FLAG_MAXIMIZEWINDOW) must be considered as good C style they are hard to convert to Modula-3 since the value computation can use every feature of C.
Thus I implemented these switch to extract all constant definitions and write a C program that output the values of them. It works for numeric constants only and treats all of them as double. Future versions may generate a C++ program that can detect the type of the macros by overloaded output functions. Then strings can also be processed.
-generaterename <file> Disable generation of interfaces and wrappers. Instead generate suggestions for %rename.
C libraries use a naming style that is neither homogeneous nor similar to that of Modula-3. C function names often contain a prefix denoting the library and some name components separated by underscores or capitalization changes. To get library interfaces that are really Modula-3 like you should rename the function names with the %rename directive. This switch outputs a list of such directives with a name suggestion generated by a simple heuristic.
-generatetypemap <file> Disable generation of interfaces and wrappers. Instead generate templates for some basic typemaps.

29.4 Modula-3 typemaps

29.4.1 Inputs and outputs

Each C procedure has a bunch of inputs and outputs. Inputs are passed as function arguments, outputs are updated referential arguments and the function value.

Each C type can have several typemaps that apply only in case if a type is used for an input argument, for an output argument, or for a return value. A further typemap may specify the direction that is used for certain parameters. I have chosen this separation in order to be able to write general typemaps for the modula3.swg typemap library. In the library code the final usage of the type is not known. Using separate typemaps for each possible use allows appropriate definitions for each case. If these pre-definitions are fine then the direction of the function parameter is the only hint the user must give.

The typemaps specific to Modula-3 have a common name scheme: A typemap name starts with "m3", followed by "raw" or "wrap" depending on whether it controls the generation of the ModuleRaw.i3 or the Module.i3, respectively. It follows an "in" for typemaps applied to input argument, "out" for output arguments, "arg" for all kind of arguments, "ret" for returned values.

The main task of SWIG is to build wrapper function, i.e. functions that convert values between C and Modula-3 and call the corresponding C function. Modula-3 wrapper functions generated by SWIG consist of the following parts:

  • Generate PROCEDURE signature.
  • Declare local variables.
  • Convert input values from Modula-3 to C.
  • Check for input value integrity.
  • Call the C function.
  • Check returned values, e.g. error codes.
  • Convert and write back values into Modula-3 records.
  • Free temporary storage.
  • Return values.
TypemapExampleDescription
m3wrapargvar$1: INTEGER := $1_name; Declaration of some variables needed for temporary results.
m3wrapargconst$1 = "$1_name"; Declaration of some constant, maybe for debug purposes.
m3wrapargrawORD($1_name) The expression that should be passed as argument to the raw Modula-3 interface function.
m3wrapargdirout Referential arguments can be used for input, output, update. ???
m3wrapinmodeREADONLY One of Modula-3 parameter modes VALUE (or empty), VAR, READONLY
m3wrapinname New name of the input argument.
m3wrapintype Modula-3 type of the input argument.
m3wrapindefault Default value of the input argument
m3wrapinconv$1 := M3toC.SharedTtoS($1_name); Statement for converting the Modula-3 input value to C compliant value.
m3wrapincheckIF Text.Length($1_name) > 10 THEN RAISE E("str too long"); END; Check the integrity of the input value.
m3wrapoutname Name of the RECORD field to be used for returning multiple values. This applies to referential output arguments that shall be turned into return values.
m3wrapouttype Type of the value that is returned instead of a referential output argument.
m3wrapoutconv
m3wrapoutcheck
m3wrapretraw
m3wrapretname
m3wraprettype
m3wrapretvar
m3wrapretconv
m3wrapretcheck
m3wrapfreeargM3toC.FreeSharedS(str,arg1); Free resources that were temporarily used in the wrapper. Since this step should never be skipped, SWIG will put it in the FINALLY branch of a TRY .. FINALLY structure.

29.4.2 Subranges, Enumerations, Sets

Subranges, enumerations, and sets are machine oriented types that make Modula very strong and expressive compared with the type systems of many other languages.

  • Subranges are used for statically restricted choices of integers.
  • Enumerations are used for named choices.
  • Sets are commonly used for flag (option) sets.

Using them extensively makes Modula code very safe and readable.

C supports enumerations, too, but they are not as safe as the ones of Modula. Thus they are abused for many things: For named choices, for integer constant definitions, for sets. To make it complete every way of defining a value in C (#define, const int, enum) is somewhere used for defining something that must be handled completely different in Modula-3 (INTEGER, enumeration, SET).

I played around with several %features and %pragma s that split the task up into converting the C bit patterns (integer or bit set) into Modula-3 bit patterns (integer or bit set) and change the type as requested. See the corresponding example in the Examples/modula3/enum/example.i file. This is quite messy and not satisfying. So the best what you can currently do is to rewrite constant definitions manually. Though this is a tedious work that I'd like to automate.

29.4.3 Objects

Declarations of C++ classes are mapped to OBJECT types while it is tried to retain the access hierarchy "public - protected - private" using partial revelation. Though the example in Examples/modula3/class/example.i is not really useful, yet.

29.4.4 Imports

Pieces of Modula-3 code provided by typemaps may contain identifiers from foreign modules. If the typemap m3wrapinconv for blah * contains code using the function M3toC.SharedTtoS you may declare %typemap("m3wrapinconv:import") blah * %{M3toC%}. Then the module M3toC is imported if the m3wrapinconv typemap for blah * is used at least once. Use %typemap("m3wrapinconv:import") blah * %{MyConversions AS M3toC%} if you need module renaming. Unqualified import is not supported.

It is cumbersome to add this typemap to each piece of Modula-3 code. It is especially useful when writing general typemaps for the modula3.swg typemap library. For a monolithic module you might be better off if you add the imports directly:

%insert(m3rawintf) %{
IMPORT M3toC;
%}

29.4.5 Exceptions

Modula-3 provides another possibility of an output of a function: exceptions.

Any piece of Modula-3 code that SWIG inserts due to a typemap can raise an exception. This way you can also convert an error code from a C function into a Modula-3 exception.

The RAISES clause is controlled by typemaps with the throws extension. If the typemap m3wrapinconv for blah * contains code that may raise the exceptions OSError.E you should declare %typemap("m3wrapinconv:throws") blah * %{OSError.E%}.

29.4.6 Example

The generation of wrappers in Modula-3 needs very fine control to take advantage of the language features. Here is an example of a generated wrapper where almost everything is generated by a typemap:

         (* %relabel  m3wrapinmode m3wrapinname m3wrapintype  m3wrapindefault *)
  PROCEDURE Name     (READONLY       str       :    TEXT    :=      ""       )
              (* m3wrapoutcheck:throws *)
     : NameResult RAISES {E} =
    CONST
      arg1name = "str";                  (* m3wrapargconst *)
    VAR
      arg0   : C.char_star;              (* m3wrapretvar *)
      arg1   : C.char_star;              (* m3wrapargvar *)
      arg2   : C.int;
      result : RECORD
           (*m3wrapretname  m3wraprettype*)
                 unixPath : TEXT;
           (*m3wrapoutname  m3wrapouttype*)
                 checksum : CARDINAL;
               END;
    BEGIN
      TRY
        arg1 := M3toC.SharedTtoS(str);   (* m3wrapinconv *)
        IF Text.Length(arg1) > 10 THEN   (* m3wrapincheck *)
          RAISE E("str too long");
        END;
 (* m3wrapretraw           m3wrapargraw *)
        arg0 := MessyToUnix  (arg1,   arg2);
        result.unixPath := M3toC.CopyStoT(arg0);  (* m3wrapretconv *)
        result.checksum := arg2;         (* m3wrapoutconv *)
        IF result.checksum = 0 THEN      (* m3wrapoutcheck *)
          RAISE E("invalid checksum");
        END;
      FINALLY
        M3toC.FreeSharedS(str,arg1);     (* m3wrapfreearg *)
      END;
    END Name;

29.5 More hints to the generator

29.5.1 Features

FeatureExampleDescription
multiretval%m3multiretval get_box; or %feature("modula3:multiretval") get_box;Let the denoted function return a RECORD rather than a plain value. This RECORD contains all arguments with "out" direction including the return value of the C function (if there is one). If more than one argument is "out" then the function must have the multiretval feature activated, but it is explicitly requested from the user to prevent mistakes.
constnumeric%constnumeric(12) twelve; or %feature("constnumeric","12") twelve;This feature can be used to tell Modula-3's back-end of SWIG the value of an identifier. This is necessary in the cases where it was defined by a non-trivial C expression. This feature is used by the -generateconst option. In future it may be generalized to other kind of values such as strings.

29.5.2 Pragmas

PragmaExampleDescription
unsafe%pragma(modula3) unsafe="true"; Mark the raw interface modules as UNSAFE. This will be necessary in many cases.
library%pragma(modula3) library="m3fftw"; Specifies the library name for the wrapper library to be created. It should be distinct from the name of the library to be wrapped.

29.6 Remarks

  • The Modula-3 part of SWIG doesn't try to generate nicely formatted code. If you need to read the generated code, use m3pp to postprocess the Modula files.

30 SWIG and MzScheme/Racket

This section contains information on SWIG's support of Racket, formally known as MzScheme.

30.1 Creating native structures

Example interface file:

/* define a macro for the struct creation */
%define handle_ptr(TYPE,NAME)
%typemap(argout) TYPE *NAME{
    Scheme_Object *o = SWIG_NewStructFromPtr($1, $*1_mangle);
    SWIG_APPEND_VALUE(o);
}

%typemap(in,numinputs=0) TYPE *NAME (TYPE temp) {
    $1 = &temp;
}
%enddef

/* setup the typemaps for the pointer to an output parameter cntrs */
handle_ptr(struct diag_cntrs, cntrs);

Then in scheme, you can use regular struct access procedures like

	; suppose a function created a struct foo as 
	; (define foo (make-diag-cntrs (#x1 #x2 #x3) (make-inspector))
	; Then you can do
	(format "0x~x" (diag-cntrs-field1 foo))
	(format "0x~x" (diag-cntrs-field2 foo))
	;etc...

30.2 Simple example

A few examples are available in the Examples/mzscheme directory. The code and log of a session using SWIG below should help getting started.

C header file:

// example.h
int fact(int n);

C source code:

// File: example.c
#include "example.h"

int fact(int n) {
  if (n < 0) { /* This should probably return an error, but this is simpler */
    return 0;
  }
  if (n == 0) {
    return 1;
  }
  else {
    /* testing for overflow would be a good idea here */
    return n * fact(n-1);
  }
}

SWIG interface file:

/* File: example.i */
%module example

%{
#include "example.h"
%}

int fact(int n);

The session below using the above files is on an OS X machine, but the points to be made are more general. On OS X, libtool is the tool which creates libraries, which are named .dylib, rather than .so on other unixes, or .dll on Windows.

% swig -mzscheme -declaremodule example.i
% gcc -c -m32 -o example.o example.c # force 32-bit object file (mzscheme is 32-bit only)
% libtool -dynamic -o libexample.dylib example.o # make it into a library
% ls # what've we got so far?
example.c example.o
example.h example_wrap.c
example.i libexample.dylib*
% mzc --cgc --cc example_wrap.c # compile the wrapping code
% LDFLAGS="-L. -lexample" mzc --ld example_wrap.dylib example_wrap.o # ...and link it
% mzscheme -e '(path->string (build-path "compiled" "native" (system-library-subpath)))'
"compiled/native/i386-macosx/3m"
% mkdir -p compiled/native/i386-macosx/3m # move the extension library to a magic place
% mv example_wrap.dylib compiled/native/i386-macosx/3m/example_ss.dylib
% mzscheme
Welcome to MzScheme v4.2.4 [3m], Copyright (c) 2004-2010 PLT Scheme Inc.
> (require "example.ss")
> (fact 5)
120
> ^D
% echo 'It works!'

Some points of interest:

  • This is on a 64-bit machine, so we have to include the -m32 option when building the object file
  • If you want to declare a scheme module (and you probably do), it's important that you include the -declaremodule option to swig (if you miss this out, it'll appear to work, but fail later).
  • Use mzc to compile and then link the wrapped code. You'll probably need to adjust the link flags to refer to the library you're wrapping (you can either do this with an LDFLAGS declaration, as here, or with multiple ++ldf options to mzc).
  • Create the directory with path (build-path "compiled" "native" (system-library-subpath)) and move the freshly-generated .dylib to there, changing its name to module-name_ss.dylib. After that, you can REQUIRE the new module with (require "module-name.ss").
  • The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.

30.3 External documentation

See the C API for more description of using the mechanism for adding extensions. The main documentation is here.

Tip: mzc's --vv option is very useful for debugging the inevitable library problems you'll encounter.


31 SWIG and Ocaml

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.

If you're not familiar with the Objective Caml language, you can visit The Ocaml Website.

31.1 Preliminaries

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 make check 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 Dl package . 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.

31.1.1 Running SWIG

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 -ocaml option.

%swig -ocaml example.i
  

This will produce 3 files. The file example_wrap.c contains all of the C code needed to build an Ocaml module. To build the module, you will compile the file example_wrap.c with ocamlc or ocamlopt 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).

31.1.2 Compiling the code

The OCaml SWIG module now requires you to compile a module (Swig ) 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 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 ocamlc or ocamlopt to compile your SWIG interface like:

% 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
  

ocamlc 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:

% cp example_wrap.cxx example_wrap.cxx.c

% ocamlc -c ... -ccopt -xc++ example_wrap.cxx.c
% ...

31.1.3 The camlp4 module

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 "swig -ocaml -co swigp4.ml". You should compile the file with "ocamlc -I `camlp4 -where` -pp 'camlp4o pa_extend.cmo q_MLast.cmo' -c swigp4.ml"

The basic principle of the module is to recognize certain non-caml expressions and convert them for use with C++ code as interfaced by SWIG. The camlp4 module is written to work with generated SWIG interfaces, and probably isn't great to use with anything else.

Here are the main rewriting rules:

InputRewritten to
f'( ... ) as in
atoi'("0") or
_exit'(0)
f(C_list [ ... ]) as in
atoi (C_list [ C_string "0" ]) or
_exit (C_list [ C_int 0 ])
object -> method ( ... )(invoke object) "method" (C_list [ ... ])
object 'binop argument as in
a '+= b
(invoke object) "+=" argument as in
(invoke a) "+=" b
Note that because camlp4 always recognizes << and >>, they are replaced by lsl and lsr in operator names.
'unop object as in
'! a
(invoke a) "!" C_void
Smart pointer access like this
object '-> method ( args )
(invoke (invoke object "->" C_void))
Invoke syntax
object . '( ... )
(invoke object) "()" (C_list [ ... ])
Array syntax
object '[ 10 ]
(invoke object) "[]" (C_int 10)
Assignment syntax
let a = '10 and b = '"foo" and c = '1.0 and d = 'true
let a = C_int 10 and b = C_string "foo" and c = C_double 1.0 and d = C_bool true
Cast syntax
let a = _atoi '("2") as int
let b = (getenv "PATH") to string
This works for int, string, float, bool
let a = get_int (_atoi (C_string "2"))
let b = C_string (getenv "PATH")

31.1.4 Using your module

You can test-drive your module by building a toplevel ocaml interpreter. Consult the ocaml manual for details.

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.

31.1.5 Compilation problems and compiling with C++

As mentioned above, .cxx files need special handling to be compiled with ocamlc. Other than that, C code that uses class as a non-keyword, and C code that is too liberal with pointer types may not compile under the C++ compiler. Most code meant to be compiled as C++ will not have problems.

31.2 The low-level Ocaml/C interface

In order to provide access to overloaded functions, and provide sensible outputs from them, all C entities are represented as members of the c_obj type:

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.

type c_obj =
    C_void
  | C_bool of bool
  | C_char of char
  | C_uchar of char
  | C_short of int
  | C_ushort of int
  | C_int of int
  | C_uint of int32
  | C_int32 of int32
  | C_int64 of int64
  | C_float of float
  | C_double of float
  | C_ptr of int64 * int64
  | C_array of c_obj array
  | C_list of c_obj list
  | C_obj of (string -> c_obj -> c_obj)
  | C_string of string
  | C_enum of c_enum_t

A few functions exist which generate and return these:

  • caml_ptr_val receives a c_obj and returns a void *.  This should be used for all pointer purposes.
  • caml_long_val receives a c_obj and returns a long.  This should be used for most integral purposes.
  • caml_val_ptr receives a void * and returns a c_obj.
  • caml_val_bool receives a C int and returns a c_obj representing its bool value.
  • caml_val_(u)?(char|short|int|long|float|double) receives an appropriate C value and returns a c_obj representing it.
  • caml_val_string receives a char * and returns a string value.
  • caml_val_string_len receives a char * and a length and returns a string value.
  • caml_val_obj receives a void * and an object type and returns a C_obj, which contains a closure giving method access.

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).

 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.

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.

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.

31.2.1 The generated module

The SWIG %module directive specifies the name of the Ocaml module to be generated. If you specified `%module example', then your Ocaml code will be accessible in the module Example. The module name is always capitalized as is the ocaml convention. Note that you must not use any Ocaml keyword to name your module. Remember 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:

"header"This code is inserted near the beginning of the C wrapper file, before any function definitions.
"wrapper"This code is inserted in the function definition section.
"runtime"This code is inserted near the end of the C wrapper file.
"mli"This code is inserted into the caml interface file. Special signatures should be inserted here.
"ml"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.
"classtemplate"The "classtemplate" place is special because it describes the output SWIG will generate for class definitions.

31.2.2 Enums

SWIG will wrap enumerations as polymorphic variants in the output 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 enum_to_int and int_to_enum functions take an enum type label as an argument. Example:

%module enum_test
%{
enum c_enum_type { a = 1, b, c = 4, d = 8 };
%}
enum c_enum_type { a = 1, b, c = 4, d = 8 };

The output mli contains:

type c_enum_type = [
  `unknown
| `c_enum_type
]
type c_enum_tag = [
  `int of int
| `a
| `b
| `c
| `d
]
val int_to_enum c_enum_type -> int -> c_obj
val enum_to_int c_enum_type -> c_obj -> c_obj

So it's possible to do this:

bash-2.05a$ ocamlmktop -custom enum_test_wrap.o enum_test.cmo -o enum_test_top
bash-2.05a$ ./enum_test_top 
        Objective Caml version 3.04

# open Enum_test ;;
# let x = C_enum `a ;;
val x : Enum_test.c_obj = C_enum `a
# enum_to_int `c_enum_type x ;;
- : Enum_test.c_obj = C_int 1
# int_to_enum `c_enum_type 4 ;;
- : Enum_test.c_obj = C_enum `c

31.2.2.1 Enum typing in Ocaml

The ocaml SWIG module now has support for loading and using multiple SWIG modules at the same time. This enhances modularity, but presents problems when used with a language which assumes that each module's types are complete at compile time. In order to achieve total soundness enum types are now isolated per-module. The type issue matters when values are shared between functions imported from different modules. You must convert values to master values using the swig_val function before sharing them with another module.

31.2.3 Arrays

31.2.3.1 Simple types of bounded arrays

SWIG has support for array types, but you generally will need to provide a typemap to handle them. You can currently roll your own, or expand some of the macros provided (but not included by default) with the SWIG distribution.

By including "carray.i", you will get access to some macros that help you create typemaps for array types fairly easily.

%make_simple_array_typemap is the easiest way to get access to arrays of simple types with known bounds in your code, but this only works for arrays whose bounds are completely specified.

31.2.3.2 Complex and unbounded arrays

Unfortunately, unbounded arrays and pointers can't be handled in a completely general way by SWIG, because the end-condition of such an array can't be predicted. In some cases, it will be by consent (e.g. an array of four or more chars), sometimes by explicit length (char *buffer, int len), and sometimes by sentinel value (0,-1,etc.). SWIG can't predict which of these methods will be used in the array, so you have to specify it for yourself in the form of a typemap.

31.2.3.3 Using an object

It's possible to use C++ to your advantage by creating a simple object that provides access to your array. This may be more desirable in some cases, since the object can provide bounds checking, etc., that prevents crashes.

Consider writing an object when the ending condition of your array is complex, such as using a required sentinel, etc.

31.2.3.4 Example typemap for a function taking float * and int

This is a simple example in typemap for an array of float, where the length of the array is specified as an extra parameter. Other such typemaps will work similarly. In the example, the function printfloats is called with a float array, and specified length. The actual length reported in the len argument is the length of the array passed from ocaml, making passing an array into this type of function convenient.

tarray.i
%module tarray
%{
#include <stdio.h>

void printfloats( float *tab, int len ) {
	int i;

	for( i = 0; i < len; i++ ) {
		printf( "%f ", tab[i] );
	}

	printf( "\n" );  
}
%}

%typemap(in) (float *tab, int len) {
    int i;
    /* $*1_type */
    $2 = caml_array_len($input);
    $1 = ($*1_type *)malloc( $2 * sizeof( float ) );
    for( i = 0; i < $2; i++ ) {
        $1[i] = caml_double_val(caml_array_nth($input,i));
    }
}

void printfloats( float *tab, int len );
Sample Run
# open Tarray ;;
# _printfloats (C_array [| C_double 1.0 ; C_double 3.0 ; C_double 5.6666 |]) ;;
1.000000 3.000000 5.666600
- : Tarray.c_obj = C_void

31.2.4 C++ Classes

C++ classes, along with structs and unions are represented by C_obj (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 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 to any other operators an object might have, certain builtin ones are provided by SWIG: (all of these take no arguments (C_void))

"~"Delete this object
"&"Return an ordinary C_ptr value representing this object's address
"sizeof"If enabled with ("sizeof"="1") on the module node, return the object's size in char.
":methods"Returns a list of strings containing the names of the methods this object contains
":classof"Returns the name of the class this object belongs to.
":parents"Returns a list of all direct parent classes which have been wrapped by SWIG.
"::[parent-class]"Returns a view of the object as the indicated parent class. This is mainly used internally by the SWIG module, but may be useful to client programs.
"[member-variable]"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 argument. With zero arguments, the value is returned.

Note that this string belongs to the wrapper object, and not the underlying pointer, so using create_[x]_from_ptr alters the returned value for the same object.

31.2.4.1 STL vector and string Example

Standard typemaps are now provided for STL vector and string. More are in the works. STL strings are passed just like normal strings, and returned as strings. STL string references don't mutate the original string, (which might be surprising), because Ocaml strings are mutable but have fixed length. Instead, use multiple returns, as in the argout_ref example.

example.i
%module example
%{
#include "example.h"
%}

%include <stl.i>

namespace std {
        %template(StringVector) std::vector < string >;
};

%include "example.h"
This example is in Examples/ocaml/stl

Since there's a makefile in that directory, the example is easy to build.

Here's a sample transcript of an interactive session using a string vector after making a toplevel (make toplevel). This example uses the camlp4 module.

bash-2.05a$ ./example_top 
        Objective Caml version 3.06

        Camlp4 Parsing version 3.06

# open Swig ;;
# open Example ;;
# let x = new_StringVector '() ;;
val x : Example.c_obj = C_obj <fun>
# x -> ":methods" () ;;
- : Example.c_obj =
C_list
 [C_string "nop"; C_string "size"; C_string "empty"; C_string "clear";
  C_string "push_back"; C_string "[]"; C_string "="; C_string "set";
  C_string "~"; C_string "&"; C_string ":parents"; C_string ":classof";
  C_string ":methods"]
# x -> push_back ("foo") ;;
- : Example.c_obj = C_void
# x -> push_back ("bar") ;;
- : Example.c_obj = C_void
# x -> push_back ("baz") ;;
- : Example.c_obj = C_void
# x '[1] ;;
- : Example.c_obj = C_string "bar"
# x -> set (1,"spam") ;;
- : 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) 
  done ;;
foo
bar
baz
- : unit = ()
# 

31.2.4.2 C++ Class Example

Here's a simple example using Trolltech's Qt Library:

qt.i
%module qt
%{
#include <qapplication.h>
#include <qpushbutton.h>
%}
class QApplication {
public:
        QApplication( int argc, char **argv );
        void setMainWidget( QWidget *widget );
        void exec();
};

class QPushButton {
public:
        QPushButton( char *str, QWidget *w );
        void resize( int x, int y );
        void show();
};

31.2.4.3 Compiling the example

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` \
  camlp4o.cma swigp4.cmo qt_wrap.o qt.cmo -o qt_top -cclib \
  -L$QTPATH/lib -cclib -lqt

31.2.4.4 Sample Session

bash-2.05a$ ./qt_top 
        Objective Caml version 3.06

        Camlp4 Parsing version 3.06

# open Swig ;;
# open Qt ;;
# let a = new_QApplication '(0,0) ;;
val a : Qt.c_obj = C_obj <fun>
# let hello = new_QPushButton '("hi",0) ;;
val hello : Qt.c_obj = C_obj <fun>
# hello -> resize (100,30) ;;
- : Qt.c_obj = C_void
# hello -> show () ;;
- : Qt.c_obj = C_void
# a -> exec () ;;

Assuming you have a working installation of QT, you will see a window containing the string "hi" in a button.

31.2.5 Director Classes

31.2.5.1 Director Introduction

Director classes are classes which allow Ocaml code to override the public methods of a C++ object. This facility allows the user to use C++ libraries that require a derived class to provide application specific functionality in the context of an application or utility framework.

You can turn on director classes by using an optional module argument like this:

%module(directors="1")

...

// Turn on the director class for a specific class like this:
%feature("director")
class foo {
  ...
};

31.2.5.2 Overriding Methods in Ocaml

Because the Ocaml language module treats C++ method calls as calls to a certain function, all you need to do is to define the function that will handle the method calls in terms of the public methods of the object, and any other relevant information. The function new_derived_object uses a stub class to call your methods in place of the ones provided by the underlying implementation. The object you receive is the underlying object, so you are free to call any methods you want from within your derived method. Note that calls to the underlying object do not invoke Ocaml code. You need to handle that yourself.

new_derived_object receives your function, the function that creates the underlying object, and any constructor arguments, and provides an object that you can use in any usual way. When C++ code calls one of the object's methods, the object invokes the Ocaml function as if it had been invoked from Ocaml, allowing any method definitions to override the C++ ones.

In this example, I'll examine the objective caml code involved in providing an overloaded class. This example is contained in Examples/ocaml/shapes.

31.2.5.3 Director Usage Example

example_prog.ml
open Swig
open Example

...

let triangle_class pts ob meth args =
  match meth with
      "cover" ->
        (match args with
             C_list [ x_arg ; y_arg ] ->
	     let xa = x_arg as float
	     and ya = y_arg as float in
	       (point_in_triangle pts xa ya) to bool
           | _ -> raise (Failure "cover needs two double arguments."))
    | _ -> (invoke ob) meth args ;;

let triangle =
  new_derived_object 
    new_shape
    (triangle_class ((0.0,0.0),(0.5,1.0),(1.0,0.0)))
    '() ;;

let _ = _draw_shape_coverage '(triangle, C_int 60, C_int 20) ;;

This is the meat of what you need to do. The actual "class" definition containing the overloaded method is defined in the function triangle_class. This is a lot like the class definitions emitted by SWIG, if you look at example.ml, which is generated when SWIG consumes example.i. Basically, you are given the arguments as a c_obj and the method name as a string, and you must intercept the method you are interested in and provide whatever return value you need. Bear in mind that the underlying C++ code needs the right return type, or an exception will be thrown. This exception will generally be Failure, or NotObject. You must call other ocaml methods that you rely on yourself. Due to the way directors are implemented, method calls on your object from with ocaml code will always invoke C++ methods even if they are overridden in ocaml.

In the example, the draw_shape_coverage function plots the indicated number of points as either covered (x) or uncovered ( ) between 0 and 1 on the X and Y axes. Your shape implementation can provide any coverage map it likes, as long as it responds to the "cover" method call with a boolean return (the underlying method returns bool). This might allow a tricky shape implementation, such as a boolean combination, to be expressed in a more effortless style in ocaml, while leaving the "engine" part of the program in C++.

31.2.5.4 Creating director objects

The definition of the actual object triangle can be described this way:

let triangle =
  new_derived_object 
    new_shape
    (triangle_class ((0.0,0.0),(0.5,1.0),(1.0,0.0)))
    '()

The first argument to new_derived_object, new_shape is the method 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 shape). The Second argument is a closure that will be added to the final C_obj.

The actual object passed to the self parameter of the director object will be a C_director_core, containing a c_obj option ref and a c_obj. The c_obj provided is the same object that will be returned from new_derived object, that is, the object exposing the overridden methods. The other part is an option ref that will have its value extracted before becoming the ob parameter of your class closure. This ref will contain None if the C++ object underlying is ever destroyed, and will consequently trigger an exception when any method is called on the object after that point (the actual raise is from an inner function used by new_derived_object, and throws NotObject). This prevents a deleted C++ object from causing a core dump, as long as the object is destroyed properly.

31.2.5.5 Typemaps for directors, directorin, directorout, directorargout

Special typemaps exist for use with directors, the directorin, directorout, directorargout are used in place of in, out, argout typemaps, except that their direction is reversed. They provide for you to provide argout values, as well as a function return value in the same way you provide function arguments, and to receive arguments the same way you normally receive function returns.

31.2.5.6 directorin typemap

The directorin typemap is used when you will receive arguments from a call made by C++ code to you, therefore, values will be translated from C++ to ocaml. You must provide some valid C_obj value. This is the value your ocaml code receives when you are called. In general, a simple directorin typemap can use the same body as a simple out typemap.

31.2.5.7 directorout typemap

The directorout typemap is used when you will send an argument from your code back to the C++ caller. That is; directorout specifies a function return conversion. You can usually use the same body as an in typemap for the same type, except when there are special requirements for object ownership, etc.

31.2.5.8 directorargout typemap

C++ allows function arguments which are by pointer (*) and by reference (&) to receive a value from the called function, as well as sending one there. Sometimes, this is the main purpose of the argument given. directorargout typemaps allow your caml code to emulate this by specifying additional return values to be put into the output parameters. The SWIG ocaml module is a bit loose in order to make code easier to write. In this case, your return to the caller must be a list containing the normal function return first, followed by any argout values in order. These argout values will be taken from the list and assigned to the values to be returned to C++ through directorargout typemaps. In the event that you don't specify all of the necessary values, integral values will read zero, and struct or object returns have undefined results.

31.2.6 Exceptions

Catching exceptions is now supported using SWIG's %exception feature. A simple but not too useful example is provided by the throw_exception testcase in Examples/test-suite. You can provide your own exceptions, too.


32 SWIG and Octave

Octave is a high-level language intended for numerical programming that is mostly compatible with MATLAB. More information can be found at Octave web site.

This chapter is intended to give an introduction to using the module. You should also read the SWIG documentation that is not specific to Octave. Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).

32.1 Preliminaries

As of SWIG 3.0.0, the Octave module has been tested with Octave versions 3.0.5, 3.2.4, 3.4.3, 3.6.4, and 3.8.0. Use of Octave versions older than 3.x.x is not recommended, as these versions are no longer tested with SWIG.

32.2 Running SWIG

Let's start with a very simple SWIG interface file, example.i:

%module swigexample
%{
#include "example.h"
%}
int gcd(int x, int y);
extern double Foo; 

To build an Octave module when wrapping C code, run SWIG using the -octave option:

$ swig -octave -o example_wrap.cpp example.i 

The -c++ option is also required when wrapping C++ code:

$ swig -octave -c++ -o example_wrap.cpp example.i 

This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.

32.2.1 Command-line options

The swig command line has a number of options you can use, like to redirect its output. Use swig -help to learn about these. Options specific to the Octave module are:

$ swig -octave -help
...
Octave Options (available with -octave)
     -globals name - Set name used to access C global variables [default: 'cvar']
                     Use '.' to load C global variables into module namespace
     -opprefix str - Prefix str for global operator functions [default: 'op_']

The -globals option sets the name of the variable which is the namespace for C global variables exported by the module. The special name "." loads C global variables into the module namespace, i.e. alongside C functions and structs exported by the module. The -opprefix options sets the prefix of the names of global/friend operator functions.

32.2.2 Compiling a dynamic module

Octave modules are DLLs/shared objects having the ".oct" suffix. Building an oct file is usually done with the mkoctfile command (either within Octave itself, or from the shell). For example,

$ swig -octave -c++ -o example_wrap.cpp example.i
$ mkoctfile example_wrap.cpp example.c

where "example.c" is the file containing the gcd() implementation.

mkoctfile can also be used to extract the build parameters required to invoke the compiler and linker yourself. See the Octave manual and mkoctfile man page.

mkoctfile will produce "swigexample.oct", which contains the compiled extension module. Loading it into Octave is then a matter of invoking

octave:1> swigexample

32.2.3 Using your module

Assuming all goes well, you will be able to do this:

$ octave -q
octave:1> swigexample
octave:2> swigexample.gcd(4,6)
ans =  2
octave:3> swigexample.cvar.Foo
ans =  3
octave:4> swigexample.cvar.Foo=4;
octave:5> swigexample.cvar.Foo
ans =  4 

32.3 A tour of basic C/C++ wrapping

32.3.1 Modules

The SWIG module directive specifies the name of the Octave module. If you specify "module swigexample", then in Octave everything in the module will be accessible under "swigexample", as in the above example. When choosing a module name, make sure you don't use the same name as a built-in Octave command or standard module name.

When Octave is asked to invoke swigexample, it will try to find the ".m" or ".oct" file that defines the function "swigexample". You therefore need to make sure that "swigexample.oct" is in Octave's search path, which can be specified with the environment variable "OCTAVE_PATH".

To load an Octave module, simply type its name:

octave:1> swigexample;
octave:2> gcd(4,6)
ans =  2
octave:3> cvar.Foo
ans =  3
octave:4> cvar.Foo=4;
octave:5> cvar.Foo
ans =  4

Modules can also be loaded from within functions, even before being loaded in the base context. If the module is also used in the base context, however, it must first be loaded again:

octave:1> function l = my_lcm(a,b)
> swigexample
> l = abs(a*b)/swigexample.gcd(a,b);
> endfunction
octave:2> my_lcm(4,6)
ans =  12
octave:3> swigexample.gcd(4,6)
error: can't perform indexing operations for <unknown type> type
octave:3> swigexample;
octave:4> swigexample.gcd(4,6)
ans =  2

32.3.2 Functions

Global functions are wrapped as new Octave built-in functions. For example,

%module swigexample
int fact(int n); 

creates a built-in function swigexample.fact(n) that works exactly like you think it does:

octave:1> swigexample.fact(4)
24 

32.3.3 Global variables

Global variables are a little special in Octave. Given a global variable:

%module swigexample
extern double Foo;

To expose variables, SWIG actually generates two functions, to get and set the value. In this case, Foo_set and Foo_set would be generated. SWIG then automatically calls these functions when you get and set the variable-- in the former case creating a local copy in the interpreter of the C variables, and in the latter case copying an interpreter variables onto the C variable.

octave:1> swigexample;
octave:2> c=swigexample.cvar.Foo
c =  3
octave:3> swigexample.cvar.Foo=4;
octave:4> c
c =  3
octave:5> swigexample.cvar.Foo
ans =  4

If a variable is marked with the %immutable directive then any attempts to set this variable will cause an Octave error. Given a global variable:

%module swigexample
%immutable;
extern double Foo;
%mutable;

SWIG will allow the reading of Foo but when a set attempt is made, an error function will be called.

octave:1> swigexample
octave:2> swigexample.Foo=4
error: attempt to set immutable member variable
error: assignment failed, or no method for `swig_type = scalar'
error: evaluating assignment expression near line 2, column 12 

It is possible to add new functions or variables to the module. This also allows the user to rename/remove existing functions and constants (but not linked variables, mutable or immutable). Therefore users are recommended to be careful when doing so.

octave:1> swigexample;
octave:2> swigexample.PI=3.142;
octave:3> swigexample.PI
ans =  3.1420 

32.3.4 Constants and enums

Because Octave doesn't really have the concept of constants, C/C++ constants are not really constant in Octave. They are actually just a copy of the value into the Octave interpreter. Therefore they can be changed just as any other value. For example given some constants:

%module swigexample
%constant int ICONST=42;
#define    SCONST      "Hello World"
enum Days{SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};

This is 'effectively' converted into the following Octave code:

swigexample.ICONST=42
swigexample.SCONST="Hello World"
swigexample.SUNDAY=0
.... 

32.3.5 Pointers

C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Given a wrapping of the <file.h> interface: C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Given a wrapping of the <file.h> interface:

%module swigexample
FILE *fopen(const char *filename, const char *mode);
int fputs(const char *, FILE *);
int fclose(FILE *);

When wrapped, you will be able to use the functions in a natural way from Octave. For example:

octave:1> swigexample;
octave:2> f=swigexample.fopen("w","junk");
octave:3> swigexample.fputs("Hello world",f);
octave:4> swigexample.fclose(f);

Simply printing the value of a wrapped C++ type will print its typename. E.g.,

octave:1> swigexample;
octave:2> f=swigexample.fopen("junk","w");
octave:3> f
f =

{
  _p_FILE, ptr = 0x9b0cd00
} 

As the user of the pointer, you are responsible for freeing it, or closing any resources associated with it (just as you would in a C program). This does not apply so strictly to classes and structs (see below).

octave:1> swigexample;
octave:2> f=swigexample.fopen("not there","r");
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 2, column 2 

32.3.6 Structures and C++ classes

SWIG wraps C structures and C++ classes by using a special Octave type called a swig_ref. A swig_ref contains a reference to one or more instances of C/C++ objects, or just the type information for an object. For each wrapped structure and class, a swig_ref will be exposed that has the name of the type. When invoked as a function, it creates a new object of its type and returns a swig_ref that points to that instance. This provides a very natural interface. For example,

struct Point{
  int x,y;
};

is used as follows:

octave:1> swigexample;
octave:2> p=swigexample.Point();
octave:3> p.x=3;
octave:4> p.y=5;
octave:5> p.x, p.y
ans =  3
ans =  5 

In C++, invoking the type object in this way calls the object's constructor. swig_ref objects can also be acquired by having a wrapped function return a pointer, reference, or value of a non-primitive type.

The swig_ref type handles indexing operations such that usage maps closely to what you would have in C/C++. Structure members are accessed as in the above example, by calling set and get methods for C++ variables. Methods also work as expected. For example, code wrapped in the following way

class Point{
public:
  int x,y;
  Point(int _x,int _y) : x(_x),y(_y) {}
  double distance(const Point& rhs) {
    return sqrt(pow(x-rhs.x,2)+pow(y-rhs.y,2));
  }
  void set(int _x,int _y) {
    x=_x; y=_y;
  }
};

can be used from Octave like this

octave:1> swigexample;
octave:2> p1=swigexample.Point(3,5);
octave:3> p2=swigexample.Point(1,2);
octave:4> p1.distance(p2)
ans =  3.6056

By using the swig_this() and swig_type() functions, one can discover the pointers to and types of the underlying C/C++ object.

octave:5> swig_this(p1)
ans = 162504808
octave:6> swig_type(p1)
ans = Point

Note that swig_ref is a reference-counted pointer to a C/C++ object/type, and as such has pass-by-reference semantics. For example if one has a allocated a single object but has two swig_ref 's pointing to it, modifying the object through either of them will change the single allocated object. This differs from the usual pass-by-value (copy-on-write) semantics that Octave maintains for built-in types. For example, in the following snippet, modifying b does not modify a,

octave:7> a=struct('x',4)
a =
{
  x =  4
}

octave:8> b=a
b =
{
  x =  4
}

octave:9> b.y=4
b =
{
  x =  4
  y =  4
}

octave:10> a
a =
{
  x =  4
}

However, when dealing with wrapped objects, one gets the behavior

octave:2> a=Point(3,5)
a =

{
  Point, ptr = 0x9afbbb0
}

octave:3> b=a
b =

{
  Point, ptr = 0x9afbbb0
}

octave:4> b.set(2,1);
octave:5> b.x, b.y
ans =  2
ans =  1
octave:6> a.x, a.y
ans =  2
ans =  1

Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.

32.3.7 C++ inheritance

Single and multiple inheritance are fully supported. The swig_ref type carries type information along with any C++ object pointer it holds. This information contains the full class hierarchy. When an indexing operation (such as a method invocation) occurs, the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.

32.3.8 C++ overloaded functions

Overloaded functions are supported, and handled as in other modules. That is, each overload is wrapped separately (under internal names), and a dispatch function is also emitted under the external/visible name. The dispatch function selects which overload to call (if any) based on the passed arguments. typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.

32.3.9 C++ operators

C++ operator overloading is supported, in a way similar to other modules. The swig_ref type supports all unary and binary operators between itself and all other types that exist in the system at module load time. When an operator is used (where one of the operands is a swig_ref), the runtime routes the call to either a member function of the given object, or to a global function whose named is derived from the types of the operands (either both or just the lhs or rhs).

For example, if a and b are SWIG variables in Octave, a+b becomes a.__add(b). The wrapper is then free to implement __add to do whatever it wants. A wrapper may define the __add function manually, %rename some other function to it, or %rename a C++ operator to it.

By default the C++ operators are renamed to their corresponding Octave operators. So without doing any work, the following interface

%inline {
struct A {
  int value;
  A(int _value) : value(_value) {}
  A operator+ (const A& x) {
    return A(value+x.value);
  }
};
}

is usable from Octave like this:

a=A(2), b=A(3), c=a+b
assert(c.value==5);

Octave operators are mapped in the following way:

__brace      a{args}
__brace_asgn a{args} = rhs
__paren      a(args)
__paren_asgn a(args) = rhs
__str        generates string rep
__not        !a
__uplus      +a
__uminus     -a
__transpose  a.'
__hermitian  a'
__incr       a++
__decr       a--
__add        a + b
__sub        a - b
__mul        a * b
__div        a / b
__pow        a ^ b
__ldiv       a \ b
__lshift     a <<b
__rshift     a >> b
__lt         a  <b
__le         a  <= b
__eq         a == b
__ge         a >= b
__gt         a > b
__ne         a != b
__el_mul     a .* b
__el_div     a ./ b
__el_pow     a .^ b
__el_ldiv    a .\ b
__el_and     a & b
__el_or      a | b

On the C++ side, the default mappings are as follows:

%rename(__add)       *::operator+;
%rename(__add)       *::operator+();
%rename(__add)       *::operator+() const;
%rename(__sub)       *::operator-;
%rename(__uminus)    *::operator-();
%rename(__uminus)    *::operator-() const;
%rename(__mul)       *::operator*;
%rename(__div)       *::operator/;
%rename(__mod)       *::operator%;
%rename(__lshift)    *::operator<

>;
%rename(__el_and)    *::operator&&;
%rename(__el_or)     *::operator||;
%rename(__xor)       *::operator^;
%rename(__invert)    *::operator~;
%rename(__lt)        *::operator

;
%rename(__ge)        *::operator>=;
%rename(__eq)        *::operator==;
%rename(__ne)        *::operator!=;
%rename(__not)       *::operator!;
%rename(__incr)      *::operator++;
%rename(__decr)      *::operator--;
%rename(__paren)     *::operator();
%rename(__brace)     *::operator[];

Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.

32.3.10 Class extension with %extend

The %extend directive works the same as in other modules.

You can use it to define special behavior, like for example defining Octave operators not mapped to C++ operators, or defining certain Octave mechanisms such as how an object prints. For example, the octave_value::{is_string,string_value,print} functions are routed to a special method __str that can be defined inside an %extend.

%extend A {
string __str() {
  stringstream sout;
  sout<<$self->value;
  return sout.str();
}
}

Then in Octave one gets,

octave:1> a=A(4);
octave:2> a
a = 4
octave:3> printf("%s\n",a);
4
octave:4> a.__str()
4

32.3.11 C++ templates

C++ class and function templates are fully supported as in other modules, in that the %template directive may used to create explicit instantiations of templated types. For example, function templates can be instantiated as follows:

%module swigexample
%inline {
 template<class __scalar>
   __scalar mul(__scalar a,__scalar b) {
   return a*b;
 }
}
%include <std_complex.i>
%template(mul) mul<std::complex<double> >
%template(mul) mul<double>

and then used from Octave

octave:1> mul(4,3)
ans =  12
octave:2> mul(4.2,3.6)
ans =  15.120
octave:3> mul(3+4i,10+2i)
ans =  22 + 46i

Similarly, class templates can be instantiated as in the following example,

%module swigexample
%include <std_complex.i>
%include <std_string.i>
%inline {
  #include <sstream>
  template<class __scalar> class sum {
    __scalar s;
  public:
    sum(__scalar _s=0) : s(_s) {}
    sum& add(__scalar _s) {
      s+=_s;
      return *this;
    }
    std::string __str() const {
      std::stringstream sout;
      sout<<s;
      return sout.str();
    }
  };
}
%template(sum_complex) sum<std::complex<double> >;
%template(sum_double) sum<double>;

and then used from Octave

octave:2> a=sum_complex(2+3i);
octave:3> a.add(2)
ans =

(4,3)
octave:4> a.add(3+i)
ans =

(7,4)

32.3.12 C++ Smart Pointers

C++ smart pointers are fully supported as in other modules.

32.3.13 Directors (calling Octave from C++ code)

There is full support for SWIG Directors, which permits Octave code to subclass C++ classes, and implement their virtual methods.

Octave has no direct support for object oriented programming, however the swig_ref type provides some of this support. You can manufacture a swig_ref using the subclass function (provided by the SWIG/Octave runtime).

For example,

octave:1> a=subclass();
octave:2> a.my_var = 4;
octave:3> a.my_method = @(self) printf("my_var = ",self.my_var);
octave:4> a.my_method();
my_var = 4

subclass() can also be used to subclass one or more C++ types. Suppose you have an interface defined by

%inline {
class A {
public:
  virtual my_method() {
    printf("c-side routine called\n");
  }
};
void call_your_method(A& a) {
  a.my_method();
}
}

Then from Octave you can say:

octave:1> B=@() subclass(A(),@my_method);
octave:2> function my_method(self)
octave:3>   printf("octave-side routine called\n");
octave:4> end
octave:5> call_your_method(B());
octave-side routine called

or more concisely,

octave:1> B=@() subclass(A(),'my_method',@(self) printf("octave-side routine called\n"));
octave:2> call_your_method(B());
octave-side routine called

Note that you have to enable directors via the %feature directive (see other modules for this).

subclass() will accept any number of C++ bases or other subclass()'ed objects, (string,octave_value) pairs, and function_handles. In the first case, these are taken as base classes; in the second case, as named members (either variables or functions, depending on whether the given value is a function handle); in the third case, as member functions whose name is taken from the given function handle. E.g.,

octave:1> B=@(some_var=2) subclass(A(),'some_var',some_var,@some_func,'another_func',
@(self) do_stuff())

You can also assign non-C++ member variables and functions after construct time. There is no support for non-C++ static members.

There is limited support for explicitly referencing C++ bases. So, in the example above, we could have

octave:1> B=@() subclass(A(),@my_method);
octave:2> function my_method(self)
octave:3>   self.A.my_method();
octave:4>   printf("octave-side routine called\n");
octave:5> end
octave:6> call_your_method(B());
c-side routine called
octave-side routine called

32.3.14 Threads

The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.

32.3.15 Memory management

As noted above, swig_ref represents a reference counted pointer to a C/C++-side object. It also contains a flag indicating whether Octave or the C/C++ code owns the object. If Octave owns it, any destructors will be called when the reference count reaches zero. If the C/C++ side owns the object, then destructors will not be called when the reference count goes to zero.

For example,

%inline {
class A {
public:
  A() { printf("A constructing\n"); }
  ~A() { printf("A destructing\n"); }
};
}

Would produce this behavior in Octave:

octave:1> a=A();
A constructing
octave:2> b=a;
octave:3> clear a;
octave:4> b=4;
A destructing

The %newobject directive may be used to control this behavior for pointers returned from functions.

In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).

32.3.16 STL support

Various STL library files are provided for wrapping STL containers.

32.3.17 Matrix typemaps

Octave provides a rich set of classes for dealing with matrices. Currently there are no built-in typemaps to deal with those. However, these are relatively straight forward for users to add themselves (see the docs on typemaps). Without much work (a single typemap decl-- say, 5 lines of code in the interface file), it would be possible to have a function

double my_det(const double* mat,int m,int n);

that is accessed from Octave as,

octave:1> my_det(rand(4));
ans = -0.18388


33 SWIG and Perl5

Caution: This chapter is under repair!

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.

33.1 Overview

To build Perl extension modules, SWIG uses a layered approach. At the lowest level, simple procedural wrappers are generated for functions, classes, methods, and other declarations in the input file. Then, for structures and classes, an optional collection of Perl proxy classes can be generated in order to provide a more natural object oriented Perl interface. These proxy classes simply build upon the low-level interface.

In describing the Perl interface, this chapter begins by covering the essentials. First, the problem of configuration, compiling, and installing Perl modules is discussed. Next, the low-level procedural interface is presented. Finally, proxy classes are described. Advanced customization features, typemaps, and other options are found near the end of the chapter.

33.2 Preliminaries

To build a Perl5 module, run SWIG using the -perl option as follows:

swig -perl example.i

This produces two files. The first file, example_wrap.c contains all of the C code needed to build a Perl5 module. The second file, example.pm contains supporting Perl code needed to properly load the module.

To build the module, you will need to compile the file example_wrap.c and link it with the rest of your program.

33.2.1 Getting the right header files

In order to compile, SWIG extensions need the following Perl5 header files:

#include "Extern.h"
#include "perl.h"
#include "XSUB.h"

These are typically located in a directory like this

/usr/lib/perl/5.14/CORE

The SWIG configuration script automatically tries to locate this directory so that it can compile examples. However, if you need to find out where the directory is located, an easy way to find out is to ask Perl itself:

$ perl -e 'use Config; print "$Config{archlib}\n";'
/usr/lib/perl/5.14

33.2.2 Compiling a dynamic module

The preferred approach to building an extension module is to compile it into a shared object file or DLL. Assuming you have code you need to link to in a file called example.c, you will need to compile your program using commands like this (shown for Linux):

$ swig -perl example.i
$ gcc -fPIC example.c
$ gcc -fPIC -c example_wrap.c -I/usr/lib/perl/5.14/CORE -Dbool=char
$ gcc -shared example.o example_wrap.o -o example.so

The exact compiler options vary from platform to platform. SWIG tries to guess the right options when it is installed. Therefore, you may want to start with one of the examples in the SWIG/Examples/perl5 directory. If that doesn't work, you will need to read the man-pages for your compiler and linker to get the right set of options. You might also check the SWIG Wiki for additional information.

When linking the module, the name of the shared object file must match the module name used in the SWIG interface file. If you used ` %module example', then the target should be named `example.so ', `example.sl', or the appropriate dynamic module name on your system.

33.2.3 Building a dynamic module with MakeMaker

It is also possible to use Perl to build dynamically loadable modules for you using the MakeMaker utility. To do this, write a Perl script such as the following:

# File : Makefile.PL
use ExtUtils::MakeMaker;
WriteMakefile(
	`NAME'    => `example',                  # Name of package
	`LIBS'    => [`-lm'],                    # Name of custom libraries
	`OBJECT'  => `example.o example_wrap.o'  # Object files
);

Now, to build a module, simply follow these steps:

$ perl Makefile.PL
$ make
$ make install

If you are planning to distribute a SWIG-generated module, this is the preferred approach to compilation. More information about MakeMaker can be found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen, and Randal Schwartz.

33.2.4 Building a static version of Perl

If you machine does not support dynamic loading or if you've tried to use it without success, you can build a new version of the Perl interpreter with your SWIG extensions added to it. To build a static extension, you first need to invoke SWIG as follows:

$ swig -perl -static example.i

By default SWIG includes code for dynamic loading, but the -static option takes it out.

Next, you will need to supply a main() function that initializes your extension and starts the Perl interpreter. While, this may sound daunting, SWIG can do this for you automatically as follows:

%module example

%inline %{
extern double My_variable;
extern int fact(int);
%}

// Include code for rebuilding Perl
%include <perlmain.i>

The same thing can be accomplished by running SWIG as follows:

$ swig -perl -static -lperlmain.i example.i

The perlmain.i file inserts Perl's main() function into the wrapper code and automatically initializes the SWIG generated module. If you just want to make a quick a dirty module, this may be the easiest way. By default, the perlmain.i code does not initialize any other Perl extensions. If you need to use other packages, you will need to modify it appropriately. You can do this by just copying perlmain.i out of the SWIG library, placing it in your own directory, and modifying it to suit your purposes.

To build your new Perl executable, follow the exact same procedure as for a dynamic module, but change the link line to something like this:

$ gcc example.o example_wrap.o -L/usr/lib/perl/5.14/CORE \
	-lperl -lsocket -lnsl -lm -o myperl

This will produce a new version of Perl called myperl. It should be functionality identical to Perl with your C/C++ extension added to it. Depending on your machine, you may need to link with additional libraries such as -lsocket, -lnsl, -ldl, etc.

33.2.5 Using the module

To use the module, simply use the Perl use statement. If all goes well, you will be able to do this:

$ perl
use example;
print example::fact(4),"\n";
24

A common error received by first-time users is the following:

use example;
Can't locate example.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at - line 1.
BEGIN failed--compilation aborted at - line 1.

This error is almost caused when the name of the shared object file you created doesn't match the module name you specified with the %module directive.

A somewhat related, but slightly different error is this:

use example;
Can't find 'boot_example' symbol in ./example.so
 at - line 1
BEGIN failed--compilation aborted at - line 1.

This error is generated because Perl can't locate the module bootstrap function in the SWIG extension module. This could be caused by a mismatch between the module name and the shared library name. However, another possible cause is forgetting to link the SWIG-generated wrapper code with the rest of your application when you linked the extension module.

Another common error is the following:

use example;
Can't load './example.so' for module example: ./example.so: 
undefined symbol: Foo at /usr/lib/perl/5.14/i386-linux/DynaLoader.pm line 169.

 at - line 1
BEGIN failed--compilation aborted at - line 1.

This error usually indicates that you forgot to include some object files or libraries in the linking of the shared library file. Make sure you compile both the SWIG wrapper file and your original program into a shared library file. Make sure you pass all of the required libraries to the linker.

Sometimes unresolved symbols occur because a wrapper has been created for a function that doesn't actually exist in a library. This usually occurs when a header file includes a declaration for a function that was never actually implemented or it was removed from a library without updating the header file. To fix this, you can either edit the SWIG input file to remove the offending declaration or you can use the %ignore directive to ignore the declaration. Better yet, update the header file so that it doesn't have an undefined declaration.

Finally, suppose that your extension module is linked with another library like this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -o example.so

If the foo library is compiled as a shared library, you might get the following error when you try to use your module:

use example;
Can't load './example.so' for module example: libfoo.so: cannot open shared object file: 
No such file or directory at /usr/lib/perl/5.14/i386-linux/DynaLoader.pm line 169.

 at - line 1
BEGIN failed--compilation aborted at - line 1.
>>>                 

This error is generated because the dynamic linker can't locate the libfoo.so library. When shared libraries are loaded, the system normally only checks a few standard locations such as /usr/lib and /usr/local/lib. To get the loader to look in other locations, there are several things you can do. First, you can recompile your extension module with extra path information. For example, on Linux you can do this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -Xlinker -rpath /home/beazley/projects/lib \
      -o example.so

Alternatively, you can set the LD_LIBRARY_PATH environment variable to include the directory with your shared libraries. If setting LD_LIBRARY_PATH, be aware that setting this variable can introduce a noticeable performance impact on all other applications that you run. To set it only for Perl, you might want to do this instead:

$ env LD_LIBRARY_PATH=/home/beazley/projects/lib perl

Finally, you can use a command such as ldconfig (Linux) or crle (Solaris) to add additional search paths to the default system configuration (this requires root access and you will need to read the man pages).

33.2.6 Compilation problems and compiling with C++

Compilation of C++ extensions has traditionally been a tricky problem. Since the Perl interpreter is written in C, you need to take steps to make sure C++ is properly initialized and that modules are compiled correctly.

On most machines, C++ extension modules should be linked using the C++ compiler. For example:

$ swig -c++ -perl example.i
$ g++ -fPIC -c example.cxx
$ g++ -fPIC -c example_wrap.cxx -I/usr/lib/perl/5.14/i386-linux/CORE
$ g++ -shared example.o example_wrap.o -o example.so

In addition to this, you may need to include additional library files to make it work. For example, if you are using the Sun C++ compiler on Solaris, you often need to add an extra library -lCrun like this:

$ swig -c++ -perl example.i
$ CC -Kpic -c example.cxx
$ CC -Kpic -c example_wrap.cxx -I/usr/lib/perl/5.14/i386-linux/CORE
$ CC -shared example.o example_wrap.o -o example.so -lCrun

Of course, the names of the extra libraries are completely non-portable---you will probably need to do some experimentation.

Another possible compile problem comes from recent versions of Perl (5.8.0) and the GNU tools. If you see errors having to do with _crypt_struct, that means _GNU_SOURCE is not defined and it needs to be. So you should compile the wrapper like:

$ g++ -fPIC -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE -D_GNU_SOURCE

-D_GNU_SOURCE is also included in the Perl ccflags, which can be found by running

$ perl -e 'use Config; print "$Config{ccflags}\n";'

So you could also compile the wrapper like

$ g++ -fPIC -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE \
`perl -MConfig -e 'print $Config{ccflags}'`

Sometimes people have suggested that it is necessary to relink the Perl interpreter using the C++ compiler to make C++ extension modules work. In the experience of this author, this has never actually appeared to be necessary on most platforms. Relinking the interpreter with C++ really only includes the special run-time libraries described above---as long as you link your extension modules with these libraries, it should not be necessary to rebuild Perl.

If you aren't entirely sure about the linking of a C++ extension, you might look at an existing C++ program. On many Unix machines, the ldd command will list library dependencies. This should give you some clues about what you might have to include when you link your extension module. For example, notice the first line of output here:

$ ldd swig
        libstdc++-libc6.1-1.so.2 => /usr/lib/libstdc++-libc6.1-1.so.2 (0x40019000)
        libm.so.6 => /lib/libm.so.6 (0x4005b000)
        libc.so.6 => /lib/libc.so.6 (0x40077000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
$

If linking wasn't enough of a problem, another major complication of C++ is that it does not define any sort of standard for binary linking of libraries. This means that C++ code compiled by different compilers will not link together properly as libraries nor is the memory layout of classes and data structures implemented in any kind of portable manner. In a monolithic C++ program, this problem may be unnoticed. However, in Perl, it is possible for different extension modules to be compiled with different C++ compilers. As long as these modules are self-contained, this probably won't matter. However, if these modules start sharing data, you will need to take steps to avoid segmentation faults and other erratic program behavior. Also, be aware that certain C++ features, especially RTTI, can behave strangely when working with multiple modules.

It should be noted that you may get a lot of error messages about the 'bool' datatype when compiling a C++ Perl module. If you experience this problem, you can try the following:

  • Use -DHAS_BOOL when compiling the SWIG wrapper code
  • Or use -Dbool=char when compiling.

Finally, recent versions of Perl (5.8.0) have namespace conflict problems. Perl defines a bunch of short macros to make the Perl API function names shorter. For example, in /usr/lib/perl/5.8.0/CORE/embed.h there is a line:

#define do_open Perl_do_open

The problem is, in the <iostream> header from GNU libstdc++v3 there is a private function named do_open. If <iostream> is included after the perl headers, then the Perl macro causes the iostream do_open to be renamed, which causes compile errors. Hopefully in the future Perl will support a PERL_NO_SHORT_NAMES flag, but for now the only solution is to undef the macros that conflict. Lib/perl5/noembed.h in the SWIG source has a list of macros that are known to conflict with either standard headers or other headers. But if you get macro type conflicts from other macros not included in Lib/perl5/noembed.h while compiling the wrapper, you will have to find the macro that conflicts and add an #undef into the .i file. Please report any conflicting macros you find to swig-user mailing list.

33.2.7 Compiling for 64-bit platforms

On platforms that support 64-bit applications (Solaris, Irix, etc.), special care is required when building extension modules. On these machines, 64-bit applications are compiled and linked using a different set of compiler/linker options. In addition, it is not generally possible to mix 32-bit and 64-bit code together in the same application.

To utilize 64-bits, the Perl executable will need to be recompiled as a 64-bit application. In addition, all libraries, wrapper code, and every other part of your application will need to be compiled for 64-bits. If you plan to use other third-party extension modules, they will also have to be recompiled as 64-bit extensions.

If you are wrapping commercial software for which you have no source code, you will be forced to use the same linking standard as used by that software. This may prevent the use of 64-bit extensions. It may also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

33.3 Building Perl Extensions under Windows

Building a SWIG extension to Perl under Windows is roughly similar to the process used with Unix. Normally, you will want to produce a DLL that can be loaded into the Perl interpreter. This section assumes you are using SWIG with Microsoft Visual C++ although the procedure may be similar with other compilers.

33.3.1 Running SWIG from Developer Studio

If you are developing your application within Microsoft developer studio, SWIG can be invoked as a custom build option. The process roughly requires these steps:

  • Open up a new workspace and use the AppWizard to select a DLL project.
  • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (ie. example_wrap.c). Note: If using C++, choose a different suffix for the wrapper file such as example_wrap.cxx. Don't worry if the wrapper file doesn't exist yet--Developer studio will keep a reference to it around.
  • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
  • Enter "SWIG" in the description field.
  • Enter "swig -perl5 -o $(ProjDir)\$(InputName)_wrap.cxx $(InputPath)" in the "Build command(s) field"
  • Enter "$(ProjDir)\$(InputName)_wrap.cxx" in the "Output files(s) field".
  • Next, select the settings for the entire project and go to "C++:Preprocessor". Add the include directories for your Perl 5 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.
  • Finally, select the settings for the entire project and go to "Link Options". Add the Perl library file to your link libraries. For example "perl.lib". Also, set the name of the output file to match the name of your Perl module (ie. example.dll).
  • Build your project.

Now, assuming you made it this far, SWIG will be automatically invoked when you build your project. Any changes made to the interface file will result in SWIG being automatically invoked to produce a new version of the wrapper file. To run your new Perl extension, simply run Perl and use the use command as normal. For example:

DOS > perl
use example;
$a = example::fact(4);
print "$a\n";

33.3.2 Using other compilers

SWIG is known to work with Cygwin and may work with other compilers on Windows. For general hints and suggestions refer to the Windows chapter.

33.4 The low-level interface

At its core, the Perl module uses a simple low-level interface to C function, variables, constants, and classes. This low-level interface can be used to control your application. However, it is also used to construct more user-friendly proxy classes as described in the next section.

33.4.1 Functions

C functions are converted into new Perl built-in commands (or subroutines). For example:

%module example
int fact(int a);
...

Now, in Perl:

use example;
$a = &example::fact(2);

33.4.2 Global variables

Global variables are handled using Perl's magic variable mechanism. SWIG generates a pair of functions that intercept read/write operations and attaches them to a Perl variable with the same name as the C global variable. Thus, an interface like this

%module example;
...
double Spam;
...

is accessed as follows:

use example;
print $example::Spam,"\n";
$example::Spam = $example::Spam + 4
# ... etc ...

If a variable is declared as const, it is wrapped as a read-only variable. Attempts to modify its value will result in an error.

To make ordinary variables read-only, you can also use the %immutable directive. For example:

%{
extern char *path;
%}
%immutable;
extern char *path;
%mutable;

The %immutable directive stays in effect until it is explicitly disabled or cleared using %mutable. See the Creating read-only variables section for further details.

It is also possible to tag a specific variable as read-only like this:

%{
extern char *path;
%}
%immutable path; 
...
...
extern char *path;       // Declared later in the input

33.4.3 Constants

By default, constants are wrapped as read-only Perl variables. For example:

%module example

#define FOO 42

In Perl:

use example;
print $example::FOO,"\n";    # OK
$example::FOO = 2;           # Error

Alternatively, if you use swig's -const option, constants are wrapped such that the leading $ isn't required (by using a constant subroutine), which usually gives a more natural Perl interface, for example:

use example;
print example::FOO,"\n";

33.4.4 Pointers

SWIG represents pointers as blessed references. A blessed reference is the same as a Perl reference except that it has additional information attached to it indicating what kind of reference it is. That is, if you have a C declaration like this:

Matrix *new_Matrix(int n, int m);

The module returns a value generated as follows:

$ptr = new_Matrix(int n, int m);     # Save pointer return result
bless $ptr, "p_Matrix";              # Bless it as a pointer to Matrix

SWIG uses the "blessing" to check the datatype of various pointers. In the event of a mismatch, an error or warning message is generated.

To check to see if a value is the NULL pointer, use the defined() command:

if (defined($ptr)) {
	print "Not a NULL pointer.";
} else {
	print "Is a NULL pointer.";
}

To create a NULL pointer, you should pass the undef value to a function.

The "value" of a Perl reference is not the same as the underlying C pointer that SWIG wrapper functions return. Suppose that $a and $b are two references that point to the same C object. In general, $a and $b will be different--since they are different references. Thus, it is a mistake to check the equality of $a and $b to check the equality of two C pointers. The correct method to check equality of C pointers is to dereference them as follows:

if ($$a == $$b) {
	print "a and b point to the same thing in C";
} else {
	print "a and b point to different objects.";
}

As much as you might be inclined to modify a pointer value directly from Perl, don't. Manipulating pointer values is architecture dependent and could cause your program to crash. Similarly, don't try to manually cast a pointer to a new type by reblessing a pointer. This may not work like you expect and it is particularly dangerous when casting C++ objects. If you need to cast a pointer or change its value, consider writing some helper functions instead. For example:

%inline %{
/* C-style cast */
Bar *FooToBar(Foo *f) {
   return (Bar *) f;
}

/* C++-style cast */
Foo *BarToFoo(Bar *b) {
   return dynamic_cast<Foo*>(b);
}

Foo *IncrFoo(Foo *f, int i) {
    return f+i;
}
%}

Also, if working with C++, you should always try to use the new C++ style casts. For example, in the above code, the C-style cast may return a bogus result whereas as the C++-style cast will return NULL if the conversion can't be performed.

Compatibility Note: In earlier versions, SWIG tried to preserve the same pointer naming conventions as XS and xsubpp. Given the advancement of the SWIG typesystem and the growing differences between SWIG and XS, this is no longer supported.

33.4.5 Structures

Access to the contents of a structure are provided through a set of low-level accessor functions as described in the "SWIG Basics" chapter. For example,

struct Vector {
	double x,y,z;
};

gets mapped into the following collection of accessor functions:

struct Vector *new_Vector();
void           delete_Vector(Vector *v);
double         Vector_x_get(Vector *obj)
void           Vector_x_set(Vector *obj, double x)
double         Vector_y_get(Vector *obj)
void           Vector_y_set(Vector *obj, double y)
double         Vector_z_get(Vector *obj)
void           Vector_z_set(Vector *obj, double z)

These functions are then used to access structure data from Perl as follows:

$v = example::new_Vector();
print example::Vector_x_get($v),"\n";    # Get x component
example::Vector_x_set($v,7.8);          # Change x component

Similar access is provided for unions and the data members of C++ classes.

const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive. For example:

struct Foo {
   ...
   %immutable;
   int x;        /* Read-only members */
   char *name;
   %mutable;
   ...
};

When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run with the -c++ option). When the structure member is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described later).

Array members are normally wrapped as read-only. For example,

struct Foo {
   int  x[50];
};

produces a single accessor function like this:

int *Foo_x_get(Foo *self) {
    return self->x;
};

If you want to set an array member, you will need to supply a "memberin" typemap described later in this chapter. As a special case, SWIG does generate code to set array members of type char (allowing you to store a Python string in the structure).

When structure members are wrapped, they are handled as pointers. For example,

struct Foo {
   ...
};

struct Bar {
   Foo f;
};

generates accessor functions such as this:

Foo *Bar_f_get(Bar *b) {
    return &b->f;
}

void Bar_f_set(Bar *b, Foo *val) {
    b->f = *val;
}

33.4.6 C++ classes

C++ classes are wrapped by building a set of low level accessor functions. Consider the following class:

class List {
public:
  List();
  ~List();
  int  search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int  length;
static void print(List *l);
};

When wrapped by SWIG, the following functions are created:

List    *new_List();
void     delete_List(List *l);
int      List_search(List *l, char *item);
void     List_insert(List *l, char *item);
void     List_remove(List *l, char *item);
char    *List_get(List *l, int n);
int      List_length_get(List *l);
void     List_length_set(List *l, int n);
void     List_print(List *l);

In Perl, these functions are used in a straightforward manner:

use example;
$l = example::new_List();
example::List_insert($l,"Ale");
example::List_insert($l,"Stout");
example::List_insert($l,"Lager")
example::List_print($l)
Lager
Stout
Ale
print example::List_length_get($l),"\n";
3

At this low level, C++ objects are really just typed pointers. Member functions are accessed by calling a C-like wrapper with an instance pointer as the first argument. Although this interface is fairly primitive, it provides direct access to C++ objects. A higher level interface using Perl proxy classes can be built using these low-level accessors. This is described shortly.

33.4.7 C++ classes and type-checking

The SWIG type-checker is fully aware of C++ inheritance. Therefore, if you have classes like this

class Foo {
...
};

class Bar : public Foo {
...
};

and a function

void spam(Foo *f);

then the function spam() accepts Foo * or a pointer to any class derived from Foo. If necessary, the type-checker also adjusts the value of the pointer (as is necessary when multiple inheritance is used).

33.4.8 C++ overloaded functions

If you have a C++ program with overloaded functions or methods, you will need to disambiguate those methods using %rename. For example:

/* Forward renaming declarations */
%rename(foo_i) foo(int); 
%rename(foo_d) foo(double);
...
void foo(int);           // Becomes 'foo_i'
void foo(char *c);       // Stays 'foo' (not renamed)

class Spam {
public:
   void foo(int);      // Becomes 'foo_i'
   void foo(double);   // Becomes 'foo_d'
   ...
};

Now, in Perl, the methods are accessed as follows:

use example;
example::foo_i(3);
$s = example::new_Spam();
example::Spam_foo_i($s,3);
example::Spam_foo_d($s,3.14);

Please refer to the "SWIG Basics" chapter for more information.

33.4.9 Operators

As of version 1.3.27 SWIG automatically renames the most common C++ operators, and maps them into the perl module with the proper 'use overload ...' so you don't need to do any work.

The following C++ operators are currently supported by the Perl module:

  • operator++
  • operator--
  • operator+
  • operator-
  • operator*
  • operator/
  • operator==
  • operator!=
  • operator%
  • operator>
  • operator<
  • operator and
  • operator or

33.4.10 Modules and packages

When you create a SWIG extension, everything gets placed into a single Perl module. The name of the module is determined by the %module directive. To use the module, do the following:

$ perl5
use example;                      # load the example module
print example::fact(4),"\n"       # Call a function in it
24

Usually, a module consists of a collection of code that is contained within a single file. A package, on the other hand, is the Perl equivalent of a namespace. A package is a lot like a module, except that it is independent of files. Any number of files may be part of the same package--or a package may be broken up into a collection of modules if you prefer to think about it in this way.

SWIG installs its functions into a package with the same name as the module.

Incompatible Change: previous versions of SWIG enabled you to change the name of the package by using the -package option, this feature has been removed in order to properly support modules that used nested namespaces, e.g. Foo::Bar::Baz. To give your module a nested namespace simply provide the fully qualified name in your %module directive:

%module "Foo::Bar::Baz"

NOTE: the double quotes are necessary.

Using the package option of the %module directive allows you to specify what Perl namespace that the module will be living in when installed. This is useful in the situation where a module maintainer wants to split a large module into smaller pieces to make maintenance easier, but doesn't want to have that affect the module name used by applications. So for example, if I wanted to split XML::Xerces into XML::Xerces::SAX, etc. , but I wanted all the applications to be able to access the classes using the XML::Xerces namespace I could use:

%module(package="XML::Xerces") "XML::Xerces::SAX

And now all the applications could use the class XML::Xerces::SAXParser. Without the package directive splitting the module would force applications to use the class XML::Xerces::SAX::SAXParser. This could break compatibility for existing applications that are already using the class under the name XML::Xerces::SAXParser.

33.5 Input and output parameters

A common problem in some C programs is handling parameters passed as simple pointers. For example:

void add(int x, int y, int *result) {
   *result = x + y;
}

or perhaps

int sub(int *x, int *y) {
   return *x+*y;
}

The easiest way to handle these situations is to use the typemaps.i file. For example:

%module example
%include "typemaps.i"

void add(int, int, int *OUTPUT);
int  sub(int *INPUT, int *INPUT);

In Perl, this allows you to pass simple values. For example:

$a = example::add(3,4);
print "$a\n";
7
$b = example::sub(7,4);
print "$b\n";
3

Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter creates a return result.

If you don't want to use the names INPUT or OUTPUT , use the %apply directive. For example:

%module example
%include "typemaps.i"

%apply int *OUTPUT { int *result };
%apply int *INPUT  { int *x, int *y};

void add(int x, int y, int *result);
int  sub(int *x, int *y);

If a function mutates one of its parameters like this,

void negate(int *x) {
   *x = -(*x);
}

you can use INOUT like this:

%include "typemaps.i"
...
void negate(int *INOUT);

In Perl, a mutated parameter shows up as a return value. For example:

$a = example::negate(3);
print "$a\n";
-3

The most common use of these special typemap rules is to handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

/* send message, return number of bytes sent, along with success code */
int send_message(char *text, int len, int *success);

To wrap such a function, simply use the OUTPUT rule above. For example:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *success };
...
int send_message(char *text, int *success);

When used in Perl, the function will return multiple values.

($bytes, $success) = example::send_message("Hello World");

Another common use of multiple return values are in query functions. For example:

void get_dimensions(Matrix *m, int *rows, int *columns);

To wrap this, you might use the following:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *rows, int *columns };
...
void get_dimensions(Matrix *m, int *rows, *columns);

Now, in Perl:

($r,$c) = example::get_dimensions($m);

In certain cases, it is possible to treat Perl references as C pointers. To do this, use the REFERENCE typemap. For example:

%module example
%include "typemaps.i"

void add(int x, int y, int *REFERENCE);

In Perl:

use example;
$c = 0.0;
example::add(3,4,\$c);
print "$c\n";
7

Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).

33.6 Exception handling

The SWIG %exception directive can be used to create a user-definable exception handler for converting exceptions in your C/C++ program into Perl exceptions. The chapter on customization features contains more details, but suppose you have a C++ class like the following:

class RangeError {};   // Used for an exception

class DoubleArray {
  private:
    int n;
    double *ptr;
  public:
    // Create a new array of fixed size
    DoubleArray(int size) {
      ptr = new double[size];
      n = size;
    }
    // Destroy an array
    ~DoubleArray() {
       delete ptr;
    }
    // Return the length of the array
    int   length() {
      return n;
    }

    // Get an item from the array and perform bounds checking.
    double getitem(int i) {
      if ((i >= 0) && (i < n))
        return ptr[i];
      else
        throw RangeError();
    }

    // Set an item in the array and perform bounds checking.
    void setitem(int i, double val) {
      if ((i >= 0) && (i < n))
        ptr[i] = val;
      else {
        throw RangeError();
      }
    }
  };

Since several methods in this class can throw an exception for an out-of-bounds access, you might want to catch this in the Perl extension by writing the following in an interface file:

%exception {
  try {
    $action
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}

class DoubleArray {
...
};

The exception handling code is inserted directly into generated wrapper functions. The $action variable is replaced with the C/C++ code being executed by the wrapper. When an exception handler is defined, errors can be caught and used to gracefully generate a Perl error instead of forcing the entire program to terminate with an uncaught error.

As shown, the exception handling code will be added to every wrapper function. Since this is somewhat inefficient. You might consider refining the exception handler to only apply to specific methods like this:

%exception getitem {
  try {
    $action
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}

%exception setitem {
  try {
    $action
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}

In this case, the exception handler is only attached to methods and functions named getitem and setitem.

If you had a lot of different methods, you can avoid extra typing by using a macro. For example:

%define RANGE_ERROR
{
  try {
    $action
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}
%enddef

%exception getitem RANGE_ERROR;
%exception setitem RANGE_ERROR;

Since SWIG's exception handling is user-definable, you are not limited to C++ exception handling. See the chapter on " Customization features" for more examples.

Compatibility note: In SWIG1.1, exceptions were defined using the older %except directive:

%except(python) {
  try {
    $function
  }
  catch (RangeError) {
    croak("Array index out-of-bounds");
  }
}

This is still supported, but it is deprecated. The newer %exception directive provides the same functionality, but it has additional capabilities that make it more powerful.

33.7 Remapping datatypes with typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Perl C API as well as the material in the "Typemaps " chapter.

Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the primitive C-Perl interface.

33.7.1 A simple typemap example

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Perl to C, you might define a typemap like this:

%module example

%typemap(in) int {
	$1 = (int) SvIV($input);
	printf("Received an integer : %d\n", $1);
}
...
%inline %{
extern int fact(int n);
%}

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input variable is the input object (usually a SV *).

When this example is used in Perl5, it will operate as follows:

use example;
$n = example::fact(6);
print "$n\n";
...

Output:
Received an integer : 6
720

The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG type-system. When you define a typemap for int, that typemap applies to int and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

%typemap(in) int n {
	$1 = (int) SvIV($input);
	printf("n = %d\n",$1);
}
%inline %{
typedef int Integer;
extern int fact(Integer n);    // Above typemap is applied
%}

It should be noted that the matching of typedef only occurs in one direction. If you defined a typemap for Integer, it is not applied to arguments of type int.

Typemaps can also be defined for groups of consecutive arguments. For example:

%typemap(in) (char *str, unsigned len) {
    $1 = SvPV($input,$2);
};

int count(char c, char *str, unsigned len);

When a multi-argument typemap is defined, the arguments are always handled as a single Perl object. This allows the function to be used like this (notice how the length parameter is omitted):

example::count("e","Hello World");
1
>>>

33.7.2 Perl5 typemaps

The previous section illustrated an "in" typemap for converting Perl objects to C. A variety of different typemap methods are defined by the Perl module. For example, to convert a C integer back into a Perl object, you might define an "out" typemap like this:

%typemap(out) int {
    $result = sv_newmortal();
    set_setiv($result, (IV) $1);
    argvi++;
}

The following typemap methods are available:

%typemap(in)

Converts Perl5 object to input function arguments.

%typemap(out)

Converts function return value to a Perl5 value.

%typemap(varin)

Converts a Perl5 object to a global variable.

%typemap(varout)

Converts a global variable to a Perl5 object.

%typemap(freearg)

Cleans up a function argument after a function call

%typemap(argout)

Output argument handling

%typemap(ret)

Clean up return value from a function.

%typemap(memberin)

Setting of C++ member data (all languages).

%typemap(memberout)

Return of C++ member data (all languages).

%typemap(check)

Check value of input parameter.

33.7.3 Typemap variables

Within typemap code, a number of special variables prefaced with a $ may appear. A full list of variables can be found in the " Typemaps" chapter. This is a list of the most common variables:

$1

A C local variable corresponding to the actual type specified in the %typemap directive. For input values, this is a C local variable that's supposed to hold an argument value. For output values, this is the raw result that's supposed to be returned to Perl.

$input

A Perl object holding the value of an argument of variable value.

$result

A Perl object that holds the result to be returned to Perl.

$1_name

The parameter name that was matched.

$1_type

The actual C datatype matched by the typemap.

$1_ltype

An assignable version of the datatype matched by the typemap (a type that can appear on the left-hand-side of a C assignment operation). This type is stripped of qualifiers and may be an altered version of $1_type. All arguments and local variables in wrapper functions are declared using this type so that their values can be properly assigned.

$symname

The Perl name of the wrapper function being created.

33.7.4 Useful functions

When writing typemaps, it is necessary to work directly with Perl5 objects. This, unfortunately, can be a daunting task. Consult the "perlguts" man-page for all of the really ugly details. A short summary of commonly used functions is provided here for reference. It should be stressed that SWIG can be used quite effectively without knowing any of these details--especially now that there are typemap libraries that can already been written.

Perl Integer Functions

int   SvIV(SV *);
void  sv_setiv(SV *sv, IV value);
SV   *newSViv(IV value);
int   SvIOK(SV *);

Perl Floating Point Functions

double SvNV(SV *);
void   sv_setnv(SV *, double value);
SV    *newSVnv(double value);
int    SvNOK(SV *);

Perl String Functions

char     *SvPV(SV *, STRLEN len);
void      sv_setpv(SV *, char *val);
void      sv_setpvn(SV *, char *val, STRLEN len);
SV       *newSVpv(char *value, STRLEN len);
int       SvPOK(SV *);
void      sv_catpv(SV *, char *);
void      sv_catpvn(SV *, char *, STRLEN);

Perl References

void      sv_setref_pv(SV *, char *, void *ptr);
int       sv_isobject(SV *);
SV       *SvRV(SV *);
int       sv_isa(SV *, char *0;

33.8 Typemap Examples

This section includes a few examples of typemaps. For more examples, you might look at the files "perl5.swg" and "typemaps.i " in the SWIG library.

33.8.1 Converting a Perl5 array to a char **

A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Perl5 array reference to be used as a char ** datatype.

%module argv

// This tells SWIG to treat char ** as a special case
%typemap(in) char ** {
	AV *tempav;
	I32 len;
	int i;
	SV  **tv;
	if (!SvROK($input))
	    croak("Argument $argnum is not a reference.");
        if (SvTYPE(SvRV($input)) != SVt_PVAV)
	    croak("Argument $argnum is not an array.");
        tempav = (AV*)SvRV($input);
	len = av_len(tempav);
	$1 = (char **) malloc((len+2)*sizeof(char *));
	for (i = 0; i <= len; i++) {
	    tv = av_fetch(tempav, i, 0);	
	    $1[i] = (char *) SvPV(*tv,PL_na);
        }
	$1[i] = NULL;
};

// This cleans up the char ** array after the function call
%typemap(freearg) char ** {
	free($1);
}

// Creates a new Perl array and places a NULL-terminated char ** into it
%typemap(out) char ** {
	AV *myav;
	SV **svs;
	int i = 0,len = 0;
	/* Figure out how many elements we have */
	while ($1[len])
	   len++;
	svs = (SV **) malloc(len*sizeof(SV *));
	for (i = 0; i < len ; i++) {
	    svs[i] = sv_newmortal();
	    sv_setpv((SV*)svs[i],$1[i]);
	};
	myav =	av_make(len,svs);
	free(svs);
        $result = newRV_noinc((SV*)myav);
        sv_2mortal($result);
        argvi++;
}

// Now a few test functions
%inline %{
int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
         printf("argv[%d] = %s\n", i,argv[i]);
         i++;
    }
    return i;
}

// Returns a char ** list 
char **get_args() {
    static char *values[] = { "Dave", "Mike", "Susan", "John", "Michelle", 0};
    return &values[0];
}
%}

When this module is compiled, the wrapped C functions can be used in a Perl script as follows:

use argv;
@a = ("Dave", "Mike", "John", "Mary");           # Create an array of strings
argv::print_args(\@a);                           # Pass it to our C function
$b = argv::get_args();                           # Get array of strings from C
print @$b,"\n";                                  # Print it out

33.8.2 Return values

Return values are placed on the argument stack of each wrapper function. The current value of the argument stack pointer is contained in a variable argvi. Whenever a new output value is added, it is critical that this value be incremented. For multiple output values, the final value of argvi should be the total number of output values.

The total number of return values should not exceed the number of input values unless you explicitly extend the argument stack. This can be done using the EXTEND() macro as in:

%typemap(argout) int *OUTPUT {
	if (argvi >= items) {            
		EXTEND(sp,1);              /* Extend the stack by 1 object */
	}
	$result = sv_newmortal();
	sv_setiv($target,(IV) *($1));
	argvi++;
}

33.8.3 Returning values from arguments

Sometimes it is desirable for a function to return a value in one of its arguments. This example describes the implementation of the OUTPUT typemap.

%module return

// This tells SWIG to treat an double * argument with name 'OutDouble' as
// an output value.  

%typemap(argout) double *OUTPUT {
	$result = sv_newmortal();
	sv_setnv($result, *$input);
	argvi++;                     /* Increment return count -- important! */
}

// We don't care what the input value is. Ignore, but set to a temporary variable

%typemap(in,numinputs=0) double *OUTPUT(double junk) {
	$1 = &junk;
}

// Now a function to test it
%{
/* Returns the first two input arguments */
int multout(double a, double b, double *out1, double *out2) {
	*out1 = a;
	*out2 = b;
	return 0;
};
%}

// If we name both parameters OutDouble both will be output

int multout(double a, double b, double *OUTPUT, double *OUTPUT);
...

When this function is called, the output arguments are appended to the stack used to return results. This shows up an array in Perl. For example:

@r = multout(7,13);
print "multout(7,13) = @r\n";
($x,$y) = multout(7,13);

33.8.4 Accessing array structure members

Consider the following data structure:

#define SIZE  8
typedef struct {
    int   values[SIZE];
    ...
} Foo;

By default, SWIG doesn't know how to the handle the values structure member it's an array, not a pointer. In this case, SWIG makes the array member read-only. Reading will simply return a pointer to the first item in the array. To make the member writable, a "memberin" typemap can be used.

%typemap(memberin) int [SIZE] {
    int i;
    for (i = 0; i < SIZE; i++) {
        $1[i] = $input[i];
    }
}

Whenever a int [SIZE] member is encountered in a structure or class, this typemap provides a safe mechanism for setting its value.

As in the previous example, the typemap can be generalized for any dimension. For example:

%typemap(memberin) int [ANY] {
   int i;
   for (i = 0; i < $1_dim0; i++) {
      $1[i] = $input[i];
   }
}

When setting structure members, the input object is always assumed to be a C array of values that have already been converted from the target language. Because of this, the memberin typemap is almost always combined with the use of an "in" typemap. For example, the "in" typemap in the previous section would be used to convert an int[] array to C whereas the "memberin" typemap would be used to copy the converted array into a C data structure.

33.8.5 Turning Perl references into C pointers

A frequent confusion on the SWIG mailing list is errors caused by the mixing of Perl references and C pointers. For example, suppose you have a C function that modifies its arguments like this:

void add(double a, double b, double *c) {
	*c = a + b;
}

A common misinterpretation of this function is the following Perl script:

# Perl script
$a = 3.5;
$b = 7.5;
$c = 0.0;          # Output value
add($a,$b,\$c);    # Place result in c (Except that it doesn't work)

To make this work with a reference, you can use a typemap such as this:

%typemap(in) double * (double dvalue) {
  SV* tempsv;
  if (!SvROK($input)) {
    croak("expected a reference\n");
  }
  tempsv = SvRV($input);
  if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
    croak("expected a double reference\n");
  }
  dvalue = SvNV(tempsv);
  $1 = &dvalue;
}

%typemap(argout) double * {
  SV *tempsv;
  tempsv = SvRV($input);
  sv_setnv(tempsv, *$1);
}

Now, if you place this before the add function, you can do this:

$a = 3.5;
$b = 7.5;
$c = 0.0;
add($a,$b,\$c);            # Now it works!
print "$c\n";

33.8.6 Pointer handling

Occasionally, it might be necessary to convert pointer values that have been stored using the SWIG typed-pointer representation. To convert a pointer from Perl to C, the following function is used:

int SWIG_ConvertPtr(SV *obj, void **ptr, swig_type_info *ty, int flags)

Converts a Perl object obj to a C pointer. The result of the conversion is placed into the pointer located at ptr. ty is a SWIG type descriptor structure. flags is used to handle error checking and other aspects of conversion. flags is currently undefined and reserved for future expansion. Returns 0 on success and -1 on error.

void *SWIG_MakePtr(SV *obj, void *ptr, swig_type_info *ty, int flags)

Creates a new Perl pointer object. obj is a Perl SV that has been initialized to hold the result, ptr is the pointer to convert, ty is the SWIG type descriptor structure that describes the type, and flags is a flag that controls properties of the conversion. flags is currently undefined and reserved.

Both of these functions require the use of a special SWIG type-descriptor structure. This structure contains information about the mangled name of the datatype, type-equivalence information, as well as information about converting pointer values under C++ inheritance. For a type of Foo *, the type descriptor structure is usually accessed as follows:

Foo *f;
if (SWIG_ConvertPtr($input, (void **) &f, SWIGTYPE_p_Foo, 0) == -1) return NULL;

SV *sv = sv_newmortal();
SWIG_MakePtr(sv, f, SWIGTYPE_p_Foo, 0);

In a typemap, the type descriptor should always be accessed using the special typemap variable $1_descriptor. For example:

%typemap(in) Foo * {
   if ((SWIG_ConvertPtr($input,(void **) &$1, $1_descriptor,0)) == -1) return NULL;
}

If necessary, the descriptor for any type can be obtained using the $descriptor() macro in a typemap. For example:

%typemap(in) Foo * {
   if ((SWIG_ConvertPtr($input,(void **) &$1, $descriptor(Foo *), 0)) == -1) return NULL;
}

33.9 Proxy classes

Out of date. Needs update.

Using the low-level procedural interface, SWIG can also construct a high-level object oriented interface to C structures and C++ classes. This is done by constructing a Perl proxy class (also known as a shadow class) that provides an OO wrapper to the underlying code. This section describes the implementation details of the proxy interface.

33.9.1 Preliminaries

Proxy classes, are generated by default. If you want to turn them off, use the -noproxy command line option. For example:

$ swig -c++ -perl -noproxy example.i

When proxy classes are used, SWIG moves all of the low-level procedural wrappers to another package name. By default, this package is named 'modulec' where 'module' is the name of the module you provided with the %module directive. Then, in place of the original module, SWIG creates a collection of high-level Perl wrappers. In your scripts, you will use these high level wrappers. The wrappers, in turn, interact with the low-level procedural module.

33.9.2 Structure and class wrappers

Suppose you have the following SWIG interface file:

%module example
struct Vector {
	Vector(double x, double y, double z);
	~Vector();
	double x,y,z;
};

When wrapped, SWIG creates the following set of low-level accessor functions as described in previous sections.

Vector *new_Vector(double x, double y, double z);
void    delete_Vector(Vector *v);
double  Vector_x_get(Vector *v);
double  Vector_x_set(Vector *v, double value);
double  Vector_y_get(Vector *v);
double  Vector_y_set(Vector *v, double value);
double  Vector_z_get(Vector *v);
double  Vector_z_set(Vector *v, double value);

However, when proxy classes are enabled, these accessor functions are wrapped inside a Perl class like this:

package example::Vector;
@ISA = qw( example );
%OWNER = ();
%BLESSEDMEMBERS = ();

sub new () {
    my $self = shift;
    my @args = @_;
    $self = vectorc::new_Vector(@args);
    return undef if (!defined($self));
    bless $self, "example::Vector";
    $OWNER{$self} = 1;
    my %retval;
    tie %retval, "example::Vector", $self;
    return bless \%retval,"Vector";
}

sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
	 examplec::delete_Vector($self));
	 delete $OWNER{$self};
}

sub FETCH {
    my ($self,$field) = @_;
    my $member_func = "vectorc::Vector_${field}_get";
    my $val = &$member_func($self);
    if (exists $BLESSEDMEMBERS{$field}) {
        return undef if (!defined($val));
        my %retval;
        tie %retval,$BLESSEDMEMBERS{$field},$val;
        return bless \%retval, $BLESSEDMEMBERS{$field};
    }
    return $val;
}

sub STORE {
    my ($self,$field,$newval) = @_;
    my $member_func = "vectorc::Vector_${field}_set";
    if (exists $BLESSEDMEMBERS{$field}) {
        &$member_func($self,tied(%{$newval}));
    } else {
        &$member_func($self,$newval);
    }
}

Each structure or class is mapped into a Perl package of the same name. The C++ constructors and destructors are mapped into 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.

To use our new proxy class we can simply do the following:

# Perl code using Vector class
$v = new Vector(2,3,4);
$w = Vector->new(-1,-2,-3);

# Assignment of a single member
$v->{x} = 7.5;

# Assignment of all members
%$v = ( x=>3,
	 y=>9,
	 z=>-2);

# Reading members
$x = $v->{x};

# Destruction
$v->DESTROY();

33.9.3 Object Ownership

In order for proxy classes to work properly, it is necessary for Perl to manage some mechanism of object ownership. Here's the crux of the problem---suppose you had a function like this:

Vector *Vector_get(Vector *v, int index) {
	return &v[i];
}

This function takes a Vector pointer and returns a pointer to another Vector. Such a function might be used to manage arrays or lists of vectors (in C). Now contrast this function with the constructor for a Vector object:

Vector *new_Vector(double x, double y, double z) {
	Vector *v;
	v = new Vector(x,y,z);        // Call C++ constructor
	return v;
}

Both functions return a Vector, but the constructor is returning a brand-new Vector while the other function is returning a Vector that was already created (hopefully). In Perl, both vectors will be indistinguishable---clearly a problem considering that we would probably like the newly created Vector to be destroyed when we are done with it.

To manage these problems, each class contains two methods that access an internal hash table called %OWNER. This hash keeps a list of all of the objects that Perl knows that it has created. This happens in two cases: (1) when the constructor has been called, and (2) when a function implicitly creates a new object (as is done when SWIG needs to return a complex datatype by value). When the destructor is invoked, the Perl proxy class module checks the %OWNER hash to see if Perl created the object. If so, the C/C++ destructor is invoked. If not, we simply destroy the Perl object and leave the underlying C object alone (under the assumption that someone else must have created it).

This scheme works remarkably well in practice but it isn't foolproof. In fact, it will fail if you create a new C object in Perl, pass it on 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.

# Perl code to change ownership of an object
$v = new Vector(x,y,z);
$v->DISOWN();     

To acquire ownership of an object, the ACQUIRE method can be used.

# Given Perl ownership of a file
$u = Vector_get($v);
$u->ACQUIRE();

As always, a little care is in order. SWIG does not provide reference counting, garbage collection, or advanced features one might find in sophisticated languages.

33.9.4 Nested Objects

Suppose that we have a new object that looks like this:

struct Particle {
	Vector r;
	Vector v;
	Vector f;
	int	type;
}

In this case, the members of the structure are complex objects that have already been encapsulated in a Perl proxy class. To handle these correctly, we use the %BLESSEDMEMBERS hash which would look like this (along with some supporting code):

package Particle;
...
%BLESSEDMEMBERS = (
	r => `Vector',
	v => `Vector',
	f => `Vector',
);

When fetching members from the structure, %BLESSEDMEMBERS is checked. If the requested field is present, we create a tied-hash table and return it. If not, we just return the corresponding member unmodified.

This implementation allows us to operate on nested structures as follows:

# Perl access of nested structure
$p = new Particle();
$p->{f}->{x} = 0.0;
%${$p->{v}} = ( x=>0, y=>0, z=>0);         

33.9.5 Proxy Functions

When functions take arguments involving a complex object, it is sometimes necessary to write a proxy function. For example:

double dot_product(Vector *v1, Vector *v2);

Since Vector is an object already wrapped into a proxy class, we need to modify this function to accept arguments that are given in the form of tied hash tables. This is done by creating a Perl function like this:

sub dot_product {
    my @args = @_;
    $args[0] = tied(%{$args[0]});         # Get the real pointer values
    $args[1] = tied(%{$args[1]});
    my $result = vectorc::dot_product(@args);
    return $result;
}

This function replaces the original function, but operates in an identical manner.

33.9.6 Inheritance

Simple C++ inheritance is handled using the Perl @ISA array in each class package. For example, if you have the following interface file:

// shapes.i
// SWIG interface file for shapes class
%module shapes
%{
#include "shapes.h"
%}

class Shape {
public:
	virtual double area() = 0;
	virtual double perimeter() = 0;
	void    set_location(double x, double y);
};
class Circle : public Shape {
public:
	Circle(double radius);
	~Circle();
	double area();
	double perimeter();
};
class Square : public Shape {
public:
	Square(double size);
	~Square();
	double area();
	double perimeter();
}

The resulting, Perl wrapper class will create the following code:

Package Shape;
@ISA = (shapes);
...
Package Circle;
@ISA = (shapes Shape);
...
Package Square;
@ISA = (shapes Shape);

The @ISA array determines where to look for methods of a particular class. In this case, both the Circle and Square classes inherit functions from Shape so we'll want to look in the Shape base class for them. All classes also inherit from the top-level module shapes. This is because certain common operations needed to implement proxy classes are implemented only once and reused in the wrapper code for various classes and structures.

Since SWIG proxy classes are implemented in Perl, it is easy to subclass from any SWIG generated class. To do this, simply put the name of a SWIG class in the @ISA array for your new class. However, be forewarned that this is not a trivial problem. In particular, inheritance of data members is extremely tricky (and I'm not even sure if it really works).

33.9.7 Modifying the proxy methods

It is possible to override the SWIG generated proxy/shadow methods, using %feature("shadow"). It works like all the other %feature directives. Here is a simple example showing how to add some Perl debug code to the constructor:

/* Let's make the constructor of the class Square more verbose */
%feature("shadow") Square(double w)
%{
  sub new {
    my $pkg = shift;
    my $self = examplec::new_Square(@_);
    print STDERR "Constructed an @{[ref($self)]}\n";
    bless $self, $pkg if defined($self);
  }
%}

class Square {
public:
  Square(double w);
  ...
};

33.10 Adding additional Perl code

If writing support code in C isn't enough, it is also possible to write code in Perl. This code gets inserted in to the .pm file created by SWIG. One use of Perl code might be to supply a high-level interface to certain functions. For example:

void set_transform(Image *im, double x[4][4]);

...
/* Rewrite the high level interface to set_transform */
%perlcode %{
sub set_transform
{
  my ($im, $x) = @_;
  my $a = new_mat44();
  for (my $i = 0; $i < 4, $i++)
  {
    for (my $j = 0; $j < 4, $j++)
    {
      mat44_set($a, $i, $j, $x->[i][j])
      }
  }
  example.set_transform($im, $a);
  free_mat44($a);
}
%}

In this example, set_transform() provides a high-level Perl interface built on top of low-level helper functions. For example, this code now seems to work:

my $a =
  [[1,0,0,0],
   [0,1,0,0],
   [0,0,1,0],
   [0,0,0,1]];
set_transform($im, $a);

33.11 Cross language polymorphism

Proxy classes provide a more natural, object-oriented way to access extension classes. As described above, each proxy instance has an associated C++ instance, and method calls to the proxy are passed to the C++ instance transparently via C wrapper functions.

This arrangement is asymmetric in the sense that no corresponding mechanism exists to pass method calls down the inheritance chain from C++ to Perl. In particular, if a C++ class has been extended in Perl (by extending the proxy class), these extensions will not be visible from C++ code. Virtual method calls from C++ are thus not able access the lowest implementation in the inheritance chain.

Changes have been made to SWIG to address this problem and make the relationship between C++ classes and proxy classes more symmetric. To achieve this goal, new classes called directors are introduced at the bottom of the C++ inheritance chain. The job of the directors is to route method calls correctly, either to C++ implementations higher in the inheritance chain or to Perl implementations lower in the inheritance chain. The upshot is that C++ classes can be extended in Perl and from C++ these extensions look exactly like native C++ classes. Neither C++ code nor Perl code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

33.11.1 Enabling directors

The director feature is disabled by default. To use directors you must make two changes to the interface file. First, add the "directors" option to the %module directive, like this:

%module(directors="1") modulename

Without this option no director code will be generated. Second, you must use the %feature("director") directive to tell SWIG which classes and methods should get directors. The %feature directive can be applied globally, to specific classes, and to specific methods, like this:

// generate directors for all classes that have virtual methods
%feature("director");         

// generate directors for all virtual methods in class Foo
%feature("director") Foo;      

You can use the %feature("nodirector") directive to turn off directors for specific classes or methods. So for example,

%feature("director") Foo;
%feature("nodirector") Foo::bar;

will generate directors for all virtual methods of class Foo except bar().

Directors can also be generated implicitly through inheritance. In the following, class Bar will get a director class that handles the methods one() and two() (but not three()):

%feature("director") Foo;
class Foo {
public:
    Foo(int foo);
    virtual void one();
    virtual void two();
};

class Bar: public Foo {
public:
    virtual void three();
};

then at the Perl side you can define

use mymodule;

package MyFoo;
use base 'mymodule::Foo';

sub one {
  print "one from Perl\n";
}

33.11.2 Director classes

For each class that has directors enabled, SWIG generates a new class that derives from both the class in question and a special Swig::Director class. These new classes, referred to as director classes, can be loosely thought of as the C++ equivalent of the Perl proxy classes. The director classes store a pointer to their underlying Perl object and handle various issues related to object ownership.

For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). Thus all virtual method calls, whether they originate in C++ or in Perl via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate place" we mean the method that would have been called if the C++ base class and its extensions in Perl were seamlessly integrated. That seamless integration is exactly what the director classes provide, transparently skipping over all the messy extension API glue that binds the two languages together.

In reality, the "appropriate place" is one of only two possibilities: C++ or Perl. Once this decision is made, the rest is fairly easy. If the correct implementation is in C++, then the lowest implementation of the method in the C++ inheritance chain is called explicitly. If the correct implementation is in Perl, the Perl API is used to call the method of the underlying Perl object (after which the usual virtual method resolution in Perl automatically finds the right implementation).

Now how does the director decide which language should handle the method call? The basic rule is to handle the method in Perl, unless there's a good reason not to. The reason for this is simple: Perl has the most "extended" implementation of the method. This assertion is guaranteed, since at a minimum the Perl proxy class implements the method. If the method in question has been extended by a class derived from the proxy class, that extended implementation will execute exactly as it should. If not, the proxy class will route the method call into a C wrapper function, expecting that the method will be resolved in C++. The wrapper will call the virtual method of the C++ instance, and since the director extends this the call will end up right back in the director method. Now comes the "good reason not to" part. If the director method were to blindly call the Perl method again, it would get stuck in an infinite loop. We avoid this situation by adding special code to the C wrapper function that tells the director method to not do this. The C wrapper function compares the pointer to the Perl object that called the wrapper function to the pointer stored by the director. If these are the same, then the C wrapper function tells the director to resolve the method by calling up the C++ inheritance chain, preventing an infinite loop.

One more point needs to be made about the relationship between director classes and proxy classes. When a proxy class instance is created in Perl, SWIG creates an instance of the original C++ class. This is exactly what happens without directors and is true even if directors are enabled for the particular class in question. When a class derived from a proxy class is created, however, SWIG then creates an instance of the corresponding C++ director class. The reason for this difference is that user-defined subclasses may override or extend methods of the original class, so the director class is needed to route calls to these methods correctly. For unmodified proxy classes, all methods are ultimately implemented in C++ so there is no need for the extra overhead involved with routing the calls through Perl.

33.11.3 Ownership and object destruction

Memory management issues are slightly more complicated with directors than for proxy classes alone. Perl instances hold a pointer to the associated C++ director object, and the director in turn holds a pointer back to a Perl object. By default, proxy classes own their C++ director object and take care of deleting it when they are garbage collected.

This relationship can be reversed by calling the special DISOWN() method of the proxy class. After calling this method the director class increments the reference count of the Perl object. When the director class is deleted it decrements the reference count. Assuming no outstanding references to the Perl object remain, the Perl object will be destroyed at the same time. This is a good thing, since directors and proxies refer to each other and so must be created and destroyed together. Destroying one without destroying the other will likely cause your program to segfault.

Also note that due to the proxy implementation, the DESTROY() method on directors can be called for several reasons, many of which have little to do with the teardown of an object instance. To help disambiguate this, a second argument is added to the DESTROY() call when a C++ director object is being released. So, to avoid running your clean-up code when an object is not really going away, or after it has already been reclaimed, it is suggested that custom destructors in Perl subclasses looks something like:

sub DESTROY {
  my($self, $final) = @_;
  if($final) {
    # real teardown code
  }
  shift->SUPER::DESTROY(@_);
}

33.11.4 Exception unrolling

With directors routing method calls to Perl, and proxies routing them to C++, the handling of exceptions is an important concern. By default, the directors ignore exceptions that occur during method calls that are resolved in Perl. To handle such exceptions correctly, it is necessary to temporarily translate them into C++ exceptions. This can be done with the %feature("director:except") directive. The following code should suffice in most cases:

%feature("director:except") {
    if ($error != NULL) {
        throw Swig::DirectorMethodException();
    }
}

This code will check the Perl error state after each method call from a director into Perl, and throw a C++ exception if an error occurred. This exception can be caught in C++ to implement an error handler.

It may be the case that a method call originates in Perl, travels up to C++ through a proxy class, and then back into Perl via a director method. If an exception occurs in Perl at this point, it would be nice for that exception to find its way back to the original caller. This can be done by combining a normal %exception directive with the director:except handler shown above. Here is an example of a suitable exception handler:

%exception {
    try { $action }
    catch (Swig::DirectorException &e) { SWIG_fail; }
}

The class Swig::DirectorException used in this example is actually a base class of Swig::DirectorMethodException, so it will trap this exception. Because the Perl error state is still set when Swig::DirectorMethodException is thrown, Perl will register the exception as soon as the C wrapper function returns.

33.11.5 Overhead and code bloat

Enabling directors for a class will generate a new director method for every virtual method in the class' inheritance chain. This alone can generate a lot of code bloat for large hierarchies. Method arguments that require complex conversions to and from target language types can result in large director methods. For this reason it is recommended that you selectively enable directors only for specific classes that are likely to be extended in Perl and used in C++.

Compared to classes that do not use directors, the call routing in the director methods does add some overhead. In particular, at least one dynamic cast and one extra function call occurs per method call from Perl. Relative to the speed of Perl execution this is probably completely negligible. For worst case routing, a method call that ultimately resolves in C++ may take one extra detour through Perl in order to ensure that the method does not have an extended Perl implementation. This could result in a noticeable overhead in some cases.

Although directors make it natural to mix native C++ objects with Perl objects (as director objects) via a common base class pointer, one should be aware of the obvious fact that method calls to Perl objects will be much slower than calls to C++ objects. This situation can be optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in Perl.

33.11.6 Typemaps

Typemaps for input and output of most of the basic types from director classes have been written. These are roughly the reverse of the usual input and output typemaps used by the wrapper code. The typemap operation names are 'directorin', 'directorout', and 'directorargout'. The director code does not currently use any of the other kinds of typemaps. It is not clear at this point which kinds are appropriate and need to be supported.


34 SWIG and PHP

SWIG supports generating wrappers for PHP5. Support for PHP4 was removed in SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases, and won't even be patching critical security issues after 2008-08-08, so it doesn't make much sense for SWIG to continue to support PHP4 now. If you really need to continue to use PHP4, just stick with SWIG 1.3.36.

Currently any PHP5 release should work, but we don't regularly test with PHP < 5.3.

In this chapter, we discuss SWIG's support of PHP. The PHP module was extensively rewritten in release 1.3.26, and support for generating OO wrappers for PHP5 was added in 1.3.30. The PHP module now supports most of the features available in some of the other languages.

In order to use this module, you will need to have a copy of the PHP5 include files to compile the SWIG generated files. If you installed PHP from a binary package, you may need to install a "php-dev" or "php-devel" 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 will need either the php binary or the Apache php module. If you want to build your extension into php directly, you will need the complete PHP source tree available.

34.1 Generating PHP Extensions

To build a PHP extension, run swig using the -php option as follows:

swig -php example.i

This will produce 3 files example_wrap.c, php_example.h and example.php. The first file, example_wrap.c contains all of the C code needed to build a PHP extension. The second file, php_example.h contains the header information needed if you wish to statically link the extension into the php interpreter. The third file, example.php can be included by PHP scripts. It attempts to dynamically load the extension and contains extra php code specified in the interface file. If wrapping C++ code with PHP classes, it will also contain PHP5 class wrappers.

SWIG can generate PHP extensions from C++ libraries as well when given the -c++ option. The support for C++ is discussed in more detail in section 27.2.6.

The usual (and recommended) way is to build the extension as a separate dynamically loaded module (which is supported by all modern operating systems). You can then specify that this be loaded automatically in php.ini or load it explicitly for any script which needs it.

It is also possible to rebuild PHP from source so that your module is statically linked into the php executable/library. This is a lot more work, and also requires a full rebuild of PHP to update your module, and it doesn't play nicely with package system. We don't recommend this approach, or provide explicit support for it.

34.1.1 Building a loadable extension

To build your module as a dynamically loadable extension, use compilation commands like these (if you aren't using GCC, the commands will be different, and there may be some variation between platforms - these commands should at least work for Linux though):

	gcc `php-config --includes` -fpic -c example_wrap.c
	gcc -shared example_wrap.o -o example.so

34.1.2 Using PHP Extensions

To test the extension from a PHP script, you need to load it first. You can load it for every script by adding this line to the [PHP] section of php.ini:

	extension=/path/to/modulename.so

Alternatively, you can load it explicitly only for scripts which need it by adding this line to the start of each such PHP script::

	dl("/path/to/modulename.so");	// Load the module

SWIG also generates a php module, which attempts to do the dl() call for you:

	include("example.php");

34.2 Basic PHP interface

It is important to understand that PHP uses a single global namespace into which all symbols from extension modules are loaded. It is quite possible for names of symbols in one extension module to clash with other symbols unless care is taken to %rename them. At present SWIG doesn't have support for the namespace feature added in PHP 5.3.

34.2.1 Constants

These work in much the same way as in C/C++. Constants can be defined by using either the normal C pre-processor declarations, or the %constant SWIG directive. These will then be available from your PHP script as a PHP constant, (i.e. no dollar sign is needed to access them.) For example, with a swig interface file like this,

%module example

#define PI 3.14159

%constant int E  = 2.71828

you can access the constants in your PHP script like this,

include("example.php");

echo "PI = " . PI . "\n";

echo "E = " . E . "\n";

There's one peculiarity of how constants work in PHP which it is useful to note (this is not specific to SWIG though) - if you try to use an undeclared constant, PHP will issue a warning and then expand the constant to a string version of the constant's name. The warning will often be missed though as if you're using PHP in a webserver, it will probably end up in error.log or similar.

For example,

%module example

#define EASY_TO_MISPELL	0

accessed incorrectly in PHP,

include("example.php");

if(EASY_TO_MISPEL) {
	....
} else {
	....
}

The mis-spelled constant will become the string 'EASY_TO_MISPEL', which is treated as true by the if test, when the value of the intended constant would be treated as false!

34.2.2 Global Variables

Because PHP does not provide a mechanism to intercept access and assignment of global variables, global variables are supported through the use of automatically generated accessor functions.

%module example;

%inline %{
  double seki = 2;
  void print_seki() {
    zend_printf("seki is now %f\n",seki);
  }
%}

is accessed as follows:

include("example.php");
print seki_get();
seki_set( seki_get() * 2);	# The C variable is now 4.
print seki_get();

SWIG supports global variables of all C datatypes including pointers and complex objects. Additional types can be supported by using the varinit typemap.

SWIG honors the %immutable modifier by not generating code for the _set method. This provides read-only access to the variable from the php script. Attempting to access the _set method will result in a php fatal error because the function is undefined.

At this time SWIG does not support custom accessor methods.

34.2.3 Functions

C functions are converted into PHP functions. Default/optional arguments are also allowed. An interface file like this :

%module example
int foo(int a);
double bar(double, double b = 3.0);
...

Will be accessed in PHP like this :

include("example.php");
$a = foo(2);
$b = bar(3.5, -1.5);
$c = bar(3.5);		# Use default argument for 2nd parameter

34.2.4 Overloading

Although PHP does not support overloading functions natively, swig will generate dispatch functions which will use %typecheck typemaps to allow overloading. This dispatch function's operation and precedence is described in Wrapping Overloaded Functions and Methods.

34.2.5 Pointers and References

Pointers to C/C++ objects are represented as PHP resources, rather like MySQL connection handles.

There are multiple ways to wrap pointers to simple types. Given the following C method:

  void add( int *in1, int *in2, int *result);

One can include cpointer.i to generate PHP wrappers to int *.

%module example
%include "cpointer.i"
%pointer_functions(int,intp)

void add( int *in1, int *in2, int *result);

This will result in the following usage in PHP:

<?php

include("example.php");

$in1=copy_intp(3);
$in2=copy_intp(5);
$result=new_intp();

add( $in1, $in2, $result );

echo "The sum " . intp_value($in1) . " + " . intp_value($in2) . " = " . intp_value( $result) . "\n";
?>

An alternative would be to use the include typemaps.i which defines named typemaps for INPUT, OUTPUT and INOUT variables. One needs to either %apply the appropriate typemap or adjust the parameter names as appropriate.

%module example
%include "typemaps.i"

void add( int *INPUT, int *INPUT, int *OUTPUT);

This will result in the following usage in PHP:

<?php

include("example.php");

$in1 = 3;
$in2 = 5;
$result= add($in1,$in2);  # Note using variables for the input is unnecessary.

echo "The sum $in1 + $in2 = $result\n";
?>

Because PHP has a native concept of reference, it may seem more natural to the PHP developer to use references to pass pointers. To enable this, one needs to include phppointers.i which defines the named typemap REF.

Prior to SWIG 3.0, the REF typemaps relied on PHP's call-time pass-by-reference, which was deprecated in PHP 5.3 and removed in PHP 5.4. So if you use these REF typemaps, you should ensure that SWIG≥3.0 is used to generate wrappers from your interface file.

In case you write your own typemaps, SWIG supports an attribute called byref: if you set that, then SWIG will make sure that the generated wrapper function will want the input parameter as a reference.

%module example
%include "phppointers.i"

void add( int *REF, int *REF, int *REF);

This will result in the following usage in PHP:

<?php

include("example.php");

$in1 = 3;
$in2 = 5;
$result = 0;
add($in1,$in2,$result);

echo "The sum $in1 + $in2 = $result\n";
?>

It is important to note that a php variable which is NULL when passed by reference would end up passing a NULL pointer into the function. In PHP, an unassigned variable (i.e. where the first reference to the variable is not an assignment) is NULL. In the above example, if any of the three variables had not been assigned, a NULL pointer would have been passed into add. Depending on the implementation of the function, this may or may not be a good thing.

We chose to allow passing NULL pointers into functions because that is sometimes required in C libraries. A NULL pointer can be created in PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

34.2.6 Structures and C++ classes

SWIG defaults to wrapping C++ structs and classes with PHP classes - this is done by generating a PHP wrapper script which defines proxy classes which calls a set of flat functions which actually wrap the C++ class. You can disable this wrapper layer by passing the command-line option "-noproxy" in which case you'll just get the flat functions.

This interface file

%module vector

class Vector {
public:
	double x,y,z;
	Vector();
	~Vector();
	double magnitude();
};

struct Complex {
 double re, im;
};

Would be used in the following way from PHP5:

<?php
  require "vector.php";

  $v = new Vector();
  $v->x = 3;
  $v->y = 4;
  $v->z = 5;

  echo "Magnitude of ($v->x,$v->y,$v->z) = " . $v->magnitude() . "\n";

  $v = NULL;   # destructor called.

  $c = new Complex();

  $c->re = 0;
  $c->im = 0;

  # $c destructor called when $c goes out of scope.
?>

Member variables and methods are accessed using the -> operator.

34.2.6.1 Using -noproxy

The -noproxy option flattens the object structure and generates collections of named functions (these are the functions which the PHP5 class wrappers call). The above example results in the following PHP functions:

new_Vector();
Vector_x_set($obj,$d);
Vector_x_get($obj);
Vector_y_set($obj,$d);
Vector_y_get($obj);
Vector_z_set($obj,$d);
Vector_z_get($obj);
Vector_magnitude($obj);
new_Complex();
Complex_re_set($obj,$d);
Complex_re_get($obj);
Complex_im_set($obj,$d);
Complex_im_get($obj);

34.2.6.2 Constructors and Destructors

The constructor is called when new Object() (or new_Object() if using -noproxy) is used to create an instance of the object. If multiple constructors are defined for an object, function overloading will be used to determine which constructor to execute.

Because PHP uses reference counting to manage resources, simple assignment of one variable to another such as:

$ref = $v;

causes the symbol $ref to refer to the same underlying object as $v. This does not result in a call to the C++ copy constructor or copy assignment operator.

One can force execution of the copy constructor by using:

$o_copy = new Object($o);

Destructors are automatically called when all variables referencing the instance are reassigned or go out of scope. The destructor is not available to be called manually. To force a destructor to be called the programmer can either reassign the variable or call unset($v)

34.2.6.3 Static Member Variables

Static member variables in C++ are not wrapped as such in PHP as it does not appear to be possible to intercept accesses to such variables. Therefore, static member variables are wrapped using a class function with the same name, which returns the current value of the class variable. For example

%module example

class Ko {
	static int threats;
};

would be accessed in PHP as,

include("example.php");

echo "There have now been " . Ko::threats() . " threats\n";

To set the static member variable, pass the value as the argument to the class function, e.g.


Ko::threats(10);

echo "There have now been " . Ko::threats() . " threats\n";

34.2.6.4 Static Member Functions

Static member functions are supported in PHP using the class::function() syntax. For example

%module example
class Ko {
  static void threats();
};
would be executed in PHP as,
include("example.php");
Ko::threats();

34.2.7 PHP Pragmas, Startup and Shutdown code

To place PHP code in the generated "example.php" file one can use the code pragma. The code is inserted after loading the shared object.

%module example
%pragma(php) code="
# This code is inserted into example.php
echo \"example.php execution\\n\";
"

Results in the following in "example.php"

# This code is inserted into example.php
echo "example.php execution\n";

The include pragma is a short cut to add include statements to the example.php file.

%module example
%pragma(php) code="
include \"include.php\";
"
%pragma(php) include="include.php"   // equivalent.

The phpinfo pragma inserts code in the PHP_MINFO_FUNCTION which is called from PHP's phpinfo() function.

%module example;
%pragma(php) phpinfo="
  zend_printf("An example of PHP support through SWIG\n");
  php_info_print_table_start();
  php_info_print_table_header(2, \"Directive\", \"Value\");
  php_info_print_table_row(2, \"Example support\", \"enabled\");
  php_info_print_table_end();
"

To insert code into the PHP_MINIT_FUNCTION, one can use either %init or %minit.

%module example;
%init {
  zend_printf("Inserted into PHP_MINIT_FUNCTION\n");
}
%minit {
  zend_printf("Inserted into PHP_MINIT_FUNCTION\n");
}

To insert code into the PHP_MSHUTDOWN_FUNCTION, one can use either %shutdown or %mshutdown.

%module example;
%mshutdown {
  zend_printf("Inserted into PHP_MSHUTDOWN_FUNCTION\n");
}

The %rinit and %rshutdown statements are very similar but insert code into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.

34.3 Cross language polymorphism

Proxy classes provide a more natural, object-oriented way to access extension classes. As described above, each proxy instance has an associated C++ instance, and method calls to the proxy are passed to the C++ instance transparently via C wrapper functions.

This arrangement is asymmetric in the sense that no corresponding mechanism exists to pass method calls down the inheritance chain from C++ to PHP. In particular, if a C++ class has been extended in PHP (by extending the proxy class), these extensions will not be visible from C++ code. Virtual method calls from C++ are thus not able access the lowest implementation in the inheritance chain.

Changes have been made to SWIG 1.3.18 to address this problem and make the relationship between C++ classes and proxy classes more symmetric. To achieve this goal, new classes called directors are introduced at the bottom of the C++ inheritance chain. Support for generating PHP classes has been added in SWIG 1.3.40. The job of the directors is to route method calls correctly, either to C++ implementations higher in the inheritance chain or to PHP implementations lower in the inheritance chain. The upshot is that C++ classes can be extended in PHP and from C++ these extensions look exactly like native C++ classes. Neither C++ code nor PHP code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

34.3.1 Enabling directors

The director feature is disabled by default. To use directors you must make two changes to the interface file. First, add the "directors" option to the %module directive, like this:

%module(directors="1") modulename

Without this option no director code will be generated. Second, you must use the %feature("director") directive to tell SWIG which classes and methods should get directors. The %feature directive can be applied globally, to specific classes, and to specific methods, like this:

// generate directors for all classes that have virtual methods
%feature("director");         

// generate directors for all virtual methods in class Foo
%feature("director") Foo;      

You can use the %feature("nodirector") directive to turn off directors for specific classes or methods. So for example,

%feature("director") Foo;
%feature("nodirector") Foo::bar;

will generate directors for all virtual methods of class Foo except bar().

Directors can also be generated implicitly through inheritance. In the following, class Bar will get a director class that handles the methods one() and two() (but not three()):

%feature("director") Foo;
class Foo {
public:
    Foo(int foo);
    virtual void one();
    virtual void two();
};

class Bar: public Foo {
public:
    virtual void three();
};

then at the PHP side you can define

require("mymodule.php");

class MyFoo extends Foo {
  function one() {
     print "one from php\n";
  }
}

34.3.2 Director classes

For each class that has directors enabled, SWIG generates a new class that derives from both the class in question and a special Swig::Director class. These new classes, referred to as director classes, can be loosely thought of as the C++ equivalent of the PHP proxy classes. The director classes store a pointer to their underlying PHP object. Indeed, this is quite similar to the "_cPtr" and "thisown" members of the PHP proxy classes.

For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). Thus all virtual method calls, whether they originate in C++ or in PHP via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate place" we mean the method that would have been called if the C++ base class and its extensions in PHP were seamlessly integrated. That seamless integration is exactly what the director classes provide, transparently skipping over all the messy extension API glue that binds the two languages together.

In reality, the "appropriate place" is one of only two possibilities: C++ or PHP. Once this decision is made, the rest is fairly easy. If the correct implementation is in C++, then the lowest implementation of the method in the C++ inheritance chain is called explicitly. If the correct implementation is in PHP, the Zend API is used to call the method of the underlying PHP object (after which the usual virtual method resolution in PHP automatically finds the right implementation).

Now how does the director decide which language should handle the method call? The basic rule is to handle the method in PHP, unless there's a good reason not to. The reason for this is simple: PHP has the most "extended" implementation of the method. This assertion is guaranteed, since at a minimum the PHP proxy class implements the method. If the method in question has been extended by a class derived from the proxy class, that extended implementation will execute exactly as it should. If not, the proxy class will route the method call into a C wrapper function, expecting that the method will be resolved in C++. The wrapper will call the virtual method of the C++ instance, and since the director extends this the call will end up right back in the director method. Now comes the "good reason not to" part. If the director method were to blindly call the PHP method again, it would get stuck in an infinite loop. We avoid this situation by adding special code to the C wrapper function that tells the director method to not do this. The C wrapper function compares the called and the declaring class name of the given method. If these are not the same, then the C wrapper function tells the director to resolve the method by calling up the C++ inheritance chain, preventing an infinite loop.

One more point needs to be made about the relationship between director classes and proxy classes. When a proxy class instance is created in PHP, SWIG creates an instance of the original C++ class and assigns it to ->_cPtr. This is exactly what happens without directors and is true even if directors are enabled for the particular class in question. When a class derived from a proxy class is created, however, SWIG then creates an instance of the corresponding C++ director class. The reason for this difference is that user-defined subclasses may override or extend methods of the original class, so the director class is needed to route calls to these methods correctly. For unmodified proxy classes, all methods are ultimately implemented in C++ so there is no need for the extra overhead involved with routing the calls through PHP.

34.3.3 Ownership and object destruction

Memory management issues are slightly more complicated with directors than for proxy classes alone. PHP instances hold a pointer to the associated C++ director object, and the director in turn holds a pointer back to the PHP object. By default, proxy classes own their C++ director object and take care of deleting it when they are garbage collected.

This relationship can be reversed by calling the special ->thisown property of the proxy class. After setting this property to 0, the director class no longer destroys the PHP object. Assuming no outstanding references to the PHP object remain, the PHP object will be destroyed at the same time. This is a good thing, since directors and proxies refer to each other and so must be created and destroyed together. Destroying one without destroying the other will likely cause your program to segfault.

Here is an example:

class Foo {
public:
    ...
};
class FooContainer {
public:
    void addFoo(Foo *);
    ...
};

$c = new FooContainer();
$a = new Foo();
$a->thisown = 0;
$c->addFoo($a);

In this example, we are assuming that FooContainer will take care of deleting all the Foo pointers it contains at some point.

34.3.4 Exception unrolling

With directors routing method calls to PHP, and proxies routing them to C++, the handling of exceptions is an important concern. By default, the directors ignore exceptions that occur during method calls that are resolved in PHP. To handle such exceptions correctly, it is necessary to temporarily translate them into C++ exceptions. This can be done with the %feature("director:except") directive. The following code should suffice in most cases:

%feature("director:except") {
    if ($error == FAILURE) {
        throw Swig::DirectorMethodException();
    }
}

This code will check the PHP error state after each method call from a director into PHP, and throw a C++ exception if an error occurred. This exception can be caught in C++ to implement an error handler. Currently no information about the PHP error is stored in the Swig::DirectorMethodException object, but this will likely change in the future.

It may be the case that a method call originates in PHP, travels up to C++ through a proxy class, and then back into PHP via a director method. If an exception occurs in PHP at this point, it would be nice for that exception to find its way back to the original caller. This can be done by combining a normal %exception directive with the director:except handler shown above. Here is an example of a suitable exception handler:

%exception {
    try { $action }
    catch (Swig::DirectorException &e) { SWIG_fail; }
}

The class Swig::DirectorException used in this example is actually a base class of Swig::DirectorMethodException, so it will trap this exception. Because the PHP error state is still set when Swig::DirectorMethodException is thrown, PHP will register the exception as soon as the C wrapper function returns.

34.3.5 Overhead and code bloat

Enabling directors for a class will generate a new director method for every virtual method in the class' inheritance chain. This alone can generate a lot of code bloat for large hierarchies. Method arguments that require complex conversions to and from target language types can result in large director methods. For this reason it is recommended that you selectively enable directors only for specific classes that are likely to be extended in PHP and used in C++.

Compared to classes that do not use directors, the call routing in the director methods does add some overhead. In particular, at least one dynamic cast and one extra function call occurs per method call from PHP. Relative to the speed of PHP execution this is probably completely negligible. For worst case routing, a method call that ultimately resolves in C++ may take one extra detour through PHP in order to ensure that the method does not have an extended PHP implementation. This could result in a noticeable overhead in some cases.

Although directors make it natural to mix native C++ objects with PHP objects (as director objects) via a common base class pointer, one should be aware of the obvious fact that method calls to PHP objects will be much slower than calls to C++ objects. This situation can be optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in PHP.

34.3.6 Typemaps

Typemaps for input and output of most of the basic types from director classes have been written. These are roughly the reverse of the usual input and output typemaps used by the wrapper code. The typemap operation names are 'directorin', 'directorout', and 'directorargout'. The director code does not currently use any of the other kinds of typemaps. It is not clear at this point which kinds are appropriate and need to be supported.

34.3.7 Miscellaneous

Director typemaps for STL classes are mostly in place, and hence you should be able to use std::string, etc., as you would any other type.


35 SWIG and Pike

This chapter describes SWIG support for Pike. As of this writing, the SWIG Pike module is still under development and is not considered ready for prime time. The Pike module is being developed against the Pike 7.4.10 release and may not be compatible with previous versions of Pike.

This chapter covers most SWIG features, but certain low-level details are covered in less depth than in earlier chapters. At the very least, make sure you read the "SWIG Basics" chapter.

35.1 Preliminaries

35.1.1 Running SWIG

Suppose that you defined a SWIG module such as the following:

%module example


%{
#include "example.h"
%}

int fact(int n);

To build a C extension module for Pike, run SWIG using the -pike option :

$ swig -pike example.i

If you're building a C++ extension, be sure to add the -c++ option:

$ swig -c++ -pike example.i

This creates a single source file named example_wrap.c (or example_wrap.cxx, if you ran SWIG with the -c++ option). The SWIG-generated source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.

The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option:

$ swig -pike -o pseudonym.c example.i

35.1.2 Getting the right header files

In order to compile the C/C++ wrappers, the compiler needs to know the path to the Pike header files. These files are usually contained in a directory such as

/usr/local/pike/7.4.10/include/pike

There doesn't seem to be any way to get Pike itself to reveal the location of these files, so you may need to hunt around for them. You're looking for files with the names global.h, program.h and so on.

35.1.3 Using your module

To use your module, simply use Pike's import statement:

$ pike
Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend)
> import example;
> fact(4);
(1) Result: 24

35.2 Basic C/C++ Mapping

35.2.1 Modules

All of the code for a given SWIG module is wrapped into a single Pike module. Since the name of the shared library that implements your module ultimately determines the module's name (as far as Pike is concerned), SWIG's %module directive doesn't really have any significance.

35.2.2 Functions

Global functions are wrapped as new Pike built-in functions. For example,

%module example

int fact(int n);

creates a new built-in function example.fact(n) that works exactly as you'd expect it to:

> import example;
> fact(4);
(1) Result: 24

35.2.3 Global variables

Global variables are currently wrapped as a pair of functions, one to get the current value of the variable and another to set it. For example, the declaration

%module example

double Foo;

will result in two functions, Foo_get() and Foo_set() :

> import example;
> Foo_get();
(1) Result: 3.000000
> Foo_set(3.14159);
(2) Result: 0
> Foo_get();
(3) Result: 3.141590

35.2.4 Constants and enumerated types

Enumerated types in C/C++ declarations are wrapped as Pike constants, not as Pike enums.

35.2.5 Constructors and Destructors

Constructors are wrapped as create() methods, and destructors are wrapped as destroy() methods, for Pike classes.

35.2.6 Static Members

Since Pike doesn't support static methods or data for Pike classes, static member functions in your C++ classes are wrapped as regular functions and static member variables are wrapped as pairs of functions (one to get the value of the static member variable, and another to set it). The names of these functions are prepended with the name of the class. For example, given this C++ class declaration:

class Shape
{
public:
    static void print();
    static int nshapes;
};

SWIG will generate a Shape_print() method that invokes the static Shape::print() member function, as well as a pair of methods, Shape_nshapes_get() and Shape_nshapes_set(), to get and set the value of Shape::nshapes.


36 SWIG and Python

Caution: This chapter is under repair!

This chapter describes SWIG's support of Python. SWIG is compatible with most recent Python versions including Python 3.0 and Python 2.6, as well as older versions dating back to Python 2.0. For the best results, consider using Python 2.3 or newer.

This chapter covers most SWIG features, but certain low-level details are covered in less depth than in earlier chapters. At the very least, make sure you read the "SWIG Basics" chapter.

36.1 Overview

To build Python extension modules, SWIG uses a layered approach in which parts of the extension module are defined in C and other parts are defined in Python. The C layer contains low-level wrappers whereas Python code is used to define high-level features.

This layered approach recognizes the fact that certain aspects of extension building are better accomplished in each language (instead of trying to do everything in C or C++). Furthermore, by generating code in both languages, you get a lot more flexibility since you can enhance the extension module with support code in either language.

In describing the Python interface, this chapter starts by covering the basics of configuration, compiling, and installing Python modules. Next, the Python interface to common C and C++ programming features is described. Advanced customization features such as typemaps are then described followed by a discussion of low-level implementation details.

36.2 Preliminaries

36.2.1 Running SWIG

Suppose that you defined a SWIG module such as the following:

/* File: example.i */
%module example

%{
#define SWIG_FILE_WITH_INIT
#include "example.h"
%}

int fact(int n);

The #define SWIG_FILE_WITH_INIT line inserts a macro that specifies that the resulting C file should be built as a python extension, inserting the module init code. This .i file wraps the following simple C file:

/* File: example.c */

#include "example.h"

int fact(int n) {
    if (n < 0){ /* This should probably return an error, but this is simpler */
        return 0;
    }
    if (n == 0) {
        return 1;
    }
    else {
        /* testing for overflow would be a good idea here */
        return n * fact(n-1);
    }
}

With the header file:

/* File: example.h */

int fact(int n);

To build a Python module, run SWIG using the -python option:

$ swig -python example.i

If building a C++ extension, add the -c++ option:

$ swig -c++ -python example.i

This creates two different files; a C/C++ source file example_wrap.c or example_wrap.cxx and a Python source file example.py. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module. The Python source file contains high-level support code. This is the file that you will import to use the module.

The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The name of the Python file is derived from the module name specified with %module. If the module name is example, then a file example.py is created.

The following sections have further practical examples and details on how you might go about compiling and using the generated files.

36.2.2 Using distutils

The preferred approach to building an extension module for python is to compile it with distutils, which comes with all recent versions of python (Distutils Docs).

Distutils takes care of making sure that your extension is built with all the correct flags, headers, etc. for the version of Python it is run with. Distutils will compile your extension into a shared object file or DLL (.so on Linux, .pyd on Windows, etc). In addition, distutils can handle installing your package into site-packages, if that is desired. A configuration file (conventionally called: setup.py) describes the extension (and related python modules). The distutils will then generate all the right compiler directives to build it for you.

Here is a sample setup.py file for the above example:

#!/usr/bin/env python

"""
setup.py file for SWIG example
"""

from distutils.core import setup, Extension


example_module = Extension('_example',
                           sources=['example_wrap.c', 'example.c'],
                           )

setup (name = 'example',
       version = '0.1',
       author      = "SWIG Docs",
       description = """Simple swig example from docs""",
       ext_modules = [example_module],
       py_modules = ["example"],
       )

In this example, the line: example_module = Extension(....) creates an Extension module object, defining the name as _example , and using the source code files: example_wrap.c, generated by swig, and example.c, your original c source. The swig (and other python extension modules) tradition is for the compiled extension to have the name of the python portion, prefixed by an underscore. If the name of your python module is "example.py", then the name of the corresponding object file will be"_example.so"

The setup call then sets up distutils to build your package, defining some meta data, and passing in your extension module object. Once this is saved as setup.py, you can build your extension with these commands:

$ swig -python example.i
$ python setup.py build_ext --inplace

And a .so, or .pyd or... will be created for you. It will build a version that matches the python that you run the command with. Taking apart the command line:

  • python -- the version of python you want to build for
  • setup.py -- the name of your setup script (it can be called anything, but setup.py is the tradition)
  • build_ext -- telling distutils to build extensions
  • --inplace -- this tells distutils to put the extension lib in the current dir. Otherwise, it will put it inside a build hierarchy, and you'd have to move it to use it.

The distutils have many other features, consult the python distutils docs for details.

This same approach works on all platforms if the appropriate compiler is installed. (it can even build extensions to the standard Windows Python using MingGW)

36.2.3 Hand compiling a dynamic module

While the preferred approach to building an extension module is to use the distutils, some people like to integrate building extensions with a larger build system, and thus may wish to compile their modules without the distutils. To do this, you need to compile your program using commands like this (shown for Linux):

$ swig -python example.i
$ gcc -O2 -fPIC -c example.c
$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/include/python2.5
$ gcc -shared example.o example_wrap.o -o _example.so

The exact commands for doing this vary from platform to platform. However, SWIG tries to guess the right options when it is installed. Therefore, you may want to start with one of the examples in the SWIG/Examples/python directory. If that doesn't work, you will need to read the man-pages for your compiler and linker to get the right set of options. You might also check the SWIG Wiki for additional information.

When linking the module, the name of the output file has to match the name of the module prefixed by an underscore. If the name of your module is "example", then the name of the corresponding object file should be "_example.so" or "_examplemodule.so ". The name of the module is specified using the %module directive or the -module command line option.

Compatibility Note: In SWIG-1.3.13 and earlier releases, module names did not include the leading underscore. This is because modules were normally created as C-only extensions without the extra Python support file (instead, creating Python code was supported as an optional feature). This has been changed in SWIG-1.3.14 and is consistent with other Python extension modules. For example, the socket module actually consists of two files; socket.py and _socket.so. Many other built-in Python modules follow a similar convention.

36.2.4 Static linking

An alternative approach to dynamic linking is to rebuild the Python interpreter with your extension module added to it. In the past, this approach was sometimes necessary due to limitations in dynamic loading support on certain machines. However, the situation has improved greatly over the last few years and you should not consider this approach unless there is really no other option.

The usual procedure for adding a new module to Python involves finding the Python source, adding an entry to the Modules/Setup file, and rebuilding the interpreter using the Python Makefile. However, newer Python versions have changed the build process. You may need to edit the 'setup.py' file in the Python distribution instead.

In earlier versions of SWIG, the embed.i library file could be used to rebuild the interpreter. For example:

%module example

%inline %{
extern int fact(int);
extern int mod(int, int);
extern double My_variable;
%}

%include "embed.i"       // Include code for a static version of Python

The embed.i library file includes supporting code that contains everything needed to rebuild Python. To rebuild the interpreter, you simply do something like this:

$ swig -python example.i
$ gcc example.c example_wrap.c \
        -Xlinker -export-dynamic \
        -DHAVE_CONFIG_H -I/usr/local/include/python2.1 \
	-I/usr/local/lib/python2.1/config \
	-L/usr/local/lib/python2.1/config -lpython2.1 -lm -ldl \
	-o mypython

You will need to supply the same libraries that were used to build Python the first time. This may include system libraries such as -lsocket, -lnsl, and -lpthread. Assuming this actually works, the new version of Python should be identical to the default version except that your extension module will be a built-in part of the interpreter.

Comment: In practice, you should probably try to avoid static linking if possible. Some programmers may be inclined to use static linking in the interest of getting better performance. However, the performance gained by static linking tends to be rather minimal in most situations (and quite frankly not worth the extra hassle in the opinion of this author).

Compatibility note: The embed.i library file is deprecated and has not been maintained for several years. Even though it appears to "work" with Python 2.1, no future support is guaranteed. If using static linking, you might want to rely on a different approach (perhaps using distutils).

36.2.5 Using your module

To use your module, simply use the Python import statement. If all goes well, you will be able to this:

$ python
>>> import example
>>> example.fact(4)
24
>>>

A common error received by first-time users is the following:

>>> import example
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "example.py", line 2, in ?
    import _example
ImportError: No module named _example

If you get this message, it means that you either forgot to compile the wrapper code into an extension module or you didn't give the extension module the right name. Make sure that you compiled the wrappers into a module called _example.so. And don't forget the leading underscore (_).

Another possible error is the following:

>>> import example
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: dynamic module does not define init function (init_example)
>>>                                                               

This error is almost always caused when a bad name is given to the shared object file. For example, if you created a file example.so instead of _example.so you would get this error. Alternatively, this error could arise if the name of the module is inconsistent with the module name supplied with the %module directive. Double-check the interface to make sure the module name and the shared object filename match. Another possible cause of this error is forgetting to link the SWIG-generated wrapper code with the rest of your application when creating the extension module.

Another common error is something similar to the following:

Traceback (most recent call last):
  File "example.py", line 3, in ?
    import example
ImportError: ./_example.so: undefined symbol: fact

This error usually indicates that you forgot to include some object files or libraries in the linking of the shared library file. Make sure you compile both the SWIG wrapper file and your original program into a shared library file. Make sure you pass all of the required libraries to the linker.

Sometimes unresolved symbols occur because a wrapper has been created for a function that doesn't actually exist in a library. This usually occurs when a header file includes a declaration for a function that was never actually implemented or it was removed from a library without updating the header file. To fix this, you can either edit the SWIG input file to remove the offending declaration or you can use the %ignore directive to ignore the declaration.

Finally, suppose that your extension module is linked with another library like this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -o _example.so

If the foo library is compiled as a shared library, you might encounter the following problem when you try to use your module:

>>> import example
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: libfoo.so: cannot open shared object file: No such file or directory
>>>                 

This error is generated because the dynamic linker can't locate the libfoo.so library. When shared libraries are loaded, the system normally only checks a few standard locations such as /usr/lib and /usr/local/lib. To fix this problem, there are several things you can do. First, you can recompile your extension module with extra path information. For example, on Linux you can do this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -Xlinker -rpath /home/beazley/projects/lib  \
      -o _example.so

Alternatively, you can set the LD_LIBRARY_PATH environment variable to include the directory with your shared libraries. If setting LD_LIBRARY_PATH, be aware that setting this variable can introduce a noticeable performance impact on all other applications that you run. To set it only for Python, you might want to do this instead:

$ env LD_LIBRARY_PATH=/home/beazley/projects/lib python

Finally, you can use a command such as ldconfig (Linux) or crle (Solaris) to add additional search paths to the default system configuration (this requires root access and you will need to read the man pages).

36.2.6 Compilation of C++ extensions

Compilation of C++ extensions has traditionally been a tricky problem. Since the Python interpreter is written in C, you need to take steps to make sure C++ is properly initialized and that modules are compiled correctly. This should be a non-issue if you're using distutils, as it takes care of all that for you. The following is included for historical reasons, and in case you need to compile on your own.

On most machines, C++ extension modules should be linked using the C++ compiler. For example:

$ swig -c++ -python example.i
$ g++ -O2 -fPIC -c example.cxx
$ g++ -O2 -fPIC -c example_wrap.cxx -I/usr/local/include/python2.5
$ g++ -shared example.o example_wrap.o -o _example.so

The -fPIC option tells GCC to generate position-independent code (PIC) which is required for most architectures (it's not vital on x86, but still a good idea as it allows code pages from the library to be shared between processes). Other compilers may need a different option specified instead of -fPIC.

In addition to this, you may need to include additional library files to make it work. For example, if you are using the Sun C++ compiler on Solaris, you often need to add an extra library -lCrun like this:

$ swig -c++ -python example.i
$ CC -c example.cxx
$ CC -c example_wrap.cxx -I/usr/local/include/python2.5
$ CC -G example.o example_wrap.o -L/opt/SUNWspro/lib -o _example.so -lCrun

Of course, the extra libraries to use are completely non-portable---you will probably need to do some experimentation.

Sometimes people have suggested that it is necessary to relink the Python interpreter using the C++ compiler to make C++ extension modules work. In the experience of this author, this has never actually appeared to be necessary. Relinking the interpreter with C++ really only includes the special run-time libraries described above---as long as you link your extension modules with these libraries, it should not be necessary to rebuild Python.

If you aren't entirely sure about the linking of a C++ extension, you might look at an existing C++ program. On many Unix machines, the ldd command will list library dependencies. This should give you some clues about what you might have to include when you link your extension module. For example:

$ ldd swig
        libstdc++-libc6.1-1.so.2 => /usr/lib/libstdc++-libc6.1-1.so.2 (0x40019000)
        libm.so.6 => /lib/libm.so.6 (0x4005b000)
        libc.so.6 => /lib/libc.so.6 (0x40077000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

As a final complication, a major weakness of C++ is that it does not define any sort of standard for binary linking of libraries. This means that C++ code compiled by different compilers will not link together properly as libraries nor is the memory layout of classes and data structures implemented in any kind of portable manner. In a monolithic C++ program, this problem may be unnoticed. However, in Python, it is possible for different extension modules to be compiled with different C++ compilers. As long as these modules are self-contained, this probably won't matter. However, if these modules start sharing data, you will need to take steps to avoid segmentation faults and other erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

36.2.7 Compiling for 64-bit platforms

On platforms that support 64-bit applications (Solaris, Irix, etc.), special care is required when building extension modules. On these machines, 64-bit applications are compiled and linked using a different set of compiler/linker options. In addition, it is not generally possible to mix 32-bit and 64-bit code together in the same application.

To utilize 64-bits, the Python executable will need to be recompiled as a 64-bit application. In addition, all libraries, wrapper code, and every other part of your application will need to be compiled for 64-bits. If you plan to use other third-party extension modules, they will also have to be recompiled as 64-bit extensions.

If you are wrapping commercial software for which you have no source code, you will be forced to use the same linking standard as used by that software. This may prevent the use of 64-bit extensions. It may also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

On the Linux x86_64 platform (Opteron or EM64T), besides of the required compiler option -fPIC discussed above, you will need to be careful about the libraries you link with or the library path you use. In general, a Linux distribution will have two set of libraries, one for native x86_64 programs (under /usr/lib64), and another for 32 bits compatibility (under /usr/lib). Also, the compiler options -m32 and -m64 allow you to choose the desired binary format for your python extension.

36.2.8 Building Python Extensions under Windows

Building a SWIG extension to Python under Windows is roughly similar to the process used with Unix. Using the distutils, it is essentially identical. If you have the same version of the MS compiler that Python was built with (the python2.4 and python2.5 distributed by python.org are built with Visual Studio 2003), the standard python setup.py build should just work.

As of python2.5, the distutils support building extensions with MingGW out of the box. Following the instruction here: Building Python extensions for Windows with only free tools should get you started.

If you need to build it on your own, the following notes are provided:

You will need to create a DLL that can be loaded into the interpreter. This section briefly describes the use of SWIG with Microsoft Visual C++. As a starting point, many of SWIG's examples include project files (.dsp files) for Visual C++ 6. These can be opened by more recent versions of Visual Studio. You might want to take a quick look at these examples in addition to reading this section.

In Developer Studio, SWIG should be invoked as a custom build option. This is usually done as follows:

  • Open up a new workspace and use the AppWizard to select a DLL project.
  • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (ie. example_wrap.c). Note : If using C++, choose a different suffix for the wrapper file such as example_wrap.cxx. Don't worry if the wrapper file doesn't exist yet--Developer Studio keeps a reference to it.
  • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
  • Enter "SWIG" in the description field.
  • Enter "swig -python -o $(ProjDir)\$(InputName)_wrap.c $(InputPath)" in the "Build command(s) field"
  • Enter "$(ProjDir)\$(InputName)_wrap.c" in the "Output files(s) field".
  • Next, select the settings for the entire project and go to "C++:Preprocessor". Add the include directories for your Python installation under "Additional include directories".
  • Define the symbol __WIN32__ under preprocessor options.
  • Finally, select the settings for the entire project and go to "Link Options". Add the Python library file to your link libraries. For example "python21.lib". Also, set the name of the output file to match the name of your Python module, ie. _example.pyd - Note that _example.dll also worked with Python-2.4 and earlier.
  • Build your project.

If all went well, SWIG will be automatically invoked whenever you build your project. Any changes made to the interface file will result in SWIG being automatically executed to produce a new version of the wrapper file.

To run your new Python extension, simply run Python and use the import command as normal. For example :

$ python
>>> import example
>>> print example.fact(4)
24
>>>

If you get an ImportError exception when importing the module, you may have forgotten to include additional library files when you built your module. If you get an access violation or some kind of general protection fault immediately upon import, you have a more serious problem. This is often caused by linking your extension module against the wrong set of Win32 debug or thread libraries. You will have to fiddle around with the build options of project to try and track this down.

A 'Debug' build of the wrappers requires a debug build of the Python interpreter. This normally requires building the Python interpreter from source, which is not a job for the feint-hearted. Alternatively you can use the 'Release' build of the Python interpreter with a 'Debug' build of your wrappers by defining the SWIG_PYTHON_INTERPRETER_NO_DEBUG symbol under the preprocessor options. Or you can ensure this macro is defined at the beginning of the wrapper code using the following in your interface file, where _MSC_VER ensures it is only used by the Visual Studio compiler:

%begin %{
#ifdef _MSC_VER
#define SWIG_PYTHON_INTERPRETER_NO_DEBUG
#endif
%}

Some users have reported success in building extension modules using Cygwin and other compilers. However, the problem of building usable DLLs with these compilers tends to be rather problematic. For the latest information, you may want to consult the SWIG Wiki.

36.3 A tour of basic C/C++ wrapping

By default, SWIG tries to build a very natural Python interface to your C/C++ code. Functions are wrapped as functions, classes are wrapped as classes, and so forth. This section briefly covers the essential aspects of this wrapping.

36.3.1 Modules

The SWIG %module directive specifies the name of the Python module. If you specify `%module example', then everything is wrapped into a Python 'example' module. Underneath the covers, this module consists of a Python source file example.py and a low-level extension module _example.so. When choosing a module name, make sure you don't use the same name as a built-in Python command or standard module name.

36.3.2 Functions

Global functions are wrapped as new Python built-in functions. For example,

%module example
int fact(int n);

creates a built-in function example.fact(n) that works exactly like you think it does:

>>> import example
>>> print example.fact(4)
24
>>>

36.3.3 Global variables

C/C++ global variables are fully supported by SWIG. However, the underlying mechanism is somewhat different than you might expect due to the way that Python assignment works. When you type the following in Python

a = 3.4

"a" becomes a name for an object containing the value 3.4. If you later type

b = a

then "a" and "b" are both names for the object containing the value 3.4. Thus, there is only one object containing 3.4 and "a" and "b" are both names that refer to it. This is quite different than C where a variable name refers to a memory location in which a value is stored (and assignment copies data into that location). Because of this, there is no direct way to map variable assignment in C to variable assignment in Python.

To provide access to C global variables, SWIG creates a special object called `cvar' that is added to each SWIG generated module. Global variables are then accessed as attributes of this object. For example, consider this interface

// SWIG interface file with global variables
%module example
...
%inline %{
extern int My_variable;
extern double density;
%}
...

Now look at the Python interface:

>>> import example
>>> # Print out value of a C global variable
>>> print example.cvar.My_variable
4
>>> # Set the value of a C global variable
>>> example.cvar.density = 0.8442
>>> # Use in a math operation
>>> example.cvar.density = example.cvar.density*1.10

If you make an error in variable assignment, you will receive an error message. For example:

>>> example.cvar.density = "Hello"
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: C variable 'density (double )'
>>> 

If a variable is declared as const, it is wrapped as a read-only variable. Attempts to modify its value will result in an error.

To make ordinary variables read-only, you can use the %immutable directive. For example:

%{
extern char *path;
%}
%immutable;
extern char *path;
%mutable;

The %immutable directive stays in effect until it is explicitly disabled or cleared using %mutable. See the Creating read-only variables section for further details.

If you just want to make a specific variable immutable, supply a declaration name. For example:

%{
extern char *path;
%}
%immutable path;
...
extern char *path;      // Read-only (due to %immutable)

If you would like to access variables using a name other than " cvar", it can be changed using the -globals option :

$ swig -python -globals myvar example.i

Some care is in order when importing multiple SWIG modules. If you use the "from <file> import *" style of importing, you will get a name clash on the variable `cvar' and you will only be able to access global variables from the last module loaded. To prevent this, you might consider renaming cvar or making it private to the module by giving it a name that starts with a leading underscore. SWIG does not create cvar if there are no global variables in a module.

36.3.4 Constants and enums

C/C++ constants are installed as Python objects containing the appropriate value. To create a constant, use #define, enum , or the %constant directive. For example:

#define PI 3.14159
#define VERSION "1.0"

enum Beverage { ALE, LAGER, STOUT, PILSNER };

%constant int FOO = 42;
%constant const char *path = "/usr/local";

For enums, make sure that the definition of the enumeration actually appears in a header file or in the wrapper file somehow---if you just stick an enum in a SWIG interface without also telling the C compiler about it, the wrapper code won't compile.

Note: declarations declared as const are wrapped as read-only variables and will be accessed using the cvar object described in the previous section. They are not wrapped as constants. For further discussion about this, see the SWIG Basics chapter.

Constants are not guaranteed to remain constant in Python---the name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

36.3.5 Pointers

C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Here is a rather simple interface:

%module example

FILE *fopen(const char *filename, const char *mode);
int fputs(const char *, FILE *);
int fclose(FILE *);

When wrapped, you will be able to use the functions in a natural way from Python. For example:

>>> import example
>>> f = example.fopen("junk","w")
>>> example.fputs("Hello World\n", f)
>>> example.fclose(f)

If this makes you uneasy, rest assured that there is no deep magic involved. Underneath the covers, pointers to C/C++ objects are simply represented as opaque values using an especial python container object:

>>> print f
<Swig Object of type 'FILE *' at 0xb7d6f470>

This pointer value can be freely passed around to different C functions that expect to receive an object of type FILE *. The only thing you can't do is dereference the pointer from Python. Of course, that isn't much of a concern in this example.

In older versions of SWIG (1.3.22 or older), pointers were represented using a plain string object. If you have an old package that still requires that representation, or you just feel nostalgic, you can always retrieve it by casting the pointer object to a string:

>>> print str(f)
_c0671108_p_FILE

Also, if you need to pass the raw pointer value to some external python library, you can do it by casting the pointer object to an integer:

>>> print int(f)
135833352

However, the inverse operation is not possible, i.e., you can't build a SWIG pointer object from a raw integer value.

Note also that the '0' or NULL pointer is always represented by None, no matter what type swig is addressing. In the previous example, you can call:

>>> example.fclose(None)

and that will be equivalent to the following, but not really useful, C code:

FILE *f = NULL;
fclose(f);

As much as you might be inclined to modify a pointer value directly from Python, don't. The hexadecimal encoding is not necessarily the same as the logical memory address of the underlying object. Instead it is the raw byte encoding of the pointer value. The encoding will vary depending on the native byte-ordering of the platform (i.e., big-endian vs. little-endian). Similarly, don't try to manually cast a pointer to a new type by simply replacing the type-string. This may not work like you expect, it is particularly dangerous when casting C++ objects. If you need to cast a pointer or change its value, consider writing some helper functions instead. For example:

%inline %{
/* C-style cast */
Bar *FooToBar(Foo *f) {
   return (Bar *) f;
}

/* C++-style cast */
Foo *BarToFoo(Bar *b) {
   return dynamic_cast<Foo*>(b);
}

Foo *IncrFoo(Foo *f, int i) {
    return f+i;
}
%}

Also, if working with C++, you should always try to use the new C++ style casts. For example, in the above code, the C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

36.3.6 Structures

If you wrap a C structure, it is wrapped by a Python class. This provides a very natural interface. For example,

struct Vector {
	double x,y,z;
};

is used as follows:

>>> v = example.Vector()
>>> v.x = 3.5
>>> v.y = 7.2
>>> print v.x, v.y, v.z
7.8 -4.5 0.0
>>> 

Similar access is provided for unions and the data members of C++ classes.

If you print out the value of v in the above example, you will see something like this:

>>> print v
<C Vector instance at _18e31408_p_Vector>

This object is actually a Python instance that has been wrapped around a pointer to the low-level C structure. This instance doesn't actually do anything--it just serves as a proxy. The pointer to the C object can be found in the .this attribute. For example:

>>> print v.this
_18e31408_p_Vector
>>>

Further details about the Python proxy class are covered a little later.

const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive. For example:

struct Foo {
   ...
   %immutable;
   int x;        /* Read-only members */
   char *name;
   %mutable;
   ...
};

When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run with the -c++ option). When the structure member is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described later).

If a structure contains arrays, access to those arrays is managed through pointers. For example, consider this:

struct Bar {
    int  x[16];
};

If accessed in Python, you will see behavior like this:

>>> b = example.Bar()
>>> print b.x
_801861a4_p_int
>>> 

This pointer can be passed around to functions that expect to receive an int * (just like C). You can also set the value of an array member using another pointer. For example:

>>> c = example.Bar()
>>> c.x = b.x             # Copy contents of b.x to c.x

For array assignment, SWIG copies the entire contents of the array starting with the data pointed to by b.x. In this example, 16 integers would be copied. Like C, SWIG makes no assumptions about bounds checking---if you pass a bad pointer, you may get a segmentation fault or access violation.

When a member of a structure is itself a structure, it is handled as a pointer. For example, suppose you have two structures like this:

struct Foo {
   int a;
};

struct Bar {
   Foo f;
};

Now, suppose that you access the f attribute of Bar like this:

>>> b = Bar()
>>> x = b.f

In this case, x is a pointer that points to the Foo that is inside b. This is the same value as generated by this C code:

Bar b;
Foo *x = &b->f;       /* Points inside b */

Because the pointer points inside the structure, you can modify the contents and everything works just like you would expect. For example:

>>> b = Bar()
>>> b.f.a = 3               # Modify attribute of structure member
>>> x = b.f                   
>>> x.a = 3                 # Modifies the same structure

36.3.7 C++ classes

C++ classes are wrapped by Python classes as well. For example, if you have this class,

class List {
public:
  List();
  ~List();
  int  search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int  length;
};

you can use it in Python like this:

>>> l = example.List()
>>> l.insert("Ale")
>>> l.insert("Stout")
>>> l.insert("Lager")
>>> l.get(1)
'Stout'
>>> print l.length
3
>>>

Class data members are accessed in the same manner as C structures.

Static class members present a special problem for Python. Prior to Python-2.2, Python classes had no support for static methods and no version of Python supports static member variables in a manner that SWIG can utilize. Therefore, SWIG generates wrappers that try to work around some of these issues. To illustrate, suppose you have a class like this:

class Spam {
public:
   static void foo();
   static int bar;

};

In Python, the static member can be access in three different ways:

>>> example.Spam_foo()    # Spam::foo()
>>> s = example.Spam()
>>> s.foo()               # Spam::foo() via an instance
>>> example.Spam.foo()    # Spam::foo(). Python-2.2 only

The first two methods of access are supported in all versions of Python. The last technique is only available in Python-2.2 and later versions.

Static member variables are currently accessed as global variables. This means, they are accessed through cvar like this:

>>> print example.cvar.Spam_bar
7

36.3.8 C++ inheritance

SWIG is fully aware of issues related to C++ inheritance. Therefore, if you have classes like this

class Foo {
...
};

class Bar : public Foo {
...
};

those classes are wrapped into a hierarchy of Python classes that reflect the same inheritance structure. All of the usual Python utility functions work normally:

>>> b = Bar()
>>> instance(b,Foo)
1
>>> issubclass(Bar,Foo)
1
>>> issubclass(Foo,Bar)
0

Furthermore, if you have functions like this

void spam(Foo *f);

then the function spam() accepts Foo * or a pointer to any class derived from Foo.

It is safe to use multiple inheritance with SWIG.

36.3.9 Pointers, references, values, and arrays

In C++, there are many different ways a function might receive and manipulate objects. For example:

void spam1(Foo *x);      // Pass by pointer
void spam2(Foo &x);      // Pass by reference
void spam3(const Foo &x);// Pass by const reference
void spam4(Foo x);       // Pass by value
void spam5(Foo x[]);     // Array of objects

In Python, there is no detailed distinction like this--specifically, there are only "objects". There are no pointers, references, arrays, and so forth. Because of this, SWIG unifies all of these types together in the wrapper code. For instance, if you actually had the above functions, it is perfectly legal to do this:

>>> f = Foo()           # Create a Foo
>>> spam1(f)            # Ok. Pointer
>>> spam2(f)            # Ok. Reference
>>> spam3(f)            # Ok. Const reference
>>> spam4(f)            # Ok. Value.
>>> spam5(f)            # Ok. Array (1 element)

Similar behavior occurs for return values. For example, if you had functions like this,

Foo *spam6();
Foo &spam7();
Foo  spam8();
const Foo &spam9();

then all three functions will return a pointer to some Foo object. Since the third function (spam8) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Python will release this memory when the return value is garbage collected). The fourth case (spam9) which returns a const reference, in most of the cases will be treated as a returning value, and it will follow the same allocation/deallocation process.

36.3.10 C++ overloaded functions

C++ overloaded functions, methods, and constructors are mostly supported by SWIG. For example, if you have two functions like this:

void foo(int);
void foo(char *c);

You can use them in Python in a straightforward manner:

>>> foo(3)           # foo(int)
>>> foo("Hello")     # foo(char *c)

Similarly, if you have a class like this,

class Foo {
public:
    Foo();
    Foo(const Foo &);
    ...
};

you can write Python code like this:

>>> f = Foo()          # Create a Foo
>>> g = Foo(f)         # Copy f

Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG can't disambiguate. For example:

void spam(int);
void spam(short);

or

void foo(Bar *b);
void foo(Bar &b);

If declarations such as these appear, you will get a warning message like this:

example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).

To fix this, you either need to ignore or rename one of the methods. For example:

%rename(spam_short) spam(short);
...
void spam(int);    
void spam(short);   // Accessed as spam_short

or

%ignore spam(short);
...
void spam(int);    
void spam(short);   // Ignored

SWIG resolves overloaded functions and methods using a disambiguation scheme that ranks and sorts declarations according to a set of type-precedence rules. The order in which declarations appear in the input does not matter except in situations where ambiguity arises--in this case, the first declaration takes precedence.

Please refer to the "SWIG and C++" chapter for more information about overloading.

36.3.11 C++ operators

Certain C++ overloaded operators can be handled automatically by SWIG. For example, consider a class like this:

class Complex {
private:
  double rpart, ipart;
public:
  Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
  Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
  Complex &operator=(const Complex &c);

  Complex operator+=(const Complex &c) const;
  Complex operator+(const Complex &c) const;
  Complex operator-(const Complex &c) const;
  Complex operator*(const Complex &c) const;
  Complex operator-() const;
  
  double re() const { return rpart; }
  double im() const { return ipart; }
};

When wrapped, it works like you expect:

>>> c = Complex(3,4)
>>> d = Complex(7,8)
>>> e = c + d
>>> e.re()
10.0
>>> e.im()
12.0
>>> c += d
>>> c.re()
10.0
>>> c.im()
12.0

One restriction with operator overloading support is that SWIG is not able to fully handle operators that aren't defined as part of the class. For example, if you had code like this

class Complex {
...
friend Complex operator+(double, const Complex &c);
...
};

then SWIG ignores it and issues a warning. You can still wrap the operator, but you may have to encapsulate it in a special function. For example:

%rename(Complex_add_dc) operator+(double, const Complex &);

There are ways to make this operator appear as part of the class using the %extend directive. Keep reading.

Also, be aware that certain operators don't map cleanly to Python. For instance, overloaded assignment operators don't map to Python semantics and will be ignored.

36.3.12 C++ namespaces

SWIG is aware of C++ namespaces, but namespace names do not appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

%module example

namespace foo {
   int fact(int n);
   struct Vector {
       double x,y,z;
   };
};

it works in Python as follows:

>>> import example
>>> example.fact(3)
6
>>> v = example.Vector()
>>> v.x = 3.4
>>> print v.y
0.0
>>>

If your program has more than one namespace, name conflicts (if any) can be resolved using %rename For example:

%rename(Bar_spam) Bar::spam;

namespace Foo {
    int spam();
}

namespace Bar {
    int spam();
}

If you have more than one namespace and your want to keep their symbols separate, consider wrapping them as separate SWIG modules. For example, make the module name the same as the namespace and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

36.3.13 C++ templates

C++ templates don't present a huge problem for SWIG. However, in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the %template directive. For example:

%module example
%{
#include "pair.h"
%}

template<class T1, class T2>
struct pair {
   typedef T1 first_type;
   typedef T2 second_type;
   T1 first;
   T2 second;
   pair();
   pair(const T1&, const T2&);
  ~pair();
};

%template(pairii) pair<int,int>;

In Python:

>>> import example
>>> p = example.pairii(3,4)
>>> p.first
3
>>> p.second
4

Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.

36.3.14 C++ Smart Pointers

In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

template<class T> class SmartPtr {
   ...
   T *operator->();
   ...
}

Then, if you have a class like this,

class Foo {
public:
     int x;
     int bar();
};

A smart pointer would be used in C++ as follows:

SmartPtr<Foo> p = CreateFoo();   // Created somehow (not shown)
...
p->x = 3;                        // Foo::x
int y = p->bar();                // Foo::bar

To wrap this in Python, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using %template if necessary. For example:

%module example
...
%template(SmartPtrFoo) SmartPtr<Foo>;
...

Now, in Python, everything should just "work":

>>> p = example.CreateFoo()          # Create a smart-pointer somehow
>>> p.x = 3                          # Foo::x
>>> p.bar()                          # Foo::bar

If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

>>> f = p.__deref__()     # Returns underlying Foo *

36.3.15 C++ reference counted objects

The C++ reference counted objects section contains Python examples of memory management using referencing counting.

36.4 Further details on the Python class interface

In the previous section, a high-level view of Python wrapping was presented. A key component of this wrapping is that structures and classes are wrapped by Python proxy classes. This provides a very natural Python interface and allows SWIG to support a number of advanced features such as operator overloading. However, a number of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

New in SWIG version 2.0.4: The use of Python proxy classes has performance implications that may be unacceptable for a high-performance library. The new -builtin option instructs SWIG to forego the use of proxy classes, and instead create wrapped types as new built-in Python types. When this option is used, the following section ("Proxy classes") does not apply. Details on the use of the -builtin option are in the Built-in Types section.

36.4.1 Proxy classes

In the "SWIG basics" and "SWIG and C++" chapters, details of low-level structure and class wrapping are described. To summarize those chapters, if you have a class like this

class Foo {
public:
     int x;
     int spam(int);
     ...

then SWIG transforms it into a set of low-level procedural wrappers. For example:

Foo *new_Foo() {
    return new Foo();
}
void delete_Foo(Foo *f) {
    delete f;
}
int Foo_x_get(Foo *f) {
    return f->x;
}
void Foo_x_set(Foo *f, int value) {
    f->x = value;
}
int Foo_spam(Foo *f, int arg1) {
    return f->spam(arg1);
}

These wrappers can be found in the low-level extension module (e.g., _example).

Using these wrappers, SWIG generates a high-level Python proxy class (also known as a shadow class) like this (shown for Python 2.2):

import _example

class Foo(object):
     def __init__(self):
         self.this = _example.new_Foo()
         self.thisown = 1
     def __del__(self):
         if self.thisown:
               _example.delete_Foo(self.this)
     def spam(self,arg1):
         return _example.Foo_spam(self.this,arg1)
     x = property(_example.Foo_x_get, _example.Foo_x_set)

This class merely holds a pointer to the underlying C++ object ( .this) and dispatches methods and member variable access to that object using the low-level accessor functions. From a user's point of view, it makes the class work normally:

>>> f = example.Foo()
>>> f.x = 3
>>> y = f.spam(5)

The fact that the class has been wrapped by a real Python class offers certain advantages. For instance, you can attach new Python methods to the class and you can even inherit from it (something not supported by Python built-in types until Python 2.2).

36.4.2 Built-in Types

The -builtin option provides a significant performance improvement in the wrapped code. To understand the difference between proxy classes and built-in types, let's take a look at what a wrapped object looks like under both circumstances.

When proxy classes are used, each wrapped object in python is an instance of a pure python class. As a reminder, here is what the __init__ method looks like in a proxy class:

class Foo(object):
     def __init__(self):
         self.this = _example.new_Foo()
         self.thisown = 1

When a Foo instance is created, the call to _example.new_Foo() creates a new C++ Foo instance; wraps that C++ instance inside an instance of a python built-in type called SwigPyObject; and stores the SwigPyObject instance in the 'this' field of the python Foo object. Did you get all that? So, the python Foo object is composed of three parts:

  • The python Foo instance, which contains...
  • ... an instance of struct SwigPyObject, which contains...
  • ... a C++ Foo instance

When -builtin is used, the pure python layer is stripped off. Each wrapped class is turned into a new python built-in type which inherits from SwigPyObject, and SwigPyObject instances are returned directly from the wrapped methods. For more information about python built-in extensions, please refer to the python documentation:

http://docs.python.org/extending/newtypes.html

36.4.2.1 Limitations

Use of the -builtin option implies a couple of limitations:

  • python version support:

    • Versions 2.5 and up are fully supported
    • Versions 2.3 and 2.4 are mostly supported; there are problems with director classes and/or sub-classing a wrapped type in python.
    • Versions older than 2.3 are not supported.
  • Some legacy syntax is no longer supported; in particular:

    • The functional interface is no longer exposed. For example, you may no longer call Whizzo.new_CrunchyFrog(). Instead, you must use Whizzo.CrunchyFrog().
    • Static member variables are no longer accessed through the 'cvar' field (e.g., Dances.cvar.FishSlap). They are instead accessed in the idiomatic way (Dances.FishSlap).
  • Wrapped types may not be raised as python exceptions. Here's why: the python internals expect that all sub-classes of Exception will have this struct layout:

    typedef struct {
        PyObject_HEAD
        PyObject *dict;
        PyObject *args;
        PyObject *message;
    } PyBaseExceptionObject;
    

    But swig-generated wrappers expect that all swig-wrapped classes will have this struct layout:

    typedef struct {
        PyObject_HEAD
        void *ptr;
        swig_type_info *ty;
        int own;
        PyObject *next;
        PyObject *dict;
    } SwigPyObject;
    

    There are workarounds for this. For example, if you wrap this class:

    class MyException {
    public:
        MyException (const char *msg_);
        ~MyException ();
    
        const char *what () const;
    
    private:
        char *msg;
    };
    

    ... you can define this python class, which may be raised as an exception:

    class MyPyException (Exception) :
        def __init__(self, msg, *args) :
            Exception.__init__(self, *args)
            self.myexc = MyException(msg)
        def what (self) :
            return self.myexc.what()
    
  • Reverse binary operators (e.g., __radd__) are not supported.

    To illustrate this point, if you have a wrapped class called MyString, and you want to use instances of MyString interchangeably with native python strings, you can define an 'operator+ (const char*)' method :

    class MyString {
    public:
        MyString (const char *init);
        MyString operator+ (const char *other) const;
        ...
    };
    

    SWIG will automatically create an operator overload in python that will allow this:

    from MyModule import MyString
    
    mystr = MyString("No one expects")
    episode = mystr + " the Spanish Inquisition"
    

    This works because the first operand (mystr) defines a way to add a native string to itself. However, the following will not work:

    from MyModule import MyString
    
    mystr = MyString("Parrot")
    episode = "Dead " + mystr
    

    The above code fails, because the first operand -- a native python string -- doesn't know how to add an instance of MyString to itself.

  • If you have multiple SWIG modules that share type information ( more info), the -builtin option requires a bit of extra discipline to ensure that base classes are initialized before derived classes. Specifically:

    • There must be an unambiguous dependency graph for the modules.

    • Module dependencies must be explicitly stated with %import statements in the SWIG interface file.

    As an example, suppose module A has this interface in A.i :

    %module "A";
    
    class Base {
    ...
    };
    

    If you want to wrap another module containing a class that inherits from A, this is how it would look :

    %module "B";
    
    %import "A.i"
    
    class Derived : public Base {
    ...
    };
    

    The import "A.i" statement is required, because module B depends on module A.

    As long as you obey these requirements, your python code may import the modules in any order :

    import B
    import A
    
    assert(issubclass(B.Derived, A.Base))
    

36.4.2.2 Operator overloads -- use them!

The entire justification for the -builtin option is improved performance. To that end, the best way to squeeze maximum performance out of your wrappers is to use operator overloads. Named method dispatch is slow in python, even when compared to other scripting languages. However, python built-in types have a large number of "slots", analogous to C++ operator overloads, which allow you to short-circuit named method dispatch for certain common operations.

By default, SWIG will translate most C++ arithmetic operator overloads into python slot entries. For example, suppose you have this class:

class Twit {
public:
    Twit operator+ (const Twit& twit) const;

    // Forward to operator+
    Twit add (const Twit& twit) const
    { return *this + twit; }
};

SWIG will automatically register operator+ as a python slot operator for addition. You may write python code like this:

from MyModule import Twit

nigel = Twit()
emily = Twit()
percival = nigel + emily
percival = nigel.add(emily)

The last two lines of the python code are equivalent, but the line that uses the '+' operator is much faster.

In-place operators (e.g., operator+=) and comparison operators (operator==, operator<, etc.) are also converted to python slot operators. For a complete list of C++ operators that are automatically converted to python slot operators, refer to the file python/pyopers.swig in the SWIG library.

There are other very useful python slots that you may explicitly define using %feature directives. For example, suppose you want to use instances of a wrapped class as keys in a native python dict. That will work as long as you define a hash function for instances of your class, and use it to define the python tp_hash slot:

%feature("python:slot", "tp_hash", functype="hashfunc") Cheese::cheeseHashFunc;

class Cheese {
public:
    Cheese (const char *name);
    long cheeseHashFunc () const;
};

This will allow you to write python code like this:

from my MyPackage import Cheese

inventory = {
    Cheese("cheddar") : 0,
    Cheese("gouda") : 0,
    Cheese("camembert") : 0
}

Because you defined the tp_hash slot, Cheese objects may be used as hash keys; and when the cheeseHashFunc method is invoked by a python dict, it will not go through named method dispatch. A more detailed discussion about %feature("python:slot") can be found in the file python/pyopers.swig in the SWIG library. You can read about all of the available python slots here:

http://docs.python.org/c-api/typeobj.html

You may override (almost) all of the slots defined in the PyTypeObject, PyNumberMethods, PyMappingMethods, PySequenceMethods, and PyBufferProcs structs.

36.4.3 Memory management

NOTE: Although this section refers to proxy objects, everything here also applies when the -builtin option is used.

Associated with proxy object, is an ownership flag .thisown The value of this flag determines who is responsible for deleting the underlying C++ object. If set to 1, the Python interpreter will destroy the C++ object when the proxy class is garbage collected. If set to 0 (or if the attribute is missing), then the destruction of the proxy class has no effect on the C++ object.

When an object is created by a constructor or returned by value, Python automatically takes ownership of the result. For example:

class Foo {
public:
    Foo();
    Foo bar();
};

In Python:

>>> f = Foo()
>>> f.thisown
1
>>> g = f.bar()
>>> g.thisown
1

On the other hand, when pointers are returned to Python, there is often no way to know where they came from. Therefore, the ownership is set to zero. For example:

class Foo {
public:
    ...
    Foo *spam();
    ...
};

>>> f = Foo()
>>> s = f.spam()
>>> print s.thisown
0
>>>

This behavior is especially important for classes that act as containers. For example, if a method returns a pointer to an object that is contained inside another object, you definitely don't want Python to assume ownership and destroy it!

A good way to indicate that ownership should be set for a returned pointer is to use the %newobject directive.

Related to containers, ownership issues can arise whenever an object is assigned to a member or global variable. For example, consider this interface:

%module example

struct Foo {
    int  value;
    Foo  *next;
};

Foo *head = 0;

When wrapped in Python, careful observation will reveal that ownership changes whenever an object is assigned to a global variable. For example:

>>> f = example.Foo()
>>> f.thisown
1
>>> example.cvar.head = f           
>>> f.thisown
0
>>>

In this case, C is now holding a reference to the object---you probably don't want Python to destroy it. Similarly, this occurs for members. For example:

>>> f = example.Foo()
>>> g = example.Foo()
>>> f.thisown
1
>>> g.thisown
1
>>> f.next = g
>>> g.thisown
0
>>>

For the most part, memory management issues remain hidden. However, there are occasionally situations where you might have to manually change the ownership of an object. For instance, consider code like this:

class Node {
   Object *value;
public:
   void set_value(Object *v) { value = v; }
   ...
};

Now, consider the following Python code:

>>> v = Object()           # Create an object
>>> n = Node()             # Create a node
>>> n.set_value(v)         # Set value
>>> v.thisown
1
>>> del v

In this case, the object n is holding a reference to v internally. However, SWIG has no way to know that this has occurred. Therefore, Python still thinks that it has ownership of the object. Should the proxy object be destroyed, then the C++ destructor will be invoked and n will be holding a stale-pointer. If you're lucky, you will only get a segmentation fault.

To work around this, it is always possible to flip the ownership flag. For example,

>>> v.thisown = 0

It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

36.4.4 Python 2.2 and classic classes

SWIG makes every attempt to preserve backwards compatibility with older versions of Python to the extent that it is possible. However, in Python-2.2, an entirely new type of class system was introduced. This new-style class system offers many enhancements including static member functions, properties (managed attributes), and class methods. Details about all of these changes can be found on www.python.org and is not repeated here.

To address differences between Python versions, SWIG currently emits dual-mode proxy class wrappers. In Python-2.2 and newer releases, these wrappers encapsulate C++ objects in new-style classes that take advantage of new features (static methods and properties). However, if these very same wrappers are imported into an older version of Python, old-style classes are used instead.

This dual-nature of the wrapper code means that you can create extension modules with SWIG and those modules will work with all versions of Python ranging from Python-1.4 to the very latest release. Moreover, the wrappers take advantage of Python-2.2 features when available.

For the most part, the interface presented to users is the same regardless of what version of Python is used. The only incompatibility lies in the handling of static member functions. In Python-2.2, they can be accessed via the class itself. In Python-2.1 and earlier, they have to be accessed as a global function or through an instance (see the earlier section).

36.5 Cross language polymorphism

Proxy classes provide a more natural, object-oriented way to access extension classes. As described above, each proxy instance has an associated C++ instance, and method calls to the proxy are passed to the C++ instance transparently via C wrapper functions.

This arrangement is asymmetric in the sense that no corresponding mechanism exists to pass method calls down the inheritance chain from C++ to Python. In particular, if a C++ class has been extended in Python (by extending the proxy class), these extensions will not be visible from C++ code. Virtual method calls from C++ are thus not able access the lowest implementation in the inheritance chain.

Changes have been made to SWIG 1.3.18 to address this problem and make the relationship between C++ classes and proxy classes more symmetric. To achieve this goal, new classes called directors are introduced at the bottom of the C++ inheritance chain. The job of the directors is to route method calls correctly, either to C++ implementations higher in the inheritance chain or to Python implementations lower in the inheritance chain. The upshot is that C++ classes can be extended in Python and from C++ these extensions look exactly like native C++ classes. Neither C++ code nor Python code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

36.5.1 Enabling directors

The director feature is disabled by default. To use directors you must make two changes to the interface file. First, add the "directors" option to the %module directive, like this:

%module(directors="1") modulename

Without this option no director code will be generated. Second, you must use the %feature("director") directive to tell SWIG which classes and methods should get directors. The %feature directive can be applied globally, to specific classes, and to specific methods, like this:

// generate directors for all classes that have virtual methods
%feature("director");         

// generate directors for all virtual methods in class Foo
%feature("director") Foo;      

You can use the %feature("nodirector") directive to turn off directors for specific classes or methods. So for example,

%feature("director") Foo;
%feature("nodirector") Foo::bar;

will generate directors for all virtual methods of class Foo except bar().

Directors can also be generated implicitly through inheritance. In the following, class Bar will get a director class that handles the methods one() and two() (but not three()):

%feature("director") Foo;
class Foo {
public:
    Foo(int foo);
    virtual void one();
    virtual void two();
};

class Bar: public Foo {
public:
    virtual void three();
};

then at the python side you can define

import mymodule

class MyFoo(mymodule.Foo):
  def __init__(self, foo):
     mymodule.Foo(self, foo)  

  def one(self):
     print "one from python"

36.5.2 Director classes

For each class that has directors enabled, SWIG generates a new class that derives from both the class in question and a special Swig::Director class. These new classes, referred to as director classes, can be loosely thought of as the C++ equivalent of the Python proxy classes. The director classes store a pointer to their underlying Python object and handle various issues related to object ownership. Indeed, this is quite similar to the "this" and "thisown" members of the Python proxy classes.

For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). Thus all virtual method calls, whether they originate in C++ or in Python via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate place" we mean the method that would have been called if the C++ base class and its extensions in Python were seamlessly integrated. That seamless integration is exactly what the director classes provide, transparently skipping over all the messy extension API glue that binds the two languages together.

In reality, the "appropriate place" is one of only two possibilities: C++ or Python. Once this decision is made, the rest is fairly easy. If the correct implementation is in C++, then the lowest implementation of the method in the C++ inheritance chain is called explicitly. If the correct implementation is in Python, the Python API is used to call the method of the underlying Python object (after which the usual virtual method resolution in Python automatically finds the right implementation).

Now how does the director decide which language should handle the method call? The basic rule is to handle the method in Python, unless there's a good reason not to. The reason for this is simple: Python has the most "extended" implementation of the method. This assertion is guaranteed, since at a minimum the Python proxy class implements the method. If the method in question has been extended by a class derived from the proxy class, that extended implementation will execute exactly as it should. If not, the proxy class will route the method call into a C wrapper function, expecting that the method will be resolved in C++. The wrapper will call the virtual method of the C++ instance, and since the director extends this the call will end up right back in the director method. Now comes the "good reason not to" part. If the director method were to blindly call the Python method again, it would get stuck in an infinite loop. We avoid this situation by adding special code to the C wrapper function that tells the director method to not do this. The C wrapper function compares the pointer to the Python object that called the wrapper function to the pointer stored by the director. If these are the same, then the C wrapper function tells the director to resolve the method by calling up the C++ inheritance chain, preventing an infinite loop.

One more point needs to be made about the relationship between director classes and proxy classes. When a proxy class instance is created in Python, SWIG creates an instance of the original C++ class and assigns it to .this. This is exactly what happens without directors and is true even if directors are enabled for the particular class in question. When a class derived from a proxy class is created, however, SWIG then creates an instance of the corresponding C++ director class. The reason for this difference is that user-defined subclasses may override or extend methods of the original class, so the director class is needed to route calls to these methods correctly. For unmodified proxy classes, all methods are ultimately implemented in C++ so there is no need for the extra overhead involved with routing the calls through Python.

36.5.3 Ownership and object destruction

Memory management issues are slightly more complicated with directors than for proxy classes alone. Python instances hold a pointer to the associated C++ director object, and the director in turn holds a pointer back to the Python object. By default, proxy classes own their C++ director object and take care of deleting it when they are garbage collected.

This relationship can be reversed by calling the special __disown__() method of the proxy class. After calling this method, the .thisown flag is set to zero, and the director class increments the reference count of the Python object. When the director class is deleted it decrements the reference count. Assuming no outstanding references to the Python object remain, the Python object will be destroyed at the same time. This is a good thing, since directors and proxies refer to each other and so must be created and destroyed together. Destroying one without destroying the other will likely cause your program to segfault.

To help ensure that no references to the Python object remain after calling __disown__(), this method returns a weak reference to the Python object. Weak references are only available in Python versions 2.1 and higher, so for older versions you must explicitly delete all references. Here is an example:

class Foo {
public:
    ...
};
class FooContainer {
public:
    void addFoo(Foo *);
    ...
};

>>> c = FooContainer()
>>> a = Foo().__disown__()
>>> c.addFoo(a)
>>> b = Foo()
>>> b = b.__disown__()
>>> c.addFoo(b)
>>> c.addFoo(Foo().__disown__())

In this example, we are assuming that FooContainer will take care of deleting all the Foo pointers it contains at some point. Note that no hard references to the Foo objects remain in Python.

36.5.4 Exception unrolling

With directors routing method calls to Python, and proxies routing them to C++, the handling of exceptions is an important concern. By default, the directors ignore exceptions that occur during method calls that are resolved in Python. To handle such exceptions correctly, it is necessary to temporarily translate them into C++ exceptions. This can be done with the %feature("director:except") directive. The following code should suffice in most cases:

%feature("director:except") {
    if ($error != NULL) {
        throw Swig::DirectorMethodException();
    }
}

This code will check the Python error state after each method call from a director into Python, and throw a C++ exception if an error occurred. This exception can be caught in C++ to implement an error handler. Currently no information about the Python error is stored in the Swig::DirectorMethodException object, but this will likely change in the future.

It may be the case that a method call originates in Python, travels up to C++ through a proxy class, and then back into Python via a director method. If an exception occurs in Python at this point, it would be nice for that exception to find its way back to the original caller. This can be done by combining a normal %exception directive with the director:except handler shown above. Here is an example of a suitable exception handler:

%exception {
    try { $action }
    catch (Swig::DirectorException &e) { SWIG_fail; }
}

The class Swig::DirectorException used in this example is actually a base class of Swig::DirectorMethodException, so it will trap this exception. Because the Python error state is still set when Swig::DirectorMethodException is thrown, Python will register the exception as soon as the C wrapper function returns.

36.5.5 Overhead and code bloat

Enabling directors for a class will generate a new director method for every virtual method in the class' inheritance chain. This alone can generate a lot of code bloat for large hierarchies. Method arguments that require complex conversions to and from target language types can result in large director methods. For this reason it is recommended that you selectively enable directors only for specific classes that are likely to be extended in Python and used in C++.

Compared to classes that do not use directors, the call routing in the director methods does add some overhead. In particular, at least one dynamic cast and one extra function call occurs per method call from Python. Relative to the speed of Python execution this is probably completely negligible. For worst case routing, a method call that ultimately resolves in C++ may take one extra detour through Python in order to ensure that the method does not have an extended Python implementation. This could result in a noticeable overhead in some cases.

Although directors make it natural to mix native C++ objects with Python objects (as director objects) via a common base class pointer, one should be aware of the obvious fact that method calls to Python objects will be much slower than calls to C++ objects. This situation can be optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in Python.

36.5.6 Typemaps

Typemaps for input and output of most of the basic types from director classes have been written. These are roughly the reverse of the usual input and output typemaps used by the wrapper code. The typemap operation names are 'directorin', 'directorout', and 'directorargout'. The director code does not currently use any of the other kinds of typemaps. It is not clear at this point which kinds are appropriate and need to be supported.

36.5.7 Miscellaneous

Director typemaps for STL classes are in place, and hence you should be able to use std::vector, std::string, etc., as you would any other type.

Note: The director typemaps for return types based in const references, such as

class Foo {
…
    virtual const int& bar();
…
};

will work only for simple call scenarios. Usually the resulting code is neither thread or reentrant safe. Hence, the user is advised to avoid returning const references in director methods. For example, the user could modify the method interface to use lvalue return types, wherever possible, for example

class Foo {
…
    virtual int bar();
…
};

If that is not possible, the user should avoid enabling the director feature for reentrant, recursive or threaded member methods that return const references.

36.6 Common customization features

The last section presented the absolute basics of C/C++ wrapping. If you do nothing but feed SWIG a header file, you will get an interface that mimics the behavior described. However, sometimes this isn't enough to produce a nice module. Certain types of functionality might be missing or the interface to certain functions might be awkward. This section describes some common SWIG features that are used to improve your the interface to an extension module.

36.6.1 C/C++ helper functions

Sometimes when you create a module, it is missing certain bits of functionality. For example, if you had a function like this

void set_transform(Image *im, double m[4][4]);

it would be accessible from Python, but there may be no easy way to call it. For example, you might get errors like this:

>>> a = [
...   [1,0,0,0],
...   [0,1,0,0],
...   [0,0,1,0],
...   [0,0,0,1]]
>>> set_transform(im,a)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: Type error. Expected _p_a_4__double

The problem here is that there is no easy way to construct and manipulate a suitable double [4][4] value to use. To fix this, you can write some extra C helper functions. Just use the %inline directive. For example:

%inline %{
/* Note: double[4][4] is equivalent to a pointer to an array double (*)[4] */
double (*new_mat44())[4] {
   return (double (*)[4]) malloc(16*sizeof(double));
}
void free_mat44(double (*x)[4]) {
   free(x);
}
void mat44_set(double x[4][4], int i, int j, double v) {
   x[i][j] = v;
}
double mat44_get(double x[4][4], int i, int j) {
   return x[i][j];
}
%}

From Python, you could then write code like this:

>>> a = new_mat44()
>>> mat44_set(a,0,0,1.0)
>>> mat44_set(a,1,1,1.0)
>>> mat44_set(a,2,2,1.0)
...
>>> set_transform(im,a)
>>>

Admittedly, this is not the most elegant looking approach. However, it works and it wasn't too hard to implement. It is possible to clean this up using Python code, typemaps, and other customization features as covered in later sections.

36.6.2 Adding additional Python code

If writing support code in C isn't enough, it is also possible to write code in Python. This code gets inserted in to the .py file created by SWIG. One use of Python code might be to supply a high-level interface to certain functions. For example:

void set_transform(Image *im, double x[4][4]);

...
/* Rewrite the high level interface to set_transform */
%pythoncode %{
def set_transform(im,x):
   a = new_mat44()
   for i in range(4):
       for j in range(4):
           mat44_set(a,i,j,x[i][j])
   _example.set_transform(im,a)
   free_mat44(a)
%}

In this example, set_transform() provides a high-level Python interface built on top of low-level helper functions. For example, this code now seems to work:

>>> a = [
...   [1,0,0,0],
...   [0,1,0,0],
...   [0,0,1,0],
...   [0,0,0,1]]
>>> set_transform(im,a)
>>>

Admittedly, this whole scheme for wrapping the two-dimension array argument is rather ad-hoc. Besides, shouldn't a Python list or a Numeric Python array just work normally? We'll get to those examples soon enough. For now, think of this example as an illustration of what can be done without having to rely on any of the more advanced customization features.

There is also %pythonbegin which is another directive very similar to %pythoncode, but generates the given Python code at the beginning of the .py file. This directive works in the same way as %pythoncode, except the code is copied just after the SWIG banner (comment) at the top of the file, before any real code. This provides an opportunity to add your own description in a comment near the top of the file as well as Python imports that have to appear at the top of the file, such as "from __future__ import" statements.

The following shows example usage for Python 2.6 to use print as it can in Python 3, that is, as a function instead of a statement:

%pythonbegin %{
# This module provides wrappers to the Whizz Bang library
%}

%pythonbegin %{
from __future__ import print_function
print("Loading", "Whizz", "Bang", sep=' ... ')
%}

which can be seen when viewing the first few lines of the generated .py file:

# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.11
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.

# This module provides wrappers to the Whizz Bang library

from __future__ import print_function
print("Loading", "Whizz", "Bang", sep=' ... ')

Sometimes you may want to replace or modify the wrapper function that SWIG creates in the proxy .py file. The Python module in SWIG provides some features that enable you to do this. First, to entirely replace a proxy function you can use %feature("shadow"). For example:

%module example

// Rewrite bar() python code

%feature("shadow") Foo::bar(int) %{
def bar(*args):
    #do something before
    $action
    #do something after
%}
    
class Foo {
public:
    int bar(int x);
}

where $action will be replaced by the call to the C/C++ proper method.

Often the proxy function created by SWIG is fine, but you simply want to add code to it without touching the rest of the generated function body. For these cases SWIG provides the pythonprepend and pythonappend features which do exactly as their names suggest. The pythonprepend feature will insert its value at the beginning of the proxy function, and pythonappend will insert code at the end of the proxy, just before the return statement.

%module example

// Add python code to bar() 

%feature("pythonprepend") Foo::bar(int) %{
   #do something before C++ call
%}

%feature("pythonappend") Foo::bar(int) %{
   #do something after C++ call
%}

    
class Foo {
public:
    int bar(int x);
}

Notes: Usually the pythonappend and pythonprepend features are safer to use than the shadow feature. Also, from SWIG version 1.3.28 you can use the directive forms %pythonappend and %pythonprepend as follows:

%module example

// Add python code to bar() 

%pythonprepend Foo::bar(int) %{
   #do something before C++ call
%}

%pythonappend Foo::bar(int) %{
   #do something after C++ call
%}

    
class Foo {
public:
    int bar(int x);
}

Note that when the underlying C++ method is overloaded, there is only one proxy Python method for multiple C++ methods. In this case, only one of parsed methods is examined for the feature. You are better off specifying the feature without the argument list to ensure it will get used, as it will then get attached to all the overloaded C++ methods. For example:

%module example

// Add python code to bar()

%pythonprepend Foo::bar %{
   #do something before C++ call
%}

%pythonappend Foo::bar %{
   #do something after C++ call
%}


class Foo {
public:
    int bar(int x);
    int bar();
}

The same applies for overloaded constructors.

36.6.3 Class extension with %extend

One of the more interesting features of SWIG is that it can extend structures and classes with new methods--at least in the Python interface. Here is a simple example:

%module example
%{
#include "someheader.h"
%}

struct Vector {
   double x,y,z;
};

%extend Vector {
   char *__str__() {
       static char tmp[1024];
       sprintf(tmp,"Vector(%g,%g,%g)", $self->x,$self->y,$self->z);
       return tmp;
   }
   Vector(double x, double y, double z) {
       Vector *v = (Vector *) malloc(sizeof(Vector));
       v->x = x;
       v->y = y;
       v->z = z;
       return v;
   }
};

Now, in Python

>>> v = example.Vector(2,3,4)
>>> print v
Vector(2,3,4)
>>>

%extend can be used for many more tasks than this. For example, if you wanted to overload a Python operator, you might do this:

%extend Vector {
    Vector __add__(Vector *other) {
         Vector v;
         v.x = $self->x + other->x;
         v.y = $self->y + other->y;
         v.z = $self->z + other->z;
         return v;
    }
};

Use it like this:

>>> import example
>>> v = example.Vector(2,3,4)
>>> w = example.Vector(10,11,12)
>>> print v+w
Vector(12,14,16)
>>> 

%extend works with both C and C++ code. It does not modify the underlying object in any way---the extensions only show up in the Python interface.

36.6.4 Exception handling with %exception

If a C or C++ function throws an error, you may want to convert that error into a Python exception. To do this, you can use the %exception directive. %exception simply lets you rewrite part of the generated wrapper code to include an error check.

In C, a function often indicates an error by returning a status code (a negative number or a NULL pointer perhaps). Here is a simple example of how you might handle that:

%exception malloc {
  $action
  if (!result) {
     PyErr_SetString(PyExc_MemoryError,"Not enough memory");
     return NULL;
  }
}
void *malloc(size_t nbytes);

In Python,

>>> a = example.malloc(2000000000)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
MemoryError: Not enough memory
>>>

If a library provides some kind of general error handling framework, you can also use that. For example:

%exception {
   $action
   if (err_occurred()) {
      PyErr_SetString(PyExc_RuntimeError, err_message());
      return NULL;
   }
}

No declaration name is given to %exception, it is applied to all wrapper functions.

C++ exceptions are also easy to handle. For example, you can write code like this:

%exception getitem {
   try {
      $action
   } catch (std::out_of_range &e) {
      PyErr_SetString(PyExc_IndexError, const_cast<char*>(e.what()));
      return NULL;
   }
}

class Base {
public:
     Foo *getitem(int index);      // Exception handled added
     ...
};

When raising a Python exception from C, use the PyErr_SetString() function as shown above. The following exception types can be used as the first argument.

PyExc_ArithmeticError
PyExc_AssertionError
PyExc_AttributeError
PyExc_EnvironmentError
PyExc_EOFError
PyExc_Exception
PyExc_FloatingPointError
PyExc_ImportError
PyExc_IndexError
PyExc_IOError
PyExc_KeyError
PyExc_KeyboardInterrupt
PyExc_LookupError
PyExc_MemoryError
PyExc_NameError
PyExc_NotImplementedError
PyExc_OSError
PyExc_OverflowError
PyExc_RuntimeError
PyExc_StandardError
PyExc_SyntaxError
PyExc_SystemError
PyExc_TypeError
PyExc_UnicodeError
PyExc_ValueError
PyExc_ZeroDivisionError

The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

36.7 Tips and techniques

Although SWIG is largely automatic, there are certain types of wrapping problems that require additional user input. Examples include dealing with output parameters, strings, binary data, and arrays. This chapter discusses the common techniques for solving these problems.

36.7.1 Input and output parameters

A common problem in some C programs is handling parameters passed as simple pointers. For example:

void add(int x, int y, int *result) {
   *result = x + y;
}

or perhaps

int sub(int *x, int *y) {
   return *x-*y;
}

The easiest way to handle these situations is to use the typemaps.i file. For example:

%module example
%include "typemaps.i"

void add(int, int, int *OUTPUT);
int  sub(int *INPUT, int *INPUT);

In Python, this allows you to pass simple values. For example:

>>> a = add(3,4)
>>> print a
7
>>> b = sub(7,4)
>>> print b
3
>>>

Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter creates a return result.

If you don't want to use the names INPUT or OUTPUT , use the %apply directive. For example:

%module example
%include "typemaps.i"

%apply int *OUTPUT { int *result };
%apply int *INPUT  { int *x, int *y};

void add(int x, int y, int *result);
int  sub(int *x, int *y);

If a function mutates one of its parameters like this,

void negate(int *x) {
   *x = -(*x);
}

you can use INOUT like this:

%include "typemaps.i"
...
void negate(int *INOUT);

In Python, a mutated parameter shows up as a return value. For example:

>>> a = negate(3)
>>> print a
-3
>>>

Note: Since most primitive Python objects are immutable, it is not possible to perform in-place modification of a Python object passed as a parameter.

The most common use of these special typemap rules is to handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

/* send message, return number of bytes sent, along with success code */
int send_message(char *text, int len, int *success);

To wrap such a function, simply use the OUTPUT rule above. For example:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *success };
...
int send_message(char *text, int *success);

When used in Python, the function will return multiple values.

bytes, success = send_message("Hello World")
if not success:
    print "Whoa!"
else:
    print "Sent", bytes

Another common use of multiple return values are in query functions. For example:

void get_dimensions(Matrix *m, int *rows, int *columns);

To wrap this, you might use the following:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *rows, int *columns };
...
void get_dimensions(Matrix *m, int *rows, *columns);

Now, in Python:

>>> r,c = get_dimensions(m)

Be aware that the primary purpose of the typemaps.i file is to support primitive datatypes. Writing a function like this

void foo(Bar *OUTPUT);

may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

36.7.2 Simple pointers

If you must work with simple pointers such as int * or double * and you don't want to use typemaps.i, consider using the cpointer.i library file. For example:

%module example
%include "cpointer.i"

%inline %{
extern void add(int x, int y, int *result);
%}

%pointer_functions(int, intp);

The %pointer_functions(type,name) macro generates five helper functions that can be used to create, destroy, copy, assign, and dereference a pointer. In this case, the functions are as follows:

int  *new_intp();
int  *copy_intp(int *x);
void  delete_intp(int *x);
void  intp_assign(int *x, int value);
int   intp_value(int *x);

In Python, you would use the functions like this:

>>> result = new_intp()
>>> print result
_108fea8_p_int
>>> add(3,4,result)
>>> print intp_value(result)
7
>>>

If you replace %pointer_functions() by %pointer_class(type,name), the interface is more class-like.

>>> result = intp()
>>> add(3,4,result)
>>> print result.value()
7

See the SWIG Library chapter for further details.

36.7.3 Unbounded C Arrays

Sometimes a C function expects an array to be passed as a pointer. For example,

int sumitems(int *first, int nitems) {
    int i, sum = 0;
    for (i = 0; i < nitems; i++) {
        sum += first[i];
    }
    return sum;
}

To wrap this into Python, you need to pass an array pointer as the first argument. A simple way to do this is to use the carrays.i library file. For example:

%include "carrays.i"
%array_class(int, intArray);

The %array_class(type, name) macro creates wrappers for an unbounded array object that can be passed around as a simple pointer like int * or double *. For instance, you will be able to do this in Python:

>>> a = intArray(10000000)         # Array of 10-million integers
>>> for i in xrange(10000):        # Set some values
...     a[i] = i
>>> sumitems(a,10000)
49995000
>>>

The array "object" created by %array_class() does not encapsulate pointers inside a special array object. In fact, there is no bounds checking or safety of any kind (just like in C). Because of this, the arrays created by this library are extremely low-level indeed. You can't iterate over them nor can you even query their length. In fact, any valid memory address can be accessed if you want (negative indices, indices beyond the end of the array, etc.). Needless to say, this approach is not going to suit all applications. On the other hand, this low-level approach is extremely efficient and well suited for applications in which you need to create buffers, package binary data, etc.

36.7.4 String handling

If a C function has an argument of char *, then a Python string can be passed as input. For example:

// C
void foo(char *s);
# Python
>>> foo("Hello")

When a Python string is passed as a parameter, the C function receives a pointer to the raw data contained in the string. Since Python strings are immutable, it is illegal for your program to change the value. In fact, doing so will probably crash the Python interpreter.

If your program modifies the input parameter or uses it to return data, consider using the cstring.i library file described in the SWIG Library chapter.

When functions return a char *, it is assumed to be a NULL-terminated string. Data is copied into a new Python string and returned.

If your program needs to work with binary data, you can use a typemap to expand a Python string into a pointer/length argument pair. As luck would have it, just such a typemap is already defined. Just do this:

%apply (char *STRING, int LENGTH) { (char *data, int size) };
...
int parity(char *data, int size, int initial);

Now in Python:

>>> parity("e\x09ffss\x00\x00\x01\nx", 0)

If you need to return binary data, you might use the cstring.i library file. The cdata.i library can also be used to extra binary data from arbitrary pointers.

36.8 Typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Python C API as well as the material in the " Typemaps" chapter.

Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the primitive C-Python interface or if you want to elevate your guru status.

36.8.1 What is a typemap?

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Python to C, you might define a typemap like this:

%module example

%typemap(in) int {
	$1 = (int) PyLong_AsLong($input);
	printf("Received an integer : %d\n",$1);
}
%inline %{
extern int fact(int n);
%}

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input variable is the input object of type PyObject *.

When this example is compiled into a Python module, it operates as follows:

>>> from example import *
>>> fact(6)
Received an integer : 6
720

In this example, the typemap is applied to all occurrences of the int datatype. You can refine this by supplying an optional parameter name. For example:

%module example

%typemap(in) int nonnegative {
	$1 = (int) PyLong_AsLong($input);
        if ($1 < 0) {
           PyErr_SetString(PyExc_ValueError,"Expected a nonnegative value.");
           return NULL;
        }
}
%inline %{
extern int fact(int nonnegative);
%}

In this case, the typemap code is only attached to arguments that exactly match int nonnegative.

The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG C++ type-system. When you define a typemap for int, that typemap applies to int and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

%typemap(in) int n {
	$1 = (int) PyLong_AsLong($input);
	printf("n = %d\n",$1);
}
%inline %{
typedef int Integer;
extern int fact(Integer n);    // Above typemap is applied
%}

Typemaps can also be defined for groups of consecutive arguments. For example:

%typemap(in) (char *str, int len) {
    $1 = PyString_AsString($input);
    $2 = PyString_Size($input);
};

int count(char c, char *str, int len);

When a multi-argument typemap is defined, the arguments are always handled as a single Python object. This allows the function to be used like this (notice how the length parameter is omitted):

>>> example.count('e','Hello World')
1
>>>

36.8.2 Python typemaps

The previous section illustrated an "in" typemap for converting Python objects to C. A variety of different typemap methods are defined by the Python module. For example, to convert a C integer back into a Python object, you might define an "out" typemap like this:

%typemap(out) int {
    $result = PyInt_FromLong((long) $1);
}

A detailed list of available methods can be found in the " Typemaps" chapter.

However, the best source of typemap information (and examples) is probably the Python module itself. In fact, all of SWIG's default type handling is defined by typemaps. You can view these typemaps by looking at the files in the SWIG library. Just take into account that in the latest versions of swig (1.3.22+), the library files are not very pristine clear for the casual reader, as they used to be. The extensive use of macros and other ugly techniques in the latest version produce a very powerful and consistent python typemap library, but at the cost of simplicity and pedagogic value.

To learn how to write a simple or your first typemap, you better take a look at the SWIG library version 1.3.20 or so.

36.8.3 Typemap variables

Within typemap code, a number of special variables prefaced with a $ may appear. A full list of variables can be found in the " Typemaps" chapter. This is a list of the most common variables:

$1

A C local variable corresponding to the actual type specified in the %typemap directive. For input values, this is a C local variable that's supposed to hold an argument value. For output values, this is the raw result that's supposed to be returned to Python.

$input

A PyObject * holding a raw Python object with an argument or variable value.

$result

A PyObject * that holds the result to be returned to Python.

$1_name

The parameter name that was matched.

$1_type

The actual C datatype matched by the typemap.

$1_ltype

An assignable version of the datatype matched by the typemap (a type that can appear on the left-hand-side of a C assignment operation). This type is stripped of qualifiers and may be an altered version of $1_type. All arguments and local variables in wrapper functions are declared using this type so that their values can be properly assigned.

$symname

The Python name of the wrapper function being created.

36.8.4 Useful Python Functions

When you write a typemap, you usually have to work directly with Python objects. The following functions may prove to be useful.

Python Integer Functions

PyObject *PyInt_FromLong(long l);
long      PyInt_AsLong(PyObject *);
int       PyInt_Check(PyObject *);

Python Floating Point Functions

PyObject *PyFloat_FromDouble(double);
double    PyFloat_AsDouble(PyObject *);
int       PyFloat_Check(PyObject *);

Python String Functions

PyObject *PyString_FromString(char *);
PyObject *PyString_FromStringAndSize(char *, lint len);
int       PyString_Size(PyObject *);
char     *PyString_AsString(PyObject *);
int       PyString_Check(PyObject *);

Python List Functions

PyObject *PyList_New(int size);
int       PyList_Size(PyObject *list);
PyObject *PyList_GetItem(PyObject *list, int i);
int       PyList_SetItem(PyObject *list, int i, PyObject *item);
int       PyList_Insert(PyObject *list, int i, PyObject *item);
int       PyList_Append(PyObject *list, PyObject *item);
PyObject *PyList_GetSlice(PyObject *list, int i, int j);
int       PyList_SetSlice(PyObject *list, int i, int , PyObject *list2);
int       PyList_Sort(PyObject *list);
int       PyList_Reverse(PyObject *list);
PyObject *PyList_AsTuple(PyObject *list);
int       PyList_Check(PyObject *);

Python Tuple Functions

PyObject *PyTuple_New(int size);
int       PyTuple_Size(PyObject *);
PyObject *PyTuple_GetItem(PyObject *, int i);
int       PyTuple_SetItem(PyObject *, int i, PyObject *item);
PyObject *PyTuple_GetSlice(PyObject *t, int i, int j);
int       PyTuple_Check(PyObject *);

Python Dictionary Functions

PyObject *PyDict_New();
int       PyDict_Check(PyObject *);
int       PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val);
int       PyDict_SetItemString(PyObject *p, const char *key, PyObject *val);
int       PyDict_DelItem(PyObject *p, PyObject *key);
int       PyDict_DelItemString(PyObject *p, char *key);
PyObject* PyDict_Keys(PyObject *p);
PyObject* PyDict_Values(PyObject *p);
PyObject* PyDict_GetItem(PyObject *p, PyObject *key);
PyObject* PyDict_GetItemString(PyObject *p, const char *key);
int       PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue);
Py_ssize_t PyDict_Size(PyObject *p);
int       PyDict_Update(PyObject *a, PyObject *b);
int       PyDict_Merge(PyObject *a, PyObject *b, int override);
PyObject* PyDict_Items(PyObject *p);

Python File Conversion Functions

PyObject *PyFile_FromFile(FILE *f);
FILE     *PyFile_AsFile(PyObject *);
int       PyFile_Check(PyObject *);

Abstract Object Interface

write me

36.9 Typemap Examples

This section includes a few examples of typemaps. For more examples, you might look at the files "python.swg" and "typemaps.i " in the SWIG library.

36.9.1 Converting Python list to a char **

A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Python list object to be used as a char ** object.

%module argv

// This tells SWIG to treat char ** as a special case
%typemap(in) char ** {
  /* Check if is a list */
  if (PyList_Check($input)) {
    int size = PyList_Size($input);
    int i = 0;
    $1 = (char **) malloc((size+1)*sizeof(char *));
    for (i = 0; i < size; i++) {
      PyObject *o = PyList_GetItem($input,i);
      if (PyString_Check(o))
	$1[i] = PyString_AsString(PyList_GetItem($input,i));
      else {
	PyErr_SetString(PyExc_TypeError,"list must contain strings");
	free($1);
	return NULL;
      }
    }
    $1[i] = 0;
  } else {
    PyErr_SetString(PyExc_TypeError,"not a list");
    return NULL;
  }
}

// This cleans up the char ** array we malloc'd before the function call
%typemap(freearg) char ** {
  free((char *) $1);
}

// Now a test function
%inline %{
int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
         printf("argv[%d] = %s\n", i,argv[i]);
         i++;
    }
    return i;
}
%}

When this module is compiled, the wrapped C function now operates as follows :

>>> from argv import *
>>> print_args(["Dave","Mike","Mary","Jane","John"])
argv[0] = Dave
argv[1] = Mike
argv[2] = Mary
argv[3] = Jane
argv[4] = John
5

In the example, two different typemaps are used. The "in" typemap is used to receive an input argument and convert it to a C array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

36.9.2 Expanding a Python object into multiple arguments

Suppose that you had a collection of C functions with arguments such as the following:

int foo(int argc, char **argv);

In the previous example, a typemap was written to pass a Python list as the char **argv. This allows the function to be used from Python as follows:

>>> foo(4, ["foo","bar","spam","1"])

Although this works, it's a little awkward to specify the argument count. To fix this, a multi-argument typemap can be defined. This is not very difficult--you only have to make slight modifications to the previous example:

%typemap(in) (int argc, char **argv) {
  /* Check if is a list */
  if (PyList_Check($input)) {
    int i;
    $1 = PyList_Size($input);
    $2 = (char **) malloc(($1+1)*sizeof(char *));
    for (i = 0; i < $1; i++) {
      PyObject *o = PyList_GetItem($input,i);
      if (PyString_Check(o))
	$2[i] = PyString_AsString(PyList_GetItem($input,i));
      else {
	PyErr_SetString(PyExc_TypeError,"list must contain strings");
	free($2);
	return NULL;
      }
    }
    $2[i] = 0;
  } else {
    PyErr_SetString(PyExc_TypeError,"not a list");
    return NULL;
  }
}

%typemap(freearg) (int argc, char **argv) {
  free((char *) $2);
}

When writing a multiple-argument typemap, each of the types is referenced by a variable such as $1 or $2. The typemap code simply fills in the appropriate values from the supplied Python object.

With the above typemap in place, you will find it no longer necessary to supply the argument count. This is automatically set by the typemap code. For example:

>>> foo(["foo","bar","spam","1"])

36.9.3 Using typemaps to return arguments

A common problem in some C programs is that values may be returned in arguments rather than in the return value of a function. For example:

/* Returns a status value and two values in out1 and out2 */
int spam(double a, double b, double *out1, double *out2) {
	... Do a bunch of stuff ...
	*out1 = result1;
	*out2 = result2;
	return status;
}

A typemap can be used to handle this case as follows :

%module outarg

// This tells SWIG to treat an double * argument with name 'OutValue' as
// an output value.  We'll append the value to the current result which 
// is guaranteed to be a List object by SWIG.

%typemap(argout) double *OutValue {
    PyObject *o, *o2, *o3;
    o = PyFloat_FromDouble(*$1);
    if ((!$result) || ($result == Py_None)) {
        $result = o;
    } else {
        if (!PyTuple_Check($result)) {
            PyObject *o2 = $result;
            $result = PyTuple_New(1);
            PyTuple_SetItem(target,0,o2);
        }
        o3 = PyTuple_New(1);
        PyTuple_SetItem(o3,0,o);
        o2 = $result;
        $result = PySequence_Concat(o2,o3);
        Py_DECREF(o2);
        Py_DECREF(o3);
    }
}

int spam(double a, double b, double *OutValue, double *OutValue);

The typemap works as follows. First, a check is made to see if any previous result exists. If so, it is turned into a tuple and the new output value is concatenated to it. Otherwise, the result is returned normally. For the sample function spam(), there are three output values--meaning that the function will return a 3-tuple of the results.

As written, the function must accept 4 arguments as input values, last two being pointers to doubles. If these arguments are only used to hold output values (and have no meaningful input value), an additional typemap can be written. For example:

%typemap(in,numinputs=0) double *OutValue(double temp) {
    $1 = &temp;
}

By specifying numinputs=0, the input value is ignored. However, since the argument still has to be set to some meaningful value before calling C, it is set to point to a local variable temp. When the function stores its output value, it will simply be placed in this local variable. As a result, the function can now be used as follows:

>>> a = spam(4,5)
>>> print a
(0, 2.45, 5.0)
>>> x,y,z = spam(4,5)
>>>

36.9.4 Mapping Python tuples into small arrays

In some applications, it is sometimes desirable to pass small arrays of numbers as arguments. For example :

extern void set_direction(double a[4]);       // Set direction vector

This too, can be handled used typemaps as follows :

// Grab a 4 element array as a Python 4-tuple
%typemap(in) double[4](double temp[4]) {   // temp[4] becomes a local variable
  int i;
  if (PyTuple_Check($input)) {
    if (!PyArg_ParseTuple($input,"dddd",temp,temp+1,temp+2,temp+3)) {
      PyErr_SetString(PyExc_TypeError,"tuple must have 4 elements");
      return NULL;
    }
    $1 = &temp[0];
  } else {
    PyErr_SetString(PyExc_TypeError,"expected a tuple.");
    return NULL;
  }
}

This allows our set_direction function to be called from Python as follows :

>>> set_direction((0.5,0.0,1.0,-0.25))

Since our mapping copies the contents of a Python tuple into a C array, such an approach would not be recommended for huge arrays, but for small structures, this approach works fine.

36.9.5 Mapping sequences to C arrays

Suppose that you wanted to generalize the previous example to handle C arrays of different sizes. To do this, you might write a typemap as follows:

// Map a Python sequence into any sized C double array
%typemap(in) double[ANY](double temp[$1_dim0]) {
  int i;
  if (!PySequence_Check($input)) {
      PyErr_SetString(PyExc_TypeError,"Expecting a sequence");
      return NULL;
  }
  if (PyObject_Length($input) != $1_dim0) {
      PyErr_SetString(PyExc_ValueError,"Expecting a sequence with $1_dim0 elements");
      return NULL;
  }
  for (i =0; i < $1_dim0; i++) {
      PyObject *o = PySequence_GetItem($input,i);
      if (!PyFloat_Check(o)) {
         Py_XDECREF(o);
         PyErr_SetString(PyExc_ValueError,"Expecting a sequence of floats");
         return NULL;
      }
      temp[i] = PyFloat_AsDouble(o);
      Py_DECREF(o);
  }
  $1 = &temp[0];
}

In this case, the variable $1_dim0 is expanded to match the array dimensions actually used in the C code. This allows the typemap to be applied to types such as:

void foo(double x[10]);
void bar(double a[4], double b[8]);

Since the above typemap code gets inserted into every wrapper function where used, it might make sense to use a helper function instead. This will greatly reduce the amount of wrapper code. For example:

%{
static int convert_darray(PyObject *input, double *ptr, int size) {
  int i;
  if (!PySequence_Check(input)) {
      PyErr_SetString(PyExc_TypeError,"Expecting a sequence");
      return 0;
  }
  if (PyObject_Length(input) != size) {
      PyErr_SetString(PyExc_ValueError,"Sequence size mismatch");
      return 0;
  }
  for (i =0; i < size; i++) {
      PyObject *o = PySequence_GetItem(input,i);
      if (!PyFloat_Check(o)) {
         Py_XDECREF(o);
         PyErr_SetString(PyExc_ValueError,"Expecting a sequence of floats");
         return 0;
      }
      ptr[i] = PyFloat_AsDouble(o);
      Py_DECREF(o);
  }
  return 1;
}
%}

%typemap(in) double [ANY](double temp[$1_dim0]) {
   if (!convert_darray($input,temp,$1_dim0)) {
      return NULL;
   }
   $1 = &temp[0];
}

36.9.6 Pointer handling

Occasionally, it might be necessary to convert pointer values that have been stored using the SWIG typed-pointer representation. Since there are several ways in which pointers can be represented, the following two functions are used to safely perform this conversion:

int SWIG_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags)

Converts a Python object obj to a C pointer. The result of the conversion is placed into the pointer located at ptr. ty is a SWIG type descriptor structure. flags is used to handle error checking and other aspects of conversion. It is the bitwise-or of several flag values including SWIG_POINTER_EXCEPTION and SWIG_POINTER_DISOWN . The first flag makes the function raise an exception on type error. The second flag additionally steals ownership of an object. Returns 0 on success and -1 on error.

PyObject *SWIG_NewPointerObj(void *ptr, swig_type_info *ty, int own)

Creates a new Python pointer object. ptr is the pointer to convert, ty is the SWIG type descriptor structure that describes the type, and own is a flag that indicates whether or not Python should take ownership of the pointer.

Both of these functions require the use of a special SWIG type-descriptor structure. This structure contains information about the mangled name of the datatype, type-equivalence information, as well as information about converting pointer values under C++ inheritance. For a type of Foo *, the type descriptor structure is usually accessed as follows:

Foo *f;
if (SWIG_ConvertPtr($input, (void **) &f, SWIGTYPE_p_Foo, SWIG_POINTER_EXCEPTION) == -1)
  return NULL;

PyObject *obj;
obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);

In a typemap, the type descriptor should always be accessed using the special typemap variable $1_descriptor. For example:

%typemap(in) Foo * {
if ((SWIG_ConvertPtr($input,(void **) &$1, $1_descriptor,SWIG_POINTER_EXCEPTION)) == -1)
  return NULL;
}

If necessary, the descriptor for any type can be obtained using the $descriptor() macro in a typemap. For example:

%typemap(in) Foo * {
if ((SWIG_ConvertPtr($input,(void **) &$1, $descriptor(Foo *), 
                                               SWIG_POINTER_EXCEPTION)) == -1)
  return NULL;
}

Although the pointer handling functions are primarily intended for manipulating low-level pointers, both functions are fully aware of Python proxy classes. Specifically, SWIG_ConvertPtr() will retrieve a pointer from any object that has a this attribute. In addition, SWIG_NewPointerObj() can automatically generate a proxy class object (if applicable).

36.10 Docstring Features

Using docstrings in Python code is becoming more and more important and more tools are coming on the scene that take advantage of them, everything from full-blown documentation generators to class browsers and popup call-tips in Python-aware IDEs. Given the way that SWIG generates the proxy code by default, your users will normally get something like "function_name(*args)" in the popup calltip of their IDE which is next to useless when the real function prototype might be something like this:

bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);

The features described in this section make it easy for you to add docstrings to your modules, functions and methods that can then be used by the various tools out there to make the programming experience of your users much simpler.

36.10.1 Module docstring

Python allows a docstring at the beginning of the .py file before any other statements, and it is typically used to give a general description of the entire module. SWIG supports this by setting an option of the %module directive. For example:

%module(docstring="This is the example module's docstring") example

When you have more than just a line or so then you can retain the easy readability of the %module directive by using a macro. For example:

%define DOCSTRING
"The `XmlResource` class allows program resources defining menus, 
layout of controls on a panel, etc. to be loaded from an XML file."
%enddef

%module(docstring=DOCSTRING) xrc

36.10.2 %feature("autodoc")

As alluded to above SWIG will generate all the function and method proxy wrappers with just "*args" (or "*args, **kwargs" if the -keyword option is used) for a parameter list and will then sort out the individual parameters in the C wrapper code. This is nice and simple for the wrapper code, but makes it difficult to be programmer and tool friendly as anyone looking at the .py file will not be able to find out anything about the parameters that the functions accept.

But since SWIG does know everything about the function it is possible to generate a docstring containing the parameter types, names and default values. Since many of the docstring tools are adopting a standard of recognizing if the first thing in the docstring is a function prototype then using that instead of what they found from introspection, then life is good once more.

SWIG's Python module provides support for the "autodoc" feature, which when attached to a node in the parse tree will cause a docstring to be generated that includes the name of the function, parameter names, default values if any, and return type if any. There are also four levels for autodoc controlled by the value given to the feature, %feature("autodoc", "level"). The four values for level are covered in the following sub-sections.

36.10.2.1 %feature("autodoc", "0")

When level "0" is used then the types of the parameters will not be included in the autodoc string. For example, given this function prototype:

%feature("autodoc", "0");
bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);

Then Python code like this will be generated:

def function_name(*args, **kwargs):
    """function_name(x, y, foo=None, bar=None) -> bool"""
    ...

36.10.2.2 %feature("autodoc", "1")

When level "1" is used then the parameter types will be used in the autodoc string. In addition, an attempt is made to simplify the type name such that it makes more sense to the Python user. Pointer, reference and const info is removed if the associated type is has an associated Python type (%rename's are thus shown correctly). This works most of the time, otherwise a C/C++ type will be used. See the next section for the "docstring" feature for tweaking the docstrings to your liking. Given the example above, then turning on the parameter types with level "1" will result in Python code like this:

def function_name(*args, **kwargs):
    """function_name(int x, int y, Foo foo=None, Bar bar=None) -> bool"""
    ...

36.10.2.3 %feature("autodoc", "2")

Level "2" results in the function prototype as per level "0". In addition, a line of documentation is generated for each parameter. Using the previous example, the generated code will be:

def function_name(*args, **kwargs):
    """
    function_name(x, y, foo=None, bar=None) -> bool

    Parameters:
        x: int
        y: int
        foo: Foo *
        bar: Bar *

    """
    ...

Note that the documentation for each parameter is sourced from the "doc" typemap which by default shows the C/C++ type rather than the simplified Python type name described earlier for level "1". Typemaps can of course change the output for any particular type, for example the int x parameter:

%feature("autodoc", "2");
%typemap("doc") int x "$1_name (C++ type: $1_type) -- Input $1_name dimension"
bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);

resulting in

def function_name(*args, **kwargs):
  """
    function_name(x, y, foo=None, bar=None) -> bool

    Parameters:
        x (C++ type: int) -- Input x dimension
        y: int
        foo: Foo *
        bar: Bar *

    """

36.10.2.4 %feature("autodoc", "3")

Level "3" results in the function prototype as per level "1" but also contains the same additional line of documentation for each parameter as per level "2". Using our earlier example again, the generated code will be:

def function_name(*args, **kwargs):
    """
    function_name(int x, int y, Foo foo=None, Bar bar=None) -> bool

    Parameters:
        x: int
        y: int
        foo: Foo *
        bar: Bar *

    """
    ...

36.10.2.5 %feature("autodoc", "docstring")

Finally, there are times when the automatically generated autodoc string will make no sense for a Python programmer, particularly when a typemap is involved. So if you give an explicit value for the autodoc feature then that string will be used in place of the automatically generated string. For example:

%feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
void GetPosition(int* OUTPUT, int* OUTPUT);

36.10.3 %feature("docstring")

In addition to the autodoc strings described above, you can also attach any arbitrary descriptive text to a node in the parse tree with the "docstring" feature. When the proxy module is generated then any docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together. If the docstring is all on a single line then it is output like this::

"""This is the docstring"""

Otherwise, to aid readability it is output like this:

"""
This is a multi-line docstring
with more than one line.
"""

36.11 Python Packages

Python has concepts of modules and packages. Modules are separate units of code and may be grouped together to form a package. Packages may be nested, that is they may contain subpackages. This leads to tree-like hierarchy, with packages as intermediate nodes and modules as leaf nodes.

The hierarchy of Python packages/modules follows the hierarchy of *.py files found in a source tree (or, more generally, in the Python path). Normally, the developer creates new module by placing a *.py file somewhere under Python path; the module is then named after that *.py file. A package is created by placing an __init__.py file within a directory; the package is then named after that directory. For example, the following source tree:

mod1.py
pkg1/__init__.py
pkg1/mod2.py
pkg1/pkg2/__init__.py
pkg1/pkg2/mod3.py

defines the following Python packages and modules:

pkg1            # package
pkg1.pkg2       # package
mod1            # module
pkg1.mod2       # module
pkg1.pkg2.mod3  # module

The purpose of an __init__.py file is two-fold. First, the existence of __init__.py in a directory informs the Python interpreter that this directory contains a Python package. Second, the code in __init__.py is loaded/executed automatically when the package is initialized (when it or its submodule/subpackage gets import'ed). By default, SWIG generates proxy Python code – one *.py file for each *.i interface. The __init__.py files, however, are not generated by SWIG. They should be created by other means. Both files (module *.py and __init__.py) should be installed in appropriate destination directories in order to obtain a desirable package/module hierarchy.

The way Python defines its modules and packages impacts SWIG users. Some users may need to use special features such as the package option in the %module directive or import related command line options. These are explained in the following sections.

36.11.1 Setting the Python package

Using the package option in the %module directive allows you to specify a Python package that the module will be in when installed.

%module(package="wx") xrc

This is useful when the .i file is %imported by another .i file. By default SWIG will assume that the importer is able to find the importee with just the module name, but if they live in separate Python packages then this won't work. However if the importee specifies what its package is with the %module option then the Python code generated for the importer will use that package name when importing the other module and in base class declarations, etc..

SWIG assumes that the package option provided to %module together with the module name (that is, wx.xrc in the above example) forms a fully qualified (absolute) name of a module (in Python terms). This is important especially for Python 3, where absolute imports are used by default. It's up to you to place the generated module files (.py, .so) in appropriate subdirectories. For example, if you have an interface file foo.i with:

%module(package="pkg1.pkg2") foo

then the resulting directory layout should be

pkg1/
pkg1/__init__.py
pkg1/pkg2/__init__.py
pkg1/pkg2/foo.py        # (generated by SWIG)
pkg1/pkg2/_foo.so       # (shared library built from C/C++ code generated by SWIG)

36.11.2 Absolute and relative imports

Suppose, we have the following hierarchy of files:

pkg1/
pkg1/__init__.py
pkg1/mod2.py
pkg1/pkg2/__init__.py
pkg1/pkg2/mod3.py

Let the contents of pkg1/pkg2/mod3.py be

class M3: pass

We edit pkg1/mod2.py and want to import module pkg1/pkg2/mod3.py in order to derive from class M3. We can write appropriate Python code in several ways, for example:

  1. Using "import <>" syntax with absolute package name:

    # pkg1/mod2.py
    import pkg1.pkg2.mod3
    class M2(pkg1.pkg2.mod3.M3): pass
    
  2. Using "import <>" syntax with package name relative to pkg1 (only in Python 2.7 and earlier):

    # pkg1/mod2.py
    import pkg2.mod3
    class M2(pkg2.mod3.M3): pass
    
  3. Using "from <> import <>" syntax (relative import syntax, only in Python 2.5 and later):

    # pkg1/mod2.py
    from .pkg2 import mod3
    class M2(mod3.M3): pass
    
  4. Other variants, for example the following construction in order to have the pkg2.mod3.M3 symbol available in mod2 as in point 2 above (but now under Python 3):

    # pkg1/mod2.py
    from . import pkg2
    from .pkg2 import mod3
    class M2(pkg2.mod3.M3): pass
    

Now suppose we have mod2.i with

// mod2.i
%module (package="pkg1") mod2
%import "mod3.i"
// ...

and mod3.i with

// mod3.i
%module (package="pkg1.pkg2") mod3
// ...

By default, SWIG would generate mod2.py proxy file with import directive as in point 1. This can be changed with the -relativeimport command line option. The -relativeimport instructs SWIG to organize imports as in point 2 (for Python 2.x) or as in point 4 (for Python 3, that is when the -py3 command line option is enabled). In short, if you have mod2.i and mod3.i as above, then without -relativeimport SWIG will write

import pkg1.pkg2.mod3

to mod2.py proxy file, and with -relativeimport it will write

import pkg2.mod3

if -py3 is not used, or

from . import pkg2
import pkg1.pkg2.mod3

when -py3 is used.

You should avoid using relative imports and use absolute ones whenever possible. There are some cases, however, when relative imports may be necessary. The first example is, when some (legacy) Python code refers entities imported by proxy files generated by SWIG, and it assumes that the proxy file uses relative imports. Second case is, when one puts import directives in __init__.py to import symbols from submodules or subpackages and the submodule depends on other submodules (discussed later).

36.11.3 Enforcing absolute import semantics

As you may know, there is an incompatibility in import semantics (for the import <> syntax) between Python 2 and 3. In Python 2.4 and earlier it is not clear whether

import foo

refers to a top-level module or to another module inside the current package. In Python 3 it always refers to a top-level module (see PEP 328). To instruct Python 2.5 through 2.7 to use new semantics (that is import foo is interpreted as absolute import), one has to put the following line

from __future__ import absolute_import

at the very beginning of his proxy *.py file. In SWIG, it may be accomplished with %pythonbegin directive as follows:

%pythonbegin %{
from __future__ import absolute_import
%}

36.11.4 Importing from __init__.py

Imports in __init__.py are handy when you want to populate a package's namespace with names imported from other modules. In SWIG based projects this approach may also be used to split large pieces of code into smaller modules, compile them in parallel and then re-assemble everything at runtime by importing submodules' contents in __init__.py, for example.

Unfortunately import directives in __init__.py may cause problems, especially if they refer to a package's submodules. This is caused by the way Python initializes packages. If you spot problems with imports from __init__.py try using -relativeimport option. Below we explain in detail one issue, for which the -relativeimport workaround may be helpful.

Consider the following example (Python 3):

pkg1/__init__.py        # (empty)
pkg1/pkg2/__init__.py   # (imports something from bar.py)
pkg1/pkg2/foo.py
pkg1/pkg2/bar.py        # (imports foo.py)

If the file contents are:

  • pkg1/pkg2/__init__.py:

    # pkg1/pkg2/__init__.py
    from .bar import Bar
    
  • pkg1/pkg2/foo.py:

    # pkg1/pkg2/foo.py
    class Foo: pass
    
  • pkg1/pkg2/bar.py:

    # pkg1/pkg2/bar.py
    import pkg1.pkg2.foo
    class Bar(pkg1.pkg2.foo.Foo): pass
    

Now if one simply used import pkg1.pkg2, it will usually fail:

>>> import pkg1.pkg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./pkg1/pkg2/__init__.py", line 2, in <module>
    from .bar import Bar
  File "./pkg1/pkg2/bar.py", line 3, in <module>
    class Bar(pkg1.pkg2.foo.Foo): pass
AttributeError: 'module' object has no attribute 'pkg2'

Surprisingly, if we execute the import pkg1.pkg2 directive for the second time, it succeeds. The reason seems to be following: when Python spots the from .bar import Bar directive in pkg1/pkg2/__init__.py it starts loading pkg1/pkg2/bar.py. This module imports pkg1.pkg2.foo in turn and tries to use pkg1.pkg2.foo.Foo, but the package pkg1 is not fully initialized yet (the initialization procedure is actually in progress) and it seems like the effect of the already seen import pkg1.pkg2.pkg3.foo is "delayed" or ignored. Exactly the same may happen to a proxy module generated by SWIG.

One workaround for this case is to use a relative import in pkg1/pkg2/bar.py. If we change bar.py to be:

from .pkg3 import foo
class Bar(foo.Foo): pass

or

from . import pkg3
from .pkg3 import foo
class Bar(pkg3.foo.Foo): pass

then the example works again. With SWIG, you need to enable the -relativeimport option in order to have the above workaround in effect (note, that the Python 2 case also needs the -relativeimport workaround).

36.12 Python 3 Support

SWIG is able to support Python 3.0. The wrapper code generated by SWIG can be compiled with both Python 2.x or 3.0. Further more, by passing the -py3 command line option to SWIG, wrapper code with some Python 3 specific features can be generated (see below subsections for details of these features). The -py3 option also disables some incompatible features for Python 3, such as -classic.

There is a list of known-to-be-broken features in Python 3:

  • No more support for FILE* typemaps, because PyFile_AsFile has been dropped in Python 3.
  • The -apply command line option is removed and generating code using apply() is no longer supported.

The following are Python 3.0 new features that are currently supported by SWIG.

36.12.1 Function annotation

The -py3 option will enable function annotation support. When used SWIG is able to generate proxy method definitions like this:

  def foo(self, bar : "int"=0) -> "void" : ...

Also, even if without passing SWIG the -py3 option, the parameter list still could be generated:

  def foo(self, bar=0): ...

But for overloaded function or method, the parameter list would fallback to *args or self, *args, and **kwargs may be append depend on whether you enabled the keyword argument. This fallback is due to all overloaded functions share the same function in SWIG generated proxy class.

For detailed usage of function annotation, see PEP 3107.

36.12.2 Buffer interface

Buffer protocols were revised in Python 3. SWIG also gains a series of new typemaps to support buffer interfaces. These typemap macros are defined in pybuffer.i, which must be included in order to use them. By using these typemaps, your wrapped function will be able to accept any Python object that exposes a suitable buffer interface.

For example, the get_path() function puts the path string into the memory pointed to by its argument:

void get_path(char *s);

Then you can write a typemap like this: (the following example is applied to both Python 3.0 and 2.6, since the bytearray type is backported to 2.6.

%include <pybuffer.i>
%pybuffer_mutable_string(char *str);
void get_path(char *s);

And then on the Python side the wrapped get_path could be used in this way:

>>> p = bytearray(10)
>>> get_path(p)
>>> print(p)
bytearray(b'/Foo/Bar/\x00')

The macros defined in pybuffer.i are similar to those in cstring.i:

%pybuffer_mutable_binary(parm, size_parm)

The macro can be used to generate a typemap which maps a buffer of an object to a pointer provided by parm and a size argument provided by size_parm. For example:

%pybuffer_mutable_binary(char *str, size_t size);
...
int snprintf(char *str, size_t size, const char *format, ...);

In Python:

>>> buf = bytearray(6)
>>> snprintf(buf, "Hello world!")
>>> print(buf)
bytearray(b'Hello\x00')
>>> 

%pybuffer_mutable_string(parm)

This typemap macro requires the buffer to be a zero terminated string, and maps the pointer of the buffer to parm. For example:

%pybuffer_mutable_string(char *str);
...
size_t make_upper(char *str);

In Python:

>>> buf = bytearray(b'foo\x00')
>>> make_upper(buf)
>>> print(buf)
bytearray(b'FOO\x00')
>>>

Both %pybuffer_mutable_binary and %pybuffer_mutable_string require the provided buffer to be mutable, eg. they can accept a bytearray type but can't accept an immutable byte type.

%pybuffer_binary(parm, size_parm)

This macro maps an object's buffer to a pointer parm and a size size_parm. It is similar to %pybuffer_mutable_binary , except the %pybuffer_binary an accept both mutable and immutable buffers. As a result, the wrapped function should not modify the buffer.

%pybuffer_string(parm)

This macro maps an object's buffer as a string pointer parm . It is similar to %pybuffer_mutable_string but the buffer could be both mutable and immutable. And your function should not modify the buffer.

36.12.3 Abstract base classes

By including pyabc.i and using the -py3 command line option when calling SWIG, the proxy classes of the STL containers will automatically gain an appropriate abstract base class. For example, the following SWIG interface:

%include <pyabc.i>
%include <std_map.i>
%include <std_list.i>

namespace std {
  %template(Mapii) map<int, int>;
  %template(IntList) list<int>;
}

will generate a Python proxy class Mapii inheriting from collections.MutableMap and a proxy class IntList inheriting from collections.MutableSequence.

pyabc.i also provides a macro %pythonabc that could be used to define an abstract base class for your own C++ class:

%pythonabc(MySet, collections.MutableSet);

For details of abstract base class, please see PEP 3119.

36.12.4 Byte string output conversion

By default, any byte string (char* or std::string) returned from C or C++ code is decoded to text as UTF-8. This decoding uses the surrogateescape error handler under Python 3.1 or higher -- this error handler decodes invalid byte sequences to high surrogate characters in the range U+DC80 to U+DCFF. As an example, consider the following SWIG interface, which exposes a byte string that cannot be completely decoded as UTF-8:

%module example

%include <std_string.i>

%inline %{

const char* non_utf8_c_str(void) {
        return "h\xe9llo w\xc3\xb6rld";
}

%}

When this method is called from Python 3, the return value is the following text string:

>>> s = example.non_utf8_c_str()
>>> s
'h\udce9llo wörld'

Since the C string contains bytes that cannot be decoded as UTF-8, those raw bytes are represented as high surrogate characters that can be used to obtain the original byte sequence:

>>> b = s.encode('utf-8', errors='surrogateescape')
>>> b
b'h\xe9llo w\xc3\xb6rld'

One can then attempt a different encoding, if desired (or simply leave the byte string as a raw sequence of bytes for use in binary protocols):

>>> b.decode('latin-1')
'héllo wörld'

Note, however, that text strings containing surrogate characters are rejected with the default strict codec error handler. For example:

>>> with open('test', 'w') as f:
...     print(s, file=f)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode character '\udce9' in position 1: surrogates not allowed

This requires the user to check most strings returned by SWIG bindings, but the alternative is for a non-UTF8 byte string to be completely inaccessible in Python 3 code.

For more details about the surrogateescape error handler, please see PEP 383 .


37 SWIG and R

R is a GPL'ed open source statistical and plotting environment. Information about R can be found at www.r-project.org. The R bindings are under active development. They have been used to compile and run an R interface to QuantLib running on Mandriva Linux with gcc. The R bindings also work on Microsoft Windows using Visual C++.

37.1 Bugs

Currently the following features are not implemented or broken:

  • Garbage collection of created objects
  • C Array wrappings

37.2 Using R and SWIG

To use R and SWIG in C mode, execute the following commands where example.c is the name of the file with the functions in them

swig -r example.i
R CMD SHLIB example_wrap.c example.c

The corresponding options for C++ mode are

swig -c++ -r -o example_wrap.cpp example.i
R CMD SHLIB example_wrap.cpp example.cpp

Note that R is sensitive to the names of the files. The name of the wrapper file must be the name of the library unless you use the -o option to R when building the library, for example:

swig -c++ -r -o example_wrap.cpp example.i
R CMD SHLIB -o example.so example_wrap.cpp example.cpp

R is also sensitive to the name of the file extension in C and C++ mode. In C++ mode, the file extension must be .cpp rather than .cxx for the R compile command to recognize it. If your C++ code is in a file using something other than a .cpp extension, then it may still work using PKG_LIBS:

swig -c++ -r -o example_wrap.cpp example.i
PKG_LIBS="example.cxx" R CMD SHLIB -o example example_wrap.cpp

The commands produces two files. A dynamic shared object file called example.so, or example.dll, and an R wrapper file called example.R. To load these files, start up R and type in the following commands

dyn.load(paste("example", .Platform$dynlib.ext, sep=""))
source("example.R")
cacheMetaData(1)
The cacheMetaData(1) will cause R to refresh its object tables. Without it, inheritance of wrapped objects may fail.

These two files can be loaded in any order

37.3 Precompiling large R files

In cases where the R file is large, one make save a lot of loading time by precompiling the R wrapper. This can be done by creating the file makeRData.R which contains the following
source('BigFile.R')
save(list=ls(all=TRUE),file="BigFile.RData", compress=TRUE)
q(save="no")
This will generate a compiled R file called BigFile.RData that will save a large amount of loading time.

37.4 General policy

The general policy of the module is to treat the C/C++ as a basic wrapping over the underlying functions and rely on the R type system to provide R syntax.

37.5 Language conventions

getitem and setitem use C++ conventions (i.e. zero based indices). [

37.6 C++ classes

C++ objects are implemented as external pointer objects with the class being the mangled name of the class. The C++ classes are encapsulated as an SEXP with an external pointer type. The class is the mangled name of the class. The nice thing about R is that is allows you to keep track of the pointer object which removes the necessity for a lot of the proxy class baggage you see in other languages.

37.7 Enumerations

enumerations are characters which are then converted back and forth to ints before calling the C routines. All of the enumeration code is done in R.


38 SWIG and Ruby

This chapter describes SWIG's support of Ruby.

38.1 Preliminaries

SWIG 1.3 is known to work with Ruby versions 1.6 and later. Given the choice, you should use the latest stable version of Ruby. You should also determine if your system supports shared libraries and dynamic loading. SWIG will work with or without dynamic loading, but the compilation process will vary.

This chapter covers most SWIG features, but in less depth than is found in earlier chapters. At the very least, make sure you also read the "SWIG Basics" chapter. It is also assumed that the reader has a basic understanding of Ruby.

38.1.1 Running SWIG

To build a Ruby module, run SWIG using the -ruby option:

$ swig -ruby example.i

If building a C++ extension, add the -c++ option:

$ swig -c++ -ruby example.i

This creates a file example_wrap.c (example_wrap.cxx if compiling a C++ extension) that contains all of the code needed to build a Ruby extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

38.1.2 Getting the right header files

In order to compile the wrapper code, the compiler needs the ruby.h header file. This file is usually contained in a directory such as

/usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
/usr/local/lib/ruby/1.6/i686-linux/ruby.h

The exact location may vary on your machine, but the above location is typical. If you are not entirely sure where Ruby is installed, you can run Ruby to find out. For example:

$ ruby -e 'puts $:.join("\n")'
/usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
/usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .

38.1.3 Compiling a dynamic module

Ruby extension modules are typically compiled into shared libraries that the interpreter loads dynamically at runtime. Since the exact commands for doing this vary from platform to platform, your best bet is to follow the steps described in the README.EXT file from the Ruby distribution:

  1. Create a file called extconf.rb that looks like the following:

    require 'mkmf'
    create_makefile('example')
  2. Type the following to build the extension:

    $ ruby extconf.rb
    $ make
    $ make install
        

Of course, there is the problem that mkmf does not work correctly on all platforms, e.g, HPUX. If you need to add your own make rules to the file that extconf.rb produces, you can add this:

open("Makefile", "a") { |mf|
 puts <<EOM
 # Your make rules go here
 EOM
}

to the end of the extconf.rb file. If for some reason you don't want to use the standard approach, you'll need to determine the correct compiler and linker flags for your build platform. For example, assuming you have code you need to link to in a file called example.c, a typical sequence of commands for the Linux operating system would look something like this:

$ swig -ruby example.i
$ gcc -O2 -fPIC -c example.c
$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
$ gcc -shared example.o example_wrap.o -o example.so

The -fPIC option tells GCC to generate position-independent code (PIC) which is required for most architectures (it's not vital on x86, but still a good idea as it allows code pages from the library to be shared between processes). Other compilers may need a different option specified instead of -fPIC.

If in doubt, consult the manual pages for your compiler and linker to determine the correct set of options. You might also check the SWIG Wiki for additional information.

38.1.4 Using your module

Ruby module names must be capitalized, but the convention for Ruby feature names is to use lowercase names. So, for example, the Etc extension module is imported by requiring the etc feature:

# The feature name begins with a lowercase letter...
require 'etc'

# ... but the module name begins with an uppercase letter
puts "Your login name: #{Etc.getlogin}"

To stay consistent with this practice, you should always specify a lowercase module name with SWIG's %module directive. SWIG will automatically correct the resulting Ruby module name for your extension. So for example, a SWIG interface file that begins with:

%module example

will result in an extension module using the feature name "example" and Ruby module name "Example".

38.1.5 Static linking

An alternative approach to dynamic linking is to rebuild the Ruby interpreter with your extension module added to it. In the past, this approach was sometimes necessary due to limitations in dynamic loading support on certain machines. However, the situation has improved greatly over the last few years and you should not consider this approach unless there is really no other option.

The usual procedure for adding a new module to Ruby involves finding the Ruby source, adding an entry to the ext/Setup file, adding your directory to the list of extensions in the file, and finally rebuilding Ruby.

38.1.6 Compilation of C++ extensions

On most machines, C++ extension modules should be linked using the C++ compiler. For example:

$ swig -c++ -ruby example.i
$ g++ -fPIC -c example.cxx
$ g++ -fPIC -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
$ g++ -shared example.o example_wrap.o -o example.so

If you've written an extconf.rb script to automatically generate a Makefile for your C++ extension module, keep in mind that (as of this writing) Ruby still uses gcc and not g++ as its linker. As a result, the required C++ runtime library support will not be automatically linked into your extension module and it may fail to load on some platforms. A workaround for this problem is use the mkmf module's append_library() method to add one of the C++ runtime libraries to the list of libraries linked into your extension, e.g.

require 'mkmf'
$libs = append_library($libs, "supc++")
create_makefile('example')

38.2 Building Ruby Extensions under Windows 95/NT

Building a SWIG extension to Ruby under Windows 95/NT is roughly similar to the process used with Unix. Normally, you will want to produce a DLL that can be loaded into the Ruby interpreter. For all recent versions of Ruby, the procedure described above (i.e. using an extconf.rb script) will work with Windows as well; you should be able to build your code into a DLL by typing:

C:\swigtest> ruby extconf.rb
C:\swigtest> nmake
C:\swigtest> nmake install

The remainder of this section covers the process of compiling SWIG-generated Ruby extensions with Microsoft Visual C++ 6 (i.e. within the Developer Studio IDE, instead of using the command line tools). In order to build extensions, you may need to download the source distribution to the Ruby package, as you will need the Ruby header files.

38.2.1 Running SWIG from Developer Studio

If you are developing your application within Microsoft developer studio, SWIG can be invoked as a custom build option. The process roughly follows these steps :

  • Open up a new workspace and use the AppWizard to select a DLL project.
  • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (i.e. example_wrap.c). Note : If using C++, choose a different suffix for the wrapper file such as example_wrap.cxx. Don't worry if the wrapper file doesn't exist yet--Developer Studio will keep a reference to it around.
  • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
  • Enter "SWIG" in the description field.
  • Enter "swig -ruby -o $(ProjDir)\$(InputName)_wrap.c $(InputPath)" in the "Build command(s) field". You may have to include the path to swig.exe.
  • Enter "$(ProjDir)\$(InputName)_wrap.c" in the "Output files(s) field".
  • Next, select the settings for the entire project and go to the C/C++ tab and select the Preprocessor category. Add NT=1 to the Preprocessor definitions. This must be set else you will get compilation errors. Also add IMPORT to the preprocessor definitions, else you may get runtime errors. Also add the include directories for your Ruby installation under "Additional include directories".
  • Next, select the settings for the entire project and go to the Link tab and select the General category. Set the name of the output file to match the name of your Ruby module (i.e.. example.dll). Next add the Ruby library file to your link libraries under Object/Library modules. For example "mswin32-ruby16.lib. You also need to add the path to the library under the Input tab - Additional library path.
  • Build your project.

Now, assuming all went well, SWIG will be automatically invoked when you build your project. Any changes made to the interface file will result in SWIG being automatically invoked to produce a new version of the wrapper file. To run your new Ruby extension, simply run Ruby and use the require command as normal. For example if you have this ruby file run.rb:

# file: run.rb
require 'Example'

# Call a c function
print "Foo = ", Example.Foo, "\n"

Ensure the dll just built is in your path or current directory, then run the Ruby script from the DOS/Command prompt:

C:\swigtest> ruby run.rb
Foo = 3.0

38.3 The Ruby-to-C/C++ Mapping

This section describes the basics of how SWIG maps C or C++ declarations in your SWIG interface files to Ruby constructs.

38.3.1 Modules

The SWIG %module directive specifies the name of the Ruby module. If you specify:

%module example

then everything is wrapped into a Ruby module named Example that is nested directly under the global module. You can specify a more deeply nested module by specifying the fully-qualified module name in quotes, e.g.

%module "foo::bar::spam"

An alternate method of specifying a nested module name is to use the -prefix option on the SWIG command line. The prefix that you specify with this option will be prepended to the module name specified with the %module directive in your SWIG interface file. So for example, this declaration at the top of your SWIG interface file:

%module "foo::bar::spam"

will result in a nested module name of Foo::Bar::Spam, but you can achieve the same effect by specifying:

%module spam

and then running SWIG with the -prefix command line option:

$ swig -ruby -prefix "foo::bar::" example.i

Starting with SWIG 1.3.20, you can also choose to wrap everything into the global module by specifying the -globalmodule option on the SWIG command line, i.e.

$ swig -ruby -globalmodule example.i

Note that this does not relieve you of the requirement of specifying the SWIG module name with the %module directive (or the -module command-line option) as described earlier.

When choosing a module name, do not use the same name as a built-in Ruby command or standard module name, as the results may be unpredictable. Similarly, if you're using the -globalmodule option to wrap everything into the global module, take care that the names of your constants, classes and methods don't conflict with any of Ruby's built-in names.

38.3.2 Functions

Global functions are wrapped as Ruby module methods. For example, given the SWIG interface file example.i:

%module example

int fact(int n);

and C source file example.c:

int fact(int n) {
  if (n == 0)
  return 1;
  return (n * fact(n-1));
}

SWIG will generate a method fact in the Example module that can be used like so:

$ irb
irb(main):001:0> require 'example'
true
irb(main):002:0> Example.fact(4)
24

38.3.3 Variable Linking

C/C++ global variables are wrapped as a pair of singleton methods for the module: one to get the value of the global variable and one to set it. For example, the following SWIG interface file declares two global variables:

// SWIG interface file with global variables
%module example
...
%inline %{
  extern int variable1;
  extern double Variable2;
%}
...

Now look at the Ruby interface:

$ irb
irb(main):001:0> require 'Example'
true
irb(main):002:0> Example.variable1 = 2
2
irb(main):003:0> Example.Variable2 = 4 * 10.3
41.2
irb(main):004:0> Example.Variable2
41.2

If you make an error in variable assignment, you will receive an error message. For example:

irb(main):005:0> Example.Variable2 = "hello"
TypeError: no implicit conversion to float from string
from (irb):5:in `Variable2='
from (irb):5

If a variable is declared as const, it is wrapped as a read-only variable. Attempts to modify its value will result in an error.

To make ordinary variables read-only, you can also use the %immutable directive. For example:

%immutable;
%inline %{
  extern char *path;
%}
%mutable;

The %immutable directive stays in effect until it is explicitly disabled using %mutable.

38.3.4 Constants

C/C++ constants are wrapped as module constants initialized to the appropriate value. To create a constant, use #define or the %constant directive. For example:

#define PI 3.14159
#define VERSION "1.0"

%constant int FOO = 42;
%constant const char *path = "/usr/local";

const int BAR = 32;

Remember to use the :: operator in Ruby to get at these constant values, e.g.

$ irb
irb(main):001:0> require 'Example'
true
irb(main):002:0> Example::PI
3.14159

38.3.5 Pointers

"Opaque" pointers to arbitrary C/C++ types (i.e. types that aren't explicitly declared in your SWIG interface file) are wrapped as data objects. So, for example, consider a SWIG interface file containing only the declarations:

Foo *get_foo();
void set_foo(Foo *foo);

For this case, the get_foo() method returns an instance of an internally generated Ruby class:

irb(main):001:0> foo = Example::get_foo()
#<SWIG::TYPE_p_Foo:0x402b1654>

A NULL pointer is always represented by the Ruby nil object.

38.3.6 Structures

C/C++ structs are wrapped as Ruby classes, with accessor methods (i.e. "getters" and "setters") for all of the struct members. For example, this struct declaration:

struct Vector {
  double x, y;
};

gets wrapped as a Vector class, with Ruby instance methods x, x=, y and y=. These methods can be used to access structure data from Ruby as follows:

$ irb
irb(main):001:0> require 'Example'
true
irb(main):002:0> f = Example::Vector.new
#<Example::Vector:0x4020b268>
irb(main):003:0> f.x = 10
nil
irb(main):004:0> f.x
10.0

Similar access is provided for unions and the public data members of C++ classes.

const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive (in C++, private may also be used). For example:

struct Foo {
  ...
  %immutable;
  int x; /* Read-only members */
  char *name;
  %mutable;
  ...
};

When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run with the -c++ option). When the structure member is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described shortly).

Array members are normally wrapped as read-only. For example, this code:

struct Foo {
  int x[50];
};

produces a single accessor function like this:

int *Foo_x_get(Foo *self) {
  return self->x;
};

If you want to set an array member, you will need to supply a "memberin" typemap described in the section on typemaps. As a special case, SWIG does generate code to set array members of type char (allowing you to store a Ruby string in the structure).

When structure members are wrapped, they are handled as pointers. For example,

struct Foo {
  ...
};

struct Bar {
  Foo f;
};

generates accessor functions such as this:

Foo *Bar_f_get(Bar *b) {
  return &b->f;
}

void Bar_f_set(Bar *b, Foo *val) {
  b->f = *val;
}

38.3.7 C++ classes

Like structs, C++ classes are wrapped by creating a new Ruby class of the same name with accessor methods for the public class member data. Additionally, public member functions for the class are wrapped as Ruby instance methods, and public static member functions are wrapped as Ruby singleton methods. So, given the C++ class declaration:

class List {
public:
  List();
  ~List();
  int search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int length;
  static void print(List *l);
};

SWIG would create a List class with:

  • instance methods search, insert, remove, and get;
  • instance methods length and length= (to get and set the value of the length data member); and,
  • a print singleton method for the class.

In Ruby, these functions are used as follows:

require 'Example'

l = Example::List.new

l.insert("Ale")
l.insert("Stout")
l.insert("Lager")
Example.print(l)
l.length()
----- produces the following output 
Lager
Stout
Ale
3

38.3.8 C++ Inheritance

The SWIG type-checker is fully aware of C++ inheritance. Therefore, if you have classes like this:

class Parent {
  ...
};

class Child : public Parent {
  ...
};

those classes are wrapped into a hierarchy of Ruby classes that reflect the same inheritance structure. All of the usual Ruby utility methods work normally:

irb(main):001:0> c = Child.new
#<Bar:0x4016efd4>
irb(main):002:0> c.instance_of? Child
true
irb(main):003:0> b.instance_of? Parent
false
irb(main):004:0> b.is_a? Child
true
irb(main):005:0> b.is_a? Parent
true
irb(main):006:0> Child < Parent
true
irb(main):007:0> Child > Parent
false

Furthermore, if you have a function like this:

void spam(Parent *f);

then the function spam() accepts Parent* or a pointer to any class derived from Parent.

Until recently, the Ruby module for SWIG didn't support multiple inheritance, and this is still the default behavior. This doesn't mean that you can't wrap C++ classes which inherit from multiple base classes; it simply means that only the first base class listed in the class declaration is considered, and any additional base classes are ignored. As an example, consider a SWIG interface file with a declaration like this:

class Derived : public Base1, public Base2
{
  ...
};

For this case, the resulting Ruby class (Derived) will only consider Base1 as its superclass. It won't inherit any of Base2's member functions or data and it won't recognize Base2 as an "ancestor" of Derived (i.e. the is_a? relationship would fail). When SWIG processes this interface file, you'll see a warning message like:

example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.
Multiple inheritance is not supported in Ruby.

Starting with SWIG 1.3.20, the Ruby module for SWIG provides limited support for multiple inheritance. Because the approach for dealing with multiple inheritance introduces some limitations, this is an optional feature that you can activate with the -minherit command-line option:

$ swig -c++ -ruby -minherit example.i

Using our previous example, if your SWIG interface file contains a declaration like this:

class Derived : public Base1, public Base2
{
  ...
};

and you run SWIG with the -minherit command-line option, then you will end up with a Ruby class Derived that appears to "inherit" the member data and functions from both Base1 and Base2. What actually happens is that three different top-level classes are created, with Ruby's Object class as their superclass. Each of these classes defines a nested module named Impl, and it's in these nested Impl modules that the actual instance methods for the classes are defined, i.e.

class Base1
  module Impl
  # Define Base1 methods here
  end
  include Impl
end

class Base2
  module Impl
  # Define Base2 methods here
  end
  include Impl
end

class Derived
  module Impl
  include Base1::Impl
  include Base2::Impl
  # Define Derived methods here
  end
  include Impl
end

Observe that after the nested Impl module for a class is defined, it is mixed-in to the class itself. Also observe that the Derived::Impl module first mixes-in its base classes' Impl modules, thus "inheriting" all of their behavior.

The primary drawback is that, unlike the default mode of operation, neither Base1 nor Base2 is a true superclass of Derived anymore:

obj = Derived.new
obj.is_a? Base1 # this will return false...
obj.is_a? Base2 # ... and so will this

In most cases, this is not a serious problem since objects of type Derived will otherwise behave as though they inherit from both Base1 and Base2 (i.e. they exhibit "Duck Typing").

38.3.9 C++ Overloaded Functions

C++ overloaded functions, methods, and constructors are mostly supported by SWIG. For example, if you have two functions like this:

void foo(int);
void foo(char *c);

You can use them in Ruby in a straightforward manner:

irb(main):001:0> foo(3) # foo(int)
irb(main):002:0> foo("Hello") # foo(char *c)

Similarly, if you have a class like this,

class Foo {
public:
  Foo();
  Foo(const Foo &);
  ...
};

you can write Ruby code like this:

irb(main):001:0> f = Foo.new # Create a Foo
irb(main):002:0> g = Foo.new(f) # Copy f

Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG can't disambiguate. For example:

void spam(int);
void spam(short);

or

void foo(Bar *b);
void foo(Bar &b);

If declarations such as these appear, you will get a warning message like this:

example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).

To fix this, you either need to ignore or rename one of the methods. For example:

%rename(spam_short) spam(short);
...
void spam(int); 
void spam(short); // Accessed as spam_short

or

%ignore spam(short);
...
void spam(int); 
void spam(short); // Ignored

SWIG resolves overloaded functions and methods using a disambiguation scheme that ranks and sorts declarations according to a set of type-precedence rules. The order in which declarations appear in the input does not matter except in situations where ambiguity arises--in this case, the first declaration takes precedence.

Please refer to the "SWIG and C++" chapter for more information about overloading.

38.3.10 C++ Operators

For the most part, overloaded operators are handled automatically by SWIG and do not require any special treatment on your part. So if your class declares an overloaded addition operator, e.g.

class Complex {
  ...
  Complex operator+(Complex &);
  ...
};

the resulting Ruby class will also support the addition (+) method correctly.

For cases where SWIG's built-in support is not sufficient, C++ operators can be wrapped using the %rename directive (available on SWIG 1.3.10 and later releases). All you need to do is give the operator the name of a valid Ruby identifier. For example:

%rename(add_complex) operator+(Complex &, Complex &);
...
Complex operator+(Complex &, Complex &);

Now, in Ruby, you can do this:

a = Example::Complex.new(2, 3)
b = Example::Complex.new(4, -1)
c = Example.add_complex(a, b)

More details about wrapping C++ operators into Ruby operators is discussed in the section on operator overloading.

38.3.11 C++ namespaces

SWIG is aware of C++ namespaces, but namespace names do not appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

%module example

namespace foo {
  int fact(int n);
  struct Vector {
    double x,y,z;
  };
};

it works in Ruby as follows:

irb(main):001:0> require 'example'
true
irb(main):002:0> Example.fact(3)
6
irb(main):003:0> v = Example::Vector.new
#<Example::Vector:0x4016f4d4>
irb(main):004:0> v.x = 3.4
3.4
irb(main):004:0> v.y
0.0

If your program has more than one namespace, name conflicts (if any) can be resolved using %rename For example:

%rename(Bar_spam) Bar::spam;

namespace Foo {
  int spam();
}

namespace Bar {
  int spam();
}

If you have more than one namespace and your want to keep their symbols separate, consider wrapping them as separate SWIG modules. For example, make the module name the same as the namespace and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

38.3.12 C++ templates

C++ templates don't present a huge problem for SWIG. However, in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the %template directive. For example:

%module example

%{
#include "pair.h"
%}

template<class T1, class T2>
struct pair {
  typedef T1 first_type;
  typedef T2 second_type;
  T1 first;
  T2 second;
  pair();
  pair(const T1&, const T2&);
  ~pair();
};

%template(Pairii) pair<int,int>;

In Ruby:

irb(main):001:0> require 'example'
true
irb(main):002:0> p = Example::Pairii.new(3, 4)
#<Example:Pairii:0x4016f4df>
irb(main):003:0> p.first
3
irb(main):004:0> p.second
4

38.3.13 C++ Standard Template Library (STL)

On a related note, the standard SWIG library contains a number of modules that provide typemaps for standard C++ library classes (such as std::pair, std::string and std::vector). These library modules don't provide wrappers around the templates themselves, but they do make it convenient for users of your extension module to pass Ruby objects (such as arrays and strings) to wrapped C++ code that expects instances of standard C++ templates. For example, suppose the C++ library you're wrapping has a function that expects a vector of floats:

%module example

float sum(const std::vector<float>& values);

Rather than go through the hassle of writing an "in" typemap to convert an array of Ruby numbers into a std::vector<float>, you can just use the std_vector.i module from the standard SWIG library:

%module example

%include std_vector.i
float sum(const std::vector<float>& values);

Ruby's STL wrappings provide additional methods to make them behave more similarly to Ruby's native classes.

Thus, you can do, for example:

v = IntVector.new
v << 2
v << 3
v << 4
v.each { |x| puts x }

=> 2
3
4
v.delete_if { |x| x == 3 }
=> [2,4]

The SWIG Ruby module provides also the ability for all the STL containers to carry around Ruby native objects (Fixnum, Classes, etc) making them act almost like Ruby's own Array, Hash, etc. To do that, you need to define a container that contains a swig::GC_VALUE, like:

%module nativevector

%{
std::vector< swig::GC_VALUE > NativeVector;
%}

%template(NativeVector) std::vector< swig::GC_VALUE >;

This vector can then contain any Ruby object, making them almost identical to Ruby's own Array class.

require 'nativevector'
include NativeVector

v = NativeVector.new
v << 1
v << [1,2]
v << 'hello'

class A; end

v << A.new

puts v
=> [1, [1,2], 'hello', #<A:0x245325>]

Obviously, there is a lot more to template wrapping than shown in these examples. More details can be found in the SWIG and C++ chapter.

38.3.14 C++ STL Functors

Some containers in the STL allow you to modify their default behavior by using so called functors or function objects. Functors are often just a very simple struct with operator() redefined or an actual C/C++ function. This allows you, for example, to always keep the sort order of a STL container to your liking.

The Ruby STL mappings allows you to modify those containers that support functors using Ruby procs or methods, instead. Currently, this includes std::set, set::map, std::multiset and std::multimap.

The functors in swig are called swig::UnaryFunction and swig::BinaryFunction. For C++ predicates (ie. functors that must return bool as a result) swig::UnaryPredicate and swig::BinaryPredicate are provided.

As an example, if given this swig file:

%module intset;

%include <std_set.i>

%typemap(IntSet) std::set< int, swig::BinaryPredicate >;

You can then use the set from Ruby with or without a proc object as a predicate:

require 'intset'
include Intset

# Default sorting behavior defined in C++
a = IntSet.new
a << 1
a << 2
a << 3
a
=> [1,2,3]

# Custom sorting behavior defined by a Ruby proc
b = IntSet.new( proc { |a,b| a > b } )
b << 1
b << 2
b << 3
b
=>  [3,2,1]

38.3.15 C++ STL Iterators

The STL is well known for the use of iterators. There are a number of iterators possible with different properties, but in general there are two main categories: const iterators and non-const iterators. The const iterators can access and not modify the values they point at, while the non-const iterators can both read and modify the values.

The Ruby STL wrappings support both type of iterators by using a proxy class in-between. This proxy class is swig::Iterator or swig::ConstIterator. Derived from them are template classes that need to be initialized with the actual iterator for the container you are wrapping and often times with the beginning and ending points of the iteration range.

The SWIG STL library already provides typemaps to all the standard containers to do this wrapping automatically for you, but if you have your own STL-like iterator, you will need to write your own typemap for them. For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

These can be used either like:

make_const_iterator( iterator, rubyclass );
make_const_iterator( iterator, iterator_begin, iterator_end, rubyclass );

The iterators support a next() and previous() member function to just change the iterator without returning anything. previous() should obviously only be used for bidirectional iterators. You can also advance the iterator multiple steps by using standard math operations like +=.

The value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. For non-const iterators, a value=() function is also provided which allows you to change the value pointed by the iterator. This is equivalent to the C++ construct of dereferencing and assignment, like *i = something.

Thus, given say a vector class of doubles defined as:

%module doublevector

%include std_vector.i

%template(DoubleVector) std::vector<double>;

Its iterator can then be used from Ruby like:

require 'doublevector'
include Doublevector

v = DoubleVector.new
v << 1
v << 2
v << 3

#
# an elaborate and less efficient way of doing v.map! { |x| x+2 }
#
i = v.begin
e = v.end
while i != e
  val = i.value
  val += 2
  i.value = val
  i.next
end
i
>> [3, 4, 5 ]

If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

38.3.16 C++ Smart Pointers

In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

template<class T> class SmartPtr {
  ...
  T *operator->();
  ...
}

Then, if you have a class like this,

class Foo {
public:
  int x;
  int bar();
};

A smart pointer would be used in C++ as follows:

SmartPtr<Foo> p = CreateFoo(); // Created somehow (not shown)
...
p->x = 3; // Foo::x
int y = p->bar(); // Foo::bar

To wrap this in Ruby, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using %template if necessary. For example:

%module example
...
%template(SmartPtrFoo) SmartPtr<Foo>;
...

Now, in Ruby, everything should just "work":

irb(main):001:0> p = Example::CreateFoo() # Create a smart-pointer somehow
#<Example::SmartPtrFoo:0x4016f4df>
irb(main):002:0> p.x = 3 # Foo::x
3
irb(main):003:0> p.bar() # Foo::bar

If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

irb(main):004:0> f = p.__deref__() # Returns underlying Foo *

38.3.17 Cross-Language Polymorphism

SWIG's Ruby module supports cross-language polymorphism (a.k.a. the "directors" feature) similar to that for SWIG's Python module. Rather than duplicate the information presented in the Python chapter, this section just notes the differences that you need to be aware of when using this feature with Ruby.

38.3.17.1 Exception Unrolling

Whenever a C++ director class routes one of its virtual member function calls to a Ruby instance method, there's always the possibility that an exception will be raised in the Ruby code. By default, those exceptions are ignored, which simply means that the exception will be exposed to the Ruby interpreter. If you would like to change this behavior, you can use the %feature("director:except") directive to indicate what action should be taken when a Ruby exception is raised. The following code should suffice in most cases:

%feature("director:except") {
  throw Swig::DirectorMethodException($error);
}

When this feature is activated, the call to the Ruby instance method is "wrapped" using the rb_rescue2() function from Ruby's C API. If any Ruby exception is raised, it will be caught here and a C++ exception is raised in its place.

38.4 Naming

Ruby has several common naming conventions. Constants are generally in upper case, module and class names are in camel case and methods are in lower case with underscores. For example:

  • MATH::PI is a constant name
  • MyClass is a class name
  • my_method is a method name

Prior to version 1.3.28, SWIG did not support these Ruby conventions. The only modifications it made to names was to capitalize the first letter of constants (which includes module and class names).

SWIG 1.3.28 introduces the new -autorename command line parameter. When this parameter is specified, SWIG will automatically change constant, class and method names to conform with the standard Ruby naming conventions. For example:

$ swig -ruby -autorename example.i

To disable renaming use the -noautorename command line option.

Since this change significantly changes the wrapper code generated by SWIG, it is turned off by default in SWIG 1.3.28. However, it is planned to become the default option in future releases.

38.4.1 Defining Aliases

It's a fairly common practice in the Ruby built-ins and standard library to provide aliases for method names. For example, Array#size is an alias for Array#length. If you would like to provide an alias for one of your class' instance methods, one approach is to use SWIG's %extend directive to add a new method of the aliased name that calls the original function. For example:

class MyArray {
public:
  // Construct an empty array
  MyArray();

  // Return the size of this array
  size_t length() const;
};

%extend MyArray {
  // MyArray#size is an alias for MyArray#length
  size_t size() const {
    return $self->length();
  }
}
 

A better solution is to use the %alias directive (unique to SWIG's Ruby module). The previous example could then be rewritten as:

// MyArray#size is an alias for MyArray#length
%alias MyArray::length "size";

class MyArray {
public:
  // Construct an empty array
  MyArray();
 
  // Return the size of this array
  size_t length() const;
};

Multiple aliases can be associated with a method by providing a comma-separated list of aliases to the %alias directive, e.g.

%alias MyArray::length "amount,quantity,size";

From an end-user's standpoint, there's no functional difference between these two approaches; i.e. they should get the same result from calling either MyArray#size or MyArray#length. However, when the %alias directive is used, SWIG doesn't need to generate all of the wrapper code that's usually associated with added methods like our MyArray::size() example.

Note that the %alias directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

38.4.2 Predicate Methods

Ruby methods that return a boolean value and end in a question mark are known as predicate methods. Examples of predicate methods in standard Ruby classes include Array#empty? (which returns true for an array containing no elements) and Object#instance_of? (which returns true if the object is an instance of the specified class). For consistency with Ruby conventions, methods that return boolean values should be marked as predicate methods.

One cumbersome solution to this problem is to rename the method (using SWIG's %rename directive) and provide a custom typemap that converts the function's actual return type to Ruby's true or false. For example:

%rename("is_it_safe?") is_it_safe();

%typemap(out) int is_it_safe "$result = ($1 != 0) ? Qtrue : Qfalse;";

int is_it_safe();

A better solution is to use the %predicate directive (unique to SWIG's Ruby module) to designate a method as a predicate method. For the previous example, this would look like:

%predicate is_it_safe();

int is_it_safe();

This method would be invoked from Ruby code like this:

irb(main):001:0> Example::is_it_safe?
true

The %predicate directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

38.4.3 Bang Methods

Ruby methods that modify an object in-place and end in an exclamation mark are known as bang methods. An example of a bang method is Array#sort! which changes the ordering of items in an array. Contrast this with Array#sort, which returns a copy of the array with the items sorted instead of modifying the original array. For consistency with Ruby conventions, methods that modify objects in place should be marked as bang methods.

Bang methods can be marked using the %bang directive which is unique to the Ruby module and was introduced in SWIG 1.3.28. For example:

%bang sort(int arr[]);

int sort(int arr[]); 

This method would be invoked from Ruby code like this:

irb(main):001:0> Example::sort!(arr)

The %bang directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

38.4.4 Getters and Setters

Often times a C++ library will expose properties through getter and setter methods. For example:

class Foo {
  Foo() {}
  int getValue() { return value_; }
  void setValue(int value) { value_ = value; }

private:
  int value_;
};

By default, SWIG will expose these methods to Ruby as get_value and set_value. However, it more natural for these methods to be exposed in Ruby as value and value=. That allows the methods to be used like this:

irb(main):001:0> foo = Foo.new()
irb(main):002:0> foo.value = 5
irb(main):003:0> puts foo.value

This can be done by using the %rename directive:

%rename("value") Foo::getValue();
%rename("value=") Foo::setValue(int value);

38.5 Input and output parameters

A common problem in some C programs is handling parameters passed as simple pointers. For example:

void add(int x, int y, int *result) {
  *result = x + y;
}

or

int sub(int *x, int *y) {
  return *x-*y;
}

The easiest way to handle these situations is to use the typemaps.i file. For example:

%module Example
%include "typemaps.i"

void add(int, int, int *OUTPUT);
int sub(int *INPUT, int *INPUT);

In Ruby, this allows you to pass simple values. For example:

a = Example.add(3,4)
puts a
7
b = Example.sub(7,4)
puts b
3

Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter creates a return result.

If you don't want to use the names INPUT or OUTPUT, use the %apply directive. For example:

%module Example
%include "typemaps.i"

%apply int *OUTPUT { int *result };
%apply int *INPUT { int *x, int *y};

void add(int x, int y, int *result);
int sub(int *x, int *y);

If a function mutates one of its parameters like this,

void negate(int *x) {
 *x = -(*x);
}

you can use INOUT like this:

%include "typemaps.i"
...
void negate(int *INOUT);

In Ruby, a mutated parameter shows up as a return value. For example:

a = Example.negate(3)
print a
-3

The most common use of these special typemap rules is to handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

/* send message, return number of bytes sent, success code, and error_code */
int send_message(char *text, int *success, int *error_code);

To wrap such a function, simply use the OUTPUT rule above. For example:

%module example
%include "typemaps.i"
...
int send_message(char *, int *OUTPUT, int *OUTPUT);

When used in Ruby, the function will return an array of multiple values.

bytes, success, error_code = send_message("Hello World")
if not success
  print "error #{error_code} : in send_message"
else
  print "Sent", bytes
end

Another way to access multiple return values is to use the %apply rule. In the following example, the parameters rows and columns are related to SWIG as OUTPUT values through the use of %apply

%module Example
%include "typemaps.i"
%apply int *OUTPUT { int *rows, int *columns };
...
void get_dimensions(Matrix *m, int *rows, int*columns);

In Ruby:

r, c = Example.get_dimensions(m)

38.6 Exception handling

38.6.1 Using the %exception directive

The SWIG %exception directive can be used to define a user-definable exception handler that can convert C/C++ errors into Ruby exceptions. The chapter on Customization Features contains more details, but suppose you have a C++ class like the following :

class DoubleArray {
private:
  int n;
  double *ptr;
public:
  // Create a new array of fixed size
  DoubleArray(int size) {
    ptr = new double[size];
    n = size;
  }
 
  // Destroy an array
  ~DoubleArray() {
    delete ptr;
  } 
 
  // Return the length of the array
  int length() {
    return n;
  }
 
  // Get an array item and perform bounds checking.
  double getitem(int i) {
    if ((i >= 0) && (i < n))
      return ptr[i];
    else
      throw RangeError();
  }
 
  // Set an array item and perform bounds checking.
  void setitem(int i, double val) {
    if ((i >= 0) && (i < n))
      ptr[i] = val;
    else {
      throw RangeError();
    }
  }
};

Since several methods in this class can throw an exception for an out-of-bounds access, you might want to catch this in the Ruby extension by writing the following in an interface file:

%exception {
  try {
    $action
  }
  catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error.");
  }
}

class DoubleArray {
  ...
};

The exception handling code is inserted directly into generated wrapper functions. When an exception handler is defined, errors can be caught and used to gracefully raise a Ruby exception instead of forcing the entire program to terminate with an uncaught error.

As shown, the exception handling code will be added to every wrapper function. Because this is somewhat inefficient, you might consider refining the exception handler to only apply to specific methods like this:

%exception getitem {
  try {
    $action
  } catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in getitem.");
  }
}
 
%exception setitem {
  try {
    $action
  } catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in setitem.");
  }
}

In this case, the exception handler is only attached to methods and functions named getitem and setitem.

Since SWIG's exception handling is user-definable, you are not limited to C++ exception handling. See the chapter on Customization Features for more examples.

38.6.2 Handling Ruby Blocks

One of the highlights of Ruby and most of its standard library is the use of blocks, which allow the easy creation of continuations and other niceties. Blocks in ruby are also often used to simplify the passing of many arguments to a class.

In order to make your class constructor support blocks, you can take advantage of the %exception directive, which will get run after the C++ class' constructor was called.

For example, this yields the class over after its construction:

class Window
{
public:
  Window(int x, int y, int w, int h);
  // .... other methods here ....
};

// Add support for yielding self in the Class' constructor.
%exception Window::Window {
  $action
  if (rb_block_given_p()) {
    rb_yield(self);
  }
}

Then, in ruby, it can be used like:

Window.new(0,0,360,480) { |w|
  w.color = Fltk::RED
  w.border = false
}

For other methods, you can usually use a dummy parameter with a special in typemap, like:

//
// original function was:
//
// void func(int x);

%typemap(in,numinputs=0) int RUBY_YIELD_SELF {
  if ( !rb_block_given_p() )
    rb_raise("No block given");
  return rb_yield(self);
}

%extend {
  void func(int x, int RUBY_YIELD_SELF );
}

For more information on typemaps, see Typemaps .

38.6.3 Raising exceptions

There are three ways to raise exceptions from C++ code to Ruby.

The first way is to use SWIG_exception(int code, const char *msg) . The following table shows the mappings from SWIG error codes to Ruby exceptions:

SWIG_MemoryError
rb_eNoMemError
SWIG_IOError
rb_eIOError
SWIG_RuntimeError
rb_eRuntimeError
SWIG_IndexError
rb_eIndexError
SWIG_TypeError
rb_eTypeError
SWIG_DivisionByZero
rb_eZeroDivError
SWIG_OverflowError
rb_eRangeError
SWIG_SyntaxError
rb_eSyntaxError
SWIG_ValueError
rb_eArgError
SWIG_SystemError
rb_eFatal
SWIG_AttributeError
rb_eRuntimeError
SWIG_NullReferenceError
rb_eNullReferenceError*
SWIG_ObjectPreviouslyDeletedError
rb_eObjectPreviouslyDeleted*
SWIG_UnknownError
rb_eRuntimeError
* These error classes are created by SWIG and are not built-in Ruby exception classes

The second way to raise errors is to use SWIG_Raise(obj, type, desc). Obj is a C++ instance of an exception class, type is a string specifying the type of exception (for example, "MyError") and desc is the SWIG description of the exception class. For example:

%raise(SWIG_NewPointerObj(e, SWIGTYPE_p_AssertionFailedException, 0), ":AssertionFailedException", SWIGTYPE_p_AssertionFailedException);

This is useful when you want to pass the current exception object directly to Ruby, particularly when the object is an instance of class marked as an %exceptionclass (see the next section for more information).

Last, you can raise an exception by directly calling Ruby's C api. This is done by invoking the rb_raise() function. The first argument passed to rb_raise() is the exception type. You can raise a custom exception type or one of the built-in Ruby exception types.

38.6.4 Exception classes

Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass directive, which is used to identify C++ classes that are used as exceptions. Classes that are marked with the %exceptionclass directive are exposed in Ruby as child classes of rb_eRuntimeError. This allows C++ exceptions to be directly mapped to Ruby exceptions, providing for a more natural integration between C++ code and Ruby code.

%exceptionclass CustomError;

%inline %{
  class CustomError { };

  class Foo { 
  public:
    void test() { throw CustomError; }
  };
%}

From Ruby you can now call this method like this:

foo = Foo.new
begin
  foo.test()
rescue CustomError => e
  puts "Caught custom error"
end 

For another example look at swig/Examples/ruby/exception_class.

38.7 Typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Ruby C API as well as the material in the "Typemaps " chapter.

Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the primitive C-Ruby interface.

38.7.1 What is a typemap?

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. The general form of this declaration is as follows ( parts enclosed in [...] are optional ):

%typemap( method [, modifiers...] ) typelist code;

method is a simply a name that specifies what kind of typemap is being defined. It is usually a name like "in", "out", or "argout" (or its director variations). The purpose of these methods is described later.

modifiers is an optional comma separated list of name="value" values. These are sometimes to attach extra information to a typemap and is often target-language dependent.

typelist is a list of the C++ type patterns that the typemap will match. The general form of this list is as follows:

typelist : typepattern [, typepattern, typepattern, ... ] ;

typepattern : type [ (parms) ]
  | type name [ (parms) ]
  | ( typelist ) [ (parms) ]

Each type pattern is either a simple type, a simple type and argument name, or a list of types in the case of multi-argument typemaps. In addition, each type pattern can be parameterized with a list of temporary variables (parms). The purpose of these variables will be explained shortly.

code specifies the C code used in the typemap. It can take any one of the following forms:

code : { ... }
  | " ... "
  | %{ ... %}

For example, to convert integers from Ruby to C, you might define a typemap like this:

%module example

%typemap(in) int {
  $1 = (int) NUM2INT($input);
  printf("Received an integer : %d\n",$1);
}

%inline %{
  extern int fact(int n);
%}

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variables prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input variable is the input Ruby object.

When this example is compiled into a Ruby module, the following sample code:

require 'example'

puts Example.fact(6)

prints the result:

Received an integer : 6
720

In this example, the typemap is applied to all occurrences of the int datatype. You can refine this by supplying an optional parameter name. For example:

%module example

%typemap(in) int n {
  $1 = (int) NUM2INT($input);
  printf("n = %d\n",$1);
}

%inline %{
  extern int fact(int n);
%}

In this case, the typemap code is only attached to arguments that exactly match "int n".

The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG type-system. When you define a typemap for int, that typemap applies to int and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

%typemap(in) int n {
  $1 = (int) NUM2INT($input);
  printf("n = %d\n",$1);
}

typedef int Integer;
extern int fact(Integer n); // Above typemap is applied

However, the matching of typedef only occurs in one direction. If you defined a typemap for Integer, it is not applied to arguments of type int.

Typemaps can also be defined for groups of consecutive arguments. For example:

%typemap(in) (char *str, int len) {
  $1 = StringValuePtr($input);
  $2 = (int) RSTRING($input)->len;
};

int count(char c, char *str, int len);

When a multi-argument typemap is defined, the arguments are always handled as a single Ruby object. This allows the function count to be used as follows (notice how the length parameter is omitted):

puts Example.count('o','Hello World')
2

38.7.2 Typemap scope

Once defined, a typemap remains in effect for all of the declarations that follow. A typemap may be redefined for different sections of an input file. For example:

// typemap1
%typemap(in) int {
  ...
}

int fact(int); // typemap1
int gcd(int x, int y); // typemap1

// typemap2
%typemap(in) int {
  ...
}

int isprime(int); // typemap2

One exception to the typemap scoping rules pertains to the %extend declaration. %extend is used to attach new declarations to a class or structure definition. Because of this, all of the declarations in an %extend block are subject to the typemap rules that are in effect at the point where the class itself is defined. For example:

class Foo {
  ...
};

%typemap(in) int {
  ...
}

%extend Foo {
  int blah(int x); // typemap has no effect. Declaration is attached to Foo which 
  // appears before the %typemap declaration.
};

38.7.3 Copying a typemap

A typemap is copied by using assignment. For example:

%typemap(in) Integer = int;

or this:

%typemap(in) Integer, Number, int32_t = int;

Types are often managed by a collection of different typemaps. For example:

%typemap(in) int { ... }
%typemap(out) int { ... }
%typemap(varin) int { ... }
%typemap(varout) int { ... }

To copy all of these typemaps to a new type, use %apply. For example:

%apply int { Integer }; // Copy all int typemaps to Integer
%apply int { Integer, Number }; // Copy all int typemaps to both Integer and Number

The patterns for %apply follow the same rules as for %typemap. For example:

%apply int *output { Integer *output }; // Typemap with name
%apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments

38.7.4 Deleting a typemap

A typemap can be deleted by simply defining no code. For example:

%typemap(in) int; // Clears typemap for int
%typemap(in) int, long, short; // Clears typemap for int, long, short
%typemap(in) int *output; 

The %clear directive clears all typemaps for a given type. For example:

%clear int; // Removes all types for int
%clear int *output, long *output;

Note: Since SWIG's default behavior is defined by typemaps, clearing a fundamental type like int will make that type unusable unless you also define a new set of typemaps immediately after the clear operation.

38.7.5 Placement of typemaps

Typemap declarations can be declared in the global scope, within a C++ namespace, and within a C++ class. For example:

%typemap(in) int {
  ...
}

namespace std {
  class string;
  %typemap(in) string {
    ...
  }
}

class Bar {
public:
  typedef const int & const_reference;
  %typemap(out) const_reference {
    ...
  }
};

When a typemap appears inside a namespace or class, it stays in effect until the end of the SWIG input (just like before). However, the typemap takes the local scope into account. Therefore, this code

namespace std {
  class string;
  %typemap(in) string {
    ...
  }
}

is really defining a typemap for the type std::string. You could have code like this:

namespace std {
  class string;
  %typemap(in) string { /* std::string */
  ...
  }
}

namespace Foo {
  class string;
  %typemap(in) string { /* Foo::string */
  ...
  }
}

In this case, there are two completely distinct typemaps that apply to two completely different types (std::string and Foo::string).

It should be noted that for scoping to work, SWIG has to know that string is a typename defined within a particular namespace. In this example, this is done using the class declaration class string .

38.7.6 Ruby typemaps

The following list details all of the typemap methods that can be used by the Ruby module:

38.7.6.1 "in" typemap

Converts Ruby objects to input function arguments. For example:

%typemap(in) int {
  $1 = NUM2INT($input);
}

The following special variables are available:

$input Input object holding value to be converted.
$symname Name of function/method being wrapped
$1...n Argument being sent to the function
$1_name Name of the argument (if provided)
$1_type The actual C datatype matched by the typemap.
$1_ltype The assignable version of the C datatype matched by the typemap.

This is probably the most commonly redefined typemap because it can be used to implement customized conversions.

In addition, the "in" typemap allows the number of converted arguments to be specified. For example:

// Ignored argument.
%typemap(in, numinputs=0) int *out (int temp) {
  $1 = &temp;
}

At this time, only zero or one arguments may be converted.

38.7.6.2 "typecheck" typemap

The "typecheck" typemap is used to support overloaded functions and methods. It merely checks an argument to see whether or not it matches a specific type. For example:

%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) int {
  $1 = FIXNUM_P($input) ? 1 : 0;
}

For typechecking, the $1 variable is always a simple integer that is set to 1 or 0 depending on whether or not the input argument is the correct type.

If you define new "in" typemaps and your program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading."

38.7.6.3 "out" typemap

Converts return value of a C function to a Ruby object.

%typemap(out) int {
  $result = INT2NUM( $1 );
}

The following special variables are available.

$result Result object returned to target language.
$symname Name of function/method being wrapped
$1...n Argument being wrapped
$1_name Name of the argument (if provided)
$1_type The actual C datatype matched by the typemap.
$1_ltype The assignable version of the C datatype matched by the typemap.

38.7.6.4 "arginit" typemap

The "arginit" typemap is used to set the initial value of a function argument--before any conversion has occurred. This is not normally necessary, but might be useful in highly specialized applications. For example:

// Set argument to NULL before any conversion occurs
%typemap(arginit) int *data {
  $1 = NULL;
}

38.7.6.5 "default" typemap

The "default" typemap is used to turn an argument into a default argument. For example:

%typemap(default) int flags {
  $1 = DEFAULT_FLAGS;
}
...
int foo(int x, int y, int flags);

The primary use of this typemap is to either change the wrapping of default arguments or specify a default argument in a language where they aren't supported (like C). Target languages that do not support optional arguments, such as Java and C#, effectively ignore the value specified by this typemap as all arguments must be given.

Once a default typemap has been applied to an argument, all arguments that follow must have default values. See the Default/optional arguments section for further information on default argument wrapping.

38.7.6.6 "check" typemap

The "check" typemap is used to supply value checking code during argument conversion. The typemap is applied after arguments have been converted. For example:

%typemap(check) int positive {
  if ($1 <= 0) {
    SWIG_exception(SWIG_ValueError,"Expected positive value.");
  }
}

38.7.6.7 "argout" typemap

The "argout" typemap is used to return values from arguments. This is most commonly used to write wrappers for C/C++ functions that need to return multiple values. The "argout" typemap is almost always combined with an "in" typemap---possibly to ignore the input value. For example:

/* Set the input argument to point to a temporary variable */
%typemap(in, numinputs=0) int *out (int temp) {
  $1 = &temp;
}

%typemap(argout, fragment="output_helper") int *out {
  // Append output value $1 to $result (assuming a single integer in this case)
  $result = output_helper( $result, INT2NUM(*$1) );
}

The following special variables are available.

$result Result object returned to target language.
$input The original input object passed.
$symname Name of function/method being wrapped.

The code supplied to the "argout" typemap is always placed after the "out" typemap. If multiple return values are used, the extra return values are often appended to return value of the function.

Output helper is a fragment that usually defines a macro to some function like SWIG_Ruby_AppendOutput.

See the typemaps.i library for examples.

38.7.6.8 "freearg" typemap

The "freearg" typemap is used to cleanup argument data. It is only used when an argument might have allocated resources that need to be cleaned up when the wrapper function exits. The "freearg" typemap usually cleans up argument resources allocated by the "in" typemap. For example:

// Get a list of integers
%typemap(in) int *items {
  int nitems = Length($input); 
  $1 = (int *) malloc(sizeof(int)*nitems);
}
// Free the list 
%typemap(freearg) int *items {
  free($1);
}

The "freearg" typemap inserted at the end of the wrapper function, just before control is returned back to the target language. This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.

38.7.6.9 "newfree" typemap

The "newfree" typemap is used in conjunction with the %newobject directive and is used to deallocate memory used by the return result of a function. For example:

%typemap(newfree) string * {
  delete $1;
}
%typemap(out) string * {
  $result = PyString_FromString($1->c_str());
}
...

%newobject foo;
...
string *foo();

See Object ownership and %newobject for further details.

38.7.6.10 "memberin" typemap

The "memberin" typemap is used to copy data from an already converted input value into a structure member. It is typically used to handle array members and other special cases. For example:

%typemap(memberin) int [4] {
  memmove($1, $input, 4*sizeof(int));
}

It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

38.7.6.11 "varin" typemap

The "varin" typemap is used to convert objects in the target language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

38.7.6.12 "varout" typemap

The "varout" typemap is used to convert a C/C++ object to an object in the target language when reading a C/C++ global variable. This is implementation specific.

38.7.6.13 "throws" typemap

The "throws" typemap is only used when SWIG parses a C++ method with an exception specification or has the %catches feature attached to the method. It provides a default mechanism for handling C++ methods that have declared the exceptions they will throw. The purpose of this typemap is to convert a C++ exception into an error or exception in the target language. It is slightly different to the other typemaps as it is based around the exception type rather than the type of a parameter or variable. For example:

%typemap(throws) const char * %{
  rb_raise(rb_eRuntimeError, $1);
  SWIG_fail;
%}
void bar() throw (const char *);

As can be seen from the generated code below, SWIG generates an exception handler with the catch block comprising the "throws" typemap content.

...
try {
  bar();
}
catch(char const *_e) {
  rb_raise(rb_eRuntimeError, _e);
  SWIG_fail;
}
...

Note that if your methods do not have an exception specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.

38.7.6.14 directorin typemap

Converts C++ objects in director member functions to ruby objects. It is roughly the opposite of the "in" typemap, making its typemap rule often similar to the "out" typemap.

%typemap(directorin) int {
  $result = INT2NUM($1);
}

The following special variables are available.

$result Result object returned to target language.
$symname Name of function/method being wrapped
$1...n Argument being wrapped
$1_name Name of the argument (if provided)
$1_type The actual C datatype matched by the typemap.
$1_ltype The assignable version of the C datatype matched by the typemap.
this C++ this, referring to the class itself.

38.7.6.15 directorout typemap

Converts Ruby objects in director member functions to C++ objects. It is roughly the opposite of the "out" typemap, making its rule often similar to the "in" typemap.

%typemap(directorout) int {
  $result = NUM2INT($1);
}

The following special variables are available:

$inputRuby object being sent to the function
$symnameName of function/method being wrapped
$1...nArgument being sent to the function
$1_name Name of the argument (if provided)
$1_type The actual C datatype matched by the typemap.
$1_ltype The assignable version of the C datatype matched by the typemap.
this C++ this, referring to the class itself.

Currently, the directorout nor the out typemap support the option numoutputs, but the Ruby module provides that functionality through a %feature directive. Thus, a function can be made to return "nothing" if you do:

%feature("numoutputs","0") MyClass::function;

This feature can be useful if a function returns a status code, which you want to discard but still use the typemap to raise an exception.

38.7.6.16 directorargout typemap

Output argument processing in director member functions.

%typemap(directorargout,
fragment="output_helper") int {
  $result = output_helper( $result, NUM2INT($1) );
}

The following special variables are available:

$resultResult that the director function returns
$inputRuby object being sent to the function
$symnamename of the function/method being wrapped
$1...nArgument being sent to the function
$1_nameName of the argument (if provided)
$1_typeThe actual C datatype matched by the typemap
$1_ltypeThe assignable version of the C datatype matched by the typemap
thisC++ this, referring to the instance of the class itself

38.7.6.17 ret typemap

Cleanup of function return values

38.7.6.18 globalin typemap

Setting of C global variables

38.7.7 Typemap variables

Within a typemap, a number of special variables prefaced with a $ may appear. A full list of variables can be found in the " Typemaps" chapter. This is a list of the most common variables:

$1

A C local variable corresponding to the actual type specified in the %typemap directive. For input values, this is a C local variable that is supposed to hold an argument value. For output values, this is the raw result that is supposed to be returned to Ruby.

$input

A VALUE holding a raw Ruby object with an argument or variable value.

$result

A VALUE that holds the result to be returned to Ruby.

$1_name

The parameter name that was matched.

$1_type

The actual C datatype matched by the typemap.

$1_ltype

An assignable version of the datatype matched by the typemap (a type that can appear on the left-hand-side of a C assignment operation). This type is stripped of qualifiers and may be an altered version of $1_type. All arguments and local variables in wrapper functions are declared using this type so that their values can be properly assigned.

$symname

The Ruby name of the wrapper function being created.

38.7.8 Useful Functions

When you write a typemap, you usually have to work directly with Ruby objects. The following functions may prove to be useful. (These functions plus many more can be found in Programming Ruby book, by David Thomas and Andrew Hunt.)

In addition, we list equivalent functions that SWIG defines, which provide a language neutral conversion (these functions are defined for each swig language supported). If you are trying to create a swig file that will work under multiple languages, it is recommended you stick to the swig functions instead of the native Ruby functions. That should help you avoid having to rewrite a lot of typemaps across multiple languages.

38.7.8.1 C Datatypes to Ruby Objects

RUBYSWIG
INT2NUM(long or int)SWIG_From_int(int x) int to Fixnum or Bignum
INT2FIX(long or int) int to Fixnum (faster than INT2NUM)
CHR2FIX(char)SWIG_From_char(char x) char to Fixnum
rb_str_new2(char*)SWIG_FromCharPtrAndSize(char*, size_t) char* to String
rb_float_new(double)SWIG_From_double(double),
SWIG_From_float(float)
float/double to Float

38.7.8.2 Ruby Objects to C Datatypes

Here, while the Ruby versions return the value directly, the SWIG versions do not, but return a status value to indicate success ( SWIG_OK). While more akward to use, this allows you to write typemaps that report more helpful error messages, like:

%typemap(in) size_t (int ok)
  ok = SWIG_AsVal_size_t($input, &$1);
  if (!SWIG_IsOK(ok)) {
    SWIG_exception_fail(SWIG_ArgError(ok), Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input));
  }
}
int NUM2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
int FIX2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
unsigned int NUM2UINT(Numeric) SWIG_AsVal_unsigned_SS_int(VALUE, int*)
unsigned int FIX2UINT(Numeric) SWIG_AsVal_unsigned_SS_int(VALUE, int*)
long NUM2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
long FIX2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
unsigned long FIX2ULONG(Numeric) SWIG_AsVal_unsigned_SS_long(VALUE, unsigned long*)
char NUM2CHR(Numeric or String)SWIG_AsVal_char(VALUE, int*)
char * StringValuePtr(String) SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc)
char * rb_str2cstr(String, int*length)
double NUM2DBL(Numeric)(double) SWIG_AsVal_int(VALUE) or similar

38.7.8.3 Macros for VALUE

RSTRING_LEN(str)

length of the Ruby string

RSTRING_PTR(str)

pointer to string storage

RARRAY_LEN(arr)

length of the Ruby array

RARRAY(arr)->capa

capacity of the Ruby array

RARRAY_PTR(arr)

pointer to array storage

38.7.8.4 Exceptions

void rb_raise(VALUE exception, const char *fmt, ...)

Raises an exception. The given format string fmt and remaining arguments are interpreted as with printf().

void rb_fatal(const char *fmt, ...)

Raises a fatal exception, terminating the process. No rescue blocks are called, but ensure blocks will be called. The given format string fmt and remaining arguments are interpreted as with printf().

void rb_bug(const char *fmt, ...)

Terminates the process immediately -- no handlers of any sort will be called. The given format string fmt and remaining arguments are interpreted as with printf(). You should call this function only if a fatal bug has been exposed.

void rb_sys_fail(const char *msg)

Raises a platform-specific exception corresponding to the last known system error, with the given string msg.

VALUE rb_rescue(VALUE (*body)(VALUE), VALUE args, VALUE(*rescue)(VALUE, VALUE), VALUE rargs)

Executes body with the given args. If a StandardError exception is raised, then execute rescue with the given rargs.

VALUE rb_ensure(VALUE(*body)(VALUE), VALUE args, VALUE(*ensure)(VALUE), VALUE eargs)

Executes body with the given args. Whether or not an exception is raised, execute ensure with the given rargs after body has completed.

VALUE rb_protect(VALUE (*body)(VALUE), VALUE args, int *result)

Executes body with the given args and returns nonzero in result if any exception was raised.

void rb_notimplement()

Raises a NotImpError exception to indicate that the enclosed function is not implemented yet, or not available on this platform.

void rb_exit(int status)

Exits Ruby with the given status. Raises a SystemExit exception and calls registered exit functions and finalizers.

void rb_warn(const char *fmt, ...)

Unconditionally issues a warning message to standard error. The given format string fmt and remaining arguments are interpreted as with printf().

void rb_warning(const char *fmt, ...)

Conditionally issues a warning message to standard error if Ruby was invoked with the -w flag. The given format string fmt and remaining arguments are interpreted as with printf().

38.7.8.5 Iterators

void rb_iter_break()

Breaks out of the enclosing iterator block.

VALUE rb_each(VALUE obj)

Invokes the each method of the given obj.

VALUE rb_yield(VALUE arg)

Transfers execution to the iterator block in the current context, passing arg as an argument. Multiple values may be passed in an array.

int rb_block_given_p()

Returns true if yield would execute a block in the current context; that is, if a code block was passed to the current method and is available to be called.

VALUE rb_iterate(VALUE (*method)(VALUE), VALUE args, VALUE (*block)(VALUE, VALUE), VALUE arg2)

Invokes method with argument args and block block. A yield from that method will invoke block with the argument given to yield, and a second argument arg2.

VALUE rb_catch(const char *tag, VALUE (*proc)(VALUE, VALUE), VALUE value)

Equivalent to Ruby's catch.

void rb_throw(const char *tag, VALUE value)

Equivalent to Ruby's throw.

38.7.9 Typemap Examples

This section includes a few examples of typemaps. For more examples, you might look at the examples in the Example/ruby directory.

38.7.10 Converting a Ruby array to a char **

A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Ruby Array instance to be used as a char ** object.

%module argv

// This tells SWIG to treat char ** as a special case
%typemap(in) char ** {
  /* Get the length of the array */
  int size = RARRAY($input)->len; 
  int i;
  $1 = (char **) malloc((size+1)*sizeof(char *));
  /* Get the first element in memory */
  VALUE *ptr = RARRAY($input)->ptr; 
  for (i=0; i < size; i++, ptr++) {
    /* Convert Ruby Object String to char* */
    $1[i]= StringValuePtr(*ptr); 
  }
  $1[i]=NULL; /* End of list */
}

// This cleans up the char ** array created before 
// the function call

%typemap(freearg) char ** {
  free((char *) $1);
}

// Now a test function
%inline %{
int print_args(char **argv) {
  int i = 0;
  while (argv[i]) {
    printf("argv[%d] = %s\n", i,argv[i]);
    i++;
  }
  return i;
}
%}

When this module is compiled, the wrapped C function now operates as follows :

require 'Argv'
Argv.print_args(["Dave","Mike","Mary","Jane","John"])
argv[0] = Dave
argv[1] = Mike
argv[2] = Mary
argv[3] = Jane
argv[4] = John

In the example, two different typemaps are used. The "in" typemap is used to receive an input argument and convert it to a C array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

38.7.11 Collecting arguments in a hash

Ruby's solution to the "keyword arguments" capability of some other languages is to allow the programmer to pass in one or more key-value pairs as arguments to a function. All of those key-value pairs are collected in a single Hash argument that's presented to the function. If it makes sense, you might want to provide similar functionality for your Ruby interface. For example, suppose you'd like to wrap this C function that collects information about people's vital statistics:

void setVitalStats(const char *person, int nattributes, const char **names, int *values);

and you'd like to be able to call it from Ruby by passing in an arbitrary number of key-value pairs as inputs, e.g.

setVitalStats("Fred", 
  'weight' => 270, 
  'age' => 42 
)

To make this work, you need to write a typemap that expects a Ruby Hash as its input and somehow extracts the last three arguments ( nattributes, names and values) needed by your C function. Let's start with the basics:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
}
 

This %typemap directive tells SWIG that we want to match any function declaration that has the specified types and names of arguments somewhere in the argument list. The fact that we specified the argument names (nattributes, names and values) in our typemap is significant; this ensures that SWIG won't try to apply this typemap to other functions it sees that happen to have a similar declaration with different argument names. The arguments that appear in the second set of parentheses (keys_arr, i , key and val) define local variables that our typemap will need.

Since we expect the input argument to be a Hash, let's next add a check for that:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
}

Check_Type() is just a macro (defined in the Ruby header files) that confirms that the input argument is of the correct type; if it isn't, an exception will be raised.

The next task is to determine how many key-value pairs are present in the hash; we'll assign this number to the first typemap argument ( $1). This is a little tricky since the Ruby/C API doesn't provide a public function for querying the size of a hash, but we can get around that by calling the hash's size method directly and converting its result to a C int value:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
}

So now we know the number of attributes. Next we need to initialize the second and third typemap arguments (i.e. the two C arrays) to NULL and set the stage for extracting the keys and values from the hash:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
    }
}

There are a number of ways we could extract the keys and values from the input hash, but the simplest approach is to first call the hash's keys method (which returns a Ruby array of the keys) and then start looping over the elements in that array:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
      for (i = 0; i < $1; i++) {
      }
    }
}

Recall that keys_arr and i are local variables for this typemap. For each element in the keys_arr array, we want to get the key itself, as well as the value corresponding to that key in the hash:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
      for (i = 0; i < $1; i++) {
        key = rb_ary_entry(keys_arr, i);
        val = rb_hash_aref($input, key);
      }
    }
}

To be safe, we should again use the Check_Type() macro to confirm that the key is a String and the value is a Fixnum :

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
      for (i = 0; i < $1; i++) {
        key = rb_ary_entry(keys_arr, i);
        val = rb_hash_aref($input, key);
        Check_Type(key, T_STRING);
        Check_Type(val, T_FIXNUM);
      }
    }
}

Finally, we can convert these Ruby objects into their C equivalents and store them in our local C arrays:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
  Check_Type($input, T_HASH);
  $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
  $2 = NULL;
  $3 = NULL;
  if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
      key = rb_ary_entry(keys_arr, i);
      val = rb_hash_aref($input, key);
      Check_Type(key, T_STRING);
      Check_Type(val, T_FIXNUM);
      $2[i] = StringValuePtr(key);
      $3[i] = NUM2INT(val);
    }
  }
}

We're not done yet. Since we used malloc() to dynamically allocate the memory used for the names and values arguments, we need to provide a corresponding "freearg" typemap to free that memory so that there is no memory leak. Fortunately, this typemap is a lot easier to write:

%typemap(freearg) (int nattributes, const char **names, const int *values) {
  free((void *) $2);
  free((void *) $3);
}

All of the code for this example, as well as a sample Ruby program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution.

38.7.12 Pointer handling

Occasionally, it might be necessary to convert pointer values that have been stored using the SWIG typed-pointer representation. Since there are several ways in which pointers can be represented, the following two functions are used to safely perform this conversion:

int SWIG_ConvertPtr(VALUE obj, void **ptr, swig_type_info *ty, int flags)

Converts a Ruby object obj to a C pointer whose address is ptr (i.e. ptr is a pointer to a pointer). The third argument, ty, is a pointer to a SWIG type descriptor structure. If ty is not NULL, that type information is used to validate type compatibility and other aspects of the type conversion. If flags is non-zero, any type errors encountered during this validation result in a Ruby TypeError exception being raised; if flags is zero, such type errors will cause SWIG_ConvertPtr() to return -1 but not raise an exception. If ty is NULL, no type-checking is performed.

VALUE SWIG_NewPointerObj(void *ptr, swig_type_info *ty, int own)

Creates a new Ruby pointer object. Here, ptr is the pointer to convert, ty is the SWIG type descriptor structure that describes the type, and own is a flag that indicates whether or not Ruby should take ownership of the pointer (i.e. whether Ruby should free this data when the corresponding Ruby instance is garbage-collected).

Both of these functions require the use of a special SWIG type-descriptor structure. This structure contains information about the mangled name of the datatype, type-equivalence information, as well as information about converting pointer values under C++ inheritance. For a type of Foo *, the type descriptor structure is usually accessed as follows:

Foo *foo;
SWIG_ConvertPtr($input, (void **) &foo, SWIGTYPE_p_Foo, 1);

VALUE obj;
obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);

In a typemap, the type descriptor should always be accessed using the special typemap variable $1_descriptor. For example:

%typemap(in) Foo * {
  SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
}

38.7.12.1 Ruby Datatype Wrapping

VALUE Data_Wrap_Struct(VALUE class, void (*mark)(void *), void (*free)(void *), void *ptr)

Given a pointer ptr to some C data, and the two garbage collection routines for this data (mark and free ), return a VALUE for the Ruby object.

VALUE Data_Make_Struct(VALUE class, c-type, void (*mark)(void *), void (*free)(void *), c-type *ptr)

Allocates a new instance of a C data type c-type , assigns it to the pointer ptr, then wraps that pointer with Data_Wrap_Struct() as above.

Data_Get_Struct(VALUE obj, c-type, c-type *ptr)

Retrieves the original C pointer of type c-type from the data object obj and assigns that pointer to ptr.

38.7.13 Example: STL Vector to Ruby Array

Another use for macros and type maps is to create a Ruby array from a STL vector of pointers. In essence, copy of all the pointers in the vector into a Ruby array. The use of the macro is to make the typemap so generic that any vector with pointers can use the type map. The following is an example of how to construct this type of macro/typemap and should give insight into constructing similar typemaps for other STL structures:

%define PTR_VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
%typemap(out) vectorclassname &, const vectorclassname & {
  VALUE arr = rb_ary_new2($1->size());
  vectorclassname::iterator i = $1->begin(), iend = $1->end();
  for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
  $result = arr;
}
%typemap(out) vectorclassname, const vectorclassname {
  VALUE arr = rb_ary_new2($1.size());
  vectorclassname::iterator i = $1.begin(), iend = $1.end();
  for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
  $result = arr;
}
%enddef

Note, that the "c ## classname.klass" is used in the preprocessor step to determine the actual object from the class name.

To use the macro with a class Foo, the following is used:

PTR_VECTOR_TO_RUBY_ARRAY(vector<foo *="">, Foo)

It is also possible to create a STL vector of Ruby objects:

%define RUBY_ARRAY_TO_PTR_VECTOR(vectorclassname, classname)
%typemap(in) vectorclassname &, const vectorclassname & {
  Check_Type($input, T_ARRAY);
  vectorclassname *vec = new vectorclassname;
  int len = RARRAY($input)->len;
  for (int i=0; i!=len; i++) {
    VALUE inst = rb_ary_entry($input, i);
    //The following _should_ work but doesn't on HPUX
    // Check_Type(inst, T_DATA);
    classname *element = NULL;
    Data_Get_Struct(inst, classname, element);
    vec->push_back(element);
  }
  $1 = vec;
}

%typemap(freearg) vectorclassname &, const vectorclassname & {
  delete $1;
}
%enddef

It is also possible to create a Ruby array from a vector of static data types:

%define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
%typemap(out) vectorclassname &, const vectorclassname & {
  VALUE arr = rb_ary_new2($1->size()); 
  vectorclassname::iterator i = $1->begin(), iend = $1->end();
  for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
  $result = arr;
}
%typemap(out) vectorclassname, const vectorclassname {
  VALUE arr = rb_ary_new2($1.size()); 
  vectorclassname::iterator i = $1.begin(), iend = $1.end();
  for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
  $result = arr;
}
%enddef
Note that this is mostly an example of typemaps. If you want to use the STL with ruby, you are advised to use the standard swig STL library, which does much more than this. Refer to the section called the C++ Standard Template Library.

38.8 Docstring Features

Using ri and rdoc web pages in Ruby libraries is a common practice. Given the way that SWIG generates the extensions by default, your users will normally not get any documentation for it, even if they run 'rdoc' on the resulting .c or .cxx file.

The features described in this section make it easy for you to add rdoc strings to your modules, functions and methods that can then be read by Ruby's rdoc tool to generate html web pages, ri documentation, Windows chm file and an .xml description.

rdoc can then be run from a console or shell window on a swig generated file.

For example, to generate html web pages from a C++ file, you'd do:

$ rdoc -E cxx=c -f html file_wrap.cxx

To generate ri documentation from a c wrap file, you could do:

$ rdoc -r file_wrap.c

38.8.1 Module docstring

Ruby allows a docstring at the beginning of the file before any other statements, and it is typically used to give a general description of the entire module. SWIG supports this by setting an option of the %module directive. For example:

%module(docstring="This is the example module's docstring") example

When you have more than just a line or so then you can retain the easy readability of the %module directive by using a macro. For example:

%define DOCSTRING
"The `XmlResource` class allows program resources defining menus, 
layout of controls on a panel, etc. to be loaded from an XML file."
%enddef

%module(docstring=DOCSTRING) xrc

38.8.2 %feature("autodoc")

Since SWIG does know everything about the function it wraps, it is possible to generate an rdoc containing the parameter types, names and default values. Since Ruby ships with one of the best documentation systems of any language, it makes sense to take advantage of it.

SWIG's Ruby module provides support for the "autodoc" feature, which when attached to a node in the parse tree will cause an rdoc comment to be generated in the wrapper file that includes the name of the function, parameter names, default values if any, and return type if any. There are also several options for autodoc controlled by the value given to the feature, described below.

38.8.2.1 %feature("autodoc", "0")

When the "0" option is given then the types of the parameters will not be included in the autodoc string. For example, given this function prototype:

%feature("autodoc", "0");
bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);

Then Ruby code like this will be generated:

function_name(x, y, foo=nil, bar=nil) -> bool
  ...

38.8.2.2 %feature("autodoc", "1")

When the "1" option is used then the parameter types will be used in the rdoc string. In addition, an attempt is made to simplify the type name such that it makes more sense to the Ruby user. Pointer, reference and const info is removed, %rename's are evaluated, etc. (This is not always successful, but works most of the time. See the next section for what to do when it doesn't.) Given the example above, then turning on the parameter types with the "1" option will result in rdoc code like this:

function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
  ...

38.8.2.3 %feature("autodoc", "2")

When the "2" option is used then the parameter types will not be used in the rdoc string. However, they will be listed in full after the function. Given the example above, then turning on the parameter types with the "2" option will result in Ruby code like this:

38.8.2.4 %feature("autodoc", "3")

When the "3" option is used then the function will be documented using a combination of "1" and "2" above. Given the example above, then turning on the parameter types with the "2" option will result in Ruby code like this:

function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool

Parameters:
	x - int
	y - int
	foo - Foo
	bar - Bar

38.8.2.5 %feature("autodoc", "docstring")

Finally, there are times when the automatically generated autodoc string will make no sense for a Ruby programmer, particularly when a typemap is involved. So if you give an explicit value for the autodoc feature then that string will be used in place of the automatically generated string. For example:

%feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
void GetPosition(int* OUTPUT, int* OUTPUT);

38.8.3 %feature("docstring")

In addition to the autodoc strings described above, you can also attach any arbitrary descriptive text to a node in the parse tree with the "docstring" feature. When the proxy module is generated then any docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together.

38.9 Advanced Topics

38.9.1 Operator overloading

SWIG allows operator overloading with, by using the %extend or %rename commands in SWIG and the following operator names (derived from Python):

General
__repr__ inspect
__str__ to_s
__cmp__ <=>
__hash__ hash
__nonzero__ nonzero?
Callable
__call__ call
Collection
__len__ length
__getitem__ []
__setitem__ []=
Numeric
__add__ +
__sub__ -
__mul__ *
__div__ /
__mod__ %
__divmod__ divmod
__pow__ **
__lshift__ <<
__rshift__ >>
__and__ &
__xor__ ^
__or__ |
__neg__ -@
__pos__ +@
__abs__ abs
__invert__ ~
__int__ to_i
__float__ to_f
__coerce__ coerce
Additions in 1.3.13
__lt__ <
__le__ <=
__eq__ ==
__gt__ >
__ge__ >=

Note that although SWIG supports the __eq__ magic method name for defining an equivalence operator, there is no separate method for handling inequality since Ruby parses the expression a != b as !(a == b).

38.9.2 Creating Multi-Module Packages

The chapter on Working with Modules discusses the basics of creating multi-module extensions with SWIG, and in particular the considerations for sharing runtime type information among the different modules.

As an example, consider one module's interface file (shape.i ) that defines our base class:

%module shape

%{
#include "Shape.h"
%}

class Shape {
protected:
  double xpos;
  double ypos;
protected:
  Shape(double x, double y);
public:
  double getX() const;
  double getY() const;
};

We also have a separate interface file (circle.i) that defines a derived class:

%module circle

%{
#include "Shape.h"
#include "Circle.h"
%}

// Import the base class definition from Shape module
%import shape.i

class Circle : public Shape {
protected:
  double radius;
public:
  Circle(double x, double y, double r);
  double getRadius() const;
};

We'll start by building the Shape extension module:

$ swig -c++ -ruby shape.i

SWIG generates a wrapper file named shape_wrap.cxx. To compile this into a dynamically loadable extension for Ruby, prepare an extconf.rb script using this template:

require 'mkmf'

# Since the SWIG runtime support library for Ruby
# depends on the Ruby library, make sure it's in the list
# of libraries.
$libs = append_library($libs, Config::CONFIG['RUBY_INSTALL_NAME'])

# Create the makefile
create_makefile('shape')

Run this script to create a Makefile and then type make to build the shared library:

$ ruby extconf.rb
creating Makefile
$ make
g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
-I. -c shape_wrap.cxx
gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
-lruby -lruby -lc

Note that depending on your installation, the outputs may be slightly different; these outputs are those for a Linux-based development environment. The end result should be a shared library (here, shape.so) containing the extension module code. Now repeat this process in a separate directory for the Circle module:

  1. Run SWIG to generate the wrapper code (circle_wrap.cxx);
  2. Write an extconf.rb script that your end-users can use to create a platform-specific Makefile for the extension;
  3. Build the shared library for this extension by typing make .

Once you've built both of these extension modules, you can test them interactively in IRB to confirm that the Shape and Circle modules are properly loaded and initialized:

$ irb
irb(main):001:0> require 'shape'
true
irb(main):002:0> require 'circle'
true
irb(main):003:0> c = Circle::Circle.new(5, 5, 20)
#<Circle::Circle:0xa097208>
irb(main):004:0> c.kind_of? Shape::Shape
true
irb(main):005:0> c.getX()
5.0

38.9.3 Specifying Mixin Modules

The Ruby language doesn't support multiple inheritance, but it does allow you to mix one or more modules into a class using Ruby's include method. For example, if you have a Ruby class that defines an each instance method, e.g.

class Set
  def initialize
  @members = []
  end
 
  def each
  @members.each { |m| yield m }
  end
end

then you can mix-in Ruby's Enumerable module to easily add a lot of functionality to your class:

class Set
  include Enumerable
  def initialize
    @members = []
  end
  def each
    @members.each { |m| yield m }
  end
end

To get the same benefit for your SWIG-wrapped classes, you can use the %mixin directive to specify the names of one or more modules that should be mixed-in to a class. For the above example, the SWIG interface specification might look like this:

%mixin Set "Enumerable";

class Set {
public:
  // Constructor
  Set();
 
  // Iterates through set members
  void each();
};

Multiple modules can be mixed into a class by providing a comma-separated list of module names to the %mixin directive, e.g.

%mixin Set "Fee,Fi,Fo,Fum";

Note that the %mixin directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

38.10 Memory Management

One of the most common issues in generating SWIG bindings for Ruby is proper memory management. The key to proper memory management is clearly defining whether a wrapper Ruby object owns the underlying C struct or C++ class. There are two possibilities:

  • The Ruby object is responsible for freeing the C struct or C++ object
  • The Ruby object should not free the C struct or C++ object because it will be freed by the underlying C or C++ code

To complicate matters, object ownership may transfer from Ruby to C++ (or vice versa) depending on what function or methods are invoked. Clearly, developing a SWIG wrapper requires a thorough understanding of how the underlying library manages memory.

38.10.1 Mark and Sweep Garbage Collector

Ruby uses a mark and sweep garbage collector. When the garbage collector runs, it finds all the "root" objects, including local variables, global variables, global constants, hardware registers and the C stack. For each root object, the garbage collector sets its mark flag to true and calls rb_gc_mark on the object. The job of rb_gc_mark is to recursively mark all the objects that a Ruby object has a reference to (ignoring those objects that have already been marked). Those objects, in turn, may reference other objects. This process will continue until all active objects have been "marked." After the mark phase comes the sweep phase. In the sweep phase, all objects that have not been marked will be garbage collected. For more information about the Ruby garbage collector please refer to http://rubygarden.org/ruby/ruby?GCAndExtensions.

The Ruby C/API provides extension developers two hooks into the garbage collector - a "mark" function and a "sweep" function. By default these functions are set to NULL.

If a C struct or C++ class references any other Ruby objects, then it must provide a "mark" function. The "mark" function should identify any referenced Ruby objects by calling the rb_gc_mark function for each one. Unsurprisingly, this function will be called by the Ruby garbage during the "mark" phase.

During the sweep phase, Ruby destroys any unused objects. If any memory has been allocated in creating the underlying C struct or C++ struct, then a "free" function must be defined that deallocates this memory.

38.10.2 Object Ownership

As described above, memory management depends on clearly defining who is responsible for freeing the underlying C struct or C++ class. If the Ruby object is responsible for freeing the C++ object, then a "free" function must be registered for the object. If the Ruby object is not responsible for freeing the underlying memory, then a "free" function must not be registered for the object.

For the most part, SWIG takes care of memory management issues. The rules it uses are:

  • When calling a C++ object's constructor from Ruby, SWIG will assign a "free" function thereby making the Ruby object responsible for freeing the C++ object
  • When calling a C++ member function that returns a pointer, SWIG will not assign a "free" function thereby making the underlying library responsible for freeing the object.

To make this clearer, let's look at an example. Assume we have a Foo and a Bar class.

/* File "RubyOwernshipExample.h" */

class Foo
{
public:
  Foo() {}
  ~Foo() {}
};

class Bar
{
  Foo *foo_;
public:
  Bar(): foo_(new Foo) {}
  ~Bar() { delete foo_; }
  Foo* get_foo() { return foo_; }
  Foo* get_new_foo() { return new Foo; }
  void set_foo(Foo *foo) { delete foo_; foo_ = foo; }
};

First, consider this Ruby code:

foo = Foo.new

In this case, the Ruby code calls the underlying Foo C++ constructor, thus creating a new foo object. By default, SWIG will assign the new Ruby object a "free" function. When the Ruby object is garbage collected, the "free" function will be called. It in turn will call Foo's destructor.

Next, consider this code:

bar = Bar.new
foo = bar.get_foo()

In this case, the Ruby code calls a C++ member function, get_foo . By default, SWIG will not assign the Ruby object a "free" function. Thus, when the Ruby object is garbage collected the underlying C++ foo object is not affected.

Unfortunately, the real world is not as simple as the examples above. For example:

bar = Bar.new
foo = bar.get_new_foo()

In this case, the default SWIG behavior for calling member functions is incorrect. The Ruby object should assume ownership of the returned object. This can be done by using the %newobject directive. See Object ownership and %newobject for more information.

The SWIG default mappings are also incorrect in this case:

foo = Foo.new
bar = Bar.new
bar.set_foo(foo)

Without modification, this code will cause a segmentation fault. When the Ruby foo object goes out of scope, it will free the underlying C++ foo object. However, when the Ruby bar object goes out of scope, it will call the C++ bar destructor which will also free the C++ foo object. The problem is that object ownership is transferred from the Ruby object to the C++ object when the set_foo method is called. This can be done by using the special DISOWN type map, which was added to the Ruby bindings in SWIG-1.3.26.

Thus, a correct SWIG interface file correct mapping for these classes is:

/* File RubyOwnershipExample.i */

%module RubyOwnershipExample

%{
#include "RubyOwnershipExample.h"
%}

class Foo
{
public:
  Foo();
  ~Foo();
};

class Bar
{
  Foo *foo_;
public:
  Bar();
  ~Bar();
  Foo* get_foo();

  %newobject get_new_foo;
  Foo* get_new_foo();

  %apply SWIGTYPE *DISOWN {Foo *foo};
  void set_foo(Foo *foo);
  %clear Foo *foo;
};

This code can be seen in swig/examples/ruby/tracking.

38.10.3 Object Tracking

The remaining parts of this section will use the class library shown below to illustrate different memory management techniques. The class library models a zoo and the animals it contains.

%module zoo

%{
#include <string>
#include <vector>

#include "zoo.h"
%}

class Animal
{
private:
  typedef std::vector<Animal*> AnimalsType;
  typedef AnimalsType::iterator IterType;
protected:
  AnimalsType animals;
protected:
  std::string name_;
public:
  // Construct an animal with this name
  Animal(const char* name) : name_(name) {}
 
  // Return the animal's name
  const char* get_name() const { return name.c_str(); }
};

class Zoo
{
protected:
 std::vector<animal *=""> animals;
 
public:
  // Construct an empty zoo
  Zoo() {}
  
  /* Create a new animal. */
  static Animal* Zoo::create_animal(const char* name) {
    return new Animal(name);
  }
 
  // Add a new animal to the zoo
  void add_animal(Animal* animal) {
    animals.push_back(animal); 
  }
 
  Animal* remove_animal(size_t i) {
    Animal* result = this->animals[i];
    IterType iter = this->animals.begin();
    std::advance(iter, i);
    this->animals.erase(iter);
   
    return result;
  }
  
  // Return the number of animals in the zoo
  size_t get_num_animals() const {
    return animals.size(); 
  }
  
  // Return a pointer to the ith animal
  Animal* get_animal(size_t i) const {
    return animals[i]; 
  }
};

Let's say you SWIG this code and then run IRB:

$ irb
irb(main):001:0> require 'example'
=> true

irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2be3820>

irb(main):004:0> tiger1.get_name()
=> "tiger1"

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be0a60>

irb(main):006:0> zoo.add_animal(tiger)
=> nil

irb(main):007:0> zoo.get_num_animals()
=> 1

irb(main):007:0> tiger2 = zoo.remove_animal(0)
=> #<Example::Animal:0x2bd4a18>

irb(main):008:0> tiger2.get_name()
=> "tiger1"

irb(main):009:0> tiger1.equal?(tiger2)
=> false

Pay particular attention to the code tiger1.equal?(tiger2). Note that the two Ruby objects are not the same - but they reference the same underlying C++ object. This can cause problems. For example:

irb(main):010:0> tiger1 = nil
=> nil

irb(main):011:0> GC.start
=> nil

irb(main):012:0> tiger2.get_name()
(irb):12: [BUG] Segmentation fault

After the garbage collector runs, as a result of our call to GC.start, callingtiger2.get_name() causes a segmentation fault. The problem is that when tiger1 is garbage collected, it frees the underlying C++ object. Thus, when tiger2 calls the get_name() method it invokes it on a destroyed object.

This problem can be avoided if SWIG enforces a one-to-one mapping between Ruby objects and C++ classes. This can be done via the use of the %trackobjects functionality available in SWIG-1.3.26. and later.

When the %trackobjects is turned on, SWIG automatically keeps track of mappings between C++ objects and Ruby objects. Note that enabling object tracking causes a slight performance degradation. Test results show this degradation to be about 3% to 5% when creating and destroying 100,000 animals in a row.

Since %trackobjects is implemented as a %feature, it uses the same name matching rules as other kinds of features (see the chapter on "Customization Features") . Thus it can be applied on a class-by-class basis if needed. To fix the example above:

%module example

%{
#include "example.h"
%}

/* Tell SWIG that create_animal creates a new object */
%newobject Zoo::create_animal;

/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */%trackobjects;

%include "example.h"

When this code runs we see:

$ irb
irb(main):001:0> require 'example'
=> true

irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2be37d8>

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be0a18>

irb(main):004:0> zoo.add_animal(tiger1)
=> nil

irb(main):006:0> tiger2 = zoo.remove_animal(0)
=> #<Example::Animal:0x2be37d8>

irb(main):007:0> tiger1.equal?(tiger2)
=> true

irb(main):008:0> tiger1 = nil
=> nil

irb(main):009:0> GC.start
=> nil

irb(main):010:0> tiger.get_name()
=> "tiger1"
irb(main):011:0>

For those who are interested, object tracking is implemented by storing Ruby objects in a hash table and keying them on C++ pointers. The underlying API is:

static void SWIG_RubyAddTracking(void* ptr, VALUE object);
static VALUE SWIG_RubyInstanceFor(void* ptr) ;
static void SWIG_RubyRemoveTracking(void* ptr);
static void SWIG_RubyUnlinkObjects(void* ptr);

When an object is created, SWIG will automatically call the SWIG_RubyAddTracking method. Similarly, when an object is deleted, SWIG will call the SWIG_RubyRemoveTracking. When an object is returned to Ruby from C++, SWIG will use the SWIG_RubyInstanceFor method to ensure a one-to-one mapping from Ruby to C++ objects. Last, the RubyUnlinkObjects method unlinks a Ruby object from its underlying C++ object.

In general, you will only need to use the SWIG_RubyInstanceFor , which is required for implementing mark functions as shown below. However, if you implement your own free functions (see below) you may also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects methods.

38.10.4 Mark Functions

With a bit more testing, we see that our class library still has problems. For example:

$ irb
irb(main):001:0> require 'example'
=> true

irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2bea6a8>

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be7960>

irb(main):004:0> zoo.add_animal(tiger1)
=> nil

irb(main):007:0> tiger1 = nil
=> nil

irb(main):007:0> GC.start
=> nil

irb(main):005:0> tiger2 = zoo.get_animal(0)
(irb):12: [BUG] Segmentation fault

The problem is that Ruby does not know that the zoo object contains a reference to a Ruby object. Thus, when Ruby garbage collects tiger1 it frees the underlying C++ object.

This can be fixed by implementing a mark function as described above in the Mark and Sweep Garbage Collector section. You can specify a mark function by using the %markfunc directive. Since the %markfunc directive is implemented using SWIG's' "features" mechanism it uses the same name matching rules as other kinds of features (see the chapter on "Customization Features" for more details).

A mark function takes a single argument, which is a pointer to the C++ object being marked; it should, in turn, call rb_gc_mark() for any instances that are reachable from the current object. The mark function for our Zoo class should therefore loop over all of the C++ animal objects in the zoo object, look up their Ruby object equivalent, and then call rb_gc_mark(). One possible implementation is:

%module example

%{
#include "example.h"
%}

/* Keep track of mappings between C/C++ structs/classes
 and Ruby objects so we can implement a mark function. */
%trackobjects;

/* Specify the mark function */
%markfunc Zoo "mark_Zoo";

%include "example.h"

%header %{

static void mark_Zoo(void* ptr) {
  Zoo* zoo = (Zoo*) ptr;
 
  /* Loop over each object and tell the garbage collector
  that we are holding a reference to them. */
  int count = zoo->get_num_animals();
 
  for(int i = 0; i < count; ++i) {
    Animal* animal = zoo->get_animal(i);
    VALUE object = SWIG_RubyInstanceFor(animal);
 
    if (object != Qnil) {
      rb_gc_mark(object);
    }
  }
}
%}

Note the mark function is dependent on the SWIG_RUBY_InstanceFor method, and thus requires that %trackobjects is enabled. For more information, please refer to the track_object.i test case in the SWIG test suite.

When this code is compiled we now see:

$ irb
irb(main):002:0> tiger1=Example::Animal.new("tiger1")
=> #<Example::Animal:0x2be3bf8>

irb(main):003:0> Example::Zoo.new()
=> #<Example::Zoo:0x2be1780>

irb(main):004:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2bde9c0>

irb(main):005:0> zoo.add_animal(tiger1)
=> nil

irb(main):009:0> tiger1 = nil
=> nil

irb(main):010:0> GC.start
=> nil
irb(main):014:0> tiger2 = zoo.get_animal(0)
=> #<Example::Animal:0x2be3bf8>

irb(main):015:0> tiger2.get_name()
=> "tiger1"
irb(main):016:0>

This code can be seen in swig/examples/ruby/mark_function.

38.10.5 Free Functions

By default, SWIG creates a "free" function that is called when a Ruby object is garbage collected. The free function simply calls the C++ object's destructor.

However, sometimes an appropriate destructor does not exist or special processing needs to be performed before the destructor is called. Therefore, SWIG allows you to manually specify a "free" function via the use of the %freefunc directive. The %freefunc directive is implemented using SWIG's' "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

IMPORTANT ! - If you define your own free function, then you must ensure that you call the underlying C++ object's destructor. In addition, if object tracking is activated for the object's class, you must also call the SWIG_RubyRemoveTracking function (of course call this before you destroy the C++ object). Note that it is harmless to call this method if object tracking if off so it is advised to always call it.

Note there is a subtle interaction between object ownership and free functions. A custom defined free function will only be called if the Ruby object owns the underlying C++ object. This also to Ruby objects which are created, but then transfer ownership to C++ objects via the use of the disown typemap described above.

To show how to use the %freefunc directive, let's slightly change our example. Assume that the zoo object is responsible for freeing animal that it contains. This means that the Zoo::add_animal function should be marked with a DISOWN typemap and the destructor should be updated as below:

Zoo::~Zoo() {
 IterType iter = this->animals.begin();
 IterType end = this->animals.end();

 for(iter; iter != end; ++iter) {
 Animal* animal = *iter;
 delete animal;
 }
}

When we use these objects in IRB we see:

$irb
irb(main):002:0> require 'example'
=> true

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be0fe8>

irb(main):005:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2bda760>

irb(main):006:0> zoo.add_animal(tiger1)
=> nil

irb(main):007:0> zoo = nil
=> nil

irb(main):008:0> GC.start
=> nil

irb(main):009:0> tiger1.get_name()
(irb):12: [BUG] Segmentation fault

The error happens because the C++ animal object is freed when the zoo object is freed. Although this error is unavoidable, we can at least prevent the segmentation fault. To do this requires enabling object tracking and implementing a custom free function that calls the SWIG_RubyUnlinkObjects function for each animal object that is destroyed. The SWIG_RubyUnlinkObjects function notifies SWIG that a Ruby object's underlying C++ object is no longer valid. Once notified, SWIG will intercept any calls from the existing Ruby object to the destroyed C++ object and raise an exception.

%module example

%{
#include "example.h"
%}

/* Specify that ownership is transferred to the zoo
	when calling add_animal */
%apply SWIGTYPE *DISOWN { Animal* animal };

/* Track objects */
%trackobjects;

/* Specify the mark function */
%freefunc Zoo "free_Zoo";

%include "example.h"

%header %{
  static void free_Zoo(void* ptr) {
    Zoo* zoo = (Zoo*) ptr;

    /* Loop over each animal */
    int count = zoo->get_num_animals();

    for(int i = 0; i < count; ++i) {
      /* Get an animal */
      Animal* animal = zoo->get_animal(i);

      /* Unlink the Ruby object from the C++ object */
      SWIG_RubyUnlinkObjects(animal);

      /* Now remove the tracking for this animal */
      SWIG_RubyRemoveTracking(animal);
    }

    /* Now call SWIG_RubyRemoveTracking for the zoo */
    SWIG_RubyRemoveTracking(ptr);
    /* Now free the zoo which will free the animals it contains */
    delete zoo;
  }
%} 

Now when we use these objects in IRB we see:

$irb
irb(main):002:0> require 'example'
=> true

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be0fe8>

irb(main):005:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2bda760>

irb(main):006:0> zoo.add_animal(tiger1)
=> nil

irb(main):007:0> zoo = nil
=> nil

irb(main):008:0> GC.start
=> nil

irb(main):009:0> tiger1.get_name()
RuntimeError: This Animal * already released
 from (irb):10:in `get_name'
 from (irb):10
irb(main):011:0>

Notice that SWIG can now detect the underlying C++ object has been freed, and thus raises a runtime exception.

This code can be seen in swig/examples/ruby/free_function.

38.10.6 Embedded Ruby and the C++ Stack

As has been said, the Ruby GC runs and marks objects before its sweep phase. When the garbage collector is called, it will also try to mark any Ruby objects (VALUE) it finds in the machine registers and in the C++ stack.

The stack is basically the history of the functions that have been called and also contains local variables, such as the ones you define whenever you do inside a function:

VALUE obj;

For ruby to determine where its stack space begins, during initialization a normal Ruby interpreter will call the ruby_init() function which in turn will call a function called Init_stack or similar. This function will store a pointer to the location where the stack points at that point in time.

ruby_init() is presumed to always be called within the main() function of your program and whenever the GC is called, ruby will assume that the memory between the current location in memory and the pointer that was stored previously represents the stack, which may contain local (and temporary) VALUE ruby objects. Ruby will then be careful not to remove any of those objects in that location.

So far so good. For a normal Ruby session, all the above is completely transparent and magic to the extensions developer.

However, with an embedded Ruby, it may not always be possible to modify main() to make sure ruby_init() is called there. As such, ruby_init() will likely end up being called from within some other function. This can lead Ruby to measure incorrectly where the stack begins and can result in Ruby incorrectly collecting those temporary VALUE objects that are created once another function is called. The end result: random crashes and segmentation faults.

This problem will often be seen in director functions that are used for callbacks, for example.

To solve the problem, SWIG can now generate code with director functions containing the optional macros SWIG_INIT_STACK and SWIG_RELEASE_STACK. These macros will try to force Ruby to reinitiliaze the beginning of the stack the first time a director function is called. This will lead Ruby to measure and not collect any VALUE objects defined from that point on.

To mark functions to either reset the ruby stack or not, you can use:

%initstack Class::memberfunction;   // only re-init the stack in this director method
%ignorestack Class::memberfunction; // do not re-init the stack in this director method
%initstack Class;                   // init the stack on all the methods of this class
%initstack;                         // all director functions will re-init the stack

39 SWIG and Tcl

Caution: This chapter is under repair!

This chapter discusses SWIG's support of Tcl. SWIG currently requires Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but this is no longer supported.

39.1 Preliminaries

To build a Tcl module, run SWIG using the -tcl option :

$ swig -tcl example.i

If building a C++ extension, add the -c++ option:

$ swig -c++ -tcl example.i

This creates a file example_wrap.c or example_wrap.cxx that contains all of the code needed to build a Tcl extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

39.1.1 Getting the right header files

In order to compile the wrapper code, the compiler needs the tcl.h header file. This file is usually contained in the directory

/usr/local/include

Be aware that some Tcl versions install this header file with a version number attached to it. If this is the case, you should probably make a symbolic link so that tcl.h points to the correct header file.

39.1.2 Compiling a dynamic module

The preferred approach to building an extension module is to compile it into a shared object file or DLL. Assuming you have code you need to link to in a file called example.c, you will need to compile your program using commands like this (shown for Linux):

$ swig -tcl example.i
$ gcc -fPIC -c example.c
$ gcc -fPIC -c example_wrap.c -I/usr/local/include
$ gcc -shared example.o example_wrap.o -o example.so

The exact commands for doing this vary from platform to platform. SWIG tries to guess the right options when it is installed. Therefore, you may want to start with one of the examples in the SWIG/Examples/tcl directory. If that doesn't work, you will need to read the man-pages for your compiler and linker to get the right set of options. You might also check the SWIG Wiki for additional information.

When linking the module, the name of the output file has to match the name of the module. If the name of your SWIG module is "example ", the name of the corresponding object file should be "example.so ". The name of the module is specified using the %module directive or the -module command line option.

39.1.3 Static linking

An alternative approach to dynamic linking is to rebuild the Tcl interpreter with your extension module added to it. In the past, this approach was sometimes necessary due to limitations in dynamic loading support on certain machines. However, the situation has improved greatly over the last few years and you should not consider this approach unless there is really no other option.

The usual procedure for adding a new module to Tcl involves writing a special function Tcl_AppInit() and using it to initialize the interpreter and your module. With SWIG, the tclsh.i and wish.i library files can be used to rebuild the tclsh and wish interpreters respectively. For example:

%module example

%inline %{
extern int fact(int);
extern int mod(int, int);
extern double My_variable;
%}

%include "tclsh.i"       // Include code for rebuilding tclsh

The tclsh.i library file includes supporting code that contains everything needed to rebuild tclsh. To rebuild the interpreter, you simply do something like this:

$ swig -tcl example.i
$ gcc example.c example_wrap.c \
        -Xlinker -export-dynamic \
        -DHAVE_CONFIG_H -I/usr/local/include/ \
	-L/usr/local/lib -ltcl -lm -ldl \
	-o mytclsh

You will need to supply the same libraries that were used to build Tcl the first time. This may include system libraries such as -lsocket, -lnsl, and -lpthread. If this actually works, the new version of Tcl should be identical to the default version except that your extension module will be a built-in part of the interpreter.

Comment: In practice, you should probably try to avoid static linking if possible. Some programmers may be inclined to use static linking in the interest of getting better performance. However, the performance gained by static linking tends to be rather minimal in most situations (and quite frankly not worth the extra hassle in the opinion of this author).

39.1.4 Using your module

To use your module, simply use the Tcl load command. If all goes well, you will be able to this:

$ tclsh
% load ./example.so
% fact 4
24
%

A common error received by first-time users is the following:

% load ./example.so
couldn't find procedure Example_Init
% 

This error is almost always caused when the name of the shared object file doesn't match the name of the module supplied using the SWIG %module directive. Double-check the interface to make sure the module name and the shared object file match. Another possible cause of this error is forgetting to link the SWIG-generated wrapper code with the rest of your application when creating the extension module.

Another common error is something similar to the following:

% load ./example.so
couldn't load file "./example.so": ./example.so: undefined symbol: fact
% 

This error usually indicates that you forgot to include some object files or libraries in the linking of the shared library file. Make sure you compile both the SWIG wrapper file and your original program into a shared library file. Make sure you pass all of the required libraries to the linker.

Sometimes unresolved symbols occur because a wrapper has been created for a function that doesn't actually exist in a library. This usually occurs when a header file includes a declaration for a function that was never actually implemented or it was removed from a library without updating the header file. To fix this, you can either edit the SWIG input file to remove the offending declaration or you can use the %ignore directive to ignore the declaration.

Finally, suppose that your extension module is linked with another library like this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -o example.so

If the foo library is compiled as a shared library, you might get the following problem when you try to use your module:

% load ./example.so
couldn't load file "./example.so": libfoo.so: cannot open shared object file:
No such file or directory
%        

This error is generated because the dynamic linker can't locate the libfoo.so library. When shared libraries are loaded, the system normally only checks a few standard locations such as /usr/lib and /usr/local/lib. To fix this problem, there are several things you can do. First, you can recompile your extension module with extra path information. For example, on Linux you can do this:

$ gcc -shared example.o example_wrap.o -L/home/beazley/projects/lib -lfoo \
      -Xlinker -rpath /home/beazley/projects/lib \
      -o example.so

Alternatively, you can set the LD_LIBRARY_PATH environment variable to include the directory with your shared libraries. If setting LD_LIBRARY_PATH, be aware that setting this variable can introduce a noticeable performance impact on all other applications that you run. To set it only for Tcl, you might want to do this instead:

$ env LD_LIBRARY_PATH=/home/beazley/projects/lib tclsh

Finally, you can use a command such as ldconfig to add additional search paths to the default system configuration (this requires root access and you will need to read the man pages).

39.1.5 Compilation of C++ extensions

Compilation of C++ extensions has traditionally been a tricky problem. Since the Tcl interpreter is written in C, you need to take steps to make sure C++ is properly initialized and that modules are compiled correctly.

On most machines, C++ extension modules should be linked using the C++ compiler. For example:

% swig -c++ -tcl example.i
% g++ -fPIC -c example.cxx
% g++ -fPIC -c example_wrap.cxx -I/usr/local/include
% g++ -shared example.o example_wrap.o -o example.so

In addition to this, you may need to include additional library files to make it work. For example, if you are using the Sun C++ compiler on Solaris, you often need to add an extra library -lCrun like this:

% swig -c++ -tcl example.i
% CC -KPIC -c example.cxx
% CC -KPIC -c example_wrap.cxx -I/usr/local/include
% CC -G example.o example_wrap.o -L/opt/SUNWspro/lib -o example.so -lCrun

Of course, the extra libraries to use are completely non-portable---you will probably need to do some experimentation.

Sometimes people have suggested that it is necessary to relink the Tcl interpreter using the C++ compiler to make C++ extension modules work. In the experience of this author, this has never actually appeared to be necessary. Relinking the interpreter with C++ really only includes the special run-time libraries described above---as long as you link your extension modules with these libraries, it should not be necessary to rebuild Tcl.

If you aren't entirely sure about the linking of a C++ extension, you might look at an existing C++ program. On many Unix machines, the ldd command will list library dependencies. This should give you some clues about what you might have to include when you link your extension module. For example:

$ ldd swig
        libstdc++-libc6.1-1.so.2 => /usr/lib/libstdc++-libc6.1-1.so.2 (0x40019000)
        libm.so.6 => /lib/libm.so.6 (0x4005b000)
        libc.so.6 => /lib/libc.so.6 (0x40077000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
$

As a final complication, a major weakness of C++ is that it does not define any sort of standard for binary linking of libraries. This means that C++ code compiled by different compilers will not link together properly as libraries nor is the memory layout of classes and data structures implemented in any kind of portable manner. In a monolithic C++ program, this problem may be unnoticed. However, in Tcl, it is possible for different extension modules to be compiled with different C++ compilers. As long as these modules are self-contained, this probably won't matter. However, if these modules start sharing data, you will need to take steps to avoid segmentation faults and other erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

39.1.6 Compiling for 64-bit platforms

On platforms that support 64-bit applications (Solaris, Irix, etc.), special care is required when building extension modules. On these machines, 64-bit applications are compiled and linked using a different set of compiler/linker options. In addition, it is not generally possible to mix 32-bit and 64-bit code together in the same application.

To utilize 64-bits, the Tcl executable will need to be recompiled as a 64-bit application. In addition, all libraries, wrapper code, and every other part of your application will need to be compiled for 64-bits. If you plan to use other third-party extension modules, they will also have to be recompiled as 64-bit extensions.

If you are wrapping commercial software for which you have no source code, you will be forced to use the same linking standard as used by that software. This may prevent the use of 64-bit extensions. It may also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

39.1.7 Setting a package prefix

To avoid namespace problems, you can instruct SWIG to append a package prefix to all of your functions and variables. This is done using the -prefix option as follows :

swig -tcl -prefix Foo example.i

If you have a function "bar" in the SWIG file, the prefix option will append the prefix to the name when creating a command and call it "Foo_bar".

39.1.8 Using namespaces

Alternatively, you can have SWIG install your module into a Tcl namespace by specifying the -namespace option :

swig -tcl -namespace example.i

By default, the name of the namespace will be the same as the module name, but you can override it using the -prefix option.

When the -namespace option is used, objects in the module are always accessed with the namespace name such as Foo::bar.

39.2 Building Tcl/Tk Extensions under Windows 95/NT

Building a SWIG extension to Tcl/Tk under Windows 95/NT is roughly similar to the process used with Unix. Normally, you will want to produce a DLL that can be loaded into tclsh or wish. This section covers the process of using SWIG with Microsoft Visual C++. although the procedure may be similar with other compilers.

39.2.1 Running SWIG from Developer Studio

If you are developing your application within Microsoft developer studio, SWIG can be invoked as a custom build option. The process roughly follows these steps :

  • Open up a new workspace and use the AppWizard to select a DLL project.
  • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (ie. example_wrap.c). Note : If using C++, choose a different suffix for the wrapper file such as example_wrap.cxx. Don't worry if the wrapper file doesn't exist yet--Developer studio will keep a reference to it around.
  • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
  • Enter "SWIG" in the description field.
  • Enter "swig -tcl -o $(ProjDir)\$(InputName)_wrap.c $(InputPath) " in the "Build command(s) field"
  • Enter "$(ProjDir)\$(InputName)_wrap.c" in the "Output files(s) field".
  • Next, select the settings for the entire project and go to "C++:Preprocessor". Add the include directories for your Tcl installation under "Additional include directories".
  • Finally, select the settings for the entire project and go to "Link Options". Add the Tcl library file to your link libraries. For example "tcl80.lib". Also, set the name of the output file to match the name of your Tcl module (ie. example.dll).
  • Build your project.

Now, assuming all went well, SWIG will be automatically invoked when you build your project. Any changes made to the interface file will result in SWIG being automatically invoked to produce a new version of the wrapper file. To run your new Tcl extension, simply run tclsh or wish and use the load command. For example :

MSDOS > tclsh80
% load example.dll
% fact 4
24
%

39.2.2 Using NMAKE

Alternatively, SWIG extensions can be built by writing a Makefile for NMAKE. To do this, make sure the environment variables for MSVC++ are available and the MSVC++ tools are in your path. Now, just write a short Makefile like this :

# Makefile for building various SWIG generated extensions

SRCS          = example.c
IFILE         = example
INTERFACE     = $(IFILE).i
WRAPFILE      = $(IFILE)_wrap.c

# Location of the Visual C++ tools (32 bit assumed)

TOOLS         = c:\msdev
TARGET        = example.dll
CC            = $(TOOLS)\bin\cl.exe
LINK          = $(TOOLS)\bin\link.exe
INCLUDE32     = -I$(TOOLS)\include
MACHINE       = IX86

# C Library needed to build a DLL

DLLIBC        = msvcrt.lib oldnames.lib  

# Windows libraries that are apparently needed
WINLIB        = kernel32.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib 
winspool.lib

# Libraries common to all DLLs
LIBS          = $(DLLIBC) $(WINLIB) 

# Linker options
LOPT      = -debug:full -debugtype:cv /NODEFAULTLIB /RELEASE /NOLOGO /
MACHINE:$(MACHINE) -entry:_DllMainCRTStartup@12 -dll

# C compiler flags

CFLAGS    = /Z7 /Od /c /nologo
TCL_INCLUDES  = -Id:\tcl8.0a2\generic -Id:\tcl8.0a2\win
TCLLIB        = d:\tcl8.0a2\win\tcl80.lib

tcl::
	..\..\swig -tcl -o $(WRAPFILE) $(INTERFACE)
	$(CC) $(CFLAGS) $(TCL_INCLUDES) $(SRCS) $(WRAPFILE)
	set LIB=$(TOOLS)\lib
	$(LINK) $(LOPT) -out:example.dll $(LIBS) $(TCLLIB) example.obj example_wrap.obj

To build the extension, run NMAKE (you may need to run vcvars32 first). This is a pretty minimal Makefile, but hopefully its enough to get you started. With a little practice, you'll be making lots of Tcl extensions.

39.3 A tour of basic C/C++ wrapping

By default, SWIG tries to build a very natural Tcl interface to your C/C++ code. Functions are wrapped as functions, classes are wrapped in an interface that mimics the style of Tk widgets and [incr Tcl] classes. This section briefly covers the essential aspects of this wrapping.

39.3.1 Modules

The SWIG %module directive specifies the name of the Tcl module. If you specify `%module example', then everything is compiled into an extension module example.so. When choosing a module name, make sure you don't use the same name as a built-in Tcl command.

One pitfall to watch out for is module names involving numbers. If you specify a module name like %module md5, you'll find that the load command no longer seems to work:

% load ./md5.so
couldn't find procedure Md_Init

To fix this, supply an extra argument to load like this:

% load ./md5.so md5

39.3.2 Functions

Global functions are wrapped as new Tcl built-in commands. For example,

%module example
int fact(int n);

creates a built-in function fact that works exactly like you think it does:

% load ./example.so
% fact 4
24
% set x [fact 6]
%

39.3.3 Global variables

C/C++ global variables are wrapped by Tcl global variables. For example:

// SWIG interface file with global variables
%module example
...
%inline %{
extern double density;
%}
...

Now look at the Tcl interface:

% puts $density          # Output value of C global variable
1.0
% set density 0.95       # Change value

If you make an error in variable assignment, you will get an error message. For example:

% set density "hello"
can't set "density": Type error. expected a double.
%

If a variable is declared as const, it is wrapped as a read-only variable. Attempts to modify its value will result in an error.

To make ordinary variables read-only, you can use the %immutable directive. For example:

%{
extern char *path;
%}
%immutable;
extern char *path;
%mutable;

The %immutable directive stays in effect until it is explicitly disabled or cleared using %mutable. See the Creating read-only variables section for further details.

If you just want to make a specific variable immutable, supply a declaration name. For example:

%{
extern char *path;
%}
%immutable path;
...
extern char *path;      // Read-only (due to %immutable)

39.3.4 Constants and enums

C/C++ constants are installed as global Tcl variables containing the appropriate value. To create a constant, use #define, enum , or the %constant directive. For example:

#define PI 3.14159
#define VERSION "1.0"

enum Beverage { ALE, LAGER, STOUT, PILSNER };

%constant int FOO = 42;
%constant const char *path = "/usr/local";

For enums, make sure that the definition of the enumeration actually appears in a header file or in the wrapper file somehow---if you just stick an enum in a SWIG interface without also telling the C compiler about it, the wrapper code won't compile.

Note: declarations declared as const are wrapped as read-only variables and will be accessed using the cvar object described in the previous section. They are not wrapped as constants. For further discussion about this, see the SWIG Basics chapter.

Constants are not guaranteed to remain constant in Tcl---the value of the constant could be accidentally reassigned.You will just have to be careful.

A peculiarity of installing constants as variables is that it is necessary to use the Tcl global statement to access constants in procedure bodies. For example:

proc blah {} {
   global FOO
   bar $FOO
}

If a program relies on a lot of constants, this can be extremely annoying. To fix the problem, consider using the following typemap rule:

%apply int CONSTANT { int x };
#define FOO 42
...
void bar(int x);

When applied to an input argument, the CONSTANT rule allows a constant to be passed to a function using its actual value or a symbolic identifier name. For example:

proc blah {} {
   bar FOO
}

When an identifier name is given, it is used to perform an implicit hash-table lookup of the value during argument conversion. This allows the global statement to be omitted.

39.3.5 Pointers

C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Here is a rather simple interface:

%module example

FILE *fopen(const char *filename, const char *mode);
int fputs(const char *, FILE *);
int fclose(FILE *);

When wrapped, you will be able to use the functions in a natural way from Tcl. For example:

% load ./example.so
% set f [fopen junk w]
% fputs "Hello World\n" $f
% fclose $f

If this makes you uneasy, rest assured that there is no deep magic involved. Underneath the covers, pointers to C/C++ objects are simply represented as opaque values--normally an encoded character string like this:

% puts $f
_c0671108_p_FILE
% 

This pointer value can be freely passed around to different C functions that expect to receive an object of type FILE *. The only thing you can't do is dereference the pointer from Tcl.

The NULL pointer is represented by the string NULL.

As much as you might be inclined to modify a pointer value directly from Tcl, don't. The hexadecimal encoding is not necessarily the same as the logical memory address of the underlying object. Instead it is the raw byte encoding of the pointer value. The encoding will vary depending on the native byte-ordering of the platform (i.e., big-endian vs. little-endian). Similarly, don't try to manually cast a pointer to a new type by simply replacing the type-string. This may not work like you expect and it is particularly dangerous when casting C++ objects. If you need to cast a pointer or change its value, consider writing some helper functions instead. For example:

%inline %{
/* C-style cast */
Bar *FooToBar(Foo *f) {
   return (Bar *) f;
}

/* C++-style cast */
Foo *BarToFoo(Bar *b) {
   return dynamic_cast<Foo*>(b);
}

Foo *IncrFoo(Foo *f, int i) {
    return f+i;
}
%}

Also, if working with C++, you should always try to use the new C++ style casts. For example, in the above code, the C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

39.3.6 Structures

If you wrap a C structure, it is wrapped by a Tcl interface that somewhat resembles a Tk widget. This provides a very natural interface. For example,

struct Vector {
	double x,y,z;
};

is used as follows:

% Vector v
% v configure -x 3.5 -y 7.2
% puts "[v cget -x] [v cget -y] [v cget -z]"
3.5 7.2 0.0
% 

Similar access is provided for unions and the data members of C++ classes.

In the above example, v is a name that's used for the object. However, underneath the covers, there's a pointer to a raw C structure. This can be obtained by looking at the -this attribute. For example:

% puts [v cget -this]
_88e31408_p_Vector

Further details about the relationship between the Tcl and the underlying C structure are covered a little later.

const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive. For example:

struct Foo {
   ...
   %immutable;
   int x;        /* Read-only members */
   char *name;
   %mutable;
   ...
};

When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run with the -c++ option). When the structure member is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described later).

If a structure contains arrays, access to those arrays is managed through pointers. For example, consider this:

struct Bar {
    int  x[16];
};

If accessed in Tcl, you will see behavior like this:

% Bar b
% puts [b cget -x]
_801861a4_p_int
% 

This pointer can be passed around to functions that expect to receive an int * (just like C). You can also set the value of an array member using another pointer. For example:

% Bar c
% c configure -x [b cget -x]   # Copy contents of b.x to c.x

For array assignment, SWIG copies the entire contents of the array starting with the data pointed to by b.x. In this example, 16 integers would be copied. Like C, SWIG makes no assumptions about bounds checking---if you pass a bad pointer, you may get a segmentation fault or access violation.

When a member of a structure is itself a structure, it is handled as a pointer. For example, suppose you have two structures like this:

struct Foo {
   int a;
};

struct Bar {
   Foo f;
};

Now, suppose that you access the f attribute of Bar like this:

% Bar b
% set x [b cget -f]

In this case, x is a pointer that points to the Foo that is inside b. This is the same value as generated by this C code:

Bar b;
Foo *x = &b->f;       /* Points inside b */

However, one peculiarity of accessing a substructure like this is that the returned value does work quite like you might expect. For example:

% Bar b
% set x [b cget -f]
% x cget -a
invalid command name "x"

This is because the returned value was not created in a normal way from the interpreter (x is not a command object). To make it function normally, just evaluate the variable like this:

% Bar b
% set x [b cget -f]
% $x cget -a
0
%

In this example, x points inside the original structure. This means that modifications work just like you would expect. For example:


% Bar b
% set x [b cget -f]
% $x configure -a 3            # Modifies contents of f (inside b)
% [b cget -f] -configure -a 3  # Same thing

In many of these structure examples, a simple name like "v" or "b" has been given to wrapped structures. If necessary, this name can be passed to functions that expect to receive an object. For example, if you have a function like this,

void blah(Foo *f);

you can call the function in Tcl as follows:

% Foo x            # Create a Foo object 
% blah x           # Pass the object to a function

It is also possible to call the function using the raw pointer value. For instance:

% blah [x cget -this]   # Pass object to a function

It is also possible to create and use objects using variables. For example:

% set b [Bar]            # Create a Bar
% $b cget -f             # Member access
% puts $b
_108fea88_p_Bar
%

Finally, to destroy objects created from Tcl, you can either let the object name go out of scope or you can explicitly delete the object. For example:

% Foo f                 # Create object f
% rename f ""

or

% Foo f                 # Create object f
% f -delete

Note: Tcl only destroys the underlying object if it has ownership. See the memory management section that appears shortly.

39.3.7 C++ classes

C++ classes are wrapped as an extension of structure wrapping. For example, if you have this class,

class List {
public:
  List();
  ~List();
  int  search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int  length;
};

you can use it in Tcl like this:

% List x
% x insert Ale
% x insert Stout
% x insert Lager
% x get 1
Stout
% puts [l cget -length]
3
%

Class data members are accessed in the same manner as C structures.

Static class members are accessed as global functions or variables. To illustrate, suppose you have a class like this:

class Spam {
public:
   static void foo();
   static int bar;

};

In Tcl, the static member is accessed as follows:

% Spam_foo        # Spam::foo()
% puts $Spam_bar  # Spam::bar

39.3.8 C++ inheritance

SWIG is fully aware of issues related to C++ inheritance. Therefore, if you have classes like this

class Foo {
...
};

class Bar : public Foo {
...
};

An object of type Bar can be used where a Foo is expected. For example, if you have this function:

void spam(Foo *f);

then the function spam() accepts a Foo * or a pointer to any class derived from Foo. For instance:

% Foo f      # Create a Foo
% Bar b      # Create a Bar
% spam f     # OK
% spam b     # OK

It is safe to use multiple inheritance with SWIG.

39.3.9 Pointers, references, values, and arrays

In C++, there are many different ways a function might receive and manipulate objects. For example:

void spam1(Foo *x);      // Pass by pointer
void spam2(Foo &x);      // Pass by reference
void spam3(Foo x);       // Pass by value
void spam4(Foo x[]);     // Array of objects

In Tcl, there is no detailed distinction like this. Because of this, SWIG unifies all of these types together in the wrapper code. For instance, if you actually had the above functions, it is perfectly legal to do this:

% Foo f             # Create a Foo
% spam1 f           # Ok. Pointer
% spam2 f           # Ok. Reference
% spam3 f           # Ok. Value.
% spam4 f           # Ok. Array (1 element)

Similar behavior occurs for return values. For example, if you had functions like this,

Foo *spam5();
Foo &spam6();
Foo  spam7();

then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Tcl will release this memory when the return value is garbage collected).

39.3.10 C++ overloaded functions

C++ overloaded functions, methods, and constructors are mostly supported by SWIG. For example, if you have two functions like this:

void foo(int);
void foo(char *c);

You can use them in Tcl in a straightforward manner:

% foo 3            # foo(int)
% foo Hello        # foo(char *c)

Similarly, if you have a class like this,

class Foo {
public:
    Foo();
    Foo(const Foo &);
    ...
};

you can write Tcl code like this:

% Foo f                # Create a Foo
% Foo g f              # Copy f

Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG can't disambiguate. For example:

void spam(int);
void spam(short);

or

void foo(Bar *b);
void foo(Bar &b);

If declarations such as these appear, you will get a warning message like this:

example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).

To fix this, you either need to ignore or rename one of the methods. For example:

%rename(spam_short) spam(short);
...
void spam(int);    
void spam(short);   // Accessed as spam_short

or

%ignore spam(short);
...
void spam(int);    
void spam(short);   // Ignored

SWIG resolves overloaded functions and methods using a disambiguation scheme that ranks and sorts declarations according to a set of type-precedence rules. The order in which declarations appear in the input does not matter except in situations where ambiguity arises--in this case, the first declaration takes precedence.

Please refer to the "SWIG and C++" chapter for more information about overloading.

39.3.11 C++ operators

Certain C++ overloaded operators can be handled automatically by SWIG. For example, consider a class like this:

class Complex {
private:
  double rpart, ipart;
public:
  Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
  Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
  Complex &operator=(const Complex &c);
  Complex operator+(const Complex &c) const;
  Complex operator-(const Complex &c) const;
  Complex operator*(const Complex &c) const;
  Complex operator-() const;
  
  double re() const { return rpart; }
  double im() const { return ipart; }
};

When wrapped, it works like this:

% Complex c 3 4
% Complex d 7 8
% set e [c + d]
% $e re
10.0
% $e im
12.0

It should be stressed that operators in SWIG have no relationship to operators in Tcl. In fact, the only thing that's happening here is that an operator like operator + has been renamed to a method + . Therefore, the statement [c + d] is really just invoking the + method on c. When more than operator is defined (with different arguments), the standard method overloading facilities are used. Here is a rather odd looking example:

% Complex c 3 4
% Complex d 7 8
% set e [c - d]       # operator-(const Complex &)
% puts "[$e re] [$e im]"
10.0 12.0
% set f [c -]         # operator-()
% puts "[$f re] [$f im]"
-3.0 -4.0
%

One restriction with operator overloading support is that SWIG is not able to fully handle operators that aren't defined as part of the class. For example, if you had code like this

class Complex {
...
friend Complex operator+(double, const Complex &c);
...
};

then SWIG doesn't know what to do with the friend function--in fact, it simply ignores it and issues a warning. You can still wrap the operator, but you may have to encapsulate it in a special function. For example:

%rename(Complex_add_dc) operator+(double, const Complex &);
...
Complex operator+(double, const Complex &c);

There are ways to make this operator appear as part of the class using the %extend directive. Keep reading.

39.3.12 C++ namespaces

SWIG is aware of C++ namespaces, but namespace names do not appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

%module example

namespace foo {
   int fact(int n);
   struct Vector {
       double x,y,z;
   };
};

it works in Tcl as follows:

% load ./example.so
% fact 3
6
% Vector v
% v configure -x 3.4

If your program has more than one namespace, name conflicts (if any) can be resolved using %rename For example:

%rename(Bar_spam) Bar::spam;

namespace Foo {
    int spam();
}

namespace Bar {
    int spam();
}

If you have more than one namespace and your want to keep their symbols separate, consider wrapping them as separate SWIG modules. For example, make the module name the same as the namespace and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

39.3.13 C++ templates

C++ templates don't present a huge problem for SWIG. However, in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the %template directive. For example:

%module example
%{
#include "pair.h"
%}

template<class T1, class T2>
struct pair {
   typedef T1 first_type;
   typedef T2 second_type;
   T1 first;
   T2 second;
   pair();
   pair(const T1&, const T2&);
  ~pair();
};

%template(pairii) pair<int,int>;

In Tcl:

% pairii p 3 4
% p cget -first
3
% p cget -second
4

Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.

39.3.14 C++ Smart Pointers

In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

template<class T> class SmartPtr {
   ...
   T *operator->();
   ...
}

Then, if you have a class like this,

class Foo {
public:
     int x;
     int bar();
};

A smart pointer would be used in C++ as follows:

SmartPtr<Foo> p = CreateFoo();   // Created somehow (not shown)
...
p->x = 3;                        // Foo::x
int y = p->bar();                // Foo::bar

To wrap this in Tcl, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using %template if necessary. For example:

%module example
...
%template(SmartPtrFoo) SmartPtr<Foo>;
...

Now, in Tcl, everything should just "work":

% set p [CreateFoo]                  # Create a smart-pointer somehow
% $p configure -x 3                  # Foo::x
% $p bar                             # Foo::bar

If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

% set f [$p __deref__]    # Returns underlying Foo *

39.4 Further details on the Tcl class interface

In the previous section, a high-level view of Tcl wrapping was presented. A key component of this wrapping is that structures and classes are wrapped by Tcl class-like objects. This provides a very natural Tcl interface and allows SWIG to support a number of advanced features such as operator overloading. However, a number of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

39.4.1 Proxy classes

In the "SWIG basics" and "SWIG and C++" chapters, details of low-level structure and class wrapping are described. To summarize those chapters, if you have a class like this

class Foo {
public:
     int x;
     int spam(int);
     ...

then SWIG transforms it into a set of low-level procedural wrappers. For example:

Foo *new_Foo() {
    return new Foo();
}
void delete_Foo(Foo *f) {
    delete f;
}
int Foo_x_get(Foo *f) {
    return f->x;
}
void Foo_x_set(Foo *f, int value) {
    f->x = value;
}
int Foo_spam(Foo *f, int arg1) {
    return f->spam(arg1);
}

These wrappers are actually found in the Tcl extension module. For example, you can certainly do this:

% load ./example.so
% set f [new_Foo]
% Foo_x_get $f
0
% Foo_spam $f 3
1
%

However, in addition to this, the classname Foo is used as an object constructor function. This allows objects to be encapsulated objects that look a lot like Tk widgets as shown in the last section.

39.4.2 Memory management

Associated with each wrapped object, is an ownership flag thisown The value of this flag determines who is responsible for deleting the underlying C++ object. If set to 1, the Tcl interpreter destroys the C++ object when the proxy class is garbage collected. If set to 0 (or if the attribute is missing), then the destruction of the proxy class has no effect on the C++ object.

When an object is created by a constructor or returned by value, Tcl automatically takes ownership of the result. For example:

class Foo {
public:
    Foo();
    Foo bar();
};

In Tcl:

% Foo f
% f cget -thisown
1
% set g [f bar]
% $g cget -thisown
1

On the other hand, when pointers are returned to Tcl, there is often no way to know where they came from. Therefore, the ownership is set to zero. For example:

class Foo {
public:
    ...
    Foo *spam();
    ...
};

% Foo f
% set s [f spam]
% $s cget -thisown
0
% 

This behavior is especially important for classes that act as containers. For example, if a method returns a pointer to an object that is contained inside another object, you definitely don't want Tcl to assume ownership and destroy it!

Related to containers, ownership issues can arise whenever an object is assigned to a member or global variable. For example, consider this interface:

%module example

struct Foo {
    int  value;
    Foo  *next;
};

Foo *head = 0;

When wrapped in Tcl, careful observation will reveal that ownership changes whenever an object is assigned to a global variable. For example:

% Foo f
% f cget -thisown
1
% set head f
% f cget -thisown
0

In this case, C is now holding a reference to the object---you probably don't want Tcl to destroy it. Similarly, this occurs for members. For example:

% Foo f
% Foo g
% f cget -thisown
1
% g cget -thisown
1
% f configure -next g
% g cget -thisown 
0
%

For the most part, memory management issues remain hidden. However, there are occasionally situations where you might have to manually change the ownership of an object. For instance, consider code like this:

class Node {
   Object *value;
public:
   void set_value(Object *v) { value = v; }
   ...
};

Now, consider the following Tcl code:

% Object v                 # Create an object
% Node n                   # Create a node
% n setvalue v             # Set value
% v cget -thisown
1
% 

In this case, the object n is holding a reference to v internally. However, SWIG has no way to know that this has occurred. Therefore, Tcl still thinks that it has ownership of the object. Should the proxy object be destroyed, then the C++ destructor will be invoked and n will be holding a stale-pointer. If you're lucky, you will only get a segmentation fault.

To work around this, it is always possible to flip the ownership flag. For example,

% v -disown              # Give ownership to C/C++
% v -acquire             # Acquire ownership

It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

39.5 Input and output parameters

A common problem in some C programs is handling parameters passed as simple pointers. For example:

void add(int x, int y, int *result) {
   *result = x + y;
}

or perhaps

int sub(int *x, int *y) {
   return *x+*y;
}

The easiest way to handle these situations is to use the typemaps.i file. For example:

%module example
%include "typemaps.i"

void add(int, int, int *OUTPUT);
int  sub(int *INPUT, int *INPUT);

In Tcl, this allows you to pass simple values instead of pointer. For example:

set a [add 3 4]
puts $a
7

Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter creates a return result.

If you don't want to use the names INPUT or OUTPUT , use the %apply directive. For example:

%module example
%include "typemaps.i"

%apply int *OUTPUT { int *result };
%apply int *INPUT  { int *x, int *y};

void add(int x, int y, int *result);
int  sub(int *x, int *y);

If a function mutates one of its parameters like this,

void negate(int *x) {
   *x = -(*x);
}

you can use INOUT like this:

%include "typemaps.i"
...
void negate(int *INOUT);

In Tcl, a mutated parameter shows up as a return value. For example:

set a [negate 3]
puts $a
-3

The most common use of these special typemap rules is to handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

/* send message, return number of bytes sent, along with success code */
int send_message(char *text, int len, int *success);

To wrap such a function, simply use the OUTPUT rule above. For example:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *success };
...
int send_message(char *text, int *success);

When used in Tcl, the function will return multiple values as a list.

set r [send_message "Hello World"]
set bytes [lindex $r 0]
set success [lindex $r 1]

Another common use of multiple return values are in query functions. For example:

void get_dimensions(Matrix *m, int *rows, int *columns);

To wrap this, you might use the following:

%module example
%include "typemaps.i"
%apply int *OUTPUT { int *rows, int *columns };
...
void get_dimensions(Matrix *m, int *rows, *columns);

Now, in Perl:

set dim [get_dimensions $m]
set r  [lindex $dim 0]
set c  [lindex $dim 1]

39.6 Exception handling

The %exception directive can be used to create a user-definable exception handler in charge of converting exceptions in your C/C++ program into Tcl exceptions. The chapter on customization features contains more details, but suppose you extended the array example into a C++ class like the following :

class RangeError {};   // Used for an exception

class DoubleArray {
  private:
    int n;
    double *ptr;
  public:
    // Create a new array of fixed size
    DoubleArray(int size) {
      ptr = new double[size];
      n = size;
    }
    // Destroy an array
    ~DoubleArray() {
       delete ptr;
    }
    // Return the length of the array
    int   length() {
      return n;
    }

    // Get an item from the array and perform bounds checking.
    double getitem(int i) {
      if ((i >= 0) && (i < n))
        return ptr[i];
      else
        throw RangeError();
    }

    // Set an item in the array and perform bounds checking.
    void setitem(int i, double val) {
      if ((i >= 0) && (i < n))
        ptr[i] = val;
      else {
        throw RangeError();
      }
    }
  };

The functions associated with this class can throw a C++ range exception for an out-of-bounds array access. We can catch this in our Tcl extension by specifying the following in an interface file :

%exception {
  try {
    $action                // Gets substituted by actual function call
  }
  catch (RangeError) {
    Tcl_SetStringObj(tcl_result,"Array index out-of-bounds");
    return TCL_ERROR;
  }
}

As shown, the exception handling code will be added to every wrapper function. Since this is somewhat inefficient. You might consider refining the exception handler to only apply to specific methods like this:

%exception getitem {
  try {
    $action
  }
  catch (RangeError) {
    Tcl_SetStringObj(tcl_result,"Array index out-of-bounds");
    return TCL_ERROR;
  }
}

%exception setitem {
  try {
    $action
  }
  catch (RangeError) {
    Tcl_SetStringObj(tcl_result,"Array index out-of-bounds");
    return TCL_ERROR;
  }
}

In this case, the exception handler is only attached to methods and functions named getitem and setitem.

If you had a lot of different methods, you can avoid extra typing by using a macro. For example:

%define RANGE_ERROR
{
  try {
    $action
  }
  catch (RangeError) {
    Tcl_SetStringObj(tcl_result,"Array index out-of-bounds");
    return TCL_ERROR;
  }
}
%enddef

%exception getitem RANGE_ERROR;
%exception setitem RANGE_ERROR;

Since SWIG's exception handling is user-definable, you are not limited to C++ exception handling. See the chapter on " Customization Features" for more examples.

39.7 Typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Tcl C API as well as the material in the "Typemaps " chapter.

Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the primitive C-Tcl interface.

39.7.1 What is a typemap?

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Tcl to C, you might define a typemap like this:

%module example

%typemap(in) int {
        if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) return TCL_ERROR;
	printf("Received an integer : %d\n",$1);
}
%inline %{
extern int fact(int n);
%}

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input variable is the input object of type Tcl_Obj *.

When this example is compiled into a Tcl module, it operates as follows:

% load ./example.so
% fact 6
Received an integer : 6
720

In this example, the typemap is applied to all occurrences of the int datatype. You can refine this by supplying an optional parameter name. For example:

%module example

%typemap(in) int n {
        if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) return TCL_ERROR;
	printf("n = %d\n",$1);
}
%inline %{
extern int fact(int n);
%}

In this case, the typemap code is only attached to arguments that exactly match int n.

The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG type-system. When you define a typemap for int, that typemap applies to int and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

%typemap(in) int n {
        if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) return TCL_ERROR;
	printf("n = %d\n",$1);
}
%inline %{
typedef int Integer;
extern int fact(Integer n);    // Above typemap is applied
%}

However, the matching of typedef only occurs in one direction. If you defined a typemap for Integer, it is not applied to arguments of type int.

Typemaps can also be defined for groups of consecutive arguments. For example:

%typemap(in) (char *str, int len) {
    $1 = Tcl_GetStringFromObj($input,&$2);
};

int count(char c, char *str, int len);

When a multi-argument typemap is defined, the arguments are always handled as a single Tcl object. This allows the function to be used like this (notice how the length parameter is omitted):

% count e "Hello World"
1

39.7.2 Tcl typemaps

The previous section illustrated an "in" typemap for converting Tcl objects to C. A variety of different typemap methods are defined by the Tcl module. For example, to convert a C integer back into a Tcl object, you might define an "out" typemap like this:

%typemap(out) int {
    Tcl_SetObjResult(interp,Tcl_NewIntObj($1));
}

The following list details all of the typemap methods that can be used by the Tcl module:

%typemap(in)

Converts Tcl objects to input function arguments

%typemap(out)

Converts return value of a C function to a Tcl object

%typemap(varin)

Assigns a C global variable from a Tcl object

%typemap(varout)

Returns a C global variable as a Tcl object

%typemap(freearg)

Cleans up a function argument (if necessary)

%typemap(argout)

Output argument processing

%typemap(ret)

Cleanup of function return values

%typemap(consttab)

Creation of Tcl constants (constant table)

%typemap(constcode)

Creation of Tcl constants (init function)

%typemap(memberin)

Setting of structure/class member data

%typemap(globalin)

Setting of C global variables

%typemap(check)

Checks function input values.

%typemap(default)

Set a default value for an argument (making it optional).

%typemap(arginit)

Initialize an argument to a value before any conversions occur.

Examples of these methods will appear shortly.

39.7.3 Typemap variables

Within typemap code, a number of special variables prefaced with a $ may appear. A full list of variables can be found in the " Typemaps" chapter. This is a list of the most common variables:

$1

A C local variable corresponding to the actual type specified in the %typemap directive. For input values, this is a C local variable that's supposed to hold an argument value. For output values, this is the raw result that's supposed to be returned to Tcl.

$input

A Tcl_Obj * holding a raw Tcl object with an argument or variable value.

$result

A Tcl_Obj * that holds the result to be returned to Tcl.

$1_name

The parameter name that was matched.

$1_type

The actual C datatype matched by the typemap.

$1_ltype

An assignable version of the datatype matched by the typemap (a type that can appear on the left-hand-side of a C assignment operation). This type is stripped of qualifiers and may be an altered version of $1_type. All arguments and local variables in wrapper functions are declared using this type so that their values can be properly assigned.

$symname

The Tcl name of the wrapper function being created.

39.7.4 Converting a Tcl list to a char **

A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Tcl list to be used as a char ** object.

%module argv

// This tells SWIG to treat char ** as a special case
%typemap(in) char ** {
     Tcl_Obj **listobjv;
     int       nitems;
     int       i;
     if (Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) {
        return TCL_ERROR;
     }
     $1 = (char **) malloc((nitems+1)*sizeof(char *));
     for (i = 0; i < nitems; i++) {
        $1[i] = Tcl_GetStringFromObj(listobjv[i],0);
     }
     $1[i] = 0;
}

// This gives SWIG some cleanup code that will get called after the function call
%typemap(freearg) char ** {
     if ($1) {
        free($1);
     }
}

// Now a test functions
%inline %{
int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
         printf("argv[%d] = %s\n", i,argv[i]);
         i++;
    }
    return i;
}
%}
%include "tclsh.i"

In Tcl:

% print_args {John Guido Larry}
argv[0] = John
argv[1] = Guido
argv[2] = Larry
3

39.7.5 Returning values in arguments

The "argout" typemap can be used to return a value originating from a function argument. For example :

// A typemap defining how to return an argument by appending it to the result
%typemap(argout) double *outvalue {
     Tcl_Obj *o = Tcl_NewDoubleObj($1);
     Tcl_ListObjAppendElement(interp,$result,o);
}

// A typemap telling SWIG to ignore an argument for input
// However, we still need to pass a pointer to the C function
%typemap(in,numinputs=0) double *outvalue (double temp) {
     $1 = &temp;
}

// Now a function returning two values
int mypow(double a, double b, double *outvalue) {
        if ((a < 0) || (b < 0)) return -1;
        *outvalue = pow(a,b);
        return 0;
};

When wrapped, SWIG matches the argout typemap to the " double *outvalue" argument. The numinputs=0 specification tells SWIG to simply ignore this argument when generating wrapper code. As a result, a Tcl function using these typemaps will work like this :

% mypow 2 3     # Returns two values, a status value and the result
0 8
%

39.7.6 Useful functions

The following tables provide some functions that may be useful in writing Tcl typemaps.

Integers

Tcl_Obj   *Tcl_NewIntObj(int Value);
void       Tcl_SetIntObj(Tcl_Obj *obj, int Value);
int        Tcl_GetIntFromObj(Tcl_Interp *, Tcl_Obj *obj, int *ip);

Floating Point

Tcl_Obj  *Tcl_NewDoubleObj(double Value);
void      Tcl_SetDoubleObj(Tcl_Obj *obj, double value);
int       Tcl_GetDoubleFromObj(Tcl_Interp *, Tcl_Obj *o, double *dp);

Strings

Tcl_Obj  *Tcl_NewStringObj(char *str, int len);
void      Tcl_SetStringObj(Tcl_Obj *obj, char *str, int len);
char     *Tcl_GetStringFromObj(Tcl_Obj *obj, int *len);
void      Tcl_AppendToObj(Tcl_Obj *obj, char *str, int len);

Lists

Tcl_Obj  *Tcl_NewListObj(int objc, Tcl_Obj *objv);
int       Tcl_ListObjAppendList(Tcl_Interp *, Tcl_Obj *listPtr, Tcl_Obj *elemListPtr);
int       Tcl_ListObjAppendElement(Tcl_Interp *, Tcl_Obj *listPtr, Tcl_Obj *element);
int       Tcl_ListObjGetElements(Tcl_Interp *, Tcl_Obj *listPtr, int *objcPtr,
                                 Tcl_Obj ***objvPtr);
int       Tcl_ListObjLength(Tcl_Interp *, Tcl_Obj *listPtr, int *intPtr);
int       Tcl_ListObjIndex(Tcl_Interp *, Tcl_Obj *listPtr, int index,
                           Tcl_Obj_Obj **objptr);
int       Tcl_ListObjReplace(Tcl_Interp *, Tcl_Obj *listPtr, int first, int count,
                             int objc, Tcl_Obj *objv);

Objects

Tcl_Obj *Tcl_DuplicateObj(Tcl_Obj *obj);
void     Tcl_IncrRefCount(Tcl_Obj *obj);
void     Tcl_DecrRefCount(Tcl_Obj *obj);
int      Tcl_IsShared(Tcl_Obj *obj);

39.7.7 Standard typemaps

The following typemaps show how to convert a few common kinds of objects between Tcl and C (and to give a better idea of how typemaps work)

Integer conversion

%typemap(in) int, short, long {
   int temp;
   if (Tcl_GetIntFromObj(interp, $input, &temp) == TCL_ERROR)
      return TCL_ERROR;
   $1 = ($1_ltype) temp;
}

%typemap(out) int, short, long {
   Tcl_SetIntObj($result,(int) $1);
}

Floating point conversion

%typemap(in) float, double {
   double temp;
   if (Tcl_GetDoubleFromObj(interp, $input, &temp) == TCL_ERROR)
       return TCL_ERROR;
   $1 = ($1_ltype) temp;
}

%typemap(out) float, double {
   Tcl_SetDoubleObj($result, $1);
}

String Conversion

%typemap(in) char * {
   int len;
   $1 = Tcl_GetStringFromObj(interp, &len);
   }
}

%typemap(out) char * {
   Tcl_SetStringObj($result,$1);
}

39.7.8 Pointer handling

SWIG pointers are mapped into Tcl strings containing the hexadecimal value and type. The following functions can be used to create and read pointer values.

int SWIG_ConvertPtr(Tcl_Obj *obj, void **ptr, swig_type_info *ty, int flags)

Converts a Tcl object obj to a C pointer. The result of the conversion is placed into the pointer located at ptr. ty is a SWIG type descriptor structure. flags is used to handle error checking and other aspects of conversion. It is currently reserved for future expansion. Returns 0 on success and -1 on error.

Tcl_Obj *SWIG_NewPointerObj(void *ptr, swig_type_info *ty, int flags)

Creates a new Tcl pointer object. ptr is the pointer to convert, ty is the SWIG type descriptor structure that describes the type, and own is a flag reserved for future expansion.

Both of these functions require the use of a special SWIG type-descriptor structure. This structure contains information about the mangled name of the datatype, type-equivalence information, as well as information about converting pointer values under C++ inheritance. For a type of Foo *, the type descriptor structure is usually accessed as follows:

Foo *f;
if (SWIG_ConvertPtr($input, (void **) &f, SWIGTYPE_p_Foo, 0) == -1) return NULL;

Tcl_Obj *;
obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);

In a typemap, the type descriptor should always be accessed using the special typemap variable $1_descriptor. For example:

%typemap(in) Foo * {
   if ((SWIG_ConvertPtr($input,(void **) &$1, $1_descriptor,0)) == -1) return NULL;
}

If necessary, the descriptor for any type can be obtained using the $descriptor() macro in a typemap. For example:

%typemap(in) Foo * {
   if ((SWIG_ConvertPtr($input,(void **) &$1, $descriptor(Foo *), 0)) == -1) return NULL;
}

39.8 Turning a SWIG module into a Tcl Package.

Tcl 7.4 introduced the idea of an extension package. By default, SWIG generates all of the code necessary to create a package. To set the package version, simply use the -pkgversion option. For example:

% swig -tcl -pkgversion 2.3 example.i

After building the SWIG generated module, you need to execute the " pkg_mkIndex" command inside tclsh. For example :

unix > tclsh
% pkg_mkIndex . example.so
% exit

This creates a file "pkgIndex.tcl" with information about the package. To use your package, you now need to move it to its own subdirectory which has the same name as the package. For example :

./example/
	   pkgIndex.tcl           # The file created by pkg_mkIndex
	   example.so             # The SWIG generated module

Finally, assuming that you're not entirely confused at this point, make sure that the example subdirectory is visible from the directories contained in either the tcl_library or auto_path variables. At this point you're ready to use the package as follows :

unix > tclsh
% package require example
% fact 4
24
%

If you're working with an example in the current directory and this doesn't work, do this instead :

unix > tclsh
% lappend auto_path .
% package require example
% fact 4
24

As a final note, most SWIG examples do not yet use the package commands. For simple extensions it may be easier just to use the load command instead.

39.9 Building new kinds of Tcl interfaces (in Tcl)

One of the most interesting aspects of Tcl and SWIG is that you can create entirely new kinds of Tcl interfaces in Tcl using the low-level SWIG accessor functions. For example, suppose you had a library of helper functions to access arrays :

/* File : array.i */
%module array

%inline %{
double *new_double(int size) {
        return (double *) malloc(size*sizeof(double));
}
void delete_double(double *a) {
        free(a);
}
double get_double(double *a, int index) {
        return a[index];
}
void set_double(double *a, int index, double val) {
        a[index] = val;
}
int *new_int(int size) {
        return (int *) malloc(size*sizeof(int));
}
void delete_int(int *a) {
        free(a);
}
int get_int(int *a, int index) {
        return a[index];
}
int set_int(int *a, int index, int val) {
        a[index] = val;
}
%}

While these could be called directly, we could also write a Tcl script like this :

proc Array {type size} {
    set ptr [new_$type $size]
    set code {
        set method [lindex $args 0]
        set parms [concat $ptr [lrange $args 1 end]]
        switch $method {
            get {return [eval "get_$type $parms"]}
            set {return [eval "set_$type $parms"]}
            delete {eval "delete_$type $ptr; rename $ptr {}"}
        }
    }
    # Create a procedure
    uplevel "proc $ptr args {set ptr $ptr; set type $type;$code}"
    return $ptr
}

Our script allows easy array access as follows :

set a [Array double 100]                   ;# Create a double [100]
for {set i 0} {$i < 100} {incr i 1} {      ;# Clear the array
	$a set $i 0.0
}
$a set 3 3.1455                            ;# Set an individual element
set b [$a get 10]                          ;# Retrieve an element

set ia [Array int 50]                      ;# Create an int[50]
for {set i 0} {$i < 50} {incr i 1} {       ;# Clear it
	$ia set $i 0
}
$ia set 3 7                                ;# Set an individual element
set ib [$ia get 10]                        ;# Get an individual element

$a delete                                  ;# Destroy a
$ia delete                                 ;# Destroy ia

The cool thing about this approach is that it makes a common interface for two different types of arrays. In fact, if we were to add more C datatypes to our wrapper file, the Tcl code would work with those as well--without modification. If an unsupported datatype was requested, the Tcl code would simply return with an error so there is very little danger of blowing something up (although it is easily accomplished with an out of bounds array access).

39.9.1 Proxy classes

A similar approach can be applied to proxy classes (also known as shadow classes). The following example is provided by Erik Bierwagen and Paul Saxe. To use it, run SWIG with the -noobject option (which disables the builtin object oriented interface). When running Tcl, simply source this file. Now, objects can be used in a more or less natural fashion.

# swig_c++.tcl
# Provides a simple object oriented interface using
# SWIG's low level interface.
#

proc new {objectType handle_r args} {
    # Creates a new SWIG object of the given type,
    # returning a handle in the variable "handle_r".
    #
    # Also creates a procedure for the object and a trace on
    # the handle variable that deletes the object when the
    # handle variable is overwritten or unset
    upvar $handle_r handle
    #
    # Create the new object
    #
    eval set handle \[new_$objectType $args\]
    #
    # Set up the object procedure
    #
    proc $handle {cmd args} "eval ${objectType}_\$cmd $handle \$args"
    #
    # And the trace ...
    #
    uplevel trace variable $handle_r uw "{deleteObject $objectType $handle}"
    #
    # Return the handle so that 'new' can be used as an argument to a procedure
    #
    return $handle
}

proc deleteObject {objectType handle name element op} {
    #
    # Check that the object handle has a reasonable form
    #
    if {![regexp {_[0-9a-f]*_(.+)_p} $handle]} {
        error "deleteObject: not a valid object handle: $handle"
    }
    #
    # Remove the object procedure
    #
    catch {rename $handle {}}
    #
    # Delete the object
    #
    delete_$objectType $handle
}

proc delete {handle_r} {
    #
    # A synonym for unset that is more familiar to C++ programmers
    #
    uplevel unset $handle_r
}

To use this file, we simply source it and execute commands such as "new" and "delete" to manipulate objects. For example :

// list.i
%module List
%{
#include "list.h"
%}

// Very simple C++ example

class List {
public:
  List();  // Create a new list
  ~List(); // Destroy a list
  int  search(char *value);
  void insert(char *);  // Insert a new item into the list
  void remove(char *);  // Remove item from list
  char *get(int n);     // Get the nth item in the list
  int  length;          // The current length of the list
static void print(List *l);  // Print out the contents of the list
};

Now a Tcl script using the interface...

load ./list.so list       ; # Load the module
source swig_c++.tcl       ; # Source the object file

new List l
$l insert Dave
$l insert John
$l insert Guido
$l remove Dave
puts $l length_get

delete l

The cool thing about this example is that it works with any C++ object wrapped by SWIG and requires no special compilation. Proof that a short, but clever Tcl script can be combined with SWIG to do many interesting things.

39.10 Tcl/Tk Stubs

For background information about the Tcl Stubs feature, see http://www.tcl.tk/doc/howto/stubs.html.

As of SWIG 1.3.10, the generated C/C++ wrapper will use the Tcl Stubs feature if compiled with -DUSE_TCL_STUBS.

As of SWIG 1.3.40, the generated C/C++ wrapper will use the Tk Stubs feature if compiled with -DUSE_TK_STUBS. Also, you can override the minimum version to support which is passed to Tcl_InitStubs() and Tk_InitStubs() with -DSWIG_TCL_STUBS_VERSION="8.3" or the version being compiled with using -DSWIG_TCL_STUBS_VERSION=TCL_VERSION.


40 Extending SWIG to support new languages

40.1 Introduction

This chapter describes SWIG's internal organization and the process by which new target languages can be developed. First, a brief word of warning---SWIG is continually evolving. The information in this chapter is mostly up to date, but changes are ongoing. Expect a few inconsistencies.

Also, this chapter is not meant to be a hand-holding tutorial. As a starting point, you should probably look at one of SWIG's existing modules.

40.2 Prerequisites

In order to extend SWIG, it is useful to have the following background:

  • An understanding of the C API for the target language.
  • A good grasp of the C++ type system.
  • An understanding of typemaps and some of SWIG's advanced features.
  • Some familiarity with writing C++ (language modules are currently written in C++).

Since SWIG is essentially a specialized C++ compiler, it may be useful to have some prior experience with compiler design (perhaps even a compilers course) to better understand certain parts of the system. A number of books will also be useful. For example, "The C Programming Language" by Kernighan and Ritchie (a.k.a, "K&R") and the C++ standard, "ISO/IEC 14882 Programming Languages - C++" will be of great use.

Also, it is useful to keep in mind that SWIG primarily operates as an extension of the C++ type system. At first glance, this might not be obvious, but almost all SWIG directives as well as the low-level generation of wrapper code are driven by C++ datatypes.

40.3 The Big Picture

SWIG is a special purpose compiler that parses C++ declarations to generate wrapper code. To make this conversion possible, SWIG makes three fundamental extensions to the C++ language:

  • Typemaps. Typemaps are used to define the conversion/marshalling behavior of specific C++ datatypes. All type conversion in SWIG is based on typemaps. Furthermore, the association of typemaps to datatypes utilizes an advanced pattern matching mechanism that is fully integrated with the C++ type system.
  • Declaration Annotation. To customize wrapper code generation, most declarations can be annotated with special features. For example, you can make a variable read-only, you can ignore a declaration, you can rename a member function, you can add exception handling, and so forth. Virtually all of these customizations are built on top of a low-level declaration annotator that can attach arbitrary attributes to any declaration. Code generation modules can look for these attributes to guide the wrapping process.
  • Class extension. SWIG allows classes and structures to be extended with new methods and attributes (the %extend directive). This has the effect of altering the API in the target language and can be used to generate OO interfaces to C libraries.

It is important to emphasize that virtually all SWIG features reduce to one of these three fundamental concepts. The type system and pattern matching rules also play a critical role in making the system work. For example, both typemaps and declaration annotation are based on pattern matching and interact heavily with the underlying type system.

40.4 Execution Model

When you run SWIG on an interface, processing is handled in stages by a series of system components:

  • An integrated C preprocessor reads a collection of configuration files and the specified interface file into memory. The preprocessor performs the usual functions including macro expansion and file inclusion. However, the preprocessor also performs some transformations of the interface. For instance, #define statements are sometimes transformed into %constant declarations. In addition, information related to file/line number tracking is inserted.
  • A C/C++ parser reads the preprocessed input and generates a full parse tree of all of the SWIG directives and C declarations found. The parser is responsible for many aspects of the system including renaming, declaration annotation, and template expansion. However, the parser does not produce any output nor does it interact with the target language module as it runs. SWIG is not a one-pass compiler.
  • A type-checking pass is made. This adjusts all of the C++ typenames to properly handle namespaces, typedefs, nested classes, and other issues related to type scoping.
  • A semantic pass is made on the parse tree to collect information related to properties of the C++ interface. For example, this pass would determine whether or not a class allows a default constructor.
  • A code generation pass is made using a specific target language module. This phase is responsible for generating the actual wrapper code. All of SWIG's user-defined modules are invoked during this latter stage of compilation.

The next few sections briefly describe some of these stages.

40.4.1 Preprocessing

The preprocessor plays a critical role in the SWIG implementation. This is because a lot of SWIG's processing and internal configuration is managed not by code written in C, but by configuration files in the SWIG library. In fact, when you run SWIG, parsing starts with a small interface file like this (note: this explains the cryptic error messages that new users sometimes get when SWIG is misconfigured or installed incorrectly):

%include "swig.swg"             // Global SWIG configuration
%include "langconfig.swg"       // Language specific configuration
%include "yourinterface.i"      // Your interface file

The swig.swg file contains global configuration information. In addition, this file defines many of SWIG's standard directives as macros. For instance, part of of swig.swg looks like this:

...
/* Code insertion directives such as %wrapper %{ ... %} */

#define %begin       %insert("begin")
#define %runtime     %insert("runtime")
#define %header      %insert("header")
#define %wrapper     %insert("wrapper")
#define %init        %insert("init")

/* Access control directives */

#define %immutable   %feature("immutable","1")
#define %mutable     %feature("immutable")

/* Directives for callback functions */

#define %callback(x) %feature("callback") `x`;
#define %nocallback  %feature("callback");

/* %ignore directive */

#define %ignore         %rename($ignore)
#define %ignorewarn(x)  %rename("$ignore:" x)
...

The fact that most of the standard SWIG directives are macros is intended to simplify the implementation of the internals. For instance, rather than having to support dozens of special directives, it is easier to have a few basic primitives such as %feature or %insert.

The langconfig.swg file is supplied by the target language. This file contains language-specific configuration information. More often than not, this file provides run-time wrapper support code (e.g., the type-checker) as well as a collection of typemaps that define the default wrapping behavior. Note: the name of this file depends on the target language and is usually something like python.swg or perl5.swg.

As a debugging aide, the text that SWIG feeds to its C++ parser can be obtained by running swig -E interface.i. This output probably isn't too useful in general, but it will show how macros have been expanded as well as everything else that goes into the low-level construction of the wrapper code.

40.4.2 Parsing

The current C++ parser handles a subset of C++. Most incompatibilities with C are due to subtle aspects of how SWIG parses declarations. Specifically, SWIG expects all C/C++ declarations to follow this general form:

storage type declarator initializer;

storage is a keyword such as extern, static, typedef, or virtual. type is a primitive datatype such as int or void. type may be optionally qualified with a qualifier such as const or volatile. declarator is a name with additional type-construction modifiers attached to it (pointers, arrays, references, functions, etc.). Examples of declarators include *x, **x, x[20], and (*x)(int,double). The initializer may be a value assigned using = or body of code enclosed in braces { ... }.

This declaration format covers most common C++ declarations. However, the C++ standard is somewhat more flexible in the placement of the parts. For example, it is technically legal, although uncommon to write something like int typedef const a in your program. SWIG simply doesn't bother to deal with this case.

The other significant difference between C++ and SWIG is in the treatment of typenames. In C++, if you have a declaration like this,

int blah(Foo *x, Bar *y);

it won't parse correctly unless Foo and Bar have been previously defined as types either using a class definition or a typedef. The reasons for this are subtle, but this treatment of typenames is normally integrated at the level of the C tokenizer---when a typename appears, a different token is returned to the parser instead of an identifier.

SWIG does not operate in this manner--any legal identifier can be used as a type name. The reason for this is primarily motivated by the use of SWIG with partially defined data. Specifically, SWIG is supposed to be easy to use on interfaces with missing type information.

Because of the different treatment of typenames, the most serious limitation of the SWIG parser is that it can't process type declarations where an extra (and unnecessary) grouping operator is used. For example:

int (x);         /* A variable x */
int (y)(int);    /* A function y */

The placing of extra parentheses in type declarations like this is already recognized by the C++ community as a potential source of strange programming errors. For example, Scott Meyers "Effective STL" discusses this problem in a section on avoiding C++'s "most vexing parse."

The parser is also unable to handle declarations with no return type or bare argument names. For example, in an old C program, you might see things like this:

foo(a,b) {
...
}

In this case, the return type as well as the types of the arguments are taken by the C compiler to be an int. However, SWIG interprets the above code as an abstract declarator for a function returning a foo and taking types a and b as arguments).

40.4.3 Parse Trees

The SWIG parser produces a complete parse tree of the input file before any wrapper code is actually generated. Each item in the tree is known as a "Node". Each node is identified by a symbolic tag. Furthermore, a node may have an arbitrary number of children. The parse tree structure and tag names of an interface can be displayed using swig -debug-tags. For example:

$ swig -c++ -python -debug-tags example.i
 . top (example.i:1)
 . top . include (example.i:1)
 . top . include . typemap (/r0/beazley/Projects/lib/swig1.3/swig.swg:71)
 . top . include . typemap . typemapitem (/r0/beazley/Projects/lib/swig1.3/swig.swg:71)
 . top . include . typemap (/r0/beazley/Projects/lib/swig1.3/swig.swg:83)
 . top . include . typemap . typemapitem (/r0/beazley/Projects/lib/swig1.3/swig.swg:83)
 . top . include (example.i:4)
 . top . include . insert (/r0/beazley/Projects/lib/swig1.3/python/python.swg:7)
 . top . include . insert (/r0/beazley/Projects/lib/swig1.3/python/python.swg:8)
 . top . include . typemap (/r0/beazley/Projects/lib/swig1.3/python/python.swg:19)
...
 . top . include (example.i:6)
 . top . include . module (example.i:2)
 . top . include . insert (example.i:6)
 . top . include . include (example.i:9)
 . top . include . include . class (example.h:3)
 . top . include . include . class . access (example.h:4)
 . top . include . include . class . constructor (example.h:7)
 . top . include . include . class . destructor (example.h:10)
 . top . include . include . class . cdecl (example.h:11)
 . top . include . include . class . cdecl (example.h:11)
 . top . include . include . class . cdecl (example.h:12)
 . top . include . include . class . cdecl (example.h:13)
 . top . include . include . class . cdecl (example.h:14)
 . top . include . include . class . cdecl (example.h:15)
 . top . include . include . class (example.h:18)
 . top . include . include . class . access (example.h:19)
 . top . include . include . class . cdecl (example.h:20)
 . top . include . include . class . access (example.h:21)
 . top . include . include . class . constructor (example.h:22)
 . top . include . include . class . cdecl (example.h:23)
 . top . include . include . class . cdecl (example.h:24)
 . top . include . include . class (example.h:27)
 . top . include . include . class . access (example.h:28)
 . top . include . include . class . cdecl (example.h:29)
 . top . include . include . class . access (example.h:30)
 . top . include . include . class . constructor (example.h:31)
 . top . include . include . class . cdecl (example.h:32)
 . top . include . include . class . cdecl (example.h:33)

Even for the most simple interface, the parse tree structure is larger than you might expect. For example, in the above output, a substantial number of nodes are actually generated by the python.swg configuration file which defines typemaps and other directives. The contents of the user-supplied input file don't appear until the end of the output.

The contents of each parse tree node consist of a collection of attribute/value pairs. Internally, the nodes are simply represented by hash tables. A display of the entire parse-tree structure can be obtained using swig -debug-top <n>, where n is the stage being processed. There are a number of other parse tree display options, for example, swig -debug-module <n> will avoid displaying system parse information and only display the parse tree pertaining to the user's module at stage n of processing.

$ swig -c++ -python -debug-module 4 example.i
      +++ include ----------------------------------------
      | name         - "example.i"

            +++ module ----------------------------------------
            | name         - "example"
            |
            +++ insert ----------------------------------------
            | code         - "\n#include \"example.h\"\n"
            |
            +++ include ----------------------------------------
            | name         - "example.h"

                  +++ class ----------------------------------------
                  | abstract     - "1"
                  | sym:name     - "Shape"
                  | name         - "Shape"
                  | kind         - "class"
                  | symtab       - 0x40194140
                  | sym:symtab   - 0x40191078

                        +++ access ----------------------------------------
                        | kind         - "public"
                        |
                        +++ constructor ----------------------------------------
                        | sym:name     - "Shape"
                        | name         - "Shape"
                        | decl         - "f()."
                        | code         - "{\n    nshapes++;\n  }"
                        | sym:symtab   - 0x40194140
                        |
                        +++ destructor ----------------------------------------
                        | sym:name     - "~Shape"
                        | name         - "~Shape"
                        | storage      - "virtual"
                        | code         - "{\n    nshapes--;\n  }"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "x"
                        | name         - "x"
                        | decl         - ""
                        | type         - "double"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "y"
                        | name         - "y"
                        | decl         - ""
                        | type         - "double"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "move"
                        | name         - "move"
                        | decl         - "f(double,double)."
                        | parms        - double ,double
                        | type         - "void"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "area"
                        | name         - "area"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | value        - "0"
                        | type         - "double"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "perimeter"
                        | name         - "perimeter"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | value        - "0"
                        | type         - "double"
                        | sym:symtab   - 0x40194140
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "nshapes"
                        | name         - "nshapes"
                        | decl         - ""
                        | storage      - "static"
                        | type         - "int"
                        | sym:symtab   - 0x40194140
                        |
                  +++ class ----------------------------------------
                  | sym:name     - "Circle"
                  | name         - "Circle"
                  | kind         - "class"
                  | bases        - 0x40194510
                  | symtab       - 0x40194538
                  | sym:symtab   - 0x40191078

                        +++ access ----------------------------------------
                        | kind         - "private"
                        |
                        +++ cdecl ----------------------------------------
                        | name         - "radius"
                        | decl         - ""
                        | type         - "double"
                        |
                        +++ access ----------------------------------------
                        | kind         - "public"
                        |
                        +++ constructor ----------------------------------------
                        | sym:name     - "Circle"
                        | name         - "Circle"
                        | parms        - double
                        | decl         - "f(double)."
                        | code         - "{ }"
                        | sym:symtab   - 0x40194538
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "area"
                        | name         - "area"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | type         - "double"
                        | sym:symtab   - 0x40194538
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "perimeter"
                        | name         - "perimeter"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | type         - "double"
                        | sym:symtab   - 0x40194538
                        |
                  +++ class ----------------------------------------
                  | sym:name     - "Square"
                  | name         - "Square"
                  | kind         - "class"
                  | bases        - 0x40194760
                  | symtab       - 0x40194788
                  | sym:symtab   - 0x40191078

                        +++ access ----------------------------------------
                        | kind         - "private"
                        |
                        +++ cdecl ----------------------------------------
                        | name         - "width"
                        | decl         - ""
                        | type         - "double"
                        |
                        +++ access ----------------------------------------
                        | kind         - "public"
                        |
                        +++ constructor ----------------------------------------
                        | sym:name     - "Square"
                        | name         - "Square"
                        | parms        - double
                        | decl         - "f(double)."
                        | code         - "{ }"
                        | sym:symtab   - 0x40194788
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "area"
                        | name         - "area"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | type         - "double"
                        | sym:symtab   - 0x40194788
                        |
                        +++ cdecl ----------------------------------------
                        | sym:name     - "perimeter"
                        | name         - "perimeter"
                        | decl         - "f(void)."
                        | parms        - void
                        | storage      - "virtual"
                        | type         - "double"
                        | sym:symtab   - 0x40194788

40.4.4 Attribute namespaces

Attributes of parse tree nodes are often prepended with a namespace qualifier. For example, the attributes sym:name and sym:symtab are attributes related to symbol table management and are prefixed with sym:. As a general rule, only those attributes which are directly related to the raw declaration appear without a prefix (type, name, declarator, etc.).

Target language modules may add additional attributes to nodes to assist the generation of wrapper code. The convention for doing this is to place these attributes in a namespace that matches the name of the target language. For example, python:foo or perl:foo.

40.4.5 Symbol Tables

During parsing, all symbols are managed in the space of the target language. The sym:name attribute of each node contains the symbol name selected by the parser. Normally, sym:name and name are the same. However, the %rename directive can be used to change the value of sym:name. You can see the effect of %rename by trying it on a simple interface and dumping the parse tree. For example:

%rename(foo_i) foo(int);
%rename(foo_d) foo(double);

void foo(int);
void foo(double);
void foo(Bar *b);

There are various debug- options that can be useful for debugging and analysing the parse tree. For example, the debug-top <n> or debug-module <n> options will dump the entire/top of the parse tree or the module subtree at one of the four n stages of processing. The parse tree can be viewed after the final stage of processing by running SWIG:

$ swig -debug-top 4 example.i
...
            +++ cdecl ----------------------------------------
            | sym:name     - "foo_i"
            | name         - "foo"
            | decl         - "f(int)."
            | parms        - int
            | type         - "void"
            | sym:symtab   - 0x40165078
            |
            +++ cdecl ----------------------------------------
            | sym:name     - "foo_d"
            | name         - "foo"
            | decl         - "f(double)."
            | parms        - double
            | type         - "void"
            | sym:symtab   - 0x40165078
            |
            +++ cdecl ----------------------------------------
            | sym:name     - "foo"
            | name         - "foo"
            | decl         - "f(p.Bar)."
            | parms        - Bar *
            | type         - "void"
            | sym:symtab   - 0x40165078

All symbol-related conflicts and complaints about overloading are based on sym:name values. For instance, the following example uses %rename in reverse to generate a name clash.

%rename(foo) foo_i(int);
%rename(foo) foo_d(double;

void foo_i(int);
void foo_d(double);
void foo(Bar *b);

When you run SWIG on this you now get:

$ ./swig example.i
example.i:6. Overloaded declaration ignored.  foo_d(double )
example.i:5. Previous declaration is foo_i(int )
example.i:7. Overloaded declaration ignored.  foo(Bar *)
example.i:5. Previous declaration is foo_i(int )

40.4.6 The %feature directive

A number of SWIG directives such as %exception are implemented using the low-level %feature directive. For example:

%feature("except") getitem(int) {
  try {
     $action
  } catch (badindex) {
     ...
  }
}

...
class Foo {
public:
    Object *getitem(int index) throws(badindex);
    ...
};

The behavior of %feature is very easy to describe--it simply attaches a new attribute to any parse tree node that matches the given prototype. When a feature is added, it shows up as an attribute in the feature: namespace. You can see this when running with the -debug-top 4 option. For example:

 +++ cdecl ----------------------------------------
 | sym:name     - "getitem"
 | name         - "getitem"
 | decl         - "f(int).p."
 | parms        - int
 | type         - "Object"
 | feature:except - "{\n    try {\n       $action\n    } catc..."
 | sym:symtab   - 0x40168ac8
 |

Feature names are completely arbitrary and a target language module can be programmed to respond to any feature name that it wants to recognize. The data stored in a feature attribute is usually just a raw unparsed string. For example, the exception code above is simply stored without any modifications.

40.4.7 Code Generation

Language modules work by defining handler functions that know how to respond to different types of parse-tree nodes. These handlers simply look at the attributes of each node in order to produce low-level code.

In reality, the generation of code is somewhat more subtle than simply invoking handler functions. This is because parse-tree nodes might be transformed. For example, suppose you are wrapping a class like this:

class Foo {
public:
    virtual int *bar(int x);
};

When the parser constructs a node for the member bar, it creates a raw "cdecl" node with the following attributes:

nodeType    : cdecl
name        : bar
type        : int
decl        : f(int).p
parms       : int x
storage     : virtual
sym:name    : bar

To produce wrapper code, this "cdecl" node undergoes a number of transformations. First, the node is recognized as a function declaration. This adjusts some of the type information--specifically, the declarator is joined with the base datatype to produce this:

nodeType    : cdecl
name        : bar
type        : p.int        <-- Notice change in return type
decl        : f(int).p
parms       : int x
storage     : virtual
sym:name    : bar

Next, the context of the node indicates that the node is really a member function. This produces a transformation to a low-level accessor function like this:

nodeType    : cdecl
name        : bar
type        : int.p
decl        : f(int).p
parms       : Foo *self, int x            <-- Added parameter
storage     : virtual
wrap:action : result = (arg1)->bar(arg2)  <-- Action code added
sym:name    : Foo_bar                     <-- Symbol name changed

In this transformation, notice how an additional parameter was added to the parameter list and how the symbol name of the node has suddenly changed into an accessor using the naming scheme described in the "SWIG Basics" chapter. A small fragment of "action" code has also been generated--notice how the wrap:action attribute defines the access to the underlying method. The data in this transformed node is then used to generate a wrapper.

Language modules work by registering handler functions for dealing with various types of nodes at different stages of transformation. This is done by inheriting from a special Language class and defining a collection of virtual methods. For example, the Python module defines a class as follows:

class PYTHON : public Language {
protected:
public :
  virtual void main(int, char *argv[]);
  virtual int  top(Node *);
  virtual int  functionWrapper(Node *);
  virtual int  constantWrapper(Node *);
  virtual int  variableWrapper(Node *);
  virtual int  nativeWrapper(Node *);
  virtual int  membervariableHandler(Node *);
  virtual int  memberconstantHandler(Node *);
  virtual int  memberfunctionHandler(Node *);
  virtual int  constructorHandler(Node *);
  virtual int  destructorHandler(Node *);
  virtual int  classHandler(Node *);
  virtual int  classforwardDeclaration(Node *);
  virtual int  insertDirective(Node *);
  virtual int  importDirective(Node *);
};

The role of these functions is described shortly.

40.4.8 SWIG and XML

Much of SWIG's current parser design was originally motivated by interest in using XML to represent SWIG parse trees. Although XML is not currently used in any direct manner, the parse tree structure, use of node tags, attributes, and attribute namespaces are all influenced by aspects of XML parsing. Therefore, in trying to understand SWIG's internal data structures, it may be useful to keep XML in the back of your mind as a model.

40.5 Primitive Data Structures

Most of SWIG is constructed using three basic data structures: strings, hashes, and lists. These data structures are dynamic in same way as similar structures found in many scripting languages. For instance, you can have containers (lists and hash tables) of mixed types and certain operations are polymorphic.

This section briefly describes the basic structures so that later sections of this chapter make more sense.

When describing the low-level API, the following type name conventions are used:

  • String. A string object.
  • Hash. A hash object.
  • List. A list object.
  • String_or_char. A string object or a char *.
  • Object_or_char. An object or a char *.
  • Object. Any object (string, hash, list, etc.)

In most cases, other typenames in the source are aliases for one of these primitive types. Specifically:

typedef String SwigType;
typedef Hash   Parm;
typedef Hash   ParmList;
typedef Hash   Node;
typedef Hash   Symtab;
typedef Hash   Typetab;

40.5.1 Strings

String *NewString(const String_or_char *val)

Creates a new string with initial value val . val may be a char * or another String object. If you want to create an empty string, use "" for val.

String *NewStringf(const char *fmt, ...)

Creates a new string whose initial value is set according to a C printf style format string in fmt. Additional arguments follow depending on fmt.

String *Copy(String *s)

Make a copy of the string s.

void Delete(String *s)

Deletes s.

int Len(const String_or_char *s)

Returns the length of the string.

char *Char(const String_or_char *s)

Returns a pointer to the first character in a string.

void Append(String *s, const String_or_char *t)

Appends t to the end of string s.

void Insert(String *s, int pos, const String_or_char *t)

Inserts t into s at position pos. The contents of s are shifted accordingly. The special value DOH_END can be used for pos to indicate insertion at the end of the string (appending).

int Strcmp(const String_or_char *s, const String_or_char *t)

Compare strings s and t. Same as the C strcmp() function.

int Strncmp(const String_or_char *s, const String_or_char *t, int len)

Compare the first len characters of strings s and t. Same as the C strncmp() function.

char *Strstr(const String_or_char *s, const String_or_char *pat)

Returns a pointer to the first occurrence of pat in s. Same as the C strstr() function.

char *Strchr(const String_or_char *s, char ch)

Returns a pointer to the first occurrence of character ch in s. Same as the C strchr() function.

void Chop(String *s)

Chops trailing whitespace off the end of s .

int Replace(String *s, const String_or_char *pat, const String_or_char *rep, int flags)

Replaces the pattern pat with rep in string s . flags is a combination of the following flags:

DOH_REPLACE_ANY       - Replace all occurrences
DOH_REPLACE_ID        - Valid C identifiers only
DOH_REPLACE_NOQUOTE   - Don't replace in quoted strings
DOH_REPLACE_FIRST     - Replace first occurrence only.

Returns the number of replacements made (if any).

40.5.2 Hashes

Hash *NewHash()

Creates a new empty hash table.

Hash *Copy(Hash *h)

Make a shallow copy of the hash h.

void Delete(Hash *h)

Deletes h.

int Len(Hash *h)

Returns the number of items in h.

Object *Getattr(Hash *h, const String_or_char *key)

Gets an object from h. key may be a string or a simple char * string. Returns NULL if not found.

int Setattr(Hash *h, const String_or_char *key, const Object_or_char *val)

Stores val in h. key may be a string or a simple char *. If val is not a standard object (String, Hash, or List) it is assumed to be a char * in which case it is used to construct a String that is stored in the hash. If val is NULL, the object is deleted. Increases the reference count of val. Returns 1 if this operation replaced an existing hash entry, 0 otherwise.

int Delattr(Hash *h, const String_or_char *key)

Deletes the hash item referenced by key. Decreases the reference count on the corresponding object (if any). Returns 1 if an object was removed, 0 otherwise.

List *Keys(Hash *h)

Returns the list of hash table keys.

40.5.3 Lists

List *NewList()

Creates a new empty list.

List *Copy(List *x)

Make a shallow copy of the List x.

void Delete(List *x)

Deletes x.

int Len(List *x)

Returns the number of items in x.

Object *Getitem(List *x, int n)

Returns an object from x with index n . If n is beyond the end of the list, the last item is returned. If n is negative, the first item is returned.

int *Setitem(List *x, int n, const Object_or_char *val)

Stores val in x. If val is not a standard object (String, Hash, or List) it is assumed to be a char * in which case it is used to construct a String that is stored in the list. n must be in range. Otherwise, an assertion will be raised.

int *Delitem(List *x, int n)

Deletes item n from the list, shifting items down if necessary. To delete the last item in the list, use the special value DOH_END for n.

void Append(List *x, const Object_or_char *t)

Appends t to the end of x. If t is not a standard object, it is assumed to be a char * and is used to create a String object.

void Insert(String *s, int pos, const Object_or_char *t)

Inserts t into s at position pos. The contents of s are shifted accordingly. The special value DOH_END can be used for pos to indicate insertion at the end of the list (appending). If t is not a standard object, it is assumed to be a char * and is used to create a String object.

40.5.4 Common operations

The following operations are applicable to all datatypes.

Object *Copy(Object *x)

Make a copy of the object x.

void Delete(Object *x)

Deletes x.

void Setfile(Object *x, String_or_char *f)

Sets the filename associated with x. Used to track objects and report errors.

String *Getfile(Object *x)

Gets the filename associated with x.

void Setline(Object *x, int n)

Sets the line number associated with x. Used to track objects and report errors.

int Getline(Object *x)

Gets the line number associated with x.

40.5.5 Iterating over Lists and Hashes

To iterate over the elements of a list or a hash table, the following functions are used:

Iterator First(Object *x)

Returns an iterator object that points to the first item in a list or hash table. The item attribute of the Iterator object is a pointer to the item. For hash tables, the key attribute of the Iterator object additionally points to the corresponding Hash table key. The item and key attributes are NULL if the object contains no items or if there are no more items.

Iterator Next(Iterator i)

Returns an iterator that points to the next item in a list or hash table. Here are two examples of iteration:

List *l = (some list);
Iterator i;

for (i = First(l); i.item; i = Next(i)) {
    Printf(stdout,"%s\n", i.item);
}

Hash *h = (some hash);
Iterator j;

for (j = First(j); j.item; j= Next(j)) {
    Printf(stdout,"%s : %s\n", j.key, j.item);
}

40.5.6 I/O

Special I/O functions are used for all internal I/O. These operations work on C FILE * objects, String objects, and special File objects (which are merely a wrapper around FILE *).

int Printf(String_or_FILE *f, const char *fmt, ...)

Formatted I/O. Same as the C fprintf() function except that output can also be directed to a string object. Note: the %s format specifier works with both strings and char *. All other format operators have the same meaning.

int Printv(String_or_FILE *f, String_or_char *arg1,..., NULL)

Prints a variable number of strings arguments to the output. The last argument to this function must be NULL. The other arguments can either be char * or string objects.

int Putc(int ch, String_or_FILE *f)

Same as the C fputc() function.

int Write(String_or_FILE *f, void *buf, int len)

Same as the C write() function.

int Read(String_or_FILE *f, void *buf, int maxlen)

Same as the C read() function.

int Getc(String_or_FILE *f)

Same as the C fgetc() function.

int Ungetc(int ch, String_or_FILE *f)

Same as the C ungetc() function.

int Seek(String_or_FILE *f, int offset, int whence)

Same as the C seek() function. offset is the number of bytes. whence is one of SEEK_SET, SEEK_CUR, or SEEK_END..

long Tell(String_or_FILE *f)

Same as the C tell() function.

File *NewFile(const char *filename, const char *mode, List *newfiles)

Create a File object using the fopen() library call. This file differs from FILE * in that it can be placed in the standard SWIG containers (lists, hashes, etc.). The filename is added to the newfiles list if newfiles is non-zero and the file was created successfully.

File *NewFileFromFile(FILE *f)

Create a File object wrapper around an existing FILE * object.

There's no explicit function to close a file, just call Delete(f) - this decreases the reference count, and the file will be closed when the reference count reaches zero.

The use of the above I/O functions and strings play a critical role in SWIG. It is common to see small code fragments of code generated using code like this:

/* Print into a string */
String *s = NewString("");
Printf(s,"Hello\n");
for (i = 0; i < 10; i++) {
    Printf(s,"%d\n", i);
}
...
/* Print string into a file */
Printf(f, "%s\n", s);

Similarly, the preprocessor and parser all operate on string-files.

40.6 Navigating and manipulating parse trees

Parse trees are built as collections of hash tables. Each node is a hash table in which arbitrary attributes can be stored. Certain attributes in the hash table provide links to other parse tree nodes. The following macros can be used to move around the parse tree.

String *nodeType(Node *n)

Returns the node type tag as a string. The returned string indicates the type of parse tree node.

Node *nextSibling(Node *n)

Returns the next node in the parse tree. For example, the next C declaration.

Node *previousSibling(Node *n)

Returns the previous node in the parse tree. For example, the previous C declaration.

Node *firstChild(Node *n)

Returns the first child node. For example, if n was a C++ class node, this would return the node for the first class member.

Node *lastChild(Node *n)

Returns the last child node. You might use this if you wanted to append a new node to the of a class.

Node *parentNode(Node *n)

Returns the parent of node n. Use this to move up the pass tree.

The following macros can be used to change all of the above attributes. Normally, these functions are only used by the parser. Changing them without knowing what you are doing is likely to be dangerous.

void set_nodeType(Node *n, const String_or_char)

Change the node type. tree node.

void set_nextSibling(Node *n, Node *s)

Set the next sibling.

void set_previousSibling(Node *n, Node *s)

Set the previous sibling.

void set_firstChild(Node *n, Node *c)

Set the first child node.

void set_lastChild(Node *n, Node *c)

Set the last child node.

void set_parentNode(Node *n, Node *p)

Set the parent node.

The following utility functions are used to alter the parse tree (at your own risk)

void appendChild(Node *parent, Node *child)

Append a child to parent. The appended node becomes the last child.

void deleteNode(Node *node)

Deletes a node from the parse tree. Deletion reconnects siblings and properly updates the parent so that sibling nodes are unaffected.

40.7 Working with attributes

Since parse tree nodes are just hash tables, attributes are accessed using the Getattr(), Setattr(), and Delattr() operations. For example:

int functionHandler(Node *n) {
    String *name    = Getattr(n,"name");
    String *symname = Getattr(n,"sym:name");
    SwigType *type  = Getattr(n,"type");
    ...
}

New attributes can be freely attached to a node as needed. However, when new attributes are attached during code generation, they should be prepended with a namespace prefix. For example:

...
Setattr(n,"python:docstring", doc);     /* Store docstring */
...

A quick way to check the value of an attribute is to use the checkAttribute() function like this:

if (checkAttribute(n,"storage","virtual")) {
   /* n is virtual */
   ...
}

Changing the values of existing attributes is allowed and is sometimes done to implement node transformations. However, if a function/method modifies a node, it is required to restore modified attributes to their original values. To simplify the task of saving/restoring attributes, the following functions are used:

int Swig_save(const char *ns, Node *n, const char *name1, const char *name2, ..., NIL)

Saves a copy of attributes name1, name2, etc. from node n. Copies of the attributes are actually resaved in the node in a different namespace which is set by the ns argument. For example, if you call Swig_save("foo",n,"type",NIL), then the "type" attribute will be copied and saved as "foo:type". The namespace name itself is stored in the "view" attribute of the node. If necessary, this can be examined to find out where previous values of attributes might have been saved.

int Swig_restore(Node *n)

Restores the attributes saved by the previous call to Swig_save(). Those attributes that were supplied to Swig_save() will be restored to their original values.

The Swig_save() and Swig_restore() functions must always be used as a pair. That is, every call to Swig_save() must have a matching call to Swig_restore(). Calls can be nested if necessary. Here is an example that shows how the functions might be used:

int variableHandler(Node *n) {
    Swig_save("variableHandler",n,"type","sym:name",NIL);
    String *symname = Getattr(n,"sym:name");
    SwigType *type  = Getattr(n,"type");
    ...
    Append(symname,"_global");         // Change symbol name
    SwigType_add_pointer(type);        // Add pointer
    ...
    generate wrappers
    ...
    Swig_restore(n);                  // Restore original values
    return SWIG_OK;
}

int Swig_require(const char *ns, Node *n, const char *name1, const char *name2, ..., NIL)

This is an enhanced version of Swig_save() that adds error checking. If an attribute name is not present in n , a failed assertion results and SWIG terminates with a fatal error. Optionally, if an attribute name is specified as "*name", a copy of the attribute is saved as with Swig_save(). If an attribute is specified as "?name", the attribute is optional. Swig_restore() must always be called after using this function.

40.8 Type system

SWIG implements the complete C++ type system including typedef, inheritance, pointers, references, and pointers to members. A detailed discussion of type theory is impossible here. However, let's cover the highlights.

40.8.1 String encoding of types

All types in SWIG consist of a base datatype and a collection of type operators that are applied to the base. A base datatype is almost always some kind of primitive type such as int or double . The operators consist of things like pointers, references, arrays, and so forth. Internally, types are represented as strings that are constructed in a very precise manner. Here are some examples:

C datatype                     SWIG encoding (strings)
-----------------------------  --------------------------
int                            "int"
int *                          "p.int"
const int *                    "p.q(const).int"
int (*x)(int,double)           "p.f(int,double).int"
int [20][30]                   "a(20).a(30).int"
int (F::*)(int)                "m(F).f(int).int"
vector<int> *                  "p.vector<(int)>"

Reading the SWIG encoding is often easier than figuring out the C code---just read it from left to right. For a type of "p.f(int,double).int" is a "pointer to a function(int,double) that returns int".

The following operator encodings are used in type strings:

Operator              Meaning
-------------------   -------------------------------
p.                    Pointer to
a(n).                 Array of dimension n
r.                    C++ reference
m(class).             Member pointer to class
f(args).              Function.
q(qlist).             Qualifiers

In addition, type names may be parameterized by templates. This is represented by enclosing the template parameters in <( ... )>. Variable length arguments are represented by the special base type of v(...).

If you want to experiment with type encodings, the raw type strings can be inserted into an interface file using backticks `` wherever a type is expected. For instance, here is an extremely perverted example:

`p.a(10).p.f(int,p.f(int).int)` foo(int, int (*x)(int));

This corresponds to the immediately obvious C declaration:

(*(*foo(int,int (*)(int)))[10])(int,int (*)(int));

Aside from the potential use of this declaration on a C programming quiz, it motivates the use of the special SWIG encoding of types. The SWIG encoding is much easier to work with because types can be easily examined, modified, and constructed using simple string operations (comparison, substrings, concatenation, etc.). For example, in the parser, a declaration like this

int *a[30];

is processed in a few pieces. In this case, you have the base type " int" and the declarator of type "a(30).p.". To make the final type, the two parts are just joined together using string concatenation.

40.8.2 Type construction

The following functions are used to construct types. You should use these functions instead of trying to build the type strings yourself.

void SwigType_add_pointer(SwigType *ty)

Adds a pointer to ty.

void SwigType_del_pointer(SwigType *ty)

Removes a single pointer from ty.

void SwigType_add_reference(SwigType *ty)

Adds a reference to ty.

void SwigType_add_array(SwigType *ty, const String_or_char *size)

Adds an array with dimension dim to ty .

void SwigType_del_array(SwigType *ty)

Removes a single array dimension from ty.

int SwigType_array_ndim(SwigType *ty)

Returns number of array dimensions of ty.

String* SwigType_array_getdim(SwigType *ty,int n)

Returns nth array dimension of ty .

void SwigType_array_setdim(SwigType *ty, int n, const String_or_char *rep)

Sets nth array dimensions of ty to rep.

void SwigType_add_qualifier(SwigType *ty, const String_or_char *q)

Adds a type qualifier q to ty. q is typically "const" or "volatile".

void SwigType_add_memberpointer(SwigType *ty, const String_or_char *cls)

Adds a pointer to a member of class cls to ty.

void SwigType_add_function(SwigType *ty, ParmList *p)

Adds a function to ty. p is a linked-list of parameter nodes as generated by the parser. See the section on parameter lists for details about the representation.

void SwigType_add_template(SwigType *ty, ParmList *p)

Adds a template to ty. p is a linked-list of parameter nodes as generated by the parser. See the section on parameter lists for details about the representation.

SwigType *SwigType_pop(SwigType *ty)

Removes the last type constructor from ty and returns it. ty is modified.

void SwigType_push(SwigType *ty, SwigType *op)

Pushes the type operators in op onto type ty. The opposite of SwigType_pop().

SwigType *SwigType_pop_arrays(SwigType *ty)

Removes all leading array operators from ty and returns them. ty is modified. For example, if ty is "a(20).a(10).p.int", then this function would return "a(20).a(10)." and modify ty so that it has the value "p.int".

SwigType *SwigType_pop_function(SwigType *ty)

Removes a function operator from ty including any qualification. ty is modified. For example, if ty is "f(int).int", then this function would return "f(int)." and modify ty so that it has the value "int" .

SwigType *SwigType_base(SwigType *ty)

Returns the base type of a type. For example, if ty is "p.a(20).int", this function would return "int" . ty is unmodified.

SwigType *SwigType_prefix(SwigType *ty)

Returns the prefix of a type. For example, if ty is "p.a(20).int", this function would return "p.a(20).". ty is unmodified.

40.8.3 Type tests

The following functions can be used to test properties of a datatype.

int SwigType_ispointer(SwigType *ty)

Checks if ty is a standard pointer.

int SwigType_ismemberpointer(SwigType *ty)

Checks if ty is a member pointer.

int SwigType_isreference(SwigType *ty)

Checks if ty is a C++ reference.

int SwigType_isarray(SwigType *ty)

Checks if ty is an array.

int SwigType_isfunction(SwigType *ty)

Checks if ty is a function.

int SwigType_isqualifier(SwigType *ty)

Checks if ty is a qualifier.

int SwigType_issimple(SwigType *ty)

Checks if ty is a simple type. No operators applied.

int SwigType_isconst(SwigType *ty)

Checks if ty is a const type.

int SwigType_isvarargs(SwigType *ty)

Checks if ty is a varargs type.

int SwigType_istemplate(SwigType *ty)

Checks if ty is a templatized type.

40.8.4 Typedef and inheritance

The behavior of typedef declaration is to introduce a type alias. For instance, typedef int Integer makes the identifier Integer an alias for int. The treatment of typedef in SWIG is somewhat complicated due to the pattern matching rules that get applied in typemaps and the fact that SWIG prefers to generate wrapper code that closely matches the input to simplify debugging (a user will see the typedef names used in their program instead of the low-level primitive C datatypes).

To handle typedef, SWIG builds a collection of trees containing typedef relations. For example,

typedef int Integer;
typedef Integer *IntegerPtr;
typedef int Number;
typedef int Size;

produces two trees like this:

                 int               p.Integer
               ^  ^  ^                 ^
              /   |   \                |
             /    |    \               |
        Integer  Size   Number    IntegerPtr

To resolve a single typedef relationship, the following function is used:

SwigType *SwigType_typedef_resolve(SwigType *ty)

Checks if ty can be reduced to a new type via typedef. If so, returns the new type. If not, returns NULL.

Typedefs are only resolved in simple typenames that appear in a type. For example, the type base name and in function parameters. When resolving types, the process starts in the leaf nodes and moves up the tree towards the root. Here are a few examples that show how it works:

Original type            After typedef_resolve()
------------------------ -----------------------
Integer                  int
a(30).Integer            int
p.IntegerPtr             p.p.Integer
p.p.Integer              p.p.int

For complicated types, the process can be quite involved. Here is the reduction of a function pointer:

p.f(Integer, p.IntegerPtr, Size).Integer          : Start
p.f(Integer, p.IntegerPtr, Size).int
p.f(int, p.IntegerPtr, Size).int
p.f(int, p.p.Integer, Size).int
p.f(int, p.p.int, Size).int
p.f(int, p.p.int, int).int                        : End

Two types are equivalent if their full type reductions are the same. The following function will fully reduce a datatype:

SwigType *SwigType_typedef_resolve_all(SwigType *ty)

Fully reduces ty according to typedef rules. Resulting datatype will consist only of primitive typenames.

40.8.5 Lvalues

When generating wrapper code, it is necessary to emit datatypes that can be used on the left-hand side of an assignment operator (an lvalue). However, not all C datatypes can be used in this way---especially arrays and const-qualified types. To generate a type that can be used as an lvalue, use the following function:

SwigType *SwigType_ltype(SwigType *ty)

Converts type ty to a type that can be used as an lvalue in assignment. The resulting type is stripped of qualifiers and arrays are converted to a pointers.

The creation of lvalues is fully aware of typedef and other aspects of the type system. Therefore, the creation of an lvalue may result in unexpected results. Here are a few examples:

typedef double Matrix4[4][4];
Matrix4 x;    // type = 'Matrix4', ltype='p.a(4).double'

typedef const char * Literal;
Literal y;    // type = 'Literal', ltype='p.char'

40.8.6 Output functions

The following functions produce strings that are suitable for output.

String *SwigType_str(SwigType *ty, const String_or_char *id = 0)

Generates a C string for a datatype. id is an optional declarator. For example, if ty is "p.f(int).int" and id is "foo", then this function produces "int (*foo)(int)". This function is used to convert string-encoded types back into a form that is valid C syntax.

String *SwigType_lstr(SwigType *ty, const String_or_char *id = 0)

This is the same as SwigType_str() except that the result is generated from the type's lvalue (as generated from SwigType_ltype).

String *SwigType_lcaststr(SwigType *ty, const String_or_char *id = 0)

Generates a casting operation that converts from type ty to its lvalue. id is an optional name to include in the cast. For example, if ty is " q(const).p.char" and id is "foo", this function produces the string "(char *) foo".

String *SwigType_rcaststr(SwigType *ty, const String_or_char *id = 0)

Generates a casting operation that converts from a type's lvalue to a type equivalent to ty. id is an optional name to include in the cast. For example, if ty is " q(const).p.char" and id is "foo", this function produces the string "(const char *) foo".

String *SwigType_manglestr(SwigType *ty)

Generates a mangled string encoding of type ty . The mangled string only contains characters that are part of a valid C identifier. The resulting string is used in various parts of SWIG, but is most commonly associated with type-descriptor objects that appear in wrappers (e.g., SWIGTYPE_p_double).

40.9 Parameters

Several type-related functions involve parameter lists. These include functions and templates. Parameter list are represented as a list of nodes with the following attributes:

"type"        -  Parameter type  (required)
"name"        -  Parameter name  (optional)
"value"       -  Initializer     (optional)

Typically parameters are denoted in the source by using a typename of Parm * or ParmList *. To walk a parameter list, simply use code like this:

Parm *parms;
Parm *p;
for (p = parms; p; p = nextSibling(p)) {
    SwigType *type  = Getattr(p,"type");
    String   *name  = Getattr(p,"name");
    String   *value = Getattr(p,"value");
    ...
}

Note: this code is exactly the same as what you would use to walk parse tree nodes.

An empty list of parameters is denoted by a NULL pointer.

Since parameter lists are fairly common, the following utility functions are provided to manipulate them:

Parm *CopyParm(Parm *p);

Copies a single parameter.

ParmList *CopyParmList(ParmList *p);

Copies an entire list of parameters.

int ParmList_len(ParmList *p);

Returns the number of parameters in a parameter list.

String *ParmList_str(ParmList *p);

Converts a parameter list into a C string. For example, produces a string like "(int *p, int n, double x);".

String *ParmList_protostr(ParmList *p);

The same as ParmList_str() except that parameter names are not included. Used to emit prototypes.

int ParmList_numrequired(ParmList *p);

Returns the number of required (non-optional) arguments in p.

40.10 Writing a Language Module

One of the easiest routes to supporting a new language module is to copy an already supported language module implementation and modify it. Be sure to choose a language that is similar in nature to the new language. All language modules follow a similar structure and this section briefly outlines the steps needed to create a bare-bones language module from scratch. Since the code is relatively easy to read, this section describes the creation of a minimal Python module. You should be able to extrapolate this to other languages.

40.10.1 Execution model

Code generation modules are defined by inheriting from the Language class, currently defined in the Source/Modules directory of SWIG. Starting from the parsing of command line options, all aspects of code generation are controlled by different methods of the Language that must be defined by your module.

40.10.2 Starting out

To define a new language module, first create a minimal implementation using this example as a guide:

#include "swigmod.h"

class PYTHON : public Language {
public:

  virtual void main(int argc, char *argv[]) {
    printf("I'm the Python module.\n");
  }

  virtual int top(Node *n) {
    printf("Generating code.\n");
    return SWIG_OK;
  }

};

extern "C" Language *
swig_python(void) {
  return new PYTHON();
}

The "swigmod.h" header file contains, among other things, the declaration of the Language base class and so you should include it at the top of your language module's source file. Similarly, the "swigconfig.h" header file contains some other useful definitions that you may need. Note that you should not include any header files that are installed with the target language. That is to say, the implementation of the SWIG Python module shouldn't have any dependencies on the Python header files. The wrapper code generated by SWIG will almost always depend on some language-specific C/C++ header files, but SWIG itself does not.

Give your language class a reasonable name, usually the same as the target language. By convention, these class names are all uppercase (e.g. "PYTHON" for the Python language module) but this is not a requirement. This class will ultimately consist of a number of overrides of the virtual functions declared in the Language base class, in addition to any language-specific member functions and data you need. For now, just use the dummy implementations shown above.

The language module ends with a factory function, swig_python() , that simply returns a new instance of the language class. As shown, it should be declared with the extern "C" storage qualifier so that it can be called from C code. It should also return a pointer to the base class (Language) so that only the interface (and not the implementation) of your language module is exposed to the rest of SWIG.

Save the code for your language module in a file named " python.cxx" and. place this file in the Source/Modules directory of the SWIG distribution. To ensure that your module is compiled into SWIG along with the other language modules, modify the file Source/Modules/Makefile.am to include the additional source files. In addition, modify the file Source/Modules/swigmain.cxx with an additional command line option that activates the module. Read the source---it's straightforward.

Next, at the top level of the SWIG distribution, re-run the autogen.sh script to regenerate the various build files:

$ ./autogen.sh

Next re-run configure to regenerate all of the Makefiles:

$ ./configure

Finally, rebuild SWIG with your module added:

$ make

Once it finishes compiling, try running SWIG with the command-line option that activates your module. For example, swig -python foo.i . The messages from your new module should appear.

40.10.3 Command line options

When SWIG starts, the command line options are passed to your language module. This occurs before any other processing occurs (preprocessing, parsing, etc.). To capture the command line options, simply use code similar to this:

void Language::main(int argc, char *argv[]) {
  for (int i = 1; i < argc; i++) {
      if (argv[i]) {
          if(strcmp(argv[i],"-interface") == 0) {
            if (argv[i+1]) {
              interface = NewString(argv[i+1]);
              Swig_mark_arg(i);
              Swig_mark_arg(i+1);
              i++;
            } else {
              Swig_arg_error();
            }
          } else if (strcmp(argv[i],"-globals") == 0) {
            if (argv[i+1]) {
              global_name = NewString(argv[i+1]);
              Swig_mark_arg(i);
              Swig_mark_arg(i+1);
              i++;
            } else {
              Swig_arg_error();
            }
          } else if ( (strcmp(argv[i],"-proxy") == 0)) {
            proxy_flag = 1;
            Swig_mark_arg(i);
          } else if (strcmp(argv[i],"-keyword") == 0) {
            use_kw = 1;
            Swig_mark_arg(i);
          } else if (strcmp(argv[i],"-help") == 0) {
            fputs(usage,stderr);
          }
          ...
      }
  }
}

The exact set of options depends on what you want to do in your module. Generally, you would use the options to change code generation modes or to print diagnostic information.

If a module recognizes an option, it should always call Swig_mark_arg() to mark the option as valid. If you forget to do this, SWIG will terminate with an unrecognized command line option error.

40.10.4 Configuration and preprocessing

In addition to looking at command line options, the main() method is responsible for some initial configuration of the SWIG library and preprocessor. To do this, insert some code like this:

void main(int argc, char *argv[]) {
   ... command line options ...

   /* Set language-specific subdirectory in SWIG library */
   SWIG_library_directory("python");

   /* Set language-specific preprocessing symbol */
   Preprocessor_define("SWIGPYTHON 1", 0);

   /* Set language-specific configuration file */
   SWIG_config_file("python.swg");

   /* Set typemap language (historical) */
   SWIG_typemap_lang("python");
}

The above code does several things--it registers the name of the language module with the core, it supplies some preprocessor macro definitions for use in input files (so that they can determine the target language), and it registers a start-up file. In this case, the file python.swg will be parsed before any part of the user-supplied input file.

Before proceeding any further, create a directory for your module in the SWIG library (The Lib directory). Now, create a configuration file in the directory. For example, python.swg.

Just to review, your language module should now consist of two files-- an implementation file python.cxx and a configuration file python.swg.

40.10.5 Entry point to code generation

SWIG is a multi-pass compiler. Once the main() method has been invoked, the language module does not execute again until preprocessing, parsing, and a variety of semantic analysis passes have been performed. When the core is ready to start generating wrappers, it invokes the top() method of your language class. The argument to top is a single parse tree node that corresponds to the top of the entire parse tree.

To get the code generation process started, the top() procedure needs to do several things:

  • Initialize the wrapper code output.
  • Set the module name.
  • Emit common initialization code.
  • Emit code for all of the child nodes.
  • Finalize the wrapper module and cleanup.

An outline of top() might be as follows:

int Python::top(Node *n) {

   /* Get the module name */
   String *module = Getattr(n,"name");

   /* Get the output file name */
   String *outfile = Getattr(n,"outfile");

   /* Initialize I/O (see next section) */
   ...

   /* Output module initialization code */
   ...

   /* Emit code for children */
   Language::top(n);

   ...
   /* Cleanup files */
   ...

   return SWIG_OK;
}

40.10.6 Module I/O and wrapper skeleton

Within SWIG wrappers, there are five main sections. These are (in order)

  • begin: This section is a placeholder for users to put code at the beginning of the C/C++ wrapper file.
  • runtime: This section has most of the common SWIG runtime code.
  • header: This section holds declarations and inclusions from the .i file.
  • wrapper: This section holds all the wrapper code.
  • init: This section holds the module initialisation function (the entry point for the interpreter).

Different parts of the SWIG code will fill different sections, then upon completion of the wrappering all the sections will be saved to the wrapper file.

To perform this will require several additions to the code in various places, such as:

class PYTHON : public Language {
protected:
   /* General DOH objects used for holding the strings */
   File *f_begin;
   File *f_runtime;
   File *f_header;
   File *f_wrappers;
   File *f_init;

public:
   ...

};

int Python::top(Node *n) {

   ...

   /* Initialize I/O */
   f_begin = NewFile(outfile, "w", SWIG_output_files());
   if (!f_begin) {
      FileErrorDisplay(outfile);
      SWIG_exit(EXIT_FAILURE);
   }
   f_runtime = NewString("");
   f_init = NewString("");
   f_header = NewString("");
   f_wrappers = NewString("");

   /* Register file targets with the SWIG file handler */
   Swig_register_filebyname("begin", f_begin);
   Swig_register_filebyname("header", f_header);
   Swig_register_filebyname("wrapper", f_wrappers);
   Swig_register_filebyname("runtime", f_runtime);
   Swig_register_filebyname("init", f_init);

   /* Output module initialization code */
   Swig_banner(f_begin);
   ...

   /* Emit code for children */
   Language::top(n);

   ...
   /* Write all to the file */
   Dump(f_runtime, f_begin);
   Dump(f_header, f_begin);
   Dump(f_wrappers, f_begin);
   Wrapper_pretty_print(f_init, f_begin);

   /* Cleanup files */
   Delete(f_runtime);
   Delete(f_header);
   Delete(f_wrappers);
   Delete(f_init);
   Delete(f_begin);

   return SWIG_OK;
}

Using this to process a file will generate a wrapper file, however the wrapper will only consist of the common SWIG code as well as any inline code which was written in the .i file. It does not contain any wrappers for any of the functions or classes.

The code to generate the wrappers are the various member functions, which currently have not been touched. We will look at functionWrapper() as this is the most commonly used function. In fact many of the other wrapper routines will call this to do their work.

A simple modification to write some basic details to the wrapper looks like this:

int Python::functionWrapper(Node *n) {
  /* Get some useful attributes of this function */
  String   *name   = Getattr(n,"sym:name");
  SwigType *type   = Getattr(n,"type");
  ParmList *parms  = Getattr(n,"parms");
  String   *parmstr= ParmList_str_defaultargs(parms); // to string
  String   *func   = SwigType_str(type, NewStringf("%s(%s)", name, parmstr));
  String   *action = Getattr(n,"wrap:action");

  Printf(f_wrappers,"functionWrapper   : %s\n", func);
  Printf(f_wrappers,"           action : %s\n", action);
  return SWIG_OK;
}

This will now produce some useful information within your wrapper file.

functionWrapper   : void delete_Shape(Shape *self)
           action : delete arg1;

functionWrapper   : void Shape_x_set(Shape *self,double x)
           action : if (arg1) (arg1)->x = arg2;

functionWrapper   : double Shape_x_get(Shape *self)
           action : result = (double) ((arg1)->x);

functionWrapper   : void Shape_y_set(Shape *self,double y)
           action : if (arg1) (arg1)->y = arg2;
...

40.10.7 Low-level code generators

As ingenious as SWIG is, and despite all its capabilities and the power of its parser, the Low-level code generation takes a lot of work to write properly. Mainly because every language insists on its own manner of interfacing to C/C++. To write the code generators you will need a good understanding of how to manually write an interface to your chosen language, so make sure you have your documentation handy.

At this point it is also probably a good idea to take a very simple file (just one function), and try letting SWIG generate wrappers for many different languages. Take a look at all of the wrappers generated, and decide which one looks closest to the language you are trying to wrap. This may help you to decide which code to look at.

In general most language wrappers look a little like this:

/* wrapper for TYPE3 some_function(TYPE1,TYPE2); */
RETURN_TYPE _wrap_some_function(ARGS){
  TYPE1 arg1;
  TYPE2 arg2;
  TYPE3 result;

  if(ARG1 is not of TYPE1) goto fail;
  arg1=(convert ARG1);
  if(ARG2 is not of TYPE2) goto fail;
  arg2=(convert ARG2);

  result=some_function(arg1,arg2);

  convert 'result' to whatever the language wants;

  do any tidy up;

  return ALL_OK;

  fail:
  do any tidy up;
  return ERROR;
}

Yes, it is rather vague and not very clear. But each language works differently so this will have to do for now.

Tackling this problem will be done in two stages:

  • The skeleton: the function wrapper, and call, but without the conversion
  • The conversion: converting the arguments to-from what the language wants

The first step will be done in the code, the second will be done in typemaps.

Our first step will be to write the code for functionWrapper() . What is shown below is NOT the solution, merely a step in the right direction. There are a lot of issues to address.

  • Variable length and default parameters
  • Typechecking and number of argument checks
  • Overloaded functions
  • Inout and Output only arguments
virtual int functionWrapper(Node *n) {
  /* get useful attributes */
  String   *name   = Getattr(n,"sym:name");
  SwigType *type   = Getattr(n,"type");
  ParmList *parms  = Getattr(n,"parms");
  ...

  /* create the wrapper object */
  Wrapper *wrapper = NewWrapper();

  /* create the functions wrappered name */
  String *wname = Swig_name_wrapper(iname);

  /* deal with overloading */
  ....

  /* write the wrapper function definition */
  Printv(wrapper->def,"RETURN_TYPE ", wname, "(ARGS) {",NIL);

  /* if any additional local variable needed, add them now */
  ...

  /* write the list of locals/arguments required */
  emit_args(type, parms, wrapper);

  /* check arguments */
  ...

  /* write typemaps(in) */
  ....

  /* write constraints */
  ....

  /* Emit the function call */
  emit_action(n,wrapper);

  /* return value if necessary  */
  ....

  /* write typemaps(out) */
  ....

  /* add cleanup code */
  ....

  /* Close the function(ok) */
  Printv(wrapper->code, "return ALL_OK;\n", NIL);

  /* add the failure cleanup code */
  ...

  /* Close the function(error) */
  Printv(wrapper->code, "return ERROR;\n", "}\n", NIL);

  /* final substititions if applicable */
  ...

  /* Dump the function out */
  Wrapper_print(wrapper,f_wrappers);

  /* tidy up */
  Delete(wname);
  DelWrapper(wrapper);

  return SWIG_OK;
}

Executing this code will produce wrappers which have our basic skeleton but without the typemaps, there is still work to do.

40.10.8 Configuration files

At the time of this writing, SWIG supports nearly twenty languages, which means that for continued sanity in maintaining the configuration files, the language modules need to follow some conventions. These are outlined here along with the admission that, yes it is ok to violate these conventions in minor ways, as long as you know where to apply the proper kludge to keep the overall system regular and running. Engineering is the art of compromise, see...

Much of the maintenance regularity depends on choosing a suitable nickname for your language module (and then using it in a controlled way). Nicknames should be all lower case letters with an optional numeric suffix (no underscores, no dashes, no spaces). Some examples are: foo, bar, qux99.

The numeric suffix variant, as in the last example, is somewhat tricky to work with because sometimes people expect to refer to the language without this number but sometimes that number is extremely relevant (especially when it corresponds to language implementation versions with incompatible interfaces). New language modules that unavoidably require a numeric suffix in their nickname should include that number in all uses, or be prepared to kludge.

The nickname is used in four places:

usagetransform
"skip" tag(none)
Examples/ subdir name(none)
Examples/test-suite/ subdir name(none)

As you can see, most usages are direct.

configure.ac
This file is processed by

autoconf to generate the configure script. This is where you need to add shell script fragments and autoconf macros to detect the presence of whatever development support your language module requires, typically directories where headers and libraries can be found, and/or utility programs useful for integrating the generated wrapper code.

Use the AC_ARG_WITH, AC_MSG_CHECKING, AC_SUBST macros and so forth (see other languages for examples). Avoid using the [ and ] character in shell script fragments. The variable names passed to AC_SUBST should begin with the nickname, entirely upcased.

At the end of the new section is the place to put the aforementioned nickname kludges (should they be needed). See Perl5 for examples of what to do. [If this is still unclear after you've read the code, ping me and I'll expand on this further. --ttn]

Makefile.in

Some of the variables AC_SUBSTituted are essential to the support of your language module. Fashion these into a shell script "test" clause and assign that to a skip tag using "-z" and "-o":

skip-qux99 = [ -z "@QUX99INCLUDE@" -o -z "@QUX99LIBS" ]

This means if those vars should ever be empty, qux99 support should be considered absent and so it would be a good idea to skip actions that might rely on it.

Here is where you may also define an alias (but then you'll need to kludge --- don't do this):

skip-qux = $(skip-qux99)

Lastly, you need to modify each of check-aliveness, check-examples, check-test-suite and lib-languages (var). Use the nickname for these, not the alias. Note that you can do this even before you have any tests or examples set up; the Makefile rules do some sanity checking and skip around these kinds of problems.

Examples/Makefile.in
Nothing special here; see comments at top the of this file and look to the existing languages for examples.
Examples/qux99/check.list
Do cp ../python/check.list . and modify to taste. One subdir per line.
Lib/qux99/extra-install.list
If you add your language to the top-level Makefile.in var lib-languages, then make install will install all *.i and *.swg files from the language-specific subdirectory of Lib. Use (optional) file extra-install.list in that directory to name additional files to install (see ruby for example).
Source/Modules/Makefile.am
Add appropriate files to this Automake file. That's it!

When you have modified these files, please make sure that the new language module is completely ignored if it is not installed and detected on a box, that is, make check-examples and make check-test-suite politely displays the ignoring language message.

40.10.9 Runtime support

Discuss the kinds of functions typically needed for SWIG runtime support (e.g. SWIG_ConvertPtr() and SWIG_NewPointerObj() ) and the names of the SWIG files that implement those functions.

40.10.10 Standard library files

The standard library files that most languages supply keeps growing as SWIG matures. The following are the minimum that are usually supported:

  • typemaps.i
  • std_string.i
  • std_vector.i
  • stl.i

Please copy these and modify for any new language.

40.10.11 User examples

Each of the language modules provides one or more examples. These examples are used to demonstrate different features of the language module to SWIG end-users, but you'll find that they're useful during development and testing of your language module as well. You can use examples from the existing SWIG language modules for inspiration.

Each example is self-contained and consists of (at least) a Makefile, a SWIG interface file for the example module, and a 'runme' script that demonstrates the functionality for that module. All of these files are stored in the same subdirectory under the Examples/[lang] directory. There are two classic examples which should be the first to convert to a new language module. These are the "simple" C example and the "class" C++ example. These can be found, for example for Python, in Examples/python/simple and Examples/python/class.

By default, all of the examples are built and run when the user types make check. To ensure that your examples are automatically run during this process, see the section on configuration files.

40.10.12 Test driven development and the test-suite

A test driven development approach is central to the improvement and development of SWIG. Most modifications to SWIG are accompanied by additional regression tests and checking all tests to ensure that no regressions have been introduced.

The regression testing is carried out by the SWIG test-suite. The test-suite consists of numerous testcase interface files in the Examples/test-suite directory as well as target language specific runtime tests in the Examples/test-suite/[lang] directory. When a testcase is run, it will execute the following steps for each testcase:

  1. Execute SWIG passing it the testcase interface file.
  2. Compile the resulting generated C/C++ code with either the C or C++ compiler into object files.
  3. Link the object files into a dynamic library (dll/shared object).
  4. Compile any generated and any runtime test target language code with the target language compiler, if the target language supports compilation. This step thus does not apply to the interpreted languages.
  5. Execute a runtime test if one exists.

For example, the ret_by_value testcase consists of two components. The first component is the Examples/test-suite/ret_by_value.i interface file. The name of the SWIG module must always be the name of the testcase, so the ret_by_value.i interface file thus begins with:

%module ret_by_value

The testcase code will then follow the module declaration, usually within a %inline %{ ... %} section for the majority of the tests.

The second component is the optional runtime tests. Any runtime tests are named using the following convention: [testcase]_runme.[ext], where [testcase] is the testcase name and [ext] is the normal extension for the target language file. In this case, the Java and Python target languages implement a runtime test, so their files are respectively, Examples/test-suite/java/ret_by_value_runme.java and Examples/test-suite/python/ret_by_value_runme.py.

The goal of the test-suite is to test as much as possible in a silent manner. This way any SWIG or compiler errors or warnings are easily visible. Should there be any warnings, changes must be made to either fix them (preferably) or suppress them. Compilation or runtime errors result in a testcase failure and will be immediately visible. It is therefore essential that the runtime tests are written in a manner that displays nothing to stdout/stderr on success but error/exception out with an error message on stderr on failure.

40.10.12.1 Running the test-suite

In order for the test-suite to work for a particular target language, the language must be correctly detected and configured during the configure stage so that the correct Makefiles are generated. Most development occurs on Linux, so usually it is a matter of installing the development packages for the target language and simply configuring as outlined earlier.

If when running the test-suite commands that follow, you get a message that the test was skipped, it indicates that the configure stage is missing information in order to compile and run everything for that language.

The test-suite can be run in a number of ways. The first group of commands are for running multiple testcases in one run and should be executed in the top level directory. To run the entire test-suite (can take a long time):

make -k check-test-suite

To run the test-suite just for target language [lang], replace [lang] with one of csharp, java, perl5, python, ruby, tcl etc:

make check-[lang]-test-suite

Note that if a runtime test is available, a message "(with run test)" is displayed when run. For example:

$ make check-python-test-suite
checking python test-suite
checking python testcase argcargvtest (with run test)
checking python testcase python_autodoc
checking python testcase python_append (with run test)
checking python testcase callback (with run test)

The files generated on a previous run can be deleted using the clean targets, either the whole test-suite or for a particular language:

make clean-test-suite
make clean-[lang]-test-suite

The test-suite can be run in a partialcheck mode where just SWIG is executed, that is, the compile, link and running of the testcases is not performed. Note that the partialcheck does not require the target language to be correctly configured and detected and unlike the other test-suite make targets, is never skipped. Once again, either all the languages can be executed or just a chosen language:

make partialcheck-test-suite
make partialcheck-[lang]-test-suite

If your computer has more than one CPU, you are strongly advised to use parallel make to speed up the execution speed. This can be done with any of the make targets that execute more than one testcase. For example, a dual core processor can efficiently use 2 parallel jobs:

make -j2 check-test-suite
make -j2 check-python-test-suite
make -j2 partialcheck-java-test-suite

The second group of commands are for running individual testcases and should be executed in the appropriate target language directory, Examples/test-suite/[lang]. Testcases can contain either C or C++ code and when one is written, a decision must be made as to which of these input languages is to be used. Replace [testcase] in the commands below with the name of the testcase.

For a C language testcase, add the testcase under the C_TEST_CASES list in Examples/test-suite/common.mk and execute individually as:

make -s [testcase].ctest

For a C++ language testcase, add the testcase under the CPP_TEST_CASES list in Examples/test-suite/common.mk and execute individually as:

make -s [testcase].cpptest

A third category of tests are C++ language testcases testing multiple modules (the %import directive). These require more than one shared library (dll/shared object) to be built and so are separated out from the normal C++ testcases. Add the testcase under the MULTI_CPP_TEST_CASES list in Examples/test-suite/common.mk and execute individually as:

make -s [testcase].multicpptest

To delete the generated files, execute:

make -s [testcase].clean

If you would like to see the exact commands being executed, drop the -s option:

make [testcase].ctest
make [testcase].cpptest
make [testcase].multicpptest

Some real examples of each:

make -s ret_by_value.clean
make -s ret_by_value.ctest
make -s bools.cpptest
make -s imports.multicpptest

Advanced usage of the test-suite facilitates running tools on some of the five stages. The make variables SWIGTOOL and RUNTOOL are used to specify a tool to respectively, invoke SWIG and the execution of the runtime test. You are advised to view the Examples/test-suite/common.mk file for details but for a short summary, the classic usage is to use Valgrind for memory checking. For example, checking for memory leaks when running the runtime test in the target language interpreter:

make ret_by_value.ctest RUNTOOL="valgrind --leak-check=full"

This will probably make more sense if you look at the output of the above as it will show the exact commands being executed. SWIG can be analyzed for bad memory accesses using:

make ret_by_value.ctest SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"

A debugger can also be invoked easily on an individual test, for example gdb:

make ret_by_value.ctest RUNTOOL="gdb --args"

SWIG reads the SWIG_FEATURES environment variable to obtain options in addition to those passed on the command line. This is particularly useful as the entire test-suite or a particular testcase can be run customized by using additional arguments, for example the -O optimization flag can be added in, as shown below for the bash shell:

env SWIG_FEATURES=-O make check-python-test-suite

The syntax for setting environment variables varies from one shell to the next, but it also works as shown in the example below, where some typemap debugging is added in:

make ret_by_value.ctest SWIG_FEATURES="-debug-tmsearch"

There is also a special 'errors' test-suite which is a set of regression tests checking SWIG warning and error messages. It can be run in the same way as the other language test-suites, replacing [lang] with errors, such as make check-errors-test-suite. The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

40.10.13 Documentation

Don't forget to write end-user documentation for your language module. Currently, each language module has a dedicated chapter You shouldn't rehash things that are already covered in sufficient detail in the SWIG Basics and SWIG and C++ chapters. There is no fixed format for what, exactly, you should document about your language module, but you'll obviously want to cover issues that are unique to your language.

Some topics that you'll want to be sure to address include:

  • Command line options unique to your language module.
  • Non-obvious mappings between C/C++ and target language concepts. For example, if your target language provides a single floating point type, it should be no big surprise to find that C/C++ float and double types are mapped to it. On the other hand, if your target language doesn't provide support for "classes" or something similar, you'd want to discuss how C++ classes are handled.
  • How to compile the SWIG-generated wrapper code into shared libraries that can actually be used. For some languages, there are well-defined procedures for doing this, but for others it's an ad hoc process. Provide as much detail as appropriate, and links to other resources if available.

40.10.14 Prerequisites for adding a new language module to the SWIG distribution

If you wish for a new language module to be distributed with SWIG, which we encourage for all popular languages, there are a few requirements. While we appreciate that getting all aspects of a new language working won't happen at the outset, there are a set of minimum requirements before a module can be committed into the official Github repository for distribution with future versions of SWIG. The following are really a summary of this whole section with details being outlined earlier on.

  1. Demonstrate basic C code working by porting the "simple" example including a runtime test, see for example Examples/python/simple .
  2. Demonstrate basic C++ code working by porting the "class" example including a runtime test, see for example Examples/python/class .
  3. Modify configure.ac, Makefile.in and Examples/Makefile.in to run these examples. Please make sure that if the new language is not installed properly on a box, make -k check should still work by skipping the tests and examples for the new language module.
  4. Get the test-suite running for the new language (make check-[lang]-test-suite). While the test-suite tests many corner cases, we'd expect the majority of it to work by compiling the generated code correctly as most of the corner cases are covered in the SWIG core. Get at least one C and one C++ runtime test running in the test-suite.
  5. Provide a chapter in the html documentation on the basics of using the language module.
  6. Ensure your source code is formatted according to the coding style guidelines.
  7. Finally, email the SWIG developers with a patch and a demonstration of commitment to maintaining the language module, certainly in the short term and ideally long term.

Once accepted into the official Git repository, development efforts should concentrate on getting the entire test-suite to work with plenty of runtime tests. Runtime tests should be for existing testcases and new test cases should be added should there be an area not already covered by the existing tests.

40.10.15 Coding style guidelines

The coding guidelines for the C/C++ source code are pretty much K&R C style. The style can be inferred from the existing code base and is largely dictated by the indent code beautifier tool set to K&R style. The code can formatted using the make targets in the Source directory. Below is an example of how to format the emit.cxx file:

$ cd Source
$ make beautify-file INDENTFILE=Modules/emit.cxx

Of particular note is indentation is set to 2 spaces and a tab is used instead of 8 spaces. The generated C/C++ code should also follow this style as close as possible. However, tabs should be avoided as unlike the SWIG developers, users will never have consistent tab settings.

40.11 Debugging Options

There are various command line options which can aid debugging a SWIG interface as well as debugging the development of a language module. These are as follows:

-debug-classes    - Display information about the classes found in the interface
-debug-module <n> - Display module parse tree at stages 1-4, <n> is a csv list of stages
-debug-symtabs    - Display symbol tables information
-debug-symbols    - Display target language symbols in the symbol tables
-debug-csymbols   - Display C symbols in the symbol tables
-debug-lsymbols   - Display target language layer symbols
-debug-tags       - Display information about the tags found in the interface
-debug-template   - Display information for debugging templates
-debug-top <n>    - Display entire parse tree at stages 1-4, <n> is a csv list of stages
-debug-typedef    - Display information about the types and typedefs in the interface
-debug-typemap    - Display information for debugging typemaps
-debug-tmsearch   - Display typemap search debugging information
-debug-tmused     - Display typemaps used debugging information

The complete list of command line options for SWIG are available by running swig -help.

40.12 Guide to parse tree nodes

This section describes the different parse tree nodes and their attributes.

cdecl

Describes general C declarations including variables, functions, and typedefs. A declaration is parsed as "storage T D" where storage is a storage class, T is a base type, and D is a declarator.

"name"          - Declarator name
"type"          - Base type T
"decl"          - Declarator type (abstract)
"storage"       - Storage class (static, extern, typedef, etc.)
"parms"         - Function parameters (if a function)
"code"          - Function body code (if supplied)
"value"         - Default value (if supplied)

constructor

C++ constructor declaration.

"name"          - Name of constructor
"parms"         - Parameters
"decl"          - Declarator (function with parameters)
"code"          - Function body code (if any)
"feature:new"   - Set to indicate return of new object.

destructor

C++ destructor declaration.

"name"          - Name of destructor
"code"          - Function body code (if any)
"storage"       - Storage class (set if virtual)
"value"         - Default value (set if pure virtual).

access

C++ access change.

"kind"          - public, protected, private

constant

Constant created by %constant or #define.

"name"          - Name of constant.
"type"          - Base type.
"value"         - Value.
"storage"       - Set to %constant
"feature:immutable" - Set to indicate read-only

class

C++ class definition or C structure definition.

"name"          - Name of the class.
"kind"          - Class kind ("struct", "union", "class")
"symtab"        - Enclosing symbol table.
"tdname"        - Typedef name. Use for typedef struct { ... } A.
"abstract"      - Set if class has pure virtual methods.
"baselist"      - List of base class names.
"storage"       - Storage class (if any)
"unnamed"       - Set if class is unnamed.

enum

Enumeration.

"name"          - Name of the enum (if supplied).
"storage"       - Storage class (if any)
"tdname"        - Typedef name (typedef enum { ... } name).
"unnamed"       - Set if enum is unnamed.

enumitem

Enumeration value.

"name"          - Name of the enum value.
"type"          - Type (integer or char)
"value"         - Enum value (if given)
"feature:immutable" - Set to indicate read-only

namespace

C++ namespace.

"name"          - Name of the namespace.
"symtab"        - Symbol table for enclosed scope.
"unnamed"       - Set if unnamed namespace
"alias"         - Alias name. Set for namespace A = B;

using

C++ using directive.

"name"          - Name of the object being referred to.
"uname"         - Qualified name actually given to using.
"node"          - Node being referenced.
"namespace"     - Namespace name being reference (using namespace name)

classforward

A forward C++ class declaration.

"name"          - Name of the class.
"kind"          - Class kind ("union", "struct", "class")

insert

Code insertion directive. For example, %{ ... %} or %insert(section).

"code"          - Inserted code
"section"       - Section name ("header", "wrapper", etc.)

top

Top of the parse tree.

"module"        - Module name

extend

%extend directive.

"name"          - Module name
"symtab"        - Symbol table of enclosed scope.

apply

%apply pattern { patternlist }.

"pattern"       - Source pattern.
"symtab"        - Symbol table of enclosed scope.

clear

%clear patternlist;

"firstChild"    - Patterns to clear

include

%include directive.

"name"         - Filename
"firstChild"   - Children

import

%import directive.

"name"         - Filename
"firstChild"   - Children

module

%module directive.

"name"         - Name of the module

typemap

%typemap directive.

"method"       - Typemap method name.
"code"         - Typemap code.
"kwargs"       - Keyword arguments (if any)
"firstChild"   - Typemap patterns

typemapcopy

%typemap directive with copy.

"method"       - Typemap method name.
"pattern"      - Typemap source pattern.
"firstChild"   - Typemap patterns

typemapitem

%typemap pattern. Used with %apply, %clear, %typemap.

"pattern"      - Typemap pattern (a parameter list)
"parms"        - Typemap parameters.

types

%types directive.

"parms"        - List of parameter types.
"convcode"     - Code which replaces the default casting / conversion code

extern

extern "X" { ... } declaration.

"name"       - Name "C", "Fortran", etc.

40.13 Further Development Information

There is further documentation available on the internals of SWIG, API documentation and debugging information. This is shipped with SWIG in the Doc/Devel directory.

swig-3.0.2/Doc/Manual/Ruby.html0000664000175000017500000045637012343706602016120 0ustar williamwilliam SWIG and Ruby

38 SWIG and Ruby

This chapter describes SWIG's support of Ruby.

38.1 Preliminaries

SWIG 1.3 is known to work with Ruby versions 1.6 and later. Given the choice, you should use the latest stable version of Ruby. You should also determine if your system supports shared libraries and dynamic loading. SWIG will work with or without dynamic loading, but the compilation process will vary.

This chapter covers most SWIG features, but in less depth than is found in earlier chapters. At the very least, make sure you also read the "SWIG Basics" chapter. It is also assumed that the reader has a basic understanding of Ruby.

38.1.1 Running SWIG

To build a Ruby module, run SWIG using the -ruby option:

$ swig -ruby example.i

If building a C++ extension, add the -c++ option:

$ swig -c++ -ruby example.i

This creates a file example_wrap.c (example_wrap.cxx if compiling a C++ extension) that contains all of the code needed to build a Ruby extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

38.1.2 Getting the right header files

In order to compile the wrapper code, the compiler needs the ruby.h header file. This file is usually contained in a directory such as

/usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
/usr/local/lib/ruby/1.6/i686-linux/ruby.h

The exact location may vary on your machine, but the above location is typical. If you are not entirely sure where Ruby is installed, you can run Ruby to find out. For example:

$ ruby -e 'puts $:.join("\n")'
/usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
/usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .

38.1.3 Compiling a dynamic module

Ruby extension modules are typically compiled into shared libraries that the interpreter loads dynamically at runtime. Since the exact commands for doing this vary from platform to platform, your best bet is to follow the steps described in the README.EXT file from the Ruby distribution:

  1. Create a file called extconf.rb that looks like the following:

    require 'mkmf'
    create_makefile('example')
  2. Type the following to build the extension:

    $ ruby extconf.rb
    $ make
    $ make install
        

Of course, there is the problem that mkmf does not work correctly on all platforms, e.g, HPUX. If you need to add your own make rules to the file that extconf.rb produces, you can add this:

open("Makefile", "a") { |mf|
 puts <<EOM
 # Your make rules go here
 EOM
}

to the end of the extconf.rb file. If for some reason you don't want to use the standard approach, you'll need to determine the correct compiler and linker flags for your build platform. For example, assuming you have code you need to link to in a file called example.c, a typical sequence of commands for the Linux operating system would look something like this:

$ swig -ruby example.i
$ gcc -O2 -fPIC -c example.c
$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
$ gcc -shared example.o example_wrap.o -o example.so

The -fPIC option tells GCC to generate position-independent code (PIC) which is required for most architectures (it's not vital on x86, but still a good idea as it allows code pages from the library to be shared between processes). Other compilers may need a different option specified instead of -fPIC.

If in doubt, consult the manual pages for your compiler and linker to determine the correct set of options. You might also check the SWIG Wiki for additional information.

38.1.4 Using your module

Ruby module names must be capitalized, but the convention for Ruby feature names is to use lowercase names. So, for example, the Etc extension module is imported by requiring the etc feature:

# The feature name begins with a lowercase letter...
require 'etc'

# ... but the module name begins with an uppercase letter
puts "Your login name: #{Etc.getlogin}"

To stay consistent with this practice, you should always specify a lowercase module name with SWIG's %module directive. SWIG will automatically correct the resulting Ruby module name for your extension. So for example, a SWIG interface file that begins with:

%module example

will result in an extension module using the feature name "example" and Ruby module name "Example".

38.1.5 Static linking

An alternative approach to dynamic linking is to rebuild the Ruby interpreter with your extension module added to it. In the past, this approach was sometimes necessary due to limitations in dynamic loading support on certain machines. However, the situation has improved greatly over the last few years and you should not consider this approach unless there is really no other option.

The usual procedure for adding a new module to Ruby involves finding the Ruby source, adding an entry to the ext/Setup file, adding your directory to the list of extensions in the file, and finally rebuilding Ruby.

38.1.6 Compilation of C++ extensions

On most machines, C++ extension modules should be linked using the C++ compiler. For example:

$ swig -c++ -ruby example.i
$ g++ -fPIC -c example.cxx
$ g++ -fPIC -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
$ g++ -shared example.o example_wrap.o -o example.so

If you've written an extconf.rb script to automatically generate a Makefile for your C++ extension module, keep in mind that (as of this writing) Ruby still uses gcc and not g++ as its linker. As a result, the required C++ runtime library support will not be automatically linked into your extension module and it may fail to load on some platforms. A workaround for this problem is use the mkmf module's append_library() method to add one of the C++ runtime libraries to the list of libraries linked into your extension, e.g.

require 'mkmf'
$libs = append_library($libs, "supc++")
create_makefile('example')

38.2 Building Ruby Extensions under Windows 95/NT

Building a SWIG extension to Ruby under Windows 95/NT is roughly similar to the process used with Unix. Normally, you will want to produce a DLL that can be loaded into the Ruby interpreter. For all recent versions of Ruby, the procedure described above (i.e. using an extconf.rb script) will work with Windows as well; you should be able to build your code into a DLL by typing:

C:\swigtest> ruby extconf.rb
C:\swigtest> nmake
C:\swigtest> nmake install

The remainder of this section covers the process of compiling SWIG-generated Ruby extensions with Microsoft Visual C++ 6 (i.e. within the Developer Studio IDE, instead of using the command line tools). In order to build extensions, you may need to download the source distribution to the Ruby package, as you will need the Ruby header files.

38.2.1 Running SWIG from Developer Studio

If you are developing your application within Microsoft developer studio, SWIG can be invoked as a custom build option. The process roughly follows these steps :

  • Open up a new workspace and use the AppWizard to select a DLL project.
  • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (i.e. example_wrap.c). Note : If using C++, choose a different suffix for the wrapper file such as example_wrap.cxx. Don't worry if the wrapper file doesn't exist yet--Developer Studio will keep a reference to it around.
  • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
  • Enter "SWIG" in the description field.
  • Enter "swig -ruby -o $(ProjDir)\$(InputName)_wrap.c $(InputPath)" in the "Build command(s) field". You may have to include the path to swig.exe.
  • Enter "$(ProjDir)\$(InputName)_wrap.c" in the "Output files(s) field".
  • Next, select the settings for the entire project and go to the C/C++ tab and select the Preprocessor category. Add NT=1 to the Preprocessor definitions. This must be set else you will get compilation errors. Also add IMPORT to the preprocessor definitions, else you may get runtime errors. Also add the include directories for your Ruby installation under "Additional include directories".
  • Next, select the settings for the entire project and go to the Link tab and select the General category. Set the name of the output file to match the name of your Ruby module (i.e.. example.dll). Next add the Ruby library file to your link libraries under Object/Library modules. For example "mswin32-ruby16.lib. You also need to add the path to the library under the Input tab - Additional library path.
  • Build your project.

Now, assuming all went well, SWIG will be automatically invoked when you build your project. Any changes made to the interface file will result in SWIG being automatically invoked to produce a new version of the wrapper file. To run your new Ruby extension, simply run Ruby and use the require command as normal. For example if you have this ruby file run.rb:

# file: run.rb
require 'Example'

# Call a c function
print "Foo = ", Example.Foo, "\n"

Ensure the dll just built is in your path or current directory, then run the Ruby script from the DOS/Command prompt:

C:\swigtest> ruby run.rb
Foo = 3.0

38.3 The Ruby-to-C/C++ Mapping

This section describes the basics of how SWIG maps C or C++ declarations in your SWIG interface files to Ruby constructs.

38.3.1 Modules

The SWIG %module directive specifies the name of the Ruby module. If you specify:

%module example

then everything is wrapped into a Ruby module named Example that is nested directly under the global module. You can specify a more deeply nested module by specifying the fully-qualified module name in quotes, e.g.

%module "foo::bar::spam"

An alternate method of specifying a nested module name is to use the -prefix option on the SWIG command line. The prefix that you specify with this option will be prepended to the module name specified with the %module directive in your SWIG interface file. So for example, this declaration at the top of your SWIG interface file:

%module "foo::bar::spam"

will result in a nested module name of Foo::Bar::Spam, but you can achieve the same effect by specifying:

%module spam

and then running SWIG with the -prefix command line option:

$ swig -ruby -prefix "foo::bar::" example.i

Starting with SWIG 1.3.20, you can also choose to wrap everything into the global module by specifying the -globalmodule option on the SWIG command line, i.e.

$ swig -ruby -globalmodule example.i

Note that this does not relieve you of the requirement of specifying the SWIG module name with the %module directive (or the -module command-line option) as described earlier.

When choosing a module name, do not use the same name as a built-in Ruby command or standard module name, as the results may be unpredictable. Similarly, if you're using the -globalmodule option to wrap everything into the global module, take care that the names of your constants, classes and methods don't conflict with any of Ruby's built-in names.

38.3.2 Functions

Global functions are wrapped as Ruby module methods. For example, given the SWIG interface file example.i:

%module example

int fact(int n);

and C source file example.c:

int fact(int n) {
  if (n == 0)
  return 1;
  return (n * fact(n-1));
}

SWIG will generate a method fact in the Example module that can be used like so:

$ irb
irb(main):001:0> require 'example'
true
irb(main):002:0> Example.fact(4)
24

38.3.3 Variable Linking

C/C++ global variables are wrapped as a pair of singleton methods for the module: one to get the value of the global variable and one to set it. For example, the following SWIG interface file declares two global variables:

// SWIG interface file with global variables
%module example
...
%inline %{
  extern int variable1;
  extern double Variable2;
%}
...

Now look at the Ruby interface:

$ irb
irb(main):001:0> require 'Example'
true
irb(main):002:0> Example.variable1 = 2
2
irb(main):003:0> Example.Variable2 = 4 * 10.3
41.2
irb(main):004:0> Example.Variable2
41.2

If you make an error in variable assignment, you will receive an error message. For example:

irb(main):005:0> Example.Variable2 = "hello"
TypeError: no implicit conversion to float from string
from (irb):5:in `Variable2='
from (irb):5

If a variable is declared as const, it is wrapped as a read-only variable. Attempts to modify its value will result in an error.

To make ordinary variables read-only, you can also use the %immutable directive. For example:

%immutable;
%inline %{
  extern char *path;
%}
%mutable;

The %immutable directive stays in effect until it is explicitly disabled using %mutable.

38.3.4 Constants

C/C++ constants are wrapped as module constants initialized to the appropriate value. To create a constant, use #define or the %constant directive. For example:

#define PI 3.14159
#define VERSION "1.0"

%constant int FOO = 42;
%constant const char *path = "/usr/local";

const int BAR = 32;

Remember to use the :: operator in Ruby to get at these constant values, e.g.

$ irb
irb(main):001:0> require 'Example'
true
irb(main):002:0> Example::PI
3.14159

38.3.5 Pointers

"Opaque" pointers to arbitrary C/C++ types (i.e. types that aren't explicitly declared in your SWIG interface file) are wrapped as data objects. So, for example, consider a SWIG interface file containing only the declarations:

Foo *get_foo();
void set_foo(Foo *foo);

For this case, the get_foo() method returns an instance of an internally generated Ruby class:

irb(main):001:0> foo = Example::get_foo()
#<SWIG::TYPE_p_Foo:0x402b1654>

A NULL pointer is always represented by the Ruby nil object.

38.3.6 Structures

C/C++ structs are wrapped as Ruby classes, with accessor methods (i.e. "getters" and "setters") for all of the struct members. For example, this struct declaration:

struct Vector {
  double x, y;
};

gets wrapped as a Vector class, with Ruby instance methods x, x=, y and y=. These methods can be used to access structure data from Ruby as follows:

$ irb
irb(main):001:0> require 'Example'
true
irb(main):002:0> f = Example::Vector.new
#<Example::Vector:0x4020b268>
irb(main):003:0> f.x = 10
nil
irb(main):004:0> f.x
10.0

Similar access is provided for unions and the public data members of C++ classes.

const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive (in C++, private may also be used). For example:

struct Foo {
  ...
  %immutable;
  int x; /* Read-only members */
  char *name;
  %mutable;
  ...
};

When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run with the -c++ option). When the structure member is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described shortly).

Array members are normally wrapped as read-only. For example, this code:

struct Foo {
  int x[50];
};

produces a single accessor function like this:

int *Foo_x_get(Foo *self) {
  return self->x;
};

If you want to set an array member, you will need to supply a "memberin" typemap described in the section on typemaps. As a special case, SWIG does generate code to set array members of type char (allowing you to store a Ruby string in the structure).

When structure members are wrapped, they are handled as pointers. For example,

struct Foo {
  ...
};

struct Bar {
  Foo f;
};

generates accessor functions such as this:

Foo *Bar_f_get(Bar *b) {
  return &b->f;
}

void Bar_f_set(Bar *b, Foo *val) {
  b->f = *val;
}

38.3.7 C++ classes

Like structs, C++ classes are wrapped by creating a new Ruby class of the same name with accessor methods for the public class member data. Additionally, public member functions for the class are wrapped as Ruby instance methods, and public static member functions are wrapped as Ruby singleton methods. So, given the C++ class declaration:

class List {
public:
  List();
  ~List();
  int search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int length;
  static void print(List *l);
};

SWIG would create a List class with:

  • instance methods search, insert, remove, and get;
  • instance methods length and length= (to get and set the value of the length data member); and,
  • a print singleton method for the class.

In Ruby, these functions are used as follows:

require 'Example'

l = Example::List.new

l.insert("Ale")
l.insert("Stout")
l.insert("Lager")
Example.print(l)
l.length()
----- produces the following output 
Lager
Stout
Ale
3

38.3.8 C++ Inheritance

The SWIG type-checker is fully aware of C++ inheritance. Therefore, if you have classes like this:

class Parent {
  ...
};

class Child : public Parent {
  ...
};

those classes are wrapped into a hierarchy of Ruby classes that reflect the same inheritance structure. All of the usual Ruby utility methods work normally:

irb(main):001:0> c = Child.new
#<Bar:0x4016efd4>
irb(main):002:0> c.instance_of? Child
true
irb(main):003:0> b.instance_of? Parent
false
irb(main):004:0> b.is_a? Child
true
irb(main):005:0> b.is_a? Parent
true
irb(main):006:0> Child < Parent
true
irb(main):007:0> Child > Parent
false

Furthermore, if you have a function like this:

void spam(Parent *f);

then the function spam() accepts Parent* or a pointer to any class derived from Parent.

Until recently, the Ruby module for SWIG didn't support multiple inheritance, and this is still the default behavior. This doesn't mean that you can't wrap C++ classes which inherit from multiple base classes; it simply means that only the first base class listed in the class declaration is considered, and any additional base classes are ignored. As an example, consider a SWIG interface file with a declaration like this:

class Derived : public Base1, public Base2
{
  ...
};

For this case, the resulting Ruby class (Derived) will only consider Base1 as its superclass. It won't inherit any of Base2's member functions or data and it won't recognize Base2 as an "ancestor" of Derived (i.e. the is_a? relationship would fail). When SWIG processes this interface file, you'll see a warning message like:

example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.
Multiple inheritance is not supported in Ruby.

Starting with SWIG 1.3.20, the Ruby module for SWIG provides limited support for multiple inheritance. Because the approach for dealing with multiple inheritance introduces some limitations, this is an optional feature that you can activate with the -minherit command-line option:

$ swig -c++ -ruby -minherit example.i

Using our previous example, if your SWIG interface file contains a declaration like this:

class Derived : public Base1, public Base2
{
  ...
};

and you run SWIG with the -minherit command-line option, then you will end up with a Ruby class Derived that appears to "inherit" the member data and functions from both Base1 and Base2. What actually happens is that three different top-level classes are created, with Ruby's Object class as their superclass. Each of these classes defines a nested module named Impl, and it's in these nested Impl modules that the actual instance methods for the classes are defined, i.e.

class Base1
  module Impl
  # Define Base1 methods here
  end
  include Impl
end

class Base2
  module Impl
  # Define Base2 methods here
  end
  include Impl
end

class Derived
  module Impl
  include Base1::Impl
  include Base2::Impl
  # Define Derived methods here
  end
  include Impl
end

Observe that after the nested Impl module for a class is defined, it is mixed-in to the class itself. Also observe that the Derived::Impl module first mixes-in its base classes' Impl modules, thus "inheriting" all of their behavior.

The primary drawback is that, unlike the default mode of operation, neither Base1 nor Base2 is a true superclass of Derived anymore:

obj = Derived.new
obj.is_a? Base1 # this will return false...
obj.is_a? Base2 # ... and so will this

In most cases, this is not a serious problem since objects of type Derived will otherwise behave as though they inherit from both Base1 and Base2 (i.e. they exhibit "Duck Typing").

38.3.9 C++ Overloaded Functions

C++ overloaded functions, methods, and constructors are mostly supported by SWIG. For example, if you have two functions like this:

void foo(int);
void foo(char *c);

You can use them in Ruby in a straightforward manner:

irb(main):001:0> foo(3) # foo(int)
irb(main):002:0> foo("Hello") # foo(char *c)

Similarly, if you have a class like this,

class Foo {
public:
  Foo();
  Foo(const Foo &);
  ...
};

you can write Ruby code like this:

irb(main):001:0> f = Foo.new # Create a Foo
irb(main):002:0> g = Foo.new(f) # Copy f

Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG can't disambiguate. For example:

void spam(int);
void spam(short);

or

void foo(Bar *b);
void foo(Bar &b);

If declarations such as these appear, you will get a warning message like this:

example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).

To fix this, you either need to ignore or rename one of the methods. For example:

%rename(spam_short) spam(short);
...
void spam(int); 
void spam(short); // Accessed as spam_short

or

%ignore spam(short);
...
void spam(int); 
void spam(short); // Ignored

SWIG resolves overloaded functions and methods using a disambiguation scheme that ranks and sorts declarations according to a set of type-precedence rules. The order in which declarations appear in the input does not matter except in situations where ambiguity arises--in this case, the first declaration takes precedence.

Please refer to the "SWIG and C++" chapter for more information about overloading.

38.3.10 C++ Operators

For the most part, overloaded operators are handled automatically by SWIG and do not require any special treatment on your part. So if your class declares an overloaded addition operator, e.g.

class Complex {
  ...
  Complex operator+(Complex &);
  ...
};

the resulting Ruby class will also support the addition (+) method correctly.

For cases where SWIG's built-in support is not sufficient, C++ operators can be wrapped using the %rename directive (available on SWIG 1.3.10 and later releases). All you need to do is give the operator the name of a valid Ruby identifier. For example:

%rename(add_complex) operator+(Complex &, Complex &);
...
Complex operator+(Complex &, Complex &);

Now, in Ruby, you can do this:

a = Example::Complex.new(2, 3)
b = Example::Complex.new(4, -1)
c = Example.add_complex(a, b)

More details about wrapping C++ operators into Ruby operators is discussed in the section on operator overloading.

38.3.11 C++ namespaces

SWIG is aware of C++ namespaces, but namespace names do not appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

%module example

namespace foo {
  int fact(int n);
  struct Vector {
    double x,y,z;
  };
};

it works in Ruby as follows:

irb(main):001:0> require 'example'
true
irb(main):002:0> Example.fact(3)
6
irb(main):003:0> v = Example::Vector.new
#<Example::Vector:0x4016f4d4>
irb(main):004:0> v.x = 3.4
3.4
irb(main):004:0> v.y
0.0

If your program has more than one namespace, name conflicts (if any) can be resolved using %rename For example:

%rename(Bar_spam) Bar::spam;

namespace Foo {
  int spam();
}

namespace Bar {
  int spam();
}

If you have more than one namespace and your want to keep their symbols separate, consider wrapping them as separate SWIG modules. For example, make the module name the same as the namespace and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

38.3.12 C++ templates

C++ templates don't present a huge problem for SWIG. However, in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the %template directive. For example:

%module example

%{
#include "pair.h"
%}

template<class T1, class T2>
struct pair {
  typedef T1 first_type;
  typedef T2 second_type;
  T1 first;
  T2 second;
  pair();
  pair(const T1&, const T2&);
  ~pair();
};

%template(Pairii) pair<int,int>;

In Ruby:

irb(main):001:0> require 'example'
true
irb(main):002:0> p = Example::Pairii.new(3, 4)
#<Example:Pairii:0x4016f4df>
irb(main):003:0> p.first
3
irb(main):004:0> p.second
4

38.3.13 C++ Standard Template Library (STL)

On a related note, the standard SWIG library contains a number of modules that provide typemaps for standard C++ library classes (such as std::pair, std::string and std::vector). These library modules don't provide wrappers around the templates themselves, but they do make it convenient for users of your extension module to pass Ruby objects (such as arrays and strings) to wrapped C++ code that expects instances of standard C++ templates. For example, suppose the C++ library you're wrapping has a function that expects a vector of floats:

%module example

float sum(const std::vector<float>& values);

Rather than go through the hassle of writing an "in" typemap to convert an array of Ruby numbers into a std::vector<float>, you can just use the std_vector.i module from the standard SWIG library:

%module example

%include std_vector.i
float sum(const std::vector<float>& values);

Ruby's STL wrappings provide additional methods to make them behave more similarly to Ruby's native classes.

Thus, you can do, for example:

v = IntVector.new
v << 2
v << 3
v << 4
v.each { |x| puts x }

=> 2
3
4
v.delete_if { |x| x == 3 }
=> [2,4]

The SWIG Ruby module provides also the ability for all the STL containers to carry around Ruby native objects (Fixnum, Classes, etc) making them act almost like Ruby's own Array, Hash, etc. To do that, you need to define a container that contains a swig::GC_VALUE, like:

%module nativevector

%{
std::vector< swig::GC_VALUE > NativeVector;
%}

%template(NativeVector) std::vector< swig::GC_VALUE >;

This vector can then contain any Ruby object, making them almost identical to Ruby's own Array class.

require 'nativevector'
include NativeVector

v = NativeVector.new
v << 1
v << [1,2]
v << 'hello'

class A; end

v << A.new

puts v
=> [1, [1,2], 'hello', #<A:0x245325>]

Obviously, there is a lot more to template wrapping than shown in these examples. More details can be found in the SWIG and C++ chapter.

38.3.14 C++ STL Functors

Some containers in the STL allow you to modify their default behavior by using so called functors or function objects. Functors are often just a very simple struct with operator() redefined or an actual C/C++ function. This allows you, for example, to always keep the sort order of a STL container to your liking.

The Ruby STL mappings allows you to modify those containers that support functors using Ruby procs or methods, instead. Currently, this includes std::set, set::map, std::multiset and std::multimap.

The functors in swig are called swig::UnaryFunction and swig::BinaryFunction. For C++ predicates (ie. functors that must return bool as a result) swig::UnaryPredicate and swig::BinaryPredicate are provided.

As an example, if given this swig file:

%module intset;

%include <std_set.i>

%typemap(IntSet) std::set< int, swig::BinaryPredicate >;

You can then use the set from Ruby with or without a proc object as a predicate:

require 'intset'
include Intset

# Default sorting behavior defined in C++
a = IntSet.new
a << 1
a << 2
a << 3
a
=> [1,2,3]

# Custom sorting behavior defined by a Ruby proc
b = IntSet.new( proc { |a,b| a > b } )
b << 1
b << 2
b << 3
b
=>  [3,2,1]

38.3.15 C++ STL Iterators

The STL is well known for the use of iterators. There are a number of iterators possible with different properties, but in general there are two main categories: const iterators and non-const iterators. The const iterators can access and not modify the values they point at, while the non-const iterators can both read and modify the values.

The Ruby STL wrappings support both type of iterators by using a proxy class in-between. This proxy class is swig::Iterator or swig::ConstIterator. Derived from them are template classes that need to be initialized with the actual iterator for the container you are wrapping and often times with the beginning and ending points of the iteration range.

The SWIG STL library already provides typemaps to all the standard containers to do this wrapping automatically for you, but if you have your own STL-like iterator, you will need to write your own typemap for them. For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

These can be used either like:

make_const_iterator( iterator, rubyclass );
make_const_iterator( iterator, iterator_begin, iterator_end, rubyclass );

The iterators support a next() and previous() member function to just change the iterator without returning anything. previous() should obviously only be used for bidirectional iterators. You can also advance the iterator multiple steps by using standard math operations like +=.

The value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. For non-const iterators, a value=() function is also provided which allows you to change the value pointed by the iterator. This is equivalent to the C++ construct of dereferencing and assignment, like *i = something.

Thus, given say a vector class of doubles defined as:

%module doublevector

%include std_vector.i

%template(DoubleVector) std::vector<double>;

Its iterator can then be used from Ruby like:

require 'doublevector'
include Doublevector

v = DoubleVector.new
v << 1
v << 2
v << 3

#
# an elaborate and less efficient way of doing v.map! { |x| x+2 }
#
i = v.begin
e = v.end
while i != e
  val = i.value
  val += 2
  i.value = val
  i.next
end
i
>> [3, 4, 5 ]

If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

38.3.16 C++ Smart Pointers

In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

template<class T> class SmartPtr {
  ...
  T *operator->();
  ...
}

Then, if you have a class like this,

class Foo {
public:
  int x;
  int bar();
};

A smart pointer would be used in C++ as follows:

SmartPtr<Foo> p = CreateFoo(); // Created somehow (not shown)
...
p->x = 3; // Foo::x
int y = p->bar(); // Foo::bar

To wrap this in Ruby, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using %template if necessary. For example:

%module example
...
%template(SmartPtrFoo) SmartPtr<Foo>;
...

Now, in Ruby, everything should just "work":

irb(main):001:0> p = Example::CreateFoo() # Create a smart-pointer somehow
#<Example::SmartPtrFoo:0x4016f4df>
irb(main):002:0> p.x = 3 # Foo::x
3
irb(main):003:0> p.bar() # Foo::bar

If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

irb(main):004:0> f = p.__deref__() # Returns underlying Foo *

38.3.17 Cross-Language Polymorphism

SWIG's Ruby module supports cross-language polymorphism (a.k.a. the "directors" feature) similar to that for SWIG's Python module. Rather than duplicate the information presented in the Python chapter, this section just notes the differences that you need to be aware of when using this feature with Ruby.

38.3.17.1 Exception Unrolling

Whenever a C++ director class routes one of its virtual member function calls to a Ruby instance method, there's always the possibility that an exception will be raised in the Ruby code. By default, those exceptions are ignored, which simply means that the exception will be exposed to the Ruby interpreter. If you would like to change this behavior, you can use the %feature("director:except") directive to indicate what action should be taken when a Ruby exception is raised. The following code should suffice in most cases:

%feature("director:except") {
  throw Swig::DirectorMethodException($error);
}

When this feature is activated, the call to the Ruby instance method is "wrapped" using the rb_rescue2() function from Ruby's C API. If any Ruby exception is raised, it will be caught here and a C++ exception is raised in its place.

38.4 Naming

Ruby has several common naming conventions. Constants are generally in upper case, module and class names are in camel case and methods are in lower case with underscores. For example:

  • MATH::PI is a constant name
  • MyClass is a class name
  • my_method is a method name

Prior to version 1.3.28, SWIG did not support these Ruby conventions. The only modifications it made to names was to capitalize the first letter of constants (which includes module and class names).

SWIG 1.3.28 introduces the new -autorename command line parameter. When this parameter is specified, SWIG will automatically change constant, class and method names to conform with the standard Ruby naming conventions. For example:

$ swig -ruby -autorename example.i

To disable renaming use the -noautorename command line option.

Since this change significantly changes the wrapper code generated by SWIG, it is turned off by default in SWIG 1.3.28. However, it is planned to become the default option in future releases.

38.4.1 Defining Aliases

It's a fairly common practice in the Ruby built-ins and standard library to provide aliases for method names. For example, Array#size is an alias for Array#length. If you would like to provide an alias for one of your class' instance methods, one approach is to use SWIG's %extend directive to add a new method of the aliased name that calls the original function. For example:

class MyArray {
public:
  // Construct an empty array
  MyArray();

  // Return the size of this array
  size_t length() const;
};

%extend MyArray {
  // MyArray#size is an alias for MyArray#length
  size_t size() const {
    return $self->length();
  }
}
 

A better solution is to use the %alias directive (unique to SWIG's Ruby module). The previous example could then be rewritten as:

// MyArray#size is an alias for MyArray#length
%alias MyArray::length "size";

class MyArray {
public:
  // Construct an empty array
  MyArray();
 
  // Return the size of this array
  size_t length() const;
};

Multiple aliases can be associated with a method by providing a comma-separated list of aliases to the %alias directive, e.g.

%alias MyArray::length "amount,quantity,size";

From an end-user's standpoint, there's no functional difference between these two approaches; i.e. they should get the same result from calling either MyArray#size or MyArray#length. However, when the %alias directive is used, SWIG doesn't need to generate all of the wrapper code that's usually associated with added methods like our MyArray::size() example.

Note that the %alias directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

38.4.2 Predicate Methods

Ruby methods that return a boolean value and end in a question mark are known as predicate methods. Examples of predicate methods in standard Ruby classes include Array#empty? (which returns true for an array containing no elements) and Object#instance_of? (which returns true if the object is an instance of the specified class). For consistency with Ruby conventions, methods that return boolean values should be marked as predicate methods.

One cumbersome solution to this problem is to rename the method (using SWIG's %rename directive) and provide a custom typemap that converts the function's actual return type to Ruby's true or false. For example:

%rename("is_it_safe?") is_it_safe();

%typemap(out) int is_it_safe "$result = ($1 != 0) ? Qtrue : Qfalse;";

int is_it_safe();

A better solution is to use the %predicate directive (unique to SWIG's Ruby module) to designate a method as a predicate method. For the previous example, this would look like:

%predicate is_it_safe();

int is_it_safe();

This method would be invoked from Ruby code like this:

irb(main):001:0> Example::is_it_safe?
true

The %predicate directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

38.4.3 Bang Methods

Ruby methods that modify an object in-place and end in an exclamation mark are known as bang methods. An example of a bang method is Array#sort! which changes the ordering of items in an array. Contrast this with Array#sort, which returns a copy of the array with the items sorted instead of modifying the original array. For consistency with Ruby conventions, methods that modify objects in place should be marked as bang methods.

Bang methods can be marked using the %bang directive which is unique to the Ruby module and was introduced in SWIG 1.3.28. For example:

%bang sort(int arr[]);

int sort(int arr[]); 

This method would be invoked from Ruby code like this:

irb(main):001:0> Example::sort!(arr)

The %bang directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

38.4.4 Getters and Setters

Often times a C++ library will expose properties through getter and setter methods. For example:

class Foo {
  Foo() {}
  int getValue() { return value_; }
  void setValue(int value) { value_ = value; }

private:
  int value_;
};

By default, SWIG will expose these methods to Ruby as get_value and set_value. However, it more natural for these methods to be exposed in Ruby as value and value=. That allows the methods to be used like this:

irb(main):001:0> foo = Foo.new()
irb(main):002:0> foo.value = 5
irb(main):003:0> puts foo.value

This can be done by using the %rename directive:

%rename("value") Foo::getValue();
%rename("value=") Foo::setValue(int value);

38.5 Input and output parameters

A common problem in some C programs is handling parameters passed as simple pointers. For example:

void add(int x, int y, int *result) {
  *result = x + y;
}

or

int sub(int *x, int *y) {
  return *x-*y;
}

The easiest way to handle these situations is to use the typemaps.i file. For example:

%module Example
%include "typemaps.i"

void add(int, int, int *OUTPUT);
int sub(int *INPUT, int *INPUT);

In Ruby, this allows you to pass simple values. For example:

a = Example.add(3,4)
puts a
7
b = Example.sub(7,4)
puts b
3

Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter creates a return result.

If you don't want to use the names INPUT or OUTPUT, use the %apply directive. For example:

%module Example
%include "typemaps.i"

%apply int *OUTPUT { int *result };
%apply int *INPUT { int *x, int *y};

void add(int x, int y, int *result);
int sub(int *x, int *y);

If a function mutates one of its parameters like this,

void negate(int *x) {
 *x = -(*x);
}

you can use INOUT like this:

%include "typemaps.i"
...
void negate(int *INOUT);

In Ruby, a mutated parameter shows up as a return value. For example:

a = Example.negate(3)
print a
-3

The most common use of these special typemap rules is to handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

/* send message, return number of bytes sent, success code, and error_code */
int send_message(char *text, int *success, int *error_code);

To wrap such a function, simply use the OUTPUT rule above. For example:

%module example
%include "typemaps.i"
...
int send_message(char *, int *OUTPUT, int *OUTPUT);

When used in Ruby, the function will return an array of multiple values.

bytes, success, error_code = send_message("Hello World")
if not success
  print "error #{error_code} : in send_message"
else
  print "Sent", bytes
end

Another way to access multiple return values is to use the %apply rule. In the following example, the parameters rows and columns are related to SWIG as OUTPUT values through the use of %apply

%module Example
%include "typemaps.i"
%apply int *OUTPUT { int *rows, int *columns };
...
void get_dimensions(Matrix *m, int *rows, int*columns);

In Ruby:

r, c = Example.get_dimensions(m)

38.6 Exception handling

38.6.1 Using the %exception directive

The SWIG %exception directive can be used to define a user-definable exception handler that can convert C/C++ errors into Ruby exceptions. The chapter on Customization Features contains more details, but suppose you have a C++ class like the following :

class DoubleArray {
private:
  int n;
  double *ptr;
public:
  // Create a new array of fixed size
  DoubleArray(int size) {
    ptr = new double[size];
    n = size;
  }
 
  // Destroy an array
  ~DoubleArray() {
    delete ptr;
  } 
 
  // Return the length of the array
  int length() {
    return n;
  }
 
  // Get an array item and perform bounds checking.
  double getitem(int i) {
    if ((i >= 0) && (i < n))
      return ptr[i];
    else
      throw RangeError();
  }
 
  // Set an array item and perform bounds checking.
  void setitem(int i, double val) {
    if ((i >= 0) && (i < n))
      ptr[i] = val;
    else {
      throw RangeError();
    }
  }
};

Since several methods in this class can throw an exception for an out-of-bounds access, you might want to catch this in the Ruby extension by writing the following in an interface file:

%exception {
  try {
    $action
  }
  catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error.");
  }
}

class DoubleArray {
  ...
};

The exception handling code is inserted directly into generated wrapper functions. When an exception handler is defined, errors can be caught and used to gracefully raise a Ruby exception instead of forcing the entire program to terminate with an uncaught error.

As shown, the exception handling code will be added to every wrapper function. Because this is somewhat inefficient, you might consider refining the exception handler to only apply to specific methods like this:

%exception getitem {
  try {
    $action
  } catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in getitem.");
  }
}
 
%exception setitem {
  try {
    $action
  } catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in setitem.");
  }
}

In this case, the exception handler is only attached to methods and functions named getitem and setitem.

Since SWIG's exception handling is user-definable, you are not limited to C++ exception handling. See the chapter on Customization Features for more examples.

38.6.2 Handling Ruby Blocks

One of the highlights of Ruby and most of its standard library is the use of blocks, which allow the easy creation of continuations and other niceties. Blocks in ruby are also often used to simplify the passing of many arguments to a class.

In order to make your class constructor support blocks, you can take advantage of the %exception directive, which will get run after the C++ class' constructor was called.

For example, this yields the class over after its construction:

class Window
{
public:
  Window(int x, int y, int w, int h);
  // .... other methods here ....
};

// Add support for yielding self in the Class' constructor.
%exception Window::Window {
  $action
  if (rb_block_given_p()) {
    rb_yield(self);
  }
}

Then, in ruby, it can be used like:

Window.new(0,0,360,480) { |w|
  w.color = Fltk::RED
  w.border = false
}

For other methods, you can usually use a dummy parameter with a special in typemap, like:

//
// original function was:
//
// void func(int x);

%typemap(in,numinputs=0) int RUBY_YIELD_SELF {
  if ( !rb_block_given_p() )
    rb_raise("No block given");
  return rb_yield(self);
}

%extend {
  void func(int x, int RUBY_YIELD_SELF );
}

For more information on typemaps, see Typemaps.

38.6.3 Raising exceptions

There are three ways to raise exceptions from C++ code to Ruby.

The first way is to use SWIG_exception(int code, const char *msg). The following table shows the mappings from SWIG error codes to Ruby exceptions:

SWIG_MemoryError
rb_eNoMemError
SWIG_IOError
rb_eIOError
SWIG_RuntimeError
rb_eRuntimeError
SWIG_IndexError
rb_eIndexError
SWIG_TypeError
rb_eTypeError
SWIG_DivisionByZero
rb_eZeroDivError
SWIG_OverflowError
rb_eRangeError
SWIG_SyntaxError
rb_eSyntaxError
SWIG_ValueError
rb_eArgError
SWIG_SystemError
rb_eFatal
SWIG_AttributeError
rb_eRuntimeError
SWIG_NullReferenceError
rb_eNullReferenceError*
SWIG_ObjectPreviouslyDeletedError
rb_eObjectPreviouslyDeleted*
SWIG_UnknownError
rb_eRuntimeError
* These error classes are created by SWIG and are not built-in Ruby exception classes

The second way to raise errors is to use SWIG_Raise(obj, type, desc). Obj is a C++ instance of an exception class, type is a string specifying the type of exception (for example, "MyError") and desc is the SWIG description of the exception class. For example:

%raise(SWIG_NewPointerObj(e, SWIGTYPE_p_AssertionFailedException, 0), ":AssertionFailedException", SWIGTYPE_p_AssertionFailedException);

This is useful when you want to pass the current exception object directly to Ruby, particularly when the object is an instance of class marked as an %exceptionclass (see the next section for more information).

Last, you can raise an exception by directly calling Ruby's C api. This is done by invoking the rb_raise() function. The first argument passed to rb_raise() is the exception type. You can raise a custom exception type or one of the built-in Ruby exception types.

38.6.4 Exception classes

Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass directive, which is used to identify C++ classes that are used as exceptions. Classes that are marked with the %exceptionclass directive are exposed in Ruby as child classes of rb_eRuntimeError. This allows C++ exceptions to be directly mapped to Ruby exceptions, providing for a more natural integration between C++ code and Ruby code.

%exceptionclass CustomError;

%inline %{
  class CustomError { };

  class Foo { 
  public:
    void test() { throw CustomError; }
  };
%}

From Ruby you can now call this method like this:

foo = Foo.new
begin
  foo.test()
rescue CustomError => e
  puts "Caught custom error"
end 

For another example look at swig/Examples/ruby/exception_class.

38.7 Typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Ruby C API as well as the material in the "Typemaps" chapter.

Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the primitive C-Ruby interface.

38.7.1 What is a typemap?

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. The general form of this declaration is as follows ( parts enclosed in [...] are optional ):

%typemap( method [, modifiers...] ) typelist code;

method is a simply a name that specifies what kind of typemap is being defined. It is usually a name like "in", "out", or "argout" (or its director variations). The purpose of these methods is described later.

modifiers is an optional comma separated list of name="value" values. These are sometimes to attach extra information to a typemap and is often target-language dependent.

typelist is a list of the C++ type patterns that the typemap will match. The general form of this list is as follows:

typelist : typepattern [, typepattern, typepattern, ... ] ;

typepattern : type [ (parms) ]
  | type name [ (parms) ]
  | ( typelist ) [ (parms) ]

Each type pattern is either a simple type, a simple type and argument name, or a list of types in the case of multi-argument typemaps. In addition, each type pattern can be parameterized with a list of temporary variables (parms). The purpose of these variables will be explained shortly.

code specifies the C code used in the typemap. It can take any one of the following forms:

code : { ... }
  | " ... "
  | %{ ... %}

For example, to convert integers from Ruby to C, you might define a typemap like this:

%module example

%typemap(in) int {
  $1 = (int) NUM2INT($input);
  printf("Received an integer : %d\n",$1);
}

%inline %{
  extern int fact(int n);
%}

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variables prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input variable is the input Ruby object.

When this example is compiled into a Ruby module, the following sample code:

require 'example'

puts Example.fact(6)

prints the result:

Received an integer : 6
720

In this example, the typemap is applied to all occurrences of the int datatype. You can refine this by supplying an optional parameter name. For example:

%module example

%typemap(in) int n {
  $1 = (int) NUM2INT($input);
  printf("n = %d\n",$1);
}

%inline %{
  extern int fact(int n);
%}

In this case, the typemap code is only attached to arguments that exactly match "int n".

The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG type-system. When you define a typemap for int, that typemap applies to int and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

%typemap(in) int n {
  $1 = (int) NUM2INT($input);
  printf("n = %d\n",$1);
}

typedef int Integer;
extern int fact(Integer n); // Above typemap is applied

However, the matching of typedef only occurs in one direction. If you defined a typemap for Integer, it is not applied to arguments of type int.

Typemaps can also be defined for groups of consecutive arguments. For example:

%typemap(in) (char *str, int len) {
  $1 = StringValuePtr($input);
  $2 = (int) RSTRING($input)->len;
};

int count(char c, char *str, int len);

When a multi-argument typemap is defined, the arguments are always handled as a single Ruby object. This allows the function count to be used as follows (notice how the length parameter is omitted):

puts Example.count('o','Hello World')
2

38.7.2 Typemap scope

Once defined, a typemap remains in effect for all of the declarations that follow. A typemap may be redefined for different sections of an input file. For example:

// typemap1
%typemap(in) int {
  ...
}

int fact(int); // typemap1
int gcd(int x, int y); // typemap1

// typemap2
%typemap(in) int {
  ...
}

int isprime(int); // typemap2

One exception to the typemap scoping rules pertains to the %extend declaration. %extend is used to attach new declarations to a class or structure definition. Because of this, all of the declarations in an %extend block are subject to the typemap rules that are in effect at the point where the class itself is defined. For example:

class Foo {
  ...
};

%typemap(in) int {
  ...
}

%extend Foo {
  int blah(int x); // typemap has no effect. Declaration is attached to Foo which 
  // appears before the %typemap declaration.
};

38.7.3 Copying a typemap

A typemap is copied by using assignment. For example:

%typemap(in) Integer = int;

or this:

%typemap(in) Integer, Number, int32_t = int;

Types are often managed by a collection of different typemaps. For example:

%typemap(in) int { ... }
%typemap(out) int { ... }
%typemap(varin) int { ... }
%typemap(varout) int { ... }

To copy all of these typemaps to a new type, use %apply. For example:

%apply int { Integer }; // Copy all int typemaps to Integer
%apply int { Integer, Number }; // Copy all int typemaps to both Integer and Number

The patterns for %apply follow the same rules as for %typemap. For example:

%apply int *output { Integer *output }; // Typemap with name
%apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments

38.7.4 Deleting a typemap

A typemap can be deleted by simply defining no code. For example:

%typemap(in) int; // Clears typemap for int
%typemap(in) int, long, short; // Clears typemap for int, long, short
%typemap(in) int *output; 

The %clear directive clears all typemaps for a given type. For example:

%clear int; // Removes all types for int
%clear int *output, long *output;

Note: Since SWIG's default behavior is defined by typemaps, clearing a fundamental type like int will make that type unusable unless you also define a new set of typemaps immediately after the clear operation.

38.7.5 Placement of typemaps

Typemap declarations can be declared in the global scope, within a C++ namespace, and within a C++ class. For example:

%typemap(in) int {
  ...
}

namespace std {
  class string;
  %typemap(in) string {
    ...
  }
}

class Bar {
public:
  typedef const int & const_reference;
  %typemap(out) const_reference {
    ...
  }
};

When a typemap appears inside a namespace or class, it stays in effect until the end of the SWIG input (just like before). However, the typemap takes the local scope into account. Therefore, this code

namespace std {
  class string;
  %typemap(in) string {
    ...
  }
}

is really defining a typemap for the type std::string. You could have code like this:

namespace std {
  class string;
  %typemap(in) string { /* std::string */
  ...
  }
}

namespace Foo {
  class string;
  %typemap(in) string { /* Foo::string */
  ...
  }
}

In this case, there are two completely distinct typemaps that apply to two completely different types (std::string and Foo::string).

It should be noted that for scoping to work, SWIG has to know that string is a typename defined within a particular namespace. In this example, this is done using the class declaration class string .

38.7.6 Ruby typemaps

The following list details all of the typemap methods that can be used by the Ruby module:

38.7.6.1 "in" typemap

Converts Ruby objects to input function arguments. For example:

%typemap(in) int {
  $1 = NUM2INT($input);
}

The following special variables are available:

$input Input object holding value to be converted.
$symname Name of function/method being wrapped
$1...n Argument being sent to the function
$1_name Name of the argument (if provided)
$1_type The actual C datatype matched by the typemap.
$1_ltype The assignable version of the C datatype matched by the typemap.

This is probably the most commonly redefined typemap because it can be used to implement customized conversions.

In addition, the "in" typemap allows the number of converted arguments to be specified. For example:

// Ignored argument.
%typemap(in, numinputs=0) int *out (int temp) {
  $1 = &temp;
}

At this time, only zero or one arguments may be converted.

38.7.6.2 "typecheck" typemap

The "typecheck" typemap is used to support overloaded functions and methods. It merely checks an argument to see whether or not it matches a specific type. For example:

%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) int {
  $1 = FIXNUM_P($input) ? 1 : 0;
}

For typechecking, the $1 variable is always a simple integer that is set to 1 or 0 depending on whether or not the input argument is the correct type.

If you define new "in" typemaps and your program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading."

38.7.6.3 "out" typemap

Converts return value of a C function to a Ruby object.

%typemap(out) int {
  $result = INT2NUM( $1 );
}

The following special variables are available.

$result Result object returned to target language.
$symname Name of function/method being wrapped
$1...n Argument being wrapped
$1_name Name of the argument (if provided)
$1_type The actual C datatype matched by the typemap.
$1_ltype The assignable version of the C datatype matched by the typemap.

38.7.6.4 "arginit" typemap

The "arginit" typemap is used to set the initial value of a function argument--before any conversion has occurred. This is not normally necessary, but might be useful in highly specialized applications. For example:

// Set argument to NULL before any conversion occurs
%typemap(arginit) int *data {
  $1 = NULL;
}

38.7.6.5 "default" typemap

The "default" typemap is used to turn an argument into a default argument. For example:

%typemap(default) int flags {
  $1 = DEFAULT_FLAGS;
}
...
int foo(int x, int y, int flags);

The primary use of this typemap is to either change the wrapping of default arguments or specify a default argument in a language where they aren't supported (like C). Target languages that do not support optional arguments, such as Java and C#, effectively ignore the value specified by this typemap as all arguments must be given.

Once a default typemap has been applied to an argument, all arguments that follow must have default values. See the Default/optional arguments section for further information on default argument wrapping.

38.7.6.6 "check" typemap

The "check" typemap is used to supply value checking code during argument conversion. The typemap is applied after arguments have been converted. For example:

%typemap(check) int positive {
  if ($1 <= 0) {
    SWIG_exception(SWIG_ValueError,"Expected positive value.");
  }
}

38.7.6.7 "argout" typemap

The "argout" typemap is used to return values from arguments. This is most commonly used to write wrappers for C/C++ functions that need to return multiple values. The "argout" typemap is almost always combined with an "in" typemap---possibly to ignore the input value. For example:

/* Set the input argument to point to a temporary variable */
%typemap(in, numinputs=0) int *out (int temp) {
  $1 = &temp;
}

%typemap(argout, fragment="output_helper") int *out {
  // Append output value $1 to $result (assuming a single integer in this case)
  $result = output_helper( $result, INT2NUM(*$1) );
}

The following special variables are available.

$result Result object returned to target language.
$input The original input object passed.
$symname Name of function/method being wrapped.

The code supplied to the "argout" typemap is always placed after the "out" typemap. If multiple return values are used, the extra return values are often appended to return value of the function.

Output helper is a fragment that usually defines a macro to some function like SWIG_Ruby_AppendOutput.

See the typemaps.i library for examples.

38.7.6.8 "freearg" typemap

The "freearg" typemap is used to cleanup argument data. It is only used when an argument might have allocated resources that need to be cleaned up when the wrapper function exits. The "freearg" typemap usually cleans up argument resources allocated by the "in" typemap. For example:

// Get a list of integers
%typemap(in) int *items {
  int nitems = Length($input); 
  $1 = (int *) malloc(sizeof(int)*nitems);
}
// Free the list 
%typemap(freearg) int *items {
  free($1);
}

The "freearg" typemap inserted at the end of the wrapper function, just before control is returned back to the target language. This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.

38.7.6.9 "newfree" typemap

The "newfree" typemap is used in conjunction with the %newobject directive and is used to deallocate memory used by the return result of a function. For example:

%typemap(newfree) string * {
  delete $1;
}
%typemap(out) string * {
  $result = PyString_FromString($1->c_str());
}
...

%newobject foo;
...
string *foo();

See Object ownership and %newobject for further details.

38.7.6.10 "memberin" typemap

The "memberin" typemap is used to copy data from an already converted input value into a structure member. It is typically used to handle array members and other special cases. For example:

%typemap(memberin) int [4] {
  memmove($1, $input, 4*sizeof(int));
}

It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

38.7.6.11 "varin" typemap

The "varin" typemap is used to convert objects in the target language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

38.7.6.12 "varout" typemap

The "varout" typemap is used to convert a C/C++ object to an object in the target language when reading a C/C++ global variable. This is implementation specific.

38.7.6.13 "throws" typemap

The "throws" typemap is only used when SWIG parses a C++ method with an exception specification or has the %catches feature attached to the method. It provides a default mechanism for handling C++ methods that have declared the exceptions they will throw. The purpose of this typemap is to convert a C++ exception into an error or exception in the target language. It is slightly different to the other typemaps as it is based around the exception type rather than the type of a parameter or variable. For example:

%typemap(throws) const char * %{
  rb_raise(rb_eRuntimeError, $1);
  SWIG_fail;
%}
void bar() throw (const char *);

As can be seen from the generated code below, SWIG generates an exception handler with the catch block comprising the "throws" typemap content.

...
try {
  bar();
}
catch(char const *_e) {
  rb_raise(rb_eRuntimeError, _e);
  SWIG_fail;
}
...

Note that if your methods do not have an exception specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.

38.7.6.14 directorin typemap

Converts C++ objects in director member functions to ruby objects. It is roughly the opposite of the "in" typemap, making its typemap rule often similar to the "out" typemap.

%typemap(directorin) int {
  $result = INT2NUM($1);
}

The following special variables are available.

$result Result object returned to target language.
$symname Name of function/method being wrapped
$1...n Argument being wrapped
$1_name Name of the argument (if provided)
$1_type The actual C datatype matched by the typemap.
$1_ltype The assignable version of the C datatype matched by the typemap.
this C++ this, referring to the class itself.

38.7.6.15 directorout typemap

Converts Ruby objects in director member functions to C++ objects. It is roughly the opposite of the "out" typemap, making its rule often similar to the "in" typemap.

%typemap(directorout) int {
  $result = NUM2INT($1);
}

The following special variables are available:

$input Ruby object being sent to the function
$symname Name of function/method being wrapped
$1...n Argument being sent to the function
$1_name Name of the argument (if provided)
$1_type The actual C datatype matched by the typemap.
$1_ltype The assignable version of the C datatype matched by the typemap.
this C++ this, referring to the class itself.

Currently, the directorout nor the out typemap support the option numoutputs, but the Ruby module provides that functionality through a %feature directive. Thus, a function can be made to return "nothing" if you do:

%feature("numoutputs","0") MyClass::function;

This feature can be useful if a function returns a status code, which you want to discard but still use the typemap to raise an exception.

38.7.6.16 directorargout typemap

Output argument processing in director member functions.

%typemap(directorargout,
fragment="output_helper") int {
  $result = output_helper( $result, NUM2INT($1) );
}

The following special variables are available:

$result Result that the director function returns
$input Ruby object being sent to the function
$symname name of the function/method being wrapped
$1...n Argument being sent to the function
$1_name Name of the argument (if provided)
$1_type The actual C datatype matched by the typemap
$1_ltype The assignable version of the C datatype matched by the typemap
this C++ this, referring to the instance of the class itself

38.7.6.17 ret typemap

Cleanup of function return values

38.7.6.18 globalin typemap

Setting of C global variables

38.7.7 Typemap variables

Within a typemap, a number of special variables prefaced with a $ may appear. A full list of variables can be found in the "Typemaps" chapter. This is a list of the most common variables:

$1

A C local variable corresponding to the actual type specified in the %typemap directive. For input values, this is a C local variable that is supposed to hold an argument value. For output values, this is the raw result that is supposed to be returned to Ruby.

$input

A VALUE holding a raw Ruby object with an argument or variable value.

$result

A VALUE that holds the result to be returned to Ruby.

$1_name

The parameter name that was matched.

$1_type

The actual C datatype matched by the typemap.

$1_ltype

An assignable version of the datatype matched by the typemap (a type that can appear on the left-hand-side of a C assignment operation). This type is stripped of qualifiers and may be an altered version of $1_type. All arguments and local variables in wrapper functions are declared using this type so that their values can be properly assigned.

$symname

The Ruby name of the wrapper function being created.

38.7.8 Useful Functions

When you write a typemap, you usually have to work directly with Ruby objects. The following functions may prove to be useful. (These functions plus many more can be found in Programming Ruby book, by David Thomas and Andrew Hunt.)

In addition, we list equivalent functions that SWIG defines, which provide a language neutral conversion (these functions are defined for each swig language supported). If you are trying to create a swig file that will work under multiple languages, it is recommended you stick to the swig functions instead of the native Ruby functions. That should help you avoid having to rewrite a lot of typemaps across multiple languages.

38.7.8.1 C Datatypes to Ruby Objects

RUBY SWIG
INT2NUM(long or int) SWIG_From_int(int x) int to Fixnum or Bignum
INT2FIX(long or int) int to Fixnum (faster than INT2NUM)
CHR2FIX(char) SWIG_From_char(char x) char to Fixnum
rb_str_new2(char*) SWIG_FromCharPtrAndSize(char*, size_t) char* to String
rb_float_new(double) SWIG_From_double(double),
SWIG_From_float(float)
float/double to Float

38.7.8.2 Ruby Objects to C Datatypes

Here, while the Ruby versions return the value directly, the SWIG versions do not, but return a status value to indicate success (SWIG_OK). While more akward to use, this allows you to write typemaps that report more helpful error messages, like:

%typemap(in) size_t (int ok)
  ok = SWIG_AsVal_size_t($input, &$1);
  if (!SWIG_IsOK(ok)) {
    SWIG_exception_fail(SWIG_ArgError(ok), Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input));
  }
}
int NUM2INT(Numeric) SWIG_AsVal_int(VALUE, int*)
int FIX2INT(Numeric) SWIG_AsVal_int(VALUE, int*)
unsigned int NUM2UINT(Numeric) SWIG_AsVal_unsigned_SS_int(VALUE, int*)
unsigned int FIX2UINT(Numeric) SWIG_AsVal_unsigned_SS_int(VALUE, int*)
long NUM2LONG(Numeric) SWIG_AsVal_long(VALUE, long*)
long FIX2LONG(Numeric) SWIG_AsVal_long(VALUE, long*)
unsigned long FIX2ULONG(Numeric) SWIG_AsVal_unsigned_SS_long(VALUE, unsigned long*)
char NUM2CHR(Numeric or String) SWIG_AsVal_char(VALUE, int*)
char * StringValuePtr(String) SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc)
char * rb_str2cstr(String, int*length)
double NUM2DBL(Numeric) (double) SWIG_AsVal_int(VALUE) or similar

38.7.8.3 Macros for VALUE

RSTRING_LEN(str)

length of the Ruby string

RSTRING_PTR(str)

pointer to string storage

RARRAY_LEN(arr)

length of the Ruby array

RARRAY(arr)->capa

capacity of the Ruby array

RARRAY_PTR(arr)

pointer to array storage

38.7.8.4 Exceptions

void rb_raise(VALUE exception, const char *fmt, ...)

Raises an exception. The given format string fmt and remaining arguments are interpreted as with printf().

void rb_fatal(const char *fmt, ...)

Raises a fatal exception, terminating the process. No rescue blocks are called, but ensure blocks will be called. The given format string fmt and remaining arguments are interpreted as with printf().

void rb_bug(const char *fmt, ...)

Terminates the process immediately -- no handlers of any sort will be called. The given format string fmt and remaining arguments are interpreted as with printf(). You should call this function only if a fatal bug has been exposed.

void rb_sys_fail(const char *msg)

Raises a platform-specific exception corresponding to the last known system error, with the given string msg.

VALUE rb_rescue(VALUE (*body)(VALUE), VALUE args, VALUE(*rescue)(VALUE, VALUE), VALUE rargs)

Executes body with the given args. If a StandardError exception is raised, then execute rescue with the given rargs.

VALUE rb_ensure(VALUE(*body)(VALUE), VALUE args, VALUE(*ensure)(VALUE), VALUE eargs)

Executes body with the given args. Whether or not an exception is raised, execute ensure with the given rargs after body has completed.

VALUE rb_protect(VALUE (*body)(VALUE), VALUE args, int *result)

Executes body with the given args and returns nonzero in result if any exception was raised.

void rb_notimplement()

Raises a NotImpError exception to indicate that the enclosed function is not implemented yet, or not available on this platform.

void rb_exit(int status)

Exits Ruby with the given status. Raises a SystemExit exception and calls registered exit functions and finalizers.

void rb_warn(const char *fmt, ...)

Unconditionally issues a warning message to standard error. The given format string fmt and remaining arguments are interpreted as with printf().

void rb_warning(const char *fmt, ...)

Conditionally issues a warning message to standard error if Ruby was invoked with the -w flag. The given format string fmt and remaining arguments are interpreted as with printf().

38.7.8.5 Iterators

void rb_iter_break()

Breaks out of the enclosing iterator block.

VALUE rb_each(VALUE obj)

Invokes the each method of the given obj.

VALUE rb_yield(VALUE arg)

Transfers execution to the iterator block in the current context, passing arg as an argument. Multiple values may be passed in an array.

int rb_block_given_p()

Returns true if yield would execute a block in the current context; that is, if a code block was passed to the current method and is available to be called.

VALUE rb_iterate(VALUE (*method)(VALUE), VALUE args, VALUE (*block)(VALUE, VALUE), VALUE arg2)

Invokes method with argument args and block block. A yield from that method will invoke block with the argument given to yield, and a second argument arg2.

VALUE rb_catch(const char *tag, VALUE (*proc)(VALUE, VALUE), VALUE value)

Equivalent to Ruby's catch.

void rb_throw(const char *tag, VALUE value)

Equivalent to Ruby's throw.

38.7.9 Typemap Examples

This section includes a few examples of typemaps. For more examples, you might look at the examples in the Example/ruby directory.

38.7.10 Converting a Ruby array to a char **

A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Ruby Array instance to be used as a char ** object.

%module argv

// This tells SWIG to treat char ** as a special case
%typemap(in) char ** {
  /* Get the length of the array */
  int size = RARRAY($input)->len; 
  int i;
  $1 = (char **) malloc((size+1)*sizeof(char *));
  /* Get the first element in memory */
  VALUE *ptr = RARRAY($input)->ptr; 
  for (i=0; i < size; i++, ptr++) {
    /* Convert Ruby Object String to char* */
    $1[i]= StringValuePtr(*ptr); 
  }
  $1[i]=NULL; /* End of list */
}

// This cleans up the char ** array created before 
// the function call

%typemap(freearg) char ** {
  free((char *) $1);
}

// Now a test function
%inline %{
int print_args(char **argv) {
  int i = 0;
  while (argv[i]) {
    printf("argv[%d] = %s\n", i,argv[i]);
    i++;
  }
  return i;
}
%}

When this module is compiled, the wrapped C function now operates as follows :

require 'Argv'
Argv.print_args(["Dave","Mike","Mary","Jane","John"])
argv[0] = Dave
argv[1] = Mike
argv[2] = Mary
argv[3] = Jane
argv[4] = John

In the example, two different typemaps are used. The "in" typemap is used to receive an input argument and convert it to a C array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

38.7.11 Collecting arguments in a hash

Ruby's solution to the "keyword arguments" capability of some other languages is to allow the programmer to pass in one or more key-value pairs as arguments to a function. All of those key-value pairs are collected in a single Hash argument that's presented to the function. If it makes sense, you might want to provide similar functionality for your Ruby interface. For example, suppose you'd like to wrap this C function that collects information about people's vital statistics:

void setVitalStats(const char *person, int nattributes, const char **names, int *values);

and you'd like to be able to call it from Ruby by passing in an arbitrary number of key-value pairs as inputs, e.g.

setVitalStats("Fred", 
  'weight' => 270, 
  'age' => 42 
)

To make this work, you need to write a typemap that expects a Ruby Hash as its input and somehow extracts the last three arguments (nattributes, names and values) needed by your C function. Let's start with the basics:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
}
 

This %typemap directive tells SWIG that we want to match any function declaration that has the specified types and names of arguments somewhere in the argument list. The fact that we specified the argument names (nattributes, names and values) in our typemap is significant; this ensures that SWIG won't try to apply this typemap to other functions it sees that happen to have a similar declaration with different argument names. The arguments that appear in the second set of parentheses (keys_arr, i, key and val) define local variables that our typemap will need.

Since we expect the input argument to be a Hash, let's next add a check for that:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
}

Check_Type() is just a macro (defined in the Ruby header files) that confirms that the input argument is of the correct type; if it isn't, an exception will be raised.

The next task is to determine how many key-value pairs are present in the hash; we'll assign this number to the first typemap argument ($1). This is a little tricky since the Ruby/C API doesn't provide a public function for querying the size of a hash, but we can get around that by calling the hash's size method directly and converting its result to a C int value:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
}

So now we know the number of attributes. Next we need to initialize the second and third typemap arguments (i.e. the two C arrays) to NULL and set the stage for extracting the keys and values from the hash:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
    }
}

There are a number of ways we could extract the keys and values from the input hash, but the simplest approach is to first call the hash's keys method (which returns a Ruby array of the keys) and then start looping over the elements in that array:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
      for (i = 0; i < $1; i++) {
      }
    }
}

Recall that keys_arr and i are local variables for this typemap. For each element in the keys_arr array, we want to get the key itself, as well as the value corresponding to that key in the hash:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
      for (i = 0; i < $1; i++) {
        key = rb_ary_entry(keys_arr, i);
        val = rb_hash_aref($input, key);
      }
    }
}

To be safe, we should again use the Check_Type() macro to confirm that the key is a String and the value is a Fixnum:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
      for (i = 0; i < $1; i++) {
        key = rb_ary_entry(keys_arr, i);
        val = rb_hash_aref($input, key);
        Check_Type(key, T_STRING);
        Check_Type(val, T_FIXNUM);
      }
    }
}

Finally, we can convert these Ruby objects into their C equivalents and store them in our local C arrays:

%typemap(in) (int nattributes, const char **names, const int *values)
  (VALUE keys_arr, int i, VALUE key, VALUE val) {
  Check_Type($input, T_HASH);
  $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
  $2 = NULL;
  $3 = NULL;
  if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
      key = rb_ary_entry(keys_arr, i);
      val = rb_hash_aref($input, key);
      Check_Type(key, T_STRING);
      Check_Type(val, T_FIXNUM);
      $2[i] = StringValuePtr(key);
      $3[i] = NUM2INT(val);
    }
  }
}

We're not done yet. Since we used malloc() to dynamically allocate the memory used for the names and values arguments, we need to provide a corresponding "freearg" typemap to free that memory so that there is no memory leak. Fortunately, this typemap is a lot easier to write:

%typemap(freearg) (int nattributes, const char **names, const int *values) {
  free((void *) $2);
  free((void *) $3);
}

All of the code for this example, as well as a sample Ruby program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution.

38.7.12 Pointer handling

Occasionally, it might be necessary to convert pointer values that have been stored using the SWIG typed-pointer representation. Since there are several ways in which pointers can be represented, the following two functions are used to safely perform this conversion:

int SWIG_ConvertPtr(VALUE obj, void **ptr, swig_type_info *ty, int flags)

Converts a Ruby object obj to a C pointer whose address is ptr (i.e. ptr is a pointer to a pointer). The third argument, ty, is a pointer to a SWIG type descriptor structure. If ty is not NULL, that type information is used to validate type compatibility and other aspects of the type conversion. If flags is non-zero, any type errors encountered during this validation result in a Ruby TypeError exception being raised; if flags is zero, such type errors will cause SWIG_ConvertPtr() to return -1 but not raise an exception. If ty is NULL, no type-checking is performed.

VALUE SWIG_NewPointerObj(void *ptr, swig_type_info *ty, int own)

Creates a new Ruby pointer object. Here, ptr is the pointer to convert, ty is the SWIG type descriptor structure that describes the type, and own is a flag that indicates whether or not Ruby should take ownership of the pointer (i.e. whether Ruby should free this data when the corresponding Ruby instance is garbage-collected).

Both of these functions require the use of a special SWIG type-descriptor structure. This structure contains information about the mangled name of the datatype, type-equivalence information, as well as information about converting pointer values under C++ inheritance. For a type of Foo *, the type descriptor structure is usually accessed as follows:

Foo *foo;
SWIG_ConvertPtr($input, (void **) &foo, SWIGTYPE_p_Foo, 1);

VALUE obj;
obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);

In a typemap, the type descriptor should always be accessed using the special typemap variable $1_descriptor. For example:

%typemap(in) Foo * {
  SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
}

38.7.12.1 Ruby Datatype Wrapping

VALUE Data_Wrap_Struct(VALUE class, void (*mark)(void *), void (*free)(void *), void *ptr)

Given a pointer ptr to some C data, and the two garbage collection routines for this data (mark and free), return a VALUE for the Ruby object.

VALUE Data_Make_Struct(VALUE class, c-type, void (*mark)(void *), void (*free)(void *), c-type *ptr)

Allocates a new instance of a C data type c-type, assigns it to the pointer ptr, then wraps that pointer with Data_Wrap_Struct() as above.

Data_Get_Struct(VALUE obj, c-type, c-type *ptr)

Retrieves the original C pointer of type c-type from the data object obj and assigns that pointer to ptr.

38.7.13 Example: STL Vector to Ruby Array

Another use for macros and type maps is to create a Ruby array from a STL vector of pointers. In essence, copy of all the pointers in the vector into a Ruby array. The use of the macro is to make the typemap so generic that any vector with pointers can use the type map. The following is an example of how to construct this type of macro/typemap and should give insight into constructing similar typemaps for other STL structures:

%define PTR_VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
%typemap(out) vectorclassname &, const vectorclassname & {
  VALUE arr = rb_ary_new2($1->size());
  vectorclassname::iterator i = $1->begin(), iend = $1->end();
  for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
  $result = arr;
}
%typemap(out) vectorclassname, const vectorclassname {
  VALUE arr = rb_ary_new2($1.size());
  vectorclassname::iterator i = $1.begin(), iend = $1.end();
  for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
  $result = arr;
}
%enddef

Note, that the "c ## classname.klass" is used in the preprocessor step to determine the actual object from the class name.

To use the macro with a class Foo, the following is used:

PTR_VECTOR_TO_RUBY_ARRAY(vector<foo *="">, Foo)

It is also possible to create a STL vector of Ruby objects:

%define RUBY_ARRAY_TO_PTR_VECTOR(vectorclassname, classname)
%typemap(in) vectorclassname &, const vectorclassname & {
  Check_Type($input, T_ARRAY);
  vectorclassname *vec = new vectorclassname;
  int len = RARRAY($input)->len;
  for (int i=0; i!=len; i++) {
    VALUE inst = rb_ary_entry($input, i);
    //The following _should_ work but doesn't on HPUX
    // Check_Type(inst, T_DATA);
    classname *element = NULL;
    Data_Get_Struct(inst, classname, element);
    vec->push_back(element);
  }
  $1 = vec;
}

%typemap(freearg) vectorclassname &, const vectorclassname & {
  delete $1;
}
%enddef

It is also possible to create a Ruby array from a vector of static data types:

%define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
%typemap(out) vectorclassname &, const vectorclassname & {
  VALUE arr = rb_ary_new2($1->size()); 
  vectorclassname::iterator i = $1->begin(), iend = $1->end();
  for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
  $result = arr;
}
%typemap(out) vectorclassname, const vectorclassname {
  VALUE arr = rb_ary_new2($1.size()); 
  vectorclassname::iterator i = $1.begin(), iend = $1.end();
  for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
  $result = arr;
}
%enddef
Note that this is mostly an example of typemaps. If you want to use the STL with ruby, you are advised to use the standard swig STL library, which does much more than this. Refer to the section called the C++ Standard Template Library.

38.8 Docstring Features

Using ri and rdoc web pages in Ruby libraries is a common practice. Given the way that SWIG generates the extensions by default, your users will normally not get any documentation for it, even if they run 'rdoc' on the resulting .c or .cxx file.

The features described in this section make it easy for you to add rdoc strings to your modules, functions and methods that can then be read by Ruby's rdoc tool to generate html web pages, ri documentation, Windows chm file and an .xml description.

rdoc can then be run from a console or shell window on a swig generated file.

For example, to generate html web pages from a C++ file, you'd do:

$ rdoc -E cxx=c -f html file_wrap.cxx

To generate ri documentation from a c wrap file, you could do:

$ rdoc -r file_wrap.c

38.8.1 Module docstring

Ruby allows a docstring at the beginning of the file before any other statements, and it is typically used to give a general description of the entire module. SWIG supports this by setting an option of the %module directive. For example:

%module(docstring="This is the example module's docstring") example

When you have more than just a line or so then you can retain the easy readability of the %module directive by using a macro. For example:

%define DOCSTRING
"The `XmlResource` class allows program resources defining menus, 
layout of controls on a panel, etc. to be loaded from an XML file."
%enddef

%module(docstring=DOCSTRING) xrc

38.8.2 %feature("autodoc")

Since SWIG does know everything about the function it wraps, it is possible to generate an rdoc containing the parameter types, names and default values. Since Ruby ships with one of the best documentation systems of any language, it makes sense to take advantage of it.

SWIG's Ruby module provides support for the "autodoc" feature, which when attached to a node in the parse tree will cause an rdoc comment to be generated in the wrapper file that includes the name of the function, parameter names, default values if any, and return type if any. There are also several options for autodoc controlled by the value given to the feature, described below.

38.8.2.1 %feature("autodoc", "0")

When the "0" option is given then the types of the parameters will not be included in the autodoc string. For example, given this function prototype:

%feature("autodoc", "0");
bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);

Then Ruby code like this will be generated:

function_name(x, y, foo=nil, bar=nil) -> bool
  ...

38.8.2.2 %feature("autodoc", "1")

When the "1" option is used then the parameter types will be used in the rdoc string. In addition, an attempt is made to simplify the type name such that it makes more sense to the Ruby user. Pointer, reference and const info is removed, %rename's are evaluated, etc. (This is not always successful, but works most of the time. See the next section for what to do when it doesn't.) Given the example above, then turning on the parameter types with the "1" option will result in rdoc code like this:

function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
  ...

38.8.2.3 %feature("autodoc", "2")

When the "2" option is used then the parameter types will not be used in the rdoc string. However, they will be listed in full after the function. Given the example above, then turning on the parameter types with the "2" option will result in Ruby code like this:

38.8.2.4 %feature("autodoc", "3")

When the "3" option is used then the function will be documented using a combination of "1" and "2" above. Given the example above, then turning on the parameter types with the "2" option will result in Ruby code like this:

function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool

Parameters:
	x - int
	y - int
	foo - Foo
	bar - Bar

38.8.2.5 %feature("autodoc", "docstring")

Finally, there are times when the automatically generated autodoc string will make no sense for a Ruby programmer, particularly when a typemap is involved. So if you give an explicit value for the autodoc feature then that string will be used in place of the automatically generated string. For example:

%feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
void GetPosition(int* OUTPUT, int* OUTPUT);

38.8.3 %feature("docstring")

In addition to the autodoc strings described above, you can also attach any arbitrary descriptive text to a node in the parse tree with the "docstring" feature. When the proxy module is generated then any docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together.

38.9 Advanced Topics

38.9.1 Operator overloading

SWIG allows operator overloading with, by using the %extend or %rename commands in SWIG and the following operator names (derived from Python):

General
__repr__ inspect
__str__ to_s
__cmp__ <=>
__hash__ hash
__nonzero__ nonzero?
Callable
__call__ call
Collection
__len__ length
__getitem__ []
__setitem__ []=
Numeric
__add__ +
__sub__ -
__mul__ *
__div__ /
__mod__ %
__divmod__ divmod
__pow__ **
__lshift__ <<
__rshift__ >>
__and__ &
__xor__ ^
__or__ |
__neg__ -@
__pos__ +@
__abs__ abs
__invert__ ~
__int__ to_i
__float__ to_f
__coerce__ coerce
Additions in 1.3.13
__lt__ <
__le__ <=
__eq__ ==
__gt__ >
__ge__ >=

Note that although SWIG supports the __eq__ magic method name for defining an equivalence operator, there is no separate method for handling inequality since Ruby parses the expression a != b as !(a == b).

38.9.2 Creating Multi-Module Packages

The chapter on Working with Modules discusses the basics of creating multi-module extensions with SWIG, and in particular the considerations for sharing runtime type information among the different modules.

As an example, consider one module's interface file (shape.i) that defines our base class:

%module shape

%{
#include "Shape.h"
%}

class Shape {
protected:
  double xpos;
  double ypos;
protected:
  Shape(double x, double y);
public:
  double getX() const;
  double getY() const;
};

We also have a separate interface file (circle.i) that defines a derived class:

%module circle

%{
#include "Shape.h"
#include "Circle.h"
%}

// Import the base class definition from Shape module
%import shape.i

class Circle : public Shape {
protected:
  double radius;
public:
  Circle(double x, double y, double r);
  double getRadius() const;
};

We'll start by building the Shape extension module:

$ swig -c++ -ruby shape.i

SWIG generates a wrapper file named shape_wrap.cxx. To compile this into a dynamically loadable extension for Ruby, prepare an extconf.rb script using this template:

require 'mkmf'

# Since the SWIG runtime support library for Ruby
# depends on the Ruby library, make sure it's in the list
# of libraries.
$libs = append_library($libs, Config::CONFIG['RUBY_INSTALL_NAME'])

# Create the makefile
create_makefile('shape')

Run this script to create a Makefile and then type make to build the shared library:

$ ruby extconf.rb
creating Makefile
$ make
g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
-I. -c shape_wrap.cxx
gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
-lruby -lruby -lc

Note that depending on your installation, the outputs may be slightly different; these outputs are those for a Linux-based development environment. The end result should be a shared library (here, shape.so) containing the extension module code. Now repeat this process in a separate directory for the Circle module:

  1. Run SWIG to generate the wrapper code (circle_wrap.cxx);
  2. Write an extconf.rb script that your end-users can use to create a platform-specific Makefile for the extension;
  3. Build the shared library for this extension by typing make.

Once you've built both of these extension modules, you can test them interactively in IRB to confirm that the Shape and Circle modules are properly loaded and initialized:

$ irb
irb(main):001:0> require 'shape'
true
irb(main):002:0> require 'circle'
true
irb(main):003:0> c = Circle::Circle.new(5, 5, 20)
#<Circle::Circle:0xa097208>
irb(main):004:0> c.kind_of? Shape::Shape
true
irb(main):005:0> c.getX()
5.0

38.9.3 Specifying Mixin Modules

The Ruby language doesn't support multiple inheritance, but it does allow you to mix one or more modules into a class using Ruby's include method. For example, if you have a Ruby class that defines an each instance method, e.g.

class Set
  def initialize
  @members = []
  end
 
  def each
  @members.each { |m| yield m }
  end
end

then you can mix-in Ruby's Enumerable module to easily add a lot of functionality to your class:

class Set
  include Enumerable
  def initialize
    @members = []
  end
  def each
    @members.each { |m| yield m }
  end
end

To get the same benefit for your SWIG-wrapped classes, you can use the %mixin directive to specify the names of one or more modules that should be mixed-in to a class. For the above example, the SWIG interface specification might look like this:

%mixin Set "Enumerable";

class Set {
public:
  // Constructor
  Set();
 
  // Iterates through set members
  void each();
};

Multiple modules can be mixed into a class by providing a comma-separated list of module names to the %mixin directive, e.g.

%mixin Set "Fee,Fi,Fo,Fum";

Note that the %mixin directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

38.10 Memory Management

One of the most common issues in generating SWIG bindings for Ruby is proper memory management. The key to proper memory management is clearly defining whether a wrapper Ruby object owns the underlying C struct or C++ class. There are two possibilities:

  • The Ruby object is responsible for freeing the C struct or C++ object
  • The Ruby object should not free the C struct or C++ object because it will be freed by the underlying C or C++ code

To complicate matters, object ownership may transfer from Ruby to C++ (or vice versa) depending on what function or methods are invoked. Clearly, developing a SWIG wrapper requires a thorough understanding of how the underlying library manages memory.

38.10.1 Mark and Sweep Garbage Collector

Ruby uses a mark and sweep garbage collector. When the garbage collector runs, it finds all the "root" objects, including local variables, global variables, global constants, hardware registers and the C stack. For each root object, the garbage collector sets its mark flag to true and calls rb_gc_mark on the object. The job of rb_gc_mark is to recursively mark all the objects that a Ruby object has a reference to (ignoring those objects that have already been marked). Those objects, in turn, may reference other objects. This process will continue until all active objects have been "marked." After the mark phase comes the sweep phase. In the sweep phase, all objects that have not been marked will be garbage collected. For more information about the Ruby garbage collector please refer to http://rubygarden.org/ruby/ruby?GCAndExtensions.

The Ruby C/API provides extension developers two hooks into the garbage collector - a "mark" function and a "sweep" function. By default these functions are set to NULL.

If a C struct or C++ class references any other Ruby objects, then it must provide a "mark" function. The "mark" function should identify any referenced Ruby objects by calling the rb_gc_mark function for each one. Unsurprisingly, this function will be called by the Ruby garbage during the "mark" phase.

During the sweep phase, Ruby destroys any unused objects. If any memory has been allocated in creating the underlying C struct or C++ struct, then a "free" function must be defined that deallocates this memory.

38.10.2 Object Ownership

As described above, memory management depends on clearly defining who is responsible for freeing the underlying C struct or C++ class. If the Ruby object is responsible for freeing the C++ object, then a "free" function must be registered for the object. If the Ruby object is not responsible for freeing the underlying memory, then a "free" function must not be registered for the object.

For the most part, SWIG takes care of memory management issues. The rules it uses are:

  • When calling a C++ object's constructor from Ruby, SWIG will assign a "free" function thereby making the Ruby object responsible for freeing the C++ object
  • When calling a C++ member function that returns a pointer, SWIG will not assign a "free" function thereby making the underlying library responsible for freeing the object.

To make this clearer, let's look at an example. Assume we have a Foo and a Bar class.

/* File "RubyOwernshipExample.h" */

class Foo
{
public:
  Foo() {}
  ~Foo() {}
};

class Bar
{
  Foo *foo_;
public:
  Bar(): foo_(new Foo) {}
  ~Bar() { delete foo_; }
  Foo* get_foo() { return foo_; }
  Foo* get_new_foo() { return new Foo; }
  void set_foo(Foo *foo) { delete foo_; foo_ = foo; }
};

First, consider this Ruby code:

foo = Foo.new

In this case, the Ruby code calls the underlying Foo C++ constructor, thus creating a new foo object. By default, SWIG will assign the new Ruby object a "free" function. When the Ruby object is garbage collected, the "free" function will be called. It in turn will call Foo's destructor.

Next, consider this code:

bar = Bar.new
foo = bar.get_foo()

In this case, the Ruby code calls a C++ member function, get_foo. By default, SWIG will not assign the Ruby object a "free" function. Thus, when the Ruby object is garbage collected the underlying C++ foo object is not affected.

Unfortunately, the real world is not as simple as the examples above. For example:

bar = Bar.new
foo = bar.get_new_foo()

In this case, the default SWIG behavior for calling member functions is incorrect. The Ruby object should assume ownership of the returned object. This can be done by using the %newobject directive. See Object ownership and %newobject for more information.

The SWIG default mappings are also incorrect in this case:

foo = Foo.new
bar = Bar.new
bar.set_foo(foo)

Without modification, this code will cause a segmentation fault. When the Ruby foo object goes out of scope, it will free the underlying C++ foo object. However, when the Ruby bar object goes out of scope, it will call the C++ bar destructor which will also free the C++ foo object. The problem is that object ownership is transferred from the Ruby object to the C++ object when the set_foo method is called. This can be done by using the special DISOWN type map, which was added to the Ruby bindings in SWIG-1.3.26.

Thus, a correct SWIG interface file correct mapping for these classes is:

/* File RubyOwnershipExample.i */

%module RubyOwnershipExample

%{
#include "RubyOwnershipExample.h"
%}

class Foo
{
public:
  Foo();
  ~Foo();
};

class Bar
{
  Foo *foo_;
public:
  Bar();
  ~Bar();
  Foo* get_foo();

  %newobject get_new_foo;
  Foo* get_new_foo();

  %apply SWIGTYPE *DISOWN {Foo *foo};
  void set_foo(Foo *foo);
  %clear Foo *foo;
};

This code can be seen in swig/examples/ruby/tracking.

38.10.3 Object Tracking

The remaining parts of this section will use the class library shown below to illustrate different memory management techniques. The class library models a zoo and the animals it contains.

%module zoo

%{
#include <string>
#include <vector>

#include "zoo.h"
%}

class Animal
{
private:
  typedef std::vector<Animal*> AnimalsType;
  typedef AnimalsType::iterator IterType;
protected:
  AnimalsType animals;
protected:
  std::string name_;
public:
  // Construct an animal with this name
  Animal(const char* name) : name_(name) {}
 
  // Return the animal's name
  const char* get_name() const { return name.c_str(); }
};

class Zoo
{
protected:
 std::vector<animal *=""> animals;
 
public:
  // Construct an empty zoo
  Zoo() {}
  
  /* Create a new animal. */
  static Animal* Zoo::create_animal(const char* name) {
    return new Animal(name);
  }
 
  // Add a new animal to the zoo
  void add_animal(Animal* animal) {
    animals.push_back(animal); 
  }
 
  Animal* remove_animal(size_t i) {
    Animal* result = this->animals[i];
    IterType iter = this->animals.begin();
    std::advance(iter, i);
    this->animals.erase(iter);
   
    return result;
  }
  
  // Return the number of animals in the zoo
  size_t get_num_animals() const {
    return animals.size(); 
  }
  
  // Return a pointer to the ith animal
  Animal* get_animal(size_t i) const {
    return animals[i]; 
  }
};

Let's say you SWIG this code and then run IRB:

$ irb
irb(main):001:0> require 'example'
=> true

irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2be3820>

irb(main):004:0> tiger1.get_name()
=> "tiger1"

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be0a60>

irb(main):006:0> zoo.add_animal(tiger)
=> nil

irb(main):007:0> zoo.get_num_animals()
=> 1

irb(main):007:0> tiger2 = zoo.remove_animal(0)
=> #<Example::Animal:0x2bd4a18>

irb(main):008:0> tiger2.get_name()
=> "tiger1"

irb(main):009:0> tiger1.equal?(tiger2)
=> false

Pay particular attention to the code tiger1.equal?(tiger2). Note that the two Ruby objects are not the same - but they reference the same underlying C++ object. This can cause problems. For example:

irb(main):010:0> tiger1 = nil
=> nil

irb(main):011:0> GC.start
=> nil

irb(main):012:0> tiger2.get_name()
(irb):12: [BUG] Segmentation fault

After the garbage collector runs, as a result of our call to GC.start, callingtiger2.get_name() causes a segmentation fault. The problem is that when tiger1 is garbage collected, it frees the underlying C++ object. Thus, when tiger2 calls the get_name() method it invokes it on a destroyed object.

This problem can be avoided if SWIG enforces a one-to-one mapping between Ruby objects and C++ classes. This can be done via the use of the %trackobjects functionality available in SWIG-1.3.26. and later.

When the %trackobjects is turned on, SWIG automatically keeps track of mappings between C++ objects and Ruby objects. Note that enabling object tracking causes a slight performance degradation. Test results show this degradation to be about 3% to 5% when creating and destroying 100,000 animals in a row.

Since %trackobjects is implemented as a %feature, it uses the same name matching rules as other kinds of features (see the chapter on "Customization Features") . Thus it can be applied on a class-by-class basis if needed. To fix the example above:

%module example

%{
#include "example.h"
%}

/* Tell SWIG that create_animal creates a new object */
%newobject Zoo::create_animal;

/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */%trackobjects;

%include "example.h"

When this code runs we see:

$ irb
irb(main):001:0> require 'example'
=> true

irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2be37d8>

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be0a18>

irb(main):004:0> zoo.add_animal(tiger1)
=> nil

irb(main):006:0> tiger2 = zoo.remove_animal(0)
=> #<Example::Animal:0x2be37d8>

irb(main):007:0> tiger1.equal?(tiger2)
=> true

irb(main):008:0> tiger1 = nil
=> nil

irb(main):009:0> GC.start
=> nil

irb(main):010:0> tiger.get_name()
=> "tiger1"
irb(main):011:0>

For those who are interested, object tracking is implemented by storing Ruby objects in a hash table and keying them on C++ pointers. The underlying API is:

static void SWIG_RubyAddTracking(void* ptr, VALUE object);
static VALUE SWIG_RubyInstanceFor(void* ptr) ;
static void SWIG_RubyRemoveTracking(void* ptr);
static void SWIG_RubyUnlinkObjects(void* ptr);

When an object is created, SWIG will automatically call the SWIG_RubyAddTracking method. Similarly, when an object is deleted, SWIG will call the SWIG_RubyRemoveTracking. When an object is returned to Ruby from C++, SWIG will use the SWIG_RubyInstanceFor method to ensure a one-to-one mapping from Ruby to C++ objects. Last, the RubyUnlinkObjects method unlinks a Ruby object from its underlying C++ object.

In general, you will only need to use the SWIG_RubyInstanceFor, which is required for implementing mark functions as shown below. However, if you implement your own free functions (see below) you may also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects methods.

38.10.4 Mark Functions

With a bit more testing, we see that our class library still has problems. For example:

$ irb
irb(main):001:0> require 'example'
=> true

irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2bea6a8>

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be7960>

irb(main):004:0> zoo.add_animal(tiger1)
=> nil

irb(main):007:0> tiger1 = nil
=> nil

irb(main):007:0> GC.start
=> nil

irb(main):005:0> tiger2 = zoo.get_animal(0)
(irb):12: [BUG] Segmentation fault

The problem is that Ruby does not know that the zoo object contains a reference to a Ruby object. Thus, when Ruby garbage collects tiger1 it frees the underlying C++ object.

This can be fixed by implementing a mark function as described above in the Mark and Sweep Garbage Collector section. You can specify a mark function by using the %markfunc directive. Since the %markfunc directive is implemented using SWIG's' "features" mechanism it uses the same name matching rules as other kinds of features (see the chapter on "Customization Features" for more details).

A mark function takes a single argument, which is a pointer to the C++ object being marked; it should, in turn, call rb_gc_mark() for any instances that are reachable from the current object. The mark function for our Zoo class should therefore loop over all of the C++ animal objects in the zoo object, look up their Ruby object equivalent, and then call rb_gc_mark(). One possible implementation is:

%module example

%{
#include "example.h"
%}

/* Keep track of mappings between C/C++ structs/classes
 and Ruby objects so we can implement a mark function. */
%trackobjects;

/* Specify the mark function */
%markfunc Zoo "mark_Zoo";

%include "example.h"

%header %{

static void mark_Zoo(void* ptr) {
  Zoo* zoo = (Zoo*) ptr;
 
  /* Loop over each object and tell the garbage collector
  that we are holding a reference to them. */
  int count = zoo->get_num_animals();
 
  for(int i = 0; i < count; ++i) {
    Animal* animal = zoo->get_animal(i);
    VALUE object = SWIG_RubyInstanceFor(animal);
 
    if (object != Qnil) {
      rb_gc_mark(object);
    }
  }
}
%}

Note the mark function is dependent on the SWIG_RUBY_InstanceFor method, and thus requires that %trackobjects is enabled. For more information, please refer to the track_object.i test case in the SWIG test suite.

When this code is compiled we now see:

$ irb
irb(main):002:0> tiger1=Example::Animal.new("tiger1")
=> #<Example::Animal:0x2be3bf8>

irb(main):003:0> Example::Zoo.new()
=> #<Example::Zoo:0x2be1780>

irb(main):004:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2bde9c0>

irb(main):005:0> zoo.add_animal(tiger1)
=> nil

irb(main):009:0> tiger1 = nil
=> nil

irb(main):010:0> GC.start
=> nil
irb(main):014:0> tiger2 = zoo.get_animal(0)
=> #<Example::Animal:0x2be3bf8>

irb(main):015:0> tiger2.get_name()
=> "tiger1"
irb(main):016:0>

This code can be seen in swig/examples/ruby/mark_function.

38.10.5 Free Functions

By default, SWIG creates a "free" function that is called when a Ruby object is garbage collected. The free function simply calls the C++ object's destructor.

However, sometimes an appropriate destructor does not exist or special processing needs to be performed before the destructor is called. Therefore, SWIG allows you to manually specify a "free" function via the use of the %freefunc directive. The %freefunc directive is implemented using SWIG's' "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

IMPORTANT ! - If you define your own free function, then you must ensure that you call the underlying C++ object's destructor. In addition, if object tracking is activated for the object's class, you must also call the SWIG_RubyRemoveTracking function (of course call this before you destroy the C++ object). Note that it is harmless to call this method if object tracking if off so it is advised to always call it.

Note there is a subtle interaction between object ownership and free functions. A custom defined free function will only be called if the Ruby object owns the underlying C++ object. This also to Ruby objects which are created, but then transfer ownership to C++ objects via the use of the disown typemap described above.

To show how to use the %freefunc directive, let's slightly change our example. Assume that the zoo object is responsible for freeing animal that it contains. This means that the Zoo::add_animal function should be marked with a DISOWN typemap and the destructor should be updated as below:

Zoo::~Zoo() {
 IterType iter = this->animals.begin();
 IterType end = this->animals.end();

 for(iter; iter != end; ++iter) {
 Animal* animal = *iter;
 delete animal;
 }
}

When we use these objects in IRB we see:

$irb
irb(main):002:0> require 'example'
=> true

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be0fe8>

irb(main):005:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2bda760>

irb(main):006:0> zoo.add_animal(tiger1)
=> nil

irb(main):007:0> zoo = nil
=> nil

irb(main):008:0> GC.start
=> nil

irb(main):009:0> tiger1.get_name()
(irb):12: [BUG] Segmentation fault

The error happens because the C++ animal object is freed when the zoo object is freed. Although this error is unavoidable, we can at least prevent the segmentation fault. To do this requires enabling object tracking and implementing a custom free function that calls the SWIG_RubyUnlinkObjects function for each animal object that is destroyed. The SWIG_RubyUnlinkObjects function notifies SWIG that a Ruby object's underlying C++ object is no longer valid. Once notified, SWIG will intercept any calls from the existing Ruby object to the destroyed C++ object and raise an exception.

%module example

%{
#include "example.h"
%}

/* Specify that ownership is transferred to the zoo
	when calling add_animal */
%apply SWIGTYPE *DISOWN { Animal* animal };

/* Track objects */
%trackobjects;

/* Specify the mark function */
%freefunc Zoo "free_Zoo";

%include "example.h"

%header %{
  static void free_Zoo(void* ptr) {
    Zoo* zoo = (Zoo*) ptr;

    /* Loop over each animal */
    int count = zoo->get_num_animals();

    for(int i = 0; i < count; ++i) {
      /* Get an animal */
      Animal* animal = zoo->get_animal(i);

      /* Unlink the Ruby object from the C++ object */
      SWIG_RubyUnlinkObjects(animal);

      /* Now remove the tracking for this animal */
      SWIG_RubyRemoveTracking(animal);
    }

    /* Now call SWIG_RubyRemoveTracking for the zoo */
    SWIG_RubyRemoveTracking(ptr);
    /* Now free the zoo which will free the animals it contains */
    delete zoo;
  }
%} 

Now when we use these objects in IRB we see:

$irb
irb(main):002:0> require 'example'
=> true

irb(main):003:0> zoo = Example::Zoo.new()
=> #<Example::Zoo:0x2be0fe8>

irb(main):005:0> tiger1 = Example::Animal.new("tiger1")
=> #<Example::Animal:0x2bda760>

irb(main):006:0> zoo.add_animal(tiger1)
=> nil

irb(main):007:0> zoo = nil
=> nil

irb(main):008:0> GC.start
=> nil

irb(main):009:0> tiger1.get_name()
RuntimeError: This Animal * already released
 from (irb):10:in `get_name'
 from (irb):10
irb(main):011:0>

Notice that SWIG can now detect the underlying C++ object has been freed, and thus raises a runtime exception.

This code can be seen in swig/examples/ruby/free_function.

38.10.6 Embedded Ruby and the C++ Stack

As has been said, the Ruby GC runs and marks objects before its sweep phase. When the garbage collector is called, it will also try to mark any Ruby objects (VALUE) it finds in the machine registers and in the C++ stack.

The stack is basically the history of the functions that have been called and also contains local variables, such as the ones you define whenever you do inside a function:

VALUE obj;

For ruby to determine where its stack space begins, during initialization a normal Ruby interpreter will call the ruby_init() function which in turn will call a function called Init_stack or similar. This function will store a pointer to the location where the stack points at that point in time.

ruby_init() is presumed to always be called within the main() function of your program and whenever the GC is called, ruby will assume that the memory between the current location in memory and the pointer that was stored previously represents the stack, which may contain local (and temporary) VALUE ruby objects. Ruby will then be careful not to remove any of those objects in that location.

So far so good. For a normal Ruby session, all the above is completely transparent and magic to the extensions developer.

However, with an embedded Ruby, it may not always be possible to modify main() to make sure ruby_init() is called there. As such, ruby_init() will likely end up being called from within some other function. This can lead Ruby to measure incorrectly where the stack begins and can result in Ruby incorrectly collecting those temporary VALUE objects that are created once another function is called. The end result: random crashes and segmentation faults.

This problem will often be seen in director functions that are used for callbacks, for example.

To solve the problem, SWIG can now generate code with director functions containing the optional macros SWIG_INIT_STACK and SWIG_RELEASE_STACK. These macros will try to force Ruby to reinitiliaze the beginning of the stack the first time a director function is called. This will lead Ruby to measure and not collect any VALUE objects defined from that point on.

To mark functions to either reset the ruby stack or not, you can use:

%initstack Class::memberfunction;   // only re-init the stack in this director method
%ignorestack Class::memberfunction; // do not re-init the stack in this director method
%initstack Class;                   // init the stack on all the methods of this class
%initstack;                         // all director functions will re-init the stack
swig-3.0.2/Doc/Manual/Java.html0000664000175000017500000102672512343706601016055 0ustar williamwilliam SWIG and Java

25 SWIG and Java

This chapter describes SWIG's support of Java. It covers most SWIG features, but certain low-level details are covered in less depth than in earlier chapters.

25.1 Overview

The 100% Pure Java effort is a commendable concept, however in the real world programmers often either need to re-use their existing code or in some situations want to take advantage of Java but are forced into using some native (C/C++) code. The Java extension to SWIG makes it very easy to plumb in existing C/C++ code for access from Java, as SWIG writes the Java Native Interface (JNI) code for you. It is different to using the 'javah' tool as SWIG will wrap existing C/C++ code, whereas javah takes 'native' Java function declarations and creates C/C++ function prototypes. SWIG wraps C/C++ code using Java proxy classes and is very useful if you want to have access to large amounts of C/C++ code from Java. If only one or two JNI functions are needed then using SWIG may be overkill. SWIG enables a Java program to easily call into C/C++ code from Java. Historically, SWIG was not able to generate any code to call into Java code from C++. However, SWIG now supports full cross language polymorphism and code is generated to call up from C++ to Java when wrapping C++ virtual methods via the director feature.

Java is one of the few non-scripting language modules in SWIG. As SWIG utilizes the type safety that the Java language offers, it takes a somewhat different approach to that used for scripting languages. In particular runtime type checking and the runtime library are not used by Java. This should be borne in mind when reading the rest of the SWIG documentation. This chapter on Java is relatively self contained and will provide you with nearly everything you need for using SWIG and Java. However, the "SWIG Basics" chapter will be a useful read in conjunction with this one.

This chapter starts with a few practicalities on running SWIG and compiling the generated code. If you are looking for the minimum amount to read, have a look at the sections up to and including the tour of basic C/C++ wrapping section which explains how to call the various C/C++ code constructs from Java. Following this section are details of the C/C++ code and Java classes that SWIG generates. Due to the complexities of C and C++ there are different ways in which C/C++ code could be wrapped and called from Java. SWIG is a powerful tool and the rest of the chapter details how the default code wrapping can be tailored. Various customisation tips and techniques using SWIG directives are covered. The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.

25.2 Preliminaries

SWIG 1.1 works with JDKs from JDK 1.1 to JDK1.4 (Java 2 SDK1.4) and should also work with any later versions. Given the choice, you should probably use the latest version of Sun's JDK. The SWIG Java module is known to work using Sun's JVM on Solaris, Linux and the various flavours of Microsoft Windows including Cygwin. The Kaffe JVM is known to give a few problems and at the time of writing was not a fully fledged JVM with full JNI support. The generated code is also known to work on vxWorks using WindRiver's PJava 3.1. The best way to determine whether your combination of operating system and JDK will work is to test the examples and test-suite that comes with SWIG. Run make -k check from the SWIG root directory after installing SWIG on Unix systems.

The Java module requires your system to support shared libraries and dynamic loading. This is the commonly used method to load JNI code so your system will more than likely support this.

Android uses Java JNI and also works with SWIG. Please read the Android chapter in conjunction with this one if you are targeting Android.

25.2.1 Running SWIG

Suppose that you defined a SWIG module such as the following:

/* File: example.i */
%module test
%{
#include "stuff.h"
%}
int fact(int n);

To build a Java module, run SWIG using the -java option :

%swig -java example.i

If building C++, add the -c++ option:

$ swig -c++ -java example.i

This creates two different files; a C/C++ source file example_wrap.c or example_wrap.cxx and numerous Java files. The generated C/C++ source file contains the JNI wrapper code that needs to be compiled and linked with the rest of your C/C++ application.

The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. It is also possible to change the output directory that the Java files are generated into using -outdir.

The module name, specified with %module, determines the name of various generated classes as discussed later. Note that the module name does not define a Java package and by default, the generated Java classes do not have a Java package. The -package option described below can specify a Java package name to use.

The following sections have further practical examples and details on how you might go about compiling and using the generated files.

25.2.2 Additional Commandline Options

The following table list the additional commandline options available for the Java module. They can also be seen by using:

swig -java -help 
Java specific options
-nopgcpp suppress the premature garbage collection prevention parameter
-noproxy generate the low-level functional interface instead of proxy classes
-package <name> set name of the Java package to <name>

Their use will become clearer by the time you have finished reading this section on SWIG and Java.

25.2.3 Getting the right header files

In order to compile the C/C++ wrappers, the compiler needs the jni.h and jni_md.h header files which are part of the JDK. They are usually in directories like this:

/usr/java/include
/usr/java/include/<operating_system>

The exact location may vary on your machine, but the above locations are typical.

25.2.4 Compiling a dynamic module

The JNI code exists in a dynamic module or shared library (DLL on Windows) and gets loaded by the JVM. Assuming you have code you need to link to in a file called example.c, in order to build a shared library file, you need to compile your module in a manner similar to the following (shown for Solaris):

$ swig -java example.i
$ gcc -fPIC -c example_wrap.c -I/usr/java/include -I/usr/java/include/solaris
$ gcc -fPIC -c example.c
$ ld -G example_wrap.o example.o -o libexample.so

The exact commands for doing this vary from platform to platform. However, SWIG tries to guess the right options when it is installed. Therefore, you may want to start with one of the examples in the Examples/java directory. If that doesn't work, you will need to read the man-pages for your compiler and linker to get the right set of options. You might also check the SWIG Wiki for additional information. JNI compilation is a useful reference for compiling on different platforms.

Important
If you are going to use optimisations turned on with gcc (for example -O2), ensure you also compile with -fno-strict-aliasing. The GCC optimisations have become more aggressive from gcc-4.0 onwards and will result in code that fails with strict aliasing optimisations turned on. See the C/C++ to Java typemaps section for more details.

The name of the shared library output file is important. If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information). The name of the module is specified using the %module directive or -module command line option.

25.2.5 Using your module

To load your shared native library module in Java, simply use Java's System.loadLibrary method in a Java class:

// runme.java

public class runme {
  static {
    System.loadLibrary("example");
  }

  public static void main(String argv[]) {
    System.out.println(example.fact(4));
  }
}

Compile all the Java files and run:

$ javac *.java
$ java runme
24
$

If it doesn't work have a look at the following section which discusses problems loading the shared library.

25.2.6 Dynamic linking problems

As shown in the previous section the code to load a native library (shared library) is System.loadLibrary("name"). This can fail with an UnsatisfiedLinkError exception and can be due to a number of reasons.

You may get an exception similar to this:

$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: no example in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1312)
        at java.lang.Runtime.loadLibrary0(Runtime.java:749)
        at java.lang.System.loadLibrary(System.java:820)
        at runme.<clinit>(runme.java:5)

The most common cause for this is an incorrect naming of the native library for the name passed to the loadLibrary function. The string passed to the loadLibrary function must not include the file extension name in the string, that is .dll or .so. The string must be name and not libname for all platforms. On Windows the native library must then be called name.dll and on most Unix systems it must be called libname.so.

Another common reason for the native library not loading is because it is not in your path. On Windows make sure the path environment variable contains the path to the native library. On Unix make sure that your LD_LIBRARY_PATH contains the path to the native library. Adding paths to LD_LIBRARY_PATH can slow down other programs on your system so you may want to consider alternative approaches. For example you could recompile your native library with extra path information using -rpath if you're using GNU, see the GNU linker documentation (ld man page). You could use a command such as ldconfig (Linux) or crle (Solaris) to add additional search paths to the default system configuration (this requires root access and you will need to read the man pages).

The native library will also not load if there are any unresolved symbols in the compiled C/C++ code. The following exception is indicative of this:

$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: libexample.so: undefined
symbol: fact
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java, Compiled Code)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java, Compiled Code)
        at java.lang.Runtime.loadLibrary0(Runtime.java, Compiled Code)
        at java.lang.System.loadLibrary(System.java, Compiled Code)
        at runme.<clinit>(runme.java:5)
$

This error usually indicates that you forgot to include some object files or libraries in the linking of the native library file. Make sure you compile both the SWIG wrapper file and the code you are wrapping into the native library file. If you forget to compile and link in the SWIG wrapper file into your native library file, you will get a message similar to the following:

$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: exampleJNI.gcd(II)I
	at exampleJNI.gcd(Native Method)
	at example.gcd(example.java:12)
	at runme.main(runme.java:18)

where gcd is the missing JNI function that SWIG generated into the wrapper file. Also make sure you pass all of the required libraries to the linker. The java -verbose:jni commandline switch is also a great way to get more information on unresolved symbols. One last piece of advice is to beware of the common faux pas of having more than one native library version in your path.

In summary, ensure that you are using the correct C/C++ compiler and linker combination and options for successful native library loading. If you are using the examples that ship with SWIG, then the Examples/Makefile must have these set up correctly for your system. The SWIG installation package makes a best attempt at getting these correct but does not get it right 100% of the time. The SWIG Wiki also has some settings for commonly used compiler and operating system combinations. The following section also contains some C++ specific linking problems and solutions.

25.2.7 Compilation problems and compiling with C++

On most machines, shared library files should be linked using the C++ compiler. For example:

% swig -c++ -java example.i
% g++ -c -fpic example.cxx
% g++ -c -fpic example_wrap.cxx -I/usr/java/j2sdk1.4.1/include -I/usr/java/j2sdk1.4.1/include/linux
% g++ -shared example.o example_wrap.o -o libexample.so

In addition to this, you may need to include additional library files to make it work. For example, if you are using the Sun C++ compiler on Solaris, you often need to add an extra library -lCrun like this:

% swig -c++ -java example.i
% CC -c example.cxx
% CC -c example_wrap.cxx -I/usr/java/include -I/usr/java/include/solaris
% CC -G example.o example_wrap.o -L/opt/SUNWspro/lib -o libexample.so -lCrun

If you aren't entirely sure about the linking for C++, you might look at an existing C++ program. On many Unix machines, the ldd command will list library dependencies. This should give you some clues about what you might have to include when you link your shared library. For example:

$ ldd swig
        libstdc++-libc6.1-1.so.2 => /usr/lib/libstdc++-libc6.1-1.so.2 (0x40019000)
        libm.so.6 => /lib/libm.so.6 (0x4005b000)
        libc.so.6 => /lib/libc.so.6 (0x40077000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
$

Finally make sure the version of JDK header files matches the version of Java that you are running as incompatibilities could lead to compilation problems or unpredictable behaviour.

25.2.8 Building on Windows

Building on Windows is roughly similar to the process used with Unix. You will want to produce a DLL that can be loaded by the Java Virtual Machine. This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers. In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.

25.2.8.1 Running SWIG from Visual Studio

If you are developing your application within Microsoft Visual studio, SWIG can be invoked as a custom build option. The Examples\java directory has a few Windows Examples containing Visual Studio project (.dsp) files. The process to re-create the project files for a C project are roughly:

  • Open up a new workspace and use the AppWizard to select a DLL project.
  • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (ie. example_wrap.c). Don't worry if the wrapper file doesn't exist yet--Visual Studio will keep a reference to it.
  • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
  • Enter "SWIG" in the description field.
  • Enter "swig -java -o $(ProjDir)\$(InputName)_wrap.c $(InputPath)" in the "Build command(s) field"
  • Enter "$(ProjDir)\$(InputName)_wrap.c" in the "Output files(s) field".
  • Next, select the settings for the entire project and go to C/C++ tab and select the Preprocessor category . Add the include directories to the JNI header files under "Additional include directories", eg "C:\jdk1.3\include,C:\jdk1.3\include\win32".
  • Next, select the settings for the entire project and go to Link tab and select the General category. Set the name of the output file to match the name of your Java module (ie. example.dll).
  • Next, select the example.c and example_wrap.c files and go to the C/C++ tab and select the Precompiled Headers tab in the project settings. Disabling precompiled headers for these files will overcome any precompiled header errors while building.
  • Finally, add the java compilation as a post build rule in the Post-build step tab in project settings, eg, "c:\jdk1.3\bin\javac *.java"
  • Build your project.

Note: If using C++, choose a C++ suffix for the wrapper file, for example example_wrap.cxx. Use _wrap.cxx instead of _wrap.c in the instructions above and add -c++ when invoking swig.

Now, assuming all went well, SWIG will be automatically invoked when you build your project. When doing a build, any changes made to the interface file will result in SWIG being automatically invoked to produce a new version of the wrapper file.

The Java classes that SWIG output should also be compiled into .class files. To run the native code in the DLL (example.dll), make sure that it is in your path then run your Java program which uses it, as described in the previous section. If the library fails to load have a look at Dynamic linking problems.

25.2.8.2 Using NMAKE

Alternatively, a Makefile for use by NMAKE can be written. Make sure the environment variables for MSVC++ are available and the MSVC++ tools are in your path. Now, just write a short Makefile like this :

# Makefile for using SWIG and Java for C code

SRCS          = example.c
IFILE         = example
INTERFACE     = $(IFILE).i
WRAPFILE      = $(IFILE)_wrap.c

# Location of the Visual C++ tools (32 bit assumed)

TOOLS         = c:\msdev
TARGET        = example.dll
CC            = $(TOOLS)\bin\cl.exe
LINK          = $(TOOLS)\bin\link.exe
INCLUDE32     = -I$(TOOLS)\include
MACHINE       = IX86

# C Library needed to build a DLL

DLLIBC        = msvcrt.lib oldnames.lib  

# Windows libraries that are apparently needed
WINLIB        = kernel32.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib

# Libraries common to all DLLs
LIBS          = $(DLLIBC) $(WINLIB) 

# Linker options
LOPT      = -debug:full -debugtype:cv /NODEFAULTLIB /RELEASE /NOLOGO \
             /MACHINE:$(MACHINE) -entry:_DllMainCRTStartup@12 -dll

# C compiler flags

CFLAGS        = /Z7 /Od /c /nologo
JAVA_INCLUDE    = -ID:\jdk1.3\include -ID:\jdk1.3\include\win32

java::
	swig -java -o $(WRAPFILE) $(INTERFACE)
	$(CC) $(CFLAGS) $(JAVA_INCLUDE) $(SRCS) $(WRAPFILE)
	set LIB=$(TOOLS)\lib
	$(LINK) $(LOPT) -out:example.dll $(LIBS) example.obj example_wrap.obj
	javac *.java

To build the DLL and compile the java code, run NMAKE (you may need to run vcvars32 first). This is a pretty simplistic Makefile, but hopefully its enough to get you started. Of course you may want to make changes for it to work for C++ by adding in the -c++ command line switch for swig and replacing .c with .cxx.

25.3 A tour of basic C/C++ wrapping

By default, SWIG attempts to build a natural Java interface to your C/C++ code. Functions are wrapped as functions, classes are wrapped as classes, variables are wrapped with JavaBean type getters and setters and so forth. This section briefly covers the essential aspects of this wrapping.

25.3.1 Modules, packages and generated Java classes

The SWIG %module directive specifies the name of the Java module. When you specify `%module example', the module name determines the name of some of the generated files in the module. The generated code consists of a module class file example.java, an intermediary JNI class file, exampleJNI.java as well as numerous other Java proxy class files. Each proxy class is named after the structs, unions and classes you are wrapping. You may also get a constants interface file if you are wrapping any unnamed enumerations or constants, for example exampleConstants.java. When choosing a module name, make sure you don't use the same name as one of the generated proxy class files nor a Java keyword. Sometimes a C/C++ type cannot be wrapped by a proxy class, for example a pointer to a primitive type. In these situations a type wrapper class is generated. Wrapping an enum generates an enum class, either a proper Java enum or a Java class that simulates the enums pattern. Details of all these generated classes will unfold as you read this section.

The JNI (C/C++) code is generated into a file which also contains the module name, for example example_wrap.cxx or example_wrap.c. These C or C++ files complete the contents of the module.

The generated Java classes can be placed into a Java package by using the -package commandline option. This is often combined with the -outdir to specify a package directory for generating the Java files.

swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i

SWIG won't create the directory, so make sure it exists beforehand.

25.3.2 Functions

There is no such thing as a global Java function so global C functions are wrapped as static methods in the module class. For example,

%module example
int fact(int n);

creates a static function that works exactly like you think it might:

public class example {
  public static int fact(int n) {
    // makes call using JNI to the C function
  }
}

The Java class example is the module class. The function can be used as follows from Java:

System.out.println(example.fact(4));

25.3.3 Global variables

C/C++ global variables are fully supported by SWIG. Java does not allow the overriding of the dot operator so all variables are accessed through getters and setters. Again because there is no such thing as a Java global variable, access to C/C++ global variables is done through static getter and setter functions in the module class.

// SWIG interface file with global variables
%module example
...
%inline %{
extern int My_variable;
extern double density;
%}
...

Now in Java :

// Print out value of a C global variable
System.out.println("My_variable = " + example.getMy_variable());
// Set the value of a C global variable
example.setDensity(0.8442);

The value returned by the getter will always be up to date even if the value is changed in C. Note that the getters and setters produced follow the JavaBean property design pattern. That is the first letter of the variable name is capitalized and preceded with set or get. If you have the misfortune of wrapping two variables that differ only in the capitalization of their first letters, use %rename to change one of the variable names. For example:

%rename Clash RenamedClash;
float Clash;
int clash;

If a variable is declared as const, it is wrapped as a read-only variable. That is only a getter is produced.

To make ordinary variables read-only, you can use the %immutable directive. For example:

%{
extern char *path;
%}
%immutable;
extern char *path;
%mutable;

The %immutable directive stays in effect until it is explicitly disabled or cleared using %mutable. See the Creating read-only variables section for further details.

If you just want to make a specific variable immutable, supply a declaration name. For example:

%{
extern char *path;
%}
%immutable path;
...
extern char *path;      // Read-only (due to %immutable)

25.3.4 Constants

C/C++ constants are wrapped as Java static final variables. To create a constant, use #define or the %constant directive. For example:

#define PI 3.14159
#define VERSION "1.0"
%constant int FOO = 42;
%constant const char *path = "/usr/local";

By default the generated static final variables are initialized by making a JNI call to get their value. The constants are generated into the constants interface and look like this:

public interface exampleConstants {
  public final static double PI = exampleJNI.PI_get();
  public final static String VERSION = exampleJNI.VERSION_get();
  public final static int FOO = exampleJNI.FOO_get();
  public final static String path = exampleJNI.path_get();
}

Note that SWIG has inferred the C type and used an appropriate Java type that will fit the range of all possible values for the C type. By default SWIG generates runtime constants. They are not compiler constants that can, for example, be used in a switch statement. This can be changed by using the %javaconst(flag) directive. It works like all the other %feature directives. The default is %javaconst(0). It is possible to initialize all wrapped constants from pure Java code by placing a %javaconst(1) before SWIG parses the constants. Putting it at the top of your interface file would ensure this. Here is an example:

%javaconst(1);
%javaconst(0) BIG;
%javaconst(0) LARGE;

#define EXPRESSION (0x100+5)
#define BIG 1000LL
#define LARGE 2000ULL

generates:

public interface exampleConstants {
  public final static int EXPRESSION = (0x100+5);
  public final static long BIG = exampleJNI.BIG_get();
  public final static java.math.BigInteger LARGE = exampleJNI.LARGE_get();
}

Note that SWIG has inferred the C long long type from BIG and used an appropriate Java type (long) as a Java long is the smallest sized Java type that will take all possible values for a C long long. Similarly for LARGE.

Be careful using the %javaconst(1) directive as not all C code will compile as Java code. For example neither the 1000LL value for BIG nor 2000ULL for LARGE above would generate valid Java code. The example demonstrates how you can target particular constants (BIG and LARGE) with %javaconst. SWIG doesn't use %javaconst(1) as the default as it tries to generate code that will always compile. However, using a %javaconst(1) at the top of your interface file is strongly recommended as the preferred compile time constants will be generated and most C constants will compile as Java code and in any case the odd constant that doesn't can be fixed using %javaconst(0).

There is an alternative directive which can be used for these rare constant values that won't compile as Java code. This is the %javaconstvalue(value) directive, where value is a Java code replacement for the C constant and can be either a string or a number. This is useful if you do not want to use either the parsed C value nor a JNI call, such as when the C parsed value will not compile as Java code and a compile time constant is required. The same example demonstrates this:

%javaconst(1);
%javaconstvalue("new java.math.BigInteger(\"2000\")") LARGE;
%javaconstvalue(1000) BIG;

#define EXPRESSION (0x100+5)
#define BIG 1000LL
#define LARGE 2000ULL

Note the string quotes for "2000" are escaped. The following is then generated:

public interface exampleConstants {
  public final static int EXPRESSION = (0x100+5);
  public final static long BIG = 1000;
  public final static java.math.BigInteger LARGE = new java.math.BigInteger("2000");
}

Note: declarations declared as const are wrapped as read-only variables and will be accessed using a getter as described in the previous section. They are not wrapped as constants. The exception to this rule are static const integral values defined within a class/struct, where they are wrapped as constants, eg:.

struct Maths {
  static const int FIVE = 5;
};

Compatibility Note: In SWIG-1.3.19 and earlier releases, the constants were generated into the module class and the constants interface didn't exist. Backwards compatibility is maintained as the module class implements the constants interface (even though some consider this type of interface implementation to be bad practice):

public class example implements exampleConstants {
}

You thus have the choice of accessing these constants from either the module class or the constants interface, for example, example.EXPRESSION or exampleConstants.EXPRESSION. Or if you decide this practice isn't so bad and your own class implements exampleConstants, you can of course just use EXPRESSION.

25.3.5 Enumerations

SWIG handles both named and unnamed (anonymous) enumerations. There is a choice of approaches to wrapping named C/C++ enums. This is due to historical reasons as SWIG's initial support for enums was limited and Java did not originally have support for enums. Each approach has advantages and disadvantages and it is important for the user to decide which is the most appropriate solution. There are four approaches of which the first is the default approach based on the so called Java typesafe enum pattern. The second generates proper Java enums. The final two approaches use simple integers for each enum item. Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.

25.3.5.1 Anonymous enums

There is no name for anonymous enums and so they are handled like constants. For example:

enum { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

is wrapped into the constants interface, in a similar manner as constants (see previous section):

public interface exampleConstants {
  public final static int ALE = exampleJNI.ALE_get();
  public final static int LAGER = exampleJNI.LAGER_get();
  public final static int STOUT = exampleJNI.STOUT_get();
  public final static int PILSNER = exampleJNI.PILSNER_get();
  public final static int PILZ = exampleJNI.PILZ_get();
}

The %javaconst(flag) and %javaconstvalue(value) directive introduced in the previous section on constants can also be used with enums. As is the case for constants, the default is %javaconst(0) as not all C values will compile as Java code. However, it is strongly recommended to add in a %javaconst(1) directive at the top of your interface file as it is only on very rare occasions that this will produce code that won't compile under Java. Using %javaconst(1) will ensure compile time constants are generated, thereby allowing the enum values to be used in Java switch statements. Example usage:

%javaconst(1);
%javaconst(0) PILSNER;
enum { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

generates:

public interface exampleConstants {
  public final static int ALE = 0;
  public final static int LAGER = 10;
  public final static int STOUT = LAGER + 1;
  public final static int PILSNER = exampleJNI.PILSNER_get();
  public final static int PILZ = PILSNER;
}

As in the case of constants, you can access them through either the module class or the constants interface, for example, example.ALE or exampleConstants.ALE.

25.3.5.2 Typesafe enums

This is the default approach to wrapping named enums. The typesafe enum pattern is a relatively well known construct to work around the lack of enums in versions of Java prior to JDK 1.5. It basically defines a class for the enumeration and permits a limited number of final static instances of the class. Each instance equates to an enum item within the enumeration. The implementation is in the "enumtypesafe.swg" file. Let's look at an example:

%include "enumtypesafe.swg" // optional as typesafe enums are the default
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

will generate:

public final class Beverage {
  public final static Beverage ALE = new Beverage("ALE");
  public final static Beverage LAGER = new Beverage("LAGER", exampleJNI.LAGER_get());
  public final static Beverage STOUT = new Beverage("STOUT");
  public final static Beverage PILSNER = new Beverage("PILSNER");
  public final static Beverage PILZ = new Beverage("PILZ", exampleJNI.PILZ_get());
  [... additional support methods omitted for brevity ...]
}

See Typesafe enum classes to see the omitted support methods. Note that the enum item with an initializer (LAGER) is initialized with the enum value obtained via a JNI call. However, as with anonymous enums and constants, use of the %javaconst directive is strongly recommended to change this behaviour:

%include "enumtypesafe.swg" // optional as typesafe enums are the default
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

will generate:

public final class Beverage {
  public final static Beverage ALE = new Beverage("ALE");
  public final static Beverage LAGER = new Beverage("LAGER", 10);
  public final static Beverage STOUT = new Beverage("STOUT");
  public final static Beverage PILSNER = new Beverage("PILSNER");
  public final static Beverage PILZ = new Beverage("PILZ", PILSNER);
  [... additional support methods omitted for brevity ...]
}

The generated code is easier to read and more efficient as a true constant is used instead of a JNI call. As is the case for constants, the default is %javaconst(0) as not all C values will compile as Java code. However, it is recommended to add in a %javaconst(1) directive at the top of your interface file as it is only on very rare occasions that this will produce code that won't compile under Java. The %javaconstvalue(value) directive can also be used for typesafe enums. Note that global enums are generated into a Java class within whatever package you are using. C++ enums defined within a C++ class are generated into a static final inner Java class within the Java proxy class.

Typesafe enums have their advantages over using plain integers in that they can be used in a typesafe manner. However, there are limitations. For example, they cannot be used in switch statements and serialization is an issue. Please look at the following references for further information: http://java.sun.com/developer/Books/shiftintojava/page1.html#replaceenums Replace Enums with Classes in Effective Java Programming on the Sun website, Create enumerated constants in Java JavaWorld article, Java Tip 133: More on typesafe enums and Java Tip 122: Beware of Java typesafe enumerations JavaWorld tips.

Note that the syntax required for using typesafe enums is the same as that for proper Java enums. This is useful during the period that a project has to support legacy versions of Java. When upgrading to JDK 1.5 or later, proper Java enums could be used instead, without users having to change their code. The following section details proper Java enum generation.

25.3.5.3 Proper Java enums

Proper Java enums were only introduced in JDK 1.5 so this approach is only compatible with more recent versions of Java. Java enums have been designed to overcome all the limitations of both typesafe and type unsafe enums and should be the choice solution, provided older versions of Java do not have to be supported. In this approach, each named C/C++ enum is wrapped by a Java enum. Java enums, by default, do not support enums with initializers. Java enums are in many respects similar to Java classes in that they can be customised with additional methods. SWIG takes advantage of this feature to facilitate wrapping C/C++ enums that have initializers. In order to wrap all possible C/C++ enums using proper Java enums, the "enums.swg" file must be used. Let's take a look at an example.

%include "enums.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

will generate:

public enum Beverage {
  ALE,
  LAGER(10),
  STOUT,
  PILSNER,
  PILZ(PILSNER);
  [... additional support methods omitted for brevity ...]
}

See Proper Java enum classes to see the omitted support methods. The generated Java enum has numerous additional methods to support enums with initializers, such as LAGER above. Note that as with the typesafe enum pattern, enum items with initializers are by default initialized with the enum value obtained via a JNI call. However, this is not the case above as we have used the recommended %javaconst(1) to avoid the JNI call. The %javaconstvalue(value) directive covered in the Constants section can also be used for proper Java enums.

The additional support methods need not be generated if none of the enum items have initializers and this is covered later in the Simpler Java enums for enums without initializers section.

25.3.5.4 Type unsafe enums

In this approach each enum item in a named enumeration is wrapped as a static final integer in a class named after the C/C++ enum name. This is a commonly used pattern in Java to simulate C/C++ enums, but it is not typesafe. However, the main advantage over the typesafe enum pattern is enum items can be used in switch statements. In order to use this approach, the "enumtypeunsafe.swg" file must be used. Let's take a look at an example.

%include "enumtypeunsafe.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

will generate:

public final class Beverage {
  public final static int ALE = 0;
  public final static int LAGER = 10;
  public final static int STOUT = LAGER + 1;
  public final static int PILSNER = STOUT + 1;
  public final static int PILZ = PILSNER;
}

As is the case previously, the default is %javaconst(0) as not all C/C++ values will compile as Java code. However, again it is recommended to add in a %javaconst(1) directive. and the %javaconstvalue(value) directive covered in the Constants section can also be used for type unsafe enums. Note that global enums are generated into a Java class within whatever package you are using. C++ enums defined within a C++ class are generated into a static final inner Java class within the Java proxy class.

Note that unlike typesafe enums, this approach requires users to mostly use different syntax compared with proper Java enums. Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.

25.3.5.5 Simple enums

This approach is similar to the type unsafe approach. Each enum item is also wrapped as a static final integer. However, these integers are not generated into a class named after the C/C++ enum. Instead, global enums are generated into the constants interface. Also, enums defined in a C++ class have their enum items generated directly into the Java proxy class rather than an inner class within the Java proxy class. In fact, this approach is effectively wrapping the enums as if they were anonymous enums and the resulting code is as per anonymous enums. The implementation is in the "enumsimple.swg" file.

Compatibility Note: SWIG-1.3.21 and earlier versions wrapped all enums using this approach. The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.

25.3.6 Pointers

C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Here is a rather simple interface:

%module example

FILE *fopen(const char *filename, const char *mode);
int fputs(const char *, FILE *);
int fclose(FILE *);

When wrapped, you will be able to use the functions in a natural way from Java. For example:

SWIGTYPE_p_FILE f = example.fopen("junk","w");
example.fputs("Hello World\n", f);
example.fclose(f);

C pointers in the Java module are stored in a Java long and cross the JNI boundary held within this 64 bit number. Many other SWIG language modules use an encoding of the pointer in a string. These scripting languages use the SWIG runtime type checker for dynamic type checking as they do not support static type checking by a compiler. In order to implement static type checking of pointers within Java, they are wrapped by a simple Java class. In the example above the FILE * pointer is wrapped with a type wrapper class called SWIGTYPE_p_FILE.

Once obtained, a type wrapper object can be freely passed around to different C functions that expect to receive an object of that type. The only thing you can't do is dereference the pointer from Java. Of course, that isn't much of a concern in this example.

As much as you might be inclined to modify a pointer value directly from Java, don't. The value is not necessarily the same as the logical memory address of the underlying object. The value will vary depending on the native byte-ordering of the platform (i.e., big-endian vs. little-endian). Most JVMs are 32 bit applications so any JNI code must also be compiled as 32 bit. The net result is pointers in JNI code are also 32 bits and are stored in the high order 4 bytes on big-endian machines and in the low order 4 bytes on little-endian machines. By design it is also not possible to manually cast a pointer to a new type by using Java casts as it is particularly dangerous especially when casting C++ objects. If you need to cast a pointer or change its value, consider writing some helper functions instead. For example:

%inline %{
/* C-style cast */
Bar *FooToBar(Foo *f) {
   return (Bar *) f;
}

/* C++-style cast */
Foo *BarToFoo(Bar *b) {
   return dynamic_cast<Foo*>(b);
}

Foo *IncrFoo(Foo *f, int i) {
    return f+i;
}
%}

Also, if working with C++, you should always try to use the new C++ style casts. For example, in the above code, the C-style cast may return a bogus result whereas as the C++-style cast will return a NULL pointer if the conversion can't be performed.

25.3.7 Structures

If you wrap a C structure, it is wrapped by a Java class with getters and setters for access to the member variables. For example,

struct Vector {
	double x,y,z;
};

is used as follows:

Vector v = new Vector();
v.setX(3.5);
v.setY(7.2);
double x = v.getX();
double y = v.getY();

The variable setters and getters are also based on the JavaBean design pattern already covered under the Global variables section. Similar access is provided for unions and the public data members of C++ classes.

This object is actually an instance of a Java class that has been wrapped around a pointer to the C structure. This instance doesn't actually do anything--it just serves as a proxy. The pointer to the C object is held in the Java proxy class in much the same way as pointers are held by type wrapper classes. Further details about Java proxy classes are covered a little later.

const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive. For example:

struct Foo {
   ...
   %immutable;
   int x;        /* Read-only members */
   char *name;
   %mutable;
   ...
};

When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run with the -c++ option). When the structure member is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described later).

If a structure contains arrays, access to those arrays is managed through pointers. For example, consider this:

struct Bar {
    int  x[16];
};

If accessed in Java, you will see behavior like this:

Bar b = new Bar();
SWIGTYPE_p_int x = b.getX();

This pointer can be passed around to functions that expect to receive an int * (just like C). You can also set the value of an array member using another pointer. For example:

Bar b = new Bar();
SWIGTYPE_p_int x = b.getX();
Bar c = new Bar();
c.setX(x);                    // Copy contents of b.x to c.x

For array assignment (setters not getters), SWIG copies the entire contents of the array starting with the data pointed to by b.x. In this example, 16 integers would be copied. Like C, SWIG makes no assumptions about bounds checking---if you pass a bad pointer, you may get a segmentation fault or access violation. The default wrapping makes it hard to set or get just one element of the array and so array access from Java is somewhat limited. This can be changed easily though by using the approach outlined later in the Wrapping C arrays with Java arrays and Unbounded C Arrays sections.

When a member of a structure is itself a structure, it is handled as a pointer. For example, suppose you have two structures like this:

struct Foo {
   int a;
};

struct Bar {
   Foo f;
};

Now, suppose that you access the f member of Bar like this:

Bar b = new Bar();
Foo x = b.getF();

In this case, x is a pointer that points to the Foo that is inside b. This is the same value as generated by this C code:

Bar b;
Foo *x = &b->f;       /* Points inside b */

Because the pointer points inside the structure, you can modify the contents and everything works just like you would expect. For example:

Bar b = new Bar();
b.getF().setA(3);   // Modify b.f.a
Foo x = b.getF();                   
x.setA(3);          // Modify x.a - this is the same as b.f.a

25.3.8 C++ classes

C++ classes are wrapped by Java classes as well. For example, if you have this class,

class List {
public:
  List();
  ~List();
  int  search(char *item);
  void insert(char *item);
  void remove(char *item);
  char *get(int n);
  int  length;
};

you can use it in Java like this:

List l = new List();
l.insert("Ale");
l.insert("Stout");
l.insert("Lager");
String item = l.get(2);
int length = l.getLength();

Class data members are accessed in the same manner as C structures.

Static class members are unsurprisingly wrapped as static members of the Java class:

class Spam {
public:
   static void foo();
   static int bar;
};

The static members work like any other Java static member:

Spam.foo();
int bar = Spam.getBar();

25.3.9 C++ inheritance

SWIG is fully aware of issues related to C++ inheritance. Therefore, if you have classes like this

class Foo {
...
};

class Bar : public Foo {
...
};

those classes are wrapped into a hierarchy of Java classes that reflect the same inheritance structure:

Bar b = new Bar();
Class c = b.getClass();
System.out.println(c.getSuperclass().getName());

will of course display:

Foo

Furthermore, if you have functions like this

void spam(Foo *f);

then the Java function spam() accepts instances of Foo or instances of any other proxy classes derived from Foo.

Note that Java does not support multiple inheritance so any multiple inheritance in the C++ code is not going to work. A warning is given when multiple inheritance is detected and only the first base class is used.

25.3.10 Pointers, references, arrays and pass by value

In C++, there are many different ways a function might receive and manipulate objects. For example:

void spam1(Foo *x);      // Pass by pointer
void spam2(Foo &x);      // Pass by reference
void spam3(Foo x);       // Pass by value
void spam4(Foo x[]);     // Array of objects

In Java, there is no detailed distinction like this--specifically, there are only instances of classes. There are no pointers nor references. Because of this, SWIG unifies all of these types together in the wrapper code. For instance, if you actually had the above functions, it is perfectly legal to do this from Java:

Foo f = new Foo();  // Create a Foo
example.spam1(f);   // Ok. Pointer
example.spam2(f);   // Ok. Reference
example.spam3(f);   // Ok. Value.
example.spam4(f);   // Ok. Array (1 element)

Similar behavior occurs for return values. For example, if you had functions like this,

Foo *spam5();
Foo &spam6();
Foo  spam7();

then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Java will release this memory when the returned object's finalizer is run by the garbage collector).

25.3.10.1 Null pointers

Working with null pointers is easy. A Java null can be used whenever a method expects a proxy class or typewrapper class. However, it is not possible to pass null to C/C++ functions that take parameters by value or by reference. If you try you will get a NullPointerException.

example.spam1(null);   // Pointer - ok
example.spam2(null);   // Reference - NullPointerException
example.spam3(null);   // Value - NullPointerException
example.spam4(null);   // Array - ok

For spam1 and spam4 above the Java null gets translated into a NULL pointer for passing to the C/C++ function. The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.

25.3.11 C++ overloaded functions

C++ overloaded functions, methods, and constructors are mostly supported by SWIG. For example, if you have two functions like this:

%module example

void foo(int);
void foo(char *c);

You can use them in Java in a straightforward manner:

example.foo(3);           // foo(int)
example.foo("Hello");     // foo(char *c)

Similarly, if you have a class like this,

class Foo {
public:
    Foo();
    Foo(const Foo &);
    ...
};

you can write Java code like this:

Foo f = new Foo();        // Create a Foo
Foo g = new Foo(f);       // Copy f

Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG cannot disambiguate as there can be more than one C++ type mapping onto a single Java type. For example:

void spam(int);
void spam(unsigned short);

Here both int and unsigned short map onto a Java int. Here is another example:

void foo(Bar *b);
void foo(Bar &b);

If declarations such as these appear, you will get a warning message like this:

example.i:12: Warning 515: Overloaded method spam(unsigned short) ignored.
Method spam(int) at example.i:11 used.

To fix this, you either need to either rename or ignore one of the methods. For example:

%rename(spam_ushort) spam(unsigned short);
...
void spam(int);    
void spam(unsigned short);   // Now renamed to spam_ushort

or

%ignore spam(unsigned short);
...
void spam(int);    
void spam(unsigned short);   // Ignored

25.3.12 C++ default arguments

Any function with a default argument is wrapped by generating an additional function for each argument that is defaulted. For example, if we have the following C++:

%module example

void defaults(double d=10.0, int i=0);

The following methods are generated in the Java module class:

public class example {
  public static void defaults(double d, int i) { ... }
  public static void defaults(double d) { ... }
  public static void defaults() { ... }
}

It is as if SWIG had parsed three separate overloaded methods. The same approach is taken for static methods, constructors and member methods.

Compatibility note: Versions of SWIG prior to SWIG-1.3.23 wrapped these with a single wrapper method and so the default values could not be taken advantage of from Java. Further details on default arguments and how to restore this approach are given in the more general Default arguments section.

25.3.13 C++ namespaces

SWIG is aware of named C++ namespaces and they can be mapped to Java packages, however, the default wrapping flattens the namespaces, effectively ignoring them. So by default, the namespace names do not appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

%module example

namespace foo {
   int fact(int n);
   struct Vector {
       double x,y,z;
   };
};

it works in Java as follows:

int f = example.fact(3);
Vector v = new Vector();
v.setX(3.4);
double y = v.getY();

If your program has more than one namespace, name conflicts (if any) can be resolved using %rename For example:

%rename(Bar_spam) Bar::spam;

namespace Foo {
    int spam();
}

namespace Bar {
    int spam();
}

If you have more than one namespace and you want to keep their symbols separate, consider wrapping them as separate SWIG modules. Each SWIG module can be placed into a separate package.

The default behaviour described above can be improved via the nspace feature. Note that it only works for classes, structs, unions and enums declared within a named C++ namespace. When the nspace feature is used, the C++ namespaces are converted into Java packages of the same name. Proxy classes are thus declared within a package and this proxy makes numerous calls to the JNI intermediary class which is declared in the unnamed package by default. As Java does not support types declared in a named package accessing types declared in an unnamed package, the -package commandline option described earlier generally should be used to provide a parent package. So if SWIG is run using the -package com.myco option, a wrapped class, MyWorld::Material::Color, can then be accessed as com.myco.MyWorld.Material.Color. If you don't specify a package, you will get the following warning:

example.i:16: Warning 826: The nspace feature is used on 'MyWorld::Material::Color' without -package. The generated code 
may not compile as Java does not support types declared in a named package accessing types declared in an unnamed package.

If it is undesirable to have a single top level package, the nspace feature may be used without the -package commandline option (and the resulting warning ignored) if all of the types exposed using SWIG are placed in a package using the nspace feature and the 'jniclasspackage' pragma is used to specify a package for the JNI intermediary class.

If the resulting use of the nspace feature and hence packages results in a proxy class in one package deriving or using a proxy class from another package, you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

25.3.14 C++ templates

C++ templates don't present a huge problem for SWIG. However, in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the %template directive. For example:

%module example
%{
#include <utility>
%}

template<class T1, class T2>
struct pair {
   typedef T1 first_type;
   typedef T2 second_type;
   T1 first;
   T2 second;
   pair();
   pair(const T1&, const T2&);
  ~pair();
};

%template(pairii) pair<int,int>;

In Java:

pairii p = new pairii(3,4);
int first = p.getFirst();
int second = p.getSecond();

Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.

25.3.15 C++ Smart Pointers

In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

template<class T> class SmartPtr {
   ...
   T *operator->();
   ...
}

Then, if you have a class like this,

class Foo {
public:
     int x;
     int bar();
};

A smart pointer would be used in C++ as follows:

SmartPtr<Foo> p = CreateFoo();   // Created somehow (not shown)
...
p->x = 3;                        // Foo::x
int y = p->bar();                // Foo::bar

To wrap this in Java, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using %template if necessary. For example:

%module example
...
%template(SmartPtrFoo) SmartPtr<Foo>;
...

Now, in Java, everything should just "work":

SmartPtrFoo p = example.CreateFoo(); // Create a smart-pointer somehow
p.setX(3);                           // Foo::x
int y = p.bar();                     // Foo::bar

If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

Foo f = p.__deref__();               // Returns underlying Foo *

25.4 Further details on the generated Java classes

In the previous section, a high-level view of Java wrapping was presented. A key component of this wrapping is that structures and classes are wrapped by Java proxy classes and type wrapper classes are used in situations where no proxies are generated. This provides a very natural, type safe Java interface to the C/C++ code and fits in with the Java programming paradigm. However, a number of low-level details were omitted. This section provides a brief overview of how the proxy classes work and then covers the type wrapper classes. Finally enum classes are covered. First, the crucial intermediary JNI class is considered.

25.4.1 The intermediary JNI class

In the "SWIG basics" and "SWIG and C++" chapters, details of low-level structure and class wrapping are described. To summarize those chapters, if you have a global function and class like this

class Foo {
public:
     int x;
     int spam(int num, Foo* foo);
};
void egg(Foo* chips);

then SWIG transforms the class into a set of low-level procedural wrappers. These procedural wrappers essentially perform the equivalent of this C++ code:

Foo *new_Foo() {
    return new Foo();
}
void delete_Foo(Foo *f) {
    delete f;
}
int Foo_x_get(Foo *f) {
    return f->x;
}
void Foo_x_set(Foo *f, int value) {
    f->x = value;
}
int Foo_spam(Foo *f, int num, Foo* foo) {
    return f->spam(num, foo);
}

These procedural function names don't actually exist, but their functionality appears inside the generated JNI functions. The JNI functions have to follow a particular naming convention so the function names are actually:

SWIGEXPORT jlong JNICALL Java_exampleJNI_new_1Foo(JNIEnv *jenv, jclass jcls);
SWIGEXPORT void JNICALL Java_exampleJNI_delete_1Foo(JNIEnv *jenv, jclass jcls,
                                                    jlong jarg1);
SWIGEXPORT void JNICALL Java_exampleJNI_Foo_1x_1set(JNIEnv *jenv, jclass jcls,
                                                    jlong jarg1, jobject jarg1_, jint jarg2);
SWIGEXPORT jint JNICALL Java_exampleJNI_Foo_1x_1get(JNIEnv *jenv, jclass jcls,
                                                    jlong jarg1, jobject jarg1_);
SWIGEXPORT jint JNICALL Java_exampleJNI_Foo_1spam(JNIEnv *jenv, jclass jcls,
                                                  jlong jarg1, jobject jarg1_, jint jarg2,
                                                  jlong jarg3, jobject jarg3_);
SWIGEXPORT void JNICALL Java_exampleJNI_egg(JNIEnv *jenv, jclass jcls,
                                            jlong jarg1, jobject jarg1_);

For every JNI C function there has to be a static native Java function. These appear in the intermediary JNI class:

class exampleJNI {
  public final static native long new_Foo();
  public final static native void delete_Foo(long jarg1);
  public final static native void Foo_x_set(long jarg1, Foo jarg1_, int jarg2);
  public final static native int Foo_x_get(long jarg1, Foo jarg1_);
  public final static native int Foo_spam(long jarg1, Foo jarg1_, int jarg2,
                                          long jarg3, Foo jarg3_);
  public final static native void egg(long jarg1, Foo jarg1_);
}

This class contains the complete Java - C/C++ interface so all function calls go via this class. As this class acts as a go-between for all JNI calls to C/C++ code from the Java proxy classes, type wrapper classes and module class, it is known as the intermediary JNI class.

You may notice that SWIG uses a Java long wherever a pointer or class object needs to be marshalled across the Java-C/C++ boundary. This approach leads to minimal JNI code which makes for better performance as JNI code involves a lot of string manipulation. SWIG favours generating Java code over JNI code as Java code is compiled into byte code and avoids the costly string operations needed in JNI code. This approach has a downside though as the proxy class might get collected before the native method has completed. You might notice above that there is an additional parameters with a underscore postfix, eg jarg1_. These are added in order to prevent premature garbage collection when marshalling proxy classes.

The functions in the intermediary JNI class cannot be accessed outside of its package. Access to them is gained through the module class for globals otherwise the appropriate proxy class.

The name of the intermediary JNI class can be changed from its default, that is, the module name with JNI appended after it. The module directive attribute jniclassname is used to achieve this:

%module (jniclassname="name") modulename

If name is the same as modulename then the module class name gets changed from modulename to modulenameModule.

25.4.1.1 The intermediary JNI class pragmas

The intermediary JNI class can be tailored through the use of pragmas, but is not commonly done. The pragmas for this class are:

Pragma Description
jniclassbase Base class for the intermediary JNI class
jniclasspackage Package in which to place the intermediary JNI class
jniclassclassmodifiers Class modifiers and class type for the intermediary JNI class
jniclasscode Java code is copied verbatim into the intermediary JNI class
jniclassimports Java code, usually one or more import statements, placed before the intermediary JNI class definition
jniclassinterfaces Comma separated interface classes for the intermediary JNI class

The pragma code appears in the generated intermediary JNI class where you would expect:

[ jniclassimports pragma ]
[ jniclassclassmodifiers pragma ] jniclassname extends [ jniclassbase pragma ]
                                          implements [ jniclassinterfaces pragma ] {
[ jniclasscode pragma ]
... SWIG generated native methods ...
}

The jniclasscode pragma is quite useful for adding in a static block for loading the shared library / dynamic link library and demonstrates how pragmas work:

%pragma(java) jniclasscode=%{
  static {
    try {
        System.loadLibrary("example");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load. \n" + e);
      System.exit(1);
    }
  }
%}

Pragmas will take either "" or %{ %} as delimiters. For example, let's change the intermediary JNI class access to just the default package-private access.

%pragma(java) jniclassclassmodifiers="class"

All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

25.4.2 The Java module class

All global functions and variable getters/setters appear in the module class. For our example, there is just one function:

public class example {
  public static void egg(Foo chips) {
    exampleJNI.egg(Foo.getCPtr(chips), chips);
  }
}

The module class is necessary as there is no such thing as a global in Java so all the C globals are put into this class. They are generated as static functions and so must be accessed as such by using the module name in the static function call:

example.egg(new Foo());

The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.

25.4.2.1 The Java module class pragmas

The module class can be tailored through the use of pragmas, in the same manner as the intermediary JNI class. The pragmas are similarly named and are used in the same way. The complete list follows:

Pragma Description
modulebase Base class for the module class
moduleclassmodifiers Class modifiers and class type for the module class
modulecode Java code is copied verbatim into the module class
moduleimports Java code, usually one or more import statements, placed before the module class definition
moduleinterfaces Comma separated interface classes for the module class

The pragma code appears in the generated module class like this:

[ moduleimports pragma ]
[ modulemodifiers pragma ] modulename extends [ modulebase pragma ]
                                      implements [ moduleinterfaces pragma ] {
[ modulecode pragma ]
... SWIG generated wrapper functions ...
}

See The intermediary JNI class pragmas section for further details on using pragmas.

25.4.3 Java proxy classes

A Java proxy class is generated for each structure, union or C++ class that is wrapped. Proxy classes have also been called peer classes. The default proxy class for our previous example looks like this:

public class Foo {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected Foo(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Foo obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      exampleJNI.delete_Foo(swigCPtr);
    }
    swigCPtr = 0;
  }

  public void setX(int value) {
    exampleJNI.Foo_x_set(swigCPtr, this, value);
  }

  public int getX() {
    return exampleJNI.Foo_x_get(swigCPtr, this);
  }

  public int spam(int num, Foo foo) {
    return exampleJNI.Foo_spam(swigCPtr, this, num, Foo.getCPtr(foo), foo);
  }

  public Foo() {
    this(exampleJNI.new_Foo(), true);
  }

}

This class merely holds a pointer to the underlying C++ object (swigCPtr). It also contains all the methods in the C++ class it is proxying plus getters and setters for public member variables. These functions call the native methods in the intermediary JNI class. The advantage of having this extra layer is the type safety that the proxy class functions offer. It adds static type checking which leads to fewer surprises at runtime. For example, you can see that if you attempt to use the spam() function it will only compile when the parameters passed are an int and a Foo. From a user's point of view, it makes the class work as if it were a Java class:

Foo f = new Foo();
f.setX(3);
int y = f.spam(5, new Foo());

25.4.3.1 Memory management

Each proxy class has an ownership flag swigCMemOwn. The value of this flag determines who is responsible for deleting the underlying C++ object. If set to true, the proxy class's finalizer will destroy the C++ object when the proxy class is garbage collected. If set to false, then the destruction of the proxy class has no effect on the C++ object.

When an object is created by a constructor or returned by value, Java automatically takes ownership of the result. On the other hand, when pointers or references are returned to Java, there is often no way to know where they came from. Therefore, the ownership is set to false. For example:

class Foo {
public:
    Foo();
    Foo bar1();
    Foo &bar2();
    Foo *bar2();
};

In Java:

Foo f = new Foo();   //  f.swigCMemOwn = true
Foo f1 = f.bar1();   // f1.swigCMemOwn = true
Foo f2 = f.bar2();   // f2.swigCMemOwn = false
Foo f3 = f.bar3();   // f3.swigCMemOwn = false

This behavior for pointers and references is especially important for classes that act as containers. For example, if a method returns a pointer to an object that is contained inside another object, you definitely don't want Java to assume ownership and destroy it!

For the most part, memory management issues remain hidden. However, there are situations where you might have to manually change the ownership of an object. For instance, consider code like this:

class Obj {};
class Node {
   Obj *value;
public:
   void set_value(Obj *v) { value = v; }
};

Now, consider the following Java code:

Node n = new Node();    // Create a node
{
  Obj o = new Obj();    // Create an object
  n.set_value(o);       // Set value
}                       // o goes out of scope

In this case, the Node n is holding a reference to o internally. However, SWIG has no way to know that this has occurred. The Java proxy class still thinks that it has ownership of o. As o has gone out of scope, it could be garbage collected in which case the C++ destructor will be invoked and n will then be holding a stale-pointer to o. If you're lucky, you will only get a segmentation fault.

To work around this, the ownership flag of o needs changing to false. The ownership flag is a private member variable of the proxy class so this is not possible without some customization of the proxy class. This can be achieved by using a typemap to customise the proxy class with pure Java code as detailed later in the section on Java typemaps.

Sometimes a function will create memory and return a pointer to a newly allocated object. SWIG has no way of knowing this so by default the proxy class does not manage the returned object. However, you can tell the proxy class to manage the memory if you specify the %newobject directive. Consider:

class Obj {...};
class Factory {
public:
    static Obj *createObj() { return new Obj(); }
};

If we call the factory function, then we have to manually delete the memory:

Obj obj = Factory.createObj();   // obj.swigCMemOwn = false
...
obj.delete();

Now add in the %newobject directive:

%newobject Factory::createObj();

class Obj {...};
class Factory {
public:
    static Obj *createObj() { return new Obj(); }
};

A call to delete() is no longer necessary as the garbage collector will make the C++ destructor call because swigCMemOwn is now true.

Obj obj = Factory.createObj();   // obj.swigCMemOwn = true;
...

Some memory management issues are quite tricky to fix and may only be noticeable after using for a long time. One such issue is premature garbage collection of an object created from Java and resultant usage from C++ code. The section on typemap examples cover two such scenarios, Memory management for objects passed to the C++ layer and Memory management when returning references to member variables

25.4.3.2 Inheritance

Java proxy classes will mirror C++ inheritance chains. For example, given the base class Base and its derived class Derived:

class Base {
public:
  virtual double foo();
};

class Derived : public Base {
public:
  virtual double foo();
};

The base class is generated much like any other proxy class seen so far:

public class Base {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected Base(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Base obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      exampleJNI.delete_Base(swigCPtr);
    }
    swigCPtr = 0;
  }

  public double foo() {
    return exampleJNI.Base_foo(swigCPtr, this);
  }

  public Base() {
    this(exampleJNI.new_Base(), true);
  }

}

The Derived class extends Base mirroring the C++ class inheritance hierarchy.

public class Derived extends Base {
  private long swigCPtr;

  protected Derived(long cPtr, boolean cMemoryOwn) {
    super(exampleJNI.SWIGDerivedUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Derived obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      exampleJNI.delete_Derived(swigCPtr);
    }
    swigCPtr = 0;
    super.delete();
  }

  public double foo() {
    return exampleJNI.Derived_foo(swigCPtr, this);
  }

  public Derived() {
    this(exampleJNI.new_Derived(), true);
  }

}

Note the memory ownership is controlled by the base class. However each class in the inheritance hierarchy has its own pointer value which is obtained during construction. The SWIGDerivedUpcast() call converts the pointer from a Derived * to a Base *. This is a necessity as C++ compilers are free to implement pointers in the inheritance hierarchy with different values.

It is of course possible to extend Base using your own Java classes. If Derived is provided by the C++ code, you could for example add in a pure Java class Extended derived from Base. There is a caveat and that is any C++ code will not know about your pure Java class Extended so this type of derivation is restricted. However, true cross language polymorphism can be achieved using the directors feature.

25.4.3.3 Proxy classes and garbage collection

By default each proxy class has a delete() and a finalize() method. The finalize() method calls delete() which frees any malloc'd memory for wrapped C structs or calls the C++ class destructors. The idea is for delete() to be called when you have finished with the C/C++ object. Ideally you need not call delete(), but rather leave it to the garbage collector to call it from the finalizer. When a program exits, the garbage collector does not guarantee to call all finalizers. An insight into the reasoning behind this can be obtained from Hans Boehm's Destructors, Finalizers, and Synchronization paper. Depending on what the finalizers do and which operating system you use, this may or may not be a problem.

If the delete() call into JNI code is just for memory handling, there is not a problem when run on most operating systems, for example Windows and Unix. Say your JNI code creates memory on the heap which your finalizers should clean up, the finalizers may or may not be called before the program exits. In Windows and Unix all memory that a process uses is returned to the system on exit, so this isn't a problem. This is not the case in some operating systems like vxWorks. If however, your finalizer calls into JNI code invoking the C++ destructor which in turn releases a TCP/IP socket for example, there is no guarantee that it will be released. Note that with long running programs the garbage collector will eventually run, thereby calling any unreferenced object's finalizers.

Some not so ideal solutions are:

  1. Call the System.runFinalizersOnExit(true) or Runtime.getRuntime().runFinalizersOnExit(true) to ensure the finalizers are called before the program exits. The catch is that this is a deprecated function call as the documentation says:

    This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.

    In many cases you will be lucky and find that it works, but it is not to be advocated. Have a look at Java web site and search for runFinalizersOnExit.

  2. From jdk1.3 onwards a new function, addShutdownHook(), was introduced which is guaranteed to be called when your program exits. You can encourage the garbage collector to call the finalizers, for example, add this static block to the class that has the main() function:

      static {
        Runtime.getRuntime().addShutdownHook( 
          new Thread() {
            public void run() { System.gc(); System.runFinalization(); }
          }
        );
      }
    

    Although this usually works, the documentation doesn't guarantee that runFinalization() will actually call the finalizers. As the shutdown hook is guaranteed you could also make a JNI call to clean up any resources that are being tracked by the C/C++ code.

  3. Call the delete() function manually which will immediately invoke the C++ destructor. As a suggestion it may be a good idea to set the object to null so that should the object be inadvertently used again a Java null pointer exception is thrown, the alternative would crash the JVM by using a null C pointer. For example given a SWIG generated class A:

    A myA = new A();
    // use myA ...
    myA.delete();
    // any use of myA here would crash the JVM 
    myA=null;
    // any use of myA here would cause a Java null pointer exception to be thrown
    

    The SWIG generated code ensures that the memory is not deleted twice, in the event the finalizers get called in addition to the manual delete() call.

  4. Write your own object manager in Java. You could derive all SWIG classes from a single base class which could track which objects have had their finalizers run, then call the rest of them on program termination. The section on Java typemaps details how to specify a pure Java base class.

See the How to Handle Java Finalization's Memory-Retention Issues article for alternative approaches to managing memory by avoiding finalizers altogether.

25.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

As covered earlier, the C/C++ struct/class pointer is stored in the proxy class as a Java long and when needed is passed into the native method where it is cast into the appropriate type. This approach provides very fast marshalling but could be susceptible to premature garbage collection. Consider the following C++ code:

class Wibble {
};
void wobble(Wibble &w);

The module class contains the Java wrapper for the global wobble method:

public class example {
  ...
  public static void wobble(Wibble w) {
    exampleJNI.wobble(Wibble.getCPtr(w), w);
  }
}

where example is the name of the module. All native methods go through the intermediary class which has the native method declared as such:

public class exampleJNI {
  ...
  public final static native void wobble(long jarg1, Wibble jarg1_);
}

The second parameter, jarg1_, is the premature garbage collection prevention parameter and is added to the native method parameter list whenever a C/C++ struct or class is marshalled as a Java long. In order to understand why, consider the alternative where the intermediary class method is declared without the additional parameter:

public class exampleJNI {
  ...
  public final static native void wobble(long jarg1);
}

and the following simple call to wobble:

{
  Wibble w = new Wibble();
  example.wobble(w);
}

The hotspot compiler effectively sees something like:

{
  Wibble w = new Wibble();
  long w_ptr = Wibble.getCPtr(w);
  // w is no longer reachable
  exampleJNI.wobble(w_ptr);
}

The Wibble object is no longer reachable after the point shown as in this bit of code, the Wibble object is not referenced again after this point. This means that it is a candidate for garbage collection. Should wobble be a long running method, it is quite likely that the finalizer for the Wibble instance will be called. This in turn will call its underlying C++ destructor which is obviously disastrous while the method wobble is running using this object. Even if wobble is not a long running method, it is possible for the Wibble instance to be finalized. By passing the Wibble instance into the native method, it will not be finalized as the JVM guarantees not to finalize any objects until the native method returns. Effectively, the code then becomes

{
  Wibble w = new Wibble();
  long w_ptr = Wibble.getCPtr(w);
  exampleJNI.wobble(w_ptr, w);
  // w is no longer reachable
}

and therefore there is no possibility of premature garbage collection. In practice, this premature garbage collection was only ever observed in Sun's server JVM from jdk-1.3 onwards and in Sun's client JVM from jdk-1.6 onwards.

The premature garbage collection prevention parameter for proxy classes is generated by default whenever proxy classes are passed by value, reference or with a pointer. The implementation for this extra parameter generation requires the "jtype" typemap to contain long and the "jstype" typemap to contain the name of a proxy class.

The additional parameter does impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option. More selective suppression is possible with the 'nopgcpp' attribute in the "jtype" Java typemap. The attribute is a flag and so should be set to "1" to enable the suppression, or it can be omitted or set to "0" to disable. For example:

%typemap(jtype, nopgcpp="1") Wibble & "long"

Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

25.4.3.5 Single threaded applications and thread safety

Single threaded Java applications using JNI need to consider thread safety. The same applies for the C# module where the .NET wrappers use PInvoke. Consider the C++ class:

class Test {
  string str;
public:
  Test() : str("initial") {}
};

and the Java proxy class generated by SWIG:

public class Test {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected Test(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(Test obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  // Call C++ destructor
  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      exampleJNI.delete_Test(swigCPtr);
    }
    swigCPtr = 0;
  }

  // Call C++ constructor
  public Test() {
    this(exampleJNI.new_Test(), true);
  }

}

It has two methods that call JNI methods, namely, exampleJNI.new_Test() for the C++ constructor and exampleJNI.delete_Test() for the C++ destructor. If the garbage collector collects an instance of this class, ie delete() is not explicitly called, then the C++ destructor will be run in a different thread to the main thread. This is because when an object is marked for garbage collection, any objects with finalizers are added to a finalization queue and the objects in the finalization queue have their finalize() methods run in a separate finalization thread. Therefore, if the C memory allocator is not thread safe, then the heap will get corrupted sooner or later, when a concurrent C++ delete and new are executed. It is thus essential, even in single threaded usage, to link to the C multi-thread runtime libraries, for example, use the /MD option for Visual C++ on Windows. Alternatively, lock all access to C++ functions that have heap allocation/deallocation.

Note that some of the STL in Visual C++ 6 is not thread safe, so although code might be linked to the multithread runtime libraries, undefined behaviour might still occur in a single threaded Java program. Similarly some older versions of Sun Studio have bugs in the multi-threaded implementation of the std::string class and so will lead to undefined behaviour in these supposedly single threaded Java applications.

The following innocuous Java usage of Test is an example that will crash very quickly on a multiprocessor machine if the JNI compiled code is linked against the single thread C runtime libraries.

for (int i=0; i<100000; i++) {
  System.out.println("Iteration " + i);
  for (int k=0; k<10; k++) {
    Test test = new Test();
  }
  System.gc();
}

25.4.4 Type wrapper classes

The generated type wrapper class, for say an int *, looks like this:

public class SWIGTYPE_p_int {
  private long swigCPtr;

  protected SWIGTYPE_p_int(long cPtr, boolean bFutureUse) {
    swigCPtr = cPtr;
  }

  protected SWIGTYPE_p_int() {
    swigCPtr = 0;
  }

  protected static long getCPtr(SWIGTYPE_p_int obj) {
    return obj.swigCPtr;
  }
}

The methods do not have public access, so by default it is impossible to do anything with objects of this class other than pass them around. The methods in the class are part of the inner workings of SWIG. If you need to mess around with pointers you will have to use some typemaps specific to the Java module to achieve this. The section on Java typemaps details how to modify the generated code.

Note that if you use a pointer or reference to a proxy class in a function then no type wrapper class is generated because the proxy class can be used as the function parameter. If however, you need anything more complicated like a pointer to a pointer to a proxy class then a typewrapper class is generated for your use.

Note that SWIG generates a type wrapper class and not a proxy class when it has not parsed the definition of a type that gets used. For example, say SWIG has not parsed the definition of class Snazzy because it is in a header file that you may have forgotten to use the %include directive on. Should SWIG parse Snazzy * being used in a function parameter, it will then generates a type wrapper class around a Snazzy pointer. Also recall from earlier that SWIG will use a pointer when a class is passed by value or by reference:

void spam(Snazzy *x, Snazzy &y, Snazzy z);

Should SWIG not know anything about Snazzy then a SWIGTYPE_p_Snazzy must be used for all 3 parameters in the spam function. The Java function generated is:

public static void spam(SWIGTYPE_p_Snazzy x, SWIGTYPE_p_Snazzy y, SWIGTYPE_p_Snazzy z) {
 ...
}

Note that typedefs are tracked by SWIG and the typedef name is used to construct the type wrapper class name. For example, consider the case where Snazzy is a typedef to an int which SWIG does parse:

typedef int Snazzy;
void spam(Snazzy *x, Snazzy &y, Snazzy z);

Because the typedefs have been tracked the Java function generated is:

public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... }

25.4.5 Enum classes

SWIG can generate three types of enum classes. The Enumerations section discussed these but omitted all the details. The following sub-sections detail the various types of enum classes that can be generated.

25.4.5.1 Typesafe enum classes

The following example demonstrates the typesafe enum classes which SWIG generates:

%include "enumtypesafe.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

The following is the code that SWIG generates:

public final class Beverage {
  public final static Beverage ALE = new Beverage("ALE");
  public final static Beverage LAGER = new Beverage("LAGER", 10);
  public final static Beverage STOUT = new Beverage("STOUT");
  public final static Beverage PILSNER = new Beverage("PILSNER");
  public final static Beverage PILZ = new Beverage("PILZ", PILSNER);

  public final int swigValue() {
    return swigValue;
  }

  public String toString() {
    return swigName;
  }

  public static Beverage swigToEnum(int swigValue) {
    if (swigValue < swigValues.length && swigValue >= 0 &&
        swigValues[swigValue].swigValue == swigValue)
      return swigValues[swigValue];
    for (int i = 0; i < swigValues.length; i++)
      if (swigValues[i].swigValue == swigValue)
        return swigValues[i];
    throw new IllegalArgumentException("No enum " + Beverage.class + " with value " +
                                                                         swigValue);
  }

  private Beverage(String swigName) {
    this.swigName = swigName;
    this.swigValue = swigNext++;
  }

  private Beverage(String swigName, int swigValue) {
    this.swigName = swigName;
    this.swigValue = swigValue;
    swigNext = swigValue+1;
  }

  private Beverage(String swigName, Beverage swigEnum) {
    this.swigName = swigName;
    this.swigValue = swigEnum.swigValue;
    swigNext = this.swigValue+1;
  }

  private static Beverage[] swigValues = { ALE, LAGER, STOUT, PILSNER, PILZ };
  private static int swigNext = 0;
  private final int swigValue;
  private final String swigName;
}

As can be seen, there are a fair number of support methods for the typesafe enum pattern. The typesafe enum pattern involves creating a fixed number of static instances of the enum class. The constructors are private to enforce this. Three constructors are available - two for C/C++ enums with an initializer and one for those without an initializer. Note that the two enums with initializers, LAGER and PILZ, each call one the two different initializer constructors. In order to use one of these typesafe enums, the swigToEnum static method must be called to return a reference to one of the static instances. The JNI layer returns the enum value from the C/C++ world as an integer and this method is used to find the appropriate Java enum static instance. The swigValue method is used for marshalling in the other direction. The toString method is overridden so that the enum name is available.

25.4.5.2 Proper Java enum classes

The following example demonstrates the Java enums approach:

%include "enums.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

SWIG will generate the following Java enum:

public enum Beverage {
  ALE,
  LAGER(10),
  STOUT,
  PILSNER,
  PILZ(PILSNER);

  public final int swigValue() {
    return swigValue;
  }

  public static Beverage swigToEnum(int swigValue) {
    Beverage[] swigValues = Beverage.class.getEnumConstants();
    if (swigValue < swigValues.length && swigValue >= 0 &&
        swigValues[swigValue].swigValue == swigValue)
      return swigValues[swigValue];
    for (Beverage swigEnum : swigValues)
      if (swigEnum.swigValue == swigValue)
        return swigEnum;
    throw new IllegalArgumentException("No enum " + Beverage.class +
                                       " with value " + swigValue);
  }

  private Beverage() {
    this.swigValue = SwigNext.next++;
  }

  private Beverage(int swigValue) {
    this.swigValue = swigValue;
    SwigNext.next = swigValue+1;
  }

  private Beverage(Beverage swigEnum) {
    this.swigValue = swigEnum.swigValue;
    SwigNext.next = this.swigValue+1;
  }

  private final int swigValue;

  private static class SwigNext {
    private static int next = 0;
  }
}

The enum items appear first. Like the typesafe enum pattern, the constructors are private. The constructors are required to handle C/C++ enums with initializers. The next variable is in the SwigNext inner class rather than in the enum class as static primitive variables cannot be modified from within enum constructors. Marshalling between Java enums and the C/C++ enum integer value is handled via the swigToEnum and swigValue methods. All the constructors and methods in the Java enum are required just to handle C/C++ enums with initializers. These needn't be generated if the enum being wrapped does not have any initializers and the Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.

25.4.5.3 Type unsafe enum classes

The following example demonstrates type unsafe enums:

%include "enumtypeunsafe.swg"
%javaconst(1);
enum Beverage { ALE, LAGER=10, STOUT, PILSNER, PILZ=PILSNER };

SWIG will generate the following simple class:

public final class Beverage {
  public final static int ALE = 0;
  public final static int LAGER = 10;
  public final static int STOUT = LAGER + 1;
  public final static int PILSNER = STOUT + 1;
  public final static int PILZ = PILSNER;
}

25.5 Cross language polymorphism using directors

Proxy classes provide a natural, object-oriented way to wrap C++ classes. as described earlier, each proxy instance has an associated C++ instance, and method calls from Java to the proxy are passed to the C++ instance transparently via C wrapper functions.

This arrangement is asymmetric in the sense that no corresponding mechanism exists to pass method calls down the inheritance chain from C++ to Java. In particular, if a C++ class has been extended in Java (by deriving from the proxy class), these classes will not be visible from C++ code. Virtual method calls from C++ are thus not able to access the lowest implementation in the inheritance chain.

SWIG can address this problem and make the relationship between C++ classes and proxy classes more symmetric. To achieve this goal, new classes called directors are introduced at the bottom of the C++ inheritance chain. The job of the directors is to route method calls correctly, either to C++ implementations higher in the inheritance chain or to Java implementations lower in the inheritance chain. The upshot is that C++ classes can be extended in Java and from C++ these extensions look exactly like native C++ classes. Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.

25.5.1 Enabling directors

The director feature is disabled by default. To use directors you must make two changes to the interface file. First, add the "directors" option to the %module directive, like this:

%module(directors="1") modulename

Without this option no director code will be generated. Second, you must use the %feature("director") directive to tell SWIG which classes and methods should get directors. The %feature directive can be applied globally, to specific classes, and to specific methods, like this:

// generate directors for all classes that have virtual methods
%feature("director");         

// generate directors for all virtual methods in class Foo
%feature("director") Foo;      

You can use the %feature("nodirector") directive to turn off directors for specific classes or methods. So for example,

%feature("director") Foo;
%feature("nodirector") Foo::bar;

will generate directors for all virtual methods of class Foo except bar().

Directors can also be generated implicitly through inheritance. In the following, class Bar will get a director class that handles the methods one() and two() (but not three()):

%feature("director") Foo;
class Foo {
public:
    virtual void one();
    virtual void two();
};

class Bar: public Foo {
public:
    virtual void three();
};

25.5.2 Director classes

For each class that has directors enabled, SWIG generates a new class that derives from both the class in question and a special Swig::Director class. These new classes, referred to as director classes, can be loosely thought of as the C++ equivalent of the Java proxy classes. The director classes store a pointer to their underlying Java proxy classes.

For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). Thus all virtual method calls, whether they originate in C++ or in Java via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate place" we mean the method that would have been called if the C++ base class and its Java derived classes were seamlessly integrated. That seamless integration is exactly what the director classes provide, transparently skipping over all the messy JNI glue code that binds the two languages together.

In reality, the "appropriate place" is one of only two possibilities: C++ or Java. Once this decision is made, the rest is fairly easy. If the correct implementation is in C++, then the lowest implementation of the method in the C++ inheritance chain is called explicitly. If the correct implementation is in Java, the Java API is used to call the method of the underlying Java object (after which the usual virtual method resolution in Java automatically finds the right implementation).

25.5.3 Overhead and code bloat

Enabling directors for a class will generate a new director method for every virtual method in the class' inheritance chain. This alone can generate a lot of code bloat for large hierarchies. Method arguments that require complex conversions to and from Java types can result in large director methods. For this reason it is recommended that directors are selectively enabled only for specific classes that are likely to be extended in Java and used in C++.

Although directors make it natural to mix native C++ objects with Java objects (as director objects), one should be aware of the obvious fact that method calls to Java objects from C++ will be much slower than calls to C++ objects. Additionally, compared to classes that do not use directors, the call routing in the director methods adds a small overhead. This situation can be optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in Java.

25.5.4 Simple directors example

Consider the following SWIG interface file:

%module(directors="1") example;

%feature("director") DirectorBase;

class DirectorBase {
public:
  virtual ~DirectorBase() {}
  virtual void upcall_method() {}
};

void callup(DirectorBase *director) {
  director->upcall_method();
}

The following DirectorDerived Java class is derived from the Java proxy class DirectorBase and overrides upcall_method(). When C++ code invokes upcall_method(), the SWIG-generated C++ code redirects the call via JNI to the Java DirectorDerived subclass. Naturally, the SWIG generated C++ code and the generated Java intermediary class marshal and convert arguments between C++ and Java when needed.

public class DirectorDerived extends DirectorBase {
  public DirectorDerived() {
  }

  public void upcall_method() {
    System.out.println("DirectorDerived::upcall_method() invoked.");
  }
}

Running the following Java code

DirectorDerived director = new DirectorDerived();
example.callup(director);

will result in the following being output:

DirectorDerived::upcall_method() invoked.

25.5.5 Director threading issues

Depending on your operating system and version of Java and how you are using threads, you might find the JVM hangs on exit. There are a couple of solutions to try out. The preferred solution requires jdk-1.4 and later and uses AttachCurrentThreadAsDaemon instead of AttachCurrentThread whenever a call into the JVM is required. This can be enabled by defining the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro when compiling the C++ wrapper code. For older JVMs define SWIG_JAVA_NO_DETACH_CURRENT_THREAD instead, to avoid the DetachCurrentThread call but this will result in a memory leak instead. For further details inspect the source code in the java/director.swg library file.

Macros can be defined on the commandline when compiling your C++ code, or alternatively added to the C++ wrapper file as shown below:

%insert("runtime") %{
#define SWIG_JAVA_NO_DETACH_CURRENT_THREAD
%}

25.5.6 Director performance tuning

When a new instance of a director (or subclass) is created in Java, the C++ side of the director performs a runtime check per director method to determine if that particular method is overridden in Java or if it should invoke the C++ base implementation directly. Although this makes initialization slightly more expensive, it is generally a good overall tradeoff.

However, if all director methods are expected to usually be overridden by Java subclasses, then initialization can be made faster by avoiding these checks via the assumeoverride attribute. For example:

%feature("director", assumeoverride=1) Foo;

The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

25.5.7 Java exceptions from directors

With directors routing method calls to Java, and proxies routing them to C++, the handling of exceptions is an important concern. The default behavior from SWIG 3.0 onwards is to convert the thrown Java exception into a SWIG defined DirectorException C++ exception. SWIG 2.0 and earlier versions didn't provide any mechanism to handle the Java director method exceptions in C++.

Converting Java exceptions into C++ exceptions can be done in two different ways using the director:except feature. In the simplest approach, a code block is attached to each director method to handle the mapping of Java exceptions into C++ exceptions.

%feature("director:except") MyClass::method(int x) {
  jthrowable $error = jenv->ExceptionOccurred();
  if ($error) {
    jenv->ExceptionClear();
    if (Swig::ExceptionMatches(jenv, $error, "java/lang/IndexOutOfBoundsException"))
      throw std::out_of_range(Swig::JavaExceptionMessage(jenv, $error).message());
    if (Swig::ExceptionMatches(jenv, $error, "$packagepath/MyJavaException"))
      throw MyCppException(Swig::JavaExceptionMessage(jenv, $error).message());
    throw std::runtime_error("Unexpected exception thrown in MyClass::method");
  }
}

class MyClass {
  /** Throws either a std::out_of_range or MyCppException on error */
  void method(int x);
}

This approach allows a flexible mapping of Java exceptions thrown by director methods into C++ exceptions expected by a C++ caller. There need not be any C++ exception specifications on the C++ method. The utility function Swig::ExceptionMatches and class Swig::JavaExceptionMessage are provided to simplify writing code for wrappers that use the director:except feature. The function Swig::ExceptionMatches matches the type of the jthrowable thrown against a fully qualified JNI style class name, such as "java/lang/IOError". If the throwable class is the same type, or derives from the given type, Swig::ExceptionMatches will return true. Care must be taken to provide the correct fully qualified name, since for wrapped exceptions the generated proxy class will have additional package qualification, depending on the '-package' argument and use of the nspace feature. The special variable $error is expanded by SWIG into a unique variable name and should be used for the assignment of the exception that occurred. The special variable $packagepath is replaced by the outer package provided for SWIG generation by the -package option. The utility class Swig::JavaExceptionMessage is a holder providing access to the message from the thrown Java exception. The message() method returns the exception message as a const char *, which is only valid during the lifetime of the holder. Any code using this message needs to copy it, for example into a std::string or a newly constructed C++ exception.

Using the above approach to write handlers for a large number of methods will require repetitive duplication of the director:except feature code. To mitigate this, an alternative approach is provided via typemaps in a fashion analagous to the "throws" typemap. The "throws" typemap provides an approach to automatically map all the C++ exceptions listed in a method's defined exceptions (either from a C++ exception specification or a %catches feature) into Java exceptions. The "directorthrows" typemap provides the inverse mapping and should contain code to convert a suitably matching Java exception into a C++ exception. The example below converts a Java java.lang.IndexOutOfBoundsException exception to the typemap's type, that is std::out_of_range:

%typemap(directorthrows) std::out_of_range %{
  if (Swig::ExceptionMatches(jenv, $error, "java/lang/IndexOutOfBoundsException")) {
    throw std::out_of_range(Swig::JavaExceptionMessage(jenv, $error).message());
  }
%}

The "directorthrows" typemap is then used in conjunction with the director:except feature if the $directorthrowshandlers special variable is used in the feature code. Consider the following, which also happens to be the default:

%feature("director:except") %{
   jthrowable $error = jenv->ExceptionOccurred();
   if ($error) {
     jenv->ExceptionClear();
     $directorthrowshandlers
     throw Swig::DirectorException(jenv, $error);
   }
%}

The code generated using the director:except feature replaces the $directorthrowshandlers special variable with the code in the "directorthrows" typemaps, for each and every exception defined for the method. The possible exceptions can be defined either with a C++ exception specification or %catches as described for the "throws" typemap.

Consider the following director method:

  ...
  virtual void doSomething(int index) throw (std::out_of_range);
  ...

When combined with the default director:except feature and the "directorthrows" typemap above, the resulting code generated in the director method after calling up to Java will be:

jthrowable swigerror = jenv->ExceptionOccurred();
if (swigerror) {
  jenv->ExceptionClear();
  if (Swig::ExceptionMatches(jenv, swigerror, "java/lang/IndexOutOfBoundsException")) {
    throw std::out_of_range(Swig::JavaExceptionMessage(jenv, swigerror).message());
  }
  
  throw Swig::DirectorException(jenv, swigerror);
}

Note: Beware of using exception specifications as the SWIG director methods will be generated with the same exception specifications and if the director method throws an exception that is not specified it is likely to terminate your program. See the C++ standard for more details. Using the %catches feature instead to define the handled exceptions does not suffer this potential fate.

Because the default code generation maps any unhandled Java exceptions to Swig::DirectorException, any director methods that have exception specifications may cause program termination. To simply ignore unexpected exceptions, the default handling can be changed with:

%feature("director:except") %{
   jthrowable $error = jenv->ExceptionOccurred();
   if ($error) {
     jenv->ExceptionClear();
     $directorthrowshandlers
     return $null; // exception is ignored
   }
%}

Alternatively an exception compatible with the existing director method exception specifications can be thrown. Assuming that all methods allow std::runtime_error to be thrown, the return $null; could be changed to:

   throw std::runtime_error(Swig::JavaExceptionMessage(jenv, $error).message());

In more complex situations, a separate director:except feature may need to be attached to specific methods.

Below is a complete example demonstrating the use of the "directorthrows" typemaps. In this example, a generic "directorthrows" typemap is appropriate for all three exceptions - all take single string constructors. If the exceptions had different constructors, it would be neccessary to have separate typemaps for each exception type.

%module(directors="1") example

%{
  #include <string>
  #include <stdexcept>
%}

// Define exceptions in header section using std::runtime_error
%define DEFINE_EXCEPTION(NAME)
%{
  namespace MyNS {
    struct NAME : public std::runtime_error { NAME(const std::string &what) : runtime_error(what) {} };
  }
%}
%enddef

// Expose C++ exceptions as Java Exceptions by changing the Java base class and providing a getMessage()
%define DECLARE_EXCEPTION(NAME)
%typemap(javabase) MyNS::NAME "java.lang.Exception";
%rename(getMessage) MyNS::NAME::what;
namespace MyNS {
  struct NAME {
    NAME(const std::string& what);
    const char * what();
  };
}
%enddef

DEFINE_EXCEPTION(ExceptionA)
DEFINE_EXCEPTION(ExceptionB)
DEFINE_EXCEPTION(Unexpected)

// Mark three methods to map director thrown exceptions.
%feature("director:except") MyClass::meth1(int);
%feature("director:except") MyClass::meth2;
%feature("director:except") meth3;

%typemap(directorthrows) MyNS::ExceptionA, MyNS::ExceptionB, MyNS::Unexpected %{
  if (Swig::ExceptionMatches(jenv, $error, "$packagepath/$javaclassname"))
    throw $1_type(Swig::JavaExceptionMessage(jenv, $error).message());
%}

DECLARE_EXCEPTION(ExceptionA)
DECLARE_EXCEPTION(ExceptionB)
DECLARE_EXCEPTION(Unexpected)

%catches(MyNS::ExceptionA, MyNS::ExceptionB, MyNS::Unexpected) MyClass::meth2();

%inline {
  class MyClass {
  public:
    virtual void meth1(int x) throw(MyNS::ExceptionA, MyNS::ExceptionB) = 0;
    virtual void meth2() = 0;   /* throws MyNS::ExceptionA, MyNS::ExceptionB, MyNS::Unexpected */
    virtual void meth3(float x) throw(MyNS::Unexpected) = 0;
    virtual ~MyClass() {}
  };
}

In this case the three different "directorthrows" typemaps will be used to generate the three different exception handlers for meth1, meth2 and meth3. The generated handlers will have "if" blocks for each exception type specified, in the exception specification or %catches feature.

Note that the "directorthrows" typemaps are important only if it is important for the the exceptions passed through the C++ layer to be mapped to distinct C++ exceptions. If director methods are being called by C++ code that is itself wrapped in a SWIG generated Java wrapper and access is always through this wrapper, the default Swig::DirectorException class provides enough information to reconstruct the original exception. In this case removing the $directorthrowshandlers special variable from the default director:except feature and simply always throwing a Swig::DirectorException will achieve the desired result. Along with this a generic exception feature is added to convert any caught Swig::DirectorExceptions back into the underlying Java exceptions via the Swig::DirectorException::raiseJavaException method, as demonstrated with %javaexception below:

%javaexception("Exception") MyClass::myMethod %{
  try {
    $action
  } catch (Swig::DirectorException &e) {
    // raise/throw the Java exception that originally caused the DirectorException
    e.raiseJavaException(jenv);
    return $null;
  }
%}

See the Exception handling with %exception and %javaexception section for more on converting C++ exceptions to Java exceptions.

25.6 Accessing protected members

When using directors, the protected virtual methods are also wrapped. These methods are wrapped with a protected Java proxy method, so the only way that Java code can access these is from within a Java class derived from the director class.

Members which are protected and non-virtual can also be accessed when using the 'allprotected' mode. The allprotected mode requires directors and is turned on by setting the allprotected option in addition to the directors option in the %module directive, like this:

%module(directors="1", allprotected="1") modulename

Protected member variables and methods (both static and non-static) will then be wrapped with protected access in the Java proxy class.

Note: Neither the directors option nor the allprotected mode support types defined with protected scope. This includes any enums or typedefs declared in the protected section of the C++ class.

The following simple example is a class with numerous protected members, including the constructor and destructor:

%module(directors="1", allprotected="1") example

%feature("director") ProtectedBase;

// Ignore use of unsupported types (those defined in the protected section)
%ignore ProtectedBase::typedefs;

%inline %{

class ProtectedBase {
protected:
  ProtectedBase() {}
  virtual ~ProtectedBase() {}
  virtual void virtualMethod() const {}
  void nonStaticMethod(double d) const {}
  static void staticMethod(int i) {}
  int instanceMemberVariable;
  static int staticMemberVariable;

  // unsupported: types defined with protected access and the methods/variables which use them
  typedef int IntegerType;
  IntegerType typedefs(IntegerType it) { return it; }
};
int ProtectedBase::staticMemberVariable = 10;

%}

Note that the IntegerType has protected scope and the members which use this type must be ignored as they cannot be wrapped.

The proxy methods are protected, so the only way the protected members can be accessed is within a class that derives from the director class, such as the following:

class MyProtectedBase extends ProtectedBase
{
  public MyProtectedBase() {
  }

  public void accessProtected() {
    virtualMethod();
    nonStaticMethod(1.2);
    staticMethod(99);

    setInstanceMemberVariable(5);
    int i = getInstanceMemberVariable();

    setStaticMemberVariable(10);
    i = getStaticMemberVariable();
  }
}

25.7 Common customization features

An earlier section presented the absolute basics of C/C++ wrapping. If you do nothing but feed SWIG a header file, you will get an interface that mimics the behavior described. However, sometimes this isn't enough to produce a nice module. Certain types of functionality might be missing or the interface to certain functions might be awkward. This section describes some common SWIG features that are used to improve the interface to existing C/C++ code.

25.7.1 C/C++ helper functions

Sometimes when you create a module, it is missing certain bits of functionality. For example, if you had a function like this

typedef struct Image {...};
void set_transform(Image *im, double m[4][4]);

it would be accessible from Java, but there may be no easy way to call it. The problem here is that a type wrapper class is generated for the two dimensional array parameter so there is no easy way to construct and manipulate a suitable double [4][4] value. To fix this, you can write some extra C helper functions. Just use the %inline directive. For example:

%inline %{
/* Note: double[4][4] is equivalent to a pointer to an array double (*)[4] */
double (*new_mat44())[4] {
   return (double (*)[4]) malloc(16*sizeof(double));
}
void free_mat44(double (*x)[4]) {
   free(x);
}
void mat44_set(double x[4][4], int i, int j, double v) {
   x[i][j] = v;
}
double mat44_get(double x[4][4], int i, int j) {
   return x[i][j];
}
%}

From Java, you could then write code like this:

Image im = new Image();
SWIGTYPE_p_a_4__double a = example.new_mat44();
example.mat44_set(a,0,0,1.0);
example.mat44_set(a,1,1,1.0);
example.mat44_set(a,2,2,1.0);
...
example.set_transform(im,a);
example.free_mat44(a);

Admittedly, this is not the most elegant looking approach. However, it works and it wasn't too hard to implement. It is possible to improve on this using Java code, typemaps, and other customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.

25.7.2 Class extension with %extend

One of the more interesting features of SWIG is that it can extend structures and classes with new methods or constructors. Here is a simple example:

%module example
%{
#include "someheader.h"
%}

struct Vector {
   double x,y,z;
};

%extend Vector {
   char *toString() {
       static char tmp[1024];
       sprintf(tmp,"Vector(%g,%g,%g)", $self->x,$self->y,$self->z);
       return tmp;
   }
   Vector(double x, double y, double z) {
       Vector *v = (Vector *) malloc(sizeof(Vector));
       v->x = x;
       v->y = y;
       v->z = z;
       return v;
   }
};

Now, in Java

Vector v = new Vector(2,3,4);
System.out.println(v);

will display

Vector(2,3,4)

%extend works with both C and C++ code. It does not modify the underlying object in any way---the extensions only show up in the Java interface.

25.7.3 Exception handling with %exception and %javaexception

If a C or C++ function throws an error, you may want to convert that error into a Java exception. To do this, you can use the %exception directive. The %exception directive simply lets you rewrite part of the generated wrapper code to include an error check. It is detailed in full in the Exception handling with %exception section.

In C, a function often indicates an error by returning a status code (a negative number or a NULL pointer perhaps). Here is a simple example of how you might handle that:

%exception malloc {
  $action
  if (!result) {
    jclass clazz = (*jenv)->FindClass(jenv, "java/lang/OutOfMemoryError");
    (*jenv)->ThrowNew(jenv, clazz, "Not enough memory");
    return $null;
  }
}
void *malloc(size_t nbytes);

In Java,

SWIGTYPE_p_void a = example.malloc(2000000000);

will produce a familiar looking Java exception:

Exception in thread "main" java.lang.OutOfMemoryError: Not enough memory
        at exampleJNI.malloc(Native Method)
        at example.malloc(example.java:16)
        at runme.main(runme.java:112)

If a library provides some kind of general error handling framework, you can also use that. For example:

%exception malloc {
  $action
  if (err_occurred()) {
    jclass clazz = (*jenv)->FindClass(jenv, "java/lang/OutOfMemoryError");
    (*jenv)->ThrowNew(jenv, clazz, "Not enough memory");
    return $null;
  }
}
void *malloc(size_t nbytes);

If no declaration name is given to %exception, it is applied to all wrapper functions. The $action is a SWIG special variable and is replaced by the C/C++ function call being wrapped. The return $null; handles all native method return types, namely those that have a void return and those that do not. This is useful for typemaps that will be used in native method returning all return types. See the section on Java special variables for further explanation.

C++ exceptions are also easy to handle. We can catch the C++ exception and rethrow it as a Java exception like this:

%exception getitem {
  try {
     $action
  } catch (std::out_of_range &e) {
    jclass clazz = jenv->FindClass("java/lang/Exception");
    jenv->ThrowNew(clazz, "Range error");
    return $null;
   }
}

class FooClass {
public:
     FooClass *getitem(int index);      // Might throw std::out_of_range exception
     ...
};

In the example above, java.lang.Exception is a checked exception class and so ought to be declared in the throws clause of getitem. Classes can be specified for adding to the throws clause using %javaexception(classes) instead of %exception, where classes is a string containing one or more comma separated Java classes. The %clearjavaexception feature is the equivalent to %clearexception and clears previously declared exception handlers. The %nojavaexception feature is the equivalent to %noexception and disables the exception handler. See Clearing features for the difference on disabling and clearing features.

%javaexception("java.lang.Exception") getitem {
  try {
     $action
  } catch (std::out_of_range &e) {
    jclass clazz = jenv->FindClass("java/lang/Exception");
    jenv->ThrowNew(clazz, "Range error");
    return $null;
   }
}

class FooClass {
public:
     FooClass *getitem(int index);      // Might throw std::out_of_range exception
     ...
};

The generated proxy method now generates a throws clause containing java.lang.Exception:

public class FooClass {
  ...
  public FooClass getitem(int index) throws java.lang.Exception { ... }
  ...
}

The examples above first use the C JNI calling syntax then the C++ JNI calling syntax. The C++ calling syntax will not compile as C and also vice versa. It is however possible to write JNI calls which will compile under both C and C++ and is covered in the Typemaps for both C and C++ compilation section.

The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter. The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities.

25.7.4 Method access with %javamethodmodifiers

A Java feature called %javamethodmodifiers can be used to change the method modifiers from the default public. It applies to both module class methods and proxy class methods. For example:

%javamethodmodifiers protect_me() "protected";
void protect_me();

Will produce the method in the module class with protected access.

protected static void protect_me() {
  exampleJNI.protect_me();
}

25.8 Tips and techniques

Although SWIG is largely automatic, there are certain types of wrapping problems that require additional user input. Examples include dealing with output parameters, strings and arrays. This chapter discusses the common techniques for solving these problems.

25.8.1 Input and output parameters using primitive pointers and references

A common problem in some C programs is handling parameters passed as simple pointers or references. For example:

void add(int x, int y, int *result) {
   *result = x + y;
}

or perhaps

int sub(int *x, int *y) {
   return *x-*y;
}

The typemaps.i library file will help in these situations. For example:

%module example
%include "typemaps.i"

void add(int, int, int *OUTPUT);
int  sub(int *INPUT, int *INPUT);

In Java, this allows you to pass simple values. For example:

int result = example.sub(7,4);
System.out.println("7 - 4 = " + result);
int[] sum = {0};
example.add(3,4,sum);
System.out.println("3 + 4 = " + sum[0]);

Which will display:

7 - 4 = 3
3 + 4 = 7

Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter will return the result in the first element of the integer array.

If you don't want to use the names INPUT or OUTPUT, use the %apply directive. For example:

%module example
%include "typemaps.i"

%apply int *OUTPUT { int *result };
%apply int *INPUT  { int *x, int *y};

void add(int x, int y, int *result);
int  sub(int *x, int *y);

If a function mutates one of its parameters like this,

void negate(int *x) {
   *x = -(*x);
}

you can use INOUT like this:

%include "typemaps.i"
...
void negate(int *INOUT);

In Java, the input parameter is the first element in a 1 element array and is replaced by the output of the function. For example:

int[] neg = {3};
example.negate(neg);
System.out.println("Negative of 3 = " + neg[0]);

And no prizes for guessing the output:

Negative of 3 = -3

These typemaps can also be applied to C++ references. The above examples would work the same if they had been defined using references instead of pointers. For example, the Java code to use the negate function would be the same if it were defined either as it is above:

void negate(int *INOUT);

or using a reference:

void negate(int &INOUT);

Note: Since most Java primitive types are immutable and are passed by value, it is not possible to perform in-place modification of a type passed as a parameter.

Be aware that the primary purpose of the typemaps.i file is to support primitive datatypes. Writing a function like this

void foo(Bar *OUTPUT);

will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

25.8.2 Simple pointers

If you must work with simple pointers such as int * or double * another approach to using typemaps.i is to use the cpointer.i pointer library file. For example:

%module example
%include "cpointer.i"

%inline %{
extern void add(int x, int y, int *result);
%}

%pointer_functions(int, intp);

The %pointer_functions(type,name) macro generates five helper functions that can be used to create, destroy, copy, assign, and dereference a pointer. In this case, the functions are as follows:

int  *new_intp();
int  *copy_intp(int *x);
void  delete_intp(int *x);
void  intp_assign(int *x, int value);
int   intp_value(int *x);

In Java, you would use the functions like this:

SWIGTYPE_p_int intPtr = example.new_intp();
example.add(3,4,intPtr);
int result = example.intp_value(intPtr);
System.out.println("3 + 4 = " + result);

If you replace %pointer_functions(int,intp) by %pointer_class(int,intp), the interface is more class-like.

intp intPtr = new intp();
example.add(3,4,intPtr.cast());
int result = intPtr.value();
System.out.println("3 + 4 = " + result);

See the SWIG Library chapter for further details.

25.8.3 Wrapping C arrays with Java arrays

SWIG can wrap arrays in a more natural Java manner than the default by using the arrays_java.i library file. Let's consider an example:

%include "arrays_java.i";
int array[4];
void populate(int x[]) {
    int i;
    for (i=0; i<4; i++)
        x[i] = 100 + i;
}

These one dimensional arrays can then be used as if they were Java arrays:

int[] array = new int[4];
example.populate(array);

System.out.print("array: ");
for (int i=0; i<array.length; i++)
    System.out.print(array[i] + " ");

example.setArray(array);

int[] global_array = example.getArray();

System.out.print("\nglobal_array: ");
for (int i=0; i<array.length; i++)
    System.out.print(global_array[i] + " ");

Java arrays are always passed by reference, so any changes a function makes to the array will be seen by the calling function. Here is the output after running this code:

array: 100 101 102 103
global_array: 100 101 102 103

Note that for assigning array variables the length of the C variable is used, so it is possible to use a Java array that is bigger than the C code will cope with. Only the number of elements in the C array will be used. However, if the Java array is not large enough then you are likely to get a segmentation fault or access violation, just like you would in C. When arrays are used in functions like populate, the size of the C array passed to the function is determined by the size of the Java array.

Please be aware that the typemaps in this library are not efficient as all the elements are copied from the Java array to a C array whenever the array is passed to and from JNI code. There is an alternative approach using the SWIG array library and this is covered in the next section.

25.8.4 Unbounded C Arrays

Sometimes a C function expects an array to be passed as a pointer. For example,

int sumitems(int *first, int nitems) {
    int i, sum = 0;
    for (i = 0; i < nitems; i++) {
        sum += first[i];
    }
    return sum;
}

One of the ways to wrap this is to apply the Java array typemaps that come in the arrays_java.i library file:

%include "arrays_java.i"
%apply int[] {int *};

The ANY size will ensure the typemap is applied to arrays of all sizes. You could narrow the typemap matching rules by specifying a particular array size. Now you can use a pure Java array and pass it to the C code:

int[] array = new int[10000000];          // Array of 10-million integers
for (int i=0; i<array.length; i++) {      // Set some values
  array[i] = i;
}
int sum = example.sumitems(array,10000);
System.out.println("Sum = " + sum);

and the sum would be displayed:

Sum = 49995000

This approach is probably the most natural way to use arrays. However, it suffers from performance problems when using large arrays as a lot of copying of the elements occurs in transferring the array from the Java world to the C++ world. An alternative approach to using Java arrays for C arrays is to use an alternative SWIG library file carrays.i. This approach can be more efficient for large arrays as the array is accessed one element at a time. For example:

%include "carrays.i"
%array_functions(int, intArray);

The %array_functions(type,name) macro generates four helper functions that can be used to create and destroy arrays and operate on elements. In this case, the functions are as follows:

int *new_intArray(int nelements);
void delete_intArray(int *x);
int intArray_getitem(int *x, int index);
void intArray_setitem(int *x, int index, int value);

In Java, you would use the functions like this:

SWIGTYPE_p_int array = example.new_intArray(10000000);  // Array of 10-million integers
for (int i=0; i<10000; i++) {                           // Set some values
    example.intArray_setitem(array,i,i);
}
int sum = example.sumitems(array,10000);
System.out.println("Sum = " + sum);

If you replace %array_functions(int,intp) by %array_class(int,intp), the interface is more class-like and a couple more helper functions are available for casting between the array and the type wrapper class.

%include "carrays.i"
%array_class(int, intArray);

The %array_class(type, name) macro creates wrappers for an unbounded array object that can be passed around as a simple pointer like int * or double *. For instance, you will be able to do this in Java:

intArray array = new intArray(10000000);  // Array of 10-million integers
for (int i=0; i<10000; i++) {             // Set some values
    array.setitem(i,i);
}
int sum = example.sumitems(array.cast(),10000);
System.out.println("Sum = " + sum);

The array "object" created by %array_class() does not encapsulate pointers inside a special array object. In fact, there is no bounds checking or safety of any kind (just like in C). Because of this, the arrays created by this library are extremely low-level indeed. You can't iterate over them nor can you even query their length. In fact, any valid memory address can be accessed if you want (negative indices, indices beyond the end of the array, etc.). Needless to say, this approach is not going to suit all applications. On the other hand, this low-level approach is extremely efficient and well suited for applications in which you need to create buffers, package binary data, etc.

25.8.5 Binary data vs Strings

By default SWIG handles char * as a string but there is a handy multi-argument typemap available as mentioned in Passing binary data. The following simple example demonstrates using a byte array instead of passing the default string type and length to the wrapped function.

%apply (char *STRING, size_t LENGTH) { (const char data[], size_t len) }
%inline %{
void binaryChar1(const char data[], size_t len) {
  printf("len: %d data: ", len);
  for (size_t i=0; i<len; ++i)
    printf("%x ", data[i]);
  printf("\n");
}
%}

Calling from Java requires just the byte array to be passed in as the multi-argument typemap being applied reduces the number of arguments in the target language to one, from the original two:

byte[] data = "hi\0jk".getBytes();
example.binaryChar1(data);     

resulting in the output

$ java runme
len: 5 data: 68 69 0 6a 6b

25.8.6 Overriding new and delete to allocate from Java heap

Unlike some languages supported by SWIG, Java has a true garbage collection subsystem. Other languages will free SWIG wrapped objects when their reference count reaches zero. Java only schedules these objects for finalization, which may not occur for some time. Because SWIG objects are allocated on the C heap, Java users may find the JVM memory use quickly exceeds the assigned limits, as memory fills with unfinalized proxy objects. Forcing garbage collection is clearly an undesirable solution.

An elegant fix for C++ users is to override new and delete using the following code (here shown included in a SWIG interface file)

/* File: java_heap.i */
%module test
%{
#include <stdexcept>
#include "jni.h"

/**
 *  A stash area embedded in each allocation to hold java handles
 */
struct Jalloc {
  jbyteArray jba;
  jobject ref;
};

static JavaVM *cached_jvm = 0;

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
  cached_jvm = jvm;
  return JNI_VERSION_1_2;
}

static JNIEnv * JNU_GetEnv() {
  JNIEnv *env;
  jint rc = cached_jvm->GetEnv((void **)&env, JNI_VERSION_1_2);
  if (rc == JNI_EDETACHED)
    throw std::runtime_error("current thread not attached");
  if (rc == JNI_EVERSION)
    throw std::runtime_error("jni version not supported");
  return env;
}

void * operator new(size_t t) {
  if (cached_jvm != 0) {
    JNIEnv *env = JNU_GetEnv();
    jbyteArray jba = env->NewByteArray((int) t + sizeof(Jalloc));
    if (env->ExceptionOccurred())
      throw bad_alloc();
    void *jbuffer = static_cast<void *>(env->GetByteArrayElements(jba, 0));
    if (env->ExceptionOccurred())
      throw bad_alloc();
    Jalloc *pJalloc = static_cast<Jalloc *>(jbuffer);
    pJalloc->jba = jba;
    /* Assign a global reference so byte array will persist until delete'ed */
    pJalloc->ref = env->NewGlobalRef(jba);
    if (env->ExceptionOccurred())
      throw bad_alloc();
    return static_cast<void *>(static_cast<char *>(jbuffer) + sizeof(Jalloc));
  }
  else { /* JNI_OnLoad not called, use malloc and mark as special */
    Jalloc *pJalloc = static_cast<Jalloc *>(malloc((int) t + sizeof(Jalloc)));
    if (!pJalloc)
      throw bad_alloc();
    pJalloc->ref = 0;
    return static_cast<void *>(
        static_cast<char *>(static_cast<void *>(pJalloc)) + sizeof(Jalloc));
  }
}

void operator delete(void *v) {
  if (v != 0) {
    void *buffer = static_cast<void *>( static_cast<char *>(v) - sizeof(Jalloc));
    Jalloc *pJalloc = static_cast<Jalloc *>(buffer);
    if (pJalloc->ref) {
      JNIEnv *env = JNU_GetEnv();
      env->DeleteGlobalRef(pJalloc->ref);
      env->ReleaseByteArrayElements(pJalloc->jba, static_cast<jbyte *>(buffer), 0);
    }
    else {
      free(buffer);
    }
  }
}
%}
...

This code caches the Java environment during initialization, and when new is called, a Java ByteArray is allocated to provide the SWIG objects with space in the Java heap. This has the combined effect of re-asserting the Java virtual machine's limit on memory allocation, and puts additional pressure on the garbage collection system to run more frequently. This code is made slightly more complicated because allowances must be made if new is called before the JNI_OnLoad is executed. This can happen during static class initialization, for example.

Unfortunately, because most Java implementations call malloc and free, this solution will not work for C wrapped structures. However, you are free to make functions that allocate and free memory from the Java heap using this model and use these functions in place of malloc and free in your own code.

25.9 Java typemaps

This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. You are advised to be familiar with the material in the "Typemaps" chapter. While not absolutely essential knowledge, this section assumes some familiarity with the Java Native Interface (JNI). JNI documentation can be consulted either online at Sun's Java web site or from a good JNI book. The following two books are recommended:

  • Title: 'Essential JNI: Java Native Interface.' Author: Rob Gordon. Publisher: Prentice Hall. ISBN: 0-13-679895-0.
  • Title: 'The Java Native Interface: Programmer's Guide and Specification.' Author: Sheng Liang. Publisher: Addison-Wesley. ISBN: 0-201-32577-2. Also available online at the Sun Developer Network.

Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the generated code.

25.9.1 Default primitive type mappings

The following table lists the default type mapping from Java to C/C++.

C/C++ type Java type JNI type
bool
const bool &
boolean jboolean
char
const char &
char jchar
signed char
const signed char &
byte jbyte
unsigned char
const unsigned char &
short jshort
short
const short &
short jshort
unsigned short
const unsigned short &
int jint
int
const int &
int jint
unsigned int
const unsigned int &
long jlong
long
const long &
int jint
unsigned long
const unsigned long &
long jlong
long long
const long long &
long jlong
unsigned long long
const unsigned long long &
java.math.BigInteger jobject
float
const float &
float jfloat
double
const double &
double jdouble
char *
char []
String jstring

Note that SWIG wraps the C char type as a character. Pointers and arrays of this type are wrapped as strings. The signed char type can be used if you want to treat char as a signed number rather than a character. Also note that all const references to primitive types are treated as if they are passed by value.

Given the following C function:

void func(unsigned short a, char *b, const long &c, unsigned long long d);

The module class method would be:

public static void func(int a, String b, int c, java.math.BigInteger d) {...}

The intermediary JNI class would use the same types:

public final static native void func(int jarg1, String jarg2, int jarg3,
                                     java.math.BigInteger jarg4);

and the JNI function would look like this:

SWIGEXPORT void JNICALL Java_exampleJNI_func(JNIEnv *jenv, jclass jcls,
                jint jarg1, jstring jarg2, jint jarg3, jobject jarg4) {...}

The mappings for C int and C long are appropriate for 32 bit applications which are used in the 32 bit JVMs. There is no perfect mapping between Java and C as Java doesn't support all the unsigned C data types. However, the mappings allow the full range of values for each C type from Java.

25.9.2 Default typemaps for non-primitive types

The previous section covered the primitive type mappings. Non-primitive types such as classes and structs are mapped using pointers on the C/C++ side and storing the pointer into a Java long variable which is held by the proxy class or type wrapper class. This applies whether the type is marshalled as a pointer, by reference or by value. It also applies for any unknown/incomplete types which use type wrapper classes.

So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit Java long type and therefore the JNI type is a jlong. The Java type is either the proxy class or type wrapper class.

25.9.3 Sixty four bit JVMs

If you are using a 64 bit JVM you may have to override the C long, but probably not C int default mappings. Mappings will be system dependent, for example long will need remapping on Unix LP64 systems (long, pointer 64 bits, int 32 bits), but not on Microsoft 64 bit Windows which will be using a P64 IL32 (pointer 64 bits and int, long 32 bits) model. This may be automated in a future version of SWIG. Note that the Java write once run anywhere philosophy holds true for all pure Java code when moving to a 64 bit JVM. Unfortunately it won't of course hold true for JNI code.

25.9.4 What is a typemap?

A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Java to C, you might define a typemap like this:

%module example

%typemap(in) int {
  $1 = $input;
  printf("Received an integer : %d\n",  $1);
}
%inline %{
extern int fact(int nonnegative);
%}

Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variables prefaced by a $ are used. The $1 variable is a placeholder for a local variable of type int. The $input variable contains the Java data, the JNI jint in this case.

When this example is compiled into a Java module, it can be used as follows:

System.out.println(example.fact(6));

and the output will be:

Received an integer : 6
720

In this example, the typemap is applied to all occurrences of the int datatype. You can refine this by supplying an optional parameter name. For example:

%module example

%typemap(in) int nonnegative {
  $1 = $input;
  printf("Received an integer : %d\n",  $1);
}

%inline %{
extern int fact(int nonnegative);
%}

In this case, the typemap code is only attached to arguments that exactly match int nonnegative.

The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG C++ type-system. When you define a typemap for int, that typemap applies to int and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

%typemap(in) int nonnegative {
  $1 = $input;
  printf("Received an integer : %d\n",  $1);
}
%inline %{
typedef int Integer;
extern int fact(Integer nonnegative);    // Above typemap is applied
%}

However, the matching of typedef only occurs in one direction. If you defined a typemap for Integer, it is not applied to arguments of type int.

Typemaps can also be defined for groups of consecutive arguments. For example:

%typemap(in) (char *str, int len) {
...
};

int count(char c, char *str, int len);

When a multi-argument typemap is defined, the arguments are always handled as a single Java parameter. This allows the function to be used like this (notice how the length parameter is omitted):

int c = example.count('e',"Hello World");

25.9.5 Typemaps for mapping C/C++ types to Java types

The typemaps available to the Java module include the common typemaps listed in the main typemaps section. There are a number of additional typemaps which are necessary for using SWIG with Java. The most important of these implement the mapping of C/C++ types to Java types:


 
Typemap Description
jni JNI C types. These provide the default mapping of types from C/C++ to JNI for use in the JNI (C/C++) code.
jtype Java intermediary types. These provide the default mapping of types from C/C++ to Java for use in the native functions in the intermediary JNI class. The type must be the equivalent Java type for the JNI C type specified in the "jni" typemap.
jstype Java types. These provide the default mapping of types from C/C++ to Java for use in the Java module class, proxy classes and type wrapper classes.
javain Conversion from jstype to jtype. These are Java code typemaps which transform the type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap) to the type used in the Java intermediary JNI class (as specified in the "jtype" typemap). In other words the typemap provides the conversion to the native method call parameter types.
javaout Conversion from jtype to jstype. These are Java code typemaps which transform the type used in the Java intermediary JNI class (as specified in the "jtype" typemap) to the Java type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap). In other words the typemap provides the conversion from the native method call return type.
javadirectorin Conversion from jtype to jstype for director methods. These are Java code typemaps which transform the type used in the Java intermediary JNI class (as specified in the "jtype" typemap) to the Java type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap). This typemap provides the conversion for the parameters in the director methods when calling up from C++ to Java. See Director typemaps.
javadirectorout Conversion from jstype to jtype for director methods. These are Java code typemaps which transform the type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap) to the type used in the Java intermediary JNI class (as specified in the "jtype" typemap). This typemap provides the conversion for the return type in the director methods when returning from the C++ to Java upcall. See Director typemaps.
directorin Conversion from C++ type to jni type for director methods. These are C++ typemaps which convert the parameters used in the C++ director method to the appropriate JNI intermediary type. The conversion is done in JNI code prior to calling the Java function from the JNI code. See Director typemaps.
directorout Conversion from jni type to C++ type for director methods. These are C++ typemaps which convert the JNI return type used in the C++ director method to the appropriate C++ return type. The conversion is done in JNI code after calling the Java function from the JNI code. See Director typemaps.

If you are writing your own typemaps to handle a particular type, you will normally have to write a collection of them. The default typemaps are in "java.swg" and so might be a good place for finding typemaps to base any new ones on.

The "jni", "jtype" and "jstype" typemaps are usually defined together to handle the Java to C/C++ type mapping. An "in" typemap should be accompanied by a "javain" typemap and likewise an "out" typemap by a "javaout" typemap. If an "in" typemap is written, a "freearg" and "argout" typemap may also need to be written as some types have a default "freearg" and/or "argout" typemap which may need overriding. The "freearg" typemap sometimes releases memory allocated by the "in" typemap. The "argout" typemap sometimes sets values in function parameters which are passed by reference in Java.

Note that the "in" typemap marshals the JNI type held in the "jni" typemap to the real C/C++ type and for the opposite direction, the "out" typemap marshals the real C/C++ type to the JNI type held in the "jni" typemap. For non-primitive types the "in" and "out" typemaps are responsible for casting between the C/C++ pointer and the 64 bit jlong type. There is no portable way to cast a pointer into a 64 bit integer type and the approach taken by SWIG is mostly portable, but breaks C/C++ aliasing rules. In summary, these rules state that a pointer to any type must never be dereferenced by a pointer to any other incompatible type. The following code snippet might aid in understand aliasing rules better:

    short a;
    short* pa = 0;
    int i = 0x1234;

    a = (short)i;    /* okay */
    a = *(short*)&i; /* breaks aliasing rules */

An email posting, Aliasing, pointer casts and gcc 3.3 elaborates further on the subject. In SWIG, the "in" and "out" typemaps for pointers are typically

    %typemap(in) struct Foo * %{
      $1 = *(struct Foo **)&$input; /* cast jlong into C ptr */
    %}
    %typemap(out) struct Bar * %{
      *(struct Bar **)&$result = $1; /* cast C ptr into jlong */
    %} 
    struct Bar {...};
    struct Foo {...};
    struct Bar * FooBar(struct Foo *f);

resulting in the following code which breaks the aliasing rules:

SWIGEXPORT jlong JNICALL Java_exampleJNI_FooBar(JNIEnv *jenv, jclass jcls,
                                                jlong jarg1, jobject jarg1_) {
  jlong jresult = 0 ;
  struct Foo *arg1 = (struct Foo *) 0 ;
  struct Bar *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  (void)jarg1_;
  arg1 = *(struct Foo **)&jarg1; 
  result = (struct Bar *)FooBar(arg1);
  *(struct Bar **)&jresult = result; 
  return jresult;
}

If you are using gcc as your C compiler, you might get a "dereferencing type-punned pointer will break strict-aliasing rules" warning about this. Please see Compiling a dynamic module to avoid runtime problems with these strict aliasing rules.

The default code generated by SWIG for the Java module comes from the typemaps in the "java.swg" library file which implements the Default primitive type mappings and Default typemaps for non-primitive types covered earlier. There are other type mapping typemaps in the Java library. These are listed below:


 
C Type Typemap File Kind Java Type Function
primitive pointers and references INPUT typemaps.i input Java basic types Allows values to be used for C functions taking pointers for data input.
primitive pointers and references OUTPUT typemaps.i output Java basic type arrays Allows values held within an array to be used for C functions taking pointers for data output.
primitive pointers and references INOUT typemaps.i input
output
Java basic type arrays Allows values held within an array to be used for C functions taking pointers for data input and output.
string
wstring
[unnamed] std_string.i input
output
String Use for std::string mapping to Java String.
arrays of primitive types [unnamed] arrays_java.i input
output
arrays of primitive Java types Use for mapping C arrays to Java arrays.
arrays of classes/structs/unions JAVA_ARRAYSOFCLASSES macro arrays_java.i input
output
arrays of proxy classes Use for mapping C arrays to Java arrays.
arrays of enums ARRAYSOFENUMS arrays_java.i input
output
int[] Use for mapping C arrays to Java arrays (typeunsafe and simple enum wrapping approaches only).
char * BYTE various.i input byte[] Java byte array is converted to char array
char ** STRING_ARRAY various.i input
output
String[] Use for mapping NULL terminated arrays of C strings to Java String arrays

25.9.6 Java typemap attributes

There are a few additional typemap attributes that the Java module supports.

The first of these is the 'throws' attribute. The throws attribute is optional and specified after the typemap name and contains one or more comma separated classes for adding to the throws clause for any methods that use that typemap. It is analogous to the %javaexception feature's throws attribute.

%typemap(typemapname, throws="ExceptionClass1, ExceptionClass2") type { ... }

The attribute is necessary for supporting Java checked exceptions and can be added to just about any typemap. The list of typemaps include all the C/C++ (JNI) typemaps in the "Typemaps" chapter and the Java specific typemaps listed in the previous section, barring the "jni", "jtype" and "jstype" typemaps as they could never contain code to throw an exception.

The throws clause is generated for the proxy method as well as the JNI method in the JNI intermediary class. If a method uses more than one typemap and each of those typemaps have classes specified in the throws clause, the union of the exception classes is added to the throws clause ensuring there are no duplicate classes. See the NaN exception example for further usage.

The "jtype" typemap has the optional 'nopgcpp' attribute which can be used to suppress the generation of the premature garbage collection prevention parameter.

The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. These are used for generating code before and after the JNI call in the proxy class or module class. The 'pre' attribute contains code that is generated before the JNI call and the 'post' attribute contains code generated after the JNI call. The 'pgcppname' attribute is used to change the premature garbage collection prevention parameter name passed to the JNI function. This is sometimes needed when the 'pre' typemap creates a temporary variable which is then passed to the JNI function.

Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.

25.9.7 Java special variables

The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input,$result etc.

The Java module uses a few additional special variables:

$javaclassname
This special variable works like the other special variables and $javaclassname is similar to $1_type. It expands to the class name for use in Java given a pointer. SWIG wraps unions, structs and classes using pointers and in this case it expands to the Java proxy class name. For example, $javaclassname is replaced by the proxy classname Foo when wrapping a Foo * and $&javaclassname expands to the proxy classname when wrapping the C/C++ type Foo and $*javaclassname expands to the proxy classname when wrapping Foo *&. If the type does not have an associated proxy class, it expands to the type wrapper class name, for example, SWIGTYPE_p_unsigned_short is generated when wrapping unsigned short *.

$javaclazzname
This special variable works like $javaclassname, but expands the fully qualified C++ class into the package name, if used by the nspace feature, and the proxy class name, mangled for use as a function name. For example, Namespace1::Namespace2::Klass is expanded into Namespace1_Namespace2_Klass_. This special variable is usually used for making calls to a function in the intermediary JNI class, as they are mangled with this prefix.

$null
Used in input typemaps to return early from JNI functions that have either void or a non-void return type. Example:

%typemap(check) int * %{ 
  if (error) {
    SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array element error");
    return $null;
  }
%}

If the typemap gets put into a function with void as return, $null will expand to nothing:

SWIGEXPORT void JNICALL Java_jnifn(...) {
    if (error) {
      SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array element error");
      return ;
    }
  ...
}

otherwise $null expands to NULL

SWIGEXPORT jobject JNICALL Java_jnifn(...) {
    if (error) {
      SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array element error");
      return NULL;
    }
  ...
}

$javainput, $jnicall and $owner
The $javainput special variable is used in "javain" typemaps and $jnicall and $owner are used in "javaout" typemaps. $jnicall is analogous to $action in %exception. It is replaced by the call to the native method in the intermediary JNI class. $owner is replaced by either true if %newobject has been used, otherwise false. $javainput is analogous to the $input special variable. It is replaced by the parameter name.

Here is an example:

%typemap(javain) Class "Class.getCPtr($javainput)"
%typemap(javain) unsigned short "$javainput"
%typemap(javaout) Class * {
    return new Class($jnicall, $owner);
  }

%inline %{
    class Class {...};
    Class * bar(Class cls, unsigned short ush) { return new Class(); };
%}

The generated proxy code is then:

public static Class bar(Class cls, int ush) {
  return new Class(exampleJNI.bar(Class.getCPtr(cls), cls, ush), false);
}

Here $javainput has been replaced by cls and ush. $jnicall has been replaced by the native method call, exampleJNI.bar(...) and $owner has been replaced by false. If %newobject is used by adding the following at the beginning of our example:

%newobject bar(Class cls, unsigned short ush);

The generated code constructs the return type using true indicating the proxy class Class is responsible for destroying the C++ memory allocated for it in bar:

public static Class bar(Class cls, int ush) {
  return new Class(exampleJNI.bar(Class.getCPtr(cls), cls, ush), true);
}

$static
This special variable expands to either static or nothing depending on whether the class is an inner Java class or not. It is used in the "javaclassmodifiers" typemap so that global classes can be wrapped as Java proxy classes and nested C++ classes/enums can be wrapped with the Java equivalent, that is, static inner proxy classes.

$error, $jniinput, $javacall and $packagepath
These special variables are used in the directors typemaps. See Director specific typemaps for details.

$module
This special variable expands to the module name, as specified by %module or the -module commandline option.

$imclassname
This special variable expands to the intermediary class name. Usually this is the same as '$moduleJNI', unless the jniclassname attribute is specified in the %module directive.

25.9.8 Typemaps for both C and C++ compilation

JNI calls must be written differently depending on whether the code is being compiled as C or C++. For example C compilation requires the pointer to a function pointer struct member syntax like

const jclass clazz = (*jenv)->FindClass(jenv, "java/lang/String");

whereas C++ code compilation of the same function call is a member function call using a class pointer like

const jclass clazz = jenv->FindClass("java/lang/String");

To enable typemaps to be used for either C or C++ compilation, a set of JCALLx macros have been defined in Lib/java/javahead.swg, where x is the number of arguments in the C++ version of the JNI call. The above JNI calls would be written in a typemap like this

const jclass clazz = JCALL1(FindClass, jenv, "java/lang/String");

Note that the SWIG preprocessor expands these into the appropriate C or C++ JNI calling convention. The C calling convention is emitted by default and the C++ calling convention is emitted when using the -c++ SWIG commandline option. If you do not intend your code to be targeting both C and C++ then your typemaps can use the appropriate JNI calling convention and need not use the JCALLx macros.

25.9.9 Java code typemaps

Most of SWIG's typemaps are used for the generation of C/C++ code. The typemaps in this section are used solely for the generation of Java code. Elements of proxy classes and type wrapper classes come from the following typemaps (the defaults).

%typemap(javabase)

base (extends) for Java class: empty default
Note that this typemap accepts a replace attribute as an optional flag. When set to "1", it will replace/override any C++ base classes that might have been parsed. If this flag is not specified and there are C++ base classes, then a multiple inheritance warning is issued and the code in the typemap is ignored. The typemap also accepts a notderived attribute as an optional flag. When set to "1", it will not apply to classes that are derived from a C++ base. When used with the SWIGTYPE type, it is useful for giving a common base for all proxy classes, that is, providing a base class that sits in between all proxy classes and the Java base class Object for example: %typemap(javabase, notderived="1") SWIGTYPE "CommonBase".

%typemap(javabody)

the essential support body for proxy classes (proxy base classes only), typewrapper classes and enum classes. Default contains extra constructors, memory ownership control member variables (swigCMemOwn, swigCPtr), the getCPtr method etc.

%typemap(javabody_derived)

the essential support body for proxy classes (derived classes only). Same as "javabody" typemap, but only used for proxy derived classes.

%typemap(javaclassmodifiers)

class modifiers for the Java class: default is "public class"

%typemap(javacode)

Java code is copied verbatim to the Java class: empty default

%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized")

destructor wrapper - the delete() method (proxy classes only), used for all proxy classes except those which have a base class : default calls C++ destructor (or frees C memory) and resets swigCPtr and swigCMemOwn flags

Note that the delete() method name is configurable and is specified by the methodname attribute. The method modifiers are also configurable via the methodmodifiers attribute.

%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized")

destructor wrapper - the delete() method (proxy classes only), same as "javadestruct" but only used for derived proxy classes : default calls C++ destructor (or frees C memory) and resets swigCPtr and swigCMemOwn flags

Note that the delete() method name is configurable and is specified by the methodname attribute. The method modifiers are also configurable via the methodmodifiers attribute.

%typemap(javaimports)

import statements for Java class: empty default

%typemap(javainterfaces)

interfaces (implements) for Java class: empty default

%typemap(javafinalize)

the finalize() method (proxy classes only): default calls the delete() method

Note that the default javafinalize typemap must contain the full implementation of the finalize method. Any customization to this typemap must still declare a java finalize method with the correct signature. Note also that the name of the generated "delete" method may be affected by javadestruct and javadestruct_derived typemaps. Below shows an example modifying the finalizer, assuming the delete method has been renamed to swig_delete.

%typemap(javafinalize) SWIGTYPE %{
   protected void finalize() {
     swig_delete();  // renamed to prevent conflict with existing delete method
   }
]%

Compatibility Note: In SWIG-1.3.21 and earlier releases, typemaps called "javagetcptr" and "javaptrconstructormodifiers" were available. These are deprecated and the "javabody" typemap can be used instead.

In summary the contents of the typemaps make up a proxy class like this:

[ javaimports typemap ]
[ javaclassmodifiers typemap ] javaclassname extends [ javabase typemap ]
                                             implements [ javainterfaces typemap ] {
[ javabody or javabody_derived typemap ]
[ javafinalize typemap ]
public synchronized void delete() [ javadestruct OR javadestruct_derived typemap ]
[ javacode typemap ]
... proxy functions ...
}

Note the delete() methodname and method modifiers are configurable, see "javadestruct" and "javadestruct_derived" typemaps above.

The type wrapper class is similar in construction:

[ javaimports typemap ]
[ javaclassmodifiers typemap ] javaclassname extends [ javabase typemap ]
                                             implements [ javainterfaces typemap ] {
[ javabody typemap ]
[ javacode typemap ]
}

The enum class is also similar in construction:

[ javaimports typemap ]
[ javaclassmodifiers typemap ] javaclassname extends [ javabase typemap ]
                                             implements [ javainterfaces typemap ] {
... Enum values ...
[ javabody typemap ]
[ javacode typemap ]
}

The "javaimports" typemap is ignored if the enum class is wrapped by an inner Java class, that is when wrapping an enum declared within a C++ class.

The defaults can be overridden to tailor these classes. Here is an example which will change the getCPtr method and constructor from the default public access to protected access. If the classes in one package are not using the classes in another package, then these methods need not be public and removing access to these low level implementation details, is a good thing. If you are invoking SWIG more than once and generating the wrapped classes into different packages in each invocation, then you cannot do this as you will then have different packages.

%typemap(javabody) SWIGTYPE %{
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr($javaclassname obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }
%}

The typemap code is the same that is in "java.swg", barring the last two method modifiers. Note that SWIGTYPE will target all proxy classes, but not the type wrapper classes. Also the above typemap is only used for proxy classes that are potential base classes. To target proxy classes that are derived from a wrapped class as well, the "javabody_derived" typemap should also be overridden.

For the typemap to be used in all type wrapper classes, all the different types that type wrapper classes could be used for should be targeted:

%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  private long swigCPtr;

  protected $javaclassname(long cPtr, boolean bFutureUse) {
    swigCPtr = cPtr;
  }

  protected $javaclassname() {
    swigCPtr = 0;
  }

  protected static long getCPtr($javaclassname obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }
%}

Again this is the same that is in "java.swg", barring the method modifier for getCPtr.

When using multiple modules or the nspace feature it is common to invoke SWIG with a different -package command line option for each module. However, by default the generated code may not compile if generated classes in one package use generated classes in another package. The visibility of the getCPtr() and pointer constructor generated from the javabody typemaps needs changing. The default visibility is protected but it needs to be public for access from a different package. Just changing 'protected' to 'public' in the typemap achieves this. Two macros are available in java.swg to make this easier and using them is the preferred approach over simply copying the typemaps and modifying as this is forward compatible with any changes in the javabody typemap in future versions of SWIG. The macros are for the proxy and typewrapper classes and can respectively be used to to make the method and constructor public:

  SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
  SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)

25.9.10 Director specific typemaps

The Java directors feature requires the "javadirectorin", "javadirectorout", "directorin" and the "directorout" typemaps in order to work properly. The "javapackage" typemap is an optional typemap used to identify the Java package path for individual SWIG generated proxy classes used in director methods.

%typemap(directorin)

The "directorin" typemap is used for converting arguments in the C++ director class to the appropriate JNI type before the upcall to Java. This typemap also specifies the JNI field descriptor for the type in the "descriptor" attribute. For example, integers are converted as follows:

%typemap(directorin,descriptor="I") int "$input = (jint) $1;"

$input is the SWIG name of the JNI temporary variable passed to Java in the upcall. The descriptor="I" will put an I into the JNI field descriptor that identifies the Java method that will be called from C++. For more about JNI field descriptors and their importance, refer to the JNI documentation mentioned earlier. A typemap for C character strings is:

%typemap(directorin,descriptor="Ljava/lang/String;") char *
  %{ $input = jenv->NewStringUTF($1); %}

User-defined types have the default "descriptor" attribute "L$packagepath/$javaclassname;" where $packagepath is the package name passed from the SWIG command line and $javaclassname is the Java proxy class' name. If the -package commandline option is not used to specify the package, then '$packagepath/' will be removed from the resulting output JNI field descriptor. Do not forget the terminating ';' for JNI field descriptors starting with 'L'. If the ';' is left out, Java will generate a "method not found" runtime error. Note that the $packagepath substitution always uses the path separator '/' when expanded. The $javaclassname expansion can be confusing as it is normally expanded using the '.' separator. However, $javaclassname is expanded using the path separator '/' in typemap's "descriptor" attribute as well as in the "directorthrows" typemap.

%typemap(directorout)

The "directorout" typemap is used for converting the JNI return type in the C++ director class to the appropriate C++ type after the upcall to Java. For example, integers are converted as follows:

%typemap(directorout) int %{ $result = (int)$input; %}

$input is the SWIG name of the JNI temporary variable returned from Java after the upcall. $result is the resulting output. A typemap for C character strings is:

%typemap(directorout) char * {
  $1 = 0;
  if ($input) {
    $result = (char *)jenv->GetStringUTFChars($input, 0);
    if (!$1) return $null;
  }
}

%typemap(javadirectorin)

Conversion from jtype to jstype for director methods. These are Java code typemaps which transform the type used in the Java intermediary JNI class (as specified in the "jtype" typemap) to the Java type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap). This typemap provides the conversion for the parameters in the director methods when calling up from C++ to Java.

For primitive types, this typemap is usually specified as:

%typemap(javadirectorin) int "$jniinput"

The $jniinput special variable is analogous to $javainput special variable. It is replaced by the input parameter name.

%typemap(javadirectorout)

Conversion from jstype to jtype for director methods. These are Java code typemaps which transform the type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap) to the type used in the Java intermediary JNI class (as specified in the "jtype" typemap). This typemap provides the conversion for the return type in the director methods when returning from the C++ to Java upcall.

For primitive types, this typemap is usually specified as:

%typemap(javadirectorout) int "$javacall"

The $javacall special variable is analogous to the $jnicall special variable. It is replaced by the call to the target Java method. The target method is the method in the Java proxy class which overrides the virtual C++ method in the C++ base class.

%typemap(directorthrows)

Conversion of Java exceptions to C++ exceptions in director method's exception handling. This typemap is expected to test the $error special variable for a matching Java exception and if successful convert and throw it into a C++ exception given by the typemap's type. The $error special variable is of type jthrowable and is substituted with a unique variable name in the generated code.

The example below converts a Java java.lang.IndexOutOfBoundsException exception to the typemap's type, that is std::out_of_range:

%typemap(directorthrows) std::out_of_range %{
  if (Swig::ExceptionMatches(jenv, $error, "java/lang/IndexOutOfBoundsException")) {
    throw std::out_of_range(Swig::JavaExceptionMessage(jenv, $error).message());
  }
%}

The utility function Swig::ExceptionMatches and class Swig::JavaExceptionMessage are helpers available when using directors and are described in the Java Exceptions from Directors section.

%typemap(javapackage)

The "javapackage" typemap is optional; it serves to identify a class's Java package. This typemap should be used in conjunction with classes that are defined outside of the current SWIG interface file. The typemap is only used if the type is used in a director method, that is, in a virtual method in a director class. For example:

// class Foo is handled in a different interface file:
%import "Foo.i"

%feature("director") Example;

%inline {
  class Bar { };

  class Example {
  public:
    virtual ~Example();
    virtual void ping(Foo *arg1, Bar *arg2);
  };
}

Assume that the Foo class is part of the Java package com.wombat.foo but the above interface file is part of the Java package com.wombat.example. Without the "javapackage" typemap, SWIG will assume that the Foo class belongs to com.wombat.example class. The corrected interface file looks like:

// class Foo is handled in a different interface file:
%import "Foo.i"
%typemap("javapackage") Foo, Foo *, Foo & "com.wombat.foo";
%feature("director") Example;

%inline {
  class Bar { };

  class Example {
  public:
    virtual ~Example();
    virtual void ping(Foo *arg1, Bar *arg2);
  };
}

SWIG looks up the package based on the actual type (plain Foo, Foo pointer and Foo reference), so it is important to associate all three types with the desired package. Practically speaking, you should create a separate SWIG interface file, which is %import-ed into each SWIG interface file, when you have multiple Java packages. Note the helper macros below, OTHER_PACKAGE_SPEC and ANOTHER_PACKAGE_SPEC, which reduce the amount of extra typing. "TYPE..." is useful when passing templated types to the macro, since multiargument template types appear to the SWIG preprocessor as multiple macro arguments.

%typemap("javapackage") SWIGTYPE, SWIGTYPE *, SWIGTYPE &
                                            "package.for.most.classes";

%define OTHER_PACKAGE_SPEC(TYPE...)
%typemap("javapackage") TYPE, TYPE *, TYPE & "package.for.other.classes";
%enddef

%define ANOTHER_PACKAGE_SPEC(TYPE...)
%typemap("javapackage") TYPE, TYPE *, TYPE & "package.for.another.set";
%enddef

OTHER_PACKAGE_SPEC(Package_2_class_one)
ANOTHER_PACKAGE_SPEC(Package_3_class_two)
/* etc */

The basic strategy here is to provide a default package typemap for the majority of the classes, only providing "javapackage" typemaps for the exceptions.

25.10 Typemap Examples

This section includes a few examples of typemaps. For more examples, you might look at the files "java.swg" and "typemaps.i" in the SWIG library.

25.10.1 Simpler Java enums for enums without initializers

The default Proper Java enums approach to wrapping enums is somewhat verbose. This is to handle all possible C/C++ enums, in particular enums with initializers. The generated code can be simplified if the enum being wrapped does not have any initializers.

The following shows how to remove the support methods that are generated by default and instead use the methods in the Java enum base class java.lang.Enum and java.lang.Class for marshalling enums between C/C++ and Java. The type used for the typemaps below is enum SWIGTYPE which is the default type used for all enums. The "enums.swg" file should be examined in order to see the original overridden versions of the typemaps.

%include "enums.swg"

%typemap(javain) enum SWIGTYPE "$javainput.ordinal()"
%typemap(javaout) enum SWIGTYPE {
    return $javaclassname.class.getEnumConstants()[$jnicall];
  }
%typemap(javabody) enum SWIGTYPE ""

%inline %{
  enum HairType { blonde, ginger, brunette };
  void setHair(HairType h);
  HairType getHair();
%}

SWIG will generate the following Java enum, which is somewhat simpler than the default:

public enum HairType {
  blonde,
  ginger,
  brunette;
}

and the two Java proxy methods will be:

public static void setHair(HairType h) {
  exampleJNI.setHair(h.ordinal());
}

public static HairType getHair() {
  return HairType.class.getEnumConstants()[exampleJNI.getHair()];
}

For marshalling Java enums to C/C++ enums, the ordinal method is used to convert the Java enum into an integer value for passing to the JNI layer, see the "javain" typemap. For marshalling C/C++ enums to Java enums, the C/C++ enum value is cast to an integer in the C/C++ typemaps (not shown). This integer value is then used to index into the array of enum constants that the Java language provides. See the getEnumConstants method in the "javaout" typemap.

These typemaps can often be used as the default for wrapping enums as in many cases there won't be any enum initializers. In fact a good strategy is to always use these typemaps and to specifically handle enums with initializers using %apply. This would be done by using the original versions of these typemaps in "enums.swg" under another typemap name for applying using %apply.

25.10.2 Handling C++ exception specifications as Java exceptions

This example demonstrates various ways in which C++ exceptions can be tailored and converted into Java exceptions. Let's consider a simple file class SimpleFile and an exception class FileException which it may throw on error:

%include "std_string.i" // for std::string typemaps
#include <string>

class FileException {
  std::string message;
public:
  FileException(const std::string& msg) : message(msg) {}
  std::string what() {
    return message;
  }
};

class SimpleFile {
  std::string filename;
public:
  SimpleFile(const std::string& filename) : filename(filename) {}
  void open() throw(FileException) {
  ...
  }
};

As the open method has a C++ exception specification, SWIG will parse this and know that the method can throw an exception. The "throws" typemap is then used when SWIG encounters an exception specification. The default generic "throws" typemap looks like this:

%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] %{
  SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException,
                          "C++ $1_type exception thrown");
  return $null;
%}

Basically SWIG will generate a C++ try catch block and the body of the "throws" typemap constitutes the catch block. The above typemap calls a SWIG supplied method which throws a java.lang.RuntimeException. This exception class is a runtime exception and therefore not a checked exception. If, however, we wanted to throw a checked exception, say java.io.IOException, then we could use the following typemap:

%typemap(throws, throws="java.io.IOException") FileException {
  jclass excep = jenv->FindClass("java/io/IOException");
  if (excep)
    jenv->ThrowNew(excep, $1.what().c_str());
  return $null;
}

Note that this typemap uses the 'throws' typemap attribute to ensure a throws clause is generated. The generated proxy method then specifies the checked exception by containing java.io.IOException in the throws clause:

public class SimpleFile {
  ...
  public void open() throws java.io.IOException { ... }
}

Lastly, if you don't want to map your C++ exception into one of the standard Java exceptions, the C++ class can be wrapped and turned into a custom Java exception class. If we go back to our example, the first thing we must do is get SWIG to wrap FileException and ensure that it derives from java.lang.Exception. Additionally, we might want to override the java.lang.Exception.getMessage() method. The typemaps to use then are as follows:

%typemap(javabase) FileException "java.lang.Exception";
%typemap(javacode) FileException %{
  public String getMessage() {
    return what();
  }
%}

This generates:

public class FileException extends java.lang.Exception {
  ...
  public String getMessage() {
    return what();
  }

  public FileException(String msg) { ... }

  public String what() {
    return exampleJNI.FileException_what(swigCPtr, this);
  }
}

We could alternatively have used %rename to rename what() into getMessage().

25.10.3 NaN Exception - exception handling for a particular type

A Java exception can be thrown from any Java or JNI code. Therefore, as most typemaps contain either Java or JNI code, just about any typemap could throw an exception. The following example demonstrates exception handling on a type by type basis by checking for 'Not a number' (NaN) whenever a parameter of type float is wrapped.

Consider the following C++ code:

bool calculate(float first, float second);

To validate every float being passed to C++, we could precede the code being wrapped by the following typemap which throws a runtime exception whenever the float is 'Not a Number':

%module example
%typemap(javain) float "$module.CheckForNaN($javainput)"
%pragma(java) modulecode=%{
  /** Simply returns the input value unless it is not a number,
      whereupon an exception is thrown. */
  static protected float CheckForNaN(float num) {
    if (Float.isNaN(num))
      throw new RuntimeException("Not a number");
    return num;
  }
%}

Note that the CheckForNaN support method has been added to the module class using the modulecode pragma. The following shows the generated code of interest:

public class example {
  ...

  /** Simply returns the input value unless it is not a number,
      whereupon an exception is thrown. */
  static protected float CheckForNaN(float num) {
    if (Float.isNaN(num))
      throw new RuntimeException("Not a number");
    return num;
  }

  public static boolean calculate(float first, float second) {
    return exampleJNI.calculate(example.CheckForNaN(first), example.CheckForNaN(second));
  }
}

Note that the "javain" typemap is used for every occurrence of a float being used as an input. Of course, we could have targeted the typemap at a particular parameter by using float first, say, instead of just float.

The exception checking could alternatively have been placed into the 'pre' attribute that the "javain" typemap supports. The "javain" typemap above could be replaced with the following:

%typemap(javain, pre="    $module.CheckForNaN($javainput);") float "$javainput"

which would modify the calculate function to instead be generated as:

public class example {
  ...
  public static boolean calculate(float first, float second) {
    example.CheckForNaN(first);
    example.CheckForNaN(second);
    {
      return exampleJNI.calculate(first, second);
    }
  }
}

See the Date marshalling example for an example using further "javain" typemap attributes.

If we decide that what we actually want is a checked exception instead of a runtime exception, we can change this easily enough. The proxy method that uses float as an input, must then add the exception class to the throws clause. SWIG can handle this as it supports the 'throws' typemap attribute for specifying classes for the throws clause. Thus we can modify the pragma and the typemap for the throws clause:

%typemap(javain, throws="java.lang.Exception") float "$module.CheckForNaN($javainput)"
%pragma(java) modulecode=%{
  /** Simply returns the input value unless it is not a number,
      whereupon an exception is thrown. */
  static protected float CheckForNaN(float num) throws java.lang.Exception {
    if (Float.isNaN(num))
      throw new RuntimeException("Not a number");
    return num;
  }
%}

The calculate method now has a throws clause and even though the typemap is used twice for both float first and float second, the throws clause contains a single instance of java.lang.Exception:

public class example {
  ...

  /** Simply returns the input value unless it is not a number,
      whereupon an exception is thrown. */
  static protected float CheckForNaN(float num) throws java.lang.Exception {
    if (Float.isNaN(num))
      throw new RuntimeException("Not a number");
    return num;
  }

  public static boolean calculate(float first, float second) throws java.lang.Exception {
    return exampleJNI.calculate(example.CheckForNaN(first), example.CheckForNaN(second));
  }
}

If we were a martyr to the JNI cause, we could replace the succinct code within the "javain" typemap with a few pages of JNI code. If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.

25.10.4 Converting Java String arrays to char **

A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Java String array to be used as a char ** object.

%module example

/* This tells SWIG to treat char ** as a special case when used as a parameter
   in a function call */
%typemap(in) char ** (jint size) {
    int i = 0;
    size = (*jenv)->GetArrayLength(jenv, $input);
    $1 = (char **) malloc((size+1)*sizeof(char *));
    /* make a copy of each string */
    for (i = 0; i<size; i++) {
        jstring j_string = (jstring)(*jenv)->GetObjectArrayElement(jenv, $input, i);
        const char * c_string = (*jenv)->GetStringUTFChars(jenv, j_string, 0);
        $1[i] = malloc((strlen(c_string)+1)*sizeof(char));
        strcpy($1[i], c_string);
        (*jenv)->ReleaseStringUTFChars(jenv, j_string, c_string);
        (*jenv)->DeleteLocalRef(jenv, j_string);
    }
    $1[i] = 0;
}

/* This cleans up the memory we malloc'd before the function call */
%typemap(freearg) char ** {
    int i;
    for (i=0; i<size$argnum-1; i++)
      free($1[i]);
    free($1);
}

/* This allows a C function to return a char ** as a Java String array */
%typemap(out) char ** {
    int i;
    int len=0;
    jstring temp_string;
    const jclass clazz = (*jenv)->FindClass(jenv, "java/lang/String");

    while ($1[len]) len++;    
    jresult = (*jenv)->NewObjectArray(jenv, len, clazz, NULL);
    /* exception checking omitted */

    for (i=0; i<len; i++) {
      temp_string = (*jenv)->NewStringUTF(jenv, *result++);
      (*jenv)->SetObjectArrayElement(jenv, jresult, i, temp_string);
      (*jenv)->DeleteLocalRef(jenv, temp_string);
    }
}

/* These 3 typemaps tell SWIG what JNI and Java types to use */
%typemap(jni) char ** "jobjectArray"
%typemap(jtype) char ** "String[]"
%typemap(jstype) char ** "String[]"

/* These 2 typemaps handle the conversion of the jtype to jstype typemap type
   and vice versa */
%typemap(javain) char ** "$javainput"
%typemap(javaout) char ** {
    return $jnicall;
  }

/* Now a few test functions */
%inline %{

int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
         printf("argv[%d] = %s\n", i, argv[i]);
         i++;
    }
    return i;
}

char **get_args() {
  static char *values[] = { "Dave", "Mike", "Susan", "John", "Michelle", 0};
  return &values[0];
}

%}

Note that the 'C' JNI calling convention is used. Checking for any thrown exceptions after JNI function calls has been omitted. When this module is compiled, our wrapped C functions can be used by the following Java program:

// File runme.java

public class runme {

  static {
    try {
      System.loadLibrary("example");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load. " + e);
      System.exit(1);
    }
  }

  public static void main(String argv[]) {
    String animals[] = {"Cat","Dog","Cow","Goat"};
    example.print_args(animals);
    String args[] = example.get_args();
    for (int i=0; i<args.length; i++)
        System.out.println(i + ":" + args[i]);
  }
}

When compiled and run we get:

$ java runme
argv[0] = Cat
argv[1] = Dog
argv[2] = Cow
argv[3] = Goat
0:Dave
1:Mike
2:Susan
3:John
4:Michelle

In the example, a few different typemaps are used. The "in" typemap is used to receive an input argument and convert it to a C array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function. The "out" typemap is used for function return values. Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

25.10.5 Expanding a Java object to multiple arguments

Suppose that you had a collection of C functions with arguments such as the following:

int foo(int argc, char **argv);

In the previous example, a typemap was written to pass a Java String array as the char **argv. This allows the function to be used from Java as follows:

example.foo(4, new String[]{"red", "green", "blue", "white"});

Although this works, it's a little awkward to specify the argument count. To fix this, a multi-argument typemap can be defined. This is not very difficult--you only have to make slight modifications to the previous example's typemaps:

%typemap(in) (int argc, char **argv) {
    int i = 0;
    $1 = (*jenv)->GetArrayLength(jenv, $input);
    $2 = (char **) malloc(($1+1)*sizeof(char *));
    /* make a copy of each string */
    for (i = 0; i<$1; i++) {
        jstring j_string = (jstring)(*jenv)->GetObjectArrayElement(jenv, $input, i);
        const char * c_string = (*jenv)->GetStringUTFChars(jenv, j_string, 0);
        $2[i] = malloc((strlen(c_string)+1)*sizeof(char));
        strcpy($2[i], c_string);
        (*jenv)->ReleaseStringUTFChars(jenv, j_string, c_string);
        (*jenv)->DeleteLocalRef(jenv, j_string);
    }
    $2[i] = 0;
}

%typemap(freearg) (int argc, char **argv) {
    int i;
    for (i=0; i<$1-1; i++)
      free($2[i]);
    free($2);
}

%typemap(jni) (int argc, char **argv) "jobjectArray"
%typemap(jtype) (int argc, char **argv) "String[]"
%typemap(jstype) (int argc, char **argv) "String[]"

%typemap(javain) (int argc, char **argv) "$javainput"

When writing a multiple-argument typemap, each of the types is referenced by a variable such as $1 or $2. The typemap code simply fills in the appropriate values from the supplied Java parameter.

With the above typemap in place, you will find it no longer necessary to supply the argument count. This is automatically set by the typemap code. For example:

example.foo(new String[]{"red", "green", "blue", "white"});

25.10.6 Using typemaps to return arguments

A common problem in some C programs is that values may be returned in function parameters rather than in the return value of a function. The typemaps.i file defines INPUT, OUTPUT and INOUT typemaps which can be used to solve some instances of this problem. This library file uses an array as a means of moving data to and from Java when wrapping a C function that takes non const pointers or non const references as parameters.

Now we are going to outline an alternative approach to using arrays for C pointers. The INOUT typemap uses a double[] array for receiving and returning the double* parameters. In this approach we are able to use a Java class myDouble instead of double[] arrays where the C pointer double* is required.

Here is our example function:

/* Returns a status value and two values in out1 and out2 */
int spam(double a, double b, double *out1, double *out2);

If we define a structure MyDouble containing a double member variable and use some typemaps we can solve this problem. For example we could put the following through SWIG:

%module example

/* Define a new structure to use instead of double * */
%inline %{
typedef struct {
    double value;
} MyDouble;
%}


%{
/* Returns a status value and two values in out1 and out2 */
int spam(double a, double b, double *out1, double *out2) {
  int status = 1;
  *out1 = a*10.0;
  *out2 = b*100.0;
  return status;
}
%}

/* 
This typemap will make any double * function parameters with name OUTVALUE take an
argument of MyDouble instead of double *. This will 
allow the calling function to read the double * value after returning from the function.
*/
%typemap(in) double *OUTVALUE {
    jclass clazz = jenv->FindClass("MyDouble");
    jfieldID fid = jenv->GetFieldID(clazz, "swigCPtr", "J");
    jlong cPtr = jenv->GetLongField($input, fid);
    MyDouble *pMyDouble = NULL;
    *(MyDouble **)&pMyDouble = *(MyDouble **)&cPtr;
    $1 = &pMyDouble->value;
}

%typemap(jtype) double *OUTVALUE "MyDouble"
%typemap(jstype) double *OUTVALUE "MyDouble"
%typemap(jni) double *OUTVALUE "jobject"

%typemap(javain) double *OUTVALUE "$javainput"

/* Now we apply the typemap to the named variables */
%apply double *OUTVALUE { double *out1, double *out2 };
int spam(double a, double b, double *out1, double *out2);

Note that the C++ JNI calling convention has been used this time and so must be compiled as C++ and the -c++ commandline must be passed to SWIG. JNI error checking has been omitted for clarity.

What the typemaps do are make the named double* function parameters use our new MyDouble wrapper structure. The "in" typemap takes this structure, gets the C++ pointer to it, takes the double value member variable and passes it to the C++ spam function. In Java, when the function returns, we use the SWIG created getValue() function to get the output value. The following Java program demonstrates this:

// File: runme.java

public class runme {

  static {
    try {
      System.loadLibrary("example");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load. " + e);
      System.exit(1);
    }
  }

  public static void main(String argv[]) {
    MyDouble out1 = new MyDouble();
    MyDouble out2 = new MyDouble();
    int ret = example.spam(1.2, 3.4, out1, out2);
    System.out.println(ret + "  " + out1.getValue() + "  " + out2.getValue());
  }
}

When compiled and run we get:

$ java runme
1 12.0  340.0

25.10.7 Adding Java downcasts to polymorphic return types

SWIG support for polymorphism works in that the appropriate virtual function is called. However, the default generated code does not allow for downcasting. Let's examine this with the following code:

%include "std_string.i"

#include <iostream>
using namespace std;
class Vehicle {
public:
    virtual void start() = 0;
...
};

class Ambulance : public Vehicle {
    string vol;
public:
    Ambulance(string volume) : vol(volume) {}
    virtual void start() {
        cout << "Ambulance started" << endl;
    }
    void sound_siren() {
        cout << vol << " siren sounded!" << endl;
    }
...
};

Vehicle *vehicle_factory() {
    return new Ambulance("Very loud");
}

If we execute the following Java code:

Vehicle vehicle = example.vehicle_factory();
vehicle.start();

Ambulance ambulance = (Ambulance)vehicle;
ambulance.sound_siren();

We get:

Ambulance started
java.lang.ClassCastException
        at runme.main(runme.java:16)

Even though we know from examination of the C++ code that vehicle_factory returns an object of type Ambulance, we are not able to use this knowledge to perform the downcast in Java. This occurs because the runtime type information is not completely passed from C++ to Java when returning the type from vehicle_factory(). Usually this is not a problem as virtual functions do work by default, such as in the case of start(). There are a few solutions to getting downcasts to work.

The first is not to use a Java cast but a call to C++ to make the cast. Add this to your code:

%exception Ambulance::dynamic_cast(Vehicle *vehicle) {
    $action
    if (!result) {
        jclass excep = jenv->FindClass("java/lang/ClassCastException");
        if (excep) {
            jenv->ThrowNew(excep, "dynamic_cast exception");
        }
    }
}
%extend Ambulance {
    static Ambulance *dynamic_cast(Vehicle *vehicle) {
        return dynamic_cast<Ambulance *>(vehicle);
    }
};

It would then be used from Java like this

Ambulance ambulance = Ambulance.dynamic_cast(vehicle);
ambulance.sound_siren();

Should vehicle not be of type ambulance then a Java ClassCastException is thrown. The next solution is a purer solution in that Java downcasts can be performed on the types. Add the following before the definition of vehicle_factory:

%typemap(out) Vehicle * {
    Ambulance *downcast = dynamic_cast<Ambulance *>($1);
    *(Ambulance **)&$result = downcast;
}

%typemap(javaout) Vehicle * {
    return new Ambulance($jnicall, $owner);
  }

Here we are using our knowledge that vehicle_factory always returns type Ambulance so that the Java proxy is created as a type Ambulance. If vehicle_factory can manufacture any type of Vehicle and we want to be able to downcast using Java casts for any of these types, then a different approach is needed. Consider expanding our example with a new Vehicle type and a more flexible factory function:

class FireEngine : public Vehicle {
public:
    FireEngine() {}
    virtual void start() {
        cout << "FireEngine started" << endl;
    }
    void roll_out_hose() {
        cout << "Hose rolled out" << endl;
    }
 ...
};
Vehicle *vehicle_factory(int vehicle_number) {
    if (vehicle_number == 0)
        return new Ambulance("Very loud");
    else
        return new FireEngine();
}

To be able to downcast with this sort of Java code:

FireEngine fireengine = (FireEngine)example.vehicle_factory(1);
fireengine.roll_out_hose();
Ambulance ambulance = (Ambulance)example.vehicle_factory(0);
ambulance.sound_siren();

the following typemaps targeted at the vehicle_factory function will achieve this. Note that in this case, the Java class is constructed using JNI code rather than passing a pointer across the JNI boundary in a Java long for construction in Java code.

%typemap(jni) Vehicle *vehicle_factory "jobject"
%typemap(jtype) Vehicle *vehicle_factory "Vehicle"
%typemap(jstype) Vehicle *vehicle_factory "Vehicle"
%typemap(javaout) Vehicle *vehicle_factory {
    return $jnicall;
  }

%typemap(out) Vehicle *vehicle_factory {
    Ambulance *ambulance = dynamic_cast<Ambulance *>($1);
    FireEngine *fireengine = dynamic_cast<FireEngine *>($1);
    if (ambulance) {
        // call the Ambulance(long cPtr, boolean cMemoryOwn) constructor
        jclass clazz = jenv->FindClass("Ambulance");
        if (clazz) {
            jmethodID mid = jenv->GetMethodID(clazz, "<init>", "(JZ)V");
            if (mid) {
                jlong cptr = 0;
                *(Ambulance **)&cptr = ambulance; 
                $result = jenv->NewObject(clazz, mid, cptr, false);
            }
        }
    } else if (fireengine) {
        // call the FireEngine(long cPtr, boolean cMemoryOwn) constructor
        jclass clazz = jenv->FindClass("FireEngine");
        if (clazz) {
            jmethodID mid = jenv->GetMethodID(clazz, "<init>", "(JZ)V");
            if (mid) {
                jlong cptr = 0;
                *(FireEngine **)&cptr = fireengine; 
                $result = jenv->NewObject(clazz, mid, cptr, false);
            }
        }
    }
    else {
        cout << "Unexpected type " << endl;
    }

    if (!$result)
        cout << "Failed to create new java object" << endl;
}

Better error handling would need to be added into this code. There are other solutions to this problem, but this last example demonstrates some more involved JNI code. SWIG usually generates code which constructs the proxy classes using Java code as it is easier to handle error conditions and is faster. Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.

25.10.8 Adding an equals method to the Java classes

When a pointer is returned from a JNI function, it is wrapped using a new Java proxy class or type wrapper class. Even when the pointers are the same, it will not be possible to know that the two Java classes containing those pointers are actually the same object. It is common in Java to use the equals() method to check whether two objects are equivalent. The equals() method is usually accompanied by a hashCode() method in order to fulfill the requirement that the hash code is equal for equal objects. Pure Java code methods like these can be easily added:

%typemap(javacode) SWIGTYPE %{
  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof $javaclassname)
      equal = ((($javaclassname)obj).swigCPtr == this.swigCPtr);
    return equal;
  }
  public int hashCode() {
     return (int)getPointer();
  }
%}

class Foo { };
Foo* returnFoo(Foo *foo) { return foo; }

The following would display false without the javacode typemap above. With the typemap defining the equals method the result is true.

Foo foo1 = new Foo();
Foo foo2 = example.returnFoo(foo1);
System.out.println("foo1? " + foo1.equals(foo2));

25.10.9 Void pointers and a common Java base class

One might wonder why the common code that SWIG emits for the proxy and type wrapper classes is not pushed into a base class. The reason is that although swigCPtr could be put into a common base class for all classes wrapping C structures, it would not work for C++ classes involved in an inheritance chain. Each class derived from a base needs a separate swigCPtr because C++ compilers sometimes use a different pointer value when casting a derived class to a base. Additionally as Java only supports single inheritance, it would not be possible to derive wrapped classes from your own pure Java classes if the base class has been 'used up' by SWIG. However, you may want to move some of the common code into a base class. Here is an example which uses a common base class for all proxy classes and type wrapper classes:

%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], 
                                                         SWIGTYPE (CLASS::*) "SWIG"

%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], 
                                                         SWIGTYPE (CLASS::*) %{
  protected long getPointer() {
    return swigCPtr;
  }
%}

Define new base class called SWIG:

public abstract class SWIG {
  protected abstract long getPointer();

  public boolean equals(Object obj) {
    boolean equal = false;
    if (obj instanceof SWIG)
      equal = (((SWIG)obj).getPointer() == this.getPointer());
    return equal;
  }
  
  SWIGTYPE_p_void getVoidPointer() {
    return new SWIGTYPE_p_void(getPointer(), false);
  }
}

This example contains some useful functionality which you may want in your code.

  • It has an equals() method. Unlike the previous example, the method code isn't replicated in all classes.
  • It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer.

25.10.10 Struct pointer to pointer

Pointers to pointers are often used as output parameters in C factory type functions. These are a bit more tricky to handle. Consider the following situation where a Butler can be hired and fired:

typedef struct {
  int hoursAvailable;
  char *greeting;
} Butler;

// Note: HireButler will allocate the memory 
// The caller must free the memory by calling FireButler()!!
extern int HireButler(Butler **ppButler);
extern void FireButler(Butler *pButler);

C code implementation:

int HireButler(Butler **ppButler) {
  Butler *pButler = (Butler *)malloc(sizeof(Butler));
  pButler->hoursAvailable = 24;
  pButler->greeting = (char *)malloc(32);
  strcpy(pButler->greeting, "At your service Sir");
  *ppButler = pButler;
  return 1;
}
void FireButler(Butler *pButler) {
  free(pButler->greeting);
  free(pButler);
}

Let's take two approaches to wrapping this code. The first is to provide a functional interface, much like the original C interface. The following Java code shows how we intend the code to be used:

    Butler jeeves = new Butler();
    example.HireButler(jeeves);
    System.out.println("Greeting:     " + jeeves.getGreeting());
    System.out.println("Availability: " + jeeves.getHoursAvailable() + " hours per day");
    example.FireButler(jeeves);

Resulting in the following output when run:

Greeting:     At your service Sir
Availability: 24 hours per day

Note the usage is very much like it would be used if we were writing C code, that is, explicit memory management is needed. No C memory is allocated in the construction of the Butler proxy class and the proxy class will not destroy the underlying C memory when it is collected. A number of typemaps and features are needed to implement this approach. The following interface file code should be placed before SWIG parses the above C code.

%module example

// Do not generate the default proxy constructor or destructor
%nodefaultctor Butler;
%nodefaultdtor Butler;

// Add in pure Java code proxy constructor
%typemap(javacode) Butler %{
  /** This constructor creates the proxy which initially does not create nor own any C memory */
  public Butler() {
    this(0, false);
  }
%}

// Type typemaps for marshalling Butler **
%typemap(jni) Butler ** "jobject"
%typemap(jtype) Butler ** "Butler"
%typemap(jstype) Butler ** "Butler"

// Typemaps for Butler ** as a parameter output type
%typemap(in) Butler ** (Butler *ppButler = 0) %{
  $1 = &ppButler;
%}
%typemap(argout) Butler ** {
  // Give Java proxy the C pointer (of newly created object)
  jclass clazz = (*jenv)->FindClass(jenv, "Butler");
  jfieldID fid = (*jenv)->GetFieldID(jenv, clazz, "swigCPtr", "J");
  jlong cPtr = 0;
  *(Butler **)&cPtr = *$1;
  (*jenv)->SetLongField(jenv, $input, fid, cPtr);
}
%typemap(javain) Butler ** "$javainput"

Note that the JNI code sets the proxy's swigCPtr member variable to point to the newly created object. The swigCMemOwn remains unchanged (at false), so that the proxy does not own the memory.

Note: The old %nodefault directive disabled the default constructor and destructor at the same time. This is unsafe in most of the cases, and you can use the explicit %nodefaultctor and %nodefaultdtor directives to achieve the same result if needed.

The second approach offers a more object oriented interface to the Java user. We do this by making the Java proxy class's constructor call the HireButler() method to create the underlying C object. Additionally we get the proxy to take ownership of the memory so that the finalizer will call the FireButler() function. The proxy class will thus take ownership of the memory and clean it up when no longer needed. We will also prevent the user from being able to explicitly call the HireButler() and FireButler() functions. Usage from Java will simply be:

Butler jeeves = new Butler();
System.out.println("Greeting:     " + jeeves.getGreeting());
System.out.println("Availability: " + jeeves.getHoursAvailable() + " hours per day");

Note that the Butler class is used just like any other Java class and no extra coding by the user needs to be written to clear up the underlying C memory as the finalizer will be called by the garbage collector which in turn will call the FireButler() function. To implement this, we use the above interface file code but remove the javacode typemap and add the following:

// Don't expose the memory allocation/de-allocation functions
%ignore FireButler(Butler *pButler);
%ignore HireButler(Butler **ppButler);

// Add in a custom proxy constructor and destructor
%extend Butler {
  Butler() {
    Butler *pButler = 0;
    HireButler(&pButler);
    return pButler;
  }
  ~Butler() {
     FireButler($self);
   }
}

Note that the code in %extend is using a C++ type constructor and destructor, yet the generated code will still compile as C code, see Adding member functions to C structures. The C functional interface has been completely morphed into an object-oriented interface and the Butler class would behave much like any pure Java class and feel more natural to Java users.

25.10.11 Memory management when returning references to member variables

This example shows how to prevent premature garbage collection of objects when the underlying C++ class returns a pointer or reference to a member variable.

Consider the following C++ code:

struct Wheel {
  int size;
  Wheel(int sz) : size(sz) {}
};

class Bike {
  Wheel wheel;
public:
  Bike(int val) : wheel(val) {}
  Wheel& getWheel() { return wheel; }
};

and the following usage from Java after running the code through SWIG:

    Wheel wheel = new Bike(10).getWheel();
    System.out.println("wheel size: " + wheel.getSize());
    // Simulate a garbage collection
    System.gc();
    System.runFinalization();
    System.out.println("wheel size: " + wheel.getSize());

Don't be surprised that if the resulting output gives strange results such as...

wheel size: 10
wheel size: 135019664

What has happened here is the garbage collector has collected the Bike instance as it doesn't think it is needed any more. The proxy instance, wheel, contains a reference to memory that was deleted when the Bike instance was collected. In order to prevent the garbage collector from collecting the Bike instance a reference to the Bike must be added to the wheel instance. You can do this by adding the reference when the getWheel() method is called using the following typemaps.

%typemap(javacode) Wheel %{
  // Ensure that the GC doesn't collect any Bike instance set from Java
  private Bike bikeReference;
  protected void addReference(Bike bike) {
    bikeReference = bike;
  }
%}

// Add a Java reference to prevent premature garbage collection and resulting use
// of dangling C++ pointer. Intended for methods that return pointers or
// references to a member variable.
%typemap(javaout) Wheel& getWheel {
    long cPtr = $jnicall;
    $javaclassname ret = null;
    if (cPtr != 0) {
      ret = new $javaclassname(cPtr, $owner);
      ret.addReference(this);
    }
    return ret;
  }

The code in the first typemap gets added to the Wheel proxy class. The code in the second typemap constitutes the bulk of the code in the generated getWheel() function:

public class Wheel {
  ...
  // Ensure that the GC doesn't collect any bike set from Java 
  private Bike bikeReference;
  protected void addReference(Bike bike) {
    bikeReference = bike;
  }
}

public class Bike {
  ...
  public Wheel getWheel() {
    long cPtr = exampleJNI.Bike_getWheel(swigCPtr, this);
    Wheel ret = null;
    if (cPtr != 0) {
      ret = new Wheel(cPtr, false);
      ret.addReference(this);
    }
    return ret;
  }
}

Note the addReference call.

25.10.12 Memory management for objects passed to the C++ layer

Managing memory can be tricky when using C++ and Java proxy classes. The previous example shows one such case and this example looks at memory management for a class passed to a C++ method which expects the object to remain in scope after the function has returned. Consider the following two C++ classes:

struct Element {
  int value;
  Element(int val) : value(val) {}
};
class Container {
  Element* element;
public:
  Container() : element(0) {}
  void setElement(Element* e) { element = e; }
  Element* getElement() { return element; }
};

and usage from C++

    Container container;
    Element element(20);
    container.setElement(&element);
    cout << "element.value: " << container.getElement()->value << endl;

and more or less equivalent usage from Java

    Container container = new Container();
    container.setElement(new Element(20));
    System.out.println("element value: " + container.getElement().getValue());

The C++ code will always print out 20, but the value printed out may not be this in the Java equivalent code. In order to understand why, consider a garbage collection occuring...

    Container container = new Container();
    container.setElement(new Element(20));
    // Simulate a garbage collection
    System.gc();
    System.runFinalization();
    System.out.println("element value: " + container.getElement().getValue());

The temporary element created with new Element(20) could get garbage collected which ultimately means the container variable is holding a dangling pointer, thereby printing out any old random value instead of the expected value of 20. One solution is to add in the appropriate references in the Java layer...

public class Container {

  ...

  // Ensure that the GC doesn't collect any Element set from Java
  // as the underlying C++ class stores a shallow copy
  private Element elementReference;
  private long getCPtrAndAddReference(Element element) {
    elementReference = element;
    return Element.getCPtr(element);
  }

  public void setElement(Element e) {
    exampleJNI.Container_setElement(swigCPtr, this, getCPtrAndAddReference(e), e);
  }
}

The following typemaps will generate the desired code. The 'javain' typemap matches the input parameter type for the setElement method. The 'javacode' typemap simply adds in the specified code into the Java proxy class.

%typemap(javain) Element *e "getCPtrAndAddReference($javainput)"

%typemap(javacode) Container %{
  // Ensure that the GC doesn't collect any element set from Java
  // as the underlying C++ class stores a shallow copy
  private Element elementReference;
  private long getCPtrAndAddReference(Element element) {
    elementReference = element;
    return Element.getCPtr(element);
  }
%}

25.10.13 Date marshalling using the javain typemap and associated attributes

The NaN Exception example is a simple example of the "javain" typemap and its 'pre' attribute. This example demonstrates how a C++ date class, say CDate, can be mapped onto the standard Java date class, java.util.GregorianCalendar by using the 'pre', 'post' and 'pgcppname' attributes of the "javain" typemap. The idea is that the GregorianCalendar is used wherever the C++ API uses a CDate. Let's assume the code being wrapped is as follows:

class CDate {
public:
  CDate(int year, int month, int day);
  int getYear();
  int getMonth();
  int getDay();
  ...
};
struct Action {
  static int doSomething(const CDate &dateIn, CDate &dateOut);
  Action(const CDate &date, CDate &dateOut);
};

Note that dateIn is const and therefore read only and dateOut is a non-const output type.

First let's look at the code that is generated by default, where the Java proxy class CDate is used in the proxy interface:

public class Action {
  ...
  public static int doSomething(CDate dateIn, CDate dateOut) {
    return exampleJNI.Action_doSomething(CDate.getCPtr(dateIn), dateIn, 
                                         CDate.getCPtr(dateOut), dateOut);
  }

  public Action(CDate date, CDate dateOut) {
    this(exampleJNI.new_Action(CDate.getCPtr(date), date, 
                               CDate.getCPtr(dateOut), dateOut), true);
  }
}

The CDate & and const CDate & Java code is generated from the following two default typemaps:

%typemap(jstype) SWIGTYPE & "$javaclassname"
%typemap(javain) SWIGTYPE & "$javaclassname.getCPtr($javainput)"

where '$javaclassname' is translated into the proxy class name, CDate and '$javainput' is translated into the name of the parameter, eg dateIn. From Java, the intention is then to call into a modifed API with something like:

java.util.GregorianCalendar calendarIn = 
    new java.util.GregorianCalendar(2011, java.util.Calendar.APRIL, 13, 0, 0, 0);
java.util.GregorianCalendar calendarOut = new java.util.GregorianCalendar();

// Note in calls below, calendarIn remains unchanged and calendarOut 
// is set to a new value by the C++ call
Action.doSomething(calendarIn, calendarOut);
Action action = new Action(calendarIn, calendarOut);

To achieve this mapping, we need to alter the default code generation slightly so that at the Java layer, a GregorianCalendar is converted into a CDate. The JNI intermediary layer will still take a pointer to the underlying CDate class. The typemaps to achieve this are shown below.

%typemap(jstype) const CDate& "java.util.GregorianCalendar"
%typemap(javain, 
         pre="    CDate temp$javainput = new CDate($javainput.get(java.util.Calendar.YEAR), "
             "$javainput.get(java.util.Calendar.MONTH), $javainput.get(java.util.Calendar.DATE));", 
         pgcppname="temp$javainput") const CDate &
         "$javaclassname.getCPtr(temp$javainput)"

%typemap(jstype) CDate& "java.util.Calendar"
%typemap(javain, 
         pre="    CDate temp$javainput = new CDate($javainput.get(java.util.Calendar.YEAR), "
             "$javainput.get(java.util.Calendar.MONTH), $javainput.get(java.util.Calendar.DATE));", 
         post="      $javainput.set(temp$javainput.getYear(), temp$javainput.getMonth(), "
              "temp$javainput.getDay(), 0, 0, 0);", 
         pgcppname="temp$javainput") CDate &
         "$javaclassname.getCPtr(temp$javainput)"

The resulting generated proxy code in the Action class follows:

public class Action {
  ...
  public static int doSomething(java.util.GregorianCalendar dateIn, 
                                java.util.Calendar dateOut) {
    CDate tempdateIn = new CDate(dateIn.get(java.util.Calendar.YEAR), 
                                 dateIn.get(java.util.Calendar.MONTH), 
                                 dateIn.get(java.util.Calendar.DATE));
    CDate tempdateOut = new CDate(dateOut.get(java.util.Calendar.YEAR), 
                                  dateOut.get(java.util.Calendar.MONTH), 
                                  dateOut.get(java.util.Calendar.DATE));
    try {
      return exampleJNI.Action_doSomething(CDate.getCPtr(tempdateIn), tempdateIn, 
                                           CDate.getCPtr(tempdateOut), tempdateOut);
    } finally {
      dateOut.set(tempdateOut.getYear(), tempdateOut.getMonth(), tempdateOut.getDay(), 0, 0, 0);
    }
  }

  static private long SwigConstructAction(java.util.GregorianCalendar date, 
                                          java.util.Calendar dateOut) {
    CDate tempdate = new CDate(date.get(java.util.Calendar.YEAR), 
                               date.get(java.util.Calendar.MONTH), 
                               date.get(java.util.Calendar.DATE));
    CDate tempdateOut = new CDate(dateOut.get(java.util.Calendar.YEAR), 
                                  dateOut.get(java.util.Calendar.MONTH), 
                                  dateOut.get(java.util.Calendar.DATE));
    try {
      return exampleJNI.new_Action(CDate.getCPtr(tempdate), tempdate, 
                                   CDate.getCPtr(tempdateOut), tempdateOut);
    } finally {
      dateOut.set(tempdateOut.getYear(), tempdateOut.getMonth(), tempdateOut.getDay(), 0, 0, 0);
    }
  }

  public Action(java.util.GregorianCalendar date, java.util.Calendar dateOut) {
    this(Action.SwigConstructAction(date, dateOut), true);
  }
}

A few things to note:

  • The "javatype" typemap has changed the parameter type to java.util.GregorianCalendar or java.util.Calendar instead of the default generated CDate proxy.
  • The code in the 'pre' attribute appears before the JNI call (exampleJNI.new_Action / exampleJNI.Action_doSomething).
  • The code in the 'post' attribute appears after the JNI call.
  • A try .. finally block is generated with the JNI call in the try block and 'post' code in the finally block. The alternative of just using a temporary variable for the return value from the JNI call and the 'post' code being generated before the return statement is not possible given that the JNI call is in one line and comes from the "javaout" typemap.
  • The temporary variables in the "javain" typemaps are called temp$javain, where "$javain" is replaced with the parameter name. "$javain" is used to mangle the variable name so that more than one CDate & type can be used as a parameter in a method, otherwise two or more local variables with the same name would be generated.
  • The use of the "javain" typemap causes a constructor helper function (SwigConstructAction) to be generated. This allows Java code to be called before the JNI call and is required as the Java compiler won't compile code inserted before the 'this' call.
  • The 'pgcppname' attribute is used to modify the object being passed as the premature garbage collection prevention parameter (the 2nd and 4th parameters in the JNI calls).

25.11 Living with Java Directors

This section is intended to address frequently asked questions and frequently encountered problems when using Java directors.

  1. When my program starts up, it complains that method_foo cannot be found in a Java method called swig_module_init. How do I fix this?

    Open up the C++ wrapper source code file and look for "method_foo" (include the double quotes, they are important!) Look at the JNI field descriptor and make sure that each class that occurs in the descriptor has the correct package name in front of it. If the package name is incorrect, put a "javapackage" typemap in your SWIG interface file.

  2. I'm compiling my code and I'm using templates. I provided a javapackage typemap, but SWIG doesn't generate the right JNI field descriptor.

    Use the template's renamed name as the argument to the "javapackage" typemap:

    %typemap(javapackage)  std::vector<int>  "your.package.here"
    %template(VectorOfInt) std::vector<int>;
    
  3. When I pass class pointers or references through a C++ upcall and I try to type cast them, Java complains with a ClassCastException. What am I doing wrong?

    Normally, a non-director generated Java proxy class creates temporary Java objects as follows:

    public static void MyClass_method_upcall(MyClass self, long jarg1)
    {
      Foo darg1 = new Foo(jarg1, false);
    
      self.method_upcall(darg1);
    }
    

    Unfortunately, this loses the Java type information that is part of the underlying Foo director proxy class's Java object pointer causing the type cast to fail. The SWIG Java module's director code attempts to correct the problem, but only for director-enabled classes, since the director class retains a global reference to its Java object. Thus, for director-enabled classes and only for director-enabled classes, the generated proxy Java code looks something like:

    public static void MyClass_method_upcall(MyClass self, long jarg1,
                                             Foo jarg1_object)
    {
      Foo darg1 = (jarg1_object != null ? jarg1_object : new Foo(jarg1, false));
    
      self.method_upcall(darg1);
    }
    

    When you import a SWIG interface file containing class definitions, the classes you want to be director-enabled must be have the feature("director") enabled for type symmetry to work. This applies even when the class being wrapped isn't a director-enabled class but takes parameters that are director-enabled classes.

    The current "type symmetry" design will work for simple C++ inheritance, but will most likely fail for anything more complicated such as tree or diamond C++ inheritance hierarchies. Those who are interested in challenging problems are more than welcome to hack the Java::Java_director_declaration method in Source/Modules/java.cxx.

    If all else fails, you can use the downcastXXXXX() method to attempt to recover the director class's Java object pointer. For the Java Foo proxy class, the Foo director class's java object pointer can be accessed through the javaObjectFoo() method. The generated method's signature is:

      public static Foo javaObjectFoo(Foo obj);
    

    From your code, this method is invoked as follows:

    public class MyClassDerived {
      public void method_upcall(Foo foo_object)
      {
        FooDerived    derived = (foo_object != null ?
                     (FooDerived) Foo.downcastFoo(foo_object) : null);
        /* rest of your code here */
      }
    }
    

    An good approach for managing downcasting is placing a static method in each derived class that performs the downcast from the superclass, e.g.,

    public class FooDerived extends Foo {
      /* ... */
      public static FooDerived downcastFooDerived(Foo foo_object)
      {
        try {
         return (foo_object != null ? (FooDerived) Foo.downcastFoo(foo_object);
        }
    
        catch (ClassCastException exc) {
          // Wasn't a FooDerived object, some other subclass of Foo
          return null;
        }
      }
    }
    

    Then change the code in MyClassDerived as follows:

    public class MyClassDerived extends MyClass {
      /* ... */
      public void method_upcall(Foo foo_object)
      {
        FooDerived    derived = FooDerived.downcastFooDerived(foo_object);
        /* rest of your code here */
      }
    }
    
  4. Why isn't the proxy class declared abstract? Why aren't the director upcall methods in the proxy class declared abstract?

    Declaring the proxy class and its methods abstract would break the JNI argument marshalling and SWIG's downcall functionality (going from Java to C++.) Create an abstract Java subclass that inherits from the director-enabled class instead. Using the previous Foo class example:

    public abstract class UserVisibleFoo extends Foo {
      /** Make sure user overrides this method, it's where the upcall
       * happens.
       */
      public abstract void method_upcall(Foo foo_object);
    
      /// Downcast from Foo to UserVisibleFoo
      public static UserVisibleFoo downcastUserVisibleFoo(Foo foo_object)
      {
        try {
         return (foo_object != null ? (FooDerived) Foo.downcastFoo(foo_object) : null);
        }
    
        catch (ClassCastException exc) {
          // Wasn't a FooDerived object, some other subclass of Foo
          return null;
        }
      }
    }
    

    This doesn't prevent the user from creating subclasses derived from Foo, however, UserVisibleFoo provides the safety net that reminds the user to override the method_upcall() method.

25.12 Odds and ends

25.12.1 JavaDoc comments

The SWIG documentation system is currently deprecated. When it is resurrected JavaDoc comments will be fully supported. If you can't wait for the full documentation system a couple of workarounds are available. The %javamethodmodifiers feature can be used for adding proxy class method comments and module class method comments. The "javaimports" typemap can be hijacked for adding in proxy class JavaDoc comments. The jniclassimports or jniclassclassmodifiers pragmas can also be used for adding intermediary JNI class comments and likewise the moduleimports or moduleclassmodifiers pragmas for the module class. Here is an example adding in a proxy class and method comment:

%javamethodmodifiers Barmy::lose_marbles() "
  /**
    * Calling this method will make you mad.
    * Use with <b>utmost</b> caution. 
    */
  public";

%typemap(javaimports) Barmy "
/** The crazy class. Use as a last resort. */"

class Barmy {
public:
  void lose_marbles() {}
};

Note the "public" added at the end of the %javamethodmodifiers as this is the default for this feature. The generated proxy class with JavaDoc comments is then as follows:

/** The crazy class. Use as a last resort. */
public class Barmy {
...
  /**
    * Calling this method will make you mad.
    * Use with <b>utmost</b> caution. 
    */
  public void lose_marbles() {
    ...
  }
...
}

25.12.2 Functional interface without proxy classes

It is possible to run SWIG in a mode that does not produce proxy classes by using the -noproxy commandline option. The interface is rather primitive when wrapping structures or classes and is accessed through function calls to the module class. All the functions in the module class are wrapped by functions with identical names as those in the intermediary JNI class.

Consider the example we looked at when examining proxy classes:

class Foo {
public:
     int x;
     int spam(int num, Foo* foo);
};

When using -noproxy, type wrapper classes are generated instead of proxy classes. Access to all the functions and variables is through a C like set of functions where the first parameter passed is the pointer to the class, that is an instance of a type wrapper class. Here is what the module class looks like:

public class example {
  public static void Foo_x_get(SWIGTYPE_p_Foo self, int x) {...}
  public static int Foo_x_get(SWIGTYPE_p_Foo self) {...}
  public static int Foo_spam(SWIGTYPE_p_Foo self, int num, SWIGTYPE_p_Foo foo) {...}
  public static SWIGTYPE_p_Foo new_Foo() {...}
  public static void delete_Foo(SWIGTYPE_p_Foo self) {...}
}

This approach is not nearly as natural as using proxy classes as the functions need to be used like this:

SWIGTYPE_p_Foo foo = example.new_Foo();
example.Foo_x_set(foo, 10);
int var = example.Foo_x_get(foo);
example.Foo_spam(foo, 20, foo);
example.delete_Foo(foo);

Unlike proxy classes, there is no attempt at tracking memory. All destructors have to be called manually for example the delete_Foo(foo) call above.

25.12.3 Using your own JNI functions

You may have some hand written JNI functions that you want to use in addition to the SWIG generated JNI functions. Adding these to your SWIG generated package is possible using the %native directive. If you don't want SWIG to wrap your JNI function then of course you can simply use the %ignore directive. However, if you want SWIG to generate just the Java code for a JNI function then use the %native directive. The C types for the parameters and return type must be specified in place of the JNI types and the function name must be the native method name. For example:

%native (HandRolled) void HandRolled(int, char *);
%{
JNIEXPORT void JNICALL Java_packageName_moduleName_HandRolled(JNIEnv *, jclass,
                                                              jlong, jstring);
%}

No C JNI function will be generated and the Java_packageName_moduleName_HandRolled function will be accessible using the SWIG generated Java native method call in the intermediary JNI class which will look like this:

  public final static native void HandRolled(int jarg1, String jarg2);

and as usual this function is wrapped by another which for a global C function would appear in the module class:

  public static void HandRolled(int arg0, String arg1) {
    exampleJNI.HandRolled(arg0, arg1);
  }

The packageName and moduleName must of course be correct else you will get linker errors when the JVM dynamically loads the JNI function. You may have to add in some "jtype", "jstype", "javain" and "javaout" typemaps when wrapping some JNI types. Here the default typemaps work for int and char *.

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.

25.12.4 Performance concerns and hints

If you're directly manipulating huge arrays of complex objects from Java, performance may suffer greatly when using the array functions in arrays_java.i. Try and minimise the expensive JNI calls to C/C++ functions, perhaps by using temporary Java variables instead of accessing the information directly from the C/C++ object.

Java classes without any finalizers generally speed up code execution as there is less for the garbage collector to do. Finalizer generation can be stopped by using an empty javafinalize typemap:

%typemap(javafinalize) SWIGTYPE ""

However, you will have to be careful about memory management and make sure that you code in a call to the delete() member function. This method normally calls the C++ destructor or free() for C code.

25.12.5 Debugging

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, where it is possible to step from Java code into a JNI method within one environment.

Alternatively, debugging can involve placing debug printout statements in the JNI layer using the %exception directive. See the special variables for %exception section. Many of the default typemaps can also be overridden and modified for adding in extra logging/debug display information.

The -Xcheck:jni and -Xcheck:nabounds Java executable options are useful for debugging to make sure the JNI code is behaving. The -verbose:jni and -verbose:gc are also useful options for monitoring code behaviour.

25.13 Java Examples

The directory Examples/java has a number of further examples. Take a look at these if you want to see some of the techniques described in action. The Examples/index.html file in the parent directory contains the SWIG Examples Documentation and is a useful starting point. If your SWIG installation went well Unix users should be able to type make in each example directory, then java main to see them running. For the benefit of Windows users, there are also Visual C++ project files in a couple of the Windows Examples. There are also many regression tests in the Examples/test-suite directory. Many of these have runtime tests in the java subdirectory.

swig-3.0.2/Doc/Manual/SWIGDocumentation.pdf0000664000175000017500001026235112343706605020305 0ustar williamwilliam%PDF-1.3 %âãÏÓ 1 0 obj<>endobj 2 0 obj<>endobj 3 0 obj<>endobj 4 0 obj<>endobj 5 0 obj<>endobj 6 0 obj<>endobj 7 0 obj<>endobj 8 0 obj<>endobj 9 0 obj<>endobj 10 0 obj<>endobj 11 0 obj<>endobj 12 0 obj<>endobj 13 0 obj<>endobj 14 0 obj<>stream xí Ô-GUç?3×Ye$ˆÈ; !o^æB@!Áp„„‡à5ò‘G¯0L¸Æk€x¹^A㺙1¬€"O5 +’€Y&J0a Q£ —ŒEe~Õÿ>ûÛ§ªOçœ>>ß·ÏêÕ_uÕ®½wíú×î]ÕÕýýÐÅ/,°y,°6áïÑñ l" LÿµMÔôhJXàÑ“âÿQM¿G>ò‘ÇsÌQý ñµ©uÜqÇmT©.?öØc}ÝHon €G<⣰qôÑGS Mw#LŠÿã›~?üÃ?üä'?ù¬³Îz–û½ñotWÏ¢ô)Oy ”Æà„N8õÔSŸùÌgz²ÆôŽ; |ìcku#±é-pÊ)§<ãÏhÄù”2ºa&øGŸ¾ð…?>øíܹóï|ç¿þë¿îÛ·ô ûÇ_ô¢vÓù¤“NzÁ ^`¥$®»îºŸþéŸ~Ík^óú׿þþà^ö²—YéýØÑd«‰Ím|ûóž÷¼W¼â»wï~×»ÞuÅWüÆoüƯÿú¯ƒ¨ŸýÙŸ}å+_ùüç?ÿ1yL£Ž=æè‡þ£çËÄä}¸œIñORþžþô§£ý^ýêWñ‹_üÏÿüÏ¿ø‹¿xÝë^gù$Î8㠫νà¹Ï}®•^xá…ý×ý/ÿò/ÿöoÿöÏÿüÏó7ÃX°R(O>ùd«‰Ím€ýâ¿ø—ù—Aþ¯üʯø¥_ú¥÷¾÷½û÷ïÿÕ_ýÕ_ûµ_û©Ÿú)ÆHi„í'l?íéO}ùÏœrÑÛÿú·ŸÄqÑÛŸ`‰‹ß~Ò+/=ñ¬gŸyâãOäöAõ™àŸàçGÝŸ¶øÔþÉŸüIWò£O}êSMçO<ñì³Ï¶Òÿ[ý>ÿùÏ3pHÞ|óÍ_ùÊW¬”ûàžð«‰EZà~ápJx³Lèõ×_ÿï|gÏž=Y>9_ÿúשrÓM7øÒQU< i&†ÏyÎs.ºè"b†sÏ=÷ÙÏ~6gÂŒ—¼ä%rŒ°¯H­ÓŸzúy¯;ñíŸ;ø²/¬]þ…µw~a-K¼ãóßõ??ðÀ3N?ý±ÛO î¤øgêQþˆd~dø‡Úxò .¸€Hæ[ßúVbäBò¤'=ɪÿs;P½÷½ï}Д¿+¯¼RPÿ[ÝH,ÌøÀðHt ø÷BwíÚ¥þúùŸÿyŸJ¿ýíoÿÃ?üõ×^ €·ÒQUŒÀ,•TÐõozÓ›>þñík_û÷ÿ÷¿üË¿üä'?yÉ%—O)h7zK<éÔ'½ìM¼ì¦ïÞ{ÓçÿyåýÏ~γwì8{ÇŽgí8ûœ;ž³cÇžsöYgžuæöÇn§Ö¤ø?¢é÷¸Ç=ÇÎ8ýÌg>ƒÓ~ík_û?ñàŸ[QÍwÞ‰¸#@ƒÏ7LÞ¹qœvÚi´#2éwë­·’_üÈG>?æÎ¬ÖYÝH,ÆDÚ€ÿƒü ç?ÿó?7¡Ä Ó³?÷s?GþyçGGÿöoÿ6á ™¿ø‹¿H&U¸ Òe2Gýþð‡3Ýc(ýã?þ#ˆâ>´8ùË_þ§ú' JYʪwÌ1OÙ±ýUo?lÏg×ö|æ =ׯýøÅÇÿÈ3~äYg?ëÝïÚ÷­ÿ÷­[oý³]»~æÌ3Î<ýé§?úQ N3Á?3‘'>ñ‰Ü­Ð–¶³1±ÿÜ­Î<óLtþ£?ú#r áÁ¡éÌøe 1¿}ìc:ø1ó$ÿô÷~ï÷¸50ñÑ‘ÕÄÂ,ðò—¿èÒ­ÿthÿЇ>døçŽÿÿñ×\sÍ'>ñ 2™º¢áïÿþï“&&]VioÂãÿxâ ¼=~•»?éÓO?D1ÿ%Š ôÈ#ôŽ>úÈó¨W¿ÿnoþÄw¿íÓkoýôyë§×žÿê#O}ò©—ìÞýµ¯|õö¯Ýþ‚/<õ”'zÊ©p;öøc©>)þÖôÉZÌüÃ?üÃo~ó›,ò­1‡Å']ðc^c ¿ ‡7¿ùÍäËPØŠßwÜ¡ç?þã?¦”¥T(¹[YÝH,ÒDÚôø—P–£?óÐ÷¿ÿýä¿ímoS>þ L~úÓŸ&“®'“Ð…47‘QUZZÁí>!æ„.½ôÒo¼‘é$^‘™!™”~øá¾ú‘GÉ ØuÕÁoüÍïÞýñµÝKdz^üàW\ðŠ?»ùϾúå¯ÞtóM·}ñ‹ŒÙ§ŸöôÇ<ú1G>üHªÏÿŒ#MCˆÖ¸=±fEäþo»í¶n¸ÙŠMR¸¯™ÎÔ"ÌûÝßý]<þ𠥫@ƒd²9÷Sh ÌÚk|"1o døÿìg?û÷ÿ÷¸â«¯¾šžb•ƒ»³é ̳>CΧ>õ)C{«k‰‡>ô¡¸GÁ&¬Š0¬Àÿç>÷9úÉ}ïÞ{Ê)§{̱;òa}ÈC7)þñ“æ¸wÐNœFÛÇ;ÞO°F‘xðƒl HÓL"FxÿäOþÄ0ÿWõW–f!ˆG Ð@i#±` €7zäK_ú’ä⊭ƒ”À-S„ûÅG½ûÝï&“®'‡*Eäª2ª!`ã!yˆÃÔpÏ –˜*â6ɧÔc >ä<òøGžðØN>û»þ÷ÇþÏÚÙ¯¸+„‡=ø°ÇmaÉQGù øàÃ=ôÐ<ðÔš þïÿû?`ð{àÈ(ø­ßú-fLçœsÎ »þ{¿ûÝÏš %/¾øbš†‡7“2±²4~ƒRžˆA ½ÕÄ"-áŸûû[ªŸ¢ÖøÃ<ÜgYRñ?í÷w§RBTm¬ÒÒ„=èA*\=AòW¿úU-"m!‰Rh2zСw¿ç½O>ë»®X»ðе×_±öÚ÷¯]ôÞïºè=½ò=½æ=]øžƒ^ýžƒ^òŽƒ;ô°ûÜï>TŸÿ œòw¯ámÁ0‘ ƒn¸ð^Vý>÷¹½õ­o5Ìß~ûí–Æù ôV7‹´¡=‚3Ï„²¦M>RòyRÉŠÑ5iækû·ËÊq ÃÁ×òU|~–Æ×ýÀü€º àÉc eRÊ@(k=ì!;îÇœö¢ÿþ‚‹zÎ몣J<ôEóúƒž{Ñ=òÈ>òÑdøP}Rügþ\—w»ÛÝþ‡ûñÐJ÷;,ÀB¨+IIã@9ä•2ƹà4°'럜Y[#ðc¼‹Ê{ÞóžV7›ÛÄ †§=íi H0éÿ†‡ûÞ÷¾¥péO>õÉgŸuöÏ`Ѩú %žqæ™ÏÜñÌÇœî/3Áÿ÷}ß÷Ýõ®wýžÁé9q; óÄ„Øoý=ÐÜå.w1¿ÿû¿ŸŠVúƒ?øƒ(OÉÀäLúÞ÷¾·•By÷»ßÝêFbs[üï÷~/h´”% ü!s b~rTÔˆˆ¡aŽÀJTãpš¹äýPGì“âÅÊš€yD['X â—åPÊc(-‡4 Üé,gT–ùº£(#sX€¾f’‹llŽŠf‚‡™àŸ8 ¨³Ó£ý ¾ÝZªY7k¯b¥¬øñeL"±)-¶YE!|1øÂð‡3iø¤ø'J‰_X`ÓX`RüÛjL$›ÀÿMЉф©-0)þY´Œ_X`ÓX`Rüïçœ÷ísX`sX` üï}ïÞÔöê ½÷òúØsùŸi,Ù*lÒ7›LŠÿ½ûøí¼ç²=»ß²{Ï¥ƒó¥»Óp¦2òíì9(MéîK|*žíô%‡È LaIñ¿_¿Ò».Ùµë ».¼øÂ]ï"ÆP¿¬&H¡¢OÃDðæ Á _|4|¨ŸÝoØ-žœSþ¥»92úL1 š°Ã˜ÿrïv¥7Þ|ãßæ}ˆ;o¹õÆC`7ïÛp潤/ÝM>³h>ú;M4U>u)Mh¿xƒ>ßøæ7 áýB©½ïÛËŠk>u ô‰RܪñU‹Aκ¬*‡Ò„„ê6ç°@»¦Áÿ à‡óÕW¥7 ®»á:€zݵ×]xÑ… ®ïJ îܪg ~Ýõ×Ìó_u>—:DyþçßöåÛ@þ5×^ÒäC gÆË…¯ªY%Îsqn¼d,$ü; #h±À¤øOÑ‹‹ä¯ùk@)q×¹çœ{þyçï|éÎo|ãÜ€ô-_º…¢äÉ+$l.¯þðÕàŸ"ÐÎ%?Æ·€çy;Óè¸øÂìD ™ýØGÏ=ï\ݸ;0‚à¼ë-»n»=dí¿r?˜·Køs³ðF:,ÐbIñOlŸ†€;ßùMx'ð™ }óÎsŸ.p½ãëwpƒ“°ž¯þàÕ$¸0 ð¹/=÷ÀUÈ!@bøÔw .Ô¨VÄB\2@RÅKwkиòÀüÜ#ÈçâÝ—ífA¦×0ÒaQ˜ÿÀCi0Øpø 3XUD„ÛÿÐÞxÓøgÜrBéU„öó/J#…ÂwYðá%üŸ·3ÅKoØ[Æ,™p# g¸qÃèÛ³oŠi¬vœ³ƒ‘¥KðþKSp¥I‡×3ÒX ë»° ˜ÿf4%'˜÷Ü|Ëw¾ý zA)˜Ç½ƒLP†ÿs_t.9 <ï¿b?Õ,Tá²óE;aHÄœ ÿ„@$RTSÝAÈGÒ“Ä*@bØ%#NøÏôŒË°@£&Å?Þ~Ï[Òj¿Žë>u19ŽHƒgÀÌ¡4˜Éd*øÁùÏ r@5&©Ê`D0>úár_`ΫAgáŸðFw™4¡àÜûÒ3ø0}𗌻4_®–¡¼ž‘V…2;LŠÿÌ€)¶'þÿv5½"0·Ü”<³|;>(e>[ûó^ÍôV‘ 4ihìÛ‹Ûǽo.ù1|ðáuü_Íg “¨ÂР”¹6ƒBà J5³€õËË÷(‚ÊôT«9G~€-n“IñŸBkœÿàŒ³MËKÓAZ—–(3,oâ¥O{æi¤Ámš8SýUç×|.¨VGa¥…ÓŠb;‘ˆœ ìRµ¼†‘ ´X`üþÁ¡|P'à¥ÕÙS€‹/ÄíCÈqæ¸zpK ƒ?'°Ix®ž ŸtY­ö§ZE‘dÕ犭ÔH¢«Z¦^$Âí˜ÿ)´æ¡­; «œ³|O£tóEx†È'4Òã-ÆÂ†uKn‘ènIñߨh+ŸB Ò".ÉïÞà˜Â“â ~ÈP]qKŠÛ5ø‡ï§-ì­é -0)þ7dÝX! LŠÿjZ Õ°À†˜ÿA ȇÜã“O=™ílþœß¼Ý6 ôÊßå`6¤ím7ÜÈ&„ùy­€'Œµ^5?”Ùâ`?OrÙÞ–Îó;ÄÿöÛØó¹Å Íï•nûÒm<ÀZØ!Ö«æ‡2[Ü ?mKûúâÎ[ÜàÑü^Y䯃ŸÍÏ „ùhßøF¯šÊlq àüüÛâæ÷Ê5øo¯þÎû\ÝYzÕüPf‹[ܧşj}æŽÛï°µ y¥oùïG\¿š¿þ/W௖@ï˜[šaÕ¯ö‡6[ÛÉá)¼ç>÷s5¸¶¶½£õý²@ þ[+ðWçµmkG~Ä¡‡ÊÞ~ÞðJƒbVg†X¬ÿ÷«ÿ·º6‚7ç;$:³#BéÓÎ8 –ïi¦OßzËV·x´¿OHH¾õ¾UÎuþIóM¾v¾í'mW)_x࣠ìÚ~ÂvÒlicŒøºíi ¥>µ>tÙêHÀ¾éF€]n?q;hçÃ$”ÃG~ÈáKAÄHœÉäp§1ÌaäåÍ72@¶ºÅ£ý}²Xå;?¸ôÚêœâÿ£Ž`ð‰*rÖñà ÿW%ü3A=sb$«ëù4¤‘usÄ?}êþ-¯ Э·=ãÏÙ}ýuòÿ¼ Æw2üóv€ðüqÇÿt§¨8kDly“‡zd„IóúþÿUš% >Zȧïuß{©ˆŸ=áŽð_Ñðñ^ Í>jÑø„h”_K¹)âŸõ~¨"X&ˆ^›ÀÏÿ¯4Ÿ.$ò' È 'ŸtrúÈóûöóqZð/>þþ&¼ÛEN¸~ð\çÃuaó°@,@ðSƒóÚëx ,¡º:æ‘Fí?mMÂ`¨§ãSs?tË›‡úc9À8móÏ>]ñG\Úš„ÖaÏ?yá0ïóµ×„ÍÃý±€âü¹Ã^êºËô§í¡IX ùÀù;×ð 繟«)FØ<,Ð Ô3ßy‡=áÿûÓ塉³€ÅÿÉÿâÿ9¦?ñ¿³~$—mþ— 9΋«< [v‹C~X`ÝüO%ð¯!P„êYÀlӉ׮¿që²#X¶9ä¶ô€Ìq÷pº¢<Ì Ö 7²wŽDËnqÈ Y€­;lã×fd«‰Ùžç ÎGÄ¡oãò•*žaMÑvv;ì¿bÿ«\øª g5‚ŽÔñ».Þ…2ì â±ÿ~LæV×ÚÂW¶,=~büZãSŽ/=(f¾Ò÷§ö^¾w:ü×[q¶­ñžä6µ=<}5VëÌ/—¹Õ­5Ù¶ÆèžX«ñkO9±Qa øIøß× ÿkk|ÕŠƒÿLÊæ¾ù#Ôñ¸–Ÿ€ 1”2ÐøÔÃþ÷î'îâ’¯c‘F:—ÖZòù""—l«S¦˜³íêÊáãM ÷íå+Cé+‹l Ú–D¨®Èø²w(JS€·¶fúΙ&ÔâÖcµø~#:¸â¾zˆ­Ï3Ò+a®þ¿‚(_;‡Ä`älìˆà¦sÈ! 1 îÜKBh¨|ÿÓ.Id?ùˆ&ŒÓ„ÿ}9þ·î\`šŒ#‚ýBʤz•Õ4>|ŒÅˆsM\-h¤-Ìw_’öÝù6zþÆ-+dùÿýûöOÿ¤øÿÞýò¨`?©æ½äð÷í%†gŒ0"(Å™“††KêÚei´ÿ_q€Q —Þèÿ¤«>±›3qH>ùi'+¬‚†aèo¹&Ôªlâ¶m­G Ÿ»w2|ÿÉD«üÃÿ¡®ñÿÀ`ÃyÚÓNK“âá¾”ï_j ú²ÄéJþŸ{a—Cþÿ uücâÎÕù|\+gâð>†xzüSkH_ëŒÓÒì{mûE};sm üç_µkü?hÄEOçÿ¯þp]¨Ý0!T®ÓÜ vØ‹¹Ò”«#e—¥åjæÕðCÏBS"Û¶çn9q`»Áÿ¯­™†ŒMÓ€Êï#-5±Z|­TA‰4ŨÂ9ãÃ¥Q¢U=õ(IéøõÑýÿzïWó€$ƒÿÌ¡õL.A‡9$ií±Ú{ÃÙuÉ.V ÉÌ(mYÒöRòP˜Š¬:Bþ¿s'ƒ‘èâÿaʲ<¨ÂÓc)=Ÿ’´j§ ü! ü3:JJص¶o·Òs^=D«þGv^t¶@Çøù<œ®é‰Ò0þqò Ÿ»€b$ðK¯õu”<{bÔàê9˜G0 Èá9—(Óàªv]vnh0 4X £ÿÇÚu;TÒêPÊ6ÃíÕÉu” Ý¶åˆ[à_vˆó,Ð%þOsÞêÈ…mÛ±Àí@+B£¶ %ñÜ>œÄp(þ¹²Úu_œØ(Dl^ tñÿD>@—¨ð+°·Í0ão›Á´8|˜pØlZó_‚¢a¹£Ær6oÏDËaîñÿ"´ aùX ‹ÿŸFÁ5,°8 t‰ÿ§eH ÌÇáÿçc×àºèÿo[cŠÊ,˜CϹ&m¶mbñg}tR.s¦/u+sZT°6¶ÐDÑR,ÐÑÿ³¶¯uN”×êåd­ÞĪÑdÕE݈öqµnã¢T9cY Kü¯¥{/œhÑRž¼ÜØÃx¡ˆ¥N­—ú@†1< f-b»§è’§ÔeñSBåeiô¾zbèÛ8¬°ÄÅy‰èâÿkGç´7T ²= GnÜ6 ac0ÿõLþ«¯Z)JÕ+W¿.s[ýUC†€žáßv†Ùr#ª46ŠüÌnhå÷e—⣵bY¶ZÚe^ƒèQ Q¶`v”‡]Ì/y¹—îä\®›¹¬‹aÞ“ß¼ý?MÆJ¾±Øjú=BM›mè‚Ä¿zÌêñ_?ž^:4Fß`7нÄáËÆ¢ îHw’¡É’nãã?ëbª÷ç7ïøŸ–ÒÑt±šŒ£ófÄ)œË%’ ”x%äÇHÛþ™’žñUcøG ’$ý¿<·ÇäZºº€Ê¿¶©PlÀµywô:þ³­Jƒ>j#Lh”"%Ì’¸­þDX6à3JáÒn™Äì²´$šÐ ñ§´dhÆQ+2ü¿? A .³çróöÿ´»ág²Gn8.nX 3ÈÁ_¥ËÁÇ‚¼=ý>ë>Kˆ²‘¦Qq¦û€ ‡ÆõÃj2Q‰ œ]£¶ªç°ÒlQ<¡€ô:«| iTÄ"Q®F~#“˜]‡ª$ÓU³]Ì(ÏOè•‚±‚áºnÕ(ÎðŸø\²‹s> Afµ}¹çyÇÿËmÝâ¥Óûà'Éí¶UiV|c?4#qVRàÿg¥êJð‘çLªvÛª4+>‹1Úêâñÿbº 'Rð' ì9wÙª4+>‹1Ëêâ?üÿbRúi®ñÿðÞžqüÀ†4 IfRLâ8X:³… PS<¥5§f²iK eεÐ4]ÕZ L˜Ìj¶ØÅ«K™8÷Çý?Õr%-6é¼Ñ7|ÚñºÒÂ`åøi5Cc½…ÀX«.äHå۹̡hÒZŒ8ÌBE¤#Žb8 Hë9¤ã· ,Ð%þø^oö\(HlX0™û'ãT´…Dò½+¼±ì© A¯VTX7#“*Â?Pä^ॗ9”NWKl}sÔr‡˜W#Ò+d.þ¿qoƒáÄ6ù€À„™K_U±œƒm¼nºT û¨§!À¥–D ÿðÁ#ŽQ RæL]K=ˆ2ZçÒ†ªÖ½EçU·@—ø¿ÿæ'yÎbñ9æ2ü“€A/·¼7#þ!Ÿ”Ôb,pB ¨LÎòÿfy™b’Áø"ßr¦«%Î)ø|V.ݘ.߃bÌGúü4ßl‰1-ÐÅÿ׎ÝI2l[‚ÂügX‚’g®9“ó'?ÏIÇUØanY¡D§H‚+9ÓÕ‚~›Ëø&pÊdy¹‘^- t‰ÿi)03oŒ7Ø[á°öÏ­{l Ô³xÆ+0Àž³Í¯eXóÿˆS²ð/sDÀy¢Zð¡]>Ωgå;Æ” ㉵@ÿO“ÁÅ'ƒ@@k°·„ÌÒ¸e…"ü*a‡mæ!ò‡ØŒ K+aH&>Š:ÿ—9Vw¢ZŒhn1õíæÊÉÛW˼ÈBU¯žñÄŠZ Kü?§&ƒUÖytÄbûœŒleŽþ?ÌXi tŒÿWºí¡|X ü``+[`ñÿð¡)¬­é톙D3œ7$[9‚l1aCý'¥ßá¬z¨Øü?3Y[Ã,×s6¶íì¾ÿ³±¬¾RL´âÚC˜É®=TlÞñ?—çÝ#°dê·i ³ÞT|dž±ÃV Ë›°au(£çYË’¬Ø“ïý?‚xVE&Ezú JI‡’…ÍTTýÐGwQ†·¡¶Ö2SL ¤YEîMpfYÎiAµúeÚ“µôÔã¥é%hlâW•ÉiäC>Òጩ©[šPIˆÉ #Ïóöÿ{$lk£ƒNG99¥= úU;P ¤ŒêÃ>*)éÁRÝ×™Ç?¨W KÊFük¤˜t°´¶•f(fÓ³3_‘‘¥M {\H½LCF:DÈg¤È,ä°lx҆~iNu£Oª 3“˜]–æ…š` ZW?^f¨fª`HÚÈá‹h¾˜‚’¶ ÿÍ;þoÄê¬êGw{Ãï’ét8•ÃIOŽm.¢–Ç?FF!¶%e#þ3étb»¶ÖSƒAÎ}Ep«|†ªpÎ4„ oOж£6؃? ®Q||ÓÛ=é¼9Ã6É(Í ¬ÄmKÀn`èìƒÎzhΘŨa¦£:š˜b‚`¾øÖFÉMùýŸdL÷”ä…ñø]t“5ý¨Ñg]38€ÏÆ>òÌ ÿvG  Üš˜Wþs‰Ó"ô¡:ÂHEâàuhäã¥ÃÙèËæ$¹^âðecQ¥;iÉÐdÁi"ü²dÒp¿yÇÿ4…>¥7Õ&|š·4·O>4Pâ(”IãT½¤Ç;Õ0«>Bg‰’³Ü> øÌ—”ÔAWUü—ÒÛµ5Y(fh§½ _QÀ6b.R©!9ÔM­Ž­k¾©yû´ ¸>Ô³Ù¥øn@Ši Ã?n“La;£‡®)U/¾ÿ%˜äK7J‚ Å´äp›F+Éÿ—Ò‡`\h ûi‰Ó`ªX/¡'£›‘¨qWjˆ>Öjh €ÿ:«| !â‚9Gf“ã™IÌ.áCŽø¨;°­ 4MwͱÎâÿ9j?-ëã'£Àžs—­³â3­Ù&«ç£Éj.zkúÿ8DõÚãæ³Lë8´h3§¦2H™F11ä@¢-ìHœæwJk–ô©žŸ’YæŒS‹êÌÚ˜Ïê)°ªèl÷š¬©b—î9Gzñèâÿ™ÓÙb7»9)ºÒêÁ`Ù@šP$²ØBt­%.d¦F™³a- 7Èïà¿-x®/¢f‚ãr,Ð%þÿ€Á·2[ŠdQ ç,[½øU`9Ö›e|ˆ•LPÜwhMPÓhNº)u„ CÌ›%Ò½µ@ÿO£ð½ DH'`#µ”eê«À¹ÿòäÞǶl°aˆEøkR‘CøÔºŠÁ("@©ÖËéŒ÷n©•Æuµõ(ùöêj”Mƒ-øû7åSóã·:èÿÓP=¦<Ѱ¨; Šø'l¦”»€Âï?á€A/À~` þä“@ü  $*“³†ƒY@ÂÇB&ò-gÌZ(ÉàbÐq¦nÙ4˜£$ùÌG8Lt$VË ”ÛwÇý?ŠKàf‰ B¤„_«òä€Êð_ß5š6ØÀ“ƒŠš_ÃMΟj1FÒ1Ï/Á¨—Mó9ŒÅH«Õõ¡-èÿãºeCÀ ‡‚„*lиH4Ón°§¦øXîŠL4$š³ùÄ)3…=¾dœÙT éeÓêYyEJÛéV++d.þ ³tû¬Ö“Ä™n°á~ͤ6è,ÇðO\„&:)”9ãÔ‚F“tDÛ˜RÓƒdb4F4 dÑ|¯žñÄJX {üߨLÜfÉŒ~ \óÎ ºq 6aôï»Çÿ¥g‹ÿ’ä„fb.ñ‹ÿãDQ,0'ÿߟ†&a Ì)þo‘EaþX üú"4Y¼æÿ/¾!!1,0…ÂÿOa´¨²i,ñÿ¦éÊhÈÿ?…Ѣʦ±@Äÿ›¦+£!SX üÿF‹*›Æÿoš®Œ†LaðÿS-ªl Dü¿iº22…ÂÿOa´¨²i,Ð=þgs¾½äèÍ¢7P|ŽO·”ò† ï•xâÆ4oò²sÛÞ½¥/§èå^{i¬¢Ì1ù·pX¹¢kû¶lÁ]»Ýý?o¿‚ÃüÀöÚÕZ:&>“ÐÁ ˜t"/jÑ€•|·fé1ùgµVø²ÕÚ¾][ÿã°qÅÙxE·ñŸvéUÁ¬T/ÂG~»ŸÜeäÛÅ3ÿœ ó¾Ëêä@IõtŸÚ–¾j…,ú:õ/–/oÞ^+³gfíRJýÖêàÓF^î¦Owôÿà.^=ÜìU}HWÜÔ¿\‚@^–O¯ÃÛû"·ø—RF?’Cõ©7{9Wd:3éPŸC×9• pËØÔ ¨Ô#¨Ðñÿ uÅ¿*ËØšDðÆ×!¸„¹îDäðÚfÉAšÔ£¾ào 1/à—•ÈܸÖp[¼µKÖûnðÕ&“»ã}Cášäôj£9„ûO…€ÃäÀ])ôÀ‡Z8¸¤3ü7pÿüTN¾V£úC§ƒÆ…ð ÿ§ê‡[–3/u0p.Hgß&ÊØšD‚mØ2¬¨E‹Ê(@(­È98MÊRcè›O¦×¿±VÖoí’Þ3§Êû©©±)]ü?ÀI‚|¢‘!¯ëî-\ât)Àhü"lÞÀ¡ ÿèÃÀáÜÐSîŸ^ùñ•ðÒöFJü+†bîØ®çø7^´"ãà5)K¡o>™íµÊ¶døÏtðÌ· þ»ÄÿxTÅ·tJ}¶>þ§]æÏëøÇ•&&ÃÿðË÷¯ø ØJðéãŸäf\9”42¼17Ï_øoÔÁb$P¡ø‡a.Vp€sÆÖ‹E“t/ËþWñÏμ&´1ão 륊jàÙ^«l |¦ûj¦À&Ntñÿ ÚÇ^Af#þ­–çÐ(È(¥Œ‡«IôLÀ$.Ýë /ÃiXYÛÍ&ž¡e6Tw-­51ñ‘h²@Gÿ_Æ?t –÷¢¬¿È,KÒ“ÑÝúâÁÐÆ¿¹¾ÔÑ'%ü’;Äy σ‡¼äÕñ‘Œâá9´‚”ñpúnÕ(ü'b×öu¹Mm÷M¨‡ûtX­‰‰D“fÿ$b!á–îCæz'V0ËJM)#3Ì+Ô76ÜŒ˜Lut‹\OlÜpø Þƒê ´Ž“AÚ•Zðß"È”ñªšDÔ°˜à¤1þÉÚî5/ÛŽ&6B>yz‰ÿX”‰™ûDà—¸‰sè;9¾SÊRSÉȨN·rØ$ÑhÈmŠö›Ý(¹žØX‘ðÕá’pä§9l«ÿ‡r” ŠÌ뚪dê‡É&Ãßœj,1dYÛ½æÆÐgfÕ}‘4a˜ÇüwÐ ;Æÿ #k„<8GDö¢-ÐÑÿ/ZÝU–øïaïuŒÿ{Ø¢Þªøïaׄÿïa§„J ³À"âÿméû«L-9˜ýãÇ¡i7IØáƒDM0íù—¦½d2ö3&£Šx2¥Ç²L`Y·Q­QÄ”fER&“—}°Àüzè_}áœöÈtnßç3¼d:•k¬%òÈ¿ž×k†|E¼zÒä™·ÁÇ4‡³šÀbùtL> qð#½t Ì;þŒµ$äT Ç9skÐ%Ky€â´0> Ì–øÌñ«Q 0g_j ½+fD°èYÏ3i¸!Ÿl€Çß%[`ÞþŸæ+挄1 g¾³„d­]2 E ‡Lí&Ç^õhb²éŸ‚v1Ô… ÒƒFœ™,å3BM6eȈÛù <í2†‘è‰æÿ/«™Þí/K ÉõÃy¹š„ôÌ ðÿ™ÄÅ\–pãXŒ¬ ¥p£aþ»!Y,Þ ˆÿߨÓ›ÕÿÙü ÛâX@üÏœ—™/‡-.Åæ~ŲV`ÛÓRÿX*Û·ãõl)ÒÔ>5Ð=ÂPݬVƒ^F¤nyûB_[÷f¸ðö­ Ÿ,‡®_³0{ÙkøgÊ 5X,yÊ–"È2b«ØX âåÚÁÔ‹˜wüþ³uKv&€íüaô±l˜ÎV? ¨5I† P„LÓF#ú„Ïí‚à ÿÞ9ÿhL¤vndèŸÍeôq¹x ÌÛÿÓ"°z…d[™ç©aÃ(üëA¥T„ø·B8U’ ðlÝ^vo %;üú'²Aªâñ߸oAd-Eè†z4 Á«*œkÅF ³O ˆÿi&›Ç@xH.q$§A1Âÿã$)å. Ø ŒYŒð&—!Í(“f;‚Œ¬;þÃ-ÇÁµÈoÄ?~ÀB«‰eY­½—ïcsÕAîºÄòçƒø‡H ÊsUÅ$ Êð¯È áÐeGwF&ÿ¤Û$[zJsÑnp–ßȉ3ÑÒóŽÿmXf0<ÿ\™âŸõ0fðáܦpH¢Ä?ãÅܾ1ßÐŒŒ)ö'öø‡›F™D$²1¶¡¿RÅ’ÿo­å=€×$ÒK±˜«ÿ'ò‘¿ZšhþK ÏtZMp P—ÿ~¨„/mÄ?ô@ŽlfÝbÀõq7LäñOÉD[zĉFÑ4Šÿ‘e“Œ!UÐ96 wÂ2¯ÿ7¶$ÿ¥3Ïd|ùñÌùÃÐn1ãÍ,0oÿßÒ„ãŸÛ 7Ž}PÄ B7ÁÈ ãX`Þñ‹ Æ‹&Q´e-°Dÿ¿em ï–ÿ÷ǡɖµ@øÿ-ÛõÑp,°Äø?ìXºÂÿ/½ B%Z âÿ%?D/Ýáÿ—Þ¡À-ñÿ¢—nðÿKï‚P`‰ˆø‰ÆÑK·@øÿ¥wA(°D Dü¿Dã‡è¥[ üÿÒ» X¢:ÆÿöOÉi¯%ò¶ËÛ²r¢í}ùY½ÀC¼ä߉ˆY©×ÃêèÿÿÓ÷é¶ô¯¬:¯'Xzêà«ëÕˆ.îRw]™^¦:Æÿøç¥?½¨ý°sà•vuwVê­Â+ZÐЉzIdÌŠñ*%Ó{ôÕçLŸ_ƒ¿ðŠñÒ/`¢ô‚œg¯%R }x7“³ÞÇ¥IÉè1÷x™ºP…Æ’/ã4VÉZg3æR€3Ýao•B–‰Ð£é<øçhÆ¡l»Šze]4Ï:kœæ{¶þEQkÔ‚ý?=È«»:0>ñ ¢´Â^lÇzã|½'5¼B/*©ƒÆ¬H'Ößö©ª£€a‰Á;â£ÕéGèE¨ÀQj›Ô¨~¾ø!™>-RjúVSÐX{MÎâVꓵn ]ú¿“™Ñ:{?Q‹ ¨EvtGQÊJUª_&T ÷uUSgIú¨æglᠾХœgÿóŽaö}¬G¿¨ue©o5þ äÓ;äY‘~?`–ñaŸb\à=8ë-`†*d-úøZtºùœv)¢/™{8æ†*í3s• PÔŽë…4S;a{)˘g&õj«.”-5²ù#ÚbrŸèèÿËø«úù-Âzæ©ÊRk2FS˜> ÿãTL¶Õÿrš!PÃ+Pâ?ÓÖôñnø÷ú´Œ2@ÆÜk2 ÿY•¬u¦^ÙLŠÚñoÊ#‚áßÒ™P¯¶ê6v–¯QÍÏØZ[–˜˜yüë ’+Æn4Í[¯,µ¶ãÀq)\’(ñßRQ²¨H­KW à [jYÀÀ]IñA¨QJNßj 6ïa–úd­3s• P”ã¿IdÂp)˘gBM=«ÛØY6?cÛ‡øgæþáXè&›\zë•¥äèGwPeŠÏþ Xrèö7ürè&.½þ)Í´•2ª•špÉ.Îâìù@PJÉèKæØR%…â÷H2«ÊzeëLÃLò©eY£á¿TÏ8gB½z6v•uVÒÙ™«äŸ±íÃü·cüoÛ| ßéã´nRúqx®ÍŠ6¿£ÿ_¡šTÕI;tRúIõé9ýŠ6¿cüßóNé¢Þ¤:)}ÝzXwE›þ¿‡X •fUŒÿ'u5“Ò/Ìøã*¶mi¬22Á§Ö†4ø=X±ÀÁ”6›5kb+;ð4G¢m½·ÌåDµÐ´Laß„dI4ÇÂ6’­¨ÿg±h|”n†ñYÍ–rLÅ€¨V†‘N•tÞ¨ùíœAWZѪà ø!šƢOðµtF&h´"%Êò'­Åˆ{TDº6 Ð(†9Ù“qIœßy~ñÿúêÜ`㳫,îasÀ1&ë`j ½æ÷‡Vå|X„ÇYùÎmä7¤ÃÇ•­Û#(’ÏÉ$f—â#]&äT«¦ZŸldˆ’(ßksˆig1ñ 1sI"ô´bp•þZ-Þ¤£šœsÞ–þ#|ÐMʃCÐko'“*Â?PÄ«{ée¥tÓµÄÖ7GØ §qˆy5f•ž“ÿ·±ŒžÐ6áu˜Z`s‚ù(1»ßɃÓcŘ|l«.#ßeŇîHø7£OF«2i5È)%f Ð Éõ‰ªÓSd– ‘Åc ¡ ¡¡¾ˆæûÙ((1ç_G°]ªê’³5G eÒQM.9c4”¡–ºƒÓu­£Šá¸bK'j€”9¨4]-µ¹u§»G*Ú£bMž_bNñ?¸µp‘Öe›p°¤œ'm—ÙÕ@,fÈ~ ÑÒ5Àž!@f²sõ“£ÅÇK‡35DOVÀ n©hXbv zŸ®çÀ K+ÆmKÀn`è|"ü^#Ô0·Fu41ÅÁœ_;þá¨&—œ­ÍjÝÄXàHÝtÎeröý‚4$Å$—âs¦«•Ú¦àg°kæØ…étÌû º°áÌÿÿ—ïÿF Ý»½IScÝN„êòNôš8lFññÒ¡1zºUNÞþs‰Ã ¨/û¡ H@+òJ†&‹Ò‰ð?ªÇkÇî0– pT“Ë&Ãë`RÈɼä`^Mui c\m4ÉP¢Œ]ª.9ÓÕ¢:Þ†ºœÅÓ7G—Éòrg˜žSü¯¦IOìÞ|g Øë­샕ƒ%äè¶NÝÔmÉÿz×YU£ä£N¡Vúm[Ç?žJN"±­¦ZQ-1S€V˜ÛG¨¸ÑeâOiÉp]·&üç;d7¦FArÅÅ’žhh",AѨ&—œ¡ÔÍ—‡ J÷P¦Wƒü')æÿÍ ÈJÓmir*ËÑ%ç‰jÁGÀ°êõ¬¼ºöãÂ摘“ÿGU¬A+8Ôw¾³0£ü ·,O¤{kåÄTE8'G³E5\éuV#ø@CÄsŽ,Ì&Gpþaè%f—ð!G|„\¢¼"°QЛ1\×­ ÿ6Îù@.™MÔ^jÑ|ŒhM„% áרdò³&ƒtˆSêŸA²þkHÆ É>œi2ÅeŽÕ¨¨à#p¦½ Å„}¼zƉ9ÅÿíªÒL“&ÓÞÒþíÕ­tV|Œá\\ç*kCæ` Ç»!ýf%˜Ÿÿo±˜Ä @…, =þQŒR£$á‰Ê3œ§µ_΂Pjו ¶ºÜMô”¢ CR (ù™©ÚHCu¤s¨™-ÒÑ-4™,ÓyE=‰ÿ‰Née,Ï¡^–›" JAŽP N@ ™ýüŒL¤xHƒRarü›†0L£¸¿´`3 8 rIÁÏ`K œë´”¸‘èùˆy¦*™ë4M[k¥[¤$ž4âìÍ"âU<Ó¡4dæû&2½,§JþùÀüÛÔOlKú‰Äq»ÿ724±[€Ç?ùõ„±i· Õ=±q#¤}´C|4"?G(U#À°WU”’EK™¹Ô9ÅÖ“â0¯—¢´§QN)«¬Õÿœ>Äÿ8Rõ2‰ÿ€ãËísgǤ%ýÌíl¨©ë¿FHTJ$ƒL"÷ÄÒŸüœ Ð.2žõks4À' |3 á­äSªZÒ´XØ–áÖ¤K¨™Út a4¥,O¶Šiúhéþ«¢]߈¬Šû‚€C8)égny ÌR…ëÞëzH›PÃ,Õꊊ<1Q ÜtÔ{?ª Bä€L!–æç[b\l¯-1%ŸRÕ’†„dÑ(ñAC\—NŽ&jBFSÊÙêž{ÿ¯®Có•¶@üÿJ0”_i ô!þ_i†ò+mðÿ+Ý}¡|G ¬büÏ ·)nÏ)ê–U˜†kz¨åY´âŠq0ÍèYàÒž9&E,ò°æ%™,rÖÄÅ–¡¬d̯Y¢áÐzf#f¸š¼ãܨ´ZU8ÛÆfÄ~{R#M¶ù§”NN©afhúü[Qÿ‘'¶ªûgX×mªÀ‚•¦BÖpt øÁ¶¯¶°Ðhˆ„Ör)–"¦–ß_TÖ‚ `{Î%Ÿºo}V«jž¸®^=zËdy²$¢ióO]Ý‘6j˜™Å‘÷1Ù‡ø$àHézζLÍR›|©Ü£¼«ñH N$èGÜ/g¼{äélqÀSáý!眕zþãôŽV”¦ž•Z‰ À´E©d(kAºŒ­OŸô¨kðÈ ³ømÐØ“ÄL–±2ìÃMAùhŸRz©a‹YLD¯}ðÿ˜db^,CïÓ˜¾ã’L9LѺÞìV\ÑeT¡×8Jø4[œ/K=ë –Ä„1Œ8€ž’kµ®Ý;–C†Q>ЙC£U™t‡á¿¬…’4±Ï(°X.㓚?x· ýŠkÒažÉ’FSnj”žµ«Å,âß·sâ k^{â¾M/s0 < ióÿVÑ:Ž.àVRrðø/K=ÿqú=“+&–Þ™“‚ŸÁîu>MÛoT ­ ä a²µVËU$“ñ…F™ŒfZ ɪr3:‚ÑÍxäìéZz¡á(³˜Ð¾%0ö_îþ=ÿݩe1Ã<—–¶™%þ3þ³RÏÊú¨Íÿ7íÌ~¼?+ø0$•K>&!XZÉöZŒ²F>©VSüC&¶µ¦‘ð²”_Ò(?ÍPÜX#SÒK ¹w›t,Œqèí¹'ñ?aŒ0@D¡øGn»LÍ}V-A†¸e awg~e©g%šösM_¡BVxìý$˜ä¸%YT#b<Nèü<&ËZ ¡Eº0Yò±†¨Æi‹UW¦—¥œ’†|¢)â(Vݤ—–fçÞž1BOü?ÈGà ¾…KߺKZÚdfø''ã@Ìa(§”•zVPŽó£÷¥¡âml÷N¶¶ÛoÔe,àH¥$a²¨EpEŠÿù(þ~Ž`†µ¦ ÉcóO)[ôA–M:2³˜¸~&zÿcÃ~Ú'´ÚÜÀ $Gtùô¡ênŸ)|ow¡Á!,€zÿ‡ÿ4.Å}ðÿKix `>Äÿ“vĤñÒ¤ô“ê35ý˜Š±ÈÊ ‡--N-±¥"ž%–8h«=ªÂ< ¾ÒLêk}‹ºeÎ8µXÖ"€kzÝìÉM††ƒiµ'˜UzEý¿­ûc‡1a6«ÙÒŒ£k8Rr¡Ÿ­Æ­^É,òH Èç±…á4ZE%Êœ ki¸AÖháŸ^V`Ì`¬WÒ2Á/çÿ³ ‡òZ£™¸-—¡5 ÄÂ,b:{Ž v¦ Þ†µ5{TDE=?Òîo±F>ð× n*=MºÔB"˧ˆÅÿ‰òø-I0G: á,&^13—ÁY¿´¡4ÈHÿ· ýeLP„õ’¹ªlµæY6Ó?—U™pVEØ‚v±‚?™Tþ¢‰“Ð2‡ü kCˆÑMPÓàÍÑÁìC¢qˆI.g¤Àyæë?6rÑæðTˆ&ðK¨Ã°Cü ”Ø ¤æTŽˆ{0ã û'äà©Ì,£ø`Ìd®73zãL«±9—™Äì’VH®÷?äP"³d¨fª` mäðE4ßÌFA‰yõKCé’]2MCtÊ®¶3¡ 9HÿÚnÍ”èzÈÂŒ¨G©:…. "‡ºé¨GCt +\1: T¤ÌA» kQW]l[}þ¨l|‹,Ž¡‹©ý³ùÍ)þ·öÄ{‚s¬dC8µ½òi˜TVUc°34ä?é:°g™¬Zý„Q|¼t8SCô¤a…ÙáÆ‘Š†%f—ð¡¯éhúHZÑMܶ솮™ˆP¯1f±†·ÕÑÄksûÁ&`ß´4(Fà?o¦Óª”…2ð'_BUÆGê¸Ñß8¢i)&8Tµœ1k¡$Ê ãLݲi0Çò䳯 ÈÍÜÿû¶þ „è6è¾äpœS»âÿè]Fxó†þ³€D•ð*ø`,O¨êaî<€àä…ÃAEI>ÜäüÉ¡Ë4ÕE4£ž®ô¡Ä”9“ÖBý^6Íç0F2Y^îÔé9ÅÿtŠ¡+Ñæë’ªÕ¸^×y°OF–|zM7kê¦ÜÂÿÿ »ÉPØ“ UØ q‘hªÿhq¿B2‰ÿtÝËÄžºãcSpà,Í™17ÖGÔnËœqj ±¤—M㮤 1mGs«5«Äœü?êa1tæÝ2üË«pëÁÎ4<ÝI«;ªb­ÖlQ•÷#½Îj üÿ/0€­Ò=zðZ%N˜Kü!݇A°4@]þœ$‚±¿§ ®e ™ZãBi ÿø%õgF ¥eŽUl© ÃÑ6‚Ô4©iMû‹ŒùLsŠÿÛu£É2 Ä¥µÛ«[鬸ù&Ö‡íŒÄ€vá&üÀ*€ÔÁ › Ïþ3™Ÿÿoi;Ž«¾—Åÿÿj1ÓFE³ÅÿFÒ6gùœâÿvc1èØsîâjfŧ]ÛY•öÜÿϪ™«Åg)þµLÚnb ,%þ_ {!™!ÖóÐÁk}eŽ5­¥Èh"±t „ÿÕLRXWaŠ-&,LÕ™°ku…Ì2ÇXµM$ú`¥Äÿeõ†wÕ²?¡²ÁäÜRªíÉèK†ÝsX”Ã9þÓ³˜á÷ÊËÚRd4‘èƒúâÿ«§À(ì1 ø·ÍBøR\1™R ’݆éSÎä?PÊÜ0e<<þyŠa+äZx)s¬zK‘ÑD¢èIükùZ|Æ,àŸ{ìJ½PÊS=+ÉèçdÉÀÿœ Û¶}ðÿϦ…TÊ6™†-EF‰¥X ñ?þœe½êhûmXlNÚóí2ÿOøñÖ*gö$ðö4TÑèÈ8ðˆ=Ò£¬Ôó³#Xí„|„ÿ–g^-EcÊ ²9Y þìLmlÿéÃ8ÅžÑØî¸äiÛ„T‘ey H&hä(9ðpʶ•¥ž¿™ÜÚî Ù!| ÿIÕRd²"± ô!þ{ WÍN8j€—íùñ4¤ ÿVW,|òB·’’ƒÇYêùÓ@ZÃ-ð?޹zKÓÿo06ügß;2ÌcIK[‚Ìÿ‡ ÿY©geÕâÿ€ìÊHÇàÃ8kÕ¹5y>£ŠŒ&K±@Oââb ,@¯ø'ÛóãñiiKP1Ã?Ü2Ðð'¹,õ¬D3æÙü¿qóT=¶iÄå‘õÇÿƒ|î6ÿÅrÉÁÄóº|Úgfø‡,ã@ÌaH“ËRÏŠÒñ†ª–ÎZhí@ã›qY”=‰ÿÏ/Ë!wËZ 'þ?ð¿e¸Ü†÷$þü/[Vzüÿ–5~4|éèCü¿t#„[Öáÿ·l×Gñ@âÿ舰À²,þY–¹}°@Äÿ}è…ÐaYÿ¿,ˇÜ>X âÿ>ôBè°, „ÿ_–åCn,ñz!tX–Âÿ/Ëò!·ˆø¿½:,Ëáÿ—eùÛ tÿ·¥¾ÌK¼lÅNÿÒ_÷Ö¥ýÌ—ÿ/ÛÃî¼QÂÛ+ö–Š%FIÙ`TÅÈßRèèÿyi üËb³¿x Ión;‚ Õ–ÕYŒªù[Ê]âÿõ]É|*Dxl½ È‹Ü8ìc>xu.%ÿQ®úŒ]:féu`ᘪ-á‰õú!w¢ôñàdÒÉáeIÄ¥w!Oƒ b4áEKò‘èy–Í2#g{[SUù˜t}Å^7×¶ÙËø^HÏÕ]ü?—¡US|ÌHð­ªÔ®êßxe—¾½†eª-aÄÈÏbH¦0H9Qöý‘Ñvé±}€(“ØÐG þ5¢M½ŒÒh*Õ„ôur>RŒœ.ÿ\Ìã<ºÄÿÿi pÕ\\ ÞCOa|õŸæôMP=ŸÐѧ«²Kß ë¨vî]ôéó#ƒHŒ£,¥S äà 9DœÆNõÃ{H—ͳ3ríÃ&|¼V yìà  =*" 0 à)éq^°ºø°žMa:H';ˆˆ(èn0ÐpßVÿ;i 2ÕÁU}9`:ügÒ­âæ†óÒ ÿ'mÈOÿä7kN;þ3>%þi)  Xs!˪˜ÐH,Ì]â”Äw™þpfð½Á+€ $·½øg—¾íããŸÁ˜€TTœ$\•ÒAt&±!þšSÅ?°EOÔó7 J‘Ædo`¯/Ô‘Hr·¥I=‰lá›éy[ ‹ÿG7à“𠜎ˆC¸¤gåÿ!à âÛ9ÈÑ%ÄêzJý¥5Ù¯*Óf #&¡;RPÃdÒÁ$4€püÃ6kœSC†¿V”©Ç¥ÝG¸Ý¨uˆ™æÎJc:ÔS:΋·@—øñÚöA¢Y}Ð'tèbŽþ¿‹è­ø_ÑŽkT»cüßÈssgþ7Sÿ†ÿßL½m™ÔãM9™ß1ŽZD¯Ï\!U[ EcZ ‹ÿ¯÷Xl¬VTZ$®¨hNK[¢h3Y KüÏÂ-þó €x³ €'‡ûËŒZ×â§VEÆ)äØ&r´6hKâ¶x¨•ÕŒ­Ç‚$µ`Hfc-$Q‰Øìß„•jˆI’5bSÉĪ[ ‹ÿgA›øGW>~‡X²ÿpÞjÊêYi  ÑèYHNkøÅÖŒ­_uëqTÔòœn0¡bR^ ò…†ÿl3‰‹Ä¦±@—ø¿ÿŠˆ žA À“ÑÒƒ¡Òî ŸáÀÁ¥§¢”riß8d½àë6ÔrÒ‘¥‡°<\ã^Ó¨†á¿ÔÙ$FbsX ‹ÿo‰’qÜ–ð)P‘­£ \AŽß„cx3üCœÛÙ±µ"Ï­²Z¾4ã†ÿLg‰Mc.ñ¿á oφo¹}rÀa‰Q’#üsk(7áXŒÄ}AñOûÆ!“èùK»ï@ãK3ü7ªø7ÃnúDÿqðŸ8m½çbæÂ ƒ"9y@á_R¶ > Ÿ³jÁ >â߸qÈÄyþe-_šá¿QÀ¿vÓ'ºÄÿ³5ŽGél9·°À( tôÿ£ØN‘øŸÂhQ¥£ºÄÿEgÕÿ™Aârèÿ_@cCDX ³@×ø¿ó÷ôà,œÖ/q¹ tôÿ,×è)Úúýã+øßVA9s t‰ÿËe©Ç¢¨?mwD™Ãî6Yÿ„’1ˆÿg©Ÿý9¶øIQ= ª÷ˆálLôøx榆[Ð]ü?8ÄÿgFcPhýœ|0ÌãÝ2§~W °}Õá?=üª>¢‡_ŒNA‚À„ÑÁ%¶¨B"~aîèÿ{üã·% M›"ßáÁÉo˜Ú…8¨9øy 3>äð,LQÉöuo{p tñÿ¸q¿íA»;þᣭ8|ܾÆl³]=Ñwaîèÿ#ˆ «¤…ÿ2Ú)s†âŸ+]ü3üQn`^;`’íêÞöàèâÿ±Ñ8ø$2œ„ýš™ÚDU~CwÆÍd°LÑØ¨È,0'ÿoá„ÿ“†þ žŸÀž!`C­DYîóiÄ?™YCâ2,0…æÿ¿Ü>z¦h§é»@Ü XM²»”CñOµYˆD5Ec£JX ³À‚ý?~›¡Á¡/ü”þõ áîÀa³ÍBŒb¤¬!q˜Âøÿ«?xõþ}ûâÕ£JX`¥-€ÿÿ{/ßø_é~ å§³€üÿÞ}ÿéìµVÛLB\q`÷¥»Ãÿ¯vG†öSYàà»Ìú>stream xí ˜Ue¹Çw:§<ÉÑ2óŽ‚¢ÈMÔ@ÑÁˆ¦ ˜6‘æhŠˆJêÁñMÞ)‰´èÁsÂ-ór´ÀŠ'(Qð9^¨¨¬¨<…eåù}ëÝûo¯µgØæÖìÿzö³æÛßz¿Ûoý¿ëúöš÷¿_‡ô¹ £uˆ@"P¡üs=¨è*Š]©þ*u >|ðàÁGlïÀ&M¨¡C‡n/Pþú!Câ°r÷lhãÈ#lMƒ â*6;¡Rý+u|à8ùä“'Ož|ft\{íµÑ·3¹zÊ)§`éŒ1bܸqgœqFlVÒ][[‹å±ÇëaåèñÆŽ{úé§—Ôþ\¥ ì<„vÑ?ù9ÿüó?R8êêêî¸ãŽ¿üå/ ,À]ðþÈ\€Ú=Ï£G>ï¼óü*ŽU«V}ò“Ÿ¼òÊ+¯¹æšï~÷»_|±_ýð‡?L‘=¬=›mû¹çž{Ùe—566Þu×]‹/þÚ×¾öÕ¯~EÝxã—_~ùôéÓ9昒† tè€þG èÏy@Æq>ƒxÍ©TÿŒC²ÇøñãÉW\qÅ /¼ðüã§?ýéÕW_íþ8&NœèÁé Î9ç¿:kÖ¬_üâþóŸÿú׿þéOúå/I]ð«XŽ3ÆÃÊѳ ì /¼ð‹_ü"ÊÿÒ—¾„ã _øÂÂ… -Zôå/ù+_ùÊ'>ñ êHÂÈ#kÆŸzɧÆÎ¾íøknÍgöm'¸cÎm£/Ÿ?jòY“F?Šîƒàí¢?ŠÚ|rKûO¶?ö±EW>tê©§zžG5eÊ¿ú¿Éñì³ÏRqp®_¿þå—_ö«ôƒ'œp‚‡•£3 |ö³Ÿ¥Q¢5³Dé Ÿþyî/ž7nüèG?Z23«W¯~ë­·šššìê‰'žøðÃÿîw¿ãþÒÑ— âžL Ï>ûìÙ³g3`Ø0mÚ´³Î:‹3ÃŒ‹.ºÈF°ÁA¨ §N˜qõ¨ÛžÙåÖçrw>—»ã¹\Êqû³o»îþ'N˜pìÈ©TÿL=²#™d›–üÒK/e$óÆoÀš‹ÉI'äÁÿÓX¸{î¹›ìqß}÷™–Œÿ=¬FàþûïG±Üôo‰^uÕU¯¿þúòåËøÃâO_ŸÍLCCƒÝÍÏ|æ3võ™gžyóÍ7QþÒ¥Ko½õÖl؇¥Üú믿þ±Ç{õÕWÿö·¿ýìg?{üñÇçÍ›‡?WQ{ÄÜ';éâë‡ßºîíÍërœ¯»oÿ)gŸU[;¥¶öÌÚ)SkkÏ®­ýÐÔ)“'Mž4òØ‘©Tÿ‡•:Ž;î8vêéSO=E£ ÚôOƨfÛ¶m  GÀ†6ß#`òNÇQSSCY€ F;hR Îh10à`îÌj‡•£s0ÒFü<ðçŸüä'ž(wÜÜŒT·lÙ‚{ÆŒÜèo~󛸙 Ušzîû§?ýi»Š›Y!÷šq/>m‡~8Ó=üßÿþ÷(jݺuH‹óK/½ôÇ?þ‘WYJE2tðàSjGμ­_ÓÓ¹¦§z5­Î}dΰžþÁ3§œùù»¼ñolÜø|Cç&Mœ4aü„£ rjý3¡w£·"·“1[ôOo5iÒ$òüƒülxpèy¦þ‚cŽG}ôÇ…ƒ™oÁùãoûÛt L|láÈÃÊÑi.¹äôÌmõOßÍ¢Üç>÷9üé£É =þßÿþw:ÜÜPêƒ>ÈUÓ?½?îïÿûœéo7ÿÇ<ã Z{ÚUzÜ&L@QÌEpuàÀq$ƒ qÌQWÜ»û ÿóö[žÌÝüä¿ÜüdnúÇûíCðJõOÅÉ{TXr‹†é©tÅ÷òàûì³_ºùæ›]ó›7ov7¿Û`ïaåèL E¸#´ÿ–(C4ÚüÐ×óŒÎ|eœã³9/ÓUóay„–Q£bž ¹YImÝ{ßû^»õ´ù6$øÕ¯~Åc óä*!–P‡ö?t葃k.ø÷óf÷:ûêä“8ÎÅ=»×Ôkz3û_¯Tÿ©öܾî¾ûîÿ<´²Nç#,„FW‚Óc }úô±«ÔqZ•ßüæ7pfý“3³$~Ôw3ÀrÏ=÷ô°rôlŒ\§vÊGL+пëaß}÷ÍB I?yÜÉS&O™x:s”ä(rœ>iÒµgÔ6Ôú—vÑÿ»Þõ®ÝvÛí…ƒé9ãv2ÌÆ„ïw`³ë®»zžßóž÷Я¾ï}ï#ó ©˜œqï½÷Þ~Ë=öØÃÃÊѳ  ÿw¾ó¨PR–€h™N2æÇÇ.•Ô?ÆØ0G`%ªäÁ¸‹¹äþäGì•Ꟍer‚æIÚ/±&ÆZ£>÷á* °tÜ,,Ðg¹OklxX‡mÍRþ=ƒ÷šI.Í`ÉâØ¥vÑC»èŸqRghÛ6´í^"TÍÊXÛAü*+qýòHäè‘Ð6«( _\±ƒa´‡íRðJõÏ(E‡ô•êßWcä@@úï7QEØa•êŸEK"ÐcTªÿEüçžE:‹@Ï °úo^ØÊž|p7ß™ÿ4ÝÙûË +1énL*Õó‚ ~?7ÝÚÔxScÓüÂy~c¨Å6Øc†¿Ÿãìjˆg~cþ<¿É-KÆ–ß|âP¸S©´JþÕL Rý/ZÄoÜ óæ6Ìš3«aNîPú­yƒ6±Ç3È›j’ˆÜýqp©é¦&‹‡¨òn¢JìClIr©tÍ3Ž'D•ÄO@ [Ò¦œxdcèªC¥ú·ÙÏèvíúµÛÞdsß¶ 7 `ª@#¿·áÌ)âžßˆ?³lyâ‘`“ø‡ú2¯‘ºÃ‡H¶¾¾•φC$4ÝÄùÈ£‰±EeqǪ•_%•9 Í÷4³ïbùŠåDbõ1¤eµ2é˜<çá˧ê ìˆþVø,[~ã°jÍ*$·jåªY³gáÍizº†ÄÁ©¯Z½ ÕÕϬç«}‚åÌYKî["YD²:D‚b×®[[d<3{‹9œ“$B$Iº\"QQËpÏ‚UI϶"`*ÕD#ùåO,Go4×Ó¦N«ŸQ_÷ñº­[·ÒÔ_ZOKÎ%&ŦI*_—=´ ýs‰¾€¯Ôe„J„eÝuäCø`lŽå+—‡ÞaëV|¶¼¶…°k׬­»´Îb^²t —ðo¸©ì𑇩^K÷0^¿ýS ¥ò—Eî*$P©þÛ Eçm¯#±mÈ;HwF}½¾mÚôi(MÒA Z X ’~`™©AR ÐgÝÌ:Ü[$4ÚT"“=–Œ^µé¥M$’Iâ±êC O•á*5ˆŠÀ%º ª€¥B‚Ud¯qnÅ9—[*Õ?‚ ­hòÁæ >ªãŒìmD„ê4½M7²Ü´y£qlh«ùਟj „ ÓfLóHðÄÇd¥…¢"Œ9m ¿‹'žšÓjÞ„fÖ›Ú>áIÁ •Jè5’šE°*™ŒÄù—©{ZUL*Õ¿Ã1úG®¼[hÃú o½ùVÝŒ:†ˆ½ÑJÓæ£XdI-peN»`>´É(éò•PŒ|A †.iý/]V3±†Ê‚ÈqЪçõŸÔ)j\ÐÿæMq-£ÓÁ†jh²'us¤ò¯¯UN RýÓP³DÉÙ>«V¬bÞJûŒ¤ÑsḩyãFó4ÑÖüRLÒh• b#V„ˆåÓž uaËæ-aD4½Î†ñaüsSÿà Š™þqäõ?»Þê²',q2r{.áC…âþ†yÄ‚fôOÒÄù— Õ̤Rý§ÆöŒÿß܆n-^ZòuÖ…á_© 6e®ê’fµ“JE™¨×ÌPø’ÅKˆ!?þh™…b>K5 úß¼ ‡MºÃC‡¤ý·¨¸ÊðÆí™‰7‹–3PâOÝ;S~5‹Ÿ²Wªÿ0„¦Å(œ™„†iïÇÃ',9&_Ý‘õDÛŒah–kΨÁº‰Ëq„H’­tn«¦I„æÃÕà˜’ ©Ì¬'9Aü¡¢±úD’K¶Ú’‡‚§éßs—Bîª%°#úGü…O^l‰2ó‹í…%w»<“Äá9W¢^ê°@:³Þžˆ¡ÞPM¢BÃÎC„B¨à¶8ãóÜÔî} uÁjMÖB³åx<Ûrˆ€¨Tÿ¦¢øl’ãL„±Ö j ãüd Ÿa‰=¨¢.l7l66BÙú?ÓÜdmä#m¨Tÿ; TÏkçiºù°ÎŸoöwHº´êÖ¶ÛÙSÙ™*lµ¨Tÿ;)3«H—{gÄÏmò~'ÄYFﳓ9¯6aTIy+Õ•`Qe©•ê¿J°¨šW Jõ/{#ÐçÝ}ÆŒS;µ–å÷Ž;“¿îsèVvÙuª†ímkÖ²ñ ãÎü¬€'ÔµnU|e¦Ê ðì‰'¹a×çŽûXü›75-hªrà*~·"°éÅM<Àê´ƒ*֭НÌT9”ÏcÜ­¯u޹ʫøÝŠÊo?ž©w¦¢mÝÚ­Š¯ÌT9ÿN>ª¸Šß­äÅ¿9ùÛÑç¤géVÅWfªœº‹?Éú ¿Ûòµ ŽroÖü·Ê×½Šß"þ—ñ'K [:ÌMµê^åWnª›@hð_ ~çÞáç¤rU7o•¾{È‹c"þäœë;lÀa}ûõeo?¿ð •¢½ÎT1­ÿw¯û_í¹1y£pÞ|bgvD˜›W”°cÁýc›woÜPíÄUþîD (yã^W…ÎílúÇÍ+GxÛ ûvFŽiWyiï0aÐÈ#q³¥:‡mÛmU©;•^y©vAØëÖÆôo_GމÚy±óáE(øð’ÆHœñäp‡QC«_ׯ¥‚T;q•¿;@«¼ç‡&=ˆ69‡ñÿ‡Q xë>-ú_^iÈ›¯P>³gŽÀÉÃÆñ”p“ÖzºÓí¯ú¼ Ýü¶gÚs¶@¯^eí??ã׸)ýóëÓÿ°¡ÃÊ×è)’˜­FT=rèF‚&Mœ«ƒøóúOÜ,ñN^¸×¾{Ù%¼ö„!è?± /y^ØŒ›}Ôf;ÌÆüó©¬Óø§Ý}eÅd$º2ˆŸ3í¿¹y-#܈œº0fô^ÚÉh‡÷¢³áUèŸjÂo»ðÉ;V…8[â_³JÌE û`ð“çÊUü ,¨:ùt„›„¨nݧìʉ I¤>+:üc]†˜‹@÷!`?âGœ^ó·¿;‰ŸäºOÙ•h‘=ÿä…. £Ï+—‹¹t6ÎïpÙ[µJz™îSvåDBû8ŸXÎ;œ;üœL1Ä\ºüÌ·£‡=jÿ»Ï-WN">þíaüßîÿGôåìjüO.¯8 (,®ò€¬«K¬ôE …ÿ1 ý[ÈW„äY@ûºCl<\[þ±cKÚr‰@WèÓ§[zPf¹{8£¢<Ì­ ÔšµìcQW—Xé‹@¶î°?üãŇfÔîçó¥õ$Ñ÷À¾E 니€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@{`·Ã¢Å‹–,]2kæ,ÞyÒ.ǰ£†ñOቊD}x½!T7í‚i8Lí•÷úW©Ã*ÆT^–ô¿ ­äMüD“ؤb F°_È< je2H#^ÆâÆéœD¡°±Üyã¼°ï..c¿Ç&GõãZø…‹¬EE´“V|†Ch/4ø šÃSG¨\¥1Ç _ ë_³ÐÂøñj5é%Ûÿ éä`Â+vÓ‘DJsÚVaC5Œ»€tN•TØ[ï[P>½=q¥ÿ€¨Šÿ´á‚¬9­&LŠ‹ÚRÞ…ª­ ä¿&µ£Ø0|³Èé#fðµ¨ýŸ›ÿxrõ3ëy¹V:’HÿäÇõOœ±þ U”“8ÔÄš0ûÎåè/òÝYTFé? ¼Ê¾/{(?º°r3a¨œwÓ ìd`oCss•± c¤Ô×,¹|äÉñcÏBS0ë#æ0ÜŠ’CÛ%Úÿ\ÎsHÝô¼1 Š÷‘fsâ¡x[© Òp„)F2œóxøê–ä*?õÈ:B¦uô@-w?)\,H<Ñ>ó±õL¾¢>Ö¢¦¾féxäÛÚ^vV£|tH„eꟴȀM]ѧe1ÇÉes⡬G£¾´¦·¤†ZõÌ:â´äøg$Àª R>¶Hœ´ÌR”iÉ<צ®eF+3è4hØ–I1¬pöÎÅ ƒme£lKé¿-ŒºÖ¥п-lZ.èxbekûøà :„µÇdï ¤a^«…x¦,}YÒ÷RòP˜€¬:b¬ö¿Ko²o‹Ëò¨ÚKÙó) ‘ì´A½àþ©YKØmmßo…ç¼ö-‰PúoëèZWàár O”ŠõO#òélŒ„þiÒó™,yöD­¡©çÃ<‚Z€ϹÌ2T®d×eW—Ré‹@«òMw¤j†4 uÀ6×¾UÇ7²Dí¾-Çþ[­ ݉@˜ó&"7mûŽº[jmÛ€[2þ±fŸ˜,¢ñÏ}É®ûìŽ÷éN@”—ª"ÀÈé2ªAü6°÷Í0åo› >‘ðñÙ´Íü!ãŸìŽ÷©*à*¬ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@—°{žj1 æc:-'eî ²üTdÜiEˆ²¬€µ¬G—[óL*v²4ÇšCjñ™X¸­áiN²ÇùñõŠÓ((±¥wO[$7+~‘š_K)<ñáÁIËŸ™åvi`P"ç™ ¹Û©¿<½µßn7W;•L*pÙ;ˆB¸ŠŒS uÖWWKg%ÓlÍ¿¤q9žˆ[–²DùÜPÓ?uìá#‹{öŒ>e\þW/!BTíú§t¡â'o°!cfæ厶i”Ìy*Ej'Dëú'Ô4œ“=ÄœÝÛãÉaÉ£1`Ï{«lµÓZ¿l(,¹„¥-´¶½ƒˆÛJ®°§)iÊØ3@*Dz®äqžhþ]I$4DEVY’µ&òÉKq‘[â¹3Ä@‹ç!µÓ‰˜gܘq&“î#.ZÉäb’žPªtä òD?^gU™Lbiú÷°žºûàHÝ‘±L1S¥‹ƒ›D]ÿá¡gò2lÈ9Á ܾR‡ç'K#eî–ø§RLYîðWrëúg,d8€ÅÍUKºhkP.Ç€ÄÊ΀6ùôÝA¥Cï&ŠŸ gí¹ƒ%JBÅÆ^L£«¼2Ëü:Þ²4‚`Iœ8Ȫç¶ô¥6ãA™)½™Ú-‡XAÿäßR4a¸ªh­eÛZ /lÖÌ eEp3n–$‘Ò?_ó<ÝGñ‰qY1!œ*]7åuý°…—’ÑV 4C Ô‚Ôðµ5©øùšÊyœbÖxÇ|býE%m#*÷.µ·Ç“ D“¯¡à‰þ=lÉP4P¥Zñ ‘ï H¥ÂM$6¢ÍßßÈØ3tUØe„gü•{ͽ²g‰D­Ž3Ç!T—ڎǰ”̃iÆï,ÉYIƒÿ€–z‘*ZÛÉ•LÈJÇ%Jë\VãRúƒŸ¤õØÌ‘º#1¿ûNØJ—Š!VcA±þÝ¡ñ´¦,ñuJ)ÄÙœÇ)¦Œwøk¬ÿ|}ÏåÑAÿ8Z‹™û –Ð0ê+´{gCqG¬¡pU¤ô_"•Þù·†[¼£ú÷âdõßÚ¥’‚tcÃâ@bã”þ±1}ZŒùP¤bWã¼Úzr%jMÿ„²É&bch„Áþœ=*sdïHœC¿ûåë?¤xü§H¤7qŸ8­˜†à(™óNÖ?y©52ä9ÎÙŽGwq‰²¡h k‰ªDÞ¬al#7ö<ä{çÂÉpÙU2FE‹³T¾þÛŽ'¥ÿ¢B²Ó)Nñð±ªíþ©¢µœ6kÆ¥TûïÆÞþ“–¡ðKîÈÞÏ!6VÌlé<¸9b5zp²Šf0ð’r)ø”jÿÝÆo´ÅÜZÎãS™Ùá¯m´ÿÄI½†3í´¤B›œ¬šr m{ñÍ  &˜q/býÓ#àI‰²©œV‹/ccσµ¢D’žÿVÿˆÁŒË×?öèÇR'·|‹–Ò?WifÉ€õƒ”%6¦æRm­€îŸ-ZÉYæíœ2Ót]?)KË9g2`·‰sQ œ¹#žC¢òb¦J§‚;¥FrH–øØhŸâFέÿ³4,‰ÖržJ1•ŸÎüŠ ó…J'¡×™©+-èZ¶Ôò`¯Ðz·®Í˜RN @OÄx†qgfÊ¢’hG¾ù‡f¼½¢eí…ѳ¦BþFÜ&­\µ‰¡ûË!O »®¸óy`Q¦þæqæ×ñŠw‰øU9D “ ¤ôß²ÈVx–—õ)?‡4þ, Æö¬wµñ”$¶”[:@¬ÿ|㜤Êp(ža.yão…_ŠÌsã. DØú.‘8 Ü"Ð býgG;YŸr²ä‚ç{ØøÁQxÛ?dÇ&©œe#C Ö?)´Ìv“­/%}¶›ÛBËO¿`‹œ¡"Þ,jW}—Èvc“ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ì<_ÿg®ºó±Y mïÿa-ˆŸÒø[ö#,OK0©õŸvÁÒÆþâgkÒMéåãïúÏÚ¤ž£±¬d;+|A•Dm­‰ê@p+ˆ/@µK¹IÏ#ÒËúgÇìÿ  5Ö?«£´Ò$íúOÙð5Õ=ÅÆT„¢_ö~‰O7D´=ï–©DíH ÖöiWÖÇ“nûùokû,8 u¬škŠ%YlC#Ïø‡a µÀ~tÉÙÚªã"kù-r*‘½ú€<0ÐÂŒø‰Üs.‡8ÿ#Èìn‡¬,Ç‘Ýÿc¡bm#Wgú÷´ˆ0 „M¶9ãŸ9z× †^cû…rñN즶³Ø!®†ù©qR5JVÃrÊ"›žM Ö?%E„H…OE³>ÛB[™¤Y«*BaÿÁ+ÕÉ7ÉØÂ&ã«d˜²ä»’»n|â?:Ønæe " " " " " "Ð# øú?sUßK-ik—ZóÏÆ`>¬Õ0ùe(5ïnÍ^þ"СR:ô¥Ël¢%/í˜þÃCÛh9(›–|D sÄúw1ã ; ­f1µÍ,\Šþ3_YêÄ2œ ¯úñ%Sù›½F›8YY +¢öÊÜÎ)¡RÖ ´¦ÆE¶®ŽªÃˆ¥°© mçÑÚ#×äß~Y×@e±± „½‘gñÙ‡,$ÿÆ%è?ùÁG‡t)ÿó ÉEn­ºå+ü+„#[.ÿg®¬%û"ÛÐÔóáiµ ÞDaµ‰˜µ3³Ko»Ïh­ýÏ·Ø…âúÁ¢_ûÛ? Aí©›”Ô?žº"Ðå*Õ¿ ŠÈvíDÿÖÓ?c!köñ¡vp.ÿØ^åÂ뀸ªCº@¥ú§Ý¦kàÃx‰lgÛ<±a:lób+šÍüŠñj;P_I‹€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ùþØN¯Sendstream endobj 16 0 obj<]/Filter/FlateDecode/Width 377/Height 149/BitsPerComponent 2/Length 1100 >>stream xíšÁŽÜ †R¥÷½G=E~Š}„¶ïC#UZÍSМ,ž²6&Ù˜ì’aÚU ‡ ØÉ‡óÏïYì#áÞwü¾]œ.Î.qæ ª. ÷ñWð…XäÙŠ…+äè '3H.ÿ3~bIŒ¬K°ž_Nx\ðÁð¶§³x‡‰äb¸“¥±?+¼§­5×Ù8ÃB¡Á µ°^¥§ééè•¥µ4jšh™L~žìàÜ0À8Žfè,Þ«?9¼™¨„až‰'ž(î uÂ[¢«»¢Ÿ7ø =N=jTRå¬8Ά£w.ˆC2Oï<ÌGC¦óÚ;å•å4^´²V{jZE#­üå¢.ä‚{ð|-•´¨æ¼¸0Ê&¸ÏÏœxyÂNïãçØÝNø²@€&Ñۈᙠ­Z.*¶î'QЇ³³Ü:>¾:͉³{Gܲ{­ÁÇâ¥.ÏÙÄèÏ¡¤«>ÞòÄå$E*Ùj¢ÿùʳD)ÚêñPd Žz¼(EÓ¿ˆÏ_ë›»ŽCÛ@·Á.vxXëc;¼Yc—z;¼¸6ÛáÕñúØknª7Ä›‡â¬ý$sË%×Ý4Ã/)ëîÛE/$u”=| zbm{=j¾…¬+À¹ƒï¥¤Fè§€ÎüÐôñ¢Œà–MÇû§Ä®xœWàDüKM¶PLjÿF¿µd%kÞÇÁm1s„@è‡OÚÑ+k¢Ç'Â?×L{9!#nÍÀòûžÂ¯ØJ< n]ðuâxW7°µÑ󯢒r¢½fæÀÖÌJ>_ì´hÄŠËJ¼ÂÅhªñe’è©^„”oiÆ5-&ÞQŠÞ6el‹Ó¦²¤ï{:þ@£.Nç@WŸ9]œ\}ætq8pž9p½¹ÞÇÏq›üö÷BÈVnM·Àji†c²¥4êmžÃi¾ùÆûJ µF¿¤H¯‘—_ˆÍôI×s‘ñÔ_Ü ¼uÌýG{‘Édøú¼[ùÓÄšŒw~ñˆä#Õ ¿á2r]1±!ã)> ½æÍZPþ<í`kþ“j&_À£BôÿºZˆ/¬øïá¡ýw’br´©¬§ýkØà½±Ö]èÃ/\Wð|kÅèÏûù퉃Ùâ•¶ŠÇvûù=‡W ÖüDïm“ ø¤}ÄÓ&zÀ'`êãO‡èI žô¹’O§=ùD_ÞW‘ÅA+lðÞà•| ÞÒ™ýµ"zZ:”*7…ZóÌ!€Õ×eYÑ› Ãp1j¼h>×Âx8Ò¹\äè£Oü4¢ugL§UãaG gñ"loìø½&ÙÒÅÉRì+]œ½&ÙÒÅÉRì+]œ½&ÙÒÅÉRì+]œ½&Ù²çÁò>Ÿoªq%ei©×ñYŠ}¥‹³×$[-Îo; ØÎendstream endobj 17 0 obj<>endobj 18 0 obj<>endobj 19 0 obj<>endobj 20 0 obj<>endobj 21 0 obj<>endobj 22 0 obj<>endobj 23 0 obj<>endobj 24 0 obj<>endobj 25 0 obj<>endobj 26 0 obj<>endobj 27 0 obj<>endobj 28 0 obj<>endobj 29 0 obj<>endobj 30 0 obj<>endobj 31 0 obj<>endobj 32 0 obj<>endobj 33 0 obj<>endobj 34 0 obj<>endobj 35 0 obj<>endobj 36 0 obj<>endobj 37 0 obj<>endobj 38 0 obj<>endobj 39 0 obj<>endobj 40 0 obj<>endobj 41 0 obj<>endobj 42 0 obj<>endobj 43 0 obj<>endobj 44 0 obj<>endobj 45 0 obj<>endobj 46 0 obj<>endobj 47 0 obj<>endobj 48 0 obj<>endobj 49 0 obj<>endobj 50 0 obj<>endobj 51 0 obj<>endobj 52 0 obj<>endobj 53 0 obj<>endobj 54 0 obj<>endobj 55 0 obj<>endobj 56 0 obj<>endobj 57 0 obj<>endobj 58 0 obj<>endobj 59 0 obj<>endobj 60 0 obj<>endobj 61 0 obj<>endobj 62 0 obj<>endobj 63 0 obj<>endobj 64 0 obj<>endobj 65 0 obj<>endobj 66 0 obj<>endobj 67 0 obj<>endobj 68 0 obj[17 0 R 18 0 R 19 0 R 20 0 R 21 0 R 22 0 R 23 0 R 24 0 R 25 0 R 26 0 R 27 0 R 28 0 R 29 0 R 30 0 R 31 0 R 32 0 R 33 0 R 34 0 R 35 0 R 36 0 R 37 0 R 38 0 R 39 0 R 40 0 R 41 0 R 42 0 R 43 0 R 44 0 R 45 0 R 46 0 R 47 0 R 48 0 R 49 0 R 50 0 R 51 0 R 52 0 R 53 0 R 54 0 R 55 0 R 56 0 R 57 0 R 58 0 R 59 0 R 60 0 R 61 0 R 62 0 R 63 0 R 64 0 R 65 0 R 66 0 R 67 0 R]endobj 69 0 obj<>endobj 70 0 obj<>endobj 71 0 obj<>endobj 72 0 obj<>endobj 73 0 obj<>endobj 74 0 obj<>endobj 75 0 obj<>endobj 76 0 obj<>endobj 77 0 obj<>endobj 78 0 obj<>endobj 79 0 obj<>endobj 80 0 obj<>endobj 81 0 obj<>endobj 82 0 obj<>endobj 83 0 obj<>endobj 84 0 obj<>endobj 85 0 obj<>endobj 86 0 obj<>endobj 87 0 obj<>endobj 88 0 obj<>endobj 89 0 obj<>endobj 90 0 obj<>endobj 91 0 obj<>endobj 92 0 obj<>endobj 93 0 obj<>endobj 94 0 obj<>endobj 95 0 obj<>endobj 96 0 obj<>endobj 97 0 obj<>endobj 98 0 obj<>endobj 99 0 obj<>endobj 100 0 obj<>endobj 101 0 obj<>endobj 102 0 obj<>endobj 103 0 obj<>endobj 104 0 obj<>endobj 105 0 obj<>endobj 106 0 obj<>endobj 107 0 obj<>endobj 108 0 obj<>endobj 109 0 obj<>endobj 110 0 obj<>endobj 111 0 obj<>endobj 112 0 obj<>endobj 113 0 obj<>endobj 114 0 obj<>endobj 115 0 obj<>endobj 116 0 obj<>endobj 117 0 obj<>endobj 118 0 obj<>endobj 119 0 obj<>endobj 120 0 obj<>endobj 121 0 obj[69 0 R 70 0 R 71 0 R 72 0 R 73 0 R 74 0 R 75 0 R 76 0 R 77 0 R 78 0 R 79 0 R 80 0 R 81 0 R 82 0 R 83 0 R 84 0 R 85 0 R 86 0 R 87 0 R 88 0 R 89 0 R 90 0 R 91 0 R 92 0 R 93 0 R 94 0 R 95 0 R 96 0 R 97 0 R 98 0 R 99 0 R 100 0 R 101 0 R 102 0 R 103 0 R 104 0 R 105 0 R 106 0 R 107 0 R 108 0 R 109 0 R 110 0 R 111 0 R 112 0 R 113 0 R 114 0 R 115 0 R 116 0 R 117 0 R 118 0 R 119 0 R 120 0 R]endobj 122 0 obj<>endobj 123 0 obj<>endobj 124 0 obj<>endobj 125 0 obj<>endobj 126 0 obj<>endobj 127 0 obj<>endobj 128 0 obj<>endobj 129 0 obj<>endobj 130 0 obj<>endobj 131 0 obj<>endobj 132 0 obj<>endobj 133 0 obj<>endobj 134 0 obj<>endobj 135 0 obj<>endobj 136 0 obj<>endobj 137 0 obj<>endobj 138 0 obj<>endobj 139 0 obj<>endobj 140 0 obj<>endobj 141 0 obj<>endobj 142 0 obj<>endobj 143 0 obj<>endobj 144 0 obj<>endobj 145 0 obj<>endobj 146 0 obj<>endobj 147 0 obj<>endobj 148 0 obj<>endobj 149 0 obj<>endobj 150 0 obj<>endobj 151 0 obj<>endobj 152 0 obj<>endobj 153 0 obj<>endobj 154 0 obj<>endobj 155 0 obj<>endobj 156 0 obj<>endobj 157 0 obj<>endobj 158 0 obj<>endobj 159 0 obj<>endobj 160 0 obj<>endobj 161 0 obj<>endobj 162 0 obj<>endobj 163 0 obj<>endobj 164 0 obj<>endobj 165 0 obj<>endobj 166 0 obj<>endobj 167 0 obj<>endobj 168 0 obj<>endobj 169 0 obj<>endobj 170 0 obj<>endobj 171 0 obj<>endobj 172 0 obj<>endobj 173 0 obj<>endobj 174 0 obj<>endobj 175 0 obj[122 0 R 123 0 R 124 0 R 125 0 R 126 0 R 127 0 R 128 0 R 129 0 R 130 0 R 131 0 R 132 0 R 133 0 R 134 0 R 135 0 R 136 0 R 137 0 R 138 0 R 139 0 R 140 0 R 141 0 R 142 0 R 143 0 R 144 0 R 145 0 R 146 0 R 147 0 R 148 0 R 149 0 R 150 0 R 151 0 R 152 0 R 153 0 R 154 0 R 155 0 R 156 0 R 157 0 R 158 0 R 159 0 R 160 0 R 161 0 R 162 0 R 163 0 R 164 0 R 165 0 R 166 0 R 167 0 R 168 0 R 169 0 R 170 0 R 171 0 R 172 0 R 173 0 R 174 0 R]endobj 176 0 obj<>endobj 177 0 obj<>endobj 178 0 obj<>endobj 179 0 obj<>endobj 180 0 obj<>endobj 181 0 obj<>endobj 182 0 obj<>endobj 183 0 obj<>endobj 184 0 obj<>endobj 185 0 obj<>endobj 186 0 obj<>endobj 187 0 obj<>endobj 188 0 obj<>endobj 189 0 obj<>endobj 190 0 obj<>endobj 191 0 obj<>endobj 192 0 obj<>endobj 193 0 obj<>endobj 194 0 obj<>endobj 195 0 obj<>endobj 196 0 obj<>endobj 197 0 obj<>endobj 198 0 obj<>endobj 199 0 obj<>endobj 200 0 obj<>endobj 201 0 obj<>endobj 202 0 obj<>endobj 203 0 obj<>endobj 204 0 obj<>endobj 205 0 obj<>endobj 206 0 obj<>endobj 207 0 obj<>endobj 208 0 obj<>endobj 209 0 obj<>endobj 210 0 obj<>endobj 211 0 obj<>endobj 212 0 obj<>endobj 213 0 obj<>endobj 214 0 obj<>endobj 215 0 obj<>endobj 216 0 obj<>endobj 217 0 obj<>endobj 218 0 obj<>endobj 219 0 obj<>endobj 220 0 obj<>endobj 221 0 obj<>endobj 222 0 obj<>endobj 223 0 obj<>endobj 224 0 obj<>endobj 225 0 obj<>endobj 226 0 obj<>endobj 227 0 obj<>endobj 228 0 obj<>endobj 229 0 obj[176 0 R 177 0 R 178 0 R 179 0 R 180 0 R 181 0 R 182 0 R 183 0 R 184 0 R 185 0 R 186 0 R 187 0 R 188 0 R 189 0 R 190 0 R 191 0 R 192 0 R 193 0 R 194 0 R 195 0 R 196 0 R 197 0 R 198 0 R 199 0 R 200 0 R 201 0 R 202 0 R 203 0 R 204 0 R 205 0 R 206 0 R 207 0 R 208 0 R 209 0 R 210 0 R 211 0 R 212 0 R 213 0 R 214 0 R 215 0 R 216 0 R 217 0 R 218 0 R 219 0 R 220 0 R 221 0 R 222 0 R 223 0 R 224 0 R 225 0 R 226 0 R 227 0 R 228 0 R]endobj 230 0 obj<>endobj 231 0 obj<>endobj 232 0 obj<>endobj 233 0 obj<>endobj 234 0 obj<>endobj 235 0 obj<>endobj 236 0 obj<>endobj 237 0 obj<>endobj 238 0 obj<>endobj 239 0 obj<>endobj 240 0 obj<>endobj 241 0 obj<>endobj 242 0 obj<>endobj 243 0 obj<>endobj 244 0 obj<>endobj 245 0 obj<>endobj 246 0 obj<>endobj 247 0 obj<>endobj 248 0 obj<>endobj 249 0 obj<>endobj 250 0 obj<>endobj 251 0 obj<>endobj 252 0 obj<>endobj 253 0 obj<>endobj 254 0 obj<>endobj 255 0 obj<>endobj 256 0 obj<>endobj 257 0 obj<>endobj 258 0 obj<>endobj 259 0 obj<>endobj 260 0 obj<>endobj 261 0 obj<>endobj 262 0 obj<>endobj 263 0 obj<>endobj 264 0 obj<>endobj 265 0 obj<>endobj 266 0 obj<>endobj 267 0 obj<>endobj 268 0 obj<>endobj 269 0 obj<>endobj 270 0 obj<>endobj 271 0 obj<>endobj 272 0 obj<>endobj 273 0 obj<>endobj 274 0 obj<>endobj 275 0 obj<>endobj 276 0 obj<>endobj 277 0 obj<>endobj 278 0 obj<>endobj 279 0 obj[230 0 R 231 0 R 232 0 R 233 0 R 234 0 R 235 0 R 236 0 R 237 0 R 238 0 R 239 0 R 240 0 R 241 0 R 242 0 R 243 0 R 244 0 R 245 0 R 246 0 R 247 0 R 248 0 R 249 0 R 250 0 R 251 0 R 252 0 R 253 0 R 254 0 R 255 0 R 256 0 R 257 0 R 258 0 R 259 0 R 260 0 R 261 0 R 262 0 R 263 0 R 264 0 R 265 0 R 266 0 R 267 0 R 268 0 R 269 0 R 270 0 R 271 0 R 272 0 R 273 0 R 274 0 R 275 0 R 276 0 R 277 0 R 278 0 R]endobj 280 0 obj<>endobj 281 0 obj<>endobj 282 0 obj<>endobj 283 0 obj<>endobj 284 0 obj<>endobj 285 0 obj<>endobj 286 0 obj<>endobj 287 0 obj<>endobj 288 0 obj<>endobj 289 0 obj<>endobj 290 0 obj<>endobj 291 0 obj<>endobj 292 0 obj<>endobj 293 0 obj<>endobj 294 0 obj<>endobj 295 0 obj<>endobj 296 0 obj<>endobj 297 0 obj<>endobj 298 0 obj<>endobj 299 0 obj<>endobj 300 0 obj<>endobj 301 0 obj<>endobj 302 0 obj<>endobj 303 0 obj<>endobj 304 0 obj<>endobj 305 0 obj<>endobj 306 0 obj<>endobj 307 0 obj<>endobj 308 0 obj<>endobj 309 0 obj<>endobj 310 0 obj<>endobj 311 0 obj<>endobj 312 0 obj<>endobj 313 0 obj<>endobj 314 0 obj<>endobj 315 0 obj<>endobj 316 0 obj<>endobj 317 0 obj<>endobj 318 0 obj<>endobj 319 0 obj<>endobj 320 0 obj<>endobj 321 0 obj<>endobj 322 0 obj<>endobj 323 0 obj<>endobj 324 0 obj<>endobj 325 0 obj<>endobj 326 0 obj<>endobj 327 0 obj<>endobj 328 0 obj<>endobj 329 0 obj<>endobj 330 0 obj<>endobj 331 0 obj<>endobj 332 0 obj<>endobj 333 0 obj<>endobj 334 0 obj[280 0 R 281 0 R 282 0 R 283 0 R 284 0 R 285 0 R 286 0 R 287 0 R 288 0 R 289 0 R 290 0 R 291 0 R 292 0 R 293 0 R 294 0 R 295 0 R 296 0 R 297 0 R 298 0 R 299 0 R 300 0 R 301 0 R 302 0 R 303 0 R 304 0 R 305 0 R 306 0 R 307 0 R 308 0 R 309 0 R 310 0 R 311 0 R 312 0 R 313 0 R 314 0 R 315 0 R 316 0 R 317 0 R 318 0 R 319 0 R 320 0 R 321 0 R 322 0 R 323 0 R 324 0 R 325 0 R 326 0 R 327 0 R 328 0 R 329 0 R 330 0 R 331 0 R 332 0 R 333 0 R]endobj 335 0 obj<>endobj 336 0 obj<>endobj 337 0 obj<>endobj 338 0 obj<>endobj 339 0 obj<>endobj 340 0 obj<>endobj 341 0 obj<>endobj 342 0 obj<>endobj 343 0 obj<>endobj 344 0 obj<>endobj 345 0 obj<>endobj 346 0 obj<>endobj 347 0 obj<>endobj 348 0 obj<>endobj 349 0 obj<>endobj 350 0 obj<>endobj 351 0 obj<>endobj 352 0 obj<>endobj 353 0 obj<>endobj 354 0 obj<>endobj 355 0 obj<>endobj 356 0 obj<>endobj 357 0 obj<>endobj 358 0 obj<>endobj 359 0 obj<>endobj 360 0 obj<>endobj 361 0 obj<>endobj 362 0 obj<>endobj 363 0 obj<>endobj 364 0 obj<>endobj 365 0 obj<>endobj 366 0 obj<>endobj 367 0 obj<>endobj 368 0 obj<>endobj 369 0 obj<>endobj 370 0 obj<>endobj 371 0 obj<>endobj 372 0 obj<>endobj 373 0 obj<>endobj 374 0 obj<>endobj 375 0 obj<>endobj 376 0 obj<>endobj 377 0 obj<>endobj 378 0 obj<>endobj 379 0 obj<>endobj 380 0 obj<>endobj 381 0 obj<>endobj 382 0 obj<>endobj 383 0 obj<>endobj 384 0 obj<>endobj 385 0 obj[335 0 R 336 0 R 337 0 R 338 0 R 339 0 R 340 0 R 341 0 R 342 0 R 343 0 R 344 0 R 345 0 R 346 0 R 347 0 R 348 0 R 349 0 R 350 0 R 351 0 R 352 0 R 353 0 R 354 0 R 355 0 R 356 0 R 357 0 R 358 0 R 359 0 R 360 0 R 361 0 R 362 0 R 363 0 R 364 0 R 365 0 R 366 0 R 367 0 R 368 0 R 369 0 R 370 0 R 371 0 R 372 0 R 373 0 R 374 0 R 375 0 R 376 0 R 377 0 R 378 0 R 379 0 R 380 0 R 381 0 R 382 0 R 383 0 R 384 0 R]endobj 386 0 obj<>endobj 387 0 obj<>endobj 388 0 obj<>endobj 389 0 obj<>endobj 390 0 obj<>endobj 391 0 obj<>endobj 392 0 obj<>endobj 393 0 obj<>endobj 394 0 obj<>endobj 395 0 obj<>endobj 396 0 obj<>endobj 397 0 obj<>endobj 398 0 obj<>endobj 399 0 obj<>endobj 400 0 obj<>endobj 401 0 obj<>endobj 402 0 obj<>endobj 403 0 obj<>endobj 404 0 obj<>endobj 405 0 obj<>endobj 406 0 obj<>endobj 407 0 obj<>endobj 408 0 obj<>endobj 409 0 obj<>endobj 410 0 obj<>endobj 411 0 obj<>endobj 412 0 obj<>endobj 413 0 obj<>endobj 414 0 obj<>endobj 415 0 obj<>endobj 416 0 obj<>endobj 417 0 obj<>endobj 418 0 obj<>endobj 419 0 obj<>endobj 420 0 obj<>endobj 421 0 obj<>endobj 422 0 obj<>endobj 423 0 obj<>endobj 424 0 obj<>endobj 425 0 obj<>endobj 426 0 obj<>endobj 427 0 obj<>endobj 428 0 obj<>endobj 429 0 obj<>endobj 430 0 obj<>endobj 431 0 obj<>endobj 432 0 obj<>endobj 433 0 obj<>endobj 434 0 obj<>endobj 435 0 obj<>endobj 436 0 obj<>endobj 437 0 obj[386 0 R 387 0 R 388 0 R 389 0 R 390 0 R 391 0 R 392 0 R 393 0 R 394 0 R 395 0 R 396 0 R 397 0 R 398 0 R 399 0 R 400 0 R 401 0 R 402 0 R 403 0 R 404 0 R 405 0 R 406 0 R 407 0 R 408 0 R 409 0 R 410 0 R 411 0 R 412 0 R 413 0 R 414 0 R 415 0 R 416 0 R 417 0 R 418 0 R 419 0 R 420 0 R 421 0 R 422 0 R 423 0 R 424 0 R 425 0 R 426 0 R 427 0 R 428 0 R 429 0 R 430 0 R 431 0 R 432 0 R 433 0 R 434 0 R 435 0 R 436 0 R]endobj 438 0 obj<>endobj 439 0 obj<>endobj 440 0 obj<>endobj 441 0 obj<>endobj 442 0 obj<>endobj 443 0 obj<>endobj 444 0 obj<>endobj 445 0 obj<>endobj 446 0 obj<>endobj 447 0 obj<>endobj 448 0 obj<>endobj 449 0 obj<>endobj 450 0 obj<>endobj 451 0 obj<>endobj 452 0 obj<>endobj 453 0 obj<>endobj 454 0 obj<>endobj 455 0 obj<>endobj 456 0 obj<>endobj 457 0 obj<>endobj 458 0 obj<>endobj 459 0 obj<>endobj 460 0 obj<>endobj 461 0 obj<>endobj 462 0 obj<>endobj 463 0 obj<>endobj 464 0 obj<>endobj 465 0 obj<>endobj 466 0 obj<>endobj 467 0 obj<>endobj 468 0 obj<>endobj 469 0 obj<>endobj 470 0 obj<>endobj 471 0 obj<>endobj 472 0 obj<>endobj 473 0 obj<>endobj 474 0 obj<>endobj 475 0 obj<>endobj 476 0 obj<>endobj 477 0 obj<>endobj 478 0 obj<>endobj 479 0 obj<>endobj 480 0 obj<>endobj 481 0 obj<>endobj 482 0 obj<>endobj 483 0 obj<>endobj 484 0 obj<>endobj 485 0 obj<>endobj 486 0 obj<>endobj 487 0 obj<>endobj 488 0 obj<>endobj 489 0 obj<>endobj 490 0 obj[438 0 R 439 0 R 440 0 R 441 0 R 442 0 R 443 0 R 444 0 R 445 0 R 446 0 R 447 0 R 448 0 R 449 0 R 450 0 R 451 0 R 452 0 R 453 0 R 454 0 R 455 0 R 456 0 R 457 0 R 458 0 R 459 0 R 460 0 R 461 0 R 462 0 R 463 0 R 464 0 R 465 0 R 466 0 R 467 0 R 468 0 R 469 0 R 470 0 R 471 0 R 472 0 R 473 0 R 474 0 R 475 0 R 476 0 R 477 0 R 478 0 R 479 0 R 480 0 R 481 0 R 482 0 R 483 0 R 484 0 R 485 0 R 486 0 R 487 0 R 488 0 R 489 0 R]endobj 491 0 obj<>endobj 492 0 obj<>endobj 493 0 obj<>endobj 494 0 obj<>endobj 495 0 obj<>endobj 496 0 obj<>endobj 497 0 obj<>endobj 498 0 obj<>endobj 499 0 obj<>endobj 500 0 obj<>endobj 501 0 obj<>endobj 502 0 obj<>endobj 503 0 obj<>endobj 504 0 obj<>endobj 505 0 obj<>endobj 506 0 obj<>endobj 507 0 obj<>endobj 508 0 obj<>endobj 509 0 obj<>endobj 510 0 obj<>endobj 511 0 obj<>endobj 512 0 obj<>endobj 513 0 obj<>endobj 514 0 obj<>endobj 515 0 obj<>endobj 516 0 obj<>endobj 517 0 obj<>endobj 518 0 obj<>endobj 519 0 obj<>endobj 520 0 obj<>endobj 521 0 obj<>endobj 522 0 obj<>endobj 523 0 obj<>endobj 524 0 obj<>endobj 525 0 obj<>endobj 526 0 obj<>endobj 527 0 obj<>endobj 528 0 obj<>endobj 529 0 obj<>endobj 530 0 obj<>endobj 531 0 obj<>endobj 532 0 obj<>endobj 533 0 obj<>endobj 534 0 obj<>endobj 535 0 obj<>endobj 536 0 obj<>endobj 537 0 obj<>endobj 538 0 obj<>endobj 539 0 obj<>endobj 540 0 obj<>endobj 541 0 obj<>endobj 542 0 obj<>endobj 543 0 obj[491 0 R 492 0 R 493 0 R 494 0 R 495 0 R 496 0 R 497 0 R 498 0 R 499 0 R 500 0 R 501 0 R 502 0 R 503 0 R 504 0 R 505 0 R 506 0 R 507 0 R 508 0 R 509 0 R 510 0 R 511 0 R 512 0 R 513 0 R 514 0 R 515 0 R 516 0 R 517 0 R 518 0 R 519 0 R 520 0 R 521 0 R 522 0 R 523 0 R 524 0 R 525 0 R 526 0 R 527 0 R 528 0 R 529 0 R 530 0 R 531 0 R 532 0 R 533 0 R 534 0 R 535 0 R 536 0 R 537 0 R 538 0 R 539 0 R 540 0 R 541 0 R 542 0 R]endobj 544 0 obj<>endobj 545 0 obj<>endobj 546 0 obj<>endobj 547 0 obj<>endobj 548 0 obj<>endobj 549 0 obj<>endobj 550 0 obj<>endobj 551 0 obj<>endobj 552 0 obj<>endobj 553 0 obj<>endobj 554 0 obj<>endobj 555 0 obj<>endobj 556 0 obj<>endobj 557 0 obj<>endobj 558 0 obj<>endobj 559 0 obj<>endobj 560 0 obj<>endobj 561 0 obj<>endobj 562 0 obj<>endobj 563 0 obj<>endobj 564 0 obj<>endobj 565 0 obj<>endobj 566 0 obj<>endobj 567 0 obj<>endobj 568 0 obj<>endobj 569 0 obj<>endobj 570 0 obj<>endobj 571 0 obj<>endobj 572 0 obj<>endobj 573 0 obj<>endobj 574 0 obj<>endobj 575 0 obj<>endobj 576 0 obj<>endobj 577 0 obj<>endobj 578 0 obj<>endobj 579 0 obj<>endobj 580 0 obj<>endobj 581 0 obj<>endobj 582 0 obj<>endobj 583 0 obj<>endobj 584 0 obj<>endobj 585 0 obj<>endobj 586 0 obj<>endobj 587 0 obj<>endobj 588 0 obj<>endobj 589 0 obj<>endobj 590 0 obj<>endobj 591 0 obj<>endobj 592 0 obj<>endobj 593 0 obj<>endobj 594 0 obj<>endobj 595 0 obj<>endobj 596 0 obj[544 0 R 545 0 R 546 0 R 547 0 R 548 0 R 549 0 R 550 0 R 551 0 R 552 0 R 553 0 R 554 0 R 555 0 R 556 0 R 557 0 R 558 0 R 559 0 R 560 0 R 561 0 R 562 0 R 563 0 R 564 0 R 565 0 R 566 0 R 567 0 R 568 0 R 569 0 R 570 0 R 571 0 R 572 0 R 573 0 R 574 0 R 575 0 R 576 0 R 577 0 R 578 0 R 579 0 R 580 0 R 581 0 R 582 0 R 583 0 R 584 0 R 585 0 R 586 0 R 587 0 R 588 0 R 589 0 R 590 0 R 591 0 R 592 0 R 593 0 R 594 0 R 595 0 R]endobj 597 0 obj<>endobj 598 0 obj<>endobj 599 0 obj<>endobj 600 0 obj<>endobj 601 0 obj<>endobj 602 0 obj<>endobj 603 0 obj<>endobj 604 0 obj<>endobj 605 0 obj<>endobj 606 0 obj<>endobj 607 0 obj<>endobj 608 0 obj<>endobj 609 0 obj<>endobj 610 0 obj<>endobj 611 0 obj<>endobj 612 0 obj<>endobj 613 0 obj<>endobj 614 0 obj<>endobj 615 0 obj<>endobj 616 0 obj<>endobj 617 0 obj<>endobj 618 0 obj<>endobj 619 0 obj<>endobj 620 0 obj<>endobj 621 0 obj<>endobj 622 0 obj<>endobj 623 0 obj<>endobj 624 0 obj<>endobj 625 0 obj<>endobj 626 0 obj<>endobj 627 0 obj<>endobj 628 0 obj<>endobj 629 0 obj<>endobj 630 0 obj<>endobj 631 0 obj<>endobj 632 0 obj<>endobj 633 0 obj<>endobj 634 0 obj<>endobj 635 0 obj<>endobj 636 0 obj<>endobj 637 0 obj<>endobj 638 0 obj<>endobj 639 0 obj<>endobj 640 0 obj<>endobj 641 0 obj<>endobj 642 0 obj<>endobj 643 0 obj<>endobj 644 0 obj<>endobj 645 0 obj<>endobj 646 0 obj<>endobj 647 0 obj<>endobj 648 0 obj<>endobj 649 0 obj<>endobj 650 0 obj[597 0 R 598 0 R 599 0 R 600 0 R 601 0 R 602 0 R 603 0 R 604 0 R 605 0 R 606 0 R 607 0 R 608 0 R 609 0 R 610 0 R 611 0 R 612 0 R 613 0 R 614 0 R 615 0 R 616 0 R 617 0 R 618 0 R 619 0 R 620 0 R 621 0 R 622 0 R 623 0 R 624 0 R 625 0 R 626 0 R 627 0 R 628 0 R 629 0 R 630 0 R 631 0 R 632 0 R 633 0 R 634 0 R 635 0 R 636 0 R 637 0 R 638 0 R 639 0 R 640 0 R 641 0 R 642 0 R 643 0 R 644 0 R 645 0 R 646 0 R 647 0 R 648 0 R 649 0 R]endobj 651 0 obj<>endobj 652 0 obj<>endobj 653 0 obj<>endobj 654 0 obj<>endobj 655 0 obj<>endobj 656 0 obj<>endobj 657 0 obj<>endobj 658 0 obj<>endobj 659 0 obj<>endobj 660 0 obj<>endobj 661 0 obj<>endobj 662 0 obj<>endobj 663 0 obj<>endobj 664 0 obj<>endobj 665 0 obj<>endobj 666 0 obj<>endobj 667 0 obj<>endobj 668 0 obj<>endobj 669 0 obj<>endobj 670 0 obj<>endobj 671 0 obj<>endobj 672 0 obj<>endobj 673 0 obj<>endobj 674 0 obj<>endobj 675 0 obj<>endobj 676 0 obj<>endobj 677 0 obj<>endobj 678 0 obj<>endobj 679 0 obj<>endobj 680 0 obj<>endobj 681 0 obj<>endobj 682 0 obj<>endobj 683 0 obj<>endobj 684 0 obj<>endobj 685 0 obj<>endobj 686 0 obj<>endobj 687 0 obj<>endobj 688 0 obj<>endobj 689 0 obj<>endobj 690 0 obj<>endobj 691 0 obj<>endobj 692 0 obj<>endobj 693 0 obj<>endobj 694 0 obj<>endobj 695 0 obj<>endobj 696 0 obj<>endobj 697 0 obj<>endobj 698 0 obj<>endobj 699 0 obj<>endobj 700 0 obj<>endobj 701 0 obj<>endobj 702 0 obj<>endobj 703 0 obj<>endobj 704 0 obj<>endobj 705 0 obj[651 0 R 652 0 R 653 0 R 654 0 R 655 0 R 656 0 R 657 0 R 658 0 R 659 0 R 660 0 R 661 0 R 662 0 R 663 0 R 664 0 R 665 0 R 666 0 R 667 0 R 668 0 R 669 0 R 670 0 R 671 0 R 672 0 R 673 0 R 674 0 R 675 0 R 676 0 R 677 0 R 678 0 R 679 0 R 680 0 R 681 0 R 682 0 R 683 0 R 684 0 R 685 0 R 686 0 R 687 0 R 688 0 R 689 0 R 690 0 R 691 0 R 692 0 R 693 0 R 694 0 R 695 0 R 696 0 R 697 0 R 698 0 R 699 0 R 700 0 R 701 0 R 702 0 R 703 0 R 704 0 R]endobj 706 0 obj<>endobj 707 0 obj<>endobj 708 0 obj<>endobj 709 0 obj<>endobj 710 0 obj<>endobj 711 0 obj<>endobj 712 0 obj<>endobj 713 0 obj<>endobj 714 0 obj<>endobj 715 0 obj<>endobj 716 0 obj<>endobj 717 0 obj<>endobj 718 0 obj<>endobj 719 0 obj<>endobj 720 0 obj<>endobj 721 0 obj<>endobj 722 0 obj<>endobj 723 0 obj<>endobj 724 0 obj<>endobj 725 0 obj<>endobj 726 0 obj<>endobj 727 0 obj<>endobj 728 0 obj<>endobj 729 0 obj<>endobj 730 0 obj<>endobj 731 0 obj<>endobj 732 0 obj<>endobj 733 0 obj<>endobj 734 0 obj<>endobj 735 0 obj<>endobj 736 0 obj<>endobj 737 0 obj<>endobj 738 0 obj<>endobj 739 0 obj<>endobj 740 0 obj<>endobj 741 0 obj<>endobj 742 0 obj<>endobj 743 0 obj<>endobj 744 0 obj<>endobj 745 0 obj<>endobj 746 0 obj<>endobj 747 0 obj<>endobj 748 0 obj<>endobj 749 0 obj<>endobj 750 0 obj<>endobj 751 0 obj<>endobj 752 0 obj<>endobj 753 0 obj<>endobj 754 0 obj<>endobj 755 0 obj<>endobj 756 0 obj<>endobj 757 0 obj[706 0 R 707 0 R 708 0 R 709 0 R 710 0 R 711 0 R 712 0 R 713 0 R 714 0 R 715 0 R 716 0 R 717 0 R 718 0 R 719 0 R 720 0 R 721 0 R 722 0 R 723 0 R 724 0 R 725 0 R 726 0 R 727 0 R 728 0 R 729 0 R 730 0 R 731 0 R 732 0 R 733 0 R 734 0 R 735 0 R 736 0 R 737 0 R 738 0 R 739 0 R 740 0 R 741 0 R 742 0 R 743 0 R 744 0 R 745 0 R 746 0 R 747 0 R 748 0 R 749 0 R 750 0 R 751 0 R 752 0 R 753 0 R 754 0 R 755 0 R 756 0 R]endobj 758 0 obj<>endobj 759 0 obj<>endobj 760 0 obj<>endobj 761 0 obj<>endobj 762 0 obj<>endobj 763 0 obj<>endobj 764 0 obj<>endobj 765 0 obj<>endobj 766 0 obj<>endobj 767 0 obj<>endobj 768 0 obj<>endobj 769 0 obj<>endobj 770 0 obj<>endobj 771 0 obj<>endobj 772 0 obj<>endobj 773 0 obj<>endobj 774 0 obj<>endobj 775 0 obj<>endobj 776 0 obj<>endobj 777 0 obj<>endobj 778 0 obj<>endobj 779 0 obj<>endobj 780 0 obj<>endobj 781 0 obj<>endobj 782 0 obj<>endobj 783 0 obj<>endobj 784 0 obj<>endobj 785 0 obj<>endobj 786 0 obj<>endobj 787 0 obj<>endobj 788 0 obj<>endobj 789 0 obj<>endobj 790 0 obj<>endobj 791 0 obj<>endobj 792 0 obj<>endobj 793 0 obj<>endobj 794 0 obj<>endobj 795 0 obj<>endobj 796 0 obj<>endobj 797 0 obj<>endobj 798 0 obj<>endobj 799 0 obj<>endobj 800 0 obj<>endobj 801 0 obj<>endobj 802 0 obj<>endobj 803 0 obj<>endobj 804 0 obj<>endobj 805 0 obj<>endobj 806 0 obj<>endobj 807 0 obj<>endobj 808 0 obj<>endobj 809 0 obj<>endobj 810 0 obj[758 0 R 759 0 R 760 0 R 761 0 R 762 0 R 763 0 R 764 0 R 765 0 R 766 0 R 767 0 R 768 0 R 769 0 R 770 0 R 771 0 R 772 0 R 773 0 R 774 0 R 775 0 R 776 0 R 777 0 R 778 0 R 779 0 R 780 0 R 781 0 R 782 0 R 783 0 R 784 0 R 785 0 R 786 0 R 787 0 R 788 0 R 789 0 R 790 0 R 791 0 R 792 0 R 793 0 R 794 0 R 795 0 R 796 0 R 797 0 R 798 0 R 799 0 R 800 0 R 801 0 R 802 0 R 803 0 R 804 0 R 805 0 R 806 0 R 807 0 R 808 0 R 809 0 R]endobj 811 0 obj<>endobj 812 0 obj<>endobj 813 0 obj<>endobj 814 0 obj<>endobj 815 0 obj<>endobj 816 0 obj<>endobj 817 0 obj<>endobj 818 0 obj<>endobj 819 0 obj<>endobj 820 0 obj<>endobj 821 0 obj<>endobj 822 0 obj<>endobj 823 0 obj<>endobj 824 0 obj<>endobj 825 0 obj<>endobj 826 0 obj<>endobj 827 0 obj<>endobj 828 0 obj<>endobj 829 0 obj<>endobj 830 0 obj<>endobj 831 0 obj<>endobj 832 0 obj<>endobj 833 0 obj<>endobj 834 0 obj<>endobj 835 0 obj<>endobj 836 0 obj<>endobj 837 0 obj<>endobj 838 0 obj<>endobj 839 0 obj<>endobj 840 0 obj<>endobj 841 0 obj<>endobj 842 0 obj<>endobj 843 0 obj<>endobj 844 0 obj<>endobj 845 0 obj<>endobj 846 0 obj<>endobj 847 0 obj<>endobj 848 0 obj<>endobj 849 0 obj<>endobj 850 0 obj<>endobj 851 0 obj<>endobj 852 0 obj<>endobj 853 0 obj<>endobj 854 0 obj<>endobj 855 0 obj<>endobj 856 0 obj<>endobj 857 0 obj<>endobj 858 0 obj<>endobj 859 0 obj<>endobj 860 0 obj<>endobj 861 0 obj<>endobj 862 0 obj<>endobj 863 0 obj[811 0 R 812 0 R 813 0 R 814 0 R 815 0 R 816 0 R 817 0 R 818 0 R 819 0 R 820 0 R 821 0 R 822 0 R 823 0 R 824 0 R 825 0 R 826 0 R 827 0 R 828 0 R 829 0 R 830 0 R 831 0 R 832 0 R 833 0 R 834 0 R 835 0 R 836 0 R 837 0 R 838 0 R 839 0 R 840 0 R 841 0 R 842 0 R 843 0 R 844 0 R 845 0 R 846 0 R 847 0 R 848 0 R 849 0 R 850 0 R 851 0 R 852 0 R 853 0 R 854 0 R 855 0 R 856 0 R 857 0 R 858 0 R 859 0 R 860 0 R 861 0 R 862 0 R]endobj 864 0 obj<>endobj 865 0 obj<>endobj 866 0 obj<>endobj 867 0 obj<>endobj 868 0 obj<>endobj 869 0 obj<>endobj 870 0 obj<>endobj 871 0 obj<>endobj 872 0 obj<>endobj 873 0 obj<>endobj 874 0 obj<>endobj 875 0 obj<>endobj 876 0 obj<>endobj 877 0 obj<>endobj 878 0 obj<>endobj 879 0 obj<>endobj 880 0 obj<>endobj 881 0 obj<>endobj 882 0 obj<>endobj 883 0 obj<>endobj 884 0 obj<>endobj 885 0 obj<>endobj 886 0 obj<>endobj 887 0 obj<>endobj 888 0 obj<>endobj 889 0 obj<>endobj 890 0 obj<>endobj 891 0 obj<>endobj 892 0 obj<>endobj 893 0 obj<>endobj 894 0 obj<>endobj 895 0 obj<>endobj 896 0 obj<>endobj 897 0 obj<>endobj 898 0 obj<>endobj 899 0 obj<>endobj 900 0 obj<>endobj 901 0 obj<>endobj 902 0 obj<>endobj 903 0 obj<>endobj 904 0 obj<>endobj 905 0 obj<>endobj 906 0 obj<>endobj 907 0 obj<>endobj 908 0 obj<>endobj 909 0 obj<>endobj 910 0 obj<>endobj 911 0 obj<>endobj 912 0 obj<>endobj 913 0 obj<>endobj 914 0 obj<>endobj 915 0 obj<>endobj 916 0 obj<>endobj 917 0 obj[864 0 R 865 0 R 866 0 R 867 0 R 868 0 R 869 0 R 870 0 R 871 0 R 872 0 R 873 0 R 874 0 R 875 0 R 876 0 R 877 0 R 878 0 R 879 0 R 880 0 R 881 0 R 882 0 R 883 0 R 884 0 R 885 0 R 886 0 R 887 0 R 888 0 R 889 0 R 890 0 R 891 0 R 892 0 R 893 0 R 894 0 R 895 0 R 896 0 R 897 0 R 898 0 R 899 0 R 900 0 R 901 0 R 902 0 R 903 0 R 904 0 R 905 0 R 906 0 R 907 0 R 908 0 R 909 0 R 910 0 R 911 0 R 912 0 R 913 0 R 914 0 R 915 0 R 916 0 R]endobj 918 0 obj<>endobj 919 0 obj<>endobj 920 0 obj<>endobj 921 0 obj<>endobj 922 0 obj<>endobj 923 0 obj<>endobj 924 0 obj<>endobj 925 0 obj<>endobj 926 0 obj<>endobj 927 0 obj<>endobj 928 0 obj<>endobj 929 0 obj<>endobj 930 0 obj<>endobj 931 0 obj<>endobj 932 0 obj<>endobj 933 0 obj<>endobj 934 0 obj<>endobj 935 0 obj<>endobj 936 0 obj<>endobj 937 0 obj<>endobj 938 0 obj<>endobj 939 0 obj<>endobj 940 0 obj<>endobj 941 0 obj<>endobj 942 0 obj<>endobj 943 0 obj<>endobj 944 0 obj<>endobj 945 0 obj<>endobj 946 0 obj<>endobj 947 0 obj<>endobj 948 0 obj<>endobj 949 0 obj<>endobj 950 0 obj<>endobj 951 0 obj<>endobj 952 0 obj<>endobj 953 0 obj<>endobj 954 0 obj<>endobj 955 0 obj<>endobj 956 0 obj<>endobj 957 0 obj<>endobj 958 0 obj<>endobj 959 0 obj<>endobj 960 0 obj<>endobj 961 0 obj<>endobj 962 0 obj<>endobj 963 0 obj<>endobj 964 0 obj<>endobj 965 0 obj<>endobj 966 0 obj<>endobj 967 0 obj<>endobj 968 0 obj<>endobj 969 0 obj[918 0 R 919 0 R 920 0 R 921 0 R 922 0 R 923 0 R 924 0 R 925 0 R 926 0 R 927 0 R 928 0 R 929 0 R 930 0 R 931 0 R 932 0 R 933 0 R 934 0 R 935 0 R 936 0 R 937 0 R 938 0 R 939 0 R 940 0 R 941 0 R 942 0 R 943 0 R 944 0 R 945 0 R 946 0 R 947 0 R 948 0 R 949 0 R 950 0 R 951 0 R 952 0 R 953 0 R 954 0 R 955 0 R 956 0 R 957 0 R 958 0 R 959 0 R 960 0 R 961 0 R 962 0 R 963 0 R 964 0 R 965 0 R 966 0 R 967 0 R 968 0 R]endobj 970 0 obj<>endobj 971 0 obj<>endobj 972 0 obj<>endobj 973 0 obj<>endobj 974 0 obj<>endobj 975 0 obj<>endobj 976 0 obj<>endobj 977 0 obj<>endobj 978 0 obj<>endobj 979 0 obj<>endobj 980 0 obj<>endobj 981 0 obj<>endobj 982 0 obj<>endobj 983 0 obj<>endobj 984 0 obj<>endobj 985 0 obj<>endobj 986 0 obj<>endobj 987 0 obj<>endobj 988 0 obj<>endobj 989 0 obj<>endobj 990 0 obj<>endobj 991 0 obj<>endobj 992 0 obj<>endobj 993 0 obj<>endobj 994 0 obj<>endobj 995 0 obj<>endobj 996 0 obj<>endobj 997 0 obj<>endobj 998 0 obj<>endobj 999 0 obj<>endobj 1000 0 obj<>endobj 1001 0 obj<>endobj 1002 0 obj<>endobj 1003 0 obj<>endobj 1004 0 obj<>endobj 1005 0 obj<>endobj 1006 0 obj<>endobj 1007 0 obj<>endobj 1008 0 obj<>endobj 1009 0 obj<>endobj 1010 0 obj<>endobj 1011 0 obj<>endobj 1012 0 obj<>endobj 1013 0 obj<>endobj 1014 0 obj<>endobj 1015 0 obj<>endobj 1016 0 obj<>endobj 1017 0 obj<>endobj 1018 0 obj<>endobj 1019 0 obj<>endobj 1020 0 obj<>endobj 1021 0 obj<>endobj 1022 0 obj<>endobj 1023 0 obj<>endobj 1024 0 obj[970 0 R 971 0 R 972 0 R 973 0 R 974 0 R 975 0 R 976 0 R 977 0 R 978 0 R 979 0 R 980 0 R 981 0 R 982 0 R 983 0 R 984 0 R 985 0 R 986 0 R 987 0 R 988 0 R 989 0 R 990 0 R 991 0 R 992 0 R 993 0 R 994 0 R 995 0 R 996 0 R 997 0 R 998 0 R 999 0 R 1000 0 R 1001 0 R 1002 0 R 1003 0 R 1004 0 R 1005 0 R 1006 0 R 1007 0 R 1008 0 R 1009 0 R 1010 0 R 1011 0 R 1012 0 R 1013 0 R 1014 0 R 1015 0 R 1016 0 R 1017 0 R 1018 0 R 1019 0 R 1020 0 R 1021 0 R 1022 0 R 1023 0 R]endobj 1025 0 obj<>endobj 1026 0 obj<>endobj 1027 0 obj<>endobj 1028 0 obj<>endobj 1029 0 obj<>endobj 1030 0 obj<>endobj 1031 0 obj<>endobj 1032 0 obj<>endobj 1033 0 obj<>endobj 1034 0 obj<>endobj 1035 0 obj<>endobj 1036 0 obj<>endobj 1037 0 obj<>endobj 1038 0 obj<>endobj 1039 0 obj<>endobj 1040 0 obj<>endobj 1041 0 obj<>endobj 1042 0 obj<>endobj 1043 0 obj<>endobj 1044 0 obj<>endobj 1045 0 obj<>endobj 1046 0 obj<>endobj 1047 0 obj<>endobj 1048 0 obj<>endobj 1049 0 obj<>endobj 1050 0 obj<>endobj 1051 0 obj<>endobj 1052 0 obj<>endobj 1053 0 obj<>endobj 1054 0 obj<>endobj 1055 0 obj<>endobj 1056 0 obj<>endobj 1057 0 obj<>endobj 1058 0 obj<>endobj 1059 0 obj<>endobj 1060 0 obj<>endobj 1061 0 obj<>endobj 1062 0 obj<>endobj 1063 0 obj<>endobj 1064 0 obj<>endobj 1065 0 obj<>endobj 1066 0 obj<>endobj 1067 0 obj<>endobj 1068 0 obj<>endobj 1069 0 obj<>endobj 1070 0 obj<>endobj 1071 0 obj<>endobj 1072 0 obj<>endobj 1073 0 obj<>endobj 1074 0 obj<>endobj 1075 0 obj<>endobj 1076 0 obj<>endobj 1077 0 obj[1025 0 R 1026 0 R 1027 0 R 1028 0 R 1029 0 R 1030 0 R 1031 0 R 1032 0 R 1033 0 R 1034 0 R 1035 0 R 1036 0 R 1037 0 R 1038 0 R 1039 0 R 1040 0 R 1041 0 R 1042 0 R 1043 0 R 1044 0 R 1045 0 R 1046 0 R 1047 0 R 1048 0 R 1049 0 R 1050 0 R 1051 0 R 1052 0 R 1053 0 R 1054 0 R 1055 0 R 1056 0 R 1057 0 R 1058 0 R 1059 0 R 1060 0 R 1061 0 R 1062 0 R 1063 0 R 1064 0 R 1065 0 R 1066 0 R 1067 0 R 1068 0 R 1069 0 R 1070 0 R 1071 0 R 1072 0 R 1073 0 R 1074 0 R 1075 0 R 1076 0 R]endobj 1078 0 obj<>endobj 1079 0 obj<>endobj 1080 0 obj<>endobj 1081 0 obj<>endobj 1082 0 obj<>endobj 1083 0 obj<>endobj 1084 0 obj<>endobj 1085 0 obj<>endobj 1086 0 obj<>endobj 1087 0 obj<>endobj 1088 0 obj<>endobj 1089 0 obj<>endobj 1090 0 obj<>endobj 1091 0 obj<>endobj 1092 0 obj<>endobj 1093 0 obj<>endobj 1094 0 obj<>endobj 1095 0 obj<>endobj 1096 0 obj<>endobj 1097 0 obj<>endobj 1098 0 obj<>endobj 1099 0 obj<>endobj 1100 0 obj<>endobj 1101 0 obj<>endobj 1102 0 obj<>endobj 1103 0 obj<>endobj 1104 0 obj<>endobj 1105 0 obj<>endobj 1106 0 obj<>endobj 1107 0 obj<>endobj 1108 0 obj<>endobj 1109 0 obj<>endobj 1110 0 obj<>endobj 1111 0 obj<>endobj 1112 0 obj<>endobj 1113 0 obj<>endobj 1114 0 obj<>endobj 1115 0 obj<>endobj 1116 0 obj<>endobj 1117 0 obj<>endobj 1118 0 obj<>endobj 1119 0 obj<>endobj 1120 0 obj<>endobj 1121 0 obj<>endobj 1122 0 obj<>endobj 1123 0 obj<>endobj 1124 0 obj<>endobj 1125 0 obj<>endobj 1126 0 obj<>endobj 1127 0 obj<>endobj 1128 0 obj<>endobj 1129 0 obj<>endobj 1130 0 obj<>endobj 1131 0 obj<>endobj 1132 0 obj[1078 0 R 1079 0 R 1080 0 R 1081 0 R 1082 0 R 1083 0 R 1084 0 R 1085 0 R 1086 0 R 1087 0 R 1088 0 R 1089 0 R 1090 0 R 1091 0 R 1092 0 R 1093 0 R 1094 0 R 1095 0 R 1096 0 R 1097 0 R 1098 0 R 1099 0 R 1100 0 R 1101 0 R 1102 0 R 1103 0 R 1104 0 R 1105 0 R 1106 0 R 1107 0 R 1108 0 R 1109 0 R 1110 0 R 1111 0 R 1112 0 R 1113 0 R 1114 0 R 1115 0 R 1116 0 R 1117 0 R 1118 0 R 1119 0 R 1120 0 R 1121 0 R 1122 0 R 1123 0 R 1124 0 R 1125 0 R 1126 0 R 1127 0 R 1128 0 R 1129 0 R 1130 0 R 1131 0 R]endobj 1133 0 obj<>endobj 1134 0 obj<>endobj 1135 0 obj<>endobj 1136 0 obj<>endobj 1137 0 obj<>endobj 1138 0 obj<>endobj 1139 0 obj<>endobj 1140 0 obj<>endobj 1141 0 obj<>endobj 1142 0 obj<>endobj 1143 0 obj<>endobj 1144 0 obj<>endobj 1145 0 obj<>endobj 1146 0 obj<>endobj 1147 0 obj<>endobj 1148 0 obj<>endobj 1149 0 obj<>endobj 1150 0 obj<>endobj 1151 0 obj<>endobj 1152 0 obj<>endobj 1153 0 obj<>endobj 1154 0 obj<>endobj 1155 0 obj<>endobj 1156 0 obj<>endobj 1157 0 obj<>endobj 1158 0 obj<>endobj 1159 0 obj<>endobj 1160 0 obj<>endobj 1161 0 obj<>endobj 1162 0 obj<>endobj 1163 0 obj<>endobj 1164 0 obj<>endobj 1165 0 obj<>endobj 1166 0 obj<>endobj 1167 0 obj<>endobj 1168 0 obj<>endobj 1169 0 obj<>endobj 1170 0 obj<>endobj 1171 0 obj<>endobj 1172 0 obj<>endobj 1173 0 obj<>endobj 1174 0 obj<>endobj 1175 0 obj<>endobj 1176 0 obj<>endobj 1177 0 obj<>endobj 1178 0 obj<>endobj 1179 0 obj<>endobj 1180 0 obj<>endobj 1181 0 obj<>endobj 1182 0 obj<>endobj 1183 0 obj<>endobj 1184 0 obj<>endobj 1185 0 obj<>endobj 1186 0 obj[1133 0 R 1134 0 R 1135 0 R 1136 0 R 1137 0 R 1138 0 R 1139 0 R 1140 0 R 1141 0 R 1142 0 R 1143 0 R 1144 0 R 1145 0 R 1146 0 R 1147 0 R 1148 0 R 1149 0 R 1150 0 R 1151 0 R 1152 0 R 1153 0 R 1154 0 R 1155 0 R 1156 0 R 1157 0 R 1158 0 R 1159 0 R 1160 0 R 1161 0 R 1162 0 R 1163 0 R 1164 0 R 1165 0 R 1166 0 R 1167 0 R 1168 0 R 1169 0 R 1170 0 R 1171 0 R 1172 0 R 1173 0 R 1174 0 R 1175 0 R 1176 0 R 1177 0 R 1178 0 R 1179 0 R 1180 0 R 1181 0 R 1182 0 R 1183 0 R 1184 0 R 1185 0 R]endobj 1187 0 obj<>endobj 1188 0 obj<>endobj 1189 0 obj<>endobj 1190 0 obj<>endobj 1191 0 obj<>endobj 1192 0 obj<>endobj 1193 0 obj<>endobj 1194 0 obj<>endobj 1195 0 obj<>endobj 1196 0 obj<>endobj 1197 0 obj<>endobj 1198 0 obj<>endobj 1199 0 obj<>endobj 1200 0 obj<>endobj 1201 0 obj<>endobj 1202 0 obj<>endobj 1203 0 obj<>endobj 1204 0 obj<>endobj 1205 0 obj<>endobj 1206 0 obj<>endobj 1207 0 obj<>endobj 1208 0 obj<>endobj 1209 0 obj<>endobj 1210 0 obj<>endobj 1211 0 obj<>endobj 1212 0 obj<>endobj 1213 0 obj<>endobj 1214 0 obj<>endobj 1215 0 obj<>endobj 1216 0 obj<>endobj 1217 0 obj<>endobj 1218 0 obj<>endobj 1219 0 obj<>endobj 1220 0 obj<>endobj 1221 0 obj<>endobj 1222 0 obj<>endobj 1223 0 obj<>endobj 1224 0 obj<>endobj 1225 0 obj<>endobj 1226 0 obj<>endobj 1227 0 obj<>endobj 1228 0 obj<>endobj 1229 0 obj<>endobj 1230 0 obj<>endobj 1231 0 obj<>endobj 1232 0 obj<>endobj 1233 0 obj<>endobj 1234 0 obj<>endobj 1235 0 obj<>endobj 1236 0 obj<>endobj 1237 0 obj<>endobj 1238 0 obj<>endobj 1239 0 obj<>endobj 1240 0 obj[1187 0 R 1188 0 R 1189 0 R 1190 0 R 1191 0 R 1192 0 R 1193 0 R 1194 0 R 1195 0 R 1196 0 R 1197 0 R 1198 0 R 1199 0 R 1200 0 R 1201 0 R 1202 0 R 1203 0 R 1204 0 R 1205 0 R 1206 0 R 1207 0 R 1208 0 R 1209 0 R 1210 0 R 1211 0 R 1212 0 R 1213 0 R 1214 0 R 1215 0 R 1216 0 R 1217 0 R 1218 0 R 1219 0 R 1220 0 R 1221 0 R 1222 0 R 1223 0 R 1224 0 R 1225 0 R 1226 0 R 1227 0 R 1228 0 R 1229 0 R 1230 0 R 1231 0 R 1232 0 R 1233 0 R 1234 0 R 1235 0 R 1236 0 R 1237 0 R 1238 0 R 1239 0 R]endobj 1241 0 obj<>endobj 1242 0 obj<>endobj 1243 0 obj<>endobj 1244 0 obj<>endobj 1245 0 obj<>endobj 1246 0 obj<>endobj 1247 0 obj<>endobj 1248 0 obj<>endobj 1249 0 obj<>endobj 1250 0 obj<>endobj 1251 0 obj<>endobj 1252 0 obj<>endobj 1253 0 obj<>endobj 1254 0 obj<>endobj 1255 0 obj<>endobj 1256 0 obj<>endobj 1257 0 obj<>endobj 1258 0 obj<>endobj 1259 0 obj[1241 0 R 1242 0 R 1243 0 R 1244 0 R 1245 0 R 1246 0 R 1247 0 R 1248 0 R 1249 0 R 1250 0 R 1251 0 R 1252 0 R 1253 0 R 1254 0 R 1255 0 R 1256 0 R 1257 0 R 1258 0 R]endobj 1260 0 obj<>endobj 1261 0 obj<>endobj 1262 0 obj<>endobj 1263 0 obj<>endobj 1264 0 obj<>endobj 1265 0 obj<>endobj 1266 0 obj<>endobj 1267 0 obj<>endobj 1268 0 obj<>endobj 1269 0 obj<>endobj 1270 0 obj<>endobj 1271 0 obj<>endobj 1272 0 obj<>endobj 1273 0 obj<>endobj 1274 0 obj<>endobj 1275 0 obj<>endobj 1276 0 obj<>endobj 1277 0 obj<>endobj 1278 0 obj<>endobj 1279 0 obj<>endobj 1280 0 obj<>endobj 1281 0 obj<>endobj 1282 0 obj<>endobj 1283 0 obj<>endobj 1284 0 obj<>endobj 1285 0 obj<>endobj 1286 0 obj<>endobj 1287 0 obj<>endobj 1288 0 obj<>endobj 1289 0 obj<>endobj 1290 0 obj<>endobj 1291 0 obj<>endobj 1292 0 obj<>endobj 1293 0 obj<>endobj 1294 0 obj<>endobj 1295 0 obj<>endobj 1296 0 obj<>endobj 1297 0 obj<>endobj 1298 0 obj<>endobj 1299 0 obj<>endobj 1300 0 obj[1260 0 R 1261 0 R 1262 0 R 1263 0 R 1264 0 R 1265 0 R 1266 0 R 1267 0 R 1268 0 R 1269 0 R 1270 0 R 1271 0 R 1272 0 R 1273 0 R 1274 0 R 1275 0 R 1276 0 R 1277 0 R 1278 0 R 1279 0 R 1280 0 R 1281 0 R 1282 0 R 1283 0 R 1284 0 R 1285 0 R 1286 0 R 1287 0 R 1288 0 R 1289 0 R 1290 0 R 1291 0 R 1292 0 R 1293 0 R 1294 0 R 1295 0 R 1296 0 R 1297 0 R 1298 0 R 1299 0 R]endobj 1301 0 obj<>endobj 1302 0 obj<>endobj 1303 0 obj<>endobj 1304 0 obj<>endobj 1305 0 obj<>endobj 1306 0 obj<>endobj 1307 0 obj<>endobj 1308 0 obj<>endobj 1309 0 obj<>endobj 1310 0 obj<>endobj 1311 0 obj<>endobj 1312 0 obj<>endobj 1313 0 obj<>endobj 1314 0 obj<>endobj 1315 0 obj<>endobj 1316 0 obj<>endobj 1317 0 obj<>endobj 1318 0 obj<>endobj 1319 0 obj<>endobj 1320 0 obj<>endobj 1321 0 obj<>endobj 1322 0 obj[1301 0 R 1302 0 R 1303 0 R 1304 0 R 1305 0 R 1306 0 R 1307 0 R 1308 0 R 1309 0 R 1310 0 R 1311 0 R 1312 0 R 1313 0 R 1314 0 R 1315 0 R 1316 0 R 1317 0 R 1319 0 R 1321 0 R]endobj 1323 0 obj<>endobj 1324 0 obj<>endobj 1325 0 obj<>endobj 1326 0 obj<>endobj 1327 0 obj<>endobj 1328 0 obj[1324 0 R 1326 0 R 1327 0 R]endobj 1329 0 obj<>endobj 1330 0 obj<>endobj 1331 0 obj<>endobj 1332 0 obj<>endobj 1333 0 obj<>endobj 1334 0 obj<>endobj 1335 0 obj<>endobj 1336 0 obj<>endobj 1337 0 obj<>endobj 1338 0 obj<>endobj 1339 0 obj<>endobj 1340 0 obj[1330 0 R 1332 0 R 1334 0 R 1335 0 R 1337 0 R 1339 0 R]endobj 1341 0 obj<>endobj 1342 0 obj<>endobj 1343 0 obj<>endobj 1344 0 obj<>endobj 1345 0 obj<>endobj 1346 0 obj[1341 0 R 1343 0 R 1345 0 R]endobj 1347 0 obj<>endobj 1348 0 obj<>endobj 1349 0 obj<>endobj 1350 0 obj<>endobj 1351 0 obj<>endobj 1352 0 obj<>endobj 1353 0 obj<>endobj 1354 0 obj<>endobj 1355 0 obj<>endobj 1356 0 obj<>endobj 1357 0 obj<>endobj 1358 0 obj<>endobj 1359 0 obj<>endobj 1360 0 obj[1347 0 R 1348 0 R 1349 0 R 1350 0 R 1351 0 R 1352 0 R 1353 0 R 1354 0 R 1355 0 R 1356 0 R 1357 0 R 1358 0 R 1359 0 R]endobj 1361 0 obj<>endobj 1362 0 obj<>endobj 1363 0 obj<>endobj 1364 0 obj<>endobj 1365 0 obj<>endobj 1366 0 obj<>endobj 1367 0 obj<>endobj 1368 0 obj<>endobj 1369 0 obj<>endobj 1370 0 obj<>endobj 1371 0 obj<>endobj 1372 0 obj<>endobj 1373 0 obj[1362 0 R 1364 0 R 1366 0 R 1368 0 R 1370 0 R 1372 0 R]endobj 1374 0 obj<>endobj 1375 0 obj<>endobj 1376 0 obj<>endobj 1377 0 obj<>endobj 1378 0 obj<>endobj 1379 0 obj<>endobj 1380 0 obj<>endobj 1381 0 obj<>endobj 1382 0 obj<>endobj 1383 0 obj<>endobj 1384 0 obj<>endobj 1385 0 obj<>endobj 1386 0 obj<>endobj 1387 0 obj<>endobj 1388 0 obj<>endobj 1389 0 obj<>endobj 1390 0 obj<>endobj 1391 0 obj<>endobj 1392 0 obj<>endobj 1393 0 obj<>endobj 1394 0 obj<>endobj 1395 0 obj<>endobj 1396 0 obj<>endobj 1397 0 obj<>endobj 1398 0 obj[1374 0 R 1375 0 R 1376 0 R 1377 0 R 1378 0 R 1379 0 R 1380 0 R 1381 0 R 1382 0 R 1383 0 R 1384 0 R 1385 0 R 1386 0 R 1387 0 R 1388 0 R 1389 0 R 1390 0 R 1391 0 R 1392 0 R 1394 0 R 1395 0 R 1396 0 R 1397 0 R]endobj 1399 0 obj<>endobj 1400 0 obj<>endobj 1401 0 obj<>endobj 1402 0 obj<>endobj 1403 0 obj<>endobj 1404 0 obj<>endobj 1405 0 obj<>endobj 1406 0 obj<>endobj 1407 0 obj<>endobj 1408 0 obj<>endobj 1409 0 obj<>endobj 1410 0 obj<>endobj 1411 0 obj[1400 0 R 1402 0 R 1404 0 R 1406 0 R 1408 0 R 1410 0 R]endobj 1412 0 obj<>endobj 1413 0 obj<>endobj 1414 0 obj<>endobj 1415 0 obj<>endobj 1416 0 obj<>endobj 1417 0 obj<>endobj 1418 0 obj[1413 0 R 1415 0 R 1417 0 R]endobj 1419 0 obj<>endobj 1420 0 obj<>endobj 1421 0 obj<>endobj 1422 0 obj<>endobj 1423 0 obj<>endobj 1424 0 obj<>endobj 1425 0 obj<>endobj 1426 0 obj<>endobj 1427 0 obj<>endobj 1428 0 obj<>endobj 1429 0 obj<>endobj 1430 0 obj[1419 0 R 1420 0 R 1421 0 R 1422 0 R 1423 0 R 1424 0 R 1425 0 R 1426 0 R 1427 0 R 1428 0 R 1429 0 R]endobj 1431 0 obj<>endobj 1432 0 obj<>endobj 1433 0 obj<>endobj 1434 0 obj<>endobj 1435 0 obj<>endobj 1436 0 obj<>endobj 1437 0 obj<>endobj 1438 0 obj<>endobj 1439 0 obj<>endobj 1440 0 obj<>endobj 1441 0 obj<>endobj 1442 0 obj<>endobj 1443 0 obj<>endobj 1444 0 obj<>endobj 1445 0 obj<>endobj 1446 0 obj<>endobj 1447 0 obj<>endobj 1448 0 obj<>endobj 1449 0 obj<>endobj 1450 0 obj<>endobj 1451 0 obj<>endobj 1452 0 obj<>endobj 1453 0 obj<>endobj 1454 0 obj<>endobj 1455 0 obj<>endobj 1456 0 obj<>endobj 1457 0 obj<>endobj 1458 0 obj<>endobj 1459 0 obj<>endobj 1460 0 obj<>endobj 1461 0 obj<>endobj 1462 0 obj<>endobj 1463 0 obj<>endobj 1464 0 obj<>endobj 1465 0 obj<>endobj 1466 0 obj<>endobj 1467 0 obj<>endobj 1468 0 obj<>endobj 1469 0 obj<>endobj 1470 0 obj<>endobj 1471 0 obj<>endobj 1472 0 obj<>endobj 1473 0 obj<>endobj 1474 0 obj<>endobj 1475 0 obj<>endobj 1476 0 obj<>endobj 1477 0 obj<>endobj 1478 0 obj<>endobj 1479 0 obj<>endobj 1480 0 obj<>endobj 1481 0 obj<>endobj 1482 0 obj<>endobj 1483 0 obj<>endobj 1484 0 obj<>endobj 1485 0 obj<>endobj 1486 0 obj<>endobj 1487 0 obj[1431 0 R 1432 0 R 1433 0 R 1434 0 R 1435 0 R 1436 0 R 1437 0 R 1438 0 R 1439 0 R 1440 0 R 1441 0 R 1442 0 R 1443 0 R 1444 0 R 1445 0 R 1446 0 R 1447 0 R 1448 0 R 1449 0 R 1450 0 R 1451 0 R 1452 0 R 1453 0 R 1454 0 R 1455 0 R 1456 0 R 1457 0 R 1458 0 R 1459 0 R 1460 0 R 1461 0 R 1462 0 R 1463 0 R 1464 0 R 1465 0 R 1466 0 R 1467 0 R 1468 0 R 1469 0 R 1470 0 R 1471 0 R 1472 0 R 1473 0 R 1474 0 R 1475 0 R 1476 0 R 1477 0 R 1478 0 R 1479 0 R 1480 0 R 1481 0 R 1482 0 R 1483 0 R 1484 0 R 1485 0 R 1486 0 R]endobj 1488 0 obj<>endobj 1489 0 obj[1488 0 R]endobj 1490 0 obj<>endobj 1491 0 obj[1490 0 R]endobj 1492 0 obj<>endobj 1493 0 obj[1492 0 R]endobj 1494 0 obj<>endobj 1495 0 obj[1494 0 R]endobj 1496 0 obj<>endobj 1497 0 obj<>endobj 1498 0 obj[1496 0 R 1497 0 R]endobj 1499 0 obj<>endobj 1500 0 obj[1499 0 R]endobj 1501 0 obj<>endobj 1502 0 obj<>endobj 1503 0 obj<>endobj 1504 0 obj<>endobj 1505 0 obj[1502 0 R 1504 0 R]endobj 1506 0 obj<>endobj 1507 0 obj[1506 0 R]endobj 1508 0 obj<>endobj 1509 0 obj[1508 0 R]endobj 1510 0 obj<>endobj 1511 0 obj<>endobj 1512 0 obj[1510 0 R 1511 0 R]endobj 1513 0 obj<>endobj 1514 0 obj[1513 0 R]endobj 1515 0 obj<>endobj 1516 0 obj[1515 0 R]endobj 1517 0 obj<>endobj 1518 0 obj<>endobj 1519 0 obj<>endobj 1520 0 obj<>endobj 1521 0 obj[1518 0 R 1520 0 R]endobj 1522 0 obj<>endobj 1523 0 obj<>endobj 1524 0 obj<>endobj 1525 0 obj<>endobj 1526 0 obj<>endobj 1527 0 obj<>endobj 1528 0 obj<>endobj 1529 0 obj<>endobj 1530 0 obj<>endobj 1531 0 obj<>endobj 1532 0 obj<>endobj 1533 0 obj<>endobj 1534 0 obj<>endobj 1535 0 obj<>endobj 1536 0 obj<>endobj 1537 0 obj<>endobj 1538 0 obj<>endobj 1539 0 obj<>endobj 1540 0 obj<>endobj 1541 0 obj<>endobj 1542 0 obj<>endobj 1543 0 obj<>endobj 1544 0 obj<>endobj 1545 0 obj<>endobj 1546 0 obj<>endobj 1547 0 obj<>endobj 1548 0 obj<>endobj 1549 0 obj<>endobj 1550 0 obj<>endobj 1551 0 obj<>endobj 1552 0 obj<>endobj 1553 0 obj<>endobj 1554 0 obj<>endobj 1555 0 obj<>endobj 1556 0 obj<>endobj 1557 0 obj<>endobj 1558 0 obj<>endobj 1559 0 obj<>endobj 1560 0 obj<>endobj 1561 0 obj<>endobj 1562 0 obj<>endobj 1563 0 obj<>endobj 1564 0 obj<>endobj 1565 0 obj<>endobj 1566 0 obj<>endobj 1567 0 obj[1522 0 R 1523 0 R 1524 0 R 1525 0 R 1526 0 R 1527 0 R 1528 0 R 1529 0 R 1530 0 R 1531 0 R 1532 0 R 1533 0 R 1534 0 R 1535 0 R 1536 0 R 1537 0 R 1538 0 R 1539 0 R 1540 0 R 1541 0 R 1542 0 R 1543 0 R 1544 0 R 1545 0 R 1546 0 R 1547 0 R 1548 0 R 1549 0 R 1550 0 R 1551 0 R 1552 0 R 1553 0 R 1554 0 R 1555 0 R 1556 0 R 1557 0 R 1558 0 R 1559 0 R 1560 0 R 1561 0 R 1562 0 R 1563 0 R 1564 0 R 1565 0 R 1566 0 R]endobj 1568 0 obj<>endobj 1569 0 obj[1568 0 R]endobj 1570 0 obj<>endobj 1571 0 obj[1570 0 R]endobj 1572 0 obj<>endobj 1573 0 obj[1572 0 R]endobj 1574 0 obj<>endobj 1575 0 obj[1574 0 R]endobj 1576 0 obj<>endobj 1577 0 obj<>endobj 1578 0 obj[1576 0 R 1577 0 R]endobj 1579 0 obj<>endobj 1580 0 obj<>endobj 1581 0 obj<>endobj 1582 0 obj<>endobj 1583 0 obj<>endobj 1584 0 obj[1579 0 R 1580 0 R 1581 0 R 1582 0 R 1583 0 R]endobj 1585 0 obj<>endobj 1586 0 obj[1585 0 R]endobj 1587 0 obj<>endobj 1588 0 obj[1587 0 R]endobj 1589 0 obj<>endobj 1590 0 obj<>endobj 1591 0 obj[1590 0 R]endobj 1592 0 obj<>endobj 1593 0 obj<>endobj 1594 0 obj[1593 0 R]endobj 1595 0 obj<>endobj 1596 0 obj[1595 0 R]endobj 1597 0 obj<>endobj 1598 0 obj<>endobj 1599 0 obj<>endobj 1600 0 obj[1597 0 R 1598 0 R 1599 0 R]endobj 1601 0 obj<>endobj 1602 0 obj[1601 0 R]endobj 1603 0 obj<>endobj 1604 0 obj[1603 0 R]endobj 1605 0 obj<>endobj 1606 0 obj<>endobj 1607 0 obj<>endobj 1608 0 obj[1605 0 R 1606 0 R 1607 0 R]endobj 1609 0 obj<>endobj 1610 0 obj[1609 0 R]endobj 1611 0 obj<>endobj 1612 0 obj[1611 0 R]endobj 1613 0 obj<>endobj 1614 0 obj<>endobj 1615 0 obj<>endobj 1616 0 obj<>endobj 1617 0 obj<>endobj 1618 0 obj<>endobj 1619 0 obj<>endobj 1620 0 obj<>endobj 1621 0 obj<>endobj 1622 0 obj<>endobj 1623 0 obj<>endobj 1624 0 obj<>endobj 1625 0 obj<>endobj 1626 0 obj<>endobj 1627 0 obj<>endobj 1628 0 obj<>endobj 1629 0 obj<>endobj 1630 0 obj<>endobj 1631 0 obj<>endobj 1632 0 obj<>endobj 1633 0 obj<>endobj 1634 0 obj<>endobj 1635 0 obj<>endobj 1636 0 obj<>endobj 1637 0 obj<>endobj 1638 0 obj<>endobj 1639 0 obj<>endobj 1640 0 obj<>endobj 1641 0 obj<>endobj 1642 0 obj<>endobj 1643 0 obj<>endobj 1644 0 obj<>endobj 1645 0 obj<>endobj 1646 0 obj<>endobj 1647 0 obj<>endobj 1648 0 obj<>endobj 1649 0 obj<>endobj 1650 0 obj<>endobj 1651 0 obj<>endobj 1652 0 obj<>endobj 1653 0 obj<>endobj 1654 0 obj[1613 0 R 1614 0 R 1615 0 R 1616 0 R 1617 0 R 1618 0 R 1619 0 R 1620 0 R 1621 0 R 1622 0 R 1623 0 R 1624 0 R 1625 0 R 1626 0 R 1627 0 R 1628 0 R 1629 0 R 1630 0 R 1631 0 R 1632 0 R 1633 0 R 1634 0 R 1635 0 R 1636 0 R 1637 0 R 1638 0 R 1639 0 R 1640 0 R 1641 0 R 1642 0 R 1643 0 R 1644 0 R 1645 0 R 1646 0 R 1647 0 R 1648 0 R 1649 0 R 1650 0 R 1651 0 R 1652 0 R 1653 0 R]endobj 1655 0 obj<>endobj 1656 0 obj[1655 0 R]endobj 1657 0 obj<>endobj 1658 0 obj[1657 0 R]endobj 1659 0 obj<>endobj 1660 0 obj<>endobj 1661 0 obj<>endobj 1662 0 obj<>endobj 1663 0 obj<>endobj 1664 0 obj<>endobj 1665 0 obj<>endobj 1666 0 obj<>endobj 1667 0 obj<>endobj 1668 0 obj<>endobj 1669 0 obj<>endobj 1670 0 obj<>endobj 1671 0 obj<>endobj 1672 0 obj<>endobj 1673 0 obj[1659 0 R 1660 0 R 1661 0 R 1662 0 R 1663 0 R 1664 0 R 1665 0 R 1666 0 R 1667 0 R 1668 0 R 1669 0 R 1670 0 R 1671 0 R 1672 0 R]endobj 1674 0 obj<>endobj 1675 0 obj[1674 0 R]endobj 1676 0 obj<>endobj 1677 0 obj<>endobj 1678 0 obj<>endobj 1679 0 obj<>endobj 1680 0 obj<>endobj 1681 0 obj<>endobj 1682 0 obj<>endobj 1683 0 obj<>endobj 1684 0 obj<>endobj 1685 0 obj<>endobj 1686 0 obj<>endobj 1687 0 obj<>endobj 1688 0 obj<>endobj 1689 0 obj<>endobj 1690 0 obj<>endobj 1691 0 obj<>endobj 1692 0 obj<>endobj 1693 0 obj<>endobj 1694 0 obj<>endobj 1695 0 obj[1676 0 R 1677 0 R 1678 0 R 1679 0 R 1680 0 R 1681 0 R 1682 0 R 1683 0 R 1684 0 R 1685 0 R 1686 0 R 1687 0 R 1688 0 R 1689 0 R 1690 0 R 1691 0 R 1692 0 R 1693 0 R 1694 0 R]endobj 1696 0 obj<>endobj 1697 0 obj[1696 0 R]endobj 1698 0 obj<>endobj 1699 0 obj[1698 0 R]endobj 1700 0 obj<>endobj 1701 0 obj<>endobj 1702 0 obj<>endobj 1703 0 obj<>endobj 1704 0 obj<>endobj 1705 0 obj<>endobj 1706 0 obj<>endobj 1707 0 obj<>endobj 1708 0 obj<>endobj 1709 0 obj<>endobj 1710 0 obj[1700 0 R 1701 0 R 1702 0 R 1703 0 R 1704 0 R 1705 0 R 1706 0 R 1707 0 R 1708 0 R 1709 0 R]endobj 1711 0 obj<>endobj 1712 0 obj<>endobj 1713 0 obj<>endobj 1714 0 obj<>endobj 1715 0 obj<>endobj 1716 0 obj<>endobj 1717 0 obj<>endobj 1718 0 obj<>endobj 1719 0 obj<>endobj 1720 0 obj<>endobj 1721 0 obj<>endobj 1722 0 obj<>endobj 1723 0 obj<>endobj 1724 0 obj<>endobj 1725 0 obj<>endobj 1726 0 obj<>endobj 1727 0 obj<>endobj 1728 0 obj<>endobj 1729 0 obj<>endobj 1730 0 obj<>endobj 1731 0 obj<>endobj 1732 0 obj<>endobj 1733 0 obj<>endobj 1734 0 obj<>endobj 1735 0 obj<>endobj 1736 0 obj<>endobj 1737 0 obj<>endobj 1738 0 obj<>endobj 1739 0 obj<>endobj 1740 0 obj<>endobj 1741 0 obj<>endobj 1742 0 obj<>endobj 1743 0 obj<>endobj 1744 0 obj<>endobj 1745 0 obj<>endobj 1746 0 obj<>endobj 1747 0 obj<>endobj 1748 0 obj<>endobj 1749 0 obj<>endobj 1750 0 obj<>endobj 1751 0 obj<>endobj 1752 0 obj<>endobj 1753 0 obj<>endobj 1754 0 obj<>endobj 1755 0 obj<>endobj 1756 0 obj<>endobj 1757 0 obj<>endobj 1758 0 obj<>endobj 1759 0 obj<>endobj 1760 0 obj<>endobj 1761 0 obj<>endobj 1762 0 obj<>endobj 1763 0 obj<>endobj 1764 0 obj[1711 0 R 1712 0 R 1713 0 R 1714 0 R 1715 0 R 1716 0 R 1717 0 R 1718 0 R 1719 0 R 1720 0 R 1721 0 R 1722 0 R 1723 0 R 1724 0 R 1725 0 R 1726 0 R 1727 0 R 1728 0 R 1729 0 R 1730 0 R 1731 0 R 1732 0 R 1733 0 R 1734 0 R 1735 0 R 1736 0 R 1737 0 R 1738 0 R 1739 0 R 1740 0 R 1741 0 R 1742 0 R 1743 0 R 1744 0 R 1745 0 R 1746 0 R 1747 0 R 1748 0 R 1749 0 R 1750 0 R 1751 0 R 1752 0 R 1753 0 R 1754 0 R 1755 0 R 1756 0 R 1757 0 R 1758 0 R 1759 0 R 1760 0 R 1761 0 R 1762 0 R 1763 0 R]endobj 1765 0 obj<>endobj 1766 0 obj<>endobj 1767 0 obj<>endobj 1768 0 obj<>endobj 1769 0 obj<>endobj 1770 0 obj<>endobj 1771 0 obj<>endobj 1772 0 obj<>endobj 1773 0 obj<>endobj 1774 0 obj<>endobj 1775 0 obj[1765 0 R 1766 0 R 1767 0 R 1768 0 R 1769 0 R 1770 0 R 1771 0 R 1772 0 R 1773 0 R 1774 0 R]endobj 1776 0 obj<>endobj 1777 0 obj<>endobj 1778 0 obj<>endobj 1779 0 obj<>endobj 1780 0 obj<>endobj 1781 0 obj<>endobj 1782 0 obj[1776 0 R 1778 0 R 1780 0 R 1781 0 R]endobj 1783 0 obj<>endobj 1784 0 obj<>endobj 1785 0 obj[1783 0 R 1784 0 R]endobj 1786 0 obj<>endobj 1787 0 obj[1786 0 R]endobj 1788 0 obj<>endobj 1789 0 obj[1788 0 R]endobj 1790 0 obj<>endobj 1791 0 obj[1790 0 R]endobj 1792 0 obj<>endobj 1793 0 obj[1792 0 R]endobj 1794 0 obj<>endobj 1795 0 obj[1794 0 R]endobj 1796 0 obj<>endobj 1797 0 obj<>endobj 1798 0 obj[1796 0 R 1797 0 R]endobj 1799 0 obj<>endobj 1800 0 obj<>endobj 1801 0 obj<>endobj 1802 0 obj<>endobj 1803 0 obj[1799 0 R 1800 0 R 1801 0 R 1802 0 R]endobj 1804 0 obj<>endobj 1805 0 obj[1804 0 R]endobj 1806 0 obj<>endobj 1807 0 obj[1806 0 R]endobj 1808 0 obj<>endobj 1809 0 obj[1808 0 R]endobj 1810 0 obj<>endobj 1811 0 obj[1810 0 R]endobj 1812 0 obj<>endobj 1813 0 obj[1812 0 R]endobj 1814 0 obj<>endobj 1815 0 obj[1814 0 R]endobj 1816 0 obj<>endobj 1817 0 obj<>endobj 1818 0 obj[1816 0 R 1817 0 R]endobj 1819 0 obj<>endobj 1820 0 obj[1819 0 R]endobj 1821 0 obj<>endobj 1822 0 obj<>endobj 1823 0 obj[1821 0 R 1822 0 R]endobj 1824 0 obj<>endobj 1825 0 obj[1824 0 R]endobj 1826 0 obj<>endobj 1827 0 obj<>endobj 1828 0 obj<>endobj 1829 0 obj<>endobj 1830 0 obj<>endobj 1831 0 obj<>endobj 1832 0 obj<>endobj 1833 0 obj<>endobj 1834 0 obj<>endobj 1835 0 obj<>endobj 1836 0 obj<>endobj 1837 0 obj<>endobj 1838 0 obj<>endobj 1839 0 obj<>endobj 1840 0 obj<>endobj 1841 0 obj<>endobj 1842 0 obj[1826 0 R 1827 0 R 1828 0 R 1829 0 R 1830 0 R 1831 0 R 1832 0 R 1833 0 R 1834 0 R 1835 0 R 1836 0 R 1837 0 R 1838 0 R 1839 0 R 1840 0 R 1841 0 R]endobj 1843 0 obj<>endobj 1844 0 obj<>endobj 1845 0 obj[1843 0 R 1844 0 R]endobj 1846 0 obj<>endobj 1847 0 obj[1846 0 R]endobj 1848 0 obj<>endobj 1849 0 obj<>endobj 1850 0 obj[1848 0 R 1849 0 R]endobj 1851 0 obj<>endobj 1852 0 obj<>endobj 1853 0 obj[1851 0 R 1852 0 R]endobj 1854 0 obj<>endobj 1855 0 obj<>endobj 1856 0 obj[1854 0 R 1855 0 R]endobj 1857 0 obj<>endobj 1858 0 obj<>endobj 1859 0 obj<>endobj 1860 0 obj<>endobj 1861 0 obj[1857 0 R 1858 0 R 1859 0 R 1860 0 R]endobj 1862 0 obj<>endobj 1863 0 obj<>endobj 1864 0 obj<>endobj 1865 0 obj<>endobj 1866 0 obj<>endobj 1867 0 obj<>endobj 1868 0 obj<>endobj 1869 0 obj<>endobj 1870 0 obj<>endobj 1871 0 obj[1862 0 R 1863 0 R 1864 0 R 1865 0 R 1866 0 R 1867 0 R 1868 0 R 1869 0 R 1870 0 R]endobj 1872 0 obj<>endobj 1873 0 obj<>endobj 1874 0 obj[1872 0 R 1873 0 R]endobj 1875 0 obj<>endobj 1876 0 obj<>endobj 1877 0 obj[1876 0 R]endobj 1878 0 obj<>endobj 1879 0 obj<>endobj 1880 0 obj<>endobj 1881 0 obj<>endobj 1882 0 obj<>endobj 1883 0 obj<>endobj 1884 0 obj<>endobj 1885 0 obj<>endobj 1886 0 obj<>endobj 1887 0 obj<>endobj 1888 0 obj<>endobj 1889 0 obj<>endobj 1890 0 obj<>endobj 1891 0 obj<>endobj 1892 0 obj<>endobj 1893 0 obj<>endobj 1894 0 obj<>endobj 1895 0 obj<>endobj 1896 0 obj[1878 0 R 1879 0 R 1880 0 R 1881 0 R 1882 0 R 1883 0 R 1884 0 R 1885 0 R 1886 0 R 1887 0 R 1888 0 R 1889 0 R 1890 0 R 1891 0 R 1892 0 R 1893 0 R 1894 0 R 1895 0 R]endobj 1897 0 obj<>endobj 1898 0 obj[1897 0 R]endobj 1899 0 obj<>endobj 1900 0 obj<>endobj 1901 0 obj<>endobj 1902 0 obj<>endobj 1903 0 obj<>endobj 1904 0 obj<>endobj 1905 0 obj<>endobj 1906 0 obj[1899 0 R 1900 0 R 1901 0 R 1902 0 R 1903 0 R 1904 0 R 1905 0 R]endobj 1907 0 obj<>endobj 1908 0 obj[1907 0 R]endobj 1909 0 obj<>endobj 1910 0 obj<>endobj 1911 0 obj[1909 0 R 1910 0 R]endobj 1912 0 obj<>endobj 1913 0 obj<>endobj 1914 0 obj<>endobj 1915 0 obj<>endobj 1916 0 obj<>endobj 1917 0 obj<>endobj 1918 0 obj<>endobj 1919 0 obj<>endobj 1920 0 obj<>endobj 1921 0 obj<>endobj 1922 0 obj<>endobj 1923 0 obj<>endobj 1924 0 obj<>endobj 1925 0 obj<>endobj 1926 0 obj<>endobj 1927 0 obj<>endobj 1928 0 obj<>endobj 1929 0 obj[1912 0 R 1913 0 R 1914 0 R 1915 0 R 1916 0 R 1917 0 R 1918 0 R 1919 0 R 1920 0 R 1921 0 R 1922 0 R 1923 0 R 1924 0 R 1925 0 R 1926 0 R 1927 0 R 1928 0 R]endobj 1930 0 obj<>endobj 1931 0 obj<>endobj 1932 0 obj[1931 0 R]endobj 1933 0 obj<>endobj 1934 0 obj<>endobj 1935 0 obj<>endobj 1936 0 obj<>endobj 1937 0 obj[1934 0 R 1936 0 R]endobj 1938 0 obj<>endobj 1939 0 obj<>endobj 1940 0 obj<>endobj 1941 0 obj<>endobj 1942 0 obj<>endobj 1943 0 obj<>endobj 1944 0 obj<>endobj 1945 0 obj<>endobj 1946 0 obj<>endobj 1947 0 obj<>endobj 1948 0 obj<>endobj 1949 0 obj<>endobj 1950 0 obj<>endobj 1951 0 obj<>endobj 1952 0 obj<>endobj 1953 0 obj<>endobj 1954 0 obj<>endobj 1955 0 obj<>endobj 1956 0 obj<>endobj 1957 0 obj<>endobj 1958 0 obj<>endobj 1959 0 obj<>endobj 1960 0 obj<>endobj 1961 0 obj<>endobj 1962 0 obj<>endobj 1963 0 obj<>endobj 1964 0 obj<>endobj 1965 0 obj<>endobj 1966 0 obj<>endobj 1967 0 obj<>endobj 1968 0 obj<>endobj 1969 0 obj<>endobj 1970 0 obj<>endobj 1971 0 obj<>endobj 1972 0 obj<>endobj 1973 0 obj<>endobj 1974 0 obj<>endobj 1975 0 obj<>endobj 1976 0 obj<>endobj 1977 0 obj<>endobj 1978 0 obj<>endobj 1979 0 obj<>endobj 1980 0 obj<>endobj 1981 0 obj<>endobj 1982 0 obj<>endobj 1983 0 obj<>endobj 1984 0 obj<>endobj 1985 0 obj<>endobj 1986 0 obj<>endobj 1987 0 obj<>endobj 1988 0 obj<>endobj 1989 0 obj<>endobj 1990 0 obj<>endobj 1991 0 obj[1938 0 R 1939 0 R 1940 0 R 1941 0 R 1942 0 R 1943 0 R 1944 0 R 1945 0 R 1946 0 R 1947 0 R 1948 0 R 1949 0 R 1950 0 R 1951 0 R 1952 0 R 1953 0 R 1954 0 R 1955 0 R 1956 0 R 1957 0 R 1958 0 R 1959 0 R 1960 0 R 1961 0 R 1962 0 R 1963 0 R 1964 0 R 1965 0 R 1966 0 R 1967 0 R 1968 0 R 1969 0 R 1970 0 R 1971 0 R 1972 0 R 1973 0 R 1974 0 R 1975 0 R 1976 0 R 1977 0 R 1978 0 R 1979 0 R 1980 0 R 1981 0 R 1982 0 R 1983 0 R 1984 0 R 1985 0 R 1986 0 R 1987 0 R 1988 0 R 1989 0 R 1990 0 R]endobj 1992 0 obj<>endobj 1993 0 obj<>endobj 1994 0 obj<>endobj 1995 0 obj[1992 0 R 1993 0 R 1994 0 R]endobj 1996 0 obj<>endobj 1997 0 obj[1996 0 R]endobj 1998 0 obj<>endobj 1999 0 obj<>endobj 2000 0 obj[1998 0 R 1999 0 R]endobj 2001 0 obj<>endobj 2002 0 obj<>endobj 2003 0 obj[2001 0 R 2002 0 R]endobj 2004 0 obj<>endobj 2005 0 obj<>endobj 2006 0 obj<>endobj 2007 0 obj<>endobj 2008 0 obj<>endobj 2009 0 obj<>endobj 2010 0 obj<>endobj 2011 0 obj<>endobj 2012 0 obj<>endobj 2013 0 obj<>endobj 2014 0 obj<>endobj 2015 0 obj<>endobj 2016 0 obj<>endobj 2017 0 obj<>endobj 2018 0 obj<>endobj 2019 0 obj[2004 0 R 2005 0 R 2006 0 R 2007 0 R 2008 0 R 2009 0 R 2010 0 R 2011 0 R 2013 0 R 2015 0 R 2016 0 R 2018 0 R]endobj 2020 0 obj<>endobj 2021 0 obj<>endobj 2022 0 obj[2021 0 R]endobj 2023 0 obj<>endobj 2024 0 obj<>endobj 2025 0 obj[2024 0 R]endobj 2026 0 obj<>endobj 2027 0 obj[2026 0 R]endobj 2028 0 obj<>endobj 2029 0 obj<>endobj 2030 0 obj<>endobj 2031 0 obj<>endobj 2032 0 obj<>endobj 2033 0 obj<>endobj 2034 0 obj<>endobj 2035 0 obj<>endobj 2036 0 obj<>endobj 2037 0 obj<>endobj 2038 0 obj<>endobj 2039 0 obj<>endobj 2040 0 obj<>endobj 2041 0 obj<>endobj 2042 0 obj<>endobj 2043 0 obj<>endobj 2044 0 obj<>endobj 2045 0 obj<>endobj 2046 0 obj<>endobj 2047 0 obj<>endobj 2048 0 obj<>endobj 2049 0 obj<>endobj 2050 0 obj<>endobj 2051 0 obj<>endobj 2052 0 obj<>endobj 2053 0 obj<>endobj 2054 0 obj<>endobj 2055 0 obj<>endobj 2056 0 obj<>endobj 2057 0 obj<>endobj 2058 0 obj<>endobj 2059 0 obj<>endobj 2060 0 obj<>endobj 2061 0 obj<>endobj 2062 0 obj<>endobj 2063 0 obj<>endobj 2064 0 obj<>endobj 2065 0 obj[2028 0 R 2029 0 R 2030 0 R 2031 0 R 2032 0 R 2033 0 R 2034 0 R 2035 0 R 2036 0 R 2037 0 R 2038 0 R 2039 0 R 2040 0 R 2041 0 R 2042 0 R 2043 0 R 2044 0 R 2045 0 R 2046 0 R 2047 0 R 2048 0 R 2049 0 R 2050 0 R 2051 0 R 2052 0 R 2053 0 R 2054 0 R 2056 0 R 2058 0 R 2060 0 R 2062 0 R 2064 0 R]endobj 2066 0 obj<>endobj 2067 0 obj<>endobj 2068 0 obj<>endobj 2069 0 obj[2066 0 R 2067 0 R 2068 0 R]endobj 2070 0 obj<>endobj 2071 0 obj<>endobj 2072 0 obj<>endobj 2073 0 obj<>endobj 2074 0 obj<>endobj 2075 0 obj<>endobj 2076 0 obj<>endobj 2077 0 obj[2070 0 R 2071 0 R 2072 0 R 2073 0 R 2074 0 R 2075 0 R 2076 0 R]endobj 2078 0 obj<>endobj 2079 0 obj[2078 0 R]endobj 2080 0 obj<>endobj 2081 0 obj<>endobj 2082 0 obj<>endobj 2083 0 obj<>endobj 2084 0 obj<>endobj 2085 0 obj[2080 0 R 2082 0 R 2084 0 R]endobj 2086 0 obj<>endobj 2087 0 obj<>endobj 2088 0 obj<>endobj 2089 0 obj[2086 0 R 2088 0 R]endobj 2090 0 obj<>endobj 2091 0 obj<>endobj 2092 0 obj[2091 0 R]endobj 2093 0 obj<>endobj 2094 0 obj<>endobj 2095 0 obj[2093 0 R 2094 0 R]endobj 2096 0 obj<>endobj 2097 0 obj[2096 0 R]endobj 2098 0 obj<>endobj 2099 0 obj[2098 0 R]endobj 2100 0 obj<>endobj 2101 0 obj<>endobj 2102 0 obj[2100 0 R 2101 0 R]endobj 2103 0 obj<>endobj 2104 0 obj[2103 0 R]endobj 2105 0 obj<>endobj 2106 0 obj<>endobj 2107 0 obj<>endobj 2108 0 obj[2105 0 R 2106 0 R 2107 0 R]endobj 2109 0 obj<>endobj 2110 0 obj[2109 0 R]endobj 2111 0 obj<>endobj 2112 0 obj[2111 0 R]endobj 2113 0 obj<>endobj 2114 0 obj[2113 0 R]endobj 2115 0 obj<>endobj 2116 0 obj<>endobj 2117 0 obj<>endobj 2118 0 obj<>endobj 2119 0 obj<>endobj 2120 0 obj<>endobj 2121 0 obj<>endobj 2122 0 obj<>endobj 2123 0 obj<>endobj 2124 0 obj<>endobj 2125 0 obj<>endobj 2126 0 obj<>endobj 2127 0 obj<>endobj 2128 0 obj<>endobj 2129 0 obj<>endobj 2130 0 obj<>endobj 2131 0 obj<>endobj 2132 0 obj<>endobj 2133 0 obj<>endobj 2134 0 obj<>endobj 2135 0 obj[2115 0 R 2116 0 R 2117 0 R 2118 0 R 2119 0 R 2120 0 R 2121 0 R 2122 0 R 2123 0 R 2124 0 R 2125 0 R 2126 0 R 2127 0 R 2128 0 R 2129 0 R 2130 0 R 2131 0 R 2132 0 R 2133 0 R 2134 0 R]endobj 2136 0 obj<>endobj 2137 0 obj<>endobj 2138 0 obj<>endobj 2139 0 obj<>endobj 2140 0 obj<>endobj 2141 0 obj[2136 0 R 2137 0 R 2138 0 R 2140 0 R]endobj 2142 0 obj<>endobj 2143 0 obj<>endobj 2144 0 obj<>endobj 2145 0 obj[2142 0 R 2143 0 R 2144 0 R]endobj 2146 0 obj<>endobj 2147 0 obj<>endobj 2148 0 obj<>endobj 2149 0 obj<>endobj 2150 0 obj<>endobj 2151 0 obj<>endobj 2152 0 obj<>endobj 2153 0 obj<>endobj 2154 0 obj<>endobj 2155 0 obj<>endobj 2156 0 obj<>endobj 2157 0 obj<>endobj 2158 0 obj<>endobj 2159 0 obj<>endobj 2160 0 obj<>endobj 2161 0 obj<>endobj 2162 0 obj<>endobj 2163 0 obj<>endobj 2164 0 obj<>endobj 2165 0 obj<>endobj 2166 0 obj<>endobj 2167 0 obj<>endobj 2168 0 obj<>endobj 2169 0 obj<>endobj 2170 0 obj<>endobj 2171 0 obj<>endobj 2172 0 obj<>endobj 2173 0 obj[2146 0 R 2147 0 R 2148 0 R 2149 0 R 2150 0 R 2151 0 R 2152 0 R 2153 0 R 2154 0 R 2155 0 R 2156 0 R 2157 0 R 2158 0 R 2159 0 R 2160 0 R 2161 0 R 2162 0 R 2163 0 R 2164 0 R 2165 0 R 2166 0 R 2168 0 R 2170 0 R 2171 0 R 2172 0 R]endobj 2174 0 obj<>endobj 2175 0 obj<>endobj 2176 0 obj<>endobj 2177 0 obj<>endobj 2178 0 obj<>endobj 2179 0 obj<>endobj 2180 0 obj<>endobj 2181 0 obj<>endobj 2182 0 obj[2174 0 R 2175 0 R 2176 0 R 2177 0 R 2178 0 R 2179 0 R 2180 0 R 2181 0 R]endobj 2183 0 obj<>endobj 2184 0 obj<>endobj 2185 0 obj<>endobj 2186 0 obj<>endobj 2187 0 obj<>endobj 2188 0 obj[2183 0 R 2184 0 R 2185 0 R 2186 0 R 2187 0 R]endobj 2189 0 obj<>endobj 2190 0 obj<>endobj 2191 0 obj<>endobj 2192 0 obj<>endobj 2193 0 obj[2189 0 R 2190 0 R 2191 0 R 2192 0 R]endobj 2194 0 obj<>endobj 2195 0 obj<>endobj 2196 0 obj<>endobj 2197 0 obj[2194 0 R 2195 0 R 2196 0 R]endobj 2198 0 obj<>endobj 2199 0 obj<>endobj 2200 0 obj<>endobj 2201 0 obj<>endobj 2202 0 obj[2198 0 R 2199 0 R 2200 0 R 2201 0 R]endobj 2203 0 obj<>endobj 2204 0 obj<>endobj 2205 0 obj<>endobj 2206 0 obj<>endobj 2207 0 obj<>endobj 2208 0 obj<>endobj 2209 0 obj[2204 0 R 2206 0 R 2207 0 R 2208 0 R]endobj 2210 0 obj<>endobj 2211 0 obj<>endobj 2212 0 obj<>endobj 2213 0 obj<>endobj 2214 0 obj<>endobj 2215 0 obj<>endobj 2216 0 obj<>endobj 2217 0 obj<>endobj 2218 0 obj<>endobj 2219 0 obj<>endobj 2220 0 obj<>endobj 2221 0 obj<>endobj 2222 0 obj<>endobj 2223 0 obj<>endobj 2224 0 obj<>endobj 2225 0 obj<>endobj 2226 0 obj<>endobj 2227 0 obj<>endobj 2228 0 obj[2210 0 R 2211 0 R 2212 0 R 2213 0 R 2214 0 R 2215 0 R 2216 0 R 2217 0 R 2218 0 R 2219 0 R 2220 0 R 2221 0 R 2222 0 R 2223 0 R 2224 0 R 2225 0 R 2227 0 R]endobj 2229 0 obj<>endobj 2230 0 obj[2229 0 R]endobj 2231 0 obj<>endobj 2232 0 obj<>endobj 2233 0 obj[2232 0 R]endobj 2234 0 obj<>endobj 2235 0 obj<>endobj 2236 0 obj<>endobj 2237 0 obj<>endobj 2238 0 obj<>endobj 2239 0 obj<>endobj 2240 0 obj<>endobj 2241 0 obj<>endobj 2242 0 obj<>endobj 2243 0 obj<>endobj 2244 0 obj<>endobj 2245 0 obj<>endobj 2246 0 obj<>endobj 2247 0 obj<>endobj 2248 0 obj<>endobj 2249 0 obj<>endobj 2250 0 obj<>endobj 2251 0 obj<>endobj 2252 0 obj<>endobj 2253 0 obj<>endobj 2254 0 obj<>endobj 2255 0 obj<>endobj 2256 0 obj[2234 0 R 2235 0 R 2236 0 R 2237 0 R 2238 0 R 2239 0 R 2240 0 R 2241 0 R 2242 0 R 2243 0 R 2244 0 R 2245 0 R 2246 0 R 2247 0 R 2248 0 R 2249 0 R 2250 0 R 2251 0 R 2252 0 R 2253 0 R 2255 0 R]endobj 2257 0 obj<>endobj 2258 0 obj[2257 0 R]endobj 2259 0 obj<>endobj 2260 0 obj<>endobj 2261 0 obj[2259 0 R 2260 0 R]endobj 2262 0 obj<>endobj 2263 0 obj<>endobj 2264 0 obj<>endobj 2265 0 obj<>endobj 2266 0 obj<>endobj 2267 0 obj<>endobj 2268 0 obj<>endobj 2269 0 obj<>endobj 2270 0 obj<>endobj 2271 0 obj<>endobj 2272 0 obj<>endobj 2273 0 obj<>endobj 2274 0 obj<>endobj 2275 0 obj<>endobj 2276 0 obj<>endobj 2277 0 obj<>endobj 2278 0 obj<>endobj 2279 0 obj<>endobj 2280 0 obj<>endobj 2281 0 obj<>endobj 2282 0 obj<>endobj 2283 0 obj<>endobj 2284 0 obj<>endobj 2285 0 obj<>endobj 2286 0 obj<>endobj 2287 0 obj<>endobj 2288 0 obj<>endobj 2289 0 obj<>endobj 2290 0 obj<>endobj 2291 0 obj<>endobj 2292 0 obj<>endobj 2293 0 obj<>endobj 2294 0 obj<>endobj 2295 0 obj<>endobj 2296 0 obj<>endobj 2297 0 obj<>endobj 2298 0 obj<>endobj 2299 0 obj<>endobj 2300 0 obj<>endobj 2301 0 obj<>endobj 2302 0 obj<>endobj 2303 0 obj<>endobj 2304 0 obj<>endobj 2305 0 obj<>endobj 2306 0 obj<>endobj 2307 0 obj<>endobj 2308 0 obj<>endobj 2309 0 obj<>endobj 2310 0 obj<>endobj 2311 0 obj<>endobj 2312 0 obj<>endobj 2313 0 obj<>endobj 2314 0 obj<>endobj 2315 0 obj[2262 0 R 2263 0 R 2264 0 R 2265 0 R 2266 0 R 2267 0 R 2268 0 R 2269 0 R 2270 0 R 2271 0 R 2272 0 R 2273 0 R 2274 0 R 2275 0 R 2276 0 R 2277 0 R 2278 0 R 2279 0 R 2280 0 R 2281 0 R 2282 0 R 2283 0 R 2284 0 R 2285 0 R 2286 0 R 2287 0 R 2288 0 R 2289 0 R 2290 0 R 2291 0 R 2292 0 R 2293 0 R 2294 0 R 2295 0 R 2296 0 R 2297 0 R 2298 0 R 2299 0 R 2300 0 R 2301 0 R 2302 0 R 2303 0 R 2304 0 R 2305 0 R 2306 0 R 2307 0 R 2308 0 R 2309 0 R 2310 0 R 2311 0 R 2312 0 R 2313 0 R 2314 0 R]endobj 2316 0 obj<>endobj 2317 0 obj<>endobj 2318 0 obj<>endobj 2319 0 obj<>endobj 2320 0 obj<>endobj 2321 0 obj<>endobj 2322 0 obj<>endobj 2323 0 obj<>endobj 2324 0 obj<>endobj 2325 0 obj<>endobj 2326 0 obj<>endobj 2327 0 obj<>endobj 2328 0 obj<>endobj 2329 0 obj<>endobj 2330 0 obj<>endobj 2331 0 obj<>endobj 2332 0 obj<>endobj 2333 0 obj<>endobj 2334 0 obj<>endobj 2335 0 obj<>endobj 2336 0 obj<>endobj 2337 0 obj<>endobj 2338 0 obj<>endobj 2339 0 obj<>endobj 2340 0 obj<>endobj 2341 0 obj<>endobj 2342 0 obj<>endobj 2343 0 obj<>endobj 2344 0 obj<>endobj 2345 0 obj<>endobj 2346 0 obj<>endobj 2347 0 obj<>endobj 2348 0 obj<>endobj 2349 0 obj<>endobj 2350 0 obj<>endobj 2351 0 obj<>endobj 2352 0 obj<>endobj 2353 0 obj<>endobj 2354 0 obj<>endobj 2355 0 obj<>endobj 2356 0 obj<>endobj 2357 0 obj<>endobj 2358 0 obj<>endobj 2359 0 obj<>endobj 2360 0 obj<>endobj 2361 0 obj<>endobj 2362 0 obj<>endobj 2363 0 obj<>endobj 2364 0 obj<>endobj 2365 0 obj<>endobj 2366 0 obj<>endobj 2367 0 obj[2316 0 R 2317 0 R 2318 0 R 2319 0 R 2320 0 R 2321 0 R 2322 0 R 2323 0 R 2324 0 R 2325 0 R 2326 0 R 2327 0 R 2328 0 R 2329 0 R 2330 0 R 2331 0 R 2332 0 R 2333 0 R 2334 0 R 2335 0 R 2336 0 R 2337 0 R 2338 0 R 2339 0 R 2340 0 R 2341 0 R 2342 0 R 2343 0 R 2344 0 R 2345 0 R 2346 0 R 2347 0 R 2348 0 R 2349 0 R 2350 0 R 2351 0 R 2352 0 R 2353 0 R 2354 0 R 2355 0 R 2356 0 R 2357 0 R 2358 0 R 2359 0 R 2360 0 R 2361 0 R 2362 0 R 2363 0 R 2364 0 R 2365 0 R 2366 0 R]endobj 2368 0 obj<>endobj 2369 0 obj<>endobj 2370 0 obj<>endobj 2371 0 obj[2368 0 R 2369 0 R 2370 0 R]endobj 2372 0 obj<>endobj 2373 0 obj<>endobj 2374 0 obj<>endobj 2375 0 obj<>endobj 2376 0 obj<>endobj 2377 0 obj<>endobj 2378 0 obj<>endobj 2379 0 obj[2372 0 R 2373 0 R 2374 0 R 2376 0 R 2378 0 R]endobj 2380 0 obj<>endobj 2381 0 obj<>endobj 2382 0 obj<>endobj 2383 0 obj[2380 0 R 2381 0 R 2382 0 R]endobj 2384 0 obj<>endobj 2385 0 obj<>endobj 2386 0 obj[2385 0 R]endobj 2387 0 obj<>endobj 2388 0 obj<>endobj 2389 0 obj[2387 0 R 2388 0 R]endobj 2390 0 obj<>endobj 2391 0 obj<>endobj 2392 0 obj<>endobj 2393 0 obj[2390 0 R 2391 0 R 2392 0 R]endobj 2394 0 obj<>endobj 2395 0 obj<>endobj 2396 0 obj<>endobj 2397 0 obj<>endobj 2398 0 obj<>endobj 2399 0 obj<>endobj 2400 0 obj<>endobj 2401 0 obj<>endobj 2402 0 obj<>endobj 2403 0 obj<>endobj 2404 0 obj<>endobj 2405 0 obj<>endobj 2406 0 obj<>endobj 2407 0 obj[2394 0 R 2396 0 R 2398 0 R 2400 0 R 2402 0 R 2404 0 R 2406 0 R]endobj 2408 0 obj<>endobj 2409 0 obj<>endobj 2410 0 obj<>endobj 2411 0 obj<>endobj 2412 0 obj<>endobj 2413 0 obj[2408 0 R 2409 0 R 2410 0 R 2411 0 R 2412 0 R]endobj 2414 0 obj<>endobj 2415 0 obj<>endobj 2416 0 obj[2414 0 R 2415 0 R]endobj 2417 0 obj<>endobj 2418 0 obj<>endobj 2419 0 obj[2417 0 R 2418 0 R]endobj 2420 0 obj<>endobj 2421 0 obj<>endobj 2422 0 obj[2420 0 R 2421 0 R]endobj 2423 0 obj<>endobj 2424 0 obj[2423 0 R]endobj 2425 0 obj<>endobj 2426 0 obj<>endobj 2427 0 obj<>endobj 2428 0 obj<>endobj 2429 0 obj<>endobj 2430 0 obj[2425 0 R 2426 0 R 2427 0 R 2428 0 R 2429 0 R]endobj 2431 0 obj<>endobj 2432 0 obj[2431 0 R]endobj 2433 0 obj<>endobj 2434 0 obj<>endobj 2435 0 obj<>endobj 2436 0 obj<>endobj 2437 0 obj<>endobj 2438 0 obj[2433 0 R 2435 0 R 2437 0 R]endobj 2439 0 obj<>endobj 2440 0 obj[2439 0 R]endobj 2441 0 obj<>endobj 2442 0 obj<>endobj 2443 0 obj<>endobj 2444 0 obj[2441 0 R 2442 0 R 2443 0 R]endobj 2445 0 obj<>endobj 2446 0 obj<>endobj 2447 0 obj<>endobj 2448 0 obj[2445 0 R 2447 0 R]endobj 2449 0 obj<>endobj 2450 0 obj<>endobj 2451 0 obj<>endobj 2452 0 obj<>endobj 2453 0 obj<>endobj 2454 0 obj<>endobj 2455 0 obj[2450 0 R 2451 0 R 2452 0 R 2454 0 R]endobj 2456 0 obj<>endobj 2457 0 obj[2456 0 R]endobj 2458 0 obj<>endobj 2459 0 obj[2458 0 R]endobj 2460 0 obj<>endobj 2461 0 obj[2460 0 R]endobj 2462 0 obj<>endobj 2463 0 obj[2462 0 R]endobj 2464 0 obj<>endobj 2465 0 obj[2464 0 R]endobj 2466 0 obj<>endobj 2467 0 obj<>endobj 2468 0 obj[2466 0 R 2467 0 R]endobj 2469 0 obj<>endobj 2470 0 obj<>endobj 2471 0 obj[2469 0 R 2470 0 R]endobj 2472 0 obj<>endobj 2473 0 obj[2472 0 R]endobj 2474 0 obj<>endobj 2475 0 obj<>endobj 2476 0 obj[2474 0 R 2475 0 R]endobj 2477 0 obj<>endobj 2478 0 obj<>endobj 2479 0 obj<>endobj 2480 0 obj<>endobj 2481 0 obj<>endobj 2482 0 obj[2477 0 R 2478 0 R 2479 0 R 2480 0 R 2481 0 R]endobj 2483 0 obj<>endobj 2484 0 obj[2483 0 R]endobj 2485 0 obj<>endobj 2486 0 obj<>endobj 2487 0 obj[2485 0 R 2486 0 R]endobj 2488 0 obj<>endobj 2489 0 obj<>endobj 2490 0 obj<>endobj 2491 0 obj<>endobj 2492 0 obj<>endobj 2493 0 obj[2488 0 R 2490 0 R 2492 0 R]endobj 2494 0 obj<>endobj 2495 0 obj<>endobj 2496 0 obj<>endobj 2497 0 obj<>endobj 2498 0 obj<>endobj 2499 0 obj[2494 0 R 2495 0 R 2496 0 R 2497 0 R 2498 0 R]endobj 2500 0 obj<>endobj 2501 0 obj<>endobj 2502 0 obj<>endobj 2503 0 obj<>endobj 2504 0 obj<>endobj 2505 0 obj<>endobj 2506 0 obj[2500 0 R 2502 0 R 2503 0 R 2504 0 R 2505 0 R]endobj 2507 0 obj<>endobj 2508 0 obj<>endobj 2509 0 obj<>endobj 2510 0 obj<>endobj 2511 0 obj<>endobj 2512 0 obj<>endobj 2513 0 obj<>endobj 2514 0 obj<>endobj 2515 0 obj<>endobj 2516 0 obj[2507 0 R 2508 0 R 2509 0 R 2510 0 R 2511 0 R 2512 0 R 2513 0 R 2514 0 R 2515 0 R]endobj 2517 0 obj<>endobj 2518 0 obj<>endobj 2519 0 obj<>endobj 2520 0 obj<>endobj 2521 0 obj<>endobj 2522 0 obj[2517 0 R 2518 0 R 2519 0 R 2520 0 R 2521 0 R]endobj 2523 0 obj<>endobj 2524 0 obj<>endobj 2525 0 obj[2523 0 R 2524 0 R]endobj 2526 0 obj<>endobj 2527 0 obj<>endobj 2528 0 obj[2526 0 R 2527 0 R]endobj 2529 0 obj<>endobj 2530 0 obj[2529 0 R]endobj 2531 0 obj<>endobj 2532 0 obj[2531 0 R]endobj 2533 0 obj<>endobj 2534 0 obj[2533 0 R]endobj 2535 0 obj<>endobj 2536 0 obj<>endobj 2537 0 obj[2535 0 R 2536 0 R]endobj 2538 0 obj<>endobj 2539 0 obj<>endobj 2540 0 obj[2538 0 R 2539 0 R]endobj 2541 0 obj<>endobj 2542 0 obj[2541 0 R]endobj 2543 0 obj<>endobj 2544 0 obj[2543 0 R]endobj 2545 0 obj<>endobj 2546 0 obj<>endobj 2547 0 obj[2545 0 R 2546 0 R]endobj 2548 0 obj<>endobj 2549 0 obj<>endobj 2550 0 obj[2548 0 R 2549 0 R]endobj 2551 0 obj<>endobj 2552 0 obj<>endobj 2553 0 obj<>endobj 2554 0 obj<>endobj 2555 0 obj<>endobj 2556 0 obj<>endobj 2557 0 obj<>endobj 2558 0 obj<>endobj 2559 0 obj<>endobj 2560 0 obj<>endobj 2561 0 obj<>endobj 2562 0 obj<>endobj 2563 0 obj<>endobj 2564 0 obj<>endobj 2565 0 obj<>endobj 2566 0 obj<>endobj 2567 0 obj<>endobj 2568 0 obj<>endobj 2569 0 obj<>endobj 2570 0 obj<>endobj 2571 0 obj<>endobj 2572 0 obj<>endobj 2573 0 obj<>endobj 2574 0 obj<>endobj 2575 0 obj<>endobj 2576 0 obj<>endobj 2577 0 obj<>endobj 2578 0 obj<>endobj 2579 0 obj<>endobj 2580 0 obj[2551 0 R 2552 0 R 2553 0 R 2554 0 R 2555 0 R 2556 0 R 2557 0 R 2558 0 R 2559 0 R 2560 0 R 2561 0 R 2562 0 R 2563 0 R 2564 0 R 2565 0 R 2566 0 R 2567 0 R 2568 0 R 2569 0 R 2570 0 R 2571 0 R 2573 0 R 2575 0 R 2577 0 R 2579 0 R]endobj 2581 0 obj<>endobj 2582 0 obj<>endobj 2583 0 obj<>endobj 2584 0 obj<>endobj 2585 0 obj[2582 0 R 2584 0 R]endobj 2586 0 obj<>endobj 2587 0 obj<>endobj 2588 0 obj<>endobj 2589 0 obj<>endobj 2590 0 obj[2587 0 R 2589 0 R]endobj 2591 0 obj<>endobj 2592 0 obj<>endobj 2593 0 obj<>endobj 2594 0 obj<>endobj 2595 0 obj<>endobj 2596 0 obj<>endobj 2597 0 obj<>endobj 2598 0 obj<>endobj 2599 0 obj<>endobj 2600 0 obj<>endobj 2601 0 obj<>endobj 2602 0 obj<>endobj 2603 0 obj[2592 0 R 2594 0 R 2596 0 R 2598 0 R 2600 0 R 2602 0 R]endobj 2604 0 obj<>endobj 2605 0 obj<>endobj 2606 0 obj<>endobj 2607 0 obj<>endobj 2608 0 obj[2605 0 R 2607 0 R]endobj 2609 0 obj<>endobj 2610 0 obj<>endobj 2611 0 obj[2610 0 R]endobj 2612 0 obj<>endobj 2613 0 obj<>endobj 2614 0 obj<>endobj 2615 0 obj<>endobj 2616 0 obj<>endobj 2617 0 obj<>endobj 2618 0 obj<>endobj 2619 0 obj<>endobj 2620 0 obj<>endobj 2621 0 obj<>endobj 2622 0 obj<>endobj 2623 0 obj[2612 0 R 2613 0 R 2614 0 R 2615 0 R 2616 0 R 2617 0 R 2618 0 R 2619 0 R 2620 0 R 2621 0 R 2622 0 R]endobj 2624 0 obj<>endobj 2625 0 obj[2624 0 R]endobj 2626 0 obj<>endobj 2627 0 obj<>endobj 2628 0 obj<>endobj 2629 0 obj[2626 0 R 2628 0 R]endobj 2630 0 obj<>endobj 2631 0 obj<>endobj 2632 0 obj<>endobj 2633 0 obj<>endobj 2634 0 obj<>endobj 2635 0 obj<>endobj 2636 0 obj<>endobj 2637 0 obj<>endobj 2638 0 obj<>endobj 2639 0 obj<>endobj 2640 0 obj<>endobj 2641 0 obj<>endobj 2642 0 obj<>endobj 2643 0 obj<>endobj 2644 0 obj<>endobj 2645 0 obj<>endobj 2646 0 obj<>endobj 2647 0 obj<>endobj 2648 0 obj<>endobj 2649 0 obj<>endobj 2650 0 obj<>endobj 2651 0 obj<>endobj 2652 0 obj<>endobj 2653 0 obj<>endobj 2654 0 obj<>endobj 2655 0 obj<>endobj 2656 0 obj<>endobj 2657 0 obj<>endobj 2658 0 obj<>endobj 2659 0 obj<>endobj 2660 0 obj<>endobj 2661 0 obj<>endobj 2662 0 obj<>endobj 2663 0 obj<>endobj 2664 0 obj<>endobj 2665 0 obj<>endobj 2666 0 obj<>endobj 2667 0 obj<>endobj 2668 0 obj<>endobj 2669 0 obj<>endobj 2670 0 obj<>endobj 2671 0 obj<>endobj 2672 0 obj<>endobj 2673 0 obj<>endobj 2674 0 obj<>endobj 2675 0 obj[2630 0 R 2631 0 R 2632 0 R 2633 0 R 2634 0 R 2635 0 R 2636 0 R 2637 0 R 2638 0 R 2639 0 R 2640 0 R 2641 0 R 2642 0 R 2643 0 R 2644 0 R 2645 0 R 2646 0 R 2647 0 R 2648 0 R 2649 0 R 2650 0 R 2651 0 R 2652 0 R 2653 0 R 2654 0 R 2655 0 R 2656 0 R 2657 0 R 2658 0 R 2659 0 R 2660 0 R 2661 0 R 2662 0 R 2663 0 R 2664 0 R 2665 0 R 2666 0 R 2667 0 R 2668 0 R 2669 0 R 2670 0 R 2671 0 R 2672 0 R 2674 0 R]endobj 2676 0 obj<>endobj 2677 0 obj<>endobj 2678 0 obj[2677 0 R]endobj 2679 0 obj<>endobj 2680 0 obj<>endobj 2681 0 obj[2680 0 R]endobj 2682 0 obj<>endobj 2683 0 obj[2682 0 R]endobj 2684 0 obj<>endobj 2685 0 obj<>endobj 2686 0 obj<>endobj 2687 0 obj[2684 0 R 2685 0 R 2686 0 R]endobj 2688 0 obj<>endobj 2689 0 obj[2688 0 R]endobj 2690 0 obj<>endobj 2691 0 obj<>endobj 2692 0 obj[2690 0 R 2691 0 R]endobj 2693 0 obj<>endobj 2694 0 obj<>endobj 2695 0 obj<>endobj 2696 0 obj<>endobj 2697 0 obj<>endobj 2698 0 obj<>endobj 2699 0 obj<>endobj 2700 0 obj<>endobj 2701 0 obj<>endobj 2702 0 obj<>endobj 2703 0 obj<>endobj 2704 0 obj<>endobj 2705 0 obj<>endobj 2706 0 obj<>endobj 2707 0 obj<>endobj 2708 0 obj<>endobj 2709 0 obj<>endobj 2710 0 obj<>endobj 2711 0 obj<>endobj 2712 0 obj<>endobj 2713 0 obj<>endobj 2714 0 obj<>endobj 2715 0 obj<>endobj 2716 0 obj<>endobj 2717 0 obj<>endobj 2718 0 obj<>endobj 2719 0 obj<>endobj 2720 0 obj[2693 0 R 2694 0 R 2695 0 R 2696 0 R 2697 0 R 2698 0 R 2699 0 R 2700 0 R 2701 0 R 2702 0 R 2703 0 R 2704 0 R 2705 0 R 2706 0 R 2707 0 R 2708 0 R 2709 0 R 2710 0 R 2711 0 R 2713 0 R 2714 0 R 2715 0 R 2717 0 R 2719 0 R]endobj 2721 0 obj<>endobj 2722 0 obj<>endobj 2723 0 obj<>endobj 2724 0 obj<>endobj 2725 0 obj<>endobj 2726 0 obj[2721 0 R 2722 0 R 2723 0 R 2724 0 R 2725 0 R]endobj 2727 0 obj<>endobj 2728 0 obj[2727 0 R]endobj 2729 0 obj<>endobj 2730 0 obj<>endobj 2731 0 obj<>endobj 2732 0 obj[2729 0 R 2730 0 R 2731 0 R]endobj 2733 0 obj<>endobj 2734 0 obj<>endobj 2735 0 obj<>endobj 2736 0 obj<>endobj 2737 0 obj[2734 0 R 2736 0 R]endobj 2738 0 obj<>endobj 2739 0 obj<>endobj 2740 0 obj<>endobj 2741 0 obj<>endobj 2742 0 obj<>endobj 2743 0 obj<>endobj 2744 0 obj<>endobj 2745 0 obj<>endobj 2746 0 obj<>endobj 2747 0 obj<>endobj 2748 0 obj<>endobj 2749 0 obj<>endobj 2750 0 obj<>endobj 2751 0 obj<>endobj 2752 0 obj<>endobj 2753 0 obj<>endobj 2754 0 obj<>endobj 2755 0 obj<>endobj 2756 0 obj<>endobj 2757 0 obj<>endobj 2758 0 obj<>endobj 2759 0 obj<>endobj 2760 0 obj<>endobj 2761 0 obj<>endobj 2762 0 obj<>endobj 2763 0 obj<>endobj 2764 0 obj<>endobj 2765 0 obj<>endobj 2766 0 obj<>endobj 2767 0 obj<>endobj 2768 0 obj<>endobj 2769 0 obj<>endobj 2770 0 obj<>endobj 2771 0 obj<>endobj 2772 0 obj<>endobj 2773 0 obj[2738 0 R 2739 0 R 2740 0 R 2741 0 R 2742 0 R 2743 0 R 2744 0 R 2745 0 R 2746 0 R 2747 0 R 2748 0 R 2749 0 R 2750 0 R 2751 0 R 2752 0 R 2753 0 R 2754 0 R 2755 0 R 2756 0 R 2757 0 R 2758 0 R 2759 0 R 2760 0 R 2761 0 R 2762 0 R 2763 0 R 2764 0 R 2765 0 R 2766 0 R 2767 0 R 2768 0 R 2770 0 R 2772 0 R]endobj 2774 0 obj<>endobj 2775 0 obj<>endobj 2776 0 obj<>endobj 2777 0 obj<>endobj 2778 0 obj<>endobj 2779 0 obj<>endobj 2780 0 obj<>endobj 2781 0 obj<>endobj 2782 0 obj<>endobj 2783 0 obj<>endobj 2784 0 obj<>endobj 2785 0 obj<>endobj 2786 0 obj<>endobj 2787 0 obj<>endobj 2788 0 obj<>endobj 2789 0 obj<>endobj 2790 0 obj<>endobj 2791 0 obj<>endobj 2792 0 obj<>endobj 2793 0 obj<>endobj 2794 0 obj<>endobj 2795 0 obj<>endobj 2796 0 obj<>endobj 2797 0 obj<>endobj 2798 0 obj<>endobj 2799 0 obj[2774 0 R 2775 0 R 2776 0 R 2777 0 R 2778 0 R 2779 0 R 2780 0 R 2781 0 R 2782 0 R 2783 0 R 2784 0 R 2785 0 R 2786 0 R 2787 0 R 2788 0 R 2789 0 R 2790 0 R 2791 0 R 2792 0 R 2793 0 R 2794 0 R 2795 0 R 2796 0 R 2798 0 R]endobj 2800 0 obj<>endobj 2801 0 obj[2800 0 R]endobj 2802 0 obj<>endobj 2803 0 obj<>endobj 2804 0 obj<>endobj 2805 0 obj<>endobj 2806 0 obj<>endobj 2807 0 obj<>endobj 2808 0 obj<>endobj 2809 0 obj<>endobj 2810 0 obj<>endobj 2811 0 obj<>endobj 2812 0 obj<>endobj 2813 0 obj<>endobj 2814 0 obj<>endobj 2815 0 obj<>endobj 2816 0 obj<>endobj 2817 0 obj<>endobj 2818 0 obj<>endobj 2819 0 obj<>endobj 2820 0 obj<>endobj 2821 0 obj<>endobj 2822 0 obj<>endobj 2823 0 obj<>endobj 2824 0 obj<>endobj 2825 0 obj<>endobj 2826 0 obj<>endobj 2827 0 obj<>endobj 2828 0 obj<>endobj 2829 0 obj<>endobj 2830 0 obj<>endobj 2831 0 obj<>endobj 2832 0 obj<>endobj 2833 0 obj<>endobj 2834 0 obj<>endobj 2835 0 obj<>endobj 2836 0 obj<>endobj 2837 0 obj<>endobj 2838 0 obj<>endobj 2839 0 obj<>endobj 2840 0 obj<>endobj 2841 0 obj<>endobj 2842 0 obj<>endobj 2843 0 obj<>endobj 2844 0 obj<>endobj 2845 0 obj<>endobj 2846 0 obj<>endobj 2847 0 obj<>endobj 2848 0 obj<>endobj 2849 0 obj<>endobj 2850 0 obj<>endobj 2851 0 obj<>endobj 2852 0 obj<>endobj 2853 0 obj<>endobj 2854 0 obj<>endobj 2855 0 obj[2802 0 R 2803 0 R 2804 0 R 2805 0 R 2806 0 R 2807 0 R 2808 0 R 2809 0 R 2810 0 R 2811 0 R 2812 0 R 2813 0 R 2814 0 R 2815 0 R 2816 0 R 2817 0 R 2818 0 R 2819 0 R 2820 0 R 2821 0 R 2822 0 R 2823 0 R 2824 0 R 2825 0 R 2826 0 R 2827 0 R 2828 0 R 2829 0 R 2830 0 R 2831 0 R 2832 0 R 2833 0 R 2834 0 R 2835 0 R 2836 0 R 2837 0 R 2838 0 R 2839 0 R 2840 0 R 2841 0 R 2842 0 R 2843 0 R 2844 0 R 2845 0 R 2846 0 R 2847 0 R 2848 0 R 2849 0 R 2850 0 R 2851 0 R 2852 0 R 2853 0 R 2854 0 R]endobj 2856 0 obj<>endobj 2857 0 obj<>endobj 2858 0 obj[2857 0 R]endobj 2859 0 obj<>endobj 2860 0 obj<>endobj 2861 0 obj[2860 0 R]endobj 2862 0 obj<>endobj 2863 0 obj<>endobj 2864 0 obj<>endobj 2865 0 obj[2862 0 R 2863 0 R 2864 0 R]endobj 2866 0 obj<>endobj 2867 0 obj[2866 0 R]endobj 2868 0 obj<>endobj 2869 0 obj[2868 0 R]endobj 2870 0 obj<>endobj 2871 0 obj[2870 0 R]endobj 2872 0 obj<>endobj 2873 0 obj[2872 0 R]endobj 2874 0 obj<>endobj 2875 0 obj<>endobj 2876 0 obj<>endobj 2877 0 obj<>endobj 2878 0 obj<>endobj 2879 0 obj<>endobj 2880 0 obj<>endobj 2881 0 obj<>endobj 2882 0 obj<>endobj 2883 0 obj<>endobj 2884 0 obj<>endobj 2885 0 obj<>endobj 2886 0 obj<>endobj 2887 0 obj<>endobj 2888 0 obj<>endobj 2889 0 obj<>endobj 2890 0 obj<>endobj 2891 0 obj<>endobj 2892 0 obj<>endobj 2893 0 obj<>endobj 2894 0 obj<>endobj 2895 0 obj<>endobj 2896 0 obj<>endobj 2897 0 obj<>endobj 2898 0 obj[2874 0 R 2875 0 R 2876 0 R 2877 0 R 2878 0 R 2879 0 R 2880 0 R 2881 0 R 2882 0 R 2883 0 R 2884 0 R 2885 0 R 2886 0 R 2887 0 R 2888 0 R 2889 0 R 2890 0 R 2891 0 R 2892 0 R 2893 0 R 2894 0 R 2895 0 R 2896 0 R 2897 0 R]endobj 2899 0 obj<>endobj 2900 0 obj[2899 0 R]endobj 2901 0 obj<>endobj 2902 0 obj<>endobj 2903 0 obj[2901 0 R 2902 0 R]endobj 2904 0 obj<>endobj 2905 0 obj<>endobj 2906 0 obj<>endobj 2907 0 obj<>endobj 2908 0 obj<>endobj 2909 0 obj<>endobj 2910 0 obj<>endobj 2911 0 obj<>endobj 2912 0 obj<>endobj 2913 0 obj<>endobj 2914 0 obj<>endobj 2915 0 obj<>endobj 2916 0 obj[2904 0 R 2905 0 R 2906 0 R 2907 0 R 2908 0 R 2909 0 R 2910 0 R 2911 0 R 2912 0 R 2913 0 R 2914 0 R 2915 0 R]endobj 2917 0 obj<>endobj 2918 0 obj<>endobj 2919 0 obj<>endobj 2920 0 obj<>endobj 2921 0 obj<>endobj 2922 0 obj<>endobj 2923 0 obj<>endobj 2924 0 obj<>endobj 2925 0 obj<>endobj 2926 0 obj<>endobj 2927 0 obj<>endobj 2928 0 obj<>endobj 2929 0 obj<>endobj 2930 0 obj<>endobj 2931 0 obj<>endobj 2932 0 obj<>endobj 2933 0 obj<>endobj 2934 0 obj<>endobj 2935 0 obj<>endobj 2936 0 obj<>endobj 2937 0 obj<>endobj 2938 0 obj<>endobj 2939 0 obj<>endobj 2940 0 obj<>endobj 2941 0 obj<>endobj 2942 0 obj<>endobj 2943 0 obj<>endobj 2944 0 obj<>endobj 2945 0 obj<>endobj 2946 0 obj<>endobj 2947 0 obj<>endobj 2948 0 obj<>endobj 2949 0 obj<>endobj 2950 0 obj<>endobj 2951 0 obj<>endobj 2952 0 obj<>endobj 2953 0 obj<>endobj 2954 0 obj<>endobj 2955 0 obj<>endobj 2956 0 obj<>endobj 2957 0 obj<>endobj 2958 0 obj<>endobj 2959 0 obj<>endobj 2960 0 obj<>endobj 2961 0 obj<>endobj 2962 0 obj<>endobj 2963 0 obj<>endobj 2964 0 obj<>endobj 2965 0 obj<>endobj 2966 0 obj<>endobj 2967 0 obj<>endobj 2968 0 obj<>endobj 2969 0 obj<>endobj 2970 0 obj[2917 0 R 2918 0 R 2919 0 R 2920 0 R 2921 0 R 2922 0 R 2923 0 R 2924 0 R 2925 0 R 2926 0 R 2927 0 R 2928 0 R 2929 0 R 2930 0 R 2931 0 R 2932 0 R 2933 0 R 2934 0 R 2935 0 R 2936 0 R 2937 0 R 2938 0 R 2939 0 R 2940 0 R 2941 0 R 2942 0 R 2943 0 R 2944 0 R 2945 0 R 2946 0 R 2947 0 R 2948 0 R 2949 0 R 2950 0 R 2951 0 R 2952 0 R 2953 0 R 2954 0 R 2955 0 R 2956 0 R 2957 0 R 2958 0 R 2959 0 R 2960 0 R 2961 0 R 2962 0 R 2963 0 R 2964 0 R 2965 0 R 2966 0 R 2967 0 R 2968 0 R 2969 0 R]endobj 2971 0 obj<>endobj 2972 0 obj<>endobj 2973 0 obj<>endobj 2974 0 obj<>endobj 2975 0 obj<>endobj 2976 0 obj<>endobj 2977 0 obj<>endobj 2978 0 obj<>endobj 2979 0 obj<>endobj 2980 0 obj<>endobj 2981 0 obj<>endobj 2982 0 obj<>endobj 2983 0 obj<>endobj 2984 0 obj<>endobj 2985 0 obj<>endobj 2986 0 obj<>endobj 2987 0 obj<>endobj 2988 0 obj<>endobj 2989 0 obj<>endobj 2990 0 obj<>endobj 2991 0 obj<>endobj 2992 0 obj<>endobj 2993 0 obj<>endobj 2994 0 obj<>endobj 2995 0 obj<>endobj 2996 0 obj<>endobj 2997 0 obj<>endobj 2998 0 obj<>endobj 2999 0 obj<>endobj 3000 0 obj<>endobj 3001 0 obj[2971 0 R 2972 0 R 2973 0 R 2974 0 R 2975 0 R 2976 0 R 2977 0 R 2978 0 R 2979 0 R 2980 0 R 2981 0 R 2982 0 R 2983 0 R 2984 0 R 2985 0 R 2986 0 R 2987 0 R 2988 0 R 2989 0 R 2990 0 R 2991 0 R 2992 0 R 2993 0 R 2994 0 R 2995 0 R 2996 0 R 2997 0 R 2998 0 R 2999 0 R 3000 0 R]endobj 3002 0 obj<>endobj 3003 0 obj<>endobj 3004 0 obj[3003 0 R]endobj 3005 0 obj<>endobj 3006 0 obj<>endobj 3007 0 obj[3006 0 R]endobj 3008 0 obj<>endobj 3009 0 obj<>endobj 3010 0 obj<>endobj 3011 0 obj<>endobj 3012 0 obj[3009 0 R 3011 0 R]endobj 3013 0 obj<>endobj 3014 0 obj<>endobj 3015 0 obj[3014 0 R]endobj 3016 0 obj<>endobj 3017 0 obj<>endobj 3018 0 obj[3016 0 R 3017 0 R]endobj 3019 0 obj<>endobj 3020 0 obj[3019 0 R]endobj 3021 0 obj<>endobj 3022 0 obj[3021 0 R]endobj 3023 0 obj<>endobj 3024 0 obj<>endobj 3025 0 obj<>endobj 3026 0 obj<>endobj 3027 0 obj[3023 0 R 3024 0 R 3025 0 R 3026 0 R]endobj 3028 0 obj<>endobj 3029 0 obj<>endobj 3030 0 obj[3029 0 R]endobj 3031 0 obj<>endobj 3032 0 obj[3031 0 R]endobj 3033 0 obj<>endobj 3034 0 obj<>endobj 3035 0 obj[3034 0 R]endobj 3036 0 obj<>endobj 3037 0 obj[3036 0 R]endobj 3038 0 obj<>endobj 3039 0 obj<>endobj 3040 0 obj[3039 0 R]endobj 3041 0 obj<>endobj 3042 0 obj[3041 0 R]endobj 3043 0 obj<>endobj 3044 0 obj[3043 0 R]endobj 3045 0 obj<>endobj 3046 0 obj<>endobj 3047 0 obj[3045 0 R 3046 0 R]endobj 3048 0 obj<>endobj 3049 0 obj[3048 0 R]endobj 3050 0 obj<>endobj 3051 0 obj[3050 0 R]endobj 3052 0 obj<>endobj 3053 0 obj<>endobj 3054 0 obj[3053 0 R]endobj 3055 0 obj<>endobj 3056 0 obj<>endobj 3057 0 obj[3056 0 R]endobj 3058 0 obj<>endobj 3059 0 obj<>endobj 3060 0 obj[3059 0 R]endobj 3061 0 obj<>endobj 3062 0 obj<>endobj 3063 0 obj[3062 0 R]endobj 3064 0 obj<>endobj 3065 0 obj<>endobj 3066 0 obj<>endobj 3067 0 obj<>endobj 3068 0 obj<>endobj 3069 0 obj<>endobj 3070 0 obj<>endobj 3071 0 obj<>endobj 3072 0 obj<>endobj 3073 0 obj[3064 0 R 3065 0 R 3066 0 R 3067 0 R 3068 0 R 3069 0 R 3070 0 R 3072 0 R]endobj 3074 0 obj<>endobj 3075 0 obj<>endobj 3076 0 obj<>endobj 3077 0 obj<>endobj 3078 0 obj<>endobj 3079 0 obj<>endobj 3080 0 obj<>endobj 3081 0 obj<>endobj 3082 0 obj<>endobj 3083 0 obj<>endobj 3084 0 obj<>endobj 3085 0 obj<>endobj 3086 0 obj<>endobj 3087 0 obj<>endobj 3088 0 obj<>endobj 3089 0 obj<>endobj 3090 0 obj<>endobj 3091 0 obj<>endobj 3092 0 obj<>endobj 3093 0 obj<>endobj 3094 0 obj<>endobj 3095 0 obj<>endobj 3096 0 obj<>endobj 3097 0 obj<>endobj 3098 0 obj<>endobj 3099 0 obj<>endobj 3100 0 obj<>endobj 3101 0 obj<>endobj 3102 0 obj<>endobj 3103 0 obj<>endobj 3104 0 obj<>endobj 3105 0 obj<>endobj 3106 0 obj<>endobj 3107 0 obj<>endobj 3108 0 obj<>endobj 3109 0 obj<>endobj 3110 0 obj<>endobj 3111 0 obj<>endobj 3112 0 obj<>endobj 3113 0 obj<>endobj 3114 0 obj<>endobj 3115 0 obj<>endobj 3116 0 obj<>endobj 3117 0 obj<>endobj 3118 0 obj<>endobj 3119 0 obj<>endobj 3120 0 obj<>endobj 3121 0 obj<>endobj 3122 0 obj<>endobj 3123 0 obj<>endobj 3124 0 obj<>endobj 3125 0 obj<>endobj 3126 0 obj<>endobj 3127 0 obj[3074 0 R 3075 0 R 3076 0 R 3077 0 R 3078 0 R 3079 0 R 3080 0 R 3081 0 R 3082 0 R 3083 0 R 3084 0 R 3085 0 R 3086 0 R 3087 0 R 3088 0 R 3089 0 R 3090 0 R 3091 0 R 3092 0 R 3093 0 R 3094 0 R 3095 0 R 3096 0 R 3097 0 R 3098 0 R 3099 0 R 3100 0 R 3101 0 R 3102 0 R 3103 0 R 3104 0 R 3105 0 R 3106 0 R 3107 0 R 3108 0 R 3109 0 R 3110 0 R 3111 0 R 3112 0 R 3113 0 R 3114 0 R 3115 0 R 3116 0 R 3117 0 R 3118 0 R 3119 0 R 3120 0 R 3121 0 R 3122 0 R 3123 0 R 3124 0 R 3125 0 R 3126 0 R]endobj 3128 0 obj<>endobj 3129 0 obj<>endobj 3130 0 obj<>endobj 3131 0 obj<>endobj 3132 0 obj<>endobj 3133 0 obj<>endobj 3134 0 obj<>endobj 3135 0 obj<>endobj 3136 0 obj<>endobj 3137 0 obj<>endobj 3138 0 obj<>endobj 3139 0 obj<>endobj 3140 0 obj<>endobj 3141 0 obj<>endobj 3142 0 obj<>endobj 3143 0 obj<>endobj 3144 0 obj<>endobj 3145 0 obj<>endobj 3146 0 obj<>endobj 3147 0 obj<>endobj 3148 0 obj<>endobj 3149 0 obj<>endobj 3150 0 obj<>endobj 3151 0 obj<>endobj 3152 0 obj<>endobj 3153 0 obj<>endobj 3154 0 obj<>endobj 3155 0 obj<>endobj 3156 0 obj<>endobj 3157 0 obj<>endobj 3158 0 obj<>endobj 3159 0 obj<>endobj 3160 0 obj<>endobj 3161 0 obj<>endobj 3162 0 obj<>endobj 3163 0 obj<>endobj 3164 0 obj<>endobj 3165 0 obj<>endobj 3166 0 obj<>endobj 3167 0 obj<>endobj 3168 0 obj<>endobj 3169 0 obj<>endobj 3170 0 obj<>endobj 3171 0 obj<>endobj 3172 0 obj<>endobj 3173 0 obj[3128 0 R 3129 0 R 3130 0 R 3131 0 R 3132 0 R 3133 0 R 3134 0 R 3135 0 R 3136 0 R 3137 0 R 3138 0 R 3139 0 R 3140 0 R 3141 0 R 3142 0 R 3143 0 R 3144 0 R 3145 0 R 3146 0 R 3147 0 R 3148 0 R 3149 0 R 3150 0 R 3151 0 R 3152 0 R 3153 0 R 3154 0 R 3155 0 R 3156 0 R 3157 0 R 3158 0 R 3159 0 R 3160 0 R 3161 0 R 3162 0 R 3163 0 R 3164 0 R 3165 0 R 3166 0 R 3167 0 R 3168 0 R 3169 0 R 3170 0 R 3171 0 R 3172 0 R]endobj 3174 0 obj<>endobj 3175 0 obj<>endobj 3176 0 obj[3175 0 R]endobj 3177 0 obj<>endobj 3178 0 obj[3177 0 R]endobj 3179 0 obj<>endobj 3180 0 obj<>endobj 3181 0 obj[3180 0 R]endobj 3182 0 obj<>endobj 3183 0 obj<>endobj 3184 0 obj[3182 0 R 3183 0 R]endobj 3185 0 obj<>endobj 3186 0 obj<>endobj 3187 0 obj[3185 0 R 3186 0 R]endobj 3188 0 obj<>endobj 3189 0 obj[3188 0 R]endobj 3190 0 obj<>endobj 3191 0 obj[3190 0 R]endobj 3192 0 obj<>endobj 3193 0 obj<>endobj 3194 0 obj[3192 0 R 3193 0 R]endobj 3195 0 obj<>endobj 3196 0 obj[3195 0 R]endobj 3197 0 obj<>endobj 3198 0 obj[3197 0 R]endobj 3199 0 obj<>endobj 3200 0 obj[3199 0 R]endobj 3201 0 obj<>endobj 3202 0 obj[3201 0 R]endobj 3203 0 obj<>endobj 3204 0 obj<>endobj 3205 0 obj[3204 0 R]endobj 3206 0 obj<>endobj 3207 0 obj[3206 0 R]endobj 3208 0 obj<>endobj 3209 0 obj<>endobj 3210 0 obj[3209 0 R]endobj 3211 0 obj<>endobj 3212 0 obj[3211 0 R]endobj 3213 0 obj<>endobj 3214 0 obj[3213 0 R]endobj 3215 0 obj<>endobj 3216 0 obj[3215 0 R]endobj 3217 0 obj<>endobj 3218 0 obj<>endobj 3219 0 obj<>endobj 3220 0 obj[3217 0 R 3219 0 R]endobj 3221 0 obj<>endobj 3222 0 obj[3221 0 R]endobj 3223 0 obj<>endobj 3224 0 obj[3223 0 R]endobj 3225 0 obj<>endobj 3226 0 obj<>endobj 3227 0 obj[3225 0 R 3226 0 R]endobj 3228 0 obj<>endobj 3229 0 obj[3228 0 R]endobj 3230 0 obj<>endobj 3231 0 obj[3230 0 R]endobj 3232 0 obj<>endobj 3233 0 obj<>endobj 3234 0 obj<>endobj 3235 0 obj<>endobj 3236 0 obj<>endobj 3237 0 obj<>endobj 3238 0 obj<>endobj 3239 0 obj<>endobj 3240 0 obj<>endobj 3241 0 obj<>endobj 3242 0 obj<>endobj 3243 0 obj<>endobj 3244 0 obj<>endobj 3245 0 obj<>endobj 3246 0 obj<>endobj 3247 0 obj<>endobj 3248 0 obj<>endobj 3249 0 obj<>endobj 3250 0 obj<>endobj 3251 0 obj<>endobj 3252 0 obj<>endobj 3253 0 obj<>endobj 3254 0 obj<>endobj 3255 0 obj<>endobj 3256 0 obj<>endobj 3257 0 obj<>endobj 3258 0 obj<>endobj 3259 0 obj<>endobj 3260 0 obj<>endobj 3261 0 obj<>endobj 3262 0 obj<>endobj 3263 0 obj<>endobj 3264 0 obj<>endobj 3265 0 obj<>endobj 3266 0 obj<>endobj 3267 0 obj<>endobj 3268 0 obj<>endobj 3269 0 obj<>endobj 3270 0 obj<>endobj 3271 0 obj<>endobj 3272 0 obj<>endobj 3273 0 obj<>endobj 3274 0 obj<>endobj 3275 0 obj<>endobj 3276 0 obj<>endobj 3277 0 obj[3232 0 R 3233 0 R 3234 0 R 3235 0 R 3236 0 R 3237 0 R 3238 0 R 3239 0 R 3240 0 R 3241 0 R 3242 0 R 3243 0 R 3244 0 R 3245 0 R 3246 0 R 3247 0 R 3248 0 R 3249 0 R 3250 0 R 3251 0 R 3252 0 R 3253 0 R 3254 0 R 3255 0 R 3256 0 R 3257 0 R 3258 0 R 3259 0 R 3260 0 R 3261 0 R 3262 0 R 3263 0 R 3264 0 R 3265 0 R 3266 0 R 3267 0 R 3268 0 R 3269 0 R 3270 0 R 3271 0 R 3272 0 R 3273 0 R 3274 0 R 3275 0 R 3276 0 R]endobj 3278 0 obj<>endobj 3279 0 obj<>endobj 3280 0 obj[3279 0 R]endobj 3281 0 obj<>endobj 3282 0 obj<>endobj 3283 0 obj[3281 0 R 3282 0 R]endobj 3284 0 obj<>endobj 3285 0 obj[3284 0 R]endobj 3286 0 obj<>endobj 3287 0 obj[3286 0 R]endobj 3288 0 obj<>endobj 3289 0 obj<>endobj 3290 0 obj[3288 0 R 3289 0 R]endobj 3291 0 obj<>endobj 3292 0 obj<>endobj 3293 0 obj[3291 0 R 3292 0 R]endobj 3294 0 obj<>endobj 3295 0 obj[3294 0 R]endobj 3296 0 obj<>endobj 3297 0 obj<>endobj 3298 0 obj[3297 0 R]endobj 3299 0 obj<>endobj 3300 0 obj<>endobj 3301 0 obj<>endobj 3302 0 obj<>endobj 3303 0 obj<>endobj 3304 0 obj<>endobj 3305 0 obj<>endobj 3306 0 obj<>endobj 3307 0 obj<>endobj 3308 0 obj<>endobj 3309 0 obj<>endobj 3310 0 obj<>endobj 3311 0 obj<>endobj 3312 0 obj<>endobj 3313 0 obj<>endobj 3314 0 obj<>endobj 3315 0 obj<>endobj 3316 0 obj<>endobj 3317 0 obj<>endobj 3318 0 obj<>endobj 3319 0 obj<>endobj 3320 0 obj<>endobj 3321 0 obj<>endobj 3322 0 obj<>endobj 3323 0 obj<>endobj 3324 0 obj<>endobj 3325 0 obj<>endobj 3326 0 obj<>endobj 3327 0 obj<>endobj 3328 0 obj<>endobj 3329 0 obj<>endobj 3330 0 obj<>endobj 3331 0 obj<>endobj 3332 0 obj<>endobj 3333 0 obj<>endobj 3334 0 obj<>endobj 3335 0 obj<>endobj 3336 0 obj<>endobj 3337 0 obj<>endobj 3338 0 obj<>endobj 3339 0 obj<>endobj 3340 0 obj<>endobj 3341 0 obj<>endobj 3342 0 obj<>endobj 3343 0 obj<>endobj 3344 0 obj<>endobj 3345 0 obj<>endobj 3346 0 obj<>endobj 3347 0 obj<>endobj 3348 0 obj[3299 0 R 3300 0 R 3301 0 R 3302 0 R 3303 0 R 3304 0 R 3305 0 R 3306 0 R 3307 0 R 3308 0 R 3309 0 R 3310 0 R 3311 0 R 3312 0 R 3313 0 R 3314 0 R 3315 0 R 3316 0 R 3317 0 R 3318 0 R 3319 0 R 3320 0 R 3321 0 R 3322 0 R 3323 0 R 3324 0 R 3325 0 R 3326 0 R 3327 0 R 3328 0 R 3329 0 R 3330 0 R 3331 0 R 3332 0 R 3333 0 R 3334 0 R 3335 0 R 3336 0 R 3337 0 R 3338 0 R 3339 0 R 3340 0 R 3341 0 R 3342 0 R 3343 0 R 3344 0 R 3345 0 R 3346 0 R 3347 0 R]endobj 3349 0 obj<>endobj 3350 0 obj<>endobj 3351 0 obj[3350 0 R]endobj 3352 0 obj<>endobj 3353 0 obj[3352 0 R]endobj 3354 0 obj<>endobj 3355 0 obj[3354 0 R]endobj 3356 0 obj<>endobj 3357 0 obj<>endobj 3358 0 obj<>endobj 3359 0 obj<>endobj 3360 0 obj[3357 0 R 3358 0 R 3359 0 R]endobj 3361 0 obj<>endobj 3362 0 obj[3361 0 R]endobj 3363 0 obj<>endobj 3364 0 obj<>endobj 3365 0 obj<>endobj 3366 0 obj<>endobj 3367 0 obj<>endobj 3368 0 obj<>endobj 3369 0 obj<>endobj 3370 0 obj<>endobj 3371 0 obj<>endobj 3372 0 obj<>endobj 3373 0 obj<>endobj 3374 0 obj<>endobj 3375 0 obj<>endobj 3376 0 obj<>endobj 3377 0 obj<>endobj 3378 0 obj<>endobj 3379 0 obj<>endobj 3380 0 obj<>endobj 3381 0 obj<>endobj 3382 0 obj<>endobj 3383 0 obj<>endobj 3384 0 obj<>endobj 3385 0 obj<>endobj 3386 0 obj<>endobj 3387 0 obj<>endobj 3388 0 obj<>endobj 3389 0 obj<>endobj 3390 0 obj<>endobj 3391 0 obj<>endobj 3392 0 obj<>endobj 3393 0 obj<>endobj 3394 0 obj<>endobj 3395 0 obj<>endobj 3396 0 obj<>endobj 3397 0 obj<>endobj 3398 0 obj<>endobj 3399 0 obj<>endobj 3400 0 obj<>endobj 3401 0 obj<>endobj 3402 0 obj<>endobj 3403 0 obj<>endobj 3404 0 obj<>endobj 3405 0 obj<>endobj 3406 0 obj<>endobj 3407 0 obj<>endobj 3408 0 obj<>endobj 3409 0 obj<>endobj 3410 0 obj<>endobj 3411 0 obj<>endobj 3412 0 obj<>endobj 3413 0 obj<>endobj 3414 0 obj<>endobj 3415 0 obj<>endobj 3416 0 obj<>endobj 3417 0 obj<>endobj 3418 0 obj<>endobj 3419 0 obj<>endobj 3420 0 obj<>endobj 3421 0 obj<>endobj 3422 0 obj<>endobj 3423 0 obj<>endobj 3424 0 obj<>endobj 3425 0 obj<>endobj 3426 0 obj<>endobj 3427 0 obj<>endobj 3428 0 obj<>endobj 3429 0 obj<>endobj 3430 0 obj<>endobj 3431 0 obj<>endobj 3432 0 obj<>endobj 3433 0 obj<>endobj 3434 0 obj<>endobj 3435 0 obj<>endobj 3436 0 obj<>endobj 3437 0 obj<>endobj 3438 0 obj<>endobj 3439 0 obj<>endobj 3440 0 obj<>endobj 3441 0 obj<>endobj 3442 0 obj<>endobj 3443 0 obj<>endobj 3444 0 obj<>endobj 3445 0 obj<>endobj 3446 0 obj<>endobj 3447 0 obj<>endobj 3448 0 obj<>endobj 3449 0 obj<>endobj 3450 0 obj<>endobj 3451 0 obj<>endobj 3452 0 obj<>endobj 3453 0 obj<>endobj 3454 0 obj<>endobj 3455 0 obj<>endobj 3456 0 obj<>endobj 3457 0 obj<>endobj 3458 0 obj<>endobj 3459 0 obj<>endobj 3460 0 obj<>endobj 3461 0 obj<>endobj 3462 0 obj<>endobj 3463 0 obj<>endobj 3464 0 obj<>endobj 3465 0 obj<>endobj 3466 0 obj<>endobj 3467 0 obj<>endobj 3468 0 obj<>endobj 3469 0 obj<>endobj 3470 0 obj<>endobj 3471 0 obj<>endobj 3472 0 obj<>endobj 3473 0 obj<>endobj 3474 0 obj<>endobj 3475 0 obj<>endobj 3476 0 obj<>endobj 3477 0 obj<>endobj 3478 0 obj<>endobj 3479 0 obj<>endobj 3480 0 obj<>endobj 3481 0 obj<>endobj 3482 0 obj<>endobj 3483 0 obj<>endobj 3484 0 obj<>endobj 3485 0 obj<>endobj 3486 0 obj<>endobj 3487 0 obj<>endobj 3488 0 obj<>endobj 3489 0 obj<>endobj 3490 0 obj<>endobj 3491 0 obj<>endobj 3492 0 obj<>endobj 3493 0 obj<>endobj 3494 0 obj<>endobj 3495 0 obj<>endobj 3496 0 obj<>endobj 3497 0 obj<>endobj 3498 0 obj<>endobj 3499 0 obj<>endobj 3500 0 obj<>endobj 3501 0 obj<>endobj 3502 0 obj<>endobj 3503 0 obj<>endobj 3504 0 obj<>endobj 3505 0 obj<>endobj 3506 0 obj<>endobj 3507 0 obj<>endobj 3508 0 obj<>endobj 3509 0 obj<>endobj 3510 0 obj<>endobj 3511 0 obj<>endobj 3512 0 obj<>endobj 3513 0 obj<>endobj 3514 0 obj<>endobj 3515 0 obj<>endobj 3516 0 obj<>endobj 3517 0 obj<>endobj 3518 0 obj<>endobj 3519 0 obj<>endobj 3520 0 obj<>endobj 3521 0 obj<>endobj 3522 0 obj<>endobj 3523 0 obj<>endobj 3524 0 obj<>endobj 3525 0 obj<>endobj 3526 0 obj<>endobj 3527 0 obj<>endobj 3528 0 obj<>endobj 3529 0 obj<>endobj 3530 0 obj<>endobj 3531 0 obj<>endobj 3532 0 obj<>endobj 3533 0 obj<>endobj 3534 0 obj<>endobj 3535 0 obj<>endobj 3536 0 obj<>endobj 3537 0 obj<>endobj 3538 0 obj<>endobj 3539 0 obj<>endobj 3540 0 obj<>endobj 3541 0 obj<>endobj 3542 0 obj<>endobj 3543 0 obj<>endobj 3544 0 obj<>endobj 3545 0 obj<>endobj 3546 0 obj<>endobj 3547 0 obj<>endobj 3548 0 obj<>endobj 3549 0 obj<>endobj 3550 0 obj<>endobj 3551 0 obj<>endobj 3552 0 obj<>endobj 3553 0 obj<>endobj 3554 0 obj<>endobj 3555 0 obj<>endobj 3556 0 obj<>endobj 3557 0 obj<>endobj 3558 0 obj<>endobj 3559 0 obj<>endobj 3560 0 obj<>endobj 3561 0 obj<>endobj 3562 0 obj<>endobj 3563 0 obj<>endobj 3564 0 obj<>endobj 3565 0 obj<>endobj 3566 0 obj<>endobj 3567 0 obj<>endobj 3568 0 obj<>endobj 3569 0 obj<>endobj 3570 0 obj<>endobj 3571 0 obj<>endobj 3572 0 obj<>endobj 3573 0 obj<>endobj 3574 0 obj<>endobj 3575 0 obj<>endobj 3576 0 obj<>endobj 3577 0 obj<>endobj 3578 0 obj<>endobj 3579 0 obj<>endobj 3580 0 obj<>endobj 3581 0 obj<>endobj 3582 0 obj<>endobj 3583 0 obj<>endobj 3584 0 obj<>endobj 3585 0 obj<>endobj 3586 0 obj<>endobj 3587 0 obj<>endobj 3588 0 obj<>endobj 3589 0 obj<>endobj 3590 0 obj<>endobj 3591 0 obj<>endobj 3592 0 obj<>endobj 3593 0 obj<>endobj 3594 0 obj<>endobj 3595 0 obj<>endobj 3596 0 obj<>endobj 3597 0 obj<>endobj 3598 0 obj<>endobj 3599 0 obj<>endobj 3600 0 obj<>endobj 3601 0 obj<>endobj 3602 0 obj<>endobj 3603 0 obj<>endobj 3604 0 obj<>endobj 3605 0 obj<>endobj 3606 0 obj<>endobj 3607 0 obj<>endobj 3608 0 obj<>endobj 3609 0 obj<>endobj 3610 0 obj<>endobj 3611 0 obj<>endobj 3612 0 obj<>endobj 3613 0 obj<>endobj 3614 0 obj<>endobj 3615 0 obj<>endobj 3616 0 obj<>endobj 3617 0 obj<>endobj 3618 0 obj<>endobj 3619 0 obj<>endobj 3620 0 obj<>endobj 3621 0 obj<>endobj 3622 0 obj<>endobj 3623 0 obj<>endobj 3624 0 obj<>endobj 3625 0 obj<>endobj 3626 0 obj<>endobj 3627 0 obj<>endobj 3628 0 obj<>endobj 3629 0 obj<>endobj 3630 0 obj<>endobj 3631 0 obj<>endobj 3632 0 obj<>endobj 3633 0 obj<>endobj 3634 0 obj<>endobj 3635 0 obj<>endobj 3636 0 obj<>endobj 3637 0 obj<>endobj 3638 0 obj<>endobj 3639 0 obj<>endobj 3640 0 obj<>endobj 3641 0 obj<>endobj 3642 0 obj<>endobj 3643 0 obj<>endobj 3644 0 obj<>endobj 3645 0 obj<>endobj 3646 0 obj<>endobj 3647 0 obj<>endobj 3648 0 obj<>endobj 3649 0 obj<>endobj 3650 0 obj<>endobj 3651 0 obj<>endobj 3652 0 obj<>endobj 3653 0 obj<>endobj 3654 0 obj<>endobj 3655 0 obj<>endobj 3656 0 obj<>endobj 3657 0 obj<>endobj 3658 0 obj<>endobj 3659 0 obj<>endobj 3660 0 obj<>endobj 3661 0 obj<>endobj 3662 0 obj<>endobj 3663 0 obj<>endobj 3664 0 obj<>endobj 3665 0 obj<>endobj 3666 0 obj<>endobj 3667 0 obj<>endobj 3668 0 obj<>endobj 3669 0 obj<>endobj 3670 0 obj<>endobj 3671 0 obj<>endobj 3672 0 obj<>endobj 3673 0 obj<>endobj 3674 0 obj<>endobj 3675 0 obj<>endobj 3676 0 obj<>endobj 3677 0 obj<>endobj 3678 0 obj<>endobj 3679 0 obj<>endobj 3680 0 obj<>endobj 3681 0 obj<>endobj 3682 0 obj<>endobj 3683 0 obj<>endobj 3684 0 obj<>endobj 3685 0 obj<>endobj 3686 0 obj<>endobj 3687 0 obj<>endobj 3688 0 obj<>endobj 3689 0 obj<>endobj 3690 0 obj<>endobj 3691 0 obj<>endobj 3692 0 obj<>endobj 3693 0 obj<>endobj 3694 0 obj<>endobj 3695 0 obj<>endobj 3696 0 obj<>endobj 3697 0 obj<>endobj 3698 0 obj<>endobj 3699 0 obj<>endobj 3700 0 obj<>endobj 3701 0 obj<>endobj 3702 0 obj<>endobj 3703 0 obj<>endobj 3704 0 obj<>endobj 3705 0 obj<>endobj 3706 0 obj<>endobj 3707 0 obj<>endobj 3708 0 obj<>endobj 3709 0 obj<>endobj 3710 0 obj<>endobj 3711 0 obj<>endobj 3712 0 obj<>endobj 3713 0 obj<>endobj 3714 0 obj<>endobj 3715 0 obj<>endobj 3716 0 obj<>endobj 3717 0 obj<>endobj 3718 0 obj<>endobj 3719 0 obj<>endobj 3720 0 obj<>endobj 3721 0 obj<>endobj 3722 0 obj<>endobj 3723 0 obj<>endobj 3724 0 obj<>endobj 3725 0 obj<>endobj 3726 0 obj<>endobj 3727 0 obj<>endobj 3728 0 obj<>endobj 3729 0 obj<>endobj 3730 0 obj<>endobj 3731 0 obj<>endobj 3732 0 obj<>endobj 3733 0 obj<>endobj 3734 0 obj<>endobj 3735 0 obj<>endobj 3736 0 obj<>endobj 3737 0 obj<>endobj 3738 0 obj<>endobj 3739 0 obj<>endobj 3740 0 obj<>endobj 3741 0 obj<>endobj 3742 0 obj<>endobj 3743 0 obj<>endobj 3744 0 obj<>endobj 3745 0 obj<>endobj 3746 0 obj<>endobj 3747 0 obj<>endobj 3748 0 obj<>endobj 3749 0 obj<>endobj 3750 0 obj<>endobj 3751 0 obj<>endobj 3752 0 obj<>endobj 3753 0 obj<>endobj 3754 0 obj<>endobj 3755 0 obj<>endobj 3756 0 obj<>endobj 3757 0 obj<>endobj 3758 0 obj<>endobj 3759 0 obj<>endobj 3760 0 obj<>endobj 3761 0 obj<>endobj 3762 0 obj<>endobj 3763 0 obj<>endobj 3764 0 obj<>endobj 3765 0 obj<>endobj 3766 0 obj<>endobj 3767 0 obj<>endobj 3768 0 obj<>endobj 3769 0 obj<>endobj 3770 0 obj<>endobj 3771 0 obj<>endobj 3772 0 obj<>endobj 3773 0 obj<>endobj 3774 0 obj<>endobj 3775 0 obj<>endobj 3776 0 obj<>endobj 3777 0 obj<>endobj 3778 0 obj<>endobj 3779 0 obj<>endobj 3780 0 obj<>endobj 3781 0 obj<>endobj 3782 0 obj<>endobj 3783 0 obj<>endobj 3784 0 obj<>endobj 3785 0 obj<>endobj 3786 0 obj<>endobj 3787 0 obj<>endobj 3788 0 obj<>endobj 3789 0 obj<>endobj 3790 0 obj<>endobj 3791 0 obj<>endobj 3792 0 obj<>endobj 3793 0 obj<>endobj 3794 0 obj<>endobj 3795 0 obj<>endobj 3796 0 obj<>endobj 3797 0 obj<>endobj 3798 0 obj<>endobj 3799 0 obj<>endobj 3800 0 obj<>endobj 3801 0 obj<>endobj 3802 0 obj<>endobj 3803 0 obj<>endobj 3804 0 obj<>endobj 3805 0 obj<>endobj 3806 0 obj<>endobj 3807 0 obj<>endobj 3808 0 obj<>endobj 3809 0 obj<>endobj 3810 0 obj<>endobj 3811 0 obj<>endobj 3812 0 obj<>endobj 3813 0 obj<>endobj 3814 0 obj<>endobj 3815 0 obj<>endobj 3816 0 obj<>endobj 3817 0 obj<>endobj 3818 0 obj<>endobj 3819 0 obj<>endobj 3820 0 obj<>endobj 3821 0 obj<>endobj 3822 0 obj<>endobj 3823 0 obj<>endobj 3824 0 obj<>endobj 3825 0 obj<>endobj 3826 0 obj<>endobj 3827 0 obj<>endobj 3828 0 obj<>endobj 3829 0 obj<>endobj 3830 0 obj<>endobj 3831 0 obj<>endobj 3832 0 obj<>endobj 3833 0 obj<>endobj 3834 0 obj<>endobj 3835 0 obj<>endobj 3836 0 obj<>endobj 3837 0 obj<>endobj 3838 0 obj<>endobj 3839 0 obj<>endobj 3840 0 obj<>endobj 3841 0 obj<>endobj 3842 0 obj<>endobj 3843 0 obj<>endobj 3844 0 obj<>endobj 3845 0 obj<>endobj 3846 0 obj<>endobj 3847 0 obj<>endobj 3848 0 obj<>endobj 3849 0 obj<>endobj 3850 0 obj<>endobj 3851 0 obj<>endobj 3852 0 obj<>endobj 3853 0 obj<>endobj 3854 0 obj<>endobj 3855 0 obj<>endobj 3856 0 obj<>endobj 3857 0 obj<>endobj 3858 0 obj<>endobj 3859 0 obj<>endobj 3860 0 obj<>endobj 3861 0 obj<>endobj 3862 0 obj<>endobj 3863 0 obj<>endobj 3864 0 obj<>endobj 3865 0 obj<>endobj 3866 0 obj<>endobj 3867 0 obj<>endobj 3868 0 obj<>endobj 3869 0 obj<>endobj 3870 0 obj<>endobj 3871 0 obj<>endobj 3872 0 obj<>endobj 3873 0 obj<>endobj 3874 0 obj<>endobj 3875 0 obj<>endobj 3876 0 obj<>endobj 3877 0 obj<>endobj 3878 0 obj<>endobj 3879 0 obj<>endobj 3880 0 obj<>endobj 3881 0 obj<>endobj 3882 0 obj<>endobj 3883 0 obj<>endobj 3884 0 obj<>endobj 3885 0 obj<>endobj 3886 0 obj<>endobj 3887 0 obj<>endobj 3888 0 obj<>endobj 3889 0 obj<>endobj 3890 0 obj<>endobj 3891 0 obj<>endobj 3892 0 obj<>endobj 3893 0 obj<>endobj 3894 0 obj<>endobj 3895 0 obj<>endobj 3896 0 obj<>endobj 3897 0 obj<>endobj 3898 0 obj<>endobj 3899 0 obj<>endobj 3900 0 obj<>endobj 3901 0 obj<>endobj 3902 0 obj<>endobj 3903 0 obj<>endobj 3904 0 obj<>endobj 3905 0 obj<>endobj 3906 0 obj<>endobj 3907 0 obj<>endobj 3908 0 obj<>endobj 3909 0 obj<>endobj 3910 0 obj<>endobj 3911 0 obj<>endobj 3912 0 obj<>endobj 3913 0 obj<>endobj 3914 0 obj<>endobj 3915 0 obj<>endobj 3916 0 obj<>endobj 3917 0 obj<>endobj 3918 0 obj<>endobj 3919 0 obj<>endobj 3920 0 obj<>endobj 3921 0 obj<>endobj 3922 0 obj<>endobj 3923 0 obj<>endobj 3924 0 obj<>endobj 3925 0 obj<>endobj 3926 0 obj<>endobj 3927 0 obj<>endobj 3928 0 obj<>endobj 3929 0 obj<>endobj 3930 0 obj<>endobj 3931 0 obj<>endobj 3932 0 obj<>endobj 3933 0 obj<>endobj 3934 0 obj<>endobj 3935 0 obj<>endobj 3936 0 obj<>endobj 3937 0 obj<>endobj 3938 0 obj<>endobj 3939 0 obj<>endobj 3940 0 obj<>endobj 3941 0 obj<>endobj 3942 0 obj<>endobj 3943 0 obj<>endobj 3944 0 obj<>endobj 3945 0 obj<>endobj 3946 0 obj<>endobj 3947 0 obj<>endobj 3948 0 obj<>endobj 3949 0 obj<>endobj 3950 0 obj<>endobj 3951 0 obj<>endobj 3952 0 obj<>endobj 3953 0 obj<>endobj 3954 0 obj<>endobj 3955 0 obj<>endobj 3956 0 obj<>endobj 3957 0 obj<>endobj 3958 0 obj<>endobj 3959 0 obj<>endobj 3960 0 obj<>endobj 3961 0 obj<>endobj 3962 0 obj<>endobj 3963 0 obj<>endobj 3964 0 obj<>endobj 3965 0 obj<>endobj 3966 0 obj<>endobj 3967 0 obj<>endobj 3968 0 obj<>endobj 3969 0 obj<>endobj 3970 0 obj<>endobj 3971 0 obj<>endobj 3972 0 obj<>endobj 3973 0 obj<>endobj 3974 0 obj<>endobj 3975 0 obj<>endobj 3976 0 obj<>endobj 3977 0 obj<>endobj 3978 0 obj<>endobj 3979 0 obj<>endobj 3980 0 obj<>endobj 3981 0 obj<>endobj 3982 0 obj<>endobj 3983 0 obj<>endobj 3984 0 obj<>endobj 3985 0 obj<>endobj 3986 0 obj<>endobj 3987 0 obj<>endobj 3988 0 obj<>endobj 3989 0 obj<>endobj 3990 0 obj<>endobj 3991 0 obj<>endobj 3992 0 obj<>endobj 3993 0 obj<>endobj 3994 0 obj<>endobj 3995 0 obj<>endobj 3996 0 obj<>endobj 3997 0 obj<>endobj 3998 0 obj<>endobj 3999 0 obj<>endobj 4000 0 obj<>endobj 4001 0 obj<>endobj 4002 0 obj<>endobj 4003 0 obj<>endobj 4004 0 obj<>endobj 4005 0 obj<>endobj 4006 0 obj<>endobj 4007 0 obj<>endobj 4008 0 obj<>endobj 4009 0 obj<>endobj 4010 0 obj<>endobj 4011 0 obj<>endobj 4012 0 obj<>endobj 4013 0 obj<>endobj 4014 0 obj<>endobj 4015 0 obj<>endobj 4016 0 obj<>endobj 4017 0 obj<>endobj 4018 0 obj<>endobj 4019 0 obj<>endobj 4020 0 obj<>endobj 4021 0 obj<>endobj 4022 0 obj<>endobj 4023 0 obj<>endobj 4024 0 obj<>endobj 4025 0 obj<>endobj 4026 0 obj<>endobj 4027 0 obj<>endobj 4028 0 obj<>endobj 4029 0 obj<>endobj 4030 0 obj<>endobj 4031 0 obj<>endobj 4032 0 obj<>endobj 4033 0 obj<>endobj 4034 0 obj<>endobj 4035 0 obj<>endobj 4036 0 obj<>endobj 4037 0 obj<>endobj 4038 0 obj<>endobj 4039 0 obj<>endobj 4040 0 obj<>endobj 4041 0 obj<>endobj 4042 0 obj<>endobj 4043 0 obj<>endobj 4044 0 obj<>endobj 4045 0 obj<>endobj 4046 0 obj<>endobj 4047 0 obj<>endobj 4048 0 obj<>endobj 4049 0 obj<>endobj 4050 0 obj<>endobj 4051 0 obj<>endobj 4052 0 obj<>endobj 4053 0 obj<>endobj 4054 0 obj<>endobj 4055 0 obj<>endobj 4056 0 obj<>endobj 4057 0 obj<>endobj 4058 0 obj<>endobj 4059 0 obj<>endobj 4060 0 obj<>endobj 4061 0 obj<>endobj 4062 0 obj<>endobj 4063 0 obj<>endobj 4064 0 obj<>endobj 4065 0 obj<>endobj 4066 0 obj<>endobj 4067 0 obj<>endobj 4068 0 obj<>endobj 4069 0 obj<>endobj 4070 0 obj<>endobj 4071 0 obj<>endobj 4072 0 obj<>endobj 4073 0 obj<>endobj 4074 0 obj<>endobj 4075 0 obj<>endobj 4076 0 obj<>endobj 4077 0 obj<>endobj 4078 0 obj<>endobj 4079 0 obj<>endobj 4080 0 obj<>endobj 4081 0 obj<>endobj 4082 0 obj<>endobj 4083 0 obj<>endobj 4084 0 obj<>endobj 4085 0 obj<>endobj 4086 0 obj<>endobj 4087 0 obj<>endobj 4088 0 obj<>endobj 4089 0 obj<>endobj 4090 0 obj<>endobj 4091 0 obj<>endobj 4092 0 obj<>endobj 4093 0 obj<>endobj 4094 0 obj<>endobj 4095 0 obj<>endobj 4096 0 obj<>endobj 4097 0 obj<>endobj 4098 0 obj<>endobj 4099 0 obj<>endobj 4100 0 obj<>endobj 4101 0 obj<>endobj 4102 0 obj<>endobj 4103 0 obj<>endobj 4104 0 obj<>endobj 4105 0 obj<>endobj 4106 0 obj<>endobj 4107 0 obj<>endobj 4108 0 obj<>endobj 4109 0 obj<>endobj 4110 0 obj<>endobj 4111 0 obj<>endobj 4112 0 obj<>endobj 4113 0 obj<>endobj 4114 0 obj<>endobj 4115 0 obj<>endobj 4116 0 obj<>endobj 4117 0 obj<>endobj 4118 0 obj<>endobj 4119 0 obj<>endobj 4120 0 obj<>endobj 4121 0 obj<>endobj 4122 0 obj<>endobj 4123 0 obj<>endobj 4124 0 obj<>endobj 4125 0 obj<>endobj 4126 0 obj<>endobj 4127 0 obj<>endobj 4128 0 obj<>endobj 4129 0 obj<>endobj 4130 0 obj<>endobj 4131 0 obj<>endobj 4132 0 obj<>endobj 4133 0 obj<>endobj 4134 0 obj<>endobj 4135 0 obj<>endobj 4136 0 obj<>endobj 4137 0 obj<>endobj 4138 0 obj<>endobj 4139 0 obj<>endobj 4140 0 obj<>endobj 4141 0 obj<>endobj 4142 0 obj<>endobj 4143 0 obj<>endobj 4144 0 obj<>endobj 4145 0 obj<>endobj 4146 0 obj<>endobj 4147 0 obj<>endobj 4148 0 obj<>endobj 4149 0 obj<>endobj 4150 0 obj<>endobj 4151 0 obj<>endobj 4152 0 obj<>endobj 4153 0 obj<>endobj 4154 0 obj<>endobj 4155 0 obj<>endobj 4156 0 obj<>endobj 4157 0 obj<>endobj 4158 0 obj<>endobj 4159 0 obj<>endobj 4160 0 obj<>endobj 4161 0 obj<>endobj 4162 0 obj<>endobj 4163 0 obj<>endobj 4164 0 obj<>endobj 4165 0 obj<>endobj 4166 0 obj<>endobj 4167 0 obj<>endobj 4168 0 obj<>endobj 4169 0 obj<>endobj 4170 0 obj<>endobj 4171 0 obj<>endobj 4172 0 obj<>endobj 4173 0 obj<>endobj 4174 0 obj<>endobj 4175 0 obj<>endobj 4176 0 obj<>endobj 4177 0 obj<>endobj 4178 0 obj<>endobj 4179 0 obj<>endobj 4180 0 obj<>endobj 4181 0 obj<>endobj 4182 0 obj<>endobj 4183 0 obj<>endobj 4184 0 obj<>endobj 4185 0 obj<>endobj 4186 0 obj<>endobj 4187 0 obj<>endobj 4188 0 obj<>endobj 4189 0 obj<>endobj 4190 0 obj<>endobj 4191 0 obj<>endobj 4192 0 obj<>endobj 4193 0 obj<>endobj 4194 0 obj<>endobj 4195 0 obj<>endobj 4196 0 obj<>endobj 4197 0 obj<>endobj 4198 0 obj<>endobj 4199 0 obj<>endobj 4200 0 obj<>endobj 4201 0 obj<>endobj 4202 0 obj<>endobj 4203 0 obj<>endobj 4204 0 obj<>endobj 4205 0 obj<>endobj 4206 0 obj<>endobj 4207 0 obj<>endobj 4208 0 obj<>endobj 4209 0 obj<>endobj 4210 0 obj<>endobj 4211 0 obj<>endobj 4212 0 obj<>endobj 4213 0 obj<>endobj 4214 0 obj<>endobj 4215 0 obj<>endobj 4216 0 obj<>endobj 4217 0 obj<>endobj 4218 0 obj<>endobj 4219 0 obj<>endobj 4220 0 obj<>endobj 4221 0 obj<>endobj 4222 0 obj<>endobj 4223 0 obj<>endobj 4224 0 obj<>endobj 4225 0 obj<>endobj 4226 0 obj<>endobj 4227 0 obj<>endobj 4228 0 obj<>endobj 4229 0 obj<>endobj 4230 0 obj<>endobj 4231 0 obj<>endobj 4232 0 obj<>endobj 4233 0 obj<>endobj 4234 0 obj<>endobj 4235 0 obj<>endobj 4236 0 obj<>endobj 4237 0 obj<>endobj 4238 0 obj<>endobj 4239 0 obj<>endobj 4240 0 obj<>endobj 4241 0 obj<>endobj 4242 0 obj<>endobj 4243 0 obj<>endobj 4244 0 obj<>endobj 4245 0 obj<>endobj 4246 0 obj<>endobj 4247 0 obj<>endobj 4248 0 obj<>endobj 4249 0 obj<>endobj 4250 0 obj<>endobj 4251 0 obj<>endobj 4252 0 obj<>endobj 4253 0 obj<>endobj 4254 0 obj<>endobj 4255 0 obj<>endobj 4256 0 obj<>endobj 4257 0 obj<>endobj 4258 0 obj<>endobj 4259 0 obj<>endobj 4260 0 obj<>endobj 4261 0 obj<>endobj 4262 0 obj<>endobj 4263 0 obj<>endobj 4264 0 obj<>endobj 4265 0 obj<>endobj 4266 0 obj<>endobj 4267 0 obj<>endobj 4268 0 obj<>endobj 4269 0 obj<>endobj 4270 0 obj<>endobj 4271 0 obj<>endobj 4272 0 obj<>endobj 4273 0 obj<>endobj 4274 0 obj<>endobj 4275 0 obj<>endobj 4276 0 obj<>endobj 4277 0 obj<>endobj 4278 0 obj<>endobj 4279 0 obj<>endobj 4280 0 obj<>endobj 4281 0 obj<>endobj 4282 0 obj<>endobj 4283 0 obj<>endobj 4284 0 obj<>endobj 4285 0 obj<>endobj 4286 0 obj<>endobj 4287 0 obj<>endobj 4288 0 obj<>endobj 4289 0 obj<>endobj 4290 0 obj<>endobj 4291 0 obj<>endobj 4292 0 obj<>endobj 4293 0 obj<>endobj 4294 0 obj<>endobj 4295 0 obj<>endobj 4296 0 obj<>endobj 4297 0 obj<>endobj 4298 0 obj<>endobj 4299 0 obj<>endobj 4300 0 obj<>endobj 4301 0 obj<>endobj 4302 0 obj<>endobj 4303 0 obj<>endobj 4304 0 obj<>endobj 4305 0 obj<>endobj 4306 0 obj<>endobj 4307 0 obj<>endobj 4308 0 obj<>endobj 4309 0 obj<>endobj 4310 0 obj<>endobj 4311 0 obj<>endobj 4312 0 obj<>endobj 4313 0 obj<>endobj 4314 0 obj<>endobj 4315 0 obj<>endobj 4316 0 obj<>endobj 4317 0 obj<>endobj 4318 0 obj<>endobj 4319 0 obj<>endobj 4320 0 obj<>endobj 4321 0 obj<>endobj 4322 0 obj<>endobj 4323 0 obj<>endobj 4324 0 obj<>endobj 4325 0 obj<>endobj 4326 0 obj<>endobj 4327 0 obj<>endobj 4328 0 obj<>endobj 4329 0 obj<>endobj 4330 0 obj<>endobj 4331 0 obj<>endobj 4332 0 obj<>endobj 4333 0 obj<>endobj 4334 0 obj<>endobj 4335 0 obj<>endobj 4336 0 obj<>endobj 4337 0 obj<>endobj 4338 0 obj<>endobj 4339 0 obj<>endobj 4340 0 obj<>endobj 4341 0 obj<>endobj 4342 0 obj<>endobj 4343 0 obj<>endobj 4344 0 obj<>endobj 4345 0 obj<>endobj 4346 0 obj<>endobj 4347 0 obj<>endobj 4348 0 obj<>endobj 4349 0 obj<>endobj 4350 0 obj<>endobj 4351 0 obj<>endobj 4352 0 obj<>endobj 4353 0 obj<>endobj 4354 0 obj<>endobj 4355 0 obj<>endobj 4356 0 obj<>endobj 4357 0 obj<>endobj 4358 0 obj<>endobj 4359 0 obj<>endobj 4360 0 obj<>endobj 4361 0 obj<>endobj 4362 0 obj<>endobj 4363 0 obj<>endobj 4364 0 obj<>endobj 4365 0 obj<>endobj 4366 0 obj<>endobj 4367 0 obj<>endobj 4368 0 obj<>endobj 4369 0 obj<>endobj 4370 0 obj<>endobj 4371 0 obj<>endobj 4372 0 obj<>endobj 4373 0 obj<>endobj 4374 0 obj<>endobj 4375 0 obj<>endobj 4376 0 obj<>endobj 4377 0 obj<>endobj 4378 0 obj<>endobj 4379 0 obj<>endobj 4380 0 obj<>endobj 4381 0 obj<>endobj 4382 0 obj<>endobj 4383 0 obj<>endobj 4384 0 obj<>endobj 4385 0 obj<>endobj 4386 0 obj<>endobj 4387 0 obj<>endobj 4388 0 obj<>endobj 4389 0 obj<>endobj 4390 0 obj<>endobj 4391 0 obj<>endobj 4392 0 obj<>endobj 4393 0 obj<>endobj 4394 0 obj<>endobj 4395 0 obj<>endobj 4396 0 obj<>endobj 4397 0 obj<>endobj 4398 0 obj<>endobj 4399 0 obj<>endobj 4400 0 obj<>endobj 4401 0 obj<>endobj 4402 0 obj<>endobj 4403 0 obj<>endobj 4404 0 obj<>endobj 4405 0 obj<>endobj 4406 0 obj<>endobj 4407 0 obj<>endobj 4408 0 obj<>endobj 4409 0 obj<>endobj 4410 0 obj<>endobj 4411 0 obj<>endobj 4412 0 obj<>endobj 4413 0 obj<>endobj 4414 0 obj<>endobj 4415 0 obj<>endobj 4416 0 obj<>endobj 4417 0 obj<>endobj 4418 0 obj<>endobj 4419 0 obj<>endobj 4420 0 obj<>endobj 4421 0 obj<>endobj 4422 0 obj<>endobj 4423 0 obj<>endobj 4424 0 obj<>endobj 4425 0 obj<>endobj 4426 0 obj<>endobj 4427 0 obj<>endobj 4428 0 obj<>endobj 4429 0 obj<>endobj 4430 0 obj<>endobj 4431 0 obj<>endobj 4432 0 obj<>endobj 4433 0 obj<>endobj 4434 0 obj<>endobj 4435 0 obj<>endobj 4436 0 obj<>endobj 4437 0 obj<>endobj 4438 0 obj<>endobj 4439 0 obj<>endobj 4440 0 obj<>endobj 4441 0 obj<>endobj 4442 0 obj<>endobj 4443 0 obj<>endobj 4444 0 obj<>endobj 4445 0 obj<>endobj 4446 0 obj<>endobj 4447 0 obj<>endobj 4448 0 obj<>endobj 4449 0 obj<>endobj 4450 0 obj<>endobj 4451 0 obj<>endobj 4452 0 obj<>endobj 4453 0 obj<>endobj 4454 0 obj<>endobj 4455 0 obj<>endobj 4456 0 obj<>endobj 4457 0 obj<>endobj 4458 0 obj<>endobj 4459 0 obj<>endobj 4460 0 obj<>endobj 4461 0 obj<>endobj 4462 0 obj<>endobj 4463 0 obj<>endobj 4464 0 obj<>endobj 4465 0 obj<>endobj 4466 0 obj<>endobj 4467 0 obj<>endobj 4468 0 obj<>endobj 4469 0 obj<>endobj 4470 0 obj<>endobj 4471 0 obj<>endobj 4472 0 obj<>endobj 4473 0 obj<>endobj 4474 0 obj<>endobj 4475 0 obj<>endobj 4476 0 obj<>endobj 4477 0 obj<>endobj 4478 0 obj<>endobj 4479 0 obj<>endobj 4480 0 obj<>endobj 4481 0 obj<>endobj 4482 0 obj<>endobj 4483 0 obj<>endobj 4484 0 obj<>endobj 4485 0 obj<>endobj 4486 0 obj<>endobj 4487 0 obj<>endobj 4488 0 obj<>endobj 4489 0 obj<>endobj 4490 0 obj<>endobj 4491 0 obj<>endobj 4492 0 obj<>endobj 4493 0 obj<>endobj 4494 0 obj<>endobj 4495 0 obj<>endobj 4496 0 obj<>endobj 4497 0 obj<>endobj 4498 0 obj<>endobj 4499 0 obj<>endobj 4500 0 obj<>endobj 4501 0 obj<>endobj 4502 0 obj<>endobj 4503 0 obj<>endobj 4504 0 obj<>endobj 4505 0 obj<>endobj 4506 0 obj<>endobj 4507 0 obj<>endobj 4508 0 obj<>endobj 4509 0 obj<>endobj 4510 0 obj<>endobj 4511 0 obj<>endobj 4512 0 obj<>endobj 4513 0 obj<>endobj 4514 0 obj<>endobj 4515 0 obj<>endobj 4516 0 obj<>endobj 4517 0 obj<>endobj 4518 0 obj<>endobj 4519 0 obj<>endobj 4520 0 obj<>endobj 4521 0 obj<>endobj 4522 0 obj<>endobj 4523 0 obj<>endobj 4524 0 obj<>endobj 4525 0 obj<>endobj 4526 0 obj<>endobj 4527 0 obj<>endobj 4528 0 obj<>endobj 4529 0 obj<>endobj 4530 0 obj<>endobj 4531 0 obj<>endobj 4532 0 obj<>endobj 4533 0 obj<>endobj 4534 0 obj<>endobj 4535 0 obj<>endobj 4536 0 obj<>endobj 4537 0 obj<>endobj 4538 0 obj<>endobj 4539 0 obj<>endobj 4540 0 obj<>endobj 4541 0 obj<>endobj 4542 0 obj<>endobj 4543 0 obj<>endobj 4544 0 obj<>endobj 4545 0 obj<>endobj 4546 0 obj<>endobj 4547 0 obj<>endobj 4548 0 obj<>endobj 4549 0 obj<>endobj 4550 0 obj<>endobj 4551 0 obj<>endobj 4552 0 obj<>endobj 4553 0 obj<>endobj 4554 0 obj<>endobj 4555 0 obj<>endobj 4556 0 obj<>endobj 4557 0 obj<>endobj 4558 0 obj<>endobj 4559 0 obj<>endobj 4560 0 obj<>endobj 4561 0 obj<>endobj 4562 0 obj<>endobj 4563 0 obj<>endobj 4564 0 obj<>endobj 4565 0 obj<>endobj 4566 0 obj<>endobj 4567 0 obj<>endobj 4568 0 obj<>endobj 4569 0 obj<>endobj 4570 0 obj<>endobj 4571 0 obj<>endobj 4572 0 obj<>endobj 4573 0 obj<>endobj 4574 0 obj<>endobj 4575 0 obj<>endobj 4576 0 obj<>endobj 4577 0 obj<>endobj 4578 0 obj<>endobj 4579 0 obj<>endobj 4580 0 obj<>endobj 4581 0 obj<>endobj 4582 0 obj<>endobj 4583 0 obj<>endobj 4584 0 obj<>endobj 4585 0 obj<>endobj 4586 0 obj<>endobj 4587 0 obj<>endobj 4588 0 obj<>endobj 4589 0 obj<>endobj 4590 0 obj<>endobj 4591 0 obj<>endobj 4592 0 obj<>endobj 4593 0 obj<>endobj 4594 0 obj<>endobj 4595 0 obj<>endobj 4596 0 obj<>endobj 4597 0 obj<>endobj 4598 0 obj<>endobj 4599 0 obj<>endobj 4600 0 obj<>endobj 4601 0 obj<>endobj 4602 0 obj<>endobj 4603 0 obj<>endobj 4604 0 obj<>endobj 4605 0 obj<>endobj 4606 0 obj<>endobj 4607 0 obj<>endobj 4608 0 obj<>endobj 4609 0 obj<>endobj 4610 0 obj<>endobj 4611 0 obj<>endobj 4612 0 obj<>endobj 4613 0 obj<>endobj 4614 0 obj<>endobj 4615 0 obj<>endobj 4616 0 obj<>endobj 4617 0 obj<>endobj 4618 0 obj<>/XObject<<>>>>>>endobj 4619 0 obj<>stream xìšÛwÚØÆIèYcihÂÅ6!8ˆ;ØMÞºÚ‡>tõ©«}˜®öÿï÷í#a’rqâÕ5ÚX7tùo_Αð¯¥Qû6jŸ]ðó•~mN§ƒ±ì¾8ÇÊh6œµÏƳÁ„ßß¼ÞþåoÃ÷Ã?'7íÉèÍÉDìæ„v+¶jbœGg•F…ˆZ,Â…<>´{bðÍçÎùr¯¤RÂLÕ« IPå ¹œ8ÝÈ@ Ø[À×lÕ£æÏ¥‡Ö颓!Íg-` °d ÀŦD$W¹†fPòG Ϋ}ª¨{?¨Ídt¥ö±†X²’gƒÇ¶õ±Ø‹]¬L<±|û^‡.šýŸ£¤J–,¼+UÊÑËð±8š)ƒ|f©Ñ›MŽ›åbšð¢+àá÷ö7Æ|ý²¾ƒÞ%Íi©7:O4a'F.1 2k CÕNS–“’´%›1”¿ip¾ØsÙG[E W‰’Â'dŽ^ôójÉ?j‰¹ª­ ¶DºœÚ3T¾Yåœ4ËP‘ƒ1ËJ#Rë'a–šò™–ó«”’|Ø-jµ^/;Ý9p{fq!áA`´w­ _ºz×ôKJ‹–•ÄLÉq+"‰ÔO³éÌ!vÎpNp÷V½ÕŒ+«¤‰Dã¹"'Õ4z_ §Ï6|ŽhZðh`Ë“ÔGñï”)i`h*jRc¶Á¢˜­n'¬ìFõ€I´2¬ Í•/Ç4QU‘žFé±SgëN†5ˆ¸lIÿRB£^+wv O÷.‹C9.yŠÊþò +ç`Ÿ#ZÈ8ôÔ”’ýµ¤ÎJºZE.¸Á¡™,UJ䊃,Þq¤[2‹X²ñ:L#4Ù,Î>[Îé¾BTŽj%‘4’7˜±§w xU+' P‡—±­wá™ å^%ã^Ë9Ë$Átl²(…Óüùs0çèÿ˜Ðp´èÇ`Ô‰-]¢0f”ô-!SÕ4Q!gM“eEÆi²‡ùž7Ô<•)Ÿi+w·ÖŒY“òø fúöOwC©Üp3Œ,ÄE²2IÄt`†ÛÓ©ðzª#–X3ì0IBKëÈèÅTÈÛï’QÏÇfõùHü{²Ã»Êvs«’ôîp¯äðG×bè#mÒn‚2¨ …¦¸«á––I³ÄÇ®t¯ ‰‡Ï=œ·;ÉœÛæURCªo1˜‹Ð¹ íÔÅò Å0„éƒ<Ûbt7 P¡.«O6¹ö4éWS¡Ó†ù2¹êTr†ußy”ÔMéØ1R27—¤]Æ"àh©ƒ…J(ÉŠ ” ÓñUö ,Ñè««uE‹Ë1Sf#G¦”xÙMIM¤V-úy8œŽúñn’œzÐÒäUpa\ßÎd~pù3j¢¸ PáÒò1+©‚Ç=¸ v.ÍÒ—Ë+<Öq·L̼]ô“e¤¸‰ŒÁUk9³Dµ¸yI2 q•ÁísC–îU¾“èJŽ®ï‘4M‰ÃC°u\‰D:¾3•z—Ô9ö¸Ÿ0ˆK’g]'—·+aXõxxP£3ŠâtÑsÿA³/J÷BÅ`ô:ø`]»ZsD5ér³r\V]æÉUÈ+ó49€T)§,L{œ {Ä3-diXGÛjÚß©wL3Èh\–AµÀ‘­£¿yY  )¤* mìG=”â8Yx5°H—CNËØON”V£âXã¸fߢ€¸JØA „h%·Ó Qð S#S“ ò‘t!8ÃñžëÇŒE|-—7¬÷wë¸]*^.o™{É"”à”‘; ‘àõQ ›fEý$‰¹Áá[ 3‹Ë ”ɱ¦v4ÛHVâQKtAPuDOìR—èËZq\ÝŽPÍU,9”æºi)t©d†R”¤EgäÂmEU˜IìAFÆ4{P˜iö6aÞá',TgŠÞÊÉ' ÝS!¬Z]†[ÿ!JÀLsÃ]e]&µò]ÜŽäÍÎ*®ãÕßÞ!ƒb„NBÉ=¶¹rî¤Ü·§O¹0Lçݪ…5=H´±kÜ×Ý3N²BŒ$] *VÚ!‡Œ ÒEw”™¤†ù œ×Éíµöm=¢†t:äğ̓¹€RRL**:aºäqwŒåTIV™|¨éô˜õVXsU$j*öœ@¥— ËŒ’×5uïuñ½¡¦¸ t”©Ò,éôA<0®Ai˜Úqé¿·hSMNoKóØÅ%ãj5ª•ÝarHp#o6ô¼ÞYµÌ2û¡¬À3—áàУš™¢XÍYÎý˜2j–9& ‘î ÷Å?=ðA'k‹Ïq€ãá ×‹]Ÿ>g“M…èöÒ¡×ÙÞúUê®er*ë*‰+R¡t鈰øS?l¢ºeÂ*oä7¿6V¸“€ÑDQ’D¯Žk׫‡¶h̃l¸çgeGžß^B‚¨æá±käJö  àÞQƒr-g:~X£°¾§>¢¦D&Q)ÐæÁœ/.kFêv˜\u‡U£x˱ˆtì/¢tv{ŸÂ\&Ço’zàÃ{¼/Á¹œ²êÉ¢n­úta$oÞt\¿ì¥£Qq;O]%̆¼ä§¦@Ô”ôaÑ-àÌ<^™,‡#]÷hýŒË#_Qf…Áøu|Ø‹Чý~ÒÃØƒ7×:W ÇuVá§¹´zŒ#uãc¸¬YÜœ5ª).''ˆ°1+^ãât>jàbl·BEÆã«Èqø~ êxw¥…Z^bµ©)gd|p/͈ċPC>=¡^ë’C@Ü<·†ç{ž¿„ôÿฤ‡]¶ÓK¦žÇ«.pÈoo9¢šÔ‹¢› [.¦ƒV€*4Ž1^*àñaãá¸î/ˆY3E©53®!ò lʆp(p^йҀšª‚—aJ0¯±û-[•áu/ÀðLŠ•ç`ô4PýèYµzø“â“OæQÔ¬µ-a˱”˜Áø¥\ï~–Šû±©ƒ ¸nmýg5Œì-åx{õäXL.ì·.^W:n)ăƒ¼Y‡“õfdeè[ʯw†ºg7ß~y'Å[{]ZÍXµÞ$—[Ÿ#Õ›ªÊ†  (ê`yx§e9òÒc 2Ó.ÛÅ«ÑØÿ*/l ³±ñöpkG–DN´jIªc‰áûl™ð±€­w\ å¦Ð/îlÏ Åçníka[\GûQ÷ëI‹ hI9%…š†Í/²DŒìÀÆN2àˆca=s„imÎ!DðË•]*‡ÝW_¥"I85%‡€ bp¦7Ù[‡]ØÍ¹”Š;QÏx.¿Áý´RN¹ÖÛ8’Ìî²qy"/ÖWÕ7ÊçLÏã㦠×åC-ÙÓiµ"Lš˜û@Ì gðŸëgI}¯Ÿ§ž}`è]¼¸*—+q¯úÕfìJÈ‚zŠ|štÅ+€ºäøe±ÿÿcT戓} ) )@._š­Nä™Ìæ@(èŠ.Û`Óä¿M-^våÞRèP—wxK+Iá¦ø?>±ä§:Òý)peKZÈQ„5¿¨ro‰Ùa}g€¢—¬PG¦vâÓoSY ÏHDo¥ÊaëÕ—Vî-1¯mv–…ß%QÅÍ `§ãl=6•S+Œ3L«TFYÜøÊwK–OVb¯.•”‚R9 ,k"(Ÿ 0±Ó=må׺ß8¡Ý•Â}À8Ô“&Å:¡˜%Xë*kݵÞ#$ôØ»K=HÈ4¡«@Ca¨*™ÂŠÄPTÕV÷ÛUî‡É>øæˆlò;“C<‹¹ä·hI•¡1ÁÐέԷsp›¯Ýx‹~ˆÑÉlI£Pr[ü ùH1 ­Ä?Qš¸#9Ä,"¥dÖ°N‹Òx,ð‚ø1ËâZc8‰Š$@À“t'£ìB ðãm¥ù*0mq½G:Dr”2攬fÊ0i.-Þ¿ã~$‚­.ÛcpÊ»bÉ–•£K>ÆÜܹl¨ºæOì‰RÏKYôkïV¹·dÅèƒý:Q±b9t.[žú=kÈðwEåõþ¶¯"¾'"ïÕàÿòðÁ¥õúáÆá]Lôü e˨=<ïþ1}¶ÿÿÿârõä äÿÿs á2Ð30P@Eé ún– †æzÆ !i †¦zFæ Æ†fz–&¦ !)`µ !ÉÁážîºÆz .ùÉ¥¹©y%‰%™ùyš!Y\®!\\ ®z(endstream endobj 4620 0 obj<>/XObject<<>>>>/Annots 68 0 R>>endobj 4621 0 obj<>stream xÕ[Û’É}ç+:Â/86Ôô½¥'‡™ìbF^ü*¤ž™¶%5« þzŸ¼TVJ3„½´lž££ºdVVÞºõÛ“<Éðß<)úßró$K3|BÿäôÏûWôIÒÔmZ'›¤*Ó\Á:¹~âà&Éóü„,XÕ<°™¥34°®ˆ+KæÚYÚ( ÎALšåøŽ|“HÁ6uÚ:V¦-hÈ&™•i•4 h¤ƒX´´#=;ËÓ±2m6“iyI)rbRè u¤L —BÞ£&s¨ФB±´9ÇßãÄqʵ¤·Ê8i3d‘”I+¹Ì<¤b'UŽØEd[“Ÿ‹,/ZÌôbÑ¢H­¼hàf´fä$ÕQ²IÃ’‘•%5/‘5Ä%• /Œô˜¥ÀäÙˆÁV¼ß8Öa°X¶qceKšôÈ–Ä-)§[0ÒcÛ’cyKa,2)"ë0ƲõGV¶R&>˜˜2EH‹ÒE)Œd»-8ÙÑà-À.Jàä-+r“Â6a Fz ¶ÉH}‘uì¬ÂEЬlˆ¥°!Ëšø"Êåe†‚h·cÚŠ¥¶¡ƒ…Ç›¹±²¨OÇ Ë¸dQKÇèBDRRÁ˜–Ýc‹¼&h{L,Ÿ¾c#ËÞØux“pîСq4”ý[¦ç Ü-«Ð8Q’PFVç ¶“ó}1Òc…Âq*ÛáÐŽÔ2.ÙŽr²¾qr…åÇL D£6’bT®IÅ(ù›Œ$"-e"Ç×Ú(žÂ s^ºÆbqœƒ´“¢G’E§Êâ3Ë*À®WàfT€FÎALš‘)DÒc°¸XØOÌþÈðóÅE@K²³ ¹ìÕR<1-\„gEÍãDËñT›ÊãCˆI‘wUØ1]¾³ƒEE IŒe§FgËÉ K J¢œäWòMž–ó¯0R ÇÂ)ÌØfh^ªfrE<Öa°Ø>´`ËzL÷ŽrµÈz –ó:Ç: ¶iá¾ë0X ÐÖ…âP5k‘FÐŽ$ SêI¨y©|ÓOi eØäÏähx &–üEK#¢QShÏ(Ä® –vÉÛ&•ÉË çlBÏ…Nƒñß6HÉCâAš†ò þÛ)C7e%å+Dñ ÍByÿmƒ”Ñl=(‚­9l›ŒÐr¾ˆ 69£Ç¹Á±¹E.Bpl|‘‹0˜žqby ƒáEŽí.pXÀ‰PD‡˜ˆ§Q„ÏEÜt¸¶Y –€ÂcPF# c"e‘"e)WQûņ9( Až¦|>w@øü,ÙÝ&Ï^ân·°¯ù ¢&g‰–Â}ÑTÉ|ÅÝÂ,™/ŸÎ×]2Ü$WÃöÐmû?Ïÿå¦ã†"O‡«†7É$Ì6AEÔ¢9_=½þðúÕ¤L3‹þbÖ ?‰“‡åqƒI‡~؉Ë]UB¦£ÿON;~öŽZ‡×¿`‰»%ÉÄÚ*‹K‘èÊYÄI^™X8H’šR¨ZñjØuüYžÎôì9X\êKãÔ,ò?Pù¸èד{³ØÞ·,&í›~Ùm÷báù囦*®;Üêÿw×í‡ãnÙIX¦³ 9]•–n FäfgòÂYíºßŽý¾?ˆ|õE¥ l­“Æ¥@ˆ-g"þ²»]lûÿX¶‡’¡ t¸á/gé4ÜÃ]ÏçŒG‚ᜓÍb{\¬é›Tò0¡HSQD^œh¢=ÓÄOÃ= áR¦Ã  (¦šq,>ýŠ¿=©1$»n±ê··ôqY¤ÕL¿{¸c'€V…}3êŠêÈ1ÝUQåœÝ”…ÑëùbùïûÅnÅPÁ‚U,‡Í'ÐÇ~Ý¾Ò ´Þ³v¬M%ű¸›?;“õ}·îêÄ‘Zê‰nõ¨ú.¦$JSvãî?˜«Ë¹ðã® ' ÉÕ®[õRJrëæ’ÒIWDLoÁ¹$`ÔC!Ÿù–¢_”«}âò~v*7 jÓßJ€Æõ¹ì‰%ç’‘E™_o÷‡Åzm º ³ÕCuÕÒj´=é¾áX?ôÛÕp/~ÉE«þ\ò:mF(¼ˆ(ØâýDÿDÆlû/üAtÈä#-õlEJt#¼ˆì‹íß.–ýö0ìïHN<³°ùË5}’שÅáÒxêBð#ªh5fï+ËI%ú5Ôúó²³BLöy·?„‚¾9Öc<Ó¦‡‡f§²ñÇ&Û‹/‹Í§µdЬ† Žóäg/c?SÈ( ¾™ÁùœõH~.æøÎN“!çÅ®…ê³fu¼®Þÿp·8°[ªÒ<¤IR#¸Keò_è[x/ÞÇ–Õg¬‡I¬þÕ!ŸÈÎÙ.šúÖd=JÎW2‰Ä ß^Fz!¢O­€®#;àzþzæk„tríùÜ«´¸ѹæ™à<óg]³ zƒ›ž<&+âV·³Æ&ž˜„‚ñ¦—5žmŽ6ñ¡g³žHdI>‚Ès-e]Soßs. ë/CÅ‹B.×ÇhÓף鹟ù.ö&§òJ&ä}~ì×VÒ#•‘3*ßðLå]·[K¬sÏ6ñ©Þ?[(Â㑹?mÉE~·ô_wòŒÝŒiЉ¯÷ª¤²g×[N0H}‡zpy”’0˜ö™ J5¬øH]°º>~¢B·ãÛ‰¾ö¸ìêÙÕ?]£ìyí¸M­ÿqÓ-G4|Ù¥ÃKè׿³6Tø¼¶ÞâmÑIÿó°ÀGïŽûþ3wåðÊš=Ÿø¦óþèÝ@™ÎÆT3‰Ÿ©Ø’ý£ªáFzÞ.›]+¶ t!ªßvÛŽ´*Þ·©•Ÿ 2(ý.—Ïp¸wwã1CÐ(N}þà×ov]·øŒKtœF)pÿ/}°“ ΞHs°õÛ«î®䲎šfÁ[ú¦¾œ8²9»§Í§ñ§¹9Kï <þÍv&4×uÖñ°}ÊÛDu«§ ÊÿFÚÄL`ØQè³ß ‚wº¬”{ñ¥Cb@o_‘/Á;wcl'ªx'O»4ŸwÇúØ¥ÿ¦Ô®}ƒ÷áÇø 4¹C ]âØ‘%ïäå öûxùØnûͰãðàü>R šh€„¦EòÈ3½³î–ùËûþÀL4ެmùk¿ÏJ‘U…ªâúp\õwñ öšS©š <¿²€ÛHõU,¼âÕŸXô½ èÖ¥9§»„a»Ó$•T±Qª¿->s:ÿ¨¿\AªæT*và åÓ¢wí/V*©AãY½³ê ÚØåÒ“BËãÄþ¤²Œ2ͯÞÐA«*vI“û3ØéþD&.2œõ½'‰ÆBA4• /AŸHÅÕ—êøQš»—às¶3<á÷2vðFüO޲ˆ>V{Ó»#h‘î$"£_öÇÕŽª%üz%ª‰]éÿH‹¤¹W_oï{~7ƒ¥”Loûí«t=JüîjT@Ñÿð þÿ ÒÐoÐ Êè÷S4³‘&¡ñM)#ýbàá Ö%êįuNZ»zÚ“Ì/æOþþä¿=JÿYendstream endobj 4622 0 obj<>/XObject<<>>>>/Annots 121 0 R>>endobj 4623 0 obj<>stream xÕ\ÛrÇ}×W죒 !ì —§”-Ų«ì²"2Qåq ‚ÔÚ–Y¢ø÷9}™î^”E"‘$åðìÙ™éîééééYøßÏòlŒÿæY9¡ÿ-ÖÏÆ£1žÐ?rúÇÛ×ô$›ÔÓQ­³Úþ^e§Ï­³r>šêkD¸Î¦Å¨\€ëlVÊÀ¸Îòb:š²®høªfQ¦hÀÑ0Ïñ޼IdÄ`«9Éý00ØINƒ:ð:+ÆÅhXè‘Ê’EšÏiTÔo€è¶œÚ›µ¦ƒEOin0D*‡m#[ç41ÖsÄ`gl(cE‚®3‘Ÿ«£œªcdĦ޳¢^j+â;0©SŽòlb¬ˆ4&Ó&‘¸HÊ©FFl"9+"iÛ¢(GU61–=­ž‹Ó³k  AD·ùx4ÏœŒlQÃø 줶 ˜žA¤Ð6`X)'v6b°©Ø€ÁN§ðagË ¼«ÆÊ# W3üŸR6@XL½ò‹l}‡·¬±ÈŒl]`R0©z§mÀ¤ªËGÃF,ªF)ZÕX²)ZÉßÔŽ¢Ub*ZŒN-k²wAÍÄ:nĉu”›L¨q"ÊU¤¾qBû¢ '12b°U5è6b²kMSâm&»ŽÃF vÎvµ¶¢(Â’+ÊÀU½bLã„ñrrKã7#qÎ!„ûÀFFLŠTƒn#&E(b‡¶ÃA±a{ë9br®á¸²ð±LɲÒÄ ¼ÅÔFF Qº+Ýæ²MH? ¼[å4~1º­XSc¥Û±x»tËÀ»U.‡šSFrÃj&NÍ XÃÄåùÖs2bȃ­gÙ€ÁNhÖ¼­ Šàc¶­ø Êåcò0'#¦AÇpgÙo+ÄNó[Ô-/ÐÄÍÈß b¨1iB>äM#&›Àÿœ=ë0Ù×S¹|Ì22bÒ“¦Ç›F ¶ž Ù€ÁÎim†ÀðËy`E`ø–O X¹|Lk¶22b ZÐŽØ€I`ö$o0 \¯+"ÑA¸HÊ!w@;ãD§ðL›‘´7TcqÚ äoêÒ2ÙŠÜ‹_#*À5ò(2œsäQ%lk®'€Ú±ë%{f¥/ ¤äåì Yõ’3 A¨!/ÕÄ!=AÖÎ/ :-È'”N'Áž%ïT¹œÃ¥““Eišœ•nõp Â1ðn•Ë‘¯@#¥aLåK˸¥åf%<ιIš)Ic ¥SNf“å<³¥HU*§J1ºE‡S}—‘n5yá<;ån•Ë9¾–FFŒnkòFg9n•š€Š·Xþ ï©Ý8ìn ¢S »1Èß%M"‹4$õdz1é`“™8läÓ̹“@NŠ@©%®êДM[hêɦàC*—K“k0E’„n•n§! ¼[åd_tRjú(òX" :Ǹ! âCžFFL¢Ø€Á"1žG6`b)Ž„¶ƒÒ–à¬(Ãù.‡Â’=QF9‘Þ¸E\ i¤yÁ`±TlÀ$î„Tõ¶ËnXÇ`q€!œ ,dŒãòZ*8ÇÓ#Œšp^K‰C»Ž˜”ƒ :EÚ32b°x>`;¡s“·Ûsþ—loÉ Ø^9Úó!‘‘Ó sÄxg¥[Í¥KDÌ °Y :ÅcÏȈÁb-•‘ ˜ô¤˜Ú,¹6ĵžE\ÍAE>KAD·H,`\##‹=6r6`‰=ÅÙ€ÁÎxA90¥ÿTlðžYà<æÅ,p$.ÏI`'#Æ 5lœ•ncæ›3_hˆ@>ƒï'ÿd¿&-Á`~8Ä3´ãYV‡èe´y Eš˜Ÿæ–‚ò¬$i(es2b°XXUd;¡ÂHh0X„êØ³ˆ¤Y¦È`©`€$^:ÉŽ,JEd[ѱÂÛÊ šGÊ(–*HƒRÈÎŒ˜e;80X„hØÁÙ€ÁÎiãrVD™Ë2q:p‰ª"’r*‚‘›HΊH©mÁSãlÀh[²²Î –s#JÖœZ$´ì8@4”‰3’jæÌ/ò߶Δ‘ã¯Q¢Gœ±gèÔ‚ãR•qy×n.º–ãÅØ?dTœ¬Š)/x¼ÒjWÐm úý¾]]¤QáëtÏFÏ·7íÕhùqÉÃ"¡œ‡¥%%/†Q€“Ô£'üO^“ÐИ2ݨ¸ªN+úË”ßoÕRÊäÉ"¿´›×ïØLõhVjÏ͆' Ûú¼ÒG¿œþë”M+ÍäÙ·4’Z¡@JpÇ Kñ•­ðòöê¦e—„ïŽÕÀßR¿}ç™øI>œv^eÈ-¿tÚ›ÕnÙoš]ûaÉ« ±­ÐÕy@ŠoýÈ´œG-eRÓª~»ßlÒ¢† &Åwïy=ç!º,?6ëë•ê5¦P!KCÃËÁuŽôÔýà’΀]SãÓ·µ‹Z¥àZ´-úŠ"w%~i}·í.wô»™-ÎåGÄðmÛmd‚ƒ¬ävìy!ú&Û†8íóï}ÛÿÎÂÇï5b—?Ø.„+×줠½ì9['ɺèÛë´ÿiñs³¹Ú7Wæúµßv>¿VïùŒ&*ì‡8ñZ±»›Ž_òø±R‹ÐcìyiÿýÐ.oèró«î’Û†s` ÞtýŠ· WðüZúY?bµ*cqŒ «éÇîž¾ø R  ™ l„Ûèi\Ä’ó€YwÍêw6¢OÀNfáJ7Òìå_ùÔ‹4ù2½ÿ×VÉn\RÕ(T’t–s½ë›ëk‰ P¿J:\î7‹] AˆcO-þþùœ´9Á­|ôÑpúgÓ·”!Ó«Hãç)1Zµ›ßSçÒíæûÈ/©š82 Ô”d"m´Hþ‘ŸköÏÅž#X½Ÿ3T1æ ¼ë¤¼˜“žîúýb·ï5î‡îÀޏX5Û­®|8î“®ÁƒÚ«Ê([¦¤‰–%Lã7}÷ñ–êdT¦cVÐŒ.iO³ºš.ÖYøa aûÁ#ß—ï¤L¥Ùl Ñ£UŸ naÍÞ=òž¾oz=O‡„wÕž÷ˆYâÄôXÊ„¸ûÅí¦Y·‹ÛÒ oÕ5v”FÞû‡¼ÃÖMf˜Þ1Ã0Bÿì‘G6;ÎÞ´»÷¼Âîº5‹áLÒ¡Á°óI^X°š'T8Á0pŸîpžãDÒeiDÜŽ£˜qx†õ©¨’{Ô?ÞS¼QHÉ7(¶×ÐÌ ËCþùªí—8í¥ŠâñlŸ÷­¨:âs®Ž¬¹Í䛦ßjQ GÚ”=ÿÜ®[ÚhS] [ò±fЪeŽ‹sW3a÷àƒ»ž^q¯djž¶TC%‡Åa–ÒÁ»Îýj‰ÃDïÖ¨¿xråI1%á¡wØNîV-8_ ×pù‘®y²³ÛkÖ[ŒUBDÆŒDJ.²Eá.¸*x’ãƒèàÓøõë—÷¯WÝy³âGÈ›Ò}\ªlpê„2MJ²í>/¤RƒmÞ]úÞ®òÿXÀ½bIüh¸·|Gæí‡;®Æ¢>[¦šJ¯Ry þÛœwš7MížgAuqŽQ~T]J1‡>_¸òp ºkŒE³§¨Üô\ðÀ—sÓ” ¢Ü*—D¡b«UlñUõ„d \”©áŸéî8Ž'§,¥’Wvÿú:‹í7Boº×÷½,æpTÜþ…ßÄ÷:iYo¹,Ïñ-‰=?´@¼ LµÒ§ “Éñ„Œ,{`ˆl.–—íFLƒàEƒ¬•ÌÁn€=þx‚š/€’gIÌÀé‡qŸò3èÈj[drM†•€t²'\Í –éÛ%î¡8xãëd‹¾ŸÐÓþdÅ÷ôŒK)÷ÄÍ ?e¨ü@qþþÅ·y/ñpôþ °—Çö­ºã÷"auß ËŸV?B×ÉýDzti˜Í)£a5¦ÿ»¾onyæŽrç1e”RD@UÄãöhX%zÙ/QÿÐÒ@È¡ñøâ¤Û¬ä4‚´+¶‡^Œ¯we+µ‚G Ú²,h¿]Ò5¡h‹±…Õà¤NíÕ¦ëÝ0vý|q§fD?3{Â…\ÊÁ›~Q›È!õêÁ?Ñ9\ë£EÂåëýϤ¶×ËE{©w¬°^_´(㹞ØP„›?¦9’þ³É`Öu¿rí¿»øÐlšWb¿NgŇôß»ž ”9?m¶YiEŸRE×ÖÊ•äânòY#Ei‰ §øµ©Õ…›þjï7XÇtãQqòÅ¿ñð7ð[EêñK|ÕD?™a&0‹øx–.uN°´³WÝ‚ÕâÂ>gaø¾z\ >N©íÅó¶¥§;{ö÷gÿ³æ!endstream endobj 4624 0 obj<>/XObject<<>>>>/Annots 175 0 R>>endobj 4625 0 obj<>stream xÕ\M“Ç ½ëWð¹ÒœáÌ<¥dÙr©*Žk«tñeÄݘ_á’vœ_Ÿ xÃ]I®²£¥“”½oÞôÐèæßÏŠÑÿ-F³Fþ·Ú<›N¦x"ÿ(ä?|#OFM=ŸÔ£Í¨ö¿×£7ÏmF³j2O¯ Ep3jf“%qu%½Tµö8 ínFÅt9™¥7…d ¶XNf ƒ­ÏÚ;o&%·%¼•E-Öª0Lx6Ó W üË€p7£e!3Ò…#( 2;›‹þ¼©é¨,HG ¤[ÓQâD'‹Qã$ct[6C–0Øf1)¨­ Še©m1hâ (¨5N2F·U%* –° *BKªŸ–¢zo«Sª—f}:%>¥Ì-E Áij%0HëtAX+ˆNW3˜IŒ¥ÛæI,a°s‘3XtnFd’(ˆA·Ð1#(CV°°ÚIÆ`k2XÂ`¡Å%µµ ©öÓj× bB‰+¦Hâ$ct[¢ù` ƒ]蔂%,S:kKXla*ö¶ŒÁVª}gMœŠŒ·Vâ$®˜V²lN2qj8b°Ö-¼Ó}¢VÝ&‡^#ˆNáv°#'ƒ©~ƒ% ¶>kKìBum K [ÀOc\Æ`ë…ˆêm1,¼¤4·Ð¸f@D%c)6‚#ˆ SU{‘†¦?øQèOAè/qKíÔ9‚贜ʈN2;SK,?ÄrÖ&4³Ìf¯ &”8¸ \Í9‚2d-r’1XlxP¬³:dµ Ó4àCfNLq1 ’1ºU+"–°È9lkƒÎÉp+1hâŠR ’±t+æ¬IÕ‘nÕH2 ¾(At Õ0Éìl!Zð¦ŒÁ"vbºÎšœ5X¥ äLœmRA2F·¥„b Ë”Ä^ˆ% ¶‘ÈJ,a°‹H,aqQ1í`MÄP7ÏJAˆ“8uàŠ0Ú©7d É4,a°Ø>*bmB%¯‚˜Pâ–’4UÎD§…ú ƒ­æ¢!oÊìBÒ b CH«æÄÚt 6{1ÝÄÙ.V9Ƀ"¡‚…KX&\Šƒ% ;?„ –0XìqÇY›ð”’‘JAL8qË…ÌÈ9‚èZÀ¢9É,ÌK,a°0î˜1ØùtгT3ÝÄ­°¿e²R dFÓÿ ¢Õ ŽAÇ5qlfÙžF2A$Þ²¥GPt#9pŒE7óASÆ`16·µ ¥bÈf  &”¸¥hm朵K%µóê‚ ‘]pæAL¦« ’1ت#kCrÑ2óê†LÆ@;çʲ›ÉX†ÔÙzSÆ`±ñB–` ‹ßJ¾¬M756?¯iª‰,G3ç°dˆ!a☮“ê[3-&Ò^oÀ}+sE)Î$ct«õ±„Á6²ñK,â ´0,hJ.h ø”2'µÆ|$cTÌ–XÂ`±µ7Ì6Õ×Ī–J.‡ Ä”¼’¤ì cPͨ‰%,S’Z3X]ïRK• 2„DîI™›‹GÞ"ÞA™ŽìAš”Z.$[(½vÐrÌ j>$céVÒb ƒ…ßC#Þ± š Åë‚h¨5Vé$c°„b ƒEBE[ÂXm8 ìÈYÆ`멈,a°Øj¹gÆ8òAžÍmMX-'²†½¶0aW °ƒ8N2†8È Ã` ‹°’+KFž {[Æ`¯  gm©à±zÝBv&Ñ¡tŽ LWŽ¡‚´NµÜÈZðÚÃ:MœÄRhÁIÆè óuÖºÕ’"wëõ…u›8-PžˆS6‘ÔJ®4$ÃÏ ˜¥vNM.åþê‘‘ÁKóĨ‘9ÝacGÊ£,AJª&ç¾¼¢+.½ç:ÜŽ¾xµ„Gb¶W7xÉè 7³lªÑÕµ^‡MGW«çWí»u7ÚÝŒ^î¶Çn{¼ÿìê_ÔÞ˜iw£hp3çÞÆ(¹ç¸a»º~^K£·nø{ôæíëo#îÍgéÙ—í}¿Ò®¿x…H®án«œ£»R{˜ @h+¹¼“n¾ßõ˜ÐAÁºÊEz~ÜÉkRÄå'7§íêØï¶ö*F-Ó«íöZßm&Ë*=Zµëõ»võS~7w2y’ÿT3™ß¸ÀºÔ¡ Õ& cWèñpZO‡N']Í&ÓÌ<"ài›5œ*w¡Pæ“÷ÑA+t¬!ÐÍv`W¿î»ëîFžÁ XÚû¡šp”ý£ùT/T-wQÑbOʼ/ïÚC»‚áËSl³y²\ˆ×ooÕàYE~üˆ !…}ÒÚ§’ó±q²ì8ÒaSŸ¨”Ùé_í¯ªZëM·y—*îäö òäϪ¹®ðb°ÀÕ`ßd3•§Xœ¢I |Ý[y†¸èÏ.[ô$mQœ­©úµ¯éKŠ,v…H­:ØYpÇî,‡òG¬ùº¼³‰ËˆjÕBä[±CáK}Ü…q} ¯Õ¥Ž€n«ª±±eO~ï6öpÇ;W鯓Q}J‡¨tÿFzpf ê®`9;Ý–qÔâ²@Ø+Sæð)ømcÕ¯ÇzåAË®ÖàR~w¼³.^àãpd$y¸ºÛݱã@ ˆTæÝît”‡Hiý¡kMM Ï2…’_í~Ÿí¹EšÁoðw¾U[NS–elrê”ѼÜ]«„ålÒ¤eôz{ß$K~±HÂüÎéüÿ›'kŠùÍysg ºˆÔ ˹O+ЧyØi¢ƒäv‘3gϦ‘Í=ST}µînc\ëÓrŸç4,w?Xn©-í·Þ¥ìùëڀ˻dy‡YÌëíºßzó¥\e5ІGââ®ë2M¾¶<}9x˜Ô¼ÞöǾ]÷ÿm³£æu×&!/rMaäIFù“ÒSݺ(n½ÐàTP~-5êM»RÿÆQô4ûí—§~í[?Ì;‡¹7ÇC{ìn5ÉÅò…Õ(¡†°no鯓sôïݾ•ZDžJ…âÉ›< ZûßyêИ14ƒaü¦;sÖÙ>RA‚£Æ¡¿½³lî““¶»®½NI#ª¥¼ŠiÜk{|t!µU¹ö‘§çÀrºX9N¼½kMFrì‡Éîµç…º~éwÖOœðmÚ~ûãó?ÓçØ'/íÀòÅ«8#m£1b;ÎÞÔòjzT ³Ñ\ó.&M>Ýzùùçºä¸lI-É%ÿ ÖZÅYïÇXÉPRnL»êËÝf“OžqXÃK­àM-8w®²BßR¥ƒ¯#æ—vàiŠã»ú_ HëÅ;c»R«ÇПmÅk«ûk’P÷’ðÍi¿ßRÝlÏ “¡óŠÞt­Ÿuã×ùäþò¬>É-¿Nñ”±™èŽ@¢‹q'ÇÑ•ÛJ .•Ïn—ØJ³…çð@‰Õj·Ù÷kOµñÀ“k©™Š4¸É +Ðí€Tñýa÷Ëýå]oµnïïm‡Ã½sqiþû~³K#1ñÀv~w+5;¢I§¸vuxXé#$õ æ2âL=O ›:òbcIv k~öCw¿;R]„Ý.×?p†ö¶“x/#UbŠö½ÕVt¯' éÍ4pVX=µi4Zñ£–z˜ ÿ½ÝÞž ŸÈ†Òh™—ñ~ß­ú›~%ÏqEœe¾îŽm¿ÖôÆ_]Æê¦5VÁp¼M}~Œ÷¦ßì­pÁúø¶ýHLœGâó§^Ê÷{õdÒ˜àq…ÓLÎóܯó íh„ëó µ²Ç'Y‰¼ˆ;t寺›ö´Vņœ+±ßãü59ó"W´«ÝþAQÈ ô}>;xxU/ÆÕ¯zÎÉñ¹:1Ý?XI-%~AK;;6-™µG¸·w†,üdÉ@HDyŸyººÔò5&xí¡ÛþE…ÄÑ~éÛâi!ÊmïT¿ú ®sÄ6ª^æu¦­” ¡ _“æýìCŽ÷$\’ù“ïdXôˆßêõ³<Â7=¾ÒÃÛ:|ðtYç6¡ÌÆNp†ê3·ä7Gä’º7ÉuUvááÝs¾tŠŽ/è¯æüÚ] uxïøø*úû/`ÖsrIòùùô{"u{¸=E…Ÿî]òþkâ6VT.èØ@†åıÓ¿4Ô^ªÿåå;û÷Ü &”´Å¨Ð$â×ÛÓFC¨Ü•g¿|$ÃЈۦ÷ðQb~÷lÌKIví{Ð-TúIµþ¼:ôÝöÚ„ÿ“-íd’ÔŸ „ˆZ?ˆ?t76ÿUú®~NqYâ=9›à2ÕÓ¥,ižÇ<I8í&».ìÈ+Î:¾GÑo›¬Ûê衎‚$Yï4³$7ù¹]Ÿ´äÂ÷—©—¹*`ŒïµÉäg¢²‡×[|4Ò[X„F´K*óú¾çßs•eŒŸ òªkªH¾±è£–wðqýàŸ2{buÝ߯N÷÷éÈ„ÏÌ™lP–ô¹¥“ã>4©• ±Ê¥xv$%$V~ÀéŽøøT‰&½ºëV?å[dhí1W•Küĉi'iá>ƒSo*ɾû¹;¬w¸FÒ¬ µ_#½âo¤ådâÇ‹ßvÇ»] ½È÷ŸÀ ç–³žÕøi¦ÝDç¹ÕßïÛc:8§{Öœ›ËÒÉGÃyéo»m‡+ÈlZøˆþ"v–,-–e°è© ÏҾؼëoOýQ£ß“<<9ËvÌ¿»Ëîõÿý„çé»Iý¿›ˆÍ±NÕõG¥Ågð»õ‰1·xtÿض›ì«¸?}ºåž[>‹ßÓ€Û~1Ñ||Ÿ`üÆ‹°]òó$.ò§Ÿp!ß3Ô"mugÉ~<„eÑRCR”½w·çMGnÜõÝ/tÿÓßÞÄ?ôg3ø…!µüÜ ßá'8ømT;ÄŰÜñcŽÑW»•–g™fò-‚yŒçÒöúyß÷b'__=ûç³ÿ·Åa.endstream endobj 4626 0 obj<>/XObject<<>>>>/Annots 229 0 R>>endobj 4627 0 obj<>stream xÕ\ÛŽÇ}×Wð%€ ƒ+Î ¯/Yv $J"­â¿ÌrgWcó²’¶œ¯Ï©ª®ê3»\ñ %m ÖœéêªîêêÓ—ñžƒþ-ÕTþ[®Ÿ.Fx" ùóöy2˜Nf“Áz0‰ß«Á»gYZªñÅ,½&‰(U]T„‘¸ÌÆPlêµÜTjO¬¶J0´º,¢ÜLê ŒÄõ (潂•*­¤¸¥*d¥ [¨ÒÀ¬\YP9r¹„#­!ƒcñb´Ð‚³ERÄõéEÁH„åôbN Ë@Ñ#^‡e謸(¹,ÉëA CÇ„ªŸTícBøé˜Ú—1Qeµ€/dè´DJ²˜[^,%YÌ­àL.kæÎ)F&*ds¶˜^L#UN¤2hJg#²Ò„™–ÀH”6KȲUY1 \º‹µQÖ šRðMTÈ%l>G˜dŒDÄ—öI”#QŒ]HõZ…c ZŒÑÉ`¢B®0aˆ`tV`$Bi¡^ȲTYˆ%è¼’. Ô ª8,UÈ% mƒ#Q ª¤ÊY:žIãe”d ³y¿,Éb®¤.*K²16JÆœË@'¥„tÔk®–Ò*dWf‰0¨É esµ‡ÂU—ZôEY3m—S‚ Ù „¡ÏЀ‘¥th€¦tÄ!­BVš°©øÀH\ÐÊèÏÀHD…#Í2² ´œ!íå¢,K èpˆ²jìxNÃÁ„0Ö±¹Ô™11þ$¯eŒD1vs2È2Ðb? %è¸ì£$‹+eO³Ìàãi ®ø­Ž„”fp{M Á£”ÌàÓÜ1 ûŒY»iþXÃ~ÐXÑI¢ø?+´‚c‹{S…\0a3-‰¢TfÛq€,K³I´fTç€q™æi V¤JEíX ꛲,j%J2PͰ„’ t>E& ”dÉ"sL(5ƒ K‰f¡ Ùà„¥ ËbÒHÂ'£$£R´!œ Ô*E´J.°JUÈ•&¬ɸȲ´ÒH| TÕV K1ªÖ„PëXQÈ@É ËP‹@jjçF¦V…¬6aE1Âà¬dYšHÕjj§*• Ym”eŒD±U(]MiâÖf« Yi ÄA9¨dYl­¤5µ‰D›ÚL”Õ­„Éè¨@Ý¥k¥N–¡31Z6£$K¥i¾Œ’ŒBŸaU¨™”h¶™4›D¨Ål1T²l&MU²`oÅüŒVвViâè˜*áLPtQp¤d(F|É(Éæ)Ú!P«”¹¥‚ö©Ú0ñ ÖÈ2*C€ÚŒ’,&É%”d  !U“JD¢`±Á„0É13F"”‚]Te1H¢!µ*×¶.ƒ£“ˆ‚ e È3FIªƒ+—µJ•A#Q©ŸA§I”Jeè—² ´’Ø%”d ˜o¸¬Uª9Ý+ Jm•&Ìú· e¨È|O(É@­+¢¬UªÁ{4a€ 6@–¡óá˜PS«¬ÔÕE5_&Fe¨Õ’QS›,â/ˆ¦©MXêüY–&’왋šZe—nmPMS›0ce€,C-ªCŒe”d©T&ŸŒZ¥Ê½Ò ŒVi ¤!¨ ei"mù@Um‘ئê1!:Ô±¢’Í Ë¢VÒ{FM-6Gbä*dµ +¿P0@–E­ CBI¾ „,£,K~œaŽ!”d  z¬™e X̲fs'1Yk%²; “0/`vžØ² wÊRLÊ(É@•KJ2PÄ ޲fR¢»fR0ZQ•ȲT*40£¦Ö ¯¤²"8­©M˜l=Mdj- FI–JeÊŠY:U“¢Z–b®E;d”dët®W‚Àe `3\–e È|ì.Ë@±¶é¡$c ƒFf”e  _ÜV,Õ!™=².ðÅÚüߺ aN¶Y–†ÎH(É@±ÔCI†³:óä²f’ó”| rü'¬(Ô¤YF¥0­”Q’¢jFI FŒ˜É(ÉÒ³’ô2j§å5ZðÅ$!ì²6&ª‹Á´6е þ?³„½Ùà $KÐZ1ˉâ ä«(¦6*ÏG›JøçÏ’(œ¡®€H…²þ L¦Õ€ªÐßÚG¢>!˜Ñ±»+±!H– ˆíY‡T]Z¨ºàùYJ;É(1Je$±ó$s€Ô¤ê”—'wƒ£«º„ˆDqW2z`ªP9wRü[&Dr H´¬öÄ ¡p*Ù!cYDD) L+ÓXI•ïÖÊ"2¥{eYë aeö2Ë" шŠr¹¤£=/én/¾F’“ƹ¼.ì}T8j@œ—ÓñàòZUFƒËåóËújÕ ¶7ƒWÛ;Ùìw_\þ@êôäEÕÉeC×6,1ã¤æòúùT Mpzƒßƒwß}ûÈɳ*=«7×òÎOËôèÕ—_Ê£_cVMŠaîúKUyQÌ´ˆ‹)~µªwj6ŠYzØ|„Õ»v»‘—AÉ«TåÅ9ÿ3‹µÃyIÞÎïy{Ù¬ïVõ¾QÇ©ÕÎÙ©lÛ|¢îaòäî\ÜsðM½nvwõÒ<œüa<\Tæ Û¬8ÝÇ¥ëå‡Fý_ŒüÑF½Õ·04ä¸S†ËMSフ•L9õÇÛNË#ÔýѦ×`XGU'l³…Æ+’Ì7Ñ åHÎcöm«ÛÍ­“}Óì¼ë‘œÊÂÿÝ.M~ ê"[ŒÔµáŒGÅ}&ûRZŒÇ{óªk-n±‚©ïý«Ù ¤ÂYÀÃéáÖ&Œ#ɿɛ‡Œp½MšˆO´¼¸Öq$í.·Hž4 <6„°n{^|’8Bš(eAú\ãÈ]ýíKÈÂX7òê9ŒþÇ|?öœÖ±þÍS ®â †3o‘o7ûn{}Xƒ”µÕéÓÝ1Ç>K®ó°˜]k̾òP¦µÀªÞÜê[›:åþ“ „%ˆäm↸nuÑýÐé œäI'ç Oð:­妫,þÞþT¯¾ö‹ÉþQÎp„6­·?Y2¡¹kÖȦíRI(W>1òs>ò(fcníùÒ[à›fÞ·jÿkT+¹¹¯5Ó§iT:š§ùx×!ï;Q@†Ã.Ô)ÇB8:é9ªd(}ªN×±’÷=–},‘8OËàÏÙ-¿S·; Ór_ÂYWáã·›vßjgêæB/æ÷U»3V è{€¿Ó’Ï[Ìýœõ†­²ºðóý¦•IV;–0­»³/nJœpcâxCáFó²2÷¤’ôððÛ0òva‚ŽYÐRÇ¡g<¹“zBñª4#¼|+ÉðªÞ¥äƒu˜O¸èßáj»½óyn¾âÊÆ±^TŽþý­^_]×ê¶"|qsØ(Ðé7¯ƒ˜™^æÚÑ)÷bÂëI/v•I…×/W’i±u®ŽóVkr<5HL(»_6ûú£<Å’y|Ú¹„Çlx ŠL1l¼"všÿ¡;j=M,:yv™0b3%öXÛõ]Ú°ÆqÓk%'›?ÃI½QÄnµ÷ùúãݪ]¶j±l˜x4Ñ®k¯¤Þ>Í7í¦^iKa½˜VžÜàOÿ÷ÒÅž¡\ÇŒ-å‰F“Üû7‡•[ŠisMÊóVÑ=Úä,OïÛñÃã‚PÔcãKîñ;,x6·«_Ô=L²þ\t× §€‘¹šÍa-ۇΠq6ë£û¸Oó4|Õ»)ÛÆ›Ü§¯¶œÂª§4L19ÙC9ïtÂxÕÕË›´A(÷ÁN6p6!®6X0÷ƒÙè“»ûØPFäb0Ça.6}wÈ7‡mÊ: êÎŽûÉÙx”»úrÕÖj4g9éW@άӞðÃ=ñ“¢Poî/aD¹‹ï± ½Ûwí2miÊLãÛÖ‡H|ðrRæp¼%ÝAÜ€ëͰF£ÜÃ×][_·KOEî]¯A¤p0tF£Ñ<ÆYI½ßÉ)ÈH“ûø¦ùYÞã-YéT;¹Å5Ô˜uV-ØU½² ÆÒû¬2PêewzÑc‰v8¼éý®é†× 8A°ç=廄óêVÜ)J}Ú÷¯O˜.?tM}EÌÒ8\÷ôçÚ|c ‡UiÇåø9ÁÓÇìs"ŸFŒ#È%fôj}À*ÀN׈þ?KŸëfÕ¸ Úȸ¯âó‡·D‰qFƒ·¬t°º¿ÇVë+°'}‰Žœ=Ãqµ¼†½flTžWœ#òðía õ{l±ì3¨w{?MМ«ä<­ Rˆ)Oxcæ×Æ‘»¹¸ïeŸ8½\­¶–¦ó ›¶N·z ,§©N˜ž'ý¼í~Ôx »5GÇ kº“@‹IÓû7NªtV)·–°Óo5òS‡–·*>?ê ž>E{ô¾Ê‘›98h÷zdy¹Ù6zËGì—õÜ)‚Í}Æ]ïžÏ}Îö —=»­®(ûý¤ô=ö þsh:]ƒÉ¸ònîuS¼ŠßÛo*`°Á‚Óä“Âfú!>MëµAŸÕ½Üƒß\ü†¥Œ¼Ó˜ûk‰¡‡¹_|ç LÂÆ0Ráæºîlî£ÓôU‹µcêKÛ|š†ÿÀ©ú¬çèÁ=G¬Å,ˆKÜš(ü$ÉøÝ5´îÜÔË„®M;Dg¶fN®†ƒ±ø"¦ïàá.íÐaß—ô=±Íw.ÜK—øœ¿çå_ë]¤yj/—ÔmÅïþ0ã_-Ñž,ï9ú¶¹=àÆ“<ã `˜ïŸnžáË{÷âú>öÊÒéîðîÐÝmwºÃ…IŠäÐ`wi/¯wg_žÜûðÆõú³d&¼ø!mäáÿ»»“¸Ût½µÓB jlYâþ§v?=MÙʶ=O»K¡Ä:ý¢$ÿÑAæñÍ>¾ÅÕ›éÌþâNƒÜÝ¡ÁWÛ%6eq²âwV*ìø–½Ã™|ðqý¼ýIÔ¿¾|ö¯gÿ‚J̇endstream endobj 4628 0 obj<>/XObject<<>>>>/Annots 279 0 R>>endobj 4629 0 obj<>stream xÕ\iÇý®_1ˆ¡@AŠsðò7G¶N¢D«øc0âÎJ4xe–«Aþ{Þ«ê®*ri[„]Ê6¤}ó¦:ººº¦×ÿyP#ü[õ„ÿ-ÖFÞð’üó>)&ãép\¬‹±ý¼*^îM#‹è€ ˜òhgï9`º¬¨Ý؈ÁÖܱ¼­ˆZσo)0Q3‡ÔxZ8 Býóq.@ª‚:1Xx%rr_ Æ@[ÏÔï$Ì*  –ÜOœ”8SOB¸Và W"ム‚|Ä”øë¼aâJìGÒH1æðµ¥éÚOâ¸ôç89ÐØ«ªáÄiŠV)NTÅTZŠeN2çÄ\« ËÍIdÁY}–ëäWb[c¯ç:åˆÚPöäÜP€‹‘¸Á ò© sÞK?­<ïuˆ½„†v.@ˆ!AÄIí4ç½Ò‹¥¶*FâÒlŒŒÝ6\𕳃EO˜‘±:¨ä¬Y–Àê ‰£%gˆÒ ¹ÔOÄ”…q-°ƒEN€)Y[õ‚”ýªÙ- âöÎPÇ b+†MŒIʘù*0cf®¬Jä>Ìrñ!Êf BD\›@}‘\€’3Ì'–)½‘¿H;j0s’x8 d u2b° ÷igU|I= 7&M¥å!¢a=ÂJwRV¡vP ½I?‰ã†0Áâ㛪Çœ¿+bÒ9e‰iÂY¢¢óI©Noj·ŽÑ-R( jMu¶’%d1-eÐnÇ‚I{æí+bt‹wac¥Û”NH7¶µ;B+¼ßFHù|sÈѶïHÉ‚8‡ü,J£o$¯Ïôg2ŽÐk §1‡usÈi0Æ;çëhäœè#§%4ž%¢Äh 0*@ †"jfæ,Á¡ö†`æd°”®H÷–¬8B£Š5*@&…:›ù^Nq8{Kb¤Ãœààô‚lÕÄ!:D<àÁ"u 8œgy^ÉœCpˆðH­sÈ–u,ãþ|ʹ;£¢]<~Š¥9Å´.®DKãeTL5°ââRJ¿£âbñè¢}µêŠíUñd»Ùw›ýõŸ.~ÝIuXº£“³³uÎÞŒ~¨&_\>š²Ñfü\¼øéÙÄXÞÓ:=k7—|„ÍoR¥GO¾þº,ùðñSCéõ7t[VÒåeK醕köûSßîv]ÏgØ"›YzÜwW]ßm°Q`xVÿ lÅù æÌ‚ˆ³ŸoWÖÛ~÷f{#v˜ ÂÑ$9ß©øò˶Ìê¾ÚŠJp('éÕ«›Íb¿ÜnD#ãá,[aûêçn¡†qîTQYþr>âÏÄ¿ø°+b}޲xû¾]¦)WPºÂ ™×ݾÝõÛ×}»^/7¯Ù/²Žj®-îÉLêq¥.G"v–æåf Öb­Épž ‰ÞleÙ À–ß=!ùb»ÞÝì“Ì •¯ŒýM/NPM†u~ºOJF𿵏½âàHYÌU>Î…fÉã>z‘sŸZ¨©‘a0Ð0d=’¥’õð¼ï`íEw}ÇRIÜç™ÌÝõ‚ýGÅÎap ‰Q øÖ$¶qxº\É*A0å¿Ü,V7×yÉÏ̉îNŠO)É>Ü$7(CâõnÛk`À1¼I‹æÓfq§­Lä*‡„ÙP Œ½ørÉÞ®h|¤^¶“>Áj_®ÚÞq0¯¦÷ã~AyYLÖ©lÇÃGÁ#gþk»è·|†º@væïßïÚMvf9sJÔÿ…Îà1êMa ¹Í‹ÇG¢Z^„u›Ã˜ˆ¯[:œøË`e%’ °{˜¬“#YŸÌegÇS&ï,r v¸þöRLR—ïß# ¥íE)¨W)y93û² pštH¶ñ­-jì.~B—Ýj¹^î»^%‡;|ÖÍÕ'ÿ©?••Xy W0Ìô(¬ˆsšþ;Å~ø_qœÍs–ŠùÉ£ÜáÃÿ¿ñGå=Óù ³Î9ÎqÇü-]Ww¤ë¬ÃJ®µÊ–We‘§E…<ëiv|,½èÏé[Âã wo6+DË(¦ÉõN®%=íà o k‰‰u»Ó•„"&¯?!ƒüTÏÿìíLjìÝ&³FLÏzþµìÞ¥äu;ì,óMª@¥'rŠíÍG.düÍ™åe%ò²\cbëaHÊrê¾o,½ÍÛäW]ß«´kžýü„á¿z×ö›|YjT\.{œ|—o;ÝkQ€>—H çrÎzO:ïˆ?d XòRÁÕòUßöhnœ“¦gfî]4e%‹Ý«@Ç$ì}Yœp‡rü¹·iNY]T„šQ^''<'(þi¥”ë®íodE!mËGó]»—gÈoÆwŸ´%¡þfêzGjzBÒ¯oû¾ý Þñ¦ÉûO%eÏ·K5 Aå{’öÔ5ç¾—õ€YŠ&PÃQ6²Ø©8Ã¥øÀý–ƒ>N7ˆœëQ=ˆu˜ ,Z1g’Š5ÅóÚàNJŠïç*X¨Òb5ŸZî³X·«Õvñ%¬ãLŽ„.Õe»oU&la_„¹hC|ë“᢬mÙøÖÁg!;;Ž5/ö}Úƒ¹]ç-ì/ˆº«œÐ æq¾E½_¢Uö°ë£ðò]wÕÞ¬$ãB‘Öö—kW@¨Ç¾‰ ˜œÛÉMD\l<îàCš?o­àнÁʯ–›”ˆ ŒcÅ º¼xÊt8;ÇÀ›%öOpí£hô2×—áÉuNnºwú-…âá{¤¥¤{©e¡Šð«®½–ÔIZ>gëßy4uÃ÷Áû©^fùq“#Zü(p©/§p|?=¹›üÊòÖJ…W¨æ· /.~|ŒO4 n7ŒrBôãAN Ï8ó}Ÿì)Â7/C€Æé˜OmÙ^ï/¿ùƃ’\ç8sÁ°÷4ò™l —¬,BEð¶hoq¸Óóáð!fÔdaÕá*ÕTðNÅHº÷‹nDzÿ5”Åó×»_Y÷Eáæ˜ˆ3óF— ûä›¶ï.ÿ½Û÷"~¯,¯ÁëuÛË–ŠkœYÈ"åñ¢œºÎé°›¥Å¥v£H˜d®¹¤×Þì·YX\á´­¿),¾™œ[ºX6)UðòLBqCRør¿\-÷²ÅñÛNþÔ¬v™ 1_@ˆ5„rî(aß>°°-PÝ+q«îÜìv+$Áb —z¬•JsÙ…¿í_߬qEˆRCºœÀ1±ÇÖ’M}k´ó{P6R’ µ'L>m5Hâľ¿^™äm VšÍæeŽb± „øL3§¤Áœ7cƒäÉ·óÙíÙfßo/oìVrÞ³vî,~ËïP,M\¬\.G¡+n×âQ—K`¸P“óþ3ó_üŽ­D%|ˆ†ÓD"Køwû"ÀÓGþ>v$"΢gxiPE¾R.fGõ„’E|¶» ü6”?: Šk“çó9¿«òázS”Nó†,ÝÉèåòJ.=J(æÇ¡üIdÏ•ü×òϬrkâÖ1ÄÊz !öÛÝnõ!|ÀÉ»@ÞË«€é‚*Ve¶dqû̽¤GP·¼H˜o•¼mW7I7¸Ý›Ô{K·šÕú’'¸ýs;ÛÿÅr½Óû^XÀy)\ì›®}ìÞ·ÖàlÖµ [GWÇÕ%1R·ž’E¨°Œõ*¤86¯>ŸÏÎþcâQ´åa0þ,ÎÚÕë5ÙµYhc"¢ º§CRÜ?÷?äê8~»Õ\ÇA¿Õ‹ÿ»¾Éãd‡Oòü®9À*-¾Û.$¹´›m5~ɇ/¦l|ùè-¥þþâÁ?üÑ8)“endstream endobj 4630 0 obj<>/XObject<<>>>>/Annots 334 0 R>>endobj 4631 0 obj<>stream xÕ[]o[Ç}÷¯¸0 ÔA*†÷ƒ——OEc7E‚¤±€¼ä嚺–ØŠ¢JQqÝ_ßsfvgf%ÙIƤ›Âöðpg÷ÌÌÎÎ~ð_ÏêjŽÿêªíùÿõöÙ|6Ç'ü£æ?þŸTýb9[TÛªváºzý,ˆÛ _É_$Öö»…´[´øKbA¤ÎŬ‹`dž-[l«åÊ6 "6³:}SGã2Ðn ZÑ#}ŠÚ¦jEpµ «›vÖT½ i8_…†"xÃ„Õø{¨z£Ìñ¬f}@Eíb¥v^*˜ÚŒÕu7k+£ µ‹Œà¨ªÔìªVW›°zNš £ µ5ù4È@[š1 AæZX> Aºlgˈy[5ègP¥ƒ¯X0,Dp: KÃ70Êè´éh%GƒL:}‰™tÉÛ™tzÇÑ ƒb©¨ÒéC.Dp: «›%ex9[E4È@ûžõ¶AÆ0Ý`C£ ´—¨0TŒÐuû‹àN6,ˆ"40Ê@á‹!¢AÚÕ%d °;ȘfI: XƒÃ•,£‡Ämµj©U¾H,ˆPº¨éRÕMœR"¸ V×b£¬¤„Õ˜0’Qæh GUm,ý[«ßµ—„%5F™jYâxÓ(…ÁÔÚ.…x.þç\/[+þë ³©xÆPmjå¿4 å¿Ëh:4˜­£Afx¶ô¡žMÚH<ª`á™1 rÇ‚ˆ.Û9f„ƒQÚ÷p©£bû&nT0—f £ê*Ç‚È.™T¥R§Å©±JYª¢ÕÀ4ÖÔ²î9 ½©ª•"5«µŠUÕ&Œ[DŒÇÀ(³ÓUªZ‰É¬Ö*KU›0Ö%CÕe¨]4?GUm*JUÕ–ADC,­Q¦Z±­¡ªV Æc8$ÀÑdzQ˜j?L2ìósP»„£ÚÊ—À†=~n$êRÝ& ¬js)©3DÔ¥6Ün ìÏ1.ñŸê5IVq¹„1ÈiAA&á똋°-VvVq)J¥3©ËRª’ÓêÒYBꆻ0ƒ‚ÈΘQsØÀꘋ, "0yX˸ËàP¾>Çërƾ¿¬¾úËóÊù[ô/¶D_ÓwÕù…ÅÏ«óõ‹óñÍõTíÞV/w7‡éæp÷Åù?‚:9­u ¤*;ËÚÎõ—8Ý?¿xQ×l߸xQ¿¿¶ã­¨¿ÉdzÏðXµÈì«o˜*•=gÉYÝ(í™g¨+õooûÝÅýú°Ùݰ¥ÔrŸ}¤1Žø¬[E~ʰÉüèZ~ Ú<¶ÞÝü2íï2cìerbÏW]A°>™L»zõÄxøppK#.ëK—IÌšË~‡i/шUdhS¤nÇÃújssIí0«—'É%—0|à3‰Tcøãt—™  ÃCHC`¸lN!ŠcåWzPÜjü~ºüpûDn=ŠGë~Öf¾odf¢–‚±4]ìnt¶†ÏÞmW¢ k~n™-õgXSŒx }²e{ ê-&©DÁ¯äj% e+ýÿLr´èÁ>G"¤~0É%nÌ"¯7ÛÍõ¸ß6“.»Ã¬Oñ^vTÀ6ûû/w·ÓZŒÅ³œ4ó«ï÷Ó¿ë€FÑûÝå~ÜnÓCa×~ªÄˆ“|!ßÌËù!&1òçWùØÑç4¾Ÿî„æ‡Í†ÝÛdˇ«X‹ßÊ-×Wã-ò¥¡ž5Ç› ç\¶ ì09dý’}§º+­`$€£Xó.]¾y»Y,M„5v³ËS¢g„3ÏU_ÔZ8ù!)sû«éíæ&çýàû‘ß ~OÙM< |›‚*Õz;ú?2Ýzþï“¥É#Ç®wV“¦?aáºß qãèºpèËÝíûìÏ0#?æO¼R99YœòÇy:ë ¶¯¦ëéèæEûWèž^ƒ;;{H·,b~¸×Ó ŒÄo¨džH˱pÃùÉ)yØÈ9Xâ8äàßRs¯¬"­ö÷׺lcOßææ A-$ÏVòŒKêRØnð5÷·JÏÆmú–„ðDçÔÊ %ÇÂãö„‡â‹ÛSäwñPÆ&ìv\ïwâHÜgy±-\‹÷NêRÜ2—.M3Fæü‡‹én½ßÜvûŸ_0ÿüÛf’…Þ# £#±é¤åäçÛépµ»ø“Áw>„#žÖeºà-Û’T½LåÑ*6‰ãŠ%d»Õ›.T?yœÕÖL¥¬©O9Áê#!b„噯ÏB1ÐI–hžonžóÜÞ£`Ö3·HÕ§™c”{¦¹ŒÕnMJŽ$´¾šÖÿªXuòƦdzr.Luï#–kÅóÝýAˆáóóó!ž…ÑYgC\+ðÚ¥ô ¶,8Ušx‚Q$\ÎóË\,Ñ9F•áƒ`̬’#6ÞÜ“Š+Y¬$2EþA££×0OdüÀKœXlJ³rSòܧ ž¤¬òõM9Oàá ~¸PNË(Çz.E”湈 mò^£dؤ›¨§º9ÞgF°¬KqTéÛý4fR,§O­óSœˆF±\+dwé>ÄÞ‚…`×̆|ùˆ_B~ª;Ãßxœ's°<¸Æz?çÇm~Îô|;mßLØU C®…ŸC˜9\nÆ"›7&%=n‘”6NŸ·ìâÌñÑ:QkÝmÅÏ3Íd†µ>/XObject<<>>>>/Annots 385 0 R>>endobj 4633 0 obj<>stream xÕ[iÇý®_10°À©™žƒœOA¢Ã;N´Ž¾0f¹Ã]:¼ÂC+å×çÕÑ]EŠ«D@`R¶!ëÍ›>êèêêê῞YŽ‹¬lè¿ÉâY>Ìñ„þ(è¿OO²¦ ël‘æÙÛg.2¼_$®lV5·«ÇøŸâ\d£fØ8ÎAŒW” =[–Ãàšz ¶i†cÇÖMMH±šƒhXµÔßäÙò»¡p XC劂Þi)*È[n(230(Wäa8ÊšDzLJhICÆ:Lb¶ÃÖ±D!@fÀÀ&¤–$ÄLœƒè4ç %Òcš.ëÏX‡Á69ù¯±Óti—1V c¦ˆU10ƒ+'ùš‘£[˜«-5ånËÖ¹¶€Ômä¤#=F·È+«ÌXévìܳd`Ý*W5´k¤Ç4[R‘±Ò-rä„’u«uƒù$Òcš-…^Ç: ¶¡påX‡á×lqceJz’àØP2°))§ K¤ÇIôXJJMë9O@½:Ç¥´Á8vêR3wvjÔÎAìy”<ç æ‚tÓƒ­iG´¦2¤æü2FJêäd¤ÎÊÄ!‰†$4ÒcR-lcyÈOÔR@’2rœç uZÀ Œô˜¤c8ÖaÚ šV&¤y9 Rúì §3qdåÀ‰$F4¬9l#}‘8qè мHœƒèT8RæÉێƼÀÀ§œìFJCMcE¢”:¨~Ç~%$$7R:õilHÙ¨tªÜ˜NÝÆ9ˆN?Ñijè1Xʱ2$;[T€å„ìHÊqªL›n‘rD§¼Vô,²è<5õ˜öñ@J¬LH“MÚ2Bžr|´¡Ã…LÈA ‰t¼á“‡Ót)ZS²ÐD“‡œ r<†q¢Ó@j7Òc’Vc;¢Ã©±2!M4eB– ’ å`Tpç :å¸l¤Ç`Ý$§@M$eÈ” :.IÌÄ9HCR¶g¤tÊÍÕ¹ ¦XåZÊ(Œ£…_hfÄQ@5s]æXéÆ9ˆàZ"˜'SáÔ"N%å"Ÿr²ÐiшëHCM%äMËØÊ!–bÖ‰sŠsTŽô, X8–‡Ô „Gä¿'¥)ƒä² )u=&„þx»J”ƒàÐáØšñPšyðP))1Äe´6K NLŠ e:Û'ƈ\E+‡L¾6Ž'¡y ›²CŠ»‰1„îÊ‹+QÜæÜAÊ! ¡QN+2QÜ(–1ivü÷¤se0*f¢Î¢î8™Ž”ƒ4?Îz#ÇCi&Ã3â¿§¡”aÿIŒ!t‡Â òhyÁq\Iå“þ{Jî<1†Ðê<ØhbŒuÇ÷§WTÆγÍ}öü5–õv»™"¼¡:\¢pŠœ04UvsÇè<»™\ßt·ó>[M³«å®_î¶ßÞüæºã5w‡Ð‡Ól{„NÔ´o‚ZÇw×ÙÍÇu¿èÖÜÕó×´ú¨ahÐ6ÈëÃ"P ”êØæ¡ç>ÆÃ<>Úì—ƒÝlÁϡζÒWwèžßE&ôÙ䡟ü³ßÐc$С•Çà ùÇSšÙ@òl¯…!k®Œš{³XÏûÌÐíf«%µ¹X©"IœF”F9‡åLâü¼íîÙT8+«Uc—ùÿ¢­ØP(çÕ^°’žzou^¡vÙ¨vË;z³pÞºzßoæ«în¶¼' Qâ²,ŠZ‹Œƒ¨—˜õà$þaµKzioWûkf4 º¯ºõzþ‘bk¨ãRŽzi‡•J5™÷¯W¤ËMyN^´cÑ=œc³Šœ6~ê¶[5("~Í×í:ꀶ‰øì¶ß=ö=¯å²ŽcÀ¢ cd‰Ë }ýÜË¢hÛÓhè±ÓÀ‹ï¾ã'8ÓD#³{˜m¿á§õ° ‹OÚ Ö«6±4ä¼,ç?Tw¾ù•0:’üÝC¯KV޲ïVôRä0V¹ïå‰ípÓ+bòE\Tð¡ØÓl‰ÿÿ@}¢Ä1>»s„<§¹<²<¡(›¸–Ý<íÿ/öÛÝj1û·ÛÄl§~Ýw»ý¦çäŽõuh‰ C8°Šø1—ŒÌEþ³íéØ".ÿêä_Ç õ¢dÛÄÁyŒöþãl÷@] ¡ŠêÈ®úƒNÆÃftæ©Jàê -È.Ò‡(ûŸ½ˆ.AKâ°á‘È•'›qlôKç)‹+¾1YÝÅ„¯>÷R9§8ŸhŸ&-ü?<`¾ZÞÿ¶XÿrýË·¤\òŸÏ’ÔøäÃ#²¾dFÿÍú'v‹#‡ÀÙøB’€aÈY(lÿ‡Ž.)Qõó&î7àša7„ñÿ}·™ÑùKÞEK7Íó„?ܤ“£ ŠúØÈ’þDÉ_öÓÙ2F1w^»›M§Ø—œÒM š%S³Ãg¢J8FU!g8KrÄÆ‡Q‡¾-9OûíºŸÌº9É€ªBLd²C"Në&pÂÜG1½Åéü|g»kÞ_z¹¤;QèŸcš‹\©§êìæÓ³úÛwo¾'ÍçOš}>»Ýt>$ 6u¾ä÷gâð¨«yËs,ç2¤ìç½ý­ŸÈAÇ%ö«Ç%\÷a¶f¯vY]<ì¸CàÕ²\¥^pï9:‹«Æ•³­±Þé3žvpI9ñ26ÐNȹSÏÀM`<è\M%á£N‘ïÁÛD©w³ ”:{Ï;;NFå¹ó('äñüGu7§‘£$G5Â"á%ŠÔív›Ùí~§ñ5žZÛPÈ匇;‹C!s˜'„œÎ»{Þ¯¨þx‘ò©¤¡à3Ë`äã®&Èj)Q{AUˆ¸—¹«N+sH'|SâEü ß+‘4W…Ãò&*jGåóË÷®Ÿvû¹ìß8‹Äü»ÛÜï©(É]TøÒæÌfÇÅ%‹-ßùez˜¨<áÁý‡ŽÊ¬¼zQd?³0O9’ éŽÜtyŠ«Gnöc;r£z¿é&j¢sæOÉó¿>»¯Ý pŒ6Æ'd6·9ÈE®&ª z•Žßº×fÇ[ιýø´JT¸,ðY >Ä?’üI1OìË“9 –²-Ñå®îͧÇ?ãÓ$zîM.žnåÜTmw3oÆŒ»»¿ßô÷©è„îH×vvB%WñõþW¾<"íâ6øWG¡ÐT—ñ¶#kw¾þãJS Ü j‚~Fc}éСàlÛ´Ñ8E3^ó)šýCÏÅd|3œrÉ¿ôË{)•ùªûýö„/âUÄ—Nðwy?œt»ðæªÍ8D-ò7ë«»=e¹䋉ó¿DE*éU«¾«O‚؉ðýÓf…’È‚m/^¾G…ø[“÷8v¡v’2,wr@IçWT[ˆ…“í~½^mb>–kÙäKŒð;¼ ½2Âå¾ . Ú‚v\¤dV_ßôëy7á;o¢p4ŽÁlŸjX1½òªÂ]êY³·$úÁ}1‚óÑ*Fga|?Ÿ œ ±0½ŒûtCi nô“Û‡ÅEj5-â´?]¡à|$ó«%®âb)á7žû¨¬Ð»Ø€’&e HÆviŸtɲ !æeÞ“ó2ŠÇQhä^©”M»z¨ÊË–ww÷Þ!èÇS—u2 ¥&)È0bfŠÚ‘Ýß~\Ü®æ³ =öálËÏÅÂå°9÷‡Ÿ•QÔÖrp|Vw$é‹Õ‚¿-•«7ü\ëëØ~£l(˜?ɲ܂¤_SÅ+æŽ ˆ¯KR–Õo6+¹G——å³fŽ’ããwË:ðá‘]u㥧>Zãã̵~Ÿéªdòu½‹óBO×øÑ3M%Poòãdë‰Mj¹_Üê—àîÓ«MÏß&L¤ì9\&{«Ìüý¾ýÁŸÞã—6pÒ)~+Ÿñã×O>¼£k÷¤Ì^®&|E“ªŸô Å×\ƒµ½»~?ãCÔ«›g{öºZŽyendstream endobj 4634 0 obj<>/XObject<<>>>>/Annots 437 0 R>>endobj 4635 0 obj<>stream xÕ\[sZG~÷¯8J¥Àç̹ÁÓ–ŒPL­$¼€£Í–_0:’É Ð²“ýõûu÷LO¤ªì“Á›-ÇséËt÷\ÈÞdIв$¯èÿ‹Õ›´›âú#£?&¿Ð'IUÖÝ2Y%YÉô«¤L»=ÿEâ \%ý¼›[® >‹’û¬û ¨ÏÕ-Òb°UÖu¾žŽÁ«Ä¥y·6lɃæ¹”AÔsþn•´ƒÖe·2¬të2Ó-ƒØ­ç²´×í'•’£Û¼ê–5˜m·•AÓ¾”AÔsYZÒ JZŒnk³ƒ­X±­Á¤ÞŠ´¤,O©ì‹Ÿ°è”—¥ Œ¤Å´¨á*†5l¯'‹¬ Ú3ŽT2ˆƒz.s)$¤Åè¶Ì¡|ÃLƒ’Ö`èÁ‘"+Sª›• â”<—¥) ª¤Å4'ÓÖ`°pBÛ΂Âýi‘–=šÔ@,D¬jÃÑr.s³¶P3^ÛãÅ9WIíà‘3óÌ2š'@Ê<Ø JÆ<ð<# óTN¦íÛe«FIé4K§ b§žë¹n–”ÊI»Ô+GgÛy®ÎÈa•3í·8ɆHbC‹ÁÂSl·<Î6¤éÐé_éÎ@RxÝ"-ëz˜PìÖb°¬Wà ¶®ZS’éÖâ;¬õ‚Aœ®ç50¦r®’^…Å9¡ÙÖŠœ$%HZ ÓéYÖ`¤†Oš¶c9g"+bVÆc QLÏÉò¤4dÅ`I²9ùÏØÐsý‚t œ˜+Â+” ¤Å`‹vS‹ÁVi»­Á¤ví™"AÁ¡ŒFU@³5p•`)‡/gà*©*$\é„8aéM† Î@Œ—Qv‹¤Å`]ÑêÖb°pXS;¶ÖÌ©(‰¬k$®14%VEá9¤ ôªœ´C.íÄvžËPtÀÛ•ä†9Êm(@.C]&‘”†=œr±¡çúdÇÈå”bDR:­LˆÉÄN='½('í| ÈzÊÄv¡>D€é%‘”†¾Ð“† bCÏÁŠy’+g ¤È øN$¥S_¬I§Z«HžÃ½*i1y…Ê\YéÖkÒÖj•)þæÊˆN9»DÒb’¥MeH.¡|ÚÎc=EY\ baAC*g :­(žE’;u¾ãä/€uN®GFÎ@ XÁŽ‘3æ´8")úBKÔ"Ì@tJyÔ)g uJÙ0’“Œ´¬ k0•¢¼'²2!_fÉ ´Ê2ÝbB%-›•4hd [²4ÊÊ ¶síL JQ;’Ò°ð‹’ Ä ÚËs´ùɧ¤Å4Ÿˆa †Š*`lm+ƒúÊOt¢Eš4[‡èë””†¾“oj!f 6T’r Š!g$¥H0}O‹-y‰@sÊa¼á\Ž\[91œ vVÒb°%í‘"Ë"Rј-@ƒVพ4m0©º v¼@í Ä€p¤¾ÿ&Ëo0X˜*ôÃC2ôU†ô£ˆhèh‘dJZ¬ÝFV†ñýJ9Ûò.†ê¨( ƒ(‹ç¨ÀÌ Bú¦È1….1¥È Y£²¬Á`±Ç©-k0ÕiTˆÄž-¦¼O¥HdŤ…ɦÖ/M] Ç=ôªâ^€$ %ŒHŠŽ|Í$–Ð2Ä@4)i1i¶”›DƒÒ-—ÁDÕ{.ãR•: ª§ÒU0uË~£¬@_¦Èô´J1*`çTÎ@QAÎaÓÌÕW7Ü ÿ]gꙬ ­ƒR¢G¬—~äx–¾²áµè‰x£”$7)R9îÐW5Ü…5¡—mJHƒÑ #!8ä!œ1Ó®—¶¸É{)ñh;)T×Ƚʱ¾¼â)óßUÅž¡Ã$l5Õ"ÄD°]¯#ÇkÁ–dZuñ2õ {¾2‘>¨6PŠçç‹1žŸT¡QNkO)näK-þš–DÑHth£Ô»™9D:I“íCòö’")òÀìžË«2/“ ¸ªHfw|’™&³ÅÙlþù±I6÷É`³Þ7ëýî§Ùï¦;>ìäî Ðà>éP±F½u0‹‡£³»³¬¤Vàñ»³äv¾]/×ôY}Fá?¾nv»ùCÃ#¼½,|y7«Ð©“~ºØ×Q;WúFÍÓ¶YÌ÷Íw‡\ž{澙ÒU¡ŧ3l9;Y¿ÿé'n’u{Nštõ?—³P¬è·Du-Q?l!ëf-m¶DÀŒPB9ÊuaÖö±d²ãª|ì“Ö˜yKÂÁÛÁÏ?ó'´Ugù0ßî–ú‘O?å7WyQSÒ‘<¼ËŽ{¤¿Gq‹–9‹–°³?ŸÄ9úa Ì×ìÇ™ùhï­æO¼,h¹ÿþtV@…QAíµs$±».gsv¨ÄÇú7k–׿®ÙÁæ®aUäjµä¡Y7Ûù~¹Yƒ«ööL>•³T9ÓnÕ; S«¸yÛÌUËÌWóõÃ3‹•uûÁ|«ÍÝó#Šê›vOÍby¿\Зô+õö*èô루Àåììn‹\·Dþ,¶—ÞTÉ]s¿\K†¼f÷!YßH–yˉ[㺜=·ƒÖøs–²¸Ñlï—»ýfû'[íØ¹¤5ÿ¿^¾·—š½û)-]GEÀYÆžÓöfûïWÒö·åþ ëÖáùš›CVŽë8ÎúWÂðØû±òèÔ… c•¼/d…¤R>­÷[H¿ÐPFEî©d¦×EîÐÑJ ØØz’"Œ¤ïæ»å‚­ùc˜ÒŠéÍÚAJ±"r¦2"ξp,Ɖz,9½ýÂŽm>Û>¯÷Ë•„m“½>£e8„9r¶²ëßqE’t°ÉÕ8†{ó3ÿØ7Ûõü‘>ÆnGc÷|AEgPE(Uönžv]ˆñ{¯C$o«/ÄËÓHܬ—÷hþí´@C±‚ 7K×ó9a˜5Hôm³å ‡Fê)›{¯ -Îóç°ƒ‹åÝçÍóž¾Kw3¡ÇÝu§|ôÊØäqùy;ß.ýþ» £æE—÷iÚ”ø[Ú’ µ5iî›m³†¿Ð×yÍhìÓµþD¬œñ^6&LL„v“C5÷ŠëÛΟžd炃j¹û¥T}8ÉPoÙ-ÿ+Ñ'þ{aVGü·Wˆ)pÚ©µh&lé?î¼Rh3ó"€bùE½V-,󅄺v Ë¢Cd”$ßêì¾-°…—Í{EWœ’wWóõS,³Ó£DWpehJˆ WN1ºàˆ—„2þts~=¤øóGY)â“^ØNSJý¢r˜þv3þ0M9œp%t°Ì‚l••í°d¸N“чÙh|Câá»'nÀ n,­O–cILfÒÔôãõõùä7×ã!é(îÈ0H˜em“z[Ä“­Ï_hÓrPhr®‚È$&¦Œn¦³ó««óà˜œ²OÙ5ƒTý˜yëîaæþs6áZ ÉT§µ#j§S^*¤ )\‚Ó o~MÆ7×Û7wš=ŸŒÎß] y]–Ø%ýðÈ®+x·Hg×­¨Âõ¢mp>xÏ©Žváœ`:ú—¤?Sø^Ÿßœÿ2TÐB>çuÇnZ/}qôª˜ƒñõ‡Ép:õ™¢ÆæéœV³IU:.DÂnõŠÜ¶˜£®ñ-y&Ê<ÝŽØWñbU·9·ãÉßÙOaëSñÓ—ž‹O𼃤éà8ÕÈÌ'Ý¡Žý8ÝðIŽduÏ7PKø4T÷·£Ù{ÖOOo/FÓÙ`@âÜýt ˆœ¡v¶U@Æîm¤ž¾GĹq­¶=Ü«—q~ KõÀÔ*ñAQ±íÄïa©±T8?ÐÎ5ˆ×ªUåÆÕÈv1º¼N†7I ü3l´.'ãkvOsKkt5œ¨uñú,ýÞÖu…œ¾»´µ<¹Þ1¢ &ËьãMáe:ð€„A¶ÃUÈeîüãìýxBæùád³øÍ‚¿Vª'è1«9%× ÆKÏ›‡-Ÿ9Òm~¸ƒÍjåï MºZîž8 ã}Âi”-tÅáUC†“ãñæ›foª§ú¾`§î fh‰xð’cò¼¯BP6¼ÉüÁ„- à}Ú÷.&¬(¯ÿ=ˆÛPãß8êâåüûr³m–üJ…^h„W*,^³e_Ä+°Ã}}¤#}êJ9=êÛ0…—bmù.G„éRÙÊF·e§†¡Ö â '•Z?Ht³Yw6Xz›ùú1ˆÉEsÿ,Ñ»áô„JJW²/bñÙV´¹PÖTCQ%Іƒ}'Ø­wz†T Ö ÔüÁ|·_æ{vZSÎ_»Z] ‹îçkþ²=7 õ¥Ù×~Åe+½u¥~Q`êó3¹üþŒ~ç°¥úÀ~lñ„—°‚FÆŸo¢“^[1 ý;Oþÿ s®ä„· ö@?Q!M | Œ>!»höóå#^:¼:á JúÒâÇÐÖž¸ßoÙóf¾jvOsÎï)Oðd%X…jWøøYMK(þÁÏÝ{þy:îÒRz:ExÑWs´ŸíàH0¹Ø,žWx2¯¯Zsü§z¨‡;5=•¿;ûº\.IAÃÙ›¼ù(ãÕÀendstream endobj 4636 0 obj<>/XObject<<>>>>/Annots 490 0 R>>endobj 4637 0 obj<>stream xÕ\ko[ǵýî_qŠ~qÐ’æy“Ÿ W±NíVJ‚ùB“Gö)øP)ʱþ}×ÚóZ‡¢8°)ùދܬ³8ý˜={ÏŒò¿'y6ÁÿæYÙðÿë'“ñ_øœÿø÷ü’5u;®³u–'°Ê.ž\gålÜú’¸Îêé¸Nà:›èÚ Àv1^Y+!ƒ­ëñLغâT«Ú¦ÚÎ"`·Ñ0Ÿ§þ—$]ò”†RCÏåe;γ&’®a‘KC©¡çòɔډ¤k8™IC©¡çòœ7‘T AŠ)õ“XÁÔ šXÁ`ÛšSJ¬àuVLLÒÈ*[Ô|bƒ­*ª7²mSÔ³àBrˆÒæ“„1©²7Ê æ” t,mƒ–(±nØ©s?Œ!6°n˜Ä fÇtû:²®ãÖ¹‹ïØtØjEÕ‰ŒŽ›šÒ&V0‡åÊV°3A)¬›Tã\ÑOÊL*°E¯©+ÃV9Õ˜XÁ`[ÚVXÁô3Pl«˜S.R[Å`k*TXÁ`Ûv0+ň=ðµ\Ú*k«6õl‹¯®dñ9@MYœ\Ž ™æÈèÍÅBs\C¢ãÀÖ9uœXÁ4mCi+˜ZœRšÈ*¦ N*±‚Á6å ­s‹b° É”[2\Ô‰LÃOéɉŒaKóóÈ:çQkIÅžËó–>IÅ´aHV0µhƒ¦¶‚©§œžYÅ`+6²NO“Áò1$z ,vL9±‚1©º²‚9e[z©­`LjÒд‘5-VSqT¢G­åY"£[ìÓ­°ŠÁb)ëÅr£“O©ÿÊYàxJ*ÛP©©b°Xg…²‚9a:Ej«lÓ"j&ÖM¡3MØ@š°çò|ÊA#éZ˜ ’H =ÇpZeU$C[Ú‰uÝ"j¦ùHÝzŽÝ@ÌH*F·yÿV0تä”R[Á` ibƒµ^XÁT~=è¹lhåÂ9¡©ÀŠ#‰#´pæ:°$Õ`aµ2Àv1l°g$SPŽ,¬`°539aSP†haƒÕ”,+j@  m-@T ¤QZ?,º„@†ŒÌ)·œrd­ãr¦Ù„C©ãÈìXXÁèëb*¬ëxª!­4$ÖB½°‚©F†þÄšƒ—„%دY6pÎ’‰TŒn+®ra;5±(á(6a¨-`N©å”+ØÅ‰°N±†¡­JC¢‰ÀbËo•Œa±Ž0llë:ö‡s‚ÒtX è8±‚)uY×q¨:Ì»ÊXuø[qKV0:¶Ì"±®ãX•˜*bUâ;,v.h<±‚Ñ1 5x[d]Ç–óƒt3Ž€b°V‡0G ¦å^ì0;få–Xó¶ÂWæ^Do \^0œ&R1å~$¬`°Ød§Ê ¦?1–¥¶ŠÁb†ÚÖfá+ ‹pÂ0¤'*Y%R1XDìJX§#_s8Å¢B "¸ÏL3Ú˜ ‹ ’$V0Xìè¹²‚9%nWÒV0XqRÏ‚¡A¸¬¶uâøjÅÍ?–Ñ- ƒ†‘TÌAkN8±‚1(δ­9pá«ç°¥µYt-ÚoÍ ™–‘cTó}‡¤©g Ä}4Ù»5dà®iÌ¢}WE# “XÁú†7%V0XË3…Lÿæ1Bbƒm¦ˆ‰uÖ±ÌÙoìEJ£¹vÄ Ø÷ ÿH*‹éC‰ 1ƒ&V0m7lë¦äósç!1‰ˆn#`ôH*æ <ÖV0XK¢„ VÆ1³ ‹p0èY0ÄA®³RÌâÖìçÌÃîÌ«ìÎçkÂÙ \âú¹ÄÙ\è¡6 À>-œñ¤‚ãYür€œ@„3ƤĹvö‹ÐÎ@jç9„Úª!I äCÞÙi†æ EL*`§¦ðÀåkÃD*¦±¸$Öuës\×Ô­çrlZS›•Ÿ‚Ñ-ΡºØT1XWBA‘uƒZúé׈ë×ÍÁsØÑ.r© ž3$R1‡dJ˜X7¤OSÝ)µ¹{Ž‘ Фbt‹¾ZX35"zôû÷hhÏ øÏ¸çy #‚çT]‘±3f—\ºæ˜'㎗“P8kŒyvHUy4SF›´erÞ=íßã¤=Cà'ØÅè3:Ó_ÊØ¨>Ïävx)ж,\NK 8¸¥p6CŸåÙòˆ`BhdåS¤r0´Ä%ÎÁÁ!×v ‚Ã) óM/€MÒgŒ6­˜&÷f™„8ENDêï—r{O²Ý»ìÙK,e —W~:®K‰CýESe—K»®˜d—‹§—ó·«.Û^egÛ;Ûìo¾»ü¯tg7Ö—Bo#„‹7 —˧ù”­Àã˧ÙÅ/ç?ð–m[úoóÍÒ~ƒ}±ðŸž¯VݻݖŸ‘Wäÿ|¶]¯·~EÌšUþë«þæšßž½ÄÒu¡RķpS㤔¿(jßäçù®§t&R9s_Ç÷sþ#XH…²Q¨›Ûu·›ïûíÆäª8•©ý1 VÔµ‰d5³ eŸ£PÏw»ù‰S<~3QÏEݘ\õÐTö1Ju¶šßÜxïãÁˆ[a!4É·/ö»Û…[y8.¦ŸþåO›`÷2—Î~}º}Ïé 0™†õ¶¾ûÓ¯ßñ#V)VÈi=¤¨- Œò6¸r3Î9%;&rÚ8{õúÂf9OBøm7¿¾î7ïøw?Eëõ±½âľÜyp/ê§4 ãœ¿ÿŽœç›÷Ý®ßÏ7‹ÎDÅ®é£Ýƒ F÷¢Á,ºpdE´»õÛngò‚ Î{Õw«¥[ÒÕ¸ !ÿˆó_Ýn1š±FñnpzD‘qÏ1ÜWpZt`Ï_Þßñ öà¸Cm¶{~Â"Œ+xÙïºÅ~e?Åî?‰1`±ènœrà÷a‹;ûË_¬OÛÖÜòXH‘•p{ã—J³°²«í®ëßÙÆÉà ±¿»înþfCŒ/ ‚ºŠ{Á½µÑ‚°—Ýúz5ß»@øˆ<ü¸ƒ©êáŠFUN¡Äíè6¶û8…pB¯Å/¿"à !¬-¶K[çð™hØŒÝ"¿éÏ~ .¤X§ vAò|v(úa0;‡AûEoîÎÌ-è`iФ»ßÜ Êí{ËZH⌬~eeD:=\â¶aÅ­û‹fÙ]ýÕlއ8!~ oŒÁ\¬{$²]Üm¶›»µ×Æ4,söíÖ>NŸNðEüAPÇݹIš²”³÷Ûm20eœüœ¿“Ôåzׯç;àÔ‰!#ÉâþA wÑL8“j‡&· .šü¥ß‡L’l?t»Õv¾DÄ}öf¾›¯»½[Û,¾}¶šÁWæ·«}HZpRrʤ<Š8› Ìš›äe(Ë^_3`¹ˆƒËª¸ï|*ß:âÒŸêB”Dýa-øLÅ`2Ä×ù7<Þ0óöèK3•ÜùtÕà|÷Î^yÚU÷GG™nbÔ‚¹ ÅA¦#Ë‹î:æSˆP!éø#³øzmŠÆ†³Ã8œ›9£Ï¾A EE Š‰YÕ[ 78— Ƈùê¶³ˆŒCᑯ}SÄ ˜Þkºë®º]ç3pdŸêA)8U–ulŽ`'™.'äþ±ž_›Z¾d>÷õŒízÒÙItZ¨Ø5ÌÀÁ˜g!M*Ç!Yȵü±äZ½å»¨ £wìß»GªŽ#ËäÖ˜1GC²w’`5TqPïvug‚FîíÇçÿ¤’pµ–sæÝ€ŸY5r¿ŠñIäÃÓCñ3Ê×?]š|3ò;²ø3ß«Ï.ÿóæ…™ISe·ˆí3îr|éðIUžŽ‚á–OcÐØ,“¥c‹ô/ˆü"Åú Ë÷þ" §¹Ö}ÙävhÜd~ÁRõsÕ•€bC×Åu¾Ù,m>¯üÒÄkÚP èÒ„q[¶¤Ôy¸Nr6–÷UX–߆lxäHÛŒò‰°ÌåÉf/_ž‡EÉ;†°õ í"íç:Ï—þ}Ë.ö5Ö÷Ž¥^_¼‰’I£’a³x‰7Î\xIq¸È,9TO„\g¯ž_\°.ópº¥‚a©=`ÌðfRá¤Kme.ãçÛeuÊE91ŒWg0^pË·Ýûù‡Þ×mí¸ EçÑSÀ½d‡¸âÅR8]fdÇÛc‘Ýl)ùëù׌=·wI‘‡}W(¶}y]Á»ƒ¤‡gÄg»ÄAycç¸Ð⯨(]4øÙ®Ãé—;+ÄõoXÙÍÝúívåö<ÜÞø…™Ýß1¤µ+%ŠGÎ1„u›ýn»YCŶTðw)§:?Œ Àëc6Îq¹ç­à­Ö‰“‡Ï´w´Mñ’¤^/D$}QÖoö»í’1ÁŸXÀ!ø®j(~ŽÕ¦®êwåÛ.zšÌUnêÎø~.g½eígxGúßY勿n_Gsí•Óç*/ ÆNL†–u¨hݲ¦û÷®×ÈýÝÎŒŒìÀœ®rÀ6ò˜J"¶˜úë׉F#3©DÛ#F½¸|E“òù› ¾N^Ùwñ.Äoº…©âs7ݳ?›ðú[ÒCð¼âôeã-£#ði¢ÉƧâ–:fçG‚òÖAßýÿ^Ò* _xP¾ƒÍèX²i[sRÞ?_ã¬àm¿ê÷VUñ?Ùò¨L$åZ&nL<Ê?0æ÷ý•¿]µ0…B…‰³óýûÈÇ?æ,Çf×!î­±eÇÍnòxv±bjÒr\É&óƹŸ}öŒÿ @ðøë-‘nç9õyòêw=ûÞð7–4µý­Aú‡ý™þt\ñïS&ü“ƒ),qýŽ’ƒ®?Â_öýv7ì›}|VâíFÁ§ü-Û.ŸöÙû‹Ë'ÿzòŸ/endstream endobj 4638 0 obj<>/XObject<<>>>>/Annots 543 0 R>>endobj 4639 0 obj<>stream xÕ\msÇ þî_q“N'Τ¢yw<¾Ì¤I䨓™¸Mc¥ý|&©˜1ßJQ~ù÷}ìÏQ´7’%%'Ï=·{ , `—ùÏ£²èãﲨ‡òÏtõ¨ßëã‰üQÊ??—'ŰõšbU”–ÅËGWE=éÒ‹Â\͸WGpUŒê^I\=”ï ý^Sã_¤O‚«b8’ïé‹Â\“Qo@\3>ké ß›8vµÆ¢/ ‡n2„ìUãHHÆ`ëˆèMƒ–½ŠYÂ`'}®·µáV% WA 7qe98ÉÝB7Cf Ë&½1³„WEÕ˼gÆ`ëîwƒ…p<*Æ0“R䊞MØþ„„UÂ&. ç$c6X6·5á‚%,ÂV½I1tVM°Á䋹¨Í!L&œš`nW–h?H•³›]«Ñp937©a*Á„”°2tª½HCÆ`G}ÈA,a°±_b CÕ¤Ã2–)•UmM¬\_P‚&q6zçº0N&aRË$L°&LfmðÁÆpØv Ɇ ³Œá*ˆá&ÎÆçA®“i¸©en°6ÜÌÚð‚%ŒáÂàš¢q–1؉x¯`M˜-˜FA“¸²¬ÄXœd qª¡è(XÂøh)®/XÆ`± ÄÚ‚©yÁ(!Ù‚Iœ­çb@}qÚ“&'œnLš‚3qæ'£ÛFÍÞYë¶dÓUÝ&.uã$ct;ÖYqÖºí³‰)ˆn'~zw’1ºè¬8«šŒm²U•\³™ƒ‘ÔEpÑi݇CÒ:Ñt D§‰Óù Ž :ÅtMŠ ‹cx±`U=ƒ!M¦WOæÊ²‘nõM!£[øí†YÂ`±^!g´%,«L¼|°ŒÁކ°>b ƒ;=3Æ–VUX¡Ñ–1ØaË0XS…Îe F B‰K¢;ÉØU¬©"·«*‚% q`ƒP£³ŒÁºmƒ¥ñ˃Jd@= C.™%l‘売 hI „¢Wö%~ ’1Õôå£Þ”1Ø‘.œ` ƒÅ1³Á†8X°³ŒÁb‚’ƒ%,йˆ% UôÅiˬnoÁ𢰻§(E%n¬“ãAˆjëÙIÆ`ñIø—` ‹"ÄË,f6ám‹"TMÁ;ê™1ø^ÆÛš"°u…"„"—,ÄIÆr\ ‚% v"»5±„1`„·’·e žó,a°ƒ‘¨1XÂ`5f%–°XŒz(oËX,F½[°„Áš‡ –0ØÉ¸3fS2 4”¬ ”œ¸›#æÝIÆP#–%O°„ÁŽ%”%–°L.ËhKŠªTÎ2‹T–쬊Sc§pq ¸8™+áå‘%ë›B2Æ°á ˜% V͘ÚÎâ«âäïVêA‚e,â4P2±„Áb#ïkÂŽÉ¥Ö BØÄ•Ð!ªN2aeK,ÌgÂ,a°p¡ ±RQ¨¹¼`@5̜ւ#˜Ê Áiy!÷‰Õ‰yÑHŸûÔZ5H¹átçÉ\‰t°ÆÂ;WR\\Í5Âi:—9Û¦ƒd,ª‹~¤)c°˜ |Ô+ŒE±vKX+!W°6שR`#ôtž jÈ%¾Ô$e Ö,a°6à` ƒÅf ã –0X˜9ÄqÖ¦&eì6ž’DФ¶éAtZ©~T-T)—W± ø´eμSŒÑ-à1R1ÙZÜ*Îæ D·‰+KÙ-‚´ñ¤,ÖÆãI,ADVQå$c°H“:,a°ê^¢­}T#ŒrZø£M\úˆ¢3å“6Ò§ÎhæÄ±Ò›ª Â2£Ù»1 >²žËØp'™äp’±ÌЬ b ËGeK,$m˜%,f$^´53Òd ëÁ3ÓCâÌY•N2ÆG¡Xˆ,a’8:b ËTXoË,ÔÆ=3‹ò „¶„ÁŽ»¬„F¥±SÖ€½Ë'=Ú%ˆI•S™à¢´-'8µÍ$ëä{H"æ”6J¥¾æád ´ œÁ;*R±×Ê@6×ñ©f‚yðfú)­€$[Õÿ–Vú©ÄhçÁȺI‘§Ú‡‰0<-Çç}?†½×Ö Ï!8ìÞ©så‚C… î’ 8|€úT“NÁªÊÃÑ@hµKÑæ£ [j#·ø¹jæôcÝ7õ¨KÌD,ÜÔ@2Œ‰$H²IÛ0‚Ã4Hèš¹€àR—: s¬’SFbÖË^›ú „îJù®SÁÁ¬e›ÍȆvÔåwgtŠÉì»_‹'ϰöÅMž›sªq”…a¡ˆQœÍôÜ´_œMŸµ¯–óbs^œnÖûùzñÕÙoÔ­jwXðhp^œ¨«Co'°”ŽbÏf«¾´7f‹—ÿþá¹<€ƒÕéY»žé;ãÞ°JNÿ$Ož<ƒ£·ž‘¶J¿ee}öÚB¬Ïúµ¨–£ôäÛÝ®ý CF8Nßê=€¿P–áNt+"‰{¥<®²Äg¯çªƒq¯Ÿ¹réÙ©¼„‚eVKjö&y –‹W»v÷A? 6©J½c]e=àˆŠ'¾WuÔð¢]·¿ÎÕ€d[«bgÇż¼X¬Õæd(?=ùaývóFµ Ç2Ì]Ìæçíår/¯£ÀUu¨}Ô½þ }nÕî.^·Ëeêe“Qzÿf•˜uR5’±qÔ7¬•íb½NÒ@úáä®M¡ƒHxRje5$oä©ý>æ¾?o÷‹ÍZ6Šú!8ƒj¯s¬&:çØ[»–Ð]ð·$}Wx2§‹í|º8_L[_Xâ‘nÓ$ª‰Î÷IUwõ ‘@XÁåÅ~³J–{Nt¢ƒív™FïþAZ!ÅwOÏKùRòõW-ôž Þ‘Œ~DË_ã‚k}ÝÓÅn>ÝovêêP¸z(q®‡¨¼Mwü]W<Úîyª—|î5ú{, ‹8aóE Iävóý¨€ qÞ+áºà¤ öÁ{#g5±y?›k¯ë£²p2úºés°?mßÎ[Ë.$Ô¸Ñç•)­&¶!K‚Èû†%´(_ f\`²t ú½±Çˆ›ÙezŒD¿~æ}äŠ@×=¨&¶éâ˪ Y¯î:g#@öCWšuÒ¿ŸÂ‡ÔdÅ(!u–è‹ùjc™f1o ÅJÓY ò2 IÂâÝëùZÛ#ãÈÏvóýåΣk$gAœÏwóõ4 {m¤Ôjªüd5_½šïä)Ö’+úm»[HÚn )›¹n²¯ç²Rä,¾c ®ëõr¾Ñ±Ëžœ¥ß¼ú ›—ë&ç¦ÛöâÂ< üåý…ìSBŒÓºìYN¿þZu›59G^¶Lk¨Ÿ Bq ±\Ý·€í0GCR“Gò´Ýk8.ñI=È#±ÅeYŽFêGdž"ÇU[¡T¶¹»ÑæÂ Ù1t½™.02ͨq2”'§Ýïw‹W—ûdYˆƒo*Ø«û)°ë¸(qu´õ­ RÇ,iõ.· Ž(Ç™aÅ®/ö;l–ý£êêj=Ì܉ڜ«É¯ú»ín³ïö‹´b¥¬xÃ&…[S2Œ¹½Ü]úx±NÎ e¸¼|¶-Œ¤]Êpàã;êAÎJo¥ftܽ×}«§ØfÔSP¹ÒAf/õý{”~g¹®Ëc°ü÷V0D(—}5ÉÃ5³w‹ýkí•ö¯v6[HòhJT0n]9ÅÕE6Ý̬։Úö§Ïüqù¯yZ÷-Ò“s¯îŠÓçn,¿¬góÝòCÖ M«˜¼È çäŽæˆUÏ×—+µ¹ëõçþËþä×ôQÏ—“Ç•nlŸ\˽˜¾± i™¦ùš1ܪ.õð‚Ž!°s„E”R<üÓn¾\¬kaæp ô0äM¢ž4á!ÞAèûóeÔ„áó‚=vìbZ´¨qÕ©¹:Ê:àQB7EÿcJ¸ºpŒy÷>?lÇ…2{åÛdÒÙùiž;ÚžÏ×s ±6}¢ÌŽpî†C¡v YVnäý¢Øüß[¬g=3¯ÖÜ™ãDô-r½|¨€²ÕèÆ¿?&m®ì”ÍE¾®9¿èT%îÇB¼Vò,˜^ïãyëfW˜¡‹}›­qâÞêHÒó/NšQ¶(ÿpÒ|­ŸBfiq#´c¤ÝäèÙåzêÆ¨çÆ÷{åõêÒr¾NN#ÆÙÍi¼4¯QîgßsûÌbéí½°MµLrŸg‹õ‡ÓÿñR<-®ÑÜs¡È\³|ÍAM‘¤ûq±~ƒ#y.óá'rÖ¥ÎÕ ]9({(Q‰0÷¿”"üÔE=î•„}–Q&ª\TCÀ=]*g¡B“r¾A Ü'x“Þ«.­–)³˜nVÛE:Ú¥=j¿XY} í6³¦¬3>˜¥u÷™ï.ËœFÊêœFN);ˆjÓ\²Î‹KöLQ)ºóº•™üGþ3 -×£9#ÀµìŽ­ÈbˆøÁoá¬Ò!.„JùŒàX(‘Î púiiò±œºãXðSª['ëRW?òCYéáñoe¤c ‘÷s]øÈÌ}Òã,ßAÞwxûÓ5Ÿy:u}x>Ïæ°ãóO^Ÿ·»WÙ©£´š «˜n–KÔìc¡–÷ðnM]ZU.Q²‘žÜý²¾¸Ün7»TüFîî•åsP^îR©ÏÓ®V &߬7ïìć\4Še8”±b®©5w£%WĈƒIÔd:.ëÀ‰xà| ƒçBÇÑ)yu*¾ÅI¶R#$Ï^Êðã…œDáÛc·=Ê[Ϊ’F¨Üe?rÊ/ÝÃ>µàõT¤Áõ݇úd¿X—º.¨èUG) eÇíý°Þï°A…5vϳ$j’ôdwlRvLònV8ÛµÓ0,üìø™Y…7â²n‘Ú}(Ûå¼*ž5{þEÆÏ~}·ÆÍj]~!ÉÃÝ­­pß¹9 ñÜÕ†oNþ–TSÿ"-b÷rë6EÓ´+HàÒÁE*yápì6ãìßk>uiZ(颜(¡OåŒâ/"5~Ç6ÌyÈbåñ›AwÇ3yªïÞ]ÄýQñ]Þ~ÔñDÞn ¾X«°ø¿ ¹T›Ë½=ïuò|>hL¯ã||H¡™¨B"Þ;J>H.<kŠðÒyÆŠÄ몤Y|9«uå‡M_á²àéïNu©7”ô7-ñ‡þ?ÅÃ$?G° ñ«³2N°$¿:Á½ýâéfzÙ¹N‡„N_>IãÙã÷2Çߟ=úç£ÿúÆÏendstream endobj 4640 0 obj<>/XObject<<>>>>/Annots 596 0 R>>endobj 4641 0 obj<>stream xÕ\ÛŽ7}÷W4,à P[ÝìVKÞ±=6df=³›—¼´¥ž±ÝVÛùû=ua±¤ñØkÀŽ{vAN±È*‹Å"gÿû¨È†øo‘…ýoº|4̇øBÿ(è¯ÏéK6ª›¼Î–Y‘À"»zäà2 “¼Ñçà2«ÇypœƒËl4Î ÏUÔ_UsÍÄÉtc)Ë#Òc°£2Ÿ¨jZ³ØœXI¬rŰÌGÙÈH!¶Òhë0Øñ:5V:- ×)ƒÔ©r,‰†FzLÖdÚÄ: ¶iÈƆÁá„;­Ial…1)é‡Ì%¸Ì&%©ÉBˆs\ú!qÜ_=áþX‘› ó*Kœ´ËDK;©r£—ð ú!qByΓ"´‘i¡ ’PåDŠqB(\`’ÕFŠÐ‘L£e„*׌ó1ÌJ?$ÎA) 5’}£®dšØ±pCrûÈÅ‹'‘C쨆»:Öa°Z\Žux™•CZ‰õl(È´n¤ÇdÖ2±ƒåÂkë0X䘴ÔÖaò"žRcyZ°ûÚrá7R†¼¸¡D@-@ï“@Ëóx&•¡Ô¶’Ÿ‘<1Hì2uâØlšä±ySG}*ÏE5Žª+‚8@Q1R,NÓ;gÙ]B˜:ZÆ$D££S•Q,N;f,uK`S:ßéð‡è3€q Rg|¢Žw¦É ‹O  JLòÒ8 QWT3ÊAêŠ"»q<÷¼Ú9a ‰l›áˆIÛAÔ+ApPÉqÿ¼v5clþÃl{›=yˆGE•ëè0¡ð“rTe×3®/³ëéãëöÍ¢ËÖ7ÙÙzµïVûÝ×8q\‚fqXÓhp“ ¢´TnP²¾ž=.Kj¿˜=ή~{uN°ê› ßÚÕŒ3ÎG¥~zFž¼ UÂq¼­!¾‰9ÌÌBjýùþ¯M7}ÛMÿ¤¯È±‡•#–í†GŽ£w5’ïyoþŠ yP É÷½†£# ÏÖ³Ž? ÔA×dËùênºŸ¯WDp$ßÉQiTÀä/J›²œ{e›#e¯0›óvÁjù$Næ»v;'—äïUÞD;,ÛévÍS ¯«Oôa†C9¤±¨nê'·bmuIüã¦k÷‡­h…-HgK\6¯TÉ>¨ó¹1YëÞIÒìòRåýXÜórÛÞ.[ÑŽÒüõs²{Â›Š¥[«¼R‚¼ßb0{þaÚmh²Î8<4ã¡t(»/I³É+õÊ>›o”Ö[™ß&/†®ð¯¨îˆœ2)<&8…/öo»-/à:/ ź†Eé¶¶žxí=È #?R8/D=Õíùlþ³Ž÷hl'¦óª]v»M;åÈ…ÓYˆÆØ6›õvOBpšŠ{ôïéCuÛ_YÛ^¢aî÷éG8VéÚ¹gäßæs´GÑLüüçœÁ”Q_ÛýüìÅ“¼Ð„"Û¬çÈ‘Ø/pu̼)¯õ*˜›º\}rŸó²7…/6ݶŊæù§Üjý®Û.Öíl¾º%ªê_zJÞiRIðʧôõaµR-ìOâg,töFìÊ÷Ýn?Øæ{Ù®‘D«7üb©¦qð1›SLÂN7¨kIyÝï>´ËÍ¢“ † ¦WÞëLcJ·n νð %Nçoë-ŸpÔ³6çÜ™ž)è6•m¶ëÛm·¥Ôâ÷xHÄ|t³hW+‰‹¸o·Pp´„|¢aÑ øoûWµÌ“vB£«Yû’NzeÿÒ³ÙùZWÅH-û·©ó5: %ç£îl‰}+†† [Ÿ[*rïæÝ{R™³ø‡“­ª¦ƒÚëÇ{™ÓïžÐgÇtÄû¸~ÞÏ÷oÉ TΈ«Â|¡üöçü!Z`’ös¼V:IožÎfsJÎ弉ò‰)w¶^.±ìóG{kŠ˜â\¤|)N4ÑçÆó-ø¨£” “#—'i‹Í”íe‡ýæ Yš›Ñsø\_ꥷ‡’O\¨™øcu´ÅùöSòVwÛ¯œÄ ^f5”õ 3—²½iwó)û9êHÑ÷Ïžœýôœàº€­’½ß¶›MLPxèI™%”|DCÑ „É!4¶YZw×!.ÛéŸí­d6ÈÓcÎó+ò|VzW?£c›êËY^_ŽuŸÐ—ã}e£¸è¿Åý*2£š#ËÔç?¡#J·»}«µ[ÜÑô¹ôUäÛ ?‘ÇÙú]Ç}¾:,éŒK,8ÐöSϨ!_mx ËÙw5<[´»fâýžDrö¨&ßí©){¯« Ü£*ÇäÔq¿}µBÑeGÖjž ôâ4J.!Øú –e~\¾¿«æu‡³U‹ó$©Úû…)ZÞY˜y?}b1tÄ}®m)Þñªw»ŠMëÑ­ M+Â4~ÖÝ´‡…äP¸ã™ÁÝÙÞlçKd™R7Â9›îjÈ:xFf‰în(¯Ï Ëáï’……Ro¦øA‘_ÅüÝlðñ4²ÝÞ"&Ç}ïÕúy>ÎÈ“¸râ•%¤ÄåâV{|jHU†[9§S½¹+z‘†ÀÊ¹Š½BLÞj¿¸"pÀ¡ACöƒ+ „Ày¢+TéÀŒ-ˆW'½4‘¬ÿJŠÛZw·±çÎÑÛ³ÿtÛ]ÌJ°EÄeÿU2¯#DÕÇúNCþ^âó´9y {ê¨Q;<Ð=rÑ“[ª_Ë}tqJˆâÉvñûÈùð»/BàU8 ‡¯ÇŠó÷”݉QOûõàçt3G…ËxOùP bÚã¶Å;õñAùåúÍ›ù¾âû¬êÁxµé†¤ßÏìéC™ãÖ}»›®åmîWëxÀx±^XNŠ¿9øî¾zÿfu«zúdFo åÈÓÇ£Â=†À“vüä ÷źùǤñu·Á"ŽC\£"2cÇÅ»Y”¾&`sàjÑÒIy5…ëÊôÀ`¹~Ã?íæèûßEG{àO$ܲEµ†t¶ueƒîř螹MŸC ‡úX©ã ö¼Ý¾‰Õs÷æl½X¤WšR=˜¥¤™ü[Ôïø púðÉž±Ñ\Ò#ÛèÝ/å’Œ_à‘m|?qÚKpÔô$>¸Ü®§ÝLeú÷ijõ”Ëi=|TŒW)zCvt¨»ó"ÂÔ”¸‹CM|’ý±»Þ]·Ç ' 6x±ÕÇ¥‚Þá ²†B¢OÊÎ/..¯È‹Q“Œ?Œñá/SX½q£=.Töì±.¨¨ôÑ¥8…Ûc ×]±Žå¶”W»ÝAoÁúzk‚ …À+”ÿ€!ýƒÿö€…ÂÌ þ¯Kò!ýþp®Â~‰×-ô†a€0•=;]´¶)+¤^ µ=þ0§y~ýè_þíóKendstream endobj 4642 0 obj<>/XObject<<>>>>/Annots 650 0 R>>endobj 4643 0 obj<>stream xÕ\[{G}çWÌ#ûe¥h¦ç"=|d6¼›çÁÛÚè¶c ¿ϩªîªYØ‚-’|$GG}©KWWu·òÿGy6Áßyjúç|õh2žàú#§?~yAŸduÕŒ«l•å–Ù›G®²07ñ‹Ä9¸Êªé88ÎÁU6-Ç…çJ¯¬x

S^>ÍF™àqQ÷¹Jû©}×R;Dý¼:y˜&”lMooŠÉÞH:X%yÄ“þõ®ëß-º÷ô1nо%CÉ‹bT5N>Ÿ“‘ïç¾[.V‹uÛ/:^yˆÐ߆*^éÅÉ|¿ì×ë´Zëñ,}¬ñ‰Å©J›ä›Îò±U¾'óùb·Ø¬Û%9(¶©b÷éfµBÈ[.ÖáªÙ8o’Oo© [yÈC*ç‚4ïå¸~âè•>W1_t»]2#Šïî®X4TçMŠèýâòjÇMQvÏâ÷®ºvÞõü)´Z_ ö³p½Þœ@$W]pÑc©ó2V]À°ÛÌÊ[Y<‰ÉQNeÉæÖíjqNrãD?^mæ{Ùõ`üwǃ0yÐĦ;@/6»†ŠýŸë(2ŽWÔ²6{±+΄Ò>ïäCI—Ã= t×P¡¬É$#$iqùS÷Gg<8m]v×ì2'Soû ’¨•,éèwÍã+ó*fŠÙð:L‹Pœ¹¥xDŸ£†®è¥åpC™l‰§<ιôù`I„ñ$©ëýbwÅãM\`üî;ú«~v/š %‹<’ CïàÓ*~@2:OA HÒƒh…|ÒÙ¯‹õ|ó^l}_B|²³„’¥Íêsã‚„EÄIRܵ3OucÊ.úÍŠU•[ûïâz/›^„>éêÍn?_lø»¸‰C}òÜ¿ì‹IrœVˆÎ[¶ýh({ýêÉ?ž±Žp<åù² ýe­U²P8Éx‡v™äš<ê­´ïblÆBSûl.èKxM§Ñúm{-[Te›|ãé÷Oe‘¢~K»Ûû¾ÝnÓòÀ꽬ݻUJ.°FòÇV7Τ٠“H¯x×½þ;}X¦ZrÛžÿÖ^J‚âBS“#!î²[w}»ë¸†E†R2§åB\úì|Ù^_K·XMüøna¾ìIt8àwr\S Tñ|¿>×”“ø_6ø×lª 0ÂÝÒP.^ºe¿XnÞÆä–Á;TVtÂ!ñ¯DN/#aÝ%!q88ò0û\_ïÚxJómâMã ÓËgëýŠX*Œpv¿ÛÇg9p¨ØõFx\14V<Àp›Í“õfýaµÙ³ÿáºKsçó‡8<™ ' †ç¯~«£Ì¡%èä:û°í®Û ®}ì4±ðìõ¤L˜dÉò¡ÑØšN¸ŸûÍÖ*Ö”Í õ^\ôœH$ •=ѳ³CY™q²’!yp À~LKÙ],¼¨'cÙPŌ˟;9ß,VÛXw»ÊÍ„Â=I”ô³BÁ×ü² 7ñgPx57ØÏÞ,ppßs,A±w".x‹^B%x5”jX™¾Ùõûóݾ—ûÛØéD¬iʰÎL©õd\¦ät˜/V'5oØ1TRaâÌΧۜ†k.vDÈÅúªëÈ]Î9Üàí]ª7n ñÀ„JjŠ©XÎy¨^E¥…ÇE.]Sj™õÝE×w4Ö5 ·}ß~m(éÌìHÁ±E A˪µ¤{û?±"þ]»ÜKðÆï\îÇm’rðÕýQTʃÝݼÞ/ùXׄz,¾õÁ •I¬VØâ6|¨¥ÖÀ È¡x"\ªø÷7UË Nº¥DtÖ½ðåJ'!´JŠÃéaŽK®w‹¬óî¢Ý/wäx+£uoÛ_"‹OÅ ¬{:µV¨¥ ÁϤ†v•ÔïYqˆß]㤠nDH¨îg¡™O~Ê%ùp¦ê£r.ÙÞ-âí:¤E8ØôáD¥# „šÝr4¸Ã1äy·HøfÕöìªþæ"ÅnváòäR¿P³_”tçmesºC¿çû·p=KáNgçÝ®],Ù¤þxöÆQö‘¼?{Ð…8€yÿɧjªñžäÍGÎâU¥;Õæ¤yÕÍmÏÛ*ž¥Jç§×/©5~q¤·vœ¢q—ÈÛNãx8Ôì #üZÏ{ÈOƒØ,Mø ¥wN¶íÛËU+qïÅîµø u,ûøç³n}œu‘üXïî,MkÞäõéìd ¥Ò88ÉÀkÒO1ýŸPÀG­þ ÷¡ñóƒ%Ï!S—ü11q§ù;/vBqwç \h¤ xç|è*7-×—rh‰^#úµöPì4ÊQó}tÌ|aæd:·Œ ±üÄ¢yhRÊ6¼åÛO6CZËÏp7Ä|4@œÌÑ‘½+4’œÜŽAÈÖm·H¬÷¶Ð›v6®üåÞÄ$ÞçSЛ—eŸwŸt»àxÿJhbò…‡ÿC¡·¹c«ö£K·Ëü°Æ g*üà ûƒŸôÁøMþ 5~__J•8®Åû9zâ<ÂV–ý¸9çC1}dG¿bŸ ¶j;üûbAÒ?;{ôïG×3~Üendstream endobj 4644 0 obj<>/XObject<<>>>>/Annots 705 0 R>>endobj 4645 0 obj<>stream xÍ\Û’Ç‘}çWàÅZ;f„¾àö´!“”WŠ•¼»[Ï=˜N+p HýžÌ¬Ê< ôÚr8¶ƒæÁA]2++3+«Àß^£1þ[Œª©üo¹~1¾ãù£?þçoòÉh:™]NFëQ`5zó‚àzT-.gé‹Â\&óËŠ8‚ëÑ||9'®šÊxõDÇ›Tø?Ò'Áõh6—vúEábžÅì²&’1X|·d–ðzTŽË^[Æ`!ׂÚNj™n%óÄ”tJmJÓôM!eJƒL. b­Û² nD·‰+ŠZÔà$ct õ [g­Ûñ‚ºUÝ&®(Ç¢'£Ûj&ë,a‘e.–,a°óB”ï¬Ni²0ûRð)e®@“ù(HÆ"©L‰XÂ2h…)kƒÎÍÈlP1hâL'‹¤¢^b ›¤bmЙÊDA š¸4ˆ“ŒÑít Œ¦ŒÁ.&=Ö’!MÄ ‰[,DÎD§u ‹ ’±LhÚg Ëv’muOj3AÝÐdB×#˜t«_Ž †D/°'ƒ‰ Ö†„ʵ1ĉ[T0͉sÑé¤!d v®C:kj/ÙÀ„ÚWŒç²^N269kf!JÆ&'TämmЂ LA š¸b¬‚:ÉÝbµ¡¾` ƒÖb(Á–ÕV-9kS‡î' bJ‰+ÊR–ÛIÆt²€³$–°èA=C´%Œ)•bkÑ–1ØZ×Û2FL+JYgUœzNþÓ€‹“¹ §£ ‹†Ç}–°hxŒA©-aLx"¦¬w=#ã6 SR[ÏÜ Úéuº±×ÆpÁÄthíT¬£ž’i$®@ … Éݲ¤Ä It$–0ØEÌA{& Þ£-cÑŸ b ƒ]”.ôÌæ€”e–1ØI_^3]ƒ”Ô ¤¥ÆƒG#[ŒEµ¨Â›Z·5m©ZAt›¸BÃ~ŒÑm¥kîMƒ…V0h°„ÁŠ`¡Á»˜c+K†»bÖÄÑ=𵤠ÄI\Qê²:ÉXÄÑe –0XÄL,œ³6(20wKµ‚4q⎱3œdŒnKÕC°„eJR©-a°³±èÁÛڔƼ­Ä”W@õ¨v’1ºÕPM,a°߉% v®âDÏ„ÁÚ2KËZ¢(g˦“ü‹XÂ`gº£-a°Èh FgÕUˆÍÍ ˆ¢t“dN^p! Òfy´m(3¨šºApíg®(ä;A2F·ÙTÄ‹%¯™% 9ÑóœX5ˆjJ±Æ@L)qi Š„d,S*¡¾hʬæjÄÆ”JU‹÷̬úähk†£*ˆ 'ÎAå$cL n z–0ØJÎ;Äqäp¬M)&ÕçVq`_n 5# ’1XDsèЛ2Vö9³eJjÞ֦įJAh)qE)IZŒÑ­ú7b ƒÅ‚–¼cÆX8¤ä°RgË¢ËaXÂ`«¹lœhK,Žz f ƒ—²w¼­©B£Trý•‚PEâô0AQÄTÔä ‹"ä8¬ ©‡Ï<¤‚2q6†sÑ©Æ þ“‘4d v*á/X²ä®2s¶ÀA29%ÀK,¶Ë”YÂ2%É©-a°z8&–0 ÆRR[Ʋà5\Z´5aù`]úÙY÷ŸAdœ²G‚#ˆ ¡ø0#’±#8šÚzXF1IV©@ôK ±O¡'ƒEì€$Á‹ óuVƒP©3Ñê&¤@…Íg9¥JAtŠ´rFC|:ÛÔý„KP$‘T¨t’1XlIH,a°H… f ƒÕê µ%,¶ ôžƒ­å°mƒE2 õ¶¶l0b‰&‚X¶ÄÉ6€–œdŒ #¿*‚%,âLdÐ` Ë„+±gƒ…@œ` ƒ…‡…ƒ%,çÆ…,³&¬Ô³°~j7ÙW ÍAC'‹°º²Á‹Q`£Á‹4 ª–0ÄS†8Î2E©ï –°(J— XÂ`1N¯g¢( T1.šbE´|åµSTâ 䛨eN2UHA,a°¨÷¢¢-aLKE9Ël!…XÂ`«“¶„Áb¹  ïÙ„ÕâBÖ+ &lâ$À@'C8£KXT!GjK,#;1Xóz1.aVN0Ñ3c°Ø°Fo«Â©t¢£ðýž¹· 5&æÑ•°ˆ#±„Áª/%–°+çb ‹8rôÖ&œ +6a/žD·…”äLœÒÂ`u5ˆ%,S’Z±„Á.TØè™°˜“ìhËXôßoË,V’Ûš°©pcÒy݆  ëd>µ”39Ö.XÂh‹Ò,aQ…$äÄUHÂ@,aˆ7ÂmƒÅÛ2‹&ÏÊTgïIR[ZSE⊱Šã$cLÕj°„EÁ‰% **˜%Œ k]-Ú2‹B*,ÊÇe !{f,ªèkªÐ2”.×|bÂð‚Xw'‹*$E'–°¨BÕm ƒÅÅÚ9kSÒæœaU )Ç`"¡ $. 8½Òôv:T‹ÓÔþÝV‰A1¡9HϖĨi¤6rä[D#5ŒTES×î•®@2s‰ÑN”™ËpN;D‚å¡Cÿî)NbÄ9à Íó…€Ò¡Þl:DÁ¤sÍ„pC–9± ÁáZZnŒ1-U¢ì»TS9½6ƒiÚåApH¾qÃ"µjé 8”\5›·Çæm+}iо»Û®>¬·ûÝ]w¿ t^§&ÇûnóV>DH)féÛnß.Û½ g)y¯y.Ÿî?Õl&³‚ŽkÖÂe¡sÍZx½Á¢%Dà4ÏÑ©ÕâÉø´ª²ˆ‹EO²'á«´ò!VbžMf¹jîï[³o“|zÐ'þF5›ë2Îû2V=ÿþ®Ýßµn dœU6üS¦—‹l®ËíZ7¶|•­þzµmÚ!ªOo©h4K^”’gÓF¾¬{¿éÖ»•íXÚ–}Æ«ºdÀ£ö}ãßÇÆLªz`O÷q5[è:#ÆödU·Uæíú1îöXþ´Q-³t÷÷Çdä8é<£µÍÒž®í´·¶É»k÷·ÛýºÙ,uᑯst87Ù!#Æ&Å=Ý:žTÍǶ²zd;Vík›cb¡/_û~ÙîÝv£~ I†3·û­†"ìcßÛ}›‡f“¯;ŸÓ}â¢c›…àºÄzȱèúÝrÙÞç(Šsþ4ÑÝ~{@mխɳÜœÖíúºM±1ë…¦j®ŽùBžP°ÏÒ•&‘_n×ëíFÌBäʦ»<Þ¶ëî_¬¸8DxD¾m›Ãqo{IÞ4ié‰VòÁaª¹zcH,uíXd\ÖôvòËo_þå/ú‰œdláïÚ6²~Húö¸YºÉC=ųñZ—™IZ͘YÚ~ÒñR’ Œ’Âö=²âû´´pÒó¼î¿w‡;ý2v~ŽÉÒo›é£ õµw2$×Ht!5±þ:÷S‘×Ùc‰@rO•C×’Ï4# @öäö´Úù ÍŸ~Eîï~RH=æ‹è«š«ëº§Œ}ô3’ŸÚÃÝÖ–5{­FÝœ®óürœó±AùE¤µv²ÞÞt·]rv¨}Ož0_©æv‚(Q|`q5!%gvÕíÌÖÉ| ¾ünÓý–ÒÜÌžkÎ gWÍSÚÝ÷j8(èf£þa³;ô^èt>¥¬{{<ä/bí=À5{Yæ´ºØXž¸*wûnݺw–ëÂ1æ$o·ípàNzÍGœEØ··í¾EÚ¤+&ÉgÙ)Y]R&î™Êeß/çê½ù£²÷LBÛY̫斵öÎbxtÔ3‰_öÍn—3qü"'»—ò-Z´f¿o>ؾ¡|, %†Ôb_KaÕ"¥¶ÈÁ"â*­§‘l®·ÇÍåqxG‘×wtª’ïB%ØhOèéÎVzàƒj¡[ÿÂ^)²´ý#Ú_»M³ÿ  @àÊ[ñ¦9h ®Ôŧ«×“¹¸2zsØÃrÌ(pÕŸŒb`2_ã£j¡{ à‚2ÔÞbK)bßùQ>-g4›öwù&k`ÀAÝ´+xDí’Ú¶Ú”Ìjµ]6öMI‡SJ9t,Ú?¨–ìÒlr†òEtš•†×û´CÔPšááî]7Y‘—ψ•U-,=ž°;€Åëræ˜ùª½mŽ+š¸6tÿø`tE¤¥òíňՂLEÞ§.¯’²Ôv!ž‹öGç…æS *6NÙº7ÛÍEOOz7b‡)éÆ<Çç ê$â'þZ-Òáï<8ü㺨§7Ýûƒ¹FìØìo·G”\ãu§öGž,ýøÏŸL<í¾V¼{P ®}ZÁ&Ð…¿Ü¥B+-j§bAøœÎi  ä1È¿‹*‘±=?OP-ì\dIXú~h¼"—†üßÍzÀÒÓ‘õ1¢ÙøP!ìžRðóxñ‹Í[&›ãƒKüh¢Z¤ãÔI=?'ëm’‡f •¨:È2š†ëã!U…àpžS-laÙ²ý|‹­BõðѺçý®]vÍJå¥rè»fßÉ%£.š¼~^Ž §t¸—!áî»·¾ÿ‡]p½=/ &Í9T®´á=bºËíz×­¼°ˆùóÑvýG:¨Ç)yî]Õ¡ØÓÌåÝW%‡hVõ&!ÿÈDžæ;õ8¥Êgá P ©òõöC÷jÿ·ÝR7@d·'‚OžC?p“Y^à½.e¸&'îà³&«—¯òýÔk»Ó¥Dl{fG²–zlÞ¯â8ÃÁcµl_Q«phBƒ×›Ó‡L»Ý×~¸Ìžõ ~Oꆨ*%ñ,©Û BÔ¬ºå¢Þ‹|áä8kF~9y¢Ý®šÿ€«ò 0ÜU¯ž »ðCdÞêÉTyHý Ñè'X/­ê=—¨Íêð{òÏFê±ÕåL„>̬ÒËûÿçægÁ|ÿ`ýB¾‰ ¹Tô Ž¨´dY§™æ®ÙºåqÕ¨ýÊa$'éâyd|Zóu#mŽÇÿµ6‡Ò:å)WO_xY„úÂ!—×âah­š¢úEΔUΨîvž0.ïL ¨WøÅãŸÿ¬:ÀË¢Ïo1Óa]äðybMêz}ƒ½~¿ÃËÊ!S9]ç!mm¯ÅekÖV¾ž8×Ëg÷.?¸Àù›Íþíq_}éKã/$¯ ÝN¸¡èï2ͨ]/ÿÈ—Ëȼ½ÖƱ”Ýçï[\¼ê}¬´Ïå¬Sy¿´›¶ºÐ r!ÿt̉óÕxå:øî&Š.y/ ÙÁÍö÷Ͳ¹·×{|J;WL<‹ÓD¯0ü²kXg¢suºpx_2w© ;â½êÛ…:åë¤Ñ•FU6û¹QûÛ±YÙ´qy“ug÷sêB¡ç::ܙߤk™!­÷_£ÍÒ¦^óÏøi]¤05>Q”&殨n;½Î¤|®wgC GN½Î"ùñÃÇøuso•`:ª¢Ô #ñ*/\v”ÅïFûö”Òùlˆ8G÷¡îi’ªÔT(59·úâs9ÈgÉOŸwHÞk‰o–ý§/d?¨T¡À-<§•¸ ŒxˆT¨ÿý®5—Ju s)~ÉËüå“[K¤‡8ȵ?û®ªË¦ñ£€“ eµ­À÷*ÝèpB¼nö÷wÍ*Ÿpè׃×äÿŠ÷]Žàî×Spj²Cìþ~‹zTzŠFOÔÎ pH_—öÔ¥ô /ýȰÔÞÈýþg÷.í¼Œ÷SæÐc’¡h“ËfU3uô#Ë£ºªËTP†p=ƒÑÍEjøûÍfJ=Ö¯ÝØ×ðÏäsÀ£æ÷e×¥åþÑ¿RKÍGGY×W[«ÑAF‚+eáãgv‹~™…ÿÆö]Ú]™gß§G€V–‡¯ÙãëS—ÛÆþân Îļ"}¯a ¿ópïÉéÖÓñoyÉ2â/'Õ*{ë;xhùîÊðFØeA¾. 圚Oë?þüƒ~D¸ÿª/£¿pUèS[$ëA~ßßâ'Gþÿ:{ê}ìh¹ÅC¦½½Æm€¿©ðw0ó()|Í«ôºJwýB޽ÕÕ^ß¾ÍGy › +ŸZŽGñI&ý½Xü¡?õ’_xÊϱð*ŒågcøÕe 3ÅO¡ä—]òï˜À‰iáÀ/'*TÍç8g]̤íÍ7ﻮ弾zñß/þöÿ9endstream endobj 4646 0 obj<>/XObject<<>>>>/Annots 757 0 R>>endobj 4647 0 obj<>stream xÕ[ÛrÇ}×Wì£\.€ØÝÙð¨Ð¤ÂX))&\΃_@”aã $ÿ}NwO_EÛ’‰ ¤¢xpv.}™îžÙÁž•ÅË¢néßlýlÐàúQÒ^Ò'EÛ ûM±.J«âúY€ë¢÷‡ùAâ\ͨ_.Àu1ôG«[/5<l2 >\õ㉠ó¬4#yÚUd`à2dN&m\€*ƒq"CnWÐHb0!j‚ áp]Œ›~ ·kÆ¢ì†`í”+Ñ]É­5#ÑÚpl€5ãš)›þ8?Éâ 6y?<&Ã!M ç~x·™ËÝ1º…"Û¢q6`°MK‚:0Øñ*r¶á)µbK™ŸRæJx'$52bšÒ°ÃŠæS°XÀµÀ†ÈÜxLíœãé 3ןNæ²FŒŒÓIÃ~Y4ÎL:¨IÆ+2p%Ö.‰ÔLjFM¡Vtl¬¨¯ŒeàóÍ\Y%ò0##F·°QX™Ñ@WψQ˜‘²Õfo,7M#ѼL^75MÛÂY& ƒò˜0ʉ²ŒÂ´äž ,¦6ŠlÀë¢JÔämÙR›Ã©YM‰´r¼òG~”ø‰¼Ò¸(™£•é0âN¹a ë!1ð†™+5Læ¤Ì´ ŸøL3W–kÉ#–Që |ÄÌIJFF ½ÖV’³bLR[I‰w›¹rP‘¹ŒŒݦ–ôc,w[cY·¬[åÊ’tè¤4ÅÖ ¼aærC##&1i¥xSéæóaàÝf®,GÈaµ‘£[¸X‡ ì¢|h0|$²”ëœq9¥  ˜3¼sœµ§CçÄl8“ƒEÖ„$–«Ù/ëZ Æn.€¦ ‡nà\€ÔiKCr/,GÀ`á#±© ™s¹Œa©<@¤kZBµqÊ£@ÒƒméÜšFL¡zÅYq’\?p’«­~¥(ídÄ`G”70Å„¬c´ÊÅ"À¥Ìå)1E)†)90X,T(ÉÙ€ÁŽÉ-0-\ZÆÎÊ„så'JcàÎ\ž ‘cК'ìlÀ`Û‰ãlÀ˜‡UgeJ¹¦”)Y½ ºEí=1X¤U êlÀ`áæ0œ±âÙ\ªg3 =°¢)î’ŸµÀ ‰Ü¹QT4žõ &#^ddÄ`Qñ´¡iÄ`‘RÆíå XÔe%n€4(%XÒ™,QnË_þÝü 3t`2¦ò&4Êå-÷nÅ­# 5 e I7„»dzˆE¯•µÜ¡–¼< £dRÊÁÃÇ…s1–6ŽX(~±`¼=ÖXÏ{QDåÍqæ°À°Å5Î!ºäååœCx6j9l~µË–Ëg–ÆJYGè°¤JÍ(n”‹\~ÌJUGh„܃ùŽY¸„ÔG»³efpB‘Á2㈺ã¡Ôß&á¸YfPìÞg—p;²ÝäNˆÈ\C³˜„.&s>“ÙóÉôfµ(¶·ÅùvsXlûo&¿†îøô»#g¤ÎzÚ[çpÚ8™?¯jOÌŸ×?]½¤hšuþlº™ó3£~[åþ1}7¥ÏÎ.&¤oÊÑ †¨¤×~Ys?TœI×ÚcWÃüÙŇéúnµà™#ˆéý“ý“êÈí:…<»"Û<¯ZÖÔghs?Û-ïÔ€mÖÙɪA'–êRÔanÐÍÚ>“|Å^¿[ìÞ-ï© §§"%I›%í5Q¾Š­MQHä{³[¬–ëåfº[ŠO#Æ< !M¼̇ÈGV*Þ÷›Író–­×öÇú±Å @§*­Ê7wäcþ•|“Å^bkU÷[z]CRƒ"ôf¯ŠT³|=¼SèH-‘YÍ÷ýfû~Ã6-]–«ýþ^\ÇM+êª?¥ÿUF$YÏ>8y:Z™WÈowÓÃrË¢"Æ>¾y>V©fiz+âBgmžïΧ:åf;_ôå‹C©î{ñÃÚ`5‘®æÔyN%ÅdpXˆ*Ââ¸Zv²ÛÞ£úÙÿ²ÝªÔØúœ’MSÈ@=œÝwd醜‹õÍb>_p+XaôÓâæ·%—´ßË•ØÑùgvªâaÓÞYwýœ4‚­^_ÿ›]5ûÞgøÅ›©D¼)Õ:‘±Í‚D/'ß? ‰¸¸ï i»%âxbiïBÇ‹»»ÕrÆ1“£céïýòð «Åü(ç? 5½÷æ¸Í b³å· j¹âW².3¯ÅP‰ÆÇ“«Dy“Ñ«c\IGéàzIû*¶ÐøkÛÀŒñ)¿¤Z¤jb©‚M>‹ Qÿ|5ݳ+b·õ•ëSd ϦzHô:Û"Ùrû¶áŠlµÆÞêoœR. …_S=٢ɚcGÜÞïfìˆxÁféí¡‚-{šÉÍ…T‡t¼åᙺë˜*O‘“Ì:=äê­ÇIú,î#°ÇÝ,ƒ¹Žˆëåá°ØÑg(INß;aC•Œo3Eãq6°ü%ó sÕ¨; Ó4yiJl¥óF9ƘˆÇvu¥»íé9ÞŇÙâŽ6EUñNÞ6³KÞ'áò¥w:¿“SªóíŽWoƒ=×#l Sbû]Ú\UÓY»žÁqÄýÔÍóíz÷†aüj¹¿ãU=œxùJ¾À)4œÉŽ(¨Wàm7‰Š «6Å[^ÒµÝà8YUA/7õXU«HUv“§ñ[V@Þ.G¹9V¹ð^½|+'!!Œ_ÞofzlPúƒìð(ìn§³ÅÏÏÏ//¯~þ†ÔˆW¦° Ìô½²“§†º³8ðb>_’0ÓÍ–6œZ¼“N$HèÒ.õþµGìóˆÏ Ì÷!ܱóÍÄ|¹Ø,è°GŽC(¬©“©Ht:ÊÓ x³ÜÌñ(‡@’“8 áÐ.¥#½îxóQbþ„ ‡¸·[NíxEVª‡Ÿû-« ´Ÿå:‡î#~õr&5üîo±b1FNÞÍçW›ýb§Æ§%«³¿Çç$foBªDx[WëZXnq+–û[q©|Rƒ‡uuÜ.óû+ÑêãÏ}j¸%+n:xÅ:âµú‰o_Ýó+x³'óºØU”šãZ5¹íq5î(x=á«dql¹´^Á•­#ñþúÅjsúî”%Å-• éGé™ ¤Ü±}(v­\†@° õ(îŒRÃÑ UY,SI\XMþÇ: “‡“‡ùï›éz9£OqwÐa½ßˉ66!õ£¿K~Ò¼:'±»ÅèûlLúúƒšýwŠ’|¸:d <È÷¸N­Î}ôjsõÝ¿¯ïã*ó‰˜YRÇöîh{KáhÉd¿™îÅàØ–Yµ~~¦ú¾ïwÓ»;]øÖW߃)%CÓMg«†oÜE¿²KíFns’çÁQDì(¾פzFÂ’ñeä—Ìäê.Þú(f½\mo䨄îCêyÁ;\—jÇÇÌ@ÑXÇ¿§öƒ}rÊn„ÂíQœuç룔zu§ñ@ÊYlî×,6} ôÄDSËeU¯P‡ÕÏïFÃû{ùÌ"陟ћÇÅþlØÝÏ÷;1>©W+ÿÿŽU¼jà›`2f÷ ÿ͇‹¸æiìîþ\©­)ôš®T¼;°Úảõ§`dKË×â£3ònÀÓ ØÄÓ¸<À¦ÓNøö4M”o®û¾tŽïk Üt"MØGÃ~ÂbÁÝIº/ÚC¢/¾ÛÎî;¯½ë¾Y‚ÃFÜXáòaùŽº¿˜<û׳ÿ&Ì®åendstream endobj 4648 0 obj<>/XObject<<>>>>/Annots 810 0 R>>endobj 4649 0 obj<>stream xÕ\YsÇ~ׯØW”rawg<¥lÙr©*²‘.=¯À%³uø×çëczzAF‡c“+Ç¥èÇ9ú˜žžžÿó Ïø_ž•5ý»Ú>XÌø„þÈé—?Ñ'Y]5ó*Ûfy›ìäƒÛ¬\Îý"qn³ª—Žsp›5í<÷\ ñBÅã5KÔ§ƒÛl¹œý"qbž¡‘wZ–®S©Såò¼ž·Ym¤Çè¶.æKÏ: vYÒ ©­ÃÛ¬€²<ë1ز! Y[™p‘ó„[ž=š°ƒd‘@Ýé1Ø*³Ó„sR½µ•AK7(ƒ4¨r:ˆ‘£ÛæEVËÝVKñ ž¼ë6rù¢EÃDzLÝ’38Öa°õ t¬ÃPï‚ÌšX™R+N&Sb¦¤\ÎV«Œô˜-hÐÄ: ¶)æµg¦)‘/¥¶“?´XM‰• 7âÀ2aiÂʉ)*#=&V4ac¥ÛÚ¹YÅ u«œvc¤Çè¶\zë0i©†›%V…õ(¢ˆ, Ò Êé FzŒnÙ—+c¥[¬£Ô-ƒÔ­ryYã;•‘0 üªgÈÙmQKI”†LÊßeÖa°-É”Xé8£iGŒ\Ç‘E¸„•¦ 1Œ6eäšF±ó7Ò-²ÀSAà¥ÁPK@¸˜ã(Ê„FôÇ‘Vµsb.J,ÓDz 6§5áX‡‰¥eêÙ„ÁÖ šϧËSªÝ^¤))—/*ĹDzŒn±`ÂÖ”=%°.°ýPTºU./XRFDzLÝ.àש©Ç$ ™%±2h‹Ê  Ò Êé Fzlƒ&V&¡m)ˆÔY0Öc•À¦1V<¥…(®Á€¦ä iC‚ç &T4ˆc‰9sïF ’œÊ©\Fz,r 9#Ë>ïX‡Á¶lk+S‚‹PdÕ3HSRŽ|ƒé±L©õ,¦1M‰ò‘Ô–•[" AY›L¹‘Ëó€%‘HÑ-bMáY‡iJ´Ø][‡Á"¸"¯ã9ð°´œÊÖ¹ ÓCäHn4äoé1ºE–<ë0XÈŠ §¶Û”+SÔ9Xokˆ+±“›á¤ +—ç$T"=¦)±àü]Ça°ˆµ”Ó(Ì: –“¸ÄŠY5³2 –òÆ«9#Dä¥l$qb@ˆÝ[CÁbŽX‡Á"ÿ€þ¬­Èésé’AÒŸr9644Òct‹ˆ“&Öa”[Ç: é=,“Ú: Úõì0âUAù`j+âpŽ¬ë¸´„™—µ@t‹¥O7Òc°%»Cb‹àqŒ•A5—Q,av­K#=Ëþ•X:Hšó1J; çø•8õT•8>U¥> è=‘ì·…fµì¨Ìo#·¤Ôq¤«B“K–W€¹Päò‚BQ"e@Me@Ë„f°gåY‘HQS@Ñr<ѰX@á…‘ƒ-Éië0XÄnˆ™Ú: ¶©°ÊË>@G4‹C’bj)S²ÔR§Y™BbÆ Èg1hbÛÖ$¬±¢^MZEŸ–•:ˆ†HhK,%ÚýØØ¬^M;EŸ)ë¤\¨PNöcA©¡&ÒÐrN1bA±®0Òc„vÇ:Œ%• %X[SòjÝEð„ho»mâÄè¥Ôoš$¹ÏtÇ’D.DZCX>ê1ÉI’8Öa°-¤Ä²å>—¹,LÕ ^DƒQ1©rYÇ: õ!uÁ ÖVeЈIÛ³8‚Hªíð9ïÝÎK(î›Ç H³UNRƒDʈœ*Æ-o”•#±–¼Ÿù9g‹ -“†ÊQ0ÇTÑ ŽÅ¡ì_;eQf„s‹IµãPLŠ*Ç ÂL­¡Çä”d9Öa°uµeõpB¦BòßM«ÊÐÖ2£¸‘¦H¬ KŸÂP¼ÿÅjÑôˆµb NB›bŽ1´ñÄŒÀþN“ãJÞ‚l?OH÷#cx;н!¼âØÍÂsã6¦ÆÑ)ynÊ,e#VS&D¢6ÐmÑ‚øH®b‡<”îÞܹíÏ i²f çjÚ†"xƒ°¤³øþÔUH¡¢E6\džÀ=¨~wzŽõ‰|§¬²¦)êžq5u‘®žv¯7}¶?Ïïw‡~w¸úû鯮;.¸rwˆ9hpžÍbo3š ´§g‹–ZÇ7Îf'¯žþD`U5¥~ÖíÎø;í¼.ô£]wôÑ£'ˆÒ5bt… és^ιߢÒ¿ý–»… âGëÝ›~XºÝª'ŠŽJÍ'öO¨kšá Þ=–qÉ2E^ì×°Ãpõú;kÓªðCÞ=äŠ$ÔÛns­£ÈUÅ®¢Ê±I‡h…aè>°‰éò{ÐT¨ÖBÎ1Á›:_°Äчn±õþm?löÝYÏž,£s_ïV‡õ~Ç’aõÃØï×LV¬÷±Éóü“²^öCwØ"–ï=Øê³´j^£³v9Z¸y1–pÓ]‰Û…yÞ¨3öïp®`6ú*Õ-¢9ß­oè3˜"úø7üm¶<ÔYܳCÜQ~|dÚr$ø/WëÝË‚to©‚³ëßí_ÿگĠ säÞ>ÁÎfrý¦ï®8¸amµv±í·ûá……¬Ëû³ öç|ÉІ±ÝÏé#«øÐo/7Ý¡Ÿ¾g7ìÃ7<»ú”„'Ûn`Ëâôi6q#;SCþ9Öøÿ{ *¬©Fq™·­ò#ýñýª¿´ð;Ù-84¼4g¨l-YÞ’LŸ»muÙa£%[ñŸÀfr»‰CÃÞ8«)µY çv5ªðô‘àm/»Ãúõz³>pä@Rºˆ±øçýc BnÐ0|ûˆwöih$_Âm÷±d²·$ÉØb$-jsSÝ'çó(–þ‘¥dËHò<=NjÅ‚w¦úÏ( CwgÞó8üó1XœîôÃe¿í.y)…{Þ´?C,û îûÈ¡f\QHæBöÂ~×Ô«7Dzqk^³°HBãÚâSŽK¢“ROTµžÆz3ÑÉS5IçR“—žWžÇnMnT:±8î¼è5…®ûIü54’·Çpxä¿ÎÈŸ:[Ý}FöQ­††O™³ãíïtþ¨¸—rPéÿS7¸é 1ÇÉp{ç~Z>Q¢LF!ŠwL¢^¡~ I:*4µÎ3ó~Œ‡/1‘û¨šï‘ŒÒ6ã ŸeàûkúžS˪ãsÞž•ñ öšŠYÂr: lUO·³âŠz$9¥þÆQ VnbA5¨Ùcþ’¡Õ¿{ñT•Qܹ×~Ò…B«GOœShæ\ÉYïñõÕa¿]ÿŽ„OÎ׸ÅQM6åý9‹çNÜ0ÿÀZpŸ}¿Þa]ˆÊt/ûäìþê/$é}½o¹xöÑ€ÿcIß&åþ¸9J•±.¹bÝQ‡¸ ‹ë>{7t—(ʈ:Z«@þÕßèß4P50ööïÎÈv,ݹŠÝ;|HþÐmˆÀÛHh%6wk`µ?³¥®_»1•»ü ´, *.s{ÎSœÛÿкõFlä\Y–®“¢À‡7,^¹˜ÕoÑÁkY¬EºÖX"c*9JÓôègiš.dÇ*ÛÅfÿZ<¯¥¢bκ§«HëSB»Ó²Ü#&¹·(p»?»Þôs&óîÒG0–é>EÇæh/øåª¢¤ØÛ10Þ’Õ=ƒG莄 ¯ˆÓ9Å„¶$mCα°ü©™ÿY*ºCȶÛuý7>ÔE…ç¦ÓÙÐÉgBËyÚ£'éÞ©n³$¥û&Îf¿ô¾é9h7cí øÝÇõÇ[ ¡åíÝ]”á7º±TɆ. >ÇMÉÛuÿŽ×"Ð'¹>¢•u†}7®_Èw´¿?ÛÖo-µAÅqâF¡øt‹w4g6\Áj%• ¦’s}ÄZB…V‹%¾²Š«æ#«=¥‹ÍóXXEåc3®›×œ“»Êfýz膵ÞàT3¡¢I?çygÞ£]ç‹ä¿yÕ=VîÆ'âô¡•J ýÆ%Ž³Î»_à*k½]ïÌŒxB2>ááQÂ*m³x¿väÝT^_oô€&Vÿ¹!`É"H¤›‡w^À‰:V ,ˆ³ÍzÇy4ž™[µóyº *‘UÜ£…£Œ9ž½xÇ<®QòD¥˜ ú ®§'– LŠ_ÌЖ1½ªÀÛÿ#}º»¼–>.å¿%éÝ_ì‹ÐÝ´2øçˆÄKŸ'à7~¤K}O®±kì.Ò“™xíšý¸»ÞÒ z4ÂOmP‰o,²“^”„ÚWsß§¾°”*&¢«KˆŽËÔÏù5Áç{Tü ò½(X5NŽ+ÒO·—ûAÌjÌW"™TènHÆ'sÎ׿.,E¬Q…™b NœXxð¶Àïž&ïŠ&×x—8¾&x¶¤ ænÞà­/:d~K5_v3™½¥XrÑïä/Ù ^/„¥ÖÛ>î_'<é»Ãõ YùÔsÚ8¢XÕXªñ¶ñbè.¶DÓÉŸ-½TG‰Îñ¥ÀK\Å¿‰\_ÍáÒÉçŠAxy”NªA%ï_\ úýdõ°G/»Õo=WÁ ¾zºA8,K ® „_)Åœo‹@,Îx à*;|úVB™ûôê0\¯l-#ÝÏ´IÿùG5€¶—›×®;gž¬mÿqw^ý{¿-ÅÚöD»e*+?çOðKüVŸËã' zÕŸ>ãùÕEéŽsVâ?ìWÈow(]ëõ_‰ÿŒ~lžÍzjöðý[ò¥OüûÁf+¡endstream endobj 4650 0 obj<>/XObject<<>>>>/Annots 863 0 R>>endobj 4651 0 obj<>stream xÕ\Ùr[Ç}×WÜ—T)qÝÀ}thI媸ä˜tåA 60 ¨%_ŸÓÝ3Ýç‚ #U²]²féezzzþדª(ñwU4ùg±~RŽK|"TòÇ//å“bÒMÇ]±.ª×Åù‚ë¢éÇÓôEᮋn6nˆ#ˆ>Ûr@6°ítÀ®Á¿ H§×Ŭ÷ÄD§]5ž©ó®+BA‘8›µs³Ι©¯‹‰s&CÙ“ B†ÄUø74d á»Þ´=íHC‚°ê ½}S¥ ,:~tL…3Ó©õ£ ºM\U·˜Oç$ct }`zÁ;)Ç-±: ® TA š8ˆ[sÑi­C:ÉX†“FSR?ÌC*ˆ!W•ÌÕIÆ2èæ$–0XX~J¬ Úš±MN1hâªFgë$ct;­dÐ` ƒÍ†,áuQ£gnË,´ä=3;­Å¨Îªïv¹ .8"Aè·OŠàbº•¬¿ ‹ÕSt é–±ˆ:×vÖô[³ó*ý&ÎÇ9‚è´™‰Ád vZÊÎÚ»®‚2q¶~» U—e4­è]‘ŠY–é˜Á 'ÃŒ‚% v"ñ†XÂ`{•ÕÛª4-B”/D.MæªR<›H‘¦æØ/³7Ò8ÛtÄÎÒ«Òx[Ì~Æm Ã?ˉLJg!ã2Ïoà…Áª3·s–Jnˆ¦œÙ¶‘Ž)KXT\JÇÁ–IM,c™”ªÊÛÚ¤tñ c›”"šTfÕ Ú` £m[‹¦‚%,SV=:kö쌭"6³èÒK#ªÁôÁÛ«ƒ%,šR=:ËX45Á²Œžƒ4XÄ;kEÑ3a°}%B,a$+Øq™e ¶¶µ„(Ñ£ü6q}/Ò8GjBŒ†0NšuªÁâRDÖÉ,veH,atÜÕ²ô‚% VC±„Åvê©Ñ–°X§»;kSÆÖi¹ 6UDSÎ,¦iƒ%Œa±ÛTÌ‹ Æñ¶:l¯Ša Ű΢£RQù®²„E2eb CZxjO¬ ;ãåÓ(¢a3‹Íª,ˆ%Œa±» Åö¶êN ìàîd@úUwÊ\U‰Ýƒd,JœÂîÁÚ|=SWQÑ|3«9w,atŒ¥‚޵ŽSFná«QDg;;t,atŒ¤¥e–° +»µ% ëÔSÑ…÷l“Bô'§PD“ʬI,a ;ÑŽƒ%,N!yv㬠›²þ¤ Oû£cD&H,a°ÓN\&XÂ>¬³6¬Ô¶~hHÃf¶U5KX¤•DÂ]Z „eØ!ËØ&¿ð¶¢›ŒÁ¶²OKlßaƒ!–0.–·Uqk$pa\CaÜ`eé1Xl æ#–0Ø™ˆ¬ ›BºO×qØ!Œ¦H0,±ÁªÛKX† Ö†M‡!3fÖY†ØÀèûã ½G?Âb>Ù‰ƒÕ0TóaÉ€èXÃPæ*äÅP¢–ä0]kz.zp`¶q˜*öEáô0Û!lR'Â\})êñü_$µææ8„‹l´]@™‹¦ƒ´†)S·†ž¨ÔÛ¢vãgˆN«™Œè¤iMsëtĬ=Ñ6­%N–?:ÉÝÂHÄYí¶âÝ€©ÝfÎNäA2F·z$–0؉"‰%lþ1%Ö¦”²›ƒ'áÑ-â@ ‰d¹Ê|ƒÕÃ3±„ÁÂòÔ۪ͪ”¡«‘ ¸±3׆(žbDeHŸÁ„­kÏÛÄdPDa’1XÄŽ 5e ¡ 'Ö´§$?©„AWUè-Hk¨Î“*ˆ†‰«jÙkÍ­T=Ro‘úˆ§¢aâì˜$cSÒŠ`m>šæùDB(Å™*qi>N2F·XϘm°„ÁNT ÎÚ šæA„,‰“”³uR¦TQÔSÁ@ ~U8EP&*B\' ~pÁañNƒÓ‰¤ôP‡öô/¼Qús&ºÃöI”vÇ)£þ·«#1Ú3rwNYï©U5›@ÎéP)QÔ¹F"hµ8u0íÜ™@ Cq"GíNÓ6,LqQýo™y 4Bé9¿-„"(s—qƒ ÓÆáÇÛ”€6ApN'’RBÚ“º@2‘zwŠ LDž¼½j‡š¢%É<]Óc=8Eât­N6 •: H&VqîoT›Ç¦[»7ųXR²\/®àبTËa³zÒ—ZÇ/‹‹ÅÓ‹ùëëe±½*ζ›ýr³¿ýóÅoÔ–úµ;"4¸*F¹·‚ÌW—O›RZÇ7.Ÿçÿüñ¥|€ 2mÒgóÍ¥~g6žÔ食þ}¾x»\/Ÿý2_ü¾Ü ýìv ëSUµ 0n´¹¸Ž òüÃ~¹Û̯åcl Í,}~¹]Ü­!È|¿Ún„”êLr|Rµ}k2‡j‘ BæZLô´©TâÏTê«Å|­:ò'IW'%õÓiûÎôá>ÐÕîÕØÔðóny½Z¯6óÝj©^‹E÷mœu-‹gÖÙ¿¹ÛlV›7¢¸wŸ?öµ…ìþT¥mû‰L{4ëòÕò¡Ëw¶]߬®“„ˆžuŸðþíR¾ˆÝ{š#Åb{iŸ¡ò¾ö°}u&‹‹ø=W#–Ë{‘Äš¹Ý Yª7¤Ø&ù×ÛË»kŸvr ‹`ðÕ…zpÀVò²Ÿ±<Ç*‰Ëûëm²-’ú&Ûöãön§^€Í-ï y§)Œ?8ü×'Ú~ªÞ|h^ V.®¹³o:(´fÓ7»-öصÆ(9éf¯Î["Vw¶ýb°(šq9INñ~µ›Wçîì»ït¡|­E‘away]ךŸÛÎ|ÄÓ¯·ïG×ËwKÝ™Pc«§I.Ý®ž‰¸†›$o/VÈEvWó…-”ÃÒ÷¿¾õ‡#fØý,©à xQÁ›åf¹›ï—šáœÖdÿãRí¤ü¿ígæúzeq‡±üùæÎÜ;ñ¡ÖNe¹½„2+êÕFJ2!˜.;Šaû79²!–çºÒ\5/_ž‘‰¡ŽñøþÛö½Ù²å] I¶Ê—Ó‹ïw»ùGTߌ)M¬S6÷Ly¾Zߤm›O¸0¦%5ê£9úl¯D'°¥ïQ¯·w›K[º’ŒåÖóО…<ÆÒu«bòìÊ(‰ äʲA]/?觸bËÑçÈ&t·!qQk8&.Êz‘}>,®º1‰{4ý˜Û"¥dkûú·åBž¨"g¥œH¼êJ=Vúa”BuøÀ´Ï?ÌÝ·)½ß^ÏoôËdÅ«­¦`ȯ«¼æòþÊÝf‘Ïx­áË`?ÿ=‡¾8‡]]oç¦AZ0‘ã;G¼ [¼|¯š/žãfÍÕZ;äu¡ª‹¤Í2(2²7g×óÛ[ H¿Oöˆ¥.šÅD¡œ3ñz ÓªÕåŽÞ6²ó‹¿Ë'4‡©âß\÷§mÎÐXêv¿ËVÇ1-gŸìtx—ùÅmø)‹ÏœDª‘\jà^ü{ÀÖª(,Ä¡\¹¬ô)³ù~§+UžQ¥·M¶œBß眬—:pKñè‡k—³¾oÑðwQ}y{› _>®üOvѪa6Ì·2篷ó7zŠçM†c,^K>rÔq1õjg(æaÌ9Û-Q㉲l> \ò²•§fWK/ÍÚH2ÒÇ_ÔHŸÑYWª8£êˆ …h¹°äQ§ŽŸ xªx${̲ßþU–8ž‡æd"«1Hõrö©íÝÞ¸ÙxvÈÍwo@KŸ¸1lS¹ð3ĽÿÕ¬€z6<-áö^£SÊ–òälU¢.åS㔺=¡k¥,˜\Ž!<[8&ZR,Þ5Ÿ¸l.ٽěã1ÉÈk&~V°áPãì:pÇ®Ô7’Ûö¡ÁÔý„òüÃby#G1[ˆòe,ƒÎN$¹ž½ˆ;M}ž•ï4u£üÜ‹âW‹ýü•‚ñ8ãÄ504FWª=é^[o)ó&qć©xþíÞj&QG¸ßñÌÞQøï·šÝéÛ7KЧ$©™ÒW.Nak¦G¸âT×ÅkÚ$Y±-W|'´¢»2ÝuUqu‹>/XObject<<>>>>/Annots 917 0 R>>endobj 4653 0 obj<>stream xÕ\É’7½ë+ê(ÛAšµ€ËÑ–%…#F#Ô_|)‘ÕjÚ܆ÍÖò÷~™ $^QÔx¹IÙV»_½Â’‰D"‘@é¿Êb„Ë¢ËóõƒÑp„'ò£”/ŸÊ“b&ÃP¬‹2ƒUñêÁuQφ“ø¢p×E˜k⮋Ùh8e®‘öš íM3: ¢/U- ê›ÚÂ`ÃXªÍ,a°ÓÉpÌ,áuQfh=—e ¶V%xÍŒÁ†¦×+@ˆS×$Ž‚,NäÊr*´‚UIä‚‘+«ÑpVŒd I'Èâ¬U«® Ó§‚\mäÊQ#cæ$cT[«zÕjÃ̬D«5àÕ&®,eÔ2ÉXF­Á¸dV4&¦<56R+Áh{™SÛKåÔØ2G ¨¥9m@ê„Phol:Ò¬áÂfð!ÎÊ5b5°u-§ —‹\ …ÕEȤXG¨Mm“™)HŠ)¥Sö¦ŒÁVãaÅ,a°;•% v"#I,a°³q¯]çÊf§õPAîpäÊJÌ'8ÉÕÖ¥t8³„Áާ}–°ÌΑX—µ.Á¬DùÖ%¹K‘+K•ÅIÆhîÎ,aéÒHF<³„ÁÎ*LAb £Ã(a½,c°c™ ™5qFfƒ&Ž‚,Näb÷dìâdÖÄIeae2Keše v:ƒÉe ËèLEQΪ8 ^ñÑ1àâ$®ÉœÊ$cg„Kl¨`ᙵF'4­¹Ñȉ†"“ŒEb¥Ä=ˆ•KzP‹Î,c°¡ß.c°“ ž —5qÆ4éYœÈÙ$Ë$ct¸–¡!–0XØá”YÂ2¬“.—Uר«‹Ï€tIŸ&n†0¢ÈA4 oˆaÓ÷¥ c°X±¹(c°Óþ…ÊFw«JÌÅk6 64©Yƒ‘+Ë€™œIÆh´M,a°…^YÂè,tÉ›e cý:k®xÚ(ÈŽ\œ&N2F—*òÌ;§Ö8kƒZÚ´±QT5r˜7ç¢R¬T°#'ƒÅÒ‡asÖä„qe÷  Ë9‹j'µ`=#¯oÀ &®„Cš 8•7…d,ý™ ?™µjaKÞŸZA®6rÖŸLZÁ1 X­ Œ\YʘI+ãku¼µ‚\0ÅÞjÓ™´‚1P¶‚“D°2Ã(×΄ü|hÇI«4†¤V‹G¤S¥ÎY¥±\¬ÔIÆ¢ò±4™YÂæh¦ÄZ‡b¨k=ðX–`êsÖ¡XNš„ œdŒMǘ™™µ&5´Eíq®5¹hNjÁŠƒ`2”'®Ôžd’1ú£~™XÂ`±t‹Ì꤭¦6ƒtÒF BYò3GÊkzA4¨v— 2‹Ø,PµÖ²[û^D“cÃ9‚¢í“V)Çå•‚,cäÊ‘øýL2FµM3 –°HRÁ.‰%,v)$³6Ö1¬W«¨<ª'ˆ-†¸ŸÌD“ðƒ3"ƒESf ƒÅRZkâ­D¥ÀýˆA„Ž y'ƒmjÑ‘³Vm êM0¼ ¢`)ž½r’1X81Hê¬U«!qœc›‡¶j#'îb:ÉXz«Õ:k†ƒ\3·‰êFËTëATZK¬“Ií«D½¾&pÍ&N¶aAãã¸Ô–jE³¹(cSPÉ,–0Ø©T–0X¤Pz5V–8*KXÂ’ BšÌ2«±AfM1xÖqwDÃfꪛIÆ`1NSõdVÔªA¬U« k8ræ(%ÐJ–•Ú0ªÅ G$EƒE˜’ÞU–°èA=×l]RŠZ*È]Šœ¸C4ê$céR賄Á"ÿ€aÍe ‹ò+8g­K1P5-y¼HÕb>@'ƒ­µÚÌ;‘ –Ê‹•Ö’ËF‡á#!޳ŒÁ§pÍ&ŽXÒ°G¢&NäJDÎ0o'£Kê2«.@©ÌVÕ8‚Ú$ºã‘(šL•¢ÉŠHë+‡©g³Ý§0+,ÛI-ÈQªÇ¡*bd$÷WNDWàJâ2'1".CpXQ©Níǵý°6Eµêm2g›8T ç´BŽwûánŠv!‹(¾Sç\†è!–_â´BHà^V÷ùÛß8EP*OçœV¨‘m´/rU÷‘1§í”Šq¬¾æqjFhI³[N‡ìãl9Cpº©Î\†2{dAwΖ2Ûˆ g‰ØC~W+v„(J¶×Îd$ÝÐõ."ù„IÎeN£.羿¢#¤cGÅþMñíLÑõÕ5|ºS#Å ý —U\-ôø`T\Í^µ¯W]±½.m7‡ns¸ýêêWªNO´:øe¸.©¶ò;œH\-Ö•”7‹W?ÿøTÀLêø¬Ý,ôép\ÅGÏç‡öm'O¿}çaµcçÐFeÕá­jy£Nuÿ°ÜwóÃv¯ý”$²H£¿<œ·«ÕróF_¯‡£ðQ38˜¦Æ¯÷Ûµ¼ -Κøæ£o¾ÑGðe©ð|»è~ùJŸ¢Ê(Ìð>þ efålÖ×G#]W7û®]˜6¢÷Ñ»¿ÙF(Ç*Œ°7Æ*ªËô¬[o÷TÌqu»ißtkب0˜£±ÛßìËç-–$CLÝMvÑ^]ýKz©SM£ÕÝÞívÛ½ % Éh Ÿ·wŸ§¶PNtôtéŸ>w!Ÿµ‡ýò½Ê‰ šfÜáî[·»4q“üŸ§kŸ©–(á·O²· u1¨Äg>¬ÕýU/÷¢Û¯Ô¼±£[ùL½ýç« åT†‘ýóÄ;YH ÏÌ?Ûíß.»wò¾ùK’6”3éõ °|¶¬I¼cò½Øw«åz¹i÷ËNí¡È—!¤‹—/N¼l«$ÞÓîpH h•+7ºF#'êSy¿|s£ «g=‹Ê¹Á:ÔíE‰X÷ËTçõreª’³ó X ’"l ”œ˜èBÛuñh»Þ-S8гJb¶"!-K‹›v½œ«ÉÓãõvq·RÅÉÞí>‡“^!‹-ù[š‹ýýÝrµH6ÃOÑÕß‘:™À»åáFÍ‚½gíoüQ{AN`z_ ÕHú‚à5¯Ó2úUýe5ÜÚƒ=ÎnÇIYð‚·ËíFM‚ÂËíµ<Á¶5 [ÈڠϦÃrrÖ`&© ÍžuØÊ•Fò§ÛhÈšù¼?áÈøGþâI»<ÛÃPéâ5ÐË<4^sC07€A¶áDÔéSb·ßbë´NñŒ;Ç´Ó!g0ï9l$bäZœšq‰È_×VI¡RÏ7¨ôî«B£º#UD`x½ÕYŒ¢Lr›Á륭d)»U{À˦²f4Ÿ9€•ÎúA©É,¹ÅyyÙÿ”S¤éësÿñ{ì¢eö«]àPËçÉÝ&-XMâl/~^nÛwɆÎügUôׇã¹¼¼ÛlÒòOŽÁwüÓ¼ï>µÃþ¡{Û­¶»èöa0^Áán±ÜŠ/¬‚ŒŽôŸµû^í.ÿ”ýíRêåIÿ·…Ô €%À“6ã±Hy …Ïlê=a‡C\Í’Ž h&w¯³Âù«ùÑ ®¶ï+D)Ž)솼DöhÝÎ-äÁimÜÞ5|n˜GÎ'ÏwØao˜ŸÜmæâñm K îÜðÿ£™$Õ¸?y›#ó}ºÚ¾nuä$3—öåo±›‘$ ™*þ/säÜf‘Aå ÃÞà!‰¨,&2õœãâ/æÄޝ’¾Øê³Qº€ÔÚk¨L®À6ö˽ÑzuØßÍw{³¾/c¸, öÑ\; Oä’Wíí­ Š;^á²½J¨4ó3ÀžåQHø?…DºÝ—‡A±äó›nþ[ (p„‚Õ÷¬³5T–*õò' ®Úð0èÄIÁ»¾Õ)=ç@à7KG×¼œ ÀáÆY…L3×…Õ¶,¬*Á…}Žx­MG._Ä­mÿÑ-õyÎSkŽÆ1mö™s*ýòÈ';ëãP[|Ü; ÇÕ#g„Ý(âÂtª†ËO)•t| rrò¶û}«÷ $µ‡¼8hšLn¿¥ÇuÍoZËÈÒõ˜¯¿óC©Ùy¶÷I_øØ•&8îÔõ&øË{A=8ég(Vwqßt¹é ±ÆPÛöá#£è»1“2­Îù¤õmërRÊíTµÝ¿¹“›06Spáóþ3¦>û’Ð¥^ðÏž Ÿ5õÆö»ù¼»MHˆ¾RlyÒÈoS^@ªÀ­T¬øºg*ÖÝúuJ«Âžmí1Ê£M6ö=©¯`Ï)aN'è2Ýå=œòxl¶ï®»}·–„†BšàÈüؤ§ü‘¼DÍŽóC8r>CÂ941 ÿÈþû¹‘˜Ê°õô’^޵g´i7”úQQ¶wú´Æ½Øoß›ó¦C y/t©"IõÒƒÞÙ0LOг'îÆ\FšãHƒI¤ ‡›¸ÛÉ““j©Ø]V¼ÌJX-M'þïöØ…%ox†9y,}üøþ î€÷dþúWܳÕG$øówˆs³Ü /kϯ;–NqhtáÐÅÙzˆ,{òý»»=XªŽÓ”&µú_¹‹yûˆd¾¶Æg‘¼#DÐÝò¤ êŸnᣥ‹õ³&ãÑy¾êÉøãǯKœøØÑ#¯—X†Ævºúm-Ã~nýÙv±¼þ‚D\HÁÀ‰û6¸Š—dæRÚùº›m¼~ ©ŒÐÄ0¾¨`£µ¤,>¤J[£ï~-?lñPRwv~‰ÏRÒÛ§")¹µ¯F‚»V—”ðˆ*Ðo4òý¼B¾H’Ï+$/Ÿjào;jpD‹kÇr·b€ý_ñÃv®A¿ßFªñ÷ÿŒ°&RvñðýÛåRÄ~|õà?~“0FÖendstream endobj 4654 0 obj<>/XObject<<>>>>/Annots 969 0 R>>endobj 4655 0 obj<>stream xÝ[É’ÛȽë+p”cLˆX ®ZÇÅ´ÕmûL‘P7g¸´¹Hê¿÷Ë¥²Ã#ÙM¶<Í<>Ô’YYY¯пŸÙÿYÕÐÿg«gã|Œ_è‚þøðŽ~ÉšÐæ![eEËìú™ƒ«¬êòV$ÎÁU&yå8WÙ¤ÊÇU WÔ§ƒÜnâ8t!æY–yíHÁâÙÒ±¡¦!«Š‡œ$@C:(Ýb®ü$Ûa"ÛŒó±ÒmY¸n¤n•+ŠŽæn¤Çè6p·ÆJ·ãÎuË u«\QÉ FzŒnë–Ö$±ƒmë!ëð*+18ÐÚò”B'1Â`SŠ\Q¶pQ"=&6è6±ÒíDBAºeºU®(, FzL––°Å±Ó âÖ±ƒð”¬g™RëB%0HSR®('d‹‘´qB-‹ÆÛFµsPwQâxÅv¼mç vÃ!”8ÞE¡’ 4]4žƒ0pLA’HÁb¡á:ê0¹®%×+ÎÁZPªh;²˜µt ‹†fd¤Ç4(Ï7±ƒ ´Y\[‡™0S²¶2¥BÖKæÀ MI¹bÌ!d¤Ç4%ƒÄ: ¶¥4Œçeã‹·$ç+×rŒçà*ë:Ú)Æ9ˆ1üg$[YO$ºØJfeäŠrœwY"¥a+a" ¤†Êã üZé1æÃXé¶qP3HÝ*§ó1R²Ë4‚j©¡rEEÞM¤4¬ÅåbƒÔP¹¢ ÄVé19–›c¦už`M+ƒ–Þí Ò ÊÑñƒ†FzLƒÒVq¬Ã`ßµg‹EǺXψDtUÄÓº&'1¢9ã„iXŽ…Ä:LlEÃ:6a°-I‰•a±…D$ð0ŒÜ°‘EÚBÓÄ:L‡!ë0;”«S[¶êdw‹u‚Ò°ÆÂEhz–Y‡1,Ÿ<Žu˜’J ¯&V†H°é°ŒÜ°‘•aë° ›XVÛ–ØsPfÆr¸U 74*‡|ä+`*?HœƒÁU9Òcr?¥ÏÔÔc°“yαÃKˆßÖc°¶@jË9²RYÉ›ZMØAd ò¡ bBÏÚ‘“1”^SSñŸ*Kqƒä?卨i¤Çè6Pˆ&VºUõ(Ýš@tf[“)Fz á[c¥[V}š +i¶Ê‰ØI¤ÇÔ-‰Ç: A2`ƚᘆmX™’ªK1Í$ ƒè–ó]e¤Ç4(%ÙÄr·¥ªGîG€Y9:-ê,‘£[èʳƒEši=ë0Xl²Ò±2%U—2%“€¢!2) UÊ“&¤Ù’çK#I–^ °>ŒšÁ ~8õ–•8Xˆ´O >hG·¬’•ÚQR@}:ˆybÑËP㕬¯4,¤ÅR®(¤F"=F·5]³+~S-&Ž29å ”vK#=˺̱Ó ´¯ë0ضÁöt¬Ã`;’\‰• GGxirL&¬œÉDzl¶¦j@l+Aj,'M:òé˜åe`«9Î|‰sCò±’HÁÖ %±lgá¢[ïȉ†O¤4ô°0™ÇH. ’HiÈÖi„ ҈ʉM¤Çd¥ƒÄJ·^!&e>Q!Ê|ŒÔùE;³M¬Ã'"*'‰u˜ò)‰•)AØ}©`,U®¨è‚‘HÉÒnÈ: ¶£S0µ•AY×E÷šÈ?(GÂ4Òc´¦A¥üeB,þ7ÂÙKÎV&ÁÒÔe g.mÓÈùÆðP}ÄaÔ%1e:ºËÃmT6qSF Á Nt‰¢ü¤ò„Ý’_lUas’3Jrœ¶’gû]whò"!šMÝ(ÁÁaMâ¸Ã¡ì€,v”)Æt@™ªpÖÏw“Ä ‚ƒo|»Áu¤þSŸ "ƹ$fOÒ‹lu”0jFI¤E®"]dÜËW¢Dгímöâ-¶$m÷›OØ‚¨V¨b€²©³›9—3ÇÙÍìùÍôã²Ï6Ÿ²W›õ¾_ïw¹ùÝuÇOî.`!¨³Qìm„¤Ð¢Bz3^UÔ <ž˜?Ï®ÿõ·wô¶j[éoÓõœŸ™äM©?]õÛe _¼­cçp&:*Jé6/ î¨Ä2J߯¶›Ïgj9Ñ—ÓõíazÛÓ³FПï7ˇÕf{·Ø­ˆB12žŸû¡niJ°´˜›³ÁUtå›5Ög±¾–Qqš\<_lûÙ~³eW ªNˆs›åÆõD,×C K6&ZøZ-áC>‰Ñ1[Nw»^–—>]j×ÿ%ü'ª‹lcwd"ï[Äß¾¬ûíînqOÏ"£T1nã¦hrt »ùø;–„N³_çýn¿=Ìö‹ÍZû(µÁã{!ÚL‚áVÍkšœ™ýæë¬¿·)Wù8îáÃz»Yº¨®•x|[N˜ ‰öÉ(ç|eþö¹ßÞõSÎl8U«‹xb]g›9§'dm[þËÍT–ºÈ'º³OÏèñ~5Û¹š8°½¬îÍÃ}¿šÞó­ÏŒßå˜8©¾x›Î0#l!:»8høìúõмA—ú Þ?÷HœÝ© ášvr-GËXÉIïzä¯é^!$°.žêWê¼i‰ ìÍWȈ•FF^êÃ>±ÇyBÍ?ÚݰZì.c–zyX,çñè…¶Gï”Þåflâ9‰(Þ.¹÷ÑDÔšÇÊS£„ÀçÒˆDî`½s³ü;5GPÙw-õÙMôf›¹Õ0¼ÙXÞ/§»ÅŒws·Q~œ0w¼ý4Å•¾ä¬mç_ÌâuŽtņƇèßí§ªúùŠÎ;Þ{ñ²þ;Ú5Ðd×0‚ß-7§K6w¸¦ÿœn´S93áæï—ebI#'*ÉBÞ»¶GßÖ,%ËRðâW޵Ó蛕ccÍ.’T”Q5… ·,± …QŸQq_쳫 ' ©°2´%¼æ«Êa«8áÂÜW¿üžÂkŒ˜”†7¿ ·ù3oÒØH¨†fhº^ØS…"žx/§×òÑzs¿Ý|} Sq5"öÕ§!H-¢;6“* ­qeø¸ {¨P‹¦d'ÖöµÞZõiTŸ»s¥©hb7ˆ\I«ÎÆë=”®È·Qß÷«ý–—ÏI¼ã¥:ó=(-¹p±qh'§ÙÿÑÎãÃ&Šý3íI33 ÓG±¥¡ îj;½]MwåuÄ7$ñ΂5ßî\žÁµ×$¾;ìç›/R…Af‹¥Æx½§Ïõ¾}QâMº?X-8‘û³ÔMsÈ#©¹ ¡êHÙ>áÂ)Ll¤Õ¥Ú0^<iÜ']8%ù*2™Uu¤r®Êi2š¾÷ìV)Zîz²¥S2‘Uè%1^©±Ð‹Zâ'¬:ãQ9®ïP"?¡â)ŇɨîÔáiû~±›õK¼ˆë7¾æ„Ë{#åŠäëÁ¨ÉÇz0‡é׃pYçs.Íûñ‡†Õ¡¯—–•ñ®™6®ÓWÛ~¹X-Ö(§È¯´Ÿ†ÑjèÈ G˜w$>ÖëX÷E7&,{«ïY.ÕÚhŸ;Tɾ£âX¿µ|wØßI»èvq{·ç¤íD1½ï’›^ïÇ—Ù§…–Õ |Sxæ[Åt„|Yù‚s™´é²îJÝ›_õðCóÙj3?h¿¸¤’LÜì¡‘B¾+u;—ÞíÜ“¥îW/b¦Ãw\òÊçýôþ>î|Er9%¨h/ÿ;¢Òi‹[ûц~Ïkǧ>|ºÔ½ë,‹v T"Ù5ÜÈÇ×ò‹·ÌìòêˆìnÊÓÕûσêýEÕEÝÒQê‘øMP Ýǯ^ìœ9Quèׇ½íåK—w÷x Ï®ë³VJC£Òp¼¸CÝÿÖ'V'8ýqÙŠ R:[ðAêà†óß*‰’ŒpV껩ÇÿwŒ¦&z\W¦‘ÙÐÖÈû;ù~ ²#*‡ï˜Ê<¾í8Ì’7®}óD¦ÛíçEÿ…o/>3;‡FŠÈ¡µØÆ7±?Ñ@ÍK[æ)†'}ò¨»}CåpRöλýa¿XJnB6»¬·T.DóÐJ/"Ò<–¿êIZâÛžT§_Ý/⧇µ+àÕ3XOWòšÑ>Ät×ú‹WgzçZ©?Á¤ejŒÓ'Ìÿ#~àsÁ'­·Êµ§?ø{ô‰~2ÞBûÓ·íøk%5NS|ÑGõ–6{½™A7­é…žž;økC\ÞG-Î.<ùõób± ÌöææÙߟý¡è-endstream endobj 4656 0 obj<>/XObject<<>>>>/Annots 1024 0 R>>endobj 4657 0 obj<>stream xÍ[ɒǽó+ÚGЖõ¾œE*a…ds:÷=œV Ñqè¯÷Ë̪¬, 8ÖE$©‡‡Zr©Ì¬¿¾Ê’ÿfIQÓ«éUºLñ ý‘Ñÿù–>IêªYVÉ”dl’÷¯ œ’¢[6î‹Ä8%U», gà”tÙ²´\Iã•×t ¨Oi.5äoÊd›×ËܲƒÅ 0Ym[ñ Eaeu\VdøN­¤Åè¶ÌIÎÀ ¶Î—­e ž’<%‡¶2¥œ†›œA˜’ã²¼¤A•´ƒ-i)°Ó”JšR` ¦)U¤%eeJig¦Ä LÉqYV“,JZLZjhJ5lWР5SÊØ#”µlÕ‘8Ê5ܧêÄw+²®š°Ôg œSÒfè3pÂwsÌ5pBŒ´H‹I Õ²¶¬Á`ÛjÙ–5_áCuªyω¦) ãØƒÐÐqYžÒˆJJÃÚ¸_Å 4t\–ÒR ¤Å$fç ¬t[ª„nçæ£¤Åè¶hh¶5lMîX_ Úcu\–ÑRª””†¹U;ƒÐÐqYž/³¤RRfVí BCÇu–B¥œ#§ˆHé4µ&a:uœô¢œdšFT’;-[cÚ©çȳÚ$“Ês݃Å.-k0­é4b- k¦­L¸c¶·K4a1hZR·JZ ¶¢´cXƒiÂìX´GQ„AçQÒbt[–ˆ3¥²Ò-G"Ä–…AèÖq®%-&YJ8J©¬t[Š£H· B·ŽsÝ(i1Ͷ"Í++ÝÂ)iI· B·ŽsÝ(i1º-Rr¤À kšWVͬ¹„AçQÒb’¥¤nk0؆êà D>±m9«”ȤVºš’Ð$3C"Ô Sî…Z ÕJmYƒI˜Œ¦ÚLÂP,2¬Á`»³q ¦ÅFNÚ²ö ¬VœhÆ\“xNб@ZŒA J…•n‘IC· B·ŽË²z(”´˜ºí"‚¦(cÅAÉþ•C¬`ƒÑ†¢ª—¾Ë£rS­r¹)#ÓÔ³(êÐq` FÇm@hXƒÁB•6´5˜­ÚZL¶¡UÚŠ¹„ubÁ (ÑqTx`JJZŒ)±+ݺrWl¬õ¬hˆeÑ&…’ƒEU±ƒ…ÇF¬Á`ªELÏ“–2ÑÀòr,¸HuËQ闣簨1¦V³bHD†ÒÓ„ZR›ŠŽ¸Ìôª×šStä8êþ«¤Å趪È”ånsW®r?Ô¢ž£`Ñ&´ÝÂÒ™a¥[[<æ B·ŽËP¿”I -¦niscXƒÁÂ"Ö`Ø ÅCnÚÊ”lYškå)‚kYJÁ,Rh ¦AÉ+ÝÚ¢5‹Vhˆj’*i1X.9 k0XÞ;Ö`°ˆU˜’ö,SrE­ˆ¦U«4%ÚƒäJJC.EQ%ä¢m‚ÒlYóJòzÈ]aÊ @€®Ï!ö`@­Y $!iÒb’6V•¹Úr7×’V„tm:x%šÅ$ Õ¦†5lC•A`ePWòÊ(ZÕˆ†% nPƒÁš~xJƒE=„¶S(b·V–›f¶˜ +ÍsYJº¤ÅÅ Î_¸ž’Á`±G/,k°DÇÖ°2%W.³Z2­ˆ D·¼… ¤Å`±³®aïƒEO4°cJ\Ì–4s3;¨Õ@x}A½jµl vÞ)’aà ÄtÌÜ)«“»vK‰Ò¿YJÑ0¥r#ƒÅÙCÄ ;݈5,Ê,˜T‡³ ëiD)ÑNÉq’Ui1 ZÒ ÚTºe}{Iµ’k;.Ë)£ÑÓ­ ƒÑ-<à ¶nHm+ƒriíÕ:[u…§Z7¨Á$ m)C +Fä"×åuj/œ¸‰ã0á #M#˜©fùÿu :FVœRb&¨: é‚—_€ÄQ´ í$ÅS*Çzq…,ëAËØ€Ðé¿¥C&¯…à*êP9îË5§gþ•Ì12C¥ ¤éÜD9îЕµ<'-L¢’¯(e 8$±y›®•#%kOW’²ý´ ëšÖ¼2ÑP´‰PŠç—©n ž»ch#…bݯvÑ!¦].@p¼i í$¹È= qä†SH¡™t¥œ#É”cá\IËâhéãšZ)Áa'‡Ä¥n 8ÎÔ† P°äq §}«IÖg ¸6j÷õ¹e૆ý‡äËwˆ d»(±]V!l^—ÉÝšo$Òänõú®¿ß Éü¼™·Ça{<üíîÓ_Zpwü–:[øÞ¨ù\rÜ­_5µo¬_'ïþî[ú­)ÜgývÍßi—uî>úñÓñqÞÒ§_¾C ’Þ‘‹+Œ‘K·Kl ¹§Êµùé0n?ð'õ²è܇ŸæÓž?ÃAˆoš×§Í@ŸÂRM+ß\ÞÎ?U“ÓäØVGâ²&s/î›yÚ›þ8Šž*¨ƒn˜HÉóµÇQŸŠüæ‹/œJß~x‚MhÍfÅ£qͯ¥ˆ‹Ø¨‡c;7mEžñ=‡41eaêÅž¯LzÁxónåâЧAîÝi»¢'+•âÂK¦r‘¬\ìÏ*×·›ù¾ß° OÿÖïGʹގ7˜›Øm¼¸¹‰…ä…¬B¢l8{W7`ßÔùè~½ì|°¶' Ç9ê—+'¢ó¥Q5œ€r¸a ?Î#ꤽXÏ vÞ×Máªáü²¨ºÈUã:ãýqZO{ñJÞþÞüìhe-øjښ묎x^­6ýá ‚b“^Ýv´©Z΋ÆV‰ØÒE‰Ág:œÁúÕ7n‡ýˆ…¹â—Ô>3Þ”sb2U+…ð³8ÃöÕ8ã×Ý?HrÔE>l&ûáaØóÀIêªýä·~sr£fò–N.D¦~¿ï?ñšÆñmv—ðZ ãî8Üf)Kì÷Vl=ÿ6ì7s¿x‡t~ô`3+N°­ºe]µœ'QïœçÏŒ½xIÖݰﳋ¿7¼|«V ^™6:eìì/I¸í§á°ëáÏd÷òFEÄ‹(šÞ[ˆH<¶ìK⇉vf®ü¹Qé(Fz Ï Èf}IÂ÷S¿?’rpT¦G>|ñZÆó•7£çI jÝ„¯r"‹²_’W0ˆã-¿ÝZÍ'”J”pÕ®Ûõùþ—a%çLt@tÕˆTµ®êÖ3HÍ&6ÛÒw§ýé”åC…ëËÙõpìÇd »Aå#-œqû\Œ¶ÔGº±½¼™çÊ„¾Šc?…ËÍÄzWÈN´¼¢â˜ »ò„½¬?îç§Oü‰q~Sq!g7VùÛµàÅ<ËÂxeIIg4ÇÅȆƳžhÞ}Ú¹Â/½nïÌÑKZµ²%@2N³VI¿Ásÿ5N¨!ÃÞáúªËÕ ÿíÅi³3q$×q~pů¤v‰“W®†_@IÆÅ[0_@.ôUÔMþ¨ñt¥\…SW¬îé/ì¸'»Æ‰RÕq…¸À¥q$?§b­Ÿ¿¦yÏ+U——©ßö† çþ$Ž—ÓÛJLU'Û<ȉdã­²]ަ¹,Z_Í_*û90¹³Cce¯èRöê*©:¶å‚^*ØÍ§f“§Þì烤#ùzÞôÛ'Ù9½÷äݼùØ=އ‰(\µú0¯®« •8·vÇÖŒšO6o·8Hóç¹&¯Ç=* ¿I@(¾Æ²üz«:v⸂†Ý" ¿q’°ñtüÁ¸õÐv™Ýjª©:Ù%D54ìÉøÃÇ-ÎÓÇ}ŠÝ«Fß ût©¹¹‰bëáÀçWî– }Àm®¶ÑõBÓcºhµ.ã¨õöi5ìüÍn{ýMrÚîçñëëT|/ùoÕ¹íÞkÅ"²½50ÿ€“‰Ç¡—s äU uÁ²«yÍ! ¥¯:À=N581áC$÷«Y4V~DˆÊé\øøL•ŠÁ©ßq@.¯èñì?ƒ¼Pؼ…’ïC¢•úýxX $”a>±X8S¾£<Ë „'gF"¶Í˜ó4ÉÕ:NÇô­Âêt8ÎÓøßpïn’ËÃÐëA9ÕþW¯Dt•—qlˆ7ž‘ ß\¸}6¨Œùkxµí·ïÏofb;ÚÉ&ã2VÚ8~µÖ«ô° èñ!Å]¹›ã_È>àr©‘éÞx±Ï^O iÆF¦+þûstõ-¥y7òq<>ò—ÓP5þ•¿-g7H§W?7®S·@r·ç!‘äŸMªÈ9šSéy˜ü3²ÛÌŒúê:‡TuÊμÈ:Â8$›v7JŠÁk,­ù/ä×ã°zÜŽ¿â>„ͳ¨[-Ïê”ýyqv ӜŲﶻ“ÔˆÃ.:]ÚæÍ§£ÿ"výºê÷8j÷w¹xctÛ/:^~š¼Õœí Þ8E—-y ´³wÓx=r#©éYn®Ó Û¼UŒVòOÛ{œûK-³;C_öqí«pwwµ¥úLDÿA^>XGž¤Å¼ÛÈ¢ªÔ7gAËï|ç7ó·J™6Æi9EÛHe â«g”߯¼:•‚ŸŸE„ZΙðçG·Y1w#G[ã¬=51[×£èäŸô1úÏÝÍíïŸÜýM/|v¶ÕÃöHú˵“OrÎõë§ËʪS)&»¸´ÀO˜# Ý~Ž-…\ëÃÏù{®Û3!åSy,“ñ/«¬ ÇQè§Ãðpò/Ö|úH.›öf_í©°ø--YÏÃѹ=ß>õ”[ÅeñtüæVdpâZÞ†œ—I7‘ãâ‰ÎaŽ.¿àgT¾ø½lØÍxࢊî+ýC’ãL=â±y(1éÈV=ï ñûÿÆ<ùûß¹Õ_tÖò¢'çñÚÆï "½}Ú¡fö2·;çñú²Ê.KâæVÔfŠÎé´9޾tÃ8þ ªß8Ñ5Œ¸îaþà‹¶Z¢ð¯EÂüCüD{#üЃ~nTãW#øµI‰›küè€~رÀIeòͼâéê IA¿ÜÄA墡Æë×Oã)øíÝ«¿úã’téendstream endobj 4658 0 obj<>/XObject<<>>>>/Annots 1077 0 R>>endobj 4659 0 obj<>stream xÕ\ÛŽÇ}×W ášûp#Y ؉¢ÝÄ/„—»bLÎм8Þ¿Ï©ªîªŠ–²/KnÈ:<œîºuuuMÓ¿=Ë’ÿdIQÓÿçëgé4Å'ôGF¼KŸ$uÕL«ddVÉÕ3×IÑN›ðEâ\'ÕlZ8ÎÁuÒfÓÒs%ÍWV<_Ó* 1$Y*z¿)Â[ÖÓܳƒ­jŒïžuì,Ÿ¶žuxäy3ªb‹Â ÌÀ\–5Ó:©•ô˜ž‘:Æ: ¶)§3Ï: ¶eíY‡!0æÍܳƒ-M~YÔÉ3§S'pA|%=†HuJá`¬Ã¤NJ6Öa°³”6Öaœ²ý•ÓÖ ÌÀ\†p……•ô“– ‰¤lQÃËU+q€­`ă) +ß$Òc°gæX–¶šIxÏÈôèIñ G‹‘ƒÅ‚,Ü£2l#A(ã0°a—Õ-l[)Ùä$B-îÎX{A¢ YUÙ¶€Kë0EY>beàRÜfäެ d¬Ã:°²2pKÈÈ YÈX‡u`eeà\\$fäެ d¬Ã:°²2p&Î 3rGV2Öa Œdo)+^OÅyâu4®ƒ¤‹:©”äà.gânô ƒë_)ãÄ 9…’‘,MÙˆcxz*M䲌’™‘˰µg1MÄ`‘GJÏ: ¶­„6²ˆT»ÕV20‘—å9M¢¤Ç›Ùˆu,û×=ë0|†m VÒ‘E¤Ê­Ô’‰¸,§=ÊHÉ9yFõ˜ì@1áX‡!6 ØPŸ‘JF%)pA%=Ƥ¼cÙ£“H”•„o©®˜c@“:CP9 Á𜌩œƒ˜°@“”JŠ–Èª4¡„'Ó2pä{xLI1lÍz(+ÃÂÉ6,6p$‚HI1lE{ž±Üßoënâãì2‹sîž2æ³ðÍíbØò”Ø—Šøi·½;¬£îHòQÂé#ÿ¯Îrx’!ïŒPŽŒðS·Ù3 ÑÕÔŸ'³›=q¶š•Ñ8‡ÍjÁ¦!•£É–}0ÎlšÖá›»u·ZñD8(4áÃn»íîåq$Ž`ÙG³K±ûsí((ªÿÇ»Åo‡E?åËbšªI>‹‹W4ŽR'µ=šÒGÕ{’UÇQÁ«.Kãݧ.¶¤ Êõô'¬¼UŒÔI!ZŽ&9;¬3öéDZŸ–²”]cAH”?ÌwûmPû½úfÑaq‹·Qư>»f'¨3vÝ„wM¯ë4c÷ÅDúÓpsX-ø£ÂÖù·Š¬ 6͉‰ÎöQÔ0ãÃÉHEÎqETñ/·â¶_žÓötûæ—oIã˜ÀΦÂxâ¨P[»D„"m@ö/ '4ú«(4Íc¬~“-Qü5!ÿŽç{,Tg 7ɰ“ø=‡UW=PµìI¨Æû 7&àµüI¨ÆÛÅCU+.GµÙŸ$ïUMóeP}¬ü±×\­F… ™Äá‰lx,õEeyU§h|:äTˆSZL…§+ÒwÝü×î.lÔ¨_ÛK­QÕ¦iz´S_-öûXdùâûïÞ8í6ŸŸz|•¾›ðVBͬ³oèuÖÊ2ä‹ÛÀÑrd)cÈþíãnXöR¥¸ÓH<ðáTw½íbÕí—¿ËWñÖ@#ëͰ•“'l‚ö¼Ú›êþÐVñx­¾îo‡í<¢NÎ[¤²ãè’Õ$ãá`¬GŽ®ý~9ßAÆ>‡óqF¼Ý©,{Iôõ¬©×ùívX³^®ÿðaÙ/÷>L7÷¬.äœÛ±XøªhE½'ÖÔ_M]V]6¹¤?—ÈêœUœ O9Vü(“½9ôóýRú2¨ £Ó’®ï‡=–¯08N—g>§ñ¨ ¼Ôñ®=ÊX/··rNΑ¯BÕÎgçÛn.ɉÞž7 k'¸Î9'H©#Ç™ )y¿íæ—®Ïõ±Û±zhÜå±Ó1_u»]èµÓYXѧgìOëœÓÏDZä#…Çyéå½ì?è¤jßÚx‹¨ Àá°ßØ0ð½Æö|è_lw1¶ñV6˜ç±5Öù‚ê/ÞhÛ5O‹d‚$µ[ùÈöÐvë{JS¸£tQ.V…¿ö—:疉빮Ü]%åøŠç^îxCÍCÙõµá/‰ªNð¶Þ2u#IÌ©x²œ¬Õʼn*L»óçŽñ/Ù<Ú µó^f9ùÝv1Ö›eloÒkÊXS®ÐÔ—dç*³cëÜ.Ck<›MÛ‹[uZ3¸àsŸ „·‹~±í¸sOW|bQ¶VË9×^H€x©r‰ûÙ8¢Âw:ù¶?výÝÇGŠjÿÆ—=œÃQH=/|¼ÊL/4À£šãV7^.…÷«ï¾£O°[—ѧãÝ:} N%GkïXÙĬ˜~Ýã%Ü–+Lñà…ºïd̺š~2€å¶jnû|”…‹ÙOÅÇÑ,uÎ*»º4¯ã"åQ#‡¯–ëeßm—R…â=üÓP¹Î¥CRY-õDA})÷þÐ÷±/„NH\ǶO/v׿z›¸Ž%éǧHÕï­ë{YßoÿyÛk»¼û$u·«Ñ?-º›pCG$ÇïÊèº}ߊ†ûDñB¶à‚DmñÊ×"¸W’ÇZ¤£˜w}°›û¾[/çô)n&i{lmoûpñì±_µÇõ«ÿ6µ}Ç€ÔæDÕ>Y‡Þ‡mؼô:†Ó/›6áò…Nwþ¿ÔEh‚ᢀ÷òø²Á5AØwþ\‰ô×°Îq°ŒÍÞóëtB‚¨¦kõ‘SÇ— $–µÝSamÇk&Ã-§pwÏæD¡²ø—‰è@Í[9îÔ4çhk:í£ÖôÛ6+¦qC–•±*äåa¹º‰G­ßÛ–¬‡«×c%ÝéãÐǼ†4ê˜äçe3üW â¬×V/þ~Ík¯òqÕ×ëŽk\þ^ ,òÀ- }ÍÜ'úÀß/~_¬†¤yÜðÔ4µ?Ü,ù&.Ÿ¶¦¿5ð«£x¸[™Ó’Ba²&¯^„Àǯ}Ò'þnÔº€í+.ül˜tCfû»8ò·\:á0Åîôj±¨ÿ@ÕwqTªÄƶ,@²ÁÙ+‹èšÓÿV½ÆûoqTvü¥3]â$çR9Ä?Ú–„Ÿä\èa¸.¸˜ð m¬Á£ WSw{¼${Bž­ü^ƒ»Áœçcº 7öd©]P¦8Žø´.XIeo É[ãÒáj¿=Ìõ&¿>¾ø…&j}æ.nQh¡{¢ÌñýÜŸºì”RË5퉻É@Þããú—”ü¡ÿ´Ø.±ååî¹Ç ÿOåLD-oF&üKf¿ðIýK:þïVN£|K7„´L9Þ6.â²e]°F|Ùßþà{úø‘–.ýã7tç¿,qÁk#j:Lp :ù~˜ó}w-ï‹ÿ]tš& ={óü?(O½¾~öÏgÿÛÇU(endstream endobj 4660 0 obj<>/XObject<<>>>>/Annots 1132 0 R>>endobj 4661 0 obj<>stream xÕ[ÛŽÛF}÷WpHoMéi_7€“xmyó’ZÃñ(ÑeV£Iì¿ßSUÝUEŽÆc,f³°}xÈê>]ÕÕÕMê¿òl†ÿò¬ ôÿÕöÑl:Ãú#§?Þ¾¢+Y¨›im³ÜÀ&{÷ÈÁmV.¦M¼‘8·Y=Ÿ–Žsp›Í«iṊګjn\dÓAêK5­âÒÃ`«Ðck¶T–Î,3¹hVIav RY1[äÎ,3¹hFI©·5 ²bv¶pf˜ÙÈE3JzLf XÆ: v^Lçžux›9wIŸõ,,ÁkÊr‡ë…D »I€v8qÒA#=F— ^Ç: 6P£ÆJ£s*5k4r±%=ÖF•FÓ³a†14ÃÒhã©f`F.6¢¤Çh´œaðíQIi˜æŽ•Fƒ ³š5¹¼.0cŒô˜|ZbRÛðÍ•„YÎά‘]Ñ#™c»(§ Ç–zQJ8Ô4VÈ®ƒ˜üsò(ßÈÍÒº6 Ä9ˆó†ˆïäÎ: "’3 ñ”ÃÄ3¹<ŸSü)é1A Þ*+^™‰WÄ,3¹|ƃ§¤ÇÔÛiQ–ÍVsñ › f—#ÿV™‘ÃlÑ §8ÖaÒÒ`ˆŒeUó˜>¸Äá–<îÁm¶¨zœƒÔ¢Gz 6̵ 2+Ý 1ëNäaiœƒ0ZrìAЮЭÅ0À:(b—ÏjX¾“HI ù˱“’&¶cÆ œ±SÔ²øºr!T1°.EN"ÑHÑ(Òñ"s¬Ã`‘ƒ ÇJ£…0Öhäòœ}¦¤Ç0‹B€)+f1u–U Ìlä¢ë•ô˜ÌdVY x„ÌJ(0 ³"úÌÝÊ8òv‰Ä¤Ý ÝI\>£á1ÒctcPzÖabÖ0X¬{–G¨œ;o °.E.šeD¤Ç0[UeŠYÄ™)e`f#—cM_ Ð£;Ŭa˜Å í±ƒ­)®íYi4Ö…œ¥JÖhäb£Jz¬+¦g¥Qe¥ÑXJ£ ¬ÑÈåûTIÑ(bÃX‡Á6)UVå¡4ªõŸƒxPIIÁÂkhTY^|KWÂ¥ZR±0•A1Öa°$øMY1Ì«9õ‰ i¡æ1=ZS€ë0Ø-[Ʋá"ybHÇ7¤,›EæX‡a8T=V §‚K Y9æ0E>,³ÂX‡Á6TO+†]AVgE¯ K˜ Sô;Öa2Lcl¬NE—ôP+²84‰-ii+Œu˜ ÓRc¬Ö’ŒœW¸’Ì0õ˜²‹c&à œg¬Ž%Yì¡Ö]“aJš…±ƒSÕa¬Ž5[4du™ Mb«†5Öa2\‘k•é2ã¥6¦.‡ñ('ZÇ: –WcŰÖf” ­¾¤ìŒGeLu,ÆP– ç±rC‚d‚PCÊ"½41ë0 c++†cu 3r†ËcJ=‹å0¦16V ÇZ*ÖzÉcâ~iy$Ù7qÈߨk0ˆæjjÎ8ƒÔzD9nŽk!PÜœFŠIÚ3Å´ÃÅšIîÓÂÇA<†„Šò:¥u޽Xq[UC´ÈHü*å bÈQPM£ütéŽ4ù\óð1ûî%â6/ËsÈÅò\┠͡ʖg|ü9Ë–«'ËöæËöçÙ³ýîØíŽWß,sæø„”Í!¯ãól’¬M°'lp¢º<{RÎé)ð¸ãìIöî—^Ѥ‡¦Œ×ÚÝ߃tUÄKo¯?|¦kß½¬’mdî-btZNóÝQ&ËϾý– cy®£•Ÿ/»C{ܸãȃ³HLGö¿P±”É‚ÜÖ“˜ß%q×n»«ËvÕ‰F8sŒUà¢/¯¸KÞ±Û^nÚ£¨£ÊqŒê(šBÅ®šÌ Ë»¾;"üÛÏL!š-£rzI¢hbL¿^8´že1­ñò¯OÞ-_ÿú Ý ²¨äòýÅyÒŸÏÃ0†«;‡`ùšû •ó(çåõn•&n‰R1ª¿?=wµ*ŽÝI>»¡·þ?ôþpt™j¤‚9”O w Þ¶‡#»8L˱oök¬*’›qÂ}‡ì—]*ŽÛIžßHÊM_ïau5yÝî>^·;¢PgÏâÌÞì7Ÿ·ûÃåÅújËv©¯©l ú©Ù,‹ªYª_|Zu—Çõ~G×±ÖÔô~wØo6ëÝG&l½ýò€þŬ «'Œ}È;ÑôS»ýFÈu-9=RI`Yy}âµ"ùìyw¾Þ%…n5ù~³n¯â*ЧòPq&™,ú 9ѪÂ7‡îl½BIÀÑŠ*’ÞáSeùcw¼ØŸq„3ó&¦™Ócù0W“¾œOL¬ÎCeKbTâSä¾PNÃ)ux3=BuqLCÅéq2ï;‘'¢*|Õ5õã@3­úi#¦ñê;»Í<Þù0þ;ÝjLÛ0_½sžu©ç‡Ýåµ,‚έ'ï¯éFLà¸Vd—í•~4ì3QhòîÔ½_ ïó&yY¸ôÄóÙÁ­KÊ"­(˜½iwï2¾¦ÁP-hvNblヅÞ~³páJžãg­_y¤î?ºÞ*ëòÙÙúЭŽë?$Ñá°îc?ɦÃç8˜ê)ÿ—w%ô$¥iKÏKò´™yºÙ¯~—”#³˜ë¾Æù=¡–ýfuÏËýLý¶]'?ã G'«ú”¥¡tªî}?v÷…:í`†þìçê[çìjÓ^Åš©yœSVEbÎù å5Ê%¦åçËnÛ^Š¿bÄÞ=„G¨9 '|ÈoÙ(óºÞþrÑÊÒƒ¹—V”5‹]Ødli»¥÷(còOº ûE<®{xÑ©IüpÞ 2Rt.ëp')W«ý%'W:¸(2Ô²_ë+áì¶—rŸí/?§¢L›[JâˆaTéVÔ&±8"wI/M{jŸw›îèä¦Rñ¹ã›Õ¡–ýÎP.{\çî› Nw·8~çøuxNWðÜ<¤ÇË ÏÆµ F±½/é{¾=U$ T%µ) Œæo|%NZ&Ø‘úL+CÖ¦yùx½{̮Ꙃ7Š¤Ë˜›©’6pGuó0PÇU„WGRVÝêwÉïÖd/ç5Ò‹Þì_’*úž°WLQ¶³3œÛ°3cIX/þ.~ µlËØä”ê½Ö>âäHÒùI*ѽÓpy<ëd’†Õ‘œ?½¶³î¼½ÞDm˜tƒ|™&Ýx^2ܮӥ×f3 ;E:Iñ^Cå;¦µÏ´ cRÎÕÝ„CL¦9‡,ÒYX_ܘNúB-Gôéã0ðDôž;?trJÁ›¿Å©ßiÆ%uÃÇ×½¶]÷'Écmø’‹ÆÍ%GcÙ«ßPÖnùÈÀÞŠ<ÞvÛÝ!.á´º7,Cï èóßa8æÃ×=ÿh“ªrÔªRQ¤êNL¶\ªç6¨û;åw³0É¥2q⎇ýŸW’Ið!â©U³m,«€j»9Û¤,1erºG`Ò"S}WÐ_Æ¢-„tlxbÆI]rSâ’Õ¡ä<å9¼…çLÛ‰”ºä¦6YÂI> ÍÓÈ;/Lçü:2„xÊßá ò¿%&ìб³ðq¦¾÷jð9û«IéÑýÞØ»åR”˜º›ý‡/bbI¬ßãô%¦3}×Äý3)Ëñš¥¿Â±ßôe)g™<ÍÜ -yô‘£œ˜ ÄO±¥ªo‘çIŽJ|Õ_oøfZ*¸øC*|Ñ΄ðZvÛn—þ¯i“¦_Yâ/G¢í žv‡ÖÏÛcKÁÉúPiêqÇ=݉Ó1áSgK?ø /ÙdpðC·‡z§šäãÝZ¯þÄ7æýw‰ðiéÆ|yðr=HL^¹·¿o×Ïaáv?¶+|oE}¾?°·Ýéè¾ýþßÇ"èCàúß” «J ­¯Ý$²ã|¾7|UCI~vÖO¾À9ýIþ(­i˜^,ýûÑÿP :endstream endobj 4662 0 obj<>/XObject<<>>>>/Annots 1186 0 R>>endobj 4663 0 obj<>stream xÕ[Û’Ç }×W°\•*Ù)έ‡“7Y·J%²/¿øe–œÕÒæeÃ%uùû 4†¢%KÎ.iÛµÞ3gÓh Ñhtïdƒ1þÍE ÿf«ãÑOèGF?~|AO¡ªGÕ`5ÈX.8¸ͨŽ/çàjPMF…ã\ &å(÷\Iß++þ8$ÓAô¥Èð޼Éq˜ØÉ¨ì± ƒ ù(xÖa°“ªÏ: ¶©Foëðjóë1ؼÿ]ÁÕ(s’+Ö¾(ÜP0HC¹,ŸÐé1:\ç4ú‰u˜”å.%Öab Ç&ŒÃ0ÈÆJ‡s² Û¶c:¹,«¨¡‘㣡±è/$›ñÿ±ÙFSô^ÈÏÄ)+š'ÖaÒ¦M\[Ö¦jÄóÙõ˜6Êe95L¤Çø(|9ó¬ÃÔ¥ƒ¶ƒ…çõÚ:ŒC‘ÂIöX½)õªÅ È89•RÇÁÕþ\:ÎAt“ ª²nH.ZÕâ¢uc€8Ñ0#7“7‰ô,,MXNÄ‘Dƒ$6rY(i€I®R•ê*%iɈ¿9N˜ÆvWq¬Ã4¶ue¬ ƒ,ˆ‘¬¬J¬Ã&ØXœ‹Y2é!#'XY”X‡M°±"8ÓDÁŒœ`eEPb6ÁÆŠà±' fä++‚ë0—´œTÆò„+qÈCÙêH®ƒ0] (”Hví²ã°/  †µd'ÎAÍ|0‘Ò› †‘Ï3H½‰\–ÕP£4ÒcêkMb±Ü+U’A9Š‰Í 4Òcˆ­)28ÖaŒ,‡²ÄÊGK7ŸJ飑“ЕHñÑŠf¿c ËAS,VÉÅœXò1ò Ø* Æ€“88é“c,m‰M0â¶Ä” H(Çhh8¦51‘ƒÅ4ÁðYSé£%i’X‡Á6cò¾Ä:Œ¡/hML¬txìò™’Aêpä2L0tØH©K4މe±Eãr&V9“HI,Y4±"vâVð‚A9ÎDzLbÇÞÄŠXÌZ³ZÁ ‰…“©(½I¤Ç[ QbElÌMÙúƒ$VóV8Ä™9L½-`2Ç: ¶&ƒ:Öa°¼";Öa ”I&Öcqß+І'S›€Œƒã8µ–‰s0fÚ‰ãL[e"µ¨ã¸%EÌÈ8Ì ÎAê žåc2ìœEÅVXJÅR fäH‰ô,.¬iM=[Ö4t‰ulÈoë0Xì‰åç1“ã M¤.‘û%Òc°H~rÏ: 6PÀqm&Ocð+]ŠÙ˜ôÁ’*!–gDn¤ÇÔ%Šc‰±>Ë-©±‘Ëà™å ‘C,›Æ±ƒ…WA,õÙZž2Ê RoÉé1Ø’’@Ç: [´‰g¦á¥!µ•.Åš‘ç;Öa°H¤1Þ©­Ã`kVÇXéRÌ.¥K)}ä.E.z‡‘ÓG+òcyáÏcnÉ‘D€åÔ«Ð"Fœƒšó„1Òc°Èªà÷‰ul““Ùë0…]Zhë1X¸.Æ×ÚÊÅ|VÆÈVñQÎ×r#=[ÒNɱ“:”ë9Öat ‹”5É“:<åS.fY´ vʉé±t8pN'Æa£f>Ç`FU.Ðè&ÎAÔhlç ²ÀN”8el=Ic«˜ºJ«ljê1X„ÎÆ±2>œÇÕ‹F_”dƒ ¤Òn!‘ÒýY2H9rU|ÑHiè³ïÌ’dù¢fßÈY¡–‘”T)&5i'‘Xók‘cùµƒh(ý1Òc°èmbxŒ•r`‰°|4r¶ è­‘Ò0æºò¦¥ºRosx;9£Ø„ÆD—_äßmÐ#Ó4˜ñÆ$Dò¨0i‹‹I,‹ãßM\dX€1 ArÐ’Ùõ.&¯,ÎRׄЈƒ´Q‚ÃB†z¢e¼ ‚C·Q'3.A‰ Ž‹µ8™ö´ ä§íXgŸ&[",e­TÕ@ᇠ%¢#Ø'x.AêdƒY;þ˜¯ßòï$Qög²éF9ˆØ õ ¦Å’äë‚‘qwùµÔ{M¦Ñ'Ê|½ÍbÞË",³MH%òc+Š0HUÔ ¾›ºº9÷ñ`ûzðè9E¼6½B Â~·@µN‘‡r0s}<˜ÎNÛËe7Ø\ žlÖ»n½»ýzú‹Çex‡X„Wƒ¡JÒ‰²ýtþ°˜P+ðxcþppñÓß_Ðrý">k×s~g2 y|ôãþò=={ô¼TÙ˜´¾‹ÐVÙ1½Q¨dtòM·Ý-Ö¯é1"R¥â ‡QSÈF~•ÕúÎvÛòób4Öwj‰%.Ÿèk¢f×í–ß6t`A~óMlUFeF÷ùO}~˜ÕM°2zìk¹ìf6X½‘x½_©±áîYˆz-ÖQ¯ßëööšßA.ÿ>Uwß !È(TeòÞ(ü°YÀ±Ù‚Èÿ‹&jz ‡\F?¢]L´¬“¿†Ð°ŠHœ¦)Ö2ÍMÞ㟶»v÷þ¦ãW1ó¢î?mÛ›C4‰åùIVQaê[±èYñÙ»vu³ìþFQ·hX¹˜þ“!™Çþ>¿a{SüÑûáf eÞ=GŽr[¨ôWÑh”ëÚûÕ8ª‰ü´>±«ªbt„Û÷Æ\ŒU|¦nÙ9éÆî6<¦›„ÙÏÔ-ÿsèV’Ã}®ÝŠ?‡nœ~®n4£Ž¨æ÷?ïBÝÑÍÇDvE û.€vûÌb½éSäNÎܸþ [†Çó7ízÖñ.¨téæf1ã×hšû·ÆÇ¢ýœªZÓÞ3Ù®9X²_ÝtÛ6&a¨ÚfkƒÍÛrÓÎ5sÁâÌVå¬ÈkØ_±Ÿl±bëöÁí;_î—»Å0¥,87µýçíì×öuLÎNœ±„šƒã°Ÿvã ­——\Üt³ÅÕ{5W•òî—‹w²WÄÑL£iŒ¨Í¾Œzm~Š­ñ; uÜ,W~vJ]µ>ë{·Úl¹:€®[áe»†Åh«Lã‚ÓŒêÌü5êjÙ £ãÉg©nÏ+ VO^¶Û_Ù¾nǯu§ôÅÛ®»á÷à¼QßÁ‹v{‰¡`y¸©¢5•'®1È~‹Ê~‘øÐwúDõÇ}¶þ𬵊ȫË_°9tó$0ÝÎnéîêÆu{Ñ3E9\•%Úœ>,3œ½f¦W?V9ö‹åæ²åm3ÝÑ(ý›JºüÆ;‰3Ì6Ù3Bó³_TA¥þ ÅÆÕ¸Û]/ð¡FdUù#”n½— 1VçóÝ{áïû‚ªÛ?!}û9v¼×%Ö;ƒ}î'µ î¢iÕO /vÛýl§Wxø*6‡ÌOJ?Ù ¡a» ù¦¶-ýüXW ›-ÛÛ[™~ØäVçmB#?wÀ@Öë'ÂG”\¬¯»ísÆ5K\ßÖ•ñdû«†½â-éÈ[?[$tÞñmd:6ØÂtÛzÞ2Ešê•Ú7írãïSÕÒƒ#‘©¥ x<§QѤð7:|'Cwº|ÇÞûóáUä+Îz¼ ÛH‹õšâÕÁ n8ŸÁ´6]±úùÝòþÁῦ܎ø%þžñô­Ç²G’Ù³&§>v"qDÃþ¶>/XObject<<>>>>/Annots 1240 0 R>>endobj 4665 0 obj<>stream xÕ\]³Ç}çWìKª°]û©]=¥BÄ7F)òà¡»®¤k] ÿÏéÓ3=½B”«œŠµÄ)ÌÙ³3;ý1===#ÿú ÈrüSdÕLþ¿Ú<ȧ9žÈ…üñósy’ÍšvÚd›¬Hà6{ýÀÁMVͧmxQ87YÓM+Ç9¸ÉÚzЮ©å{uÃïu HŸÊXêiÞÔÁ$ ¶Ê§g;›M ÇV3ùhUñ£üKôëà&ëù&_ä€D§E-é1Ør6yÖa°u!Jm õzvl;·ÑSo²²˜ Å¡JË‚¢ê›ÒÒAt›S8#=[5b6cÕlùÜuKº \Q4Óy63Òct;“KÃ4sõ>ZBtë ¼H4”87Ù\ì’8ñÁ²Ëp: '5ÕáÀ d2è÷ Òp7c7Æ9(ªãxŒÔN[ç| Aê4pPC›9N,ÙÌœ%˜Ê#WäÕ´ o é1†S”p½ÔÔcaç'l¢Ÿ\†Ä1p¸Rí¼ !HC lÐe‰sPô#®•HºVS©ÐE¤NÆJD9uì‘Ť™ÃhÒOk©¶Ôn R·“™ '0Òcm…àX‡ÁB^(7µuXÔG}%Öa°ˆŒƒ¶ƒí 1jjë0f}ž‹°Æz,1a8fÕ0Š[«*’*Wp¾7Fz¬ÂÂë a#ÛÌÅæ‰uXLU«Cʽs¤!®È;у‘ËhtcÙmÝ9U`ÝF®($ $Òc‘EºM¬v‹ c ¬ R·+°dÖY"=Ž£M,#C=sáFtËè¹Nt8ýšç >XJdH =)e":Öa°ˆJgÛIdpm‹€ØxÖaø$´K¹ETUQ·&HjÜ9K–8ñIh¢ZCÁâ“•g‹tdÐÖa°þ³‹c—bqû®Ç2%óp¬Ã¢ˆFœÐÚª›!5HnFÜ,pºV×Fz,ÂҮƪ~KÈÍ`ê7Ad?t3ãD§XF`4#%S¬‘BÈP™'*>„=g¢¾Èï%ˆïI––8áÖ­}@Ú9(–âšÖ©Ç`›RDL¬Ã`Ñlm,•SÍÝ꬀ƒ•§‘S'R"*‹hŠ 5 \‘˺žHmÈD(6$H ׯ•qÒTšq0U„‘ëb"õƒii¤éƒcSç :ÅZSf‰¤¯V!皢@:u ±"C ¾É/ÊBP1‹‘‚Ô0pE!ºM¤~‘+Tlhé©~1pšÿTFz,‚HlO¬vë3ÛÊ’WíÖ2[ b¤,,²3vk,»-ál6—˜˜‘“‰5Ëé1F‹YÜ9V» Y(‡WZ¢é çO‘%‰PLÒÈ'­¡Ç`èã»f°2ä¨ú ‚$Ià „Btk¤Ç"‰ Äª$>½--ÏÔ¯NæÆc¤Çè¶r¬ÃòÑs/±œ %GæžÊ)³=reÂ9ˆN±„œìEHÁbþà“Æªœ!IUÁ,Gu á;0µ‘Ú)^ð÷Òò=m8M2© ™jņ–wiÃÀÌ"%[t)s/}Ó2+ET«‘ƒÉR¡ýP±b¡Â'e „c·‘“½bÞTÅ&Œn¹¬¥¦ƒ…Úg¾­Ã`‘[7žuXÖpÙ³¦ž©À§{ Ò€Ç}Mâè]…ÏçP ¢äȉâ!¨e@c°,Öa¥„¹¶ƒEЮ<ë°¤#T’}WÌÅ+L‡"%#pàjA¹Æ9(Õ•HÁ6æúÉǰC qÁÿøÉÀµ²ÅNœƒè4ŸÉ'SCzXÈpÔ¥,QqPÒÒFz ‹Tˆ"Šþç°HrÒÖa°øÆkmÕ‡ o‹ÿbVíW‡8‰’ø¨‘ËG)š± ™½„¹-"ønº1Òct‹²ÜÄXv’ ŽŽ7Œº.3ÊAôX‰$.AÑ„ ãø±ñc–7%„FKefÅĈ±h%6 ŒÄPÔÙ"å :DHF0rtDæ:Áõùw›ªÑ™i…¤G3é¨ü„°öŠE-áIÌ|À’Ñé.Ã\Ï èOëªIK¦ü»Œ§ÈŒjy£Š?ùáö‹xÞÄom–û"ÏÃëÝÂì) öž³™>ŸŽäm^ʈ!¨L$/…eðQ=>;îïû=UPLçuîº?,×·®„:åÔA´¾ÛÊ‹Èo£jЖOp$p¢r¬ü]4Ìêvy¯}¹OP}7Ë;À4¬/¨Á6¯T[ÌI¶¦…r’.>ßõ›åçfÔïö<‚Úœ«Ý„ùpš¨XÿEf›¨oÞ/Õ—q>&c¶¦°ÈCÚ³—ÒÄyöAuòWyŒþˤG uB^ö~éB™o }XÛýBdS{çÓYÐÁxdK#i‹\¤™œÄb¤SC!ÕZ4êáѨ—ûµdU”Su|VœNÛ‚Þ:)XUð^Ì@m^Œ¬ðc¿?„¸ƒóŸŽN=÷ŒÁo×÷œØÇXx؉¶äô ûÊX½_2ãAYµ©Í÷ß³–µK:M[ÐÇ'8{óamÊeÌ4ös8î·Qa)û¸¼=ªK i³¨¾Ö¤Íëcÿî( ¹Î¤À—Y¦„‰]ÅæÊebÿ뾿92ŸGRkïæ¸]Éb¦Só'ä°iªãomÁ™=A©eÕ¸h™¯X„—{îd*gEÚð|Œks«[©3¾Ä´°u’g(*ØŽj} n3ÒD:I9ÜYQFŸ{¤)Šý¡mNƒšmd­7»ëã­î‹ÒäÆ~I›ËGO;;!¯–«ÈÛ§Ôö…vYmÁø5ÁQ‹jº¡Oáþñq}{³O<Ž‘yÛÿÆÐìæü‡õöšóg1x¡ÀÀ×p,î;ϨÃvûà~qIýåa”nc€~ù޽âðòùc[„„¾õšAYÌøÖ·¥EHå‡J$Ô5c>kk”[ÂìŒ>òb{Ø#z2#ЧvTØŸ1Þÿém©;ìZB² ù˜ºUåjßïû_ëûõA-Õ\",ý9Mº¡ýªû-BAÑ­†×,Hà¢Íû«¸}Ëó~Ûï—¶–4¶Éêóâ¨-™ OpÈä]vX.8·C>sbóïW/©\¯gå -µ¨û€NÚÓª«ýz³6t§Û?.Üîã¼¾Š…Íׇ=R]dB–°õ×yÌäöu`,Ÿ(ñ   $åÅ83YÚJ3öÆ»/nÕÄúûòþ}X'¿©4Û9‘Š ¨•^¢ð®¦úF21_[©dØEûõw{²ÛlôpT~‹I»»Ru®ÓöÒUó/<²­4›œœq¦ “€8ÁÆê`½Ov8ˆ¡*ÜQ“·´mÀÎÄßäçøåæüÂë¨i—‡¦¦ /ý$ò#O_–n+NÅIãëËm&ÿ±ü¸~g6†ÃÛ=Ž3¦ÃÕŽõÝñÖ^Ç=H;;Õ‡ú#¿YÓ!fþ8@CÍêb»ï¶âÄÈUMoe&HNov{TŒõZƒ+,ü¶>¼ÞWÔeÜp–#Uçr[…Š:>½ä_Bàø˜"º[÷Ÿïý†O;+© uœ Ýë-no®qf¬÷(è/‡Â"wRiOÝv˜¼Lׯ^F¢|­^Ež¤+H±°P æâOvÙ-¦Ã» ¸C?Îâ}«GP“áNõô¼åNR¢‹e'Ž÷{0 ˆXª;|qÞø+¦ ®¸rzèþ2œ‰ýq¡n7 (Û§Sü‹œM m­û aa g|lWá¿z û á@? £Õ£€s_8“ab#“WmìÚ®h¤‹zCX~3ºË‘ΤAHþ#ýÁRà§T˜Š7™”»åG~†XƒÃe)¦M f?îV¼fU å™—ÆP#ç4þôi½^‹¾ž.üóÁÔtÈ^endstream endobj 4666 0 obj<>/XObject<<>>>>/Annots 1259 0 R>>endobj 4667 0 obj<>stream xÍYÛnÛF}÷WðÑ}Ã%w¹äksC€i}–-Ze+‘ E%Îß÷Ììmh;-P •“ÀÉááÎ}gg™OW*+ð[eUMnWE^à ýPôãÃ[z’ÕÆæ&;d*}öñJÀCfê\û‰ð5u®'à!kmT@넾ªÌ±Pb°¦„UÎ66G`°T ÖhÒ£ ;Ò$@+IJ¡…ü&‹,ž[É ÖÚ¼¬SZUB)ƒ¤ÔsJ—´0’C¬i—¬À‡¬T¬4®uJK%”2HJ=§Š†|‰¤ÄPZ) ~b¦8””ÓÄ ¶®¨+0 †^D8²Îà¢3H{N9O#)1ÌJ+0XSI‰lc(‰³©‰eƒ Œ6ÑàÀ©’R“H‰¡T·¨IÁ ¶­áÄ:¥°+)e”zÎÕŽ‰¤Ä[—y•%Ö‰µ¢D ƒ$Ös A€µ‘”b IH¬[û"d?°Ø±!‚›‘”˜ÄÖ(Á Öš¼¬SŠ(rˆX ƒ¤Ôs ­Kg&’“Òû"±NlåÓÍb$±žsÈDRbˆ­jl(Á ¶-È—´V`Ú2vÁJLõIÝ#­•,b‹Fɶ¤<–®”Ò”7FäÄ EqJ¬À`kNNb&“5¹YEå £È EÑsTJ°7’na!K‰AZè9¥ya$%&_,~bÛÐ9$XÁ¶t`V`x SQÂQ²Ä`3TSb‹ög+0XèAv+ð!«Ð®äZ‰Á"áÒ_‰Á¢= Ü¢d²nÄÖq 9pª¤:M¤ÄŽJ²SIiZ‹ Pdg&íWÓà/H©€XXÔa"%[Ññ˜X'¶vîä0Hb=s 5rb.¡s>qB¡jÉ˸Pb2‡ö¹`‹þ cãZg,wÏÉXÏ¡ÀØÈ ¡šUFRb°8©”XúãZÌy<ìM»ìÅ›ýn­ï'ä¢ÂleQ`µÎÖ[ž ‹l}{½ÞÜì»l¼Ë^ŽÃÜ óé‡õŸB,Î k$l¤­P9cæz{­ Zol¯³×÷´í‡=…+Ú?ÿøû»·ô¨l±Ð?›G·4o“Óùx§™W&oÂâ¡ûÂobmé×î7Ãî¼Ùuló‹7:XØÂ݆–ζ§CÅâ‚/ÇÃa3lé™Ö¹²A^?t¬ƒ*ع2ç~X¬6æÏà—Õ%Ù /©“.œÕœîúÝyÚ'Ä` ÕtS Tù(¨:oC SwœÆÛîtò4Øå>—ðÛjNÞJñL±pÔ,}=ÌÓWzRêT#DZ¸–Ê*/jïu,º²ñOnÇ-§Á¬Â³]7t)j(ã×_" Ðaô2ßõ" ?ÛóžÁÀýîÅ{zKaG…öDî¿L›ã±›XžA¯ðÑ9ýÕí»ÙUO…1àbq°škµP?,z»ÂOã—Õ¾ûÜíé)æˆàÉ?äyœx›#Ï…o0ʳSk5§u…Óp™ífá(Úö·w÷]¿wÍ'AÓºd^Ô©…r«Ù••*%³]øøá<ÌýÁ•4UèÍò À |ÁµpK«Ù“Uû ‡ŠLÉ® œ±7HU]ÉöýÍ´ñ=­ÍU(â”VœçÏ(­ÁÛ'Ž$¥8£ÁáßN®ÉÈvÛÝoG_¯ºÈqzspd8/ÿïàbû¨dÇ1¥ëîÄÇFË8¯l§þsÇG0¾A…zͶԦÆãÃÅ“{LôzþÃ(∛¡ju:÷³Û!¸YúÓýû‡Ë.d7.Û”Â%ò7†uìãÁÏ“ã>þw—0 ûCëû»ô ÑSýp+»Ñ2øøj¼=S*ã´…yûùÕ±5nx|Ô—øxEüËÔMݧsBmñá(‹ónä9R½nÃÔO#~Ó7TbÀL“|\&ynO}_<¤Q&UÑãá퉊W ¹ÑúÓ<õ7ç0k|¶ü;Å7“Vøˆú`øVn( õðr !Á«±äOóW7¢Qô<Ûûm·ÇÄÍ!øq±9k¹ ‚·ôsá-op|¬ ξênλ]ºøÅ;ÅûtÂÿ\xŽ^:·DÑUÌ€âªÁ»E8ú–REÅZŠº~\˜ÇÍtr¯¥ tž:×ÁmŽVâÎÿ·N:.)õ3:Ð]l¬ñC7îU‹ôóQysž°¹+P±‡ å«\®Xït‘Cì•Ø‘µ¿}-Óòÿ"kø2ÁŸRÒþ Òøo øÞ‰.Yâj¬Ñçp“¦†³Â3{tTø(WjÎÒ”íõý}ÿ™Jçõúê׫¿ömÒùendstream endobj 4668 0 obj<>/XObject<<>>>>/Annots 1300 0 R>>endobj 4669 0 obj<>stream x½YMsÛ6½ûW Ó‹2Éâ7Õ[âÄn2ÎÔµÕú’ B"‘T)*©óë»û–àv|qCN2Ž^ß¾ÝÅ`”¿Îµ¤_ŠRþ]ÔgËÅ’þ†üãöê,JK•dé"UµJØ©»Kcpy²ˆUà¸$ôtÌI˜[%‹P%–ó`­‚e¶È<ÒÇÄÆù"ñXI5^Â2 Y àÒ sI' ?¤ã`­VKNÇr3ÊǃN7pr±œ)f¾X©Ärs)mKÀÅ8 b9rkÔ’¯¤ß ÀA=X«lõˆó "ªÞ %h.•(.èÀIËyP2ÍUlI šÊR`°bêAñ"PŽa"k‘ñdÄ,.–ž®âE¤bæˆ?¼dÓå ó9Ý¿ô±œÝ™‚=öʈ³›ÓÞÌs>/XObject<<>>>>/Annots 1322 0 R>>endobj 4671 0 obj<>stream x½XMsÛF½ëWô-JE„~@äÞl­íu•ÖÎFJœƒ/#`HÌÀ0ƒiî¯ß×=8²³U¥ì¢Ýhôô×ë73øí"¡Z¤ü7«.â(ÆþIøç§7‹4Š)]¥Ñ‚*Z¯¢e'”tßé–KÑ¥I”R*ëFbE›ÍDÖ\ÌGv"œí:ÝfÍ)tÁnìD8Ûuº$N¢5¥ƒ2ÆëÄMtC©C«M—àƒÀºõY”$â‘9õbEIÂe:Žeh—7Ñf¤•pVëP·×4ìr$V(5B=ëF"‰'v#çsv(xѱ í‚+0ÒŽdhSnÖY‚½ ÍZ‹S¤>g‘—å®e0L»nÝD ­D`Ãô,J&gлehVºäDD`» G­æœ†¬‰@ª`лy¨ø؆1 l‡€!&!Á$áxƒÄʱŒW7m0CŠYG¶‰\AË Ã%àÅS•$K .HÁçY†v¾‰VcíH Olᨗ¡]§ƒ4¤º¼ XOb8Hg% bJ¯¥H¬\`–6òO+Z.SÌWX e Á3ÎfÕ ¬zù0"a·£ë×X‹Kù°ÿ¤hÖÍœraž˜²Ë„~tz«2ýýÿGöBJb¿¤/n™¶fsLÐ*…ýåÛÚ;›·™7¶žZž='\LgŒAü/¿ü8Oohúþï=ñÛ³„ü¼ÿðö ý¢]7ÍÔîÏ÷sg2]7_âÏwãtc[—éçÌ=uú·Ö4Æ?«Ÿ÷n§jóÅ0 »%_˜†*U·ª|ÆnýÃÉ[RkrrZå¦ÞÁµ~~Ï/Uöé¨\ÞPf«=Ò~4¥ñ§gÌõ']jÕhªíóvòÖéÜøçÄäËv‡fí­{V/oëÆ«²Dr[˜¶—|0un ™/Þ ?ÿé© »T¼èÉkÿ!y…÷;—?׿ó_éïŸ*3µ·MAïïé׿Òóƒn<¦ðáÿªç«ÏªÚ—ÿ £=åf¶XD1H';‘ìKl¶Øãfó5öÞN óËÑ—Ýõë~CŒñú2Z¯‡}êãå½AxfktNœÚïµ#U缆v¼ÇÒ]k§¼u¿'0¥¢Æn=ES®º´ûJ×ÜfKÚZG­)…ܚ̙=˜JUïZµÓhn·hƒ÷¥î=ÐoÅéí?ÐÞÙSUÑ{gv¦Æ`œzOˆÑÔ”l6«+’mö¨Ú×xj(OÔdá˜ÆóÐÁ>Ú:íM¦Jú±85&kèïæ€}ü¯<ÝÙÀ }(/JUÙ†ÞÉ8ÂæN=ZÉÿ4ÍÝ4#jLÕ†1׿º!×Ö5Wž˜ëom]k9`_˜ZÓjR†¦Eý™¦[*BÂî¤ëƒq¶æB_3¬µÎ‘6ö•£uŸèh|AE‹B#ƒ¶F °½bÊ•WW² ”ú3ظWRz5‰#ÃÑūڣôYîqœ=‚×#BI¹à¼<àð>s7†cÄ{ 4M'í©0»Ko†yij-¢EpÜ@hIcË{GùàПö¨*Üb]2J²6ƒ¸é¡" Jåv¾Tëma)òªù$Õù]ðï X ‘#›Í€D{ä:Üãˆ'¥c 0 {Ö"ºš*Ž.ö ñl·ö\&õEé ÛîŠ3’íS€ç™ê@½5aBK@™#j®È –ÆÔT}@­dDø A;™Û’ö­Û[®O¨/€xL1Ë™ÂäˆVÑA9£ýIš;r6›až@žT‰ùÀ?õ G'”ãXààF·×£é­ø9ܘ:ı¯1k1 Œ5%Ÿ™Ÿ¦,™žzÍ,‡ð\I<,céNÞþ@®;€÷«h8œã3Æ"úLGßnQ]3&AP·š4zR¯€G1íVÏÉâmT#l,¤-_%NZˆÍ ö¶ÎV2?§yŒ;ŸLÓ–‰nˆ½c®ПfªãËø ‹&†;LÏZÞµ~.ÆÄªP`E­kŽ Lšãç)ÄÑ >‡ÌûWú²Ã!5UZî4 ûÈuøH«Ô§pÿèC‘²¤|1 ôðyO‘“öN49#€Æ]×B¤=± ~,‹ÐÖÑÅçi¬< Ì»··¯ÞÝ¿Â`4…Áî–‡$$Æ®ÌÞî©ä­Œrã@ÏÖõlíN]’í8¡ˆ^c ·­C˜þP7…àÂtiO ‚á,Ûá¼ß¦Ãçw ŒÖƒï…_¯ÉGgÞž°©bÅà\ï=¯ç. ï÷»¾>Qs4»ÈºÝuÉvQ᫯\m.¥Ör*à#׬۟=ÃÑ¥êqzÕp¾àQv‘$Ø@<¥Îl[2þPØÆ;Øâ!¨•ëÝ`Ÿ«„ѱФj̪(NVX éZn†NóL,u®UÙ ÿôµ 7U™—}‰Lï‘_xóîçî<ƒ³@ûˆ è®jŸÞâÛð[††L.Ä_à0[¥ œ=Ð& ,–czPðØRÒŸ~b•ƒ}Lü%G½97 _¢ò§ú=]Aî²ÂðQƒWÀ÷¼u’ÈYqüe…O.Ëe¸5Ìy¡Wÿºø/ÚHú¸endstream endobj 4672 0 obj<>/XObject<<>>>>/Annots 1328 0 R>>endobj 4673 0 obj<>stream x}XïÛ6ý¾Å Å¡Ûv-[ëý•Wà’˦ùÐ&mö®8 À–(™µ$ªeÅýëû)y­f7H²±Lj83ïÍ›áþq–Ê RYßðoVŸ­’¾á”?~ysv‰'¹Y¯’[©%½¹>>Uò!.^_ÝÅÅ”[ãSX¼½Lî$½Z'/ðêzµJ®Ç'®ž>cõò*IOV_>œ¸üq¥,ï¯$]ÉCŸo^àC\Ňìüak:éŒ×’ÙÆ+Ótâ·Z*åuçe¯]gl#¶ßv¶ðƒrúBú+Rö&ǃjr1Ma]­R  L}fë™sP%èÆ.| ªÕj§ ,P"ž©"Ÿ"5KÉIĀ債̓*xï‘oЧ t¡M,  •¼šX3E¥ïBo !ǺdÚhØȦlLëG´ñ<Õ²Q…8N'¤%ÎÍ©‹…¦ æTk[ë¼@ÇEå{…xs)´¢LÌ X™–F¡Za¸ ß*«r¼`Áå-3ÉzpÙKùu«â#­í:ŸFŒÇš‚ܳ¢,°‘œ£îA»±š™»b¦€‰á™CÆÖ© Qð@‰w‚´¡“ꬑ‰Dî6\9Äc´”ÖÆŠB,,òÁTPશ(ÚL;êVu˜?Œ§¡•v}…›‡³œ. 3Èi"o‹`.55*ñKñ Zä÷§LöºiŸY[å¢þ“½1u'ËûG‘‹fšÜÈ;WªÆü»ê˜ÄñUzÿœÜi)Œƒ…$Ûª‰>b0¾ŽüŒ8v€FJ`ì¨À¡í1às ÈÞÀŽ7ð?#+¡.Ä5vD§Ñ 1Kèñ\ 8loCÙ õ“µ z¬…IMÀø¼g±òt¾Ñ銵æó Xš˜nèQÖe4B’P´Fe¹qdÙÈö.Î1AT"8lªÑáàAaèFä ‰Åæi¤Rƒ¦EZR¨?ß-yÍ­joMN1 ²úˆþóŽ<ƒ[AÃ{‘1£DÒ hp™¦¾xÛx‡äeœ¼¾€æ´ã@¨º0ŸAÎç´9=OÛ%ôøYú^\ÿƒÀ& RL¡“….À|^@ÒpÚ!,ÒÑ êÅ‘îÈϱÌÀª™±‡` ÄÈØ‡ 3Œ+Nt6-óM3G7Ì A Žñ|!(L(wá,êKk²8©>[†wòRe; Ï9Ø€j äéñ#Oè¦÷Æö3á˜M†s!QDØ}³±K"“Sá…^£áêæé£‘é©ã3·¨/]Q¿çË„a^]nê}Ð?<í´nŸ³|lßaU êÐeãL°„Á¡VÈqi©ÈAóÙÝÐ1aœ7„8ƒ-TˆscŒ3)«n½~¤ ¤œ{ ‹}[ ´]rcËŘÛ½8Œ.O'kæˆéºž%ð‚Ôx¶Œ'¨²]· #žc+Vn‡Cb» žƒÍOn!çcoçp6vÞãži¦=Ÿ#U&YáPƒy$)‡°‘;A¢ž!A€Ä…(cK¢â±@™K2ïÿÿ}ýˇ·ï~šeaA/íõÆV£”lmÞóåщÁhÌÔDýQg=´=™n`>þˆÉ"Y˜e¯Kðÿ©±xõq•®Öi*¿gÖafimµÒ«‹4Y'iúÛ×ìp¼€ ª ㆠt>ŒL aŽé¯™•ú¡E£j! ž s’ǤŽxf©xÌû4A‰öY¸á,d~ ®žæV¾ÿ§LAMÆyy?_~#ÿážX@Æè'Ã4ªÉ7ËÙæ/5²œ[Þã· 0PHzw•\¯¯7Òäê:ÜpyðbßCüÛf¸ÛŒ—pZ•)î^Üòíü<ÅUŠÛ!¶íÊÛ®SغÂo°cÍ/^?œý|öZX—wendstream endobj 4674 0 obj<>/XObject<<>>>>/Annots 1340 0 R>>endobj 4675 0 obj<>stream x•Waoã6ýž_18°åX²»À}HÒ$ °Èî%n ´DÙl$RGJñúß÷ ):Ö¶Ù^±‹À‡£™7oÞPÿ;›Ñ9þÍ(»àÿy}vžœã ÿ™ñŸ§û³4%+ZdódN5¥‹U2ëW=Ÿ®±{±‚U°õ»'kì®.“ÅÉn–Í’ šÏI ÏÙå»aÅgO×5ÍÏ—G[Þ=]c7Í’ìä, y–y¿é‚úEø¸Ä¹ ɼí,kºô.çVK ¥+ÄXÓ,»„ï°b§§kì"k@êmywÁi§‹Âí 'Â÷N–8xÎï|Ûä4R€ÄçF\ð¹ëõI©|½ì–¦wsø u‰š^¬ð£ð¥Ä|ôhZù=­w’^¥uÊhr‡zc*RŽ´i©¥Ò² ¥©…ÑVjiE‹ÏŸîioEÓHK¥ªdâ½øÇ•5¹tÎXÚ ½|·þýìœ&³!ŒØò·ŸoŸž>>’S:—Þçd–ýY¶ӻ͘`>ôIºäŸÅˆ‰÷$+)œä¥ ¶oINÒy²\²)'vóãÕãýís’wÖJݎ㺠§Û·WÏ·×·Ï> Gn§TA{ÕîBš}ò­i¨’¯²¢BY™·Æ(7ºJ©Yéì+˜ÆHÚÓ˜©6 iVÄÿ›ööU™ÎEWÎç຺ˆeàPiMý†nš’Ñ{a ÷m”Á™+ Õ~`_opEhêtÙéy¢ö¿#}d'ZÚ›®*<•6’ãœÚTÒck:6€ÐªMׂ}ŽLIµÐj¤iØÐØ¥·=ÿ”%×+©U5÷P²<˜l{•´KKÕ2M}æèµõù N™7x©S¨ë= Õ -3úÁhÑò©ÖøƒC³ØY#Þ~‘²A‘QlÓÔ m úv@¤}@R“ JØ­„ü*¬B”º«7ˆ¹Ç´w&œ¬Eñ5BUTU`"ðBßöpÜD EAðnŽ â\†] ò ‚›Ÿ~yz¸ÿqíÙO eß/ïvLàÇu›:@¼é¶G¤]w[ð³1ö[dºªÚé¶;˜à³@ë¦õ ²‘@ЃÄkñÄ‚ðîIi¥Ó^ú”Eå µöЗÎ[–R´àP5˜ù*ÈY‹Ã &š¢ƒù¤hmú Q<<G„tÔèj®?sØ·AÏà\)‡"z™ãÇ'ÌíÕvâOxG/ŸZ¿ñ  øB$½ó¡uô=XŽ€ˆüEÚ¡ùÑ9Iš'¾bŒ"¨6‹˜*UοcçŽQû¼ê Ž÷ב*  R¹@Sÿúð±‘ÖP~±•nì_,7x¹ë­Ñx¨DÑÕ&“{,Ø,X@ö/aÊDa8":I[ Ô‰'uNc/…¬(3Î4b£$†·ÕñäÛ‹³+7…ô:x„í3:zftu€ÿ/ž „TA±mö$6½tÕ£Ÿ)€u-šRb4'ì'ÆâIzÑO)ŒòÓü³Ò…Ù; üõ¡áhóCðSÐ1'!† tU`Å9rbç;Ѽ¡Õ‘ ~*ñûm‡ùåõXÇx¸äžç¸$Do\0ÂoUÞa R“[9Á8.Õ6¤Èâó må:óŒgWa~B ´“‰Ö_IŽËUjcyš:dÙú Ç©g\bdUb¼A'*ðŸ§{¸ž;ީŕÀÓ 7ueÁHf1×ÐN*+±å‹F OÔ ®(o‘9Èß1ZÈÉ–8æß><\?{ØýêæîÃÕý3ñìç#|¬bC$˜Ð)ä^ýož‚¸ÙxÂâ Žàxº¹Üª&̨ª{…{Ïð·…è¢Bô„††zƒjÓÎÙie 3G2Ŧ=mf¥Àž,%%Ÿ`d`ËÓyg Ç»ÿØ7#Š3ßXýÎdõÂü&0"Óx¿ Üðàè+ˆÞ>ÛF Ý!Œ^\ÿÒcøÏ”cŸr 7í¯èÇ.ú'¥Xö“³åûïÙ7qAendstream endobj 4676 0 obj<>/XObject<<>>>>/Annots 1346 0 R>>endobj 4677 0 obj<>stream x}XÛrÛ8}÷WôÃTÉS#R7ß’·Œãd\•Éfc¥vRµ‘ˆ1I0hYó°ß¾§$%Ú3›¤ó /§Ïéæ³ÍñwA«+þ—UgótŽ;ücÁ?¾~<»Xݤ+º\àš*º¸^ W%=œ^Wt9¿L—Ý»ütuµÀõÅê¬]Ý\¥7Ý•<=¹ÆÎËUz}òôôO/.ÓÅÉS˜HË›yzÅ6Íoð¼â}]Ÿ¸!¾¸Í>\ÐbNë-ü½zƒ_rq¿dçŸmÐo)šrãt¬;ÐÎ<éš‚¥Ÿ×œÍ> ²øíÖ//xýžß~X¿ûô‰¶¦Ô8ß4ÎÉ xlC¥~ÒåI|r”)=UÖÁémµÞÔ;Êl½5»ÖÁëw¥Çqî XÂðå2]­p•ŸÿDélXCI×1DV¬Ò««ëÞÜã Ÿ9ÓÀ[S–¤BÐ.©Òf )xRÎØÖ#Ù£ÚiO¶ŽA¬TV˜ZÃŬls6|•Sú‚`]â¿C(ð¦ªsRØ—ƒ`ñ9Pn§%sCôKUïZÙ;*Ä ø¶i¬ ž3ϹhTm²>Ø€&È?mm[窴÷²>IâêÜÂP~¡ÖHÎ0à[f«†ÓdÝ®­SZÃÔWÁ1žTZ¸r@`ì#»»µðf¼5g‹]` d2RGœX¼ ÓϪjJ‡þz€ÈÈŽÉ]÷Úä/{ƒˆb¯B=ñéð¢@Jèwõˆj–)qÆóù¼3CÙu$ÏϯjÏ6ÁØÚOiiÂÄwÉ¢>AÓ‘•0DSejS©’ôv‹ºgÄJ²\'ØÂé¼ÍbQª É d·´ìBn¶Š&¼ ¬ÐÙã$f@ÊP?ë¬ jƒL1J³q wG¦˜ÚäÑDÔ9ïY뜮²F²™ÇÓùvã!¶Eà8xø¢®Å ° 0wè0…ºµ€K0•îì2È*Cƒ\ŽûÉ-&vX|­Ú2`…Ÿ·’7 øT|ÍeWïP&›Ö”ã*É['yGj;w'àùTñ›Ýƒ`Ü$¢ðôñ‚þŠþ`r- ‚¬êí;¹ÎRžrP¥3›Ž‚žR 8ÿ=ÚŒT©&èX=ƒàõJqÞ“c$W¸G·¿½ûüñîaLŽ ñÿ¡IÅX|ŒìPAûÂdÅÑGgãÐÛ šKã-C"Ä[÷‘Ïtœ`X™Ùœ€{2Š>š0•Bb°8åee¥3Õ»Óuê‹XtGQÛh@âU-žðõ‹)݃4óÜpj§€Ú¶-ËÔcR\ œÓ?Z(.×jÝVäON™ðŠ#¥ØM®]›IŃðÿ.Õ²?JO ·ë|%óo²=û°¸é¤9¹F£Sÿ} Á‰.¾‘[[Dÿ&}CÉꆅh‘. cà°ÌÔÁú‚þñ@ÿî xãúw‘ŠäFÜxz¬í^Ú QkÔC/XÛR=YT»Ây[–v/‰þV0\$XE|q ÊÆ>– „©²ÒAjêݘ $OÁkðÎi„5× E,m€Z`]g(=¦»fø/œåb‡,Ç$¶9 ^DqæÂïIXX<êpáüMʾs»ÛµÏíÔžwUz¯Ü•O±ƒ`U1A8¶ªÂ{ŠœÊM&š—ð;3*íÕw«A äžþG+ˆpl]΂MáG¼2s qµõ•<–öd‚×%n™Ì‰„£ ô6G {àìB¡ÿ?èè +ªEoõý<âçØ|òfÿ6£dXMhИzW %üýg$ä–ý…žd¥…q!A“ON sôwl‹;%nÜg2c­dƒC îãl<cAÉSú¨È°·Û Yå6£2»Bš‚SÀ Ta3HI;I Dq!>º­*" :+jó£E¸¡aB2tèÖRôzV›A´îQ0Zå‘";¸µ€¿ùSSÚÁÙÛ$ö½CÈ… ñÀjٷ± ãE¿Ø$ˆ¸¼Äú|d¶‚ =dBóv6Ë¹Éæ†=…•:…ƒ³Üf-¼ R賯ºÔÊk?{ß¿¾¶€Ël½·ŸøÎçliªÈ¿ÃѯT®S%Ô>[òêãrLßÖÏ0 ªHÑøÀ=neáp½µt]о5·®‡ï‰“¹ïj Mp`ì¢Æp=!ÈNßö Çá “ÜB¹)f™S±÷Š]Ze퀂 °@ÆÜRÄ44øúÀ£`+ÏD`yÒûË1…ðç'© JãycÛ_ )B¨ºym•‰² Q\W%.zì"EÜó^$Ñ!ùhüÐx £Ãƒ Çj3®Ún_ƒÕÀçHnS©p°a¥¹ÓïÛ~ip£­‡euwÕb³<“ ìýWÑ©Æt®fAÖç¾wš’ÞÑ—Û¯wœ¬_-¸Š’‘ZE¥2Qw¨:ñq¡7iªVåšßƒlÐ6î.l#£O×Ñ÷…ŸÆmëyÂõ­Álç¡Ø S„cо›“úD3‘ewûÂÝ[bxüØ›“nx·¡‰{`Í€WžGÊûí(ßþX8æY‚µVBš€ýÝ0•ON=˜oÐy° «Œ*•«ðÁ"¼uËÄæ4dºs‡sXë½kdÌ][Ì;aNÞnM†Ñ YÂpÌÕ¸×<ÅÎÆ 0‹-¹¯»¤Æ–KÞÌÕW ÉM…X ÄžŽÖ¨Æ0#wd|ÆÁnh{°ðöË7|“qZ|—&ÂbÜÎ <ª–‘ 9a ¤h›“ªC…Çò#ðd þB`%ú2q²7m=eûFFtµÒqß/çéåê’®ð¹OÚnö7YáàûSiäÀÁñÝäš¿tú2ŠÀ)¿òË—‹ëôâŒ÷.ùÆÝúìŸgÿ‘!Ö¦endstream endobj 4678 0 obj<>/XObject<<>>>>>>endobj 4679 0 obj<>stream xuT[oÚ0~çW|ª&•ªM×¶{Û¥&M“¦¢õ¥/&qˆ[Çf¶åßï³ íx „Ìñ9ßíäÏ`Œ‚ï1¦‹ø)ÛÁçå È ¾}¹5F÷nò)–5&·ã|±¸Æ²JU–å|}@+^$²ç ²”,_.–σÑý cÕÈx9›LûËÃOÚÛ+<<~ÿvîá»Íƺ€Ú:|¹¼„ŠGu­J%MÐ{ˆj+L)+„F”Ò¡ ‚ôÁsìµPÖÀêJ:”¶Ý(-ÇÓ0vUƇتÆÞv.b#žñ„D†ÇbTVzÞµ²]±cíF Î{ºÈ±l¤—ÎYvN¢®ÕÒû¾7»˜óÀ‰A"¶èXÒ¥ZŠÐ9Î úˆvgNlœ];Ñú¼?Ì"¾Ÿ6Èqn¢œùN‰²sî NiMÔÃÃn‰uNÿ’29¾'®Ä·•”ÉìQ©º–ñ‚pk …YwbQ ­©± j¯íŽ—ÊFyN`¶jÝÄ4¼µT€¶ÞC9‘±ëèÎ ÜDht‹¨xÍÔe“E¤6ÎÇ“|Ž»WA…¥SÞ#«fy’ ’?‘†“e°n7ê[á” {زïw^™uÊY"¦å`ºl+±rvçÅJK:Vv-eAY“ãAÌKOx'ÏÒµ ›8ÖŒÎzl#e*ùš7¡Õg§þ‡€à0 ¥î*šð[ùNè´LÂ3IbÁç•ß<] NòiGVÒUä•xeûµÁ#q\ŽLíiØ™O–LK}œ÷ºJYì”ÖQQVÐÜX.|Ø“áÏ…± IŸAÂÐ]”.Aì­¾é÷~RÌòùtÎgGq°2î|6Í |ýWõ¨3‡Úì:>3útÐ.:ÙÆ’ùø:ŸÍ˜þ»ˆwËÁ¯Á_b‰ƒendstream endobj 4680 0 obj<>/XObject<<>>>>/Annots 1360 0 R>>endobj 4681 0 obj<>stream x½XK“Û6¾Ï¯À-JECëýØ=¤ìÙØžT6ëõ¨*—¹@$$ÁC4Jֿ߯|@3©$Ö®·ìRM«Ùïú|3#ü‹é‚þ§ÅÍ(áúÓÇÇw7ÓE2‹ù"™ŠB̗ɲ!rñp‘…X,’UÄ‹ÈB¬×JH.èœÍ‚Îy2 &XgOb9&¹Ž‘…¦d°c¥Ó +M“‰X0AJ#²UÚñ‚ÒFn<â{æ„¢ŸŒXéz™,‚”F$¼™Î»'‰ÓàÎGÉ:]²ÚÑŠÕ®X-$‘äŠ;fLwj;.«¯C­(”‘{ÑÏ.¹ î”|Šd#Üå(GÜ`vÊÙ˜e*2Ûrƒ™žÑPŒb®Ä¼çF4™]"_=7˜Å'uæx´&Q¦È,wÃ| AøËñ"’9M3¦É£9%¢çF4yÄF;n0: e]I’ 2‘œ¬)û3¦Á]ÌPôžÔâ“]0.s&XmOBp¼Jæ3¦Á…Ð7¢ÁÅŒ\p#š\z&Ñà¢åüÎ)üè&¡!œ&ÈáˆÄ(Î'áA.LO"P.Z'‘äì˜ vÌ`pZ!X`¢7Øð–œ Ž‘PŠ^DuÌ7›í^¼z»FÙñÜfä\¬&Ér"6cæHlÒÁDÜ—Þš¬N½6å÷›O‘ÆTV2Cß‘  îíˆ7_@Éà·ƒôB;ñðÛý»/E{ûãU#{K ‚–lð8Y,Ååó/MÑÓ·crv΢vê›ÛyÍ„ú"‹*Wä Å| ….½²;™*±Óá~ý^Äc|9mcžþ4æð|cqsPÂô^¤¦(d™]&ìnîM­óL—{!Åeó¹(Ðß<ÈØêÙLùÿ1ûp0Ö§µw×%õv:MF¸,¾²›yôuUÁºÊÄÝ«»~¹,÷µÜ£§”ôµUÁ§«'éWSÞ¢‰míôQEí¼mŠÿçé¸Úô}™‹À¥§&kÇÉ ÝØ¸pgçUñ xrÂìv¨L‰½*9óô~o°®šÃ„]±³JeæªðÂgØ¢ÀßÛ ÝWô 2L€‘/@øÕÛ­GxÊŠ wH·3;’V‰LUnªB•^xcrá ÏøéV´^º'$­ë*^¦w;eI¬í]¸ÅM‰‘q×zòOùÄ ˜¬ê€òæÔ(¶/–xÖáåæIìàisÆ<~­Å ‹º¹ÞZi ¨_Ûïl†ÝõƺF<èýA`¬®œZwÍIà8ª—¹ýo3Úµ5i[@FU~2gºÇ2é À‰ÉLUªdÀ¥r6µ•AÉ Z®ÿ¾Àìa|á«Ý!ÕXW×–î_[/uIÚŽÒÓë‚6š×)iÓƒØÕ!ŠÇÌ–5Rn¶GmjX)og’Ð M‹@ÖxÐ~e„í¾b¬a:Ixb5fŠ13SNïË€w€_hÆõV ž(éÎMÕ‘ í×Î$ãS€I©2ÀŸKùaÀo7—€{Ò²y¤ !¾½BÄ‹=¶4ªC#t߈7*•ô‚DúƒvCNKóÇpa@@Ü™Bøý¨äNÎin.ÜÙíÁ¤˜ •ì“ff†×‡ow 8«ÄÄ5ΖFYÑÂU*V Ò‹'Sç¸:4fñPlm$úþ¿\¸Ñ._TV¼n›âΟQ~D Ú•ßq{XSY kŽÊž >©Ô©ˆ¯¤õ:­±ÀQÊv>úP“ ‘ÍráÊ…’Óëhµþ](Ž’;†z±ëc¢XêdìäÂk)½7ñžÜ´;×µï ’Œª{áGVê{s‘d‡˜‰“Ìä9¼ëRpOø.r­ya#ÍÀ«3. ‹[Þ'dm`dŠ|Q6Õ@íN;ÙŒ;:׺Ãn‚ÃîÙ[o¿RãÃî5Š+ (9ždáP œ·¡OQ¬BRjᡉۓÊ޾3+ˆO>,^dá£É|8=Ï{ŒŸíÆ‹“wB$¡!‘ lAq’|rŠŒ Eúŧ[éNí ø¹¦ÕC®‡NB‚w5îSƒ58 wJ”{ïKÝY‡eůUHsëÔ³›ç§/)š‘ÎW^Ÿ…OVs¤‘\¿ô®Åá÷Ï—Ùã ¬‹-âLm]¦àÏPdÒKê :]ù‹fÃa”O“¯„ÜèÜzàW* bŸ nÆðªåøtà›òÚánG}Z¼.µÇ]Іo\l¥S_¥ýbgü \âÊòß¹¸öˆ« K;òEÁÃdµ?>/XObject<<>>>>>>endobj 4683 0 obj<>stream x¥WmoÛ6þž_q_ 8­­ÄNš¸íŠ¡Í–¢²ÔX7 @AK”Í™"=’Šãûï{î$ÙQ–[×lÉ{yžçŽŒéÿÇtrÆŸ¼:x;;8ÎŽñãîOXÐÑå)iV²ÑÙ <b€‡|ð1˜dÜ‚ÕQ2.éPª\“‰TZâ·µ2®¬-]L¦³!åÞESð‹àAU¯ß˜´¤«Ë‹!ý:éÝìû!ù@ÊmÉÕÕÖ¾$ÏûÎ~?8¦Ñx?Ö̃ FÇëÃŒ_]ާ­³£ólLÕõä윚×](ür49å=f:Jð8™J‹µ8u=Àø^­ÕG…ž× Ê·¹ÕœÆ©‘VqKÉSÐHEiuÐk^Çä+óYK2|Ä€ÏVÉx÷`|ÿâÄ+_Ô9ú,»P®Í5¥`òÕöK÷ü ó…ßr®r\DqçuYr™në7‘JÄd\L &ÿ1a£É4{±«'UAGÔg©£&k*“$š8¤Š!Ò!I‡HKu£I…`ntA*ñqÓÖYÄWüfð‰TÕù’‹aà6ÊSa8íÒnK€³8åµZè&¾½}Rq3º¼ô6;vèë¥É•½Ï“Jm¹Ñ,œ)aà’ÝvN^Å<˜µÔ¶G÷ý1+M?mÓ±áìYÎDÛQŒƒ”£ÍrK•±YˆÌ¦$ (¨;$"ÍØùk8ýYÊÉ”´õ59 »ÊÝsÛùu¦7®‘•'Ô y^ aÀñ‹e"e£'¨×)6ÊÁú üZˆ˜¸‚RËÊä½ÍèGîûöºQí– ‰ÄõЦZ[S‚jH—‡ƒî*R˜ Ìë„P˜àµd8ú2mTÐͰf¥,Ic°nöåî’ÇîîSæ…;«¾; ¸Z¤%"Fx­VÖÀÌRÉ´¶¸Ô·0­4pP;.äô»Hçsá•Æ2ZÀÇ#8Zƒ}:O@Р Ò¼Ÿ„;7®ïxò Í)JY#ËZÄÉ›£T"ÃP*ŽV`N¶ÄÓ8n“YH~Tx dU—Ý^Z „`ýºçD í,__Éé¬ ESðâèâÙ³!Pc¡¤Œbí×V y?||ÿ¾æŠ™ ¿·´$1€ÊIÅ Ž(U qylWÞy‹ö€_ô\»[ãÊÚ‚B×L ɨ-BC”­i ¼ÐÕ^aÓø’÷DçlÃz¸Y‹”°Á›²vòÜÀâB­°²Ãxâ+T†«…¨@“/•ì7mD¿GÓ(iP¡:׃ëCvoßâ](ðB‰ÜDÈ0ƒÄÀ‹/?~é¡Éœ”~üK•¯ÚhÖJ⥕E„|w¦à&“Ú"8?òNÄKÁ…Æ.ˆúÿé6ïѱ´’Ó^~ÓvNÆå>¬=¦®Šà‘E]Š–Ð7Ö)Æôžíbâtf«ÿËbì0è@_X;K«oͤL[Àù,í°¨°ÂcQ³ð¬Ï'a4±åÑ6!îÌ,@Q*Îö.n%ø„<óôÆŽ±T¯}Œ\BVˆHÀ}ž[v,=’ :: xv+ ê…Ôº* !³nÁ ÎÛè^Öv£$2€ª;Ð]˜« ãqg€…Y¡ØÂUrTÝ–iãw@ÄÊ®àdÏ1)ѳšÍ£ÂüÇCà$]<¡¡/îøˆˆI­ÑUòfüÀœqgfè‰.F ÄzƒA¾b¢+41¹5†&_öüèæ¾&å;™þYE^¢÷£]ÚÊCŠ…Ž­²rØœ—CÛ $}EŠ$­ Xc-n&$¼¥êã-ò@eUg ÷0]qû5ÚQêO3ÌÍ%n<¦É=ÉNèM“2}«¸(á^UDÔ³éTÆm8+ eƒÉ¸ÁD‚Á€ÓÍpX.˜|¸—hjwÌ袻8p¼%TÔo`ÀA¡Ef.i _à݄τ_'øV ŽžÒ%fxz¹Û-§§Gm` “Â׬NtµýÔ©0Ñk:ÉŽ_õì°Õ… ð#އ`[.‚ÛoÈ [ xp\|ðè®éÏ®ðb@í?ŒU×G_½¦1l0)ÕÁѸ;µÙ¬³Õ½­5qOÙ,a]ßü¯Ç\v¬:T=äkµý„w­³,s‰ªG}n\`·Ÿ°Õ§ï«?’Zœdg¸…!/ê5„„Õ †ÅƒÅ*Æ šçû1¿ß¹æ ëçHö®<$—¼íhw*×¼é.{*y˜ÀlœÑo8PºÆ¢N/TW¹S 5vêC%ãâ—ÜæV6|Û‘»Ï ¦ôñ!3±iÄ +„-h”Џ™[$±E'ȃ#êœq.P\D8± ­æóÇÐlîô‰4—yšíº«ñxzš=?yNgS\ôÇBva¬Ó7qÆDxª×XÎ(N² }Ä]‚§,^ö5[=Ÿg§§Ð5å¾ü|ð7ÔC6Iendstream endobj 4684 0 obj<>/XObject<<>>>>>>endobj 4685 0 obj<>stream xÅWÛnÛF}÷W Ò¥S‘ºÛŽ[HÜ85Фi# /‚¹’¶&w™%iYúï=³KÒ¦l¹IûPY©½ÌåÌÌ™Ñçƒ! ð7¤ñ1¿ãìàÕì` °Ø~Øõ/ti¶¤Ñ€ŽŸ£ããš%îÔ€fqpøåhöçÁ€Â!¾&Aÿ½¯JZK‘H[Ð ™r--%2N…¥2ºÀ¶•ô¬ß¹)oJi5%¦Z¤’Þn?] «ž|è˜Ò%áµq9ðe~ôرlû)3‰;HºG|9Û½qøW­ŽÂ‘ÿÉœþÅ„É%…°#kÀƒÙZ²ÝÒÂeIKŒb£K¡çËw.霖•Ž_Ê­)M¹Í¥@d'±Dv™cìU‡@©J¥_m (QVBòµ„„¥Ò‹’™$³äç&B#FÎËÀ²(i£Ò”0ÕJQÊ„[úðñòÍÃÊ¿Á--R_±C×*awß]ÑÒXRH[*½"‘$Š})`IdŠ*^“(‹ÏEYÑ1î\;ïÀã’Ä8?WRK$.¬?§yŽlf‘‡é9 áöÅŽŽÙÿQ4ް„ŠZáh–¡ º˜òáI4á㌩¾\›+(© ö‡öWÚà°´®” ÑG`,4.K\…´ÒТRiÄfqJuLæA¥Q—ô«ÒÕÍüˆñYš45›‚Îm·åŽàÊÅŸàšº¡µEÆç`XB¼YžÊHíˆi‰a„USˆ÷2Wq+¤}úÄxGؾìW…ísìÓ¾ÒqZ%u’¶ôôUŠŠµ°€¸1Ö4O^¡°]‰ óž…b½ïÎá=èR#Šú)ûÕݿʤG“}ªFn§…ãþuO†4ÓÉ^¼ñˆy“[zz‡£éšDÓ}âNüÖ­@°!˜˜®‘TóÒ#©ÏÜT1¢*HËMÍŒ"M±²#¥ÆºNª® ç«bm* 3–Ér,Ħõ¸Qåú¡¢lâïŠc†v Á^;^|kŠ’ Øü‰Å¶(e溈­ÊÝj*ôª+P6Xž²Ù¢@8iø.X×WtÑ¥&SÙ&“{îË’_‹.é-¤Ô·Î¡£W×EªVØ­‡‚é8°J àB,˜f ~µç¸…²±"Žeá[CÓ‰ºý§kˆœh¬çÁ¦ÃEôJÌ¡‰0º†÷Mñ´òZŠ”[Æ­ÃTe0/¢_Ì;¶G[S!¸GEó >¥£é6bÀfc, ƒ¡F•Qþ˜^1áºfDï¥M§uŒº™á ó¿3›¥²ü U}à'èû»:8we~$"“‰+§Jo)^#i¸)£ã{°§óö<@Fo´k– 0UÌþÕ#{áW“ôÿ’ì›ë÷h~>g¬Zšà_öGŽöý¢Ò“°ðNõ§˜ZÇýóßþxÝ$IÝÇZi{ª=|ÓzÔòÿ×t„À›W~‡–Ïmœ[ª¥ìŽ?{,pÞ°ùÝÃH…¨îd›[äE³uvæ'àÉü¨GOæsýäÑÃÍ<÷N½ñ´V}vväÔóS\Ú4L^ì§):®î¶“ÕLW¾GL›i˜g¬I§à¶( ýOw¡0 ¦Û¦êš ©žŽ8n|»usif¥ºôÛyÃMç_7å^f“öuÕœÖC÷ðs<¥ãÓ)þ»i‹©0GúÙÄU&1åóhË€:<ñ¿·ˆ¡›©w~ðééð$šL0™b‚{Î ¯g¿ü R•kendstream endobj 4686 0 obj<>/XObject<<>>>>>>endobj 4687 0 obj<>stream x¥WaSã6ýίءýs±; Úa†KË 3íݵdÚM‡Ql%1gK>I&ø~}ßÊvJz@K 8ÈZí¾Ý÷võù ¢¾#žðOR¼ Âþ¹ýeVÔ¿ÐY8¤Ù’âL¢ðää”f©k@³ä¨RÙ]Ðñìî u/­’„ü,Ë,!ù Š2—áöévcD‰Áu¿²¦ŸëDäýL%y•Ê~Y»µVq8hlnPáÈôÅ#íZ™nOÔÝSs¢¦@ÓmçŽÕ¯<¡ñì¹M½ßÇi~ôÍI®ä‚âÀ ¢EÃóxr>Ïyÿ6–?ÞM§$W‰ âУKÑd2 £Qÿ§LU0åW£0 c22—ÂÊùñŸ¤åüB¼cnV—’]Ö&[­Ýa€Gæì!iC‡y–Heå!-ñ©ÐFR¦ðX—iíØ»¸ø:µYQjã:`ŸCã©ðK‘¸ùѨâQ‰mQ‰GÿêEg«¨o ÎâaïôƒÿÙ^r/Løs}‹?™Xä’ÞÐ(?åi·4¡(f– I[šÅá0ÓÍ€%•³™q/A¿ …#.é™&·–äL•×”‹/5•F¯Œ( izȵ¤BÔ´Ñ*•†6k²«!|Âi³·-ά“¨dá¤Å€Ô—/GY,Ða¶‹½¦Çˆ<ûâ'œ&u¥0.Ñ|ÿÙ®Í÷Åì=ú”-Ñw÷Žè·nØÈ¥Z9°Õ¬ªBþŸâD’â¨Ô~,xkA|N:–N+càK^÷¼öhuiè͉h)NJ»NP; %-«aÒ”yÌ«Š“éC˜N 3ý¤ô&—)—Wrœ²sCÀ0) ÉiFÂM†MK´¡æ,xƒ|ú!“[×4`*•`ô')a]½“ÔD€† Œv6¢<¨¼±í]œ”D§2¤kE<]üݨ:8ÖjؽÙ›Ï8Œs• …³¹1/QÍj×›fkQbŒÞÊT׎âîÃ1œâ2ìû7ƒ qíûA'ž¶>÷nÍËÁisuåûÀˆÞòìÌ1a|n.ÍhÊ[ÆQb,ðý.òWàg¿ü»žšÍendstream endobj 4688 0 obj<>/XObject<<>>>>/Annots 1373 0 R>>endobj 4689 0 obj<>stream x•XïoÛFýî¿bШ‚Z”õòÜoŠ,;BÛ•äK VäJbMrY.Y8Üÿ~ofIJ4RÜIdSËy3ûæÍlþ:ëÒþt©?ä¿~|vá]àþèòÇüî¬;¸ö®è²×óSwtå]–O-κ×=oT¯öú¼åÞåÕ^ÿtooxíuOVá†×#±Ûïu½ëòIìGÞ£¡¬ö.ø§{»'Ï1õ]Ø=Y½bŒƒ¡CÜÇ»°,O¼÷ãò$H‰4ÛRçöšºŒ}¹A>†£K8_’ˆ Zú­ >˜¤&yVØð›&ü¦³ò5­‹0 ÂdûaùçYçv@]ì`+íÞÀ`¦õu§*¬HYÙ˜:8§Å×Ùeú¯"Ì´¥8LÂXEôÒ 7¤’ÃËŠMnB_å¡I(7¤ßB›ÃMÈd4ùåòM =ZîBìW¯°"6õ[žéXG† Ý£ÐÊØ €Ð>ÌwGs©ò_Õ»UPš™Øäx°f“ïU¦‘·ð‘ÊÂüàÑÇ»d4ùNÓ¤SÁA€N5>’œÌ†W0vávG‘þ¦£cÏé` òUBþN%[-&f׻☱• 2Ri•)²ÍrB*Td ¥ÆÚpÁ–![¤©ÉrB:7:°¢ü"\@­=Zr!ptœzx=ñ㹓>eL»Ç4F’{ Î,ñM87ì—eCÊQ…ìÁæ:vF¾G·a Ô8æà£0á8L$§ÙÂßI¾ÖœŠÊæ%‡†+ ò* ÌÀoF<ÑY¢¢f6àÆvà9 #!§œØØ\™$:8#p¸]„N8E_@ öÃÿñ(^³ Z8¯ö¥&e>Ñìfj $>Äù%ô3ÃD¤…¶@u,ò"œ€Tç|¶ú0UQ›%!ïži\䆳fQTb¾)n¨û¿â›dÓ\®d¡Õ¡æ‚ˆbµ+®¹ü¿÷݇kFô7ÛPóà ã ·‘Ôsñ!¹¨Œ‹óOíççBIYmP•z¬8mAXyX$4¶Cb2.\¬s¥0ŽÎ-Ä^4«¥ÞVéëve÷á;5k“Õï‚­rQ Ì.ÏÓ_;ý~ïm“Â3Ù¶SiHG•yn«ÌßA?;'®¼]G?ž|ñ7Ùq1|ò!ß™d°¦¸ÕªªZÇHEv:J7E“ïHéV'º,×'1mÌub¡»\Ú RV~M!»Ðš¯Õ” v´)2Q­0ÁSì„]†U …î4­:S‡Þ6ÙŽs3ðþ63{f{%nlßÕjíŽËÆ$²aÏÅ»~Sq El"¬™põ6׎è 1«l;TÎðÏÉ@çÛÄ¬Ú 'è$™(‚˜ª(É]Šh¥Wp=¿BÖ@ç`÷‘ÜúMûE®XÅ¥ý -–-…r•muNÚEÈu†Î!gÃLQ8µUabó*ƒ®:,J–vfÏ%'=œìÂj[™í5*Òü¸Q$åáØL8 %{œ´ƒ3Ò’U±i¼’ºFFª4ºCöš4Fs’6ÆÍP8[rÓQÐ/l½-û‚¥DûÚZ.iŽ:ÈÂouËafa-S焹&“KÅ8Š\Bq¼ìôÙ¬ˆÕ¹ìTã “âÎ2ï*rc8Nv\LÈâÒ||Y ú™vmQQ*•ÖHÉ>C›{8nº%«IËu–Ò‰þÊ{Y½F^ŸG®”¨ßóú}<­Ýœ@©Ð±uWæ¥slĆÛÙÃÍêi<ù<¾›¾´Äõ|úÛól>½yùPÁ”7g“ûç¼ôÓ¿ùµÕóbººÝOÿS¿÷=‹Î%€­_cÙEÿræV7p5Y>ÎgÓ›~úcùéñaU­>—ŸÞ;¨ÖÞíœ|ž®&Ïóùôa¹Z<>Ï'S¶þ~ûbº|i¹—%ŽÛûñÝ‚~ø¡ÆçÂÀk•Žr±zš?>MçKÁYŸ¿¥ÉÓýó‚ÿÑãCmÌûÏBÃîGE QYG”¥a>‰ñÍÍêËãÍó=§:nÇ³Š›^Xÿ濽½Ç6îgŸññq>v'QÙ©O¤^+óyúÛBÁ¾7^ñÁrËUkƒÛBec¢àêŠNP XtâÃä.; ><[È7ç”ðïRn®”“P5XÚïBÌ„â@¼æÔ-tf9+;)¯ H w @ÈUuª˜£_Zϳß1™ jêïÓC€…¯õ!p/<ºÅªk^ï„™õ²*¹†”›ÐM‚(:GGÀ0¬Ðùpé!íº*GÝ<ñaÔ¬aŠŒ7¯j'ƒ÷}B€<Èo%îå>4q'ÕT ƒcy5“¼ÀW m¸M þh²‚mo2i"bLFèDk8H á–´×3\ÛÂ}³îo|‰Œy%ÌÝ,d¦È¡™îšók4”ì'?7o"{…;ˆeÌØ9§öز;SD·C_ãTÉ0ø.ÓHe%”kÍj€AZ n˜p¸Æý`œ$à ~ÁØ8$\H‹H®/y©ö_w )£SÄ¡À¸XÐ1ã!ÂuF¸Š‚£›mÜM4Òå¿â.ÔähjÒ…,–ƒ…s'G¡ «0>¬·å‚Ø€òèÂíÑMMT¹vÖ¹•lïbà]ö/iØ¿ôFr!ãÛ}üOÃñ‹z;[F±º—ÛWNAþßKþe·ËìíîvÙÔtyöÛÙMiQendstream endobj 4690 0 obj<>/XObject<<>>>>>>endobj 4691 0 obj<>stream x}TMoÛF½ëW |‰‹˜´(Ë®zLܺõ%E=¯È!¹ñr‡Ù]Šá¿ïRr¥C †­7ï½™ï«‚Öø)èáI?e·ú¼_­ó5¾|ÿºù…Šm¾¥}è§ÝcþDûjŽYÓ¾¼Ýä;úú÷ëïd|Eu`®¤ûiÿmuÿ²¥š•m¶ùn‡´Û/rG©µ‘lôŠ=—Ö8Š\&+žðI-S”&ŠÉ$&©i”à*êÅÙd˘Ó2ò‘ÃÙD™èÀ4D®GIèÍˈ"&-¸Fi 6%ö4ÚÔ*8@*6ŠÇPÉ!ëé¦o­“(};Ý9ȨÒÓuÖ7Y–yÓ±›–Âç‘LÜÎLæ¾IÄEŠ­ @ýmˆI'™HkbÌgfʯ |æÒ`ˆ%¤;šd`稶çÂ3Ñ`¤À3œžCgc´G& 1êÔàÄqŠs~À…Vóä9½zªMyª]¯¬-,%¹ÓŒÖžÍo0‹$ð ECdWk7ªÆ÷7dkªŒo8È/iƒÌs5b\N.9‚Ä@-è:™áM3öyWè$/ÿnпLÉÃh ºSÂÛ<•ÒõΖðL5k1ø!ðÖóýóÇdúå.‹gæ7°uuûÄ#͹Iñ`¦ÅÅ‹–3åÐûh+VÛ¢Ëàô8Lhs¡E‰ÊŽ&©hÄ”­B,¥bjØsÀ›øœ>©JZ*ðÝïs·,Z!¯²1©àõ…¹Nà%S/Ñ_§šKW2â]t:Œ1K—U ß *ÂàÖ*hˆÏt¬«TËÄeëí÷Í&"Tü˜O_¾¾Òó¥ž9]¹ÔÆÿq鹯KØP6ÑBAUɺ…¾£ á[]çiQê Ã):\,WË(²”„}5'êIµ„ì6Xè÷;£Ù®¬¹ÇN뢂]Håàß|Ÿ“Ã\ 3aç3Øá Ž3 ™Ú³l'ØAÄ{ªš‰šà²Ík«ËžlÇ> M3“¡q¿ÜƒhÁåÒÝ ìT{ŒäÅg3èƒCp Áë›ÁW€Î—HËÖlÒxq÷ýËît7ëmþøðHÅ®È7óV—eùš~•rèØãÌ–Z7;g?ëñ®þó¼?…žô9¦ØhêoûÕ_«@Äendstream endobj 4692 0 obj<>/XObject<<>>>>/Annots 1398 0 R>>endobj 4693 0 obj<>stream x½X[oÛØ~÷¯`ª`c†wI}ëºÙ`‹MÑ&Nƒ~¡¥#‹kŠÔòbÙýõýfÏÐIw d ?Îý*ý~Qˆ%9ÿßΠÄþˆøãû³$Bʳž)ò@ë$ȦÈEI ~+…—1ËIù!À(dP(5 4[ÎPkO k9åB0§"ÁÆAª@MužÕZ³%lÑ:ˆ)ÊZäi I‚=ªh °6yTÑ@¡¾zTÑŠ£t¦WÓ@DDxâÕ4Ð< "*è: – ÂgŸÎ_ B‰¿‚fk›ô(΂YJ¡«1{q ½™P ¿8V,#J¡ùç8Ö” ¥ÐÔY•ÂæL(…ŠDHŽ×Œ Å(T„”ÁçPñÚø‡cbÃ%ƒBI„ Vô Ê£Š ¿Q2U4ÐõŠËÍ£Rªéj,™4^K‰^EƒwB¯B‡ÙŒWÓ@Ó9¯¦ÂÆ¥’¬i +άÒkm^ŽíemJÙìPk£G=Ù<¡£Í#oœ¬«tBmÓ§ùØ#V¯PJ¯C­*zÑ|)YIÌ+ÉO3[Q˜3(”V4’G¨*…*(ªjÆ«h ËóBñ*Faz"½“^MMV3^M…$„jâ•öJ‘sž&ËŒmBœõ$»²;¨i É’ÅzTÑìì#^EäÌójh¼âšš$ÇÑî%×0Pä6)6YÓìl>G1sY–7ƒÍ¼0B²¼žïŠï…*ú@IÌVx4‰xAÇQŽO )ÿµKÖ4P¬T£ŠŠeÉ"Ix} q]*4½agvàYóFІG¯Bû®ø«h (‰X¡?]ªI¥ö†Þü¼FmB×åçT¾ŠƒeL—[9¤BºÜ,zgú¾¬o¨ë‹¶7[jjú\ÖÛæÔ½ºüM‰DÔC‘)Æ3 ÄavŽÉ›f9D.~©!¡ªŠ¾„„¹~1b½‹Q2½½7›¡/®+3WâíŽÑrŽ#,L`=دâ,$æ8Çb —¨qû4_ÊSá–/år?S~ÿãç_Þ9aIq8VFœõv²3í°a_:Ú5- Ǩߛ‰Ne¿§•ÝP 9ý°-¶Ì˸øáû¾-ƒ4]KRëÚÓNàõ1”+îŠUðÓV/«à¡ß7õ‹ª¸¼øõEåxYéÃõÃRpŽ•’­i%å>5ÍS•e›ì|=µò³ª¿AC´´iDz2í£!êd`<¯—ÃÕÿÖÌXhS7cÞ\<ܜʚŠzKïËúÝgœoÆŸ†²Úʘ;•7¹7ßQ_¾i{_„Zñÿýñ¥å©È$[û[&XÿϪ‹ª7m±~g‡¤wâk þÊ@‹¹ÐÜ‹ùrVŘJA|êÚÍ^3k•¼q2?74O,“|\1Ï]&²IïËMÛtÍ®'sß›º“ÁEh{Ã-¼ß‡²½}FƒðššÛñæg·oÏqY­Ý»Ü—möÅÙ¡­é6mym:’Ý6tŸ7n´# qMsDå]6µýZˆY|sgZœEG'SUø+µç6еë)^‹" }5®õ€>‰¼$Ñ•üƧº¼§ª¼5d껲mꃩûÎ6«ôÕØÁP\T]§úce°R9dø “C†#!³oã'»ã¬¤¢ÄÔmƒhÕMÏÓËØ]ÎF²Î]Öú‡£¡R6Ƕ¹i‹ÃkÚ7'ƒèPÙ Fz{øUtÔ7tczwNt ©‡1èzsœ°hÍŸÙ9Sö4ùksª«¦ØJÀ:Œ*iÿ)t,6·œÔ]ÛœO×Cö¶9™ëöÌ_qݺX5K-kX[жlͦoÚ¶ÞH*¨)zªÙέÆi(6r ñiÄas;âþóØ3?ø¹®]k>9ú6CèTyÐ]Ñ–|&¢&º©Ì·0ü»Ap&éÏ®óÉ ‘M»EF4Úن〱‡ž„ÔÕÿÅ?>ÏOÜà8TwH²4p"UˆÒEL¼•®sX…­[©u.$WÛ÷iy=ˆå›¦F§àPåLHq;©¾_ +/¾×tÚ—›=JÍŽÂ÷$¦k2êÙίfç {M¥­#紽ΤŽoÓbªìè¡èTÔ=ÇO&?i Å2©¦}qgPoUÓÜjk^ S ¹þæ_'¾’ŧgD<Š®ˆÇ‘¶â“\û~zŽW>νÁa>4ŒŽL+Ž˜ B Ïí-Ä­Áƒµ*ë[7iÿÔQ3ôÇ¡·#Áá›Ñ™7ZA;srß0X7Ôü†j¥ÆbGW‹`Û-qõJ¤v˜d˜ØüâvØ`r_?hþ< ¿¼0Kôì uûf¨À‡4¹/g.óð®9{a¡äP,ÈõÞ@çÌ®€Þr,.~p$„¿.Îû… ?%„uMe ™CVt]³)QUÛ¹ØYçñH6˜’¨S•š|Îaã<³ÍàµÍpä”Ù&;S  ÍÐõ³¶ŠÛ¡ÂØçw×#KPÿ»bc8åÕ+IG@ñGSõ ]ÆEóz4iž:eRè2øšzß ÙeÍwúÞm8ú +œ$óD¿Ã6å¤úe7ÁÓ8AÔ%O2E®®HßàsìûC…Jc7dËPccä´K‚xÜÆÏúî0«;+Ò:jè½­»>²3b“Ÿh²¥:ê†ã±*a÷¸ä­¶ÁbŸ¶ší.“ãHÿ©iozÏý\õÍ€-ÛQkø`›O¾Ž…¯ï&ˆAÇ ¤¬ÙøÓÅO¡RÄøA³˜î-_»hÌ„l\ÿ”(D–Üšs÷ó TËÍ-×nQ?ðXÃ`«×ýdÂñ[ëОHßù…'Ã/a˜zrtF z{yöϳÿ:¡tendstream endobj 4694 0 obj<>/XObject<<>>>>>>endobj 4695 0 obj<>stream x¥WmO"Iþί¨d?,fudxñX¿)âžQ¹Ý\2ɦ™i¤µéfûäß_U÷À‹Yƒ12S]]ÏKU·ß+)Ôð“BãŒ~òIårP©%5|¸úežàôº i #Œ=ûŒá=þ‘W…®fÂh5áÊÁŒÁ†’Ûî§\ŸÈW6™JIa§0’Ãa=“Ðùô æBJÈ gŽƒ¹6/vÊr#m`¡=dU\7ë²£ºÊzÃÁùÑà¹Rƒ“´ŽUû\rf9 ½ 䎩 Ð˜»ÏãÛ Üpdô„^ÁeX€ÕûøÝðï^\·0Ü»v*ÙcæÂ)‹0ÅäÞ˜H‡ôÈEù®Þ¤Bi)¬=:´1ÀY>†‰.<ò'™zòì‰<&­y°Š!—zª_„úP±ëÝX¥:–mFYAi·tê»Øcf”dÑ0F9Ö±2¡r鑹nOøë² ¢Ýºå´ö–J¸¹ú;Mçq<+Ês œºëÏáê<Ëž‹ŒÏ²Ò8´n¥Æ²äÍH,/fßcüÈ%´“}"Þ­ñ´†7²Šå樂¬}-*tÆ·)?ƒþÂû碌¿×õý·QÝ_Uû…”„%;*õ]Ó)^‚1*L1Å9^üâ5îÎð¢Pp›1Œ—$:»Jôíòt¨×šI«Ñ‚³6ý¯P}üÚûó¤‘Ôàjý²C„,#Oþ s¥¨†›ô”uÆ£ÄZÙ08ãID;•gSy±Û¸_PÂVš&í6þ›‚¹Ò&=é*ÿTþÓ øÏendstream endobj 4696 0 obj<>/XObject<<>>>>/Annots 1411 0 R>>endobj 4697 0 obj<>stream x¥XÛrÛ6}÷Wì[iD“ÔÕ~‹o©§q&•œf2£™DBb’P Ò²òõ= €i;IÛŒ5¶@‹Ý=çì‚þû(¢?õGüIò£0ñ„Eükúö(GÁˆá0èSNqØÇ_7ÊhvG£öì[[³Ñ$ÆFÁ)ïÅÚÐxoÿ”ŸG7;ˆã`èG<Ûç4EAÔžm1;tfã(æqìÏ ƒYŸ[cx5wg[ãœúá8KÖgxy°Üv-·Çð*u>DZÍWì,Ãɨ—›­*ú±?°γÍ~qíAæmL@ &h/17“˜n S•uR)]€šˆÎñŠ è™fh«¹Æ£ÙÎ7 Oiºi´y€xaöfI;]Sª©Ð­Å˜$ÒXèþT¦]üú«]´UYæ–Vˆë A_­•‰¡º÷’%㼃i8±ÖF{_ºƒk’u#:92°ƒ¸€!Äaé¥åN&ŠU )R®Óš § ª+Ú®EE…”©aw*~—\JZ¾o× ær±£…d«Fç’VµJE‘ÈF®§7Y%ËBTêAf;4oÛŠ|Ö°,éb·¼$Ø“”j!Sö˜Xê,Ó˜\Áе}r } 8Û͉K<·ƒÙ§›·„ˆ›EJ·ªxûé%´&†ËîHÎÏŒæp<Â) l.ëÂGoÛmI¨{Çî îdS têNÙVÆûö^ÙŇ_<8½ ƒBJHÐÇB=Bv÷ÈH ¹“„kÈÞ'U¤z‹Âm¦H)»%ÌRw•$¯±ˆÞ¼ŸÝÐÅ ³¯áq@¿é­|åkW^À!¦­ ”ç8hì+30bX6¥\Ô*ƒ2©+±@9ÆFSo6™’餧‚ë£ccgj!ݪ•-üÀËGòLmQ5´)%JD%­;ìKjiØX¬˜Æ.#6ì42UdZ¤¯=«ìV ØÖª ʱ¤‘ˆ…|G)$k™+£§/Ûn"'*S³¿@EÉA~¡iMm©XÄpž6aAj ðhii ö„™"¿`hÇ‘|Y<(PU½çã2Íö ç¾Õ³DÜàw®M…®«¹ÚâÓ­V…F ±Ûži­Û¨ 3ô²—€tuÂå”9y;û<{R–ÝgmÞOb±(僘,ûNüA`é„;¡ïÿ\°¢Óµ¥>ÃÂÈmæl’ž õ»‚3ª’²§ªk¥— ‹Ïº§x4ñ]¼7FB¦ôxÆVô‡+Ïyö\Û‚fý¬m'°Êî„íKŸ»5¹Ë’d9QjÈóÐýABGÿ†y‡D"nNgE3.ˆ1ßT/ÆàŠö Aôâ .‰=àРWÉ ¡ÍþÛ‰>5b³øðäsĸࠉuVºP˜ÿøª¢0z G߀Eü-Zs½ð’W [ *6Óñ‹»»^4—%›Í¶ þÛ&  ôB|¯¾U¼íÖó m’ëØUºr5wOº}ð)ÆËDWBTµäŒ ÔJC:\ö®lQu¥“‹2亡.SÜ@ š-j`Luñ ® ¨"—kT¬³—´B ¸ÚÐRà&¡ð1hmÈg«f¥r)ê¬ê¤Ô#å VC2\ŸHðÒ—R›âC>ÜðÿÈopéªvŸÀuPšÙy­K\göTúŽÁA:‘{¾T m[*¾üXŽâžóEc¼ã ùfªxP.ê²DéE¿ÌðÂâ*¤™Ñ±w¢ÖÂY!6À®â>pÅÓµ½DâêèD×¶°O¸›²RîqÙ {÷LöýäúP~"d¬ß aø¤¹Y WK ƒ(êÅa8ðéÿ¼ÙÜìÌåÝïÎòOº¸PFx1 {ìlP‰2X}ý‰Ù·ž¨+w¥%¿ðZ›‹¯ö•âæqo4ÇaOð:Ážþg«½þ08Ó©­¬Qà±k:K4žÃþ†øF¸¿±‚ !]ê¤æ¶oåÊéž»¸7æ‚ã^qø&SžFprâH ùÉÕÝÑGÿȯ_endstream endobj 4698 0 obj<>/XObject<<>>>>/Annots 1418 0 R>>endobj 4699 0 obj<>stream x­XmsÛ¸þî_¹~¨2'AÔ«¥|éäü’º=÷RÛmæ:š¹¡HÈbL<´¢üú>»H1õ¹½I'ljÅî³Ï>»ä¯gáßDÌ–ô“g‘Œ°B¿&ôëîýÙt=•K±ˆ2…˜MVrê¯rqvz»³HžŸÞ=¹ÆÝ%lžÜžŸË¹˜¯glyºžÈ™¿"Ë§×ØËÉÉÝÉr.×b†=äÕd —ýíýáá$ŽÆ<Šñõ\L"ñ°£P—kü•r¤ø#Ü”µó\Üfåû£™„ÝÑDªÏJlo7^Y-Rµ‹›ÜŠ\'±Ít)7oÞ<|:Á2YL¥ k\Ž&SZh-ßÿ|“‘œLFÓ(šKüÌü!RÜÆOJÔQ⨑yo2+t)ì·âB‰CV¦úLö¬D®¬UFĵsš½hOu^õ±Þl£ÎóÍ)nœÑJ×¶=«NLVÙ!™>Þùwe}ÀGa5»ñ]ªÙÁCVïi-Ñ¥Íʆ\³X€£§6ÿôY_OVx $£™j3]D U—w÷¿½»O‡ƒI¥ßtÐñR@½ßé‘7£¸±ºßÄDÚØÈí—é7P¥µ :îFS¹XÿŒn³Z—0(f6øøå÷9铌rB’È.ë÷Ü2Ê j¢‹".SQ]TVПŸ¤±Š1_Gb„|M©Ê#9›á*$©“[¼H 0+FŸ>ïD ˂ͅ÷ÊŽì?ÿ'¼ˆ‘_•õh‰yëï²ÃaÁùž=+syl)UÏ*×U¡JKë5DVè¸ÿxóžd,~޳<Þæ 'rô›´~ÀOcã{èR³e|Ú‡BC0ÈI\Š­Ö2×qŠ2‡¢ÆâKV‰]†S´¡Ý# žÝÍv\l,C°ŠA¥CñœÅt W82lr’}t}W Í‘ ÿåëßî<­Ë¸ª÷Úñ¢)É;bˆQ%5*U«+´@GE cKÁiÈÆ¸©Í¸6ɸ>dRüDBÆ!};ÑÔTâp}(l_ ]õ¿ÎÀâ)ÍLk?œËBFäôçöÖ\’ëR‰½µUýv<Æ %Qì ó‹´m|½ „¸?Éåòœ¨þ!³;êÚ¥n«$ôø¸q‰:Äàâ¯ò8QžE%œf»~Öãõ‡ÇÙ•!’IÇ*tAU4”Ò4ÄÅäx©C×Cð+‰i#å‰ÔÏj×è™p}6‹y0àôѵ{/É, <§ λ¢™DmÕ|¸¸»‚ÍÌ@5 %¨ lkbTR©TZS@ ö¶É0®”ê3xyéI~JH6RëÆHÇx1‰ ùŵ³ ’¹] T‰Q£•„õÄ»Å~øjmÒ‰ŒÚoT¤Ë”ïÈ}½¤¸{í©H©Q‰Õæ(ň:—3¦;›% >=Ô†#?¥æÒ2æàµTbÈqci‚ë…õëµpBxæM8‰«áûýX)1:e_uI_p ù£aŒ±ÔT~œòXÆž2¯¡;®apz»Öí;‹#ã€îò ±È1ùQ•©¤SóÈ1ËöÖ© ½mÛÖ.Úñõ:ÐmŠ1t9§:ŸIšÈ§.«$U!¯\ÇGT^ß: oþĈ`Hâ¦@zçõIm88RüY ¢fèžæ7Jþk~1¶îYqùã˜qÏ5j8&Å5OLôTˆžËõeö™[…izm¨iÆ$ÎÝ]½»¼½r­Æ/±›FClNÝEA»¼ª|ÎŒ.¹U²§*!qµºç„QÈ„†ñè”H„Ք݀0ñìKL«›ªÊ3ˆa;ß•«R–fµ5Ù¶áw ñ°WX£~‰Þ‰}Ŷº\v‚–´í´Ï¢î]`ÐVÚǦKè#)RáíZ’™¤)Pâe‚ó½v‰d—ôæªÓ§Ukkdz–(Že³XçxÓ*¡ ÏÊkbv³ï6©.ÿhEè9aPöéÒÆ½B ¹‹œ¶ ”hð k6—(‘€Ød@®¸¨r5ksŽÅ‹u¢Ó98ÝK4d?Ni”A ˆÅ?³º‰sqñý÷4\~‚D¶tÓ†^w¨QôtÁÉ7áv²÷æòªC¤Þá=n„õõ9wMY¼½Ó55´þµõ´Îz(â[LI!bP ¹§™pT7H{Ðæ‰”F¢ë]“»ŽéáÅœ—è¢pÝ®9]áÉ-Ÿ|âª(tÚW[¦÷à{‚À¢:µ?|þp´{]ñ¥Íñƒ2ø}×lCñŒ£ìæÅNkßMéÿ=õÞs¢­ý.=”l—Š9ç’±rÎðßm–]ëÅ«Jš¢ž›Ò´§—8-Wüjú¯øEXÁÌÜ…Ó;—É0c[Tøäbwô®)YíDîRО1r±3-ö>/XObject<<>>>>>>endobj 4701 0 obj<>stream x…RMoÛ0 ½ûWð2À×Iê}`‡"kQ k°ÍC. A¢c­²”ZòÒüûQ¶ãCzl2õÈG>¾× ˜ž²µyÜAÅœ>ínî CQvý‘¢¿§ËÒ:Á™R³âOps¿! ã5¶ÒƒÔœ,Hí°­G¨¤Â9 y‚ð4À"yUo΀@¦à$] ®F‹ày¥>7ú/j'¶tcºCÝS÷ À”5¾X ‹$¥ÞCB;&=ô|Ć-T¦…ši1k£Õ:‹bjÛ‘ËJò>É‚íx Ì^w_–4Þzù®÷«!ï¶Û§ÿa6»íÏÍhõQsÕ ’Õ’/gÓyÜ4ßÉtJÓg0$SûNq?-¾±æ¨ðÓ¥±<Êü~S*’¦Q–ÑŸ?È‘éË´•¯# P–¹òÒìC¡¾Mëö3øý´}~€É¤¯Ù‡ý@sŠ’DYºŸ}¸óÑ1I¾ŒVÙ òõ…þ×îña‘E1l ïÚ/óöY‹4À‹[ïKfѾKÞk*GÃ9Ô¶w-uTáâ¿×N¶/ÖWY%I”çäi*ÜúÈ·"øüM˜çÙendstream endobj 4702 0 obj<>/XObject<>>>/Annots 1430 0 R>>endobj 4703 0 obj<>stream xµXÛrã6}÷WtÍ“·bqDIÔ%yØšqvv]åÝJÖªÌK^`±& -ëïsàt¼¹T2e—Ê­&úzú4蟮Ršã'¥åšóújžÌñ ¤üñß^-×ÉœÖÙ:YRMYš¬;¡¢‡«H¬i½KÒH‰5¥óM²‰”± íb71ËЮæÉ*>ÉÐfÙÄm,C»EÑÙÌj’ÉØ®|2£XÓ†óu‘XÓv™,"]$r*sNt0Ëìnb6–¡…—m|6’9• ':ZŽäšó©ßÍ‚ó^.|¢\í^âLc†WkÙ?ËÚpypÃÓùš‹ä¥pt”¡]n8ŸAŽÎ·áhšòQ/ v³]Rš.Ðò y»‘ »Dk#ZTqi½×lšºË’íF"›]£s£Ò£!ÃqÎtÃH ‚vqI ÿ¤6’¡]qg"m$C»K9ÚálˆvÊ»ó™xÁG;Š8¸Ì8¢AËÐfÜáHÉÐn·\†ñl$, į̂ !­º¶Í—€Cæ¥ë(ÃðbɆGm$‡ ÐÕQ‹ z™ƒÚp%mp‹&pùw+ÖyÁWbÙiÆfåO´Ø£w¥+èÒt-Óò‹½¿K×ô­¦ï¯>î#Jó¼fŽôþÓ÷ûl¬·‹d³ }áyoNûüzE¹Q'§š#Ý‹æØŠ£´Ûÿ/²åéÑÛZl :C «l [×ûR’;kªºãô¬ä™ôgmªbjoŒ-Ývg +˜.®\¬74}þ—þùéYʉ\ÿKŸ©ÐÒ’ ;$2DâDõDNÓíßÙ$‡N}6ât’†m“;¥›W¿aŠ/—}ŒÙü7c Ïwþ~F‰ÇJR¥š'”zšà_îî9Ѹ/Öƒ3mîZÃåo Ê+aíkôüåÉ}gôËåÏùš-—É‹à"ÎÎõÇVUËx“/N6¶Ôˆ·‡RY ûHèÊU\Q«œ*-ØÞÆÄ}@•+ɾŠç û~pÂq¢ü]ÏPÓ˜%Þê9i¶à=0 =Ý—ÊR^Š“ÃŸŒ~V…§ˆGÿ@úYšž£~­‰|òhD]s·àLhµ„ÝFÙÚÒã…Î¥ÊQΞy|{’XH5ãd$>1(y.­¥[oðö«¯(×…Lø çêhÝs5çƒ?‹ëÈî÷QìXŒ9økeËç?—²y›Q£Ö– È\7Îè ÏÝöYßøt1Ûmå·ƒ½X'kÀ ËG*­ŸHX:èªÒgûuŸ{6O²ÝŽ=ß50'qkd[ÓCÕÆÍUŠúèÚP©Ž%UòYVC¤çR ÷Ü“¶)¤©.ܦžÑE¥Ü¥ÉoŠn!ݾç¢w!±“Ð.Cit ?ö$s%ª±«c|ïr]×@‚MÞÑÝ.º¥R!@sh+Ô?HŠ«!_N•V.àÑâÉæèJËF$7«·PÀ_.œžÃžÁ^‹U¸ @Ür´™×+¢©T.š†q:ZNØ'”ï¡'£Á)¨Ð» ÓÎ.pýQáVÖ# rÚ]N˜!t— Kàfhò±=ý×o|<“‡ Á®è…p¸‰÷‚?Vc¤¼=aŒ¸Ø_'¼càw_ëÞ¦½·Ê€%LXߎF%eœ ³/=5à1*á9u¨íG5ÜpŒ~ÆÜ½yžÓ`ŸeÒ×aa€)Mg–™jþPKþú¹»*¢“ÿáîWÕ…MÃ,~=FÜ0ãÐt)!šƒá2¨nÅÀa¼°¾ü}Å_f^ m?á­m9@ÞZÅX8EA nø“¢°÷­ó!‡~3 `TÃÖóí‡ïî|‰`Ÿ »HèSk¢©µigPR©ŽH½»ÈèF&ØïúYJ;¶Ø:ÐÀDwB’ÀK^mÎbÂe¯ˆã’‡a5žÀ¹8"ŽÝW,"ò˜y42øä’á%Šau´ßÐA_ü@Ø*Cꓪ¾;‡šwc!<¢íg¾øZ:V-À"ÝY"ØW™ù‰æï"¢½¬%| öñ™p`Gœœj<{ù%$uë¼Ë.P¾;rp/ãVÒ U!Îá1ÜŒeOý}oÑwsly³Ù@@V3^\é£C!_Ü$˜0jex¿#UU-h äéÀo¾†u4Ô¿†b?â?né<ó÷®ˆIïã7ã ÿíÁÕÊ¿<¤[vùýÕ÷W?ÌÓöendstream endobj 4704 0 obj<>/XObject<<>>>>>>endobj 4705 0 obj<>stream x­WmoGþî_1%©„¸p`»i*9$Ž¢FušÐæC\EËÝ[ßí’½=©úßûÌîÝ6vÕ¨62à×ç™™û|S¿1 †üJòƒçãƒ^ÔÃ?›?vF/Î(îÓx Ùáé)SÞ£qÒ>ŽúQL¬X,¤¥i©§Œ.Ç<¾8¦B|­Û?ŽŽq±ý¾\,L!imJš‹¥$¡ÉØTia×4jP¦®%¹¹*臠«G§Ñ€•õY[? ð-m+íh*wå?é«Cú‹å!æÓ6U?jJWmM?>£2VºÒjŠŸî••¬DôQЮ»¸·+þ÷n]ïØ Ÿ°á×>.äÄI"‹"„S§ˆ¦Öä$¨H¬Z8¥g” =+ÅLvH9BàZò-Î T¬¬rH ™(‘QkRÞÚ¤ÌÍ…£BÚ¥,H°5YG‡Ú¥íYVJšH·’RóáË(FêJJ›­Ù«MM":‡»…¦¼,¥·¬ôÓ³ªdªÎ–_ ˜Û€ƒ„•¹ÔnÂ^.P颴|[®q(i)2•F!½ñi¢îÍ×ôªï&ŸÏºŒÑ´=YæƒØòü[U½”ÖymàÒÔ¡ª456P3Óê«Li‚RíM슥Û?ÎêÜs’H~ù"2Xý8Én×®øÃ)8í‰×à½:ÜÍV{11 a¥Ÿr5›;ÊŒ¹® (d–™Cáß™ÈðølŽ2…¿NPÒ|ì°óŸ^k'킎E¼wØ·[|mx ~/I‡’¹°t„ÏËÜMsˆ[Y”™Ûåê u½;N¹I°5úîõï4²¥ þw é“Ò OØã¢µßF}¹ÂÓxôæÓËwï.ßí—ö=æVr ¾sÂåý]~Œ‘’ýçBYøê]¢Å¢$SßJ·ë´¾O[*­wÝÝ çòç]OöõÉAÓ'/u²5 +…“Ä-„ìO1(2*œ\p‡ ¬Ø~»°]òj¹j Ñ˜Ç ^eQ¢W¬küùî‘ÍôfÒ)­Z­ú*x¤5÷)Á¥ Ùë®M«yÕWs“–” ’HeÑÈÙPX¤˜v3OÖ@¾f"p87š6s=Ð Fµòs©PRJL*¿£<«AA…‘y›ŒwbžEG¾8#“çèÛ5J:Ôbd ù;`цþPùËooÞÜOóšõ{ðm”§/d†ÀßZ“ÐQ¥é‚`¿à®œü"“Ðó-ŠV °ÒfUí(˜Å+¤Ü^׿µ§ÕÞh³-Ô3™w€*±Vø½Fè5”Úú^^éõ3‚w?3Ï377ålîq²@ø¼@˜)UèÞ£mä0RæûïðsÙ2•o¼†”‡,`)²Ü`j« ZÍ<Çè-¾ŸÇo×°¬koÂL}okì5+Hµ xN$ʯœƒmžé–×’‰ ´3}`åŸÁ]꬚¼ØLUB©tBeðΦj:•nVt³‡vûCö¼~öéwa•˜€s™Ò× ×n|NÃöyS1Ah$˜¬È´äœç{ÓTÐèñèÑ#šef‚–µ%?ÿ›ohûÿ6y}Øi6MO(v¶â°ƒmænmæþù›š’Spa Fà :ñMx³ƒß\O]5ìQ9­Ð‚9 °¦bûÜÙMy™ Î v17+4à 1W‡÷;õPÀ™‡ìÓag ~? —¼Dù¦Zgïu^ Ò‚A¶dÏ‹BÍ4o‹¡¨õ6ŸG'ƒÏ¢8< ¼ÿðúUwõè…Iü~Ù˜@ìAºû$<ÜóÔrÇžq¼Gñ}9>øõàé¦îendstream endobj 4706 0 obj<>/XObject<<>>>>>>endobj 4707 0 obj<>stream x•WïOGýÎ_1JÉiÌalCH«ªjD‘ª¨ ”~(Zööì w»Îڿ½oö~ØglÒ"ænvvfÞ›7“/{‡4À÷!ŽùG{o/÷ÉÛ_nBçc:ÐeÛã7øÆ÷ø {—–fÎÎuªÈ—rJBJå}ŸæÂiq›+OÂ)’¶(¬É—T£ge.‚J©ôÚLHÐLhG6£‰ ^ÊJ#ƒ¶Æ'tn©{QÌrÕ§ÅT5WŽÂTÁ^ª——Ÿ÷´8DH=xíµ¤=9%Ò>ž=ƒãg­W~£ÍÜÞ©4¡ ]è\¸|¹Í;ÇÔõ(§ÂLTå‘vJ‘çðYÇ4sL g¼¤çJ1Q( ›y 6fñ(e¼6t«H„ äE‚¡â\W„„IIx¯'¦P&)'‚u¨ÔåT9•Y‡:5ö\ÜN…Lj¤<ñÛƒs ‚Û{~nmõ¨Á»G…žLi  ¥@ãobo‹Ú©dXÎØ-Îéo^°°ež®¼–&UÀƒ¬sOµH£&+&IJœ¿!æótxÌŒ“a2¢S)|÷r¶' ¤ð ’ S¦õĉ‚@Á\ß:ᘽKJU¦ ¦nÂÌê‘®LÙ\Ô¡îwM)N ¢òňk„¿ÒÞ7µÇOgïˆhpŸe|5 s·µ&oþíŒMØ Ë¶š¼ÿtvö1š°Ÿn¾ûñâQr|üš½¢u qÇ)ÔÕ!1htmŸ+‹®Œ]æRzP ”Ô†¼tz¤†ÙmçùìB‚ÝxzýG$á 1뫇+ªÆ<7,›Þ«ôàJ»P‚¬KbÆ>ŽØ·ÂuÚòØZˆ$”#&×4 r²HÊsNzU1ˆIéë[(8=×"‡b)'µWO‘rLÁ•2”Ž% Ê­v3ô§ŽÐg”Ú §¶"\8mp©†ÊHE…Š^P¡_ f•¿LHõ#6ªNì?Œ±ÂúÀÕ,³àÞB8h¾’S£¿”€ lÄÌI#ëºEC¨m]qQW‡*Tq¸¥‘OyN£:uU£¬IîFYãl¯íhZ¿iÈ­šV¡+(#‚ø«¹.ŠD.~U/¯{×/¿ßúþŸ¯¤×ïûËþC×ÅßñÏÕÚ…oÔ _=cQuãQá"jZMº zn±s°Š « >-ãu®ßµ¸ÙùÜê$³Z›æÜ|³uzÕû›ûì ×½ÿh½ü_Ö_±Ža·q`,¯ÅÑG7DɹߌýÔòfÇ©åS§vz¨OíDø£]ô)s¶Øhgæ>D©Á´Þn°oAªx³BÃ1üþi¨_ÄÕdN¬°þ³Cá5ó/1Ïç4J޶[D¤`±ñ¶C’ǯ“¤ž-Í¢¶1Ú/4ËÐhvuâJû"ŠÌj  B•`=•À½ýŒNŽKÁº8F!ÄØ dTµªÞ»h2‰K9–ß0ån·ç8 ††ä6©á£kûhE¹êa“h¯Nü¤^Z‡ƒqr4:¢ã£Arªzñû‡÷û£d@ï¬,Û¡ÃNP£Êvÿ5/¼Õr8¤«ú*ØòÌBeÓ£ÃÃääk$¬†q‹:»Üûuï_lI'òendstream endobj 4708 0 obj<>/XObject<<>>>>>>endobj 4709 0 obj<>stream x­VÛn7}÷W Ð<Ȩw%Y²â¶¨\ê4@€¦°Ð¼((.WbÌ%7䮥u~{Ïp/²j%yiÈ/Ã3gfÎ̧“)Mð3¥Ù‚ÿËâäåòd’N°8|ø5¯¢é9-sœ]\^Ò2‹ûZÊÑ<=O/è½w»†¤!¨pºüx2¾žÓøJr>Oç¸4zkI*_ ßÏHW¤•.½2Š*GuÀ¯"㶉Q÷ÊR…à<嵕•v6ð9镨 *÷OŸ‘0ÁÑu[K"`3lDæ¶-°”^02àa_²Ñ£‹ ‡K%µ0t§mF.'·ú¨d4¢¢µªB÷fFÀÓÒë²ÒvMFØu-Ö~ ۯƯ~ü±}˜nG@*_Ëêö´½½M4|€È8wÈè»–çõZ[j¯Ö^ÁRD£[êØ­@ø††'oOSºÆ£j'ŠÒ(SãjÚˆûÖvî fô|'S¹¶š¹¥ŸÛèMè2qøÎ9~çél†oÙ(F˜þ-0þ¹8ƒÎze´Œ×™â¸FÝ¿öÂíèöô—ƒ;ýþ?ß;9XW´;kÎM|‰_÷é–DÀ³t±xΨ^<Îv·Pr#¬m]m2d xˆÜ ©ºè1Ÿ{Îc´ ö­¨jš a­B>zWDîµ­”/½Âç!í½³1ß`ç}Smœ=‹Ïz½©h+,2ÌQæ`I‡o³uuE÷ôkÇ?ÓÙ?ÙŽÛéfG֬Ϭ?`=™>½‘¦é“ÓÊñžW¿Ê÷.´Þ4H9ø«¼¹h½E¾·¾‚ÛÈW.d¬˜­ów}΀gì½UÛŽÃLxvŸ\}Þ}a÷l4¼1?²ñÀ àX͆<ºæBì¼ZJó2é $R5Ã=Igs½æ:Nv4£¤¡9%=ûÿátÿö‡²Ó/`J™QµuPµ«¬¦!H›$Î2ß1MŸ*R',Õ6C¨š¨Q¸Zí2 &ð¥ò¢`‘ç,+Wm†×Õ§º}&sȾµ€dKÔLY{È|§ù¢,•ðzab‡‚†V5\]º¬ ^B¹öBúOìF±£´Íå²m.sèÕËZ›Œ¯=uRX)¸}&0ëÛ<]m´DrB £äª’y«C‹âˆÁ­†óUßi=œ‚F‚b?É"’x`ÿ6×z”—§ÝCWA™ür1LǹôºÁ-¡üBnLtæ#ËGJì”(WÞ«Œ*ˆÕŸj¤@lš+æœf‡t'2Áâ:€ìó¶‹^b 'Ɩʦ^y`AS5=(£F¯FÕs—‘È(¯¤+JÍMÕôˆ»{Ѥ=•$G–± CB$åñ’œ/XÝótJ7Ô#â~ÈIݹÝ=Çbg’å£QÓÂÞPC öõ»w­K.Gö@zZDܨ¹ÄØ5¤+òžJ m8bÄ;çQÀb´½ãÖð»Ûb¢ñ(Ú: á”*caˆ…C9$ ôã…À@¥Œ3<Ù¬ZÖ·;Åm)< W´ã Ð:–Á Nk))ÉKOÙO éð×ß[/J|MÞŽëàÇÆ!uÆÚJSgƒ#±!»’7Ã}×ÿÕÞw” +ipè׈ä7¿Ó¶Þõ„ÅãÿÜh¦‹z7*¥į‚__v³íôrž^Ì.h±˜¤óiœn>¼}“ÌÒ ½v².”­¢ 0xL&íéäy;}et¾˜NYŽ¢ŸçS¾ùÛòäÏ“±‘ Èendstream endobj 4710 0 obj<>/XObject<<>>>>>>endobj 4711 0 obj<>stream x}WkoÛ8üž_±PÔE-ù•¤ipÈ¡¯Ü(îz‹^-Ñ6/©T÷×ß,)ÉV’M [¢–ËÙ™ÙÕíÁ„Æø7¡Ù ÿeåÁÛùÁ8ãb÷aW4º8¢É˜æK¬=y/y¸/Ù`n¨v’¶¦¶äÖÂÊœ µ°Ân‡|‘œ*«bÖøµ¤ÌX+]et®ô ¿ÊR蜔&¾é2«*Ï7 ¡WµXIºFäCBcýã Iú,MÓë)Í×ʽ˜ÿw0¦d2E^ƒ*ŠfqÌ©4y]Hâ]DQ˜MHÊr^Xp¼›ò)]Kò^ YyÆGc:Mg|è)¢O§él†_ùàqF”ŽšÕ©3mŒ î/Eæé¨wqÚÿù,îТš„féÉÉ+Žðu-5mŒ½áÜ6ʯéÝË—À*—npª¬É¤sd–´¨U ìa¯¤£Rli!©4–QǹT&¼Ì“¤²ªV¡(y- P0ô!g¿¾M; ÉûFc<-Q^‘çÊ+£Erââ›KË¡L%-vÁ ”9óÅ6¥¿5RÑ[|dk¥ùL‹Lè˜;‰–6»Íh±í¥±4\9FƒS s')`× Ó O¶Ö‰W¥a8¯b¡3S˜Ç+é¡à^JÒZ¤àêlÍ€p*;–üºÆççç­C¬PÐu6¨wnE&"»ó(­¥-ó°#ç¯_„°ì4a%Ñ…ÂÉswB¸]Q`ñaÌ  ZÒ`ˆ~~ƒÃ°u{ˆàÅLq·u^–´ãkÝ «0lìè…¬±ûx¸#dW†vÿG[†Ï.å†D…[pbÔ£µa/ndÊ[a€û°÷°c=ôî òžÛˆ‚¯“—h´œ{-J¾h¡s\°ò¶V»9€=…÷iæÐ÷VF¬õÐÎsh’r£eïÈ¡÷ÌJf älvZbÕ ?âÖ!š|ŽÚÎ:s3o0Ol%|ÐüŽXÅ#E˜&Zå±E–Rs‘!hdူ9w3øè“bà#ãUWú³HgÀMâ­ ´«Ð–ÑÉðu¡·<.ÔX Sã,ƒ…?l¡T£‹Éis¢äU:¡X¶ë)ˆ>|3AaQÔOØëa°nòb%ç¨Zæ øÚ8ª¼—Yí™g 6^fk­n16 jfª¸«8Ÿ¸iýÍ(€Ž…ŽÒ«ª6:ù¢ÁÔªO”îÉ#ÅyîgGоj0ûò×å¿$õ²FsÍèNÐÇ~||ÿýãåÛÏo>ûþéÍüÏ>V.—`Ddõ#ÔöøŒ‡3Þ&Ü‚VÑÌ4wüOÁaSzSÀiëÕÑþÀ)Ü5ÏRû E@‡›Hˆå:¾bK=ÂdÌùnÄѵ¡–ÁØŒ•=œ•†YˆüIpñe7Àœ¦¯)9-ŽÇ—]yáUÔ‡3õ!ÛŸWxP…HöÖÆne˜b"¹Oø ³••øŒÃn絎Y×Lz˜vkWÃF· ì)îà*<Õ*° 3$^zÇ/d ³C«)±7Œƒkp=p´vÞ”ê´ÍXCØaZal»7ö»ð’§‹½4Sú†¹‹u%e»Sô¬^&m»°*¯36c 3~â}gOrMŒXªŽA}„ƒëŠßph ítÅöùÆÝ<0ÇÊ%zÖî¤Ì¢íæÌ'SjGÏ@¥Žä˜ù­a¿ÇÜI˜·™ cˆÓ†GbPpÁÊrÃÅ✒$k‰yüHb}ö¶f7¥Ç³c:>=JOÙÔ¸ù&³tLïMV³ôÁ¿è7èñqmò*lÌæ ]í¿£†Þ„:ç[Œ(Ìq¼Ù5?žLÒÓS¼ðb“é”kña~ðÏÁÿ•‚éÌendstream endobj 4712 0 obj<>/XObject<<>>>>/Annots 1487 0 R>>endobj 4713 0 obj<>stream x½ZMsǽóWÌQN™Ð~8¥(*VT劉‰.º,¹6°‹,’™_Ÿ÷zv§¶R„@eħ‡þ˜žîžž¡þs»ÿÅ.-øÿbsM"ü ?b~¼s‘“Èy1IÝÆM£I6€µûpaàÆÍg“Ür å²Läæé$å ܸ8IðÿMQ*‚)ÿJ§“ÂDP!§“™!§"˜D"Ç9µ R­ÑLÈél2u…áB+ŒA«’ÔšÏýúÅ‚;#gñ$¾,æ³!Sj0޳‹TR"žc5q†ßQª‚QW•´l¬ß¥¨Å`‹ù¡bYfáƒ7ϸâ­BªÂ1%-›ËBƒ¨ìIžù°ÏçT+@Ô*„`†¬3¤D(„8Ž‘w¹ ‰‚8›øÐNEáB0ŠÚ@Z 6I‘†5˜ÍhTeóh20Ø™"u)6M| . BM -¦QQ«¬Á`ó˜+›ËÎŒš‘Öˆ¯²Cv°>˸˜1‘Ða7n–Ófà „RÔ®%-¦»)Z‚ŠÊžf3Ÿ ÜŠÔyD›C4ÍÑ1”õ¢SŸÐ0u™JAîÜSí UQ‹éïþÖ`°hpp)˜õ.> ãˆ;‘ ò«QL³²Ve [0»¬Á`±‹¬Á—`¹…‘õNå> ãXœ$N ÅH¬6°^ù&±}f‚(*Ù’%~ërf‹ä „V¤â/ß$éµ¢y­ ½$EŠ!š±2 k0Ý-•5,ÊÑjöf±)4+}'@«Ò_–”’ƒEÂ¥ *jÓùÞˆíÃ#¿ÅTÌÕÖ`°¨ä̲ƒE­F†õf±DD1#ȘYoFY †F:"‘5˜N%¬7‹f‚˜  ¤ç†±€Ô ò.)†ÚŒ'†a ‹†‚8Y¯x˜DL'‚D±ÁE°ƒ-Ä •5…#ǘьBBȇ±#–£Æ#±k04£`` S‰Å\ДÁPÖ`ØM0XÖb°hX‘Êz¯Æ™'RîÒ0Óð„1í², k°·‹MPY¯Ÿ’S(5x%HÖk0×ÑŽ²3’íÖb°X Š$°ìÇ‘K†y*Θqy»Š}$§–E$G Í㬲ƒE’ߥf‹Á¢÷VÖ`°ÈÁزo°N]j×b°X‘µ+éœ S`œr~õȧ•b.—­HY/ŠO_õ­ Qô¤CÓ.‹ûaŒ4‚)Ïà$^pœçP*Èç †¨Ü~ k0Ø‚s¸²^ñ0ía‚€Þ0ÑHØS•´,ª jƒ¨Å`±ÉC`Å(Û’O`î…G~[Ó,Ïà vJ³†5,Ú¬ÁtŠÇ€‘5é ;3Ãz—eÆ“¹œzŒ¹a„P+·=%½à0 âþ„o†qÏ@â˜Òb°h—Xiµ¬Ìÿ†5,<ÅJUÖ`2çe-‹–© 7†9¹€q01Ê)w8D²”¸å؇BêÊ×›pÊ’ƒMd)¢G’Å`†Uã­õ±†Sy[ˆÃüi ‘Ü0H‹©–×6e½Ú0ºrM¼CÍC²Ücú+›ª¬ÁT|(ëÃ)ïˆn1-¦¨(¬ìË0¢Ë%N~f!ð…eÑÑ©„ ¤­9¢8ñrœ¥Uš¡’4p,!ÃHs,\å‚C¯Î § <7œB¤*·B9qs˜Q%Ȫ %Ýe 8\Sñ:Å6%¹¦Nò:816 ½sy“óA„0™ð‰dT¨æ܉§…7À)äªY GÆ!·¨wµ`.@¨DJâz8…àR¹ÐN!8œ¼ÿ:ÒMnjàÄ™XåÐǰlj…‘Dí B¸,aÌ)ÁÁ+LÌSoT®«Ã(÷êÆ<_"’‘ëîÜËŸÐô¸–›^:‹¦³ÄÝ,å3r7‹¹ûðñí÷ªÜÕ‹Ý7¿ò*:ÐVñåI/“|’åt¼x¿ošº¹”$Sû‹·Ívß»UÛmÊþP§ú㈥—(®(…wü”ä‘;”ø³þûƒ)ñþ—}ƒ‡rßÝÒu»ÙTMÿ‡ }3î]Wm»vQívmwæ5Iô^×]µèëÏÕ¹—ö®ìvUç~®7u_öuÛœhð2Åumê$“‘2ÅôÑ”á ~9˘b»r»•´­7Ûuå®Ýëj±.;uHóXªÂÝŒ¿WËÏe³@7 ^ìöÛmÛq‚>ÁªLp ÎW‚ñnÔÌòÓoÇ}©>WÝCO/Ц÷eœëJ·ª¾¸]µÆI‰Àì6·íú´]¸Ä0Ç/Àfßz7ñGþëjUî×ýËv+ÃÆÚ•ÝÝþ9îav@¿Zí´o Uþ,×ëÛrñÛñøÚ”0'øe¤È±# Þ(ðAÎk9&Xcûf¼è‰2œv⬞*×Ð×¼=ú0¹Æ‡C‡L"£|¬žÍü«ÛT›Û£ÚÅ“–¶@æ—g2zS=‡µv˜h—UÀgÞÜ«å’M‡הjãZOó âèûÖËn*àÌ«ö³›ôÇÇ–¦í+óRBÏ<Í—¡Ì¿µDÒ ®ÛeåÞ6x`w¢¦ ÜãJ&o:¸™…÷%µü$/SßéIœ©GgÜíº=¹Eª—Ìõo¼' % Ä3YÄ9þ¿òÖñ$›ÃÞ'ã±ç€?¯l<ºíª\TîÕ¾^K¢3•}u÷p˜ | Ãü‡.Q®x»ëÊ ŸŸ#-n‡òD&WqqwU¯Ï}µùxÿàö» # VޏC뻿žV®G'曪— c•ëê»ûÞÝcÇáȵŸ»O~¼/{ö«eë¾Ôý½Û”uóéŧN[óׯ¿/ oÏø]ØÜ]â¥ÿô„ÊŸžÃsü€ÙpeJRzñ·›‹^üNyÏýendstream endobj 4714 0 obj<>/XObject<<>>>>>>endobj 4715 0 obj<>stream x•XÛrÛ6}÷WìL§SebѺ؎Ò7G¾D­í¸–2íL݈„D&$Áddõë{¼ST3eâ M`/8»ØÝ“¿OÆ4Ÿ1M/ù¯|XŒœ>Vÿè-ÝžÓxD« ö^¾Ç‹g×ñâV~`ÈõE’JMž4®ÖÒPêKZ ¸¤©E¨˜Ô†–¿/îNí¢Iu榙–ü9H q’¥´ BiNIÄùj‡òñŽodR¼íÑÕãrAó7«/'#Ž'ðfàI7¹ãÐüí[2Y’(œ+ò`šŽåkZºìÐGµ“ߤ>µb‰V[-¢HjôUz°„!i)<7Κ*ÊbÙ¯–7ÕÙáË2‘n° žLEk…cJáú” ½•)…"Þfb+IŒ–³¡`P pÃFÎnßÓøÜ9σ1œÌøÕ\8czÎâ8ˆ·ã|kµáäÜ™ÍxçJ‘Îâ"™‘‘|;!ÝÐÀì‚m[À\E•]úˆ)‡Áac‹HR|e}ù¹T8s¦¬q‚HM&ÎtŠß<«žþ¤|Ï„Š=ƒBiGt@UÚ> ­Ö©syù޵î| üJéâ$œNìZ[rÀi!,È `¼®´VHi,ÌÏ8…|„ð³ ‡>ÈÓ‘ÅL¶6›ÚäJ/KÔJTº¶R_ ÝDLkIÜsèÊóP„¼·Êâ UœC„F!6A,=ÚÀ«¾Œ&ÚdÈÎ00• µF¢±ÔzOé>áŒÈ=j…—†¾ “®«°Ó»7ÿ8)OÊÛÙ׫¯ÈØQâv EÊ­VnHçNÆ\/$]ÝßßÜ=šßÓN‹EİI Iê †®¸_eÜÅk%=ÿ¸˜ÿzóxL€%mɦìýbùtLr³ º‚ «··‹c‚ƺk³v÷‡#b[u`­áé:&–!k»’•µ;»ÚëñMtëþ«ý‚av(W Þcµ_.R^ŠiÛfåêƒ]¥é1áŒëK”žæS —«ý–•+¢Vî±’Jø“]í—D6Ö’O¼zDÐï¦@ÓäÓÇci—peí>•«O¼zÄà>õÑzÛO-˜¯ö‹ê¶Pþ[%úL/ñUÐÝãgZ¾¼9b^g¨BݧÖÁ«ýÆ|=Dª¼çë»Þ¼&Zc[Q¿š´]\:gXaµ_.ûïkŽ^P­gôùø¥=̯F†ýñpPÛP!mmCû9xnb±Æ¥æÖ”mPØÛñº¬ÒeC5ûh­l‹9»­jð ­÷Ú¶t5 ‰áÇœhµd]oo«¬¡áÅž¤ÖJŸí„¶H-b‹™ Ï *÷¶õq'‹DÚöû6 \­ŒÚ¤ÿKñC%Õ§”»[C]þZz‹ÆÓlÖõ]½@矎áÅèæÀ;¥›*¦«ìLÅspÃÌ“Xê·O]Ä¥xÿ÷l- uÅìk-`ÑŽ(mõ¶ª–ãPm¤ž…ú´ÄXÃëæ0–ó;Oì”kk[P‡\–~ï<&B3fàrÚïhÍR7ÓZÆ)-È~aYˆ±+—äU]ìeôµIyJg>Qq‰ŸLöÐÁ9Ú58ø–êÆ؉jT7åXÏ6 §òhŸ)q53 ®S剈Ê\|š?ßP¹Äy.cg[Oäˆv-ÎoKfH!ºX“]a´IÑ–/ ´Xyßr9΢µ,@Ï·Ú`pÇý˜^”c6˜¸Æ"¸ºÍM†È\Ã’’«‚ÔæI„Štx‚fÐPbTy>ͺ›LÎÒ ‹´sˆTß$˜Õƒ²Ü1ň ;¦X¥Ì,1¢ó”^ßÒÖŽÎÀ¿Ãé³Hf2Ô…= š0>[¢ƒiŸ# û¬ËhA,œ ÿPR¬3‡î³; Q†;˫ɕš50Lym 4¡u‚üàð)¤Å®ÉM}(Ø*Ó…4¥-áÀ‰ìeŽx“'b»b\sfø1œ§XÛ5Ìïvþžö*£(ØúUÕ¶²Æˆ¡ 4… |Ïù¿‡›ZõòÆ2äÏÄ&Ä õĺ7…¢ð…= cCƒ !h×wèäE­‹ö­¢7+B5ž;Ó ºœáÿ4Æ–€2Ôé3¢kåfj½A 8’=ß=|—ÓŒ>b}13™¶­zrÎb7«“ßNþ+\ù3endstream endobj 4716 0 obj<>/XObject<<>>>>/Annots 1489 0 R>>endobj 4717 0 obj<>stream x¥XQoã6~ϯ´·¨k+¶“xÓëS›6½<\‹v ô%À–(›]ITIim_qÿ½ß )ËR¼ÛÞvØ29œùæ›o†úíjAsü[ÐÍŠÿ§åÕ<™ã ÿY🟿¿º].’·´š¿MæTÒíÝêô­ wWçßKº›ß'«¸–ýf}fP¬º-]?Îé>¹¡uNË9­¾\$«Õ[ZgrìœÖéäÕï¯×¿^Íi¶À×lò¹©Ò¢Í4}VwZeÚ%»Ï+^ýgðõúš~°{*ŒoèëÞ=ÑÃõÛ7”é´PN5ÆV~°ÞT åÖ~õâáF¹ç ÿzx~=ü5I^}ýxKìdN3Ä2[ÞÄX&ë¦Òfm¡©R¥&ãÉ·u]QëMµ¥+|­S£ ¦€¹˜š¼ ;‡L(3N§ù ú§˜ö¤œFX>ufÃyë`Õ‘©Äº„3Ì'àŸt{ŸªÆÁ ,Új¸´Ëg`Éð|®­$dó–~÷A»c³ãXÎäìvaüN€‰Brz¤&´)lú^ 1e])µ5ã{d§¤ÆŠÿNû¶hØþÞ©ºF`¹ž©ÓªÁòÍ‘Þýòô}Bë£\„U‰¥ó\¥ T±WGä±Ö;B6‰Y`Yed¿s¢À…ýÀÙéßZd@ ”ê½·ºÒ žv>¦LMmYÃׄžš;p![×( Žè²Þ)oþÍÆp̯-|ÝèTÁQ:Úöä¨:'/í$v|ª[pGMƒ…3×)³ZÀ¸~\u)¡ÊŠCçÙPmcKàžª¢8¼eÐÕ‰N—CÍfŒ™Î- b—+}‘oãÓqf}í,'sþÅ ¼Ìäw¶-À œå| |\£ iHˆåìã Žñ¯ÐÉ‚)ª•ã–h´«±O¿´Þ¿¤½?V:0Ï({]‚ &5ª˜U&£*ìÖ¶>¸as!ÜY‚{Ò ¯±»§ƒìÏÅÄ¡€a̬D鎔§£JSÄ5ðfc|,ôëÇ/‰Ë?G‡˜-W\òwÉ"YlP/@Ùi HC"â°ðV–°ã\§\ï**±Ô±$(µÀÄTø©(º•Ät „Ú´ùU!ŸºòNÐÉ$Ø/Õ½_É[°Ê2õåÓ= ªÖUÆê¸0O”Ûê† Um[µEí~sÄ¢\Aƒ¦|l.íM³“=¢í#>±ùÄ ‘™pôS•G”zHÐÊå‚­1I:6>~|ñá0^þ<¼ßiÄì˜ÕÌqŽdm–¾y36bk† Y¨3]‰ž>¿fŽm.”·j4²@¢K# 4Ýc$µo„ã³íå“¡§¥ò ²§Êk? °ù6ÏÍYe¡–j@wà ¢;.£ …ëJSåö¶u©¸Ú¥žž'SÂÈ0%ݤIŒ0hÜTDn§>ÀŠå£.b÷ÿyK^v¯;Ús‘Ì:ÒöýD€39;pvÏ-„©Zpfò2ÌmèŠùHÞ„‘e}PèµúïÒý6[.“›ÌcÙäoä÷fKœzšÕhîHö ]*ìD¬ëîÁ˜åf 0y 80l߈ÕŒà*›Û¢°{ê™è'ü?­M/âäøÛàî”M¢Ý¢¤–™ wGƒEÁÙL[ÇjúѤ²^w—óÛäîæŽVwóäžÕAF¬¼ÈúöÜ-Ît!¬½ BÂWÆM¹_cfWr×¹[,’û{\ˆ`lyÇ¿[_ýtõI‰endstream endobj 4718 0 obj<>/XObject<<>>>>/Annots 1491 0 R>>endobj 4719 0 obj<>stream xWasÓFýž_±Ãà€-ÇvâøÐ¡ÐÌC‰gúÅ_ÎÒɾFÒ©wRÓÿÞ·{’,h Œ‰biïíÛ·oWLè '4›ó¿8?9‹Îðþ˜ðÇ×'WçÑœ.æs|æ4™Í£Ys•ÑÝɯ‹Þò˜[ÓøæM¦´Hz~uE‹D"žÑ"\D“蜮é‹Ó¥³±öÞºÓÅŸ'ã›sšà~f4=Ç=‹dðÑÜkºÒÝ·¨ìžÐžT–‘)ʺ¢Ôd¸®6ÎÖë ©‚t±QE¬zÐÎñ5âô"XÑ[„ð•*å’ƒ¯(ÕªªöŒ h8•d œ&_—¥ub›"ÎêÄk9?\òaCŠm‘˜ ?ª ?ç¥É_YB¹Šõýf·è†2×’ùài« 0ÌJ纨8`˜ua@ÔR?Dɉ5AAÙq\àËWf M¶œåi¥u!ÉfF'-Ôiå‘Ej%Æ«Y7,€~ÃPU(.¼Íuer|S{­,ŸÜQÙžœÚ¢*­íB#º- båõv¶F„Ðwd |lUQI5õc¥ )on“:Ó8£…Ci]Äœ pq´P7N¥9ë ëHp›ã Tf ÈOrÊÍzS’6|B«]ø¦‡œ–éhH~çQªæ ?D~™Y9åv{TCÒU-O£ÇT´~[‘ߨ:K moù¼Â²Ò'qÔ(„¿7eh… t@øqf™nbMêX ϾEQôìïc¬2ß ó* ÒâT}Д5‚ÂÑTÔù Ä¡ÅDÛ‘FÓ…A´G…f6åÐ.•è—Ö§jIçh™ã.]l´×ÔUûPíÜ ‰ö±3+I[`?¬‡6S;ÎÞéZß<¡x£ÊJ;)M߯FÓ9›»×E¨Ä;ã4Tölâ‡öõÉúŠ©áÊ=÷h0 ±°¾mQ9›eÀ 9ùRÇÙ']ÐPwNPe[µó\ ˜Z¸]‘$9¾éœãÙQQŸp? Q+ȸ6~ÃÌä”:›CV胒&:ÎT@ ¤÷À0ަ“iœè8„ˆ³TÚÚLKçEÿ¬ôF=Ü€>dK€HŠ¢aWlž9½ƒœš€G'¢(ÓkQ…ß•z²€ÀÞZ#Œ¸ßSZïÍêÐ$_ÛëѾñrI Ø3C‘ývG”C—œÝÏœ>ã©Å&ö:匮031Ù¦œó4šÍp• Æ/pцh4Ñ3ÔÃK/Æ D<豄§Ä=¶ Jc~\] ñÅX<€WB<5i¢Ãmmöòûg‰¦¶sêp¿Æ0KÛ4”I³h>¿”ò5Lî;`ÀT§éýÜfD~—¯,„®SÌѾä´ÝpRÛV<¨Â~Âÿ[CÎé ôõ}4¹Á¤dç°R¼Í*¸,69–KÍçA™Ü«×ãë—/mß "¸Äb‰Ðœ}ÎÊ“=Ó¶ yDb@æüK¶<Qk£—¡ÞÀl•` •‚ÈÐE>/XObject<<>>>>/Annots 1493 0 R>>endobj 4721 0 obj<>stream x…WÛrÛ6}×Wì$uM7-êf¹ÉLšÄOÛ$•æE/ JˆI€HËj§ÿÞ³ )›²ëX /»‹ÝsÎ. o½ˆ†øD4žñœ÷†áOø+â¯Oïz“é(œÑlv)§É|Nš»Œ®z÷ïsšFÃðìÞÛ_÷ú¨vM§Cš‡cZ¤4Eàó(œÍÎh‘øe‡´ˆÂ_†´ÝˆRÞHË7'‹¯½! "$Á¿|wz1!¾Mi0â7mœàµ´¥PšDr#t,J¥(++™”^¿xA®Š7$iéJ¼Ž3áÞ +I›’v²¤´Ê² ‹ÂXØ„ô1“ÂIrRR¹‘>ŒO©‹Ê Þw¢vZ 8ßWâd\*£)5–rƒ”Æe.ø¡¯ùô"š·ež…ÕnË ;ažÓ4"ì¥öY<]rÕ‚ aÒk’ÖÛ§ØèDñ""Ãu^¨Ì/I±Ð´’T9àRrת€*a çØ$2¤ ä*oE^dòç:‡=¡LÄhŽÇ 7 ž«T'2¥«/—ï<-L®3¹¤•H(‘ ÀúåݦŸóÊéa¥¼Ê¸‘Mð*+¥Õð¿‘Ù®O;Sù*¾V®DìL–5cÝ*(µ&÷) ÷TÄ’R•ÉVg£ ðAKF · ßhMî|=”H†åRXs£ ŒY4^ 6d«¢ÔØ*‡H¢$UÒê[I©‘ Sk]ƒ½5öš¶ªÜ´Xy…(Íüø2\!c•ª¸ÁJhÏèBì¨6WΈ‹8¬¢“ŒycÝŸ²ò\v2_2\‡ýºf}-µ ìÜâˆõÓIf»A΀Bånñë±.¸ƒºDB#¦ß*y·æò$¤Ï,ï²]ž¬rPDZ2×È ðÈÛÒ8t ÈGÁUVBLöØRÜ´;@GÍ^ìu± €:7ÐB-si«›…ûÍÆjG †@o;}gÖ4Üv²èhwp³ki+äWV™ÊõëhVå,ù( …íJûZº:áHÜ:>Èi¯¸ªT™útrqW~xz1k†Fà+E´È›wíÜÄ;Ö Ï·ËW&ã¡EÆV­ IŒ¥"¤Ñx þöã'ðWÇ>§h‚]“—qΗI0 GôÅ‚KÜ•/‰^Ó›{Í];·‹³ë$œÏÙ×W¹…³#×zv ]8t`ɱ¡Õ½D-*ÎŒc±`lÆ(ˆÛŠûÝ(‹tâmM•%í ë ¼¡ÈµygØù©éÐê5É©É2³åŒîÒáòôL<ÊMRe² ÍÚ˜›€áHi´«¤£Ú”üctè¯VpÄ_Íõíòä—ÇL‘¹ÒÆy± 0éYüa駺‚öî ç cºü– Îê ø9Å™^-^->_ÑtØÉ¢}û×ÛOW—ÞÓ³(Œž±ÅÁ–}7Ã/¹å0 ?ß/Í€)·SUû=Ò5Ž&€%¥À#±<é äeƒÅã>È^gf…¸V ¸Ž·_P¬'ž¼HÍc+4ÆÎSËßc™5X¶»P½Ùá¡ë[Ä÷Ž`QhÇG‡ZP5̵ŽÌyF‹8–˜k\º›{»ðm” ½®ÄÛ^‹ofJ䤘q¿ Ý•Šƒö¡z»=è4Ï"ξӬ`·Á½Â1;ÆãéùtÖyzÔh˜Þìi¨k?¾öDÖE"~høÚ›MFšÝ1´·ôyÏö¬Í'át<¥Ùü<œEþ4É0ãWÈWûSÓ€óm=8«ÇÓ4ÄúXŸÂ~W¹ªO`ާø¡€]ÇëntÆOÞ.zöþœãšendstream endobj 4722 0 obj<>/XObject<<>>>>>>endobj 4723 0 obj<>stream x•X]sã6|÷¯˜ÊK”ŠEÛòG¼÷¶QΉ«’Ü]Ù©}ÉÃA$$á–$”¢üú딨•÷öj][E3=Ý=ÿqq#×øw#·üÉ«‹ï_/®³k<þ +¹zº“›ky]â݇wø¥ÐïñK>ù°¶µÝÚ ß4nQÚKyùðü£äÁšÖ6bjqukÃÒäVÚµi%/}c˽T¦Í×x£][éê†rïê•̯æß~+¹/l&?ù÷¾”¢Ãb/M·hKûÍë.®ez3C “Â-—6Ø:ÇN Û¥4õª3+Û\Jèêië*+¶ÞºàëÊÖ-›ºÆV¦n]Ž®×Hí[1åÎì›!Zà\ŸÉ+¬ퟭ,íkóÖùº‡b›<¸…•­ ÎwȽÙà½FüIâ€Êl6H1㪫§w ˆétöÀTî³Yv#ß›ÆåòºßXù a–Xß?Ô`:»Ëî¸â¹€Ã\t®,Fp÷•X`ìh (Ûß´¦Åú•ý£s[S‰Ï\­UiMXÙv€3“Që`Êr9JœioZo@^6Áo]aÅH僕ÒU®µ½%›ÀÏn‹ªÆ ÖàÉ\Av‰—±t¨¹!jÜ€M[_nÉ,É‘qõ(SùyrB˜{r,W̉´âö‹oZù|Ô Ò)­rwE€¹™ÒutÕ¦´dêø¢¢«5©R&`ý¸nÔJN^*ýiu'’Jƒ³{HdéËÒïz& Ô/³Xû°(ËÈ2+óaJ zS9îÞH(€eðUJ¸j'5ÿ[ ø1»%YgÄp–ÝÞâS‘rdDt… ‚ šõð$%8<èêÆ­j[pßáá™Gé=&x²çðÕ››K¾6áÌ Ÿ>_x_Æ“¼¦šâmöððS¢¿%U­À}ˆ»„=šà€9‡«HnP|×5x|$: >Ñé‚ÝÛ€;†òêBG›’›Y¸Ru<DÉCÙÃô(Ê“Œ,¬Üθ$6Í€ ƒ)ã!ò¾è‘)\ˆ¶FñÑÅR¢LjaòÜS³HÐj<>¸•«Ì\U’É3íîh}ë=ŒVÂø–®M~Û8Z:A —ÎÑ-ŠÞ“†À¨×¡â©®‡Ž4Q*Ǧu“ȧ¡Ú£·‘?mÙ!`TKûDBXàAE á—MEE=N€l2ùÕ>ßG|NÎ<ÚAÊãNÁF2âk;åZ“£KÊû—ùó³4m€ØÇžõ HOŽü”¼ÇpäD{ߌih±º°Ékýú-¸¤½²r'¼œ–› ãÑÛÑÇq¾xtÛœxB­% Õe´óá#ÝrçÚuψž—1@ü¦3CQ`ö¨ hË©¥"²‡;~9b&ý!é@µ‚U$=á(@‚8ø $e®b*6ë=Xáp¬†Û«j`â ¨ß'»µË×ñ}”{€@Ê÷Q0µ]AòèxuW- Äß¿Éä=! úŒŽøâ,µpV¬|ò¨£2³¶ä*gµ7NˆrŽ›\xòÚ`µÇ‚IŽÖј¥ÊåÈäÉ«É^=%áÑÐÕŽa: ýÌÁÉÈÏž{){ß¡H²¶ÑäH¯e%Bâ¾DÒæ>оÄo0¢¨·S¬Ô’¹+1K* ÖȉhA‘‘ !ïB¥V›=sLë÷e»öÝj­giKݘÐ`¿¦ÛlС¢rNU~.¹Ë~è,‡É ãRBÀ‚⾈—Ý€SƒÎ …ðeÇ ©uMGÛûgc¤IxèF¹ÓËl ò³·œ±{F®£(A}Àùš—ê#ÿÄùÿ8ˆ‰¶YôaõA¨S@œu‹/c~¯tÔ¤+zâÐgÑU÷¿ð7ŽúØî\¤#Zœ«žz'у´Õ1è¯]W àÌOPú³Îhgó†…Ðp8iÌÙÌ$V}YE'$xç[àðüò™¿{7Џi¡0ŠÔf™kWÃyB£,艅p8à8‡vª š1}ðó ²C¨:Ö#N¸˜mú—bäí¿4ò…Îõ£HÛ 7>àHRëIçì7$¨ª]ýªviãÒd,ËÒCö0ü´15òùñU—¤ˆt€-|Ä”’Ùž „Oãsz7W¤ú¶~ÜqIÖÚ´'Ç’ƒ=ioÞÙ›²â…¥¿›š±:íü”ÁçR˜p/hå„ (c“­³óÄ|“‰OÔµÎnCú‘N# }ê•<ëdÏsh»öСraýíçŸf]a®¤Vާ¢ØŽ1‰ ÖðªatêÝAŽgîwðÒvèwð“nC3òìûÉ‹2o–¤+8ç”þ¨~ŒN/ʼnê0'ãB Œm¡(îØ$Žw£Pô Á£>½•ª¯rɆ­=ÎÖK@ˆÃŽH Å™Bä BÜñ(þÕÒû¯XBoâLgÃÿ]©¡¤‚©³à/ñИ÷¿—_küzzìoÀ³ë»ìþö^gñ¯Dcz›]Ë>ïx}VH,¾;ý.^$ñ§ùÀ†Lp1šá¾ ›úÁ昫t•ÎÓ÷77Ùã#&XÜÓfÜèï¯ÿºø/ͪ%endstream endobj 4724 0 obj<>/XObject<<>>>>/Annots 1495 0 R>>endobj 4725 0 obj<>stream xXïsÓFýž¿bÊ`Š­Äv~ÂôCpcH‡Jœ2¦Ãœ¥³}DÒ©:)®ÿû¾Ý“dˆÀdlånïíîÛ·{úw¯Oø×§á1ÿ“½ƒàOøWŸ}z»×ïGt|ˆï”Pÿè$TßbºÞ{3ÙØ"ûò9í©@“lŸáC$&ñ!ìLš^L¾îíq„¬é„ •ÓÏþa½±C‘*T±Ê4G •F±ŽH9Rtuóþ}¯ÐybRUàáùõèò’\‘›tÐõçË·”¨ÌQ±ÀN“{N{SS¤Bl­Vã¯X¥©Pù\ à€zýðv\˜›¬€EŠU:/Õ\W¦C›Þë¼p;Æø¬ kÍ>†L=XGS=³¹¦L9ÇGK"ˆ[PFû£—/âÀEz¦Ê¸ðñàvÆ›œ®rYí(µ©8¶Koê^“N¦:Š13]Ú‰Ù\Ptü#RÓÄh3C|ä\§:ǹ+r¥)Ô4Ö÷ï¦ÈW¾’¼ôÎ.5âØ%¤iÊ,"À€YJçøÄé›j 702ÅF=3);­$É­1QtäHóNÍF2N´M…m[´G;¿Å‰†õ5…;=Ò…21H7µe!ˆ‚êØÁ!³äÜ?¤Â$ºë©—åöÞDHBlÃôte–Ù¼{7© m¤ t¦%Võ¶éè¶ÃðGÛ5²ä•_„£ëêêû}ûnÛD7Œó.ÕL®ÉR© ÎIe®KSø5Õ¨?qð@§ÄÌ…ðh z¾dS…9òD‘™Ít®Ó‚l†„K•¸•+t"|âªã:tlBTh;Q63!QUÚmº”i¤sWXqž•®¨ç¹J<—h1¿L’Å:Á¹ˆ*à*B-:ƒs›@>ªÖ5 »ùz¶y¯†ð Ûˆ¾Â¤i0ñÍ*Ñø×/s@-¢¢ ¿¡o·àTâé§X²6ØØÙE¥ª¸=|A¡Ývn_l†G=ÿ¬¹ï@ýêj7$awŸtR2˜¹ž\©ÉÊÃo!MiO¦c Û˜ÄÁ„c› ¸ðhÙ%ÒaŒCäfµ…’‡«íySHjS™ðeªuèÓ*êÉ#Ϭ€®l¡_#ª®ßyNиŽÔ*ì/Y<¢ôúÁ0  •ÇiFuqgTLhólÄ™õ-ð@ef gEñó 75L‹*z¨ÝiÄŽórNÝ'7ú|³Ó–ÌmõI¥\ã¶ð=•‹‹dl£bº¤Óã­Œ‡¨~°u]‰[žÕ´áŽl84æ—Ó 4pfùÒÇʶžûf×&øÌÛá†þ ùqÌ:><"úA[÷NÑå—ч«ëI%âÛMsŸÎS3Gr7½`¾W†>^6†Aÿ°tÖ>/XObject<<>>>>>>endobj 4727 0 obj<>stream x•XaoÛFýî_1@œ\H´dÉŽ{EpP\;qÚi¬´W@@±"W’«î’–…\ÿû½™]J¤·jbÈ0¹;;óæÍ›Yýq4 >þhxÎ?q~ôzrÔúx¸ý° :¹îÓE4¤ÉœNûtþÝ :?I“DVõiwtQå43&Óª /·w¯ú]úõêþÕàÏï'¿õ©7ÀºÄ¯ËMQ.}y7¾íÒõÕë.ý8þØ¥ñ|ü8þµKï>áÅ»OïñìÓ›nË5ÿÝ_}èÒÝå¤K·w?w釫˽ã^Ħp¥*JJL5Ë4½~?~K¯ht _¶=û&Ñó´Ðôáæ·>NF­cë·×ïÇoî©ÿØÑÿø×…üõyñÉõˆ8Ê9õ€Ro8 (un òï´¼ïsí]Jtœ)«Ê^w©\j*7+MfN摤ŽÒb®­Õ Í6ä6E©#º6–ô£ÊW™îb9ò1Ó–Öi¹Ä_0œæ*£•I,(çªJS‡yÊé™išg ¿6"8¯’$eŸºtÿËÍÊ+WV*´44¯²lCV;“=ài–±Ãì¼Ûä3“9ªNJaç@°ÔØÞÏS#ò=gU\V8mþÄV«R'M–ˆ¾”6Ùg¶Ð±vNY^+xs¨À)sÆû@CVV¯¬a“p/W±5᪒”Õ~MZêlÓ¶0%娒ƒ¿+eË-L±MWy¦ŠE¥`•ÚÎU¬[yýwÍ¢]-öNÁä!*3©9EWÿ\}¼`¢N€XÞ<˜4´fÚ™K ì÷´IÜ’ñŒ•©6¦">CÞ7¨§â_%­CDþf®bdY¯=¼÷ø‡u±thÚY3|kSe`$ˆó ²J¦ÿL…€ ]h«²À¿u ŠÐÛ@˜<¨«Ä wBrª"C²–cˆ“Æpµp®6 •£þ¥¦Ø‡f–}R‘’H€ ¼DÍ̃ny±-@~ݨ憿Lœ(ÏVzžMŠg!¨¹“„ghýáféµbJ£V™õ.4M©¢™äþsaÖEDoÍZ?hÛ\9:§rF°pÚ>@0ö€Àï{¸îë´ÔzäRFžy…´s:‘tQhZ—\C³ÜA˜]ÿvyw{?…¼ÀOé¬Ù!NNh¼'i{ΰm˜D½wE0A°¬µmúôpŽuZÔ4Ë\ŸU¥×ÈÄhèŠ^3—!ML˜<¢ ¿bZBœÃ"~ŽkªÅ’Å“©Ê,ÍS`„„°{ÜA…è ¬§ò%ÜÉWXbi±0–Í@¿ÓBŽeœvDµÅ£z¡¢,Í¡R¬ØÇzFÓ‹—:þÌÚ¿ôÙFù…³OG, ÒcÐYPŒ¡G!Ö‹þ€Š‡¨c‰À¦ ïB5i!’è"Ϊg;“ë5à`½“][Ùó¡O;í ñIïX‚µÜq ˆpØîÓ¸m²/¾t_üéŸí´f–™ø3ËŠ€b Ô~iUá2äÈãÊ£L†‘‘Ø$=D³ËøÝPœ­É€]xHCºÚÅ6ü¦ O}XC/8"ßa{¡=¦±AÏA)†T$•Ë?¥ß0 0ô;^´“7Á»}„êöQJR> EÍÙ•ö ?r”'Ëbœ:–Ì'Š+þ¹•)¦6$ésŠFÓ»¤D•Š9æ"gåRØîɳ¯ä•ó]= Î3@ ³ÜwàÆ‹ ô+ä•™G&mÍ‹dƒ×üǦ?“ÍŠÉ›mdÒäY×w«mÉm§È}˜à…0H¸GÖM‘‰R,$áì<¥ “Ì7{¤/L¬µ>r×”a¶ž5jB’}rý±LÌ1Ô÷NϹfÏ¢ÓhœÙTÏ#(þ ¸0ë;âi;@¶1ÂfX³Ø`nç€æ Ÿ—òKžVåè &‹Ä¨sÌi,?ó ·^Ãûµ;ô’ŸÎS_ôŠp½žv+pO&>ÁZèÓ‚#OQÏå_féÜ€•0Þ„«ì2§RS9Bƒóš‡E–`ÏWƘ¯`ÕACf›^zb:• ”³Úr“M÷Ñ0z)ì,ôáZ»7„¥BÙÍ9’výÞ—˜M‰¯¶YíóAÙTÆñ&b]Ø\(‹0ü "UlêFv@&`å¾¶jµ¦Ð™E†Ñow›­À§# lD{„ ¹û7ÞÐA‡{mh¯JzRou¸÷Ñ05HùŠT?fp–[´lYmZ±Àï̘Ï{YörƒÅÄq%.b™ ˜ð‡¶#ö´ãëø(ÔLCâd>ØP`¸’Ù×_¤‡ÿýQ[q?!€sÈ‹¿–‰ ¶ËãA˜·ü…0=–»§oÉÿÓˆîø5ZD­Ó€¸Mä·Üñ™\Üÿë;«0ôïƒkß‘ƒæ5¿œh\ˆ¤J)^*Dÿ}c(”™P^òí…ßC´­³/W%Ùå ÌØ Eø$mO }\iXj;º•Ÿ$žñ³¦÷–‚¹DÌý•!Þò$Æg/’”.Gá#ªjw§e\^Ü ÈV¸±^„ŽzÚEgÃ3:¿8÷mETlõécêÂ7¬˜lC¸_Û{ÉÝØ÷±!]†ävp6Dhux=”¯`®&G?ý½§âeendstream endobj 4728 0 obj<>/XObject<<>>>>/Annots 1498 0 R>>endobj 4729 0 obj<>stream xXMsÛ6½ûWì4Ó©ÒZ´õ»R·I}h›6žé%„$4 Á ýû¾]”¨8'%ûùöíƒþ½˜Ñ5þÏh±æŸ¢º¸Î®ñÿšñ¯¿Þ^¼Zd ZÏñ’*š-çÙ«î•¥÷³å:›Ñí<[ó‡7Ël™^ðg?=œX“~KWo®é64¿¦õí,[¯_ÑC)>¯é¡˜®‘Šòô­þ†WWôšgê¨=EGŠä¤ªÓaUàýŒèa§ûS/þ¹¸¦é fËÉ`ç옭ÔrM•+ÍÆè2ãç®Þ,‰ÜÐqNç‹.ÎÉ}Mqg*èKü9x£ô 'MôØÌOÔœV½ÕÓéÔÄo¹ÚÄÄ£²­F ¦ÞvÁ—œbÜ©Hðåµ*§|XBãp–œÒ;«Õ.êttã|* 5Ê«J£"pâñ|l=â>4:PtI¦Fý6m]DãêKzÿ÷ý[jp,¨j‹™mí<s~”6ÙÇ+øS^'/—}çMÐ…¦ Å(’“Šœ HžÎ{­ubg^• q>â@¸ø³Rl×UWæ¡w®jp 7Ö ‰ßQ“ïÏðG­¹”‘I¥¸\qÉåÆëÒêó> ÊÎM•º°(1Htˆ•7*·¨' DQW­Rõa\3ÛÎÈ^NqÜJnH=Jï*³ÝÉ,a½Aíô'U50UdMî•GwåþÔ8ñv8T¹³œÁs\5&¦na¬¤ëM›[SÐëw÷ ØÒ„µ^mûi*$»KÊÛH! WÖº½%剧ÒPà=ïÚ펂«49®}4uI¨„ }­,Uš›Põ“¢xÓz>ÏX¹ŽÝè¯ü›¨krÚ[ç>ŠÛ#œ÷&îPƒFNšŠz}ü ÂIO5!A[—ðs`H•*ª4Ï£~'ú’Ùf68!sFè‰õÖv“€Ä¬ÃäÊË< ºÊuYb Ã!D]q§ŸÓÈÓL"¼Þ­ŽÂUGæAåQÝ©²/ Ì€ ÖºÔfî”êN+Õ4ˆëþê*õ£)˜'¹“s §î‡„‘½7‘ëÝ(ö"£ ;xoø%ìç‰@Ñ™rûð2£¿”`³ÊóÒ€,o-^ÒÛq¤¡Ñ…¤˜È1¬5ΰ›ç”ïßVY^>õ½ÖûQ´‚VfS?ûzŽQó«è¿bö†§m.y’‹ˆe,@Â)ÞAà[ÐJ4˜þyŽ0ÅwWwß} mèàZn²…í=ÌŒòàÑÄgØ.'C‚0aÀY@0VAž™D/y¹ò#Éðq?>ámܨ֢í¾Ó† ñš±SöÍÊpÄñ“ëä0Õaà™•c]&@”OšAž2j,5E™Ïá•ßêHý°à.''…ex›Ö–õ7‘tÈ¥—«éâÆpË]Œà‹ª}Æç‘Ê¡¿6ñ=¹»H>Å¡énÆDSÀƒI-‹â$2i ºEe‡Œ~u{}-}2Dt|sÄX2?räîvL}pËNðå´ë9C@Ó†žŸ¸âñU ðK7»ãzáo °`xoÒNXáÛwéšÉƒö)p³³ú¹üh…³þ¥ersÃÛä7&Ä;Fëf±Ú4­P‹ò4)ÕB6AÂB*óÝ©áÛ¹#±ÎE¢þ&Ë·šk!É.¹%JÑY–ó…˜û/&º´nºÎͯ—Ùj±¢õú6[K„\¸éߤüìŠv@6#ó™O_¥ï+xÇ.Á!¹7XÛà,ˆ×Ü¡¡2æüÈj6˸(“ÅŒßùåáâÏ‹ÿñåŒDendstream endobj 4730 0 obj<>/XObject<<>>>>>>endobj 4731 0 obj<>stream xXÛnãÆ|÷WôÉ“vcѺØ^'og}`ä$>È‹cÄI“î iGŸª%:ë Ø q.ÝUÕÕM}9[Ê–²¾æß²>ûáþlQ,ðåøŸßÉÅÝw²\Éýk¯onä^Çç ¹/gWźXÊo¶n+#­³Mg|xwÿÇÙÅÝ¥,±„›æ«ËâÛf¿ ¤sÒz[ÛÎ>¹­:ÕZ$ôå^ÔpÂBnŠ5XñŒU±^㓞áyÏ;ð-¯Ð3íú îÿ~úu¹W_NÙÇÃÖÅõõnUÞȶ¯ª®n[ç;£esß~ÿé¿…üªº½ñÒíU#?ØfÇÈK×<ßák#—á“”½æ DèDI(½m;>ó¦õ&˜iZלÇã%µCNë™iJ§ÐÛSmó™Ó“ZÇ€:e›´M•]¯*yVUoÄm'G©F#,"=ïÔ®û}Îã æ;‰äÕ=ÃAjã@XæYÀTP=¼;—ÚîöTÎ=IeŸ Nµáûý<>.‹›åb¹zlX¾>2Ÿ™åêò±mÛÇÄïtÁöF•xøH’Ó5Yp¯þ(?ÿÿóç´Øpd#qM°CçÉÓ7\ú8rn ’XÑòb»}Ddl¯#™ÅÖ**ücU囂P[7ŠšRA\«¾“ͦìÂQe‰•÷I­¢ìzߤ4Ú”ÔŽÃV…À3½ëñ Zs×ËmF(j)ï@Ac´Ñ…Ü!5Å=tbK¥í}ë‚tp”l¥š]¯v†Â3~«J#/Î?|ó'v£d"rªÆ„Œ[®Ç¢¾ÒÒ3 †+GA# }ëÝΫš*( ŽÓv»5hãRŠÒf^ñSã¤6ັ¡€/ÒêX–'ç˨¿Ì$o¾ô–¼`C§üÎ@³9S aóÃA`ººŠ…pÚܢȨÈ$¡(›Æø4MÄqÔ%ñ¡8_0¬Û!x‰³ÝZv1xmKbC€Ã š÷Ε¯8œœÓùê¦øå ãLº’_{ؤEoÊm‡c”{S>!—)Û/‡ùM÷Â|Ç91½òãè§^n"ç°à¨ßÚ陉A[C·…;¡±ؼ!躵pÍ!#››£d%Óão/n¿ý6ïñ°ŽÏ0À±B…¤±¸î…¹!öÌ<·¤z9’—{‘'Ñû‘" ¬'‘ø¾9Æ8¢GCÃÆ8Hޱ‚¾’4&ñE÷£Ñµ £rVo,!ÍAÏÚT)4€ÊXI¬%vÛ}<ò4ú ïƒ÷Ó«1$c¸Þ`+ b‹ôNµ|û€ß)$æ4z{þÚßÕ_s­ ±| ²m–Á«Þ”4¶Žé«l!³¼l#ehÛ5ÏóF ›?Û8â!:½‰jÂÄ ÆB>Vc÷Ô{Œ]”HëX…€ã„RSH¢ô*ìÿ–ù?†Ê¥ªà$¸ÚPƒ>p ß_0 ï±uâ.ÔaÏ$ØÚ²waê¶;$¹ M ˽2êÇO¦óQM}ËD˜†… “*‡ßÁrÕ³lÇŠ_ËÆ6 n *bhbtZˆ®âÈüö›)½™ù€v‹Ê7ð{˜G ÛqVœPä]YÅûdl1DªFxD27 ð(~^®†®³Z¬‹ËË«ÜÉ?½º’µ“e3U^j&;‚¿Ï¡\#Ûh°Ç‰¦óêh´¡<0›¡~Qr`³VOä"åIÒ©f˜ä:ØÎÁíiêR{ðw {œ +G§`(z>$‡G§?Ùó¼ªÐô¦F‘Åù~ì:VÁ–¥? ÚÈí}µ¸,®ÖWrýá ÍmœÍ×ÅB~te?ö&žhÓÚù‡ôs›?j\-—~‰]h½âÞO÷gÿ;û .ü·endstream endobj 4732 0 obj<>/XObject<<>>>>>>endobj 4733 0 obj<>stream x¥WmoÛ6þž_qË0ÔIÕ/‰›vè€.m¶°¡.úÅ@@K”ÍV"’Šãýú=GJrìÖm±åU–ŽÇãsÏ=wº;Ñß#šLù'«Ž~ Ó!nöì’ž]ŸÓhH³¶Ó¸ÈÃs\dƒ×¥_™f¹"¿RŽjkbQnÈ™FçŽ2Sեʄ—yBÊ?qd¥(ñü®Q^’Sx,Sz×Ôµq’6¦¡•¸—$4)í¥-D&©P¥¤R}’q—'³GÏ®‡t™N8¦ñÎÆãt2Á§|ðSeòö¼H6Åc>\ßüñ–N SK=d+aé4¡ø~òóŽ)6§"+Ó¼]¶oÑh§–ZæTàDù|poTN§µ· õœúG>ú¨ÍâcB1ŠÃîÖÈüo1œ X›l>àãèÅÆK·¿o°Ãú[ƒmÊÏßÉ$NŸ3ˆ7:fñMè݇›ß(7Òé'ž>i³¦õJxÔå(Ò&`ouLr -h$9£qT8¬¯MÈ"áQ¿EËžJx#î…§Ê¥tS0{º$Ž9Ôµu ‡™--àÕÐ_pV'n¨†maÎ4:óÊhGç#嘒ò¡–™§¯ïGº2õ¡ºvâå²w3Ì( ›ÉÄ »”~~¼ö¥ö«Ñ+j©Ú.8¶Çó“¿½ñxkÝ&ÇëCÆ‹¦(€Ý+êÈq9z1>à8r†G’ǵ ¯HFI1:°l½âŠÚå¿ÐðÐ1û´¬ßÛàP\ݲÿ_ä{Ü+á›tÏ8 ½DV £x£§tò™Åø3 ¡ó}«Èž% ,K2µ¸k$A;ÀAVTí…ÒJ/骫¦ÿ¶Fǽ(±ÜÞt ÏÎ@?Þ‹)Êš½´¢¢µ±ŸZæJKZ+Vvˇk»”ùR¦1ÎÄ‹¹!œ§\lé$=§÷\Çâœrá…ßÔÒíž‹íÏaˆVRG‘:C»@E£òQð‘•8þÖ ÷78º 7á\SI‡è 7APzÎÛ&ó 3–àÙk\ÊÁjÒ6 ²ƒAa ”kµÓbíA( ÏAè”®×÷×¥ ˆ*Bµêá¶jJ¯êuÿg¸A§"¡îr±½Ì¾,¼ã^xC+ˆ£†"æRtJ{îY}ï¢>8ù»YË{‰ñ2‹{eÇ`vL"¨£3•„d hoØu)µ´èá,ÌQT-4“-”ùí¹,UÖ»[î%f&Ô àô¿×¡¥_qª®ž>}ÔKpBdy ‰Î¸Ö+„Õúž³b‚p´ WmewÂŽ–H&+}h.Ûá!`Ï”f˜avxÁýsí" €¦b»ÞAMEFÅZX¯*Ö¢uTèâ9ì cÁ4Ô¨Øk zw–JlÂiÛC~©u~)Ÿ=Þm?Ää…3—@ã?;æ¶Vƒÿ\P­‚X ÝG©A †ºXÒc€ÄeVÕžsU ½lÄòJ¡èû̽ÆpVÕÆz±"—£’]VRó9Á´X”:k [–">=z-‡€ B€Ûl Ï!Ö>üb’BçU…â.1Ùɨÿ”:RGj\tâ´s=à€×°ä ü„s ÖN%Ðéˆë…Dºâ½Úï* tÙ¡,-c¹æVZ¢¬2|‡~Æ`VÀy‹Ù­©¾%˜b|½ĵûA#;[m‹®KŒëª»Í`;÷+3©x.i s`3:Ýßn>ˆÓÔ4è…a˜i ™ï äVàTò$¥×,3V:g²ÇÌ-Q*µ\yTyx[@º@YYnvÔþëxÏ1˜ìþ3°ì­µÆ¾l§>&ÝÖ·Ͷûu³ñV¢gP– k”5P+Ôо•² ¥Bx•qÜ¥¸RÑ~kiQm׋r·"»—W.ÈÙÒmd—-ÿÇÃóôbrAÓÉ4v[®Æ³I:¤7&CãÄÁÅÊNpˆh{ö<¾'q+ŸÐi‘ñXwP«X¸à&´ÖØÚ/F£ôòs$}2aogGý nžcËendstream endobj 4734 0 obj<>/XObject<<>>>>>>endobj 4735 0 obj<>stream x•V]oÛF|÷¯X5À%Y²ã¶èKÝ:5P )¢¶/‚ÓqI^Mò˜»£eµèïì‘T,ÇqÛ°hón?fgg÷ýÑ‚æø^Ðò\~t}ôãúhžÎñÏý/WÐìê[ZœÒ:ÇÙó‹ ZgñýœÖ:9K—é­w-gœ¿\ÿ}4»Zѯäðôt•®p<ùÕÜ2]žPã$-_ȉç²VÅ”f亾‹IyÊ´Ý~†yßßš‚¦×³Î»ÙˆÂtxP Åpjž_Ú®ÊT´¦´R©‚€í€vŪ`ÚØ»SnG…cª€vhη;¸PGï÷Ým±Ç!m¡EFÇ®VMFµÚ‘c¼èZ´˜¡ŒM ë†ÃŽlŽ(𩏠\F—¢"'|z%s“pZ¤'ä;] `¾emTE™qÒ¾wEÔþõååÍË”þh*ö>’ˆh >žÏw±A]$ÔÛAD½5$s}ë²¥a âwõÆV e¬¦$&²¶µîñ: ~n¡l¯Tw‘®|i357± îNãd §à”¾õ_8„K"Äœ@æB¯T^Ó·}#è’õ-0í»À4¶†Àš<Â3Ê÷äÕ^s‡.ïߎs.‰8•J(Ä¥ty×ôªú âçuõΚ ìMr0£&mp7/‡5z}¤Zk¸Ž%ð YdÎ8PöaÄŠ(­¹ àlÑI9¼0O²z þa¶‡%ý¥É£“±Øqˆ›@¿\ôKÁ>~‹úõõè˜ Ó”ý¡ á«4nÉ[K¹rût©Z X*Ñ ©G6èbUÕÖâ;v;pe2޳ò¶±X"¬P¦ŸÂ9ƒÒíǵOé» è5 ö\JD{  §j˜ÌX²ªG»ïL¤"Í€íYÔ­„3¢K²{€B w¨Åèâ`윀¦4YLžn—ç[$³ŒÀ̆w(D†ln’?¡;¨£:¡áióÙn‘­Ò¹ÅZ…0 m¢ÆË¸”dÐËc”im,TOËHLÆï;LAD)ôAv_””Øy÷Tf“©M®_„¯!ñ{ú&jPŠ‹aÍ^\¬Ò³åV÷yºZÄUX’.Ó9ýduÔ¸… +ýéé«~÷úhÁ?[,¤ãb¶\ÉŸ×G¿ýòøÔŠendstream endobj 4736 0 obj<>/XObject<<>>>>>>endobj 4737 0 obj<>stream x½WÉrã6½û+ú”ȲDk±=ž¤æ0™dRS•C%sQ• A c`P²’Ê¿ç5@Ò’b»&9D–µ  —×ïµ~?›ÒSšßðSVgß,Î&Ùû·¦Ë÷ºÍæ´(h6¡›×Óìææ-òh5¡…¿)¬£=½¡áêëóŧ³ §¸ÇÛN…ÆÊm¸«Í–ƒ‡Ñ~y~lú/¼|E¼² 1쾒ĠÂFQn­•¬±V£x1-D4qáàè åùñ¶*#ƒ¶†ŒÝ‘RÕÁSmµ Êy ¶ Ç“6>(‘“-ºK½GœìGe} Z¸ÀhßÅ<㘃ÆÖU"£±)_µ2¼¥½m¨ÒëM€ ñ_K•%7_Ó{(ÍxvÛ]gWÙŒ~N)\íi+ÊF‡Ä¶WÙ[¿ë£Ã¡¨Í½ioœò„d)¼ÇÇ\ö5>u|DlxÉuQhÙ”3²&/UFï¬ñ:W)…-K»ÓfÝŸùUòë2ãÙ,›Ï |ТD:ëý#Ú«Û騃ÑvÖ"ãY,,ñþPÚ ƒÂË6ÖΉ é€ãŒ F´jýòñÃ÷dM¹ÇRQâÍ7umÝ2zëIà¶G&Fi„q@Î휨kd£Ô÷@&œú¬ yÙÝÓiäaȉ ?Ùó£v:è¸î¸íô¸ø>?»r;{Ñf˜|Ú&ÝÃIË®„CøU!aV.^ÿ¡lÑÝZžŸvuò…h¸¤°ö ÅèŸdξ-æS޽LÀ·.R¥v“k ítØÄ®=ÆX^\œƒlÍMûo ÙÅÏÕèüÿ™5j×V~98Ì2êB——ôkì{Uîlië=^@sÌÖ= µÿ\0öÊ"ñRà̶w"hÚîaOíê´ƒ@/m÷¦n+¨R¢§,éч@hø¦æïL¾g ²”«Rî<Õ®V ë´ãn£ Öb]T¤fc©´fåÚð6 ´R Wî)eI¸rO• îJÌÖL‹;~‡ð‰ºªK-qDkÙ†ÆÂÂáäÖ| î`¨H ªp*R7·sRŠè9sKF ¦k/t>b¿ýÆ6eN+Ű"™{[©^ú@ÓyS‚‡¤h¥¬ –%GF*ƒäÈ{Fh-1V—¤ØäGYq Š «.Hè>*ÜÌ­l*èWÒ46QBnN½!¾‘ôC¡Ke- K Ù&JèàqtœÔ(4,)Hr ‘ºlÑ×ëÊöîâvBŠløZI-ʲ$ÏêA 4íh Vv«€ñü8ñ…kŽë´³îV™Hªžx¡Ÿ)žT,VžËœ«BEÀ‡¶³ú¦âÊÂOlÌÐÀ3ªC¤ „óuTm§¥bq‰1¾4&Ìémî9{è^ñ118-V@J ©›¯¦†Ü,ëÒ®ÈÞº+´ÙÚrËû÷›Kèôªmx|Ro / <ƒ¨ŠP«n¼:©8 ûăGYíjñ8‰þs¬hŒw:*سs&Gá‚f£¡,Ú=i¦ÜsLµÐŽaçU¸ä³ý£ôy²\¹Ã&ËÁ³ Þû‹¿{•×ÛZÃQïÎH ‚ÏVÄ펵ýe }»è³Ø_R4Ý‹KÖ!]˜‰NÁÒ3 l"T+a H6Ò):~Çä ˆL¿Üïí8ï¥ÓÐ]T¡ì;ÞH< ÞØu|ˆª©‡àT¥Ð¨+ŒçH—“Ù•A›+ÀÓò0~êO„× œQlºnþ­ ñ<óa':‹aS7çQônÛŸ³ÉUv=¿¦›ÛYvË„Æ`ϳ }{H¼?_’íøUú%ăü”~©tPÇm¼êz:Íno1ýcïù5_ùnqöÓÙßå‡:4endstream endobj 4738 0 obj<>/XObject<<>>>>>>endobj 4739 0 obj<>stream x­WÛn7}÷W •i­‹­8) M“Æ@‘^,4Qл”Äz—TH®!è¿÷ É]yåÄñCaÁØËœË9gf?Œhˆ¿M¦üË«ƒŸgÃlˆ‡í?»¤“×§4ÒlÛéS\á=.ò^n´ó¶Î½±¤4[HK ÜçÔRWR{ò†6Æ^Sn¬•¹/·Ùñ쟃“×Oi4Ž»ÆSìÚ;ËN³SúMék¥—¼,Ú’]/_ KâÃKƒ1¯Âòw+©Iв4W¢¤a•¸*%™ùíZ¦Ínå«›õH¬×RX×§Ëw¿Rí¤Û_W‰²4ù¼7?î:ÒCðû¶ZnöUØ@xI•¬ŒÝ†tù•$XÃë²–!?CpzŠÞåZæj¡r,ÛöI-hkjZ‰‰XÛ Ku-ɯ”‹ç é<›pnÇØf<Î&Ü)æ…1?vݳI6> 'rìK©¥…—ÛJøˆ¨7\–ÜòÙ½§œ<¢—TÁŒ°!G¨éÝU`'óÑI?O΄€çÇô¥cIÄÎ{0Æ»…•2]ÇÛ a ú –0nêX–RÏ{é€Ç£ùñŰÉ×Û°u?ÙumþM^!?ðŸ{ü8„–¸ r<0k¯Œ&å0Åÿu!K ¼ÿÀ1vÝjãfÈpäïïDûáΊ‡»#û(.@#à‹£Ô¤(®$`¨{¿>Àr#´ï"Ú)‚JD&öEª•¢]n‘¬@s¼là”¨y¤ªªöLÞø¢áz Å ¢ndF/J/­|^4è Œa‚Tj¹ò´± )äVÆú IεÆ(¸$†PBõI~¬OØÄ»p<½FˆxU­Ëï ÿHéRiIG_nˆòqÖGô÷ꊥ»ÐìÓÙð+nvn¿Y÷ÆËg„J†Øbn ™jç©MK«%ýh§Ê2ê òÅ*DŠS‰¬¶+ÖT!^Ø%2êr«À ¨E)ô²K †bUa '@O“P­Ð™;=›w²ÙÓôÇÖ¯P´àúm—BïW¤çÏŸs¥cößHh½3¶,÷U|ô/€åªÂ©2$ ±åWûpýZ[êµ€ŒAæŒkFÜ.H*d^ Åh3~ñ ¿_ýuyñû[¨Þá(ž³â@9³6NöÒS_Üp¯$1!™k}ºªQX½%Ὤ֡qãHê1Û#E¬tué·Z'—ÜáAB¤$‰=£¤µÐ"ÇæÝ†6K2RÔØØ„½à. "¡ïÂao·i°ÐAxìLY$?¢xD}h{:7Šøh'w»rÖ}» O'¨ å°aŽ@G¦¼Æì¢¡ èÆ!La´"·Nÿ€dò¨€Z$­Ûs·iUû |Ø(‘ÑÌÐB}†ÓÈW£Å‘³¹Ð$Õ Á½býRáEÚù¢ä~+—zmÐxpNã)_³CJ˜¦`•زïЀ°k;¬¤s,ú®ÎWÜ*BÁ66_µ*yiSóÍÔ³ñ°OèL'gt™’>FR•Ú1„ ¡#†OLX£{z?CšÁ9ãJu˜ËwhEçö©ÝÍo7F‰Y åqFò×FÅ£®à¸Nç»?/·Žƒðíæ6Ÿë¦;œ'|ŒÎO³³ÉMÏÇÙ“øMÀ‚;˜dCúÅäu«ær­OâtÁßg“ÛßgðŸ~5BkÄ ÏF£ìü_‹˜™'S~òjvðçÁm^endstream endobj 4740 0 obj<>/XObject<<>>>>>>endobj 4741 0 obj<>stream x•WMoÛF½ûWÌ% -X´dÙ²Ó ‡ÖmÒIƒ"r„`E.¥µI.³KJU‹þ÷¾™%™H±›ÄEîÎÎÌ{ofôñdL#üŽi2忤8ùev2ŠG¸Ù¿¸5¿¸¤ñˆfÖNŸá"•ç¸H¢ÙF;Y§ÏÈÔO=)rZåùžV*%“jEµ¥wètvwrþ§‰¥(sZ/¢Åi¸Ý‘-É7Ɇ*kÊZ»˜Þ–To4Y¼8Ú¨2å³Â¾igŽŒ?¶”ëµÊåxìYk±ÑÚä»r‰ Þ6¢áøqEÞÝA[•7:¦÷ t]›r §¶ÊµÊ±(ƒAã©ÞWˆýÝûW/ QÚDÕš³PêùÚñ¦EÔx~/ä9Yǧ„@(×`ñµ¾øó™Ÿ²†Í¶Žýnwz«Ý^iœšRaS“x`l郃:¬¦Nû&¯É”ð¯Ð…u{ʵº'x—„ôØ|Xç€l—3I ézO½¥˜^ °è¿TQåúëÀÍÇ£åsê~ÎÏéª$>¦í  H8Êwx9C¶-R¨G·Í'¼õ±mü”·>J߀•)¸N(xƒdaFHõò½•BL~’PœqãL÷éé}Ü…Ô|9?:<ê[ÉUß\þx;;ô0"ý±1¨Ä:øƒzZA“`ayßíêx?Ð’{ Fh=­¨;¡ úc‡_X—C䨻ݟó…yκ_DP¾ß؈´²[´ãî-LWIÝ IÒ[ºÖÑã.·Ñ@ï¬G¹”ŽØõn|-ïY8ÂT®¡R^Rh FÐ-’å¤[ÃÁË´A ¶™Ô#ãè–VÖÞKktzˆQ‹`ãx‹õVÒ_zgV2€ ȾìL½‘fr¨>i>ˆ1´ð º¾ÿ„¾Ã:äc‡¶ä!f’Ÿ)Pé;õE(Î㑈Ô?Äþ¨8¿âéÙIÐ[¹™«´ £w”žª§xP7mýÆ<`ø8f뵓䱰"Ͱ"wNnf0@sGQb,$ãà!‰û|ÿ æˆì Û€ÛíÅw”QEö­ãó2¼á!T¨U:4ÌX¢µ"E>/XObject<<>>>>/Annots 1500 0 R>>endobj 4743 0 obj<>stream xWMoã6½ûW \P Y–üï.zØn›E=t×@QÐe³•H/EÅöýï¡>,ÙŽƒmX1=3¾yó8þÖ ÀÇß&sú‹²žïù¸B/½|ùÜOÞÆÁ›C㻩7©Þ¥ðµ×~ŸÁ$˜yw­OY¶Ú¨z £{d™À؇ù»À›Ïï`Ûm}XFÀhŸ4g†³SÃXd\æBI`Z³<æâ;z ü'Œn—õ|裯Bg€gküø¡C‹äÞ†·ÖíŸ/ÐÜZ¢o¡´ o!ciª¢Ð¡ƒÀÐS%ÖŽâ}8 õoçý};ºŸ%˜À=OªC;é<9¨È‹°)ÍœhÃt¹T{:xx&ã”ÇÀrÄ&ßòH°"–sXà럟=x`6"·«.äF ¹Î\å`˜^s)“ë‚­9IXq´R£VF8î•MÀ¸|ϲmÊ] T¹¼P…b¥L3CõIÅ߸îîÖç9Öz8{“ V>¶§ƒ-3É2þ8žÍŸ,НÂDƒ5—·á9$…Œh;üOiX)³ÁÁsÂyõ?÷…¥eÄŒ…+.qäƒQDauw䩘¿;íA÷3î:H32UTª » éòãE‰¸Aâ3Kp6ñKÁ± 2ÚB§ïZSQ<%ãuîYžœ1µ¨”°Õä ÂPaH¥±U-Ø*å^ ×; ‚$¨%Ãñœê;󦨶‡ Yìåx¨dzhó.·ÉqêMÉõã뚥‘…˜¨^ä˜*\W¬jœ‘e…¡äº[8 Í‘6ÄÙòÚI¸^îÑîEÊá=‰ × ‹¸'(*¥k冤‚~Øû8{ÁŸ°Áèü£ÆæDýd½©vRG]¹‘ŸÅDyÁŒçˆCWtǪ@\öîáBX¸›ê« ¹üÀsI…É[%ΰé F¤  jñý6‘0H–Xäd_)ö[¥öà# ¥¬ŠVÊK±˜õ ™@"€ªß%©ÍI%‰“ލ!bñ"â{ %{¤µx7¥¹"-5l½.º¡¢ÕR<šÕÏë¤;’ö—X…Åÿa/î Ö§³¤ò<Û” ªš_ŒE$¨ÈT¶gè$ZeÀ™N×ÐÊ¥ižð¶³]þp)ÕvøsöW‰þÅ^)7‰>eÕº?©—oÑæ$H ¼PYd°šÈ6{¬îüƒãŠs“à R áѯkY6(0<+ß\‚×+ýSißF Þ.tú {ú'˜7޶—/:ºýÊ÷U”Ê«|ÇPábj‡ŒÈ…€ÀN³í×j­ou­ +¨i”ä€W0i8ÈÄzc¨8ˉ@Ô^ÏÎ#N+m®£r,ÜeJÕü§/¤fkÓlU»˜nßGPªæÂh|ñ­q˃—]uA«_m«Î†M7\ZýÞã·øOri–„%™©oÂ݆ˮ§Ki*5ˆ2iõE„S“)ך–øu²îtâä¥N „cûù½t:¡Ó` ¶0xášÆúŸûøu£á®EÝ/ªá8XL½Ùds|Þ•% ˆÃ‰çï**ðË‚±ã(oêÒzxWÞº4›Ì ¼É`Þb³ “­ü¶ìýÑû‡¹ýendstream endobj 4744 0 obj<>/XObject<<>>>>>>endobj 4745 0 obj<>stream xµWmoÛ6þž_qëPÔYʼn']?uÙºõC×­ 0 Òms‘D—¤ìz¿~Ï%YòÒµ°¦I‰¼×çž»ûppJc|ÒdÊÿuyðÝÍÁ8ãa÷Ã/èäåŽéf޳ÓgøË{|УkW®T´3[ظ¥ÊEóíáÍ'/Ï›+#zkT~ìªbKJkÕÁäÍ iWEïŠfxO+e=¹9åÖíÚJâ`¥X0zì!Ž¥í«QUþàÙ·ÑìÎèE—®^,ùŘŽOÏàÕ(.M0}Ý!Ú¢ ó÷G„—[Z˜Êx LÝ(_ÙjA%\R “Ñ;[®à¤^ªjaøx_ÜÝwÄ–eÕ¬0Ï÷¬£‡\ùÔÙè.[˜J'õ…}ïª'‘æÎ/LÃÌÇèSZí W}• xFÎòñÙ”ãq‘g—È_¥Jö”Ͳ‹Êyþ#7ºP…uUè®KŠøúyvÞ ÈNSh ùV2VFÛ¹ÕdsSE|2¾‘Ó"Gä°”Ÿ/UQl%c CDÑuß² °6KSÁI÷ßn¼Z­4[!œž¨$ òUKr³6žõ@Z©c:z¹lç…Õ‘66.aɽÙ$99Oª`€nÉ|´@5¯+ ÙUÐ+Zƒöv%ovŠob\±f`‰ƒ­†#Úºš´ª¸j™fRàûµÁ—ÓÓ6Œ£ I K·©¨)Ò1]eNùû,›LðW>:9á ?WÚd¶ÑŠ#x…òc·£r{·âí!Éo1ÇJŽ`ÆW´v6O¯oGð(D®OßܶÇ÷¤Îƒ@u‡"áwÀæâ°Ãw嶈æ+oïTÁ”/º·c¦cvz2ɦÓKöìÝo¯~¤Tðʃ$K;ÏD¨µi<¢YS.­@œ‰öõ~JRŒF·‡ûIÙ0³$7…¡Ø|´—Ñ.Ê—ð¨T‚q“¥Dd²ÚÜI5ÞÀÎUœ–¨8.¡ÿ!8­üÌ‚?<;§ˆ[„å¥|€; š†{,ÑP~P û—¥«–G£—•ýP®gÔ©°7æ1ªKjX¸ˆ–(3ãi£ÂÞ³>þo\wðÿW@m@n+]ÔpäQ2=[îe[yֲѕ±«fD¹°è‹ªG§+nJÌ1ˆ€4ÆpZ×À/úAHŒÉÕ“ã £âVn¶G´VÞrkÂGÐ|fîˆû@ˆ¾Ö¢„eâXiʧ£a;<ácÍÓ\E•ÑK$Ð|Tè’æˆì\˜m©0 lÜqîþm_?}šô±Dv¤á×$f”V‘ÐeNï¥ÐžÐíh³´zÉèÙÑ2˜÷—-ú}u{Øð©«‹<Å@pZŠ2„ཫ㪎OxIŠYç3tÙ"]î‘À£o….E|kbk¹à»U8Ìò„šr‡,bÀÂwj‡„¬£&`{ÅS‡Ñ÷"1ÔNªí&T'—×.ZLÓ¢r3·•4Da‚¦>Пïšd“A–¨ñc^¤fd$¬À3P  yî^ ÁÒåµ j×ÕjäL"­„„s+ï½2dÞ3a¯ëƒ“ÞÀd€LAû\ûc"y WÊ$óé^™í3ùã‡/Xt5.…@’%`(ëOlæ‘RE SÑsíõv3РJþ™ÍƒR}Ní?€îiœçbh—jÓÛ”¦¦Þ˜üú÷×/®ß¾ieõ$Áví»IS.eY›ŸÔ‡¿Np¢FfÉÉ@Éçg$§‘»×§w´øho½#*2QS*} 3°·Ž‡ó'}˜Ë ÛH;!2j`šÃØ?¡ÖÊLŒ4÷®ì•Mëªì]ûízð “+àˬJÍxO[À¾tµñQÏúãw²E :"'×âR­™À¸/äùÀHÌc¹å¦¡ nÄ+øÕ¶.—¦GÑ®Ü#ÏŽÌ›ˆ0µ‡«-ã²lx¼*éÔ·!¬@½ £W‰ô+#õ;0Çñ{ÕÒá^`ÇÑб†`–A ­Rm+oð–—J´–u²`rabDö7X,'<î}Áâú¦à A€%ÒA¥n‚ÍQÉÒ"¿ý¤r¡¥g»¾Ý­´ž®ÿÔk‘Mñ_5‹ïÙø<»˜\Ðôršv+¶åx’±Ýéš':IkE÷Hg/SIñ7¥kL›²wð‚’ò®Íóµ‹ÓÓìê Û¢3yÆO~¸9øõà/¸M^endstream endobj 4746 0 obj<>/XObject<<>>>>>>endobj 4747 0 obj<>stream x­Zkoã¸ý>¿‚0¨SÄŠ%?âì:ÝîƒÅv'Å~¨‹€‘i[­,yõˆãþú=÷’’I™Ìf‹b™Xä}sxIÊóË»XLð'ÓýM÷ï&ÑOúÕ–>ˆétŸñô?'ÑRTJlhª˜Æ3|¤GI‚ü<Æä©wäl1peL8J2s¢„½M—I4÷Ʊm®gGɹž°¿y2 ÔjÛÄ®»`±4ÜO‘»7ßÈÙ“0(Tcàó¦söØ6wv¡KB£—AØÝlAâð²m\oÚFËj~oÇ {ÓôøâØ6®· ¤É§ü$ž””‡ZGâa§„Œm‘ÞWŠrwÓ¹Á÷%Úò¡<ªjÓæ4ÉÆ QÀ'Õ Ø.·Z+y8dÅV”QÉ£Ø)¹Æø&ËQI±)«½l²²ˆtÈ{“Õ?#—óhÝ¡ëüyý,‹Eq‚äÏTï¦ÚÛý¼£Ç*kh®žô[U"QTšm²8¦¹¬8·š!ÏöxTEÙnw7¢.÷ªÉöª P¬Ù9³ªÅÄB©5KFüpÈ3äÞ”\{YœnÄ^žˆ”<¿ ¥h]UY°ç¯?þ+~‡Ž"ñ ù©Iy`nC–ä½P©ªkY(ÀË”h*YÔ=À<ÑPºD1Ep²¡FV[Õˆ\ÛVnñ™Òg>7ež—GD­Éš0…‚Ÿ)]ùFäÙPÃzMò "¤¸É^ºÐ,À°i (v‘ø¶$‹¬q2ÉŠuöœ­[`rDŠ’é®·"2ÀE%á#•X¥`Œj N¤ SBð—ÙM) ¸©ôŒh,4ɨIeÓUªÖß™ÛÆx!4¢O¬»eµ]íO“Ç÷õ:ÃÕÕq{«›‚ÿIôÃÜ&´Ï׺‚ÌQ>Öø‘t(®¶{0CõtYýÆò.U]ü¡;‰öb$ J±Ž ßkË&•Ëy薓ݬF«k7ãјu¡5hEâó¥îj^\hˆ4õfèþ X þ•:ä’ZÂ1kvCEYeÛ¬@þÝ7B¢w­BȧòYEâ{´±g´£†Z¬áTæGyª)`ߨôªç†ÊZC;…@±†¨³5i™p£%ÔÖÐ-×: võ©hd· °Šx‘j…®Fäp¼Æ:)ÔŠè‡ñç¤Ñ1;hˆLK‹Åý—ÞA=„q]>r×Ú!òc^[a÷÷¿Ég©ÙÓÈ÷½s]~¥ÖGN¾|œÊV@*Nêm ež·+4U¥èGy*kuA3ã‹ÍªT·g0ÆÊ"ÚÞºòÞ¯Fn°Õµ½7eùø„Ý‹¿~”Õô[ú÷üDçXބЅ½Y*l!@«ÊþK»4÷2ÝÀ½`\”6Ñ{ÑíéÜ\7U¹ç¾|VÇ€6£™+d³½Pä¸I/Î¥L©Ýk‰¦%Ä"䆶užjÚ7o#¿}®á›_þå"|ù^!áÌ¿ØÀk ^þ£âIƒÓà´Úý^sÎ?m+ì v³Î,¢¸y ¯™•šf¿>/XObject<<>>>>/Annots 1505 0 R>>endobj 4749 0 obj<>stream x•YksÛÆý®_±Uã1Õˆ >¥xÚQUÅu'㺒šÌÔt5+`In‚—±Ieòãsî.žKОÈŠö¾Î}ìYèó™ËÆøç²ÉœþûÑÙØãNý‘mè‚-ÆôéNø;K– ¶¦¥l>Ÿã’nM¦¸Ô÷ÝÉÜ™ô>i$,UFÄXñ¦+§µM–ž3ëµÓ–±Ô!ci9i‡sZÝt>E€}¡¶eºÚŒŒ±3»jÛ9­mæ‘C}vÚ2]m'!ÕÆW@ˆ²3[ZÙéyÒHôfÇøeÁY"Ý£­„¦çI[ÆRwÏÓêJlz µeú²c"êâyZ[™;m™®6@Zv“KßîßžM<ªîÙlá\±M3qÜò*dgîtŒû³éL?u— g^^é§­ëˆyžë,ZOÛ×xº æ0šH¶} »ãyGödêéÁD÷3U‘·°š¼÷Q#Ó_GA+ñ¦&zÕ™,ö>jKY Oçþ úL"{Mµ¥zkIGÕÍþÔ™bêµÔ–êê; ,=ð&.J‰²ä"¹QÜû¨‘éÍ’qÍÕàÝ«ÎàÓû¨-e)<êô€zMµ¥ú²d¢ê¢úu&K½–ÚR]}<}ÍrÌ×lêÌ]ìQ‹+g²œ±Ç c<úåoE$×/?cý´\OXysH`íà!Ïd¼a{™oCVÄÈ”ŸdBa§MCî‹À< ¸Ú u‰»ªs‘Ö1ºé‘1‹ Ä~*…‚љƗa ®ÈDÌ#áO*Ͻ)òᯟ°Ñ|ÛÞi< â%{õD»ŽÒQém&EötbDèøe‡|_n½ÈøùƒÈGoE~^Ç¡Oâ4(N&®Aê7Hu2kœjÜÀšyXrBéÄüGòɨP`îX]kšèJŸ8óù‚{£JÞ€I Jý‚íIg/)ötråcQ|b<“oÍ<«êÙÜ­öÛ&(Ò%ŠÁ–ÂdF_ZR{³58h**Ô/¨ý&*…},¾¤­Ú[ZDêYšÄ«%½»iý¶ø¦W«Q¢pø§½³.`lƒp’ŒV6,‡Ï¿1±¼%ÎA3jé†+©XâŒ`Þì\½Sæ•QŠŠÂ ™ïŒIz‡JóÈ]NÙoã–®ãÍ\JÕÃOïÞéÏ4ÿHü‚ÎzD’ØÐ›ÕÃ…©Æ™ƒ÷aŽÇn‚ Õ  µ|AR3×u–ø 鞺tçîñì?g¿S΃ÿendstream endobj 4750 0 obj<>/XObject<<>>>>/Annots 1507 0 R>>endobj 4751 0 obj<>stream x¥XkoÛ6ýž_A)எ?òh†~躥+°uØšaÀ–  %JfK‰ªHÙñ~ýν”IqSC‹4ªHÞsÏ=÷A}:šŠSü™Šù9ýó£ÓèÿC?¦ôã·7G³³i´—x¹˜½XDáÁˆ÷GÇ\ÌçÑìþ]çïÎÑ´óîþïpfc€Îü‘T™x~½ÓSq“íù ü’0Hüe‘<½ùpôüúT\FsZ3;'³Y4Ÿã)?©T!su;묰•Ý>e¥ ÿmØ×}ÂûæÑùùí“•êNÆÞl…úTëµ4ªðæDk/@j-ôO‹Xb©DíT"¼N{½V8/ym¼.‰Š¬¤×¶pØ ‹Lø•JµÖ¶vØ‘(Wz©ØWø7Æ\úxE«Këœ^j£½V. H^ì(;™-hõY„袟tŽuØ•»”F0Aô\ÕF¹¾D%o~åÀFi¤.àŽ.zøà<ö‰Ð^h×Àcð[i¸R# ;½ÖI ³=§m%dYÂQÙ®$0´_#lJör‚¶ó]za‹XEâm¢'« Ã2Ò{XŽ•Ý¨5G0é첬,B/½ÒÑZĘâ,ÍFnp6§˜Çª ‘€u C¦ UODO$n, ãqÇzˆb@àb[*B ÔÉï+Ec(DØ´àꥃI~!:HOΆ €~ÄÆ¢„”r ìJm[%Á:ˆQÛ†Ôž "«½ràÇÙ˜˜JÄr+Þÿñö ;Ì„ô"‡S•D:e¤ íþ)k‰k„ù“CßW-ê/$hjíh"XÔÇDÚËÑRV”®£Ñã¹:H5‰¤@Ü«Ã9B¥)ÚÄ\8M ª¯@ò8* Î’ê ëT‡4/å8×l ÇnŠHüØÈ²EðX0É5ip0JI'€¤ËN„ß–PzÏyÿì]Ö0¹/G(7Κ¶þ‘yñC:ž—Ròâ®5‡ÌC:ÝŽñ×Ïž=U±±¤Šš¤œ?b 5£É4ZL vpQ3sÈBf2ÈaTH4¶ÅZZ¡ l\YǸ:^5àQ±à“ ¥i9_Ðã“Û±×Þ¨Û§º|r¬]ëÍšÜh®X–ÚK£ÿ b$Qƒ<Ô¼#Žé<Ñ:)y,žx%‹,숥ãBB‹-~T½8€ ´³ KÁåÈ ¢<ùŒ2h}Z\ȇ[öžzï«:ö¶É¤ŽöB© Dás¡´¯¬Ý£1¼Fñ‘K3\ß=j¿‘ø™ ñGÇîä¯Tüµ- tP´2ãWHãÄÆ5‰Ûr›×ên%kdôÙæTˆÑ¨1¨_':v7j["ÅàÉ®f»Î"·É²v)Ìi qí|*Dãê²´Uäšusˇ[¡W£#Ê$AGÑAfa* þ…Œå}Tª¹ÓQ²ãwêcCŒ¼ppkkf•³¼7U*Sw{w¢, H@üür`J0ö˜†‡jŽz•Õ? &Mš÷Úz1ê1Ï|œp­º1È5y>úÅ$#ê °S§©¾좭 uÞFQ•ÂÓд/œ|Hÿ¢^ºv(F$miLT®T±N·„—ÔñÐçpºý€*Ht…¶‡¸7ý,¥P’…UÞi-=‚[ÐØJQc½¬2Åâ¼ËLJ¶øvoÈ g½œR=e²ï±ï,MyàÑÁùK©É¹)µê ×LB˜»e“¦eR «)¼Pa( šÛ¥`»[Rët?®ó9* fHe2XÜÕG±³þ'khø…Àà;Øz_ÊX]]½¦OÏWWÑ70‹ñžúã Þe)Ïúû&CÓÐCú†‘ˆémeTMÓèCA£«að¶xÃ!@åúûTPÞ0MUœ7ÍìiXãC%‹Ð@Ó‰…Qt9ÌÁôߎÙH˜z¤4‰þÏ_¯NþüûÙaÉ® *ÆÁ à Áßt”ÂÙsù n¸2¤>ÚƤþ=t¥L)6•,IÖÂbP5V&Ä}y¤ˆ ÄÊ&ÀV=ûj³Ò˜´H÷‰J%î²h¤·L¾x -)3Û‹+uBÊ-Žeÿ3nøãWùRgµö[„ÝYSsó" íí´¿¯ý20î6Z:žœÂüT"È߃â-µ’Ý·¨¶¡ÄÌNIOR¤j tsCn›/­ùÜ ù÷ݽݫxUh\غîË%¸Þs?nTˆ’b¥\ŠyQE"|>àèl1IçªÝPÓ†‘ãùî¬Ô`šËØ$$ÞXy0°åÛ`>â n§Ì‹ózfN#Uc€b‹)žÀ~ ZH &¯!@c‡‹ç×—ÍÍuvºˆÎægâüò’>MÐt2Ç7¦ï»C…_eÂÊ“ º&}ÍWŒ³é4Âñ¼k1£Ã~¸9úõè?[¦ÒSendstream endobj 4752 0 obj<>/XObject<<>>>>/Annots 1509 0 R>>endobj 4753 0 obj<>stream xWÛrÓH}÷WtR8‹­øµT±á²yvcŠWm¥‘=DÒ˜™Q¿ì·ïéI¶ T°2£¾œ>}ºý½3¤þi<ãqÞDü† ùÇß:ÃÙ šÒh4ˆf”Óp>ÆÕSF×ãçœFãQs—OÿXôVÍšÎßÃø€)<Ï^àCââCܽvœ-¾uÎßOª;]R–v¢p2¡rU~XÚH‘HÓäTg™Þ©bMb»5ZÄŠu™%´’äÄ,^›âàáx4 þhÇxJº§j]h#éääŸÓUx’·ÒìÙßš_æ8Ô..|)ªâ¶² 8ÖÒ3ŽýYu—óƒa# ‘Ëe÷äÔž,ψo¼ºoíõ9T&^‘m–‘*â¬LÒŒua)c§‘w"Ÿsé6:±$]ÜòX=\x•Cô`YIq ƒšÑ‘wÛLÅÊe{*«¬ir~8—/³yìÞ¿ÿ÷¢ØÒ—€QK(¤ÕÂë´Æã$ßD›¾q ש?G³Ù×àM¡90c·QàG®ÖÇä\y[*'V™$aI9J´´„÷ÈÈï¥Â9âñìBA¸5Þ5¸Ç45=´k®öu9FŠ/1ÛùVZ*Êe‘6¢Sºq+’„Dч*nÀ®(ö𞯤±¤ÓƒYM» Èè‰r/ ¦´½V<éÀˆr¶ÉÈs¨ì :I&Q€ö¡¾©éý4Ø£Ó§ÊzªìU7}*À­*v襭y¸O¸›NûYs=L…4à©oÙþhZSaM¢9½•©(3w®·NéBd$̺Ìeá|L1‹&Ñ„ wýõê8²Ýj¬’`àð7Ù ,£KÔ'¡ËçÏѪ‰Œè½6(¢È·™|\Táh›i·ì&ºdÞ¡Áç}æ fÚüþõϫŻå™×C¤÷U)d,¬ì‘}- i„«Ca r3c~ÌIन":äk-e¢X—bÝNÅE5eõ|OË"fŒá¬ãÒ¢­alv[é¶¥ÇÁ9õÐPŒb\`¼üêÏú‘«3ºY)Ûl»gÚõèŸ'd‘´/·6®+è0ÆOhŽzPù*Œº“A“ËõÆÃûæãõØaø!LrÔé<¸šX&²¼{–‘Ìne¬R¡®`†4©ˆÑ°ÚÜøùè™XçëËа²êæi3}Ap¦÷Gíj~ÖÉt¡HÌ ¨’óWœ´2ÇV1~iK?bi Ö3fJËbòcÜÜ|¡EDÌr¯0ˆ}…tµ‚þ‰„SóçÒó7 ÿú¦/4ÂÅ5™+ÇûàÑÞwå §U0 5‘ *nõ nóvlÓ*Å×i+¢¦8•Z³`«4JhOøñêë1$,¡½ ä«D¦±¯Ò#„ñ­{3A;@.xy©R’ža<…}ë"úœIô6¦¼³k†×ÊÐkh7v{ÃÚÕ­ªí„fmîÕë®0E¼ŽmÄó¡¥¥#ƒèœP™­ØTk-ËåŒÙÄ*û‚>kÏM? k°ü1¦ÀJÄ7Ëí§Òåµ9ƒú 4N¦VFŒ>YRmD«n#K ÀhK… gû³úý­¶V­0”pÕJƒ‹P¢&¨Èó´Uxl”· ëVÅŒ0*D*k\Uw™ñˆ‰ëR[ÆÛár (ŠeÇ‹aèO^7‘ÙVDÕLé¡ ‹Ð°Ý4æÕ kº²«*••*€ê?z»ìò££fþ[vÃÁ™?êá1x¸‰i¯KJ•Á‚ý€µ„™ÎÑÄ…4½ßoœDü`l®“2ð◹ÆÀ&ˆF  k‰Ê«êùýjàgl ÖfQÄ04?c׿Øþ_¿~Í GXº–Ý»Þ~yÖ^~£(òãÁHWš‚îž7Kß]p\û÷Ïlî×qoÒcËg­K Íæ& e7×ÀŠ9ËSž7$ì„»ªÞ¼ëá|MÇSšÍÇÑ0|maAÅPÐ[ûFð°e?Eávÿ",æÜ“ŸWüÕ†‹qô5$-‚óˆ$wè‹ ÍzÚ}¾Ò™oÕépÍçøÎ†ŸŒÙÍ»Eç¯ÎÞògÀendstream endobj 4754 0 obj<>/XObject<<>>>>>>endobj 4755 0 obj<>stream xÕWÛnã6}÷W «¶â[œlZ¤@·ñ6/½`U싃–(›‰Dº¢Çß3”%[rœnÛ§"±£ËpfxæÌáäÏ΀úøÐh¿aÚù1èôý>Ö_Ù’®¦}ºõGÄ4ìÓäãÀŸLn(ˆœUŸ‚Ð#šªDÒÙ÷6”¾?ëR¢´¤A—”¦.‚§NŸz˜F^°]ˇ,3Ùñ%I¾öéáu-Ã\F4_Ïã¹Ò¹ûðWcõýý=ß_MÇÄîbê!£Þp´ËÈ V’2)¬Ñ›Œò•²eÂE¾9}ùúø™"#­þÓ³6Zá“JÅšÙ0Së\é%%B/ ±”:Ì<"“OŠ$YˆðÙ§ŸÍF¾È¬[%9ä-ÊWe‹OõZ‹5š’ ‹= K"[©Ô¹¥uf^T„§[S „Íá©Ê”ÍBÃ`æÓ¯t#¶œjdÊñž »dûTÓáÂx»dÎ+MÜ<ŠTÄÕ‹D­žÙƒ²w•}µ{á?¡ö‘wuIÓ ŠÊW€¢‚.¯*\‘-”ÙvnÖ3osOË?3ï/.Ü«.žãòâ» T´ŒöŤr¢*ƒm«wèˆ(:ðZù,¹×´´Åâ-Ó"i[ždà£.k +»TZÅCr哊¾Þ‘ ²:2:j{BJ-3°+dÀ*œhm¬Ìö>LÊA>™¿AuŸnÐl¬ããž^)‡«YjÆÆ™½Ïôë!FÝq— tQ9s¥¾iܽ±„ño. ÛkøþdQþÐPƒ¼Ð"—ɶK‹-E2LDÆ}ΈÔ<®ÀÍ×e£-zV’6”½¬" ¥µjÝc4vFBxä«H׉ü{p]KkA&BÉC3/56‡¨…P —(”É¢aœïZVÿ›Å4€µQ›Ò¹À~îèÃ<ŽûþŒÃ#9þð€Œ6°Rc¡4¢‹Ä‹P ‡d¦©)¤Äôß/ê:,§;ák·ÆyUÍ&%<öS>:ImN-ªeÒþÿurwlͼ³s;g{Í-õÑéô;úÉïßSM~ÿ†VÖ$=ßÃì„ùd¿èÉê„dÞ4Ëæ¬0‹Tä÷l¾¯Ð÷)N}›ïz¯1i¨XIÐÐ"eÀ)ù‚ãc¾D¡:A-š±‰m’¬H¬EÓ®ôqĂñjF#¨œ]°Ü„IMÄÃK*0°TË8ææ,UBÊu©|]'*TyS–'Bpþí¼öH7ô|¾¯Óüº’ÚõÓn¤pJÇç¨ÌbdYØÐÆdÏNÿƒâƒm-…ûÑ?^u¬ûtBAý;fKméò$1¹nvÜ0ZB‚põDWŸ"Ý’b"arf¶1,Ùv86Ø*;dœK¥ˆ@SÊþaàF5s<áƒí©ÀQQÉ¢ÉÔ3XÒ¤Ý;Ù̼²F{,J¶\MowSå°?ö¯G×4™LxFãYº7òûô“ Ý4+¸87Œå¥e璉–kì¤ßʑĭU3€ZÐ÷J~]?]þí-þ3AŒñ˜ý=ß;)9Ç©endstream endobj 4756 0 obj<>/XObject<<>>>>/Annots 1512 0 R>>endobj 4757 0 obj<>stream x­Wko7üî_±`äìÈg½í´hçáÀ@[ •Ò~`Pw<‰1ï¨ðx’å¢ÿ½³¼‡uެ&h[t$wvvv–þ|Ô£.þ÷h0æŸ(=ê†]|Ã/=~ùãÃÑp<»4ðkJ£î0WŸ4Mx=úX‹gý×á°úÀÞLwNóGÚ_©×¥i‚°ã×xûhx“¿n>ÐÊšµŠeN‚²"KK&!yïd–+“åä åNd±°1½Åj•¹„cSáœÊä–ÂQ*¶4—Tä2)4© ߪœ"“9œÒµ±ø’‰dÏäÉôÓQ—Îz}à £µÙðYka•p[®Öá—’"¡õ\DwÀˆ­©X­€39ž#Îu9åE´ä|öù5øôYWïÞ•ßÔ<§K&ß|±?]öëÇ_ž,û¡Žu˜â>rê÷ÃÁŸâàü”&&}„OI‘Eœ]N§ç¼“àŠÇu†³àÅñ,ðéqv³“üÅìäÇÖZðO"ŽgÞtð»ïy^Ì>O ýìóãÌÔh|àGùôáx|Á ¯*@Å‚eSÓQQϹ ²ÒÖ¹”Ï›BpñÖÒ¢v\Ôh)¬ˆœ´^s~Ÿ/qHW‡C8å´§ê‹ãÅJ9¡ÕÔÍ:J”Í]M¦—^“¸Þ ^leîXü;@ª­ý¡O2³é o• N’˜›Â5…¦•A… Õ%5p¥ÝÒ‹%ùÞ‹ a~ÑOZo™³ißä)Aƒm¬rèL´G+ Æë„]HGZd‹B,|›q ŠŒSD‘IWZåKÓF¹¥çíÊUsÛ•LÅ U@JgYlͽ—0)\>BšHB0½í\ðš`ZÔŽWà ½¥¶§€ED©±5u-0*‹Ì©»OÒcµð©ùã~¸F-Ü2ú2VVFÎØ—Te2óë×ÔÂ=½/žõ/ùmŒÂMœ-"Ÿ®ç£È¸aË=µp¹Ë‡áå%o™²ÑåÁ®¬šWr›Ë¥X+¤Ž}¹7K”~É<玹úmrOEÿ|GEýàí"¤÷-?^¢Pºí¡o_½"kqiÂ’2pϧîÁ3ò› •Ì"S°JË&‰%ä¬|:À-Ñ2ñltH9Š,Dá§FÕñʈÓšÆåžW»”qK" À_G/%_(£ÈÁã£XÌßîâTÜ €­ ÈkèÔT˜vRH%O8y mÔˆ[Pô´™DÐómY¿\¡‡¶â67½Íq22óO—LÙÃåéÃo„\B(g¢¼8qÏHÜ©>2%uô§9ý]çâÇ UÿbS0!÷mç¡=Lþi Û;<.•ÃÃOP+²œç=ˆ@Lé¤ÍÈ~¶úÿ»ÂTâ¾½¿E¬YÐNæœÎNžÉÉJô¨§ýìçû=I5³µh{(PikõP®ÙÛ´ýúHÿ/Ò¾B59­Š«’ƒ:”`uªR_ ]`>>C$Hƒô._Xv(¿Ý¨Ûïuû­Q¾GÔ‡QŸ½ìÜd|éò¶Ø)Í 6@˜(4 ‘/¢lä°@¤pâú㣧¨£>ƒ{x«†Õù¦ò-Õ8\˾¥ùO3¹¹-jì­w%åYPÙÅ)VñÌ4Ñ,èur\”LòDJ³“§Lïm)ÆRK'›Ø_ÙÆ‰•rø&ß#»óëËê ß»†£ÁˆÆá¸ç¯Ö>/XObject<<>>>>>>endobj 4759 0 obj<>stream xµV]oÛF|÷¯Ø—"r*Ñú°¥E´nÕ Qš*}\J“<厔¬ùï½£(ˆVœô¡¶ Päqowfvö>\ ¨ÿ&òQùÅOó‹~ÔÇÍæË®èjvMƒ>ÍS¬¼ÄEâŸãBuÞ:]¬¨\³cÊÌ®—ñ–3Š•b猥´*T©MáºdîÞ³*IáòŽ)×…Îã,ÛSzSeqÉ ¥ÖäÊØ®¸¤,.VU¼bªüNÊ$ØHßãùZ»ï.çï/®f}šF#ÉoاÞpFø•t¶ô¼[þ…M]t—²K¤˜¤n/–ŽËEgÛž¾?<ôÏ/øxXзDQt²c—Üä³ Ëðö|þ£h2y! þfv@Óv)7®$“Ò›w·¿>sGHr“T;Š3ghcÍVœ˜Özµ®‰ÐEÉ6•À—¤bY&eŠ-š‹2¢ß™7d9N@¤O÷jö’Ã@wo8‘LÆÑ8Ð|¿á„S0™+m¥Êʲ Ò^G×ò’dK®ÚlŒ-§454"‚A!íÖZ­%±•.%³<7é‚n¤¢•sGOÓ\ÖiÕÿ9œê¿ÄTwÓCwßýøýÉŠO„àﶸ5\¼[sA\(S ¢œt=;Wå`À£+ª-✅*¹®åŽÚþ[<óÐ)€] kš$ûŽSpÑ\BÙþ-(I:‰NSì_€QÄm¶­Ð~Ø5pŽöÝÚ©‘ w u °àB¥¡ÄšÏ·õvÀ³ýò=ïwÆ&ÈŒ4h]qÁÖ7®tfD34=?Äù&ã§Y« i𽾍[’ž¹Å%gÒ2d罤÷ê¡Eåi²­vº+;”[#Xz®@úð%GWùozÛzwYþ¯êk”Õ¢( wZuG„á Òè1ôõaœäÜ~>ëýaðñ~!igÇž„w¯àû ”ׄUCâôø‘ê‚ +^ëe+Þn¥«¥’£)‰l厵-ÞЧR­›ð¾9×½²– NZ1ví¸ç1OÓe#gïW'ÄØÑÆjâÓí©5«ûàe~ñ¬qéf p” €¢ð D÷•Ú¸,@Ûšlë÷{Í2Ì2v+::ãNèzÊ9¿cë¼A\!2=oëaoóþ—ìao"„–)‰¡(oaH‡ É7ê0 ' ÛûNüãíë×= ù€?¾¹¹½=À‘·aWabÄu1A£hj-¦,¼o,oµ©ü`jˆSbÜ9Úià€Ó‡Å,ŽÑör0‘$`ݼ“¹–5%XÚœá›0)߇‹ƒ€üq£}¨õ=3æ3FØrêr‡‘Öøé”8ï~Ç6Çq E»*u#çñ™Yô´}‡äüR\z÷–R¾Æº±®÷êq]>9Ày¸Zø3Úaƒ.…§ê³CB§´è`Š„}°,µÌ'wÎcÚ¼‚£ã¢vÁÛƒ³Œ >/XObject<<>>>>/Annots 1514 0 R>>endobj 4761 0 obj<>stream x…VÛnÛF}×WL´•m‰ÖͲ ·òЭäE@°"—Ö¦ä.³KZŠü{Ïì’”H;NØ!9×3g._Sšàï”æKþçƒI4Áþ1åÿ¼LgËhFóÉ?sš.íSFwƒãg|½šD°äeý×£g|½¾Ž.¾¾[¹ó>í=ßNè*šÓ*¥Ù„–×Óh¹¼¤U⃚Ð*RýÇ•6.öë¡Ù|¿Õ"—£x}òædõy0¡ñ¢I+jeYYM­dWê+ëœß.ˆ•RÃïx6¯ý?¤Tn•£ÜŠe,%*M¥u”Z“Ón+JÚ›Š´” )Íÿ·$Š"S±(•ÑnuIw?¼§W¹Ì7Ò*ýŠÊ}!sQP,4,Så ]Š·BßKReDwR²f“ÏŒó©µË¥´”"ž´²C\²*sQ­1[°ÆŸ¦”¯Éç )ä‰Òú<‡ãøì¬›úLÁAòåF}-w} ¡“¾T"3YúȨIØCž…´='bìžD–™—þüöš¦H87dz%çq]€¿Z+ö¬]7–\D>g/å(‡( !êá|jE2)?­“©±£ÓóNL_ Ö½™ÃØé±Ç÷Å1–a$0)v–‡ÚA•üˆAœd`F‡ º‡GTi®³çD`i;L!++²a×f A7‹NS˜ëa¬bkH©ã¨ÉÄÏ EI™ú—;ñæì ³GêXÒzè°¼pwScuYô?=-ºRÍ‚®O"ZñЩçÒ £©Æ(±É p”ºg•Äâó‰d˜•.u"³Á½Ì.®ì)jõ)ýt/ËõIqºYŸg­Ò/ž1ÿM1|Xëݯ`?i¹ïœÉ¥? \µ)!¯œ hHC‰Aç–[OžÂ œóðÎ Š=OSÞ¤¡(üä§’0çø¹u(W§©G˜ÓEaœô'ÉN`Eø³"øðž=ì—mñ±UiôÞx !ÑÆOÄ6ŸÁŠ@WâåÚ‡ZwÁæ:D¨Äüòåö]Y¡Æ5ã0wNÝk¿Jp»*c M‡^ƒw¦Ê’öÄ:ÂÓÅVáØ¥ 7WÅK®]X .ƒ*Ãzňå Ðî¼N b“|g>—.èÿé±åiÓàÿh~Y_°ßd–“Oœ=cT…ó¡WÊо³Ö'ýjµíx´ºÅžTQöu^‰ÓˆÙóœ8öüò ø8mÏÅú8n«ÃŠíÅä¯ç@\ÏøóÛeÃRœ=žçå92÷E¸µø¨âRmÌ>»Ó¾^sOÝd8#1õxÁþ켩öòç6û!(^ÕqÎ&‹èb~AËå"ºâ-È'ÖxMè7WL×ö$ ²ãË0ÊøÒÑ n óÌòÊlÅHá°ËÙßÅt]]áF†ƒÅ%¿ù}5ø{ð?O±endstream endobj 4762 0 obj<>/XObject<<>>>>>>endobj 4763 0 obj<>stream xW]oÛ6}ϯ¸(PL]lÅŽ×]±=´]¶¾´X / Z¢b6é‘T\£Øß¹¤>,ź6AÛÔý8<çÜ›¿Oæ4ÃלKþΪ“W×'³t†7»ö–ή.h>£ëg—/ðK>Ç/YòÖ“Û˜ºÌi-I/sòáñC9òVhW[ ¯Œ&ohk”öÒ:2ºÜ“ɲ¿«‚>~zûÝi³ÃCü¸ \xA•¬ÖÒB rÞÖ™¯­$c)+…s)]ûìúËÉŒ¦ós”•(í¼Ð™œp̽©i#òÁ£¥º“¡¶ ?wv5£UºàÎÎãü<],ð*Ob.„7ô­MÀ}'Dôéý‡7øo÷rðÁ?áeÔ4\¤Ëås~NèœÑÙ(}K;áB«šÄÚÔžÚJ"Ä Çoµ¨'”,ui§Ê’n¥–VxI•š.Id™tàµÎpG]»¿´I޶ZB³ŸwŸo¥¿I¸ïŸ‹›g›'+qšŠéocpÜ•3|ˆèBÄ÷ïqÁ»e-Fç°ô+…#|c— Gð¾6Õ[«Rù=½ ›†;xÓyºHçsâÛ– ܲ²”Âɲ‚Âk£§[«*åÕ=€ŽLdVúý–÷dNé£ÖóÝ*ÝÂøÈ´ŽIÏùH"6µlšJ‚*â{}á½H¢(8=+‚Õ4á¨cµ1a•Ô,Héšã»ÖÌ赯­wƒZåWåB™ÉeJš¼—¶S’–,mC^› ×(T°¹„->oáálHP"W[Ú„œª¶x£v\/\a'lÞ¨zPHŒ-ÃÕÙ† — ¬ *,(yÒ ôå“`i|ý‚Øز¦çK–àeŠ/zM„¬ÄÀz˜ ¹ì^Cñ£é?ü‰õ·³b»å[ŽçaEðxn6 ’ûE{E]2RÞ°‡e¡•«¸gÊK@¹ËlöÒ¬¿ÈÌÃÒÞFãÊþÉSn¸¢ÎÞ„Þ ™X¨½aÍÚ1ôðYQ4×»ï@†§”&»Inž aIj£Ã…•òÈÑ´c×¼,Àߟ1Œ  É:ÚufȤvà† _l.é&Q©L'ñ gÕ9ÍNOÇí˜mOÊÅz9±Çg]Š)9|fª WÉǺK¥ao)½>=enàöó’Å¡ŠBZ©}¹ ôbr ®|'´oôezŸÏe!êÒÉË7‹!‡ùÈ3µ°ÿI˜z™€*!³#ý?Õ@)ÄÊ|žýÌJP¢ ÙïOÇî[Ft Nÿ3H †Fœ€m˜Ô$¿ 8@kÍÞº¥a‚öÁT5·Ùšãh ´ý<ùieòº”a§ª0ÓÓ´½v—<Bô³>ü;;£7A”A¶ñðJZ´qqˆ1x™£‰2Œ;À’³!Ñ9•Z¬QìcYú[Ð)Øuض¸R2À÷¼5åd¬ˆa»c¾3•Fd`a±"€q¹ºWyµ£3C®UiŒKìÿ¸ða~^ÈÃ;s €`¤87F{ð:–W¸æ»{|$lkžùqµcµ†km¿–¾¿yȉNÃG£>zÖXR·ØíØšYÉ<>U†ym¶´8˜]Ø>+ÂY¯*I[ ÂÃxy1vO`Û" ï°FŠr'ö¼ù„• m¿…1l0H\…¡Ä„’ù„6í^Àëõ˜¹rµ\nŽÿ¦¨¦è³®‘¾zZóäD§‘§'IÞÙÖc2ïÅG#ŸT:šŸ½ô‡)Å’=àÔA[Ýj€?Œ~ŒU»¥ÕAàö²bÔ³«U³ÍWéåâ’–«eú<þ1–ÐE:ƒ}eu…ù숣ãééóh}¼#]`›mÿÒ:ø#, ÇËù<]­°SÁ&/Vâ÷ë“¿NþÒKZ|endstream endobj 4764 0 obj<>/XObject<<>>>>>>endobj 4765 0 obj<>stream xWýoÛ6ý=Å![P%µå¯ÄM7l@—-[lèPcÃ0-Q[‰tEÊŽ3tûÞQ¢myÉÒ¶id™¼wwNF4ÄßM¦ü/)O¾™ ã!^îþ«–4¸Òu<¡YFã!M_ŽâéôÍR¿jH³$úøåùìÝÉàöŠFøœQëúãI».º1åJ8µP…r[ÒÆÉ/šõ—íúˆÞTÊTä ½ýíõ÷ýQ<‰_ôü3¥*å-´”ZVÂIJe&êÂQb´uU8SYÂæTî?ÖºÖÒÖÔ$ïV…J”+¶äêJË”]#¼Ñ)D.—%MµUzIMT@ÄgõKñ^þÕú;Š8¦ÌF®eÕ#åH¬VR — G¥±%>o„vœU.Öò0`:=˜²Z'N!!²†íåÂvÂÔfC )5I-…LI°¯= @0n¢ uà*\rš??„ù,—•$Á?ܲ½c´y8{2+×§q´çìÑ=©ª$²\Ëmr•ä(­ålha\ÞIÕTeS¶”:ˆ´t@1Íren]¤TH‘2à¥,Mµåï-‰¤2`'èDµ”Ž ¡—µXJÛó)qXÈÕ2K¤)K©SÀÌJ~æëÉÊá—ÄüÉpzúã)#|_ÅSz•¦Ì#x_Èê ªˆè†zÖ•ôµÜöû*žN?1uvÁѪ2k•¢>°˜äB+[Rp’Jâ<ÁQRk%2l½Z™Ê¿6‹w@‡BIíì,+Q–ØÓmeJXäx°me”v½´ÿ³àˆ½«ç¨ÂžfÄ]øIøÜ™Œ„s"É9Æ=·±j—MZyðµ6UÉÖ»Á¬šSïÉF G^èD²v¸3Gó¸4‘ÏÏczU¸ÜÔKO+Õ¤€(¨ÄiåÀ`ãæùsŽÝÖ`£ › À`',7{´G™´ºµ¨ÚÚ=Û‹6 L¾SyÐ ¸§…Zr v%…@Ø*7×¶ÝœÉ;Ú5o9¢6ÄÅÝ=ɲ¯8­øø í£(@ Öw©çù³ª+ì†@°¨UáI+t‹ßž7 †¬2‘ ™·Ì.”‹O„ïfÌ §y®…Ok’™¢0Ò '•à*ú7w¶ûN•þxO&˜1i4¸h ~Ak ž–ÓÅ ØBcN£8ö§›¸ÿì¶+‰>Õ²~õÛèïÎjÿ¤¦fÌîzÛÞ½ŸZ;+Ûí, ð³l²›e¿#ÿPqPJöqPÂÆuó2ˆ¨0æ=Ö˜b…òÛü¹¥Å–6•ò'V4Ãnx³Ð¡±=Öà,ÕÉú¬4itËmóÐý²‹ÐgJ'Ensp?í.ÿØ~ÄpGÎþ»<`L4ÐÜ"ÐuL§¥Òà{‡0]Û õw¥Û[ÂŒ½òÝ„f§cìJ»±c3Øhj2v•GËòØöÂÓýüüºtÐź˙ðuø½¦¯Ð‰Z^À*74“Ì#«î¥ÉÂWóóùù†ú_ßÁÖÝ“«¶Xµ}rÕ=VÑ=„~W’å=’`¨}sàž¶Oâ—URΣϭ,²ÇRØE[«R,µr`ç¼Fôá×uUáì~Bp~ˆpÚ’ä³ešŸ?çs}Ú£h/>1¬ ÆCÿ9j`,ýì¬-P¤|rú˜wݼ f¢ÝØZ‹J±n‹éµ³ºlBE;•àœó@ò£õ7°g˜T¾¯5*c:m!Y!§‚õPÑÐh^98Îpç¡«ïF?\UòC¹œòœ‡råE3yžÜ ¼Çý½€ìV;qÇêºQÓ>n"ª¬ ¾[ˆãÝhö–z„ µŸ¥aÚÏ‚h0º¤^8´ÝTe¤ I£p<4‡Q²Ö…ð@l~<¶Ê…5Ÿøª{Ò¦îáˆeÁc Ú )=ìÕËÒr9· iÕ_éžÔû[Óþ‚±u•3ý¹ØÎ®¿ží@‘.ZÓ´E ÑõÈ,¥‹c' rÓ ~aeÐᖳ᫠Óp‹Å$élu2ö¾Ù_ÝóB†yÊÒjÅîGn(×­2/ã«ÉM¯§L÷—ÔI<¤oMRï Çâ°5kû/šVÉ÷‚+/ n«ÝÛŸ/ïÕh__ã>Ñzù’M}7;ùåä_`¼Gendstream endobj 4766 0 obj<>/XObject<<>>>>>>endobj 4767 0 obj<>stream xÝVßoÓ0~ï_qbš”–ÖM›µ”MLâWÑ^ˆ (š²ØY{$NÖÁßÎÙ±»y´lH<Ñ­©“»|>÷ùÎß:#ñoÑTÿ'yçÅ¢’n/Å% ç!ÌH‹Æ!LŸŽÈtúÔx…°H‚ÓÓS¨á|d‰’Å2ˆúGýpÙ…»ŸxY°X1ˆA°k¨{wñµÂ`„HÔ ]\(¨I_ ®*Ê–ÁïXðθm<˜ ½{ 1À»ÀW +å½û¢>õ‘¨/ÞsIY† ßù9€W¬T…l€¼áüôS ‹ƒqdY +XÓÜ:‡l­˜ íS÷Z”ȯ$±€8+%\0¨JF‹’S ±(K9òÆ¥™š'mZ£©UŒÀ\ÀÖq~•±c7÷MŠã1‰"L8 †CHyÆàØ&‹pƒÃ\Ò ÍyÓ|ãwïö€‹$Ãl£6ïdõȳþ°·Hάš+†K±Q[i鈧²ºÀ(Öý¦¿9ñ@‡etÏûÎËéw‹vÔôÝhƒRü„pá¶Âuî÷§Ãz ?"î ÜŸå‡åÁ,r¯¢ÞJÜbj«êJ«É IIˆ“„•%êC±BÄYÖÀuÁ ÒJ þ¤(áª5 Žj}5Ê,“×Fk"ι¸„DŠš #B«O´òÒ-q¬3l÷(°sO ô†Ç(eØsêÈ™ZIZÞu¸Oyvô°&»´Ý'/—tTï¡.‘ËÀ9¡0rdW&Ë ä&SgZv—Ý=ƒÓ5b¬÷Z´6{­´îÙààNà¾øjÉ©®xL±-Mn1µ–ùNNÒ‚aG»–ƒn7»e»E;ßÖtÇôöãÛÈËo…Âi ž¾<ÆK£GmôwîŸBÀJçë̯th>¸!Ò8a¦$z‹ýOë öá¾ý"y€,pc÷ɲRwð­ –]·ìï­ZxrÛäãÝQÖŸ!]9¾%á6Äkže&N[nkêäY‰uoÇŠh›tŠ]×5¢r%«Œê²«{¶ñ±ÝºmÓ B*Ï‹\_ÄB­ßl½ÿ¢£»÷í4ZÔ—¬h7ïp>³GÑìˆL¢ Lgx,h>½D$„W2©r,î±.ï:ïx i½OÚf8!2…ç”êV³ü'¸éùË›Ãˆé “ÑˆÌfxĶ01G·×‹ÎûÎ/ÁYã±endstream endobj 4768 0 obj<>/XObject<<>>>>>>endobj 4769 0 obj<>stream x­VÛnã6}÷W PX¾ÅNÚ´ ¤Û¦ÈK/XcûPM-n$Ò¡(+Î"ÿÞ!)Ù¡â&(ÐÍÂx™Ë™3gøÐÁþF0™Ùÿ<ïü8ï ã!-îô7C¸Œ'0_Áx³oGñlvóÄœGPÿÒÀ–e%^uç_:Cèh;‰žáVšpé ÊÄnà5|…8ŽžaЃJkä$ËzƒÀÔ‹{Á[ÉÞ¢€)€Âè’ ÞdŠølB_¹½cÁ‡›Ý\A`Òþü:ñ&ÚÚñÌñ`õýT7ç`Á^AŸRî'u¢yŠA $>rÜ¡$&¥U]fŒ aR‚†ªi7Å&AZbRÉ]®Ê"Û¹š$P”<V|g‘ ÙÑãÉ„¸’D-¤ŽÃž¨rIÃ~r{!ü ¢~/Àå·{¶«éò¯h\C&Œ!‡÷RUVÈLIð¨•K¹IÇÕ¾üjo‰°ì[‡ª‡ÍgXV(X"”ž XBHí$Yˆ'ZbÆh±, R1´=«D¬vÎõS¶J7Ü[),|…r 3ì……nÈ>²|“ád³QÂN•P1ê)@ÎîZIål-…)l§Å@#KúJR•÷‘ZdZ>Sò>ÎÊYºnϳ ‡Mª’æ Ϲ3e.Ö©J CTSÔè\%HÕ¡ˆ-1ߦÖ`×.‰Õ‹` ÒCt{õi(ã·Ž´?W>/XObject<<>>>>>>endobj 4771 0 obj<>stream x¥V]oÛ6}÷¯¸/ÃVü;î†غ¥è˺-úb  ©+›©Dª"e×òßw/)É‘ë:ÆæALÞïsxÈÏ ég“ÿʬóë¢3Œ†´Øü)Öp}7„y4Eã!Ì^¢Ùì±·ÂBv¯{pŸ£T‰’ ²<Å µN &‹îz’RK^³˜B*½)råDª¾ÛÞõÕâ±3„¥YÄ]¹ôþÄÂý E†eÙ ÐË—WðOå0ò™ø„ežc±ìæƒ7ì´¼úéȨ@WªýöîS«‚­Q1(vcÊ4†•ƒÖb n#à5ýgÊõ¸eÆ8ë¾Â/uVë]ÂJs˜Ò‡0 â4î N@†ÙŠ`êSD´è׫%嶺!3°~.Ul T©‘ U(ªbŠˆ”ê5…X#(®Á¬Q:Xv1ZG>‘*€&Z¢…¬´Žk#ÒQØtv¯¹õ•ÚM “~QÖ1ã„s…Z•޼LÒ*Š“ÐŒJIä tetBiŠ€©ÅÝ ¢R¦2­fÅT½áŽÞš,§&V*UnÔ/þx<¿Åk/M:¦&è l©w ÂO“‰Ì§Æâ8 -CÂ2¶Ç9›HÜ+-¿-àû®²â ‡¤6G¸üÀªí0°rÈŒG•˜òÈTUõÉÐïØ’Nû*EhêߨFX‚)7Æ¢®†ü8iB5ÏxÈÓhÝÂhÒd>jÚCyP>H)¬'o!/̺ìTš±¶&¥!"Aª>1+iì|Ï…o0G“ É`Üuûc$eó|›Çbþ£´cò²K[jÂ6@©Y'O;×6„?Ê3þtœÚ66%Ïâ l½~‘c:¹ÀÜë!›çgÍŸh¶îoÌÛu>Usò«Gâ5iÄëã†xpÿñý;:ÍÄAíHW<$^ÎHØéd|,ØÀætêüé6´´Ä‹œ+„¶ÁžOwŒ2Õ>hüab)¢ÎI:øª"³áCò´#Ḍç ¬!¬a:e am{ÊÂÚö(kóÓPÖ`=´‘ ó ÿâ»ô‡§Êó?ˆã9ã6HRR pt½ècÑmå;Ì©XlIî¨ «âpUÑ(ˆ~‚d4Q)Fð‹”t£’ÝáaãóÓM²ÓåC»+ã6-R5Ilïùv#½!¥Âþ³@%ÚÕxó<[íA¯õ5¼ŸÂổ7K`Eõ@Zv[ÞÐ#‡ÌàM›áIÒ~ 0×[¾íÏ ¨¹NyBœ.LéŸl­b¨u*Ñ}y M~ø¹v9R¶@£yõ*Ío¢éd ³ù0º “s0‰†ð›‘eó8f7zëëÁm˜ä™[n:Eó9]ˆ|ŽÙû÷Eç¯Î¿:xñendstream endobj 4772 0 obj<>/XObject<<>>>>/Annots 1516 0 R>>endobj 4773 0 obj<>stream xWÛnÛF}÷W 𶑉ÑÅ’:q`´ˆS[hQT…°"—crWå.%«Aþ½gv—´è8}¨X¹œÛ™9sø÷Á€úø7 Ñ„ÿÇÅA?êã ÿð¯ë÷ÃÉ(Òx0ŠúTÐð®‡o9Ýì/h44gùîOÓ=ƒÎj¹¤ç}:F4Miا N&'4MœÛ>MãN¢«E.éjñIÆvž){-×ód#òJΗÒÎ:­;t¤g‡ôùpúé O½,$ ?¥´U©H÷^ûÇ_µN}i}‹¢ˆ¤ Ÿ|ýùÅ1±±”z³7…0;or»ÒÕrEv•Z—:–Æþ”gÖ"ð•ÈÊ]—2K[]Þ\¾•´Ó¾VyBòn¼(S° ÉŠ9‘‰Ëlm3µ¤\¨e%–²×“3‘ç;Ú®¤b_w»:æ!çç ץ¤ÊÈ$¢ ]²±BÅ!(ú(Ëü¥Oh¿î½á0€BÒyâÎŒC”‚ˆ9)ŽFIceB…,²¬}»¯éŒÎK)¬ôxÌ:³ÃWuå÷?Ÿ„c$…•Œ.äJoì½þìÑþÂ9À¿ÀÉɾ1"˜[¡F’ÜÒ)éÈ?ùg|¶-ø† |—©ƒb%6’Ó– „,-«#)‘(m)l¦•qH2¾É&3‚;Ójò=Ú‹W2¾e ©•%••R\·›ß/ßGT÷J—À,[©sv.µN(F:1¬®„ås@;Ës×;]k!vè)Ä ¿…N²tÇÇ.¦O¦‚Ö±,­àO¦p]ŒÎ3È™âFê’Ò6¸â¤9T…’0ÃvŠ8•EËÁÎù³gìd¤$x›0ξCB+¶Õ3ß #õ‚H;çô†k£Sºâê 'Dc8I£Xè sÑ@²-Åzmt]‚‘K‘K\¤QO-JÀåN]¡öÀd°ÅžQ$)\bÌJ~Ü;QÖvÑñõ•w"æºÂuÄÉpñÐq¥J%˜µ—ôœb”fyËu=ë®6 (?ºÀè±Ö3³C?ÅŽ^0^F«º}8'¥™Ð……!]€pØ_¸‚~èâfI&+Öˆ¸9ÆQ6mE“È4S·;‰Üj0‰( û]¡ú;ZƒoœCíº™G#omcÀ­$z˜iÒ’ÜÚe¶á§Bûå¿wÛîÖ°¢KŒ­¸ÇѨ ¨TÅ<ÄuCj¥ÞÈÍÊý‹éXHpd!Pw´»zŠˆ†¥T³¬‘Ð 3jšÅ~CçØüñºx"„}ãÍ'’‰z@—%ƒÒ*[®z9¬å9Qû´R±£2U¼"àu}k}ƒ‰Ãâû ëA—ó;¿ìü7:Ú<¶å‚Ûô^ß=²Ûì°{,´q¼Ç ªƒ”\±˜¢Ànëd*Ï”£…!9N@iÝ „&ȦÌnX` ôg}ãá`µóš¶Ç “ì'£q/ï2pÃxÝÇÙÚó³‚ÙD§Ã»Û“1/%î75‘3ƒU|“Mužë-ßk‚DÂéÖLð•"ùïå‰MËC‡i¨ŸuËqÎ1ÎÛ Ÿçšõ­°‚âæÏ.‡8¿d*_Ó‘ªu×SíC1³·qŽ7iìŸÆú¥£ó«7S¾¸ùó¯Ç:% >ÕíÙ1 vϰƒÐ‚¥4Un›ûP@ k¾Jux¸æï¥}S.ͬSíâºß­_îçŽõ‘§ô]÷G8í»`°›l·õÃö§||7¯Kˆ„ÎÎhzþËüÝõõÕµo¯m„ihÎ}^Èë I„LazÖáb`„ _Z(rP Ï´¨ñµ«I“/ßø ·oXÅmÈŸ`&½ŸÙác÷¢¼ú¹íÐ)ÒoN-¦Œ´Âú­Âdqô{îT`æÖ‰€¡ctúAkÜòÎJ•ø«µLê€í™ ›0."Iöx!֊宸µiäš%’¬KæÖZ=Vm>oÔ41€»5” š¸^ön™:Vªåo[FßA!iu‰Ó‹*ƒ„¸‹EÆÊ‰ã Rè^rÕÊ©rÛKÛ‘˜ °vó<êV>/XObject<<>>>>>>endobj 4775 0 obj<>stream xWMoÛF½ëW R‹Ö‡e+½%NÒöC[¾0VäÊdLî²»K«jÐÿÞ7ûA™†cÃ&wgß{;ófô÷hFSüÌhqΟ¼}X¦Ùû_æ–N?¿£ÙœÖ[¬=_­h]ø÷SZçãevžÍh]JÒk;GzK^ýöËñúëèôóͰŠ÷MægÙvޝJ©ü ÊNZªœM›·U-Oð€*K£ï°´k©RNÓ¶º—deî*­,åÚi[­ŠJÝ^›N¹ª‘xQ B)E!=¡m+ m;vž00Àa>ÅX¨‚]tµÄ!•«D]ý+ø‡®Ç•"W °2ˆw}œZËH šú o±4ÂrûMý‘ï©­E.K]#"mµ¡Î*s`ù?á@E7T1AˆÊ.O/ß¾=p‚X¤‡Vø4Ú²øŽ%³²àx…ÜVJ2šI|kdkt.­ÅÉÈÆÑÌP6‚G{1‰¤g«Èzr´¯çç4Ô„_N DùãÁ<¥É•'á©3…Ó•¨™§ñ-áy¢U©¼î ’Û·r’—2¿c‰x‘†HÀݵ­6îpçnö^LäcT½4Qä?LúWŸzI¼WÐÌÌ$ÜVÑÃ÷rø«)ªAâb#ó‚"…ì‹l|ô²,££ÿJEe¸pî‘.ÙNÔ5+€ss”Re¹ü¶±d‚p5Ú–²ÔÒkt«’)>Âêc>L iQÈMÎÿXÍ–n¥’IZèœnP²¹g]8cž*þ{òùËS^ðÂ>iÖ€•Ì嬄S¸7–À!ÚMï¢Z ö¯×ÁM<™¯²w(1öao¿sºdÓ¨|Ä{צÖùÂàäÀa5×o€†Þ_Y_x¥Ñ­© l0¢hhœoõF¤`ôÁŒ|~ísÌRœBجõŽ [Ø>ãÆAŠõ†î¶¿a¸=[2’Ï’-õNýØLi•-¸¡Ì™Ï<[,ð_1>òNIGßRlÔC1&òåq7MuÉo‹CÑpT¿÷(õ“çc¦UI§—¢†¾ôиèµ1S‹{iZõÚ¨œµ/àôKžw˜X×É|‘£aàn8)6\Öé^_ma>+8)ŒËÑ/½A"Q8}­À€Œy³Wýi{L‰,€‘=àÓ+>/XObject<<>>>>>>endobj 4777 0 obj<>stream xµW]o7|÷¯X0"ÖéË_iŸ·nýR´°Ð¼¨;žÄæD^Hž¥èïìòNÖ)N¨mØò‰\.gggGO&4Æ÷„fWü“oNÞÎOÆÙ÷¿üŠFwcºÉf4/i:¦«×“ìêêšæ…¬Ó<œþs6ÿëdtwAü_Òë†ÓY»nð†r·Ù8KMÐT: MËÊå™@ÑÑÖ›¨éÅZWµö/¨ll³!£ùZc—òØÙ=¤¸VQ!`A¡Ö¹)M®ªj'áãZSÝøÚa£+95¤3™"åÁ²1Ua슔%c£ö¥Êõ9-›HÛµÉ×u¥­öͺH&˜e¥9KlߨŠn©önåÕ&£;ÜHR›‹~H@6œN³Ù ðƒÓ¿»dS1½¢[¯.®Èê-=ê<"Ö«QoUˆ*šœþlßÄÂ÷éõb°8£~Dj¿¼Ž·´t»°YñÅ ˜ÏÚ•Ý[‹³ÅÙ½ó¤–\?É1•–ñK)è7·E¹TM&RocwV?C >º{M\€Ž—5ð̺·•±¨ä/8ò¡8‹ì‚A{06G1¸ÄÞå:”XèÃUMü9` ØU*ãAŒDÁsÞ .á¹JÄA-M{<¨¹áhOi$¦a±M!˜ˆÛÐÝ[8õš§èôŸjÿ<¤ÿcÑS•ŸíçÙ¾Ÿç?Õâ! ?8M·ìWm@…ñ ­yà6hzU1Ä\?YZ¹E à— û†[3uÛZ«B{ªg9à‡K¥©´HD ÆZ²Ö¶WZy‰åŽ–.®åà‡w÷¿€=º%ZNÙ‚d¡çhMšZ:dÞµv.­Ê¼á^e:ñ®#ž¸ E˜ ÎV»^zÎj*t^)‹;›Ñ¿àf –¸õÑI-âàeYFÇ%$}e¢¯€¿eùÚpËé×À.Ýœñ8çvÆbSUz…žˆ®—&š®j$ |ûÊbK›â~3³,ݧÓîð+îoV„ (‚‰FUæ³ ÒΊ´£2šðEß3 Mµ@^Rí/q3±i@YêlBîjΤ;B;ötܸ¢Ê›~vÝ`êÄ*iç>ŠåS¤Âj] 0j1'r܆)½:Ž º·ÇUNñÌ:çp¸fSí¼Œk¾«>¨ë‘ötS‚¯ñþQy£0ß“þ$è8…‰øvê}“Å V×ôÆ¢Xí ¥·Ýx}À…¢^ ×eüæ†ëÛx›:Éé`_Fäü±\rÑÅ͈ÿaª êQY’SIÄ¢dâ®Ux ]+ f…ôj‹å­r²BbDâꈂÁ™¢°üzš*öGÙÆ¬Ö'ÒRÃÁe1åô'8¬8 üRuÜQZŒ…j[6UF¿b°¾”¹ª½áCK Q×!Ñ –dž¯´QDÓöµ¬€]¯.­ÃJ¦ €™s_hM¹“îîz™Ó¦»U6ò!lR2ºÈ ‘– ùN®f5ÛåÀ‘ÊÅChŒž±D£½»˜2nžÏi8Œ2&U&FÞãà¹Ö®aürܵ€5dß&62˜Ã.ã„;seÏFp­eà츄pÀ=py‹­œƒN5æv)Ÿ ‰°«ÖbŽDÅÉMgÔ™¼ ÕÅ=Ýg*¿9îÀ¼çS÷IÊüe»þ•’|ëZ¼XøÜÖöÙ„Äi~-Ÿ$¤·®Nõ¨!apÑs”§Žbže løc·ˆ‘.|hcdÎõq8ô1ŠÔ…3¨2-+´Ýõa=¾E‡ùä#nvIW×t"…œËp–é'—7Ä”¡Ç9À„_d—X<¼NÎŒ§ã”nùóSrTìŠÒ')^9™dW9úò’Ÿü>/XObject<<>>>>/Annots 1521 0 R>>endobj 4779 0 obj<>stream xÍWÛrÛ6}÷WlÓñTN,ZwËi§ÔSÏ4½ÄžÉ‹ ‘ ˆš´¢éôß{ $Òµ3mŸ2qdS»gÏž]~8Òÿ†4žñOZ ’¾á!¼{s4šM“)MGx¦ŠÆƒ‹dÒ<•tsÔ~ÆêdÔ]m=cuzžŒÚg/Ú–'á†x[n?W4Ï÷^„ÕÖ3VgódÞ²üým+]ÑÙÕ„†ºÍ9ÔÙþÊB¤ø#í9SÛTžRdÒR®J™œÜþqÔP8ÂÎÞ[q'ÉÕV’¼—vë ¥W¤4ùBâ——6© ©vÒÑ«Ÿo®éòìòÅ r[íÅÇ`ïìj8oœèŸ'Œ>L/F³sâÛòÚ?.eIZ¦Ò9a·ô{‚æj&_[Ô&§! ¹Pœ“¶ ²Â4]ÉX]…€ðfaðY·¢BY‹v6±cY«2c™Bj÷ue¯$’Y³t5 ‰ G@N˜ I$T.¡[X^J”àçàd&ÁæhŒazÓá C­"„Ô¬±‡MžKœaº°;yv¢<îEå4ÈŒë×·¸ÎvBee`eim q/CÅ€¬Ë e~tœ/Ö`ßÞnuÒöûŒ«C®Ê |bma‘s Y¨QŽ* Öº ¥ç6jÕÎ0cK>W*ç»»wí§Ç¸~Ú^nY¯È[‘ÞIû„¡†™Ä)GéfÌ»iÂý•S íS0e[‡þXƒVS¼meŽˆa%Á]SÝäx¢¥ÄJj’õdÞº©×kã"aCjòÜ”¥Ù°µKj5Xz}Ð<s #öj”ŒÇxÊzgÏé ÚO/›3IAÏÏ"Ø´ãK¥Ó²›¾q>S&)¾m–¹#f½Ã2ú\qX‡åG?Ôü3‹^fjp}qòuÇF³+.ÒRØE°Bvµbë½Qeuµ^ô®®zMÏófã|v¿?'3´}øùŠ»dc ·nÚàXÃ:ÒFn([sÂa.é¢üoqÝß”¨´»ãÊd5À¯¶ñ(Çv÷8?‹.&ųÎúñ_ÇÏø_rèS %à|FSÁOÜÚp}Tˆ÷r–5tItiɇ!˜/XÉ™5¤F¤Ehža©¥½QÜšŒ)÷yçéxW]Ý´> ñhOcÖîÛ$²{ŒhbÅ¢Q݃ÂíPé0\ðVÎí ûÚ-*ÂÄÄÇ<»Z;)w@LØ!gP—íSò„º£Y˜×+ž¹•—ò#7Å?0lºÓGîI œ…S']WÒšÚ5Ãø~´ÞAÁâï…Çïö[wÅðp«óhs•ÔÞí*XàÇ`j 0<Œ¸à}e€gC)„Œö±/ÚˆR!8CY´í´hŠ Þ§zƘÞÛÀã'ú±û®N«{ìg ]Âë&¤›ƒîñbüƒIÁ‰‡Uv÷öÏ£¢rsÒ¯3„eÏñŠÃ´ C/SMñÁép˜ÌçñÅp:ão^ßývô7­Çåendstream endobj 4780 0 obj<>/XObject<<>>>>>>endobj 4781 0 obj<>stream xXoÛ6ý?Ÿâ†¡˜ ØJÇIZì¶vmlC·f(h‰²¹P¤FRö¼bß}ïHIާð†QäÝ»wïûçÉ”ÎðgJ³Kþ›W'ßÝžœegøeÿ[Òé« šžÑmÉ‹.ŸáSàC>º ¤<9á¤Þ’‘¹ô^¸-K"ç/$×ß½2K-©lL”5¤ ÒÂ-%Õ"¿K™ÑÂléE¿ÆS¥–«@+±–¤Uxß:2–/ãOoÿ8™œÑdzŽF>wª² iÖÊYSI2º]I'Këä˜6«-mœ¨)¬dõ ¿|újzݦ6¹Ê¦”6úp~yEéq—8?œœ_ð1ïd-œA®9²RZzª]«B’0dëÚºÐ"Ý“ a`™Ìp ¿$¶AŠvïív¤@p!)·Æ×äÈ+;1côXÀ)›½8sœ4ˆ(Ð 6a @¼Fý-¸Lÿ÷Èwïo^Îù" ºÉæÒš²T@[#Á•$êZ ÇÕ\IQH—°ÌèXƒ1àˆïàfIhm7ž¶¶a|¤V•2\ ðbcÝÝÂÙ ¡Úˆ/´¬üÁ”Ž©û>Œ„‚eÝeH¶å#”6£_½tž6ÂN’3ù+È*ù­²bôhiù^ç¼zžïX’ Á{ªªd¡zÐK™Ž‡ÄZ(-7mTXE¦%\±m¡–¤ñ/èýCD{ѳØ-%Úâ:{F“Ù53qž]eôZ†”w©‡ï7íÞuÒ:¿À;ÜY¶’AUÒ90„?núŽF÷£eîX©0Ö¹E.¥‘ܦ-¶ùˆœs[ÕL#Ô®–NoYsî$yæ>8µs®ltðLìÙ°¤ )¨(Z±¤Ñ“ã'ÿ SÑBÛü†³ÂJùçÝ;×ÙŒ_:gγ٠ߊѓÊÐZBªV*÷]T±ÕŸ||ý\™å—¯8]êlõõ§7ûÏS¤|zÜüô”Þ‚Œ¡“>ò‚?2‡RGAð Šëé_ʲ¶¥v„à çÙ%T´¥ÄœÞÇFël¤"UPƒ£OÈpSrE— @TI9X0÷?¼Ó¨#㨕àé6€K@K(]À!Y#*ô(H×q ˘pП8U¸ÔZ˜e“•õ¡ÃùÞ蹿ȷ3˜Ê‘ݘcãF¹,˜‘Q Ñ9T‘+L´QvìFB{ œïf¦—ùlVÒD¥äXYi[à rÒVXÐOÂl¥ÄŒªÈ!¨Œ£·:Š4s$Õ±ï‚ÇŠ‚qVj•Š-;ÑU(FW’#wÂpWì9êy$æ§§â/©æGž³…:­7©=ÜÊo˜A,Ò`4÷4ËL’^©û¢'/#|A4?,Ãw.fò’±ûÊꂦU]{Œ&û@™»å÷L [‰"Ž^¡ÛHcKs%­Áàè¤dÙè±RF*z!<Ð)i«¡Çz¬6íI&«› m›7y.¸ok‹y2vCèÖÐô6€›_tõÑ-l¦) º±–`9›…t° ƒ·sÔ-A¾q€ņHÔðt8¬··mËîÅÝjÙïÓCñµ ÏþˆF“ °©á›}0–5·&8·;Ï6::Ó8²D‚쮜­p FÞY#Á–ŒÍ¬céÇ|ŒôGoŲÁã ÝÖvR!–ŒÖ¢²úÇyþ-«uZ¬!A¼J¿Â'âqÁxó=´#^Ÿ4ˆÛºK[aãÖÀ ÖÉ^ò/¸m¡,lØÑ¼ð\±ú¾±¾Œ¹w»qþ˜ÄA¦Ü<½Ûrá±}î$ûÏžJHŽ€DS­šÀg Á¸1)ý\x¶8ÈxP(tü±´ðEù‰w„ªÖH9YkÜH¢éôgLo·°~&Öñ6×må[%™·¶¥¯ÙO(SkO:qäÞ çÅÈÁÊöj†ÃY5{ĺã!ˆñâN®bG¦ Ä¢è6Bv_¹ðm”Ö»ñe Þfbµ4M×ITÜDºb+‡»X`x úE ¸3°_Fc%£ÊqÂÜG©¤)ß4‘ðx%ï#Å5ˆû•¹‚KPlϼ¶<¯ÿC7@ÇxõÄ#ùpÛïqˆ—ºü,©ÆBâJ­P$ íâ;«,K Á¢¸OK¿­VÓñ2å+™C(•¯Ø±'‰§÷ÆA™;éœ ĆÉñ%ä»`;*[îu7ïó³‹l>›Óüâ:‹—™É,;£—6oø…ˆq„OMk'Wl·Ó}csÉý º»âðŠäã]>f××øï~íŠwûþöäç“ÓLJendstream endobj 4782 0 obj<>/XObject<<>>>>/Annots 1567 0 R>>endobj 4783 0 obj<>stream x½ZÛrG}×WÔˆå°4ô}f^6BÈà bͲH^xiõÔhÚÛ—q_ý½OfvWå¼Ù½1pt¦ò^YY¿…&À¯ÐÄý.ê³`à'ôÒÇÛŸÎâl˜,ÍV±©Íz‹?TææLÁÚlÃÕFq Ö& £“…ƒM““¥¢2IDeºJLÆ€T “8˜³^…&cÀæxsÖ«Lq Ba®ÖŠ¡Q0 Ç`:CMW‘â„Јջ…ƒ…°Õ³ ƒÝ’³žƒ‚ ”nW[“1 ƒ„Aä¸u„d¥[IVÅðR-Ô˜b¬RÍ* 6£`¨µ “¹‚ëYQ»‘„…Á6¥ŒX­Â$8B®«0ØuŒ()VáÚDAJî9É¢ŸT a¢PRF¬Va° /õ¬Â¢þ8–ß²Ë5j"Á€ä*X˜g§ „F)ùâHH‡ñ‰ä”r’Ñœ›“µÁ)«0ØMFžºµ"6sVÃH¢ï1–¦)j)õ¬Â`±ŸàŽgFô#Ϋc5›dd²g‹N¡%k\›8:]+ERNØc°˜ù£ Å)¦H8RcŠSDîY…©˜22ɱƒ7TÄŽ“¸‹aÓñ¾bÀ&yH&qÖ) i-! Î0’äx,KQ…Žå¥ÉF  bc°N±0Ž!Ö“²p=éHy‚±E(ùäGå{@+ÄÂ:|“HY˜ª¾œ0ðj˜ 4‹É,ÔCl§ Ës ’¥ríIQItÄ4^a(€¬c@œ‚|Hh‡Ä )ª*Ú/…TeÊf3 ¡ âTb/§ +„LÇAá ¡2S¤ÆdΩJ6'ÞJÀ78­ç O)àØ#‘@œ‚ÜÛpòó‰CÞgHæl)Oj 6$c«0Xô•D³ ÓÖKP’~­Æ`Š»b‹ã®:“5»>µYcô™òë×J3)!lÈe@¡Pîp+÷¤Æ`3Ê¢b‹CA ÖG!z”_Ë[7ž¦­0 FÙ¤1sóS¬Â¤vCF±$ö‡Žxš©Â0EibÁ c)¼…Z7ri !†`ÇŠÅÓ@6 v™ÆXšÒù{VaL=M± #P0jÝZQËã–Šý~¸R,3ö¬Â¤–ýq¬Å4zIøñŠkdâÂ(¢*v¤Æ‹¹At,‹¦É ~¯ ¿‚è„çd<<ïbZ'"AÛCA€ú'àòM#̆êHq RìÖXâIÁ&k2Ç 1““4G+VaJYˆyVÌ Ý#?ÃÐH&m"{5&“"Rê–j §”zVa˜P3ô¬˜„OŠ ’(1àz±˜Ž^GÊBæ…~Và…†4÷GŽÔXÄ"øž…šƒÅ€EŽ¥Ó‚NµAˆç|+ƒ8~ŽSB\¨p¤¾[DnQ…ÉÆ8NA’¥ŽÔ,Î|ϱ¬’Ew?\6PÔ„ÊR=§ „ò.ö¤Æ`ÓÍÉRÉ ºû¨µ S‘PÝzVc°hA‘bÅÔ;CWµ;ã!”bbZ+Rcqç„…{3Ë•à‹ÒyL£Á€\’Ï–@N¢ë8Y7Mi< Ð~‘u Nƒç ‰˜ÖaŒ†en‚0GV¢HÉ ª=¿TÌ™CëCQд©éVäšÛ ÑøhÔðœ‚pŸ†Ï)H§íIÉÔèDls.§™2ÉR* 7TjŒ‰ {#Tìó[õ®Â+ݽyö’*Ýîñ“Q#s»ãÇ—ÀÜ癹y÷ê'“7;sýÃßßþª„ðã ëøöžžo.qn'i!ç×m]ÛfèMÛÐbó®ËDz¹?•âM Q@,æ’ú0þ¶;eksúýϵҷ/C²ûüêxìÚ¼8œ.ù[UÜŒÇcÛ –bö6ÆÎö *¤0Rü«²±¦=eÛôœ¢­e•ÓTÿ¦k?=˜¢Êû^ܤ$K´¯aÉÐY`Ú½AìO¿Ê÷\+>ËhEA<ç9 ¾šgùþ¤û­íÛ±+¬Alò{K…fʆM(“Ž¿¤ü_ys?B«é¶(÷eavvÈËêeð%½—¸UkÚ=ßTòɆ¾SÖÇÊòû¨6زÔvR7;+YþzÝ|É^ŸÑÏ7ãI’~´û|¬SÌ…•@G”úW3¹Qå€Pþ¿Ì{w°6Äp-…©³Íw°»Ãö¶»…£týÇx,¬ïg[ßÙÎìdžwîÒEp3 E¦f­K+›|ÛåCþ´(N{q“|Û^ÜòÞë=ïîG>ú¾nÓ:ôåÁrTò¢ëù°A¯Ïqš/¨íeWÚf·¤†·vo±µ +NÛ²°ßôé ÎMîoŠИ»ó!¯F» ÊWÍÁv%’U,©åÊÜ!]{³+ûbìûi¨ÑîK:JoÄ…™ã|Á‘ŽÖ[üwÙapž7Í¿?Ø®jóf¶—sÓcK~¶Ã¡•‚óçåėâह·í9gý¥óòª¾+ïÇrx Qf¶úQAú›Ôb’m«‘ç99±Uòzyýú¢ÐN¹z²Ö©ËpôøûCÆ÷ W2³(™öHÉÔ°ôäf~Mãµ±ŸÛÐNZ°9ÜZÌYj–ìy¯óÚb¡Ë’#~gݬi˜˜ïMfßv5¦¾î‡KþÛ#î SÆåNòøŒG|Ä¿JÜ S`v†úSO;ð[ {rê_|*,_êÜe‚;Í’ùñ*Øå¸WÞ›åp0ÿ(¨ï-Zo¦× ­‘YmIGoê¼ÜéÃ-ÞÍ—ÿ|þþû7½xtó¸[ƈIÍäîW m½¹$îÙØàsÞ ÚòKO9ÞYÜâå“‘DÑ *û÷üÙËùiíÿ®¼Åë7­ÛCÙc‚Ê^é¾\tåZ=Õ}×›^^¨ØˆùI€ÞVæ yÇ ìüm,ûr°æ¡MhÇjgöeרË-z–ZóÿœßŸç}YüIPÏ)½•t~2:´åE‘ ëÍÕë›Wæze¦G56™6ÎÝXV»ÞŒG<,ÉwänNeLƒÉpȼüÀý2¯Ð¼ªÊÜY3öv?VÔ¹Çf‡±#ðŽV {1[1¹¶¢òh‚gV~¥0sˆé?ƒè¹ä˜>3eeµáǘç¶Èa=†•ØåôBWÙO4ЉÕÖìóbóIb‘ãF`1CïñˆD/%]Iî±M­4eȱÕÞT5]µôˆät¦šž ðžÂ™h›êáÄG<Æ}(Q'åÝõIÿü|¹2/ñ¦96ÐZ=\pÀ J¬A¶r[DcG/^¼~ŠÜü`K!X¯¶riþüÉ8Å?Ì >]©Ó Yùâöì?g¿Ư49endstream endobj 4784 0 obj<>/XObject<<>>>>>>endobj 4785 0 obj<>stream x¥X]sܸ|ׯ@ù%r–ÖÊúrÞ]”r%99‘*W©Ò –IX$ÀàîíýútHîR¾T%JùCZ. ôÌôtø¯“µ:ÇŸµúxÍ¿y{ò‡§“óìçÿúJ}¸¿TësõTâÞëOø¥ïñK~úÅ©N÷ñLÅÚ¨®÷›Æ´jgc­î~øAízÝuÖUÊÜ #ïê ?9¯‚iµ‹6×M³W~³µ~êùÔ÷JÑ·_©ç÷j§÷*zÕêÿî,•Aéb«]nŠ÷OßNÎÕj}X§¥ÑqèMPÖáÏÝT£]5èÊ„L}Æc*ضkŒ2¿hþRâp¥R­Ékílh‰hDç¹ AšŠA”Ь¯¤‘pzÐ’$.1ZÇñ4Zo Ž ÈŠªŒ™óEM¨Ak §)g-Ù „èºW[nb퇪Vq~šЪó;Ó—C£ÆîÚ稜hƒÊ°û{<[y‡¢ B¨Ú#…ΓîG陳¿„BÐGdºGçþF§<>ýEú‡{ˆÙéÖäè°tqR·SP1cSU˜Ò:€‡Þ¼*ß|ã“]m‘²SúñÛâDFäÃôS[%}zò(bÑIñs!um"y?ç@wDOÍû+3Ù©bÐOB'r”0`… e$&pR×À'‚1­”QÀ 8‘j#ªò|j²*;CÅ ŸÀˆ†0%þ¹ãrï!¸ÐW„Û4gÊÄ<ƒ@ZD¾V`Ph|Ñ$Ö…,¶•ĺդóŒ°ÌÍ?l¿wÒ;D¶Ç¾& ƒÁŸ1ÐbF ÃWÞ@ƒ³É9·QU\<¤˜4«%’÷>õФÕËÄøÁ"L¢ÀØs ‡`šé?"ãØ0B¸H×P{Ôò„ý´‰(â¡õÿ„hílÓ(!G­·âèý½ž|¸ÿ¤Ö—„—»º¸å¯Åéuv¡>wØ\çõ’¨¼é2»½å] ŠÍ~–¸£Ï5zÒ ,KˆTú¤®Gy¼ƒ#Š%ƒX;òŠvŽ«ˆ6ˆh$²i@ú±±œÐ@7‹¤}þéñËêN…¸GãŠy¢ ™zªQ¼ù3ìò%/DÆ}Gv, ¶@È…ÚäTBЬïÑÏ`WqÄg’jp¿Kz¿RÈq#¼gÕ©‚ð†Ï~‡Fª tè²´¹%ËPQÞ.ÏÉÁ¢'—ŸÍt¢×%Gj3Ø&®¬[À˜Ò4º›ˆ=hLŽÒÊZ[ÕQm-8-~#åbRæ¹Ê5À< G=ïFa؃ahÎR§ áeêœóŸFÄ ¨ìh‰hìói y‡¶˜ý;/÷]åñÈ/h£FRJbNˆ(FŽ£K‚¸òðqà*°øÃÃñª@¶@Äš ½0íˆç ¤Ô…ÁíÆÒ€ãx¸ÃÌE-›ëu9`Mh½LQøi»Ï N}ÝÃX@)Ü9}\À‘è8‘¢m ©~Ì9#I §¢0µÇÀÉ«û¤citú¹†L˜æ[. C„SÃ%‡âl¶i?ÞpÞ£r5ýÍ ¡ Ïwàƈ WŽZ™ÛOTÁL Z„5;Ä[wa@½S+LÕDš i:“[Ô‘ êBw°EQÑyL XÎ ³³Ÿìn ½Õ…¨>~@ÅıÖÍñÔ,sê¨.döB*ÐaÐ!΋íØc­ÇgB;87ž M&(Ìy.M©ÔyÛÀ¯Ä3„LW̯g )í7Y“#›ŒmZAxöÐ-LBˆIσ¡!lD&a¸qg° §‡TO_¡å¨ü){]rtê$×áí°.\µ€21+‘Ÿ&‘ä ð¬Ã°+g· ÷ØØ%¤ØS2hgìäP€ŒD…¡ÇÕ`V+”e. f9ÄçŒ~Áêˆòe9<Éi 2Í¢½aPê™îw¨fÎ4îK¸©kj âö9~`xaÄã®|€¬õÅ‘r¸yåÌs"|~‘•Ù©R28‡MrCxB…`tÛ U „SšÎ›‚ÔºDû§ƒ§4"††±0›¡ªøyÙ¶<¸ˆ€bÌ2 Òçâ¦ä>ü¦˜ȱ§b•ðd)…€1Ƨƒ—´HBšà¤IñÏÆt0Œm$(Áe^éôƒæuœ¤¶2 þÃ$)aÛZ âÇ›©¿ò„—Ì•óœ‰cò8Î- #艆 ääÀFc0 ¼†&ÑüÇÁæ£zLމɺéÜÎ]ß6Æiˆ|è1Œr´›­wÖ‡i ÀÌ›A<3%žý‚þû=ׯK,ɱé.™ZÚp}; V7_‰àûç‹ë›ñÌ0øÝøžá:-g»éŽépúüÆ%ÿaû8@†§S•´Æ‡ûÿÚ×aƒc²pxOñ|zÈÉo½Èx~ÿFÌÁüÿ†|?žaEBpX¨ýá­Ç¨œoHÄÃøe~BO!]eŠçŒ€M/[Þ˜ƒ¿'$óÖ‚=ÍÇåã:®lM GqmM‹Aá`Âo.Û×t¼K6(‹¾ûO¾Ða}ë?šRÃùKAHߺÐc‹·ÓÁõ¿ZdêùõÍUvýñJ]ßÜfW×ì}jÍêcv®~<–:òcuq~™]áæÕ ß#ðŒ¶Vwo¹ø‚ .A1ûy|éÉ®ÖkžÓäÞ«O¼òǧ“¿üœl ºendstream endobj 4786 0 obj<>/XObject<<>>>>>>endobj 4787 0 obj<>stream x•W]oÛ6}ϯ¸â,¶blj›lØC›5[ lÍÐ y1ÐÑ%³¡D¤b C÷Ûw.)¥–ÑdX$2EÞsÏ=—ùë`FS|Ïh¾àŸ´£Ù”îrì]\â! ïñŽîÖ’r£µÙ¨ª «ãcʥ𕎄•TOic­¬¼nÉ5um¬—Ù÷GwŸàqrzk£Òj#2™žœ2•#“S*­ª"SK+¼±Ž–£JnÆ”I-½“ôi²RŠ–V9$À’7Œ3Y€!œt ýb6øi#©Œ~Çì”ñ€›R…o´3c”cóž#´j ˜âò„à¸-Æd´co¨ž]iY:¤ºE˪þ°< éž\_Òì,AA™' t¨í®LYŠ*Cì’«c>¼š²V:$8¬SÀ.¹¸à°ïײ¢uÝS,5ª¯B¤©U^¥B£€ÂÇò%,h¸Q~’þŒæÁu0#§Ñ$=>zv‘%t·FyÒµ¨ °˜O3‚*Ufbv>è>ñÞ5éš„£R–"sQÈ:f3„–Ð >£ $+L£#+SSTHtƒn§ÙnŒÍPÞ{$c"úït(×¢" ÜÞ(­IÂRQÎ5™m„­[cñA [€:Oɺ¶òbKÒZî@•3î²JMSyôjˆ‘ëÁŒ¥¯æ¢ëa„BÆ’ÎEF<ð3£ Íht`c(v×P}+cK®² ÇûhMÚ„®¼ÜвÖ2¨ËÉõ”.’9Wû”ÙtšÌçø”^‘Û¨‚˜4ñ)Àˆ§ÕƒÄã… ùíÍöö›>qhIºÝ]]æÛäÍ¡¸ÇЫåèÃÛ÷—G4A•;'.´äWE„àæÉRCT9:°©„—ºXÐs©tŽ…U ‰ÓªX³˜‚"R€i5ú‡Ê„~åžw¬ ­igc•™´a †V{:ê¹Ô¯Š…Ûƒ ycO2 Ö àLÝ«é»Ó÷÷Evž? Næ!5X)­|K¿ßWªW罩íà®tôçÆ¡o˜ÜÞcšb6 ÙÓtEηó7·7œv ‡‚G«3# WÈ!Æ×‹W1¤;© ÀÞ¶ñõ× @2–¯õb‰ìz•‡ÌcTrˆ'k>/XObject<<>>>>>>endobj 4789 0 obj<>stream x­VMoâH½ó+JÊ!°B˜å0›YV{Ú Í 5vÙtÒv{»Ûv5ûÛ·ªmL@L¤I"„âªW¯«ß«òß­úôÂpÌQÖúyÖê}úçþäp3íÃ$Â,AÆïÃ`<¾ƒYì£ú0‹Úpð£B‡‹©Öó¶E•Ì;;³§Vz!ÅÆuì×ÿ“¹ƒ¥0ó6ÙÌ;ðª’AWš¨ÈÂgp¡.¥¼¥Ôf‘¢›·¿·Nþ¶#½hÃfa¹ÐåSñqêàï?ÐWæ›é¸¿ ôèŽzƒa}Gí߈ti,vA¨µØZxF,@æÉ<·Ž> …Ñ›-DJX ÒÂÚHç0ç`qÂPÇ@‰<-EеßnDV(B§ ?¶n¥ó®® 2™®Üî|ýJëg0ºLWj J>ìJÚÓÔYo0†CR]Ü®Qw|XCI1&°XÈ\ºÅb§·×Q^4ÜÒ€‹Á=丮:ïìØíÅYA’Œ/"KÝ£ŸAlÈô ÃSªö˜,í3<éF„sfǵ›‹ ç3düîïázs}&È7ë€ÊðÏЧAp†#ÉÿÇî‹På`zdšª_5ø+>‡DÏZæS*$©XºkrAVhã $§³b%¬ü‡5[ÛFéuOá *Q„Ö’#’2œÔ¹apgºÒb Ëí5¼¨Ñðe…9!(´µrI^ÚÑö†a#I´à ek2!YFÄ/D‰<:Ùû49”Ùqq+3©„ἇwú½'É®‘*c(ÐG´5QPZÄ2O»äê >DƒÊJä±òÏé hš tÚº¨¿û›é{‰uB[¥7³wÇÁm0€¿ÐÒŠ2‘í ©¡40ê³q‘o·Á©£`ÄÉŸ(þ‰¸IkK„µt«] µ>/XObject<<>>>>>>endobj 4791 0 obj<>stream xW]sÓ8}ﯸ7mÚ…av¡»a€]:ÃKgÅVQEÊJvBf‡ýí{®d;Žk »@ƒK÷ãÜsÏ•þ:™Ð'4›ó¿t}òËÍÉ8ãËæÃåtzuF“1Ý,±vþ²ðéà­Ý icM&+INúRÊä´–këö´Fär-MAÊûRú„>®¤!»ø,Ó“p’R'E!3R&Øð©S›bžÛËvNl6X¶Ø“‘;½tóùdL£É jg¿ì)ÕÂ{öu³ì8ƒ'åia‹ ¶@­µðí aRIÂdÕëæ+» ±”œ¥Þsr¿>y}$tÍA+Œü"Ö-‡Ñ¿:½ÎÃÁ2þ^c:;k‚¹îXÓ… ™ìÄ>¡ßíNn¥‹h!…"bݵ—l….e×3Œ8²9JK§léG£ÑŽ«#¿È´DI†€bc•)¸¼–:V;™4µ€Y_X*êUƘt˜ˆÕäª`ÉZ ã Ä̉Ugp[e‰ç5tôòí«nµí¦$äWŒ–—ÒI®)B.Ä:@ÐÚÄcÁÓ;‰™z¢†@_†S—ž=¤ÔN'2ý›Xçôœ|/Þõà2q*ö£œä› —»Ðç]Ž@n‹ÙVlâXð6¤ÏÅŒåéÚýVà`y.tB·ZÉXæ £{gìŽÀ rŠnŽÓø´tv Ž©X–:£•ØJZH ]÷/šûÀ4P‰ö­W ímkK ( ªd„Öhˆªi#\¡ÒR 6Çv<Ї½@$Tn‚8¡Ç#¤MŸÞƒ8j›g™ä%ص¹JKëº6:2áÅ^ØY—A—:4íÄÐÝÏÆPŠ%,v¶„¬”ãÐ2гh´œ†X¢%c4Ó3ÖÒ+°l~Ç]ºbùEË…ˆŽú ÆÎîeV¡f®…hØE$~vÎ J×V8%ZÞ[ßYÍ`\„ÂU1bŽg&/1u‚ì³Ò ·Yi$Yp.(!ý@½ÅV(bâÊæÂ-`ÄÕ“KYÃ:Æã%”>¶²(1uÈxŠ3£¥e‚Ù+¨ãØjA÷Ú ‰4ß‘òLjºG‹ÊL•$2umR$ônÉ ç|”»¨@Ô´îò/€äTÎ ¨Äâ(Þ~]?( K\‹*HX/èº ,ÌüÊ1Ê ²•ñÈ»K™„߈¾~– ÈU=FµR=Lzùþ:´!zŒÔšÇ‰ÝA·üJm;9Ô—efS›ÉáQrÍJVzÞOk•¯ ÒÖÞt4_é=i…AÁÕ~Ê{y®_&3>MÑXÓi2›á7œGøBWÖ¾’¿kG||lÊ…Vi0Àݾ£ðøÿÇ^êå³£=ñ=æQxàn½¾a6.©}Þnѱ߸ ~²L*œƒ>a/®µã‰k+oX>yVÙ8=¥·|k„ûXò[ñ|½ŸÆ??£ZÒí rŽd@}YÈ.‡ßr?J’ä~„ÞÕähJ õ,ÝZ•Q0×Tã><û‚ ¶EúW©œüQã“ïÿZ/‰ä8²p“O)Òð‘ô}eävÀŒ}ì ZE4_‡Ó¥×B¬7©±îk³@ÕÞÒ×ü£Ça|Êeñ òN¥3©&qöú©µ=2²—“=UE»=;oEô–-ŸaûnG?»,8P·§ =áuQ‹¸n$£ v³d>¿`åy…d­ gyÌ– ­>/XObject<<>>>>>>endobj 4793 0 obj<>stream xV]oÛ6}ϯ¸èPÀmmʼn“nok—®@÷0ÔX_ 4EYl)Ò%)»ÆÐýöKI¶åÄ@±4("éò~œ{î¹üz5¡1þMh6ç_Y]ýº¸gc¼<üç×týpC“1- 6š¿Æ_y2Àrð©T–¬Ú‘[}V2^‘ôJD•“¶KEQøµŠd„]×b­†é¥ÛYåC©7T±&(¨˜½X|¾º~˜Ü·Gwç¸ÈËéüŽš¯]6üm4™ò×”… ¯ å••éHXÄÊ[aèÍ«Wm‚È«X{«ò!éÈÏ;/6¤»Ú“ wßö$aH«:¦dO^RîT ë"•b«8£q—Å¡¤'Ëh2½TÇô†ëxoI*€“"(dpðɉŠüslFΣºŠÒŽ› h+L­’]zn@¥ª•òä µ•õüþ7ô[á£?élôÎp€m«óÙ°QRðé!X—5ÈuÀÑå`ù¢ßÜú—Ÿ ùµÖ^=e]©Xº<<‰ü%¦÷Ùk5пÓ[€˜èêµü²'+ÀÅ 1{¡ó{ª„ƒ+ecG]mà^EšrÂЄiXGW‰¨¥0fÎØ–j«à¬;Ø#Ñ£@ìÞ«Œ~w;>8LA4Ü箃­”„wª”å¶t͈¥ˆ ”¥•¢: #Ë.0·R… ü~ù©öÒyîñ‚«‰FxÄ‹iv-xMLøÓ;šÎ™Ûóì6›Ñ‡V(ñ¡Ð’r¾›Ðo?ŸºÉÒL\néZAÕ€ûNì[*‡THƒÄ}SÓ<›ÓG0T`r%B^OapÏà-«pƸ§/]®(”nI ŸÞ¿k”®P¾B·LŽÒÔ·é@k¦Œò4›Íð”žW¨ g±+9MÎóz?i+Mž±eV>ë}}þ½}„s8½¾¦¿—“TÔ7‘ çi1Ú~’'!›c)]úÿÔ¾©WFËŸ{!)²(üröþ_öðÔt‘°o„—år€Ž{z™Ä󱋭Ó̤Uî,/y(ÄÚÔ¸{lÔ¼Ç"Äè!¼}l‘²2Ê®cÙ¯:¡”ËÆÃl9Hؼ4çN¾§ƒÇ=J=žeslO¦‘kU»õ0܈˜¨ß,½D¨B{€ïS:ú5=aEÿŒÁ²×@È#H92&¬ÙQˆ{PHHÖ¸-j›Ì°cK‘Àv-J{~m£Gؽ¤'ŸÇ :W’9Vÿ‡ýçkjàeùîž9È„1áiƒ& ϦëKôÂÓÞ`¸àÇ儚«i€9ÎeâåõÃ…kZÆ—¥¿^r?¡¼}†SûÓ\RÒÕŠ­û„膌—h>H¼È•QQµžì¸à¼1&ó„×ë‡N¹wf·w YÙ”ÞªBÔ»äÄ!ž6¸3¼J¸²üh‰;Ötæá nÌ5ì<8: qÞ¹a#„;mÌÙÎÅM®Æƒ[¬/(¼³iÛæÚ„×¸öñ’¯wê[“=¶v®@~ÌÂa¥ð 57ñ4‘Œ»;\·àÛ¶œèn´ÓñMv;»¥ùVA’v·Ñ,Ó['‘'¶3 hŒGwM£`…ÞN&VFâÅ|Æ^~[\ýyõ[2«Vendstream endobj 4794 0 obj<>/XObject<<>>>>/Annots 1569 0 R>>endobj 4795 0 obj<>stream xÅX]oÛ6}ϯ¸PÌEm9þˆ“®OmÓt})°ÕÀ^òBK”ÍU"5Rrê ûï;—eÉQÚd¶´HlI$ïÇ9çÞ«ßÎftŽ3Z¬øœŸGç¸Â¿füëç÷g‹Ù2ZÒrqSN‹å<š5ß2útÖýŽ»«óhÞ¹ûfÝÙÐïj·4½YÒìœÖ)¹z‰O‰?âч”½}ñ‚âL8G‰‘Ž´))‘¸`% } ù¥ÈT¬JŠv¥­âÒØ1}úåÃ{ºSYF¢*M.J‹,;ÐVjiE‰¥tgEQHK©±d´Œž¯=›ÞÌ®s&—pÍÝÎW—Tß ¶ò½ÉlÎw¿mc×ÄâðOí$•R¹“µ=H LLagcͳØAßÞ)G•“É —µ#¹9_>ÕÍDþg‰˜Ì¯¢—4©m|­Ž”fÌŒ‘âTÞ‘­2 ¦Ü‰’DVJËŸ%Vî•©mäNà“ý†­€±TTYVD†_l% ”p&DM‘áZràUJã<\?Â@,w$ì¶Ê¥.Ý`´ëûá Ѐm ÀN<ž=_`†?¸¨ðÌ^Ù²å²Ü™Ä@ÏÀúø(½“LJ­ÉÁ-äQÄ%‡fÒBÌ/Ó¦þ¾D,Í^%²ö]• Žû½A82¬äMhŽtÿ1|ý˜œTéFXpöF8Ù:誢0ÚdФ¿ På(©pLÕ|lÍœñ+½ üVí¹SV#ƒõ¥Îƒ¦”1ÐÙ´ÍžÃMdhÐãÇ$a„Oqš}ÌL‡0ÚèIQm æC)`û0hüÉ_€ØigîØ¼1¯½¹ð^ÆÀº°ºÕU÷€<‰úæY Ëð×¢úÄk¯œÚd²&9û¡DúP²ö ³—†Âf(eÆÒwû¼öÛ) ¼Án|¨béÅÕ©ßÃf9„ê( åME,±ps \hhÊq¢œ@ÆõÖ¯ ¬éYÐÑÑi'ÀMž”Áº¬ÍéîÞ&'ÇþÞzzÓ²å™6Mò†j&ÇåÁISdOz¤~KƒniqYw)j qš‰­w°í­B+4B8,Ós厡¿H±¯Ùôœ†ù(açU`Âönê~g¥Ñ¬HSìT׺Ö€mĬÎ96;ÊW’~EÓ]HOOáî G' \~B–z‰kš4ˆ¡ö¡¯Ù"Á³¶MÛ h$¿¯¯Äœ£«hÁ½ÍœšG‹¾%£~ÆèƘWDÓ)]{$Õø |ì@çXìxI8››§dT†Ëôµ?Øò#Èx¿ä2‚H$cjê Ó7‚Ï!~ÿ(êŸ÷ç«Þíúø7žÿ`¹ëœÖÆyB÷ö>òØkO|PÑ -"°FGÔ"èaÈq„q*2g¬è§3=øn›™ óû;àŒû±§¤ôU7›¾T²x¡È…ë9}šÇÿ+…=£êŠæÀ*ïA„lߎnŸºõLõ9ø&ÜœÒÙ¯¡í]ÏâL Û“9áwÂ[Óå[A&±J³W_Pl¬•®0:a=¯Ú ›Ç½:º×•=âbØaõQñCWíh5î¨M¨•iH…ŸÔ´” & z¤ÞA¸:UµÑV0¸.®ˆYÂçç27(¯øúÙÏPL*ÑÈË’2¡·•ØÊˆ~”ȉ¯ÌX79Ú|œÄ@¿!~ªª7äH5¯ÕÜHô«Ÿµ¹ÓuÁ RODŽl#ˆ]±Í!<¨ ÷Z•v x¤2òÞ^Ã÷o)âôæ"ÌÞ}yz‹¦=ÌFeª<øbØJÇGž=}€O;EÀMC &Áz IШ\`€áH…ea.äêå»ÄY´ˆ.[!÷y\#±X‰~ÃßgŠ¥-A2Y‚F27 Ožõ Ä;ãr;mœKáª5xƒÜ1øýîô98âŒw>áÚ¤e{ÿyÖo7#”{4^0«ðóÝT{Yà± /,{Áàðî˘óð¾æ†„Æ·»Ó'Ú»ÀnÜ=9òÊ•¾J@wz¼ÄÖ[ÁgãXœÇ/k ø~Ý Î.>0 4l0zhQ398á «´~CäMe¥@ïd<%ë1¿9‘C~²exa4?_F‹ Z]]…Ñb²Àk²kû¹ß»ÅŽ£øÖON.ëz°ŠVxQv}_üžû ;9„cÞúb6‹p¼¯2«%_y·>ûéì/ 15Úendstream endobj 4796 0 obj<>/XObject<<>>>>/Annots 1571 0 R>>endobj 4797 0 obj<>stream xWÛn7}×W •ku³%A_’VN€6@yÑ µË•Øì’[’+Ù)úï=C.e­;MãÀº,9—3gÎŒÿLi‚Ÿ)Íü?¯“l‚oø×”ý~3˜Í–Ùœ¦³Y¶ šfË^ã§Š>N?×4ŸM²'OßÜž Ví–Æ«+šNè¶„çÅK¼)‚C¼É‡¹ÑÎÛ6÷ÆŽ ™Þ’rTÈRiY¬/2z¯ÉT…´´—Ö)Ü SÒÇOïo.Iy:G¥P¶º§ÜÔµÑä 9U7øÂÊÚì%IíÉ´žüNRcÕ^xyqûÇ`B£é Q ….ð½ñ2÷² ‡—äLP^ ‡ ZÉÖa©T­¼‡2zgñ]Â:¢ŽEEµ¸'m”‹ÖÉ3ß—Ö-MëâVjiÏ#9Éqøì^:¾ƒ†Ôz¤÷ÎÀIŠ;£·x¬7 dUz{v$^’xñÒ–"Hµ—ñ ¤èêÖ!ô\ÔE´•Ra‡œU©î`Ÿ¡5›JÖYý´“ºåÁЦAŸ°Rÿà)·ì*ú€#þÙUÊñ¾d"Ev‡–ÃÍSƒ—‘µÚØZTˆÔ[Å<4Gââxç30Uù“^à&¥ƒªªQ¢zßAÏdI•ŒZIîHÏΆÀeЙ‹Or‹Kwrp3#0ÉJN'cÀƒöãæ9„G¡?kµÝyr;´fÛ¦Hו²ÎwY CxŒûˆ-·äƒR„ANNs­ðDÞ p$1~B,®Âû›eó9>ÈÿÊú+ÁÁ:9<ú ì _ÿÃéõp}ñ:|à_ã1¡·:8Š”T¼Ñ´ðô+V(Ëú'ÿ~ݧÊ(D:Ï‹Ñy÷_ÀI”ŠudFB2™5ÔfÚ‹ÜFAÍšÅÝAÆ[ð?¨>5- ¸WÖ·,¢ÊVÏw]iFAµ©eBÙuÂò$Ìo„=‡ù1tp´qû i"6‰vN™õ wR.{£Ðÿ¨×C~»¾ iò:hß±¼±LPíHŽk>Ó+Ã… ϨòXÄ7ÿ•Åy  IÌShPi]À˜Å ùØ7¨ò‘ ‹ZD®µº·òD3ºÄCF´@Õ ª•ãÙsÚD©¹]7ªpNà „Àf ªÚ8—*vy7€Q0sƒð1²+P¨e7KY# ‰ÉWó¢qFN ¶‰ÙX² Á?ë >.ɶ:ÊâAa`°o ¥<$FXp¶µlÔè§ùœÜAmiô‰mŒš{]Smж’™z²‘zT2¨^R+ÖG`ˆ%š# šÌƵìÒxa5 óìã*‹ õnìVmôèx7ìÁï7Ò*1tÐÂëá3Œ²týj Õ sÆn–¾ÿCîS¥oºeªÀ¼ÁîåQ\¨¾€Ô`5I:åÉúýô;uðWö( Äàk"lójK–ö¦áó‡~%‡`‘f%, ¯cv ©¿cy¾m±»ÕêKôÒÙs¡‡Ó¦ Ã;Ñ éЧãÕWw†+ì… ïÊÇÍ;X;ÝÒŸZ°Ëð^‚°ÂžZawÈj'ö ý]Èë Vuæ)÷M#6ªRž·4 ç…ÝJO•ÐÛVl1»±‹`)³•뀊i¦æumÓ‹]†[œ]÷³œç²£s¢ªxu9 •ÊV‡å¾7¢‘@I÷¦Å(Âß Ü\O“<êò/ êó¨WËnÿ.¯²ëù5-–Ól§>oG£y6¡ŸLÞ…—K å§G/âüþþeïz:Í–KüÉ…¡½¸f£?ß~ü§S±endstream endobj 4798 0 obj<>/XObject<<>>>>/Annots 1573 0 R>>endobj 4799 0 obj<>stream x•WÛnÛF}÷W P¤  ‹ÖÅRœ-кuj -ÐF@ò ÀX‘K™É’«î’–…"ÿÞ3»\š¤ä‘ BÜëÌœ3gFÿžLhŒ¿ ÍüŸ'ãxŒ~LøñÏ;¡ËÞ¨ éëøªyQôþ¤óZÐå¼7÷˲s–;ÐlèâfLWñŒ–MÇ´x3‰‹×´LÝcZ&áóGn«U´:}Ë/§ËO'cM0›vf]ÚÊ­¤ï›•Dt­·{r“¦N*m¶ÇqÜûò–_/n.‰¯ÈhÃFÓYcXTÝË’ðÀ™ýƒ)%­%ÕV¦$,eZ)½³?øÓºnަÓx6ƒÓiôH?¶Þ±sÏwtm¤¨$ Rð¿gã¾Ýö¸:íìÁWlcÃx =~Õ“ÛÌùQ ³‘)Qnj±‘”ji©ÔÙz»Õ¦"ý Ò"ÍËÍ9ïxÆýÜ’x¹k%±ÌèzsÛíV&¹P”ÕeR庄eŸy>!2Œ9qï<ü~ ƒ¿ÿõbÁîYÕ¦¤RîšhžañeÊ‹ùqTÿÒ•l ¸Gt£ H”°Ö±ŽÉê9}ìG6:§÷nß‘.Õž*† Á貎 ÁÊäåU ŽØnUîTšÀ$½þ$ í·ò¥û ¦z“žL¤³‘1Ýf<Ä1™2û m ¾­Šb«‚8<#ã¯ÂýN~‚ð pT¯N½úµ­×½SV¥X̼Ü«v/”¦œ=!^Çä&P ;T ¾tÀ¦çXz­‹­¨òu®òjÏ, Á AŽè}#ú¡„ð…CBZÚ!±Dš‚uuYåè!£I<‹'SÈUI[#r][[,ʇõ”éñ¯GµD×*å:ì…t­ëŠ)³Gš:qÅœ‘,,é7 ìQ¼ÑzP}ž+]Ç mº•W|ï*º]yÅ)(†u^²øpn][ˆ¾±Cá²µÉç0)Ò¨‹VS¦Ú=4òsßjÆiÔ ©W7Î;$ Ó…'ÆœE¬Ñ¢¬…Rû`¼«/½0çPoQ&ò<è‹X£³€¹ür…“{Wò\ÕÊ= •E‚ÊÈçwê0*þ]&D?Ûò°/ìf»-BÏ%ò¦U*ÛNЙèÕþ q…ÌÐ ¦ ÎâE¼ˆçô§,ÖÐÐË4’îs:;%ÿ™X »RáÚ"×$ˆÒ*H5Ë-Wü$*¹öì§F‰¾ÞCb¿ÓŒ;‹œÜ¯"ß)¡@®Ü CgBÕòhãÔiž°~ôS8¢ÙÑçbÓBw]c>/XObject<<>>>>/Annots 1575 0 R>>endobj 4801 0 obj<>stream xVßoÛ6~÷_q/ÝÜÀVü+NšaÚmél[ì%@@K”­–"=’²g ýß÷)É–í¤kŠ ’޼»ï¾ûîþîi„Ÿ1Mçü?-{£d„7ükÌ¿þüÔ›ŽgÉ”f“Y2¡’¦³I2®Ÿ=ôŸñu>ê|ýøxpa¸Õ.éònFã=æð<‡?²à¤ý{One*•ÑB’6^fäWÂÓÃ_÷Ÿ(3ÒñË·Ÿ{—wóú’>‰ÔWB©]|ß\Þ§ÔJá% ú &©tÎXÊ+úÂh*4n–”šLRái)µ´°v Ýkç¥ÈTÊr!m}–\•®ØÃˆ†ã ‚î GÑ#° éôÍâó𽓦«§þF¨J>½=ªp”V¦^íƒ*4R,´7!š&ŠŒ¶V¬×pÞÄ‹¸~5[¹‘v,µ(‘™Î(Eæ…^"½‘šSëiò`®Ìv¨pZÑÚšTf•ªñá¨>]»Sœ`ïß­%eÒ¥¶X ^±0™ÄÌÞ£ÁµNæ Ë<Á=xá‹´†ÐuA`ÓY2cãŽÙ>Y¥AfpÖ¢µ-<¨áíNXè¹µL dâ­Ð.7‰`u‡RËD¹V2âåãiŸšúµ•][Tä©ÿ[á<]¨Ó¶!zc¾€”Ý{ÂÁÛÛoÝR3ð´æÌÉ×н¦ß#33áÅ‹ÐØH·YNx0~ÌÇ<*…û „†èçm…ž²Ü h- KàÑ 7\(“Ìs°¹·vuÇe¬E´®Ý6HÝ@SÀš sa’L§xÊú@ôg%õÒ¯ž—²­Zëé-ýÛ\ʪѧúŸ•ˆUSè¾xò‡ŽÝ×ÎÓ±×q2àf¤ºw_ðwàˆ~Œ¶]‡G…Ûº!¤½‡é4™Ï¯9±åʆFÒZ„R¡Y£¤eT9n.`h-Aoв¬¼X(?ìÕÅâØøÀôHø;:FÀ-ŽØrh*˜A¹Ë€k;0}ï×- J5âV²ü,]Ðêa}o­§[Ö}ý½§­@ 8·Ê•Æä]Ê(dޤ¸?!\›†™‘E͂ހ «E<ª@b# Åð h-iq®ûmDg‰™*á\ æ%ÖÕBi`5s= ”$á²öy_’.–0áÎÑöM]î©ãÛ¿†ÏGTšì©¤¼´²Èý9 © «: g¾ƒˆRK˜†jP‘m„N%àîõ¾Ýg0º½=—Îqà/b \Žmñê¥8º¼¤û†î´@6<—öì ôlªræÖo@÷P” ŠeØ0‰ˆÅ–„÷öŒCd`yžè?f±«·”ƒþCÓĩ޴ÌkfdCšIŒwp‹JùA\~Ð .t@¸ÄÍ¥•\#žÍ¥XGíŽjÁ†Xšxˆb•W?ØAÏW8>9éwÕÂ+l@ÎU¸»’ºA-ì8!`î¤ýÉíXÆŽ= ¢Ġ„óáa\¦ô5,\ À€ó'ZîÉ6hdê•^¼3æ´"3%LñÂËÒu‰¿Õ<{±{]\÷ûS;ë•­‰µÖßà(¾Û—¾ÖðfOe]s´6 ´´Ýeåõ>‹ Rnâ|d$.œTùÙùXÏÆïØ`øþ Ýá¸1E†z5Âll "–éxywS¯¿ã›Yr5½¢ùÍ4ÇÎkûpšŒèg“V%ÖÓ°Ÿ1<˜xÑzxU“ׯ«f±i·^6½“››8}æ×üæ—ÇÞ½ÿÁ×ÌÉendstream endobj 4802 0 obj<>/XObject<<>>>>/Annots 1578 0 R>>endobj 4803 0 obj<>stream x¥XkÓFý¾¿â¶PâÍc7¤[Q‰Ò.PA_›ª_VB{’L×ö¤3vBZñß{îÌø¹»U@¶Ç÷}Ï=×LhŒ¿šÍù_œŒ£1îðÏ„~{y2]œG šŸ?Æ”Ñl:ÎÃUJW'ík<=›DóöÓÖ5ž.Ƶ$÷îxÍðÎÌKž#â®ÜÓÖ5K^tž~·l™êì5:½Ó"—kšŽiþ5Œ™?¥eâÓ2þX™®GߪBf–žÑ“½HKùÍãåŸ'cMp*|à«ÓË3âË5 l4aƒ·ÚHRùZ›LJç$Vº,¨Ø*K±Èi%i­Ë<ÁÜ”tõÇë—ô°*Æó­ØÒ ÉéëÆ ® SÆE ‰(e2[Ic»‡+oð$f¢`üôŒ_BåÁˆÝNŠu"©Ð´‘¹4¢ÀÿñPı´V 3q$ÖJX¦3ü®ÎÜ¡V9 ¥â¸“™ØÙˆ–-ÿ,¶¢ 2ÏÌ)Ë fL¦lqoãÕKè‘ïE¶Kå•‚ºLÜÝÁ¦å²Erqa £ò7,D€öÂ(±Ja!¼A€½ƒ yá…îB˜,:¶¤"ß”bå–½Ú"O‚j'5îpö8ì©D8r[‘kid{O8¤×¸åslpM™0v+ÒVɲ,¼D'h-9<œƒŽA…LQâ\páàWîWÙ6šÖf×¹y]°:~ÒxÕºJ1Ô%T%}[$BíezäòÌ7Þšƒ8¶*EÀ‡ªˆX‚ÓµÖiªðú‚ë6ß81›¡“å…x>¼Ôúë¼wÈÑõ—ô„ûñú1ýSE=—¸F5±ËÛýzG›ÖM»×*A¥UòmGþ0D×[áZþN•]løhhX"U,5Rû£’2Dt ¶sqŸA†7™Ï×íêÔíéîÏ_]Ï&w ÷Wú€\:ÚptM|í™ûàÿ?eî¡Í>›Ch\¤O/ÏK>æ/¸“Š0¸Re MM,oôÿTòƒ­Ä ñ1†Òg =šD³hº¢¢9³¨ÃVÅ[RMx!—¼íãªy) :„I÷‘~Wcýˆú×ü+í½å!ýÓÙcžPo ‰ç¦Û8ÂVä·¡®U\iÕæ{£Øê .r‰~²[Öx£›À$øŒÔý:2ÒLÛüÉç@„` ;iŠ@ìWBö5a¸=ؙݰ´¾¡ UýˆóÙƒÁúÐ;¤""åfËêÖBÇ£¶tÛ‚9³!ž÷òXo40õ LÎXˆ%˜ÙHDW ëjg#jIB‘õSYV¼¢ö¸ÝÀ!Sÿô}g{{¢U`þŽðaåõFô½Î¼'`…r-êÇ™•™Šuªó/¼²OéË_ªªk2Å6‚¨…/œÍ2¿Éõ(ÍëïWÝjGs¢fÃçZ—¹ûó°n| ò§GOý~1æÑSzë>Ó¸O6|ê|2‰ |WÃŽ3_ð–'¿žü , ’endstream endobj 4804 0 obj<>/XObject<<>>>>/Annots 1584 0 R>>endobj 4805 0 obj<>stream xÍX[¯ÓF~?¿bDUʉIì\©ú@¡Q©ê…¨¼©ÚØëÄÅö¯ªþ÷~3k;vrõ¡*­B6{™Û7ßÌðájL#ü7¦`Æÿ‡ÙÕÈáþóÇo¯¯ÆoŽÍ%>3šž)½½ê,3oYŸäÍ©·èîvÖØùýÝÎ:#4ò‚ÎÝéÂQ¢ÒrÌReÁR;KViÑÛì®±,=˜Þ^í®±»Xh»;Óý±å‡pUVÎÖÓW§#=ívÖØÍ½iw·³f[çì‰ÎÝ9Þò—s'w¹ôüz%r;kÜÏz»Ý5vg3Èu/ñÝ‘ È÷§òr0ña‘[ÉngÁ÷#~YÎòî÷«R.ņžÝŒh'W1¬ "1›Íi žF´ ûdõçÕ³› "Ãdž87ôƒúÜ@åå¦Ü&ù†ÊÒûÜrRkS•ä.–rq`“Oú²ÿÚàšÊ­Æ…0ÔÖšÂÒÁTiDkM‡")Kl•¿ïé”Û»Ÿ¤oÎõèm©Š’uJrzûîÍëáØ ¼±ÏÒ˧aÄØ‡¡ƒµÞª}b ÚBûµ†ÀÌDIœè¯ìtˆ¯¡JÓã5íL’—šULÒÔIœ5¶‘ÉÓã™lDeuDI,:ˆo,4P%)ŠT©ÊãNShŠBÛÉ#ììØ²¨Â²*4™¢§j˜*k=Zmu¡cShñûzϯDpÙÉwj·cÉ9¿Øú6É÷&ݳ[œªŸ KJ,…[•o4á›­Öe ©kÄ6)Éf·ñ©ž¦±>Ю0ëTg– ªÊ@•“i‡²& k2ë¼ô+[š,ù¤ÊÄäkÅΰžÓy Zò&ŒDÆá‚¿FƒòᕎU•µŦÊt^J˜O¸åÓo±à㌉"@¦v„ð‡¦ÄWyÈrë@š¢ó§=ºbôG•íRM™ÎÖpA{óyãÝSf }ß/±p‰"îú«ñò#ìªuš„r—Á)¿þìM‚|PÅíѤ×T:Òw¸¯ŸðurûDÒ´½ø@ÖŠ×(…ÑÖÑúHëÁÒ²PèÔ¨±Ìt¹5…¤U¸mÞÀNã~d{°Ñq¬áÒ½vÂ:Jæ‰|àã¼B†_jƒ¼DpÌ/-n@¤?TÉ^¥ö¥n’(•ål,IxNˆ¨Õj:1 "àı¥Æß¨ ‚¬Ø¤©9°ºÀ1›ö_D¹Žðytï‡Åœަ±ßþZO™)¶Mª#Åå¾ C÷…ÞM¼¢Ç-\G;@鿯Cfyc•›Ø„¹“È7•Úh{†+º¥—_õ0Êüó£Ú«k:lnfMþ¸DˆÎßì˜TÚ+&J–Ó<{M/xþE=F­)‹Dº^¨Ù„_%o 6ðÆJ»î»ÉÀ¾>Íãîp}çn@à¥Û6CfRŒMhÙá΋Ùž’Sˆ¯röY¸ý¶Ý©¬®{æ—{Ç~½(zÙgÏè¸ü4ç?ðaã±vNâ¦øs ¬ËùÝ8„öz5Íð¢&ùñbâMƒ)ÍæSo6–ù{×a€ÍzeB4¥ãáWðO#îôpîÆ·{ÇÒéxÌ£¨è>[òÝVW¿^ý"ôîêendstream endobj 4806 0 obj<>/XObject<<>>>>/Annots 1586 0 R>>endobj 4807 0 obj<>stream xW]SÛF}çWÜ·š+þÂ:}HLÓ wúâ™v-­í-«]EZÙx2ýï=wW’% L€1Zí×½çœ{výõhHüi<å¿8=D¼á!ÜÝFÃhJÓÓq4 ”F£³h\µ4Ý£÷ÐFïä<šµ{[môΰp»·ÕNi<D£Vo»ÞÉ$š´zßÏ[¡úxó5½½žÐp@óršžã!ñ©à!îÍ7ª ,·IË‚JÛ4SZŠ¥–´ËE–Éœb›HZÊX”…¤D®D©m….1Cº|ó†D.Iò+ádÂ/ÝFR!R|Ä6“$ ÿ&•éRæÇóÔŽIo…=²†v™KŒ»ÿëÓM³–Ÿ–6 úµìŠD[3}ÑK¥0ʬ±‘p~·*ÄØJrPV.µŠÇQÂhÂ!x VR¸YQ:› §b¡õžðÖ §!ÂdPx¿DWÀºwàÚ)·i°ùºL¥qEwNÍO„I8#·€ûAîw6O€i5‹½‡ZÅ⸃^d2V+…W6'‰]±Â%á™iaæ"úíÙ‚f˜rõ¼DbÝj‚€À Fpip%m<†Ðà+UVeQتv•s>[púÉÐzÉ…>z€ÔfTÑSBCšö¶l´ÃéƒePøOW½éÅaü„ *[CCVòj¼Ö2 «d니 «¨<ñ»ÕtNW¦LÆtQÙÙËeŃ!N_ž—fޝ© ¨ÒL¬àúÆ!ãª2šW÷0c¥†Ì˜_†ǹZb>džH'_8r:Úð®à¨}ŒâÈ íˆ>Ú»-hCù4ý¨‘‘|ž*o *‹h±Š:±DÈx ¨àúOQ÷R0|ât㪄(#º†¤eå§¡â[ŒlÊF£h̃ьò-ô]$~¯Ž‡Pp 8 j ïy4º‹à„‡nÃ}ÊO—$}k ûÆbؼ,ì>èæ€êëçh¿Î•4‰¿]g Õ§\Ðv (á8±k£p–rùñYØÑ%޵•7¦p…â«"ß(^ç0¨õÚÚkÕžÚRðʧD[«š›EWüyµ8î ׫ýé /ªyÔ¨Ô'Ä…=Ÿ2×¶ÖÄ¢rYðØBçŠ,¿–8p5ìŒÞÙbávÖ­Öºu¯Tÿãù2¬ï/!Ê †Ϊ{ÈðlŽOi:›FÙw!VGŸ¿í|°±¿ÍzwçiX9ŒîσÏ/_§Ã!_¸|³Oºšýqô?¡¢ zendstream endobj 4808 0 obj<>/XObject<<>>>>>>endobj 4809 0 obj<>stream xÍVaoÛ6ýî_qÀ°TMmŲÇͰí6·ý2`[€}1PÐe³•D¤ìCÿûÞQ´Ûqº|›²t$ßÝ{ïN÷â/¡tÂÿYÕ{{ׯCÜÜ}™%]ÍÆ” é®@ìä5.rÿYô† £dS.³Rá”®û$,©š~~õªOÊR[çÒX§uNNÓBò3·’dE…¯L7’6+i¤¿‰],VÛ°¡Ìû´’u&ût¯[ÊDM+±–/ï>õ®fCšÆ)ã iŽâ4ů<ú^-kíÂÜÞ.J±šG3­é²˜¿ü" X€mDæC韃gD^¹}ÂEÈ#¢¦]”*» ñÛ»DÇñéÍP µV9=޿ɾn1wQ_ù€=#œÉ`”Æ“É c`BÐÆˆ¦‘† m|M+éV(þ >ýmTYR­3±”µi2÷¸¯f¯)ÇãŽêÁhÊ—y4‰“„þ(–øF«ÚÕC4ŒeO§¼ ì“y°„ضi´Ái}Z´ŽþüëÃ;rFÔ@+ËP+–}†@ ”í1͇ü"ª¦„ ÄC©Q©>³n OÇ‘&F;Mœ#ó,•`3×àÙkc…ë ±×Ðác'*õfPʵ,Id( Õ¦+Û~÷XÃYPÞGH8ˆW/>õ·ˆ.âD”ŒÂ?ùUôé¼a¤¶‘™%|fQêJ[G¥¨—­XJüÊÛô7lÐm\„‚¢L×Öj!zÈ>ÓiT¥œZKÊ…î¾ÁVóèh´Kÿø(»‚„¾T”ZœI—ŨÜâžÖ¢l}b“ËU!)rÒÅ9á©Â· n?¨TÑÖ7»½ûÛ\4¥=©Þþ…Öó®V,qºø(:ëgå¸f¢,eŽN«+æ(3ªqÜc ]BZöiåû3S¤}ðùŽ~ÓN¡óy6Vä,–YȘ*Øu­©ggrð¸‘7ßêw!ÁÊHÚùÀÑO£ï|ûV˜#½Ÿõ-÷ë 4õjèßÛál~ïB/ä·3êžÞ§qò±—€ù±;š_‹ùÔ#4Ò¶¥£;Ã>Ž„… ^táϱó{½AÇ1ýPiÛjõÿâß`MÌí b¿ß&ί ¡T¾“žúÓ ï,IÖbÚÀxd<×­¾ŸuõÍô[>õ35Ńq‰Ñˆq—­Ø¦é a€GØg9a–Ò«z¹o±&Ã/MH.lõ4¼‘†ãø:½¦Éô:ù¹ËSuÆCúEgm%kôZ´)æï ]ðছ]ìCšù÷7?ȯ“„‡7ZzÝ$¼ä×»Þï½Wèóendstream endobj 4810 0 obj<>/XObject<<>>>>>>endobj 4811 0 obj<>stream x½WÛnÛF}÷W Q‰ÖÅvœ¦-7u èÍBòb X’K‘1Éev—’Õ ÿÞ3CRi»ñSãÀ–¸ËÙ¹œsföóÁŒ¦ø™ÑâŒÿGÅÁÅò`Lñp÷Ë®èøò„fSZ&Ø{ö bYLJhôÖ”Ïõ\iˆÙãƒO•G;17h*ïŸDüZ‚üW›lõžî+°¶?4/þDÐáÑýäÑýÿ#e¤/ø®;SȰ÷9šV©Õ ´»EªÂ ­Ñ9F3E|n'Ò H¯5ÚZŠ_†wPmß¾ƒj¯â{ nä<yž*hu†ñ¡mª(ºkmƒü².BÐ3ÏÏ€6P×Ù?M@¦’žÉ(C·fB£q€&é3“ÕHx0¬L³ínFˆTI! q @—‚tÇcd¢ÙžÜŸoF;dî¦üŽÌ€6狟tTêåFN"7•)èK̛ܧB79»vµk/ÓSNÄ„À 4Y” ‡4$+9Ë›.6æÁ™8È|-Éär ÁûcNÏS³ÖÖ²PdžW¼96PP™túù}— çÕV_~°3ôÎË4> vYäªô·ÂÅ}Yà&B°Ì&tׄîzvÃÛêXÓ;[PäæÀ•.5¶h¦ \BíÑ^ ªÂ݈'o †V2Üît¡Lé~´m}[A|Øy äÔ¶„GkÍ·Œ œHË(Î#ÞÞ¢0¾àë>ÇŸzk‘x ã)Æ}L¨:I rïÂ%¥@ƒ—cJܱG–oèx+¸V€_w: ±¯@ú6ÒçÀ5 â Öý‰2mI¸§‹˜‰+Ì/ †°öºqÞÎÆóéIpº8% ×Á\.,f“E0¥·&’DªÊØZ›Í“— 1p=™Ñß]›KJ›EÇ/œÎf|#ô¿œó“_–ü ×÷Ìîendstream endobj 4812 0 obj<>/XObject<<>>>>>>endobj 4813 0 obj<>stream xµVMoÛF½ûW Ò•‰E}9ErhZ¹)b Á’\™›P»ÌîÒŠZ$¿½ovIÙ”m4-Z%ErvæÍ›7Ãùt’ÒÿRÊ–ü¿Øžüty2M¦¸yø²×tv± tJ—Ø.Ïñ£ Ïñ£ýf¼|~zùáäìbÞè²R޼Ü6µð’¼ÚmŒÝ ¯Œ&<ÒrGJÓÛw¯¤I–¤) ]ÒVì)—dåFiY²Å¦õ­•Á·k)œt ½ÖÔXQxUÈ1)Ï®÷ŒbJ“t€#‘;S·^Ö{D+¤sÂîÉ* yFfŽÆÄ}õ{-ý ³ZèëV\ƒ’K\~ßÈIQÉ⣴ôQsl‘›Öƒ|té¹J5˜ßIОCKS‰Ôoïøj!¡‡‹eã¼Y,w\°Ê âP£ a ¥"x4 aC¨ˆ~¼±¦‘ú(„Ç]øX$^¡\'6`Åp€+;®·Ê*y(£·RpÀæ…ÞÚC†àáNi¸2Em@â1“\u×(hUœXê ÜÈU­¼’.Ôµ1Ω¼fõjÚ‡†â‡†ÜJL‰ØŠ¡¢;U×èËÁY=iÚ¼VÅ`)Á¥ÕS Žf‡+qÃçHn6È Ç‚£k©%pÁM‰ù‘K§JéŽA¡˜^ªÀti ÿŘè«FÇíXˆ…‹nLÄv;ðÍÝn´ÉÏ~%¹Š%Н(ß dÖq‡û„.âˆÙûq€¾iA —€‘S…âä¬dƒÖA>]—OidÜä3†0K² Wåèì 1Eƒa úTyžnMÙ@üpøèÏÁåwJu‹ÀO:GÕ“Áó§_ºK†ã qzË1iè(–1¼4‘_,刺OiPcIŸÇûÎûç7ÊúVÔ˜ÖÁ3S\®NéM¿éÚKm%Æåßœ2ªäNú÷µ)‚¾®Fp}øýÕé0ê—áeäà•²rzN~ÿ)'ñü!¼¥jÝqäž ¯½õcGÌ ÷^:£[CË3}û©å·Ø¿Î4ž?dêÔò±4¾ö¶üWy² ow›Ièª,Y.W,ÛwüßYÑ4apbJ¾ÙûÊè1í$&öiyó‰í{˜<åãÌ¢«iÎã'&ÕòFÖ/ï/Æ¢æÝ¦õHOMˆ>蜗/_ò,ÃK»÷žQŸ/úíì}¯¢ÕÕé={«<°ï«‘N8€×Œî£'Ñóûع1ôÑ‘t‘%çÙz:ŸNç‹sþ¬«{(NCKý>cÊÇ8§¼%}îáì†eD8œ'Ñëx6ždG®¹h$x§D4ÿ@ ðìbÝíêézž,²-׫d‰Mš[y–LégS´[©}P*ƒø£õd§6–ǽÁΖ¸²V>±HSÞÈ_e|ç—Ë“ßOþKŠÍendstream endobj 4814 0 obj<>/XObject<<>>>>/Annots 1588 0 R>>endobj 4815 0 obj<>stream xXMsÛ6½ûW쥥•h}ÙVÜS“Ö­­§µgrÉŒ"! 1 ()YÉô¿÷-R%Õn›Æ1%Ø}»ûö-¾œ ¨?]òÿiqÖOúø„ øÇ_¿ž ¯Þ%.’>4 ’I|Êéþl÷ß^’‹oß?ìlèwµs:¿Ó O3œ|ù¿dþ@ü’vn5• åH>‹b™Ë.}P6Í% Ñý—JXIfúY¦¥£…XIšJ©)µR”2KèwYL¥¥Y¥ÓRí(KHé•y’MR¤‹¸M7Tˆ'¥çX—çŽJóöáóÙù |æõC˜× F<âtVÔtº´ÿJ'y|);á ¬Hè7³–+i»ðV’…$+]•íh²HS”[Ànêž6T96—_jŸ»KyäØ>EjP< ;ØCÂ;aÙpÌ®ÞiÀU,-….ii~¦F§Òj>Yi¼¨ð]Še@l!JoMnÖ½åÃ¥sf7 >jÖÏ¥––CE3,HsáœtØ“Ö …°À¨M4&àÎ/Š´¬ e/Xó ^VÚy+ºü:ã!¦ùÐä TÈra²6RN–¹IgȧΧ·È&¢ì–acƒ#jÊÙçöÑn@½÷¨¿´#Ç]›Û´m‰‰õÒðw߀:Í^x1¡»¢WY‡J"û›üG/šZ«<„y —ô†PA(­Y]UdÅ!¶¦ PB÷ªP^¾éËN†h]c“(K«¦U‰üØ·ºóž·cx[k|my¦CœIÛì; Däóã\–Grâ°Ê}ÜŸÿë—oNî~ă`ÐæÄ u͆2¹iøÎU(£CïbšrÏ£ãt%&d|¯Çõ%EFS‘[˜*ÏÀ='XçÔ¾µ•Yþ0¥D˜a ¨3JÃgL‰yj­Ì}Y‚³Ë53;Wñ¿S bÏ‹–Ö<ƒÍ}Ácßð©•È,>Súã8G¶ù•ƒ‰_uþ‡~TÕÞ~'¡ÂñžÐêUÞùó›‹m/ÙÂpÝNaf4vc*]Yw‚.ݼýO_*…æ@ Aš Ä æMà†Þ–É™Ò(7Ð šèZÚ™H%JŸý^+.}b!˜Q±´žË÷à(ÀÙb°Õ¦\4±O“dÄ­zä†Ãd4ÂSÖ‰4›¨ëÁäš>† iÜ\¼àNñ¤Í&MMUî˜MonŒy“Ðí\#4Y©®åž?e”\^^ñ)·3Ï/[§9g*=Žø¸’騮môON£]i³ä¦Ê-ÔÒµ‡h„‚'¥eÉf‹6•À^ú¾/¦À=ü¸YD: úqÙ¡Áð~­+:س½£•sa³a`*]/ÉÜ¡­o>šF¸¶b¹DÄ9a^ÞØg Ÿù,€‚ñ½Ôè7%A—{^ £j )œboÕ>7›ÜëˆÙoÇ;pý:•K–¼.¦WÌ:5_xá9-_¾ š£J†Ì‡”CcÚ¬)_¥Ó¼ÊÂ3Ž“A,!3:Æ!ÜI¸çGÕ5 ÈÎ)¥Á*…ç©Df¤c8 Kè§娱ʽu¸‡7Z3xõs…¢¦·Í:´œÙu.‹e¹‰´O’¦þ9ujÂnizHðN ¹j¹¹8h!oY£þk±ÞyÕy=¼H&Cˆz”.#—Zñìi(ݨ¥.#1vXñ¶Ö1¯ÁøŒÝV¿ŒɧÍP=úI:æúýV£îmKïç’þûÇø5Øgk:T¦á¿wÓÏõ÷ayØö½°tMËjš«4.£oÄÿŸÓÝSBô¾©¦­ÉæÐãFl%K‹ wTÀªÆüÒÜ-ÌšÙ’!ÇØQÚ BšûHhÿÞýã÷m ÜcjÎÇq F _¶m‡m!öã oªr…JañqÐuïKa=飂0Œq`ê%W±µø1 ®jwLˆdR<9ÄéʳvÃÏ’ Ç6ÆÛ¥‘¨xüÍÔlÆ„44dÀ#x’|àÃ8‰yY€ŽÁÌ»wøÎö»%ÄÚhÏ4ž8•‘[ÊT‰\}åÊ;ãþŸ¸<ÔÎ~Œ<%Ö¿nFÂ`;2¾Ç™üÅaÉC?•¸XP`Ï0 hQA‰ÂT:ж£9FH|›´!ž`0ß`QÈê…œkSüÄh!°Hí7[±~ £CÆU }]ÝoŠ4tˆZ5‡ÁH‚W ÷!T˜¬‚H O\ á :YÕØÇé…äæ=ovøô’`ßÖã,ŠA’Gxw`›¿fñ¡o’êÊ.[ñ-æ<\¾xbñÚqG ³ï°…¶ÕD:Çëñ¦²ÜgÉ@Šêk¬¢vIÍJÆIŸ½ÙJY¾9tY+ÌŽßÜèn¬&±2*ãJe­ e k0/³vï18ÊqW¨|¾j:Uã9¯,¶Ú|§‘E4ÞÑ`œàÒ…ïÁzà ÿšu.“Á˜~¢©Urpiå›3Ô$ÁÎ%L7\ÑÀ_A¡¤ ™òµÖ¾ë|È8™Lø”>‚þã‘À¥Võ› =¯xÀèä½ã‰  jqÙRBBý°ˆD`al2Ÿ#þª¨¹T z G¥À$IS ä•È+\áy¾ æM¢öÇÉÅè‚.¯®’¡7’Mo„[ÇŸMZ[ñ• ¿ª‹{W¡'µÝnï¦xÑßTN‚¹ó'¿<œýyö]bq}endstream endobj 4816 0 obj<>/XObject<<>>>>>>endobj 4817 0 obj<>stream xWÛrÛ6}÷Wì[eWb$_d5mӱݦÍKg:ñL^4ã@HBL Zæ4ý÷žY¤K’ÉPÒb/gÏ.?ÍhŠ¿3:›ó?Y]ßM³)¾ÜÿWoèÕÛsšMév ÛùOxÈÃïx£ÊjãUMÂä$È·•"çkm6½µ5©GQV…“6°.ư¹ùñGJ§J½ÙzZ)RFÚ\Á…ƒEt@…¾Wä·Ú½>¾ýxôêí”Ùgq:¥Ééivv†Oùèn1]¬•X,]ËBEó”ó$˜Ÿeóù%›_‘³¥Úm…'iËÒúÔ(ç5´£ÝVù-ÊAêÆzDG¨iâÅæM‘s²N¬UÑR­Jû€œ×µ-ƒeWU¬\ç…‘(Ý[Ú(®Ò(Î éÏN9—JÕk[—Ñ,ºomê¯HEı ðýØ8OCšA¦^mTíðà¼ùoóÓsvþÎ ¬Qµê\‡0n‡Ê cÚ«ÚØŒ`ÎV»ZTHËᦿ«ák…ú̓ª=*F`‹{êðË…£ª•SÆ‹eðÖ+Ö‹ša(„Ù4b£2ºm+-¥ !'N@}jôƒ(à‰ìš¤ÀÕ˜ ‚%Ê r¼_ð6prô`uN'ñËté#¸ç*K…²á·-L¸8ªMžsí%)œ³R .r§ý6d”"Ã]aq 2'ápðu."î·ø­ªíªPeôC\Â0.Ó-$¦áÒ‘QŠåá0n°¸¦ªlí iIäÌ“<Ô¾ûxO&ÊU Å^eSx9:ëÀÄAGï 3n+rÔ“«ïí9Y(º¢SP…QÕ¬ -C·2ÅÃwDÌzü¹gù_úˆÞÄÁèîúûݵé| ò¢»zM1#º§§aŒÁINõênÝÉÌXB,NÄòxJªà7$&o†…%*„ºØÝõ»k:Y}ÅÝjòfX»{’ß”ýmwc¦¡Ó976x·¶Eaw̶p›^ ÷}-ƒ}AfoèDÒ¯ éŽn–£åqÿbV0Xvýˆ:eß&ËR£Ä[ ¼À‰CÀä8Z °q ãC8—#z`üE ‚¶¡Ç”1­,;ÕÚiH/‡ã>ê£ ¾ƒ½<ž(EK…ÚqRªŠå‡ì꣒AÖ‚ <àa\`©úgßÂËãŒþ²;³ñ~’X£X.:öb˜iH¸(v¢u‰±l°«-õ€FðÀ3éûKóË®ciÈì¾$—Ñž/émÌ;x+‚rK+Éz‡l°"Èû ú¸åžD}í =ý™üáoÁgt"(µ<ž dËÀÒCaÞŸÿž®âçÏ\áËfQ&|¦ ºð˧‚Ûëo9§Cç0îãgWxB°h¸èXq:=Ï.Î.h~¹àmŠá›œeSúÝʆIä’ ‹¢åä2Žày6;Ç·ªµZS®l/´œåËŠÖåͯx! ý%·JÞ£Zp1›e‹^‘ÆåóÇíÑ?GÿªIL¬endstream endobj 4818 0 obj<>/XObject<<>>>>>>endobj 4819 0 obj<>stream x•VÛnã6}÷W RlãdÅ—Äñ¶h€Ä[ûPE]ì‹‚¦h‹Dª”Ç(öß{†”ìÈë¸m825œËá™3ü«3 >~4óŸÌ:óN?êcq÷áÖt=»¡AŸæ+ØŽ?à!öïñ »”;û²%™Š¢ QÐF¥)ÿ¿˜ÿÙ¹žÁ¹ßØÒeXi\uI*EÓ×"šcIZç”,IŠ‚?¼¡¥¢LÄŠ–ˆ–X[h³ö냈ÏVÇ_Í­6¥rTZ6ïÓÕ`ˆzºU¡H˜˜tAëJ8È6Ö=q9œ©Ok‚¼ïÆï[ ùÄælVˆLQ¹ÍÅVdlI©õþ·aY›•u™(µ5ß5IO¢~fã*UE~ûüé'ÎæYÇàI.\©‘|Qå¹u%#d÷Q”±/ !{>¾´¦(]%K늈fؤ^D–§@J¯šóßÚÊ;O·!òF—ÉÑ”ê'08ÑÅizz®¬]t=pð7=A‰P^­ݳn­wñbaÎzôrH/­}{¿2Ž.aþožÏßç§|¿I-–›ZNB0èqiÅR.#ÊŠyµÛħṿ¿Ç!Ñâ¢UŸÇbÔZÚٞϩ=;¶ãÜ¿:?ÜÇßß,¯¡-S˜¥¬µ:Ó) 1 …©V“ê4§@)b%â9(ŪRèÓQ “afíÁæÕ2ÕÒCÈ2Ü0†Àa`vÈp©~ã ÏFô-Œ°z}MS›c(ì;¡…‘ßê9µnÇÕ¶NØÞ¡Õ¼næòÅï}s]R¦×IÉËÓi×N'qò€DÖåûŒüÇ74uJ”Pü®Ušßù²IƯֻ:¨ù;Fë„«šƒ½a`áõ úYAÔXØnYf…ŒôQ¹(e²ï£µ«ü| ·eÑ«+÷æË”)½)ÙÕq5b•m؉-l¦6‰ÀÅ€TK S\aüÆ[#2-CÓ*öZH§ó-Ð`çå°™PÍß?¢éû÷=Ú$¥,µ‰‹×é4 ÔquŠx:ƒÈzÏ*\Tbˆ…Ë´áÎðS&çÖª‡…Qä*ûZyÈDáîÀ-¸Ës?+ÂìBŠs¨1®=lЇUåõ ÀµˆãòÅÓ÷-_¿T®д¯ý‡‰ÑJGcœÃ;æ2Å”Á…޽bÞÁ¤#‡$bæPŸ˜r ÙûyóJ6ö5| Å~¶œV#3 Ý±{ƒzøœnJ†Æº8Ü Âó®30Ôæñ›òTl±Bà°GÙi\= ÿΦÊß‚®g“úb;ìßD·£[OÐ~Þ3!®FQŸ>Zé}ï팯î‚Üýÿ+Æí`À× /–wc>¸ç_;ÿɈVendstream endobj 4820 0 obj<>/XObject<<>>>>>>endobj 4821 0 obj<>stream x­V[sÚF~çWœ7ãÄ(7Óvú›Ï´dB¦Ó>,ÒÛŠ]²»2!¿¾ßY aðäÁØc íÙsû¾sùÚI(ÆOBƒ1ÿ¦›Î›i'Žb¼¬ÿؽºRÓt ÙñOxÈÂ9Òî±ä¼ð*y¾'¿ßÊŒr¡W…XIwCŸÿºÿ 'ùµ¬®m¤_›ŒÌƒ´¹™Ò+¼J×B+·‰hjHm¶¹ÜHí2K؃¦ë鿘zIÎt]jÕÖ³†SÃ+©¥ÖeÊm…O×´,tê•ÑÐ#<¥k™þWz§‹ÍBZ2KÚ ç‡°«‚=Àu±YãˆÐS+¡ºá‰_+W믂_*ë<Éob£4;’çl³qˆ–Êl”v¬Ð¥CijlÈ7áÊÒä¹Ùq¨¶È¥û™­¿ºUðÃ^È)ù³Åʯ…²ƒ‰ÊKL»ôG€Æ­$g¬‡ðbOJs€ŽmsA[ô`^t“ˆš.á Béu•ÌAÚZ™ÊLêTž¹ózûò%e¼âlÇ€ˆZiŽƒÝ‘V¥§ŠèAä…¤yw·V€HdÒKËiç€N€:’‘6&C2çו'1M¢³½ßûýh0À·¬;…+Ôø|¬c8è9è|ˆŽ/‚Ó¿?¾§UÆá˼ûA­Öóë†ðƒQYS¸7îµ—+iÝQß°)p‡: U²5 U…ϸ)€ê³ÇÛü4i |ötxd¼c—çÝßÍ®ô÷Ø+z!}ƒh<¾åô} Lí|~‰úDK-ì”_Ò;±‘Orð1s•>0WfœŸ^M@TRUÝ5n•ùaþ|»A¢=íËßË`ÁžœÞ¡_ipùBß©žö?"bú^I^dã”Á™û(96{ª;oÝÃw³¦ä í1˜;Sä(&’Ê”såüÓH²Ét¡W4ÞÌâPc퓞0Kê“vÌúµ@ fƒú´• ³a}Þxx³Q}£ ½fXãÙzMÉÛZ²Å&ñžDÜI”lFçM¹\†¹ÌåÉ`ð¼æ¹1áÂa hŸ7îé©ñ\ø¶ô£ð^`ÇóàÛŽYºÇ:~~|ï”æ ô†°)Ö¾Pg{D€õUwXöpü¬—³¥ìaWÄ2Ã*Â\*§Šp‡ˆÂFŠÓ=‰íV¢Áaô‰Š\.¼X„±r¿¤½)®xñò<3Ê‘"3îyúÊ£¹X ±0˜/Ê£7„}ÚÐobž•a˜¯‚;KƒÇ¾WœœT{a?F£ÁˆÆã bÖÑD1½3iØo±Í`f—’½[^ø³î8JFQBïÎvç*ÅÕ½Q’D“I¹ÞÞ²¦÷ÓΧÎÿ™¦´endstream endobj 4822 0 obj<>/XObject<<>>>>/Annots 1591 0 R>>endobj 4823 0 obj<>stream xµXÛrÛ6}÷WìS#'2c]í¸Óé4Iºmk&Ó©ú‘ „˜T´¬¿ïY€”DY®íL;qì‘,öröìÿ>êÑ)þõh0柴<:MNñ ÿêñ¯Ïøê‡É˜Jêð'~(èúhçcIÃAÒÛy¶ó±¤³ód°ólçcI½Þ¨õðídljà‰ÓëË7ÔëÓ$‡·ãósšdÁÉSš¤q }ú©œ©y¥üš”¦ßo¥-ŒÈ”žO¾½¾R‹yûI˜ a óYέô^ÌŠu—®¿\} åHOøF’7äªåÒXOÆÖ´4Î)~R9I&§[Q¨ŒÞ½zEf{XBïŒv*“–üBRnŠÂ¬àÉ;Q. y½9%NÜé³?ýd0À§¬sk`17fÚQÚÓÝôø{^Ž%ìûîãÂÀdó|ÜI07HÆã3^¥Ù½.j®Qÿl€ß­áÁžaxzF™[ˆ ˜Ì¸M aí ï¡1†8=’•„úõ&»˜_Å­ø–À{ãÇF°l¬r\¬mtèç¥ÈB”›^|wòÅœ<ØìÆL)šÉ/jð;™îÑšŸ”¦ãh¥Š‚ª´HS'0[nMÙ"n›‹ ­®ûÊèè6I++–œlše Êì<‚S÷½…‡Gž¢š˜˜%žÚ$¨Ø{K÷Kk@Ë¥#ªb³šm «À0 6nÁ-oº*v†æA$ËÈbÈÒÅêz/€*  Ȭ@^b¯ÿï³DwɊ袷À¬i#½C©Ð<‘éÝe—3 • ȺF2u›f¨|Ý<½ózžœñ˜Ô1ícN´Oä‡uB.1?Ã4XDIÛ¼$ûæ¼²mç Yf¦B¡ö"Ä0uŸcÜÚ%PËC‘Ä8?rÌ«LàMO˜O訮»ì^Ù.¡—û¾˜¼î»½usþ\G…µbý:ùçð¯ÿÃMf/ñ¤tî~¨%=¡ßŒ—‘>" =J úÚÍýPŠ"kî?UÐs9Øæ‘”ÃCŽ>9 ˜ˆgÃø½ÌEUxº…‡ÚhÊêÏÂΫRjÿˆãy£+ë=pÊôø ¹·‹~ Á½ÏJúIÿpùD ùÇÉ®ÌÏdZn!¦Oˆ®—¢¼¸Š#"!p`5ÑÔ(¡V"ƒ4à®!HÁ­¦¢ƒÛÏžçÉ[tÿË.ÆŸ>×§å6_ÉÚbûˆ/€ n¹5à¯øS5@Ù¼\` èQ¬Dá bŸ Žáâ¯Á-˜çêŽÁ†+fÐÁ®°@>¾Öò ÏW3£kžn´`ÿt˜Œ#Æñ•#òd€>ïMfJ(=Ÿ†KW\{rkü„·.£^/Á»š‰³s¶òóäèÓÑ?Æ,’Íendstream endobj 4824 0 obj<>/XObject<<>>>>>>endobj 4825 0 obj<>stream x¥W]oÛ8|÷¯X(¢¤±Ûùªï©é]yiq}1p %Úâ$º$Ÿq¸ÿÞYR’-¥iÓ&MÒØâ.ggg‡ôçÁ˜ÎðoLÓKþNŠÁÍ|pŸáÍö—YÓèö-'4_aíåõ5ÍSÿüŒæIt/â)½+–j])·##­Î+§tI¢Lñ²…*×Çó¿£Ûs#Šó 'çñ92Ew+¬#ÑÆ«’ôƒ4¹ÜæÒIRKÚB:­rI©–¶¡t ýlEæ·m7P#-A‰4N@…6Ñé•G<œþeç¼ÝHÈ2[D³º[[1‹øgìÕ·if3üµˆz4~däÁXƒ™úçõ°P= bWG¾ ßø¦ÑVáÐÞkBó Y,¥±=a<’?k¤‡IŸÆ»WëêÉŽyCû‘D/Û8¹Y VÁ}«Áâ@ËBÆöÞЇÖÝ0:%åø˜=Hç½= dOÄ¥ ^`p§aY_]š‘ð¦|ÐxÉK ÀàIÊ:øõ¾ ‘¹Â¡Í6 {e Å™$ƒ8qÙ 2 w²C'z‰ªúT4'œê`y;—uÍ?éʸ ný¤OüÉ·àÐS? ÃÞI!à‡G Z`x Åõ¤ý_w ¾ú-B#nà˜3 ÷#î÷\o|{àTÜ˪«KÝ^×7æñõy|1½ÀG‘I|.»|'Nã3úU'Uõù“—q€€°zxÔð#X.ÆãŸw<…Wo9ÝoóÁƒ/øøDendstream endobj 4826 0 obj<>/XObject<<>>>>/Annots 1594 0 R>>endobj 4827 0 obj<>stream xÍWMoÛ8½çW QÒXñGì¤î©Ýݽìb½XÐe±¥D—”œ‹ýïû†”ËùhzkZ8rfÞ{3ü~4¢!þh2ãÿIq4Œ‡xÃ?#þù|}4ž ã1MF—ñ š /b˜û'M7GûÏX\v¶~uï«ÓQüvïÛ‹½íüžvMç‡tOh‘ÑxH³·£x6»¤Eê5¤Eý÷îdñõhH¬/Ò(ÑÂ9º¶æÍiS¯´J胰ôoc5òVaaÞ{GD[e«ZhÚ•RfÌ2ReµuæCŒ'M ¢O)GB;CãœÂ>|0U&ºN%±+N_ø6zmýÙÃÛÖcDn#•©DTÊ”S•K YLe¦JÅ ¤*'uÓGcIÞ‰b£¥Ï^¿>ƒñ8žLP­¶7Q¤‰l޲Œ|—'û©î%àÐ6mm»¬öÌͪ"ˆÇ {€YFiÙG÷kF÷xhOc–ñÔ&ÂÉ3µ—Á4UV&•ÚJG®RZÓZV$6­ÀF‘Xàß{“eKÀ8—VU¢L$åJZa“|wF«”©Ž•†´)×ÒR)霰;P§Ó˜,ïàW4¾õ8 »¦‰7÷^°Â` ¼aãç½,£v7ï¯çç~í[fõÜápÏxÜ#r?¿<úìÍ_r ö5Úˆ’PÛâÙË Æê]ô9¾Ÿ<­Së(j$…a ÄÞ÷êüÜV8ïÈ«lWžûäõc‹˜½š¤V…ãŒ5p/5—!xëÞVxß :âm#j#̬)^ð}#pÓfÐâRx©gisL¶FU!8)5°<Ð6 ÛÍG7˜Þ~®1JÛúé…¯m©ÍrÔµ–ätË-ñŒ•ºé(-n¡,y y%lÅœG»Áè+m†UÊ”–­â„²-Xh ñ ÂÕþô„Úiú…~L^^­tF×~–¼U,Wë%ËT˜Te;Ê¥@îýv®¥t-|ebÉhÈ®ç§Í¼Î¡f+­6س}]bšà÷ô¼ù¦‘ÐØM=¹þ Ñë•O¦á$¯Û™üU1Î_\Ž®ºÑþ©·íø¼ãšlZeì=ã1bÁµJÌFÒwÜW0¿#mËh>Ç|ÌuõÝŽ @ S<°ûBüTbÛd¬„…g? ´2 úì/œv®!l˜okmV˜nÂá F…G½¿'ìÚæbt9g“)ͦWëÍ—O׃ ®›¿£”;»…î]ÄSX.CMfñhŠËâûb¥ÖµªxLéPÇìk¹ÀOG£øê ×]lq5ä7,Žþ>úNùb>endstream endobj 4828 0 obj<>/XObject<<>>>>>>endobj 4829 0 obj<>stream xÅWMsÛ6½ûWì¥3rcÑú°eÅ9¹n{i':½h¦‘ ˆ$´ªvúßû i‘–·—ÆŽãPXìÇÛ÷vùébJ|Mi¾àï8¿øju1‰&xØý¨¶tý8¡e4§UJ· Z¼F‹Å­jB«xôE% ‘Ëõh#ªõ%}(E~Ÿ󎈮¯égÿ)á9C8Cª X kýQ2…Þ_®~¿˜ÐxŠû’á}_v—½¸¯½HÚî–ëÇâkRÏøÆ6ÜÑ‘ráâL[r•‚âIU‘Ë𑱎l)c•ª8ÄsáHYJ$ŽÉ$¢úT 2!Ιlg$,q\©àzÔÕ çïBé×#U¸õåóõežL—-Íî¢)Ý,¹‹×3(C߀?/<­W ™©¸Fz»L8álÇšFHú7Œ(Q …SOHBT²%#% 㘫hf¡6¨ þ¬{e)!6™X1Å Ù©„S¦ðÜßxð»ÒËWYm¯Øv`aBšâLÌt;) ²bîÛ‰d͙͢ù‚ùBÉPÕw|ž=ö•Ÿü¦µ³©þ‰ã€çPhûóÂ7›7:=b–¢Ù½àˆù‰H]ý2Þ ôÿ1ŸD?Gº½@‰gŒ­ˆ wŽ ­Šø]+6'šŠù¤T^šÊ …V¥ŸRŠM]Y¸ƒ†p°l1kÄúsm×Bæb§´¦â¼ =e¥sÌG4BÉž”©_̃Ϲ •’üCÄNï}§zb)¸ Àê“<«F ‚­ËRceäÃú %§ ÏØGD×Ú©R£Õ t¼òµ?¹ù;µ©j=`çÛYn„•a¤Ë@ŒÕ èôìQ¢šÑ„½Š&²tÙ8¸J@›,„úÆÍö„LÉJTq¶g:ÖöTÊ S"4»áz¬p§—Øn©Y,¾ú©ÑÚì(—ùšÒÈyì5ƒüш¸h+GÍ®¸½©¡öOø‡pµúÈÍ¡ìyu8Øþj+âe¡¬7ZÅÞ¸£vŸ(òH>z2*á•j=‚Ä5×WŒ#Vû'98``K•óòÆí© ç¼O#&6T=4»“ÛÃ¥§A¢ ¤álã$<íÖ+–n‰>c™”ÞË¡‡P@ëM›ŠÇ‹ÞŸ«aðzt,׃ҟ,ìCžv<}µ1,a_¿yC)4©™ûuÓwÇ…Õ%ìävÏÈ5ö"}¨ Ï;ì©aFùE˜u@ªªm+ÏŒn7GÿŸå7‚ðï¿l¶!‘6ZOœ;ÒÝx Ó÷Ý~ÜpÈ”Ïô|ƒ­/9ÊV`Æ{•á÷'ª­t$Ö•F“€ .3‰E½õ¤„¥÷= 4 Hn±¾0$9YÉ;¤ìÜU| Ÿi}j ™Zlå¿hÌéQvŠÑkâÙðìkºøƒÊv(½ï”/Ç ƒw¢àÑŠŠ©mÁ —)ð7ˆøáÞuÅ•}1ƒÍ€Í ¯Ë|AÒC·§Å½"_µãÛœ+ø,ÝòH;Sk(qÕ‡_øî T¶¾»UÔké0MØ9­ÁñãrDbƒ^iàë/Ìóåp<·ûôôî6ZÌoiöÖgáŽçÑ„¾1qËÂùQÄî±æÝD·89¾ Ûä"šÞâEý!ߨm­Üã×]óºëׇv³ñ-^Œ—K¼þc&.§üäÛÕÅû‹ƒÓNendstream endobj 4830 0 obj<>/XObject<<>>>>/Annots 1596 0 R>>endobj 4831 0 obj<>stream x¥XQoÛF ~ϯàËPµKv'E¶vi3ìe½(.ÒÙ¾UÒ©w’cØßÇ;I¶ä$mÑ4Hm‹GòÈI= iŒ!Mfüggã`ŒOøOÈ>}8›]×4½¾Æ”ÑõáMJ÷gGo3 §QÖ’üð·Å‘6§Ò¬éâvLó`B‹]Îhv³Ù-gsL‹xð‹ZçÚHº/Dvsó Ìr°<§Xç¶|CDtç:†ôP•”J±•¤Ë4Ô<©Îåù⟳‹Û)…0±¢Q4¦Qؘ¼«Œ‘y™î)×d¤ÕiU*“²TH³Ò&“ ©œ´I ·Ô”‰2ÞЪÊc'W#2YJcZlp*“"·O<§r_H<®lɱî>ðú䣈áD@·ÚÞdE*‡”Cµ-D,ék%RµR0C"Oœ®D®,íTšÂó’vÚ|a$­tšêÊ×TY±FDV­xÇp"3Ž«%Ü*áúT›#¨q0™ cɀ݇IÄ¢¤»¼”kiÞÔú _Gø»¬´þ¬6ü¿@|yÞŒSa­K1ýÛxä4ÕCªbç‡Ç}†¬oµJ¼²Ú.:,Ü—boé켢倣à]H–ç½ÿ5ö½Joÿ£È~Ô¼¿ < øÉÝÉÐìÝgõ„Í‹ÛpÞâî N§M@—ÀÏgØd‰QˆÚ@89•O8N§©RdJ¤V#³’ Q¥% ³®2@ vV*NQ1¥Ñ)í62§EÁ €ÓN8Ù¢¤ WK­£ñܲÕà†±¾œ|sx§ÊMsîȶ@Õ:C(aIt¸€üZ©­Háé­4© ž7ª6"¡)óŽy”…Ìrà>í28dð¾í®\Ã5²ÒUèò< ?eùÊ:Q®Š;URW9X Æ1Z4©ÉÔçÀlŸyד_S¤þÓ†žF:Läh¸1ß’J€C‚jE¾®·œ&õ˜ax"ýleÔ]">#k:1@NA\3¡‡½c¦°FÔ”N c‡¬Ò-+¾xà;‘„[ŽxÜ ÓÅÑüë(ëNí|ÔÒ+¡À?QÐo+c5 w©ò[¸½W™Ÿ§{D„ƒöˆIò©&Ïl ¢´2å~¼•¨_?ä'È O%ýÜø§½ô»>zq{Y÷1\?šò”ôNgZʃJUÉ#|ÙTî¡·-à]߆O`Ï%ÊxyÈ5:©b ž/×ïRý™ ûÁýßwFa0 ¢ aºÂ)Ö~@¤å:)•/ÖoÐD¹¿éÓí™kǃUëY’ÀÉÓãdî†Ç£ÙòšxÏà½g\Óhê·ŽY^SBøüèè7XGNºqÁ†0Â}.Цtͨ‘GŒšŽ\) zÇq §~=Q¼Ú°Q? `c²:“;I«¼²Øs<+ÅœYà ÐìNKNÖãë;ïKÌã"±0q`ý¦ӻ¦v4v`x. )pÀb„Á$ÃXÄú—Ê­àaÌg:+E&Ã&:t‰=´,ï;îT³†Qp[>ÊØ/ðI>Ʋp³òœ¤ tdz¥Ö(Uc]õÞùÈñ#•oõÙÌ‹Ýwس X¶)²&ä¬-“Œ e3¾ +ÅŠ ¡©:+‚éïÓBÒJ—#±5Ô‘KäÚH^;7<6ʽ€óŸ‰=m…ÙûÁ§qæu@¿"Ü´–XGÞ]†„4•ŠG&¸Åëd+|¨/’þ[ázŽsÞ'þâ¶Ù ¢ñ4¸œ\ÒlÕh䚛້÷:v+ƒ;‘ØËŽ®üým¼_â;ù_ˆæóˆ•ü¾8ûëìWþJ±endstream endobj 4832 0 obj<>/XObject<<>>>>>>endobj 4833 0 obj<>stream x¥WÛrÛ6}÷Wì¤Ó”¶DF[Qœ‰šÖ­ßÒÆ3yÑŒ"a 1I¨ (…Íäß{ i‘Qp8™óÇ$˜Eã}0b»Uùšô^´Hà^o¥V›Â?äNΣùœmßÇ,(‘q*`¬t^PŒäW’öB&]kCò“ȶ©RŒد!A0)ê­Ø*.}ØÍ£)§<Q8™DÓ)®’À/~«ÙË'úÌkqŸ«š †j'¬tÚ/‰]®RIf+Œ’⯻v¸¯â¾Yc4öô†FÃÆ›â«Å)]z¿‹À,Nkç‹@áÆgúÒ BÔ:ä½Û撞LJnâÈåyà,Ž\ʹ¤çMÏÞ,‚#Þ»e"¼\l¡×­/p1Ý‚#s¤-MNgܲ¾ù7vÞ"kp4KŸø‘\}¤¶|.÷Ay]s\ÖUú¿¹„?žKØÍ—ß™ËÙçrVçB¡o!®]2ù…—«j³š 2ξs+(+ûÔ–†.úÂ'Fkޤ<ŒBÆÅùzýÕñ«mTvÌÆÅíÛ|qXz`íÐQÑ4šÍ^2Ý|ØÈ¼…t—ú˜ñ„‚ÀeEŒ"ORp«Ê¹/®gµ̈±M+ÿuõ[R!2‚Ès¦ÉÛ[—`WÊ$˜>)"úSï%hÛ…!ˆAß±e!›nO8ÑÚÀ%RHÈŠ¦Â°~ͺÏ|phôŽ‚†LhÐË꿹:쯎軀²~3Ú+»ñÉÕ¹ª—‚U®.’JS¹i'whDnÕ’¦@ñ `Î"6jkYµZ%ôê¢À«"!/•.Y~±ô±„El$„ZãK[•|{+_o±½Â†!òEG÷Þ;©BëD^Ñ^@§µ AÊ:fsšû^££MÒØLR¦hšH‘^RÑ}®÷´Á/ÌEiu!õºïáC±4V “¦A-‚¬pd•¡B0}¸‹¥øš¬0kÙ͵ÉaqÚƒQ™C”ÓŠ‹«Xc3”ß鹇z†7ÒåiÐÄ FeÄŠÖX©«AY°ŽïqÑÂëg#¬=´P¢ŒŒ­ÚɦdcÞÎÔÐvf *T¦øh`÷¬GœcYÈäñQ¢Îc,—"I–KðU­1——M SÀ-[©>/XObject<<>>>>>>endobj 4835 0 obj<>stream x•WÛrÛ6}÷Wì8uLÇ-J¶¬$“δnÝø¥3ªíC”Ñ@$(!&-)ôÛ» ²¨ú’ú"‰äb±—sÎBŸRèão ÃýeÕÁ“ƒ~ÒǛ۽€³ë>Œ“!L ôaô:MF£K˜äΪ“,:Ò\²ŠO#–çÓP5×Ì*}úödòéàìúR4+ ‡Ë{ƒa»<š,9hnšÒ ¹“iQ»OBZ® –q¨Äbia¥ô-”â–ƒ] óÆûÜ ©7$Ã!˜G ÞÁ•ªê’¯§Ñ0>Ÿž9nKäÑ|÷ñE<Ø{œác–PÑóp?/àŠ•%ÞÞfå>™Ù¸@.†Ì³¥Ÿn ç”ãœç`^°VÂ.AÝq]*–ãý¢‘™J`¥QÀêºÜqØÚ$p­4ð5£ Ÿ®Ä‘XH¥y¨Æ›7ÁÉ»·>±öõì n¼å;²’uj¾zÔ•÷¸çŠçœró »GÂÚÆ¸ëŽc©6«%×ö±P)|ã[ØP¨Ä;Oœ(©çïBEPq»TyK”9‡%“yÉómyΩ<ïé&q,¸1Ôi"TLJ®>)cm ±®PzÅtžÀ{µ¢²Ç„f„£(ø °ÒƒÆ¸¥·œ×ä¸2wØDMé \7®NOc–¶*˜Ð¸U¦ªJaD,ÖAî!-à†Æñ -Ç}àhͲL5h„!î,±›šwù P<´½¦8~ ™•MîòÑ‚Ë{þ}«ÚtȇÝ&ëf^ŠÌÕa+?…ߨEç¶!§Ó(ÜzC®p-Gäu~í^ûPš'\<Š×ßÿºùŒ@1Ù€— Rž²ù}>è}èåÓG4SŸP—M©Pr\›sÅ<¶p+é„vjœ1*ˆ§ŒÛ«Ü{ÛQµ\¿¶™íïìd“ÄÕ×õ˜g¬1ˆE{l@*‹­x5G`·øq†ÓG‹ !J27y µ2F`Ñ)ÌŠá¨a°Ò¨¿è‚`æ¸â‰aÞXبæ.Ù[ä‰Gw“ŠaºB‰’þ”;(¢’„†Ù,`â[ svŽ·#÷2I!½…9àìî”,zéhL¹âÚ2äpÈñ€„÷ØÈa¾!ª2Ô-ŸŽÆ2™aÇ»-Œ$_u÷ˆ5hß*ç%·|ßðá­™Çzã{¦d«´ô?p1®Ë»5p%pz,{‡ BÊp”D+2CÐÉÚj víT¤b²ŠÙl‰ÐP„<ÒSÓ Ž`rѰ…ŸRû‘8uØ ä5¤ç â‘ÎGãäµ{uð%é%\¹yÌ×–KRÄn±’“±ëܯ(É~`…˜ˆØ`-SCS€õ~å¢#·AKÄûé’ Íñ@rǘдØ^“Š×ZTL ”¤^îÎJ~jO0þhSkµÞtšäˆèÇFGº¹·CV ë=˜_ ¤'†ì–u(Ïœ~*•7Hç;Œ_é‚+ýQW§_„)pèm“åa×ük{é.øÓ¹ý&Å÷O_XÇ›øKWÇÃAÇ»tŽÎþáù?Ï$I‚Â$’ˆ\Bl@>xÐcÛô½,Â~á=[2 ¯ð`e5’ð<ôŒ}X‡Ê€4·Üòªþ0¸}|8õ°$¼„–´Å4¢uñá8ZÄí?|<Œá;ÃË¢÷ý:n?l‡/û33xÜ×Ü6ZÂKX߇uvD3Ÿ'à ñ«Nê¾WÐ¤ì “>ü¤²¦Â#Š›{TVüRã­{—þ;Æc´½HS¢ªÃàøœ–þ<9øíà_¢NúCendstream endobj 4836 0 obj<>/XObject<<>>>>/Annots 1600 0 R>>endobj 4837 0 obj<>stream x¥WÛnÛF}×WÌCÉD‹ºYvMÒ¤A6­…ö¡.Œ¹´˜\†Éj‘ï™Ù¥îq ÔËË™3£Ï-Ÿúøõi8á¿ mõ½>Þð‡Ï¿½kù“7¦ÁkJÉ¿ô½K·J覵»Ni0ìodyw„õ”ƒ 9;šlW²»³Nit9ñ|'Ë»0‚þXN/¼[ðÖÎç.øJ¥ÛeJã‰w±³·³LérÊ×mνšíø.(îéümŸ¦Þf ú4ï“ÉÍB‰PŸfA‡~¾œÍ>¶úÔó±nv÷ß~yÎBçoGÄRõ »7:ÝÙ".)0¡&†%)²ÒȈHwîîʪ¸»Û×Ñ¡TW ReÈÔ‰*KŠLAyaÂ:ˆ³{hÂA~(t^èRg•ªb“‘‰¨Zh2ó:¨Èûp'ïš^?{Fí hSnO]À`¢Jg”ijI° ì¦:C`©ŠXÍ]v]¢JÒUàÑì8ÚOJDlÔÖˆ•¹b•lôP¹äÎ5Ò¦ÃÆ›ö….ô—®M Œ2 ãL¶Wê•æ À;7KM¡NMØ©J%ŒlƤu€!qèƒG?›JCRY,Ùýrψ6DøÏ„c¾>„ÔI'Óº¬åõ<‰w-Š‹Ò¶Ú`[Tq S“5ÝëL³Õ!! EpŸ˜9¢ÕY U€Rih' e¦¢…Zê=3U¶vŽryd&ëí_nÃ#XqW‡i—À$W©°BÀaK±dTð¥;»6­–xªÉÞn²Ýy)-. É**Þˆ*Ûé°ã‘-$÷r„¬6Dà rW%Í’/oº\ìúaßYèÏu\èÐ:& VÛ X[•„½Ð™Œs" c¡¾½¨IÝUãïIrâê ¢Wlß?j¡ ¢e\T5ãÝÄ¡«˜ÛsÊùH˜Èó6Ár öÙœ (pÞ>áXšßð3é.â%âxuʸƒ#.‡ÔœùŸžHaô®9(WWÂaÏéüœÔ'δ‘=%sD"§Í’ýKZ>wðH×VâHÇ·b+‘ÞÂ÷¨Qj°Iƒ¨CCqŒÛ…ÊU ›¡^רç&¸óÄŸ®èI¦RÝ…WëÔ=¾ ÷ê Á^T'‰<6ŽHõ<ÉqQV±(Š $·vж<,C…|Èh…ñ¢ss@½–ç6#X3†€£ÑÔ¸U£™/ãTš8g Sðïh…Vm;90ŒÃ÷έá+|¢xq5˜ÜFQß¹‰¡d—“-á>l:eZà–Àq¦×GÒvg{ç6ðÍïßùžïÑMŒ>¸¯dCì(³ôêzWB“¸¬X¸ë÷û8ðà$£4vÿ¥Am¡l0±Kéc ´˜‹ õÇ󄸩Šû:E¢Ànx˜ÐÔbtI,–už›1à-ËF;*·¬š„›J.á†'ì`ð£Yñ´×•ŠÆ¥ímÑÒ¾no‰ô” ê‚Iƒ”›T6vðÄÆà¥ÛNûÅËF?Àk|í¨ï·g’FÂÊÿ=O_ üÁ75nz¿üdÑ6uÕçOGÞx8¦ÉtìM|ùšÁ¦ö0ÖÓHœ…nùº‘•î]Øo{Ç8û>cWæ†é˜ý0kýÚú” ‰nendstream endobj 4838 0 obj<>/XObject<<>>>>>>endobj 4839 0 obj<>stream xÅWMÛ6½ï¯˜KQ9kký‘uÜd›i›"hÑ €V9p%Zf"“*IÙkéoïJ²+¤è©I6°¥áÌ›73o¸^MhŒ¿šÍù_¶¾z•\ã1îÿ³ݼÓ"žQ²¤é˜æßLâùü%y°S’E£rz6JåüÒ~8}r;~IOÓÁ êÿ¹¹¡·?’WcMp(¦×Æ’ÒÎ É!eF;•ý_)×0e2“ËçÏÕ£é4žÍ@|ÞE€7Oo´—…´/:—ƤÑFfÞX.S6¤ö{{ Ïv¨Iêgot€H™p€Ýájs=r×w1¿òQd¾c ÞɆá.xb G^bâ²m­¨*е‹G B¢éàèjS–$²LV¨/ê$-[pŸš7Â*¡}Ü>œ>efßytƒÒESØw¼ùi4‰gñ³!9µ®JIß__:Å÷’r™• ¯PKð£I”ÎÐC6iï1 +3!+¡sGue˜ZIRØR¡ ÑÖRûà=¦W‰#¢rYí#ä¾!¡w´¬-'7d_0üCK¹e ]4«¥Ì¹i?j³%ñÀݽÏ"0 Kt¨²ÎqÓ+{dõÓ6˜¡C—+há0|d–dk­Åˆ2Ðz#næP³íJe«ÀG`J»%ØÈ˜FÜ8TÛ†l‡hð cÃÀ˜`‹#] Ã0]Ž…ÚÈ&Ò ml“Tq³uÛo§Ò«Æ2d\Ä—ZýLƒ$ëb3ûÖŠÝ]njðqÜÔC’>‹ÓZDB r°®phžWƒµÿ2- ;ãïôQ¸gðRÐy%,8|«%¥QC1Ý1ÜÀç㆞ûÆüúú=„çÓèD§)ž>áB”R~•FZék«/¶À©ÏóÝÖXÙ'ú^Ÿ©nßéçÝÅKÓ«)ïd¹ä uÙOü?Ö«N éÜhÄK¯Ù—8Y@é±.”Ç^ÌløcŽ ¢¿öÍ:Za%a55¢Å«ë$¬rUv}vv­9-lž0¹¼tØæ ¿QÒ|?èÀUÖl €yÝ¿ÅöÚâ‡ðíj· ;K«dÉÌI77¸nW0¦ËµÁJÞìxì\\ ô…Q²Z6º‘+‹ÝˆåWªý=ËY‹¾²’µ4Ìx˜¨A¡pÃë.׸ÿ¬’èDø°:VƒfĬ¹'~ê½½¨hÜÛÿ‡¦µÝºh×ídñ4¾ÝÒ|»rs?·®Y<¦LVï/Qœî¶õè/ë<šÇ“%­¾‡{øíd/øMos>ôcrõÛÕßünä”endstream endobj 4840 0 obj<>/XObject<<>>>>>>endobj 4841 0 obj<>stream xWQoÛ6~ϯ¸—NËv’¦^Ûe@·f+¶a*`/~¡%Êf+“.IÅõŠî·ï;’’%7ÍÒ%i£P$ïî»ûî>8™Ñß3º¸âŸbsò*?™fS,vÿÙMn¦4Ï.(¯è|JWßͲ««g”—a×”òbDøúç7åüb´8}qš¿;™Òx†WexukTIb»•º\Œ”öd–ïîÚǯj©W~}÷=ü~%a„ôñ ŸƒáÉÍ%±åŠÆpv|~‘œåkIìG7ŒY©ÅFÆÕö؈JeeáÕ­$åHKYÊ’¼¡¯xÜâåf[ /©¨…s$4ÇfÍÖ*^T¥Ô^UJZâËIéxHX¸NµÐ«F¬$-Fã»´smgšº$m<Á³ÒêoI?>yr°ìöÚ‹$`nE x£/lqqšk%î7U°^˜2DÃî;ö 'wká)ZâÜË®ŠÚبÓÝ¥¬”V^¥Mç—ìì[¥ I¡l•·B;ì –P޳æÈ &6AëÆÚýYp,bÈH‹m\¿+'ð^Jj\ÌJae@];/€»`ÿ`ª:Ф½7Æ’Ñ[ ‡½*D]Ó‡zzp Éß#·6ÖÇÊǸKwÈPD\ã…(<tÈïNãžµÙé„ã,$],Í­Ìèi‘üsyÂqØ“îyëâˆãóóìâ´,G“Çô¦§©’;”qUá.PåVZNI€ePÀ'­«Z”ßO‰½ᮇ¼îí-M³¬e{\‰'î%$HÑlØEð«°%çÁ™Åi|w($‚ K%®:¸úîf]$F8µ7 kc€^wt+Œ®jUø–ÈFå×`ùž lZ*%¸fS¡%;ÀGÚJ€•ª%íø„Ñœ¾Bn¹$c•Àmóù¯Œ þ·!Æ@€ÁFøbW`&—0ùýí§¸Ó³ŸÑ nJ5r‰ôògûÉú2·YÖ2<öðäÅ¡o¸â7þÉ„þøu˜ £Öûö¯7?óVÔ}Tj ø€’å¾c]€£j4z.2×bâ@q¥WÌ4µQ@oеVäÁaù›ã›[4CÍ·æ^Æš_SŽ,|\Œrgx^.Néz©o,·®kZÒøýœ–/èsº ƒ†I8¡ßÅûÄÛ¯‘ÐF:p£—X¼0‹‡û‰‡ ‘iióƒh÷†çÜ(„“_t¾h{˜Ìj¿ j瘮Q±ø uÙ+-܈P-Éþ¾fã«£r'ßz‡qžL§Ïx%]Ѿ·ã?4]ÖkϽ¹ÏÍ#ôÐ g:ÕEƒ9Šn 5Â%%<œp…Ù¢‘ä B fjöu}hQ8)­5ö2ÚC ðÞßh{{y#ö]~мO)y= C-Šª§Ü§ZÒ܃:Ø¢`=[ˆ œ@S~vàÄ´#jÝÄv&iZˆ¥X†â‘'7€É±ì ceêö›¥©ðz©@í˜Íè•tÌÅî z‰×û˜6Y¡[¨¤ ŒÆrH9n½³“ ÃØÒ¦ÙØ=ÕʲAæÙÓ­ñ¬ÌÆïÀ© Õ–µ~Ø~¢²å³LK„ã½×fçòïGm•訪{cû–Q)ˆÂ3(|- 霰ˆºkŽò+ú š u¤AAQ¤ÞÁÚ‚[’üÐ(|>@ܱ‚ãý?RÀȳáªÀçƒÿ¡úm$B0OŸ­fóËìéÅSºšC°F‘Ê*`|‘Mé'SÑ$C£Š»ÇÏ¢à¸Êfó®Ú?ŸÎfÙ|Ž«´óg|èu~òçÉ¿÷ÏŸ~endstream endobj 4842 0 obj<>/XObject<<>>>>>>endobj 4843 0 obj<>stream x•WïoÛ6ýž¿â€¢¨;ØŠ¤®—Z¬´]·jË-Ñ–V‰tI)®1ìß;’’-%ñ6$péx¼{wïÝùëÙ„Æø™ÐlοIyö6>GcMqê¬Æ'ƒj¿•©\S®*ºU•ÜHóÃËøÏ³1&0HQuþ¿×yJk­—ƒ{™TÚ\…S×ôÝ·åKwöüæ‚øðšF¸u4…[·Šª,·”+‡Än9@oÚwçß6Ž„cò›Hªb’¬(%qð$ìžÒuÏKDoÔžj+I¯û§~ï¦Ó;É÷—b °ø£3etV"ùB•v!åÊVBU¹¨r­¹ àõHX”)*™’¦È¥‰(Τ‘kmS^ñÝJW¤d"­h¬¹ àÕŽ’BX‹Ò cãshnƒëg¸¤:W²pnÉÈ´V)ò!¡RÚåEA6/·€ßH[JQ¢SI«B‹jù²é’éãr—I…°*‰ÈŒœ¢|S7¾ÁóƼ0PH«ôÀŠ•®+¤(ª1|[qôV{ú|wû“ 5œ…•;F’ƒE×°ß…­Ñ#ʈn€Z ‘2ÚkÚëšvF#j—_‘A§¡m‡M¸F¦Óh6¿ò¤Mf9@Åßçÿ¹â8Í1_ÉߊÊ>A—´­WEžÎÓ_M.ޤDÔçéß§©4”Gë‹Ò;ëñl Œl£õÏ\Üs¢@Ϧ{ åXÁ4¡ ‰(  ßóPèûâîÆµ‘ˆBS†ÎECírp*éV.ÑÆ€¬Å>¢Ûõ@6¶Öø0îøÙ’qƒ¡58=´¢kš^DOå7ô-À-¿‘èÚ £Ø]ÉôÛ@|ò2/xÆÄÏíeã÷ÑÆ­e—ÓKº ®.Æ“ˆ>†0côµÑÄF×/åFA ÒÈAÊ ìŠ~Âñ±_I—x³tôãØ}àbÛ¯þ–§5|}Ìkm(ÄÇèôó¥hØì»Âƒª$Á”¤²5˜éˆ¼Â@ðfháøÚªxí”R4hÎ`·$v÷KÛ!ñér4Q]ùÐãëд7Z÷Hõ8£p5†ÿ”£·hŒ–°ðz…+ºlýÇçç˜ÄmúÔÁfèA‹£-œ\ákÊÌ‘eª!(ò`ìÿoeÉgˆ@>êݱp75hju"À€@ðù_9òdÆLwƒ~ps¥Üjô„RxQƒü³¦±†4HòPVØœÊ@ü·Ò`˜Y¼ÞÓVn(Ã&Éöar„¡hRvãß‹Ÿñƒb9`-딫iw±ÑÉn37@b~ÒZ½¨hqÛFa±þ8qsÙb*©ÍÐeØ Ãfº.Rˆ•BÔ˜[«;œN°€ÈôÞÓ²{¬žš•„îù9êD³“c+;c®p3·!‚Ò “y—åIÆ$æll½ÝjÅàüª«âˆ>ʽæEG 7ù„¨+ÍSŸ W¢)%^†Å¢Ùwpp[¾*$Tƒ&)™ R£j>¥Jó£v”·"ö^ k¸®Y] Ȇ°Àâe ?ÞZrqe;ÀêTeÈÊõÞÿЩž `È+{åé1 ,ñ€§¾o0‡‘nSi?"Ú –ñQ§×„[¿eدú3DPRaNóõ;ÔØí €}ôŠ×Q€Æ»U™o2Øjes¦ð#ž‡«ðMWŠÄh‡S§Åð;­íÏ}WRüîç÷oâwÜýúæÓr°Å*R á ß¾zz3zöŒå3ˆhL­&>@ô`¯ö}­.UŠ(}“,ÂwŸÉâ"z5{EóżY'™€£Y4†*$u pÝòËÇ0~¼õèµiM7„`“W“I´Xàû!ÆÔbÁOÞÅg¿œýßÜcãendstream endobj 4844 0 obj<>/XObject<<>>>>>>endobj 4845 0 obj<>stream xåWÛnÛF}÷WÌKPÚ‘h]lYu ij·ÒÂmäE@±&—Ò:$—å®$«Aúí=³»T¬‹£}¬Ø0w8—3gÎŽþ<èSÿú4ñÿ´<ø!9èÅ=<\ÿh¦t|Ý£q<¤$§AFã~<Q’9«%i”\ýrûþmrõÇÇßßÞN"UÙáÇäð0¹?èQ·«lÛ*Óó»BvÈÿ~ÞöƒmT5íP: =o{+Tãío8c³óóÏ.Lp‚Ì.·\ÄqÌ©_ŸçšS•vÃPiô«¶’ìLÒÜHÒ9 ZˆF›R¤¦\7îÔ®jIIL79þT†–ÂTßY~)ë8ƒT—¥4ÞZ–u!¬ÌȽžÂX’g’–z^dTiÛ9` ï$ÕÚø\Úœê‰C~øxóÙàšJ È*eJ_Þ(”ui6KŽÈÌëZ7–L-S% õ—°JW1]£µ9·,t÷NûÔîÇÇC” ¿´Ð‘Ûsˆ º(DyˆýÁž-é"A©Éàq”š 6ä’Â(oN0ÇzòvpMä ÃäÌ2*,Dn¾¿ø!¼ ˜ç[´N"rù"Ûµ×ÍD}L¾&°{AÞ¼±F˜u¡ïA62™Í¡×¸p ©NzxsËuQè%ÇØrs;¶6Ý|¢{Hi»ÔÈ•_ÄÚÞ¹Ëk©@{Aï^¿Æ¥UÖªø·¼´œùŠ à8Oäåúá±A«ÛY¹LÑ(&/G—Áñu霭½µ-|q–Ç×ã°möÇ'ñéð”Fgøá÷@f_w÷èG:±wôâıy{ëî™ÿÚ0ŠûcJÂBëvÖÓ~?ñÍ åø{~é*9øíàÖÔˆendstream endobj 4846 0 obj<>/XObject<<>>>>>>endobj 4847 0 obj<>stream xÕVMo7½ëWÌ%°Hk}ØŠâZ´nshƒ  äâ µItvÉ-É•,ýï}\.e¯c5ANŽlHKîp8oÞÌ?ƒ)Mð7¥ù"üÕà—|0É&Ø<~Ù __ÐtBù²‹×xí{<Ã?¹Z±¥u£ ¯Œ&ÏU] ÏŽ„erM]ëYf”o™-Ù–¥7T[¥ U—LÊ‘Ç;'*&áhm,ic+QÞëÿþøîw*„>óTX†~/óÛÁ„ÆÓìî­¨kØÑè’£ƒipƒÙ)ÉT¢4ôV¢5Q¬LãÉjv]ã:¾0šG$¨(Žï•ßbQEß’KT©ÍÖSiÌ'*Õ'†ÙÊ]3ί'´Ìæ!B3˜4›eó9VrÕ]CŸ“¹!|úY•ªhÏÚ= Ÿt×›x2K;£$­„½æt7¢œ7/é3eYFÿþÔSÚ*À~o3ÊÜgpÜ8Ï‹WÁÜÀûZhÙæ Ý>"§‘5Ž)90|‘„â~BÆ!v!Ü!—­ñ­Ï82m¸ŽÞÜ c¥=‚‹žß`ñö‰÷OHƒL2…qñèÐWðÞŽH­[Àî…, •,v1ŽÆªÒ¨„ˆÉk¥UÄpi4{Û8OÒü@H<Âý1P_ðgàðËby‰OÄ¢Hõð¬ þ‰0£ðQð}ø* ¿ºzð}aùPø!ÖO²Ë;ôp$ˆÛ¬Rð™Ä¤?¦©,£  pXOšY²A Uœâ#iЄ@í…‘;Ì­Y¡à2ÎðíIH‰î³7¸`º÷[Ö&\"ض–p4€òžÔðjv‚ù—ñ|E+.D J³n¯Ù‹p@)÷Zá¶—Á‡§ÂDO¢ •.J(GgE«6Ê.ºÎ<$±öÜmÞ“r¸ìmDûîuVæYq× Ð°;¡äè>Ñ”%/ì†Ñ…Þ4bslòŽÌÝ݉þ>j ›xÇ@=DsOôÉ>ÐâìK>-ûM˜ r˜="æÜÇùA1°MÜŽ%:Ì&g¨‘³6} e¢•>/XObject<<>>>>>>endobj 4849 0 obj<>stream xÅWÁnÛ8½û+æÒ@lÅ’ÇmƒÙ¶)zØÃ"*zñ…)› ‰ÔJTc£è¿ï Eª’ìnS´À&AlSCòqæ½7ô?“øÁrEi1ù#™,Âvÿª\>,`.!É ^Àêe®V7pµ€$ Œ(Êœq›æ¬®!¹ƒö̓Öðešü=YÀ<ÂH”Í6—é«ÁÐÏå%ÜC!Š­¨À/w埸ï -«6Á#fðÇ;@†ðõõél v1x,ĆÞJ¦80ÈÄÓM=˜ûBŒÀÐÓ#¼ð07‚“ˆ _n¥2wcPÃHî"¹Æ,‰QðW·}‡õM%0åPëBÀSÅÊRT5dÓ·çSØÛ a.|9ƒkG¨(®êòá ¨ ÌÏ<^:JÊŠ¥M®›:?Îà¨x’y™ÄT™=3 XºAi®¥V 3 sÅÚõܪñ;°gµ/FÖ¨ÔàÄz<Í&:ØLÇs©œ£0”oÎ…r.¸gH|E”¸‡TâljAXG­AÖ`4p«jS5©Ñ®©.¥¨0à³ÏX ‚b:+ÌCÑ+…¡Âæq.—¨7~"¬h攕ÄwÐî%“ÕHe¨§$¤Wµ3’jhøÉZˆò¯Ú©› ‰èóf:sSp$nGPež­°qËv¾MmŠtb¸ evëúK¶š=YÍkÈIýcwôxôþVôþÓø®lËÝyËs~¾a mÞa›¦MpÝ;ò–!ÎÖA¾«†düàͰbÄZ¢ Ê4©ÉÀÒT”†¡Ô‰CŸ>¼ŸÁ¶1V¿6q-•:-·RÚ ;¥+Á¡Q¹@»%•¡¢ÐW%-kÅÅAš+%ÊELlâÚj°Õeª›œûàÖðÛþÖ1¸/׈}bž†.¡Û†nx’gœ£FJ}ÎæäM×çúÇ9“–ïšæ=vK™‘’ð*ê03µkØ/;MYêÊÔ ‘z¹fE;#‰©Ny¦:Z– Æÿ»·âáÿrøìý¦jøå~µkwÿŠÖWáõòV7Ý%„:Ó|.à­N›B(c̓JŠjl£ç7í-`FkHÜ·{a¾Ž¢p½ÆoØ^F4é]2ùkò/ÜÚŽendstream endobj 4850 0 obj<>/XObject<<>>>>>>endobj 4851 0 obj<>stream xVÛnã6}÷WL ¢‰|K¼Þ4Тën€ö¡¨€}1`0ÒØf+“ IÙ1Ûoï iI±­lÝ"@Kùž93Ï>ôè¯Ãÿ§«ÎOI§÷èeý0 èNn ßƒdN²£tÈüw:¤Ñ£·”RañŠŽÎE™;*ƒT«5+µâ£u¦L6–b^ØŠ‚¢G ŸP¥¤âÏ¿ÀFæ9hºšk‘±àÊ«#ÕR!¡Tò¹Ä‹äÏN®ûr)ZK+Ÿr|mˆ.hˤ-„K—Þlat†œ&3¨2©@^rÂ,Ê*n[`¼³1¸asà+zN‚´´êÜÁs)*].–ÞÍ­.Á na#X†•ø Áêj…ç?RXøRä:«BΤÁÔÉ5Z°%¹),°éî„êãsäL…·UE¢«}©:gøâ(®Ciïàþ•èŒ]‰â@–Ò£à Aª4/3Ì ¸HQIJ®Š\Pܾ&ÒQ‰m m(,AŸð®22އ y6ÄÃ!ýÊ¢n&’Šu¹´.^²0»ÎàŠ*Ý÷i.¬…äÂáW…/{¢ÇUÂí¢|ÊeêÍ×I vé›F³Ù•l5›M/€ÎÓH*7½øáP3°Aÿ‘ê÷Ò&ðwhûtè»ÔÖ(…¶ªÜÕí8NVéR¸œÍ¨•Èûˆü?ʇ—ãG÷~cØ iÆ·Á %d .\v®î¶9Ïß¾ÝØóÕç°á‹k_õa<½÷í³#‹D_Nmÿª„Aà. Q€fËÝɨj@b‡mxY÷BƒJIdC­'}¤>v=ì¨o©­†BÛÀÔ¡ aÐD–aM˜£ßŒk˜½òÔP!3ò?àý ð1|îî‚ûØ«0Ðø“Að?ÐVüý23å©.¶m`J¨üñ[H5èJ£@áÆwÛ}ò0.¿·˜ÏÛšj߀6æO‡~WÅ:FŽx„ƒ|‹Kª¶‡/P;؇oÒæ‡ÎþKç|^¢:š­ Ïà&ðê’88k´!ë+¾r\ˆœ'TI çéç'r•:àžX¡£Î‰r-yð Y¯´¢?„1$¾‘¸‘‰xr‘Ò½ ‡Á7kä-ÍAÚ0‹– ‘e~˜nýÝLÀöˆkÚ¨&Å”ÁÊj…"ßs”‚ZêÌz)°¦r.SŠë5mœ>ÎΪxü´ðè¸x¦ÉòP5w€éëæ¾çÏ-¾Ö2ƒ§\,¿Iñ±º›O£wŸp{ç¼$5V¿›NÕ»S›èMÊöëq­¢­¤(´q¶ÞË8Ç»-€€V*Ú^üð£%0•Œ**ôa«á}ÃÜM Uý6F­6öJyòÒQÙnÁçy®õ4J€¦qÝÎÝÉx7húã›øvx £1í1awá”\ãü¬S¿(ú)Á.éë÷ Fq É.I–Enûýx<¦Ešöœ~ó1éüÞùÁeU½endstream endobj 4852 0 obj<>/XObject<<>>>>/Annots 1602 0 R>>endobj 4853 0 obj<>stream x½WmoãDþÞ_1!R.qã¦í¥å8‰»£Ç}à$h$¾äËÆž$Km¯Ù]' 'þ;ÏìÚÎK‘Ð A[¥Ž=;¯Ï<3þý,¥1~SšÜÈ_Vž“1îÈG*¿¼?KÇÓdB—W·ÉK*)\'×í·‚Î¿ãéÍu2=xúfv 0hµ+º¸“¨œ-érL7·irsó’fy0;¦Y6ð\Ö…òü*+”s4{M£sZ3ÌèiH3ÚÍÏéýùíùì·³1 h–¾êÎ"{.'^éÊ¿b÷W”BnÄG—“Öî`¶Ö޶º(hÅ[&¿5d6l £rÎikU]³¥’ýÚänH~Í´ÔÖùxΫG&ENW«‚ yiåHU¤ìª)¹ò¸ÎÃ9Ç™Áe0(ÛÒK A ÷çÛ“.颼‘ÌyÁÈ‹7äÔnH¿~xÿ5¾¶Y#×Ôµ±žjk6:gGuû;2K2áISi¯q –Õcp 7°ã„fkå¡YçCñ_—¢L!€¥®Tqämmà+!{GäÉÅýu›ãAp‹r;•3l—Æ–ÄOž+SÄÖKÙš³GäM¼ë"p_D]]½ «æL/u¦Š¢ ø¹f¿«sÙ«®`'8¢}´RǨl¢’*ó*eoÞWp»s‡r m**C©«9„d=è*ƒ(Äß¾xe­ Ô^ª{”ªµ©yÙÀý΃º5#Áp*“<2YvMá%%ì–P0gᲤ¥…Ï’H+·Û˜pÔ4oêÏÆ0räŲ©pΠŽ€˜ì!C謸‹[ð„˜7\Àg Ãl +´Á(qešÕZr¸Xà?0Rp¹X$«Wk•Ûùy€îÒªÄo1ºÐÁ‘ƇÒí[tpv=Ö«%8@JuË…F£®Ym4r •Y¸Õ pÃw]…ìÖ–ÑúÇØ®¯bëÍÚþq´V€ç‚Q›Ò v/á@ièK¡‡\.MT§Ð2huémàÜÎ6bL²8J“Ií]ëo+Y˜ \qT¤ÆqžÐ[“KÑŠmlˆa^à±då %„Ö5ÿ>à@0ÀJ´@[cúÑlQXIƒPN°šÊl#ö¾£2mRŸè»Pš»»P¼8ž ,Õ oMÎó”òî®Kõ7Ùé‰ãçYÈõÅý´öéô*¹ž\ÓÍ/qi«aÝš$czg²ð¾HWÀa¥G/c®ÿ†d¯ÓTˆ5çv"§~˜ý|öÝîÐ×endstream endobj 4854 0 obj<>/XObject<<>>>>>>endobj 4855 0 obj<>stream x•VÉrã6½ë+:‡T8‰ÖbklMå`ibLJIUÊJåâ D6Ed@‚@Kª©ù÷þ>Þtö^96y“}ƒN4›ÔJ dÇÛ~=ø  ozñy>ÿqG`܉훾üåS ñÊÖÒ{¤ó*fˆ¡eJX¸Ò°t„B,´µÒ ¥´5Ò1¥,â!r[é¸>ñüÁ(½¿§¯ÐEJX‹ÊÒ+ߺQüÖlDãèTèâbãIò-/‘ýUÍXÝwo‚E{™/Ò8À·GYpBËùÜcÅÿÒïnlw]@|z\ ì‹Öú|ýÓ%Êâ« ¿s@ÕÜ-„¡9¨y€]žØ‚«]:[c©Oz.Dv<êÓ|îþÚ ØÙ¾W-câW©^‚ûš™¾Ð f꯫ï oýß:NQ?tn€_ÍOmØîDË¢–xê'M™ŸiÊô )èÍuŸ¯“Y*éö” ‡Û2J©`}°(Ÿó¿XJ…‰}ºK4N™#á!^[ö´|ÿRoŒÈ2F&7©ƒlä®>)Ò(…­¾sBZpjªõ©Òˆ’×#%òMYÉÖR±ï UDEb?’ —Z<1Œo2IØ —Ö1f{¢tØÐk]ªQ·Uà° %+"èe]´e§ÀÐK ”»œãéUeþÔ,N®}²?ÿýôHI©€Î–…—2[p(b\–ƒ1ÿVõFUTÐ:†Þåq“—)>ª¶U„ô”Tœ0Hªîðâ!Öê ðAè€ÜJ¥¼ô ½ÂÆè­Wt¨jqÃ9Ö„–V4ºR‡Á4Gz0­5—®¤­6_<.AíœÿÔ†2Ø(®ô÷0 œŒU˜D©À‡Ûo]s*^%’ @äL*Ãcs©Øò®^äÀÊ< ´a—"VÞ¨#¦Ju9 €Љðâ42Ë1ÍLƒ|o»×dd¸QGâØÕ«Âìw'ÚüsM*J·8ÏZ3VÎÚ*»jka^äϹT·ëþ²—à|µjaW·Íì4¾½o¦74Ã{3ùÄNÃ}ÒQ™¡~*óð0ÄÔÖÃuœ…ã»ãd½ÍÍxÞÞbàEÜ]û'¿­zöþe>]endstream endobj 4856 0 obj<>/XObject<<>>>>>>endobj 4857 0 obj<>stream x½WÛnÛF}÷WÌK±h]lÅQŠq›¤yéÅŠJ[“\vwiYúï=³KR¦|AûRĈei¹sæÌ™3£¿N¦4Á¿)Íò“–'W«“I2Á›ývCg't™Ìi•ÓlB‹Ëi²X¼¦UNMh•Ž*U²«UÊ´V–¾½\ýy2¡ñŸe#"º5:£u¡¶×£ë—oŸþ-}<'9œÓÆóy`ä·\Ñ—¯Ÿ?‘Óe]ì)µ¬<;ò[ËL;«êš-åM•zm*Gñ6¤n„ÆôòÑsªÊŽÏviÝIº(&¯ì†=ªÚ4jÃIDŸ`®Œ—‡„˜™S[®ä±@ í´ß’Š6q$×wxÒ’²¸'¹âÄ BdZU{ºÑ¸ÌäT±óx×¥¦æ¤8;—ˆ«-ãíÈ™’É*áL¸÷{…ç7Áª5*ݽ®PÔ_½:€ÂǸÄä¥iyC`VL¥Éš™9¼1ž$^)ßXUPj¬å"  5ûãFI±Ð7,µ6bx'9©Èc €l#kýúˆ„tå¼úSÒžv¦)2© °4å@Ã< å\nüVy «Ê+õfë©T7Œ÷× ô1ñ :ÐØæ¨dP7ä,¡Ï’¨M• ˆ "º5JÂYSeªò¥Óß²ÝãaT' åÎ2‹w¨‹œ±ì¤g„Æ–,í`°@¢ÙÐí-J¤ð3Àг÷¤’µT7`,¢®´S{P›ÓÞ4x È¡Oû†¹>À‚ØZ²N»&–¶%!é !KÀ&³k»_C 6‡¿ õ|Å©‚ïmæÐÊÂY(=H¯sZ ,Bwûrm ×j6tO¦óJE= °C\Ê{R™:õ-Eø_4Èw ¶ÅK99tÑñl–ÌçðÔìžy¾Â:sc®GààQóì¶ÇNWÏÝ“™TÈe ½/ķʦðZæ@4œP<‘zW(ØÂÐÛ&èd'Ò½ó„~³|«M#‚H éjéfXN 7˜NVV ëLq+y]H½W¹³«{;޾ƒÆ0)‡—Ž‚j§ÊµÆÌ€©HF÷À¸ègÿJKm„ëÑÕ"š—tµ\âÅpæ&Ƀpþ_b3 :;£OŒ^Ô„i° I½´Ûuø¢KÊð£cÂõ³óá)t ·í¦W<4¤|x€Ä Ú8Øðqýî׊2ÆÌVA2•ÖÇ€¦†Bív—ÔdØV[Þ‡¹±`[ÚG?í‰~¶¶³oßñV‰6(Ôˆw’ÈñæŸÍNHÆPä}¬1E·,IüãÔEÀ"؃ c_ ¿¯6Š-£íz‹E$¼9J Ù`øn@ Àj\ô¡už÷„gõ)`à‚CÖó†íPíA;½’B6Oæì¶½‹îZ§|ÒÃØ»©ÌNì [C¤°_AÛ{މ…]§èzÈäÁÞú~¹|â¹ÝVc¹xþi]…Eó€xÔõ{ñ/ݶCU{é„ÔÀ|00ズÖ¡ ãù,ëd*fnÑ]‚ø(½ïºÃÇ fÚB÷]pÔm|W‹†uOB“²=frƒÔ)(Z4LÌåÿà…Ù  'bÿ{‘¦Õ;Z’»ëÑŠÔ)^¯á ß`MØWÏ;ZÓø½¤õ[j=é²mŸéåyr1¿À×£ón°‹2ÆódB?™KeåÃl‘4ñ5'ž¿Ž#i‘LßС.ræb:M./ñõ +› yçÃêä÷“qî5¿endstream endobj 4858 0 obj<>/XObject<<>>>>>>endobj 4859 0 obj<>stream xµWMoÛ8½çWÌ%X±;NÜ$íî¡Ý¤í¥Å¢ö’ -Q¶‰TI*ŽPô¿ïR’-;i± ¬$ú 9ofÞ¼;šÒ?SšÍù7)Þ.Ž&ñû?fEgwºŠg´Èè|Bóëi<Ÿ¿¢EêWMh‘D?N_&4ÆëEÕ6W+Ê´¾¹)ÅÓëÁ»c'˪NÞGx—+wBD¸|ƒë?^ãºûœÑçÑÄíö©?z¸=+´à:SoüƒpJ»î£oµ(ò,—))QÊû“îÄ–ŸÙJ$’–ÂÐ÷5†œÙ®‚­Î£‰ a¥º^0ü wP‚p€ÞÙÝñmæƒ8>Ÿµ1ŽkI‰.—¹.׊tæÝð- •’vkièËßßSš™¸üQZ„´!„Ôè´†o¶^ºÿ]ɱ‘œ€”*£³´1±‘Ù[sæœÆ¬°½‹Æ9§µÌa,·X$‰¢&WRIãÛQUÒ”‘|6Æ… ’:»›·.F´*ôRáiçx´u,¦/M¹Ô…¥Ìè²õ°ÏA° Šhì¡Hi-Œ¶ ¬‹¢¡aúíx<öy”J>"tyYiÃA¼4£máQàE­ œêŸc4“e;*<Õ”j²š6¹[“¡¤|*QS:gßÛT&…@èÕ˜>*„´Ô6D6VÚQ°H¿ÖÖÁRƒLVŸtÛÆö—’²¡§1}ÐvmÔÈ~•vªä~Rb»«R*±u/öZG ÛR§9Ca륨p%ŸYùwk°¯@ÂG‘F·ŽéN¬¨s9w•ÍSD™ãšé¢Ðpì¦ ÔVWÆççñl•I£>Ó\ÙÏÔ$ƒIeÆùBàœ\IsX“.²ö|QW(Ð<ñ 8GHVqãÇÃêäg?†§ÕîX>9‰Êð"ô¬¹"‰4½º›§QHÅ¡ðÀn·ÖÐïôD§Ôôúu»5F&Ž÷?$Xf¹êjI÷åÞUÈ®“FºÚ(:ŒZçZ«LÞï¥ œõôb¶¶dM´aBÙiuÁBÄy‡ç€UJ·Ö—^)· 甫©#F¨ ÈGµõq¯€vXކƒšìHÛyìK/˜«]ýæØ6ë˦§º§?"%ËÜðxƒ@´mÅ Ú%ºî6œ„ZÁé¢á,¼;= ±ëˆÃ3ê«ý³”yÇÍÐÆrïÛ™¦º¾Nëú{ôbœ ûKsU@œéÅ-!Õ^ÇÑÑ1#‡é‰›'Ñ·D>¶î©Â窳%tž{Û±p“cpãa6$( Y=z ^Ytx„\IG$ÀD¤Q­:¢cf³±hGI†¼±ZõÇÙ0í#ùo“úÞ{Hœ¢ÎºïmÇ}„{ / ô¨ó”ç„ûDãVì¹?ì„<ŒÃ%¡X˜` ¾=Иè¶m1>Eœ>ÅÛX 5ògȇΞÝ]µÊ8½ºˆ/g—4¿štÓ×ÐxOèOÔ<æù‘“c¨aõøUhøóxzMŸºoD^9/§Óøê ßQ4×sÞu»8úëèê–Gendstream endobj 4860 0 obj<>/XObject<<>>>>>>endobj 4861 0 obj<>stream x½VÛnã6}÷WÌKP%ˆå[â\ Øn›"/ 5º/´DÙìR¢"RqŒEþ½gHÉŠådÑEÀ°¨™á\Μ™‡Á„Æø›ÐlÎÿI>øy1Çc5îÆtÏh‘ÑtLó›I<Ÿ_Ñ"õRcZ$ñçѨ”V¢ZFªpËSúFqÓ3ÞŒÎèþ‡ïR:.þŒi8b!vpxò|ðèŸFw—Ä* áÃp:k|ˆ>'oY~twÑHDôy# rIáBôªÑ‰|r²Hû⩪dâÔ£$e©¶2%UX•JTˆ\ÚR$òÜÛÛ?ú,®ŠDשWñkYÈJ8du£¦°1Ý™ª iÊaË'‘—6UF;SÓFàîÄàF­¾JØQö¼u½Ëüp:g3Ô!:?2cè[k¼Íi¢…µ\‹ãWe½Ò*ñ;¬êÔ¤çX‰ËË–VZl|‰éiyúcÿf/ö|tÜ;iJÚ¬WR.œH9§¹t“ö«¥%§£¶Â0ÿØÇÂÝå+£qa‘hnŸ¯é»r[¥5­¼ü‘àÞùžO©|WïC)|˜[±ƒ÷±(•Ñ5Ç€An2SåH*žKQ!)NVKpøÉ‚b™*t}^[¤¹dChäÄi7´1[R6ÜNe¦P²˜~1¸ÜQ²Aµ¸Ã%=ÔB«L%Âûb2ØÞä9ƒÍž°uY+²HIÀùŽf`¦Ž3|ÉÖÿ‚3Žš7° X0?f†ïÑIŸ×=7à«1 Hx1ÑÇ)ÏÈß8ü‰ÅÚœ¶ç5^±ÿ.žY ™ÑÚlU±f0p ¹2™®Jq$ŸJŒ†@)Àë¶R܃P«€['‰´6«u€Ã÷óRI¦íeä ÒÓy{{”¸›h=‚¼÷†©<Œ9|àï-ÀÛÿ ®ϤÝ#"{8ÜÃ5B¡—Q3TÞ ž9óœK%ÑÌ'hkŒQ®Û>‹(\Óxçh» TˆÈh‰Säé(ðD[sßÜØ¸—1 ÆW Mõ®¢îqîéKæÓîd°X>[„Æñu0€Æqóîׄÿ¯å>/XObject<<>>>>/Annots 1604 0 R>>endobj 4863 0 obj<>stream x­WßoÛ6~Ï_qØPÔlÆ?b'ñ°‡®kŠhѵò’Z¢u©’”]cØÿ¾ïHJŽ\·@‹&cIäÝÇ»ïî;}:›Ð¿š-ø/«ÎÆbŒ;ü1á÷¯Î¦Ó…Óbr!TÑt>—骤gÜ>ÚöÙ ßÌi2¦Û5l/®ñ%&ñ%¼5^-ŸÝ~<;¿¹H‹tû h]Jï•.ô†Ì𴬔«e¦ŽŒ.÷Th<ÎUNÞSv«H:’´’®È멨êRUJ{é £½5Z±E^ÚòTJ½iäF1Œ1&S T&oJ¸“VQÖX pZ[³±²ªàvWø’zÿÈ—ÜaµVÎ z­ƒ‡u㫆 jÍVrOÆÿÓÆ³Ým‘+<¶}2ßJÁ]rM]ëEŒÚ51^íhº`à 1¹“CBFk%­á°3ãúAçíâ‚ |0Õ¡qÂä=ãF3àGHð º ‘ìS'ð Mñt:×—À w ]KKˆdH'Ȥ¦]×e3Ï ÈJéÜœ·Mæ‡Ôh$šƒ«tS±ÙQr—2›+l°)ƒ…g8("Ü÷¹³²v‘.ûZ…´cÓ ú«UV¬Á¾Ì eµgšEã!CŽY8fË1õY2;‡Xõ—ÜJÁÿû‹_©ô®TÒ)ЉAÌ[Â<:•1½“‹AQq’à´7 º‚ëÈ*çœ+¥7¸ÏŸ@¸ÀNÛ-×hJ J2WÜ{+ÙÎJ•f‚c4Žk˜a¯M‰û|•ž LWbÆž²õ©˜Íp•ž$ó÷ƒ_"_îŸÑ›ý±e¾\¾'[Èr¹|aJckÏ8õ$!ïVß!‰5<·«éüœÚE@/Qˆ™5ò)·É8ðWWB-ú·çœ™£åK(²–øO…hÃÍ…•?ÿõ‰_õÛž÷„åP-?Óo@qhߣřX,.øÚ¤i| Ã=¿9Ñ+»©òÂ2©·ÜƒWíUqdà º-J7Þm{Ë`h¾3M™·÷>õТƒ¨€òM陌`ýÇÆ¡Z;aè»)£$„\9‹iÆ•b[¨â¢”«26Û5»¶¦ ŽÄæÛÜO"Šåõ’^Zkì’žÿOY+†^Crµ.t¬\>æêKðÈ[Ò>§Næ“wVm ÓpAs— ¢É},9ïŸþDª¿?ÏŒÛïÌqn¿leîËu8:zQŸšb+Ku¯{BŒŸÓº)­O,Ñ ± :ÊÅQGÎdYòq•ÌØ(ÈØ<:?&͆~<ÐßÎ_j<¢­ë¼JM+^ýNZíÚ&r´ô~pÿ¬_î­É¶´“ÉPï”ÉþÒÎä¡ÚŽÈÃ'¤Z Ä“ kóžeh+ÑžQ (_#:)”㉌™›TQ}$’‚nX¹[aD¤™r] $Äí«•)a$`·™©Ïªæ˜ ÇüçiÛPèk<æ¯ìó$“qÄy¶Ê:žÛFpRŸ~’@™˜Ú~ßÏ8÷ü­)rÊ >{è2ÈñH²ðCðS}¦þßÎøGœza*`/VE‰óaúþʸß5h‡Y~]ØOo1ŠóŒ }¸{ýj4Sn0þ†±5ÀWq‚]hÐ{ÖîÉ^pa.éʸKÝÉ)øêŠ…ë¹£ X)¥‰ßÀ•i‡Ú§$<@”•MŠ×h••ÂD‚9”é×]§ÖQ±À úÑUÀíŒ_%î:6ôpÖ¶S$ÝUš¨§ã 1ŸÍiqy)XˆÁ /aš¬éÞlxB.#=¾ç]`>™œ<ÐêúŠÍ½¼=ûûì¯ÞV™endstream endobj 4864 0 obj<>/XObject<<>>>>>>endobj 4865 0 obj<>stream xå—ÛnÛF†ïõsc@F,J”lYV‚uj¾ ÐF@š@7+r)nKíÒÜ¥eÕè»÷ŸåA[Í¡½‹-H3³³óÍ?ºï„4ÀH£1¿¢UçzÖœlߊ%õoÏ)Ð,Á½ã+Äþ:¢n!­ÉJ§Œ&e)—EbŠ•Œç§}øx÷ ¹B gÉÉUž 'cr›\Z²™Z¦.ÛP¬’DRó±Ð1¥Ââ“D+6*2Z ¥J/©(3IÖP©3õ§<ýÑP/"œ®6ºwàâŒÍÈG¹Ê‡§#‘­ÅÆR!ïKUÈ8 »„\*))3„p_ŠL%ŠãÜ‹˜Ÿ¶¹Œüµ3RŽÖ*Ëíƒ$A)#‹½ˆòBF2–:’ddá],¥–…ŠZÓ>@û«ˆ9’´™YŸ€C)-Gh° -V’Øyÿ{é÷©»X,ª3ÍÎu}vÛ…îź³hlÎWÙ¢èÀ~ÐD0 F\*ClÎpŒFøwOªHçØü”>ä"’ÓéO×ï¦S!ļ;#7?}MÏþúý*ѾhQrÞ]JÈrº“c—b·ë ¸*¸H·NqaÏé›ÚÿïŸ>¿­Øžñ‘ñ[môŽã&Þß³è¿å<úEÔ;ÇÙóFyƒ-§«J=¸Œ2a-a%ôô÷ëƒkM ¿aè|¥ÌÞ’uE (ûg¶ˆŒŠi»#°y`òÀÇþå“Æá¼ óˆéhÖ}¤Û¾Âkí GÁx|ÉwçȦ¦Ìb»$ò\p“àñ:áÈÖò<6!=¾Ø¸eøb©k/ Y tðŠåÊh¤Á÷£ÅÆ£–˜ E…gšõú¾âÖ†{siÏhª(õ~%šVäÔƒDË`¦,SˆÎÅÇbà›§ºfœy9kKx£:ŠP°Xº"ú)mUŒg÷¼·[ÿïlµ·©ö¾ ÊöHýwÔ,rޭȃËÿ9$™SW5¸–õŸq ùáú~Á's²Óiše²0øÓäߣ×÷ â{ã .Ì'fG_ãêÌV_b]oYÓFœ6´-Ò‰³lÀãX"ýdÀC@+S»zÌÒ´*­5Í.yF[Y&6×t o ædÍðCãÈ<¿È%7¥éD>:©ãÿÈaeäHç= tÛƒ·ªØTëw‰!QSΕ8˜m<»¤¼  mlÎ>¶ïÌcô>ã×;ù&\Wج÷À÷ŠÂóàœÇ®JI'Á RÒq0 éæ1’¹ÑkV"Áßì>Á¬ÀçÁdÂü1•šÞ½z…IÇ,Á'&N§2õëZm zØcJ_HÌ wk´Âز™¹€tG&Á¼œ”ꉟ ¸·¦&†&c"3«{xßâžZ‚§UÀzqĬ¡›¢ÀOTÍ)ýÛI=‡“óàbtAãKL¡ŸIù÷Io èg•+LÞ;û@«»{—,Hã€~ãЧЦÇ4?fÐ Úöæ“z†œH/"WWlñfÖùµó“Ú Qendstream endobj 4866 0 obj<>/XObject<<>>>>/Annots 1608 0 R>>endobj 4867 0 obj<>stream x­XMoÛF½ûW \U™¦¨[zIb§¹m- _ÖäJbBrUîÒŠ´¿½ofIJ¤åÔ)’(îÎÎÇ›7úëdD!þF4žñÿ8? ƒßðˈ_þ|2šNƒ&s~Íi4ƒI}•ÑíÉáuNQtŒ_Oç²w<‚y}Å{¯sšŒÅ²¬å»‡×¸; ƒ‹ƒ½‡×9MÃîÞhïÑ{àÕ|/ü[>¼Îi<¾¢ƒ»oIL”+:¿ éFKŠBšÍGÁlvA‹DRÒ"Ä™²–nŒ¡¯/ŸNB:áûd°©î³4¾ê|GøÁ£ïLšÐ}¦Öwƒ»—äÖ¥ÙÞ ®ËÒ”w/_?ZÝ·ð·,9¿™Ÿ¼¤3xzkO–¤ Ò_b½q©)Èntœ.ÓXÉUj©²:ÒíÇïIUÎ丫,ÛÑJºTN[Ú–j³Ñ%Å&Ñ´4ø \¼N‹œÕ” ›ÓÉÁ)ª€ÍíZû‘$ÅX›ÞgzH¥–0ÙDê`Á1åT¹ÒŽ2U¬*µÂ:>˺t‡K9 N6ÛFn•ÛÔê•)á–Ê7|jÚuç÷[›bH;S!¢a¦Nû ³ô³†éÔJ»08‹€î1@‘ –ô מëÖ*Õwåîqé—ASãÎZ_’zõãmô!Ç–T]†aX§ŠX“YÒ©ì;e‹OBàv*Í,/_›-q®q-©­ë¹F½²¦ž±ªVkGo_½êôX%¸þ½¢ýl÷ÛÎ¥LM¸‚ö¨\ÇøœÚœƒ3•Ãù€P]QÙÒå$´ãàTPcOÉí6:W›î²¦kduÌðnZ-šp±nSÎÙ€ü–š¬ÉµKs@Þèn 4Œ*‘šl7@ÊL¡)W;*Œ£{X, ÆiÝ”m‚¤ævbo϶- % zå†(m’.—ºÔ…ƒëŽ %mª@[Ü—IZr@ð‹½d·zk [eN@êßãpÎ×uÛömÚ·©[Ó‹Ö“'2è ‚Ì¤fu:¥õ&€Òú {,ɦúÉáÒ¼Ê@'hòoPpXêM¦âv]jeÒ,<¿™Óh‚ñrcj»äÉ`D= 0”¶Þ¾/x÷$¸¼äííNŸÓ.õùú%0±6 H÷tݦyš©ÒŸƒaN>¨R?IÌœµµ,Ø2àih2êbH¹sZÈ~ðâh ZjåªøôŠ3 xÖôËPõ)‡sÅ…Ã+;üÝ™g+Ë¡qß·'-U ¸?s#`nå «rÚ„÷A*¾_·§î4ßMb—kÑ6Aw(z öAHmï´¸¿;”WÖ1‰‚} tIœs›ìËRãˆáh ¡»¢žbÀ‘ðž_¢öÆׄmÖÃ|›fY;Ãqœ¥f¦’gá>·Ü¯r,fñÖT™‡*s¬Ýƒ£ÞÐæ ›´€~3Nw"§$"A!X8«0wøŽ÷ j£kŒN!rN»Ã»Í^ŽÌaëÊ*vtýFYM_é!-]òüG¾àéüš¼LjõY³ƒeĈ®Ú­ßX=oÙøyË&Ç–Aºššž®Eàh(3>")ЇÐWW÷ª”°š„÷÷q"Úµµ²l¤¤?äÇ ×c®°Ô}ZÖ¶I`cßäˆ]V{Œ«,5I¦ÌßjÄò &d«)ú‹ûNšŽ‰ú¯Xí¦N/Y!öÞ‘Ù¨wØ#êó…í­"…a£ÑxW|A+sxß.~@•t7PtÍìÐq  6jõ\w›»}Cõµ ®úzÎKíóvW#ª¼K‹N7ný÷Ñ"ù‘ìªø\˜m­çâ•ÛÇz@)mÓ+ýÖóóWd…sÈ&&Ÿ_ÙPºEzVž[{&09»çIÓse§vmþºTÇ¢|ŸÚãØ ýƒAT¿ë÷IÏÓ€~5[ˆ »è”ÿ‘)uoðŒô‰‡Tv<ñ³†¬›óåSî™r…LGÀ,ÔsÔ£ª¨yº”š¢´ûÜáqÒÇd7³Ìá=èœß\Ö ) 'Át<¥~ψDù±¤>㇂w&®rhnyf“xtö‹Ï.üS<4æè@cvT‘È„iˆß"ÈRÐö( ÙÈõâ䓼ŠCÌendstream endobj 4868 0 obj<>/XObject<<>>>>>>endobj 4869 0 obj<>stream x•V]oÛ6}ϯ¸ÐMicÅ_qݬ3Ð¥ËÖ‡.Ýj / Z¤,6’¨QT£èß¹¤äÄžÛaù´åKÞsÏ=÷Ÿ ¨ï&ü“'¿ÌOúqwìš.n^Ñ`iž"z2½Œ'4—>¦Oó$šÄÃ}0ºtÊÖä ½WÅ /ÏæŸO.nÆ4@¯ì ÇñtŠ¥ÑG'¬Óåš6ÚeôñÓ»ßzƒx¿<'—)«H×”ëB;%©¶æÈº©*c¥ÆRõ$×õ‹”䢮©YcºAˆzE•««€¡OÓxÄ †ŒbFx'#išU®Hš¥©Ñíê³J=7çxâ?èž]]=ODž¯Dr·8[´ËÎCœýÄY°3*#õÊ#{¤ÆTÎÙaý³Ä”µ¥;²ÅÍíí‘õô3ýÐ_]!‰ßî‘øž/zO&/Þ›Üe¦YgLu­èN—²&“>’šˆ’VÊþE)ɪÊ"ý•´ÚòBß3rÛJQ½­*Î)UÊE¹nÄZQad“«šîJ³¡ ¿Ît D†mÁ ¶<†Oñ1©RˆÈ»¤€•ÀÒPJ€»‡=„bXÊ4ÂþŒzóQÇ1e˜ü•KÎ ¦F¶„óé±!¤gÙ)àÜEÈ@¼Á'6àøçãÅEhz×ýB¼at5¾æ³Ö}p–¾tuûpÂלž‡Žªýs¯Â™«ï`»³”ã½î°Õ"â•èÈU+BµˆøíŠã˜¾ËÓqôy ïoL¡sæLüù¿wF¾½l_»BpÒbZ@Û­•ºЗ§e/8ucÌòäq€é[°g?tYÂ5ƒ¡Ýkë`|to44'@Ñáe„£þ®§x×å »‡šmâÞ5ãuWÀ ×­pãàïê¿¶Š…ï磳 ÜÛï1wj‰Œü€ †Þö¦“ÀcÖETâ¾…žE^}Xy×¶¦·pF¶ Ø|{ñü>>/XObject<<>>>>>>endobj 4871 0 obj<>stream x•WkoÛ6ýž_q¿ UV[ñ#qŠ=¬]³åÀ5P 0Ðe³•H¤’CÿûÎ%EÅJâmÓÀ©û8÷Üsoÿ=™Ò§4_ðOÑœ¼]žLò ö¿ì†Î®'ô&ŸÓ²¢Ù„o¦ùbqIË2ܚвÈÎÎè¨kò[I÷Vìv²$×ëig”öÒÒΚ‡=µpŽ”½°é©zÓŠ¤Wׯ¼:]~>™Ðx ³eöƒ—Í®^®2œ­Né#Ûüàí/øz{ƒ³«Ÿù…³ësâ7*#ÀñlÞ˜ýF_äž*)|k%™ ~•#Äg(¶„Ï~+<­÷TÊJi¥7í”`/3;i…7v|5t”…é·¦„E]’ðÞªu륋ŽàoýY¾^DD%%9ã$Bz+´Ûá“ö5n…tN­k™Óµ±$R–#|ØY>1Ú‘k‘ˆàD¤“´Ê*kš®Ü)ÓºôÚêt”r{,æx6Ëçs”¶ÌªñÕC , kaWÙêt˜úŒŸÇÝDxâ¨L]›{@ûMï<Äš®NP(oχ—/uA~› Ÿ¶RÓFj®&—9²Ôº}ütó€W¨"–MË„Cä GÕêÂeQ+¿çSæ·|ð(>‚8 ?OUZ*ù–‚Ý{x”wÒ¦´#¡8—Pöa²C„3¶*uaZîô:FÄæéâ­ùÚqެ½5®ùýN.¶Ù 8„ÜåœúÒ"+P©£V,JÓs ·º”¶Þ3b‘ÍO˜`äSFF¬Í¤Â”’Û½lÁÞgªÕ—ˆêO Yµ×ÍíÃ-´!´=ýX¡óÿã·z"uIƒð|üŒ)_×ïŒ*;«îÑê°zºu+_rÐ[¦_ã¥!xdDG¢NF9ÛgLÕ²ehðÄ[òxvz2N¢´óB8`M"lÛ€¬#‚.A⬬ðÏ™¸Ì©{x½ü-ÈM¢y'^=·ÖûT·ï!rNÿ˜–ÜÖ´uI¤¢jk([aV9f Dë1'îƒ'Ý„¨”u!†Ó¤w¥½#¥·ÒªÐ.9ýiîY«G8E‡0­†q’n›5h‚8˜a.¸PklNãÈ­¿d¸t'¬p÷‚ØL‡P‘N[RNïá'Œ(Œö†~¶mýßxÉ@–éAà¾6žsñ¢‡Àù³ëé›´]æSŠ7V3,oåD>ìR¸á =Å‹V"@·¶±>{6hmü6nP,I1a”I@¤…ȉF’Ư€sØ0½¢¼âÐb†e¦%KדFTq/n&O˜Ù<~bv‡KëÁžwP–èáLÙµëZ¡¢}+a΀]žžì!_Ó(À¶ I‰ßB+¾Ç"ÛÆŸ@°ÄÂðnÉ+o™Eï‡ÅÅêž§Uî Ä‰ÓË‹|1¿ ‹ó@^zÆó|B¿›"ŒlEFs,ØîÎó Ü_Fw‹ä‹w¢iäõ0D~õb²Èç3ü‡AN'3~ô~yò÷ÉÿpÐendstream endobj 4872 0 obj<>/XObject<<>>>>>>endobj 4873 0 obj<>stream x¥UmoÛ6þî_q@Q@]#Z¶b×Íi6wù²a­~ `Ð3“H•”âmöÛwGJ²-;C·&¢—ãÝs/Ïs_#ˆðwñ”þ’bð~1ˆX„/»‹¹ƒáüF,22š¾Å»ÔàMTk¡/°1¼,…Lxµ¸ çèÙ Þssqñè_¶®àI"¬Öî82NE&•HAªÎ{žÏ€«”®~Ðó\ëžgFÏ!V!Ÿc‚› ¶º6ˆªª‰¹hÐ*ß‚x,µ€-¸©ÂR“‘$çÖRT3÷*ã‰8éŽh%¨.ÜlÉUVºZ?ë s%T„£1a"¿>u‚žj• “o¥º½ºIÅà7½œ|(j[­džC%ðòéóÍà+]W>²ó†}’.[ØpL•üV"Y+ù¥ ›¹rýéÁšX )5fŒéhóƒES¤;¡„áU7;Ö ¹>Q35á ꦰ/åÒ£KCƒ9¦,yQæâÂ÷.‚‹ivÇX¡ñ˜Å1>¥A{{üs‹˜;ð¥Ã×ðüÏp7.PWggøÔžCÇÝ9œtøz௬W¹Lj‘³E¿à'|á•6á»ÛàöU믳aÌÍ[wÌGܱ1t)Ål:}C®rœ/Å©ùvW-Y”Úø†9I× õyt<í]Çþ•q ÈdŽÓdiÚâ6 飸·Åüá|Òè5ÀÑæw]µíélá3 oF×ÓÝöìíÌ ek‚„²"ψ“^™Ràý¢Zë´ïx¹DŠˆl¹¤Fôüþ‡©Êà’:KNšáiÿ½€Oû2@!º¾–x*cšc/à#ß@+®m~á;³-noN–y—JËWØÅc’­Äš?Hš@üòÎ;oèÒ« 1ºá`Ï~‡òÇ ÚÒÔmSG•Ý`}Oî®ü])m]:Vlp&2iPÿxšúõBêŽXÌFçÍü¾¼ÅÁÍpW†ãݦÁ”'pýú5àØàè¨UW×(ñi#²Bú6¬^!¼ª8, #›Í{Qú׸¬,dŽ*"S‰äÃ=A1h±cc¸ÏFdp­••8ÊNH¿K½Þ}¼þcu=é@éCb碠íF(—&i@úÏ•´eÕM3ÐV£r.Ñø”®ÑçTäÿöO.]˜ýó^gOëéƒ4UÍsøÛ%âøw Q«¨þ¤Ö€Â,výP«‰uF`ŸPˆžÇÿÔ¤»ïÕ5Ù…õ~K‰Ñ3¸ 2ƒK ß¾í—ÿCý8†Fð°p•¸ZKÛf×í úÞâïrßÿúäh½×©ÎüVßq›°wÕí½xoï]Áø:„}º[WûmmÒXd^;´koÖ¬‘ÑìœMâ L§6¹mî8³~ÑIMÊ[P+êJƒ·ßø@ÿŸ·“hÊâ16 Ù?Šbòþëbðçà¹8 endstream endobj 4874 0 obj<>/XObject<<>>>>/Annots 1610 0 R>>endobj 4875 0 obj<>stream x…W]OÛH}ϯ¸ ‹lÚĉÔ•(]ª¾lµÝHû í ™®c§ö˜€ªîoß3wÆvâ (ù8sæÞsÏu¾÷Bã'¤éÌüÆëÞ8cļ…æíë§Þéô,xGÓ |¦5ÎάåO)ýÝû0ßÙÂûŠ{ÝŽé"˜Ò|I“1ÍÞ…ÁlvNó„Ç4ý8eIèÇÉü[oLã‰OtMoîÄ•Ä^ nª(UñegᇅµbqB—t'¾ùïu‰áï…\.üÅÉUwòçÞ)DÿòE*ûŒ½ÁÏ}î*Ó´*³Èv†?Ñ{Êä–®-Eâ×hD ?ΫL_ÒxqÒÙ¶{%»Þ¼c'<KZÉB¶a`ÃIˆú›(tçâΈÜÕk“ N’Z>¤·ÐÍû÷„ùƒ4ÚC&C^ä8=8‚(‘©Ô’¢‰!Ç/·S1 ¨Ò”åÚ­KÚ òífº†è&~¿o£YéØÇs\IdÉ!Ínb™äèö” ð’†ÈÖp2u…ãÎH¯$ÉG±Þ¤’D”?Èy×ÙjRY©EK‚*I5@ fˆÕ$Ê£o2ÖÚ®T¼¢Xdž¦H6ìD)]ˆB¥OT*³QiT¹…Lj!NLYFRo¥´´,jI^z|[/šxjØœÈB=àìe‘¯IÑíÌ]Ó§¯ Ç£x¬ûÂíº:>y_o0áÕÔ•‰ÃZfºä(à¦#N©DåëÀQœªóœ´LáVÿ|þ„ÕB×`ÌU`F¦¦ÉÁ”ªè¥–ªJÉ'÷±¦Ï@}&з>³o£ðD)…® Y2µfº¶L? ùJÇ:ò!ÇY¤eNâA¨TD&ó%ㇵBñAÀ& 2£;;Ö.fŽÏ.à¶åê@²Ò§€nó¢Ö›ï¾©'“`:…Å'þñ:O*Psâ¬Ù³yA“ þ|좰ð9n°"N,õÓ+U¶vÝßÃÙÙg£Œûûx˜]´Þiýî2N«DR¿ˆqï`UOÛn§¯»SŽû‹5¹e£5eçÀß £A½bÃС,êüÓVAq(:ù(ãÊ9ͤLð 3ù Ô®é 6O¦†ZðÍ“^åÙ€ò¢ËÄì$;GºPÐ/ˆðPátº)òǧÑYE'çÑVÍ[Û³T‰3#ü|ùŠ»¾YN‰Z²ûhÃDd8q)Àé¾JEAµ[½®­ý,.P9òŽ[d÷1@ ÅðDm¼tdËEÁ>8üE Û¾qhíÜ%m‡tðGtóö­q`·;;:dÛ»œ™ÖØ"ïÂz-îa[,$,$Cì>{–ë<‹“YµmgÀ¼¹D8*z«àíÍCF{u[3&ª»Q7§=·ÜÖ|D—Ø{Õ=È)0ج´ bØ.¯¬ÈYꢊ5,g[ˆÍ:iȹFùbþ™ã1]ÝÔÔYP’ËÒt6ù¸Á££Òèf¦ÀŒ͹ ×øŒ©<Јɀ‰]&+ÖsÏ Â[œô¥#E}!-þE©Å0íE±W‘¶¼Uvÿ‚&è2uíyÉ+÷n` Y-ŸÛäúäÌ„– /H?mPœÜÞØ\PëIï÷ö(ù½R"EÛ4±@q©ÌDQ×õzEî8±é|ìàýާ¶&ÏA5‹ú.ˆìòW¼~t{ázXxqœMÏh†¿®©˜Ë §øÊñ1+Óç…VyfŒ'#»zxnå7 &gu]>û¸SÒÐÔ¬{@pä ÔÙxL'ø„.ŽOÍÐóÞ_½ÿÞ§µÄendstream endobj 4876 0 obj<>/XObject<<>>>>/Annots 1612 0 R>>endobj 4877 0 obj<>stream x•V]Oã8}ﯸb´"06--…Ñ"13ÛOû1¬æ¥/nì4†ÄÎÚ¥Zíß{í¤mŠÊ ”Äöý8÷ÜsýO/þ&0šÐ_Zöñ¿Ð¿„þýõ­—Lã&ãQ<€&—ñ¸y)à{o組«ËørgíóýŽ1oÑ,¡?»€d÷z\á÷Îð!îh— +m¸=ƒï?î¾ÁJ(í€k`jír©–`+‘JVÀ* (±½x©i¡bÖ NC…Ûµ:Ãs¤ ¦X±bk Ç\‰c@‡'÷½œ'CŒ&ª¦X“—ƤwLÁSÌ KÇ 2úy RYÇT*âÆÌð‚ÌÜãºÿÐ…ˆ~ÁpÓ™`®6!€Íƪˆ’áÂÊ¥ éHÅeÊœ ÔÈ¿cf)L-k¶Ä÷œ!l®ë`ôJ csYÎü!#Ð# !Äð1ì"@èI©VµJÔ ¡s9íÖUã&gƒ##²#hòD^cað'¤;£€ç’̰¢Xƒ(¥ gSÍ9¢\ºv¤rºmùòñ#¬ «*abø¢••X©ð…ªE[2]zEoK6kÈÚ ÐOF‹[è'qM~ú³LãÑrˆLãÑßøn­ngÁä§60"ot §íÂ<šŸÀ¿U@ÂÜž¡·´¡{ú¿à¼m‰sï|O&—»¢èBÏD­¯î¹h›¦Ò+À8-”ušC!‘ R¾M:œÜÜ·„U·ÎÔ„^¨¡ÔmŽÎ—¢$Lsì§A~:¿B®‡>„žFÎÀ1;^{.ï4Ä¿ ÍøŽQ8Lâѯú8’Á˜Ìývßû³÷?ou©Öendstream endobj 4878 0 obj<>/XObject<<>>>>>>endobj 4879 0 obj<>stream x­VMoã6½ûW u K‘ü•À{ Ú{hÝu±-Q»©’”·èßRrCÙ»ëu‚ ¦FÙ÷Þ<òÏQ þ¤0[ÒoVžÖ£$NpñôGïàþ9Çxë¦ ,Óx¹|€uî¢Xgã¬bÆÀÓ°‚¦ÝV"ƒg¥àï»õ£¢ƒò±° Ö?­rGñ«ÕËZÀÏý=üÌ>qxéÒ}í¥mÅJ÷^ÿ-\zïŸ7”æþyTPvMg]7ãu) °Ê(8(ýÉ€ðáãÛŸ¢(²%þÒ(ÃsÈ96«™J8ˆª‚-‡ƒfMƒ¥Ò5«ªcÜÕ;SãK.Áo`»­Ç®é°œq˜›iŽÐ`RfÀ”ê © ¬ÄP-¬n*n&á…V5EÀ–aã„cG˜'SÀLBZår®Åžç]•锪ô2™Ÿw®ŸdÒ%x…‚æ–amL¡ÑªáÚ Ü×–ÌB-v¥…’í±(Ž(0kYVb)žô(·šKVó,“0Šôä ¾;Äû,”‚}[pfÛ³ÐÖe‹ ŠÔÜ– !BÞ]ZB —ÿ…ã¬'ÜiYï·G ‹ü&¿¡BžxÆëÿžr…PKe ù½È9Bòh§‘D9SÒjUÚs}ΛchÇ-ˆºQÚòܵX³#I:E!²¶²`õv‚½f’í8˜6+Cù^Mƒ³ß ‡MqÉÙþHbU¸™‚¬5VÕâ/ =&†·U “ßY Ò®EMT™)­yf«ã¤Oˆ£}`GYÉ$ÖOs‚óÀuÁ2üæç¢PU¥hGÎ¥Bß‹fÓx6CìGkèx“ÞýèÁ·ÝïF2ç’¾zg•Þ_cçq_ ÂýV+„Üðʸ9™°ÏŒEoÆôßËæ®÷]ç¼huÈ¢@ðÀr48rA`[ÕZP›höóÙs…G¼Û ûB{¡7\¢Äº%4b„Õ¿ühøÞ¿Œú5–Õ³ ½/.Ûù/ÊrÓñØ;>r‘÷dÃ>œ z«Í‘ ´ÌÞ üÂ+@Ȩ|RÉ•¦Ž2%]÷³ŽÝ´ñðÓ=8ÎÚ:ƒ¿¤Âé¹ ¯Pš‡–ÿŠ÷!%]Ðú†‘z:=qþèÃõe ÝéðDzo2š†å\ênÓ«%}<Éå!N!Íû©ÞLñVãíõBQ:_’:ßs£ª=]UX½»VX,N:k­ËéYg£ùž#ÌÁ=ÁÌ[N1½×žWÈÇi£?𿮇îôÜŒiv~¯”ÜmîüµÊ“_ §Ð3wý]-TÐcÇmÓ±ÕíèÈ|ïŽöœœöT_¯y'¢ÿUS—E—Ê ’™ØÜ•¸6.L3Ê ò‹¢: é+QõÂKñr¶€…w"wǜŠü ²¶Fé¸3‘¶ÁéšÇ ŒŒü zO—ð›».ò¢K›èÌÂ2™9Ã_$Ëx6ÅË=*7M–”îÇõè×Ñg¹ª€mendstream endobj 4880 0 obj<>/XObject<<>>>>>>endobj 4881 0 obj<>stream x•WÛnÛF}÷W •‰ÖÅ–¦q›>Ä)j /й’6&¹Ì.)Fúï=³Id£CwgÎÌœ93ür2¡1~&4›óÿ´8ùåîdœŒñåþ—YÓùÍKš\$t·Âéùâ2™Ó]æÎŒé.Ì“é}¶–¥¹°VÚ³»Ï'ç74Á¾4š^$‹n Þ¯¨ÞHª…YËšrQ®±–d›ªÒ¦¶îaÙ±E©.SYÕt?ÈÕƒ¤?ÄVÜŸ O¾}ñ"z&a$µFTÐKÁ–÷ǰf2e${ß•Ñ_wñ~7ïKJ…•¤WÎèÔÖ¢Véi4ÂLîÏè¶ÌwT5Ë\¥½§ÇPºEئU0Ë$)K¹ªë\v@ejµÂSLKY·R–Ѩ(3*µ)D¾‡nNQ™&6ÓÒ–?Õ1ÁÑZ€2edZç»!iã2 ÁðJ]“*ª\²äÚªÒØç­ÐY“ËX–•6Hª]½ÑHdc<„’yÕw{•æÚz _µöhDCüËV9AA™=`D-T©ÊµÏ0°%þ{£¤&ÝìAÏé*u-K™ÞŸ%t3– /åFl•n b‡¿¨n °#$zûŒ8óL:Zîœ÷ç+)pˆ#wF}°úŠ<»}uEÀÖªz³¦É²ª›Zª”ÃTe‰ï\©à+hë%8 K òÈÈ0BfCj ’Èìšߌi‘̸§ÜƒÓd6Ã_Ù๿£¿ó÷Ö0…O××øø*BDëfï_Ó·{‚[ô­sƒB38ÜlÎ…0³ä Ÿß\¹9°³d>¿bouQ¡ù– í²£º–!¸(/úhgGÓ_ŸÞÿ6š%/§(D ÊäªPLàc¶Å†HzÊE-7gmPbÜÀe]‰/¤J+4±I ÖiÈﺕ[iŽ jµyF7  3è1¯¡—Xcò 5† «tiÉÈ/2Ld&@cñ aYA^€È}Û1¨Ê ¾bS]É!‰,cs ™ zU”+‹Oö,9ëÇ·õáœúó‡øN)¶º;PŽs¿AQŒ´M¤ ÝU¢‚€2š^;†^?n±è.¡OÜT0PqÓ‹XVˆWÛAƒþU¹`ÍA&º4°ÆN—,º™¬ ŒžNx)×åÎ8øã2¥:ƒm0ǤM¸ÿwº!+}¥V:Ïu‹ôu ´Â°t=Ý¢ò«`éMÔõâš>ù4™Î¯rõ ±± ³×Ãîµ4Ô*æÞQ}Y"½éCe3eÓ3Ͱ„4S»Qé†ÖRƒôX°ªÔå(Ôàh”Ñv˜Ö\ØïyÓÉGL~¦²„Þ€¦D¿oA‹!w€3Ö P§[k—û€Ý3 ØX#>0˜¸¥¶"Çâ^^Ï—#¬8A{Êó*K×Kžì?Úa¢Bø±ì¨6IfÉÅØu“&Lj:t<¢v“Sȇ꫆µÌíNn°ÉìÐsÝ¢ö•ç)ÅÉŽ‘ccjú–ã^]P% 4=>†|VHä­ØYX)*"vt²ê8Ì›ÔÈ­vQ`~ò¯ÌO­ç|x¥¸°.7Ý}r4]ðj™ñ¹ 7´4 eªÂ55{[R="ev>±\¾a´Ê£¬…f·t2gŽÃwc˜EÔ}mDayÅɤÈ÷EžCæ­ßL\ì ‚§;'¶W«_Œ/ ì­¸¾n^ç"}à#ûvŒÔ+ŒÛVÁÛcæÃDTÐkF!ÜwÞÛŽ­û'Qñ§NcÿB÷D[]Z¢Í6ºYoœÒÔÒÒF·Ü !ÓeÎŽÏÛ‰ÉRXàݘ,q‘‡ Ù^ Ç|UwýD¢†mÝðj'êNºx\ˆ)6qO#!QÈHäßÐÀ[®ã_! 9¢Üïz^³Qt×wL c¸ßÉ<­;D84àËžlo:ÿ‹ØÏ–ŸÁaÊÍR‚Ó\ÔB¢„”÷…¦Lk^ºÁê†ÀÐ!wbÍDÜO|ïm øÓ“Å{½uPègXÓ÷ì®1T·®m5Ti)Ìý ž;œÀv†nM’H(¿àŸ“{ ¢G,åbÃN¾[½èøæÞ£Í5ŸÀ[ŠM…AŽöŽý¸<Æe°7å>è¶—½°ïc’;uoŠ`-†þ¥Å¿Ù<Æ×¯_÷ÐGìôŒnÄ®“Oóç7‹ ì“ÅEr9»¤ù|‘,^ºµ<®%ô«N~éÂÔ%_CTþôèʧûïÜ—ãy2›â…šŒ¯øê»»“?Oþ"B(éendstream endobj 4882 0 obj<>/XObject<<>>>>>>endobj 4883 0 obj<>stream xmSKO1¾çWŒ¸$vÙl GÚBÅ¡ª(‘¸pq¼ÞÄÔk/~öß÷'DEª²‰{<ó½öu4¥ Ÿ)Í–üÈnôu=ªÊ ›§¿¥«»9M+Z·¨]^cÑäs,ääÆÄKÛÅ„G%¼HЛvFDí,¹Çо]\PzU„!DÕ]R«ßµÝæ³Þ»Q5N;ŽþDGE{ç#÷W$šF5¤»•ÊÆÜü|ý2ª¨˜Ö€5‘ŽÏÞuP/"®&Óp¯^“ö¸Œ–!õ=Z’Æcsßǧûä“-¢îT†Hˆ%­wÊc0¾ÖQo„ ÜBî„Ý¢2s¶Ô¦˜¼ú„Ä+èT ç‰øh¯ÆÆUoÊcšA[; p)¡žÏËc§zΜ€€6.FבÑV±Æ™[Þ µLFx쇤²~€Iô=Œ8J(èCßÖyê\ˆ”9c÷EÉJúÕ’tÉuIƒKÔéíò Ñá1élÐ ¤ÀÈfA"T9Cº¥Nh£-Ÿqi´*ä\°y0ìƒúÜ™Ás60Ð3@†’¹_Ý]Ót^‚>G®¨W¼l&˲¾¦§l<Ø::7ÚbÙòðo`‹z^®V|ý>O£|ï¡# Êk—BN¦tÍÿÈS¯åJ=-]?0Þ3¶äÆ‚¹ˆˆÇú·j‘+ý6 sF›nYÂ6Ÿ|Œ#£O=§ëðÒ°8þÔ¢q2q¾i¯ 2b² š‚³@Àæ°i>ê¶:¾¨u5/³T\”ufÏWŠYYÑ÷c÷“ZÅGqñ…ßò¬óŠnhãµjɳSbà Í~Òy£ØW浨–嬆M¸8­V¼u»=Œþ¬žj endstream endobj 4884 0 obj<>/XObject<<>>>>/Annots 1654 0 R>>endobj 4885 0 obj<>stream x½ZÛŽÇ }߯¨Ç5ìõu.Š") ÇÑŽãFMOÍl[}s_¤Ý|}Éî.¶-ÀN„^Èëì/Å"Yµúí&4þ„&ÞÒYylü„>Búxÿö&Þn³M·›Ø”fŸn’æ~ä’„¹”9Ä)XšCB‹Ìœ‚¥ £ýf¯È]Dß#^4 ü_­ª1D˜ªY…Á¦»%«0Ø}¸ÙiY…KEñf«X1*"cÈb6Š?Ù(…Iívš­gÆÂAJͬ,ìyáÞLb@ë*ˆeã”,šIL²/alF[¤0Ù{ؤŠѽl[l±§)#‰°Çä ‹Î¬ˆâ“âpˆ`QÊ€ÍõÌ6‘"Ep;0†£)#Ö‰hO˜tîÉ™™ÑDB ²%e$æz Q¤<õ¬Â`·!¹êY…±3ˆÜ™YQ‹ôç-ä#Që1©M‘iŠU쎽›eeáHÂÏ{œ2àR„`ÊͤƔI¼Q3+ˆӹaŒÄ^ÉÞ˜áY…Árä«0XœDb–µ|LQ´9 H«‚DÎ#¾3©1Xœ˜4³¼l²Ÿ6HAâÇÉ"Å*Löî Ö³²ðnÚVʈ„‘,ì1YLGN± ƒåìñ¬,¼NÅ;aäã/¢ØØP³ “ÅE/+ §ã™‹I’­{ð‚qŒƒãIDM”¢Å®1b‹"Å"¸:³"ŠÊ,ÉÏáf$Îx Ñd‡o%3+¢¡ø@u)aÀæzAüû6“Ó²éBT–Åége$ÎxLÎpf–EcT+¥ QI” ˆgEt?†0 ‰dÄ¢ “(¥¡bË‘P¬Ât–wØrÏj 6¦b£X…Áî¨\zVLÞŽ…jrÌ€ãï!L†ҙÔ,’‰Z‡UlB{çYQ:N hïX—+õ–Ýâ`xRy2@C¡†û1ÁC¢G$ŠÔX¬Å²³(Y?a°°eBì‹Â`·^/«0mÍ~¡Wc°áRVc° uOo•Æ`÷Ñ’U,¢¸U¸4qäcCi –€×+AžF*l;r‚CacG#•b‹bº`†É\½¬¨åQ¢«Á"ŽðÖ³ ƒÅÞ £<«0ØMrŠUF…T<+F¥<ü™‡*$g€ÈKíÂ2ÛPœ$oè”or‹Y-Q,댦+¤ƒ%Hâï1DÑ `ÂràŠ°Õ®ÍŽHRA†T<):¹u“Z4OT<¸ A;“"ÈcÈ€ÎQ4E“±TA<+¢<而÷¿yìÑì–Ž³b‹±1šeeáqd yG£yðѢ܎«0X.ÞŠU˜r…J¸gE-rDº å~ÄH¶ÜcRK%Ƴ"Êã ȘH47ƒE½I5«0YL7%«0Y¼”Õ,’Iëe£Âq¨â$ÀÉDÇsâÂ0Eü=©1LÂ}"Ò¬ÂPŠδ-,Jç‹F‡P \Sœ(‡«0XT5åe‹”Y¬¬0ŒB¶ì•¬Æ`QORÍ*LQ¤cçõj ö.¬Ò˜ê4/û·£ºbó=»½šoÈiè8^pߢ ì"s<ó=<0Çìvgî~÷ÖØêl^}ûm~süU-Ã7u^þãûôes‡Zœ¤[,sû®êÛúgg[Sä]¿¶w?Uù¥nK“Ozí_K¹¯ròøÔ8h3j刾§¤¾;ÙéWnVVù½-Ogk.CŸã3ó|û² ŒE®Î˜î©êíãÊnÿóô«Ëz9£­Ô.“—M‹bQºª_YûëǦȳ¼7P×¶ùÙIØ/ye‹•Uÿ0…iê¼BÜçµ²Î{4ˆêZ<™‡él\5”¨’tx×.¯‡SA}àŠÏSk³nõ25o.¶—꾩r¸n×ö÷e‘Ûn®ÿkkû©B_ëÛ<뱫Cõ ûùoÛæöœgÏæâî³!«+ZŽŒ-VjçÚ»³C-@PŸIçñ¡uöŒv“ÙîÖ-F¬•kÂtJPà¬ÐÐó]èì ·øéÊ&q«/P©  D®¬ð¾GÌŒí°åÏQ _EtÆtZ_L_›ÏuûÑ :•®<¡Pü4+ÈšÎ|Îû‡zèQ9i|›÷Ì•còú1s ÃtËòKžI£à¹¤ªÓ+Ûðª¦+MÁ*\ûdj0ì^«g˜^ö(9§¡— Ž¿ªüÕþϓެp5úŸnZq²'äeu¶-•ôL¸ÿÅÛ– ªŒ›å¨Tùÿk®wð7ÀÅõê84èã4E¬]…ÿa»Ó[ kkzï®CaÛg¼%Ž—Ô»fh›ºÃ帴m?Í„k»KWÔªËi*k‘eui0 ¢úLIô´òÙþ¹µ †1ÿH°²¾ë⩬ÛÕUU”wt¹››ÝX\֮LJ¼£ªØÐ-êšBÇ|ªcqÇÈÝ…¯uŸrŒŽöDM´pò†fÁ÷Kîiä+Qü憱KŠîÆðâ I|_æ ¬ës\Ü,÷lÞ«éÑ+¯ o#^˜6#±7,Ù MS·ØrRTÁ"(oØSUç^oººt‰€Ä,ò2§É×3¼|c1 ˆ!{À¸‚‰-+x·0LO[Ü-?óùÂÂé9ªÛ˜ñôIN&Ý¿—šn>Ü0àŒ×»ó/t9í-¦à¶ûÒaBü¥¾|gzê݇o L‚y”E4&RØÜò€ë/lñ‹"’Cq–¨$¿Šü#z‹ì^Õ7éatÀŒ†[:t~v”⫵ypEcNOÆž‘ ”É$îñF`^f"OÐ%e¨žvî’Ã[7œòi…’BlMc{XE•^ß#±—‡Å™ñfÉCí4ïý‹7Ó;+’¿>ì%¯¿ð¾›âŸwÄ‘¼s†Á‚ôúxó¯›ÿ" ÈÊendstream endobj 4886 0 obj<>/XObject<<>>>>>>endobj 4887 0 obj<>stream x…WMsÛ6½ûWì%6ÝØ´(Ù²¢4=ÔÓÚ™¶š&™ÑL"! ) ° hEÉä¿÷-@Ò#+¶Ç’M`?Þ¾}»úï$¡¾ù'-N~ž âþÙý²+ººAÉu|M³%N'7ñ˜f™?3 YÝÆCº3VR.ôª+Iéïdu>ûxâ/ÃÕËá8žLp—¯Ä ýù òZ’•Ki¥N% Qa$U²Ú©´1qM <±÷Ë¡$‹þz÷ö ¥ÆZ™º|K¥°•¬È­a®oµÚj'>ÑÙééÙ-%ùIe.ýi·-U*rª+Ü,I9RÚ?ò‘¤FWÎ֩ý6<Î ¡$H+‹DU©•.¤vdJi\ÈÜl¦!ýMâ?äè‡ñh„¿²(Íq‘~ÛÞù×/­I¤™EqïýMT¹l:}@ªÆþ¨´û‰t],¤­^î+ëE®Rï—Ãó¶¨õ1Zg§§8Ùù9M[;óÈ{àŒç‘7æç8÷å랟Î&v9¿:d?-ÂWc•^…”:ÜOŠoYéj«é·V½”‰öCûê/_Ý·Œ¹ô¨âñø–‘í3®"Þf’K(3OŽ»çÏÉÉ¢4VXJqÑ+ãÏiãèAÚ-È"—uN›µÔü­)H}éo »’®ë†ª+¦çË©Á’œÝšš6¦Î3úXW`ÝJs¡4=(A ùÕ=ÚÓS?zž‡ÿ¶éE -=ÿ•^yÞzjÅtÿÈô‹ã¡Ávh}œ§Û–EÓiâÝrÏÏ£>CW–RèPÓÆÒo¯Š[”b)êÜ·  e²K†¼RFssr×Çô»qŒ“p´W»-ÐÁÕó Ò5ëFæ|0`pø¤³^<…A‘\¯¶´Qˆ€egir4=×`#¬Æëq\ ŠÕ4™Lé]¸B7ƒÑ”î„>s´±¢¤³NR^Q­s Í€TŠœ’‚ u*#•A~ÔRIë¹ö¨¹þì@–Ý!5 TŸaÄóR M,-¬çïhn£´ÜÛ ¼ÿÊíÆØ¬O\ï‚Í÷¨{A‹ÚQ*4·Ú Q;•« p14xÇý”š¢T,תÀha=FÀ¡s¡Ú <éUÙÖ@cï¬ïO®R¿~1ýÌZMÕÚlªn0„aÀ£"p„«*žŽ%´¿h5Ò·ùÁ ‘¦N0>Î1L"Gïß¿ŸG,­ &ƒ—=ÕÛ¿ðáÃèk{í9dp¼?ß±ŽIYZn2¼r ªi}à.€G3ÔŒ"À†Ì‰f„Ö:“6ß2~máz å¡Èë„_ Fôú““Pzà\8¹O>ûÝñß°°êÓP³Åô«ÙH(ÍÒg™j@<Ý”à²QU—m›ð–X¬Ð"凵Vnk(6([.ï7¦vš¦y—Pa¹Àœoî?U ‡Aðü²c4wo9•ÇÉлVäÇÙNüLbíEÈ"SruZaXñØ9¸µ´Ç(¬/ýµä%kþººâä#–¬$~§ÚÅØáyŠ_TzõyÒC0$O™î•¨ïæY›Â<úÛïSoµCsÈŽ<î; Æ>ìWÚòzMoAYþŒn‚š¹§õô›“~ËðFQ§ë}ɱ¡ƒxõ; /.ÝB"ҔśµÐK¯+Æ&Ï:´óÖ†˜Hô£_sZè¿Õ*Õ†H =ðµíêÊ3*Z•2EŠ}"z»ûÒþÃéÄ,Ü2ÈfÒ¡l¸Ý½[ß»ÐuÛGÎFAkdB‰. ¥¡ÔÂŇfö’ÀÏ£;-;®ºy„!ÜNäëÛñô±¤M£{ fÛ¨Û¤ÙÚ’Éu|3º¡ñÍ‹x˜øÅŸ9u9Šô‹IkþØàm2J`S8}yv÷£¬nãx4ÄG"hg’ ØÀëÙÉ'ÿ#^_Äendstream endobj 4888 0 obj<>/XObject<<>>>>>>endobj 4889 0 obj<>stream xÝVÛnã6}÷WÌ˶Ê–-;qRwk ·ykQ}¨‹€&)‹Dº$¯[ì¿ï u±dïfz_ZÇt‡sΙ™¿ Lð/Ùœ¾¼|·Lâ >lÿÙ-Œï¯!™À*EÛùWx!Â{¼àуV^±\ý--äÊy¥+Yž€ív’YP¸ÑÎÛ’{clJœéÎk¦–š{e4 …ô™1¬2y“zÙ5îùÚgŠgW«?%SŒ+bV‚y–67LH{å3`¹—V3¯ž%íj ã™tà ÆV¯ôðœ97Wr\„™ç…ï™ÒÒ~é`WºìqÃøS%¤0ôâ¹,¤Ælà.è¸ñVrSàkа ˆvӠ§Š&PmµÁãPm ÒŽ(ËÝ”C ò-ÃErAQŒï'pϰ)ff:g3¼Ñ«Úå÷M<‹E{¹Žð¬‹Eg§GÚéÒ~¹¾úº9¡…DA»þé½Ý•›\ñ áVÀÑúÁxüâq{[õÜžF ðl”8B¶ŽÌž¾87Žã¸çû]8ó‘û£ËY<ŸßR¾=² ±:˜1)s…*=Ôª41( üiƒPÚ.t¹6ãÈPÀæÎÈâ`\H¦‘’IJa2`(¡Ü¨²f@ðY’Ð*‹F·Ñ§x¡y^ oÐÃcå VË^:.ļJ}'À@¬áÐÒêÿBÄ?ˆ›cYÄ+ÔxHFU!µ¦ úXðÌn¥‡œémɶ²‡úY ?°0êaàVjòÜì©níº­}ËžkÏžÈ7ÿÌ|Y.—Àá›®¦á÷d8Ά×ÀúªO¾á<¤A-T©KÍ69V8s®š g³ÔEÄ0K TO¨`õ©^¬¨7½ˆL_É·ØD¬Å(D¥bW-ÛËQËÝ^.šfç–Ó'¥²W¿>&‘¦—¬¯ÎVwÖÃkBDË}•ó*¡–¬#*‚µcX4W®‚®Sµ?|´lÛÞ:ª}ȳ•¾´ØîûÍà]“ïÐ š;,§Ÿ¥%U~.,O/ö¾ÿJKZá¤À68þ@ÁžhÂÁû}PÎ]¹1O4_à`£ÒðªJYÆl$ÎBâK#‰CŽPuq— àBX>&‰SöáÌÐ¥ýEhŠ#L^âL ­Œ×ÑiÿnØßßÕ=<¹»Žof70¿›7ÓÚ¯¿=ü4šÅøÁð’¦É0 –°¢VÖ£Ûj¼º§ñ5<4ãl3‹“íÍNqrG±%IB~\ ~¼Lnºâendstream endobj 4890 0 obj<>/XObject<<>>>>>>endobj 4891 0 obj<>stream xVÛnÛF}÷WÌC[ȈD‹”¥8Nc Iã¶/A‹¨è‹cM.¥MH.»»´¤ þ÷žYÞLÖM‹Â¶ sg‡s9çÌüqÒ?!-VüçgïÖgó`Ž‡Ý‡ÙÒÅ휮‚­SŠæ´z«ÕKZ'ÞjNëxòøú|ýùŒíBüŸÒ v³hÑØM¬K®¯U¡œ™úSš»LYW߸lnLHY²*/³# Šuá„*¤!·ŽbQ.pr/©w“é¼T™$§rÐ[Kʱ§Ï•uðóþÅ rÇRNëÇüJF~RjkÕ=_Õ´7Êá ,sQZJµÁe'ÌV:ÊD±­ÄV> Jì®ÿO©ô“ÞËi¦HÁ>Ioa¢ ÙÄ’ªƒL¨¨ò{ÔD§$3™ËÂYȸ/,qañÐH*´£DZµ-pq¢t¨ªu¦Šžì•Û!Ça”à"ô®‘uÕøö=ê fª¢®òz'Iz%á6Ó{®8|Is¬[(I”¥Ñ"ÞÑ~§ð‰(´‘0*ŽT #r餱øj-bQÊ¥‘èqŸŽm£ôÙJÃyr꺨ÂÉ- ó ² o‰wÚJø¢ãºíTåY‹€L¾mš¿™¨bsNÏ"ö{¼ç†Nm @z2!ú&¤7t çScJ ü]âo9¯9ÁÕó†ƒkq†Ôé}ó¡Ó²ºÏTìîîSo½ye>¼Íùkº¸xRD3óµêz¯Í [\>h•PYÙÝݽˆ¿l&Þ ¼;úîïÆA ®·ªÐr|¤ oáœÌKPÕy0¨bËhhú˜ƒ! 戉{•e^ <¬ @ðmd™‰€º?Žiù\8Ö‹Û6¸I»W‡R&™D@+Ž S;Xðî™Ê¡É”î+F[•ù@ cF? ªÔE}æåËfj»sÙBÕŠM‰5ȶx!Ä¥-¤F48ïIÚñ_û \¤:VŸ‡È(å:4/MÉ«£ºwÒ¸orÄ7î-á&Uq[Òè’©òQ³Æ²žs¸‰LE•á{-º^çþG ”h0b·cìp”µ¿GÒ^˜‚Ÿ2>/XObject<<>>>>>>endobj 4893 0 obj<>stream x•VÛnã6}÷WÌ£ÛŠ|Ï Û6íEo1Їº´DÙÌR¢—¤b‹þ{ÏP²'±·A‚@‘ÈáÌ9gÎðK«G ~z4óoZ´>N[Iœàåþ]Ðåýz Ms¬_ã! ßñF?›µ|’¶C•Så‚DIr³²Ò9eJR¥S™$¿””ÉTûíJ¾UÚ;|#·-½Ø´ÖØ›‹écëò>¡«xÀ'õêöûñ`€ÿ²H•žÔ-öxz¼å•øÊeÑ.î,RíÇÙ}¾%º¼< ]G¾¦^ŸwCäQ<Oxÿ$îÇúS” Ù '3ÊíjcVõ¶CåÝþ0ò–éR9ʥ𕕄Ǖ°žLÊTÅJËB¢.Ï̵I?“)õ6¦‡¿>ýDjQ @ÊÇÇiq¹ã]BWô‹(æ™ ¼*Sälö Yw2¹pJj¬•©×[ÎÍá¸Â¸}НB×4Äto,Ž\Áy6Då = Mèïè+( ÓÒ/¡‚[ú÷˜¤°ÁUEئ@ã¦ØÜ‚²}€M{ûέݻå­ÑÖŒvŒO¡Fý ^PieažXÖ̵«•´ È”fÝ¡¹LEåäŽm-˜Ýœ\µZˆ€×¥Ú8ÃÑ,r©àeÔG2o¬]H1‹öì´·‰v!=ò+•XHTÂÚÊ{ErÉd¤r”àÄ*1×8³hØ¡þì"(ð¤>Jï¥Ý×ï–¦Òƒ%ž„ÒŒ!3"@/³RKxù–½¦ï4––LÃŽ×Æ…Ža dÖFz5¯4phˆp©R®m®JLäì"ºwt©ó¶J== +êǯ;Ž‚sRh{8̯¢/»ò¸ë~>‰&« ýÁø­­²€.8ü÷ív¯wÞL¾f ÿTžT[À[é2Ò¡Òà€ÃÍÍ7‚ÑK ƒÛP›¶/N:&÷ «©úøT{³çLÉ@» à! ó®ß·~iÊóÞÝÝAªžQ=‹fGd‡%ñ¡î^Ò½XÒ­%ˆu­´®}%“ðÿµòK S]•¹´²L!~x ·ƒí°`¤á}°ž0Ù?\jÕ"…ÕJÚwÈ»6…/ÌdåÚOè…‡9 º8Ü ÄÞÎ\à|¿Í17)ÅÄ -.1ÅÊb.ðP?èY'c¦ÀÓØ×üÒÊ`¹¸âÀhÍù€1a'åÊb<Ãwç°·îsžügQß(\•.N†87Z›5n#«Æ¼ûÉ0 F4ž`èñ a8¡LZío'\ [¯íNêû߇°'üŽS^8JÆñ  Âõz~õã´õGë?— –endstream endobj 4894 0 obj<>/XObject<<>>>>>>endobj 4895 0 obj<>stream xV]oÛ6}÷¯¸`+òGœÆAÒµ †xÛK€¢h›­Lj$eÇ Úß¾CRr,%p¶!NìÐ÷^ÞsÎÕ_½¥øÑdæ_|Ó{¿è¥IŠÃó¢ó»”Þ%Z,iœÒìj”Ìf—´ÈƒUJ Þç³–néélñµ—Òp„Ó¼_VY!ù¼uF$•#výÊaöÚ!oq3BÝ>ôÎhîßG)>=}ï„Âá Ö˜16@Þ'M!«,;vɲMþ[tçÜßA솱kÊn²ìšø ç×ÔÎð{¨èünJ¾KK¢²áxR÷´¿[ #¨Â×Ê:Sq§%ÎeoE!ò„îÿøô3­™Ê aÉ­¥¥tk]¡·jOÒÚJ$ucÆSß¹ÅZ™“Ü”FoÅF`p<ºmÀõÒ1Åm%#F>ˆ@L¶_Y©Vñ¬) O¹ sR«„>¼Jf¬ÈÝÁ]±P†ìÒ`y.½-+šÑ}†GyXbh‚ÒŽxwwï…pN‡9²Üâ_ò¸§?©ÂWŽ™•pT0µªØJ$t«H<²MYŸ–]ëïd¡w™mpÇãd2Ô‘NÀô{fÅOáÓS“ì l¬#åﬨÄÃYƒáH‹?ô)Þó!®šSdÂuˆEµA—Za8Ï^óù!À5ŸÓmž[:¾(d Ðu¾UäPõZJŒÑÏ:@i#6€+æË ùw€±8v+ ½¬ç‡²[ˆù&L|ÛñÅÄ"ÊsÊöõÖoLí^oþÃÔˆöA\^H @%¤LºcK¯2JìþÜÆ!C“â§þñá!V£_Qƒ%ÝÐÅkÐ8¿»¢(ÑhÃE£ —É8èc“ HlŒÌ¡‚8Š65=ȦÉ3ÿKÁ1‚‹rr)t%:øæÙÒÑ;vÍÕ]ÓZ¦*O}­h# J@Ïy6j6 [ñ51E$íR $¤¥¡êinÆ@é÷!æ ‚l¥qJÝj™ËÂ\ÌÑô´Ýt‚ÒóÜŸ4ËS&?<ëbZ/ÍäZPR“²®eþÿ kFr2õX]ÄÊIÃXcÍï·BÿhšýºK£(§>¦/UMÑ X³™rm¤uÝA§B€Ò™¶K?êBù=°ÑÖo•Jajƒ‡SE;ÃÊ´HèS L±£²`û×@,ö°X.±Ò°õC$gs€{!¿‰.¾üöùs'‹Z¿šøBf~ßrOÐj…ÌܾDP¡ªˆBiÛŽ:¾õÏXœHºÓ'îÉv”>Ù½rì1*ˆ6;f>/XObject<<>>>>>>endobj 4897 0 obj<>stream xÅVÛnÛF}×WÌ£ H”¨›§§V‡ ¹° ú¸"—ÒÖä.³»4Cù÷œYR²­D†R(, ºìΜ9sæŒ>bšâ/¦ùŠi9¸NÓhŠOvK“õ”.£9%9ͦ´zG«Õ%Y85¥$J]—”Â9zÛÞð›+ªµS[-3RÚ?ÿ%ù{0Y/(ÆñœÆ3žÍû0Ãd'Éykô¶hÉ·îp@i…WF;V’·Rx|áù¬(% ^›)-lKBgø7º-MíÂ}Q²SŽðØÈTÔQpÛÊϵ²¥¥CDF4ñ  »\]UÆz§ŸÞ¼æZ6!ÃiµñÔJ RãLj,Np¨Ô„U¥ô–LÎï‘ùõu„É{˜ Ô®øàl‚*k6…,G´3¼“vÄaAK)Zà gÀˆfZ¸$Œhm,É/¢¬ SnŠÂ4 *5™¼ê:ò°±ãÙ,šÏÑæ=¯L ÿìa¡uÙµ}¯ßYTŒˆá ;êùw‰^µBè­ØJíňþ’ŒhD×…Ho²| ’a™|ŸöZ8•ö9Ñ}Ùˆ^[4‡#×ò'¿,Š“a'nBV§ÒQ#¬FÙ÷ºB›³º*T „>¸£¬t(öw+ô- 0T0ÐQÏOýÒ·=7#ú´Sþd%;Ƥž‡ÔÄÔMùS*:йJ{ÄiÅa?Bÿ—ªn¾T2õ,&'YJl·%æä.ø>$•×¾†OÁ²¼œ¥Å–ñxLÖψm7Ç ÏV¬á‹hÅ úÍÔp;m‹ç…;H&ê^Ý|e-øRðh¸°&„ë â°(Úrc G/^ðºH ãX¿ü—0FÖ÷¦0)ÆLåðÇ0ØZ™$ÓEY|ÒTTÀr‹Á û­cÕvçÉíTî÷ƒö‡©xiá2vèF9Ù{ÂjÏ®®îÝØ_¾†³"HÙ¾Ñ>`#øá=eÝ ]îWh nIhLà1®Ê{Lÿ†À[ÙÂ52êÚ…_ pšœ†²OÓ}¼ßêCPhiO„ Id™âÎ$,Áš åÚžþùÃ×–ÓU4ŸaN ÷8^òG7ÉàýàÑcëóendstream endobj 4898 0 obj<>/XObject<<>>>>>>endobj 4899 0 obj<>stream xV]oÛ6}ϯ¸O‹ÓÆŠ%ÇNš´º´)öRlˆº¾h‰²¹H¢KR¶… ÿ}çR’c9i† 1b‰&ïǹçÜËïG!ðÒxÊŸ¤8ú5>#,îþ™ÝŽè2SœQ4¢éeL§§~׈âdäÂZŠ¥u7þéá$þûhDÿ¦ƒU5ÏUrÕ[#:;SÅ ëÊQ¢Ëµ4N• ~´ÎT‰Óæ`ÿÎúlðµÙF¿¬E>;¡rïðT×ô£=„8á˜Ü>zù‰éÝ–=>ïcýÔ‡*¹ë^´?º×&ŽÆ­ÇGÌsI}xžD ,¬Ò%é•4â)»h»ßi®u> ÞóDFºÊ””‰ÜÊ.´¦6´ƒ¬yo"?»='~Ïhˆ †Ñ¸­ø ^J’Y&G:{ZK¢Lw¡[Z K¹ri™Ëµ(I™6ä`jeô¶&ωƒ–œ0 é(å¢ ¬¥º1†ÞèÍë×ÝxŽõpµ$¢0´Á!$þÖ•#öÀ¤o t€7Ë2*¥L‘T) f®Ó$4Ti/@•ÊÒ©LÁ 6JR¨«Iñ†ý…¸÷i$ÖBåžAP©M!òžB"ª4h¼¿¡ygPí0š2A„Sú+†OBRÂIÛ•7Ÿç¼ ˜é<׎YqµPFc’!Ä2سäUÛoÃ( Æc´ƒtÐù{K®^1’âðtï%:EÂŽÞwxY6ÝâN2Æ©'tC‡$#š®±á¤¿x »ç‹‚©,Á¤2û¼£.´·ÉR˜W§#É{ïê%eXI€Ô­LäyM¶Z­´q` ½ûöÛg0,GY…ÁV0@,-Ej^*Ni©7-0.eí-ªÑXÙ­•Ú‘HS¬‚HXíöªàj­-èm„)9K[%K¯²C(k+™¾\ë–%º ÇWô­59>®(†½cä1ÝËz‚3Ï;øJµ|㸳ªN-]KïN\mçN‡¤Ü9J]w¶}ªž³pðrM©¿ýˆ¯µJi6x5;™ R%g'×<.¾È SÖè´J®­K'¶}9÷ˆ¯¯îÿop^ìÃþN.j—)K÷Aɵ’ß+…N…ÆD:GŽ®†úHHÀR‚&€$*Û0Nêy/Œ®ÊaHka‡-îÃËø²ÿÓ×®§5¸NºYã;Û}- îF%¬£ªä¦Þ/Ç^wó뱋„ÅЩÒBiè®ÞAc%)L ‡!ƒIÃh"Uòø[CÃûב€nÁ½V^œ´1b…ݳž›l¢á5ÑÆ`j‚Á˜ykÄÀ’DâÖÄsM¡Åsßëù_¦s{«Xin„óöâãWýà¡»u¿ý‰Om›ö\ãêpEÛ¿fƒíìä”j<ðRsòìö²„áåy0Op|„Í`À‡ã`DuR ”p(Ç‚b6»‡c_Î }Ú»Ž^t|a'£i0Ž0à0_Âpʶ>ÅGýÿLE“endstream endobj 4900 0 obj<>/XObject<<>>>>>>endobj 4901 0 obj<>stream x•VmOÛHþž_1ÊéÀ¤ÄÄ„ðr•®´T‘z¨WÂ,¡½Iöêìïš$­øï7³¶“Ø!WïÎ3oÏ<žÇ†üö Û£ŸpÖx7ltÜ>\ýJ'ptݾۅáüôÎ<·×;…adou`:BX<Âòáâ`øO£mO"ç¹üˆ–øñ!Ã8‹8\J> GGp­RHbòGˆ}|¼``¦B%µI³Ðà•Õ¼‚œI¡$|†•§y$ßK¯y‘ÊF1‡yýy¢(ðä‚"Ä1Ÿ°˜¼_½yÓé^ÀægÏskŽÐä}ÆÁ(lŽ4ã³OU‚øXHa(^¡!å™HyTÇû8ÁÁV:X’ÀÙKðÌú [õ4ž+¡=CâÙG×gàùÔ·6–¿íŸsN]ßõúðK‹D†Ï°†kÂ9º>ªÛ©ÑöÝcjÜí×ÁGÐY’¨Ôh›ðÓ–1è¥4l#¤Ødjâå[Å*üv+ƒ0fZc™§<†É“ÑÆñFÛñ L óˆËÈbñ§ 2f ZÍ8Äb†XTbíÂýŽUŒŒr‚ÀP°î¡JSšx K5Îód7¹Ýö}·ÛE¦GNY¸4Ë„K6ã®ëÂ;¦ù…Ïõ[Èó°oðÎ!A–a97n‘Ñ2;ùë|5%°† œ {ØÛ#ˆÑÚ/¦}¾é!p*‡ÖaÕ®æ\è–\ ”jS5çOÄ]êZYšœίe5ªHDHäЈ'JbaYòù¡$§"cQ O‘6#m„ÉìŒÑy°l ™,¡×ÚNFUu6:³ &pþXZ KãaUVDÊ•_8£H,dV`¤2%yKn*½y Ú¯@£\è­¾ýÔº[·>$©´Êg”‚“Xµ"8}x!ºõ<Ö:w›#R}£¤4εîi5&ݨ·oœIì^.Kÿo<¬6S*p;øûü¹d_à¬çy¾…díLe+>)¤_0”£-’£z8ÖjŒ“á@Ãfè„¶»­õ lµ]oJ *´¡_ìa~çØ=éž@ï¸ãöËm¬Ýu;ð^…ö½f7‚ÂWD~·}šï¾VçNQRNzH»:[;éô\I»˜xÞ)!|6þlü (ö›(endstream endobj 4902 0 obj<>/XObject<<>>>>>>endobj 4903 0 obj<>stream xµW]oÛ6}÷¯¸°EIcÅ–ÇK‡.m†]‹µúbÀ`$Êf+“.EÅñ†ý÷KIŽìå³C‘ ±%ò~œ{Ϲä·NŸzøéS<àßdÞùuÔé…=<\ÿ±S:¼ü…ú2¬ ‡4Jýû’à$ŒÂ¨GÒvS™)-SÊ•“VäÅÞèKçðòˆúXÉ{»ÑQx„ÝÁ§ÏW¿ÑBØBäf’R™ä §Œ&“QyŸ±¬ŽTÁ$U¶»·˜<:cig‡&óUQf™ºã½ÍÊJx?ÅJ;qò{™ËÌ%É[1_äˆLXé]Y±lR:mÜØsBæÝ( ãßÒàC饭’¶âù(–ï*PÆAbtá(™ Kût#òRŽ÷Î6Ãìz»q8œ°]]Î¥U %Æ|mÁû½Á|òà\i'§¨Ò8(u¡¦¾nFO)ÇŸ: $Çð>–Xeë27ÂÞJ©)¯ó'S:mÒ)œUì·nšÿ—Õ¼•í‰GS¨¿äÄðœ0þÅKól¬/y7 íÓrÀöûƒí!Ž^àáŽÈ[ÝùN}E¿ƒ“vÝõÌjpµEó´Vs¥UASu#5‰kS:²R‹9?gZ¯y£ 6…Í ¤VŽœ¡kIK+ ™>Þ#5CuœÒçÚëq/>¥ ¡w·B»kW•dÜQt—J þUd | fªJI¥R;•)i½r<ÊUF?ùÄ$§ AK½liN%šsIDž{6>¡W5„u†4—nfÒ.J ;._ÑÊ”¤eN±‰ÊV²¬Ìó¶‚ÖŠÆ‚J'y™2º[£ÒÒ:ºÇ‘¬ƒßWwðŒ÷h]¦m肼DÝ> ¾™ÏîK a\ªbƈC’ x‰Ü™)àö‰hë-ö{¢{oOt3Šøàp¢¢Lf$ªi–™<7KƼp µáfGU‡¤µæ‰DZsä:@ç´Óâ£I5Öü°¸O›±8Âb^ûŒ¥1–Æaÿ:Ó²{7ë+š7CÈú>fVŠ´›´/ò3VLåæðòÓ´5çƒN¸ƒ[¿™£õøvÞêÄ[Ý´ÐW¹ZB Bº„ÔÜ>­4ÌRvÃGº®‘T”AÕ8Ô†nÍáDw½L½¦¿"ùH„lqBIj³U¬¤´ceØ,É?›_ÛÉù ÓÜ\‹œ§’_ø ˆŒ ˆu×±6¾³º0TéÔ cPi6eªá•Ãk×kÞ³m½pnÒFb*Q²˜Ø©/67Ÿ——ÄÌQÔJ“–3H: @ïØOã…{½®Ø B@üêÚTmú‹„€¡Ìš9Áq&Yöêu,~Ì 8a¡” =-ÑzÀ³)“ˆ—Ð9 n>0²¤<ÇéÅ«W>ÁZØï޼ÝhÀRê ÑÛÛE®ÅýŒ–eî8êúT‰C#6©Ì!´­§›-½Möp#ËG-·Î¿[pÞ²é& ‘¦UiÄ:Àö éM¨ç†âc1IË™b-³›•ÆqÞ4#ë?ùÐL@ãx0,.VƒÜf`-ª?‹­ï¾0‹•WmÞ¶ßý¼ž\çÍ0ØxÙÆhrÔgt¸OåÜÜ 4ÍH9§ýÃ*a}óèÂãø÷¢cü÷×>ötã°GoL‚“;®Œ,oƒ¤V«»'ÕÁú©ÛÓqoÆ®Nè¿~È6ÞŽ:tþS.Qªendstream endobj 4904 0 obj<>/XObject<<>>>>>>endobj 4905 0 obj<>stream xWÛnÛF}÷W òÐÒ‰DÝlù’Ä@âØ…ûЛ(ëåRÚ˜ÜeÈ¥µè¿÷Ì.i“r`7 ¬„âÎΜ9çÌäëÁ„Æø=¡ÙœÿÈüàãâ`ñðáG¹¢Ñõ˜Nã-RšŽi~6‰çóZ$þ­1-dDô‹5—¶Ø‰»L-#iMåºè‡å!½§DeÊ©·Ôý5zM¨ÜnTEðgËZ:[ÒëÑáâËÁ˜†Ü’ìßÒ„LE¹~ÌnüðwÜrõ­È´Ô.Û‘È2»­È­©¼pÏ^úï[Îat}DœDJC@0œÎ¢Ï¥( UV”"ßP_Bim¤Ó(„¶:ËÈXGwŠÄFèŒ"müÝN”+å(fU‹•Ši/˜¯L= gS€T—•BП)ãóò õ4üZl²¥D—J:RiÊ\Ùí盟h˵j³"°K”ÌD)¸RÒU/•µ0I†ÔóZ®)Ó÷¨ÞìÈñ’råÖ6X§ rºÛù‹â&Ôôˆ«úäIÓEA”—UÈSUzepÐY*JµQÆ‘ÎC›™H4&´a­ I´³ç¶·ŠéÕ©o§ÔÀuùæ Îæ…Î+÷¯W÷²ùÖ—$m¢h»Ö(S8Çl6–jtG$Ô€åv…"´ŽoG¹( ~!*.'øZ`Y”†·¬‹Ðkpö¼}ëQŽÃé4žÍ Î$ ºînpí?mÚtˆ6VÅe”ØÚ“pyè©Ý‘×ã;H¼«Ø^¬±Xë t A$Éé\‘\+y\’À§ÄBô h.‚42 ðùt@lO*¿®<Ȧ¡D‹6Y¯‰¦X0®^­Òxñá¼è‘Æ 7`<Œ¡°U¥&ZÓö°žÚ/÷,-mN?C–úm‡ )'=»G×g4A‚)ìw8s÷NâiS·.AGaÚz½$â9(]ñŽC"ca÷˜F„[› vðGïæ½ÈÂ``&vm€ ”U¿E>QøBÁÑkQvvìwSÌ£0ëK ÍÞäªÂ òcÔ^YlBøÄcK`›Ôe»¢YYç˜ß¾Œ tÞž„ÿ5xc›v×ÿï­¾<5Ÿ¬ïïx>/XObject<<>>>>/Annots 1656 0 R>>endobj 4907 0 obj<>stream x•W]oÛ6}÷¯¸À¦ ŽjɉãfØCÖõcÀ¶Æ[â` %Êf#‘*IÅɆý÷KI¶•¤éЉ%ò~{î!ýy”Ð? Mgü›U£I<Áþ“ðŸïFÉì4žÐÉ<~E¥“³xÚ>”t9:xÄÚ4í7†µý#Öfi<ßÛý´8¢Ù5½|ûŠ’”2šÍç´ÈC"ZdÑYœÆé½6Ú[S’Ð9}n¤½'³ú$3O¢Tk]IíŸF/ßžP3vtœžÄ'p]hj×PYX‹‚)†™ZZá%å¨q2§Ê8_ÞÓVùÒôúÅ ò†¬ôÕû¸„%ÝT+iÉ´º÷ÒiÕxÊLSæ´’­/X*­¼Bì¿% ºV‰U)9 $Ëåç‘pä6f«aUšmL‹ÜmüÞácÙH¤S–ìVÜ U² *³È2éⓇ‘v-=•B¯±Æ^ä€Öì¡ÇÌTµ‚¯ªa&}® C÷ÎAœ2Âi<â)2£G]?ú±ÈËèâü¼’ŒÏòè‡!äÇÁÉ4žÍÎØ WÛG9ì”pC³ˆ\-3U(ÔÂ¥÷PöÄ‘6žîkêÚX/ó˜Þ܉ªFµ&ç}¨' rÞ6=»„[FÉlyD—ôq»@¤<¢P1šêÚ½þwøØÆ>rÓ [ðÓhÒÙl#,eW”`¤ú ×Ïãô‡CÀUmem · €_[coHXÓ`FÀXÀÑfû|¥ßå²PáAâ4Ë£š~(Û6öm 9§ ï­Ïåƒî0/úÉÛmA² ³Ðo ²? ùËÇÍ ƒ˜¾V·ȇÜGGî¹§ô^¸ ºUùò.ºÜ7û½h<H—‹_ÃôõJ؉nÒçÀ=ÿËÉÇj4~¨ÐûÍUSzõm¢nC÷ÆÃTvìz¥zdÎJæ|'&ûõ2Û3µU:SÌ ¨PwBƒ² ãøt່†ƒTä¢ö<ÀjЮnÜ~Ú¥U'ôA®›j/ï ÛÎa¢¾Ü²>“Ãä´—ˆž™=+‚²s™”¸—$ øöÈ?usŽÝ‘÷p­%* jü課Úá¾_Xwcú8ÈV=GÕSz'‘(ëÆÖᨄõTh°Ò€µ±;B]ù¸ñ¹q‡ÆyÍË ›†!"çóós‡cl®½ƉúAp¢Â½J€Þ§b(ÍÐߘ•ÁÝðÏ1ýV‚U ™lköóàŠ›o´OmXÔp{QŽvÚäp÷‡í[…Ôæ+ð—½\ïçƒÕtXd ÚVŠ›§ ãøSû­p1Ê‚•²µ˜w7ðtrŸNOiv†/|߸ÏÇS|‹øÙd  àòØ çt»ùø¬½u}Ó7‚ÓÉ,ž¦ø:€I:a‡o£ßGÿa÷Õendstream endobj 4908 0 obj<>/XObject<<>>>>>>endobj 4909 0 obj<>stream x­WÛnÛF}÷W Ħ™¶$ߣH»õ[Š°È‹aE.¥MI.³»”¬ù÷žY^,ÊNÚE‚ÀáÞfÎefüeoH'ø3¤ñ9ÿó½wÑÞIx‚Ý?fAÇwW4Q”bïùå%E‰_?¡(.ÂqxN·NVÍ3IF‰Î©¨ò¹4”ŠXeÊm£Ï{Çw§4Ä!¾æhtžâ¢ Z*K©®2’$_“XÂdþ&Q_¥%·”ÝÊÔܳ!]d¿5ÑØRhG2Meìüî__¿¦L‹J,$Ö }ütÿ[X‡ñ˜ÍÑ蜃à$.è“e‰˜L¥‘E,ô“á[•«Lrš_ÌEFEw¥yåüÆX—›£XÖ™*v6NÙÖªE!eHÑRnðµÊx ©¾{, 3’sI•• ©‚Êjž©˜Þ~¸·þ("¶…&[ÊX![•¥6ŽRÀQçî=!uÉõuél]CÑ àGF¬«Å2¤?­4–Ö>ÀB" §ùHÜÚ('™eH¯ r›R梴¤RjžØ†‡1œKU,ꔜµ²y©n!Ì’(3z woüŒëKú ³M®M‰D@-t`Òª%º =ÿ 1Ù>[ÊõH4â(Ãñ8#âÐõºaói%¡Ü‚åBÖbÒïz-ñ•¼äÜÁYiôJ%Às#k¶8ÙB®û¤u0{òÚ¸ûñäd˜Ôä^«,£R ZYö†N½_Úmp×_®‚½ð(´Üoß¾ Çlá#1 Çcü/ ^Â/"—Ó`6‹E–ÍfÓCФu×׎fLßÐñ1½—©¨2Þq¢ãš‘ÿ°® ~‡ï†.È’ ⯢oÍ +6 ˆæZg´}ý4P…£‡°w´ižkaièìÝñýMﱪˆ³*‘4i‰ì¦w ôd¥UBþQÿäôð†Ê;úÅGû†ˆ“m/ê`lµÆ×>ÖCÎöhŒBz~Á¹Ý>pæ©iô)ôت…ïogÉÜ=V]²×æ2ÓëîuåQ+­ä³Þo#í4.:¡giwM¶Ln¨9Ü4F ²ÒPµ}g‹Çöâqµ8pY¾¢EƒœÊÕÍ¥0ȈœõÓ˜•ÓuÃÙY{¶16º JbS 9¤ B”Ô´ÊH8ÔݼTੜmB‹ZŸÑ ¸ª¦ŠõŽ6ä8»_™¸:Óe. w]ùu·n+¼ÚÒ2ÖqÅ`ÇÖ²Göž$]›¢5ë¤6Ç;ºA×ôÙB£/ó'6z<ãKEÃA]Ä(ùó¡©°¥=S 5Òþ€÷Á-}£ãWa¾:†¡QÔ ¾¡ï-Þ©;.C*%ºYòosyšÃ9É›ÿ#ÎãÙ,FÿœÅ=Ú·(œ>¨Ú2sR'È×XQ93v^ªÛìû!de *Ì'äXó)”È_ˆÄUŸ%áõ˜üˆêgic¾ºˆb< <·MÐn‰ëmýiu[†/˜[W10 Èq±;”6ÃÍ!oge–n±Ó†Õµ)¶ßa¿ÝFád¼,Ô— 8äj±tè¹m瀧yªÜÉõ`Lu†&Í÷÷à³ ‘g~\—ƒãŸwÊipÛ– ˜¼3ÿ„ÉÖ½ñ²?¾»lfþáåix6>ÃotWáU=Æ±ØÆá ½×qÅË+šCFg®w]Ô®ù¿÷œ‡ã~éÃh3 ùºÛhソoL™endstream endobj 4910 0 obj<>/XObject<<>>>>/Annots 1658 0 R>>endobj 4911 0 obj<>stream x•WkoÛ6ýž_q‡!˜R8ЉÓd™KŠ}úpQ 0Ðe³•E‡¢âdEÿûÎ%EYRÒvC‚IJÈ{Ï}ÞŒhˆŸM¦ü›l†ñßðŸÿy÷ú`4=Ïi4ÆSÚÐèâ<>«ŸrzÐ~ÞÐxxÞ¬å·íg¼=íîm?ã-üœ¶,·Ÿ74žÆ£ÖÛßç-¨¯YÑÉÍ^Æšg@BÓ‹Q<žÓ£µ©4„¸W)"*h% iTB;°j@³¢ÞØC/.LÁ¨?ܽß{yÉ$ô Ç„ƒIª,~±$ŠGÊÕÒóȧ&‰¤Lå’q•Õv«Eæ©ÒùŒé#2X*—¡;m>:ßüó5íTžS*™—µ½C…c”´ã©JÏ›Údõ÷‰¯JŽuS[Y[®õŽ *×;wÈ.+“u¡î*IKQ*.¹G®¸0)"Œ±3÷¿P„Váó`À Ú ƒ’cåV&ø¤þm*<œ¿.pŸUM-º0ÈÒÆ´ç9pµé½aWÙˆbŠ$+Àv¢A–ÃwØòÝó<›!!Q›d®½vølŽæÄÁ˳}âP¹*$~ &\søYI^¥’ÚÅÒYÁé›Ê¬n¶‹èEVÜn­Y-"ßG®3wÎäá×z?ú0JºYn9£‘LÔõNtrB7 ðd¢gtʽ1NÂ}ÅÀØ8Ý »Ì`ÝT‰Ýoë‚rž^¥ŽN²£Âÿâõ©£+ªiø Ù“sw‡G÷؇øµûE—ÇÖHÄ$ìæs‚-…'á÷_ûRyW¡öB@é¾t’€BG_Dô‚ó>æ]¨Mˆ|gF|u“~eV³Žá&ˆ½aÏ"ÂêÅÑÌ×â^ÚÛ:)ÄÁ"ž,Â:Â<ý6j¬ZDnÅó°ŸMÜá-ßpÒzºe$ý HÈ+’&g ~Öu ŠèýÛ¯Þ]·‹ˆ~«Ãà ~SÎü¥!_¸åfÊ”Öu¤-sʪŠ’Ñ·ÅÈn­Ð¤]O3ò®R®áê–Fñ¶C] 'H1‹Y+²Öbžèe•e*áê¦zÓA Í-ìá1Lçäz©Ðü£èûåA0D,Žšyˆ) ۮת@ɓ쓼g­”ˆMÚÓ¡I€ÞÖõ¼j¸A¢y¡ã‰²¥ä¹3PŸµ¾ä¡üÂiÎ¥H>{(]Q“4}ç,X݈ƒjå©ÍïÈ<ÝXNðleÓ{å=‰QËý ï]"PEÑíFèÕÍ^`Ål &}˜›ëGÐô‘?2vBîúA 2!­½^ͲB¨òÔ)j—Ç…†¶Ñ¬s ĹS¾Ê¬{[…¸ˆ|E è쩜ÅW]{W„7k¹cÝ ,ç’ PTkÖ%¬®˜ ¨õVÈÜ×lLë ŸOä’o¥!¼ Î¸B7OXkr7½õ8óK½zê…ý¹\m¢ë²^†VÌ­©è\5yçe”¢|ó€êå£ô¼tfë¾ÕD?ùu/ë>2ÆeîlrFÓ—C/ϹqOâ!ý¡“j# ëñ&0êןûfÊ·„ š3F ,n>ÈM\ÚÂʈÍôñγá4žŒq»å«ÊØ]=®çoþÙZŒsendstream endobj 4912 0 obj<>/XObject<<>>>>/Annots 1673 0 R>>endobj 4913 0 obj<>stream xµXÛrÛF}×WtÉå]º"Â$xß·c9~p’µ™äEU[#`(ÎÀ ¸ˆf¥òï{º—Iśݕ¬¢ÕìéËt÷93À¯WSšàß”fKþÒ«I0Á7ü1åï®fË`BËÅ2˜QJ‹i°l„„>]ybJ›I°òtÎn>÷ìDèíÝzÎ>;³›…b·ž!-E`;OLi:[pÀNé É.Ã`JKØÐa8YkOé 'kg(;A {;œs):Ø-6MeB$ãÙa/¦´Ü`‡½Îás†\z'"ÑùÛï•. êÅ­Øð"p@Oäni¯ôehѶ…§]…¼Ÿìv®Ù¯Hì×—9£E·V´ž í’GÀ³õdhW'ZO†vÍuôl=ZT%ì³òä” I¯õeh§'ZOfíf³/C‹Áñ=»Ra[^©DòJÕj]iz­'cC .÷¢×z2´;Ðz2kežz[Oæ É`tZ74s7ÝëoVÎØávÂ@앾 -Œ0¨©s‹O®:9§…ìÖa2jz¥/C‹}cÜ:Sç&ìVèe!»õD„\ó w:O4œN§óDÖ蕾 íjÅét¦óù2Ø`6§([JóuÇNâ„|ÙNó½,*­bKm6üzë­°mñ@¯oi…owàä%b­BÚÆÂÆÚF£5ýPè¼°‘.K“=¼ÚþËó"t-^!–ï˜ÐÇ!*±XÂËèÖ$šL%uil6´í3˜®ã1×nâÑ]¸\Ñpýy,^=žrºM 4·EUÍþ¯aÞØ,6¶¢zcÓÜ$Š¥gŒøAE…¥·Ÿs•=s ?ýüþI¸g­àfC*‹éÝw?bW•–]=gÀÁôJèX'&5•.$,¬›¡ó•/£ èåïôº–?¯ih-ÓÕúqžB3kz1ùâ@»õO¦ã²ùýNa<›“…ó?‡4T Hë«d )çö˜ëTåÏÙߌ>€{(m]åuõŒÐÛî5½ÐEÑìóÅAg›BG•yÔÿÕ–_ß¶T9Æ¥g¶”6ú„)c]’©J²‡Œt¶WY¤czÄ´‚hÈî¨BZo¥ˆS§¬sáBY]V@œ*âá’“m´(`p¦B:º%*êD—}k‰Ü¢¬Nï5z°£ÔÆfg"áÁR¢I:Õv±WšîµÎà4Öœ©))Ú«øÃ —Qaî±áÒ¦ZZÙ¦á6Zê¡ÿ€×È‘5Ç™(GWQ*È7Èóó¦/÷„K¬×<Ä[ëN¥X#c‹Š´sGUe±»¦Hq§"}C5ò಻è8S娽lúå¾nÛ:ê„ó [šòo­)߈wÈÙàº5ƒwŽè:·&CØÀ\ŽÅ`,q,ÂàÇŒ=ßœ&ôârBgëžJ¼›?­¢½«ˆÅøÑ݈§â`’„P-*tbU,‘ªa.Ëú¾Ô¿ÖhùiNOÅŠu”¨ÂÍÝ+i,jâ˜ã\è-°CS†£fš¯ ª8zÄi²?Ô˜m`&;é[Ù:uûúˆyÛ©:©n.5ó‰Úqtó!—˜ê 0(éhk ¢‰v0Õþ’»q“J’a'Gds¾38ÐZ•(öê¢0¿T…j/lÚU¥ëRªöª’Dìg(Å6ûkE…òËì¢B %]+TN Û#æÞ/1׫#†½8 *e¥Sr’³ª?›Ä êƒT¸í®¼O‚1lÀØßÉ.CQòÅýòÑ0ñ ±¹8zˆzªÞ/:­uGrÝ¢Æú³JóD ⊮wÖ~ ˆB¼u‘[Ì#(Ë…÷âbRÜ?K‘Mœ#é¢Rh†É0©‚v…M»Z Ù¨%ÎÞ¦Oî ® NDRQUcæ†ízЙf¨¡ý*;Ò#‘£Ý‘eFþTë~p·>ÚYAº8ãž± <gÌ ²“6ܽ"UÒAƒ?ðÿ›¯¾"x*Kô›çx0Y©yØW80á1¯¾W¥·Ë'ò÷0TéY¨“Ûa‹9âÏôD%%Žéé°°\íK—Me©6UÕ˜ªöË «¶³Íy ¶Tö‚ƒÒ£rbTF*~tç{esáÀ²ìŽEÁ(ƒÜ%þðe®œ£Ÿmñ 7—‡`âshÖ>ÚsxÈ“<Òlðú¶›ãqS•s.ëðEº[vì³ÃpÛaO}=ųà"pÜPDw)–?»:!³î¾;i zQíÄîL&Ïk¥ƒÔ€à8Ë9—Aò–›á1ðÉGÂ? <ìøÜÒ.ë s ¦3ÌaÉ9ä.­Êþ“e:)å&Ö'?:÷¥±çÓ¼§uÅèéƒr…§r†"&~ˆÑÁ°º™á9.é½Å4©B®µHÛd@ÐýÑÍ— Ó] àšßJ áÿÇô.¦§þžÔ‘Aè‚h ˜ó!Øn@^Z°ç÷~øþãöí7—üsÉ¥›t¡æžÉ4¸vÇ_ºÿüéíÇOï¿ÿîRŒoqĨMŠ7w£{“áè3ÑÇL™ü5ȸ¹½G6㓇cKQš‡Œ‡þ\=WÁd3å«ç…÷A ¼Úž…î9wÎØüíöêWÿ›ðcçendstream endobj 4914 0 obj<>/XObject<<>>>>>>endobj 4915 0 obj<>stream xW]SâH}÷WÜ*k$@dö #( Ñu¶¨Ê¶I™ él'(ì¯ß{»‰Ó×/bÒ}úÜÏsóÏ‘ ü¶¡Õ¡sté5¬Þ|ý#Wp6h@×j»„f:_m«Ó¹7P«àú5øä+Ýúk`)4v »Ñ²mXÔ|!%Oa¼‚LÀüÏáuݶZ–m/N¬÷ÇQêxžÔèQo4ê_Ï&ÎÈpÔ_†1àeÍcئØ‹"¾’œÑÉ~Erƒ¡DÝ2 Ñò2ÆÍÐùÖ¿3˜0ôò2Ìh8ŸAL0´¼ 2¿éÍ*PL Ç%„ëûá¨ÿÿi\oÈ—@n{½ “-·ì™1æÎl8uËHS#õe˜d%$èh(ïvîà~‰K!á Ø²lê{ð‡n»ÊTMS?wˆEÀ­)”˜î+ÝhmËnO®îG½V‘Øá?ƒñcl#Vo•¨Œÿš;7ý±15L8ÿ¦þšox~n oâôƦú¥ ¼‰Ï6‘Äí=)U€dì¹ÂiVÅÄDeÊe™Éô¦¢êÌæàò’1Óá· SŒÆLßS¾»7s+2š²ÏÖ".1™åQ3|b3+Ü_~7ìU·LÛ§} cÞ¬t©c^ç»U$ Eœ–À\£VhŠ0×/Gø±2]áÁåÄâlÐ’›¥Ò¯z³uÐËÚ0a†tO•ÞA ”+…lͱ7D‘x!ñJyb iÆâ€Éœ3çËØ0_Šôw}Â{E®7›V«…úÔC“ÙAí˜cÅ-‹FÓxý®=ç &÷ ÛѾË${³ò1>§|p¨&W„F®u3Û&d¯JE5ª‘+^ã•slª<£÷TJE|÷!Ü:fÁ+TÞ±-`vðÛ$ÿu{Ì=Ötû³;²Ë¢¢Ã•¿ÌìoêY‹“«tq‚*¿,.æQZìŽùá^aû¢¶8ù°ñÓ@aª½S ‘PÇR·3–$œIò“ª]¹JrÞ¤CÇ ßø°êTnìtðìn®[½bÚ,šøª§Ÿæí‹s«Ó:‡ÎÅ…ÕT%«^ÝZV®„¿¥bÔŽifXÛ:ÇÅõ †ôéÐK­À wTy]ÞèX­¦>Ún¶ ¢ïýqôzû‡endstream endobj 4916 0 obj<>/XObject<<>>>>>>endobj 4917 0 obj<>stream x•WkoÛFüî_±ˆaTJDFK–´€ãØŽ¦GiPT…r&OÖÕäQ¹;Zb‹þ÷Î)Y”e'Éåíîìììêó^‡ÚøéPoÀ¿Qº÷z´×Û¸¹þgnèåù!uÚ4š²ÑàŸbo€Qã4ÓwÒ8K©ˆLFÂÜä©ÔŽš£¿÷^žãpÿbcY^¯jƒ-Yg”¾!›“å:–1]gùu"ésž9iiÜx¶|6n†õó‚6.i,iŸŠúéë‡.NjüYZ’Ð1ð|#ÝLaš™ôA¨[§5*ßa•Lpv¨ô>î޶Þç‡A÷cû´üôH`—Ó­·¤ìWÔ^¤37!ý‰-”•-r¹Ñ¤ô&Ήº•Û~÷·+ÒhßÞ½Ît``&æLÖÀ¾ÿxyAr h­ÊôN€J6:¦Îa\¦€gSÐïòe܆}ò¾c ÙuÃá ½ÑÜdw*F=…&©gBG MI¾HÌŵJ”+h¡ÜŒÆvº±œ*-ë>žå½5c¤Ža¼m+##§î¤ é<3A¤óD~¿z{ö8Å. êvÃ^Wq£òJ'WW'¼=ûé׳«qÃsÙÒ"•ã&¿ÌØrk5”N"ü[»Íæô\ËÅ„Ïï¡7P_ÒÊÉÔŽ›T·'"#= JWô&©H’,7¬úGfÓòÁ¸ù|uÄ«šÇÿjWw™Š)–‰trÁêd·ËûÔH ƒqó©S}V>$5Ac®l1yñËå®Ó«ÜÜŸÞ⯧|øÈ×>ìnhøN$»¼­ÜÐlñ”³ƒ:j,bFø×X€$[t©Ý‰1¢ØbBͰ”Žñò¸a~/Ï|~Ðí…ˆˆ4ýçF¥Â4ÏÍ<³’²ÂóHG ÿ!e·PY—e“Y>"ÊbÒð‚¢¡¡"¡Sø’hÎHZ‹¾ðiQDÔв@‘–üˆƒqÙŠY^Â4©b&)¢yòûþp¤Ò¹pPŠfˆÖ þxPåͼ,Å>|~>UÆ:Ê¢CFB,vA°³Õ½ªqWú ÏsƒÓLšhëb&5¦‚-ÓÄØCðË9”RÆ`ÒLþÆBŸÜ î¦T¤:P,·9pòÚVAÚ8s¡4¡ak`Aé@ ê{IB ‘œ;k€Û:xæ—7æð#Õ†ÈCD0·í*ëR¾Gð>2ÚX?0ù jÝz•ÂBy˜n¤–†kZrG¤ðØÖä¹Ô4E1[@P|›Ý|UDגžJ%óšƒ×FÅW@ý:W‰£Üò!ˆ=D‚'ZÙ,ñ%–N_¼ ä7O8 ›Ïç™.Ucë~.q÷ W3i@§ÇÇ>­‹Ÿ?ÐÙjÖ}a<°‚1¼j@«Q*ÉÑV~! F‰XEõ"–¥ÿ†™²_õ曳×.ÎÇiêZaB½ˆ¦h{í ïÖÅÒ˜?›L~?™œ\]¼ŸLJ™yT7>2»sж…4 óF¬;ßW[¤‚ÛòÎýzÇ¥Ü<›IæG±ËHA)<¼âm³áÖqÕN"›Ñ"3·¶œï«™:üƺY«>*Š+vlyÛÝ uú{êóÈ\ð2¶Ž[çé5* Ò®Ö]Ê54 »"¤·ÙB¢7X ÀÈlŠ= <°y‚àžÆæâA²4ài UcÆØM¿$” ¬t-'ô}uS݋߽¾~ Y1åÙL"%,Õ¯@• øñ]*Då'Ý£Dq›;2X €¸‘V‹)´]âýý­Ê¢›1B¦§7¨oe;v¤ :}ðU™A®ªG-¡ç±ù éº]ïÐÕƒnû0ì÷ú48j‡ýÁjc zaS;òß‹ü$c 0«Kãà¨\ûXxÞùïPgß:íý¶÷?|²endstream endobj 4918 0 obj<>/XObject<<>>>>/Annots 1675 0 R>>endobj 4919 0 obj<>stream xµVïOãFýÎ_1‚KÏHÁä„Ъ8¤êÔ–œú%Òic¯“íÙ^w½&¡ûßûf×±Ii«ªE±wwöÍÌ›7óÇÁø i<áÿ(;„¼á¯!ýzÇoh88'”ÑÙ0¼¨Rz8¸šíìw‡Ì’No4 Ç4Kh4 Éå0œL.h;«šEÁQ,•Kzsõéîv$™í“0Ë2 Ãù1QR•Ûd”6Ö•íó:/Ïg¿œÞž›?ý“Ѹ¶\ë,“¹ýÞo:«7toß–”kKXTF¦ŠR) ­ôš…Q"Ve"2º¤L-W–’ªR&UJV H“ˆHÒ¢Ri¬òeHôZ>JÓ'»’@wûc¿5)®°šaßpß•©dt$(¯²…4¤zøíþŽb`Ьz”%‰_¤ß˜iÜé¬V-RIkeWt}y‰w± ½×—4< Ï88š)ÿŒƒ)’ö³‘°ɲ„î¢X¦*Sð­lŒž…Ó)Ÿœ­$Û“1ÄHŸè[ŸñaȽ'ê}£g{p)I¤·éæâàQMjLáp*Ø ØÞw°Î?w,ïCê\d .š-´±TÎ|í:Ð"3ò+S!Ju‰«áÒ"ÕÑöÅßl™ è}R mtEkƒxùÝ©BZìJ•}i—ó'£Q8£â ÷ÄËL06ŽTîÓÇ››÷Ÿ¯~z÷¡µ¢„XÍAû£jíþÖz:’9‚ÞzÕs;No›BèT ˜ OÀíÜ–ÌE~æó\¾¾¼¾Ž…ß êP1í#](D‘©ˆJ¥L…Š@P3yÙ(ÞXš 1¯¸~Ò¦Õs Ì_cÌhc<È]þµáz>;–8†ˆt-6%™*/¾c6óC$‚±ª¼D)vCS_Ú¾)؆RgÒª üS–T —Ê.Û¦¦ff8h¡Ø†ƒ Q2J£«åªÐD¥2¤[¥ü*X^jáû+&Â-ôKr=jÓB˜ýÔûjâ:Ånp;FcÿÅ>¼›qM±­y~8?þaÏî=d…‰6¡_'ïÕMD•¢q¸¤®(å”´ûÈÜõà¹0*­°NwX—¼‘NÎו=^ ëëY‘­ÜâÒ5 ÇöÆ[—ÓµaâLõ™ð‰úú’rÛd—^ÑÙÄnúççâÛ*Ïÿ™ï^7\[ séþ— ïý÷Œ?g¹´F.Œ`´ÝÊìuãÅ ýþ‘åºÓͶ¡gÊzAü»N:ÝQ ”Ÿm ™‰ÂµÑÎøäÆ¡&u^ˆêƺ÷L3B‘UQhÃÓBYÈH‰”„…ß‹ŠûH.vx’k×ÀºÞ¯¹‰9ß^ê$,¡RýìÒÇtãëf§³Âsûl˜ÎÆ·Šµ”¹4¨7öx©wƒ÷M’"'|kN%&#ª¦rÈá!!z/‡òž4³^íú ‡gµ6vr»m–®ÿ±J6£)Óí³› çÁõ»‡:róãÊÑÏšP8ìYŸNîqØyFþôfø£“¦Æ Ä jøº¬ùé³ ¬wwZwãÑà,<ŸÓd:1ªc˜`Œ'cLçïuTñléÚ.ŸB«÷›O.üÜ1ÅôΓ"Óõîã'ºá^P¢I»˜ž&áx„‰F‡£ [¸™ürð'nŽˆàendstream endobj 4920 0 obj<>/XObject<<>>>>>>endobj 4921 0 obj<>stream x­VmoÛ6þî_qhÀ)bF²Gi‘Ý–ÖbC…õK€–(‰Dj$Ç(ößwGI¶¢8† ‚Pà½d²E~zúF7eú¯ ?/Ñ⻆pÉ–{'D,ð.›Fì~—b#UµµÑ‰°VÐë´Ý³GZ²("{ü"ïT\m!ÑU-Kaì¹×lS×Ú8 zr[Ng·íƒÞ•SŠÅ)”ä4];©8 ©´uÉ·à |êÌèÊŸ‡]2øZŒÀkÿXÊn¤K ºF“4' ÒBcEÚõ½‘e Jdncx]#8†¶NðÔW3Â6%AÌœ0ÏÚ‚‚[0Â1=‘2ˆ ¬Øúyí¼ëÛÈš0Œc”Ä"H‚X7yNÂCH„µ¯®3TÄcÍ•Eò,kyØëMšE$}ŠZ“"ŒA‰)íɆE5RiDâäƒè¶B¯ÑPsr×^^ê„ôÓªÜzÇô¹Ç¢SÝ‘\mGã‹C© ‘Ï©Øx}ŽTSõÒ-­mz¶'á)ħœTø¼ dêpuÏè¸ÿCµÛÁzâQ:ìÉX3㎗às0¸}äU]>m²±<o{Òöï‹á¾nE}åM†>{’*œjLñª‡îß$=g0êáö`ô9¤ÃA&Ö¢àR74øš6G*Èämîqúq—ôàº]Ñ÷6æTfÇ=¡!5ÜRûãnÉ wL7ù~ZvNx_â0+NCPnÏ•9© Ï+>.°×¹CG[…ÐшX^ Y†ÓuŽhõ=®&ÀÅø¤S™ILµ£ïm?»©Ö/+oè¦jÝðæ‚z%„^p€A0$í&ÝÄúŸµ©Ð—/Tÿß*-ŸQ÷­FKv¹¸„ËpÅ¢kÿ-B3:[°~ÒIS åP$íuFC¶·gW-ĈEðëðEFÛ&n?Jüj» Vl1Ç/3܈áüŠj߯“ß&C[×xendstream endobj 4922 0 obj<>/XObject<<>>>>/Annots 1695 0 R>>endobj 4923 0 obj<>stream xÅXÛŽÛF}Ÿ¯¨—ÊfÄ¡(R¿%“uÖ€ƒx3 Œ -²5bL²µ¼HÖßï©ê&ÙÒŒ‘ÍÆƒ… ÙÅê®ë© ùï›…ø3£ù‚ÿ¦åM„xÂ?3þùõ§›ù"i‘,‚9•”Ì‚…# z¸ñÈ’Ö³`åñ<²¤Y´Æ}+…/ú4¸1K÷¸ î2 bŸëÑ%Eá n²BÎ<®Gƒ»’Øw=šÑ#¥ã]kòcƒ¸‰Pl“Mn0s)»ùÝ"]W„Ä0…E /O#tÀd!“Í^Ó7y•]¦)Ëk¶ùQ“ª²^5ZÕ鞪Ý_Ê œ­œðé‘€šlò!Z,éòüS[øôtÆÞLîéûºVçFT¿3yÕêºáûl¯=’ìã ¿”ûœèŒá¼·$ ÿÐ{¾W¤Ä”—×Sª¢0éËëÉT«þW-Óù<àÕŸËêBPpOmWô ªÀ.3ú£Þ©®h©±‡öÞ!Iêø#aö—ÒûN5 Û´Í+Ô qp^P¿‰¾o*}2ÛßQbÔªu¡U£©Ô¥¹®Ú¯háÿ 6oïî¿ûŽÞŽýi¬é¦Í^½²Æ½pDÓÁ7õ k‚ä?§úÐæ¦’6âø«g¶Ù«ZgmMM©ê–\“|aUך¯¥ÔuÛ1þû¹!Spò[›y{vèÊõÕÌòð¡o'Ð`ÜÝë~œN#ÞG¦@4OSC{]hÛåE ´ºj€*MÖº¹µƒ:o0LÓOêQgtÊÛ=©aÖš5Ýá`Ç]ŽÔîUKgÓQª*êçt^ñ£šÌ‰ŸaPîTª›@RÞK v4+Äì`ez—WšÐ„¬ôoÈÔt¨Í1Çйxîº «ðkM`õ[pØŒæ¥R(d7ê·w8£ÑÄѾUÑ=Ïð c¸üíz‚´Ù#é^`z¯ƒ-q§k]¥šU°È´«Ac>è–µ¸ÐÀ·ëXÿÄñ»×‰ÛABì7±¬¦ÄÒ’o-@*ÓêWlÕ˜» ýRd0áˆUC\…Y¥\ 3ØTuåGÀ¹ÐI;ĬTU~è èÀ4qu‡$Ûíÿb‰2pÃö›>1hv]Úv5âgÓ`x™B-SeNÈÕ«˜já*KÙ+ìd[$Ö˜G<ÝÕ¦”e9wÏ-Òfª€¾/Ò áüð>ÄÔäe^¨Ksú<+®¢€ÞÙ¡Tk…<ûiJaÚ®+Š3å;¤…’dõA—Ë6Ö/‘²±r…H>ÖØö6zßÓ%‰ V²ˆ¼µÃÄœÃ6䬓aËð±ÙƧY|'ýž{ ‚¡z¿GŒíÂË9å$K ÝºÝØÔ0 ´ËVŒL Y×Î`•;¹ –Ú†ajàKP'k·„CÐÛªvó ;ekšb:H'æGYÌ­òæ Ó|—C³ôŽgüœ¾¹ö05%°ÊiB02—øÈ 0ºVèÒ8„î®9å‘åKɃ€ùµÿ!Bo( ® h¢ª@æ./¶çë<±.šòï…“[ɉþ¬ÊCñ$Áw]Sß±’âNÆ¢X}7 æÁ<ü‚áñµá¿Tô>¯2sâB²þÄFàïRâ„:[x®y Þ¢wسC8Ù·@Ö×"ÐUј\’†!ȉµuñœ@é=¦ð×£ˆ±Y¢_"ĘғšO7zvyŽSó©‘@*ôÔmýL©A¿m¦ÊýÜç©Uõ#ºo¡ªÇ‹>LtðÜ^{t8·{S]ùs{éöç6-®O’nÓà÷½ÙÁ°®ÊœÁ§¸qo  õÁWéàü• çÜtá«“õ±¿2®ä ” ‘›3˜Ôñ‹´7\À²ÿW?‰+ƒ&À9p#à˜¬1µd2ê‚—–ñûC?ËLã3Çf}æåÇí:üÚfW:BÉæ‚û>nKá º‡-)&®Ã™vЉÎqíu¡ñ•ñ*¦XðèoW8yR~™é€”gÎa€]É;š<{rÐ:Úût¹ìñýÁ9ù`½Ä½¶ÞòÔaýä…fpÓ{\¿ËÙ\»juޱ³ˆNÓL‹üB+¯ÆØŠ0Ê¥¶xí×PëEÿ‰±‹ï`¡Ý+.*&øö=Ü0Vüèï››ÞüU3• endstream endobj 4924 0 obj<>/XObject<<>>>>>>endobj 4925 0 obj<>stream x½V[oÛ6~÷¯8pQ@qmù§Ù°YÒt}ºÖ@_  EÙì$R£¨8ú÷;‡¤äZ¶·¼l¹ÚyÎ÷}çúWo üžÂ|I?<ïýºêMâ ~Øþ1?,`:UŠg—×ø"qÏñ £Ÿe" ‘Fp ŒsQ–`5ä"צ‚Ý i *È m…²’eY •*Y*€©j]A¹ÕU–€x†K<ÍYe¥VñÅê{oüp Ó™0š-@tÏâ)ðBKe…‰¥?¶Ç9š-â\mø‡HÔ‘ˆÎÝŠ ×I•!‘J%JÈ7Ùl™E< žIˆ^ó#”0Ì ØV”ÀŒ®S)óMÝ!g±Œ FæÌÔ„h#"•D$ŽNÑ *à+© —jÓZ!ßdCZùŒ@™e¶.jYñ-°²K]*9Á;‚$ºzÊDç`P~Ú†%%´o¡Ç´RœBT®#Â0T,ë‹C+3$é¯} B¡@Àu–a¶à]âêÊ@k ß^ɢʘ%ê¬!ß%G^apè0úé[ëßVb÷èpFç‘Þ%œxôÓwJlй;´îˆw8°•Qd#¨Eq“6†O î\Q4†1ÒÜ9L0§ˆnÇÇbÑ|}„7ò¶Þ½vo êCH£6ÓÐ%nmS£}”¼J\uÉ}ð̲êBûŸ v«°0ÛYµ‘RXxª1Šš“R£ó®îø¡A4zÒ ¢ü?#"¯ B"2aÅa Êói{ïÎcÊaQùœ}ežφg- ryde)7Ê:”Êá_2ãÖ];êJd~ñ—»òïÏ¥¦ãºÚsXÎkò%”!¡=XLJ"s ÄUñm+T¨Nߤi.Õ Ò1„¬¦©ÁTíõ¢i×ñO”Ž®U%f8ÞƒLl0óqÂâØL¥04ˆefƒU1µ©ØFį±F¬Òn&´¹Ïµ1¢,4BÃ&EP5z0.ð.SŸnŽ¥Œ He&\ÚPkñýý7a܈gÍä/ÌM@Tüdc;5Gº‘Üwó÷ñœæ¿ëT³x>Çw8ŠÂ´ ®HEbEJôV*žU¸™ô÷ã¾N <1€ï\Pê95ãÌM 6RoÙI»…>2‡AãC'&!ž¢^¶X_üÜõvÛúð+vW®gÌ»êcI²ŽÈý‹3 ¸Q90±*³ÁÉ~AóI;—Ë+¢ø»ÞÑyø\Û­Víh<)æÍÍ à΢Å%Ì…î€,=æX´áYL“ÔñÄÉôõ¦Q1ê;K« éèñYl¬9šóábȃµ`‡_+ÚÙËã14…öþ¸ÇŒLñWqW_mf\5Z®§ÕX"CÔ‰éÖø¡Y‡F ÊüVè6™y†­òÄBô>¬Q³É"¾œ_Âr¹ôûé×oŸ>Žæñî5¯r,s\z´"gKvtåSw^Ü'oa5åMŸÃjI§/'Ëx>à Ã>]ÓGV½?z*·uïendstream endobj 4926 0 obj<>/XObject<<>>>>>>endobj 4927 0 obj<>stream xWïoÛ6ýž¿â¢€kØò¯$mW¬@·.m¾d _ 4EÛleÒ©8ưýí{GRR-;éÒ¤¶lêx÷î½wÔ_gãß„fWü+7g¿Ü³1>lþ+W4º¾ É˜î–4ÓÕk¼Ëü‘½Ï¥Ø:´µÚxU’]Ò‹»¯g£kÄ ÷ôü~«¨?¬õH§s…e!œ.„S9>Dˆ¥*£»µví5áB8ZÚ¢°;÷S½Ã«l–ÒN§Ùl†«¼ç|YIOFlýÍ+Ç4äTòQøtÞ›¿xƒ÷þŒFôk©„WmU‹¯JúN°y‹ÿì½*ԂѽÕ9jtzeæ³{QTê0Udö.,¡ðe'! PÇÛ¯1>(ÿD€¾Î?QÃä×-@Þ’-õJQ„,º™9/¼–±)ýei7‰/©Ô~(³Å=‚vàÖœâõ¤´óÚ¬º‘íbûâ¦ínþç _¶ì‚ÞÃé,»ºzÉlù¼V†*‡-Q)ø·²´ƒSì> n;*h¨¥© §7ÛBÅfú›êÆý;¡Ž¶[V/²e7ÔµµP}Š…’LNÝ+I¢…– zÎËY)S®‰„u¥"c= Vʳî&\HgÚT`Æ‚… ‚ѹñz©±Y aå{(ÐBæäÖ=€\l:K¡6‡A`ÚyàÄùAš±ç½|)ŒÛ"[ã‹=m!¢»ÙÓ²2ÒkkCxh »ï©›¥ˆÓ .üf¾ó¢\A#…0«J¬åppþ®Únméi[Ú‡}ô.åb‚¨‡Ý¯å ítQðʼ’HjQ"ÐÀ±7Õ™±³EkËlÚð<ÑöK³–ey93”1dÇ:êÚVEÎø q„à,¢¸¯Åá2%*ȨÙàxuhZ‘RiÛJ ¹G¿­JtóÆ8ö<UŠ]ÀqësÊu‰^ûÃ|T hÀ‰˜jÌ¢Ó¼à,x§§'Áó  ‡êRˆ:£0 žk#‹ è\¦Ê2]“ >*ŒúÄífáwÃH”¶‚„„¡sÀFýsêƒ×} PÏ{X5àû·°¹´°Ùã]C„Ø!`à },ty‚ÒCKûøÒ‡ëT…O›QáÌ5ö7C3àJ8|V¢\°õIœ¹ SvÞËyªápÅ~¬® Ÿü¢†= ‘°Ú!U{.$n<„?ºž¤ƒb¿Á½ZÔÂI„§Ñ¦‚—é á:&&w¸5ÜÂìÀ½¼]íQ^Ý# Ó¨°G·?Ý'–M;˸ 0YöôJ³%Œ¬àÄÌÌèäOìþ£5Æ€ î3  gé•A‡Ò5^¾xû¥Âë¼à†#²L»ÇIÖ¤ßÉýû¸'æÐ®ž7ÁÞŸ#C×ø$ÈØ™«‰—Ç ¸ÅÈJP´Ï ·ÖÔƒÜá<æjÖÖ{:±T`/‹&)ç0³r`o§¹åñsÉñQ*®ë>À4ô­“oFïÉÔÃ9ç)%GzoøaŠuh—Ò‡ëºà÷üÀ´±˜N‰MÁB¶8ã`mMBòUó v‘]Î.éjDñçç›ÃY6¦÷VV8K¸‡ñ€èâÊáËhx¯³i6¡v&ò¢ËñU6›âISq2óG¿Ýýqö@l3¼endstream endobj 4928 0 obj<>/XObject<<>>>>>>endobj 4929 0 obj<>stream xVßOãF~Ï_1!HL~@àzíÃJ{/U["ñ@Zìu²Wg7·^¢êþ÷ûf×vˆ‚`gwæ›of¾™¯õñ= Ñ˜’Eç×I§÷ñ²ùegttùCšd8;>;£Iê?ïÓ$‰>ÄÃxH‰°V¬‹XíO¾tŽ.i€ùxoxãB4™«‚&-sI©Ì”–x‰5¹¹p$ŠBŽ”¦•Ë¥Ò326UZØ5ÓÒ(í¤-pŒ*W4™ËÆ 5m-­yP©$¡×TˆLº5¬à‰a ‘FòÑYA¹XKK&küõzÊÑBZ™¯k;e¥Nœ2Zä ¶2K¬ðº£pÖ¬ýÿB§ Feüˆˆ$%ˆµ+Ø…+áS*œˆMƒ§41²=ä®vZL#·^Ê® 9Ýߦvè¹åKç ñg¦´ Þ¢rän2Á§Ù h¹ºóV#ðJZærÁXßv"pxUE‚ÀÌý™„½á€±vêmÃŽbú¬é¼ë) „ .Dž›A¤TÌ_ËLâ?ŸFmx•±ÃÃnûƒ¼¹m¹&x* ™¶¨ém¨ 䤠ÃÉŠŸð UØv¾¹uáÏ# ˆ©ClE‘Y)_ˆ¡Aå‰y!–ç‡Ãá4ßͤSN.B=ÑÂé¢Õ¸ÝRùøzdÿHWZÍ*éAä¥ló C7ÞF›ë×9~0*%ªø?P¨®Tïõu€Ÿ 3lQ½E¿­Rððž$þz.uU{Î +Ó³ªbD-Cа5ÝÁñ€YZh8Øg×Jˆߣ\ÎDN-íT¦ I@æÛ ‹¬A¦ô¬3¿Çj17evcà%ÆZY,  9ãµÑÀƒõYðQûô"›‰DR¦réIjdæ(#×*ª\>ŠÅ:h…ú\ÀÚ¹CÏ^•Ë¥)$­MIs‘‚ƒZð(Wÿ"rdà§ÚðY<âIâ»mFxJ#_CK ¸w^C¦QjÊ{ z¼ôo§ûô_?Ä/ˆB±l¿e=ŸF EÒÿHŠ~†XâïááK`Ä{̦ÑÎÍ^z‹K{³éTï “ºp¬à÷™ƒo[ýÓf:†úÅãñ)£œ?ŠH¹®§f¡fs‡WhÜwP²WÍÖ*7•_ÐË{J'y‰±¸ÓÌé-`ÏÓøÄŒó¼~âé¾ /X}+ žŒW£ýÓ¬X‚ü"±jɵ©õ‰_ <ÕžŽ}dróµKaV6J½EƒbH-¥îwùº/D’žRr×H˜èªîð@±»]ºBߊî4··*VlAk@îÒ_X…¸OÏ·ÐUCi+¼¶‰]º+I˜C|ÿè²^2zÇÜÊMµU)Orx{ךqµ Ý_¯b/4•Ák½F ´ðyW½{ Ìí(- MŒ5¢Ò<{…á]Áê ÀöU&Ø^ ¯¡á.Ϫug0>ŽOF'ØV‡ñiÐŒ«ëÏ¿÷FqŸ.LRò¶ƒ-ÎhF‹> §{§!Ë/ì´'ýq<b¡E; F¾öÛ¤ówç;ÉâD¤endstream endobj 4930 0 obj<>/XObject<<>>>>>>endobj 4931 0 obj<>stream xÝWMo7½ûW XÒZ¶â4ð!Mê —"mä`ÅåJLVK…äÚV€ö·÷ ¹«•â¦Ez©mØ^i83|óæÍèËQŸzøîÓpÄ?rqôóø¨—öðâú—ÑÙu.Ó!s:ïÑèy?žÑ8 V=Ë„ˆJ±P“D—žJU¨…*½›œ¼À­¯³3ze•ðŠDIÂZ±::êQ·O<ý=<¼ã ž^#{:à†üj©h¦¼öjÓe¦öüÂÍïÊW¶$¶l%CwFgäö¼t¢û;QT*x„—÷Êt9•ÂùI²}ëFŒ ŒÈ2VÏt)Š¥’óÂk§ÓÜšÅÒve'IŒÔÄ`iYçèÞŠåRYâ#mŸ[i<ò/<ªí¼.gTÝqôÇ ~<»>'.fNÝê:ÖtI>ÌUI•ãÓ~®-„´¦Cñ h΄KìºIÆV9oµô*c€9½X*–C…þ¬Ú¾€KÛ•±m£¼0¢m–Ò»ªM32~à$ .´w‘ØåØ73wÀÌVQi<‰¢0÷*KÛa8Év2‹ õž‚À&h:Cßè\#Xt…úe+Ò ›J)(è•XÓŒò¤Pæ8H½5 Ѻëü¼¥["ËÒ+Z‚5”åŠòª”^›u5^*éT+­¯:8竆<€ÆT—ðq¯ýœ–Ö<¬bÊ¡;p4^v]×ãÐ¥·!In„=,˜ uæ¤RЀrÅ7Ï«"¥kTN=®úOëZ•ÍépÊ’ã…É*P£6®3òr¬KYT™¢'2¤ãRýd×`'ËÌTÓBu(þ}É2ƒîª *¢XZ0í6$јnú½µõ7[â%“ÅÑÊTÌêÌ„Æxüzཱ\¤ÅNò’®š×Ó픓~orBô´Ñƒøç·s<šÉ¦Ì 潟 Ùlé3‘¼Ñipª[Zñ”^:§g%³¹Ú´GÀ©Î7ÝJrZáë)½c¯8§³ë‹FC0r¶4äWã›ò7*“Ðx®œŠrâDîUJ±tUÁ“æUœwsh1VH/ʄǃ·•ÄPÐÝHä”]âVššªÌɹ’ŸY¼`åD®üŠLÞ%­ ôþÛ<Ôô^`²Öu£››ªÈ #! [ká&›@ 2ÓOh?Mdqšç$MY^jÍ Í¸Aˆñ m¹…MÓuƒ‹ôr€Ïm™Ý´º;Ôƒ¬uþÆAsì›m[߉!‡¡YkA €Úþä\ØbS?ÚŠÊVtÚ²«ïýœXpyº„Ëu#¾Þó€†åW¦z÷h€( Ãä‰ ‘© V"GÌÿ ¨qBa¤˜ûn¡îT-ÔÂØUPwLÖÊ5’íäcðÝ›u2dû=–|±C¦|UîÏš‚{Ì­B3ï nf¿î³5‹Ž›ôÃ6qÓá¹uÅÿCÌvQ ²@{Ï fÉ–›æ»‘‰C„§FnXÆa7¸ÖÃA³„îÊ=[ļÖ[jB§ñ·ñõÉd3„7ÆõÖ:]yPá ‹ÅWeòIÒ>z(ÎääïBÐ$÷ø~Ó²â±_Z·I˜ª<¢UÈ#Ü¢4XüÚÊp•Öé¸C}©´åÝò¶wêÀ~² aJŒâR)è 4› Úk[spÝC"®ga©RŠíhÓ™$*¥ ƒ˜?kÔ@ñg‰¶<Ù7«ÇíéSåe:9i=.¥¶ÇMÿqméÇR½qÝnšä‡S=Fú'TÇ„¡«>6E ì¾þ/8ï¾>Æ÷ø^#uÛ Xëê@µïÅ˺ú—çéÅð‚FÏ.ã{ÿáí›î0íÑk#+þ Æ_‹¶ÝgqÝ=0/z£tX¯ýá€ý2>úíè/ÓŠÏendstream endobj 4932 0 obj<>/XObject<<>>>>>>endobj 4933 0 obj<>stream x­VÛnÛF}×W ¡ ‰¢DI–SÄM«´/Š èCUËåRÞšä²Ë¥õë;³Ù”ä¸-šÄäË™Ù9göÏÁü;tAÿx5øv=HâyüOï`¼šÂ2Na]À,ÅÝ$^,na[«Ö<2‡F\¯ÿŒWI°ŒàF V–ŠoÝÉ1FT³êÌzZ]ŽÙ=Y¨¥U»¹þÆùÍ`‚H MüI=Âè'eÄèêR> 0>AÀéì#rm®û‘¢¡uØkÖ4BÃNÔB3#rÈx [¨× dÕ”’KS/»\´Ö¯• P…ý֢̕mTËzTXL¹édŠ}ŒVJƒøÂ0’¾‚o‹5o¢fˆe&gHÁðÚSÿæ¤*hbb¤Uæ-E¤ŽŠÐ­Å5^MzݜƫB ±±7 ¿ é ?R!¿Ÿ‚±ý·ŸbzÈ´êêü¡ |'‚½4¶}…Â1ÚSë­Œ¢´Â-ú¹´Y§qšâ”æÑ“’9PØÿ{ôŽãvlâŸ]Ñ­«â?µ‰¦“«º5¬6_/ï*˜Y"¸”ÿ¨Rø ëß3'/±íÍj-½™QºýWöTjÃ`´P 0òéÈ–)ú‚äcFbcìl:~ÛùúAhÈC†Eu…üx—e×b¬ãc׆ÀøÁR·ýz—Çcøå×?[jè‚q+YDYÔ¤C¥òî9g ³;óBïxe[ËwÞçÔ:Û_o""µS°çÀ޽“s/¸±*ؼî}n᣼¼´\uY)Ž÷üªˆî)5škÙ¼1÷÷÷È=U¯/Gi7½‘Ãyt rêæ$àØ kÒsz¿M’Dì6Ù6äò¾wê#é©w»-ë%l‚æ÷2f½˜>c6¥ŒoäÄxÙ…¤“rÛô­ow4÷ÞKÌÏ,»[bZçw^-…K6ÄF5Ç?pX= Vü‚A£±q^ |ʤeïv›¾Ww@K,lÞyؼwñ4žÏ™a±t–a¼°ìé ‘ k=wˆÏäFÑE—<ßrQÈ)]t5·ª`¥ñIhC+B³=.yJ FÃuc‡¥O[cZÃôN(Y½ëØNÄ@@°Ó‡P¦]͸üq½;rëœ6¿ãþ^u%>БñGŒ>îjÿ‰,3Yc0‡³wÜtøF¤uÒê<Çu/ 8¨j!r|[ dñU‹ë؃bë`uE!´C|RT(yÐv%\(ÙîQQe"§ /aa3”ÎñqCì›óï•~ôÏ€¥¿“i2‹çé‹¥»6ÆQ'ðâ]%jcDhQŸíèÖ åÙÌ“EœNñÙ‰×?ISrú~=øyð7ñ­ >/XObject<<>>>>>>endobj 4935 0 obj<>stream xWÛnÛF}÷W a‰ÖͲÓ"Rµ¹iÚÂ.úÁj¹”¶!wÙ%iEýúžÙ%)“‘'A“³³gΜ¹äŸ³)MðwJó%ÿ“ùÙO7g“x‚—Ý·¥ó×SšNè&…íò9ÿ2’Ö”ÉpôL&¢ëèÖꄞ•Q©ÿUŸ+2›C¥ÊõÓ§7Ÿ¿^4ÎfÏ𭬹U®*)‘¿- çú§"²)ñE$ª¡=îkSYTVN›mü€RÚ(æ@…Åiåâà³å`|Äí#ÍUžÛ[Õ‹û.+ÿw¡UI"Ë8¨j§œ!>m†pË“Ññ9€°®EœbÞ†§¿e'¦›ã¹8pW÷ª|£’D%ôáÏ÷ïá Ùc[]’ö¹éŒ3'dUþï( åøî‰0‰p ­(Ó'€. ï²Û7Œ)­¬´5#Úï´ÜáFJ”Ì„Ñ0Ðæb¾˜Å31 Ü— ö?n Ô!=A§¥“G%†Àqd±R¦Ì¶Ú £4CÓB8‘+è ‰wŠÔ×ÊE—:›{ê2a¶µØB …’:Õ²•ÅGßu—$3P›D¹ìÝw¹‘6Q^ÎwDü›i©â¡M'› !¿°°6ío¾þ<Þ ¼˜Þ*Ä{”Úκ a‰¼ÈÔ-ä«xÎ Ä×Î,žÏñ[ŸÓõ_ïÞ/³THÅÖ†OèãÜ&uÆ yWýoÚȬN=’Â9q(cýè>{ü ¸ù±?õ²*Ëu„ûG â»Z?ý1€nûTàj/——|ô÷Cµ³(‘‡øòåK0òâè;šN‚ƺ(Ù$µŽ4ŒÈ!óè$“›yî:»8Ž ÄGý‰ö‚e¼m°-Nݲéy²^L¾ÿczÂdvâÝüÄ»EïÆ'Þ-O¼»<ñîê›wÕ“Þ}ÌŠü>ù]ÿ–£Í‰ÜpŸzÎû¡á*þzœmÍ\C®*´ELÄn‚¡^Œ­Ðÿ÷P0}1v®Ç¥›Ú,³{®»\Hg}ae¥E#LµQISUm„FÂ}Ü :Š>Ž úÌ ~þ4ìkÇöFåúûàÞ¶ xm6=Šñ¬ÂlbÅ Úê[…^ƒš9¡“u~g=øxšµ†ƒ ïºÃÑ:bŸÏÈïL¿Ñ•Ê»AÚNÉÁ¨Ÿ‡ˆ©cFM‘æ˜y覆Çxn5q6Á\4kÈ^ùÁVmKk»CÄ3´×5 go5ZS¢’È®”ªÛin¥Í–¾ë‡5ö·w@æÙi•)ÖÍÈ1ZÑYkSŠ´eù9M1'ÞÇÆ³+~L¢çh°+ºö{½ÅÒÕ'Ãë$¾ºbóW˜õØ[ í&S9†-R¹·Îwû½Æ [ñ·-†•‰ì‘ü§VÌ-Ö°\]Ôd„¶÷Û 4´R—|®Íq³ÚIôñEžxîx~·xp¡37y^j0½QRðÀ9`†ÙItšâBX”+œª¯%§ù!Çc"·u–øåÏï=c¸ÊµATI;€¹O7v춃ê7E¿uÁ›Ž9ô«uŠ3;º3ROñ–Ó4(¯=È+‡BËIc”j‰››5—•!ÂY¿óvPêJgÜcRýU%c^ÀRÍü”-½¡Y@¶Gf׫÷é eÆ´={•ecßÁ° ؽòa‡áš\³”lØ/×®PÑI–W¨«:øu«ÇlØ @ÞiPË%J ™eä¾È6¢Ä~ÔêÑ;ñ-«“$»gQ®šÎ__uÿ YÄó Z..ã™/ F=žÇúÙÊ:‡ª<ÓŒ /ÊroÑ]L–ñ|ÓéÜ‹_nÎþ8ûöƉendstream endobj 4936 0 obj<>/XObject<<>>>>>>endobj 4937 0 obj<>stream xµW]oÛ6}ϯ¸(@lű›nh¶6m†"û¨‹¾‹¶ÙÈ¢FRu½¡ÿ}ç^J²å6I_†8¶,‘¼—çžs.ý÷ÉøÒxÊ¯ÅæäçÙÉ àfûæVt~õŒ†#š-1vzyI³Lžh¶Hž¥ãtH/õRUy œ)V´VE–ãâlöñäüꂆÊ“û£‹ôÓ“wUYZ¯ig+ þ¤IÑ/´¬ŠE0¶ ­ k kã©t6ذ+õq©]¦c^kÄ‹Òñß²d±VŽ~XZ;¯/ýüì§nð¾Ì§ÓéSž1[kÊꤷN•%§}«‘‹±Ž–ø—ømJÈ%Xò:P“HÜSâ»a¦È©íñÀ˜ãW£×*ÓKí$@@Z¦Ú*oÀÌTP¸‰„4åV:ð"Ø?—$KrU¬*µÒ)]d1ÈÑÖºÌ÷È,ß­vš*ÏTÔŒ¦ÜÜiÔ/ïjÇkDì½fßûðXz£óÜvws1R)ŽAø ­­­òŒJ‹M3r¼G§K§½.‚2Ø%=‘`O‚7§(™G 0p¥ô£áºrEÜi³‡ºNß„¿Gï>\¿&å}µÑ(Ãà%i¶+ºyÿöma6¦PAgMe¹ºÃLE [Ҍ©»2Ÿdɦh{èMðd·E;%nÚC?i]Ù‘ˆd†ZBø·· e%r¸ÍõÆ7 Ùs¸¡nJWÆùÐ#Ô{Á²úcP)„0±f] xd^» °«KÈÙùÕ¤{B7¿ÍºüHÈ«¥q©½ØQõÍÌr'Ô#‰;O20bEÏÔ@9W• H£ŽXtan®U5·pʯçg@ ré6ÖéžÌ©…^ƒeÓF™E™ X5w´­#º·¨µÛI>,-°ŠÁ¡à\¡D¿ÕÇ‘Rg4e¹²_ŽèwÌÇÙébuà•×QƵM¶Ž$dÕŸK½’}X¼Þü£ÿB•3a׺epLy’뢽6… Fåy)›øBÁ¶á£‚7VW–¥?¦ß=çgÝÝ'ÀÜeˆrV@ÍÎÆÄ¸!lT™Ò¯•( 0çáq ‹ÏwÔÄ7ûóúæu»Ñ·¯n^ÏÞÌÏèßv Ý>&xöE: »ºY–¤i£Öøýÿ@öÆn!´Cë?`{…>Z׿n¿¢!1xvó‡yñâyzÏ?xNôНŸám4xÒ¨F6Í£îøÞà¸nG ‰%+ým©¡ne ì­tk ;¨„†«â¾´Q±#Ìd£EV8´Üb›Õ÷ñ«©/ÚJ“¿4˦ÐÇtÛÀ|M¿%ZM04R9LH}R&W°^.†Ê2ÈǤ×Á J8É#ô:ŠúEŒé½Äi¡·öö#DÎᜆݡÜ sÛu—ûNÇPhÛ 41_/wýƒ#ë„c·R ¢ø}›OÏ[aèF"ÎY/µ‘Î;V–ŠM¼VWs_º[>¢¸ 'M}¥ í¤[×üã® ’Õ>!«Ô]¿Ï,aÁQwuKKóY&äÐà -žlâ[Jí ÐÝ{B™q N5î9ïàs[Ïcô;E–¡çW—5¹‡—éd<¡éd‚O9v3Îýq: —v!ç9±qž¨LÝÝñÑŸ “Á4ðÖ:Ox‘W³“?Nþ/Ï£endstream endobj 4938 0 obj<>/XObject<<>>>>/Annots 1697 0 R>>endobj 4939 0 obj<>stream xÅWÛnÛF}÷WL   ‰ºÐ–í{MZ+(ЪVäJÜxÉevI)JÑï™åE¢œH_j†ö6sfæÌÙÕÇ“ ñ;¡hÆqv2ǘáþ÷ë«“‹(œÐlvŽ)£ÙMxÕ 4Ý 3šL¢ðæ`ñpŒÕh^®Œ±z=í~:?@âáØ5^^ÐdLó Ïnð!ñHñ!æ©r´UZ“•Z '©L%>»J—¤V~$ŠÂšÂ*QbUص,I‹|]‰µ$W…±ØêHl„Òb©eHw¿Ý¾"Ú¨Dº6Ns¹]Y)OÏçNÆ4œL)(w…ÌDA+c‰F/‘K:ˆSaéûz² % g`Y”Þ|&3cwŒ¢ #Pj¶r#í€v¦¢Lì(—2¡Ò´ÀxÞ’ÙæÔ¢C™° :D'¥GxTsd:x³ü ã’JëRUÈ:C¼Æ/xkSÚú>f )‘%’èÂ:ÖâÔpÙ†Óçè&ŒÂ Š]iU¾U?#¼ëËØ7G ëÅ}¿|( ­–V w+¥e›“b£5bQ&'³BþbkœšH¡á¬)SZU¹ßÃUF-$椥¬*™,µKeªLæ¥#ÓÏç6UqJ%œ£*¦*‹ªlÏ$¢0iMµÆŽT*»7Ò“œä'‘@ l®‚ÑA¡L­Ó’–Le&„ð>VÒq0LP_†–wŠÍ0<ÁËÚ´]‡§~ÊY†Q„QlŒJü_Àè¢á¥[œÓ_­Ið3Ñ[S¬š–Õj…´Ðq¥Ív8Vé€LêëÌÐsè³¼\-78=s£3w: %Úò}¢,ª’ïr?\œÿÐóýwo†}@ug2¹E‘$IvW9§—žqé×Vd½ãÃò­ÈÑÿ1O/þìûæ¸=òÜ>c>oGˆ¿tÊG±×­¡/CÎfWœßEðfi2…ŠQÞ¼|D·«º››  B륔íªÕ}͉Z¶¦Ò Ód+µŠd£\­VZÄ^ ³šåNpù„.¥ÍA“tmšÐŸI òÑ©òÄQœÊøãÅy›þi×—M'%r¥røóùM3“T 3`ƒÚËzb#¬2ì™l©Ø³ÉÑD½ÖJhÑœ+ É”_F'24±((z¶ŒSFea¹˜íC›‘ˆ»Þ5zsÙ]P쬑š÷>.™¼¯›tÂf8øäÔg¹8çlì«å‹UÇ[YÆfÀ¤F“¦­®³•þÑù@ÜšSËÁFè  ÂlgQá Ç9èŠOªøó»×¯‡p’q¢0Ë!º ù„_hS^;j}sÓùÚ51Ã`ž‹æã¹YØ_§:_W‰ÍZ}q ‚éÅqï÷Îå†7÷)?jÛº©.믣~üøñA£Ö5í¤i”B5FK)>k¹"¾ÇåïF/=¨{ƒ~2`crr{Ö”ÝZP5jû”[ÀÄ(!_B¾€­|.ÜE,V®¨.w†VzqGÍ™¾ð¸ªIüžÂ€XðRó‰v xÎWƒ´¶Ý([‡¨9ìçpP‚ÈÌ)ÆÔ­§“,A ¦["”ìšÃ|ÐûöA×aÔç{XüÛê_‰,씢ÊWí"ÈðTS|âÁ¥tÔÔ#ô £¶{mÐê@@˯Ç_3~dÆ/ ˆ:ë56üŽé¤WêoV“~–Z-‰ïe9 ·Ožýôb~wûû‹oÐ>Ú>b¸¥1ª¯æÿ¦+× —&×áetI³«YýåoÃ߃ž›Ø?ýEÖ¡Þ;¼ªŸ@üÀèã[kÿlæ«°ýzR¿ôùðåxFS<ŽqQM¢O½˜ŸüròŒÜ*òendstream endobj 4940 0 obj<>/XObject<<>>>>>>endobj 4941 0 obj<>stream xÍWýoÛ6ý=Å-ÀPgˆÅqR @†$K€`ÅZoÅ6-щT)*Ž÷×ï‘Ô‡åvIƒ®@‘€ÖyÇ»wï?ìõ©‡¿> Çö?L÷~œîõ‚Öƒ^ÑÑu&Á¦Kõh|ÚÆãšFî«MÃÎùù9­¸™g,¼çfÖ™LÿÞëQ·×QçÕlöÈN?ÃÏrŒ!:ÁÀû&ö*ZܼÞà÷ÔÞœ,í“¡½=ÅÐý†‘‡zv*gØÃdòªe>Øû£ëY«KêàÀ`X:Û™Æ"§”…Z.xžsiK’ ‰È^†,!£È¯ ¸5:߇¹ÑB®æ UȈGsU˜¬0mK€¦1'%±X$–K®¹ ¹5cbf0pÒÓj¥YJk‘$j–Ǹ411Z6(¤¸^&jý›çÒ3²»þ(ÈiaØ"á³NÆtzˆ¬9§<ªš7 L -sÂÇ,åˆQ¹©*ºn•Ý€ ‰d3*-‘Ï2v¸*R Á'TH¤ºzeS—çxY˜,8ýüëÝ]ÖR„Úà)“å)lh½Åʉ:J­WXí´ìÀäp¶m<Éáð³$@övf+ûçíz‡ëZwáÃ!*ÿ©YhÒ"x F³ƒ×v%»aWýAàXß?(!¥÷|^d×3€¾Z œÚ¤x§†o¥Ã»Aš¸¡„ÉUÁVüìIÇ-7m[Ûy’(Z+Dû»Dusuw÷†Þ¿y{wù2v¹•@‚´tbKX©™†%©Ê ñG”/øÁ’A˜"•_‰kªà;Bij‚…!Ï @,Éãú%…#GKEî-¤°´ r®¢LܾÊèÖ}-ÒLiÃ$ÈMO³˜YÖÀ GwØþ²¡ÊA ýHD¤2®êŒ7Pžw&¾yÔív…Ì g | ¤Àk0[¶!µ,½²…鿀@–„9t5¨¹qt€¹ˆ1+©÷,Ø ÔÿĈôå$Ø"?úóÐɘÌÌ¿¾m èB’ÊlÚYÒ nƒB_ª5)Õ[óÏ:Ì3Š¥@ZmÁÈ"]Øþ±D,ŒênH‹ ­cÆî»L©XņVZ­ñŽï³©Boendstream endobj 4942 0 obj<>/XObject<<>>>>>>endobj 4943 0 obj<>stream x­VmoÛ6þî_q(6Ô1bY¶ÇÙ°+¶¬Ú½ºØ%Q[‰T)*Ž3ô¿ïޤìHI›[–|¼;>÷Üs÷q4‡ç-é/­F¯Ö£0ñåþŸÞÀìòæ!¬sX„°<ÇO™5Àé¸1ZÈMp´~?š]†° "o8],‚(§lümꬮUkêÖ\Wì¶w<§Ó0©™)ŽAHø=ÄGß“¿¦6õ¿¾Q"ƒ 7×Öø /‡ì§˜þtËåy½’` †it%“›–møw_¼ÉÅÅŽÀópqõR}9+TÅg gw%ßÍ~gétÚÌ.•š½búeϽ¹h¾ƒ ×…h“T+¨µºo€AÃr®•†kÉŒ¸á+ y+S#”lðRÌ€ä<£`«…áàà‡ŒF8+ô’´9º à]ƒÎš¶®K'Ü[ ê€hºdWÛ8ÙN²J¤¬,w˜D©R†*^)½%¡à¬àOÞ´¥Ál5‡ºd)µqmn>“hnZ-ñ[fof¹*yÏSã)uê©ç 9yŒN[a ǧšéêØ±HW®2‡òÛê[÷pE€»‹˜PÉ!Q­Ì0#â&Kdp¬½‡ð¶àx¯D™tÄ.²âÉØ/ëè® j…  ÃÁbþäÁ BŽ5ºbJä·u¸’ÂBÿØÒ÷9¾VqŠl3@ŠnXÙrH•4LHìaë;PTmeÀoÒWˆb!Tî~ÀÄÚÊñÁ; <ö9R_!v-+A¶UBæì oø±A*  c =’OT5rÉsø‹|òi”\nLÀßù2rèhmIU±]/Ÿ$B2d&QÿëDêÀ*§RäÁ©Ô³£§gË”5öÌø¬›Q*ð_tÊE~L§n—‹³hµ:Ÿ/h’U¸/œÜÝÝíêówp…~á„¡FnI¦P5æjËuÞ–pÃuƒFdÐz8AÒ¢•âñ°ÅǼuJ„}L¨²G¨+S&!A¶êDML)ipÙj$¢¦‰©¼Z{â–V%j U›^X±-,ç‘Ì{]Kv$$rÓõ—c¯Ê)COå7¶£PWîm7PHôO~…:v:j^rÖð!tO©£»‘o9?dHÝ;÷PÃ7SqZmPr¬ìí¡ÀïP÷R„E6»úÁ½]³ åë¡t¯vü–¡l<1®í¢+Õm“&>‚:?v·ü™4ðt6hQÙKÅã%N÷þ&BÖMÉãñ¤9†¯9Î@Ø*]fq,_ |êðA_ðUüî«+Ró×woÞLQ¼+T2ƒãÀ3eÑM_Ð~ 1¦ÉS‘ \ˆ¦Ä°C©ü¸ÆP8 0„w‘!ÂRs¯äŒƒ”%%&€×4÷(A ÏÂض]Ö„`®9n‚“oæñѼG÷¾A9m}þwí´A†«]¿ÔŸQÀ•/Ë|yœF§°\…Ýü×ßW¿L£ „ŸTj›·7%©nH g==sïy'à׿@Íi¸ ¢®ë¸‹Í£½úy=úcô/1hŠ‘endstream endobj 4944 0 obj<>/XObject<<>>>>>>endobj 4945 0 obj<>stream xXmoÛ6þž_q6ÔIcÅò»S¬ÀÖ­k€¢ÀcE1#Q¶6IT)*®3ì¿ï9R’-G^‹®«l“¼ã½<÷Ü©ŸÎ|àO£)ÿ¤go€•æ¡×üƒfsoFÓ±7¯9iI¤éÈ›ÚR/ciÒµÞok±Ç­öÙ W4ÚO©ñÇoÜ¥/ÐVäì þp +›+NªÂÄÎ;$ŽtðŽ—Çóîu¬7Ç;bÿ¦Ôvͺܡƙٱ±h+:í×IU.FwHtÄÈ ´½c§G NÌŽ:Ö›ãm-§\³ëjœ™{®Yûü:©ÊŨ㎉#]?-Ï®^OÈÐ2B]Nø"2å2è}FÇÙúN•&/ÍH#ïŠøQ®z¹Ðé%îSËDŠB®ÎÏ—Aë¸Ò:P8†ÚÞr”Š@+—²!…â6¥ÎÈ]TÙC_ßÒ66›8ÃŽ¤\«µ)‰,¬¡„÷¶Š`…H¥‘º ‘Ùå’œ%àë_/ØMmû`ž?dóXç‘@œ::ÞóèµÒ$?‹4Oäu-0U!„ÖÙ¡7áWØ{PqH‘R«úæâÆBeñ¸:§X–oç˜÷ÿ]ôÕ‡q"µ1Xõ¦ãÕù‹ŽÓ8>?ݹº¢:6’ •Jº3¡w #žèð<¯µö/ÿÚç®oýLg.ru—0ظ£@eF 7yU(‡uì+t´õ÷¨ÈeG±,h£¶6Åû¼§2U0XLîùj °!Š#yžÄ¸O€¸Æ ›È7ð”Ⱦ.M_@y…š&w‰Ì.)Òpñ¿:?ÎÍqLO£š*á“!¿q¸7B¯¥¡DdëR¬¿»—/_:Ô¹Rl ölµú,¯ñMñgxH9 ïß¼ØásÁ?f¯Œøçü;ž2ÀcÀ¢Rà!†xÌçÏZÂåí?Á2Ã)E5"’ª…—*|A‚cN(mª=5T°ªÇ8æ’¿ýpó«G7íTIñ€¡Ì«¬" 2R:eE"S¸O׆Z”€JŒb–¸´Òx½1Œä"¥¦­¾À|lgjˆmd’c¯¾§Å¨ìÚИîÿ©Á‚Š.Ô;vˆf^ø @|„·*Ð"L¤ØÔÆÕVQÿ-¿Â Ëtw·7¡º–E™˜Š©¬EO©êÂÿìÅ÷Æ7ˆ«è¤n0ý1v† ¼Ri*3SGªn˜ «†q[æ¹Ò`Ö/X{:wˆðâ6àzSXE¡Ìe¢tÖGï°—$I•LAA©5ŒJvTT·s2[ÈIâ{ Fµ¤sõÚÇaÛKæùäZÉjÂl[Å›•[ïk˜o€ü„A†~¥Å–^5]Ù ö3ÁÆÊãÀ£% Œ¾ˆ¿©Èv\$–E(ô¢¸ØØ¬ïkÃöÛÊØ–€þP^4.r€Er h¥)ÇK›,þTÊ⛽DeÚR}õüù¥³­²†wŠãf›Ém;d=Ë n­I:‚‚Oüy|–}¨:FÕB@– Ê‚cüã»ÛzÅvH”ˆÍ 5£­Ÿ¡ké¡î½ÇãL§Q®<9úͱ{/˜®`*Zrçe" ;Ñ6¶+Ž#ÆZ@p'±¹`×xER!Ž?ʃ˜$„1HD’Î #EØé„YP¾ Ÿßa0õ‡soaŸvæ[`õvùö  ·.êms™ðš4¯ç‹:5®†Ù ‡œ.!¡<2v ¨—0䎹ϸ‘[ŠAM 2æš4ÇY”aÅælŽçj¾®ðŠ_ذ&ÿ8UÍ*[+–•ΈV¼€ýTò”Åå§åF¢upBíÜU7ë†ZîKãvx^ð³)+/Lx}-J£îrc'Ûqß‘»ZÂu™þ)Å!Âeí=ÔÚ,:ÁJíFÝ·êþ1z“)þ`6ô3ŸMfû#¼¯þ¬‚’[%H@el%†ª1Â9¡þ̽>œ¨³É`ê†.ºþhÁ¢¿,Ï~;ûèuæendstream endobj 4946 0 obj<>/XObject<<>>>>>>endobj 4947 0 obj<>stream x½XÛnÛF}÷W ÄPšˆÖ•²ä¡7·ú6ò X‰K›)Éeyq,ý÷žÙ]^µ´óPÄ1igçÌœÙ3³”ÿ9›Ó ÿæ´ôù÷œÍ¼Vš—ü–?ÐfƯþÊ[âãå’BÞIþÕÊÛê¥ùº^÷—ÞÚihú@ÚÁDØl¼Mai¾šy+gŒŽK˸˜(óÅ É6DÆÑHÔ§ë3€£©×ý­<¬—ÃÐ:8êe*ßçhÈ;l¶KÇ¥õÁq4[/Gœ®«^Ú¥OSÓ_×'5¬—ÃÐ:ôF9ƒÉfë°t\œõÒ<ÇÑl½qº>¸1šz}¹µ 4¬—ÃÐ:¸ê¥“ês4äH6[‡¥ãÒÇz„à8š­—#N×ÇU/íÒ§©écøÎùå0´} QŽÆà@²Ù:,g½4Áq4[/Gœ®ÏnŒ¦^Ÿm1Üyrõå0´®zé¤ú y’ÍÖaé¸ô±!8ŽfëåˆÓõqÕK»ôi2ýõvå®—ËÐ:ôF9jƒ Édë²t\œõÒ<ÇÑL½\qº>¸Ÿvg—7+šÏhÒÜ[/¯p“_y+A»Úšádw˜ep}GEùb÷ùŒÓž£Q±cR¯m|o[¯aó'^÷"Þ=ÕÑ—KšB¥³Ï^.ÙÍ. Á°üV&¢|V•Q•G^òö' yÂÕ. Á°üV™Géí0¿¢Y=AÔ–'@ïå¡T'¤ÛÕ!¨±<Z܉\Ÿ²ò¸o‚·Ö&ÀÜÛnæ8tˆ¢Â¡ïî$±,(*h¤TQ"EZÐA%Y,Kùš •`‹Ho+q+)QAË‚Š*ËT^’À»=ŠM*¤Xb¯îñšƯÙQ©TÄô~÷bQ²ð¸ú3¤Ãºž¼‹¥(J©¿)T¹†‹£}.ò#…R#Ër•å‘(;‰Õ;ƒ(×gpÔà—7[bô1]h™o½•7'-öö°Ûvã}üHkkÃ^Þàù_÷"÷È'ãeJÚúMPF“+’»¤[3‰.)4›ƒJïe^BrôóË—tŠ{}íJgBjÿ„€¦tYÃ\%ÈžµÛ¤ù­éŒ¦˜Å!2­>:nPTù ø`¯ëøWø¾‚ê,˜öÂ[b"€øssÊõæú”ôly¥‡¸ $wkqn÷þâ‚»ú8ùøâuä^EÙŸ½È?NPh°ëwñ`ÚOu–KÏ÷7å­Qƒ!ß(ôqfô¦É¨N þÿý%Ë*‡ø!j]`[û^ê:Ýóße+ú ò88Gžâ½ƒ®kgÁï0¡]Ç: ò#÷[¢R‚vö±L sQR&ŽŠdzPUZÊœ{TÐk¶ƒ.^5䆖"JYaâÛõåÑÒ^š7G*³ f­{3alUýåô\dY|d~}\Ð×Nàƒý·ÖY-D®%GnZ¼«9i•~í}¢îa1TÄL ðÿ®Å&³ÓyðÄ›žÒ¬ÎžTݦô%*ï¬Úz\0Ó’4@-ÍF¡Æ¦µYߣ¬´2ì,P)ŽÀŽs3ÚŠo™ž\œbg”ž']˜õƒÏÄ£w DdŽŽÄ…’ªtjœrÊmÑãf¤X†ÍÉjµV)’ŽÂHÚ1×mÍ zÿáío”YØúþYØq>¨‡8_8Üoaƒ·øÂqÐv<ºS‘È"ˆîÑÛŽªÂ Ô—á€aGœf„I ¢¨4Ç(ôu>{E‰ø[¢Ôˆlöl¦z={Ë;…›2˜¹à{U_ØÁ ‘ÝwlЪà¡ÓÔ…;©ß=<3@­×bïõˆíïó¼úHL×é{Bß fˆRñÊŽãMe=}//Ý^ÎíÕ[ày3& Pƒ9|3CKãÁ™[/ñ‡8<7-|ý4Äê˜.ñ­äu¨‰yÊÅe7 l³{º1©9#Ö3ß[.ÌC8ž°Ùñ×ÝÙŸgÿ5ã:Bendstream endobj 4948 0 obj<>/XObject<<>>>>>>endobj 4949 0 obj<>stream xWoÛ6ý?ŸâС…ÜØô¯4IÓ´@Ö-C€ÛP-0-Ñ6;‰ÒHIŽ7ô»ï%Ù‘«¤XœÀ°MywïÝ»ÓßGcáoLÓSþ“£ïgG#1»7»¢áõkOh¶ÄÞÓósšE~}D³0x-NÄ„\]\”*ÌSÛ›}>^ŸÐËl0˜œˆ˜³µ¢j7úÅf·••Ðm»€b½°Òn)³i©#åÈY–Úœ–©¥g½?>î8¯Û€ÂX:GÚxÓ³Ÿýî´Yá«v»»´)Ó¸Ä]|~áû„8ö(H—þ烞ç*Éb™û½û¸Š´E>t©]Å1mÓ‚ŒRå)E)áR|ÐÆåÒ俨¿\*«LN¥²N§Æn<¸­+ÅÁ.#ù6ó¾ËÜ_·ÁÑ| ­H®‘Au'á·ºh.8SÆk€MÄtŠoQð#{®ã2ýKQ¢òu¹~“GÏc•‡Í!UMà´Â2óâ-"qÅÂášíp&&”K Kå¿gÓðz|^×ñàLŒ½@DÁ|‚̶ÓÅ‹uü7&+@IÐ4‘™#iA{µÔárUWv;u¨™ðUúû‡C —'Χwô¢í@Ð'i¢o½<0äËD†ë:Nù<v‚ )KASÀþãtx(%r˸e#˜AÉ* B €`ÿä´_J‹ü^ê™gOH¼ ÖOO?dÃËa)ã$®…µÂÀ z#ëžÈÐ ÙgmŸÍ¢?9XFMBpSh¸¥RZ¨k£¦,ë̾Êõ嵎+Üa©„d+CþHÛ˜®@Å$Òe;cðÂøP™Tx©»Peì7„ÄD1"é(ßuìmº¼µˆ¯zÐ槺ò‹wùÜöÉ!Kšƒ«TÅ{¤ñ’Eþr«8ݱýמŠU­ ´×+ã?Ö•PÓ°V¤HA4#×f’àk+agDUþ:²;˜œ‹×4€C†gè¼q\¸Ürã­{}­Ý»a O,+˜<ªic™Æqºá‰aYôu¬=Þ;‡/éZ£w^4ÝS¬éå#ãëYð]ÓB/«ºñ}†åå`UÆ«Ôê|<´¡qIÆí@RV‡ÍruÕ2Ibà@k™ó8ÖŒO¾ÿR‰öúU×f kª™O†a‘<ÿ ‡‹…Zi3æ½~)€£ÿ„IrÞ–Âé°gÞk7õ/­„Üw îç༜•Äw¬¿xÀÉŽ­´‡` ñDžÐ^q+‚¦“~;zCúr³w›ôññ¼W»[!ĶüÚü¡ÿ¤á[šˆQ;:^¬³µi¯´ã.Sq ¥ºÕæãdx€FŒGƒ›ƒJ$!qŸÎ8ØÝúåÓ·@uOFÿ-Ò~¿¬}ñà"âyï0¥>¶ý¸t0s¡øXxiBÓ‡7?õý°šèÕ:Ç dÄWä®Þ¯²G'Ô6uwÕö¬ž}ź™V+8Ÿ·Ay|À­L†C´Äý ß ’ŽgîˆÛ¦ö[é‡×Í,5>?¯¦¯ðœ5gÕÎILň~HQlQßÐøH¤¶Ú=8«üé|{5:Ó Å }ã“1þ8;úíè?ÍùÍendstream endobj 4950 0 obj<>/XObject<<>>>>>>endobj 4951 0 obj<>stream xµVÛnÛF}÷W l¤ ™¦®qÜÔE’Ú^ÒÒ‡(ÖäÊÚšä²»KÊJÑï™%)‹rŒ6µ A\ÎÌÎåÌœùó O>}Nø?ÎÞÌ¢0ÂáöËÜÒÙuDçáfKD4yÙ'“4K¼TD³8 ¢gNfE*œœÓÜ}”±Óf~L•ÿñJåîòûãÙö¡’ì©ü¤Ë›Tîk%þtOñïÆ \™³3šæqZ&’ÜJÒJŠDZªTÒZ¹‰]I*ŒvÚm i;>& ¦8_ ‡á!8–Œ‹ä^sÝ/ÊÌó¡Îñl‘c˜@6Ò¦6Øô ,Œ*¦×¦ì ¶\?Ý)B@ê¶ûUMç ÆföpL“ñ„Ca·N‡aÚ‹½¾¼lMWKž¾¨××—á(p[´èg©q4 ‡lÔ°Õ øèjvðëÁ?Z]_;endstream endobj 4952 0 obj<>/XObject<<>>>>>>endobj 4953 0 obj<>stream x½WkoÛFüî_±pë‚F$ÚzÄq\#€“Ø©¦H-5A‰$R~$_ vHÞcovfvïËANñÓ£Áÿ âƒ×ãƒSÿ/ë_fA'7/©×§ñcÏÎÏiºï§4¼—þÐÐhü+É¿™Z¥“ìxüùàäfH=Œà9ÝþÐb–÷^$Òs²K馬HSihž'›I" )FÄÒâ}°”Á_*YHBZ«(ÂL£×$(É" I¡LeÊÄ’4F›“: Ê–:BÞ‹ãA|„Ð[‰(—%ÚÒLžTèÓ‘È2à"N#I*#aŒØÐLçI˜ÕÁ£#53Âl¨<•xPÖÊ„¬®}óìÙRI#Æ!™dL\øÅÚí9ds“ÐBZ¡“•4V†X »ˆ„€ Ñ©QÂÊ=æÚ8¬­0˜]ƒæÓë CÚˆ%â1c/ñ-bØK«DbÏ Ï¬ŽU†oZêµD,ú­àâ< I‘©ÀIÁRaTH³ eyšF—ÎmÌ]z³C²›TÆ"Í|ºÁÊŒ\ðØ“›S:ã@¬>3«ïx ½£X‡9ÒV®ÖñM%A”‡’3NW2°Úøê°9¦ÜsâALŽ ƒ/.tn§z>5 œ¤SˆNNÊÓï䨡'Mcäׯӑ•`6ñ>"–ÛÄV›¡]"·¯~æ)[uÝiþÙÙ >‘#¬ËÆþΫÅÒvˆ³_¢Ñ¡H/¶úù­‚O¤lI(ÊR¨9ë ¥§&™ª9MUjôË·}§öO¼AÎdq;³Gð6J¸R™˜!YLa(^Æ`Me ¡|„ –$ ý¦ÇJ)0‚ƒ9§ñŽê%šày*¤ÕŠõÖÔ HšgA‘“ Šv®£H¯ù)Ð ÎLâø 3û€3ƒZj¸0.¬@ÁT/–+,!|‚®5%똷ŒD®™µõ—=ÞY8O›‹D? ç¢UjÜ"D_K '’Ù‚ÕõÒ?‘ùö×}º}7­GM<÷|—'VÅòš™Ñ!鯗ÂN¼Éñ䨱•=¶Ú´„£ÿƒ\¾¨NsI+Ç•åƒF€uaD çyc)$Ƽɬ!Ûg ¦ ŒÈ–މ»u«Û?cL¹\ ákpëpšZCY,Œ¥TCr…f·aŽAÖ¦‹²O‚OìjK°ÔvïÆ¶ÌeÈ¢ñÎéd%TätrOÝÈ,\Z˜P-z½’„°õŒZ¢p.¶ ¦¥ Ÿn-­1KD™f!Žïz-bMïââÁ•*@㼞ËTÅçUÄꉒ;ÚÁáZ«P"µN‹­Ì´Îìc;³§pø¢¬iD· d~‚õ¿ Ž3¯VD\F¶@øªj¹‚É•U.5ÿ­ÖpÙÞæUsŸ{jBjd·ÂùÞs>‘C®Þ;ŽX¼ï‰± {3ÅÆ &Pu×Õ>Ió ^°Çó‡PÎU‚þ‘ jôËÕÝõÛé‡ñÝtôÇëß®Þ_>\½¹&œ’w¨ ©n¾Ò'˜ó1ï厛ô°g£Çùó§Î¹:’N â?®3…:!š•@™ …Ùn©ÏŽ±Ñ¹Á_øçMŽó¢IçZás£éê7,^î,£{©©Öò7ªÏ啾`—÷IðhÄÄOŽÛŒríÐÅzOñãö`{ú|i嬮%ù%GsË}Œ†Añµ£X n<¶±\Ž[ {•×1¶áN³½Â^H>‰NºhïcÅÝ‹OW”)w=©®)¡Œ¹¬´“YÜãúù¦>ùòîlµ=ñÄCû‘oUUÎË~¬w>ôŸžãÎøÒï]:«¶;ðOé­ò×6wi`4afÅèî‹¢‰xèfùüôÌôq­D9ï <÷z|ðûÁ%û›Ìendstream endobj 4954 0 obj<>/XObject<<>>>>/Annots 1699 0 R>>endobj 4955 0 obj<>stream xXmoÛ6þž_qèMAÅoyiÖØÖ¥è> Ûl_ ´DÛl%R¥¨8FÑÿ¾çHI6Ý8؆j$‘wï¹{îÔOG#âgD“KþÍÊ£a:ľŒøòçÛ£ÉÅU:¡Éô*RI“«—éE{WÐÝÑî}IÓÑ0î¼Ý½Ç[Øx¹óö§ûwÞ§]Òùí®áð~Aã!]^ÒËË+ºÏ=¨!Ýgɱ҅ҒŽ?ŸÜ8ÒÙó䥳¢É%½šS»óz%¬ÌßWΦ«ªzÝ®…M¬­m2Gï´ûK¤Ø‘ÒŽøÍ÷‘ êwÌ¿dvB7aá,yÀÍç/Ñú/ÝöΫp*óÆå£³" ÞgIft½ƒæ[Ǧ"KDVºÆjré¸:¯Ïº¹+…u³ÄçæfW]^Ós~Ï^?ã80pìqœßN‰ïtÁ£2ýߤŸYÝô¾Øâò<¿½nµqt=M/&ø îgnÜg|Š¿1YS–oNì_[aõÙU(¥—éã;} ê¼åbx™NÆø I£é”ýrôÇÑ?™§ dendstream endobj 4956 0 obj<>/XObject<<>>>>>>endobj 4957 0 obj<>stream x¥VmoÛ6þî_qhDAkZò[7+¦MQ 6ÌX¾h‰¶ÙH¢FRIŒ¢ûí»#%[Ò²¤ÃlÀ¤ã½<÷ÜsúsAˆß&sú%ùàÃr²oîÿôF×!œ± ,×0a~±ùü–©³ a™¯e‘dU*àb¥”±#³åZ¤·¥Õl[–ïO–_! #´NÑÚX]%>k^¤¿¢aaá[Ïà^j[ñ þj™ÅA|ß¾÷l¿¿«o`zmÿµëÅòöÿ-ÆÕVf),àå2œå Î=@G®ÀÑõèz C¬k8žÔ°\øJUìV@.‘ÅLε…RÉ ²X+s+U± xº]ŽÇl2Áž¦xäy™ &Ñx7èœœÍÆá>p# ɸ1pÜêÂ1¨5ûŠA(”#s™qíÓ¸)p̱›ëô­wÞ‹ûQhy.êйÿô_±¼LSª¶ c–Ç>8:PÙ?iº`¡‰Vd–ÁZ>¢ižÇú¨“WnLn¾™|ÕA§6ZØÇ' Ùk®\ÄAMàçL< ÷~bcÔ®•@ÊÀ+_éìiþý¢¬¨Ë<`±Ü <Š\H*M<(˜ª,’ýÂ㊪à:’J-‹GׂÛJ‹:­sˆÆ44sbð9›²ðÊ*œ.çº=£#S6¥C78¸¢Ÿ”±ébÑ8ê ¨¸T”˜·ÈMYÀÕ›7QôŒÊˆGi,Q)Q¨‚9ß¡È/V*7Ò’%ü~óå3”ZÝËTÈphÈY 'ŠJR‰%¦1ÊOÁâ‰To›L™ì皊µ,0ÛîJ‘󉺕ÉxYbs¬rÏÖU‘DÐ!v£¯V_vCCîâÓy—źÓXÀg>"n'QûŒÁgÒªµÂ7³¨ëi# c×›KÊY&(þµHP.öAU¨¶+Ñ?¬¥– í‡ì¢›L³…<çðâàgR¸ø¤AÞ-t’!‚pÔ]L^‘ÜÞÊ*«U&7F½‰F#¸æÄá4PC¢‘ÎD•>ÐÎy߃±hœ ›Z̼p ¼‡+ò$âîyV ÚŽ2?¾³OzˆƒB<€¯?¨=ô Ù·Íz¥paÿpi#'H \áM¤üÖ¹z×;X¢¨cºýk±ÿR4ÛÕ, v7éýsý“}²Süþ½ –Êç×**X]dÓš„~„ñ^A"Ä3¤íZ«Ü×d¼ØT|#Þ‚`æ_½®5²ýòÔb©çÐüäágM/£Ó~öx íkïVÁèú¬Âè up2ƒù>/XObject<<>>>>>>endobj 4959 0 obj<>stream x…UmoÚ0þί8Uë”VÅÞJÙ´UË„´©ZË6iBªL‧Äf¶DSÿûîHGi6‚"Ǿ—ç^žó¯Fm|Bèèeëi£ÍÚ¸Y½ÌZã+{¬Ó¥Ã>À4ö2m˜FÁëÃW'Sé ø$ç†)ìÙôgÃ+vJµfgÀ†CÔ#q‚ØFbå¤VL–¢=Ñyhv¼³8˜.”‡Òµj¤Þu+£×28¤\-r¾M©b±øR’\EämÀpi¥Z ¬ÉUÓÉL<#©À!ÇÍB¸Ê#Hˆ2ÄÈ£´•kZ’pZ@nE óÂxø>ùXÉlŒtÂX“VÚZ9Oʼn{Qa ¢Zr§ËFKøšË”£ 8 …ÎÍÓ’}°À-™2ÎÂŽî IÅVÎËaX›%wà}ÙV•R W0' Fo”³5ÿ® ELуE6שŒJp\9;*UÛ0d]j8©Ãº]üÚE÷YdÚ·T‹}бýv‡“»šƒû\QÕœN°û¶5gÓbU§v#ר¡Z]?„ÑÇhîÖÂ$kå‡B9^çöOó:¿…u"«¬¶Æ{ 6}¾ºl0¸¤”ìêüJ98Xg¨H>qGKL+¶¥Bæe¸äs;_2¤-6xæ»®ô§œ+#3n<§Êc±3çÈ\Q;#§Èüž|¯Zµ¤•çÞI&¶<[¥âßíp*U”æ±€“Ê “'e8­N0àx4Z‹Èi3áÌ@¦gðû@ðç0–ã]:yÃýh:ÒxBjºh ³À»Àœ=êäÑàxoIVcî%Uý÷s#^xÂ>Fܺ÷ÄÚó³@0š ³`vFÏ»c$;OôÕw3"öX¿Û‡^/°âS³ËÚp££<ÃùëëNjXäRºyIÃÝ_ ¯ß#ýö€u;x3 PØòí´ñ¥ñ4·endstream endobj 4960 0 obj<>/XObject<<>>>>/Annots 1710 0 R>>endobj 4961 0 obj<>stream x½X[ÓV~ß_1BZ5Ð7vâ\Z‰¢.ì´Ä˾œØ'‰‹ícŽí]"Äï7s|KÚŠZ`v<ž9sùæ›ÞŸù4Á_Ÿ¦sþ‰²³‰7ÁþðùãgÓ¹7¡y8÷¦”Qè{óFHéæl f´Zx‹n fäso9P.v:›‰S?ð½Y#±W§œ¢\M=Ÿæ"°n Âëtå…¥3 &ÎpÅ'Š †½ÃÙœ½vJg8Y6áL9‘ØÒz¦ Tg Ópåʳ ½9AÎìE6@@½r(C;Ÿ™JÕÃ¥+ÐbÊ–"°ÛC…–ôÊ¡ m°b·éP†6 ޵Ú% 0°u™â“àO¸Ê¡HR¤ íŒßh2´‹% Ükc@û\íP$q çp5Zï5U‡Bgª(½„Òdc•=°~ÏçãF×yeM\GUbòcï} þ²q?öñpŠpax„:¶ø{<îý®¨PVeºÒ¶<6þÏ{UWßõ¼ëÇ]~ïSß”€ÅÉv«-#%Gq¿±²ãéÔ›0ѹöÎ_lïC0ØŽžEzàP"“—•UI^•TJ¸*t§ÒÚ…Õ#ï&ÉŠTÞ'ýAñ£ÿÏ» 8Ü›øË%€•/àþ¡ÒäúžbU)ÑoŒ¡iŠ*Ù´ìòªåƒq°¡]K¯sz¾WF¦tóöúÅh‘ÕªŽ1[Ú¨2‰ú˜¬C…A+1­t¯JŠuÙd£cà £\%Q*{A…M²¤Jîã”TÖÑž`Áͼ¼ÂíAøi_îIáˆ9~iÒrSlêƒCŸÞ·šÀh…Ž_‘±V—…ÉcŸ”˜£Š©OÙ®(Uù®V;íÑ•±¤ï´=T{~Y§¥Fàm~ì·.W«1NìP7Ö8âB`Ù†¥ª,ñÑXuàQ*ƒS-û°ãXo“¾ºþzôÒÜóá^¤m…!¤‘&‘bò-)©(‘'V!oÉnàuÛ+²­RGá”…Ž’í wM²n .è`jʒݾBAHÌjd•SV§UÂcè&u³¦Þí¥~(ŸlŸRΣmË–ðh½Gœ‘ƒÒQ-<Ð~“i6“>èhŸ'ïA´Eb‚Ïõ{p†ûžìA,~±ýÀ-/°@K0ó–K6’ÀJ-avXÆwT‡Ã~-:EÇfKÒ6Iõx™,3yzè´¹#m k ô2AnÜ”v_ƒÑêmísĺåM?dX9?dxº~Oó’ZÜÔEaJ-]Ü«˜=ﺭþPA5jSäËŽ ø,\»¦âÑI`Ç·#7U¤.Ð ž/Út¿=ΈÛÇô‘ñ Ê2 æO£§_´ùùè¥OÇ•ËùSoRÂùWÖdrcІ”¦¶ÓŒ!tÐR­0u{„âp<ee,ÃF9 ¶#ަܰK“Pæq<£þæ1˜ElÏÈ-œv²™Q447•¬$ rËÆÄh¶D¼½åuàz—›û6vŒΡÎcmÝbÜ轺KŒDj¹.¯à¼ñk•Ò}Rñô5 ãNdúuøVº·I¥Q0øV5ÿZÔ\^R³¦›ÝŒxZžå[%GÕ¡ä<ÃEx®ñAç¨sZÇšõ‘?j¬✹ðÐbòÉ«7ë×oÖô±{à IŸŽA¿¸k:?¬þ€lsúw ?ñüy<35ôÄeàö|'– ‰£NÓR¸Üá„I™—Î΢‘mpÄ…Í.u¤o¹¶š’ç̨æIí¸ê„ÒÖÛ]üÛ•!˧…+ßÛ»ÓxÝ*+iÏøî‡Êɸ ¶lÚò|ãaGLþÿžÄÖ,9K»–|G‘-é³JÓv­t«`.+¨y¯Ö6ÂלH—ã±c ŒR¤0EÕÊë$žGÇSúv¯Ý½Ì#Ѐ½óJÇnËF¨3A;·‰uEÛÁºÌßÓ‹Ùíc·>/XObject<<>>>>>>endobj 4963 0 obj<>stream x¥VMoã6½ûW 0 Žâ¯8Ù.šC?RäÒm»^ô’ -Ž-îR¤KRɺ‹ýïIv”4 Ú$A ‰ÃáðÍ›7ó×`cúÀlÁE5øa9çcú¸ÿ6pz5‡É–k²]¼¥-ëôPd×Ri"*âv¾¦'JGK¾NÛ:Á­²5‚ó¡RÖî `ªƒC † ; TØÔº¥ŠP©)Äx…HVA¹¸¦ý²)yPGËOƒ1œL¦Q¶®]‘Œw­çæ¼~´¨'AVê3F9no]ÕE ¨¢Á䳎ѸÁ$ k9Ö» -:,0FÈ•§Ð\½V]AAÜba”åpN¯Îª60íë•E8n–;$3ð«OX$PNÃVÅÈ’gÆb\ôŒy{Ñéœ/úž£Sv[¬ÔV|Ôvk aÃÈÈêˆ]ƤväÛ®×|„)!Áû¢¨C@rÁ¯åtv,Q9UaW´¿¨jk›üö@/|m5Ü“8ƒ¹·Öß·ù®ã"Ÿ1q¦”§é4ŸÍèMgÃÊëš0iýv.™YÙзµFxÓÞ0ææM@cÁ7ÝA‡ëûËß>.áëþCÀXÛßÞõwgC~í‡_·Þû´¾ÉZ·jÔù[ퟎÏ7GgδÎõêµ.ªÚ¾Ö…6·ÿÇÅð[š<âªÿD²8Ë‹s¾w¿ô9ý¼ýP”ÇM†šÅÿ3€Jì>o‰˜- »àrUL[&V¿–mì…Aqý³ÛoI1V̰„N7UAÀ&C4î)D|Àð‚<Íb ªæ5¾@ågèÚÐcØÐÕªµHWåíÎèTR•òJ‰fS>"íé)ü!BI0‘J˜7Y³«±¿9êeLX¼ÁDÍßx“±kz1º=åñ‰-™ÿC’»Ì´0’Nw¸ŠÄÇ니@+i”’U Ö|Ï#zyy w£¾‡ ºýM(ò—e»mö@˜Ç½÷ƒ]Ùû>{lÇëO#AbZŠÞ)=“ËùÄÌb~*›hmSŠ 6nºF5èûÎ@›@zln¥î=µVÓ–Ü\%T´JŠ?¾]—•8¸cQíuW“^(¥ÅòÛcH.©tÝõ!çÅ_OÉÍ 9"^~0Ü: § “êwQÇ.šF¯_§ö¯ÐëFxêõ™»/ß/v€žÇ'©Ò*S”î{¯ùÖ.ËÙÚQ.;êØ…IÜÌÐ"“‰šm@kêTÒÉy %"hÑFêÆKO4‡`ô¯”£')×¥GÈÒ’º­Òž>_¨Ã&’®7ÍñÈWå‰Ýøs•¯£endstream endobj 4964 0 obj<>/XObject<<>>>>>>endobj 4965 0 obj<>stream x­V[oÚ0~çWMª¼@(k7í¡»têË.Zª¾ðâ$¼:væK)šößwì\J:`›4@(±ãóó}Ÿó½7¿ˆçþ—½7I/"¶zϯ"8'1$K˜F0¿˜ùü$yXA’õ…’+^ü|“ ’o½ÆÏûN¾’,.íÑy³VúøŠC[äÊ¥‚í ¾ŠîÆ|~5ŸÖÆc ·u´'ôˆ»ô°kÖ¶°µž.X0ì3“i^ZŽT®]±ª”%6ˆé@ª 6Jßàw,°ãx‘53NXx ¡ñh¶T=½€Éô‘Ãg ‡'™ D?9[:‹|Õ´ð››ê¡†žö32ó¬K< å¹î¯»‹¤g˜m „]£„j®{Ø®ªöñR maìHi«¶¤²  •d\YŠ­ÒP¡ä}ªW®`è/Ä RÚ©8ëJz#P3ÐP(ÝÍÄÅ‘J,;¨¸àFŸn’§vU»Ðž™Ê}öLtîØ‚ÃÁÛwi¼`OüÚågò;n -Ö*7Xfé-ð˜Àì6Ò‡Õ‚£‡Õbq| ¾µkz_ñÞ¶ý‡ãœ¾W<¯øÜX^«Ä´½fýn˜y=œþ“×]V>/XObject<<>>>>>>endobj 4967 0 obj<>stream xVQSã6~çWì\‡¹À€Ib’ƒvúpw--=Úi˜{É‹b+‰À–\INÈÜÜï·’í4P€ ެ•v¿ýöÛýçh@}ü(ó_V}šõ“>»» ‹›Kôi2ÇÞñ5òðYïvN~)i^ëÌ+£IΕ¾¶Ú‘ •(jyFÊ“rͲ̱Éè­•_cau)µOèÆX’O¢¬ 6šÓÆÔ´9v)÷ãÉäáèâ¦OWIʾ ût>&iŠoyO>yi5)íinÌ´—›zVHgÔ<ͺ§Ó»ûÉŸ÷“éÉOñÄ6¸ópbšŒÇøÄÉó°Öª(ÿɯMŒËQ¡åœSVººðð >ÐÏÑÉ4Ñpzý¸¦Á‹~ŒZ?ýd\Ò­®jqW{ü£JXQJDìvC`H.±î]Jdƒ*H¤%'íJ"#Žf° †ŠO:' ¹ gx];Ž ™5EaÖ ùò›J–¢rôz&8§·_2û˜:yÏ-=ø"pá€A­Zh°å…»÷/žÜíx銆.ŸF<÷v[!;iÇ’ôyK~¿„€sTªÅÒÓL’3HÖ’1|#aVFå¤åBxÙQùôizBßv0¥æçô Œ:ŸöxK u‡ú÷]~ì9?1T 0øi– ü!†€Å2+„mèÑ~Ì"½@»¹ÈÀ …B|3Ç¥Ékìjj'Èc¥³¢Î%½k ˜¨w;;’$Ùù~¼‹R# 1ÝÇë8ÖÁ÷ši øaÙÒã‹YcLÈeVUPV5.1§ t>/XObject<<>>>>>>endobj 4969 0 obj<>stream x…VaoÛ6ýî_q(PÀ1lŲc×ݺY—Z'kœü…–h››$ª”äÄ+öß÷Že9H³¶¨m‰|¼{÷î¿uBâoHã)ÿ‹ÒίËÎ0âaóŸÙÒùõfÁ˜– iú6 ¦Ó7´Œíª!-£îk‘çÉTVRo¾¸½_ÒwšgåxD=•Ñ¿?Ÿ-ÿê i€Ý˸{~NŸÅß’m©÷ˆ]º*ë¡]QùóÅ ãÕ«ÖùõñÒÅŒÇuDÝ¥¦(‘ S%²OåNcsnG÷µ]áz˜.ÅÊȨT{Iª ªñO~Û1õÁhŒÇ "®A(ÖÕ:‘Ô3²¨’ÒçYgá"ixèûŒí²')ŒŽ)r™Šœb%ˆRé¬ aÀ—|T‘HÀsé\ÆTh¤YÖËKPZÜlmŒNmê¹æšè Ð6*S F¥¶¯dó &h£ƒi¾ #N1e´S¨‘'âeþŽánÃ[ /‚ .—~Æ_ãn8 FtÉja乕F Æ‚ÃRY^•´I% ‡áëÃÁlÆóŒD7¹D;‘mŒ3Á÷8áÈl/ŒÒUq‚Ú'UrEòr]ŠË‡£QqO¥ Å º_@×`H>Š4‡®žuXK:èŠض‰*VîD‰Ù„øTˆ°÷% ê—¶BÒðëLgƒÅý§O-wø‰Œ€+¢HãLUìPr•EI×ÙžÖ…¶ní Õ)]JÔÚs°%?Ö û\•¦¾FAHwŠSmÕÈgŠéJc‹»DZ§7‡!™µ,@|’T\Nz:Iô'H³Q-Ç—Û‚¾j¯På®}¸¯3”TǰƒvL—{ç8•ôªz ^Õγê>—ùª[\ö{ý<ÑÛfÍíÍÝ|9ÿz…¥äÿ ôKΙt†Vö’h©¾‰¬,¾™²A\Ü,W/Û \@9™ÜÂ,à_®,ü 5œÊöm´?¯¾Ü´Ã£îiôsAíµŠ‘ÊÆH¹êÚ=Ž ²}…Ÿ#G[Û¢ é‰÷µìZËØ+4ˆ5'HǺ>Ñ{Q ÊDázMWIŒ‡9 / ù†Dvð†&̶J%» èÍjíX_Šs>ú³ˆŒÊKhÐÓeÛ(­TbË¢‰$^Ã9 `nI8D@—0rÖï¥í)(­E\óاÜÈ=¢ôP@¼Ör£·F¤ lÞ¤³»sDë¤T–;?ë˜M[nš>;²àÆJTƒ˜˜Ø½P‰€!2§C¿5ù¼¦½žO>/Qƒ¬J×0´÷°ýU7Ó%±”Vgž\Ût^Ã'›ýÈ»A޽à·?[ ï¡áéé7‹gÑÚøî™Ü/ÇSÚßЄ¶i\þO´Ð^Þ|çæm÷ X;é˜ÕÙ)ð=j0žø;TÜÎ~4T3ù@±(_^ÖH[~NX“*ª<׆g4ú37*µSŒ>qû´Æäv³UŠÞŽ»‰»Úx†-¾W™¿VØõî¡û];u=•¶-ë Lÿ;,èÏcV6(ú"E‚†4Ê+½ñÛúÚ¹púmòÝmyö"û£CüTgÒ}ønÚ8Vn%Rm¸.…ÁôzõmùüzVßWÃÙE0Oh:³Ð^>ïþ˜Œƒ!ý¦#ësö–Èç@nõà›nGLèÞ2+\¹Ù)©Ãd8 pM·±…“1®–ß;ÿ2Óendstream endobj 4970 0 obj<>/XObject<<>>>>>>endobj 4971 0 obj<>stream xMQ]Oƒ0}çWœ,1A#¬À@¢OñÅ8%úÜ•nÖ@‹¥›áß{ËÆ44$½÷Üóqû$`ô%È DÜU‹O?»Å|¹@ÂPm[%ªzìSE„Õ§DßI¡x7t²‡Ù`ö¼k×ÒÎÀuÙ‹QÚù›àk Þu’5œ¡þ½k¥UbÄv(öÜ*¾näH +½‚S{Ù 1*ƒ†ßyõ0DIJ~B+[³'j£{g9)^‘7š/)ãè?<äãè_¨µ²þÉâ®'×Ólg>|JjigÝê#^%WúfrC2§Þ;‘‹‹±9_–GI¹ˆó,GYL\oOQ3ÜAÛÐŽ;e´§ŒRvGW>A&,& ¸¥JoÿåíýBµüAÍiÞ?…'È©¤ôp~6O}é¡ VÁ/V’endstream endobj 4972 0 obj<>/XObject<<>>>>/Annots 1764 0 R>>endobj 4973 0 obj<>stream xÅZMoG½ëW4ŒQˆ™oOÁÆ^/r0âä¢ËhØ"g—Ãá‡Qœ_¿ïU÷LRd‰AZÏõÑÕÕUÕ-ÿï"6þ‹MZðÿº½ˆfþ†1?~ù×EZÌ"SäÅ,5­)óYæÁÖ\_ÌrY&Ü"™S°5qZΊt‚i"‚qœÎ榴&‘##þY"+ ½Y4‹ëôF¥Íf¥)9Ñ€)šÓ߉Ñ|áÖ¹ GÈZ„`Œø(Rc° cD5¦ÑqP¬Â`‹l–hVáÖ$Ñb–+Ö9\úà‹‡‚Þ‹ã +Í'Rc:\œ² Óá’Fƒ¬Ât¸D„«0†ÝX±Îa|2“â¸$)H6Ga:U"Ñ«0ؼäöY…ÁbÅÀ* §r‰ÔÄâlWá’­œ3è“‚PeŒÄDj 6α,Å* Vr[± ƒuÛ¥§¬Âô‰{db© bAJñÈ:EUxR<±¢8+} ÁWçÆ!Q¬0D±Ì\³ ƒ-˜AáŒL6wÛƒ='€zäjxp©1=uþŠ‚Ö,XA2ä„`ÊâHÁæù ëÔæãÆÉRI¢€!š±2eUl¹ Oë£p»,eÎf‚œâ€é1Û†b;gP¬Â,—s`YÔ1›ŠO‚ĬÂô˜]%›X'ûs…ò$¢ ÓcL± ÓcÙž «0ÍJ6Va®'c,&Vc°èf¥bË‘ÕB(3™ çrÀ0‹ŠxÂ*L§äY…a69••OÑúi6Ÿ#ŠЪ‚PÅð7ƒ…ZÍÊjRì Õ¢œgƪu[) W*È­4`¨M™ŠU,24׬Â`1W3ivfýXDïaV˜U¢ÈîH±NÔOM^TY41i`†âbN‹a†$åÀ¢¸,ÔÕE ¤' læ$¦ ý(µJ4”ÜySÐÕqeOÜÛ(ÏžüL÷‚1$b(’¾ço#¡²K{†'7ü1ÙDÈwGwgáѤ¥€`Irhj›’erNHɘ5àз1ŸM\€àÐ70‹Žœ¨"î8èMã äÈCªŒG@'—Ù Çs  >ZîÈ1ø‚síyä~\ª×ybé׿û÷H¾94/ïðS”Élž˜åJž`"³¬/ãØ,?ím[íß,ÿ£4ÈûŒh`‚R/8W ò5/ áò§ÝÐw«c=4ÝŽ’dc꾤>Sw»ßlð¤¸>DmÌE½W\T ÷ {“ä‘yÌ÷}eíÏÞ‡õ¿™Õ0Ø~gÚj¨7Ín}êã‹›ûŰb†ÏîÍ‹›ûuS ¦®væÖšU·³æ¾6“ñ^y±£õ¯‡¿ÇþuÓ6Ûªo†ÆÌЙö¶ÌÏ}cwƒ]™}·î«¶}ým_n¬éía0Ý6ÍÁÔ›j¼{Þ\áB¡tËy½A¹xôdñF…ãXŽÇË0Í]SW<éR$ÂQgïšó´“åyžJBËÇŸËÎçN»9ÔÝÞ¾²­·ÝþÓ9×öÎnípNƒ·Um[两ÛUŸj…/âOM5iF—k«é[û Ó~¬M=Ußð9/^ÙÇVöÒ·¹Ãdÿ•3Ǫ:n‡ñLMfϲì°Ü\UýúÈÔ@Aü¢ÄûóÈÉþà«[#æ‡v_!ò¬Ço¿ýÖ ¶Ýo«Á¥EPúâ›þÎÞ×kžB¿n³‘ÎïˆKø§×â2c)~Û­¬YÛí¥‡4•øú ñ­Ù&›½7Û®®¶æ7üEuëë+îË5»Ðßhg°î»Eé«•=Ô}³ºþæ’ùróÍã•·öÌ»iöø°+_÷³îW>'o.[;lºÕw’¤>AŸiû oÞ9ß‹NÆoŸ®™L=]Û¶ÛMÈùú tošÝ›ñÇì‹noµzcëÿžÍbwÎf •3Øùì¡%²9m}çÝ9Dóœ›w×[ “g & 7MžÍ^kÛ[‹–q6ƒìGgµvÎl6}wøÂXúÒ»gœ§×vüc ¶ˆë®µcá6ö÷ cÙÃY}é'Fs×õ¦êûê“ÿWœ~¢W9œàéé0ôUÃáõäãy}ÆÇklO½Ú`4óoa|’P´œ¬á¨päí`¶Õn}¬ÖO™iy1ÿ‹w+÷÷ó~hZÌMõƒò~cw¸Ù Ç^îï·Ÿ0ÉmO¸R?Û“Ó{ŘBOÈŒg[ôyhî+Yä9LÝõÕZ®M̵0¿÷-«v/*Õ¶ùC¦ùçee8LÜ«FÓSíV¦:ž0q•ö£ä‹8óù#òýûé…¿ÑY˜+üN-)dÎ|ðêœó·‰KpüsFäŸË‹_ü¾Âüòendstream endobj 4974 0 obj<>/XObject<<>>>>/Annots 1775 0 R>>endobj 4975 0 obj<>stream xµXkoÛÈýî_qk ­’•hQoí¢]¤îza ݸµ6ûE@0"GÒÄ$GË!¥U‹þ÷ž{‡/¹nhbÈ]Î}œ{½ iˆÿ!gü¥WÃ`ˆOø%ä—üx5žCš-–xMi³j‘ÐãUg™ÒbL;¶Î2¥p¸Fcw ë$ ë|Ä!çs ާÁ¸ZqLoœMŸägf²`›Ïu:öÏi& Ù×.SZN¸ŽÆÖYr6“`Ù1z§HQ/²Ú%š5¶…¸©ö…£!;mŒÝ5BŽç @k ¹æzï|Ö¬Ú*G¾#³W" ¶u–HhÊ4¶Î!G!·«1vװΤ–Æê1}G¦]‚A»Li¾ ÂŽ­³„Óá’1h6z§CßID®²:Ú%œŽx_cë,¥F€ÞØPc½D——ŒMcë,¹þÑ…±»†£!ÍÖ¿¬žOF¾£›» j¢Õ–gg¶Ä»XFo¢Þj¯)/³AaRMÅù )ÚëèIç¯VÁS„#<ß»O‰NuV¨ÂØŒmíÊ;‰.ª@ƒŽ1²ØºM‡t¹Cfö"3ÿ|ìg§vúrÇ—ÆŒ1TsM|äÙü³‘ç Â…"ÓÊOÕÁ‘Êb²G'VÅ&Û}>vRû¥!=®³¹&µ±eÁAnî gð³¥É"X,¼Ëß«Ã!9{sÝȧx¹c FMªQ¢•4ð3M Ã`2úºÄ”s€†bU(Úèâ¤u&üaÿ€Ý~ó ]{ã®é`MVx¢~ºÎ¯îÎ/{ö–v–¶6§”»e2¼Me¾ÿšBoî–ÐnŒ?Ú<- ü*„E?BºÏŠÜÆeTZ;¾C<9a^€«·{•ETÍuŸÎ¶ä7”ká+1>˜cu<’¸Í4Ù-'ËÏ8›¹ïd“6J¤“Ê .3*]aSóOM¿ÜÿøG‡ÆîÕÑ rüpŠ=¸%ÜC:žÄΦš#¤eºI˜üpŠlzÈõ^gÎlMqnŽ:ñlG«a»–i“ Ü“Ž9Lît²mŸèÓi¯ )°Ø[§¿¿¦>ì›”‰û”èI»BåP)r{‹El\”(H\là«0#иÁ@L[­Š’9À»¹=š…˜\GH(BãæÑºH(±§A¢¹ÞÈbËNg:W…ÍúÉd³ä,>ûxÕg© I0Ÿw¹JèÀpàÎ윘ö¢Îîì Òº§(³m`j°¡°ñS8²§lý*¸H§•6ã“IjQ™UšÓƒÇJ†::ÂüZ¢à¸Iª”Áç´4‚y¨H˜šÝÐWtÊõ€)U€4‰ü+™­0 üòR_wrkK¨/³~’Åö›¥­Ÿ¢£Ú•àY¬W.$°TÂaÏ[ È¿õV•I!ˆÈôáHÛBö#‘}ž:ÌC„fe ¸«Î¸ç£'Cú®š%´&µ® “@1.üÏSÔ–Ñ)‡ls½îÃ+¡nj‡G+U¹Û«Df•°¦r³yþDX/Z‰(àHšò %*Û•8,]@™­‰àæÜ—¡ûò3ÝÞ0wb þƒ€H¡ï•bÖeP÷öTÓS_¦-¤‡?{òŠ^·è¨’É¡5 V8rlTô$“ 2`ðê¡› A“Oê¥@4¨…ÃÃùS%6Û-Ø•\ࢤ.ðphÔ¸A”YððN>;}b˜¤ …Ýi@Z±2pn噼Ï0U "üÙ+)î)2,eˆ 'rJ£%gž¹Ä¤IX ýZEû¦;‚ o4Es –ªÌÊD:®ÕßYV–L’ 7h†Ê•‡$¯•˜Í—{KÛ2“3E<±@÷-ãÂwˆîá`øˆ)> Æc¬âÄ…¶*‚A0Ö²„L|ç÷Ô?=ã`†k ߈l£r<„MÈmnSz8CŽA'ÝBoî›Gå„¢’)¾xÚcfXèРϤ€î0ú7Åüt‰E'Î8#?¼qo±X÷Îï6Y_ÛÍGDòïæu• F§_ßÔ¤Áý*îlòÎîPw'~ëú¹UmÞO+ Ï­¶&Çh5X·çå3ùLv(ùPÛ•|­&ATÕ9×ø "® ÈÝÊE¶½ ö8ÏËÞõDŽÉi ¿¿F@nôu+XF1Î>[?ÇÆ¿œÌ%]18|"rAµâÕ…ûk‰?œ–g@äÚZò…Üm{ÌQ>thÜZøÒÐGÎ5­[¿¢ÕUKß™¨Îs„Ñeø*ó‚r„s㿟hƒ A/xhíÞžª`¾@?Ic‹Süwç7ùîý*AÿuïúÝ·M}×}ú‡X¿B%¹ÆU$£Ÿ~~ûV¼ÝÜ…ÝI÷pIô'ÀÐï¢ÚÔȃP·-Û§Š½Mt\2à­Ñˆ¢5å5!ÛAò¶f÷ÿ+U5žj |bÿ¾¤ø³iûAN8\÷ ì­ÚŠfæPV>ûAo‰'ÇÚÉæO,Ô"¨g#K2îhZÔç'ð=P®i8Tù,ÄYPSJ©uÌWpõOKØý{z<Þ¿_÷ßÓkwl”¦âdý‹ ‘_–¯£51¹ã§ s¬=õ ®1Ì­Gø¨Ä‹=ÕÒUIñ—Ÿé\™/‚a(g£5à?KýÕF¢KÍ×} ïŸÌ}g^ü®2âO@Õ7Êp:aœ~X]ýýê? h˜„endstream endobj 4976 0 obj<>/XObject<<>>>>>>endobj 4977 0 obj<>stream xWÛnÛF}÷WL ·•‰ºÙr’¢µN‰‹¨È‹cE.¥µ)®º\Z‚þ{ÏÌ’ºÆ~¨ãÈÒîpæÌÌ™‹þ9éRÿºÔðo í5‚”èÔäHƸ 8]}Ÿsv$•…vâ³Mr3²”°‡¦h’¢bÖCpF¦Ôø‘ñ­p\×Lƒ–yƒÄÀ…²ÐID·0¬Wн\;í  ‘<¥¨º[û²×jý"\´ë¤IIÔöǨ88Ãe÷mO€ðsÖ¥_¡årSp9Žg&_”þ°Àþ­EÑ !‡8†¡Bó,ËjŸâtQf~ƒ†ÛB…§û],[¢ò bc\ái ÚÆº)y ¬Xhfí#²†Êò™ÔeZ TDÚ¥Fò…쀿Â-`^Æ3f™AÚÁD•bP‡‰rjòSa)²>>¯c-Œ©RÍB'@³ éK!‘ü¸Wnª=íÛ0+4BBÕÖÎs5›vM˜\lÙ¡=8môC;Ú‚ç~¢ûYjÐ{Îm-ujÊí‚e¤ãHÀÉQåt"\`Z()¼ª!PèMk« —I¬J‰üPÃW¯ªôÍ ÀIQÁ[ŃÃ6ËÖ`G÷'ë_nÑ\´°ÿì÷p¨l©ÖÜÅÁ…  ¸»Ìs2·I™i„…ÛÉQÆ$0K!ðU Z rd·8‚-Ißò!€4–ÔÄ lbðÔšá›âæ“—ó š²R·¡'匚0HŒ³Ô¬8òx²g2Ðôj1Âmg4Óì*¸^ý¡,öòÈT¬g6C/dF„oM„± »ÙaÄ4v¦ ´{„ˆîar"ÂÎ Iá¸7›hhFžm½77e@ÞîÅ SHZaY@‡…Vä;×:aI’žÏ3˜¹ŠÏÁ¨Aû¦oŸ…Nô¬M á= HÆÔŠ{bÄi_:'˜ªvwgÍËèÈr÷£à:ôÁ»xÊœ-s•ç#—çQjaŸ†tq¦ÂT CûÀsÔÑ!Ñ«éTrÍ<nªm¤º¦¹™ÎÐ+UµŒ U›[p$δrHxÊ«-¹É 8xj³ålw™—g!ÐÒ4Nx¼yZ5¹íк[²‡:#[sK[fI5 gWf®d/ØìT/ã¸[cÓd¾]°3÷i{Vè,mbÂÖ2(÷Cðh3zÜu÷×ZLèê¢÷Ý‹@Õ£«­9”±ʽëcÅÛë :j aú3ª úán}ã¦÷w …>*±¼Œ§Ÿ?¿EN›ô›zãs¸ ƒ>ýýñã‘:ì»ÃÍMe;Å·‘°N´o»õ× ^Ãd ŽoueÕ8ã0nöˆz«a4‡{de­ÙùªÂÌ®U=ª÷¿@õ¾ ±©£±qê%P›5IxÆ®6ñRkiß¾®ÖÏîëËèªEƒëAt¾xñ8nõ£ý¾»úsásn]²˜we1¯öþÎÀ¢WAÔïa…çõýêŠþüuòG&eendstream endobj 4978 0 obj<>/XObject<<>>>>>>endobj 4979 0 obj<>stream xµWko7üî_±RT ¤³¶â¤ /R×­•ÔObrGª$Ïö5Èï,y'ëá&·†!ß‘ËáìÎìêïƒ! ð3¤ñ„Óòàåô` ðpýÇ.èðt@'ɘ¦94y6L&“§4ͪMÓ.>¡Ž©|‡|½’¥XõÈJ_YM×¢¨$=9|<ýppx:l# ¨?ÄÞŒ÷~âw›ðÌJWÞÌ?ÐOtQŸiujMùÖèŬßÍÿ°»ïsÿšZ!°8´Ç¢ØRà÷Î+Øü†ëóû•5< ³T%º´#y!Æ/MµX†<Äi"3ú{O¢¸µkæŽú¦¸ï°ÕöÐ"æªPÓÆ +Ò!\p A©U^¥pž ØW.ÿ<û¥ßGaç…´üv×£Òdæ#º1ö#•p˜Gl{ì;輯ñ&|íÜô\8•F0É$NÃð~4®nñàxˆîÀ”x„¯u¬ÿ´S–·À“~ƒÕ´Íf&dLdÈ0`½! ¦Î Glx[‰ñ%ŒŽ˜|š‰QýxŃ Cžâë×lümÛ‘¶È np§x绩âõ•Æ™ŠG3m´– øéµÜçPèÊø>úøE}Zá¯^¸×!ÄYÖ«œðvH?Ò£Ã^8¬ |¯xcíÕ¥ô—Þ‚çYnÓ«÷üoŒíuÖ”•¸× “ήu„¨øÓ|×8÷ömëLÑñ®7âƒö¿û§†(‡ñ§Û|¾kÒ'Mž%Çãcšœœ$Oãˆ4NôÚ¤AÊ¡i1¥èèquÿi¦Y´Ó ‘&Éx„—‡Ýã o{3=øýà_©ÄDendstream endobj 4980 0 obj<>/XObject<<>>>>>>endobj 4981 0 obj<>stream xVkOãFýί¸X5°‰'Ø­ªŠÒ¥åK»…H«J‘Vƒ=If±g¼3ã@ºÚÿÞsLJ¥ˆÀ±Ç÷uι÷~>ˆi„ߘ&Sþ$ùÁO³ƒQ4ÂÍö]ÒðjDçÑ„f hú&ަÓ3š¥áÔˆfI/5å]&)1nÞ\?ξ?š}:Ñ Æ™´¹ï>[?ïñ“áUܘmj£µ\ ¯Ö²:Ñ:îmÍ!˜ó›B¦rAµë)²gýef¹ïŽOÓ¿rVÅEQÏ ñ Ä`<© Ñ»2–i½Pš¼p÷Ž\™¬H8Rº(= »,s©=*¤×Ò:etŸ8ƒ\Ž¡éN²QZ¦´€1'?—R'Ò‘YðKN&%W¥µä"‚Ó¦Àc®ˆ|y‘É·Ê…HÇÑdÓÞ«Úë¼§ôüˆöK“¬„¥cçm±{ʤîØô¥q  üÆô½ßÜz«ôòã…«.æ½ÃP€‡3Ãcj­Óñp߯ø©[õ—Ü}ŸýÀF¾tl|ݱXcÖò_KL©Ÿa_Õ7sîW‘'5 ‡Wß Â5ð_)†ÔÉ> r¨„Q±ÀÜ}’‰'<–…Ð)°FPÇ ¡,#}ùߪA%‘9C…5k•‚‚VœÞõ+I¥.] B¯…U:lÊX¡EŽÈ%+™s k“­ùbaW|îÆÕ&¯^ïÄxïr „ÂúU-7Ãí]e0ž2áâ8Š£º‘%×¢%ý®->}‚S8?kT!¬„Dm.²l³«B&j¡’`‹8†V^HV¢˜ÞK«¡_̓„Ü:R ¥„ÞS(@À,¢“iHù ÷»–ô 6\ä”ë 0ðÁ7…²Zê éLÝËðø? ïZ{¹”„,.HËÕ=•V ½+ N‡±w,#¼?ïíÓ÷ŸhzA¹Ay—RK âÀ¼j4ņABž (…éVÕrå•(Šl³‹`ReÁnîQÿ¯"œÔ^_Ü/CËDÕœw(Z‹w§ Œ]Õïö„m]MéQ½où¼‘¾´ú©ËµÈJÙm8/ø«†¿àZA¾˜ÕÚ$ѶPŠÁüè»æ«:WA6G¾2W:Òì £çáÉ¥•Ä‹{é*è¦ö9º.šu°Û W‚ÇØî”2Ÿ¨DˆDzrÌY&6<†3^¾¥)ðS:Éʯ±×Vp‰ÉstLY+<„é¤5ƒž£Ï1ñ ãMãmKî¡Øðj•Ô˼mD?ÝçÂZ™2Ky kÂ-2W¡mãi‰©ì„ -ÿ›ŽÅƒ›¿p êj¡æ!—»M³féÔ=Lõ¦éCè‹P³•€ª¸õ›Œ¶ëØ`ÜÎvöÍ+³ºbT؈¶•éiºýpý `¥H7t¯ÍC=SµñVÏØí„»Í=´„ˆþ©Ñßyªb½Sè ‚×ËGÄ)}à¢5»SëAùUëáÇ]×O'"-¬ÊîÍLÝ’ÐÉl5>¸³=X ZVÏcÐU:xç¤3ŒŒ V¥S…qË“õrxùú5¥Â‹€oD3p›—±ÝY›”Öb˃̜zl»k,em 4ÌpŒè¼©r¨HS ^Õ3ä´–fÈ’§âE³@®0®2dÒ@ó,˜ cö—;~ðØovæM½Õ× aoÙ^×Äç'Ñéä”°øGqµI2q“hD?›$,·XÛæ¸@³êôà¬ZŸÃ0¡÷Õ`¦\ø„ùÀgOGÓh2ƺÀ«Âéßz7;øãàoÆ)·%endstream endobj 4982 0 obj<>/XObject<<>>>>>>endobj 4983 0 obj<>stream xµWmoâFþί¥ªJîÀœDUUåIS]5GuJU-ö{Yv}»ëzêïÌ®íBRQQ%JŒ×ÌË3Ï<3þÜèBºÐKè7]4Þ¨ƒ7ë?f'×§ÐíÀhJ%x•ùð"mÞª¼pÀ̬Xpå Õê‘+´‚qóH¨#p«œ/X>>ŽŽGŸ'×ÝóÒXû,"ÿ£¬9Ž“3§•':kwc:Ýò@ö óôA¨9¡þó|Ýn#9S™,ý`Žºpp²•Ð#“ÅfF‡ÊfË‘P &Å_Ì•õÁ”èærºâSVȯD°T™,Ü<€ù­L ·º0)‡SlÆ=óÐßÔpŽ)íë¯_2>. Ÿëî¹+Œ‚PœŠ%ƒá<êQ;Ä|:Žz=ü”5…rá¼S7aªõ˜à©™.&’ê…ìeÞØññ÷›¤ï&h¯%Ø hïºP©/”Ye³ÁCÈ\_ÀƒØ×½|¿£pSm@ñ¥\“R§Ìñ ôäO'Q]÷u¾³¨Ã§”çÓÿ«¢àæF/ÇÍ-¦4á mVCc´iÁ­Êø“¿Þ&Ì¿Pâ§JŽôo߯ó±¨b*=lmy]¤HÛÔ&±Œ`Ha»•ܳ6 Ú¿JíKkÅLù¶ÅLÌ6øðÉÛ!ÆÇ=g)ø‹^þCí$–xÂÍ6Jµl¢d)R×Z×pÒ¸õŠO¿Ç?¶iâÁm“Åðàß{ 1ÇÀiÄ#•ÌÚ“IaPL}üp¹?þ; #£åÀpÏÏ­t6‘ù§†P®ïî GOÖY~‹Ú ‘¢¾»¼‡à4ö©×ÏpU,à \¾¶àýåÍð¾Fw¿àuˆed€t¬½xí½äï969«#ÿ)ÕÙÞ¢T)b{}Ò\qÇ„´äš³tNÿÝœ[^mN–BJ˜àŽ q·Bu´smœ\Ep)­Æq ZP ™š8a¡³Û§ã J4Y–áð× Û¸\È,za~bx~ÓâO9 9non.,Ha]„$5¨4l‘KÞ¢ÐàgöÈJ'¥}‹t¢†ånåã;ŸE!0„§3Zú5j- F’…Òõ6«jû`&BQß"þ,;íu~•ØáHMýÚr6- Fh0,j¹s^%8Åm³'ÔYÝnÔøˆ@ÊÔwŽàÍ4Òn)ܼ†èÇÀÔªlôõÓȯ£*ÃúÛ…ÅÊ`_•€çFçXe œå9N8<œrg»ÏµFð-çZò-°m‘ç™°ÒÌYl¡5X©$ Ö¬B~AvHoÞ,Øÿ¯Âf¢žÍ/,_÷¢°Ä):Ž|üðñö&¤Vy ïÍgæ7AlBØgÐ{aîãô¢ZÕòž&é£ðZ>áÎq³*ص…_8` q”¸qy6—%ñ Ý7fQ½¤Ü› t¹îUìhb>µ _ó¥.dFÌBÕ©ð›Màל‡ªw¡¸sõ{}HΓÀ/B·Ý‹:pµNqúV'<Û> âï¹Ü¯¹ü “û$êÅá«Û?'kÃQãׯ?KW[endstream endobj 4984 0 obj<>/XObject<<>>>>/Annots 1782 0 R>>endobj 4985 0 obj<>stream xXmoãÆþî_1¸Â¨œÈ´$êÍɇà⋃ Es=ȇ(VäJÚ†äòvIÉjÑÿÞgfI‰T|išóAÖ’û2óÌ<ÏÌúãÕ˜FøS<çÿI~5ŠFxÂcþøðíÕrh¾Xà3§ñ4Žâf”ÑÓUwŒ·‹ûhÑy{?Šf4—Ñœ—Ž—XF²´3ÆÛÙ,ZvßvÆx{?¦Ý·qN“Ù¨·¶;Æ[ußYb¸ÒZOÎ#¶ª;Î)^ôÏÇcøÇ#ñ(ž.`UñÚ¯Ÿ;ð †nKwSèyœç÷ø’ ¼ø’ RU©êXjºyþçÕÝ#0—‰ƒGké³ð¬]< õ‘Låu¶‰èy§ÞX§‡¤(±y™éJgGJÍfƒ7EEO?~÷-%µ¯lnþ¥*c Êu²S…ñ9­ç]o´ªj§/Ž\ÝñT{£jg<ÏÑíx?eíJëuD¶ðuVaFpå"‰€Âà¡gËc8/lwʸ²ÁÒ²ÒNŽÍá'™äÁµ¶5Ÿ¥ª¨1g2esžd®JO*ó–Uüµ¢µöW–œVΩb«‰}Á7Ï[ŠÍÖ¥8ÌnH¹m?Ñ#féÅØÉlèhkÚ©€oê"D3ó«T¾hñä G¤'€h2‰â£t°·†´«)ª!ûæè³ÕÍ—}´oeQÍç ^ÄÇ€?q’ˆkð›hÇ¡„' øÉf$C–Ùƒ)¶b,¦&x sþ_“ÅÚ7;ýÞ cäÁéß_èƒÞkÇ9q:øwù.@wPÈJ6él8[ÇÆ&¶Øs䨗œÒÁ™ ,)9ZäMá+­Ò^”~?× …ÊõjÀ®Ý`cUþ‚¯Nh&æàÚ°HÓõ¿›Ä %€íŠÕ Ð#+àÒ 6ëÏTßËÐ7A>íÿŸÞ¶×2¼{¼'¦Ó)Ãi3k3R3†š>™Üd 8íÀ·¾ÔIE?8Ì…÷ÎnÊs ÙoÆê¿D vÊS©@×™ì$ÆœÈ'rÏL½<àÉnªƒß!ð™-™·?¼_Ýô·8ñWJDí%ÀBBÃ`›Ùíñ[ÐÁT;p6x ¿Å‡@ YØJx¾7úÀYé?óÀ7 1kTõ €0Îz›ÔUÕ¤_¢]!ZtëÁ¬²”¼:©¸—Û´æà4 aF¶iª2SñDelïnX`R$ûÎ$;VÜÒ™›BÐñËïšðæ¸çl~Dø¨ $ÔePƒZAT‘ÒÃÝÃ矋4Þ=Ž—÷·‹h,y–VH q÷ØbÃ/pÞ¦{“\V‚Fã­mzdÖV <Ä—TŸm×/À"‡.X)ÄÌ®pÐéµq:}ÕHaâ§l …ç½õpLpâT"ƒ•eóu ‰ŠèÃòb 1‡¹Ìz"¦_Æ'<…•[8àû‚Ó쟵5Ðé7–†ÇgQÅצ®I£Ö ª(½„f5,MZ![ÚÀ\U ÷Yþ¥-h·“%º£&ö¡kขö8Åê±S{&Œ"¯ý¿*l9ÕÓZ…ª`k¼“$ÿ­¸t;³6t„£í È×p‡äN­Ñµ~ItÉѼ€T¢ÍvËÉ­.|Š¿À>€Dà £Êœ“âÒmTš”j˾KSÐ<ŠT*ȨŠã‰÷MZ]g!ž³îˆ¢/EW l‚÷Tm·Ów¨#ßÏ úk voRHBªÁÅL2õÜ'á•ÚB_@FKm5µÐ‡6yÐì<³Ý C»é!‰ÒQ™„ÕŽ YÖUŠ“0xnQ3ùnMŠTŠK[¹ùœ ÝJ%Ò‰Þñ½=€‰hr€hSOzžËv³kÎmN(ËÌ$7œ‡fcq ñD[á<·¾®Î´—¨ªR˜ßöU,¾r¶ØBuQjSöŒ9‡\Ö.;r졪agD÷‘‘¢k%ãzF…QÞ£ƒÄRˆ>÷p¼1:Oo µÆÖ…jn”ëA+¥Žƒ`}¦ôB{•Õ†Hœb/éð~Êýì¿Yècr³1 ãj £m4¼¤ñ—’¹º•«nÿ±÷H¾T²=|,™|R‘ö,Î5ºr.OŠŽ4PÖPw _aQÎØûƒ­³”¹t@+y« _,€–má__Ê#«ÈÎò‡n;CkªÚÜ}zÇzm¶ ŸHãS%;#m}ØqêtE½mè AÆUÄÕ%ÌC4mQ/ jÂ_‡(¸3}¥}â‹«¤´ 0zµ5Ôæ›dßEÿè»Ûq1av5‚èúÄ™57sqÍ¢ ¢6šÏnv.‚×¾‡Ç­fpÑsœp{\ŒÂ•0LxMq&(íïôÆAº_ݰ£5ïè‚$oÊk´ÚólóµQ' Á&ôƒ¡žf|©Ëƒ¿€%=ÏâÖçܽ!‹Yr¶†&à'Š¢ˆ~#­T•­nþÇ- q¿½O¨¹± r]í¬$9Ãß>¥ŸZufZ\³™g-íäŸqÏΓù¼ÌÚMø/+œ\i.Ss<õkãY4Ïh>ŸD˱Ü#YFoù¯ïl"·TÁ–7ÂÍaÍâÝ.ÂE*Íœ~d ·Hp0™æ¶ºAÁÅ‹g£yO‚eãÙ=?úæùêWÿ³tçendstream endobj 4986 0 obj<>/XObject<<>>>>/Annots 1785 0 R>>endobj 4987 0 obj<>stream xWÛrÛ6}÷Wì¨I‡vdZ7+N:~hs«;m'­Ýö!Êd`’ÐC@vÔ$ÿÞ³!‰’cuêxBörΞ]èÃAŸzø×§á˜³ò —öð ÿéóŸß_ŒÆ£tHÃ'§iJ:ퟦOšUA—¼Ÿ†gCÿ®?JGÍ‚_m,qî,… ¿‘ßýpµáÉ»«gtòrLý]MÒø r ²¤”nnòë¿N^Žš] )K‚¬*«b‰-JIn.ÙJfjª¤¥[^¾W:'3%·¬d)*>v-•žQ.§JË<¥ Ç.ìBkS…z/)¸>°¤£tg+Šîγp»›LÝ6Õ£ãþ9&QÏî8‘ÒÕ\Rµ¨+c¥~.ñ€°n.mV«k™S!œ¬Ó`áñ`ÄöK“3µÝŠÛ£§ÉTN- ÊLYMY‰æ`TYÇ~Ûa'ŒòyçF ¹$ùO­¡ŠZ’5X•`ÂΉlNò£«)=5u)عÇnV˜D¦ˆC¦fê$v(éŽ ¡g 1“È¿’:—Úy‡¨ø…5ô^›[M>Âá@-œ´_‰wrÂwa´BÂgy³TÁ¨¬5œp‰ñ«èíV!³l8œI-kÌù"‘’Gÿ#Ê©) skŸF Ï 7ˆ`4ƒt8Ä*Ob€„Ÿ§ä}5Лîærk‘¦)½¥ïta³±7¶è M0_ÚÉ!½\øÝì1þ|žƒÔþó‘Iâô)Ãü鵤9éá0s /¸\8óˆ6ƒT»ŽÂ°wÛKâºAµ,JT‡¶K†Äšf›Ðj ¼e"¬\NÇc¯Ñ†Z”ö +Ï—m—äN|™Ðè-·†LPê(éo:—eejQ/¡—Z‰ë¡¬À%³-ûV0ëS¾ÒàN~¬ ÁŒìÜÔ®X~­Ì3“K¶µF<Ùh– ì@#„©&õ”þhº£›ƒü>;a-°Å.A[q¿uÐtæû(ÍÙ¢GÙÚ.ÙhEáÿ$nD+3¦íÙ7¨`vÁPfF;$¶mÃ{e=Q&ë°®ÐÚ™ çO:æ-ô’ŒŽÝ³7~–âÁqbMÙ?¥OÄ:úƒÝÖÅgêø ¾!rÛÝð0˜xèm¬á÷?Xü¯Æ5#Œ¹¨jYÕ&“Ö"SÏ5ˆfŒ|l\U GŸ¾ ªT¨8àËlh³b¤häîÖuK®5ôôÍÝV†)·5ú1“×Äܽ8ˆ«rÿbumˆÃ4v?§ßOiŸžó—^"ªˆwŸöÆép€oL¸.õÇ=þèÅÕÁoÿù%endstream endobj 4988 0 obj<>/XObject<<>>>>>>endobj 4989 0 obj<>stream x­V]oÛ6}÷¯¸/AÀ¦-)qÒ{h×yËËŠaú` %Êb'‘šHÅŠþ÷ÝKRþŠÝ9Ú"€˜ûÍsÎåߣføC:§ÿY=ú°ÍØ ·¿Ú5L3¸g), Hf0³ùü–¹³šÁ2‹¾]/¿Œ¦‹ˆñ³€ šM’4˜EïóZZ+òªƒ´o (mÁ–jm,´‚ç|U 0½²ü¸…B¶ø‡uÅU&üª7âI´cçÒtm£]¸O©rù$óŽWÐH‘ YU°™®d•à-óµ½…8¡Ú¨²9Å1Kõ¨y&Ó8lƒLoØ ÂJ …T"¼Zô•Ê€T ŠBdX»nc ¡À\do¹•­lIÍéªÒï·AjÞcÅ8ˆÀÅÈ%Æk…²TVBÕç‘Á.†ç Ó6«Â1-0±xæuS‰|û·6I–¦x‡y4™ã!6ÞZ]…¦#©¯1¶…¯Œ¹YR1ÎÁÝ: É}‘}Á3Kîöñúœøw.5ù®³Ü¹Â3¢¿û£/}}ÞÝyrPíÿÐŽ4M+kq¶££Ôg ðI ¼šL4tw`µƒî!žTkh» áÛˆÖ:D«á&=±¢+ñl…Êýé@·‘¹EƒË\¤ÎˆœªáÖò¬%6û®z¨ÃG>qcqflÛe¶k'$õÅàƒÈ8ÆôЗyr†Èïeu®*ýS™nõ…v4??7¢Öaµè±c%òŽ§Ñ„¬M‰Ärß¾!i¨ À‰¾‚L>ÂBë#® ø_Ðå](Ðãö_ñù2À¡¿‡òþDnjsUñ20*Pi‡W(9Ép-ðq‡ „‡„‡%Ø”2 Øñý½ésð¦AÝ5¨i(†~ÐC³û;7ébÐi¿Cn‡âÔ:…ŸtÓY¶ L%íx·§Ø;yÅvˆbØÌªGÌ;wcäZÕ¨®¯¸ê¡š)êヲb-Zø‘Ô*?0òh"cl)Í÷eùtø1üÖÕ+Ú~˜%Mþ´—䣆wˆ³×ÊÔ\ñµïIŒûÇo"êvÍ ;Áü÷‰Ðõð¾raØ~WìºÓn‡ËLŸxëF}AT4õ ØaãèN–šPÑïi*WÐd’>„ "ŒI)_È¢¼êá½fvÎ?tö°ôí`k"•ï®Djk¿ºàqÀÈ«!ü€ý½+mË-ª¹Êò|‹÷áißß°Ûôæ÷w,öï‰?>?ü2IÙ >ê¬#N¹×¹áȽõäΣàÜ›ëv6gi‚o3|†Äs÷,ùy9ú}ô5ˆìendstream endobj 4990 0 obj<>/XObject<<>>>>>>endobj 4991 0 obj<>stream x½VÛnÛF}×WÌKZÆ‘© -Åqž§nóТm +r%mºÚe¹K»jï™]’2%5µZÙ¨½ÌåÌ93üc0¡1þ&”Íù?ßÞ,ãtŒÅî«ZÓèæ‚&cZ¬pvþ EØÇCž,6’JὬŒ£•­èùâã`t£áBòL”¥ÞÅÅÖJ‚ƒZÛ{ò¸ìÄVRUkéHœ¶àw¥ÜŠòÀFJ7ð&ÿÛRË«ÖëešqœÓ1O§i–áWÑÄ@Êx:³µ/kOŸèñr-«nåók:ñhÝÓ½ò2ˆ–}Á>'ØÙ¾Mò€±e½GZšÛçpó`c%«¸çÔ_›ìö¨µWÈDµ®·Òx“yE“)çr’™¥óùKv8™¤Óô‚ÞJ-½2ktàçpã›öåÂÐRRÁweAË9øvXY)ÃÖŒ¥Üò)à6îoÅäC ‘ãµ–¢r]ÌìydgHÚšõÜÆVlôíôþ‹Ñ¶Þmë–™ë¬ÅšÉìùœs*ý[ ª’¹Ww’Â6¨¬u›m$µ 5¶MX| ºÁÞ)T#YÉ/rkïX=ËèïÞÎP‹@D­ýõ:¦4kt{ÄÖ·k¡Jè½2¹¤÷Þ}÷µc ôÚˆ;Åõ kÊDž5ÅuÃP$îª6ôd¼ˆ`‘V¿Þ$²ïA ”ˆT·gýFø)Õ¦vb©;qB:ER´G;[g#Í!42òžœôdWû*©íVJx =ˆZhO6[ÊJxeMajµÉ*›wªœÑOZä’3zh¹O–Â\4¥¹ѾÛk”מg@õ¶KÀär„2 ½‚®_¼=É•p<$aŠþŒ8÷¾©>qü]¿íÒ4 Ð-}n Osî!r¾8¾Œú#"ìUà@ ]g‡ý¬ï?;a…ÏÆÁkm,±9·¿bdÑó´é~Je½Ô*#¤ ‡Z£!çY‚ôU|þ­’èåìÿR˜4è‡áòþÂk9|‘Kðµ—ÁB?lÐ\ºY@˜º¡ã*ãTß•Ú H`yÔAìsL®Vè`‘W#'A%–Yâ8Ãsó6ùXŒ Ô¥DÇ ëØ4÷½½—w<éøfSMò+Ú?V´Í[3¤–Dž[xMi±¦l‘¯¢{ðŠÒÓɱþ¿1íÅékü 6H¦’hÏæì¾R< [¨‡ tu5Ðw¤ô+šÓ¡ábî­XïËïCÿ p-“1§ÏXúmàt6júCÔäã S¾l&Òäò"e3š_fé$¾×1/ϳtLomÞœB‹æk(@<}þ2z oM]ÛrwôÒ4ÏÓlŠw[~»šOùþ·‹Áσ¿–¹2¡endstream endobj 4992 0 obj<>/XObject<<>>>>>>endobj 4993 0 obj<>stream x­WQoÛ6~ϯ¸—Nj+–8n7 h»tËC‹¬5Póh‰²¹È¢FRqƒbÿ}ß‘’Én×KÓÄ‘Èãwwß}wüû$¦1þÅ4ñw²=y±8Gcõ”â‹QÊP£Éœ?¦ƒ8Óo…sÒ´.k2U.m× ï¹ˆæsÞ´0+#•61j%™Ž³D«ÚmT²¡—ç/Ÿ<¡T8Á|B™uÖêD ΰeZD|NèZ0®–H³^Yi/,&NÜ1•«j½fÇtÉ qnn5Ò §ûn!<³&8QL/„UIÈ±àø€.Bq×u:Ç'<‘ó½ÀÕÓëîaµÊds{©­úw:Ç4wü¾æž„ŸËØ%¾v ¿×žÇ»m~¼ûȦ²Çëýçw¸îa¨}Q6ų<íbðæ¬‘7çOÿ‚•Ï&ì½ïNšïDTÏåMæx>¦-k ß3êñˆ%õJ=œÜIˆ&„+ü´D¿qsFIÁt#)ž—¸¿ìüìÝöV< «¡´< Á+?úÝ7n¾Œaxû2i{·N¯5﮸V¶^Æ 7—K\#QÇÌ}ÙÚ$0¸ÕâùEt9½Äýzc_W|¡íÑ/:ñs¯—Þ†»kX=º ¬Ãµe]Ò-+OÈÍx„²ò±»Ï¢é$ôóx6e׋“ßOþû²§endstream endobj 4994 0 obj<>/XObject<<>>>>>>endobj 4995 0 obj<>stream xVMoã6½ûWÌ¥€RIJ>l'» ØìÆE.‹-j (êh‰²ÙJ¢"RŽ¢ÿ½3$e‹®×A›†Cç ç=òyC„¿1¤sú˪ÑÃr…?Ú L܇), H"˜¿‹Ãùü–¹‰Š`™ß,ÿE0Æée|§ ¯X³ D½ºLÖJƒ¨5|ÿ ¹ÈØD@†àâ!õ&¯‚ÜoÓ߯ãMÿ#ÞÇ/¿¾8»‚¸“"‡D™îW7ù™L,û=´]ÉÝà*èYÇ«Õà<8œÃœ! œp’K8ŸVÁ þ6«ÿ“ÏgçÕd…8ìW›Ö)ŸôR>–×ÏîÈÌåCÇy*Ð gz gÑãÄQ9¨Çct™YœÉbÔ}…i×q’ºn>ɪaZ¬E)ôj©ù{:—Ébêâøù—§ÇIˆê meÞe<¥[Ñ4¢Þ€ÞrxîX) Á[²æ8É`hQñ¾¶B¶°Ãiºpk„•åp©¨iuß ÉŠB›Ñ;ˆq¨@펓9ÍÅq˜†8„ÂËy-ÇÌ´Ù b:Ûbn>Z8 §´ô©@®`Â@((dWçЩžÕQ![íiùNÈÓæþÖTXÓ”£ãy ¥YIÀ¹å gZÑ'|–œµÙÓhMˆa‚å¡õ!,%ˆ²ì°àLó[P]ÓHÅá ;ز»1çPŠ?9.ÊÞлÆI¦):Ù¿LŠD{Õ›â>Kc\¾7õ¬ ä©Ö|ÃÛ^¸‘ôºdÛUàæ¤èŸ ¹ç ‘k!°`ÔS´ÊTÅ.B×6=|ÂóÁw4/X/ÄiÑ•_ÙB–¥|1ÇlÑß(Ø1q™õ7?c²@´Oßf· 4ѪsìXø¿ñ$9ŸàjwY¾N1ßè„„½GˆFÌÏw4ªx,¿é“œÑ|Ü!#½•Ýf úÛ˪ ›­†5µ$š«8ìÄQ'½~è$Pîˆ.@!‹[Ÿ¤Àj‚ækBÀz¢Šð£ÖåÁÄÎ!Gȃ%6>y áÑB¤Ã[®4Õ?CáÈJ¼¢ÉÉP9ÊšIwÍ9™,yy@ç9vÝO+^!,(“=«šÅG¢ËdWæðÒ ÍOâëËiòy[ˆÄŠ<+—ÝšnÇÆ~±·'ZúW©„;¬‡ pèö¥Ó®hàëóì â°/ |ÃÉœ]¾Fúô=ÛçÊ`»Ä ;ÛÎQ¸l(v?¬þ=ƒ<ÄÞ`ìÆ.;4åUà¾دƒÔüJô¹¨çV¯‚þ¿áêÁRÃj²¸wæßOÃY:ƒù]ÞYÛ47`Š÷ßg™u6 i&JÕ`£Çw6is'ÅðÀ”Ȭ’¨ Í}Bñ³h¦ ^at}ÍÍSíq9úiôE›endstream endobj 4996 0 obj<>/XObject<<>>>>>>endobj 4997 0 obj<>stream xVÛnÛ8}÷W °U¶ê[Üì²—yÙÅ6ŠEÒZ¢ln$Q©¸î×ïR”%×É‹ެ!‡Ã3çÌ̧ь¦ø›ÑbÅŸ¤ý²Mã)^v_õ–ÞÜ,i6¥u†µ«ð:;’èÃN–TË´IT¹%»“d•“.ó¾üÏTf~Uº$eHTU®dJÂ’ « Ó[u²£ªÖ‰4†]ZU6ÒÕnËáèÅPcNâõúŸÑ”&³9Š a±dº)SÒu»ªÔTèZö·'¢¤¤B¤2n}Ì—ìã»] ÀDXÄÈ÷1cw5wOw‡.DxÙÊRÖXŠ«ä äÊXÒUÂZY—&¦_uiT*kç$Óy®÷@ëG>öÍÍ”.ãƒ;Ç5æóx±À¯4âc7UZº-­ÜÊú§pWNA· 5Ò{½_Þ/?=i• ý±™j½7÷³éLJ×nÙ1±wø"^­Þ²ïµ¦L@|Ñ ˜pnCÄž CŸÞ˜‘¨·M!K;¦»·ïh¯›<¥d'“Ç! Nc2VWóȱgÏÔR¶Íå™D¿ ààÂ䜅aøú­èú¿Ï˜î{¯PúŽÞ3ñ¥ƒž&“«(¤aà:¤(ÀÿœczÎÖEÖƒóFÁ½³ôÍ'a†u©*í DüîØqÛÎ…Öíadúçú°Ü¶éY¾±æ*Q‹BB1êKP¤ôˆ "!Fè«¡Q¶¡È'pÄI»'٘ÒFÒA7´)]HJe’ã ÞjZÏ;e^&Ñ7«ûùÖËtÜþ¿bá)uF›\ì"g¥ï?ÿ—oK5-…•eØ•Wœ Qu‚êBˆA¶AЧú 0޹‰^†¤¿‰ ¯£`û²¥Ô 1Y‡§¯PÐðÜ@ô kÎݦ‚Î0žEÇA´WçÎ9Yðÿ£çðFv~ÌÂiEF;àDw-M©ù^Žý}’ù‘ËÌN 6ÄüÅ+î³U…îŠfô'wfW[Ñ{îz ‘ûíÀOÀß5Yç“ïmæ6Ê»4¶9)[Ã-ðrnï`ðFîÄ“‚Ö ) AK4q½ÝNa`À@ÐÞôõ˜`DËxühû|ÈÝ­WÜÕºhL›ÆMGGg¨ß1‘á?ñж«õ¥öcÚ LcºN …¶žæ–"î„j n=ÀHÍ•,™LØ$_qÁ±6—˜mDb1Yä@OLCm_+7=„{jø·¯}HR–1D5ËÿW-݄壀LKYãkÞ0–Dïuý(kC]µN<× U0pθHªŒ‡Ê17`\ìŽPˆw¨/~Ô©8bRÜ”Ào±Ôço=¤mî¢#]N±Ãw}FŽнR-ÍÙRÛ0'ryãÈàlW£6xhãŠéâáCBÏÃS¯ ¸ËíUžûyÃÑ™Õâ÷{«._Y°IavM…O?â´AL®Îz( °ë³@ÓB¾¶.€àó”…w¶n׈Â{ÃrüFbZ$%_#+’|,íË Hœõxì­P†L< ÷uÂ:¿YÍštó¥mƒ¸lS;Ÿ.ã‹Å­.]/à¼Mñ”~Ó‰›“ø@Ô4¿ròÖ·Ù,^Ä(*-‚kq¾˜®âÅêǬ3[]°§ß×£¿FÿÖÚôendstream endobj 4998 0 obj<>/XObject<<>>>>/Annots 1787 0 R>>endobj 4999 0 obj<>stream x¥X[oÛ6~ϯ8°ÔimÅ—ÄMº§^–¢ÀZl‹±¡¨‡–h›­$z”d×-úß÷R”,9·s‹ØÉsýÎÿ ¨ù˜õƒ>ÞðŸÿùãõÑe?ÑpŒ)¡ËK|Ùß1ÝÕO †WÁy½´óˆµÑUðtg­~ÄÚŸ±V?bíò¼±V?&4\5͓ɭøfAg×}º„ð“9 û4¾ãñSšDV¿>MÂN–›"ÌéÆ}} ‚àÛϧ“G}ê °!êäÛ•ŒäÜïp'î¥ß ÚØùoMÄjÚQéô´ËN±H…XHJtÄùÆFAð¢&d•"z=Ÿ fr)Ö qñû—€±JT®Ö.ʳ p»Lseo–†³´ÍYn„Z,sXc#LÔˆÉ.§ …J †eÅ&[Š8h絈 IØáZŤÍG£põ‰UPÙ3o­ºÐôP G#”½¢À0©?Ç(Ìd- ’µFV͹.ûºâ*P«®dKÝþÓ&áV$25‚ÉÚDÜê>¼ñV¿­â9s±' Ü ºO«¥•;ë¤?ù¡³NèÏ–:ÔЕБ/¡7 Ù·*U0Íuë Ò²ºwxY-TÀ±{[E œjlÞDåé–2v8€sR#`ï‹‘n˽ñ]‰ô¥¤Œ.Ëå²9h†¯ÂO`\¬òñèB« oDŸ ï½ÈqV‡3´‚2¶½¨â’ã,\ ›¯‹\åìaŒØÚ|°Ä;”NÄ0*lšÈ$ÕiÏg6ZY-Wh`Ë:—P¹j’à2á[˜2ÚV«êê"ªÒZE8‡ÈýN™’á×!ìr‡ruŠ´Ç}4¸ øB!ìRä€dX¦2H¡B”Ò]Rz˜Õ*V.ß´Í ,õ†«ç†A «ôØ{ƒ6ºˆ#×qú®TUÑêó•ÓN%að¬gX^¾ýÓj—[a]±{¼{ºÉ®„ÀŒèPv.Ÿ8¦·³s;`ú]ìJ“ÞÇîÓÆîÃówïÿ®ìéØ ^Ñ\}ž2õpv±e•‹ïößaìèCÍŒ0È0ŠôSª7©å9vûï~v2-Û@pçÝÒÎÇNå-Î+ö€­ÕÙ­ø¼Ÿs“éI©Ý­ìvÔ^Üa?»*¦—¿>¿¹yöì1fDoNÏЇB"“’Q¥î­áw ÃÊ”üÃy/SvVñ\ïgãÏ;vwÖM []ÐF`ü±å I>EÈŠ?ʪÜRñb–røÚÐulv³K[ëf‘s®(Z¸²m»³õùÙõˆïtŽ •³iKÿ²NØÉ‘ó·9]{.Bq__ruÈVïH§ò²bp}× mÜüùc9Ù›Ú~ÿW•­€oFZ-Ž©¼ÒÐh@gÇ¡†‚gVe[6•µ¹Õv!sW£ L¨‘›P×bn”Ì ÜT KiD׆³õŠs—GÆZ}¤¨FYÞi–í¬#]ð@¤óPÅùŽaÚùS†9Ä]*ͪ“;m±7¡»£cþTÇudåP_@í-},€ XÅ!&ñH¹ž-Šö¾¢Š ‘ f7h£w8Œ ã½#’“"–ÍaÐ2hÉuÝM;Lºu͇˲š§Hf¡Q3(ƒ¾Š§’ OA¬Â´¸hõ÷l驵³ëËòeØ?.F4¾»Ë%ÒÞ(èÓ+•¢Lèt{{OÝÀsð-ÖEŒ†¸Â 5™Ø/“£ßþó5}endstream endobj 5000 0 obj<>/XObject<<>>>>/Annots 1789 0 R>>endobj 5001 0 obj<>stream x•WÛnÛF}÷WÌK¹‘h]lÅn‚m' m¤ô²$—â&$—Ù%¥¨Fþ½g–\Š”/p|DrwvæÌÌ9ï'3šâwF‹%ÿEùÉ4˜âÌøãï·'óÙ,˜Ñùü*˜RNó‹E°h¯2úxÒ¿ÆÓ«i0ï?í]ç´˜Oƒ‹ÞÓþ5ž.‡{[õœq™ ]ŸÓlJ«^/¯ð%vÎâK4úmOFÆ2Q…*6tºú|rv0ÜêÑÇOïß®þýóMsÛ‘ª({ %•ÚZf’*M*/3™Ë¢"]¥Òàq*¶J›€®µ!ùMðó1©„öº¦(“'“È2ªö¥ÌEi)Ñfè”&³9¾Ï•1±dùì=ítñ´¢%‰bOuñ¥Ð»‚bQ >‚Ö£]ª¢”rµI+v¿¶2©3>–bÖ› @XŸôkVISˆJme¶;Ýv®s)×±JöΉ!È…±©ÈH‡ŸeTYRnÚÊÀ,_ØJŠ˜tB‘.¶ÒT 9 Êyk©±X´gÌÏ9ì?dõÔòr«b@* #í1`O%¼Ï2½s¶<Ž@!© p7 )K™Ö_x!Ì[Ci9•0ñ·dQçdSà66”8㟜K”3Êi,æó`±ÀU<ú©Mãz¤Šõ©sº¢wÎÑê~n(úîs5Þ½Ó9â+-Û{ïº3”\UÜx¥ŒzŸ¸þkýi=åpþ‰Po½—\ÃìZë̘4« ù DRHü÷¢ÒuhÌcdâ*"9ìÆÆ•õ …¾’ßÊL·‚SD0ß'€K¸+<Ž8Ñ‚“ uï½r½!¨èب΄¡L›Zl$êL´j,@q1©J!³Ä YÛd·‡µ-Ù‚áè+S¡fÏ÷% tjk´¤°Ç„üYlE`w>çP£ññº,dÊ;V’¬¢€ÞéÿŒ]`9Se“ªû•0Yu¡©CÕ5¥*F€vªP¤ÁÁ*8'‘ÑvLV»]ý|l•ܹ›ÇÉH ¾ ð™jè ŶMBFn¥QIk᮫’+òVwi›Ý© MnIªñp\œˆìŠt@ÁTárÇô¢øÚEÖ–WC¬Ü5âÊ_D\ìûV ‡‚³0 Ø£N|­¢ú8î¢3:Üè¥~Dºl*.B“±¾fHˆA¹.9»¾è&I£0¯‘6]¨2Uí¹eËò¹ç–:ÊVçFÛŽÙ ¢Â™¨c®ëÉ<€_”£®mƪ‹úwb Ÿlés“ƒS –ŒsTÃÓÄëgÏÀCÂ"á%†xšV„ÎÚRFJdê?D\ð6â+â ‚gŸÉ|Éì‰ÑlœÓ0š ÈkžY`¼-5öãÐ[¼ë«±ïSS>ØÕmr î¼I€£1°øÒç)⌸êòG5þóŽ–b,œça ® ¦¦Þõ(B÷ÓÏa$®S€a&Y’o<ÆN Rgg>š žy}ntëXÙ{æ´9ÀæV+ŽZßã-nG Êj}ú‚½gáútpˆ3 s×ê0);üÀl+¶tHý‘èëÅãÖ0¡ÈÀt9ËŒZ…6‡Dµï„(mtzï ÅÕ) åë¦ÄyÆäŠwRŒMIìñúÚË­i#£Â¦ïØ ˆswmÉbE_4â΃¶­C+¿ÖÜUþ‹’îCz„}°s.èŒ]›9âw£<¤”{Õw©ÂÙë¤k7~b²à$+„ƒ)›‘ƒƒP¸;U¥CCcÐË‹0ʢ͇sÅQ×£ÁâΗ%מx@:–G $ÈU;Í ‚ðú‘¨²v»ÌÀI†÷ˆ Q|b*(M!xY)ð=õ<2€§<$Ç„…‡0]Ä\….&?pÞbî=e81öÞðº{­9t¤Ä16ŠÅ‘ã­¥T,$ÒG3ñ€¼Æ´A7ŒaÀCg•oª¦{]¹TTOšÛQz˜;À_rX…€Î¬^ñ› þ9¾Ýã ±17åÛyIÞ;zåí„};÷’ ›ËÙzTàVÅdÌyð"‡)¡%Ц%r>åpx°jæÃ„ËVÔçÓóàbqAËËipÉ’åTx þ]GNæœN2” ·fíä9¿ì?J/¦Ë`1‡òòås6ófuò×Éÿò›^.endstream endobj 5002 0 obj<>/XObject<<>>>>>>endobj 5003 0 obj<>stream xÅWMoÛF½ëWÌ¥†ÜH”HÊŠÚ94“š¶(Ö€/+r%mJí:äÒä¿÷Í.I}D’äPK°àõÎpæÍ›7£½Æx…Où®{?%½q0Æa÷«XÒèvL³ ¦dAј¦?„Átúœ’ÌÝS’öÿ~IJ[º¢W´÷³ _mÃ@Ü÷ï¯_\'z£Û …°XО†QÜxê ‘]IZ˜<7¥—$òœÖ¦+wîª3î'”]Ú«CŸ}z…U"§òA¦øTÿ «Œþ±µÞ%1Œ¢ Ž‘RÖÆþ½÷Øf°8ö(˜w±#^~zgàîזּ1ÄOì ÚNØ`²gp÷f3 ¥z”š>T¥eDJIvc(“ Qå8©äZ<”Ú¬d!)!U’Ð"7KS•d ýù×/o“»ßß\ã»ÆÑ}?‚ûëΪ­ê'Â9}f@;<ÎÚ4ˆîÙœÍ0Aí—RËB¥Ç9Q[½¦öm"ǵGÂU)3Ú(»¢µa˜ )+H”­›“$pì=ôøm m£ß§ééuÑQÞï °+áXG]`®a=éº ©¨r ÚÚXR™ÔV¥hÇ…)\?³~Mµ\ ܹHZ‚Á\@Q¢.ƒ&âhÂw 7Úèá±› ¨ÔreInÑúÖñ–YïõÄa»¨ò¼Þ)˜Ò%ãâ(YCxk) \傤¢DDóÊrF-|ó±RVô:„D‘=ÊþÕZå¢@.Žý°G…[Mϲ…UkÇ@‰¿}üA,m"—YÒÞ¢—Ì>-ð„ä•¶¨Ø]ÓáŸèѨŒ¼dÓg§ÚŸvvv^ù˼þ7¼p6Îöýoºš+Èay2EŒZ'ãûŲ©Íë˹ÞHTóDª÷'R—[c±tHÍs Žöfر…O}gWó ¨ã§,vƒ€jžu; h4ú²Ü.úY(ߺùÐKé»ÈÈ…æãF¹ù¼+f&S0‹¹yäþÛ› K¡ôÿ5G:õºò¥øÚ9’š5ÚL•FÓ\ÚÄÔ<¥H+;t µÍ7‹–mq%«B—d¸G \{ŠâÖÓÅ ùaSãŽÕu°Îœˆç2Ÿ»ùÔ±ï5¿è ›Û²ÀŽA¹­Îüòxg6ò7 µ€X±#ß®£!`n0+llRd—=»LtúôôâÀjÄçס¹ ­à¦9$›2µXàH§(6„üx*sÝçÓŠûÉg̤:Ì¿ôûžóó2Çá+ÂSErõ9GŽÑí¬ÙœÃÙ$¸‰oh:Ãä÷_ÞT†q0¦ŸMZ­1²ÝÎÌTÆ&àoŸûÍ7 ƒ8¸¡_y-çÝÏ{ßo,ц^?{ÖÁä6®›ñ4ˆ#|ÉÀÈ §3vû&éýÑûj»©Vendstream endobj 5004 0 obj<>/XObject<<>>>>/Annots 1791 0 R>>endobj 5005 0 obj<>stream x¥WÛnÛF}×W 4‘ ‹)‰¾}H‘8m¬¢ì<¬È•´-ÉeÉ¥Uµè¿÷Ìð"ÉMl uÁâΞ9sfvvøÇÀ§1þù4 ù7JcoŒ'üáóǧwƒ`|éizz!¥L}oÒ|Kèv°ÿ«—3o¶·úã|PP‹ߌé ó%c ¯|/ /h‹Û1Í£¡ÉE6+Ý©|¾<™ÿ6ÓÈÇb¼[|IÍÏù9¥ÊEk]Rf³Q¬—ªJ¹m®S•£ ÄùÍ”cI#8“Æñp¾Ö…&…ÿÖáO*«…K4Åf¹ÄB¸¬¢5©R@á€Ö*‹“­ÎhQ9RŽ­JGÆQ¹¶UÓBS„g¹5VÛñ®ØJE•nÛøޝ4©IxŸÅ.[jZZ0ÊudTbþÒ19æ‰rºãàñþó›+ò°D>GAÈH>R…¤½Ñ‹jµb‡­"¹rNY­êý­8¼êMa'ŒÛXªJ½¬ŠùISh@²åÎ _¤¸/ “Ã}ÇåÕ®P]’‡!’°‘KKH­‰ 7pˆJÝFjlZþCÑC¢hb8Òk ÄCºXpšg_ ‹jòºôh¾Æ®Heœ~lݶšñ¾ ר¤a}˜ñÇé ¼°¨¹•K*beYˆG’nÖÙdTªˆ}ÅL¡c›•²Åj’ì— ÷–,o'ª”*ƒÄÚßQi̺ʜI sâ8àË2¥*Ö½Æé€ïÆ)ÈGIóÑ‘Ôâ†ÓŠÏ¼k‘‡9P¦u\{;`³)TžC¯3U©²K‡ˆuiœaw#:NÎ \>²E’lik+ÚÈDµVò¨æÐÂV+H¸ã\WR'Ǿ#æÎ–¹*œ‰*9 Ì]$c',: úEé@Çd‡Uxñÿ©prõ™ô6s£±)’µäÈÆZRˆ½ò@Ä8lÇèžÃ9Ür*t\IqÔ9ì Û6;„ðMñ$…Vñn¡¹Ž¯Û#µk£ ð&´äxÈaxîšïÏJß·i‘þÛ4‹ôÉn¦wÓ/‡FÖpùØû!/Sa7å?þr"fßlᩉZMvÄV.G£E±¡¿nø|%v#ÅYya²íYx:¼rcV4Êu‘P×Bš‚hÒ㙃p=¯Md}ý´VëëÉ5ÝJió™æúàCbœ´¿W&{Õâµk‘©ÓáÀÑ·äXCVµÚ럟·¼{ΪÍz›Qdþ)÷­9Óìi*ÈL£71|ÖÚ  {²fÓŒ;Ä^l´—åí¯ïßÍ?ÿô¶¦{Ü–~Z|ÅÓiììkø~¶§]&ŸªúôÙ v¦Ç‰Û/¸»Çf¿”8Á×ô·GL÷˜SïO¨£üȾé*ßl„Üä¸#tÃã× ªz²• Í&σ»f±?ܹ²Úøyð/÷²cÒendstream endobj 5006 0 obj<>/XObject<<>>>>/Annots 1793 0 R>>endobj 5007 0 obj<>stream xWmSÛFþίØzœ"[±0o¡“I¦ ¡`¦Ó‰2ž³|²/È:Uw²qÓü÷>{’Œ-MŒ±îeoïÙ}výµP¿õù/šmõüFø#à«·[ÁÁ¡ÿ‚úûG~fïùÕSB×[ëÏ3Ú;|skyvý³ÇÁÊϾ¬çÎÌ'ôülŸ‚ bøuø_ÆÎ|‰¼ÁTRi¬ó™°J§4S“©¥™”––ºÈi,GÅd¢Ò ¥RŽM‡¦z!ç2ïðtµz!RKV“HE²ü[R\äv*sŸÎc·*•w‡Ìõ­¤ë?ÎßÒBÙéÎàóVºÁüñ°œxàùPr®zÝÓr öÝ#9qÐX™,KâmY.³\GÒ9&]ج°x2&#EM W+׉ܪ¨H—™œ‰Œ lq÷ØNŠö°Á¸ÀS½$Ò©•©5Þ†ž¼³,‘d€FJ#™è…;èri§: wNêËû}~7ÝÛóû}<½g•õÐSi‡R=Jttû2w:ƒ?/Oéã' ½¹VcÚù$£—ÔëBK¹4ü€µ_jŸ8¢U3ŒïðW"DöÒæ¡×V©ƒäg¶Ói¥‰r•Y¶#ûÿ!3Â_U ~rÏ͇ßBg‡;|²‹¯:šœãCyI£a,Tznë«|ršçž¸íj)d™NcÚnQ«m–³TÌ$¾n#pù¤˜pj5œ¡Ç~Zm¬O‹Y«E:v1+M2¾­Öv wjºúµ9Ѐ'`Jx®ç1NM0¾–ñ¬s±ëâÙ÷û²f"S™ ‹ŒôITe]¹o•Ô±Ö›–Á¯EÇ2À–†@úh*2[ŸËÜF‰1¡)&°®–TÀZn,sJÀGFUc­°£¹Läœë@ž­Ü}ˆÊ†C¼QŒôüþ^‘`:»ÀÁÑêi&q†_ N¯.èrùaôYF–v‡ éP‡Þý ¯¼¹¸¹>}sùêê}è™ÄáNgmâŽônÐÊ÷ýÚã*×ïIɉӣ¬)IúØäCcˆ/tDY'­}ßeƒÏrQfC1ÜQ:8ø°¥åÁ͘OîÜÿf-¶? -àý!Æ ®rMûô>}Üÿô½ŒE JÎòÞÐÛ w°¹f.|ÝŒHô§©|íšXÄž‰U]W–¤Š{EJ¢js—L¹#:E æa‚ÐE£)“èñ½4Ö°-"[€IKPUëÓ™Îë$s<­ºKǼli«‚âªKUܦMuvïá ‰³7]0 UÄînîªE‚G¨ ‚ï ™™§i×Ä´rØŸžô_œP‰!ƒÀ 2…²\šh[¥Û« †¹.B9펊8–+*ž½Óú¶²ñäº÷ G£l5ý$º1°yBë̽uG:œW‰D¯£â\ªŒÝ«©Gº Ö(“•Ráëßë'àËöÖ%Ž›ìÚ ‘r®î0ž“0\gk±c\6¬r·p…Ç‚ê4ŽÜF¢÷´‘üßÔ¯•–«ÞÅVíI)šš¾T' =HŠÌ­º€Æ2EÄŒ•Ó²D~fHJd€DW@s$F‰¨TºöT ¶g—ý+ÓÜø¾¥œc@$Ð{¼+ÉQ·ÃJO€£\D·Ü0¹]ÁBÙFKÆ­œb𠦢†í9§bU†a%K@ºr’F¥àüVŸ‚Χ×N#"F|«§k5é¸óx úm~߬+êûM¨jqîšgÖ£z³Mf¡&Ô…ÌH¨[‡ÚP3WÕv]ª×£àó *µÌÙ|¥û”£>pÉmHBèT7,¨Ø3Ëa¦2ºmX__²ûcgĹD¡œ4N¸]ÙÿÞK8a€¶X߆Ýr„—°·ß¬!zÑaýg$—˃²s!DU’y,"ˆK•ȧ ô³™ ZÈ !¨V~ûØ|qpni‡s‘•§[W˜w!*Üã‹k™+¹ÿ¬~¬ÌUäZF¬¬¥.†7ïÞ51‡ñZÑæ×çÉó³ãê/8Þ÷útˆÿÕ«G¡ÛÇ{ò¹.ìÞRù>¨¾åêîQù>9½©9±b{&,ÃKGÕ›y÷AïÐïïAEà¨ÇC§ƒ­ß·þüàºZendstream endobj 5008 0 obj<>/XObject<<>>>>>>endobj 5009 0 obj<>stream xµWaoÛ6ýî_q0Z@1,Ù’ÇÉÐíÖ ‚¬C= ´DÙldR#%{F°ÿ¾;R’-Å˶bs‚$¢Èã»w÷î.¿õBãW“}ÇÛÞ‡EoŒq±ù¡×0ºÃ<˜À"…h ³ë0˜Í®`‘Ø]cXÄàg4€ €k­4l˜L2!×vi0ºX|íÁqs‚›ÿh=×OhߎFP OY™+! ~bPHSp–€JÁ¯0-coYžgøüåîÇůŸ>ž!Vxâ ÓرlØZ`R®ñEÉdËÛâó-Ë—^¼áñÓò¢uOÀ»ÊìÃO¿ÜßWéžgz-¤(† Õ*SñÓ»ðŒ±ç–'Hé›/è÷k£Ž¾6];%0¼pøhÛ×å…=<ºNÁGdþdREÐÃ0ºª,ò²@ÖWåú†`´cîGQ0™`$žÙ‹5ø9×Ù%øv¿_l1b ðßÙ6Ïx Zn4«7Qx G(¤˜#ŠÐq¹ô*–š8r\íœøæ{„tWœË•¨šmÇý¿q†r§Ntç½ëäž—)ÛñÈ¥, ê”ýfSÍ9Ææ?§²Ò˜˜œ”p+´Ñåj+»£&»˜Ù©Ê2µ§R¤V†ë+JØ mÀ~à aòŒ0‰c&aÅQ¦>,=Ò†a[>ÁM\w'ÖM«(¯QA:âM‘·¼°zÂòêGSÒ<ã;& ¨¢EÌFíåV‹ÔQ¿‰U~@ôC+SD¡U®+8tPÔzé\hª»Ó¦bwß) CB@|*Ú¡®2ßÁèÛ|ëU¾ý¬ œÕp^W›« g`aÏh_J/OH©=ÞªD¤‚k ’¶‘¨©ákK‚3ÒÐßTÔ¶qj; ¤=ׯ I÷,ZÛ„þ ¬s…"ˆ|ÄÅ?cÖ®-ÇhoÅzS@¦Ôf\šrM‹…jÒ°Š–K¬‡±Jx·Àù÷O >½9F¬ÕغÜ`´1űÀ +ZjR›"^ÿ>3ʲGÑ1°e’ÇQ/&#Ÿ°ã6áß~—*Ü¡I'‡zÐ…E E ÜzâŽÇnæ ¡ÓÙI ¯!œ(>jóàüˈ/ ñ÷÷È3¬¹äÚÖÐeÆíPq¼qGÓ`>wú%±ò˜ê6Lk±Bfì)X0˜"ÞÔŠ°A$uãØÂ5Õg¡Õ¸´×¨HœqlÀëˆe—âpæG³)Êå3–ÞfÍa³î|Ùp ¬¹›$ÍS!ñŠLîdñøÞÜ+¹^zo„Ä顚5(ÆVD¶u9´“DZ6Se­OŽŸ'©¦&-¥#¼4TÊH¾;I!J¸“`9Ø+W§êÓÖþ^d™Ó‘AR[Üþž²ôHÝ‚ï¸^bQÉ ºµU뿊GÍÈC ^¼¦MÝÏ‹]¸k ƒmÞÕê+ΑíñŒµ‡Zéb{=6xÌh?#.ãLѸ‡ÅJ°i¹@ «"’ñ5/Lò„ÇUp,~¹ÒLpøÆÖµBuÙgÇü’Fø:jÇ«ŽÃã’DÖªUþÖ &OƒËÉ%ÌæøO‰•'Mþþ$Ã*.©êZQ“eL@·Ù¿r úºú/dz`¡©N\…dáã¢÷sïO¬fëlendstream endobj 5010 0 obj<>/XObject<<>>>>>>endobj 5011 0 obj<>stream xVÛRG}ç+:”I–]°ÀvüàØàPqǨâUQÃîH;°šÙÌÌ"T)ÿ{NÏ^¤„P‘( Íöôõôéþkg@}¼4ó_¼Øùe²Óú8l>ìœÏúth2£aŸÆ¯Ñx|L“$Hõiwöü*— ‘O;JO÷É¥Æzú{r³Ó§Þ"I‡ˆ2£çäå"‹Õëð€&81VØ݉¬tp¸}QÍhÚ™ÄÙÕ'é?CÉ™5‹‹ë¶æ¥Í»ôBé¼ð]ú‘µÃÞÑäÃç«‹ßðÿ7`ÙJ_XdN¿~½øúvÛâ÷íƒz'BdP¢hÉ„‡gGÄáΨ‡Lõ†£*S‹Ŧ°NvIhÔ*qIG>žV¦ DÆ™°’”v*‘$¨J)ña"·f%Žœ1š¿}*¡ØàNŠCy/ãÂCpÚÁóU¸­¯]r)î”S0NÞ¥\XïÈ̂ʥyŽÃY¡c¯`ÊØJ¬ò¨rz¡æ©§ÂAqb!›°Hã—›îG•Ù᛽ˆcá PdÙªÛö|©²Œ®¡%—±š)¸_8°šÉ%‰ UÖ«;I3c.¢38%ïÅ"Ïä6Ò†ho8ŒF#6ÙF&C»¡–_VçÚ_½wŒ§i§Ðtÿín [Àæë{m@=¥¬Îzh€½6¦65wI›ëÌÄ·ïÀùŸ6žá$•¡ZVVy èX¥³2áì§n!½Š]¯ Û”$`L9øêIê83|£kðŸ\lrIËTjRž ,ÊŽMRåê|:Ãf€t£+2PÖ„¦pð•U±` gÆÜ2¶qÑïÆ3øÐ@†#`o}ªlR#Ù§iƒÚT?A¨$«–7!¸\8Ž ÷L1Oƒìå·óO”[™[Ã3c¦Ï^ÓQÌÀž½á˜6DGÑ>†6f5‹šŠ¬i‹ÿš"øêQZã²ÉE™5cVdÜ 5-ˆGôÁAÄ.ï•Cò– ±ëàsY„ª¥ö ò0{ïinLRwQ+á*ŠW¶8úR 2yYfØY¦*Nq-HI3´Ö¥ˆ\… K/‹<J‚X*@^ôáåË5±dê6T¬ÊËæÙè`n‡™1à^Ÿ¼ySꦰKèÔu:·WèdË=®.\¨ˆ¤RT¥Ì ;—ž2¡ç…˜#`H"f;/H`É7€º:…ãÒi³nËÐ×P¦7­|.½¥&Ú§ ëÅ=Mˆw÷W™e†¾›%»ÿîP1¨¾r¥W±Ð?yº)œ»‡¸­X¯«òÔ„eö,ÇV;Éå³z¤u6òqŽ\H‘”¶ÊÆ2[‰ŽEŠy:†‰ÞVλ@ÙúëJn›0×72Æ$”͉®]N„H> ¦ ÂF;ë:ÀÜàs——š@<™q ¼²ªÆLÐÏö¿ê‘˽Äõ—÷Þ žŽg¬ù™%ܤvðy ·T<¨ªN×åþR§­Zº:[ã€W§kÂ\l¥n-–ˆSaù›_îásœ]Þ}ù³~]hÊÊ øÄfvÊñǾ•þ‡ÛY(wÁ!D³­'hzž†Ò¬xæhØßÖ.4¾°3—èϺ!YQ(÷¿i|zž3O‚ß° ›ëlWÀ%(ÖÀ¿–˜H˜TO-Fg&`¬=qŸ½´0Y_xlÝÄSØC9M?÷z½jø`Qâ­ Û§znà7–<É11Òëm<Ššõ¬>âe¼œè?,”kÝÞKÊú¬5ºñ€?Ŷ{äö÷P’G|=<;©xjpr½½¢ñÉ8:.7=žÔ½QÔ§&¬òÀ1JéÞqéa˜Õºäe…^õÇÑhˆYÎsüxÈG§“?vþïïIendstream endobj 5012 0 obj<>/XObject<<>>>>>>endobj 5013 0 obj<>stream xÅVQoÛ6~÷¯¸Øà‰lK±“¦ØC·.E¡Ãy100es•HM¤ì¸Ãþû¾£D×–½.O¡È;Þ}÷ñ¾ûc0¥ ~¦”Ìù7-?,“h‚û?õŠÆ÷ºZäOhþzÍç7´Èü© -Òá_‹ßãûkšb™ÓŽ]ÅIwlø¸–šv¦!+µ'q©?9t²¬Ž‡ä Úˆ¢‘—¤U²¶Ê:K¹©É­%eM-œ2šLî×ÛZT8Dy£Sÿ]èŒVi!…–5‰Æ™f©(ŠÁX>+ñÕë5Ò~p¤,_—ËÔá¹ä`+©45þ_ \ªñÏ®’¥¨Hé)6J¯¨0pŒ k%ž i±ãC³¢D¼2-DrD÷HB>‹²*ƒ’š¦Èº3²‹gs<â #Kw¹/¥¸Šã(IP˜l¸1*@f9´.»»³®æ¨FÏ—t´ÞõÖŸ—oŽáïÕn±$øe, È ú$SÁ°<<~xO"uGµ–ùZ¢Õ2—ØN±û´#®—Î8B*êUSJíH7åÊh›É¥¡ïiÔbÖ¯„ïJ‡&ÿyñK³ˆ‘ÅwœÅi½þÿ,’—f‘„,N9u’E¿ö_—ƒ>Ú±ÏÁ6=%5+­>Ë^³±´¶R±£R +tÛ7Aã)vË‹ˆÞ:ßÈ©=ÅhìïÝ£Í;nQüÍRµ9´ªÔè ËtÄ6UeêÎÝr¨tÕ`Ñ úf“®IXßµ^)ý*ì ö<¾ŸuJ¸W¡ÆÉ®g=Ýïy%måÄ7ÏàÍKcÙNAVüG{IRàj„ÊÆ:´î„œZ2[ÝìH¡Ú°ÿ@f¾íã<Ñ0<v”QO`PŠÃm¦8ìÆcúøË7ZßdðÉWáðôACMzÑöÍΆ@h˜#`‚©ìòâÈÜ “ šó¿§u6—æú£©ÁUw6†ñýkb SÓ,LMÓit¡ë¡’©:-ØË—QËS#òãË£‚ÜAN!¾~­Zæ¦(Ì– cûÎÐA%Æ‘ ².³ˆ‚ÚC¢µ¡ÃßžVžÆ0&³õ¯Íó\!ôª+iCvþ¡x²‰,S§Ùd%1Ædðdz“°¯Ÿƒ_¤¯Pendstream endobj 5014 0 obj<>/XObject<<>>>>>>endobj 5015 0 obj<>stream xÅYmoÛF þž_AÙ ¤¶bË’lo؇6k¶ë–­ÞŠ¡)‚‹,ÛZõâJr²`ØÉ“,ùF%iÒlnêØä‘|ž;§|ÜÂÿ aäÓOì ìJ¶où’¾Àx@ïþÔöñëò4ü‰kOY4ôj¹?ÁO’¢1ØuÄ:‚ëÕþ8D§+ÏÝÝpÖžåˆh"òÀC7Bk‚«Š‡ i™κ³çOæ!(‰c2BkP‚«Š‡ i™κ³|4µÇâzŠÆ@âÁ˜ŒÐ”àªâ!hZ&†³®ð,wÜj˘ûCP4Æd„Ö WAÓ21œu…gù`j{âzŠÆ@âÁ˜ŒÐ”àªâ!hZ&†³®ð$÷¦®ÌCR4Æd„fP’+ÍCÒ´L g]áYîm—×ÃïÔ]OP4É­A ®*‚¦eb8ë ÏrϱGR^y‚¢1x0&#´%¸ªxš–‰á¬+<ËGcÛyŠÆ@âÁ˜ŒÐ”àªâ!hZ&†³®ð,wœ‚¢1x0&#´%¸ªxš–‰á¬+<Ëc[ÜFÝõEc ñ`LFh JpUñ4-ÃYWx’»Sß’¢1x0ƒ’\i’¦eb8ë Ïò±/÷‰® h “Zƒ\U<MËÄpÖžåþ°ƒ‡ h $ŒÉ­A ®*‚¦eb8ë Ïr×—ûDWP4Æd„Ö WAÓ21œu…gùh(÷‰® h $ŒÉ­A ®*‚¦eb8{9Û;:ñ`8€Ù‚ËÒp„פ‰íúÌæ¸ÉxóšÖo*ÔeÌþØspv3ÖEªæ*£ª”q\ObÛñ/!Îû1ÌU©H Ùâ^sÝ9©w‘‹%,¼gè‡OTºÔ¹Ü¦þš¥sXdyrÏà– 'YáŸ*Yc.h²øè‚·“u±¾8É2-Üî*bßÞskXó°òh]f9ùªð®šÑ5j(Ê|”zN°ê©½m“ÜJàÍÛÓïf¿Ÿ½’ˆ õÙ**Öy”àNÅm±)0û¯WaŠÛ÷š ʪ8ôX ¨¤X×Q¹âm™oÒ~%zB° ƒaç–¦s‰Žh3åç¹uxWrÕÐ^å&80î, a17ÜìIvÎŽîÑ©o=¨Ï·5ž\“é­ÀgÆã7§ÃýòM?5Ÿß’|wb{Šä{$¤§L½GBûoïv°weÝ¥*B©ð½D9 ÔOèlWq\—³T:‡G‹û:J¢õºN±ñÀM°¡s<ÛM¨Ž¿Å:^7XÔõàŽÏй ÏÔA±Œ0"FS;ÓÍÔv€*±uÚ9¥z-à&ÛÀu•H O!='˜àƒld>fs¦S.yxÃêÓŸ¿Í~^À‰A„†Ýëê=Ú.ooèàlï ì |{T=’Ž]½šíý¼÷äŠÁYendstream endobj 5016 0 obj<>/XObject<<>>>>/Annots 1795 0 R>>endobj 5017 0 obj<>stream xµWmoÛ6þž_q²NIÙ²c7m·]×t†¡k C´DÛZ$R#);ưÿ¾çHɶò²lkòÈãÝsÏ=wüõ(¡>þ'4ó_Zõã>~á„?>¼=Œâ>.â1•4Ä—á{AöO%]âÑþÍþ©¤$ÇÉþÕÁ#Þ]$ñÅþÝדƒó½fI½« Jú4YÀÑñs|ɼø’F? “‹y!-Ù:]‘°t2ùå¨wïýŽèøI2sÛJ†Ÿ[C •Ý[zúÈR#©¶2#§ÉŠ…,¶Tê,_lÉ­$±qšoÉÈR¯sµ$mHd«t®œ46¦W…[éz¹"¥{Ò§ód€@"%e˹‚Ië¼±RTöŒM[‰ æÖå®v¹V–±º”./p³NUFWÒÀ­67´ÉÝjgv„£T«µ4ŽÖ¢¨±s.ÝFJÕq¤õÕÖÅÍ‚Á{únSi­0[¸ÇQYï»^¦B‘(¬Æ1¶ÍJ*ÊdZ W@¥Ð)^Çt ä­(«B¾ÙéÓe<ä<€Ï`‡xÊ¢Ïø0 2r5=VŽNi7é"'Ë ¿ÿÖÆÃ ‰ÿø}Iï·ï”›½²ßiµÄ¶\Uµ›ž¼¼·ü8Áâ'¼©ûî÷à]ËsïÝ0ŸñA“•DZrKZIN@FzA©ð)#1×µ»;ÒÐ’yw+ì-…RÒÄ·ºn6H¬ÝàÉ ë¿çÑa -…dVø¼qˆÝ˜¢3ʼWŸó'HTä7Ò»"o+™:Z0«[°•“‚MÎßä*C䋪¤F}<O7F;T ¢> >üý¬Júןýëû©>> íŸdeÆ) ä‚ ãi]kTäÄPgEÁB€e l»ëA3o§Ñéôć°£Ù^Ýî Äà¿¢KQÐk²[åÄ­O@HUªË*/dL;¦µ1R9h‚X9#òåÊ!ybn$K‡ £k$Ò³ú -Y…>þôî-e5¤;Ycˆüv–“¦!+™gþX„1V ™Åô­ÞHèΙ/J[›ã|s:¢cMÍ¡[ªòô±A; ™ ™XqíøñˆÊ¯užÑi€¿­Ó ñnT£uþ¤¥„óˆ$Õ@ ¬öÕàå)ˆé¿¥ÇéÜÛ¥œÕ¿©8nev÷Ó4‚J5„†®ñ6&¿þôË5êö%K[ï”,‚AÒé´×¢ô˜Ý?±WèKÐ1Ò'ÒÕmV9ú©VMW±‡ ÒÆÈ2˜õ}ÃMfsß蹇"õA àÚã=rmRº¢ž‘þp~NÜßhcÜÊFm³H0í`ÞùMÍQÒm#€þ§F7òÑò—7òbô˜GÖûÀ+µßO‹Z¥aRð}…+u%QòZÎÝ ^jnVܱyY—Ð Ûäš§ ?æ°Ösb½Ñ–W¾ËøB·H¯8[t'Ý´ ¿¶×:€Š+ Ì8¥e‰½ò]Ú„ç6ø:"ù-ëÃÎR¢„Ø}«•^iSŠ¢ãiÔQA ÙkVS2#Æ1biš Öø÷Yí§^ãE±†›o/hnhÖ‰¥Ä(3Á¢…. ½ÁŠŽ÷ÂŽù̉µÈ ^Ég ¥jYÃ*˜5æZ¯½+ðÉϳžL‰À$ÌÕÇ™´©É+§Í4⪛žt¡Üm™„ILkzz‹jðõJ¸·Ä­£N] JøÎ¯¶ôº÷úéÓ ˜>¨EæÖpØ®ü¨{Œ5r%Ö˜=}Âjw| ó0ÊwïE7Žˆî–ι÷Î5Ú…¼MeŬÔÞ"ÂР8µ\ ŠF—´j+Œ€gL~ÑŽsµèÙ~#‡‰‘ԟБ²³{z¸gY—½x±FëÑæ `ÿa¸¥Ÿ+Z‘ŸGbRN~~ÿfVÍ`u6 V'3˜ù;Æ~°ˆ˜¡ÞsQໄÝW»— Ü+<‡xºt€­¥%bø¸*pÁQ>/XObject<<>>>>/Annots 1798 0 R>>endobj 5019 0 obj<>stream xÕW]OãF}ϯ¸¢ -qâ$hÕ‡.[¶HUÕv#õ%R5¶'Élí×3&¤Uÿ{ϱ!°ˆ‡>4A!ã™9÷ëÜü9ˆi‚wL³„ÿ²r0‰&xÂ1üúqp9¦”$çÑ„JŠc쵫‚> öר_Eû»{kì^ÄQ²·;›ÆÑ9%sòìü‚‘ýŠ‘÷רMfÑÕþîÞº¤ùdÒÛ}¿Ø³ÃS¯i|sEñ„+œ\áKîíÄ—lÇÑï)»]%KQ-‡¥t“Ÿ?¨„s²ÖËÓÓÅçÁøfþ€3šÎ3\l”¥Rdµ¡ÆJKn#‰8J [(œvÙFé5ÕM!mÿp§ñri³Z¥2')êBÉšœ¡Â˜?šŠ„ÎY&Û¤Ö)×8éÛJfJt'j%ÒB¶Šm•ÛøýÌäÒË£Qê4 '{ƒ; ðvÿ ^ßkÐ$2£!ÈѪѾ-C‰v†¡UmJ¯ñ“îaè:¢”î¶ž·J¾Z9ÆGnÖOÓô8¦oéçÝ­v¿gD9E-SºjÜòô›^оž¡9y8¢K¡±‰;¡  ¿¬uß•Eþ?ÂÐW?c„¡)rÎü;Q4hWM­ó&†…žÒÇvWò<÷ˆ6¢Ÿx :uŽ·s_*t[‹ ý¼Ò'åqÄ_U›ö„”G‰‡Þ Šæ<—¡×R™ UÐ'3¡YçŽ Š;3O¯”5Ö™Ò;ЃëZ×/Ûav:™Gç3üvÁo–Äçȧßn?Žføó¡íÒ~nd x8<º…ú-¿5Î'I4›‚ùÌú‹„ñ¾_ ~ü ׿ôendstream endobj 5020 0 obj<>/XObject<<>>>>/Annots 1803 0 R>>endobj 5021 0 obj<>stream x¥WmoÛ6þž_q²ÁmcEò[œÁ°eIg¬íºÆE1 @AK´ÍV"U‰Jæûï{Ž”dÙM‹fs×É{}î¹ÓǃˆBü‹h8á¿8;ƒOø+â¯×Ï¢á4Ðx< BÊhFÁ¸^¥t}Ð]cw4FÝè,Âz8 ƒ ß² ¿rw;k쎡¶»ÛYg4 CX±½;šNƒ)E¶-£ñ ‚¿bÉ,)OÜ^4 Îêou–M†|Íä½Î2£é)+h÷:ËŒ¢ÁdWhgÝá¼Þ^í®±ÛÑÂJžw‚î"_¬èä Bš/‘É~$.)ø÷fšD’(«Œ>&»–t¨ô!ÙM.3‘“HSsWºçºÊ² ³¤Øè[YX™(VU&µÅ C Ie.cµT2 hQæïN®<§» Jç•-ýóƦ k µ¨¬,i)b•*+ð›O…Ô°·gת èÊ$ÿYžÊ§ði0dÏ8:Ã!VIïä„f+mŠŽA#ýï}W{xÓSð»µì<¼yDJ[zl*K¼iÉÊ,ÇÓ¿wî>GÓ÷¼ýÃÎÞ?Þ´Æ¿¾3 ؘœ²æŸ ÎU™<&£Ó }’…!¸f´ì„4Žií€Þ®¥þæ BE)¡ËPèÛ$‹°#—K[u+¡]ù@5.¸p P,´6Ö¥µÊóY¥ea2 až ½ªÄJútw”V¥)òc¥8 wly&>(½r÷/N.ž<œaUŒ;±0·rLj„åºÁà­H+IU ‰pBéÒJ‘YX¡tcž Ô°à %2Nk¿…‹±Äs¬}~Z\rwSÖ èMY9!{g[¤ì]`{-~Úb¶­†cö¿Un´s5‘KQ¥v±;¸q†„ÅO—ªÂ=ÈÃŘsðP~¬m16A/}Œ]lš4íX³—2KÚf"pqqœá¾eƒ=z/`«ê7ŠnðõÙ|Ã5=Ê s«$”J•)d€!ËÜú(|Ñ~vQ&;67ŽÐ=Æ7†kW$k ‘€*ÊØ\0xí½ˆÁNµ¥c‚“«qˉýÁˆ+óÂd¹°jÁ´ál6$ÓTr®Ám8-ˆZ`œ‡~g{ æH—"ƒMþ·I­+¼–lk³Ð^P‚LÕýÁ„ÍŠÐ#Ñ{¹ⵌ?´7vñ…Z®Ì¡îžó 5ä¾DM›ÂŠ®HH8x•']ºšÌ¤]›¤;³”½((§w[–b•Rrfá"¬ØÉó‡Âuaq›;=€Ï·tÝFá8/d, h_¿={7ÿóÕåů—¿½›½œ_>»|]SùgÄíxûÕf¦í» ŽçMïÈõ%œÿÓËS ÂçÜ“Z£ O¶ÐѲ¢.Ò;±qPܼ¸ÅÈâUW}ÃÔwÄ•K¸r×Ð2$’œµÛ¨ýVÉM£@tp˜iŸùlISAÅ”IZÞí4üº5cŒñ-›‘°‹²_/¸ÈW…ÈNeC5jŽw ‹´4BÓÀÁgLf”î ‡ !~/ÐÅqŸ"€ îË®.!ÇÜ!’.$îrKF-uÍk1Ñ ÔØÝã[î*½e_-Å!ˆo,ÂîÉnùÕ]½­¹8tL[ÚwLCÜo/-ž¬÷hð?,úba²ä¾tN¾:® þ¹Ñ+Htóè!EÁäÄ(vP¤mE È©¸EJ¹-×ÑéÞQî¨6Š'.ÿéÓko§Y¼gû˜À8J`ùî`Ò€Ê }Gå&ÓÌÂí§O/y 6ä×$b!Ùò»¢mJÛ!zo sd»“çš[á¦&“3¥ÂùvÈ¥e*VÍ(rÈû™Hy„Qà{XlÐ@Ý–*Ñ’07ð˜„M_ðõë¸ÿÝKm¼w3“¹’Z^¢›É|ìØÕÅÆ£îÿ”ƈ¥Õ·–Çþén‰¸é8bqÊ¡‡§%¤J´Éj9°ß_HÄ  ÒhSîý¤ä¨­ÑoMW`C÷Nâ#¼?¨áE)@ƒÓè(e)ŠÍ1áu„2µZ»,·¬RŽùp°F´ú„L!©Š]LøŠr ¤6S ƒ÷å›çÏ1ÍÜçˆs¢åù½W˜:ŠuY?N„Ÿ¿®¸®Çî­c¼œ:Ʀ£`<^Vð¿{—âæÚçwí_LìÞöœ« ‚?Ý?åÛõ¨ít>7'Áp€ÆÆGNOùÑåüàƒeÚÐendstream endobj 5022 0 obj<>/XObject<<>>>>/Annots 1805 0 R>>endobj 5023 0 obj<>stream xWÛnÛF}÷W Ô´¥‰ºY²Ó6©m)‚ÕöE@°¢–Ò&$—åŶPôß{f–¤HÉ ÒÚ‚å¥vgfgΜ3úólL#üŽi:çWŸüžðŸ1ÿyÿ†ŸÐl<÷çÓ|†7·ˆèŒiüqÙ2&³- /i<¡e¯ó«+ZnÄÙˆ–7û3F½U=*ö©ŽUz¾üx6\\À;7˜\ø8é-wút7™œÊ\o¨°T”YB ¯l[Æ:)È$xª¨òÐ<÷ia3Ò*N#ýó7¢+Ê'#L&þtŠÕÆûº jåUFVçl•ÂHmsú‹Ïb?‡ºñˆèÙ˜^ÑÍíâõoï–ï^¿¹û¾³åïÎÊ÷ýÎZ [»òøŸÇ¾8Ú»7ñ·:k‡ä $Ø©?Ÿ_Ö J3«lÏ9!R±C~ª;pªmŠÎ(Ø©d«±AÓC¦ÒÔ$[>pœ«œª<Õ ÷O¤1âiS¥Úêú6¨øÆ{€±s™N¾-(/ÓÔfеò"óIÓõêܧ%Ê¥‹ÆbÜ©‚6–Û!›Æ&*jj˜÷a.Ø‘Êé'u¯Pö ]Õ'†:(̽ŽöhÌ6±.ºWQ©«;³ÞwÓ“*jy¢¸Ì ZkÚÂlR—l"˜ü% t+-u¦w°±Ö¹IÓˆ}0Àì9‡6Šìƒs¶S÷º)…Ä›ût§%r­nÛ¢Ó…’ö×NÃÓŒuÖ-êQÎ ³ …¨tXf‚“`+yŽŽQÑ@F²ÑîòÁdÎÅ—æžS/ØéàÓ¶vwo»±8Ѿ*œlc´vƒ$•ÿß´|`“{å¸l×ö«Zp†‹yÅ/©°Ð™{X“V’KÒêÜJY¤®Î  ü¿¸D®P1IjsÃx=%¢OÀ(?¼¢6Ÿ ø†îþxûæƒ~ ´ôÇÊ“õï ðÛ,³Y¿wûˆÞå–küœü^E&mö겓¬¥u\Ap\#¾¤eË/%ï£ÍígZØÛaÂÌÆ‡p%Q?¼b‹N lÛx¨yÿ!3EÅb(½àøzxýâE§va™Ì+~I´ëÊÊo 2P‡14cçørŠ$=¨}Ρ¬MK UîðžI´$=7k„ZØN0-62IZÎíÀÒð9è övjÀ2Ó¤–D¤¯Ð1(—á^eF­qÃçÃ:Q­ƒÂ™¤OI‹½üCŽÍ÷ec6šûÓ &(ž[.¯øüíòì׳ûû“endstream endobj 5024 0 obj<>/XObject<<>>>>/Annots 1807 0 R>>endobj 5025 0 obj<>stream xV]OëF}ϯ!®d¸ÄÄIЊ>”t¥Jý Ršêjco’¥¶×Ý]“¦Uÿ{ÏìÆN )Ð ”x½³³3gΜÉdøKh4áÿ´è âÞðGÂ?Ý÷’I|M£Ñ žPAã¾Â"§‡ÞÞ² «ËøjoooYP2Ç—{›ûkì^L:n¿žîÅáƒ1K:¿à Mxr‡Ìlj‡4r+IGª<"·©d!ª˜î´!ù‡(ª\~q2}ìß è*ññá€úÃa<a•Eççt/ Ê•u¤¤J'—ÒX>K¾2‹>lÏ"UÎN؆N•“…¥¿:vD~¯ {7ô,—n5‹ŽUYÕnvò% èù‰ã„nˆ=Ã)œ"Ïu:‹¬úSê…?;9 .á¡súïÎ ¹Ü)‰áðétvw9,`$ÌòDØ ‘'ïÜU£ïñ/&—ŒÔ”K±½ ­@±Ò8™‘p>:YfŒ5º6¢ª¤¡E]¦NéòŒkTb.ÚHJuéŒÎIY2ÒÕ¦„¹H#§ýi‡.r«©ÊE €Z£ä¶’©9= £Ä<—¾2Ì”À³è8Í¥(ëŠaÜ%áb¤Qˆ ‚¤Úz¤‘‹iøgi½’¥|Âñ"A*¥Ì,hªãÃsmUôEš2ßÄáÖkJ°Ï¤ï'œO’ÄèÈ£R®æãnl>ŽÇmEž[3"MèÀøq >­•[y`ƒ»Šp ç2uÝ{"Ê”Á[õ$I ¨[à›IOdá$²Ðf.œoØ?{áîò¹‡Ê¢À¶Î}Š– ÿ¡“wüÞ& ~[gT¹¤Ó—mšÉ\"²ã䵆ڹÔܽ¯¸;ÞC?lü¥ŸïŒ.Â#wQÿ«ô3¢™E³“ƒ ÕJMûÊsƒô´ÈÓBën´;Û SMº0䋼ñޏÏ:õJáËЕ|Hmô½¯4éu !\©Ê—¶KÝ h:B|ÜÆÆwB&P¹}•ÅúÔ˜Ké<~a¾Ï¸TWÊ„}€} ê¤ifä 0RdVô&ë‘×e@^{JîÀŠZ‘p¦N¹%™Å5¦OŽ/ÅDP)hÝá3È¿B3@P„1‰pĪçÑi”'VÚÿÅñˆ­ˆÿ2þõ%ÇaSè'/âgFÐO;ƒå w0<ãLHÝ(èX*­hl$¼6˜yÊiûýþÃÏŸî[ì+£ŸT&b!¸ãéB–Nðð4òÀÙ³mÇáØu08Izƒe ±Â¿—b]Û.¿ ”šªÚTEæq'¬UË’ &‚nÏo?~¤e®ç"ïäÖÌ£0Í8‚gyú,Túzw }ÞP®wö®Ý7>”yt@À§Qnáø74xBÚEÆy7çCÒíàm/Œáo'}µmì!~Z^Œ.hâŒb@2Ûú£x@ßè´nYŃÌÁ¶ôÒÏÒ«—¿WØøb0‰GCÌ]ž¹—×üêÛiïÇÞ?øiQëendstream endobj 5026 0 obj<>/XObject<<>>>>/Annots 1809 0 R>>endobj 5027 0 obj<>stream x¥WkSÛFýî_qÄ@ñ Çiš) 3™4ÝöCñ¬¥•½AÒ*»+ƒ›Éï¹+ÉX†¤/0y_çž{ï9ËçNºøîÑ`į(ëtÃ.>á·¿}xÓéw{ásŒŽÃeÔöóú)¥Ig÷£c,ÝÝyÎhÐí†ýÑÝgŒžµ×þ4Ýã™%=½|N½>M Ç4=Ø.M£ × ÏÂÞ€ÜÊè{@nSÈLGÓO§—Cêa¯;íÃ!VÓ•¼7™”%§*­Œéf%sšü~õ† a¬´$èüø˜2éV£Ê­Hä$o#Y8¥s²…ŒT¢"៴¡•°äpL…¤z Á!fD+iïAãØâ ‘•F’pN`ZLNû]ªsCºrT½V±GËD”©ªh%re3JüÉyœª|¹˜¡LkI±ŒRaxk ÛàÁnhª°Ü¨4Å$0V”¦ÐV’Nð)ȪIfÞ€2ÒùZWó´Ý—TŽA¦Ê`ÃkwÈcpÂ,¥£TäËR,¥Ry‚¶Plª–+‡ÜÄ*I¤‘¹kˆÑˆÂ4P%KÊ1¢…à, £Ë|/R?™Œ¨‚· *†#œoº±+À®…Qb‘Ô¥6-vä­ÈŠTþÐäw¸Èú\eýp0ÀSÖÍ‚ª2gGÌ“u„|zB‡_š=Qq@ô~saÌ|"ÝĤpàƒÛhþ¡ÌÊ$Æ´9¡Ç½ÙÑ‹½…\ªóD¨´=pøµ5o­U jÌ,‰fÁ.¢z㻦9õ ÂÑè#|e)c IV¢A£3OßR攂òHÇ㩾9©ú§BrvÄÇ)Hö­Ä¥èƒ©Ž®±IVe¹ˆ1Ô„à;d¿Ç™P‡‚yÖÓË.=˜ˆ0ôã\Pžig6´Ï=5Ì´)l3èQ‚3Î_EÜ“¹™÷7ûG©äµíã_÷’‰$€ü6’:¤o¦êvì¡íUB]šZ¼,Åšr]«A+'mÛ )Á>šŽ52p׺¶Î-jwºÎ1¸ÂZ=–"m%¬Ipæ{ –CãèFlxvU|Œ•'\Sü§×L¯ûþÍÛ @'Ôjë—quøÍ·’âÞúXc6ŽX—ë‘x¨,a\YP¨,§f;JÕ5ׂ²ßX/hVºùÖÐ5ØOà %©F­EZÊ?†ÿNØ®| ,!&ÞuëÊlT¥¶ïö¦Õ`s¿<9@}‡“ø©h.cû¢£Ð’b[`Ve V\YÙѰ•CoÚ@ âÕNf…öž 11j_j  ³àÑûÍD~.eÉùùJF׳à±Ê‹ÒÍŽþ°ýÆLWupq‹ë)ÐÕÖ ‘¨”œÞýúöí>´¶Ø‹»áé[™/Ýê*=zIÃÿŠw¢þ”H’ÍørÒþd*¹Gíÿ…Ï=…ꤗÔ}AŠ~¤!~ðÏ‹OàžhÌ߉ùtWÈpô‰zˆÓš¨w%w_“Pý\ùŠQqP]C€ô~sÉÍ3e_ë·ŸY€õû "ú vн_ª6×WÜÞxž ÎpI…C\Ê!Yìg§üðzWòx®ÕìÓg•1ï*Ö…ƒ>îñ¬‚ã.¯¿˜v~éüƫڔendstream endobj 5028 0 obj<>/XObject<<>>>>>>endobj 5029 0 obj<>stream xíWoÛ6ýߟâZd€œÚŠd'®·¬º6.dY{+†(0™²ÙH¤JRq´¡ß}w”äØÎÝ0lÀ#ˆ(òx÷îî½óÇVþ†ÐÐ'ÎZ?LZàâêžÃÞ(€¡ß‡I½߆þ`ð&3·+€Iìû9/µžŽ¹[-ä<òpá6žþÊÒ‚ã¥;ÏÇücÁȩ<ãÒÈ cኃ,²+®Íó¨}XYkO>´è†xÁ¬¾@s[h g¿œžÞ{ýikeûy'„W`y–ouÛöFû@%ÐÅ»½~¡w"Á.„~˲<å|âpô`W)º‘À©Žzd¼Zj¬yÀÒTÅÌr L†OÀ´f%(2Ìá Ëâk&ø`Ëœg,§r•©;è¨N19ƒœƒæ„«š{„Ù+äŒë´DôÑtRÈØ %ýz[oŸ¶½'ë…á3H´Ê༴ %«ÀÈé¥q&Šþ'{ôT²² 1nû®à®>º½žßïcµÌ¼££#0ÜNoxl•Ž<2Ñ ;Ðó:€„û2jo¢¶ƒJUÀ’I‹N[s.¹f©ø![‡MËó´¤-.Cîä3µf ã,eb¾°°ÔÂ’ažâ›•È2jC’*f±°¦/^Ÿýv ‘W-Qö/vÂ)^`HðG“œº€…´ 6k@$xþÙyÙôÅôÍ‚Çב·#d^بý€À”}¶ÏŽosÄ᪫[Ž:kË%€':j»œ«kžžr9·‹;WáÙ+¨ÃÿZ¯Ç”ÒL`ŸØxáÃ*ˆÚìŠ4þj(‰Ò»@>AÀ÷ßøðâÅ#Îÿtõ…]…§ÖPxÇí f¾¡#B¹†îÌQ\“bõHvÁ‘Ô…¸Ä‹êÚB—ÎËÞôµy« äžÈÃó÷óù 12ü^í£~AÕ4U¸ú¿ÈÎ+_°ôQ–®‹i“r>/XObject<<>>>>>>endobj 5031 0 obj<>stream xµWkoÛ6ýž_qad˜ƒÚŠd'®—nº¶) Ý#î‚"Z¢l¶©R”cèß¹”äÌJRt–8AD‘÷yî9Ì—ƒˆB|G4žð'Î~„AˆÅÝ/»¤ãó¦Á˜f)Bšü“ÉSš%~WH³¸Oþë÷íkko.¤»pVéå¼…Ûøæ/‘UoŒô.ä—JêX’Ìd.µ+)¯JG IºÊÒ–½ùѳÚÚÑìÓAHÃ’ÆAj¥œ÷#ìyà­•®²šÞx÷îþë¯ûÏûO?¸m!sQÌûìPØåüˆÒÌGkNåêÅû×ôwÇ ©”êØè±0½—ãóâœR¢˜ÃѸ)fÿ­&·R%Å¢”š„µbKXYfbádBU‰º{æžÔfú¹_/¶¶ûÍV²»³I§³•štÙ•[I /på Y4 Áð"‚YVÜ0©“Ö/¥•Ž2º-Ĉµ%º #1¢’IмðËÚÀ–¥Øä¹ñ~ȤMžM¥ÂPaÍZ%’ʪ(Œu”Ûl,­btZR.=dzU!Hƒ½ —IJTšJË(ãPÜÑì…X¥‘ꪓÚ&œjz9 ­©·þÑÑ'FeO”¥ZêÛxè­.I}z%Ö>y[d*V.Û"Ùb{w¸6\½½ˆ|§:GŽòVäEøÄQ|Ži%(Ý%ž©ÏÜUž±™ýñŽFÁxŒaMúõº0¹ümñIÆî>hý¨ÕØnÀ}r}xxW´½¬'ò«ßö(š/H—oß­t9 åhc¸²hlR„æÒ ÃÜ8é<¢Úl`¯e\¯ìPÝ´< ¨JŽék¸Y⸠°š§#—e)–’¾³H‡TnÔ’†ÅÖ­€É¶j;äù§iK Î¢ðŒ.W'“Ñ}ÐbÔ5i¬…UþÀfH7ÄquríË÷h½f+‰fwr`\&ŠGåýøz&¸Æ Ñgm6´ÂCd#0›ÿ©”©’Yg>g†Ru둵DÀø+d¬DF½zîFM”ß[ë;bmMì˜õaRÅ´êâ‘©`ÞWô …ÏHÑÏtÝ$*ç‡'O`ð3½‡Ñ•ºÆ‰C¥‹Êáï®Ñ}ø6S£W Am @ž-o2œÿ=®u²“S"œ¨›ÉL)2 êØ6ŒiôZZ¦y¿$A´ c™ÐËŠ1¿Ü¡çÛ}Õè Pmw†jš'Ö” Cßà©lV*^a(Û0|­êˆq¦tƂС+l i<‚Õ›B“^½|~’ÜŽ¾ÚjMðDAX(Ì7Ê­`÷a3ÅBS;*ïdÂê#‚ˆE„—z I&õʹñúKü7¨¢p_ÈŠIãÛ|úüùs*¢;B÷çG­Ï~Kp‹MWÑ€FÁé€ð‰Âëý&t¤ÿO™yyçùí¨€õüÉ|‡‹R"Ke[Êiî<ÝS@>¤å†>ƒB¸@Æ+@Gd¿hg›‚/ÄN<­¨,óü dnÉ$ ó÷ÒŠ‘@ëFqEg~‚Vwc‡–rÄ<ZÅ2ÛhQ9Ü+DÂLÍgšÙ(To»G§ÑöÿÛœÝU“[Xàþê¨ nÛˆ|so¢0œ¦RLoН™{où/mnŠÑô$8ŸÒdº»"°¢ ÇAH¯Lìïw~ 8 @´Þ=|Z ~„kÑìþ@òöÓpŒGøg÷Žh:â¥×³ƒ?þ;öº endstream endobj 5032 0 obj<>/XObject<<>>>>>>endobj 5033 0 obj<>stream x•VoÓHý¿Ÿb@JiâÆIÂq ÐÜUªJЉ jc¯“Ûkv×I£Ó}÷{³¶N iÕ&ÎììüxóÞ|=i€ŸFcþ²ƒ—³ƒA0ÀÃݳ¤ãé€&Áˆf 4~ãñšÅÞj@³¨K¤rGêÙáìóÁ€ú!ÆxøÐH[¦ŽžÓÕöBYws)7óîÃð&VÙ`~¸ožhCó®‚ùà)újK|8:šÒ¿{î nß,>ËÈÑcí/™¦Z¸›©ÑÙk].R9ïλqõîÞ>ªOwoe/>¸kéÎÌ`vOõô]óÿZAøOÇÓâ”ê£>ýᨮO÷Roz´Õ%mTšR¢ò˜ÜJ8Êd¶†DIkIYúZ*')W‘üÝ· ÞƒÑå»/^¼ ‹L¯u&«Ì‘áa+"oÜÂècØ£apÚ#ü†ƒOw¬ ÃM³Ámë›t÷Øñôôþ_é¬N-TªÜ–.µkâo Ò¥ëç†AH¥•È^SaôZÅ’ÙBFJ¤Ô©Ê¡K×!·-d&Š€þÒ¹–¦GÊÑFXÊ´ué–½¤\3R®ðت<’MüC.ÑBÊœdª2• 'ã€fšŒt¥ÉÉ:SFx'ëØÎgEå‘ÔiÁ~§O)„ãsÒŽù†ø†tŽ“2“¹Sù’"û@A-šíVM"¶òÑ”ƒ}œ'ìåM.©Æ©¨L…A 8+<ïNEª"TV礓3† ‡ÉAû«wÂ,KŽåû@ú "‘ÓBR¬qaÚª]±N´’Ñ—ïjÿa…r¿z¸ Dšêõ@þ®‘Fydýq.‡¶i)-”yähb³Ma.o‡ÿs ?Êt\¦h”p«º½-”íQy×_ V¨æ› mëwwi‚ðR ¸åaVóÜC%lÓ¼"£Å—y·sv ˆV aÿÊ©5¦´äáíÜe†êô=üÀ]÷ÁAÐ`Õ®¶_kxê[õ{ä2Ú‘‹on=MèY‘óú²ð w m  ªišÐyÛ\.]2Œ«BØzB}Ï›=X_I“¢m‘,|?=™-Úôù4¥¿q-È®±Â°( 2L±XʦC?>¥/L“ÀÏV5€[Ãt&eJFêFœYVÚÏÑ/aí¤Þ£ëˆññ=0i`ô"õC]mÏŒ¹ž\;pìrÞŃÛèfrÃÚô:—ï..誊•ríª“ñaUSŸÛ—Mºr?Do^aÀ­ ‘owÈÿ¬uºæB ªX ›WµnS6™u)Ðz0ü9ŸVÝ‚€þ`XÖZêuÀs‘Nš¶ ¡OÞ„ Q°rÉ|V\"°E€T ipŒ!Sæ}§2¨ÑPùÌÒbK A ¶ÃªàT$˜Y ZF:ÖT…QM+Œ2ù-½:~utÄ÷0œ=Z½"x¯4aRñ9T;Q%_Öób† ˜ŽP:JE¾,ù{5a2av›A=¯2Q«¼Eü¥-AÄÛŠe!hîz´jÔ2ã–îßG¶, mœ'h+P·ñ˜’sŒA¶`ŒV b¬kÈ¿Tö›–¡ÕFC|c•$*h—+·C¢R¼Ô Uv¥Ë4féa)iqeÝQùNt|Á<Ï€BZ¼-ÑÛ¨qµ1Ê1|„ý¹~<ÀœÆ—Œç]^A®ÎÞ^ìmJDßÄDåf^‡:ˆç^)nR®_¯ÏßC:T^”¤ÜiÂóþ«ÆÞUoß½ü§ºêx:©G(œœ§£Sãÿ ô»GÕz­#¯ÝëìjQY÷ŸT›ô/o§ƒq0beáue2b§g³ƒ¿þ‰§endstream endobj 5034 0 obj<>/XObject<<>>>>/Annots 1811 0 R>>endobj 5035 0 obj<>stream x­W]SÛF}çWÜ1$PüÆ$¡”†”‡&mâ6tÆ3µ´¶7HZU»Âq3éoï¹»+™úЄ1xµ{?Î={îÕ_;=êâCþIònÜÅ ôøãí«~ÿ4îÑppw)§þÉ0> ß2z·sû{Nƒþ(>½õô‡ñ-ƒÎj5§']ÅϨߥái/Ohœ:·]'Ñ#»*e.ÊI¤ŠÉ>©ÂRg¯Ggôú·Ÿû—¯Ç“hOem'ûÏ:ûã;]:ìáhíÊÌÈÖ ÑîRT…*æThꨢCÁ8¥r¦ ™¶¶ïÊ"U3^zrqDltF‡ˆó°?qFã…¤Yed¤%=£LóZÌ%™R&j¦ÊERiCÊ4.Ys®Ú‘è\éUºë¼T™àoíÝ ~ü&ü8&ŽD~y™IS}ƒÏÌh2 ½4$š¼ú L¢ó\$ʲÒ"YpÜʘšaÔ4Ó l2´Bjuaê²Ô••é:ÇØ#sa\ŽØ«©öðäb¸[¡9]r¹ú{}á6˜F.ò¦ˆ}&Œ…CùQ&53ÔÓ%B.²\P¾æœÖOäv õôˆg¨)¥`!L+:£ÁòLåʺР| /ÈÌßOù±ÌPMw39&¨A8íïã{&€LN*Bú¾šÎûÚù»•kÄù‚v!,DËXQX%,bA0EYGއװ%¹æ¿X7Œšnk+´'"FÚ|pÓˆ«¦lL/à¾\1,³Ñ#ÅBêä¡¿ )ÊÀ<ÆÏÒ…l‚V¢Æjwµâ=RšU:wqXQÍ¡v¼„{°T b”dRT8Ñ…Q©¬¸ì¸A,bȵ_§ª.\“q©é,Óˆ!ðRéz¾p@Y¼Ýûýx0@CL£Fª&î/ æø_^Ò£OM®ÍíUÒp)ΨKÚëý™ñÍD(=ʶ^¡Ç“ý½údëü£Ïá+:»UE2m{ÙUE’Õ€ü¹ÒÆ‚Þùw-+µáYŽM)@scÓÆ·‹CubéꊶÿºB¨ûô ¸BŸ?§Ž_éðßhÁÙ3jBô`…§°òî9wJ93“ýLxxÒcRUwm6<`‹C>/XObject<<>>>>/Annots 1813 0 R>>endobj 5037 0 obj<>stream xÅW]oÛ6}÷¯¸(ÚÂÕŸ‰çµ[Ût:dKŒÅ Z¢m¦’¨RT\£è~ûÎ%%9RÃ0 œ˜"y¿Î9÷ês§O=üôixÊ¿aÒé=¬ðGŸ?.ßuF½a0¦á`ô(¡Ñ¸LÊo1]u~™Ý;âΙ½8ïÑ$ÒlIƒþØNOÏh¹‹{4 »Ï¾Ín;/ÎGÔÇ÷%`ßÉ`XîëÚµLiÃøBIR9™"%±*=v˺°YaùA®’,ÞNý•÷MŸ ÁpG¢î|~ÓíÝñ˜b«Q÷/^ôkºò«Þ8kOtfU"â'$¬5jQXIm>åìÀBæ–ä—,†s2¢"WéÊZÉTa±ÆAt­ì~S}›¥¹ 7>ËÕõûwoç¿_\ÎèN«ˆ~ ^¹š½yýó‡ôúj-Löq>ÿ Û"}mNÕ¹[#ó"¶ôSëñ|NþIûA¹ÿÍçÓéîþö¶êÞW”Ê ö‡n¨Sd 7?¿9ò×ܵÏi “Ry¼ùtd†5d8³Ê'¹„ÑÿÚC©i&öß§hǪ¸”ˆ[m(RË¥42 ¯˜cw<»¾>~±âh—¬L2m„ÙÒ0J,bIkGØïD\Hà†KÄ/NÚ÷6ƒkß&¥šb®¤¡š4LY‘F¤€#)"WíPg[p +¦-B E3%ш”‘¡·Þ޳åãbû<ô¦\JCd*–&oxÈZ$™ZNËåŸøà§‹Ï’m/·éT#ZbÉ…£·pØm”wH‚gXDÚ+anEø‰øÌA¤zBÜV“q C|qÃW/œµ•:]¥¹µY@ï½í¥2 /ç^7>ª–OûmÓy&C%â^à;—Án3™ˆŒ…l¢¨À‹J­n¶‡•KÍP$Pà±áý;èÛ!Û’ cv;øš<çz»šnÖH7‡XKü½†½VÆ1#ƒ›p¤ƒ2ŽÁˆ>{à¨k?*V¡8¸'Õ0㉆à8’KÁR.à’¥5þJ‹dé%«9ºVȧó€Î¹–ñö˜r”ý5)_¹¬rNešWÕ¾Õâ³l ºe"wÍÎÃn2 ‹”W“nê0,L­;®Á;sÍ¡D÷™üJt\67T#F—sPÀ±€^#$B6Q-KKÇzÃ9ç<›”¬iÚØM:íJ(¿&óãcwK«'Ò³¯•KnÚ°ÐÍæ ÑS¿Š±šJ¾!»6\W 3·ÑtZgƒžË=Ý<ä™âåK’ÃÏ5|þ–FñžZ?†0‡PÀȲ,Jõ<¶Ù5|\Qˆez£X‰W©6è2À¥c§çL(rLOîyž£g0pveÚ“¢\§½¬M ¦ƒÉ”®ý¦ô›Äµ«Qäb%™ l¬æîSÓ95*¶³Ñǵ ¥ŽqÞ+-ãšq´rPU=­a¥ò…ç“©Ãh]¡}ñ’HO`ÿ5†vdiMîï-å˜pãJBa,…ARJE }ÇR€ÆÜJM™:aVwΊm-q²ÃªüØ §¼Åë=m¨XäVÙ‚¹Ö”Û+×6X •GFYM'.ùá›F7‚¶U]1¥:¬ Î_ Â«Éƈ,㹨Hé=&U “‹;¥‹cAK|7û` ØVÈu=Ð Ž¦x'Álf­’®®9íxèx&¨ä–~ì€(ÆêÓ…ÛÑ`пOƒ1¨ö]¤Í®I‰Z­¹«ÔÐ(bÂë*2'; g-9v/]žÇßóÏÕõÅù¤T÷þdŒ‡c:œV¯€œ©“!^cßèÐáÌ5Sv ö»OÎü›a¿·Ü ÿÆç[RòBèÇ\N z¯›*ù¢qÖx¥F'ïOƼôvÖù£ó7Ë®>/XObject<<>>>>>>endobj 5039 0 obj<>stream x­WkoÛ6ýž_qd˜“ØŠe§®»nº®í t[‡¤ë‡ºh‰²ØJ¤&Rq¼bÿ}çR’)nÃ’ –%òòÜs_Gì…4ÆoHÓÿEùÞç{ã`Œ›ÛåŠN^œR8¦ókgpû縈?™µ¼”唣ØH«¿q$²µØXZIÇwKµJÝS’¼y‘IZ§RÓáùǽ“8Ý[„õö¨)KkåR¥Éš\Rdò\j'c2•÷XõŽGž§5¼ÑdΗñ ƒGôs•95åªâä6…ÌEa»i49 æsÞuf(pÆ¥r»šŠRÚúàT\J8U–Qh¿¬(Í2“9™„b)2¥W5Y\ÁÕK‘UÒôbçþà58s¼V´ •.*ÇÈ€'œ0³ü(# 6»E[W@Š ¤Ò‘SÀ‰, hжVÔÇX^Ñ ´$JI±J¶ '–ƒjK¹ÐZ–=ÅRÝÓÏ£·*–¥w¿ ©€1·6´”+¥5{R¼Õ(…“å·5ócšSŽ×„¹ŸÓ)¾Å…%Æ,üRœ˜ìdo3GÉïmäjT(^)H±D8s¥l¹á¥Û¬eÛ™Ô+—ÖÑÇ7°Ð[.ˆÚˆvÆåë\¼åZÖâ.Bj ¬.¯\)s <©õÝïBiêR™Û ·ÊU‚ËÆ·_ýœ>O)¿µ[°ãâ:¨²bìœd¶‘J”´”š5¨©k5y³¶·55Þ§´)p_z0 ÖÑ13¡Wò¦©{Ü1IÇ+beT9ލíØë{‚¤éÙɳãã^Ëá°$&ËÌšÃÐs•›"²DÎ}r\‹A,mTª%§ lR, `4Màþêøºi¿\ß‹Cº»Ìés{ šÁ% _üœeíÍ&¾z³yìºx–ÊèÓbpà›èâæû6ˆÞlž—åÅ™tg¾ªܸŠ.~ç:Àƒ¶¿ÿü !mú2§í~Ót®KTJW•š~yûúuÔ_=ä!}ƒ=Æ3õ§ÜAìï<˜`åbP—îÈÑÓM´`Kx.,ö›¤]ÂNömðˆ­04~Lо£ƒŸÇÇwÐñk=_ŽìãKé^9™·0‡êæ!GÃ|Íc˽½ƒvÂORJv}r›5~þOBÃBNÈ3ªÂåR¶íùÖ ±Ù{EÔÑÁä½úà¹h<{jÛTs}²ûûÛÝãîÂvfryWL ŠößBM=óx'¥þ¼`ëÍÈMŽG 7¸Z±µ ›:Ù EQé˜û…/õm‹aU†\B¥FØnÉ¢êNÏùߺAP‡ëN¿ÞÕ:‘a6]½8ÆÐà;—¢T#ÄöGÝ É9¼±b½;ór z”›!H(eÂ:ÈQZO°¦›ƒXˆ¨,k‡`e+‘Ó¥u˜?<~¼ ÝŽMQÙf4úÈ© yY3^@¶ïä `7Ô2j¿ÆºSÔ}ð¬duÕ*×–Òòz1Á*¸… fô ý³Â‹ìÖuÒEA­{¶“¶;±Û€m“Ћl d,uIM‰Ú‘ > gï^½l3·^jF¯¤u£\8DÄ¢Æ"¼A¬ÚY_+ëóT‚ S"A¼PTˆÏ^ΖÝ\J@Qæ ªuWÒ~¬µò‰ûÏÝ?Ÿ}N·©î2|;hzfï™–Sº†'ÿÝp«½¥öÒ›º†§Ãuoû²|ï ­¿œœ@¢2[*š”7Ê)œŸ¦h6‡Ìý[G}4 Æô#ÞÃøµÎk9NGôºzõèa-¾ôø`< ¦¼Ô¢3‡óÛx~¾÷ÛÞßÖ—‰ endstream endobj 5040 0 obj<>/XObject<<>>>>>>endobj 5041 0 obj<>stream xµWkO#7ýž_q»)AdòZÛÇv!--taÛJM…ÌŒ“¸Ìس¶‡0­ö¿÷ØÎ’L «nÃC?®Ï½çÞs==êâ§Gƒ¡û³ÆÛëF7êbpùOO©3êÒQ4 ë õ»4|Ó‹†ÃCºNüª.]ÇM!-Ý2=öLOã}rCãÖ7´õÓéÐà Ù2ç˩׺þ³Ñ¥v&oÉä,{j3ž1M{°ÿûû¾q‰/Õ9ë&ÎdgôšœÍ µ¿Ý,à7Ï,™™*Ò„n9«¹1‘ T¿›MJÕ¼âÐt=É4gɸˆxŒCm>z¨[kJcƒ˜¥éç$Ÿ‹bÂ'TH#¦^8¡6â/~c+šB=»ñ€Ó=M’}ò¾§o‹É„kDÄo¢”Cqª­Ú½À½ºw¾uïcÖDúØ0žE¨fZÒä#¼à؇ø1öóJÉ1‹˜¨˜A93Ñ-}çÌ€ •qº({5¡\ÔjáØ2|Êõ—á#ÄÔÁ=6çJN·…Üùd ßR÷¿dÖ¥B3Á½£ò­È¥O¾ŒCk –y]ƒWýõôÝH’÷!‘®…BˆN„‰™N|È’rÍï…* TÌ'=õn)h¨"*¡ªòý_æÐeyóÛÉé»÷§#À';èìÑ[ôGbNÐq—~ ÇᠽΠ”г`£â £øÀ–W ¯Qg â®ðk,¸ÅÍ]­õÖCèæðYêÉH« "U%)g^O¶ì[WŽÎèhñÖÑ;z hxÔ­®ëW¿ž}ßD]:Q±Ãð×ç/º_XÝ> ½´×‹ÞÐõ¯#nÃAw úx‹Ã¼wtè†N¯?7þ—õ-sendstream endobj 5042 0 obj<>/XObject<<>>>>/Annots 1815 0 R>>endobj 5043 0 obj<>stream xWmOÛHþίUœjhâ¼ÒV­Äq…VºB"U'Yª6ö&q±wÝ]›4÷òßï™];$¡©Ð Ézv^Ÿgfòí G]üöh0â¿8?è†]œðK_n.N‡á)õº'xÍñöêOÝl~ÆÓa?ìo<ýu²¡Ï)5sê\tih2£~—F/{áhtJ“ÄYíÒ$ˆèߣÉ׃.µ{8HøàÐH[e%½¡O«ÛÒ¤jþåÂèÜ¿=SÉmú—Œ‚Ã^ËËEG¯w5ÌŒt»œ©ÎÅ~³Om8Õîj§‚(Pº”¯èƒ¢r!ILõ½$ù]äE&[Ä685¨ô§Â€„Jv%½—¤r©)Ig3i¤*é^˜TL3içiH­sÓH‘Ñ9%¢媀҅(i),YVFɤINŸÓ;]¹K³JÅeªÕ#S{ªmÙØ¤E‰‚P&Ô¼sIzúUÆ%M%Ÿ6&©ÔÎLªJi œJFGaíIÈž\ée‹RE‚¼Ö­tE±P´4i))ÖIŒMQÂZiiZqÂ,!BëÀa)KïX4µ¯|–7A×î÷ÃÁL‚·oßÒ ¨ªKêBª(xöQÜÉYšÉgÑQ“*‡DoD‘ä$ f­awGèùäú ë~ÞPvÂ0ŠÔíç—ëÃÃ(€PtÔ ŸÿýaÇ.Ó9ë¼9¿]ëlüŠñ`rvsùnÂöë3mÁˆÙŽ÷ÝGÍçg¦õ³Ö:×_>ß\_ýþ'ý³qt~óîlÒ¢îh8ܱ°™DW×(˜·ž½—Y¦i©M– €ÝÄ÷úÜjâ}P1A¹ ‚JiËi9Ù«¥ÎÆ|Ç×GÙ`{»Å©*ŸJCzF9ÚUÚf^åÌdæa. *ŒŸs8™YM ·•Œø,|–W ifÚä” Àù{;Y\e‚ÙiÛmi §"þÓsj=²‰ÌQ– ™V ]¦—íLÞËŒ.´) Ȥ šs)䣦fžly:_”´hs‚š–ðT6ÛÈÿ»Ês Çã(Ht…pé0³K2ziý»XgU®lÝ÷æÔu^5—ûwq)8«Úµ²:—t—¢Ñ"ó „ Ms݋иOgHôXîF)\qFWYR÷±S¹­¼6U|bwù¥–‚TEGô´tÐßÉføÑGƒkßVÅ£Ù†R½¡KYz9Œ^1UEU"Ç®MtŽYªNƒKÚB/é¸SÄèóÓ–¶Y²dt®eד™{Þø'íZ{ˆÝ˶û^êõß'2ð"ç50+úù¬vôo@PÊx¡Òo† ?•TYxYh}ÇHÔõŒÁŒj¯'—0ßaašTñ‚§ÊH pÖÙªÞ4'Ö Yî4Ü]ØžL0§é {ãǪ°,QÂËÇ2-[ž(­ÚÐme\•)šËyçüÅ ô-ßík@1Ý £+xÓä]ÐBfpí¡Ù^{î6²F×6ÇØæ†˜#Ôµ©-7–i–­“ˆ ñð(¥rkHçâ%VØ›È Kq»?æ·IÐë… öº/…QÈše­=‹Å‡áxÌòŸk‰x"AÝöãUUÜ{·Ì¥’F``qüUÊ^¤ Œ3Ži=AÆrH·Ò»_ªxn¸IÁã{îùöZ5<`Ôpù7zØþ›m= TÌm…>à½ê­343bÎ#ï')šÀ­Â¤¹†‹ÊXD¸q¯o2APN#“*®·¾i¦‘1—6# ‰„%œ¾Ö4e·2Û3lf¸j5®ð€$«RLÅÒâÎVζʺU€ãOAè÷Ýã6U"UÌMÏ«!}àOëì¹ë4XªsÍûü‚®Z—¯Å5ñ…©ýÙòª=æO]¿MÕZaè7ˆáùc†ŸóVìóÃy[)öÈùô%ä\¹çZoeÊõ@lÚUQ`/ðå×_eúÝax28¡Ñ¸žŒÕŒÕö ìÒo:vÃßÂ7&/Ü>õCa?aNº£pй˜Vã1ß~79øãà? s endstream endobj 5044 0 obj<>/XObject<<>>>>/Annots 1818 0 R>>endobj 5045 0 obj<>stream x½WQoÛ6~÷¯8  ŽjÙ±ãlèC×.݆u«‡¾h‰¶™H¢*JÉŒbÿ}ß‘¢$»NÖíaH`˜ÒñîøÝwÏŸñÑtÎÿq6‡c<áˆ?~ÏOh2¿ÆgF“(ŒšEJ½eF³E8ï½ë-3Z\…“Þ»Élζã©u:&áU³b¯ýuFÓÙŒ÷Z[~ûò—£M´ÜÒ«›KŠÆ´Üà0ók|Iìð%6uWJç$ò„ªÌ©HE¬ò-/ÈÔE¡ËŠZ+•WšmJ±Íd^…/—wƒ1]L.á4¸Ñ%É?EV¤rDjC{]ÓNäËa¶2GÎ|ÒR“LU¦r<ƒÂ!¹Þ$³iXã’PyœÖI›y–„ǵùÎAýM< WÁðiX˜í½,‡ Î“„iíWÁ‡ý¯ë;@Kçz}wbÏ·ÐÌ’è?P‹ª.óS<#²LCgôxÇ}b©Ýï‘QÛ¯{@<Û9Ã{H¼PyQW«—'ø~"®eæÿº“¯£VûÄrÅ„äV!P½i–¶™ˆùïÕC”Ò?Ùm±ÎÑŽ•UvãéD1äìîaIh^‘$xýƒí¯=ßÐÌNKºàT¯Œ:™å€ýÖã2SÚ*¤ŸdCCÙ&“ÕN'äÁéxÐÍ=÷ZУJSZæ×õ«•oöúXŠ¢eÓÜ8¡Y¡’Y­`, ©#©GËûï`c½Ï%0ê.Ê!…8u ¯mYš¤üMÓaÏ’Ìy¶X¹$UedºæIw¸Ã›·÷‰½·Îƒ‘¥½Ø ]ñ½±k÷ø›1°© ݨ¥ÊT|Aø*rª&¤?L  `ë¿¢Úਨš/HïÔf#K–ÙÄ b%K2å(ˆµþv9Ëö·þPÌξðUEg‡²p桃 žÜævýËMCjxH¯£þkFÃMSýh!ª.*pÇ•:–ÆpË:…ÎóýƒIƒAs½qX;Q¡ŽÁ‡ƒ½’‡æ] ›¢àB…\&”ûÝh°ÍF·›=C8ñm­Ø5¬µMÔCil¥0ó5“Í›ŽäGBà:‰ãÙYBç`ŠFó†dÕɹeê8$18B½7xU:wÏ»n:r³Ö<:!UÛ¬M£°ùEKu'ÏÓêA«GÔ«.¦µªx¾näþI•åä;±§´"“j}of­Û¢{îåó‰´GnÅëŸïÞn4;uÚ£Ý2<·ö€°>q㩟ïœâq(Âp×KWô5SÔërìÇÒ(lª¸hª]-ÂÙtF³K+<<Ž]ðÔþNÇvÚÌw[±ÉøÒZ^\¹"üTˆhéfá–\V¥fãy8@Î0¿E‹kÞþãrðÛào/ª»Àendstream endobj 5046 0 obj<>/XObject<<>>>>>>endobj 5047 0 obj<>stream xWÛnÛF}÷W T ‰%[vÚ¤€›Ö­’ÞäE@±"—ÒK.Ã%í¨Aþ½gfIêâ8 b‚DÍÎÌÎ9gfüþ$¦ ~cšÍù/ÉO~ZœL¢ ö/ÕšÎo'tÍh‘ÑåœæÏãh>¿¢E*VZ$C"U­§ô’nüëí+«¼_ÝêÝtyúÃéâÝÉ„Æ1ìRØEQtô$sn9Äñx$NŽ|bóóÛ b§p6µ õ½.Hyª7ºÒd<¥MiM¢jR½-u®JJ\ª©vTV.ÑÞÓÊÕ ^qwñ:T‡Q†¤ŠôØfud3â¨ÇF}ŽŒ)×õÆ¥ô`¬¥•¦Tg¦@’®°[¼$º/Ë” uCY¥Ö¹.jòרÖðà ÎÐ]¶»zîP‚z£ øk˜Ú¸"ä™™Ê×!¬<åbqþlÛxFtƒÌP]qêcÆLR‘Låˆ@š¼±H Y›uˆ8xë*ÒT^Z="“ÑÖ5´Q÷:” çŽ 7f30)>ë.¸ú¢ F4Øh•êj°<¥Ì–]xŠñ‘„=¡ð¤/œ0ìÜN{·OÒLPâj}®Š¡zwʉš>¨­ aîuUfŽâ"ª±u¬'êÒßoï~%kV•ª¶´Ú¶kv"Hô@t}²µîv¥néü̉mÒN;È޸Z8R‡dW8Àב¡,7lâ:ùø=ˆ¸øP6N]qÈ>·–Î窄ü@ë²Ò÷ÊXr´<ö”9k݃ÔBÊ86Å8¼qM •Ð2ó ƒØn+„3E­‹”íX9këVÊrV âAmb¦G§¬K”i}©£¬ùÄåÃÜ˜âø‚9DÌxæÏùI—;*מiá$ÓZ»Äå¹ò½¡ßlßÇ‘™àŠ(%¹ª4i)»ãÅ•êõ}‡lÛ€ŸÑ krSûhó㑊ºI‚DϾkÉA»&Âf_%(dÛ"ür°s(ò=ðJÔN:ëå¾þ±ý}õN'5a\°äÎìºW¶Ñ1“n¤ ÀˆðÃö.×”«Êo€³~¤íïÍ›9Z-‡é½úíæ¯^ß½¡ó³–ĬËÝMÎÎ?›Vˆú(ÛO¤- ~|§ìy8nh|¿J×MUT »=+oß¡>yZâbÒ£åÑ©!kþ¬i¯ÿö`rGÐà)zzMÊz´„ʬ׺ ƒCXäY¯N†íÃßûéå1Å‚„/v™^\F!<8ÐK–|‘ÈM¾Ò‡’ÕûG{ú&µ¬Ìºãíž\öÉÌ_Çø®3{9àwÓGOfÌõÁ@pyr€¼ík½˜‹ÌÓ#LèzSéÝÕ÷…Dæ\Úd;‘÷³´HA§l¬E—4Å^›gzíF9¥AˆÏ›Å `\Ö[¨y s~ï2ä3Æ–§‚}ê€w>t+„Þi¡×h›h…æcûBsý"?:¦ËRqbÏ’+aõåŽ$×í:Ô/sh¢r[OTH©"ä·E­>ðeS“eÈ´¨G2¢ †ŠÌ„ é˔̫Òí\·3[:?y]ªJ6Mk|Ñ+Wx ûêZv{4 lfã@®x$“W¡ÕGtƒ/KS0Ùïîh¸æä·¥°OMnz_„ Œµ;µô’}'a™Á×j…U¨9žÈ¼ïPŽã0oMÁC: ÃãÒ›X…¦ë6ª¯)°Œ,æ=7nÎa­ €‘Ö‡ÕÃKYxâ Ë®BüóÛëö¿€øê:ºœ]Ò|.‰7³ñ,šÐÏ.iX0Š·QÔtr!–ã«Ðvã8ŠcZ´ÿpt z¶½œÌ£Ù4DŒŸOøÑ/‹“?Oþ òendstream endobj 5048 0 obj<>/XObject<<>>>>>>endobj 5049 0 obj<>stream x­V]oÛF|ׯX(0Ì4õe)v›HÓª(Т-" /Œy¤.¦H†w´¬þï½#)‘Ví(lË0}»·;;;œ¯½1ð5¦éœ¿ƒmïûeoäð°ù(b.FtåOiÑlNóë±?Ÿ¿¥ehOhxgQ!â­LÍÊë¯U\ÿÕ_½þîõòKo¸¸¤1F4˜Œð3­x» 6¤4ÝÉbO¥–Q™Jµ % 2r›'ÂH ¡õEYAò^à¡ô9í5&—¨Äû5Ó† )BYhÚ©$¡¼ÈÖbìi'RC&#}«r2I©¼Çƒž”ë–QYª)KI„w" dHuý¨HÄ’Ê4‘Z£ PjUHN†«äŽ%§æZÐÖx•ąʹ³!m%åÙNÜÖºÄÙB·{ÚŠ ÈH¤On2a ÊEaPZdëþüçÏ?‘Ùçr+rJÔºÅÞâ0\\_a–ƒÉœ«}þ¦E5G:—‰úKpÏíÉpè¥oÁ¬ƒ4"¥µtçÕ½N.¶y>-²Þ§FÜs3BcrI’íô·îdÃ&K†‰?‚[a‹D©ØÊþõ7v¤à=ïûàú2¡Ì%>0ÙzVø/=r~ž¸v"ß?þcÖÓ9]Òg,Áˆº/Grïé€b OÃOoÞØ|úEÝ‚JnœLîjRt‘è È×D° Q¯C{žÇ´Ž¡wv‡hù¡‘6EúH­ÇDÇ ­Ò eÿáã»å‡z(âѹ 8?Ðíx¥p¢UO lÀÔpwÊÊSé—÷ýV̈Nr×ox ; ]›sNw\Ëyƒ5µsrõœumŽQ•šÕëæÔlV«™[ºI³t >V\”&Ûbá‚z؇Zž_ÃÏhX6µÖËè6 Ùd^p—ûjUI&2†àA›¬†°îÕK`›O‹ƒ”^ŠhŸ•´wÀ še6*k ¬¨%àêóD;E˜(É„yž1ööù†oÍÂû÷Êû}ÿÛú ”™¾ÉÖ_NŽúÅQUõ;Rª.ÉÒø¿ÇÿmÃ!m÷7µT/‡PF*UµL4Í>—­ˆ•·ÃR=2§~/lÇ<"ˆ?Y¥;‘”’Þ æÕ+{‰gça× ©©½#gÐeÙ†ÿ¨¿•çfìœA“ä‚•g‘~Á;€õ©]p¼ésYt5¸YmÇB®ç âÿîìu&^`‰Ñ=_˳3•2_ØgOÑÉÕ!t7d¡À0ØE;rÝ8·$•ÁA L´u$$”E£ØÝÍó´ùS·1 aPS+%x«4‡‰)ÁÛÙÀiÕjé<Ørƒ—}$…)R›AIKã&Åa^4éÊsgq=ël*Gc]žuN:€•2"JD—pbÚY •âr© ¬<ôbÍ#ìЖ€[mÐt†ÐJ£xÛr1Ù-Ácñ­õHµ¯w1E*úUuYûæüTB9¹7t!¬[´}Wu&£K6Ñ|6ñ¯øÆ‘ƒ©?¢² d[Ü=Þîìà­{¥ü[£6ÍýééÇ×cnóÇeïÞßJÛendstream endobj 5050 0 obj<>/XObject<<>>>>>>endobj 5051 0 obj<>stream x¥WïoÛ6ýž¿â€}˜»ZŠ$®Û ÚnÙ: À¶è—-Ñ6ITI*޲îß;’²-'.Ú. ìH%ïÞݽ{G~<ÓÿÆ4ñoVž½XœÒ^î>̚ίžÒø"½ Å «góËtF‹Ü¯Ñ"ŒÇéxB‹$ÓT‰S¥$×Ö’²Ì®¥y´øpv~uAc,fÉä"ÏaaðZ[G63ªvªZS!ªu#ÖÒR%el¨j¥M)œÒ ·s²÷—d¢"UeE“KÚè-9M™®¬3Mæüj;Œï°0ð|°f ÇX[r¿RT@°Tµ‘F9QeQݨÚÒRº­”U0Ò«•_ß‚Nš•À¶\sXÚQmô:å,émØÙÃr±uÚ×Ð[]ËJá™7o_ý¬°Â‰BôÙ4Z› ^ùàoù±QF–²‚?¤Ò[òÕ±­u²|Æ«Q{…—¿Ã~¼>\M6t# ÉI8ÄÈ –’IJ@Ù9ÝÆ …E‹L%™‘¼÷YkŸñüj<œHž¤ÌDø7™=!†´' ÿ_,Ó›:þAW„RçM!í·Z¶sZäȵ殺´É¥"&P%‡oE"s( \ֲʑö[ý?¿Ñ*ð­±’Íçm%J•‰ÉćÎ|ñKYjÓ*§B-0íy¨%…eÄ*Å·"ù3rT ^au…Ú¶´hVUÖ…'“ï!•ªR¥ºãîåF)´¾njòÀdž]WÓÿ,ÏËÝP÷öl-3µRY±xÂ9ùA:uìÍ@ª¯¦Ü)š*Òbet¹çuÈÿ¥R ÉY¡áæéS|²”Ï_õÒÛïƒ œ¾KOJ-AA4dK%h;¤eã¼ì CæKÇ÷–lS×Ú°–8aÖÒí²jYYO9­ÐÍ‘–í´“[’…Í¥É=1}Ÿnš yÓÁ:Ð&ð™›üÝ)¾m² Kˆá-¼ü. Ù&¼EQ1^–AöPì-A Ñ®ÎÛÁOK‚0h¼{ª…qÉÐ5ë*O˜(h¿=_TŸ{.ÔÛ Ä>ªF‰0F´ü hzùº?ÈÇÖˆšãC8á^¿ÑÃ>S˜fÜÐK7ÒW’Hšw–;[)]!kòV0-ØK/d…¹æGʨ‚QîgìàJkú!¼ëæî½ºÞ8/Õ(„á–…Zaˆ°Œ\³H+ë§ÁùÕˆæé”I:áÀ'étЧ|ð~<šËÙ|þ¾~}ó‰_:MgÐo,}Žäs•Ð…¼‘àËÃá©€,k O rŽVÇsCbÅJº–[WÞ:YY®L'ô»Þ ¤øžAp_ÖãÚ‘†kÌÅÉ‹[ŠkÜ‚Å0€EW©—SVk„ë´AI ¤f7Î’$-(Ž¯Þ–ypx,ˆÏ%ªß"4úNTðÌ&0jŽcdŒg@ÙN¡ú‡Îz´ø|É|H`‘¦:îø9KƒŽnì½ý·{D1Qİù…0on»ÕLº|ðàfxæýϨn–È€ça÷÷IÃwÞލæ[’ÉàZvüô¹:`™Ôf-*u‡c^v3b¾t­åùÅþä„Û¹@qî;9öÀŠp´ê¼­ÄŒÄwwÌ…¼qGa`[J]>ЂÏ=&=I~¦OÞv?Ÿˆ~J®Aç ãèà°"ð‚Ÿ>\Õäïh4ǨOm¿ÂèI×àÝWÚ:Éž2±Õ¸À[Ýa]à ÅaÆ@mqá#&.A‚2‹XRÀq\qdz ößSbV6Å&x»Ý{¹J`È ?kÙeÁßQx]>/XObject<<>>>>>>endobj 5053 0 obj<>stream xXïo¹ýî¿bp Y'Ë–•ør îCrÛiš".š j—’¯–:.׊z¸ÿ½o†äþ’âÍ9IK‡oÞ̼ÙßÎft…ÿf4¿á¿ÙöìõÝÙÕô ?6ÿ¸5]Þ>£ÙÝ­°öæg|Èå9>d£·%ù¦½S»v”Ù\ÓZ—Ú)¯sZYGZe*T¹®ÕZOhgM鵫H9MUæÖù³õz#¦êJ“]QµÓ™QùÃNS®«Ì™·¼¯ÌqLùÆ–çw_ήèbv ¯F«ºÌ<~¬¦tË'UÛ]3ÍŠ¶¦ÂÚRþØavóÃÁol9‘…{STi®S˜=¦ú3vy{E/¦sFã__Oçs|ËG8d1ZŒ>þûí_ïÿüï#»ür5YŒ­Éi<^œÓŸ”[Ï&Ä ï>xs¿»¿µv2[œãÙ/¿à.ø¿Ó¾v%½ÿ×»w/é)rê|zsóŸ*ø›Jt¼¬0(½¹ò*¹ æ3¢(hUPàµCÿDRš"·_ :l`LÌ‹¾^hAB} …/ÃõhQö…™~ª!“$R¼%mÌ;†‡©… ™åš’Á`S·?á\y>p‡¡B¢˜>4__2Ãà L C£ºŽ­JªEã@"ú_ê¯Â³¾ãük >¸ÑRä{Íîœ~dXúfÙM~bl %ÃTØ‹áçGâßÓšè +NÎtÖj±ïöã&I5 e‹ë`÷Nœî-íQ[‡Áš’œz»êlˆ]në%:v×ÅNkNEH4ëRe¢ŠÊP—ûŽFöA¡ó,Ý¿£6©Sm“k3ü=ÕPñ³p$©lñØož È­GˆE™Ú¦Žá÷eRÄvƒºÀEƒRåüé9Åv„Æ{ ªôÇÍv©*®t –• ™œb°! Ìê ¦¡ù—µ)rùâÖõ W´C³ {ó¡ü?B¡`ÆXSB®ôÉÐhÏ#­þ„‹Ã­œÝ„&§yŠÑ_1«H QCÚ’Ë¢½Òe³Fü¡û.ÊÔ0d) ËV,¦NÔ£Õ±F¿eÇ—\œÖŸENœû¥FRx`¥OÝ¡•PGYèÇá‚c4°p .‰(††Ø!ÅdPämM™jÝtCÞÌŠcMñø¦cHQïQ;¥6ž„ºjÅlà™1ˆñDÿcgxº"Û^„Ÿ7÷ã,\cºÃ<Æã í»S3YÌˬøNå<7Aìdù!ƒ%‡²2š/¹]‚ªÉÖ¡¶SÒw`í¹ÄEˆG2ä³Èürˆú©‹²x@¡ëKTäü)>Í™ah)I;ÙÌ•ݯ.¯b)5U…a3©†S ŒUž;-Uû+?y„2ÔjÎ¥ö{ ´¶uá ^!ÐÖæu¡Q]þÎú )Ï üI\R.oÔ ˜þãý›!(OçËÁx$‘ñ{›§%:„ ½%.®a¼ª4"žÇUH•ƒ[NX–ÝõN`ãYÛzQìûÒ¶šPãøpmtV­hjb{J¯u¦Ø`iºÕ[Ë]0ö–È7ÊŒËê}#LqºÌ t¤]õüà“8;9(Lä<‰O¼o÷)UÙ­Þóë ïLö€`ð±L/Þ"Œ:ò’‚_ùT|vò^&Âûv§ Mæ½3ËKÉ”Æóô–µ²Ç9  rê`Tå¡¥'ñÂáÀ)Ú!¼Q<ߢ~°Þ¿ÖÍýÆð{´ÿ{jZ¾LhñÜÚ)""¨i¤M\–ò,:Ù gÍ@ç8bNö¯g2[hŠÕÐ,fÿX\ÀŸæv¨¼ˆ\ÔI0³å¸@×DöôõÔt 9†B½‹áÿ’ê¢Õ«V¬C›¾rNØÏF7³.áàðaÝÐDI«s„›x¼ÆùOwè™,…ß×Û%FòFp&-ù-“Ý‘¤{ÓqTí0ù!¼fåª'¢]CÊñ+0˜>êPrÇy£½ïXpÂÝÑ6T¸º8Å_¨Äô@Õ ñ2hÓ–ñr4~þÞRÍèÐ(œqyû"êþÙ‹gÓçóçtóïlÃ{ZnäóéýÅf¢#å#óÓdX}ñO ùh6›Î®§3z˵ƒák–>¿º™Î¯ñ>œWý<çÝoîÎþyö_êß„ endstream endobj 5054 0 obj<>/XObject<<>>>>/Annots 1820 0 R>>endobj 5055 0 obj<>stream xÍX]oÛF}÷¯¸(¼…lH´(Û²Ý"ýHŠÁn·QQ,`À‘CibrF;CZÖ.úß÷Ü;¤D* ¾mÛ¡fxç~œ{îÿû,¥)þ¦t=çYu6M¦ø„¿¥üí·_ÎÒÙ]rK··÷Éœ*JçirÝ>•ôñ¬ÿŒÕû‡ä¦¿Ú{ÆêÃCr×_í=W4KoïöŸ±z;<·ÿŒÕûÞEÙ«½@$¿¢«wSº‡ó‹‚fSš?à•ù-r wJ‹lDôâLN—Yi´­sU«ïiøçê’>(»jÔJSØèÌ&£ÊåM©‰÷ÓåÕÅâÓÙ”&),æ£?)lÍê)îx2¶pßóúÕ»â MàÊdvݺ2z«²ug/ÔÎë@Ê’ò^íÈ´qÆÖÚªE;¨“ØÉ9õn£å”á!# µo²º‰örª×šlS-µg«üV cñ± íé }t´]kÞ4。ΜÍ;±½t*×ù˜LM…±9\ƒíS¾õrðEï¨p^ Ƈº;EáÀ •ÏÖp“Íïó!ž'ô¾@–v?–©¹-¢’ð”×1D ?Œ¯Õ Œ–^«|GK {Q5ANuátX_“r¯à5¦ìÀÉ 'ÖÆ®Èê-9«CB Äxú ¯ÉЂ0³µ2V£Ên¥å`”VQf|֔ʗ;*}ÆziBÄZ^Ð;çè’þÛ¥,‘ƒàLì=Ž>þñþ—§Ÿ¢K¿Öþqtn즩ÇXŒx ßž§c:OŸr2o6 £Ç |üæ Ø ?½¡Xúûï>©!ø–ô¢›_ ¸®º6kƒšÓFùš¤~*ÚGF3Þéboùnà×ð@Ô„©–_”7jYê„bAJ•(Î2¡Ë“°œ~Ý€td«¤þ³Ó9‹ýúöéòøh.2Fnù !µDw$ô:”"PK¬ÔcÚ¹†ÂÚ5e Úª]Öùúh9íâ´±€©Ê%_~Ç´ß×ÊçÁU—ݾsVÞ¹ñð°Ü Œ21còüqxÕ£Ü* Ë·ëÝ\þ«E:*Ž Ÿã±]1ƃq¨R]ÂgÎc¸m0›$p.‚ ô z J¾‰õçÚLj‡‚äm<”}Fp|Zeê¶KÙ.3ÉÑ3ñŒ{©ørdÂYpìâLãùÁ Ïd—UM[ΰÂXïíØOá>U¦|°ò@€S+ØãuÞ€¢$â`þ³ï 6:𨤩6ØCdÄ „MvTéd™ ˆž½ˆp¬Ìj]c(Á!@h‹>…Ÿ{–ßy~8$^xí@vh׉TXs/‡@â GÂ;.óÀ÷Jeþ3ys~h©Ç[~¼à—Bjç\ÆH~ó”A9-uÌ+í "Éô°™^IIº«1A?í«•€JýÀCýªªM©ÿ¿èø˜é!\Äè¸ÄèÚ ùY$í_lcÜ2pÚ‰èÑ &rVW”ý„õæÅ Ù“/ŽqóÏ.ñíü‡ç)½Áœ’ùó§â¾%O¤Iîúmã ¨Dzé3"k/­qžÆzTÄ2÷JG@,rDТEjVdÛ2 "ùÄ&É#é5^*½ãâÈìp‘™_Á°Atµ7­¦k1c(¿j*\Z&“ Ã\A^5³h Æ“kHttHÛï1ˆÑ(,¨x'ßÎÛ¶G»üˈáàÖ~®†ÎÏ™ÈÁ÷Ð8ˆ6!›ÇÔ²ôNì:f&‡†Æ%ÂceƒKcN•zN—|‹E1ŽÒüÁ,¯ø¸º$a»Š«uþ dK³ôLy-9!T\¾ºÖ'·O]]òè â¤SŠÕå£Õ+â3ª+.›•MÓÄEêk£(¯ò ÂcôC®,¡Ñvô‰é«tî™@&9Ô—ö2ÎoêÖ1Ìûö7!³éMr{}Kó»y¼¤òÞÉu2¥Ÿûuá—ܸwro.ŸÝzo§óäz†k1.Oéà ¿ôvqöϳÿn»ý¡endstream endobj 5056 0 obj<>/XObject<<>>>>>>endobj 5057 0 obj<>stream xÅV]oÛ6}÷¯¸h^œÕ¦%ËvyY;é𡆢.F¤%m”¨‘T¡Øß%)щcÇÅ0 I`(Öý<÷œKþ=ˆ!Âß’…ýKËÁOëAD"ü2|¨ &«Ä¬·h»¸ÂæÞãC:¼ãÆpšWšÃV*ÈåL[s Tq(iE3ÎÈåúÏÁduñŒÌ| ñtiÙ0ŽIœÀ]JZ£WÅ@Þs%$eE•yÇ}þñtF–Kë·Î ySSÈ ˜Ä„•4@ëZ´`$˜œƒ6Ô)öŒÏ@Ð*k° ¢ø‹ÃzO]Âw#Øå ~”äÖEñÝ`²k¥lÒÜÖÁ8žÚR\°w¯_Ã] ¯¸Â´UbYnrÉ4•IUÆM(‡ÀMe¡jû”«W`žZé|üãæìª¶ ¶õ¤ ÝÔµTFƒ­¤ïãQn‹ì¶©`šÀ ‡ÅhY >‚b ­l°Ã{R)D,b| ÈQ`ëÝJùayïöÔwGez•cë ÌÙ¿<‰ X.MŸÍÛ’ì?qé£Q(›—@³ùŽ/þ6âl€CJ!pƒ;û¶RN“_ùƒAEk+Z)°B×Ôà‚éWà… ßMìå#0ûùû-Ô«Ïao××€Ú‚¯‡Ø¡=­7Ãä…Hx½žr°N.¡˜°w¬w‡ãdµìnzñrFæÉË+²°÷36´—qB"x/ÓÆnk¼åøSObo=~ãùvþN7$™â…ÇWsÛåÏëÁ/¨endstream endobj 5058 0 obj<>/XObject<<>>>>/Annots 1823 0 R>>endobj 5059 0 obj<>stream x­W]s›F}÷¯¸õC*O$’Œåvòàø+šº–kËI3Udz‚E¢–î‚UM'ÿ½çr@ND*{d³Ü³÷ë\öð÷žC6~¸üëÅ{¶ec…¿þº½ÜºÇÖ€†ÇG–M1þ­QuÑÝ^ý:¦CÇiÜÅF4Hgô|ÁÀwÓš¯Â¡^Л ›Fð6 ¨o“{ìX®{DS¿ˆÈ¦©×¡òó™¦íÙÔs°êoVÀf±9Sù<’³ŽÐ ó‡ýçì`v@ÿ~Íž÷Ò2ËuB+-Ò‡@©§z]FÏ~þîóöâ‹…"ìàÑÛ·Ôÿ–ÿ*Þ»L‡É¢/½zEc3N2¹ºZwvçñ"þÿ‘†ÔZ!€ýkE±È¼%¤ O¼,TɳY²¿] ¢o.†Ä} ¨‡.öúƒª‹éRRšëTI*  —þ:q葚”=œÜÞž|Ú„åØ-“ʃ· i=@·qì–YdÐß‚´  îp ÒÂv¬ßÈÆ±[è[°qËËwñ±Žqì6F‚\u:ù}ͯƒœM÷¿© g¬¶ nÒ/gO!pìiˆÉâ,Nfž>ÙJÚ1«pa™Õ¢\ÞÈÓN§eÎq0®qŠF¬‹DÁ&^”³êÁÙ´-¡ý<‚œT3W*Á1ëÖ­ïÝB‹| ´R3¾„¢ˆ‹“šµJ©‡ %J¥Pj2Îe¡Xâ@(AfUÚÊ¢+µ¢'>kË|E´k³¹½ÿJÜBØò©¿XBo•‹.”&ù`!Òe ÉïåV• x+pT_fºdÊRó¹e(´F¨#ä4!ÀÙ²©_îy¢b=Y‡E„JúD h¤-]“3M‘´Ï%*‚ØÖ¸•¨A~žÔiFV1»m”åf ËúžûGaAcC·£žÜ¸J*Öôí¡uˆ±wGn¡‡ Iz¼Äž)¯xÍ(ô>oלҲwÄ|ó;x v ¡6œ‹³‘Ò(Cm×ÂQZZ»¼t>Ýûmï?¦qQ&endstream endobj 5060 0 obj<>/XObject<<>>>>>>endobj 5061 0 obj<>stream xÝVmoÚ@ þίð¤.‚(„ÖôeBÓJÓ­*YÉÞ´L(MHwìrTbkÿû| „&®R«}( Àw¶ï±ýøâ_ |›Ð²ä'˜VŽÜŠ¡¸˜}ñ4N Ø×[à¡i€u`ê–µn˜hàÕ† ÎBŒ±˜Æ$øÑðù„Ä 6jîuÅ€º‰Ê¡T¾`‚¼–Ú‰²WýêÕ ŠÁ‡©pCÆÓí©?󪙞6ã$ !¡iK‹Ì5C×÷ö¿tOî7ÇîœÙƒî…kŸÚ—^-‡V¯ˆ â1ãø3at¤mW›Ó8QB¢ŸIKÃL~ÀÃÒ>û\ƒÌ ·)}¥Öêëµí6£±AÑ ˆk1ñ ”D™Zdàr~²Õ‚Ãlýž3øk‘§KCþ¿¹èœ½ÇîÄ»ÃçPж/8Þ+p%)Þr·ý&÷Ê×nƒéÕž\«¾{Ù½8]!T·ct%ŸÆ§'¯/™žïAÕÖÿ±É³õï?6ݰ(u&xž¥ÑÓ–Ü“FoŽà«Äi¸•ªx¬‚ÖvÉ $qÀ£™`(¸É­cv7Î\¶T¡1ämë,lÎ ññ,¯VÄtd“2æ†zŽån¼- -rîù²¦¼˜´}îuWò0ÍÎF™ž-iÆ ¡—³è]]“@€š#j‘lËçOúÈWmÙ[yª'Ônœìƒ¢†`î¿Ñw[»`Y8™µp6 “F®·tŽY0Ÿ*|1*­7T»¾—Ž`¦©›hƒÓŽW8tÑö?> B¼^¥É®aé­&‡èØ<Ø“K¶[ùXù ¦ÕÉ%endstream endobj 5062 0 obj<>/XObject<<>>>>/Annots 1825 0 R>>endobj 5063 0 obj<>stream xXßsÛD~Ï_±“¡Ô)±êqâ”é }(-Ô /žaÎÒÙ>"éÌÝ)ŽéôçÛ=I¶ì”ÚŒ'²îv÷v¿ýö»üy6¤þi|Í?iq6Hø†?†üñËg£É$Ðh2ÆgA£é ¹®ŸrúpvøŒ··7ÉäðíÁsAãá´µÄ{¿¸ŸnEÏ__Ñp@³%⺾Å/™„ƒ_ÒÞ›@…Y­u§IѲKJmt±ÉU0¶¼¤E…kãñ}¦i­<Úé|GÖ­TiþÒ©<ça­i¡¼IéÕW_QØm´¿¤³÷&Ã"o MÞÀ°¾˜ýq6 þp„pz¼®Ÿ®uzgÊ•8¹$U¨÷fUb£VéZ¬!ÄÓ©Ît™jºWy¥“ÚÔèŠM½6%BÙ]R°´Ò¥v*h‰*Û•ª@\™ñ`nY•i<Þ‡ßÞü@•×^.mžÛ-¢ò•u&¬‹ìÕìGïîµË­â:¬mæI9MKã|À]À‹ÅNŒ•U±ÐŽ3ãôŸ•qx£Üª*t¼þüõpZW§“0xpˆùèú†Øç¾tü®ÎÖÛÚ硉¯Ö½§ÖD…Š”AgÏslÍŽX°ÿ× U”"Š™BmbZ$]˜ÀiAU€†¬BñÔi)pHlðÞ:OdJ9fjJ|ºL»ÿd4Mn›ê½YÒÎV@ñ½.ŸÚ¢Â)R%*†HÜÈ Ö n[ -èWe Üy¯ÖYÚ"˜©…•ÖÄšÃ3p\•kŸÐv«XØ»ìà¾ñ]ê-¹aSu—clMŽ”]új³AÏ©S_hÚê£çAÓ³)'Š»ø2‚t@ÓdÌ3BKFÉxŒ§¬÷ü9ÍâyhigNðÁÁ~“û“úÔóž)çX‘½x—ÑÇÎBÂ?ärÞ{¿û f~Ť1ï}!Ù›_`÷éÞE_ éå¡åßøhìÐÌ×'~ééÜëÏÙgù]?¤zÜ2ïÉ3Ÿþ{ç, p^H? IÐ çó‹Ç|tÜ~êðR%ÙêÔÿÖ·,µ=èGèÑi%çJÚhj‰’óY‹Ÿs‰«{•€¶—9# »Kùß;g~ß„©™nix•@J/1É£jšòcÖ“á½åŒDÙÃî _Ûõ½'ŠJüzo¦'á.Ns­\üz?ã%Ó)»{ƒ4°ÐãËAJŸjR¨AuƒlA +§ @sÃð¤­) W` 4o‡¿d¨ ÕA6·<ÜEs°VÛ‹¬» ê R%Z«K/YD!Vb Ϧ¥cQ’ÌøÀ—iøû3RéP]BÊ‹žñ/Õ }öî×Ùû_gèx~â«ÙcJG4Ηü¶+-º:bï 'Á™Ž\|lÎ.êÊ ºÃiLË2^·dÌ­í¶³L<ì‡Ó±t°`¤•85±¦‚•¶õ‘«ØÉ 4pß>ËBQL0eÖœaƒ5‚\Rx –zìZ·6×'Š_\yò¼9A{•‚-V àS˜¤§ŒÇ ÀCÍ™%‹2LÏ&ªGÅplŽN5?Æ'dW.²€nÆ#zVíÓ? 2!­ƒkwã½ÎÉlâ›}bØ‹îABL¼˜=f ‰íØ‹»ÓõûàÖ×\ÙÜtGƒ«d2žÐõÍ$I·óHîóßC¾³©ÜŽå/lXŠ‹û7QОðPYéIK*“Áu‚pÄÃÛ)[ú~vöóÙ߯Jvÿendstream endobj 5064 0 obj<>/XObject<<>>>>>>endobj 5065 0 obj<>stream x•WïoÛ6ýž¿â´ƒÛƪ$n²­².Ù m†¤(h‰ŠÙȤJRq´¢ÿûÞ‘’c9)à¦ISäÝ»ãÝ{§/{Cà߯þN—{¿_í ’×ÿÙkzy~HÃ]åØ;9ÁYxŽ?ÒÞ_f%o¥= ¿V’r$ÈUs_H®”©'“Ó³«Ï{/Ïá(é=eYÔq±µÜƒáIK™9Z˜Ê¤K­*½2:¡wb)‹ú`7K™‘Ž´k [Yå…|]Ê¥(ÉV€¦rö> þp„hzÊà…•"«á8WZf”ËQ‘öZzÊ„l$¡«œ˅¸UØ"ŠÂ¬Õ¦"o(3äWøY(}í~a/HltÈnþÅ–Thâ¼(Q¨ÿ$•ÂzÇ)”šeYÈ».ÐyM¹²Þlbc.Wí&d[g RSåøén™6Ýèujli¬@ž8^‹e½§MMÍzJÏž‘B€Ï§ï.>\¯ Z¹,±þµÍvðNÖé5%IB\X·¢¨$åÖ,é‰Òeåùɯۇž qäg6Ù}ô­ÙhHéB¦7-ª‹÷—Ó«édz‡XT°Ïaü·×4x ,ð^þ3ýó“¼KehÆY/|þȨϬ5ö`ÿìŽ;w$¨4NqþIW˹´?Ífzö¬ &ñe¥¯¬¦wÞ¾}𸠊 #뵟bˆHN'7‘M6³ÏÖ¿Æ¥cv¿u]lžYçæñ3÷ä×·?N&¨y ºT:•;VåCBB¡² Bר7å<70Ó“ lJF5­DÍÝa¥C¥¬9üƒÅÊņåtlÒkZHaãbÛ•=ZwFÓÎ-¯Iðé£Ç@`QðLQ´Ý1vhœÏœ–«tݾ íÞGÁsçÂÂu½LŽùæ¦ Ý;Cj âó‚›Õ°dpB!CLF¥UKaëetaRQ W­s\ ޤ r^¤7}V‚4p•™FC¸(!hYkcIi§2Üy[ÂAVD(-å•y–„€¹pO˜æáÕõKk4@’ÜzŒV‚_.Ÿ àR€~šjÐŒ–V±®îcYÖI•Ô™Ì: à£D~ñB¸„y˜msÜeô `mÚÚ CÃôÃÙ°L"gAüBªc^5˜ß5TtÔ·Z²xDFaÍ`9 sÙ)´ƒà 5U‘)FœÃwbï° „yQOµÿtêÞ}=ëE„ð~”¾µ©|Ëßyû¢~jŒžèBq ‰0X&žÀRö–m üú]žCù„bL…“±€bgµÒkÅÕ{ÂiËŒ;EÞ•¨`*-JýÖ­òP…•ÖøH ºd¥À:XåáDÉEÛ·­É]J§S+®J˜;·Y™Ó1ÜÆÇ-µ ïmíCÿxr‹PQ˜X˜#xâŠ$þᤠ}Ícœ)™O* D=#Ö9Šý& Ç"ÆQPv”ãÜ+"ňÅ,Ö $„ƽs¿ ÜÂ@æ ¡:LP·|’%tY .j0X#¶Bƒ|)nÀR°¶Ð×< « 5pÇF£w°„®Ä@”z¸ä;c÷{?Cï6ªrOØ‘®ÃÜËd=¡7/^Ð>WÒ>†fœ-‰ÚdèSVx jériåòŽú¸ÇÍÃcG¶ŒK_IœÂï7k âü‰,Ãe€»xZ@ŠôÓŠ° &ØP˜ü&ÞK€%¸Úè>ÈÝCØÒ‚Ù»&£~?àÛ®D·U>m¬ ½OÑA•¨ o 1BÄó Ñš0 ×o*¡SÐ>/XObject<<>>>>>>endobj 5067 0 obj<>stream x­Vkk#7ýî_q˜tíY?ÇéB m“²…n·Ô°,Š<£ñ(‘¥YIc¯)ýï=Wǵ7”|Ø$[û8÷Üsõ©7¢!~G4™ò_±îý8ï ó!Ÿþ¹½¾¿¢ÑæÎNoñ¡ŒûøPdo YWJGÁRÑú`×ÊK µ¤ËùCïõ=¬Ç›Y¨•OK{c5V™€»µ0¥VfÕ§ ÜJ´N‰¥–dÄZ–§Æ¼ÔÕ©1ehg[²käZ4>Ñ%ce'ô燷¿Pëe sHƒÑ™fÈËÉ*%ÈiÉÏÁ j„ÃŽn·N4 ‚¬ZSeÏ96X_±…{ëpK¬-û¤ªtÙR…_ÅFÐJé_ýnÚ,Ÿ0àc¶2Î'|+³‹.·EVÔ²x\\ƘçßßÑ· ]üÝyfÐË ÎÙ7ç#<Þ xñ/v>¯ÝÞ}.dÃþÙƒ4›þaû]«õûT¦§Cý#'„Ÿ3e6B«Õ j#É.dÞP)5@Zd@«G©w$´“¢ÜQ!´–åÙâò͉1'Cë 8>ÞûçèäEüz æ B5ɧÓN¼äj‰¥E8…ð€þRžØæÁHvàò(Zb¢°`©MæÜª]K"+±"Bb ·žK*Ÿ’Õ—p?O¶Jkö`ö9Fî)㥠Ñs,8¶”´” Nê1Q„VhúéÕ+*´ðžÀÉÚ"`ßÜ'd@Ѻܙ ­®ØÎÕÌlôNø:ºŠ”Ü(ǦÂY‹¢VFæ4²gN *ºÐÖ>’·ƒÁ%ÿB÷(Š®ޤ_›¦_•¨]ˆT=f)Ñ1O ù¥ôßwBqßéÄ"Ëó¼ë€Oˆüή5˜¨ pK0ú¿ ôb…d~‘ ‰B{KkŠTôNYrúÝHÚZ÷HÂÙÜ•XÚѵˆ<‰Š]‰BR¥´<âGŒ’sLM¸Ø§ehUH«À"µHMd<éšgD> ëëû[]åÐVHƒñŒ?–Ùh”nè ¼,­lÔ×5·Š2èä û!9ÙÏ (ÒùlƘÕKé5šÓƒJ‹ðO­°®`yëT`¢ïGNVlÌd–º[«¥n—Óoæµ0«V¬$¬–­,¥„£c(¡Žd+¶ ï‹V‡Ú+ ¤5{¯±¹µ‘i•jfbq<ùå…& Ûì &÷ÛÕ1Yÿ‹“Òéë— …ž=s.Ê·ìP§‰ŠZ„:‰ÈI\O©“¸b:¤Ÿm›9¶ß‚x¥Ãƒ›ôᮜÆuÆ/À³ý›_§ùdŒFó‡C^º›÷þèý ÎCzendstream endobj 5068 0 obj<>/XObject<<>>>>/Annots 1842 0 R>>endobj 5069 0 obj<>stream xÕXÙnÛF}÷W\ £MR%µO­·yjZ»È‹€`D%¦$‡åb[-úï=w†äŒ¤¤âMÅG‡s·¹ýËE@>þ4‹ø_\\øžoø#࿽˜EžOÑ"òfTÐ2ò¢ätwáÀ‚‚`îéb°³9$9|ÔÅ`WóQ‹2œóþÚ {¤:ìbî-\ÖÁ`£¹·rYƒ]μµË:ìzÁ&k+¬Q³Ð„ ´Qf£|Ž…eÌj}lYBLÙ¥ŽEÈGpÔø®‘‹ ×Þ’"Ë:˜ÕÎÙÛ‘5‚ý•ëFŽ?;_ñQË:‚£{kYÃ?`£FV«]¬MBþa4Èøc1#ö —u0ØÕF9g µaˆ¬±¬Q‹<3a ¼9-42j-fµ¨—u0X$Û³fo9¥,kÔâ“Õ"¡ÀiÀZ±>8’.f“8 ìQƒ]ÍØ{ÖÁ&¡Å‘Õ½ˆLBE!.Ç6ÉëGÈDKºl8;f v¹8l”"m8Ñšã VjaA+­säÈœ#éb°¸¦ÀeÌéÌÏ"(Ì2ù`‘É‹Y0g°y–Ys4RI?ª‘st`¸:²æ(*ÜhøÚ42G-6î 4FÖõ‡> SI#sÔbEîãâ,ë`° .W‡u0ØõÆYV«¯ú.á³³YgGv¶‚?.ËFqËò¹ui5鳫SÖalŠ#IKâ³_ß;“J«zG×·PÆÆß§jÑ ™Ò}¢Ç™O÷ñ$é¦kZUd¿Š6S%ÝJÑvµl.ïß;òôäÓòæPÉÒ0§á›/"È›¼zŠe¥ÏïE™äY¹£Ç¬ÝÓK9,Ï@!žÿnxjäÊJº¡X%òXµu%Xõº§¾œÁ!HÚ„ ŸŽOœkžïuÌÖ\•»÷Eµ™l.å}r Fïo>ÿœlžYë‰ß²n(U5=ˆ:ÛüôÆ?¹ÓßÈ4+91’,Me-ËÖºN:k`Ñ3‡à®’q&r볎Àq’jÇí‡NúO”y?5ìÿý^ÒÝÛ×ß:îçÙ¶õáßy?Í<I«¹)‡hù—å°D¯›®uá~¿}/ã–Ôc‰èﳊP˜ô²”JmËê ñïj6-`h4Zc‹˜¼LMëA‚Ô°){ÐÀöŒþ‰¶­³m×>{Æ Ó\ìž;3or‰:DvôAxn}½oŽ~"SÑå-‰z×(ÌÿH9 @Uþ/û}ŸöÑqò]ßjò~>5eñº¤B”ŠE#›+ÊZÊJd“ÕÜú¨U£íðqÇc-ªŠïD¥T‰ºÍâ.5èÿéi©‡–(1ºZY§"–Ý¢¥ö~]ÑAuTd»}«ëh~½*«Z=d‰¤½R?›^‹6Þ³ÆãÁpE"IH4„ª„P2ž†ò†Å±é]™È:?°ž¤´“¨kѪÚCÛË𲂩Gæ 1 J6Ô¨B²³ÔHŠö‚VÆû2û¥“ |ÌꦅQ¨ÔO5¼7àØ8ÉL;g# ²Â2œ’ › K>V¨Ú\úcf>­ººRgª ¨eÖôs‰F…@Ћ¡L^ô©=HÞ¢ÞûŒO®tÔuS’eœ£ÊÞø±÷Äè<¸§¬äö†oÍøÏÜUMWCbOsù sÒ-YÖ”v¥NH4#.K]Î^ÇNÙ2E˜•ÃÉb›CV®P“è`ã÷ñ#ë“[:§ú>20'ÔtU¥´W¼W!áªe•ÃçÄ4NEÔVãUÅ­š{)ÜÞJÄ~^àÉÍD פߞï1ÎòüŠ ‰dåh>(T Ç;„#¾˜²½Í¥G_•§}á¬e!¾‰å aW¶YÞÏIùTåYœµ¸’Dæ²oå|eÆï!¼ Gq{ N¯¹ï}|N 1Lë ´ÓgK5VòéÓºk—Û˜rGòïÖì—HóëkúF;ÄkÐ'ÕC¦ºFûÉm:ÞKŒöÅðúyÜunTQ!ìÛ,ÏÚ•ª•½ Ö·7½dzÀ– BÂ¥æ ã:c«ïY,L$NÃÀ/pcŒÆ±ËE!Zg^”„«H™L§§1¥ªê÷ ¬\p›Â†‚¿"¬ä\JM·mZl8xÏB yÔSšË§ {V?ž‡×xLKom6´?ýEÄ¿u›…æ=¿;eÓ^Ý_üpñôã&jendstream endobj 5070 0 obj<>/XObject<<>>>>>>endobj 5071 0 obj<>stream xViÛ6ýî_1M[T^ز$¯7=€&Y7)‚¢E]ôC],hjl1‘H‡”|$Èï´ä•Mö0$kf8Ç{óô¾CD¿1 Çöç³NFôeó¡W0˜~q³%ÙŽ'˜¥îy3ÄI‡1¼b2Í…\î8®K¡¤!áp•bwö¶3˜ÞBL6F?¹ o)Jð2f@*X*]°üèLßâÈéZ˜Œ‚2CÀèßà5y°õZ+Æ34ô•PˆUV¡2˜†ð y¸µO¸* %m*”€­& JŠ-Åû A»#Šu¾§Ø%00käÂæ¤µÒ®Œ¦t…;FVøÌÁ$Úª[V‡t—ƒ˜ŠáÙ¡¤ÃÍàp6Y’…)Y)8PqÒq_ 1l…ÿ&£ñ?Ôy>´²<˜ZçÊÀOÕ†>èF‰”ú Õö¾™Ã>/XObject<<>>>>>>endobj 5073 0 obj<>stream xíVKoÛF¾ëW œ•kŇ-? _’ØM©ÑVE‚@±&‡ÒÆË]w¹´¤þï™åjeÑ•ì¹äPJЃ;ïù¾þÓ‹!¢W 騽óª÷zÒ‹XD7×f £ËNX “’Ƨ1aR´RLò>.,«Û¿¯›p‘ã­Z¹%šŸ“½†1 AX(»!X[n›:’|Q`)‚5K%dýŒtƒe¯çP£%¿›GÞi6Èp~Q6è¸VsnóYÖ¿ã’äPÖè}üÛÃ9´2[Ø™Ñó`Dj5ÝÊÁn” —rÙ°òà“½„‹,äºÀ^Ž:!‘߸šâ…1Ú€»â­¾w¢¦Ž¼^þ…FC²U誱Wå¬4œ®Ô .Áõ­„!6LÓUóû¿èùÌ… ÞÀ­ÑSëXêr® Ð`g¥–RÏ…šÂ™·· ¦a’°4%hýB7×’š î²ð{Aù܉ԅå®îØ my1‹F‹€3/¾µ«>u« º÷Oæ{é;uVCn[¤´ÿóýÏ(†W…DCu1‚ÎÿKúûÝD_•˦@Øó€d³½N!öÛ`©!-ûkØî(˜ãP×C¨Oøþ玲/áìžÚ²åk;[tr£ùMÖßkU ÅçÞãŠÙµýÇ z&æà#¨Áõ>¾Ÿw´õ¯Î„t@—PµyÂEàôÓõ±ÿ¡n”ž«í¶ÜéÍ6´&ì´x“™¨AT·+T4a©¿@w´¢‰CóU…󲩭q˜v˜¢BÃ%ˆ9ƒ‰†Šß3-̵¹k´4í[žÿ(%(ô6*]ˆ’ÌZgÐ!Ä›8~+¬-Iº{n¡ø™Ò'\ú;aÊô¡À\rŠ…‚­™?<…˜l”´«†ÉØ‹ÓFzçøæFË›W¯ Xw-:¥CvèÔvÈ»špYkp5Ó™-µ™sS0¸¤¡Š î*øôôúŸ€ízù>¸VŒ±¯æö7²ðd…çøä¥G0Ÿ°c¿×ÜŠ¦,‚·:oÖ4t¥Ùí¥‡Ç~eµ¨N6ö~K#‡o·gaý|áŸhŽ¢1Kâ;‰Úe}1éýÚûâཉendstream endobj 5074 0 obj<>/XObject<<>>>>/Annots 1845 0 R>>endobj 5075 0 obj<>stream xµWÛnÛ8}ÏW Š ê¶¶|w.}ê-mQtƒm³»À"/”DÙl%Ò¥¤¸FÑß3¤)[Nœ¶ l8’I‡gΜ~9Ò¿CÏø/)ŽÑßðÇ?>¼>šÌ&Ñ”N'ш šN¢Sÿ’ÓGžM'#72ižy`û†5³èÌÏâ‘í[Ag'XêÖóÈó«Ý vNý‹ t•ÁÍÙRç’ÎÕB’üšÈe¥Œ¦j½”%i)Sª Å’R™äÂâU”„§²Ä°ÌK¹ZH+»´4e©â|MJ“ …©´”©\Òù£«OGý‹FcÞy4 ÞhÇxK;Î}z._Yk,}ûþ”`;&¼T7ª„_Ï×ÿHkLº¬«Ëì½,Œ]‡ý‹3ŽxÛžÛwÍf'lv8Š†Ñ„^5^æÒ–”Á‰a•ˆsYzß· õF¬Âúçk ’‰:¯Häùv­^Õ\+)œÜCÞ9nàm›ít©4¤*R€4ËdR© («Újn²Ì9µ·Ë%üèjuxÉB‚`Ís‹<€ˆÃ§æ<]*d#4Í7„sSY‰J%·ÆØ¶dÓÖˆdÁî%ÒVBi8'(7s•ˆœŒ–hZ±KJÏwŒƒ /¢–+oÌJÞHÛe¢¼xòÿݹ¿Ôª’EÒŸWïòÑ‘°ZX³ÂF &VßÂ1Ø·XòÞ`&З)|7$uYÿ|˜s.«K àTÎgN 7rãaˆ”~ˆ…ìû¶}Äg„Û£eRÀŠŒèw ª…¨ÚëçŽï·ß?Õ%XI…H*Lç¶¥Îñf¯ë΃[®íùÔunÚ$¼$Ä=@­õ=Ók6ѸÚDŽŠÉºÙŸDUW°ÖªªësÐi†ÿN _—âºBÆPbj[B— sUel DÀÞ¢ FãëÁälyÙædqΔÞË\$ˆÞÕ <­Œý\R®>#ãôš {¼EŠ“Ô´ÀM„f]vDõ)“"ØðRæ^Eš)]”á=R=¥½Ÿ~ß©àÜÈKÞDÚ©ôÞzzÇâüüýú/aÙØÎzöOP¹”‰Ê 9#›³A¥¡WÇÚì0“ëQÛ`c.HãA{¾ˆÜ²·wÀ]{KÏ“ûÊÇ”^ÊLiÎ÷TA·­ÔÕŽd…Šâ Ý[C8Ón ÆA²§Ên›XÈd\hf#Ï\)ƒMá´ÕQÄÁŽÒäDš™UkÔ£9%1-3¬NȈþÔ(|®ò5ÉÁ\ôÙC+™ç=”>Å¥éºãª‡*–¹¼~DÒUp·=ƒRÈϪ,Xë]~t¹hzĸjÔ…Ζ¨!·/ÄÚÑ[¯”ÌÓ†mNŸyS+K.¾°Ìk!ú7IŸJŠsƒó@…/! ä> —s[iŽä’¶F¨U#WäQA2õ±®M Ùs9‡Cî䘈 DgøxÎ/KW͈.Ên¹…›NÀx\)…5µNÛ:`j70\* ¼ø¥¢ $šü*86÷÷`[é£oÁ´Kà QñÑØ\èªj-ùÞzë?ö)‚Ð/ š4 ñRWÖ·ÆKôøqck£ Íæ¡Aôßo÷ÐF÷î“ý°º½“ßdÛû6qÚÄ÷é%²M¡ %FWÖ ái·Þútc¾oØabn‘1º$Wáxðî 5[áò ¶ƒ†´(|šŽö¿L–ÐòpGT+n‘ƒñV¬Nn}w]+B3¶‘B×ßr»ö"p·Y´"â3ôèÌPt¡èÒÑr„Xn­¶äÞ†ç-s‰®õ¬¡ IİˡÝfck\rö¦•a´l:ê•©ó’‘ä5« êñ¦ô¹ŽÙ·Ñ%žFQ}ÀfK*kט»‡gsþÑu ˆ1Ÿ§„²5™/^,âûVPu0ÇŠL:["b é qÅ@!ÅŸóº}3Åݰó¬ˆÕmx[k¡³&¯ÝR/»Ø |nÛ÷ËNKuÐ6fNWBWðjæ ÇÝɰ׸›¡—ÝBÍ´š¯³ËøŽ}~þ?dBÿâtÈ!nóÓñ”f§gÑÐßj?þýöuoŒëüK“ÔÚ—ÖŒôÅÏîxÊ»‹è˜ÞpÍfÀhKbW…§ƒY4áÆŽÆ«ÙÊ««£?Žþ%Tendstream endobj 5076 0 obj<>/XObject<<>>>>>>endobj 5077 0 obj<>stream xÝVMoÛF½ëW Ô‹¢$Kþè©uâÖ‡"h" ]VäRÜdÉew—’…"ÿ½o–¢$ÖrО Ô6l‹Ü7oÞ̽1ÅøÓtÎ?IÑûyÑ‹£¿ìšF1ÝFSZd4‰i~7ŽæóZ¤áTL‹d@øJ„OrZ~“…±»÷Ö»¼¤?/_z1 Ç8—†sá¬5âërÐÿP{2áJyùã‹Óß:O§Ñã5±¹Œ†g8™îÃ|ÎeI‚-œ£ÊÊL=“räêªÒJ¦WäsIò9‘•W¦¤\”©––ˆæyÎ$ÆZé*S¦ª\S*aÑŠpG•ါd¢2ØÜ;޶Rk® wÂéfÖSYz•­wTŠW²ºLØXp+…e°›J«6­Eé"¶ÄÈ7©r¢×lóâ@s Åb€”$7€`%©v°„l*UVF•°D9ÙIgˈ™´Úˆ+°à«="tù,ŠJËû6’#†“I4‚§ñЇÕ™øû{äjÀ¹ÀóYx»{…oDÀ¦…ñÀšoôâÑO¸Ÿ¼IÎõ;Å1ê{z$§X»À3Z“ÒVìø˜•iHJL*i… øˆž|(£ÐÎpW#«u{C‡'ÞZPÝN=WÂzǽ%(—Ü¢LiùoêZ˜´ÖÜ/­£P‹nWÿ ÊD×H¢ïL!wQÞï^i- ÖŒFôýYrŠ™Ü3j»Ò7ÏY »vÈÿoéÇ­ßÀþ2×µôÊËâL3½Úb¯vX×SEÿ(ʵü® '{=*SùL¦QuË×þ©¨FDå;|S>‚Àà‰ÛS.w½x‚£ÇÙùqñ`Š ª¾RZyh³ñ­Ò%uÁ~Ž:üýMÖCÃÑØ•‰„à~+÷"¸©¬Ù`$¤´‚àm*Y—!–)õ›òöÉï*Yˆ*"¸o³l¼yA[Sk ™=霠<Ð Ÿ[³-y¢°}/,8Bµ¨Å:#x2`úñK+}mñ/Ì6RÑÆJÐhVé%jfɪŒÀØN0C•+B¯¶£†åðlßFô«Ùb@Ù+RžJþ„Á¸5ö+;É…ßRøçKhÃqâÑbÕ´EÝc%½—v?8ïh Ì2¬7ÃÉœ%g<‰°¸Ð'ÝBÓƒW¬4ŠÄBsôÑ”»¥ß¾ŽÂàE1NŽ„Âû…aµm¤,äÞq°Í¢VR En4ô¸ñ´ßÕ+‡6®y)EGH\[FÒsŒ¸Ülf‰Pšß7xw|rSéq« ÃÊh¾ ƒÚ³W>è£Ùô™ÏÂ_`w¢7˜üwsÀŠÇ æu Ϧ’¶Y‘0…ÀB|®¼î,Àe¿ò`¸i}âøcP•ÞõÕ¡°‡ÆqW$}-/9óáÞåp<‹â›PË7¼Iñ»¿Gó0zxû–Ü®XÖ­P]ν !$xÎ$.½fõÔ^ج¸-l¨‹>þôùé—†6·{¥OcPm~;â»1#ÅG†Ó(¦w&© l„!íÝ$¾Ì3Þ4;ràé¬Ì€Te™´¸rfH²Y<¦“¦ “xÆÞ/z¿÷þTðšendstream endobj 5078 0 obj<>/XObject<<>>>>>>endobj 5079 0 obj<>stream xµWÛnÛF}÷W  “ˆºÙ’í}ˆcZ¤mÔ(+r%mJréÝ¥eµÈ¿÷Ìò¢»Û¨lH9;×3sF'}êá¯OÃÿÇÙÉ»ÉI/ìáfûfæÔ½¿ ~&3ꇗÃ+] ‹р&‰—Ó88ÓOÒä"“ç“Ï'ãA8¼ÑÁd!I>;#(ùFJjÇS¸\Š9Ü,d¬f*¦Ê¤©Ž‚Ò–"MW$è–fe;¥óê™|.´qcftV…ºßõô³Œ]7IÓè|íÓþ¯}Jdœn$²õgV²±GØ„3ÐuÛ½}ó†XZámë*3u¦’³U§‰– -wÆHW”`UøŠJ ûQyœ– »Æø®È\4ZW©zJH‚EÕIQ„ˆ|{P{–Öùmå»Ò,3á„™KG-þ«Éax=¼„É¡o ]T"¥'a”˜¦ÒÂ$=s2o{Ä*WúÊZZ.$ו»J>Õó¹ôm"bt,*^pØTùo¡\ÊÄrÚ†áó¾§,•7™Êõ¤€ ¥y,•‘’oßÒ´ÆŽ|Y‘JŠu"i*S½$»ÐK¸“¦Þ`¡­UÖµè œ.ÒÒÄPÜeÁxÝò$“Ör³ÅºL(&'Tª¹gà[ðÊñuDÀ¿aMÝû]…CžTÄ7Àâ[¼j Ò'îd‘ÞÜXÍZ8ò¿/|Ÿ!#QpZ£á†Îê«Óèü›ƒ’ÍèƒhsyT¶™6m.Êrxã£2M“B®¹< ëÌj/J¢3f£uô_h'ÈX8* ~™6«;c´A_í&ðŠ u`/óxÒ‹áË–©íoOZ%U)bàÇQŒñI¯kŒì–Â:SÆ®)îžs^W[ð(ØÔïê"ÚW¹#µ+öŃa͹a8rï6ú‚§ÜºüHâ[}DU·èíqJÈã­×Õý†‰ƒ–‰ª^°^ë Ï—;aÝu?<´vÀ§jˆÛ7ôððé·ï><ôŽŠ6І(_>ìùG ö÷›µcT|u¡é†›ªš_¥épÛDÈ w¾ms»~Ad°‹¢¯î­£õUqùFëÞ_¯L3 J–— rûƒ°Žé˳qœr±×#›R55¬¶ñÈ.‹fqÚq;~Cµ},h´ÑL/ £Á< B[¼>yPÇF‚áK˾`(YH¼¡/[Õ–ÍJ—ŸNš™ˆ¥ i¢™JI¹·l¸%=«À`+*0¨@G§;nÚš§öü>Ý·æC€ÅvOï3úz+ܱá;¨Õùep=NÀÔƒ{S¿¢µ¾ûõŒh„Bd±Î2ìœ66 Œº™¥V¹ÏŒ N(¯¼ˆçÒ„t}»áò—§F·Kß7«ðÁäÓ+z*M“dÏ%‡ÒÈ4W-àm³ó>«îAÖq˜¾¸É «Í š®èO¨{Ù4øö㬢çÆn÷þªùÍvu¥ó¿ÚúaÿÚÿFâ(;ðGïu\òrç7L® FA%Ý3ÿ$£–X׫*ÿX[¯U|ö²7 ‡ƒj-ôF|ënròÓÉß•Xdöendstream endobj 5080 0 obj<>/XObject<<>>>>>>endobj 5081 0 obj<>stream xWÛnÛF}÷W „ ‰ÖÅ–}ÈÍ­Z£‰Ò…€bEŽ$ÆË]v¹”¬ù÷žYŠºYJƒ8†c‘»s;gÎŒÿ>ëRÿºÔÈwœ½u¢n~¸]Þuhõi4¥^‡/ºÑ`pC£$œêÐ(nÒúëçûŸÿ⧘sŸZ3n†Ï¿rfÝêsÖµ¨ñPz²SÊÂÃÆøüåùèóY‡Ú]J‚¡/+ÏÇÍ(ŠÆçôï³â쨧÷¥ñiÆ•«ÆGóhìÒÐ&žãÞöÌ‘O—wW$áL©|Ûýþ:ßæ«‚”›•_´¨:Šò…£U®_ãæø|ßV“¼zdX@DR ò«œ)¶ Ó¸‰‡©ñ2ùyZ|ÜwÖÒÅD+ÈÉ1- ¯§ô!Cø´rê™"9ö¥34ÝqL*¶ÞOieKZ:•#JÞÆ}€kÚ~a›­ p4WKÈ]ÁŠòÁÔ:œ…0Y ª$xhÒڢμªbD¢Wä¸(µo­¯Êï(¾¸Ñ­äâÉ3 ì2›”šÑJÐIÊ𭥚4«G(•èxLØ-€ë‡ XËTkD‚Þ¤„5{®Á¤Òhˆ¥žD šÛ˜W©Ù‹ã ÃM"´”2„cÇ’áø<9ðOÈ7²4MŸb ]–ºK ƒ*¤ôÉ;EsH,y*twÆ`¹ò§,„‘Ô>§¨ß¤$uèd¿GÖ¯³qkø}BíQ5¼ÚöD[vmíð†–Ö=Ò9±Œ‡Ð$‡A„TƇÂÓ›ivp8¢{CÕrâ/Ù©¹ò^Åsu޵ì˜ôh‰pDÌlX—+‡0<»ô 0N‹ €{Â`Éw–öö¶îª—õb²óÿå%=iÑ%Ìc:Óv¢t€¤1̾m™×ºX[‘Z‰-¡s Ø®mV~wߊ VšzÊòÅímlóÕ±PÅî¼C ýÜ!G“WuåbÏ v%ù|r¤|š³y†ï YoJËfú$-l0I™Y){H%EÕîÊ9<‡£©°Üìk¹tÓ®VÉî"r™‚àm@¡JÎ`SK•ÞfàBŒ³+š)7çvlµFÇ,KIƒ5¨£¶ÁI¡1í"úÅ.E„Dðð>áœM‚ŽÀfèÖ r˜Ç"Ç~›V°½pò ’†j<·¶§3Š~§h*Ø «1 G!*<7À–Œû@´9Ç)H,[%&}µ(6€ðÔ17êÇAë½>0XÖSãÈ©ÀÛ+K@ íjoC-Tª:A*[ñ´Røå<…|s2ê& \«¾” „—9#[*V„c™v™¯7âõ|«6›¸ì¬ÿ£Èëz›ëRaKˆçÊÑ5¤rãæ]ôxc­ÇÃõ>Ö^E×ýk ¯£Aw³F·ûQ‡ÞÚ8ü‰ÄLò‡xW§Û7Õ_9Ø´ºÑ } Cg6†¡ºQ[ÈöÄ)·’»×AÔïaMÔëunäÑ»ÑÙïgÿ¸Å+þendstream endobj 5082 0 obj<>/XObject<<>>>>/Annots 1847 0 R>>endobj 5083 0 obj<>stream x¥WÛnÛF}÷W ŒQ‰‘([–§\ê$/M[ È‹‚"—Ò&ä.»»´¬é·÷Ì.)‘t £¨lHâ^fgΜ9³úódFSüÍh¾àÿ´<™FSŒðÛŒß~2_L£˜æñe4¥’æËÃSA7'Ýç’ÎfÑe³–g»Ï˜=a#Xò³gÌ.ãhÙ™}³ê8ã=2zy=¥e4§UNñ”—³h±¸ Uæ]žÒ*EQôlõådJ“ž³Ñ%vzýE¤Ž¬3Y]½êM—§ÛÄÐó°òv”je5c·ÏüÖ—×gĦsšÀ…Iöp©€Á†JQj³oóŸ±_¯C8¼©Ê‘Óˆ‹Çì \SntI7Ÿ?¾SçQ¼Ó^×_Qm91 ÷I&ŠÀ„-ʤ?äp¿Ö†šXÆ$sos›Ü Þœò˜º¦R¸­Î옴ÂišR#'(€ØTÖÎd@ë=»Töœ¼jƒ=2zÇÑ|~÷ˆlÿ‘kÝ'ï1"jy¸fHðk­éùÑàí¨¡õ¡`î´ÌºænG~ ¬蜚r Þ„(±ÄyH À×WWM$m¤¨1€‘‰µÿ2¬üA›ì&à!Ø'©C!¹ž;Ia5¢©„Ê,ªÄ1pŸ‡YJ¼8°P2XO3iõN=µ ÉJÚ’*£+aЏ¬°˜½†ò†D´ùê´ƒBѲ_R9±1%£t[HYœYS]+Ǿpq¢Tßa_C>Ä~ûDǽ}ñbh{èïi»Üˆ,ë‘V^2_^Ÿ7ŠÍíÆ‹ç[]V‰“kYH·ç´ú[Óˆ~5âNêÚ|´0 óÀ½m’qÿ©D*Ñ<~€Ï™Ž<~Ð;ƒcªU!¿>”ØC³Ø` ¥è IUÒSÜÇ~TdL‰{Z Ö?GßUãGD·}ÚwùÿØ»Yö•Þy}ðìw\s¶®*m˜ ëÚñ08‹NÁÜø·Ì .j ÉXQä-C ¡®‰ã¨ ÌÕ$á‘NÅÞørîF¥Îd.¡½>9\2eÿëƒôt;à;­žöËug$$"Õ™híÊÇ4½Çƒƒ2ÿË£®S–J¹Ù:=DqÇJÊ_܃ѮÉË%ÍÎ"”JŽÛí$^ò×l4Co¥k´é–Z ¥'y9bÐÇ]´\²…7‚0„Sܧ¢b¾ö÷ü ÃÅ=`ºõšÑ^<|©¢BÚi#”0(Óª6•†¢¥µuº”ùéèàW°½×ÒiŽNùlÆÞ·€×ÔÆÄoi ‹¤™d"Ç=rÛ[PSHŠïOXˆn‘¤[_®A1r™vgQ£@áîa}m[Ñ"иÑëàfGk:W±GŠ¿1y;: ¹8EËÿäïüWW‡׿8^Îì× å×OèZMBÙ3ÕàñïMò— Ï–gÑùüœKü ˜ùkßH'süÎy§SßÓ}¦8ZÜÂêÉE°>ÆŸ„ìA§·²ò¬é_{ϧ‹hƒÉ``<]²­ŸW'¿üìüendstream endobj 5084 0 obj<>/XObject<<>>>>/Annots 1850 0 R>>endobj 5085 0 obj<>stream xWÛnÛF}×W ÔU‹–([‰]ä!mì A ÐöÁ/+rimJr•åR¶`äß{f—WIqí:†rgçrfæÌðë`Jü›ÒlοQ6˜¼á?SþóÇûÁt~„t6Ç3eN^gÕSJŸÝgœžáj÷´óŒÓù<8ïžvž3šAsm‡5Oç!,†Áf§¯'8tî¬}„Úp ™æ¬óÈÓöì—E'@¥¹¥“« ½f´HÍÏ¡mþбƒaB‹hDø‰„Vt3º–™6ÛKc´¹yA/_O!;9'k´øçf4üTZÒ eîÊðæÅÏ{Òßzoê'¸mG‰¶4Šry7<N¡‚^^\Dz½uªN®N‰-'4Æ•q8«<}È)‘=&»’Ä&8F/9:’÷‘\[¥sP«‘Èã=aXÖË/2²»Â±2x«6² a$)ÒtK¹¶+•ß0’0.rÊDdtA*ßètÃG»îTQî迨ÅÚÌŒÃ0˜Í§xôC,•Kjc¡Z>@€Å:šä4wšºwZ„ûŽì»ž¹È$ÂB9p8¦L.m ‡bÄÙ`¾ÓJ¨´ÑÛl©nKe·À«ÐiÉYp° ­PçjoýëÃÆöð¿l+7yÈõCx|Öqf<š5ù&Ê€˜6Â(×â€ÞÊ\¢åy*íeòÁ×Q›|LU¦,w‹Oß y ^ÜÆŒ“¦Õ_x}®ôN®Î‰)Áb5ç̯S .¬!WM ÝZ–V:ºh­²üipÊ78¨g—›H Œ…ˆ§{A_ÿF…Ý2_6æj€ ž`w¤ÈTk·k™‰uA±æâe¶D€h‘ÎÕŒ[ñ©§5 þgâ21NrÐm•̇šùŠ'—5[¬>h†ÿ·Mß ßÖqýɇn9*¶ÙR§ß-5¯ìiJèÁÙü~Ñ?KÙ‘×öH=K]…ÇãqÝì`«R“Jl²<;ëij* Ç=é,Ã8—kžxŸªÂz†ú(6;]Œ]‡“ Õ”ð„ÁË:¼ìõk·™Ñ‡(Ç‹6[¨7Ø¿Å`¼íH¶›X|Ý1”®zÉùY_ø)vãXÐÚèû-ÖræÇŸøk'È!ÞØPã3Wr[ÚUÜÇ»Ýy½½¬×ê_ÙÞ®¯UKÔ®±ÒŽsÜËzûö}ªá8¸ ïƒÊ{?‡ôf¸ëÖ>¹b>Ôáº)¡úÌÜ|a†þ$â±éQqpð «Ó®gŽv‰¨2§¡ö«žåþ…ïÌ–=w6õ«ÒG"·B¥È®¯z½Ä#/ê‰Ñ™CÚE߬Üî«—Wu—Ö·;!?}é½½š¯«ý-œœg³3šãK×ñúç¿>¼ÏðüNGe†ùî&+…û^vüÊÇÇC£Ür¨]ÔEìvËàËg“y0 1p0:ÂÉ9¿º\ ~ü ±°ßendstream endobj 5086 0 obj<>/XObject<<>>>>/Annots 1853 0 R>>endobj 5087 0 obj<>stream xíX[oÛ6~÷¯80ÀÅò=ëS–-Å€aÃV{é -Ñ2 It)É©÷ë÷ŠÔű³xëãš"±Äsçw>úË ¤1~Bš.ø” ÆÁoøWÈ¿þø0˜†÷ÁœæóI° Œ¦óY0vO)}tŸ±ºZagu1V4Ÿ­j8S÷ĪÝçŒÂYȪVÖ®vž±º¼–ÕÖHm¸&¡»§{ '´Þ"¥ÅjEëØf2¦u4 'Á4˜Ð“ee$mS‘ïÖŸwO3 !Á:·“Y0ƒÖ°'EòU!c*5É\lRIÚP¬ ûQÐ^˜REU* mkóAßµ (ÒY¦sÚT%*ÛÃLUˆƶTG‚šÛH†ß9;ý‡$ò˜_!RN3–;dâ2:ˆ´’Tìt•Æ´‘$VÍ©åðÔd/§“0Æg„}Ú×W[a{QÈ Wåžâ)nrù4¼q¡æ"“7ŸÞQóïîÎÕµðÙ°EÎå¸haD7¡7ó¯-|ýÏÆ ®8צá-ÒˆR)LÏ@‹Ð[[Ùi°X,¹.QY‰4=Gª·_Û=/w"§¿¤Ñô¬ÒÔc¶»cô«.%A®$µÅ_éôUA:Se °­€h)ÓãÈ Är+ª´t‚‰ué:Èã¶Áå)ʬ#7Ç:•'ÖdÓ-~ß Ø H{©í‘ås]{Q!¥Eõ S¡ÿ‡\<–v–m|­œç‰a@k¤ìaë›NeYUrOŸÂ>VFF¥:Ø…&ÉX‘QDªr›ŽmŸ>mPÊAáo|«slØQ²£Kñ!GøÓùˆëñ¹*J”‰ºóœÆí’Eƒ5Q'IŒ˜<(0À ŽÍlÀžKb r*J#JÙÀ¯¦Éï½Ã³ýÝtñ…À´ß ˃®Gìþ:Lù8l·«¼D¥â÷Ìqt¶‰©æ”$ºUè˜b’êð ñ«6"OdG£”³Nñ¿£fg©õëRáø(ÓT?_tüætG–[·"¯ù Éø”y=ýÄH™Ÿ‚‹~UúmöNcšq!8D¼¨ÄgØ…N6þ"+¶ÌöO°³‘qwñqùuŸªH•èÎúŒý Z‡Œ÷h½>' *…IÀ‘1Å2Âù>×¹=–`¢}`‰R0š)Ð`ÿüùFÇ+ˆºÜÑ#H7–ý¶Å‡ rtÔ•íÙÚOÛHm´àCmÙ§v=ÿ"ÅËMŸ®Œ|6Ìì9‰âõŽöÓGPjl¡¶Gz÷š| ªžøÕ ^O¬ve‡¶ŠWuX«veK´ŠßÇ-pÄ~o´ˆvØVÐÈ@ä^z좮àé8.$ÆQpxL[£3+wŠ5ÖÞgŒ`Öõ›e'LãÉ×Úð¸Ã†©r«Rà”CLu¢"‡p>]@3»Fåi8>{¾ ßûè.“~M¾ö y³°ÃÇ›åíþö¤ÿGu÷X¾ÈÎí˜ KŠçæ™ÞIÓZŽ(Ó kGëõlbÙÑÑŒ”@·€osP2¸·8æ¥øZ#öåûvÊò[j±_O\áîîÉOºÃâY%Añœ°B'DúEmŒ0ÇNƒl5w-ϸ›¡{¹é΄à›Ze"Q9›¨M7]Ú|y:uê–ÞÆêlÀ 68Õå—Jáê A®à“wÜÝø›–Â1iï¿Í€èëUwc®;ZÖÇì= ^¿CÙËAÏË.ì= .ÎݱVîî®fÁ|:§År,ë,óçíßzü¨£*C©ì1Ï©cö¬¥o—5÷_ú–a>^Ó ¾bÀµmÚ{õOëÁŸùQendstream endobj 5088 0 obj<>/XObject<<>>>>>>endobj 5089 0 obj<>stream xÍWMoÛF½ëW Ü•‰Ö‡-;ΩMêÖ‡(¢¢]Vä’Úfµ«rIÉB‘ÿÞ7»üõa=%›Úy3óæÍðïÞ˜FøÓtÆÿãuïÇyoð°ùÈ3ºyº¥ñˆæ)ÎÎÞá—Ä_âþ|%)¶&–›‚lJ±–"W&£TŠ¢Ì¥#å(Q..“ ùRD×ó¿z7Oïh< &‡“LöÇ“hMéñ…p¼E0œÜF·|á‡Ú ¹BìáÉLSTšBiR;—/­bUè}'“ˆÚ›8à!ÛrO®Ülôžá n‘xÿMPM±å𨶒vªX‘±´º”=ٜώhÈq&}ù"Ö-/Ù]ô¯ŒXË«ÁÕÕâúÈ ®QV0h-…qT¬DAÂì›LÀKÌ¡®E¯| ør“Ë­²¥ÃóD¦Ê ØÚŒr€¯­ÉdN%— -P_ÖZÌK-]DŸ,©yj-ÕœùµÊVøÊ¤…©üŒ-$Nkœùˆæ¶ƒ'Ö`Sº–Åw(•5N%°Â¨B’šÉæàQæt"fÑ?ºô&ÜRÖ]\\?ÖG@JP‚JN@Ñ)þJú77ôѧ’2m—Bƒfì†h%L¢eS|n—†=¨r8ˆ"Ó?ìùáþùþÌSþæ[”µBÙ¹ñ…b®4"‹¢è¬M¾çV|†ï?Ìgcw†>¼}Û”÷'H¾tžÔ!ØO‚¦Ôæ$PÎ4gd±² hÊ´Ê|ÕÂ# Öº¡Þå}ÿøè--úgc»œ/¸‹#eR‹¸«ìôkË.ꈾS…©œ¬DU8¨¨änLĦ›d\¬ŠÖ”É‹†Oûe èºV¹–§^è°5Y‚† IùŸ`ÛÉ2ôý5f³{æØsP±´PVK°ÊIr™æµ„¹Æ$¬¸¦ÌÖ¢K|ÞÒÜ®½•B䲫…ÉJ‘A¯ç+Ì·‘±JU\'Å+÷©Âyš³E~€$¢_ìNneîA; ÉNGxœSJC/"dò´™}ž)¶ôªÖ ¦6” !x@ž1Ti)]ѨWÿäš§ Ÿ»¤T müTýÍÇ1W<{Â0>/XObject<<>>>>/Annots 1856 0 R>>endobj 5091 0 obj<>stream xµWkoâFýί¸J…äTÁ€ „¤Ê‡íƒÕ~kw‘ªJH«Áð¬lµ‡]õ¿÷Ü@ÛªI±=wæžû8çúÏVŸzøíS<⿤hõÂîðGŸ?>¾oÅã(¼¥Ñ ލ A¿›«œ>µŽ¯ñt8À*·–ŸÞ…Åß+h| CwÁ~œe¬–ÔôhÆ4]PÔ£Ñ]?nišZz4M‚ïR¹P¥¤v’KQÉm"WFé’Ú )̺’³àÊݼº¹ºš]_O¿´º“;êG¼g›v¢a³iÐÂ8ÐÄYÖ$Ê”°½Xç†Dµ\²4µÛa@}¿@¬:€3€KÁ§ß?¼'SÁ¸¦BšL§5m”Éη QS-W¢F’~”U®E*Ó½§Ò•ãž*Éd’øÔ'©@x‚‹ÞÖù08.á°„ô®Ü9H¨GÀÁH±S€@—F•K‡ÏÁÚ¨<'±Zå;2š.Øu¹5•¸ÓdÂÚR–’ƒQ“Z°EKç×FäBR½’‰Z¨C„š|‡ôÁnq)ê0+µyÖô†ván6P€(„I²—¬çr+C› €eå#£K€çºáƒ¾}H]!^¢XåòÞ§éPÿ£É:”÷ìšµJ)“y®g* ©‡Þ ¥z=Ï%¥(¬ùJaÒßJ Þ`÷ƒóÆ—½kœØ7Îqâ‘q½}TR> TÍÁFúUý2Î3×€f×Ö)t ò/-hžu'Ï ú×Eô2ßc/§íãÿ“°Ë…îŠ×÷¯É줼_÷z®ž ÷QÇÔg¥ò§þÇ´ÛÎ8=fÚD+ô{CF D+—¨–Ùi.™/×µLH%U‹…¬d™ðs³‘àÇb;^ŒÎ?“½sN|±ï.å<ð4ÉÆÌ½*ÜïÐ/ëÚ†6ú$"ŸžiÓÐ5ôð ‘U±Ÿ§Qs•+³c<ùF hŠ÷X  dâQéuEzá}ƒ¼íéÙJ Àñ·^› ¼¼¯ «J§ëÄò¹''+K,>„9Šiãù@+-’ŒuÆ¢ã¾"º|L’‰r)=x?°ˆ˜Bì0ô€gâSê;Rüw5eØtn3™éMIAr%+›tÆ$KÖuÔ-Ö·™ßgE7U+ö£Cr.ej™A[¹Ü*Np‚ìêBý…daÜ)$CSuáh5åIçÒ£•åIåÁ#•IÎ#Ì›AE¤©âK‘Ãw8 áã½Ùu†0ßù´&ÍP@9¹KI’—Ëšç ˜{c÷Õ©/…_w(xm­BúC¯©>cÏycˆúJn*((†í®[g"Õª™Ö©m‚…†n^Q™¶sä8á{Yi£cE9r.ªÏ*…„⫯7NZ|ƒiEÔíÒÇÆ/»Ná[­ Ì àÇ>n“)g}¤†VŒúþÞ‹ëöWŸ]{"ˆÂ9õ=óÒìÚæácU.ËYàžÓÃÅç‹x!BŠ©4Ã*0 šY$ áÁg€·Ç‰¯^²jû)Ä!wyÃAtŠn…ùE%çîò„ãcBÛCÜ4À.®Ø«êîéZëGw2n¸°?„Ã/5ã»°ïÆ-KBqØ£Ÿub_lgp 0 ¹Õ[wð›_"†½QGxƒ@ÍDýˆ7ûeÚú­õ½\ Âendstream endobj 5092 0 obj<>/XObject<<>>>>>>endobj 5093 0 obj<>stream xMMOÄ †ïüй˜ÔCY>¶U¯­ñhlâa¨lÚ²ò‘øó…Ö5† ™ ïóÎËáÀÊá ûZz!§‘0ÊÊðï †#p£-Úþ¡4f{/n†Ò'0˜”›#x ·ã™†b»!ÍE•rÀ}|uj G5!¸XШƒû@n…bÆë¼àšTr~ëÄ jg†Y­S®ÜâMž1ÒÝõþw™`GÚÉD Ù¼½¿<·’2xüoX‰ö*lïjJÓpA%í`Ø£~«å2o‘;ÖS)ÊÏ‹JpYé§‘¼’"‹Wœendstream endobj 5094 0 obj<>/XObject<<>>>>/Annots 1861 0 R>>endobj 5095 0 obj<>stream x­WaoÛ6ýž_q(PÔÅ’ÛÉÖ [±tý²a­~10Pmq‘D…¢bÃþûÞ‘’,%iQ m› ”È»wïîÞQ÷'!Mñ7¤Ù‚ÿ%ÅÉ4˜â ÿ ù×Ç÷'³E0¥Åå"˜QA—a°h9}:, ºšÞ –…³(½ÑùÜ].‚KZ¸,at6z7XÂh4 VƒƒÞ(<1Ò¥CêÎèqÉCìYô/‡kƺ ¢áÛÁº (\ŒÞz§ÑÔÓsÅvÝ‚þ²ðéH5;º¸½¢p‰}ë-¨_¬¢`Ñ:u¤OiL½ӥ5"±õéúï —gbN!ön9içÑe0¿\ÀÄdIz´g)UF&V=ȱ‘#ŽpÕZ9_"9°—N6ÑbIãýÏòîóAOŽÞD™R’‹º–O@W ¦¶¢´$v;#wÂ*]»~Ý=%™LîÆ1|W ¿kûÿb¼¸íÒv­‚+dnÎþL‰. ÄQç² › h¨¤}&KÚQUªÜÑ;ÊUlð oTí7ê-B•?¼ÅÈ\‰XåÊ>:büb« Ic´©âBÙ¢¾‡mæ ¤Ki!¬•¦7_ˆò~mgDQ—¤R[m”njg+~ý Rvã\ó GàŠt™?:¨g>šGÝyë yH2Q1g©¬£b ùôùÃû75ÕMUicM5ð®AAχÒQÀOäÁeƒžI·‰Á1Òƒ’{™’`LSZUŒ³†ý5$ Õœ>äQ )3"€ Ýi•Ýr-È‘gÄù`/RÔ dùcÈó®)$Ìõdš\Ög~í`ëÆ‚FzyƒõvD— mSB~Úþ,´‘}æjÖ¥lë‘À$c}P:X‘*AÌbe™†6T€MdåŒaóN–‘`7~gà SR&8•\Rm±Žð0¡ªl\}ȃL+]&Ït"Ë17¦kÊp‘[YO½Ì‡æÁjÅ­ü®Óm×&"E¹`7¾ º2tlÅ’åSÉ_H¸nrèõް Cb4²¾®„777dž€ÈK@¯va0çQ8»\D³ålzuvq9Ýznàü©…5.ç2ɸ+4Ô7m7+Ñ„K°Ýœ>Ø[9~õcmqKºyu†› Æ`&Júiäþ£Ÿî¿òUíºÿh'$êâμ„Ã9¦txóvú$@DÀ&‡£Í ë*˜zaÅx‹ãçÉåý؃>/XObject<<>>>>>>endobj 5097 0 obj<>stream x¥VÛnÛF}×W • ‰¦DYQT @[Ç®"nj~1¬È¥¸1Ée¸+ÉB‘ï™åE–,× ¹—¹3gø¥7"# ¦üå½_ÞïùXì~ª%^ø4ó û4}7ò¦Ó·Æî”OaÔ'¢…¨ègò: ?÷|ް÷¿6o¸†·7‘.l%"KZÏçø¹ë«Â’¸;¡öîUòËJUr¾·'â%Q&ŒaóËÕ"SÑ{|ÒÅpw²8|‡†¬Üþ€ß}uwN/&ÄÙ&4DšÃqÐT§¦’6b‹›´IU”gõ¬OïÊQ¯·Vú¤ ‰²Ì”ŒùQ> bÙ–,Ì‘KÆ=ZK¤°«J‹QÇȪµô(LWf@¢ØR„M…¥­^‘)e¤¸äûŒß˜Kt…š/„‘TWv£²ŒDf4-ˆµ"J¥ÕH2••²xÉ¥Mul<Ô¶âàó2«Ü§Ñp<ö‚¤Šûµé›Rä4§©o‡p¥$ïô”.¥5»Lc™¨áqJŽ~´îR›vMÛÿöª ÇÊ*]pê6U(«‘¥¨„E¡’÷(\™,qt¡mêÀ{TRQĨqŒê­ž«ÅwÔî §Ú¤è¡aìA<×XôðRgí1PóyëÉù¡í7·0m_òô½=|œ-Z¬;\¼#Psß:äÿ$£#ã“Pò®Š]`GâzV[nSYP®+ 6eºØñî‘| ×@Èš¬f×å,J‚^µtxúB$Àg“‘ήW¬^¢™eE+£Š%‰6B§ ™^ªHdÃ_>œ“.%¸û¡9@rÜÙè*vý÷Ô9÷ ËÙA ´=»×  l/˜|e,¥:‹]l[,ôZ¶úÃ…€”æR,žÐ¼®Eµ\å²€T ?Ùæ#…î0ª×w íÜAKm ÐÖúÀ;M¼ &ÔŒãþ(ÀèüMÆ žuËe%—®VPâ˜Þ´ ò¤4ºß÷Äf&ÞlÆvØ„Bp‡‘¬IJTæ8`„rùaYg™Þ0h‘Ž_ß×µ4ýý'+'8®#ºÝóëÛØßýëêò÷(8¾ûÇû lÒ¤Ù­{m­¦Pºëßè\^/>ƒƒôc-(ÍØÒEûÊå‹d3‚Ÿí‹k4 FÞ<ÔrµL-f0êpcL)C*h ×Ëàk„Õƒu”é|K9æŠ{¹¸ÇäÅh%e0®×t‰Üˆ"YòÔ[‹l%M§-®CBç“é6 ›Û«K*+½„ïIa0Ó5ZKÂCTé'T¸ëCTYÑJ÷†2…8˜Çî3æÙizȨæûűëS—âhˆ1£3 ‡`WßYó•2šM¼³àŒ¦3|׌ܸæT†çÓ¹Ž\ë863´ÑúôðmMpL»ÉÁ„w + ?ó§^0F¯€ÝãÑ/½{{ÿ-;$vendstream endobj 5098 0 obj<>/XObject<<>>>>>>endobj 5099 0 obj<>stream xåUßoÓ0~ï_q RÔfùÑu<1¶ŽI°ÁØK¥ÉK®©Gcg¶ÓµBüïÜ%iQ· xã¶JÛwþîî»Ïwú†ù—äøMn&‡ÝñÂ’)íÐ «×izÉLZ(Ðà|N¥B *'çÒ­`Z©ÔI­@OÁͦÚÝä¶³;`äÇì2  E~Ó[æIå aúí:“kÛI=¹œtß4–k,ýÚ2ö‡Ã}¶Lf¢5µõQÂäUän NƒE9é€àj…k@ 1¯ñ\Z‡™u4À§BÁ Be1© ÕÊ‘:ëÃXÀ¥(Ê9¾þm\/EžÌ…Ãë:¼:¨ÞÃP{ðåSŽÎ¯Îzpqzò>éÁ‡ãq҆Ήâä{/× Ð œx—ºÀó›[J¼êB›äñë¤ ßÙs3Ïà]EÙ­o&?R¿qô CããGë±Aô¼)=þÚO¸uÞf•#£õèéÕ:b€øéUNÙ¶Î]h™ý]8'Ö •⟈ôvîÐ(áä‚8Mù#Vm×ß­J,DI)‹¥ATNÄ›îÅŠE§DÂVr.LÓ]ªª°ÐÈÅŠ†´EdºŠ\’ ¢°è3ÝwÇüA£ÀýhÄÃÌ cú?Óm³i-Œ¬4â=ïZ­[•¥6Ž Y¬W¬¤g7+¸Ô*_Å'^"s4Tü1ª¼f÷Të@”% Óˆó ú±-¶Q{7DÁÀß‹÷`0ý¨>¼Þûé´ÖbJŽV –„¬ÙÜßoä„b‰Àr‹Ò­XòÍÁMöP=ÙÅ^0ôãˆn$Š2 ‡w~×þ endstream endobj 5100 0 obj<>/XObject<<>>>>/Annots 1871 0 R>>endobj 5101 0 obj<>stream xµXkoÛ6ýž_q`€Û:Šåg²aÒGºYÛ¥ÞŠ F¢l®’¨’T\ûñ;—”d9m—mhÐ"-MÞ÷9‡t>Ä4Ÿ˜&sþ›£h„OøGÌ?®^LæÑˆæ³y4¡‚NfÑ´Yäô¶Ù›NýÞ,Žæ4÷ Þë-a·ˆN{{Áçdìíæ>€_°]oYЩ·ëözË‚âɈ“é6ƒÓñÈ;]Ì9¿`§½% ÇÞk·Ù_cw6ŽâžiÝÓ1ílCÐÑI¨d-hݘrBÝ^oÉ ù¶v›Þéì4´|Î^¢sÚîÅ#®d·Ù_³Û“hÜßí­¹ÎÑžãyñœÑ¯Íü¢i_»D%ó褷×[Âi¼oœ. gSvêì´·„ÓÒí»y3ËSÞó ¶{ºì¡ÔCÕ¬èøü”âr_fôüd-Æ´L=”G´Lñ”~F‰›\Ò¥,WnMgfU²töÑòÏžK|ïrJ1l3¦Æh6‡ËÁEéŒNëÄ)]î[î’‰OÓ£À'éàz<_ÐþùÏ#ñ飘3,×’Þ|‹}«oå¹ÌD;ºF˜•%[W•6î#¶]'#«\$’'@µU劾k²xÀèÀ€¯S”)¹m% QÝÿ7moncDUq‰àåê&ËÔVù® §3Lö}®ìCNôÙ“'tam-²“Ï•Mjkÿ'çŽÏg-!!‚§ óÔsr ¢‘Ò!³m­Ñ&¢Þÿ¯ñ˜ŽÏ[)µ¦Ëµ²”¬E夡TÚĨiÉÁOXKh~7÷¬.½`ð áȉ’³.(RY7ð  3ˆRDçÚ*­e"‡´’¥4ÂD8­LøÒXÊpš£?ó"s|Ž܋נ2ªtÙõàn)ÊD¡ò-GíÒ‹ç¡?¾H§+•ªµ5P›(ðF"½å¼À"M…4Ê‘r–ô¦l›ÑE‰‰¶¢âSl(ÎþD‰ÐN–P‚ƒ³L Wš´¨J™»mÁ"MqP•ôöÝÅË£8šDñ8¢_´u¤Q¿ =Ç¿mÃt‰uni-n%h%ÒOÖÚ"2’·Z¡ §bûøëdŠ›Þ_'GÀŒÇK<…>ßÕÿ;àˆNNZouÁ³`a~+# K…Ø"ù$¯S¹ëz¨W$‰¬Ü¿‚…ü$Š** ®»qŽ1v­B'ýŒ•@[Xyº9SftÑàrQÜbLÉšÐsFQ¦ó\o¶ïþGÄOtcÌ À}>Á*Yˆð•h`•§oèqV`ìQÌÁ„±Žgíùó‹ËôxH_¶û¡Eygh[ÃÂþ£ån(G>ãI4Çõ‹Îr·ÖõjÍU¢=˜:ÓÏ‚-dÙ9¼*ЪDäTÕ¦Ll‘a†Ol%2`Âm÷v­ÅqA,³•rQ®j±’t=Ø€ûm]þ’ßè:Oé†ÀüéúÑæ­×>\Z‚Y ¨g!d¹ |#,¨¼#¼µ1‰³7AHÄÜ?Nr¨_v½þâPýp¾ÚbðÞÓ)A:CÚêÚƒ~#€ðͳÐ2;>(ƒ%¸· z‹H D‰mßö%é©„ÐÉVq¹¿Ü:ÖRL ~N@%u9„ ñxñ)4Mð4Ü"Þ&ÑE^Õ²,ZaòúÌI „ÉÕV §÷¦&ËD×% ?Fm$#¥¡wD¯on•®m¾r¸`7œbË£{UÙº-P¨kWÕ®7\Ó®¡¯=ËJded.X4ÑTßïLû‘˜|k6å¯P•ûñ|:IBÓ Ü[Öì+¯jŒQÖÜ,à–¯ ÀWÓf­ #FBÇK45‡²ûøÇ^ÑÏz#o¥îu´»óð4ïnAo*r«‰!ãTo˜˜/zƒ[çë"úê·ËË#̨P¥ïÒÝl#:£•Öé^ K¸ª½–‚Q-Í<&üîý\’Ÿd’W׃¾ÄU­÷¥ ÅÆZî«´Éí:~L/‚ðÓãã6o¿Ó:Ìíá0ü8ʇ܃ëG÷²Wª ”iIÞ|ÞïŒ-ió…a7!p@ç)ÈÐj¡’öîã… €û„rŒ>¿K]ÉòKϻś |ùi1 UΙÔáÝ¢» WÊ—–L!)èHóÔB@ Ø(Ø5`vMþ­d$³³ynÝ?Ìæç£ä;Pg¹XýÇÚ»CÌèG A3­‡ôúýÕóׯ.ÿhFØ]£«ÝÁaüÁwW|þ‚ͳ«gË!ð«˜nöÝ×Q¾ '¸ g1*¾çKñl„ßAŒÃ÷×q¼`ȽXüzð7‘m&ëendstream endobj 5102 0 obj<>/XObject<<>>>>>>endobj 5103 0 obj<>stream x•XoÛ6ý?ŸâP ¨3$Šc§iº_@ÛÕm€aØÐ Å-Ñ6‰TIÊŽ7ô»ï)Ê–íY[¤®täݽ{÷îÜ/'—4ÄïK_óŸ¼:y}w2̆xØý° º˜\Ñåîæ°½~‰Exù`¢´(ËÍyCªªKYIíIÐJXaŽæÎ½2úŒ¬ÌaI~)#7==<¶^ªRÒt€—GbaW™¨k©‹`rxŽ~â ]ô³›ç1—_Å<ˆú˜½•¾±z?çpËÅä%]^eW þy@ÿ&^¿`(ñ¥ ~·f±Ó]Ö®²›¶|'µ´Â+½ µåd-8fldœ8L¥Ô ¿$¤Ø2& Rm¥;ŒuSͤ%3'WË\‰’K]òIé2zUú¥iKp²¶f¥ é Q®©kc}pÜ‘žCJ®\¤9(/XŽf8ˆæ[‰X%i³<šh+úði/ŒBÁ7WF8‹¹âC/r{áð3Œ”ÇõÝÍ1®b£E)·Rxɘ0ñ‘žé‚À¹|‰Væ>XµÝ $¥MF³oK3 4ç‰ã#”¼t *OÊQmœS\.H@Œ2ÝÒ‚'ò\Ö>¤žjä7µÜ‚¶ûŒ0°p‚?ÎTŸQ”€•*Ô|ÔµÏ评T/ ñÎNrŽ{"çm“ƒô8¸jáàjªK‘K”Õí›àü…Åe#€¿ÍŒn=}nP–ÂHêiì}Vî”Ðúò®%4`œ¦µBKp k±ÁßÐà7˜R–Žrgª S ¥V7¡EL÷ ÒQº-wÅŠŠïï·C´ ö¥Ö‹om•öóéàÉ{Y–†ž¢Q›ºU|ZL§úÉ·?›ªÕž­HDEg×QQ>.el›6'K¥1÷ 43J¡ñP£{mÖ-Ù¸c¸ 9jæÊ^éS€ÓÓø¢›6W •{Ë/­äfŽÂƒ,&å®­ŒEÔÉc±P ®ËV‘ºó„ê­Hˆ 6Êw@ìK§þÆ'ð¿˜\§¹HZ®¢Ll¡@E8)0*‰£¢â‹®ŒòAæM’;Ö#*âeœz±‚"€ òމŒ»*‘£¯€™)¸È@Ö±AS£uç)ôˆÈïiÊHˆ&j¼Æ³ MpÙcï“ÿVûöV8¿¥i¨¥÷²ª} ,d {…EG¶£ÀšOë» Ã~$µAìàíS¢ÐîÀWû«E«6Ç6 ¼Ún ¸ãÈ>²`¤ØéÑÙ}ä <}cÖ ÛÅ–c{í׉}ФX¥ËNbB7¬ K‹SÚ åædù®ïvÆ´þ_¦°ø'AãNL÷\‚ú²Çêp/Ï·rÅÅ5šy QÞ¶ñ{ð]uFy)…Å{|m¶ôFMçjÑð^n?܉ßFRJÏãgm ü¨y•½P@ÞžaŽŽ“€°3†c/>&0dõÀ(MãŒ~“²(%&Ž;Ú«±>0jÈo4¶„°çÛS¾‰¹Æá$]nÕŒ÷tÇS£ÕBÉ€ó6Gs ÂÐï©ïíÇC˘J‰NŽ˰msíĘম4_È#¦'6Ž çšLù’l£Ï½ª$¨ÄB…þ¯$Ë" ©‘«uP8VŠ˜6‚ä¾Àšy/€­ç¾Ÿ$ÕG Ey0X€ <3[)Ó@Õy·qùÞ$¦Ú,m¡iâj›Fu/”=Þ‚)æ4ô» @Êô:¤x £ÃØÀö²;QҌٽÃÝMt’/!‘—¡é!z‘Q×FAbËÁŽƒæÎc  Æ Æÿ|õú6,ØxÜËß‘xWÁvåN¶®S­lÝÄÆX}ùž´<Ö [Ìv\UB7¼0j|Ùã-Žç¢ØiÝY†L!¾Kô"éô$Èh¯SfXêZ1àåI8¬V~i°„Æ\ñeQGîd5 Á í›¨4Ü Â?‹`¦éåL¦5ó·ÐÚ4eAUƒ…ZÞ‘XU„Z_LnÚa4¼ÊžŸÓõ‹—Ù(|©úðñöÝù8Ò/&ß™BsóÕõh|þ‚¿x‡oj—hVoM¼ wlõ|xGøßŒ.oøÑÛ»“?Nþú8ûendstream endobj 5104 0 obj<>/XObject<<>>>>>>endobj 5105 0 obj<>stream xWïoÛ6ýž¿â€3ت$n²a¶viƒuE·eø -QWŠTIÊ©ÿû½£,Ûj›ÄŠD÷Þ½wùt2¥ þMi¾àŸ´:ùùöd’Lðr÷Ÿ+èùõ9M't›cíâ Yüއtx§BI¡TžŒðAé=)C•2Ùˆþ¼»yCµ³k•IO‚LS­¤#›“·º ÊOÁb»¤µpžî¨ke Þ¶Ò²Jè7ëoÁ*/6 'Ïnÿ9™Ðx:CJÃÔVØS)£B)Bw0iU© ³Ý¾©këÝ#uÛ*ÅšD"Nzþ€'ὬVzCZ˜¢…Lè­½—ké¶·J…!¡½í¥ÐEvRèÝq»-‡|"ù Òã܉JR%Œª-¸Ë3R9mlC¸’Óz›U!9G“yÊ” ›„~•²F®"„x~}EÓóä¼…h<»äÇlˆWsz-sÑè°Kg›c»mëxvž\^ò®»R^­êOZšI›¦’&ź–Â1ƨ€2Aº\¤rA̶g­$×ÔbUÄ7s¶î@n£vဠÀE\å¤ÞŒzÅt²Ö"5(eÑ…<^ ­÷½{Gµç't£ägQÕ‰l‹XŠ g"¼1)×7F~=¡KT\ž9³Y2Ÿã·l¸¶ ë®R;DÍ—à“Ani‰Ë~—WaDI’,Ï~èn£Ì“ÅâGQ`•mtF+ ÈLí"'|áŒVÅÍdªqü”[­í½ÿ¾ û“{*¯ˆ)·YW F&Z# e<Ú3âÓ¦ì<ŠVàG¥Ù+ žŽ"NO%÷¸®m˜CH UsV¤h)«–?2—ègÎÿ¾´@?Ïšð MÚµ š†×Ýt¢àA:Ûeq]ûæ :s²1¥è#ÄÌoõö”ŠÙAõ´fÀ/óF¨l…‚k˜Yˆ„‰û™»5_ã*-cQø ÷7}ʼé¥S‰€1Zý‚wñFË!ZðÃåxœ>/_¾ìSûô­ëèÎ:.ϺSYÙ‡-ø„þ¶ëDH ²åҜҀ–C5ñ§åÙ“ñbH-«¢\Mƒd›ÅÞi¾h¬÷6¨Tri¡ŸhÐŒt•pœ‚ƒ¬$?dÖHV¦¶,Ìì•dä^%t ú´åç L¦6’§šÕ>£ªA¿G/rÔØ2žìUWžè2lEÙ“no¾?Ý£Q°Âë#N™{ZMÈlâ*}*X°Èº ŽÈލ15„A¥!ŠïVG÷_ñýºÄ C‹¡gôÀÝ5`Á×!]ÌgTX¹û ~D £ r¨¾Û[ùvN¬ì>0=öŸ¶lÎ~:K{çg7{°Åá‚ÑP;FìlBÃÙ Œy-÷ŠÄ¼á)!&A푟P±œ†Ëa4ˆ~"îñ=LœçžFµÐBGZC—ß 1_NL¾–©Â0ñÅYß¾õ ³CÎqâ!¥&x›E{Déè‘÷qWìÎa± TYøÄ4l-M´BÎ<2—ç$w¿ó^Õ7ÒZ„îÂßr- 8Í1® µþÔ¨µÀ0§3ÀÇ[âØÓû×zÜÜoL«¼©ðк#e¢‹tÎÜ­,¼ˆl®R£•2Œ($V<2;åg¸éÁØñ¬TQF‰Ú*ËFWô¨N½'tæÃX»»uqÔ-£8 ›úø«u#0‰SS@xè¿t Nµ;—m ˜ ßOó˜¡gϽùh;†A°Á?žý@AùcTý4 Ûuߢáᄇ~<Š‹˜ÃÙ>dž·†‘s ëy¹ÕƒÙä<¹˜_ÐâÅ,¹X°³roçÉ„^Û4ö~û¹00»vñøEÛL˜Ü'hð¡ý+ˆ]LÉ|†?Áj6½âW¿Üžü~ò/ª@Rúendstream endobj 5106 0 obj<>/XObject<<>>>>/Annots 1874 0 R>>endobj 5107 0 obj<>stream xÅX]oÛ6}ϯ¸0T)Ŷ/Ù°‡î#]­èVo}100ms•D•”ìÃþûÎ%EEVÒ-}¶?DòÜsÏ=÷ÒO¦4Á¿)% þ?-N&ñŸðŸ)ÿùåÕÉbÏi1Á[*èzÏÚ79½;é½-hš\ÅIïËéü*¾¤ùâÒ­œ^^Ç×í;^ڵ׋øªÿmï}A³d/zß~³ìát`͆.n&Ä–kšMhq=‹/h™¹h&´L#UÖ$ïdšW«(Õ¥­)Ý C/*QoÇÔÿD˜Í˜Î–œLè|еYD÷ÿùE¶6SúšÞüúãOxtöôG“öÑÕÙWŒàâfN aMçë|–´aEË­²´×MžÑÞˆÊÁeüÃQtuv¼KDÂ’ uS¦µÒ%Õ[Q“HSYÕ2£¦¢ZSBºâ/EN`¢)dYÛ˜¾“•,3UnÈ-“$ª*W©à'ÇØp q [ˆ›1q…6’)I–ºÙli­ UFàôûW©´•6nÍæ¼h¹•„%YîN[ûT+2¹Mø¤Û¤{.(#¢ÇßJNw¹A”;%I)KuQW»+6µCêÖRÔ‘1½^û€Û±7Vfc¼E•;ŽEy>›ÅI‰fÑi»r;ZµBuèDxº†a­¢zuÚ… ;½<º&޵^ÈŸYXþoB 7ÏimtáX­QÖ”ƒëFl$í·*ÝR¦¥¥R×ȽީŒ5!¡—;U4•Mq+ éõ}*Çd,ÖW×#ʉјF·£ñ‘ÞF)Øæm¯p#KiD-é[Ô:x\ªLó&6‡GYË’ ÂÚ‰¼‘@àŠD= áøqk l  °t<ºP©œ]W)u0 *c½Ò€—«WvqemX+Ä~|Jçk õxKìˆ-/êuƒÜjÃÛuP·2¯˜'ŸK~%ÈÂ%T)s6ZšB•Ì5 åI¹²uL?è½ÜIÓZF¤bDYËA !IˆRpÈp aá$Ž ”º¡ò®6¢–ÀCM©ØdÁ[ð…ÜoŠØEÒ°WÆô)|Ü!@9“Ûùç^›LŒ£-L~¬¼nô£BÝ« ;ÀŒ¶ÅÊz½Šé$o]£çs}çí†=7¯V°e¶R·ï=¦ ÚâqÓ'D£aº…%žÙÑ6€Ònµ©óÃêÌ%ìâæš¦sÜQ0"ÃuÙØñÑ%ýæç%O³wÊÁLÇ+æñÕ/ÁÓJ°Ãç²Ü |a®õˆtÓmEæG`4™žS~äv%é›dÏ»`W«ÈYôg`¼»r\\Ð+ÌR˜û>lY]È­ÞûpÛé½î¯v{Ü#xbè_€ÖE=¦õê_‚!GðÝiŸ¼½ †€¢,ÁÅÅÄUñ×»¤ ö,ÖcqbNoÐç>'ЪÔKg¨Ð–\ŸA[C]pS'ªÆ @"Ç_ .j'‘áðáü´ßªóõÇ`©´Áó;­2zñÏ;L¢8ÃyÖ–š`i¼<;pëæûà<´§K|+XH„½¿Ò­"Ô?ØØ)ÝØüÀ'uã&݃‚ÌVg<€=רY€‡ªÇeŘÍÐp¦ ç”´Õy2ápdk ‡Ø«”`B°ë5³ù¹‹#‰[Ý€% q>y6è‹‹_ánPrÍÓk´¶iø‚ÃßJ´I…CqÄ»÷¯_¹îª=gOÕ‘ Ž -AòÁ¦B£ðsû’S†€0Øtƒ!œ¯ä°_·¤ÒÌ”aš˜—®ùï¶öç!:^»ç8 Û·waM˜èôFÔǘ‚>0p‹56†%Z¾Çs‰àg7–÷IæÖõöPouù™võd«xÆ¿‘ŒNíè«ûßOuñ‚nÔ»z Ð­ëäšN-½¸ªè¬íÿ ²Š¼Zá oïÜŠß_Zÿb=s35.¯DØ›]´Ý´£Þï{qsÕNÂÓ+ôŒä’W—ñbê®é,£ó?`}§S÷;ˆ-ÃÁ¯1þéó/¼ãºô2(¦?4ø©¤?©]Nq2ócülæ¦þï—'?Ÿü ÔjÖòendstream endobj 5108 0 obj<>/XObject<<>>>>>>endobj 5109 0 obj<>stream xÕWkoÓHýÞ_q·l¥´¤ÆIJé‚Ä#…Jº4g.o¬Ì ¥36,3)[‘1©,/-éË/2²o,#c\d1剈Ü—Z+îk­b:hENÂÌÊAÃÎTeØŒ‚lÛ=ævŒ÷¶= t- ®®ˆl)š–Yd‘E"I8èTÄuýË,–&©¸< #ò\â|h¡°2ÑúŠŒ.gst#QW‘©âa“Ø M‡ý~0[q‡­L˜Œ÷é{”ÃQ äÝ[‡¦|‰0ÕߘbðY”‰m&/8Ä0£ÇÄÈhæ<„ý\sãŽ7ŽˆÎ« ‡¶ÉÓÂwØ%ZZ#xÉlo“`l6Y²û.›ø…ý?Ö;Ø¢ÈmU$i®€ª/ÑHép „xÀ®šÊÈS–-æ S¥KZè2‰Aµ0mhÜ?âzÑ”á  .Á?a±_PªáIÄ×"c(_)×Sº d«\¦"è…*¢D¨Tš‡hÍ×R¡?TÀ¥èŠ2ϵG˜ö@öKÛ€ÁÑ,Ù¬3 Ÿq™À+'RP¦-a܈ÌJŸîB›+ ’ T^|<{YoAÀæ¾E(Y¬(4äDè*µJŽ JÎ…£á,×bEbÁDDäËD¦¨&»¬ó`†4U@J®L3™I#e«õŸMQȺT^#VÜYåˆ#ñXX*ÛvŽwÁVìYËÚ±Ó{·àª'.òåî‹(’9>8Z%eez ^ëéZÆè‡SÔªëTàL§Âq]hÊjÙµP‰3ˆü]1Y¼D²ôF «ci±¨ðevê˜Ë,ƳAÓñµ@êî_J.qÉëÏ0Ýõ ªd4¸€²xä¹°JºÔÇû½Ò è¿éúŽ!WG†’#Nd$›;×ë‚ÙèßOXÞÈ(ÉÇM^Êkâf$…I”4(Œ)êPÖÐ8>¥pÔòS-(ìÕPóÃ˃®ë¸ªÙÜÒTÁ £ì:’WÈûEÅÞ«ƒwTy¬Qˆ¸ÓÌŠzáç-Z΢¬ÚŠËƒØµÇ¹¬pÝ ‘¢?qžãóî]Øõ>Ôg7×`£w6…ñójTâÒ0¹Pß$´ÜËѦު)|¸-O`KÈKCc&Ò6â›hòA$¥ÄŒ€vGZ{ÖÁ”'Éî¦/>Žli2zóþõëv¶Nço$Ù»ÕùoåÌA¾õ7Œƒ¼ÂÁt«/¥=³2]Ö Kj[h¾yõÍšîÝA•Îÿž|¾»8{ûfòjøéÉãð&„îï?cÁv¦D®è¿Wï3Åw‡É󹌮ÆùxkpŒþJ†îüuE}CÜÚw&ÿ´Dí^啯Ì*æ§ÅûÑéI‰:ôÍTý6¼Ç%¤à¼zVáÔ¼u‘p†9çÍ­çÕäÓ‹áówÃS. L´íÝ‘ TË ·³ª¯îP^_¥-÷¬­uEÞY¬–‡Ss©»­ 0Ø.h»©¿ó puËs’²¾§¾zÔ?$z'GÁýÁ}:Æg}wå3öp„ôBGŽö‚oÍLÜÓüêÃþfÙÃ#}¨oE|nÖ"Zðêûáq0èã7®[ý~‡†£¿vþœÃendstream endobj 5110 0 obj<>/XObject<<>>>>/Annots 1877 0 R>>endobj 5111 0 obj<>stream xXsÛÆý_ŸbëÄ#J&!þ(9n:“4²£™L¬F¬ÛNèÑò,à=¤ÐN¿{ßÞ ÉÒ îövß¾}»ð?&4Æ¿ Íæü#³£q4Æþšð×oަ—“蜦W³è’2š½½ˆ¦Í_)Ýý¸x²Åïsk:{?¦«hF‹„¦cš_M¢ùü’±7<¦…¼.ë\e"_§”pëå -Qá÷¿O_ŽÆ4š`e~rCéÞ~Æðg»S[å8 .Î 'Ú´¦H“&}¼ëÁg#ײ¬œá#ST–©5Šw[’2¶ZoØ¡L< Y,©Œ,5ò¸³î!ä𸩽ŽÄMAUN™Ê¬«™CVŠ\Ñ{ÂøÓá]ðBÚØ;±VF9¿>¬1Ø0"’R9ïN€¤cµzT2Í{8í}FXÁ·`o)7Äð™ |•©¶0Û"XKNíœ.}ܾV&VÌGÃû[>{ϳÿ:Q‚ÁîûkЧÔ8,Õ^]|×´×½ÑtÍfPAˆXch9x%üÁ¯ =!æžÜÉptzê’µ47°u1ë øW¥%sËM†¼t:dY¿?·W“îjÚ]ͺ«óÏÃ./½,‡‡Ÿ`ï¢Û1ï®.»««îê-®~ýë/¿ôÕ³ÕN("°aÉn}—Öeƒ²¼ÒÓ;fH¾Gx¾ª­ .)OˆÎM¼0I‡¬â‰ØóË˯­"UE᫤xR¦±5ÇP ”„zÌS¡M  ßÀ=O¹²”óÒÜ•ke¼9f烱;â^$•+auàÅGÕÇ`ÒF@2ÙYh¿¬r¨@“I¢TD7‰§7üNQî;ÄpªJÕ„Óו« § +ƒújÃa‡JîýübW8HV¨Úã[jSù²a™0hü˜¥" œ~K“sLèaÜÁ®ø2àÖœ>…^D;'òœÙérƒšX%‰>¬Þy]]ñÖö})wj«-\V"Cï*B ;•j¨Ī©ÆÝßn>Ì•[€Èý‘£Ým4!ä›k(6 SSjw#à¤Ò–Ù^D3!!*<¡X!)²¦œñ¦¨ ßjX†‘Àãñ>1Fœ(mÔ$ÔDhÔ©2k„–6]vUc©h„Üy!—ã#*ûÞXØLÑNA²]0›AYõ#ÎÇ<²ÂSœ»?0·@( UOÂÀÑÊÇ–27QÊ%È-J¾ÏoÇÔ®#aÞbºzšùšbž‚/ ?óVÃ,¯1Š!Âs'[:ÂJ¯×pr]™¢=cêYó- àò–˜ 8*¨*€r˜B€m^¹Üâ˜Èj**dW ³ ‰ÃÃIcç`S–ùwggÊQ§bTX$mv¶çä~Àm§Õ÷ã°€½ݱ¾>‘{»;LGÎÔFdšûRdÊUâ…¿G(Dž}B!n-zDî¬T1z A8,ÜA°rRB2<ˆUŽA’Çð4¢Ÿ7I¬]°ï€>-@YA—M,:\Û©›ˆbÍCÖªòTb‡¸xxFp8ËwèrBš–tšVØÈú”çü€fÁæ É}‚>/XObject<<>>>>>>endobj 5113 0 obj<>stream x•VmOÛHþίеMBb’RN=TQA*tèÚ+éñœ¢Å^“mm¯»¶rÿýžÙµCóÖÓ%ÈžÙyyfæ™ý¶×£.¾=òü${ïF{]¯‹—ˇy £a—N=ŸFõ»4øµç ¯iZ­.‚ ó0»SÓýñùúúMsôe¯KÄ!‹éA2nÌ´ ©5nZõU¥§ê\àÈQ‹>ɹQ…¤b*)*Ó P:¥@Äq›Ê\¥«û(RÔ:‚}Z9ý"’¢(7„=w—òQqFß×BSiÁçñQmš«AÁÃ$PÄxn‹LµZü›¯+Ø|­ñVk&ârS#˜ c`.-8¸‹Q™Årr£þAN3aXsÜ\÷fC 4‡m#k1Ú PÓÁ¸³Á¡?n¶rÒѸñ¬6nnÚsÿP¸ŸÚªk»i‡£EŽÜ6]^úuu²¨ú,¨Ì(Å#YHƒ¯Uͦz×å~{Y'1É4Š)Mmµn>—F¥ ·½ZaÓm¤L^ps–‰D_ìpÛû?n2Löw»5^uôœp¾é:Òø)$Ü}CŠ~;ãf%uxˆú~_C‡ÈáÓ?´ùŸ¡ÍlsÞÕnŽi®#®‘¬g´þsáz(32ã17^âÙ¦áðjrq9<ÿ|=šœ¿»âÁ:ôÛQºÆ_>Ÿã,QȶKéYƒ~ßšªP4xí»b™qÝŠ–G_W£ß¦—ºŒaÙ¥»Ù©O$ã\nÁóãâÒ˜ šó¦0àžq/ƒÉ§2-T"!Ó¦M·S-öù¾YÇTb$¦×Vf·xWdõqT¼iÜH^º•|׫öÓ8œpWNº-†ÚÉ’¾/À¶Â¬Ò·G·S9ß_on¦`ÇÎ bM0 ´éÇ7ðÜk“çyGÃcâfŒ¨Ǿ_­¦ÆµÖ_yGˆûCå0/0h›º.(/„LÓ\§!­|s{õž ›{4V‘$‘.HŠ\IãÑ{5“©]G"Ñ(¯±D=LÁ'q¾ô3Ÿ.l ¡ ÓW})‘­Ûs‚¦" ;Q!C¼Y&Í>]*l@¿È€^V6§xÀ&• l*ã˜DBWT˜„+Áp²0ê©–Èóf­,8ÌbÈ·ûoèÃýLé2Ç©ÆlpM¿a‘ñ:Îm4p93TZ®|ŽX™«§ÉeyU ýcä<'A‰† ùX™ð¯­ ƒéz›.@Í)×[„mò¢(d’¹­'–ùrâ: ‘a2 Pиéuk4,ñ¬Þb:ý¾çû¸ÓØ«Æy¶üÙÎúE£NÅ^Q^¬².ï®Â”ß;¬™©ŽC®O&òõDëÚ¥P_Ãm=“&çKÍÖ5ÊMÊ·ÐO É&”)[\ Í,ŸÁGÙÙÞ–îT¨n3­l‡Æóªµ|4<­ªÒ;=öNüœ.ç9ëø^—.t`!ÜKŒ-†Øiw^»Ó;öô—»ï¸1¢sLDÕ,|ê¤;ðü>.²(f¿ïó«ËÑÞŸ{ÿ¾y"2endstream endobj 5114 0 obj<>/XObject<<>>>>>>endobj 5115 0 obj<>stream xVmOÛ0þÞ_qB0µ¡„¤…ÂÆø£ $ û@PeR§5$qæ8e ñßwvâB›ŠÒêî|÷ÜÛãün¸ààÇ…nOýqc×k8¶ƒÂéCŒ`ußM» ^z_]»×Ûo¨­ð‚&ÀLäCJ·ZÞmÃÅCÓ$á.½Áá±×Vß{'»G}ýóô…ý3xš=µôT:Á`èdIùIê7Yâ·Ào<É$c"À cÙÛ¶Qñ8Z㋈ÑdÖ?K$ંWTÌÈ «ìs ™,µ:oÑ…m8}8×êÁNVüð›‹,Isé·j<^ÁÈMD!¢ÉHŽ <¦‰ÌªÞVíßËÓˆÎÙ_ê7'D <{ömÊŽÒ Z£…*XXž˜Dü¦rdexœ‡¥ÚoU„\ài†>œ-`𽨰ååšJ¦}rsK ò€ÊCIã)Î6«Âf„éôá0‘ƒcÜùM®UúYvlrÅ®mÕv9V¦°&ù—†Ù 9Õ¸Tìˆ'#¥zò h”Qƒi?âäS¨Š!¯º×3§3PÀ†ÏÀŠH;ÙÏqþ \9hŸ¨Y¹wïÁK gcÅP©—,K}góºã è9¨Zç•–dª6„9ù]i Ë<f½$-œÀ`Ùõ[Sâz6«c¯ð‹¶½éË wuvT^˜ß,‘¢°cªe’Åžã@Cž^H"-ÇTR¼Ÿæ/ é•s>¿˜)ÇVRaœšÁ+²(1ªk ªQÅ‘‡Ï‘kn ¥ãȼJèÙ=“ÁXïTf·–“‚tY\ïßf&Yè¥Í®Üe6›qŽ ›lLºÊ¼LÙØ«ú«è(.Y¼îР䮪0È .þ¸¡æàªÃ7á\^wèx%ß+ãòNý 6ÿÀ! II luTŸBp7×ìõî:ô6ñ°‹ï„Ãæù¯Ãƒ•®íÀôë Q|§†a¥ãÖ+E—Ý5»øÖ£ë^4Utˆ³6.9QZwzv·ƒï¥è»ÓYS¢¾×øÙøâ«ú×endstream endobj 5116 0 obj<>/XObject<<>>>>>>endobj 5117 0 obj<>stream x•WÛnÛ8}ÏWL¸U²ŽâKnmÑé%E°½d7.ò"À %Êæ†UŠrê.úï{†’ÜÈIÚ®˲HgΜ9CÙÒCñœm½šl ®/vNûg: Ç4Ii4 £§Ãðèè˜&‰Ÿ5 I‰™±. ¢çüu—®F<¢+ùÄJ*¥U¦*õЦ” íîïLþÙÐÞ’ÆÂÌJqÍ«ïŒ}ßx²ù]¥iª¦…•Å4Vi<ƵOggçÓ7oÏN?¿ŸLO_÷iÿ1ìoXóîß¾bf4Á÷)3 +vaÛNÆ‹\}”j\,eÍø»Í$6tVF «ðÈx‡µÈ畘KK*Õ7Ê-HÐ †ifmè ÈäîD:¡tÙq‡ ËÚæunnè,ðÁ^ù=‘õyÅÀ#næ@Ë’#ƒŸRpõ`\:j= éÌ0žó($ŽF¶ØÔ^zàŽ#<­,d¬„öýƒK«®Ù`),+E—¬´×*1Ó@Ï» ܵ»!}h@)¹Ê‘‰I¬O¼„.¤Õ‡T¢@Jaͼ嬶k)¯²r{ÇÇTYä­ c ÜšTùÄÃ'•'ò+®¸õ¶­XqR áñk÷òµÃî×RÒ8‰8¸œ˜ãŒ D­pðÇäw<þ-ð ØgÜrUÔÙkØžÒð <` d<áÛ$À£cº¯ ´"öm)¦Z•®‹4/8ONxÅköЬ\3q-ó9³¯á Ý4†û^53D/sJΑ´‚ŽèÂyVø8VdÒÇŠÊ@۾˅{< ||ñ%v‹?#nËVïô ůÚÈi AòÒIá*jÓK ™Ù’Ot@Æ¥!ë|á^^¿k¸„•3 p‰§"µ©ÄľQ€µµ!˜Y™¯¼.€tEél£µK¨fm‘Ë97ôšu¶ºC ŒŒ Z< ÒÆðƒ$^L! ZÑNH $*Óqˆ“ë±`:¯ ˆßK*zMë2»7ÔsªV+v«B‰Y½böòÉm¯t"†â»'^ã±F"/žbÐvtcžù{Û¯Ùtc*@ÖÑ'D¾bY'”˜· €êQ<`kÝRqä+ìÔk°° }ÒêËŽ?g ŽÙ tP[^$ëj¨Db|!‡M¸§pù­Ž‘¨2®¼¦ X­0ß«®ê }«!¬Í!½’º–|Q«¡\oÉÓjø!Ãu¥tÅ!€ä(Ùg‚5(,„õA‹ƒaèïïÙK­ÉêYÝZ:„jÕ®îj{M\›zAn:QÓ™à5Ø¥b0šÑlëÐ÷zqíÕ0çßÑ׊ÖHéíŸS·Ž|½î/Šÿ©-L7âíùðþÙIÓý†'ááøŽŽñÃmè—,{ãp@o5ð'ŽÇÛzöÞqmíg 88 Ç#ôèúhtÈëßN¶þÚún(bûendstream endobj 5118 0 obj<>/XObject<<>>>>>>endobj 5119 0 obj<>stream xÅW]oÛ6}ϯ¸(ÀYmÅ‰ë¦Ø€v]ºÝ†­ú  %ÊâB‰ IÙ3†þ÷KJªåäaoK‚Xäåý8çÜëdzMñ;£Å’ÿÒòìÝúlšLñ°ÿg·ty;¥U² uNó)-_Ï’åò­³°jJëtt¾VØ­»¥¦ržÒBXúîþ‚Ê×]mUåó7ë¿Î¦4™aC6:·²¥¼µoŸ]ŠÃx©ª´ª$ÿ3°›GÖ‡ç¥S’$°:ÜD´_´‚‡¢:DÄ­töÝ›x~Øã¼°þ~$ê1ÁøýE·$FCíFúžºxFÁQ?] d•±­§ï¬ô­N܈g|Dn/o_Óì*¹âÊLàíd¾J¦¡4#<^Ñ/_Òst¼ùòöŠØVŽ’Oæx¿âô~¶¢®Uµ%“‡õ¥,7ÒRÞT©W(&ùB ]i*k| V‰–T5av¡ðM)+ï¨FþÂ…8z ,h-«­t ½;P.ì6eΜÂ)‰ªìż¡BTŽð…r„?çǧZ”7ÏþÿœbŠ ˆDX´ÕgxX´ í í}p´W¾  \¶I½±nL¦–VÄKÆ‹¨d€?(R[³µ¢,™5ý¶cž„FšôäHØ@<®û{ÛaÇEi¬$‘íD•ÊŒ-U=ø‹*8 ªÑ;¬#'­2 7VgLÜZ¨*¡»ŠŒÍàdK o Ë‡hÜä¹ÓÁ4YëÖ¡ÞJòÁ†*³Lk*XÒ‡#ÜÆº½ƒ*pV2é…ÒŽ`n²Ú¼}w—ÎB2MàúñÊö;J´,fžŸ–´¯™‘ìÔÀÑ'ú$©5á“ËT¨,“Õ‘(ý*Õ¶ð´‘,$!N6ŽŒgŠÃ5T•[ ¾cÍ€ŽõN Û³ ð\1­YðÂjrµLU®RœžQ ËTž£é÷ž¤¦¬•––ÝËH"ƒí X ž‡|¶9thŠýŽ„Þ¤cv[ìáÃ’ÁxH¢“¼°næ ˜e Â#t•³øá%¤¼U…RúÂd>AqSáP66-pŽbò¬|l «ØuTóÐÔ§å1`‚Ñ+Ñ ˜E}'ál£?8HÐ8±ÙŠ}i‚:‚­ p Û±9œò1Ð4©|„º8ºd§ëa LºÔª g zÐúÇ/àRès4ƒ>'W÷CžÞåÁÇÌÀ@ª2”À°H£›’DD3©É¼AÅèÓç»Ð47€Z‹m†ó!ßÉÖè9tQÂç“ÕЕY|Ô5õQB¿q¹)èå„@Eøð§Öæ'ÖÆÏœ¸x²†! w|‰ÿßÚ^.&Ì/bÞ^5»“®†Î„Q®‹*ô!<Š“:%'bòChj¸œùÁbLÒ§ÿº~ÅB“ž±ÔŽQ]OzÇL-–gåƒP®0Æ3.¬“|ŠKr<m¹ý à| 0ØAÆ@‚i ²a'RmY°Ù"Öï]Œy XW Þ·ÞU‡áž£~°H„Bê¿BÛˆç3J-RÌlƒÎVVèhšö<îu¼é:=sáD?BÂçKn]+53ž-_Ó{åÒÆ±x AZ\;[®yö]jfj¶q¢¡ ˆ^¦E¥1¥Õ«c¥îD •Ìž%wœ~åÙý»CzŒê!Ò×9e`°i>/XObject<<>>>>>>endobj 5121 0 obj<>stream xVkoÛ6ýž_q‘¢˜[ÄŠc§I»oéÃmÐÅÀM]Yl)Q%)»Æ°ÿ¾s)ɉºv/Ä1lšºÏsνŸÎh†¿3Z\ÈKWGÏWG³l†ÃÛßÐéòœÎf´*p÷â>äéw|Г÷5SãLÉ”› ÛŒ«I»Z³¯Å’)DßêØz–Kr`ͺ( ñU5–™:7ž·Æµë+½sî“©7¤".àM»œOÈD2jå\YûhõñhFÓ³9B›hËÊw·c‰kx‰KVÁpˆ´S{ŠŽ‚³[å*£7nÇ[ö'rŠP•üSÝVköwh×Ñâ(4. ™ÀN+¡Âæ8 W“³ŸN+¢Ý‘d$ YïJ£ËûaP©­™kÊY»ªqóŒ–Æ‡˜j&iÊš‹)Õ¥†*‰iKÆ•B—ðâ6Ê«ôšãN|í¼j+¹™ÂhØ+œ¯ºKªÎS„Èö},Ú:5  l‹ŒVH i+J%L¥ÿ*ž½k©2›2Þ…O8ópÙJ :>IkLøQ29]Îèi¶øÍÑäù<[,ð-Ÿ<Œû†+ÕÜN6tV—èûã¢B¡²,»}D¿…ÈNˆäxtôÇèÛ•€ôvr¬RVǰ="j<‚+þ½=Ä ‡§éºÖ¶ÍAW1J¢* P´3m¿g}ªŸŽ#2ýóÇb {>+åÎ'§©*‹ìââR¼Þ6u~Bø-ZKA{´ÞÃ¥µ‚±²(n"ªÜ•P¸#u¨’(hr;IÅûœ¦ XÊ#;˜ NÈ#@Ë]ŸÞÑÁw¯ü>CA†WÑîÖûD· ×ì¾Tωibñ›„¹Ã^ ˜i¡`Þ…0+a¾0¨m¬DX±JZ„´QæTŠ5SÕêrO‰”„@JøKHï}€´/¶ (V%}’Ià,~5À¥‚B²ŠAôv*Ô?ýmÓ89'ˆ‡"ˆ¥sMcUžAzÒ j¹’ª´¡V×¶ø*þ€²Œ~ÅHÞæé– ÂáÑzÃf‰,EïÿD·¦È¹ Ÿo^ýöîúùry=ÄšÀþMòüWÞäòÉF´ÅÈú=ßïWo^}øÿÞÿ^î\—_Kƒ*Úý î2µ\»)ÇýÒšE>¶2r¼‰2KJ(éT¾Ä;ÉM ÚBVý€êå4tRY—µùÜjèuyàl(L"Ð׳㥠Qå[½ß¤™»f!´ø$†!Þ½ò¥©vóËõk c “ˆ¿@ýV$x¡Ò  óséÕ¸E`휇ì$¥{Aw¯ªŠ½ s®¤I2Rh!´Ugõ DiI˜,(‡I ·\o “¨M[1VŒC}dú©1Y„º€4×sñÿ—¡.³Û+J Ò5"xkKâ]ôÝl›ª},CFW(S☠f ‘?Cl:RÊ’€! QµÅ©­3¹\ÿ^:Ý"!G+l:ׇχô¬È¸I!˜ƒ ¥ ÷ó7ÙŸ$é´„A²(ˆ±Q8"pÃÂÕ7Ÿ¾zž¼ÓŒ*$ph•L"}Y½˜ î{’P Ø=8•}®³œ& é¡=éòPçã«Ël‘ÍGÁ,‡áðŽ¡YôšŠ•@A±k|0Q—Æç±§®]m ]]í|É2S1:@Âî™p^ƒ›‚Úž8"Ô=Çøv»â• î $µ“NöUt¤q­e…ž-i¬‰ØÞ€bÙ¬ºQ p¥©‚EÁ»¼ÕœÑkçr²­þ”|ž.Ÿö#u>;Ïž,žÐùE¢°ðmºÈfôÒéó¤ÍR2Löîæô²SƳóì½<,ÙrçÉì"[̱˜ƒŒóù¥½Zýtô'¿Ræendstream endobj 5122 0 obj<>/XObject<<>>>>/Annots 1896 0 R>>endobj 5123 0 obj<>stream x½XYÛF~Ÿ_QÀÂHÞ’ä!q2Y»Èa-ò¢—Ùq#’ Qôï÷«jM9XÈŒÇTSÝu×WÕóÇO~| þŸwžëá7üáóǯ?Þ…‰ëQ'nH­c7ꉽïyQ$¼nP"ó,² ß[ñÅ‘iÓàÆ+×·¸Fe±ó„±YÐ&r‹g‘†îÚb¡'B“ÈÝP" µÈ‚`8î<‹4~Àš‘É~ 4¸QèÆרôÖÆŽR"„ø1‘¸è{n`1åb¼éc¾Ï|ÑðÖ}ÌÙXˆ^è@J®V©HVèÃÒ颺ê#ΉŒ…¡‰ˆoàïijH ÄÒñ¢š˜ˆK9ÄBLB{žïE¬qdÚ´‰*,¹Ã‘‰ªï¯Ø¡X®Mãjì³Ó×¢ÁE½ ²#׆Õ\é~òU¡D°Eƒ›$‡‘k®&)JD±|Ó"Yl™6ÍbçWXߤå±BˆØ‰ÄE?œ1mÜX¯Ú4¸ OG®Qê™´mBöSQ:‘¸®Ð)Ó¦Á]³„‰+b£õ6öJ¢‹zh\Eml®Eƒ»â”[w-º ½éY\£ve’ºñX®âÍDB, F¦Mƒ›Ä³«RÛpƒkÅ•B°ØP,àv–OgŽTPè…¯‘õÝÖÂ^àú‘î6p:¶Àt²ÜU@ÛLÚ£mêø1ý¦ê2/éߺiÔ£n^oÿkII4²àü2ŒÇ $9ïʶ®².móªœßœlð×ýÕ%ƒ„dÎ.HV4?ÿ¡&>½ôÙ`g0²0FRÓÏ5¾?¯ÖJµ?qlôŸm­èb"u¡¿ÕÏwMÓ±ÂQõÏcõ·ê|-öÕ)O©‘/ÏéÞÛª(tÙªúúŒþôµÒjH×uU?§G}×Pյ箥CUª}~ç¨ìн®©Ö]ë2Õ¬’;Ó´Ë÷Ý‘ªVgtЪíÐ*´s|Ï[ú›ÍîõÇíÃ>á…C«ÆÞG[Õœïµÿ\C}•¢=«j¨ ^@íÛû·_}E?«ºA`vNµá ¨Ý^ψ®*3jñ­PguåÑ ([ešu©kÅ Í˜Ëø4ÿK•æ€ÿ“¦æ¬ÓüÙ9+˜°~þÉÎô!/Qç;gµ›/W»Ä¾ï­h}Þ|ÚÈügÞ´Õ—¡šÌè«fëðF>Å ?Ƽ°÷Ã$öp2r×k6øû®æ¹‘VÅ9?I-,èýoï~¤B]‡Ñ+OªÎu{¥ê0Œ³aÂ4.= _õŸª8Ÿôƈûxß‚e+Âʜþ›¿ñ“7ã{þúéI×§JeHI¦Ó“ê 3,«Zg.Ñ^Õ;'«ºýI÷HÔ’¥À’ßH¤<åU×Ìe6FX^¶FÒ𥨋 kìEæ©:®‹¼¦¼ÌÀk5•U¹<¨Vè늆.y{¤ö¨qˆÑýrØ Ý·œ¼Ôê|F¦Ü‰—üdnco¸öÉÐ Ûš÷“·’–²‚ȪþNùïš®U‡à£‹Z×Ä«[_û5WH†… OŽlCSì ù¦õ̘r:ª'® L]£wʼnö¨`bCͱº”ð\¾¹ }:¸´­Æ]LÎQ†-W" l\bfèš…QËC G[ËüHšª’öšº†«å!¯›v!±áß×]iªzLÌP¦f7u–ó‹¡ENBÁàŒ=NSuf”üŒBEÍ%¤åùÚ¯Ë j|h7ü’êý«£‹Ø‹Ñí•)?7eúí©Õu‰î}ÒV©Ž!–^TÝþŠÄþ$ÔÊ€¯®5yϵz,ε•UÇücÍýªGô¾gNþ£*ÐRV\ß $ŸrfˆÅ>/XObject<<>>>>>>endobj 5125 0 obj<>stream xÍVMoã6½ûW ¶(àE,Ù–?ÖIÑC‹Ý¹´(bÀ( -Q6weÑ%©xEÿ{ß’Ùν5 ƒgÞ{3ÿ{cá3¦ÉœÿÓ]ï×eo°Ø~™ ïG´ˆ'´Ì)ÑüvÏçh™y«-ÓþaÊ\Nš§þl4~zO¬?ËÔÝÝåZÿô~ù¹7¢h Û¬ŸÂÚz›¾u¶öÕºPé]gˆTénžúøñô¾ëíõv¦q^‹øéQ²tőԦÔFf§žã8î,ýÓ8Gžm¨¥QÏ2£; ñý¯cÞO‰qÎ)BQ2©¹ê¯À*7–RQÒZ’­ö{#­Eb¹6„E ¥Œ¤ÀÏúè-Š#ΨK±“1ÝÃ\~»}!=U]yDIO&Kö¶*.¡ôr @[ øô”ÿR+Òç[S…,.þ&hË­"ÊR©IïÒ%9ÝBGw=®~k.£icÂɳUpæ¼K9)¬.£(‚S'áì¨+×Ę0ŒVï¤Û2;qu¼9¼Ÿ×4÷imôY†Õ†ü>§ o†‹Gš\¤ îÁGp!4Ìõ¡¤=_øÂÞßÒxOYO¬¦ÿÌúãºÁ§R Z•üêŒh<Ún|h/|êy4f-R“LYø‚¡ºLæ¢*™ù½,¥›ºD!©½ÑÏ*“$²L1%¢ L äfJô¶½¨Ñ{QW™Ò;¤ÊrŒHˆÍÐO?Zù´ºÙôkü— {PªÝQ´?º-TT×O¬ºœÔìZ“Ú(ú现BðÉWWw…ô9¥ åìÏZf°eeð.ªÿYéÊâ ± ­BMWTü»›w»˽.+*«ÝZ }}7¨‘8ÜLF·ƒ›é,¹´›31†ô‰J…dLÃÞ˘zÕ‡~رىPª¥æ~nƒø.úûŽ;c¯õˆá× ½7ËïÚÉ»rÑ{ëbÒy±¥R;Õå«+»‘C›ÏÒ³}¤M¡×¨ +óm[ËNm¶Ž¶âY¢• ‚‚úìåη(å¾3ÕÀžØ7#5ñ½â/ÜË¢Db)ú¤) «CÂü»•Ti3– À }ÊåaàGÔu3ç¤Þ,¶ëµ¶|é–K ÅxÔœøâk&•™,SéÑöÛí ©Í ™»!źÎÄÄ4R?¥ó6ƒÄÌ©vÒ @Þòö6U¦E•q÷BvZWŽ£)Ï.h8!é•Z0[jì5ûâq×° ñ<èÒùû6sÐU‘Q¡€I‡B´g±ßKana²‘¹g ›ÞŠ–Ë7„¨›–¢|Õ…áý,r?ˆÃˆ½Þž-[½¹¶$w‡‚î ÊË#¹ÐV$êo@Ê×è˜f*Ïñ„(]L«Kì¬.äü2på­Ç#H `´ih jNaeD¼BPÜZÁ´œb’â½—e˜€è ‚o÷—Á©é…¶zF•ñÄŸÜw˜@i°[Ô38MãÙdFóÅ$N o­hè£NQ¥<¸øg0Ž>pòO”„Vá ØŒÈVÖõ¡ÙhO>/XObject<<>>>>/Annots 1898 0 R>>endobj 5127 0 obj<>stream x­W]oÛF|ׯغ Ê6C‰’¬¸ÈCÛ"hcFƉVµ,µ‘ßT+ ø²_Ñ›èÃ|HdÅ!:…3PvywèÒzpîA êdÅ ¥2ɦ;¶˜ ±L7eÒ¥6ð ¾»oƒ£x::Ó×B›7äo¥G·/QÞößûyÐãæ‰¾ÖêD‰•Y«zEõ¦’…¨lÛÌbowKý–4}oJYµhj."­}@ž“{ûøm Êãø7èáÙ§–™F:J/5Ãæ¹4’«¨ÖŽã‡á[âÿ%8Àx-r±¢ŸèoŽŸËƒ~N" ÃŽrþ£ú ÀyÅ,†§DXyŒ·² rÇ…†„ðT†µèvláÃ:° ’ºq™ YRHSꬹèú* Ñ l%Q¬œî…QÜ@¶®×µtÞ»$]_ʇ æÙ ¼V•Ñ …?3¿‘’-oCu6ŠÏ¨£W…žU–¶VæY¡+Þýñÿa¿n2ç`ØøBÎÂÈË&æÌ„®7ÅBç*!ëÞ8T/‘]«%÷Dh×KÎf÷`à‡‹ˆzikTºë´ë›«÷”貸Ñzæk*kžŸD79ê•[ÍTr ~z/Û†t³c íÐ?êÝ?¼¤ï+#–… E©9ƒ‡{íêÙîfå6d&r¦ó\¯¹s¨ûW†œÎåÍÛîæŸ~»¸ûãÃùÅåÕ‡‹ó»w¿¾½¾¦q4¤8Üè I?µ€SyÒnßVÐ"»ÕÖR¸!ÿÏèˆG`|óŒ8rÒm#zzKð…¾ýïl¡s—Z·a·h}Éý)½ÓE!AB³éCäfo»T1ëÅBåªÆÞ 1ñ¡XÄ5Ïí-­.ëÒíú^±â°Âˆô^” .@c‚ÒAþJ]CºŸ½1Ö hŽ…,+Ö–¶¼ÐÀb­D$…NU¶ñ«Én¥Ã ¬9NG¡rÉÂÒJ-W9~YŠûÛÒXIãy¥­U¼—p«¶|è’Ç{‘´cÐvSc„U6 ÞIÃýìÞòrýµ‚ׯhã·J¬GõêAÇUÚ`6hª„q ©?J·ÁÜ´Té'¾Á’T@$ X[ËŒðz¥’U/H´(<:˜I/î•n¬C[ËÆíµÛ»…LV¢T¶pµÚKÚÇÛ5Ÿî¾ž2Of¼Ç§¼³ŸvS¶mªOóª Û%¤¬ÛG¹T~7g±ñ†¶ºwrãðé›çÎ.Nê©]~9U€à†b"@,_ -°á¹ÅG€wýÍ6I–gMî%:–¼Ü´µg`e æ/2uLxu9k¿#Œ¢q8‰'4œ†~1f.œÄøu®“Æ5]·'¢1ýá“S¿}|ýëÏ$š†ñß}ü(Ž…‹ùà÷Á¿ì8…endstream endobj 5128 0 obj<>/XObject<<>>>>>>endobj 5129 0 obj<>stream xµX]SÛ8}çWÜiw‡0%Æ! <e‡‡Î°Ótú’ÅR@‹-y%™¿GrHèºÝl<0„غ:÷[÷èbü$” ýo^]MŽâ(ÆÃÍó@g·” ¢MæX=ŸGCšð°&¦IÞKΣ1}Ö²AºvUíh®MÉÜÉ䯣³Û%Xçeûé !Ü›<î,õ4Óî‘Ì(©,1ÅI£¥œ)š ²¢¹<,–ʉÜԊ‚K]š³g|H'èîæó™àÒiÑçðÙl‰çÖ+u’Ôëâ7¯mÍŠbI3V4¨T6&5RrNR‘ƒÚ¬ªŒ®ŒdÀhÌ|Q`VbÇž„W…¸4PÖ?ÑAÎB¯VÏ÷`XDðÖ.ÖÁjf‚…p I Õ`ðlI\ÌY]8/¹¨ÁêïRq½°´xF„]¿ÈÜh«çëü@>`ÂÆ•Kõ34‘œ µ¥GmÊuYú(RAñʻڞç‹VV…¸l"Ó8Ê|ˆSã4Ê2|ã½ßÈ.äõ«¥{„ºýÛu+ñH®A‘ ¼·yz9¸¤¯KåØË*p½TÈ«hký»ýËù›­¶6O§½Áô„Ú@Þ&}?˜5ŽâáÈ«‰|¿ ïM–’ªË™0dÄ1PyˆfEj5)?\¥¼‹ºòɃ æj#,M{I÷“‹‹éIãÐuÉ *}Í ô'Ñ[éf%Ê7Wïwñâ„ Q|-¹Þ* å³®;»MÆ+þÊ·OSصëß­ª#‰ÓVØgVlË3kÅD“ésЊɥe³Bpw}Þ -TwÈÃVdX«U±ìÀâQ+®uËbUJëR8HZ[Q ³¢+è‹Vh']'q+ªÅ…ž~øð&í­ÊÖ³î ÛÛ•‡î½½q1ÎKÇ ä°}#ZÛñ`ãÝÔ2¶Ÿ/üDÖAšµw¯fRê¶½y)±è³½u¹e%JVM1CùépwŽèí}ú'?é[k\ù ´‡ÃM·;×&QLM}S+'KqJ} 7ÿOOö¶5mïZŠ•äpŠölèX ‹¡p¡Í3ºVüx=ú!žo¦Æ_²„-ÌŸýtŒYµŸzÂæÖ(¥{ƒ½trÆ5í¥˜<ÓöÉ3õ“ç·0„x23íh|¸>ñ¬À”òÎ?¿¤ìú„3t¦~è¼ÖuÁIiP ™µç[âóµ›3ëUÿf§êöG¿òTTª¼¨¹3 dT–•6.|ß-â— hž+½®Ýüúþž>®(ð)}ØñóêÅŽ¡öGD눎¾Ç ‡†Tÿ¦©†Ä;ý$Øõ¼…>îXÚ°gð–ôÿHhþ½2º>»þô‰î=ã÷…¡²öBÈ|!4 mxW^0ûî4K2Üý”f¸ñi ëKÍ÷fc™/Œ;°u'çjï¸í5x rºÊUXÙôi¾—ÌbTÇŽ÷\7…u9c`o*$\ø;żm(8í—”ß7µ³ÅôMÙºò5ë!qwËG¾—ˆÃxÕsÅþ÷ÖkFžŒp³–Óp4ŠF¡cý~÷G?‹bºÑy]"èá¶Ë;Wƒè‹û#ÏÿCso¹„;‡Q–6t?Í¿ÃçÉÑŸGÿNÒWëendstream endobj 5130 0 obj<>/XObject<<>>>>>>endobj 5131 0 obj<>stream xµ˜ÛnÛ8†ïýÓiœf%럀4ÀnÚ.ztS/zQ·-Ò72©ŠTÜÁ>û%Ë˨.àˆ*b¶%ýçû‡æ×^þ…Ì+Y÷þ˜õ?À/wÿò ÞžAÀlinMñ-oÀ7I?F>ŸÌþé ÞŽ¶·õ9eBó%gyu¡~¾ \A–ó;¢pú?'RhöMûÕ½ád«â}ߌöçÑh •Ì5/ŒÌÕ8ûpIıÅ4P¶$Eªä«baÀI ó>_ ™3:?i=Îć+²f*# ’r¢~˜¹Àë#Å9 ‰á¤©Ü0 7,g>ü®T±æbuÐó­ãúð©Nö¦]j–hF?cæ1 ®‰ÀylÓÒ:ûaàÃŒ­³Ô,i³ö¦cƒy#iν‡MN² Órh*;XÆ0òáoa"£ ˜Â„@’¥ÊeJŠ<Ç¢IïAY&ssÕ³}–b3hιü;ŠbÁ³¸Ï<¯Vx‡Ïž¬=ï&г§²J¡AJĪQàpËî72§í“3D°$zq+äFYÈBÿPM?·•öC£{]³ŒañR8ZKZ¤ (Ç…Òü޵—EKú±„£K|'šKr‰&<ýTÚVõN($\óÝðOÚ5Y/øª…ú ÃkÖD)Ü,ŠB1Úæ9g?B×»’@’„!ÓÊ,‚iD°Âõ°”9,ˆbò͉ì¯î"ôÈ7ß²”'\ÃnåÔÙ‡£p[-;ŸòbZî£Ñ 6\ßEÁSíaG6)h]vZë5£… Xx€Í–¡³æ»<¤;´öš¡+\hP‰Dcµûò÷kÇGo½²›Êþu®ÚÌ®¹øð>—¦R÷aäÆ%ÊEÓ&«¢ÕŽjµy~Ò>GÆh˖׬ü[.h“`³mÙßOïÃf·Ûj,Zók–¡Wæl:¦À–9c.àáöq»Ùú¿æ÷NÄ>/XObject<<>>>>>>endobj 5133 0 obj<>stream xÍYÛrâF}÷WôÃVÀƒH\©Tewã”6·e“‡J¥&3d42!_Ÿ3º Û38©”]6¥KOO÷éÓ§‡?Îäág@£ÐþFë³7³3¯ïábõG/éòÚ§G³…}(œâSœ?€Qw4 û¤6\3£tï‹×$–Ri÷Ïg¿Ÿ]^&ûW{ã¾]mwçÃpLÅÝÒ®½× íÝÑdÜ´wº¹ImnÞŸŸnpZüåדÍM½ÚÜç¥5šw3Éôn~îÆé ¶Û{I»ÃÚn•ì—ðwTÛýì%ýõk»$ùö%R4LÆ<á†iuJì ê 'ý)þ†ùƒ ?íû4ÛmxJLÆdðiÍ6)¢ë{^ÏŸNçç‡uƒzì }ûRŒGño•Y ¹¤;©¶’Ø­Ê E KSêH¶æ>ÝœVž¾‡ü¿a)?0K"%!#µÞØ`¸bÖ÷€· oi-–+C·;If‘q6 ÌÞñæ3¼ --83™æˆð«Te:â—¯ ÓKnÜ+χܛ‡HÉX1M¯éžiÁnNk¶£„³;ZóµÒ;÷M!?ò”ë{;Ò­ؘ3Ù1Ä6›d‡Hl˜1\KDpªAȦ˜/„tçv?D>Ê<FQYŒ®‡ûFÑm\+ûC—J‚™ŒŒP¶^fk.Ýá"G‡Žh ÈÆÚŸöGÈÊ›¶û¶ÐË´ëœá®ýL¹©A¤ÏuÖ}u`£^]sÿ·Ëƒº?Ê4Ûl”¶E›“6IæÎ2!è»ÞÕ L‹’|&ÝC •ÔÜKÅÿúÂSßÝs(—,QC;æèn(ªdI*Cuìç]YpÈŒGw–Ût†¸-”¦N«ê-UõÛ);×ÑzÐ!àÀC³ÒjÛÉ…¦XRQîÿ3⛜ê¥ë=ÖׇØÃâØ¤Xo´•¹ 4h]0€µÜò¥Š®Ž_| ¶œ­lÙ]j¶Óû™LÙ‚ÓVƒ®‘…‹¼*D Ç ³™¹Ý%‚žœ¼îŒÚñ Ðd/4;³RÎ}j 2xß°Pç·i·š [r²$¹Â? cÍBgÓâ63¼˜6‹öè¤2›h5öÒB%‰ÚæMœI[ !èXÐÊ&Ù+–%—vø©‰T̯Ú8°‹k‡8(†ž§F¢a¡ìÆ`¬÷YbäE,IàaîÄåõ?…¡RP¥›1Åè˜~“"d#âÞF°Dü•“ "h#ššøêJ”w¸þ-©{3ƒâP¤%Ðr¢@„^®8Ÿ–ë½Ebi\+MæÝZ=ø´V¬V¯YdVÑp‰Ì}ÐëüÚg U ïÓ÷šß •¥‡Ò6ú{÷14>c>ìÐp=oÊ:³Œøÿw½Òº–>ô-°¨4b!¸nŹÖM8†(Í­¸³5 "bª_r-“Àµ]ï¥m;sˆIZg˜)VìcÑžôs°Ÿ<Ûxæ§rHI¸\šU%µ1‘FLCD¸o|PÌyü¡ äSÚ ¬sÇw[¥ãÆzˆ5†¥V-|Ç–o$Èá*ç‡ç¹-öÇZîsaàAȼk:zS[9=’í¥+«ía‰³(…&ï«Ïß¾´G\„9÷!-¨E{¹í´ïžc(¦=4›ó!—=!;ùby…laÝÇüÂNÂØC†"¨ÀÛ];‰OoÆy/°k-8ÎbJè>/XObject<<>>>>>>endobj 5135 0 obj<>stream xÍYmoÛ6þž_qHWÄfE–ßûmM›-Åd‹ƒ|10Ðm³•IM¤’z¿~EÉiTw­.2Å—»çŽwÏÿ>êPˆ¿uŽ^OŽÂ Äàæ#[ÐÙE:!MænÒ`Œ§¸˜€Þêw†ÁéäÃÑÙEgTÎj·ñ$nM£ÁüÛj ÷®Ý‰ÜÛ~gеÎ,›ÉDÚ5=°LIµxE2~٠ܳEsŒužîÕ¢™$4¤ïEöIk…¢ÙzÛÒ¨¾T+âÌ’Êe¤•÷¢8ì+C&çKb†î¤Šõƒ9¡‹_&Ýb—°R€©˜®&7”«DCv)ˆ'̘³•ŽóDb+`(î)Þ ”ÇâkHE=Ô8 —+M˜ÓÖô”¸V–AvRº8& IùšVÂ.uLr¡t&âWu4b3f¥VþÕÂR•Gó¼–goDã:Ô&tR¤u¸Ô­zBzþõÙuCž8€•¶däJB±dM+–}±3#ƒ/–R-•ÙV<ÇS£N@—I",¡X›åÜꬾ¦Õgc•Ë·°ÖÛbÿó£€nᬆ)‚Ó’ÀžˆòhÝš1—¢—ân \Ä@›4^ÿìý·¾§Yê<‰Ý%«pÛîûkØÝ¦a ëg‰ð ë[~ýÆä.õœÚÑ(ãsàîp§ŒƒýÎÔ"g Aeˆ0©àr.9M[Ã0lÆãééS“!è¶£^P‚QG¼Ë´ZøØ2mqÁ~0Yý,x¦§Îú3Ÿ­ñäOÚ!øx4ê„]iú $Ùu*V,…#Í¥‚sÕ¯„›òT§DxÇîÙ>"ø€9ê '‚ÛüpBà^:!Ìa¥Àݹó¹sü›@[³Á+rA»n¬ÆŠµÙU> è}žX™"½IµDÀ·Lñ"ËA8OSdtøÂŒ³°s¶¦–îíî§•“ô½} ¼“%òŸúÊ`#ËLÇëÃùìp#‡ÎíáÄùsW¦«,Š€X•RÄÒRPðªº4‡4X;$ˆòâEŒçúže’) þkó̹äj_†‰ëLuóܵàõ~Õ¶øô]J„(ZºÂ†XÌ/‘ðé½4å½»ºt¤“g2u¤þù#¸*"ëq%ðR¸;ÇĬÍä,· 7¥ðRÕ ¸ÍxÇ. lP?®`ÿ’G„¨;A]¦Lʦæ‚Á‹t•d)TuZ»E¾š¨©-ÛØå#è›ßt!”@%…}¸Ž¡3[•׫Õª+@\ê£X‹'nïÙ‘î8GÑsQ­9벂ÛÅTEŒsT—ζÌU(>‹â²šþ ÌüýüZ¹ ® ª:êú8ÄÝy•-v'xç/л®§w¼!³j&ƒgwÜ<ˆ”Ü¿pžÖ ßý‰]×;nšÓºf*xRÇM3J×LOè¸iÄš‰àÉG”:T¼ïÍUzU7kwšÓÛŸ!õv`Hî®5çG,Üó숛M–>¡{`Fç/H|â"u=ÌMÖE‡Ê.3ý ¨íš¢?a†KÊ`LåÓ#9ÙNJÐÅð\eÓ¸«TlézW·jŨCI€£oà2ô¡ÑÅFû†ÑÍÝå¯ß,Y–Þ{ÒþÛGU=;v}g@P¨·áKŒú®ù†Z¤~ý#V†î%óm>ÐrÖ#cûOŸÅ†` ?bâú·ë½cÃ4äV¡0Ô …æHYÆ+Vç´Ÿn¼Ç!z½LŸI‚ª_O:Ã~0èöiÐ-{~Î'ÚÝ ¤7šç+¯©Z÷í(ì}ÌmÝï3e±Â ~_rSwC¦­>Z‹ýªµØA7ò¿ÐDÝžÓåíäè£&Sendstream endobj 5136 0 obj<>/XObject<<>>>>>>endobj 5137 0 obj<>stream x?SÄ Åû|Š-sE8È¿ ­£§–Ž86ׄDœN s“oï’;­,ŠåíÛß¾¯„Åà¨ãíæäN$”P,þ>n„ý‘ËA ¨­›D¿ýS]Ê*ÂÉÞ¼rЫAÕÃ)å”fœóÓn'>“ý±†âØžå%)Ñ Ê+0ËÜ*ç¡“Z‹Çîv…Õ.ìÅ€<Ÿ'ÝÉ ­!W+$Ù®fÍÕ !pÀ“öÁºõ¯‘tœ ²Õ“+ 5ÁÙ .ÒmF˜•÷rT í|Ù÷H„Ú×÷çÇŒ‘‚°üÒÜvÊiIª¢ÎI£I7iA(ÜÛn™• ~¤Ê~´Ù!æÑÿ'¼ŠÖ¤È19”çEmDò’|³övíendstream endobj 5138 0 obj<>/XObject<<>>>>/Annots 1906 0 R>>endobj 5139 0 obj<>stream xµXkÛÆý¾¿âÂ@‘(‰z§èÇðþP u0,PŒÈ‘41_™!W«ýï9g†”ȵ…»¾Î}žs諒›Ë æ²Xóo’ßÍ¢žðÇœ?>üx·XG3Y¯ÖÑBrÙài+dòÓ]OÌeÇÑ®w..—þâ:Žæ²ö/†³EìÏVóh-k/ð¬'ÂànpÖap¾ˆâÞžŒÓÅrp5˜ŒgÁ]õM®ob.»Íà¬'BélK“׋}ùšÛiÈHksŽ®zwƒCPÈÄ.}(^ C=1—5s¿¾žõDägü^Ïz"ݱZ×þÌü,¢mÿ´'ãtµ‰–ýÓžŒÓ]ÌÜ^5ûPV»€‘í 7ƒp-õj`°á¯ ð¬'æ²Ý!”ÛYO„Áxx±/ãt9\íË …5»)þᡇru{”éýNæ8÷p!ÖÛ8ÚÄòz*Ìä!Í×ò±´ŸLq”³©Oò÷2m2í^?üÒÓæ9ãµ-‘}ê«&ñ*Z®ÖÐ6j/Éû¢¶¸ŸÔ¦,†nþÌ·­Š K eéè1^odøþçùödNçG?(g’.~S'-?}|ÿ£Ø¦¨M®%)S=tð›Ú{÷\k[¨LT’hç¤.¥† ­õ?Ñð9—6•ò ‰jX5Qû²©ÅÕª6‰dfo•5/áðMcÿ Úêqÿ‰q~Ð@%1δž­ª*må`2-Îüûÿª¬'Öd˜Ä[´Vþ„˜‚R€ê×(1½ï(4Ãe´ÝòÊ;•œÄOe‚¼£ (HÀŸþµ1V;Q’{bJ¡Gàc×+˜ƒÑi$lÿã¤q:å‹áѤ]“Õ> Êu-™*Ž:†ð;ni@±pô!è‹äݳJêì"瓪‘?¨Îµ*àR‘vÏt°ÒY=”VR]é"uEÌy=49¾£ŸU^¡|nztŽ$ª€’ƒ)4‚qÝ¿í*•hšøȈbÔ‡& îÐÔ2b–¾X9錥O2åœv¿@q•e—ñ5ÉC?ʼ²/æD‹#çcQ’œJèB«È2í; «xÌÊ=xý©=|˜šÂº1HfÑ*Ý´uÆ'´D.¬¼¾ýî;©/\l‰=´^Ö™I"šªÊ@ GRRŸK9« B䃱®Ô€°¹ˆ©CÇgöý3øIcÓ{,I¾Éþ0žv¸I H"ˆ'MåPz•‰Ë˜$Ó” W¦(Xz»¦@ã;°Ž¬Pðõ¨ má Ê—‡÷ú&Ä÷—\1@¿˜LÂʵ€”v>?ŽÊŠTšÿíÕ“Ê=5âöAüjEÑãëçþnüœx½‹há½g&@5$Åó žåàªK{ñõcPÁ’¢³²€h‰»á9»|šúÆ µª0¡_*“‡R”7vHŠ+åúŸ"ùåKÕ|%ÁâtR’ÛêÒ‡ # »º_ø¼+H ›É— ÀŒœÉÂTaR|ua|EÍWEòþ0Ü<¼£mC}Æd@ù¤­5)Ù8|M¯9–=ðytHŠÖ©ÀØ'ô„@?ŒÚÛžÅö>f»²Î'¦,PyŒ][Ólb òDa@GôÈR2\2è—²‘ÜOõ­K¶¯Rõ 17–ռ;åÄ•$cT ý†KN$?C/¢f#Ë+NH`²£k fFÓÍPÞJ0NØ·X]„„ÄFrØgìúWÐ2ÀœèG §ò¬Q€1 N8³¥„Nð/´Ëœ[Èd2a8¨ÿÀ¶ZåñÆ# b«Ye_n–ŒnÆÐ ÚòE46Jøî„b$úº¿:·4¢DœÞÛò„¦b/CsÍ‘.hªŒÆFó²yãýä¤*ô<Í%Öì[àµá2¾†U ÓÝG«rpÍ·ý¬ Ìá2`„3o8qP8ژʖ±&¬ã]ÜÌgïÝ"àP×'ÄéJ!‡ìÎÝB‚Ù6Q÷aï½í=±Üvó['ío:0½çþŽ@™èD/¾‘äÜN¸´0»>Ñœb™)k9©'\³¥s{Ýåqd^ÿ¾Ç&“Øi Ða5ÁØ—·òæïÝãk´®)àÝÁd>›#¢¯° ‡ÍÁÊ&KåŽ4ÒX¸$·3l_>ËÄÓѬ3-yFOÇ•(y~úÆÐ?py€j &Ýx‚½´2ZE=ÍJ•­~[ô %ŠÐJm·ÎuŸ ¢œ÷êì]Gò¸±òƒŽâ#âôìm?²Ø2ýÌRx̰X@åùd®ØrRè°iº“”3·gxhí–7Åá@lAéWM¬ˆ^32dt…r³­ !¦Úš'Fy°%òTÿþÈ›Nå­ë{"MG§N©ÿØôÛ–?ÿ ªfÖä°eéHX$®|=¾þëàõÿvâÒLþ+DÞ˜Þ_¿xýFÿMØÌ©üw>½W3¼‡¯ãx±¦šwwÿ¼û "â„endstream endobj 5140 0 obj<>/XObject<<>>>>>>endobj 5141 0 obj<>stream xÅWÛn7}÷W \Vi­‹£8.ú´q‘½¡òb  v¹ZÆ\rCîZŠü{Ï\É+ÇíK†-iy9sæÌ™Ñç“Mñ3£Å’óúäÝêdšMñáþÛÐÅÍ”®²­JšOiùf–-—¯iU„USZ壳Ú–´^þ_¿X}:™ÒVÅèì¯ôvÞ~£L®»BÒ)oȪÓÁÓ³/÷Ï,¾\òÉt£´¼¦B:u/‹t{¦†g$|ÃEiI‚¨êƺ6BÚŸÒ#ë×­Œ¤£pr-¼ïÐ55ÝZ«à9gSƾKh3Z!–@úÑ•gÏçëqZâÞ?>~ø1F DÞê]€”ѯe+Í×âɪãhJˆŒQ7HµDHvJŸ…¬ãíÊøVŠ‚lùÕë‚ZÁÓ¶RyE)¡ÉÎ ©]XéÍyK[ëîHhMZ˜M'62æ3ºÁÄY7ZŽé·][YCN~H%è4¢ÙÚƒª$Ž*^ÃM)”ʇ䑷¸ptõ°‹+pl. •He=Ur8äÜS-¤¾Õ®Q9 ïhg;Ú*±‘- æli+œQfR†@ÆÎy¨•÷x>&¹ å4ô¨É|ž-p¬âHß™º¾º¦éðËéìšÞ"=gÀç¤6ÆB™4ÿ¬{Ó³.gây]Fï+µ‡œ-Šrð³‰RD:ÅÅ™9ÔBõÌUÉÚŒ)êŲßžôº/μ…åeC­±ã>2…¨<Ä}U#Q…ôʉ5ÄŒ¢N%ÄVP'ª.`q‚ãâTÇâ8‚Ê%͵›ãÐ ¶pɤô5ô\„êà›ræ;ÕAªW¬%§jUZ¸ 4 5ÕbGk9Dï±[3aµhá+ÖQЧÎ#âhå‚|Í%ò86[²‘¦0àv×HgÅÖ„Àù6 ¯_ïúÄ0.À6­²FhŠÄï4æi˜›SëÑÀÜxûÑ®g ã^vÀáž}‘ ½;ö¼G.³é+VpÌQn;]phN6>\ üÚ*À*­Öv‹ÿ¹œþë~{;Š´}FÔwOo_ÿg>PzT\¿ØÐlÑÝè¹â8Ó©pƒk°6ÓÇž-LðlŒE¯B <‘Æ× õ0b;Ú,Oèi+QáÆç”ôŒ Ÿ^õ/’ fÄtÉÞû6õrxu g-á¡úˆ¿ît«Ð©PÚ}%¦É®U¹â–,†€;Y\h £bÃ@+v¨n©©t¶>ÔV‚0´ÏLìk%Ìpá{ $cIÛüŽKzZi Ç'4Ê8«0Þ1Š„;¶Iû†f—Â*11OæWü²Í–<#×áx×vYŒ6ÅÑ8(É®®xÏÏÂìØy úbË&×îû¸G34 Ǭ,;«·†‡¦º¶­3ö¥˜S:}|{vʀే]à|À:Q-œÂ1NjÜÄóLPl›!ùf–:M"y%ó;Œ?68utË`¸.ÑkOqlk…Ç2ßax¸8|²å·L5BI àÜ Ý!'Hé÷/_fô¹K$hrøZ1Ø|+Ú470<`>"n¼¿ö'q/ÆÔ.Ã~B×ëNi´Cñ°…Ðo€‰ëµhkP ÁqÞ¤HQV|C±C°]àô¤ÆIf·Gà™oä>6‚AÒøò‹›«4•ϧ—Ù«Å+Z.gÙ<ˆ†OÙ”~°yW£a š+<).ž¼Žß® É9O5*ðj Î!ZHo¾xͽ_ü~ò7é2^nendstream endobj 5142 0 obj<>/XObject<<>>>>/Annots 1908 0 R>>endobj 5143 0 obj<>stream x…XýoܸýÝq-PçUìµã8ýòá ¤I.q[p%î.cIÔ‰’7î_ß÷†¤VÜ$W$°½+‘œyófæ ;:S§øw¦Î/ù¿lŽN‹S|Ãgüñᗣˋâ©Z>{†Ÿº:-Îã‡Z}<š}lÔÙÙÓb9{8ÿŒ§ç—ųùÓÙg<}zZ<™=}q;³DÌé7êñë uvªn×0ùòþ¨ÄRüQßnêÇv°Që±-ëZ¯toT×Û{=58et¹Uÿ}óËbcZÓãÛJ5®kS¨Û­”õ'jøáN•)kìX©¶ê'?èÁ–?=ºýrtªgKØs\ÛöNoŒÒm%‡ß[oWµQ®­h7ßõºëL?3³2kÛb_Û☱·)®ìz‡]špð°µð¬ÃwtËšÝÖ´™)ƒóxÔâp#^Ç}¹dôé8£¼fد¶%r-!pÞÄ·½rëÁ´ª5Xü– ¹k×7²†øa[ë3ŒïLiuMßûq½zùóωÛôºñ Fc3FD5£TéêÚ”ƒÀš¡ôʈQ‹EvÐm‰ˆ›ZŽ÷[ÛEÊÞùÜŠ€¦Ââ¶Ò½5¾ˆF./²[øäê{bE² ÝZµífî¥Ò²{BæDiÕ9ÛfŒí!.ÄÚˆ„W«MíVºV÷°C“q“6è~cUëv3’J-Âã;]‚£¯ÆžE‡lk€kÿ›¢vž];]ÉÙѾx~¥ »ú±FÞÒðÌŒ9ðëÞ5 aLŽ(A$+´Z›B3±çñe¢d|DùNѶˆ1 ÄM®s¤V V—$þÖîÒµk0yðje†s\)MH¸Ö ª2Þn˜t@fçú;üìpîS¦…Ê &¥BS:8 +ðöcgòÝÏ·ÿyýùöù‹7×< üº·X¤ÕØÚßÄ@.DdVf«ï-…>®Œ2-¢æ ¿‘MgQc6BÖ}ûÌšR”_¿*×g&ÄjmA¶ÕƒÒUÅÕ‹W¶ý­y€i_{¤[b3Žk7N„ÉýflL;|| )o ç`$MfôRÜùy;‹hÿ¨²|tʮՃ{ÂG3·š¡íÍT°@ì¾ò[7ÖqÌ­ú?– ,Ȇ4›ÿ»¦¿@½Òíƒr$V²þO°ÙÆì€ä¢”5™É¸×ÚoSæ‚ °¶€€q‚çØ‚Û[ïA¨PÉÐmbVíyƲ@wt…Ê¿6ÃC¡nÿ;Ä$fÚЃ( ;ЇB;Âî¡I°»†48Ìß ’À\NÔû~ì†"¤r9ö=„vP9øO×§„Jµ+ïÀÎ~9³+Z‹Ö „>Ñè;˜ÄÒ5ë—Òî3CbõóèlB…z‹P¨Öc)5ß_|¦¯zÛZ™*-÷ I4<ýòeo»ß¥:í“+…zwPÐ^F6VAÞEXú„÷Ê 1bÏNïZnIÆ„Ág0‚¦¢ëM§©af5ÍF¢N€ o†ÆŒX"„„59•Þh蜄hÅÂö‡PÙ‚þùööæןÿuýáãÍ»·'Œ™È(ô]=ö;»Au,üŽnTP ½˜®c›1÷äš Wf_ävPíØ¬Ài”d’¿ì KO*ƒÜ0oa^•P:°S@˜Ø„ðt`ȫʮ™mí `ާRÌ !;@Dž€«¥3_­'‡CF ÷§æ)¬›bRÃØõéø bÔÏ~z¤:mû“ìü Š°×c|™7d°i:fî;êÊÄ£¼ÄÑ ‘v< ÔšTXþøõ3uvQ@Q]/–Wü³:>»Äïë¯P8-d‹.KãQ=± †Õ{e¾X^WW\üܳË"SV"NæóT}’î Ñîn¹5å lz?MÇ¡íE~0 µŠ¸£Àþ:‚k¹uXû½·ßšÝû ãÞ­¾|³‚<–\av5†fæ|IÒ˜]uÆT…z‰ß¡b°{ìm JJ2¶Ñ ‚»Îõ 6¨ ¢³¢…Œæsm@˜ ¹7bŸÏmŸ¦vÿ(‹y!´Kêû0Îý¬ô½¶u!è,´É+º$FIF!è!P‡>Å&ôR¤†„% ¦cø U“-[4$öü¸]›Jƒœß•Os„z@9.d0GÞ\cpp;"Ž$ fùsè +h±$©—Åù9>UÇT,TjÑ=`ÔiÕÂD†/"§Õ_ ¥ÐßsH²ÏyqyùTfÄ*½9 $ñÍÁIÊ€>/XObject<<>>>>/Annots 1911 0 R>>endobj 5145 0 obj<>stream xµWMoÛF½ûW •›Ñ·÷Ô4u HÑDE.¾¬È¥¸ Éew—’•¢ÿ½o†2e'EE ù3oÞ¾y3ùëlBcü›ÐlÉ?qq6ŽÆø†Mø×‡×góÕ"º¦Éê:šRA‹É,Z´ŸrúÈïÓäz!Ïæ~Q>ð£—ëÑ$¤ÛÒóÛ4™GsZ§H¼Dì%­É8¦u<š,þÚ[—M)Vu0¶$µ±u T01åfã”3Ú_¬?Ÿ=¿ÓG9ÜÕt­Vˆ7ú”é’ƒ|1å–ö&dTÔy0U®éã§7¯©°IkI[“Ïl'Ô„NSiKµ×RFtké{U Ö%™T"dj§Iµ/3*`™LHƒõ@ Tp%PùëÔÚH +‘* ˜›ò Æ6Ïu, €Œ‡È›¢B¦BKÇá’´ŠQ§T†ÇyN[ÈOv_RåÌNh«32ý$ÐØ&šLéµ :ÁàÁ„ˆÖ™ñ„Ÿv|<è²-4Ñûß×§Õì3¼WeÚLÃ%åZo0\êû "Xݘ¯ÊþÊÙ­Sm4x5ÖE ¯69”ª0±ÊóåV%jƒk~ò†YY¸Â8¯½Ùiø WŸÅ%Y‡r½š®X¹ «tItª.ãïéðU­9#Èñ,™{„þ6OS U½`ûJ@^a¶Y1ÐÆÖZÜO¢'ˆmé!p$4ŠÇ×Î\5¢·6+éÞ™Rÿäéü„¦—ŒïÀþ>ç{ÎÌ8 Ø….ü×à#©cî7®vïTUiG©Á]xóUð<Ý«z>tZn'p}Ú:ÏLQYNµ–` ¸OFÏ ë!6 gû¨ )îP%tÂ>$k®ÜV÷‡}DoJœE€½:4gßÈe]lP:'1©\|éEظ™­.µC§%— Ãé "í¬I:fÚçìjÓÀpÔ yH7Î;ÒKlkv2>žíJ¸"êö6³ô”¢™ åãmð4Ù&>gë-X]lvÈ„± Á€ð¹bëiÄ‘jj§}+ƒ®ïÅt¹%®R¸ŠO.¦çO ä‰èSµgI–Q àr›òˆ3Un;:ůzÎÃ:=‰{X= ‰º »Óž6¹‚ÝrÉM­Ÿ- °ý,œÀƒ…›â>ŽVÆÒ:²>„Ž>GnÇA¡îMQÇhž²n†ý‰‚’¼o±'¸Ýj•Eß—ó}næ*…Ú¡ö|MóÚÖðõ&(¾ÒòŽŽø€89ŸbÙ=SoJpa‚‚ý œ&3¿‹³ÃMƒuL«hÆÓyÊJ™F³>%#\z© º¿»$Ɉz(Ü4-ž»ÑÝÅÏ'¯EQ?äà?Ý ÈtÌð (w°õ›ÿ!×Ñή¤ºY´\^sî÷Ö2:¥‡"åþÜX^J„m¬!{îtÅòù|³KpaZ°ñ·á]ªîÊ:–dûàDÝ=´sº%俦ÉÝ<íV¨QD vªl~(¬«2ì[í®ÙT Å­¤?¶irx)Eò¨Æ´{/MÇ cöòn!Ÿ@å%Eô'³‹CŠD{Çx\:«í[u7ÁuÞ³ÖöîFç­E%:U˜´˜þüîbˆ©G, Ù•¹ nÜôàqtP[°°´òàäë¿åíµÍ mkŒcUkØ£ï–ÃRîãdyǺ=j2Î]D¾íþnEaÂù¸önÈNÚÕÁc·ÉÜh|™ í0XµKàt<³-f³h%‹¯¬W3üᕸœã¼h™æå«kV¦ìT?¶ù/ÆËh6ÅÚÃÓÙ úÛúì³¶êdendstream endobj 5146 0 obj<>/XObject<<>>>>/Annots 1929 0 R>>endobj 5147 0 obj<>stream xµWïo£Fýž¿b>:ºšÆ˜H§“8‚ct±Iz½ôÁk›Êü(àK“¿¾3»`Ö·‘N%‰?¿}3owÙñ_g¨ø«ÁȤ¿8=S?¡^ü병©¨`ŽMe)þWŒì h8Ãàœ5Rt09踑Î9MÅéÀä¨#u•“‹9 N‚)h‚ŠRd£ZR ‡IÇ—"S ?¶@ Ž´Dªæ%Æ9 N‚¨¨Š&‘\q†p@LÊA7iÃiY7>"_i!Ç<(P‚)L4rîÀIÜQiÒ‰oTë­¦b6€gÓA D§dRÆÈŽx‘| •1²JZ¨+D5±$Oˆâ$ˆ¾ªdÝ“ Nªóô¤˜Tm¶$_V‚†%<×T7ˆ@Q& @'j kÇqŸCé¤òãZnàbz‰V¡SáµiéÊD‡pų a<Ð&pW%Ù‚ïž“z qÅ[ÃæÍ°zN6íñÒ(+¢ ;ÿ”¤øCK¸¢$„¡ŽO…±‰Rƒ…=w#ºä4« NÐ? ^ usÇãß*Ðè¡F• ‚¯‹åmàÇ!ÿ«Ä•8¾wzËE*K.@p7ŸÛþ×þ•zTðAhßÜØ=[æþú64ÆõXŽ»¸÷üåbî.B¸·}Ïþ|ãö¹áÛ™¹x¿»0·öµKÊ=Ö'ôœåüÖwƒ ßm>[>€ÂÃÒÿÒ§…w·¸GTöà…3¸ò‚Ðqzt1˜áÖ@Q¸jJ3,eÙë#âÊ›N]ß]8nS9ÚÞë÷]šã»W^ØçΰïÂÙÒÿ™Õá—©½ÞqCÝÂ[›^®ðÅ©½é.¦íM¨âC±,"®U~›âÝÁ:ªjˆó´Hv¬~çRR²…w:ÈwÝû"ßăñ^*%òc[õOð­]ßöizõîÈÏz?\Ÿï'žThO››pF¯†ª`lUÁ¾€’ ÕIžA¾çÂùðá‚71q¾bðô©³)Jö=É÷U;%Ξ­`Åj×È7öˆnâyË2¨±û©¢”µ€ =1šj•g ¢M”dŠÜÑ€¦k*v(Tí‹"/kXç%ï«ÚÁ\XÞQÉ`_±ÕQIV³2ÞFÙ†EO»H(#TXåñ>eY­ü÷61Ú%”;‰Ó¦Ïês·«}šFå 9IÕçùZAËe6Â*PÓËÊ!}{!X †œü©¶ù3T5.TU'1yÕڊyÏ7|= ¯¬Ì¥Øã˜øtL¹Ïh÷ð6Þ±(ÛÇqÎé8[òâ›X<™;Ü#»—ãð)|Ì>½¢b5¶Ç'é>…5žèŠ–íp¨ñ SkŒ.Í߯’W\uSÃã7\ÿsÀÝôåñü8íÛTè¾a¶lWÀ¡a?¤p:¤(qãÁwVVt¤²}úÄJÒº˜¶M:Vß9,M£J~ö‹ÃXÅ/nºèõuC%7<ûõìA=ÚÜendstream endobj 5148 0 obj<>/XObject<<>>>>>>endobj 5149 0 obj<>stream x¥W[oÛ6~ϯ8óËR4–í8q¼aµM¬M»Õ[·¡/4EÙl$R©8î¯ßwHÉ– ÄÃVÄH^Îå;ß¹ðï“ ñ3¡éŒ?²8ùiq2NÆXÜýªV4ºùŽ&É-2œžÍ/“-ÒpfL y:¹J.éÝûÅí»»ÏŸOF74ÁŸž_$ó9ŽŸ.ÖÊ)²¥×Ö8²&ß’(KüÞ¬•¡­­I›{¯HJ!׊„£Aü:t½$ô‘ÆC)o ’¶(u®*2Ö@vF¾§$ÈOèÖ°U°erΆøµð$ŒR¾Z"ß‹j-ŒÆ “ÛÜÚÖyJ•Ê ÍÛxµUï(µ².”ñ‚½K"—]XñpÝG7&½¯´ñð§Õíê¢Õ–J±R}aÃý¥¡;.X¬« f‘cËœ×ÒQ+;³p„0Ú !<ÝS¢âm¥Rre¥—•u.\qõ2Õ•’Ø× ± ¸7‚ئÔ¿9mV½0ÒÐ H¤©£ºŒ²ö–5DžÃÈžŽBÉEýÞz‘»˜»È|y ™¿Te÷^w>"ì÷§„Ũ #eTå2u±TU¼Ö² kž|Jâ‹\ Ó±ý®ÔPŠ\ֹ𪳕÷ mͼÁ)§¿`7âBwÒH-¶m(ZQÃac=-%•sÌ2ˆ´ Z“÷J•îèÜRåv$ºRIiP#×…FLO Ѳ¶Ä›Êq¨-¥ìÐQ \›nÌ; …ªÀ¨ wf`¹°ÎËک¬ÎIg! ajPd‹ÝTgÑÇh¡´ÆƒìWÁÁ\« ÆíhaêXVˆ-c¡Hx„/ŽE-æ´#/b&œ!r…}à`FSâ°cî ýPˆÇpêǧôÈœj’ÇuQ é8ÃmVj7ˆ‘î*¦ùƒÈkøŒR\§Ó.·Úä5N.„œæÞ²A»ø°SYíkö7–a—ÐKF¨ð  å¿‡ÚxMH6[/¬‹r\qTÓ)VR»åQ–Q¨GÎ÷ôuîu‰$€Ç“Ù‘¸½ r‚üGD#«øbB¢?Iäfä>€iý2´Ò+±ÜzåΨPÍW¦à½ÎmX§ehuʤ ôúŒÞâ{³§ûÏ­¯¯¨Te^28;%q§`Æ£ØQ¯½u rû*Õùœû}ʽ}F·w×oÞ\s‡ï“lè6xp‡ßX?S†“·éè{• *Tt•éÇ^+e*!ÁÑ68ÓëÆ”ÇƒDKB5=F¸m±´¹–(Kæií7 Cg†tfþQľ&€]Øfºr¡ôkxÉUv™e4÷Ò¦}®±¼X`’VÛž)¶Æ•ÈX½ÑnÝb¡=qçuŲ)¤HØÏh§H ¬s ÚÒC š*È—wSWp£Ž÷‘š=kº^Æââ¦2‹‚ÈÉŒ›µÃÄÁ|e”z@w¥-·=@á:{ƒvTš ©~Xõ”Þw2rüš3$טñÕ}É6¦y2mÆÉéy2âŸô”H–=[Fµ«F¹E³-µµ`åùÁèAgºÜ8ØZÉÐ¥¹Üý_ ÏŸ¥ _mÎÃÎD>&³ÙU>÷ÞFì7¶ºç‘:·Ü®qâ¬D¾,(û‡˜ ”èÓéf­ÑÒ!«v±5ƒ NÄáÓ³„®3toxÆæ4æÖËüm1г¹åI‚Q"¤XK!@ÇfßÎ-[écªCóR±\n%}æÝY¯¾¡—c¾µHÐZT<¹˜û³f¡W7`m8jHÀF ®aLŸ 9fh³pÂ.sU´|_<™òûÒyE¯þXüzýï£ð´aÏûÏš¬ÂHChm1iÙèKœÐêY[:Ùµý; ò8ÛÚç]ódÊMÿð,SR…,T6æ>,%ŽiôípØ&ν.¿e)²šM®Î˜¨8áºâÙ'VÂ]ðŒz܇h´9m´W˜é8J¡¨næÍóé||‘\N/ñîœ$óГ>|¼}=œ&c„µóêb?†íááUÌÚçéåx–LÏñ.EM8¿˜ðW‹“_Nþq®Ø6endstream endobj 5150 0 obj<>/XObject<<>>>>>>endobj 5151 0 obj<>stream x­XaOÛHýίXU'•H€(ýB(‘€pq­Té´±×d‹½ëó®1ù÷÷fÖvbJ8Ui¼žyóæÍLÿÞÚ{ø³/>Ñ'ʶNf[{ý=üØþU܋ݳ±¿'f Î}Á—˜ŸãK´­M^z‘èT™©!M,Ü–i,æJäÒ9 ™Zs/¼~¡Dd³Ç !]O»þÇÙÏ­=ÑÀìö Ï %58ªˆ¤!3:Ëmá¥ñ¿ù…ô"Šd„³±UN…+`<—…SÍ9’j£Ø£XyUdô¯ŠÞ†îºNçj_öäK{rå±Í½¶A:¡=ßKîÀ¿äËêBzNЛðÙB¹2õxØùOìÄm™FÇ œÃs÷ãcNpˆÀY¨²ÐÎë¨A t@@×pŒ¤Y ç ¾Š0ô+\Gõk@N"Œ xÊÚ3”8ŒD?¶KWÊ4]âí¿ŸÅÉR”ŽníõBšzîAçbiKÎgb‹ˆ²"š„–±žÒìÿíbΣ6Î+¹F­Ž;›hï@ºUäábw÷ì‹Ø?èƒ|DîÞà˜¾ÆÛûŸûÇb|u7¹™^]ޝfânx3ž\ŒoéÂõzqûÇÇôNMINˆ¦ÌæÈ$’®Ì£.¬Éèû( -ç)R†¨#k|aSà  IÄꋉ™u ·¤´b•5¿ª€eM"ÐÉ¡ŒÆ*‘ “•NÓÀ3áë(Û†Ãäíh4ÿ:Üt#‚ ôÝÈüêÔ‹a—«H'¾Và-Ê’œJå(*b”j¼VE¥‡fôñ¹ö´ë8ÿá·óéåx·ì}xDoådíàl|yý¶Pê“ï‡dÎ+"Y,™ëîyœ‡Z§Xz S©ZáØWÖ“JA†ÖnÜÊ¥_ˆ¬?VA%Èb¸p ögMêW6¡|~±Ó½Ô‘ØâŽ‚uÙqH¤ìúJ© ¾‚Ré*d J"Éme‹‡Wñ¾˜~=›\Œ7Qg’0wêÄX¿ô2ôÀÂtèS89‹ØS{‰ƒnd\&„KàÙ‚èUëö ïL£éÔ¢(lÊd”gR¦Æ 72z ŠmeD^XfÒîYS0¿rín|s2½}gìõKoŒ=Ö.O%ªÝ@Àc æAd™.móÔæÑF WÎ*zÎ:ºS&3AS^×Õ¼¼¿§ÈK£žP¤öoŽÿz8;ß”øïµÆ…åÎ@$¨©Jo’ð‘c"N¡aq«aÚÿ*!©µ!U 4‡´DHÖe}Ìj÷¹ >ãTÇ^¢ ”™zRQéI“˜¨ñvæÞÍ }œ(˜ŠG$He× ·Ìæ6E‹ÆøñÀBØ ²ª4yµ¶F£ÿ†îhDw…îJʲ>t´´Á ¡Ì'ÿ_Ä 2@SùÒ*11)lÖ Ô¶ÔWƒº¾ŸM¾m Œ‹3pFÈ8¦a$/T¢Ÿ("Š¥Ó¾™áu§)Jý‡¦¹GËÕ\Ÿç³/†)”Щ0:P}˜Úª›4ü†–¶…AˆQ‡>Š^ îtrK³Á¦èž©áKó@S!µ%髆?©%D tJaGÌ—4g×Ìí$,²ŸbN—¯†r3žN¯.¾oŠ…À­«¹9ºAÓTšBx‚Tóžš'úeGS,jÄë³°C@àÍ„Þv“äÑyÉVŒáÔ,yJÆ^µ,¡A£å¶Ä<RÊb0W‘õ©1M¨'θgMºÜ ÀÓÜ•A~1?uWf=•ĪfïXS¸¦£åó$_iÜØ2 žH !ÇìÇ£.sûùP ßÜF×׃MéyÕÈ̯<#Ô %Ê3$ziÝs!­Ž}`½ |äµA/¢v{h'‘rmv¾¬U»yuí1ú4…G+’Ó ¸áö˜5ŸÐo^YH·[àÄlLã ºï€Ôî™×­,'Èk^è 7¯'«žtK\ê±§ÞÃ./„¹E Qà$óÜQ^oVM‡§l±cð„QSJZ´¡}SÅÝcõä•q :Êfm[z‡Â¬:Z„@™»µ4F¼VClÕ T H˜½ZÚWÓÑô:|ûl‡Y Óï`ÏÊXà@¹sC{M†MÖTJ±©gO†öÞ"ÄPÙ-^ÄÎf_œÛJ=ª‚JæP[, ™VIB+3 .€Ah©Î …=¯9m{"rì´ÎàQؼꄹŠv”y7m¥£Aà HÞΆ³ÿF¶0\× ®Ã<&ú6Σ iíwuÐ@@!À®<Ö]þuÿ/Æwã‹Úÿãz3ìô?Š£ãÃþ€ÚÛ?'_{Ÿú{âÔF%­¯¬|es¸÷™þ_ˆ÷åÏbümv3ÓëÙdzÅÆ÷ŽúŸØ«qbpÀ¢5žmý±õÛ4í>/XObject<<>>>>>>endobj 5153 0 obj<>stream x•XïoÛ8ýž¿bàÃ"-6vçGÓ~K]wclãæâ´Ý=8Ðes#‘^QŠãýë÷Í’­¦ÙÜ¡A)äpæÍ›7Cý¹wD‡øwDÇgü“{ïn÷‡xÙþW.èÕ‡::¤ÛŒ½Áo©,À/ɋۥ&mïMél¡mE÷ª4jžk.F—ãÿN?Ž¿Œ?ÎHå¹[{Ú¸š*GÉÒ9¯©Âf[s]’Ë(×÷:÷üÛRù%+OT²Ô/oÿØ;¤þÑg¿HM©“Ê•›ñé©ÎTWd< ÛÂXSÔ¿9"eS±S¨‡æåù€í½úpÃê#®h;z}yqóþãdúkX·~\6É$¯+±ýO4¦x¡¥D¡µÉsRU¥‹,8ªÆR•)åÆÞyÊJW<<­Å^©Ueì"¬vÅÊä f]­êŠJ…3KüIYœÀ«eX@‰[¼ÏòjçXà•)_éò€æØž`[âlç‡~›€Ué¥*<¼½Ó´_¨;½Ï§àDoÈY*\j2“À5üþ ÿ‡ó™í0òÝ%£W£Ÿ¦ÚB¡·Ò4˜–?Š tëGµ€"Ç&-ìƒ7¾QÍ´mÌ·¡å6ö±Î£Ñ7]GaWY¨\*è€PÿM²©¾ÙMw;Eä˜þ¹©*4®9diö+­£ìâE¡´C8ÉÊ«BW"•Þ+[Å2aÙßÄm_°ªFƒ\àpt{ˆM m ½Ð£vÙR£©hàlÇYfðVìB«“DÈNÒœ€ÂeôŠXHMý ûº0tlpÍ 0Žb®ƒšHE1O¼–»À½óè³^…4AG}ØŒ¡Úh¾éĽ3T °€™A ØV¦•v€ceaH¸ã£àcT`œ*-£„À#Ï ôø·Ûñt6ù4e‡:³g¾¦B).ë(MÒ\‘ó;®ánS6Å{“€»e`U—¬Ù®›¡(Îã÷¬ááÉàôø”Î^ŸNϸ4X~úǃCzï’š¿ÓI‚xW¿YÜÍßø¤òÎi<ý2¹ù4åz£/7“‹wÇ3^~zx68â£!VOŽùÕøvïß{eܨ‹endstream endobj 5154 0 obj<>/XObject<<>>>>/Annots 1932 0 R>>endobj 5155 0 obj<>stream x­XïoÛFýî¿bPµdI–¤ß|Ž ¹Ä=K¯@€ëš\I[“\Þ.iFýëûÞîR²R½¦E ‡—óãÍ›7Cýï`,#üËɲò`4áþó×ÍÛƒgÃW2Ÿâw)““ñð$ýUÈüàŸ‹GO„ÇÜJŽßLe<’ŦÏ^á"q‘zÝ4¦ZI³Örqq~quùß××ï¼¹œÏEWÆÙªÔU#ÊuWèáóÅ/ÇoÃt8F“—¼ÌÇ/†ã±\]ßÊl!·×7ïæñðÎÿ`2¾|ɳ x¼SÞdbr­Äxi¬äºÑY#ÝZW²±­(§%³em ©?«¬)6!X¯JÞʵ(™T¹4+\´^‡µÓƶ磋m›ºm†ò“mØHã cIn›µjÄà± º‹»,­+ƒ’µòk±ËhEBF4ÁàrP;›iï­KÎdél)®­ªæ“Î4k\FˆÆ/SÀ…‚ÉO“³² 菱é¦Jæ t´Øº1¶òÁœÓªèÁr^¼ù5BZÚÜ,M¦h?ý>TµßäÚmÁYéJ;Õ 4€8e„bk÷g<~¯ú:,Ö oX'n=/ó©|:Tp>¯Â½OÏ_”d*–K¸eåYhÆ£< ƒ|IŠPs§}[€=·d'ƒM!=#6& ¿£•EYàSg¶ghÁ{‰”÷m]'NgÖ9ÒËÈWnª¬hóÀ¿¢N9²É‹n2dÀc"¡?B¤eò‡øåN#ì È,Û;gš†‰XQE§6ôµy›é§ÚŒ)êmÕ$lÏζE.+Ž—m¬aCfKq ÏëÉÏ,/ˆ?5~öÀØ·‡'ŸÅPž…ÎN”ê ZÒ¼4ŸƒU†µM`žG! F ¨RIŸ„ýá?"ى̯ÎoH³s ãôëÜ:—•³¨ x‘£1 [ƒh‰JÐíâ4ÇbÖKJÖѯ1ŠÃ(Š÷rCÕ°n3”PÃÝ0mZ.SœŠmÕ©ŠZë1q÷pÔË%,ø#L( …y‚§gÇ<ª#ÇáJ±|æåwƒÁ7ª¬:&Ê¥G6²Tüçºt•6¸… gµBûSÿ÷"â8ÆQˆïZ¥ñßèÒ‡ý $¦*‹*9²Ð=Šº‚†¡+ #E@›ó ²wŽÂIá5³AÇÀ†áówÈ"8Ðc/4cºü&<‰6Ô<ÖÊVpæ„ú‘Ò‹"ñ–-ƤÕÒ…íGƒ ƒ{KàRêæ‹ýâc¢gNäÔiZûÅíõì&Þé•ìðÉb{šxöOï«Ôž_‰ôý¯Ù‡wÿO(ßÂ{uakQ ’`C©CLQÁ’$||>÷tú`Þh49BÑAR]Ñ B;E®ƒn¿GTƽŽHînƒÝ,hhå$ûÆ ók»\œÒ»„¢€ƒ›d4X=`@bRc¹ÔX@V’ä[9:?F qO"À5‡ÛâÌm¥•]MBnp`j`ù`;¢CþŸžÿ]i7ºYtwܪÉÄÏ`úxÙn)Ÿà>‰FO ÊŽ}OÜM…v‡±$ÖG¿651É´M¥ÒÝc´º[—¿ËÖP.Y}ïåç¥XÿH¬AÉ ÙÔЪŸ¿“Ò¬Ö U ÀqèsØ“4ߌÏ\7_išÝ;×—mC§Û≠ÕCթı aVq›àö¶Œ8r+ȰdZ7KÐGŸÌâË÷ŽÝ[^¿d?zÓ›Ê֧뛟öcÛAzÉëG0抩| ŽþnÓÁbU§ gÎÔˆ6þ×o¨y—ÎÜsªhtÙ=K«ga  r­îemâF†ª?g0ˆÙcEm4ö[t@gÝýPæÐÿpÿ%¯Ì‡ë¦©8>îºn¾Ýo6›a®ÓzäBÌÇûöoÛ‡‰':!³Á®ÁøÎ¬âFY³$©-&!¦ Þ¿" ¬ê^ì|Oày•ç‘´@ùã¢2¿½ åÜ.fÀÇYˆF2v§ã€ãȸµ«Ð˜¥—°'Â,ÇÂë7¡MÂ|û°Ó%VxìŸØ½S…)M_’p/ô¨7¨Ç U6±5Q°óŒ¦ÃÓ“S9›Ž‡Q5™Øàd8’×6kù-D°OÛƒþðà¿Úˆ_=ŒâÊ%ý÷³ë<{::žLâ;õd:åG—‹ƒüS~[endstream endobj 5156 0 obj<>/XObject<<>>>>/Annots 1937 0 R>>endobj 5157 0 obj<>stream x¥VÛnã6}÷WÌ[½ÀZ¾;ξ¥Ž5MRÇ‹E¼Ð-±‘H•¤¢ú¥ßÞ3”7E¶0$°-^ærÎÌýÙÒCÏø?.:ƒh€þòÇæ¦3œ ¢)//¢4Âއ§œù<'—ao8šà»yâ½_·ÿ2lÚ”ú«KN¢ m÷ð<›O£m“àr@Û¸;¼ˆ†Sº^¯VËÍòn±|¤Õæþ-î¿=¬o—›ÅÕâëòÓöN5¡!n°•Ïç0ÓÝf’v*M¥ó”¨ý^Z©céh'}-¥¦¥UÏ¿8ŠMQª\ÚXĸàb«JOB'7+ÂÊ/ì˜À6>n(GµUÞÔҴøLu¦âŒ ñ ' 6àÝÓ^8/-=uc‘çJ§d*OÞü ËZäTZ“ZQàŠ£Â8Ÿ`Hxr¹©eB‰©5ùLrÈn8âš(ÝÓ§¨I8?æßbÔœyÍ.è-:¼ù6‡Xh•7…ðŠ<Ð^!uø#+\ Î{nxÒý™—&†#RÏR–Žœ‡?ŽŒ¦Ly×/”sÒ}Ì8§˜SÔÐV-RYHí?n¾±ØbÁ –L"³¤tœW ¯…Õ ×E´Ö¨}@È §Àkª^ð³-(**ÔI¦Ò …ÑØd…—ïòy>ÐŒE†ÚÍ%ª/x©U'Vè_fÿJ(™Ò+£?ˆ½x1*qð•˜j§\B\ÜqY2Ç¢å4ŸÃÂI z£yt‰Z³8$Af´Ø,¯×ÛÇÆÒû/ô3 7¡€÷&G q˕Ҕˆno,o(€n´·jWBÀ¶|jsÖÚfJž®’±*Uܵm14ô5ýxNŠmØ¡›&¹­b%´¡‰3ÑIàMœã,¸)K+{ ȘC2m!¢ú™à=bÝø¥8ñwÂyUN› .²PÌ® BÊ%Ä‘ƒIäÃWü,€JzNþÿKñ]}ß~½ßüœác Õ⤽»]éÄÊš¶V%)GÍ÷ÿ3¼0mº™÷å—~߉b'"cÓþß(Üè¿=ßN§nÔv,»‰(=ô˜«ÒèQìûž«Upªœ¤ZùŒ¬o‚ÉV®âõ­ªÜÚ<Ì*®îõž¦Â]—±y+Kcy|€h4U¢ C+'¸}.!2$ ¡Ðw „]ƒ—™›RÚ ´¼Ì1öÂ2,©0†rHñgr²,o'=Àz5GÐ꺎ØJÀmD™/ò÷{MìÈТ‰iB•f=â˜nî¾ÓÔÒ¢› *¦[K|^:*Fœz¬mDMª8ÜÞcdãEàá÷õÝM@÷ÃÝDzDçŽBÚÎÅÑ`MÇxu™£yFª7Æ˵‰+NFsB½öpï‚_*õ9ç5d:˜Eã ÃÑdʶ–ÛÎoÄv½çendstream endobj 5158 0 obj<>/XObject<<>>>>/Annots 1991 0 R>>endobj 5159 0 obj<>stream x½ZÛnG}×Wô¾)ˆEsîäÓÂáJ†ÅòFLŒ~‘#ir†;$åðï÷œêžé¢L„´i ©KWUWW·ý¿³Àôñ_`¢”ÿOægý^¿á€?~{¥½¾I“´™¹IÃ^àÀÌÜe!¹8.è§½Ø!’ÏMŽD±V4 ­hõ2“ Q…;QÏZU­l:Ø’µŠÃ¾ó)ë¥ðšÈúä1‡)E=«0ØxÀÅzVa°iÚ 5«ðÜ„ýŒ«íd5f[²6Äý¸œI¼Hˆ=„Ñ ë MêIÆ?Úܰ™:ä×Ú±I«±HôŠè M]DRõ˜`ê<+Nð“1HÉ  ¤‚Ä:Š´‚©KM”ÑyAbSa†w€bò¬Eh3˜òDˆ* +…⎵¢ˆ1E‡,´D%´ja³#i¦ÅT#iŠUll³ ³äÍËj 6â²(YYNÐÎ`Xf†D´™¦æõ¤X+ÛŽh¸;A¶Ñx-k1C!²žµ²Ð([?ýî2¥0då´¡õöªÅÔnÀc[L’( Y„y YkWÆ'° Ï–°Ó¬°Ý?°Ó±’>V‡¸°?Y$f†bÌ[¬Â\ *Y…i–óg5sþó¬lêÀa˜çBìž"ôIA ®µ#5f$T‰gíZe®)÷ï@MY¼[ kƒGžU˜ŠC¦Ç³ ƒM³mY…Á¢c=^VaD›BÛ—ÛÉ×¢ÈäxH­ <òœ‡Ð¾c¥µ¡V'9z˜3rÝdõnˆá‡j†é |AÆÕ¯M˜‚ô“'ºç<„½`¨9Á¥C¬¯““°¨±£µßHö‚PÁ ›×Yž‡à¤ÃxÎC†lKN̵ó JK{(²â¤JÞr<ç!8laŒ}œ‡à°:Ìç!8´­ÓCFŒÕÒÉ)÷/¥ó—±z¬’«æÑ¼½B룊ñÞµÒî¡OåE«oÆ“ó``î>]¿7y55ïf³â±©Í¨žÏëÊÜ”ËÅOã¿”Vy­ÜGÔ‰G² _œ¤ÐzþK¾,'KÊð÷-ÿ¶®ª²z+ÛÚ¼pª»ÀE¡ÁS~“¾Ù–øÚ¾ýÞ™¢ß\ÇMYæv±*ëJœCþ‡,à™¼®–E³âúÖøƒ™ÔÓ”ժ6EU4ùª˜š‡rV|§¸½öyƒ±ñH³½ñÈpÄ^Ä~ÿ©É zvû\4Ïeñe;/Wëj™ö»íPÿðä\ÕMQ>:sEóñYÜS WW×ve§7õ¡®.jÄxVçSäû?ÅÃúäuÇœ¾¦½OOùÊä÷õz…¯–«¼ÄV{Λ2¿Ÿ&ŸLŠåòß'.¢Ûû¿ŠÉêÈ’u»jÛ®Ê.lw Ò¼ÊËÙ‹f÷!ŸËEŽPœ8#—„SÛùÃå÷Ôv.«õœýòZö»¦É7§^Ïh–/—ÅRöÈݪYOVöÏ¿W\¡ù|^?™ùæ_ŸÚnÊ£›Û;ó¥mÜõÃþ*°»ó2Š÷Ÿ—òy{\ÒØuõT4%öó¤8©±_‹ù=ȇ²˜Mm(Ð%å: G,òÓÓÆTõÊLËc¶qÊŒ~þÙL\’ÖK“î€ZmÅ!l‡SxÉLðd,çï·Ì/©L<ãb¾˜afˆø ê½%裔F;gÀa³Ò"þpÜuzïð× |}šêJ¹†_å¤\™ÖCÌ8r”²c¿«p\¬B×…Ÿõì44F–¦ÅÛΥå»Ù6U]mæ†ü‹8ŽžêZ2›ESÎófc˜ëc¼·#î·dÚ®·¾Ú¹É}û1op|¬^,,_Ï8VîwùvÁ¦‹:êzõî·Ê»;‚s&ohG-—›þòïIñ*Wƒ8Ìý#Òl]¼1 ›â¡hŠƒÚí®µºá%D¯—;Ò¡w‚0‘Û·Å<_¼Ü¼¶´mW‚²2«§Bz¤Ì;EÃôûŽtýAöí/‹#ÚÎíïãW±3ÿùñò(K®™µµÃ›™=*FŒ¿»1òJ†øóòݶûÙºy¥ðß¼VüqW;:‡e7×w_ÕØèæÝÝÝ(.;#|ËY#O=ç¿ÖÓòaÃéAzî‹§ü¹DË·SOÀ¶!øîšþ¡‘4—Ïá¡Ýÿ‚†íëzZT«3aƒ7§ WZ~[s¡ï9£¦À°U,7óûz¶l›ÔŒ¥¨žË¦®æP·¿#íZˆ_úדýÞ Í——Kq£ì|¿ÀøŸ}ÿúÛ‹j=›íwõˆæ¹Ã&C…R8©Y¼~pt1Þ¼Ák˜ÍŸ¨åa—¼k?²Í·RÞ"7õº1õ4ÚIÜž£ /†rì6$ƒ·Cƒ¡4ÇKâd=Ë›è×îÇŽ·WÝ‹+ÞÁ‡x«Å#1þQ7å/ þÞ[^F0N±ËñÙÏþ›9!endstream endobj 5160 0 obj<>/XObject<<>>>>>>endobj 5161 0 obj<>stream x…W]oãÈ|÷¯hœ6'ÑŸëõåžn7q`àÃeÜ‹_FäHš39£›ZÖ¿OUI™ÞÁ.v%q¦?ª««›ž]Êþ\Êõ-ÿÖÝÙçdz‹ê?NÿÄ­œßßÈå…Ô‹ÇKRïÌ>Û(Mutk›äëïÿü>Iê÷û³„üܶvƒ| ]¼üâÒ¾:ýø‹ÀŒ‘Mß¶«5¹¶×í[ÛYŸMv¸#ygÿ8»Õå¢YИ´Æo{³µ’²ñ‰ N›,Î×mÀ¤3þ(/Ö7!®ÒÞÖnãj±~g|­Nàß7bšf_]hú—6!ÒB´&! >™µk]>Vƒû«ºÿÕÃi_ï†[£K$àßeÈøïC´nëå¾÷5óJòàÞÆÔVž÷÷O*QXKKÉÆµ¸ÔÈ>ºÎD×%‡2œà+ÎoåàòN¾œùá&µ)‡èjÓ¶Ç%#ÈÑø%ì…GlŒtÖ ’õQ;‡LêÐí] —@£­Cc¥6^ÖVÚ`–Ç瀛±÷>g±´,ˆõ/.Ï*´öÕÖ}¶ ³³¼=$=$iu"3@±G×› (¨³yš´ ‡R¡b™×èxI }vž•Œ¡›Lj6O :[›ú9=}€=g}ö&¥!‚Ædƒ„óÁZ?Ýå9ÍFæD`^Û`ÚBU0ºTÜTyFÚYöÖ­åoö®~F=·ÖÛh2~ƒ ok›’‰ÇÉç:lã¼+´IA˜Ç¢¨é>ÙYꀰP`²uëúŒÆE[gøUT4RXi(’ë;f±3/Ä‘*dˆ®#IÐ4(ãï;À2»dn×¶¨L ³H¦ì6}„‰8Ä5˜D“ê5oA*x"ÜÆ¥1!Y<9WRP`ÈÞ=lDbœS:•

äjfiËXVe9nú:¨6* ÷/ê©õI9"ÃTºÎãÌ •N›yžl©ëÇEˆ¦ù£O™XDN¥°CgÏ¢1ä¹9A_÷1²ƒ •ç|Æ 6ñ¤˜œBùà— ˜<†•9"ð×|£¾£À¬®Ö¡E`=éÃú9gýÇ Ø{Áok}ñy?xÙØÛ’ÄIoâ‹—úuº¶ëz´4”ãIÓ-B÷“ë\kN¤B¯ œù Z9PfÂ2ôÖ,±¬5aåiñH»`œ|ÁÿKÞûj8á¨÷_9>‡¶sðhÍ5$aƒ–bþóÈ‹VM pöLQ¶ßg‘ ödÁRÑÚˆ ¢â¶ í3ÆÑEeÔ1ao´]Ö2Ÿßÿ(—7FÿêꎛÅå]u)ŸMru¢/=…)\ÎÜVwwã!ûw™ º”çMbu¥¶›ÅÃFŽ¡ÿ…À˜mXµäÒ·¡!‡±ýùh”‹I\ÐË£hãB°4ÄA´¹’°˜M8%½œ¡µ ð'ªÑ:)»F ƒÎÃ;1kê$Sð†ÆÝ<ý™«Ζѿ¡ÑP22ޱ“uc¬šp˜7–Æj_±¥°c‡½j?nA‡²×(3þMÖ¬Ú?¸´c®Pè3ÛRQÑÄo ë€~œ­ÁzMOb‹.KjT™ŸÒÑa'€²{8tU ‰Š<$q)k6+oqL¸c‹ÞÛ±ÌņÒlÚõÐå\Ú#0lX´dûŠ^„¯ÕŠÚ‰0Ø6#Ä ƒ†Qv>÷ƒÆzÓb.ÅBŒÕv#‹ÊÍ9»@Çb%nöRÌbFÅr¨Ã ¸ª$JIy" Æ*¡ËNÔ°«dôr ªÀpƒöª™cȜʈ<…G÷&–±4 †„F¦¤X½9=ŒÛî°èø÷2–£M}Ë=Z×_¸äØ.%}LjÓ>ÙQÎ6.±tá&šeŒa>Q:u_Ö[-؉ e7`«Zµ×Å3å#Gì†Aúy×ükœ<Ut—â-Ö,tœÖiX&ßnR?©ï÷ÕÂ:G-/ ËMy©€áqI«ä3—°hñò2KòÀõ(cÖ¨¢½e#öH ‹¸0,§¡‹â(ÊÅYYŽ÷n‚0,çóäÆ&SæÉ;ÚëˆF¸ºcc.B€U4)§e>„÷½½ÔÍÏJÇ@› Eš<;k lf™¿é}L|wz›§ª:ëÑ"‘* Ó;U¢itß…½qJs<Äû}_qBé|P›÷Bîªëq<]U××øÒ,þ2læÃá!zá³Á½|Wò¨vßÍžCUokùiÁOþéÃO||zI^i,×Õíí'š{äþ±@ïƒÂX©U«Œè™jØßæiŒÇŠíÿÅ)¼Gù+Þ|³¾Ë"&9?×—r ¯Öˆ¸@Œ¯J)}ߘfý8˜ÿOô#ºu[Œ´!>/XObject<<>>>>>>endobj 5163 0 obj<>stream x½WÛn7}÷W ]ÇÖZÛqUôÁu£"@Ú¦©€ôA€@íR.¹!¹‘Õþ|Ï»+KÎCóRä‚DΜ9sæâOg#â׈&·ü»¨Î~œŸ ó!>ìÿrºš é.ŸÐ|Mã!Ý~7Êoo_ѼŒVCšÙ"+åºÅG±‘4•¢ªµ<Ÿÿu6¤ÁeF´È¦Ç·…­*kZùš¦~§64]¯ùQ¡ç‹óöÅWyžÓVêZ:r¶ ÊHOkëñ”QfCa+I™ ÝZ’`~ä`‘q„2ƒÝ"{¥5‚ËÆæ x /z$ü‹ìÝýû_†KD•4 =õÁ1ŒEö©m…[œÓ“‡ÇS'Cã"d0Ä0;atDg~PXóYº@á™Í"ÓOÁøÞü¼n3¤T_ iX¯…Кú§lÚ‡H”-†IàlP¢6¯Þåÿ˜¾y’É!ìW§ UŠPl‘K'š†} ÝBEPÖÐT8t¸ÈF¯f×Äq×4‘ƒñ¤m’ln¤‘¢)i­´$”7e§7BWü-É;IÂÎ|Ä\£ˆsBP&÷;¥u§´1w•|¬…)9&^Û’Š@lF•øý“¨kgk§ºí5ÎÝS㻦»×Znœ¥ÙìMN¿ZØ ííer–À²oå9öÕì¦e'#éœ5Ò6ímYN³–â#´ ­(9.06oêÚ:¦Sz¸$Îæ1&Âf˜45Ó-?K¦Ï6›m”>•ªŒ~Ø@£ý̸fzÀµu%zºÂ‘ ‡'cßté?¼í9áúpÊc$Öñ@Vâ£6*$ îL^ sNF¶fž‘’§•Ôv7í^ð`<Î'Œã2û&Å9¸£vöæ*½ëÈ=Ñä‡-Y5JGV…9Níáâ"&r‰ ÝDHê€t)Ç1:ð_ yOÿ÷½G!œôd×Lt¨ÿ—WXA/\ù ¢ðà1uœÔr’BÇÕó*D ­žömÛ²øãöò Ô¤¸ì™w]ì¯~åÀ;©uãË–;'ê¼x|<%Šâ¦êeX^"µ8;ÈÃWŠßòzLl ÛKiÅ+ŠDQHç VýÀüHÓT<šx°}º‘ÌÚ a°æ°¥Ò‡9}hÃôC) #9‚pû؉@S6˜6–Bã`z±§R8L?ëŽa³Ñ§\#Ïü¾ZYÌEQ8 øèâDÛvv‡i¼u™CÂtK³aílx¬eT_«•c¤"ž¾ZO&ÝeßÊíÎx0[„ c„yŠááÍ×-ç<=Q©nV”i”ö*`>ö¶qœ½TÓ [œ4›í#Ð0w›™?L1L NÔ c nKåEü'”_8™ÊØvë)‰ÇÝÞ¢c²gÙjÿ$ë±g²¹ƒp¦¡·pe@%&tp’Ìg8Ãú$¡2¦¡´æ[¼Q£±bZ>F‘a¦òçIT¨ºØóFéM8íx¤ãjŠpÕ–d) -’;ÂaÑë”—„;vzO”'ì¸=yÅgsg»=¯^a×nÕh°§ZpSó°kë[<~P„F/û®9"Àx™D„íìK“§]ý•Ï÷K¿cˆøª&mClÎHjdçŠvp¿þóÝoïçLÝ?¼].—|L/—ñââbâ™^¢¦ÜNôOWB¬EþâCÝVäØÃÑâ|Hß?3LŽØ±]ú/\~É–Ñ$ŸŸîÇ bÙCDÔ}Ë+.Á (Ës ô#ç¹ÈR^ÑÏÕì®]÷£»ëüfrC·¯zR™Á$ÒO¶ˆ­åÉIbS'ëÁ«ct—ò½ow¿d»›ám>#] _ßñG¯çg¿Ÿý DLPendstream endobj 5164 0 obj<>/XObject<<>>>>>>endobj 5165 0 obj<>stream xÍVÛnÛF}×W ü$;&MJ¶l«ÈƒíFE·qS-š\ÊÛP\fweYòï9³¼H²äôòPÔ6D™;;sæÌ™Ùý܉)ÂoLýÿ%óÎõ¸…^¶fF'£ˆ.Â>3êE4¸ŒÃÁàœÆ©·Šhœt©þÉ´‹ÜÑkª¾üp8þ³QÃ*m­Œt SPm¼kó•á’štÃ0œÒ—ïy™tUá&‡Ñ7[Û¾Öÿõ=”7ܽ{?&l¥«›Ûétš‰ÄM§¿ýþö§iŒÀ¼ 3‹÷†÷«mª Ú…À†ìå…¥m’ÀmM’ßòº°ëÔ™Õ‹”Ôì×8©I·J£ñ³ŽÂ5û¿ìdtJ,žŒzýZzÝ«"%1ª8&÷ i& i„“)åÊ–”èT†ô‹v«Â‘r”ª,“ÆRfôœ–þ¥Ýض|•ÂXUÌèÆ;²b¶µôza¿Nðb†:kQU¤Nºv©f*‚R$ŸÄLBH“ÃÉá>£Tfsét ›®Óì(1: ¡[•’†Ù¢HœÒ …QnEÐeíµi-„êÞ]½ÿ9šZ"æÒKò¡u†3šth˜<=o@ZoVMYÙY·;¨vfƒDÒ8Bßí È%¶‹o%H/¢g¨ö†÷ÄeYˆ<§v+›¶!¶8þ[ôÅÿо‚ir& ÕL´ þCŠÜ×aÿ1Qh¦È¥Ú^M)ia]5a_l½·šJY i+«îc¶ D¼îCKn©Éƒ]—*ÓfnIpçÖKkp¼Ò˜ý–F?ªp`=æ’õ‹¼‘[[p»‰•£!Ë\‹sÀè…S…´!]Ñ\I©tBåXëĨҷ“Ϊ\2)p&!&â;M÷ˆ©ª8WIVVÝ甃q2:«S—Fusnk  ƒ“;aº5$^VNšéÖm'É)gеIa,œ¨¸yõŠ«ŠçcZé-R.$RbÈ •{bÑä~ ÞƒÂ;ù$æe.§K#Ê0yz é9!_ï_Ÿš<1‡ÏHÎUåˆ&4q8PÒbS昄¥¥ò´®ò\Î ô¸‰bÅr“ðñ<¿Š3Α9gÎJäâɆ.øèØ‚ÃÄÀ÷.”ÇÕÄ»¹õe=]R Åf¸k½8¾ã°G7z>ç~¸…Ré—¤Ýï8 ½(€CuÎHIë(dK™¨L%8·¼ÃÙKÒÞá÷1nQ @1”äô¡Þeé#eh—­Ómoº³pˆ'Ms€ lú‘ºVEŠ.8¬|9ÊðȃݽGÔðÙ^€šûäþgÝ”ë3?pËra_ÝuÛVÍÝïpýÖ fÜð0Xت½š`dWó{×Uº¨g@|qžõÏh€çyu?àC,è‡ý¨“ŸÆ‚£ÃM¦²Î+X!†³hö{ÐtÓ;½doÆ_;ßLNxendstream endobj 5166 0 obj<>/XObject<<>>>>/Annots 1995 0 R>>endobj 5167 0 obj<>stream xW]oÛ6}ϯ¸èÌAcÅòw¶aÀš6]^:¬5‡e(h‰¶ÙH¤+Jv¼vÿ}ç’¢,»I , Q$ïç¹ç^>‰©‡ß˜cþKò“^ÔÃþˆùãýÛ“x]Òh0‰z”Óp¿ÈèÃIk™Óøp¯µÌ)î£I-…/¶×ØmÉq»­5v§ãhܾ;G1õûƒh‹ú½»~ÅwÛkìzQ¿½;ê7kìN&°ªu·µÆîåðPrkÓ 5V°ÞW³Vì\‹%]\÷h 3g ØIãK˜:žÐ,uîÑ,éÐw¦ r%)SvMV¥’̽Pº”ÅB$2¢³Ù§“u¡c–²Èn²-ÄšºôW*¢ÊÊ¿é­Ô²¥$AQòð@ •IJŒ.…ÒJ/éŠøÊZ´¨tR*£i»’º–ɹ˜˜6Ì`cc-ku)) «s• ¸a S”xõ¤ØÔhIìòÕË—0‚vµ Þ½yXg*Qe¶£²*4³ŠÙ~ÄɹZ;f½\/•ÞKaóL+h\$w!7i•IK[U®Ø“5âÖøi#ºš´)i%tŠ-‘e”É¥ÈHê*F6Žsüm)téŠ*)í9q¾Å=$¥l‰¥Kø‡Û›·”T¶4¹úG¸ô,¤€×Ò†í³¯¬É8Õ]ºe£Ër˜<‡Ên¦`Q,«\êòÜ›ËÈZɬ|‹3’€OŸñBiªÒês%i-’{6W‹\¦“»UËèÂ.¿ÿ•euH\j%‚Æ/¯‡_pGP0{]È eûõÉÆÃÒ€[£©»—ÑJ 9W:…A@ß\Reñèriœ ¬0€;û̲q%åbwÊëÛ"ðQ.‰‰<Çiä z©Z,dÛ 5«KµPp^ldºõY»¸‚™¸v» 4ÏRz­‡t JÁ–¯ÎxèæÑMû*k$RêÔ°vùEùgÁ–KŠûl [2f&‰§Q öºÑ6s­Ã5ö„8™VؘMœº½G,e YÎ —tá¨>~KSÅ$š­ƒ`AÀ‰hcHJ™»ˆb‹è¾3¹ŽÚ Áá(Dǧ#0ÌᣜÕC£:`X¯ÁB1ôI*wk¦Ííαt]ñ4ÔùSƒ‹ç]£À¡>Þër z…O+(%°ç±.Ib y8 ž„Aª$n뢰0Õ R-WŸ7, ·ÛŸb¬cñΠµ8rd€Î3“ÜùÑñp|‡À¼-º@y ²+S”I…ä#[‡Ñè48¯ êEôo%»&xq sœãIlêé4Ö§[žn€€7Jn£Ë@FÓ)ÇþÜ:F²LQ®¹J˜ª@s¤œ½G³chîÕ¯„UÉS Œ¾‹îϾ(LNfþ ØÄf8[¿à1É$N¬“THܨ֘1¹9dÒÍc~,?sÃÍ ¶Kéké§µq‰ =Ýe«d–î|ëBÕB2‚ÞK逋jËÑA,‚ ^œ½xWÐbýä²ô«ª5úI?š Ýˆ²”ù 0„ X‡•ÇHÂj^˜(Àf;¾ÀÆrï9·Ÿx È«dE9‡Ãå=š/˜/ wtuÞèw³…XPþ\»ãÿÒ&…š{s1g¬ÄÚMJî«E&vÀ›“[™m8ƒž×Hð`ülíóÍ-Œ…~‚}Ž“ë#_ÃQÿË»Np›¿Ý=~ëºô‡·ny‚ÜÊžºë>/XObject<<>>>>>>endobj 5169 0 obj<>stream x•VQÚ8~çWŒ"U ]’%°Ð-§}ØÛ–j¥½^¯Ç©: )2‰¾'µ,§þø›±K¶· ;xf<óÍøëDÐÇOÃ1}“uç×Y§öñÏÃZÂå´×áf ú0~…ãñ˜¥Fª³Ä÷ÄöÙÚ¡;û§Ó‡ B‘´ù^‹Ú_ç~V(.–´Hù¼Û®õE±²ä ’"å€Zü±âJ‚wçÁÎ.iHXž ¹„»‹ hµâÜsZÉ62©D!50™ÂšW«"Õa›níö÷³Å ÄO€Ÿ óKoÐnÄíü“øäB—?¦Ó{x`{Äœ‡b9ßòŒªˆUÆB–MRžñ€ëEDFΡ:ÕÜ2%Ø"çmÊÏcU¯àxüàiµz ^ÃNO×ÚÔ–æsòzòBÎýæ¤ö¬ÅwkH“ȉ|ÁWP´æŠy(¶\åKyÚjö z²nŸ³´ íbõj;Q­ÚìžU[mއ(°LØ&¯x L-7k.+Ýjµ>˜˜,dp î`öüÌÐÒÑõÆÙs:ÿŸÎƒñ–É!»ö$­Q´X©ÿ2ÖšiNñ8²*Y"øi‹O3\‡šÐ°`º½0j‡^4ó&ª=ùv9} Ñ€è;@þ†#Çß~tÂLÿºTš<_N¯€ˆ;Ãþ ®Â+âðÙŠSÕ|˦aÉ%WŒ*e±‡?¿ÜW;! Tû’k(²\P2ÅðhpE”-a2ŠI´F#BB™#YÁF™W«Ç`©7ûûÓ{ctÍJÚAhÀï£L ‰§«"Í’i,öÁ–åÞÜá®×ϸâwÛ­p’'\k¦ö!Üæyj`ã@Ã{ýÊ ö´›H©P“£6.•…Ö©ò%£žC×4žLÍ9<ܬãšwCøÌ« v8'b:q¤ ÚV0ò~ÿkVÛ0è˜zJã˜4Iš–ñ„»0‰ni#êZ‡ð±¨À¦JR–¹H¨U>¥+§NՃŦ2>ÛÅkˆ)7ÿU–!ã<)BR¡8öê-ÇlŸÀÀ¶LäÆ>åŸê+(‰œëmªKžˆl)xj¿òý®P Z½*69V/w’«l1Xâ~òP¸Q:As¬Ÿ¡˜Ô¸;R@ƒp8ÄSê¿Zéƒ?FEËæJä"ÅìW VÇ®xo<)r¯GÍ9¶aßx•7ï¢SÅ/uì/± xΑMâgå7‘x%P^¯(+±ÿòcŒ‘ÊîÌ/˜ªÍ[ñâ@{â ÛN£¸Ù`Þ­Eíõ®E4Y1< Ikt[Äš©¹of¯©ÓÆ™<´bFûõãããÜwKGJ²46¬iìƒ# m2ê§ Jò§:I¿Ë@È¡øÊ–ã¼{¸‡Zoœ›íé(ã!2x·wHç8c⾸ïÁ„(&uƒƒ‰ab@$N’GWß¹ÿéöóoý8‹Ý$ÂËy`1žØáL µH'гÁó:gZs¢ ¡3â åëL&Ts­9¨l]_»ƒ]_…£áÆ×Ã0²µMðïŠÄ\ ±‘fÈJol}Ö‰`ê.Ü`¨}!áQØhð¸ Fýõ~Öù£ó]5…2endstream endobj 5170 0 obj<>/XObject<<>>>>>>endobj 5171 0 obj<>stream x½Wko7üî_±0PT.t=l%QQnúH[ù"@ (žÄ掼’<Éê¯ï,ïa½R¤@SØpN'r¹;3;Ëüy5¤~†4žð¯,®¾›] Ò^vÜš^< èU:¦YF£M^ÓÉä%ÍVqÕ€f²GDSœ6kŸHk¶Ê2:ŸßÜÌþ¸P2ĪVÍ{¹ ø;ïýþþñ‡…pë½»ÿí§Á"Îo>aù0..²ÑÅå~§×I–%Rä9=Ñ>Å36¢¤5ïÅm+•*lì ù]gÖ^Óõý÷?. U–åì6£ˆFáI,mHTÁ"hIuÞT§íáp-F±¼ÝFÎMG—ɲ)žYbJ¯M4Ý/}Zçðš†Ø‘aº$£ #3|•ŽÒ[úÙšÄB±ð¿êy£à¤þ8mÞr‹¥Ø4Û(¯H8@ ‹2W|6Ö§„/ðR{2–Ø‘ÑòòCS¨ e–½ƒÂÔ•C¡XZÍŠAÉ-|à:-–9¼%Pi½×øtTppÂx|ËàÀí\dÄ÷ÉWrCÂSYåÔú=1šX¥ÂxŸÛà áÁ œcPEip{ -ä‡ö+Àô+ W8`«ÓVcÓÒͳ423QÙÀ¡e'¢ÖÀKG$C¥ð§|ä¢;ÞàMàYˆ=Y)+tKŒJu+5ªÌœ-HGúºÄºÉ(…¡%T'ŒF"àতS çícÅÔï/«éŽ~ùd%=šX³„q2?läE•ëÀ2ËžÕÌZå8û”´ó¡ÏtÅXmŒZ>‚Öz Œ W+V•P—ÍšÀ8¶\K‡z¶*=-‘VlÁ=Á!P–êΉ²Ä7hxh¾¾˜@ÐoT×\Sx”C×´Ò²Â<¯÷8j+êÓ’{›Yݨ«|«Ž¹ªw®+í78j¹e± ØŒ?hè¶í&HÄ+uƆ›Ì¡«Ø(§éâ¬rˆê«‹ù—<´¹5ÚÔ š÷bÛòwúw h³µjcRΖèå (Ò¥eÒ:˜e ×Àú­^¡Lcá{Yw0lT)—Å‘i™ì£\:Òÿ©!ºhôù›`Bï7¸QÖ>ÛfßÁGȨµ7R*ï¿=fèÀeïs èw:l¢€‹tz E´ ”Ø€ª réTíe‚RùôÔJ¯€·°« ˜FžÚþ3o²È,ItãÑÐtQTÝ8I|\Ù¬-¤¡¸¶RôÄc”*%ÆJîâ» yTè­þ©b¡¥vó1"=\¿:³Û“Q׿r€'…¯ë†õµ¥H‘y{|]É:·ËÃa…åûÌ!-I¬ˆ§yànÆÆQlk3b¿g]º÷ïcFl œ{Sd¾™ Í$ÕÜ4FƒÛôn|G“»—idŒÿK”ŒÓ½±2Ü8#9\lêµÉËúÞ‡ÿ˜é}46ýân0IÇ#Ü0êGw#ÞúvvõëÕß’)žendstream endobj 5172 0 obj<>/XObject<<>>>>>>endobj 5173 0 obj<>stream x}VÛnÛF}÷W T¥“ÖÅ–]õÉuj#@Ú´€¼VäRÚ”Üew—v„ ÿÞ3»¤.Ž\X°Mî\Μ93«ÎF4Äψ&SþäõÙ/ó³a6ÄËÝ/»¦Ë‡Ÿh4¦y Ûéí-Í‹p>¤yžŒn³qvCW_dîé³M£ôú|þåìòáŠF°a¯t|•]Á/¹«*ÒF§UµòêI’ß6ÒÑ"¹¯„sÒ]ó¶Í=þiµ2….‚U!KGJ?™ê )ȉZ.Îi#DPn¬•®1ºà³ÒX©Ö:åà?¥eAF“ßH†@\O‘TÊ5äT!éI *ËlÓCç¬3ÿ/za%•­EtKV6"µGÆÕÈî?|üD9WwA¹•‚8R…·ÝiÞ˺ñ¤Õp¼élr(5†8B¿QÒ ›o¶ô¬ü†È !A¨Ò†AF¡,zSmÉX¼Þ=•ÖÔ\r_nc@ÛŒb%Šò 5© ­E¡Ú£#HÔ™»#DVúÖ2×1xìzƒŠ˜£g–N ޼(í¼Ð¹$S†Jqn Ä–b)€Ø/:“€ƒ½ð±ý+)õ޾å Q~mX™‚v…Š¢@‡àÏâÈÖmê×Ns” M•\#å–V’–iE‰Öt4pøS÷oß1q.DëM-¼bà[@òVäÐAFó :Ž -@¨¨„BZpBî*䵿G×ë"Ó¹ÇT€A´ª¹  &,Ûm6Ìæd7’ôNz¡ªÐ¯—£f:yÏó,|…u¹U+Ô»1Ï(Ý¢„¶–î/Q)‹ö…i íEUÚUAàÀgˆ§k¯[ éxÊ“ÇØ²ýŽ!v ê8‰+ 'Ò;³“‰>ð#Êßb écê>}~ÿÈäJz¬Ì ¬îÄ *BÑ{ƒ0°è"wðò{±ß^qY¼©MÑVÝi¿Û’n¼x•A¨¬c÷$=í–›ºÆfK+ì¦w÷Ìú”´–³Þí”IܳZ§P}GB„ÐcÜ­»Ö«Jùí^F¼Z×€®c>Z Ö6ôÕI³àHKlj÷¢ípaÄé”_EÝTrÆYÇaÙs‡Kc2Þ1—,Åî*g“ Ф#ê6ìÊž`ï¿uÜ€"ùAé¼j±Br38:|óï±ëiÛ÷ Hø8 eY¿íc^¼Ú{x,Q÷½l u*ÌÒ™Zb|ôz‘ð½8ÿù(,{¨1|xÚO"מN&ÙtzÃE?v ç5‡ËÅT•yæeλ4À<&:¯8ÙÑ)³¹cz‘ìµÁ‹°ç»/t‘ÌZl¾‹·s¸g¬)—4“_ójq¾8?¢zOWdw‘¼!.õA.ìàÀ3æ{Õ’æCû•\ _$âÔ÷¹NDx™³Õl|ر îî?,uò/—‡§Ë%o“åp@³pcÌú%¼ãcÏâ"ùãî¯ß†KM4c|W:!÷,Þ’ÜM>/XObject<<>>>>>>endobj 5175 0 obj<>stream xXkOÛHýί¸¢Z 1‰(ÝjW¢(U »[v»T‘ª‰=I¦µ=YM@Ú¿çÎŒlêjUZÑÿ "‘÷Idqõ&(TŽï M3IQ.E!〮³ÊÎ\ál_ó2‹ ¥3Zçbµ’ùîÍ—­! F!¢êÍuN±þlt*‹¥ÊK\”1bs—gïÌG5ííMwo'œ°ißœú´{{î}U†Þt—Îî#¹*nM{c”‰þföÃTÇe"‘h’Ø/ NI÷ŠDÎu1§‘5§¦b™j®d>ˆtv'sÔsPç+ ™"GR¦‘òZKäâC+m›z?+ÙŠ™ôüÉ1ŽÖÕ:ÐeA ý@X_ôŒ¯¢ è_U}„¼™ÌÑ'{(– ŒÉ<¤3 ã(Ò%²A¸B‘`är.s™EÒô9ˆ8VÜSa«Äw¢gHQ³/WÚºÅQ+\ñV ÌZ-€ïL+Cà„2]Ó³<½~ÿþújðîòÃo„€Ïþ>}W9 è†sGz%B§•6FÍ[ÞyhØ6 ìp×'€RƒNE F±Y€t•kôÙ DÏP*¢\3,lãZ…ù ½·.[RŒ‰WÝ1`ØU%e O #¶³ÃÌ~¹l‚ÉBH˜šŒé0– ‚ÔòX±ö×¶Øçˆ0f Yœrðä¾Ã% w0Ow")e@¸âöµ±±¹ÈLÂ$Ë0ÔŒ×* ÆFÚäÏžÕÀǰŽvzv€çd:âmÓÁíè:ø[¯x´ # ©Ÿ%¡W·+Fqqm\ 5Î-WµÆ†åÑÈ•À 2Ï U4í)Ép¹ð™LôºÍéo@=6w{äf3Ó¦éU!ü(ch@HUn}CÚ~!+ Æc¼‹{^N°R¿ñó˯¨§¥Ê mŸlÓ ÅgÊ ¶6õŠv¢§¶:L½Ú¦gÓi䆿‰­SzõÔQ‡­ÓïÚzM£`(ö½[¯‘b0ŒÃŽÀÎ(ÄOÛVW`gÛöx‡­sÔ¸Ì H×{ºëm#´L›±¬WW\«Qò Ž5”á¼PGj6µpÞ•Û ”nZâw]Ñl´Ö€±5GGÏ›Ýz”ÝÁPevì{žÅ[êu´Ä“WBŸkq øÓ˜é7yz­½ !D ¸ öÄQÕÊ*-OMõ¼6÷ô9ˆ©c¦ûB¨ŒgJÞã v)³Ãz©ÀPÞê†Êš<IÀ¡;ªð‹¿O¼'­ ÊšÏÎ6äT$,)X méɺbÆ‚Ðzp¿<¨l®î¹,_áŠc´+Í$ö»¥ “ëg99WN¾BVp5sµXŠ9Aʋ׻a.CF~¬q™Õjt{Ätÿ¸FÐd¬Âd]Û,Þj=°\Ãzب_´xël^6BY‹Ü6`­ K±:ê.Úž?v±iJì?^c|ts™GËåÃ[ßG—Åÿ£ÌK:¡}:kJÇÐ]ncÊ÷Á²<ÛÓÝ*xK£Ÿ²J­¼e›‰^(ô†;­ÞâÛ}H“=ãßIqG¤·lu¯Š4ÏqiÂæ;¾áõã|Õúá Ñúí輄Ècyp8{u]i„·ÆÉC—¹ˆ^¾¤\_]TkpéíØæ?¸°os¯ïæ2þ1OŸ|[¾-{tÈ­éÈçÓã‚M{ƒMJtÈidÕÉÉ™{6%³Œ£Ó…´ øk¦×<°ŠUšW¥7̸d)dåÛãG.àF÷*Éá>®„l©!m©«ïjâ1ýåÕR·&fÂ>uš ÌÌŠpÀ‘bjµñƒ,Xe3óLX^ƒ0‰žYÑéÔ™in…üddu³ÿéþ>R±Œ¡ñë¯òÒIe:“y­ñÀ‘((V[¥]Å¿Ûu·Z×í0,CT¹B§Ý^*MË‚×fš±eœ)“dëþËÀ«E§)yÿøÞa¬ EË‚¥p—ÌgÔ­Ï…´Ò«Ã¢ÀÖÄÊFû4‚3&XºûÇ÷Ññ$8ÒÑóIpÌ»Ÿwó` 鵎JfV»ÒøD‚;;xît£} ÑUõ`o{~8< Æ!ž•`+<œðų›­ß·þ?rWendstream endobj 5176 0 obj<>/XObject<<>>>>>>endobj 5177 0 obj<>stream xµVmoâFþž_1Ê'¢‹Ëqj¥4½œNºV}¡½/–Ðb¯a/ë5õ®IhÕÿÞgvm'R©‘*ëy{fæ™Ù?N†”à3¤ñ”¿YyòÝü$‰özE· ]Åcš4JhúnO§oiž{©„æÙÀˆRÚÈ$c诳ùד„¢!Þå"ee•±ŽVºZ ½ØŠš¾¡Ñû¹BW"È,ÂOÈÄɾÔ߬sq{Il¼ EãqÐà£4²Næð—Ë˲Àè’Wg:èEü~ÇÀ—Ò½W«H™hîÄJR:8¦Óô,=Û ·•ÌeÑz„vJ§×7ŸÐZ,O+é‹_¿|ú¸HNiævI3œ9YX&˜›m+•;¯¥kj£ÌŠ…8±Ï„hf] !ç[Y;rÏdÚà‹"Ê„ÖO°}ÉŽa %9ÄNö6œÇ–~ºþå‡Äç¦-4ÍBÁŸDÒ5`îaæÄ¼´–Èjì« êUB‡‘ À·D›+êuY´Oì+óö?ôD—Ƚf%z}W¼H¶+'Ih[“[ƒ¸÷kYã`³Ñ*K-Ï)´Ý×8”µ%÷ªÜhYJÃ$–E *¥[W¹¥ÊÀ’¤À ±2§*sN›ºÚªœ›^Vv³ëÀ˜³`¬ >®òúEUKµ2~Ät÷ã §{ceý-Zƒ'§–Âq®5ßyñœxO·­YæX·[qï§ŸynOõ%/Ù'Ÿ[ãÙ,MKu'ušÚ:Ãc)M´.M‡iö¯n÷"é5tÿ'ƨšÍÂ_žÍÈGÿÉD`ô¡‰8yÙˆo£át¶h'qò²Å#È:S{J­‘‹Ûw4D+uëdÒ­“!¶^|ILSòZA/ZÖd„ß-@~2tsNÂ|”¦­Ð Zox Ê•¬ÃÙ9Ø¢4^Aë͛՘,*SNïxò0W ÷ù3ƒ0O‰eƒ f'-%åÊ:´l£ì´[îH9ë%ÞC1·6I‘­ÃY.3-^.jù­8«nϱµàó©ËàIìÅ}Ñhl!ÞxUA¼µbú ̳TЉükƒ«kwÄíDÙš¥­~êRÈ=î+ dA–*Åæ $ƒŽ‰aésíBÊÃø´TpV«ìN¡˜@pŒì"YÈ“2Ê)¡ÕŸÈRcýÀ1;VÇι¹àJɇM-¹21qÉé^¹µ>2UÆ“•*KaòH+#÷2QmÂ8»—´† óR#+-hiý„ìÛ¥É÷_z†Êç}þCyüÝJà.€ü•üxRKß1ÍרÚZø\ñ¸ð]ÂÞE¾…&_tPdÆT‰`äFf*ê·&°O~vE ÷=`=×JnÛâ{‡6¦/kiº8}")κ]@ºͳ—Ÿ¶UÑd+Ýpº˜=4¨v2éº7€9¥xËðû¬–þÒ61¦²Ê-\ ï³õ…¼ *ŠÙÓ†î­ð=¦B‹]µ-6J.ãÉxBÓ«$œ—„©AßWfÇ!².¢A6zn.~vŒé÷6Loy’Lãñ7nÌ‹ÑdÂzæ'?ŸüŠÞ”»endstream endobj 5178 0 obj<>/XObject<<>>>>>>endobj 5179 0 obj<>stream xµV[ÚF~çWÑVÅ^cIˆò°Ù@iÚ-Qú€„†ñ&±gèx¼,ªúß{ÎØæ¶ eE ä1s¾sûÎåïFüt êÓ—g÷“Fàørûcp=êB'€I‚wûoð!vÿão-„†YƒÕ`„5R<6‡–ø¤ð}*ó•5ùÖÀ »(ßiâ‘e«T´Á.$:MõZª,‹…D¦‚D­ŒPEæ/ôòzÀk?*MòÂÐ"<Ä-º·ã;øî‡Úðñ~8ü܆÷w_†ðï[€Êr¦º<ñ2þvà:Ù¦ÇÐýF(Qꪽ÷È–(òûýW$ÿI§4_¶‚LÇèHŒüÃyzÖòi+_Ë…‹ÄK´r¡<»Y h¢7M`§WÖï¸V¹eÊB}nBpÁE—&L[¿Â/~…$U.Œõd\áL[Ó+8#µ |Ó™^] €"~«þ5`Ä1Ò;_‚ƒÉº88”ã&¦øë‰§­/~(<Uàԟή*xy£bX/…ªéHEÅÀç@\] ó”ž3ú‡®œ%éð¯ßÇ÷pl Ê†›Û»Ùðó—ßf³ro6ûóë§³+ O®x°`Êb;'êè°'ìΗ‹×ö¤éx¹0%sO˜Ž/…à G‡Â‘>™W¦â§‰ó^_y`¦jÍçóŒ¥wÜN´(UUý>ØAæ_W¶˜}´}"œûá–âœ)›À¾ö}&Ö^Vî¡Õ`XðG`[f½ {ËØ–i'À®Go Ò“–Y©¶7ÓoÒT,Œ†Û;ï»™–Ó´,hðËï1Û†µ´K]XÈ7:Õ‹M·ƒ•yŽpxŸm@i sE^®ùJp™lHOÍ94?nÅ2ª”Ò 0Œ,‡Xð”áž‚p>L–¨¿É`©‘óT@lØzÎøw(TŠšq‰q—Ç3¨JÃ%…ã¶Sû¹5·Z sF¦iu`­6O,@'¨''É ÆÃ±6ÿ&¸õá+5nÔÌÑtt7V˜L*r#µsh® lóè£E ‡6n>ÂH^®]m NŒaMÓs¤âi Ä¢”Yª—–øC1—äíoKZq4žÍZæ„!ªÔ±z܆9æ’ë SA›!fÖm×£×Õ]¿õ ßë—"s½Èàƒæèˆ*‰D¶#˻ޫ²v#»0t»Œ:^ö‚¾…¸¡" Â^ŸD‡“Æÿ®¬B'endstream endobj 5180 0 obj<>/XObject<<>>>>>>endobj 5181 0 obj<>stream xVÛNÛ@}ÏWŒÌCÍÅÆ—$ÐT}HB‚¸•‹z!ÈZì±ãâØéÚ"Ä¿wvÛ¨P¢ÈÏœ=sfvÿ´L0èc‚Ý_wÖ\´ Ý cñÃØ·Á4àÂ'ßîgzðä{zpÕFÉ=„)0p“Ùœãã4¼CÀ¿l6p ÒirÆ9ċ٠rH|ˆ0` ·‡››À8gà¡1β0‰ +ö€¢ ›â½GÈ8‹ÓˆeèAgÉúÅï–šiQ*ªŸp ƒXËæéÝÐÝ%P 0F¦è(L用‡ºÀ°Äj ™„>Æí±»ºoW³,ݶ駮yè‡1ÂQÿ‡3¸;ç¿FD‹Õ^fC`䳦sæ"ŒONàq•©|"y¢ä†EÎãæ•i_©¹øQÂÊNÖUyÁÂ=_í©²6Á0<9<9ƒG8íÁWÊo öÏF£cz¶èypx9Ú‚Ó˳ÓÙ:dþìÃÓ*ú.}«¥èN/mîd›`Y Õx*@}SíJÈu)Õ” Fêáe::•HZì vr¾+‚íΕ$âEn¢&+Ÿî•`£pÉÉ€%§+§Ü©’H’ïXÖå¹m4Òl[ïvwûK9¦=A¬xW¡ ëk*œ¨a¬‘¾nY€°¦o¤÷a Ío¡&´·1Y¯hb¢JÒî*h¢*$Me²^xæ97zRùËž9!KÏR"õ 8­Ò¡Š¨=âýÕ ¨\ ‚PúÃCgt|yä8çüûÁ¾cP¼ì÷žKó"cïAÉÊWÁ¤éƒp¢‹ªhÂòA°¼«p¹íƒ€BÂU8ay쿊[q"U­ø¥ÜˆŠŒÍå­È¦.Å:ü"Òkid.7F vœ’Ù 0{±C²eÈkYöî’Ðk²sÌ<§)ZÝXŠ^¸B/Í8¹¥íÿiBÕµ,–™±[ÔB©O:>ù~oÕ ó„ÔOGaa`žÇ1M)H¶«ïk.‹"ÑTÅÚ¶œ¥Ï]Z§Æj¦ÆrÒjÈÖLÍD}fÕ’\åçs/áâ¼›¬!EZ«O¬–Ù“”¸3YÙëŒFé´±×.³EØëüUDø±iÀ)åQ¸=Þ]ÞˆÌݶޱ;ÐÝ¥;C~QËk¶nÀ^â.fgò2"¦2¹·¶“ÓfRÞ¾¸¥Â£ctuÛ¢{VgG˜F­o­ÇÓUendstream endobj 5182 0 obj<>/XObject<<>>>>>>endobj 5183 0 obj<>stream xÍ–oš@Æßû)¦ø¢ØùçñγÞå’K/õhš&$d Òâr]V?|gñD®G“ž©µÑ3™Ù>ì3ß{&ø2Árå;^ö.ƒž¡l>xÃ+ƺA #Ü Sw]‚¤Î2 ˆÕP­~ä™–ÐtÅ T•¬(¿"Zn) L¦·ÑådE­pTQE÷Ÿn®#C_l(ø”‡ƒAðµg€fâÙ‰ x`¨¶JeÀ'œ“ øñ‚pèoMcd¿5·ýpá £ÞçT¬8ËY&k×ež`Þ/]°½à˜QiqÉÖ” ÏrBµ ¢ž§žœðÌ€Öd½k2iªÅ¤( )“©ÍñVýCÑî†hÑnA<ÐL‹’0-Ä(‰ž—&¶o”pJšY‡$1Ö-ÉZE>‘Z¨¾i‰õ€·&{”þ–äÕrV Âb ¯ÓÔOKNóŒieÎpTh$I8­*  íEÂsº…ç/<§%<¿Z”ø˜í_TܹŸ`çïj޲ÕR^‚O06Á—Bl Ûñ?G€×óÙìýyà5SÛVྗ{,:÷9ºéçəɹ§!çu‘óŽ%çµÈ5†Ñ×ï¼Ð05´Uezw{7W¤Gâõ½·‘þöü˜½ŠùÄ^ò§äÿ £^]€9’룆û£f9û£jâV©»0-HUÑ Kà^ðU,vß?²¼dÒ¿Ê,7¯vf;¼£ªv»¨­;–®mË=Q®Vš¥ð®ŒWKÊX.M»î25o·HÓ×1\Ýá¶Œ­FÎXž; zz?ÇQ[endstream endobj 5184 0 obj<>/XObject<<>>>>/Annots 1997 0 R>>endobj 5185 0 obj<>stream x…WMsÛ6½ûWì¥S¥±hKþˆ“:©[§žI§ÓZ3î!ˆ„$8$Á µÓÿÞ· ‚%w:ö؉Å{oß.þ<™Ñ9~ftqÍ¿yuržã ÿ™ñŸß?òš_γkªèê²ÿRÒÃÉ‹½ñ2É­éìî-ÍÎi±ÂÂ×oñ¡õð!ŸÌn²‹ì:›Ñí§_èÙ©¦1õšìêÕâéäì8_bâä¶TÞkJmmlÿª.È׿Á“ršTYRpZ]PØhòªÒô¬v´ÜÉwSíV*×´Öµv*X—ÑuXh‡myŒ×d—O+by*ôjº²N›u= »Fs`ç4Í9Þ]†äa\%Qtkë"®­·ÚíhÕÖy@ÔØCr:´®FÐu·}ž ŒÆJ„gN¯´Óu®?¿â°nÏn_¿&ÞŸ"2 C ü1Fjr*ÇLHŽ¢ÅQÚ:nƒ•[ðò‘¦OÆ7äM¸ @Tm°• &¢;aFFuñuádSóLíƒB´„mœ$Ød´Ø? §R_´'¨jó iåv,ö2˜ÅÐzÙ®)·ˆ ˜a—UÂÇÓ3à¡†Õ œm™  IOmµ,%r%·ªlµÏ"Nƒ;Eu œGÞ×íù(c\AyTàP‰X#å>ßèJ%1!–#UÆ9ë¼ g†åR² ãP³|XfràS°6ê ÎÀ¥.†~~u ‰äª… bÇËmÕ˜<=[аÏG¤£À‚Fȳ·D’3XÜýl¼ŽÙ — ‹¬mDƒù9ˆx匮Ã¥Â8–äå(Žÿ/o¹¤ÇÍŽ×呂‚.:9b,iÔzæ"¥[½ÿ~ŒÐȃö3EêBÏ|ÊÚ‡Çû°•TïŒ{¨Ù™’kæêtiô»^ªBB¬„Tªm<‹#êËŸ7¼ÆP‘D±.¿ç¹;YIϬåR‘·Fq–§(¬RhcÇã¨SþV¡xÀ‚"B$œ5â#R> †gØEéK¦âûÓï†$Ìègû̵8òߟ)*­£M³CðAõƒN3úѬ¤‡^ˆ«xj=ð¼Q ݺKÅ¥ ÅußôÅöVyãÐpt•sk\hU™0Hvë¹xfó—ÔµoHvèQèÜn‰ÊE[’’1sÝ,KX >ƒqß–á”K0N 1Û v\ jqmä!ÊšöæA]ƒ¢XÑ|žª‰3Ž5Ú10Ì>y_ãäw+ ó!/ž¦DÔ9€áì’q>JòÁáÑŠqo9_sO&ý -V ö:7åf&½dˆÞócì9ýÒ.ÒsˆS—9jH%Éàh[4NnÓ4Ö©­…V¥,)u<-ŠºŠüU }©#ŒfBY ?È‚/%E¤8ÇøîÇ[Da¢ï¡{t˜®€‡Âsi™@Üm.’›jÍÄ[®´(q† E€VHNˆç‘Ó -æW±£cå¶ÖÔ‘+ú_ä Ü¿÷ŽoX7LÐxÆpiHPO£(—Þ·÷ÃŽÉ9ÝcI޽g/jtÞ¼ÕPÈú锸s ƒ.Kt 7øÑˆ˜Òf ^s»²÷2Q…—bÏÇk;JVSçe+.s“ÐéyÄIö“Gî"Ò¶5£J/$Æ -PY ¾Ó#¾æÀ¹vµ­w•¼ï’&Q HŤ˜â]$šF1°éÓÈZr‘þ¤bë¨Ñ‘±½ÀAY_ìr+‹l$aL¥1AÑn$¡dÏ%øÛoZì ãÀ-¦]oØÄPÅFˆ–ì%Ø1·õ 5ÃÖì{-§Ä°ÔÜK°[m0NZÁR¿ãæ½2|ÄÄg›,î«ÉmæÙž“Ø ¿¥oÀd¾š"pèëûÔþÓÝøé?é+öÆTÆÑ\M­¼:»»én|³›Ëìê⊮o®²Y €Stz›ø6—Ž÷¶¨öéü<Žž¾‰Au×—/ÜWç×ÙÅVŠæWo9îŸ'¿ü ¤J+ýendstream endobj 5186 0 obj<>/XObject<<>>>>>>endobj 5187 0 obj<>stream x­W]OÜF}çW\%ª´PÖûEHRTšB )iÙ*/~™µgדØwÆË²üúž;ã1k©TÐbyÇ÷žûuÎõßãwB³9ÿ%ÅÁo‹ƒq4ÆÍöìit=¦³hF‹MÇ4?›Dóù)-RwjL‹dpIG÷÷÷ñ@•5©øð…ŸÑYY[º^ÜÓ/üo‡ŠŽF‡‹ocNð|:¸ÖšŽv»Ý áyðÜEÏ@Áû~xxˆŒ*m ?c6Œ¬7¦$¾Íf~n®v ŽÑõ 1 ak8›5™¤Õ¦Lj¥KbÄœ r_þNxv@Ê’(IßI“k‘Ê´}Ö¾£šMi#ÕºloS"òœjMª¦­ÂåRÒÖˆªÂ£ª$AkYJ£’a‹a›i+I˜õ¦er8åøƒ$“ÉwkáÒ ¨ÞU’ôªÀe~D—Ön U®áÙª¢Ê%¹Ov%8Çø"@îeÕölú°šô ª4ª$ ‡ŒD]’^~“I}Ü#SIö|:>Ü|¾u¥eâ"Jraí¿ÅÔ%Òñr×v/#·›=ÍÅxâÝåµ—ôg?K‰”vBôùiD_UéMMÒÖb™+›ùì'¹È×ÍÈÜå_Uèz+å“V|Æ)‡ÜƒÖ¯7ç…D]Ë¢ª¹"®²½gÜ@… ½XÝ6Ge'LiŒ6QskzÂMú•²:¿“Œ‹BÇÉcZî¨Ô5Çnw¥.wE'lÛÆÍ±´ÍZÓÍRƒ‡x¶\c­D"ÑÆôŨB˜Ï ÜX™£ÏdÚ Ì#a²”¥Ìõ6>¤•Ñ…³˜ ‡*µ$¦æjÀÙˆ®µ!ž] צ½ìPˆ”ÏîÁ”€ør]Û’Ê•*•±m)ƒÑ´È}@•zËÏ>2S–Ïn<Ù®(ÀZ:ôÃñ¾}ÐÞW>/¸ö&u9Ú›8aÊC‰\×Ã{æ@\I#1v ìò‹"‚ÑfKtŠr ¤uǸì…ûúý%•*§×÷³é|"Æô+.§ãÓéùy*.~ht…M!€‘ Ã?´{>IíÊó³é‹vÁq$zç/àÃÀÐ;>?žïŽ®ÏŸ_.&h›è,šÐ‡LkËE‡@î—8Œh;ä< I¦•WÀî#¼®cRåN÷ÍÊæ£ ¾ ¤Â—û¬æ‡Ù5vÁ†Q>­ø\ÃÉN2ô?´Ô ï>ma…sv¸ƒ37ºžœ…œ"^×Qñ;d7DþnèYè©_nY± ŠbˆãY²&bâs•¨:ß# §e­p&¥;ìý´«ÛOÁB×ÿtô¿FÑS ^„UDo.Ö³c—µdˆÖD Z´¼B*ñYÊD̽ÿ%¿è?P;/·gÑ9>çLO®ûÎé:l·akE£Œ¾ºæE Üì¦Êucä$ƒ”˜+ ¶\B™ÃzJÀ¼Te»:¶*ØH@ËÛnb¤+øƒŒ0órDŸýÏÈÊéK`~Å$ê”+,ɼU0pUrúžA§j?!d™Žš8ñ€Û‚ ±CcÝÁùGö8dé³ÌSÊkðËU#cnÍ@nªÊhL·o_¾"ZdÒ­÷üÖaàÁìɨEèlÂ$j€ á 4ÚmýUH¹)–°‚® EAv\sœ€ÎHÝUؤ}ƒnd“­çj<ƒº}'aÔÈÌA]¾ùí¡\£ðÞ`v<>æ¾ Ãá+u Ú‹pƒòùíæê^ð;‰SÝÇ'вFŽÕLÎN¢7³7x_=ñzûõÓÇá,Óï:q¯O®1ÖvxêEÖS3-0ž¨à1-ÆÁ¬2çÜ6„Èß[6ðf>/XObject<<>>>>>>endobj 5189 0 obj<>stream xÝU[“@~ï¯8´.íe«Mêº5&&®J¢$„ÂÐÅP¨Ý¥1ýïž3ÜÖ‡U_L›RÎå;—ïÌ™ï# LüXà¸ô6£×ÞÈd& ?b ÆÒ„9sÀKÀ6Á[Ìu/Á‹¥• ^¤EYX–°€cïÛÈÝBi¬Áv·ÊÒèÅPi^A}uB¸ í+E´$+Bt¬k_#„ôBÁK0ýñ¼Ú‰R˜@ c£ç¿€Iš—Uƒ ¼ûþ5<ƒ…þªyì$c9*,3Ò§iƒv-xXñª;I‘eÅCš¯ñMp"Ün¹(/P#€‡Ñ‰´Üe™®2¡Xï6KŠŠÍ*ÍÃ*-ò’R§(ö”j/î¹Àòã€àXTפîÑB†6sä(Ön¾Þ~øäÁ}‘ư¸~AÌ3^ñ`Ÿ¿¼{˜àkØ‚ [þøWÒ°“¨$¶V¢ C2Јò& ÓjâQ[‰ý dòSÙH÷ÖM1LÊDa…Mò5ÆX/¹žÅ€ÕCóæÈiJWT«Úq`zeÓäÈ„÷ô×îEéÒW™àå.«d#¤ÄwèŒ Uv£­ç‘Ê>ö¯S©*BëØ•ùûîRÞMïíÖ·C>ßûÇõÈEÁ.ÏBÓÐ.¢¥kÄ0ß.&Y5ǯ1n‘:›säv=_xìø  §Î€…ƒuœJüŸ°û$þþwêìÞÖú«§÷ì¶3–ófá[ó)›93¼ûðT[–6©î0Þ‘\ßroÓ\âí ¬õK5Ø:±ç°Üåívh·9ÞÆm( .gk1 q× @f¦Ë÷..tÛµHtã>Ž~舤endstream endobj 5190 0 obj<>/XObject<<>>>>>>endobj 5191 0 obj<>stream xÕVmoÚ0þί8Ñ/aZ‚íД²­{aš´I݆´/‘"+q¨§àt±YASÿûÎ †Ò@é4MÓ(¢Nî¹»Çwç;ïP øG!Œì7w^M;$ øróSÍ ?!0 B˜æÀDç4ˆ¢3˜f5ŠÀ4õ?RàÕŒÁ³Þô[‡€OQ”Õ¢¼(¹JèEaœ-­¥¨Dáö¿“nuk“”µ¥¦ZÁÏ–?K§ñ†vc¯v÷–ËeìY'O­Í¸ç¬m™X½b£¸Ëw˨±n•r`gi‹¹…”›ô A÷r¬­l’=†v6wkŸú“XO9øHÝÃu:¼±ÊÀ\ ÈË¢(o¤šáªr¦ü|¡R#Kå§¼(€#n.ÌU™A&r©¤i(U­]H} ZfbdYl`SUþæ1 Ò¢a±) ßbX†X"™{úFÎ|´¼ö{] }ºã×’$Áu’|ùúþ]Bº02«k#ÇF¼’f˜}2ö.ÇŸ?’DBZŒ°ØÄLT`Ð#Úbi²Üƒm¡coT ›1|hªµƒ‘6B´Ÿ– caÀ´0±Wäƒ\ë bX³Ž{@Ó¼÷¢ë¸æy“Ä­·¢VéŽbS×O=˜´ü[éØÿg!Þ´? ;¨ëVi'Á:Ri,!_fx,º¶bzî,¤×cïÉCp»ƒÿ£òqßwªÒõÈöQù‹Å-Ͷcl®ím>/XObject<<>>>>>>endobj 5193 0 obj<>stream x¥—mo›0ÇßçSÜ4µ¢I!Ò4ëÒ¼ØC§½š¦Eꛨˆ‚¡L`§ÚMªöÙg7À –/U—')ÀïþwgßqÜfàŠ÷ ü…üDÅèÃfä:®8Øýð¦Wï`æÁ&×.–KØÄÏç]ØDÖléøÎÌ…o;ÂÊqxäán—ÑBÿ;ÊÏY‹'›Ÿ£éÕôlÑöæÎ\Ø´®%Ix ƒ˜$%1|œL:#%„œ@XW¬«, óü7pBÂħP—Rso[DôlÛ:ÚŸî+Z§R º#°(?ÄyI÷äµè#Vá`S*NQõ—Àn)n zŽ¢o›÷gC&5:¼Gv•´dÄ\ß [A»˜§WËfÆŸ-çΙ&ŸKœóý˜þãúëÛw\øÄ¢º ´O ŒÊ©ÙöÜýÕöù¾¼îéåÌ]8¾'†Äüë-|iùófô}ô2Ïïendstream endobj 5194 0 obj<>/XObject<<>>>>>>endobj 5195 0 obj<>stream xVÛnÛF}×W R¸ ku¡-;nä¡q‘—AÔö¡.„9”¶ v•Ý¥.òïYr%S–´¶a`ÉÙ™9g.‡_:èÓïÒÿe«ÎdÚé‹>=<ü³ è=öáN¤0-`؇ѻnaš«>L³ä¢–+|Jf3i±˜Íž.áÙÏÛû{³F+½±ýýÓåôŸNïñtµ€.¹ì¦iã2ù•ÜÀJêE©ôL–UÖÑ Ë\•-¡Ž”ƒÊQ{U(´î œ¿”¶V®)p2°@Í11‡ùê „5M&ÇŒÆí|Ø*Š5ÇWf³~™ÍN̯øLCb$QÅéÅ÷Y)ëÛå´ÜZføpê–ÒQL$ y޹€ß#"ö°2¹*ö„BŽ…¬JÒ…=›3Q'ðšzœ¤ ¹²˜yµAJ·ò&ïÊ‚Ùj U¢Íûá5ãú­)˜ ÚÒÈ4“šy’ÙRᦦ¹I§¨4Å1šR”ŽÞP)B]W:Àáa´ð±¶*LYš-£Â\­KlS,!ð PŽùPš%ÜâþG} Á¦…»š“‘ÐLn”¤©w´+¨‘øO)3–+Ú³žä"n—05m!{6pǦyª}Ó°ÀnxRo­Ê»¯_MÿÃMvÙ{|¬"Qo¢&H|Å`H+íÂÕ¶Q?ÃvaIÓ{%çÄD‰zÁûÐ.ª©$”ÊyGGm<Éèzm,éâ H£(´}‹Z`å3^}¨3Si–Í%l¥Õ¼™ƒF–Xw>GkÔ°I8D>D Eã}þóã//„kscrT.^ä¼÷£’ñ‡Ù:Ø›ŠkïÖ˜±ZJ*#)ƒòH[­Ål—Šú‚ÔDÞ5ßÃþµ¸Io`t{WÓÉùuSчŸMx”<¾|‰¾YjÛîm=Tg*tÓ‰tH_W´Ë†£k¾öaÚùÔùŒÊÍendstream endobj 5196 0 obj<>/XObject<<>>>>/Annots 2000 0 R>>endobj 5197 0 obj<>stream x…W]³Ó6}ϯØ:ã ‰o¾ …v†R.e†ah¹S^ò¢ØJâ"KF²2þ÷ž•,'Î…˜àiµ{öìÙõ—Á„Æø;¡Ù’ÿeå`œŽñ„&üó×›Ád²Lç´\ÌÒ1•4YŒÓU{§èãàòoW“tyùö⾤étÑÛût•>£ùdŽ_lŽÓE{dž»¿ðÅ;dwt{7§É˜î·pzù ¹÷Y²‘Th'm-s\Ԇ꽤£U%-P¥D&Élýóƒ°…Ø(IJê]½'awM)u…y‘‰ÚØ”^:šäWQVJ)3Ú9l±Ým£³º0šnîÿÜÞ-ïURY½]'ë›ð"º›¤|?¦Ñd §“·µ£\fJXá­M£rbW…%áhk”2G÷s»i:çM¥ gû—…Þ‘“Á‰Ö«Ü¯äïç»~œÎ[îrñM¨²æ€(]ŒÛŒïÍñ:П€ @óvÎYI(dÈDãd>$¡ ¼<Ø5ÛÃà(NŽ\“í;0]ܲ–{Ìnïž!å£é’˜¬ÒYŠg¯ž<¡×_3Y1†Wžêé¼Åò×gðÚ32ÕpŒ‚öBçŠsjpvuBŸz´ ¼EM¥8qLõÞš£¦ã¾o@¨­±²Øi#—)Ýï G{©* å¹ä fN/hvCZk,rlMIŸ ¥8“Ì)l),Y¸ŠÓIçØ¬Ä3˜Îk±BH*eÏ W²ã{qðÄp0qöÞ…ÍQ m)°Ýž/ t^xú¹“«e9„e kL{¡REV ЦªŒ­cåtG•Jp±}üôö Õ§J–Áo¤Ôäçz’?HâŒ>‡M':ՠʪöÖÊ-×™‡ïL°‹´¾TJWï(7H¦6g_N¶ÄТâµÑ#Tf‰hUÌ›«m“ÕÅÞx~(zDæUCdeãjMmJÔj&”:õPÌe*d9+ÄúÓñ.XQâ=²Íï­Äi:Dê8-•ZðÛã^jpÆ’–œvaO-¡øÜhI‡BxŽ ®8 öàBu"øáq§9Þ£ìÛ{¡a¨¬üÒ0Ý8×ÛGÔf¸£‡ƒì˜ÇŒü:‚y¹ä•`’íÎÕéëŒ%y4]…’C…¢ôZJô½ \­¼¢1sâ²(=¨ÊÊ¥Ý6 åÏïáO; ÅÊ w¹øBp![[˜Æ¡@t!°_¸Ï.†š3rG `ŸÐ=p|¶Ü –HXØàRc+ ¯¹Î£ðâë!%™- ’•¦í01'^ #ªœ-MÞ(èÆ%…ë‹„•# (ò ü` öÞvzí{3ë{¯ÿú,眻:½Â%3ØèsâÈê<Ð+FôM‹0N†Ò±/¬\ŸB7ýVBƒÒ‚§žÔ¶™gÀ« â3 Ž-†&ÇÉ`×|¯cNCÜYí§L”i:›á.OBéŒ QÅG¥µNPbå˜eÖ“!¥i®ß‡ ܘóäߘmGÔÖ¢7¨B¹?ÇÓÛǽ" ÛÆãÛk#/” Œ.:ù¯×KàL²œ8> ýóÍsº™‚E†ºÓÀÆN—?5H'0ñànuL<ˆV‚3ôK§R-Þ(ôÿG(ý °|Þ†ÕYgw¢Ü±°°kÑ4*¢…ôSþ|/‚ôk¼B^'Àm}ó¼u‚š]ߌ£k!Ï8à?6é§·‰@‚Ù,].Ÿ2ެLé4û>*OXUÓë¯dІWÝtWxÑ8w£$¶=nÐ<ò°DÊwÒqºèÜ›Âê˹$À¡æ`ˆˆs)‹r{5Ä›ˆ›'=a6’¹G' ˜\ 7$´ð-¦ 6D…ë›uáþ˜b—ÁGs€’}ò]f‹0]ÆacãÒ—ðèš?ïc7c F„@›×os‰RŒ«…áJ˜IAT¡ìbäkömFbpõÖF<!›m¢0q‡Øq¯ös›ÒÖ |EO¨îõ î²Va~ÃÀñÈ3$ÂÝsG ½kÄÎ÷sßÅú l׆Ñÿ~/Ñ}Ø!F£=’\%³bËŸ+<ÿÆC˜ÙmóIé QÃk?*tÕÔ|Àe6=è^UøŒŽ¬Æàwp/²Û1  uEòhÒ·ÌìYÊÍ–½¦øFí?À†7xÚ£Û“†ŸÏñÊš{7>Iø#ŽÍ… ÃsõÕt{·j¿É¦ãyº˜-h¹DéwcLj?g7™ÿêó²×‹°xô4èÉ÷?5ãe:›bèTL— Þýú~ðçà+[Åëendstream endobj 5198 0 obj<>/XObject<<>>>>/Annots 2003 0 R>>endobj 5199 0 obj<>stream x­˜ooÛ6ÆßçS‚¬pZ[±ìÄIÛm@—5E"ûSC± -S6;ZTI*©÷é÷)ÉV7'EÒ¦pL‰Gïîww̧½”†øIi<áÿÙjo˜ ñ„?RþøýÕÞøì4yJ£Æ´¢ãѨiz»·=ÆÛÉ89­çòÛôô$9¡4&ÈŽ†ÃvÄo·Çx{2Æq.¿ýiº¥LÐÈ.èèbHgɘ¦9V£ÉÓ4™LNi:*išõ¾óëR®DyÕSÅÕ!͌ѴóßþAJ?ÐUg]¨¢¬üóýç‡Ó{C¤Xpþå‚ÙRØ>U…S‹BÎ)·áÎÎni¬ïS=¹µ+ÅñniUldÃ÷V’G»å´)í¦qÐJ†ánÑ\M禚iÙ'žÝøàô¸O×F͛߷h!‹jEoÿxýjúþ×—ýö$woßLÿóÅåû¿¶d«Fß}•Ïš…:Þhq¡Ç•Ž.ž»?§âl0×qÖKÏ’ã$MFôË»)Mc¨ñ Ž.ŽkLsàL—’â+„uX«g*ßÜ£:\I9ªÊZÈBZá%ef.ùAnìŠ<–³ÒW¶ k¡+I&Ïn¬(Ki)·æ®IsÊ«"óÊIcõQÔ»‡Íð»Ô"ƒª«Ÿ™âZZO¢˜ÓLáÃJWiÏjéøõGr2,Úh$fæºV~®ÄŠUB¯½£¹Ì‹‚ÎR!”°™p8œÖæÆ=kLµÁ{€\3öma¯ÀºV’Ù@;Ýu\ñ\ÓÃÀ†©ïGvòžhÓ7d›îw›þ—îýƒÖƒw»îV¼·V*ä ¤˜¸«ÞAzuXÇÄ]°éœ³Ö¸#ž·h.ŒDƒÞWÍ5ðëÓ¬òTVVê5ÓPóVŽQLh€ šº†ÄR$éAºVÎ7¬Õôwpn!Ô•V­„]³.L¸]‚e-i¶ÄD‚Gøne.­,2&—‘w¬Dê]:Jt±vÒ{` ¨­üZš³àŒ[Ëô>ðØY’ù‡ÐKå—îO0=ˆaú¦Óý8¦ÛHFmý ÙÇwzðˆ÷Ejã"›RûEmFÁEŒû¥•øŒ¥9#¹Rf*W™ÐÀM®JmÖ¨p³uÀî…Öra ¿a7J›£ü5%ØØ$œŽ„v†$åJ(e‚ÐÏÌÀ"аAe¶ÛÍýRxÊDA3¹ÉM@Œ57VÚó£ó'O¨!-¡÷¦ ¢VŠ9¡¤"a`#0lÕmÓÑ÷2³ZØfïît•¡ú‡¬‡òŸã0M¸Ê†æfDçÜv4ZÆ$ðF¹²Õ—Þ8!ô;Ièx^lY%«œç†¤ñÃR 'fœIY˜Ïc³s+­<·;Üálm ÓnÛY¯Dï ÕêÆ§õVBÑóÈ;7̥ˬš±«%ZŒ0f©ìË|LÎÛ*CoR$Ú­ …æD ·± I{Òy<•ŸKÔ&ÎŽ®O¦!K‘-7ɱÏGA/ºúp¢_‰B••FЇûùÀÛ-]?tYZ8ôü׌¶kC¢ýåÒè¸ç ±‹*¦ TV6E€šŽ¸âdÀŽ u€Ó ÝÞOèG–Ÿç¢>»¯hŠ„xŠ0¶n‡)ê#l¸ü›ÜC¢õ7·™)c&¬¸2$:ê4+m0a6úëgñ&ˆ¦Ï€Ž5è8g§þÁ¶|o`ÓÀØ>î­Ò,ÊAÍqWÛbÛ°Œ®£°è•=6•ó"û{ÀîÊÚæIlÎÏWUY÷£kSYF¾=­p¬(÷l!QÁ7Æ¢kЉ7GIiÔ G0cÈùGgõån4>/XObject<<>>>>>>endobj 5201 0 obj<>stream x­XaoÛ6ýž_qȲÍI-%¶Ó4Í>uY=Úõ0óPÐe«¥H•¢âº¿~ïHI¶S×mº%AdÚ$ïøîî½£? è ¿]ð_Rü:98‹Ïðf÷ÏÎét|Nƒ3šd˜{ñ/Rÿ9^$=·”Õ:q¹Ñd¥«­®âãÉ»ƒ3Іç˜Ú›`ÆíÍ r«R¢$‘$²tù•F)³ÌõœxÉé¾x;½£;as1S2¼ßÚïÁD&­Ô‰ VÖKàcð(×÷WE$?–B§°j¼a- I&ó¯Ka1rÒÒL²+¢,U.Ó05Ç’àxØspÙ¸=‰=p:¼xrÏþ, ùÓ#S»¹£L"µç'QUù\ÿîäúm–ñ‘>w*DÄJØ[Ç”§¶H]{,|xOÇGâä¿Û¦eîd´¤ÒäšcfeaîdÓ¦•„iÓ~Þçû|@B6YûÁsùÔ§ƒ¨©Ó ³óaý—âÒýhfÒÕçØÞI»¢¼(uB;x«+gëuðú¯›ßi¹@VSUÏ*ù¡–ÚQbRIs©¥¾´*'ËŠª…©UŠ<¥\WÒ:¤P)Ô…ás­;j“º1ÝJqǹd$q/Y{;]î +˜«Z9X#•W%--ªDZFO8J ùó©Ü9%i¶¢¥XqÒ “›õNfƧcuò9cza,$¦(¤NÌ€ßv†x·À¿ŒGÌJÑeü”¢ó‹x4Â8íýØ{Úƒñé1‘ÇxòæÕs¼ô?‡Ó^¢®”t4íM}‰rè§Çøj"Èôøð—àÇÓ¶ä‡p{4Š/Pï03¸ŒÏãa<¤Û—Nh²É-_aþ ò´Æµ6ñ )tå[äÉ‚–’d–ÉÄù¬ô û¨eԀצuÅ‘¸¾}ùÏ Å|H7ˆOÕїȸ<>D‡÷W}%") ™æÂIµBb±o\$®5v#ޤË—TW2TSÖ±ú=oé}ƒ«U¢ÀpçµEô|›¯ýQýÔqV–ÈH¤{Õyhfï\ÕrUÐ"7Â% Ò-Ö|¾3ɾ…Ðwøë†B˜Ç†ÜÅôJ‰„!…åŽÔC¹¯LBA±ooÔ‰)#ÎdTöw;«RˆÆØ¯‚\­Š™Qm XIZ/f˜Ã!BP5!t¨/z?¦g¬çñÉàz ©­üËr-Tþ)¶µ3OžÐ\Ø™˜K0ŸR$÷·5tXqÚ«$»– f$`\Â]‘„ééñN¤v÷wŒÎwp¸‡›£ú”,„íS­-ÃÍA{HŸ@-Í4O°¶u}j¦7£n¯0Þ·0t«ýën-ö­TFÏ»¥aЭõÃ}‹3e §¦FÖ'žß :éÓÉÓö¹×©ëb‹†=ÉŠevòÀm0w@ŸÅ‘‰ûïg/ÞüÓ_op²×X»Š~j"ø¾ïeÔò%ýÜ$0]µ'Ò¤‚.€+¼¥ÿ¯ûÆ6:A9ñŠro'ˆÊ> 'ÃcÚ{v}û¶‘[/SßêvcÔ«ëØLB k­øìÞâÕ'i :õ€‡Ål&?b»*YÈ´V2Ú*ø£ýü×ôÒHï7[¡õNm NÇûuzDãño¾.ÕíÌV­—ƾ‡²âR¡ññt(@iès¸[ó­Pb4Z!ÈÐõéõ£GA~ªR&y–'žôX¹A J9·Þ kðW‡íu1M¼­é´=…µ_¢0ÑdÙ2ò©­çï Êw‡~²Õ~íµGØyÎËqo‡þMAPÏ-o!ð ûͽçÚ·è>Þ°šùö´0iž­‚Z´æ™… w†ùTƒëféÞT¢ð „5õ|A­OÞ¢ØòdžßI8Ž#Å4††È¢(™¢#ïµß©À®âRãܢ̕¿2tͳ»oÁ|l+‰ï_6c +òù»¤)@!„ˆ^±7|ól4„ÛÂáðsɲœlD„QcA"¦Ï¶»l»žh»»DKܤÔfÓ ^Ys‹ÆuÝ#b5ºiçøöãÍß à÷êþ]×\&<îܦsóÁÍ ‡;Ù-¨›ð!ñ-ÀF~®»°¿jLýn„P_”„5œ^}¯Ö(î éõìu/⻣°wý†ÌcõÚèé¸ý.`py?=¦ <›;KP4ŠÏè7“øÚò!blç0;zD¯¹G |&ˆ+Zžøø 7šaøŽ_1ð[Ï'ü rWtendstream endobj 5202 0 obj<>/XObject<<>>>>>>endobj 5203 0 obj<>stream xWmOãFþž_1ÊÑ*\±Ib\N÷áJIõZ]‹«ªR$´Øëd[Çëú…€ªþ÷>³k/ À@P²ëÌ3/;ÏÌlþéhˆ×ˆ‚ ÿG«Þ÷aoèñн :œ éÔ(Lh<¤É»‘?™œP©!…Ñà›ê.—+‘ÏI¢x=ß§r©‹ê€JµÈdlwÔŸš§ý÷ûá_½!y# ãè:{lx]5¨ìÞ:Ö°÷—X¶ g·:ÕÙÂÍØå—n`ÎrG|’jÁašÏöb]_§»è€ˆ–¢ ·ÔŸÞÒ”7óý¨­b‡âMwTÊòlȬ^Ñå?†~9ïœjø¶‰iÓ»ÃÙ;b~&äõ^4¬ŒNý#ìÑç‹Ë/Æ^hÙϤ>œ5(`ÆGLïp©J¿Ètµ”q}ÎÒ;ª ‘•‰.V¢R:#Фb®KM¥)/ôŠ%I©*sÑ´^ªhÉrü\ç )6ªˆI‹z%Áx•µe6f?Üó2—‘J\Q J’i,~HÔª‰4%vʧK#x§Àbqo  ×Öt"bweÁPc´”Ñß Flðs§3%å¢äXUæSˆ`àŠ¨ÓŠ@¡$ޱ¨=cD'§ö 7›’7ûA€µÙMø¼†ft­uJý(òBŠìQJm` Ûà U²è‚j«–C.º›ž·ú! !Ï>¼¼¤ÐžÖ£Œ”²íÉn°n!3YˆÊÒn%«¥F9DUÈ RlˆgÄTä%u1ˆ—ëBä¤odŽ#·îûm €éîZ«jÙ&–¬ånV¼Q ’9<>8û­¬KB·ô·°­ü»IÀ:ÚèÍУ;Fæ9…öÛg•€nάY;¼{ÎÃÆáíÆ)0Ûg5l÷b&—Q—:hO±™e@•h ©ôžj›ykǰvù¬É9ÛEûiǶ©<ôÐvo‚€~Ö±JL›ä‰B×r)nj¤fçÛÎUòÁ="f@H”7U—·b•c.#Ýh²x£µÄhÀ ÀL ˜Ê×(/§™…ˆQ¢užãÒåêsÍñ\UFηæŸjš¦_ÏÃϵ³Oçg?]ýþËÅÙ§¿¡zZuÿÒÞˆ>Ðè=ý×^ä0!·Z¯Ê ßüµ°¾Aí©,¯«÷O´Ò{¨CÎÈH*+šæƒ=]óO8>/XObject<<>>>>>>endobj 5205 0 obj<>stream x­WÛnÛF}÷W ´` “ÖÅ–)8Ia mÐFh_«åRÚ„â2»K+úûžYrI1•‹4(bIJĹ9sfôélJü›Ò|Á?rwöry6É&x³ÿÏnèâÍ„n²9- šMhñlš-×´ÌÃSZÊä;¨ÕNÔ«¤(4¿^=%¢½Ü û—§'·Måô¦Ryê¶Æú'?>]~8›P:…q~d\jWGëÞøÑ§e|ô8Tgö¨‡¥pö!dyË© é•ý/–?И:ouµií.Þ<£éevÉX¥+ßd“V2½É®è>W•×…V–îLõ ,"RÑTÒkS9†%x˜±=¬g‹ìæ†1bãlJwV `仵)éŠüVWEªzÐÖT;Dh]Ü: 9åÉÂjÓ¸Þ~×8OkEU)+¼ÊóHÞÐ~«å–z”«BW:d}>pNexQywNˆ%Ö¥ÂKåeF]¬Ø{Ô˜'kÓTyF¿ TaQЍ¨0V*T ëµlJaÙéãf§T‰c§b%çS= »Jp‹:Xt`“vÔ8•g£|^ð{6 Õ1½Ã´uÁí’ˆ„Ø·«KÅp#ö¡ Ö% „SéÎäº8 Ùsrr‹g›Óvˆ:Sòä¾:jÀû?ïF¹:àh HBÎÀTWˆ^€cÖ”ôP²ªPVU ¯¤½kùÐV`h'¤5\°®PwH{¤X‚B(eÁÉš#E™‘+lI¢®­©Ñh[1¤“ѽç¨x)«H}®‘xŒÏö§¢Òé#[U2ðïÛòÞ à²JÔ'ô¸-—6T ©…òd vÓp§\h÷3ÖØŒ^Ö. Ø©¼žs†oNÌ×roh-œ–G…‘5 |*G[ñ 0mȯ#ØÍ0¨C6ø¦‘VMYžˆÏf¿ ŒÓ*aAácŒ©Õ*nJ .»é%¨š?ϰ:ÿÒz',PUЋ½öÛÖpÔ¶6F¿°f×)‡ˆ=Úë² ŽXκa=9‰Âì ¬x­G€xÿeíz™ÐŒ@2N6¦ÂÐöPcè\FvÃÁ,ª@Ú…(ŽSK¸ Ì#,¼•c°CWŽ(x²Ü9½R…hJŒN¯>œYÇïAʺu1b!³àn«äÇк#‘Ž\kzÐ~%VØx ´Øâ<i&oõú‚¡6ÖÈrx•¹ýfÜ…„%¼wߊõPBó#,†•×@@[Z0%³?–ø!Ûqx^›Ý¶û5ïõ§ISæÌn#γS˜²4û°r!]ØÜíhÝFp†»(ͲùWRž¬€ÛœJ6-*è•Îéûê@|Àtû»Ò bY–­M~À¯ÕÓðÏИ9ñüùO‘ y•@ߊîÖ`¥pÌæÝ±–,QM̺kéý«1tI?û¬×pÙ@pkDçŒNŒ×lw1…ïø‰{µÝpü6”‹º÷ÆæC$ì0ÝAº0Œ: ßÉW«ãÁ R6Œ/‡û¢l` C—ÑrËrǾr¯¡ËØ`X*ØÓa‰zÚªÆò.ì_,ϺæÂ‡'8!Ç5d„pqB¡a…‘ëweص±¡áôA`õàd`4®9&``Å­Ž3+nÛk,å³9 º{ûî}K©n·LoºN¯±O•V3\¤ãÎógé4äu‹ ' ^Açønk÷^m#=h;8î§%CÆëV°‚Bµ—ηÆ«ü¿‡,¬RÕÿSľž¡ÄБ½,RÅNù­Á¾ ÙT_Õ§ØÄéõU¶˜_Ñâz‘]†o̵tžMè•‘áÄ ³Ãˆaþ/³+<œ^ó¼‡/—ø÷K>/XObject<<>>>>>>endobj 5207 0 obj<>stream xUK9¾ó+ê‰$¸§if€AÚK’M4‡(Š)—¹xÜnð¦Ûfý¶ÿý~Õ†QP¤E c»Šz|õUùŸÉœr|æ´XòW5“ÛIžå¸<-~G7ŸoižÓ¶b¥å=ve§€šnªJ¸ƒö2:O‚¬lt I•óÚì,)Y×TêÊX]Ò³ Úà(¹`ùÛíß“›ÏóõàD¬2Žk[N‹åŠzéËļ`éf§cÔìtØTɪhœ½Ö^ûA*}–ÇÇ÷ïûœøþZÃa tDg¸Îè«lÉ똼vSÈ+ móäêÇ·TÚk{½ÿ õá¼Æë…¤ö$} ùÇì´}—]uíâ’†ó Ñ'oT-C¸ICp‡°¿Ú_lç•Ö]ÿ†,¿Úç³ôF>Õç~OW¿ñ9êü/¿¢Xg÷$Š[&ÿv¯iÓ!H?u{t¾$éw©Ñ sdcwÌ]þ9kHF=£{mÉ:+¬©gd¸2¥Q2¢yã^F,šTò D%VSôÚ$ Ä>ó"›‘õÃA+V+© ¬K g­Øþ°³uKòpÐÒ¦H8šÝ† ÷®äÒtºåQ8“{Ö¾v²äãÐûHí!z–uBŒâu˜ÆF½CC¶ GnSó„[W@ tN0]§á]Š˜aã!xj!€‡t†jÞϧ #LK®Õ|Ýe·ô`{â³Ó¿~<|aÓ)hÔæ }4*¡ά å,òÄëpœ€¢0ÃZ­2ÕqÖ[<L[¶ùÔ‹aS]g´uC¡¹uÈÞÓàé⬳ÁÀô®ñD`W4—ìþ^?ž•kiKQ3l#7áVûꄽK5pd^³•=¥Ö%:š°ïÊÀõóè<Pµ,gtdBô¯ÈÙORPCÿ»3Zg N©`8‹l±À©œ¾é¨G’Þy§j ƒR4®Lhò¦6q€øâ}ïq|ÝæëÛìnqGŪÈV½W&ƒXd9}rªëànòßD‘÷ÚbŨ´ Oü 2h{´ Îîòe¶(úç´Xå|õçvò}ò÷ÿt„endstream endobj 5208 0 obj<>/XObject<<>>>>/Annots 2019 0 R>>endobj 5209 0 obj<>stream x½XKsÛF¾ëWÌÁU¡+&H€$H:•ƒÖ+%ÎÆ]±*Um 9^Á¢õï÷ë 1¥(9dË.Rž~Ý=àã_(1ýOŠ‹y0Çúéã??],â`.âU,D!Ö«`Ù¹¸éyË%óâ-¾b&ˆç‘…çÛ ö˜ëˆ”." ô2E’> Ñ8 6׊Fs+:§ï˜)õhku5ânGƒ»\[kÏ7¬x³%¤×#!}¦O“ZÒ0ˆ²ÚÕÖæo»D,– µ ÁÅ I˜œøÕÆ&wµ$$è‘(Ê2ˆ<^gçb¹%m…XÌc˜´Iú4¸‹M°ö¸á|Жø¤j‡‹54[Šd}ÜÕ–dù,s×Û <ËFa„\\Ÿ.D„àb»ZÀÙØÙÂì–$-Az=’²KLʶ£ÁEèKŸëÑ0-áà ëÓà.ã1×£ÁçH£'ëÑ”dJöÀõip£ÕHö;¯Í¸×šƒ˜]#Œ5Ò¾ËБñ& ֑إ܋s±K&áVÜüöþ'!ËT\–iSéôõî‹§‰–5!ɨ¥§°½\ÅÐ4ùt¯š{­Nc©Á~ˆøXlºF"ðW:¹âµŸÿÖ ž†äì¤÷K¨¯²¨seH”œ°Ü«þ©ÐeÛTi—´º*ÇÚŸò&ÄÃ…óg5Ñ{¾·y£Éñιô7›{÷ý÷"É¥1ÿ'{ŸÚ£jœ-N7gpø`< •}*—Óš¼ùk!ðÍî×—Óú-¦f×§Óˆšx-ɃÝQ‘eÝ"²T™¤Ñ{eûßaºº®šVT™k‚€ls÷,ÑûÜ=¤u…4‘|Ü6çd/Øpл£rÚΖáD&u“?s$ƒr°UÍù8Ž¡ÂÈBÑbý"ïåqBaóˆe«ï•x_"ªL&JÜN~ùøþöµ€‚ΨT´çÐõJ"ó\dMUœ-±tN0à #­*jC8©Rˆ+4øC{ÔåƦÇeq­;aU}ŠÇG\ÿM„¬ë\#ï°wP¥jà?ô’!R&‰ÊÉÑßnXìÖ¨ IU¶R—FH‘©Ó98S«Dg:eÕÂ(Í87C^¨otÖáÈÆFÍÒi„ Èu"âÙ9ô=ÕÙѨß;Ý×uœ¹sr]nþù¯ñ /·oÌûFúãóÒ§£NŽ"‘¥Ø+Ú´€ 0ôÕèzÐØÑj r]Þ™@̯’\×F±u‡5ÀÆ`‘~cÊu¸?Œ|éLËàJª¢ BA;€^U9ê†Ô0šo'èšSÉ*~Õe÷•Ü£F9V¦}#ö]+~ÓeZŒ8é<¹ƒ¨ÈÂèBç²y#tÆ~éT•­FcPXôˆ:G'™Û׸LÑAP¤;Wà’ØS@ñCÕ5¢–í‘Ñ•4J¶hY‘¢œI[‘½ªPܵ#o¨£YÔÕµnª/0è`™r2>_î~¦øJE=!¡ ælÿCÒ+yȉº}ý–ŒÌ®ç‚.‹€iD8Åux*¼âxÌ‘ê_ýüéÃÕ ©¦ï¾§&½›"õÝ×ÿ~ÝÄ3VûöÏœDÒZULÿH¤„ò&Þ¿}E¸|ðÀ%Š;äÌuÝe]‹e ©?Ð¥Iá,qm Ã¨§@AŒ‹{\@ ÒÊæ Z¡Sšñ!¡¸,ôáØ"Á4뎲<Ð,JU­Ê”þv¹DFµ] 0d´:úÎÀܪ(ù®†€Ézà"ãË Æ4ð¶Çmáì‘m3º7ÁöþA4]Y’MRç:`¯òêˆÏ¹’‚E@€‚étkì§ê^'ªlÏB /8ú‹޳òr2³*‡/䠇ܔæ¨ëœ4ðÏ×È®L‘$rÒC‡,¯%àò˜ä¦¾äʰo(¦}§sÌæó¥RIL¨Þa~ó˜JÏÃ8O]О™ÃÀfÂè:GË3ä/M‰ý˜u%_.©+O ›ßhxëpQ¥:{@<‡¼ÚcšÜËFSÙq­¤ú¤¾ƒ„ˆ°uaÝaÔñ’s˜ÂÂì¡w’Mj§V¼]™4äh\÷«ÔBé|'@<ív*k²¾|ëEIì‘+5Ò3(ö?¹9éƒÍ­e¸œÀb7Ý~˜|Ok°¹~,Ý™Gè7ˆ‹á9àþ‘/Ó©…ïc]h¦ ±^•ʾ襤dƒûµ1ç„D‡[íy]:ìRò^x¥˜Ïíܲ”»ÑÎ/*Å»~Ça‡ÙaqþydØæ/tÔáÍ|`ÓmUcǶ’¶bÖ÷\£2\KÜiÇ@f‡iUmþì`èÁÑ/$᲌Ÿs¦Ó’.¤ð„W_0ë;h:•è{Ý><>•ÜɃ ó@(P€ÁíMø'ŸË²ÅXÞw‡q¥§¼ÝÎCÿƒmÀG 1M2ƒÕYí½œ _0žÇZ'ö~L¹OU&;´P[ýñ^­å“ÑýÀèÂ^â†Ã~»oêÆË>W|pv}~Qæ¸VÁjÚ‰öäú ¿À,"û­C²uµ»ø÷ÅÿSsOendstream endobj 5210 0 obj<>/XObject<<>>>>>>endobj 5211 0 obj<>stream x­VÛrÛ6}×WlùÚ®@]bYq£&µe<“Tm¤4/œñÀ$¡¡¥x:ù÷.xEQ±õPÛÃ1ÀÝÃݳ‹³ø§Õ…þv¡?pѺu3ouH7w½„`Ò!éÃ|½ ^uÉ`ps–Yu`ùb(mJ¦•`Dr“Jó_Îæ·:Ðî¢;´Ú¾%áãI«­`KnÏZ%O±œóoöTÔY¤U?km’¬¹])Fr!—Õ†¯¹´³ý22$3MÒ‡XDÅÔ˜mÅr† ŇKfà·Èа5zþ­­ÊT@¥6I­[ÂdÇåçrbm• ˜,+®lóМmp~cÇœÁvÅ%ØZ„ÂÀBhc!ÒœZΜÈÞN7\kÁxãM‘úû”g¡Ÿ·ºáìNKeÄgáóB“³I®I…x ªÉJæÉíXI$>k‹ÐÿDbúˆŒ’52<+*zœSñÐ/+ž-„d®anï˜ÃÂvŸîªS¡U…©£ó:†¾÷‡æØ/>¥òXHж„0”Þi8õ }É·E4Ú3ôó ´žê^»„~ÕFGSÍ_s]aU‰~/*Y¡×{ÍOñÏÆ×Ðw,Â'ö@UB“Ïrˆ=¤]>E›¤xظëwÇBYî*îýbWÈ!…YqöS½UrxŒx'Mªyqâ\1,P pŠÑhllââd’D› Y‘ô!æ.68Þúû4êT>a¹÷…ªD^­ý¢’Étüyv;ýòûq*Ê2îôý˜qiXQRêŠ!‘‹q0¾¸€H1~LBö³ª—¨AÜqZþùôvÚ°.ãÊÈVÁä%¸åÚm»×/&˜?wÊ÷€JÆ)ô#P†òLf0>>`‘ò­Ƈ‡l ¹‘WTÕ1«{ÖÓ@M&«ï?ßá¿ ¬Éú¿—hµÔtM û¸1*Ngå@¥:â$Ç¥Uef=7Rx)È?ÃZ1±x„<$œßYf>ú¹²NÙÈ·u|4µÀ§¶æºt®{»×#ý>Žyæ¿~ƒÎ€o„’#¯K:v6V…eä¥vÑzo~-ãËFÞëBrª?dÒ è.Íuqy+k“ë 0ÑŠ¯©!å=!Rë€&_y±çÕ@v/®•(áx–]Dšlž3q×»y Ç÷ Õˆð¬ËŠ‹åÊ>ãs|.l?Œ]°‘÷öB°`§dåÛÝö3­‡¾Õ4¹òv‚Wý©nN©FÆ…ú>/XObject<<>>>>/Annots 2022 0 R>>endobj 5213 0 obj<>stream x•Vk“Ó6ýž_q‡)C Û±“l²-L—…0P†¶l(_v†QlÅëXA–7Étúß{®/I`¡ì#ËW÷qî¹GúÔéS„ß>%#þK—(ˆ°Â}þxû¢“ GAŸ†É$ˆhIÉé$˜ìžJºìì?/iП£½·ûÏx;Œo=ñÞ§³½p.¦É)œF4š-(Žh4é£Ñ)Í2—TD³´Køyòpö±Q¯•¬ûëLnìßJ®VÙNT™Ñ*;SÙã{¿ý¬²ðÆ®Ëö÷î4.ÅV7öÃZe¶x|omÄêCª++«ïï)¤Ê û½MáQúáejtYrÇo^«J óÚeäÞ…ÓqÕ êŸ^œìð龕óF•ÙBÒÊè2µ´V¶ c(-D•ËúŒ‹>„¸ÇA’ð¬ûð²”ÁQîíîu^ÚB7yÁ±Œ$ÿJS%¬º‘´hªÔ*]Q*ʲ&U¹ŒRÉÚJ‹ÝÐRliÍÁ¬Fj2½†‘ÀS¡jªÕrU¢†n_‰Abµ"ÓT5ÍåBÙö-æ”E–©*o£ìRp‘š*S#^--5+ùçj¼Q)rÕ† a²5—àêÎá·Hra§ô쾫9ÞÞ&vT·\î`à~ìÂdŽd©WÒ<à’­ è}!šæê­ôùîò¬7Z;—TªÚÊÌ׫k`o­€rÖK ü\©®åwÍw øÜÛQz ÿ¤í»[ÿŽÖê<‰{£gOŸGQÔïM¦Ó1¾D½¨?|6Š/’^Gýqw^¸ì;i;ã–/¥@{™žKk2Rd[f‡ªj "9A„R¥ ™®‚ ðn÷Õâʨ°Ý>/XObject<<>>>>/Annots 2025 0 R>>endobj 5215 0 obj<>stream x¥V{oÛ6ÿߟⵀÒV’eÇŽÛ-\'iݹéf»h‰¶™H¤KQqŒaß}w¤äWݰ<œ¼÷ýîñ­A¿#h¶é'Îjõ Ž7ôÑÇðC­§Ðì4ƒ:dÐnáwHaTÛ9fÐy4vÞvŽD­(@-V 1¾ïh²êôÂË:t‚&ŒgШC»íö)ŒkOƱ÷RÈTH/ÿ:ßÔêàGxxüÞp-AHø5“‰Gÿß¿±WëÉñ‘'ª˜¦.•Ú~ù7Q‡—'@Ògà£1~£Yãõåºå0ú£ÿX3•¦j•¿s<»øFÐl¢;‰÷ò•˜ƒÃîøKß²9¥çݹȖh‰¯ “ ¹ŽC| é-ܼÁ!¿gDz½ÒlÄ»WxÖjkîœK®™á9˜/-r3‘ò­Îk„ƒß8!ã1§²ãÓU? Ÿœê¨SEì“m33i`«Ð8ÁôæGïHþ?bêߨ·Mw'x[ù~…ЂÉyFA¬9Æä†É„éº2ÑJ$puþ L ‘&¯sÃ3Ô×=²¬d²Ûý„yÏCè¸Ä,½«ô•ì›|éu׿vÇáݼ˜x1KSÈÖ>jrLšÄ6'BÆi‘p"ê .ºÃëß»ÃÑ÷ùËù×ÁÕÊ,¡WŠr…çÈFÃÞõep1Ú!«ZrñS&¼ÿÚœ_>v‡ç׃þûawø§3æÉ qnlEî÷+ì"ÞnF—†¡ä>}Õu<, ™ÒXÒÊ}JL5̹1T+˜xm +au](ëT`wˆ·Ú*¤«ÈäÖwY LM¬²%&ÔŠÀJ¶%N‘+RÙ‚iT¥¦7<6a‰«TL5Óë¾fY :IÚ”“"eQú<^l-ÙËeocP‘M1ãUÂá§MîˤþW¶MòhFÖ«sƒ¡GLrµ'¼/1Üè^ùu@ g?o2q6áAOBèJ­0òÌØð÷û¤lÍ5,°¥O9—¶–ͪý˜IXieÿ‰Úw¬°v¨a8f”•a"w"ø¬1[Ûkò†Æšk}žDdÜñrº‡ªçxq³P ÊÛç ú~²UŽp>ŒìèØé–[‘•ÔëÉAkøvbY°±Û¾c˜ˆ‘®‹Ø`E {ª˜}®râ,qí cM0$Ä¤Ò A%¬«±gu>GJmøêPPrÏ^Ø{ýڲ«°Òm[/qj£©wÔt·ñœx›æPF¤û[Ý ®ÐªUh·)LŽaVÈxÓ ª6éÈígpÒØ_¶¯k|ê­§žçø\¡Ûn&÷o,$NN¬ç1Nœ€-—\âs4ÆÎíÌÉ Å6Õˆ;‘c‚°§Ák¸Çß#›L:­í ±H‡9&y´Ý€Üp 1Ÿ™Ë"¥™FÙÃ]橚²î˜ ÷£2þ|eï&‡¸Ð;,2¤EE½M@¹fÍPôN$¸A]”´ÇâöX$È´3ëIúž_½“¸a‘}OÙU%%/MiÑIÔzÛhom:pšæŽ˜9˜;ùF©[à³¶ç8„ØÃ„nݨôã`)CqàUxYíSQç$h5[Ð>­W%ís>íä燧¼£öO]"ÜËq3wzÉàV½4nUkœžÐÕŸö[íݸtHendstream endobj 5216 0 obj<>/XObject<>>>/Annots 2027 0 R>>endobj 5217 0 obj<>stream x}UMoÛ8½ûW ŠÔ´¢¾lÅi]¤Xhl —^h‘¶˜Ê¢BRvÅþ÷¡$¥©c±43|óÞ›ÑÓ(ÿÈrúÛÑ$³œÍüí,¾e9$yÆH“˜) ºO&ðQ÷QÌbL¦KB—‡Ï£tB¡I’±¶ÎRJ÷¿*XŒÎo!1êôôïåYA_Õl šÇ0e,ׯÏ–ç·°þØ–EþEð ­ÓFÂŽW­|³|Å&"úù‹o›J2+Ý\ëÁ/oþzø_ëS£›°Ž;U@¡këL[àAp=Ëí£þ}ö€0.ÖÉ-«4ÿ¨•áæð#xÕƒzõ"’h>êb !" Ó¬' ¸ÓÛFU\)á ßqÄ&$p ­myõÚZ!V^U>BWvÒX¥kÐk‹7 ¨5v¦0¦•x-ÀÈð<¹–{Àè÷ÔÖ¥ aš²,CyDð3¹j7íã}±:C£Í†Ù½Â‹"9~;½Ru´ÀÈ… }iÆ›ŸÐáx—‡¶>¶Ç7\Õ¾#W* Nm%t {jÙÊŽ<ݺ¦uШµ XÉJïß-õ^Õ_ËHÛVŽˆ+P‹l9íÜyÖ{bf¤$Ê”',“QƒdÆ#¸{ûŠŠ[ ½ä—M´cœ/LX¢ è”ÆÂ]F ŸïF‹ój«­%d®ä(1ÁÑV"2«1r§tk¡8œÉàCï‡î#ŸZE=c~Ñû õ4ÁnDÐbUXP*‰Æ-ʃç‚Ú‘L[òÿ厈«; Èù0u}ÍÔ·8WáFr‡ÅkøP £•€ÆèGYàlQuáŽðþÈ wtæ%u…Û•À^h4/ðü_%38ñí•?ÁB+´ ç†{J¿|½ï{ •E@‚àP ¥â±Ånh¯‡¡ãf#ÝÕ‘¨Íé–ÄÓ5ö)¹©ØA<ÌåjÅM|êö—wŸÑ—f_Æ[3`’Óî¼ÕŽð^‚÷0¾°æ8-GÎñFÃ] ,ê\†ì”;\Å?ùFÂqÊ}ô™åKù5¢›ˆKz®ÖÜW½?*rÍïc­.sƒKÐ*CYêS­”\ ÙkZžM½Ã°`4¶¼.½/UQâ‚[«®[s9 ~(‡:ôéZ·^›Ñ Ì Éû㤔ý›%šO{ç'Ó1›dȧ9˦d¾Å÷ûÏ!½d?ê¢%#áÛ©3Òׇ·ÝËïOûgcÁ–Lo'„þÓrômô?(EX0endstream endobj 5218 0 obj<>/XObject<<>>>>>>endobj 5219 0 obj<>stream x½UMoÚ@½ó+žš‹µñp”KÓRå©UzAª\{)›øƒ€¢ô·wv×¶²N ‘*°ëç7³3ïï{lz;ð|ñ‰6½O‹žmÙ´Ù~å¿1œÛ˜Z+¸6ü©cùþ‹X¢l,"#J¢Àí:Ü2<ž/îz6L‡®Äƶú•ð(Ðö KcyÞAƒ^i!hŠÁà¢sÓSg½ãyY… þȸ§ÙLó-¶8£L°ÿˆÃ¥Ñ –ñXd·ÉvliÔà˜ÀÍßÃò¼¢I°†„9 e–—°ß€nYÎ7¬dù1|Q†%ž–MÁtʧfI£6¨]ñ<¢3P]y½a9ß…%ëv¬>CƼ*îS-V±ÚRåÔëêö¥!V8ÖÐN½ôh@§¬Z­tì«E¸½¯¨ÿR„—k=Ò™ËPm d äÝKC,þ[ †óD³V0I¦ëÕ6Â4FDº,Ê5ßl¶a©PW–’ºä®°‚˜ŠÁ¸KùíCµ¢íV]mø ¬x¢Ô£ Óu-Ï£!Ã>æ¢<£AX[N)öŒ§QRÅ ÐúƒæÉ³˜­xÊpóóÛ5<Ë9ã™ë½ñt6™y®7ù!E½!óÊɃ2Cˆ”= É"uà6¥ì0½œ.ApÊø/¦ØƒKÄ{]#ÀAnôíÆêØÂÐuÄzâÙ¸P˜ÚÊaAÐΕG­>@ÎÊ*OeúÊyõÏ©:äš»^œ³ŽàöEÞO®,øvæÒ*ýWì¦×¬N¹a}WÊ££´G½r¥|âöÇõW1yY¾ #&U–“²x«ÁQFº%óˆ~1W×ZÛÈy;œOk“¹öÈ")ßL…cDDÓ³l|΢ªõ§  ?+¤9QšufM¥!ŸÊµ}xlû–çÒŸ(݉´Ç—Eï{ï/„ãBendstream endobj 5220 0 obj<>/XObject<<>>>>>>endobj 5221 0 obj<>stream xµVkoÛ6ýž_qѦ¨ÛF”‰óØ:ÀqâÖ“l¶Ûa@ƒ–h›‰$*$×(ößw/%ù‘æ5 ± ï‹çžË›­Tñ]ƒF“>A¼u<ܪ²*>\~é)ø*° 'P¯Bó°ÆšÍ}†U…aPñßCGFŽ@|çq &á½ÿnxµU¯†°ò&Va†P¬¡=Zû±}-“ ÊB¯Jk³W€7ÿllGï=a߸ʌ…©æc°3JË©Lx3ÁC¡aB΄?…ö€?¿³ ü<ŒÓ«7м+ÝäV] üÕýÜÀDE‘š›H”èš[çß >|•Z©´¸É¤!Â5´q)P¡8¢D6ëëÕë¬ÑÀj‡•m0s9gȻⷼ”×|JÉM-² âÆuOe6”Œ|Dø„ðï à*‘~±a4מ{ö¶;½Ö§Aábu÷{üµÛ; >·ú§'£^÷¸ßêÿ‡ý v·ÀHšP QÄîÔYM ¯½œ[s‰U*ÎÖÑÉé# ƒd ¡”>à`f(Z!¨ñ•¬_2’cÍõ‚ÁEfSþæœø\Ç‚¥W«dèÁc=W󼜊=D|Í9Ã="qÊawHaÔ”¹–(._h¦Òv‚CÉ¥Çu¬ÛÎàL…r²È}ãUÉ](ó'†Î'o›Fóšt—²W‰V±ãV(&<‹ð¾ð)û¿%.z9N•¶DUMÆÓ”µ+o¥]”À¼S± Öʰã, #ñ(êVŠ9û†_¢æ2œ ‹ö¬UÉsCÿçZ/\O¢-šd±°3²| ·3u+b‘Ø3÷¼Œ,/\š#€».Áòü°É¬HBe7øüc㱺Ìð*†íOá#$Y•Þòêv• —òu ëwÊKPí`—í5ö ‰¿ÅÝ®a^ƒUáD¥ä¤ŒÂAMÏÑÞ~îªvÈðJ™E¢d©Þ«6Y£ž_°êûûôèt¸õçÖ¿OŒ Õendstream endobj 5222 0 obj<>/XObject<<>>>>>>endobj 5223 0 obj<>stream x¥Vms7þίØòÅg»Ô/mê™Æ$nýÁvhÓN.Ó‘uÂ(=$"ép<™ü÷îJÀžtJìøtÏî>ûì®>¶ºã¿.ôOèGL[£VÎr\\ýgï¡s™ÃëÃh ½NκìääFe8•ÃHd€ŸÎÁ xUÉ&RƒŸHૹò Œ•u„•ÜË’ÁAgô¡•ÃQÊ€ðÓí\Z«J¹µ3«ï*%`nT FF‘]Ôº¬$8>—å•vžk!‡á‹ý-„Ï[+䳫gÒ²1õ"ý¦ô£½Ôþ%Šì «ø£©=›r¥‹ýåKÈ×"82‡û³Úä'çPdôÞÞ+]ÒÓÅãUIXªd·«³ ZCÕ&s2 YûW+ƒ½7µÞoI±ž1Vºýu8×f.§ÖµôƒÎhùCaMU)}ÿt³Øo@7CuáiC ñý¡Æmi¬&Ð/ öôM-` µ÷˜BÈ?EFF`N)ù: 4)a|6“#n£†,iô9Ú4GeKÒ{‘¥ü^Ovƒ|©´rY~³™&8,£¼Ö®¶¨ë@!eÝ3zIˆqI5›çcÂÍï*I¾AZúë4ÚZ?sËd‘L6®«*f«Èâ_â›]Þ~þýêöíMš €e›ÄâZêðò`Cɲ¯8P¹t‡‡ L)S-d=ªÍm—¢É?¢ÜÞ}bÑ­”ÑquKŠÉ$C;ô'¬pf*Á(÷¥R! ”ØÈ •[üZdÝ<}<¡YhSGˆ±ñÚ€Dáo{Smë9~¬9Ima9~ý–]Ä#ËnÛr“Ô óHõK!¨eqêU›üTNï°o„ͯe|‰…âyEuBÖ‡>“ì^úGO.è©€ø$†½FO2“ôò:zUrÏqªwyˆ"º1‰„‰y@C ¸†Òà@Ä)X;ƸÖ8vàfR¨1†íÍ–BI4F÷¢"ö@TÜ9–8(hüYd½’ ûYmÿIœ7èlíd˜ÛŽ£p'Uœæw·ƒ á‘]“[Àu±êŽâØO‹{u½=nެ;›Ô?&ñÊ)rŒ”) ¢¶ç`WTÄõs˜D +‰¦u¨&RÒŒ]•´´ZB_ãÄÝe¾ÓÊ¢ —Vܶ•°´ÛÊ:;«FÃ)¶ i˜åî?×T 4ôjd3kð¶ä•ta¡.c-=GlPÅ»÷˪;‡Ïâ[÷%%ޱ±H2¶xPçù P?FpVI}ï'¸px˜é°cºí¢:4¦ÐÞ©÷Ì›¡·X«ìíÎÝŽVO¡’ÄãÓyPEtžlÐN ¿syTcèž}ÇŽûÇx±ÆKv¯Ùe6|{õóQŸåðʈšncئª;êåñôÑi,­î÷¬‡wó0©;€üħ³*Ü¡óÖïá !{§gôþëQë·Ö¿,eX%endstream endobj 5224 0 obj<>/XObject<<>>>>>>endobj 5225 0 obj<>stream xµVmo"7þί­*…$Å»@BzôªãÒT-´UUªÈ¬ ëËbom/Uýï{w9^–K¾”DQÇÏóÌ‹ýw£ þ´¡Ûs¿ñ¢ñn܈H„ÆÍ=‡ðcפ ãt"èÝ´I¯wcæ½"ÇM(?*·YnÇüÙše\²I‚j1ãZ,¸åh<“ÐŒ›?Å_d³2iNNq%˜Ld“ÓïNÇŸ´Úx+ù·´!’- áAYsHÔ lÂjN}0*솟å2¶BI蓦ëš30žKõÄ‹XY¦U¦µ–BÛœ¦€<Å@Ià4N@M?óØ’zh-÷÷®³É ˜‰4}Ì0SÒ¾¸%ábžØöì‘çÕ>ŠÝiðù`!¦©pÅ[æ¨÷.ô•¦Ù£Ë»Ãþò® ýk·¹Šˆ‹òµðJS? %7$¼åPÏpOœ‘¯¿ß°êŽRÞTør}µªƒ]uþïĺ·Áëÿ´yK¼ûNŠŽJSò­ÍëÁ¦}éÃ/Úï%%ÜîW¿vt(Õ"nxà üD—´˜‘Ô@nðmñ-äRàu‚Ö{(¼|ËÉjæMø¶1Ãí½8óSIóÖö6ÉW€~_ŸKßàN ŒOóùu´³é¥çĬĜÄ)5¦œ¼5;*S!Ãú{ËÇÇáS9£«+cï®Â6ذÃÑlx¡³<µŽ:^©»RœnÃóóB¶™V ¯bÉôº¼¨:ѹì^BïâÚMàÑïw·­.‰à½ŠóE5øDQx¶®Šµ}Cpp'8üÕMãœ/£évðÍŒ!;W7ÎôaÜø¹ñe’[Âendstream endobj 5226 0 obj<>/XObject<>>>>>endobj 5227 0 obj<>stream x…T]OÛ@|ϯX©•‚8þHB‚Ô(P¡"ˆQ_Оà+¶ÏœÏ„üûΞ“Ò@«*Š¢ÝÙÙ™ñ>wòñ (ñ;):ÏLFÞÄýùGÞˆ‚Qä¡`z.è_:ÓtÓ9;¾ç£ÿ÷—y¤þÅ„‚â%¢ÑØ‹†Å©«ñ)NºÁÄc ©Í¤!ù*Š*—õ~ü³Ó¿P€nì…ÔÄi7Î$oŠú¢LV)¥ÊÈÄj³¦D—V¨²¦ecvi•©$£D”´dš’ÐL¨´"Ï%ÿ"Aµ*T. ¢,AÆjUF¾(ÝÔdWšy ï“v·d½Í¿¡cx­­DŸ°®yO¾ZY¦{ÛÍHÕ”ÊBc°V¶üA[ Ûéѵ6˜­éëÁzYY¥KÊÀ:Wå£cÏ­óøŠ!Kmw¨‰M¹¤Åó–¢É-ïÈ-/ÒÔŒ¥—ôð:SUVÊftÒ*zH‹†ùy³$dE-·,kŠà}êĨE«"O(±ôö`¤ÊåÁ¹Ù;nE "·,6âÞ÷îÇ,ù<ÓMžº5X˜¹…¤KÄzÒ•Z Üws¿ïÌ–Ï ’B4j¡p¬îIUå*Ž\ñ´;·KKK)S,®*1ðçmÏZrgÏ­‘k–…•x?®•×û8ê­sa6Y•KŽs^,´³¤µtš1™KΚ¤ë³ï”ê¤)$òïê[³wØ}FÕít÷Q‰¨é<å'®®d¢Ú¨Í®îæüéÍïf³émìe¶È=:•¹^qÊ ß6Ïßöû¿œ`^ˆ§]Ù vUÚXÂiUBùÆÇ· C Þùx+). ߆CèE_•î'º€gÇôÑW~jáyÚ=™Íø©9þBeSÛü¡ÙâŽ7ÉÆo i8ÀŹèý¸üÖ‹<§î¹«úmqï¨ñÏ“6ôG^âžG8ö¹ù<îÜt~Š¢ª^endstream endobj 5228 0 obj<>/XObject<<>>>>/Annots 2065 0 R>>endobj 5229 0 obj<>stream xÅZÛnÜÈ}×W4l–±Öh8œ+òäHö®Ëq,%ûb àpz$®‡ä,É‘4ùúœSMv团ìÂÐÑa±O]ººšöï‘â¿ÈÄSþŸæÃÁ¿áÿøøóA< Ít2Ä&7óÉ`Ü‚¹8˜ÈÇÂ-fƒi È)˜›h8DŠÔì4î±nÉxä–ñµøÚy€¹YŒ Å)È%E7ÔìhÖ3Õ˜‚†ôÓÛ:A£¡B(à´ R‚†ƒ™âœÝp.vã9´S07³×óœÄu²hcN?¡Ñ¤GjL'ǃ¹2Õì$‚ ðbÁ·P`¤¹Ku4\ Ff"ˆš4†)ÜŽ4«0XÄ6Ö¬Â`s.Þ¬pnF£þºƒŒzª4ÎM—]–¶¤\‰|Âyÿ°>7•öE§YeÓ¦tÝ&tÿë?¦îÁ! ëe,ÞܤæqAù¯—5irc“æ-÷kåmës´¶ .×íéò >^ïK׺´Þk$ç6/«=z,û1“`n¯ma*Ûì*¶=ü¤ÆÜæK[™›¤Ê’%\xâl}©n]V¦\þ† ®Í6©kœ!íy}òÓOf“ìmõÄšN“Æê3©m»Rc]ß•9 Ë4ƒNº¦©²å®yò˜½6+*ì…\ÔM…Í…lª³Ô”k6¨mUnmÕdO®KâöuUŒÝ‹me_HÐ^l˺yâèg˜ü•n_aÛËOÿË~ÙÖÿm•l·È_ºaµÕ“Z‰ÊCÄ’M÷Ë'®¸7w-VL’u·ïV5·Ysm’Õ*ã‘5ÈfZ®0­~­¥…PþàlûG±²ÕfO91$)¶Øåìm+]ô'$¹ðÖ‚«Ä>\.x_¼ÂEÃöýÅñÛîæ1äL?˜ËÅñv»«PP–åÎ:CÜPo2õKþ¨;“ìpdËV½Mö|:IqÁÔÞeµlŸ“cvÙ¬+ðƒ÷o.ÑtŠ«ºg=0\ÏŒëBÝ-G,úçÚª jxŸ¢°›¤AçpM†àO‡ÜOŸ^²èlµNRËfçt™;úÆnP¸;e”hPç”´öR’ð¦ë¤6K‹^Ÿ^#<…)o‡ó,­Êº\7/jÓÍèt9˜Á*k»mY5<(iY¢½­ù5+Våm-®eq䙞”më0âÖ*•×bku¹zsrþúøìâo So~˜3Ñlj,nDÇÔ»Œ}–=¢*—À¸[Ú;§±ÅMV•¸Ú¬vÝÓÂh×›ä#†a%×ßáÝ9<ÏîðÀé»wæ]™Èý€µ1ÍôŸïšÓá ½l=7·eõ¹6ö÷ÖØ›[»Ù˜²0½`6fiÛ=©õ¾nl^Ãß»¿6ï²bw÷Ê\”Ê.æ:éOÚžM}5A}Y¸(ø\à…Jê¾aö¡M<‹¿ÿˆ7´ŠÝåú²4W¶‘8æhí¦Üµ†Üô:Ù2{Ø€;6–ºÁ~`oÁ”¢+·¬Š ‘Bã_¹Âî¯üéŠ×œZì †Ï¼· Cm>ž_œ¾ÿô²oêî†Ä\•媕î®ç~ú1W» »ç{bjL踦ÉÖdz3îNèG#iÂì¯è°ßú2s¿ÓÊ÷“3ô éc3ȳ"˳[t¨3Q‰›{Í;7ê-_£$ –7¸L8Æ! Y±EiàþC“{aY1ôŒ]0óg]×Û||¥-¯+,ÃÜcoð»UlZì5n9\¡€¯Ã«¥×cÿ‰44¤·» l…ÙØzóäßjjiÇoñqp¡Z›C¹t3+!.‡í‚öÌy¡—ƾ|–3ª{YÙÝ`™¤Ÿo“ k°¥cç»Ïaîœo¯óõ+Nr•'øÁ6)N› ݯ¶G_¤ÚÔ5× ¾¡Ôõi€7=˜¶Ðôq `Ÿ9õ}Ì…´™?ß÷ Ýõ;>îŠ&Ëí ­Ç [Ýd8E¿x›âÚI"d³çvÅiÙM8=½8<Ñvàtwxw‚ÜTÔ>ѶØýq+&ß ks]î®®u° îyÇPŽþurñËëú±À~q="OpfâDú"ß¶=dOÃW®¬°+__]i<¢Ä¾A-^ÑŠ0jH°z¡Ò 556.ŽnADåÔiÂ&Ý·¡­Ù{‰Oue኎M¹ÉÖ2&…ŒP ¨ÛÔ2á¼³Éèèê1l$ΣÓïÅ ;wÕ>b²K¸ÅyzÈÕÞÙt'cÚ½Ö·™|9T;´í}Ýe,>Æ_"Í¥—}ù¡{2ÄßfŒÜÞÑ<âëß\üýà?á­ËŒendstream endobj 5230 0 obj<>/XObject<<>>>>/Annots 2069 0 R>>endobj 5231 0 obj<>stream xµXûÛÆþýþŠŠÀ râéu’lŸÏp`$W[­kÀ€±G®¤=“» ¹uTj'R]8o[&Áœ4Yõ>d¶pKŒuò>E䛓V ‘Ò¶¶ij÷ÊÄŠ>Aú)Àï·È6ös°*3‚^Ý¢‰¸`øØÊ|ç߆2PÞ3iXm”°;Ž€6…#×™c!(È#Ö«Ûñ²Ò4\ ë 3|œÌ•„ hUmPŽÅ»ÛÄ»o22±H2B'ÔüiÄNÆŸåæ¨áú#õÿ3 ® X¢Ä_é×ŸŽ‚òÖNÛ^§©Ø(£r‰>–xˆ-ÚI› L‘ÅNÅz­ªüpœƒ^u:,¨»(w;›£Î ZrjÙTùÒ ª[JNŠìÄ0åPdì9åaÓQn±-s‹LP{›ŽÄ-[}‘N\úME×¶ kå•è>µ›Míu²QÜh j.'í 5€ÖbŠZÓ3h;!]£h:ÅS2¨ÏªÿQâ"ŠjÔá7ÿéæqH’'ÓhŽFä_,ÇñC^µ–eê.¹ÿCZBú8•EêßÊGŠrc¸ N&¸ð#ƒ 4J“«EbëtÁx f¼>â{(©þLETá@`†9…œjj‘~–0˜ªº “`ko>ý:JŒØ¤§Sf`|ƒTÏŽÔ«C3Y`.×SU²°8¨"Îõ=àÿ0Fb5è%…»*¿HüÝp,˜÷[o1!~+5¦H'ˆ”á*à Oºî ²ý€£“¾ j˜ö>ù—4¢rÑ×B«Þ`{$$ —Îbø¯Ñ5˜™^L™ý`>Í~ª„˜7Í6&iª3êùo¤3~RÛ„˜Ü¼yÃ6öà&M_³žãHç±ïˆX€â…çî5AÔ¾r[›Dâu5׫ ×FJ”ÓF?ÒFó{Œ ÃÙˆ >^?ªU£ÙÓ†µit–Ú Ç›\¡8ÖeÊàb°½{ihk°~˜+¿Ìdè äNcìcaGpU‹—â ÑNã>ÌêDåIb°O5h'±š àOo•`ÃøÊŸñÞùâêÅ?ˆG™kZ_ÐeÀü}.w;tUµµ‰]nw*wšÈ€Š:µÏs%(ܤÊ=¹ð¿÷Zôu¬`¨x•Ú{ISû ‡“,j³„Ê1Œ2â—D‹‡U¾Æüý£Æ¬¶ÀÈJ,'UÍRMÝé; „)äZ eʬCŽN¢pR¸2?ü õa‚°|Ÿª$(·à—}zäȆK6Lkìbêzn&ÔwqÁþ8}üÞU¬Ìzcp›@þ ä¸H¥¯ï&WƑުC`нŠ%a'Á.,¢BnšI;…8e4”H•ÑNKlÛP·Îm†ûChj—:—Œ(7’‡ý\e|©Á‹F@^Îö;ZîÌ“î®4 åic¿bü ¢DÉ£LKZçs%ÑÁb—à çZ¡ £\á ;6W‰=Ó%ìî†bÏw”PÛ0_`¯QTN7;¸_{â/rZ"@#i%ë­,ßÙç¦Ãœ›ŽW¡ÕLeïÑÛtcä©—Û}A£Æû-#W(z¾ÊÔMñÄméØn…LîDðA,5ŠL”PÑÔ—Xù›JØ„€›F´ÔFâ ö–=ªƒŒ«•EÕBbQ˜ÝH»¤¡5ï¾£›N­ÈëyŒüpp—ݬ°\ð´5TF¼ÉÚèz]]ò\zÀ.¬üüïÙmä—µö¾gµ¹W¸öæÑÏñsyôè„ò7gía0Sï#̱ùKcTì7(*ôÔ«ô zåå·cÏët߯=™„ûÁhqîgø“ˆÉjŽ­é4¸èÍ0èì”Óè ©`rWBõþ0‡6'çméΟñ„ÁƒˆÍ±‚†x–ïXa‡¯Oa=÷Š®¡•GÕPôã:Æ^|JT¬KN,¹§¯E=?,ˆ'ÜÔ˜ÑtCÅbPÿ0G—xÊK7ÞžÏ â ‡_j[j*nï0o¢õzïk y¿·É¡G‹ðNx¢f­ fÕ¿NŒcŽ@<áÂ5Ååe|R4̈g¹BN‚¥®@$îö×› }¢/êÞ;‡!ã%€ZU É8·½ç¦é{Þ§ŸŸýãÙó_o>|º{ûë??Ó(rL~ñ®!vë2¯>ܽ|ÿöÙÝÝË·qÄÜ"öz7ís.|¾/ðqvzÍŸ‘'¼ç’æá„oÚŸFI2®ï³è‡‡ ;ßø÷z4¦ÿ‘l²œ¨—«‹¿]üŠ.Ê endstream endobj 5232 0 obj<>/XObject<<>>>>/Annots 2077 0 R>>endobj 5233 0 obj<>stream x¥X[s·~ׯ8aíöHkÞI¹“Τu•q:n¥N_ôî‚ä*{ +‰éô¿÷;‹¥H+ndDðà\p®ðËÅ„Æø7¡Ù’ÿÇùÅ8ãþ5á_ÿüébz}Íhº^DcÊi6ŸûUF·áÔÕ$Z»½†¬sšWÑ2¤NÑŠ¦ók+y6nexƒ5$¯^³×Pƒ5$OÇ,ÙSçóq4ñ’ç ÖPƒuN‹ñÚ[Á’Ã5¨“ë¾UK5[“WÝ‚9ƒeN“É4š»LœO»5 žOØFŽ¡kP¯áü€:3z¦6ËÍ,˜3XBéxÆÖz"äÌhfý;™.ÛóKðaãÂndÚŸï‚<0É vôáfùt·åLY^ãSbâÑI’ê´,DFúPÉ\TõÇwwnÆ´†ZpMÇtÌfX%£¸~*-èÔÏ_þ@q™HªTYI¥TKÝŠe¡Ć8!e£“ÝY!Bk•n-ëcA°$ nKÅKïÓbGºdŸg¢®eýAM^ÛCOÖÎUWSŽÖÜû~º\‘ÝÓz“7\-æ|ž—^ Ô²ÍÖ»½¤AÑdÙ ÛBð§æïá’Aë0ŠEAIu%ãt›ÊÄþ˜ÂÂEÖH⓵á²1½aá}KGÌ*Ÿ+Q$P…ÏÌö¤DUÉ„w^q`¦|mSÄœ5ìš”Ô*¨(‹«Ç2M"ú{©r‘ecn"·¢É´3¥Ü[2>¶"­©©%ÄÜ@¿|y•IHÂ×ø_H™àé–eCñ^;&Jâísqªò™Ø¨¯§ë[—Õ÷£˜?Ý¿£[-tSÓ€y­p“•Ý^Äá’Ø? Ë(Š"ú¯=ÕQ¦¬ÇmœË”kãà íJ’ü¥IBYh*D._)º·âQÄË‰Š¹ú½kCìŸÆóØT K$à1Ä—Œ¹Ôû2ÉË„SOùú²ŒGÄ“ù­¥óE‰].¾Õ•áºñ þÙnˆë½PÕý»Þ ŠÔÔþFÔ²ÏJæ4÷Ô“l†z䚎­O=-€›äÑO Ô“li^•JûX›£žæ,´T[‡2àôTfþps”Ú«W›àÚt¶[nT˜#<Ä•ým9þÆä+·d.ˆ¾w`ëäxKìñÍ÷ç™ïû³Œï¿Îøþ,£ãûõׯXj‰}K™/-ªSsÏžÐx«è¸}Øó WAý]qûW‘¥?›VKk¡ŸA—¦Ïâ:-üw””H£¢ÔT7'¤Ù3¬vqU ƒ™&x†HÂ$F©4HÏ·˜`ls7x*ìa:ãN¨@ëË,“fa\ËGtJÌ%ª„Bv ›#2“´oš³¨&ÑÁš²rø&ì3;úüd¢S¤€9„ü<-„.ÕÐëIRsJ`ŸÎߦï„\§µï o(Õû²É¸¢ÐHãO¹& Ÿö²€—tÌ>ºŽÌˆP Ÿö2B£vÜ›”óˆ8Žx,ï V Éœo`ærP‡ˆÈÐ0µÀ2‡UYë jëºÐ™Az-’xh0ÕÜ 8 ²é¶£B¿²HGëÔ2:®¢ïAÀÏÂ˸D¢Æ{B>² )ÉÛâ:ÌÔ°Fû]‹îF„#mÛ¦Ï6k:H=¢MVÆ?³§j-üÄ Is9??]:ÏàoW6ÑlÒõ÷á‡7€¸Ò5WäBa e™Á±Dˆ´#ú’Ižhµ´ÕÌbOäÁ'D“BA‰õ·wIÀѧ™&§Ô QåÖìl³Â™—¢a¼¢„é¶QH.EM‘rhèåcWâ[˵! Ö -‘Lç©ÿ÷ì=kÛ ÿ½¶²¥­,/°|‡¸^2ò>'ã5“o]¯e?‰ú£ª4¶= ˆ¥+9ƒu‡H¸4gÔëºZ\Û…ƒÄÈX' ß%­…¾2€„í7]]øãôœ÷´OQd(Ÿ«`åQÇÚÐ >sAvÊ;§˜Òiï8fàØbçÁåǵ?¯wΦÔð–Á\_ÎhöÏkÖFôcÑf(ˆ'wW³aòÃJõzowtŒÍpÁ³M ¾~È¿•Šo&OâP_¶rO¾tW&›i—|’»¬ÜˆìãÇÛC­e}.ô­ø&ÅVÑ{ÔÈÞb׿~9Z;“pc3›ïßý±oø•y˜EKÜÈQwpXsŽ¢Þã‚g•ú è‚iÎè·Õ¢d[,·Ü1øe’ uà)a3ÒWîfU³A?âî¯ñG>CDA'àÇíýÈžŸ„ÚMüp·yè±.g›ÃìEs0™î«¤Á_ïüÒ`AÙùFÀp¨}méÇcÄ>n³ÄTª˜ólmùù®{µÆ¶t6Oduùª]Óõ"Ý»N—ôçmm¹¿Íf€ n|Pˆç%Ì9 ¤V%2“;LÛú.µÏ9ê ‰$›H`º ã]çÖò‚…Ǹ¡y`æç®ßu$´¿Ýð’ ¿T0°è¿‘qjÞy悔j @ƒÑ¶Ü¿XI×ê6R?I‡ÏôSùÝw—÷eûvÈí`˜¿TelêÐ&°£~Õ5Äv¶XlÅñ$›jŠ¥}Í›¬Ñr¶ åÌÞTÿýù§«^j?•qã#bÎ5ã1;¯Vö¥ïÓSúä:"ߟþ®rîbÃ|‹1Þh§x‘GCš®güÕ_ï.þqñ?Îñendstream endobj 5234 0 obj<>/XObject<<>>>>/Annots 2079 0 R>>endobj 5235 0 obj<>stream x­W[s7}ϯøÆL&›â,¾äBÓá`ÒJqÚ>`†‘we¯˜Ý•+ic< ÿ½G—½9!Íqâ]é»ïèß½1ðLÓSû“{£x„'öcl?Þ¿ÞŸÇ'4=>‹GTÐd4бÖ}Ëi¶×ýŽ·Ç¬jß¾¸îtVÕŠž¼:¦ñˆ®—ÖåéÏø+uñG]<¢bë5W:¦ëŒkN +iÁ©Ò<%#I¯y"–[bå–°š£Ä¢2œ˜Ö2Ì`ÙF˜Œ]<¹xü˜Ìv͇„%ħBâDÂò|ë­.¥:¼þ¼7¢£ñÑD&ãÖ´}öä*á‚Þ0¥3–?×þyDÔ†Ó+©ˆaÅ:ççõö§ñÔ&;ùÉ$žNñ-ömT[Ï#Q¸ël9"ªÿ‰²ÉO?|XårÁòóóÙV^Äï«Òˆ‚ÇW¥áJ®g\݈„븉týU¬d+ž^Ã_üû»™QóÃáÝîdezþ7•*Ïé‡ùR"Km(ɘ¢Ÿh€xD¹„pP#dß[ñš›7z5°óë·^Ô7R¤4 ¯»{ ¬¯W·`;r ˜Æ§§gÖ °EÂÖ­à©`jKI9yNèI»P°ªð}Ï'0ð'€²Å–ø W[“ÙW¢t«|?ìÐàûaàļ»zû÷¿½¤¯½4‰â8ÞyòP \æùU±–ÊÌ£Ap2ÒËÒ¨í;‰ìŸ .fhÄú“¯òÐØõô£!°c]-r‘îð‹ACJò  ¶õ¿„]D?<£;ò¿3¾òËÿÊõg¦Vãùa²%Ÿ4rÈÿ.–ßJПɘq´µêÐVƒÿüÚ"¡‰å¶Õ´â%W–B‡$”â–kÀ9KÇ·,M…²dyKzQÃtrNØ»åG¿»$í¨ÖÑôš)Vpôß‘zèþÞd"Él¤ºZw*–K®x‰œ¥K»qdó šÄv;_B¡á=…‚3^°PLîÇ£¤ÒF\¸ åäBË)M ¯3ÅY:cKþ¼–a;Hó¸ÈÙ‚çn€·ƒ4¶˜­Sx@žËmÖ쟫×8š)'É&|X(ú¡•hm·|=8a–¦µ;…Ḧ~¦¿Alà.Fó|yÿ\nåY·¨PÏ/œL¨õ >´5øXËÏÙ=€…ççÞÀÁµÃ¿¯_ÏNâÓ)®Ö'î>/XObject<<>>>>/Annots 2085 0 R>>endobj 5237 0 obj<>stream x½XÛrÜ6}×Wt9v‰®’FsÑÍNå!QlÇÙ’“ØZûa'œAL€ÔH•Ê¿ïéÉRcgõ²%•DDßûôÿ<˜Ð?šóoZŒGc<á?þóþÍÁl|:šÐäâÅhL%ÍN§£Óæ® »÷XÅ[/vV'gg£MƲwryΫrÇ{§ãñÎêt6ï¬þp³cŒXä—tòÊÇt“³¹ç/p•‰µ¸H“ê~­KµÑÛœª•¦CWW‡¤ªÊ›E]iÒw&TŒÅª Ô¼~Äïò#-O¨:#,çÞ•ûÄŒžßüqp<¦ãé)´'ß[ÈUåºÐ”;ÏÚTº2v¹Õ MNi[—¤lFrq«ŠZÚ@aå6–ºp~òzL—ˆ ¼œ²žéh6Ã]–þò¯Wñi + ©õZÛ  rH’Æ-]†þ"d,Keäò¡¼Ÿß½È:Hh࡯d2å:ŠÂYö~ƒH˜\6v_0ËÖù¥Ø×É‹ 2q4úJ¹©K]­\¥&7Ú‡þî„r­ªÚkJ•%UX∌Ý*oÔ¢n!žÚÇÿ(2w±'Ë ÃK‹y™Îz£oGç{,Û¡ ­qˆ½ªèç·oh©­öª‚Þ ƒu_ÜÿàPÖºŠÂZ§ìw& ß9+M,Þz½.TŠI°Ò}É·ÆWµ*6ŸôßN¬ÞüÃîV{o²FͶüZç15:ï1®ìgH…wkä Ò#ºá)Ö& —˜\y]H͇šw‹Æ\-‰îœ@‘c‰li–« ñ­¤Ònüÿœ56uÞë´êõ àµZQ‰2<`…ݦR6Õ{»œ õ¥®8—¹Æ]!ŒF–÷à…Ô>Ê>]ñlÈ"0 M-sí .MˆEû7Ês›6cºm÷ˆ*¦âôij6g†]7·èµŽ­ RaÊÌ•ÅBH ú“¹‡†&8_;ÏÕódGòwO84âÆ0¾ëk A0­·$l ‡:0?ÄáhȾ}؉Yc«D FúØñ©®ÿj×Û-×ø}Ï“½%wùU ~!‰F·! jðQt¸ö «‚¶Kå +uàB~bñ¼M.•Gä0Œ@fc$KåÃJ`:KDܾOÉOà™…~¯ó…? Ÿv~Wê3€5U0´ µ ^“Ãrt[‹æŸ»fª²?+]dTÃÈBL¨m©,ÜÈ “!÷,`v¶7p&†4ÇôºÄ)á8öòÓ N‚ÂF°åbí‚0E1Ùr¶¸ð¶£ ¦¡[yž¡§#¹GQÅ£ZxíÕ²T¸h€4®ÒØœ2-v%Éœ¨m @'[I=uq2„Ûo§ -î÷åèø Î%:„2&ë„®“É·òŽÈA‹ß˜€²b$"ýgm Ó¤*¦ý¬å:ô4÷°{åЮM[#ÆÏÓÀèËëb Yy>}·†SÝqè!S“ÖÑkœ£MÆ0ö­˜·H,¶…ÃÆŸk{Ì“v”ìPæáÏêVÍŸ¡XÁ]bíx±ƒºÐבä¶KÛà\Œ£hÒ"hÞbDw~n¬7ºèÝÀ‹¸Ã Æøu”ôUŽ}¨êÌ8½{uƒäxFÁµ@ Ÿ>ÑÄ ”áq^¾Ke ¦x7îa#0#£SpmRï‚Ë«(‰Š/±I–>›¹ sÁœîq¶Œ$ƒI3r¨Ä† W©pG¼¯èßÖÜõÒ§-h‡³%¿ÆöŠ˜]5 ``IÑG¼Ì'èPÄ\•-çó6|Ý87 )R¬14ÛnS#ÃýÓ4…¯mÏZÜ—z¤ïHž'¿¶ØÉÃŽ¯¨ðhI—úÒa:|EØ5¯÷…ÀMlÝ–@“F:Ï Þ·VHnKöÚM´qþ3#~"]!ˇ .ø«û%޵ýÅ®Ê[—ö4ʵ±o>}iÛn¶åJ]9LEfSgs³¬Aûy6c®±™8—RÀ‚R]õ~oïQ…2ǸV«¾ìF-P?-G$qE:º²FvšaÑÖXd€Ü¨  û Ç–Âó;ý»Þ±›º—1ëx­ª•˜|òŸÂNñ- #Áá’/³dÊŸÄ>:ƒ6uÍ ­=ýMñ5îlvFçg²7K˜ÄÏð}íG—ÖÜ3.Ž6¨Z|÷ø"~ÒÙ/ûl|>šMak¿<ã¯n~;ø/&ø„endstream endobj 5238 0 obj<>/XObject<<>>>>/Annots 2089 0 R>>endobj 5239 0 obj<>stream x­Xmo7þî_1表âØk½Ø²Ò´\9)4®/Q/8Ô…AíRë¹%w¥ ‡þ÷>CrW»r’×[»$gÎ<|f¨?NÔÇ߯ü/Ýœô“>ÞðÿxÿãÉõ8¹¤ËÉ цƒ~rŸrúpÒ~ÆèèUrݽæçÁð2y…µÃþá‰×¶Ÿ1zuÝÌõ£­gŒ^`#Xò£­ç úƒdÜýaÞڇߌ]ÑÅÛKôi¾Ä†Ç¯ð!óûć´÷Þ2¹U^Ò‡³©´R”Ž^Ì?¹x‹Pøe½­Q†—µ­ GBïÉ”ki©0J—ø-tFk©SIaÝZä¹#Uú¹Tî I;+ŠÓ\8G)&ÈìØC™ÿûþÍcñÈ®'üܧóÁ[éÍ–´7í„.©4WÚ©rM€FÉÝ›ù3{WÊM2Óå}i̘Jc†ÈÎØ„•¤°WrjSä’œ,É,I‹ óž6¢øÜNjø ÜÓý<»}œÝÍïçïŸy^‹!Ñ´T9™%4_Ë}ýqË\æêI¶"ßÅñm°Ù§ h‹”áy8LF#ÛHè?ñ%ýUG—‰3OˇøiûðâuðR^â|ÀŹ÷1Iúãk^2ìãõôtc­Ø»îÌe2™ð$ g=™”^Õ¼‹ÀÌÈG¦hÆìsUº®È9«wé9Ôá¤dß’VRK+J ÈÕ3þ Úw÷Ø£@็N©ÂÄæXa)ýúÛñjc½ñ¼ãÓÇq)WjËx HÎΦ¬t¥U)vÀ\bÆb U:“6ß3°Jo„+Œ§&cF͘±1®¤ÂŠ´T8œ>›ˆÑ…[¼z-ø˜nZ¹ÒlføCg4{ë`a»K“çf"b%¬…5"]K÷ÚŸ%ð’§yšÖ¾rµ°ÂîÏèþb¦·įåʃiŽ;›’Biý ^'.Þ²zñ;Žk‚&>ZŸvÖMH ,ˆî‹LÆ(Ddô$%N?dÌ£¨äÆØ=)C^Ç9{iƒëå,,[¡r±€² ¬l(zU!1HEVåœ_¤Fù£ÔèHfÒj#!¹ n|À»E âßKc0tÃDz;¯.=È2ntB÷¹È¥•KÈ4 •L´8Š,Z¤ bwF‹ªô/R£·R+–}/˜|`+Ç;àéœÕrg:„ ÖRG¦*sÅ9ì ³nmv¬€ K­ôCþ·ÑVÈOsоö|\VÚã?RœEW˜ü£R[‘#pàÎTyo_ÖÍVAÊLÅ©ô}m9Ñr÷^ß°h=ô}È$ÑÅM¹žòÙ ´©cൕcóÐãí¾ï¿&õÝ€¾|ùð¢3?-(B %ì¡'ÎÔÙðTy‡tøßP§Ä5¯µó~c@’ÂÂ÷£Ì8˜ Ÿ`ðžu„˜vðÕæ2™ËRvñy«0wËeö‡È•PRFÉ8”æͤOgßwaèРü?2ߊ9¥È9rM­wM®ÛÙã¿ú^ÛùÈþoùN“&»êŒ>‘ܘÄðÆ9µÒ!É@|>Ëi’ W>ô^tÒ}œÛƒh†D\Õ‰àÚž é]¬AZp’X~ÿ»BwóÓÖYP°gê’Í;TŠ ä…«‹–2óLÌ$oŸOj.+ˆå+(%e‰å™"D-Æ|Ídߢ§ó],šV]T%ÜUeømiN7¡\ÜYÒëPÇè1ŠßOïYÆM \\›dÃÀ˜®+ýÄ…xêÚ’…Zqw{$\Öu鶨ÐÃpÁ¨Pn…/Ï(šçzª‡¸$K,ö Dn³B«ÌüÆÑdÕ›…Eú‰-D°;Xb x%t¾déŒæ;‘d`©)¸A…¬Äª±¨–\D|Cä pyóþ2™ÐÔX4)…Ñ|æ(òês;€ŽÀ6)j!D] ¦`_Ú-0E$ÜÙE” ‘>ÕPù¶Z¡±d4ˆ­,+«]B7u_Ùt´[ì;X8õ +rµ=¦[Õæˆ+˜éŒö‰ÃŒo1'¢‡e˜DºaÁMÁ´%÷Rx xÆùînÌâwÔvÊ*þŠVÂ.¸4§èÇbÉïì&²Äl¥]ã„Û_EhÚ3Ï7œm Dœ8„j‰vÜÀÝR è ©E^"± ŽSh<}ƒÆk}$4¾ƒC¬gÊ2|ßø›%hŠƒŸZµðdóÆ´ü³¬›”n€¹m@;†;œöÀ¸ÉŠøU®ò¡9ÃÊQáyuïÈï–qq=ºi®8‡o •°8¢hàë݇ۻ.*NûõvUQË-^ >£k]Ë=WÝcŠk¶-Få¯n1·JøÍÎîÑÏ¿ÌñÛ÷”³;>/XObject<<>>>>/Annots 2092 0 R>>endobj 5241 0 obj<>stream xÕXïsÓFýž¿b'¦8Š-çWéô ãBJLi3ÌY:Û"§;qw²ñ0ýßûö$;Všà ˜8’îN»owß¾õ§­.uð¯K½CþŸä[¨ƒ;ü«Ë¿^?ÛêÆÝ舺ÝãèrêîÇQ\_)ºÜZ¿ÆÓã^„a-?ý}°v`8ÕNhï¬CÇQcŠ;txÜh†×vh´ˆ¢P Ê´§þùÅ›Á»÷D_øê¡3¥MäkÅâŸÁÇ­ív±%]ßòêÍ ÚSmñÂN¤¿Þ²w¶O¼gL»xýnÜ«_ßzâH•®T¾MsIØE~*il”2óLO(—~jRØîç&-•¤D ç³1MÇvã8êõàfÚ*Ê‘Êr^x|ÌL–R¾˜b1lÁ5¸¸æ[›}Ç­5ÛÃ-Ò™—¹îЗ†÷„ùYä…’ýó?_=?/hÝ8tyà¯ó¶wÕ3<ʘ+I-…Ÿ<\iÇ"‘$*ØcfatÊÐÁis™fÂ.*È(1© @;)q¶]¾í?£©p€^K+¼Lâêaé¤[3ªÂ{›J/ [ckò`Åå¢èu©}–˨Ïï5Å¥´³,ÁJ-r3¡7ä¥RaÛÉ‹×|—P*Ç9@¹°n*”bóÇÆ†e‚3ï+Ñ~7Qf$ÔãÇ÷›=UªŸÆúak»Þv›Nµ·‹ ¼~Û>¹œ [|X åöpçý„÷ÍÔ’Ÿá­¾%Ã6µ©¯Û´¡ù/+xž¸aëÎ…™…Œ^\„Ô†¥UDvÛÔ0›öë?›ZýªDÅþ³ãöwXx‹î wBYÝYHÌ8zY¸dÆT€J8Ýp7Ó¦ôò éE2 X/KøÌhšgHà‘A Z)R e tJs ¦ § wÚ¨&í²Tr.gŽN–Î…rZJÑÍEÁ|8ÉfR“.óvÁB©d.µw°/ØS=ߤ,Öiï§Ú£‡a+Ò¹R_ÄMª»Âs3’Èœ·eRóªynEQ¹:Z°¯wôƒL'ªL%mWž|HPù¶ˆ²í"tŠf“韣̀¡«S9qgGºeq|?Å8>U/ZA½ÞoêVt¯SDMr¸5pa-Ë«!ظÛTq]>qÔí=†è~8‹‘7»FÕƒ¿âø¦Äñ­Ìþý‡‚oâ| W¸ljÕ7ðc¾ï#l¢ÿ“ßÇÉï¿PºT”KEw¢}Ý—Us¬ ÍAc0řָ¬y©HYîGûÌ5}O ¡œ¡Â +Œ 5AiضbåP_LÄ¹Ì dUÝ&ÆÙgÊÀÐÊ$Лè«ÜÌÈ‹pFšY ®,XjpG0ØÔFçI™×uhE;kd¡d¯W³4f‚- ÒNöN=Z5¥ˆ}á‘5"™âý3£f,¾ :P±€Ûm‚pà !²®ð œeìwþ{"ìz«•‚‘_ cô­†-Љ¼¶–u«4£ì·m<ô)X4+G2Ž¥&4=02üg"Ó­’ÂÉ4¢¿MInjJ•’¬‰å¡-õwgÀš`»£ùTÖoA»õÖ(˜¸Àé»è›¡õ^ÛÌ͘f™@H(Í‘H®8{pXÀ|Ccç#gZB`KHƒÉt’7 ; Š'l¼!!ª×Å!ÁÎð¤„;€%©Ò¦J‹ËJ­5gAŒn- y 2 ¸ZµðZŒC{ò)¡'%‡ÒÊ1`щlZþMJúŸ9]1O`XSDJiãÈÁá`„@µ#ƒø‰•ü:BP]HbØ‹L)„…òþ޳S²á¬ªA§Èj¤^uÿjÕ²8[¤²‘åùeœ¡Å„ë1™!ˆU*Zù©DU ²`aBËv6_×:ëÿuúôæáÚ9‡èŠèEÀƒGÞë`÷ª´‚Àã+“yIaå,3Ç!÷èû§Ñu°š?£u­Æƒ"ë³F#¿SÕ¾•(½9i À*©Ä„\Ä-†Jíă ‚„©’WÖa¯¨f9l×±Š;ûÑAïßÔDÉCã.íðÔ$%kÓÉŒæûjíîQõ%Aàãøv>¾Øëƒ¦®®Ç¿ŠÖ†@>ò sõb|e.ŒøÖé`ë­¿e|endstream endobj 5242 0 obj<>/XObject<<>>>>/Annots 2095 0 R>>endobj 5243 0 obj<>stream x•XkoÛFýî_qáEy+Ó²ägýàUìÖX´õÖÞíuaŒÉ¡4 9ÃÌ % Åþ÷=w†¤HÅyl8É{ç>Î9÷R÷Ži‚¿Ç4;ãi¹7I&¸Â?Žùǯ?ìM§—ÉMÏfÉ9•4=Ÿ$Çͧ‚î÷úŸKšMÏ»gùîìt«ÖvvyœL{¶ýÏ%L/ºgÙ¶ÿwO.“I϶ÿw/‡¶è%²± :º™ÐE2£‡œ¦:C0ggçô…t'ôŽÞ¤®”~i²Òd*WÒ:*7WÖŠÍÜTÚ¯êçB¥Tk'r¹ÿ·ƒ‡÷{G7't ãœáôp6kœŽ®ªªØ_JUeMe•ð’ü¦’¥¨yï±sª„8ç½>ûN§Él†°³Ñ¥Ó¢Î$í ¶sO©[ [%jŸÍp$·] 6Ÿ¥Â/ ²‚’S -| Br%‹:£AO(LžhfMƒ@™oÁ|Ë“ýFŠèc-´’ÕfÊtX/Uºä§­üX+ H=ËTÔÌ.‚Z 1‹¨2@Ø¡Sábláf)3%ì&²¥%RaÌ&]¡¼“Ú´<åÖ”!ÝWHÛb‡# c­§|©dê9 ¡Û‡L"~ÁÑ)fPóPÞ{ªùû°~­QªR2"%„ù^Ú¤Ë%ïŠâ¶¬Œõ£ýÚûcºÖÞnî¸8ßïÏïYnŸz@ß<ø£ 3(i£8È¡_шšäÞCmÇôù›Ó¨üÜìñ @—t|’@üš„1: sm4$§4ÿ ]¿¤²ò@–ãP·¸åq’\\0Pn=£¤2Ωgt1 Òš5úÚw{:?š÷¥&“ Ýÿvû‰ÂJ‘aŽY³R™Œ-Êy¦­ýäß/áÛ w²‹‡TNŠOnkZ-š2ŒÄ”å3qàÌΧ׃wáX'tU{S²"c*€\Á”ÏûkN99ˆ¢«E˜C»ç;À|Kq" {p*cÊI ^†k¶QרÆÔ»ÇÛee”ÐpþU_×Ê/éMW ¡aë••/”Ø1É8ê$TÆ&L¢¸ÎŒ†¾¶¨Q.ƒ %4¯Š®y@ChtPŠ£æ=ÿÏÿ‹Å ‘·qö1 ¥ ÜocŽ#=¡ÍÊj!£!lÊ-Cã e¬]pápjDK.JU@ÃbHaÕ0í€ï9A©6~À@šÃ$Š/$Q š¥¿Éñ¨M0âïUÁÍ u¥Z,=­ÍÎLìÀ…š§!w«¼ë¹ðu0A@+?Á?ö©ø& ËV†æƒ(òn¼['ž¿Oq/¹—þ.2庰ØÃv*Èï]ñRWë/û¸²‹šIòН„~CZƒHc7APÔ¡ok˜þ!Ïg‘~@¡š•·…öôJ <•ÉB.м¦°¨M°IA îh§üëVX*³áç×ÎnïØà¨†xÅ 2*¡Áxx¥};€_hfÜT\¤‚“‚JJ¡Ê°/âVâ@oâ­ÇµÅ»:fW[*l<³̶Â×V©Ã•E§‚1ö†nƒ849Íg ¦Ð±¼Ž;ËsLndŽuF¡Ñ,ºkYq׿²ò÷ÛAËC0]* ]ŽÂMj¤$Þ6¢V‚1a…Aˆª•°B…„øÙ£›­¸´™óÓñ^ûu˨¥wÎäCTéR\Üö¶r]Å‚¶·}͎‹~Gƒ(· êŠ~Á,/¯$îkSÜ#b´Ç>£g´ÕÁ è>¶±«R?8N/íNN’ÓÙ)]œ&Ó°Å3“gø¢ìIiÃzÊVøj(>|xß}ñrp‚/Ã~jÖø…RóuK¥´ÆLd»ÓÉY2›â;B¼#L/.øÒõÃÞ?÷þ¥Î„ýendstream endobj 5244 0 obj<>/XObject<<>>>>>>endobj 5245 0 obj<>stream x­WioÛFýî_1pmTnlZ‡­Ø=>ÄG mÜÆZ‚õr(nCî²Ü¥d¡ÈïÌòD3Šì& KœÎ{s½ýgg}ú;€Ñ˜ÿÉtçâ~§ôéËæG>…ã·'0èÃ}D¶ãsú%ôÏéÙ›¢Æ\8 ¡°JOÁÅ÷ï¿%¿þL¥ ±ü²vÔ·È0çrõP8¡Ãöѽî³6C©D3‘+ñ (í_œc‚3¡¤B‹)ÅÄ/®ßd¸Si–,AEMŽCÓzÍÑB¯Ž…íÂ$é-qnæmTK4Ý!ŸÔ„kFÊ"ÏQK´`¢-a*Kae‰„d®\ìñJ¼ë<7pº9k" à&z$ŠG_™È±ÇT?A•˜á '枊)Ë3\,"“w~÷ÇÍÏ.ïb‘gwè~C’£ëG‰™SFOz“ƒ'YÒág¸ÛìëM>-RÔ®ËgThÉï³@àjïgÁˆÛfH¹ƒÑˆ>…=ë„SfF…°ù}“ÞÊóÑ%µõ¥}X±Åö`û?’ât ‰2ø.µÓÉÁ•'ŠôY.銴~ú"®±µ"1]þ2‘‹ôƒ)V„,ß‘Oá(_×…©œ8ôgÐa!FJSbæ±’1ï®ï:±,BJ—Ðð@³ˆ‡†þ~c}p±“3@]¤ðo+Å+4¿É²DIª%£›Úhó±jžÓI‘Joë+5S!^,þÂÜlc£C|¼-Ümô^è)nwd&^ ëža~›ñ¾ÙóÍí6žßIò#ôóy›篘š|±•ù ó(1ómlïÖaÚX®eÿÓê¸hL|s­÷ïÖTͳÆ×Æò)g“õû/ÖD7ªµÑáÑ}¶ç1eîÐo|´áéCÝ`•YmƒŽ®)­—ÚDÚÕ63:¤åoüÎYïgÏÓRâ4«·«%[Îà­ÖŠfpˬK -çSÛ¸™B¼´•ºüf9‚ EkIyÇ=ð´co a­!qÅŠ®ÑXϱ§ë¹d¿1m‡¡p­} Âú?²ª“Á}iYBÐtýrõñI>zÓ^,’Tå 44êY ÅbÆcý‰»­"X66E‚ÑÉ‚7Da™y¯™¨ TêKæD$†>ÇoÏ%, ó£á˜7Ó°œƒõ“UWT }WÆ(?îÖ²x=Oìç$ðâëtßZ°bs\¢ŒLB“Œ•¾e1pùê•–‹M¸y«y¹“«œš¡e´“ž"©NKîó/-\¾Ps÷Ô‘±.èQ¯tFYi•béx^YÉ\,,Ô±ø†P‘O¦/ L_Ë[=:ÆYëu”w nöã)85Õ”iÖ´ SZâhš“n,HlÃÂÔŒIBÒû…µF¯$ÙNõ%“ÆQ7Mï/Õä ‚H­Ðˈç +c´Ci×u¨ã²e#ZTÐ~Dp.$»¹höSTdÕ¡*æR¤îW7ÈIÏówÈËçï§Á䀨¬K ö×5¥zÒÛÀÐ'»õg°ºa7B\¡¢ÆÝQÍèxž@ßõà)в’)/’å$†»‡°[~·»Tîõ G³ö4‘]«‚òÙ§:å>˜ãcõúÏËÛ«kßtk–¹)ÐÂïÐto¥J¡µ†ú«âÛ–EqV]ïg'ÁéèÆôÿëò‚ÃÜ‚>\éïK^¯ñ1’Ñ¥õÑë2&WÜm×õ†ñÞOûã`4¤¡ÆíìœO^ßïü¾óc¾`endstream endobj 5246 0 obj<>/XObject<<>>>>>>endobj 5247 0 obj<>stream x•VmoÛ6þî_qðbLFmU¶7MÚY’nź:K¼uŒDÛì(Ò©8ưÿ¾;RŠ,Í52'N êîx/Ï=wuFáÏ&SúM²ÎóNFxøô'_ÂË÷œ†˜/`Áôõ(œN_ÁøñúËÙÕuþµÁp„¯Óºq¬?bqp”é´üæÃ§ßg?_‡¤sÃU*Ôòú1ák+´ ˃¸ßÝoÀ®r½çغå6üÇAÜ?oÚëá½èz㎞ݮyÆÖq]ØðÇD§üm[܇-Rø»¡Gñ‰,aRžyÖûϽêsŠ9ê %)…½Êª?v­µVaQ­ŠyLΘ•Þ ¢4^—i…Æa³b*Ôa ë–Üè¨VH"Le‘+xj3@Ö$ó4Tý`v†š—0kž&áå‚ÝKŒZ¥ømk×ÛF­LË—óYŒý'y3‚é FGOžçƒ[Öx1²5b[»¤¹&[q gÕ¡ekŸGì¸Båmé”Ë“?­VTÂ9$7lK ¹aœ^ê´Ìß8:O&'0=uØ¡¾N®tâ¦4®Z‘ n@^røÊ·Ö8 OÂí=èr¹”ˆ€ÂÐJÔ"²rMÃÉ7g„ÆøuDG×óίg[œendstream endobj 5248 0 obj<>/XObject<<>>>>/Annots 2097 0 R>>endobj 5249 0 obj<>stream x•WÛnÛ8}÷W Ü« ŽjˉséȦilÐdïv ´DÛl%R)»Æ¢ÿ¾3¤h[²›f›"ˆDixxæÌ™Ñ·VºøÓƒþ€þÇY«vñýêѯ»­^tö!tÃdМ„§ÕU ÷­Íë ¢î <ÜXݼÆÕho®n\ãêqýÝ߇`,¢b /ß#°. 'ˆzpŠ$,þü;Ëò”ß^}úûæË0WZ1çZÉt9 d™y1Úß~i½|XE BÎ8ðï1ÏPt™çª0«„ƒ`pUHËŒ'‚KˆS¦uÇEYc9èEˆ¥¡±U„© è™ZÈŒKCwb% ’'°f¶ÚRòÂíÅuêÛ÷Ÿ¯>Ür™9½ôÈ›“Iý­.T éíÕkyšóbÇË¥ ¶Ô0冞X²4÷¸ fÆ4ç’¸br jb)[½‹‚布á£Zð9/:6¥ W€ÌŒY& þ­A” ž)©Åà“ÒŽµm0Ëœg,6VsNøl(KµQÏxüõš$†Õ]|`83+Ôžo-˜‚›² ì—OISxÇM!‡Q°­ÅŠ•è´tå˜lÛ3¬šˆÄŠˆÚtŒéD¥©Z " SI™VI‚…*Ó9Ó†3ÄÈ×É<ó¼PycAE˜( û}¼J‚¼§"v™Æò°•ÿV©“ zHfðÙ¹BhªÃÒ_y[¯ƒü‹’}ÕØö‡çɰWëŠ>°ç臃Á1üÈ  «Q›¸Ü•ÍFÅ[~‰7WòT&Œû•„ ‹ÉnÕª¬ât“K.YžRgQÖ‡•Œ»í=g¥{fP èENÎPU#çt¥x†…ðxÊöªZöH£} çÙ‡½zîï(xÞƒ×ÐÅçêkä÷3Vä÷Ü4‹ä¼˜–—fd}¨zÎß¼)ÍÍäŽÉ)_YŒ5K:t¥xÚ¿6ùöJO•ŠÐb²jž´;ÐvÊjö› qE Ïe™¦õ5¯fïqñ|R˜çNK :‘á±Ñ°T%ÌØœ“K%»êþçôí(|P•o5”§fbËKl3QØa47†ÔMìIò `­K:æB¤)º†AK^°Bb¬ªü\Ë˸ÖlŠ&2‘²Œò»ìô•ÊJBqõÎà³ '‡Ggð—̘ÄP‰«µª/bÆ±Ï ô_ö ez`Vh73•P„‹g.d¢¸«³ÞE‹Ü2 sÁ,U¾t×d„î\¾Š>s›Q.Aǘк$ñ`«hƒ‰*lœ”2¶ÃƘO…$Fm¶šéy<÷u4A…î(+4Dò¿¨…1°nYÞÎKì SØ[-ÔCRˆCœæ0È57¿ÙAE‹›2óÉv3L¦Ðbc•aö†îŠÆzåïâÅ‹í'…Êìid¨æƒ<)!|Æh8X`e9@[Eñ3Ĩ\ äL8È¡Š0<hL´8D+kÂF!¬P¼~ÑOŸžå.ìÔöúu|Š=q5|’ÏYZr4Û†œ)›þû»žÁ¢÷¾ùI1ØF6ÉÙ–öƒš<ä´@a›1WOÝ»ó{=âUrÅLx¸ÀaŠÜªé¯»<”ÔbËnOH$”7ùLÈ8-q¦~ðâÞÖÎg§‡GhkžÏv0Ë)¼}C]¬ZŒ›Ö¶ØUß 9œ†#lä~ß­V²ë¨?5èKb=ø–u;³N`DFâÆ<¢‘#×+ƒ¼ m‡dl1h$(2=,^:ÜúÛ'8ß‘1÷ˆ·§_H•ÔqùÏíÍÝÐmt}?|wq~} ®ñ?xNªï'’ðVL{;´vÒ EðÝÖ‰Ò`o¿AÝb„Ѿ ñª:ÏIõÖ;9 úG08ÁD7 ƒ~Ø…w*¶Ó†•'uæž>8vMüÿZÜ~¤ö#´H²ÇÓż¶þlý¡2ˆ3endstream endobj 5250 0 obj<>/XObject<<>>>>>>endobj 5251 0 obj<>stream x¥VmoÛ6þî_qKëAFmU–7M—išÅÒ4k¼u´D[liJ“¨¸FÑÿÞ;R’-Y,1œˆâ½?÷ÜýÛƒ‡¿c˜Lé®zof=Ïõð°þÊ–ðü§îf ð=˜žŽÝéôÌ"s˃Yèþèlß³/=Fc<Ì)½Q|É´xày¢ä&pX¶ƒWåUÔX^ý!Óa “ëèì,)ô}²¸Ï˜ZràÁà€ò»Ïï¿¿¼‹Y–Þq}ËU$Ôòê[ÈS-8;ï/ÒT ´çõ…!pw38Á`ëTÓÿŒë"SPy¼}ù£ƒyzþîèÂFÙÈŸ”¹rf1‡SlÉ#“ˆÃ’+ž1QÂsc~…E’Æ›©x°V\‘ï(ÁY&Ïèn_>žåø’ST2ë†Ó¯uØ•Ä,/ûTRÕ™Òq–¬Û¢LëLÌ Í!çæˆø‚RŸUò[¼Œ|ßL=ˆ´˜c ×X…µÑ!”†&‹îŠóol•J~ûþæï\¹-d•rû… DUK–€Ñ†‹[ƒ*15:à”¬HÃN-Ÿ8f‡?pUÛ™%/r^¡ä¤B‰ï¹'ØiXкj•E(rDöÎyžòP,J@›JnÁGÐ;v)éŸc®àòÙ³ƒ’À2ŽÊy4ŠDl.9諪y¨1rF_`®ã$‚•XÆt@ù`j«Ø…75Œ®*‹^k!%°B'+*>“rS÷€í4h€LmãgŠ:F!Â5ü(¼Çê^ªW¢½«Çí•÷CjÄ« Nšo>’åÊpdÌ@oR¾biî _/)“µ-…õ:„Ì /ˆcPo[Ö±@nÃÜR¦ñ »#Âô5ìo£nT—â×L(²Ó x+÷¢Í 4\2EK]P†•[BU¡çCu+¡Îžî—Ù >ùkh9ãY;½MåßIÝÎŒØ!è¿È–ñ^“ÈË늇ðt\Óønþº¾Þï¼’ÆŸªBÊfW6y¼/”Dl@¿éé¡BY qÿ†1Ù:½n„bجÎhà“ •Ó`{¥c²uÌ5CVF°ïÃ/çàu°‘Õ·—ÜÀ9RÅjޏB ©D¹sÔNE®dýÇçÖM‚$_»R¶àU{IjsE(óÿ8»–hª H¨¦íÁ6ÿ\&8×BǤ¢Êp9 aµA3FKKV6F®<{±¸«n?~šÙDÏw³·—××`‰ûV¿Ø•¥c¡ÓËz9Ø®3æøçÞ FÅ+Ó¼;ØlkÚñÁšob–«f!éĤ¡fðë}÷@…Ž H˜^¬.þc_ޱ>/XObject<<>>>>>>endobj 5253 0 obj<>stream x•XkoÛFüî_±pj€NdJ–lÇuá®b7ŒÄµU´@U'ò$±!y ’…¢ÿ½³÷ Dê‘Æ1ŒH$÷æfgövùõà”:øwJ½ þ ’ƒŸ¿ƒ/«?Ù„Úw?Òi—cÜ{qyIƒP_ïÐ ðºÿÜ?£~™*¡þº™Íâ(E¤ÒÛ×@Îø?$_E2‹åñàïƒöÝâQvÒ=óƒÐL£ÜÝDQ:Wñ\æ$¨ÌeF¡G© q݆ói0•¨t.S/bò?ÝV7ÐT¤a¥³Y¦D0%Ä/™…Dà@ã5x@€Ãû ½m[¨C÷ P1ÍÔ‚¢ˆi©ÊŒWs{7' Øpµ¨íÏ@aøYK’ž; äExu¥ÊâE_2‘Nzk{ŽRlP¥’Ô˜ƒæ`È$¥ÎMîóRš{üd‚Ek±*þ@Û×2eRäKf! u²÷üûý//ýç©Èfϲx”iˆTzÃã-Öc•ÉÀþX7Ù¤Lúm1YLUíd’úyB9£%qDŸ>ª…ë-+dËÔc)1‹W:kémŽTC…³˜•¨Pâ[QP^Îf*+4àd\¦k1§TJ¬ŸI+…tâÓ=ç2 øYP éæQŽg‘ª\%’úíþ»w&8„UCKñ¢FOk÷"¥‘¤‰Led!d†ôp^tÄcàF¾Ø[Òu¥08ÌJ˜(‘›é £LbOs$\‹0 ÂÚ5ŒÛqÌF"[R‹<ß&Jô ¼S# W$…Þæ¾èè‡>=¢v›ú:‘ÊT N ¬ÌL!#Ø¥)gÛê3®sU¾œ›¸„ØÐä@Â5sC¤pW,'¬›ž@ÄñH_ZdÌRY¤o/¼-.WCuõƒ ³¹—µ5ó«g]dh$/ËE¨«ÃްÅr&Qh®¢†ÚÛσý›‡‡·»a‡K» U€Þj Ý¹c‹fñ5}úíáÁÅAª5ËòÒJé°¨}ûÇãç§Ac- mo7 }’xPfŽœ¡÷-tÕÇÔTíÙ€!Ú=ì¶âó¯…í¶m~R¬.2 *àC”´tI¦¼Á€qŒJ#à.BF³‚¥»ˆŠiƒÛ_Ju!\ˆ,å—gç终£‚ýŒZëùOòÉð;¨zú]ÂŽê|™ê€us>x°ÜZ%¹Þ0¾©Bk¥µ2ær¹™R.oVþå3ƒ ©5¿¶OÄ¥·A Ѭ¡'XEѲl p&zy‘q&b‚šÜ$ƒ8Ýœ’®¦ë <´ÿ'•‹]±Qªs½±ü ¨“1ÑŸ“XD|uõ¼„ÍÿÉœ3þ= =B6™ûâø>á£tèþÆq¤?¶è6-²å£Â1r}ØX¯éÝÃáñ_;µÌ[ÂLÉØ¸É²±-+ÍEP ê9wi³¤; l#£f¤,n¤‹(I;ºÙ^ùHÍÐ[%oÛÑ9Y­ º2DT7ó²]jÆ.Ü{mE×àh“Ä vîìCâ°9dîó>\«&ÖÚú Ù†¤W{¨ÌT—Õˆr¢{‹žqñž>ÙmƸ“é¦Ë”„µ2áÎØV³A®oœ•¸ZÈãyÁ%"Qê¹¾›¾u­àØö`­‹ÅE'h=¸¬u¶ÙX«_ÜÍ">Öٌٲ]+žB/‡N-šðÄ5’¨yÜþ-©L‘¢$…¦KEù*ƒ'w¦øå5(˜¹"´Úº÷ž•…> xÝ(ŠHÄQ®'DŒ$¾Ôì}z’L…A¾ý„H ÒÉÜ(éñä—:3v,h¡ÝÖk9?Š,£³¦Ò¶aÀ± `¥B^'ÆL[nQ+´˜ÓH“_ÓÓ!¸!Ô“nÊ55WWÝp8É4/3àßÌ)gz3·ú6ô¥%oç{ôYMf¥<R¼dü7ÌßÜŒõ’å~¬½tè®3+˜²jȵ#>W3×ÄHÊ”BÌÈ­¦žyšJÄ xÖeÌõþBeqÈsH¨ñõÖN`Ýà¬#~rEe]S:?‚´ÜF;´m¿O7p!\«&„ÿ×›mŽxZÛzßHf œ°öÖ„ó=3cýªÊ²ŽøBŽ^”ï¸È4ÚoÛo§àöóEÅÚþXû^ „ ÝÏâc˜÷.V•4ò(‰b‘ÅK×Zs±pm¸zÛw—ö}Q·sæŸ÷ÎñJì¼Åbh'=¿CT _PèÇ\à1÷ž¼7‡Øw¿6;ï\ø½.Þ™áêþØã ·ƒƒ_þ'nXÚendstream endobj 5254 0 obj<>/XObject<<>>>>/Annots 2099 0 R>>endobj 5255 0 obj<>stream xWïoÛ6ýž¿â–5€‚ÚŠ$Žë¶Ö4í2lÀ¶dØ-Ñ–V‰TI*JPlûÞ‘Vl)i¶80,“<Þ»{÷îüå`L#¼Æ4ñRŒâ¾á·1¿ýþñ`<9‹§4žŸÇçTÒøtcÍ?t}°ÿŒÕù(>Û[}w³gÐ[5:ùpJãݬqóì>¤þB|H¢ÜÚZ’Ë$5¨\mH¬tí¨Ä?ßüupòøóQ"”ËŒnÂ×­Ùˆ„s&_ÕNZ–ÒÜ&µµ2%)L‘KÓ•£kŠru+ŠZ¬Š½-å~Y {ONÓZ›tìU÷ú ǸÿßnP“IEɃp÷•,EeOÖR¸ÚH³]X›œ²µ ï^]ÿyõñW©Rœ¾¼Kdår­ú˜3YTÒPR –”vd3ݨ!üÍF*i„CÏí ÷\9iJ™æÂ܇5-ë4ÝúPóî*8E²õ çé&3R¤ô³N(‚ƒb#ɲy᣸·;*-8&¥Lð9·%;Šœ²+ÖòqhV:/àvU %:•L‘[Iem­$Õœhx!ÒáÖŠ3(ˆ/JŒX3ú^p/pP—?TU‘'‚O|+Ä‹öàúN8e“x:ÅSœP°DßSÇó„i…Ü|û>ZЦÐ+Q,×÷ÖÉ2~Ê+úÚ¦Á%ªê\ßÞþÔ‰edQ>ÊÖ"Ëcƒ¿ Z +—Q)Û-ýkþî\ëŸv¥<ôÁ˜Æ³Ù9#E´=›˜¸Rk‘„t=Å£mq,#_Øv@m¿ÃmëÒÅ‚ðI¯?¡À«¾—|ã§‹ëL˜êZº~Ñ„Ø/£ã¸—ÑòxyüºŒÈHT¥¢ª.ŠîZ€È£\»’Žº>Üê<%¦V«â~¡ ªvpßc"NGÖºFˆò56úƒGúî-~ÏOÚÚ{l-:Tu¹B•luÞöq¶X5žÏ'kÒaÈÈa«_P˜†l^V„B…%]R²éØÿKI€·cTDëZ%¾‚÷´£ ×Ýê€$\û‰¨7™°¾Ù:Éž§šƒÀõƒ.ïðÈx—¾É£¸á—dHÎ3…Ì%Ö·Ç­˜…o#þ =5†ð¯!&,(óxjh2Šg¬%ïs#¨¨Wß]|xïi<Ÿ39=¾ÔÒv/m{ Ë …à:#‚Xne~× pCeôÝVìÑ1½LKå{"4Þ"¬ÜSxEï l'‰ÑÖ TdÍb_éâ¾Ô¦Ê è1]â°r9(r?àÖl[ªU)¶§tñòåƒwL%hQò™uCS»Å+=:1ÝæÆÕh,¥t™6«;žxïÇ-¨-3#•&G‡X]¢4FTU{)#kÓ²k¿k]ºaÅ´=Z‚åÝæh6¹‚¥ïÄÍ‘Ç]m܉ËA–€v°&OhH¥FƒÒkdߊ‘_j¤ ‚©¹yõÐtÌÛ˜~Ô¼•fàÍø½Ý‰ Vô“¸.…¦ý°©Â¢ u™ @™¡†|ë…»Ú lìÓ&8o»ÍQ_!1-侓à1Š’‡ºádƤdþÆã}ÁB_\ìtŸÆ~ð¹*ņõ´AKÇm>Oœdüàör:è Ì;,u­Fƒí&ËQª0ØxŒEþÓ¥€ ”` H^L×Ð Üò0:ù± ± %„4ìôã“Fê·ÓÓ#‡.Àai¹¼ ZÉÄéR¹ê+å~ñ$ï Ð*LŽO”'3ÈßRÖŸm.â¬E·7 p8{êF ¯§{SCëÿ?|‚{)}m»Jèô±fê(œÛáÙ2ê,Ü=!›š~Â?Þ¼¡CïݰcãîüêòØ?ø–ˆÙ´×¿yÐÙv÷»×äD[9žo[Œç§ñÙôŒfóY<û vÈ?Þë¤~¨q6廇çAÛŸÔî³Ñ,žNP \¯NùàåÍÁoÿÆSFendstream endobj 5256 0 obj<>/XObject<<>>>>>>endobj 5257 0 obj<>stream xµVKoÛF¾ëW ¤ ‹¢ÈXql¤Ëq 9Q‘ bI.¥mÉ]uIÊ6 ÷·wf”()i{¨mÈÞÝy~ß<üçh~Ï ™ÓO^n—£(Œð²ÿÐ+˜ÞGp&°,!Ž`þ~Îçï`Y©–y°ºíX[% ¸e ¿UªúÌÛµ*Ò W²iÍ-ü]@†OPVl•žÁóËÙò÷Q“*‚—wDGxÌ+Ö4°`UÅ5<$7]V‰üzpN4 Ò³k¨Ë0Ž4ˆŽÝüe’$ªÂ˜ÊޱO>ô ô¢»F˜Äq˜$ØE0=‡{r~ ü‘QT¡€óé 6_תè*,1Ÿróa<#‰Nc(<¬õWBæUWp{óëñPÞ׬åùµC3 ÆÞy¢´<¿Nð†¿ËÙŽ$‹Áâ•ʼnXs-Z¢¦Ôª˜÷¨¦‡ÓeTÛáÎøâËšéÍ:Ø"‰×&—CÄœ¶Úr­B× ; »‰.°IVà`Ê~-pz)¤ô+&Ç9ÙìµjÊ °O•‘/—ã€}ÃÔ:³p ÓO»ý ¾ÿÿ4|¦µÏöBŽÅPwÖ?Vƒ× ÍNöj¾|,ȉ+—p×ä9 fqrŠ”^¾ßöÆæôþÊ-˜ÙÕÛð2¹„ùn»9¾|ýôÓ$ #¸SyWsIå­$¥€ÛÒJOÞÙâ(œ‡3¸s+³Ùß—Ñ>/XObject<<>>>>>>endobj 5259 0 obj<>stream x­WaoÛ6ýî_qkBFeF–'ñ ˆÓ´ÆÐ5‹½ ²t¶ÕʤKRv²aûí;’RËò’ K¢ŽÇ÷îÞÏßZ]è· ½¾ùK–­ËI+`->|È9]pÆz0™A@ÿ¼ËúýS˜¤Ö*€IâüÕž|iÐéÒsêÙ§£ëc03èжNØ+·y£èB<k„L,¸oWD¡W…6KôžŒËݳ;aÈz=B’z—±BèÀ/#®?¢^ˆ4òºa/jïàŽ±\]¡ÌÖ˜²>º>‡n¸ÅyRá Ög!\e-¤‚l¹Êq‰\Ç:ÜÁ«8†ÇìØ@›¹•Äu& Šö’1¤¸\ikBƒ²¾ïbã6 ”hc°Î¤.â*ò.‚Þ–çî±,-{ØÄ ’8ÏÉûLŠ% ß¾…D¤è®Ñb5Ù!š©G‡qï5J™¥)=–^(ô$ÉSÆaøš!”qMÄ aÒG†3“.ó˜ŒcNv*›/(‰œbcJË c]H¬’äàùU1iPdossäèBe8ÀLHëGoTrˆ•ÿüHÅ<­] ‘; ÕBë›´¸HUv€—dŒ^‘ÇSú¨óD¥eõoÅZsI+ÅJ‡¡Î%æ0O ø6Ã×M°ëþ*ˆ,žU1ͳÄY‚­¤Ìs1óÁ`|¯4.Ùè*S+¡ -ø³DéŠHÜÙšt\ßr[@–Ȩ$QŠÕå:KP±øoqj“͇7Z~¿çPhªRÜ”’áÌ>âòÓ†W–ÔAH¹`e(9Õ‡AyuÐ\“wHèÃw®r#ä=yŠÚ{<àñIp[ãêØŠqiiœ_ÇÍ‹©Gž©ßB‹Úu÷U÷Üc©L«I^|‰G›8G®MŠé—Fö©9DÀ+òœ ø Ív¿Ž•Ä@@Øï¤r=:Š’A= »$7bwò$ <ÍRíUãX‹,¥¦nÔm·7È"ÉW—±Æ³I†³È«X”ú†ï.þ…;¼yóXlÜÖ9‹s…u±€ý)oŽ›ÑO¿~úñK1GŸ]À*dû¡1[«(oµý?¨ûéÜ7Ѩ•ïû!+º:•ºÎ¨È³?(A¦nšˆÔiTÏU Õ²^Ð…´3-Ø…»ÆDØWTTëµ0›ø~ÞÞÅ[ø@®ö)–FÿêkEjNÛÞNe1OËÎ6Ëãy#ú&ÈuO•B|ÛGÙC»˜Fmœç:`#zj5ïãßFïo§Ÿ¿»Kpe&V.Ô†1§[½tÇ=ÇË-j™Ñðò‚wò§¨ 숲‡–:wY"†§–6FpL×T5õ çt5= Dy-ÚÜðÑÐllX­¹›S‡f0ø+7“DÞ«­Þ^ù¶‰¸7“ûª j7†Ù$øŠzœîé ¼³ÜnÍ 9ˆ¼Ç0·ç4IùI˜»Û‡Ú}Ôî!¨Ý]¨»g•p®ÏÊ«{vÌNz'Ð?ë³S÷}ÁµÓc\‰¤Ø™áéÛ‰³îœº–øŒ¹ÿ$è³^Hßh( Ïûfœy7iýÜúdJŠendstream endobj 5260 0 obj<>/XObject<<>>>>>>endobj 5261 0 obj<>stream xXýÓFýýþŠ‘*µ¾SbòḤ’»ƒ¨(—~Humìubpvƒí\ˆýÛûfwØNÈ=ÄÎîÌ›7ofvïãI—:øÓ¥þ€ÿ†‹“ç㓎ßÁËí?ÙŒ\wèÜïÓ8¦^‡Oºþ`ð˜Æ‘YÕ¡qè~ä'±X¦òíèõo~¹òŸ‹\N¢$“a¡³I¨•§ÀË×Élø¶ÈZÄŸ.e*g¢úc78ýñtüþ¤Cí.ìG°ÿÅ=€y^fÉ-6ÒTë”nŒ)¼‘Ñ0yþRä¿Êb®#ø+²DÍha_‹…lÑ,ÕS‘^\ÜlòB.üÆãx³”ÿã6ðCœÒç"·ùŒSÄ•hå[#k·Ù||JÅ<Éý²`[œòç]–ýì<6Ã'è\ä—ÒÄi-ÐÓŠ/ÿR†©àpÙˆ?ÊoVS¼Èó7qàx¥ñ?§%8Ýç—(“Å*SÔtÑDòµD¬UØD¸œÿ>RÛ8Í—ŸéÜVWcá}½Þê$ªyåøžC%ÃìÄGÓ–å3NÅì ª¦%×d¨ó°5)“ˆfû]XAŒÌ”H)rj§Wî ›žt¯ä©irßÄ.ðª‰nàÝ'àÒ|³˜lÙ’´êUZî+‹²,½}ÝÚ¾n¹¯é//D‘„Í‚dõ¢¹?Ø,ššè@뜅F|nñg*Î"¥_JŸM¬ßâ³{OŸFÐC‰›Ò>S9®CŠ© 6Ú½¾ë¥ÞÕ­Ì6èhVq¦h’¸ëpóµWj!”˜áÉ–‰¶IŸŠðö#ìòkHWøôR¯%êµåh°&…"—YERÕ€8Ís@j³ iü–“_€Dpª°pÀlü+}¡N»]¸k 6¿ÀÁ£¾q@vFë ãÇ B‰ºÕÐ+h\O…ÉR•þÃàÛ·m bDî øt\€î´õd›LJ"Ë稢Z+Ý嘷²–™È2±æhqeЦ€Lqî¡v%"Û8]×8 ¼WÕ}4. ¤w[\öÎ9$À «B ±RüÙ‰}µË±i¡FÜÆ 0“¦Ñó\©À>wÄ4lÌQ©i™ª7VN;N™£Eó7C¦aªÊË‘Áej›e¯Ñr#ÿíh1oëxm)¢²líêjÆj‘º làbúÜQö£Ó…I|A¶TœŠ†¯”c ۹Ȗ“ûú)‰µÃmÌÙwÀ]K^ˆ%Æ"ÓêÔÅTÑ<ˆw0–Ú0aìÕooí^Ïï÷q—‹¼›?G/®þzûæÝ˜ìiÏ7ãËáϯ^Ñqàfù™ž¾ÙÌNœÊMï‚wÿT%aøÁ} þ'CðË·3±y5Ÿ[e.Ýåïnó¼â.ÝŠ Ü8÷.yœ5â(q ´': NmÔÍÓåž/:+OTØm0“p‚R.~:°ôYàÁìþ­Ý5ðJ;ÒöØÖ~–ã¸\^³·š<® Ë¡‘,>/XObject<<>>>>>>endobj 5263 0 obj<>stream x½VQo"7~çWLUé´¹ƒÍ I8å¡IšSZ© U_Ùõ‚s‹M×^¸ô”þöÎØëå¼r})‰Y<3ßÌ|óÿêô!ÁŸ> Gô›®:7“N'ø°y+pzŸÀe<„IƒFWýx4º€IfO%0I#À×F‰ ôV,f©’’§f–‰ÿ¨r=þùðivËŠbÎÒÏÉÌ@ZþãAš_¸Yª¬ '“§N½>z̬GòúÊ+pØÿÆá ÓüF©Â9ž|¬½"pôº.ņ>Þ ø#€.‘=”ÞÝd`IHËξõ®hB 3óeÑÓhÝÅzñÆ.køˆÕ¾«‹<£PãñÿÕ€V_öªà3 0=¯­ÚåÚÑ®pÄ—ÀW?° #}c~úx!4§÷g@.sèaq{ƒaÍïèWe8˜%3«8K—à9 iÁ´ÊÒ’#©40 •\1É´|O"®O” }—ÔXÙvs0Ÿ 6,¬ùÛµvôÀ8µvÅ¥A†E~QšŠ°²2¨»PrG2Ê”ÆHCµ£>ŽY©Ê8ˆ<àÑiÆ ¾@6L*Ùû›—*BÞ„gF( *Siê»WÁñ8œgçG%½T[(0b/CV AΟAÈò¬%°¶;£–Úã!óJ¦6‹µÒðÒ y¸žzƒA<â²Ê¢×42Œ1µc¸´´wó.Ìq}@^°Åµ².ßÃÓõ%PK§_‹…ÄQApðD. 9ãd¨qÓè‡#9ˆ @Ûý˜Fó®ƒÙÆÈ!S•²ýüx¡ùžƒË§.Ä{ðnþÑ2žÈѬc—е-MÛ3[{Óè ËjÍÛ[ À*p§Öã+ Ióz|îõxÄ#¼‡ø•‡Ó±Aå­õÐ} Îâ3"Ò¿´Á@Wsƒ»P&]2Ø ³“rÔà‡õ)gUa`ÍJ†£ÈKœV4®4Ç«‰0Äi¼Í¨r†ÆyÌUQ¨-Êܚ؊¢ -Eþì&4œTWŽV’bÌùR4k€vÔc¸EN ôN¬IJVmK¶^cf om¯ãcæÌï\ýt‹]ëj^ˆ´}áòš÷·Ú¿ïà…²F;sõÁúZÑ€±k$gÒf”»'½ºÒç$©X\ê”{­º5#ö9°à’ã¾à 6¸}ªZÖØì.οjØÓ­Ü¬»Ôß•,Åýƒ›Ñ¯%KJ³Uí]¤î4Ôs=²°Jì±u¼U®uÃo—¬\ûÀüGÕNþ×à?€Ú•ÃÆ=ÔéI˨í|,ßϺ“pzŠÛ «M­ÉênlXQ¹Aly ¥ãû q¾¼‰/ô\‹Òe}-ë_žÅçÃs_ÆnÓÐ5°7Œ¸SiE«Þ ÁÅ¥;Ý»pJzDÃÎT·î”®ÁÕ%™ÿ<éüÖùû¨qendstream endobj 5264 0 obj<>/XObject<<>>>>/Annots 2102 0 R>>endobj 5265 0 obj<>stream x•XïoÛ6ýž¿â‹‚&Š$®“aÚ4é:¬]ÖëŠy(‰¶¹H¢GRq½aÿûÞ‘’l¹n·¶FlY$ïݽ»w'ÿyЧþ÷i8âWZôâ¾á?}þóöåÁE/ÑÅh?¥‚ÆÃø²¾Èéþ`ë² þ ·n.GØ98Ç=ìöÏãóúŠ·n_ãîÅ8¾Øºû|²…ÄÃ1s:»=§~&3@]âCæ‘âC½rTˆ5•ÚQ")Í¥0$Í”±î„’Ê‘]è*ÏHPe¥!U:Yfä4¥"ÏéxòÇÁÙ-œöÇG×÷ a–/äLT¹³qýáµt M£éqXÞ ‰hftA×Ožœàxž²¼¤G§ý`F"u̬1“lô‹ìëG&cš,”%¼™ ¸Dn!á•rJä †`N• »»Fδ‘t¼sÐŽÇûPáÃA+…øqÌá D|=(ùa)S‡Ë•r ožo[v=l³áNV‡ø$\2’ú«ÂDªrNV:>à´ßë±ûÁd"Ò‡³Lær.œ„Ã.]ðZÇÑ©ⓞQª+S‡I?J“kP‘5K¾Üý¸ð;½’8´å?$ÄW_LõG<‡ðnàûìòÎÉȪ?“ žµÉÛ ¸.‘ ñ¨à>Ãa¦ti•Eþ»õ@Í&‡™U,sY`‰pJ—Mñ,…‡uä ß;Ý\›ñŸ¯ }ùTÙÀ›ôéRg=м’«e«’Dò|ìÏn/ÉkŠ×ƒÓÁò‚Rƒ=¥×([:«ðP6 ”ƒóx<æõﲄ$°m´®þAu¢¢>lû¬L6â‘r\Žx-µµ*É}¡§ºX*|”"]Ðý»W/i.Ki«¨ #–Ë E‘©Ù å VeY$ù:¦6¯’u‡Ò&<ÌÅæÀTC]l,«ÙöŠœÏJäJ)[C¬‰ûW (*D£]é ¯åQÁY•+·æ*c@!Ø­˜Î¥»¾sfŸnrÚ.5k±ñYéL•:m¶ ø¬Üshjù˜lºBDn½”…XZ*¥Ì,¥ QÎÁlP‹}²Äí÷¸J‘‡¯›ä‰|7ÙÁF(©Ë*ÉUº»uI"M%jÈ»µŸòï+ëZätÔ€8ââ= 1 h+®ö ZÄuª,<_ArEj´%aÀø£P¹àäÄ;¨SË]/¶«ù.r˜.Ä÷DI «8#À][³ç=Ó´D‘Æp#X.˜HV^²,.k¾\7%ßǧ¢fÕÌßBÙ{“8Á[ “aW±„&±¾·ˆ'1Ï!«¿4U†ÀYå*„ 0-tÏ7®ÚA[qd.ƒ¿úÃ:ôVä^SÑi]fìM*J2Òr?T~CQn~öØÄµËeݸüv hÊ"°ÕÐ6Ƹñ°œ âáWYD^e~¿¾þã‹÷¿ß½ýñ—÷Ó(l<¡æ]š¼¿» í†Sˆ§©½¼àÝÛgww7o?>aÿI›Z<õ¨†ñhô”O~–£ÄKðÆ8AÐÑ~DÆ‚IA7ÊãÍѾMq?k³l7am„òêKJÕþÌj”ˉžF‡oD!§Ç¿u³¹-áœQ˜ wŠ‚YßÜLP£Ø¿ÒæVÜ#Öº¢‡R¯p¥ åµiå M9ó j½?žÝ˜ž5âY—­üštÉÞJÓxÏ#+üÑ\ö ÅSãBA7Xò\YYb}²ÞħIŒfH®§Ï_ï×w_£t ú¥{>‘Ç7™‚Ö>7zeY¦ÑÿZv‰@ÆoxÚù?¡E÷áÀeº<´!ÐÜxüFYk¯#(ë*ô:Ô°±“ð ^×Ód+y€ZØ£¦ËÔµfÿcÓõW4 }äžk>3LXá,×*Ш2Í« šÉU»Û#¨;ML·P‚#u{ûÄ{\¨ùÂQ®õ?‡pRÍ0X:ì’}RtYUxq›°»[ÑŒU7ãCw6éŽ\%F˜õ&Nx$áG¨ÓÁˆKÓ8îÓk 'ø¥s?ø…¬7zX²L{a—%Ú“W`@Ai> £8yöFÔÏc> uÜý g ƒVñÈÓÞ1¶³êÎ…I`G‰@B'à \…ìUUBrß øÁÆ‹-à1P¦ª(v¦à?Û»op"¸9Ø%ùg¥0…2Rlôíȳòñ ø=šëÖòîªvNôA²ÌaõéÓŸ~V»èâá"ÅuyÉ»o&?ü ½vÌÃendstream endobj 5266 0 obj<>/XObject<<>>>>>>endobj 5267 0 obj<>stream xåW[oÛ6~÷¯8k“ÍEbE¶7M‘‡Õ¹ ØÖf«±lC€–Žm6©‘ToØß9Ô%–ì+†íe¹Ø¡Ežë÷}‡ù­Ó‡¾û0ñO”vÞM:aÒ‡õ‹™ÃÁEÇÁ&3„0zÓF£×0‰ý®&Qü×<ÑS‘œœ|\Y‡ip9n„tÚ\£Š¥š_H%ù;{Û½}õöÕäS'„^Ÿ,ÄÛ-Œµ²:ÁàÆH‡ßJ…·ÝËb–ÌœÀ Ø¿x]š<¸8¶9ƒEÛ Ëh»gZ}å`Š`s“i1·äŒÞ Úð¹0SAF:I0rÚø­åÊ'‰PÅZ¦ûNÞaÓc¤²N¨)9b–ëåRÝñäM!ÆdP¨¤Ú`“…7Ã]p֙ѫÚÒ~ۭϼåwŸâVNwÔƒ%ÆA8 )’“UÑ£%c‚ŽÜ“åÿœ¤Ø@]’®h£!?le-¼GÅY#lÖuftZYa ð®Ï ¢•àß<žæÖÃVÄ\|*Ì–sÛ*[÷Á#µNñgC$5˜ QS§+ ËU:xªÌst7ÌAæp«—Ô2·Ð1C%Ær[ž:õÒ¯V¦"³Ïh×Ûn»‘tLìïvÿ¨:V ÇÁœ+â4†yÂÕ¹×ø-›îA˰¯«øŽŽ_¶,’:Ü ‡à÷OéÐ.Û¢%•CCª÷Z1â¸ÞyëI|šBoÇ þA½NýºmýÏF\»Õ’d¸Fi“O¿lò&3†é=ŽëÒB²ÔŠÊ¯)^nkW¶õ b¾„;6ÞÛƒLû\™:Žäœz;#¥)Î:D•7HÞTµÓÃñSÀ5ºè„¦Ð‰âS"á½0RLIèû×@’¼øÀ@8ýxsuyþÓøÃÙy…‰/¡å–B·¦…í Dür ;2e¤¾Ý)l7üóLÛ!ð%ÂZ%RŽŽ¨œöol¤!BHe£_œÂV—Á/hôV(@e— ‡…Á}ØÑK…fûĤ˜‚&ì˜ÔÛöVèyœ·e¿è­ßûä øD%϶™4¤P%_¹$åÏh•§1ðÑAŠÉákíÇJÃEš$}…"Ð#UÒåŽÆ3³}š'w@x¥¿«¾øi´ãœÆ¦!NÇmÁ®³MÎf¹Š±å¤ˆvý´6ê³|šÈ|ì¥Fl@àLÚL[ùDË« ôÿLÑ*H‚Ö¨£—ÞXÆÒ`16Öû¼ÑØèWC%ðA¤Y‚×WïüðÍyÀ±ýúhÏ.å|LÌßFºÂ÷!ÞS¥3‘Øê>¼†+V´Q0jOÏËÇ{M£•y[±ª¼”®ËX[X¤ËûÂqy»„‡ÁÑðFÃc‡<zà „3å)Ýá3—íпÅÎÞë‚`ƒ08úð]q¿L…¢Û3Ÿ(n–…*òØkN«Ö¬²lú(Ãý E CÍ?Ÿt¾ïün©üŠendstream endobj 5268 0 obj<>/XObject<<>>>>/Annots 2104 0 R>>endobj 5269 0 obj<>stream xÕWmoÛ6þî_qhMmÆ/‰ã¦Ý€Î³lëÚ%ÆúÅÀ@K´­–"U’²ëýﻣHG¶ãlÀöeIàXÒñøÜswOŸZhãoz}úK‹V›µñ}tèãæªÕ音.ôû]Ö‡:ƒ3ÖWn[ÍëºÝç¬ÓxúøáÐ{5s8=‡NÆ3ܹ?À8ó¶aœ&Ý6ànoD¡Í ®ø\B9˜izúA¤ÎBÉ­8 n!`øìH¾æÉøCëdt ôD¾»§ì½'c´ŸyQJ¹YnЈOU¾ä’Ü{_øŒ|ìP€ˆ“Ÿø’7Ì·­b\ ƒ78Ws(êR®`*À™<ý¸†ÕB(¨,='Ð\e0| ¥ÑŸ×Þ#-Y’J Ð2 à¥Ë\Wv]è•­Ø*]@Ê­ð®ÜñÇ0¥Ö1Rì0ÉÁïÑ`’¤-…p !èwŸKO=^§(3¢à¹ü³©.ÆÌ ã“2«Têr­`Á-š¹Ê(‘1jeó,Úh)õŠØp+í _Ž“Q¬G©ìR.»¬×ë,±ÎT˜¼KYÆ—³ž%€``R+ñbçAX0I‚Åä \Ô–“àå—¯[K¾n{¨ÃÆŒ!ìnü?Q#Û^]VS™§>2Œ†J”Àn¼M',$í}8Kg`…ÛDr·%™Çá;/`;ˆ|=…yÃ_V§'®Þ]Y³p×WÇ>=ÖïŸS TÄ•Å.…™ÑE,¢ƒÉüÙ i$s›+2 ¡ETT†É“}³Öäå›Èã½+*/_£`Ã|±\À#ºyçn›¥ãï½™•IãAJP¾°Q Ha±)ït¦IÕãËœH¸—+L¯«;©tö‰Ùc0, ¼â4Ý&ô`è$X$m©Î¬r)Ë_£dê:ÔwÛG0Åÿ¤$5©þê9=-ø”v^4IÏPZÈe²A"ygp­`¯%*…_¬ÃbŒì…tµXQ@µæp˜s3¥RMQyPÎHŸtšVˆmÎûߦ£!(¡f¬–‚½7¹¿ VM’ýb§%cÛµ^7Äý5ur·yQIîPìï¡3²äÐÌ¥žryqq»¶NìjȆ5û‡êvÁ{ž»‘6ï°õ0S£\q™ÿ‰ùþ‡†XÿV>ÆWjÃqp í©H¢¹[øÙ‚„±žOjâ­n¬ë/Î/ &¨’Éõ.ÑäПʕtyH•WÖ÷J,ã°Í&ÍÛî©f|,¹Éù´žŒZÃ4!q5—ôµÔظ‘k#¦ëº“é µ+WkÀ5`°óPýë~Îfšc?Ï<žzt@ÌõS¼‹C¼¥ùEËŠš0VǃM“ϲØû¼Ä 5‚jΈ¢P©h*ƒþþ®ëó7Œ=Xá¿Ø­Ïë×¹-µõŒ| ÀðÄó§u؃¦‘pûáRÙ µÞ-pØ"©ºB¦…Uߺ(3ž¥i:¾ÃIéå¿Ñºè g%ráÕL®‰d/¦4‚ux¤Ððjœæ&ô^nÆÆYZMq³P†7‘µÝc"Úï´ÜM¥°®»¦ÌëòV˜eŽ”³1ËR 7*Êá;g^©ìU–mÜO’i¼ˆÉÝHÂ.(WH<ÂhÜ’PѶ“$,Ø©8õÄ…´šœ@ܱ~Yxwýëïo¾DÁ åòGóH´«|Nh޲Î#¬G@÷d4¢Ðœ²³Þ¾uÙy=îÞ¾¿¾:îá;×kVô*ÄcË`ÖÖÇçµ³ûòtÖî³^ßœ°Ú{íeîrÜú­õ MP­endstream endobj 5270 0 obj<>/XObject<<>>>>/Annots 2108 0 R>>endobj 5271 0 obj<>stream xÍWÛnÛF}×W œ&¦‰Ö=Ž‹>¸²œªǵ…kre1á-Ü¥¡È¿÷Ì.)‰syÈCã@ ¹»s93sföC«G]üõh0æÿ^Ôêº]|áŸÿܾjõÎܺCwL6¹/‹—îZ{¯áØÞÚÞkD½ÞØî-Žº#HbKõûkßX, ŽÏÌÔcɼðÒÞkDæënmï¡¡”™ïùfÌèôjˆ4_„ñK<øÆwvì© >.ÏP$´·’Êlâ4×”ŠLDRËÌì<¬äÉü]ëô Èuz}Xä(©§¡Œd¬í†Òd‡ b•ø[lÀN« ¢4Üð}EAl”«TzÁ2(lÅW˜ï“'”fÉÇ y¡PÊ-í8s M¿Kh0À›ï<-X8ìäâ„ ÛèGIGROntvû¾+—2“±'μŽ/NŽX8 d°+ÂØzˆ›$±१ÿ{ß!:=¥i¬òŒaÚXþjB~"U|¬JO“ˆ7[›-³$¢É“CYÂF$}™…òäùs )dˆ˜ µœžnj"Ò,xä(6H[·úÌþ‡0¹áùùÝFi¹·y¬ƒHº³ù¤w2{ <©Ü_Eì‡ÒmͨÖ¼:bDu£èçòSÝ<¢Lê<‹KÜBíÂ)d,NêG>U<|j^O¯^çíÒĸÓ¹ãñ Ž_¿ërB]2d‘È ° zŽÔ@}¡l8I¶Eï ɘxàQë,¸ÏµT¬s¿n;ý!¨ ¸òŒAU C™;×⚦=™ê ‰I~( Sn†v?¼—w®Yn¥di,ëèð‘9Ÿ½GÌ/nf¼ÂéV“Øn—þú›•Êm¬@£¶C˜â}"¸–Ö™MK=L—*YÝdµ5Ióû0ðÌiÖWP±Ù¹p)¡X@k¡Y›› !ûõÊ>úbsxˆ÷€mÞà@“ÌbùO–ò…õKˆn°ÈuMCÛÿ©Êb(Ë]ãÂ3ÔP'P”’<ㄟÜ%Üp0z×s×3®ÝYÜÞ}ͽ®ªˆ  ‡¿vÔš¼#=îžþ dÖëÄL"h‰eŒíáXÃìÇÝÔ€´°æ3Å"u2‰ùC‚ýs øÞ >5ˆ'qÇ LrÍÓ O%æ}CÍWA¸B“¿a’¼Sš*àžoË F•C•ÏÄãË¥ÈCݶUcK¦2¥Ô-l*.ZSzÅüc‡¤“̖“_. ›øÅ>/XObject<<>>>>>>endobj 5273 0 obj<>stream xåXmoÛ6þî_qp·UFE¶'ËÐ]^cX“-Ɔ Z¢-­2©ŠTcèßIÙ–,g@ìÖ©I‰w÷<¼çŽÌ§Þü7‚pBŸxÕû~Ö ü'·¿Ê%œÞÁ(€Ùß|‹_ó¿ÄÞ:å%‡×_Å*ΙR‚­økÈè’ •3ÍÈ„– SE)Ÿ7`ÞzqƒÙ½Ó;ŒÀX÷®op«=zÀDbìg¢¨ôQÛdäÂúa%Ž4/‡À—MœŒÆÀKÐÓT´|ùpWÊ\¿;8:“ÂJ¹³<·¬d’-ệ)¬3‚’è7ÍÄòì#¿ª}_ú!±7Fï㱆8J¼ÇÒ|åäY†ÁÛˆà-¾†ÖÃÈ£ÑΆ0 £Áwd˜ Ð^tº¯ô1K»å.?=…÷RsÄd°)˜ó\®‡u<%_±L(¨Dœ2±D´´!,ùh‚–pç×Ä38žX^q˜o Ÿ×oÞEïbÃ0³ÿYôv.r›4‰žœÇ]ôüß²6²væîrùÄlGèO&Dà CŽÓŒ?qŒa¬XQàFaÍ Â&L9&•’ð«r ±L8,¹à%30Tž-So0ð=¦?”úׯ gÊHÖNúÖVۜ٥¦jºLÞÆR<ñr+«k]òa†!P6—+žd¬ÜØ`0g1—•¦ßš}ä[!Ík–®DÂË|C mãzYªFÚÖ›Þ˜8‚-¯ †c†¥C¥r-lÎùµN½|íLF^¬èk4@ö…Ò` Ã7Ðo1Ù¯š4ß_ž [z¶‚ú§(ùÛ> ¬Qh¥Í”§'ó òêYÿwÎpW·ÃŸ¤ÐéÞø†m0óš¡ÔÎÚñÖ/A¿¶úK®¯tyû¡EƒÚ•ô>VGÕ–$ÒÒ¿I¡?ʶTÚÒ [•­}¼ÄñyÑ`XC·õ`K›ùÒ‡ö2³?fÝÁ#Ú*2ý¼y¬°Ê¿í™õÖwÇ{ì¨ÿ§»Ûª\á®r¡PK®°‘N]1‚åÚ-U(¬í$çZ_®ÝÚ2k'wÇöç…̱ ¨—[XQÍó,vÝò+XærÎò«+—eÓ›LR±yÎáÏ ¾o4¿§Cg«$ò±n§Qg“›¢Œ;Òy×*üíëºÑ9œªíœÓ´8E»‘Õs FÛì=¦…ídήk>{8OH›Žø€ê4n'àÏlUäüaúþ×ûo}Kð‡-j-©SXS/ŒL Íêb“ à¾`¨ãÑÛÈR4èb9X@äµà?þ6ýá‹“üö9æõ[ßM Ê:cÔi)×m; ýÂuIÍŸ*@óxeáŽT¥ 9|ú™Àca÷~»„h•^[ÇÝ+²Ö ¨ƒÝ핺=K­J·÷¤£Ð°÷¹5Smƒ<5à'Æ“=!¾Í I ”Ô£Ë*Öõ¡®Å€;gþ•ìr¦•Çx¼ÿPsqDSAª;òð¨lþièÚEÍç—åV+ÕIPWØ/3yְߙȤ¨º9uѶa²ÓÙ´Ý꾸¨Þ]ºûñèòÌ?Ïarl/‘XOB?€W+¼­škÂë}û䞌ÆOçê’늕*ÅŠE† ·Ks< ƒ.¸S¶¹åá…^Æ.ÀKŸÆú8¯47בó`â‡cüs^œÂ $·³ÞϽ¿+Ëfendstream endobj 5274 0 obj<>/XObject<<>>>>>>endobj 5275 0 obj<>stream x­XmoÛ6þž_qð^â´¶â8iš®È€.I‹bXÛ-Ɔ Z¢cv²¨JT\oØßsGI–d;k±%A‹¼ã½<÷ÜQNh„ï:=çŸpyðÃä`Œð°þ•ÝÑñË]§4™ÓxDçÏN‚óó§4‰d׈&aŸäË-2»"ýI-ÓX¿{ýæ×·?Þ·¿½~õN'‘Iîn>…:uÆ&Á/ÚeFßëizôühòá`DÃhŠ éïÖgùtüòŒxyNC0Ÿ–ô_Ð\¯È- <'g)±NÇòðf8>c…“…¦^˜»uª{Ä¿—*¥…Ê)\¨äNGÖ”ªL-µÓ™ì`M¬„ýöÇöo×¹ÓËàZ9=1KíW+£úd,«ˆì\ÔEz®ŠØÑNt‘¨«îе•pÆlpšÙOëÀ/ž\T~? NȯOÇ~[–î&6†&í<–¾m ÷½Ï&§¥Êò…ŠcØ‹ø(Êô\g: ›ñ1 ]}Å˶^P¨„f™Oc¯)׎,Kb7¬Ý³³:t’™Ö …™æ (·82A:Ë0¨\«ÂûŸ‚ÚHC‘Ø}˜fú”g\Piªá;|˜ÛLlÆN a©#£²5\Œcšö}ÜjLt€Óß¿ÞÝø·7±èhðÒï#{kFuGÓôè ÍÝ®¨¹”²»‚‡KÕîäGì rbÐÜ$ˆäšf± ÿ $xS +ã’›­S«¤±/¨’ˆS±¿™Õ–ö€Pø¾x*†c‰ræ^s~(PEŽ v¨íÔfœê{•5‹5 bO¦]‘%xx˜Ùå+Ù(®‰¦a3]æ°6D¡3&„ÔÊr‡:XêÄq`¸¢àanØ”;˜ÌÀUî³16BÍŠ¹!”{sGaƒ9ö:s[d(ÏiŸm?ÚÂÕô¸fàTÐÓ¾TŸ]Tl»̼Ê!2I}8ÕÆÅµÍ¬äkÞÝ)­ %êÉbc•é4V!TԪ鼀4‹Bàú%B‘¨ÓÏ›™’$êKÏ *§é/!Up#£$”Z[Æ‘ÌÔÐð …ÙÊä0he (”ÓQ1*®ÍË7¾æl¨X»²EÌÀÚTÕ΂õmq_}’'Œ®úY;mÈÖ¸AH“ÉŠÐÁÊ…ŽSôÏy‘nÓåíÊÜ]qWbD9=âl´@›¼ `ÀÅ®rîBRü^¢Q£ª¶yd©6 i¹IŒ3*6‚lB±ÉÝÎÀ}nû= spw“[¤ “o¯x\×Íäߣó`´+¤2†Ç`¢gíØÁH‡1ÊNZ|Çp€´ô·…ó+;!ÎŽ$ÛR_Åáø"xFCÀ[Ks•ÑJcP_sºL„º÷+s×S‚2JaµMÐU˜¹D W?ây/ 7˜Jcí1P”zv×ð£®×uÝ–ç{ݼ­.[› ™[†(w–«Ç7±Z˜pjŽÌÜ |8UâHªr&"“ÈäÚ¶‡ãqpzŠÑ;êß[ÿ¢èwU¦}!éQzÐ ìh- GôWe_9Pû=tI"2í‹Èðû;íXàôØ h³ö“MÜ‚›¯Õšu‡ö‡‡ô×sp‰º6éà¦t¢wt¯¥¤ÔG’cäJªËàŽÛù T-”›?<‘×9¨NÜ\`1íŒõ¸d¨þ¥ÊoºK™F;[¦ýñh4`Ðø¬ˆr  6i ÝÒ É¤èø¸õ Åèt nY'#Ü0Ò·#Ó¹ý¬ ÆRÐe=(Ô °öþ3^Þ‹„i÷ð›r×´ï¯ShU…»ìuԜʴR½ï®³K¨\äê¦N“ ʵê*试„iý²Çÿ{½õhÀeî“T"[f< ت? –ŸÆGÏ{ûŽÃdéÏ£ZÅ>04m 5èívE<ÂTM7l,ÄÅÖ]*Kn@ÿˆá’V¦ ²ÄË@Iã¹”¨W¾ï¶c“£Ýfòt…6‘ç23ÁÀ«wLÑ´mz$ª÷^Í_Åv¦b?â­2¾aa6Y ë Ì[r€°6÷DÅÌ(ýÁ‚1ÞÉOGBÿ7“ƒŸþnóîJendstream endobj 5276 0 obj<>/XObject<<>>>>/Annots 2110 0 R>>endobj 5277 0 obj<>stream xµWkoÛ6ýž_qám°ÒÚŠlÇNÒ!¶ôb¯n1V ðZ¢m­’¨RtR£èß¹¤$KrêtØæ†E‘÷qîëðýɈüh2ãÿ0= ü+ü5â¯ß_ñ ÆçþŒRìñ/ʇ„nO)M§þeã]ã1¥«i-„Ïý0oè±ÊôšÎ^téOh¾¢q@³«‘?›]Ð<²Ö4="ß÷Oç4a%ò>ñÓÙËsâÇ qp8ž”½ùFÒJ%‰º³5™].S‘S\Á‹B¤’„ûky«mAË­¡H¦*+ŒF´Q÷$h[°€e¢ÂwŠŒ–K2‚pme™æJ ½£;¡c±Ldmæ˜ÍdCT–ì(܈l-É({¬VÛ1-ÎŒVÑ64±ÊH­ìÞ¾‘:3a”î“0FǰÕI*_àj ˆ˜ij–·Aòœ#>Áªön†ÕÚ[l—ð?4J¡‹îéTšŠÆ ¯áTÉÌÄ¡H*¿ÄRÝX"¢èˆ8‹W;†ã±?™ "ï› …"¶¨N"ÀxÝ#|\˜ÞÍsÄŽ8(_óþA½†±÷d_,¼jÕgƒT?þ¬2³iöTªÂ8T/uÜî höÙ„yœÊ…×´Ã_K êÂ[œz?ØêµìæýÖ*{ààÈ’(pÿ‹Óo{› xö‰ã,þDgg䲩S#Ñ|‹Mœ]÷´\Õ.w<Tú'Ïz€8LDQd(:öéæÑmd§•0Ô0B~§âˆZyXÅõIÎØUB;NPŽPG¡Ûƒˆ”·G†ß5Ч¡;< ý»ÒûÅc@ÛÒñxçѲØ&†ÇZf’ÛID¡ŠÐyÐT\ß©¢Ð¨sVÂuðhý>«vî{f£bòí2‰C² “ü Ò<‘(•› #P¾ôâìNB;¼ŽÃÿP)ZDÛuh—Ê"t¿Ë tuùµ€ç"1è´Ýózéè›×¿üñë/ü‡Ò§}VP™Hí³ÈO´B×MÐæRhÏ+|çI#ﶈëåFÊqŸ¨×«Ê>pmúügßÚ„m´ví 8] #¦+ä3óø <`?§Õ<þ¥NßSÄý¹ÊÊý¼åZIQÐàÍ¿1ún¾B{W¹Ô&–I_ÀJΫùZÓBºÁ™(õ%' ª.»c )èæéS§ßÕF1ûØ(¹N¾»·ÃðìÌÏ…F#CõîÁFˆEbÏ·…=ÃAíØT –X–Ä•cƒÈ#ŒMë—ùÛ?ŽJ¹ËïâÂt¤“i o¨àÑh@ãqwàt6SÜúAEí~Æi£ÀMßêØÈŸf ¯WÛe‹âøÇÓ¶èÇ¢õ–õöíëW6[ dM•..Ù•psè ¤¤öl›aÞa€†Ñ¦8òÝõA¹Â\çÌv™‰_M³µ\ u|qf3·}_Á=¢ŽÔ­U·E(uA©L—¨Øö¡êòáY:\߬Z-ßoc Û`¦Ùàvà ªžÍ ®³ÏezeÍ«+½ª³ºIˆŽD;\4Šx͵þ\kf•s–O5tTvº—ý$±EVŽR±Ý ¤Ëå ÌævÓ K†»*Û=©­é×’¾œ€³ðáðu¯““½=$Ë»ïK§Ã;NêËWs{v“K·¹DMâ¿„Óƒ%WøZ²YÔüãõ¥ŠÿžÞ—‚gçåÆ}Œ\ÚáÎn¯Š£Ës:™ÒìòÒ¿p×.®êá7÷ç*ܦ¸ä'*[u¸h»Ýà >¡sýûÑ> fþdŒú…¼I0eó^ÌO~;ù x÷Dendstream endobj 5278 0 obj<>/XObject<<>>>>/Annots 2112 0 R>>endobj 5279 0 obj<>stream xÕXmoÛ6þî_qZØ.lE¶ÇM X“Á°µ[Œ½ÁÀ@KtÌM"5JŠk ýï»ã‹,ÉJ[l뇵©‰äñx÷<Ïýgo!þÀlN?QÚ ƒßÐÇ„>~xÓ›„çÁ .Â`)L¦gÁÄ>$pß«=âØÅ,xY;<¦0„Áô0öõ²¶‘ÙM?Àém Üj¹ió—“`>¿€elÜ a Àÿ9yåQÂò\²”¼xý®Ð«AÁÓ G„ÌÊb5<.ï…0FcËxð¼ØgR1¿ºÿéîÍÍϯß^ßLWCx}Í /àù_nùÄ,§O_€[ Îxqz45çg½î'\ä;;°xïƒ_8Ó#¨¿U²ØÖž¯Ù~5|u´-À3‘F,I^=³‡;šñžp/;ã¢ÊâŸ22˜¬ÎÈ<$jÍ’ËËû}Žá îd)…ˆ>®ªS§Q“¸+À›EWÐi2ø•k…yþ d™$pY>-Ä «äÃûT 4/J-ÍRç/m¾)· ¤'‚%eq5X G@)÷oM2_SNinÇ!=î;þG@?]hð¹>½=BñÆpa<9b n•©ŠË„Á†ÇH –f G·Ü'3ÇçeR€æõF%‰Ú ù`ðI7É;žNƒÙ ©²rˆ [½ñ#¸IyÁ œÛ )Ü¥™Ò“…Éð1­þS^>²¤äMRšWŽ‘öwGGûð$](ßÝ}÷ãÛon‚Æ1~C…X ŒØ4õËØ\ »óy ô/ƼžNˆíÒ!+£õÏMË KrÞ½Ùÿ…Ž­ôy!ö&‚Æ 3þ$yïUÊ!SB9 ¤*¸a"ÖññôŒ¨·DgZe\{ Šá’6Z¥†Æ}WÍúžçÀdlFªU¤Ö«pÕ2ãõéídáUæ{S5WS¬àV¼ÑØx2õþQ!…2GáÙ ‘æT{ïK“»Âr+rȘFÍ(¦+uÙ2ŒZê'YQh±.±¨S¬‚ù07|-§ÃãJ“rÈ3‰àñȽ0>âêLó ×\F¨ŽÊlcŽà”ÑÛZ«xXÑØšG ×·g7¼h;1ª/\£ËQRb›:Mit®Œ¶äj}é¥Ö|½ö¨DìU¹šdÃýœ©^Ô¢†Ÿ^p=€r0‚ÝV ;;U&1¨ Â¥ÔxVÄ#!' ïÄÂ!ú@Î -÷k5¹æ„MK€:;¶ÆjÆßg˜OÏŒ-EÅ¢Bs`øO*œñ¬J§&&°>ë„&÷tBR)S&ÙÉ›1ö”À¦ûs)ÏQápцEØá’”é|‹%•vÞáÖ±’tz¤á˜oUÔÊ2 sì«¡=x“TvÛ§‚v`};h¶)´o=~³z¬È5–1ŽHT®S ¦÷òb«bÓ(89nWàjV‹ö~¦èÃgŠEûX®Õoïc¸[ƒ#'ê•~KvlŸ×Oß²oJqÛ8É”“(Áóî¨%BŽG,çÍõL>ç²ÒÞ¦†ß¦Õô -‘þ\µbE’ÚGéCµég*Gí'µÄIÈ,üÝKl>ò%€h†ñ •FwY¨ôå˜$;OB¾µ1<0ì`Ò2'ùÆÛ‹QQ±%Ͱ±Dư˜ÛšÕ4»Ò÷ÑûKGÀVTëW²V¢Bu¥—Æk.J„é™_¹R!b.±&!±Bì¶Ìïñ°ÎY×Xþïݶ}_à {|nè2 ƒEp¦'v ª¤ #¤Ç4I³É²yóªY‚t,4 ¥óæáéú|TÝÄ‘µšwÀ“(÷¶„<©4†d1ØX[å6Ç{<ÐeÞ£ÍÔ–€Wò¬â”?±ØÀΕƽV3«ù%~·00aªk²3Мx_EþñÛ½ÖØf·}1i·sTŸ© ±×BÔV×ΞÞúÖi²8 Îgç0_„Á…½@Ñ×ãYµŠÊ‘…ÉU’üÆo6ììñ…m!¿ $ÎÃy0›Ú®nÎiû›eïûÞß%ólöendstream endobj 5280 0 obj<>/XObject<<>>>>>>endobj 5281 0 obj<>stream xVßOã8~ï_1êîž‚–†6…‚x¸+pâa%NTZ­”7qZ/‰³Jµâþö›q’6I[(UEÏx~|ß7þ·7‚!þ`<¡o”õþšõ†þ7?z'wC¸ðÇ0K ÂäÛÈŸLÎa»]C˜EÀ³1n¿+i—¡'¤ ®Žf¿zCŒpOÜØsÃÖ{w¼¶ ŒÕEdáÏÈ %áwיж`iu°Êø”¥éœEO¡7½a–Ã1þî ¢²û¯ôz»[|ßoVÆurw ”I¬Â WUð˜Œ!æQÊ4²£r•½/ g¶ÀõÐëÇBóÈ*ÝÊ]µ;¥Á.w¬Ë»›ñ cŽaÅa¥Š4†%{æ`†Éű ‚ai2¦Í«"ät‘rCµ#¤îÔªfÝÃr¦YÆ-×>Ì0@»ÎyÆrô¼†T©'HÅ®.…¹¬ýn2g‘ª9K//+øÝKû`5”b³£RÐE©+(m~Ä;x³z½Ç3@;°º]e(m-%°¾ Vv¿¯“’”H£`¡ˆ Ã%[`Éë¶0­ Ô9R)þ"Œ¥–MAó„k.#~ ¿ cËæ)ùÌ¥ ÕD ¡*hT¡¢­l©·Çzcw˜iïY"Ö{vûx´cóÚYi?W;È TU“óH v3k¹tƒ¥ªžñL! ʾdø„1ÇIPjî1Ø8kµ˜–7ÂNî¾é{‚S~LHŠƒ¡áã…–[ÚÅ%SqBààV€ªo)G_n(©mÐäéÔ?uCã˜"Ï•¶ÆÅ(•‹X%]°Z"NækV) nX¹9“0ç˜x*0':¥¡‚ë Z"RîÃ=å ¹2FÌS|‹EÁ èÔºänŒ•paúõku’óÈ6M?U뛪uU%2.ÄLÅ"\w²÷êèÃTI#b”,Ö8ޤkW©n_°›ñwë¶’ÞÛ UVª6í@^ÌS9 ŠÉÂ6oDÃ~#?]•FWÐFâ;7šâ ;ÄŠÔ¬©å[…oæ—VÕÞdq ]ý¼Ûʨ«Ý;ÞviLšy֨†üÛî\èšéwÑP·ÌRà¼Bv ?îÿF|–^›—åw 6°Uä`öóáúͲU÷¢ºNŽ.Ný³ñL&^^¬Èn0ö‡p£¢‚T)Ì©Ü=8/ïß$þÙpâÔÔŽñðœ\ßÎzÿôþNë”endstream endobj 5282 0 obj<>/XObject<<>>>>/Annots 2114 0 R>>endobj 5283 0 obj<>stream x½W]oÛF|ׯX¸0À M‘²,»èCëĶHkA¿œÈ“Ä€¼SïHËBÿÞÙ;Ri;n›¢° HÔÝ~ÌîάÿŒ(Â߈’ ¿Òr…žðÛˆß~7ˆÇqxAI4 'TR|~¾ûVÐíàð{IÉè,7gùןfU³¤Óë1"š-àyr™sˆið«®$U+Qá ¶kIµ•åÖ=°k™æ¢ TTéŠDQø#¯fŸ§×ÙY n?ܼ›}|ÿÖ?n!Ý,(W¶’"£3ìŒ.tQèM®–ÎX)ÖTiÒ÷Ò˜<ã`à{¡ }ªmÅ#Žbp„=Ïo*©²_dÏ3¥…°ö²=< Î>†¥8“ß²à˜“…ó» µîx©³|‘Kcï^Qk—ŽÖõ¼ÈSZ S9 ØðQ×ÝÐNÂÉäœ ÏæÕw´6úa롹Lu)-‰®¯ø”ç}`—´,ô\——·[ \†7or»ÖVÌ IŸ9@Æ‹…aØ{ÒÏUEï‘Úè.@ÖýkO]üÒ1ä¾íû«‡ÄG]£s]‘^Pªkc%exIBiüb&ü3×·ƒ3ÉÂÊ ŽÈ×òA”ëBþo°õ@ŠŸÉȪ6Šâï;Ðý¨„ÊO¹ÎQ=Æa?#©Î^Èx׬²¤HÉÍ®K8ànTWZY]ÈðƒÉ+ùs®ä]pĘ.ésôåè„ÐI»†ø»—ãÞeTsùÙæÈd‰X*#*Ç-¹Qª *eµÒ™EŸ›£e¨V¥Pb šbphØg…]\}:.£—¯ºð{WCš­ËìØh_¡¦-™3Ñ좨¤QÈê¾ 0'Nd'ÐqÇ\ì¥T8 ŸÒp{z}AL~LÝÃxÂÓGá4M¾Î§I—¹ú|zü”ö$ÞÏU·Ql2íf2^›¨=P-šôßêï·AAÔCöå¼å/çgíbã˜gJ¨LšbëæŽ÷EÞÕ¤ªKû¨ÃZŽúî€c^9„ïÔú)KL—|š P¥„-ÖˆMn‹¦+¡–^"û·1«<§b"o'<Šrd;â~bFR;þÔ¡Z4sÒ5gèwÂ:¢ÚÑðjw/ŠZ6›¥ämR€T9ð^J¦ÒZa¶mö@¥Q|ãë‡pÚ,Öq4Ï’3šLÇá”ÉšG}˜„½Ñi]Jh$“/_B©üÙá¹_úþ½LœE“0‰!8pˆÿBØúÛÙà·Á_œfÇUendstream endobj 5284 0 obj<>/XObject<<>>>>>>endobj 5285 0 obj<>stream x}RÁnÛ0 ½û+ HE•­Äu;ôRlÝv0ÌÃ.½(2ãheO¶ÛEÿ}TœM Ô6l’â#ùý7I!ùN¡òø˜&¹.)$ÿ¿B³›%R‰rùùÕþœ 37mÓYG¸Ón¤÷[k¶Ð0´-œu´°±¬gCûøøJœbûèÓƒn:G—§åŸäìF¢*¶Ê$Y&”b¯šÏ†]Gînç¦_ëžnOqmëïc³¦Ðãdä¢'±ƒâ¤ °ÞYO˜=…òcóûˆµ­¯äC!§ëCôk xúx„œ=M>K±Ø¨DžŸÇ~å–P“§ ª¦&÷Ö9 [ò{V!&Ø»èùŠ‚ÛY_#²b *<ËhÚÈ n÷¾ݸvÖ¼ár‰(^SfB¸Â ŠGÄp |<-{O‹¥X©Ò%ogÚÈÏßß¾,”øÔš±!?èÁ¶>ae¦ìÅù´‹LŠBøõŠ÷¦ {}­d.TÆ?k©äE }.“É?ßÇ¿ endstream endobj 5286 0 obj<>/XObject<<>>>>/Annots 2135 0 R>>endobj 5287 0 obj<>stream x½XmÛÆþ~¿b¾Uà¤HŠÒ/|ŽÑ¼úÔŒµ:1Gr¾œ|ùõyf–K®ä¸¾6v‘à¬Ñpggžyæ…úõ* ÿ´Høÿ¼ºò=ßðŸ€ÿ¼yuµH<Ÿ’8ñTQºÂ?F(éîj².ŠDø‰ +]¹¢`y±«udha#uµŽ m¼ðV®Ö‘¡]¦ÞÒѧ¡ë”HŽSVkœ˜´Ž<:5iSöl{!%“Ö‘qHÁåQkP }q*^z%"°OŽˆƒ~ĘŽJŸÑD|§H&šIÆQBvF­W&s¿„]#ñQ£L‡ÔR‹$vvÃô\ëÈÐ&+ø45†ñ—ùC"M·&† `ÂÄ"±R0Š#jêƒ.F˜tx‚­&)È‹0 M(+&R,ë‘ Ï”® íbMG]™Ã䈭#C»Çk]¹¢0HA†é¬+C 8WëÈÐ& i´ìÊЦ‹³³üÀr_R.c1PÀj#ŸNZGF@©4i™JªQk®õ‡´ú‚£HæÚIf”WœØIëÈŒò’š´ŽŒk¥6&­+C Œ@Äñ¬+C» δB¶(5d[.ŽØc£[:d‹D`„%¶åÅH¬‘L¨“Œ`¢%è6iÙØ$'•+Eà“ŽˆƒaÀG¥+3‚LGëÈŒ` |­#3‚)P˜´&dÞkÂGE’he+Ã0FŽNZG†Ùgå¬#ãZaÊtÖ•¡E_u-»2´qŠÆåœudhÑü]-šQ„ëVøN‰‹A2é™dh#nàæYÖ~µq¦ŸŒÀæžnnWˆ V6{ Ê$ ½eH›ŒHŸ6ù, èî§×¯(«w´>ùƒª¿ØüâX’9*–"8Äv0içaìEqK³UUQgM¡Z>Êê€/™½é뺨ïÍEMkªôN›Ÿ ÒÁþ<À— ¸ oÃØ§óï;džÿÐ¥/^ü‰kçhªþ)6Î$Ë:óq àüÑÒ+U«&ë -¸Nà|—´{ZëúQÕ¬ðŽéàþ‰€ùVïúÒ¤hº@>}Ê[OÛeu× £þ VdÛÏëm_çÿ _¾ËÕñO\4Ð)¸ý\:IÍÎ6Eý´þæû»órø£ 2ÿË+LÅ~SÔÙ½”èÄÔ»ôÍiË5þDº¡ö5jGe±mø›‡ fåº:¥¢®¨>w™ÕåŽ (7M‹Ô»NÕ-êhðkèFŸ‘ê {PõeW¶4R´8.3:ÝžŸ²?êy[L3y>—-QÊÍgótTUv|FWùŸÙòƒ.êN5]ÿUÖlÁ!¡,•TåÇ û¢7Ä|~ô¦Uÿ£nûãQ7ˆ¹WY×7H ϸ‡ZŸj:6]©ºðÜfkT›$c‘*óëË¿áår~ʨnnípc{^Ù²9-ž2íT›7Åq0ÏþÚÒ!é=­¿~½þûËï<ûp.£»ü *5ïô|mKÅkpâê¶ãÓÝAQ™Õ÷ýPú¾àr-®ß5ÐÄÇóüÍm2Lì½QE«vÿŠñ‰a'àd®7OÚðf½Æl¨2˜Éºñôg¦AÓ8 ƒ?ϽÇäñÞLO<ÂVy”`‹È‡-‹‚is'câ°u^ö ä}ÛéªøMÎ _ž|Ïh ¼4À=­¥Nã6ÓæÐN 2j‹Š«ýV7ª¸¯ÉÎzÍŰÏrg4½¸4=$ ¥}_–ÔeE9oTÞn1E÷EÓvó¼ÌZ$_c7¨{Ù„­£ÝÈØ‡#V?TÍö !SÒ2d¶A5Ú8ž®GŽô-MyV>™æ…€-âãc§&;ùÉ=Z?Se4å1†#æ_ë“B‰\Ë3ÊJÊvØ@ª–YÖ·Ì9é‘âÙÀYÉ}ÑIp7·ñÈ(Ën¾uýâÅh>'½ýýe®±xJ¼L &þ®Øï‹M™óÇÞŸ¹¹}¢£Ìû¨©¶%ß¼ïD‡&ºõ„7Ô(P§Åeã:7ÕíìšT˺‹Ïf¥Æö9¨¨uùÈ0´]Óç¦+!>ɵjOÙØ#¼ÈÆÎí@vO¼RôÞ®=Ý4àý1•Öo㲞²áv &SŽp€ŠdØ–x /ùæ{^è9e5µºRˆ:GXHæ®ÍGªÂ wM'Lß§ð c]—Oh¢‚ ‹*k ¬sÂ{ÝW[S’.îÁ"î|è 5ïê×àÂ}¼^®.áÑF QñÃF`oUwR( ü"àŸ¹ÉIgS×Ô*î?êËýì¹#mC2ñh«J}²õaZÙϺGß{¢j‚ƒ(µ~à¥)«±T™&¬ÞeÜZ8[ôrø|3„s^#ÆÆe+q›µXÌÚN¥W5=š.¿Ì O|Âë¿ÿq³ÀjÀ\›>üzvI+a ð½¼@ŠHÞ®®{†pnáײ(>øÄ¿TÀ‰½ÀO H»Ù_¨=÷Ó™¯8Ïî\Ná§"¬@¼ÚhÊJà+)Ú#Úejj: ê¾ç³xÈà° Ž'9y£1#ñ¾rMÇŒç–É„µ*í„a?#Žåð~xí@-Ë–ÞÎŒÛøñÛ÷žfC8ÿfk^~ÓìíÒ!äV\cmš©ùA[^›Wïù¼aÃp^ša…Ùwæø–×2ÙÑ¥ ¬‡¦ü¤{,O R…½Âz2<Ùpém5¶Ù=v{30\;†–(xÓà™U¦`Æd#5us;b’·—@|Œ"–P–@€æºïŽ}7g—H[Í`yü!iƒßÚÃ80´7ÕÁe¿ž~êˆñ»ÿ"4‹Ä"ñrsõãÕïÃG9Áendstream endobj 5288 0 obj<>/XObject<<>>>>>>endobj 5289 0 obj<>stream x•WmoÛ6þž_qÈLA-Õ’Ç]±«×dÁÐì%Þ† †¢bµéŠRcØßIɢܤ)ŽLÞëó¼a—{u FFú— µPŽØ=+ÖäÐpÞ*#0rçU±È(…¼@4 ™QZÛñ|è<ÌS`QåŒ ƒ!G5¯í]Ïx§²%ß7ßk4© ù'Úž›óÌØa5”´G¶ ¶l§ ƒ8Q´ÉÙïkÆ©ÃÜpÌ¡wp4÷ƒ¾žTB7 #oŸnTUëaÅ–«8,ƒF8¥M©CËÓ婟xÁUNª™©jì 2Ò`G´õ@ÞüztÓáÛ|`Ã4­B©LlvâÒÞ@>}š¸ÆNL¢51O2Î…3ãÚbgÙõã ¼øt‹á¤ÝŽz¥^<¬T7Ý,ÅM¬|’9)ɤ‘8’ž þv2ø8“öçIh±ªn ™¢LîZŽå´<¡~èºj8bÀ‘ÛçµaØ~Üsí»Lä²ñÝûùo×7‹Ÿ®1D‘K¦WH×8”¿pd91!dÐsÏ\?>a0yÜ ±70–>i,}ܘM ÿöšXKðßkŸ]ªkŒ¶O'KW8Âpaã Ñc'N›²6N¸4xÄ.å•*Í ¡UÓIùš„—A!Ÿ½pó5RÅ ¶ç˜èÚÐbﱓ…Jâ¶ÁñZ ”|z}° 5úMjØ¡Ò,"].{3yƒù,Àp'ÉXZ¸ Ö {8&H”»íô}¼_»{ò‰×¥´ Ê]Ø^…$œ”g°B‘:¶^|³Xèž¹CK®šv-uä$G6•XǶ C;>°ƒ01[0ÛlÖ…›ÿÈÙ¶q´õeÙÔFÉÚäP‘ÆØ+â¶U\šƒýŽ›åÅëx·HùïaU‘ù0µò‰ V; í»ÀÞÿ‚ÞK8Ãw"+ÎûÁÓ›8 >ÒÛæR3«6¶Äí|MÆ“è,=ƒéùÌ­Œ¤èaágÅ›w-³âÑ-\ÁíáðœÞSÝ{^|øž×½å§QšX=J㘌¼]ýqô?÷Õ!endstream endobj 5290 0 obj<>/XObject<<>>>>/Annots 2141 0 R>>endobj 5291 0 obj<>stream x…XmoÛ6þž_q PLÙlÕïq¶u@æ&]°6ífwÃ-Ñ6W‰ôD)Ž;ì¿ï9RR$§ëÐ" Eò^ž»{îØ¿NúÔß> 'ü7JOza_øGŸüòêd0‡CšL/Â¥4˜\„ƒr•Ðü¤¹Æîtö›»uJÃ^/¼hì6ר^„£æncÝóIëîh4…£‹~¦4šNÃórÅVÁ|ë¹=˜_-x«±LiÌ®ùƒ¼×X¦Ôïµ/Ž&ç°`4ðRǽ¬õ+¾úâÃ/ÛÐóëÄÐb Œ'ø%vÐâ—(ˆL,élñçÉók`íËÀÊü zóûìíí|qy»èÓ2h¬–gË3¥’„4—^ÎQä >¸–"/2iIè˜ò­¤gkÿ…b•É(W÷’Å=Þ¬ hm2RzmÈhÚš=å†Än—XŒ»CÝþ•ÈÐvAü™î&¼?臌Ôu¡¡ÏhÛ¶Ÿ°ƒ3ZWg(–Q"2Ãg÷ü·›Wø=—ÙZD’Ö*‘´WIB[q/)2œÜ+½¡Ù7³Ÿ®nime*i—™HÆŒBH×pJ>ˆt—ÈŽ“;k¹Ré§S¨"ûW–/ƒØ+({Xž}{êU®$‰{¡Áß Ë*ÚRpK?VÈ¢Áp„ŒúD//Ü·q (“¥¦{‘¥ï›*|U(fwóÙWo®îÞß¾¼º¾¹½zI±ÇU[$¹ ÛѾ¬Ñ¦T*é©É$¼a—¥®Õ¡á¥·ªNØ·ïïÞ/ŽMµ;©µ’²×";_«Õóh«¢R?Ï;™Š Õò,¤ÅVjT½‡ºpIS}†¥0^!dÞ[ZsdÉ2pÈØ'ð’Zs|à—²ÔöÏã#áqŽí°ÒFwþ 7׎$RØÜA#²)r¶¡6s'2‘J¤h‡f‚þGJ¾GE9)Tß„õ“–rKâ4qêE‘´ íU¾mcP[² "‘$]>ÑýT>[­cºzˆäîóåŠÐ‘+Ë2²À6.¤-RλAÆ3‰ÈZ|ÈÌ^Ó:3)ͤÙ×_£xÁƒ`ø‰b³E 4YW»Ÿå¶ÚÄVºqÂ%ÉÎÓ³Z¹;T·¶6͹¤`®ËRÁ>“X!¶%±¬ZŠ­ø¨MEíÊšùL¯@°´20ñ;®rFï®–½ ˜t~jäY´}•ÚÍ'rº¦B ½— B.ôÿH§gÁØ×˜-ƒÙÝÞd1—ÔSé5rü\ÐŽPpTÚ*·•Ú Z%&ú`Ëôªx¢Î̶ËÞÞº•y"púP>‰bþeõÆ•±O—eÀîj×62[žÕ .Eqˆ éÝß±%_–’õc<[©ã©¼!:2’}à¸ívh0o]i"s]Ú¡(Á•Oø½n ÑSŠòyÎ@V¹“ ]ˆ„{o2ßÄÅu»ýüú—°e{·Îò*?=ΕF emµI³¢åúxër@HæÏ'>!.±âZéFÂÊ'è0ÕLR¨ëHäÀ ÁzÔÖÖíúxdÒöXÁÁTwdÒ´ýT/[Sy;pSÅ~®M’˜='‘UÜûKªªdN1bb Kƒp8Ä cMIgµÕw¹´áã(QTƒìÿÛáŽvå>“g~>~çRÎW6úÇÖÂr”:–;`¹8Ê‹Ä`c—^¼ ~užúãoþÓÒøÌ-‡Í®seN&çlgdŠ©))+t«m|Òñeð$aº{PQK'±lì‹r·?öáh¹³ vÓÚéŒG´(ÿâ^ÉaIå©Å6“{²È…|ë('AížzÕìÛÆ »¾®W•˜AÝL¹F@9¨Ó°ç‘À,Šà*}˜½~;g31ãs£p:eÀ8gD‘oÁ~`ê|‡^erƒo?©è£H$Æ…XÚ(S+ ØÕ!ðð7tÊ+b\¢ ]î¥Rç¾Ë@´ ?>ÈLËD}”ñ—.n¬æÛ îb‚€‡0«? ³¹‰Lâç„#‘Ð&ï1'ø4gîö“C•÷Τµ)0Í ÉþÁ~^¢M{šl©ó¨ñ]©±ó%:Ú¸Àà6Æ!…¨é¸¶Ö@‚|Å$…›Æ1"œˆ:*œ}÷4›¨¨‘OKÕ¾b/“Ô€ú1ÁÐÆ˜¸BoeÌ[#^½IÀ2 t¼ðÔ2SQcògª¡b.ò`vM¦`xÊï-ìÁæ2 é}üÆÐQŽ Óòm=èÂñpL“É$ì¹*gT»CüßÀËf2²` ¸{î™Ù½a‡4ã±LT9üki°ÃwÜ›„Ã^½ ¡oÄW‹“ŸOþzÏ:3endstream endobj 5292 0 obj<>/XObject<<>>>>>>endobj 5293 0 obj<>stream x­XaoÛ6ýž_qÔ"ű7í·¶k¶bÝÖ!ŠZZ¢m6é‰Rÿû½;R²­¸MW-ZÙ"ywïÞ½;úߣ3âÏ'ü7+^Ý Ó!¾ìþ©tzuNgCº™cíä9ry‡lð¾2¥©Í&¿)g®ð¤lNóÆfµqÖÓtP/5[ëj®2MõRÕ´vM‘ÓLÓªÒ^ã]NfNɪr÷Z+OÖÕ´RÞë|ú”T¥iiò\[9Û:*œ]èêéÍç£!%g#84PY¦½7³B§ôv3š’Æb›^uf®,Ù»ÂXSM Ûd|4Eµ£ëo9áÝVŽØîm£[›¢`ÏÕ2…‚¹š5õž+ZeKj×!¹¹G€³œèëÊØw'¿8Ž›GçÇ ×÷+W1(Á(YUjO™²l8s¶®\QàõÚÔËiV8, DIãuV¿ö»«lúowØ $€¡ïtµ¡R—3]u‰íâ[h«+ÅÎvÞˆeqšJÅIÛ´ì8[nJ—¿8œ‹®tyéÚí1Àƒ©ã¯#pBÉŽwÆ,¬«tž²3§WÏéìJÇc|Ê?‘_s!ÆÂDÿQ̳ԴørËÇ*¶Üu¯}V¶Ï™˜iÖ}\Wj…µöõGŸUfU§¼:qíŠÞÉéi´0lãMÄÏq:™·ŽÅ a:`çž-Êø$Ú§ã-vÇúE#|d b/ÐX‹(w(}¾cX TY4õa·v¸ =Œ@z#‡!TÇæª?yïE’yÑÐ~ÕIò@—Ñ+VoŒ­×Úz¨d8LÛRÛ’e%—¡4t›ûò…½·| Ù$\Xƒ0¢}¬]u‹Y7\›ZØ‘ÂÃ=)D L¾@Ùàô~ðúê ü<@Oî‰l©GR0áC'MÍÞö»(‚Ù_d…3ÌíQs aÒ¶c/|J^†i ©ý>/XObject<<>>>>>>endobj 5295 0 obj<>stream x¥XaÛ¸ý¾¿bphP§°µk{³·ù˜l“6¸à®EÈ—Z¢m&’èˆÔz¢ÿýÞ IÙ’¼w)Š#Qä›™7oføýbNWø3§å ÿÍ«‹·÷WÙvÿ4º|Mó+º_cíÍkü(ä=~ä“7µõ[Ý*½njåÍ£&ãÈ[jÚš>}þðªmS©²<ª Ê­¼&E.ßêJÓÚ”šüVyÊmí•©½¼ÿzqù°äÈÉäÐy©M“Öi^/ÒkªlQ«J¿zùð2ÀÖüüŠfó,™ä¶Úu©ëÈmqjA¥Y5ª|G{]–½· é'UíJ=% 6› ‡ÀìKiU‘¹¼Bღ òm¶dç.€i±È–Kü¯™Ív΢UŒžãpvÕ"­:Æm&{/³››Ÿù«Ï[“oioÛ²`à5­4Ü/~(hoüö‘ý…ÜÞlh–c—oø˜e&9U`Y²-É]N3÷Èßw~ ›ÁaücÁž“'_öÚe¹<<ù=ÿb„ô<þžY^–9Û÷ùÀ÷l6M?yÚº‹s®Ä!:DŸÝ1ŒìäÑß[JþGˆ–Ѧ ñFNkB~€(ɧ‘Ö§V÷‘NŽ©Às+ôR>yXh»ÑÞ»Î[Ï “5صEB!|@)K؉²OaµKoi…Ô÷JfàÓÅù4|éu¾­Í÷Vö­l#¹Ö%rrÝ–ÂÁ¶´Wµçü¡V¦æT_ë}P‚€8Ã,Þ% ‚0%ív:7¢fÍ(a—#–F—‚V‡¾K;D/ÀÛˆ¿Ž)ÀÉuÍäÿP“FL¡Y•ö[[°‘A‡ [,D|F— ωA.É£Jg9yv*ÿ¦6À$Ëv½ÙdtVæ‘ÀàCŸ±‡#óÌG¬#§°E]Ù5ÁálŠó¬»ªdó¯ÂB‘=ÕpEŸ ˜óð6†ÿ'°-Ñ: „“X@ðmaœoÌJ¨ÈG€‚AÕœŠX>"ÙE9Täó»ó²ÈëOÈŽGß“wAnÝedÌ%Î:°@BæÞB©MHm9ÎÙ¶É_h6Ç%ì½jMYÀ´½åx¹©P²u¦Þ„µi\?éaÄ‹ìÍãR§Q½ŠH(1èòýkâÃ5s¶¸aâ-æÙ5”þ£©¿ñU[zƒÒO ‘›{Sî>þö©o¡08§=¼…•Óf)Q„ÉRÀÈv^x B}†Ðq¼|6q&/;–+û~Ë¥RX6l0Û5ö)¦å±î"â#Õ`z•&çDÔõ0øÌÿP=Žé<¡ä£v‹c5:Y,9H1@,{?S AðØ’4z ¯sÎ5KîP­lé(ö%œõý];%0ãݧB!Ïy¥†Æþ@»3ïŸ6×û îÃUÇ¢Þt-£.5OUë<çº~bm 2Á‰êíŽìù Ïè­°£sP¡× Ô†ò! 7Û¶F7 çÔC#"Cé'`æ®/3?äG¶ulEoæ#ÜK~ÀË?ØT¦Á0:³¸oaifñû÷¶ùæð€5£†`s>sTJ®Ê'm×9å›Õð†3ô²Í¦­4*-ÝÛ§«@£¾&5vÊйДֶ.¸G¶¯…ì(ìàhWPçß`݉ˆÀ,.âºiRÿ«ZoYbrÚèZ7AlÆÜú^œqŽÃ¨b;å:=PŽÉKëŽ#Á‘¢—°3WØ%Rp:‹ð`Oøb¬4Y,“ÜcAßa®ÔÃáÇ/PÒtã& kÉ0O/éÅèÅÃ1G€GÑpÕ‡4 q‡Ýf“n¶@WÒ}Âí[8 I˜Ø—<ŽGÒ4Ë|!*ƒ²;62¦ûPBçZÞó4 ½ÓšÛrKг!jèD¿…Æ`3pQÌœI4&v Ù+ó#¹»åøÅ™Lôƒ{‹‘2š›ŸP$ðÁ9›:"öÿ¿SæÃUãU¥†YHä³ÀiKÉPlë)ºážI ÿä8yô óÂÉ:öb\²÷rr¾—ÃÈ žØÄ€Þ ¼’Gj…Ç ƒêoëŒî⬌pÈëäé4á# Ñ6t~! iŒï²ðl–„µGÃÒsìW¹çUAúñ`V½70$P„´BÌ‚wrÛpËÿ•5”eÙ%Ãј‡âÍ7¡Ã‘v„¡aJ_¹Î¦µÃ¬ À»iyà¶“Ë”¾óG×üº‹ÈyÌèòzA>vµ×܃†¾ö6´£èl_Ñ=ÚÌJíâýLŠ%NY\g··Ü3ÿ<¨nA}™ëø0làèÑ(ùÅ[E8í]!~ðcAëÆVCï|4«n>àÍd ¹˜8i9ÙúÞéqú}œ32·Îâˆú—…*£}éGçÔ|´ «‚ÕÓPb¸–ÑÝ??ÜýòîWòjÃe\_¼<âBÖØJÈ÷Séô³WfßྭÄÐí…^Ñ£5ý-£ÏHÜ"nÃÒŽÂ{9*Aáºb4ãÈ`ÀlÚÜ· ºO˜¤8¡Ñ¦ÞAð`5tIô =0\Ÿg±s€áɾúÙq7(ÙºU¤ÑD£¼Ç±øÐŒ´‘õ¥Æex×írLîB#Jš²Š$Þ|5€À4âæa6V9¾—ʃ“x_»ú ©ˆ¶MO“oÒuò |:ˆ )ÖŠgQÚ#nã=æâê:{µ|E7·‹ìµŒ‹âŽevE·¹´zÒO1V\e…ųŸÃ- L– zËó,WÅç®UL¸=}uu“-L‘“Ëù5oùîþâ߿ɀ»uendstream endobj 5296 0 obj<>/XObject<<>>>>/Annots 2145 0 R>>endobj 5297 0 obj<>stream x­XïoÛFýî¿b¾ S™Ñ[–sé95Îw°ÓZE€ƒ&WŠËî’V}‡ûßûfv—i§ ‡H.wfÞ̼yË_OF4Ä¿M¦ü—îN†ñwø¿ÿ÷ó‡“ÉpOèb8§´£Éä<¾òWÝŸ_ãéåU<:~zt§WÓxxüôèzGçç³îÓñ®Ï/fÎîå0¾ôWb÷èïÇXåÖÊÓÙ«Ç—x¾ƒÅóxæ¯øéßGaJ¬fC¯¯Ïi4¤ÅxL¯ð#ð#šR]ÚÚ4iM ݧ[µS¤>+\¯Þáæœ*—µ2ª·Šö&©*eð^¦(MŠÂÊíuS¦u®K:]|>y} ”ÅdtÿéæÃêVí?º=î>/£GgôªªÍ€él4†W‘Ýç›UýT©U^®5½âŸ‚iÒûR™å©Û:D hZÃõ6©½CêCo'Ú5¶¦mò¨ïcbòä¡P”©´HŒÊº»µîÎW{mÇ—î­l•¤Š~ ù ètÍW÷7ÿzw½>ÞÝÜ.Þÿ¼<ýKßôMM¹%ý…jäïþ9€ývÚ(¾×z$JÒe ô>s`»ä‹"ÛEǾnKªÔÍfKÎùµ6Äp–S£’Ze!õ6öÆçœ)”ÍFÕ²Ð×Ueê$£‡'.›¿ßÌÿñþ–êd³9lôM5ä %Ô†%@Îuù¨Lý±6 ±dÀÈUÔ+xÐõ€¾^Ië"ÙØ*©J¬ÍË üÕºƒiB¾KÚ@y9C¥~«Ð-‡‰ë6&±Ä©U9Vú·2š€ðq9¬~¼¹¿ûtKËÈ*EªÐûå©@ýúúЏ+¸iÏÆS}<Чà ‰yH6È. ØEË9¸B[ðúóXÒt³¥{Äâ0á)J­‹ñ mÚÝ5âHFƒþkÆî¿±ÏQLI–Ôu^&EØ4ƒÆÑ~›§[’eRùxÀ{´ ϔèá/S…ªíT½ÕiŽ ïÀ^`Ë£ÕI™…å,¡•©ÔTèr?5m8k\õUಎþ˜ÙºÌ”ƒ"U’Iîˆ7OáùU¢³JÎ…¯Ó vÉë&á¼X¨`”3.ÇL —G K€jTݘÒÕž "kìV7:© Ȧ›{• Üæé¦Ö;f(ŸÈúþ ÅtÍhJE/Ð?œ’^E|Wª½ý¼f¹áÂY mö|´è†|{d[ÀBe-8¶h”¥6JzYL÷h )‡îàÆD‹0Ex@Ilv›W’“®Ã‡qæ`$©~F–öDËñôÒ¹ –ø™?~`+¿ƒ«p¼­áL‘Ïi]êm½yó(ÿWK TÏ"/Ÿæÿ¼»ç)+F5ê¯Ð Wy‹÷!½RZ©6/F<ÔE éÂÝ#9y>'¿[;P—Qªw8 Ô™Z'PȨ#/‚4ßò÷7EÔéÙx†SóA¡2žmh!ˆí0÷šÉ·½ýq5vmòq¬^Ëþ+ÐÒ¿¢°¸„‘îСWcš|¨I¨]^ËHGJ!1ERI«æ©˜ ZèNâ8Ëp2/85Ý’–›Üa Ë×kè9´_ÙìÐ>à=Q;NÚÚ77 ³Ñ¨^ï)DütkKa ܇B¦]¢åŠì´™M0^¶ ¡Äú2êÈ‹Ëg^ªÜÔ[œ5»n»:š¿>5±w¦—Ç!ñ7[ÆœÉq<™à*‹p¶ÒSÓþ+'`FXz’÷k­—ÿH²æÕƒ?'eÕ³Sô™X›ÄSô7¬ !¯YƒIz4ÑþÐÅe„æÈKuæËnA¡W†ô¶ÖÕ_—§îrDo .å†ÛtâŽä$S®@–È!=Û¿Í÷Ú¿ÅþÿÃàH{¨ý"LÒ”UR㔵ÅìRlGÖ?$ôœ~v°v%#sÁ_G¸TÖ¹Á ]º9Í`þ:úhä°ŸÐú+†Ü&e€P> )c´ñôØŒOd“ š^àŒ n—³ ¾Àý¨S™¦B¼q‹Ï.]qò‘›>º/W2…øcádì¦ÉdtÁ/½_œütò;/SMvendstream endobj 5298 0 obj<>/XObject<<>>>>>>endobj 5299 0 obj<>stream xuSKOÜ0¾çWÌq‘H6ÙeÚCKKU ‰VDê…‹×™lÜ:v°ÿ¾ŸóBKUíCŽ=3ù^~J Êñ)h»_Ù&ŸË$Ïrl.îHëÛ *r*kÔ¨†s,äªlØ1 üBã˜É[Ýe§`±¥|F(!^ù@jØî»£:b“qvÓ(ù‡ =³óÑ=Ý‹ò|>”ÕJóYù;Yßñ„&-6@³ºS‡µÛ×A™W©­OÛ^•Ù°S2ëDÍØ>“Y‘2Ãä‡_ß¿xï$“´&ø‚†Çøhž›y٢ѫH å4á(²ë M@æ )ªŠ|ßuÖAƒoîŽFœÂû–M  0t{„¸l„ñ"IJîWãI¯Ç3¬|¤¶àpüÔ+Ç~Á‚w˜z¥ S‘ì}°‘ ´&[ϵ}2$t`gDPÏRŒfœ´Ë÷Ùvƒ‹Œ!Ûb·¾–ÉÏä/±Mjendstream endobj 5300 0 obj<>/XObject<<>>>>/Annots 2173 0 R>>endobj 5301 0 obj<>stream x½Y[oÛØ~÷¯ ( `%š¤(J Š];^¤(ºi¢ÂuŽÉ#‰ É£ð"Eÿ¾ßÌáåÈI6Á.\Ø5ž¹~s!ýé* ?ÍcþMŠ+ßóq…?þx÷ËÕ<ö|б7§‚V /ꈜÞw¼(Þré-)‚yYÐzá…Ï! ækoí0­ÂyèB„†lLè[cæ¬Pæ­FB}ß[9L—7ð½…Ëuh6(ºìÒàB+y)&ù+1i³ŸB°I‰ƒáŠý˜. îB̸"vv†%ÄÓ‘ÄAx8L—7šCéxÔ¥Á]s$G®Uº²ù\-™'„(IDÀ t`º4¸ öÔá:tA!κ‚­R|²§A"3 ¡X«K³à9ð7ríÑØÂa=g“„Ø$Î}/v˜. î2`±ÃQ+6²) |a %94 æŒ/F®Cƒ/Ù›+Ð^àS’Ë–øŽ$êlÉ”™gÏ…]ùl¬#ac™È6¬‚y‰ô/xV&À3žb<×ñV!Û2ðä\´²ÁAbWd >çÐÇçFž5ZZßÍ…âƒ.°¡Û.סÁ…îØå:4¸ë!w$;4°¸\—f.—öxÖšÛ°¯Wh ‘l±CBi¸f±Ó¥Á¹EŒ\+vÑÞgˆDBÙHŒ4Ž.–lÑÀµG#›´À„H({t¤Ù¦ùv¸Í‚%ÃY›Ut¨ ‘,WPdI sÎæ<‡d•¿i…6åB°P‡,(^s¾žCB¨Ï3gdº4« /¹Í^Ælí Ø¥ÁEE ¥wÎ]kÏ‘,TCЃ‘d“æ@àÈtip£”Ž\LSš‡K‘:_ KuÈ‚ ßÞ(I(‚—#Ï!Qgkx1ò0€#Ø`õIáX‚er›ÆdZusÞ8ã_v€jG×wkôGX¶ÙbSˆÑ –!mRÙ|Ú$“0¤÷÷o~!U¦tûróÁ‘!+„È€E¸y‹¨Ð,D>1dLÞ”MeÒ6i2S^žµ°PŽÎ–H¾¥“‡0^Òåý_jâ»g›:¹1EÁÖåY©)+&QϬqs>èBj6’]îìxAžý…n©T…¦ÄUeõ¸Îi›÷Î/üï:oïïÔ& ¬™RVØ¿)ÿ¹ŒÞ×¢ý‡Tfå”LÛL)Í*4¦â ýw0žY}*ꬽV¹ÔÏo9Ùëä#ñ· èñCJcø ùIÜnTÓÿKë{x™©œŽ@²zÌ5*©Œà~tóGá5Ãøõ—´Š¾[äèaÒ¤È×ÒKþ´Õªi+Aöõ]ßo&?`Êïî+o+µ+Ôsj¸¥×Ÿ}àŒ>¯šÛ®NŸS˯Í^WÔ¥I­ñõçF—©N¥5Ö•hªÛÃÁT =L¸[\ßõ9Ÿ”·‡<øO ;ƒÉhŠ‘ìâQUêl{7^™Âˆl‡Bå;ìïÍ aÛ·¡Û«¨LUÅOU Í3µe[[¯¹œo:?ý|Ɯ٪6Ç;ño§K~tà®É‘ax\o°Åþ²újОȟÐ6W˜†Uí4v™ðúíÞ<N>vD•v¹îMÍêCž5˜ËŸeÙ¹¾ëßãÁþÿšßááÉËÃÞiÏCûªk,Ùß×›«]ý±jendstream endobj 5302 0 obj<>/XObject<<>>>>>>endobj 5303 0 obj<>stream xuWMoÛF½ûW Р‰–%[q‚ ‡Øu‘CQq‹`M.¥­I.»$-«¿¾ov–¤HÉL(Ü™™7o>øïÙ%-ðç’Vkþ›g_Îñ/û܆.î¯èrA ­?àWêð#‰¾ì)Õ™jófFß~|ýƒ6ºÔN5º¦fgéŽ ›¶¹®?R³Õçÿœ]ܯÃmUξîåeg" 3*U¡SÊͳfUªmëNé1ÒoÕ•NLf ùbÔ`Qy4¿\Âáè7ñcj,5N'yÑd]w‰PwEtZ3±E¡Jv°„s;Ó$ÛÇóí¶&ÙRbËF™²&•çÞ{)%¹ªk]Ï(kKXµ%~ê²-ê›ì}ÕMψ/?™)퀌Qî èÎ;±.qÌè©m¨n³Ì¼58¾üӜގlŒÕÂ+¼,£ÛÇóÉU}ìà ðU­õ­œy¨R®©É–ùžÚžúÀKº§§ý¨VÌfæ°¿¼âtͼD]妚1s4™€«§÷á’ é0å¢x/9$ÕxÍÃô"Hã(…Þ_Ÿ:RN“.LÓàÎÆ²= ˆÇ8²»²¯DQ7Z¥1=€Ó82x‡2‘p{ödNë/Águ£J Uïw¢jí£¿¸ï(;G¡ÞÏ+•<«¦OÕóæó8ƒÔaÃéàS_¼%|CLŒÀÎ1pÉzøœµÀ]LÇô}@ÙVœïím;‚*Qe¨å=¬ å6º¿¦‡N‚8ëΩªÒ.7OÕAŸvù›3ü 3bÚ´,¥{”I<Ór«|ÒíÅí»wˆÒ \íÑ{rkŸkÊÐ9Ú€Ød5aìcô«ô'ës‡# B7éWæ3=fÄ8Ùíœïœ*.u²B÷Ì€Bü²óÓGÈ1€< ¹¶l ¤#–™¸ˆ¦žUN£ItÉy)ýÃÇ^o‘îƒ €Aßg:0LeŠ×ªml÷pÎPóüžkÎ2}5ýõíñܳ·/Ý.ÆÂl¶ ißÝ¥ä5w¬ÍÉdLÚ¡˜m¦|±>µ2 Qrë Z£‹p3üÑn¹ù¡¶«)§kÌ.8ÄáqÿqáCDZH-“¸Žâ܇Šû@—W1:NF¾æ–7üŸ4Z.ã=ì+]¨ªX!‰A”aÞÎ—ëøæ¦‹/éöú4ÿŒzò¹dïdmËq><@r=ºC r‡V²§çÒî<˜Ü&Ñ aÉÌÈ4AÆòÜî8cÔp[ Ó ºá82Z²qÄ´ÂÿÒˆ’¡ÑÑÃAÈ«3–˜Á7ÅIy/.gcù¤~[>壩8Záñã¯Õ¦Â 8zDGSiY¬™éáè-¥‘©±Ò S~Àe*u‡§‹ãÔMM J?Sɉ’#Ï&BèRw4U~ÂèL…_b‘¦â~}·xßr“">>:RäF;}‚"Ž¦â¦¨,ÏþÑ€£©Æ“ELŸަ⨕›ÿÆ>‰xªëƵIcÝT©;™ J¦®ì1^F¿×it'lëâ¾ks_n×ñzý¾ïK)¬Y(&tÒ®†õü Cü‰ì», ¦¦'Ýì4Ïgô\™eabÍŽ_õãC¿",¾Æk ›ˆèÜõrÒo:Àü¾-9 º`Y¿ñvãí.lT`ÀtM'ßq¥áK#Cƒå¥ÎoˆèÖ©æí˜WrvYBÇk˾„à{¯{—dáÌÙÂ늱nˈ†>5àyìFÞ(ú°°ú‹ô° W^Ú#lüNÇ®r²ã÷k–x9që ¯ú=’±¸4Þt³K‡äòÂô0ä†ÑÕ3r7g„>.ú¯(n’ÃïÐà´Øù÷yÞ›à!&6ßAC* TåO!°m þ†ÏËŽ”~NóMb·õô‰Å¦Ö ^Þj¬LÇËFXßÌûd è°.„lÚBórÎIÍL}êN8Damȹ¦~)%é1šäüT-Ì?ý ·5âPùvþfc&ÚGyGÔnŒü%Ó%‡^TÞ¢ƒôzÊrG!:Ý´®Ÿ»¾HF‘Ž©—ó°¡÷…v*ºµ‹û›ðY¿\\Å׫kZß,ã+¿Jñê3_Å º³‰Ïÿ®äØÑMExþ^ö,2Kº=ü|ç2é®ëxµÄ¢†ÝeuyÃwüþpö÷Ùÿæe9Yendstream endobj 5304 0 obj<>/XObject<<>>>>/Annots 2182 0 R>>endobj 5305 0 obj<>stream x­X[oÛ6~ϯ °>¸hâø&ç‚¢Àš¬ÃÞº5Ã0 À@KtÌF5JŠã¿ïRÔÍYZlná˜"yx.ßùΡþ>™‹þÍÅrMÿãìd6á }Íéë·ŸOæÑÕôBDW³éZdb1›‡Q*¾œ¬VÑt&¢‹Kž]Eküu#žíŒ3±ºˆ¦—Y#¢5í ¹éÂxc;ÌÄå’„òBž›¯§W"š7G^†‘;²‡#y­“{9]†½Ñ|Fnv…“V‘“ÍÉd7¢YRwµrêbãÊhŠ5jæ°ýª3÷ñ®ãTö¬}çŸVb>w[x}… ;?âÉÝN‰·w_OÎ?!¼f’h«âÊX»‰fóDT‡Be²ºu©Q›üIÙJÒÊLUÊ–ô´‚TZì–éœÜŠF²ˆešndü(¶uWÚä§BW¥°ªªm.ždZ+BÇÏÄÙ|'…5±*éÔÍá%M] U¾Ÿ”J‰JÍþþíÔÍ^ IÞ8[¬Iöb1]Âʼn† „à»Q•5ƒ‘|’@ÁŒ;ç›Rl…W%T®¬$ëÀ#dä©0PÄî5`¥rŒ-ßšÙ:£”š ð÷-[¡¨/©A•¾1{0'[H£Áa[ËÎü_˜J!Ð7x—,ES~3þëë0é°¾› Í´ýÒêWBÊ,Ù"»ô¡)*ãbj«|?Ú‡:S9ê#ç ®«¾„ú~sûxc*íö¹Ž@Ö%…‘$´>yÉÂQ+ÀDH«ÞŽœÚÍZÂöqÕIƒ›wïœê)KŸ´<ÿ —]þÍÀLƸ ÆŒàI=×Ê£sÿ=µê("Ïœ8ôM­ßÖ(;ñN‚0 2•úç-BK)ö;• y¤‚Wuþd‡Ô˜ÇR¤úØéòº‰%õ hvÄÍès–%Á>Çýôß7Ÿ?ßPÉ¿¾vÈA–“.òþmlÎÐfÏýmûñ¦æÃ=ïÌ#|Úmá±Î? ·ðªï<{â‘iΞàŸÏû‰[ÃZ=†ýó¯ÿ˧/ŠÑÙP¯¡Z~E_¯Û#¢„ø>¯¼ïæNÏùMPþ?ï'C+Å-£jÚ€Ê-ð¨:ÿÔ4äg Òhº^_H¹-8âÂmÄR¡$w´…€€í›ð*– ÛSQ眨cQÆV£¼ìR™?Ô(l¥(ë¢0¶rEÿË¿ü|Šž51˜A}¹ÂmM¹ÌtŒÄ+ YÅ;±S)õìh%dL׬jb÷ƒËPjd‚ýMázÆ¢¶hÑxrÆdn¦¬JQæ©¡-qã‘b/mNŠRµèˆ"zlÄ¡ßÉŠ*8iŠF°³ÎÑt`±[p¡Ä1Ô´a¨%wTËáᎃ TЬܲ_¹%­Å UP×oS%{5&wÔ†e\…BEl®H¾•*U„ÂKz‚¨CÈ tZ(Ž>?ØVãñ0ì—’ ºã>\&£îÑyoq kBW ·»màÚÅ%Êê'å;™Ð+¸€ëM“®dƒÊ±£Öy›Ž‰l ìA‰ƒä›}ܦôV«d:҆˼Ÿ¶#õÁvf_Šƒ©²‰Cu\—.€abbjº–R/À¾GuØ›ô錄sÃ0t5m–tF 7Ôð”u#+¹wÞ¢KOQ/Š6úÖõûFæí5*$à®2]QÞ" î=ƒÓxc’?’R!&”V;w•iz}¯€(i…ÃÜ^‚õHÍ=BW¡æV†}оa²!rJPŸËÊÖô¦d`ÿ`‰úö¥ Å@äQ—+aé 0l3 Žj@׉qG¼ïè)äÈÕz?q-AKøœóåâ´w}’õ³NùÍ€ë5‘Vࣄ¯„ÂpVHiH™n6|£G,VËŸ‚~ÄQîQ“±Á˜„–¿à¬©ø9B8$:—cªŒÓÒ!U %ŸóO—þmÙb¶šFËH¬£%Þ)TLΖx{wkbnÛù¢L*¡º¹µgô¦Í×·%Œ+¿t /ÞÿÛ7ºÑl=].\ºœ_‘¸ŸîN~=ùÎ1"endstream endobj 5306 0 obj<>/XObject<<>>>>/Annots 2188 0 R>>endobj 5307 0 obj<>stream x•XïoÚHýž¿bÔ#'' BHîÛ¥MUtê]ª“¢Å^ÀíumM«þï÷fÖØØ@Úªi³»³o~¼7c>ŸxÔÃ?#þñ㓞ÛÃ'üËã_ÿ¾;Œ{nŸF£¾;¢˜†}Ͻ)Ÿ"z8Ù}ÆêxàŽwV½ñÏW7=9Ûôª'{vèix3´–G½êIVwža6®Ë½¼ê *Ác—:¡…NtøÉ‚ÞÐ&Siª³ü‚Íõ†T„ìòaÓÐ åm^e¸ø‘ÊóDź…•¦ÎÝo·{nùù±Ó3¶Ú”¡›,Ã|/ô1Ù>c¤8£ÂÉÛå}ëä‘/ñ¨Ø¸MY]hŽ-UPXP¦‹U–äRì™9âÄf¨ËëúKŠ:ĺ‘-o(ÍÌ—g×ø¢.d `{šKLÎÏ4'À†?péý\,ÈR`tN‰)h©Ö(ãušP¤@•î\pqœ/sZÃh âr)Ƚzc>Mþûðö1Å¿ë»4½ãÔ¶ÓŠ¤”…T®+¹–²[«ÀïZ¡óó–¡f‚ÛÌ\ü/6† ¢•Y]H ÐuKè=Ôß×ÔFÔ9?ºÝ%@`úƸdÀ­鵎8õa„™ö™ìF×Í2¹9·‘* œÌtlÖÈ¢I´K÷Ÿ0aÉòõÅ˱º7f?DûîÇb¬¢€fÒHùHÎìYIå4PK™’T¦o2HHjà XÒi‡<‚ëPæê=Ýš²¢_¿þ¢<ðsjPñs·Š¢gú¼RQ8áþÝë×– ÈAÉÓTùOj¡Åu°hÎÍ¡Š“„¨i×ÒǪzNrœß“¹¹VЊ#ò]G6‚ÏŲCæK¬’E,ÛŽ…]^%Rs²Ç–Ó1úþ ‘xÞímõwÿöö¯ÃfDµFÙ(âv ”ÍvåueÍ{¬þì?ŠÝG»µjbBi6Û/ûõ!ÃŲà:Eì‘2ñØWQÄõçë¬PèÇ[Çs ’Þ*[¤žA²©£Ý…K«ÔWyQu²é(úKV‘FÄ·±Â'æj˜ ÎÜ ˆš^ÕÕý>!ßš) œÛpq>kA¼»ä²Û­ü¸{ëIÙ¥©Æ|¿Z‘ï589AwÀ$³ ´)Ĭ)FNµå±(/µØdx[è+\V¶¹L´Bc›èCùè86/+Á S™šÊ@, 9Ò˜K;ÔYf2é•N–åMŽê-o¦g/¤j´?ý(m>¨Õ¤‰ø õáÃÚŸûêêp€¥¹çÐìÀý׎–è:­ìr @1èlŽR)öpŒ¡豨%>/XObject<<>>>>/Annots 2193 0 R>>endobj 5309 0 obj<>stream x•XmoÛ6þž_qÈR@]mÕïÉ:ôC§E? ÛÛ-R6ITI)Ž1ì¿ïޤ^,+nÖAdR¼—ç¹çŽþz1†þÃtA?Qz1 Gø ýÓ¯/Ÿ.&×£pó9>C Óé¢~Jàþb:Ÿ‡7õêlr]?ÙÕñ8Ãìÿîd‚«îÉ®¶žñä›YxÝZ_/h÷ljíNf7õ½ûÓªåªõWoáíÇÜ„SXÅ0_ÀÍ.×°â6 ¬¢à^¥â6aÆÀ÷¦×Áúõ¯W_Œ`8ÆMÂécåA’· ÿÐþ:$-ŠRg‰}ÿ:O,Íñ—LCÿâb–Ñ͉M ¥Áf¨1çÿÿæü‹(tÙo ô ”C䑃2¸âK’n¾z2{µ—Y^Ýëàö»w]®"Ósêàd›LûÎt@cý ÇÂ9b<2-Ù&˜PdŠÌM\jJM."ËŠC.R–k°S‚ž×žY¼zYfãº\›¨˜Ûðíe'*—¬fsÏ‘!`pQª0,¤>Fh*ºÙð)D-…Æ$¨ØFì@¨ ®dÚ“î¾ò¸â} ‡”EZ™S{¹©¬`23Ö™=ªˆRe•oKȵz:@*Šâôé~'£]OH¶†YR xš‚€•‘ݰè>¹}óæ”5ýD0àõFðÚ45pôÖ`±mM y©ÑR,“S²—ÅΦœYaª„w<è‹£>”ö’ŽYb±¢ÐrS˜þÉø¦È-”‘*ÄR«}æÒG<Ä‚‘\„p/hU*êUêÉûûß?ºûãö—åÝ Ê”íúPý«gÌûËõ:0{¹]z.Ý:.ÙÙê)IG®þüõîdN Ñf]uƒzðʆÒïÚd‹šõHㇴª£ ;3‚Ls¥ tm§£åŠþìÌcM1³»RÊŠÓm»ƒ;U]«•Õ%à"Yt@8¾ Ò°´„n›ƒM 1†qN=q¬RnõÎcêñ:&æ˜ O[¦Å*Iv™­MM&‘¹Å‹i`Õ'f‘0V=_~È>“.ÑÊ>¸8êO.íØÜ´“9ãŠæÒ¸0‘­f·Z&Ž¥§· u}辂6´–0&Ò¤™ngE—fbîœp>eN š½Ã¤Ôù8ÍÐ Ýð†9œ¿i|ÄÙŠ „ê|¯ôÃÉ\Ñ2Þ £o’úVîvì¤ipL5‘ʱi~ŽkŽ’ìÐBž`gòêE-~ôC‰Ð‰Œ,¶©`Û¦–F?+†È–EW>WcxùAè%³‡tðãçë0„8'Ód@¢iÍÑõ á-lõ‚:¾/YjlÖZŽÓÛŠ:vT XnKEŠ>Š£ ž¥Š—4ߪµjnÌh N¼•"u±r]u'ÿIêÉB"¶¨ð¨÷F% ÑsŽ='=OÑ–¸ûaI©*ÄϹ€WÇÖWë E'§”µØv¶Y=«yßÙûës‹P}d"~ˆ§IK{œñ:À» º)l€¤»8AãoV*?2ÀöÍI$NJÈe‹XP{°v°ÛhzÅ]ãje)Þ2|i,=9Θ‘)o[ºñ×ÝÉhΧsXÜ,ìÝ{ç¾Yv§S\·sxíä¿M™â7(÷t©ÄQ²ºúËÅ3-Âé¿ðAñ™NÆôÑÝêâ·‹ÿ+_;nendstream endobj 5310 0 obj<>/XObject<<>>>>/Annots 2197 0 R>>endobj 5311 0 obj<>stream x•XÛnÛF}÷W Ü ›–([QRE'AûÒKEÕ‡¹’6!w™%i[-òï=³J¢Õ$…eI$wçzæÌ¬>žŒi„¿1M¦üÊ«“Q:Â~óÛooO²›iúœ¦“›ôU”Ͳô&\•ôîdÿº¢ÉxšN÷žNf¼+›ŽÒk콞\ã©¿â½×ãîgÙuxzÃOÝ•{ ñ{§ã~­{ºw§³i:ÞÛûÃ|Ïç]ÓÕ›kh¾bW§Ïñ­pžâKž¼2ºJ7Ôn$­º²ÜÒÇN”j¥dAZT’ÌÊ=Sº•¶’…vK·T™¢+ez>rõæ9Ùh¸„ŠËŒÝ›I–áÓ¯÷+’³•mgåpkÒø;ÑØ]§³KšÃ¸¨“ ¹RZ6$HwÕRZ¶°PVæ­ºÃíûÊ7lŸZmå,v^D%y÷ûo)ØâTïÖÄÈ%ÔÈ–Ö¥Y Œ±´Â¿ ¦–9"”Ô¼V´ÊèÞzàÇ…ÚYϦŸ•Ðj%›67ºi}LHè"„(îÄ·òN”\$þãüpGyœ±øŸ»6fhi.Èyµ–ZÂ*ŽQžË¦Ñ•l7¦hœ¯†¿ !=Tâ{õô)9{„n›”8‡ž~ÞCÄÁÚgˆ¤Ë’eE]+½æ$5r§„DÃÉQÛ»¿HšFTiº_ ”ÀÊÐ=^™-Έû|½A°ÚBAº7öÃ…ÃЫ+‡Eâìì%—!ªº¦ 0TrSÕª”Þ•Ü’Řn½IéG®'ÈÇK›ÖIÏE#/غË>\[ÓQ.4‡åÈ໓Ö*èçB•µE^;DQµ­Ôl.?¹¥Úš‡m¨Oêšàa<öA6ŒKŸª ª´è5¯èMc5ZÞ¿‘¬%|Iû8’^tí#Yh.H¬Á@ÿÇ@ÌRÂ9pü>Ï(kX©Vâ-’˜jØío°Fƒ|”à8ãjrù˜:FGà·h¿c7g”µ«(Ç3JÚyí tιî#êrú_¦÷²ÍøL®: f3:%†&¨º:žBœ •ø¤ XwËRåÃÜÆɬ¤£Ð¨ä‘«î@$C)*Ô2”{ꛥnS–N&¸rx)zùâÅÊ:­½ðÓoƒEØÇë•.ÁïtöO4ÔÝnZÛå-½¤ÃÛDwF˜Y$‹ó(‰9¸H>^ž}ònìu«ß­FÓg¼6ßÐ/V¬+1H§c‡]/²7ÿ£}Ü{Æ­ý®]gèËÑ7ʋЖbYºŒ\¥W y¤3Ô.3Å€ÂûàûŠW¹HŠÅ9©ªðzXÀa²ö‘(]=sÑȇ–É-xª¼¿Á·š[>Xf‰~VE>9Þö僨êHTm„õ"á~¦PÓnŸfæZ¸ÞÕ³G,ZYa›( ¤Á:ЖCmdY£:]$"Õr´–ÛÀlí¶–•¨›ÏÔæÑШª6¶$v—;SœnduÊV¶že˜ö‚ Œ®$cç=$Ä—·8—<}<ñ¢Ø™Ã»Ù£¹51²6·0öÓ´È\J Q€(–è©[ºG“æÌ9x¹&£Iý>PÝ«vã æ1y-ù ~HçŠøÊp;Îú 0þÄíÒ1ÈÀ”Ï H|;vÝU¾î€ Îsf?+.0¿›‰°24™ÝœçF}ÎFS—@£ß‹BúÏ”ÝWÆä!æøêMMÝÔ"”aGM6™“éÊß«¸œ0š«è+à§U'á ˆŸ»qÁóåµ(0TÌf<™4]Í8m˃D!k© –  i¹z½”˜—é:¥•5`ÈçfU[ ÕK‹“ƒ'ƒ]³~K}YÓÜ0/¸íÞ–‚&óÜTÆrûTáÂZ1 Õ)ïÁ4 C8&زô·â©‚á¼›€‰Ãb/ÿÉe,,ÎC¯Å@áëêÑü¥˜'»Àe‘ýÏ܉[zàÑžèwÑð½Ò`ì|#ìŸÑé"y‚5Nßb½6iÓ9Þ,òõwÚšwþ[¿{_ààT–‹óÓè«ï»û¬ùØ#úŽN98õ„¬Ë°J+ëU_p£b„– ‡1ã$føpòbAÑö8ráL«%(iq¼P8±7ÛjiJÇe¬å¨kc=Ä^ ‡ÑÑý¬ø3›³ÅáËTäKJÞ)Ó5a®Çž«Ãñâ+ÉçHÔœ÷>ʳP–Ùè:½™à×”>§>/XObject<<>>>>/Annots 2202 0 R>>endobj 5313 0 obj<>stream xXMsã6½ûWt%9ȉ֗5ö¤rH$;•’Ý«rñ"! ’`Ò²þý¾n”H{v§fjFôÇ{ýº¡®f4ÅŸ-Vü7-®¦Éßð?3þç?¿\-æwÉÝNÉG*h±œ&·íSN^]>´œÎ{o—«Éœ÷Ód‰½Ë»erß>ñÞÛéßÇ··³UGd-¿]®ü<›Â:öÞßwOüöç§ WÅ_·§›Ç%ͦô´ã`V÷ø”I,øŽžš6”Ú¢PeFµ¥ÆkÚYG[Sf¦ÜSG§ªJ;Ú5eZÚ9[È«õÍúûï)7[§Ü‰÷óz*¶6÷dJy4e­]¡3ÃK6×O_Mi2›ÃQa³&× ±üâæ)_GßEkáûÈ^”3j›kx]ÖÊÀ¶YªB“ÝÉçMçit# `l,K†Æ‚Ë_4e<¿št~;]å*ÕmôÀz8*ZnS“ð~lŸ/9앨6ð¸>O•SûB>ùJ§fgt¼¬œ~1¶ñˆ9o4/°/Ú©k]Ê‘7÷4cÂÞ ð€—bb>OV@öá5Õ•`ÖM\IîîØ›?š:fnk_ÇĈên)F4e†#ßy~Bh L¥jÃ(Ì#ýOcà'ÅØ7t´.ψ©•ª²´5yST8a«Û|TÎVj¯j$Ç),Îs&߆ ]l&Æé`IãTÒʟ訄xÞæ/]>-<+>Ño¯qXÍÙJ]PÑAaoÏ“Hõ\ØF¥| s ‘áÁÒ†mgT¨Ïlï\©Í498ììñ}{mBúdxœ-ùe¬(Ó 6 Hø Ô…’D0®Éô˜¶€ŒMÿùׯ¿p–¤ŒH5µ- §9Ñco{üö”[$ÿã0>9@ØË¬ë”ÏWµ$9R×ÍÊr&ŒØØrnIÏ#ì›*–vŽy𣠪a…ËÎçQ’$Ï×}vŽ. jK("3Ï×ýÜýÄè ŒVu#9§d‚éW•Öœ 8äY#˜.!v–¹õ·9ðV·%}Á‡ŠŽÖßRfÓ¦©¿,ŠíHÄSx`ÔY/»úÒQJ4o*˜«ò\¿ìÆ8`aèÏYÉ/Ë÷¯ƒ:›Åµ—é@ô¨JTÖ8e¯Kíðì‘™Ú¡Ô˜´ ÜÖÖ¡H5éHØõŠ×à¼.ƒä:ëýþïµÔ°ÍOˆºEBÞG’°”¢B+‘jÊìèdòÍ6͹Àоž(<4T»!¾A8H¥©æuåIЙ,CÌ/ÆÕÊ{Ù |óô7W>³<˜JB(`âÌ >u¶`¨Ï)Ôc`R‰RŠœöÁ§“®ÏU( „t}‰…ÐoÖí3¹rœNˆXKÂÌ–(ÿRjc0f0ë~S/êKLc”úïd: dí¿èèù(wG PÐéC=µ¬C‹A·Þa&šÌWmÓ@¹Ãìñð 1ÈOBO¬Ue] E`ngíîQ)ï×ñÈѰô³¥…ý|Z;ÕäHµÝ.WÜø@„<‚tFyÖÎáÑ6¸))·×5E¢ž½  \üœ\á:« D?i1›CÉ9„3V1·½ê }í‚mV)¶¼Iè×]”`®Ph:3þ" Öí‚ç.鉴¢ô3jÎß±÷ ý!¾è‡¢×¹ASb G¢‰“ʸƄøq€a§-LtZ6œ£8OZ\yð»›þØ5iæixˆrøÒÆ9}~’džB×R@Ë=¦H[˜þœë£[[÷ï΄}žõxXÞÍéw(Ú}ee¸Œœ {â¨xA¥5ÚwœP1éBF¤èSg0¡#v™‰g!* wÌ»1d`×pKmAô´žøúžµöÆ“ÈeÛˆëf6LI9š5’×"…2ax.tzP%´’ó!ãéº;‚’à ˆ äCÈ (8‘£Å£qsžYN1Aç8©õ©â&&_¶û„>Ð_Œ¬N³(úo“Æ8Öô¥‹ŽÀ/0rLrŒ[ùóõ˜²f»EV$œ›Ç3u*a8Ø|ƒ& ßWØ5¼p*L€kmJ"˜ÈK&ãŸOŠ„Gõ¬Á騂8ƒ HûOâd°Ø]ÒΟ¡+ÝFnxÞ`göžÿ­U^ B…ºŽýq°Ÿ»ú‹nÃøŸÆYÀ"^‰¡5RM¹Ãœ_BDùeÛ}[ªJ3ŒšÚûžËã7q™ràÍÛ%¶©ß¬‘É,!0ú$Þt`¾ÜÚÏàESIÝC}¸Þ¹¦,_ë­>à6)1ùó‡ÿĦ¤<¹¤óxÓkе¸v¶XãxG]aÊP¼ªñhûÝ6ßTäp‘ uX¢d¸}Rö¬-нDfQœ¢‰ì ýJ ½®/$¼­,±{9çà¾nnþ £s{m¼„>,ΜK 3Çl 0»0²sÝpöáœõ޾ÄFš¾àYë²\q'ˆÃõ8| )à1½Ùà*‚ :*¢À*Ê?ðˆÊ? °H õô©ÛFgåh0iJd}OX1.Áf0Î÷UãÉž©À*aµ©ÅMw4WïN´êc=úJ…`_;ß+·³ñ… —\W‘Ü<øV'¶£Ó÷kÎŒüçV>X¿Ë­Öªz°îåß̾ /ckɇ6,²Òýœ38â+‹aóeèÉ–âžXЇ]Ør7üR,ôáÃÀ;fgê wþI*@ÑÏ×Ï£ð€ƒÃÚ‘÷®uæø}ívqK«Õ2YÉœÉ=~²H¦´Þï&qñä#ÿ*%ÓÇ-ýK~®‘ÙøvºJs Æx·˜/ØòÃÓÕ¿¯þ ÌBPendstream endobj 5314 0 obj<>/XObject<<>>>>/Annots 2209 0 R>>endobj 5315 0 obj<>stream xXïoÛÈýî¿bŠ¥'Ñ-ËvŠ~ÈYI ¹\£÷¡.+r%mMryÜ¥÷Ç÷Íì’i§=$HL/ww~¼y󆿞Íéæt¹ä¿Yyv‘\à7üÏœÿùüþlq}›\ÒÕÕ"YRI‹ÛyrŸ úrv{›,èj‘Êâ|>O®ã/¦·¼)½I“[l½œ/qPxâÕÓg¬.¯pðÉêÉ3Vo®qÏqu¾œóóõ…œœÎoøy’{OžKJ/SXu²zòŒÕåå`ï÷'1@4[:wKó”î7Öòæ†îs‰ÑÝg“4Mnà×§Z7ÊÛ†ì“n «rSm_ÝÿûìüÝ‚æx‘·ÎÒ¬¾Ï'÷;M+*mÞš2[jG{ãw´VÎdd_8Š\[×¶ñ´Ák‹wWsRUN«4!×hRžÒÎî5 ˜’¢ÞSaJã•7¶rX7.SØ|²il ªL×¾Uåf³ÁYxv´Ö~¯uEwßnzÍþˆÓ8Oúp²‘Œ#¿S^öE«m­iÓVY´Åõ^:z˜¨ÂVÛÕlÛRW~–ëZW9~¢ÂÚǶ~x5¥ýÎ `«hGp¡Ñ¿¶¦½]Øp½…ñTêr­›“Kí†!Þ…rl"¬FÈâ6†l•ЗŸ?¼§LUx(°Þz["|™*ð´ÕçXÓ¾Qu=efsxˆìŒî=Úõg2:Ø–ö ^ÁÈÖu×ÛÆQ®7¦Ò9©gÑ2­¦²³Òx;wH="'ÊA0JU!Å!¤êMÀ N{Bþg’àÅT¹y29âmBïà¡þªÊºÚøT!L]ÿ6ç+Û ”ˆÇ Qk¸ß°)­[O0“Ÿá+Ç1ÞB¼ÿüIªhòÝwá]YMœ£—~ûmôR¸@ÎŽÏûó7¹¬êÙø k²F3Ïs:ƒmåÍ#Î_LVóáBG$Rë.;À¢i¨¶Îó zÀƒÃÿÍÃÓoÞ›v$“#n;Ð í˜k$m¸÷ÄÆ<ŠÆ7ªr@.0C&8/üæ)h`ÿÊ088B0À¯W¦`žÑ´6B~=ÏèʶÛv¡ˆަz²ÅnrpŒ²²m‘³±¤sA_ƒ}Ùñå¥A¶C%8ÁÍš©ª·‡´gf4N‚Õž¿eÞ &8†Ù:€f×.kLB‰,<æŸÿâ¼>™r®ÀâkS…H—ƒd̶âð8šEæ {(wWг#ùDæ]Ç4Ú·\ž£Ž\ê,/¢°oŒ÷øßÛ)º ‡¾!¤¨Àµ {fÉpí×7bóÈ=šßÙœfSBU²A&3ž¡ä™5&Rå µa¤Må4¸ ©€3«”žŒ‡Réó1I'!}x•Ð •¤ÂP+TöÈÔuCì,Sê(/p"[„ Öu·ë@…trêGÑDÙ9’Ò9mó³tÉ]Nºû‚>·U&¯Ÿ9æ»a Núû›ØÏUu @½…ª¶­ÚÎ ]æxŽ4à~Ýš"tøzCwß(Ušå³ãÖ¡ òèŸÙ޽ÎÛzV@ü^_Õ#Ø NÓèÜz£ÚÂ*sA sº( Bú|hÍ«t*-‹bknäh #ëV¿üãíç/>ý86ì òƒ J:Ù&ãm%,˜FÈžRô_„ÿNÐ2佭ׯéÃóVû~u‡¶N3Uû•¡¬b[¬Áwh8e,£^Pp«F S=Ží-Ì:—˜žX!l•*UF½U Øí@‹ùÀEœÑ¨æ{i¶;?ï–TžoœÏ/ì¡-œ”Q.ò_@J5ò<ÎE —åhÇÛÐØÝy‡ÑN´)–-ËÜ¢— †üR­¬m Qf¢‚ü‚]u£¶¥z˜ Ó$I^n!‡Ž"åX•"œƒ†¾ •y z»?ÔºTu§„ƒŽI 5)ŠEw쇕¥ÕÌÕ:3Èm?:!tŽ¿vBZÈœ½PkH{‰Ø Y%z5 óŒu L?Põ düÈL¢ƒB.09ˆ¦Éµ,Ñ5cÎmž8ˆ&f‚ÀJá¬Ê,’áj %‡wïþþþ ÃþO¸!À~¶Í#ã¦nì'£ ±V¹±pÝh…Ö¤W f ùÀDÕí‹õÇúA”`'/B3R¤×Ðf£M[ˆ¡€@¢¨Ðr8.•V<°Y2½œ¿[F‰qãSüÖ/™”9¢_;ªË»ÐA&Üù"‚ÃN,2ns\º)Æú¶Pp3´I¶Êʵ…ÙyÎ1DÁeNɬ¯"yàE[s‚›¶òðBÚy÷Š2h0JG6`©®ctZ £Sl;,'aœ€*¡C»îfJ&{5€·¶˜e;…Lgª|Âî  I¾åÃOŸØ2¡F± ÙäNQá7¡cw3’„ ¤/ºË  H :[y\Þi%Zo`ƒHnã4%lÿnlèü&&qvÈ· dñ!]^G:ëRÌ‹³Oë“»(ïdnz)˹UçÊC"ù¦ÍÇ tQÍwç¬ÅB> Ò…R·ŠgÆ'vARPòˆ5ð›9]aFÖA)<äÚá7âŽE¢:ç«l1b÷LÏÚŽo’ðv ÄM |§ð£Ê0½Ë€ ž–°x „3Ķu ¨ë;,¯2 —*k¬ÄßéÒÌzý5ˆ¤ÑAHº_LS(¶“4u%6KoÀä1Q_xJéí\N£PÚ2İ›.P2O(ü×1ßjÈz. “µ…j4¤H2`‹Âî9j¨3å¾IuiQˆ5„ ÷g\𦀃 Ùɽƒ´ìA–˜å¹"¤‰4z«™«Øª÷w"øÇ£œ›‚5paÏlƹVÐ'%n€p¨˜á"_ gf~‡_1¶^¼˜‰0vždbP0!OÐëQa³Edž:yMŸ³‡à+C`Äø‹1ÂrÖ›mÂøÆþ±`¬æ™éùO;»¨ºOZýΞºymÄöžïqNø<Ö·‹ØA9Ì„@ɽ. ‰+#ë§×@¯GòŸp­"ÇN\ã"êcŒO`H~`z_:iæ+®,í³ß׎¦æ×WÉòòŠ–Wø”*c×Öì2¹ •Íäs— ŽR›éÅ"¹Â˳kþà'o_¼ºÀWÕñêeºà#ÞÞŸýýì¿“,Å>endstream endobj 5316 0 obj<>/XObject<<>>>>/Annots 2228 0 R>>endobj 5317 0 obj<>stream x½XÛ’ÛÆ}߯è·På%„;É”ËUÖÚ»ñK”X¬Ê˾€ÀD``\–Þ|}N÷ €¡V[Vœ’Ê2k›=Ó—Ó=§gøÛM@>þ (Jù_^ßøžoø#à_n¢Ôó)MR/¢š6‰[¡¢VÇFç³NÖm±¦ÝÖK#Ö[oë(]Ú(ºÚº 9œ(—AóV‘ا+cë&òv®Ö‘k ý­8Zc8ôÅð6öBJE`»ŽÈñÆѬteŽ7ef­¾¾8b³"°YG¬) 8•Y爀=ô6ŽÎmr¥sD&^êltehÓ„ñ™] ÉÎTZR6ÂŒÀ¤ O‹Ò•a6f­1 {Œ€1+ÂbÖê ɬ4ñ¹laÙhuA˜×dVâ„—:¥4²Ñꂘ/J³16Å2¡Š°l´º Hz2+€—(6ÇÊx ‘x«+3>1ã³hÚ]€¢,ZRè¢'Â’Õá–ÍÎJ³1pÑaÙhu¶z³Ò•O¢Û“YkÌúÛÀ¤E’D[ H‹Ö‘Ù0w_²hZ0Mêjg7Ø0Üó^ *Þšºív8HFà˜fqävŽÒlÜØ²Iô±HK6Fæ­|ì­#s6‘£udΆk³hcÔ* Ð +l´‹‘Øï»½CÃÂÅ݉ÞÞï`ë÷G0vº#„´/„«}Úç«0¢ÿú岦 ýfÿoLjp¹‰)Àê#³ýä')Œ¬Þ?©î©T—ë]‹ë`k·­7ˆŠÕc˜nèzýK/¼zpœ«_Ǧ)›“‰ñRg$bVüXåPê&«èN×5ò¨ÊFÑû–¿ì¯]}.´_FSp‰ÿ‡Á™õÖùƒ¦÷ãÐŽÝ—•ú“ÞÖ˜Uþ†Âø iÐcGúH‡¬/sº{{÷Ýwté²¶nœþ¢ýG–ÌNŠþžÕêëcÃ^þ$(R*ùxÙŸ–à…²fø®~nÆZuÙ7ê­»*ë{ƒàUå{ú¥9«®Dâù”rãűíò(6]¾Žp½=ÈA{ ¿¼÷M§¢›öªn«lø5þ©ìT>èŽL–‘¿„©Îù¿öOê˜Õ¶¡¶+k0Ì“¢á¹UT›“õµ{ÍÒJÖÐp_¿µ™EA³ÙB¦'M¹.¾ ³>‡³¥´ ²½eIÿíý4HÖe;P¸$ûsÙS~ÎÚAuT¨>ïʃê…ôÿÒS?¶­îæ¸íÑ=š Ö¢²9ê®–³Hº¡á¬L¹ô©ËêšÓ©²æ42ÝõJ½Bì«“æUžî„,_¶ÔÊcž”9Ê0™£½°uaT¹cpÉÐǤÄ3cË$.B‚­[̉bì–=@Ác`9!{ô7}Q°·TThÀÁK', 9”g¦Ý‰¡9ŽM.´ò/‡A5ÀÇLIᘃ¾L9ŠÛv‚úù™ŠÆa šNªa~Sf„¨®ç/Ù ÝI?бÓ5p¾¥¦0çBplÐ6Oª)ѬtÍyÆ7Òurç8–Uû\üSÖN » LXÎðÿã*¨RY?<¾¡á¢©(G(á¸ZH»Þ£÷û0Å}pÊgCŒ.©ªgò¤?"ͧ23«4¢Ô•GŒ‰æ\–ý€HæãÛäç–.ç2?›z‹H pÆíâ¥*el—XÕ³¢í„fHØÛ­Ô Þ’úZälí¥ìÓ8¯`h¢§¸E£W Iäxx6ýÆ"’‘–Ñ5ÊïTž¡ò $b*`¸uŸÑ"/[•ýá8vc3”µeÃü¬òÂp3iªòÐe@õ¸i¥·ìå) yN)õg=VˆX!‡ŽkØNo ÑÄÊ„™ÞNõÂü·$_è\ØQ8@2{ýœ†ôÚ]òógvïœé³BÝr&RC øµCnÅ«µi–ÅЊ Ú$Ys¬½C…íT‘à/èþå¸I?LuwÚuv#™)y·œrtë-=ë‘,–YÕë׃åå&ƒ‰Ž§x AÜübX‡rËÏ…`º?¾k/þ–ÜŸpãnàÊ¡³>mÊž8 Û_»ÖÅX™³ó òiHòAƒ€Çní±GÏýuª?àmÈ.ñ6Š «þRž…¡õYU­YšLï¼KýÔ¼eB?±Ý·*/eÎk7Þn~ƒ˜RJÏ.é­ñsNäÄ\Þ¤5ŽùI÷å}ßÿÀVÒÐÛúxÉø „/IL•F²r«˜R± K曹@æÜ¼fè´°&Ð`WÃôȸš›¿ô‘ú© BÝ@ÌpBB Ìm‚mÏa9~˜Ö(C[_¶…™¤ÆŽùÕ©ßFŒž‚бãcÏŽ‡.kzyƒMÃdªCvÜRfXYâÕÇë\ç8^æÌS=× Àß·)õÏý j¹(4'ÌÃ.ÜÃY£½:0_†Ë2æ…Œ($ƒ‚AËŸo<Ü™%äã8Œ¶m–ƒ×zç Ð¨ šY…$@IËÁÅÅÔc}››Ü2ÞÞÏÌð™¤ìˆš6d¬­Æ:ÕÉé[Û¦ÁݯBÓXrÀ9<«“§ôÃ4©gêe¦ÚÓ°3‡Èæ¥\7‡e^õÜš÷â§¾§^nðÀãË›C±íjvù=«~¸fRË. ƒ jÎ;ñ÷–æ_ÐQÌÇ,ñðëŸÔ—¿X$>~‰ Íë& öçýÍ?oþ ½àèÊendstream endobj 5318 0 obj<>/XObject<<>>>>>>endobj 5319 0 obj<>stream x½XmoÛ6þž_qè0 C-Å/‰ãnÅ€.m²Ú¡.Š F¢dβ¨ŠRÿû=w¤äȱû¡–7$y¼{î¹çŽùr2¡1>'4›óW²9ùmy2ŽÇxØÿ¨s:»>§É˜–Mâ‹Ù‚æ‹E|>ŸÒ2•ux“œ¾,ÕFÿúÓòß“1EÓI<¾œãýiÔ:¹UanùÕ|/ÆØÏo–º(èç·7ÔXÒÓPbSMÍJ5„M޹•ªuJØ\«zÓreáË–Å–6Z•¦Ì³¶ ÌÖØ§)O`cS™B×#º_™dE¥Ö©Ã Á± ;}º.í=ᘰ˜³ÑX¯a£~r,Ý8z«Ù©4f;Q#š^öa:ËñNÙ!ÖOÏùðºgë¶”syÙLž öXp`é«L$Ê5\t+Û)™2)Z@†H‚1†«u¦Ú¢a¤°yàS¥’µÊ5É¡÷¦YѳØÙg¤ªJ—)âbÌ!30%åºÔµj¸OÓÈñ+[‡EˆàñΓ$·#‰PiÍ*tÙt>xpµÆ)Ym7²Œ÷Ÿ]ƒ™ÂºÓh§d«ÆØ’*åØOЈ±òÅô‘ýÀ括a6Ua@2Þ±ãhX9Ìòä¢Ïrn£jWªY Œ½ …þ!Ù>òOǰ ¸@†`€cæ! ‰­kí*[ ƒâ’ =:ާ~4ÌÅW¬uföâ“gßžìÿ¶èzw‡š·|<}Œo3Ú'ÐqœÀ¦ùèà–ƒ‡w‚`òÒBŸäð³ëÄ)Ï(šŸÇ³ó9¸!b‰’ŸÎâi<¥KïÚ¦jº†D9ïb§¬¬šç±(Ä>i°¥qäÕRNåÈr©!Eaï™íÛý™ CÍaõæÏw¯?þñ&έ²Ä–2¥l„á¬-."®èÈÖ¶5û)R,'%ª(DVêwÜ׬µë%øêùóuv[ J¦D™Þný)›¶EGuv<ÈÚˆÅ0CvƒHC‡X®8^ñÏË|À~²J]ÆÉCzúÏt~rÚaÌ/¨|fÿã„Ð?”%Jú$]R -…yRúò åz%Œ CMèÿ‹ƒúÚ Ô¸¦6€H§ë®(‡žY7ÝÔñÈÉ@0F—¤·R¹}öí´ÅÇ“[0Bû’š– ÅØp|G /Âö^ËÏ®‡L>Šj4]Ä/(:_ˆÔY×°:€Žy­6!k ŠÌBðƘ`­×4Êý´$…ÁŠúrmUY Ã#ϧGº2(5"VoáŠL®(E]g*Ñ¡(Q†øƒhé‡F—ŽÇ•ØÝ›*‡5»)ÂÁîËžå^&1½Ç©¢Ïb„Wtóîý«åïg®Ng_“[Bž«ìûÍpèuT’7f‘Üšî‹Þ‡®àx ÝÙ”¬÷Þc˜Êäd=ŠÅ·%02Ì)soïøMéô,a‰óüVmc7˜+¹ÍlyŒõMŽýgÙa;¾×ˆyÙ¡ÓRƒÒ;™cK¢Oá|Ê$K>˜çÄ9]d1I‹}ĉÝÅîÐÎ8MtlxQ(`ÄÙz4Ýú¡Ã´ŒÜ ¾³Ñéä|ö”òÝ{#:ÎíÓ+j¶£ÑCé02ë{T(¼ëQÕÒ=ß^Ö®qâšUÛø‘€çéE<ãeʈMãÙ ¥§?3’"$L?( Æ:61Ìß¼SE Rª‘||ü 7+!w3ÄÇÜõÝÏOD< wã¡ÇîŸ*qž÷Nä=;;Ýš¤[ó™•òˆ%–"ÊQ]PªÿmÞýÆûqïå°úà½GÏÎÑWL‰yêȱóÂ/˜óûÝÌ æ³xŽ©dŸ©,*œÒŸøeï<òÁÊ|˜½·¥£$–v‰ŽÉ'ð͹ó[®ÂAì {þ’ôUrUŠ5 }µU¸^ ñèÉöèÞÕ¥èï¢ 5ÑåìiÂ=9‹ŽŒW†Kvwä~Þ)êŸàjܵÏÀÿŸ¥Ç= |䢔ÖÄtÉèôD‹Žr¶›¦'‹s\a.hŽ+ÍdrÁ¼eA‹fñ˜^Û¤Ýàí¶2Jà~utéë^n=z•¦2òX뻄PÓ;¹“Ë%èb>/XObject<<>>>>/Annots 2230 0 R>>endobj 5321 0 obj<>stream xXaoÛ6ýž_qÀPÌÃ5±´Ý>µÝšõÊm : 0Ðms•D¢ìúßïÝ‘”-ÉΆ‰cQÇ»wïÞùÏÕ-Ýàß-Íïù^]Ýd7ø†Üòß®æóEvC‹ûYöŠ*š¿:þUÒǫӿ+ZÌo³»¸–Ÿ¾y<1(VÝšž¿{E·‹lA+ì}ÿò.»§ÇB6½¡Ç|2›gszMÞ¶ŽìŠ–ª19½}þöÛoiïÔvkêõ7_=· [¼ÀF®g‹ìåKX™¼9P¡Wª-ý”>þþþ”÷ºÚúöhÙš² Eµò­S%=X2µ×n¥rÍϼeØ)·…Îè'»×;í¦ä7šJU¯[µÖ )§©±•Þo”§Â¬VÚéÚOÙ+ør;cG+K¨²X`rå­Ú¨ìdó¼u=nLCÎù!-Ñ«ò@¹Å–ð[ê¦aWU³Å²†ñüRB" PQì `4Äì–#üEåŸá5}P•>‡òPL^—‚FO¥Ù!TS¯m0Áþj€WéÎø„ö"ðŒ$;\¨…¶Ô´r¶’´|ÝPð<“Nž…%#š…qŒÒ9ùöT©1JÎÀQÁcy ¶3.X¿ŽŽöÍOiU©º@°5‚ÚržDtƈ2’MßR  @ù¾Æš)P[µuH,Òek$vg³ ¶õMpP·Ž¹“ &ÃùPÆ5žJ òJtxÂV»Ýj—«XðÕ?­ñúÈDÁ™ìØ(¤ÎèÎUÛté›F²s¦«[uAû®i­kíÀ\ÀÊœ–Ëwc7áÇÊ‚>…”š>úÉAßókkëI•N«âQ($æx VØžPl¦Ti¿±>ì”3 HâcŽªòªöø¨ë¶Â/Ng^*TN#©”Ô0ÇCawïJKq¸ÆoPˆ7X‡Ýæ\6£w’—KJ¶õ¥&–Èe¥‡@—Åà1LÖÃ’xÐÚQè&dÝpÑÇñ¢´ñÖé­® ]Ào¼¨¿¨j[êiâXBJrU–#P»«LD¾Iz;=¬ƒ¾¦ÊçB½ð L"²O#«’¹ÁBD7^˜Ñûê«Cž)wð]„E2 x€•Ü! Eñ óI£ê0xfªªõ̹%]T&~p´‘šÝ„qEÉLƒ@)„¨¨“+Ò/% x‹Ñ#σü‚j…iòÌÇn­ƒ!GK]Ú=:íõ×PiÔg ‹w:'4bõ‡OªÚ[ 95¼5ÔYL&ÝWä[*çu(U׿@¤Èxíˆpô~ˆòÊ–ˆK¡óâ;¿ØUÒßøs–ƒ™”ÅN ÐPÖQ&Ïîñd7˜³$¾M Ô÷ù¤#¤‰"*å=XvF kí«ê¾)){NV?œÉ³$~Ãå'‘~t8Qî´ Ù‹¨Þȇsß‘)æIH ÉPbi€¦ïÛí¸Tè‚ɆG‰Ð¦d€Ã4@>ȸ¶­…Yâ>ã’ÇŸO þ9‘%=Žÿ‡³€´M«Ê?¿ ãÎN•-š£Ì]}ë‘Ãp*d˜ì÷a„j6¶åsgMÁCè¥=¸{åI<ï„b¡]„oàw7Ë"DZWЦšJ`Ð%s”̲õhÆTXÅ-X&Ò¤#èrŒaƒâB7¬á%ÌbðŽ :Nª,·MîÌ&6Vjµ+-IúŽÓ<¹ÊËJu_ƒû¡ŸrDB îÏÜ£ï^²ý-ƒðžõa@3’=%‘(~ Ú³ñ3§E#teÀ¦˜pL¾ lû»Å°µ±r6ØZ1 ±p':Q6t'²1ðuàK—„ÄQ°Ê|Vè.…”C:'CüIÔ&PËKvBŒ=ÿ&¯>#³55 IQ8•[£9g<9#ÏþÂÿDÿApO.¹qŽ*q0JõÌ<ŠÛ÷Mut J}Ñp m&ƒ÷‘Ñ$ÈT ±„·»gø#’0âòéÚ0¢÷±H½9°äqÓê'û|` L½³ŸÁþ Ð8„3 לˆÎó?ûY¦Þ3ħæP{õ%£_Úe‰#r¥«%GqF¡êñ€»5øÝćßãÈ’$UŠ"ZιSÀ—±Ç\îÅ-™ÚÙ­zT&µ®0µr–¸nßS²ðQ… §Áùìs¬ûÄûŽ"9.ujR¦”γØS(HùO0ÏvnüõI¹3Ùêãõ ð?Y]S†ENâ9¤õˆë8a5*ˆ †#áÓy­_S“{³Î·~8ÌLjÏ\éåŒ@ë†DM¶;ÂÞ''† ·†Elù=†gâ—-êjìd† !À!m¢Å$|eÂÈ ¬d¾ÆœžôOšr;D +ÔÉ!™Ùäœ{âéXÌG¡ã&R>Ü*±Sp`£s®b,í.iPÏ'qlÆ'ú0?÷2ÞpÌnÙÝüN.¼frWÅ‚u=ÇåÚ6é•ñŠñ¸N‹¯_ðõH¸Îùwbw7÷Ù|† 1¼2Ÿ½`S?>^ýzõ/õ<.öendstream endobj 5322 0 obj<>/XObject<<>>>>>>endobj 5323 0 obj<>stream xWßoÛ6~Ï_q/ÛÜÖQ»qÓõik–4)04Ø0 ÀÀH´ÍF]’Škýß÷Ý‘’"%+Úi’÷ã»ï¾»~98¦þÓbÉ_yuðûõÁ,›á—Ý7·¦£sÜ™Ñõ w—oñC!çø!Ÿ8mê ÝÖéðo®|xqýùàèüuº?Éèzc<ùmÊ‚l]îéVSãuA+ëè^»=ù­Î* ϵŸ’oò )O»všÞ¿zE;yŒG¤(Úoã™ûZU&Ö5_Ñáü5ž|´ASب ·V¢ö,å¶ÚÚ¦Ft·Ÿu<)¸uyÔ 25­-GÔ^]y]Þs´µ |„ ­ÍŒ>Ù©d§¿ªj[ê)™UŠåxαìmC;§¶ˆGãbYÚ©×´jê<[ÿÚæxš-ô9'1Ï |*&y©¼§«ý{ù÷¡5ÌU™b 8»Òac‹›ÉÍ‹w£sT0y÷üåÕþ\åÁºýyrþôÑ7±Ñ×ôãY,²åò ûü‡“1eIk†Ü èÒÚ;O¥¹ãÏÆ?­°ßê.,)ÎJåšÆù}Ú™u¾ ŽÃ¤÷ðó(E¾ré@|otþÆkpü-}BŽÈ-y¤.ØqˆGGäUj ¤™ÄO=ŒÐœwhö4nÄÚtÌ Âj/”C»5®F?ôÄ{GTÌC£JtY¼2óÏŒ.Wºx r'Ö¢ùjî̺)Ë) mÌBX>Ì7:¿Zs1év'eɼåHu©„~›8:ÛIGêD$»ÈN²cº°I|Y%T T=8]÷² Dâ›þ.! Õ[1¥SÒƒ®…ƒ¢ùÚšõîz,”6ü¨ªÑ™°èñªÉ)÷«îäÿ®3Ù#ÏNÏ»ùÄ\ÀŽ™ä6Îè”ýà…ç]ÉqÎðÇÕòvª +‰¤¡jWÞè‹ ãF7“-½L±Wý¥ãñJøü»+u§Åº¬c`O¶6’?igy®"7“Ÿ“û‡o£…MÂí§ˆlŸý¾ôš››mP¶ÏH‰'Ì”ª`Õ.¨Ù¶—¤±dá¿°ÒÕm÷Èd†Êæè(´µxMÔ6I-þ›Ã ‡.W‘ÂØÅñ¦=L3¾õ¥ ¸ä8|4* óHÃå4íNóÙëìdqBËÓyvÊUc•9\d3:³ySA„eÊq0À'Þ=| ×-¶.õ‰cèd¶Ìs oØZÌOùá×ü“Šq‘endstream endobj 5324 0 obj<>/XObject<<>>>>>>endobj 5325 0 obj<>stream x¥XQÛ6 ~¿_A(k/nb'Nn¬×µèKÛa)†a·í$ÞË³åæ‚aÿ}$¥ÄV޾ë0lhQ?~¤H)ùëb üo QLÿ'»‹I0Á•Óõ†>@-‚–Q0ÇK¨3XÓNˆÃÐ-MçÇõe,DCðY3D×}†AOÓpÌDŽÄ÷5DÎ듺#aç*CTp>|f’àÉ©,=ˆïkˆœÖçס¬B2tI‡ä3sH’'«B²ô ¾¯!r^_,‚HªÅ\0tA… Ég¶! žœ ÁÒƒø¾†Èy=ƒPT!:€¤‚Cò™mH‚'§B°ô ¾¯!r^Ÿ-ûb.:€¤‚Cò™mH‚'§B°ô ¾¯!r^‚¡H*8$ŸÙ†$xr*Kâû"çõé{\ª…`è’ Ég¶! žœ ÁÒƒø¾†Èy}2 ®E‚¡H*8$ŸÙ†$xr*Kâû"§õÙ2Æžj!:€¤‚Cò™9$É“U!Yzß×9¯/¦*CTØ|f’àÉ©,=ˆïkˆœ×ç1>7¤Z† ©à|f’àÉ©,=ˆïkˆœ×gS|_I*CTpH>³ IðäT–Ä÷5DÎëa,¿g‚¡H*8$ŸÙ†$xr*Kâû"çõét@…`è’ Ég¶! žœ ÁÒƒø¾†Èi=ZÎÜk0\`›ó‹I† ©à|æAOV…Äуø¾^¯.^½½†i«5~‰—KX¥Ø ü"²JFaD(àM¶Vmaà†ªÎw¹É¿d`U;UUy¹i.W £LFŽÆ!e`•ŽV[üº¢‹BïquWdPäiÀ %uŽû¾`]ëܼºyùŒFÎVÛ÷3vŸ˜ ÿ8èöÛ<ÙRXìwg÷U–d¬AQL iKGë¶LL®Ki›¬R¹PO`uÌ<‹ÑµÌùoôâ¢Â´‘²:ÃÉAþ] ~ÆnÇ¿ÚL1í»Óº8ÇׄíÉVÕ¶ Ó Û›|Sf)H¨¼4Kò$ ÚòÜÝ#l[]›óèg?EÔHÈö1(Ú¦§x± À ]n’x6°ÿ”7 H<ƒH€„z äщèG9×…VrÈ‹Q8 0Õ-öëyJ3(μ Ì©÷xé·ß{~¸SãL°Ô³ \αWñ'ì8ì“ÚàˆÙ*?ÿòþìkUÙ‘q„xõ8áY3:önüŒì8PÔádU‰Éê>iÌnVãj™‚ªkuh@¯‘„† 3…ƒšˆ*l!Ûø?Ù9©m˜*mhÇ1èâHT wàÈI!_Û¹¥JCÃÍÔ*ü A¬ÅuiÙîî²j…´¦•¾ÎŠFCyÊŸÂY™è²1x­³:+}F{±ûS3„™àØl&0jä:ðr¥rw€/ªhíÄäyOUÃL5g7ƒpÎç4˜…ŽàÙFSŸqÚñ àWæ;u r•WxÚ‚Æ+ až¦Pf{ËÙ\QîP“©u[½÷´t3Úê +Š2_òe”›óÝÅ7ùHò}w [Sµ#ß´»¬4÷Ûë,QXW:FÝ‹Š®˜¹Xæé3W6‡µÆ"ðy(¡Ùç›+¬`wCåfûÇV¶ /ß^Çye{óÔgufÚºt9 à=Ö>/XObject<<>>>>/Annots 2233 0 R>>endobj 5327 0 obj<>stream x¥VïoÛ6ýî¿â¾S [±-ÿH²e@ÖÍY?ÉwÅP#Q6WIÔ$9Žôß;’²%­C7 q Käïî½wÇ?{#âoDÁŒ?aÚúC¼á¯ýzÓ †3B³éÜRJÁäø”ÐC¯ùŒÕó™?r{Íjã9¥Éhæ_4V›ÏXÏýqsµñŒÕàŸ7VX6B5ñk:[ éÜhÓxH³‹‘?›Íi™„†´ ½¼*èòŠÞˆ-ªÙ䦟O—ô†4aGäÅ…+¥3Þ–êh›ÈL¤Ò¿ÕQ¼ò¦þ°Oð±:e›³Å„Ø(¦ŽŒwœ÷ ²PRµQ%á³]'û>íõ–R±§È*ª4í ‘c‹¤r§ÖƒµÌd!*ÑõýÚ©jC¥N%™ÐÚ OOD‘â EBñ63ñ–ð¨ªJf¤2Zë¶a] 'ŠŠ6*â𤠭Î~ÌÙG²*)}÷r<á—Ë,$ ügÚDÄu¶‰{áFôêîíòþí’Ž5ÁYû\¦"/}úYïä“,LB‘‘Èódo"°6w¥Zg(‚õúOþaYI]ÖÆGÌã±`@ä„d‹D¿;Ä¡¾g‹Ô'6ŒÖ™6z±èm•o«Ïß¶Ìž´ŠdhnYš=g‹ ¡5#¦5#ÀÀGÉ®\¶¦~kM¡Žd;WfÓªCw1cÊ`%‰ò¸7Ôq¸T„úî)Õ¶+ ú$Ë\†J$(¶ŠÙ‰ÃÑæÓõ6•Y„~=”VU;À:{ÃæmÎ9pÔLdäB™ÜÙð sm.Lû\ykýÑXË¿éÇëS¢>YÉü_TÏÎèõFdk°Â%ÓŽ9Ï2;T¯äÀßq&2ú•Ç>Ñ’åZ« L’:oÓàv#ž¬lb$zÇE`îpÉ¥­¸‰ýÀ/˜ñØ:jå¹ÞÓ?¶¡Õ)¹—­3O Ó|Vž-› {9â•éíc"é¹Oî×+•;2LÔŽâõ†šÝ ê°ÛmýG| ^:yq™Ø8P tRi^è'¬WY%‹Xp£Ô f£ø} ¦Â ê œvš ‰ gô$’­,û­ Á/¨ÎêH5÷'Gv)¶ñ`pÉ6òçºÞ¨&AÏ¿ ý×|]u>vJ©ü+ƒÐ×n¯:d U+xtg^añýðCgÕ¡õ²\jóxì¿™´Ð…‰(K”´åÕ‘„Q¿ÃÄÎ+Óª!ïF»JeµÑQIè>‘ŒUfºY¦¹µ4eŹþ 7¦½±.L éL¼|â å³HóDœÛ½ÙÜkeÔ"¾Ý¿æä”ûÕîÙ%Õûoduýêhqyy|é!(zõ|”“…ÝÉÉ,´d·udá0µ®ƒé²'‡rUØf'Õ›W^÷Xà º^¨LÞšúcøhÌ@7'ÑÆaAКÜ7|p=šE#ŠQW#1Éz¶×D~Ô:¡¯f~èŽlÿFô¬9å³Å¹»SÎ'þ4˜Òì|ìÏí]æáÝ››A€ ø:4[ðíÍ r»{0·€š›ÆÝ™›ËqÂóÞ)nòÁ÷}\+‚`ȯ~Zö~éýGB‘iendstream endobj 5328 0 obj<>/XObject<<>>>>>>endobj 5329 0 obj<>stream xTMÚ0½ó+¦HHY BB€¥½µj¡œº‘zAZ™xL;uœ¦«ªÿ½c;¡ö° ŠbÏ÷{oø1Š!¢'†dmY5úŽ¢0¢ËëK0ßF° HsXD°~‡ëõ#¤ÜyEfÁŸ‡ô2Š`Fæ”wœo—Ó9w׳EÒG_rÈT«œ‚ÈáEµpf?Œ¡R•ƒ9Ó7š³â ùÊÆ ãöþÒ’AŽÝÔúH—¤Å™nè°,c.$ZƒÕIhŒn3CÞÌô½Æ Û«YÙrl\­¦ŬӬ®‘êœ.˜™»ºŒs!‹¡%Û±íÐE(Q3s D–¶ÊÞÏ)‘ì%ªZiš¢5 j–}gÒŒIà6µ Y„9ƒMe9ðh“B=û Þ0À„°Uð«ê§CÔ¹Ùb& ñH]sƒq^™ñžaÜʶAþ仡+]ÃX£dòyßãøø0Læ¹&ZP›c@ =rúø“ßwNy+3È•:dLvPõðI iJI½TEˆ:ï\áÍÁmôµº¾×Ý|{‡¬%É1Cà‚éD†@˜Ö¨+aˆ*©Öç¢è"er$ÔIA'„©Ž%Ë—7šhÉ$åì•ê9ˆ÷IÿÁù:@¿*¯†ïÄô+àûLÚWÐ)]ò77ªþÖ°¤›^Vñf®’$Q4ˆäðm¿›%aUÖV( 3BIË,-º÷ž=úÜ´ÝIHŸïý†ØE±¾¬´ò¶˜Ú¨U´“ýáïIÛ«Oéèëè/aL[[endstream endobj 5330 0 obj<>/XObject<<>>>>/Annots 2256 0 R>>endobj 5331 0 obj<>stream xÅXÛnÛF}÷W òR°hR")é1ucÇ@»±Ò¾VäÊÚ†ä²$e[ß3³”¸J“8iãqfçvæ²CýyQˆMRþËÊ£0ñ ?"~¼½8š¤AHi’*i: ¢ž(èæÈ#KŠÂ(˜yLŸw2æשc§6 RJ…µYÒlÄÏ#¡tcé”NÆ¢4A” ÁJ=²¤tÊÎìyYÒ|L=žGÂ`A÷ è ŽC1˜Î8~!$Š1Ûg‹B>ã(fú4ƒ“0rv/šÌæQÈŠåDšE§PÍF1/<® Ï|Ó…íQ;Œ©é!!ð¥ˆ3¢Ü‘œÌ˜N0uØJ±,è‘Hˆ„ LŸwÌ ¨[Iƒì¢½1e]hòxÞðä °FàLvÀ&á£Àºó½±kÕ¶æî¿²öFulLªŽ\&ÿ£89©Ï7½²*çZú|xi—KÓÅ?ÿ»G“IbÑùÆN’!pü®ÊÑ®™m4Û‚xÂê^lk]ªú)'Ã[]7ºÕU‡Â²ˆÚšªCŒ¤ZjK»ë^sí¾ÚI>}ÏžºPÍ]Mg¶(tÆŽ=ò§š¸Ï4æõ7ÍL‹ó/2] (/1è‹§Íôuc3oPU¹Í6å.‡ý¯„½Å–îM·¦Vwœõ'´xquu}C°û°¥³cSTZoTɃå²m7Žõ„%Æ—ÃW¥ôëëêô|wß°œÌiϸŽkƒFreL¹î”)ZºåµaÔÖ:3+“QëV2•lgAÖK¬!¬RÊ pD_Z!7Blq0/da¹·Í‡>Ýnzßõ«ÞygÁƒ,4x_‚ZÙ†úS8”âÐsa©uEycëZç-ÖšÏnSDìukÕQÛ™¢²ÚÝÏŸs£7¸Dš=™ cùÆvšz­ªé¸Z¤xN‚À ¸Ú¡K­Ý4™n)S¦Ì–5@Ï%$l½Që!–ªÊ4ÛøË6Mƒ,¶TÙŽ:Ýò²Æ†ÂhïÍ-ŒÐv¨„jY¥ÚÒj¶PfÙj«VxèŽtug[qkó£–XQ.Þ]¾zñþù»ÅÕû³«×× ¨³ØDî×ÀwÓr|båVWºQðâÀufsýHÁŒé3 à§kùÄ Røß­‘dV+|Ç3 œê®•E²t‹$ŠöÎÀòÕ½2 ju­Ø]ÈõÃÙv Ð7ÊuãþÈîú>Þ™p÷e?c$ƒCSÁÓûF¡ï9ü­æ*“w‡­[ºyöȈà•1±SwX-7!è­×j@ßφݼ2+îMj´*¸•5ÒÓï‡ðH‘Äþ²ù¥ÚØÏpÌŒÔ*§–[R˜ŽÙî¸È¸•å¦2ÝŸÖš_*Ý¢>î×&[c€Tf…‰ƒATQ¹):Ãï2íí˜ ³l0\ §éÁdt>€^WÚ€žËÄ‘]Ž[3PÞˆxöðHQNæw22ô€üU\?§çx£Æ~¼¢cÂæ³{ÅÂwµrz¾{5…xâþŠrüàý8Á¯;“±{ËšLÆlåÅâè—£¿Šˆo‹endstream endobj 5332 0 obj<>/XObject<<>>>>>>endobj 5333 0 obj<>stream x¥XmoÛ6þž_q3PÌ"ű“4]>uè Æ((‰¶ÙH¤&RqÜaÿ}Ï‘”)nÒbI$ïx/Ï=wç¿Îh†ï3Z\òO^ýº<š¥3<ì5:}÷ŠÎæ´\ãìåÕ- ÿ~FË|:?OÏÓ3ú¤ªº”ôQ鱑ÇË/G§ïÎé GX(áS›.·’ ¹mé¨ gIYrxl½ë®I·UzC¶–¹%(Œ–)}Ð8‰ÿra¥—Y·:wÊh ÂáôÓŸÞVZ¹Õtu<4fÊêä]m'‹´³;ÚÂGa-ûZLs¡)“ÔZYÒdå­l`ÍNìí/AçE¼¡ƒ‡,ó¶ÊdQ@à}«JyW¨2E[J›ŽÍøË´Ð¥9C’ÅH)\ædS7¿ùoC{Ó6T7fÓˆêšDYR¦tYªD!)Û{<°ÞnùœÝšµ5ÛÏ1nŒqÑ ” PâT0í;£4D”Ö²ù\ ¥E¼KÂ-Câ&!Ûº˜=©„kÔÝ)Œ(K­.‡Ñ}oãÛÓ Ç9¼ìà6¡>»ŠéI^ !?«ùå˨«K¿LAdïÍ^‹Jå1BT©»Dé'—7R8Ùg.äaøŽLì•–I82²ø„r£¢ÇràOŸò­¬$Þ»”ˆ×áä_3Jz@•F>㌋‚$,!@­TY#…ðz€y´FGgt•.¸lç\·ót±ÀÅt58@«iµŠWÇ¡ÈØHÔßýYªö‰58Z„À&\f4IOq}ÌojÍä|ððœôå< WÇt äßHû>ÔÞ†ëë.†ÞnÅ4ÁÌ¡ich+›hïí"½>àÁorÐù°ÊÞzaTà­B¹ .«Æm9kó›å™áþ\4óÍŒp–yç¤f–Dñ#‡_#—$¦E‘ÈE oE¾¥iK@ek¨hLíQ5@ѵMø?O~ÀZæN-cæÎ»ºT¹r%ÛÁöÃBƒþp"ñN¸A¥ ë°Œ/² û9_âekc(Í3áí:WDý‰""œË¢mP…!ñ=Cé ‡ƒkǧúlÝw¸×%úˆNÝÊrâ}ç*ˆæšÉNyÖÚ3ÎÚ”¥Ù11…À$vo¬h+ò›çb%*QƒJQe…Àv_Ñm²¾`iðzñ}ðæüü±¼m©]dPpT*ëê˜AFôPÛcÙgÒåY“£$Jð×F¢¹1Íûá#2³um Ö©ÆÙå8ChÆmxÚç;89: ­¬T"Zg*±QÌ…{RkŸÂZXp·dŠ;|nª $ÃL‹"n6m…¯Kl^±ý£ ýHà[í2¢…†BнÖO xdçÝIJön¥¸gtG7‰ª‘¹3Ížß÷XóßZA=Fš‘²Ä´Rc}à_ïwõz9Pß§ó &Î0mòÝ<ê<ö–ÂH«vt£1Hñ0…äùæÊ3ëOzã{Œ…tø‚YñT{xÜL†?r~uê¹£BÛÖ5 âaª4Z†)n &<*[I°’Þè/pFôÓ(êCêÇе@$8ïO—ú æ•ÿpUþP[¢ÿÝu¦•_FAŒ÷ §1ûì jÅì°Xxn%^4™r˜y0*ßVx‰ŒŸ®ÆÑÑäA±¢ûœ¯Qƒ¼PÔ%â4œd3év6kYÿ$ApÚ<Û<È<ƒTiÇhé÷<d÷co7%'ó«ô%ç ¿·|¬Òí#-ØÉâÎópŠ ¦xY`Z¹Ùmã4Ý*6Á†ã; µ€} çKÜU0©g¦dÁªy)싽ó5÷À®J6󄘒ýÊy·B•<ÐÄáö~Mæ~ä÷ëëœ~¢ŸÙ_»sq_ä+¾´èA¾xÂNÓíµ'”µÀ†ë¡k4‡IT”êk¨Ìn3¢ŸY|¡¹»0½2,!©Ñƒ±n“—CcÅv•IuìýEèÂÚÃófVžä°Î> š><ÑÆ5¼sv¼Y`mˆ{M…å]ñ²Œê6ÛnÛšÏÎÓ‹Å]^ÌRþ¨À/ãÉ"Ñ“ûvä]g?Péálò2àô›&\Ì.ÓÅŸ$@~»<úãè?;endstream endobj 5334 0 obj<>/XObject<<>>>>>>endobj 5335 0 obj<>stream x¥XÛnÛF}÷W ¥ÖÅvœø©Eâ´@’¢ˆ‚4…cE®¤I®Â‹öë{fv—²¨$Z$°-q/gngÎðóÉ„Æø7¡Ù%ÿO‹“_ç'ãdŒ/ûÕšÎnžÑdJóÖ^^]Ñ<“çcš§Ñô<9OfôV5æ^Ó«ÖäšÞجůצ¼Sk}:ÿtrvsN¬çbÞ‚3¢w~E©*Iåµ¥µ.u¥M»Jm·º¢Ôfššj(³ºÆ¢ŸÂ…»"Ói®°Ëز&[’iðk‡ß+êlK[U×øNö90V`DñtÀÄæe‘;õp E¡Ê,ÎM©Énù²„׈)¼mXP© M¦¦Z7´3Íæ«WoUz예p Qþ0¢:¡wívkk-–ïT ³-ezŨUÀǘ"#ùô1j6H$ç™7Ý#ûsÚ©®~îξðBa¢d8Ï^Ke:óe&ù%°Üåµ\·/µˆøÆ š7#\‰š²ÑÕ¶Òø‰ë=”KEÛÊ®+UHˆIN^š23åºfHqï¬zÃÕmÛÆmÏÌj¥+¤ Xè)¶y‹}á®Ú®C‘\W§Å­)Msë¾ï£y”G „ÚÙM_ØÃU}NìW|5V$Á!¸ÞbS‚n eÊEtTLó˜\ùÐÅO“ ¹Ø-¦—O½å!°ü0FtÙrϤ>8Á…KŸMáÌ­ÊöyéwólT…@£h*U§„W¢~-$BJXÇ7ô6ª¶±¸”#ÖùÐR©wÄJƒšCââÓ¨}Ê'“Ù Ÿ²hyî)ºôŽÎF¦Ñ;%g@ˆØŒ§ÎŸ²™7^_ûëøîÀ[Ìœl=x„ªÒR)ýÆý’s£>±ŠîÖC¾ÅþïˆÀ§>*ÁÍ1›1%—ˆмÕ;”ˆ+”h-F(OÁÕ¶³0´Ê¦:k+ ª¤¸}8g:Ý;‡ãë/.ùȽ?’ÚŽè1è!÷‰6ådºB ¼ó÷ÙZw<½Jž!@¡iÛçôøû„=~ 8¨soè›kàÎ+ 3d¢¥šÛˆ•:ŽdùÄ•JMnšN4è˜&/¢€cÖ–ïäÆgj–ª¢ÚZÔ.!.9Ž©Ð'YwÔ/ù[q%„‹ÀeèqÀî!þW9‘7YŽ#†eü¨žˆ ;+~ÈÍëÏû>ÐÔ]órWõL÷ÝFÎîªôç- }î+mC|+>vºI|.ìØO¨¶òÀÝ5<›n„O\O´žkD‚ù§[Ä¡è]ºÑPF+–‡Ewæý|†êLPµC‡É ¼æ%CèLNÀ=¦%üMÌEî«pbtÜ6P™C`‹ÐÚÖPÎü¹@¸†rༀ.~ûžI¿±6‡`NÛÍX„ñâ4¡ßWˆÁ¡9ü+Û"î,ŽøØÞ‹©ÅVEÍçÖ]±Ä‘îÞ>³zn}Ìúa;þºõÃUÇÞ÷¬=0ÿ‰@t½®c‹\þ>‘|fô¡3ÆÞ,å&¡¥8{ÃEQ•q-þãæ âÈ@ )FåæçpgÉ¡ÄûÀÒØ”÷–©ë›úßôãüðÄ‘V˜‘0 •¤¿0ÝâdO¢Þ[~YĽEÇÚV†ç-V½^¸„^ÁPt‰´‰ úÍ.—¦9ñèH7‡Ëm Á`á|®¸žf™g8 p~cÀNUô’Å5‡Ê¥nM£–` æVÍËŽ6åç£éb¹'ç,}Ê»Ð!CWïC¼– ÕÇεž>$™FîœQïrÉ%¡3m-]ÆŽb?Ռ˜Èû $m“ g¢:øïƒøèÉì±Ô°Ôe— *.Yºýú‹‚žÖOh ß\†ohzgÖ;»Zhæ<8Ö&&ÀÁ`œEß[í§.޵߹Ÿ7Êi'Ó¡‹qÈQW¾=‹|¿?-"ŒïmÁ®vÚí£Âø–*¤‚ ‡:àù"—=ì=‰JÅd2ÂhË!æ«n¤Ú¥!ˆåë¼á)x>ù+ù˜ü-$²B_+3L×N¥¸6†Œqúz¤ãBÔò¤™»Ñé(¯ò D=âvéµ;çÁ÷Ò½@ÆP˜`ðl_ò®Ä½6¹r¯MP“ô^–¦œ-7V”‹síƒ|Ç:yWí׊å‹0ë$UodH “1À•„Ðûƒ(+TGëÊî˜vÜtïøpc@ ð=ü±r(úHµ Ô0’š½”¾ÙW ÔÞ€-òm¬€’Z©Ê†§é†Î.ðÆiœœóK'yaÏ’1½xØßØp¤ž[?å÷;Ù¾–º_&³)ÞIaÇlvÎ'½œŸüyò/ûÙîendstream endobj 5336 0 obj<>/XObject<<>>>>/Annots 2258 0 R>>endobj 5337 0 obj<>stream xXkoÛ6ýž_At- ¶êwœvئI í²ÚÅ0À@@KtÌV]‘²ëþúˇl+îЮ) É$/ï=÷Ü—¿œtY]ÖÑÿ$?éÄ|C]úøps2Ä=Öôã3–³ñ8ÆŠ}ÉØädï5gÝÎð`qÿ«ÝsHØÝÇêp÷÷W÷Þ±z>ŒÇ{«¯§{zZeËöâzØtƒFçxH­xH¢TÅ^°J f–‚Mþ¾½a©,EbäZhv:ýtòâ–Ùóѳ‚çÂ}dFŒé£}¥8¶Ó(¦W"‘‹­½ì¦’™`´‘©…ýfSòÕJ¤lQP@Ú _óRòyuf‘öþkw{°$ºüãâýÍÕdv;µÎF>/XObject<<>>>>/Annots 2261 0 R>>endobj 5339 0 obj<>stream xXkoÛ6ýž_ql€3Xª_qì°vY`]º:ذ!@@K´ÍVURŠëýúKR²äm]¶¶(,‘¼¯sîƒúx6¦þŽi:çI~6ŠGxÃÿù¿w7gãå4žÒ|±ŒG”Ód´ˆá)£ÕY÷«³Ëþjç«óËø²{¶óŒÕå2wVç‹xN³É(ž@íò rýkí<æ4žãeg±ûŒÕËEµó ¥ãQOð«ûN\Ì–^|?£ñˆî7Õ|‰©‹~$#K#­,*Ul©ÚI’ŸJ™T2¥R«¢’†ªC)cZII"³š.îßwT¸ CÅàGM]D•Ê¥;BÉN&¤éïoLÄt»qúV؇#zýj©ÖB÷^X*tE‚V¿ÞÞÍõÚÉ¡h<ù}«%:/E¥Ö™l¬â(Ÿxñ=ˆà\ì.¶{ ³õ‹M\p;‘e¥tAÊ’ VÄ~Ï’X'Ç.šÌYùd_録}1¼eÏxÓmAR˜L!€OÒX¶¤7Î!½nÌ´´—k@€ëð<„ÄV XxWTB  ü$R™¨\d8V¤’÷°dÆ.@ÆFÁª'‘Õ€®€dÊE±Í ƒƒ@…Èë·–nj…À‰,Ó{¸.·Êv–ZÛ¿’ÕQ‚-8|ÎhØszX‘äìÃÇ<¯“%™E@¾1£u8!È;¸¹–ÑÎË øƒi)ßÇÄDJ%Îùk<+›ÔŽªpŽn4[ F.ìt>»ßixã<´x’ñŠUŒìF‹…ª”ÈÔ2Rb¤¨¤¥j¯ÑÀXÊÔ&¡²  ÕN°9"c+Í U…¢„ÒVTÔ’W—jI‡*ò€suôᑽ§:;ËŽP{ø £ë@²Tf²Ýë"áZ‚Þ„Äu¹Xq½@Ó jÎzõ]=.tïk[õ,J5üã¶Ã‘$›äÉc*7ª[[¯KFXàŒÿ«5L.]Œ½Ót³GM›ƒ›£sÇÂP z–ºh6;b°ÄMœ‘®G>¡V NmhâJQVóƵTš>:Î"_wºf(­Aû±±Xô˜¤Ê=“QŽ¥4pËýq‹'ºó­\ï‘®v§JWB¿,äÞ‹þ±v `b±—ŽòhTµÈÀ ÎEéJ,DÑN0= §©;[×Â|AèY¶“‰¾‡S{UíÐÉÁÇ1âY¢rê£!…„| 3Ùïz¹ïü ßÖÑÞtÝÎ ?À€ Xçiþ/Ü’œ;‰NQxA*{:”0ɤ1ÚIG 6©I†è.¾ r‘ͼ,ñö¥×=¢¦\Œ)x:ÅS: ÷çÍ·oœ%od®Íáš5Ý’ërQî^GΒ󇋯›ò¬ø·wó,ÄËPú™çßÕ˜6syâÏczä×Ïr‹ÑçÓQDk¿~¦ˆ{«+!øÁ|{¦„ïÔ“âÑîÕáwi4ê=IÃëh}ˆþÀ¿Fô•wƒÖÞZãåèðú™Ö¬˜»1ñR¬{ýL¿ð´ØšÑbë†ÈgŠX¹©«#£1ƒ‡±¾Œ#á#GÛi<Ÿ_5ƒ*¯¨³ÊOo\è,.& Í&ÅŒÖÉ­BóÜ¢.™Ôçþ¦ò£Z¿hÓ'V®…¡ò_²{IoNdêfÔ<šº‘õŸSÉ*žôæÊ W1ÜHPÃÒÅ­À_,šD ÷‘¨„¢T'þµh®)Q3ÙW6úªØLª8t´‹g'”4×dQÑÛ1)ô?Ö^𮉑¾7ja²ký¶j[øñ„ë«‘˜T Ô[0ÃWܽQn`ÆÅ <Ãþf™¸«‘/‰¨ä¥MÿÎ!× îð ó ,öÓ¬ø]×ÝRŸZÚ ¸×7û§ë$þmõÐáK<æ©ë;Ñ8žÀå(Ð÷áâ%ÝDx&ñÊÉÖªr=›Qó ¤nŽ ß3] ~˜ 1¼’æBËkᎇ§Šþ‹Ú±k¤fkóM¨ä'žå?cDØ›dm0Ƀ™cã9Õ8bÈÛî¨Ù à"ÁwP ®ð×€ÏGoÌÚ[$™»ÿì’‹;am>DþÞcàû›®©HlXÐÜŒýÐÖ&YŸ»œ¼¾ xPÛñ:P¨Av2šÅ—S|LººŒ½*ΊhŠoTßu“=Bmô›£+æŸÿAïšoþB‹D˜¿Á2ëï@|ør4§O¢étί®ïÏ~>ûh îüendstream endobj 5340 0 obj<>/XObject<<>>>>>>endobj 5341 0 obj<>stream xÅX]oÓH}ﯸÀîR»iRJ[t)BbUV´/‘VŽ=IlñŒÛFˆÿ¾çÎØãØI»­´¥¢ñdæ~œ{îÇøÛÞðïˆ&'ü›ä{ï¦{£h„Eÿ_µ¤ÃËFš.h<¢“³£èääMS»kDÓ$˜µa®Ò:šfLDxF©Jê\&6R³ýÙþþôËÞˆÂ#œIqF ó¤¿)\HÐÛGög$ªÐô”¿:¼Œ[{>àÖ¼ÁÓ]B[ý‡—ÇÄ,(„3áxÒ8ü¾i-iSÉb©)‰ š ‚ò…\Ö•H©Öø‚ÌJЇÊC]ŠD.dBf]Š<.)®–ÖmëcçÔ€ÃYÚDt-ÄpÛ'9?\²äÃF Žäà-TÅKŒå˜±L…‰e¦#·ïŒŽŽ£cv‘<åi0>Ž`ÇçJ%"…šn¥YB`D¥ûòùÔqtzÊÇ.UEËLÍãŒnâJÆsÄ瀮ÿúø’JÄ‚bbD2A·U\–¢¢²U2tm8Eq I+Ò-{¤è\•Ì«4«…cN¹à€nW2Y‘Ôb:_~ý¾õž[˜;,} >åÖº »üêÒ´ß¹HF":° ÏÜWöÿ×"¾ºÎc0çÆ/WoÌÍDÔáZ(Ó‡Õ´…¨ÐÆÓ›ŽèÃÕÕçkž îÖt‘ÅZ‹æ7!`xŠ3ÔÅV %îœ-avsÓ¢.®éÚ‘K§í3vºz®éjþE$&¼ª$FI4!°¬â<çv~½ÖFäH#kÛl¿í\n*r£DcBQåJj#v•”IÚ–…­­º”•4¤öéíHôIê²± SvñéêºÓåòdªH<50éº,Ue¨PV¢ €¯ó!úÎÝÙý숢¯oå2¢)ì è}âŽ%ZYγvÞJÅB¶-j´jœÙ¶qÓ_}¸Ýˆ>0%ÒIÞ§G@Ëc"‘7˜*êÌò–b´ø/EÑeèi¹„©m´Ð`<Ç\Ð&¤ƒ©å\.s™|m§À‹/i%‘U²Z÷u½çpòn'¥ (ɼÌdsGÙwúrQQø7g3eÂ8I„Öj8‘³Þ¿u®æ@¡ï‰#ìêÐg-H¤ç,ÏIÈÚi ìw ÈœÃËÓ¦±G/'/éOÏl†sç'шz/TØ pÖí_¹”Ç[†³î•Dÿ­ x9:‰&c¼Å@á˜L^ñÒûéÞŸ{ÿe9‡9endstream endobj 5342 0 obj<>/XObject<<>>>>>>endobj 5343 0 obj<>stream xåVmoâFþί˜^”Æ‘bÇØ@ÒÜ)R¯-×~h/Uú©Zì5l1^nw‚NýïÙ] ¤—ªê§ °=;/Ï<óò©×‡?}HGte«ÞûI/Žb|Ø~©9\c¸R˜Ä0ú¦F70É­T “,˜+¶äðn,å=œÝ‰J˜P¯ä _¬•X #žø¾ çÜàÏÏuiÞoé˜.¥ /@oÄüw{䂾§— ¦—ô¹œüÑ‹!DÓ“<˜9/DÅÃ7 ™£§ð¡¬5ðÂ}+üJ·ºN˜äÏk©Œ¥½÷Pö”8/®Ç 7 ëz˜¤µ€U9lDYÂZɼÎ8Æ Ç hw$9bZpX–q­¥ÒN¤Ñ€Ð°fZó˜†ÿCT¸jìïg-L’(M1‡{f%žöQMƒw”€û2Ì'+K™1#d…7$> ejVZ¿1; à$Ðä´›zFÉù€ææ+ÄdŸ,,ćš~ËÁacýòØkðóD \ aÒ “cóQÛ ÚûûÞœÝU|u•Ù˜w^ÑcäoGü³“õ”A¾·4·µâhÞQG¬Ýô5óú‚éè:éË®þ^ëÎÿ¥¶ »ëqË´àˆU𯫳Ù2VYð fjªàÙï± 3™sçÅ Õûö-TÒà!QÍɬw,~l)X)ôÿdú¡YÕI#Ss Ó`0ì´YWÈ{}™Ž^°#ŽÛ·%ë =ÙaE"ƒ£÷®““oIÛÇ=ÏéÀÍ^'þG^Ñ4éÌo~? 7MÌÿHFÅn‘›þ%`÷%ðXâ)È^>¿H#pä˜3ȵJUgF*@6Ô+^ä’â±R m€È-bìáœÂŒk¨µ šÖ…iù¶Ô’êÅGLfÑ/JÎq(;Õ4È,«Uãe$ %[0 rQ\ñ*ãŒ,þÌVë’_ým¡ž¯pº£õñ¹u¤;ÿ g¢ÊÊ:çð¹-ÞÀùŸ]Q•¸äÀùgÿ¸¯¢2 åŠq2Mƒ1VÉ×Xšp(EÑÁÑÆ‚Sul°ãÝÁI»×Þ3¡F…—¤Çß~úàðÆå“¿¤¥d+kjkÕš7Â×7Ðõš6«+˜ÕÆrbÎ+ŽÁ†øáãLJG§ÕÓfJ.yÕÆeiòˆH::9—ÛªA©I¶éà:Š›ŒÝŸ”ï¾6ˆGÿ8à¶c½é l“uõG±ª slw¶oýN—ăh˜atsKÔ$ƒaÅð½ÌléY"Ò„ÛI†7.YÉ ê÷="J>oá;Zݸ­»a<ŠÒ×xÔ™¦·¤à‡Iï×Þ_ª†Iendstream endobj 5344 0 obj<>/XObject<<>>>>>>endobj 5345 0 obj<>stream xXmoÛ8þž_AôPÔb5¶“´Í.Øâ.‹·»=ÔÀ}1°%ÚæF½"•—ÏÌ”%ÛÅâ7G"‡3ÏÌ<3ÿ.fê_3µ¸£ï¢¾ø¼¼¸Î®ñ0ýj·êýÚ]«åkï>áCÉïñ¡˜”zcãm”ݨËåŸï ‘WOœ­õC׫ÉêR^EAµÖÛjåwZ eüø`íO™ZâÅV7ºÍ½.Õ/¿ÿþõ›Ú˜J«gÛU¥ª¬}T•yÔñÈÙ‚4œ_«é|ž-ø¯œüðC–e´‚ž’â“•h¬§µö;[ªUR’>>›í®¶kÅJ¬.Eml&ƒÊ‰Âš}kjØû¤ï£u´±²~Úêê%¼#9$!ɾ£RQåÎÉÑù#Éú)íŽî—giÉè€Þmdût¾Èîî>¿Yo ‚>÷á4ãTçspŠñ OØ-ºWlÌ =óVýÙ9¯ög×EôƒÃßšzo[¯Þl¬Ívo¾ãó£Mešà̃ ©lñÈ|ÿðIÍæƒÓù™1¿Éf³l¦~ËkÓlÕç:í†G’Ù7Ù ­þÙ©WÛ©"o”ÓZ™†õ×/y½GPåkû¤¯èb2ÇÏÞzÝx“Wªñ…m6•)¼<NÞU^é2ÐåE¡³­BXŸ‚Q}ŸÕ›¨§¼5ùºbÃ)Ì`a9Î82G w‹&´”r2é¹Í÷{ݪme×P}ƒÜãÔ„Ä‘¬­öÐèkÕ›dê‹Èm˜"@8@÷ˆsó26ÄîãA{1tG¤P3¦´8YõÍ«*æTÞ”ªÖõÊG­z6X³†3Z½×M ©ÏÆïØRÉ’•©o–%ÄmŽ8FfOÇHòñp èYuÎ˪¿"*>¿ŽàÉÔÏ•³WÊœ†vkíÞ ®Š?ßö#$·]€¤¬ŸtË&ˆMI±»13b!ÒÆúõ(èôщœ8‹Ëg«¶xwZÛ²«4<…ì(ZÍ´ aßþûå—H-˜A–)¤‹ÏMÆ@X&Î< zG1K1ÐÇmyàzÄÃÀ1QÜû 0€X€¡!¡ÿ ÈŠ—)« GŒÀ™êÒôߦyÌ·:(;{u©ÂAž+jç»u”ž‘5Ж\„¡¦aûÑ ãÔ…=‡(3Õ8Ê P ¾ l¡Þ%:¹Œ(a 8)ÿoH•Þ¥—Ø7í2ÜÆ DZ÷¹¢: ÷£{iÚ—Àq€ÒÁHÈ-;w|" á#{º‚,¸Öu{žKZýW‡Z‡•¦!Öix$”B€Î€qàñäN ðC­R!·ŸËM*Óndz+éš—>'¤©$zÚù•›®!>N Ȇ{÷Dã½tô]^H6ô yçmeó½#r„&ÖÿJ9 b„ºœ¤q„ÉëydïyÁíÓ¡výÞ0ñöãçDb¸YEÞˆÓ“îäB5;dáèí>rÀ9ÄÕƒJZPaa'e_ S=CJÐn‡N–Z§u›·¯WdbR‡ß‡ÎOãJi_d«Kaè\o9ðåá ÎD‰pºõÔ:¯§ÓDeh$“K_ÊŽM•~7ùv &h€Y‡ 'K™“PRÄ,£]ä­9³+Z£{ÄÄ¿§O´ˆ Ôï0 Þ?ãJã3M_C?KùJ}3õ…(eçúÛ{…+†pÁ@ÉiIûœŰ½ËÃXflŠÈc¦w¦ákŠáX–¨«gØ812¡ÇI3QÆ•Æú0—T®ó§ð¦Úlw>Uix(“…µ ÎÇn"žŠLJ%„Çñôp¸‹OǶ„Àð€“qPÇÑ{])(§BAÉþq¼Ái:c5†2Q2D˜Âý˜Ü¦«$ñ‚\¶°ý¥  ­în{áï´:TQ”fOÅOÆßï…ûÿ•_!;NñØ=ûBzúF7)¦Ws܆Éëøvöjq«îóŒ×|ÓEv­þi ž¿sºå M(h7Ù-ÖN?HÑ<{u{}—-æ¸:Å™‹Å'Úü¯åÅ.þéж+endstream endobj 5346 0 obj<>/XObject<<>>>>>>endobj 5347 0 obj<>stream xÝXmOãFþž_1BB5vÂË}ºª½ëIWAR¿DBgílk{Ý]û‚Uõ¿wf_ìØÀ)åN§¶€ 8û23ÏÌ3ÏäÉfø=‡Å’~’bòýýdÍða÷Ke0}wóܧ´hy…¯6f¾H‚zËAo™âÈÅZ1ÕF'÷¿M¦ïfp-hS<ƒp>‹ üogRVŽÿ„UK¶ ùcÍK-d GÑH¥Œ´<‚#¢õCÑ>rÓä\?à›îõÑêŽÿ²WyóBº*^DËå]u«pWÂ5©Ìs¹e‰Üp`µyZË dj^f¼äŠÕèÇû››Û;È‘óÐ^Œ¶îD½5ë¼w6"AX±äw–q(Ú©³’VÏ1áO@ˇÆhHQ°’âV¢A*k ^ÖzuâoØ‹_ûø­‚ Oqƒ?w-¸‹ÑI¹:±P$©àÍp1ßÅ“Z|âIŒÊ–+îM5+¿wœ½x4Ú›©1‚ˆ;^Œà#r«àn'Š¢¥7yúîÜå™r>ï€dZ“ÙEiBm°1?tݬGQ½†ŸÐ¯SUÉ îáu«!ET1ae“o`ÍÁÇÚ¡ù³É³°R¢©·.p¹`Ÿ.½ÁÞÝÖñ6Å«œ%˜^ÆúÝSíW 4dxQiS¦ŽL2Æè&MÅãøHŸ3Üã>“×µª*ãþ°,ÓtFg, —‰IzQ>—ÝÇ:Ùò¤IÏt™t »­H¶h|žÓþ’bÊ6t-!oöãÁݯÞÛŬ©eÁj‘°úÜ,ȈCDQIUkèÕ†TÉÂéèŠÁ(IZ]h‡–]©ÁYâf#–i@ìÇQê3V亵bºS¬/hJ̸5Ó¸ÁIOu©ÈEÊ\‰ªÓ-fX¥Ë:µç§ ³)7DË7«“>¤ jâbT=F±ÌLû²ÕD‘„$Žçg+5ŸÌ0¾6ßõÊeˆ[ÇycQ o -´”dÒ*V6Æ£ZµôqÞî¢j°ë¡ß)VU\ÑÎhT­š*o²©}ô§æXƒÐ’ƒö†^Zzv™FY.ÑŒîógŒ“þƳ³è|qËË3JbJpÍà™˜ p’’%] `W†VÝÆgNÒ±é¬è/­9Ÿ-£EŒŸüàI‹³=úñ~òËäo]d‹Oendstream endobj 5348 0 obj<>/XObject<<>>>>>>endobj 5349 0 obj<>stream xTËŽÚ@¼û+úÉHàµÍ#›ä)V‘‚6ÑZÚ —ÁÓ6“Œgœy„åïÓc0ÌJXvOuUu5¢ Rúd0]„«l¢OE”&)=<}™î–sÈR(*ª]¼£Þ½§›2^yéD+Vš{‰vTüŠî–³c}üŠ}‹À±EÅQ•-lÐí4‡ ,Xß¶Ú8ä ,µ|a aŽATp$’˜eW=@¨RzNÈ+¡„ZYÐXÝ ”’Y‹v¥0Ér¢3Åo篟#Q#þ"‡Ê覇'7¯™ŽÁmjTh‰…‡ÇÇOP ²¯"ÙC©F;!% Q;°Rƒ¥»PGn¢9êN  –ZÉ=´Fo$6Áo·e,ù†ÿÓÔ“`÷ÍFK{P=dz[ê°n è̃Æ[רåÙÓèÖ1Ñ™ôÙY‡@äëÑzt(?/ÏžœQNîÇðôüí¸&J;`Þé†9Q2I®àKH9B¶H¡ð“ ödxoÝ%§øM­u{ùQ.Â`()!ŠWéáÛw-»N•wžFÜ1/™¢™;B£Ÿ³E )¾¦ŸÀ:Þê©MŒ H¦jÏjì×-´=qÜ…¯ŒÇÇÞÊûãÊåé,™Oçp?„&Ó$…/ºô ùKFj@'}áämØUç³$Ë’¾ õ[¨:ÔÌÓE2Íéo„^Og]f¾ÑÏè|HUendstream endobj 5350 0 obj<>/XObject<<>>>>/Annots 2315 0 R>>endobj 5351 0 obj<>stream xÅYËvÛFÝë+z©œD4Þ –Žcû8sìx"M²É"A <8 ÿ~nU5º‹±ÉQÈ9ÉQtuQ®êª®îüç"4þ MœÑ¿«ö"Xø ýéÇÏo/âl˜,ͱiMž. sm¹$anYà?âòˆä∹0ÈH‘·&Œ“EªX “ÅÒdŒXTaˆæñ¢Ð¬Â­‰‚å"T¬(Æi-aÀ2Ÿ<f‹ÜdžU˜2‘#E?Ý2#ÞË…q€èyRùT´ñ‰Ü©+-GÃJŒƒ™¶iÕþ¤!âãY>…">„qÒЬ+€$Äi’àôœ‚PŠYJýQ®0X¡pȳ ƒÅq$«0Øe„Ý©d¦½KǦg%F|:#FÔ€#\¡6¡ÉГƒÅ‰µ:QÉ%\4‹½<Ï•„ ޾ÂÍ©«0X ª›4–Bíf*ÔS)ÒTã5K(ìt!¡pǹ‚0ŠCûÌ‘ƒåK± ƒE®Y%Ë¡àC¬,ÝÉ“æ˜ìzVa°|+Va°µ Å*ŒPàPC œfEhG”Ê)$yÞBmHÓˆ'5&‡i(R,ç]%–â/ˆó®09L¹R¬È΃Ú(X7HH çI‚§HA¬YahF "ìXJ³ ƒÅ"Ô¬ÂsùxY)§Ùn”¦ÇšÅçy‚áäÊö`» “WÔ«0ì"5¹b5‹È± ƒEê+ö‚ìjÜâ( ( ŽÕ,OJŠU,n G² ƒå[‚’U¸Å¬Qœ]›Áyb‹©'„~bS˜rD¡bÆz¹YzVc°¸„ÇJVc°hàØìήÆ`±øìX)><Ðí©)ËÉAQVc´…ZþRRï1XnžžµvJä[vè=ImFûÍ‘CXæ!SÅ€MzÁŒfÏyã|¦8ÞÃótÈÃ/Öé!­‚ÆJÏyE”+ÎC—!-Çöæ¡ÎŒ›7)ò’=:<ç!¸%]+=ç!ì¡÷â¹gng|šÛyÀµ‘fZGHnŽx9Æ#rc 7¥ ¹Á÷æY¡‚ä-ÛÉqΑ"ÎB¢@¬”U ¡-—†™c17§P“¥ƒ‹IÌqßߨ7<~ȶæÅôjš o6xîËà{™›5?ôæfu¥æú×woMÙ­Íå}ùÍÍ¿•~ d5h ø~C…W`“4ƒšËŸî«á¾®>Kyã! „Å®r,¿­/‹²Üÿ¹úú*$O/?US·uWuµ'9ò@¨Ÿ§®«»-/àXãC„øc<ûú ß[S/×ëz¬û®lÌ«¾m­¦î*óÓŽþÈn±Iÿƒƒæ—ÿ,ão«q¤uŽw•êíÝhîªr] fS7o—û;c¹»‹ÝšÒ¬]ÙÖ+Óöë©©NòíÉ衟†óØûÁ.ký,ï†þ¶©ÚS'Wâ[Ò>r&¹W.ðŸêñμúöÛüû©nÖ´rxòkÝ­ûORof3ô­ù¥ÞO(‰ëqZ×ýãî¡á&¶ãäñ äÏmÊnøðþå?^ÿ%;WRºBI²õ…$ÈMÁÍì+:SÌ­é¥iwös[îQ¯^ IæÓPîv#¹é{Õ{.™ýwfW®~/·Õžs¼­ºj(ÇJz¯Y5å~òŠ~3u«³´­¦¿Åæ¸Gç.QI§/¤n?–Ýxj;¯»©¥¤Íßçøe×w‡¶Ÿö¦Â7OðãõpsØUûrSÁÔÇ¡ßá°¡éà Öhafêδ¶ëºÝ5Ï ¢í+™mž>Wðvù±¯»±ž°Wž5A\ô§áôEˆxž.F­¶îFѯN=ŒÌyúÎ Õ¦*XD//‡¡Vh 8ÁO]Á´°ë¶F3oÅÇÇ ‡Z†xðNúu—±(ãÉéÍ4à2 ¯cY7{éVòå9Æ—Á ¾ãf×VëºæÇï¤WOJ_þóq¹mË'„úï¯!òŠO@¹û|ÉñÏ>ùúÌÎàó߃îÉ>#ï«¶Gp›Å@JÕùø–z °þîùÐ=¿àß}M³~†Œ+~Á2e—Ã-VhV}ÓT<úžt¡´UvCÕ–tàšígƉ¼G´ùÆWèV˜Ì¦@8ב•aW6tó>©·×0€ h¼èMampyiꕌ·=a dãá/¹ò̉'B¾U!Lç.hÆ×¦|ÍÍÝú_=ÁŽÖ‹7î…ïè…¹¢s9ªzÙMñ¤ñvÁ—•8‰¨š_ß\üóâ0ÍUÝendstream endobj 5352 0 obj<>/XObject<<>>>>/Annots 2367 0 R>>endobj 5353 0 obj<>stream x½[ÛrÛF}÷WÌKj½ÉJ&^Ÿ¶ÙÎÚ•ËîZI^ò‘  0([ùú=§g0s˜¤j%t%eëè°gú6=ÝÃäç'™›àŸÌsþ»Þ?™\Nðþ‘ñÿ~õd‘_NÜ|¹ÂŸ{—e“ËU@;÷ö‰b°ùâr©¬`°ÓÕe®¬`°‹ìr!¬ßv±ðÛN&—…›²mC´°m+˜ O¹mdýÂóYXxÆ… ù…¦Æ³Ë¹²‚¹°y&Êz8+taC²ðÈΖ—S7O¬`,¼œŸ°~á)‚ p±®+‚­J¤b°3:SXÁ`WÓË™°ÅœÎ}Øá¼,n*‚ÙœÙ'ÍRÁÜ4­CÖ/›ù°. FÆ€-› ‹ŒËFR1ع-YêjE÷à²!˜Ï™À‘Tì—EÀ#kËÎV>¤øká<°e¤¶ô^"ƒMa‹°‚Á®rä`bý¦Kî,Ë‘‚3CÜU1ž 0 »à©VðÞå9޹°ŠÁâ °‚÷®˜pqZÙ«<5$”2d* †Rˆë +˜e\8É †RÓ&±–L3Kã½Ãa‚ pW{ÃºÈ Ä–ÈWXšHžêN:Obe „˜‚æüH*¦ËQÅ`—–/IV0ìœ,©od{/ÀÒÄÂ+#»Ì™‰‰ ‡á„Œ°NOÍõa-ÆŠfÙdȇ5aš;£¹‘õ¢yJbøÔ‰"©G QüQM¬`°Sócbƒ³Š¬`°Ë%O’ _d¬î‰õ*OÆ‹ÎB`È«œ0U6—'V0XäœY[xºò5Ï–Q B0£5‰TÌMYú… v>5‰õ›.Ã5SWnjÈ[“0DíÚV0؃%¬`° S9­,¬9\d#yN_DYÅ`§¼·… vÎ$¬`°X®Š+[¡˜âºá™¶Êà}!ç}J'ÚÉy'ÎCŎ̉‚a*®d¨›XÁ` ±‚¡.V*„õÛ¢=²–ËocH¶ÙiNK+ÛZUV0¶Í̇QV1X+`IÖ+e×@¨‹SÔÉʤ‡Ø§ÖDR1Øœ–°‚©0»ÀÄúMñ‘PŒÁ›Ž‚ðüIÅdíè›°ß¡‹¬ß4 ecCæ~Áµƒ/¬`°è ak’ v5cÆ$V0ƒ³¤A‘U g?SV0X„u$É kéXoîDÚË©Zkí¥‡4vNWDR1eךX[¶sƒ­ãA\vä2kD©Ë¢5ÆpbëPÔ/kݱ‚iQaƒÅlŒÀ'YÁ`m‚V0#dIeÓ|I²Þ\›a‘R¦qhbSë„xÄ&Îb+,Æh$\bƒÅ¦8˜‰ ubCa< #«,.]Y±7VYo¬ÍÆãù‰ƒ²?? ÆFR1¶>Ÿµ'¸B0Ø9[°ÄúMm29aǘÇ9Y1E-8‰ I€²šXÁô„ÛÈ*‹Ó„TM¬`°è&ueŸ'0Ü U£¬b°_½Èš¹Y˜ü½yù‚@ó#kæ +æZƒ)¬`¨lW^bƒÅÛdöᾊÁ¢)+,Šî‰¬`°(ßs•Ì+5‡3’VÞ6“‡î"‹ºuÂØ)OH"3/X„LGñþV0¶ŒK¬bº‚Y#¬`°H¡¬`Ëò—dƒÅJj‘õм[Ø ÏsT ˜r®j$'¦bKÄ&’ŠéÄSQ¿exÊÀÕÈÄ×x+žp5ö‹IÎGÔÞ¨Ž¥s|MP ÖJ-¿òe‹Z­‰‡„Ô Áe;"¬`°È¡V0‚†™ –Æ•3àì¯땲w€PùZá¶’è!æ-šHÅ`ák,EÓË²Ä kO)IÖ«d“{´‰Ysf¾©†m‹úc¹Ôáþ{ûý¾ÝÔ·õƒæ÷*Ò›x¼¦.}zh"Í-ñ®ëCoþ@ên›úçP(Rú¼nÇÁ>Ñþx(;ê uÝ1ä}½¯‡ú®r‡¶nŒ`¡íªÛª«Pp~Ï,«ŒöÇà í¸ù™CùcWLª+Wv]yßûpZò¿8³ß77í±Ù Ì\¹ç¦Á™7ü²nÊîÞmÊ¡tw½{;t0ÿÜAåÝÕv}5ÕË¿MµCÚ¹¡uån×®Kül¥Þ\ûýð8?„ヾÁ®ù‡Ÿå”Ÿ·½‡ûCµ/æ’tp^T·åq‡óÒǃŸsø ÓçÜþwus¸“]Ó6§êœ[·õÇá{;wSîÍßœ{Ƿ倎Ǖ.˜þÏǥŃËÏuˆ¾y8D×]Ù¥K z&lL“s[7‚"®pToŽÃÙ+°íÚªu]îÜ]ÙÕåÍî웞øý¦EŠŒ{‡ÝκÝêuEg޾™n3EH·sG8ö÷æïÛz=æù#7å_•þ±ú—V0CÜK?ܘ©ú¨óù_5Ç=ºsÔ!ÿ»2ô®nÐ=”»ú—Gw@>«ÿ;B&IlþÜèJK”Ž>(™Ï7æ ‹Ç¦ýЬË~°+æÐîî÷mwØ¢"¨æ¹ô)Wý|,w=f_uà™a[ùx­9 ž]“Úzs:”¼8&›·nʾr¦Ê™óÇäˆô ós$üxæ}¿©ÿ{4˜Mù®âap¶U’Ç'Mdvvì‘â“]׿Վ%Íå… ²¡ZÌVç]y_ugöØ Îû²ë·˜(è!?ÐR…÷˜Îëf¼[­±€Š-:>ðüÙÎj¼tgó?xéÎmÈÿº¾£¶ö¬a¹=68í~rún³ñ/U³±}Ò5O^´k;nŸ ¿ Xh6í½á¶ÄSãØMàîã½?çg/9þ6¸çtƒRìÞ|ûú“=°ý[^Y×-^Y:¼|²ýÝÂ%Hƒ?õâò¢º9¾{‡|Üù Ùï ~Ê:qû Ýò]»ÍÔeÙO¿zÂÿmº§¯ .ð-÷Ê]ä6É_o14¢¡9àËmª~Ñ ÃÛÛ_õ·ÞõÇáí×ÞÚeré^ÈvtG¸ðÚ~°Å÷×8 ]!XBv퇋]uWí°*~+²ìpQ•„Àû±9r|±Ýà%{‹BˆKtUv;<Žºõ—üì³Wã—9þË«Yÿ߯×ê{Áoq­#ŠCÐÅøÉ‹¿ÞØ<Íg^mf ½Êugøê ½ñøª‘¿zyýä?Oþð~"endstream endobj 5354 0 obj<>/XObject<<>>>>/Annots 2371 0 R>>endobj 5355 0 obj<>stream x}X]sÛF|ׯ˜ò•Kt"Bü’LåžûäȾä|–.~ñËXkX¤xW÷߯{ %—²K%»³3===³øv6• þMe~Íÿq~6‰&ø LùãÓ»³E4•ÅÍ4z-¹Ìn¢ëî!“û³“Ç\®–ÑìäÝ|²Œndqu¥糫hÒ=qçés.óùU´<}{òŒ·°Ü[Ò½'Ïx»\÷ž<ç²€‹§çή—ˆ`6D „3ŸLa9<©å“gz5‡åãÛŸNÐQˆªµ\ÞÞÈtk)€¼^^ÁüC¢Nä!!î©ück«­³»W_Ï.o2Å+.ÏÑr‰õ£‡Å_'/åc[Yyo¶FlšúªW‹‘Øç¹-³Ê,~/b[6²ñ; Ãâ i°½²&“¯²DÊʯ+ƒ-U->ml!ÖaI%…µ‰4kÇmm¹ÍUt ®LgôÃ>¹ºqŧ$V¼¯}n¥vMkç‹Zv¦hh¤1VL²Å£Ycqü^µïcœæ ,mkÚTC¬l­|½¹|óý÷_^éI‘†ýÌø^ãPwÿùîä8³×ß‹5õž¯Ê¬ÍWÄáà¾AÀ1qlëZÒÊçzÊ…˜:ÜU®E¨¨ÿªî ¼¸+[¥&¦Óï½ë\f|²÷m$wš¤Ä¥©­l€&ÄK£ç_Ôæ^úìx¨ËªÊ”äð…ì*„&ºUa® σÇi[ÄLŒ$6ÎLÕ%ɉİÂà‡u`Gã›}ië¨ÇÀ”ý*Í{p_ñÀâ§½Àp]ì<95 SÚfâR"r ÈÆ ÑôÈœMLîÛ¢!/;¿ôÄCfg*¾Èöø¡lv^€ºôîà ‹D¶C_€vÑ­£Ê^V0w«-XD¬©>ã3¹×g Ä­Si“Õ^ u‚|ãØ ò½Œ:Ÿ°ˆ7ÞÅöB¥³³…8WöT1Å“– ñ)ârßç5 ©ÐPÔ»ÐAyUxĸ Ó2Ãës¶ýöËó6pïÑÆæß]Ñ>B€f}ý¦™ÙB1´qœ:p—ÏèF~ǺèçÍ~">}0èÁòg:³æÄ¯r:@!g6Tì´M;*bå\Ne8ÌS:ûì%E]­A2¡*­#ÄnH ~ô圀4Wx¾@×·OŸ•¥Œóü®ùGEyMƒñóq MP£¶í,;4 YïJ븨s9¢ñ%‡@ÆSïëÆ†Ù ‰¸ Lóì`ZÓOm°O†²Õ—l݌뷰 ¡€ðF¡ !"ùÔB»—·¸ÃëEsÄ[“ŒÑ21¤„wý%tDŠÇ(Ÿ*¹¤Ÿîöÿ n’¼¢GfÚít€ûWឺÀBêͶ¿Öž2´²ßZLŽ5‰ X Ô.w¨+N"aNb»e±%ûÂähX™×é‡9@ÄN#ü\¯ :K…1•àqñÀ{RDm”ìééŠ:ff…³ÀÑ–ãP˜¸q„{ÒERy—°LQ‹ÔZ¦Ÿ5¤ãc†‹…Þ΃ЫS‡yF?²pâéÍvÚ?\ulÇ6Öô×/@8ˆ#ÍÚ*ùºCŽZŠ;øÁª£?è0ßÐÐs!Uͽ'@ªTà ç4§09u’T·˜p%bªÒ¾Ýÿ¬NdÍéÀŒ|™EøÞB/.¿“[—ÙzÚGN¾»ìŸ“ÑËÎ8 døâ?ƒÇ¿²ò¢nÚ46aÜÄ·Ž`濃ոó nùÍ—+¾¼ú+_ƒ«›óèúúµRÛ˪uÕ»›dðé‚Óa@ kv<Ø9Tãø+X3´=‚B¨Vü94/ë[‹î?¢,-»ZŸ.ÑÕüJ®_ßD³”e:žã3ØÛÓ·!¤°zü:@ò»¯UW“ëh>ç*À>_,¸éogÿ<ûPn6endstream endobj 5356 0 obj<>/XObject<<>>>>/Annots 2379 0 R>>endobj 5357 0 obj<>stream x}XmoÛFþî_1ZœŠ˜Ô»lßô’&uúzqÁ‚¹7&¹ì.iYÿ¾ÏÌ’”D)FYäîÎëóÌÌ꯫)MðoJóÿOŠ«I<Áþ˜òǟﮫE|KËÛy<¡‚w“xÑ>åô÷Óò{±6_ÅÓö—óo]Ü„ƒËYËft&°;„À§Ú™'(Ú8[Ȇãͦ¬š…˜Þ"ˆm”¯Éa‡ubØãè+Ù]«9qâ’}—…^Î3²c)ÉT¹åèÍÑ¢D•Ôx~suÄÓ}Í©Ü[ª¬÷fh!K½ð jP\@À‘mjÄìÄ­Ô8ÔÖíåm_:ÎŽ` éFÊi:`Ë”PÞx¦î BÁÀs 6màg÷š|¥³1¾"¿ {"¯•Z»Â”LSIJÊ“r†Yr°6É•÷Ø¥/ã“©Ø}!^9¸#ÖÖúÀÄô›­[¢@#ÔóîÈJ-”•¶†…˜‡z!Œ­Tò¨¦ÓzÏ‹ªÉ뿃±²µ³8µ"'SOC)=ó•²·%j5 "ÖVM(ö‰3kÄ`­s»@† 쇦JL%Õú<…›ã8cÀO`º'1tÓ8DÇQå^'*ïxŠ Àu¤M™Ü“-)ƒv¦Da¶YM[Kj ø´…‡óþ3Îp¤“ȇB|½#®‚Üm¢ÙŠË ú·ÅÒÔ°…°åµ- ˆE=Óô»´'>ËUZª{ïe­˜u¹AáckЮ:™¨”½ÌКàê¼”T*> ™ 8‘ìí%òÂiT[¯uɰw_îl¡¯}arF™Î«–ƒË¶cFÓU|·šÁ 8?Y²#¢ºeYÒâ`àv4EǦËxr#‘‹J[m“ªâàÜÍãÛå Q…(ßTŠà¾ªn¸6(·fp'W@ò¯ŸÐ5vª”Ñ[fE­¸2gŸ¥"+ë2.ñØ¢"sÚ4¥éD%Òn£Ð†ÑØj­Rn,Ë¢–DìÀ%•¿gÿûÌMfxÔ§$‚Ý0âp*º[Æó;ŽÝ<^Îo[Ü'E~gò4@š\£Š:N2á6xÇè¤1¥ñ8‰ÁCF"n±˜+>Þ¿>°%BÆñÛËpŸÓ;]×LVã„[¤Bµpå«p¿/1™ð6î,¡ù‹ˆ0í´]ŒÅ¶ë®›ð*Èíûí—ÒÄÙ©®‘8p¾ïs‘žo=6™v™I2iB€’ ¨7?we)L?™F ߨ<ß(ù¡ÝåÜe0ÔÏ(yžC©çyõ,áùpíØþO£7¿üÂ^|4ejwþÓw’󭆄Ü„Òû$yÿû5¦¼oз=}#õLK•<…ò_±EFF¸Ï#êSݬ7œ¼1)a\®pjàË £Z§¶#CÈL˜\Ø„cÑ0z“7ê¾pˆ½<´O#~Wâ£[ ‚ó2»+ C±k¢áöÂ!0~CÛ$¡hóÇýk\uºMí–2ø®!-ê£y”ûõa½›Ÿ{Z³UGÓ“)9á®(á:íE‡bÄuLöI.Ü\øŽÄ}wÓäh¤rkç :ô…0ŽP›7ú9¾­¡·í 5›,ÐÌ—´ÂÏ2ˉ Dì]Ä?Ò¼± nâ¸JóhÖÅawtH)Sç”þlÊ’5òIÞAñ|ƨùbɯ~|¸úïÕß´Œ‚2endstream endobj 5358 0 obj<>/XObject<<>>>>/Annots 2383 0 R>>endobj 5359 0 obj<>stream x¥XmOÜFþί¡T1MÎÜù^€´ªDHHS¡¦ DQÔ«ªÅÞ»ÛÄÞu¼6Uýï}fw}Ø’J„níÝy}fæÙû¼3¡1~'4]ð_ZìŒã1žð¿ ÿ{ûjg2ÄZ̧ñ˜ šÌãyXåt¾Ó]ãíâ0>ì¾í¬ñöðh+Éí¬ J’£ø¨svæ4.&Nï {ȯølw]Ð<³Un/¿…´ÏÝÉéAœ„¿z~ÑñÑ9Z­iÿtN“1]¬ŒÅ>d.øF¯‹ÒTµÐõÞÅÇýÓÙvãh’`côzE7¦!QIZ¥×Tj¬$SÖªPVÔÊhKuSi™‘Ñt­ê ­Ó”–ÑÊT$¿ˆ¢Ì%Þ$˽§$µm ÉIÌ­¡Ô¥Âkwj´ÒfdëJ¥õHäJX¨‹éb#Ù´1ƒ^œ ”oÄ•¤K Y’ ñb½®¤µ W•)ØœÑ Ñ2úZT™%¡3hÌs®&¯Ii’Iª7¢¦•P¹õy[¨µ¥gÆþÇt.Y$·»7¤":Ù?yò„ƒø‹¸Tß”²¥íonó‘•)˜8”εLÖl_lIfœ#„ˆ´€÷fåTÛ Ò•Q®.+QÝiê²cheIµ ÉeSÛ³HKEçï_¿‚®¬ñ»wYÓþ) Æ( õO[´D»O{‚ 4èA”š ¡.ÎAóœ]vcš$æ7®›p1<¶C—Îol-‹˜åžy,÷ÕGTÈzc2.`á *Í…µÏÚÐÆSö*a;“x:Å*‹ö÷©jt!ãPÊ;ù-7Ũl.s ÀÉð{èï°ÑŸED¶†OéÇDwm]F»¸»Ë½rþé)& ªƒø+£2*„ÒËèýÕúê?—{kF•Ç%öÖ9Nµ³i½Œf˽‡-ðž9{nÛ?d”LãÅâ€ý> mZ g2–]ïâºõ½áüzÈÇ:¥ï»1÷Šý+í^Œ’YoùˆWˆF¦PüFZý¸¦kS}"7@i>Ú:›½2yn®] }õz£Ò Êʦµð¦-v‡å¶6ûýꫳ A+ÙJì›ß)œc‹†h®5ƒ˜,+y¥Lƒ§ÁF~èÇS(1¾Ò+¬eÔ70AŸ÷·ýá^€rç:ûÆEܼ”oxíÔM†&ŒX¼Ó<û-·±3tÍ—Uå¦}*][q#–Ï ¡g ¢Aꦸ”©J ÚПb@3 qCkYã8˜C+ }Bå¢b!5ìú/P»O/·ò\ aBF»\c»œq.À6îóêi³å18ËPŽCO‹KQo8zHhÛ"Èýr~#‹=á®t†6&«n7[Fݼýè(ˆÒ·%¾m4ø—ìJ/£ö©u0;ú/’îÃExæÄ&ã‡ÅøFúcŠé¢êŸ–‘_»só!¬=å°.Œ­™Ö©`ZÉÓ”“Ì”vÔ!­y”r=†3(*™±Æluhñ¿3X¿2KVvd«E¥§.l&ó@èþ¿‚©hà®6L8Ó¼q„3-“_jPcfzŽ‹…Vàõ2µš|AîŸ.Z&Fq–çƒÊ/ðO:»î°¦»œ:8èì»t4¡«‡MêaJO†ÊP÷íæüðì(sQ3I²1½Ñô^éÌ\ãò€ê,Ás×@R•ÙPë¹/lâÈÐâ#\˜î"óN«/d£ºjŸ ´§û¥GîRΞy#ô´€aß׈ï8Å™gü1–oÜXäa Vž>qSéE¨Ÿ€B¾9AÛ0m ºŽ[Ÿ¥¾R•×3¾•`²°UãÁ—6Ä·¥ÒÏ3À­«@d68´áìÅ_g¯Ÿ¿=~ûá¯ßŽ/~ö¯··ƒ»*{™ •:Tœ¹H±…°5Pÿ[\K%º‡Å´)ÀlõYÂt_W¢°ŒÇi=Q,Ýð¹ÆM8(ÛF³ ­®eÌ%¤áj!åS7úüE—¥î.ªh“ÓÕwÏÏQ”}%|:·‡p-ðAÜÎïQõ•D+wK €ø+Å«_ßù ç w³™IFF7b°Œ:òPe·™ÃÝö­%ßh>l]ãN-è¹Úl%îŽ>/XObject<<>>>>/Annots 2386 0 R>>endobj 5361 0 obj<>stream x½XkoÛFýî_qQ$Xµ¨—­ØF±À®›.Ò­ä‹bD¥±Éf†´¬ßsï´(i»»Ø$v,>îóÜsîøëÑŒ¦ø;£Å’ÿ¥åÑ4™â ›ñ·ß>L“3šŸŸ'S*i¹LNÚ]í},éì,9ß»÷ï›=cbѯiòþ„fSºÉáuyŽ2q†Ò‘óôææîhò¾å‘Qê /uoèvtí åM¸}Cµ#•eüejã¬*(håÓ UªÞ¾]o4e:WMQSØ…Z—”:››uã¿sõÆòúkc¼ÆÎÕ¤ÒT‡@Êf´s mMQÕ:ƒEgJãÙ¡¼V¸¥²ð¹Ö*iŸ˜Ÿð7¸iáéASaV^ù]´¦ŠàÈÂUá`ÂälÅkRüewÔXÄ⊸ »råŠ@ÆŠ§Ô••)pýrrùý÷H&Ó ±—Ü…Û»&ý˜êJ’3a®±™Ic0Ž=šp«;¥³dÁM™#µù{ÿÎ{ç/¸ úQ•U¡“à.(ºc¬Îº@Å~Ìù‚r•ÖƒÔþQõž£ËB…ðuÔþÕ'Iïc,uÂŽÅkô³®7.»}ó· Š‰ÖÜôv´ç*áÚÓeßtâ¿0þ?±ý[ckSꃠ»«ÿaÀ×26û61‚ñÚß²(0J~H cMýÏÛQüÌ&.N ÷*²ú±Àr‘,—oãLa`5ɚШ¢Øa8Ù˜ßzlðÐæÎ¯1_àcÓ¢É4Wjr«;Ö”c†ÁBœJƒí€!¼{ž"™gÃËï%ô³ºïBˆ 4\öÚŽ'­\½‘y½þrõ¶^U•öâUX…9ƒGWÞá¡—'Ø­±-k°Ft|•÷¹iÉ­õ×aZ‚aÚâ,ºŒž‡ N®?ä&ör,.„óÖp¢¨‚Û(˜Ò€y;Zí çÿO"-ƒüôé*Y§˜ð««Û7W] „Aöˆâðá¿HK‰ƒîƒ u6?€ëž³j¦ÂÀggñ•'ù;ÀôVè?¾—?¸ˆ€|ÆNiB`´ ”76¶èK³×ÚjèT¢‡Ó>úËO SÜ $J¦ø­"öÄ,Ðzš–¥Œ3í£Dϵ¢ñƒö+ôÅ5‡¹»ÐÍ &ÆÖÔÐm¤'ʨh Q©i«v 7Æaé0&Æb¬Kp<”ÛY6ØkñsÉLèX†8ÔTbös¬ ?q­ô–g¯tf±+>/XObject<<>>>>/Annots 2389 0 R>>endobj 5363 0 obj<>stream x¥XkoÛ8ýž_qa °ÎÖVüHœ¤ÀÐIÚn:m¦3ÉN±€€,Ñ6YÔ’Tœì¯Ÿs/%ËJÜ¢Óé#­iòò>ÏåÿÆ4Âï1Mgü']Œ¢FøÇ˜üöö`|<Š&t<;‹f´¦ñ)ÿ>åts°ûyM“É(:Ùùöì,šÒù,¬œœD£ðA¶aõä$:Ûù®ýˆïÎO`SŒðºŸnw|Gí’ŽÞŒˆ·º]ÐdD³óq4›Òm&‘Œè6íSý+×sç³ôÅ‹!þ—΢ñp9ƒÿõ#UÎa˜ÿîŸ÷GÇ£Ñø|4҇·ŸF4cƒlwƒ5[œ‰ÅÚZ=R/?™uyúly=R/?=ýòòà~†àŠê¡ LÜèŒÖ¶`éY$?p\Goމ[ÐN¦uFûot‘äù#­“;E®²ŠüJѽ²N›‚Ì‚Þ]þL+•dÊÒBçÊa¦OWø÷é¼ä>ÁXâéÑT”À­ŠBKJé"5ë2ñz®sí5V§¦Ê3Êa¸Iû„Óî ¾Y—:Ç\ì_Z3ÏÕÚ‘±T¥U™N}‚!š«Ur¯Me£Þ9a`ô'3¶´Iî 7Ÿ[v€Ë†"Yxú­VtN¼¡2©AŒõÉã66n´g`ÒA‡và„Æ~S }ÂL]È-M#î¥MÖL4éŠE>–঩5!Ö€Û¸÷ßöÂèCƒ¶ÅÈMpõ.wk„¹ÛnÚÏܘ;‚kâöóÆéòN LzÇÅ‚oòѾm jÄÄÞîs‚SÅV®?¼úùu8*͉ۂùU‰r?"j4ýwJš –%Üò ¸%åñ`cµ÷ ý"ÏlŸnTq¯­) =Ý'VókI`þ7¿3upÓžÃS¿£@vJÇ «'zcrLLß-]Drî>C^=_B@–õ­Ç¹†CèˆIWwô¦iÀ&£ãèdzB³ÓIxqax§xG¼4iÅ. í³Cx¦ s‡§áANÞsNébßë7 Μfy©@¤læd4‹¦“ÐôMÏxèõíÁ¯†ðx¼endstream endobj 5364 0 obj<>/XObject<<>>>>>>endobj 5365 0 obj<>stream xuWsÚHýߟ¢«rW‹oA`p°ã*ªŽ`œ#‹í]›¬ï®T•¤&#FÂæÛïëý°0I\–<êQw¿~ýzôÿ“3êáÿ †ülO>/Nz^‹Õ¯tMÝ›]zZ¬¨ß£á§3o8¼ Eh­z´ZèV<Ë•Š$­â”r£ôšŸf_H辊°ë âPž.~œô¨ƒW-ÂÖãÃ䑪#’¯b›DÒ «3k5»™Í§ï­š6w‹éÃÍxâìFô7¿e·ù§žj>=Œ¯ß÷ÖðûK*’ʵ ðÍã@d*Ö¯(ÛHúS™\D4ùõWÊâ82ä·}ZªŒ„1ùV†þi#ÅÅýý¼ÎqDÁ•ïoM(w¨ã‡/ÓE™c DE »É¤´á«Þ:ðO}©´ï‘'_K|óÙÝoõ®#{"¥ŸßíšÝMæß®§ÈÍyêÌiåKé Ê«b:?·ãÉ¿fwe¡F4û÷å°ÅšÐ\-S‘îIKÊÒ2WQH‚®çó†5þž}®ÒÑÖì‚4ó"µ¤8 µØJcÿ Æ®ô¤t¿‚!<)iP6ꤒD’ࢳ¨ôßÀöiv%R#z–©–Ñ o½ˆp'Uü‘™·ë°\ âm­‹å¥MzðÞƒøvlA,` ¢ˆó7xLMWk‡‰ÊôváâþÝû5"§8aÖ¼ñþ÷‚c#ê„r™¯¯V9\»ûlŸÈ«`GÝ»ûëéÍøÛ|Ápt¦óéøqÊËóû/÷äû(K¼ìµ[pà ñ·°ÈÓýÕ÷ë(ºJO™H³<ùçY¾+Š—-ÇB±M ')­"±.sp'7óñ— —uÿ{AÝûºuuÅë¸Þ×ñŸãï—K"_£„ÏgÞÀ÷ "SgvdÕ÷QÇA¿ðÈÙÕUÃG yQkê°ub[¢Bk\Áf¥DU áú¦ÜÌ&gê’t÷o3p+¬šî®³Ÿ¼ÑÈŒPÃÑÛέ ùÎ; …{ïDÁ]'γ«R“Q'ΉY‰Gåj¼üQÞ;ýÄÂQp–€þáñ• º7çĬì,èôÅXi-JI`µáí)aØÌ£¤Mi®éîvüÛ*¼sÚ ×ÙÜSüÌ9ÂŒ³ŽZ»`'Rã ZûoÑJ¥&ä ÅF $•Y¶'£0”ÉT5‘ú<·Êy׆ze´‰É}´'•’:Î׎` ø9*Ãl—¡G÷+0;O´Ëì‹Ð›n1@)ؽ†.ðÅ<ÁòKœ>»Ù‰q³Ü“CÌÖ_Š‚€¨N ¹tI`clìnKL~Ê$g/ <ßàúúê9˜>ÑÙ¹wÎáù|É·a«ÿ£ŒXrHÊŠ–¨€&]<.“"œMÞ{î]^òæÏ{ åJäQÖ.ÎY&· @Bn¥îk‘å)&êWî¥3™®D ÙØ¥…/.·G7¹¬ªY5·þ1C+´)ˆ0‡"„¾Óë¤M`ƒËÈY»|ð>‹ GóY € UäJ".¼¢©êû˜ñÍ6sŒ´áÑcg:ñŽw¡>P$Ô™BÎÂ$ØbÜÙ¼+!­+‚»z Ëjxgt‡9¢nS"‚gÁ”áÀÖRËT€hÊ"KWÛ²×\ule`=¤9‹ªIþ¾µooîkQ¨RÎnb!fµrƒUâòldKè¶{ô´‘ÚÑßÚïéÇ•òqàð—v‰[÷fX60Õ±!LŒ8Ø Ö¡D[t¿ŠÑÄu¬5Z|pE×»>*£gtj¦ª© ¤ÀV«°ÃÀû£aÍÜ«àKeM;ØÖFQÝRíŶΘŠP_ïf?÷×>Ô¾Â6‘à7Ñ‹„ÂãªqŠMãy‚¸©%ÓaI¿‚ÞÜjQCK¦GSløQ•é›-¬°\5´î u²úe²4G'´)×|lq¢_´2k(ߪî ÿZ/"ãdö]=¸XÄ• ,)Ç"%µ²=ª¬“Bï’‹VZdì×ÀI-!¬¶UÙáŸ?):Ñ-Á&ŽíÇ“(ˆnaj7p´“Â䀃a cýK†/.è%k¸mC¢Œ1f@ñÍRùmï5N1žåsê}’)°ñÄi=«`#Œ@hg´,ª‚ZòxÂØ¬ˆÑb[ v¶S[eÕ„ßìÑÌvÒ0*Ë „ßÕÔJ±Óq€Œ|ª<+:i¨ò¾Å°BA1¡ómÕÜL5ÇŒºÍ¬Á1m’š ¬Í4)ºÃ½°ÆÑîDAðÕóCA“ñ{ D›ˆ.4þ²Ð¶~ïÜû8øHË oh§'‹sgàõè:Ð’:³¸p¬øzvÆ wˆÃ”î{—^Ÿ¾YúØ#~ì =|ÁÙ¯èÁù'^š.Nþ8ù @ʹendstream endobj 5366 0 obj<>/XObject<<>>>>>>endobj 5367 0 obj<>stream xVïoÛ6ýž¿â0 ˜ƒÆ´c;nºaÖt)Z Å†Ø-Q2YÔD*Ž7ìß;þ#7 †…EQä»w÷ÞÝ_'4Å¿ š/ù/Ûž¼½=™Š)ûÿÚ’&7 º˜Òm½Ë7ø‘û÷ø‘Þ)'ueÉ$«ŠÜFYE¥ªU+Ê)«¤µÊÒNãeW¦ÊIZÚ›ŽZ%sì×–¬Êœ6µ8»ýv2¥ñlF·E? ÕèzrýêÕêŒ2“+ÂöÃéºv†$ºR´Ûèl Ö`c Pµe4´5y‡×µÜªs*LKêAn¬ðm“Dï#Å寻V6"{x¯Sà#2íð½˜1Ðá‡GŸ B`äßÂðX-2§ñë1£BIûæb¹|Í7|ùóÃ{Ú™úGGj9&³N¨Ä­¼Sd»uëPxÚ"Ëk…*T#xC\H,®ñlÉ'Ï.Å\Ì覫½.ìo[ˆ¤>ÚR ;”?ä„4C`’ÊʬeE¯xCŠë×T¤ãIâ.û Ä·ÖI§3Ú*·19^û„FyA º rè Rv >““ÓxFÜœ*ˆ e„º¥BfnåÕ«³Ÿ‡Q{òç=ùqŽ3¢MÑ«tHK{gY陫öTid-‡é¹ãTlu¹q?½¶éÖXðñöžñÏ3QÜ1|ï'šL|QÀØ.ƒ,Ùæ Öþ!-G7ý;xöO[>ªLXNÈ{ŸÂ]X=HUau™L1¹§?èè om}!oC E§¯ÌÎRÑš­ó2Û_öÖ©­€ EӂǪ^%c¡,«³¾(’bBÜ—I‘^7sz*ÿ^¶Z®aCÜäãKD¿ÝË¡è*ŽíšÆ´ÜÇ`¡¬wxÍ ZZm·<³ó‰3÷ªmuÎòC+äTæxo~ó=¸„qõ’Y¦Ð)¹#¶¦+7èrΩ^çhþ· _Kô58H&Á3ßò¬ü½î£ÖÓ­çnáb{ûHÚì>7°ÿ„(VyöW_O{E ÿK€¼"åªE¢UlæÜFŽÐû<2_Þ/^ò!RóŒ{uíûØéPŽêwÖÜ1éÓþkŠÛûNMÜ“¸Rªj«Ý~¸åt(Íxù³âüŒ‚A}~^Ö¸ùµ@P*§êЉ1eÁ#Ž˜IùóÄ<¥¤ÅG¿Ðô*9š@6½\z•õpŠ”ó%ý¿A¤ŠÂ}8[¦âj±˜õNÎó„w…kZ庖g hõëÎO’²ÚÉ=·Rê®æœÛ¯ºWÈf_8ž–¡Ñ–8”_ úl|›F‡8œ8X¢ÒOvM‹Ù‘‡ª`fþÎÛ[¯ÃKˆÛíQV—x–¬Ñš]Ç7E1·Ö&=¼J¾ ͤ¼1“v²Òã&V{ƒñGåxàajtò &}(|KÛÈû0EnµÅ\á:ž×ŠÐÎýÌ´3\Ç7Ç\éáp±¹÷ÐùM‘êv€ßž£]ùÑ›Öi«x®æ žq¨¿žÙÄiýȪ.ÖýUl3³éB\Î/iùz)®Òh5ž‹)½3Y·Ålìa1¨–°wü:hÛ{þ}òS> Æ!2$õ鉙Ϲœ.Å|†‘ £ÇürÊK¿ÝžüqòäkÜendstream endobj 5368 0 obj<>/XObject<<>>>>/Annots 2393 0 R>>endobj 5369 0 obj<>stream x½WÛnÛF}×W \P‹"%Q²[ä¡qmWA¸¶zy0P¬É¥µ Åe—dl7è¿÷Ì’Kо5éCmCðîÎÎÎå̙џƒ€|ü4[ð_´øžþøãüt0ŸÞŒÂéÒóiKóeè-›UJƒÝõ–Â`á…;§P„½ÐÞœ-¼ YØ‹Sß;¤`~à-XmÈêë•=ÝYãôðÀ›ïœ¾^ïØi5×49ñé–®šú´8 ¼ÅbIëØzãÓ: ÌÄVÒQ*Š ÛElß¿Xø4 ’T‹²–ꨬ¤ˆ/ÛíÉ lÂ…„Æxp<5ŽV ú$ŒW©$UP,qËȘDAü›ZßE:+ÊzÏií“*ùÚy^ßd¤ˆÇ:KïZÍ­7°‚v[е,Kix#7:®"{_Ó9ûµÖ´%i«L˜NSÑiß§;]Q$2ª IåFÞ7x¨¶ÛªdÏîYM±22*Õ'éщ6$oÅ6OåwÎá.7ãéԛͩx4üÜXXG^ÞÂŒ¢0ôm.Ê:Ðmb†÷¤;Súiú7-ýÏ'qýŸ\§¢w©Œd’ Te¥J›|ÊÛ¨vḞª(éF @Êe‚Š\F*QQ‹Xj±³OE•ç„hŠÆâ5.Ïÿ=ôižç¼| ˜d&ðˆ+ÌËQ\!)š:`^¾àONÀtˆ»cŠÐ1Å4ôf`¶#&ÄÎf££&•9Ž‘¯£ÉÑË—dÉ‚å€Ù¥‡7âÂ]"ˆ%¨í´ y–Ð1$‚í4ìÛò®mk¹è›Xâòƒºã§ªVÒ’×=°ø±ZÔ}%4VÐÙŠf^0ÂC§Ã’³;þõøübõþí¡Oíõ$†Î2”aI'ïßÓ+šOûÑÉXáÆðÞ¤*Ì$Õ‘H÷ž'‰×¨d™ˆ*ìÁ×2“ŽŸÈ…M›ÊT©Dªþ‚ØÕ32—© 7ïVàÝ4eÉY¡2ÈcZ¡$ÖÐîܪ³ß¾å|·†ÇÚšÒ cKšDDHSªõGJº@¹QÅóäœWWà+Žb£ Éß‘ƒ+}vÛÔ57j6xŒ5ÔHNç+×àªw¶ú^^Ž._ô3ó¸’‹Òp”\Ò{ššÍ¯Q×£q‰-R¾FGcsGß3Þy\‘m_]}ßÞi”hÉ-ýâ·Õ)m0,¨,‘†FוwyEôf a>0:Ç ›–¬„Õq£¥ƒ_5"»FßÇ\‚Í\…â”Xl–â­~—L‹$ÖäÑÀ­Qu S…nŒ!óU‹;VÖ¹:²݃·2Ý <ÝíHos•¢Åcí"äôzuú¼ÀÛÎO¾: ¿»®vüûÙùñ…ml—#ÿ6ðý—a»vv¢xÕçûoß:zšì#ø&äû¿Ô““ƒ¦Zƒƒ¹ÎBZ,¼e=‡sÜÇ3|ûQG׋ÇX1Hª–/ëQÈÎ,3:MõÕîœÁ²¡¿ðfS|¡„G³0à­ãõàçÁ?Ï¿8dendstream endobj 5370 0 obj<>/XObject<<>>>>>>endobj 5371 0 obj<>stream xÍXÛnÛF}÷W R¥Q™–%˹}¨];u&mìÞÅŠ\I›P\eIZVƒü{ÏÌò"2ô¥oEÛ"wvgÎÌœ9ë{G4Ä¿#ŸðW´Ú;½Þ†C<¬¿¹^ÓÑ®çX{ò¿Äò¿DÁB§Ú©\g/ö¯ßï^ éY8楣!ŒFáxŒOq°.f‰‰È¤¹vsiÒ·jµNô™M³\¥yFŸØ6|P•s“ª„°&÷ætþç/ïί®.ß¾¡ïi o†Ão'ÓýïaŸØtA§—/aYžÿêÍeˆ/t> ·É{u£Â•Ê—á©Y\" …vôú‡w/ÏÛÛÊ£þ?{¬*T«qxrò”ccsMùRåtõ|]ª ¸Íµs:ÆcMgTAí“HXü­½m@ùv­iîìªk»kUS‘á•’Z¯];ƒ¼Ò+„ë7š=çv¶™îÜUÞêáåd2‰rêG~¶RI¢³œ2óÜiÎH6&I(W4a­m–™Y¢éF%…Îhn4@!]™•I”K¶bÚqX2Ø 0,}³¯§š"åô¼H€Aqq~:»|ÍqOƒ£é~g?ŠÓQnnPF©Í%®3Šl¬I‚ìjm"^ ü&¤ DZÖ0¥Úà\×w8šcøúuûÌi­/ðžòHq^'°öþ­»yз_¤fAol‘ÄT±çÑ”9÷q^Ð*ÎX¯F¡ZÚ mmüSÔƒC³{ulkåÀr (+Žù¢‚{å>èÚç> }Ô»K›d·1PjÜ̱ÕYúMÎv·io ý\\±ž«"A•€rÊAÕç¶z ¦ÔPÓ5*Ù¨m8¤žBúÉnôvƒ²tÕuÇáܮÉÎ9n‡Þç\±hnd ¼”l[¢àíj¥Ó˜ÙƇµFy†«Ê=7+4W:i…™®+…y*¦•Op³T¾³cd¹I[~¨t‹òA&8Çõ>xö­rņ“çæþú6÷ÉÅäİšSÐdé‹oS Ú 4̳ ÆaŠÑ†Fhx`³4ÑRê§ %3­ÁGxêÀ6›%ëù[®« ½6Y\/‘ІjyJWó¼$Ý&Ùsøw³Õ€6H 1óϪéðÉåDŠtz@ r! F¿É¡$ª„¼ä5Åevm%O˜>-V3íBªZÌÅFê BÝ@_ L¥çv˜ ÁãîÌϬäÑ=ä“d@Y$F„ ‚K ‰Q¸¹åswüª_µêš¡qúcsš2…²ï%¼I¼_d5Ii+¢æe™á'©ÞϦ®˜š>arÇé>¾¼ºy`;ž4X F­BÕ`D~Æ2©ÞÕm;ª­B°µ{ >«ÁUkÂj'¡cèËžéÓ¯¤€ªÔ}, ­¼Jð5ZõA ñ>ñ›ÂåfÓY¤ÖUvæ6I솽領á£ûSó¿Ó¿Œo•¨û$w_Ôj÷î òxvõú÷\„¡ N§—ü˜èdL8¿/aùêMœVñM¡înÔ,„"˜c£&*ŠtÆ$àY]!›9™Û>FÞ™á‘öç“qáô±ÆK7›Jën‰Ë…Y`ǃz2ùîÖ·‘^³ó74¹‚¥ Ë+ŽÈ ]8\|¤WÙî!vF˜-o€W–¢Ä‹(¯h„åýéóe@zñB¦Ò÷5¿ýŒkΗW³®«tqù;_~&í‚ú,/&å°é4çtÒ<3‰É·Ä—ž²…šþ»LE5…ãð蹤NC¬¤ÈéDctgáæfÚðt­'O€ÖP 1#-XÉFLéµY Ïæ’›˜‡ª¾5YÒ©Š>l”‹½„j\GW FøïËŽ·ngøªËó΋úØÁ4  Å¸Òl±X¶ÜÉl)„L,Ÿ™‡ïu]§õ Ò8\]Ð3ÓÚ)”h¤§û"(O5ê]³j$ÕJëSå¤P÷ýýtz¾D¿,”Ž ¿´pŠcð=XÞ ppäâº3°[zE´³ºÆb ¢¢ aÀ^öèòuØü5Á/lj´mƒÒ¦†ànãÞB —"DGH‚FÞªd`zp]eÈRÄŒ$òÙnÚúÔ'c' 8Ô aPßs}tßÌ=—;q(iâYÙãáq8Oèäøw¾ÓŒÃ!ýh£‚ \Êý@³û•OýxMÐÄÇT£Ç‹&Óp<Â_•°Õx2âGç×{¿îý W°®Éendstream endobj 5372 0 obj<>/XObject<<>>>>>>endobj 5373 0 obj<>stream xµXmoGþž_1BB8¹ø%i+>„` 4¢-UB–ªÍÝÚ^r·kn÷ìFˆÿÞgfï.9HÒPQûnwæ™·gfòigHüÒøÒbçÙlg ð°ý¯\Òþ‹Ÿh8¢ÙgŽh–ÉûÍÒÞh’Œ“ MmUèRã¬ß}ÜÙq@Cà+{£ƒä—zïþ<}I+e³\{:waEV:#<¡ÊÆÏóž²Î^®òó]Ò×Ä&4[éR“ñ¤(]9“jr RëuéTº‚Èàh[â»±ËZòÉþÉãÇŒ(Ø‚¬Ç=‹‚üd•ækø\iR•S©•‡¤<1ÞG8fM0xã«õÚ•®`ž¶8”›Â„Úˆ×j£(3Yò–ƪ<¿„ÍÝ\ï iE%4… ­1¸ÙFÙ –°Œ=”ÿÕØS0*œ`a¥©òºd«2šLÓve 'ù]á|è@ÿ­K£ º¼â6®Vp÷ÂUe‹ Pàò(¥-LéÉôBUyhÓ¹òpŒ³¢Ø;‚{s</…˵öj¡;X88´V!è2b ¯SÛ—ÚrvA=‚½†u"£%§)l]«gáòpOޤ±A/uécðØÕ¢ ‘+z¦‡.’ܹ N#üF•y]8‡î¦l‹©ÑGÈê4®s…} [<"Rê,a»¥®®Š„Ó3–S2¤ãîõx¼SS||ÖT„u’ñbÞ7šá@x!º$F+0Cæ^DHœ<¨‰œ×+ö×ÏQ߀ޒ1ñˆ«x”ŒÇøkˆ>ÓñÙ´OgÇ/§oŸ}z7ûíý¬O¿Ÿž½{3}+><­¿Ñ—_ºì‰Äqrxø„%"9Å—ÈDJ°Š³™¯\¨T÷ñŘš\•T(‹´àJeÇÆ³óž×Y¢70ä'ô|÷n‹ÖÕynÒ+ENZ¹Ÿ?³â•õˆê1ï ;ÄëìzÚ\ýæ4Áƒ¿–:Ì{ó]ñÁ=dˆO»RäÑ÷Ê‘ˆtåÈ£ï•Ó±cWýð?ÈúÐ…An–òåΜAîS“¦±Õô~K.Ì{‹\-ç»] =!Ò[/mT^éy/þúæjfJN&09R´tY•J¶ ?|oLzW9™*Ë:Û¤r”ã¹ðtF[ƒ>X3Ù±ô$æÒÔ)ÅÜJé‹¢†cQ0·š1ï n0ÜKSÓ ‰…(9ƒo©+Ö ‰*bRíM]¦zå¶z£KŸP½‡ñv‰®w¸¢Ð6ƒP³*ãâEyÞlø-°+·Ö\Üš›Ì%÷¦m©||Ä18 ý®ëU@&&8—Â}<‰Àe"”é…mEóà°Áf´Ey·uöQh}PÁ–Ø[zï™ÿ¿ÏQ¢­¯„ë£_ƒ)º­¥¨qÓÙ2‰o©ÏÁÑyœAÚT/8¹É8ZZ Gú ™1i„‚i|)Ý£ÃÝ´w½^š.?]‰„jˆ½{HàýÐVÐ8Äß ýG3ö k×íßóðÞ7Ž7Óð¾ªþÞ­EvÜͳLJq„RBi¶Üç*W¡êÓT{™0 ¤méª%H ÌÆƒ(²¸@Ý¡~Ó\áÆ ¡¸¶·¶UÞãYLà~·öZö¬Gn¬ñD3õXr÷R¯>|ÒèºáÖ¿ŒbØêQ5²tW'Pd·i ¶¬!éf5¹a1© †ÓÍ$K½ž~ã–SêƒÅFƒì¶üuaݶn,e•b4ÅÂãÊ †ÔºGÁùøG®Ò ¦RQÆAEF^ÄC¡Ìý G¯ŸÿJÃd’Ðià±7!(…!ÆòúQGŽg^ÌëmO:*&r,A8×AÒlF8|Ž<€Î¯¦%Ù6ü†¥JvÔ‹‘yT­?U2÷sƒ±ÑE<´KÛ¬ÓòY\: dügf”ÝTö¥˜ÌøZãûÄo—¤Ç$t¦–>^xúg¥÷™‰›æÚÊ r÷÷É­y ÅŠ‚6Û(­ã‹ͯ³¦A/s&cÄz‚¸ËìÈ-½ª!Ûškê}48H&ã >9ºÚÜ÷ÆÉ€ž»¡¯½ÉP1Èdz{Oâh|Ë&ƒÃd<Â_0='c¾:íü±ó¹4¿endstream endobj 5374 0 obj<>/XObject<<>>>>/Annots 2407 0 R>>endobj 5375 0 obj<>stream xÕXmÛÆþ~¿bpEÑQ"õrº+üÁ¾ø\»®ãøTp¯(öÈ•D›ä*ÜåÉ× ÿ½Ï _´”|-ÜEƒ8NF»;;¯Ï3Ë_NBãŸ&sþç'ã`Œ_ø¯ÿzÿò$œ4»8Æ”ÓlÌ!£›OÌé|L¼5OÌ)/z§Ó hÑ:]DAØH¬Ö—qgSoÖQtó`Ox,z"ÎaO½‘×¢yÈjšƒÑâ<˜ù«žœÓd2‡¹û³¾ŒÕóyO³/cuqpÖ“sšŽ9œ{ÍÓÅ,ˆ:«fcÈ~Õ—9ì‘bváB„} šµiÈWvkžSVÙ­ybNÀnÍøpÑSN8ûµ"¬ÎæœÐî¨/sÒ"Žý~Õ“±zqN÷«žœSÍz«¾ŒÕ:oÝY_Æ*¬òáËXÅ=çÞ½¾Œ¬¢`}ž/½V‘~)×4º‡a¹¢hLó‹0˜ÏÏi™HCi¶Õ]–Æ´J •Qœ)ké¹¾×¥ZkúõÉòÓɘÎBìLD½½Ö)‡ƒÝægo^ÐS*ô®ûévpŠOoŸüñ[ô¼yöòÅûcMòóéô•o3ýúí«@~úÇZ»ÛÁí“o¼åfùÓ_—Ç·ÈÏßjñ»WonÞ~Íæfá¿Ð÷ñØ4(ûØ÷ŸyÜý¿A@*IR—έ­¶[S:ʵۘĒÉSçtB+SÒ]©ïS÷@8ò÷^®~cit=\r ¡ˆÎ" ®ÑàFk’í}ˆFÝ –[mÕJ“.ª¼®+mû{Û3d¡ÊmtgÕµ½5Žw('ÛDkêtN»ÔmH”pTeé?uI·)Û'”Zo!i]‹¸œå _)ºîUVáö;§ÒA¹O)B‘Q¬², ?™7Å”mo4ÅCn*+Ç-,H(6š¢pvH•…²•˜ZGì%|÷IÝ+ÙY/´¡å6»’´Ô±Kï5o]iŠuö@øÍä¹.‡pÅU AÝ{îôFݧ¦*/Û«öEÁd‚þOߥEœU‰¦SvØ5ù ìn}J£™mS'ð°]l}+ëÜ$z¥ªÌµQPØ»s;{P"Ûį4’¤æi8’4Ûš.‘ÿùø´‘è7GKo—f­u rúß;ÞC­ßÂ…ãÃ8þäýÝbY“ëcwÿصDç·õí‹Æ@/ieS:¬Ô*‘®Î Ê_¯ViœêÂ1(r%À¢mw>‡~O€4Öñ)4¾Ï€Aè)Ü+Àãm{ÔÛf’Öç=M“ñ‘¶ãv€©W[ø°a…}è‹+8c¨‚àØ¦™æ ¯=⫇h©ã»ð¼wHõMè0ê ëMÙCX×Îl9*)¨uº\©‘h¬ª-0`ΘÜ)ÝÄÈ‹ƒ'Š`§x´-MRAdר€Î¸)¾w× ³Çâœ÷=òàXBv;¨ÿsݽK1ÈFeÖwë´sBûˆé³Õ:3w*ëȰˆ*‚‡ûDT W$H¦0æ'¤`÷˜zh«âÏ<”!ˆr¶²i±èꇘFåw5•,Õx‡»zÝÛ sõ˜€Õ¯˜Âå)"þ_jR½Ñ”9¦Çú–ÀKÂi‰AäÌû1x°7b=m3ЭTÄZ—LÕm¦5Ô#Îmˆ¹÷1Îè•0 C0ÌRL8˜QQ@]#IÍè8ä^ýÜ/Þ‘‹7à\DTëjV·º”¹B4q«ð°am¥z—/4eÆ|¦¦ÒW&ËÌ™éÅ»Ô+XXÄðž«eU•l2ü…”‹âKÚ8·½x<lUhÛQ‚Ìgf«ËÑsÜaGv“®— ïmÎ0ظ<ûC©ÊXו%Wdïë=ô‚˯gžŒBW\uÏhiÁGF×óv¡«U3¨HQ¼+ͺTyÞø¾gîw5×ÎM…rÖwsÛð±¹ñ ¸‹Aj÷¦*.¾©ïÞ~Šäµ¦ÌÛ%^&Ùã—ˆ½ËtÛ B8™\Ò_ìÙ\|}tn塯o|¢àù·½‚Â(ºÄ‹h'€¶ªû§§Ýäí+úš[.ÝÚ~¿õ‡bû€û(ÿ¥Â YOöuŸõ.ìèȪ\XAЕë}Z«m”RbÈDÅãnUe”T%ò+ÙÄÎÔôGjQ¤XÍ'TÚÈѾyxdz­âÆ÷ÔA¥€>ltAÕÕ“ˆrC¯ü3¾öÌ6e(ÌÝG¦à+¤ºiß^&ʤn*ÇÆ]xJfÛ½éY™˜Djjèz¯Là(ƒDã=Ù£Û[àÆIÈèú¢i ~ â«À$À¿„¾è•mÝwGwàhzEŠ´ˆ–¯)OX¹8Hj‹è( ò$,ÊŒ¢ºéKkˆçùå8üœ„^üj𾤠6]ó«¡cð†zÔ & nje™âï žc]¹qƒ°@UÑ=TÝ´éc%ñƤqŸ¢¬É*Τþ>åwɘÊ ÄÈàS“ÐrSq: èCƒv#|@àH(ý„®F-{rèv%6á×»‡zîé éeJàµÆ÷5ÃÚ°µ¡-õ:‚{ï] êTÁ"$ˆ2ã×Ý¢äðÞgeJPÙ*ôÝ€rû@Ä¡fÚ³d\Y‡=O¡r«÷îoÞûÝ|xõ’œú êØ¸~¤Âù`·‚EH1f³4cæDõpH¸iö‘ê3‡"‘ïû‰°›’³}¬DÊek¬•¢ô´µƒÀa“I×OU[¿QeZÌágÛó-ÖÏæ7Ú}¸{ZFU7¤ß´©ÿ5ìÑ·q}aÛÿwÏÜE5ÑxÌ&3š/p8½gü±öGƒì¾ÚÔ;ÏÎë/y 6áÍqDs3| žDøin2›òñË“ŸOþÉÎendstream endobj 5376 0 obj<>/XObject<<>>>>/Annots 2413 0 R>>endobj 5377 0 obj<>stream x­XÛnÛF}÷W U›u³Ý¹8©S#McR÷a%®¤MH®Â‹µÈ¿÷Ìì’"i9N"‚œår‡3g.çPŸBêã_Hà æÉA?èã …üõþõA8 Îh|vô)¡Ñ0˜øEL×eB“a}#ï5– ž¶Î5– …áiëàèdÄë ÀÇá(ù›…o¸6”½aœøo5–|ŽÈ¼×X›>{Sï5– Z6Kx:ÃÆÁæ»ã {Z›m®ôà lìrƒ¡ã,ûûÆÁ)8ÄÃD²·[²Í>Ö{ϧôI³%¿êÓ)¼ž.p;MÎÂ`29¡i$IîÓtÞ[—³ØÌI§eBÏõFgj©éŸ'Ó}: qKÔ#zvuqعtõìõÅû›^Ø¿yÒݺžþúû´{ñÝåÕõÛ‹÷{.¸éùÍ›'?užòg¤¢ÈƦ*¦¼\¯mVP¢‹•r²‰) ÑÂf4ËôÆ[‘¿Zf¾òêøÕˆ8œ‰#äÒ!ѻ֚äöví¼Þ»Ì®uFoÔF9€æ±Ês·o¯°îQa)‡µb¥kÇ:4ÅæR§À™ýÞ™^©œÙ2oF\EZØ*¦礲ËyËéÖ+2)PR±ù[gù!š¯6]ìhh‰½'is×*õtÙôùA¾Õühu¢¦ÝÚò@ET)³—µ¸¹w„°ÝF­p¹V• ÏrÌÀÈ€h4l‘Œm±IË´ç±ÐîõGlœŸìÒä·ËG@6†Ëe.%Ì#" +]üS¡>¡ô)¶öñLIQ\l¾Dš4z4Ã!H5ê=6é<.#MûžVÁ‚É‹;Ûó¥Mt‚ÃŽ}…oIFõyØ?$G¨TQ(ÿçù_ÑW1µ«É½Ýš8®›õGv©­ Áx)àªÏÜΧV0D­{}Ù¢`Ùs:§~;¼ûo—q üî‚N¸“O)üÞGUx;8é¿ý€Gz í~[\<¦âV–Z³DÁÇ[©×)Þáéf¹@b¹¼5Ûõ$ˆÑ·¬ ³6® Ý×\ç)ÒàsaÔü©–hY4v•Qa 4c“™î"a$u?¿í%ÊšÖ ÛdØÿï)~ßáÇš#àÉzöï'H­ß”EËØÎ0˜¹[1­¡k$˜2doV‰"n€ó-ôë–Úk5ÿÄrkK±Sæ&]„aîC-‰b#J¶\Kî}n‡8 /÷¸ÂeÈÑv%³_¶Ž^ÚZ`§Ë46˜Ž­)zh^¦?—P49æ óÔRbóÂqEf±€ÄÁ|È·à†/R¢ÄKÀ{U‰ã´é ’˜/×ËLaØ‚ÁVüÎå‹aa¼Þ¼üo°c¦˜Ä"OkTü¢Œ û19}árÀ(í¦jÍôª5ÍãàN+a%ö±Y@Õm]täʇ¥Ùƒäßh[ÏÛ ç‚+E–ewÊñªA‚dRÍ ­¢Cz¨¶96‘ǵ­'»‘-Ô3æ‚r¯9Ï6)áNùŠ&„1“‰"ò†çn~ n`ÖJÖe†!»U™ÄÓJ”+ܶø0)—¾ Û÷;Þ5!b.Ý*fM‚R]$?hMñ÷=&º]좤á€M· ¿´É~«·ªˆ¶À«ÛáQÌU‰ÑÌo–r÷QÖÛg³¾«~Ýtï’¢ˆY!ÕŠ€sÌ¢HPœ¬ajíã;`ܼ/@0031¿Asë{©°£œë?._…ÐŃP&»VYlf[-ÛP²  ‡•Œ58Ã{aìœÞ×$€¥¸3CÍ@dR0Âoõ„ ­6Ì¨ŠÆõŠÌÿ&€A{«2üRÀ¤¸‹°z»…Œ¼Þc8VÕ©‡jÐãá˜&“S–s‚ÿ~óÒΡç=üô—»óèÄý|â_&†ô®ûòÅ·û“`8ÀÏp0:ùÒÅôà·ƒ´Ä÷¡endstream endobj 5378 0 obj<>/XObject<<>>>>>>endobj 5379 0 obj<>stream x•WkoÛ6ýž_q ˜›ØJb'nöÚ¬YSô5Ôk1À@AK”ÍV"5’Šë ûï;—¤œÈM šX&ïóœs¯þÚ;¡cü;¡É”òzïÙlï8;ÆÃívIG—ßÓɘf%ÎNÏÏiV„ïi–ÆgÙ$›Ò;£´—Ö=ž}Þ;º<¥|ÉÇGãÓìG‡‡Ô¤c$¬¤²­ª ¹¶iŒõ² Å†Þ¼ú-£ËÖú•´µ±rÑJ8Ò†k•¬im쥗´V~EJç¦n*é%ùM#ñ¹4¶^q8‚ƒ//$œ*G‚¬`ûäßÃD^Š\þ£?¦ólÂá9þq6™àS1xT›¢ÅqùUðµdgðÝåÕ«çtPšFêù 7ÚyÊWÂ⑪¤5ò¸ý–äüñ]tÁ¢ ²i½ëR´}çñ¼2NΓ÷tâ¦ú£?º3}Â1~\IMk+šFCÚ˜å«*ZH(*yC­Ã¯7Fç\>‡Ò ZZøÖŠŠÖbC¥55½×]2¶«ÅÃ…ã¦Îþ|÷üSó)äRÒÏÝÅ,•lÿs«¿ì÷×û»y¦jg©4û/dUúhlUÌçzHå½7Ruº÷æâ–È— À Rj7#Õy@±ˆÕßu@‰0TF/ã£ùº Üç¢Å7W´0­.„ÝÐJVEÀnpDNOi¡<é¶^H›Ñk¡7d¢B~¹ŽT ½lÅR¦ð\hšÐ$Á‚‚9aÊà01-Æì¼ÅWÍV-v¹Uç³±h…3>l«½ªò•Ì¿ìD‚Q±®U9±Eðf6TðÕwäFÁÇݳà»-êAÖWšŒ-@K 1³– Ä7MÙ+ÌVUXPSnÑ0ÆÁÝK˜g}çCóJ8sê i`ƒ¹Ž<Øér$ânŸ·…v[GA–D<8MR8…ê…ã²ÂØ5›‹ªäâcHtÐÓÁ•v.ur7ŠûVç’Ì ¥™ð"vªsjŸe•t ¥•ZÜ p*,#•ûP¨²„j¢·TÁ¯„G¹6€CVæR¡d0•¬ ßË–µ9 Œ†+nÔ2¨BøÎ3`@´_‡{Ò÷–ì¼-™Ö:HjˆC9¾^·ùŠ¡Ï€BÞV3ðáÃumí׿©‹7WÂZ-Wžë€YRq¹8-ð_• ™.ˆkQµ%A¾lc"xÄ“‹‡à—á¯Qç„U!a0“ Q¤W›Ê,NµÄ̃ˢ°¸×Q½¶Úp½b}o{ ~ͪRHLŸ(QÅ ÛÜ–ÅÆËQ`V°ä¡žÇ$Í*“Ù°ÎB-Gl ½?*å}%Ó“ùcè“Á|{ùá5F)è5ñÂ\©DœÎ z Õƒ,A¬ZܣȉòÀ™K—cBZz`ɵ•zm Îäîl²ï`2€`€Ù¾Z3„Vèm¨,jºó7)Ö"ñ˜ïÔHªÌº§î÷jB‰ŒžqœZœE ¡Ð`¨4gk¡[Ð{öqY¶è0må:2rÕ:nYÔ*…9Œäo«#,ĵ­@Bæƒ|‚ªàgÍ£Ÿ±9ÞÃ"ŽXûÊ@-#æw‚ÌcAxu Å:½¶Š öJã ŽùÖàûÛk„óRÿcgx¤4‘ýÓ™KÒÑ]Œœß`_ ¡õ¾~Æ+×¥13ƒ¿°ƒ lþ˜úFˆ3¬4à7p¢ì/cÿ&³q»c¯‡‡ø Ž`jfðW2ºxÀošŸ8‡Ÿpåà—ùçŠ!¸¸Ò¹ §r¸ w9ê2,ÕÝVy `§ ‰Þ»=cá¤ì/ܨEÜÝÊ´ØdD…ÍswK$㘡vÓ-ÀíÖÎÈÁó–e"Ìì^ƒ»î†ý§Æþ™'°L-ñ$À·•à~˜ò;Í ¹½øæW¯¶ŒCj|3ã//Xyy bœ@¥€`HY„Éqûh4žrí›Ïzïm›MòþwŸD2½ øJ’® A%zÊÍjßo–Òó›U'—þæLä<\¸äœFvGpÔ*^çwjÍu<º¼çÅ&†C0Ö`ö®€.„ ײx}n†ï*|<º>/XObject<<>>>>/Annots 2416 0 R>>endobj 5381 0 obj<>stream x­WÛ’ÓF}߯è*Úe­õm½&TÂÂR¤ò°N§¨±4¶ÅJ¡‘|)*ÿžÓ=º^’P`ifzºOŸ>Ýút6¢!þÑdÆ‚älèñ†ÿñ_o_ŸM¯ý Í&þš7¿cº?kŸz6õ§n¯´O Æ£îRçkÓ‘?ku±6ùÏ:kí#ÖæsÞ®‡óÖÇñõ´{®ó˜Ðx6õGsí#ÖžMº6_,:X ù†®î¦4Òb Ðf³9-BÁ o/²TZ’²´6qlööÇóÅdz«»!±w83Ò`<ö'<…ÞŸ:(LN;ú‰R½'÷¸ô–çÏù¶òE¡·ó­.þZzÿú«Kï—Þ?>] M¹Š5`|çoÄÀ#[Žõª¶´QÄå‰?›Ý°/‹­¦Ê#ŶáV¡sK* 7¸ß¹&[C+ÅP˜” ùEíÔ ­R µ6)eŠw§Ø™k)0;c{™†:—¯c³Rqs—ÅeA™Ô¯¡³;÷QÅ*'ÚZB²Ü좦Ö@¶LqÂùÇ^d@$ (T…¢D'+öݬéöéS be­¶µõñÔ ƒfõ7³i¥Šã#â¥(µ…JÍç•„çLÀwUÐ XiÒ>WYÆŒÈ BÃÎÌD)"§ÂH”·d‹¼„Ý\û´Øâ’Æph´M(zá6„N‹m”nƒ¨ ¥-€P¾Óp†Ã‘M"êÓ+Ûˆ¶:qc“"w¬Šï“2ØÊ¢U‰¦½Bè¶çPe7"íbmu¤â˜a³Dž7ÀÒ]™#9P¨(Ɖ•) ‡œ8[ïS5ÅQQ€j±j’®¦º.O’,@µ´õº V-Êb970i €^v¹ ±Ž»šé qÈÓJSsõ ÈÆ¡õÅ{%IYpY¸…Z%< £œ©»Ó5¹FBÝ;ðST’ÅúÛ*áBwÆÐç|Ñ"òýÆhýªu¤¯"Ø êÑá9~ÈWô¶¢AëâêôŠ`‹úºHA€/ì=©"þbáÔ­eG›Qy·E©œàé®=ŲSµ§I­JíR’F:-/QÙeÒä2<"–(p… ‘À,äõć›Lpêòv²âÝßÄÒ-I^z¡Ît2i …û­–€‰ÔtÿîÍk–¼ÄRT¸R#“±Ö-Ï}lX¼¡¨rÅ!À.^ƒ:nbÞGq Ö²K#¹Žµ2kµ’v³Sq©)·€OoÖ@ŽÈŠo|åJoÕ.‚³GS¢úS\&¿Ø>V4WìqÉ'*#Ž×y´¤R²¡òÕ*né&Ž}V<”e®Žö²r‘Gæå=;•¨Tm8‹[héf[ËšõQM%]2 úÏM$úNû­ ëøý¹«®"©:ü=šýÓg÷w¨ÌñI/‚§Pî{Ьî€G@ð»^²{«jBÀï¦E7ã³hñþ·W²RàØ»ê7üG oÁ ¯û«´.ãFØt,$b]¦Òy-œEoÓ‡Œû! k²ÆíÐÑ¿fý¸pïZ\zÒ¥$ì[¦ö{°ª‘\Pöy¸`VrWMëœH% jê»jU¨!î(U="|[RÿLøÙVð­üÕøvÀlUko÷ß«+º5Ï@•f!ø•`„ÿÐGñD8™ù$ sUÍC ÖskL5—-Ï/Ü&‹0$0ÔØŒÖÔ»—_;ƒoò‚e«&›Ö®/OÓ¯ûîz•~Ebª¶w‰ŸëLoxÛ›"Ї¤_¹>n+·õ¯SŒ=,梎õ9" -[<È<4ˆÖ¢SÌd¨ÍJ…=&Utqe™`¦D,JzÃð)^Z«2.ˆÑuƒ%TrÆã§ŒT¡v¤ç0HÎ= bh–ÓÇÙ´°Þ¤À;Ö’ ³îùÓbÎڌɹʨ»y›ÄMI(Uk½ç"Œ1÷ŠjKW•‹–™²BBè#L©ÅVtY;´`ÍÂP‡Ù+ŽRÝGF›e‹]ûŸ‚øüñÞñ\Ç!ßÖÚ,a¡«^ôÖßM :|Ìè©$¾ßÒÏ¢ø©¾Nui’õLïFò¶]·¨°:îužK¼ã®Ș厙ò5!¹$[f·"n}®ëíMÛ-rñÐïµMŸW£êx8õ¯'×4›»ÏHö€¿§_š£IÅ:ŽîvnÜÇßßÛþ Ýן 2_gþdŒ/P|M®oøà«ÅÙïgÿC1Áüendstream endobj 5382 0 obj<>/XObject<<>>>>>>endobj 5383 0 obj<>stream x•V]oÛ6}÷¯¸èà¦1­H±“®Ø€&›‡iÑÁúâJ¢lµ’¨‘”?Pl¿½÷’’bÉnš&†aI‡÷ãðœKý;ºÿ¯ œÑ'.FwË‘Ï|¼Ù}©5Læ>ܲ–)>Ì^_±Ùì–‰Eù°Œ=mT˜K __.?|_áƒÄ€¬4Àßôîþ×^b85«ï¸:]M!ÓîbºÕ“ù5Ðu cŒ2¦(ïƒÜ]‚®«Jjfà d <Ž…Öx-€J¡–Üj/u×m4 QDBL‡H,pˆÍ³/”$Ó¿¶Q‰ C¤-ñ¨µ~ƒR쯼ÕË~OÔæ[ 3ïž·Éw¥Í 1×ârXç~Xe¦C%q'°/K‰½@:ä9F°˜a»Ãd¥Î’ £œÁ)üßš¶<¯p kQ ÅH :¸î!–‰x§”]g¿DãßÓ7¨4ú›\ÀGj´+5‚‹I¿¼^îDÌk+ÑqÔÐÓtk›° ¯²MrŠy …L²”zØRKIy™€Ø u@M”kØIõEÃçZ°J¡¥;YçÚW"6 -c5E† H)bÏ‹*OÉéQFL óvå…(8bgï]ÕK'^:«ž‘ e´ÿÕ[²ïGoIöŒÃØmò±P]úÉü5Pç­§­ƒ) Ù-Ü¿zq‹äùkvMœa€+;Å«Ê ìo¾åízRßNä¹%7À} Yjwt÷ÎÉ~é²¾#?ÛŠà!Ã}ýÚc¤ª£<‹­–;bÁ;OÝÿŸ"œ{@3´à*Þ¬¼xƒÓã"3¢N €­Ì2¥Pç‡@% ¹O]œB+ª(OsÚârQ®Í¦ïÈ æÖ7d¶Ì`Õ`wç™#Ô’7¢?Ï[ÎZ&^¼ÍÅ‹aåGFÖæ)À_ uXE®¦­ÀBršÕ+/æ!~=-èÁ’Õmôw§ú= nxsá@A=»³ ”uµà%RÒô=¸‡“fkŒ…á&‹ {ëRתR™ÆvòCg ¦Ýwj:)㣞Ó΋ŠÏòE›Íª8•²cèÈ#-†X¸ú)Å-éôé7DÙÍb^@bsÊu×Ã5]Þ6ïͦáf7¾›8‹Oïþ‡Ì‡?d\8ù‘gY÷x¸8ìøÆ½­œŸcSÆÂß½p|…Ó[ZùçrôÏèZo­Eendstream endobj 5384 0 obj<>/XObject<<>>>>>>endobj 5385 0 obj<>stream xVMsÛ6½ëWì)C'õeÉv:=ÄnÕIikÚCÕD‚’`в¦ÓÿÞ·IK²åÄöx$»À¾}ï-þéhˆßMfü—½›Eoñ°ûgÖ4˜é*žÐ"£ñf×£x6»¤EêW i‘Dw•(âLëe´<ûélñµ7¤þoÒH•ŽVÂÐÏä׬¥»¦[6˜_Óh̉ûÈÜO›Ì>Mâkº}ó†T¹‘F9Q&’3æÄ©3¼?¾ˆ/x—»?ßÿFÊRVçùŽÄVI:Ã[KKFæÂÉ”œ>NÓÉe¦<'•ÑN×´÷’’\X‹Ð\}“ä6ʆ­÷qèÇñdTÒȯ¦¹ÖôïAñq|ÿ¯ÅÅvaÀƒÞRU¯r•üpŽGp“8·ÑöñøŒÃÖˆªBõè„&A%0ÉfÇ}÷¢«Õm„VY.‡š%YQÈ}øÉ:S'®6òí‹ppE+t¼”[ÚïvGŠ[F—,YÅ`„ÿÚq¢[u·³N±®]\œ>/—QÂëïêJ9ñ“8)nØw­Ês®;ѵL©²U.v/Wƒ¶†j[Þ!>¯ À2Åeu™8¥ËeѽV)Y(i1•^g߫ۖ¾Q¾ívÔö&¨$ —g‡ED$’DV΢ÁÖ‹Ë20G±OjH›ÃQ‚I UF?ì:6¥í=h—]|?m«“±—óGíXu £¯,ÕPb©Ùºª´qTÔ¹SU~DN°gyö 8±$:E\È·Öª\³-lµùÓ;‚q”xÄ(0 áLp0KkTRÒ–á~>½¥T:ÈõŠ2%]Â…XA™2–ý¯•$o\[™úrÍlÆ{yÛCß>á`N{Îz„AÁûðY#vÖïP±€V;ºy}Úß—lxç|›AÁ¥*óIêå|°ÍÀT*ÔzÃHTì7B€ªjöOÒ«¯(ÑÆ0)CòAèÀËÒé=j(ýJ“ÿ èSSCŠmA÷ÖØEŽCä«g#;pž„ØÇPÚÛµC®ó›nÏ‹&Ûã"îƒÏi`J9á ž™Û"ïéÆ*E`;N5ˆw¦ß·•LT¦ÖFúAÆl:P©÷>‰N,ºÆ–š™Ú¦Ä3¸ƒ 72` Âcíœüè¬Kl ‘aëðFb‰ÛUxä4ü•åÝh(Œãu¨Ð­› 3‚‹À(ÅÐÝx~vr+ jµŒÃ”cUÀÑ3° A¹\‹œE™jÄà çËdcÏÌš©ƒÏ~žwüÖH¦¯àáÚââIÖp8f‡CÙoÁMDü3h$x2Ä< øÒ*õdøxò«·µ¾p_Ú?xx¸>ppHæ²¥;võ£Ñt§ •ó0–¸Ô(¨V' ᾑc—Á@5Ýõ‘Û×5êñ*tÎÞ ÷îB܆׌èôéDçw¯øÝìùw~ú]vïó«æª7ººˆ§“)ͦ—ñ(ܹ˜·ýI<¤_tR3‚g- „ÕýË€ééËät8‹'cÜ$ὓé5Gÿºè}îýÜ/Qendstream endobj 5386 0 obj<>/XObject<<>>>>>>endobj 5387 0 obj<>stream x•VÛrÛ6}×Wìd¦)ÝX´$ÊrÒN7®Óɤ»ÍtF/ ŠˆI‚HÉj§ÿÞ³I™ªåI}M‹³»gÏîçÑ”&øžR´àŸ¸½¹M ^ö̚ήæ4Ðmн‹WxHÜ:â ÎdI"ϩΌ””6e\+]ZÚ*¼4²n Ö©Òª¬¥¡Z“Õ…¤“ÛO£³+\íÌWZû7ÝEéÕ'×!ݨ2–°Î¿Ê$ý ´ l%Š‹åI{‹Å5‘7ò”J¹ÍwŒJÇ¢– ›žÐx:ò …6;R–+”韸ÀHÛä5‰2y€½ؼ ~ѹ–Ka*K­Ñ-Ã[b¿qÂ{ñµ¥T•"W!Ê𘦤ÕÎZ ³kI±Îsø®Íò$ôayÕÇ<›³³ó0 §“pJĹ ¯³ü0[íîÚÜ©r àuFåø± é59ßü}}bx³µÏL,€Xúð±Çr¯bPg:!y_;'£2ú~Gq.¬%Ôï*¹5¢ª°Û½t¾õy¹Ö[6tJªfP¥®á•µj•#Æš*¶â ãŸË³Ë/z&XOÔT‹;‰mFˆ4–ƒêèÀwãÙÈT .…ô.¥n¨ øÓ1u-‘øAb8°¿xÚ¾½eÅ´nÓ1¡—aÄõ0üÙ,Œ"ü—ò^U.Cæåt0ÚåÉwDtvF­%“¾ë®áJšú­ÃŒcÁ9j(:0ô×Åÿ52?0òÚ±ëØÓl종‹Å;t…x{Êô,rñïö4â2{dßü?ûVzãàK Š\‚F”6çò'H?üþþ}W)”%sŠË«\´CV…t›IÆÒ34Ö%Š’¹Õ¤ã¸1öÔsOáá¡yÐßó„o™‡Î:½h@BYNzñI.àÅJoúqc}Ï{}˜× Âgr-D¢—çá½|l:a9và´­o8ʉC,lm)ïk¡m ͵MUiÃAGÉÝ||÷cḢ¶2Pܾô2Á)Ýê= ÊÕÝ0Ü{ûm²Gëí«B' 䡵Î{ÙWV­à®ÖËÙG¶‹Üo’`¿gÂÐ7q»á(§ÿ„L°ì¡e0U PÊË%>!B­³œÚ ´¨B”¥4Ocï´ÂAŒ¼L@)Üäb||pêÙµD‡{ÖíNõ.ùØuwP¥7ªP¹0ùn˜Ñê5gž‚×ÞÊÅóâŽîMpVÍ*W±‹— :»†Ëà0ý‚#ï¡çí þc8ƒÿ¸¤ÍK;çlkT-}¶bHG4çÚÓ b)}ϳDÛeêK#¡-H>ö \çsë‡çÒ.Aþœ®v”>™šŸÛzeijë©ëˆŸöE`œÈå½kxQµ˜”0XÕªÜÑêœù¦ÜvH®G ÷ÖDYQ¬Ôºq^tG°Ø9ã†%´yLKÌR—ÐHè 7rp¼ª öÚÊ:ŠJtòÅ냲:Ю¹C/U¿Ú”V­y¨²$¦eÈÑô_sVÀiÖð<{Сw°±-$w ã‡@ŒÄNZ¾Àƒ”©ý†ÕduHÞ½Üðúóný(tÌ'‰DiáGiÛÄ'ˆ¸û`‚˜“†£ AyJNòoyˆì+¸Åþ²!g“yxÓâ¢U|fÅ8 'ôƒŽ›B–µ»•iÉð{Ǿ„Û©³fÐ ú©ŠûϺÄOkÝÆ¦Î'‹0š¡?A}£Å„_½½ý:úۋħendstream endobj 5388 0 obj<>/XObject<<>>>>/Annots 2419 0 R>>endobj 5389 0 obj<>stream xµWÑnÛ6}÷WÜ— ê(–e;nŠ)¯ —PkCÐÅÍ„8ª sÀ<§f´ÐT”ÔÜ—vH;Ý’,›{iHIßènèî— ÉGF*QKÒ& ì/ë8ŠH+,*pŠ ‰Ú˜nÀ^q\ŸÉóñ8NSðšGßùS–“óWÛqòeªÞô(Šã>e]v;ÂÞ~zG+žV_\Ð/zK‘#è”ÏâÑÚ¼œ¤/ñ üÿY}ð ó_S2>heÚie<Ó3o_½¢\¢­æ®­¥jl?yÖØ-Œò}¯vT´*kJ­h u‘xM¥¥­ë5D·ÚÑTÒˆ†ûD(y^r°¨û,‘a¯p>´ñc› ºg…1*n¤“w8¤² ­¤{±‘N’…®*½åÓÙW´Xë¼­d'ܰ=Z Û;é„ãí2Êu»ÂÊüšMg*À»-Ï\-O÷#Zä€Ç»‚E–²# •ÊÁþIl ¥C˜¾ß:,Œ”¬v î߈ª•ɵUΈh…Þqˆ|#T#îœÃF×ÄÂD÷µÆÝ$¹lDY¨êzsß´Žº‡¡·‘”qG‚Þ=ÕNùåFªšÐ5¯÷fQy~E½û’Q¹›éðÁW4à,*Ô¤³@®ÉŒkâÍ/uæÇ—|?“§]ÏÕ„Ùr(ÇäO¢é iG|ŒÖÞÁ†knñbq3ƒ# iëã+ȶUT¢i$Ä€½z<€Ig¸‘ÕÎßÖ‰€:¦[Í®ÊîÏØG:à°UíªÎøn{ï@Á|ð6qó{V¸–¸zP²w«Î«WFsµkvGM¶]ù!ƒõÉ÷^ λù™âÌ[àí%W僗ÍO<ýŽxÁ»éZ?sEgÞ…ÈšeÄ6®‚‰óÅ|.À-¶ä¾¾¿3Â…ð8Ü ÿí_è˜üÜÿÆO:ZÙÐV›8šòJ¹ù[ã+—Ã/èºóÿØ'•>M(¤±ÁJ%·!«eôtÙ&¶²ùs¥ñd¯Íƒ™%óI>/XObject<<>>>>/Annots 2422 0 R>>endobj 5391 0 obj<>stream x•WýoÓHý½ÅH'¨©Iì&”‡Ä÷ÄÇAt=¤JÕÖÞ$Km¯om'D'îo¿7»^'N§-‰½;;óæÍ›Ù¿F4ÄßÅþ—äGÃpˆ'ükÄ¿>½>ŠÆ“pBãá8RNÑYžµß2ú|´û=§xtŽvÞÆ£8<¥èQl÷Æñ(ŒÚo¼w÷;öŽ£p¼ûvç;Þ†·Ä{ŸÍv\µþš=x5¤³0¦Ùœ¢!MÂÉä!ÍRÐfIêæ*“´¡ßh.dýå"¸¸÷ë½Ù×£¯Ni„5s:ÁÞ“(n÷oæ´Ñ¡Òè…9-EE¹6’ê¥(H’ ‘˪‰Ø”èbž©¤®è"PsÅæâ%X|%ÉÈJg+™RS©bAîd€mOîÉÆúþôJ’ßD^frêwlã<‰¢0Žuê÷_Ï„¹„K9ÆÇé”?Û094œ•Ó°®é6‹wìGþ¨¢&kÁÔ½ýޮݷƒƒnoç`Ú+ù#¸lʹ¡µ€³µ¦k)K¤E*CÕ&¿ÒYE•,…5Rƒ¬T*•†ÖF”%ƒ•9!›~ }>óÚ1¹N›LV!½ÉÒ¾†/üȧ³Ìö”ÁÒ$¶†@†k±¡Gê”Í–’R9MVƒ L1­RY%F]Áˆ¸Òˆµå‰ÊÁ7æÉJ vÔ2e¯8Áø °Ä£¹uc,q¶‹|Y!½×µ%lMªg³ ­µ¹®hf%™¨*Y ¨ªMÖ¨)Àê!ÁPË¢É+8Œ ž­U½TÂf*¥ôüþým%„t¾”…u¼ï!© Ô—éÀ¾ëí©f9M+ijdP{>¼+A-´é¹5Qáp{nHþ¶ñáXcõ²9äpkÃò1T\ÛØ™‹kY‚”Fc_"2‰eøß¾ÓóÎIƒ°•0í‘´^*Ö:„€ïm ‡?öjãyÒÓŠlX©æ£5j®)Km@çM‰'»¦Z {nx“"IdeåÀ¾bß>bÅlµç¤µå{1 ãØqÛ#gû²ÞïIj¿¢LúCT|l7$Ôi‚¸\'†¢Xœ*œÂn;?à!®]m3jÅp¢3:ŒÚ彈m¤47T{ ¼Y¢…Î[—ŒÆN&h畺R™ª7]쥶‘sçs'sv%:}FÁ?ÿXï‹åÜJ+ð£ç¥Ÿ6Žo-Ôâ1ûs\bV‰+ÜC¤dV\¾}úçÓg^|¹üøéÃ__œ3[~æ"1ª-8™Ø‚¶¥ÏÄËEéŠî~±NœíGÄj<Çuä$šð¼Ã8ÚÁ¢–~¡ÎÖÆ¶~yí)îXÍ£D·ªÕÒIç&#hÙ,b£QйžC éw½F!›%ááð$Ôl[‡Á8Ä#¦•¼¬% ÊVM·²¹k8ÆMV¶ËÕ*i00uÎᬪÆÀª÷Rh¥†·È‚jObV3Ï*]úïøàö3‘*ƒÔª• oqOh§Ø¶ø¬6ßéß~QE’5ðÇMmyû¤¿ºðN>v2¡iòxI³¨¿Ï1EƒY½ îLp—f#š+SÕ—üÀ__º+J·*ÂàâI/óFnìŸù}7Þ°WÝŰ»÷À1÷Â*œ»ë.5‚»ÛÞ"wÿ{ØÊwš»>ui½x½Rmþðš0ÀÏ»|ËøýŽUØÆÙöü³v–‹†§á8Óä¬-&ì _Â_èãmQ[îq"aÏ­=yè€uU÷Çy[vãá$Œ#Ô'ª-žD¼ûåìè£ÿV8þendstream endobj 5392 0 obj<>/XObject<<>>>>/Annots 2424 0 R>>endobj 5393 0 obj<>stream x…WïoÛF ýž¿‚PÀmcűÛý±]×t)°®k lgùl_+é´»“cèÿ¾Gž¥Zn’¶E IäùøH¾ü{tF=ü=£Áˆÿ¥ùQ/éá ÿ8ãŸß çIŸFÃqÒ£œ†£^2Ù=et}´ÿŒ¯ãq2Þÿº÷Œ¯/&ÍIìûëtï:¹Ó-éô²G“d@Óõ{4zq–ŒFcšÎ%¨MÓN©Œ3†Jú… ½¡øxÓœ ož¾z:ýrÔ£î,çSZçLËd©Ã%?Ütî³ó:µÅ¼6¼–§ÆòôrH|䂺ªÛì‚êü9[[ùl{Ba¥&ã)·ø?X :/34mœ*KS,a¢ ò+»)Èx‚±¾S°Ò ýÁ^s”É<¥°›iZØ !‰©&ɬ]ÀÕ¹þûê=)˜½}þ¼mR#ÊpôŽt¥Ê ]Âf§—/ˆß.PþnÄŸûçÉ 9;çƒè:W.Ð' µóÑ¡†€†É]® JµCÌ…x•Î.Êý ™ÀH¤6Ï-µTyMi¦¼×žQ´RkuÑÑsšmÉÛnª² Ç^(w$Çô^Úᣠm$¤&1S¬m¶–£µ\e¤¾ã/Çk ƒë"xÁ“ÉëÚ±%ŽÖu/¸êíŒ;”™¯¨) ö2~Ùçh·ßO0vÞ©Kþ:^9½ˆIG8?Gÿ±;Ç-ü$¢$‘r쿚ҳv0mRßãô­îG§+] " ÚÚ*â®va5Y<šULæÒÚƒðËj–™TÙŸÀØ@w?DßÏ”kÚªñú&ÆvÙjÑ6¶Ê@©µôSVyôK–ÙÍOj$ÔF-^#¡ ™"oF›âQ¾§§ßÍAÉ\£aé¦SØ{7²£‰ý°‚e÷âcdð Ýû§ã®—/ïZ\`̶<~º5D‡Þµ#¾?^p+M ZóƒZ«òÌý-º"Ãì•¡1³U€Q-{­P#Ô¾¤³# ÏvÒÝL¯uvØIHîÐÓξè4`È)´‘¯0阋¦ðAÁüèP7#c+ë¡H*Ïã´íÔyRwßáí ~¡Sí½rÛØ»zê>ÞÌOr;¯2]ó©½¹û¦SÇÌ|zÚt¾°­Ý;â<Èúvƒ¶­Ë¤Ýycƒ0ÿ¿TXlÇë¾?žÈ^DÂ÷zçð¾a=f§çñÛÝߺ Z”‰×á¬],ÓC¢î=ל}€ìÉC\—#jçŸþ*Î6†•ÆúÀÆQ)W\˜Š%ª]¶eèꌜ•+âÖ9 Q{öþÀ¥àu¶hº‰÷Ú=t{‹õâöö¾]’ë°²s!b¨}W–Çk VÑBTJëŽÃ¹Ï’¢§½ìÙùYÌÛ_vx­h&IOd«€!]VY¹FðGË/eÀÆ#¥^èmˆÐ"P“ÉN°[é´¨$‚Æ Æb)Z™åj7>Ö*[Îl´ÒóŽ»Z¬7ôUoYP”¶À+¶ýÔØCnˆ°ðÁU)Š«Û§V-@æøÅú˽.w8'QdÆmËÚÌ}ÿWÔ\–Ž7¡Rœ§h¿Â"b{g DøŠ­fÃK™§,û`·6s6$îk*BVT$ßêÕBG8D-T%°|{Ê».µs-¢oa d0#6&¬¤Du2¬Ãra¼rjn–y;ˆß톻…+QTù ¥ ß'z­C7,imn‚Ô@"ßÕp?ƒ™3zAçÕ¥ä+¿**ŽºÅz˜AD²slV V§½b Ö~¤m«âÉi/*œR0À¨Œeˆv¹žÌ}úðñ*:FaZxÀïàÙ;ÙÉÀ~o˜œÎi4†Äóªìð»Ïo6­X9JÉÙ 2+wÇQÎE=)\ï"aáyo” úPÚˆƒÑ€ßMþ:údZìžendstream endobj 5394 0 obj<>/XObject<<>>>>/Annots 2430 0 R>>endobj 5395 0 obj<>stream xÅXmÚFþίåK}ða®U+¥×]õ%Aj? ¡Å^ÃÛKüÂA«ü÷ÎìbcsÆwm•Cpã}vö™—åSÏ‚!þYàxôöãÞÐâú°èãý›žíš.xžmzƒëšöQˆàC¯&Æ0ñcÖÐÅ)åDËqM§6³.Ç`¹vsnMÆÑ±gŽës'¶y îPYd=VYTc°m?¬RÄ1w‚ §±“ˆc·#sX;‰18ö¨¾ž3rJWÙRqìÖ-iìÇYjÅwº‚›é-X6ÌBô‰7™À,P®ÂÌ7Ð #Ó‚ÙšƒHržÆ<,=ÀÛŸïÁX–]Í6½›é,T'€:Bã>gÑø™wqIãŇßïßÀ’eÂÏ^4uJ³ `IÐ=Ÿî^¾¼à¯ÙÎúðœ‰(B$ßñ²<-ü¼H¹ZImR¶ÝŠd <óS±ä 3©¬„1YÇ,rܤÌ8œV!dk¶CXXErÉ"‹ÄÏ…Lj Eâ#MG‡0A#…6qh›ŽƒR`h£¦RÂ_åúHt`l‹e$üoÏ€^è%Ø×þ<Û²xnFRÄ}@Ôk¥œ_5õ?7ÅðÕjn¨ þZl³ã”“ãÊlÇô¼1™‡žO@¹8OY’…23z?h‚Dr2ž7²M¥Ïƒ"EÆ”ÐuÈüš#Á-CÀ³Œ'¹`Qt€-OiZ¤Ü¼rÿTˆ‹P–"¾)bÀ—WìÝL/0Oœ_'üaÿÌùÕ™ˆë”cð$€JÄ%)5™û\Z¢\¦x xÄs®1Õ a+²Vƒ° üˆ‹ýbÅså¸nG;Ú~8‹Œ5"z¦Dì«B Þj*¡Â÷ žc®B½w}Œ—‰Æ¥ôl5#l‰\"übP> ¤*+ó ™|“Ê "ŠïE–÷aYäT"­’˜E"?– ÎÒ ÙÉD@™ÌaÅž²œª<–è:„éQ*0«a]*0!Bam¼ز4~±Ð2*F¾LvêXA2©Ö*§“ÚNÕª´¼;®)+_ÿñë/ïg°‰$b£aw¯Þ½ƒ·lÇ|ÏâmÄñÙ‚bßB?Í ”^';¸ÞðdׇÎaü*ËV,*ÿQÃVÑ~ ú˜O ÷K¾6%Ü?}é nXº²Îsó¹¦R>Xû…¥2â"ÿ©©H±\n¸Ÿƒ²|2å: vÇ6”Ò%ÆËm¨Rñÿlã‹L×yÿÕ ¯Jû_êæÓ2NsgÑÁNg*©ƒù+ðr2Õjšj•¦^¬³S™öWÇ.ñ®ª›T·°L­¶–Ôe9ÃJ‡5,Ø.Qª´Ëƒ_×Y,³ªìa"´4¡ÝO׫Se{tÀèf B‘`ãÑ4IUÈZÐ<á:¦>:ïVk1z‡òw¿PEè£Z¸ªH\¬èg]D;øyp> Q§l; >øUEû·9Uc*!;ІÇiÔi©òJ  ƒ½«½:ÞT»t1ìgÔ[êXÃã¯ɱå•t¢æÇðÀÝ 5 *Cæs:бߨâ|”2XIØ †1_‚šðŠðJ‘N{<öñªƒ%Ï8OÊS7˜†ŒÅሉY§§îÂTªvY§šÚ¼…Ó= ÛîýA›Êé.WÝÓú—.iùaËËFþ Œ®»^,ƒ"Â+VyÝl5Aä€Ô|Lä^²ñ 2Úë†I:7ÓÉñöjG¦ëàÏ㡾ÃR“0pðRþ“ô‹0¬SR±Œ÷­;ëÖçYe—~5°ñ–Œ½’ãhõ׳Þo½¿§Æ¥endstream endobj 5396 0 obj<>/XObject<<>>>>/Annots 2432 0 R>>endobj 5397 0 obj<>stream xXmo#·þî_10`TÁÙkI«»Å}h.¹à‚6HsŠ¢ j—’hï.•]®m!Èï3$÷Õ”síÝA§%93ÏÌ<3œÕ¯g3šâïŒâÿKò³i4Å Ìøã§ïÎf7ËhF«ùm4¥œæóe´öO}>ë?cwyÝôw{Ï9ÅÓÙ`·ÿŒ]h¾íÉöŸ±»^F«þnï9§4/{»ýgìÆ³æÎGû­Ü±Ã8uƒÏÛ9ÌL³”´åhÐb>.^š-›õ[v$´Ñ 9ka1_Dqg⤪%Ì-‚Fz"#e§ÌÛõé C~6:6"#ÓT@•÷#°Ó);ež×c úÚèB~XL#ÓTH•ó#´Ó);eÞ®¯×`e q`£øá0L;PUÞÀNOd¤ì”y»¾jJfTq`£ùa1L;PUÞÀNOd¤ì”y»¾X£‡„òØèB~XL#ÓT@•÷#°Ó);eÞ®Çó~6:ÓÈ´PåýìôDFʾ¾;»þ¸ Ù”‡V·ø’"S\=wÉä_º¦\©ÐF%’Ì^úüÏOßQ]ÉŠ}/žeºØÑó^–òI–X€óÓÐh[ û_6¶tr™*ðÝ¥Ó–P" ’+G$‰¬*x¢kc“ ¶*S!|É#0FôW{€ýC sŽóN¨f_Ú´cÙãpå•ë´Îàœ5ÄÕ²ËôFd¨[œ,Ÿâ‡/®ì¥ jÏÙÆ'L¯Þ§iäb¡Óî°/É^; Û–@áD*·¢ÎÌ%dAUñPÌ´z-5¸ªÐ$øjÙri+csr,U%ˆÌ\e½©áŸëH4y(”uŸM¸­¦'N8€èvŸFì÷ ”(Uý¹QqƒaDœƒ‰ËâOéäÂc¾¨~ÎÎï¿ò.½6weÕÄÑjµf5Ÿ¶c¤¯E,BSÅqG6À\L’„é à“ÜPÏýô|¹V}Áßm&G¶ ºþxÛU´«¼Ž,¢^}îNéPŠ].l½ueÏ™h+ìm¡2ô—Aqpº™¿^÷%1Ì.@´¸\Ù½´@­12ÌÞ3L _Hh9ž"KïÞâ@[Úÿ‘Ý-xŽ_Р̢œóod•”êÀ]a¨+ê cÞtmË­áíFT–·}=_c­WÔÌp,ØÊº}ciaâíŒaþèú ÷-wÛrCÍ„þØÒ mû•¶ÁEµUèûcƒlj·q{¤Þ=s< “¢q}‰aËÆöF×õA%¸Ò7¸öЬøÖþ¿Í©ü KÓyè3ßZ¼kLGGËxŽÊùtRMÐsÜ[èŽ6àýúDй±bFj8õF¶-E¶Hã+t@}A•ä{šÇ‚ö¤Ë‚Ÿ´þ(&qß,‘ü¸)‚»¶„P\˜M¸¯c8d^±.?Z5ö^ߌvð¤#Õg]g)É—ºýÛÝùßÔŽÏ„/bú…IÀ#…¥xwlÈÌöt«ÆöLùbp#UÔ‰qY¶‡ªé‹ÿaæÒÝSÜÆ÷¾m"ô ý60аQmN ÎD‘Ÿc» †ºŠpb ñ;?uvt[q*Ýf:ko?1”4ÈÑ1­îd´ÝmÙBæ±38Æï*¡M¦“G»™iaw™x‰àî©MÉÓ5¥GäÇ3U<¶Ëhö…"•h☣ÁãŠöúÙCÁà©ËÇ·©sá"‰{Ó<.ò†Hìàû‹a¨Á>^&2ûz•IñùX¡¼#vòoΫûɹ|LLi± eß)o;÷“Ÿ‹ ¡ªÐ=!Z<~[–h C–¼Y–†ºÂdìüàfzK™&¦[\‘1úcŠèþ¾8§w¬÷5–¾|Qæ~2 ±jk ø]¼M1weòB–‘ÁûI¼+`þsäjyw~îº1¡¹øÆÖ&>/XObject<<>>>>/Annots 2438 0 R>>endobj 5399 0 obj<>stream x¥XMoÛF½ëWÌQFlZõa·è¡qê Ú¦êVÔJbLrY.iE(úßûfv)Rå¤hØ"gçëÍ›ÙQþŒi„¿c çü/J£`„7‡ņ(¼™sºàÇ(¸¡BÓšOR¸3y5žÕïoÇøÔ'hŽ 9ñÀ~ÂÆÅYSÓÅ<˜ö:i©tŒs/ïg3ØãÔºyô…¾<‘ŽkT)ŸG¤¥Ò1vν¼ŸŽÎäÑ#húò˜:®]P=¦|=’–JÇØ9÷ò~Ró [A£Ð—‡ÄÔqí‚ê1åóè‘´T:ÆÎ¹—÷ãQ0éåU QèËCbê¸vAõ˜òyôHZ*cçÜóûÉí,À¨8í>A£Ð—‡ÄÔq-Aõ™ryôIZ*cpï'ؘ?ýþv0ž·4¾¹A )…L,÷ÐÇAë1¥›9Ž4²ÖcJãQ aûR”çHÚz†t>F[6ºSÒ8\ D4ÝrHòÄ!1~le“c.,zý0¸¾‡¥=¬1·ç·ø°B]FHô!þ˜$Tn5¥ºÜš•¥8“Ç8+u‘êU¬Š=½ÿåE‰²–v±;žQfJZjŠT’¨e¢ÉT¥Wø½ý\EOj£IÙ–uJÍ*^Ǻ°´UÏú:»xø<ÑÕx‚¨†ÑVe½¢uaRÊ«eG¤¢HÃsih¥×ªJJÿ& ‡mŒx-UV¯«„â5íME;••|:/ô³ÆGHá㌳ c5%fG Ä ­«,*c“Ù€¹¾GÑ u5™sHÀqŠ~|DïÕ³â*¤+p8•Û«É5ƒƒºIÌRµÊVô¬ŠXàÚèÛkë~“Ês­Šý¶“€îMx Ò_Tš'ú’“ÀuŠÌ?W¶$“ájõi|çBÑ È‚4&œˆâi5ôˆºRzkôw]æÅjØm©J ÿlâéÍæqxo EÛ8·':TǦõé9Þ}(‹G”UÔ.kýï;.ÿ9z–§†²W’CÌç  ц‡aÈ4S„™êèæÀÉ Ù*Ú-.<$ª® 8.µ´†@ !è—á´óªD)@"è‚;L}¦›†ƒB×Á c7:Ó…*ÁY8ð˜ÕÅ€-”NR.šÅQÙŸåЖ{ÐÓÓ²Î*S)j뺰cPXür‰}U]2½yÌãðñâñB@Ö¼ˆS±ÐÊšŒÖ Ú´žŸ[K¸·¾68#àŒ™¿)w¥Ï¬ÜçÇxF[=Áp@ïF_¡aM–{bè¯ï1êÀÕ51%Ý›º‡81Ò9*œ¥‚º«‚vÕê’]ÒŽ{‹É’í»z‰ÉNÿ§?_è#JõÞf>IîÜ×2jÜ|ÂÔ;¡0Õ&Uö8߃òI3ùtJ'¦`·…©6ÜCš)OwoñòÀQækª2ôA=íÏd !zõ“F²q'ª@™¹ÐNhnEx]¹Ú©½ô"E†ÙTbšÇh¯µI0Õ­ïÜÓ8˜…7€j&¿1>> oS|7á¡òFÛ¨ˆs¾Ž‘ºò§®°SŽr!¸á³+»V^3S]pï0fíIÅÇÏÚ5œv×c×ò\¾±€ãqI§þ7ofu½LÄž¨‘Écàþ¬‹%®ð­ôÍ ¡ÕMQ ñÃ…Cúàå•­08ör®„ã-™2'ì%削ÊRS}*/qוsø.°Otê%”\ÃR‘¯ýISEVçª9~8éJ©í ð†I8 kzqC9†B@é®õÃpln‹6Ž ðg×ì=s}ÿééä¡­}b¶ ¥™ñ«a}¨!‹ç“×–ûE)u†m¯>Ítî·Gßôç0Ø“íÁpgo¨ Ru”GÉA@ÿx÷–àv|ó`ÔÔÛ)½¼?|Ôî>è¬üøO Y-$êÓ½×E'Üiå+‚=²D SÖU^,@Lž¢ôöw¼·Ñ òžE3t‹I^˜/ûšœ\soËìö[æÉanÝ*BZaͰeQEeU`u¬2Ì8‚àîÕ+?«Ê­Â¶ƒÝ^]ô¡íÝmê*ÁÃ뺬 hGAüø[#‘k]ÔÅýH¦”kºàÜ ¯÷úVÖ‚$ï¼¼ÅǦ²õ‚‰ÕÝ<Ùo혣…—Ø“e·ˆŸÑõ°ŠÑîâ /¬Ýõq•(0!c CNþ¬Ó_wY}[*ºëóá°l^b8‚Ñ˃rESì¡Û»I·lÓÔ®¹6箬ãåc=aû>ÀwA„¶ÆWÉ)¦ÔŒæ \†·Rn­+þŠúÆD¯e˜õîÄÒíN_-œ¿¯} šæAˆÿ¶`Âùœ9ðÓÃà·Á¿è2¥Nendstream endobj 5400 0 obj<>/XObject<<>>>>>>endobj 5401 0 obj<>stream xV]oÛF|÷¯Ø¾¤r#Óú°•Â(Ð4 M‹ H'ri2&ïØãQŒZä¿wöN”DZI†IÞíÎÎîÌÝßgSšàgJó…üÆåÙÏ˳I4ÁËý{O—·zÍi™ÒlB‹Óh±xFËįšÐ2UÖ8Ž'T;åò˜ £ïéžÝ«ß]n!³þ¸:§Ï—Ï&t1ÅÆ‰,»ÆjZ°€nnH7E…?ÙKÙÕm~/a~lý¼{(ê€acò„Ò\«"ÿ‡W£“i.Øùÿ·Y¨¨Þê8³F#dB>Ã!ĉ²òt5êÓw7¨æÉò/~åò]«O‚¢ãtC©*jâÒø“*«‚ßþv@ñ!áêüñ¦Ž®ó{x@7\ß­Þ“Hðu×ìþZríh£Š†OVrÈ>|ú€M|crY^»ýߘ\2b¤ûdÊÝ =ÊŒ-ÃÌùùB½’²®TÊÕM9&™åde–B€Ží®ö.X´W‰:Á¿‘€ùBðjt„Ds†duVúöõ$ž’ËÛ+’‰Ié£p1›ïÄ?Z">Å…ªk*Ùr±¥ÌIMŠ*ÖØ’3è2S£¶Å6‡¼zúT £€ÜE½b-!ú^+áu—ŽèÎt`(6Ú©\#GQøÐ%»Ì g®ý£„ˆrGyÝÙÅLìæðÉc¨Š¦–)BÒ0¬Ýÿ©±T…)/¹\£€²¹Z\G´Ì¸fJ»ÜAÜAÐp» ƒ‚O@ÉI®ì– Òч$•ljºg2)ej#$Iã ogj xݶbªUÊn‹gåüK_Ö®è:“¦lo èÙY²g? MQ›åqF+,F×Rn‘¶nleóšÁ’#Ûh——aúmg>cÚšLhPx)Oý;vË  5 MЇ¶ºí5µ:¯÷ÝÞ3Lè`›£ÍFÛÖØ”U^0µ‡®WÊ*Ð/í¬00ge¦DO†Ù¤ýj¸’¬CÕÖ”X‰bì÷H#.ÛäÜŽj©À“Ôæ¯5ö3õ…@¤zU¼UÖ¾ ÉŽØ‹Ù,šÏqà&þàLq@¼b<¢õ¾hÓ(¸ñ|øA n剂ý\ƒìV_Þ¾8­îÙutÍ£)á°2˜áRiLiÉCÅ®èk… :žÆ å£ ¦ÕèL–W”ê~ÈõÑyøˆsH.œ´…H«Ë\ƒï63"ËuMæP*¼Ó’?ƒ’¸GúI'‚LRñÖ®;K“Àóæã:1ÝEƉM¸vÖˆFùØðó*NÔù¬HÙ5¨íMQøÛÔ18ðùÃÜû<÷£ÀPܤ&mˆa°[spÈ`ÀÑ.aèÞ{“t+˜³8»e%×¹õsãEMÈvñÚðÑ߯äçY5Δrûƒ9¢~¯‰Cÿ}YºÕ.¢w‘M¶W|UŽƒ¼w'I’ÂÓXÇâGÓÚ&É=1xè&u¨µ· ( =hÓJ<|E2P» Šöl3Ã~{Æ8BîæÃ· ç_Wo0èvp? ÇŒßÛ» ŸT¸\÷$ÄZÙécýw_ŸàóìËŸ8ýù³7“ËÛç;˜>¿Š®ç×´X,:úóýÝ›‹y4¡_L܈ ÁF U¸„ÕÏÂ2˜F˜…#+`_Or†k0Ìb¾x&^/Ïþ8ûdðÊ8endstream endobj 5402 0 obj<>/XObject<<>>>>/Annots 2440 0 R>>endobj 5403 0 obj<>stream x­WßoÛ6~÷_q{ꮉb[‰ã¶ØÃ–-]´Å{ 0Ðe³‘H¤¬zEÿ÷}Gʶäüè,‰Iäï¾»ûîô×`L#üŽ)ò_V FÉOøkÌ_¿¿¤“Q2£Éì2QEi:K¦í]I7ƒî=V/_&çÕç…A«]ÒÙõ9G4/pòô%.òp .²á[M¿Šxõ|þqpv=¢Y’òÆÉˆN'“$Mq—¯¡‚¾'-Âõíðöùk":;#*רåÕ;Y}h4¶x[KÖy>²•c¥HÂŽ;²Åø_ÉNv²“®ìäH¶¥{ààt'œv…ÓÇ„HÒd:½d/æ+åh!Wb£Œ¥ŸµQÚKëH蜬,¤•:“ްOºµÌ”(Ë-©jm¬Ú™¬Îa_ O"ÃÇQf´JCSl-ÉO¢Z—ò„TA‚*éW&ß:aS¬ôµÕ8wgy#È,>J¨ ºaÄNoNJ;•Kl1~%m»ï„¶¦¦\J+/ainô3O ›Ê ”:WW’LÃÖ­Ôš]í™’Kç­—þ›öùä<ÆÜÂI•qžÖÂú8R»¥Jh±”•Ä) Ú…•ܧ•Ês©úÅ4r#í Ë[S¾^øÜ„‡ly¥–+Oˆ‡dK¡¶f¼{Öe+¡—X†! PÝa<PÄ#eq¼JuÇÂÊ=]!¦ôañ‘>y½;?d~\yϺ>÷P:¼ÿ»(kÙ—Y׋ReáÄ}aûƨœœô‘Ûa¿}NŸ)^4YV[+ó„æ«},™„R_[óiK1]WeÉ’ú®å)Åe{<_±5¡Ü×ö¥K£QœÈA{åW—9Ø––Â.@xP–à6É\PÙ*ÀΨ³%\)Á›«/@ià¤:ó Ò†]¥7æÂÌÔG–ß‹O^Í‚‡H"JyÚrþ¿ˆVBo fØg௲Îî¶‘oƒv£A·Kä§@I/™ »õ<)D]ú¤}IuŽ{J45áàÆ¼;D¦(Å’³÷ÈÉ{©¤¥Ì‘¹Ìœˆ÷“oßMé? ÉÓIƒpÒ}Ȫ ×:8~öܫĢD`‹{꥚ NpI 5¡›9§X¬QèyÈ gÐ|²ÚyS©¿D­F¸OX¶*Ta˜ÈV íɳ¥ÚÅ"óÛ5ZÌ^ön»Ø :Ãù´®¹P¡ r‰>]Bw _-g"½C^¢5þ‚úþ4‡ák»i4Âõ÷ì´a?Ò7pÜ« l$¨¨u< ¤NIµm¦qòài€ƒç&8W6È1p…É`lÞöü„ŽébºIÀ0º>F@§bðµ RÎdÉa‹=¬Çɤsܾ™sÇÎÐw1i0¹ÈnÙ⎒Ö7Uô¢Å ÂTU€ã Ï‹šý›0ÿÄ…ßæÊr„62¡«¶½?ÝÔ:ý>/XObject<<>>>>/Annots 2444 0 R>>endobj 5405 0 obj<>stream xµVßoÛF ~÷_Á½Ê+¶å_I k;)°e[ ìÅ@q–Ïε’ν“ìxEÿ÷}<ÉòÉv:ìaMc„&ùñHÞ—V—:øéR4äÿqÚê„|Ã]þøó}«Û„ a‡Rꎡ¬¤„[¾œR/ŠÂ¡§õehû£päk=ÚѸyÖ“SŠ:ͳ¾ mw܈ʗ¡z \_†v…=/*_†v4hž½„ÝÊ:¥~ïºæ†ÙðehÇQmë´žœÒE®ã±0ËÑAÀ=1%áÖ:OLéºÃáÔ:ODåzƒpì)}Úa?ì{Ú7Sï*¸û`Vt5éÐAO—ÔëÐðº‡#š.Ü…éÐ4ÿl.rÓÃüý)r‰?gÁ삾’‘ya2Êä–õüå-}»˜~ju¨Ý…‡Eðí–Å«IŸX^RHí®•C ~¦X$ åšJ3ÜSg,d"sÉ›çR–2M‰ÎVÒ9–Ö ³#a)’´f.V’b$2ε¡­@*>K§ûú5-¤ÍMá”}.cQXy‚ݪÕÛ_eú°ÍNcào8É'™é-Á£ ÷IXm÷zaãEÀ jüÞÑD0ø.lÐy ®¯®Ø"ôaÍž‹5©aX!½Àê£N%¥22ÏÀG*³ÌÙBZFÒ—Bå ĨøóŽÙ_ªgÙÖ;ÒY²£¹˨»óD’Xæ »°*[Ñœ Ç?å*•!=d’l?•þñÙàfmd*pKNJ£tFz TN¥¢’-NéƒØ‘‘¶Hrð Ë…uZ®b¬Ÿ¢æ§·ŒòÝpëFòY¤ë‰Çzƒ,ò­.õ±Ì„QÚ^ºÊ»®pnT¢?ÿˆBN¾ ×ÒZX+Ì_<);iv=v÷½¸dšºïàlŸ¤»tõ+;ù7r)ÌpïUž#© áJ•ÜŸ _M®«ÆâîëómÄøè‡<*ï³'iŽ%‡whÕÚÔÕbmôóŽâ„“¶US)cÀg®N(~*³!M «¸¿¤•ÚH”DÍZÍù9n¸7Ð4C(YS¹EÏxXœ?ø®T½)eÆyÝXFÀô• ëæZóDÅîpýÑF™¼ -4Ô¸…Z»i×8YÎ:¦Í¾¡Šn¨tLÿä¡fGã•»Ãã£s%3i0ÃÑêܲ‰Â\š¥1ä]…‚YŒa¾Ïd•׋„ܪ 0Ë¡á†Ûï¹iŽ46Ò9‘͵N$æ‚7÷Æ%³¾1Ó9 xP ¯—õé¸ì^Lo^UB¹µv˜î˜±ã=R¹¾jK¸f³3qï÷ÝihÕæt±­dþ‡g+?FÈÙ ª}: `@ww”Ißð¨»9l†ÿÄF+ŒT•‰Dýíöé.Ëö8û“ä\sÝeñ“Ñ\.È!\œñ¯–³`_vúáÙ¼zåW÷,xy4J´‰=Úƒ\ÚϘ¿Ý‡eË;±GÄ£ä¤úû¼ÎV¹sl¿·®K\²Ðœgò®ÊY A#ûè†Ç>ºK EeOc|³Lí,aÎOàáYVQ1» žÿã@¯&ãjYtÇýp h8®1Ý¿oó«öŽ ~Uàq¨ÝªÂè)­Û£’Õ—6Ì 3 £.¶P4¼æÚü2mýÑú»ûˆJendstream endobj 5406 0 obj<>/XObject<<>>>>/Annots 2448 0 R>>endobj 5407 0 obj<>stream xXïsÛÆý®¿bû%¦¦Hýr;žNíĉ2×­•ñÎdŽÀ‘8 ¸CRl'ÿ{ßî RuZ[# ¼»Ýwûvß.ôϳKšâÿ%Íoø+-ϦÉŸð·KþöÎno’×4›½N¦TÒååeÿTЧ³ËÛëdN—óy\}}ܵO²zð\Òl>ÃÙ¸—WŸ±zw«Ï%ÍgwÉÕÁêá3V¯®‡«Ï%]]Ϋon)Wõkzõæ§ô°B8n^ã—L¢€_ÒÉC®éüáËÙ«÷({&ßio6:‹Ÿv''”ª®I?m³z|æ­ªõø@i¼wÞØ58y÷í·­ csxʦšr£½òi¾K:wˆ9Φôr6KæsÿçvŒ·›\Ðiе6ÙŸbï-+´²”þ¬KçwÛÚÅù‘¢º©´_Lô“*«Bÿôá>ùôùþ‡Öà/Uªê°˜°ÅÅùÅÀV‡¦ƒ S-NzC|`¼á·gá×AÄGÀ¯uà».:É-¿œîuh¼¥ÅèͲMQ`ã_%âCIç÷ãØ8“ÑÊXU˜éÅä¤ÛL:ÈâWíFÖëMsï,Lf$ö&NðaV‹I‡œþð·ùæ›Yðø‰mìã„¥ŠZñþÐQüÚ§Nçtq~|°£î$×Óãý’TÉþžã½>“c¨2‡ŸšVÎ=ü–óƒ[´ð•3Ý.P²¦>¾È3nûœ$\LÖ‡ÕÛ}Ô¸*‚oôל‰ë½’½˜'77·\ËPÈ"3¥Ô*¹­Õ¾ÎME¦¦ÔÙà]Q }–;ÙµdÉAKèG·ÕíI«4ïJv*ÊUM&Ôì‚*glоӞCÙ¨¢Ñ´Í ÌÁ¹[e,\gh!ÀÔ¸oŒ³ ßê±8gûËCŒUQð½PX_[(´ò®$5Öç–!úãØPp¤âgþ³ˆÊEDWÇ2n…/EV§º®MØB"úîÊÊ<),ôœ82¬‹¥¶¡Ãˆãö¿xkBN™Y­´çCÏZú÷„+Žñ}Ю‚ƃÊÊg>ÜÅ5À©ÕÔÜœv0!dþ¤6*&€®º_M´1G¡¨¼Û˜lŸ^1™¾`㌱€*ºaš´%H*Ë8Šª1Ûc{ÿ^ïq[Îb·Ž¼™œœ¸´¤ ©ÚhHÙ tàþÐîZ*3$±A–YèѺ-©¥k{è3DB÷â®|ÂaØUšÜŠäèbÎ2 ¯Q$†[s_ Q&(õàš e×Z3óÅݹ‚©Uai)sHEmPÞE²¹Rä ÃQCÒ$3³€óõp½¢&´B¬ÀQ;©`Ú“q©ÏÉæ´dŽéå£wO».‘$¸kå— 6e’ÊDuÃUoãíqX©¦QŽX)Ñ£ºÞwˆ¡Å‰ø=Ú~ØšÇJr‡pŸ¤¯A:š ŸG'ò(îÔ†Õ"¦_ ms鋌Z-GåÐÖ«ª‹ï(Š'tÕ·>™Òýp™qâ@]Ác¼ êRqF±•xåNè&ÏÃŒ,A€Àç6×v•‹:Géð¤cꜷ°d W Ãh††ÀwQìD¬Æ>®%‘îß‹ShÈ+Øö„iNM`•cg£´Â±Àæh±_zŸèˆô }Æ­Xu¼[{UB5ÑÓ¸íŸ2›9PÃØQs^¡ã‰ÐÊEàmo!ÿ+Ê×ÖfCMlÄ9@㵪1ÊAw—:7"< 'î¾W `9w\§?*[Ó[§óòE¹½§û‚Þ·ƒ§ÇEXÓ>õƒ£èÊÐÞ¾®+…>© o6Œ ´…p¢WS†¶ ±Ë;œ‡~ÑØÕA—ÂwSCþEáJµãlåC$–„íªuµ•ÄŸý¼Ž=Ÿ¥B€Do(6bù¥©Á8;Œ£P À ¹QùFAò›|cùÞ¥Ãáñ}Îçº×gPè¶\·ýbÍSBŸpMé =¦œ$P7šÅÞŸkUµñ“í}jÖTçÒ1Syûjª˜•ûõ/ÇÁ娠Ԗ˜ãL8ÈqT¥¥1lâ4nñI'”èðtƒ¾èÒ‘øm †Ûâ‹T° ~\FÔõ6SÛ‘ÞÏNLg^Á™ÅMp”FèræQÓæé³óq"Éã¬*s…ß×=OUÁ õ»qœ ì”j/“-<‘ñÛ ÇÛ@Qzx÷ñÕýG`KųvfdÒ¡&È âØ0êí]ô—qTǸ!ª)ï¬È>Ñ„–©8ÑË›Ì#èæ64 lÇIÛbÁ\ϼóy‚i¬×2>¦ ,ªñ‹Ø×ûvÓkEÛÏñ·éç³éUr=¿¦›;™4yÉúÎ¥ ±½”à $î|yßêþçàzz“ÌgxAÅD;¿2uß?œýýì?ÕçµÐendstream endobj 5408 0 obj<>/XObject<<>>>>/Annots 2455 0 R>>endobj 5409 0 obj<>stream xµXßoã¸~Ï_1O=/.–-ÿLZÜCšžo³ÀµèÆè¢@^h‰¶µ‘D—”¢õ÷¿÷›!eKN6À=1Q$‡óãûf†ùÏULcüÅ4]ð/)®ÆÑ_øóãó/W³é,ÓüvŠgA³yÝ„QNWÝ1f—ãè¶;ÛcöfM{³,y2[zÉ·,ÙXòtÁ“Ó¹L.gØé2GKšÄP*A£8 x®3,hG³Î\gXÐí„Ï!¼¯3,(ŽÙÜódwŒÙÅm¶3.`ÂM4éìíŽ1»œ÷Ôýëºãsq¼ÝÑh5£xLë-‚³¸ÅK*1ÁK2x4…¦ÒTä e©V9^òºÊLéHYýçë¯ð '3lÜ«<§j¯‰?V«ˆ<]¥‹ÈÖå*+Užý¦­ûGùó·¬zT¶ÖOü†VÛ1¦a<á#>×e•:Úé*¼> ž>üÑ•!]ºÚjÑt{Rˆí¡è”6zküVãtøÁšUihî"ZÃÒDUÉž2aªÂoø)JõÁjLBض.ö˜'ÅK5¥&© ]VJfœ::ñåhµN›àTïÕ5 -tµ7)ËÎʽ¶Ø™©.Úêˆ**Ô‘¬vu^au¬Úè¬ÜµvA‰<{Ñd6_uR9jöY޲ÐÊj•JX{F'¦LjN,T™êZC(4r'Y×áxž€ÚZ,JàɽzÉŒEDá•æ&yŽúѲ©>º% )P×iGGSS“RMy<I•pg†‡x;«¨1öÙ]Ó¦†Ùø9Á*"Œ*}1€ˆ>*ج(7æ™%1¯Ÿz@ƒÁ'õ¢¨ÑrY¥ûkZª XžžTvZY x¹Dýpï>G A’¡O‰Œ‡· ûÊš‚¾¦Ï1ò‘)e9îë*5Mùæ29.½¦ÌÊÊš´N€O€ÀCxW+«ÊJã›wa`C³×¥ø£ cé‚ ÿF°…À— fÕÎÓk§ì†ß^%œÉ,VHp†éµ8PSÅ!×׈‡átL ˆaƒ­=-˜FI®\àÞ>0Ë›{Ê=…ÊÊ7¼pò` b'# ï&ÑtŠQ: Vƒÿ¶Gs~Äg¢ïd¢WðpƒëN;IB¸¾±jôZ8p¨79l1YJÀ’_I!—îÿ¥ž±& ÅÏýþJg¢×ß åb¬9Wáçd-K¶ý.ïëÝÞ¨v5¢yl‰ø:µ¥F»ò‡ŠNàòܽˆÒúûç’ ™@%•?¯ÅP«º‡3ž"ºóyÖ2ОÉDôH%¿¬yJ*G}+Ô3g‰ORs H×Ð^Ò+ 1Iöár!ɵ§BeUòÌäˆUšîG÷?þô§úÄõx.dŸœÉ/„í÷--.|“ê\WšCzé’SeAÒ a.‹«²¢Ði† „èdå‹q¢ôIµCÙe:ŠŸ¹z·Ã7.RH£\K8ö Û.?HáÌ`§¹Öµ¹Ÿ¿”58 'Šk¯vV@ mú¢mJ—ƒ“Ôäd—sæ ƒÄ„b¤¿%úàõq=5P¥Ú®E¶Ê±´à‘Ý91±Ê105}úׯƒÚq= Âï)ˆh…L² í°Ÿµxüòð ít©Q¹ œO-wïç‡;*Žwô“úNX×j+l –5Q$àº!SØ#Û§ ¶1àx«ÙÊn.ùoÚØ;2b7þiŠOy?¾xÏóyßM k8þÒ‹€~è·o8:….Œ,}½ön^š,Aò$xFT<ÊδFx*!'âÃÈIÓŒAÂJ+2Ô•3„—õñìò¾%{&éTÊ´CÒ™Ðö‹EsÀ™MS†FŠ›T9Ë:1–#’j(Lµe|2·Å5+ä-×v0øD ¶AÃç˱ÏK’MÚ‹F~¶íßÐ[iÚ+¡Zf»mª$tì´‡ã ïÚ‰S‰ “é{Z‡JÍ©?9ûíV©§Vu<èBÙúJæëÆÈ k“µôi¸/ 'iÝÑ•…ì’NÅhÞ¹ŸDÆÔ)ïpt@ '{=q{N Ù=Ü~°¶ûFW¾ê²K$–Ë1È݈5zAñrËŽ´å½WÈýÁ3…ÊÕNŠÏ¿h9ß @D÷¸ã¾J1VòÜ4ï¶x¿’x—~É6|l¿!ü½ŸÏ¥!l /|„ jBwŽèEÛÆø)ÐñCº? ÷:p÷xÖVHÒXø+€†?îr³ÁßåÔPû“ûè„ûéû&††ÖßVß¾©D¡NŽV7 ñÍ,šOç´¸·]9'Ò!ÿÏäoÝ[4«£ýêáÒ—Ùÿ/æãE„J!}ºŒYƒŸ×Wÿ¼ú¬UÄùendstream endobj 5410 0 obj<>/XObject<<>>>>/Annots 2457 0 R>>endobj 5411 0 obj<>stream xÍXÛnÛF}×W ú±h]l%iч&M‚HÑÖBób X‘Krr—Y.ŨEÿ½g–‰ŒìÄ)  d“šÝ9sæÌ¬?N4Ç¿­Öü?Ì'ó`Ž7ü±àß_M.ž^OiyÌ)§ËÅ*X7]MžmŽøU6¡ó—sz¬hÓrNë§‹`½~L›Èo;§M8%*ªm¦B*pø±3*¢Úl·™¼ž¾Sü“êë‡ô×ÃÍÍdN³VEXE$?‰¼Èä›_^Cû ‘îù¯Î^O±ðŒWÿ0Zü÷àÙ?¿¼ Þ;¦<-›÷tZ§ÒJâLc2mÏnÞv §¤Jr©$-rI&ö¿ç&ª2ÐOY†÷Ní$åÒ¥&*)1°°¦JRo©´“6—‘vOa&Ê’êT…)¥¢ÛöhyÁ’áˆ$ì­Œ–e¦ßwî°Ÿ-—Áj…LDÓðæˆŠŸAAwJ z»2VZd]ÂÚ yËŒNèFØdqFmýÓûq*î†~,KQ!,@@gãT42qÖ¥¢°2®Ba·"‘š,“¡SF¾ÜIÝüÚíO§!"Š€§ãqBoC¾÷‹2U:$LjìiIÐóóç$[…ŽŒm3ŠsaËTÀ Ÿ.AoÄN#Ðk ËËqn¥ñ ŠîÔéþ ~ëRùïàÈEãU—"O„†¬ìò 65¼ãàz¾Ô T¬œ+Æ©í£úÿé~ÌaÔ…É6µKÅbA!€gt»i빉î~,HVѤeÝÒþz:ö»×­^´>Ó§/Ej\YNä…ÊÀÇÌéÌö¨ 0œmgŒæ—¡%ºñr”h2ÛÀw‹k$b›§SaPVT¦¦Ö,µJã-âÙ*TxŒlDòÌÛÝûP$bô²*$Bé_Ö8Ë»ІÏÍ¥ÐÜ\÷Þ ð[G*Ž©oOh^@W(ø,úª -”ƧŠl¥5³©ÑÈ«?ïc¥\Ÿ:ï)³ ô>ùäV¡þ~ì¿ù*l”få ÑúênpÝʨ›q¯¬n¾ô­\Ùf¶g/Yy#Ùh/ŽmÚ¨*˜šíN™ª„³‘*lñÀ– v³Ë‘·'u‚yÓáS•|¾gECª€^ ÇŠÇߺ•Faß…ú ŠÂ”¥âéÛà…\ßÏ‘$àûlñÇ–>ˆû& Åq¢_z²ø>/XObject<<>>>>/Annots 2459 0 R>>endobj 5413 0 obj<>stream x¥WmoÛ6þž_q˰BAmù-qÓÁ°¥M‘íºÕX¾h‰¶™Ð¤*RvÜ¢ÿ}ÏQRl)N¾, l½Ï=÷ðîòõh@}üh4æ¿duÔûxÂþøû=?¡ñùk|®htŸV7š¾ý1iÛç ê]Ò O“9_ã" þp‘D~›É•ÈN&·{ ÃnXÅ4YJÞçjVxIÊ‘ ¹ &%gÉ-m¡SšIrÒ“·t<8æ/iÄLKòXíŠ,Ë¥sÊšÙœ”§D^bWÊ{™òÃzu?¬N•ãåq@EÝÁ£+˜É{±Ê´|Ã/zW}:GÖ°OÝá0p—F¿T1M£[¾ê±Ù"ɲ `›žÐš1´t¬­Y—®Î*‚ºÁÕ(_±«K»Ê„W3¥•߯·® A id;kÈÎ4Ó”¦ŠM™ÈÅJz™SªRvB6I ah-sæÅQ–+„â¾Ü\¿ïâQ<ê‡ð{W¯rמ2¨áY| ƒ3ú¢Ì"œK‘‚G‘eZ% A~Éoȉ¹ôÛ2Ð83¼µ|kÑôT8ìC>]“‘Ø @V)jlPŠÅ!Ör½t4ç  ËŸieÓ`7K™—ºˆ?½›4¼É¡ÂIú|mÖöNÆt¹Û ~^¾¤D çžW@0¡‰tž¾×[°ì#")#|ýÚx“3pÜ‚>-lÍ.¦Dó†WL£ceU¡YGß4üþvG­¥¤2’½Ynï·e TiÄζ!ûχVâ¬ÖŒRZ œUV7¹Z\~nKдœðá›Y«%Îc°ü(WnLÍ ÎB`ag\ò<'ðÚyX`¥Í·XÌÌ4ˆ!üì9§ Ú×;Õ|W–pÍfpל?†æ<„Ÿ”Q/¤ç §Q ÈÎn‚Ê¥/rCÓtqA¦Ð†¿¡J¾!<‹Ÿ"ïik‹>W8õê› ÂyÌE*5Š¿lGßöÛëÑ¥Ð:¨>…ó"ñ6o‘[ ÂmM²Ì­Á¾)»}$DͧQýt_¼ØÏÒAÂÚyœ íd;NwU¦Q2âÅ¿¥pê‡NTP ýö.µu­ƒ}ª¸:=ËU æ`ˆ\»§Ñ~#7øéI‡àV>ßמ–‘ßXBOXÚ×KÁ-‰æ[=E×B!ÕÛq¾¹×•ü)l¥U]Ý£]å効#„ÛBÓ!W»Ð_÷‚n$mzòœï.cºæÞ'i!ò™XHl«5j Z@uÅM ]'Õ$èþU§ źCJ>k§ã6´Yî¦òžÛžò%,ÊyZJS6„¿ƒH–1yäÁ,“ªù É`v){%ºǰx]>ⶆð7“‰@ob¬¡ŸÁúþì±²ÕJäw8ƒÜúZL„ H˜meìÇ/ÊŸ@kÄà€Õ€A«,$å`ñµÞ†®òÂv@Âl :°j)֡窼­¦ýZÕ¦·ÖçYNò(ƒÖÒØbLjDÔ¸T)„Kˆ™»!+s Q®•Ó·7Cì%n)EV¦ ÅÊó"ãvå¬Å¬Å#£t 2¬qÌT!“<$”¢ tábå½L0æÐiÈ“_M0˜Q!t÷É5² nyòÙŸ° a¥%­Ì‡é†V…öª[E¾¼Â¤Õ,¹’®ÄP¯NoxYïã[²Y˜Y,ÿ(WÝ ‡#ÁLy£Lj7.¦ß5B6ÐÃ:TzÇÜ’H€g8¼b^˜„½V•%$?ÐY¥¯z©ÜÝTsæyUa†ýÓøltFãq9ò@:ÂÿomR¬@P#ÃÄ„SZv_•Eû ¦gýq<¢ aཱûw“£¿ŽþÓÆûåendstream endobj 5414 0 obj<>/XObject<<>>>>/Annots 2461 0 R>>endobj 5415 0 obj<>stream xWÛnÛF}÷W ´Pb™ÑÅ–¤yhÓ8pPi¥¶( X‘Ki#’Ëì.-ËEÿ½gvIJ”•8q "w.gΜ}9ÒCOøœŸ ¢¾á!üñîd<šDC]žGÊi|>Ž®ê»Œ¦'û÷xzu]î=ýe¶gÐ[5Kz~}NÃÍRxž¼ÀEââ"î}ÐN’[ GVç’tŠIÓÙo¤ úKÙJdôæô”&¤,Ú᱑"!+RÙÇ™[éj¹¢X'’rµ\9ZHÊT±– 9ííåUæT}ÒT…S¹|:û|2 ³ááô2µ0Â(iûT‰LU³ ¹·JW¦¶jÊ2ÒqŒoœ «ŠeÆÑsD8ð^Ü *^‘G4U¹Ê„ɶufY" ÝJc•.,':­ šº*Qº œJZTKËN üYëEåe&sY8á`©A̺äåKë B¢8Ö’(€’¦ 1dÀâXrÁ‹íb«²ÔV&ý±,EYf*öبtÎPÎqª³Lo8U:®te8•K_ä™´Ž+* ’w‚3Bª 66®ª-}©T¼FHT €o,­Õ¨ŠˆW(©À™÷n:8Æ:/U†²xbÀWM ±ª€w†¶“½¡šxµæƒÏíùõ€®¢1xÊŒFÑxŒ»¤—"ŠyOHåõ੟†þ‡«ÓÓùSú·‰‡)ß#šn­“y¤+•(”ËŠyïÉ“&Tò ’š?}upjçdÍNÖp‚Ï£ˆ<®ŽÁ}M…Üøûyï¡ÑÿœÔ¡-ã‡/ûWŸ_¿ n•é3ÑdrÉYáê:ÓTHøº‚’NÆœK×Ú¼çÅ8Ò§…Öè‚ו«ŒüÓÊ# ¡ÖêÇçWœ=S¨©Û㮳>ø~Ó–¥&,¥cæ½nª¤Ÿz4ÙB¥Ÿ£Cøs ÷5Ýš‰è6nèÆê’K(~b)Ñ~ x½¬k*bÖ?[‚ ?)/5ÐMm­Z°Ôh>,Š-È‚ºn08BÔÐ 3S¨¦‡†J–¦‚JUÜæL®vr£!ªíVëv-ÃFâ¨qPCaq£Í®Ã#ºIi«+4-·„F’,áÞxˆ¯Ôà'¦‡ËË$'Þ‰…ÞBÔxrW墴dK«åÃSDt8×Ip` •8œsÈÂ?XBïìç=?ç>‚v‡hF~à;¡2K+½ñùèD¥[Ž òNX¥»“d·@áN6A#SidûŠúÑ{·­ çtZ!¸-@–#ZÃChÄBÆ‚½0Pèê»m'ØPИ›Xr0 Ïjý Ðô”Æ×©Zô~[Ø–r¹-xBù) K^»vÉ¡X‡7_ ǧ&|fýí&Æ‚Š( ‡ý5”¹£[,@¾chñRÁ[Xì Ë.[~ FÑ/SªÙTj›~ÔCI¬G±‰'¬b׈´^ Ðǘ>¬G-s¡xN×c"”jZˆû{_ÃÝê¡x¡Èµ,ðf±âÎPŠ}QcáŠåpþ ÇäR;‡|ënã$œÿ Š8«Ïô}lj2Ü[è6]`?ÄÚš…‘;4¢§Ãi‡øY´<ÿº,oÙ×çbx`vt8Üpýkõ Š#ŽÇòl¤¹×´bD?gØ4‘œÀ®™“Äâ«‚rºPA÷֎מ6¢iX¿/´ºÊj AÅoEV1Ã×mÃ{Âßj…Ý·9Æ”§=»ëS}ùã¶½¼¯£]‘ÆÍ~˜ØëjÖ6±X`•û>¤ê.= ÊÞ =NÕ¼Â&׈ ÷0>/XObject<<>>>>/Annots 2463 0 R>>endobj 5417 0 obj<>stream x¥VoâFýŸO1BºÈ)aƒù®W*%*‰REé5ÐVÍQ{½›zפºïÞ™]Û`ã&—;@°^fgç½™7»ÿÔ\háÛ…NŸ>ÞªÖb-œ¡/—¾î®jm·Ã:ÐëXVÐîØ } `\»˜ì-1ëâœ^vÁmÁd޾ûoqà—8ðœÛH ÐK®A?®…/æ xŒ31÷þ>ÌaüÇõðÐG+œ·Fò•© Qh¤#ð¢Pé8ñÐMjÛ˜¯×"/àJ™ .£Ä_­qr<ùTkAÓmc<­—>ZÓr+Û¥À8ÈèôÑ›ðqÈŸžíd†É¡8xÃÃò:êò¢íRzK ΄‚5•ø>Ûo€#_m °Ýf>ùN½äÙ"ÕÙDÒµæ«i(|÷p’ZÂÑc>|š›…»¼4ÍFÖ£ áqd6çÒ¤eÉ7fB„yrˆ«Ÿù†Ã< =-£"1ט©žÇ²Nfô@i®ñg?rL÷äÏ÷£ë„“gý à_`ŒÁgKÚ[ TΑ0"­—aÁQ—õ`&+[ BSAÖ]Ö%ܦÔ?¯­"Ø:¼aÀ&¦¿jª¡¹ y¶¹]̰ÛTu¹1ƒ!„b ÙÔÔ©ãd½ÌË ~ C‡žÌtý›è+ýžý™éׯ–¥çgúÇWø»? Ý#ÒÔç.ö$”B‰>jcj+¿ó S‡Z)k±ÐIîÌŠló#7ë˜z‚Žìàeç·x ~¡ïrõ„IDoê!U’s˜:9jøaM±@„ ½„££Ý$ü8Ä[ÃÑÑ1€¯ÜúÿB©§”Âp¸3™W¸(³»ï§Ì`‹1v‚(1ó­wøS>N7•»¡«òU±Öy8Œ¬hkÄ|bÁƒóx‡Q¨GžXÓ‰„â¾lë®C#×<³7¥Ôa+1 *K|hTGìã+OÓN%öSQÔ±ÜàA‘GŠ÷[ßäƒ*·R:z)•)²À„eÆU”¥–F‰™©xÐFÙØ\6öõöRhö¶²¶Bäß©‰º¨UÇ-‚Hñ«†[¶û @Ù!a5º¯ú³ N/éÚàõ¬Óƒþ`ÀÎì=—ÎÀf‡µà§È3•kîQT…Øæ¬uóÌÖÊÿÜîz­>ë´±q`ÓíœõhéhRûµöÂ]δendstream endobj 5418 0 obj<>/XObject<<>>>>>>endobj 5419 0 obj<>stream x•WmoÛ6þî_qÐ@mE¶'í–iæ)‚¬[´ hÝŒDÉ*dÒ%i;]Ñÿ¾;R¢-ÙI6çM¦wϽ>—¯Dø5€Ñ˜¾“yçm܉Âý/•Ãñuçáâ †Œ_Âñø âÔJE'àËÌ êu‘ÿÅÊ%‡  ç‰XÎ7‡?Å_:ôx)µ—HæŽ?oÞïÚÂ?ªËÁ^^¨bÅ m˜)xËW\±œúl [Õ~‡ËÛIn/ßMþèÁ}üÛŸq>ÜÜÞßÑ{|ø?Ú¦Zª a¬Î hô”xVVB-m™’sû¹ËüZª2†ÅEy7<¯rNEUµàÆÄ"Ä>Æ¿è3[,”Äb¤1ó ËUn5pj|^3:>p~¶ƒTE§6J-9gJÏ0JÔK…°ö%‚P˜ZÅSȪ7›¦#ÝyÚ‚ÄÁ¨Š4å´D½UñÚ.8vè¦GŒˆ|…NçëªliþœPËOÓð4Œ܄Æ6µ›ÉåïÅÒL–¥\“ü‘Íئ)ŸÛþÇ »œzu…€õþ¦vzCCýá0”ÒàU!’r™r8°Íˆ|“ÔNY²xõ}²Sc ¦GÍ9kãP³Gƒ..Ñ~Ƹ¨ø£bŽ«­!}ÿ÷Í;%ت9ÈNvvlÇÀ»ú¼ƒ‹åC‰×BÚp,͵ŽìœA—£é‘oèŠ=¶äkZÜ=þ8 ª7áóDìÐía¿i0=‚ï-mPOßÍ|ì0½3Ð"zK›nMƒéî5Zg¸½Ôç¡#¤œ› µ+*I&Œ&ÚøŠ ¦Ç?o­aÉEŽsx¸9„_.pÍ:<܉íM^þä?ov&¸p›”]'¦G{TTÕ_ÞÖ³ FÍ4¨½¶ÖÉax³d¯ï3‰ÿ|„Óå]Pf¦ä_à ÒDÎÊK•/çÈf“Ç„/höMƒƒ;G¶p]¿í¹¬AwOX(¶Ï¾Ü.àƒ”úî¦|§$«å³Žã•ÞÜiq½¯öÝPàÒÛí¶#ñ²™— }Ǧw«m špª•ÝÚ_¿7¨Ÿ|Mííýðš%õ2Φ’ ìñõyÅTƒsä§Ñ)ŒÏ=GÐ(îÂ~•‰­,\Z¥ ²Á™í¤ûgîÿ’ŠÞ7ä-n;Æáhˆ-ä3:“–IÜù½ó/ZŸ endstream endobj 5420 0 obj<>/XObject<<>>>>/Annots 2465 0 R>>endobj 5421 0 obj<>stream x•X]oÛÆ}÷¯ª 2­K²[ø!Mí Enšëö…_VäJZ‡ÜUwI+ºEÿ{ÏÌ’éÄ·(8^îîpæÌ™3Ãü~2¦þŒi:ç¿iq2JFxÂ?ÆüãÓÛ“Å<¹ Ùt‘Œ¨ ñè2׫œîNºkìN.“iw·³Æîlž\uw;kì.Æ}Ë5v¯®’E÷ng]Ðd:I.;»Ý5v‹dÖÙýqÙ‰RBõ:¿;¿\ÓdDó«q2Ÿ/h™ #Z¦¢?_.NFt†Ë ë7ªÔ´6VådlIao6¿ª¼Ò?϶-Ÿ¼¦Qcº9Üxײ:¿½@¦8öõl2­ƒ,·š´­ 2¥.©ÝN+ÿ}(zo>k*q¢<ìtPëúèN•¥öv([©³¡ôUZ:ë^7$Ħ¿Úõú÷ÊxQéh«l–ë&Ò CøæüÍ«WâP ½)·ÀДFåæÚ‡h’Ïsnb8!>j"УòF­rM&À€¸ùäVôÓ›ÆZíëdx…Ð=n+ÛX¤bªT ˜ 6HÇâ?PÀáGÝú(UÖº’Vš —™µAðkï ‰ÞE›ú—òa«òÜØ ®•{­-ý¬U `“˜Ž`õ|5ôŽ?2킈sFF} ¦èÒÝ€OÑàÅg-Ü-ŸŸž-t¹urô:Ïå-ýÔÃR}¢Á² ˆYÓ  åÈCÊ#QèïsäE¡3ûÀ½ÑH&Ê1#³—ê•fX÷ž©žQæt NÏV!iÊzžtهͻœè‹"äbpgŠ]ØÛ¸­ïpÙUeÎ};ì (è´4ÎR¦CêÍ þmÝ^J°P;¡s© ±ˆTº5®—[6y~{U×úWÕd–\$3Ö2Ô1UöXÊÂe⽦€Ú{\Ák—çnÏé/Š#„_…°Èq«k1|muµól2I¦S¼=¼06Í«LÓ)ç‚e%z“„ýæTA%‰æ½xá…C÷ƒñý˾ÆI"DØ^m4ýA¯ßß éýë·7Ÿ®Ç£!Ý-ùÏrHß½¿ûpóI~ùíº^ÑŸbêYA¼ûï»·(M¸¡PçC$·z€3熤f´WV#–â6UOBèM±f„þ™í‡ø%ݲY¼Ä G*›j¨ š¤mr/-}ߥFdŠ6G‡¢7Q3ÑBòrÂ]Cä^p[ŽÆ¥éÂJÔ~ÞµC¥W6ìpÈ–ùAzÀ›Zý|ÏueEw¢Št4DyÙè6¸¡¨p(à™¹ëö´…ö¢Ub*qèúÞë°s6ãT:EâÔè/&”Ð G;žvzÁen;µ±èºFàêù#x™`ÀñÁC‘Ð; k3T•+ ©WÇìà+̀Œ†÷ƒÕiÃÄÆNŠÝ#¦’Úû—2â °ŽL¶­^4¢nì&ž7ZïR—é„~5¾¬0ömÏpÞÊmÛŒ+ˆI¥©4ì dW£ÿ‰Ü0ò˜Ñ"à=d:ˆ‘ $} Í (†RY†´°qäÜÇEd™ªç<¯syKØš];yt¨.§#ëjH0Ó Œ–Ñ8iI=åÇeeõ¾Tˆœ´Õ*$ï²*ÅøÄP¬\Y‚û.¶ñHï–%uÌ2o>¸UsêhÑ–®çG/Æ8&#K]\ÂÙ%‚ÂÅàɃŸ‹…ÄM¯ÅÍØlx7æÿ<ñƒÐókn>I å›=_8¾¯¬ÄQ·Ú…-FöŸ+«›Î'¦€¯XÍCJË0˜yåLwØ÷kÅqRŽé¾ç „'×ÎkúPƒ!Aj”w=â0ÅeÚbté³ÅŒ²¬ Çzl0F-uö½$5uÅ ßIÂj·îyңذ¥GC›¨­ŒQ+]OÄ®¯y`‚S 44¾—›ÇYÛŸÞ¿äoX´ªnß^ÖÃèø#ètFóÅE2Ë0ÈÂt6Åÿ"üäÒª­0v©ñôÙ"Nƒõ;¡ÞíºCvC ¾5Í“é9CsŸ.üèfyòï“¿ ôKÆendstream endobj 5422 0 obj<>/XObject<<>>>>>>endobj 5423 0 obj<>stream xWÑnÛF|÷W, Q™–%[qœ§¦‰ hÓ"‚z9’Gñ’á‘’…¢ÿÞÙ=ždÊvj4 bY<ÝÎÎÎή¾ÑÏh6çÙêèÝíÑ$™àÍÝÍ’N¯ÏélB·ÎÎßàE.Ïñ"}1m麖ÚÒxruk\E•£Ü4:k]C™Ë5mŒµ”jZêJ7ªÕyBŸuæª|L[×Ѫó-u^ãM?Zµ]££ãxÉñâe¡Yã£Vã¾Ï_n~}yûõhB'gS`mJ“•”Yå½ö¤ªœVàrOmŽðí˜Oèö^´{÷gªb¬ª®­Ñøu©²v;æÀ¾Ö™)L£Œ%̽@}ø1Yó“3þŠŸŸ^Oè2™1ŸS€ŸN“Ù ¿å£ÓÓC{œT€Eˆ!qj©T`bmš¶S6¦csFÓø–âŸþ0ügàƒ0dª€…®{FL>ÖÇ ÙG1Hö³d>Í þ‚˜ûG„P¹§¥Ð5¹¢8 ì°Pûr@{NHÕwjU[=¨ž¨ÉãD‹ì¯®RÕ¼ýaòÒ!±=ráâÖÀû¾ËtÝ‚,F‹—Ikzά¾ïÑ ·Êz7hD2 Àd¦µ[«qݲD}KݘVU™N覒®,œµncªå¸ûN5¡­¹©Ôqÿ´×h•[t"º:R%}»ÒUhr´6wj»qòz1Ja&•cCi´<_¼üq×<·Bb \8ú;Âñ×] $[‰¼Ç])_;“SUŠøô©>‹á©⯡× ÐwE!òÿ…´#(Þ ‡p§×oˆ]±€¿°Ç\Ä.ë‹dJQ¡^ÚÅÉŸ8OD?×h­¢¯¢*b>~WpOºR©Õ°r6äÁ€©Ò›ûzÈ¡ª5ôP4nE©kKQVàžò½Ó^ÆëA«U6ÃŒB]xþô^ÿyc–WW1‹!úQ*¡²C¡ý˜]覭óÕ>‹HÔÜß:çµô·D ‡áã<Ÿ~yõŠô÷ά•Õ?ˆbmó‰j­¨nÜÝ6^fMô°ø.y H ª©ZÝÈd+µi¨«À•ݢݻ¬ú›ëãcoÉêö…'³¬øf3äoô Þ¤…§¼Ó,M…Aù‡zõdÄ”3UàZ&ônK¹.Tg[1×]Õø„¾ku…ý˜ÅAœÀ=7¢¬Txµ0íý€´yÒ­±v蜉óØ?xáñYº ç²Â)¶õÂÚ’jŒSãx'–‚î18Ð…µÐϦÄJÁ¥*õ6òÒ2Há¡ðJê¿6“^C0˜×’¦®æÃª=ÀƒËx*­pVI8Äœ8ÆFö/YZR­±?€4¡ ØYV{ùˆþ¸ÀÌãK0|×? ‘{­V˜2¬r-›°_Þ²QÅg»',ƒÉŸñÄÛð¡{"`xXY›\cékTåkÕ v(ÿÍÔ5+Í­!VpÈÚû-}üý‹c‡†àõW(H `JUÕ²SKžŽ’Ží› V¥¬iyïÄg#›îJ³\ÅV…kkç½I >g´¿Ššd"ú„yŽ»ð©K¬ï©X)É!Ø/“S(ïéûmÄöë›P­ÌÁ@3=)lGº@ `eK‡'{ÅöúèåÍxØê€¤2о‹; ö“g€âüÒš?ÿqÃybÏ”1À„ãPïЃ]ú•³^ŒT¯à _<¸Lç} P¶Ò~îpn¢l¼ž’>½¾ì÷§éä<¹˜]Ð|>I.YB¼³Ì’ ½w™0(3‡`o gO^‡ÅRÔvFÕç/&ód6Å~†;g¯/ù­·Gý {c'endstream endobj 5424 0 obj<>/XObject<<>>>>>>endobj 5425 0 obj<>stream xWmoÚHþž_1ª‰^‹ÃK iO=‰†¤m¤¦º„k¿ ¡/àÄöÒÝ5„«z¿ýžYïšà¼Ü)QDì™gŸ™yføqЦ~ÚÔíóï,;ø0:hE-<¬þèS»E£9ÎößâCìÞãì1HíR‹%ʼn–3«´¡LÜJJ,åÂZ¤deÉÿ›¬%¾zEjzƒ³†6‰]Ò…X‹êɸ!Lå*<¿|M*—d)i*Il„–¤æd—òåèæ EÍv¸jºNTah.f/…¥L`L3‘¦†¡ì…›k•9D›$MÙqVÌ–dRµ‘šÍóÝ=Ü â8±‰Êátûšf*[O ÷{`f©0F"*ãˆåÊRadu?óšñ»¤Ua“|AIîž6=|C"Žñ‡L†¤ÖR/¥ˆ#-C&±ÈUŒ6ç[¨•M²äo šn÷™‚x¤!Ý’ÌÅ4åb…á îp.94LÇ/i®4 ÷))ö÷äĤÉ-GÛ#ï¬Ìc`ÁÕ˜üˆ¿%ΗT³ÓçÔuzQ/:¦ë$[¥!—“¼ü¤´Úb³sŒÓ°;U¹Ib—/ d)’Ç௿þˆVjÔ^$©|WúhÑIÔåЎ݉º]ü73©7æý‹ö ÜÖøÝ3 +>íy7^„ó|vè»àƒ0rßÀÃÞ{úé=roÅUtÌF.g÷Œhh$7¥î{7êç¯=óÝѵJb*V\ñ“25ÿµÏ±I±7îÇ¢ßÂý8f-dxÕüãA¼à¾¼ˆÃºÓ‘¦£¾õûoøê#Ú.sãè² æTJê‹Ë·¡e?—ä¢P|ˆ\csýºv_iu·¥òÐÞ9au×"]«i”—Ù·«çÁ½kN"ú¾”¹Ó˜™Š¡‹ùZÝBöÝ5þËM©\ÓÍ…Ì¥—dIrN¡=®î¸½ž¬A—Ÿ9L…ýXQR‹2þɦ˜:ö"º,Ee}¹.{SÇïw¯\"\?f@+´ÏÇÀLh³D±³õLåP9KB/ŠLæ˜Si7ÒsÉ'œÇ ³›K ñÂòD{—íå‹ v]¯Qæ¹ö$òj¶eo…kø® ­YjEeúTgÖ¬‰®·ÆÊ,ÂLˆV¤¥9t¦øÝ»Eã«+Ž EûýG ýŸ~¼*ò< €]_:¾¹ÞBí<*£5”»éòiÚT ûBcöö‘zµ‚Å^Qý¹'5ÄMp-M‘Zž4\|;èSÉ׫Â>?jðŸ#¹¤!̱RÒzAÒÜ4ëU×Í(cŠ 'AÆxùq6”+ŒK7§­*0iWÜïüĸ²píÞ0<ñ±¹¼pC,Õ†-Ð2{”Q±gðã,Y,-¡oÍ‹o_ÎÂ`”£ëú§‹ÑR »èÅ‚g2b•bOÁÄåánÑÄ\¢ØB$­´œKÍ[P8CZþ(=C7ñm³iÍ SH—vŸ° =¥ªkÅlyZÀ_nGŽº ™©¼d=×@®Ñ*B=¯kê#NêÆ¬Tòy±B«y9'þ~Ñb늿j¹- —žn1{ÀmÉz)Œ“‹Á·Ád0 N?MNÿºº:»MFŸ®ÎÃÉàz2œ}ùz‰uy¦9ãE2q;—/ä}/âF‹JÁI~D缃¥˜w„DòàCðûa/¿N†gD„A¿ §HVfnuÉ¡|‡:…Ž·iÁÛ6«u¡Àn˜)”I*Åmˆ\bŸq5€[‘`5GWØM]ã”=v6?0ùÑ7Ø"‚.Df³ÀÂ9Õ²ÃH¸Â®hÄ— /æXMŸWŸC°€¡±×EŽ^òNyè¶®£ó¿µOŽ£^·Gý“nÔ.wW·t£ ÕÌMK÷u€Iƒ,•§›oJåwÂÔ¥¯þ+„ŸµØL¦©–Mz­~Ôí`1ÇfÖ}ó–þ<ø?/wendstream endobj 5426 0 obj<>/XObject<<>>>>/Annots 2468 0 R>>endobj 5427 0 obj<>stream x­Xmo¹þî_1H¯ˆœ³eY²å—â øürI€Äh¢ë}`л\i“}QH®dµèï3Cr¥•à 4 KK‡Ï<óÌÌ~Û;¦~Ži4æÿI¹7èð ÿ:æ_Ÿ~Û;ûC] 𻤓‹“þ |*èóÞp|Ö?£s^RÒ/üy¶ùXÒhxŠ5²Ÿý:Ù:JÎ33:ºÐyD“Œ†_÷Çã3š¤âЀ&Iï/©ÎòJÓç?ÞýöðþêŸWïnn'W×o®ÿôéöãäaòöÓíÕÍþäËÞ€±-íýõ?üñè‡lýæá7ßÃ_ø›nr£WZh“Õ¦TU¢É5U^Íüöbs;žôOØòs]‘¢J¯(¯¬“-u†oÒhlÚƒEÛ<&…²vºO¹¥ÄhåtŠô^-Õ¹¹¦ëŸ&›§š°?·‚7FMS¹¼Ô”Ìuò•ÝŒ·Ä­Ò^»£Ôn^§äjJµÓ¦dÄr¶ª-”qyÒÊPX‡ê¥6&OSÜ%øDp[rGv^7ûº¬¿Žà飲°Y. ]êÊ)—×Õ ¾ë>]p¦™Í±'•ê«¶0–»\ù¿d#Ù"ŸÍ]±¦²6šôÓBW6_ê>{fºÒFx®hVãbì.>“3*Õu–õÃÑC ÉÛz¥±»¬Ú8†CŽ@jl#ÖýˆÇµ§ ¶'F¨ã|¢*ÂήP¦,ðî3jYç)HÄà5 ž¥e®M^ÍÄ÷Ôê$M©ƒÚ?Œ¼ë‘rÎäÓ}ºC„ô“â\F›ä9û£R äÏÀ¶ÆèiïU„âÕuÏùå̼«ë¿uôy2Šy2ZZ•.b>,®R19K°7žf)3u)ü^q¶0å)­µ­^;R‰óàÇ &™«á3ú[ƒ\"Õ%˜JS„¡®TA G¹YÀ S¬«*¥G…ÁÈ+Ð"ŽÉœ#Èt_ðNö¾®ÀªÆê¬)Hœ‹nD–8‚cMR—%¶À0#ÄÂ")çs\Ž3vAº ¤gxœíh N ¼‡ãBÝ0±²Œ9h"Igþ6ú)Ñâq@2âk»ÁÚV¥ÜÍÛ0X2uã˜VÆ óX ka꧉W‚©eϫӫ ¶ønùƒ›€þÐÚ@û`‚fš*&¤Ih£3Õ™2WËÔN°ŒÓ¥®Vʤñ V‡N¨àæ¦^Ò´ûP+)Ð8. —Mµº :|Aì‚Ö^¶†ûÞä.1,Z™"׆àc,0M™µ€kÉR­*h–NNn/É«¤§y8½Cš†öPÖC¡iXåeìÚƒÀ˜‹©ÎrÏëíHJkÖúŠÜ âŸg™6LÆ•Z[Ð5—‰å¾÷­ñWKèÈc€°…w K ßÃ+àëY¹Á3äàvïñcù @½‚f~X_s]¿¼ôAö Bô„ÿއ ND_„Èê±ÐôŠ-2àú¢«åáßo#31F§ÓÞt_„˜I¶£–M{~ã Æa¾kêºu_²C\§½Ï«|vyÙžüA9 m§=6s< W_ ÕG…ªfGïªT?Ý7î>ûµnªÔ¶[Ât箄r]².½¼„ú<ÔÙƒ!4‡¨µñA[‹rÒ=~ºß/ã÷|Æ."ÿÛM~Z àŒ…ró£ëÎñ?¾"¼X´®þ?ýß‚(4v êß+AÑ‘RéÐvX‡ ì¢# oËŸø m/’V:ÑÈÜgD=zó†&,º–4ÊÔO=#·‡]` áäyýæh‡Üþ„œmó£ëohÏ£Âý óbôgë]ñ`Í}.¢-èܵ±$Ç›H±çº©Mè@UÑòCšªšKšÔ°úèn[¹<“E0ó Ÿû„ºÝcè´T"/#r¡h¹[SÖT ïcg^¨p/ç²_Eçˆræß5óƒ||f·•OúfÑð<[ÓŠ›Ô)ÑoLN¼±-À+ƒÐ¡~âŠh…ÐkÉ]wœx¡ÝmœeÆÃáØ-c‡ÒK8áÖ‹8nuýiߨö.Yj¦¸$域¶±GG‰¶ñš[Ä=v'›½ÿøYµ{}P*UbÞáùîͶuøþ–‹Ç«wPiýÔ(nI•»¼¬½ 7W ™ÅQÄW?à,NµÁ¨:K~<ÃGðQžûSÚFáÏ!ºvŒ0cŒ*×=w}ïºÞ’q» ¿p£Ðâ‹iÑC è#u¼r·uëÂŽ§0íu%µMŽ ¨­gßoP^ðSѼ.CÁ%VA•$è[˜áŒ^èaü¼Ã_áèö¨âÝwÚê‚v“„Ñœlžþ›ØÄ“¡'jWQ0a!1¸z³côƒp›d:^BÁRJ§š–·P €îÈw…ÁHªA:`-úÃ…SàIêųñ0-¼Êˆ“4Ž/;xääoØd ‡ß¦‘ƈ_˜µ· =üyÐßáà¤::¥ñù°Î=“ä'Í›:‘¤•JÌWG³áמùf[FïÓÍÛ@L+‘€ïf´TïÓÁ¸?úht>`;·“½ìý`ñÅ­endstream endobj 5428 0 obj<>/XObject<<>>>>/Annots 2471 0 R>>endobj 5429 0 obj<>stream xÅXmoÛ6þž_qLAÅŽ'Ͱ}èKŠØŠ-úÅ@AK”ÍL]RŠk ûï{Ž%KÎKûeC DzIÞû瞻ó—½1ðoL“)ÿOнQ<Â'ü2æ—?ÞïÏâ šNÏãt>ŠÇÍCN7{[]¾ŠÏ·¾›œÆœzá6N..pŒâÛÏÁ#àµüíëÛ- YÐÉõGt›ñôÞ¤(Þ$ÑŸV• ª–’Ä\ßãuµ2Z$Kª4­ª$-E™æÒXÊ´!A¹0 Ie]Ì¥!Q!«¥N-­Už“‘_je$þ®d¥*…Óz•«DTJ—¼–oïöN®á§Òñø¢“J›+ù5‘«Ê¯ À#ʤ¨jèTÆt«©Àù €ÕRÙ#%‰¼’¦„©í{(K¸Ñ½JeJ÷JPµYÉB¬,)l LØ%#¥ÈÅB×÷fË#jP±gÜýð«Ñ~µ4zm÷Ñq]ð~D·8c¸8€²ø–ÓE]éwHDžoHq­ÜèÍË—ä}Ä–re+܉¯ÑCìòƒ¥TfªÄŠ­=³H*ÜÈPftëãHÞ{r=m¢u«É®d¢²&v~YÇÿaˆdt€0'Ki‡k›ÐÍ´úE܋ΌE0='ZŸï* ÜùŒ£¢Ê{°R²‹VÌaДìR×y Ž”•€c˜+Ldg?îñOïùÀ=vjzì\6‰§Ó ¾6hLRñAKª­ÏYPò®.'‹kä$;Œ`HƒgÎn(ò€ª¾‡øð1÷±o¹às]ät/ŒB~ »l •‘õÕ÷ ô‚jèLçH¤Ò­— •CäV£j¬V*þÎôÅq&QçÕ3 ºµ^m<>ìrŽîÜzO.ú‰˜kÇ?·$ø˜$µ12E»±ö¤õ;dÛð°7¹æÁ“ˆžp;ËK“&(ìSåmS[¸C²éIßÍO§ˆ YJƒÊ™"Ä¡ú{B´RXó õPçs‘HÇí!{ŸpA—BÑ.ó8BڹƀùçpCÑù}ËOé¶þ¢ àEr÷ÂÅ@Bó7r·õñ9¾PzA_ikó^I¶” ¥p·-©¾ŠºÄˆ~Ù$ظö±*)¸bÛĨ90:G<ßzô—µ‡ïH ëg¬Og-…P7þx:'‰â8œX|¯LU³vh•Rªo4;¼šE( (Ó¨yÈ'¯Õ³h§zìfbc¢cÉ@h?±&º˜»ö¦UÏFT†þ÷{†Ê̘§Øåûc®¶ÜÞZ¨§ó²GÖ.·¶ó{IdhRÁ­<çýõŠÒõ ®žË§ý¿¥qåÕÕÐï‘9W˜ÛÈÜ@0Õ¸o¨ð­™ÿ­È·¾µÎ£ »þÅ“õÆ50oSå­ÓûÂÜ´ ¡§°÷7]É+z-×Ó &"¯Á­îôõ=¥×›OÞSµºæ’:ÖµÙ`E±¥f=Žö{@0E¸bhÀ'­Q:|¡Ý,u°rKãZÐ\ý%Ñ\sÓ*M¡0‹IÚèÚpç¾0¢ˆéFòÀÖÏllÂxå+4\“Jôð9ƃnD ÒÙ¶#ªÄ $¸ºQw—ž¾Éé >©F‘rˆë,s Ï…ˆDY)‘÷¼“´“¸N¸3vúZ&œ³äf»¤ò(é†KQn¨.—ß­]SÄ&»v­é•w¨æWµmO¹›6H=Ôa wÑY LÀ­½%?„[Ü@øMTÚ`¾­­Ât³!µ(9u)¿bä~¡=µ–…°ñA‰»´ÓFW?)Á ìef>-nÿAÃwr}ÙŒºã˳ø|‚^.§aèá$;žà§”·:© pÃýlÁ·CûÕǾìžÇçø]fY7WÉwƒðùÇŸâ—Ëäṙ½»Ýû}ï_8üÀaendstream endobj 5430 0 obj<>/XObject<<>>>>>>endobj 5431 0 obj<>stream x¥WÛnã6}÷W \{¡tmù–8©¶] §HQ§—¸hŒ4¶µ‘(-EÇ1‚ü{‡¤([²Ó`Qd äptæœ3Cîׯúô3€ÑXý ’ÆÅ¬Ñwû´Xþ è]÷áÌÁlÃ>Œ¸ãñ)ÌBÕ‡Yà@4ßi¡©ðàåhö¥Ñ‡î€¶Cµ ðùS÷óä9ÀLF)¿Œ‘ ßñ>퇶ÂH` S!—"]çKÆÃE¾(P®‡_Åñ'èõmzˆrˆ<Ö½VÚúÏÞõ1(¬sèR‰Ýá¨(Ñ9% Îdô„ñßùB&m<ÄëH.A.‘v£\F|¶HP.ÓpçXžaÍ£€Ž¦<‡€r> ¦J¹ çy¾JT¹dX[°CE¤I–«õt ¹ =O¬¸Œ¼×̃L·É:‘:¯4Õ9ÆÌž­Ü ]Å¡Jå )gÏo ÐÝш젅ÕÀ@ñ»u´ð¼_Ø+EŸbž³úŽ2C¬]ÜÄ®ûG…!Þä†CBªÖ$‹ñòH® •`cÆ“vQ¶•Ã3©>GFFBHØ8ê LJ,ÍŸV¶BÐÜU9”Uލ!ϱAÀg¦ Bˆ - –Ña•#¤s-OÓ"3Vo‚Üd˜°,w*•KJYäQå-£ˆ¨Ÿ*° ´IŠ M–‰4‘bdž åÊ)P+ú0‡®YfHdò!&° j a¯T#*8ðÎÁ% Éçó9 ä²ÝHV0­­³8[l”W—쉾f5³¥k¨HÌoQjZ4åÕa´ãÅv’†«˜¼eÍjš4‹ þ¬^z"µë껈ñ*DøÑÿÙÂ×á»û¡á bæˆ2„>A³è ç¯0qX" QPÍjr‚"z¿‘+_o‡&ÓÕäúævr?ùçròûìæ·[ß¹=ŸNü£jp½2Ψ»2 L7·w&3LƒÊd«‡˜¶ ^tˆïh[˜€Â(Ö4¬ˆi*ÓÈwŠõ—Wx­ùCS¸¼0ÚÈC*º"1:yÎRj˷Π–ËA Ú--ý°1#Ì6œÞ`t6ˆYNGxÔOQ¨"T_Ér4Õù,É¿üõüÏwÙ/Ó,1,CË–2ñX H{ÕÒ”¢q¼½ÏÍE½ã?{˜§N»¸J|§œÑÅ£FÑts©üçy*ûÀw"NmS%ø ¿å¤úâÈ0·K³Ú‘i.¡Ò²[:…‰Ë• »²¥ö†ª~šg@ypÊ$]©yõ Ðf‹FÔ#½ èIµìµT›èVUÎ&æJ© ËÊ…+´÷ªŠÿùÚØëSÃÐÕd¯éËBöMùvì¾+÷b·<–µ*ÑKÑ0fæÈ€• \9 JÝtÃòÉÝ»>+…ƒ³c÷dtã³¾}ØÝý}óswäöá* V ]ïú‰¥æ1Ýo&º{j´ž¸'î©Á¸Ás‘&e×è§ûI쎆ôÿ z/Ά*ÙdÖø£ñ/k1â¹endstream endobj 5432 0 obj<>/XObject<<>>>>/Annots 2473 0 R>>endobj 5433 0 obj<>stream x­XÛnÔH}ÏW”"²H<·dfÅ· V b7³âe^zìv¦Á—Áí™É±ß¾§ª}'!¬´âÛíºœ:UuÌ׃ ñkD“)ÿ’ƒ¡?ÄþkÄýõî`2òÏi2zî)¡ó±?./bº>h]&4>¯OòÃö5žN`µõjûOÏ{ï¶®ñôùÔG€ƒXn]'4žN:–_Í[YH*ù .‡táOhÑxHÓ‹‘?žÓ<”\‡4¼#“Æ&ÕôíÉüóÁNF¸zDA¬¬¥«ýkù·ÿt½YÆ&˜õÞ!Úš¼Ø¨˜¶™ )ÑÅj´ðLZÐíâ «<Û-¼«ý‡ëÙìím ×…ÉÒ—ÇpÒ¹ó g_Ðð÷‡^y–ˆOºcï•Ï¿S}»ÖA¡Cz:xØßdáEq¦îH§1ôPðÿ”Jèß¾÷œ~ïf-—§ —ð5<OÊzïSdl,ÊjüÄr­)4Q¤s ÔC“#»,èí!ûµNÔÚÒÎÄ1-5m,R/2ºÑ©ÎUq·]ÕŠV* c[вœ#gz¹Ð˜9cfŽÝ=«ÂöŽ©{X{‡¶ï:7éóiŽT«€Ã&&Éi¥¶šMtHË8 ¾H¤¤U°¢& F,ên"£Ãc2Œ£n°Ã:Ÿò\ ˜¬”åýð$XiÛ‹’"­ŠM®ýÒØø”Áù Ä`;¼¿<*×d’5 §PÆ,÷d"2¡ÚÍ}¡,{+xKk4.Wí¶¹Yɉ×ÏžQ¬öZŠV§†ºƒàÃÚ‘ 4¶0iP¯á²>½@*Ç$iê,´Ä!.µIo@¿8†å^Þ ²Y„9ÖÂê8¢]î|hEן޿ë Ü”òµUåá\è ‚@c Á’Šwjo[Iáž3›KŠ¡ŽÔ&.úå¹Þ™›ÙìM}=uúÕrÓng[ºZÖ(éT`4)àN ÐÈR[äÀŵÌrscRL¾7ÀÖîÏ\'0¸ø´s_õŽ÷¨B×õiÕeý …Š*U¹QËXS”gÉÏ€¨\Ì\€}Û%]u Šq-Èw¸ê‡ý‹Ør_vbF76e$€6jO‹êùô2Îàjg &.×Ýuº `«ÖZ„¡ã.ª±Õyø÷ $x_¸ +ŒërþZЖ–*ø‚É€Rs˜›4Ôy¼g„¤u•-Vžâ#ÿÍÝl–+c5Ûº—“³,ë®8ýÉê ìXx‡uX‡ØhåΚ͒ý•DEG}EPäû4Ñ#ðÜ䀸¥¶øŽahÒ»§ô›†×¾ ìø ni©L·¸…ÉS5#H .¸a¨éÎ!ЊŠHû?Veá}Öévñ¤»˜¡7@Y ø”¥›8î?íîõ£Ÿïñk,íj*ô„($œWW­:æ ôÇQ]oéÚ)ÐØªä Gz€ïŽ$à ÇÏeï°áîägeÀøVå“_{µ²Û—Ïitêc½EÔ'ã þ1ôÆg®/e|³]LÖÂé¬D'K(ˆ.EùÅSÿâ‚ßü´Ò)t ¿UÍ,ëF|c¤’™®EÜ2R±ÍªM#¢¨ý¼ZB‚jE$ ‚íÛ}'Ϫý`•‹#K;È1LÞ‘U(,5·¦p >1´d³Yxî¬Èh ³E 7úZ«²€ºbáÊ!E»•A¯ð¾m`­”féI„DÁ`¡»hxP4Hr±§k QýP;-Õ¾/·;8äúëQb•±nxGšL¸ƒ°û­. î\omûݺ{”ÉGK0†F¨YŽ\w²šß^íý~ œäÒÚÄ2¹µ…±îUL±ù½fìÓÐYY4^_Ž1Š[ò )w2UI¹ª©ÛÓê{ @ÕâvhVD]xË «ÏàÌUv—p&iq]qÝ ƒº°(ãq¹º .Ï ߨÔŸ*>hðY;ÁY×¢*_Z*Ñ6>Â$²›5ËXùòà=á[³\aMÈ6ÈÖÂE 4Þ@È&×é&‘QQ×’A¾Ã[C,Ê\[Ë)—EOµ&c6åÞÎþ<øØvQendstream endobj 5434 0 obj<>/XObject<<>>>>>>endobj 5435 0 obj<>stream xV]sã4}ﯸ/;¤lã8ͦÝá-téC˜fà0Œb˱X[ ’œ4t–ßΑd%qše˜všFº_º÷œ#ýu1¤?COÝoV_|˜_¤IŠÅý½¢Á}J³dLó‚F)Mo†ÉtúŽæ¹·JižõzXI¥95†“*¨‘¦Y¯•¶<'»[sC‹ž-6s^‰U!É–œÖZYž93ƒ¡äâòrþçEJý!"ç½7"Äý)Ú}`†ßÞº˜ˆd޷ƨËË ÁéÍKg9«˜1Ô‰@Ñ"dÙWqÛIN]§EoqI/ŸOL6BÛ†UôO'ÁÛn”È©u|ähLîí3%=“ÁYK%Ÿ,³"‹ö¹j–ú‰š¾àg¼=ùdáÿè+¤%qî0~E0™ñG^/¹þ…iÁ(v:4Œ¨ îbìsæa0D@È&n[PD0l…- À²ŒcbL<ÀHí;d›¶CÛRd¥Çöë“´ØÂ,=HËW\Ï—Ómùjœ½ãUa]‹HsÛhI¾§îì?wCº| ÜÞžë }CÃ4z¶¸õq÷ì8–õ±Ü[šõ~EÐf}7Üi#ƒéqÁa'éQÉÌQSM¦Öü¨§nZÝN ãAu.9êå„0hóŽ2&¥r;±á#Gº­fk1iG·8Ô~ÞÅáƒ8ìivEFùÃ(YíhËvþË~N¡:dt…<8Ñ@Á€ ´ƒQ`µoKεØ@c ­j©S_.4”Eéà€Ì  ŽD…ª*µråyßÕ¹þh”ŒÇP½¼R=î:Ó%þl¹ÌO„%¦özôÒùF´cEF'‚Tœ˜F¤Eþ´®žË¡ûbÎúÓky‰˜‹ ¦×š2LF‹Ë×vÆA¨nn6±<è·g…cÑ»>Ør;¶paõe¿ƒ['ÍS+ƒÇr³è ÓƒùQ–á¼Ëk‡Øõ eå ' PÝòr4KRýõF×É;ºSu­$eàŒªÅßPh|+8ƒfpã†z 5H=š$³™ƒÔ·’8Ó•à:^|`7zD-ªɌȌ»Tïwoß’ç ›ÐCA;ÕP®0HGŠ-‹ÜˆðôëÃGp¤ä Ü BTüÊÛnEU¹–G´yƒd˜×ËZ©Eír‚J _É6ôɹɴX‚éôƒÚò ׎ÅÐfQƒzÈo@Où•%.U³*É*Ç÷¼ALFRà£Æ·Š'tǵeîþ÷UtŠ)é߬ê!V¥×¢ZãNˆB\UGõ*ÊÚxÑÕÜØöÓ–i”>/XObject<<>>>>>>endobj 5437 0 obj<>stream xVkoÛ6ýž_q‘-˜’*ò3Nºa¶¬YÛ{ Á†! V¢m6’è’”)úßw.%Æ•¤«Ô/ïãÜËsôñ G]|z4ñ7-~¹>è&]<|øcfÔ¹R¯K×SØŽ^âGæ÷ñ#”£•®òŒÞKi*­UïsIS£ z+–"¦÷•#7—FR!6lVj’Ânh…¥Ó”Š<'庞KZãy{eqP8ä6 I+# i(Í…µ¤ìñõ‡ƒ.öúH(šÉRádFSm8¹•¦L²´J—"'a .„…tpcu“Â즤KëL•"t™!íR-ªΑ‰­”\!Gï\<L”é O[)Ý oñ­í€-E^I«iªÖÈ@Ù˜6º %*Tbu!I®t r®yZ•©C6¡·•uTYˆ"w²8Re®JŸÆ¶i`0Ç—ˆ{täZ‹\~_$nn`öûÉ`€U5®èèS(ŠuNèwíä÷T\׈füX)Ô&Kt[¨…V%ÃÌ‹²¿>Cãèd|Œ“tÒiùÞn—r5)„ÇÑø¸¶m§ADFºÊ”p¶=æ-ÇÇèXžëtõF'VÝK= Fìì‡VÌÏ­ÕR+ ‘2Dßú^ç{‰°ý8ÂþW=û’&Vº­kcX¤êÿ>Ä ¸´D-{áÖ7êöæÃ-ýHËç6™×!g_ ùX à&Þs±Ž<ŠÛ‰;õ£4HF£sž™«-øI÷|é ŸêLR®îx¤•}~,ßb&I(CB~ÉCÒNïÝ?o~»þ÷ÏW“ÅDL†“I†À©fø“ÖˆµO“/Ú%â.>½¤»éQÛ^ŒÏÿ´íÇýÇl“$iMfˆƒá™€J š+Æ‘*bñTJ_Îq0z²G?g…r Ï|û.ð•.µgn*4Gær&0¤¹Öwªœ¸Øh‘Îz­Wr) †—µÀÜYÏš¼¶üŽé@Ó\˜Œ©@1ñ€“A÷o0ð4Ñ(†Ó¡^Ïç04z)I—u:•å ¬(Äã‚$! …X€=™£5Æ ÊjÔ…ºL•4• !‘ŽÅdqP%1‘ƒý™Á§µ>1å:h…mø¶•Ê÷‚ÅX@téêeÌê¼òñP^¦¦S•V¹[i} ;W/‰5ŠÕó´?â Ñ?KΓ>]z!Ó×E+åætä×g°mŸ&C>ûG P¦žü |<ËJ랇ŠaÀW€ö Šf°¾Ô®©Ö¶`çõ¥ûð|©€Å\g– iPBm =¯a ø‡$ú¦†‹õüõ=*tVA=›qμ´ì(Í7ªLó ÌpÈÝ™K‘I“ÌÛG}ƒp€M#Ú£·ÈýSˊѰÀ:ÞÄ÷íÿ9,k?Mè)G)Æ™Nœ~ç `gúÙ†x“˜’7wÅâ¦×íoC(~qÈ"6Ã?»€'‚Y|XÇGG³ØÇLJ1}ke>=ýi7?6áÇý.Ô.ƒ@Âã^ÈÛC!âD,ÐAó a¯²Aéd vGaë ÃAƒ› {Üä»Dqp±ÞË–÷±¹Áææ©Í{lî4µ ÃŽXb³ B=«‹æ®w1LÎg4:&çõ+_©ÓAÒ¥_uZ1‰yžá)ƒàÕÖ§ç5¤þ†÷è²sùâÅÞ;Ÿ8뎒A”€\œñ£W×ü>npQendstream endobj 5438 0 obj<>/XObject<<>>>>/Annots 2476 0 R>>endobj 5439 0 obj<>stream xíWÛnÛF}÷WL ‰–¨‹ííC];u8m­6( ÀX‘Kimr—].¥ÈEÿ½g–¢nqâ}­lZqç>sæèσ.uð×¥Þÿãü vð ¿uùí××ÝA/<£A§)§îY?ì¯NÝlŸsŠzÝõ]~º}ÆÓAF[²Ûçœz]ÙnthЯÍö,Êous„K'ƒæ¢¶9Âd·v7r?Œ¶ôQÚ)_ö©Û¡QŠL Ïð!ñ À‡8¸6‹)MoÄ\îŽ/;töørÔ¡v…½NI𻌱4§ïHËÕÇqµz­þøè[–Å}6“7ËÒÉ<4• «´Ëô8˜¯.mœi{½p8—ÔI}§ÉB@ cïKZ(7£‰ÁÛ9 ÐùË—›D†tå(1²$må&Qé’ÜLR¥i³¥ÒS2“;$„3'ô’bÙn·ùŠ·W*£K2:[R93 ªŠ&=G !¾Ê)‡'m*bÖ>žQw¸RíhÈ—£Ax‚z\|Œeá —fp5c¼û°yÀ!<¿ƒÒõW»a³Jîm(½JI hÔ“cN+{ÕnfÍ¢DD$­5¶EKSQ.8>íÈdGÏ¥ÅÇ™põÀ@™fm8¤‘AqO•µ–J«RràµW˜¿UK¶9â$ØD²ëv€¦°Èµš£0#ämWþkä¨TybdÒ•>&+V9I…@0&õå˜J-­p2¡…E!­ïŽZé8«‰¼°iîrï°ÏÅ3ßûŽQ%%Ò •AJœVèçU©½Ü.ð`.ƒ§‹º+Ø t@%'Ähß4¾®¾ªšÎ[¨Åºž&EóÇDÅlSXš,ÉJWYÍ}$¨tÂUeï8ð©à|“®ò >týÛÛ·Tß°„ôÌDQŽBúIZIˆÝÃÇ:9>ã<™—œcßOj:sus;÷ª)裸³i tb–™˜þjªà±†è™ð¹ØûV¥4¾±²¬27>úDˆè.ÎD‰ 3ñðP/î¤Jµ¿¿DÆÎùá8à¯ZtÈSuœ ==~_¹÷é;™»¼à9ÜÇ>ÂkK׈GêZ.UÞ4^Y¤6ÕtF¹×ö¨¢ºHôL£—v!–èï€wOs£zQçk”êAÞ:Ò“%šà)¾ªwAë‹E¹ùpõzôÇÏ·Å­7%ÀU©ÃÆjÔi^O™ôÈ_X“T1†ŒR‘«L K™1÷Ü »ØòåvÙŒ”=+EB‡¹Pú¸ˆ!1Ü/â+ú¤;Éåšò‹A¯nè7×Wë@¯ëYy'ÝÌ$ã£'$×bM¾Ø­WÝáçm¥s 1…-Z®EºQ-óÙêQ>S+ì’ß¹J¥É%!¯ e zÙ Ë׫%µ"—¼$7à-²Ò¬\¸. «¾\ÿ4¿€Ø[Ç•µ2ã£ÿù_ r ú‚ÄÁZcæ QTFê) Ä|õ&CÕÄE¦°Ýxãc¹5{²Ù7å£ûy ž7xuÄ8Be!c%2š «Ä$óü`½G˜ÔÀ²• …1Lcs1w:?Þ!.1»3‘žùå<êÊ'pºío~^’P¥ë‘ÎýH¯V%¹e!Áf8‹™g¨k'1øžÚfkSGÅ•9aëhh%û‡¸ðVª@)Š-äX«~-‚ßù ø‚'9å÷w–5˜ãyÉʬw7¤éIWÃÀJ}Ù÷~1ñ0»_ŒÒ«^S— aÓÊ¢ ¨»·ÏH¸HkRˆÔ‚)x‘¢DÍŠ„ôAD°”xV×w[ГsDÅ«”;Q@ÓÞR LÝsœª\¡ÑéŠ^F~8è hxrZS_n¹v/ìÐ&®r©A}à6G‰ŸõÝöIý3ÆSïˆ<@àRLì×¼»ùa1è Ã^ÆÛ;²ª‹ÑÁ/ÿ¢ MÌendstream endobj 5440 0 obj<>/XObject<<>>>>/Annots 2482 0 R>>endobj 5441 0 obj<>stream xíWÛnÛF}÷W Œ¤ Ûˆ–H]ì-кqê  ÐD@_kri­Kr^$;Aþ½gvÉIÛíKßZ$<œÙ¹ïœÙOG3šâߌÂ%ÿ²£©?Åþ™ñÏû×GóŹÒ|uîO)£ùy蟵TJXžæË•á…3Õk¶‚>Æ,K0«Gf´X@ã×#3Z-ýY×#3:[À¯Ã¹™ÑløAÙ§Á ‚;}ÜUàŸ÷ÎΧ3Ö5·A΃%»k(JFœHV'ËÜUÈ>† “„Ùlê/ZŠ™}f‘>dÝÈn¶NÍû\8ÙÑÁ9»ìÎöipçS÷ÀíÑà.‡vûtFátɹ³?¯{-bú¤¼¡ÓË)!ÐuBÁ”–ç3¹\Ñ:64¥uä=—w‘,j¥sº‘µªeF_NÖ·GSšÌ {Duyÿà= ¥HÔÑ–6^UÇ/_ê¦þ¨“¥Èo$}#7'hºRQU„ßϟ麕ùnòã¥Êã þ¾ñŽoÅNœ¦PqúªsöxsòýÈ2µ'×ÛRïßÉýÆ3_Ðñ{c]–¥.=Wʺ)sz–7iú@ë×™ŽB6‘ëø¥ÖÆÓQhEsªèåà8ÒFää¿m3¾ñT^–wËÈÐé)½U7Ûšj‡&ÓÕí¡ß÷¿š N/Ñ–p;¡ ¼ŸaÛ ÞU#’äÈŠT’¸Ö;ù‚X·=âq |®ïj`%:¥©ŠE[ý)chëÚÊ&Iä1UštcbÒt-)–`•U֩郦’]çY'cwÚÌ\ðÉBB‰ÈÙDUÈH% 6]’ˆc•ßP­M¼sÔTÌýœ£v‘˜†ª*YmNFvAUK“N†ø™×ltôí·²”cË&i² ÛWuɾF:¯…ÊùOKB|™†¢Hg™ J¢5ƒøn±ã>­·&³‡Â<ŒR)ÊAÀc뉸(’½0 ó©Q;‘Jô.R: Ü{nÔ¹ÜUq;‰ŠŠRî”nªôþÐîm!™Ê²rmÒ‰0Ìõ¿ç|®y«J\§h3{oºNo}õ郴î0Ù»à,£f¬Öå¾M¬)÷áL7Ä=Ó¼l*VI‚fÉ#”;Å^pý]6™è”™Œ `x CÀAì[Û ÙÑǰüþ£ À7ìFæÒ‘¢Ôw÷”Éz«cÊG‹GþpöÆÒh$ðõuØèr°|²e- ÚYvÑñ¶2?¢öœƒÝÇP· âé A'uÈßmEc;†ÿ$Ær:[€EÊa)QeUw¤™"ôæÝ`+5ººÇl¿c†…Æ‹ï¾{„oÆ91otn¯Òeª •ÁTTta&†HÈ;…a²Ã€>]a ©h«÷¨ÐU¥0åx¸ïKl†Îƒ ˜¥°ã3­ j°¾”t­ëm«žýâÁ•â=½}Ã× &£†ëûBf¢¨ÌÔ鳯„Û;–쬤YK;¼æ<í8ý¼¼4âFNxÑ*$~\£uSßW£Ö¤T]—›p‚|šõ¤;*sŽJ¡PK§`Ë0€#‡±nžo þ¸zM¿YµÃœ¢‰¶¢¨eé€Ûe©¶Yêšê)¿2|2*p5œoÝ^„U<²²k‚x‰0v*ò%M‰ÐÊžNƒ~l*…¸V©ª6›F<€Û 9XrA‚…¿Â3é­("Š$^{…æ1Àd'M¦x ½9¬+™ã0Ôüdýî¾(†w«ë?kôLA{µDÚùÁÂÅk‡žó…’Rg†ËD4郲ãfè²Ç—‹?¹ú‰¢H‘nÓãÐßpcñ¢ÖÚD]p}ìè|÷1ý8óf_ÿû™ùX쬲Æ-ù˜Éˆ?ni_?;­Œýžpû’À;Û¼$fgs.h¹<óWv±à®ž„x0ÿ¢£&Ãs·Ï+=YÙ!jš ¤Wî©àZÈv‚kG“ˆáÆÂÉ\à h*tBx¶âO¯ÖG¿ýÛ³ô«endstream endobj 5442 0 obj<>/XObject<<>>>>>>endobj 5443 0 obj<>stream x¥V]oG}çW\Y²Š)l€Å@Zõ¡qD¤º­Bä‡8ªÆ»;Ñ~yf¼²òß{îÌ.‚ÛX•c‡eïÌ=÷Ü3çÎ}gDCüŒ(œò¿(ëü²ì ƒ!¾ÜýÑkzu5¡Ñ–+ÄN_ãCìÞãCÔ½QiJ¥.â*’dI™´I“Êý^¤’¢TC[e޵2²2&EÒ˜àbù¹óêjHó äã! Æã ñw÷ÑÆ «"Ú*n÷ø;“·ÝÛ zä-°Œ1Æ]"ù ²2•ï®A³¾‰üñ ð‹ÏüšF“`©.÷<Ng¼Ñø2˜ÓR•†D@'¹º¯¤ñËö” Æ“`ŽÈ¸ûsŠÚ«uBïooIJ…^Ë´&QÙ"cü}fEKø¤¶‚yªKi¨XÑV‹²Tùšë»Kef,,iy_)^Çʪ")UFjP\V6 7¾Z‹I3•GiKŠ¥HyGG}QY¬ Rh.Imúd¬Æk_¡ÐZÔ& eäQ"J„P¬LT€ÜܨȲˆw\ЪÐdŠtÃIadK±ƒÑÒ4Tãk–Ñ`FK[éœzƒÞ‹,¡Ÿ–ï&]V~h:l_—Ru§…®i¥@û–=&‘iÙ¸Š‘hˆ­pžŠzýföÏ3ïFM«8çÎ5ÎÛs¶uÖDÀ ¤ƒÞ¹–5}ûãÃòÏËۋö0£O(]\#¦Yà>7ñ{o=jÜ"§wb#Ø0 O‘¦ÅÖP]Td 'ÌV“‘“^ÀóRƒž*×ûYr\ÅûÚX™8–°R¬LóÛîÙŒ4Áâ3ˆ±íWÅü„ê3D=¿¾lsºsö'}Ä}SÞùÚ¼Xóqøé¿H¼IT”xýÀÈÊTÔÿ~>ÛÊÂm´yg‡*=jØu—”[g•>ÃâYQ×õüp}÷‰û³È5\×7•[}×ñ6¤r´BÄ<(<ð™„^•Ïft¤ðÛÝÈhÎ5Û|#f†¯”6–$’„tžCZ¤nh8{gSwŽ»X9ÆEþ¥­ÀÔ‰åÖå=æØN’ç:âðdIýÝÖGÑç¦i}L@ŒIñ yÁ‰ù¾áq8§ïù èÑ?54§ñŽjãw¶¼[q™ž›*‡gMà‰;ívÞ¨y#ÜÑ|\†—4á^4rw2¾Ü Â`H¿QÅšpFÌDãDøèÁÌßÅp…šánõ»¿ú Ÿ¿‹œ†¹ù»"\Y­F:oq9œá78n8ŸóWo–¿:ÿ,w)µendstream endobj 5444 0 obj<>/XObject<<>>>>>>endobj 5445 0 obj<>stream xV]oÛF|ׯXpAÛ­[¶Sô¡nëÂ}p[XA¢ 8“Géò޹#-«Aþ{g2%Gn‹–DÞííÎÌÎÞçÞˆ†ø7¢É”ÿGYïzÖ†C|0éJd‹ŸÙRBY¼ÔDê =Hyž*`]úéäØ'ÒJIv‘x0(±ÆÈÑÊ”iŒ¿ö“OÕ¡Hy^Ö´`LJM±L”FÈ’Kjä5fo¢CÀ;Àjn€)š±Ãh¥%VEF~ܬ€ªTx„ïÿ £-»õ­Lê”Q)omV­Pg›ªTxk;¹ ¯`9zöÓñ?ÛÌ{ŒÐ -2ÿñ ïþUÞ™B¾¡{ؤ̠ =®`¦¼„Y(€¨Œýò!óP)?É…sU/>Š´”ýmÐãªåµ '—JÎÀëÀw/ΉU¢"ôˆÑ`Á¸ðZlBi±ñ‹ÆÆg¬˜k$²â4Š¥(<…œµ°kÊK‹ó}û½ ŠFë¡Ú†BÂìI†\™çÆ¢ŽˆX`X0!½³À-ùl”´Ã¢Š¹oV$ÆÌƒkaéöýÇÛÙkž°Ri S(ÐEè7.ˆ{BÇ@^&‰Œ B3½æäZûß.36`”VÝ:©Ê„l Øu¶b!Û-¬<§7W4B÷ò¤Œ§LÊø<¼ ÇÐ[oÛ¾Ýͼø,ôbó€ËJÏ[Ç Ý†z:»AF´$Ha++À@ÇÝÐí&›’…¸³Rt6Ûœ5'xa^·Îù6’•Vjóéîâ9ê-ª=lWnõ Œì˲M ¿ŽÑíoøC´óU;0ßïÍxßߌwÜ/@V¤°b:ìÞTäìV“w-ÇÕæ ¬×ÕDZ•®L‹íIxèï1Ìm¿®îc3”åCä¯I~¶kå‡/Äcbúƒf~´-ƒLDÖÐBjiý/áq¼”)¼¨õ¾|À9øv…ý¨‹¬ÄŽ>šÃÖ æÈäkl)…í©…î{Œ1+ê¹ÈVUÍ«píá«#‚;Äâ¦mqðÖ 5'&MÍÊí'™q§c-Wñ-ŸÛ¨Wï9Åz?h7—õ(]ž…ç“sšâ󢺸޿»ýu0 ‡ô³‰J¾yµ~ «Õƒ‹êþê»z„¢ø²Åî_ß»žÝ–«iµ±Ë ø7–·9æé|8 'cxd8¹¼âG¿ÌzöþqS‹¸endstream endobj 5446 0 obj<>/XObject<<>>>>/Annots 2484 0 R>>endobj 5447 0 obj<>stream xµVÛn7}×W •ki³ÒÊò%ÍCë&iŠ MkFaµKIt(r³ÉjÑïr×Z­k?µq,CäÌpxfÎá|í (ÄÏ€¢1ÿ×0±ÂþøýC'g4º8 BZÓéY0¬¾hºî4¾®éüâÑ÷~˜4‚¹ˆÙ’^¿é<ˆh² aHã‹A0ŸÑ$qG†4‰»«¢DjYÈ™2E:í⓾}˜¿9žÜwBê`˜T†l1y®–¦6ì;l„.eÛ‡7ˆ·Ó™ß?Œýúýˆ8ø‚úÈ®?Œªìº ý,6¢G;[ÒÖ–:¡2—T¬$-JÊšœ´úÂK*¿ä<oÚƒ(½“îõÍÇ“?>¿›¥|=Næs‘Ñ[’bj¹­îÝξ¶I2íF½QÏû¶Í8j&óR¨XlÞG¶Ý®wy!×-‹ Í`®èQD'4B˜#üõ1+·ç¡Z82™jKª¡ð°v_¥¡e6{„ÍUo’N½q]ƒ.ÍwÏúÇEÁ·çŠãÎZp*§µÍ$9¿>—*¨SÛ÷c£JœÐ¾6¨‰ëši·Ú35 b‘lݶGÜ}qð…ªVl›þG¹–¾Qùº-vƒ®铚g"ÛšÔœíR¼)ŠF ‹ß2CÛg`h!”Î+/h0dÞ0kÆÜåÃÓ€q½ÉDš*³¤+Y&v9mU±rdªkÎþ£`Tó„bah‹µ·2$|!(ÊLhj-ŒANÅ æLÊD.÷?¨Ìùx^¬ë]µ¢Ïgv^ê0‹.¸ì¡…#é“,¾É)ÉU"3‡TNº8°j—YÿJ™X—‰¤£ƒs5»Ãíߎîwœ,¦6-µ(¤Wº‡Û»é1ýU§ãDêÆJêЛ—¹xp|¾!õÝ''žqŠÊVüïáVÝóèÿI;Ò߇Hµtr²’EkPµ–€Ë”¨ª<×u04—¬ž ‰œÔ‚—v´•à&Kleü2˜¸áí·Dž9Ÿ@VSsšKdO3h<ëqK÷ zÎî’Žö¦þÉ© d|=ŒÎ0ÐÒ,‹Õsˆ>ï¼ãèjãŸOv.‹ï™2Ó®³ßçâÍ<KmçBÏœECí—¾m·§ÙM§¦æÿ»wó”öõŸ}OMŠKzË2’BþÑB x&hËå–„Ù±\™¥Ì¡õ+Ckñ …uBàÑÚ*­¹sÉ-¹s;±Ðšå¢ö è'Į懄ÅÏdZ‚¬ ÖŬ4Æ« vc›È—Û×éø5ø;ÄoTŸâš² Õ¿Z>‹×/¶`½…#¼ŸŒ87éÈ”˜kÆ—ðKÖ‘]ïòkÉ uˆ*t;𶘱àÈòè#lõÇÁh®–ËJ†ëÛ8Ìø¬+ ä¨Ç6•î!èW£=ô¦\Ïá‹\0úA; ˆƒóêéð®•v 0v+72ðç³ß÷ §klAZdKIÒØr¹j§cÜÂýÄ£§` ¤Áµr¹äÓÏtä_§ˆc™ç´Qú‹Ý—9Žà‘o?"á«€nXãÜhAœà´[uSùI‘3âÑ¿F¬ÁªZ¬üöã(äÇ™\ý‰Î««å+Z¡jíú Æ/´ÌÖÊxšp šþ{¼ª'ü¼JeŽ‚Óè”Æãáþ!îGÿ´qùˆ 'õ÷¶ý3/îÕÒµâI=‘’YΦ§á8ˆ†˜ ¸ÑEÈKï&ß:ÿQ×½ºendstream endobj 5448 0 obj<>/XObject<<>>>>>>endobj 5449 0 obj<>stream x­W]SÛF}çWÜa†¶ðhÂMC›<¤éàN&2Ì"¯ìM¥]u%aÜLþ{Ͻ+ dyhI,íîý8{î¹×ohˆ#šLùœmý<ÛFC¼lù\ÒhH³{§§ø0—u|ˆ{ïS­ M7šÔJyMåR•ø…ë\g*/ÈX<›‚Rsã•_ï²®$$&6Ú–¤ Ri*§tª3¼Â ìŠ]nôœï2Y|«n¼ZSéHÑ«ð°;û²5¤ÁhŒÀz«¥¶úV{9öÂw®Š–ø”­ ¾}÷æ:¢ÙRÃv)‹8Jí­*Í-ÊsïT¼¤ª0v!/?¼ùµŽ M%?St‰¢€OIë»’ —ÆÙˆ7\œ‡Ì ÆSŽ}|D‡ô§½q•ãì+:çlÅðÃKŒ±'.]¦K“iÄŽÍIeÅ>點BB \¸¡†›rg,RèÂyìWYžê~ˆkH'Ñ„sdãh2ÁÓ¼‡ýTT™)uV\ÉÓ^b|Qö‘bI6¼ß¥¯ Ì“ᇗMŸÏÒ _÷q3ÌÂü£iePÄÚ•È@«RYpË¥Ì(ŒfH¹æù`ÑGW¡«tNën%`Ö B™*ã%W ¯R0ýfݤ$_€ê&Yó:X­|iâ*U¾®R¶Ñ;X\³ TxµÂFòÁm±,pyz9qÿJäáyÐ’èkõJ  ÃÏçÌÔðspj™ °‚ðv½Ð¾•)šº ¸lΆ(ƒ—â Jµ]”˶,Z»—…ÉüºUi¥»¦(à€ A|æ Þ³pŠS&C(ÑZ "<ÕÅ.þû’ÖÕn×È庀 D®*£ÜÃFj¯zÛ—RêÛ´ÏëßeCϵÃÎWÂHÕÜyªÖzþ<þÁÑáééé ï²r£Žg܃ZIçžàݺ© 7s4LA TJ¨s&0EØÑonÅ]ZÇ(% ®,ô¥\{\W¦l }…Eô¯‚¸ Õ]T\èaL„Â*œ¢‚htBàZgÚ&è⸂#n!^Ù^qèDsÝÖ¸rÔÐwpâEDç¾Ö ¦éq’/¿/ de®›,¢íP:öHšbÓY¨6#)?R7n½/…ËwŸ9ßEì~Rà€ÑFF€"s' Á¶âXK«wíGÂD¢ˆÛd§Û=Ϭ{9m£ß”R¦ÆuÓsCK”^xÎ ?býºº#Y<´È Ø·*ÓW»]n÷ бw´À°ãU UL\åi©Sð±ä^Ê›rÄ^ã„ Bs]”ÞñHÖLíÅUé`Œ·B§JFô¦çbŒ}}¿…v`—cIS·*ž˜õfŠy1™)lãiShn™Ó«¥Þ8²w·¹—m7f¯˜ QõÈrƃùêÑ1qÑž+¾{.˜µýÑ5-.¨¾´Ÿ n\AÌÙ{ØRó¿2?@Œëlöñýë뜨9Ö oQ˦!@¢ÿÔ|ÄÒF×iºZç/¼<ߊ¨õ1ÈBÁ¾é›Í»ìÎqœ87Šû´ñô¿v©“ú«Îèä0:šÑt:ŽŽÃÌ0˜DCúÅÅMÁ÷g¹2ÑkÂîÁqè¦2ÊOè&ÅœUµUÑ•)—5–O §ÑdŒï7'§#~õz¶õÇÖ¿òF*jendstream endobj 5450 0 obj<>/XObject<<>>>>/Annots 2487 0 R>>endobj 5451 0 obj<>stream xXmsÛÆþ®_±Ã©¦TEBIQ²]ˆÔØu¦µÛHi§z2Gà@žà軃(:ÓÿÞg÷Š ¸z#A,öõÙg÷ôéèœFø>§ÉŒÒòh”Œð ÿ9ç??¾=š^N“MGãdF%]Œ¦xWݲ<¬!xîÚ}ˆ6+÷˜h*DÐI "‰U¦Eç €2}PKM Sq±3TL?xöæñˆâa;ϘÎ1°¯’ º~§GO·M·ØÐÃñ4™òS×ЬsUnÿýî­Ü’hºRî Ö&/à7ó»Žm¡DÏ–Jè5Cå–uÉIâRªõÞÔïóTS‰Ùƒ%«Eÿ£“²½¼Èç»Õ§]Hú ÝG¹-PFÆB3SCÜ%Џ<Õ¬¿Ø¢5"ÛðlÐJ@ÈÊï3.Ût5qËDçêÇFà:^òqÞÍ‚ó‘ϰ٢KbÎoï~|÷þíÎÖ¿úÛ÷ïßÞýUˆì?صaxüüq'g Óerì…©4ÿÚz(óåÑ¢•c2o éüÛj»Ï ¯ç uX}IÇ™8ó’zÎÉá< iy¿‰§™i|E§§˜Eßx`í´?±J Ô|üRíNn>¯z‡·2!—Ïýp°Ý€,¸Ú¹³¥ ~,®Ÿj’#!n®éNлÏû 0 L³Äo`¡hL?€¼ÓY ”ªº\€~lÞ¦@FJÛ<²…°Þ€O0ã U-kæ˜G÷ ¢·,`Y‚ ûû+ ñóGI)æ{oeæóÑýC/þkÜ„?Ìc»tðÂ% «áv_?H,2È„€Ô"MâjÖuàxù8ðÕµêtÕ‹\]•ºMŒàVÀvÑ`mv…3<ÍQ_KÑnâÖ+49£˜~Îdì ïiÜÀ™.4šùDý-f¸c‡€•V먷‰·!ÑŸÐX8?ÈÚÕÖÅc¬×Öñ0À¡…ÉuÁ´âe—‚«5-•[p SpdÞ}½ðqe¢HpShlÙ¼žæNkÑÖ&CPÒRL\ ºŠÇ p§1O°í°•$Œeû‰§ÏÚÙ$zd+ŽÇ§YÍܳ¼‰ÈÎWúœñd>˸4s¬Ä^Ï‹”MÓÚuœáÙ'¹¦Ôϫ̗V«žš4ƒb#nˆÓܤ ÛÃt€X+Áÿú{»t𮄞Là¹~J1OÅïŽLÚK,…ÁÆŠ‘*ÓFv–©ä„†Î*MtÄñÔžV°à„2B¾R&ì~i¡•ƒy9ïdÚ'ço‹š+),/ á9û]E€×’÷ŸÜ< ÞœžbìpPÆ]!©G·Ëó(K-ÖÔy_æ­_Ù Ÿä (STÅYÎÇ 9ìv²‚Ðw繫æ>Æÿ.&4»¼J®Ø]®Õp‚ÿüŦ2»¥ô¬íe‡—ñ|" 5¥ŸvG¾›x¶‘ãb4K&c4&tN^ŒYÁ÷wGÿ<úÀé2(endstream endobj 5452 0 obj<>/XObject<<>>>>>>endobj 5453 0 obj<>stream xµWmsÚFþίظÓV¨Ô„¸ 3$ÆŽ=.´MûA3šC·!Ñ»“œ4“ÿÞ½Ó‹ȵәØéövŸÝ}ö¹óß.8ôÝ…þ@ÿø›ÆëyÃi;ô²ü%n¡sîÀ°Ý‡ùz ^tÛƒÁs˜scåÀÜ·:6œ!žÂš¥Ì[!Û¶°;Íùºá@«K6Üú~ó$DP(Uuásåñ» òÄ#¼”ŠãG·jTop´Ž‚öê(_$h¥cÛc°Æ “+`àfœ#‡ d>½ ÃØg*ˆ#P1¬â›,`Å"¢ÜóVÍI*‘ø ®Œ¨æ°^|R8‚}¢ì—ª'XÇ‹5ÒfËêÒ—â1ˈ°«À§){ÿ+Ø>aFî­Ó ¼§jz5½œüõÛìfë "XÓË7ãëký×›E×1ã®U¸¡ýÇÆ[ D‘"w›T‚Ñ–"\ÖQ ì*‘ ð~róîr6õº^¯jõ¥ÒŸ"B¥Ôœ«éÞ*zp­:#m‡QZõJÕÕ) Ÿªp²5*}YYr¶Ûü6ïct›ûþ‚%¸–ö÷ÊØNÎ&óñ›·“3·¹×8µñ‘ŠŸžŠ$RÁ="®uä'B #d¢XSÊôìèñ˜y¿.$M¤(¤f°Ž'“í6 yMÀ¼aå¬6)+Ä[LÅ"¼s-üƒ%VÓ%Sºû.À3bfèÂí¤¾U{¿ßýù¡ »5šâÝëb®ˆ3Ñ€b)ø 4Âx©9®GÚmÖÀ@5~&FZ¨h3ß4†Co9hvÑîã^æ˜ìÁf5[/’åa͈îùLª—ÙÚȵL`¢h™À$Ä ÑEº)ı®Zïo:.{›¨Â.V xžW¸|okDPÞ5J@çÃXÊà6·a¼`¡–=¤Iñd Z(IžµRÞaD<Hz¸Bà¢ÂI³÷Ž ¯2<9ܡȅ‰rƒDBT‡û›5Ÿ±Zì¾ôWL€½[Ü'q¸ÕBƒ1”Ÿu‰ïuÞè€OlE~ ­o²ŠŽ4ú(>“ ·èÔˆšš”™ÛǦðÁê?Ëüÿ©Ûë~yÅ)¨Ý—ãX3ëPܲEµÛKô¤?OQŸj犧ì”7˜JÁÍïægXZ£¥†½éÃJ›åøßjTŸªŽÖz’–>™&Œi°ÛÄšTõ”ÝÁÙIqftcG ª5<ßwCû˜Ä‘.µÞ%…¹ë™i.’5j~£hû=C³Ö\ìœA¿_Bwøsû¤ƒ!]¼ûtõæÖ»?//Zý¶g±ŸèCÃÜYõ¶VÏɬ[Ï3¯½“ö°=€Ý DÀƒèVŸà ‡?#–¾èA`$»KoÌíô½]û;qí~þ1 ¨ý}ýj2oüÞøt¾endstream endobj 5454 0 obj<>/XObject<<>>>>/Annots 2493 0 R>>endobj 5455 0 obj<>stream x­YkoÛÈýî_q±À6Ö¢Eêí~Êc“õbán×.‚Š9’˜…kU ÿ½çÞQ¤<üÔ&Îû8ç>fD¿ iŒ¿!Mæü/ίÆÁ+üòÇŸ¯¢ù$ˆh:› Êi2ž+÷”Ñ#ï§é$YòFy`Qç1§iÌ:²ÎcNó1ÔÏzÇœ‹ ìÈ¢9û˜,'ÖárÞ>¹`\ð‚ Ü2Š–Ó`Ba¸ ¦x^R©i#qGóÔy)œÖÃpÌÉ'S¢qaÊ©ˆ—å ®Z'ÃÆ¢1ãò¹éêô­9ñ3pëgØZ4eˆ>?]¾µA "À^ËY´¸àÌ#9kø9:û(~1±GÒÕé[F9lÍqæñÓÕ¸“A "@y¡Ñ°ÿgÉYÃÏ™ÄÕGéð{Œ¹ˆ=’®NßÚ0ÊakŽ3Ÿ®Ž‡3Ñ¸Ê „Ë%>}œù$g SÃ(­ÄgÌFì“tu¼œ š>Êak–3ŸŸ®NßÚ P`r®üœy$g /g6®>J‡ßcÌEì‘tuúÖ†Q[sœyütu<œ‰ÆPa`2âÌ#9k\˜Fé$c.b¤«ãåLÐôQ[sœyütuúÖŠ`¸AS–'ŽFßÔû§«ÛOcZâòý´¡hLóUÌç zJPJc|‘yНIþlJ­Ÿ¯×Íf£Ëç·}ûôõjL£;ÙñŸ‹•þsÿéÇþc¬|ûiJloC#D2Š&.’ë§]ZQlM±Šwº¢z§éWõ¢H/iiŠ\5%M™[J‹´NU–þ[Õ©)nH vº Bˆí¨,Ó Ö­…÷ÇZ¿+KudD&VµN¨6´/ÍK Ÿpv‚1ØÇ/÷ŸÉ¬¿ê¸®èÖ;ªö*Öp|Žk§Õ> ‰{§l¼±É×iÓ Æ5™ ¾PTU鲿¸[L@T7*£X¡ð¦¢,ÍS(½0r›òx ¹…ºo•J` XÙ—ºª|u36¼­*×j & hˆyUǪÖ9C.›‚`ßóJý½©ÙÑ¡öÁP®’>U–nwØgõrŸ¥–µŽUSi‰ð ŠyË›ª¦µ+”nú)`þ…ˆ‡ûý­øÍ¨„Ó¢ÿÔqƒ¬œbQíÔ~¯û„¸üW5SœÚWۦ¤–’ã2›rRÿQ@T7’ŸoŠ=7X*-e®3)+[FÀÁ#%ÆíqƒØne²Fˆ=¤YF…©é`Êoľ?СäȪ겉k$¦:JuýbúE—7t4 )› pbàëòÒ’3.)UŸ’ŽQ乪ؔ =u W#5•­2N"Z)ζUýœž½ ¦÷7ªõ,×;b,É iNÁqûiEá/ ÐÅLî’ÿ›\c&­,õq¯sµ¯ú /y–KÞ+]S¹ÚLt—éµ³3á$Fö ݉;í‘èj2°ÌÔ2ȵީ—t3å/ªLMSчÛ?ýD‰BBÕò¡É†‚¯N2{®t!¾ŠÐ&(IKŽíEôO—"•¼¤•(îÊÓ,U¥ œ„UUb&FÄÒÈýFxçrýÔᆧ¯Œ`ûÁâ(FÙÃT@_vi¦¥´ÔZÊ UKhtÔ'ûùV˜†ÜV߈'Œi©-[ŽY´G“ƒ‡Êäç˜Óúx[êþõþ¢é¾€ß WÂóõ¯÷ÏoÂJL #®)0Z îîØòÁ£ÓQ£BŠ ƒŒTíÇäÛø›é·½¦*­m]¾¦‚8¹\㊶Æ$ËÚ˜o›21E@¿7ë,­÷Ž~/9àê̇€îß?ÜÑxNFóÅj¹šÆ®WB¼A³¿Õ’£ô9ÂéËÁOC–9†Nq2Jozعٖ 0Kpù¹áŒ§Ãã^Çé†G3F~Â#ŽÆ-ý–ªbÛÅÀŒÚļÃyR™bôEW™Æ‘pBÃÑ$š-£( wYe‡rš©5ŠÓŸëk[ }¡Ô:W8JD¦ >b ffòyÐ5P/g¶p<¤ñèYÑ)ÆHyoOœè±Ö ã†p V;Ód W,†17Ž}žª§%5Ãã[¡r¾7èû„öª”£ÛNS@£Ñˆ{|x¥2ëZ.uašíŽG.±ªpЩõÅ'8:b>ÁÎH>p|",Ãý_àì––U2*±°û­.t)7>©Ï£}o±ðÀcÅôÑ Ì}É no†Œ1%ãÓ;šeŠ_ô–¤5 G—®-Û¤R©_F°‹mæ*¯·'K´áL~"WvN³.¹#‰ÒÖŽ“à=×l|`4Î}ƒ[$Zg:AóÌ‚ñBÀ0ȤøNÅà w,Ó_ºÛÝZ¼Þu÷•·»õ³¼¶wN¦Òã„—=NN»{N‹>óUºå{d»¥--‹¥#öx[ã¾û[ôykŠŽAÖ<믷ÁãmVÊäïlW}>[á%46õÿqÑF=ä«¿Áã4-^£rk>LNt«ÿ»é6T¿®Øã,3ÅöUEœ}HN² (¼ì1ïbê%ß­Ý~jÏ¿)uNó~I†¦ÆÑ:Á×õÝ+†Ô_„_¥Í&3-ì·OÿåÃ!˜à7.ll²š²æÏOW¿ú/y˜ ¡endstream endobj 5456 0 obj<>/XObject<<>>>>>>endobj 5457 0 obj<>stream x­XÛrÛÈ}×WôSB{%ˆwRÉÓ®ÖÞ•ËvœXÙMU”ÚC28ƒàBš•Ê¿çtÏ$¨Ö±]9ƒ¾œ¾œnèß#âïˆ&sþo/†Ñ'íÅ#¡Åÿn¢)¾/©Ð´æGi¾G7r4^4ç£Ñ2šoŽgªœˆ³²¼‰&G#ýÊÆÃE4 š9•éjs2ÎÎt ‡[0ýÚÆÓ›h´s*ÓÕÖ T.¦3oùYÌ7G‰`Ì\º(=þ€2ïqàæT¦«­e¿6³€S™@ÌDâ ¨D5å²õ,f›£Ä™ª~”þ& Ì{¸9• ÆLÐtQökó1 Ø9•éjëʳ›Q´öfèæ(Ž™øÕEéð‡”9C7§2]mý(ûµ¹˜…ìœÊ<™“8*˜OÁ]Ì çu6 Ü%ÎTõ£ô7eÞãÀÍ©L(fMe¿6³€S™®¶^ r1YD³pÌ7G‰pÌį.J? Ì{¸9•éjëGÙ¯ÍÇ,`çT¦³î/®ßNi4¤û5¢ÙdIóå2šÎÇtŸ \C ÚûxP›2}4:¡ÌšÇW÷OCºñ#ƒØš²¢Î=ýŸl×s~ªƒêÙ¥ËgOÍᕸ7ÐÕx ­@Ÿ1–“»ÿ‡¡®çK/ÂûÏ1>©Š¶ªÚD?¤w¦Òºà@t0ÛÕ“Ž+>¡^gVÉå™}9 mŸïØhOC&[¯2H¡»9Jt¬Cfâ*èu× ýó_|Ö©ÏU‘º¢êè/ÛcèÇ®¶¡än¤BQ<m¥©Ú¨Š>ÿz÷í •—ø®é–ØÀõ[,‚RÓöÄ5e> êkR%)â[Wºˆè“M‘´§&!UêP’]Ci Í"€…’ åè;ˈîaǫ̈ë>•öüÖ HP=“"–<´ð@‘+i7‘mØÛ=þ„1ÜR$Æq¶‰‘ô%ÔEåÅÆšÐçôku ÕH(ˆ‰¥·‡îÜFÅ &•ªlBóËY¶¶ê@Å»%î­‚ ›ÁßÊKÊ¢®Ðiv… =ðâ„ ¦ñÄ·wC)}@yïSPÒª»e—‡²Ò[HåÚ$ÚT—¢~°¸×3uY0a°.BÏýݤ_éý'¸ít”ô /T—MåzD¥›ÀŽnˇWÎsvØšN¥~Hã–v]5¡ø55‰Ý7üí½oãÅ–ïÞCíà©BBÇ!ˆÅ¥ó¿µÌû“Î|+r|±ßªº²x;¸´ëÂVWÕÈb_2Ãyy3‹5K¾Ô"O‚}‘âÌbI¥¢ÆbkèpÈæ›4¤|ƒ\Ú,Á[ÔnNñ~›³z©ÆŽ1)¸¸;':á¬cuDˆ<:¡ª±i¤¥¶·>/XObject<<>>>>>>endobj 5459 0 obj<>stream xÅWÛN#G}ç+J$£ÅãØ(Š6$$ìC¤d-¡H~ifÚžÞôtÏÎô˜µ¢ü{NuOû26û²ØS]]—sN•?hˆïM¦ü“G?ÎŽ†Éon~UKÜÝÐhL³l§××4Ëüó!ÍÒÞø2¹I.è!ŽTM‚ܺ”…(8›}<Ü]Ðf|°?¾€Ý,뽋&lo¬Ë•YRa+I.R›IZJ#+á”5T5Ú? 8'Ò\fä,LëR¦j¡Rº¥L8Áw'tg+’ŸEQjyÎf©5+Yá´qr)«š#C<œQÖ[T¶ ÷b…À-ÝžÓÚ6T¨eî(“ eä6#Òê/ŽCÕoCnCºN&œÜ˜³'“ ^e½ÓÂfqB{løY[yO™ùGDÇp¼ÑɈ¾§eÊÆ}×yTV8°˜÷Žÿ©T+õj³¢·tšÍçæøœ]ÌÏöÏþ³çéTÍ©îß-?;Yy‡´©ãdŒ\¢+Ùuzê½n{Ü÷u˜$Óéç: @&ÐZ¡ŸÄÿÖµM•pýI¹œj[Èm·Ó‘]t!нñ•§TÔÜÔ\Ò±2ÇTH—ÛŒ*¹@_¹ƒxSõí ½¯Fp뫊x–M!ón·oÞ$4ƒÇˆ bƒ;ðÂC—ËÞ‰`î1r9†Í Üü”«4÷ï¶=F†ZÓ#r/K­d.©›ðŠn;qóðÚÔÚ³+¡YïäÏÜdšâQVœ’g€Ð´•ZÖT¢"…›Ç5,;¹œt3áæð¥!º®õ¨k¯ñ\ç‡"•—æVgˆk Ò6Ý ŒƒåÊt#:¬îó¡øÞ½êå„2¡-žÎÜ›€”÷¿Ýw/ýxx+Àî¡ ±¤Mmìë!—í³–Óœ}j‹Ri”®XŠü¥úç¤Ün¾o¨¨Q­íÓ¤ãúv²HlãÏumæ½öÊ$Pr:?kiø"ï„8œð ‰(|]³ž”il°—¦«ñp¿ü¾GŠn¥AD. `- ¼pƒ6M›ª’&d0î_ã]$\BB§¹Ä;K™ïï鵿‰‚g¶äù!tLÃ+B)*ÙJ þîM‹×kô•º¾#œßVãÛIóM4>ö|+˱á~ˆ£ëÖhÈÐîÐÞª/ï @Kê`Rù„1lûW¡Ó¯~$ºN“ÉŸ‡‰ÉŸ°?ÏŽ~?ú­±Hendstream endobj 5460 0 obj<>/XObject<<>>>>/Annots 2499 0 R>>endobj 5461 0 obj<>stream xÅYÙnÛF}÷W ‘‹‘D‰²Zô¥N“:ÚÈ‹_rdÑå¢p±bý÷ž{g†äÐÃÄYŒ"›93w9ç.³äÃÉ\Ìðk.ü€~GÙÉÌ›a¤ý«¼¡±\®¼@+o‰Ï QJ±£•béϼÍWf L³S.U ‡k¦'2P6fžÇ—Ïç\˜©ÂØûÌÄrF;/lñ³%Ûm‚s1«Tƒfëo—ÛZÆýå‡"…Ý1Ñ ‘Ï|$5¶WFîSð#ï>ÁÊzзs#.ÓðrÐàŽñv¹8£xË0znÇD'0ÐôëöäÅ«%Zlw8ãüÃëšÂ6šlï2 •ˆÂ\„iUˆ÷RÄr—ä2»¢7eÑ`ºØ‰¨È+5ur'EXÞ4™Ìëʯ°H~ ³C*:ÛÞÂRTÃÜb&¦‹…çûøŠ'?ÔÊÖõ$ɯÏÄõ$Ú‡¥ø±ªËs‘äµH% ÿC: GÇÏó¬ïÖŸPi‹Š&¯µ²è\¸”²PÇ”ýò½ X“’w{ è"kÒ:™`B;+’ÊÐq.ê}98ÀWz ï+±ó8aaEU’ߤR¼ ïBqË0“µ,=±ÝCU˜¦Å±"EÖ‚\Ø5yT'E.jæ¿© +Mþ–X¡ëI^ÔI$ž8²`ê¦ÞwÊÉÉ"KêZÆ×gŸ3&~1ó4{Ïä³óÓß%¼ïŠ2O¯Ï4ih˜pq‡@R0qþU¤á'ÚAÚô¡TA€]\¾¸|þœ ÒBAtV„¹ é£Fü[« Gwa’†ïA!„‰rf2+âCI¥MLÄHD>ˈ3“ÂiR,áÙ,¤Ì2—¦0HŠý±B7Ù{YRž‡qœÐÚ0íÄû$Ú³T.#YUayÏÕÑP°ÅÛwW¯Å1AHÈU¶!²¢ªE’в‘¥Ð —+ B¡Ò¡oËC–Ž2¨ƒ‹­ ù¿soå_ˆi þ%"^ÒKa ä1üRVQ™•ƒ©^5Å9w¶hímž Åßüq%.™ Ô;ŒCYÜ%:h!Ч?a¥p‹]Yd òZ(MÝ&F4t=a´(ý¨ˆ%—{ë޽Æ+ÒØó‹’2žpf ¥e™É8¡ °áoq’ªvàeRÏ#ãÔ—¬‚­ Ë ‚¥a¥ØbŸÐ^è­ˆºšä.D×]q°QšìÈÕAFÉ.áœ&óÓÖ>-¨é§¹Å¯>¼¿µÖ6lFèQÁú²ð0@võ»#ÔFþâ?ÛÌBw„èlNLuQê'úW„‰ÌõT|"@ÆtÛtøîpõù¿¢xóÕ "¼˜âŠƒøÕNÜ ß’%®Ð¨j|ãN}ì]Ä õZ‚—ä8Þ5šÏ@”Ÿç,~LpzÌqGåßc-^› C qeGö¦©ºÊë+u¦HÓwPŠÎ‹Wúz¼ W\%<éͼVĺªOéÍ^¿`án§.ÅxàP«§kõöôÕO«Yàùøÿ;²çoÖäÓoÛ“?Oþ ÿÞendstream endobj 5462 0 obj<>/XObject<<>>>>/Annots 2506 0 R>>endobj 5463 0 obj<>stream x•Xkoã¶ýž_10ºNê(¶åG|ý°Mw[}èý``!Ë´M¯$ª”7(ö¿÷Ìz9ɶ7 Q$ggÎ<è?.&4Æï„ÂÿÅéÅ8ã Løã×÷áò6˜ÑücJi†Í(¡ß.ºcÌΗXåÖòì2 VØÂ/SšLÆAèG<Ùcv6 &ÝÙγ‹°?Ûcöˆ»{;cÌ®€ìPˆÞÎ8¥édÒŸNƒ[`uÇ,æÁÂdog ÉËi0ïÎvÆ<^A²“Ä{»cÌâ|«Î,´¢å\,µjžy_;‚F˜â– œvˆ¹9#2×Ù³`ÚÎM'!ŽåµMgÍ@`¶C ¼á ÌÎs«ÛZˆìk‡)…óEggˆ¹å*X¶2¿½ïN˜g÷tó–Óýì\¬ð°Râ!–¹J£¼ È*Ò .ï7ïÀXÙ0=¦ëé À†÷Eƒc¦#üã­NÓàX¸A#ñVE%É#m”©-•f¯Êƒ²x &Š0¤ïq~uws÷õׂ‡päàzƒ#ëlP£ôX&SÆRL•låpqlÒ<Ê4”lqÖÛ¥³OÌ‘èOê¤å„40UÙHíìé¾èÃ{H= '«ËRe#Ö¹³JEvï-‚§®0 À¸$Sb ÆíwSTÀW)¬ƒ0Íû V‹ª¤ì˽ç^tˆ7<:>ˆ2Ñc”µšø®Yo`Å¥N¡×ªD¥*5–Ñ&&ŽJgSvT×"®‡ †UûJŽä$ª,è!J*‰wU—Úd”G6‚ve ›Y“GEátZµSVe ,61Kú\üÑ”L ¨uÁáü¶8ÀÚŽ_?~p¬:(Тä,Lâ*ØÇ/­Š’. 9ˆ8VxÎä¹)44nµUÔ;¾=óxĹh¯ñûÄÐ; Uýr…Ì1ÌLv[êRƒ3BŸþÊ:Ç Ý¡9$p¨ð^(¸DcU‘›¬ÐD(Ÿ?ŽŠ’sÅF•'¥œ]´æFgðŸÄ[`1£.n7K%&;OQ‚VXÄ™­ ÌPnl±Îbbµ=¨–8}ø4ˆ¯Žßí9¯ ~(H!ÖD†2úÌÈ ¿ýþá=«JMQ"-ÕêF´©#á¡O…÷~”è¨àÛ*QAÖÃQT)ö8b£"ŸÈ"*JÄ Þ€-NF‰|*ÀÒª(ýˆHŽý-¨íéí“V}6¿Ç@¸]%µ•â ó4ðvzb´±Ù**2çªô©?ÒBù*ƒ> ¡ûgcŸÂÿåó±ÇnѶ M9ãOƒ0Äh;$ü ÛZœìum®SíÄ–¾¡ñÓiø†4Oý9™†³zòývÞ¶æ\nËõ¥~ͪn®È|®nž(ãÕW~ùÕúò?Ø€ÕÞwg'sÛÛêz-‡Bý_,Y9J J«NÀa÷è¥ {ãÉ0jØÇÄD¤À˜û8¦0gžmЩ$Ú ^HzVŠ´ÇRT›#ÒSKx)\r–åž%‚°6…”>O­`…޹Ðò’/úðµu=ÔÙúŒµU\"¿º¢WÕ×}5ñöî¬d³¥³¼*Åöl :r€ƒ« îå¥}Îu¯>?QÐâAâl}AÀó€Ø÷‹,,ÈV\'¿Ú‘ƒ!ˆ¸gÈôê³s9]s7åÙÜJÿ+‚Ï5aŸ¬`«}y…;Öá¡-ÆÞ­/Eî‹ÜtGâöåê,Æ]•÷´g:õ©ÿåhæ4øö?ÿôë½÷ŠÐÝ›~ûQý¥y¢ðîc Ïo³º:ªìaDÇ8A…æESóqøþÛç—#º™ ¤‰’áGpᜎ~uãì1»¦KgêK‡¹úâ.qÖ3ÂëDµ>½]_² Î7s0É‹sŒèãù¬‡Ù²ZèÁ¬;¼>çg°á“à^_Ö®bž\Èà5i[ù²\ä7¢ÜÃ3ªÊÊftôӽؕH~‘¼èšM%7–JŠ('I´¸xi‘¸žéDÙ‘¬rÜ ¸ƒnk"SŸ“Õu^e|u¨kãI'‰K÷œ½t\^÷™/÷#>¹¤ÉSd3–„$Œ _4JùÏÒäR¡ÔKùþNÊ>Ú>fQªc´ [tb„gÒ&E[«K4 Ò%8¼g‘ÚïhïÉuÛ/µ|¯2ÅåC:i_êvT.M[” Œ5©”Ÿä¥ÕæÜð¯ïŒ‰ÞX´5¸rƉÚëbMÍy!UJ‹íC¾Aá–ô;mé·¥õÎÝžž1!½Øœ‹mðt¾1_‚`B\έlÝsò]Cz¬Þ!YI V(·oŸ…ÅèÞJ"†/““èB|¤Ð‡ùÜ‹¯U¹‘šópŽNuÁ%†}xâ‹ïL\±-#¾1t'nåõÒ…ít¬ð˽+Ùð/NíïÅ; |aü  żóñ"§HuЮnYøÛû‹_.þKž…Çendstream endobj 5464 0 obj<>/XObject<<>>>>/Annots 2516 0 R>>endobj 5465 0 obj<>stream xµškoÜÆ†¿ëW ’‹Z’{ ЊjJ]¥µÖ-‚¸0(ʒÜð"Y(òßs.ÃÛðŒãÄ)âÈ&ç=—yæÌpW?ùjÿù*œãŸ8=šx¸Óþ(îñB-&øÓŸ„Þ ®—ªÐj‹ªùrê­è–?kîû“À[ˆ–n„%ÅCŒ—pn$É‹[-—àò·"ð‡r<ˆ=Íæ^Х㖠VS/õÇXj4†ý„A?!·Z̽©ì§ÁPǰŸy3ÒN[-\.¼¹è§?ÆR£1Ý õ ç–›¡ƒ‘þœ¡žœ2L3Ì1\Y¼ –n„È£cbxÔÌd –þKî„0¾‚œ!D²ôÆH¼qFCBÜjf¶%?ÌY†jŸ „éÔÌdK–Þ‰·n†z€¸å o’#Fž,olúÛdîâM°ot_æ­uÏ-³ßß5ƒŽ`1¼±'©¿ÍÉ“E³#ÈB$KoŒ¥æ$Ä­fØ‘ü°YDÞ(‹fGP3€H–ÞKÍ ˆ[Îð&9b9²H¼±aÌÛl6ƒ½ûÛÌö7É‚¼ñ}™·Öýˆ7Iy“,Ì›ñ$òFž,BˆIŽ -½1–š“·ó&ú!5¶ˆ¼Q>!ÄŽ¤Æ€ˆ–ÞKÍ ˆ[Žy‘[ÞŒAà-XÂQy o‚…x£û"oû1o‚šáM°ÞØ“Ä{²av9Cˆdé±Ôœ„¸Õ o’V#‹ÄçcÂìjÉÒc©¹qËÞ$G,G‰76Œy›.WæÂ>¿Iäï˼µîG¼IjÌ›daÞŒ'‘7òdBìHrLˆhé±Ôœ„¸Õ˜7Ñ©±Eäò±!v$5D´ôÆXjn@ÜrÌ›èˆäØ"ðf o¿²Úým*Xˆ7º/òÖ¹ó&¨Þ‹á=I¼±'‹fG3„H–ÞKÍIˆ[Íð&ùa5²H¼q>`½ŸJÓ`üô#°ÔÜ€¸å o’#–#‹ÄÞ|^á¥óÛT°ot_æ­u?æMP3¼ Ã{y#O!ÌŽ g‘,½1–š“·š™mÉ«‘EäòcÞ5ˆdáþFKÍ ˆ[Îð&9b9²H¼±aÌ[Ÿ¿…âùM² o|_æ­u?âMRcÞ$ óf<‰¼‘'‹bG’cBDKoŒ¥æ$ĭƼ‰~H-"o”E±#©1 ¢¥7ÆRsâ–cÞDG$Ç7cxƒqþ(Æ>¿…‚…x£û"oû1o‚šáM°ÞØ“Ä{²av9Cˆdé±Ôœ„¸Õ o’V#‹ÄçcÂìjÉÒc©¹qËÞ$G,G–1oæ¿vxûš¾Xføùnªæ!|vÎ{u{À'ÊSLðÑTó™ç›+´NçÓžuº˜Ã»-?KÖÞu Ÿ¯à—Yõáí„t—ÐTù†“%§ìgme®ÈÚ»Ná[KÏ’µwªéd !±…°úÊ÷ñݬàÂ\‘µw㱂ŸE+<ÁÃÁë òö邜v—©‚D[[ï2U>œŠƒž1\-ázfÂ!Øé‚ců[Û¿ÓèlÝ%Šß µ6Œæ à/ú7 ¶Wä *ÞZ¾]_Í .µÞ*ß›…ø5ÏÒƒ³¢Zo`·›'ëøôR­ŸúÅúáÀ|‰_f­7§x3të@ÃÂûWÉž†Ø¦SøÐïý=É6ø ,2À’ï}=F­òÜ÷üœèH Îâ*É3p~…ÇøÎp=ÌÀùY/æøä¡HÒ¤Jµ:äIVé¢T;:›¨3Ó8-ôV:‹uÙÏ€†_ßüóÝzÅy•^‚¦~Iv¨+¼iÒ Jã.*“-­[T!&3‰Á\ì÷ùS©£}­KUåêN«ºÔµÍ u9Øš*ÀcÑOIvߥÏžÜDU¤(6ïÿ õý»õï«T^W¿¯T**Šèù· ¶ÓûzJª]’ÁDŠ@ãGUm UTEŽÛ.ãâOã ‰`kn׋È¡ÕòÖR5ª+3þ Ç… ¦c¿°°ÝjsVvœ ¬T%Ö¾â6뻬 0uOݽ¦Q­~¬³,Jõæ¿]}áÀŽ™–Õæ¬èÏ­0=wÛb–3Ý}WÂ÷ó°pÁÃ7ß° ñ€«µÊaÓ ±Š“.^*ߪ®¯µm¤I–Rr'Ë ·þ¡l¹Mµ‘ rè¢Âl¦6ÌA·kêÓÔäÒÀhŠÓQCÕa§vuÚ^/ÇÔå9T¿Ž«ò¼Î`ãtz³B.þ}ñáâíÛ‹n¿¿º|sq{ûê3èbH£¸ 9ãÅ ¿ˆ€ð|q=i’c?ùÇge2À`šâј?¡x!üZo”mJgu:¨ÕTæÕÍ»P]š"õK‹`–Zõ#-Î&KÚÿH–êý)òVge´Õ͆߶È2I{Myª§‚Wãp¦á^‘Gñvà<Û?¿a1×õŸxê/8z°ü¾ýaýŠnR7mæ1*’¼þŒS•ôî¹ÒƒrÐ]Zhâ…¢’RÅyö¨‹ ŽVG¡Øhf(»îtÔîVý8üÛõÛë›×¼>+ 3fGo+=ÚŒè9nrƒÜx ÚS}óîÍtßêÁù-M²síx½„ž–OS­ØYo;¿‚wX?t^\y¾¿‚sàŒŽ¶°šƒ™·‚j¶]U WW|ZëΛV€¯90l½ƒ$8ÿÕV?©h³SgžE{5VQÕ.ªà‡f7i¾©Dz>ò¢* 5’6Âj›e…M†À~SŽcOª]'Å“.?˜`pG-:N¶ Öp %±&HÜ q½ TU”dÈ?ÕÛ)€Í,Í!Ï8OÓH•ú4¦IÑn‡ÙÓÇÚrBxàe£ÀÉ`ÿ 桱˜9À;ô¾ Þ±¡õ ëj ʈÀª–‡6¬Ã W}SoÊ\ÃfÈ(ǥʫ´T»^¬IvÊ®¯˜IáB7Y<|™VÖÕ£‘Ì.ÿ\:PƒÍ»¬›©27ËÕ¦>ì“úQ£è©[Cµ •›è¦‡þáÑ`ˆUË-½m]€\-+º×ã‰lp1%‚ !]>ÉòÃ}|8ôú¶zÚ%P^³ZaVp'§ý €5OÑzÅÆØ®1À>¥ö¦î£âBÔ4Î÷{^´>t†Û‚ÂHhþÌ m¯mÞR–Ðh“ì¸!AH9y©NyYAª° O(m왽ÔKj>€n”9âÞd íц»¼/Ñ–5È 'i±9òzçfEí°f ¬aÀ †×Û#ÛíŽ-îIƒEh"øjºç8ˆ©kÝCánUw[o;·a±JKƒôÈìþ“H€"6Ó>ˆ|üL ø&Ep6…h><Áà!HøSæ€R’B?È´Æ}çi§y[àš7 #.`†§"Ué>УÁáa9ºƒs/PŸÈª3~~ÌÂA÷î)œéfj¾€O¦çtH»ýÏõë3ü=è¿åqBæQó"ì¾üôÙGÎ1p¿˜šÏ3ÃÕ ¿ZýëèWSUá endstream endobj 5466 0 obj<>/XObject<<>>>>/Annots 2522 0 R>>endobj 5467 0 obj<>stream xÕXmOÜFþί!œä0÷ÎA?%)D¤ˆ¤ÉEm%¤ÓbïÝÎ/YÛ—¨ÿ½ÏÌÚ¾³/@ÕJ•*òzwggžyö™1_w:ÔÆO‡zCþõÂ¶ÛÆþÓá?ŸÞíôGCwDÃAÏmSHƒöÀ=*F úÌëiØÇZÌõÜn1à©Þ¨ñà¸íy²Ûq‹ÏnŽ1;êá»–g;Ã#w@ƒÎHövŽlIF2»1©Û“½ëÙ><ìwŠcùT;S×ÃŽº°ºž{3Þˆ^ 03:<ëS§Mã)`ãÁtðà9—q¦)›«Œ–sáIÓ~bô>Åqší“Ê2\ç™NIMi¢½`hŸTäË•¦±¨ ¯²U¢)H)O1"RäÅQš™ÜËbÓªi®‰6/Æ7;m:ètá—3Í#/ âˆmÌt¤ [ui<Ç¿‘ötš*³"•ÊÑïÕ¢ÄÄ÷«ÍƒhiTÓª[öš<µXPã)Í“$6YmužÑŒ;rx6, r`?Hí»5|…›lÏ¥óˆä|€öô^Ç:æiF× ¹¦i`0H3Äê(c¼øõbtû+û-–æ©Ø´HX0©°†j™¨Æ˜fZùL|öûËs±Ù"¥¹a\øµ¥„û’\Žé½ÖÓ|ØÜÆ9 •¯ÅeÌa¨H\©_IÒùa×¼ •Iç0Cë[J;¤ïU˜,ÀÁy¼dßįVETðq?™yI©Þ .SQˆå²éócb¾ñ…8è™xÝ{Œ+'ù†«Ý)¨ë…ÞfA·ïöy'ù‹|e|úüÛù;{;6÷ÊKƒ›"@Æ—ƒ–è…|㾄*L)ù:õpÑìÅaTë(ˆ–1pãr{9Gñ©/® kñ‰2W^±C 4R”ÁÙëØ%×–œx¶^DIž5W5Íæ‹æ*Ò™'È3Þrvû9p&Ì•©^’òý€#Š[™8±Çu*=+ÌíÝbo%âÔ×}¬ÄET¤i’–±¹MiÜZ*Ç@Þ<}s³0C°^ÿá‰46‘yÄE‡oJ„ ‰ajníL˜(õ°P†‘€~€˜/"¯¨Â8ˆñ¨XÆ è³àb匃(ÓÆµÜeÕ„tGÀ>m׬ÚH n•˜B‚¬R»ì”ˆ¼÷X<ê]ˆ5§J|sé W¢ å6çžÍèd¡¢:”Ý!cWŽ:"—/±P\霜TÏÝ““_øÊÙ=]Yƒíý”¼-ÕΤzìNÄÔ¤a«hY›õGÔÌS$¹v™CEÃÊ*Ä–húFÌ"´XìPûwÁÒ®q(h­¥ DcŒ¶«› à‹¸ÐÒOƒûIõ*¿¼ÿu¿tŒFn#ÒÊ ‚©‰Cq§Ì»ƒ¯ ¹ì~ ¨ÞÅÏß 2Ȩ°ÁáÒ©íîŠߦ‘Ûã­ _º]·×ÃÈwžñZ´LWŽ7×ÞíÕ F„^Ò³ï¶h£Íá/‡˜µWŽ6&6Xô½Ä½˜$)y.I㹉—§÷žN¸ë¸rntt×ZOŸG¾¾ÿg¦o⥶ZÙ¢Ýׯ¨é…íßå¬Ý«?mU„¹Ç87gÿ¬­~&ÃõÛDßs‡Ã#ŽjCP´ McÀ_7%øÒ^Z¼Á {z‹äxLá[Èòœ»(2ÑÙã ³~žþþñç±5 Þ½}}q!ÍÄä& ¦€ÍuÝâüDþÛDPÉÚfˆêy B<µÌ<ži—z ‹òºÐ³‘ÍÏÊË/öÝ ßû&¾¾Ñ^ÆëŽ7Gý1/«hã2HÙ]·ÁBùÊç’²/ñ¯ r)ï• QoÖ;·>1¸ ˆCow¹w ¢Ýµì‰õí£Duk»â<[os×î•ÿR_0Ývßô4<ÙOJÎþÿŸêçæ×¢·kެÄ=ùÍ:hÝ^¹PŽ~»Í€œŽw~Ýù U¹.endstream endobj 5468 0 obj<>/XObject<<>>>>/Annots 2525 0 R>>endobj 5469 0 obj<>stream xÍWMsÛ6½ûWìx쉔H´>,En§=Ô©SçÐikuzÑ"!  0$hÙÉä¿÷-À‘QÜ´§ÚY$Å~¼}ûøádL#üŽi:ç¿09#Üá1üñöd2›sšŒ¯‚%4Ỹ«ò*¦»“Ã넦“Q0;xzx§óq0=x:-`y<9ËãK¶ì¯ØòáuBãÅepyðô§å«ÎßlK7X2¢å1ͯð%r¡àKØZÄfkŠœ¬¡3Ze4)Mçò1”)_tkIå”É4¡ŒhýDv')qÌ›ø»V=HJ¤Ý™ˆ·óM¥­Ì)‘=Ñ»_o)ŒEžtföZf0Ù_ÞŸŒh8žÀ£Þ¡y©°?#~~qƒ”;ß{6+¤¿U…Ó#µ¡s-÷f}/CK;‘ÓZJME.£¶²W¹ìZÚˆ8ïš‚_÷âA(.ÜVb8œ3ÿ(Oe¨DL"SbKNO+#©JE&„¤ñ?(—O.9î_d†Tå$4ÉG‘¤±ü®Š{X häh2 ¦S\E½sû”ÊD¤«žwwÕ§kÎ+ºÁVÚëßl¶ê5á¬ú§•‡\üc& «­FqóÉ,6›ŸÛj [ÿ’>µ!üdÒ™&ÈûÈNiÅÀ”(Xõ¿ïìú\^#jvUéXiIç_wh*cÿÁç®%*¾¤µ@>|–Â8P'Ú"ß!ŒOGÜ…{Ô±{îlZjèÊ.˜¿f‡—@ÊVßÂ"›ifŸ(4‘+1P¤Ÿ/nZ¬cRnÑOaé~×y´ðí<î¤îËt—ˆBó™"Hƪ?@_rNØä€\kt«ò|ÈÁ `š.½æœnz€¢U¿s"3ª(«æ—g";Î-·-žB»3C1“Š(RzëørcâØìùJX¾ÁŽÔ®®åViÍ͆L‘}#Y4ÜØÔ¿¬w»ã]ù]}#´¨C£sÐrh1>ù€ÌPm'þ8…ë”`«,”-ã(­³Ûup·<ŽnóŽ(°1mLF‘„S橲xýêU+•‰L &XÈà\”÷(¾îº‹œuŽû¿·/Ïȯt︜£Â:ódÓŽ³†Ýr‡üvG°—¢+œdð£Úï†hñ“º$°¶Í!Í3™ëÉT¢î gMût†#CȳºŸ‡<î¾ÃT.o{• q-¤4ŸRûË&Ny0:;‰‰ÔFÉ,?¥rjR΂ýµÍSÜ-“9ÄŒ†r }&Òˆ€ŽpÇ€‹˜ 4°…ÀTµ÷Bê"qZžXÛCθàœMù¡P"–Ú¼+ ì[2¾¸uªS 7Uõ©× g2ËL†9 >tÊ„¿rà,Ëg¥"|/¶2¶Ã¢u¶–; qÔ-/…$)³ëüŽTye2TÜ‹¨¸;éeUGCnöޔ˽å &YµÍe¨–Ò•>í•]k…Šó¯Æ‹bqGµDò8e`x Nƒ ¸Ä.pàñk-6Ïç Ì–:‹‡Ç‡&IP '`Œ×Ò~ã—ÅT‰C"ËC¿¤š‹ÿ.–äö­ä'ý™À wä DŽÃ8 /μûP /XÅj’ð¤e®¼ª}Öfj]X§jš,–ºŸ8‚Š2£äÁ„×…öº %ð΃÷~eN欬&³à*XвD ÃÌtB×î®#M’ª³Ä8Vh&á%˜q/"ÈENI‘[ßôÊZ¼4€+6ãÚ"O_ç§RË­%“*Œ=a\3¿Á‹€nð¥”pί©ª“˜1d Nuj\éø}JЦÐþ=¬ºëg,^¯’51ÒV>/XObject<<>>>>>>endobj 5471 0 obj<>stream xÍXïoÛ6ýž¿â``˜ƒÚ²c'nÓ!V·Zô×PÅ-Ñ63IÔDÚŽû×ï)Ê–¯-°E‹ ±èãÝ»÷ÞúÏÙ ñç‚Æþgg/fgÃhˆë劷Czi¶¤Ñ&×Ñdò”f‰;5¤YÜun,ÝÅ©0†ðó˺¡;™oû¿Þª<™òçónçNlÅ ùjðÉ–*_uæç¿œÏîη—t@Kêã‚þh\]Ði’¹X¤’ì¾™( YM I#Zê’¤²kYÒ”ðïé“'ë¬P©°Jç=d¤%½¤7ÓßÞ¾½§LÄ¥6´[‰ 2§D.UŽH*ç4põÅuuߪÅÀåÊ?ÖR$‘Ù­z´ÃM’îI!‹µ¤|“-p5‹rµÉdn ¹GœÉV–Yðs>ýæýkŠEšF4Ãob¡‘CøÌÐNoÒ95ÒØ•ÊZd‰ "@©úh¬•ñÀw¦?Eã1ú”<Þ‡Âż[·¤çzÔ£ïoÌ{m9 a]mŸ>¿þŠR¥Ž¥1Ü–ûBä‰ÃÉH€®1¢À‘¢Tß®[P!о| ›Çiê0k>þ ˜dÆ0½=÷SlRK¸ÛÝçРð%ô4›ø'ØÑ9Wˆ”! ¾*I>£×KÚë %šrm9 B‰;ñ´D °q4µ`†´|¡í%sbœîÊýéšØ±àDÕ&NÃã"åe·S 1œ<[®‰ ¾„æû£ ódt]G×ô<¯ò®tæÏYòùËè’¿ñNCéà4ƒô3t) Z•\ÃJæ²tBäãÓë ñ­¿çE3ÈÐRÇèT¦{'r„k Ý ]'Ñ«TzâF0í~ÏfdŒ4žÈ•v%HÙ†賤e©3üR§©Þ96„Âæ]®¦b–™ŸWPÂ6c9h˜Ÿª’æ]v…0r~ÞDÑy›‘ŸÒ¼+ï™5ˆéªôup¾ÏAÏÂÖtnÔ~¬<6"Ÿ&‰8– H¿3¤×…*S;ü6Û%aáÀ‹ t(œŠâ"¥e*V}f~²y‚Ç‹N”¥JSªÂ `_e©@t‘ï™Ñ|k¿6PW_@ØÙD¦Vk{ä¼…(aáARlfîZ6V°™L!cµTàv¥cP‚iÁ :ŽÜó2”AóªH›$Q9ìZY‘Çhº(sn*.PÆl‘=é+×Xò©U®KÎo†Þ‡ÏEjôi ‘y‚ ·2iv½‰u£—ß;ãâBèHYF¦ºØóXÔ@U}t²ÜaP2^Xij??¾r%º&£v_n@ØøJm6ö†,ƒ8úüžÚ÷Ó@™¾U‰ÿÞ¡]þ¹QnH6’XH»ãaü fh¿·§£Pàšâw0ÿap¬®ßîE^kh» Jbq Šè¥™Ž` [¡rƒ1nKn>¶»r[]¢½™Ìt¹'½ƒ½›µ*ø±-uÊxÚ Ìw¬l×j”Ù©ÕôÌ>ìܾuäG½v‡ÜѶlaìêB­À²Ó‡ëæeÒ®5ê¶ñ÷´è¯Š ÿ[«‚Hƒz}Ÿ"ú$0àÂn ãFw‚ãôíúy­®á\þÁm[¿µH—G¦¶ÚC¨ õaX¹sT ¹Zü¼ ‹ì£Sl©Š=Ã*©žÔïL§3¨'<x¬  ˜? lÛ~µüÏéÉo0G/©2‘žãLp¦KŽ®Üt™J+1ÿü‡57¡J³Ïãu©sõE&•ih}À0D‡uIöÙÛDö÷Í»m,ºUÐTÓ‚ØëÕë¡‹Ê{^ p›ÆÒ±[«xíç°pvÞ¤’ïõó°î¸íÛ¸yrTÁ¼‹2–¥„ħ¬zØV¶–Rbg0í¢NhÙ}£%äÓá6„°øÜõ¾ñÒŠôU$¹ÁžOùR­6¥{Íä"À±Ã‚—ŠGÚt HS4G³Þ¯þ :¸QPœÛiÜN=¤°UxÙ{ÈŒOßÛÄá¤âB?ƒÍŠïý(0ÇFêë<â¡Á0ñÒ`Î?¶·Ï*?»xv]¯h2™ø÷3ÞTúãhH/uìþS½‚q¿@¶ÿ”½ð+/WÃI4áM/‡#ðjvöÇÙ¿½Â endstream endobj 5472 0 obj<>/XObject<<>>>>>>endobj 5473 0 obj<>stream xíWÛnã6}÷W P€Xñ%ö&éS·ÍÛ‡íÍ@QÔAAK”Í­Dª$eÇ[ôß;Ëd¹q }ÜÍ"ˆ©ÑðpæœÃñƒ Œñg³ýϪÁÛå`œŽq±ý¥7pýî&cX0ÃâÿÊ]þ‘%”å`·Ìâ/—˃ëw˜Ò…'9/¹å«duéÄ< TÜnU’U„LÉBlÍÖ%&sZ35ÏD!xëÃsÉ} ÊpšœY«Åº±<…%‚ò4†ÑdŠð“Jå”Z`7,êCØ v~Ëöåóûú'±#¬[ØøÂj^±z•|d;&ªZikNËCáÓÂéÀXfyÅ¥5P( ß⫕̘{àUmó‚5¥}í¶Òr]°Œ¿´s+‚QúýW—ÿ ‚BHVŠOüüÉŸaSûÒy>­’Z«§ƒ/7 dyX]ÞÇú@ÆÊÒ<×Ùcj`ïJŸó¡ö@ !´ªÆX¢–eBº}‹¦,¡­'³BIP…Š›Â—O‚ T%>ùH«Ȩ¥“Ý¢Pz{+pƒœ#=ˆÙ´°‚ìöÂnÝ–™ÒšgŒØHfŠq‡sŠhUíT@n¸äÙ˜‡Šx= }ý†Q×;À·/ ÌîÜ禣ÎÕMhÛ™À á¿å\‹GÐySë`RxËKµ³U{¸ì!åOŒÈ NÄ!7½Òë+@U5U\?AáOé;¸¡¨[fðÌ\‚æT°¬:=…Ù‹ ¢'S>I­ù ÈÙd)2ŽCüI á°ˆþP'V¡üÕÃöxáÏ:·Äè†ìn–.oúWªª‘ìkQ 46bã½ï þ^ºƒ&é,NÜ}Á™.ÑÏqÉ™áæªeƒÓ'BÖULû›Ž ù}]P¸ŠýŽijÔõ‘ÏA)p•¬ Tj ϲèWgáÎi±=öšãcÜÝÒÖ¢ u ÜCg ü QæüKk¬{ÚËŠt|ý¿ÖcbÑ]EÑêO(`ÑïGê45 ÅTþ¥¨¦3Au³Fºƒ9Èl«•Ä;+'(OÊi,u˜uüjÛ€ÄÉÍoݾûÑ!ŒŸ_…2Sù¹â¦iØP42£ Å®õàØy¥H:É…û,ŽoÓþøfºóÓœãyw0ÄŽ@¤”ãï B‰U8’d\Š…Æ£¸Ñ­Õ¶xÇã1½ŒhÚ£ç°×¬®ÑWÝ0)*¯Fõ/w¬ÔgÁ áø‰ž5‚ó´{™RÔ .›ªë€)Ìç6D2»Ë‘´û@eÚ±²ÁyõT·G¾ößÚt4=¹½Iç³9,ípA3Äh–Žák•5ô%ÚmÂGÞø±b:OïÒ»ðý㈆¢çãE:›â÷I¼ÄoÆ3ZzX~ü $gÇendstream endobj 5474 0 obj<>/XObject<<>>>>/Annots 2528 0 R>>endobj 5475 0 obj<>stream xÍXÛnÛF}÷W Œ¦f›ÑÅ’Aá\œÆh×V›U¬È•´ ÉeIJŠPôß{f—Ë›”)úP$0LrvöÌìÌ™³þã O=üëÓpÌÿƒø ç÷ð†ôùÇí˃QÏStæ÷(¦ó¡ÿ¸|ˆèî ñSÐó‡ýÓóê_ÏFþ¨ùµñÓ 7òÏ_ŸNH œlA®N©ß£ÉÇñKhâ—À›,%¾k¡âTgE~HÅ6•±HI変ÎdHjNìd²Š)ˆDŽ/9m2‘¦ø8Û’HH%‰ÌèެÅ1VˆÂØ-ebU²`Svsòþ G'ýÀx¡„SÞg£Š¥JHг‡­¿4œ²!ƒ å\¬¢"§®f’ôZf™ ClRh*„ŠtÆhsi=Èܧïd& oþQÄi$i³TÁFK‘,¤‰w{t…34Ùò²xvSdö­Ë¡G±,–:„·°F “¼ÈVAóLÇÆc —ÒÕ,R‰ H¦™.dP jûΧW6Ë&Á)NH'’R|€‡Q¢ ZåœF>ކ¡À—¥4@«¬– ù 87&#yN‰Ä¾ì tÈ’2ëµ9¥ ¦]é Er-#B™D2–I! ¥œgP”#©\±†ÚТ‡cƒ28û@°°¯+Î8Döxª¬jphAÅF;*‰5*NÉ \õ#ÒnÐñÌ ÃåÔñ\–®ÈGQÄŸkÈôÇ­# @X¦ë9®äðÌYøtåÜhňµÊE'ÑäÞ˜ƒßÀ^µc — *ø¤P"B´¹lA)ا ³´Aû '¡D{ð>Ì¡¢š3Æ÷ëFF‘in;¸¸ÛÞ•kêé•/õ*·r<³6’zb´§Ë•UÐ У ™‡&žœÛ/HYMl’ç*Ù·„ƒÍ9ç|–p;HmždxáJá_σ㚈¾nüþÛ÷ìûË»»‹‹è¤/£«Ýæn÷ñ^š]­ÐÄòç\îmq×Á_Ì+Ý­ÿÉ{¯ËiŽ#v£úÿSÖåB NÍTC¿þwdUÊÇQ¦ÿ]A~V(µÛë Ë«^ 1´3dªC×)gØjɼmæÔ¬GeŸ¶?ÙÍ^’ÊGÒ\ .±¶QíCtCÅ Ó.‘V•° ñÔýÌNRJ+ûºâx´u³„‰TÒaœÔˆ%nt#Rl|Ð¥zQÅ“yët­9·RÍè‰ÅÖÐ6ü§ éoX°ß•‹ -ºÓØ{”²Ñ©(p3hl­r5S‘*¶¤­"í„_ ìéýn8úT«¤À] )‡ëÝ+aÜqêtSÛc5ȘFq)±ÊÚŸ%»‘™ŒØiìr4@gƒJo·wðÌPD5°$6´Ü]j´{wŸf)çËIULY ®ì5çz…¡ïÓQèˆëïÈÊð#–ýܺeÀØa©P#ÜÏ ê`šA™†rż…ØP‘˜qM$]ÔŸP"¼Y,>°Æ@’¤È!;v®2Õ%#faÏxÒLBró% ·¾L³Ôæ9J9_ 1tºuâ¦:+®Ãæ&·ã&¤n#2®î8…dü¶ç’-g¹:u{33âž1tŽeÉxUê’¹3 9n+1sÓá¶Ðyä³´Q²¬aÜ„½{TêȼÇõ¡1“yŠk ²à&:R\gtVÝ[MaOüó³ Þw×—¿\>}ýüí»›Û׿¾zvéqyw«¹íHÎ_©ÑY4Ö«Y>¾¹½¼¹yq»ëÃùt:Óu7þ¼gs꟟ú£áˆÆc¨{íaÓ“!þÀñ\«êRÈùš¶Ö'gÊ`ä?ÆŸ@®Q±Hô´«¶õÆþpá}Ú;åW/&?ü L•e¬endstream endobj 5476 0 obj<>/XObject<<>>>>/Annots 2530 0 R>>endobj 5477 0 obj<>stream xµXmoÛ6þž_q3\XYmÅïitÀ–.]Š¢ÀVû’/ŒDÙL%Q¥¨¸A±ÿ¾»£(Kª;X‡I,‘Ççîž{îèO'3˜â¿,Öô?ÊN¦áŸÐýøóõÉ|: W°¼X‡kÈ`>[…ÓúS ïOÚŸñíù:¼h¿m}Î`1Ÿ¡ g‰ö¶?ãÛåExÞzû릆™-œ]_Àl›Q¯_¼€MÌ`§°‰‚ù*¼gSx¥ŒŒ¬6P2R‰ŠÀ>2Eyº¹?9»^.b “ù2\¢`³“ðF<ˆë½%$RØÊH0òS…K°¸fp‹ü•ÆÝ'º²ô¨µD»þ!­iÊA›X°šÀMaBÞÅÁ^›P]H“>†@øøìBDÅV6@•xèÂ*‹Ô†ª”x®Ëܪä‘1°‡µ(„ÝA‚QRy¬T\áî÷ݼîÀØÊ\aÑbùüQ*ÊcÁæ»w 2iw:.Ca$Ï!Âäγ:·ß¡òÛÓn:æèü¼ÉF'ˆõnr–O&ؑΤ±*ß‚0Û*C?K '¥éêùó4ÆL± 7¢  …>Á›w7/¸“hPÒ{B4i’P‘H1¦š¹AY@‹HKíV³ƒ &J¦1IJŒŒ*ˆ„„•N¦}ßàð~ÂZ£î*+C¸Æµò³ÈŠTŽ;yP¹•[i0׈³ö“"¦:Mõ¾üÉþE¸ ns0çábŸŽ‡|Àðrp3¸=EpC••…—pÜã|<œ]¼u—Ö [_„ëõ9Yw[Ü_[åŠÜ&JA.2 :áu™Úósq—J¤#‹)Ë,­é2àøßÅtá÷Oß+L9"òî¾&¹7ý-è­ãÈÑ4Ú°¾š”Ï7)†c>º†ïùÔ;ÌÒIŒÎˆ‹.±qLÜaý3ó˜(„¡AtðˆjšeCayR¨¬È#9F-JX*8¼·«Ö(¡uÄ!H!J€Î&UÒtwzi Bø¥a7±ö ¢0"²xf‰Í·X`ÿ•ioIAÏR‘oÏÞ³ÍK¢?úh vÄÀ³/аñ^擟ßɽÛôas} g·§—ðìoÚvPõ9?”ÒLb™(òŸj°„xàbÇ*MD•"é‘o•#ôX¼ÖÚIÒy6$GX[ˆÝ—]Áö;iXOή[rèÔ½m¨·Ñ×—i.º8˜OMQE:ˈ&)ºÆ|q–üaAà7Žq-´4Td¿F\·!ܸÂ홟Ôû†kXŒÊµ%r)×¶éI®-»–T£sµs6jêÉÈL?ȸ± öfL"õ,-*ùcõ[7¦Uݘx¥ò|+-×Òmj¢UŠÁè"¡.AÆûCS{¦¡ãûÎ1ž\¨[8)àá…g×>=Âkc¯G|—ÆÔw}ÖÕ~P¯xê!(E²¶ÝÐc¹ÿ§W»hºf _ü±u;Î0°Snt¤õS•à¤èˆ}¼¿:9q†oO]3-mÓ̯°ÿ—ÞÎ¦ØØ{§ðI?PÓ÷äæUšöò8Ь‡ƒ&ñK|3o&×C±‘`<åjrÅ·V3n@÷<Öãàx_ò_47y;Í¥ˆ®o%öhœÿ˜‘ŽÝ}€î¤¨¯*Ú5"/qwæz]¸|ø`Ìi2bTI&“±¢)š Ú]snŸúÞ‹\ô2Ä0mÀúQ—&XÞ:ÌÌt\á\ÎfÇîú×AÁ/°kð¤Jp÷/W(þÅ· p ZXz÷*¼Ÿám´nGîªã‘Ūè` 6…M“.Fµ§ýØ»îEó8é|U43ys«« º›'‰Þ3e͈èVI£ j)ýér²ŠweìU‡0‹'OÅ}ž±t †÷¹â{W=r¾¨Ç”Ùz®+ü¦cž»«ݧ& ü æU{Æ''PÔÜêɹ+Χ}²š®ÃÅ¿NAf-§+²ôÛæä“=‹§ïendstream endobj 5478 0 obj<>/XObject<<>>>>/Annots 2532 0 R>>endobj 5479 0 obj<>stream xXÛnÛF}÷W Œ•›ÖÅQd穹8p€6hc /‚µ”Ö%¹ìîR¶¤ßÞ3»$ERr*Ç0ÄËÜÎÎ93Ê?G#â߈&Sþ³£a4Äþ3â?}<'Ñ„Æ3\SFãñ(UW)}9j_ãét†·Â»þiëOgWÑUûië:£Éø*š¶ž¾½k%ã32+º¸¹¤Ñîiz…OKŸ->㻵¤Ó»û£‹dï_¼¸Ï•ʋ҅ûµñ€l!c%RÚ£Ä"•¤,‰\¤z¥KKNï:q§ˆn{3²HE,—´x"‡Ì¼1ˆL:i8¡!Æ(aã^ÔMýž/ùé‰{*d&ŠùàI,•‘±ÓF—n~Ú-kkòNçi¬Ò9%FgtoÙ×uï?$ÚPíˆÏZ/mDÐJFÒ'¢X/ab[zX«xMΈÜÂ:ó5y_¥E‘*碼L/K §ÂÚ3*Œ~| ’ñ^z÷ô`DQHÓ<˜„ '”¨Æ7‡"Žë”æ§\CÛOçϹœ7«˜gr©„y¢O܆Xô\$öØ ÄÐàH+,¸ŒZ¢· ª|ËHWÂï¦< •ye¤òU81öóîåK.ÑY±HSß$\UèŒ,ŒÊ”S›@víT‘uiKX>µöºn¶¸Øt>G“ ®~Úp¨ÇÑñ nDÎç¸Û€¡i'ÑtúšýÜ¡†:PCÈʲkx!g¹â,þÏ×s”dÛ¦‡„YI·§s;<9È…—Â-&9'U_y„ÃjõyÅ :š¦g6Ê8Š?à®9ùBØ.“<{чº³ÜÚè{<è$¤,cY8†W?N£uM\»®ÊýÅnŸÓLNѹ=šùuà03UZ/à '÷(PÒ^·J¿§7X¾eÂÅk&Œ'H“®×•-ãXZ›”iÅQ‡±!Α”ðg°µ]H9÷S“e%ß÷Q7 íÐoÇÃ’,Ý‹CÏÁ½?7GýŽf©„-Ö)W2¢Ê­‘~™«J¹cÇóS °~‚¢p{îäS‡æV߆G{‹•솟ŸFY}Ÿc¼éÕñ£s}â/·dÛ£à¥S©rO””yÌÑWáý˜„“Û.\ÜÁ^Çö›ï«kÇ“µL±) /±¥5S®úAZZÖ„úˆÃšÁ; vlÔb»Px ºû.VÌW“cÆñûjë²]£z/…FAçÎ!*ÍÝQˆøo>ºg78æ¤ï£êÍfaÐ^©Eú†uÌJ³á]DæKîTòÖz¨Á-_Lå¢'Ïv­Ëë©Ä†àAñ¥Õ+)à¾>p/5Þ£ßy@Í€g¢r‚‘½¨!é¸4iЗ¯·Yc¥I°S¢ÒJ5+%õuäØKBt("Œ½*ªrI½_ŠæL«īޗ‰3Þ²ÕSu;Q[&a†oL•Ôý\,..ªv½ÑÖ†z‡½&‰ôUv ô.Í8QY¡ Ö%¸ˆ”_•Xr½žœ$R`IwëN…"Ї Â5g«wUŽé*wÄ"Ðé­0ô~tM¨J¾ò·cZ”‹TÅÝt ?5„ÿV†óÁ®€lßÚhµ¤l›¥_±Έâã]Ó&Ë ª?מ߬-3´Ÿ1÷‡%ã8ð=ÊÕ×îñ ÓúûY=èl!\”hžnEiQ×bý¬×¬|è‡Ei䧬ê±^Àˆ¾bjƒ0¾ ½ô> ÄyPXMñéxJç+&}ˆ0« Í.£W“W4Íxj1Ï'øJþ^Çð”;ÁÅ&hÃðæùëpãWÑU„µÐÕ_bÏI jOÊWÃi4ã¿ àür8eOîŽþ<úFë )endstream endobj 5480 0 obj<>/XObject<<>>>>/Annots 2534 0 R>>endobj 5481 0 obj<>stream xµWÛnÛF}÷W „& ‰ºZ¶Û§ÄµÓ º±€¢€cE.¥I.»$­¨Aúí=³Ë•DÉFúRÙx›Ù™3gÏ ÿ:ÒCOù?ÊNáWøkÈ_ߟL.Ã1 'WøÎèâ<Ä{’ÒýÉÞiFWçÛùÞÞiFÃÑ8¼Ú3|7Û[É.g–Ô¿Òp@³„Fš^á(¶¡à "…k-DÊÏ"+Ry:ûtÒ¿4&E©(Ëf+I‘6FF•ŒIå•4‰ˆ$%*•”jýXRªå÷Î|@œž[²7…ã1Îâ ßwîèVkR%­D§Ö ŠU’H#óêÀ»u9 ç¯TVhSQ.BÕáåv÷ªM!3Q̃Î'ñ$ =Š¥ìÌOy½®]ôÌý¼¦Î^æ‰ÖÚž)ªÚHxŠç¬ »¹qùg§(OU.éKË5™¾†¾Ð×¶‰¿Ùø;2-êEª¢vâ„Ï“2U-Rú§1œóSïÙÁ³ÿÔ“V1*_ÎÆûL˜å°KŽŽM·Q:__]-=zH·ÂM§œöý?¿o _T Þ´%jªs¾è\œoÙ$"N í8 ®̓"*ßժЖf’ØÚiùÉùi—JL)ÉñA€6•öq€ ­Ž”¨$‰4E,FJ»PIkU­lı,Q]€ä˜ÒA€*‚Á†ÊBŠG ×¥®©\é:)2 0¾ÎX\¼Ec ”Ù€;ÖΣ0²0:’à!ÑŽa[ »y¯eü º÷êEaâ9ý®å$Ê_¥×«4¼¹ÿë§ã9hfº¬B+ä²Ü*]£^±LX½Žë;÷u™Ÿ¶¢x9—ˆOÂþBh÷Ñ …9ФQv™Ç¦Y«Ýsüû?⹋°”Õ§—£{³;'%£‹÷ƒÎ!W-üžÏÅÛ»j­ìúg$«ˆÎúìmסdy†}V•Ør•\n F²ü€ãàõ“ŠY¿€´€¬x5±»­“@—f}ÒFUÞ½¼—öt¡ëÐFç‡7`«Óú<­ì5œ/·.åçH•Ò¹ß-<º„+O¶·\òIŒÎCÆÜõrßsí6ÜeÍ­h^^òó³’+Ѥá³C”ÖÐu¤˜È5„Ç5¥MÃy„pÞ"ÉLÛi|¦–«Êö4 dÍÓMy¤W<\„åzÙ.DÐáNÕ‚àPè<$¡:2Eãã­¥ja„Ù4š”€g‚²7šnñ ‡tÖ—BömWy9¨Ý÷8]ó,¥*%Rõ·4ÏBhgÒxBØÚã*†ÈàÎhn1»µÚÏùa3 ªÑÜØ@·µÁ³ÄÅÄeÒ™\¯€î“4 ]J,qÙ±Óƒ¶]ú¾@Ë»î_¿yãì»H¦/:0šuB¿wI·2vsëRæ’÷Ú·ù#‘£G¢9>•(îÆŽãìw8`9îÄõ‡(`TE#ù¦í¾ g´E1Ñ)š/{ÀÀ°Æ„«× „‘™†=W¸¬ ;Àfб+ .î¢\l¶Õà^¬ò²’"&ô?ëÁ[6”á’´`qi`kFP¾¹×m-{SF|ƒ|ÝM?ã¡|ÇÍgpÍ™0å SÓ®Ö Y­%†W?öÊqºzð6àlÚ›Å+ß$nŽaj$`óó-ò0ší°ÅX{No´ZÄã ûhÞj:îû¹ãÞfšQoa‡×íôÁRFÉå mbìÔµä™ A*—*ÇdŽ*£ÐÇrfxÉbçÔçõQ¡0Ú ‹säÝo‡€]û庨¯%-@¨ó»QÔUˆ@9,~OxéU‰†P¹±¯3ýÛËf€^NÂóñ9Mñ;Ú·9.AoŒ7×udg+Á ÌÁ"T÷tïÂuÏ—%ý|0 Ç#ˆ„|2¸`ë›ÙÉï'ÿž›Xendstream endobj 5482 0 obj<>/XObject<<>>>>>>endobj 5483 0 obj<>stream xVïO#7ýž¿b”½EGL~@àhÕ½#=NUÕŠHUÕT•³ë$F»vj{YRtÿ{glï&»¡èñÚ³oÞ{3ãz#â÷&SúI‹ÞóÞ q±ùeÖp>Â5›À|ã!LߨtzóÌï©ðúÿ ,4xäyIŽ6µkÆÞ„Ø3î%ãóÕ¥¡úÔ¤êCl ºi$Bq1­ý㈡§Ü"^Ý‚r€U†2 'ã{-,¥±Ø6ºR‹Só jg‡ ˜…j˜‘Øiž”7†ï@¯BÍ!m¡1â,bÜЂãÓȹZ—|-ËâQfÂ2¸¼]°‘û~’t»mx|,[ÈÌ“ªK·g5¾{|AªÌ7Â"û¡[ Q;Ll)BnÜ' ±ÏªP¾Ý’”Ô¦-àd±àjGd ¿ß¨´zë( =ð ]*é$Ïå¿Â`vw VO'oë-Ýqæ:4ôÕ5ºdW£Íë³ ¯%i^fúÖe#…¨“}8?÷ZãâÍMX­Ð0€u%ßÔç¿»~ d$“ˆh!?9‡¯(„µØMÚ:Œ1Ÿï´‚.߬°¸ßBa×x)»Áàƒ.’°ð\É:ÒÁ!ô w4XP6WÉ!v¯‡ÍU톽Ž¢BX¡ÎTk_CÂ>ä‹ Ô¡< ͇¤ùÓì’áo'z+”gÁ;i‘Ì­÷9Œ±({Íi;l ã|v‡Áèú‚]N.az5fWá²GÌÁ„ á£NËB(º+iEQÑJa÷à*D-e!ys0O½eC{§Šó£ÕE)ÚåpÊ&cìOèÝ‹á5-ÝÎ{¿õþ”oá endstream endobj 5484 0 obj<>/XObject<<>>>>/Annots 2537 0 R>>endobj 5485 0 obj<>stream x­WmoÛ6þî_qšUYŲc'ÙÐmšt ¶¬k Å<´DÛL$Ri;F±ÿ¾;’’-ÙI`Iè…w¼—çyŽú§A#è è/ÎZ°ƒOè_Dÿ>lE§aƒ““°ô{᱿Iá¶µq›ÁY§ö.Dhx|ì £³~Ø÷wd¹yŸA·¡­[Koß7±ÑS8º<†¨à F<8ËÄŠqðNƒ™q8Þ·Ž.1v»,P9—îQi@ÆÍL%0cœ¿yü1æ¹J‚Îy,&"ft׆Û/Wa)ÒrVhŽ´‘ À6—èe½<ßêߘ6éª ˆÂ•šC¢äkc MtÆ©HO‹ÆÔß)ÉKÔ…ƒ \£D­…B[ÚZ[—: ì1ÊEÁòõêÝC•ÇÇÖ;êÎ\•5\º’‘LŒŠ6EƒAòGF¥u»ND¡é´@=Æ¥zÃ䬌“_4£Pê¨T©Æ}·¦3¸–&ãh_ è&F]÷ØVYé~JáBx—$‚NA4¯¬ªfb:[·JQˆÄê^Ý{ñŽ]Â)7¿s­Ù”tši¸¹ãèå9‹W¥¾J`ÄLÌÉê¬~åë³2fšo)¨ÓÙz!ö#Ýǧ ô«dÛËÖųäÅ»]Oy‹dþ>/XObject<<>>>>>>endobj 5487 0 obj<>stream xíWËnÛFÝë+.„–™Öï6È¢Mã Y¸h# mFäÈ¢KrØ™¡¡è¿÷Ü™!%R†ê^Ö6d‰Þ÷9çò¯Þ„ÆøÐìšÿâ¼÷ó¼7ŽÆ¸Ø¼èº¸û&Sš¯pöúö–æ‰û~Lóx0½Š&ãhF÷âž>~‹eiSUÐ9ÉæýZI–´Rš•BÛ4®2¡ÉnK9œ?ö.î.iklÿ|z]ÂÃà'ú"žÄžX´”d×Zm Zi•“(¶þ,¹ÿL±JdDóµÔÎ䈄¡\ë<å¢48QX‘$S‹S7è±2–cB$œr2KUYç‰Ã…ب²ÄÇë»gd™ejÃùÊo"/3I‰ÌUa¬VšÝijê‚z !-·á¿0©Á§V ñZÆÖu<½WŠŠ*_J}J‹ê¿Òf- ù„Ä\E.-Þ«•·êKv»RV™.Õ]ù·-ÊR&Qp>uÝø€ ÒÆP¶½?¼}ëŠþcmû£€>N¹‘Óh6çd°T*£XdÜu+Þ3­Rmìˆ\d$:“,†ï¼¡zΡYt}}Æ択D–&°Bœæ–j¿ÇrZJ®Z)Œ‘h›"=¢ },µŒeÂsÅWðÆUp-i¥\OÁfÆk?&”* 骰iŽ 4}a//‰}-¾÷->^á“\%F-Œ\ NBÄ‹Á#•_óþWô'ëNiž¡Áª¬ìbØo*µxÈ…·+þn®Ùû“¿['‰.ÎÎèkŠñß’–¶Ò…qN ØåV’ª"“ÆPjy芽qul~P@-«’¡²‡8¾ÓóADgÛŒ *µ²2¶h½Ïº•¬¿!n Dé Àºc˜D©qÅq'ÃŽ'Ð…A…ÜÐï¾û .ý}°öÃ3Á¸þðݾF g€½ïþiù:qw€íà~xïpÎög›;#2UY*m |±V ˜ ä#%j$2l.ŒXœHTÆÔ3^vCÑuâ§Ç‘d“#ØašµÚø9y1_&’`°´•Icã ¬–zîc¬ù·ÛØ(j¸-4àÿi}åimƒyˆB?Y$ðû2)x&¡±PühÏT¸Úf3'2‹á¨fÆö·µêB² »ïA]ßóg¿Þ9˜£*V^¼h©8®´–E,Y›Å‹Á«’3t¢ˆŽJ#úuÅ:¦ –FÒÖâ 4 ôä?ia[ X¢µa1 ÖoáöÆàu»î±!&c¥H8+Þ£^’XE·fÌßN5›Ço\" õ' YqI:–*3g†PŽ‘N!é§$¬Õé²Ú'ăÖÞ3‡¤tpk ŠêÁªeðºÁ"é¼64vœ¡ºj<‚@É÷}ÿ”ãwÐŽF»™v"½cóŽ$ø5eãVVpsºÂŠy¨ Œ:}¥UUÄn£Gmëî"ý? s<ßïdäZ_™8ŽqCWqé8WïêËž ?ÏTaó­ÙçÐbà›Û°ªOn/£«Ùž½¦Ñ_©¿þñùÓù,Ó/*®r‰‡îwý÷§Ïo|1_ã íj|ͦx<«_NÆìçã¼÷[ï_ýØaendstream endobj 5488 0 obj<>/XObject<<>>>>/Annots 2540 0 R>>endobj 5489 0 obj<>stream xíWÛnÛF}÷W ¡‰&%[¶›¦@êÄA‚ÀEc}(‹bE.Eºä’%—VÔ¢ÿÞ3»¤L] úVÛŽ̜9såïG>yøõi:ã¿0?ò\+üáóÇÇ·GSß½¤ÙÅ¥ëQNž{Ñ>dtÔ{ÌÉ÷¦fwo»À~½ÂÍ£,»—¨¡ÈÂ&Ci³ë]itº WÅŠNÜŽ›‡&zå#²uuÿþm-CAª"ºWi(Mr, ìj¶´ÇiUï mÃܤµ½T˰èŽlsÀï¤ á˜F™eø\~Q.¸ X¨ˆÛ:LÞì8}‡”¯g`Ù,2Äš-^msØ‹×íJ*šÒöÿ,±­™sä¿Ï’ŽóÖUmuXE&¹ v¹ØþE&8GmͰA÷OkD›¹m8¼¿{çö´´«Ûµ×( £nrØÞíPìW‰íJðõB`§ŠÊ)23^£Ùv ˆ ùk‡ƒ¢É"Tï2ÈN°º ÃT…¹…‰d•bfà" ÷GÞƒø5¯K´I¤¤sNmò™…¸dá$"2:WFg"1l4h øk5ô¦U’†Éˆ²ô7Øe,Ù¥÷(Ý]%ªGت `>0 láØŒ_&;Ïn¯‰rŒIy<™qžN.\ßÃüzS¨GYiîþFÓ=Æ6|U%ÖfdÁ(UÑp¸]9X O¿ô Äå9zzÒ"“9— µ¦^YV"G;´Ï!º#Ëu|gÌž°¸Z6¹T"°€fZÛ°Äô„ò Ájƒ ÷·Ì½ûôáiYå©Bé¨6VÔ.ÍáȸȲbÅZͬ•*ŒÙýqŠ ®yûæs-šŽa9ØÌ„™q¨X< 5·¼i¸±cF—­-6›Ï†@ÍŒÉ,«-dåJbVnUZ8fp¢»Fàòäùµ ^ÂÐŽ¦¶81µ#àyœFîf»CÆÓà•*T‡N%&$0‡¶ó‡Äêá‡vzIÞnG's;3|ê1Œ¿{+õ+ްR-uÑXщ™¤ö+щoî·X ?g·…8 è¹ †ü¥ˆÇ ‡ä€Û\p‚!úÊ5G¡aÒ†Ë.\Àyp k¥ß²Ž”>~¾ð`C~m¿°Ýí"0mQðƒ‰CÄd›‰¥‡Œ`5ðºaM¥°¯«Ï±MæOóÛ$qÝ ï Èû’øÿçôPÞ£YW™T`·Õ öH?L9£a¹ÆÎbG¼­ö³Û«ö5ËÇ+õůçøi_8eÇS¼b¿.BS!0ÿŠ£o»öôøÒ¶ÜSÒ.¼™; ,¢’û>Ë}3?úñèo7˜ìtendstream endobj 5490 0 obj<>/XObject<<>>>>>>endobj 5491 0 obj<>stream xVmOÛHþž_1Šà!qœRt åTD9]IÕU‹3IÖµw}ö:) þ÷άm'á.D8Þ·gvæ™ý·Ñ—þú0ñ×ï& ×qiñù_2‡Þ… §Î&3¸0úµïŒFo`2µR.Lü¯ÕP-½ÃîŸ0D‘âI¤šž\Œ"I½ow øšÚõøÅ/ïðìp4\èöÉât—Ås²hðJû"ü„³MS» üØ2¹×¿•wðܺ·Rà‘ï^& ™‚OT Y fa¤“XÑ/†Ú?˜Â=Ît‚vw–)ßH­€¢ ¡Ý«yÞ71F"öZ³Q$sï|Ê´ÛðT“äÆy!.ÐÿF½:’Æà´:€*ØZM‘‡¢’v%¬'s+Þ<Ôåe´í—åvæa=Í7hÖо1BeJ3An¦²³îÿU£»©b­vY(«>Ïgù¶F ˜" ¡è唢N¿ùòá/:saàòú5Í+Ÿ…HBCF:/²A äZå7]{³V+ly])OýíÝ‹ ékÂá¡bfö£nYb’2Ãé™]±‘0Dê6Š©Ô²ÏZðTøœ—¥ô؆ø„P‡Iµo›Nª83/$×(¤à¨=J8óófInõµ^‡ÍpE‡L$QÒ]º¹T¡TûOâ<—LM1Í=ó•(šø£`Fz¡Ñ¸£¹,ãoO%¦Œ’NX—F×Nu–ËýÑTlZÉý)O¹ýÔóTÓvϳþ&v«LC‡(jóÔ ÌKÅ0E"7ÆS)—£/Ðα„¿#èÔ#ýbd,E˜azË?Aó\,‘bn~”ßìó&Kƒh^ê…}~”þ‚Z7Ý›AþRØtïêõH÷íkïâá º ;×›Öµ6\üÔÛÜãÛã\@L«¶#”¥Zº+PŸO—œËÄ*Ô)&z¥*V¦Ñ83˜XCeUÙ+C š›÷ˆÔ_9_;åq øNòeA;†o%‘žfÔ”|?ÑQLÃfÚ%°JDÍWÓ™$„"›68¸çh®<Æ€Ñq¢ç‰ˆ~cgõ{^w0p†CºõÑ…¨<Õ’LEèpGæâ§EÞú§ÇÎÉðF§£R…y±;t\8×~Æ”Nç­«Q’sé®'NßuŽal)Æ<‡–3[~{°\Z9qÉÓ€î®ÝqÀKï'?‡n  endstream endobj 5492 0 obj<>/XObject<<>>>>>>endobj 5493 0 obj<>stream xVÛnÛF}÷W ¥m‰¦.v\§)Ð:v mQXAÌ XSKqe’Ëp—’ÕÀÿÞ3KR¶,%šŠ´—¹œ9sv¾ì (ÄßNù_œïý1Ù ƒ‹ëjFÇW!#š$4 éôlœž¾ ÉÔ iûe}›©˜âLCU]ä’¾Læ{!õqc2õ‰ŒGºåA»Ld«ÕŽU¢ë•±22-¦ïÕm%ªUä{ò^äe&½èàekÿÑÐÅÂÆ)Eþ‡ÂÀ™I”ÄÕâtE2:øžYUAY©Âfüü…û I±žJÊÉ)YMS@±Ñí@Ö±Ë{e#°ëÌóð»ß\-¢-j ­¦” …Ю-‚œ‘¨f‹›O;SêN*™¹ùD¯è«w!¬×ó^ë>/ôŸo4–¶£o!nÀø ?&òEckW"7œs®ºë3iÛË»n%(HämR¯Â—¤~e?A&‹™Mñóè(:x¹?-)tm‹¥PÁFnPyžU‡nC÷ëøjLü3qíG-©ý©,Pø¼tÕÅ” MKIÈ蜃Úl‡þpŒFhŽ©¿Os± ÿ7¢wÅ ¹(Ãö΀wPší¡»£—Û;#Þánl…ç¯ÅBn, ÎÿTw›KÃóëÚˆbãØèüN7—Ƹ§2ËÜíoâõ¶ ›JjëÞ#A‰\ÒT%‰¬$ lW¥ÌEiPIµ‘èœ Î{ªðº=RÆípoU2–Üz¢ U”µå¢Ö9âRĺXÈ ¬] W]C.€¨*± èZ±¤éª9'—¹†Äˆ,ÓÐ¥a÷Ñ[»*»SÌKÎÆY깯^RI‰ vF› ++ÄœIaÖ »Xl 7ï„O5(ɸvAèÄ-\PR1¯´°€ÚÛž8¬î¼Ùº*h!²Zš€Þ c³Uê¼P^¼9cîmBð¼¹qìMI Œú—ZUº™RÆ*YÑ2–Þ1£ù–aÀQ¾€Í_ýB¤™àõèOûáI0ƒº¼/Q('QÍe};—±+W^gVA½×%5­®ÙÖ8³µëº,µ‘È 1¬tM©˜¢Ü±Zü±3´T6}´K¦ÆC 3j™à’^"¢ïw/‹Q¢u£J¨wÜ£8rû¶šò£.(+¹Pº6OÛ¡mZ"že¥¬…¾Ë’ßJÑ`´Qð· »Á¯³)ÿI,›¨ùLp©¼l3n)Ånn7iÉ HI¥óÆ1Bjà1ß§SuиGZ¼ úæÓWÄaÚÍÐ(¹3ùÿeª¬ô~„Ýï™Mu=KQ-ä±ÔÕé¡Ãfx2àÅŒYÞ-EåߎžM›¶Ú뺰BS¢î"G¸þZ@ºBÄЖ[„LT9b8A=æóÔwP"ŠB[‚Ò¬œ©Ìí÷™‡º@¯¥YÆ6w’L¦f©¥\CòT£0®W8¾çt@Jm?Àû§ö³ü7I¹c¢q*‡ðù#H´?ÀzäÎeB÷{#íï,™ïÝ»ù¼Þ£}§»Û(îÝý–Šˆ T5ò#p„9çШ¥N¢–­ÑÁ.+LJ pÜÎåŠY t«i›Ãã®ë ±\Nöí„°#y rnDšn¿pÎí""ÚHÿo'N„ËLò3³‰x¸+vƒ§ÈØV"(~êë)¾M“|˜\]@K0I5w¡õ(ü–ùý!&¤ü1²Á€l[_ÑÁä»çhq9.1A;³P¶µ ǒ㫳Vggãàdt‚)¼hÆšëoßôGAˆ%v/±{E¹Jî›ÓýÍdõ¿“ð4 ñš ǃ¿œìý³÷¦ɧendstream endobj 5494 0 obj<>/XObject<<>>>>>>endobj 5495 0 obj<>stream xÍW]oÛ6}ϯ¸@qmE–7]×]³l¶nkô!.Z¢m¹’¨RT<£Èß¹¤¤TÊÖ·%A,“ôý8çÜËëÏ{c ð;¦É”ÿ¢lïÇÙ^àXlÿé_tæOh¶¤0 é‹±?>§YlO4‹<ªæÞ`#ó›ùÑè‡w2•¢”ïNòÕÕìâÍZèrîñö6—v}HQý4?zy4Ûì4ÃbüÅsX4ò7‰ô\öM=dàöžÉƒð:ùH¯(èzk"=ø>4»Bf¢˜{K-¥Ð«ùͽ$7„ç1# ð™Ò—{NødÒuÀø,•f3¯‚—”|0ñúìÙüèÞçq~çž ö¡¼šíþÞcilòäÉö7j±‘‘y­µØíwâ¹ÃbèIË_[m9€Ž¥B¡ËK '|»Úv˜[JºåõVmiË!i3Ð"U™8Ú>/XObject<<>>>>>>endobj 5497 0 obj<>stream xWQoÛ6~ϯ8é 8¶bÉŽ›uh­mŠY¶!Nó0í–i[Ž$je×-úß÷%ÊVìÃ’À0ywßwß1Ÿx4À¯GÃ1ÿ…ÉÉ/““;Àfó‘/èâz@Wî&sò4þÑsÇã—4™­MB‡(—ºÌS*´ÐeñÓÙdu2 ¾áÌùÖZ½°K@AxÑ¥–x²Œ ÒÛL&"£MÇ”ˆ'I"ÝÒL•ÓXR—æeêH¥”‰\$R˼€ª^RŠ•s~{˜|úùöá=c;¤+ˆ–#‘/ÊD¦šÔœ~ݾ«°£´ÐRÌxÏzsÉ„dBiıÚ^J EGéb—VÈ`Xhqh-â™#Ü:[Æ&W‰Ñ³‡r[Nº­å‹:3¥ÁYƒmOK_[Ú„ŸU‹¢ |~ùB¯i%ÓuÿÍu”ÎÞò~àtìÙ;ÁYûÚŒõ<’ñìæÍ£YcýAêëj;p n:Å&Z¼ý]ç|ÿx*VHQ} [l°À9Ò¬Ô=vu,'u³æëkº{¸½= »8N·œý°or ä˜1N=Ĺ3ì¿1÷×Ök—òîrV|MÇîg—íÖEíYÿß4Žº\©éJ†ºS{¬ÚnÏ£X‹ãÅÔ9]n¥mŒž½CéoPÍYoMùÚ–EésÕs'ÎPòy$г=¯ãÊÐöÆ®~›’V¥özû+Ÿ¾µ“¡w‹L$SÈFÚ|ëâÔÅuq="æ§9õ‘’¾?¬I͹SZâ B›ƒ¼=?§w7M‡*]ƒ5˜}–¢ ©”)•Ϊ qE ‘ΨP””…†œB•dQ ¨3‹9Eý l€>¤­ŸiÑghRWtÿxóÁ5¡È1ƒ4a¨$ÒÊs–ÆH½ÞZ2ñG úhU_Vü’ÈeE±»kãH˜ó«ôÔéíV»6iÎŽíöX™ Uæ”Êáá=ÛÏa69j”Xè¼ 1C$®¤N”Ú¢óLFš—cBp¶“-¤æMi2œ)Ô ‘µ„Âì_ ¬"æça%2™ÂV°¹5s0¹vÖ†ä™g¢åÂ|Ù0<ݤô­Õ£ÍåÃHVVO†"Éue„|õb¢ðí¶:8ø',œ}Ï!‡ =ƒ…~@?Wg6™f£&ì¹â¡ÆUÅñQ–«&,Íd¢0sP¥þ•b÷,èû¾;â‘€™~AרøW”—i"]f‘ÚKE>æxrb2fpU dÞPùj£3ožH:ßÙ%ºßbr'n¬Äì6šæ"ßb¶ÉÏ"Ébyt}CKëpIóBGFLÓ§÷¦½˜¾½7~Ѓn–£Ìâ~î`¿æNŸIŠ+ï4¦é‘zŽÉ¥@ÛÆ'Úa~ŽtàxÇtì ©TDvmÓUg”__ÈÚZaZ'ÌêνF 4ùbýç_Gdû}«yäqëÚ=.ªÃ€­”-üÿdÁT"tëq+âö\¿GCwÔ3ÎͧÌc}¹ð·K:ã#«&±»»ß -‘ß:°ÙÜ{®~w:>/XObject<<>>>>>>endobj 5499 0 obj<>stream x¥VmoÛ6þî_qõVLiÆ/‰“yi.K¶Àa^úE@@K'[©$j$eÇúßwGJräÄi©…QÇçŽ÷ò<ü·7„ýÂxÂÿ£¼÷ó¬7Zlôޝ„áf ÙNÎÏa»ï˜EÁèT â >ÄqZ,àw¹’«uIc X¥Ê6¹Òå2@£­tvS¢9˜ÝõޝO`H0 |4:'üýéã¯`ª²TÚB¢ô#“ÃZéÏRYJK?²,µ*u*-Â*Õ¶’$UÙTˆd–a,à7µÆêC·)ÆDV™…¨ig ‘Š‘c¢Hø¬q+4P( ´_­]$ÍÁè¤þ@ûƒ¼—yZ ’«uj—>Q¼‡°SÖœ‹1vħ‰ñ˜ÞâàuZDY#ôoÕŒžöëXÈ–l¾kl.RE(ó÷M¬î{eØW!s4¥Œé§ŽA”Icà© ÂCç[Yͳ4rAòá ÐÓ$s¥Ò˜¥¶aÀ;t±…¼/Íg»wý!ŸW™,(¶)x‡{¢aÏ> °RYå£Úi Û­UŽí”Q€~üû×N¬/œ³›$6ä'R•…‹ è·>}j0îó2ñN̼éŸ.§ª*¨â©ÆÂeöetçÜ0¼ãWßìö+ejzãÍÊ7Ém"#«ôfOdõ(¸†6aпA½LUq?<èÖÎå`;ðGnÆb29ãÿ˜Ài˜0ªhŒy¬·#ä8åësÔ ŽŸú”g³ÌP[b€7CÚ_—ãë󚜆ç'ât|Ê·_qæ¯m|M=‹ü¢"ºZìó+I›·>:ó:ð¿îȧƒ‰è‚L*y2œp¿\Ízõþ5ˆ2endstream endobj 5500 0 obj<>/XObject<<>>>>>>endobj 5501 0 obj<>stream x¥W[oÛ6~÷¯80²Á6jÅ—Äɺd@—%kúP`¨‘½0h‰Š™Ò¤GQ¾ èß9¤.–|i²¥EŠJä¹~ßwŽþiô¡‡ú0ÑßpÑø}Üè=|Xü2ÏpþЃë`ã=ýÒF£+GîTÆa ²ÃmjD[Å"œ†,±7³T2rèü6i­ø\„’OÚ¿¶Ç/tûh r¾Wž|wÎ.€NÄÐE×ÝÁ0sÝz´°Ö©ŒÀ邇4áÄF/à[1â+Çw"!£ÕºƒA0b:Q«ŒQÞBñ4ØMähìÅÕ Ñ©Š¦‰0\MZYŠG3ø2wñçñù,óúø§yî-PÚR’:»]r¨]*"¨_sÅa¾"µ;w’%É6è~ò¥ZÕ/‹ hôZ0žsP|c!Ñ2¥³€/,Sà ]£>¨ å{…—™õ®#4BXH d®YKnbmØ14…Aº¬’>D®¡k)õZ¨gLR'9D<J8ïX‡Z:®¦1 ­6ÛZ.ïóÓ%ŒwPðÕtÁ–“–Ní¤ O£ÐoyrH l@'Ï nOþ¬ëÉö:Iûç3ÓTZ2–U«ÊœH¬sò ¢ýÇagÄT|]¢{Ò:{Q"dR¾ƒ3ôÉÍ~¤ÎëQäØš5†ÿ¤ µK§¾*½–Üþ¤Jü8FÝQwF½»ÛI *Ð|ѳÚf…i;שú' >/XObject<<>>>>>>endobj 5503 0 obj<>stream xÝWioÛFýî_15’‚2,Z‡­8M ‡8@U´à—¹´(“\f¹”¢ùï}³KRÖa#(P ¨/ЫÙ9ß¼~>èSß}Žø'Ì^Mz~‡í}C'ãûCšÄ4èÑèißžÐ$²R=š„á+‰)ðD6­R‘‡2èзÎd~Уn"‘a±“ Eš’™IzÙJ{©Êo(¼6ú˜¦J¥Rä¾—™Ò«ËÊB•—FW¡Qz¯Úy˜Š²$üýú•.h.óE÷Å8É£×|x‡­­Ã ól¯ €Up¯óÀ<“f¦¢«7”%Qkê­4ïëóÀ³JŽéðy’'æÅ!žïÝ_Aç{m³bk:´n=pÉ*Œ†ùÞþ`XŽ¿Ž¯œŽŽ‚ÎÏ¡»×Vêí͆»NôH˲JMè¹ü8ËдaÂåcb­Ç‹´Déïwéû^[»§ßIB“KIœh)ó›$ÿ1P!~éÄÿ}T­Ý[Úÿ+¬Ö¡oàj]­ÿ&°vh¶Ÿ«BUzþœÏå—˜—™U!éOe¥»Ho° ¦¬YÏ৺‚ÎŽÜi­¥±HR¶¢(ÔRI¹\Ò\,)Ûu÷X¶VOƧÄdSÖ»ƒaÍÓÞ+iŒÔ$µVšf~'`Û¥ªÒú¹©$ExNr7³dª"éÓd&5>ïgk*UZ™tÌNZ¹B«i*307ÒeOÀ¹†ä‘©lâp>"P:9"+¡)“ŠGŸç •.`ü݇«ÚìoŸ®ÞRUV˜+º‘¹twØ'ZÎ’p¶ ðÃ^|Yñ(Kè®Jñ'Î^冉!(E™ "Äa“"ë aÖD‰ ¹bÁñHíÓ…Š˜™à0eë,‰©ZH˜„]Ay•M¡TÅ„8Ù‰T©Ûª°é²“Olxrg°#0äZp<0Z×GRaXé:¤é .„*+,NÚ}Vz2~J}ä9ÆPïFœðÁ™ßïùçô2ŠØŒUù9-ÉM1WC„bårç45PbM§þ)ëú4“9, ‚ᢖ¦Ò9êk•á#._\å!'ï˜\’—ZD\EÚš»S0.mc9aíÊèÓå‘”œó½‘¶Ú $ðáb”"“Öä2Áv‘#k@t¡Ê269ÌÛ\-!Y×Î,ÕFÐŒ�¯‘$ŒwÌž "4‰© g\kúteQ…âäÀ´3Ó@†õÑe —mRÏU"ð'¬»×»Sœp&Ã[N #GðÚsCC²©ÌíS;Éy[ûAA œM»‰&òe›®P×-Çg¢œ½F#>à:¢W:rÍWiÌEáÜivYË .¯‹Áú\›Â ›Š÷TÇkÎÛ¤å‘ë eoÁ_竤4¹µ™F¾C@àXjû¥ c½Ìv8Äjy€™(oŽf`ÒÀ"Æ,4ùóú’oOˆ¢š¦IØ.«ÖWì™-Ks‘ö®qÍnëB»p Óî±#:¢Òð: 6ydÝâÍõ½s¤ÑŠºà{û‚õÉ/—ÉÍkìÙtq$e{°omsýí ±íe3èšõ¾N¸lºÆÇ¾×€ZmàA8èÜHsí(…ñô°™ÇU7^-ÛÓX)úFß7oâð¨æ'< Åx‹I}©gôð蜳±JSµdfp”%e‘ŠÕvWØå×A¬!O– ØÄŽE¹-ßÀlûJC7U|ú ¶ušóHÆ Oíèt0ÜÖØpý‡Ö›=z®iŒš7ð¢eÙö%Õóåî‹àÞáä"™}¼%0½ãßÝRÖ2ÈÔ›ïp`¥ùv]ü“ñyM`ýóSÿlxF£ó‘ÿÄu)7dwè÷è +fÁ³†ýÇÎ㤻O$ÿáè;ëüáœpÚ?gÕ—“ƒ_þ“s+endstream endobj 5504 0 obj<>/XObject<<>>>>>>endobj 5505 0 obj<>stream xÍWÛnÛF}÷WL ¤¡‹ÖÅ÷"(ÅnRM «-ŠªVäRZ›ä2Ü¥¡È¿÷Ì.I‰²yªm½;sævæøãÞ€úøÐ茢lïÕd¯öñ²ýUÎéø¦Oáˆ& ûtv9ÏÎÎi»S}šDÁíÚX™…º²aQªÜ¦ù4ØO´ü@ûôœø)”+‘ši€ÃéÁôàûƒÉÝÞñÍ% †l¹Ó½áim:ÀÓ ^ÒïZÅThØ”¥!‘Ç$(ÒY¦súI,Í„‘¥Âoî„@” ªÞð$<Êà].)S󅥕ÎcYÒj±&»À5o'Ò±Ägaéö·?’Ì”5€\º3E©?­_».$­JQ0á›”:k2’K£„dd!Jaåׯ<“‘¨Pe€é DÜ…J¹-ŒÎ¤UêÁçÅ*Id)sÆw-EZ¡z ™S$Œå\àX Ò“ÚÒ…ô2Ž•U:GQ{ã;Mçø`ª¢Ð%úÃÀD*;x¶2ÒÍ­«—6FÍR4š®ýÖ½· v¹Zëª$½ÊQàRzÇm¯%®#·ê¼¶™DLÏwLUñ¬h¶vÒ½’KY¬S&Ö´È dz)]öH{ãÛ#ñ°›é ²Ê½‹úËO"+Ïj¡PuøÇÛŽ÷ÿnK?SMX<ÓÍÖ[ëROo8 G#Q<å+™(¦Áh€s2=pÑNþ|}Ô>ÑáÖów[Ïý}äú‡#ô­_L씦Áøç—··WW‡€²Ï¯÷ë„€Ú@fÖùA~úOS¿:!¨“•‘Eg¥3—ö½§iä»§ ÜbÉ©á.Gð[ùýÜ1ÿÔ}<¾iÛóÿ¨áÿ×2Qàí\®¶è³›¦€Ã¹ýr{Õ,U‰øND¶f%Çﻸ7Q¶§ · Æ—’0žÎÁLëTò4ÔËíÝì#=»{4Cãô‚lDÙ˜Þô¡JÐL°’5Ža1Œ}zÐI¡ïXç¶P|ûcθS°/ÀÊì¼®ñVÚB:Ë»èš*6‰`‡ÜþŠKÞÕpÊ;û«:…«»stQù=DÙàðYûr3MvKX‘Î-Ö•ßL\I•RRå‘g|eAŽÓ:d©r&O,~Œ­ÛêÐKP<×o-1£ ¸:ÌXõošÂ—mÓêa]-tÒoyªîY|`¡—r©tÕâ>/XObject<<>>>>>>endobj 5507 0 obj<>stream xW]oÛ6}ϯ¸0’ÎöbY¶“´ëЩ»¤-Šb[ ìE/ŒteÓ“E’ìºÅþû)J²ìdb(uy?Î=÷ùëlB>~&4»1Ÿpsönqæ{>›‡^ÒøÎ§WÞŒ1M}ºùiâÝܼ¤Ed­|Z„}™ôAj~W ë _ý¦á0ËÜÒ€¾ë3ŸFìˆúDµ³ 7Ôî ‘$* ú¹üÆ*®ßƒ`ðó‘·ôv¥Jßn…LÄcÂð7½zÖv©™ ™.mÔp%4 Û˜³éi”¼Ða¶úM´ÚÃ%õn Ú#6嬷2dzºwê¡Á1—ãô4¥NiÒ]ÿ»SðVɈîžÀÚù N‘ŽQ왟¦Ø1<~mÓß]‘i`L#Pa49*ô?sñCN…ø“©Ø)Y¦•WŒ5E;¿ ÚÅJ檈=Z¬˜b©ó‚°ØoeÄ$(.Ó°* W¬cò%mÊpE‰4þ±Si¹”ÆbÞÚx5NSC0ë_D;ø“Ø ˜ò•Úå„íØîM#ëÑdeòxd*sŽ^g]â¦So6Ãö6ü]3oQåJyç8ô±3öüUl²„½Ã9©6?eý°Ï Þxª,¼L†$ ú½{ÇÚׯõèGªxK.êw&øÿvè¦E&²Ø¿>rø¡3NÆ-âõ€¦Œ2Ö‰ý4o =$i§ÐgIô;çebÇR¦¶)qÓ@‘•íVœ’.ÓoOE…ÓãY3ÅJQ„éU·ÄŠϰþ‹**>–¹X‚N9mYï¸*‘²*“¨¦ÉØðnÇ-m­sKÌK,Ì0\‚)Y"ClÝðFw"…÷ Cd!eŽ8ò苪«°|Ÿ×Ö0±Ú) Ž@pGîVÚ±"ÛµšàÕ8;ÉîVÛ7SùuOa"rxu“r¸¶“IB©*(bP{ë¹L#ÖÉÞÌݼ“£«Ç6å!Ó æ™ztKi¹y¯L~ûŒ7"«bÆ, ‹˜1ЪêÍ J3M«*µâ8eiˆÓHH'“Xâ„°#=pýÉéT¬èá÷”  ƒâˆGµeÈU¯»öT<‡‹ŠJ¸wïâB.!ã1½W°%§¬Ñ#ë<âX€ù5ÜÊuK Ì™½Sº.ÁººH¡Xv›y大{r´&Ñ©I“Ðmdy’ãt]nSéw úk(«ÁòàNô‹ïS¢ñp¹·Ýn 5Úê°­bíV/SL¼§HáµáVeН€c—‚‡{ôÁqi8> –•ž%>¹x —yÐ÷/)IŽÌ»¨uOÜ‹úϱèÙrtÁˆê|…¬ çë‹Í°“ÙE‹X*[°Mo­×‚ÞsöfgwGâÙ ùíèTbÍÑ$NÃfÈ/6Œ˜œø¯Ïä(ÓN‚õ}/=>LN¸q>ÁÑù¢¾&vÑ_][…^"¥NÄÎé^b`íÁ_ñËLñœ2e—Mè Îl­âWDU‚A§F¢u%x~ûfï‹Ã5§Û`0z{'Óhn´c€%\]cN)µŽ%'ÑÇ÷¸óD]'÷\ÜUïj/6œå;¹œÿZè¾zâ¨]' t a~;Â…¶½†ƒÎlx~t»$ ÑôÀÅgø´ùÔÙœË'/fEF—6ØqqõxwÉ(Ã/zçÕ"ZòŽï^¹ëääÕ•w=»¦›—Wõ%Ë(ðhæùP̰4B/Ì­Ð4wÏÊzô² :½ö&>>ô`•²i²¹WVý6Û®ýo6Å?<â«©o–~Yœývö Çÿ­endstream endobj 5508 0 obj<>/XObject<<>>>>/Annots 2542 0 R>>endobj 5509 0 obj<>stream x­WÛrÔ8}ÏWt¥p€8sIÈÖ>@Øp©‚½-^æEcË3ÊÚ’W²3¨ÝoßÓ’í±M ¨­*D–Ü:Ý}útû¯ƒ)MðwJóÿKŠƒI<Áþ1å¿¿:˜?‹g4{Š%´Ø/rúpÐ[4œÆ§ÍIÞ쯱{zOû»½5vÏFïöÖØ]ÌãEÿÝÞº Ùä ØB¾÷ÅUÏ ïŠ]ÓÉå)ÒUwÏðKê½Ä/IôÞT’ª¨ðCÒÛ÷o(1©$'+矔ÖÜî8:ºº>8¹Dd¼ÈmÕúâ×ʆǭùˆ Y¬¤¥a•Xå°l¨4Júñæ´Üæ;J¬•Lɬ®eRÅt…«ïºà,~Ùêá:žÎàBde!”vTëd#ôæ–ÜÈDîäòè19¾±ñË{A©‘Ž´©ÈlµG´Æîb¾fg§l–rî™<¥{ÑÈDW”* °êFâ7ÇÎ¥ÞF»í*['•±$tJ©Ü/Cp(UHvX9¿Z;‘IRš ã€+c“ œàe"œt½Å©)šjÇ“$oË\%ªêìnßãNP‡I5$’’ðƒxPV:öPe¤¥Le:ŒgÇIø—’(I¼¤™´Žp[Ù䑌URs^‘pi3‘øüó-oÅ`Ü6¦ˆgÞ¯vTˆ?•^{$þLHT’ ç¸a zñMDžûw5:V¾FŠ^ÔU.í2Z…Í>7«AÒLÃ?o¡Ö©´ùŽA\t||ž¦ªRFãšm%­eÈ`@ÇTÂë­F 6ªà 9äBµ$Ì ªO(­þ¯9qùM'2С…¢é…+­65R<@w«tÌÓ$—àXT—´ÝH¡Ü žlKN™GŒÊB9[P‡ iåŒRfMA+ÉlK¾e&—z“ªa¦º"þvÆßðÅèû¢ãbúɵ à<³¼N%@­äyköi2öÚÔÖ5rÉ&q×!mø1•ÈN*v‡Í-û6pìÝE_Y¼4[fZkäNBŸœÐK£TÜ3LÓ>Ú°Â@"XRNRyŒP6+jÝìdØÓýžZk–ü~6ŒyX652"uûJ¿ÖÛW–_¼n¢¬€*ÌY¡@>hL#v½>0ì³-ƒNpQ‚•ÍEŸ›Ô«foµ›Ôú˜ Ë”‹ºïÍý/œàT¦Ÿ³ÒÓ®91¶ó÷×?M¹¿6ˆúNæÙX@páФ_}gå{n"â-•>Þ ¡ O÷täñÅyÕ§‹GˆÙ vmzL»¦‰®%Ú¦ÿü}A—+ßMQrGm\¼ðA t2”ÊhLÇ€qÆä€Ò<}vÌe¹ 0‡Õr¼ÑnÈoÇã(ôÒ‹î=‘÷ªv4+ ½J€.—•Dÿ@k/7aÎÁ4åÔNÂL{|Ç,Älåro(”skjŒ™+¹ƒ¢†Pu*[òXd3)ó0si^)\ì¦+ç·“ËgÄÃ#ûdzqvO'ñtJïÂXR ô²å{~ )‡ÐJ vR'è{°Ü´ç}÷dbóüé‚ ü@+o‡ˆÜÆlzЖM´óþ/2¦©¡BCyxD qsañ£7™_!\(žþ³É6þ¤ ‡ŸïÆx:ü¶`«Âøç³Ò)©g33îÛ’XE7œ‘q©òè7.wzùíO(ñsj9^|UnûrÄàÿ nÁãÛ$Ræí;AÊz…/ï¨Ñ$¶0܈܃ð¯.£°Á àâ}‚øŒµÕµpëXt<Œ=QFóF[û×£aMdø€ [kÍœd6x­¨6ÖÔë }øøæU“§Íé àgó3Z<™Fò™ã9>Ž_š¤f¦ûÇ 4áìñ“’ÿ³:Î&‹x>Cå¡(NgS¾ï竃ßþkÕendstream endobj 5510 0 obj<>/XObject<<>>>>>>endobj 5511 0 obj<>stream xÍWkoÛ6ýî_qW4›‚ÄŠl'NÚ!Ö´)R`Ŷh‰²•H”FRvÝaÿ}çRX‚“µÃ,‰íH"ïóœséß# ð;¢É”ÿÂlðf6ü7Û7½¤“ë€.ü Íb4}5ò§ÓsšEnU@³Ð#üÜ­¤LiãÞ/IÉ ½IäÜóC)­{>÷æ‡ßÎî Gع­·[ceæç¥õ (›ª¹÷¢²d’Ïò5½ £Ê2ºÅ-¶³ÏÒÉ Ý&Y™ +IÐRè…XJ ó4•¡Mrõ”ëeøldºT׉iòY°•g×þ³,N®O‰ Ó5Ž'u½·¹úÎÒB’)5ŠcdDv%,%1>%iiÊÔ&jIð[”––ÉZ2V …̫Ǹ.à ãû>W ÛÐáxìO&hoäíÖ|tŠÕy49 F¯¦ÓÓÊØ‘ßq˜+að* ©øJjI‰q÷z“k·´î”KRRkUñÔõèQ¢Œ*D· %–¢\®—]%êoÀ›’2‚A¡¶”åZú4[93 Á1g]èüÓ¶µtÜwë2ïù=¦”ð˜i#1Âæ”I8ÙV=Ú ¨H¦ÒÂ=¬(—ø×$ÅÚ’øt£(בÔðÃVvk©8kÙÇ<êë8¤¶)þš— …ÃšºØ,7é·cm¿4Øì«.@o¡‰Èv'`GµKçŽiÄÛ}?lrÚÅté®ûæÿìvÐ\BÛ@8dþCŸÄtéSè ÊøÌ„åâô„ò‹šD;ÂWš–Îõ<¦ú—rã®ŽŽ¨È1U¤fY©1ˆQõåå×ÞT³Ò€h r 2ìÈ<˜¾×B'b‘ʯ.ˆ. Í ¾¥Š{*›æ8üÉjTõå½JýÊž0¶RaŒk¼ÅrUî[Š)1÷œÁo. ƒxOj `bw-W;ée¾QRï·n¯ßÅÓsßÚc¿.9>ú9ºµOŽÄ˜ÂÔ%kâDCkjæqy!ÊϨÎQ¸¹<ªf€+ªFBí!b·ñC'±¥Å eÖ.Êô9üß`ÆÍ•Ý—€ÌŒúÒÛ Ïý âR¹SËëêÁî)lghå"MBr±×ZÓçl=÷YM:‰¾\|XºšãRرõ?p•ætªääñï‹Tïq€iiËÚC£]êÊO"+RùáãÏž~{ì±Ù$Ë+ðû`ÙO“ÊÙ¿Èig°¡r,RQïóÏïpù_1¹ÅÊó¼þˆ‰äÕÀ½>÷íêKŸ"¬õH¾¨ÐãàÔ?›œÑôü‚‡ÍíÝÍûáÄèm–ŽIîÏvpÒ®VÏ+ZŒÏüQàFôcuˆË„Â×ÞSß*Áâ¡Ò½I`ØøY0õ'c|»B§ã1ßz7ü<ø [2ù¹endstream endobj 5512 0 obj<>/XObject<<>>>>>>endobj 5513 0 obj<>stream xÍWÛn7}×W òÐnb›ÖÅ–]'-:vàéÍBû"  v)i.¹!¹’·Aþ½3¼¬%Yv‹(j ¶´äÜÎÌœ}ê  ¿é•W½ï'½>ëãÃîYÀñõ70ÂdŽwÇçç0)üy&y6ÃÓ÷¢Ò¦…Š+¾•PæÚ€ž}¹³PskENƒ[ ¸<8É[ažO>ôޝO`€ºHûÑð„ þì=©)Õª 6ç fœ)ó-¬—BAcéœTqUÀ;¾âP}×B.ɘe0ASµ«R7įj)À.õÚ‚Vø®É—s+¼·,-¹ƒNP¬E–¤Ö-p—\Ù‰{rïT%ÜRèj‰VÄ]ía à$…/àËæºF7æNhËy£rWjKnQÄ5F‰‚Á¥V¶,Â}„ZJ½&<ÜZ{ó„‹€pÎÙˆ ÆC6á§"³Î4¹ƒ+ö9ÙÅl cV\6âåÎA˜fñÆô9\„›Ó ðãç/["_¶5xç(‡ñc»†£þ ‚gÛÒu3“eî#£dEg;mÓÌ»E§Yÿ¡;+]`…ë"¹7IדaøÄKØŽ^/`±¡À‹…ô$é]É€Â}½ùlŒØx|F€S7»æFW”Å'“øÓ ys+ºCK^M³!BòðZ§mâòUÂq¯DãàÕ+xï0_,ðŒÞ«ÛFéè;‹®UHïÇ“ ­`ÓÂbjJ”'zÙ€ŠšÿŸ`…éUb}"•Î߆#²Ñ}¢·­u¢bºq¬6Ø,RM³„VhBëàQ°b÷+u y < ÑÑa® ëRJàrÍ[$_2 è¶ÿ!Ìð?ñPHƒ?Cf¦ÓŠ· ´óD‹lHÄD=µnOúÜ(LŠçZÝÓf£ð¡uTÌëe{H¡žâ°àfFå#[!§éÃÁŽ»Ô² !È¡àj!ém­±ö…9$ÕFÌÚÐ tBÏU (Ë)7´D©°i9¶ÄÜûf7úNñé°ÏàGZ ´l(}äY纣Ej^ãZ‚mF%dĽP¹Øn.¿ ýU „±·ËD÷ÝìÄYâ‡vTCs>>Á¾R¶AuK\c¨¥ß^B¡…U_»ÔŒŠÈg4à Jĺ1gQî!¤Äwºl KO;´vuH׸.ážÅi'Aýu›Š!+B#™‹ÕöKg—‚Ó}©ÑÖÓåOμVÅë¢èD¦ÙŽ2Ç;f!•u'Eã}߆AS3Žò¨–ˆ˜ÌN³(ðíÓ–`ùzlÓ±ßۦ¾ûá†u9þ}s Ûu¹ O¨¢K{ø(¨þlì‚™Ü {“ÿt|}7ðÁù ;Âx>/XObject<<>>>>/Annots 2544 0 R>>endobj 5515 0 obj<>stream x­WmoÛ6þî_qÖZYmŲ7ݰYš)º,k  ŒDÛê$Q#©ºÆÐÿ¾»£hKªtÀÃÑ y/ÏÝswü»Áÿ"˜Ìèç½Q8Â'ôÑÏ»ë^tFp:š†3ÈqQøª¾Éà}¯q›Ãnk¼kÜæE³pÚxùë}C«ÓK8¹šB4‚ûš4{… [‚qp¿’°PY¦Öi±»)e.Jë4Ë`) ©…•`qQ"Mªe±Jd´­ÿI|iÑ÷» 6^IÃËÓ¢¬,”B‹\Z©y *‹•<¾ÿÔ;¹B$j›†Ñm Œ´—™ÌeaÝot(b¥’†V2b§×¤y™m@$‰´`õ¦”qºHk{ñ©Uüü š ¥V_6g˜ÐÛrN ñ†ãq8™à]<«ñ˜ÎÕù1ÔÂŽ–Ò^ÜY}^$çIòN.¤–E,çÁn50?>"$”`ï$/Pä…*,∠=û§^MÈ$ÀÉ \¦ÒaÙƒë H”4Eßb(²LÆD±éZå@ž~+M¸èTE"u¶¡_¼xá c•Æè 0+A òËMGD©ÓÏ”†ZíÖùŸ¬Ïª:„WGBÒż[Eð‹ÔU  ¥­tám kµó 6v~ÜÝòµeõ3¾=¹z”— ŽÝp|Îf/)*xÂh¯ ˆ\h†‹ ¬ s©á`K Q$€É¦â·à¥µ:}¨¬4¤·ÉÎáxŠtF%Ä/6ª]6ÌÁ­¸…Ë/±,mª _&?SjWb<ñH9žÄé—‚Zp"9#ZV¦Ö@¿ÔH®­‘D;S+Â:«ÂXª V˜%Û,cS:% ÓkFlØ‘߃ ®íy0€Xð@x–%B„”p„5Á:á|nIv|a††•M³ðZË¥Ò©(.D&isGò½ë-QmŸ½ÇÿÍßïðrX&pˆ;ä­+õ@á©Ö¡©ïõÝ Ï»´ÚCÀVÁé®gf0—Z4âùúHcð_+O-?<ѳ±!bãÔöþÏ›ëûw—ðŽxæ&AÍÓOÁŽÆV>A<ºuÈoÆêƒ…'ôÛ6ô¹'kQ˜ i•ìÎã±.IºÑèbËÓÁΤƒÒIb=/x®ñ ´= @.»%Ëñ´£2„+?ØcÚaø¨\Üž0¼ø> ç(<¹á…ƒA®’t®Ò¬°Ní ŒïT¥=Qåh<<0P‘ž¬n œÃ½[u§@2ò|`÷<¢hÐXâµðüîÝÍÛD“ŒÜ·K­ï± ëšõ¤µè“«³ú$MÃÓÉ)ÌÎfáKw¤”NðüýZÅ88áAð&‘Änõð¥Ëêÿû\p:š…“1Ùñ80OIçå}ïÞ¿èDàÝendstream endobj 5516 0 obj<>/XObject<<>>>>>>endobj 5517 0 obj<>stream xíXQÚF~çWŒPŒƒœZåá wéUÊ%í!U‘¢={_ÍÚ]¯!¨ÊÏÌ®×Æ÷®èžª$ˆÃkï·3ßÌ|³ë¿[ððÿFúø›Ö/ó–çz8X|Éôo<¸tG0_ÂЃÉåÀLÞÀ<ÐOy0÷~îbÅ!à³(JáGñ®K\LÞ |ÃB‘B&ü5+AñÀ‡LAgþØò 7@Ä€ÃR®@ÅÀ@ðlY”qx؃Zs˜¾~­—ªLºòU 7ˆïã WëP¬NiBi®¶èü|b*0oõ‚î)ˆþÍÍKè!;½á(gÇ™£áþ:ä[Ž£3–$hRvá‘ò,R\j‡¾dY¤À+.¸dä ¤Q¸Z«hiŒÏ1ø!~c[ÛsÙE~È “1Äy'ù*–!Ó<æ¾5”XËh•‹-— Í …¦új:cŠW§;.ÌÉ‚»[šÃå†!“{c ìÂ(‚TÑ·bq4.‰õcä/Yž‰€ËhT›}j-ð#–¦fEµO0‹’‘Ȣ ÍLrH×ñN˜$t­?e÷†Cw4Â|œsÈ…ó˜ÒÏE‡IhS^Aûiv3ôÆ­qÚ¶6è„=@Â)¡èVóì¿Dò·mºÐ+€â›äZ$ Ö€I<}ká”ãîŠ+4±°Å†Õýt}õÇ¢Ó…ª-v-ý·ý ˜÷îæ¿Î3ž]ͯ¬Ÿv£‹+?IÛ £U÷ÚUzáU…ÁÂjc±Ž;¡óÓJ.œ*Ú¢c½Æº;Ëz-svªQ›ïÁ+ÈOâT™…Ãl@%>æŸâò‰3Œ eN56tï},ÔÚܬ²]¬eò³>sÆöfž×úœl¦Æ^$Íše%Mòµ›-Wn”ÓDÆ_öFα-’ðY%ÊEÚ´3h•Ù1rË8šþd§œ¯${ˆB?ŸaÐàŸ£’r]-€E_Èg¥ û‹O•~YŠLMð ÀVpÛ¨lÕ°W% ­=£{pÍÜCY4«U%ÑŒ=)‡G$¶œþñh!Ž/ŠZÈh µl díŒ*]!|alLaÏdáIÜfn)ŽÓ™(¹Ê¤þ…m’ˆã.Ä5¹ÿ¹’ÇšEò¦l&ÎV¬ÌUS;)‡£ è¼6r˜Gêx«I _a Ü)ŸöІ¸];PS܃rKŠzp焜֒îëш½6­pC§å"‘á“¢µî~®¦´[’™¯ìf¹,÷Óúq6á%ð:R/¡ÆD·[ª#BC_ûMd7žU9ÿŠØ\3ßµ#p(:Ï×*p¥¾õUÿæ2?@./ÜñhŒï:.ìIñþÏÛw½‘ëÁ,ö³ ¤‡± <ö›§{oÌib8vž;ÁŒ¤rÃdºF©§Ýa–Ò7íÉmÚš­~‚ÇÜØq ¾QJ†™â)-0ö&îhˆ/jðs1ÓÐõ¼õ{ë/3!±endstream endobj 5518 0 obj<>/XObject<<>>>>/Annots 2547 0 R>>endobj 5519 0 obj<>stream x­Xmoܸþî_1gôê5nWÙwÛéË!u.©×;´ñ5_ ´ÄÝ¥-‰ŠDy½8Üï3CJ+mì"EšŽ%’Ç3Ï<3Ô§£ ñwB³%ÿ‹³£q4Æþ1áÿz4›Í£sš_œEcÊhv¶ˆæá)¥GÝçŒæã‹hÑí>ct1évž1z±ŒÎ:kgKl8?_ȶgûÞõo× ‚¶\Ó«wsšŒéz…-/ðK"Á/ñà ­ô–ÜÆä늜¥Ü:ýúôúþ§Mç˜;¸Þh:¾WÊí }Lü3SmTEñFåk`½¦B•*ÓN—2ƒm±™Wïà0Ù{À&¢Ú™4z_êµ-Ê/UªóD•~fƒr@6¼iÖŽÆ4šLÌÞÈKkM^9­²+•蕪SGkëR9€=€uùo¥}ÚEþíä<œ`tMÈø™.Ï‚¡5v<ÛD“ÉÃIQêRΕæ®všTQhUVt§W¶Ô2åÇŸ¯(ViJ7ƒ|úIeEª1!ÊõööMìŒÍñ¾ê/jÝÕYìÞ&öƒE˜8àFnNÿ¶•{îÄj%]š?»'stð’}Þ+wE´29ü¶£»ÔÆdªN¤·ÆmúÞ á¥~¾Ê:)m7b=£q ¨ÐsåÌ£·ØwVÖ•£º‚OI‘ÓYaK…-H~—jB˜G©]]æxŸÖxYÚ¬ŽÁp*uÝi¶ºgo‡3Þ#iã]99Ó¹cG — G« CX7³Q¹þž˜§Ø\Sjðƒ!Ä Hµ‡'¹okצþ³!óZñRÌ &AI>÷ŽàcËF&o÷©H!;8+>ÏZ6ós˜ CÚn4Ö‡ácvE©‹TÅ0ÓP¢çµ½tå°¨¿´®Xà,e:ø‘¶qåéTYïÖÌç²òÞôÉÕØ@T†þèß6’1ðRcɰDU½€ aRÄ©k“!Yà(·¦ ­…^’ìŽPi ¯jOK´[[§ o×Rê«Â ÐÒ†‘Ã(ÎBA“Ë:vÀ¹Ñi±ªs²ÏõîÃÖ¬/›ϪÝÍ)Ç£wd¨©Øoûœmì¶¢Á€û5N4j”H¸/\ùT›ÒÇ‚£,d…I|kóÇ)ÂÞ0*Ž.¹²x£½ð±¨mu"Dþ*_Ÿë¸(8Š]iâ–¢61«PÔÞÝëØ«G¡ªÀ-†#øúÝ š„jT¦ O`†*ïÔš‡ÌóQ 䣩<­Ü´‰Ó·Ù4D—wœBTXXæãvI›öÿ«/-@4™£×B?3šžG4šù1LÑdB?™G>´dºÄî-¢ÉÜ‚t›!”ëèüÜ+ÜX…ÃâW“;4&>ñU’”ºbAÔŸj8µFUÃSÅ.Åq¸Î°Îc[Óä7C.n ¿¾Fª¤A8± ]ƾñúÈ+²›X£·"ˆ{éíbHÆS0…ü¡mƒ¨söG¸]YëGëÐ0ç€ôYdÂê¯<ǽ¶Á=4X!-o3›Ô©¾5¹ ¶få-/þn·”XºBq~]Å¥)XÏW¦P8u¤¾jo(N‘tþÙÆqn/ôµÜB3ªØ–ÌP†Þ¢(TüÀI(¢¥èPÕÑÔÑ•ïmûsx‡`iHEíV‘ä0«-« d÷Ò‡Wïñž®P«TKGhØ—Ò‚M¢Ðä6qÆÈèLñ«“,¨ 'X*ËÞàÏs.Ò)’ ˆ™Å†SJÑ=4¹Á®CBgì%VW¬±M•f½é;ˆeã0!•šúÚ²ìW®“ptè„;ölâýâ Êu-ÍJOÖ}r;âkÍy4c šò.Óh6ÃS2ø6œçFn*áà’7yýúQtèÏðù_‰Ž9Q˜qÏ"äeˆó¿mÐÞ þ-ë~Y]å¶Mý©ÏùÑ á8hú\Ïeц‰êéZX¡CÅ E©W€”ǨànSÚz½Aä8EëB.*jiÂÙ[¸B8ÐÃoÙp_3½B‰÷ûšKÎK¬øá)ÖËhD¹;…Ð]!OEÂÁùõ‹Òñ³-3îü‡À•Û|ÔjKœÄû\8`\jæc§G-öÕ:•GÑCßðߣ\@ELÌ‚ìðߣ5 ýc''º Rät3¯Q[ÒÕ†\¹Í&7§M¶K(~ë=½³–p/^Oè/„[?3£ðbH+•VúæT¢ÎÜ vˆvû©žW¿ÐE<‹–¸Ñ‚À¿æ¸¬¸Í®eñlîã8#Ä[lÃóÐ0 pAÜ0µ]$Šg¢´è2Ýqå0¡Ú± >/XObject<<>>>>>>endobj 5521 0 obj<>stream xµWïoÛ6ýž¿â–/uÚDþ•8YŠ¢Ø’fH±nê¡û`  )Êf#‰I91†ýï{G‰–í´k‡mi‘Xy|w÷îÝù÷ƒ! ðoHã ÿ—ÅÁ÷ÓƒA2Àâæ—]Pÿf@ɘ¦Mhòí0™LÎiš†]šÊ‘Sy–Ê/MzWWRäù¬— »ÎŽ^M? èdˆ­iïO~êßœ?ft2›ѸµØû°T%­MMº¨Œõ$èý‡ÛH—^ÙLHE™ÎISz¡K].HæÂ9JU†G¯MéŽÉ/±ƒ—• ¦DéÉš+JµUÒ{¢J1ÏUJEí<^D„#F¸+Œ4HŸ€´—)ák«f½Ãhæpv´ëM¢áÌXòëJ‘[‹]3‚cïš.µ#QU¹@µ‚Ãìõ6ðÀ³HûW»ò%ØøÑ„a^ÃQq³•°×*ë`Wàˆý„óm’öªÑ){?åèÕÖ*ípǃC„Ùéàê<¾{é*ääêÅ ¤i©¬ö¢”ê˜LØYÄ8×÷*_S&tN‰rí—œÀÂØÝðK{Z ]-—$àƒUŠpWªEaÊtÿ2Zje…•øã8¾Æ)ÄÔ¯u”ckº$¹3U¹à›+kÀ¹hœ0GÇ ®ªxð`h)äý§hñV¬Äå%ÿ¾‹i¹KbkrŸ MKó"²«»ü½©­Týw&­såúa8‘{vv“v›ü"•Ãq1ª€‹HƒKL­Ô<”R8ÿÿÌz³#j‘À5á½*ªP$¨³Rà.i«¥©¦gŽØI2ó¨!ªLˆlÀÑ¿aÚãhØyc ùqÝh*“Ÿf'÷ ð(Y!¥B)§0kM½Xó¼ÿç€æØ™–Âmú‚ 1-T jpöwás8T2Êé2f¡Õ· F£d<†Ú¥µªžƒ‹äE d¡6*ã‘ Y/”ÐôñÍ£T 7"&Á¼O ¤~Ÿ>ˆ¶wpZ;&Çà uhŽõ¼I:è‰OmÜåŠù<ÞftêðÍ(õ ý®\4 €…‡[àž\ü’¹Õš~³/ð땦.?ÛòÒyWežÆÿߊËd{ÊƹSîº帾·Z$”t±Ü æÎ[!ýkâÍXâÁwozg3e·M„[Hxý÷Æ刳7OÞaæ»·²‚íã¶´­ £R ã_§4·J4CÑÛŸnrQ<7Â:´‚&ÂÏðh¼jä9£èF†¬.%כȵ_£,Ô/L˜O0[&(Å+Üæ1”Œ°cSdAYÛ!4 h Ùî´k1ˆ­.1!Š4¡_]µÒ¦n³)bõ(xÖ C9½`9M¨‰ëE›íáùEr6>£É8¼gïOÆÉ€® ñÙÌ…øòsvžœ7=:K†CúQ¯ăöËfºn1Ç÷œ &Éx„¯m|õ蜗ÞL~9ø ÐN>endstream endobj 5522 0 obj<>/XObject<<>>>>>>endobj 5523 0 obj<>stream xÍVïoÛ6ýž¿âf ¨Äò¯Äu³®Ú4[ ¬Ã0oùb  %*V"‰IÙñŠýï{GJŽ-ÛÃömHHy÷îÝ»;þq2 >~4óo”Ÿ|˜žôÃ>7ôõnú4 G4MèrLã·ƒp<~CÓØíêÓ4 Êjž¥‰¹±ZD–¢LC¿©OM:ÏäR$Ÿ­,bCüüõtúxÒ§îÇ〨wvF?‰'I¦Ò’*$µ”Z§±4d©¡\Ú…ŠÏ)µ¯ ­Ûì[ËHdYËÑB”¥,L¸÷¥×ZiC_ª4®Ý{ã³€'JÝ«ù£ŒììôÛÚÆ°AßëѵZ‘0–­r£U-{6VXp×"+®Íí.ïCiÙlóJdõzm"ÒÒVº Yð}óU–Ñ÷XFÈ×R§KÏN9š°„çíCøzåN½°Òä”è¯OD‘°Ñæ?²@>‚®OÏ‘,mª È#‚±ý ŽÝ S¼¶$J‹|6Îɨ\’‚4Ô3÷ÒS ïl‘ƒ°›¸9Î&‹ûx›•¿wo½› âׄºÈ~w8ªk!˜²Hc%ÎRË¥,¬W(‹Ù‰"Ò©.60¡íØ“¼QÍ9-Ô ‡õy[¥V˺P&"‘vÝÄ7ä"*$û!æ)×™+v!6Åäù×´#ð•µûìÔoâ êjp¥Ô»yKƒ‹ð€–ÑNø%†—á`H?Çð+Š˜¸Ð½ì¼m¦;‡“Éfs8 Ïb)®UD‘ÊsÐUŸhó ç*¹’~½»ýGoŒY+sñQ¥5–³5ù™ŒCº[È ƒ7h‰Î‚XßsK«ªŸKJ Š5²S–J;·ÉÅkUAÁ,Ä•€ÙD[ ãc‡‘ „V•ä™ÐJé'¡UÅ©è^ˆ=ÍzcH^+)¯ñÝg&Wqš¤R·è (œÐ.w G‚;|"ŽYqÏóºnËÞê†t—/ø¨ÓOkƒÇ×a@iÎ̘Ùu)sQ2p·ƒ`‘>Šèi×}Zì hçý EêàÔ>=?6÷-ÊšîÔQÒJ-rá¸äùãJ‡£™Q‡˜K +u.ãT ‘~þr[sÔHÖ±—¥Or•?‘Z¨<³GƒØÝ½AäOý«H62ÜÎaH?ò„„ðš|9‹°Ö’!vÒÁ»›ó«V=ö]«†£.qpH›ôAè|}u•)#ïs¡¡k3 ÐÐ;lŠãjfåÙYk…0®?bˆ³N·F½¯Êœ/\w¹ˆ÷†9b>b£]лùûÊæÊØw½ù{è²â:ly‡¯Ã€N3 üLU |lÉѸ([1ñÝ…+8ÒâϺÆB‡K€} ã–lP7!œ7tx7¾Þ¼ÑÝÉç¯%.[ðÝåd⯭9åB9:¨¾(ë…Úñ>:¬ ”+&73tnîVü؈ ž‡Òî·¼T%Bv)„ðØB,QeM§Äbݲ|Á?ÈBjîÔ^,|Iº¤Ël»[°ªa*†=•ejeþY¯ÿ)A '×úrx.Å[ãš]áÒäwwßø†päÞpÙ‡£!. h7à ý4=ùåäoƒ1Øendstream endobj 5524 0 obj<>/XObject<<>>>>>>endobj 5525 0 obj<>stream xWmoÓHþÞ_1_Д˜ÄiÜé>p=z-BAR¤jk¯“-ö®om'ÿýžÙµØ};Š*×Þ™yfæ™—ýçhJüLi6çÿq~ôÛâhNð²ûeWôôlBÏÃ-RŠ&41 çóg´HÜ© -âàÛãÅõÑÓ³4øÔÇÆÑIs,ÀÓ4 #:«u\)£EFJWÒ¦"–´UÕÚÔÖÜì(ÎDYÊÒ«;¦)´§@8ŽŽÃcX .*R%¦,ÕU&©2dkM>]ü•$(7 Þ®EE‰‘%iã'5 õ ÐÕŽêRéKkÓ|5y.t’)-ÉŒ5¤ÅZ2€`ç’`H¬€¼…n•«JmàÎZjÚZQ¬¼¬lWµc[çØ ÇÎ&€`M½ZSÚćb‘e%;ÇààR W]dBz™eü¶‡¨•+9C¨,ÁëýaŽ<©DêJÁ i‘¦€Ýµ)e«Êy›ËD »£×o/ýÈ%åÔèz¬³-oD^ïVRfÌE2\Tø‹Ò–^*~öÉ>¤Ø8ŠÂÙ „Kç6C_[ŸÁ‰$(ê«LÅN–3ãÞÿ`ºù¥w¶{_"_rI×ùˆµ>¡Ô˜åãþùoîϧg-ÿÌÎ^é½-ì£vÑéE”빩KVSU2/*nÞ•ñnÛ¹ÌÝù”H?ÛŒ-i-0ø|äyr!ö¢5ž0m0öÚÒ„ú~¿ìÕ-ôƒê"‰+³‘¡ÿÔnPÍyøcFÝPߙڒÙj7±:Šôµ²h³U|65 ï¼#¥É%žÐX·V! %¾ëÁmR ·Á6ô I‚À`û¹ÍÄ:èï<;;$ˆ!Në#ꢀø@¤úxˆ•ëšÝö³_`¼gØä0S ¡v°Œôý (QVbCé"e+X’ôO˜Î숳ã¼*x@ÜÃ×¢gžhnô1¢ Ĭ(Æ (?¯U~¢ 1©•6ö!Lçf+7Ò¢{p=Xí ¤ës èµØ@H»'zi÷pïCõÝH-`êÔM´Ò±™Mwc’g_BV¢S!ï<äs†‡T2V©rƒŠŒ7]“öÂé|)XÌëá7]yë´ñEˆý,qÛZˆáÓ•×Ã]®a-ƒs ~o¸JѲ]g?xûшâ5úÕ“aczÔ­`Ç«¿ßýù~á•àÏÓ—oÞ¸¬\6d} .ýúê ±¸ÞГ]ûm¢Í~“skÛÿùu½‚bt(ÔØ-?žJo Ò tûLlÖ.¤´¥ 6Z$S2 83òû¾{¡v&·íø{ßoÚ˜¸Ýi_íƒÖà ¡ÏnÃÜ“¤ÛÜnmðؽ¦®ó®—ÝF•*¾Ç5{Ucý.:ѵ°«éˆ>¸d¸¿¢&%÷Ž'ޝû"ð«AW¼5î/3<¾ygxØZeæ b§{™­©3(Ä ¼¾ãŠÔ”Îó¦}F“ãðdvBógQøœg Ç{< 'ô»‰ë÷%tW£99ØhüÙñ3ñchêʧџrp{ùÉdÎ"Üf¡ò8zÁò¯Gý óÝ­endstream endobj 5526 0 obj<>/XObject<<>>>>/Annots 2550 0 R>>endobj 5527 0 obj<>stream xXmoÜÆþ®_1`ôÜè¨{•åôSãX± ØH£KÒŠ=ry·¹Ëì’:]‹þ÷>3KòŽtZ6dñ¸;/Ï<óÌœ¿˜Ó æ´¼á¿iy1Kfø„ÌùÇO?\ÌWÉZÜ®’•´Z$ëö¡ û‹³Ç’nçÉüìÝÙcIo׸ð½³Ç’æ«u2;{ ï4_®’·ð·¼M–íß;{„¿ÙàÝw›³à%¿£ë»±‰MN‹ݼ'77oh“IŠ3Ú¤¢ªÙ&¥P«ÿ<;“Ñe³Ÿ\QèìablMÊïfWt_{cwü0xMÿz½y¼˜Ñt3ÌéUV…þôåcrn ^Ž·þ2ºôo~¾¾[[ÉiŠ §‹eäd³×90©Tú¤vú‹*õðê„óøt鲦øÃÃejr9¥®ñAÓVã7ïuZ“.ð|t LQÐN×Tû¤=iïtØkK5"ûôËgÊŽV•&UEqì2[0…SYˆ§¾|¤¼±imœMè7Ø-Õ‘öêYSíHeKÁ•š.ëc¥/¯ðKèSÏÊØKÉíò®©/‰ß–ªjc9xUU\±ô‘ðÙÐíáQg:WMQŸÙpþ‰rçÇØ¡îÿÂé^yúóè`ÒF°X1‘_S–Ê%€x¶/è+ Ú=UÌÌp1ð‚ pÔj°£û_?þÀ¨í´Õ^Õ1¡O@ÅË"žiªÃ øwò⊶MMÖ!i. ò® p.ÅêÊC¦ºÈÚìát³Å‘¼æ:StÞdòÈ…þ@L¥yágOî`Q^p1õ*¯u&%>þ#4º²A(rÈ;r¡Jj…BF¨OK}÷úî-qð9Ôkº¸a˜ëd¾HVô£ö¨f©lÊœÆOoƒðg»!¢ßõ_^áWIÒùXG¢°aª¦@}€ý¾Ùi´¾WGÃ}íþBnûˆ:ʽ+%Þ+ªÎ`®‡&ÏÑ>;ÀWêôOØ&ƒ!&tåÜ1Þž-1€p'$f˜ËuÅäÒXS´1;Ð/•¶™Ä•çV?½»~÷Í7}g {Ï=µå Ktº¬œgÚr!>+oÔ¶Ðb¨µÊ%Üëò2VªÀmBTPâ ¢÷Þ°[N5‡õƒ©÷èx$u¤ÜXU˜jHPäs1T kªØúE§xTÒ(&ˆŒ0Qˆï”ßB?qêžÖü©£Ì%t×™$Ú²”“H•e™ µ«*øìaÂǪ>ŽKÅ5êbUªŸoãçç#jºX$Ë%V6yÕÊÜÃäÜ&÷Ïæ·ßÓååÐðh||pý¬ýÕIÍ;Ùe¹W^ÚXmàR—…ãN©yä1ÔnD9U-fÚ%H˜Äà1ª]íÊt¡ký0yx=Œ§¥(ÜmÑÓ[Å)5ªA¨Ð½\Ü–«LP5Ó¡ö”ìk±Î½þ){Áÿ-kú^o›Ýìý*äN!6LŸVy¡n¬¸-'2¹ËD”ÆÙºz€„Éí+/xª6ö„ôO"ЄFȰ ‚Ÿî­ù½Áäâpzܾƒ†»êX*eñ¨ÂªWsgðZ(!rÌdg-ÔqPÀHš^¦_õ‰Ù49MÕ„îµLý¾¸]#Vpl±È\jÀ“ ½œ®uËï„ï¼w}fE ØÇW£  f‰&Áð&˰㉸ÌäÌfXÖ cœÐ/µWT8ižëˆ^fà<âh?†Ù ŽfÓ¿§{>}ûhǃM"ù/§-ë—ÍFs}™ç0Ñ ±€víÃ)µV˜3¹k§%7¹ã}™¶* X´4M×ÖÍaKœý»Tœ °­Ç.ö\:k0~PiÔh ”%ûl&qùK ï8˘Ûûøec”8¢„\ÝÞòüàðâ.ÃÒÞ¿æa‚ PmD†Á‹¼ñ vüÖ*’c0¸®î‰ ýx‹}b´óñÀ«{ˬ“l åN½Ù‚EhTÕ2’£ëc2Е—d_—Æ<”çàŸçQtJû\ïqÁ•5²3Aß»´áÎG—cX3w!-í¥­:ÚËJ'BšPÜü|\KyŸÁð‰Vìý€å›~¶XoqËGÀFR@ÿ€N+Z<§Çlf.EÊv»æ„³Ò*Ýw Ÿòºâl¥«øûj¢=ߤ^%²›c¹Dpµ$ßX+œ¼µº-U}Ee~ºîbøâ =À} ÔüÅÈìáQyÇˬ”@ÔŽ¿W4XsÛúJQ‡ÿ?qêíüt%ïEIúæ<,üÝû1æjWcÐ÷bÛ»æO§¡1øÖÓóa k §¬7€¢6àdgFÂè†F Íöd&"{Û"¿˜­’õrMëÛ›d&ÄL›.ñß’ñ-l\ñðô —­û²¤Ÿeè¿ñÌè¶iÙõì&Y.3¶õ~sñ·‹ÿgS€rendstream endobj 5528 0 obj<>/XObject<<>>>>/Annots 2580 0 R>>endobj 5529 0 obj<>stream xµX[oÛØ~÷¯l±¨D´x•´ûÔ5쬠ۮ¤~¡È#‰ ÅÃåÅŠQô¿÷›9¤Î¡“4Ž I£9sæöÍ…úã§þ| þÏŽ ooøÅç—ßß\„‰· $N¼Ž´Œ½h JºxQ$¼Õo‰Ì[,Âó ÅL—>’F^ìph°pE…rDGn¸ð|J,סqq´d#,סÁ]­¼µÃ5j«A­Ï eÔZ¢Áj• Åë!Hk\kˆs â• ’qÜPÖ›37\z 9\‡f{C¾Xn2²+xÃlN¿Œ CYµÉD?òV %¢ Ñ(ñ–.^ãâhˆ|)G-\µàÂd¡¬Ú`â­PF”a\˜‹-סÙ[6Ýá:ô‘@ eM| Ai,„5i1ÂI®êÌŒ€vf"†`ž\-£k†·!¬\büoE‘ÌsHø„ðÙ2eQl,…BŸ !‚–„ ’rÒjŒF7¸¼"¡,¹œ,„)3}‡fƒ8ÛÑ™k ò‡t.Ö^@‘PFÔÒE˜pÜ„³ëÈ:42….M†ÂEˆWðC†`¥Qà2Ì(²sY0Xpa)ôù #Ë_ÇŠùœ!˜õËÆémÒàš=]Þ¬Q7ˆÙf‡6˜¬oÐ&—¸ M6 º{wû†Ò*§¿§i›5Eݽڼw.“F)—EäCjÇ­t SÆ .›ýö š‡B¦RÖ5ˆÍ—.Èg÷A²¤éùOµðé¹ÏöÎþÙ¨²8UÚªe9¶À°~﫪¨öâÆôÆÏYàãËp´!^|Õsþ‰ªj»VBvý1=Ö¥1IÔÙ ˜uýO)~[éSE·mÛ¿TÕ<Ö–œ¸oŠ~´âó·U§öMÚºšÆþªQøÁ¯t®¼÷-]ìTÕâÜ“$mÝo§ƒÖ|þëyZzQ4¤)ŒLšæáÊ‹gÄ}ðüä;q}ܪxL¼NO8™VÕ¾@¼îgmŸïG_SÙåM2,³qÑ0H+cvÿÊ3«Gnb½W•jҒ꾩u«&ÖWŒ|ßXI8>Œg:é¾älÁø©mÞ²¾):Ô/^Ó0ÉÒìø€“  µ7XŸ-·‡ÇaKiø&A71‘ neM½¼Áº/ë÷ì.Ýa¾´›Ìä*Ò#ˆ.oÎö<¬¦GFMn:ŠìÀ•8ØaÂ>šq†äÕ¡ÑÇ¢?>ÉŠßTdæ ×Ñdb;ýe+È”pô­YÙìì ž™N¤ ÓTÉ&qž¶„'›¢D‘Kºu­ªykF®ñpÀµ€—WÄ¢B—Ö|{ôîyµù—ªçÐ2Í 3˜-#ã–Þh½/Zø“¸}1Ä-ï³ó_·OE¾WÝóO\Åï§Ï}cñÙºÿJcè“Ç3™XÔù©sŽÞoº;>OŸØ,$áf`ÜñCéJÓxÔ=Z×]‚{‹Ôž9¨6TJXÁ—²Ô't€ŸÆàñ¯°!à{ñ{D*Ÿý8ˆ*³ƒòYð¹²ÀûÏ„üKQeeé‡á°wøaràÇÿNHà†öY~?ãÑ‹ñöxÿêçÉ!Ž+šËÝh-ìË›óS2›‹çþõÒg“¾ü„ã7Ç00OIQè³’ëÍÅ¿.þl4OÒendstream endobj 5530 0 obj<>/XObject<<>>>>>>endobj 5531 0 obj<>stream x¥WÛrÛ6}÷WìC”Fbt±eÅÓv&uÇN“¶±Ú¼x&‘›”¬~}Ï‚¤$’RÒË$ã¡(`/gÏž]}9Pÿ4óÿpyòóô¤ôñrû'‹éÅ›Sôi:ÇÙñKõC Й"—Xj™ ‡ëó¶‰HY’ÖJí”H’ ’Jd,œ‡ÆB§ëžKKY²f)IË–E¶¡4“iføbŠä\iÅ8Z>#? F\Ë!RƒÑŸ¢Îwd×*¦½ràÙ†$ŸÄ2Md ê`ôüíQ0Ÿóí›yÁÎDÐåóç¸ç¤¶ðÛ%¡l@«â}QÔ‹ÂÚ7báóÿ1 éP‡™NZŽèÇdMž…’æ*i1§Lóó:iÐ䵋[?ÿôTG§Ð=ÀÚËšïÐh'”¶ŒJS‰Y÷¹’ q©Ìøˆp(.3&)4Ëñ£%ЉÒx\+·ðgÒ:2sÚ Ñ2g˜ITŽ¡“`¡€—w*›µb÷ð´b·à¬qíÊx ìm$3µ‚ëyf–þÀþa¥ÓÜù£½v%X]R…±Ý÷ÜJA8B¸NwßM µCñ6z¸¼(€YKøP¶ËøQŒrËoÀ\Sò¶¨kFTø“9¦&ø¥y®CÆ»äz¡Â-sˆ«ˆö/JšÉXY'3ï§Í]=÷UiBkãoT_ïò2åZDGp-€Ù‰l“‚¡ÉÀ¢Ôèˆ{Ùk‡HÔ_%nÐ¥ÉÀ “Cùg¥Péæ™1 —‘Ï;ƒ÷Û»ëÄÌDr‰v€\|”s°Û?véöî×Ùƒ ýËï líý³zð â†àW“¯«Ëʨè`<¸xñVù?üTVvëý¬œ\ ïŒk΋ ®´X 廸Áɶ¶/„×*(Õ«ßn ›HÈ-rð‘9Xζ(´Ý‘i+ –¥·Ôù—ÄsŠGvo8æ–Žƒa0¤¹Ö\Ú)´îà㪨­£Ë÷Nƒ­ 2sç˜v¬$Œ3”µ4P‚›ƒ<Úa²Ù<å~°ô‹Òù“wó^„h|Ç>µqô^éëOtßù¤tdÖ˜6Òµe#L䉷p@6xÚ:D®"Ñ•P‰˜Aùy¥@æ‰pHcY`€ôVR+Ï*‰¾¯ÇQÆ…Øfëe·Ñ™ü’cOi©Z¢f»E=&c÷Øý:æRä1œWˆ.É º”k.ý1˵˽>/XObject<<>>>>/Annots 2585 0 R>>endobj 5533 0 obj<>stream x­WïoÛ6ýž¿âl¨ƒFŠÅqò­ëš¢í°v‡n˜‡‚–h‹Dª$e'ö¿ï%Ù±¼ýЦ0,ñx¼{÷îñüõh@}ü h4áÿIqÔûxÃþøøúhxÞG4ž^â³ át›§œn؞Ɠó°6˜²axय़f¼—vEg×ðܧْϛ\â[ŽÃ—¤—½"þ8™}9:»7–=RŽ´ñ䪲4ÖË´^Lƒè"æDfio>œ\P½ÚžÃkÑ`È«?jáÕZ~ïml¼¿ká«JO‰Èó…Hn +¿KèJ;/t"ß/»Ñ§FÖèlŒ½¥J§ÒÒÛ›—ßQ›D4œÆ— Ç Ò,“TZU{O©\ËÜ”…Ôž¤^+ktøž G )5ý¢tuGóÞï‹JûŠø?žŸÄôIéÔl¾NéýÍ”‰µ¬wxéP@r(¤Hus¬ý¶H8ßÊ¥±ò”Æ0à7œ  Þh/W[½_/6ÇÓi4'™(=J¶1¹Œ#VÚ[œ˜°Ê̆£¬ šÂô€lòÎKí`xE(‹èп§M*ã/!¹‡-U't*ÄÛ4mý@Ü‹…LSî“\Ü*J@cÕéO8%NýöÒJäìšÃéUc'ŽŽšwYƒäyþp„¢é܈”sh<Ï¥5HÙணkP¢ÞF."§|ƒÝr+T=F!p—9Üð9¦k¼¬Iß/N±´¨Tžò{È9SÙD2߬“ù2 m+ÝÍÐU©drÛ$°OšáÔ[)K¦7żÇL‹üžœ7ZFb%ç'T‚çø–ÒZZ&DnÓ›%÷ ‰á¾Îm~øðbßb Nå8V6õïK>0äBãÑOiï(5iÜw!€6”²WIf•‹Ð g¨É§o÷bßJzªÊT4%zÄ¢% ;ëÒ< qâ nÄõÂu_O»H U-2ÑËçÏCÍSpwr{ñ«\-,ë£B§¢…m•(‘sq`W*è¼ÕŒÊÕ*"ɉB¶&`h.VÁ';=è¹À'Þ¸žÆ43Tˆ[hU†7Ž mJÚÓn2à|ØéAÇÒ . IÉÃ…cëôÛ»2ˆE´º/;¨´ ]ߢñ‚ #á} QçÙuX_W­ÅSÔÑe±uÕ2² «¶S]NgÔÞm=èZ)Ï¥KŒ^ªUUë2-¹P%9@aÛ @LJ@Ð&SIÆE_ áöbš¼½yÿ+W°¾¡‹æ'×ö+žÓÞöXcë3l€³À€ „„^³Êå3øg=‰<—ª¬ž›z‡Qm»±¶à^ ’úxOáŸ6ÖБDÇ^X4£;¾¢¿:KD]c¿fÃgF›Žå(Ê\Ÿì†m­‘ÁùÖ2NîîŽO·Ÿ7V”áý}àâßΛ}‹°ºk‡g®•u×øºâî’è}Q–óšÌ7ŸÞ¼~*ÈÕF­(ú²þ"&"E t¢É›#ç  c–Anþç^اô£j»oÖ2¿“êŒÇ˜ÂõÚ¤{0)ÊíÇÉ·`Î%ZÇ ¥[%k¦zˆúÄÓ ¸›"ø‚ÔÝ™xf%F'+ŸÉÔµ>îf˜¶‚aJoîLnϧ±o|Î{ÇñYˆýì£ sßYË·ùINûCa€_/ç£sš\àN„»ŠKð+æg“T<Ün‡6àW[GõÕ„áW½Ó8èM>ÙýyCϰþý1øÕ«ÙÑoGÿØÞ¦endstream endobj 5534 0 obj<>/XObject<<>>>>/Annots 2590 0 R>>endobj 5535 0 obj<>stream x}VûOÛHþ¿bŽ{ªÄyÈ©TŠh¤×“ª6ñ$1Ø^×Þ¸Óýï÷Í®'W{3ß|óÍì~ß«S ujvä3Žöj^ #òU—¯Û˽úQÛ«Qçøß5ê-¯•¿…ÔßktÚ^ƒZ'¯#³Xu”¿ÙÙµ÷ˆšÍ¦w¼6»þŽÙ“cxp–dï»Á‹(Rµ×¢z îœàÁ·`ñ0.Q¤S&Ÿ Bö‰Ÿ“PÅÊ:¦ £i°`<ÄdfL‡ƒ‡5ë6TX/½VQr¶9]8/QÆc1çÉ|µw²„Ri´¥ÔèxM¯îÕiêùvfZ› žºå|9ˆÎ×DÚŸ‡|@zôË4SÅš”1i0š¦ƒlœ‰ù© >pVêǹ™Ê ¥a£sd#Z±Si{'…›Á ásšê’„㌞fàÂD¦-¡¥éKâF ŠKB[gF…Â'À)òƒÌV5~TSöèƒ5ed4˜ôÜøÊ°ïÑ-Gz(0”r¦Ãc¤E9“5:öš’ÕF  ”!ýBÙ܉©LY ÀÓ'øoȦŠÝÕö: ¡ÈBƒÞG#ö}àþÊ£ÇÀl†&nDÈXî¦%Ô$åÊ*\Ä÷©ÿ©‘/ (¼Žƒ0¥*}¡ ½|ü¡H̼â]|f ÅŠ89æT…`F#§Y5BÔ4UQ$$>f&á|›€'F·êUD|–@ÂtÁ uÂ)]èñ<âØX«›{–Êö°^Ê)¶^Þ¥4ÎõX«„}¿´P!šX#O)¨—ð,=–oY}&%h!ÙºÔhJjyågiŠ®ØÕá=éyèS¨õ#…Á#C:AÖ-À½ª™Ÿƒ(Ñ©¡}(ý‚CžBˆÞl߯m•â)i¤u¯¶ä¿q`ó°tÕ¿ õH…çPŸÍ-O‘},ÓUÿ“-V ¾‘_Ùðð÷Ü~Óä)0@Üç”·$¦@´ç4{‰Q|Óþ ø©°eo…†¥…üá¡ò}Íè ÖÊáa7ý>*ªy3﹑a 1/Ø ¤« hx¸…5˜`ù¦õŸÞÒÍ—ëk¬Ý‰l[ŸÍçTªÄ¼,#(çÑ–7ì•WL•éñª_l;+šõ-+ÿS¾”­Û]ÄiADÈ*ƒÎ6h‘õ‚¹7¢,Þv4zƶž.¿!g³k5Ç3dß á§Ð$_"rPEÞ]¢j•úF¡„”¨q5ºÆ#m{4}9 ‚Øçgof¢&8l7p­¤—(t¬·twwÓg·’eîñ>·ökî·C_™˜§!,,8ö(³²±ôl¯ìÒé¾€èV«¿žV­çÌØsKQ-V#_n¯ói\ì2 F»¢ üþeȉ© uÝSzai™%7°Yx§ûBUµWÜÄêÇ-¯ÝlS§]óŽÜÍ¥ÿõÃe¥‰ûìÎá‹ËŠ[]9rÖÝ¥‘l ”vkŸ½‡ ‡F~ÚÛh»†»eÃÝ÷ZÍ–x?Øûcï?C1”±endstream endobj 5536 0 obj<>/XObject<<>>>>/Annots 2603 0 R>>endobj 5537 0 obj<>stream xWmsÚFþî_±“Î$r$óâ´éŒ›Æ;¯5$þP:Ì!pFÒÑÓ¦þ÷îîI€NâI§Û{îÙ—Û]ý}Ò‚&þ¶ ìÐ_”ž4ý&¾¡K‹.·W'AØò[Ðé´ý&¤´[~§%Ð?Ù§¶ÂÊlØîáªrmØíùí½µûãΚçþùÞ,’€N;t»žûgÅ€7Ý SÀ- ÒÜÞ0…nÇïîÍí ShµÎýÞÞd€ìº4;¨êyÞA®nä¶ÜQÏ …kw³gÍŽ[Ý&¯= ‰ŸÑZÒ$ìñTØFT~¦‰ß{öf£›)4.ϡՄÁÓ9LJ˜ý‘tüÐü®oO÷'Kܧ­g(ë fÒHP9Le&H@emRa•Î@ŒõÒÂÂè©iª²)°@`L€/ìz¤âÑl¬£e*3ËU¹’²"‹q#°3ù-(»´Ú(‘<‚Rcd wr]íœàÊ,’Õu[¾>¿‡Âdr·mÂFÒáóJ‚|°2ËÉtÏäƒH‰|k½LbH´žC¢æYªü%6.›ÐóCr]€Ô‚ÀCÅÞO*‹’e,á—©7ðߟýZ0 ïí ¬Yó†»íÄňÉ`¬u‚̘ÎHeÊ¢IÕ?rèÝô¯=Ékê\[v\®1n°Í1Ήåv®¥^컇ڇ¾d·°Þ_Üm{ù^dj"s[ÛFä ©I‘‘8†Sk,­PIνMã¿8ÉÍ3¿âw~-p^êß]_Õé;ç÷ÃNêdë]çÅÃþ¿_+a€ ˜ÞÎÂ6ñ{38ùã仞ìxendstream endobj 5538 0 obj<>/XObject<<>>>>>>endobj 5539 0 obj<>stream xVmoâFþίQE8'0ÆŽKI¤´w´'µR« õ _ï‚7Ø»Ž×8§ûïY›Žòî¼ìì3ÏÌø¹5€¿Žé¥­_æ­Àpóí/_C†:ÌW¨;þ„ÜÊñ!ò2mØZøOF«ëùS«?5ºÞm½`âÉ8  †þpˆ+î}#)îcî´KEûÚbÇÒ,mWž2©Hβ̋49QØJÅõU\×èÜÄVRä¥è:ŽQº•¼ˆÑpg¤±ë¸@ñ8ÛïGk»:гúãñGºâ<@ê4½Ý©So¾ÁY®3‘è•kpm0™ˆäJ  ¶bÙË0-PhX È…â"¤‚àc¡†Ë?‰R4¢h÷(;Á]Îé”òrO&ï;ãî&ÀÔD¹Ì 0ytgsúdÚ÷Ó~½ëªOûçœL—šW®*zæòåt€°Î+„) Òiª ª4:G¨¨?S“1’ßµw64\ÝSü¢juP•æ¢æë›¦MÂ;Èðèþ™KLû§Fdö˜ÿy6Jo¬rº”RšSõR¤h% Âۗ愵¹x.e.\ ¤Z¢‡'öšܦš—‰0>ÎßÕÌNªïæ²€ýE&ŒÜ0šuÔÀ0ðB(ƒõ…‚K|-Àâö×UVK“6Fõ„Œì\à “æ& FþÍðÆœâ5?þùú[oèð¹)FEM~‘oµrïcýJƒ â‹Ï¯äχ‡,Kddõ ¶¡"¶‘¿k|7Z„H!}4“Ó/óÖß­ÍI¨óendstream endobj 5540 0 obj<>/XObject<<>>>>/Annots 2608 0 R>>endobj 5541 0 obj<>stream xV]oÛ6}÷¯¸0LAmZ¶ìxèC›ÕA lÀj{˜‡Ž–h›©$*¤¤Ø(ºß¾KRR,9 š†Ežûuî塸øïAêO”\ââŠþòô×çûï‡ä‚Ùœ¸‚?bÍSëÁ4 š×»Ó…×>éÝ÷› ‡Æ«<Àdå‚°ÙƒïBxë‘0œÃ&6a]ØDη›ÍÃÀ…±‡O±0,¨<°B —ðWo  ü« ¾d4eh4d'šæ Ž®¬«D)#fœ·HNÃQûøåIÒܬÁßW.¾÷Vº³;YMA³‡1–<ö‘CS²³9² ´½&Å"œLÄl|8çv¹1t€+(‹¡°+y‚?Ž Ø©`™â"[6^ž©û> $:v~‚Æ+D"ÛóC)™õÒÒKo%E ~ÖÆê yžðˆ¯žD‰í˜M1á_¸z=«Éxš YôœUœ‚d%—L§×NBE%lZ oÄÖ’‰!dò™%Œ*6iÚ½½ù¥¶GÖ‘ŒÑ$áÙÁ<$bGHYqñU †˜ú;Š:3®{îìzã€udrˆâ­s_Èà]„æ:9|tÌé.¹.wát%D7j 7oêÍnýЀþwäV\*Kx*â2aýñ«vçÂL_"hŒó·×C¡g/—¬â¢TÉÙŒRñ<Œî/¹U@³¸­ŸpøhEy¢KngIE"oë÷u»ÄÞ„±i›Ð¬>%úM5èwQ«çz%|¸ûíÝ:’Müendstream endobj 5542 0 obj<>/XObject<<>>>>>>endobj 5543 0 obj<>stream x•VMoÛ8½ûW Šb£-KŽëíbmwS´·6zÑ…¦èš…D:"e'(ö¿ïŒ(Ém8)ðèÍÌ›7òýd þÍ [п¨&V“„%h>ê0½M`É2Xm M`ñçŒ-oaU´¨V"(L³.%Tá¶]¯~Nˆgø¬ˆvø@‰w#ÀÝ}Ãk™G½_~ ï¼wðË/øo`¯j×ð²O…î<öFùõ3ЬU%¬Ïã}&ª’o Æ*ã4몌>ªZ”’øOoç$® ð¶Þ-ò5…@¥·˜ÞÁ¦6ՉǖïÂÈì% Ør ¬ãN ØóZqj@H[ŠoFoÐqÓhá”Ñ¡Geö!p[î@p}å`-u­ŠBj KSNiÊy¤Ž»åטûãøÚºš ¬¿KiÜ4È€â¹îC ±9®X-ûõÀÝi W øÂúI°Í:%·VZÖÕΩ†÷!3m ù3lÈ'µ¥æ) ëF•·åî?œÌÆÔ­ÍSĪjwºIò“yÌ峆/|Ï­¨Õή€ÚßXYø ei¶•ÕXŸqš²,Cµî²m£ÃßPËûF‘æ^±)Ñ.¦ßd)¹•Óóê($TúO§P’ã¥Bœ¯K½—ZI-ÚMtNÉîhß0U_Rû},N‚yE=ÁyÃ)Ð+ê ÐzàÀRà 9¥€–Peì,6‹l4ó+|pwˆ;SwS÷÷‰ LA®žGÍ’c+Ž(Û¡úÛõ5Pá3·yyV²ZËqÒ¶1¬ÓçI9ÇÞux»‹CÇ{@FiÒû{¦‚=¢5 ¬¶ÅâIƒm ¾éC8ô’zg .5žÎ­)ÂÜþþ†}lÐi…-;ïdÏ; lüD£ê̦Û3”Ÿ60a¥œ“Åh¬4ζËãõü·FënQ¬aª —Å=Â3„ŸøÞÀû¥ö³x>¶²,QL¶)] ¢ýÚ’#1Û5î²._ûH±1þƒÆÜKGø;zõ£ot!7Jðq_ ÍKî/’ì¥ÏHùùž×è¥ô—´{9÷Y©z—4˜ßyA¦É ìœB³6–ìôvÙýö˜-çì&»Å2éýÝ÷ÏŸâŒ%ðM%5ý,0í WÝ£ã·ç›³>Ò xÝ$ –¥ø+ïý<[’éßÕäëäF—åendstream endobj 5544 0 obj<>/XObject<<>>>>/Annots 2611 0 R>>endobj 5545 0 obj<>stream xWioÛFý®_1H€D,Їî€ëÊ©Ó$H#¡ùb Ø+‰Ée¹KÛBÑÿÞ7»ºH;.Ð$PÄÝy;oÞKýÕ ÈÇ߀¢ÿ‹óŽïùXá€?>½é„£ÀÃn4õ|Ê)òG‡§ŒÓgì†Qs÷ä»ÑÄ‹v'YìÉ3vÇSD¬»{òœÓÀØ_–'T-ßjMý+ŸØÅrE¡O£)ˆÆ´Ll@>-ãn/ðÏ–·ŸðÝW¤½-ýDÃËÃÆÓ+Š=QIqÓ½9kÚEÁÀ †Óp4Œ†“éx=•²Jsidõ< ½IL†‘?ÆÓádÔëï8 üÇ1<ãfÐ¶Ž½\ÝÉ›îÀ?‡¬7g ·u‘ÈUZȤ±Ê <4VFOÝ6 ÆmƒBÞÓb#JxnùœW•ªft™ ­ Å¢ Bú*)-´…I…i‘†*Yf³`6 ºËGÿjHÜÓ+ê¡÷{úWƒAw†LÓüòýÅ"®ÒÒÐÌFV(5¢£X±ÄêJUsMJí  â$)â ­ê"6©*l™¢Dk-šcµ©êØ{°ºß¤¥z_¥!Où ã%M_·ì^£?^“B# €=ºª+&•«JžSRWi±>žÎ¾„,PY1ÈlɉÁmUèbÝ(³-ÛÁ“ZYì“T¡Ó`j c8nÁÎÜ¡»¶Œ%a›©Ä(G}½•±ñèâÔVJ]Š,ÛzÛYQj¸=G5Ã5Ÿ³J+mzVwJd&×8•)‹'·ou¿ßÈ-VY´ˆc.J¦|†Ñ—+‘fÈç®Ú’¹<¥j§ ½ÁÔGbsíÁü³¡…îc©=ú¸ó&-¿³Ë&ÊLðdÅqZžB.±bÏk^¾¸Ñº×'‡ˆ"±A“opb¹¿ »ç¶€ÝôÄDc«þÕ”pc ¸K¸G&ü5é†#oH×y™É9\ÙÎzß0l;ð&6fáÞŠ;¡]ë¼WIA­š6h#¾Éi°*'éj…+ ‰ô¹˜b•—V_$K!óe¢X×b-¡ªYU%œZeƒÄ­m{G×e©*CÇSO¥<Ä1›ð©Qçbí#ÆËÆBÕ’s©’V“¸€­8­x5®ŽCÈ.£N±C÷¹£ûNÝ¿=(æÅö&=G˜.‹.…‰7b@DÒ•q`»ÝtŽN·‹Ý…ÓLZòñÍc~4‘Ý?'ßA`jµLß..Ÿ¶E‡'IÊÜlOs%!Ÿ¤j#3 %=k·”(tt‹ª«U³ÛLlôlrˆñ¨Ä9z9i{`ò}|ø~»AzËEÁuy0\Ò“>w2ïíÅbI¦(]-2Èw¥êõÈ’ç†AŽúnpÄe/…Nm¹bŒ¥ {ÁÓÝA Ÿ²©Ù¯«»UšÉÙ^ïã{k/ ½(Â[lÒí÷w½@÷)êÁ½šíï\s0yééÃÅû9½(0Í^ìYÙ}ϳMÀmŸqäËçÿ4àlNô›M§» ÁÓוe“ŠÊÍ\ÐßôÏþ½Ù‘p–ûbxÚæÿ=ø>%éžìîÅ`2ðð¶N£ñÀó«òâóõ›^„Ÿ7¿ª¸nŒ@hæ¬{c÷{á;£rˆ_EQˆ™Š„ ¢){œ/;tþÇAë/endstream endobj 5546 0 obj<>/XObject<<>>>>>>endobj 5547 0 obj<>stream xU[oÚ0}çW|*/ѤÌ{êX;µS7¢ö ™Äd®r›ã”]´ÿ¾/; —t]@È8ßýœco ÀÂÏl§øzQëƒÛ²L 7õ mÁÄ´Á]ÃÐçÝÀtœ pý­•®gx!Í2˜Í¯".%ðLÓ„?ï;îSË‚sôr}£ßõ~M=™ˆŸà3ôTò$Îj¶U¨n¶áÁò‰>ÓÌ<•KO0*Ùr6Ÿî¢-ŒEGel3½îý09â¬Ël7?»JË\ØUfº<ˆ?Y­490xÙzÍx7ÊˇËùôëͽKÒ|rniä4`'g{˜‚GiÈ"Ëí€kYx,aVå ë<ö MS&ÆçÄgЕ¯Ö4¢[ ‡Þmû…lCçECݘm–{(˜îe.Ña?_1œMϪ‰ìSda<'Ü? À«ù©uZ«‰½¢ƒ†Þ4óÑË“½¸ B.WÂ!$`Rm/ e!a.ƒFì ©’„Gðhî±}¬I%¨}h+©½ÆZ­I;Úê)(4•RµØ^Do¬ª®˜¬ZŸmA«²#$¢"ûFÛ8Íå¥2ÍðÜSÝrt7ÅUÖƒ »)ÕЃ»Ò;Dç¬9ëÁ*IBàÙ2bÑŠ‰êIð‡ªªSɧ†@5Â}¢? Õ¤wAluø¾™ú¬•ƒŠÐ/^ჶ{´O“Ì´!zy’ ÅY§­á1—œ†üÓ8€J“Sûý'2Ú¿ºþõ í®a0™c{ ÎïXoYߘ?Þ|:·M >&^^;Àñ*-­Ï/Jåsl`žäÂc0E^`-Ç´‡xµc°ÑÈ*¶®ÜÖ—Ö_`ìOøendstream endobj 5548 0 obj<>/XObject<<>>>>>>endobj 5549 0 obj<>stream xVÛnÛF}÷W Ü¥‰ºËªŠ>¸‰ìÔHœ4ÐE®¤µ)RÙ]Iµü{ÏîrIk;± ƒ—å\Μ™3_OÚÔÂo›ºýoNþœž´Â–ÿÄŠšW-†]š.©Ó¢ÁE; .hš˜S-šÆA³I¿¼þs>½;iQ£ã‰9NïYºe‚øf›² ËT¤xžÑ,¸™Œ7\)&&xÄê4e8«Ùya1ÀÆñ±Ñèø~ÌÎé‰Â0¤oG®ñäÈŒ³>¹«Yç™T4Q‚g+ªÅyÂæ¯[k^ýFíŽÆ§à~PЄý°Coa¢ÌCjÿÍ«i,–€¿Ñé…=ÒešÒŠeL Û„´_â’bÁÌ=ÀQkF‹Hâa¾´ïUŽ iŠ—å--saý ?ÝDûHÆ‚oÕÛ\°ã(Š£Œ ßí²„xf_ƒ.H_|à‹æ]i§y'ãg·:âPVžéú÷‚Ù½SðIÇN}gûá}•Å5€NsR"Šï p¹à+že(ªÁÖ¥ÃóqÈw±+‘¨: Ñé„Ý.ú! Þ<ð5*Lp-cj$l±[5´çÆ«»eJ×1å°æñš"ÚJ?–WkŠ(a¶x|ÏÿF·ŒÃ뻡5k¨'2¦¥ˆVúô,8u±Ì³hÃNAêZSÛÐ4M…îðè÷ ¬2äÇ6+†{™jžN ÚRœFRj–ï$(Ÿò{pxÍåèÕÌʯÕ\ C‰YA5å^ Ó;¹–oçRO—x¾©Îü÷"o;*C¡`˜61ƒ‰7wr wZ'm€…ˆöñqÜ^~Ï?^Þ^¿›—sÉš"ü1X;.kå'¾FZȯ ¡úþz<Ž¿ü„ù’…É+0ü6zˆº†ª’Ûb,‚KË9ϸrÈjâbšËØ‹éµ*ïJˆú¦cÈÙê?›\Nì 7:ÚóÈ35îu*9¢{Ÿ×‰…«°nŸ>—¸g ~æìA™@ªŠCó„ÕP-T§t# ?¥Ø=iå-Ñ“fVA \Ù× —¶Ruº¿™|9ðT— •Xì»Í3öÍÄZš:3Ò¦ÕÙNi¿ÑŠ&ó².Eb¤ÄùöAK‰ZG 7z¡»"ÖlàÚj4*šÃ·ˆæ•4Á üUúß~±í¥©ÿ‘ÊQzÓkäHI`DNÕYÉQE¡oº K“Õ7_è™™+pÅR¾ÑÓŸQÊ¢Dk€NêÀS}ƒñ«Ú=fPRkÊ¡ú,}C}ß‘^pr°r<†Ý~ÓRšÎ8Ì|wï>½÷]̨>ú+€ÛgÝŒ{ï<º–ô.±aj'(tšæŠ×:6[™Ž®6àÜh)3»J—ŠåëØ¤>T,)z|W›mòd—2ˆSÊV@ëŠ^[ Ñ ÉÓ‹ºÜÕŽ½(?m3»Í,s¸.ûWë88ºÎÒ¨9C³dŠXÀÄ•{]4¬Ò”žÉïJ_舚µšŽ¯l7 ö}Ú² ë×Nmw •M‘±!Hš‹H ì+TQþov–jë¦éž µ³9 ®óáО[ b-«dÊÊsSójXô|{Ø ûÝ> †ý°mw’É?]7ºa‹Þåñ®Ü¬u*ötãÂFðâ~Úo ÂnË)ˆÑëµõÇãéÉß'ÿþ/“„endstream endobj 5550 0 obj<>/XObject<<>>>>>>endobj 5551 0 obj<>stream xÅV]oÚ0}çWÜGˆF_)ë´‡ÊJ7­Dåi2‰<;s´jÚßuHÐX…i!0ι瞛œãïµ68øjC×5o?®½ójŽíàâîCEÐ;0°»à…ÐqÀ}ݶ]÷ ¼ ßå€ç×À‚¹bš¦@8_rN}MüP`BKÐ+ 2ÓI¦!dœ.êé¢a7¼o5šmD r”VeeÔÎ7dq²¨2ˆ–X4à-8oŠíÈ+hYV‰ 9%"…,ɹɄВÈèá.=ƒÏeŠÜW·íìY>±‘kÔ†è\”%˜LD Ã|Áç$Mïˆ8U%àq Q¡©šËK£$ªP¢"¸™LW¸ÀÏêt@Q)³ùäýׇ%Ù²Ý_åÂY‚nˆbdÉéË5},.&ëy”PÙ}FÿIÜ0¾fR¼\Üqp1qÏ£„âî3úÇâ.Ÿ $=W$I¨tIü5êü' ~$"ÊHD¯¯+œè1ÓE¥j³h­'=u¡’1ú¼H5%æ_IWöí“¶žKЬ‡E¥òn9–îm6E%1¡ b <›RÁPnÌ$©v¬éÓ}vUû²À[±bªW2üf¦†ÖŽó4y*ÅhÊ#¦0±(¬¶¶¾SxÿýÍãÍl8|ö€“†X?@fO*’ªhÓ£q‰ƬÊ%‡™V&b,Ó׫í¸vkFˆ#‡>¥ˆC±Ó^. . í*cûŠyXÈ|Ê­ñŒÓ‡Ðôì~·î]>/XObject<<>>>>>>endobj 5553 0 obj<>stream xVÛnÚ@}ç+æ©r"0Æ“¤j¥4)MÒªi‹Õ¾ U‹½†m×^w½MªöÛ;»Æ€£\Ÿ¹33˯Î| Àóõ;L:o‚Žc;øãæC. ?qàÈö ˆÁuÀ?ؾ?† 2(‚Ðh’q¢(,¨ª®gV(Ò\ÁTI–.à0% ¼<~tè¡« BË©Òf/ÐÎ\ͬ}ˆmÛ5£¿ú®?Â}ÄÆUÏõÖYYÁ’B"¢‚S ç9”h¬Ó -–2Ågw´îÆê6‘Q‘d{’FM\ÈEÞt± ¬˜Z²¦ÔÈB‰¦kH¨ZŠè¤n)ï¹®íy(@„É+¸:ýz:=ûrù)89A73룈(Ò;;€?ÚÉÕ¥jri”¢²÷z[ôÌB`S„$]dA×[Oš”š½X†Ž6%U…LaúíòÝ÷ë÷U¥ý#45ôìÉIS,ðŒ“wþ+Q¥#endstream endobj 5554 0 obj<>/XObject<<>>>>>>endobj 5555 0 obj<>stream xíWßOãF~Ï_1ÊCecò‹ÀQñppp\Äݵ$”‡º²–õ„ÙÞtw Uÿ÷Îzíı““Zõét²™ùæ›ofwÿlõ K?=ŒÌ/OZÓV×ëÒâú|‚£ë.œz˜Î ß…Ñ»ž7À4Ì­º0å€ÒLG¢TÃ'5Aí;¾ÞÀá ‹ýƒŸ¦Ï­.thó4$[ÏóŠ•^¾òwnpt=óy–vúƒ"Šó0Ç0Õ(£ô (.è‚Êø˜¢`¼v»“Û^ÆL)ûEé×qAϸÕB¤¡ñg€#D h 5°4„_!dš™U¥…Ä𬌰¡¡Óï{ƒ‘:¹ ÇìíÍwî®&WÓMÎ6Ã-‹/ï?_¹ð)°–¾“ºÐV«ä,e ¶ýƒbë^6&o:2!ÊE œ¥ðˆ„_Ë_0„L™ÄJÈ) þA^#=¯ï,6¬¼o…hºG¦b\g,ŽWÆi¢×7 öL¦ŠŠ[C}ÃÔ¼8J)PÊ1ÑÑõ;0>f¤ãNdœõGÞ±w 7TÊØqµä¸0LåZ³¦¸Œú’*»íÛ¸zCãäýbG<'XYVˆeL1 ‰ám' æ"‹CSö#h £&ꅪŴK Rì i‘iœgÒhØ(sãv‹LŸ¢=¸ÀX¼Q(K–,(VH]aj>“"!e‡H¡ÅKd@>®àBFd{ÁdJñH*sÚOVðXˆª”.µ¤aXÐ[mýŠæ_DR'ƒun"¦O¾3ž\ êÙ¥¾Ã<«€ÛOîxò‹34«›}4&2 $Î\>gòÐh™ô ”BÝ|¶ìø"HØ2ˆ‰#=·š3ªÊçÊ_%‹ÅÜO¾>>#Ïmb‹|­œQv'@æ\Óf’'k3´‰Dÿ¥^¦Ÿá¾ÜßÞ67®9И,„drµaqï¦j4"+§ÈFݳEEoh‚F¤ˆ¤Š:Ë7'w*‹uÁõwuÎȬ i*,³¾S©ôÎúæ|lÆcy$‚™ä™Œáð¨V9Ê’/V~1'¶uÑþ¦f=­gµ§ã‰eñR"Íýw÷ÓëÓK»è;m‹âþîv‡ÓµòÄmÆ4)*¾/y+0—š`&~Ú¡fF%ð;Œ‘)4Áv¹kn¤ŠÔµ²®ZÁ…0ÜV+·ÎÔ­Õ«lª¤r6¬'bã3[FI–TX s÷[0š@›"ô\žþ§Cpß©†¥93k´>8×Ýozxª§ Å…Zhw«ešHKÇ•ZlsÜÜBµJé8Ù-áfüoϹN¯`&‘X®%²1+íÛ8Úgmw×ð­ÌØjìÒ)u/´iF¤Ü´oùýn©Vt³¯×HÚšýhD 7j.ÇÐ÷Ûˆü×FÌïLå%ólÅâÚúÝtcD‡¹›Áù9¬»òÑrZ<%{§Cïxp #úb{“‡O;¯ Ϻãços_¡÷­µîœX}þÛ‡Èqwä úô¡÷Çp84>¯¦­_[ÿTÇ>endstream endobj 5556 0 obj<>/XObject<<>>>>>>endobj 5557 0 obj<>stream x•TÛnÓ@}÷WŒ"!9Èv}oñBHJ£‚qà#˵׉‹½¼ë&ñïŒ/-ñE(V¤Ïœ=sfHèø3Àr«'Ê¥7ž¤k:&ÿŠ-\,u˜ix ˜:¸/ Íu/Á‹ë*¼Hø5õî$Tãc. …— "Ê‚¤(X`6¥[&ú²…E•ž(0Räá1ÈÝŠjøÓW½¿{1É8饆¬îxÐvj˜ÀkX­?‡YI<¶®¹ÍÙþäËX1*ÈQ(p_½ÆÏ>lnn†LnO‚ð€“¸†l°®ˆxÓ¼Ì7Þr6o’ëô'©tˆŒ¡FØ”—™hUC`_ŽvañÜŸFa–±È—Ï+Àš%M‘?ƒ\­™QÒQ ×\éœñ)èO$#!ÿÇ#ò']2àðÿ.H ‚dzPÃtíTGK*C' ¢ñUÓj/_ 8°2‹á–@Éqä)±#0œÊ ‡ðô²2cwwTÓÔ, 7)–SšŒ#²)£þ´ãݾs«±íÈWÓq¿õ7ƒGEº±ÁZ u}Þt@ø¡T{Üaü's–ïÓŒ@½ÛrxÆÇW¹ÑÊ;kå5f¶æX˜¶ý ÏúËõ•ji:¼eQ™*ÂJ¥J#œES­^6·éjŽæÀ»ÆY¥ýâAS^ÍeÞ‡ sVÔ„£»šeâŇc°m§Â\xÒGéãK’9endstream endobj 5558 0 obj<>/XObject<<>>>>/Annots 2623 0 R>>endobj 5559 0 obj<>stream xÍXÛŽÛF}Ÿ¯¨Ç ,Ò$%Rš}³g3ÆÁn6Vñ>PdSj‡d3¼Œ¢¿ßSÕ¼´âq&YØ–U¬î꺜:ÕÔO7!øÒ:á¿YuøžðGÈß¼»Y'~@Iœøkª(IüdJz㈅¯±+YéÊÐF×[­ÙÍFÌn×~D‰¼Ó­Ù£d³“ -6ݹZG®( ëh·DzŽäÐ0ܰ!‘Ä_G†a8Ë֑a8Øù¡£µ†£`4œøJD²†™=xë¢ud>vË.ÎZk§qöÃP ‰äž´ÖТuäÙð¢µM{ïB®À¢udNcÈeŸµ® ízÍ.ÏZq9¾³€ ƒ-¶ZI\vd8Pl]­#C»á$;{Z€/rµŽÌÚú±£ueh£íÕ^c¼³`LŒV`m8ø´`ÌÄ"Ù ,2ç˜1ãh™]’pæ½Öp2b&àÿc‘lž†Ãˆ]´ŽÌyŠ8Nj֑٩;ÎĬµ±"•O¼åü‹À§®9iT;`Ý:+°îíÞ!aˆöH¯îpLí ðH²‹ümDû\$ }vméýwï(­sº7UejúJwÍûŽ5¡±¶‹°-‘Åþ&N`íöMYªck>o`q'ܼ-°[ùí‡(ÙÒKòj/dßoG7L«ô±¦‡¡Îz ¿ë^µEš©·÷¾`›ì¨Ýö&Ï5¯KKñ—ºVôï†v×ç?ç/¨*XOÇÁ‹ÛõãáïT­Ú´×õ‘Ø7:è:‡ðwK…iéþÕ+ÊL®þâÐëNµù€/r"éº7t´9Q9ºT0“Ú`÷û”òî¿z|ÿõÿJþ©úT—ÌâÚŸ„ɘ›hóûrƒ–A—} ˜¾ŒŒO›øõÃÄ^´Ûzöx‡[Hw”ÒIO^©žT¹¢´,½fhÓ©™ÃG•õžiµBCç+Ê/uZélEÅØéèà¦5Ç6­*n¨2­CzTtÖý‰JƒG'Ýõ¦½øÀD¿phÌDªÒúª2ïVÔÂÛ,ZSÑY(gMSÁf ]§u/™/Ó²3À³& á[3€‚¨Ëàz¦HåC†ž7õµû“j¥øW¨?¥5ÝQ®‹ÏqŒ®šRñ²h(¦CJ03O:;Éöô hI%»S–tJŸ”c-.ü8eí*h@Ë•où?Z>¼¼P74i{F!¤þ¤èz_M\ÿ2 c)OÉØ ª©&¿t’™arŒ–ùµÁmMæ#JÀŒëAøœ[vËÀ€Áç‰aŠ”A 3ð”vtPª¦¡ÉS@ ®ë¬r5¯eâ<àìÞŽÌW¯|úÞ ”¡ˆ­JŠƒ•“¥Õ)Î9¬ÏŒ[Æ„Th¾ß/3#üÙD¿½ŸO £•”yìÏWte;—ÑÁ¨ã!r…°¥x2_Þüëýãä¡  »t½ªÐe®ÜVâ]2D]£[-mÆ8ñéÛºÔ?*b Â'2üÓ [5b3¥®bàwªç&)ÍÙŠCºGos/3ŽÅ‰ëî‚/w“>“/¬2 ¤Ÿ†x¸ØÈvœáîf²óP)4ôÅrCŽzJ?g¼¢1€n"ˉ{CíP‹kYQhÐA> ­Eà8û¤Ú •ºï¡TNëWtæ>]Oµ²@…¥Ø*ÄwG4LÄ €{ñR~Ûõ‘<9ÈO²ë£iý­}ìq€¬ “ØÞwx>ÏO‚w1ñIpà oüÔ3 žÑLˆdè$‘¨W 1g¨¦1ÐagÔ\Ùˆ—.‘OoÁ½gð0¨ÔÏM™¢YOx6oœ÷\¡IöK‡ò±Oi«Í€ÓNp¦”3È]›ÃXXI}„spÓä³É0ä×fœ¯Kr,ù[íáBaJ„¹°½*– t±É£dº–{-¥™ã¥¥8{3°¥ò ¶/† £ˆŠ (•ÄÿvDœTÙ7½~ˆ§:`´ÅßÜùQs¥»FeºÐ.ZMœëñµw·FâðÒ°•äyÓEÏë/ÊU!Ø¥­cüÁv . ð"A3ËõÂ@¸¨*2Þh1€ep£þ“Ù«Âw'´G6`|¥YfZ¾d3V8qãéó=˺Ƹ–Š{üS{ãzýCmþ›ÛTÞ…¦âî~hk¾£aôòµ(&gø=𬗕Ê5& †ÀSõ•·F†PHŠ%3’û ‡%céàÜð4Î ÞX@óÝý×Ýç–÷€´çC`›ƒùÄ}~+chX6{RÖšåW}æÍ$„…ÂHs•׳o¬W‚Ó ƒ¸t·.@l–¦;J‡'¸ôÜíS¥å©Òùd@Þ"Æf_(Ã0öwwxM\ã…Ú^båí6æ_Ã"Ëo›MÂeùróŸ›ÿËdWendstream endobj 5560 0 obj<>/XObject<<>>>>>>endobj 5561 0 obj<>stream x•Vmo"7þίåt—…ÂBÒD=µ— ÑIU¥^©úá6Ê™µÜ{³öÂqUÿ{gì] m) ¶çå™—g¼­ôñ;€á˜~Ù²õnÚêÇ}ÜÜ>Ê9œM¾…AÓeÇ——0åþ¼Ó,J.â$NàNhQ2'õn&“0“šã¶§¿·Î&# 0©÷’QtÈ WA²—ñ¢N(ì$qÅ£W\äR ØÀyãsó´ÿÒhoß Òv-PÂm Ê€ág{½sŠÁW™ƒ+áÏÃvaJE*?ÙXf‡Gä§óõÓ ßïßž>ó×½{þW³ ÀkQðà:°Ü<„¥rc3käŸÐ×–I§3‚ºE\ï!¡ ãûç!¯t–F+#9f¼s£Œ­J1©tÚN# íL·ùÏ™Ã<Õbå mw=®"m7È‚SòBÖÉ0¸\=`1ý>ŸGÒ/ÊO÷!»ø¼ß7â)i ‹Å{চa{¦ALõº¬,Ùf_Wèj‰­¨ ö|¼}ß…w?þzÛ…»··?…”<‘²‡ {É0/¨)nLY [Ï_bœ[ ó2k¤¬K‰ c`å²@<>“[&þ{ã¿^^¡±i§s_K©Š 8 D;¡Ó=|Ã-¾)ˆy˜686üd¸AÒx³ÿ ßõõµ×X—¬(pÚ]Á:V: QŠ\i”©+$Ü’e¥üÃ4Ž*Jm½™¾ZØ-K·myrcôJMÒØ,Meƒ(¥ídF£OílìC¥ Tóñ³÷Y”f®¡û½_(c ȱ’+¦*Êx0µGq¢òá‡Ôp‹/ðÎ^­¡cPƒoÂö!ôC¸³Þ*b?º" IÛØ„Áœަùñæ­Ày#vÒýîl†ð½ý\–Ö5æŒÙ ÎÇÏÞ³"@7XFFbH~ÿ=lb½:W™Yx]ôœA¬„‚+eß.0y§•ÆËʆå3Si^À©]Ëyh.s¤ñA®´•†ç’h„n*È›ô)èÅ[3 –ýÁæ‚¶;õÿu`ÅfB¬4ZE¬H#…ùU 8 œwÀ*_Ü ’á";©jZx§h~ác ŽxÁ¾4¡@àºÂYã=¡ãA¾ß?X¯ˆû½ŒYÑ+ ;JãÞ&ñe¼NœzcÇ lÀ„t sŸáÿ£IÃÚ˜5ֈ˹Ä„z-;Á«4íÕÙ8.ªSÝ x§Qöi>¡5ª}Ç£ÌÕÅó÷Ò{6¹¬_§—£ø|xŽ/’I|^‰h$÷†qÞ› _Ò´ÃI£)3x7éÞEè¯#^7Ïûãx˜à¼ÃËl4º 3·ÓÖÏ­¿ôúendstream endobj 5562 0 obj<>/XObject<<>>>>>>endobj 5563 0 obj<>stream x¥WMsâF½ó+ºÈaµ›€1ØØÁ§]¯q¹j+»¤R©(åF#¤DÌÈ£¬sÈoÏë‘1 W,c@Óýºßëžù¡sJ\§4ó¯\v>Ì:ƒþ7›?vA'Ó]öG4‹i8 ñ÷§ýñø‚f‘·ÐLtø' •åÊRÈl"#KYá·ô&3ëæ®ÑE½žÛ+s) EVV±1_ogvÔ;E¬¨%VøQºH]O2RÎ Gx"xK–ŒŽØÐ¯x2Lî5ž„4 ÌY-¯ðhYZ¸w$é›0ì5’¼ê»Zd–[6@¯Õ×+«J‘U)ÝÿO‰ï·²zÆð(\/ÐQ2{Ke­±Ô½Ó+‘¥1!²úç}—»es”·ª†bà N¿Ö™s±ãL,úlúbóî»pB;Rº\"“R¡ÔÝo»G1æ6Y ›Šy¦¨ûîx'ß]ØÿgÅ=ÇTCÝÆÇ›H£¥pJãÕfGo²p6ÕíÒ@ÅVwG[µR ïìѧð> ïÒbÉJ"ªNÑþɶF@ôöÕ\ȿĀOW „ˆ)tuuõå×»[Z[á÷¬4‘BE£‚e7¢Œ¼©g©¢U…¤ó&p…¶gRw—(:ÇàÛâÑ8Äq:aTh\JGsa2 ƒœ&Eb,fi‹ÁÃK‚&¼YZæ/¬ÿM“Üø¶j…Ð[&ÑW´>Z¡»|¼¯Xw©ùØ8Õ§Ä^Ä=°Z¸Ø˜]@Iï×{9 ÀºaÕíE‰KÍ)×–÷ø*»´ý =ËavrƒëÌ¥USø?ÅÙ³Bq}Ž/&ÀO‡£.ÕÚ°aµ Ò¾h·_L[6/Д÷‘)1˺´sƒÓ[™4ÚKj*JkÅãQ)ðà%i2sxÇL>ß|Ü [Õ|òáÓ/7‡Wn?ßÜüP‘>™ž÷`L=4Co8ªŸ–‚YâçÂÉt\¯´=BøÉ7@‚˜(VŘä ¹DQ‘+™òÑËKë$•I…°q­TÄv%¦%–p<øÑ„ñK×Þ¡O¿™’¤ÐäJ«ÉèÇ »a4ä¹¶PZYáR ^Mñ´ÀÑæ@f°Úa›Eïwmþ(Öé¢ÇEÜåarF«¢/K êD¬iãRÉ'ÂU$FÈ Sô«³‚ §ræ£4ïo÷,ÑëéôŽ"ö>(Y"sé[)SœP ¸ñý>)Š>¡ÐW êëàÁ>/XObject<<>>>>/Annots 2625 0 R>>endobj 5565 0 obj<>stream x¥WÛnÛF}÷W T– ™ÖÅR÷­jHÚè‹cE.¥M–» —´¬|}Ïì’)ËIŒ$c‰s9sæìÌòËÙ„Æø;¡Ù‚ÿÅÙÙ8ãþ1áÿ¾ãohqO”ÑôMtSÐôñ¬ó1£Å<švžýq߉庺»¦É˜îS$]¼Å/‰Ï…_âáVêÜE÷ŸÎÆt9½Æ³áßb¿–´·í„)©´´þ‹‚ìÎPlÍ£4¥²†R[ÐFYˆR™ iårJ+û‡FdÒy“Ø…t¹5 [-LF„(œîSåÊÉdÊHšüW¥{*·’|Ô íìˆÖ$í$§ÙȲ‡Z>å¶~8Õe úÝ[J,ž+7â;¥5UNzÿ½ç±ô;6ÁS@—JQVÈž¨B¢âGÙ·oØFôA–çŽd¢eJY¤"j¥%¹*Þ"§—TîsIƒD=>”¿ H9Š·Âl€øÀ ƒÛl™[kàñ7, ­{,ÖŒÕtÈGYìQ³Ù€D“0Îf’2&Ò•Ušz5\Ýé&š±h¦¬Œi4›áS2ü5³IÔ¥l›~À°2‘¯†±2« ÐÂР‹ó÷XíQ3¸|æ¡ÑÎ`4˜ V9‹ æ¡–ŽÅ‰€Z ßq!<$¶ZkÙÄ<á®t!Рפ~#P ®Ì³—öd:£ð1yˆ­Õ¾¬&om®6† Ôô&ƒÆ¦Æ¦L¬«FÌu´0y‡³| «ËÙ,Z,Þ0;÷[¯¿«»E}Ö‡^'‡†ô½‡$ƒz]Pdè†D±©2nG»­‚,0*“W~ ,qDJ–*ºßÕèÈÕkt0ÀÁyJšñŽÍG•)- ½€NÁµU¹º8ÆËP8šŸ(Œ•1tqÇѰAa3Z6YÃP=Tëç8ï‘öŽóöxâ¼Ë0ƒjnX4ÈY9m &¸ÏÛ&¸Ú4*:ÝÈ£ð yÚ`Œ>èLr3`”cÇvîØœÇ«ÐÁ‹–M[[­>?ÓAçàÕÚ=ge i£í¥î!3ã ®“Kd¥fHDïÓÞÐ-¡ ÌaÑCÌÜ`d4åúŸÈ*ÀÞÀA±¦¼!(Å rüôPÝ(xÌ·*û‘ãÛ©ÙÇn9ÞJ¨ ;!ˆŽë†D‚ î©oé®O‰ÖvçPwÎ7¤*üÜá¥ÕTýLÇÅ„¡¾mö°Í„vrtV›Ûgk«ÃqDex¾Ñw@e<°Ä|;øð4ë[p×Ùÿdè0ßú¡[öÚÈ3å€:ì1ŸŽgåjˆ}ˆõÂÒJcà@˦M!ò\¸p`²î° Ú…6´I¯[]œÚB ó¶wxXÝž;Ë¢ÊÔŒx>kÄÁÊp|„&  ÔhÝ”[çŽæ#–¬„=/Zù$²§²®œØø_ø¶AÚÚÏTßxϯ+¥Äå-½{Z~`ðm=ya?áÖúÞÐ:åûíìOýì>›p[šãV¶º8ïe,ýXÏ}ÓTy.\YTñ)*Ö¢`8Z8çíw·ÈßW¨þ³>§!‡ŸÓ¶ nt붸¡´¾ïÿå'ýÅ‘?ŽfñŠôëŸsÿzä^_‚^À¼¡ñCj|ÖÀ×¹÷»ø:ß~_çÛïÞë|û­ ¾Ww7õ}ersÍgsZàÿúÂϳér†Ñ?mìï†~$òÁ‰Ö—o‚bñf:Åëè»Ãáòîî=­•ñó·˜ùxͦx‰Â•õúú-‡ùëþ쟳ÿûd«Éendstream endobj 5566 0 obj<>/XObject<<>>>>>>endobj 5567 0 obj<>stream x¥Vmoã6 þž_AøPÔEÇIÚ´Ë·]¯9†í–a_Š-'ÚÙ’+ÉÉe‡ûï#¥Øë¬/XSŽER>¤ôØBŒŸ!Œ'ôŸ½ó^Åø²ùÒ+Ìb¸‰Æ0Ï`ÃäfM&×0OU ó$\„I>åßJ¥-œ~ˆ¡ÙŠU?¦Ù‚85¹²’|q¶8;›ÿÝ‹¡Áæék¾òß,Ó”gɆiX„A±{0VW‰  ‹ã`ñí[æ‡x†LK%¤åú}8_‰ÝäZãõ(€Ì””“œãùÚ³µGþovÓc-ª`ŠY49¼î½|æÝ°ÐÄhrx©Öøïsoçð>ßv]ßšú¬’$͉ßô!Q*ÀwÉ1É1:%[+”$);–ŸUh–0-vý†ÁÎúcWdu¡>Xì&ñ÷¯íö]ÊQh¢@:°…Ì…äN’ˆ¾é^z0ØÙ©ª°aP&‡t>£¹ãNÂ}{|˜n”H; Êãò^„Lk¶{ƒoGòœ½:O.«âH'*WÉ¢å¹ÛÆ_î>íÝ6,¯8L¿òÝVé´aº–ŠŸÝùóîÿEøüåîî×ÿÑÀxÓ8è²àý³Ÿ`8¢#…Žþøj¦„£ëh„gÍg.¹fVÈÜÎf÷°2Å2¥áöü•rªÈ`v DH†Yt]Ò™2_ ´äÌVšƒUðÇ_÷ŸQãΣaÛâú†ëH¾&S0Vä9dxˆdZ½(sny¿ ›¬AHØ »†ª4” _qsËjšÓ©g\ý޵X1½4Ôü±â †(J­6„j19¸ÉÍówy¬„æÆg<ÙgB?9?o³‚*i8Ñ~K%:qi>/XObject<<>>>>>>endobj 5569 0 obj<>stream xVQo9~çWŒšƒäX6!íÝCÓ£ÊSïÚæ*$dÖ^pµØÛµP£þ÷›±w—„…ô’ˆ`Ïxæ›™Ï3þÞ@ˆ¿ˆFô¯[o§­0q³þȗП\ „i‚º£Ñ L¹“ãNÜùÌr© ‰`¶È…íJÆ+ØŠ\Û0™²E* Ñ9ÜÂJ0.r1SÀR£a! 0‚£ LW,˗–šµ-`hm©¥Z‚ÕtÄiÆÝé·VÂM¾a½á0ˆ"\ñŽbka2 ø õN¬5<ÒT¢px N™10Æ ¡ ‹TÆÎçà~’T3 »× 3$í÷!ÖÊØ¼ˆ­ÎÍQ³ÎFK>ëÂãþ€ðõÏ—T½Ë‡Jû¡ÖÆ,¸à<2t¾äçÒJ­NՙȪ^ ‡Ø¥æ 6èįsuVn•v›`7ëuŽS¡–væ{äGýú(¼â½×Û§á¹O»’¦÷'×”§sZœp `,³2o›K\*dÁó˜ØïeH”ù3X̺el³ëá*ð˜f“^¤J¥>ËYšŠôV¯3­„"ŒO3X(iß2C˜«LM@™àúœC–ëoXB,Ýq~U4y^xÇ(#ì¿V¹>•Õ’x>¹§jY§tü@£M£vJ´ öÅwK¥ó5Kå'< ßä‚Ùwþžk­Q0]Ss¡^-•yBíÕ5ñ_uãWkÍ œö°Ù¾’*N . M¢ β6eâ¤ïû/wïa)µ*8$2H#‹˜™cÅ ˆÃΜmβýáZýfÁ¬ôÖ«|æ¤K‡³”I·“É;†½°>/XObject<<>>>>>>endobj 5571 0 obj<>stream x¥—QSã6Çßó)vò†Ä˜åZn2s3´%wm¯éx{e‹S¤ ÉôÓw%;NBHè„H–vÿ»ZýÖ<¶N!¦Ï) †þ'µ®Ç­8Ši²ùer8¹á2À˜C?†áO§Ñpxã,¬Šaœv&”sq•!Oy©`Òi'O†Í“1Z—$ ˲$iÃæhrWs-”Cs4~hÅÐ;%KYh³EÉ›§“£ç‹‡ÍcRFÛ ‘¨rWÜ?–Ì`VËÙšó¢¸ÔÌí¸|!é=^3aS)ÖWÃý¾ØFx;B¦ߣbÎ “åžÍµBåj9;óÿç`J%Ü5³Â~P¤E÷—ÓßÐèZÝzâ²ö§eÁŒ¯ÍP‡ÿ®½ø¯Í¦º WÅÙÌ®¯ %: õÞ†—½Ð"Û9ÇT’ÌJé¯Rýå`VêZn"X_°\ $‘¶œn³w¾ú~È¿Þ(‚ð? àw¦2=ûB%öS§ÍúóÛ¯’)ºX{mè«Òpr{>zt ½þ FYg\ èÒÍKT¾sƒÎ-!×:ƒ©ŸrÀ™„ºÀl6yÉœP9èBF†úR'´²`Ë´fÁ‘Õ”&œ)½ä®ßï r2‹Ü)„'¶ÍW ê{ˆ´Z.¼ñ°vnôTâÌërfì;»œ¥¥­f *6Ch(AbÑ Ò =G^J¹ô› ±¦ /eÐÁHAZøÜÿ1ú´¥‡I«!G…†9´]`póùî¸è×m·‡^¿ Ô,Œ¥¶¡+HfI=uƒIç•zœt8ß eÑ罺1LŽü§–ÒÜ¿Úä ]A§CÀ—W„ ÏtØ“3yLôô¡r·6°.ÿpÿŸÚE+×î€6‘ oáÇ~ŸiëÛÜ䯺yÕÕ-X¦Ÿ }Ünâ®dû0«TÖq¿ðOÀ”cŸˆÅ⯻2­ÜÉÀÖ”·2»±lñ–“©:kÏVíö ÜÁúw€pF[ÍùJ_MìVêV-¯—®záAqôpÝתôîÓ»²Ü4Ù7jÞ^Öx{K–©ˆ{K§{¾‡ cŸæu‹ÝVQ]†WJa•à½(Ë z$1Hus{;‚›ãc˜é¬” 1³ µ£ ¢Ñ“6ß#¸&ÌŽÀÓÊÓ–˜·Zb ½=™@Ú@….¡ž A|]ê’8ª`J,õ,m‘Ksô¾Sí÷ ¤˜f&”~v­ðræ‰5âÁjÁJµ„Ç’å‰Þ%¤çy3˜3—…èÒ¨ %‘1ó6C¬uœQ©Ð¾ 8–:‚µÀ7ÏY¹žô’Þ‰¬ªyS w.ÑGH|¦l´ÿöþiƒcyÕM¤MˆødCaˆçäö²îrýø,:œÃð2¼{—½AÃÏ:-gôH=L+Ÿj‡ÕÊÞEEœþED ‡Oö½ÄÚT¨Œ¸6áLS….p£AŸþ› 4ž÷½Í_Æ­ßZÿÄ©ëendstream endobj 5572 0 obj<>/XObject<<>>>>/Annots 2629 0 R>>endobj 5573 0 obj<>stream x•WÛnÛF}÷W RU‘I[—ö)qëÀ€S§µŠæÁ@±"Wâ&ä.Ã%uAÐï™]RÇ $°ÍËÎåÌ™3ÃÏgð/¢dÌÿÓòlŽp‡Dü㯷g³8¼¢ñ8ÇTRGᬻ*èáìøO'—áåñÓ£k<]…Ó£§ðBÉl&°O¸»`³oæG¸hê]ÜÌàŸæKD<žNiž¹@G4O|®oµ•u£ôŠZüA©É$)ÝZI-kÑÈŒ–ªöåüãÙÅÍ%E8Ìæ‚˜ŸgƒÛ†”%³l¤&-Si­¨w|â 6i tZ´pÂî‚L.•† v{ú~ŸÂÀGÓä’DÛ˜R4*E±;ŠáÊz)Ré# éÆÔ$·¢¬ 9¤MŽÀ­*2NR8/0*ÙàúÕ+6ïOû3ÿnjQ…évKUT¨Oþ´ifY j5±´3-‰,#ár½¸:ƒŸú$_äRd²ó§ø (SµLµ–!Ís˜ Dé1è£ËŒf˜8lNÿáŸÛ·O+W¾ÇecF?¾¤ó/†!Š_tþß7ÿ⟌h >¡¦15“WÙà¼4Y‹T;;Øð?ûÒ]rºÙ·²…9ÿÜÇÀÖýéçÁÙ?GAÕlA•†Ò¯§)°™ NÂñxÂÞ_g™âÔEA–r±–@…Gy˜Á „GŠÁ„Yã=P¼P¶:0Áñh¯)z”g‡ü.—õ4ª Ïp(©ÙU’2™¢kîz(šv4 &!‹ L>ÆÈÅÛë9ÄÏ:–ÚZ±Óo;è¾úk$ÒÔÔŽ÷È€ TC¢ª¤¨-Âu(„Êåë­?¸¾ýƒx MëðøÃ4È5³¶(LúéI. sò2‚ør¹ô€dsS7i  d§ˆ ödïºêÅží_[ýYÈŸ“)¯XS¯XP¾„®ïnÞóK_KÔS™sÂ9xæÀ‘FYľ”¢ik=Ÿ‘bý)¥n\ñ¡,¥Ñm“«4g嬰X ÓDZˆJilÃ/sË›Š%˜9kw¶‘%I½VµÑlÕ±‰{Ì)™ÐX_gQCQ\¬¨¯SZ„¦=·«Z‚'C„Ú ™û;“‹vµâû×w÷Czwÿž_a «¢zÕŠ•› ½Pªhª‡TËU n;û8äN¬e¶³ 2H ˆƒÆr %L‡ôZÓ‡(:u«-½[UŠ!½¾¾‹˜Ü‘úµs€zÝq½*‘~ Ö‹ÈiÁܬ¸Z¥®¬j¢~N®kù¹…Ð[ZK ÅB5 KêØ6C7>>¶¨¶–*·Ô—{åyV˜Y (ðÞ‚Î'{Ü+ùÀß´(0Ñ„Wè OòýÝ̓h†Œ’½¤¾‘©ÀxîY˜+Ô¡kYv ïxšÝÜÜ}ë+ÍZcF3Pw8”ÂÐh¾°¦@–hwˆAUäaŠ×N Ùƒ|ÔKE.K—’VƱ¼+²>‰ùóN&y!·G ãü²psùè=TÞêñ“8šZ¡†¨蔵X4Üš´oáèBy æ8Ž9þrJRX…4}ô|÷ JÝRÄc® +ôþh”uÜfºÒ}u4=z vôzÆ€,MQ˜ ãáÅdôzŒØGàÁýâloó¨áXpŸ…uBb¢°ƒ 3–שßK~€©¹,ªNЯúùÃÙ8¦àrÆ£+ÂWÀV2UK•BÿžÉ<ˆ°]€l4qàr UÓ¶B.Z4JÂd4q{/¶SR耷Ċ°ÂÎå:V“o"·ƒ:Œ¬ãì8 –­v;•ÚàDiW…Y`ßX‹ZqY­_N á•ÙéÇFqi0à‰‹nùèqfïϵÃÁ6½·ëøƒ­ÊgàˢǠ_e^:àî€Ä˜Jß‚ÔÝg‚þwšÔ>‰¹ŸÒìã ƒéÓùßoJWmÓñ¾_|ð3Æ'Q2 '“ˆËÎ$ø¸ùͤí~d²K,{—áU‚‚Oxs­ò£Ÿ-W£q˜Ä^/¯6ûûüìϳÿ”–1ªendstream endobj 5574 0 obj<>/XObject<<>>>>>>endobj 5575 0 obj<>stream xµWÉnãF½ë+ ºˆöˆ4µXv”“ÇŒL‚Q0‡‘a´È¦Ô1ÕTØÔæ ÿžWÍE 5Y‰dÐduu-¯^US¿5:äãÛ¡Þ€ÿ‚Eãý¸á{>„Õ%ÑÕè;êtiAwp{KãЮû4œî×óºô 3¡bC‰¦û§ÇO?ÑTéP陹ÿÚ¸õ©mÞïvû^œ;C ©3•h’i¬dJÙ\žì§™Ô2”¦;úôùñZˆi I’I¨"¶d<ÃB+³ä…UŒ‡Tb·!AV©XrLˆ„S ÊæÖ¯°¦ù"ŒXÄv•Ù[  ÑHX³ÙV(£¥^ÅL¶(”A,.‚iSeºXέ[?¹‹£@êîÊm+ƒøšV,‰v9“ R+ŠT‹ E¤›¤]>“Ü.“4Cql÷G+XœÚd²td«”‘ÑáQ k‘*1±%)mæ*˜C‡à©¬*mUïh÷]”¡Å"`ï!‚c”ƒ+ß¶+GµˆžŒDÄœ-6‰UœQ,ôlt­Ÿ«‘O·^ÉÔe6u½^O¡3qœ Qñ¬ Ì Âgâ % P¤!Òš\œ¨B1‡îDNÃ…x•îT¤µÈÜíYéî¬Tœ•NÏJßÎJuMºL”ø/\æÚ" ;Ý^Mn3 °Zωif@ —0Yµ­ 2LN.*Q[ ¥Ý’¼¶5…¢¶.&Õ Œ.jLC“…A®¾®-uÏ nØ>÷8³q“ŠåR¦9O+nÛ¾ØsX¤²d#FxkæÉFÓTÆÉÆ£Ïs f—mAs±Fû§³Ó,¢l·”ÔÌ Ë;9DšŠ]³¥0‘F·2zÕÉÆ i$œ’ÊcÍÓJV:¶°Lè«jÉš)Úl£Ð©S‰6F†èÒ$·¾ŒÅÎð#"‰AxG>s¸Õ €ÙÝÄÉÍN5 Üe–ÒÃÇ_Þ?}pGOïÆ\³–G#Ru.hD——o_:¾ÿÜäd€¡½s˜_ d¤4*·ÈçÜQ0Ê“^›ÉÈæ"£Ö[«€! °TE£'û{È™À3”´DUFJcÁ {Cï“*ïëé–+Hý(BÞ 7ŒN%Ÿÿ Vùêl‘[´•¦æ}“~/mY¦3P‡]7qÖ‰ àå}œL×ÑJüC,¾$îÌvyŠLTrÑäÀÁànrñ}á%ï'2G¹×œP­_PÚ¶Y\VÉ>쾟±t4e#ˆ©$8ØRŸÝ[v»Å Šº¥jWMÿ2|Û'y!Ðñn€ƒÈE'avh1¦í1Ü Œ¡ÁƒÆ9þò{âá¿*ÏÕè¶x½ïÜö½ëÞ5 ]ï&-ãcÃíy>=$=Uí™Á‘àPϵݛÙòSâÚx½.~G`ô¯ûlçøñsãOìÀ‰endstream endobj 5576 0 obj<>/XObject<<>>>>>>endobj 5577 0 obj<>stream x¥T]o›0}ϯ¸ê^H[Iú±§U-U¤¨ÕTª=,ÓdŒi²Îl£†Nûï»&/"­Ò ŠŸ{|ïõ9÷WÏŠ·ÁØþxÞ»‰zÔ¥øqó§^`R¸tˆRð)Œ¯~Šf}{wwR”ª ¦Z x˜LA²E¬˜ªà¬y ¶Ž³:ly¤'FhãùÁÁ®;½°€6`O“‡ûm!º¶–¸êT}Çîþw̓pödS X; ‚F N4ˤ̰LK˜³"É„mTix©ð¿ÀT΢Àe¡ ³ÇÌ3—¯Ä"“¯.<}™Ü+Ì™YXUÀ’DƒÁ ê(Ur#UM×èÛS`œ :ÔÀ•`F$JU‡Ù¸#ë7T¡™‚®òXfÄj‰âEx\ÕëKƲáZò}?ßwƒÝ‘8 eÌün³ØëQVçP}ì¬ñ9†°sˆ»K(t8}ûêQJ¿uWwv<…býOûºÖcÛ䜭ð°(m’ðë6툕l9;yΜ\×Þ°®ª+:âêÖ`l匡ŽðÄïÀ¼5˜Öç]×o¦E]õŽMÛYdGʺ¨–d)±ëBäÞœhrm¥ m;×ùÂ+ð†îpë…K—ÖÃÒñ/ðósNlWáeãŸÝQ0‚¡7¶a‰c¥N—­äõÐCÅË¡¹ÖXr±Î}rDÇnàã8GŽáhdî¢ÞçÞ_£#¨endstream endobj 5578 0 obj<>/XObject<<>>>>/Annots 2675 0 R>>endobj 5579 0 obj<>stream x½ZÛnÉ}×WôË"2V¤æN2xËÎJ ¿èeÄiR³ž[æ".óõ9UÝ3]t”X6Ca’««º®Ý½ûÏ3_yøÇWaBÿ®Ë3oîáúáÓ_ߟ…ÉÜSIœÌCUªå ¿ (ԭ墈¹…7T€8KµZÎcÉ´f°œïGó¥E$(q©|h^HV`°‹hHVàR^rÀ.XmàIµŒ„Ú‘ }RëX¡6‰ç+É vІœ¬À0*X/&Öå-¥QŒ„Q#°QŽ˜<µ$“+0Ø•O¾˜XV¯LXW´H«€ô)Ž”l´Â²Žål‰—&#¢8´¬€¥J|øÈq– ¶Aã$' 2)>à„1A‚Q|Àa½SàèˆïXc2û ¢¨×˜Îä°Ä`‘‚¬À`Qt0ŠW"µfáñ`‚kT„]Q§2¾p¢h¸-N,µk_ÙY¢oä/wâ‚É·Ìv«.¯ÉXûnƒ»h‚ËÒ"PwßB=u·>–êöóÍ{•V™úû¾¹û]¬Â×T^&âëºÈÎpˆâ«œju‘—y•¶¹îE>Ò‹egÔñWv~$ uøýÿTEßžùdíù¯CUåÕ–-%1²Â0o³,ïóºJ µ®Ë’vQä•VuCŸ¾À&††£U±÷M«Ì÷­ö«ºlrèÛ÷åÕ—ñ×mÓjü<Üçs~ùÙ ²}•–ùZ•u6úÄŠëh³ûzhÒ7 q¸Á9yù}‰‘p"½U=é¯7ê!í°ñ«Ë«ŸV»6mw˜*Ø)§N‰ë¡Z¿Fê½/ê$ýJ/}(^R}GfYÕõiÕwœéºJv¤+Ä+Tá’IþÚºH»Nw—]ßë~h_båbE¶ÃÈ”ã,ÄÚ·‚ûàåEDܤ꜊ñÔ¿ýŽM d¸õì‰+œj)¯u›#²ëS÷“O6NªÕÝjhì.àÅ@¿©³§m›îOGÚtý¤Û¢N3©Í+Õ3«mt›öõÉSõŠêRé?z]u˜’j—÷ê'ÆÙ‰SÊ Ÿ*½«~×ëýá.tÚiUê²n÷'6€üÜë²)Òþ%íèèJ½-Ó¶Wcn¿ÂæÞý±Ö¯røù˜–ºkRT)íJN‚²Iûü£~¯>Öý Ç3]ŸJüã¹£!†„=ƒ±ßöën¾§>£ÇÎ/xˆ¾v~ÙsOàÛ_z"žjwûF—ió•ï??¦½Ê1¤Uoø¿~Û3G¥¸©g«ìÔ­yÜóë ƒP3ûûØÑpÔÁ÷3f2¿¥ç] Nfãt®Ö):<¾þ‚2<*èù§Ž.‘³+õöÓÍeÞXœä/¿'šâºº¾.ó¡ý`¬áVÀ·“_ò*ƒ¯¾.ëAþJ½«Ôš…ÍåáôÇEº¸Ò½ÑÝ_á8Üa³ ÓQ~û›îÓ¼èœÖ?j ¡z0N;líÖ“jk.YÚ§8 b„“”¹tÎ,ìÿ«Û›¬´íþ·N·¬—„`wÿן|4Qx_H·ºÔUÿc»´A'mù—×ãëÊ ÿ±h¥fænKQ V^‰“ZÓÖÛ6-ñä²UEZm˜£2ÝåÛ gU¢š¦Æc«+œ% µÎûç$Ë'>v#„×mεI×4´ñ–3W7f‹ã”M‹®FAá\Þ©m]g“¢Më7åf5^pÓÊHé¨ébê’Æ÷9Å,˜emþ¤+)4ç ÌÍ8- K\E'rìòA«¡ÃŸ)Mº¦Þév3xùÙ>ö³¦_(¥j“o±sÈÞ´Ú깘˜•Öe¿5«'D´ÕÂñM)ò‡6m÷ÜVaj72H]©ûs^1Ç•ŸR]л «:ÝSSzûñöß$à4zÿ†œÆÉ.æ¸Ëk<¬â}c£Îq8N‹‚Å.MÎzÿ~Jl\ã<½þü%ôvè>/XObject<<>>>>/Annots 2678 0 R>>endobj 5581 0 obj<>stream x•W]oÛ6}ϯ¸ÈVÌYlÆ_qœì©k×"@Šu¾(‰¶ØÊ¤FJ±½aÿ}ç’”m9n×!AbÉü8<÷Üs/ÿ<P?Mø7]žôEoøÏ€ÿ|x{2˜ Ę&Ókѧ% 'S1‰OÝŸü:Û›âçÙ]¼Ó O³9Öž\ãCæ—ć´£ôÜØeR)£ ¿ò®N(M4=Jš›Zg”K+oèlöyoa wòª*o..V«•E”Ö|–i%´¬ÚvH®i0~¥7œòǬƒÿzoe¡–J'VIÇÓ÷a÷†c1òØY.)­­•º¢û·oI-ËB.ñ¡eÒ©…–U†VÆ~¡•ªrâ“]оXwño Ö”àt—b(Ö‚n+r¹©‹lo|‘TÒÒ“´Ü82s^¡ëÏE½Á±<Ö¥ÒV‰Òņ´©v;ž¬– ÁÕ®Jt¥’‚^¾¿¥4OôB:¿+ЖÆ9õXø¡@±)†W*¥Bé/d,e,›çÄdi²S”®L ¦óKiK+þCGsx Àãóï-ìHU[Tò”¨"aˆPÖ¢ܰlÜÙAH g(Ç®.KcCøš04 ÛÛŠž[³ ¯úb*èõs¢"IÐaµ’R‡]+5÷æÖ:âS…ª6§J:Þ¥EL¹»ERÕŽV|h³Ò ›dA/?Éu)­òz*~A‡_í>ÔZóQ»KµfçIESC¡sÅM¹b4]æâÜ…Yaé›°lŸ¦bÄi3ìSo8£ž²Î‹8U®NƒæÈœã·P:-êLÒi,òÓÖ€ÿ´!#Z¤Ù,¢"$ ÿÛ<œýÒ$×P™‡5Ëã1þë]æö<Ü‘˜L®|òz¬Òl_Å]²u pí˜L>?ïrñ¶ç}«Óƒ»„W ¿2%»V ÑWøù‘ÜJ-ˆ§SslÕ^èâí<@d ½:?ǼJj6äHS9‚.=?o/Ú ûvôt˜þ Îr$fj% Ê1Æ FéLmSèF!äŃZÙ¤é3 öÛã×냂f `!µ´@Ñ«ÖÞ©+&xâ‰k0KȹWÈ'Yã@’ñ䃖!óPqR³,ò@^³ûá£÷næÜ"«9»‘?6žË* ¾£ ”`ò.dò˄Ǘ†G…Á+ð9â ÜùúaÕ¶ö.Åö+]Âõ™f½ÃØBæ!?Âb»ïÙ>GBH°Óõ8â6-ÖŽá;¾èñð"X ÆWì¡\×ûWøÚ’¤ži2ÉÇ5‘Eâ@?üžO‡ûC_µN9íÚ¶A>e—@²™RêO‘š‡^|ºGM“?ÓÝÙwEth•+ß²F|Y¨0AV.”ã*Æ$D£ÛÊáÍšJçEÙbγyz€åÖ h™£ºD1; îQµl=+¶GaÐ3×j3rÔ±XÖl!±ÌÎà*¼Û3¹gÙÙãa‡Yüý.è§7ª=âÛ@gŸCã…†TÍáUHd‰ÆÚ[YÔ´SïƒÅqô{¦Á>[8Hä,˜Å1þU»Mà>/ L/P1"A‚>r«ÌFçvÑ¹YQ^/¸iò¶ÇMoQ´H_®†¿b*䮨/Ðû¢…µ&RY`¹û/ß¡AMm>Ùúãñ¹©œñµƒ ”o#Ü¡B{¾Èoè]+|…Üž6¡ µ¢ÍË–¸ãYÃæšè bY Ý6§]ïxÞ—2eq±AÍîäÏ¿-ÑѸ9“*_£I¡¸ùcr¢‹Ä­/a½á„»!\{†¸ø¼ÜQ–±ö¡:yõ½ mËØ¶M¤ à†éáíñE=Ý®¹×ÒssÎñ¼CGûcöù¤Ü죭‡';nÁ7¨ÿÙ‘îú­^.‹2æù46rƒéX\Ž.ir5ÃkßÂrëÜãfþµI!šxã0ÂÂèÞ»Ä×ý‰ A+FŒ/¯xæo³“?NþóA³oendstream endobj 5582 0 obj<>/XObject<<>>>>>>endobj 5583 0 obj<>stream xWýOÛHý¿b”¶§€bç;¤ôC¢Wè!…£©®ÒåmìMØb僚6U÷¿ß›uìPÚò9öîì›7ófÆ_÷ÚÔÂo›ºþ‹Ò½wã½VØÂÍêÃ.¨yÚ§v‹Æsj÷ÂNoHƒá0ì :4ŽýB<Šê£\[ÊHÍUDf™)£ÝþøË^ó´·Þ´;áa›‚v?l°¹È$¼¨Ýî†ýÖXp÷ƒÔÒŠL:/)2éRdj–Hº³b¹”ÖÑÜXr©Hi)–·*ÂZ›k­ô‚ØdÈ6ƒÒèîÑæÄÃâħÎQšj‘ÎyV:W£ÔÄÒØ=è‚N»òL,̹HÌL$›ä=oH›Œ¬\(—Á‹ìZ²el -RI‘ b/Ý «û?ËyG–[ýp}æŸÍ­I)%Ž2Ãǵ@4G¨nå×\Y¹ÃÉÔÀ$qÊLx[ÁLéTúð•$¨•+€ˆèæNظ ŽJT¶:"6ã²C-Lxg-ŠˆrJÐ1\›Ë;2pš=ç£ tæ“ûe"4ÂîwXIJGIË„$°f N2I > 2òKŸöÑ}Í…»fÂÉÇn]ù‡È!·Jg z2Á%ND• Iʬ”dæu+5E '†Ò™!•9™ÌC:Isähiepõ÷Ù‡nØÚŠÅ{!i§šõ"t–¬X=2FøàðÜJ†M©L]síòÔ ÌûÛ<}Ié9ÎÒêõ½ÄúÝ!G¿3 ;a‡~‡Š$èƒù)}S^Ÿi0¼ød¨¹"^Øc#Ëj[‹\9’éLÆE4à½@&s$•…©?áN½™$‡œ‚¼§ßÈ8¤cMòd¦’}Véé‚e:Db4‡z P•“zõÊ×¢zªtèµ¼Á\Ÿì3¾"@3™˜»£rÓ0ì2Gv«v»øן­óŠ^»,V&¼~[†ËW¢êq‹Êuí釉šýà¹Èï· R†¿óf)õTÞ æcRÇ鸓4šì¿¢f…)p©(*a¼.kX…U6— ¥'u¾v5¢kaøòöŸ'û[N|ÛúÆ8Šcé`ôjû‘šÓ¤Îæ^wvlÐŽ$ŽžOêµîˆ^ÏU"¹¦…0þv2ѵ†GÒ”#ÊâÖÚ¹ÿß6’цÉ|Mïµxä™d¥Oêž;ò?`01"&<@ƒB8ü‘‹°@»ëRi¦ Hi©4ód89ã:yº`e4åS™ )r[&nwW…\û¢ ¥z^¸MÊc§QbJö¶¡¬»ÏN€||6" ¼Æºá`pÈTSšGס[s‹ îdÆe4â>ŠÊÇUbnr0€ÒάŽPcbtE«ÐïЈ!4O+Ù;5A,ÿ?’?Uß(her»–Gƒ¾äRˆco¿]Ñ“«âRˆË7úÍ/»ç>‹å\¡>>OO>/Ggï®è[m"µ=ñ+õ‰Ì°2‘·(ù„}Ù×Z&k `0ʸµ¦È‹bØá!hS¾¹’rùÆ`°*z,eŠRô~¶ê¯CúCrçäIbiœó#TEþÚ8¶…®ã~\+Ÿ“»S à&Cä:* LùeÊE©ˆÓêeðœQDÁY3w¶¹®µ8 "òå›÷óE5²ütÛúèõiÎÿ®¡¨ÄLø—yø(º‡[,`<0éZMác‘¶Õð»-ŠSL°r”‹†Ï‡dÅ„‘ršB³\%ÈWtÃÝ©ìÚ¯©†ßõ0%ÍVÄCFHçâ=4_7¶Kk“\MÖcx) *çËD™b¢˜‡×Ûxë¾ïH} CªûÎZ/cô«xƒXjhs rÌ«Qcæ+fÜ>&<Óð ,v…VÃ"ßj7%õ”£rFfX•¾·”@¿Ûå›tåóµÒÆÚe:h–¦|Þ=”øÇÑñøôâò|Ê2Ÿ^^œO&[k‰üÍ:úŒ%Ógª/•i>¦©XÒdÿ'[Çç—›­Yj‘©ýµ­çï7[Á[ƒ~jkˆŸ‚¨aù>7ì…ýn/t/ÃöKÿºÀ`n¥÷&ÊSÄÐEÞ†º^¬ uûÙ²MÇq¬¸P‹¤,Z<ëaVÞ¼âÝ.ìvŠ—­^ÈÖNÆ{íý¥¾j¥endstream endobj 5584 0 obj<>/XObject<<>>>>/Annots 2681 0 R>>endobj 5585 0 obj<>stream xW]oÚH}ϯ¸ÊV‹S!$!iV}H»Û )ÙvªîR4ØLc{Ü™q¿çÎØš&©–D Ïý<çÜëoÇ4ÀÏ1Œø7ÉñWøÏ1ÿùôþ`xqŸÑhp(§³ÁI<ª?et{ðf²sÄŸ3 ê¿ÐE|B“9 4zuFç4I½áM’¨ÿ’nE^f’DµÎujã%½ìM¾ ¨wŒ[Òè·TÎU!éêó¿×ã7wÇ(¼K¥÷n½þ|Å·\}“*M#Ê*¡KYÜáVšM#|¾»uÂIzy ÔÇÝCO7þlXJ7…ÈUB¨L•Éý´ùÜi|Ê'o´u]$é¨ÐŽD–Q™ ǰd«²ÔÆ‘[ÊÖ\¦…¯†ž×–-þE©^Yú®UQ­)ÕÓ£˜>ɹ4ä´?ÏÅÊEQ‰Œ¯¤ÒI“_>C`餑šÓFW¦  À’r1½Óõ BÞG%Ó:"ïÏŠ\Òʈ²D u—*+Ó˜®¬­àzÁ¾h)¾KXM÷áo ƒå¼çÿª AsÎ$p‰ïBIÁT¤H®=£âd¿ÔQׇƒÀ‘}ji¥Pb Æê\º%‡‘©{‰{”½l,nÉÛ¢­' r½ »R ê;ÔøRÔÓ͇;N6xoIü‚IB½ùÇñ[êû•5}U$Y•Ê>›é%?~`N7ýñLÝ3מá¡"þé »ûY×>ªLÍ|Dub!—£»¬wñ(‡'kÝwK`YZ%p=ÛÐí—ñû G¸Î¤æãíJ¹%1LÏâãx¾d™˜Ødƒ{eQ3gd.;«XDkMÙݾù­RFN£Ã:¹ÃéÑ>D~!ƹ[j+©²ŒÒ ^w=b=€Dfu@(ô¢+Mi˜R! æ+Ç‹ªÒ¼*/eÓÈVÉ’„õx„º‹*s{gÛ¢p%šÆ{b"&ô‚hÒÀéZ^ZöAi|yeç‰wö _j·ÒT ž"p{éïd~A¶$A^8‹œ½X”fÓõ â{Ú åšÕjÛì˜Þ"ì‚„~Nn‘A½†‰¡Ï…Z÷½˜6.={½Ç-¦Yö¤ÉZ¤÷ì k¥qÓ¨¶:=bÿ¹€ ÙŠG¡ëX? fQ³4÷G8^8Ǻè‹Ê)Ó` MDÇØé£ŒýÐ tª±qx¡eäCjÑ=æ@£ÒûëÍÓšd~¹Ø¼š>/XObject<<>>>>>>endobj 5587 0 obj<>stream x¥VMoã6½ûWÌ¡El¬-Æëm‘²i芺ØC]li‰²YK¢–¤ìøß÷ )9¶ó±‡"AbÉœ™73oÞð[kHü i<åß8o}Z´Ñ/Ìšúó ´Hqvúÿ=>ÄíÏR–ÜF8RŽ2-™àQR®“*“]ZUŽbQÚQªŠð]!rœJ«"vJÝ®…*(ÞÈxëmm)³Lë. X¨”Jm­Ze²9£)[I¶2²³ø·5 ÞpXmܸµ´—F’|,µqkcdì²CÄ&ý9ò®sªéŠágjuEŒVÖ‰,“IßVeð ŸŠQ>XúV)'I¯vJW––í{M+l¬ [eÎgö[%(Ñq•ËÂYÒmôžœ&YN¯@©6tЕ¡2ù²S£þ@œ)w¢7šrÊ£Y4Š&ô§E½‚M¨ü3¬£ ŽÁàÖÚ*çÃHŽÖZr²¬Ë¶´Wx·’äÁ–Û(ûSS®Y4æÈ#=ŠÆc<%í(ê燯Y%ø7‚ùÑþH¥Q…[¶å£ÈËLFë8Y¶'Ýé²³ìœ==³›k}a0¾0h"àäÍäâ» Ï]°yŽûZ¥H”“EƒéûºÖcºE¿Ð¢ÃVÅt׿{÷ŽöF”%ª<œPeŸÍØøÓ™ 0¡K|y¸'gŠ*¯*•%$h'Í á*#2b¦ ‚Ò¤"–|Êó!‹u"#Z 9dAiÌ­à,Í ¼ð@‚ùÖ‚e ¾*v¶)Žàçî¿Á¯q4¤Ï~œ½‹S9è5¬Z  Ï*°ÅævRÄV©Ogxô¹v S Ç#zH=ÃáýS»©›{Õeƒ‚$—°ÁÞºLÎÒBÉ4JÉ®gñUã‚çÐAgê3‚'­àAÝ £ØÆFô…£Å­ýX50=úî“öxȉ.®UMÚœ«‘å\}·Ùõ t .ÖyÎ11è™"&©ká-ÞìÆˆæµt¾ÞûL¯Ðù“¡…ž¤BÀ)äÞã8‚:žŒhPuÕºÏzqø<ïRÓ¯hºþT,;?WÍh„ÑGÓ0Z±‘ÂaNÊÔ ¢CÐ룤ïð|î¸>`íµÙZNƒ%Ÿ2…uÁ ÇäÙòªJ |oK[­EM)¢or!G£%ä•,àæN«$°"ÖØrÓkkEE8£ï~£â m¥,Qˆók»~·€>âL`àq ¬Z‡î %Áˆa§kÀq­bfb]^õöX`ÙæÎ+òèÙ!w¦0?ˆŒ¶Æ"‹2ºàŇ5ã6«!Œ¤ÕÐ{žÎyÃÍ$d-daÛ^³òQYdž {–å•u¼Á0Iˆ Óˆ¥.½VB:x'«÷ƒ¢\Bª@¾s!ášuhdŽèœ“¯P!…Alè´<Þ%^œ~‘o»;¶,…2ö¸Q±DÓ×û¿¶ßì°þÁÏ×ç‘sÿ‡u¾ñ`jtÚqƒKŠ{Tϱï *"©µoÕ÷ò“7µP4­<‡/Ÿ†æ; \Þ.ïÏgõum8›D×ãkšâÿlèï ¼wzãh@¿Ô7+ÁmfD™pº÷>ÜKümiLw:/ß01kÉeÀ5`«ëÁ4pÅÂÖžLüê×Eë÷Ö˜Ãpjendstream endobj 5588 0 obj<>/XObject<<>>>>>>endobj 5589 0 obj<>stream xWmoÛ6þž_q_Š:€­ø-n›¡ú’dÚu[] Ã<ŒDÛl$Q%©8ù÷{ŽeYíÚ¡I Ä"y¼{î¹çΟ&4Æï„f þK‹£WË£q2ÆËöa6tr1¦§ÉŒ–kšŽiñl’,Oh™ù]cZ¦ƒéüxùéèäâM¦¼m„}£éi³o0Åiœ¿ÌõÈéN%nriÙ9M`c ?FÓy2‡ÝA#­»­J·$Œ¤\•·2#§é5¥:“«cÿÚÖU¥“ÙD™‘¨*) ﺑô©¶oµÛJÓ^Oª¤·µH轓wXÀ*‰ÔÕ"gÇàÇ’ ™nE©lAÊR¡áAª‹*—÷ ]ª;Y’ Ía`g!°.h£é4™Ía6xTè¬Î%É{Áfâ]À È{'MI™®]hýÓ!F×YÄõßW—´SyNr½–©ƒ;ùmd)p’ÜNÓº.ñ^—–¢Sm\å¯Opɵ•n5XÞ5ð8~ãÔæ«§ºr %pÉ2 p é„ã|#l­–ñ gs¾Rx°feÇyámyc'9UHO \ó kÎÉ¢Â{Mˆ…´."l9ÆÕqBK¤_®9ƒjííðùÐ%Ý5%¬U›Òó¢É0ì÷i4 –8 |§ \#xZ= 5n –q ªDf+#ñR 3èTjl/7 ßžÕØ}àS`y±/ħ^Pepê›ÕOFÛSkúO/(}ÞaF”2ý~ÿÛ_¤×>FoOC¬òÕ¦g¯cí¹WƒöæÖ¹ô».²°n«ùÒÀl¡6j£J€Û¹«çÅ—0 û·Î,8£öôê † HDCö£Ò`C`1=.ôY‘×^ésžuw¡^¶)¤Å’òv™{jûzÁmÛ BÃîE18¯CF²-o»QoH Ð¯¢éú êúÉÝ»§¯_éÁFoØ·_^_]þúþóëçËë«wï>._¾z{Î8îÃøé “®xî Ä2’N(ë©…›§~ÒüXæ j‰Q1W<ö>/XObject<<>>>>>>endobj 5591 0 obj<>stream x•WýOãFý¿bDut‰Éá®'q|Ü!µ\ F§“ªÅ^'>Ù»ézM.Býßûf×vbCh gfv>Þ¼·üµ3¤¾‡4žòO”ï| wÁ›_fF‡—zŒ)Lh4 éûa0S;«…Ñþê÷Iþù"“ÁïWkYÒÏÒ„ßwÔÂ4†é¤ÊÞï¯ÍïZ*ÍZï?lD>ÃɈOSrI"+%‰8–qÇãßÎpaØçðrBœXB}ÔÖ«Úö¯Zé’æâQRYȘì\’÷@ÇœÇ~_f¥ˆÚaöI/lª%ÚpCò×RP®ã2“=s™f™l5̲L/IPœ&‰4RY‹…Ñ"šÓržf’r¡ÒE™ ›ªY]æˆ[9ËôƒÈГЇLÝï‡ó´ üpó'K#þÈ%³4x MA3©¤5-S;±¨NM~BmôG£`<*x¦Èéú4­²•í;ĉ©2ç¼b™¤JÆ‘?¬ÿœI äþ c:Ô=¨àTãˆ] v9Üüo„l?ðȸ'ªêgÖ£¤TϾ 8¼y·¿»õ¼êw;Í&¡âíN®ÄûƒçN›PZ'‘È0€õ˜Vtûõ꣠nžp½]\>Í÷4„oÚè¦<ü¨!˜ÐʶBÙÂ¥/ÑÏ¢];L`—2|6/S…Ú³d¤KÚí¯Z¤U$–;‰—>tÎÏÞ¾]? ªê•wmI©âà…s¹rF"²¥;à{Y`3ZmˆôbUOÌS J»r†x#ÍÂHüvD%¼¢H(z@²s¡fØ'œ[€€00ž¢ºT@¥Yú(:—,ª*ö}ÛäÜ]{㙤ŽV‡pËðf£~KWg_®oÓÉè—–ÑO~ _·Î‚_í~– "úªM;p5ŒÍ³¤s±*žnï®ÏO¿õ~ûâþ„w·üöëÅùµ~¾»q.o®ø“ÛÓðî/þvl]¡š³ö$ ô(³ÕùQf©fž+Aƒ9‘Žå뽪©¡éD«õ§¾ '¯4 6_þI›€|ùm’³½ Xg¥0ØÉ¢¢Ý\®£k KJä²Ffcé2‹u"ŠÒ‚áp (ŠtnõA¡%xQìÖ!WÁR?|G§ºSÀ²-Ô [õÓ@¶“B<¸X9ípôdkNAº1¯€°s »vx¢èÜ8†í…æä†xrè¸þ7OÇÂÏ 6öàî‚ãŸ]S½úõþ:íu*eàY¢y%ôÏÈ—$™Wï‚åÚñ“ü±!Žt¹äÀÜR±Þ†Œ‘;ñu*~M¶¡'òm¤ô¨Òª…†ÖJCÔP¥5T‹ yµiäËO¡„î?ù^¾«z9|7 ŽÆG4Åßc•e¢ëƒë¨Ì™\ùBÇnøÿÀ[÷ý2®õcúÔ¹…³íÑ`ŒG¸#¡·“éˆ]„;ìü2™õendstream endobj 5592 0 obj<>/XObject<<>>>>>>endobj 5593 0 obj<>stream xµWkoÛFüî_±pQDn$êe+IZÅN i + 0NäQ¼„ä±÷°*ýï½#%K‰›6@ý”èÛ»½™ÙÙõï'cásLÓ¥ÕÉ‹“Q2ÂÃݳ¦áÕˆž&SZä4ÑìÙ8™ÍžÐ" «F´H{„YûŠþ¤ÅåÍbLßÑxÔ¯'x¨¿¾9[¼;Ñ`Œ€¬÷…Ê3™ÓímÚ”Þò7 ‡´(¤‘$ð]k²N8•R%«•4–TMóƒ-øÌvMªkë°ÂÑõü§×7 >~rt ¬3•lS^#W¾Ûi&Óör½˜Œ²$È–j]8Â9¬SÉÙ¬d!î”ö†6F4ª×4'Qg4ü˜RIʼ$§ÉxÙ†:²©k/¥%ÜLf]¦Fk·#²ñVf$,åº,õ¿®è•áȯ9ì®Ád’L§ /ë=§Æ¤eOþ!ª¦”ÉÍ›×/¾ÿmyÖ¨¼û f!­KÉGqãù9ŽœÄ´ â²´Q®êxYg|ê‚Nð„á]—z%JªE%m#ÀóÀ:z­ÿ§Á€n$¿Ç6aEP.˜cD–ë‹Ks®«űR¥r[z­l‰ïìѯ¨…²`…ݼ½~ÉÔkÃräwƒi‚ ‡*3T𣵬¥.&Ÿ–ÂZrbUÊ]ñ‰•¾“AŸÀ"Dy¦…¨×»«™¶dÌ[ Û§•w‘¨V®‘P˜Òu¹¥Ør^"M%\H+± -jg‡l+`¿õ½:C…E_è  çï‚þc°¤o?WÒ·Ÿ#éß½ÌÖmòJÁ›ê5œèZ§ÊrÇHÆN#²L9Ù™I-7@NÚ„®óc§æèc½A­¼{%a¡Ìã ;!.Ü«D7aßÖVúh‚ˆP\`ãTïK'KÚàÉ9[Í5ì¬iã 0Uó)¸aÙ GGévn´w–ã4¹šÿ!(r÷AÀÜÛ.çà—÷ Úe1Eã¶”i¬àkEuG“ÐKuñ \À|ÂE¢V™µNzíøÃ¶ícp|ß4š]"_ai(œ¬O*`ä~¾Õ>ÔÀV‡Öo}ZJëAw¼á3ô6nWܬfŒõ½9¹ Ÿ5¼Uˆ¯:O'ó!÷‘¦]ÒË}‰ ‡ WÛ` ]y0'M¥ìGÿ(P²(ûÆhªbjß3‚lËÐh G*%;ȶáî˜kSÁ¡tÝÉ"âAûJ†;áú6WhGÅsDâ ¸3´ûƒÇ½Nöe¥3ôOj¥Órˆþ 8®®_]ÒW¹nd½ìÅÉ<ÂÜ!ú‘-&O±“\ž Ž?º<-Áñ²=½]ñàlñvggB`ò7\õPG°]+ “û:eÃ$Ðáœ7ètì™]ç[pöŠOY_þ]Wn-B§ï|ýþ´º9=êAÏ»-“ŠÓ%Fz«M™öó‡—·P´+áM]ª÷è1¢†S£àET‰¶âÅZ¢yðTò+DÖicÙK8EQëÕ;‰¢\yUòV *5ösªŠ+d*Êòhºz¬M§|”Ðýœ4W@ÿ]×M7…B=29VW’PwXÌ„Q0w@f”`x8Žbv<ÂDŽl š¤&9q`A]2q Íšqèœ ðNeì3d™*ˆ¡ÓȱGÚZßrA.{‘¬=½>Z*_Eå´Î&øV†6ߘ®‘\èY†2ÇÅ[ࣩ‡_È,Üž–=Œ¾bZavÜôEÄ3L̸} _žµÖö´w&£óäbzA³§³h]ÝÌB/t깟oáŒ0´Çµƒ'ñ?‹à†çɘæG#D0~žm¤Æ ÒƒÞãb4K¦*Üã|6åG—‹“_Nþ=¦endstream endobj 5594 0 obj<>/XObject<<>>>>>>endobj 5595 0 obj<>stream x…WïoÛ6ýž¿â ›“ÚŠb'nÚ¢Ú´ÙûUûb  %Êf'‰*)Ù†ýï{GŠŠ¥nm¤EñÞÝ{÷ŽýtrI1þ^ÒbÉ?IqòfuG1û_fKw1ÝD Ze4iùü2Z.ŸÑ*u»bZ%“¨2ª¬×“l}v¶úxÓì/ÒIc¥IE-^P/îÞ¾¾‰¯ûïìAm?Ôm%Ý£CîîÞÑ9Íf¤êï- â…s>èâîŠ8PF3 ›Í²ÉC#H–™6‰´Tï$ÜU·¤3c) ›’ÕX ei¯L݈cÑ8•çÌ€E» ¡X{5ŽU (Ésº—Am×AmstG´¤÷®t Øó»ƒ6Y™WÑc¾Ïœ6FT€qÛUŸL; Šr,À*^q)‚V!¼–Dš:P!kˆ±Ó(Ë/l›ú”¡†½JAª ½4-•$ — ÷§¥Ók&ÑDØ•súÕº{…Я,ö¿$n3úÅëÑ1 òFy€à‘ù¼W…Ê…!‘À}œþ;*RâÆoJ´ X)Á0XcG—ÅFËFrûôihG§ÿž«#µXJD‰æ¤ÄHg÷ŽÇŽ ôî8ù¢NlL¦ÊFÃ^!à˜ÿé¼i„š:U•¢4B0`é(zÈq~Ünš†Ër…ö"o$—¦b£ã±Ñ{Ù«Õ·78[–ÕhŒ·H®þ‚¾©§N#îC?ùáõz1wÃëûˆö®leä^éÆsË®=!û„wü0¢ŸôA¢]A úœÍ–›d¶Ú ¤½‘vŸ²—Â! Ñ%I…MœÆ²;DôþÏûIf‡ßK¾W ¡TJµ¹(ø ¦ÎÕ1ß4m%¦„`ñoP+Oi1úÎ]!ǶJ‰ñÝÛV7¤z›âã; ­¼ê»:0Š3âÁ+j:ÀæÉîôÕpzð#Km7S4…,‡ÆÍÞbIáŸ*·˜nC©:»f³NЦîÛGÊ'Ç*í›§=Æ‹HgºÌÛˆÞ75÷ªóuTÑOú`€,XÎUÌ»zªŒg,¢×n¢ôNà®èWÜ<úíY×n4Ôµ,*Ìð@K"PÐHÒmVÿõÖè¬þNk;=EQh]ÕƒO>éÑ ^¹Áð²3Sº¸ ßC±BEƒ^Ü(ÆÆd =g+ùâ°']‰¾x1ÆôɳrÚB RÙÂys!J±årôó{ô !îUcDÛ¿@ÛÎí¡UOI.Êm#¶ÒFtïî•ÜfV,ÔÈ.Ǭ³K×_;w‘C3l@~ËÞ¾`èÒ’Ù´P,®`ŒŽõË2î |QÃŒOŒÚ`OŽa`zAßtwãy|]/®iùìÆßBØf‹(¦·]ƒ6ÆKó{gÏ<«îjsí‡= óžëx-æøZäjyÅKïV'¿ü $Æ÷endstream endobj 5596 0 obj<>/XObject<<>>>>>>endobj 5597 0 obj<>stream x•VmoÚHþίåÃÕiÁCHÚêò!¹ãT)=õT¤~ABËz ÛÚ^ŸwÍËUw¿½3»Ø`ˆ¨.DÈì¼Ïó̬ÿîÜÀ€>70ó¿Ì:ÓÎ ÐaóU.¡?Áͦ éŽßÒCìäô ƒ/+ÌA@†ÙKÐ =ÒV%‚2 ¬Á´uÚ¥3–¬D§ƒ0dSh•[,C˜èp+²"Å.˜ª(´AØéŠÔ×v£î ¤ê^O¿vл‰(­À®”yÇ'ýÉîÃ!ç‘4ŠÂá~ÅOŽÂhø^›rEP Þ·Nÿ­’—ƒõ£(Ï­ÙeR«s»âÀ[Ú×s¹ ÃñøŽÅêÍ¡F»Ö*¤DcÀ®¨oÖ–jQYäÖrX.™d?+óð+Ì‚Ùu«¢Ø’d&¾M5²'©}È]Â[Æ«‰$”ªCŒÒÔ.S.Þ3ä¹Q1R˜Ržlʵ‘!¬EZ!#¾ÄKa þŎĤóRÇx¢ñŒóÜ3±®o_Œ« æu×á$E™ŽU eOæˆDkÀ5–;*+_ÂF—ß |­ŒõØ1—7ºJIi[ ´Žò5BŽÄ{ú_nÅ%€ ÜPPK†¾Íw¯}Â-ZæÕOqŒ£p‹.Ð…U:§AªáL䪨RÁç´7I„,–‰.3✠`¨û*QòÈ0©rÉFm~Öýpà|þòážÑ¾2DéÝÑjâyÕiª7Œú!™•+özPo±°â|·ðfÚíÚÜ'`c]-R„Ú‚“­õ@¨LJRwëjö82Oö„ sÜÌ9þ ;£Vañ|;7hgè0gÛ¥¥¹k4£sÍ¢¤²fAË`;_:׳ën“–‹¹k'‰Ѡ͉ó]æ×MÚ…´Oyl™àÍž]q#<ÜŠ«¶÷ {¦ïuç~||¢ÿßÌõôÜŒ÷I;¿æ¶»JJÄ ‰‚ ;XTVg4 R¤é®½w™ËÜ@!W§”¥1Q9<…0 >¥H×äÚâ;¿Óc&E·eQSrÁ6yÑV¬RšÿÃ’¿8Ñ'íÝ´‡¹?y |µó«G/ó­ѽÞÁÓ›7 Sa š¶V…#V=Òq½Ø””°¿s𦡥_º‰£%±Á4=yÿPÉñ|Ó%åvk8^|Áp*ð¬h߯»âf­ IUÒ-î”;§È$k0Àìá%¯0(J¹šrE7âke1;÷°ÖŠ!¤ ÉÏOKÌô/+z'n@9‹ü<¦K.Å|iWí‚ê7¡ûý.¿¹…·Ã[ßGá3c6ö†á~Ó²Êè*uû›[Hóìµ{w¾mŽcø\o|Ç€ÛÁ8FÄ~4¾eÃß§¿:?¥ÿ)#endstream endobj 5598 0 obj<>/XObject<<>>>>>>endobj 5599 0 obj<>stream x­VïoÛ6ýî¿âÐ/uV[ñÄI=¤@“-] Cûb  %ÚæB‰IÅ3†ýï{GÚ²¥¦M€. Å$wïÞ½§¿:Cà{Hã ÿ¤yçzÖ$|Xÿ²+:½=£á€fKì¼ÅCÖñv·¦¢TT9IÊ“*认Ճ$¿Vnz2û³sz; ËdÌFêFÉxŒÿ²î;ÒtEòo‘—Z&wÊùyw~ÂG°o [¦ªpÒbéÕ{-_}oýÞ›ÊwÇXIûõŽÒªèéJâÏp~Òº%nåUŸÑ²Xùuëĸ¹;°‡±`'“É×8ï~2^Nii,°ÔZ+Ê¥_›Ì‘Y’ T çzÄX3Î1úzÒ «Óx`Þvåb.‡¶u{Tÿä¹ä™sÊ¿v„þJá¶”£C‚;köÕ8ÿŸ%ô›ÙÈGiC™ð‚„÷V-*/]`†{úþzW¢Fg|Ç C@!n.ó…´ÈÊJi*“ϯ%9‘KÊEQ á膜·Uê++]B÷^x•F4pŒRbI(»R¦Jh*­Yh™‡B@æ5Êe‚gFºâµ§µxÄ¥UYëÃW¥kZJ±»r¶–V¢¯²G÷|ü@+‰ÌC²±¢,¹ ¿ž¼ÝUÚû€ºLUdä JAûQÏ–s×0kB¯´®P""öbØÊ4 yíˆóÒi <¢ûRäôϾà0ƒeµÐ* £\Ï%  p>•¡tãûsãÜa¦‹Â6—ÿ ÿXÚšŠAJztóæÍþª}ÏXpGÍG§—Fk³yVoöZÃU&»¤‘fýÕï×È[¦ÓÝžF]ïH\5¡´:ÄJ‘ñÇ ¼ÞŠÐ>µhEØXå9XQá߯ êëœϻie-H­·ó*s „æHq\Úp²Æ˜ 4´Hås’íµs×3Õcà1ž‘Jû°­úÝSè†У‚¢²l„;:÷ä#‚ñÀÒ§ßgaÄ"Žç;mñîÆä%ˆ½PZù-enâÞ%PJç”)ÔBA¶¹K˜ïþ8s’)4ÆrYÉm, LzSé,¤ðÊÇüøòõË•Ïÿ8Q¯_ƒ‚[P2¢ÂB¾ÆŒ[ÊäRTڃ̛ÚWz¤‚¶]¤_˜¾ÑY>ÓÏû UðìÑ>LK—LéÑ1¦&L4ëqƒ‚i쩼l!Ò‡°¥;4²d=d ÏY†1ETÀX\+ 䦀RGμ¥!Âò‹S4aáE(¹ ¢¦ ˜ƒ 3×$o>K‚íÓ@ÆËJƒR™Oˆn•ÑPþŒ/g•< £88€«=!ˆ<˜X¿¡Å«¿ñ‚-áÖ˜–#$I¨¯vƒ(åœw0Œxìª7¥hôÒ‡†µÆò=,ñ¸eU¤ŒüKK 6å éó.çòÓrçV§·—;^ž%çãsš\’‹ø‚ºŸiúŤUE…0˜‚!Cvqwÿ"¾¨†Æ^„>ì0æmçƒI2¡ýhýÙdÂý:ë|îüdPàendstream endobj 5600 0 obj<>/XObject<<>>>>>>endobj 5601 0 obj<>stream xWÛn7}÷WLýʉ´ÖÅ–í ¦u @ÓÆhQT} ¸\-“]rËåZúó=C.u«bÔ6tYr†s9ç ý÷Ù„ÆøÐlβ>ûîálœñpûâVtyE“1=Ø;¿Ã‡<¬ãƒøR ‘^[CÏ.ïá5X ÚFÔ‹Áâ">NŽ$¤ToIнµÔXm¼rd¤/Þ’0’•h[Ê•Ó*§ÂÙšM2v8¦Ñô ñ ÞyÒ-µ¢P«®UTw•×M¥H›¦^©h­}I~÷c°¾¼¿£É4æ5šÎÙÏô6›ewô>†ÓÉ©B9[|~UÇïÂä$œ›ö0©Mã1ôæÅ‹!WÆ)lF<œJ®‹àÎÓÖHu[µZ¯JÓ¤B–á覫„Wd—•ôm†¼©Ï¢F^ߤ:#bNaʧO³Ù ßòÁ£Õ9qé'‹×÷ùçÅÅK ?——ôž ºÜ¤B÷•ä†íYN£å³“–Û²œ¶EÛ)íÊxÚûó¯.ì^s©É© 1ñ„¤QH|–Íç7&ô7U 0ØñBWO®[¯{œVúÀRêv4j%u¡¥¨ªM²äžYSm輯þyFÛnÂiÒ#ŒD\ Sz@W>`¼´– ë|™ÑwJ (âÓ‡!^ê P€DUÅ…-~Óà‘·+Å8’ÓÖN4 ¾J›« mÚ€ï!é‚6¶¹|ÇÉP)r¶9 gi±„< yà²Ê`T©•¨˜G¹ !> µWTзÌHfy„XxèS ß@ñBÙ«„ÍâÀ„`óó§,Ñï„ @yÚä×ÄÓF@ãi£ß˜ÐIH"ücdÀái‹ˆÅÅ`BªRµ2þXØŽàøA׺Ž–ªÚvP8);×2Àvß9ÓËʹ·äþm;E[È|±Èž$ <“ÿš[òò "¼öŒ×æ§×Bcn¶k;é?J  2¬¾tjMX ¸Ïì@Ê[[« õ‘O}™…n—'-Âи4¢Ê C2j €ÚVYyJ-ЬVµuž `o©´U€?ü´Q¸qycôÍ‹ÁOH±WJ0ù@Nê}®Ó”Ûo;X ·«C~I[U ’ÊA2Èöú5ÆD%é­K-ËðrÜÕ1äe˜p™³@sqÞ¢‡Ø!"¡¼Æz *ŽõþÀ'§ð‘Dྫ¬ÈqÀX\Æ]§÷ÆØ— †(Œ/mÞCi!@®“ÞÙaØÙ–…¤íš¢s cw‚ízÄåÙ~Ð\îÆÓ:F^Á2„«Ä1ìw‹²ŸË~Ã.ë#|ÿ•„«ºP³ø2Dð&É ž× ñZ¹ÕF¹§ÃƒLrl³ÁƒÞí"Nùö Îß*`ý¼7JÛ·96î(…·v­ÐlÊ;T×rô_·ÀŠr’¯iµ‚£[d†§È”ùéuÙç Í*À¬ÚW_›>³óY 3‹GÁ5°ÎоÕñû‡"f]ÄÔ¹¯žÌê5"3ót"ѳZ9 °F8ϳ‰§¡;LnÐ{Ã0® F+k;Œèà¶ç*Jq0¢ÖfÅ>¶ÈLM Š¡‚ö-Ue×àz¿/¤½ðó}¢ŸÉ< ãmö*yÜ|Íþ'ÐÑtËJË8°5N.®:vn¥û¿ ¦A‚Ÿ󃳬ïómwŸÜ^e׳kšßÞe“x¯dfÙ˜¾·’e¼à;?ÇðÅÝ£›O¸JßÍÙ»‚óÖëñ<›MñÏîFWó~ôÃÃÙ/gÿn§Ã endstream endobj 5602 0 obj<>/XObject<<>>>>>>endobj 5603 0 obj<>stream x­VkoÛ6ýî_qQ ™ÓØò3Îcè€&™‡²­ÆúÅÀ@K”ÍUU’Šcýï;—zÄJ2#+–ı¼¯sÏ=ä—Έ†øÑdÆaÚ¹Zt†Á›fMƒù΃ -biv1 f³3ZD~Õa÷ÛÇ‹¿;ƒù”F¸©uýñ¤Z×Ýé‚B‘ÑÖ('é×BP¨#I‰ú,Ém”½,­÷£ôÇã`2ĄûÅôžæZ/»Ëcj~ú}º6RÀ¡à—ìA9>›¬k“xφMt¾£ø`¶w÷Ò$ZD*[“-ò\GÊR¦})¸a)NäƒZ%þZet}rÐGJ§RiQ“4x…žltÄO„£Ÿna~p)+Ò•ZÈ?@ú†äƒHóD†â^«ˆl.ÒeWenyìaoªÞ{k7Ⱥzÿ¯mÑæ îÜ´ö?ïnoh~w·ì®>üAï®^ŒsW®„¡£Õ³h- ÜÆÉ0F8¥3 `à  ¨, Ês)L˜([•$´–mÝ “q€©ëW¦‚2P—£ñ%}ªœœ/.©î­ŒªÖThVx‘Œc:u/“©u¦Œz-fíù=ñj”gŠÝˆHobµÛoVpu M±zðãPâ Óˆ2 GNWÙ˜bd&RI:Ã'fk–ý"½-,»L¦¿êêKfís§áVøô›û=®½Ž‰˜ÛÁ€>„!z‰ŠÖcèƒÀ%z3qlt:œ“1F c4ó£Ÿß;ÿZÜpendstream endobj 5604 0 obj<>/XObject<<>>>>>>endobj 5605 0 obj<>stream x¥WmoÛ6þž_qûÐUYlÕ/‰“¦K€®[†bÆaŠÆ Z¢m.©ˆT£èßs¤¥XN¼Z´Dïž—;úî¨O=üéÓpÄ“üè‡ñQ/îáeóO¹ 77=ºˆ‡4žÓ G£·ýx4:§qêWõhœDD©©f™¤RN¢É1%F[GŸñèªRSYˆÒ½£/ÇãŽzÔícOú¸GåÏíQÏíùòŽC¼¹9%Ž1§.ò醛|¢OK©iUŠ¢i‡”£•)o-eêVÒÚT$ ™¸Ëc»¦î`‡¨0®)¡+ú`ò"““hØ9·ò¾¦t{Áyçâɉ Pº³Q^|Z¯ûÀºõâšäeÀ¤õº?ëöVÿ»fü­+Uâ”Ê-ɲΔdîe™‘*½ […))Kn)ýùéãÏü #Á4:Có*ËÖ´:Åse³^”R¿v”ʹÒ2%a‰É"3¯0’n))É„µ1Ý ù Sð2÷d,E ¤2Ðã–Êòî¶Ö¶xñ‘j^ès}’—RÇ­çy©¤N›Åuö'“(È´³è†eú6™{e5âÜøá¡TPL´ŒÍ­6+Z1¸À25 Fd“Û¼Òž¥nWiš‹Äy½ZˆÖ¤Ú€IV0ð3¶Â“ •(5ø‹é/ˆ9š¬SYæ_×ß _Ý¡Yå<à¹`>ï=»R'¢°U&œäSƒ s(‘ùZ‹¶ÿ6Í+BäðþÑ©HÓi TåìÇþkÐ×$ÕíT³¸×!ã¥,%A½@r -ÊZk¯I”¸{ˆrKÔø¾2U–íÃϵVCŠ^ÉÉ…·uwŠ(U%Žº—1ý"e{zÖjœ²OÞgÖ€%$~9ˆ&‘¥`¥.ÚBC,«\ð”*Aú¿V¢ã%bM.ùék>œœ<.ñ·„£Ð¶…N`Òº]x{[2—ßt“ítBde.´S t É®X—()(͘_òáµ?ꄜ_{ã³õ¼x1;ÈR ßÄêií@<ÿÈ5æN×€¯LeÉ@Ý2ú¹xPy•Ãüyè3•)·öÎÒLjªæs(…fB/*±`cwüFx¦47Q 1à3o³>êçØ Ô‚•½\Ð&×nitLï3ü_-–ˆîd©·ZØ0¸(­]èeÊôB¥ÐžÌ¬hïMm<äBAz» ŒY»UŠRÊ[9Z4(•,}'W[”O"æ‹k™O5Ü4òõÀÜkÓ‚p‹èUO}˜î:¢æó$|è_Ô“ü<æËì0àrÑæš¿mÔ1Új6ݶ{pؼÊö‡¥ïŽ›ªûýqß¶ÒùÓ°•åšr¥«Í,=Þb|¹¦­ÍKÄ·ðê±çAœsØ—íÑ…áÆãóßpië ¤V˜ÕÓÌX¤¸× Ûúé¥am|³‘w•º¾t|sôŽÝ)áïüÿG~¡s=ŸâÞ®æàŽÞ£gz[HóÔäÝÓŒöÐyuuð)™{ñ)ß~ˆ|ù!/*¥Vmwp¿­;×oÆÉKV.¨Á ô£–EvW‰Ìv(“–;´Ða¨5›Í@ÃÇ4ßÜ‘câFl VÜÄ›!:‰¾¹ê\w®¯B/%‘,•¼‡mfkƨ‰áÚ!(3 †{zQd K1ÜØ¸.V™Ã5#¨}J{(rs“efÅÓä1Ü&ùö¿;r\B0›f20Ÿ´öeñÚÍ.÷£‡“~œ˜ö>/XObject<<>>>>>>endobj 5607 0 obj<>stream x¥Wmoã6 þž_AP ¹ÚÎ[›ôvh­[†ÃìÃå(–œè`K>KNZ ÷ßGJ¶Ó¤îa‹Ó"ˆ-’ɇ©o½1Œðo ÓýÇYï—EoðeóUl`øpã,š}À_Ü à¸y„·Áû[6,¾ö†ã›J:œG´Á‚÷—“ÙüjmŠÖÂñ„V/@ç¢`V°ì?ë¶l'Àj(€ŒÙm”i¾œi#7*Ê6Ûœk)Ma-í^1LõFÆ,­LJ­Ìÿ1Nn¢N®Èý¿þ~ü,5X‹Ü°[QE “ƒL ¿Z[¬VË~‡:Ž}ÈD¶$¥Š-ö[o!Öj' 4ÆèõW[Š(4#Õ&‚ÅVšƒŽÙê2åP[ ¥PÛXòhT')Þ²â}y!ÌÕ:}&sÆ2+c:.ž+›{Ia”< æ´Å›Ï`Û|aŠŸznµ?r›xí³©à÷’Eð³1e†Ò®Çç×YžŠ'ˆS" Ó¸ïS7‚›hJÁž Ó“I4âï»P€sN²@Áqøþ§ÞÊ=Aõ©¢Cª°.ŒÛçÉõõ—íÂ.&ɲï%ƒw÷þÀËþÅ&¸Ø,ï‹) ï A‘¨dFËA»Í*Þâ±Èwïs¢Ðù=Ž8³¬ÕòNKNDrðÊÙ ª±ÑµÚæõ^¯ w•ý&Ðî//›Æ‡€+¨¥æ¹OR&1:‰Tø&–5”Á½ §T[QHl$I¡3 kf„wò@©4Ø_“cØÎ‹¥k h*{G{>ÙÐSvjYr#J®Ãæårð“G}Ýq©èjÅ8_­üò§ZùÅô©(×´³2í Í它v©°Îö§ªÚÄ&Ôs½ï 53ÛÁ€øÖA9í²s*ºì,Tí†{φLÃZg[¨;¯7д0?."ŠB¹6µ~¦Î/&À¦·Dõ0F¼x`4×újû/‡¬Op4’ÿ‡R<ÂKV¤Í*£ú€ã­xb4YÔ+bZ§®ÛÈ8.ËJ$GlĦÅñB`§öãhôºM¾&yL¦H]/Fû\Äï$[äÏ5‚ÇØÚÐÕ7ô“/qkóà˜<ÀI;+Sdp%üȇ§­::LÝQ\£>Ô·»Éè*ºž^Ãl>«o1á4Á¯:.é¶…‡V”|¼d8÷Ó2^~¦Ñx G‰$¯G³h:ñWÆ«ùˆ^ý¶èýÙû;îœendstream endobj 5608 0 obj<>/XObject<<>>>>>>endobj 5609 0 obj<>stream xVÛnÛF}×WL‚Ú¦b’Ö-²’@~¨ŠEUô¡,Œ¹”6!¹ÊriG0òï™%iQ’“ òE w.g.;s>õ†0ÀŸ!Œ§ô罟½A8À—í?³‚‹›70Á"EÙél‹„ϰˆ½Ñ,‡xx‰²ùÙÊ¢Tº€e×pÂÏIñ¡wq3!j`4 'hÅû£ S°k ¹6Ta¥‘¥UÅ R)l…$ð×?·¿‚*QPXPbQ8W ”ÖT±E1Á@%v_ÈÈ¥]ë¤ á¶`?#ï•®J„H(¬Ä+el´Ï×:ßdò³3ºÊX‹{ KYÈTY™ÀÊ ¸l ©Ñ9 –»;„qwyQ¿v1È,£ïRçŒÜe0ÍNôFaµéÀÐ÷ÒdZ$>âuaЬÔèªý¢²HúS„WdVCo s@qR· 0©…”‰LÂÚÓˆ¿¥ÃaÔJ‘¡NÔ®`ÀÚRÅFT²Q8ãSâ9ücÖ6ñ6FÝ +ßv^$ºZf˜ƒ0ÖE_ï:">/XObject<<>>>>/Annots 2683 0 R>>endobj 5611 0 obj<>stream x}Vmoã6 þž_Atè-½KÔØNÒv»õÃ^Ú°a·5þ[Itg[ž,§-†ÛoßCÉN㾡©aI¤H>$úŸADüE”Ìù—ƒ‰˜`‡?þ¸D –4Ÿ%x]ˆi»Êéfp¸.(ŽæââàôûÅÁ…þV»¡Ó«)EZ¬ay~—ÌÄK:t[UtóׇkÚ¨RYéTF·VV•²5Ýê<§­Ü)’T¨ÂØ{Ê•ü<³’U®±%Ä3éd])JM¥±§Kg T;«Ë ™Õ'•:’eæÍ™<;Y|LhÅph˜šÒ©ÒÕ¤7¥±*íi<åÓ…¡µ¾óŠ>Œ¨©•ßôÂ} ÷ð¸T·­ÝL[˜×;Õí z{§W: #ó8I‚UvxÑÚ˜o;ÏÊ¡¯Œ1"ÙJKo!¶.O¼èþcm"æó3ÖV·[PÛ`dž›Ô'!ÄÚºvAŒçpÏY;†«"šÒïÞ‘SE•C§f×ì±ìåéže¦üÚQeU Б¤m³QXšU® ZëËAÐÏæVí”!—dl¦,!¥©U°´¯Ý›&TB¹øZÚKvhù<ïëŠHª¤u:mr@Ö…[µ“¥ÓÒiS Bî3Ü ¨‚¥.ç{ù}j]áRu'…ú& ñRB “5¹ê„;}ÿí-¿Òeš7™¢£Jj+¶G½Óã/í™ÊSïÓ\Ö5-¢µoñeO]Ñ øJêÛ#"w_©L­¡Ž²·µû›7úUw(S­Ð?ÙóbÝ%OôÞ“öj_½Ü¢>6˜ °U;8÷Á…×øM[êÂÿ=Ë—ÎZì¸Cl9dy­—'ÞÊ{°Çÿ—^ü¡¢uЇ’~iäë¹¾¤Š¾ë2-Z+Ãd4]žôR90•ƒ#£>ªDÀõ‘\ hʪ/ºõÛj§MSç÷#¦'«}êYq‡„V ÄÔè¶²¤zknKî3®ô½·ô+keÊI×”Büº6 XÔ‹¶¼Í¬Šï Œº••SVÐ)T°ž˜Ö[Ú6iù‡É=Èb_盙盛K ðÂècq@:HOª,œ/½fceFÖŽ!?…AÄÆ¹oU3.ðÉJa8ÆÈhuOµ§`GÌ–£Ú;Pµˆ#ºö£+kB—;“ïüÕÊ›2kpÏ>¡C½YÍÔQøAd0þ¤3v|É­@¹þ̳Fׯ[wiG—mÿ{À>ºgšýñü@q-èmßz×3ûF|¬äYèÅr\`ÈóõSËÖ­}T£Ãè2 teÌ#®ªšêÉ#rÐùˆuAwO¼û+ù ¹Z8½:o¿T¢ó©˜%3šãó' C˜§Ê˜?Š~4iÃ9ò‚ý)éñY@(ŒÆ„þ¬¹¿>Pjݨ ÕÕg“¹Hb Vøô,æ­ŸƒßÿÎÃÍrendstream endobj 5612 0 obj<>/XObject<<>>>>>>endobj 5613 0 obj<>stream xµV]oÛ6}÷¯¸PÔimÅ_±S·õ°eÍ`ºÕCæ! $:V"‰IÕ†ý÷K‰Žå9Ù^šŽ%ò^ž{î!ÿì i€ß!§üeï–A0ÀË݇¾¥³« ´\cîô ¾Än_¢î·d2¡-*É­Ô´UeS(©42¦$§ËׯIZ«4U[3?]ÞuήtŒp4 þhŒÇxŠ»Ÿê£Õï®”ZPAïéRKa%WÝÕé[":;kÞÅdT&7jK«n®,|ÍW§ŒLN7îAÐz.ú‹€ŽèèбÖ|þÐ ÃΨBÂC¡}&-ˆñz‡ž±¾Ûá8˜NgœÑRÑV‹‚ì&1=2IV¤Y™¦ôéóõ$BUZ JòTP” cHä±{ û©ü"SΓTx'#ÐOâ^’)µ¤J• ÝX‘ÛÄ=”&Éoý®FœŠ•Xœç$kÊe$º €«I>ŒÉç‹õ"Sq™J?Ùc%þ…_lµ«1×ôt—Ÿ«øÛcâ; ògµí±À~,E@‰®@j~ËB` Þ•ÆÒÉVéû“ç÷Q ­ÙrÐÜc‰ûýFv$jÁ÷½à¶Rdà„öpø €G”†@ µ­ºÅ¼Q8ú÷þ/µ]¯ ˜”ýh‰ˆKíÄTæ±ÔiŤùÝhiKcfXo‰[µný®*¤Véþ‚; ô*ïRbL×;I£ûÝ77XQ®onŽAdÒnTìèÙtBý_j\К;tÞZÁ1²~u»2´·anŸWuvohˆuÖ0"6£sߪ#XT0œ:ûðÉÂ&*7í}sÀ$˜p;A†+iˆÍ(6A“VhÊ¢P°G¹èQˆO,màŠRk¥ m7I´!þ…#$©Ð}ÞÈZcÔu™G¼6|Bg  ±È6±Èk µ«‹hHå’¾ˆ´”Šèž‹ÏΉ4•X¡6œÒª ÉòËŠ2Q°ÕT˜o’ˆlUÈ&·„£á°è8‘KÌeÐrÃ5UÈ$Z©øÜŸoA6ØŒ èV²0ê¥VÝ|[Š6BÓ+¼ýË#;‹!?ëäšâDÆÁ ˆƒ54l¿ÿ›g=i+Ž–mG-n ڈ͙¹hSP>q¨-ö·ÖJ°I¼õÖÍ¥Ò"’\4ÇÛî<óNðûås¶>Ï.½lØ{ÙÂòÓ“|>t!™@\´)óû£Sò7­¡?=IWc1[8ÌJ$,+Âô‚ï9 ÊØÙ$„ 7*Xp®ÖÌÃî©·× ±ŠÊLâRᮬ\n†Lä¥Húϳ&Ò§ëÜ¢._6ÜÂÈI…–7-â8á6)Å2,oA ôÊâGk­º¦äÄ!r%pXºûÓ÷˜ŽïMá6ºO‰Ã®s0Æ;Æ=ȸ©>s§è=´g¿%1ë5&_±v¸{AžM×¹ÆùùNJ R÷=-Íû†{Á ’fDh½Ü$zbs>ÕÁ×­µHQa¢cºÞ­ç‹-z® ÁNê_9¯ÑXºÌ3¤¥˜Ï oÅLjé¬ñnohÚôÜEsö/&Áùøœ¦ø?k®Ê¸.öÇÁ€¾oÚÄ阋…c¬žÝŸÕ·àú ;w™»VÒÇú²î³óÁ4p³Ç6™áòóKço±„endstream endobj 5614 0 obj<>/XObject<<>>>>>>endobj 5615 0 obj<>stream x•WýoÛ6ý=ÅaX'u$nê¢Ò.Y[‡ÛŠºhжTK¢FRQŒ"ÿûÞ‘²c¹iŠ¥A#™Çã}¼÷Žþw¯O=üëÓpÄ¿2ß{=ÙëE=|¸ùÏ,èø²GgÑ&sôhô¼FÏh{«Md‡šŸOo>)-h^Ò¥º ýÛRŠ,Û?˜|ÙëÑQÖñÆÚTE®¢¬ãç§~[.°W&U±|ÐÞ{ÿ…—Ž/Oˆ}Íé †MD_ýF©%1Ë9M.1º¦¢Ê•I%¹U©l—ÞñG&Â4÷±¥ˆÉºx<¶Î¤ÅŸÔ©Ktå¨4îòˆ®%–™ÕT›Ô9UxŸ¹(-͵YG=à,½/u+Ué+ÁîSg)F$7*&™ k9š:IeBR7Ê8¬è~SZ Q2FDÇEÍ)ƒ>å­®6Â5.´#„fÓ¼ÜN_é É“ž“ž}QÒÙˆ&\œbýNÂ(ïáFdiLHܦ1Šˆ€ö¥p2Ù§Y¦å’÷)£®_\µ’–¢à fŠŒr•)¨ï‚*œ2%>UÆ{À±7©®Pe±²l¤‘†Ô9;Ek]e1ûÁŠB@ðHµ*Wœ‡’éÊãt;”­Š+ö%š*úv7]"Ǥ«E‚B’U*·›ø°©Téæþ@~P¦Ë(·­èbˆasò¥¶6`º­prm/™+ôÈñXe<ÞØ¯H™1èv“ÛäÊðæc¸ óci”`·ªŒû.ÍV@Ý\T™ g6Xc g8g Ü%àÇã,0"”ˆd|дz ”qMñ1gÙVˆ£Á ¡qçFJþˆëóigzž§óC<]¨Q…†¬ª&oû¢µ|ÎyŒ÷uŠ|¾T¨óšMhæ´Sjm²Ÿ½ÓþÊ2Ø„#ô€©éYaDŽؔÙÀr^e]š¡1ð)2ÚZ›¥ø²·¯¶ÓoeÔ€rÃöñ9¶ ¬rIΩfxò•þFD¿•\Èg^?¬¹P¥´÷ÿŸÜn}õh&@‡Bu(gm5…ÁD7¬(ÌZû•®(çNnYcoXnëwjÝBXš{ED[¶hÏ^×Í+o#pke…~BG@—TÅmŠ\͉A€Š"äÐ s³—WkQ îÊ•ŸÅ- ~W¨ r"ޱÊ3óÀ‹”¬XP–.ƒ¨=N•'ÍÎiÇóÀ¢|uбNÏåÉWj½a„^—•Mq§wÝŸûQ d3å¦/èø¡Û*çp6NÇãµI#­œÊÎüÁh<¤\Y+jç0îßõ\¤™w ©X,xºðÜòS*Á¤ËÔf†goÓ‡:µIèÆŒ„LJ ”Ø(ÍScÄ54Ûk£Ÿ4…o²G›ï4ð€V¥¬µ"ã䘻á6Á@÷z"Ê2ó£íþªÑAç…S¹*\—ãr Í÷hÆËà r?w¸>­x‰‰¥nOêà‡âš||Aÿ¼¹x?¹úã÷ëׯÿ:G_/nå]hÆa‘00Ô+?L·‚h‹”:Àž­Û²\V³,•»Ú»i®Hâµ æÈ:ÁÌ~I²­è|gb Y®¦Ü.ºywp:\wç±³‘ â2z»v Z‚ŸOðò¹½x·~ ¹nM%ʼnðl`™v8¯ï ¦°Ø9tz«­ŠòÔjÅzç‰y˜Ë)&2î‹Â\g™®™Œ¾2¸41h!˜1†f»SíßÉßž½ò l‹e|åËGÁÊ)AÔ°¶¾nþx*ée×(ûÒÐH‹Íô •Ñ+¸G½§½ +Ç—g Wúg'Ñéð”Fg›iÏd8F=úUK\¹ Ð$c‡¨D°>z¾ ð…"êèÍÓ§„¢‡K²eÓÓÞ(ðµ >/XObject<<>>>>/Annots 2687 0 R>>endobj 5617 0 obj<>stream xVmoÛ8 þÞ_A (.ÅÅvÞSÜ»­ílî`_ª-'ºÉ–'ÙIƒbÿýHÙNl§ÝÖAd‰äÇ)?óÁÃà ý‡É™Ç<|B_>}ý{{6šÎÙÆ3\Cã7«•‚{:ãÉÜí LJm5–h7fÃê í5– ÌÇÀ9¡=2cÓƒÓÀ›³ ±Û\'Œ&‡³dÛ\ãîdÚBÔ\'0ôÛ¶/Ù; Ì7Ìú2†ÀƒÉÜg“É–‘ãȃeØ‹¹²âbùß™}ŸD½¿ 32ÍW=#ìꢵUXa"žóxž7ü0›y­í¦% u$.ÑKìºãf€ûû¨­ˆÚh5¸A‰¡ ûÁ°ݻӹX€ÌAZ@Ø2m­|TV½|£‹õrI] nÈ5løV‡¸HÃ\êòÑ;°b+ WÉ8F¤9|“idAÇ žB‘ÑQË`‰î…µh‡wR©k@<ñ½†d!Wêb­”Þ‰÷øÐŠœ\ÊlÎs‘` áF„m.äûLÐú-ŒÑ†Uþƒù§T¹‹Á‰LàÖ‰ 8<‡½. ¼û¶ÜÂÂØ#z°™e,CîÒ^õvn“Ò9DZØô|uÁàÂ;<@G©-Tîà¼qHÚÍ„rê]×µ˜Øð4R”ÕNæ8ǰ˜§m»¨Ù{ƒÌ”å@«ß †…l8”éW!¨&UŠDÎ¥Â*§°A :x)kåÓ¦Ö Bsk¥±Þ{Ê™ÎåV¨=JN7sðQ1¦~0¡BØÌŸÂÇêe%U¬UNGÌÕü^¦¡€û¯ŸnûCFÉ*œì€c&¶È2mPè°•Üxž:· žF´etŒê¬žehŠ ®ásöûå~ÍQ!NŒØ”ÕS’²–ÚB)¼ö ²ËÝPÁe èÓhœ¨ó#Ú±õ0lnŠ€"ƒœ}cRa)Ÿc¢Ø¿¨ú ùf+"ïQœ2Æå[6 ®n€EÉhsØõƒ€ ‡8ú¢Þy¢£§„xâI¦ÚÓ®æîËþ«6*Z,î–ÅâÃN(%ÌU­ 7ON;£ú N+Œ†Ô¢ä(àC­›Uz#0ë¦Wð£åµa±åÈ"M´?aÞv{ *¨ðÜr*œàìeÅ£’¡£é0èi»ÓÞvDÀCŸB]Ð0'Ôm¨dCpCƒZΤ’ÙÐpÁ¹–(W0P²\~ÔÉ—wµeN2¬ó¯êöÂ>Àk,B‘ ÜŠ”Dö _Þ}¾FXÞ%Ü\W¿}8Evàæ» KZJâšÕöçÝr“͉«6Ínõ“{p‡“ÍèÄupaùZ¸+ÑVWýy;®éªØ jíÜØÓVy^sP‹·cÜ®í‰q%gvâ¢+®Ž?ÿhZYGo_¿‰­Ô«´ÅHG¯¼ Õט:ŽªF[]t¼ù\DÿàfV½ù³Ç0â+`9âê+>è_plÓÕOføUžîOË^zù:{6 ðÒ 6šŽÉòzyöÏÙÿ±ÔQendstream endobj 5618 0 obj<>/XObject<<>>>>>>endobj 5619 0 obj<>stream x½VmoÛ6þî_qZÌF-Å’çeØ€ÖM†«»!òÅ@@K”ÍU"=’šãýﻣDÛr/Ý€!!JäÝû瞻ß{Œð/‚dBÿYÕ{—öFá_î~ôÎn¯ AZàÞÉ>äî;>dýø2LÂè"Œ`ªª5³b!Ja·0S–Òßzg·ãÝÙ ãÙþ]÷w?0 k)…\‚À`Á²O¦sYkªä°aÛ!ˆ‡°v¥j vÅ¡±ŒÈª~ U Ê<¨¸e–-J,„ÌѰéBèƒZ[¡äŒ Ë<´d%mAÅ„,»Eç’UÜÓ–\rÍ,ÏaÞ—ÊŠŒ;µÌ¹6™Ò|>¸ö 0"« Æq˜$¸ÊûWÞ…¯ÿ#¬µvÞçO¬Z—<ü°}PºÌÃ7è$|¿áeÉõㇷ?ßÌ££Îꥆ2U“»ùàÈZuÍÑjŸîÀÝ! '“ BísÃŒÓì=•Þ’Õ2[aÐ|îš#ÿ5o—¿£LpÀ˜JåÈ–‡•À é¯ç2kWÈ9úŽ”B"iÙµj—ÜB´©/”ƒœx"‹BV2cüû _Y&-òDæí'.ëÊ„®”9$±¼ƒÍWÇ\~å¬ó_™mµP%=wcÝw¾ˆ—Ha /Þª‰¸ÆßZkÌ6Ñß½uöBÀª{-Íš!s1\R™äm!¸-dŽù~³eŸ¨ZðÊäÀ™Bwè IÕ„ŠöÃuà$æÐ ¾¦œP}K#°r:kC¶s¶8­˜¶;ÝM U–jC÷š¾yƒFò6,#øÛ’{Ý:lkÌßÏ GÙÖÝõuŠ…÷}gË´›àsç{Ã:wô`]/J‘9A Uqc^WðÒ›û4‚P»†î9†/»ÐaRØÂÝôãì>¥3qã—îr)þvL Ú[Lã—bŠéPÒE᮳×ý#y åÅJðj(ömiî•Ù3»65+¢9Êž JboDYÂâÿ“iÊú£Kä|AŽ+¬Ï«¶¾:‰^(ÝÎx“òo±wœ}ÕÈjì0'{«1äŠù…ûƒŸDÿúÆ~;þw’î hõ,R/@ L)–+ ¹( ”‰GíÆ•2£¥ÛÔé~o ¬¹†)™ÌqÚ¶ ­*÷Z×™­uÛ÷ùÓZijû(±Â꺮ÒÈ®oqLn±¹óB<¡P…ð‹æ–{1fÖ1%& DÜ–\ QBm#‚DmܲQu™#›O_'u¥MíìcÚ8jòíÑ::Îce?à«ïø ÜI ¸À˜eG½ˆ¦7ÖaFH¬¸Æy Á’Iñ'vN%Aøaw©†`Å䜛VðŒÀŸŽÁ)…o´ðÃÜÕíŽ<ŸÝ^¶Cdt9Ï“s˜\îf6šRƒ$Á{•ÕŽî:0 S³;¸hÔÝê¹1ø|4 “çg£Æ²q“ö~íýé–w‹endstream endobj 5620 0 obj<>/XObject<<>>>>>>endobj 5621 0 obj<>stream x…WýsÓFý=Å6“LÁVüœNé@ -3 ýÀ3üPw˜³t²®‘îŒtŠãvøßûvOR"(ÀÒÝÞ»·oß®?LhŒßšÍùO\¼\Œ£1v•k:½ÓE4£EJÓ1ÍŸM¢ùüœ‰¬Ó"ëi¥*ý1­m¼,ONŒi4Áûdðù‡ÞÇ8WUE¯tinuB—´©W¹‰é%öÓ¿½•Ô¼»Ü{ÊÇ%aÿWNä §×gÄRøh:k€Þj_0Ô…¦Ô•¤¨p…FLŸ)O^¡‹•.‰ïã³X_jª¼+ÙX ñAžÄD©íŸ8 ¯V¹Žè·RßWWùnHÛLÛ^W´Õ¨ï6®ôé½­U{Í)³–Ô¥±k@Kê\ãLãÊÍ?Šá ·¾Õå®%¢Á­òœ*]ÞšXÕ>Ö÷‹åÀD€vÔ‡!U÷T °êS­ª À”ÅO’ļؕ¥®6Î&Œ²ÉFb÷‹=r.é5C÷oMKWìcüŸäÒæQËVU» îúÿ1Z ò+GÎF½.2ƒ4áE¥Žë²‚^iSºX#5zÈ[ Ÿ!Àÿn3'©Ê M¯,§ ÔšA÷ùá Ã³ë¿oaLÏX e¡4(úTvGq¦ì"JœÅî!'*õÐí£ª¡­«óÄ~ïI¥©Ž[©74H‘õ‹}4F³J?puÓ¬*6Ð5ÓÿEã’–4a¿XõâÎK qÜPÃ}Ïh ï’Æw“ÙüüÙÙ¸MŽxÊsZk_h¯¤ÎB°åÉŸ¢é¿"«·pÚ@´Ü-OI_—–îh4¢‰h‹ïWõÉ\ÚÏC²áPÈz%ÙýnÏçú7k1àPœu•éø†åÑWÝq½+µH{»˜ ·»Vù¡ÍæÖ•7Qg¨‰Óç8惫²d XW+¬`ËÖäý£øÓ½왦TÃJgŠí¬”º*L"zç¶TÛ\ÃÖGA×#ÎkEnÃnE¸1êæÖÀF†N1SÔVn*Ï%bü÷•4êɤ(0tµ+V.Gˆ«˜#'#u5¯CxÞé¶vßøP’ü²‹Ê®U bñOã#ú5 ìÃÞ¸¨–AÍç»V5.O¨£@Èüj½|#oÌ–ñ(Æò¦»”húq„¬<£ÉY?h›ÙE4–.<˜^ðãÝFj#áî3ÈMï,º¸.‚$T(zÎÚN® b¼Å7›¥Å1õBé5*-àm‰NUv©6rG'ïý‡7?sšµuõ:ã¤iYê$s¿¸-÷-I®7D"{ µ#«¹á@ÞÃFÑuÐòœU9÷jˆ$ª£ |ÛÌÄY ]êr³A¢»QšòJD‹¸CôÜ" _I?fbøzIh Bt‰¤Ñ%÷J1H¦sfšMèS FT ò§~y…äˆÃ¿h—ðz([Ú"×+¾E„Ø%~gu)ÝŸJž¤ðÞ+‘4›U›ãÔ%ðFÎmD×rç2E±³HàY¯×ºìT( ’~Œa„^ içj*Ì:ã‰+5h7Ý…¨†aªo·Žã¦5š:ÆH²Žña$±p5ìöG@’_Gx9¯òX–×ê£w¶æm9x;<2vSãEÎ 1Cr»I—ƒÃ?t¬eæ—«cüm0ª .xÌm{÷#:‡hUΓ®Ê·jmU•‹â uk|Ö8r+1ÅbïÞhDox0ÂñlüãÐØCŒ1>s ì4…êX`xÓ²,â ʬؤ¸%pZaKkLê>Ί<½zò¤q¤FßB>_œ]ª}†¥EàiËQ[æp°CcSÕá]í!AÍ!*ò ãy[3·*¯ái÷7äÚTÄÈ ¥aZ·ª4üúƒubh¤Õ Äf9j8ÂîVr¾r,ʼnv߃¾§ä.~§ñÕ˜€&X`¬!ÃØDßa¬f¸¢á¡ 8s%7aNa|‚'ã¢Ñèt|==%|Û‹æÒCبG³hL¯\,7â]˜ÂâÑy¨˜à,šœãkãÛMüòéxͦpKÿÙù9?z½8øýà?dF•Šendstream endobj 5622 0 obj<>/XObject<<>>>>>>endobj 5623 0 obj<>stream x­VßoÛ6~Ï_qPÄñdÙ–'m—¶n†v?\ôÅ/´D[\%Ñ%©ØBÑÿ}ß‘’c¹Iž–Ä‘Lï¾;Þ}wŸÏ¦4Áï”fsþK˳Ÿg“x‚ÅÃ?³¡ñÛKšNh±†ìü%^2¿—tð1—¹\Y’{Qn IxMu¹U…ÌHUN“ ?jA¥ÎêBF¤é­4ÂIKÂÒZ…ÞÙW‹ÏÆo'tÏØP2¡Q’ij¾eƒ7däçZIßµV¾cyÈ0,ÞߘZÚÝx-R|›//–=Á¿e*Õ=€‰Š±É4ôŠæ=™ëdÀ¼¤iÂXFÌU<Ÿ_³±ä&¾Œú`Uµ!×le)¶6œxÓ(¹Œ/Yz‘KÀø”¢jà‡ÈÚåÇ­=M«Z.DëŸw¿!*†DQp Kä,-€ѺЛkƒG¡«MDi.Ì0"YÕ%\Ël#—QçÜÈ»\¥9yõµåà×N—©†šˆvÊåTi’kw]À3‚ùF׆¶Â¸¸U˜x×~×;y2X6诽{Z×Uê”®,›0ß¶µëÚáÁºD)4–ØQcDc#6𺒸!$N)>IâÃzM?t±ŠÕ›ÇüJuå„‚ÉNÎÃr¹Äq«\ G(¦·0Øf †%•Á… wÀý|6Þk…Ê2´GJWŽA~ ´uá–ô¥ ¾ÏP¢n‹niOßSóº·ÿµ‹¬—fM¶^Ãý´ÕÝLÓk¤«ME ›ésj=p»ÛV±m±mó˜bFán‡vß×É®Ø=ÖO\ðëÍ­ëK{Ç$ÔÒ¬«¥;$=è¢w ùPÉzƒì(¥‰ð]8:!=gI”íi Et¾Ÿžû¬?oø‰è“í8˸&Îí¾³Í‘X›“ÝmøRyÈϘº,‡õJ;[lJŽŒöµ„B /TÖÖ¯ª Q2Ǭ€µ-O à^Ãøüð` wv¥é™iªMz)š~ޝ@#RpaéºÈh%à š|ð„ÙÔ%£ +šrYl[œrCl…I6ùàÙD~ÿañç‡Eàχûôk/o)Î >RXÅŤ}Ñòež|_‹&,v\9`y‘æ \â}°ìL¸óˆ;ˆnWÁU´ '»Ä U¥EÉWtõuìs¡)øG_Žªöëk˘ ùö¤š»wˆR«å¨PTí§>9½ï]~>£ØZ•G%z¤ÒîTZŸRmÊsž÷£uúŸ½èޱúuËpŸ  ¾à³¤âE²ç¤úýì óƒÁ½ ŽÄ cwØïÿ<}O£ä› aÖ»–Ã`‘ÉRÇ>MON‰hu Á“Õ4Ênƒ"ÏÁ:Oæ°Aúd{ ŠåŸ$<OoýÉ(¿ÓèñàœoȔ鬫xRënAƒŸÐŒým´ Ý×#jýÆœ¶òíµO´žô˜»`x†sm…µ~DÄ`ƒ2÷r‡âÀð‚¡|Š\ÐFmT% ºEíçKFŽyR­,<^f™Ã빯V>/XObject<<>>>>/Annots 2689 0 R>>endobj 5625 0 obj<>stream x…WýoÛ6ý=Å¡@7§µÕIºf@—µ]€­ÅÅ6 -Ñ6YTE*nPôß»£d[®Ûå;y¼{÷îÝéãÑ€úøÐhÂ_Éê¨õ±Â?üãí«£Á8:¥ñùY4¡Ï¢óúŸŒ®~™îSå‚N^ŽiЧé–'çø#ƒø#é¼¶^?¥ËÇ©Ôs]ê<ÑŽV•ó4Ó´Tyšé”ô'•øìžüR“S+MkuÑov­ïtI×ï¯^ÑÚd©ÊÛ•ò&Qv¯KU¢ã釣“—p_<è$6‡q“ûƒƵ)G*çÅ>õCxÙ1yQy*T‰;=nŠ;ÎÀAø¡`“Ý[9Ü%;ãã(Ø<'>Ïáö†64<‹ÆÑˆ¦÷…^©‚ïII•¥ºwm'øÀ8ó‘çò˜ŠR;{Ä‘,•Κæ6ÝF‰ªœ¦ÌÜj*,¢Ò¥ €¤@æÖÓmn×´^j€W2‚Ø®J<&X²•ç(ïTVi×Å‘²…؈—êGs6ÄÞØœìœ–0Ÿ©~©<Eni«,…wÛ$­_JþŠÒpdQ™T1–b:ÁQ­œ©³† -T7Òw§sÃTN-´ .°1h¯ Ê5ó*OØC÷4 ܧ3NÀœ†¼yFø/íèO@,§;kRr¶ô7€0FÞý#¥Ëûöù_7×W¿¸ô[ùèõDm˜. „Rp☪ÛîµáD #v]Ô÷D¹^‡·½#>&˜­µŸ ‰Õ–CáàwzRëÚÎÁZ­d¢ĉ;ÜМ¿ÇTÓhLàçÒÿcþ½8µ“ aÃÞý´ù %qM)CÆØáRK0„ !Œ8K®Ê¤%~»v7C8C¦!¼8O“¦O¯;ÓèÔõ˜A³ÐéB-q¬MÅsî¶5Ïg07/튓,mÛTƒ«ôêMWžÂ~²ÓŽf•Jl*‰ÚF‚1Dfž+Ð@Ö¦Ò¸}Dt­ÃtÇ/‚L¸8†™8– u²“‰2ƒä\¸ù¬~ßöÇѓњL&ὂÞ(êÓ¯»ÂXööNCöä­eH喇7Ï;Ÿô'Ñhˆ×´œñé9/½˜ýyôÙ¢vÀendstream endobj 5626 0 obj<>/XObject<<>>>>/Annots 2692 0 R>>endobj 5627 0 obj<>stream xÍWmoÛ6þž_qÐÕIcÅoqœvÐ¥IW`mºÖE×ÁÀ@KTÌZU’Šk ûï{î(Ùq»eÀ>­/¶%‘Ç»çž{îôé O=üíÓpÌÿÒÕA/éáôùãÍóƒÑh˜œÒ ž iE£ÉiÒo® z{0œô“ {É9? “Q¼àg?Nî†N®N©ß£iŽsÇçø‘Éqø‘vÞ+WšòæñáôãÁÉÕ¨Y×!SÒ>2ýY{òA¹@*Ðo—o®ùÙϵúúéõ«Ë„Þ¾ñœôçJ§ÁÓEW9§6ž‚¥¹¦Ü…Î(·$¯º}Re&¶‚šÚ³=êöp±·ô±î˜f°Ðñ@8 Ea×°Š›¥u+±È…*oju£g‡ ½(åyØTz¥*Z/tI&PjË[íௗcÙ9U’xÊ+>ÕF‡b³çLº€e ±ç†JSë28Tlšª%;4ÙËŒGÀ uklíÈä´±5áR“®y]¦ÁØN™tAN‡Ú•¾4iNŒ†W0ù8¢ª o)…«¾®*ˉàâÀÊš2hÇ6p‚7+S(G+U–Ú‰½“«sb\™ÝÁ˜-&ÉÜ™F€¼ä¢±Óm¾·žJjvü`²7ë¼Õ€Stñèfî”3À©öé?ZcÈS§Ð2H…dºÄ…ÆÆd wǔ䪵ÛÀg¾à 'ºaÚÚ„…ä¬çr K½nMè¥Iõ6Á×ë—Ã3š†_IyZë¢ào`¹!‹ÍîN˜’QIöµ‚Ì#¡§%JB­ªñzº1·pq®Áá¦îz4A©#9Fv ‡¸Ê:>¸: d^ª°xBøsrBÞ®4 ’ÔN·çqQw@ºT糎l<:¢ª nvø„·3Ü‚1?@¶UÎÞš¬QH sÖUU1¸ 'ÛÐD+qÏëø1Ó;/~X‡Ô®¢À. ßü,ÖŸû©Ö^TÈ/Ú„Þ(7‡|"}ê4èLJÒi˜Xb7ç•) …©ŠÍý~`Ê´¨±þn€­Û‚ÿ„TlDܦ^_‚©×羚ßMÿôé舉K qס`n¸R¡‚¶Uƒàéÿ±`¦À¬ö )@C–šÎu?pvyŒ¸÷)?;¤n—)-†Ðɸ¶ Øô»åÈj0ëØe,in«[.MÁÖ8¡­tf®èçaŽr[UE,tûÚÄú4IzQðë”ÞƒöB¼¦Ä=í$;ÅdÂÙ™rWôà·>ð;uf–/ìZÚ#w¶•ÍL$g:Wuq‡ûMKuÒðoÑjl Ñ>áÞ“© ¸¸÷´u]Á\…Èsê0JN±¸{»Š¼K`fmk…ÙßNxùioœ ñäѤǷ.§¿üY¹¾ endstream endobj 5628 0 obj<>/XObject<<>>>>>>endobj 5629 0 obj<>stream xµW]oÛF|÷¯ØúE² 1²d+Nû”80’Æn- /Œ3y”Î!yìñhY-úß;»GÒ’â8EÚ†!‘÷±73;»÷ÇÁ1ñ{LÓÿÅùÁ›ùÁ8ãa÷Ï-éÅ{ŒÓ<åA³Wø”È|ˆû¶öGó»ƒïOš1}ò+SþRëÈi_»‚ü¦ÔxàlNi]ÄÞØ¢ ÓŽÏšy£—‡3Oú‹Éì%…·íÆünt<á·Ê-°§êö ®s]xZ¯L¼â Tìk•e›&2S,©²¹FÌÅò?Fć‹W:þú= êJ'ä-%Úk—›B7áØ{í2«¼mQ¡jeë,¡[M1ÂÄ›E߯4U›Â«”¿v[âH¼ëhÜ“˜4ÕŽ,h·ƒsU©Òa&¾v2Yµ8Šž:zÀ{‹WÄRM΢W4šž1ø|MèúËŇ^EŸj5:§×W»X ¼ÉItÂã笎J‹H?”™2EÍhY‚*`iR?®Ñ…§ÄB?…õ3h2<ÇÄf”*ͯ”·ÖY†)±p U‘ðdŽ©jm_…å@}@«7‰—£5’vsn l쯼[ô³ZÝ\{åõ€> y„)ý0¼·& ¨ônX­Íò†Iº1EjiÀedš©%ðþežI·Ÿ ƒCçq+·%§U¢aõ*Æ€ðÆ%Ê+–™"‰Dpóê+€ãÕîUVkR^¾,ͽ.BØø/°Ê>Pk6CNc2/ßn&;¬ °Æ•ÎÞ›Ãn…ŽuU)·©’¤G5ä¸SÃ)°Ä¨&–ÒBpŠSÇ6/•7·™Þ emÀ¯Ê0R;õøk/¢9ožšBÒºÒÞóò½xèq¼<±Ù§$ðnÊï…Þ«Ë‹Ïów¿ß¼½¸¾üòyˆI¢¤½0pÒ8ÓÊ– Ùu¡]µ2¥¬(«Ù¥½½ƒ¾ERÜdc9𠆌`J±*$ÝÙA Õî°¹Š]ÝEuùqÑ_Õ´"±lB’2áá Ÿõú*zy{·'U‘ÅóúÄ¡þ¥:mYÚÊ@"6ÝÏÉEˆ¥¬«Ô§ †u'šÆûÖN•%ðÛ¦‡z¢·øåƒ?z\©œ‚eC3=ÄÛk=[LÐæ˜I7å$aÀD†7Ç †>Ûvs‡zäW¶)8w “uÆHRòÉ ¯¥ýÆ…GªE%Ý(̵^öw& j×””-¿…wk°áÐòâè¦ "¹Ñ+±FR\Ž‚æÛ«ód|NOiv†{»PÌ8šFczÛ\‚D#< 2 ƒG/ƒÉÊýí˜æÈK¹"¥hîxÆéxM'áj~rvÌÞÍ~;ø¸|%€endstream endobj 5630 0 obj<>/XObject<<>>>>>>endobj 5631 0 obj<>stream xWmoÛ6þž_qèÄYù-uÜõÃÐ7wº[ ôK€€–h‹Dº"UÕöß÷ÜQ²#w@±%F`‰äñî¹çž»|9Ó¿cšÎø“–'¯–'£d„—û?Õ††‹+h¹ÆÞÙs|Éd_ÒAÈ5/?Ÿ °#{§VóUÇ·ÝÉe¦Ò)/ò´vEáÿKwtžLÙþdD—“I2â)ë Ý ÊÝýº¶éÝ9(š—7Á8{7(juTÐ?¿¿;A4R¥7Æ]ùïwÃJcBN·ŸnÞñõ¸’ÏI’ôžOÿê=þøj¾¸Üµ7Rê2Á`o¿oŽŽ¯û»wÛ©<¿h¦Élv;.ÿìÆgK­r ¿©r[è º(¼€UxK¥ÉxRĘ3ÂÇ ¯væ ὇@Ôä&Íù†àh²LgœX'î•.« MµÍt%/¬*5E#{޵Œ82}–Ä@Sd]`Û=O•ÝQS©í¶×ŽíÃ.Ì x³s6ãSÆnÈ„ƒWÝ jUè„~s í\ c&hþVI¾9*m˜^ì¨Þr„XZ Ïi ¸¸ˆ.'3Æm2OfÉ„^ÆëøVF[ô¾V{úãsWÉŸ|é©AÞ¸’Zg~=|ýô©œ¿@ gØRxG[ç½ïì6GŸ]c÷—ñó£MLó -#&³÷M§uÐ}TM‘F¸ã˜< q¨ÂxÈ€³ðÁ¦E-ˆ²ùS^ŽörܱÒÚRŠÃ:ëªo"!.±÷ Gé?EÉwõuhÀu¾ñiO:ÝF€ô€Ù…SìYB\U‹]̪«‹Œj°8øGˆõØÄèuÄ]ø6Wor1—Š9­¼}PÌ+[¬‚ò¾åLjþ]Û„´û¢uz"t@Б¸ìýê =ÙTZ‡»Ô¯‹A ~¶kÛ“évÔ¸ªÈžoÒ¶Ky¼wè÷X®Œ#ªØ=<éYïkÚ±âý@ã>¸`@¬N•öäÂÞª*[?&l[™àM¥0‰bÇW<‚ŸGù¡²ör%<$ Ê ©‡Ž¹x‹\‚Ø ³,Y–tUA?ZIíêjÊ|aùa†‹Y×Yâ«CCôÁm;öcaö€ýz­ê"àBøiXb0w­V;cÚ”í-Ž~•Ú{µ‘Z÷BZÁeñµæ O¶††Ý@ß|OÒ\Y>ÅAn]AÊ< ¢:n?ÁEc÷]N`ïß|¼]þyóáÝýâåÍû»îÎÃGUÅã°›™µäéq°~zÌüZ™¢/*åq¢Ór­BÝö¯(«ÀÌêFL\¶±bs0`»t¶Ç ?¼AO4ëy"´ôbA_Ñý0߯þé‡P¢¡ª*µ‹^05âR<$Å@Œ-@<6ys´kz£âóMbB2£VƲ6õq‹M`>ç⿉{·•fzxò<_±â*ÊÍ&¿,ôW]ÐWƒð ›”ÞÇÑ7^œóhV ;}\‰È“#¥²|¨×kTz¥6ÀqͧÚJ9õxWª‡–8ñHÛ7Z—¤$̶P(™Çèb lýÌäè®BB §ÒÜ ŽØ%8kÑØÏ\Ï‚ŽW¬ÜR(ÌúÌÙ34V°]4H܃çZEë‘"¬´tp¢Bª—L|6Ž‘Ú&›: =Qr¤²qXìÁÐYçêBç-.@eznµÃ¼…áÇJ¸ù`áOƒ¡ ;ãeÈ>Ϧ­¬ô‰óÝìpŒéUäm ·Âà© ÇÆÑv—NwzS„¯KŽQ$–Ç™\e1;ííWÞè¹ÏΕ ·ï×¢.àWœ‹2zü™Ü¿Fÿ·î'rý #¼Ek\ÎIó.æ­¬ŽçWɳé3š]O’«±üÏÀ÷^N“½qi]‚Þ2„° ˜ ãîËëh]Ư1}jA†8né)¨äÊnNô|öÙh–L'˜ÜPuWó ¿z»<ùã亇$endstream endobj 5632 0 obj<>/XObject<<>>>>>>endobj 5633 0 obj<>stream x­WÛnÛF}÷W òPÉ€ÄÈ’íÈ)d 7ÚE\ô! Œ5¹”6&¹ —´¢¿ï™Y.)Ú²´u Å"ggΜ¹î÷£šàß ÍÎù7ÎÞ^M¢ ¶åŠ^^ÒÉ„®SÈž_àDÞãxøùïOik²Œtšê¸2÷:ÛÑJºT•¦j­i£LI6¥´.ðÞîøúÛÑË« Í£+Nh4@jRh“ÓÑ:å;¾™EFÀûÙCËã4cþ4íX‚ÐKРɤÒä$º8*² Â`ŽÉÁÞtºX}a|_Ù ÇÕ¡ð=£Á™ƒ§!ÍÄqÇü¥1ç'bTëƒg±Úmôr˜.‹Aÿ Ž_ 9åñ÷$èίž…ÎG ʽA„8„ÚëB1„ÏÄ=4Ž0õóRZï: ‡ò ]¸ÿ *no¾ÿ]$‚ç(ÒZ©¶0ó˜ÔG‘k<~¦Ñ(¬j‡õI°³µä 8¾¼T5õ¬Í؈Ð%ü»v‚bwaw÷·ŸÉÐÌ/¤hºMü`#¨Öþ-ÚÆz!nt†}Hº7=Iïe²X4Ea<âˆ,‰«Z¼ÖñïÛIV“bŒ ýøJ±æöÕ™ÙÏý6h¡Ã½kû¤Àé¡aÒ.Q/ƒˆ>›ÜdªÄêWÚãC÷X\œÈœê"3<@¤xé½k©ºá3¯€ü°+²f‡äC=¬âd§eÀ³A†EàZTí9,þIŽLØCô âU“7÷ñôœK}:^ESúËé2Á®&ÛÔïamkºuÈ>tÉTyã°Ü¼;cáÔàÍèëd¦œCr0&W•5öRì5#â¡ÇÞ®9E°xm¬$Ûˆj†¨AÝ t§›liµq¶uûn¥F+ÏLEï:4p[³ºÉjuÓ+(Fp¥ viÄžþÊ|ûÃÇ¢Œ1ÖÑÔbþªÂ×N¡úQ“ÝÜ罜(J3µj¢œ«Ó‚›:lÙÛoØØ9 ¿…mã6Ö[$»T6 íW(*.³Å ×Bk,Û¦b¦@³Üz¼øå‰ng,AüèÞàRƒ£í~Hªª°ÿñU‚/@x“,’4«Ewˆ#›ÆY4 ;-Øñ×"~Ƀízçï,±*øR±-ÕFFÈR¾' XOmt[?ÃeMV—0÷ܨç¥ÝðÓ–e¦«ª4·u…­Ú·ØrËZáFê£|ßS­3ŸŠÁLg°g!2¬”«BѺ.î˜Î\ãú³ëÓò&pôÕàËnÞôáéä4:›Ñù|âëˆsd<aïm\·—.>„;«—¿ò³N*õ„Þ¢!2ÒUfoOЉáoªÍ…‘ÏŸMΣÙ…Ž"?ÏøÑ‡ë£?þmÆæ”endstream endobj 5634 0 obj<>/XObject<<>>>>>>endobj 5635 0 obj<>stream x•WÛnÛF}÷W 8’ š–%[q(hÝÄm€´Hy aE.%&$—áŲ¤ßÞ3³\*T­¢AÃæÎÎ}Μý|tA#ü» É”ÿ‡ÙÑíühäð±ûQ®èünD×þ„æ1G4}váO§Oi‰Ôˆæáð$3Q“jÒaQýÜ”¥ÎëtëQ¤KT1êy#A!–L}â® MV¤ šbëj½T¨»Hêçœ@xQÄՂͤ$³‘è“£v]{ù­Åñ%·Ç;“u]„’è²…*'Jzb¹¥Ô˜OI¾"UK°]<ì¼äA— îãÅÙxìO&@hø‚Š™@„ß ©‹[0çv,‹à´wàòzC£Ñäîåíøºwü‚²ÙJ×CÁp_Á ›#}¥U¸†™gMõíøõ¶ÐDÀÕb± qÐåÏzr;ý¹ïÉbÎJòH?°ð¿ÅoG=Ç +ëªâ´>ëkõk“:·2—/÷dxž÷d®F}s~œ³HOÏ•ÍåAÃÔÐ@ò2@áë2Y6èDL·t®vm#õ—)ƒ<†8¦bàï¶C+Ú˜òÐ'É’T•hñ<·Ø&#"k¤jçN%¹Ë–`X”ıÆÜ„ý"rí¿Y'!Ã)pnmÒ¨ê5ÓÙ&\ŽsÁP¢âšºï.¦v¦" ÔhB€J'Ñ5¥ÖŒ!ý¹IîUŠyv³)˜Åè§sà$Lg\†¾QšÔ56fš`ÄyÃp¤Ç]§¶a‚!Ëãìw>µÛQêK°bØ÷§—‚S:;#”ǰ—h™ÃV %1妦ŒkIë¦Ì)ORÄÕVï‚5»šel üÕ3¶kiäÿ2¹úN“ñlõÓ!§ìöážB¬‹e—ÉG#3H€KäI¯ÍêÛèGï G Á0Ng³c§ÿ¸è(k0k>y„Æ…]N8`·óØÃˆlÂIe¦ºFzÔ›þ8—üc2úéw®ÙñTA[pÀÄ÷U<žÅù¡ü;³Dè°i—*kϲ|j Ñ¡ûH‹ÉÖ*УL @.$’öè­ÿW³ƒõÚ BO{[ÞƒHúÎXö1(n:ö9`ÔaWÙpÁö°ÝâÔ²“nX…Y)ˆšo`Yp3o!†ñg'ãªàÓ{̲ó[`Mc ÙFwr÷¢ tÿ %;L‘ìý”dµ/Ú±‡­1 𝥵L æ³5TªHÕÖ±$dƒw½%4O„É`¡R þÜ€Ýy„í·ZH¯× "ð·°QÖªÔ aÌLÁZê 3Yi‚¼£ Á§ÀSÀ {Á Ú{²ªÄÓ¤moI«*I·à\eÙ–ñ¸ä0KìÖ hºUßgT¿›ZßЭÅçö4…úÜ€JÉNáP°„Zì×t÷úÍ«œÙÜ” ÛòæÈ²*]Û‹’ÑWñæT›dµHµpi°³àܹ"ÏצYre­*ŠŒ@Ïšù7*îUÀ@ÂÄíÉý”o::+SÌ'™e®ùAb(JªÂt/‘Ìv:çdŸß]·/¤ñèÒ¿š\Ñôz*¬¯”³‰?¢—&l2,PÑÊWðx´’gOíb_ûOý1ýÙ¾p$U¿9'ey^¦þdŒç,ˆæåõ%ky5?úãèGã¨endstream endobj 5636 0 obj<>/XObject<<>>>>>>endobj 5637 0 obj<>stream x}U]oã6|÷¯Ø§“ÄŠc'¾\û‘"@ÛCQEE­,6©’Ô¹þ÷7KÉnŠ86-iwgfg×ÿ,ni¿[Úî䥻Å÷ûź\ãâå-èæñŽn×´oðìîu¾ƒ^—8ôñN­ŠÔgbË5Mj)µÜ•Wû¿kZmî¸üÍ'þŽ>÷TòüÖ«:’ L•ŠF+kOT{Çdœ$ ¨:¦£:]Su"Uׯ¨œNÆ»HqÐ-¡pñò‚{}“$)(ù¯­Š±˜PÜnEÇI%UY.i z]"Óõ–;œ”ä&TT™DÁ‡\磱VPr'긫@üŒ†*>ç`¦$XL8.EgP’÷×À‡NÂLBMGþ½>YÄ›ÇO$ø¥«ÍNˆlÊå–~åÎÀQN2)ñ¶mP¿Ìúÿ2(áÙOÔ²í›Á^Z%tæiFyŠx4‡;¨—!r¨¡X¡Õƒtj¬YKo¤Yoý2lɧ;V.Ι·*‘cøJì¤}Íäà ù*Pó EjÕô)é³ÓŒÆô†ñé:ƒÊþsž7ŒvjŽâ“®ñ/xLJ‹I¹dO3$Ú[Ë:q ‹ S‹+Øâ|™Ž-»Œ§fîbN†â1ªp*éyù—H@6>Ò&‚(bEéì™ÑÙ+c‡0|Ó`­FgNÁ*ð}^>_Í[‰ “’ðBôT匼 ̅Б‡Þ¶$»W·¬_ó­K>/XObject<<>>>>/Annots 2720 0 R>>endobj 5639 0 obj<>stream xµXÛrÛÈ}×Wô>-·V‚ɼ9Œ´QU+kV9©ÒË’XfÍ¿Ïé\½«Ë.•mYÍÆôtŸ>}ÿ{ÒBš%ü7-®¦ÁŸðüúËÕ, ¦”Ì“`F-æAÜ9}¼ZD¬‹cÑ…ả•þà,å2 BJDèFÓæ`ÈVEbeörAa‹¡v C;›«¡v C›$|mgÙû;]¯ipm«õ×ôÚ Ã±ÄÓk2´‹Ôi‰ùÊC¸\áv/tHÌ—-„3Äê¥^ ¯û0Œƒ%ÍEòþö2ß9í@.(‚/á@ë=J<þ’Ô¹r)çØ‹|){=PrÆç±Gpµè>8ù ø#Ozo{ÚxÎÞvZIÌ^ù@“ "/ù£½Ì&Œ‘<+Ú íJ wZo8jàFABs‘ø¨W† ¼ÓC$R¯œ¶M‘:e¼lˆ4]À¬—X)àÆp‹ƒ™/à­X7QM+>'ŠÑ^,4Y tANãÑÁ¡ÌØÆ££eœ´0>^ê™·p”±H} qÃ’ïu!ÌÎ(z€_(Ùe#ÉÉ8éä‚f‹ õϲ6 °Õœ%e½Và‹Vè?€/™ÁŽ:"à&ºÐzuÝ º—´0{ ÛûO7{4ºmhÑf'-nJ›t­è㧇_H•;zovu®nf?m~˜’F(¦b φÐ*o"TÉ<©É‡m_2}æS¬ ù‚É{Se/ªÊL9¶Ö;.s7!>œÁ={ŠæSâ7³Y0] ûùO“…|*§åÇï½Z€¾7QÌϯM™êS{yïÔCYi»W©vTZSžm­²™vßæãŸyãcjÀøâÞŸþÞ›t|´OÑ×¢$€Î£ÕyVdeyÐÚ§,×ö­y·Ûeœ•®,@¾<+5}œ}ãåß…IK}ª.']¨“øÐãòPžêÊI‘˜ºâßߘ1k0³7à­v÷Y§\-êJkF üÚr^J³{o¬¦cV‚ŸhjÕQÓA—LcÙ›žÄ÷ZUµ}óf÷hÕ¡P߈÷wñ¯¨\ûü7ó¨hÆMƒõí};Ün¢%6„flŽ™£ô¨N˜´Ó.µÙÃ'æŽ\}bÓÞØW¦ÆàT©“€þcjrGSç;ÚjÚ«"Ë3eéœUGÉå˜PíÔ›l•ËÒW"Ù‹‹×¤ÝI§™ÊóËkû]?Ïzù~Y"b¬F²D0@B¼h‡Ó¿qÊË%›”ŠR?av”£½Õê )+%ÐÊ*?ØûfϹª}ÊluÒÞE×t>fé‘Mñ±Ú–0éêÝ! àÿ£r©Ê­Íb“®Î‘6oœÛÚZ]VÀ[Ì…VióÇìpħúóIÛ¬À#*ÿÞ«òBû¦ŒH¡î\•å9•¦bvd‡RïÈ¡U»ý%+8ÏkÕCãŒßeJg ®Ù]æÒÚ9ŒAR[ŒÁìv~Îèrçú›)¬ûBüXý5`,qÙ6×ÌQžâSž=óó ®ûš‹þú»9kÄx=r†»EK×6è¬`)·Zí.T;½¯sá8zŒ¬O­m5Ýõ±;~{ùûø-åñ¹©ÆOµ4Ãèë1 ^á)hv©ûûͧÿc%òV„¶Ø÷pÝå‡I ÚŽ×Ó/‰+ô~—W¨ËÈV1ßN©b¨A²³Íªp©Ùá㣪dA3(€ž£³3ðÿúv…¯0®›2èu°I˜>l²Ò%g­MÈ(S[ðº5æ°w-ÌBBË-è 2j»ÚrT¨ ¬yÉàᚎÈ(Ô{¬xn\"÷ècu©*&N{?¥ªÄ?D±¦}]¦¼°aaO.èZGõòG`´$ñ;6Ü)¼¯€­PÏŒ@á™HU ˆŽâdËg®)•;CR,g«Nã!NM Wè–ÕY#|.Ô›H€£me¢ƒtAXU`ö-NšuŠ…—Ì1¸:}¾QÖÔ°ÈPµ¸y§*%W:Ô Xø4Áá¹×ƒíZ qX°GcYpÀŒ9 ;ŒŠô¹í‚mîF8žQzRŽçÌiIWnð‹«àtŠ)±×•'‡‹¾ Ëô2Fö–ž Â) ÙÆusAuΡCycúY:ì“/Úák&í­)º¢ðE,;†ØFMb "&²lÄ–ÿ(*é{wƒ³Õ î(}mâ}v}B°4ò&bAkR¿Ü‘ª£5硚q;Ù ó H­Çp¶]€‹¢< MÓVФyæÔb¨ØO˜áþ Í™í*˯W­JsÔO¦«f_¹·÷í·@³E€ï&y§yí[“ùßzE~–ÅË„¸Û\ýëê×™þendstream endobj 5640 0 obj<>/XObject<<>>>>>>endobj 5641 0 obj<>stream x•YÛrÛF}×WÌË–iG„‚à%µµU2-gUk'ŽÃ­ìƒ^FÀDL 0̪ýø=Ý3¸zàh+©D ogºOwC^ùb†|,éß(½šy3X®< óßDã8i%œÑÇæ­gm6ÇIWf nÔ>çÀ›¢iïßêrœ´îhرùqm6‡®Ì@ݨ |€4߸£qœ´îhرyë™C›ÆqÒ•¨c¸Vh“Ðôç…û¼`\’ì} .žØ”€£Ì…úªUV&OêtU©bñxú¨D©¿,âˆöìõ°ûå·¾ Õ ž%¼É÷Â\5n•ôGyQ¨òœg1ùÇGÆÀE0â2ðÊç^Ë´L2ü?V“šœDGUªžý½’º‚FO¼U‘ÄKd‘ =VÉIO¡¢ÆAdˆ?ËE¦q(’`g¾¨"S'º‹ƒÊ'Ås!ÏgU”â¹H4Pèbë‰ÛÓ©ç \~Â[¸tNaYªTeZDG}¡`#™‰G…¬Ì(­Zœ(áÉ>Ý%¥½ 7ÿ¬d¤Úï“(6ÈI|”OÀ$‡"z ?_}TΉ¢ŒM¶´HrœçJ“ìA,6¡C[­þÊ÷ë’5ô€³µNÌKg'ó:Áô³vê/±.6(´Ð›­–”÷Ÿ yH¥0/bÿìÅäïoÄÝvwŸ¾ýÐõÍ?úi _¯çÂî§aÆTŠXE'‰ë"ø¶Ÿ>ÿ²½{÷ïÏw&}€T’žOŠ®w—qTE&O¶ê.x\j%cÖ@†§ G48r–*FlZ{ó’ð¶·>¼½ÝþëEáY¤^]yÌ«jõ5ÕüMp”¿ñ Á^ ǧ†×²Õ—³*ÝW€‹‹'`:ªÓ²Í3–0˜§RGGQæ)ª¬ŽøtàD›n'>:߾ć"¯t’1M€0L=j€¢Ÿª¶¾ÁWå0ÊR¯¯ÂŽšVôíûÑQâK¢Ž T=÷‘õA]?÷H6 0ŠŠÓ“Kj¾vJ0YÖ”SŠ=®@bî““*4¦êò¤’ »ÅiaËdÊ,@ŸqB¼`j¤ÿ˜çË…ç/W¶tîcB²OTA«A1L ™Ðp¤¾Ú¡³dhoÞ×Ö¦^€4m8 RùE½Á~áuOÚ"°•çódà&çüébG1åE @Íkv—bʃ£@£®MÜØ>ù  x@9<¦ èf®!zn_M«“N°y™ýžM+\!ëãÍ•Àío Úm˜2(Nö{ð&¹þQi’ã8µÑ4EPïÃkv%åÞä‰vÔ-AÚ§<;Іh°56ŠÍËhÓüièæ=þª†2Ü‹ù ”`à\ƒÙBŸ*“|˜Ò_@Þ坸>/XObject<<>>>>/Annots 2726 0 R>>endobj 5643 0 obj<>stream x¥XkoÛÈýî_q¿,¢`MV|èµ$Î&ëvÓl7\F#r$͆ä¨Ò²Šþøž{‡ɱÛm‹¶ÉyÝǹçžáß/"šâ_DÉœÿgåÅ4œâ ÿˆøÇÏ.âYÎ)FaJ%Å‹¿ýSAŸ/âU.‡Ñ$ž†ÑÉh’.Â%Ë•¬M§ã¯=}.)Sìäçòh2§”,²4J–Ó .R~N½Qi2>ñèè„üUoÙ#ŠfÓ0¡å4\àqIµ¦ Ϥ(NÂX^Å‹þ=f==0¾?ßÈ/Ò4Á6ÃÏn5ùOr²äÑfÏÏï{NÝ’¢)‡Cü“žðž?:âÙ%ÞÞ§6{{sñ»÷)Î¥› à4_á¦L ›lb¶•­uNw“—7¿b&œ–™“oüˆÛ¯ŸÜ½$UåÔì4íkSef¯ jŽ{MeëZk¸V©òÉ yZ©ö_íú7+$ÛÛÄsØ8‰WaŒä_W®7*ÓŽKWß~K…Yת6Úo5¥0Myé×k6¦À /ÛlG%œ¦Ì–ûÂdª¹WxËsœ-1‘çäÚ!ø•glvª‘9•m¨T¹¾¤£nBúhó¶PAB;%vÁö'ŸT–\»ßÛº¡­ÅM[eì¶nyæÀÂÚ‘Ûٶȇ%[]éZ5¦Ú>Zy0ÍŽ]‘éã#q” ð±?èZ¿€Ç䲆7vC;{ÌõÇS¦ŠB¢:¨Õ~Ïfp€ SëŒÃÑïâ~¤~½ûŽ€ŠšÍ–ˆý,œ%K>úñn<+ŠÃÅjÖÇDfhŸ¾q¡IΠdgóaQ X³>ŽáÞ+Î}¾½þÀËãä8OLùd„Ë‘ƒ̵JX»§ Ù?ý@8œsÏ/¢Ù*œÏúmþ&¯Â$&ùUñtΗØ.šõÛ Îy‘àÉ kž+°x2?«Ã×Q‘þ×Qˆf ,šwQ‚ßóù \Š¢>2#pººâ)AŠe½‰%Cúq–~aˆ„ÙÃO™%ˆÒpá9˳§WËvA´LÂtá €Çƒæ–‘×Ã|¨pàÐ8.Ü<7\1`›}m×….=øÐQôRòŽLCNWÎ`˜]bC}qÊñ&R2C~2ÿöµ÷#bjfú è’ø+ŸÜÅó{Éc]þ~àb²´1Jå°ýçHÍ+’ÃhožCŒC5m]y@£”AmµmQëúÿ4*׈“x[¶Ecöˆ‡©vº6ª2M‡”£Jo _àLMƒåü°µ6‡ÊôþWs®%'{놜¸vøX°·] 'Ææú5Ýì ã\ Û%ÿµF¥ö=+ÙÚ]‚Þ6Z!ˆH8ó2|â„ Ü«@f¦ÔU¦;2Š<— ¿ÿ¨ªm«¶LôŒs~û¢%áÜ¥Ez¡2ùƒºW²õ0$“xHzÇù˜è3ûéØìlu>8,ìß9ô<;<‡=õ{¥ªØ|רšK¹ֶª^ó‹Ìœ]$üØ'÷5}>éFϸ{ª*}°ë_±{1¼¸í_õ  qÿ¦ëõw¬ÞÔZß½|:§ûW½hÈ '£_¡©å]g½Ef¹“­Q@¤³m-b oÄ> ‚Œ§½G“•ÓûÒu; µÊžy Uö…k™W÷Áô›²<9i%:?ÏtEU_Z,«g‹{lo*èŒáqhènsd¶Ø(·¯Šq£jþuM_*{x`»ÃK©4ßL,b²~ÈôÞ‹ p@ã»Ó©…ÂY˜>¨&‚ß‘a«ÿ˜dŸR›sÜ?G¹A¼Ä5¥#ù·@¹bÆüΛÌÔsORƒðjÛ@Æù–3vaør‰”Ðõ‹Òg‡YÃpn…h@ÎMÁ羜š }*ê’U4%]5¡Ÿj]˜ÒT'šôL̆KÉ ÏEÿ¸ê¥žB/­E¸ùM%¢Àr³Ù 3a_¾"Z½RTh"‘•É%íù‡þÿücâ¯6m Ø/»¤+U®k“ƒúwa¡ÆébC¹õzz¨aFpfÁœÀo/OÉí!„7&Û\«W.R´oºÃv‰0úøˆõÞ#¬v¢dõƒâ*g¬·•…Æ^ÐGÔ#»Óÿ,ˆŒ|‰`LoF1€`¢Ró=“>y˜ÿ†° ýŸöv÷õØÈvõ"-e_ë{N€˜MmË®âÅ‘tñý"ÄeÅ5ZåýuC—¦—Ieô$slà¯Áµéh[4e]ºˆXA{¼¹wlÖé”*—ëâkÕÝçˆçÇq˜ÌUÖ9&3Œ¤$„òN»¬6â´?£Ç$Tò,Œq bt4/—ƒ^ÚîœW_±×¢4«p5‡¢¥ûÎ8Å’¬[ÈlJ¼³#ð"ŸpñCȱàœ1 1Ym©jK4õŒîUÑCØKLQUsÞü{F÷³y­ãW~NEu‡t×Àb¿'®~Ðx">¡ aSƒ<¦ (Q4"ãJ•Õ¶B5ÔT<vÃqù_ÒËÈ÷NéÀB–x@på¶‚T¹™pÔà_=^¸Yëø{bYHoÐÒ|§*q¯«øÀÁMSÝ[H›ÎÛüˆ:׎9¬Ô2»ÒÅ6¤·¨pp¤EU8ÀÒ&¹µ`jÉ9Ê£½E(ú(BªiÉ:ߢá”Ó |ÀŸ;fO Ê“ŸÌÆ•šFÇæÖX¡Icqà>/XObject<<>>>>>>endobj 5645 0 obj<>stream x¥YûoÜÆþ]Åâ2¢£ï}'·©áêaH£V=§(  X‘{w[ñÕ%éóõ¯ï7³Ë§H%QàÀ‘¸œ×73ßÌÒÿ=›Š þLÅ|EÿùÑÙÄ›àIõ—ÙÓ/bµØx—øi#–So*Œ»³ÍÐAý¯¬YêuålþË6‹9Ì“ ¬lÈ=_®ËW×Ëò}ö¶ï ô¶czP•£ÏHC¤£lÈCM™Ù¬¥n(P~>_¹~«3o}î9¨úãè;Aªrîöiˆt”½â°:‡X¡¦Lb,Ò”˜\ ÖsP ´ iOzT9w{N"ýˆq$‡Õ9Äz 5e:ꆥç›Ù ra—{žW¯÷ÁÅu"Rd]í±P t4½Ü 2 U•†DP,ÐŽ_.ŸuZ±çyõz[Ë`p|УÇúÙsP ôÂÄt"ÔeQê1ÒèèˆÏ6Ž’;(õ<¯^ïA‰ÝéÄÆA÷è±~öÔMÑ ê²(õiHtPúËöìýíBL'b»›©·œ¬Äj³ñ«™Ø˜[¬X[ÿ|{(2q't”†*Rq®‘T¦DvÔ¹y"Ô·ÜH?2 …ŸÄY.ã\j§ckü.dˆ£Ñ¹R\‰Ô${##¨‘¹HŠ<-rRùnûŸ³ñDŒ§dÿü« •‰dGG‘'îrqLÌs&v‰q)£ýÊދÛɒ9,Â'+d&H÷û[Ì~Žöcä‰íAÅ"ËŽ÷YË,©–a–ˆ'E6}•e*ð.,—« 0ÃÌ^¯·qé¤Q±Œ: þi§Cõg’t‚ëkIà!œ(b'×5rmvæ\þdš¤V2(_G%û½Êlª)=d öjWšp·b¼¡~2ÒhX+P\RÀ{ @NðŒKEg"VèqH¢„¼MP›1,f:Ò¡4TŒ¶ªvâ¯IP„r<÷Pq%ʤT1¸u¡%»¸£ls©3Fá~C.ã$'(›Ö7[`Y)Ö™(Mb´D&2•JªŒ€²\ÄpòCõkZaú2Õ¹ õÿ$¡%üƒŒrŸÍ¼²Ó€žÃ‘¨JÔuˆ/ûÏJœ’Bd‡¤œSpìnnË4‡.гhY„ô«r$mPÑú«¢òþ®çmñ¢.àE†Þ¡@ÕÛ™µÃIl–GË¡²P3I)ȃ* tjÿ œZ,’)鬳ù¢Â¹)~oç ¾!½–}¸ždr>dììû[ÜÞ‚uìuŒKãå|C9»ÄQ•¾RÒæ‚`½.¹cÜ6Õû¸¨ÜÅàGÛ‚v+RR7‰°ÑàüF" ̯¾ ˆÉ >)žÀ1ÛÑ]UÔÌöÞN% ÑeY@Bš=¨~á úðf‘\ìh…ºËµ [©­Ä,%£Ü*Ìë ;NÀ8·™2‰ëò+ŠF+eX!lû„`²G³úL¡w‘eQŸ Ž€'ÔhЬŠà¢|숷tµ[”L¢›0 ba½Ÿà¿aâqi§ŸD–*_ïNÜN®ôÑÓ%UU®øÊ0µCD˜L¡6Hÿd Ÿœ[ËRÑ‚Ž[h&|BÔþgžÆvšÚj€DÎSwGL~s/;‚ÀlŸ”äB)çwJRó“ÀцŽx‘É}5º®-wÀ‹â9Nޱ'¾dLÑŽüJK¶Kcšd™¦Ñœ†É”bˆ¥FÓ m. ä; QZá%O~$„$_â+2µÀµÊ|£SZëÛ 4žoÞj6‡òiyI‹æÔÖ -4C» é£À_IåwÓâî§íÍç›ñáñÝôß4@þØVO·úÍt)ìžËfï´”ÓU¥ê7\žÝ>/XObject<<>>>>>>endobj 5647 0 obj<>stream xYmoãÆþî_1¸¶¨±hIÔ›S´@bˉ‹‹µU +j%1G‘¼%iþ}Ÿ™%%’ZIçÏì¼?óÂË׫! ðÏü)ÿû«7åô‡Ùò/4ÈŸ¾7ïs2š6ü’¦ó±w+¤á¤¢ÏF ¹gYCÑèvYkb4š@íɆe¹”MF~‡ýºLK]—BŸÞ ¶ÜÅÁ8 ¸B±þ¶l—n9”•¡88u™–º.„>w„â`œœ¡ˆW-Û¥[ee(N]¦¥®Ë¡f%æð%ð,ÀŒ³@3+ NFSozÆW§ªÒ]‡‘šHKÙ;!v«+3æ0T—qeLDšJЪ6B™½‰`Âç ÃM|v1ÎÍŒ½cÛ²\Êl(.N]ÆŠiz žùã2”Vñ'ÆY ©èÛ%Ë¡¬ ÅÁ©Ë¸B‘¦âÙðÖ»æñÄÁ8 t)rÐcÏwp0Āл]ÒÇó[oä2àb°KïRä ÏÆ 1 ô.EúäÖÃ…€¦híıƒ!„Þ¥ÈAËuß6à`ˆ¡w)rÐGs÷2v0Āл9èC¿Ã€ƒ!„Þ¥è’îOGÈ?×`2lL'ƒ XzS‘Œ³±Xn`á¸TÙ¶uqj"-eV¦²ã¸ä\êìäpqê.´&ÇË«›‡1 ´ÜÆ·?ÇÉ9÷ÆÓ-×ÈÖWì2èíýƒQiÇj¯?.½b3¼sÝ{Òb%ÊwšÂ8-rRf[ìuœ{ü¾_ ôÏÁlÊb•Îü˜^êü%Y‘êûÄÜ?¨x­7ªˆò ï-ÞTTtènú<¶}’øßÜ<àè—Üq1Ǹ8²?éû¿Ó/~žÜy/;eôz™'/¯ ÿóôúñoV¶Ê;×d>œ¤å%W¹æÄÑ&1Ć´ÉÃx+©=¥ÅæØF'âî€úC®ZïRû4 tÈ‹V áìtðŸôø@Ký-÷>éx›ïjqÐ?$úŸO,|ràù‡Ç—-^{²ÜPž$%ñöâ¦ÅÓý{Áß±#%ˆr½5a~lß/˜:¤’"oãÔ&æ©Òf´½çÅÝçç{K¬ÊÒ£M¨£5 •¦"Ók)‰ÑyabT„_÷OAïµ0´MyæÑrf¤RBg¬Ãè6¨k¨"‚‹è‘FÒª~ÁÛÊ)Û©(b»l –ÃXTðo•±j¬vUa¢ÝYRÌe­¡Jü°=øj[Y®Õš3¯>^†ð[ÛÞT=Ãk æV”Œ¶øð̨CåÊ%³*w‡l•‡eh~S¦[ó;NC´át†£5ŠÊºÝcˆ<³Cýr ™açˆιÃYåÊ’Â ..àà"LŽ41Ê„ÑÑ6Œ¹›ªød<ð$Oµñè%Œˆ0LQïK À=Ö˜8Œ¼ìKˆ‡ëë†ôË¢Clòñ#¨fïáñé‡OŸþk©ç†Z;V[bù,¯OýäyÔ¡I*4‚–¹vópKÜÞêûø–ñ]¼Ç§N_\v/ÛÝêìš1–’Qy˜ÄøíEçYÓE˜q/C¸&¥R*^SI`_Ó^»0Æ1!zÍÃ`+K²W_4Ù‘MÈéi6„Ä ô·ÌÂ7-Óš—Òšï.ÊÅú(;¢BûŒ·W1f"Šj(BP…B\’ü½|ox.žW†Í+GÆNn€ý vIÈ ‚j̽Õƪ»yÖìnëÏøzeͯ£é¬,\UTæ•‹§žÜ¦inГ©²l¿[=WKÔb½í“¸‚8¯ÉM¤¶ôÚKR.ìëG)Ïï2Ó—sµÌß¿³rßîQ¦\Ç\%XãrfU=ƒdQ/EU-%5˜™jYX 8ew”)š¾7a„½xM+4jy”¸âgšQ2†«Ø–Æ¢ˆ—J! + V§â ,ÐËñ6ûžIy£uËJ_Ë+kÍpK×R‡ecpNâ0˜HÜÜérUè\ˆ#”ìf+Ǩ.* „;Ô¢5þ$ïdÎÞu{ ˆ; ¯áh³E/…8¯­7Àµd¯è”Úö>¹Ë<ÉòŒñ¹/²œ‡ÞÍ1Vù„B°¨û:ÜØÍͳît]Døø´\ü´xn9Òœž5\„þ²X¶d_? †OPz¤4RG8§LR`†È¼È¸8)¬luŽöþ²ÑŠgdK%‚í·©QÛ½¬úZmÊ!–ဌR®²/T¤öáÅX;Lïh…W©Êsmâ å¯ð ÃO“ÀâòðAsÊæ»Ò EH°çê³å¥…y0¢]ŒþZ`œé56Ö"³‚Ä`Â¥I¼æFÖß×’«fÕ…ee7{ùÞðo¸@7¥€âD;ÛKpúZ„@ÿcíg¸_3ÌÔls„˜OÄú ÞÐAuL TLA✱”0.å”;àºmzãêEž÷Ïlv#)¶¼  ? Û~&˜‡ÄðÑ ƒ]SbëÀ‚*òdo‰rV[’Ñ$‡ ,GŸ>¯~ÕÁ;kð^‘*7&/‰»ï¾#P² ƒÉ.@>Ø` UŸüçâ® ér=vH¬\H6§Èã Rå5¡¬¤Œv! m‚Ý‘>¤Å* êSj’C¤ß(ejÂ7Dûw=UøjB[´G$û¾–@Œ°3&.0 ÑÕ@€\s¥1ÞyubânŠèšŽÚ~ÚÞ>/XObject<<>>>>>>endobj 5649 0 obj<>stream xXýOÛHý¿b„„äV‡ÉPšŠ“hm$¾.qï®R¤Óbo_oº^“F¨ÿû½Ùµ`àPŒíÝ™7oÞìò}§I ü4©}Ì¿álçc°ÓðxX}é \¼§f‹‚1ÆŸœPÙ÷ B¯õÞ?ô©?›+m²7Á¿;‡ÔÄ;½ßâ—AäÝÆ2”©1]©(OÄ~›BIškuG2¢»%™å\ÎÄ<£™XâmjDœ^¦&ÇRg4ÖjFc¥eçB‘_ØmYú÷ óÙ,«تHDr‚Ç%Hx&E8¥9×Ê“RÑí"2›Ë0I²d¤ÆyB ÎîBdžù8‘©Ô")EÑ(ý®hûÙvUGI|§…^út\ IUÿ° ß²5žL ÝIü#5œ—H¹pdGFQ¬eh’eÇq¢A'~›E¡ÅªÐòÛmÜEÞ^œfR›êT‹Eœš1ø¼÷PzŒ޼þÕíÍ p‰úðèMIõRžöíâGþññ;žhµéˆz?B9çúÜ.OW¥(z”‘@6§ˆp®²,¾‹Å’S"RR¹™ç &n¨¬üÉÊÈãÌŸ¥Ë- EòÁòá_ýOä@f¹cF•”ö´ˆÁ~üQ™à‚oIN I¦XŸÀlcÇj]Ë»•[« ‚º•ã0ÍT\©òÊH´#0¤^€ƒ³þ°÷DÓ d ¥e;\«$A¬‹û¤²ZTò¢j3ÕjQˇ˜L¹V]ç½×ªO¥Eï)tÞ¦‰[’K×ORVåfØcäýž‹®ì„žMT6UyQ!÷õ©ÛÍ/©o›V¥ù•Ų*›–ˆë½{¿u\•Å1ÊBÌæIÑuÊI\œEËæ”;5±½ |çN:çFŒ¾\U +dFàÝ’Æq*m“DÚYáŒøâF÷­|bÁKD:Éù~,…É5·ðÏR[ÊX’[¯P^Â¥+`Sá릉d¦Ð'${¹‚¢4 ¿õDYN…µ6K•Ÿ‘÷–ö´LÄLˆÊöÍ„p» 4‚Õ +èj\$Ç"O ½u ;¸¨”ùeèvpÓíôèšWâÏÈôÎÎo®/¿~dFuøôþøÚ9åo¢Ý]w¥ÒNÖšbˆ½pXÎ(X8•á·Ž£Öó®bnÇz9ÇåÊžz?é´LQQ÷æzF)JT:AïyŠ#Y‚¸1Í«™°¹ã ÅÇQaðãWp #,|W2Ë–ú¦±`2¿aI\[Û\t%á¯ÈYf««æË¡Q]¦a“µ=Wˆ€7W¯ñµ0¸âã©õo%9Û­°.¿Ò (Q7tŠóvàØLž·ò+ŒˆÓ{œy"*#{‘µŠ¿àš¼´…tpqRœÏ›'‡þQûÿVhâj¼#Þoû :W80áô/xÿÁñ`{ïFï¿sôé?ŽÇ~»ÅHDÞáû&Ïê;ìüÀ­º¢endstream endobj 5650 0 obj<>/XObject<<>>>>/Annots 2728 0 R>>endobj 5651 0 obj<>stream x•XÛnÛF}÷W ‘“¯’ä¡uì @¶¶Š¾(ÖäÒf-’ ¹´ã~}ÏÎ’ÉPFšA¼;sfæÌm¥¯'-ð×!/Ô?Qv²°8éþ)ïõ/.\Û£`e/ñëŠJI‰–ÄÉÒvùÈ ÚsHM_†@¬`,¸Ž˜ÎÄQ(wé1ÒSÆNàôí¼çzG õuÜ!ܱ@ùÜqÆ–#Æ&. ŒîGAšð' w'nz*#°WB|Î06a¨¯ó=cMÕ9ºôn>øáòCÏ)#í¡þÌo;º5µÇ&†ÄhÂ|oi£¬¡=bxêâ 0:N ßLA™ð¦nz*Ó s$#J^c†§ õuFp¨³@{ßu±·À²fìÐÅZÐÔ…2çC VðÙ‚†êºø(”»ð©)#=•˜Ñ1vO\ Ҡǃ< Õ¸;a¤§2ÉX“²IÆ&àÆ&nú.L1Æ*Ã@™ß9ÂØÄÅAat ™S)²HB«ìw"eάÎðRK›6iõcˆQ‘+ T$v;BÖ™ÔÅñœªšµši:øÜ¿Ó<ÚÕqšßsXMlŠ„Ï.Anç)Ÿ•œýƒ·p²ÈåöÔ¦Ï eº492œu®dØ™3pË!§­ÃÎǬ®Ô˜·ñ¤±å˜“^VÇ*M @¼O9;£»ZQŠî€CòÛ~—F©Ú½ ›_kYq‚Ë"c‹u¥Vо”O –²´RâQV¶6h¹(ñ5ºçPáHH¥r¤¡L#ãS[žÃïËm玻=%õ,wOí8^æÏ{uÞ‡›Íw\å“àÃ"çªky‹P¢w’~Ì£F¢¾®¹™,ïmEw"z´d£Z˜ˆ.}·}þÄÄuÅ }£Ò$•eSÛ¨Š\F²ªDùB)×Å&•D£[¤ÎÙ³¨(–IšÃ›»ôN^ä–*Ó§Tìè‚B ¶ ÉiéœD› ô'JÉj©d&µ3zIð¦ ~8cÀŸ_µYqÖ¾í6ƒ±èfßAƒÿ9Zôx£ÑL¨¤Ö£XG–‰ͳ±¾Kÿ5t<'S&˜˜ÊŠª:z ÁÕÛEˆ-…&6ÕÈ˃§?êÒ³=Öñê ÌXç-àÒï¥¸Ï ÈùUÛ|øÄ¡Þ0Rš…õÚõ÷+Àû±±•ãšPç•Hxèõl¦?>VèéÏ+âÍž=ÜΛÑ=šÖFýÃL•µœV‚bÏ­œf‹\‹ò‘3]ŠgÔ˜’e""‰9…€ÚBEéøNÌÿürûóÕ¥9lr=§¨äiPµ™È_¸RÚÅÃUÛLýgR»Èwé]‰zZý¡7úf™—$êùõèo÷2Ò‡‡æf£J9”zIÒo—=¦[{‰)‡£ËSÆ(\EÕCQïÐq£¹cb(JÚ)ɸÍâÂ#1“2zÝøvˆ’°$¿+Ñnd†Ä5¯”6 øÅrñý?P6ð½E´¥Ò+‹çN\È*‹U©‚hÚ–¦<$Æ;Ï„Òã=*b¬Yl­—¢FNMÓ!pÌ:€·zFîLaÒºö˼ý~T0¼,ŠJíËB84ÞR’¢ð&М¦ö-ý‘Ú¼[¶.žz®½uðA;ôòø0„>ÄëFGjé¯N>¯{Ѿ½ðbôÑîYKÍ/?L½§[°m<ÉøÖ_»ÚØåæä“ÿÍ™¹Dendstream endobj 5652 0 obj<>/XObject<<>>>>/Annots 2732 0 R>>endobj 5653 0 obj<>stream x­VkOãFýž_qlkPâøœPÊÊ&«J]J—´U%KÑÄ'^ìwlCØUûÛ{ØD»TU$8¾ïsæ\ÿÙsÁÁü€~£¼çØ~Co.½}x×óÛà<°}ÈaìØ£æ"ƒû^ë2‡‹qç^ë2ןؓ–£ :é }ú‚‚¶.ÑÑqìqë¦qô=ãxa_@ /´ãþ’2º”qwó‡y«7Ý ZÁpvîcÍC0ñì±óXÀydùÜÿþã;`"†÷Ÿî£5Ïùð‹xu:ÿØŠ¨§¥#ްfЇóxçöè<ÀˆÖâ¬JÅ ~>/XObject<<>>>>/Annots 2737 0 R>>endobj 5655 0 obj<>stream x¥WmoÛ6þž_qsÄi#ùEŠ“vX‡.M‚úbÝ0o-Ñ6ItEÉŽ;ì¿ï9RR,7ýT$,ñÈ»{îî¹ã—ƒõñ7 `ÄÿQzÐ÷ûøÂ?Þ_ÿŒý3žüÑèŒ&±5¨O“¨KôßñäóAŸ¼Þã®}ë]…Ðû‘¤¹Jä ÞÞÖã ‡~@kÜí=¥+"y/ÒU"}EO{-…‡©ŽËDÖÕÔb÷á¿-Ñ'*‹’2–Ô©O[vZ‡µ/n; %ØYL»ü+›ÿÌÒßun²”d¤1Jg4“‰ÞPiT¶ ßÅL¯¿†”!HˆŒÞŒéJE´T™<¡YYXÑ•†6C…Æ!X…¹"ÇÇBf2‰OoÜæJÔ¬Ð:Á™µ#CvœUÚï›¥Š–åRÒ°t.r%Í ¹>9©ŒÉ·X=¡\`oC`Ÿo4[ªí—2S÷¼QçM^ø¨²XoŒïPÙÍ”’Ù¨yéW-e*É‹e”@q;n¾ªp‘£E‘‡ÿ4’§ëðú¿"zBs#‚¡7SéÙg!bÈšv}€»È’íôxOO o„‚FÍ8ÕbaÙÑþ!¹“uˆ’&QaºÝ?ÕÀºÍRGû‘Ó͹ÈmIÖj¢®/ëõO›\¬üèQ!õáO[r‡”~…^´°ÏFgu&,Žtºbø8XÑŠó7Ò±Ü;çöõÕí«ëñ/ïÖ'/©¼èTç'qÛÚ†N™†2ß÷EÃæìxîihÂçI:švWHKï¥)r6hÚ•*‰=þHÊæ¸CLj-;0[SÈÔs ¿õL9cáé1ÿµT5û{nwOç#U©Í}/H÷‚Ò»Xåä­j¨âÇ·Á½”+ž”÷…Ì,+Tæpm äÑÙ¶J@„-ƒ¥õcøÕ~>®°WÅà“1®”÷Ϭʯõù£Lp*SýþuìÊsúC?¤¿‚ôïºÐ«m®ËFÓc4~J·¿½Pµã&‹,4=à%¤sù¥T`—†jéìÕ‹1½ÒéÞÂ`Øo™ù’þyÝúpH2Zj:º)h£ó;ó“ éw‰yÌ>V´ªç®ÿHSØÎƒ&ë CæÌÉLQq3BK) 9£vQÅKÁ!Õ8ÁõŽ®%(½*˜õ7K êçܬy‡“؃ÞÕà¼îŒghÆ–ë¦CôT·Z·M^ó–Êoæ´Õ%mZTWä‰ü©è´¢Ñi—k‰%W¹ž‰Y²¥XOOPYGp+]é¼°G€“¬Xˇ6%;ojÄ­Ðli­ÐÙ“*ƒÅé²°ZÐ@R y,„ŵ´¹P %h?ùô¸êm œ›ßÁÅæƒAwá䚢Ø]àŸ9þh ­Œùʧ?uy“42‰%ìñçÒ¸Nk™gžˆ…í¶¹œsãÓ¶f«JmapÑ /N» w„F)ôçÜ!²Á+÷÷Š%«˜›tvBÂdÑïÑH­`Z&…ÂhCÏž%ñœøÖ"xü˜]ئo½e¡3ê|ë4ZÞü!…wñÁÍsi–ÉÖsãI!ãlŽŽ*`Ùñ³Å‚ DaÌáéƒ×\{üÚP˜O¯æÈ¸ b5Øï/ß}¸yiËä¦ÚéM@ "®÷ 7[·‚I\ á[Ë™%¨šQã3Y0B+ Ô:OEUƒ$ד™)Š "ã˜ç%²38—)†®•j„4×Òt†d´©©ŠGú¦bqËÑ3켎;‡öù5î}\.LPQ™Ê¬°•ÀN=06ßBÿüœ7%2ÀX·Û·\IºôêíM{­¾®t­ƒvTŽ¥‰råhœÿ‰­CdʤVVÄ–ª›“T¨¬m.ƒÙVj¯cl—s{©±§î‹U‡Q«œ. dÏ[¯«Rç“×µY9/kV,gåÂÖëÁZàtYO›–Ö™® ¦9™Eºä{U°ºË û¡œÒhx꺸‚yß§×ûÑ@cwÂÞ™»Ë!zC£w@q5^°Ÿ§ý‘¡Üö®ðyÈŸ.'ïþ¨|ûendstream endobj 5656 0 obj<>/XObject<<>>>>/Annots 2773 0 R>>endobj 5657 0 obj<>stream xÅYÛŽÛF}Ÿ¯è·ÈIER—Ç݉m°aofcE¶$Ƽhyþ>§ªHvqì¬Ç—xgfŽëÒUÕÕÕÔ¯<³ÀžñWô/ίó>¡ýøõÅ•¿š/Ì*\Í}“›Í¿dææj½$.˜ó«yÐ!"5ÎçóP±"ê/EÔ æ³bÄ¢ Ct¹%QÇ* 6\Ì·ŠÅË…ø»ž¯ÌŠéÝ8AդƤ–×6°¢v±aµÛL2 µ ’ÚÕ|­HÁÛùR±¬6ÜJt½%ÙÄaP¢+Š«0ØõfÌ*œ›år,«1Ø`lWc°«%ÂïìrA„Izè!ÀÈcs³õTÇ)wýŠÅ‘ÓR×°c%JøÉ5HI  9Áå†RcRë‘ÑÅ÷JJe»%opì‘]$Üó=ÒˈY…¡7ÜŽY…Á®H¹’U,ì§A³ø„ÓRÁA’òiÙí7þ‘àÁ'ÇŠO½,|Àj«02¾XS- ¬Æ`±“‘€õ$R^·•Ñ Ëˆ½R^!u¬Âdw3b5&»!Õ¡“» I_—!F*C=ø´^Ç*,±¬9Øt¹Ç³+#HVä0d7 x¥X…Án)ŠU˜ÖKÑp¬Æ´Þ5*C± ƒ]¨9Å* vb½ŠUìÖG])VáÜøÕ«c5»Ër½ëáx€O (R8-zˆP ™a9)eÀmªtoÉ3â + 6ôñ”<ˬÂ`yC)Va°èÎHÓ¬0Ù³’z4ÿÞ+¬€QïUÉ«ÅÜÓ¬Â`Q>£“ÍAW®x b$+r²+öÙ± Ãg” ¼p¬hFëcŸ}j\#Ö¬04¯=òy`%}8²XtR˜±¨ÂEýÁeŲ¡E—ÀÀ#YF,«0dQa#–]ö·]˜qll †ÃEšU˜4o±Ã”¬ÂºÑ¬ØÅåõ²>#ç³`h^±¬c¦$¬ÈgÇŠf<#š©Ø}F¢ÙahÆ&XhVáA³“ÍÝFÖËH4;L>SŸS¬Â¤yÌÒüîi°¨…‘f±ïQ°šÕ8ïŠQÙŸûÉkÁz±Ï “WÔÉ+²ýh¸HÖ  C½ ²ŽÙnúóP_f8!‹Ú€ìÀòV𡀈2Gq0è-'ŽØ%¶°CÌ*L-2D[§$û†XÁbÄè5q0Ö4ϬCxŠüñ„Ê€9Éß%î_·jX牽:˜§ÏI5ìÞî1ׯ6Ëùzinžèæ6žøž¹y÷ò…‰ŠÄ¼‰£<{rû‡ÒÃC?ë Œ=] fXO® gò¶²Yš§ET¥¶&Q¢=21ùµ-Š´8°ú±R眷é´Î·…!ø~.ÌXâc7äùÎÔu™ŸÒŒŒ5Gkâ2±cñïnð–Ì X§ÀäeÒf·½ßjZÜ¥l«cO5iY˜SUî2›×\"ñésÚÍõÏ?]¤g8ft+’„¯ÖŸMøÇÔŒ‹wBÑÏÊó,³w6“ª}zmÒ¢±Õ>Š9® éáƒ-l56ù1Ñ{V´ùƒÍ@™ær¢4¦Å§vÚ§jó^Ðí ?=1ÃébOóû’² (Ôÿ¬ªèòÀ·›4?e–¼³µ)÷fW¶E‚XEóì›ûÁýÀmÝOxéžýxçòãjãföžK«-~ aÙPQaÊÝ6n>_Äß°Èg÷Ñà<:™}Y™ÈìÛ"æýÕD¨*öY5æ ”òWyÔG°ùÒ6*û»Ù\gQ]?lå7·¯ÌÂDŽãœ¨›Š<îÖõUž>º@z—~Œµ¡»Ñ9b%oëún¤4nl]£×~•©oLú/i%™ýdæöeÑT8é¸d¿ÊÍÇfüÍ­ª4¡{m›c™ÔßÖ0kwXéout°?¦Ü*‹# MúH7âþìü濾_ϽEŸGª¹õ–ë)%õés¼æå)o‹©—ÞãÈèI‹éàhÙ6DÕøóEááö¸œgn™î¤èÐ'…óBíÇÑ Ÿ[XÏçí?²…ÿ/ëÝ:Ÿ>ÿÿ˜w‘þ^tÍcËÃü—Œx[CÅñì>¶':ÆQ³Ÿñ»9p¹îèA·¼_Êf>¾{€¹ÛcZ›ø0ê™ÄÖq•î0´Ð æ§ÚÔíéTV Í0|•™Ë/™Èࢂ͆ñ‚?c[4&J’TNà’ï ¯_™}”§Ùe*‡°Hå"ë/8MɆçæeãtbÔ6.q>Êl“)×fb²¨8´ÔT ±³d×&½oǨ6ç4!·¢øCQž3›0|í0²îÓFv©-iamUO1ÀÖMvù‘Ø ëJ̾*s,´.OˆR“Æ<ðÒTgêKÝØ|Ú;6kÒ÷—£yò8Óøhº{\ƒpÖ˜««(3±ÌO,)—»À¡Šr\ø#вKòަƒCY&¦àX›&ò²Ê£"¶sóî˜bÌŒ²Œ6”Iü;#`x¨Í¬£­Àãÿ³Í²Ù¹J›ÆæšµÒl’¥»Š/šx³çØ´5â2ræœÂÄ9B†oLWñ;@Ê,#à§HªSŒ4Um ,÷ý¤nð77¯d)É.ÿË‚Ÿp‰~‹Hy.L5-|uîѽs>òDnÖî*$H¥‹Gº*€ß lŪE¸¥Zfu´G¢ ª,^ãÔì.t »“c‘*­@ ×uT¡VwmƒŠ>ÙÅ|‡»NÖª+p_«’ã˜$˜Òûu»2ð°ä4·—ŽØ°:ówÛfÚ½8Èê’œÃl@:Ø7K×÷6¡w¢Æý5Æú)y»´ÀÉ~‡t"3¨œ~ÆŸ]ÙMmâ>žr{y¹§;ðOˆzQ6²YÓ¨OÉòæ) ׸œûnJR¸¯æ.­Óæ/®š|­”šzgwxî/.õö‰_¬x%Ä/V¨Kñý _y棗"®-ðò_mrïäê —¤ç²ú@] Ï·ÁÝ8à$E»ò;ç–Tplãc™ÆVTË6ãD2…öfëÃy„ë:µ;Õ½E\Ø’,M½®èÓB-hgÉä‘8ìóWiÑÞcCÜoVÓ·o¯§7Ø1ñû'²/‡3êO½CQÚb}¸áºE%ýM…|Ä ‡^ͯ.¤ a¡´?±fìÿÑv‘Ä›ª‘aþ–r%ßfu‹¬@'õ+t$üI1£ÕÍͺ'Ô̱հeªî q£Í$§–ÀÝOw–s%Ó°ª,eªéÕÏ hÕ{:€ÒÁÎø½“ø@±Öa6CÛò{² ±À¹‘\ :1š[ÁÝøý„è¶nÑ‘fÙý=.LJˆ,B…Vj^—£æÄáxa«ÄÜ4evBß-`Ç_ãcšœü’¡ÆÐÇôãæÄHbKzÑõ{ï&µŽÑ'¿Ç§ºlu°8¬Päý)¹Û]맯{b j Å=5kŽå¹ë=œz²@Á$H½RcAÓàÊÁ Š«2u˜Î'¤àB®"éï²ÀYªêyäÈPÛhZû¨ê¶rÿ»“¾yØt[Y< 8©¤(¤7äK™aƒmH=»½ú÷ÕŸ”VJ»endstream endobj 5658 0 obj<>/XObject<<>>>>>>endobj 5659 0 obj<>stream x­WmoãÄþÞ_qéªYm<Í{| °P „.!DQ™Œ'ÉPÇãµÇMzý}ÎŒíÆ®Ã u·Mõ¨ QôœHtt³ÎÏgs±ð0˜^·‹ÑsÐÜï»Ա|êQ¢è98‘èèúêþâê8¥û ºiysC÷1\£•îÕp6ø¡ŸÊ45é–~þõîÛw÷AdN\`‘h:s ïwšÖ²0ª »¡­vŽE¤¢•Ü'´·q™h*3’iLy¥Uɔ֚ ­SÚävO6Õ¬‚­]¤rŸAêù¤7&Ñň֥#SL ËîÀ  ƺP¹Yë˜v:ׂî-®š$†¹–#¶+ öÒÁ÷xÁ6Œ,»ÜŽvH6sƦ¢¾{#fœ…)§a*f3|‹‡ÿ)fKA¾ö^˜¶¦ˆEf3±\^‡Ü!œƒIÊräHiš‘1À5þØõ¯JËã!—™PmíCR6uÒ¤œ£„sÉÞâi¬)Õ:F†Ü™Üœd B¬·Io(߈^lœUvŸ±k¬ýŸûx0n×Ê'ýM46gbtãFT*×ÒŸªP…õÞ ú­vœVt§Áäº(_Ø2Xñׄ’D©t’ŒüóØVѧ2¡Ä¤OÈ ÂŠTY8@ùa˜ZW§|ƒ8Ré̳ö7ÞU8zí¿hºd8ø¶›Ò­OoO.^;\FÝIóýxË=Æ]S7Zj˜wKƒx|Õ8=UÍd}éa´6Èÿðm>¼C{f2Gb“Aw)É86Ü Œ#¹Ýæz‹ÀÐIP¿ÇÓš)ìlÊTñ}™÷2ò9c;µ ^J±t’ ——Ê•×n'ÂÈ„N]A·W·ïßÓ³LJ]px&HìTúÑy%¿“9;´Öîfi•:¹ ƒÆ8XBYö†$þÃÿµIu ’ÑJ–E’{É<%i©v—€Ÿ  ¥íú/&¤Xç(nXŒÃþèÑ5nv ÝÉ~ûšq"•¯ðr€#é³Î ¤¬  ­ â+d®BÿÝšçp´ b“Û@ž‡!R–iå¸H  dýRT`ªËÞTêßhÁ c Š<gR§ó±%æIV#®Ÿ?é”@#eýw߀Ÿ·Ž^OêꂺÁ¿B@žJ¾yxV(R ÔBƒèîª,ò+“ª¤ŒõÕÆÚAÍç'´Ë‰{c·bgvú¬™×;u:Âèé̆þz0è X»P53¨žÐôíÐù(úÔøy’§ W‚ÐÄ#2Žb ^`‚b!’k‹¹*Ôñ8Âo5â¾*Ë‚ò–»N'yä“>Û' ߤÄ͉ÖÐaNìÁƒŸ*·Ê:i=ß<#®7×B”Ú—,:*XoÆãñ,$BÊkæõ)Ÿ/êqìù³\ÄK@6¯z=Ù}Z7Aü âlÎó#úÒã_ÔÞ‚J²Ë¿ÛäútlÀ0{¬:à9„â'ö:Ñ(¬§¨BÃϾÁklùí$„^çé®xQP5“Y 5 »‹ÄàâýI§ Ý)·:;FohO?Æ}A=è}E™“¿7ë+DŠ1M”³ùK½Wx ñ–?±‡ØâÉÏ^ÞôÔN«'šcâöæúAøtÚUÕÅΖXôêéÖl$½º_[ªa½èŽþ¬*å¹þ“"@ÿ2<³ àG}t¨×>>þð½,¾¬i¦Ï9¨Ÿ¶—c,xàà mµ–…1ÂBÃ"µv›šÿ¡†:ç í™F¾žúÈ0 ÞH€à<ê=ñjÁeöá6À‘E« Ç´~ñ¼J_Åýꃱ²C›W+ÍV§š€¸ÃèØÇÙ,®k¹N^Hzé¦6Ô^µ<‘é Ê鬓Bû^l2õrï'1—pÏÍÁ·s¼=›,ªEýf%Æ«9ò¼‹¿½ ïÒ¬ô‹á=™àŸŸþä[,DÕFöð©X^OÁã 1¾öØæòaHL,hWLZÓÞ¤³ãŽmÎê¢IÀ‰q8?¼ã~÷ãµ*à`ó0¼}LÐô»WÿÇYý`ææí#w‹Ä"ÁfÛd[µFܸë«8‰0°sÓ^»!^|êµOÝÃ0Ð;Ø™Á©MÎÖ'í±î«Ëú%‹.±lÙ,<­yuˆòoË=v½¾ÔÓåû/h}êcx÷ëqòýƒ¿SÕHHŽˆ/{µWnê—[±¯hy=«¥G3]4à þ×Vy±óZ ¼óÏ]‡eàÌ›ób¼³i@ä|µä0¾¹¿øïÅÿn©h*endstream endobj 5660 0 obj<>/XObject<<>>>>>>endobj 5661 0 obj<>stream xW[Û¸~Ÿ_qÖ/ãéŽ5¶|b7@ênÚ<´Ûb§Xq`Ðmk#‰ªHã¢?¾ß!)_:›É`"ñܾs§þs7¢!þh<ãߤ¸FCœœþÔ;~¡ùÿNãa4Çû‚jI[f¥Ùb=ۣѴ=ŸŽžq¢œ%nªŠ‡±Wx¶1C5›ùÁž3ÛˆfеaÏ;ª¼ˆ<-¢ÙÙ“ÛÚ¼/;—2u7!X˜= z œ%ÂÞX`óY@›÷&@¹”騻 Á†c__ä&@9K„½±À:æ=²€6ïM€r)ÓQw¦ó™/‹®7!ÊY"ìÖ1ï…´9oB”K™Žº›,aòMƒ•6 PÎAo°Žy, Í{ \ÊtÔÝ„À„ÉóÂ{3]Oå,öÆë˜wÈBÚœ7!Ê¥LGÝŸ^îžÞMi4¤—-ÇÑt>ÇP\D“YL/)ò2Ĥ}IúWF’Ù C™ˆFKJD‘WùA5æ]¢veö_©é‡H”)½yóy$YXË*‰Lis¤\ç–!×5e%©JÖ¨šJQH=¼üD3h0Ž£áxA îá|Hýû¦T•ãšx®>©Ío21$442m v ÿ >à  ²*Vý¬|UŸ$‰Õõ¾ëÑrýª²Ô)mƒ1hEñ¨µýK!jC•ÊJ#kI"µ¦<ƒ&³Ïô5¨í~ð† iö*¥UAÙiZ=܆vÂèÅ{ƒ7-ÎÕƒ<'.„õ½sQK#>ZD÷€EÑW9 ±UõЃËužiC¬èÇoõ¶®Å‘¾ÓýNîÇÛ:ÃùðÑAV óM0´Îve!!Â28å.—(*ú‘î…‹zÃϽ­R=ûšXúži)¿˜º‘—˜]¶j–k‡ñ¤k¹Ö¦ÎÊ]ë\®SÕlrI¨¼“îåz£TÎÊOðZk¡J8wÌR I!?OzZ|k4bÆÅЋ{H´m'ï#ÂQXõwÒÈò•zÿxûòWæ6Šœ3W_ÐtPõ'M[49üôl´Í•ÀkëVÛpñ„;·Å36j«¾CÇe×Qº| ðÄõRÆ÷ôî™87[BY<ÃÃ<šbÖÀöx¢ ýKsjŽª©©Pi“ÛÌ>½kÇÂOÀ«±$#µ¤uö*/Åxêmš,OY@ ª\¾ÊœÏP‰¬«Ѭ#ZªR7¹áÉéÉ…(‘Ûà¥Òˆ,w3ÒgÓ¿îe‰T~²ÊË£Û Fr*é™ý%˜GâéÍúI£*0M¦€]9ŽyÛ” óD…ù«:+2þqÛGÄ©½ÊµW„„—ÊP)eЉ`|ˆ¡W^ «¡ùYß&‚=²ãÙFŠPU–ƒتZ¡ íºÎØ]ëÛòûï]Fyy«1sKV$b£^å#EÉçÏ´Ír¬*†Hº’I†ïÑĈãÎûÍZa8€Î>Bì¢ìÛÌ%×fûýŒ0ÕˆWvå#-¡9°‹a×]=I.tgo`7ÀÍ«¸–ª|’GtQúh#p©Ñ6J!%ìÑÜ¡m7”9V°Y`ärB¼GÔ”©E) ¡kOQ{S˜o!F#„-ùÓœ8ÅYöå¹U½¨Š6Iç¼ÚîØâÛmãJá; ]‡bÊÕaàºàgî‚§¥ëƒ-n ×aµ…au£ÖßãºP[ðŠ­½fˆ­ß‹ìÖ˜(\t§êuñjyµ,uÆsU5¦j FRúGÒ ðÁ•%q±˜ Aó·–ZBÆpñ\—z! Ä[“Ú²8%k¬#âpÿÑgÎ 1¶d.ÄLKô†Ÿ1s!*:Ô:ßÞ•pQB6½Š¼A¡êC¶[æ“q÷ò—­Da§ghM«»©k^d M]R*Œˆè½qš¸Qm®ê©@ß#µ$ªJ¢|‰[eH…]êkG;òwµu ­­ÄB$µÒm2ìýÎ-fœX_ CZDc·1ç3ŽÆc¼¥}‚Þ-DtXÚ'üœoe\€þø8æ…Á‘oG‡œìEÍdþ¿£”¥›ß¡ë½Â%ò|!ñß¡Cê+Âgê8(y{ñ[ ³‰g˜MìNeû`ð7‹¯pTƆX`ꆠ%aïrg[üö5`Ï^O\ü`âîϪï7;îÊNkûà¶|'Ñž‚׋R‘eƒÇùimmŸ78v?ªë6ç¢{K[y8•¼&ù™¯·‡}–ìi'KþNAÓàªç{ £]Ã?½[øÕ'¸ELñ5f£)«ýå×÷Œq“û³J^Gv§q`ßq殾íêCgðHAóàûê|ñ˜gŠÃ:7yž³üO/wÿ¼û?„×/äendstream endobj 5662 0 obj<>/XObject<<>>>>>>endobj 5663 0 obj<>stream xµYïoãÆýî¿b` µ}±hý°d»E[4Î]q_´ç"ê@]‘+‰9’Ëî.­ªõß7³$Eê¨ö‚K‘ä|ærgÞ̾y3ËüãlBcü3¡Ù‚ÿó³q4Æ“ö»á_h:}ˆ´XDøõž¬¦5¿IÓÉm4—G“yóoMú†Âñp;¿‹î.NššOgÿÛû‘±Sîùùäá!ºŠchá°a(ÉÈ‘k‰cÈTˆch¥³åÈØ)÷òüþöD ‡ qLG®¨Su+-GÆN¹—狇h6x ‡ Cq¦#×Ô€©:Ž•Î–#c§ÜËóÛi4•8¦w½ú˜ ,6 Å!˜Ž\P¦ê8V:[ŽŒr/ÏRŽê|2°pØ0‡`:r@ ˜ªãXél92öÍÓÙÍ»[šŒéiÍ¢¶xÀ߀CÙžâËXåÙ²ôvù¢2(Y¬ÓíHQ¼4«ŸH úÊüìŤ ½‰ˆž¶©#·5U–ÐJSåtBkcIe•&-¼¶TV¶4N»èêé'@˜ Y‚a$¹†ËçéâŽÂj×F“)¯ °Ì›ÏAÆïý\¹qžÖÆ"Ê_ÒÅië¦,¤ç(g’Ç/Ê{ZÓ;GŽfÈð”V;]ø´ØPêÉVبô£x¾¬ž¯~ÿ|o•}Åñ[ÿ ¯œü×uf”MLµÊôóU'-©²´¦´©òšI |ô/†ë¼å$tI àôæÈyýÚ/“¢`l™éâ„_EXÛøíÿWn'ê/UAXÔ±'¿/õ†G.ùkÚmÓxK±)¼J¥ìã̸ CÎ&}á|æÚoMB*޵ûyÕ=šÞcdMo¹¾¿Ñ±‚pY“9ñûL_CeY®JŠ6hpîéc -ÂË?©§*@ïµ596­«"ö©)Ð…™*„ ƒP0XH M±ŠƒÚYŽ™ùk²½ãŠŽ.Ôý‹á—ÕEp,¯2œOßYÑ8“º;ÂL› W+W›³ïAª™£•KËÀœ /»-¤É±£­za2"5C}ª²÷š\…rÅ"|¨O{c]È‹ÁA)þ ÞC‡“$åÁQÆë’ºo×;ƒHÔè’ÉÝÓ"æb£¹²„»âJ“@”fŽ€#EÀ%Œ™ÀÄ,ý(c÷‚TH%BQ:²öа2(Ä”©ñ¡â1h<¶Müšô RU1Ÿx‡Z› Ð,/6ˆäñ'ã…̦Úl™Ô(X˜ÔéLøúk¤1Ñ=(‰3 ãÑ¢6Ê®ÔFãí,CŒEÞ2è"l îß¿ÿcÈÙµCl£_­O0‚MPa ÁjÜj§eÕKÒõZ[.ÕÚ‹ÒˆZGôÅ‹ 鸞™iLlL±Ô©aMÊRLi»@/Î6…äTÎÇŧ:$”Sćs„ä&©R ‰è{&ªf¢àŒ¥œD¶ê‰2ˆFà+V…OA&™Å¢s@ˆi1ôÀ ñ(<¼ptþ«sjè £¨&0‹gÒšýäþ€`ëñTŠæÀ‡šÑ!ÖÀ ¼"sרÖ:Å'aãòMç!Fš—4AL@á¼òiÜYô¦Œ"¡C7}  4†r¤â„Å¥ë%‚¦c˜ëX®Ý2éí>t¦CÇ,´NDDñVRÅ}‡ÈA˜®ÔvT*ÇP¬p8I1@ølM+´º¶¡‰ŒIç0»"°Ö¡pn@É7€+L6 ±k޽/ÆÒôAf9¹›wÄcÿŸ_FÓϳI4Åm  .XÈìÀ=NîáR# ÷|ìá—%Õá |É+ÇåWCû.QT$Ÿ?˘ô09‹‚ù/•£é».çÁJ\wZ8HæZrÓlOèïÞIÿS±õ‘_^ô%<(Øž­½²…>¯aÞJY{¡ xµ)Ä·Á´p¥y& ©Lä"VeêU–þ+ðU攺œQ; ¡N ¦aŽb™ gØž>‹ ëc!/õ#ô˸ð!Ùý¥™—Z©_.Ð…­q¬6=uE°£Ûéæ(mÖGô£@r¤Ö[(ç kÝÙŒ»¨åJ9¨\B‘¦´ £(3ètѾy6ükÆ7‰æ³{°s.?Á¶ó­ÆÔbÏy‘/à“Ø+,D‚œ¶LÝBc¦`O+½I‹‚ÛUM±ÇzÁP•ò¼ÒÜ$ËÍ€iÒ½C>FµÃ¾@Œï¤`ÎÃHó¹xj x ÇUVÉ 9²8’ëŸ8ƒ!Ÿt”gég:iO^ÊU†i¼œÑˆ>pyãæßjU÷ëE{BL–>”é¤Mnžu‘HŸøÚòÉ9×y²Ž.L'ÌPm˜*Õò(&Û½’ëÕˆ+{¸³Õ-ÇæÇŽH).èܯrµg;õ®EJÅšºªÃ·¦óþ+¡Ž¸Å‹&"ç«úž‡Füئ+ôQáþôZ.+®J#³ŸÐþÐ'F‹»h1Ÿ Z®Ë¦cLémQårlÒÄ J/soA¡Jh‚&ÛcL-qFÛÂ7 ¾cÖGZÊÇG+'„Ë ^y\²±0j·s¿«ÊßIxFëÄmäøÆ:$Ê‚7cnçÌ´5 ¶,½»ƒDÞáx.Ú!ÜzÃx!”·ê@¶ñøƒ0Ù¶ëKm=!p&æFËUá;¼ÇR•eå¾A-7Ê>ÔИXÄår‚IÌ4'NÀ‡´ÀÌËQ¦V:sB:¤Éf˜MWÚï´.zéèÏmcDÌÝ4‰ø>€âD&]ñÄGˆ§Êno«gÝEÀoÞéÒ1eLyh˜F³~Kšñ N¯ví÷‘ó¯þÍPoÞ50'ø†>ŸÍiqÍä[%“jÄÿæ[‹c!oMÇáíÑÏ"a¬‘¡3û(CsÊB+½‘OzAxã|¼ˆføXÎ{nîùÑÛ§³?ŸýÚØêendstream endobj 5664 0 obj<>/XObject<<>>>>>>endobj 5665 0 obj<>stream x•WkoÛ6ýž_qÑ®¨3XŠ_qš°víÐOÅð MQ6‰ÔD*ޱõ¿ï\R¶%oź8ˆmŠ÷}Î!óÇÙ˜Fxi:ç_Yž½YœÒê5]¼Ñ‹tJ‹œ&#š_ÓùüŠYØ5¢…(Ó”$—ü¶ô»JÑŸ$è5‡´’ħÙ2¼½ Ï¯ÎŸÎF”Œa˜ ž}î}ý¿~.Þψå” ³d2m3,6Šlã«ÆSYh’Öx¡{ÉÑúå$“I:¢¸l2ïVñš~ë¥Gtט{c·¦·üÝu¬z~ï}ëk4äþµñdsÂ[Ï!ÄéÂêtAž.d½…~.¢à(KoÃØzÓK¾ãG„7¹´«O=/lçl—¼©SùÁàð-¿8£KÚ?wTYçôªPä-e–üFÿÇœVÂm’I:ºß•¢,Ê{o+Jdã¼-Ûì”óËm-ªÔRYZJ: ¨¾êU×u^Ä:Ùûïm¤öçãê“’^?(z‹DèAÕN[CÓt4k÷˜ÀÖS²•2ô.0éUŸO©Pž‰·qwât wþ‘^}¤a:]“^ŠO{sêBnNÂ'_ðËŸxí¢¦çuöµ^Íï\/Þ_ÿ;ƒ§ãt‚×8”K`Ž6k ’>òÀ9£#®˜ù3nr`=?§›_>üH¥ÍÀ |¥p䚪²µ§ÜÖTX‘±Ca2j*›Âë Û;¦Ž„9QžºT)-O4v#ŒTnß™ GáD­ý²á©jå”ñxmïÒÑv4Ne´Õ~‰,„Y7b­ðDK,8×”Ê!$â*•XHÂÒtj-+‘¦WœÖ…ê¥Óü`ÈÖ™ª™Tp¤ê­„œmLf”ã* ÚGÇÜ'íl!<¬TÄà\2lYÕ5òST ïóX @Ù´‰¹ Ò;HNhÉJù­BÍyc@ké’g€y ªf:ÏU&µ…º”~µ f‚@³Á&OmÔQ ‡Àû…8¶0­^/™û0´Rr¿-œÏeÛ~cñ¥nC§S@#2Ïq*&“9O5àpJß׵؅yp—äÅ]@ë d) ク¸Û(Wtì÷gÖ·r§ ÑQÄÓY+£jQ;”Pd\£3@؃Ή°¿/¢§‚‚c[¥0$›šû µ…ø¬{èÁÙ6rH=VÌ g|”Ám.…¬m@3ÇÊèvÀ(GAKY4¼´ÚQ¦r*ÝžÇ&³a(/ÓÎ×€Aèõ¡ú7»Öç‰ u§úÉ“‹e®!B‚oà9µÉ¦lTQ…ͲVï¾.0½ÓFÊ…®Q¹N»và¸þ„ Ä!g¥¸WKæ¸ ÖáJƒ¦F„ì§7B_Ø+úVì8½~²ÁãF-2ÿÃM""Ä0a€}¦†½‘p—ùP$kxî¶¾ïTÆ4´Ní½t›]¥¤ÎµÊŽèîÛâvBoƒªœôAb/Gót:Cg××\ûÅÙOgZCBendstream endobj 5666 0 obj<>/XObject<<>>>>>>endobj 5667 0 obj<>stream x•W[sÚF~÷¯8Cì; #q·“<„$?uš¸“‡ai%B«ìJ¶iÓþö~gwÅÅÁí{@Òžëw®úvR!uü¯O:ÁhH»/½Ä Æý`HÝñ8iwtIKZ€¸öí—'îw#°0ñˆ%mI©‚±}öëçNæ±Öëž?)êÈAÔïzµÑ€¯¬NÉÑ#Öâžvì ;òZ{9±:ìó'E9p˜3€½GŽ;a»(íÿúöäòݘÂÝ.êÁ‰ .âf7 ¢ ‹€þnÒ|I"'5ÿ"ãòüö øz[¾vÔ_ó¦üÙP¡ŒI癤RQe$Mž?ç˪4‰äNä¥XJšo(ÖR”V,™t]€Ã §r%J*´ºKiHı4f'Bk± èv•Z‹ Í%­•–lQ‡ÚaÄv€-Õ‚mHs2j-)Fšôä1 [mUÅpÉk¢¹ªòÄP¼’ñW˜Õ"YÆA«¶FÞɼĩf%Màõ9¿'*7°UÓ½NG5Pt¿’¹U(ó„}~ËT`á1a‡ÞÄŠAx€•U¼"a€žCGËoUªeB&¤¹Ìœi.»àù ø˜õè탰¨–›B®EA …ТÊc«¿ì%-2´/Ûh=Y 7lu¨¤îŒ@vÙ j¦¹{P§F“´ç$¬·ðÝêm1>(BŽH&óe¹bXøÎÑA£)dœ.RxD-ùPjA…Ðb-K©úäڇÅßâçõºO³Œî•þʦ§™ÐÒçÆÅyÁAFǪ‘)4€°ö‘ePŸÂ:àgñ²æµ,h;œ›‡é(â²Yí –…Ò%"7Y-¸àí²Z#¸¬Î?û‹B®…VkR±X# Ö.„|b3¥†æ+Èaaˆ= =€gë'rIB¯MçËw}ÆpÔ ¢q—ÚQ?èwG\R¥õ8HëxÐÐ2Úá( †ý>.ºA/dʳµJ*.ËQkæ¾Ò<ûóàöª1«I/L™¤*X½òÇ‘¥¾Si‚âÜÆbÚ¬“µó'«ÅnzN‡bɘ ½>Y¡ -¥—Ô¹ÆÏ „ tª'¥Õ¬Î p7ÎÔ@æˆù§ô3øjM\ I³&ÿë¨þé4o03Ñ45›vVß:`Î|nOQn°wÚô5¼ËQ?ÙÙyyA§áÌæÊÅåìÆiœ8áf6¢3`5mž¦yQ•Ǽ> A‚­Äéù¤b`Q(Ã?¤Zl£Éï‡Fÿ¡ÓáMMT…þ?»Ù´¹g{^®jÛ[éôü˜âk‡O}÷?SÒ&Ã^A Q%=®’~Q9IóƒkÎï+ß1;´-©-q]RÏHè·º>Ì´g4Û+ ?qq¢Oßi2s8PˆàzwÛ=¼í|èûgÄâ‘t0ÚÅ]8âNç OÚtåÍ âÆ8Â0™q3•Ý00˜¹]Ø~ÒÆ^uú ƒV=»$L2îpÆqÔ3=êv»àE"v4è¼™Âð²=Ù”ºŠ1šy‚U9F+.1SÐgµä‰‰¦‰mcbÍš6Aͽ²ýŠœ¡õ\¿×¢(@gÊTà ˆ[9V·—X˶;šg)ÐÂa­TBYjJ7„m»<ÛRäÈý{îêkÞa°®`)bê¯n5ò²úÈ›‚oò(T4p7·y"`Bó*U(HmZ5övÛè %r©Z)øj*ðiU-W¬;ÕÔø©áM…_oï¤ÞÔ–o×:ZaÆbjìCÇS—5ýCtœäW¶{¨ÅεÚöеÔJ,ýйä¾Ão#~eÕ+ô Ç4õlCp‹“¬Í}öŠín‡we“³u@ÔÅ4ºóooYýÞ§#‡Tß5Ý··'¿üiàŠìendstream endobj 5668 0 obj<>/XObject<<>>>>>>endobj 5669 0 obj<>stream x½WmoÛ6þž_qp×ÅAcYò{Ý—Ë’­À¶nK°~ˆƒ–h›,jm'ºß¾çHɱR·°am@âñ¹»çž;R¿EâDÝÿÄ«£0 éá—Yà!¤î0 úÔ>"ŠúQÐ!#iãÛw¿Jã~§Œœñˆ‘v¦Ô‡FõÞcZa¿þ=Û„:°Ðõ‚suºu'—\vnÏgÁ-8>8¹è±“+ÎÇŽÁ½L¾¹:j_ô( éjN`¸;¢ÁhôºJ±X‰›q.ŒÌlÑ8¹z44¤ù«´k“$(U…%='‘¦”(#cK~Å©( YÐv©â%-ÅFÒLÊŒ¶Fä¹LhvO—ïÞ|0v«ou¢ ØEc<¾öH-‡t³„³xb£ä–ƒ°KIzöžƒ…{RY¢baán?ª€®–ª ü¬„ÊÒ{Z°P™•&C"÷cq|.¼ZsÓ\édÊSš­-öÂPòÞù:%«‘±[”½0bUìe6 ýÌ®Wr5“¦µF‰Y*?Mí\€2oE•‡[q‡ìÖíR'´UvI"#[¥>g*°&M@gÈ™9If±^!ÆSNïQf.¦š·BZN‹™Øˆt n=ÅJ@ïØ÷iô¹pÐ¥="6N)2)ÉÃ^dvè@èOÚJxðÄ%)¬QÙ´¦:[ „Þ»OÛ”µ=E¶ eš·€þ,‘&½ç]¹v%<¥B£*ü&6ÅŸ^ßÝLçF¯¦¹5P*¨ñꨂc&v%ö©Îµqð¨,ýºÚÏ˾Á†N5ÑÅ\ z˜P—W?ÐâÃVްÌåüN¬òÔ±ýÐt»Í—¦Â$dïs¹9 ‹—é-Ëh£TC9ÐƼAe.Ú­6·Eଽw—s'&ô~^MÕ-㛕Hki—öžÜŠn£raUKL†íèì½°¶ ÚÅ Z(Ö¡ßxJ“¦+µXZî˜bmr£¸@“´’ŒzˆÞÆbu0$— ;@«¸Æs³d®îR*³…]ô&+¬É)w#‚I­奸 I¤Q2íêµ"’¾0eYûÕ8ŒpØtº(n¿Òhe¨˜°öEH£ Ë“³Eà?òzîE¬…§~@TØÃnh>ý£öøDeqºN$5*ü¥q,Doÿ±´ïøÇÊþeaÓ@½®-fi‘‹äڄꎨü÷ÔJeš4/]›ýæ´:9á=ãq©Ü—eÝèõ‹Z¸«ÇGÑ<о}1¨èáDºÕ8w·L”'Êqîù/Úš+ßFVìð¡GZþdbNØgv/A™‘ÇnŠ[9W(´+.fˆ?´¹÷ShÏŸfº†~Tê‡Ñ®¿‡”zUcȊبÜlÐ11DlŽ0œhÆl9_DEVÕösXâ`¸åá#àx™¢ðÈåóä¤<Ê+¢ÝûéĬä=òŠ*UºÓªÐÂ}§Û…“æLËV'ûâ+ Ú%êvª”ðÖ‘œÎ|`f—Š5(í}‘+{¶B$? Ø!±ÏÚ?Á!„þr«ô¢Ò‹s¹TÖüÓÕgͽ¢Ln§ûê¤ãI }„† ëq%¡ žâØÇî3÷÷å|UíQy¿£ÖkjŒý™Y4P‘OQ[Ÿ"Öè;›òm§öŠ®Ï¦~ÎQ#ÓyãB¨ž õAÖ^ ýì}íMœJau¦h"_ËéLÄ·µ]×7µÇWµ'Ú_ü³fûuíiwÛÛObì._zþÌ©75jž Bà|—(o̵nü#ÞÁÁF«äog ï?üðﯣ›Çr= ¬½"s‡åëפ60ØWÿwPÎ磨ø"¢Ðe!ÒIÓ•—Eîzɱµhá³.Ñnð´/ð¡‚Ƀ |êô»}|f ‚ás7çørÝÂÈ¡ouì.¥‚ï¯ì²Õ ½ukèÛ×ß°èìÙ3:ó_lÖA·ã?HúaįίŽ~9ú ^õ7Eendstream endobj 5670 0 obj<>/XObject<<>>>>>>endobj 5671 0 obj<>stream x•VéoÚHÿÎ_ñ”C!i<øäHÚJmÚl#¥ÚDAê‡eE`²ÆcìáHWýß÷½± 6G”„=3¿w_3«Y`â×§I¿`Z3Y»›¿dŒ œ–ÅÚ`;.³Àê´™ ‡‚M$_ÿå`¯E$n§5<Ïe½eyÅ~Æsß 1Éö²ÚsiJb­¶S²÷ˆ¤l¬+)ü¹[kÜšÐftG`›ÐìX¬ÙlAw¨M6¡Ô?q""ÕçÑ0‡^½W_ÁÙ_”<ø»w~ ©BÔßÏ»Ï5 ɇH>”Hs}]ÙIYYüdký«²6à æ‘Pð¤ŸWÎŽµÀÆmHâ 4İܺc1›¹Λwïà&ôÓ¾®üirâÒ¸us2"rIão<ág)ø BÏÐ0OÑ<è&2 &yTp/‰Ÿ¼\e¼¼œ—evXÇs£Ç<§M\gЉ ´v8z¨Í\ËCW9ø$ÔéTç(s¦*&žþ[Y‹(çCïg~‡"ð•›|<„Šçéd0Wjtú»Bhÿ<~Úp…ªèx>@yÚÜRˆ)GÊd½:eøÉ8¸„`â'pq‹ôΫ™‘,¤BÊÕw_D?Äp̲xÌÞàb©w^'æ+PrTùÿ.–˜èàÜÀtÈgíÿc߆ uˌ¤¿,©ùº† OÅ/ž»fu©=ôò:I:‘ËCF•RÞÒiFyd›Ù™g½7r ,Û1¨É:—)æÕÊ7l›9öa}à§Ãf¦çŸÀc÷áS÷ۇƋœ'™jľšT¦ ÉF³WD.ŘMCQ¼ègìâ\cGÐK0dàã†H8Ñ„téº\'WY€†ˆ/¸ d¶³yP¿y?In삱œ`±ÿ#Žá(Û“û}¾RØìX0•0ë¿÷SEïG…dmÇA1dúÆ4l:ÆÝIæÇFQ·XßY7ØkætçýeâÇ,X­6ï%†‘k+0VÉͨ þòÅŽ.kQÕ¾½ßï¨7õ Šhàë¸é?Jƨ×>/XObject<<>>>>>>endobj 5673 0 obj<>stream x…WÛnÛF}÷W ‘‰’HI–¤@sqà‡6ì"(ªBX‘KkŠ«pIËBÛï™Ù%eÅ6Ç2/3³gΜ™]}?Ó?cJfü?ÝœŒ¢ù9>ª[ÜŒ(æd:‰ÆÇçÑŒ*M9lGðî>ZÛ °ñœu¦'q4•Gãiû<Ä|â,+ÏŸ õÔ vãUãq%~í°ÆoÞÞœ /'4ÑMf¸È$#\¤½_œk6¦¼¥½mh­î4)ÚÙê?2¥«UQ¨ÚØ’lNŸoúb¶3EAN‹©)3»£Ô–µ2%;ÕkM®®øòtmNWM]Û2:»ù 04Ž=˜A<˜^2Ž˜µ÷¦Òim+zW(ç´ë¬ôA<‰&{Ô©ó¸*ëÊfMÊH½Û!c¸±Sg›úè¤Pßöz·6éš+rù”ªMŒ2Mµ%{§«Êð5òÚ6«Â¤´ÑõÚfŽ)QôîÕ+²«¯@ÑÍÚ8ÊUj Sï}8'ŽÓãÑ€sÏzˆŒgâ\˜U¥*£ÙRÕ(ç÷D r¦+s§3’±l+{ÇPÔv ¾,n«S“TÞ”’¾’µÁ:æºèûZ¢üì1ž¦ö˜óJm4×_j¸ž¼? ŽT!fSA %em©ZW{äÃ5‡‘ÝrTA”¤Üê¶Ù貦Â|cûÉ×hDs貌y¡8JÜe½ÞoÑkWqoNǧ‹³@ ŒaEB¹é&€ãÄ[×@^U)ê¸Ô?ÀáÒH¤¹VÈS/z§m”ÃâÞÄûçÖÒßmUÅ•èË[þûÚ§ ÍÃ"GšœjÍf眅W~Ó'/3fð× .”P¤è<Òó[*–gë%[¨ò¶Q·ºå½®ˆyÅ¢„EáH¹pI)JuÅ­Ûé§Ïº•6/5Ä›ÌdÍ:7¥¬Øf-Zn•çõ+Ãa­Ê •glGK³,uµ‘Öá—ŠŸúv2Ãïž,VhŒBß)ÈÈ”(çFäÏ-§ŸãiÃÜÞ{¥Þ-CC-}üc^{Ü೫YZŽc2ª®é‘¶P)Pæ’Ÿ-á:3#ôgДX«Ø£œGàÌf[hn…ø¬Žñ§ÑñÂöQŽgÅGW^a£(‚Yj§òó”WvC;ƒ†+%…#(ípñ^ýfk® "'Ò…JËE¸³èæÃ°Œˆ‡D«™NÈô9]äaü·%é†Ëÿ—&ã$Ô¥2Âcõ¥¬y¥‹Ðñ×* s{ö ž a<¹þAlÊ Y`ªÉŒ÷1Å<¹ÿ@.³ß¸o§ö}YëRºNöO'TÒ F½tmÁúBtïi•Mãç¹Ë-lr25vlhNc=ï˜ù¢‹µ4²Ýù¡ÜÊÃ÷°á--}´½ÉV9w“U6Î+ÞJ0ô½bùöéê%z‚ïÂ0Ô°r['ã)x÷â~‘}«Ý0é «²vc »fˆÎÚ‡ ñ="áƒGà†–×ºµÚ°r¨FïTFkr8$üîx8† xx9 ãaœ\DÓ9Fó4š&sÍÐào£Máí»k0NæÑ$Æž‘D“1ÛÛ-ªp½3]ÇËŽ O,ÉðäÅa£ð÷…® §&ŒðB/ýþ²Åð¶+‘ ‹ÔÑ›– ‰@„ˆS w°´ùo ÿNS.ð) ~~â%Ñ¢çCHtžOZq z·,Œ«éOº_š^Ó^þþõ\hqâ¤î½ NPmŽÒ×ϯÂM·g½u€ˆž÷á4¶Ö”õҔ˖Bbò°ô^-ÎxJ®¬•‚¿1 >ÿñ-‘UÊ ½Ke lÿ;™hh•ïƒ8þŽ3.± ;•¢†p‹^‘vR$¡ùµœ:<¬û£?žŒôˆ¶‘NxôfÑkÙ‚Zô=|CèãwqÖçëi®ñ×?2§—p=#}x9]âèââœfóó(™H×\¹ú8Hðýä½MåÐ';Cƒî'è­) Î=WÒ |¢¿–¹B×Ú¹p|ŸŽfQãÛ új:JØýÃÍÉç“ÿäó1cendstream endobj 5674 0 obj<>/XObject<<>>>>>>endobj 5675 0 obj<>stream x­XÛn#7}÷Wü‘;ºØ²“A^âÉyÉb1Z$A´0¨nJâLwS!»-ëï÷Tñ"µíÁ À"Ž=R“źœ:§Ø_Li‚ÿ¦4_ðOÙ\LŠû;:ýr[|˜ÐânQ|OóÛ›bJ³9~9M¬`wþ5X g+ÃÎ`eødhýžÆZ^|÷aB÷Åœ–š·ó{ZÜOŠéìž–•;¡e9ªuGô#=VNýNíõciŸ´S[M߬F3ªÝÖzL¦íh1IÿšMVWôîÝÕòNº¡)Ìmè:œt=³É-N-wÆ~º¦F«Žì†;ü=ÚžZ­+ê,U¶ %¨²ëUM—e­¼¿¤JoLk:c[*mÛ)|h·b‰=¬­ª°½ÑÝÎV|„,Ç7¦•5›¾-y/{8g3v'Åó(Gð©Á=Eµí¨6Ÿµì•§gç{Òé:_éãï¿þ2&³‘jk?ÂÑϪÙ׺hê1â3åŽ=Úê™äm‡neãÀDåûFÃzÜm úIySªº>ŽÅ¾V¶æ »9ƒÊm±¾í<)üPùhןHµH¢¤W2Ѫ ù±G´ív, 8ÝMï;d§Ó®ÔûnàÉÙ~^ɧÊBíÙ{d”Ù;ûd*-õÓ¨ Öõ®¥'U÷:!håxOcÄ3d‡Í÷m…¢¹„ß~‹ŠÂÀ¿rÄ™í®KÆ»ãè³ Mì8ãá`êšÖ\,gm¬ã‹Ç!ûÈ$/ü LÝ»`é7ÛýkýI—]A¦´pÊÉÂO7pÇ–ª©#ÆÄ¸NÃ*Ü@®œ×õ¦ ÷ÈÌÔ‘*ã`ß:”SÉÐàºéjœËúdƒPG¬§³ bëv$\‘„IܪÆèªöɯœÌÐÀÈ„G9™Å™ªâ¯Û`´ˆVg7Ü¿`EŽ%€·¸ uíÑ(¡Q] •ñÑöÍp@kï-`#èÔˆß ™`ÉjÄÇ2'¦=‡Ï‰9F`=Ë.ËZ] °ÖÝA#‰€qʹãtÿ!ÿ$õ¬½Ô‘ðØ)ë*P”¬ÚcðŒi®Q{2¡ù=šÅƒ €QüÅ—Nû½m+l¾ðÁ—âêåyACí­­­5΋ 6@$­ðØËòÕUDq#è:ì=Œ.?CD2¦$º1ùœ#mŸ/m³6m| l¢ ôóùØÒÔX€So6Öu5¾aknü!2|F$O‰x/u»5­¾¸²WNxƒD†·N5lÀ¬}÷áûXtÐp@Ý|ZÌŠÛâ†4§†‰ ¤pÒ•¼q‰#ÎdˆãC£nÄ&JO%*€ +íKgÖºc¶GïüÀîŸéãŒíÏŠùjY‰&f?¦H¡oÕˆÀX‡Gð¹bòå¦}±"¬¾zrÔ @h‹Õ">Æÿ««1ÿûv<ÿÆßðýêêÔ Ñ bqßž²t-qÌ‹ÅâŽå\mŒç'Ù`†J¡Ç6|OXûr,!ÇŽJ:.Bd.arÃÓ ï;Õ–:¢9óFdì”QãÀ`PGf<.$ 䪓»‰åÕ~¯¡2+H½£ B°Ý_˜Mž¬©è¿½Eg9 ² @ð ä;èžÕèáqhô]¶:hë·Ëy*ÆöLô„&B»f‡ BôM"{]ˆJCˆ!‘¬§˜aÀ•à3TõæÞÈÇ ÒေW‚:‚tÑ·‘±-NÍ" ¾„h­FèLéƒRyý µ'Pe\JM5ü8+2¨é+kë!±°•Ì¥ƒöäºaœÃx÷À3T!¶?lâ=&ÀÓFÖXÍ`´AÒXh9Ù1ì|&ŽHÏ0ͲêÃõ4?¦±É†IÂéÈ‹XÄG‰; YQ9dÐä³=OYñÜAÀ¡àºhùY{åjÉr©a;шÙúH²ƒ¤ž xùP U8%Œ)ý)œ“?;õ„Ž„ ‡M?wi†sk ¼jüH$nçsÏڮÙ †àÑgài@|Aì~N®T%æÿ%Þ~³­~yJ_d¬‰É9›«LžàôÎÙ#ÏS<™¦3¼þ»GWç ðíPQÃùÿlD䉜瀨ŰÌ#rçŠx¸Ú0â$¥2Ü ƒ¸n­NtöJµÑ¦ÅÈO™õzñú8HÔ&¢„„ d–õ”§Ó<@³1×ñX-à &yè‹ÊÉ¥ê>7×µê›ý`”9Amà Ï™déÞó„þÑÆµl‚¡ AƒóR£Ï¡’Ó4á¥'¦çU¶ïNÀÈø<¬Vú{]°S—¦Ÿ™ìùH$5HF:!öR°”'Ìôô?’±YÊ¢ÜתDn†–ác¸M²e‰è­HFÙõq¼¸¡&¥¯2¨×÷ˆJZû˜§TŽ•ocPí<¸JÊB;‡aõ qqQCÙP'Æ 4ô¿Pä.¾¥°ñd9C6é$›çû›…{¥ÆÀ“u9L€ÉJk]ƒî=í˦ã¬ð€-¾ ¤P‡4Næ BKôé°r£&†{²).‡T_nìœ á–JNNlxá Ü p—Å›|¯EÒ°U( $Àô‰‹+1Ä—X§Z_ËMJš™ÍÀ‚\Ï®¨©RÞBz`Hi@Cd\¸Ï½ê  –r…•ÛcŒ^0ùáéÀ¾© ”9*^ŸòrÙøç¹äœ›•=¸¬m…{)ÙÛ&_ÑA®ËW0s÷%Ìd‹ÿÐd['IŒìôÔ`ÂÄÀ™Ióª”Wª"õX«ò3Wšó#Øar\ILPÆ¿;§ÍA©<“ãÆàÍÑëV‡Ô2›€ZvBð^ ªøv1Ú—•5"šg3`¢2¡ß\M>s›@ \ôû(³É Þ>Þâí#î3w ¾˜ð ´ë9^Œ¾·¥¼Î’;*ˆLX}}Ç÷“j/Šsz_¨Ð<ßÙ/ÌxÏídQÌgx+€å·“þêçåÅ¿/þÙø•endstream endobj 5676 0 obj<>/XObject<<>>>>>>endobj 5677 0 obj<>stream xmT]Û6|÷¯Ø—6Ncëdûì$mz)òXÄ@ @@K+›©ÄUøqîå×w–ú¸,ò’\ÎÌÎî·Å†J|6´;èSu‹?Ž‹²(œü™îÞßÓ¦¤cƒ½‡·x©ó:^ª¥ñL¡çÊš–<KÖsÇ.jÄ“œ¾rI®Ž}¸Ø~E«âåñëâîýÛ9åz{”ËݦØûâ ë›q}Y#eÅ–o/)>õÜ™~?Ãs¾{õŠLÛÊx’«¢GÈ“ˆ×‹­.øÏtz¢^¬‹ìéóò·Ï/ɸZƒžöì*FøW„£ T±}d2ôhÚÄÔxé(^˜*\Äõ|ÏŠL +·­B+i½Ù*IĻں3‰c=ç¹ Òq´‡"6ÍØë¨O¾—À$MŽMèé ®ÅB s}~*Ö¤Ê,V4¡'I°»[ˆ•Ô&Ä]jMTŒ€-r•›'…nêÚª–¹æ1y7hÔB'äHS2`ÔLÿ÷Æ„ :‚ÛÇ>üE¢—S'ujYI:Ù\áY¯V”;d_£8ÈÙ™¡µbdì»z!ã7€­LàÕÀÎs†7bÉ%òÔ¥§¡Öâ­¡´SÕøÄ&¿Ü”oL×Xâ Wk¡æPÇ8|³C'-&Й/HÜ®^mÛ*†:îÙDšÏ„`ϹGèÙl£À?4lT»Ç‹—t¾ÐmÛL}õ³JPö‰Øm¢*Eµ¸qª±úc2œƒßC0þiäµÒÒòÙC¢Ó šL˳©é;{A€Jˆ>é˜çÁ b ‹A%Wsc•©çÚžç:FGÎz{˜çÃþ«¸Wó½øÇÑ„ž/ò$ygbuÑrò¼WÝåäJ!õ½øˆÛRÐjÃ~™wRÖ›~§`»Æ<Á¾N •Nq“Z$6y Y{/¶FB˜ö¹QCkqýòœ;rˆjN5ôÃ"ÜipRvð'T¢2hú!éàaŒÏ˜`DˆŒ½Û~[ÞûÝž¶åvP@i­wEIJ•‡QÅÛzÚ»~­#c»¯gàa'·è}y(v[”{÷å^CÇÅß‹ÿÃ8 endstream endobj 5678 0 obj<>/XObject<<>>>>/Annots 2799 0 R>>endobj 5679 0 obj<>stream x½XûoEþ=ŨpÕøroÛðS M…ÔˆÒ!¤Hèr·¶Ýݺ÷ÈÄÿÎ7³÷X—@ ÅUÛ¸ŸgçõÍìÎnÞžxäâGAÌÓòÄu\|Ã?<þñæåI;.ÅQìTÒr… ºêea(²…ë„ `™KZ-È–ùl3ðEÏÃç€XÑÆ%yqà¬úµbVû®QõBgI± Qµ0T}ÏYØR C-¥†tå9¾¥»·îRÜ®"I{µ ½˜ÍŽBC®Øì(r£•!7 3€ÍZ°¤ØC¢“Ì‚%!¶…%³ ˆdD0~äÄ–¢!9ËÉ¥0-M­=wš4V%ÂnÏóÐ MÂØ”lÅD„» B1Xp–£Ð¸ é½UA¬icÎeÉ>'©…!$ÜQj ƒ| ×å&ŠMáú}¢žÏ 2^'Ì^WèkKjaHQl08éZÒ¥ËLŒRÜõû šØ+¶Ý¡ˆH4ÅëzÍJ“b/ëG¡avs¦£Tâ —†|1kÀhv1 š„FÖ8‘UÀ2¬hAN${“ÐÆF\KjaHWLÔ$5NcS4­€)Ú^æ.›…F1²hLнŒ72<ŽBs´Ø›¤ÆlØS.wy(ˆíz†j(©LR CºÏÖµ0ÓaZ–-\’ïELðhÙÆâ{;*2öͰ) Ä!¡P¯nŒÍ 2ùLRì_Ä4J*6Yߨ`_@Ïð¡è £P)4‰)4€-Ed‚&+Y(##èG¾…¢Qœ 多„6æxhÞIúÍÚ2#ë-]¬P#ä¶Þ`’ÆKœÅ>­3™¡.­ÓYàÓÕOß½¤¤Êèû´MnÕÓõ¯–!™³b(±l“xŽ£9Œbš½®U‘—y•Ô¹jU§¼e¯;_€ XÉf×~¼ ÃõuÅ«ç<{ÓUU^m%XVã(Œä\—%¢Ÿy¥HïÛ\Wˆ‡è‚!”È}o(fýärŸÃߖʪ¤ÌS*uÖï÷åøÇ†>è®þ(ó p\ôŽTðÃ+.¹Ï©eÿzC7IƒÄÏÏΟ=£»:ÙïÜam.…”c—㢫ÒOQö—…¾I ºE¯'7Ň´ûGûÜ&UÛÈæTUW›È×:¯ZUÛÍU[wiÛÕÊdÆí“IÓŸQxÊ«ªsðš{³r^úVÕ…N2•Ñæu©¸Ý«:iõÑ+yÎe#uߪªÁ¹Kwy»£'‚³ÃÃý? 9ÍV•û"i?Iß\•IÝÒ'Ú!ßæµJ¹~t=K“BF™Î´©uI²et¦®Ÿ™åõ®VIvìáR•º~ Œñd«JUµGÎêjýŠšn¿×õ±=]&mßSû°We²ÿ<öãÚwÛÓÙÅp%›ã"¼Â­Ì—Ý7JŽÓ•vùv7/Ô­*¨Hªm~qb»Ê‰¤kÂTÁqˆ£}­·uRâ.·¥v—´¥nÚâR]î“6ÇÌ3;üòùúÕóoºÔ5›Û躄XWR¶á^–&Ý(ÚèWK˜;¬épÙ›õÑÞ©jòöoÎä™Ó›ö…‚õ±¥»daÅa޵š¶ù­ÂÀäïjÜ>äb€ urujwª¿99ô³î¨Ùé®@xE£‰;™+s!Ît jªV ©´é˜!Éf¯Ò|ƒ[<˜Lzc§lä$ü2ý›ªl˺Ophaôå•8{Ñã3-·oÊú­ÿp*cöj•ËqصèÝ©!ŽëÙh‡WÌe…xäûÞÕõSaUž!^LòDàVŽñk/þr»ŸzÎE¿á l®„ _å‹¥ãJö==Ý´K´hàø0eTôÅÇäñÑkG§øð?ð*ã¼ß ³Ä ú±ÁMc¿WFKºÈÐèã ú÷Î=· Ї"£™QWô?L6\Õ¸^•¦BW[V·BåìÞ×Oï¾R§ë•j¿lw; ¡!áÐÿ܆G¹ˆm’(/ÔéÐ6Nþ —ø%Œ’ù\¼L löÄ/Ö'?œü ´l¼Eendstream endobj 5680 0 obj<>/XObject<<>>>>/Annots 2801 0 R>>endobj 5681 0 obj<>stream xWmoÚHþί¡JqT¼€MHÛSOjÓKU©RïÚœîÃqª{mm¯ãµCòïï™]/J_’™ÙyæeŸyr;˜Ò¿SJçü—•ƒ‰˜à ¿LùåãÛA:™ŠÍ.'bN%¥éL\öŸ ú4x}óÈÅù5k_Ïh:¡›Ξ?Ǜ܉7Yt³Ñ–²FÉVY’tõô)YÓ5™¢•. Õ½,ëB}Þ6²Y]½rVîkø®U¥xç¤îTEÛ ¿À¸ÖÕš®(3¹"iéCÖÊ;EpЭUÅêüæË`Bñ4šhÛè¶…Ÿ®ÜѲʩQ·n€É¥Pkh‰C*j7Ь,²Zwr­ÝàÑÌq"™©Z©+ë< ³ À-ŽPµjØD¶T)¤äãe¦¬QŒœX¡«¯x»ÕíÆŒ-™= jt5æ¸8¦Ð™lµ©h9´\diÕȹ¬³œ4WµTÅf‹s„:ã[‚ˆ¤îQËg•&ï %Øn|ýœ¸vÜÒ8™sÓD$bJW¦,3NE¦æÓ­÷ØAœÌ0CðášÙ­^£ºÎ‹³S´A¿$U]¹DÝ‘Z §ˆ,*ê8‘BU\ŸFåèSÖr_Étmݵ‚þ¶Š|P ®›¼È…‰7ª¨ÑD|H¡dS‘\Ÿ+d}’»ùøàÓ [«L¯tÆ.<ýPùºlÔ‹ô™H¹8 W'iŠOyôÄç?‹;0‡oE$„+îîs~¿ˆäÔ…\âb¸þ÷'-Î9ì΋ø'^f) Û—!¡QTajPFÓ'Õþš)ŠïæRf™²7Ì¢;ÙhFféß\­dW´/è,ÃÓ³ÿ¾Eç >zá~‰3× #óS§ê Eï+Í9ØZf.‘£¼M]7j¥ï¿Éƶ͉¼ÿüuã•iB²÷T¶ø¼êªÌøã¬MýÙ'½'¾ØMB*æóË~î=–yÏ]ÃüópW¢~øÉ*Œ7ÏçΗ‚߇šƒõt¶ar ®:ĈO4HÝצaÆ\>8‡þ^3ƒ…V9Ztã. r(†T 7'[îšÃ±4"-À²0ÕÚjPñÕ£’1¡+]†ÔŽ0à8Â7¾~TµÐîÓe³ûºõSÑWÎM—ÑOïxÕh4.ìáÊÃþŠB»¿ë-Ú§ôCnL˜A优$åÀ*ñÉÂÇH†< Ðb£èÍû÷vl7x›“Y~÷YPæË- ðËl·Â-ôºÓEîBV„/üZŤt¶“Eñ@¹ãî¶Iù6¼Z]ªa?v^D k¤ÌöØ+=8¿QGÄ÷¡1¥CaÁ´Åâ\Ð5žöK|䳜.ú1;fØd± ¾; :ê|B;èÁâ[—ì°ÌG—ÒÕ ŠCdÃp¡œÔèx¨2vè"ÂÚ<Ü£¾·ÝöˆxkŒzнÚH4„{¶ä&Q-\î–%@/?ÓêêÎð®ƒÁJ Ù+Æ-~V4î­|[ByÜUÆJF»Û"&´KozŒz«‹‚ê[rlÈ ´o¤›°QÏ:ʦ1v¬è=ȃ«§±ª™ËÃð8ÒBy¨”aŽ£™Òl\P—=ü|ë¾3;Z¨»Óß݆íQz S|³/;µ’B(0$§~r_YÛ•lŒ[CkÃÊ>r¢Ä ÂÐmf¤–³<ÐögjÀ£¦ø6´ÊMòwsÙ-ºÞ"9ÈV¸‰œæGj@Bs¾$JNÅHOàm-®ÍN:8½zÊvÚÿåì·SÖ§­Lûh³~{£yN)®@ˆLŠÏÄÄ/P´/Å?-‹^ ÉRZP©W¿Aüó¹ãëgý‚M&3q‘^Ð<âh­Oÿ¼{§bBoLÖí„0;!”·/½,ãY¡]UqûÙ­.&s‘&¿8ëbrÉþ¸ü5ø׉ Õendstream endobj 5682 0 obj<>/XObject<<>>>>>>endobj 5683 0 obj<>stream xVaÚFýί!Uá*ðæ.ôÒ ¥i¸æC”VE*tZìܳwÉîŽß7k/Øw\%"Ž=;ûfÞÌ›ùÚÑF_óߤèü¶è £!^Ìš.ç¿ÐhL‹l¯§SZ¤þûI/Gq4¢O:-si/ÿu.çá[Æ“hûÞb#éï/o©ð†”fF&.ÛI²[™d«LZr°Q¢¤Wþùsâ ª}\ÑA—µýºµ'»ÏÖòQÛ\vû|NQ¦¨:Ëp‚±§=¹“æà6™Z³_V{ØgyNKI"I¤µÙ2—TªTê¶} Š¥°úÖˆ¾ð¥ÉFkËÎEð˱ô©²…ÖFúHR­^9*­ô`,GîÃÇ=‚–e–»Á1JtQ•’6d„I›÷DõcŸm¨N_oöA¦ä4àïôƒ¤Š%ðîYê5¢¬¾þz}Êùô8s`« 8uݨè2–n¤×Å{$Ím„£T¦&sU*p¬U;‘jÅÊ¿ \i¤EÉ ('|¢¼Ó&Õ…ˆê˜›W–¬&ÙÐV¸MŸö› ωPLj(¯q¸Ç.Õ.3ZR¹1;a2Áìw?¿_¼ûçÃýŸïtÜ*³ M¹)Áy«<ûd3” ’tØJdÍz*oB¦§QÌ 1æŽ@ÃÄø_ÚCæPß7£5x ›£ÉxFë$½ëMú×w-¡,½%·^ÖŽã%ˆ)škÝú\Ÿ‰[/ë3“Ó™·“³X®N-µ× ¿•LÆÁŠ` è×R=(½‡£ifþ÷fÔqãævÀ§²m˜Téy®Ù,§™V•èU(Q?ÐÆ4¯µëå‘v›ë¥ÈOµJ¶7b»EµAÕÜ8Šy ÆF4Gê Òç¨/çC:+?=t­,e ¥*w×ã'uwñ¦ø ãOz01R8(tcÆXߘ QuÜW`ƒó^%û{m,Ç“8ˆ`žA¾yXó¸}à!’ji´ušLV·Nžt ´¸Bö’sÆT3tý»T =•a8‡qàG˜>œˆn±¹(dp]Õ@8øí¿G$L…T•<„ Ú¾Ô_ÔRŒ"ù¸Õ¿p=äÒïX ¡9xXKÅ ÇãxáJk’Æ7‡)–bt:?w"/%”W#g]í3ˆ{6`Ãð¼×ežBCz) 7¥Q*Œü”Nè÷ăá_¿äñ †5 ¹Tžã©¦ñ`PK7KF­Œ‘‘/âjÛÊ5<·À$z{‡ÐÒlÄoØ+ß7Ƒգ$Ž­*ÿpáÝó6yòpÌ4aâhŸ·“7¿)¼ØÆµR™ö—ói½Š¦“è*¾Â’ã_¿$0¡ƒ8Òï:)yeñúÉá¢æ+ëÁk^äÒ3«øÕð:ŠÇØÃñõj8åS¿:ÿ¥$²ÿendstream endobj 5684 0 obj<>/XObject<<>>>>>>endobj 5685 0 obj<>stream x­VOãFý?Ÿbt"Ü%Ɖ“Ðé© A¨R»±Ç‰ïì]ßzMˆª~÷ά$>…+jPb¯gdzï½y»_[=pé¯Þˆÿý¤õqÖr—ë/½€Ã‰ G޳ú.ŒŽ{Îhôfraæ·•oÄžôOÁg«hÏ"Ictü'¡‰R³Ï-º= Ú>Œ¼ÆP9ß;…]³ÇƒwEèmñ—w'nÌ2ãÂæ‘/88«Á#XeždœqÓyl~ $ùˆ…5•¾(Ìä¾!´ˆÅ5,Éÿ-‘ć©á¶®©éÀÙáÙ»w›‹33Uή"!ª|ÏRC†I|ßäüŽj­–öÏyfÈŠ}•®ùU,!Ö:y²$Îø¶¬“îQ“Þé{›nŠX“7HKïRÈ‘]äd‰QN ` SJ‡\O“í– 6âF)™JÈf*$ÿ£ Wyx0=»¾º›¿Ã†Ü²ô¹³|ðæR?ÁƒÒqð¦ªÐ ƒ‰…s±Îþ¼»¿:ÿð[ç—kû3»¿¸ãÛ‡‹ó«âjöéþÖMn§üäîÃìþ–.þú¾¿Û–¦®ÞÇ0,ö¼x½Ï˜<¡6„lMJ¨¸å¹Jz|à÷!Û6ÜÆò¶# @Æ/cѶhŒÝF6‡>¯hž!ܪ^î˜BôifµL.BÍ’åiª,0ó5ðÞHË5+.!+êØ!ꨌ]?ÕŠ\6•Ò_7{Òˆ$Y° õo‘$KÈè•´¶Äû‘m“òØ+-Ò”§—½òSH;‹³>/XObject<<>>>>>>endobj 5687 0 obj<>stream xµW]oÛ6}ϯ¸Èæ ŠâØM3¤@—5[€ ÛÐ}Ðe3•H•”l EÿûÎ%%§ö’!+DER—çžsîÍç£1ð3¦éœ³êè绣Q2Âàî]ÒÙÍ9GtW`îü nrÿ7Yôq%5m¬¨k™ÇÔ™–6ª,i!I,JI¡Öá²’T´:k”ÑŽ”&AZ4­%mDG…5ý™5b-º1–äVTu)/OîŽÎnFt‘Lùó“N&ÉtЧ<2~Áåø-¹ZöK~â%˜Æñî¦LÞRqõͤ¤0µÔit¼9ŽZýé8=yrátoï¤¨ÛÆaÙo², mŒ-óã¸xfíùÁÚ¬4N¦Ñ0ýÔS¬i2Ÿ¿æ˜?(½£Ú*Ý(½ôØ­EÙJ2p뱦ëW¯¨éjðö³I5ÎiQÈ÷É2‰¿7‚½@>ƒ,öRRÐUÿŒcã¸_öÞÝ×÷7·¿¿©n,]Ñhûf1ÊòÑhoÚWâÇg!|À80Ï2h|_À)m ¨°’¬t5Ȩ˜¥(WX)nÕÄ„GÎ? ÝñTÓÚL:ΙL‰F怽Ya2¥ÑCë¼ ä7m™‚_Oø˜µ5K+ªô$¡»•r”l§ ÖœmgÈ5Ve î¡™¬Ä—ø{:çñ6CbÓÈI a•fƒ]Âù¿Ÿ284àf%bÿ•\i­±—ÔÓR“UËUC+®ÊSSK]IÝŽÛê\JË|Åç¾ßFò>“ÇVÉm àƒ´–J,§IL™)ÛJÓ¤§ÀàÆÀæ0T4…M$súàÁk±‘Ç’EÓc»O ^{žœ{ý}¼ýÕ«ÌÑuþSëiÑ`ž"äj V”½…Yf¢,Aч —Å‘ ŠØ†î­ô¢x$p”лκ >*0=ð'Ò¥3oºXÅ•Ó1µw¬…ë3ÆÀ,$8å™îéËñn¢4ÄP!€e!t?¹7f‘­v˜ pÛ½X<Æñ‹¿«È9L2óÓ)ȘÝl1ǘ/:J¯Í'F@ìŠK̬̒„DyXËM>o0Øã^¨ÌY+Q‹З¦ÀÇç-!šîs/p~ )ð¦ki»]½ó6Tˆl¿Òý·O é/ö°C¿Ämãn¿|}õô:(1,H†Ð¥lãþÇJ[ïUZs=_êd{5ݾ/ì( uÒ]Íž|9ã—[T‰¤Òé-E WDÓ§g}z‡næ•[ÍE bb •׋"È…m½aïæ–…åè^þèX—!QÆ&/%R/Dl‡ž¨DàÆ)ûÜ*‹ôÀaVbí-f8ŽWúÐ UÏ_0mWåvfà%þMû >E³P©F­ƒä})ñþÇîw#,*8»z +Xø–ƒAïd½A8r-ìÀ‹¡ub)©5pàF'Ô± ëØ7…¾.â4lGÁ„’GsÞ;]%«…´Ð ûJÛê™êÑç¶Ò`“¾Û‹#NÇå$ª)Լĵ’ÍÊäLoë;¥µ°ŠR—Ðý+7z¸O, Qæ\Sòè«w_Ê Û}LPœàS<Û¬zG|JÁu»(Uæõ·k[ =¡j ëÓˆßÞocéÒº¤mÝoÓ“¸Ã•G¾|0õª ôøŽ¤\…ZFž­aÃÈ®/:XC±ÜgÛ¤QÆ#Úžb.„7IO^ùÎt>/XObject<<>>>>>>endobj 5689 0 obj<>stream x­VÛŽÓ0}ïWÌÛfE’æÒf» ì—^¸ˆJ¼TZ9ŽÓÒ8ÄΦâß;IKº-,ˆÞÔÚãñÌ™3gúm⃇OÂH¿èvò|9ñ\÷Õ¦·,Ü–D×¾EW°L•Kj>vñÝî´ñ]ûìrùeâãã^Š{?F¿˜íéí ô~út‚°÷iQR@ –,…¬[xO¹gó¯ Ô†Kíl‘nb|©%ŒñSÿdÃ×lG¶eÎÆñô&Á ”~ü‹•ûAðB­¬Ðž¯.O ñHpêˆogŽÌô-nÊ¥"e+«Dä`úÞ<êR;ÌóAáÅA`0€ÐAhé4î48+«ó€×R¤§íÛ#zhŸÕU\ÒQ0ÐÁ¨¸g•¹»Ô8±J‚Æ·B?Df6ë"eUÞê8_L_O€ä¹ DßM@'gýÔÊÜ¡ñȬ.0 ]vÃ?\Ù°)ÏL¡5!»\¨JÔë 0Ž‹UOŠí(Ö†ç9Ð )ÖW6„vˆ¶såÂùŒÌËIÙI6¯eMò=:÷$¯¬,*ÊÖ…ÓT\±Õå«®t½†l ¦€o£!Z  x™¨ž+‡`Èl†Tô2Þœ ´ÑÈ‚—%aбµÔhš•³"Ø#…P=lǰ“#{{ð÷»¹ºKUÕeëbwaÏŽ»bíg/ÅßG¿P²µôÌF‹ƒV£(ätqIlBÜ»Jþ“ëktí¶ñ8ˆpÐ>2ßCØF9“Ìå ²G3ìhª¥ ͆¡x2’kÖ4ØÐT©“öýÒKìš)TS¤XÂ6äžwÍý§‡ŒÄF¿ú™u&§®’Ç¥7m(U…°y»k’%Iâ\œ¤ÎÀóTøÛ«¦·‹¾aüÅ̇sˆÞ0Ê?}~ûÚ ]^ Zo6®J:BD»³v®º¿!Î7‚O¦ê ;MÏ<œ>@s”Qfú}îEnàßäõÜ÷µ£WËÉÇÉO °‰pendstream endobj 5690 0 obj<>/XObject<<>>>>>>endobj 5691 0 obj<>stream x•WßoÛ6~Ï_q/ÄQý#qÓ)në°§bˆ¾(‰¶ØP¢FRqÜ¢ÿû¾#%ÕršnMSǦÈãwwß}wþçdFSü›ÑbÉ¿yuònu2M§X^ì–^¾ŸÒUº Õ†æSZ¾ž¥Ëå+Za×”VyòõtõédJçx¼*“{ñ ß\¼¥,uÒ¯“ùd¶>ýµÛ3;ÜsÉ{'xÙ‹ÚÑ5Ñü{‹³ÑbwÙò- 6$~ÖÐË÷Ä6ýù|Ñ9—ü.YªÞ’©É—’Ì®–Ö•ª!8åà b4¡h$q;µ½³r—{ÛÉ„”§Jì)ZÓoggTHçm›{cíJYcƒ#”VÖ¹¤Ü´µ§­‘޼¡ÏÒš”n¥d$½ÿs¶“¹W@ˆßJVÆîqK-¶²’8žImv´1·y¡´K#¬×4Ãá r>_²•Å<]¤¯.U—Ò*/bìo¾H/xû-¼×’D]PÕj¯|88GÂJÚ´ZïɵMc¬—EJ+Ä0Zü¯`‘ß7ˆ€°V±ûüAÕð¢ÁU¡ ²²S¾‚}m²OˆÃ(0Qµ—–ã^]8 ÜÈPnjDTãô2^ʵpŽJ%­°y¹Oé#gF 9u!CÎ< 0Ö‰ks@p A%}i ìz0yxº>1yÞZ7 y‹4ÉNè{Ypv7°ÎF„‡=Ù†ý ‚ïá’>¾ .›M`K&œ ~IÒÆÜ· ›…/5b——°mƒŽ4ròÁœï3õ‡¹ŠÑ~VQà†M[þ¹xIÏ÷®|øÎæ@¨Zø_âEÃ"\l7,U¦hutQx87! ÇÈt&C­hs²HŒçÖI‹l!óœÿZèQ&jQI·>w *”kBØ{GئÐά”o)Úb†ÈÇhïåƒr*åÙVäõS3Nj0’K["öf„&¨Á:Q’z¿>%ÎhÑ N.r@ì¶åjF¦Ç™L¸2çü~ü$”L%x‚BlÙXYÐûÏpƒCØE¨åœÚÖ#€•¹,X‘ù¡¼ Wë"„‹þ¯Æ¼Ž Eå?` +¤év ùæúCzˆ¦tFUJ Ë~>¡ÎÏÉNgY ‘|EezfŠßŽbÓãsÐY¿“QÂ¥æ\"k8‘pŒ¸,Á`Hˆc…»½ó²",G𣆥˜S½ìôW°Û!ë½I55þ‡&3Ô3S4ì¯ ”ðÓ噂çbà³ —“5­€Y‚áB*¡µH8ë\•áÍP,">ºUð>Šð„Ðn˜n´Õ&zØ<ŠÝ®4.TÊ¡=Y˜€œXS‹1hùÁ«uÒ!ÉZ¾çS‹x2]:þlKÔvP°À%–¹÷X–¢BBÞEŒ)˜„äŵ¡MeOö ·ÿú“„UR4ëC˜{&On8{r>“¹ =Ù™Þ݉¢X'Ylßf“$ÊÌ.ˆ”­“ù ·ÄZ±w¬£cü¸0!h#d“ÛáN1¹¡ÞÏ%…D ãÅ1ª`æ80m´`É~B/Я ˆäàZGýacôÌŒÀþ„‰BpÈ“ø.˜5B¶Õ!Š\¼;èè ,æ'ôOט8ÂÅÔ Š)½ELÀjpáaaᾺ3ö>ÃÆhŒNXe#úÉèp,>Ÿc„Z`H.’ªÖË/ýÙ0ñÆinŽ–‰Ûx¤[9ž‰nÐðì.>/XObject<<>>>>>>endobj 5693 0 obj<>stream xVMsÓ0½çWl-iƒ'nÓH”–áÄ0d†¦ÕV-¹’Ý”¡ðÛYÉvâZv`H2™IÞ¾Õ[¯öI÷½xø?ÑŸ0é½™÷<×Ã?7_r ÃkÎ\æ {09¹“É)Ì#åÁ<ìßÞÞIÒ[¢–ÈO"—êLA®Ôáü[Ïg„a†¥DRæE‚¾Ž ÛBÊLUHk.•É"À’r*IFàŸŒ/AÒ´‘–‹¬ŠÞ# ,Oã\èÀÂÆKÐib™$\¥BQâ¾h$]Q™°Œ,—41ÆÃJ; ĈnAÇi€$Šª2 ஫ün ;œäñ>²àˆ=lá¡§b½…o,8ÞÒ «[M  u÷_×¾›•ÈzôlfgÛ´ÊlP¤k&б;åk85 [9é}‰9§S _ÖSÍZðº&[2¯Ó÷l:o«píö ^=bÄíþ ^µq»AˆW=B¼¥C@x±¿Xå#,ÊmKà©€‡×Ç ‡{zƒ3öKoèà­(\ XD_š_]<Î !iŠcªíˆ‚…ˆc±Vº-ÏÝÆ]ßGï‰úûh$¡ÚNApXöêèâB¤zú…¼Ò 6vó„ þ BÁUÖIÅ9lètrc3§V‘³Sà.Ò_âFkxÔ)w^aØIHDkö; ±™xëÔöþ3Ø÷endstream endobj 5694 0 obj<>/XObject<<>>>>>>endobj 5695 0 obj<>stream x–moÛ6ÇßûSºyPjYѓԳ tÝRìÕ0ÔÀ0À€AK”ÅN5‘ÊŠ}÷IIU'+ø¼;Ýÿ¿£ÿàã_ÑRý'åä—ÝÄ÷|\^š\ßÅø°ËÐvù?¤z?$Îß¼…„TÐ L‚äÒŒUDMF 8ÒœÜ3Þ¸P°(d¼úHʺ Æ’U'ø#‘䞯iC$oT\BIꚦ*â‡Ùì¼çFÐÏ@Ï«Ýç‰ó Äœœ„6’°ªVÒ$'¥Ñ&99Ì•?ÓDBݰJ îÎ)¹ sª‚^ßa[º’»ð\'y¸'EKW«/L„Ä'×¼™ WýÏ„è»æ@ÖV‰d¼@ o¥©Œ m*©Ìy ö³ƒzÆ8˜Ì‰Ô=?êT‡úMãS`•`)U…N飤UêõQo½Hbˆ.aèE~KÎÞÃe§Â©#vLY SØ;û«Ñ6€1ÀWJJXÓÏ–?àÚzý£ E6ßê¾-*Û¦Ò†R±Mt'‡”F}ëB"o¹¼Q ïrZañýùsá‰Já¾Z½9ÕU°²y¿wâqÝ~ˆûVu6[+e´5ÂÊöΛ©Øï«7.½èã#¼¡ÛVhm}÷”Ð3<\Ö¿)Ä;u“Éjþ”U…h6ÃÃצ™xp )H³µ|?zʶØ+ Í7âØ‚Ž òöhˆøÀT“¢Eö×B¦‡„«)ûè1;§á¨öŽJéJ%¦ìW«ÎaòöXÐ-|‡_gj«mÄ¥ÒjDߨ¸†—¢¯ËLݸØöWVo NÓ Öê™Wãæ….ˆ\^ú—ÜbíÍbæþ,d—#„!Ì ^2SIOÛ¨þO¬d¨ŒâÉíÀëYyQ·š,uW*ùª ²Óåë£lúÿBþuX2#þ]&~8ûš[Á¼ÈL×Ñ–cÊž$F$@2e‰¦{@pn•ÏH;ˆ*_ÀE¡X³ê<~’¦–Û%,UôÙæðM**H‡ì[™³ ûÝÝuÛý¬nco-`yë{7æ"þô×ïç‘çï>/XObject<<>>>>>>endobj 5697 0 obj<>stream xVmkÛHþî_1Zb+–e;iš„¦×¦ôSïˆá8˜µ´Š·H»¾Ý•SSúß;³»²#Å¥MB°V³óò<ÏÌøÿAcüM Ó_^Þ/ãxŒ‡ûúÎïÇp§°(a2†ù›$žÏ/`Q8«1,òðÇØâêÊX-ä#,—ø!‹²SÈ•4¾Ÿ.¾Æ0JкpÖ{4欣ûö˜%ž__›c¯4·–îfB¾4ûÑóù£kÒ}ýÊòzS1˳È4õ2WøÄ¿a%øtíj G×…jV¿…Û®»žoî‡+îÂùýFˆêh’T#& °k.¡1¼€R«¾ä–m9•Ñåb4™ÄiŠÌ‘r&W“[`7Ï&g©ÈN»9ãcVY4ÉN; 1ià&œ`vè?‹¦Ã´gÜL÷nÒ3 õ[Gé·:¿ÉäÁ¬… Ųb|ó×Ù<ÔL[ø[ i¹6ƒ9ÂmO)?25ÎtLieSU;än³QÚ"œÌ€ _ µ*šŠ›ØûlS!Ÿsòè“HáƒÐ<·JÈ¢œU Üâɡȹ*x[ӑ䎃0.6(•†‡?:DÂÓZäkØp] kÚ0ä¬Â‹«¼bÆ8\Ü'n†@z¤ÒšKKʶBÛ†U-ˆqÕÜ®UáËuÀÑa(d¸H…+µ“ Z}ÅêAiÞÀVšÕ5¢0„µzâ[Dƒ‚G§‰ÓtdžÄãRó²KXv·áäd+ n°qkªDN`)†ÿTÓÉÖÄ*«Œ‚÷£î¹Â•D]P‹"ÝÔ`$Ã5²á°S ¬q$¢ø±Ÿq0 48¼5ºÚµIEÿ•ØÄ¼·•|gÝõN78ãE~Eþæv…ö‚@½›´÷Øç#ƒz›Œ"ÓáE–É“>üÝuÔÛU[% w{‰è@wݽ†Tï¥édã%ñ’Á^œ.;½•„óK>ßDâÏ°Ãæwk •þþ5éö`«÷;z¾;€øKýïÛò`äÝ©8ì#l†gÐûÃ?Å?¸@ùsYxL.ÃHK.§ñ,Áü2‰¿ti&ŒÒx TÞÐøe4<èè­G^4~›$^Ìá+†Ûf³ñ>/XObject<<>>>>>>endobj 5699 0 obj<>stream xµWk‹ÛFý¾¿âRö[ëÇÚÙlHȦɖ|hK‰! f,ìI¤E3ÚÒßÞsg$Ùr¼%-”]ŒwîóÜsFŸÎÆ4Âߘ¦sþó³W‹³Q4—íK¹¡‹Û]ESZ¤4Ñüé8šÏŸÐ"ñV#ZÄ};q'¯g/(Y¶Ú™ª\åÒmM²ì¿Zö—çËógç‹g#Žq © ­J$•¦rJKT&lvq{Il—Ò‡“i°oJÊM S£cee¶óÃü†“I4"Û&Êõø½zþ’Ó [­ãLX»ìßðçA/ßÕ‰ö°€ËVE©´K—ýŸB]§Ò\.õO•u=ù¿ûð›q’ÜV8B«i‹Þ“3$µXg’UÊØ™ÒÒ°’ô(•ÂUè[øIÁœk•dð+·4©2i)E{ÝVÙåyÔ´5LgpÉ Ý·oyÞTŸîU–‘ˆcY8zGºÊ×pnRúùñcZ ‹Bvýÿ“ßžLȬ? "; £c(ÂaT›A˜ÓêNd•ü>³B¨‡…®ÁÄ{p1'\VZéØ)£W[Ø G¥EôVû>¦ðã€S+üÙJhª¥&a}äá%í3RጕkR‚‘9*Ê%7Çb Rù܉Rñô|ì61ô«É $²:A½d4Ýo±_è/^hƒ‰jòÕ“²$ÚC€„íkÒÁ|˃lB­½…[ƒ²8Ixâ>´¹„2ÓÒä1›ìê@½‰6Ñ¿ZJkr‰Á•Ï'§Ö³ùµ7hÞ ^úwxÐÚÃiÅŸz>,§ëf¿Í‰YYW¥Øg^ØîløåOlS,0ÌÌLÔª&mô\·ªãé q"u˜f HV±#§rÑ#âN ¸§(Léüš5N­NÅ>×Ðð+ˆjÂâµ~2•+:“Ÿ‹LÅÊe;*eŠ€ G€¤]»ˆÞ™AùYäXB¬Í`|ÏdZe‰'‘ЛÿL¦/[2=M÷Ì‹-`ö¶5ë6M8Їëé "bRŽn¢ƒ¸¿dëæîS‚Ä †;•Êü‡9=>¥'\>dvqû”˜—õ›5ê7…°Ecñ¶”"9b)•ȳ4ÀB¶Ôë‚)ÿ¾Eä¼®ås‡øzhºN2QD2b²¤ß½¨‡,c&—šá ògáñåÙŽò ´¸>Tð–5Z¾ÞÖ¤(%^{¶N/¢½1³©v±G˾(Dé8âŧJV’EJfÀ+DOÞÉdÔ3™bÓŒ'$T\FôtŠû+÷Øô=ð|ðÎäÍ4™›J;$ÎûÍ åye­öµ%%k&SmÐÊ(Š(S±?¬™õJù¦™‹¯¾?…ˆ?ŠM­Ô|3ê2j•›¹…qÛƒØq¼fWj5nPÁ“ž³l<ÌèW‰KÑŽr¡Œ[ÆEïïPȸa"bú¨·?6zØ·÷j³…tÏ÷Á*˜˜…cÖ–†bxm€´+ùŸ”ãQì —‹ù*äo'-DY=ƒ<UÓI[Cåé‹, ªàmjòð×£<ü@ß/ǃ‘ic -ôÑê<ùß`,ŒæŠ~¤tÆ7é¯MžKÃŽÞ}[TkˆÆuÇ’ÈߊéëžEoxj¡˜S¸õ>£oGÇþ:q®éþƒÇ¾uØûÜ£öH™ß{‘*J\Uc^(ìïZââ«Ð[ÀН¦û´ròi@<÷ùvãw+ }¾ªoŠã«Ëh6ÑüjóŻ÷oN£½6qÕ2#CæÁzø$\EžN[æåk³^ rO“,ØLÊá’2Í£égØôÙxΞß,Îþ8ûO…H#endstream endobj 5700 0 obj<>/XObject<<>>>>>>endobj 5701 0 obj<>stream x}TaoÛ6ýî_q_†É«¥H–í¸`k—­@‹b¨±~Ðe±“H¤¬z¿~ï(9i†¡Hbäñî½wïîïEF)~2Êwü[v‹_‹4IqøøaOtsŸÒ>ÉéPÓ:¥ÝË,ÙínéP…¨”edJ/ÎòÇõ_‰Ÿ–‡Ï‹”â WÕõ*¿£²•ÂÒÿ_oøåæùËŸ©’ÎÛ¡ôJŸ8çÍý†8iM1pÄë|ÆIßi9šãgYzª”Å—:KêÄ…Ž’'+ò†J£½5-ùF9œ7⬌¥½QÚKëÈJ?XðÚšŽêA#‘Ñ.™9­7Ìé­F I¥p’ÆFZIFã?åéB:¾}ýâ9UI.lFMBÓŒÏ7ÂÓ(•V ZJÓ‡  ‘t½,•hÛ z˜ßô²X®B¥Rè«ÆkÆ~ÐÃC¥jQ±¤NúÆÚJŸ¥õëÖœT™ÓÔJÏÒ†§s}+kÐÑ%È™A{:†ÿ´ôÚ–´¼Üs Ï&\+:þ¢9æš}&RhUâ_ŽƒRs˜ªIyrž Ê/Êy]„® 8N®¦0è–©É@kÄ>¢޵|쩟ê†Ö«¾•ˆÁåxÞp|2Vä†cÙ çXÂéêê¹è{°)–Á 7÷/)ƒô5¦'^ï¸ù:É“lGïÈ }olPäɳ¹I‚þV™Á…ØV­°ªU ô^ê­9Ã7° ?ZÑ÷,#çeÿ ¥áÓo£¸¥÷Â[õ…ü¥—èÝs&_!™Û>—D}²ªlÈIÏÚ%fKW]ŽQùs…ô¥t ½,üâáVîƒ ´TëcîÅŒ€mÄ)¦÷p¦“×™b!«èw3JØtÅy`gÂÊVð#9'Ô©ñ¬É(ì¤ l ±¨àóFvN¶gÀ-"''sU¦„IžP }ô Ìà©@t4ö/6×3Ÿ8ð„Kfè€]¶qLN\V´%ˆ€,ŽÁlÏn Ë£n#) <š¡­xýôÆ9u䌆°s@îq±\Ý÷´^ã5Œ”cÙVQe~Õ]*é‹Ýw˜¾pø·`…²Ô…O],Ãò|²ÛVdØ9Øz¢DÛx†ý6·_¸Õ7˜i½gwX,Ʊˆ6År® KMë^hG¯(N“lŸï÷SÖý<\Ù~“ló-åù6É&Š?½ý-Γ”Þ˜rè`$4Ü„åüSt|;ežlKïeg0/Ðâ$ù Ù¦»$_c!Û6»å£_‹?ÿ:5(endstream endobj 5702 0 obj<>/XObject<<>>>>/Annots 2855 0 R>>endobj 5703 0 obj<>stream x½YËrÛH¼ë+úè‡8xƒ)À ŽÜ(èHí6±¬g±í ƒ•^êY«'W*À+9¶âH±,'8Ö. ·ùˆ%‚œ‡âÅt&óܱˆ¤mòŽbhU¬ÂК±GzV’/–îÜ ‘ÀuÄ‘p bQ©^/¨1XTuª–µ*³±ÙÐ ±Ù§‡D¿ã„Ã'IZÁq ™³aÄÈ)AôöD‘ÓžÝÜ‹j G/¬u KXâqRÊYˆµBç3”º1Jc*e?V¬ÂTÊãdzVé8‚-$bnNR‚±Û‘Vp“‚j0öƒÂ´Hìu¬•!­†^ì&©S)a‰Æ#¡Òñ‡ S¬ªHžŒÑxì‡!“Ú"Jj QIbÅ*Ì­pRQ¬Â`s6yÅ* é¾Ð¬ÂdÙ•¬Â<>räŠg5æñq\±âàŸ,péºp· BiÄÉØ“VPŽrèXÕì ƒEk 5«0XL² s7 üÊV­ÉTË,ŒÜ­1XäÀ«0X$àe†Zl.v¬U‹¤¢Â&A’ caÔ9D=«0ØŒG¿b‹¼C켬Â`Qe0Ù³ 3²¬ÏZ“§ÃÇ,Êï¡ÂXXŠÇ³Ð€ˆÀÜmÊ£ÏnVA$ O>ÏY•Óù±¹px±RÈp<ßÙ‡rlwê¢ÃˆfšU, )Õ¬Â`ç¼ýù•­Úq:–Á3Κ¤ —å•Å“VpœP sÄŽçàX„ Ý„HZÁqª,tC…‚d{Ò ÊRZKG»ošdèæ°mIJXib1vÁAžU ËЭX…Áb€ƒûœ¬¤oÔLä*<ä†!ˆˆB©#5‹îjVa°¨3-k•ŽS®ÂØš:DþåHyÏ)ˆEñd¤Hñ®Vø@€-`i “Ïq"6Ž"aÀ”v£ˆ‚‹)æ8Ç 1¸fû`9H1&ç<ä˜užóÐöE\¿§5EÝ8„°c\Ÿ’\A.)Wʉ±qŒàµ•3®K)!†papvœ‡àÎç!8ÜÓr/'êd,…ÞÓœ=†!øíF½,’7FýùõíKà‰›5Þ+e§òÈܬäR`n–¯âØ|þëý;S´+ó±ìëô_7«u䥓¬Ã,á*x-u‰f’¤ÖyõákÙ­ÊûC)¯=dâQì’Ù‹o«Wÿ²Ü>ÿ£>}ÒÔWû²®šª-úªÜQŽXê]9 U{g†Miúên3˜MY¬ÊÞ¬«Ú>+–øÙ‰· ñ âɪ4ø©UöùQùU×l«šê ³zh‹¦Zš¦[íëòps9ãYŠÛWõê1½æ¾6æâKÉýË™±Š»G.쪮5ÝZRéÌúÿÜM¡¯ÛpcŸØà¶ïnë²ÙIÕ,]ˆû¯^¿>óÆ}â­»/x/o«Álëbl¤B|›|—¸p¹™'O«Ð…4—l æúÛP¶ÌƒÙ·,Æ¿ªvÕÝWºŸömËøIóY÷]c~/¿–u·…Àça¿ªº3{ѦO‡ÖÑBdïi:GçEOtúÚÛ zWÝÝ_Öܾ©Ú¡ì×ÅRzˆoto÷í’™w¢>~ì´=í]ÝݵùŠ^[ ÃÏ­î ;Šv8·žøõÜj>ý~9ìûóûíõk³¬‹Ýî%5I³¶åårS.¿ xO«–£“Ôt8Sêgúʬ_¨> Cwj38z{Ȭ`Ïm±üRÜͱÿàåçÓº7&g ¼o·ûA¢Ûí~Ý}Ñ”hDGÌÉcÝõ·e¹•ÓtƒÙ“sÔÏÓédeŸÊ¦ØnyÞ¬ Ì*Hâ–ø”lÔ·Û7fW5Ûº4#mÊoñÏ-|Ö`'ó÷¤óß?KÙÝù‹õú?wåz_?·ŠÇTOæOËôL*cÚòµæwAÇa„f#÷‰Â^…LÑ÷Ń:LøËMÑ›_~9s|*q|´ˆI½?µÝ¬.Ö„Ugd +ú»}SžÿH~³\–;™à­“wÓÙiš²¹=ªõ*|¸ý»\æÃ} ]›j{æÿw¹0ÎX­çîò6º/u}xßâ6Ua¢·÷—3¦ †§jýÀæ»ÜÇ‘ÃY6ÝêDŽ5tÚøÍʾÁN4¸AI[Yv«#F†“‡š«¾C‘ÔE{·Ç숖U?4]¿ÝT»†)ìëøºÅeN†ŸªG¦Ÿ´ý}Ô£ÛÊ“ÁU®bm9¯Pf¼Ž!g.h?ÉîÛ¾«eëãÞE?¹¦ó­+ßtÚ^‰,3·¸$ gÞç8>=¯À¾;¤~}ë^ã& ¼ØÅ/¢LÞ¤<új:Åo3qm‘y. çÜòõÍÅ.þ`3)eendstream endobj 5704 0 obj<>/XObject<<>>>>>>endobj 5705 0 obj<>stream x•WÛnÛF}÷WLÝV‰ºYŠœ ‰§‚&m\¤Š¹”6^rÙÝ¥dµè¿÷Ì.)‹¾$(b4¹—3gΜÿu4¦þi:矴8zsu4JFx¹ÿÏ®hx1£ñˆ®r¬Ÿá! ßñöÎEí•)_ÒÕZ9J×¢òÒë2Õ•Pö‡çW_†§ûS“SœÒëìɤK­ZJGŸ¿\¾?qäêª2Ö“Éé“´z–Ðkíצ^­É¯e|G…Éj-ùBSJ^ÊŸ¤°ZIçÃIÍ×'åi-Ò”^•µÌÕˆã cñ†äÆè$QfaÝRÊ’TQY³‘­¬^ïh«|¼-uÅ2Zª´.¡ cDừµ÷Ÿ•©) Z2¬ ¸¥ä½](á ™fÉ‚p¤ 5¡/òÄJ* iS®@®Ç-ª\áäU­rÎhf~@H ®_Ö>…Óæä¤,!ØÂ¸ޱ7}Ú®H ;¤´‡PfÊŸÄ4žÑø4AþXƒÉ‚³ÞtšŒé#Öo”Ü>’îd±7€£tÉ[/KFy—£–MGaï¤[¢BDº†| W›-¬åFê>9äè±&•Ym…¦­ÅÄO|­d)-ìrœƒÖ¼.S/8JµpNâ¡X†V˜,e_q¯$Uª¬ÀjÖ(_–}â·uêk$>lß*J2ï¶Ôh-õO‡ìqDq»káPŠPÈ>¾ÞXN/2ÈÂTô öX7ã³üŠó±LÉQG¦m.Ò×¶î î:hbšê Éá’åƒÀ7 ´G5ëc-_– *T0K’·„xö«ûxwàK¹R s‰XQ^¶Ý#‘T§Ð\LÊ:ÏÛÚ¥–—ª7W+DÊ|"q¦¨”Æö±N8ß Íß"”hH¡£L¹´ÆUYB¿@„ñ’»¤´ÇÏÛ*d6ÊàL½ësˆdÁµF–…zÙÌël#J(”p³7…ú;D@9l… »J¢êh/Ê& 97ðT*an8Iëwí~§>'ôÉJ­ ‡6suÏ“ï©ÄÍšêì“­ËÖîÚ„ÅSÐCÐ rê Pvº{r¯Ñ>ÁzsˆßlÝËv×"™ò¶ É$™Nñ[Ös[µ¢pÉ[Áµ¨î‘ÞÇ™Ï_Saa!Y¢òüք„‚P™x„ŠÂ‹>µ×6`›Óÿd»HÒî=š¬Qä¹%úoQq¥”ÁÅ[3ëòïu°ûòžçÀ.ž‘TÅ“šF¸ò= ˆœYß¡F·Ùä«•_Ók[°w ú´35âãˆØSb9Ép »Ûÿ£Œ=õvÃvß'¡íÐÃq—å,­¬(Þûȼé"ô‘÷Ò‡ÆÆP­Z­Ñ·¥`×cH 7ô XÐÞ›@úQ¯ûFãšHYA‹-©³ÎßèªLu ¿C³e²>æÜq¥£ ²ÞÝwÎËÓ_ÿøüû›æë]!mO´ Ë } ö Röä9å~ÆÍ@ÀÊ0XxcñZÝpâTCЈ­®aíìP«å± gÉøtxþñ·w]ñ=yì˜/±ÛWž0šfÁyö–RD€to0ü@!ÜÜZ½5¥ˆšý½ ÓZäÉÊlÙmµ\±÷¡oÑŸ£Xïh€4qKÀ,è0‰CÚïÃü*ÜMÓ¤¼“:ÿvÒŸFI'Øè<´¡W4:?‹¿ÿ#lº¹ÿ^_—ǯNZÜA‰œcœ E9ÇŒM ö6I&¸§éoœê]) •6åÝÍ;h˜Êxªæ†)si‡'8ôtV<óroöâþ†%mBŽÈ­ÑÔ@w+‚)`ÔyûáÆ1çj´“UHÔZ`vfkj£Ùb‡iÍ%XÎ º ±dpv eßDZ׿oÉßð«CsÁ@͘IC‚Úº ëž[›mɳZäü9p{ýü{xª1í ÿ­Ò”ù§Ëó}ë A<ºb¶‹šDƒË‡" ÕIƒ·KcôOhôùðbÑtÜñâ4™Mg4_@9g¡ò=˜&#zkÒpø0hpÀX\=xêÁÔ>Í“éƒ=ll6>ãMﮎ~=úÀhendstream endobj 5706 0 obj<>/XObject<<>>>>/Annots 2858 0 R>>endobj 5707 0 obj<>stream xWkoÛFüî_±HX$Z/+ŽÛ¨S;p;i¬Â(ê"9‘'é"’ÇÞ­(Eÿ{gïHêa;M†H‘{»³³3ë¿÷zÔÅß Fü/ÎöºQwøG|x³7ìw£c Q—2GÑ ºJézoóßŽŽ›gùÛÓñF@ÕÌèð¼KÇ2žR¿K£—½h4zAãÄÛ¥qÜÚ§YSÇÎ…‘ É/"+RéúÓÇ¥.;ÍÈêçãÏ{‡çCê!”:ˆÜéªÈ­ñ\ò˱£Xg…J¥!]8¥sKw¬hjtFE*ÜT›Œœn>Gt}sñ†œQÒòýY)-> œQ³¹k¢,ç2'åHYR¹u"MeŽ5!e›³CF½>êl­tI™XÑR䎃âyãh©Üœt.IOýUÙÐ_‡Ñ_`‹ó:< ÐØÃBšôh‚%ÊÈØi³Šè‚c G‰–6?ÀaÚ,Úĉ,UšR.³ó6Y)p•f"ïbP ¿cÖ(Š<¡Tå ÊèHÔÓ`cq…Z* #úƒËö¨‰ÔjŠç2^4•íð4ñÒZ(^ÃËšF-Ng W‘$Š›*R`Æ|UÏô‡Œý 7Š3Vù,T§“2•mÿ9YE>=ù i ÎPVZ4\<ßx“üK¥€U£Ôà´TiÂMu\ªbùÁ¸ Éÿ}Ç×sÎQ†‘ïì…Ÿ>O­B[«&è8 ”é=¦ƒ?OøŒ:š™½[‡Æð'-®éì‹ûùØ““&Á¶ºáÄê·­­ï¨úóéêç˳¾øé}ª¨bÜû󔮪Ù(D¼€<îíÅéuîÏO4;øë`Dëp1f Ú›ª‰,²Ç}wúëÙë1"o¤yÏðõSz·ž×íX·Ï=ß=gZæ1¯˜ ìS*ÇÆ!Rõ‡ú5˜{ûÍ. Ûn[#º™CÚÙÐ1ŽXù fù²~†Qæ„k̘D•ïxļ”Oî¶·³ïmä[ƒ7—g*Ç~$éÙ?uFþ6føü’íòrõ‹³bëÜvê1ð—°ý¸Û>UÒËÅ…þ­"‡é"°aM#=—káØÊ zîÐÌCîS¤^ñ’o ±³ì_Àã[锈YêReç"è‘)ƒ’ú)û^$÷é‘è¤ëÌêM.ªæã¸ÚôzÇÃèhpD£GQ/ø¾—lþ5ë—™ÌyŠuΕ¡5áé΋¡_šúôÚk5×´»5ñ[G]ü®ÖǦ…•á¨ßå[gã½ßöþ^¿Akendstream endobj 5708 0 obj<>/XObject<<>>>>>>endobj 5709 0 obj<>stream xÅWkoÛ6ýž_qQlˆƒÚòÛm³/kÒ¦ ÐuÝ–a`  )ÚfC‰.IÕõ~ýÎ%%ÛrÚ6, bYº$ïãœs¯>œ i€ß!gü'‹³«»³A6ÀÍý?·¢þÍ„†º[Âvö y|Ž Ù¹[+º¸{Ö¿Á>Ѧ³QÎB—™NšÅZj£H—^¹àé-ÌÎýéb^8ïÌ/,­J´-±âYÉ+É áT~TŽ1ȵ}Ë0Â&¶Z>w@°E¢×¶BiÀ¦eMw|Ó¹*#¯Ïqç­ëTÂëþõãÇü7ñFb‹„­½ê—²ù ÈDR³a£¨©ŽW/_ݾ¡¥@oÏ{=ä{£ º0’.Ö¡×>Xz˜'NÊuǺ’J… a ‹f*rÓv­ÊX h.Zê1Êœìâ=úC/˜ËÒ)nò€¦ò\ L`ì÷`K¿QR/5ïEi`Ń͸ö“Í·Ÿ#a§nOV“˜Ôjž ývÌ9…”¨¼‹Þ•3zµ`&ZîR9Píó×™ôà-5äùÂÚð®fÐ9ù]±°†˜õ›&â÷-)u†£ò6Yˆþ³êîG1È},qÓ2ŽèsT1ŽÈô»}kàxØ vûù§ÖÉŒ"–dÝOšbak@AÚ'p,Tتa©Ê $"Í:½Ò<ý`Ð[9Ám ÞŠS:ŽÄpT³ž5ÜÔZÝòÅ)¼P9÷¶eèF»z*zZ¿RŽ“l:žÒl:KÓs¾7ÎôÂÊŠ‡•È>%Ùöž¤ö© ]ñÐÏ9ƒïl-O‡U^<̲ñC°éhÈ·^Þý|ö-ÑÆ×endstream endobj 5710 0 obj<>/XObject<<>>>>>>endobj 5711 0 obj<>stream x½WïoÛ6ýž¿â>t¨‡Frl'nša·é‚m×dè(‰²YK¢JJqÜ¿~ïHQ¶Ü,m1`I8y¼ïÞ=~ÞѾG4™òORì^íÄxØý2sžÒ耮2¬>ÇԽLJdp© Y«BZjJ#­ÎoeJv]ÜèÜ’N’ÆÐLDc% ZQUÒÐBX<•%%FŠ2mð:kʤVº¤z!jJµ´åãšDR7"Ï×$ï”­I•X™«#Ì:þùêÓÞE£1|\-¼°~±;ÚÒjS-¤Hqn¦r IÞ¤pXP*“\áμυü,å-vvN¨¢Êe!KöN«š°¨ç†‘…æ$dFWi¥ê…njjª–s)·ýŠéJÃÁ;Ó\6É»†g€+ñà'5/µq¶6…PªŒDun±G“_âvoéTÖ5¼]ËzßêOØN¿Õ؆òªºçm¨öBàÄÝ”©ÌT‰<ŠG‡C59žFLs7|¹.ÅÜ“&® ‘¤ÑôY`”…Ë+Qû®Ýé«×ço(œ÷(òðt#n´aÙÚlz—Ÿ?îQ±õ»_ÝL8úó¥Bµç²”Æqk _nõÁ*aW—èSäÐ%?ÁÂûÕ¥»p«˜>0¿ö°¤˜Yt%•é>› )q,m×¶–b Ç꺵' ™,–™\‘­E™ “ÂC[_<àÖûÑQU¨Ü®{ØÿR̹Ô;÷Ü3‘ <×z ®í¹ßòFðÌŇh9bË“BäÌ#åÜv4›ê˜Î”± ÄÀ¼`RߌÿÂVŽ£ÀaFP%@WªÄt*\.:¸džËmsìØî‚!Û“2Õþßœ6<QKž“®ÿ¢¿ZÄEÆô?zfäyÔZ‰6f~”&_ä˜F%òv+yN„ôÛ–ávÐtñòãÅùéûïÿþøîÅÕo;!YÞ*£Kžýt+Œ7˜+< ½žpý³áWBG»ÝÓyÖƒÜq‚à‡ÜÙ‡€"±bܹqŒpÁ7Pem0``L•Hç9È뻀 ˆZ’Ä{Bµå*ô¢;ŽSišÒ5§êÄ52«¨w Ñí²ÈÕÂDúðÀxÄù¦’üún˜¼û%ÛáÇN.xMŠN,˜/Ü|øšbò4Ñe¦æ}Óº¸^»þ™UàNå“%Ÿ®¡”¡5•ÅäB¤ þ¢ôʰRŒ'î ˯WËL4y_%µäé]jÀï,q®®èF~n Ñ,¹(’DZ0*"ãxW …-%¬Ctã/ÆÇ™s §¯ ÏžkiúÑxÊ£m2‰Çñ”fޝüy3€~á{"c•à?{ò¤Ÿ)6t;½¶mCg„¥à®V§Yw'á…”`(¸‚€ÜPÉrMí©1]¢áü´b 1¼¥©ŒdÝ è¯Œ‚eÔÓ̃0D]‹åÎ$ªeå²]à êVbŸ`g1œÖ°‚ ‰\}áIT:ì{Qâ§œomXçÝÄkÔ·¬@qk)D‚© !ì{a·òwƒ<åžvD™B]qN¹H¼¡=Æ`’lÿ[ dWjNQ‚íGE¬¸B5CÓòŠìÝù ‹»EÉÝÝw,óŠk):Ãø~5{ûþÕŽA”nZ œ-[!Ø)âN[wO¾©‘Áfm‡ù– תB¬»VäV¢!øné´â|ÑÓfÙ+À>©Ìu³ð¦`— °çû€³ìu( slK:c´Œ:ZÀ¥ÏþàˆÏS'z¢|æõÃõ€ÙwÞ`¾3Àá÷ ZñAPܳê?a‚íýZîÝ h;=Çívt|MŽh:=ŒŸú«ߣ£I|@/uÒðLwÜÆYÅØð«£§^‰; <¢?»ŽôÀk¦ñd ¶SÇüèÕÕÞ{ÿb´u«endstream endobj 5712 0 obj<>/XObject<<>>>>/Annots 2861 0 R>>endobj 5713 0 obj<>stream xXkoÛFýî_1hXEDêeËÎv[ÀqìÄ@¹¶ƒýb@‘Cij’£!- ‹ýï{î!%ªM]lØ"Å™¹sÏ=—ÿ>‰!~Fb2¥ÿIq4Œ‡¸C¿FôëîãÑø<~'ÆgñPbzŸûϹ¸?Ú]b4îµw‰ïF§ñt·ìýÃÞ)|”]ŠÁõ öÌ™¾Ã‡”­À‡¤7ËDbjëT_T+%JY('LÆꥲRäza¥Õ¸-­ÂÃÅ:W•Ê·¢4e´6¶’‹\EQ´5µØè<kk¸‡”JEeDj„3…êe­¬.TYÉJ›2þáá÷£¡ˆÆ'°¨wQ`ÅÚ8§±#Ÿ¤ñ—¶ËUA×°!³¦V%ØD<+ë°Û{«l.{§ñy<|üAÈ'ß_¾Â“»XÜd‚Lt †Xk¬+ù¬Ë¥·0Ø2“-]­Ä<±Ûu5w•­“Š¢#+Q(‰ãæØu~?ûzwy%´C*‘ªL—ð–ÎÕ{îhㅊŽñ¯L§­[dÝÆÊ5B‚?©ƒë¡8'”ª1EfO&¸J{oÄòí[e·7—"JIIi˜Óqòò"¢›Aíì¹`Ã|Àq\Îî®DôaÏ^H‡ˆ™ÄÓéÒy’<“¹3B—I^§ðM—RŽt’d¹\º¾Ø¬t²‰,áªÈL ÿ[aë²Dh_q‰,‘ǵSâÒ”™^þˆtk¤ö»7þú?á ÿ>>–ßýxü—æ‡8Î3›N`%Æú»þïP?>ÒÎHU[ÚûÍ;ø‹w…=õÞ:wüÛ+ŽªBÝ8±Vi'à*áêåR¹ŠJŒ  ÔQÎI»%ðY•ëòi—4VÙµEõZQ;†>@x `…@YZUÈ'å¯J*°Æ)®Â¤uS6Æ>¡¨<&|e«2Qž;;uµ2–ê+I¦¡^…LªZæ B>… ÐÙnJQW‰u.«ÌØ¥{ÇŽƒ;Öì»ÄUKÞXÅ'˜Çô¢áª[«DËœàQ@÷¸-U.±zA%¼0ÏÄg097 ü%ÞàPâƒEñýe\ˆ;p Ý2gŸ²ã|ý[tüåD-j ÐRiuY1UW¤§‘Ô-r*†¡uÅ~‘mð¶ä|¶&öÙöB/W¼1OHA­ªí*ZAáÁ.­,b1Cäe¹_KýÒ‰r!“è åNQôXEã–ÒËÓÔßiX¥GpÂF©o9Ž ¡Ø‚'תLô“X<6B\–˜f‚¦VÊ¡†ÃnÞôwƒÁ_™Ž!Ë`#U~+[@!7׆rÈÚ'òÖ@-ù•iË–– bÄvð¢%½J͈€pènÔ0øIK‚«ÒäíÛŸ’i<ŠF±3ñXüô³hyû›=ö†/'ÃáèÝpˆÖÖD?´‰hwŠÿ°QAÛOy{\Q[wÂ^§‹v¯ÖȽåÉ–‡;aùÙÙ·—sÊSxZÖ/;/ÙŒÎݰvjÜjMyÓÔA›BM4€ßHçëÂÔË•‡ }ÀÜ ŠBþŽ„Ãå:aáAð¾†:S¸í9£È mèQWËÒ¦hoV,t v퀯1ÂK¯•¶½^àCèÀĤ­®á>™ê,ÀÐð±’†"Sh_òRœÐEÖP;q‚—šcðœ…sÊ…* z@.Q6ìC’K稢P•©¬$œ"YqB“” Uæ{<¹6IÉõFÞ/”Ê2ßKRirМNöùÃS}Ç”FºrKœQÀÕ–Æâ“ÙP;1–ÌzÌÈG«þ(Ö»è´|Š8h«&jÄ4`ÝÝóvÇ6º±¸ØÑ:"–n©[§ò,J *©¹Ð¼È Ö³C`+d…ºï«å½ Ç­ šA±î~Çâ2Ÿå +j¹håköK> BQËV)‹LÖyå³çA  (' w#º$f ̺€fëS´å† K¦$C /ThÀ×ÝÃÃM?(:/40”Kj;L¯ÔøÉ/y»4I’ŃîÕv=êx¦Õ*LæÀ †•ëÀ‹r òºf¯»Õ×6œô<Ås7ÖôŽ9ÊÕv MM-À盬ôýk0±:ÙÓ/¬WZ!KIÜV¤¨¨G˜<7lÌrc]˜^¾"ýÞ¦ÖÌèç‹ûùûÙìó±‡&Ò¾÷ÿºùØŽD~Íè?èApºüH ˆE]bÆ &†¢¤L¬áJa©Já£äuV©·7"Ã2š3ÃPË‹©p;ýUÑv`â×½Éi  èÁ˜Õ* ìDÃpùŠøÞÛ¡wÂöì6Ýà´µøÑ¦†Ô‚eäÚ?5Ä0mñ3´ˆLÑ x¦ÁmÀËŠç =ÚØˆãYVÀê¾ÿ }oãoÓƒîÑN{2£1, °„³½Ü›9¨€ÁõÍq~*(á`Ôf^ä–Ã<Þp‡Ïà'D/«iRÈjâ* fOW¯©?!+·WwŸç_fóûO³»‡ù—‹_®îͧàA´?j%¥Ù°y<8“× m )ão=²:@òü ‹ÏaÀ>”¦G°KØa@¦iÞ!°@O¶ `IÇ'?ÁÄÐì Ï\ªÐÃòVnøtw›;\ñ |‹÷ðPûWD§>!Ì„Ma…—&ââ!}Ѧü™_Hˆ}G¥°®šðöœ‘ Í¡¤! Ár|g i É ZýÞÇSœáçcµ¤Ños%ÁcVù C’4ë‰ÔC@A΃ü±†Ùñà]Þ‚õH¢GÀÅzB^r‚x‡öÅ\óʬ˜°áßñð$>œŠé9Ó å:šàµÝ“Ôm›¦­PÔþÉèÌ¿˜Lâ1¤ø%¿Šðò³!:Vc»ø6ó+ms:œÆ“±güÓñ„n]=ýzô?€#endstream endobj 5714 0 obj<>/XObject<<>>>>>>endobj 5715 0 obj<>stream xXmO#Éþί(Y+Åèð6°Q"íòí9HøbéÔžiÛ};îžëîYÛ÷ëóTõŒía}í ÙLO½<õÔSÕüvpJ'øwJ£ þŸ/>¿œd'øå懟ÑñÝt:¤—)Î^\^ÒK!ÏOè%ïFÙ0ûH×nQ™ÒØM§‹³ÁÄDªJñu_~=8¾;£S¼ÂFóì fúv{ˆâ\E uU9[ªªJ“«hœ 4î?»RyŽèÞ›Õé˜gãÃ# •Î*)W^“ äõoµñº å\[šÔ¦,84½ŠÚ˜¢…+êR‡Œ-džˆ8¿¢ç:hZ¨|n¬†›&‘Nì#—tá@Ù‚öW|¬ûPT˜éT{m‘‹Žä¦ía,=¹JÒÉèÞ’* Ãߎx!rëb' ™¶Ú«²\SåB0“RSt´0+ c ‰2w?idáÉXª)¨…¦ø³ÆüPðqTGÔíwÝAÎüÖ“ö%àÒyû\š²$«‘%¼O4Þ"ó÷8½É)§‰Gõ×¥GH’C>ê$ÌùèoÚ¯ÉI•âÚÕ~7ïBÚ´% ê{/o2É’Eu“Ý87¾°õõ–HŽ ëäN•ÁÑ\}“"|C†e¡‹u ÓGÒg¶ è…öÂÝà¦qÉ9þåÜäsÎ9y³ŽòÏ™xLHIŽç©.œÜ¦äÌ5ö"U¾è¤¦#QÐdÝ4]ã;£—9H¸P ›GÀa6(¨MÛ"ïäG÷Q .ÆF¶B•w Í":m£§ÔÞhY£ù-Îké¦ÝÀÑõ:›eG4p£¡ôÛÀâL³ŒdQ(Ñ”$/—I^ N#úܶ¿ú¶Õ@` PðÕØÂ-÷J”H]ó¾¢ç×ûlÙ„›C¢?®žÍѳÁ, ‹2ŽÀ%סÁ~iâœþmÍ*£h$÷øNa—бwœðºÀ«èæË—gÐÀÒ©åD’#‰ ß´Gñ³©kÐ9k ©ê…B#f\R.IN¢úÉäÞ1é?&ÔÐÕë~èD¢Ê8ç·Y5ì0oM›µØJÝÖ4§O-±;Oà ^®TvJ?×Örñ%–©w º KÇZñëÂ"{GÉN{é6´G6Ðù–¶)6‡á ˆƒ£ä¼AÖØoŽÅ£(¯CDH2Ogdu›¶È¾á@3‹c… QWáŠßÀÀÅ”)XaJÕ>lˆ¸Zñ)ùý“ŠóñáVl"ï &ütKx^õ¸Ƈ)Þ>¬ÒvúGœTd>ïHàM¼«Õ6âÇ:"ÝÔà»1îeÝ;0ÀòСKË¡M7bçÀæÞŠšhJ¢aí|õäu£¯Î÷2bíb›—5–߯æÑñŽ)Eýežs’›>6kQ‰Û OÃ4½{°%›8ÆÝs½½¿§,7zŠ»„„Ö‹‰+½Þ?4«ÌO 6N1`Xo²Û¹%´zÆ™~Âÿ¦_yjó5 ¢Ë+i±ñÑI3ù£§ÛŸ¿üòøùŸ·×/I# nZ¼’ow¹¶Óß8 Ú™‡úf½–©Î¡ ío¡À¬;ö9ææDcºi›«*Ô€\öH›¼^bÙ‹l¢ô>éÛ±ikÚ‘Ÿ?Á§/Øé1ÝÅv¸$q§«ÊZˆÏÈ‘x¥Þ^b$ìm#ßaš4ãz,l°YÔ‡Ÿ6éÝÑè¶½Å.*bô0°í¡-{ÓU“˜§bã%+Êr³ýv•õ=´-Jyý? Ä`x™ýØî/n "òRÙ¬\H݈-v-t¢òÍRÕÎ~UcB÷å\?´[ڱ䲎¤›KÒoc£OX:rÜfhm±ž&S‡ïoñæ5X‡«µMSn¢9Äýþaîš›71\Cå¯{vì}Ž|m‚|˜yÓ‰fÓ[(¿Áâ²–óB¯ÝÅŽ¼f ð–iå.ÑŸd[<¾;¡KÜfð÷“!tl8ÌF#|+ú7ÏôwbƵÞE‡ÙlÔ¿v|Pô·öÉÕÖ¼8‡*,©÷AǶ'ŽïÚÅòôò,;ÓÅ®S‰ô`”`ÿÉq³°Q”•݆'éôà#oq²è¿ïïEç'”Q^:ž±±Û—ƒü˜îFendstream endobj 5716 0 obj<>/XObject<<>>>>/Annots 2865 0 R>>endobj 5717 0 obj<>stream xVMsãD½ûWt-pÀVlËVÌR–@B.S{ñe"ìa%vfÇEñßy=úŠ\I`©¤œÈšîé×ýÞ›ù4šÓ ?s #þóÑ,˜áþ˜óÇï7£ù2¸¤h5 "Êióæ!£»Ñr9BZÏ‚Þ-/WXéü»þqókºwØ€¢µ #ÎÈÿsЛ'ø2ÌŽ.®¿¥ù‚6)JÖkÚ$¾Âmâqa° ?¬*v¤Ý^Šu^ªL{¾ùstq½¤9Vrìt± –ˆß}¸½!eéc¡9Mm>ÒA¹=]wU(ÊÅñÉ‹“ܤ ú ŠDl@×ÚÐNÒˆŒöªpÖÇÛj·“Ö)]X22EeNsI(„Ñ$cTKþ‹aÏxܤ¾mû1¦x/J'MP#Dw<°ãºÆˆÆ+vÈôašÉ™*“&±¬Ã†ñ}¿w¤P~¬œ×÷«4å:©2I••@FVå%žžÉË­¼¢´*bF=¡a”¸Ï¤ ca@k&¾7q&,²¨sèRy¼m{ºr)ÝûýÞ¹œÑueH”e¦bÁô³>©™ÏWdVsÕm”u¦ŠàŸÌLS£d‘dG*~Â9ï‘„Ë™õ¢¦A‹ª¶+f£9(ɯ†wðÌ*¯¼Þ(S%’«†™ÿ&Ã)5D`ž7‰® vº+EþìÂÞŒOÃZc KpK©Î` ör§4Ìß·y¸œÉ›í¶x3,j¸|;ùâZhÿ/Ióß!§<°¯ÀmŠiuƒ¸DÂZL ®ŽÄùêO¥±7Æa¶që_w«£„§ÍT0«6s@ï“y Ã? g•½}?ˆ¬’ H–!ÊV³¶KÒ]^¬Õ ˆ M¢ aúä|f‰Äo8a§õ&ܪwÁ g*Ï+Çv‚†eØ+äçØÓ_œ¥c WXß^úºn?åÙ߃Õ})Ãeÿ–¥©ß½ÈÕ $÷ùÐ §ßÑòdš¢TNáHöç”|ä3L9Ì6Q–[˜` 8ޤ'MíD§{>ßl’dY¿x³¸ÂXqZìúñ¶­ów’–[õ Ø]Lú«GsìA£g°“½P™õ¢è˜uÛÁ¥¶V±3€¦NìøQÊX¥O-²ï×{ÓëpæIrq½nÄ4_/ƒU¸Â%1 Ös̱=OC\7Ôq•ËÂy‹eÈÐl½zzY»ôûêUr5‹‚p{$d³Z¬8ÇO›Ño£4kR¿endstream endobj 5718 0 obj<>/XObject<<>>>>>>endobj 5719 0 obj<>stream xV]oÛ8|ϯX8>T)lÅ_qÓ}hÓºÚkzˆ÷bà@KtÌ–UŠŠcúßo–”•(mœ$†?$Š»;3;ËCàHã)¿’ìàÝü`p±y³Wt<Ði<¦ùŠFš¾ÆÓé š§~Õ€æI$oœ´9%kaéy!ÜúõÑüÛÁ€úCÜN£?~¶ª,«œXjI~-µîÆq¼÷÷¯±(üÓ{™haeJZ !R9¹µÄGQ9Þóxö’†#®£Bú£“ºh<Ž'(ðÌ䥹+Ãâ qú+ ÔMâ WònK©\‰J»%»Õ„´±¢(Y”d¥Hû&×[ú*­¦ka[Æ43–äÈ -_…w‘íFñx œXfÒ øÔ‹k@4î"•Kš]\ÐdÔN5Ô5ÞÕužûöǪÊ&N›¶ÂªÜQw—ð+ìu‹¼óš?¤‹Ou^åÖBzC#¿¬&ç>XkìÞlßjV‘pêZêmÔŠ¶¦"N¯Ü¨«g¥× ‹1Ðõ=í-#2…S&ˆž²JÖ…p^L©üŠº¤Êü™s?*ÅúYDË-"ó=ѽ« J£²ZZS9±8êÑf­°oUVBƒö+TPâÁÌ@(¨²B-PiW"‘=Z=U ðóz$û´>¡¯Æçò°Ô/ÿ9ÿ@ +K‰– ¢~€Îj.“•+iež°¶ßþz¨z˜K‘I~Lš§ ïDLøPŽÖ¼&M(t n•¯ Ú09 çD²Fxgø)•§*Ápµá¾ã™Õmr~2œû0e£¬µ¸FZt†–fÛ›kõ]"!Uîoš?…³ê†žçróoø¾ˆ¸[ <þÈG¾—Žg;¹×™søRÝãVB 9£s-t%éJæÉ/Y­Íæ‘dº…³h¸=¹ø.<¤K®¸&øp\|”°³ØÞa<½Ä»ö¨SÔõ…®¯ÛÙ÷ÿ;Vƒë©Ým R A…ÔïÕet|D0ØaNÁmòÝ 'N¸m!™N¶QSÝê0&¸Û»¼†>yN•ÐH²î‘ÈI²á^asVG†tÅæ=O'ßÉ Þ»¹3òV?o1TJ<ÅCµ¬¿üýùóÍž÷)N'”ݘT0ët-ŽÚ€Dð•,yº_h»ˆšM˜“ÅÑâˆþk¶c%8vç‹'t7½¸Ó¶öŸ$5|uï.ç,ɽ›´ ò Ç$ ‡ƒˆñÃ$tÜbwwéyW/צÒ)æ?ôÔª%··jð!A«*OØ îQø;ž¢NЃŸ¿·vÞr@Ãñv–Äß9˜Õ[–ÈÙŽO,‚•x•†Én›˜<à¹sbº¬ŠÂF¿6dÛðÞíô¹ñûé.Ûk#¢psëaŒòMÆ=ÒÔpFfùM&ηC²îýà^2ð”,6JkZJJÕÊû¼ë÷1.Xn}ŽÍ. )±AÜ›nÅŽ ›f9¡A`ƒmš øcè ­Ü–9{Å'&þàöŒiñÏN¢ ­€°·6>/XObject<<>>>>>>endobj 5721 0 obj<>stream xVmoÛ6þž_qÈZÌulű§/Û€6[Š]Ñ!ÞÖZ¢,¶©‘’eèßs”dÇn MŒÄx÷ÜËsÏñŸƒá÷„&SþÄùÁ›ÙÁ(áåæ[Òñ刞Gš¥4ÑôÅI4žÓ, §F4‹{_Hj/éßg³O#žàeÒ£ö§pÊ”t(H˜„TX~,-%*M¥“x°‹O2.}tøjÇÁ~:¾<%ö—ÒàÃɤï½ö”WqFÂSm+ÊÕ2+i!I™X+#†È-@j ¨t´º’@vÀÓ5¥ÎæôA:= Äšˈ~F•¥2Ë]+OÊ“pq¦JWNv±Ž9ÙDÒ$œ gÛJ㯨Pç¨pvéDÎ1ÅNø,¢k•+-œ®[h*]B¦±ÅÂÃÙ&X 2rMe]HZÔääBKï9N±J(°tÍ2Dœ‹šŒ-imÝgÒêsˆäm$B¬ªäÄ áJ#qDD‰0KélåiI"a˜‹££M«è* e7²©ôn´;ñXGqÆI•¾éÀ2^%èÈÚ©PkosI™ÔÞ¥•‰K…h¦/¥H"º„y+òBË— -îsr8G“ šôž*Ãí§§»d<îÓÅЗµ–MaûÇ]Œ«o„£þ¥µ3‹oó¾Q??ûšÑN¢õ†æ½`éœOÁUèGGà ¸šY|k.ÁMj#rßp¹‚Iÿ—yç‹!@\™Ø„ð”PX´ý! ð*d˜©‡½6Ãýô¡áo‡S{ 4ÐŽ¹³VeƵÖø, ˆÐkQûŽù<,e&É™jÛnùþsðá XØÚi9Ï÷Üu7 'Ï@›– …]‚ØNúJc*2(†ÞkÖZiÝv¤k´¨÷þÏwïšW<õ8]vj¯¤óà/¨QaQ«Sër™DÑY«iÌ”SfÊ…Í ˆÎBiUÖôÞ–Í·î¯ IŒ§bküû]ÿ}õTÍHK:…ãðÕŠ1mІ›if 9¼°—Û­¯E±—]DoÕJ~Ë êÊ("Y Ë<èxS€&&È”¯1½y€à£Kg×D'ü±ô¨M¹–И`ÃÒùñš› EÂÇXÒ–¥ˆ|UÖ•›ú½ Ž Åòާ\?ì…Ó茮KWqö»á‡:G¡Ò¯cà¢Ý¶kV‰Ð=Ùúê;s=jçì …M’A —X5ä%¶UЍÖC-WR“Þ N[ÍB]éc§0m©zò{#¼ŠýáN !EÉj}OáMðßP¸&Hú Ü]™ëvnb+lºÔƒ»½1{[u;¸K‰Zä¢(Bìm‘R«‘qíËÜæ‚}•üãÚ¼yÛì¦ÉbÞÛ×°•UI— þ'RËRnN·¹÷WûfmÞesîæöiÍ{®óg]‚Nï¡mÌÐî3ÞÕMa÷<Œ[n}óMÜúáÞ}îÝ·qïÜ=Úl/c³ Âs0>yCõpk¨roÀQŠíý‹¸a™œBOVôóæ"ðò15×ÎîÎðrÓÓ@…'`Îàp>7‡¯˜+?Ð[ ö-ä1/¬ì°ãk¡?OVƒóè9رý\47=W{uÛŽ[{ l')\Ä:ÑÁ¾ Ê„[ë" h¨Y.óäŸç·d¬…÷Ò·{åy»WÆ#¨á䌦Óq£z¬?ÃI4¢_m\±XcÙØ æ¸ª4g‡çÍjRzJøž .ÅÙhMÆP[(íÙøœ_ý6;øãà?Î9½[endstream endobj 5722 0 obj<>/XObject<<>>>>>>endobj 5723 0 obj<>stream x­VïO#7ýž¿btÒUKŽ,!!ë©'ÝRÔmé>4r¼qëµ·^oBtjÿö¾±³ ,ŠTH Ç3óÞ›ñŸƒcã÷˜¦s~Érðþb0ÎÇø²ûã¯èè6cºXÁvþЏŽ2“ÎÖáàâ÷ÁÑùÉÞ(£R•Kåkr+TßÈÐxEo¯D1rÖìrú(‚èL¥°$Líh©hå¼T…øÐm ¦ÖöŠÂZQ:¯ *{©Ë² biT?B{%ƒÞ¨œWÆ4:ž úìÜyR×¢¬Œú¶õu–O9à Œ&“|:ÅS‘¥ØéÜ9úÚzàü3"ÊóÎiûÕM oúÖÚº~ƒmñçhH¿´…èJ0<êo’káihE©îù{¹ÏøÞB?¬¿¢Å :£˜á4ŸÏO9‘/keûõLǦÂü'P·^T•*#8`DP6ÔnQ×MÙaY싖˜À6NŠ€µ„k:®Ã´Œëý€[ÏΪí]£äEV¨JÙ‚Iã,m× ÔñÖúüåÓ¤kò –tXÇÐGòÕ+rUÐÎ.rеa¾ÝP81›7Ö*¤|)¨Ëy«…9¤.¯Œ5oBÄ´¦Q$Ám §O+Ÿxql|äR­ÅF#Økh+,‹ŸØ?V«£©¡) »J•¢"η–^/q’_öqLNêwÞ‹]Ç6£užë¼£=€$P–—9hßÉä°-û³eÂħë_gãßîRõ ^VÞT`±ì 2•x¬Òª±Ð4 5úÔ…{\ÄÁ¾¼¾¼Raõ;Öʬ÷UüÑ«,à5«ÑÛëgÅ [´0C7e¿¢UIuSU,z‘¸¥í‹Ò ¤mâ ZàœÞÅúTJjaîpN‚p‡‰ä…C¯”U¤S‹ÈÜ­Èb³f*õÆÍ Ó «sËÊâ„9×à¸ÁÓO»°2 /ÆxoɧÏÈ(°¾¸Rã¸ÝRP8_C>†UTSå€)ÌÿDч[&‚ØØ÷Cà=zñ×¶ÈmÇg.­žE’ ¤Ù'4šJ#לàÓ¤Ž$FH—«DjŽn¸|ŒÑß,Goû¡îÓIynœ.(¹;Yry§ßëAç씾#^ï•!‘æ5ñÈ]ÅZŽ&³vìL§ùI>§è·Ò`H¨ú.Ǹø'yl[·l"Ú^µÜѲÑ&öw4 ˆ × °’ŒÚ(ó@usú€ËŠ.0¸Ã®\ËáÁã=$šÐº=TÍÒh7sÃßó‚ ÙâànIˆþþ·…Ø%k%¼\/²4uPå}$mkåqÀ“†^•n£0<:?ÛßÖŽÏNòÙtFsü?M·ž£i>¦NbzÛ ¸Ý2@PD²¦T#Ž3úÜÞñ"Œ³ñ<ŸNpYÄЙMÎxã÷ƒŸÿoz »endstream endobj 5724 0 obj<>/XObject<<>>>>>>endobj 5725 0 obj<>stream x•VmoÛ6þî_q2@qmÅ/‰“x؇´[†-СúE@@K'‹)Eze×ößwGJŽåÖA†$ïõyžãß½1Œèo ÓÿÒ²÷~ÑÅ#z¹ÿgWpù0‚Ûx ‹&#˜ÝãÙì™·Á"ÒBXè¯Ð%‘ÔtrñëÅâ¹7‚á˜,2²à× P¯\ÑýT9ád #3X[2K¢²rÐWÇNþõ/®€æ0¤t†“i“Nôµ@ [+ÖkÌ`¹ƒ/_ÿ€+r£”ÙJ½‚¼Ö©“FW ,BjQ8Ìæœj·ÊádO§Ts’€¾Æíg–DljùÜÉ2Tè°±:Q…oó÷§ …M‹}Ƀ¦“Òay2Š?(u…ö¥Wo?h±4|SD?UÊ´ï#úé6E ü<s·¶0í§Ãs¯×Ô¨F¯ÚwÜgöSØádºÇÉ£†Ïh•‡FEàè@¢®á6¢Ð™È0-0ýFiu'ÍG¯â+>¼ Agi?0§©q»j­ ²"˜Ü{—šZ ý8M´Hlæ>æ°35bCK ©ÙO”ñ"mà­áÁø§m­_pqì‹Ý/¼°«8mÿ9{OKrëz©há½ÕÇI¸sËÄ®¯fíå²Z‹2‰8l?o”ä¤oš¶pmÔZÿaõFÁY‚/‘‡ãšÈvdwíöŽÀXÊ¿áXè„$KxÏ ·¦ü‰«#G1<æ ‘‰*ì.¬|&wÀC¨Š¼gÌz?]ž’')• ¡j~h³I"¢+ajï¶Ü‘²VN’¸‡öÀb3ÞÉÅ«p¿ üÜٌȸ¶vït«9@:UµG)iI±teE‡¶ø¾¸§%’¢dÕÀÞJ¥¨ ŠG Îd%Ê¥\Õtë¡é"tcÜühj¿XÔ¢ôÒ}0ã=Ð} (b»(Úã/·Åæ\ö òa•z·,=1,ÝÿøFÖ¿äó{5Á“(7æI&t‹3þvIØm0qÛ\Ç·Wñõôf·7ñ8ÜÚX!†Óx¿›Ô+­Âˆ‘Ázxî¦^f‡jÄf×£Y>/XObject<<>>>>>>endobj 5727 0 obj<>stream x¥V]oâF}çWÜfál°I›J›mSõ¡mªPí‹¥h°‡àÆöx=ãTõ¿÷ܱ qvÓV‚ ˆ‡{ïœû1çÌçÞ˜FøS0ãw”õ®½‘7Ââî£| á͈æ^@‹ù#š]Œ½Ù윱µÑ"rNJ™‹L†ÎJ©û8<%|‡N¬ªe*ÃÓoOöFäŽa;žçužŸT×öIn`Lû×pH×2R™ÔÔçÈIÿ Ïh-Jzí½áygĶöëSèäÊP ðš(Hx¢ThMw…Èè¯Nøè“è²³l_ÇûP;~»º`õµ_ÜM¯ëõ·-çðfB\ϹHÃõƒ¦'ίj3 $§[Y¦2kI™4kk¥$ERk“Шyšª¶ v[ìú¾hxìTZ’|Y‘Ên›ÅËKۘР^÷ùXÓUëzy™ËÍ=×8t^ÛíñÏ÷M´c=ø"à—†qè°¡7ž4A߬Êm*2)åJ–d”­ËÑݧŸ¢k¡“HF¨0øq¥JÊJ•äø7&Q¹ØáÍ}®8×{ÆÅ oâ]Ðo…,…Q¥æQÙC`³‰7aÚԊžd©Æ^àùçd·•Q¼I$ÒtÛL¨®Û¦´! gg¤Ú]$ò˜2QX» @›„`{\¥’6‰Ys˜vzóÒh*Rád[þ¤±âyqÀ=b¢à‹³Ÿ•¢šœM±ÙfIn™åû=ÆlWgŽ›‰U8ç¤&µzµÕ=‡â¤”‘Iž$6RĤ¶ßcÀìÅ;žúw;&fÏi‹ÄÒÍKíƒåõŽ,…ò>:5üÛ‰S”(QkÁ‘ HÖà( ó£&ì;ú @ÕWUޤ@úñÄtù“n ^Iÿºb>´*)´N£U¨¿€˜¤) ±ñ©˜ & ¡04Âvƒ…;ïú¹JRÔ÷C;?‚7ç«ðQÒ£…ëF­XÜú¯m¥ü\%O"…Ôx4ñe@v(£¡4yä©«{i{Žda„d’Dzø¨ã12 h¨¼Ê–@ƒ¬ì"ÄqKK Ì宀µDÔc¨y$›áº|Ñ>µžËR=â8TE;ÝÝÚÕ5%+{bŠ÷Š$$±Tã͵B‚±í*¨Õþ$× Ct¨m;žXÏ÷ˆZ%'‹Úž&\Þ¸5ŠærÒª¥?šxÓ`J³ÙÜ›³,òVnàèUjg¯4Ü'ŒOmëž×Ws{Ÿ™×‚Þ\p>wÈØg:šy_Ëñ4ñÒ‹Þï½?G‚Bendstream endobj 5728 0 obj<>/XObject<<>>>>>>endobj 5729 0 obj<>stream x½W[oÚH~ϯ8B­–¦ÄLeÕ‡¶Û¬¶—U©Ú‡¼ ö³µ=ÎŒMÂVýïûÛ` Qû²jû̹}ß¹äöl@}üP8æŸ(={5?ë}c¥kQ{M: ÏªXk0êHzNTî® µ‹ª5·’]›Ë(úâ‡|þ¼óEàjÔ'da¤ø ¼ühR(¼-¼åš¼WÖùÜvˆ[·7‘@G¼?r¥¨ÌÜè‰\=fÒ®úKÏi0 Ð3y®^ '|Œ»a\Ò,Ë„ð@„¹0?æ§¿Z—_“ ß|Éñ¦èE˜'¨‡”›”Õ£¯ùÉ \ÃŒ†j§GÔJL”n$aäjn7áz×fýF+hˆã›.®Ò=z>¶þãÜH[&¨ÿ­†€×ˆ.U¯èÝÓSÚþÞzÿ½íAaÀ3ÌîµÈ«¤œƒì‡-Þ¯óʱóí1gŒÄÆÑùýÓó_òd6¸®l¹o}#Fš±AïfN8ШjÎûøš6Zls™"ž@µïÒR%òÀ¨GÕÐ[I}¬²()±otvæÜRÀdr°´ tV0¾ÿ4ÿði~ó¤'x/ów©.¸s%¿ë68Î27«{蘰í‰Î̬I¹I)…’hU¥`:uÜ {£C÷sÃt‰››¬ÓŽìª•¸G‹}uŽRW§Õ-~T¶Q=HÃ;](´Ç5Zý‘ì2پͺi >m\sr…M§ªšŽUuó6ƒŽÆ›V]ޮŜ0è±>i‘"´G· Ö9r›wUA¾ÞÛ‹áléÖ´Xïï+u!¸íúprUïjªæ¨§½S5ö˜Ûýö0®f–ýoEæýp]òÜG@ßü7Ÿ<úî¸øìzR-ЃÉ(¸ /i<¹ Æ·áóQaЧ?tT¦+'/£¸å¥/®xývseàø¶úû†‡K5×]û¼ìƒpˆIÙËpÀ:ÞÌÏþ>ûD¬?endstream endobj 5730 0 obj<>/XObject<<>>>>>>endobj 5731 0 obj<>stream xµV]oÛ6}÷¯¸0@lY¶j7í°‡µ³7?,ë:yPÐm±I•¤bEÿû.õÉ]â¦À ‘åKòÞsÎ=—Ÿ3ðñgÁÒþÆ|ð&øž/Û?jÓµ7^áæ>,_ͼåò%„IåC;W$ϳ0aÀÝܾû|©>ÇÕÿÓן®ÃO&¸E˜8÷’%@’$rì¢:êT+ª‹ÌD×Í’Y¹Ä‚.¶Õ·Ý¹Ž›®_€ Ü•GLæA¥³Ù]!bä^b¨)(È0£!'Špj¨Ò±(˜”é±Í¶_ød>÷‚a¨³t;5ÙD×𥮰JÜ#ü “Èqçµ|­¶$ã“, & M¡É£*ÍÙÜþù!ì/v²~ÝD?ÐÕÉúЉ8+ CsÊ)'¹öØÐ®@Vªœ=Ïë}.YêÕYžqï¨Êƈ{wò€1èT49ß+j %àždõ`-Ð#áyFŸ.eDÙ&òu“aps®¬h†#EbØWÓ$è£huÙM˜RàRˆ%ç(KÊŤtNcF2¨aUd¨(¦ÁHH‰H2Úê ߥÄ4er©¬¼Z+¿o‹.UgÙ˜[•i‰ªd·îè·¬‚Îv‰…ñ@³¬‚³ÉŒ*…PÆ2¹€ãÔMExˆ&{:nßRe+Þžl·`A:3)öp`&Å>Œc\Sî´§‹¹Ýõc½käÄ)QàzÄMì·u«×û\RT(á HnM;hŒA3Ë©¤¹9ïì4£>ÑNI­¼Žâ®¸LæFt½‚/7V× «¤ƒl€lýñ¿;ñ2¦îwBy—ÒRÎ 2Q·©E®5ÈC1ÕmÉQ` ›±’ª.ÍáQSŒœQ)–1ŒÚTº]Ú—Äðw­„;©²dx‰þ_„Ä­ »ÍØf×5ì ì1,ísAÕ©-K?Ã\J×ÛSó1Áæ§†Žœ?ˆQì.ofºXýˬàSÍ«GçP£ár¼€õxÎö©iµ»“ȉýÓÖ÷ Q}S\Ðä3pr¿£[y° –º|T›b»ApNÚˆ_"e# ¦Ê<3&šZJuò\jͶ¨|´t£(Z¸hØ;ª¨@ë³~ûð1ñâಛ`¨½:´ŒVƃ¬òZâ¼_­WïW·oWç†TÏ‘gHô‡D0]ßÔ©Ìn^x‹`Ë¿¹Òü}·ùmx>ü*ãe·$¾Í'c=yYySx ؈¼ÀჳCÆ>>ܢ종¿ô‚9^.qŽ-‚¹}µ  þ Aendstream endobj 5732 0 obj<>/XObject<<>>>>>>endobj 5733 0 obj<>stream x­VÛnÛF}×W 7 ‰ºP’U§-Ð:r— ±Uô!êÃz9”¶!w™åÒ–¤ßÞ™%)›–´@aÒɹœ9svf?wF0¤ŸD3þ•Yç·egéáþ]Ãàjó0‚eã!Ìæ£p6;‡eì­†°”ÁQ1ˆ8^J;Øö€?vÕÇ‹ëÅÕâzñîr±ê¾ê.ÿê ®&0"·ú®?ŽêpÁ[ ïѦ•Ñãœýñ8Œ"Be€[‘å)úhƒÅÁ™„ŸQûimzqáÑE½Ioµ:“5’½onð3z±ÒÏÚÎ+4Óã߇5Þ¦¨–„¦†ªÐ`ÏA›€®´ª£ÓÈÒZÔŽ¾ežë0†ÄXÐe†VIp» ð<ãmB“Aj„Sz ¹¡:VݰÊò#Œ&ᄉfšçü5"¢[‰¹SFÆüSrmãbûI8Ÿ³WsóÇÛ7OKú› mßbeQ:u‡ …†[êY ΀´T-‚à¶c¢´¸M¹Ÿ-8h}ÉÒè;´¾®½AAÊ‚)-çäöâåàòåKÈ­Y[‘±öŒÒCÜ"ôM‘‘;ŠNu˲p&S_ˆ7ú¯îB”Ó ¥ È 5%Fú'-zp[ºª$>ÊN¬Qq(k ‡LEQ@ª>!8b-1ijî‰Üï+ºòºz k©×_¿½€Á~gÞ¸ûDãž‚:#ª¼ò}mJ¢ñWkž6ˆü{ VÔ‘î!ìõNáýÕm­óãØÇ‚¹³O_æ”EÉÃH„ô²é¬Æ{ˆI Q[* P_ð (€G«¡ÁV«î|†DPèhsä ÜG¶ýó):¶ÔdÇ/ß};@@¨_cá¬Ù1½óÍß-˜'à‘LR$Ya àhÞk¤3¯½FRÔk·"‹sÏ&€Êrœ@a«˜G:Ú@¨Ã4QéoÐqÙÊa‰5ÙCz?Qr´¤» nM©c:”ŸHÈ~°´TTËeŽCU­T' ª„™À/4¨ÉæùsdðèUwÕ= Ÿ‘ÖUµÕÑŽcZŠ‹=ÝÆš{x8ULÜiY´¸¹yÄ ›}cþ3~'-^zÍéºéÿÇQE)Ÿ¢VÀ=Wÿ–¤c*nDUí^²ð™O®ö¥%B4ÐE º!YyrióUSŒ—EÕµÇã®™¦t}“ôkA )± ÁÌÃ8Sëƒ{A§„wŒprCq(lÝ;¾S4âòë·uÁsÿv÷VùÓØìʧCÓ¶H!OTÚìù÷’‡uxÀµ³‡càLÐŽ4š‘ ®æõõb4Ÿ„ÓhJ—¬i8ù ïÞ~idJºÐ~jÜèúTY÷Ï«6|g·O‡³0ÓE€–Æ4Š8ëbÙùÐùûÓùendstream endobj 5734 0 obj<>/XObject<<>>>>/Annots 2867 0 R>>endobj 5735 0 obj<>stream xÕVßoã6 ~Ï_A;ÌÅ5Nœ_×nO]/-úrÛÒ‡ŦcílÉ“å¦ÙpÿûHËJììº= õERÉ4õ‘üøQ¿"ÓoÓÿÅÅ`Ži‡?"þX= faQtŽ¡€Å$œµ‹že7‹pÑyöúã«qhv0ºÃu8…u “1,n¢p±xë¤9q ë8ø|¹þm0†aDë„Ö±°q›`%Ô—Æh³¹„?ÏŒÈÌhñi\Ü# U‚/ k;Ôép«k•T›ËïÏÞêåW„ŒŽsQUð^×ÛÏþ™aö¼}nœî)?ô~ Cr3œLÛƒu†€/1–Vj™PI.Õb ÈŠðVh,&Hƒ±Í9«a‡ àý½e‰ÒZÅì¢ ]2Nª;3øF4Ý®GÀ³0RP|’Á21{”6›¡bÂQßîÞ¾u¨¶Èñãšllìq„ð1CBEéS©0¹äzUTC[¤¯z—Yz+º"Ÿ¡!0iç‡8ø Mîüp–,Št ©61ãcL¨,e J£É[Á^-šB*Jœ‹’N§´¹ÃD¾t“}[A•齺rÞ^©Ò^æ9!’ÄAÇg4ŸcaBx’*FrÅe%ϺÀ}&,Ç4•±$´!ü¢k($%£uLu• ¥ÐpþŽáõÑcŠP+âQ‚>iU•KrÚL'äò“ƒðãB·í†“I8R&Á›%wh¥Åâoe)Æ>ó~:Dë´ªï ÿ¹u;QU_}T¯*Ê£r‹E…_d®kEGkEœ9ÚzŠpÕ”(è±'K+'-'ÜîINøÍ3Ë6Ïg–ý6{Lá@´Ï¨äÚr'2MÑPKxæ^56¬âYË„äÅöPr7Õÿ# $ø!ÜkC&¢(sü¦;I‚Õ퇇å¯ËÕêǃ=’÷œâ_í]¿½AEÒ”¶a¹)Öißà 4#ë˜‚Ž­o›sÛWÉè4ïéãã÷ÕùHà‚‘’â›aSE®Î‚d[rYø4çÏI•ü $UE4š!™(IÞI}ýšÁuѬú—ºpwueu!ÿÍÜMQØÚ`Õ7ö·“à‚Ç šPµ¤ª îçí„å™ÞÌŒ;]”äs+siƒçß©M¨A9!QÑô^ÁžøîdKgŽKç,ü ¬3ÏÛ’¸Ý“gwIÏþÌV÷MPh*¨/\›^a¹—…&M§›Ø-ï£ûë6ÍÑõ,œOç°¸^øQÅ©Néú^ÇuAŠÑT”ÒMËYß¹F˜Ò­ –>ãÇËÛÎÇäpBW^~ó錷–ëÁσ¿øï>endstream endobj 5736 0 obj<>/XObject<<>>>>/Annots 2869 0 R>>endobj 5737 0 obj<>stream x­WMsG½ëWt©¤ ŽÅŠ/!¬T²b»tŠcQö…˰;ËŽ³;³Þ0•ÊÏëž]`AŽrˆ„óñúõë×÷³! ð;¤ñ”av6x‡Ÿ†üôéÃÙd2 tsû&¸¥Œ&³ü÷£”žÎÞΖȺbE×ï4 Æ4i4 é›a0ÞÒ<’4{D¿š=PˆqÔ“Ñõû ñ0¦>–õGãfYož˜’ð(+“¦TÖyîŠJGW´¬+2x”é¼Ð¡Â»ÍMVotA|ƒñ»ö.õ÷Pç•qÖÐ×£È`ueÖšò­M¤Kª°K©2Mqmñ‘³*5Õvwf¢Ê6‚G ¢ÈøYª\- fÙFU”©?5Í\ Åuxoh8 &5Ç<ã—Qo<ËŸt¦òÜØEªRÕ6ÇvS%Ä/ñ‘Ø“ÆË'ÁlÆë…±’CrÜ”aa–X¸ m] „X"oééË㇟˜¿XÕiE›¢9r©µ6® kUW—ôpýðúõšºdtÌÔ1Ó Ä.Ïœn!kG7'ËçˆT´V6ÔU.7!¶sª,ë Èc•QÀ¨¶ 8ô£.Rz û˜G qà?ÃÉ „¨”Œ•ñ¹äª«mµ7?`r/ýVÇ=¿¬E&*Ƕ’7!›™~«AÈ&Ô:Wœè2quѪ ]–‡ÓfŽT¡=7ÓVœd]Õ¥«GŠ ý­†6#ÊUQ‘‹ÉSÎYë÷ûê3gº ÕÖÕ«„É\YA¥.ÁÃ#"gÓ-NÀq&¡l”hGÝ®ŒC=¨2‡° Ÿ&ƒÒQ9}ɇ±à(V¡Þë9÷êž¶Ú†tO¥ÉòT·œþ®xÜåÀ‹Zjâ~7ŠY kO* ÔB=ºHÓJ[](Ñ}QóîL;¨ªRa"âÂTÁÄÙÃNͽ‡ÒW´³k Ö9¢•.ºlƅ˼AÏÕ°•™URqBŒM;¸©Aõnyçc;4ÇþhŒÇ°Ê¨w‰ŠdÄ>/XObject<<>>>>>>endobj 5739 0 obj<>stream xVYoã6~÷¯) 7Žb[±“Ý¢ÚtÓæ©[ÄØ¼XÐ%q—"]Nbÿ{g(ÑR¯s–DÎñCýÝÃÇÍè/oz¿Î{£t„7·¦‚ëÇ`^âÚÙ;üR„çø%OžØZ{YÀ’ƒÒŽàjæðƒCÃ\^ U.a0ÿÒ»~Ä\!Nâ6+^ð²½£' •Ü€Îso,…— axî„V)<•°ÑpŸP˜‡EiØ JmŽ<)Ç+nŽ A8– ¥'#¸O°„­VRP阩|Õ³T5%8Ž,TØ»%I»X“Š5o‹²3LZMÈÄš©ÒÊh¿ ás­,Ͻk¾Ë›Â#.âÿ°f%ùû¶Ü¥0Á’'“4ËðªH~èX$B-°HòšøÑ:3¯¬¨&ÉéÙ¿±_¢/ü¹ÃÏð¼þøi‘\µònx1Y ~:X÷-^b^܆­C®½r]¦|ÿ›1ìÜt*ÏÒÙì–"½ÔÁÆK'®"ä[>‘¡°aR\`%DJ¾²…š©B’ ð.X”™äð‘ zù“¼Æ8LJýjC”Ò« $d96ÈGz¼% ÄWŽ qÓ"AˆœC­_ÃVİr5¬˜a w܆t#Ê}18ÍQ$ò}\Ÿ÷‡ý?8–/ÚÈ¢Œù8 ¿¿¿§ëëÇw@R-‘~’À4™eém: O#~¶ÝmEëoÒV›èÊ•ák¡½”ù „”%ÃÈ»(Ù¾Pý)8 UºæÆ‘‘÷ðEL5<¤ð ¬™Ü¡oK4kYrƒîÙ@¸j]âb_ôhˆå&7ºð’èù×(¹PÒü€S!ø–,ÿJhØýª†aB4¢ª]'¡Ð’ön×ñ|P q~šÄÑ0º‰Œð†£ ·(h´•]VüµÑÆ1¹HŽ&÷Yî>ã¿X£ûÚmC”ÝÓ' ~1~kz`-./£!iŽÉ·C¦L6G¶KM îâ°ÜcØš É–{s&Îy” %Ø5Næ0[bXõÐd;¶$æÂ\­ñ¶>sw„ºÛI¼KþnÆmlÃ7 Å(=º8ÊbÚÞ8'Éøœ[½M»1Ó¦ª¤^2œ@hž™î¼Eßï®›u-Lñt}ÎÒpŽøŸ Qr¦,ø:j‹jd XIcoïIŽ“õŒ´àd›z‡GÏöôk§:ÊõŒÐÈøwº¡ftQÝì5qO o–ü¤2ž¹ ÃçßÃå%´ `Ž¡£%LUžUÜ.çgÜCí®{kšŒnÒi6…Ùì®çÏ/O¿_eé~Óyxia4Ð :”@»öê¶áœã´¶‚Þ+¶Ó ;žhÏt4K³ ¾ã¡ï§ÙŒn}˜÷þêýab Ôendstream endobj 5740 0 obj<>/XObject<<>>>>/Annots 2871 0 R>>endobj 5741 0 obj<>stream x•WïoÛ6ýî¿âd˜ÒÚª'Ý>eÙ\¶®öÒ/Z¢m5©”ü÷{GJŽ$n‡iœïî½{÷È>vÔÇŸ¦ü•~ÜÇoøÛ€¿}ùÔÇšö‡ñ” OâËúCNóÎo‹£xÈlèÃlLƒ>-Ö4ìÓô#~J}BüD_¤«Œ"½¦›÷ï©ÅJJ…´ŒDžS.Ô¦i—ñÅâ[çà ød=dë †ÈýäžJYˆr%[™<,/BäQÙÞpÌ7üÏ´y%¹d¦ÊÊQ)Œ(¤“¦.ð‘8ëšBn4Š/ã-B$0™XåÒ¶ë Ÿá8ö¾fn›)ªû¢D§²K‚Tåñ¡´-e’‰ü9•F®E"SÚã,bÛh£óv­ˆ ñD¢,¥01]Óºb²2ëס?J„¢•¤µ®T ¸ä¶’ó˜;óŸÚ#ÆÈ¢©ø¬€f¢Ñ%[Q2e´Øf–ð%ÕQƒ N]Z=wóK’§‹§r>hcãÁ†y]Ó å:9â I‘¶Ô*ÍÔ†œfH$W!ˆéÌ®3ð¾$²K»fDifdⲌi¦M­ /ÛE‘eÝç­Ñ_Ã7„ûÙ’­ÊR[t€ö¶:O SfSR9Ðõ…ºr,À—E‘{Î*w¯%ÅH__£ÕËgiò·7åÜK¾ ý˜n>Mzõ LøÎ=Çhç°2ÇHŽ”V£ ‰_ÙÐó€åÇ 3‹¾ºõÃmhЬä#Øô¨ƒ{…½~«ä¨›O鉦½°X-#IOÐ8¸g­Ê]KòÆ›™f•VOÿžu²H~ªÊ5Dem¶QlE´“ÆfØ6 …õÃz¢*»kXO6ÛDðB >ŸËµëm…J{6K½Y ºa¼ëµ½¤u)p¨“†àKce¬3<*å¶±¢ÓÀ,àFì_(WÎá$ˆ9‚˜m„‡x…ï¾ÓkËgmuØv¸”¢½a˜v©°ëZáY2ÉñwJ• ‚Gçe{ÁHfê=m<µ4 ;‡ û!œ”‹}*¾§Esa=Á—­‚,n.1R¸C±·îª1ýk%î„g m­z‡­¯ª­d^2ç¡QÂñ2Ç®®d"­’մ׿¡¶IÀö×w=© ÆÙw©Rkm\¥ÐgþÔmøÐd¥Babºýð·ÖÈXzgLë¦rö Q½·?.0™Àš‚ºÁAŽª ¾¥Ò‰,Gñk²[Ô…ûwŒØpq$»ñóÐ ãÛAÙ)m¡=Îßêw1~­õ-2nu‡Z¡gðS^ó¯·Ÿx¾Âc•9Ir½7IÍlž”Þ3ÁBùÆ€Ó²î|ë½.4ÿÀÄùä­vŽ&Yª,K¸.Û•Á+D²EB ~sÐ’òRÕuRÕî2©ßL‡‹Õ«íV9¹Á2ÌšeéÓ¿uüs­7Æ£>¥Q†»‹h¾»½[Fó;z·¼øµé‘ŸtÑNg)‘ÝÝ[‰[4ÄØ]—nïÂ⼌G¢wJîçwþVØ¡ìß¶ê~˜5 ü;m8ЧÓKîÃC›å†¾?kNðcS]±“Îw„XcT5Æ.Õçüù*Ê&Ÿ8 rýÿ…uÒ¯oîq<Mh:½Š¯˜mo÷éwø‰wn%ˆ ±½K~b§‘öý=;i”矄“þ4 ñMF—|øEçŸÎ«m¹endstream endobj 5742 0 obj<>/XObject<<>>>>>>endobj 5743 0 obj<>stream x¥VaoÚHýί˜F©d0¡êåC®NÕE½\ œN¥Š6f ÛÚ^ŸwmŽ«úßof׆˜@Ré”{gæÍ›™·ów£ >þv¡?¤O7~ž6|ÏLJÛ?Ù:cF^¦!ô|¾ézÃáLæ”ÓÀ V,úq'ÅílîLfà¶`2½»¹þOæÍ·Íé—†í.ž_8… sTq¯¸N‹ÊÆxr ½l’<±y.$B²?nÂדEÜÆÊùs–"Ñ¥)&÷ûo6ê³ðö$£—Ïï¥S!* ;ãw!´±í^¿¬s˳îxÈ3ž\Íõzµ{=¯ßÇê=¥=ãáý>õ-0ÅqSícÞUJ>|á>LÇŽíIqW6Ä îX½œ¾é˜Îø tϽó]â#Ï7ÍçôûÞ¦›”Ç,…ëXœFUúç%UDÔ¹7Âc gº 2‘Q¾à „| ¼´‚¶•c™A,3¾}Ý‚Ì!Ë•†HʯÀ4è‡P`d8©¨·erR,ÌÀSë¥}^arN€%‹jzmßr A<1‰‰8ùóý¯‰‡ŒeÏBžÐYˆãÜî É+ñãuáL ži‘,1Yj–°,cÐØpëq,mÈù¹‚@Æ12–fò!â121K6ðŽž,3+@^‰üŽý§(ÒHf˜'‚L8\æ1O´jÁz%‚>૜EÑR¦_c†M†5~>|¼¹ͳX$LãQ¥3Œ‚šù2Šäš¢R°Gy²ÀV0‚\S™gŽmo§…8x $è”Ñ©’X0ͨ %·åïÑ8½Žå"LzE gYëtÑ£HY\Ig¦ aâ©”‚E0Å«”‡×eÌâ¹5úV;Tª\¡Új§¬¨«lõþ}¿G"|ø% µ8üІØuõ¯"„¹ó Ç›$ñT$i®çÍyó BBd’};'We3À)¶E’cK)H¤Fö·uñNöµ¢JÅÓ¿n¯Q.Œ´ìBëK˜Ìôýíìjö€”mx…%.‘€«™;oÖ& €¬¸§ëбŽeyÚ5¾ËVÁúÇÔÇÁÜ™;h}Ö›7]%þå2¬î0"þpØE ›ýùoAÀO—¦@œ¡ÛoG‹¥ 6ä:XUp[ Zàc¤ªGÍO»ŸÄçG9`,»`7µnoîv ï÷ƒ>+¤õ<¿W_ë“Dœ% òÔHÓv挺°% wžØû @~kwófœc£¾8„tç »ŸX•Ðß;’sõà"bt©T=’Ë4Bé"%¢LÛ4¯JÇU‚ÐGÀJšÁP‹xsL+hssU¡*Zí¾V܈õR˶³½¤ñ¾¨ë¸0ËEÁJ®íÁñ¡[ÖV¬ààvjyTQðŽ@U%2?a˜ÏÇG™†áì0RLÁôŸÉ9©&M¶³Cï~|rhpgè…ÉÁÀ¶÷qGÂã¡q™uöۢʕþïv`Z’õÑ2]_vÆ£r©éŽÎ½ACüïwÍ^G7_»ïùð‹ ÌEËhË!nqY´§Û¶D¸\à:õQñ0 ,À¬èáMaîŸADæ×ÓÆÿL Lóendstream endobj 5744 0 obj<>/XObject<<>>>>>>endobj 5745 0 obj<>stream xVkoÓHýÞ_qÈâ†ÔÍ£-…+´mA¬Äci€•0ª&ö¤°=Ù™qJ…øï{îxœÄmZmR%éøÎ}œ{îãß! ðÒøˆÿÒbçÏÉÎ àpõa.iÿ倎ã1Mf4ÐÑÓa|tô„&™—Ð$(¼~ý¾;ù¶3 ½!޳Õqq-–ôœH,/ ñ]&Q.˾]Údw»üÌHÝ#ðÐH[å:KyõáÓE©U™&Qê%»lî.Õvy1*´q"O¢ å.Qa.—êñã¶‹¿B€îïÓ[}E‚fòŠœ´ŽfU™:¥KÛ¢«Ê\•’º?[Ǫt´0ø¼€-›Dé\êõØp²KmYF˜å‚´}âGWs•KJ"¾ûE}Ýzåj{³$êxÉnöúº6IÊNŸTuý¶û|Ú`²Nº‘®2%©¶–Fn…Ý/f_ˆœr […'—²ikhÖ §Ò f)òJÚ/ÙO꜊¥Dl7ê»ÿ>¯¬à`;é¹ÿ~£Ò¹Ìs~8ØBàËoAëàëö êà»>Æý—ÄÿÏh±îÇ¡`¢ÏsY’›+K…Î*$ ¿R],»¬’®ŒX,dF'k&Q*JšJª,ÎU ´ÞK““MZ8–f:Ïõ•}Ƹµkuo4ŠÇcTná6qvÛÞ¿ d¸ Ò a®;(Ÿüúã)´ÁcÄ5éY_¶IÏÖž=Ûäw’¼mezýÏô^XKʑӤ+³C‹§ð»6°ÉŒM?o«~%× iftA'-åÞezñpÚïp]ܧ4Û\Æì·®\‡§4­(0:l(2Ç#ª©O5©ê gÀ˜ÑA|ÀIkIÁwI‹\¤ fù„V…„að?ýΉ"™…bš@8­ŒaYo“e·hX ‘:iÀËÄE©.@ ü[ £Äô­Çñd÷ÍGµƒ‰bbÒË%” îÖ Ð¢j¼ÿE–1ùƒQ¨c‘Ã7p¥Ôî‚ÿhñFr´2‹é¥6T`¨E.[®nª·uMÍT «°ÿ‡ÓdçºÊ3®:ÉiÌ *«bŠ(\ËFÌ|Æè›â¡ƒÔ¹nT—Ú‘ü‘J`Ê&ÖÊU¹‚ÇRUæõp­+/r•*—_ã§“e}5°Á€Æf^M¾Ð<2ñSY©7wƒ³&goO1@wë #*Dj47UÞß_ºîz! ±ð#¡MsEôÞ}œ¼ÿ8Ù2̸tÔ,Œ,E<dM{ãÐ]Ï–gÔømýá­Æ²ß£³5Pu…L¯±íèé7™Âµý­º›)Õ¶¸Þ8°A€ÆÍq×ò)+ZbËpÈ‘tý$zý Áõp_ïºÇ=íÖ C徎2…ˆæ;[Ã_Ïë¹´ÑcÎuG é».“I«Œ¯îj «MØh¸#&‹PLFL+T„r(ä@EËíŠäQ :Y!Êz LtÅg\ÅØèbzÖ$ÁS–%j ®šJM úpÍËÀ6Oø;g^7LÙÚí`hµ}x'&¿¥óϯ_q|Ž'¶LWÜßz« èJ¹9•¢ôè]åNýóG(ŒÆýfÄåÍöSˆç84ÉáñA|8>¤£'ÃxXf¶¾7ŽtªS_ÌVŒõ¡–Þ{RÓÑO!è Õq²ëmà0 6İZ¦XÁáà(°ã£ŽŸòÑÙdçïÿ8cMendstream endobj 5746 0 obj<>/XObject<<>>>>>>endobj 5747 0 obj<>stream xVmsÚFþίغv#Û ˜ÔÍLœ:|IÒ†Œ§ žÎ!æbéN½;AhÇÿ½»wDÆtb{ðI÷¶ûìó<Ëß­DøÛƒxHIÞz5mEa„/·úºãFa Óô#>ï…Ãá%LS·*‚iœØMÁsV̦ïTig§ªržq8{ÿiúáÓþ=~iEÐéáú4€êçXsSf^€Yý%ù:WÚ²lÌN¯ž\« ·r5 ªm8;² ŸÞñ¬ÄùùU}cã÷ &2Ñ<çÒ‚æ¶ÔUâC§"/(i€³n#š‡ê ÁÀ\º]¸á˜®|f!ašÃzÉ,Ø%¬XVâØ„0¹“Jó6ÌK ˜X ,§{˜ÞàB-bÖ8}‡¬mYæîLó"ÚCxTˆ)å=μ‡XÿDKšpí¥ôN­1¸E)+”¤P-7„m qÒ¼ñüÝ¡h\þ ¡q‹]« ¬EIP›Ç€ DNÏŸž®È5gš'{¨M°æ YÎa®ì ¦ql¹6ð¾´o¼$ÜÌZdÌ9`ÈÞFÉ¿ /­þù±Â0¤ã»ãøÐAÞvúq%âàfɱ¾KavÕÆq²Œ§mWG#ìÊG,gEÁeÊSG $»±,¹‡Òø7~^ÞHý)o–jm ,€Ip¹Éú$¨±ÒÀ¿²¼ÈøÏ>òoí§Óï‡qŒf”/5pË›Ëv/~œ{¡ Ì£Gkp×K=›É£f9ÑT¾¶7Ȩ§O펟EX#xQ#Çá(Àu’pc„¼«’3V— z ‡œçsä@³ T„nÃD^+iDʵWÊ2µ¦cRfâZòÿXü˜ò…>Nþ| 0ªåݖ̧«£žp ¼Q™ÏtÂmME£­…?ÀX)·ì³ ß‚WÀk » o&¿¢ ¹!›¼—è.H†š;K&Sìä™Î-‘*uÖvh<ÏÌ–7mÊ¢= #çµbp ú+ÝUà•³{î-ÉÓÎן¥%³Mˆ¶ÅR‚ÜÉÒ õg›º!l¯©£õ¶&и‰¿´;I®€nr¯ü(ÖZXò÷6F~äç…<‚ªu¢â$)¨ìÚïZB}R–JèKw ¾b¿¤ Ú,H÷è üâȃ£óóƒ®zÜû,nqƒoº8Þ?µ6EÏ=÷t!ä=|…ÄgàÅ_FœG»|üDm^Á–¸tÍškô¬Ä7ZÌ,ɘ1d`è<5Æ…V+2 [0äž09Ø“-‘@X'Õ­!9NÖÕwн6uí ÍWB•·,o™õ…UQï0MÍ2ñFJ71‰ÒØ 6וôŽw¸ô×ïþ¸õ•ïŽGˆ½Ñ ¼ˆ/`8ŠÂKo™$NFðF%®3jï1v¿ºsé+ç\-®:ÁRIs¡U¾ë´õ"†q¿H¢•] "zõvÚú­õ7¹ @endstream endobj 5748 0 obj<>/XObject<<>>>>>>endobj 5749 0 obj<>stream xVasÚFýî_±!ÔÅd@€ºýà8q'Ó;­çCÈdéK:åîf2ýï}w’a×õ[w·oßî¾Ýï}êáÝ'l?ArðvrÐózXÜüQs:¹êÑ™çÓ$¢AÆoúÞx|J“ÐíêÑ$h‘H ‰ó£É·ƒuûX íj$M[‚~£Þ9 ú•šý¯¡Hì—ããéýØ?€3Íþgñ'š"ÍrƒçG·þ];å¾\ ÉZ¨ ŒÝ_bl}Zð”47F¤sÒFåɧ„'3®t‡Ì‚; ‘œ}ãœÐÄâ[ãŸÖyÂC2’fœ]SŠ­IF´dqÎ53C ¶Ä¯±â,\c#Ì2]rexXáX:"%gÎ05ç†b–Îs6ç½åË5·›…(AÙ³–ù«VX¤Årål‹Ì:ã Ë Ø‰Ô¦BÈd&RÀ_ ³pvK,¥†HÕI¯ò ã,Éb^p³»D¹‹2Å—Bæ¼FÈ”V2CKL8¾J¶öü@ž|þ²ïDÁ+x¾¤Õ‚ƒIK-§Fåt£†±rù «ÙÚÜ ŒŒJÀ¶ÍçúÉÕê#@*¡;ÛHù¾wæh’«ÔfÍG®bR<°4@ÔÝm—”I< ‡êÎØK†ÞÐ^sA‘âßsŽÊ (×–*|¬k·Ÿ>üN ±5 „ yÇ•’J“KÐYø’ˆ»¹±ƒ¥!«`x´»a:Ï2‰üZ˼ÌVœ‹ò´žKâD†"Ö9ƒÄWs$~ЧXÜsàú—ÂË]!èžïCÂÖRŠXN[¡Ìg1Ê¡CåÓlóÔþ¥à‰ÚêÑ1Íêµþ|i_€Ö$¡‰Ð.ÈKÃ\B–•´uìZÚ#Çrµ ª”ÈÌó¾½.x/¶V´:}k2 ö½Qss†ÕÓG«ÖC¨ê9®|½¦›ÜXáqbR»ÙQÙdæ¬36Á›;$1 8RQç1Bq}ÿðÌÀ;H‘0 ëôgƒ’T÷Ó£"j•ZìIãD"Ëøºý…T°m®w\ʨb«¬’ Òy°€<¾ 3~*‹M EøË¤hwù:ïŸÈŒÛ»6ždzYç­&ÂñW·Ë¿nþ˜¶Š.1=zâ¢@Iv?m5øC¥‚4íø6¦ [ã¨ÞZ¨D€ØÁÜÝÖÚþ1ɺ¶  ÜÔáaöC}ý¥pK–6êó2Ô©õ5PWpöQ7ûØrXl®ÿVÑ€^ŠòÞÊ s³È{ÞÞQûé°«ÿI¥^~E»N—ìµ›ýý@=/ ×rÕ±Ybõ.s%c% ý ㈕3¤rn´a›ä¡|AFÿ¯ª¯‘ôtuoeðm%Û Ö¯j'3£Éë"¶í^®¸ýQ5÷¸6¦E“‚ì§¡í5öºí¬´Ó¬n‚€ÙÅâx ò Du¾0¶§§MO3…v$«Ñ¦ê:!7i¢Cˆ†UÚM»³RvË~‘\kt§Øõ)Ê´™ 6¦Üüäz p\ÓÉVÏ7í ¶SH)êgåü4è ½‘?¢ñÙÀ;³9mp×÷zôN®Ù9–Yìížs¬£rHåÁzTŒ+†I{xÔ{þ£LŒ†}»ô~rðçÁ?ù]‚endstream endobj 5750 0 obj<>/XObject<<>>>>>>endobj 5751 0 obj<>stream xÅWßoÛ6~Ï_qéª$¶ê‰›nèK³e(еÙâ¶`À`$ÚfC‹*)Ùq‡ýïûŽ”äÈq³}$–Lòî¾ûîîãçƒ>õðӧሓåÁ«ñA/îáeóÇÎéÙ%Öôh<ÃÚÑ |Hý÷øD*+èúãë_§&[I[\v] csó©C+£R:>Î Û!·Vói±ÉåTe3CÇŦC¼{¦ÅÜMŽŽÆŸž]žV†=êNa)ªÎu$èJZM8W&…åµ_Þ¶ˆ¨0ØrA¹ic/$YéJ]™Q§Ä»ì”ÉH9ʵHdÊ.ÿmµ‘´ID/Ä£kÇh¼ëW±ÙYÁ–¿C€ýÈèãB©t‰Uya,¹Â–IQZùàDמCKáúBd©–$­Å1ÉB&·*›^’AÌ–„ËŸc ¶ñÿg+Ii­Ì íÃjB(³TÎTÆ Á@–v…‡<˜•É»\dŒtLH¼É¸Ü]™$Òìëöùw<Öéí2ZQžq¿‰[¹nßÅ6+‘l&[&×p5ñ µ‡yœâ°…P,@œ…pt#%x–©B ­¾TÉ2IkˆÙÙ¥ÏC†1xCí2ÒXtÚ˜5ˆí¥ ñ8ñ‚ã’7@„w0K;>Wm[Ñ×H)|u‡£àfaF¡Y“£S( ‘kÜýRÒ~"z6ÝãÐ+TBeÚI04K 0Ó¸ŸK²r¨('^"ˆËÛ¢ÕÝ_¦ã2Ó”-'¥ ‡r³³KÁHܘ²àã[/E6×àC&–Þ&›OE!Úü·ËŽ­„–Y"ïˆ\8ZK­ùÿCC1¸þkºà¸3N–.NNZލ BVbºDñŠÐ—€ÃN¾/ xxWwì¨ÓPdo#câ–®ZoHø¢çváÐ$´6k÷cmá<ò¤ñ`‡xJ#ooöSí- HÍ“fwôª,/‹¾ªfÏäˆ~˜u|úÆ^ý2ͧ8¬C=¼ù]ÿ­ïHôöý›7µ ˜çÖŒ9æVô’ÜjŠ~°4¶zMŽêe<CŸ6ÝÈ­:´ß ßµqž‘ƒa<=çS^ƒï¥È¿‚å”èB¯Å†ûÉÇÒq’™85]™68ˆVÂ*qƒPãytØŸny¼“É|y'–¹–'æIeg!$}žè¯VžˆÈ§êëÉjåê°ß¡–s¤êñd…,üÝŽbÝ::a¡;|‰m§-*‘mÛ‘1¶æ†ëÝb» á@æDÛ|DK‘XƒªÜfõÿÇõ¾Ç>W“#_ ߀ï êŸÆPf344íÁyÜ üãteÍ݆-œ“. rÖhG(ºøüœ¹þm]]æ­”)zCîŸÚ(²¯ß7G³èj¹’šç[iÑœ½Ä›A¿…B'ΡÐÎÏÆÐ“‘……š/ª­•ˆ4VAÌ ÇÍ~VPÛ6„ÉnŸ¬ÂcI‰¦†ßÔd’n7¦ˆn^rUòa‹š’wê63køÇ*Á-DjÖ0$Á‹ĵRÈ(IïÞÑÚŠó’=Û¾ë [KL (¾ãi’]ÏnÅżD¸a¥ôÆ0˜±DÞ*ý…\C¢²ìïFœ7ÎqÜG–¥VK•¡·ÔY®Ç€Ïó#Z\À¨ÂdËLZ¯¦4£€éõŒ6¦¤µÀm€£„<äP—p”'1×ëNõu3ãn&K Ô”4Š—LÎH|CÝúk u““êuMµHXßcÕ¶¸Óg>. òšM|à¬Î+n.ÍŠs‹¡]a¿—ÑUÖ¡»pÉ‚tÏEr+æÒ …˜^5r?S¾Ú€~ÉõR“eEJO—&-µLžÒC^ÖÏOk=y_|„¥>'ˆ„¹˜ÒZA3íIÓ°¸ID)tX¸òœ”ßô‹6^V  ç “¦pV]ÃO *Ncǽ2öÂ)ð(cŸqyò·(× ¬R@ºâ˜Ä»É÷–'ÛCÆ ZýäÝf:ú›*˜‹‹gÄÞ´…-Ÿ]×—;/¥=M“m ïUÓu™çp¥,Ä*ÔDO\ÿ^Ì7õK3õ¯“»ÊrEë /hª–ù c2>ç˜èDáËI”š’åÅ]]ÐÂx­>}©„Ò³ËójôÏOã³áðÿ´ï¥;ÞÆ=úÙ$eÓŸØTVXÝ}&<ºÏy<¢«p£7]ÄÎkÏz£x8@£Bß9;ð«_Æ¿ü_{<endstream endobj 5752 0 obj<>/XObject<<>>>>>>endobj 5753 0 obj<>stream x­Vmo›Hþî_19Wç„ 6‰›ººS’ ¹Dj›;ƒ.:•E`ph1¸,ø%–ûÛ;˱aÝ^Õ³-‹—gfž™yfw?µz Ñ·ú€ÿÜiëÒjiªF«¿dÇל©:X>ô5¼ê©ƒÁK°¼¥åv ø|þÝ4NìŽ}ôúÈúÐÒ Û#€W¼8{–ÊJyÚElòÛãëà>t)TW׋PûGŒ`‘8³z ˜÷·€› “"ƒôÁÃ0^Ѧû@wÝç‚ãºÈXœ€ŸEnć‡ÌM‚ô ˆ`–à<ˆ3FÆ¡rò»iwû}Uש^G$ ¿D¸— W‰AqµRÊ«§z1æqàñ‚ybŠ•‹Òí¼Ž/<‚Œ—ã ¦vÅâÛp*ɼâ5w ¿kõ}±Vãˆõô}±žþK¬½zº‰¤ŽDÖ,‰—+pC‡1”“ `äPIj¤.†Rª$iˆ¡àOLBáÂà#’uÀ†_ÓÌq?: ¸t¦³‡CÑåÝá8¿5/àWø´°;%ê;¼»gŒÕœ¾ÃË7†iWo·—ÆÈ¬ahÐHÔ,{tn ëÆðNWÐfúdË?ÝåÇÕLˆs'™0Bœ›¯Këy¾B¸Ãáöôä†õ„¸ÓÓ,‰ ‹<ô!ð‰ÝOtDèÙÜ£}$3£Ö1&+pP+í„\^»uîqC ôšJïØÐÐ4ߥ–/%áA¤iV$'ÈÚvá^9 ¨ÑÜ-yîÖ•aZ£»$ͪª&Ê0þW{ßý-`ŽÝyqsaÞ¼•l«Á”•÷pÝæ†X¬\оµŒÑ…u72‹Ò5sÌ{†Ë€¥Ôí*ÛGâ¼å¥ÀI"µò+ Ï KVÛav5‹xmX¿ßH˜P9 …)m?ÀÐ#¾raóÂMqú€É˜ï0„:¨4.:9n¯s¾ÀÕÚʉs¤+²üyÛS¥ðݸÅNUw‡{-èRÛ$YqÛJ²‘"ò‰â–Äsïð÷ÛcЖ³Rx¢Í|¸õži€=žšNÊæ>Ÿ8 —͘%ôy˜LR±!©XCJ›®¼Lÿƒh·”èáGº+SR ´ NÚ õ0¤­nÝXûyw¤~«RìiÆñõYqšë¨§ú) δòÅÏp]]Õà*v³)F©Ãg<8ýºûRô’ޝÔ>˜i’¹´ÐFyÅ.+và„q»Sm ê}:ÐÒvvz¢óG†Õú«õíøendstream endobj 5754 0 obj<>/XObject<<>>>>>>endobj 5755 0 obj<>stream xWýoÛ6ý=‘µ«²ÚŽcç£i‘KâlÖfKŒÃ<´DG¬%Q%%ËnÑÿ}ïøa[i4 ìH"wïÞ½;}Ü9`}ü°á1ýÅùÎÅx§ßëãæúCß³ýë>{ѲñŒ úìøô w||ÂÆ‰]Õgã8ú²7þ°³}Èp9c],ë†~Y4âqÊL¥ë¸ªµ`J³8ãÆ0iXÎËR$L•bœý)tÆJÏù=–ÍX• fx.Xãòòùs«ÂYSÚ0^$,[×8aË*9gð7ztã ~Ñá|2ÌaŒg _ëBÂv ÑìÚ3w¯FwãÛ›v_[¦Ã-nY%EÒr$å&eŸf6*à°¹A¨Ô˜"q,€y•‹|*4[p-i›!xø¨²`›8 s©n[]tÏ?/¿ÀôIï(ø3Yæ-˜–‰§ÖÿIÄ–gçÃNë ?«³óÓï<útvÞ|Â­à ¡æ|nŸød Ÿ8Ïú|å+Ôk¹BË}aM"Üþõ)£úõº2< º2öN!K7ÓÈ»i ¡M*K2¸Ñ"Ë žåÐëÚ“ Š¨Ô·„jB‘4JÏén Zu˜¬¨ AÈõÊî±ú„¥9/H¡Œ‚4å"Ny!MN9TÎ\é±ß…Ïl ‡8ézg¢Nón·kê²T`ùJÕPÈ õÉ2‰®Riç³gï/îûý½¨&Q¸·@P š,±œì±ÏÁ!ËÆ@'ZìçÅ¿ò¿4ÇÿÇ5~ ×6ÞV|Py(¦RÙb·u¾QÅp€òBAä´_ßcw5:ÆVô¹¼O+ˆÚZ}¸Ö¤ÍJ‡X,¸™4•È…­eÃ&äñr²×coUCí£ÒÜTÎϬ ÉÚm)'¦¬ÃpÙý± ôß;à'Q¢jâeâdÿ½üŸ¾›ˆuÖÚYyz(FËΪc¯Âóý}v m}Ø/NßÊù¢}Òãù¾@ÂÖØæi ê°iMø¶ÁCÜ:R Φ-¶KjîcmRIý »Öä°Ñ-¡Ø”W)¯XÃÁ¹LC’ÐðU¡™L¢=«Ñf(ÿ*bøGþ/U+,7´s °Ö<[¨ðÍÎý.ÏÃŽm£¦²aQޕ֔ 8-kÖ¼¥¹™©j%ŠåDCLm‡¦õ{ÒL‹5ÆRT‚-°uG$ÓΪqº–Éb­p—’[i! )­åö%^rhÀTƒ¢5ôrBï-ø´ƒRÇá…kš¡0Q‘ÛÏì¹ýÂ+Ï Ø;±ã“c7ÆQÕu‡½>»RqMÓ³ŠðÄ{§[Û=q3Ë#âQÿ¸7àí£øÑá!mwþÚù6;Æóendstream endobj 5756 0 obj<>/XObject<<>>>>>>endobj 5757 0 obj<>stream x–koÛ6†¿çW` æ¶êKì&´]œ"Àz‹³õ‹Œ–(K$ª$eÇ-òß÷Rr*ÏI—‚-ËÃ÷ðëÁ€úøÐhŸ0?xsuÐú¸¹½è%=??¢AŸ®bØNNð%rëøvÔºÚ$iI‹ ™4/³ E2“6-–dIjñE†–b­r÷ûéÕ—ƒççx©sØ9üðùýôÒßlÞÒ¡D˜$ «$5„O¤ I•i<îx8»˜ÁÇ®‡\ÚDEAc{Œ8þaŸzÃa0áWÔù…>JQ¨"IVQ˜ˆb‰€·©˜DQ'ÀŽð0Guž¬è%rM#5¥çÛî¦ûmþô÷«Þ©nÞÁñ_;Ìž‹gL&/Øí•"~­RýPÝ}|ýǧ¿..§mÏò ,¸zò§Åx›®dáKÒ®Åi&Û©U(€Oþz)íùOöUï´ͥߎÏe>ÚfþÚÈÖbcº$(K­Í$"G´@GR4û|ñ0HC…²TjµJÑ9-c©eâ UÌ]—–B/zª,C‹RUtá„D´0Œ(–ÂVŽ˜¬<]&¶IoȈÓ"â÷UA›†Ââ¡ xTðjjªNhkÞ½á„C>'Á½—†Í?8ðM;o¶=‚ ¬gUY*òai-ÁüJ"{ƪÞ3n%SêÆ &7l™šß¼¿>í%ÚX]a³}A£†ß›´¶Ž@\|ãH·qÝY]=ºï_M ëÜØM)Ûwí:ìôÿ¢pÉ¡çFzÈs™/ ,„=È*âCˈ©tFÞÖu2¾„¾~™–"Úy  (DiªÌuín€s»¡0Æ@c _D÷|;ðJt&TZƒžlÓåþ` ¹Pš4öæÏél6={7}÷fz9k§é•ŒÖI&´VUŠÐÏûvÒ¼#2©\§6o9Re.Ð?Üdeš?}¼å¥oõ¦çí²ƒu«\‡íh±‹ç½ŒhzyJÿxR~íî5þÌ$~ؤ֋ûÙ²ƒÄ猥 ®DƒÃvŒlèÖšz?QÚ)î6Š&2¼Ò…‡K˯•ß³q*Ñ"˜”YX×øHY€×Á’ʨÇcЬX`§!(D¥ Ô:ÏÐ(÷ø—ÊØf‰QvT™RÑ}bT¹ŠR¼Þ«´“ 7ÜdÚs„#XÉ ”™ZðÈCK•Rst¸_ø¶•¦Š¡€°~œ¡zŠ0”Æm¹]WMê~ú•õôkÛêû³'eïô{|‡ËíŒqšhcyøä»3YÝñò¼C·/Oû]Ú¸ë7\›yÉjâ;ب­Ÿ™ãff:ÍÓG·§Ï«Â‰ýâë©jÌÐ;ȪÐËŠ«Ë£f¥²·EìhL]e.x‡Ú4ç$¹XBo¸ k2!<“ -qí? s y+¸w RS){ D|Þ©eúÙjÐm$ûÙj¸ß ·£t–ò(¬ŸEÄÛ ¸ñÚ¸Ö¢,1  Ö8pÔ1;9t¼kXq@";&°Éˆï3%¥ý¡jnL±,/ùÑ âv D—‘•Î’ƒow¶ó›†å×ñ]ñp‚t{Í7ÀͶ/þ¿°ZüXÄ=0ßÐ+tÜ€»W׎ÊççÇõitp|ŒGcš¿þŒÈgŽÞ(èÓ™ %nr’Ñ[÷^øSáƒãÜŸ£!Î ˜úã£1?<½:øtð/‘d×endstream endobj 5758 0 obj<>/XObject<<>>>>>>endobj 5759 0 obj<>stream x­VÛnÛF}×W rAhÄ¢)É–c’&uê7Ї*VäJÚšÜU–KÉjà|{Ïì’rH_â¥ggÎÌž93_zJð7 Ñ˜?iÑûeÒKâ?î¾ì‚Îzh2§aBã“A<Ó$óV MÒˆð¼vQþ™|¢ŸÉ)™M£—_›Ÿn¦{?±‰žÓGéÈ-%Y)rZ¥´´y%˽É_½„úx;ó:¸ëuð‰½Þ±/¶ôÂʲÊp¬eêŒMOO3ã>¯¬ÉªÔM£· ô¾³VºÊêæ|Û÷ G:8;$†6§> ÑŽêBD“¥*i^éÔ)£‘×*©,}’ƪ…ÒH´y½O³Ê‘YI+l”&¡IeR;•¬ZK‡p'4r86æ’ŒFñI<¦s½”V9¡SÙÆÅ†‡ñ!›^ªb•Kzÿú5bìÌ @—Bg¹Ì¨*•^xÒæ<>Ãèíù延󈄵bË¥H—”æ¢,i%Ò+±1KòZpÔ}RsÚš ¡ÖÒG˜›<7Äc—|ÃÈ+‹üÕÏQ+š«\ž6nÉÖãÑÔË¢ƒ*—b%ËX5>k½é‰Áe÷`BI.'µ­ªY®RŸ"§ï­›–X+ë*Ü}f`$Qe)¦Ñt NÚ,|ฤ ‰ôpʨŒ=”Ò}ÎM*˜¬Ó¨z½ß„ßv{㦠"äø^ÙXO)$Fÿ6çp~ÞŠLU÷v%#þÖXw¡ñK~:•k&;£VµÚ–÷fzù¥Âü÷LÃù]¦¥ú[>”Æ·Æö!ƒÿ+OæpGÍ -AÖ¡f¬Í¬¡è×}òâ°±b…ÂÕ=¿QyN)hê:ÝM©É~ÐÇA/aÚågÉé§QèµnâØËâ®}Oº Ñžê0ÜÂÓ>ZÉPê'ÈjÆ\(¡°^£²†rc®¼”¡½—&+ÉÌI@r-†E•‹ú>b ¨,¤=%ÄwfÜÒ«n'v(Tûî!ê:ëj(@×Ð7þ팮Ü–Ýtô¦¸ã±ë®4´‘¯@¤ÐXêd1\x7è ÷êÒu0C²5!Yíq¬ˆé3“Ê(rĨ‡_ÀÅ®Yõs¹–9ûÛ¢z"tâ"vÇäç=Ê=“©¨„´NyjŠ @îP×’´”F-²óã¸À˜'l"×Û[¸éÝ;˜oñ…™ˆ‹iA´±2¿œÆ®#Ñqž"ka•©À&{Üké,vž Ýܴΰ^8€Ÿ›£A0î tÇ«ƒå–“)«Yþ¶…Þ_ ‰Ý¢(”4®*÷©ä,·˜®•ç¢E!µ=¤àú~&<¼–0°sXÔ|ÓÄÿÍlpÓ-ák$7Âj¾Ž¥à á£CO9«ÖŠ÷Qk0ƒA¤sÝ‚yÛs¨Åwû2NP!‹™´Þ¡¼vV¹Âizµ… q¿*|,Ò( _ûœËÊk0l7Æ^a֛ߛz &‡ñÑèˆÆÇI½Öa×éâ„>˜´b:ù1ÎP±‚ÛþqX/ü²xDžngõvêWì£d†X+±WŽùô¯“Þï½ÍÈnendstream endobj 5760 0 obj<>/XObject<<>>>>/Annots 2873 0 R>>endobj 5761 0 obj<>stream xVaoÛF ýž_A)ª4ŽbÇŽ“¶ÛÐ.mºÖ%öÁ ‚³t²Ï•têÇ(úß÷x’bKñº5‰]éHùÈGòëÞ€úøÐpÌ¿aº×÷ûxÃþ¸ùÄoh|Ö÷Ç”BÆÔ Ýîm=¦t~îŸmý:Ù²å š9\½¦Á)Mb\:¾¸ IäîêÓ$ô†CÿµNèHÅk•Í©XHÊ~\S*‹…Žìád¹wr5¢äÙÂñéÈÁ†w]²”kkÕ,‘ThÒÒáÿ0rû÷õ'šËLQȨ²yb"Ò«ÆtJËwVW xw…÷"–¢( ¼ýJ~?8l{áù„ÛWÚ|±”¨/’D’¸K5n6,ÛA(Às!z2O‘22,Ôƒt1n4ÜpËoÒHŽRUiŽ(å£pßv¡Wì:¾8rEdu*é³4 ErVÎ)ÔŒ„v~…:³…)ÃB›7M´þ=eHOýáO‘wòŠ~—ÅKK©@XŒã–*é¸z•kéök)à]ªñàgÚJzuâ‚G¨€rê6’µ^àEºä¼­*pžJç[Ë‘-g”Éuߥk:È¿Ìég² o;Š•€•I ‰¸ðÍغ¯|¼w÷ÁásµÜ¨¬ Ûɇ77´Ù`‡*½û652¼6Þ}‚lÿ¹ „ŒœP¯òRÅHL¬2=)wÕ¾·"xÑ<"E3ÜFý[K2’*t™}‘vݽÏ÷ý–ïNÀñÕ‘,Fipy\øýñ9ûº"KkE§ ¥3‘TeÇÇæºlu”÷®cZÈCÑ–y®MQU¨Êè%ž½,Hfºœ/z¤³Ebu‹Þ¬Îõˆ²†WºO“Øá^ÍeañÞJÃt‡@]ú•GOäöó´í£G±B†¤—Q‡cêlíºˆOf­Brý;‚¹ S5_4s㈒5hºÀËãD>È.ÒÄ"t!Üp*.3PåÓ•6MUþ˜“Zݲ¸/ŒÈl¬Mxש˜ƒn*íQÍ£Çéè¿›z®ª¦›büFVH2»Ù_Úáoëºg´Î½ÃàE»™ª-ÍNWÀmYÇN0C8x ÁÑw÷Ýe† œ0gSQŒF· °êD@„EDûoùû'Á¬::êtÚÑF6úËZYë/wèï²€Xع{ÄŽˆߌ¿%vüËTÝM—ÈK rÿ‚7‘tŸë¦å·0m0;0R68<;o[¯ºË†«Ó‡þ¸bú5Äܪ]èu‡dÇ¥g’îf1Ï®-R8úl˜1+URf²æÌ®D¯jö,d‚*ëð¥Ð±óÉ3ç§+Ç ÓÐJ™Z&?ç«®®Æª+R¢étÐëóÏ]¯sBÓ~Ïí>/XObject<<>>>>>>endobj 5763 0 obj<>stream xWÛn7}÷W y-Y¶ì¸èKœ¸ÈC‹Рť´Œ¹ä–äZ‚þ{Ïp/ÒÚQÛ°¤%9—3gÎPÿžLi‚ß)Íæü'Ë“·‹“I6ÁÃþŸßÐÅÃM'´Xcïü Þäioäh][µ³!;[|>™ÐùåÖG‹BÞ »Q¥²‘øcØ•¥Š^KÒ–b¡((Þ‰HÖ‘tÞ«P9›k»¡RÉBXJR_tˆ¢£J„€…X¸œ¤0&Pî¶)m åuVª6é%#p¶ö®¤ûׯÙÈŸÊ›Œ>XXóQËÚ?&½&‘6HÃ> h¥”…ï¨l®rŽ˜Òr´ÚµO9J΢òîËŽÒÁåÙ˜!©t000ƒp¶ÚäažtÐ+£öÁI—«ŒþÖ>Ö óìž«C2"ø¸R!dŽÄ¸­ Àº¬LB]peZ°a E ¡aõîüF1 OªÁ¡9ü:úøéÃoü*òµb¯(,@ % ›S)9@E^™ä>º‚¸e8¹ (çÝЩ!P¥C¢=a2ZÀ§,´B@ÉçÆ 3&«¶½=& •k¯dtžé§{ô.¯%@2ŽkåbÜ:}â€^‚A‹bÈ¢ÏnÕØÛGæ@»:ªa±‘e4»1) Ÿž÷%OƒÂ_½áÕ¶^ÄA.dÞ «÷Ì —ý¸`‡´ë* ÇÌívX),ÓñÕ¹@=ïFb²g8xçq^pÎd4`Q{”êÀMF´`¤‡ :(웦b⣖*Oˆ>Z·¥-€·š´ÃX‰Ò“]åw©¤Ò•+ÍþA}Ty@±qOŽ6ãÄÃ{ÚzQU@±×3Š`r€Ì ˜¹ëÞ…pnÐµØ i…‰ ‘¤â 1P?³Kýuñð†X•XGÏ/ç,O³Y6fSzoÑË|ª§WüPx!¬Y+­ªßEk%bÍ<‡êÀz*WkQ›˜Ú¦†õViçj*kˆDÓ¨[ÈnÛìà(ŠÌ£üZHè’6£íCJyÎËžöfOÉU ðÖÈ«Mmj6€ ã†ܺwMfºÍfŒÅ%ƒq™Ífø”Ú“ËQoû×ÓééòŒ‹V”)†=2çéü,›Ïoøü'4 €XIfKg CTK* Êo”U^D•gôQI žñ†ñxÕB¼õér8}fÜÛQ,x¶…–EdzFÓè „V¬M÷±,4mÚy;°ß¶'èi4ª»1n2B[à8TJê5j+ª ›5 ?]‹‹‹¡}œ´F×r7t:žô$MЧÁäêÛ”/ £.±!Œ¿P÷ÓŠbbó÷?sÃò™b¡çº|¿ã“·µ~y÷Q&ýƒNaì¿Aë:>½¤BíYvÖÏ{^(–ö¶àžK B@YØÇMTÇúãÛt䜎å>Œ;ïîV§íG“Oҵdz\¸øÏk…ìk€I U…+ŽðËÑòlxµx×gÆV˜àxötžpÏZj$±€”nŠÃùœîmÜ•kg0õ ˜ãÖï[á›¶æ¦}ÄíjËQ›Húskë@Î*Ž7ujܺô×=ˆ _ØJë˳(ØOVh××A媓@&PF¾wç#în9‚:#w·<V›×»’<9w¹ü`W›åp×ÝǦ›0ï5‘q ôõ§B„ÔØÙoRkÜ%"Šš4W·tÎSŒùƒ9§m;Ž4 ·o¹k¦Gç¹É¬ò3œ~ß!£´tñpÛ~Ñ™Þ^e׳kšãõ¦™L¬ïç³lBù;Mºb0AÍîó›&§4Õ鞯 Ô]¨raø ƒ©äSדy6»ÄUõ½¾ºåGï'üh]`endstream endobj 5764 0 obj<>/XObject<<>>>>>>endobj 5765 0 obj<>stream xXM7½Ï¯(ÌÅ2<#ÏwìÙÃ"‰3‹9lœ…ðe.”š’h·šr³[!Øÿ¾ïÉvSr‚… #iñãUÕ«WUüvr)øs)×wü;_Ÿüòtr1½ÀÇáŸv)o.äÝôZžru!wï/§ww?ÉS¥«.äi>郕™Á?¯Öûµ¯úÚÞß?xÿꯟ¾œ\È9¶=U“ÐÏÄ7VþL_/õ«È¦uM'§üiÑúµüaÛúù¹9Í»ãºÿr×Û‡÷ryE$<óüê6A™\_O//§WòÁµvÞùVæµ Á†¸éFxƶž_ÝLoæk¬™¯âBéV¦“• R¥‚ØÆÌj[ɧÏÿ’¥mlk:ÄHcwãm•mÝ?(ø™ïV8ͦ®‘o½ ó˜¦Âæ°±sgê ÎÏÀhV5ù´sËûûlE‰~ÏœÊÓÊÂ× Τµ Û¶¶’ÎËÈŠ¸ƒ 榑™•Úû`ë=ú~¹êÄ/¸œx}óFì·ÞmMm¿àåpXÄÅŒ ‚å_öùX…2¸,•€X˜ºñ¬m‰ û]+}_Õ{×,ãa~öÑRǬàÚÊÖ´Î÷A\p̪ásZU Iûü1 +·™¦_¯†Ð·ÞÔnԶ{…— AÑŽèÕìúÿÇåŠP]œlߺ¥kL­nS®e?fáNM ýq*¿ì¥² Ó×ÝYaŠ9pŸØ—Î6hVײum×ã’µE¼ð l¢®Yriæ ÙÊà+Âèºñ…ò< 6š»AFØŠ>p6‰¸÷W~G[­n±/u+‡“ìÊloŸ_3ÆÈ1Pª®Á¬Ý èå•Ýg¿t©¾ÁUø/¥ÎÖcúœ‰Ý‚k°Œ„ÑÒo¸™ˆ³ LŒ¦]c­Q°ˆ~È®å…|ñ™Eùóà>0ÝKë{ÀÃ~äPü%Z’Ck6 MñdSø8^W: Føôhï©ìx ’€Óu*6;ß×$g é´¶Q `º‹Ø™ßé£üC€ J”€x*/ÔÃ; ŠkÖµ >eú-©Z£¿æß†_H„Û¾˜y‡ ;.:v-2>ٺʞIך&lL‹`Ô%qÂW·Ùg~ :0Ñæ]²š`åç?eY÷Œîš9r뺗Ú4ËÞ,q]ç—ʪ2³(‚©‘ÕÀ=?ò7¬a%|C¡Ã±‚›9ìs6ÜgZÒcSùÈ$RÊWÐeEˆÖFMÅ-Ä›ZåBÉû©<‹ãÜC~¡e‡LÕà š 8² ö;=´ät"m¢Hb8ipœí€ÃܳÕ¢âÕ Pýó· ht£r‡qÁÁ(åZDxž‘%x¡àϳ€Òxv+‡òÊ0õ"VŠëë>§³B0}ç×ÈpÞ½—Å@ h-JUéYSº-ŠþïÐ3jZåÉ\:ˆãZYP›p2Ã$ jþiÙᆑü“%–ùçæÒ¢›¡c ©F#LêÆÂð¾aúDkQŒ,½¯HÜú7 æcáLŸ(ÇÊ@Ü¢uËÞGÁd?¢—ypð4[x"Ë]ÄÏ“])l„Úèè È/$pgÙØGò# ¬]ãÖýZ¯ÓXŒ„úû} ŽV#fAD§ÿK‘:§¨nÉøe¶Ç…±fÆÖ©Š­M]KnÛ°­Œ¿ìj_ìœjžõ ÷:¨œÆVÂÝ‘ãzp'"Ðc†’0&5Í”ü*»ºI[ôPÔ­tqµN1Ž¡ç¡ÑRzo)èZcÀóA\TbÉÙv$)ë¢ ­øgZ bèxïÀóè(†ˆlÅ/šÂÑM±¶Æ<š™ùW¢o.Àd"1¥æ~òéô˜Å§‚:Ð D¤LÒjÎjd2z%XZd–è_εX!û˜Ðõ.J¨k  áF»™Êgpwë䊇FBYN~U±á‰½6¬€ M>'>³êYt3…S2šOfpų\ˆQýÁ‰pKd<¯lƒ‹ÎWo¦_(º— ’™–Aç#´³.eÖŽ#™£æô§`Ö¬Û+4å€cÛá­DaÝ”¢…ˈ–ÄG¯¦§½ySÄë¨Z!§µÍ㦣 ¦½QÃ?¢n¯Ù¥«¹p,{ŸQÅÌкé­:°õAóŸ»;¨šÙp>®‘ XÄë3½P´¡`UL¬Ò ”XÈ3g¬ñqŒ_yö°1 ðñLÅø¨ÁZQNжíÇ0°i˜9‰˜ÙÛöeÿK²5­„›Ò„ªý”¿HIú,BÄ2¢ò làŒl𽲦T ×l}ÍÒDþé8 Y¬Ô,¶\©Pi“õýÕ…(w|§ˆï-×ò1àšli.¯ÐÞ¶½–ÊH´Ì¨ÑûË¿-2}¼nÐïs²ƒ:òÓìP³ãƒÑªSÌòšŒ 9Ç„P‘‡ìŸ ?¦QiszÐ Ÿ)Ò<ëjª è”<g˜õ'£]±ò2Ñ2&X×·ÍN/Ÿ§5‡š±Úq&óÏ9¼—ü„ú¹3_,x ä­,^8AÖÐ$ò¨€øqiÚ¼‹ò‡3ç˜î‹rËF"_kÕT%MDÔë–sÀHîivzº:|@ùðøéãçߟ'ϯËhOrM6ŠÑT~æ¼0­à©Æà¦Â-ƒ³Õ?p9t…„aôÙgeI˜û^ß­ô³¶1lIù¸øð(<÷ÑyÌ(¨°ýñÁ½èÁU´ÌK¦œD•l@“a`]k³C(#€±•E‘Ó¼ñ{Àa?B‡£r \Ö`!^%µ'ƒóšeîæ³‰¬PQ^0óF/±”ê“'ž(9 ãw(ȺÇpË£Zãj|þd˜Ãå“ÚëÛçëT» ç¤mYMâ5Ú€Öî+5lnøR¼÷½&,^&0px>/XObject<<>>>>>>endobj 5767 0 obj<>stream x•XkoÜ6ýî_q·›¶ÔžŒ=±“¦è¢Mjïènº±‹b-Q#69%)Eÿûž{)J–]d±IyH"ïã<.ç·ƒcZáï1­Ïø_Õ¼¾:X-Wørü/lèÙÅs:^ÑUƒ{ϾƛZ®ãMµøÞFOÎ'M©U‰êo<ÞkÚ·'Óm­î´K*ïåÊÓ«_ž]`_YsñÃùåÕûwÿ¹^\?ÍWÊn êtj}MÞQm‚®’‘*åèFãÅZ]SãE}«ƒ²´ŠÞÅCê”Û“oxµŸ âÅ®5UK­ºÕdMJVâ¬=íLj%ª¤U¨ýÎáAÂþæWlHÆÅ¤\¥—tå©Õv‹H¢ên̦W’´Á~ !TÞդ¦çdÉDRuør1æ1}"sNv­vXüÍW_ùqEÁ¸ ’¶H[×Kºô(¯'uëMM¡wŽ/ï}¨Â-î¨ßRåk=¬:e¹³Z¡ÖîiãyµSûCB™U“t “PDdgqS½G­±Êtº>äËÈ=ö›Ž‰ógTT}L¾£_…>wÑ8úI‹;oðlŒ:’õþcœÅ=€ƒ°æ£~Uªør¹f0ž Ž''ËõŸê¢¡žô{Y…±º êö׋'QÛæž4Æ){ý”¾¥ï>|óà>Óà¾rÃÃEˆþʳ4…«ù`…?|Ž­iÒÑß.þéüý«Wc¿¿ûpýt¾¹<øìâkb´6HŒ“;]ž½àÖëåññò9ßUzËD¢Þo-JÃÞ'èÑÉs܈g~a`O´ ¾O\ÉRŒ¯Èpá.Á/Ö åN¸ã;¿ÌÛwñ–Ì]"‰‚uÇD÷TA·=øܲ”Bè÷zö7ª·)¯5f6Î}AÁŒ¯* ·îÃã R ½½È0eŽr¸Û§ g±T>°˜XÀ:ÃÕéJǨÂ^èª9 ‚rÑf¢£ÆårÜ[{¶ü JµwàWQ”Ï­Rôõâ³’î«ÒgYêF!È—Í-Ë ¤³AkýŽÂÆÖ÷¶FJMc*ÍÙv>¢Î }ü4)>Á#š™†Àèþ—oé_?ÿø#¨ò˜ „?© ~G—;³°uþ§èõˆR–ô9ÌùÁ9GàÍÏÀ_àçâŠjbÕê꣨µˆG %Îê¤Ú~âÔy[8a>'‘%vD — «Ï€#˜ ¬µ×ôÀèIý¦eÏÉVF÷׃x2>Caljpõm‚g±˜JnÜØ,œj–‹fõJàè€xp)ÀÑÀdˆû€MN a éìÀ"¯™á`4¼S¡„‚d©á­Q¤fY¬{/ém.Ga s§xÞ‘|5IÝàÓÌÐüÿAÚéþÇÌK©ß鉪ÄæTbrU*׋9/ÏÇÞ}¡™ÐtùËÛ¿h”±ßüŸtÄàÅvý€÷Óú=FF§ ¢”ƒ‹S¥^† …fÞyÉ<ÐrH˜.PL~@};ŰÇ`‰Kz­+…ýEô1ÄÄËDõ˜ŸÜ™]MÄÁæAEBzc0Ö0žçíŸZ†Ù(z4^Íoh‡°·x¤é]nZÐ0E&Çg¿?›¼þ”Þa¨m1c‰7‹ÜX¯dPûS¿?w{FÁsæ©¡ÔÿF;Lʬ–äôn¼³¨ 3•gé=ÝšÀý*¤¡CÓ¾D{[€mØ<Y—y9ë²l…¬‹÷ö´>15¦d$B‹©YSkY¨ð—”a0ŽÓ\J¨Lпõ0&EÃäy&–@Ë7× (dYªÜo’y„)Þ¡‰“Up¸Ï.^¿œ¬ž/O×§töâlù’E“ýìh½\Ѿ’¸üÜÀa Ì÷½àßÊYjMïvÐBœÏ¶ù¸_ލ@?|º:[®Oð³ž;=]ñWçWÿ>ø/£Ûendstream endobj 5768 0 obj<>/XObject<<>>>>>>endobj 5769 0 obj<>stream x]“MsÚ0†ïüнt’L‚cc ÍµéäÔvÊL/¹{ÁJdÉÕ”þú¾+CR2x°¼~µû>ÚõïIE%~ÕK¹š~òq5)‹Á—?¿¥Ûû9U%­6Ð.ï°hó{,šËÁiÙß³L¡sÉ´´fR{å™Ü†b‡Ûz§] ´QMD@Eê9v®¥F(:úÎÞ@öÄM ´×ÆHŽ>5ãöìe—}•º¾>©‹«ÕÓ¤¤i5ƒ­ËU§“ŠÚÉ+‰Üu¯ÿ2œ(°A½cs ¶jm´ÝR«=‚Îz¼LA^ˆýwV1gTaëãm v9à5…33™TŽÁèg©N˜á?‘m /Úfì p{GB '<-¥®‹ª*°< Ü«!§þ¿ÓÙ¼˜gæ£ [ÒvH‘”mÉ¥(K´ w!ß…e­‚n(b Úá]ÿJÞ¢ÚAÆliïu„ׂVQH¼KÛ.CcÍ;öˆ»Íj¦’2|ãEÊ Þ½G{¯†n\˹TvÚÆ~ì£U=œ‰‹S§´½¸y},}fåE¬üVcúS†\‘Z‡ÌÖEj’÷l#àà©/Ó —žžµmC! zˆ„iË{ +O˜ë(ó—? ÚwºéÎìŒ)„ÄÞ ^«(•Z²ŒóÇ#¤ap>r{œ‹Ç/oV΋E½ ª.ǶÿüõðuZ%}vMêá<•œž´Ó÷òÕžFiAßаŽU›kÊyÓÚ8eÏ¢\õ ÓùbQIèËjòcòÔ¤Xendstream endobj 5770 0 obj<>/XObject<<>>>>/Annots 2898 0 R>>endobj 5771 0 obj<>stream xµX[oÜÆ~ׯø%*²Kó¾»E_ÅvýØÔ #rVK›ä°3¤Öûïû3ärh)QÔX°!èè̹}ç6Ãÿ^D"Ä¿H$9ý/š‹0ñúÑŸß]$yŠ<˃D4béHÔâúÂ#…θ“ÄôipÓM°ñ¸›˜Ô¦)«ÂÍ™r¢3 Ñ(]r=Ü,$³¬‰e=Ü]Ä×™Mb6»Ë‚È™ I$£9ù{fú4¸yDד'ȶd’ Rë‘ØìHîÌóHg2ó™ Q¸uEAÏiå@²KËn‹Žà@fZS¤Óc:ÁíÁu`ð•Ì}ÎJ|l/,¼ý,ŽUðÊƒÑ w ¼ ¶…²=‘p6a!ìAu)ŽÚ|^‰Û¡G…ˆ(£î†Zõè{g¢â/¨¥þ÷­è1#Eq@Z±ÔÜ€aJagÏ‘ê=ÙŸÙèrÀ5›r>^µ‘ØŒ=®éTcÞð- âÜeoBu´ÀÛ«µărcC²,]iqU…œA"&­h4‚‡×=*o¯äx·¹—UÍï¸gu£pbáÖøaÎËÄ>€L›|d—2Êø90V\Ǫ®Ïù?È{…WI¡»Óä g±j‹zÀ¬ÚW¸"»Bi:üÎÞrÁx ^>3ØÂÙŠ®ôu3”᫥ lÝV­4'ôEñ«ÐùÔȹ$G!œ|Õº5ò•@OO„ª_M²\ýÀ‚¢ÔÔkg{ø·®²…£xãi*EàÇ¡Pq„Ôë·¨Ž¡m©WIt¾@^’è®}u'Öëwó˜ºD²'À¡ ¾žƒËZo^¡©Ô²¼(¯03¡ƒ€é/J#Ã)š`F¹µ=GMOKÊ«™Ê» tÍÚÜ%¢>=È<”ºéjÕsÏ/ ²PV£PS=r‘ñcš¾·ñcš&3Om|‚‹Äo>…gœB<ŸñI’‡9# °ªó‹xEyö¸~½_¥d °ÜŸ¦Eq)´Ûìèø=V»>Ú?OBôý>ÇdPå% =@NAµÔ¸æóIã©‹ó74‰8‰xC” JÆêå¡©+‚þ—IçwÂDã¦Â¾2h*¾Õס-µ-]ºä)/Qè5¶,Adî[ÃN qiÀ»ÿ(ÄÎ l"–xÔ‹E ¿êe†n7˜7U‹‘Ùà‚­Wnç+»Ü]¨N Þ†ɸ„}æj?€+à©%ø¹Ù”ªqnc¤™_ñÚÃùϘ<#x²•Ôî4•,ör×[4V/$Cb(œ-O­lhw“·xdå-}:¢åËiAFróql§Šj_¹µ@?0ìÜϼLhìð«–²Ç[Þ-ß»+ºpÊ…Ñ0Å’¹;üy9=;}GB‰dI°s7­G>{eøvˆç ?¥²,&Ûon.þ~ñ? Øÿendstream endobj 5772 0 obj<>/XObject<<>>>>/Annots 2900 0 R>>endobj 5773 0 obj<>stream xW]oÛF|÷¯X¤*ÃâéË’åyHÜØ ‡´qUќȣt5ÉcxG)ú÷½#)SqQ7…`I¼½ÝÙ™Õ׳ ñoB³ÿçgc1Æ'ü2á—ßîÎæK1¡ÅÕ•SNË…¸lÞdôéìÑÛœ&“™¸~ôåÛûGÑ|ÈjC£ÛKšŒé>ŵ‹kü‘øÛðG<øôùýŲ *T%¢¿|$õÍ©ÂjSXJ+“ÓÍÅez]ÉJ+KÒÒ^eí· çô¯n«èüþŸ³Ñ-ŠðW ¢øâ"|ÔÞ> S:tÇm]–¦r”šÊÇ×–mãÚZ•.øè˜¢ÉérS)J”“:ÃWþ¦ÐPæÀª˜ÃÓôJLÅÂèm±ˆ&ðô’s"µ­eF«,ªTlò\‰JVç´—BZÎкÖYâ«ì a$YUJ[r(d®c™eÊŒDÊMRg ‘÷[o9RS3¾[ž™¨ªFÜ]lȬS¹] úÃÔ¾KÀ¹ [ªX§¤#^w­Ú;eíLŽã!‘«G])·¥Ð…æ‹cÆT>i‡Þ—™ŽµCÜYÈÆ•.]/ÙPR¡Tbq¨ê{ǵÊÌ*µz €a¥Š<`~ª¬©«ƒ`B%¼m1c¬\WF¦‹?ˆÂ“†"¦Šk'{&óÀc…s|5Šé§ëhoª‡! JBn•úZëŠç™ÒãÜægRÏÜU— 3âQbá8PJŒ²ÅŽÊ 3RèX®½v[*eü 7¨Ê7OÐgÕÃ-1|ª³Ð>Y–•‘ñvÈ}ÀŸ;¨®íÐøn4Pn¯‰™ÁŒŽ¦ žäÙ¥˜@4Þò òð02a|Žlîw^BZ˜í„?*5Ì÷éX÷AE L©3t Ücúa ¹x@×· ߯:eIVŠ«¯-'xws3äzðtÇ÷ÁX':M޹€<ž‡äÀßY“+ÚA“ÂÕkåö ô@K&7·5 tQíÖÔà1h“)iñDx\?è¢þÖËÄáÑÍvuþ*€6¦¥˜1àS†m*f3¼KÔü·‰cú‚±ŒbS¤zCQ¤‹8«e¿P”–:¦(Fd^fêï}%K··A-ûq"»PIÿqC‘i?Ö„¤Ú!ˆ|Rs±X\u£0¥ß=Ì̶wœ‡s­ ÷'À) Âô:Jœ§©ôt0ô}dÚ3£yÂX2R]Yw©îcL³Ú©ª/z‰ŸN¯Z µ¾³E¹1?‘ö_ß%Ì •yðôäÔÓâö¼vE¿•ÒmGÎŒ‚~CÖU‡x‹\@|Ö"þ&snŒá:0bOmx$©¦ht5à 'õÞà’l ÿôn‰¢”¢€îmˆóêyE&Ùjðâéú^¬ÎÂ0Fô»Ê= õ÷»pR¸_¼Ò·ûË)ës8ðÊgNé÷:ºú=b!ED̽eÂs!èäg§õÑ­ÜõWBÀ#J©’®Æí ‡_|æbæQxÚ §pÃl°Üû]Nóy‡ò>drfßlQ‡_ÿ°äáó›6`q çw1v'•BÃü6LMap>yX:}ÃõF0õ¢!‰̼à!µ!§Õ„/ù\Hµ[£_ÂQ| ý |X`°ôî”ß©áµÞ7¦`ƒ”;,ÌÞ±½{s?jF0x~ß^1d«ˆU,8òÄØn ô¼—(‹U0sUœv.°/ߢ„†u >oC˜û=ì°c¬$hvàíôIs}Ù,ÐMÈ&Ðäû!@OßÓLL.'óëÞ×j|5½#zMSq5YN—}O䌗îc]6~N|f!ÿ£IËæ'Ódy)æ³9~ÎÅrâ÷ æH4ÃÏÀŸM\ãw ïĦàyx:ºbÏ Ý…_q¼_qcßõŒ>^ˆÙ+#žžÏgåÝýÙ¯gÿŽÒ~ßendstream endobj 5774 0 obj<>/XObject<<>>>>>>endobj 5775 0 obj<>stream x•VkoÛ6ýî_qçˆ3ت-?Ún؇4sº–!ƆY¢l¶©’Tœlèß¹¤äEIºu‰Äâå}žs®>õ¦4Áï”fKþ¤eïíº7‰&xxücvôòbB¯£­sŠ'´|3–ËW´Î¼Õ„ÖéP¤{Mý«Kúúþ‰¨¿Ù¨þ÷§ë½ qo5f«ÆjÕ1zy1§)¬ro<žÍš Ãõ^qbI+A•HëB&Fº{Ò9íõR­¬K”³tÐæ#IEW?]Ña/Ó=IGÒRmE^ä4)ím†n§øà+Y¸”¹Lùøú÷ËwäöºÞí7§4&™Ó½®É™{œ6…Lc..)QT«L¤EbDvLcÂË¢@[ÃŒ‰QRíp!ƒw¡HÜUÍÿÇk>!ë Þ c¥V\!ì6èJJ:Òɦ pà¨:w±T"> õP‚Š}9'F #†û„v!A±µÂ êˆ;æ½TFo“mqOI×Û c´‰ ½#mÈÊR¢ð¨rq—”U!F|ÐÅÍ8Ž£Ù (ʆƒRgu!ZãÖ‰ÇÈ‹Lä£^]ÿq³þåæçËë«Õû÷4 ; ‰ IÒTør¥Jµ1"uÈ=`áßS}Qgb3ì7™GÕ¾êoN»À•ùfØMù«É›Q› ©ù‰ðÓ9øL¢\¾Öú™2;\๎ڢx€º0´­Hu)µÄ°@µH\Χ[€`Hœ°Ž #~r›8Öy[”'€7U@ZÖÉB×EÆØ{àRôÈ ‡G¾~¹. }°ß…©?\5$ã¿xñ‰ûÜì„ã»]àäQ=N:Fô-Å0 ~ÁúJçÀ}@cØšwiý…P_,Ú/—Iö)Î=PïsÊ—¸û Ø%³RWÚƒmƒƒãØ;ÒÛ9ÑY–I.¦XM á¶àv;žf{±S¦pÛrî^NC.YIž¶J;ô^ˤjë=}={­´€>/XObject<<>>>>/Annots 2903 0 R>>endobj 5777 0 obj<>stream x­VkSÛFýί¸ãÂT³Øz§-ͤ¤Pfš@‚¾x†YKk[‰¼«êëßsW’åI;b´Þ»»çÞ=ç\ýuЧþõÉðo¸8艾á>|º>ðOœ“?p…K ò_·£„î9žü WÍ 8ÐxÊo‡ Å`cnc¸ ~/ÁÆäæ³¾·>ƒ·ým´Ò"Íftvõšú.¦Èf0Ò(²Iôh:ž/\áÑU©Ã"6:?}>8»òqlêúÂÇ ç’¦M ÉLQhô³Ê Q¬ Cwܵ‚Þ©©,“â̤¼«L°dV.”.r»X&¹!™$f©"Ao5© MãDQQTÌãœ~ªõh”ÈÀíÑ© ÄF‘s´0Q‰xõ·\¤‰âXÌ3öÈÁ–45fläøøç­ÙÈ”,œÈlìTÏ]j¾£ BUwW!¶‹sj±xb08çóã$¡‰"†*Ïm]lUþk.±“2Rc§Sg#ÒyÚÙEq(ΦåîMM0eòDÐED°n„`’Ö??ÐC®(ª®m}[8)#WG”ÊL.î¨*AÃ'[/hJ`ÉäÓ-ˆ‘Åz¶]1¾»šNo“bnÊÙÜ–(2*'m ÊË45YA¦Ý¡eiYÄÏ*Yu)_Æ3ZrÁgJ«L€ç©,ÂùFürclÃÊÜ’ãì Òm˜Í’…ŠUªÂ¹ ¿lcuˆ'2Í ô¶\Ý„%hÄôÜ;õÇœLʈ@{’\¹L…*RÔæx•‡Y<©ØÁîX Ôê«°Vu¦l‘¤ÌíÍblÊ [v 5™«¬’öûÕýÇ?ÙB4s¥æ¨Üµ,a#ÄCOø¿€—Ä8-åÊÞÇ5¢´A4yÌ`ï,t žhìİˠštI 0JõmG!z61àGÑØaW¢W±îw›'·~BZ@T««µËG¸Õ°IÉæf•]ñ+¨ èPXãñóLËk6VΤ²™W± ­¹½ÚY__úÿðÌ£*uZpÞyÝ@.5è§u7°ÛE©Òñq cDè÷+¤•šÕqUxTtçrË\Î 0ͤûöÿò¶º…óߌ·Êæ<¸Mºz²©:Þž·ÆÚÝ Ø7ß ü…VËzv‹êŒŠu|R—ð ¶Ö ïF± u Xæ‚:$˜¡éÓ³LJtÞa|Œ/;tòÒ$Z‡¼Ø›l¬ÆcÝÙn›o~ÝæÚãÑÉe‚.Q95-M™DÜ!P8°½³¯ˆ¡1Û}1T.ŽÎkîhCQkÍÜŸn>Ü=Œºtû0Â_ëd70hhkíóYf±DÇ7°*µR‘U“Š­)UI­Eu¹%«íLÑPmLd&Å^è85d}.óÂF¬;¥… gÅo»è{H³-U#Í—õV×ÅšØæsU¨µy kCê}xÞñÂY½^Ý?Þ\Ÿò æ;Ú·7ÛÖ¸.¸÷*úô¼ò…—Þ#ƒÞ@x.^:aAðºßGþÍHYendstream endobj 5778 0 obj<>/XObject<<>>>>>>endobj 5779 0 obj<>stream xÕV]Û6|¿_±pÄilÅgŸ}iÚ4h¾Ú‚àš¸ ø…–h‹©D*¤tŽÿ}g—’|rÑÇ> r9š\ÏìÎÎî׋KšáÏ%-Vü7-/^­/fÉ ‡ý?~OOß]ÑåŒÖ;Ü]­žÑ:“Ïq’Ž×¹ t0EA^‡¦¨ÉXªsM;Wî`ìžš öšo»}þxýåâé»=Ko>£é|ž,ø-ÿô²Ê+¾Á§ˆžM‹&Ó›ñHSeUè7F›Ç?n=0ö’^Т;e¬Ù§sœ.ÏN#̤²lÃw.'|!‰¾£®Ö̰ï”7j[è*^([5਱V§:åɈNsG£5臦$õ„0Žñ‹7;"zùsLJ—c¦>/’Õêši¼Ò©j‚æìQ®)²ª6wšRgS]ÕävHýN{_'dj*Õ‘‚Ö%•Îk¾ÝxUP턇Éô.\¥AË­>½|R©¨rÆÖÚ‡ŽàåœÁ¬iËYA,&ä,¾@ëL޵Ŋl–­bÆ„ŠõÁÌ꘹IsÚ‹L³p¬*uFõ±Ò¥ªèãÛw‚ù#¸õ†ËáèÓç›_i‘Ì&ò ÷º7t ƒN$÷(PªŠbZ›R µéö8½—°ˆà€ÌfºòHv§Q­´„J•Ͱtw:kkSÑ_¹Jè“#³££k$›`œÞG4‘ÏBîš"CCƒºÔ¹ª…Äf>Cµg"¬ÀÔíµÕ@èàU…:AƒÞ•ÄŸa@‰v*E»ôFûYLÔoà`ToŒŸ“; ?crQ?IbhP _CZ–T]{³mp›“4±`ðôÔŽÆÛ#RÏ:½ŽŸw䃮…–”ÄÆàb ¥ú‹[¢e= À%ïèf_Ú56­ (ÏÊr`6îÀJyhÌIÚ¡¯¥ðÿWsyXº¬p[#é@ˆUÕ¾I±@ <_?yBiÁèüî*‘ -3]a”½@†cã×AÆhm$˜|Ë~ÓLcéQŠŒ7 ¤©EÉÕv2RH½Á$Sœ!HœÏÝNQy÷íØní€g `K’õiW`Ÿä7Ú¸v”™$ríÉ'ô'†*jN™ ý6Ô¯BQäíq‡û†Ñ³îSW–Èæ´ÀÒC®ñ¦Ö ÔÔÙÃŒóû¶ë/ Ìb/Ö1<ì™/hÏ{‹A,Õ³v†ÏgWÉr±¤ÕõêT°)o o\ÚôíÈ0ºâÝéuÜ©EKºm—CÑÄÇnùI,g«d1‡Ž ¡årÅQÞ®/~¿øVÝendstream endobj 5780 0 obj<>/XObject<<>>>>>>endobj 5781 0 obj<>stream xVmoÓHþž_1 =ɱëÄIZà(p½C‚D€/‘¢ÍzœÙ»a×n^NðÛov×vóÚ–¢¨õÌ<;Ïì<ó³Õ…~º Íž·^ZaÒÃæCÍàâ&„« ‚Q½†ÏºÁpx £Øf…0âÞ¹ŒË áy!ÕùèG+ŸrG±Ç3¦5|³ø¯ umhQN³”?ßyÕ¿XRaÕYw6/Žf8ȱ7>?ÿýPBuDÎf"-Ê¡~ÕÈŽŠ.TÉ x#óE†«=2PÁ)ì@š×…Ž¨Ã¹¸éƒù;±£ñ{Q5Fï»,³¦¥ÆRÅ!‘Y&—©˜Á’­!Q2‡Oÿ|Øií^ˆßëQD×{¾ZÌ{ÓRø³LBÛ]N@íº=Ç àì^‚ÀeuO‡“0)þõв¢ºÖQs5úÇ ê@}ò¹„ö‡zî {¿c>×ös3>§Ú6öäK¢gíñXgñï×÷ï_Ð=Ý…IœeÆA5™º3N'ÖÕnÓ¾Ëñ¯ix/!¬Y4¼¹æÛ‘ºæ òÁé°œ£0‘™D ², oÍåë¾ò«kÓæÉeù€ùÜ2•2Rˆ&bȱ˜Ë˜~§Vç¨Í"•ÚlÙ%HB·Ûçù{'x@M(Fʵ\Ü<«2ˆûf¯¢~Ð †A¾ZL‡×mð„\(¹ZïöÝŽtp´ÂôQ¤R@’±¢@¡mórúƒÌÜ]–† ž¡0}N:¡8•ÑP,'êI)ªGc ©ˆ ­¬šÈržò¹i™íö K7çYKÅ4:‚¶g|€!¦òWÌx(ÔeVèCÍÌ]÷k–prʪÜóÉj¢± ‰Ð(:gñ¾á5I³:éDÆú10ëÉC0›ÇÀl„Ù’´!¶ß³Ë]:T‰Â{{ÙJ;IªÎIóGAQÚ>Ô^Ì+oË×+ÕôÈ_DmEN¯okÒ÷ˆ†ß•AêÖvÛÚˆ«jmLì£Õ‰ñ°]HÌ•,ð°brº"M*÷Ø«òë–¬šú³o¯BWHÊ$™’,tÁG#L—kÄFWN² à]9i(5rÚ"ì¼,Æ$FÏD€ð\M§QU&Yl_“i–5/Qj#ÆUNå41Rú68r§\!/‹Æ‡ç½FΈ’qCM“ØThèpYŠÂš«„œ 6³N KEÎÛZo ¯=éLä(¬ÑKê£öl:žØHšˆ]RkLWqUYj/ìƒhë¡1¦/ßßýíGAo%/ "3~g(ÐÆ¹LÿÒ)Ãí|±_UÈ-ݾ½yúÔ™Ú}„à êÑ7? . Ð_£ÖçÖÿ`äí¸endstream endobj 5782 0 obj<>/XObject<<>>>>>>endobj 5783 0 obj<>stream xµVmoÛ6þî_q02ÀAcÕ–c'ÍÐ/k—u(Цˆ±}10Ðm«HíÃþûž#)9JÒl@±$0åt¼{^îøç`J|Oi¶àŸ¬ü´L’ vfK¯¯'t™Ìh¹¡tB‹7Ód±¸ eî£&´ÌF'Fnè-ì<]~¼¾>§)žohŒøq:‹ñ£L8+-5;Iö¾Zë’B8Jðá>O?ÈMÈ. ÿâß•$§riÊûBmI¯¿Ê¬!aŸ$Û?J•ÐrWXÊ5jPºAZëʆ E‚2Q–í ï^½¢L×÷øP¶1.k´!m8Ú™¦h}äÿ/¬-¶ª’ª!]K#—Ĩôœ£>+‰ÌŠ6Úd’äÌ\ShEzã[yrÈúžœESW¡ò‡°Ó4™Í@B>:Ñø7ß’’úìû_áéêôeøß˶KÂH®Ñ•h îÍâSætØIà0öÂb]+¿T£Í @E(4ÄIŒ (àU ´Õ¤ÐØE‰’—”wçö ̂؋¢äƒþ5ãå먄r\R舟x©ÌUÕFo¨*(…!—š®<_xÛWÊÇ´(õuÜ:ee@÷«Óñ&ê“Åìy'i²€%nÆ>ÉjÃ~k! ¯µ.è^‹ÑUˆn«±¬@ÖÃɈŒ¨kà I[—íøß7nøÏ¢9ª—c„w@«5¤1,T#!·Ðf™´ÞqÚgêÁßïIÇÚÈ3³ÜГ¹¶¶./QöL êiãTæE}âG‡*Øô j*Ѐ‘3*?sÆÀ0J)ìLá³¶Õ%t ²ä¨êRX¿áŠ*;¨èA,Á·úœ5ýÕžëSüŠM8ÔA7Ö‰áãþ~ÎW³n¬´+s–nÄ;?2vöbÉ…ÊJ—ËÕh‹Nê]=Œ6ÙNÓF;±gpl:¤„>ê««Xôj´:Å“aÛÄj¥†/WkAê´g‰?£š9fí“òÂlŸ{q(÷¥pF2ÙúIØ_ãY7ÃzeO'ÿGÏ­ký:²½{þÈ»×QÆ60ö/ÞmE©uu­MËF«‡0P-ÿqÁyœ®®Ú×™±þy#lFÕˆ»ïÕ}î7u¿×EÞ©µüÙ·y'û°×ŽÝ û}²µ÷Ò­6ŠýÛÞ,æíÍ“záÇäÛ %0¿¦q5 •ÓíÎ5¹>(¬ô<Ž‘Éë°C] ,6·É|2‹[©x½£ÅžSiS`àè¸äq·áàÀç¼½Ò>/XObject<<>>>>>>endobj 5785 0 obj<>stream xµWmoÛ6þî_qðLAmÅïI0ôC—6«?,ɵýbÀ %Úb!‘*IÙñ†ý÷ÝQ’+ùeH, …"wÏ=w÷ø{«=üîÃpB?aÚú5hõü.î~é\ÜöàÊB°„A&×}2¹„ r»z„ÞYª¢<áÀŸXš%ü<øÖêA·ï"ï,Ól•²™—ÅÙìBñ·íÆŽŸ ˆ…qoÿ i¸¶<«*“>žnâa¬`6k—WÒ{ÜËÃÜ %gø…¿Ú¿4ޏ[/nG@Ž-¡‹ÁtÃ2ï7ybéz°1‡¥JµrE õ[J+uHºƒ?"@‘÷ßc©ßQDQœô;ˆÞ·ã2.=“<*—«p=(A30±Ò-@ŒYD`»3`,³<å‘À7„Dá¥H¸O 69QàuT¨¼ÀÜ•”Øã™<ŰòàÛº…6\\ÿž‹5K0º2ˆ œ=.ÁÝr©ŠØ«c?0uœ­8\0¨‚©`›÷ðñaþûôîö~~ûùî&˜ÞßíÛÚÄ"Œ)=!KäÿR«ðØÏÊÛgVÐ2—!‘üEyhVÂ^M–Ö÷ÊàO.£y¦±—3¯ýNVTµ$¿ÀäYF4²±Vù*†Ç¯Óß°ðÚ³óæu@þÏ ¾ÂÚܲEÂçH5m)¤gíŽ9‹¸žyƒ•ý{¡9¢°æøì¾°$§žiM«MeêCÑ´ªh*ƒ\’“ÑóM"X‡Áü{Ï Öu»²ùQã’;NipŠ:P’#m$ä V  ½oäLHa÷)§·¥Gö½†jdþ¢‹w»Ï¬i£ã—…R‹ö§þnXÿdRO£}XgØœYÍdtÀ~]¹¾]mà1ÍaÍõŒHEÂ4,p>-P“„z‰äž¹ÞþizW§ì9 G$ ª3•#Õ¹Cd •š›¬hrɶÌÚ5ôGþˆÔ i—+zŒ¼áÅÙVÆ@Âä*g+™J¶©Ò «´1ùWWtòA«§-„ 3†ãÑj-"ŽêOrÌæš%Ø[ßЮÒ'Î¥ Û:Õ†¯äO–Kƒó¨²ãÃ;7¡ ÜÍjÍ;ÀÎ6¼ïCD-“áN&:tb†²Dz¢B$‚›7ov[;„&¤ÜÆ*rãq§N “”¹Œ¢ˆ*ÕR? V3i2Ü$m²…µ`pͲŒëFŠªÑjÜ)‚ÉÉS¦ÑÈÊI#'¡Ì6E´ÑI×´ ÂÀñ‰Y º¦ü)‘†LQ®2‰¹@¸„)´ùÛ ‰*Û™¸8 àeNP|8-°Yú0•¼¶"Ì‘´KL!½w‰BvÁ9MoÌT„¡ ß3o±-ÉG<šîÜì¼CK4Oª ›X‘$©Eã©8-¸F2߇/BÛœ%Í(wîSÒlœg„†-°‚Rä ŠoW`ôy‚ä(#ÉSBÝp£†8|ÊR¹*åð 7òÇÃ1L.ûþÀ±ždJwè÷འóm2Š2°ØÜ½,>¼`i üK‡Öƒûc:ðH²%Ï#Ë~ìæ7Y÷&þp€Õ‰´¯iéCÐú£õaendstream endobj 5786 0 obj<>/XObject<<>>>>>>endobj 5787 0 obj<>stream xVMoÛ8½çW pP[ñGâ¤Yì¥i³ÛÃ.ºh€b_h‰¶ØJ¤JRu¢ÿ}ߢby“´IXÖpæÍ›73ür2£)~g´Xò_^Ÿ¼¾?™fS|Ùÿ³[:¿» Ù”î7°]¾Â‡"¼Ç‡|t[ ½•ŽJñUÒZJMµ($yC>¾ûƒfÙ"›]ó£( +#_*G5ëJÖ$tûϰ/%YY ¯Œv¥jàÊïØÛíË—”WÂ9Ä`kœü¶?»ÿt2¥Él(£ô¶6V’Û×µôVåÝ#f^* \!æÖˆjLZîz¹¨*YP¡¬Ì½±J{kŠ6Ç á®µñÞÔd6á‰)]J«¼Ð¹B)…Ò}h›ÆXOci+µ´HKoéýŸïûÐ¥p‘-ЂHJ?Ðu1vÐñɬSÌ„à\ZÓzIH´4qnÃXΨÚI*0kùLÀ]7`]jy¦Rmù-¢3ÿYQΙðã$ãVG'+³{æ`6€ÃÉ´+'†_‚ÖêæBƒ ’ß¼Ô‘‹½±àmÏu&ŽB•1ŸqDp–T)(H#'”úÀóÅßÁÀ@¢Ù…’„)‹@ígmv´+’5Âz•·•°‰l$ÐS!‹›À[nêµâðŒm¢BS¡Ç&Rû·!Ë[ÚYÑ4àsÓê Þõž ¹måCÓµ¨T²w´7-Õ­ó]›ï K+L (+ªÎK»¹¤ªdFwÊ:?æqÁ¯ôönOÉ4ïÎÉ‹-[¥¸ÐÁ8Š‚ÿ†}œßMé:[0sæbž-x*FÝÉÕ¨÷ýûéìtuFÑ£uÀðÀÌ$œ_dËåŸÿˆÿÀ J:PÚôPÎêÚ)ï†,0#dnt1~à‡ic>^t¯F}º 'Âc…sÊþx¾èÙ•*/“´âh Âz¯­ „÷=0‡LŠvà¿ëG(²R¨î¶2kè³]#sµQyŠ‚:¡M^ Åå~¹çç=C8ÃåHs> °n¾*ë[Qu½ÙÏ@^P£”ØÆß(ýt@QL?ø( Ë€…îŒIù>“ͺ¸lý¤’þE§0÷A›¤ÎÿK¡µyª‡õt<.GÎé©Ü‡hays³6˜?™|èÔG¹pñk€¡Ø×{ —'YVgiìÏÃôzÓ/wæVTÎ 1Ls•+^#¾Ä$Ý–‡{0£wq7nL…•‡9îâ¾ÆNè@{lŠTŸîm§Q]T˜âÇc¬«-ol¡ ŸW£5†‰ÆªÞ¯Î~2Á~±B|}T®i± òƒïTAÉÜ%(Üj„Û´bVgÃjóûT’¯F)—ŸXù˜åÐêGzŒ½a‚ÞŠÈ}ÿ%ÈH=ÉL-†{Rˆ(d/~|;p ó›—ËkNén<±O¬üÒBr;õ>®¬)´mBq˜å_{Î-Þ|Ü#yR#HÁuÀ…ƒ«t 9Å â­Vú4Lý1 0<ß]wûÙõEv¹¸¤%nŸWq3ò~™,²)½1yÛ_Ù V`´ž\Eç|© [¾œP9iLlƒ½Xó¡Ëé2[ÌqÁ¼½\Nù«·÷'ÿœüþø:endstream endobj 5788 0 obj<>/XObject<<>>>>>>endobj 5789 0 obj<>stream xXïoÜÆý®¿b¡/½ -édUQN\7úÐØE({ä¹6¹{æ’w:ýßóÞ,—º=Š$F÷Ç›™7oföÛÙµºÂ¿×jyÇ?ewöãÓÙUq…çÿôµzóáu}£žÖX{w¯ž*ù~¥žÊÅò¶X7ê½íM9ø^•­Á„ïž¾œ½ùp«®±ˆÛ.on‹[l\|À£Ë&.TC£Õ蠪造ŒÓ«ÖTê×ÏÿPµq¦×ƒ J+gv‡Û*ÓÛ->¬{ß©•œf¦Ö©o£ ƒõNiWasؘÒê6ƒÍ  «¿îlýð¬ÈÑ/â™…zjL0/(L¸P½Y›¾7•¼:°"îà‚R;µ2ªõ>˜v„~¬›Aù5—ïO̷߯Ñnuk?ðr8,ââŠO?R›Þ?ïÓ©‚döXúUøßÀÒ·n0=!a»íÕèàªvo]-gùÕĪPø™~þÄ`T°muÚ9ÿOùièÏÅ¡çÜåwî\u¦[™>ФÓh§3næøãŠMkK;ìUk†?áòÚ:·G×§øü‘¸‰Ãd±ò½­­Ó­øV™œX†;W±”…úq¯*³Öc;\dë#'+ó<W‹m«¶¶F\Ò¿r4Àº¼´+q|£ñ+c‡Ã Õo‹`¢¹¤©™€˜­k$Hãw´¥ó•]ï3D«•iôÖúþ·ïÈ„ñð®mA¿]täBcöÉ/2P‘w¸ ÿG~m-xsȱ e¶à# ka³7\«‡#88 Á4ÖjÁEtCòtrñ~ûâW‰%óçÙ{ȯz?ö#6ñK4$EVorÓ[‚Ú´.¶î5 ãH€Ï_í=W;Þ‚%àé:¤Û ²´5È]ãrÜF†Ós/ìú!¾ áI@8…tð΀àÁè®5!À¥LÑšÂV1†ÁômþB2 +ͳ.lØqÑkÏBÿà’­­ ¹×.ltX´9mÂW»Ùe~ 2½Ñä\ršXÕ»OªnGw­,™ÎuÃΫV»zÔ5®|-œ*&‹c^?:h¡n‘Ó£N¹ÖxgH洞8vãC°+‹}Ö„‡DJ8¬P™AÂ÷ Ê-q@§ÅRÜÐCÞé µ¶7•°O¢v>Æp•]béO%4ˆ¥àhýNÍWNÂ6dâ7Ið:Õ‡‰gª#6D¹k÷Ý? æG'þ›‰Ç¨àÜ1Ä*ÃóÅÞ ÝI‡Ðè5JA†f×X”_Æh Ô¯\ÇèVߎ)•I]=¾Cróæ½ZÏ´€Ê¢’ån…$e´øJF5«<™ƒ;çÄgP+ZMb— ¨’z®jER^òò¿±3õl©úßáˆFƒŸ/FŒèÃÌìÑ1óˆ¡7­jï+r6€ùÎ#·|¬«ÓOÔáT¥`™QJ6+4¤ó ßy,¦:?òCÒ¹¤ä“ÈË'Ö[vI}ôrPÈ,¤î Õ8Xòù§UgíÆN®c úåº ¡™^/\» ⦘eNIðÕjûb©ŒmUÛ*Zzp-i hó¶<øjgÁMólJªx.Ük!oXgGzËÁžˆ@Ž™KÁ!(Žh´ÔOj×CÏ¡eëÑIÝD½zF‡7Pä£ÄH¼a¡ jo)äRþb¸ÓA¼4Ç’í(A¦„‹¤Ð_Hˆ‘ã½3É££"R_${£›bMI´ÒåW¢:Üœ™x¤˜O¥ï¦d:Íás…Àæ.êÌŒdb„”!¸pÕ"‘ͳš_Ó]£k¹`Ðb„ÜgXÂ0F´¨œÖAØ6¢ÁÝê3˜»õí0 ýƒpœôªb›ÛpäZü:šø™ÕΠ‡É|’ >CÄô­x– 1¨'N„×X_Âp2—¯'u"î¤Lñ[ÃM÷&·¢;ÁQQ5“A Ø*ìŽÁ<ä„UðÃÄM3ÅNcx Í—8êTѹ@‚J¯Æ…:Ïï<<ÐX°?¢wìºe\ÀTcXíÁ üŒ«ô ½˜ÜÚ›V¢»ÁçaÇ–h&–x n¥/” Ÿ,ÌúJð%fLæ3P¥„ê¢bP¹ãìäÑ󾤫§Z|€ªb–Á)¼ä͇y–¸ü«Ì/ñ×4š.HÀŸ$XÒi5”—wu;Ëñ T›gUC¦‰1`‹xðÞ¦YiëBf§-GNX‘k°8iôì1ùqÞM“ê Ç]é,^&ëE”éÉÉ™W§ãgß^°d?yhÐÙŠßOºXú¦°ñNò–r—,;ìé«%&LĆ5ÌæÞ“”FÓ_bÖ²Áã*±§ÓO€­gOÀ'´¦´›gË9ê²íB…¨9.„lÆÌ+™(˜Gdwæ 8`3à¥Ø&²GãÅèdú²8%c5¤5.f(܆cj´h8ÝÏå02™>‹±Œ¨¼K\ÈÀÀà^‹ £™[ß²T‘sbD,l±‚PÄ`XÝ0Y¤¹8|¢¹¼¹ã“†¼Ì,ÕÇP$uIÖ8ûƒKœ•Âi–Òáà¥æŸò°‡8´ýœï`BÀ›ŠZ60Y$„ÚŠ^2X§ˆ(²—½TæE8“@! U’„~¢õÓ™[ò· æ·Ç+•"#d4+–afYºŸz2Œ½“£|~‘‚ zp1K_z9x ˆˆ34‰­x÷àN<­œ@«ŠþÊP!îh*ƒgÆ%•Y‡½(ˆøXë~ï‚|JƒÓ}Q£E™2ùž“(ø=‚ƒAS¦G®×ÊÇÒÔy°4MÞa¦¦æ H…zÇÑsé05U`ð¼þµº^wß7%*²$¨q…°ÑïI–<ï@84Á53yÌÒ!b$¯=ÔæôÑ.TÒNú—é°,€ý¥C¡›.†ÙmÐ,üHgP3U…iP€] Å‘îx¯þ›üŠwÔj±ÑP–²—O—ò›Â?E‘î‹¿ýï/ñøû©ª]ßßo—oñªüCq¯à«ï岸Rï}9ÎÏJÜvysW_þ9žöÞžß^ÝË<<ÜÛ»knÿûÓÙ¿Î~>–»”endstream endobj 5790 0 obj<>/XObject<<>>>>>>endobj 5791 0 obj<>stream x•WïoGýž¿b„Bë”øpìÄüH%$%R+(¤â‹¥j}·g/ÜíšÝ½8âï›Ù;;—ÐT’ßzvæÍ{oÆ_÷Žh„¿G4™ò¿¼Þ{}¹7ÊFxqûÍ/èñùˆžfº,i<¢é³£l:}B—…œÑe>È+;wêlTÆjOß.?ïhx„Å`ÕÌ+“?ï½FøsåLAª(ðÖÙßè—ÙÁ‹;§²,ë½ö½;r<åàû9½$«×½fƒÛ‘öÕîØž_Å¥ nmqlÔÝÒßχ¯º,÷Uøñù1ñã’†€e8ž´° .,q$Òת^UúÖš”ÇWMmìOUì%KkSUÕM9Ÿt%ºÒ‘+~²Ô|žVÎØ¨} )OPB¬àj PÏŸÑј3ã¼£Éq6ÉŽéì:׫hœ¥ÆzWU¸€‘Ý•Âo8ÆAÀúÉÄ%Æë<:\é]#ùÔ:.]<«*PtôþíûCR¶ •w×Fï"éšœ>zt(,qŠoäòt—jA –L½r>*+…åÚÛmËQH1x½"¥jª˜bíò2 ëÙ€¯ËóÆSÑx¾°Ÿ3£Ï({\u¥ 2–«ÈèÒ‘ä¨)4ùòFÈŽ}’JîW϶­ûI³ÍÐÇO¿ý]*S½øŸ&jÊóoñ›Ðéˆtp08ylÐà p™3·SàÔtËÖ1±yx¤±ïÕª‡¹°n VF¯5ŒAt£yNõ\ )„ÈËCÐÇ*¸÷bWâYöPBI^/L`óM{‰lsÀꂌ±5à'sù”ÖHz…·”M-óÚ·áÞýã„Þ]i¿Ô ;T"Ói^9ûܼ±ƒœY0%Б9ˆìT‹³¤¿ÐØ7ÅÁe ìNvþÂ2Õ¸vGðܬk‘Žý ßXjb[(®fleUñ€æa}ãÎÊEÖÅ®ɰR¾¸4ÈÌçø2JÀæ±hØÒIXŒ×_Ì>V;¼þ?-’ XÑd»bœdE(@^îŠAïm®‰›Œ“óÂJƒ‰=4%p dq.®x­:šV,4®FVX.im\JUp~¬ ·æF`CÙ®ƒÎV›8ŒsXéÜ`ËH "§dõ(¯ðBا¾ŽéªäõB†N`˜¤ýr `°­!/×[8Øb$VÆ6­´²«n÷Õ¶ÍÝ‘¶ûËòÃRŸ–g¸ŸCÁî‹&o!¦Ë-Ìú «j.•_à6ñ‹¨Ì«($‘vª°Zî,sFt…É}…>¦IQ.8%b¿Ö9otŠm¡‡8šˆA8GcdX€>‘[eõ¢Â4E»R·×ØÞÓº×a‚ªz©H—Àƒ ‚#´‹±LBÞlx€Ë‡“]‰…Ž®ñ½tºñÌYtç ¶êl‰ ,¸ÁŸ¸Äœ—ý¦c…è6Ùiº)ówÇqž‹h”fjöRéºÉyÈg#Yv[ozÚÈñè8;™œÐôÉ8{Êzâá1œd#zãr‘¨ÜͱS¦³Ã'é¡|œšÐ»5¬',Í*@6%|N Ñ7âŠüÞ“Ñ4›ŒñI 7œLÇüÒÙåÞŸ{ÿG9 Pendstream endobj 5792 0 obj<>/XObject<<>>>>>>endobj 5793 0 obj<>stream x}TÛn1}ÏWÌ j*šmî½¼¥P DQ#ñÒÇ;éºõÚ‹ím¾ž3έ„u½³ãñ9gÎøgg@}ü h4•Ÿ®;ïg~ÑGp÷/<Ðéõ˜}š-;½À¢Ìß±ÐÝw6U¾}¨¨4uò!R­ž˜L"§R”¥ä©6/òjž™>¼}K~þˆÜHK“*ºý|» ÜwUÜUÚFïéÙ(R¤}]{Gs™´U1Ï;}ê †€Ôm¼q‰Ã yÇÊ–4gRK˜ü‚R…ÇüÙø6ÒBé„€JT3𗤕µQ¾F³4ÖJ‰ºÕEë—d“Ûg¿"S€™U&R4©i@ÖØ„B¾I¦6¿ÀVÙBHbWÄNÍ­q{îk\‘î»m”‚þÍ‚ERÞda+¤YøÆ¨Ðe³ïL&**Xó$§&ÀðKbW‹qÂ:ã?½¾ QS:ÝNEÖѸX­®U“%í‡Þp\Œ%o›×´‰”+É·I–пö1?… Zh4%ÔD/‚¯÷¼s_­¼2gv´ &iA³ŠAPxq\¦Œ5?s@Ü/þàÌÔÆöû ‹+Tð}Ý A´ ªiÐ_íKÎGetHCÓ8¬»èT dàhëvãŽNöo ‹WÐ>€²KVáA2Öå·ò‰TzTv>‘nC`—@èPjµ³.Pz2®Œ9´!QÐM"x-ﵬÁÔIÜ—ç–•ÑÕœu aÆÁ7Á¨$'•äz¬ÍÛ¦ñ!qù_[œÑW5[«c¬ä˜zãjs7l5EÓáÚ»Ù—õoDƒ€7ìØX¥9 I;Í´òí둞[œ¢PLååeL3rBœtm1ç/ó Øû,£X`Ãì|sµ ûãb2š<ÏÅÐw?n>õFEŸ®¼nkô$›@Šõ¶¹½3¹732¡opbŪÌbŠ‘hn½J²eÒŸ£!¦ Ù“éHBgïßÏÐÊïendstream endobj 5794 0 obj<>/XObject<<>>>>/Annots 2916 0 R>>endobj 5795 0 obj<>stream xµXÛnG }÷Wi‹*°µÖ^%µO[yÆ*úb X¯FÖ4{ëî¬m¡è¿÷3«])nnMÀ1Å!‡<$Gùëħþø&ü7+NfÞ ŸðŸ¼¹: oFIœx!´Xâ+ät}2XE¢óg‰9‰•c¹ ?Œ¼x¤µ¦aàLÅ‘HÖtaê'Þœ’A;’ÙñÂóÇÚ‘ m2çˆÛ‘ íbÎ ìµ6¨`&A-coI‰ÓH܇´Wº¥-½`dj!œ-Äm¼`ìv$^Ie¯‰¸2öJ‰5^Úºø3NÄJìÕ*®0¾ÂÄ" JáŠ.9ÔXÉrqe8÷#¥õšXx|ëU$¶Ëí‚ï´#ÚùÍ0ÒŽä‚‚™Ï1ímíµ‘…ÏB”;I®Ép͵#Z:ÙZǨŽq®"ƒÃ0f·{¥è(vÝ›,•$¤‘ Û嶃öÅj4d2iÍ_. âXm0É"ðæ­Ö2‰3Ze“0¦ëß_^QZ®éµ~«ž¯þ¹‘Y7ù8¿áiž±Å ÜL^7*×….ÓF«–MYíó “7]YêòN¼:bóÎëÔLJ!"„áMÏèÐâÝ0ìywÕ•2†¯2[E¾ÛÚªt­Úè܆%W?$£/tùo-_½«º†ŠjÝåG~l²Ó0ôfs†W Hæ„€«?|þEÚêŒ.Î/NOéUZ׈è°¯$2©Ð€Âdž6X| —]™]•_ûž«¼ºMsºG×¥·_¿ÂÈȤ¥ieHTÙªIZ“ÙÕ_½½äò¦ËLÕØûV­qòá|ñr^›Ô ­^©âV5ŸYS×ÖB:˜l×Öç—=LAßKš.¥íW[ÝR¶MkƒÙ]«6kô­j-?µ]]W¡MÕOyôSKÕ3›‡F3œ 1•¹y$hÎsêJ&…µºWyUª4RP¨ËÊ–=we¨¸ÆYÔ¸“ìäֺх"ƒ­À4GWÜ*æç†é]ªÑ7’{‘cª´Uru‘îønºU”UE ¸ÑΑ !P> :=ÞYCŸòa¹b=¹æND‡‘„Öj£K®¸Únä›m)m%ÓM•hôÇœòùåŒøÍö‹eBZO¾s¦ê1-ê}#à ëþîáñ]fy·VôÌö¶N´°=ÿ;oÍ5š}“fæf¿•7Ï´‘ sÈ‘„^‚ åVªÐ%:çœ.H=…y¨Ê~ ú<£¦+mÒlA^À}†ö¹0™ÖîQ1`9¡ªæ5AïGã[çÊïÁš´úŽÄ!bˆ<ýÞ4^n¸@ߣñ$P$„%¹O ÓàZÓT”®ÁéO¤ž^Ógðy ÀÝ'eaçDd@†)1Ò9‚Æ‹#SòÄ¡2-ÐGÈ;ˆþxhÒÚËŽ¸™€HßkñøxdsFZð¤< C*ìôIˆÝ<ï9˾™HÙÕôN•n«Ž3MÙ)¸ŠSª™ÞdK…äQ>Ç¢xó¡oñœÍuù¿îƒùfNy«Éc‰DßÛPà2×8 o™GC³¸þï3èYW þv)ì"‰Í»kDß#ŒMSÒ]\¬þ°.k1?S=ºDA\ÍiÆuÐó{º\Ç30±kÐ]s"»<Žïi§Ow €Á¸cúÓØ%Lè0ê„ßþʺïiæÿ S M+ª[Õ­«rWxYX¾í¹O…YãžÏ„ßúð…¥FŒÿ²¤ªá§·ö4Ê%•´î¾-ìNßw%´¢·eõ DZ߱D+ù]^ão)ò¦ˆò•E–p×vižï èæí„=œÒZ7Š_†»~ÛX´ûoUH!ÄZ[¸uhgvüE/Æÿ¬„ýÚ'[ÿ²:ùõä_ÒJ¯%endstream endobj 5796 0 obj<>/XObject<<>>>>>>endobj 5797 0 obj<>stream xÅVMoã6½ûWÌ¡ElL[’í8[ @w[§{X »ë¢(` `$Êb#‘.IÙÍ¿ï#õ;N‚Em =3œ7óÞ ÿÅ4ÅwLéÂÿdõèÝz4eS¿Ì–&«)-YJë‚’)-nb¶X\Ó:VSZgѤ±fRéŒW“¼“k6cñt"UV5¹g—ë?G“ÕŒb84F q’v¢u)Œ \ «.Y!jršîqõ@þàÿÛ G¿ 8IgEUø##ö‚WäJAþr'µ"OJa²öЬ¦ÝP JˆÜ»•rÄnTN…6Þ¾f>?ä'ý®› $Ti}/Õ6…pt® ÷)^ K-(T0€Š¶•¾ã+O±FWOívFo ¯Ï 7÷ kÒ™¬nÈçS GãdáKç,F'~µ>-à2T뼩ÄéÞ|ÆfÞa­©A1ŽLQY慎pî zq†ŸkãNcFdw¢ʽía?’bœ$,MA‘<ú¦C÷œ‰<%ž¸øJ£fy:º_ÐÌJp¤ŠsÓ(åþ,«BÐ>esÚDTfÂõèxðZ­œPùæÒ"~v ‡Ä߸Åw/¥rîXðÌm¢ÙæòEŸMo.é³°MåÞR2kc£m¡ü=Ï—lãÛ—Ð;neFï'ïß¼¡|·ÒÁí±Ûl¹ìž°˜>†.ÛÖ®ÑQ›¨ªŽù”éä­9må^(úòÛ‡ÛŽ&$- ‚8È ¶•h+Úr‰ÑW 4ïÛ’øUòÎpI–ˆÆ³*4ÈÓPYƒ9`\.œ0µTPŽ×l{èçÅ„sKGÞ¶Ó¹$b”@¯Žs®~ûœ"Ê¥™~_²!Å~ÂŒ äSò};b¬Ü*YÈŒãºW¤— {«F!®V/÷â6L*zCŒ1Tà”8´ïY¹±T¦ŒVh\GÔ«¶Ûdz÷HfîÞ¸ƒ‰± Q¡µ¨¤ç®ÿK üí‰ódúBWè|jgY=^]z¬½ÑOYfÐA›{ë³Ë* ØA9vè f8ñësä\Žÿ‡Žƒ ÛzÍûmåUŒ!ÜõyÏäwØ5§e8çSÃ@ˆ¬1³µé‰qÚqi¼àö\a@‹íþóªéiÏ«FôÚì“„+ Cì5UêkhÕ1¤ÕjO± Ã\d7a}¶þårÝ  ¯îfå \;HL*æ%&¹ƒ>†Ú_ßíSDûksÌoÊg¬÷ëÿŒhG åÊHñÐò_}w‚~Ï©ïl)‹gñüfôÐ*?ã‚ó&JŽVÒ×îJüJÆéQÄ.ƒx²ZvoŸx9cótN‹ô†%qxø½3>úQg7 ƒžZëñu›sxÖ$t+œó{ßÓÜÈmé¨<“ÃãË—h>]°4Á{Sn¾˜û£ŸÖ£O£ÈEendstream endobj 5798 0 obj<>/XObject<<>>>>>>endobj 5799 0 obj<>stream xUßoÚ0~篸·¥*¤!”²·õÇ´‡I›ˆ´¤ÊÈìÌv誩ÿûÎv£h€ˆœœ¿»û¾ïœ_ƒ1DôC’Ú_¾|ÊQÑÍîO­áêáÆ1d+ŠMg3ȸ{A–É4ŒÃ ÜJ¡ FPÔ[TÌ óZ¡¾È~®&0¦-dOhOƃû£@(Ü^Ý^^ǼdQ00…ð¢XU Óð­xFÈÛŒCÒt·mjú„ûªGqjÓ¹b§¾XUçF*_ïjÓ¬ß-ÕuØmêä7‘®¿ WH½/ƒåE-€-šäzèXâû¬ÇºHùzq%UCLÉ´Æó¤°0Äm_qû„ê}…ÈÑãr‰Z|0 ëª’Š®¡i (=g†ÁqÃ} M«Zä^UÒúUÖ ¬Ü$¶-úˆK¹Åz ×5YâÀZ­«Âï˜*ØSùT¬ ­åê`÷2ÁHX£³Aر²Fc=Ü^m/"#óm¨-ÂÑ„S˜åE¶¥2<šÆƒ¼Ö̕ ';¿fãÚø6¹c#„â³mUâÖÅEN¬Ž•Ž¼Ã‰™·þ™…‰¸ØŽ\& ­xàÐa±a¶‘oy𧷪꧲È’Mæ"€> 1;Ypj£ƺòcoëA=¡m*ÝysËý¡0r5&aš^ÛZ?¾|&nÊ’Ôî(mW͘¹»üÓöigc$‹ØÉg’ã@ÙS`óù´ž{I| /HõÑ•9{µ8³’îݬŸÊôØòHæ;5ÖÖÚg÷‘ÙNì¶~v£qìëS€óyS‰ØÑס³æL‹£I8M¦ߌC× h”„ÜÉœ{a),)écG×Þ5ÿýŠ˜Fi˜Äô~ LÓÔ‚Ýgƒïƒ¿ñ4±endstream endobj 5800 0 obj<>/XObject<<>>>>/Annots 2970 0 R>>endobj 5801 0 obj<>stream xÅYMoɽûWt슞o’§À«ØÎ1쬴ð%—9²fÙᇖ•_Ÿ÷ªšÝE¬ÉR¨Àŧ7õÑÕÕUÕ£ß_¤.Á¿Ôåÿ¯ºÉ,Áoø‘òã—w/òj–¸ª¬f¹ëܼœlÜ…çŠB¸Å?*äæåòL¸4©((ˆ¤ÅKóbVVE³DD—ålé*”4‚É,5¤ & ÌgsW Á)X‘ƒ-â³â­Á`ɬ2Š-î\–æt)˜—Ê¥†oYÌN¸!Ôf%ÔFR[Yu) A!S®%’s-ËYfXU‹Ongšq“JA²PƒÁb»ànd [æÐaXƒÁ.GšÕl¥[š¦²pAbÖ`:µÀŽ—‘5˜fKš¬Á4[qµU³…&DšÌé“ 1k0Dó9ÍFÖ`°ˆ=GÖ`lz²DGÖb°%—Y9Q%>¹H-è@Ÿ ì\•2þ3'1ã¦ÎÀÎ![,g ¢i-[ñ´©EÄ2MB?AôUƒ›úTJSœðRP$†%[F¨qÇ*)Z‹…ß2Ѫˆ’©Á\Ë6 k0Ø’ÛYU<×°§ S°Ü-*¿P¬¢rŠ"YêBQæ–®@Î@:”`7#©& ‚>) zŽõZ©‚XŽœRäiî A”ä>0—™3‘5ì"§âÈ̼MŽX‹ÁfsÆ(ȪS¨6tJW# ®Æs~5´.!èˆn`U-ö#ªÕz.Í–Èë""˜/Ͷ(‚.E\3IDsQÐsì/ I¬t[$¹€(è9Öà-•O’´˜[–"‘Uµ¾ÅªZQ­çÒb¨­rzYƒÁ¢ùXYd\ârß»qì hÔ@T“ M$g ”¢¯CihúƒÍRF!²ƒÅ²Š-;?6k1Ru 4š5‚~Øf™‡YÃ@ºÄIô£Fš°wçaÖ°¢2lX–-.÷ÓFZŠ¿¡ï§ø–¸Ì7~N¥G’C3šÉÒ²ƒ•ˆ«&‘5˜G˜õ(²ƒÍÙ "+ËÍ ^ë ‡2E¢X†´À¢‰bò,YŧŠòðd‚T4bxœ²GÖ`Æ‘: k0Xt985ÌX¤\O`%‰3i÷†¤¿úd ’xN­a.0JñdfHhÇÂÃа@N(Ò•F Ñ‚C[dUTš+ÈD HE#‹­h`UôÐj1ìjhµŒèS”ƒ™a [.Yƒ™/œ£¬š Mœ/ M<•F¨˜Š%øUQßâÓ”­„ äPñ"†¨´Ã VfTà v.fƒf1›†£º"ÆXÉC“G¹\H¿QŸ$[Rßä缈`„0™sòФÅ`+–ÎȪM?`¶)¤´©I!ˆâ³4¤Åª¶2¬ª=  “’̇×`ˆ¢Ä––5,nm¹e ‹…ÍjVš>ŽD7LBPnmœÁ¼KƒE=D#k0²DVÆÉ:m™rn ¦bÞù k0Ø9#dXƒ‘ü(íˆb=4!üx¹ ‡éÂ@LÛ c8aê 4’Ü)?• `©~çB"¢—!é—³ÆD.Bp(Èeä$p‡iEŽH˜dÒ©²„ÊÀ‰X˜UXœU„˜œÓÈEó5ní‡í•~NAJá.ÀH–ýà<(Ù™ã9ܳ‚¨“Îà³P¾û(ÎѤ¡êp 0òH#$ÇÓo¸é{Ê1à ÷Ó¥yñ!o?ÆÏîÕ[œUNÚ—×xGR-páÊÜåZÞŽ$îrõoL.>ýüÎÕýÚ}¼›n†þ/—¿EòE¡"@âšïXÎpÿ*Ê Š^~øÒŒ_ÚæöX*šO™Ž;›cïðmýò_Y5wÇÏÿÑ Ÿ>KéëËc³i»¶¯Ç¶ÙQŽ(õ˾ïÛþ³,áXã·<@¶&ùÁ‡2¹×}Þ›úuGCëv7í§v#~ˆø!QŠë}’µ¿s?VC·m74[»õ]_wíÊuÃz¿iN¼Ö‹©ž` ¦ÿ ë'6¦½öãó,î\¢Š½®Ýù?¸æëÔô;üâÔÛª¶¹£×È÷ŒgWíä¶›zìNmü§}»YÓ¶žs÷&¬Úíûu3ºOm¿néÆŠb2wK© ßqÄ“Ïøk71°Wõ©wþŠûr;ÖÛ­ÏÀxèßËx¤›ñ¸þ±æ÷·û~Å9µw›áªÞ¸/¨nõÕF \tR¾ý/ Ë9V4Õý´“Šßôû“§ÝÇ¡í§f²V?x7ß·»U³AZ7Ãþ‘¶ü±ÒcòðûÞ‡pïëÐ VûÝ4tíôòyÝÔa^ÕWo>7ÍÕñÙ¦Ÿ×k¹ÖøÁ¤Ã}ÄW¦Õ°>õÜy΢¯àî¶nÜŸåJ¾>qÎÇSvƒ¬—rv°îßãð¹RÈÕöá¹RÉÈqÙnõr65«›¾ýã7½ˆòs¿ÝOZ–ö¿nëÓäsܱZÌ‘ì Ïr£ûµ¿Â@ÇKÀ¹{ýW\!ÙѹðÿØ{Sㆺ©'×")ܤü_Ÿäš¾: iùêmxE‹?t,Ýþ˜U2 À…o¼.ñ×·<Ó¡¯¬æôåÍ勾ø/é]Áendstream endobj 5802 0 obj<>/XObject<<>>>>/Annots 3001 0 R>>endobj 5803 0 obj<>stream xÅYÛnG}×Wô VNDzîCæ-V¬ÀI¼kû"ÀhÎ4ÉIæÂÌE2óõ9U=3]T´ÐZXŰAððLuU×­«G¿ŸùÊÃ?_… ýϪ3oéáúðéãß?œ¥ÁÒSÉjÏJùž· GTªgƒüe X+š¦£èz¹R #+ê0‰®–‘`­h³èzµLU€$„`°^Æ‚”lêÓ²³h˜Ðfâ—MC2ˆ-+ ý˜t:’½€ý±|ÚRˆ·"0m%¥u+0Ø$X&’˜ì Ne&–]æVìš=áX+øn¼[†pžÝPLaed7ä0‚SV`°ð‘/e»òNYÉäÕ)+0L#ról•Ä`ÓSY›1‰J­ãåZ% h?B)’¡I‰Á"ZPêXÁ"IOŽ˜|œR.ά5ɳIì{l/#ö±ÀdÔŠ,v¬À`‘Àˆc»b£+0ŒòRJ¸™•Øú&Ï,›¯mX“-r&ÏlLÕ.XÉdª<Á 6õ`”`»&?:Öµ‹-h­bFÖ(‡! ¿AíÌrÁljMó4&ŽI AßGå ’ê#ާÞE9n‘Õé0D#*ZÇZs£1ìqD;e4ù ‡£‡ÑWÓ1+0…ŽŸ}VÈ£#쳌„ìÈŽ²ŽÅZÐëoe Ù‘e˲¢ÂÍ‚e-r²kekeW£7¬,#!;²÷®hfÙ‘JŒÕ&ÔI,"QŽl„¬"2‰P' ÂãE$ÈOiWä1bƒø€³˜’"&QÇ Lq§.#XÁ"ÁZµá”PÔ "FV­Ã X­c‹¤Œ¥¬À`×TYne« Ø>OY1bµ|(X Q>¨+0X>¹+0µ>ê_޵jý1tV #¡vbQ u¬ÀP»¢ÃDZ6ìž ;Z׆}äpò¯T4sbQæA’[Bä&;‰¦E66Ô@g6&{Ë Ç‡/ HR@è cZfž¬ O&d¥R8Ï)ƒ ¤’`'hk޵ ó䂃šc81BÐçegRb°QDJ+0XN3ÉPLý2Y!E-b L²)’ß±onŽíN½¾Žàu³U)FÊ5¾å<—âKvñþØï›Zõǃ©ô¡{uó«X§W^Á_K,|übÒ½É/nƒØS§H&Oè´Ï/ü€$n¬u§ÛBoJóÒú~éÌv(Õ¸Éë¡Îú¢©_@ë`ªÛ|ûIW‡q—¸ŒìUSß™¶/êÝdXYt½ê¥U¶×­úúëS§þßÃðöÓA×9 'šÍ¯&ëUQÃŒj(ûv+Ýî†ÊÔý 8ì$-~éÈ–)ɭ釶þÛ øQ"ý@Q³Îè*]–0¤ÕÇ—vÃdEg~LÁxâêïÑý¾AèM«öHŒ®x^.hK©Ïp{HÒ'Ûõ¯Å*¢ç¿o²®o) ×F#ü¶;¸ºù±É$e>=ö<¹˜øã‰^õÕÖZq{q®‡¾ÚóÛW¤ÓYôÈ#—êÜŸsš+àtEc £§Û(?>6ÇÕú_FmðeÔ†_Fíœ|ÏU¿À­*¦ëéç ¶¦Dè?ϔǎí±Z×ÉçU+î²$0ªïuö›Þ=¬Õ¦ç®ß›é„9Ø_¸j¿ÛtM9ô8»ê§H©ûâΨ¢:4í‹coëmÓfÔÀôd…U¬: Wu_d/}‚¼ã}’Û¶©ÔÇE]ô?.Çç¹}̈~ü¯ýÜf÷˜ ¡ú0Èý§½sƨºé¦¦~ž®Í>ÑÐß Û-N8>ç¶:3/¬™Ø·3ÕFwFe¥îºŸwß‘ùã!Ú ýaèUÆÓf÷l÷>ž¯¯ãéBÐuuaÛÓNJhúVÝ싎†ÙÍø:Ô9¾´æ ‹öäxw)ñÔ"àóÿD&7]ÖÌ@þóî‡vª³I¤šíØP–ÌÐâYS@¸O¨û¢ß«ªÁ8Ýš “ëÔ|0p“ h¦ËÊGß)=qSE¯àd˜&ô‘ÂëåK¥;uohìTSÒ&æ¥rèD¥mÐ×hP›…¼¥ºnZE­ö“%êî’BÑ´ÄÀóî,*<^›{Ó.G3qHÖb»7r‰Ç¬»¡0ãF¡‹Z•Íý¢4w¦T¹Áe‡ñÙGÂ&ÇîÛÜ~ê1ìÑOF·e³ÆxuKõ®#{[ “O°Àºë/U¥CšaBSÇfÀþtλ=?­¨©/ØÜ7ºû¯ýïâ|ÒÍx}½Æ7q\Y);è=$¼¯ðÕϰã®0÷äÐrÅmê¦CŠ2Ÿb>õ~Ç%·âcƒ”#î?¥>²kphíÉ!÷û_GåEòá*ìÖÜl‹Úºcúƒ$j ÖŽ‹P ÄÃ6òKT‰Á|ÏPrP;ÁûFQÐﱿ ‚1³¯°Ì¶)ÑÜðžÐ*/:¬Ëe ¸®‡«4ôÎÂj›àm%Pï1*Ø ÞKÙCúõõôÆ+ÀKï8Ä_vðþ.áCícAïc¿o2~?ºhC‹éáEJoÜéY1Þ—†½øÅÉŠ„ÞÞœýëìOxP‡Õendstream endobj 5804 0 obj<>/XObject<<>>>>>>endobj 5805 0 obj<>stream x•VmoÛ6þî_qhW@IlùE‰ë¶ë—uug`¶U@¾h‰²¸É¤FJq‚bÿ}w$%Yr’.Ža8ÖñøÜÝóÜÝ?£9ÌðoÑ’ÞÉ~ôS<š…3ü±ýÐ;˜®ßÁ|q†¶ËÕ âÔ>ŸAœÑ2\„sø³–RÈ|½Þ|9‹ÿM×—0G:2Y\†—x(øZ—¥2ªœUð jHy&$OÙs°Wi]p0u’3hÆ!SE¡èù½ó:ƒU‘Ûù]„Q„ÿ¥ÁôÖ¢àïß³}YðPÀù”N ÁHƒ7Þ¹7ðÏÐ =ûÖ3}í`YL·ëͯŸo¯7ñ/·›ß6qßNȤ¨S¯š[óW=ƒ7ÿö®²‚Œ%ÕM@ßäÍÙzÜejbcŠÂåò-¡Š1|g€²© ¾ƒ¬s@‰! וÁüîY¢•K¼)y"2Á)ÁXʲæ¦.*ªß'È0`rU)l9lkQTT åC•+ÙDˆ|H~_qi„’cù >ÛüBŠªs‰Jyq.Ì0ÚP m-¶ƒfå€`UÝ£!U’Ž*ޝŸ®«38)$ô øÜ~„ÙÍÙ7@~Ú}^K­¶l[<`â«ZK`¸ÖJ1ÝT̾]Pºƒç˜LÞéåÏÎ,‹ZžÓ“†v½Góñ#Áyí‘¿ùÿñÇ ”ñiÐäC­¸±dÊ”uÇu††CÃ(;¥R)gsÍ¿Ÿ„s¯9™{Í<­½‚ÕTÔjêZT¹ågÎYʵ%û é’wxŸ`ƒMࢅ+«)jz¿[Ay­ŒA×ÒõÁÚ42ègÒI°ó€*+”àóqüæ và=t}²/±A Úd+Áaðéâϵ‚gijS9Ę\\ô¾ !J«¬Ds†¼ƒê  Y†Ä¢v‹ÍÌ| ìSBoT­*Ôâ°} ¿¥î&'èçíïï‡'˜<ªðѽýk‰È¾‘º¹U> Qkä°ã’kŒ/Åwä ›§¬vy[TÙ¤àw¼ ¢äÚwxÉñ\…´ãh¿/1x„†ðpDü_&p T 2ÐâÂ)­}òÐe!FT#o.á¶u5œðLv=¹E›‹]î¡Ú tu<°õÑ¡*õ°´kÃA`ǧsˆ¤¶+E3sBfaWJžd{ŽqY§>3Žx6q‡IÈ´Ú[ƒcc!KlÇ„#„5ö2ÏœuÎY÷œÚµ+\;«›`8ÄÆÇ× âãMåZ|;}œ¥˜w,KÎäŽV,aÆvÇJp¸4x›(÷C³ª5Bu<΄/¦Î k'!øÑo7»†gÙà~¿“ @„€mçh‡°ŽžÌïà°Í.T—ÀÁ}MINDFås|NOéÓ® `xBì7³;äg­¥†RãN‡Â(~஄êJ9*³0€jÉqüѺ»GÚW8ý€mˉÑöV´ïš~+v‚ß*‘ro,ºézåÂÅì2¼Š®`¹\ù ×ïIÎàg•Ô{ì€V®ä;»³¼ukÁ‹ûÕlF ÜÚq»»Z¾££ŸãÑ£ÿZpŒ‘endstream endobj 5806 0 obj<>/XObject<<>>>>/Annots 3004 0 R>>endobj 5807 0 obj<>stream x•XÛnÛF}÷WLÕ¦‰ÖÅ–~H‘K ¤è%*òÁŠ\IKK–»´¢¿ï™½¢,c¹;×3gfòïÙˆ†ø7¢É”³íÙ0â ÿñŸ¿ÞŸÝÓ M¯‡é”¶4]¥ãðmCÏ¿ãíä¦óö—Ù<'´ZÑå»—4Ól ÅÓÛ[šåNßfY2™¦cHøÛ(½¢\[[µ1³¯g—ï®h„3|k0¾J¯p/™­%••\ʪ’9‰²¬ ‘­É´¨Õ&g!B“üf¥6ªÐ´-òz#iYTTîíO”áÓY±-^(K;e×­æ>íÖ q@ÿNl6TÉLjËfÁö%OeÅ* Ë({ž¸Ý€"É›è½)2ç]õ¥d~‘cçk{ÉŠ“‰J²²­x`?M¯v-,틺:ðr0‚gl½EÔ²!Ë,-7beú´–"‡}’6K]|øPð‰µüÂe±ŽßU­]\Rj Ü)h‰1=6G#Þ‚ÌæçT,¾:+8øHÊ›ÈGíòèÒ¤¦`-Bâ>(]ë“Óž-÷ù‰ÃŸ”΋wq¥{ÝñAä¹²H^¿M<«i-tÎ¨ÐÆ"neçL)²±âçpÅ(+á ¨¥O¢žK£àcJ¯ ½T«º¬…–ìí<ÁÃG O |ß1(Ù¿:öÎH[—ié΄c~Áº²J- Î[ øy×°ˆvÀ¼¯ÃàjÊ yôèд’ZÂZI/•Z­mÌiÕ16‡—™U¬<ÂÕñ¯(El±-Ÿ¬&ÏxèCÆÙ=±(ÙI'áU”p –;Œ™Æéd‚oyòóO—µ©.J_Jý¬ÇIœèõzÑ÷=ZЪüøéþ}ÔÖ9Ú^õ¢–U±m£™¢Äàë¶,*KNjŸÞF& r&NeðäK`§»öØ<9ÿÞž÷;ºéùƒúϤ¹û|ï*Q¦ÙyŸâ|ùçË›_ÍÞKç à«ÅVÒ]#ò´}‘Apn˜ŽNŸ5˜¸òþÜQÏ…›y±wÒBôÒN÷zbÉìÔ*f‰|&XFï´TH·Ÿc |N‡¦ÜÞè…+½Ó‡}ÌÚ8XNÒéô†Aw¯d”AÒw°ÁÈ'%ßµ ¶6š')~Ž%”U…‹ÓíÙØø<Ý‚æäRiæ3.'NdÄ–ke—e!kJúP’Síš5KòÈKäè± 9ó¬;‘OÄEÚÉi±wõü¹†$BLÒìÉ}GϸJSɽo´7ÎSž‹çƆ7Ó@Kœ G’­„ïÌ[‘‚BsË‘Á8[€ûÖ¼CÊ]“?{ÒeSS˜\»áÙE}3Ã]ä«ÖÜ„™7ТümWeäoÂ'`Ž£®ƒV#ó¤EôÄu>ßÑ87˜²Ð<+ul<ìÌ®/,ä±¶ˆŠ§ :RªŸ\fPz”BG"GéCËí¯ ÕeK¦mg9ìÀ@6Ðh+­ \XáaS ã ©ôñLä#xÂß”~×çÁůAB1W>©gþÓFÜg=nrpãç±V7Z"†Ç¯íµc¾ß½^xV„¾³«¢á®{¼ˆm=åg_$ÇÒ` t¹™«ï¶pØè5ŠX²Øç na.«À-~XÀZG)yÓÒéž§I$Ë»)šAÑÍŸ[a38y~|ôs)ñ´È þûÉ1ºãÈgæÇYQ ´ÍãŽ=d"`cÁ*À„ÚYëe÷„Ø„PF!’œ¦ÐP¶—=º sçà&ååÂçc°vW3¿ ƒ »?—”Fy§€ÝYâQ­´h¡˜’xÌ什 G%öÙ04 ŒDŽDÃD‘ôØV—/FÆ)c¥qÛq° NCraûa½Ïà0‰ÝƒrLÌÍ^Õ%"À^7Êi£˜¹=(j¬/ÈfO”,ŽU;e$ÆïL¾ŒÏ˜Üz‘ð@e§ ¯&Ü*[ï=Yçy`ðýL°£F¹*ëÆØËw]Ïýæw˜ýÁø6}Iàð™Á‰Ö3×#Pû{òg‰nÕ «öScOc§NÛk9†W98+qw¬ž1_a¢†«qÞÕ–Qí&xp€· 5ßVܱ²R<â‡^V1̪Ã[KO‰-%Tz“ 7곡،t.*·t5¡ ëV\ý€ðpýþS„n¬²ñð*½ž\Óô&¬ô<þ &éWãz‹»É¥.žÜðf˜ç? ®‡Ót2öÕ{}3äÛoggžýGá(Mendstream endobj 5808 0 obj<>/XObject<<>>>>/Annots 3007 0 R>>endobj 5809 0 obj<>stream x•XaoÛ8ýž_1®¨ Drl'nîöÓ^·ilw÷®ÆõÐms#‰:’Šcö¿ï›!¥ØnRôÚ4µ$r4óæÍ›¡ÿ{2¡süÐlÎ?E}ržŸãÿšð¯~à;t9çsªiz‰ÿâEEŸOö.kº¸Ê'{Ïþ¾Ø³%ÝšÆ×¥É”+¼t~uE‹RÞuN‹b4›çÓ|FUSRaëÖT¦Y“¢rרÚTÛ²«ô›Åï'ãë š`[ɦù쌾lL¥)l4µN¯´sº$նΪbCÁÒ²3U)ÒA7ÞØ&%ãyIç£ÒøÐSù3ò¶†Am[Ø®Ì=ž[2MÐk§‚l²Sp…#+GƒqO[6ˆ Rn­]\M~烮ψà ›ÎS­vXèÅÉ·xa\r.š±]àßrZX*-nø¹³5!{àLoÏ€±ð»FœŒÕp§¸`†nG~c· ­¬£ŸMÓ=Þ¾ù[üœ® >eÈ‘§®ÊÑ_ÈoÍš²v6@S?ªHå¦÷IâE뢠ì×)e«ßnÞQV ‹ï\x·uªÍaäfÜy7®l¡ª±iŠª+õ8¾|š_>gÌo3¡÷ÌöŸ¢EK™¥»þ¡ìžØ•I°³|>Ëq,À-,-Ât TiMN=(·£•³5µ• xX3_úÏ9}´[ý Ý}þró‚3Zx·î´Ç˜wf½ dÛn"ïÝ `g™Ì4>¨ªÒ%(°Ñ »u:2@¨¤0ÅÖ¸hMv%/H¡zX®ÙðøÅ.å4b¿Æïc}6.é+nD¥qºÖírºa£*í›×áÀË­u÷Ñ«­©ªžœä´bÞkоÉZµ ¢ð3‘ÕIm úïQ4ˆd­#õ#8W&a”ÓÀüZ`S•·TltqÏ/gÅ 4T©dà‹¹TÖõB5¯TYN…ª€§SñUžâœ&ÝA’ØÙÈ&:ua»ì‘•˜!dC&PÐ-jzŪµQ˜g­8û £=Q5ó*/wÀ‡º¦ÔÎH}|ÑŸ”•¯I½=9_OãÞ!ý‰GOÏØ§È—Þ;‰—;í[Ûˆ¬Úåï EŒ*ÒUðTõ†kmtJÖñ‹‡ ;×oîçÇÅ::•rx:Dê[]˜•|QüØÿ£à_EÃGÁ'º›$lüz[öü¶¤®ÌŒÃTDâ ‡Æ×==XT…MïÐø@²%š_ØÑ/6è$ÀC~é¦ùÈ&ù,ŸÌ¤V´r•A±8]iå5úAÊ1§Ë#„’ ‰‚)Q`¡¤í‰G ÂÏR ½ð Ñ 4 ‚c(…ªÚQrü}—ÙwŽº_ß¶pÛ)ú-¶ ßµ­…8 ÷oG¬gðæ,Zã2Jë [jÚªCõK›ãKQOTè ®tNß¾IpQ-5x[lT³ÆzHW}îB€C°”ý^C5¥][äØõ Ñô½¸¯ýØê¯A‰T3R#Ç”ò¶¸×"‹OMeÔ礋 F¼hôÖ ,þ‡çmåí¸öÉ  R£ tjnòe'£`T8NîÖrðØÆâꉎѨÐ.(,©1ŽBüÞ0À¢â ÈÀv²À65ƶ8¾æZC…á" QßÁú-íPÿ^øŒÀ)‰/¼p}`¼!¨®©ÒÀZÆæbnl"ÆžD ´€“ayŠ,t‰JZ¤Œé Iªˆ‡Ì<Øê{¼‰]‚cMÏIsõãÏ:tí!©Ð²ÑKã`HÒ·ä}‚<éò㓺׼s/#ˆåI7<º4šÄä MT$¥`ã‘\™J0ا™œ4 ¡ìkÌ/]‹2~å”ØÃ„§{g–8|€2I{ɉ ¼íÕ~p ã Û³¤ë%E™rö5¨2K'Ã*Eß­!úR û5¶‡]N{‚÷íƒAj¦½:&¸0OC ^™†»"½ú_¢Üæzu5H mä¾nßüðÒpM–œñŽÖ•¶["¾O»;LæFáó¡¹W;&' :M¨Rü3C/â#éI<±B£Â¥4°zGF±Í'¬å1;8DÄOS×w¤(µnˆQìÌlqEæoÔ9‹‹'>] ÇòSfÞa6£w莇"º—àC%1ü@pÎä“p´ÏÁP”oSàÿ8¦Š^úÔŸ÷noÒŸÒAÙ¿¹' D3ýÈ“DÖ ïKëúøã¿Þß½ûõ—ë›w¿}ŒœÐKVöŸ( áà9#+œƒ_ÚøóÞ©õÙYÕÊh4ÅW(YUã_Y%kãë«t†˜\]ä—³K|q2Áà'ço™gfø‚æ'[t5ôsè! ]\½å³]jËßõõÊåù<ŸMqT®˷ÎÀûÅÉ?NþS¡ÀQendstream endobj 5810 0 obj<>/XObject<<>>>>>>endobj 5811 0 obj<>stream xÕWïoÛF ýž¿‚6LbÕ±§ † ÝÖlù°aC= géd_#éÔ»S\ÿ÷{äIrdí°}Z~GæñÈÇÇGúÃÉMñyAóeÕÉ÷Ë“i:ÅÃá‡[Ó‹»)½Lç´,h6¥Å«‹t±¸¦e.VSZf uKÕ®Ù…­Ï–ïO^Ü]Ò šààd>ï&Ù–¶¦,©Ö:§`É·MSî(l4yUi*ÍÊ)g´Ç#h«¦ÖGÛUkÊœ~“[äDaœL¥SZnŒ§JíÈÔYÙæp·óAWÏú6Ûò1>$/ñ!º‹RJ&¥·Ù£ãð“sÛîöå‘‘ªócÃ&lœVùqJ¯½o+S¯‘bVYhU ¶Ö=úsI¬Ö[zÒÎ[“-ú”ýƶ`¥Éäº&S%CìøŠ!“\ª-Ãà@Ìt˜ÏméA×⻲y[êX¸U扩©Q.ðÕ\Sí§ñ3É\íÑ›]2z?تBH7¹Ò=<9dh2}ΗS—CãìJ­¸ðß–Ô“59ù `‰’Õ )¨±Þ›U‰ú¾µ`Ž­ÂU.Öš¡@¹M ¢Œ8ôWïÓÑ Ò[ëøª~kGv…u•ª3Üø³Ýj!VäÙ+´Vrájw0`ÍA\Ë%r йQ8¨¹©P3À[YÜï *PcO 3èCk‚¦Â©úÐÔü·.l$jÍ)Ú(ïQ0xàÂØ#E"•Z4 {8ûL•\¸2¥ â_l ·±ˆ}‡$ºZé<5‡¥º£Âp@žr Šd* œ "• VZ#] "jÀ—<ã vZ9ŸÒ›'˜ òv½!# 8pY5 Û0¦§Ü§à*é4`–^œã*ÚÐB'XK€³nP ™”î (yL‡ÈÇʬ7€¶|‡ÓÀ€*ÊMQ@{ê£pœU‘‡„بÆw®sãCLéð_ëJ•ÌÜ"óE:K¯è Eú0vßW6¿L¥§––•/¶l4=e*–K~Îèp8(lÃØo"ÙknRAŠCk ™Ý게Pˆ.³  ß ¦TÇçc`2›¥ó9†Bž|E{Éç’AQóäöö–b…p‡ž^îž§”á!¹|8ãX³ËÑ¿ð7NEFÊl)¯)ƒø hÚ9p Ôæ $D{Ê|˜ð|`Ä@#0ƒa+lYÚ-(ñùô¾É¦W*{¤Ÿùjð²\R©|x8ÿCbDwÜ+§ßú›úöôœ•N8Œ~þn”toÚ#ÕìzëÙ'­©‡üݧ0¿B¼a|nèWŒê(û5nNÏOÌí=Èè!VoȥЂ*í½ZCÓMÀß ÖÒhPH)ú| Pž†ófä·Ž;Úá&44ÊÂÎ#”‘oËM^hröàȨfGGgø¡“fæ´RúE=²"@†Èº@°wì#'$Š.@‰Œ$°Ç(õvÌÅÓb—[:БӰ°Ò``ùiëÌ,BzHÞuB!ýÎmórϸõ¯£óÿ†±#Žå;“¼#ZÎBÃã « 3S+@´kìèÛ‡„ÿï!>îÁÿö1.ØxÈÖ…H«RúX•[µóècˆFNÛ ¦6#•3K¦ ‰‰%«6å`fWïu†¬Àô”îÀà®Ñ"±w2ì‚2ÅfL0–¡vßïG<fXg––ñÙ¤GÒE[Y‡Î•dÁÚûNeà #W¤qÈÄ;8f Bç^‘¼»ep?´† q[Ö A@Ñ|î™ÎÄEß0ž<ÀùÕƒ4¾Þ{ÞËP€¬r˜)ýh[Œ¦I¶ÑÐ\ö ‹)†ˆŒ«êYÃ÷WóC˜’¯&|ô¸jòr¥B¶áž>hFáB܇ ðGìrÙ ÁÞ[ÅùÛ?u%‡+Þ‰Þ(À ×­£²@!KìöÒB>a+~(|²ë©Èh$"Pí5æ%ÈT¦T®gï?…ÿzÖõ„Þ°ùçØçWúâáoDUYTðîaW­lyC¼UDn½ìÞ¦\¼¼L¯æW´XÌÒ븺H‰æé¤ÊZÞŠo>…ˆÖ“ë¸ÐÈâvIoGoNØòjºHç3lxï«ë?z³<ùýäoÒÑ endstream endobj 5812 0 obj<>/XObject<<>>>>>>endobj 5813 0 obj<>stream x½XïoÛ¶ýž¿âbØC],’»q»bëХˠ{í[3l4EÛ\$R#¥8Þ_¿s/%%r³öíËÒ"±e’÷×¹çú£šáß -–ü_WGß^Íò¿Â†¦çOèdF—k¬]~‰…|Žzr¹µ‘L>P–{²®°Z5&R³U í}Kk6¾¡ÆãC]¶…¡è+C~õ»Ñ ­m‰Å8¡´« ‚Åë°Ùà»¶nC~-oãVStËö²/§Õµy|ùûÑŒ²“9|›Ä6±ª}UãhZùf+ûßýrñ=킪kd7)WðÒëvc*©~Tà­¢¿5Iƒ™ZÅHˆ¼óräK0´öÎg Çö¡™w«çOØówHJc+,j]0Ñ—7ˆ6î«•/‘­áçÊhÕFÏú8¶*â©q¤ƒAÖ N6>^·N7ÖsQ„›è5¤t“Šdnml8ͪOgïJJ¢Ôµ¯¨˜Ž´ÛŠ¢­QEŸ¿®œˆŸ £K”Ø|È…ütæ;'lU—¦2޽†Ó¶!,:È_å9 ëà«;Wig›­ojëÎè=¿rºô(ð-žÛxœÀ lƒ}SÀïÕL-’ŸÌÓûÞhìöô,”‰§‹|¹|Ê.9ôçv™,õ»&C Ž (›<ᥲ›mCÆiߟAʳöeéwŒ„¹tSK0š°çZ2 „OR->žâ/^ZÀØIY%â2(mVJ_ÓÕ¤òèV`½¸kJ›«Çr>_—¹sFñg_ÅP}ñÙ1ãÀÐÉ1÷ù7£³/ÄìwÌÛÏ9/ÈVýs†2àB¾F§w¥¿GÒÏé¿ÔÛÔ.€²ûÑéØáO*O_ŒƒÞ›"(ÎÆ8"€{¶ãÎ*öNUVsLר<Ÿ•ž'ÍC756<  §_˜ÎFüÎôŒ ƒSÁpÅ1ÛÇ•&Ë>6(::º’IçÆÞ}Í(Z›ÅEÌ(v MS¾³äÇÀ Ó6n’C÷x"=¸–lQ]Kq=ÑÎ09°Èü‹!‡öw›8Wás:·!6wT ¬uÓSàüɵàiPT+°ŒuàüJBÆY@F‡èc1½¶®½e²§Í‚‡á¿AEB=ÕLÏJZ Í“ýÚ+ Ð'im6ÐZwlvwØ?æ°—%8Æ!}7†Y¾OO4iPâõ«÷¯/¾ýéåO¿½ûòò‡Cwcƒw]B=0¦Dpñ`yiW²ø”Îägh´ §£_Ú–%ÊÛ=d„»Ï÷;…œÇ;\Â%t¼*>ÎãŸcLÜÐAQ¾þ€j±;.Û#¿‡B}hÊŠBHøCR) íÝÚnÆGcÄN¤¯³Ì:¨žåúä RbÎFì@6TAY@5!­`hTÀ à6älaÖª-›Q1b¢ËäR Fg‘r5‘ÂwÂ8Rð˜7JkÃ":©q@Î ‡ªÅ_ ›§DMÏ¿$«|-ÉæK–‹e>Ï—t&Ô•ìáêpöÅw*Iôåã­OrQßÝE,³Áv}@ü"ºZ}½ï™7§wÐÄi"%x1¬M¨ƒaÈï‚m Øð˜ÎôºHG¹kp«Á41µd¸’w|¯áXpôÚB.[¨Š*íŸH§O0ŸÄGše>/XObject<<>>>>>>endobj 5815 0 obj<>stream x…X]oÛ8}ϯàÛ"‘ìØ‰“.° t²íN€évf“n_´DÛleQCJq¼¿~ι¤d«mfÛ"udòò~œ{î¡~?¹PSü½PóÿÛ“ŸN¦ù‡~­&ï.ÕÅT=¬°vñJùŠÓ»Zé²´­uµjj76œ«½ëÔVïUmLɧ¶.ª®4ÃJ]©Ê.½ö{µ²• \³Õ_²­Ú9ÿ5WïœWæYo›Êœ+»‹ÚÕ[¯qŠQ÷]­nÏÎ^=|9™ªìb¯N ·m`Ï+8sï*í{gܪ5õàVº†ýÖëÁš¼C2$ÐÓ¬ºõ]öÑŸb1œdŒë—ßäs&ff³|>Çoåé_TØÙµÊг3•5ûvR4¹í=f±òöë†o‹çç?ûþóÎë&Ç"•ÝMºà'•+t5IùÄ£fùÕlük8ÃõŸ¢5§²_&®i'÷ÿý)4ÞMP•9õ¹w9`ÉÒ‘IÐó|±¸f(Vªp(ësœ]KÜ@Ed™*Óš quÖ8ßêee²,#pv¶ªÜXâÙB¥SÁmi¶1ÞnMÝjb.O‘Î.éÂ=V´ø2¨Æ8¡6úɨЭ×&´„âF·Ä˜ ÀBaB =o*[·Õ²uk|ãá¤?Âð&Î ÆzÌ~ BnêÀ~غ²#º#¤Ñ)1/ ÀÔ…Qn…'ðEw@ˆgÚðËFÓ¹'œ«‹¶Ór ›Æ oÒJKsp=WÿÇSKôE—V8`gÛ {qŠ=WÃh zÅ ),ºϘÀÔ¬[iBáí§ë¥{b‘à`åÐ…øŸõ’Ôá6E>òdȽÀaAl~XGo·*l\W•€B«Ž£‹…YvßŪŒ‹}7°Bý×VeÜ£Ú@\íZ‰ŒÞ1?ȵ– N&š²ëM‹xÜWl+ØÐr®½Þæêª©ë½úXÛ¡A%Ï[]llÍH˜G~D"UYÆ'öa¨Œ(¯pTJƉnL]ÈK®ˆ…”™µŠ™jéP)Ê#ÜÐüf+aÜ[7JϽ» ð…z%¤Žh÷ÿ1b–ë:Sé Ú²8;Ëð©XäÙE\>Sÿ‡Š¼e—¤™/z<>_N§¯§Óéã«—ØÒâB,­¥'iûÕòO·ßmOOÒöëë—·ó°IU"¸º{>öýÓd –úH³ôú|ƒšbÖèBáG[ÁãéVÁ8Üý@ „2± |ô|V: ‚ýSXüÔVåÒÐnÚ—jKØå5|Æ ×';bÛè: ‡žFl©–@¬]­ŒGçõO=¸ŽìMW„Z·6è ÏFí‘Ë@ý‘XçcFmÍÖÑ3 ˆÒï‘#E¥C èÑ8¥n5‚òØÑã™å,á<CYˆ„ކ/z?Xغµñ¹¢XÖkW‹lqÜâ‰}9w`;ö £‘]°laÊ\ýìvdh°W¨Iˆ i\$Û‡ü ¤3ÌLÝM¡èÃú˜î(f@oÂÈ“ž}#™öüÊÉLµÊ ‡á”G1É,Ý92åV·˜jÇAp ‘–{K€ °6Àx \k M7ò‘´Ôn˜°(9ýä,¸Á¬‡)­Vº«ÚX?'x0ÞÞEO°È¸Ë:Öh%ó’'KR*‡Ä14Ü®W®FÁ£Ðùip§I¸eë'Ì}»Öm/Y}¤ ­°EŸ ­ºbCdÞ~x/3fòîµ¢¢¤àÍf J‹ù"Ÿå×êV&c;-.³%XSé–&¥J‡çÞË\„ ÆÇ°(vmè³7_¥ŽêB&‰×;oŸÏ•i‹üñÕù0¦ æhóæ÷SÓ„ä.£’®}‡6ίQžR½‡Ù•yÑçb‡r¹”ŽÆÇ(ÁõQ÷#L“À QŠ™KÞP¡¾l»tGèû­4rhmР"N†¢¾²Ïj>“Óä¥ðÐÀ,hAD£‚†j9ò¬œêZ[Ùÿ™d$Íë¤ö̳):Ñ ‰¿Ò½êÍУˆî}8>i‚80ܹ¢`ó yžBfDd‘½Š-Ѱét ´ßß¹48t€ “å`&1jíhLçËŒÖ÷dŒ¢ø€å`_66ƒŠÞ³¾›G¡¡fX,ÓJ†evX¤y¨ü'Î0”¬­ú"ŧîHœ_Ì ´µ‡´‡“i\€ ^jð‘7B>ð£Æzªà(M{ÇÑ÷&_çç¸{ÍgÒqY0Mx|5N2(…ÿB ¢žoŸ—ÇÀÒ‡$­HñÛ÷‹ËÒÇÒ 9OqëÀ}㦎UÙê×»[ôw(:ŒÝ$üjÁký(.”„à Œ±êª‘øNââ <…ÓáˆBиPš"ý‰ ¨}b|ð¥Å%=Œd Elî!Ÿ‘;ƒÀ8—<f5¦ DtŸ§(ëÉ´$·4éâ’ybgj0… 7£ ù Óv– ôÒ·{Q õð6ùóM~ƒÊ¶}·¨Ãí$~䱨8—ÐR ¹'ÑO0ºÅ!¡ˆxÙ?´´Àã¥Éu£~âEŠ˜8ïmYC‡H>A5¹ÝË3l0 Õý§;¾Nèï¹p;Y’ åºõ†·2»µil^V}ÃëwìM/V¹ú8¼ÞaÅIÙñŠhÇ[ѱ¸°ò‹+”„® ŒÐÀ)2À°rO /eŒ7xÞž’ç;0(^@ñžúx*nÊË€f8!~ôvEDòÍÈ2qQîðÚŒôÈämÀu^Ý·]i^MçÄ€¨9º>F[Dx×ä )K×.”éŽø¥ÃUR^4Ä7éEÖlz™_ͯÔâú&¿‘w$¨]6ϧ꟮è…ÆM¸ÄµÙ5_‚%ͳHšGn#¤jÓ¡öR—«é" eÏÕõ%m½}8ùíä:â¹æendstream endobj 5816 0 obj<>/XObject<<>>>>/Annots 3012 0 R>>endobj 5817 0 obj<>stream xXmoÛ8þÞ_1ðnQÕØNœ´ ´MÒ Ð&¹$»E†,Ñ6IÔ’Rßáþû=3)Mo{E #Éá¼<óÌŒþz6¤=üÒxÂÿ“üÙ^´‡7ü3䟫Ïö_G‡49zíQNÃýíSF×¼Ÿ&‡‡²6:ŠÆÍ/µs:GÃÖZë1§£ÃhÔZk=æ4„”p m?cu¿{eû«“£hÒÜ~ÆêѤ»ÚzÎi´×=ûþ¦åñ]Ò«Ó}îÑÍ>œ¼Æ©¸$ýwŽÌ‚ÊMµ2Å(:Ø¥j¥(Õ®ª+9ruY[ѼÖYª‹%©ûJN›ÂÑZW+úŒ—¿©+–Ççæ>¢S“efÍø•.\eë¤Â1Z)«ÞÐÎÍ·–¢C(Úß\#Ë4Ž kÿR”kß¼0–¾è"5ëF SdZX¥¨2&s]éÁ }r+Sg)-UES“«b[©4jníómg Y+”J!ÌNÖüÞ’YÞI‹­‰…©”£Ø**­¹Ó©JßtD~Å]ke„&VÅ•¢˜Ž?}‚ƒâŠ’¸ ¹¢ÌÄ8 áfï¸JÙÒ*üFt³Òˆònœ[­0:U.±zŽûyí‡áúËÙG OÇŸub3‹ŠþÔ®Ž3úðòeD@ì=ÁÑ* îÞ¥<.6AÐ ×Çy™á]$YŠß -4¿ö£Ô•þaºC‡hš+(;úÀ^SªöÎ7”¸ÏªDÝ)ëSA×Uj»2×ËUEë;ÙMñ-{ò¯Z'·ðŸ¹%¸¾À…-µ)NS-øÃxŸ±ÜQ¦j9÷ :Vw*ƒ®–¼»Þà œ`‡.îÌ- ‰Ù™Ií*“7È1%ßÚñ«Ùó7S@mgq¢8 ¨màAx¿P]BX¡Ö´6öÖ•q‚E*1æX¿+Ë/ú_±˜:•q<<¢€BŽŽ˜ñêtxÔ$ÿàÜÆÙߟŽ&‡’‚ÌÀkM¾½KƒÜæ[JÀ„² V€ŽxóJ¤åiº³ µ6)D<ø=”ÃÖ"Ηü÷ÚÆ%{R$ ö%5àDŸ)‡e°”4D…i_«¨Ñ¤/lÖoþ¤‹[ºÌr-ÿ6­W¦ç6yÎ6Þ½Žtí·!ÜÿÙP~©ç3j4Œ°…gΰžR¦;µ]d@³OW ^v`( Ò5Jå&­3µK¨ ÏJŽÊMJ_¤ÎlR´b1”Šª-¬—:EûR¶Tl3®ËgH—½~†b%á½£~¥0O¼ÝÊbKk¤~²¬i?BÝŒk´€t"EhEÖ+´Vè¤X‡¦ïmèŠv²Š‹%r&GÛø¾[ì;®•­ruV1%Kí˜+.¬]Ô½JjtÖ,÷¥5·.ÒÊ4­]˜Ú•0DÑ{÷mZÝ´ÜÜ5AߎFOº‘]Í"swÀŒ·P®ûØ‹1Æ¿ ÃPŸ æ>¬06³.p¥){uºG<½azGF£h<ÆSÚÿ½™š‚‡$Iß¾}Kþ®ÿï–K ‡Õ]U5íïûÒÁ<%bFûuUˆ*ãh‚>îafá¹s„ߺ5ýLL?±ÖØ®>”H”¯¦Œ–Fq'{0äã'7´ŠïÐÿ»4F@m ËÐ[ƒAÛLáǰÐÈÉ ‹2ÙæŠˆû3^iôæyºÓ¦!jp‰3è o1ò1r–@¶Åe€VÚç©r &ó\¥£pQ—xíC±ËÒƒCe¤[b?t8eµ©K›g*hÕ1)ÁÎ$¤dDaÂcç@“[37FP¼Œ¹ºˆëÖÖ`3´Å :aN›×Kò!Ø–£jÅ£Hã4áͯpƒd™h/tš¢åŽ­AÍðLÅÁ™ó jßÒ¤µ$1˜šS¡²1F"l0)ÝüzG/ŽY¥AT§5uh51Q!Õ¹MÕ›ý¶&á„*:ã©O#NËp^ÎLùsP´d`‚ÇÜäàÞ¼¾^i°?F&Œ×Ðâ›™o{…8§¬ÀÑ<¾£  U,À€˜Ò6‚$§¼¸B‡;õÈÒ¿QEjBü½“$ø m9\S.óÁ¾G©Ç9»üzó‹óÙÙùÍÉÕåÕ ~gç³ã“÷||œMŸ ÝAÇIò'»ºðÏã»LJžÇ˜õÙy¢O¦™sµÔ…¨ ̰ÔÀÀ‰AðC¿~ø¸žg›;êHÌ¶ó ‡ cÔcÞ™}¾þ0ûóä걑^M|K@ ÁÇ'þr2Œoî üÌÐ%FNû¿©ø¹˜EÏÿ´ýM/`=µõØìoÞ/RÂþ.B‡T‘±sÇóÿxóÂŒ=<ÚÆ4™ì…:Á ŒñuðØ$5f¨JºO>÷»‡žöÇ“h‘ô ©&ÍN×àóô¬Í·/–q°7‰@/bðÁá¿:¹yöÏgÿL’îendstream endobj 5818 0 obj<>/XObject<<>>>>/Annots 3015 0 R>>endobj 5819 0 obj<>stream xWkoÛFüî_±`XA$ÚzXVZ4@ãÔn€hùb =‘'ëbòNá­Eÿ{g÷HÊT·háèqÜ›Ù]}9ÓþÓtÎÿ§ÅÑYr†OøÏ˜ÿüqÍŸÐ|~Ž¿MΓyó&§GÞ4[$ãß½^>ˆ%Ë[:½šÑøŒ–k$¿Ä‹LráE:øà M•×¥§º×Tê­+ƒÎÈWiª½'ciU™<3ö–ô× ­7ÎRá²*×Oòç—õíç”ÍÈ….)uÅÖäšÐ¯n§ïu9$|AÛÒ­r][?_~>:£Ñx4ƒ.Aå¾§7ïÞyÚ™°á‡¼Þ‡#äÏ<G+@U’«‰©‚Iºr¥$ÊUÐ>üÚ•¾rvHµ«¨P5í” "uÖW9^˜Àé‹â:€>¾½¦æÎôϵþüôê%gÉ,=š,øe6˜Î“)ýŒ„U‰{ÓJy“Òåéå‹´+Õv ãÓ{‘F“Y²XðïkÊôZæD( hgXRnk²*T¥Êé·:l Ž±A—k•j>ˆk—M¾ÔeU6eF<©RG Ð[yZ·_ )Í•÷ÚËu[•N7G†"»w¦Ã&¡åÆxòZ2Ð h×y ª°Á4jJÛ`Vù-Žy&%ðC-{2Q\³£É¼%Åþ>–Þcœ ßK$ªâ ´””þà8Ölÿ¹e¦d°(}†cÖB/BX…Æhº¥5HèíZj)ž¯é¯Ç¡[T±ÍõAÂéKÜP«Q¿«´–(n4=9ÈòèMg&ô§Íti5zDh pndˆ‘0>*Ðåñ(Îí+]qzÕ1ؤL¶uÿNx6E¹Ûr\/ÿÆ/~j#z×8HèãF[J7Ήè3Ë2DßA¯ åËM9{ØÄ䦞…õPÒŠãvø¸gÂNÕp ›*Ä´Jò/T™=Ìód!Nö}ÔÇÎõ*. ®s·B¡w}uØpVïZ(´îp4³†¡aÌqF ˜ šbÂY&ÉtŠwY[Ú+ŽïÌN?@¬ ÜÈ+{óüÇ>Ü‘„š&óùOK” F‰ÁY-¢CõZñbtDî@ hçÊ;ÏÈÒ#È „c͸òïȈ§ýOÞîÕ«Wd K^¿Þ–|Í> YÔ1™q–î-‹YaÚâ3‘ŒÚHÛ6¸n$¼W¥áÑ$ŽøpžvZGG¿ŠwÇEñu•ãê¾Ú6£uU‹AÌÆŠ6¯yž:Ý(k|A쥘Ð;f23ëµ.ažL¬ s» íµd”ê¯lª”Uâýl¸;Œ>/XObject<<>>>>/Annots 3018 0 R>>endobj 5821 0 obj<>stream xÅWmsÓFþî_±šÁ[ñ»¥é@HÒ̤Ʀý’™ö"ìI§êN1†ÿÞgO/Ž_J˜LdÝîí>ûì³ë[}êá§Oà ÿ÷ãVÏëáþÕç_×ç­Ñ¨ï ñvêõ(¦ÑtìM˧ˆf­ûÏ1ûo|ï-Ñp>>&§:³$?Š8$Ǿ®xýˆÞfðF:·t'¢\’IÐ -"}+"|–)q»Ã0uf¥[ÏÇ9ï÷õß;vÜ:“EBßugã¶@&FÙ5ý´ŽF£ÁŽKÞ ¨N,ì’t*3a•Nœü‚ß]?é{ý;ØT­ë@z“É”Q½i­s\ùA’HHf™Î8Š ƨEËÄvÜÉ•Š"ʤ/ÕÝ=‹X#Ò£3˜—‘|»Ú»BB{¿É(Ò{Äçøs+ütÓŽµ±.0Á'ÆÞ¸ûjº©HÒÞ c•ïu(R‰¤~‡³ûµé{ÊSNü9˜T'þ¸*ÙM;Ð9HE7vLØo+6•¡@ú‘ÈdTKK41ØRÛ׉±MomÄj f«L¤ia%¸º:‰Öµg^Z+ãÔ²šb¨p KƒÜ"eÅLÁøUVÙ+sŒ˜s2t´D¶qn6ðá U¹Á‹xëöUç¶jÀ çÚ(PÆ‚2ßÁýOe„EÿËP‘„ü¥ÈèIŠù¹ñzÿsó±¥yì[^ÊøÑ&­¦™ÿPêd¬X. C AybUT–X~L#å+‹²Ê0„jA~$_r£’ŸwƒíÑLnʳ5- àíPȲ¿šJt¦BÕÆ}Z›j´Ép)¡ë! ó DÈÀl+Tdš¤*Åå}Ž~] t+ÓÓ) ™Tú*T~MbH™N‡Lž¦B”ýâdÿ졇Ló¼*Ë/“Ü¿ÃCº®{"‚VDþ›¹9`€¿H²¼•Σڅބµð}(m šA'r!…C‡´+…]¢Czò¨­äUm^׆$B^¸o%·U²ç ;z»[ŒXGŠMÌmÌ)Ç…¯‹ýOdVjAÝ´X*_¯V5/<Õ p«éf:F˜èVD4” ¼[-% ·501DNas Ù_ç,…y$G%–•lmƒf:¦!æE½Œ{ ËìA|ãé”3:·þhýK`Qendstream endobj 5822 0 obj<>/XObject<<>>>>/Annots 3020 0 R>>endobj 5823 0 obj<>stream xWýoÛ6ý=ÅÁÀ§µÅNº-Àš5m€¢éVÅMQ6YTH)Žÿû½#)ÇöÖ´uaéx¼{÷îÝùá¨O=üéÓpÌåꨗôð„?úüñ÷Û£áÅ Ѹw‘ôhE£þ9þßrút´ûoGãd¼óöõtÇ¡÷jtzÝ£ódHÓŒpuÑOÆã MSm¦²ý‹4…«DQ‘Æ¿ëÛ[úFƒ_O¦wG=êöa“îØxc’KaéE)ª%Œ[§µ³§¹‘"oùc§×#âsuqgw0Œw¶¯%UÔ+ס•¸Wäj«¨ZŠ ŠR•éBWÚd2ÿ„m•þ‘U-ò|C¢,•°Ñ’ ¥©²”é\œã{Z[6ŠY©¥Yw»]5I 8©©é®v¹JË{…-øýôåæ-ã¡l&$êjiêŠDî U*Ïu±ð7]‘4«·[s¶ÐUg/iR7ÅqÕX&1ˆÁˆƒø`*õ ©Ë\„D]ü¢RŽØ–Kàl{ôóâ6 €2öG, éšH= «Å4kDãûÐ]^^°F™Ð ó„_gÑWqlÝÕÅ}«ÓZ·f' %=Úl¿µ µÞA† }16Og³¢Õ¡ì{‡"pÑæ›Ýp;£Åx<9Y]p¯u ˜èbŒ,¨CœYÛ~L•*qh¡%ÈõhòG•rÿb6á8(Ë Kó¨,älÛ(@h’Ðð^‡š´½¨zºnp5ÚØ¡q3Ú”â¡VP÷¼FŒAÅyx¹RIª•^¤˜~ô ¬î\°ÒzJ6!xäû´Ö º êÏbÇ wzL˜Ü½§ù$g£Iï’~Ù)ÃS±“DÔH™UÐ7*.'hMilRA'‘6]íÔC¯ž+¶i©4d ®Bš^‘9ÈÍvt†÷Clû E<,›¤ã0c­á†Aˆ˜Ü©aÙE1• ׳I&ÛíÛ À×Ö¡ÿ}¤Ú±ƒU-—˜àªH,Á{8mXïKÁ ’Éy¯aÂ`¢æYÅY»õ xÙñ&³“B­YïvÙÉAeΓÌU(ð"┸Î)ú)Àðan•BÞ‹§'ª=D°"a{°ê¡Ö bHm{‘WÞ‡ÄþühÉPRè7öÊ=ćË-r -G“ ë)à?nT ª±š(±ˆÿ,‘æ¬}(_eo<é÷{ç_˯L…}"çXó:¤>E\˜ŸH‹õ¶ö¾ ™‡~|«'Ì•â¹s=·ÂB<"•<‘~&ãýÝŠÇÕBÙŸÍæÿÍ¿?<;ÇX;|7ñwfªØ°ÂBÈ@?,%X¥Ã¾ò"W,3˜ €(QÉ6;ð|^k°H®TÒ· Oⵟ¿H(È@3²Ÿ÷á¸f7¿ Ž{ÇÌ­Ÿß¿ßâŽH¶TzGP)¤·íú¦ðsûY–ÚÞ+°- T´öw°Z8–9öš¦ 8oÆhðk¢Yk÷"öí6yp8Ï\¡¦Ý³88¾0¶N¯Ïã–ß?%gÃ3OzÉ$l"¼áu‡ø-ø§‘øIaçýšsƒuwF«_ÏFtõ¼ÜBMý.6?ëa{`™Ã s69çGo¦Gý ¡êendstream endobj 5824 0 obj<>/XObject<<>>>>>>endobj 5825 0 obj<>stream xV]oÛ6}ϯ¸/ÅœÄVü‘8îÖX³fPêm/Z¢l¶©’”uØß¹¤äFi– I$/ïÇ9çÞÏGãoB³9ÿ§åÑëåÑ8ããáÇnèìæœ&cZæØ;‰‡,¬ã!‘ß O{U´–$?×j' ©=yƒ%I¹) ³Wz3¤uíIOVŠ¢h¨v2¯‹!]Sj2ùãñòãÑÙ͘ÉŒ/›Ži4&³Þ²ÁÍíÛ7t’ÓÏôî·oâ½Xg·²AžÆÉÕ _‡…¯‚‘Y2Ÿ_òÆ_•uº%á¨15•j³õì´Òi¡´D(†J“©¼!A•QÚKKˆ¦–”)+S§skJzßø­ÑCÊŒþÁ'´D˜[y/2™ªR$5BĤÇÛ9;e´L¥sÂ*Øâô8QJvˆŸ ³Q)Η²4>d™Å^2yX­u&mѰ]³þoºÕÎK‘‘ò|›°bOëÆ£íé6œž/!´èþa{(äNàúLVR‡0Œ¶µðj'ƒù‘±p&¸« áscKZ T"ÔZmF|\hÚ¹„ å}!Û/«ã„>¨Rñ {.…Œ’Çõ\ ¡ë€”T8ÿ $X¤åž|S±?äTY!ŸV”½âTðâÈyö’cD‚JÑüíý>Éy_!™Ã˜Äž3•°^¥up“2¡7ÒšÚÑ~+5±K|Óõéi[Dy›‹ZF,=rÛXJ·lW¹ˆ«! ¯B.ioU0è ±•E%mÏ™¼Ö©WØ ¸†ª't‹€bÿ{^(ͧw&qÎNèj ¡“³ÞòkaéäÆ˜¥ÁÓj€'0puL}#DÈ»¯­Féà ìÈûý§5 6‚|ëéé3÷†‹`jiðÔ]?soÖhQªôŽÓý GN®Vì·pÅ­Nm¸!¼å@TK=uQa~ªž¶…èEô¿å§p—äÄøcìì•ßr.†5nkê"#QìE2G @##÷€v†Ú×jnêÏ·bmÀQÔaxX஺Aˆ˜ má­ÍÀ†ÚÔ´|+¡Ð®S¥GÅ Ñdƒ,Ù±= Þ-ã§®c 8\&#`¾“Ö¿€D“egÉY½¤ <ã63šÎ)³yí¦ÞÖ)&]ß8ï;OÎygK¼½¤áij´´»DU• ÑÊ7¥…pÈb†Êšhˆ  ~B&.„‡‹Tö³Ýþd¯Š—ÓŸPô¶€0„ÎQ¯A»ûa3üòRáõˆf‡&×vV÷|㼺º¢Úf«Iôj5Xs ‡¶%÷Ø8K.žXi°r™L¿Y© ¯žvÉý? ÿ|éí¹L4:O.xdè-ð…üáQ ÓC mƒ ‘rÃäþÖÖ(Cà–j´0 èÏ î›k€Œ&s%ÔWº€®€•H‰~ $ŒÎØãq,ztô®ï!ÐüdmJ#{-œDC‡~û-Ó;t<þ µiìeèÕu!|¡SÌ žî& 9›œwÕ]¬åUßÉG3O@wœ8‡D -õÀ‚ƒñ0Çm«µDë#Ðò0ä}‡Ú±3ݨ;Y>/XObject<<>>>>>>endobj 5827 0 obj<>stream x•Wkoã6üî_±@q€’³?'í¡ùp¹¦8 (ÚžCÑ-Ѷ.©’TlãÐÿÞYR’#åuM‚<È%9»œnþLhŒÏ Íæü•ƒ÷‹Á8c°ýfÖtr=¦‹xF‹MÇ4ÿ~Ïçç´H}Ô˜Ityyy´ø28¹>¥ V4Bàh:«£ëʸ4”J'²Ü’Xêʆ跽ÛhE¥Ñ»=%¹°˜4’}/LIPž9—KÊ…“&‡±?„8Ž(Ñʺ.€ˆ Y,¥±¤WØÅ:S%®Âμ»‘"i•ïcú œhC¡HäVÓRÒJ›œÿ£]@•ÍÔÚ#ïb‰ÞdEQ9±ÌeHš™¸ì^zø=™2èkmHîDQæò‡f¯C•GÓi<›¡æi°ÓµÖô•yäŸFDÇí¦ÍÐÈ»~t¦íÞa™ÿ89¦?šB´%8>é/J6Âб…|´ß›:ãG}Xÿúˆgéñy#55w…cÃ`ê/ukDYÊtè/ŒpR¹@&ª*Ú»L÷È%KDžïqÙ¹NÀ¬´¾×†ÂÏ÷1àÞzqJn»Aí%ßD©,¥J™4 ùv#½°…ÒŽ>}þø3e–L…©Ìm<ôQòö-éÒeZÝÅäkÃJ9P80›ZéB¾:O¡™:çm–ç 0Cj™KaYQŠUÄt/ò J·Q€˜>®p<öÄcã#—r#î3€Ý늶Bá0ÿïÉê¨,4En_ÊB”ÄùÚÄdKœä%‹jAª8塳Èß“{;$‘$€á ¼µgP…PbÍ·¸1ºZo¨Ô 3C­’†\›¥ðN曄õüþÚ«Q±Vh÷×dþw—ݯP™óó)i¦j{{P6+”5ÏîPÃWqÂ]iI?6nðMtsÔÌ1¥aÐËx×™¹½O.æqz[Þb¾3Ç«xàYe.˜u¥‰íÎXBOL$\¸„›ZU þ†º#᳄ßñ|OÂ÷À¹¾bèq÷ääùRYÇGU®˜û‚v­'ƒëØ_Ö´eWWM.ÞO=Sj«å,@d~vê:Ly™\˜äJžÄ;D¡ä©úŸßÑ•.ñœ5‚XAEßͺÿP‚Ê!9[«&6 >‘è2“\bIÄ›ÒÙŸ‡ÃBë„qì7­£¤üÆ…„mß¿Žš3Dðå©Ù°nH“y§Þ¸B¹æv«+¸ˆáÂI~ñXÃ.ÄP+MÞ…½­5ï?š•ZJ62¹àÑh”­¼Á0Ã`K‘6WTˆ=­AÑbåšË$˜‚´UŒöÂL׆¼«6¿E`tVæ«bŒmhÍ™þŒð)b ÉVeÉÞÅ^lr«öm=Á;¼n/õ¬%ñ”IÁüц:ˆ'ŽÛŠÕS«dèqôW½=äèω6Æ †7]Z´ qá^ˆÊI.|/ûáÿÓ%ŸsÇ Ô˜^j ç<•Ã>´žr#fCK`}žõëõ¨¨t?5_=¦›³ú.{á1y;F<«Ý¢#«Í\\K%ïd–û Û+è1mZË‹ºežŽOã³ÙÍÏ}ãÌ ÈhéƒNÐ"Õ"âcQ˜9:Íæl£§OM#m9êlŒÑ)þ…ÉÎ.Æ<ôÓbðûà?/ø¡\endstream endobj 5828 0 obj<>/XObject<<>>>>>>endobj 5829 0 obj<>stream xVmoÛ6þî_qhÕMmŶ'MÑK· : C ìK€’N[JTIÊŽ7l¿}w¤äȱÓ$ "H<ÞËs÷<ä÷Á&ô;…xÎi9¸Z &Ñ„>nÿ™%_Oà<Ša‘Ãló÷Óh>?ƒEæ­&°H‡WÂ@òáíâë`ã)}ʆ×ZÃÑ=|„Ÿ’ñeþÂÏñÜhY9 ²²2CHàè˜÷_ŸoÌaL1Ƴ¸1¼ÂT4Á5oEž[¼biR×ÁF7Š JÉ|ã÷¥š¶qPQe€+4WÈj km¾YøÚXJ~C¿u­EF÷5¦.‚kmºªf\Þ‹²VxRîÃ2žÍ¢8&²áåå%Õõ•»áÝÛ·ůEy$h=nAé¯á÷³pÎȤq:( J,Üæ³uÇ 'QÞyé=÷"ߌ ÐF–h=^V”=HC­ïaJtí9íÚÏ£8:ƒOïÞAª„µhƒy×MîåIt°ôl@„µu$¸¡†èªó•òðS+<ä#¹oP!V< ÒóQˆ÷D+|NðER‡ÿÙA£n%SßÇíÈ‚7ä–íŽ2ÀìáÐÍ#€EaÒân˜Dƒ#é°Ü÷°Ò2ã™GC~ž54XêþØ08Y"ùã,ªý˜>9…ÕÒ»ýë_Ÿ¤\Ç ¦t”u×O†þùùW4”m碼0TÔ!òêg…¯P¥gqëtãž±ù"–hÛx ¦B¼ñNßì%VÆNE¼åxçªà÷'¡üÄœ€L8Ѳ—4ˆF_¤)Wx"WŠª"q£áÿô@zµñfžC·N8™†Éßz¬ Z’7`Iµ¤PP(,!צí]7FÒ›Óí‡ñ,šºÆ¶Ô…BdPi°M]kãüv"–H Í<¹™/^ YMÉšôÔJb/iUËãv¿¥2|ºA¸`%Œ”+7%ÛÖë áàöÏÏ¿yÕnœTòoŒ`Q AÊŸÝ/.‘À.èË6… !†e‹¼8Cz¯½¬̺¡ü¬&)£Ìèài¶¶AKÎ5H¥H÷Ùã(ÔKË<ø^^D‹ð >¨Ìm-Ê©L‹×„\ëCÂÒÙð&Âtü¥³‘”ôþ~î; õÓ>“nÃüD ³2'À)ÚZl^ÀïŽÛ\ô_m |ò¼þrqÑ~zL°=]`˃¤z{çÙ#ç°’‚Žt*‚æ¬Jq/X?ɾËG~ˆþüaJ€®Ô懔¦Á„\:QÜZ=/xÄ©=¿[‚ ¥:ŽØ’ø ’òƒiQÉï ϧb%¤bªpƒzÉãº"=¯Ù:?({ÜcýIýV›%"ÙY*xliÊ)RF%ŠÊúQ"ó¾x¹‚8¶, ÀE÷HΆ)9ØEp®W½“ã¼5žMN¢Óøæçí%¹>Ž£ ü¢Ó¦¤I@tÅîè^lÇgá†yøêq:¡ÉŒnµÄ“Óó)ïüu1øcð?ú'4Íendstream endobj 5830 0 obj<>/XObject<<>>>>>>endobj 5831 0 obj<>stream x•V]oã6|÷¯XÜ]Ï–¿bǹ¢.i]ä©ic´uQÐó"‰*E%gýï%%ù#JzÃ9KîîÌõÆ4ÂgLÓ9ÿGYïjÕ…#¼l¿Ì= —#Z„SZ%4ÑübÎç紊ݬ­¢àòò’ £rKò‹ÈŠT†Ñ£0á]!²?7¼_}îh0ÆÜ88ç§áò‚ÆŽ8@ÈÁdV‡ ¦óp.èúÃRùVeEI9#Ž`ǃÉYxÆÁî~»ù‘TII•¦;OÂHÒ Þ”•,ÉÈTX“Õ§CZ!¸L´‘}R ítE[ñ()JEYšªIv«J¿ôa“I8¢qàfÓRkúû(Ç0 žÿù¶~D²-ìJúHEµIUôÕ1†Ë¦ ¾pÓ¦pv«Ëýö¹OF²G[4 Ú*i„‰¶;.Ðíóó6[»ÕJRYd-©™òäcZT•Ù´¡ïZë÷M`W:SyéX±6}ÔþdÆøù|°aãZµóc°FŸ÷r¼“‘Ïá…v,+ƒ™ìÁöù:Š=jS !­æÙ7Éú½#Ó+D¹kN³5Åöê |0ŸÍ>J@"ŠdaËÓénÕã\ÒŒ*4¨% ËKä;O&Š¡ÙG°.1:ëu¨‘ÉÄ©ùƲ–K‘@zä’”U©Uð“#.>)»%V¾Cï­„}aÎìs&rA·~eŸ© µÃHðûQ¤ð†>¶“0Fìj‰7C^e­›Æ'_BÛûqÝü/h>¹¿ánáT´Ù5màÊbïÞd[äÄ#ßu"Û²tc§ë ‚t­3'á`U?òÎüêûÅé ‚kD÷ʳ÷ûMÂÀ}âf±óÔ…<¦Ò‰¢uÞãšîX¹;­P)è«Ò*ïM{¯ ÊBF*Q›TƒtgJŽãåM½ð›úôpŒ@ÐZ'<óÜê7 :[dΕšpìØmHW2Lrg¦ pwšU96€[¨mSì®À+«ï%sjp ÷o(Ò1|™iÕXc{¨ ˜6'ƒÓ çà֤̿MöbÊ °&SJå=üZŒ5Àª|®ìÍ |›=¾í‰ê¾ßÒµ‘¬ÁƒMIZCgGÅamzK?=„ˆ;1 w'æ—Fî(кuí¸ÞÍhNw BwbeSiÌÌK°€ËOçu0&™ÊLæöÔ‘O}§2•âʰ‘¸¨(ôZGQepõÁO#q4çµµLKîÛé=å?_<‰÷sÞsnhs‰ñùñØ;;ïsõZ<;°F_´3†ËE}Á/ÎÂÙtFóÅ8û›Kc0 Gô½Ž*®–àk÷eò³ç~c/_!g#Ü.'¸?⌘-&ŒþaÕû¹÷/B$1éendstream endobj 5832 0 obj<>/XObject<<>>>>>>endobj 5833 0 obj<>stream xµVmoÛ6þî_qhÑÎYŶÇɰkºtù´1P 00Ðe±“D—¤âCÿûž#%Ûò·û°¼Êy¼{^îô¹7¢!¾GOø'){og½a4ÄÍí³¤³»s i–aíä ©Ž‹¤ïrY‘( r¹‘’²ºJœÒ•¥µÂM#]mðœVZUNrš¬.%Ì>õÎîp´Û¿Ó:Üiê“^|’‰‹èAU‰DtþU&Ýž@ó¾]‰r:?iN±8æQµP%×ņ³Ò‰p2åÐC:‘y¿”¥6R–j+SN(×þã#m]8Uº—1†*°xÞÿ°q¹®Úâ )¬ÏËRvÍp„X¾rŸ¶f!–²“J¢‹5Êt~Ñ dº6.§„£†ò®PÞ:WI¾Wdx>gÒH`3 UQ©qKgþhÞÞà¿@vF2$ŸP‰ª–-R\«r¬¥ýG­P’Öó>4>?ù¡E“²÷0É…¡ï“fÁÎS§>ZM&—¼áw䕈ŠÕÉð—Ìn£:\ ²ÎµÌ]¦ÍZÀ¥¨*iŽgxssŒ!§Ý×˽¬;Io׿øEB/š]Íúm!]öêxP¥*„)6]´%…°ÖãŒú”Å6,F{ ¿:®êE¡_5;ÛCÍ…aå¼ÈÁöApG{ýok¢Èëxð‹§òY¦XAÌÔÚ('[ŽÊ]qß@ ýØ&½OÌ­w-èF²Â™še»'Û£ó%ÝêÕ†²£¤üÚx;@ãnN•vô¹æ*Ð%²B>©Eᯡ88M=Û©m’„ͼՂqG8ï1ã;G©BÇX¨e¶Ó±Ýq0¼‹¸£?o£ðÔæpö×\¤ÍQYí,û–M¹8TC÷ùëöù³R¸Ï(•ЪaøÙX-ØX¬VR˜o9¾».%¦ Á¾X-F÷ª¦ib‘º¯écäbxuM-½è{¡MR2’Y†y£%Z¤ZVÚÈÔÛo«ø½Ø£ƒØ¨F9‹ÍEª×¡µîñÕŒ€¶—tƒz¬z †÷8HÅJ¤F Ìà ¡Gc¦ñÀÑ~Ã>/XObject<<>>>>>>endobj 5835 0 obj<>stream xVÛnÛF}×W $•k‰ÖͲ“ÀÚ´.Š>4E+rdmMrÙÝ¥m!È¿÷Ì.©›U70lØ$wç~æÌüÓÒ?COå7-:?Î:ƒd€›?ö–În&4Ðl‰»Ó·xÈÂ9Ò~ý…,;“ß³#sÏ67*㌖u™zmJGªÌ¨`¿2™£Úéò–eÚ©b¡ok%wÈ¥+.˜üJy²ª¼‹BÎXï(ã4W6ÜÃç456Þ:™ýÝP8‚K]Ǟ̒üºâ~e9åŒË”ÉÖ9»„f+&H²%]ÒÃJ§«ÅUÅ*zÜÔeU{Ê B*§ByI~L¹ò¢Ài=wÐÅ–÷‰i¿&eµc×ïC¯´£T9îá‘i©­ƒmhäÕ¬mO£‰÷1gÈ"ÑKøÐEÇ«{Éî‡ÓÓW”®T%^.¥ÂX p]¬µåAþ‚ú³›·$É“ÂöGS14ž&ãd8•d*FÞuâÊ.ú£IÜúÀÖ+Dnok¿DÄ%-˜Vð2(Tíx”ª<_ÓbMBB7p™UQåHO Ìh)”"Þ9Êõ@C»wÑ]&cqz$^’ñoY7^þ`DË#}iK"píVVß+ÏA&|$¸^äÈj¥¬ï‘–ï÷åp®ÓC±ÆÆ¼ÛÊÓ z­6-oózõλv~Ò(Ÿw5¾Ð×=#D…»o_éMº«&M‚Ÿ;ÊÒ$¸üœJzÓÖâjÞ}ª½™D–6Žl*zT*”è SGdü6ÑþËE¿¹(¬"•!I‡yi ÍÛ+(£e_Û2–ùý“¢62º8&±v ó5˜Ý6Z?|œL§RžO+uY¦Ê(OÆ‚)C{¬Mª8õÏ7Éõõ5¥èqãÞd~²G¹’í^¹è]¹Â¸’Ò)eO„9±!O{CL”½b†“˜½ƒáèÈMXº:b =ñ¦Ð+¡GM¤|¼Iùï¥p®óV‡YFÚ¯6ͱK§äêªÂ¸"°|˜b›ñ"ãC É€´—µ°^ä–澲\~'a©K!JŒ°Zëp˜qBûç8S/I°Rð›ñ–2EúìæŒ™$íŠd¹´šeÒ4ôÚ²ÊiK‚‘·÷¹«í¢¨áPãÿ ¡–a<¾-1Μ ^†v®Æ›¢eK™dôB—Aã¼ÎóÐ!a>¶>öhÙ'ù)”¤ÿ>˪\c,ˆf 1E ¤U¾—òvÙËøóMöµT€Ùdë³Ê²Ï™yëÒ§m~ò< ÌdÝÀbÁ ìÕŒÇvŠÀ2³QÈGq µØˆ«]÷5?z”8~m¾.65ìR^ßsB¿1Wh%ûW‹Ž¸žü;ƒ4Ã1¥ÙãÒf7hcÆ&gâ…ª€aV%zî\c3,cv5¦ŸÂÒÖÛ´Vh\¢Ú…dG•7{åŠêÈq¡Jìq‘|\À»ˆ¤¬Ù}.›¥v4˜$çãsš^ŽâV#½Û'úɤµ;”˜#Ç»ý‹ê¸.  4as:`§aŇŸ_NDÏϳ΃‡ endstream endobj 5836 0 obj<>/XObject<<>>>>>>endobj 5837 0 obj<>stream x•VMÛ6½ûW RlªElŶl¯»m÷¶ÛæÖ¢F{1Ðe«+‰*IÙëéoïR²#lQ¬± Ä™áÌã›7ú»7¢!þFÍø½w‹Þ0âåáŸ^ÓÛÇoh4¦E ÛÙ|N‹ÄíiÑ,ŒBlþðæ •¢¦±4·‹¿zo'4‚ { Æ“p¿à÷?ßÿL™!±Z’JOüú´ªí1Ž_Q¢¨T–DUI¡)+Én$*©s‰ íöG“–¦Î-›‰ÖÈn„å”בÈ`¥Õ“,©®`i™zå#BDñ$ÖÒ„ôˆ'ù,Š*—}ÊRÚ«š6b+<Íp~ž=Iä“™¾¯yHó0â¢Ç\õ8Œ"<%ÁM“nªI6Ø;ÀF©Rô©MÔíqz”ŠØ.^•ËÛoO-ŒÕulé[d{1Q½B¶Ïý}ÿã™ÿçîÿx¼¾+% g³;‡¥ÒO†þuo7 @¤žçjgî_Dááá²¢RÚ¶˜vJáí ÐW-o;³ÎÛoéûƒ`œ89³ð†Q89 Pi†uî;;àç1øù*(ï3@­ÖZ ˆù@qP¯$U‚¨-CûnI±*Ó<‹­!\lJ¢Ü/o)†ñJ2…U¾• Õ&+×äOFŸºn n´ä`Ý|‚/™úò-4þËàÐЯÆòþž×-N©ùx‰šŽ›.0o=9Ë$øÜÀw]`(_Á qþvßWಠw­¦À)hõ')+–L“Ù+•2²ZX´8®Åd‰„µ†Þ0ú°,˜á­ ±†5Õy5i„ãD, á”á¨T¸3F†Èë+\š±–H|¶Y ±ZIJY…D¼9ÚwhSË÷!2±¶Yž}”|œª À€À¥d ‘甉|O¥4d;äbüY»ÌnX”6‹EÞ`å­ú´“yÞçÊN&,k …€â:­L¤‘z+C¶úrŽ Æ3¦‰‘VBeQÿõéÁCæ`M+¿¶è8œ€‹´©×’BW@´»¨~Q;¹•êFÔ|µà@ƒ´»d©Mÿ¨ëØ´¨Í9-;E¶^îa¡PƒÙmr8ËXÐ-×ÒBñrcÂTOʱ³[ÿ¾Ÿ%™†¸gÀñ´ùÅ‘ã»óæS[kÖ¯²2ÎëDÒ«Jd:ܼêìÞt{¹Íñ»8ÆÐb„¦ñ«±ÓH².j3–8äyËÛ}%™ÂsTû_t%cë`5Fû¡5“Ëfm3ÿEëw¶ÃYñ¤¸²Á2`‘Ük¯XŽ_Ÿÿs9J;@çbæ“pMivwŽü÷kÈ ‡ô£ŠëüuDaØ1m½õàÎÃxý k:ÄÇןWh¤é|ÊÞ?-z¿õþ½Ûé¿endstream endobj 5838 0 obj<>/XObject<<>>>>/Annots 3022 0 R>>endobj 5839 0 obj<>stream x…VÛnã6}÷W , ìZŒmù–lj Ý6AÚ¦} Ð2kWµ$Ç(öß{HJ¶¥ÜrqBq®gÎÌèG§O=|÷)ÛŸ8ëôXOìGß~|½ê £Ðh‚3e4÷Ø´:¥tÛ9<ãv2a“ÃÛƒ3nϦ;KV÷·ù;çS=Ðée¦,¢ùŠ=ŸõÙx<¡ùÒÕ£y|0"+RnÄ]PðD%ÉÝ Ù.’Ütñ;û|2ÿÖ9½Rò+ a'D•à:§›­YËüÜ‹º Ep¾ f³%Y!•!ñÄáPXqX²FýuA¿Ôw¬Š$ˆºÃ»“ç’l•(mÏ£ÆÉº+˜±Ì—‹¡=½šÌß‹ÇD–:Ývɬ…”hÊ$þI5L´Q¼(’ü"<'½–›œ’'W¹1úÓj-…áIª)†ÜBÐJ–ùÒ‹ rQ5Ùr·ÿ^_‡Ø—OŸš"uE-f‹Y¼æ…ŠÑ­Ì„3–@6‰QÌeЦM’¦„Wd묘ÇàŒ¬ÆÖ`4fë­kºÍ8Ju#A¡t4«0dC«‚êÇB!ËÜiJ>(žé.%Æb‡x2 h$•ZPœr­…¶¸ZóGPDîñDÀ‹-iÆÃЋ_°_ççO .X̶Ѓz Q[»VÄýÛ—®©üHBkúÝ%mÙ¿E_` øA³¥˜GÍPcÔtT´±óÉ*ë0"m÷ÒkkÊÅ7 FŽFÒ%¦£ec’kÃs“~¯P·ã®µ_‹¤Ôv7•ö»¬íäÏE,´æjË€¾ªÇãÛíü!“Ë2µ°µº#z»ì{´ŽÙ2êd×ûŽoMÚW6^åý_rƒÆÝX+,[›9öŽío¥6t´‘êûÑÛ©¸x°aœßí¸">Ƨ¶8¬&pÝ ü–udß[hÿwüÙ½fÅó¶Æþ\é¾Ç÷k?Ú,:(3¶m¹M±u…J·µ:%L©r¿tZjŽÞgD2Z¤«]+ÙµöBûÜßãXÝß¿´J2×¥¥ca¦ÛçÕ»Ãûe\Ù)Á>dÇôÕ¥¥é cp>ú,¦ÕªëO‡lh<œ²‰=³Ó ŒðJú»ŒK»¹IdnÕ0‰½t8ñ Ê¿%Dnß×ëÎmãQï¼Nà½`4[å?æ:ÿ¬ß ½endstream endobj 5840 0 obj<>/XObject<<>>>>/Annots 3027 0 R>>endobj 5841 0 obj<>stream x•W[ÚF~ß_q´OÞ&0°­R©iºé¾TiC•$4ØvÖö¸¾ÀÒªÿ½ß™ñuÃnÒ$Šæ\¾sûÎðוKüui¶à~r5|Ãÿ¹üßï¯Ü•pi±˜Š%“úÓÇ«Þ1¡¥'–½»Þ1!wr+n{—ý3nç“êÔ]âì¹31ƒÏé|%Võ‰öϸ…ŸÁ­'<šî-T=OLëköŽ ­ƒ;wâ!ÂFÑyðmO¬Ù?¯7êöθ].€¾Ó}»îeÕ¤6?Ðë»[r§´Þ#ý‹ÕŠÖÉú„Ö¾ƒ¬Î„ëÑϯ^Q®ö*W©¯È×UZª€ôî³òËâfýùêõÝ™µFÆÓ¹˜ÃŒ³ñå“J§óUƒNƒÓ¡Þ"ÂZÊ(-èù qV2ÉbUÞS¢Ÿ)‘©<¨D¥%UE”ZôüÙàÇa‘#|˜0ž®,vD>§»*/C•S à/†ý”pnÜú±, ŠŠ|/}u) &νUËruŒtU4qŒHRÂq¬Ž*¦c¤NAÔ)—YÆhO² ¨ˆE‚~¢uFI¦SeÔÊãsÊ’Š2¯ü²‚¦©¹È#Ó€ räKæÊꡘ»sã9Ëõ#ÕA›DÕ "A¡Ð¬¦$z/G•Ͱ`ÚlKšÖEýËsÆVPÄ©¬çÁ\ ú*ž&´d§à,#ã~¯¹õxj®Ø8×úý|½¹¡@ÃMªÑ‘YŸM%[,^ÇÃSÿÿ²Ä£ðbGgf™1¾å,s€k›­wB_p^GU5S§ n7¦),ÅAˆÃº1§Õ||ÿ"žk3¯;YD~qý®äð®Çê³ÈýY~(3f1êHuOÝð¶¤ezÆ2lËlœSpŸG;fµ6Hš.*ª$‘yô·BÒ5æªóíé¬+ åQ3¬Ñ8z`Á¨Þ^ZaËbN9_S1›á8VöNkú§ñ… œ¬ÚaÍHsç˜ïˆÿ€éñ‡lû}‘Édã@bssABˆºÆÍ"(3±X,Ù%:©¦•2—iÁ´€åS²G¨ eVA—IŒ 8Õ´¯\~v¨·eÍGÏÎ!nØâÃÆÁÌ ãç˜r²NͬÖBèþdᨣŋU©¬MãaѲ£ýKö8Ñ0±}ÜT¹q^°VãÜ|R˜ ­Eä²±82=ʸR¡²UzCFà[àÚ°h­m™Ü‹¦;ÜVÉ ^pÒ½½ž´ øsÐTŸ|™òºØãõÆtl¸©ëõXªÔ¬«D6ÉÆQâ FOyo[÷W·óŒixtjÞ~šWš¶‡`d×âA¥¼ÖÍc¢÷þ©y¾·:AÆ…¦‡TŸRÞ hóPØÉf.‘µvŠ!Z`Y§¼ÿš¾3ÏÚ*^É››—[û•_)ýø˜ Ìl·<°q죷66þ¯‡í6J£r»£½/p_ ³ÆÞ´EoÞš:fhq¤oÈýRÊBÀ}H±sÏàd¯Ô!ìp«½¹¹ŒÃ¶-‹lï>ã£nô&ñ‚‡°Ó5Yª °Ÿ×w«ú¡â®æÂ›yü£EÌ]Ã×¼ÂÆ3ü0|§ýŠ_ÿæ¹Äj(¤•/-]óOo‚ASü6 {«%ûe}õûÕÝúG-endstream endobj 5842 0 obj<>/XObject<<>>>>/Annots 3030 0 R>>endobj 5843 0 obj<>stream x­X[oÛ6~ϯ8ouP›ñ%vÒë°^Ò°nñÖ-Q[IÔ$*Žûë÷’’m5MSlmÑ ÅÃsÿÎwúÏÉ„Æø9¡Ù‚EùÉXŒq¿Mø·?ßñ Mç—bA9MžMij𯌮O^-œTµ¡³«1]Š-šŽi‘Åâ‚–±{vLËh@üãŽ~¢²2¥ªìn5¸Qw2/3%®Œ¹¹»Ù(;¤ÞY­ìêôtùéäìêœ&x(¡Œ¦³ `°LuMQ&ëšrU©lG©Éâš$•FVUd ÙTQSĪÊvºØÐë§Oɬ?©ÈÒjà_‡ïîõ°xðXã`uJ²ˆ)Öu)m”*VeSÃZpœ«| 5·²Òr)’Q¤`5ü lLˆM¥m•65[ÁFef;ÊÔ­Ê‚”©(iŠÈjSÔ‚®*“ѦVÕ“ÚûC&¡[­¶CÒ–rù¶ð;>[S}¦ÂT¹Ì²ÝóÖ±}^FÓ©˜Í¥xðòåKJƒ¬àgk2bîÎÙì«óNxä«Áü»)R”HÛÅ`on*kZ+Uж’e©bZïàm¥dFvˆoÜ2I¢*$U#uA2¾•…•ÅBÀtQ[YDjH;ÓP$qÃZ¥T¨mx¨5ße¢Í]¨ :Nd+Ž|x5UbœpðçjP–äÌÆRÝ”¥©¬·:˜»ntfG0ÑîJ$¦)¬î\™ŠéêTøœ<#®‰]8š.8Ò³…8SzÕÊ/YÞßmËžïž‹s¾½DÂýÇ®jGNµ.ŽedJ.%î¹[Ã$IµÞ:Ñ“%ôaÂÕ‚à‘Îù’ÊÎÙèhÓ™X ZßBìØ}5'FAšÕv•¾VvËYÅ{w;ŸBÖ ¡ãø )SumQÅ0,3æ32G[nÙ)}Ê_kÊ4®ºF¦µ±)EºŠšÜ§¿vÁuaâ }L¿6¡‚p­â!).Ö½ N—¾ê((¢¶¬¸ã& „ÃwW1‚~ápV*× ,CB¹ е·á;ÎP›]h{sÓÏ”¯J…à'—úanh_Æ@ÒÕÀ;´:u¬Øu³àX%ÔZ€ŠVYrï5¾Ë¢Ó;TFKÝ8=¨pI™mÁɱ›=ìv9’ýZÆûÇRƒ}.ëh»¡Ç= üq°÷“¥gï~Š Â;œCÆ  ½G°ã…+†^Ô*‹¶ÅÂOt©Æ!šîžZòevÔ À­,˜ôl¸Þê͇ÝïnVùO- ^¸–ª­©Â x¼hg.þâÂø„‡ÞJ´ÊbÔû‘Œ¡ð‘0½Ñ01µÉ%¡ø™®ÏKè™tODÛæC^M^t'÷›M+­²²µ+bð _‹}~¼ÍÊM©Ññ‘ÁÜÀ¡ˆ'—-©¸L‹€«)ˆËq¨ù[˜âìç³çcm«£îÄýÏÖü`ézsçøhz ê"ïšµçì·ÆÚÔ­+žèÌäT Ÿ&íf>†» ·‡xì‘ wlS¨°8º4dþ¨sؤ®å|žÃì®ýðîÙü`fxJ=þ~×G@€¥‚ű®À-AEy8¥{xâ’£u¬×…Çnd˵i0¡{P¡î¬ª€ ÌYÖ¬C¸%¹á~l01É%?åÇÀ1ÇeGÌ|K¥Ö–ÏÏÎ S //Lµ9sªbÐ3à£#4"µyæ îÛópG »g=§Aëü¦sí-¹ÒpÏý7\×ÿ(¯iÉ´£5‘i~%Û«ëaGÎ-È$“¢Ààz—þö_kšŠ¹CئtÉMpêVFžHöm4A$f-‚ÌÇ=ñ_†h˜9 SÐ:®ŸÜÔ\4³|ÁØŒsþ2…Ý"½Ðà=¾ÀÀ}]¯xvu†ÖÍz䎘¥Ê£ÚjÙg’a?dú~?üʲš~Ë_8#X¸¸S°&,ÎÞ#ŠüÚÞ­Ñl&Æ´x…/ƒ¿yÜÈÑÚ¡ÌïR öTl`ÉAÙSŒ5™¬z©^b²µÛv·-bOq,nÿ˜ºscÉ·lX—üª‘ËÝRà>š-+ïPécª¿|1‚ÉÈë ë]ºÃf·i÷­R"è=–%ÁnxÉ›Ú2ö!)¼÷·þKj¯¹a£þjëan¿é¢1¯M³I¹^éI„M¸å«1ì;ð†WŽZðMq¥ëô:“¥7·£7aYuAD¶°¢xª#DacvÂ)Ö±6¹3{‹Ä|µØ«;»ê·t¯B•ž_>Ä|•~ [­_}±X,¼TIÍ<Ûo@$u)·¨a£ý¥h›îž;¯ÂWœ…Ìjlì%ÿÇ…£žL¼ºž ô¨ÛÛö] n¦òVAÎO_&)˜Æ2®+g¾ÓºÝ‘¡–)M.æb1›Ób•ƒpýñý»Z—ÞÎ&Øþ¹˜ãîè¯ n$LèÃábÈçã…˜M=zÎ//ùèíòä“ 3›äendstream endobj 5844 0 obj<>/XObject<<>>>>>>endobj 5845 0 obj<>stream x¥VÛnã6}÷W ò²Š×a|O¶E즻À¦Ý6ú"@`$ÚæÖ"µ$G(Òoï )ɶܸ67ÄâÌpxæœC}ë`ˆß#˜Ìé'Í{7‹Þ ñaûǬàòv×l‹%Ìæ07bóù,25„E¹ª™X‚u¦Lü}¾øÚÂųðëKõÛÃW‘ºä㇟߿¸ ýL¦îÇëܬì©õ\XËWâ0ä·¿áV|xJEá¤V¡ty;js cìx<©ÏÝ”ìV®.VB ÃÈ`kxQcA<xpkî€o6!.¬fn¸µÂÂVâÊš? Œ“¶fÃ+]ºèˆ{°ú­Çl2A³ïEóQË ú…3‡(Ðè@ +‘j©¡ïªã©è­:^hf}%žNNéxŠÏp[7N#¿X #€ãïV›¿¸Ñ¥Ê,,µñ@2¸ÅÿÄÏ‹€\êGpöðŸÆ×‡À]Õò¡CØ¢|ØÈÔ×8 ñ~F¥ZYéšèçv•ÄçÇýs˜² Á×ÊØ/³%BÅQ|þiS/F>" Ûj[hâƒìžO£ÌóÈ¥\JWªš§EåÖZ`»–ér^ÁƒÃ¥Ep ˜#1½ë/{hÇQ‹<õø@ä$ 2Tº$‰#+6Ë Âè“üÿ3…ÈÝeÝä:ïÈW¼$°<Ë+<ü´Ï‰8Â-ãó£j®žuöb7F¸Ò( ˜PžQ 7hÿÀvF¥FˆGtRqSF¿áN£çÄ‘`+6€Æ9‚iEIbx–%ÉaQ¢ Hi4±²(´AÿbõYÆSâÞBT‰Ž¤ Ò)4j¿•”·.^›^mk¢Ý!:MÜU÷ÎHµê41@ždAžMÅi(ñdeÃUŠ©—¯+D"SÏØž0HwµüaS¡Åº5(î$šlÍ[<6b]n#c;M¿i°}‹ØîTØÏßtι@Md©/ºvã*ŠW[J¾ßô‰û;³Ø]£ Ð-/{‡¾vhž8üÿØå£èél­«ýGÜÿùé—pñÒé¦ùWA¤AL A#m7šg8Þfþzô· &é­çØi³X£ïtVn(9ñ?ïÈE7´wμÂA{Á†Å8:ûUƒF w³=ëHWÒêL`JH} gØ€û‚+i×ðI}+¥•ôvpv8þÎ{Á‚.sº˜,ZbʉÑTg) Þä|uÈæ7=¬K Æ‹~ [´Xj?Ô”Æ#"—é±tÞGà£Þ’? –š`¥9ŸÕ/3­dÐ:Ûúæ¿s—·£ëöµéŠ`>/XObject<<>>>>/Annots 3032 0 R>>endobj 5847 0 obj<>stream x­WÛnÛF}÷WL¤¥k‰ÖÅ’í}°›:ÍCz³€¢€^VäJÚ„Ü•w—‘• ÿÞ3»¤,ÊNÒõE€¹ž™9sÎøîh@}|h4៬<ê§}<áüõêhxy‘i2¥}*i4¸HÏë¿ º=Úÿ«£ót´·z=Ý»0Üj—tzÓ§ l›.h<¡Éå LÎiš‡×öiš%åÖyK?Ñ›í­·J/gIça­ñÙññôíQŸzl̹VÎä[;/¥È©C'ó®Ó›3âm ê qb8ªß“LW’Äܼ—”ñá…P…ëÒ\f¢r’É­ê¸B×L›õBT‰4 I`慟¹ÏÊCÝc¡=sr> º`›È3£½Pš%@DòEÎ*Mh\ZXS>Šô Nn)NŽ ²Ù˜ªÈ©0æýÇ\¤ & uÕÎÉyY÷ËsZWsïÈ‹i lWÒÈÖ™Þã,Ç] Dþ ¾O3ëú su/9‚¦=}â‹ ¢€Ö…áÚ¹ ¦f.·Ü> N(4U—m£øÁ*J±¥::ìßi.X-ô–Œ…}¥tõéÑŽõÃzGg>ëg‰r®šnÏ’ë´®`—®Rfúì8:â¾4 ÏSúf6„½Æ ^6ò…ÕKêÆÁ„F“ô,ÂägÃóP>x£-ŒÈ;\mŠåwí*0ÐFX!ÜJOo¡®A~ƒþ7z@¯¸·D¹¶€ð÷‚‰¦45±É ÔÑæZ¾AIХòJ"îUY•üJNoˆoï2Q¬,w6ÖB ú`}§7ã:CI;L­„Ôrúàu¿‰@K‰± g7[ Ÿ­˜Ü®À0fĉ¡Kò½Ô´Yá#3冖·@"†(1.³ þ zB/+±”.¥_Íçm·ac0Þ«><Âó€À»”¤«r"Ê0x×é‚¢0K6:¼æç““8Ú´ë¶ÐlV QÀEœá,¨—)›UÐ*xçasÅ3°ÚÈQ–èϘBL®Ýƒ×[tñB`†éÆf£Š‚0hWÀÑ[(.CÔò µz\¶Ó$…£e&Z8lJ7Àòȹšá©láÐa_–Ýh0S8ôÁD1 ‡w=Mø [Ð'¿àˆŠOŸ³c¤ ÚFÆGOO9€°9ç~wGƒ;øØîBæ|e5ý"? P^Ð§ÖÆ¯˜d˜4BÉDå Ï—aæÂÍKåàö‡žÐŠ`ß Á¢UÀfgÁ†>£Sú,dùÝ€»1<ˆr¡ÞñȨܗ«,ùÍöMœÆjÉåRÔaÇ!B«¥,ðÿ/Ì0÷òâéM3ö .ÎÒñhL“‹Ý8‰èñÿF/MV±o„Q›a,‰»{çqîø÷'éhÌñeŸïûezôçÑ¿O%endstream endobj 5848 0 obj<>/XObject<<>>>>/Annots 3035 0 R>>endobj 5849 0 obj<>stream x­WÛnÛF}÷W ‘k‰ºÙrìÔI§~pâ6‚й”6&¹ÌîÒ Qäß{f—¢L9v^šø&qw.gfÎ}=ÓÿÇ4ñWœŒ¢Þácþñ×{~‡&gçø™Óxv5¯2útðfþà‚¿eV4¼ÑËhJó”&#š£ÙìŒæ‰7;¢yÜ“¹Êjº¤ùF¹Eoqt4ÿr0¢Á“^)M¬îE†ç…ZÉŒŽÉŸöP$’dìsëb{) Ä`2m‚èÍ×’2a¹¦LÒ’NÉáݲvk]P¬IÂH’_+ŽC®OËʱÿáÕicµç¯ð}ü!U†ØÊ‹ã¤‘ƒpÚ²”WñšR8”&XØÆÕ‹šŒ&'œöu1(3Ëö²%$­¢>…{¨ˆÏ§·µ~|¹gpqD¢H@^ £,rÙe[OX¹¼ì·Ç~Û3Ø'éâˆÍ‘Y ÛŽ4N&ä4æªM|Õx6Ó®5g#ºÂG”Ià€Üow§€ÞEåt.œŠE†þxèk[œ®ý>™JƒXúN<©Êä>p¡ÀòfXld7jµ—0©ÂñÓçë÷vi„©»eBû0øÖpihÔ\ü´ÊÆÈ½€®¨uE¹¨I~+3+‡¬™rÓTV«ýI¥p•ñ™ì¸G‰22vê^6ˆÊo"/3Ù'[•¥¶’ýt²ßˆ ®90¤d(âÐç‚6F”%êc, Kw²¶œ· Ðß·s i».Qq3»¦9'¹QYFmîØZ¦‘~sæMª‚ÖÂbª9è¢hÊCò0@Ü3!¶¾ofŸÏ¥±Æ3ÖLê^„®ü‡…wÛ ‰[æb{tÇKƒÉ$šNÁRIo û¢w,_ðÃ>6&ñ§¾.åå!ûàW‡˜‹·k)­¼¸ˆýï?ðä O^5)‚x`=NÒ¿Í£†êª%ÚÂ×Òá_sxÑÃ``âµ0ôk!r¹8ÚÚø°G¼¦ÁùËÝóßýË]k=âF–/'Po|ÑE£0»é1SwÌ{Ê>ljtNyM7õ­ˆïÄ Í˜—Ú¸&ÁL ÄR€3y/tQÚ!‚!Ñ$†Á¿ Q¿gçàJW‰øù±¨æKPZs´cð;¿z­72Üž»V+¢;Ã¥vpžiËGÔ ßõÚ#½ü‚ñÇ*“,™:0¾1?U<½¯ü¤lÖ2מÿnkìÛÎ%–^Âï¶TŽ@1ô¼,kЧí|Ð'Ø 8Ù­ÊBïS­˜²®VkÐNW!P-…‹×½¦\ƒfé¸<á'qe-„ÄRo÷ñæ6ú'†y_ô(£™ê ;³áýÿqkÐß`@öa¤@¹¶·qb¶ÂCÜ#C±ÄÂj fúA}±i7t5$¬Õ°v®¼Û(\Ž´Y ã(ÕЯÐ;ÑÚ噯pkg+ÕZ;,·—Æ>3 hÑY®­ãå¿‹4˜¸-T{[ˆÞm=‡ß¾gût[¨x¾n|ŸY~ã ËoûN§÷nëO]ëªyŒ·l–Â#oª:àÖ†½ d©0<~‹¯Î‰åJêœ1;OgÑ ´êD³Õ€ Kå ¢®SäuÚ‡ówô:ÃØpó2 ’å팾ôj«_Siô7 2ŠeŽb7ýÀZ 0d kù©Á,+•9å掄@¥w¿Ì]yòÚZ+Á Úz݉㉅Q¸) Öª¤44HÄáH€V½$¨á ‡å2LùÛOir/£7kÍŒ´%Ö–â~æõžHH?dÎÛîgžÄÜI“Õ Š×ƒ¬ˆ®Sàé7þ¸ïùô6HKUÀSiØ_ØQ‰DmuíÏì ìà 5ëq­„Y¢¸0be¨P|àv„ægY>猂üÇî+P±ZùÈÝú0ÐbÜÛO¾úÁ3Xš M Cû†;»p»åûÌÎ%òX°ÇôÁÕôLì7:·3Âð¨LúÒðtùÏ0¢#¤¸cõ×–½‰…ª24z£(Ÿ_ç!¡+­÷tù„ŒÁI"] ÂKšM,…yüð'úäºhlâ|Ù|$šŒN¢Óé)ÍÎN²~Lñ‘õwW<ÎP¶AyBñ„³ƒ³ ¡ž#€ÓÑ,šN@ ŠÓó1·Î»ùÁŸÿï2Ÿãendstream endobj 5850 0 obj<>/XObject<<>>>>/Annots 3037 0 R>>endobj 5851 0 obj<>stream x­VMoÛF½ëWLA•@¢)Q’¥5Ð/9Ic¹ä²"—ä¦ä.»KJQŠþ÷¾Y’’iËn‹V– ‘;;3ûÞ¼þ>šQˆ¿E+þÆå( B<áËŒ/ï_¢%n)Z_ãZR´Ù‹î® »Ñýû’Ñ*ØÜ[ýa{Ï¡÷j3ºº iD´MiÒj3 V«kÚ&>lHÛx|ssC)}G·Æ||ùrûiÒt†µ¤] ê\9sЃ•ÙàŽ}dð‘;a/zÉžöru» —Ò)NçQ—âø­¦:—dp±” LèKM•Qº–Ö‘°’¬¬«eBµ¡wÇ:7z»°¢™´†½6tG6øM›ûÀ*lŽ‹RRjMЖŸ¦ÆJ¿½?ÝœQÀÙ-W»t²fO_¤50³$?‹²*ä7¼eˆöt>¢Ø'ã¸Î1ÄôGïÚ\5»BÅ~ï tÂ'‚?ãݯ\%JøÛGË·üÙ›,V'*Ÿ¡Ùyúz÷ïÌne9¹‹,†­ùþIV·¨&ÚÉ\ìÐÃoé*+QGReel- LM:P%j1þÅF×B1ô'¤RTJ@ÒÕê£/fLh2»OnØ_Ÿ²'Iô~RÚ©D¼­»vÏ„Ž¦¡D¦J«Z"ÓÄè¯k”Rm«Î‡p®AAë5‹M®¶g«¿ê‚ÎLÈ÷”äÚU¦Ò‰ŠEÍu‰Ãž=¸Ü4E¼|á1*â\òD°q¾ªÉGv4‚ñ -‰²ÀAíåдïã¾öÚDßˉyõ(Y7¹—£Â±AS „…UÈ‚U*÷ís¤¨¬S*SUî`e…Ù‰‚öØ+v…ò:à á™ àÏ7TÄ#½¥IšBö:í9ðò3 â±.Yo\ðȪhd¯¤¶)öZ¤WZ~®‡k'Ñ¡“c/Ù\Š⠽哲øÀí`EUj¥O½,F“K›µë¤Ý‹Z˜©¢@ì%`{P/1úd2þ -ð„/’ð|këçGלùâH/öŽÇs¤÷#— Ã.eÌ»OŸ¯Ø¿èøß5¥7>/XObject<<>>>>/Annots 3040 0 R>>endobj 5853 0 obj<>stream xW]“Û6|ß_1Uy89‘h}ì*ëKÅU9'NüÇwVU^¶ê "A Yà dV*ÿ==’w«øcm‰`ÐÓÝ3üßÍŠ–ø½¢Í–ÿäÕÍ2[âþ±âÿùñfµ\e·´Þ®³-U´Ú¾ÊVý'Koþµ» ‘8 —o—tŸmhWÒzIÛW«l»ýšv…l¼¤]>{ýú5²x4Áë»ßn–´XáI1[N>a~ùö–øqI l¸Xoú go§xÔT¹©Q>ΩҕóUªV]é:’ ¡Õ¼®”©éhŠB×ýäÎú¤ýœã½&…¿.ÏU0®VÖvLlUħ@gYѹ–*s8F:ª“Ò\sÒÑñy­ÄåGU´d…»iަ!W’ªÉíÓÿ³6uˆªÎõœra íñŸB“5lÂ?Óů‘\¬×Ùf\‹YnUôž#~Rüˆè9†¾<)Ûêo&O›voM.[ˆ#âäLAAÇÿJÈÃlÜááýNò%}K§oèÉnˆÌ²lòÕrÞ_Öë½;_]˜+W:kÝÙÔúÐÅ£«…ÿw&Ï ù¤,fHòòë z㵊(è€÷$?Ž­ËÈ=‰$ºÄRçϳ+ŒNWÇ~AuL8= :}–æ«gë méÄßþ%xïj!¤  ƒ—E) ’‰ÌDP—]f-d”à;˜G`í“È'ç#²ŽÚ‹®óñ×w?B ÑYu¼ÏcíÎÈHÅ”!?„˜Zïu1òC”²c)•Îã}½C4ÖrXýÒ†† ®Õs¹mF®µÖjj¼ûÔ 0ì5:Dï:]>Œ—¦7_}•¾oóèü€»dsæ£fê“{Ô8S<…ä˜CÌQÙêE㬌ޕ«øüĶùc7çO$Q®†¯À±Ø›Ä`¨T­Në[Ö÷Ð:ÿ[r-’bC˜€A)•è‚Ù[)ciá1шYiÕ!9þ¤ªÆêùPë‹3_ù‰hj`*ô!6|áÐÛ}×'Ü$B+‹›ÆãµyކFm`Æ®7a±€BUqbÄ]cr*LÈÛðÙBÂ^ yùö­P­j±Þ28›mv‹žÔh­¥pb‰ØDþÕ!]wèË1ˆúVê-@G*F]5 .nãuÐþ¤i¯òdzòE€U Ê´7ÖÄ.ÝZ‚]#–›ˆZ©`®‚þ¹ïˆR͆b Eæ ³±¡-¥Ë,p™9[â× K­!,@Ƨ$Ó]@¾P^`yzW´0£(«!v`Åd­+¡ùÀ=ª›ð_×hV¹tIÞ,·­˜$:é÷,Û:—>8g¹5ÚGèf©ÃB41z³o£/8÷¢?»Òðó"dô½ŽÊXwïZp’Ã]€SVÐH€ãúÐd)ÄGCŒ§c fŒÙù|Îi™ó‡é¢a™I:Œ‹‹0¾†CAlAC!Fµ©¢@í(ÈX±?dÏZµ >'¡Ø[Q#]™ˆHôÿEÅ9¹RªÀÙ«˜Ø÷¥È’ª¥§†„’k¸;´.øÐ >äÐL˲CKÎÏE{ZsäŒ OúŠ„r¦R Z\õ«,eâ„&ܸÔúáÅ•ù›¾tŒ†$UéK’ö·Ò»j(4Oν'\\> ª}•3úÐáIêæc±ã³Ò]ˆ3Ie¬&&T˜é 2Sh SrfFf“’nU*ÌbzhôìÂŒ?œHó)¯×!§;s“ﯩ&p娆À5ô¹Iž°–‰‹ZvP—Ï€–CGJNç‰v­nð •CªLš“Q²aÒ©mÉ‘“LF W¢@­>/XObject<<>>>>>>endobj 5855 0 obj<>stream xWÛn7}÷W i­‹­8.ú'.ò¢…—’˜pÉ-ɵ"ý÷žá^¼ëDM#Ðj‡3gΜ™¡ÿ9™Ñÿf´Xò¯,NÞÜŸL³)¾ìþó[:¿½ Ù”î7°]¾Æ‡<½Ç9ºßé@Â{a·ªP6?†CQ¨èµ$m)îeƒÂ'É:’Î{Jgsm·T(¹V‡‚Ôb è¨!àEܹœ¤0&Pîöµ+mwÊë(¬Tg÷ŸN¦4™Íh'¶ñ® ›—/ÙÉœ·½·ð磖•~LzC"™HÃQv"ÐZ)‹èQÙ\匹>J«ÑúÐ|ÏH9“Ò»/JGWgcþ* q$7A;h¯A¾þéQ½6ê  t¹Êè/íc%Ì0×. á™´*$'‚ )@3ãö*€ï¢4‰yt@IC~1J,eÕü‚‰»û[ÅD<ªš‰Bäˆëèîãûßh–-²Ù?ŠvÀBÝ©m´žÿ¦C¡N£QÝ­qkhC©¤Þ`Á6³³sïÅPÝ3èÔ£?®ÅùyÇÐNÚ m¹ÚqFJÚƒ-ÚØ|Sµ‰ iü…ÚŸÆÅ„ñÿ~†ghÂB·ÎýDL6kâ²õQ%ýNaî¿#ëZ=}+…ÊóÔÙ<#ìy¡0ß›ÅÂß¹D*&(/‰qêX|_ŽœÓ±Ü‡hay}½>™M>uHÛÏráâ?¯dW¬©J\w„_VgÃkÆÛnG3·ÂÇë§„[(ÐRó&‰;LÒí®¿¤Ó-Ž»rã .>˜ã&îáë¶æ¦âæm£Q›Ltœo©JWƦ-ÈYÅxS§Æ½KŸqõÃ0áËШô~uöƒ ö“zâëk '‰¿¬° dŠÁ·Úôw ·a:#w·:V›ß·%yt:osùU“åÐêßö±îÅ&车¡¯?y©#°õ_§V‡;*D 2©ïoeºÉSÐá¼ÇXAØtÚ6+áHË@RÎcáêÒ ïg÷áÈm-2~ª«Ü«"Ñö:><¬FA™Í¸.Å·¥êb%O}["~{Õü%5»ºÈ.—´¼šf¯ê È{d²È¦ôÖÉŠÿ–ênôXuµõäUÍ_è†/!Ô]BJg¨/±ÿÒÕírºÌs\80W/__pøw÷'žü¡§~²endstream endobj 5856 0 obj<>/XObject<<>>>>>>endobj 5857 0 obj<>stream xX]o9|÷¯hè嬭ø#ÖfórØÝlyØËÖ@^ Ô ¥a2*Ãɺ_UMr,ÊÞÃ:F`ÌpÈêîêên~?»–+ü»–Û«ÍÙ/÷gWó+<œþë×òúÕ¼ßÊýJn®dñöz¾Xü(÷µ®º’ûê\¤¶+ñ}8¶]=¼z÷êþëÙ•\^ãu×øÙö®d†E²êýF¶‡¡ñÝŒ _øI®o¸ÿ%¸¼¹Kœß.æwóyïz[ ¾—ª5!Ø¿y#Ü}.oÞÌßð XcMÕÄ…24fÆ©ÓAlg–­­/äÏÏÿ%kÛÙÞ 6ˆ‘Îî?«mïvx¡X—~h°›M \'ßGç;1]ÃÖVδ<šÑªúüϽ[¿{—­(ÑŸÇ=çrߨ`ŸPØp!½]Ù¾·µ ^ެˆ_pAe:YZi½‡Û@èÇu3ˆ_q9ñþúÃb¿ngZ ïûg\Wü¡a@tüã!o¬`&§å§ c·‘´=Qa×ËØÁ[íÁuë¼_~EÄÔ9 <ÔZÙ™Þù1ˆ ®ƒi-üNË Dé;¿G\Bã¶sùˆ½¯¡qüŽwƒ•à6®5‚Ìøv¦ÇéŸø~&»Ybzã/ M‡ßLìÁÆÛÖUn8Hk‡àÈuG«¹C \Žî߉ª"Ò(&g‰ïÝÚu¦ÕÈ(s¨2GqæÒ€ úr.¿˜[fl‡‹ÂSæ$>bÛÕ`rÛÊÎõÈC6”À3–¸®«ÓUؾ1x ߸áø@aGs·H:[3¨±$×WH¯ÆïiËÆ×nu(i„–¶1;çû‡W$âýXÛ¶ ï¾:Ò¨±‡ì„¨ÈZ…¿;w¬;fè…Ø A{˜-ã–ËÍp‚Û!žvƒµFMÀ"z";;{ùϾúeæÊôzr ÒÉKïGÄ÷O|mÉÁ5[€„ÎÙ²m ¼ìºç€Nƒ 1ž=ûv&{ž‚ 'àtœ*ÚÞm ]ÛY$¿íRÉEžÓyOR"Ä ¥J@D•ÉÇ{ šk6­ ^eޝ)Ž5# !Íï¦7¤2Ò>šjÀ{.zî\$;¼²sµ- <ô¦ [Ó#4ø8|sÛ-¹æw I­ñ%³ W~þ㣬ۑ1ÀYKG¾sݰ÷Òšn=š5ŽüZ™5OFÇìþØAtL‹Ì¦˜XyÉã°†õ Yá;€â¶[‚[:|çlx—©}6—OL%%~ ±ÇÆÀX=¤G• VÆA Ë ˜p€¼Å U:ÁVêôˆòœË¤Ö1û. (› =Ѓ³X*l=;ñF’¿"Ñžôì¾úèî È6¤ð Õ98&rÒÈÆun3nô¸‘#é~:1Ò 5åÁÄßÃÔlÑ •¼l,82ÖÑØ±Õ±c£±GÇ’§@7}V²@öTµ¶¢¾g=ÃY®¬'1Ú îÜ?:$n3‰c*P3ÑÃɯ²ï¡ô`öjì´¨¢’=¢y¨}Šñˆ ýÒ|G‰/Ë ò; oªLyw’,)ÿ¢(í.´<Äàñ܉íÑQ 9‹7ºitS¬¶šME”–¦ú„º|Ú(Ó‡‰UùMʪÙs&ϵ`˜ˆp²j!›0/ËùŒ´žŒŒ+€$™5:œ ÄPbÁDQ@ ;F(«®ƒ6°™DûŒFó3ø»ó-)mÍ…2 «c›|Ø!úåy@ñø´ ±èw^r 7a×ÜË…Ëv„ãX(ãe÷<5ÎÊ ú† x‰…{2ó² yCmïkfÔ1rDÐò‚¾ fË[Œõ €‡çÃÔDcîQJñÂÁDÎD@7§Î}©~] ¯µùãÂgaLÇ’ÿ µ|Ãî]MÄleÙ/€DxŒ-f‰†NOÒq„ f¼öì«&¦±S“å(ß-"ö¹Á¢9¯br6‚Rdš#R$+¼¡ñ9Ä•”ŒŸæ>ô¥ió&Z’5›7–€Ó±dN*ñì×ò„|žä ²¸i³ÖPŠº²7Ü;N‘àä42sÂ¥ ôè»èx6šGoáÞ4Të|À¸1“]5r@‹Ò “³†O.Ó7ç" Ìçu8ukgr?JzòráÖ´ýäÜ Vo€ìÓ€4èÕñ/:Xû®°õ&8¥1[v<œÖWŒ>Ì-K^tõÑD*ƒ¨¿ÄÐæ:D;ŒËLŸÁœl= ÞTèÄ–ÊÄ4§N1×Ï.$D¡)q1 ¤3Ó<Ï%LÒ»p0 +ðRl3ÙãñªdìtŒsØ¥ 5ÊêaLK¸ ÆøéÐSñ’a*‘ÊôY„ˆeDI°Ì… ±†‰°ó-Ë9§ÃU,‚±ÚPíPK×MÊmÔžnŠxë³àåŠÞÝʧ|e Yšä°F§ÜZg#ÓrFÝýn!B‡áƒ"¬Ð+ ÚZ6°Ze„:ŒËÍbÅœƒB¬H_6`…#áGÌó,Ò9½XŠ®ÑÎÉ2Œx2‡ãWJŒ‚–ѲX¸¹.C ¬ cßéÖÚtK£e9mšú±¸Gq·q€2mq™BD¸çyˆz{0ß3ø =FmqqÂ@²ð2ýð-J(^®M¿„ÁBÔ§Šƒe:/ªõ=ën!Äéz‹rßs¨8ª4=]º à—/µ ýåËÃùë2îç¹)KÍÐQ´æò³Ž¹is@;½¸Q¾ý™2^å§ž³j \€F]¼ÿ_Ûû‚–ô«ƒD‘zäÛ½¬.•õÖNŸO+—O ÐÍ’KãÎ×pÀwˆF˜ÿs ìïѽ¯™Ã(,E*‹ªËs(À»ÑN‹` –ÜÌjNú A*5Œh'ò‚<®½ü1^¥«Ú]Ëo¼Æf¨&¯põÝÕb~{ƒ qÈâÝOw|ôÛýÙÎþÎ$Äendstream endobj 5858 0 obj<>/XObject<<>>>>>>endobj 5859 0 obj<>stream xW]sÓF}ϯ¸e ã”D8vb <4$mf(m‡txñLf½ZYK¤]wµŠÉ0ü÷ž{%ÙRL!léê~žsöêß½#ãßMgü«Ë½_¯öÆÉ7Â’ž]Óј®2ØÎ^âC*÷ñA®<å¦X‘qU Å\Erž‚ÉL0N›Š¢ÇUCÝÅÜ;ò‹OFGÜ/•u¤²hiUÖ-iÿêÓÞ³ ä#±F×ש­üÚ]_ÏGóýæf—ÈèNmE¥×îb\EŠÖFݰé˜&Èt´É䛉$ôôÓU¨Â»âŽÔ­²…Z†h›ý­ •õ4IŽH¹”r»ÌM8 ÊSæù"E=«;_r)ë*’ù¼*¬¶!RS˜hå÷2Hèw´ŽPœr0Våª0§]k^$SžÃåM&ÉtŠoéHªªèÂ{úÒ…ã!Võ‘äYn‡\#ü$I2°ûújðuãîÌ»ˆ)¡¢ó{ëmJ*M‘É|Äéü2ߺ~0úñŒ“~óæ izÍålâwóßTÁFª1â{É.T¦:é²R w[Gƒ>p¾·øq÷‹o¸ß—¾ìd{Ú‡2Üi2›=ç~\ºé-€pbŒbäuɬÊõ»Ek @EucÀ,FsÖjÌFžÎÊ[úUd#éfÔÀ\–KÓÜL车kŠÐ©#x®Óî>ËÙoCñ w…ãöèž]¼$&&kÉáD&>%'É1ÖfÁ.ª]ð¢¹/>‡“c¢)mÌ)µRâQ@ðuäêZ5`=ÝiX{ L]ÿÙBŽ:[t¡dI8{ú”µÄP>‹ ¡_¦ËÍÚråCT.š®i\B¿2—3U±ñµMÍ.Ç z¥ƒ^ë:PZ‡Ý´YAylÁT¾¸5éV~bµå4 UµÎ¹ô"h¸3ÅÝ8!®T¸ 4\‹ ƒrU¡ AÒàAÒK1Yg5´ha(õÎ^h>ìáŸdFAƒÍ|ô¨+þ´IéÑ|¿•½5ìÎ@*‹Â¯¹tíSÔ’ûºHQR–Y-r[z¥V•©V¾‡£U‹µÇf4=6!@«zMïÿy÷ÙíÚ±m̃_Ó‡µ]žž¾m¡ö‡7ç:X{vîk×\ù¶ñ=v7Íå&iunô ±=pšT«È#jK£tÞ:eÁ—Ã®ë€ †ØG~Sˆb¤oË­P®ËT¨ÝÄd“¶ƒßÀªƒ€Võ2ªœøC(P£0¥q@-Î+imƒÑÐY $:>ê°X‡#²TBqµe{…~# ®»0AE«:´¿xXZ؃è-Yì(«©Ý8E¹ŒTª;Æ8[0ôð™8èµvi†]è–0>¨[Å©W­ àQÈÌ2ÇÓ,;ˆÏ't£Cp*)Œ¹7(ºµjЂÞ<QKè’Ö  ª—K·ìD¢ëBýµð 59æ/(RÓv¦_f±ÆØˆ~qùœ."ÉA:mÝSƒÝ…ŠôåÂ:9e0nLº 'ÛP >!ý¸¿ïunuƒØòfÔ _`µX 0±²ì®M|ô)芲Çm“iúqÙÚï*D„˜~¡ÇJ œ‡”gõÐ*‚§óÑ´çrÐφ…‡>|¼üí:âùІ>¾'À¨l}ÿç¿®:†íî g™Ž5fˆõÃÈ/èÓÐÑ=¡“gI³Yµ CP·iNC‘mÖþ¾Ž ±yE© <2ŒÍY‹„¹ƒn —4‚YÚŠ_îƒu“ v$,3X(ð?³úŒÖH}…G²Ú5ƒk_ÚÕäEûê1''Óš·ûépšŒé­×5k¨7zÞØ>olÙf¦ôç{s•Û•,í[Ojªj‰ÌÏžŒgÉt‚EÍÉË_:¿Úû{ï?ç¶Vˆendstream endobj 5860 0 obj<>/XObject<<>>>>>>endobj 5861 0 obj<>stream x­WMsÛ6½ûWàÒF™ØŠ"ÅŽ“žÚ$n2Óô+êôâ DBbPP²Úéï{ ‚6“L¦‡8žX"ìîÛ·ofxqøƒa½S«ùöáUmêìÖÑw*š˜Û½iŽÊ0f7*ïšãæ%îLe×¶Ê Â' Q#¼ÆÞðD´2Êܦl ~þzD–œÄÙEXÇ£—Mû£ç‚—À‡À5?>¹öÊ~l¼óìF™$0#ø.‘<}¦?CÕ.êºVÑ·Fùž›SõÖ)ØK¶ê€â©Êü¼ƒÀ!å`B}tºe´|@Fó!‚ Z­;è˜8⫪uw&òÉcIl`ª~7&Ø ’KD fõ™[S!ïF¨K*‘À]ð+dèØó(lg6ÝXä-§ý€òItÖdÛÈ!Id[ÔN|³H9+ªÕH¡¾V%Б3µI¾#½üf[Ç^j„ŽÀŒ‹Ø vd_£’fr«êk`H¼eq°j‘ïK¡vMM{Êë‘38ÎVFX[2Ë0$ÕÄ Ž9ö}ÒëÂ’ˆh)êÃéÔèüoí-¿2M`©ò«¨êPÂ-Ï®':‡••סBšú…r;VL†hÙÈ÷·.P8Gø…8Q7úÀR%_í­ï ‡ºJÐLRK´£Ç®8$b‰SÚ®ÚªØøS²ØÃ„4r£ß™•PE õì9 ÏáÁD±ƒ¥«ã§bq_µ‹ü¨ëIù‚|³6¶”.0:TJ VøhFÞäðþ¿¦H~ï÷¤³ùU\Z>A4[½…ÿlï) Ä'ëv]_ã]âGd¡õÔœ $B…XʺÐh,¡öʧè3@Âj~æT F¢Ægv+<÷ëQø„¬‹ì_ŸøB³ …B(ÉàÚCÐ; »¬˜ï° yc¿¤8A¾¨€pàAñ׺§wß  ø i¹2,FOâŠ||9A,fmeICù ÁQ¦µ;È<¼ êÆºÝ(öA@~¥%ÉÞÆht{ò›ǪP‡­­¶#wòŒ¿ V¦è±£„¢lAÖØív>$S‘ÏÔ;+Ó µÍ|–¯úqdðZHò~ùÓnº¹Ù5º2‚ ÚÎÒXï*šMš˜ê/ö2åœæ/1Ë©2©šâŒ(›¢Àq„A“öñߦHûŸ}2/ÆMÈÀ;*X‚AmbB‰QdJZ3¦p>˜µAN+á(ÕD÷HÍÔåtÁnÎn>],ð­žäaíÊ{õOqƒ^=¹žÏ£ ?eJ˦ñoa>\O®~7ZûÉæåý]ºÎĉÅôââ‰ü¡Þd}‘qEÚJnÑȺÓÁzŒH°Ê†bdw¡dÉ´ :±éÄ…ø4¸õµö†Ðä1y œ¯t½·¬ÍäK y Ü{ËF¨³1¼dÐPV½þå^nn5[â=+¹¶¾¶kªçÐ[¥“ I œ #z“ÜñøêkfšUýURü–Z µ`– æ#½H@{×"2y°ÞœšÝš:úþÏ·?bráõ !¯-yA5ë/a쎣ØïIi1+TìÞ0oÐ -p¬M¬‚]A”ÕÌ#à³8æ ¨N?Ûº s£ÌfPJ|Ý̸ìa¼C®;η/MH¸´õzõQë,ønl:‘Í„Ã^ z#BI(Õ#W)”ª?¯lÅ4X¶éà æ0¸¼dS*H—Pð„—‰<ßðüJ0a“/¥GA‹UBJ‚}äO™‰y1,AçJ¼ì…~>{:=_œãæ Nñò=¡Á³Åt¦^ùJ®œB#î‚4æÅgÏxåîg¢/^ÏÏgÓÅws¬>þŒ§¼^žüvòž[endstream endobj 5862 0 obj<>/XObject<<>>>>>>endobj 5863 0 obj<>stream x•VmSã6þίع¦—˜¼‘ÚÒ¹rÐÒ}»Ìôa2–¶å“d ×éï³²p p7É$q$­vŸÝ}öù¼3 >^Møe;?Owúa®?Ì‚öÏh0¤i‚½“ÃCšÆ~½OÓ(MÂI8 ÓýÓ·oi)ÓBJʦ¶òáÞpŽq<ø¨3éT&-Ý-eN+]Rd¤p’e:.SÙ%åHYÊ”µ*_P$*§kå,éd}‡H•[…t® É{‘þdâ-.E s3”ªIn©j¯útŽØ­!û5 G#<ÅÁ­V1YéæÎˆÜ&Úd³à" I{*ëR¬ËëTRv9¾Â{Öù¾bÏ…“É;6†ît™ÆtÀ¢H">ÑŸ+·Ôy—®K¯¤Q±â¹&)ìŠîðè4E"MÅFˆŒX¦KG éH£}ˆð¸òjKˆ'''ÀåGºä]ž³aÑå Ûç×U÷¹Å~×/o[ôËÛ±|uÕ2Ëžl` ŬÓÚ55"’×"º¡YiëÈÈHæ®B&ÖÍ:>àu(Dç 0¿ùÁºXå'oº@&—4@MåôSÛöªgŒÞ1Mñ³B2¤³ûBFNÆ4/æb>žÏ«¼óчzÞHöt)©0 ÎÐÈ'ª×-E“]ó;g$.Mu4 “=«¾H4›Ø˜ç‡u<ÿµ<ðT“)›Ûlß7ÆŸ8ÂûgÖ_µìCš£½è¾ÛÜZ}}ZsÚ-byrÝý¥ººüt¶¸}éÂÚóêJ0ÒËW>wQ p}ßKwíz·¶áùcrõµîõÛ”|¤cù­\Ùª‘V™ÃA-<Âþ‰=Ù6—~ŶawøÌ6õ'^'RøÀ§¶B÷>Δ륫®ç î´\{ÃTÈT.j'Õú†‡²(@x"Z†ô«¾“·Ò ¦xä™ë9„Í¿ã.Õ´&æU<¥3ônH~ƺŒN7Qy¦ŠR‰næ‘Meâ+«±IœC8 ÊÎDa»þ6Íc”"0–ÎÔÁ „ˆŠÒ@g‹3ðœŽ!À4k0z*™â±|,rzà 3¥×6CzcŠ X|±M‘>v¢ (:½‘8‰gX>iˢЋ ·ŸXEæº\,=fQ¤VƒÈÖPÔݪ¯3þOô™…9 eTElŸ¡é°Xµ 0ROÛLLÒ^|A§¬èã?¿„ôæ%Ó>”Ö#ÄkÉ‘‚«8ªtò]B‡ôR¤?eb‘&Á¸æ dk˜ý†ðu2¬&´2„üª¤LSGþcäoY;Ƈý¥güm5Ðæ¸Ø-¼^óÀoL©X&ϨPô¦*ñªk;“`Ì@o’âø\€çǵ‘ýóÃZ ÇáÁè:ü(T’•3Ö…}ú £’ûÊ—>#…RíDÞ«jý ? GCHuÀxptÈFΦ;íüWœ4endstream endobj 5864 0 obj<>/XObject<<>>>>>>endobj 5865 0 obj<>stream x½WkOGýί¸!Œd/~€C’ªQ›*RUµÕ|ÀÈvÇÞÝ™íÌ,‹Sõ¿÷Ü™];65ªT@6xfïëœ{îåσ ñ=¢É”ÒòàÝì`˜ ñáæÅ®èìý.“ Í–4Òôõ(™N_Ñ, ·†4K{¿–ÆÒ)MV蕜÷Îç§W§³»ƒ! F¸—u÷øv)üùùÂI?êßõ¯ÕÍõÝÍütÿ‰…|eUÈ—¦ü”óž*ûâéí¥•rŒÃðÞññßlûìý9q8K ÁxÒ¦Óû ÉçÊQë¯Oñ6 n÷öüGã[k=ª¬yP™t$(W«|PÈYЯkŸ²xi—"•t[«Â>ò¦"³¤Â4íÕ\•´´¬uê•Ñ.¡÷Ævõs7±…HS“IÒ¦!'eé`cïCÍwAŒÇÉd³ÞÛ·oߺîìd’$(×£þ¿oú_;öÃñs‡áøùCßÜì˜åHöjúLq‹ŸÚÖyµï³Ry/³bÝð5¹)$¹4—¥$¦dcEU)½Â±$ߘA¦J© LÂZ±ÆëªÆ'ž¾¸eIdƒÜ¤ ½“Ží“ËM]dúÄ£x-¢…r¾K(€_‚~)«ÒîRôpW;°Z¶E±þŽ>É“¢ •ôŒ(âdÇüD·B#sš÷RS2·ç§°¡VuøWŽu’è@ è­EðÔf³U4©ªŒõµV~Í@ˆ,£µ©-™FZ$µª „CÆb'ž6Ò’!|פ‘è¼wbY²/ Aƒ¥5¡‹ÙÂsi¸‚‰Ã=¼–Ö”;ñ,ËšÙ»X ~âæ’ó  Wí)Á¡(›éIh6Ó‚j'VQoÚÆÉ”£®Ñ×{UÃ`Ï)G®b—¢€­‰ ÷<òU œ‹Íd­œ—"cŠî{úËSàËn¤ã¿ºú„Yp™\š¬†n(dTÚ0fÅO¹úü™ÞaÔS¡n­°¡-6³>[°ÁèK!z‚ <£LÀ*ÃÃѼwø³ 8ìÓa‡áˆðîdõæ„x®|ÛŨ•K V yÂ˃’õØ7z¾” 2×ЖV(:±ÉöF2^†¨…{Êôk0ä7åñ±¶Œn×:~Þ˽¯®ÎΚ¦I\£V‰±«ùi'Ñq;¢?!Ï…q2LF£ªíþE?ÌUíò“óNׂ aպα Ð=¯!aÐð_z’ 3€Fj¹K£ !èíV ¶´îbŽÔù¯|ŒVþ’m§ZXS&›åò£)¥ÇÞ«Ub4ÂʪàµÛC¬U¨NÛmÛŽBj–B¥y¢µ£ ú¸þ—ŒcY—ºÄï0£&ƒ‹MÓ;„ ¢ÇiÅHjq J2̈>ãÝEñ¦ªÐÐ+ƒ½Åc|ƒ£]f‚E1v­žåƒ6²{ÞU㎽™aÇ­Oô¸ËEfšÃ'ëv\ŒÚ…øåV:nµ¬½Ü¦yqvF¿ËÆ*É/켇A7•0w®~-(lèæê*< .ãá(¦gï/Û”F—çÉÅ䂦—Ãnç&É –†Å3,Uì ¤‰·¯b¿N¦É4Ó÷ËÏ\Å3CºÝâs1œ&“1þ™Ãvñú5ÛúqvðÛÁ?Ûn>endstream endobj 5866 0 obj<>/XObject<<>>>>>>endobj 5867 0 obj<>stream xÍVÛnã6}÷W ¶5àtmY¶¯›>m·M±/½ .Š~¡EÊÖB&U’Šcý÷ž!%ÇÊm ¤h5ä\8çœù}0£¿3Êü—ï_¯i’bñôÏniz“Ò2ÉhUÐ<¥Å—³d±xG+¬RZå#© Ú»}!ìÖ­/®/VŸ)Mfø*G„ŸÏ¤!göÊïJ½¥*ŒUŒ>¹/~´Þß, ¯lÏføgûŠðà/¯„stc ýÑ3«›MUæc+µÑóÃÝúâ«Þ®pöôæ’8™‚&ð1™gm F‡²ŠxW)šŒÎò¸ß8¢CYUH¬ª+‘+I›#ù¢\`Ý›ðüaúáí[ª­©•%.—‘I—Ü%'÷²×ÁFwG*ŠF¹UÂÇCþõãwT:*J­Æ´i<MC®Ü×Õ‘Y›’r#?—ÁÁ,½iòpG™UΓ)‚»­Òʲ‡®:sçä~cä1AÑ-;NÊ)G!z[J¼ñ‘JUáV×(‰Òáäó‚ -Ÿ¶õSæ Ð d:ìÊ|Gè8u‡ŽBÎ"ø.O]B×b[×l·È2¡Õ ƒk½Å[-µSÖ£ŽŽnEÕ(¨$ܨm©5·|[Åþ¥éE)2¢Bè¡“ZŸá[w¨aÏј>5¸Á·U(‘&çq“{¥}h®>À'óy’e€» ÷F6•â:¢w:ÀF”M§ô-/ðÔIÖáÚ(öVëÑ›Þ}¿!`z}v}xö1û u£„qÓ5côÓçGncÛü¯sþÆibø/Éç{ã•»¦_\ƒJD.y^OÃåÙÖ{'x 0ž ÔÑë~'"%=ðîvBšC\ìøsDí9 ½¯œSaÍ>ðDw•¡Ão•uš%Y2_þÊá$zS$K«@{·Š ${÷%†±ÍþqÞ­ý3‰ƒ= SUæà‚v¼:ZzyU€œ—éÅŽþ¿˜à†„¢íZ¡l´T¶:2 3mDUe}4è²Ê©ä˜ÉmÍ‹P2Z±C_ ÕmB·Ñ¾©| 6<;Ì%ôñ4¶„þŜゎï„ÔÂ:ht Á±;¦VÈ´äF }‚ÇoÐl†ÚFy <àõ‚\­ò²™°º´¦÷Ú5 ` {MU X•vÈ(÷˜9¶Ê3¢=Z<Ì<ˆpÙø‹ð^ä;DÆÃBüpV±~ö¬û­H¼F"‹,Ûk¶¼L®²+Z,OZÅ£Æ$KRúÆä¡¢›%¡BÑzò.¤Ù"Y$s–/î B%›Šª»l–Töw•.’lŽ R¸HS^úv5øiðDîZ§endstream endobj 5868 0 obj<>/XObject<<>>>>>>endobj 5869 0 obj<>stream x•UÛnÓ@}ÏWŒZ"9­í:qš–"ú@!À ÁFÑÖ^'Ûk¼›+ê¿3³ö&r. $QâÍžÙ™9sföw« ¾»àèf­W£–çzøç櫜ÀÕЃ[ׇQ =·]w0¸Q¤QŒB«]¬ÔTäEÉ žG0âîî‘•ÐþÓýlyàtYp "ãjšäxä±(9<\^BÈÒ´n?ÕKô‰¶µ VüŸ+^žpàkaʤ¤Ð¡t1{L“ð®&I®s ,zXÇ»›:³«aˆ–ÌÐéù5«ÖhÊA²Œæš&\rbÎËT°ˆGŠ\ªr*QJ—œ^ ŸC·G'Ñ9b˸¬ØƒÎ‰/Ïe"rX$j m½Ž*KYöÝ>Ù~Ì9ˆ†‘Qu0?^r©¨`1gj† |ùöþ-$LA¢°‚9TGCŸ2Ôƒ¦´ûœ/€ê/"é8h™r&Ñ>×?i&1§ˆèåeÌBîÂ;Œƒ<2IV¤Ý1úÕÅiªÔéõ\ßGÍ¢r2Ͷ`sx¥ªf­Ï“·þYb˜endstream endobj 5870 0 obj<>/XObject<<>>>>>>endobj 5871 0 obj<>stream x•VaOãFýž_1Emå‰ÏvBàè•J¥Ð"]ѵäÚ/‘¢Ízïaﺻ넴â¿wví‚€"Åž™Ý÷æÍÛý§CD1 FŸÇ(ŒèáæKÏáýe'áÆ$Œ>Äáht ãÔGE0æÐç¾;þÚ‰ Ó“4¸ÿÁý|9÷;ƒ>eö“A›|1ÂB!nl.Ìiýx~’„ƒ­šggg ÊJi xÇʪÀ­µÜëü¸~þ…Ü*= ’Þ 7œtŸÄ.÷ÄÆQ/Ž{q²'¼ÒBZX.· ­‰“^<ìÅ£=‰kL{øï,Ê´‰Y³ÀRé[Kas˜)ú:&S8?<®R áÊBªÐ€TJ•ŠlEü!Ô2E]¬„œƒš}%ü $e®`ÉVý~ß…øõŒPÒ€’Å L®–PWkP‰#š’\èç•Í•¤uÆ8†Í.?@LQ)¦ŸŒ\ø`ŽÂ!\Üq¬,U†œ6[¸Mx±}±Òå)*\eÀ£ÒbVKîëØ\«¥!€Z+݃•ª¡dµÂ*"C.ä`sFšp1n·ŠŠµ{ß,ÂXe^eMNekÒ!möEà5êÄëixnã¤B¹bAØÎ žÏ1$]â»@k<K-,BÅ€Ê<ãs”¨™Å–šUjßn‡TH^Ô)n¸ž#¿õñ ³h´µ–®I Œe¶6ÍZ“€Ä9sè@ÖåŒ6A´2¸þòéTÊ«hk9«Ì¤Âo¨iˆ©¸cbÃGëÔæçÔás:óýóÜ6qä3ûòÐ?J/ Åá¿õBÞa¾e^-;OE“à¦.ì¤û$‰œêóêBëé ÚK£=ŸôàŽOÇRi÷ŠwpMó…RÕóJÿü`Òõ–怶ëS©†LOÑîÛ?ÜÚåB‰Þ5°&ÿâÔ‚œ­¨Wí2Ï:ç•l%Þs·­yÇ2Ù#Ÿ[¯•DëÏŽa5 úŒñ[b¯TÆ4Ž4lœ¸‡‚âÒ÷ëþKQ |46òì Gn.âé~Ú‚ûˆÙSxÂìV(yyƒkm‰;‡7ŒBÌ4Ó+¨´Zˆ”ômT‰pKzwzkf©hmacI™f%:{}pVÕZ³!\’Ü[ݾZš»š|F”àUIF5Uœ×Zc: &Ýýò|NŸÖÒŠ:tÓaslJíêÏÉ/Ès÷¼~‘õk²Pä#‹r6/‰I7ùs² :1Ô«½´A'YFU‚ÌÎ96Ékíykÿ2ÛöæN¿ŸS2ÙŽï2C§Ÿj-e«=n¼Öž¯½m<2ž9Zrêò©‰XRß“Öáû- îiŒ,Ïi´hXNOUm§*›j&çßãÛdpEGý]+:ršÎ>/XObject<<>>>>/Annots 3042 0 R>>endobj 5873 0 obj<>stream x•VmoÛ6þî_q_(^ÌÈ–ã:+ö!m“"hפµ·C€‚–h››D*|q, ýï½£d'NÂMÅÖ‘Ççž»{Žw½!¤ø;„lByÕKYŠoè1¤Ç—÷½q:d#ÈÒ3–BãÑ„M»o%Ìz¿£õôl¿–¬oæ¯f'—)LYó%ŒR˜L‡l2yó"›Â¾o<šj„ÃúE‹«ßë7/1Ây£ ¿ô I€àV µ÷¼ìØööA¥ŽY·Òy,}­Bй%PTÏs… eø‰düRéÂc»Ìµ4N;%NÇì4;Å;Ùˆ¥Ã0ù©Y^ýÞé<\ZÚ†œ·«¯ÚœüŸ$œ¦–P@P&iFû/æ½Ï½|\(’endstream endobj 5874 0 obj<>/XObject<<>>>>>>endobj 5875 0 obj<>stream x½VÁnÛ8½û+‚U [–-ÇÎv±9Ý,|I»¨Š^ ,(‰¶ÙJ¢JR±¢ÿ¾3$¥Xm7—EÛ¢†Ã™7óÞðë` þM!^ÐVÞ$ƒ(Œp±ûP[˜ÜFpÆl`Áâ÷i¸X,!É­UI\ˆ*+šœÃ+s¬yÉjŠW—ÉçAcÜ’äÁ½9°<_¢2#h?`øîcòþc²¾üÛO­9¾ÐMjÍa¸ºC»Ëÿöö“Û9І=f<‹}dÁª‚÷G³“ÕÌNh`E!÷޲#¡fZƒe]p¸gEÃu·R?0Z{M¡ô“Ïfa#ypss þtÉÄ£ùú²9½®ÅÏzëËÞY¥èĦ¸|ÆIÚÛ÷žÐ =? Â4"ã°“{ƒ³År[À‹i€È(VrÕ‡Œ Å·\y˜¼”[üxŽï´á,¹Z’!íªò§t•~òDÈg†£ 2ÁÆ™ÎnÅM£*P\7… ý«Ùœ^­6¶ ¹¬~3°g9†×hn³­0ýK9cá]P4F:ê\ÿ`}Áêº8ºÅ¶È…â™÷ü­uQʼÁžô}è“uŒ8O1U¬e|sO<øÞçØ©½mhížjÇnÇ#$ouôÆî3Dî<Ÿ%ðI¶i*„PVP6ƶ†¬8u›0ú´S ñ…j.ô¨­ÌƒZ×JPÅ·èÉËÊa} ßz(Àð€¼¯ƒ!¾íö½_cR¶É!mÉXe»¤££vTs]ÔÏËÍsuw†--ÜóÏy®îðü³ˆ?H&ó€ç(ƒFÑÐÔÀ¡HGËJ+ž/hðV;Û*Ä¿(žã  p(q(¥6$È¥ 2ú©2ýŒìÄLQR{¥ÇF6€Ã¢’¸Cj-pÍŽ ®6R•È¥q]0ë3‘1ۛجï¶í(«_4kP+-jº¶s:– 8Û03Y–Øí$aè5èšg‚à+(MQ¢ÖíPm1Ä–&¸¶c¦­M)17\¨€Xós¥,Y:™Õe_džÐÎUÙ՛䗲Øó¢pÙ´‘q¥PB3™Ÿœ“!hŽãÑl‹hû&ªš2Å ƒ§GÒ4Â+dµ…½0;’Y†{ì0œ´ðvòú¯÷º²S04üà®Pp¼XQô~Î!‘°W¬¦cw'hŒÜáøÔxthØrKåÿ2ü¤°óè±9Ðéd}r{íïÓëyx_Á¿ý-ççÕßã8Œà­Ìš+b› GÙsÖã¥;/^„Ëp «ªn°C°À²1ô³ëvMÛ®¢EÏ𶉃{Íié¯dðÏà?µ bendstream endobj 5876 0 obj<>/XObject<<>>>>>>endobj 5877 0 obj<>stream x•VÛnã6}÷WL U [‘íÄñ¶h€mÚ àÌ1ÚŠ\|¤ÖÀö„L~& Ò6‡¬ç»æõ\'Z/ƒ2–ªt/).g;ß·)C”Ê] ÍE$‰ˆ±¡Q/oÈ’kaý ¹H¤BÔ2¤È¬I¢f Á¶¨ª=êŒÆdd~Sr§É4¼ Çp/©?¡ÐÕÔœ4^IÁá…ß%U•ÖÁF›Ïh‹.Å|Žv“a¥Àl•ïÚ.x žëò±ôÛ‘Lq8×êg<¡õaÝÉ”ZÙŸÔË …£¥•Xƒ5í£6CJxðáÅ5¡lcÉäƒ!á’ß`q¯3‘ñ‰à°B„h3Õ¿÷µîã°8”¼TçK?·•IîÛgV-ܽ³ô¾Õ/ªß_§»j†ú/ÖÌ¿¢xIôó§}ÛûÁû¨6ÅrÑöŠr¦¢„a82‘[lŸTd–k¨òŽ[àAPí9i 6w € ëŒÆœc]ì I¾ºÌZ¹Æ™N"Âú‹© Y£ùî”÷ˆ™Åw‘§’k¡ ?+ìóI2‡¾›þW,ƒ6ëÕ:A¬èAÛóõD¬™pât֪ʲR@¿–€Ïí—{ äKŪZ÷¢Ùƒ8iáÈQs;¢IºÑeÆ“´¾+Ùƒ¹>Ï”%^™8M¾'¬)×7EU7ãcW£h–6[Ä-ßÎêÁ1š]„—“K˜Î¢ðªºŒÝ/îþNÂþÐq‰· œxÏ mx!¬¢‡WÕåò´3^FÓp2FÅžœF—´ûÏyçßÎÿ÷Ÿ6rendstream endobj 5878 0 obj<>/XObject<<>>>>/Annots 3044 0 R>>endobj 5879 0 obj<>stream xWýoÛ6ýÝÅ!E1¥µ'i×]·t†}ÅÃ0ÌCAK”ÍV"]ŠŠc ûß÷Ž”lËN³¥MYÇãÝ{ï>ú¹3 >þ h4å¿IÑéÇ}|Â?üã×wÑ ¾¤ÉTÐä2Ö9Ýv ººÞò»ofμG»¤‹›>]Å#še4ìÓôzO§—4Ký•}š%ÑëׯI¤é<uÇ]+Ë*wóóóÙÇNŸzX¤Þbm•v„ïõ‡;‘Wr=hzy|Ÿ/nÆÄž2ê!†ÞpTǽÏhk*²r‹DR°Þ6zº6¸OÚY¥§Œ.çQˆlï0¢Åö‹ç’\”8ã¶kÙÕ¢'‡»äV’“’6ãTI…±’üÁ^®>ɸ‰iao8ŒG# € 0Ð+M` ºÿ nð×ðqàÝç}ä­”>~[PÐ@tûûûwôƒZXa·m“F&%+±”|WÀXJ¥*/k®i0d™Â)§?šÆ—Öoza*Ê”ÞÒkŶ  5¤³ý8ó‰[SH§ Y’€qÃ+ÉûµL>Ô$Ø9C IkЯ‚­k-Ätƒøä½(Ö¹ì>J뵬 ådðÓ³LÙÒu™)ÒáósúÛÒHðůU—Ï‚ÕþË“÷Œú—¤èëÚ×KRÏŸÏrÈNÙÛóWä#øSýuêõŸ“{¬t•Õ|²mí-¿(…™¡kÈjF*†~Þº•Ñ]_jZP|ÆÐîá®Áe¤¹ |`bYR»˜ÞP©oÚjRS{‡¹¡ªôÚk¸Å˱¤Qâ -cÞ7šˆ(rÄe¹l±ú¢ñô`É=U:É«TÒÙÎóY ¹§þÂuíÏ·×åüÜùeè{syÓƒZÞ|'¡[ "±†+…ƒ¼™‚µ´¥/'ȺÚÕˆwHfñŠŒÂQ‚÷j·\L^ôM^Èš‚†*nNÇÁ²pŸ…ö8C¬G9¥¦Z€ÌcË@‚Ò¥:‘A.•ç›ààzǼ®Uõ8Y~´„Öˆýð…:i¾ž„¦A&Cã︭ž•+—°Á`7ˆ¸ú^Ó½z‰9ä]ÎÏ_ìýÝJT>: ùVÚvDZ7(BŽìÄÿ¾eˆníºe3¾¾¾ž ‰Ö‡H”ŸUV þ,0V+%}h~µ4w2´@¦#©±Æ¼†âšþÈ%_*”‡ =U‰¼î¨áÚ˜Þk¨CQpƒ÷O›&¯3ßËKŒ™|RzI€»™t[&Hè-áÓýïcU:1T.ÞÎÏcúF&‚›ì¸ù„áês;_>[ߘšêˆAÞ;+ ™o)7›^.ïdÞŠ÷¡kÅôVÔÊWèÎTœ´¹ÃB"à°¾Žx€MŸ+i1GVRYÊ¥^ºÕA¡R*$þ–÷L_„JQ$ žÐ)•_PZÑlªli¹NÝqö©‚5wÿ Êek€7R‰=àƒçZ—¤KbÆêGd”ó(ª’_xTÐ3¬ÉŠ&x‰héM*åHäm\`«Q`3Šé'í¯4Ì+­„NkŸ;LéÐûs™e*Qèó 7¥DÁ—¸ És¥ÞÁDoV á1ÊxqóðB1¦[‡esé“ÈñK0n:ÚÁ6õ±µF¬xSà" .†>œÝ­”XrìIãóBűº¥Q®?jË\Yë Óð`y¼û]\ÐÛ!ß¾î —3Be=8%_{OêZ§¸‰úCg߃sÖ4„«zO\ãÉhBÓÉ$„½”÷½ÞÿøÖ$~†{‘°WìÁºwÉî?v¸I†Xø`8íOÙÁw³Î/9»Ïendstream endobj 5880 0 obj<>/XObject<<>>>>/Annots 3047 0 R>>endobj 5881 0 obj<>stream xWaOÛHýί!Ð…+1I€=]O”Ž⸒S¿D:mìM¼­½ëzmB®ê¿7³v Zé…Ø;Þ™}óæÍøËFŸzøíÓþÿâ|£õp‡?úüñá‚ïÐpp‚Ïœ‡Ñ°¹ÈèvãÑeN‡ÇKC^;8FûØô(:ƒ'GÑIsÅ«oG<‰»rF{çÔïÑhІ'ø’H$øw>¦Ú’¢›E•:K¾*‘ñT(ïuBÊc±P¥Êu¥Ë]ªRMg4­m\Ø—:ÖæN‹‘3&T91*ÕœU)Š­”±ØËXY >"º56Ö;£O=êöª³ö,5™<¯+5Éô.™Šã2Y¦g*£©+iáê’ŠÒÍûSegZœÜ©¬Ö]Zšª¸Ú¥ÑÍÈ;šc~f‚M—ʧò@𽎜§(ùàQ³08à8/§«®s—˜© ŒŽ±E]=@Fˆ³öXCø»Õ¥dvo`V{ŽŽŸf?{ç ‰¤«7`™p¿Mc‡23)U¹ ©É4%ÚÇ¥™,!–`Wù,a¾ýxyAWaƒUÓ–0†²xrnáJ›{ßžE= :U%ý¼q›?ЪÎ)°˜hpëúï««.<åÆª ÷[v¼cî ß±+Œ (²z¾FUe9CË¡°N¾Ÿ1«u‚t®ü NT)MeÎîrz)V–3¯Õ¢Ð¹*Ø^ßðˆ{+\EÒ%¼"ÔÀ^¦í [ªr†³Új%ÀB™2¢SOYõ«³„Ru…Ÿj_‘¯c<»ô TVj• 8=åJŠè¶K¸ÒŒîÑ1t5>@¢ƒhWIg[ˆ>î £ÈÊíèÃåõ’a+ºz}1ú}¼C_—Ëáô¼èÍ¿Kß~iƒgÙèDQ‹+4é°%ÔÁT‹ÖÁêÁ‘±¦2*ïÈfjÔ•P÷£áðˆ7»vsÖˆ€ì÷OõæÍ›¥ßM=ß÷N¦SïùKoùÑíýæ.õÆ;¢¶|Öü†r·-›}‡ÜÌÒJñ 5¢Ñ3%ΈE/8³Pe.T Ø(…£ï«Rµyå|,MK—ƒz#ºá¤—ÄíŸPÿ ‚Šq/èŽùkÒÙFÇ4 ,÷«X±ÕAtŒå¤3ÛÈë ý­èxJ‘·¶`D Äó“g¾ª:«h^‚…,q ªH"Ë÷ˆãjOg{g¯^Iáq¡ù—Õp»)Ä'†ö‘´£ íˆqæVÂxÉB£aà £bT…®Æ"äÑr“áoÎlSÙgtzsÉýo®Ñ1ðŸ×rhT *3OùzS²ðDj;±Q}ø€wÂc­d=«µo5 ÒÜ©bð؉€úTô\€NjéÐr ˜Ð3­Ã ¡Î_j’pTä¦ ¬œ™n·ËÁ¿œ#$X6 m]=Kù̹ƒîÄ ý 7|‘>í,DFøi¤9Ò\A ŠMOö.‡’ú âXØ}Qšºå;ë6˜CNt‰†­¹k†VhÞnª3}‡L„.<«Ëp¨ª~ÄqTE`ø°åwÔ§œ{fE«­¿=a¸.qÚš°=M™½9gxóÀ»DÓL[]ª0 ÕhÄ’ vPU*NC±*âSc>ˆ18q­s®":Ç õ½Ê m'gï4ÅÌt¹š)é#Øž…)ô„‡3a4øÌ‘ü°1 T9æ&ˆg(2 ½-´1M€Uþk›1 æg«O¿¢yÀf7‹+ggÿœzþ7îlÉ$Ôˆ>siåIdßVÓqgóC!ÑSm{xzMÛ Ä{sw«¿þü·•8¶ÍÐi{5<¤Æ”Åqóø'N²Ú̶e¯ÛÑ ¿U6W $Ö{TdhZ/óûÀï5vÈ Ê)‘Ú Sô¦±›„©:u juŠ”3 PíEØ-<ÏÚ(›0[¶c…< âKK®õy 0ðží0©E:²çyj0vðÝFL¨ÌC&Ì`Á‰¯Ã­Å‰rÀ®m‹jé,s8ăx8?— æ¸:Ÿ`îÅ‘<*7žó! h¬×“ CàËyxký üŽÀ>CpëÖýuó¥„Zdp“º 8›-ÕŽ[“¢ÌÅ£bÍBÝ®ÇóÚç‘Ä}/Æ=d×M>µ"ùŒÃ›ÅŸa}}¾nç²ð†"“ºÞ”7ç&vy×~C¾—#lÐi/®`9CcD»›º,sóL—<‡‰8-Ýä…ƒŠItËš+©Ãa;Š7o8ýãƒèpÿ†Çƒ¨×—‰U:Ô>Þyß¹XÆgXs[°î1ÁÜr½¾ o­æj0cÓÃÞ’˜q fÃÞßz?Úøkã?5ÇÝendstream endobj 5882 0 obj<>/XObject<<>>>>/Annots 3049 0 R>>endobj 5883 0 obj<>stream x¥WýoÛ6ýÝÅÁHeµ[Nœ´Ý:d]Ó(†¬ñV 00e³“D•¢ÜxCÿ÷½£D;r’vIà„yº÷Þ]>öÆ4Â÷˜&Sþ‰óÞ(a‡?Æüñîu/ŠNÃSš‡SÊ)š> 'Í"£«Þ³;Ü-³ £‹áÔ,¥hDÓ§ãp:=¥YâÌŽhïd,ÕJ&$ R…• ièMgz#Žq& N£¯.މ7RÂØ0š´Æ‚7Ù¥ªHÞŠ¼Ìä+Iv]Ê\”„}Q–™Â+¬&‘e¤ã¸6F±¬H§îpc:óé¾0 DXÁ&Cú]×Ã[#SUà=üæ›5U5Þ²VÅ‚#Ñ¥Uº™#â0JaD.-,ð;¤ m¼ËϼÛd £(œLº$ØÏuRgÒn"ü¬s§ç‡œB*tQÈ…°H+ýå=p‡©ýÚÓwÄ7,®\®ßêbq}^ñ¯y°§Š²Æþóoª÷pý[áêÃÖñ’Ëõ+c®¯¤½²)™ظ¯Y-ñD›AÿÕm)cË…ï8¼â#aÿ±÷ö‘¶6ýüëÛ·ûø¹ãywµ¯ŠŒ«¶ßu]Þ¢,€”ŠØºÔÜuk×}gõ«€ŒEµƒÆX'’!©‹lMÂZ/[`šEËÂV”°\êØâH.l¼$ˆ©´…ç]çš§žA؆3>f ‚à @h 3EÂ=7@ˆ UP©Š7] ¥uÇAµ¬V:[/¹6 y@¼RÌ5²HÝÐy‰:‡­e1Ò—Á?­3„ãn—jǽ«÷o^ÓË'OœWÃj]Y™‡ô~) ZƒjIC³­Ó)hs?!;I` @}  ·úëW]ük‘!-2é±F¹4V ;ê"ª]s±.*˱íøDJ$‰â"tª‰˜ReúÓ=ƒR°cY‰3È [«þ’´ ¹«°ø¿kD ÊÛtô ¨Ì~2ŸýÁÞx—Bÿˆ—môœP$Ðu‡.çï·=EÃç¬vGGt~£¡„ Û~àKÛèè—=kºIå”_d•¦ÙB3Aé -Œ®K×O2®üzý̓x) }SY3pyÈ$ }W¿8RW°Ëu£¸s/½ ú^„mn\©?åcòÿÙg½i:\ŽX×hsñ€rÒ]zT$ÃåufÕÐ'ên™æ' [ü§,hãŸÄº"èP’q Á.©X@.×vÉ:wóí%¤·gt}¦i]ÄÌ_|'N”³®`*S´=}ÚªXÒRrW‘ø…]Ò¶³ŽçÊBÍæ‡_îà/^¼ðÝ;lw ?IxFïµÉ’ƒù¡÷ÉrÜYÁ¯.žÒ.ûèÄ@“ixF>øëUsÅwž™ŽÃMW(\)]CÊ(n *Ëj Ì©3¾¯Šþ¦ q{%å§“d'«/C:'ÖGi×Üd•¦CÖVƒ1ú,ur¿3´eæŠ ÔšnFžŽ´Ú;z¿d6¸yñFÄðã¿Þ”à:H®K»é#L×v™Ï²ÃÁ¦ø_®ævæ‚¥vèz€FVÀ¶£TéúÂè¼±æAÆ£Ö!(û *>J™sDa…bÈg }†›ù kqàûüòl 4§à'wY—Ô¾ ³;Ïc<¼¬uûé=è3­KŒFn¦8º8k'htžLNhzÚâ‰{øpŽèG»1Æu&¶ŠQ½9;}2š†“ÿ†`r™ŽÎxëÕ¬÷Kïo â¿endstream endobj 5884 0 obj<>/XObject<<>>>>/Annots 3051 0 R>>endobj 5885 0 obj<>stream xVmoÛ6þž_q(2ÔÙbÅïi·OY:w,[= ´DÛl(Q%©¸þ÷{ޤl+ëÒ­màÄy/Ï=÷Ü}<Òÿ‡4žñO^ž ²žðÇ?þx}6Ɇ4N²•4™f×鋦·g?.N·KvCWó ´XÃðì%þ(‚=ü‘÷~6;ù í%ù­¤•tžœil.ɬÉïkYŠšTµ6¶^™Š–=Q$?‰²ÖÒ-/H9ª­Y‰•Þw{¿Å¹Ò–¤¼“zÑ›ŠÖ"÷—$´fÓoß½yýÜ],>œ ¨?!¤^!×¢Ñ>x¥-¼hUmØ<^¨J´‚ƒ‘Ëè/ÓP.*zPrÇ~<¼äƒÚ˜{¾.`‰­‚Eá û&­VVØ}F¿4ÈÙ‹{Ù FUÞÈsÓTlfÒe-<ƒÈàpœ‹Û© pfãl4úny±L’ka%U&ÜÛ/ååÎXö o‘˜Û)Þ³ð­+,Š^Ê46æáu«#½g”oE ”™}èLüéäû¬äŠç¦,¡‡h¾ï¦Äè°Î‡ÝÜPôæ†nQÀü'µVºÚT·5ˆÁî (Ü1 wDv­dêÔ®×Þ7©(]Ÿ=*”•¹G e4TUƒÀ˜Ž¹Í2Ä·ŠÕfˆcÂ?w䚺6©C·F`; »iJôNâzðaÿ9'œ‘;€ :øO£(©•¾±¬†Þtb‰²›ˆÜ²§ÏFu=‰u“?<¾i/öîö¿­>ú¶{¥‡¾Ô¡"ÄšÔÞÄÑÂ'IÐHÇf?Òû4À˜v×ÝWEäšÃ z€“Uó>ú"dÃ÷•(Ã\86û1¢ÊU ‹,;|2ð€vn Ë|+‹'Ê1|Ï|ü·lÙv"÷-‹@ñd5 BH„~Ò‰~ÊË *åœÚT,ja„J1¿à•Øxnœ¨J„ÖçûZ®}ŸÇxß©"Ì&A·œï’ÑwhSKö‹åE’–0šÏy« vgkúˆfWhq+!JÊž5J€3i*óÙˆìÏçŸÃ»…|¶-¬v"ìjPX v–ÓÄj*¨o<Ú ™kü.0†ƒ<±l„  U\B÷æ { ÇÐ…%ŒçÄ“tqûòK\L­ˆ˜jø8XÀÅáåX1üÁ];õb/esoB:ÉK@2ÊÆc ÿâD ïö¸ù~nMù«©6ËžÆ'éåÅ-mx¹ŽO‰ÿÅó7.ž>ŠêãX7ÃùöÆíVæ÷ËÇéÂÕ¼Í(Tk4Îf³ëbغçÚ Óa“ÿ?½` $øÊ4P…e¯ˆ¿¥ŸÆã×ÞøoiÆ[_›è[ÈÒ|”à‹TîÑ`’MÇSš]² o€ýq6 W&ã8ˆ  8ƳýkÞ¸ÒÎ7jIŸ¢é`–GØqj6xÉ·Zœý~ö7 ]? endstream endobj 5886 0 obj<>/XObject<<>>>>>>endobj 5887 0 obj<>stream xW[SÚ@}çW|ã2C§OTÅaj--±}a† É¢¹5»Ó_ß½„$l€(ê8šìù.g¿Ëáo«*ýîƒn°;h}5[ª¢Ò‡Å¯d WFЦ š ÆM_1Œk0~JÓnϲ«dè̲9I¼p½œ$Q þ\´í•@gqùåÒ|i©ÐëSs4¹÷í°]ð½€BÙ {,¾ ×XÆ$Cx8 SF;Æ»XÃxºÝ ûuQÉ$wu5KÒ…e¬§é9cô$ÙD!Žcq~Wêu…ZåœCŽ›£9ŽW˜$ƹ>ž†%®e£“šo›ÐA~èúePŠÉ‘¢rùÝÖ åÌ,FÃý»Ð-œ‹ÉA.?™ø(£S’æÆÃ€©Jg,{¡í§Â`‹¶€r4D.a+0‰¢¯»E)ÞzCµx½‚E€l¸”x »¤„ômÇ\ì*x»/vAµ/À öŒiÅ&C‹¼Ô ¹ËùŸéýP°JèŽQÄ¡Qž´¦”¡>ãZW4ž:;ÜÓî"; PH,FCQ}.÷®Å§JꈲýŒ‘›útøq½¾'Õ‡ª¡èýÜDã6ú*³ro¶~¶þ·æû\endstream endobj 5888 0 obj<>/XObject<<>>>>>>endobj 5889 0 obj<>stream x•VmoÛ6þî_q0bLqÙ²7]·]š)Ò6C<ôC5 EÅl%R%é¸^Ñÿ¾;J²ãHí°ÄHLÞïî¹×/½&øA<£/zÌ{“p‚—›?æÆÏ!šÂ\¾Æg1c 2GÍD´èècÏõÝ'Á=wd¾Èˆ¥!÷ ÐP ‡ óIdSÂlÆ1žÒ`PètIÚÍýCí 2 aÜzþ$Ø“ª\ºdú(º`å?~G@½Ô ž¶B/ž¼_IHdŸ´I{Þ' Ψ¯ hñ$HÒq%ûCú¢³†‰¬j¿“iƒÏTJ@ÂoÞ :}4ý}•C½uäµp—N/#Ù¥ ý©»ñ)Ø`¦É°–ë€?{ÑGù·WRK¼´Õ— ìz»5‹ÜŠŽ–ëõ¹1·7Âmß>ÿÊoç˜*HÐfÔ÷_,±ì¹VŽa±ÙªˆúÝÊ2#(°„6â¤Ó·4 ¨6»¾·àhß4à´rã;üÀÙÿvTiWg{§g?±z×¾æ´[·<LYX–¾ãÕ¢nZ+Q'ð/)Ü LJᙲ¥âNbå˜Ý; lK™°Æ^ñ“z®¢±­L¬§iYüN¯ '0è»ú¥òÝyðmçšj¼ÄënÑ$Û¨R/ë¬'âÿA…c³Ç.˜$‹uÐ)N¹TéÃ2ï{ÎAJ%3°I¢ú#£xW¢¡4Vz›ÒÀAÝ< HI{¹Ë»Ë7ðÇí(<¤ÆÇálöŒžù° £Šµîðø d‰n¦#î•ae‰ålƒ9(Œƒ.…ÁÙ…ØÖ˯ûøb3äôôkP~ˆ€,JmøAMsÑ;E,#õ±ÿŠ=ˆþ¨ÿV~öÿ˜Yãé Stz£ª1Ø ¶‡vBp“h›‰žk“¦ž„*Ú¤˜H¤¶M:ò$4e‡tL§'¨O7¨_æÄWV”¹@œWR™eÂàNõ@DhýR!Òj/èKÕoh4ýœÇakòg³Âi†“ŽðõË Þ¤ÔiWYïGg™~ñÛI7Rá~‘®+$‡BÚ¬ý¦Á™¯ôGÚüDÃÀ7\4«ÈÿR•1ýºú;­ÍQÖ ÍØw¶‹€·¥ÊÂZwF\F‚/½¸ƒÑÅ6ë•å¤Þo¦“£ð8>†Ù¬^õh}:ŒÃ ¼ÒÜâ!ÿ±*ÞÃgUâý¿Åòx2 ã)n•X@³(¢Ïç½?{ÿ}c%Œendstream endobj 5890 0 obj<>/XObject<<>>>>>>endobj 5891 0 obj<>stream x¥VmoÛ6þž_q:ÌqmÅ’7]·Y›Š­[\äC]´DÙl$Q#©8ÞÐÿ¾ç(Éž_’nXØz9Þ=|îxÏýqÒŸ†#þóƒŸÇƒ`€‡«/3£ã«—F4Na;:;£qâßhw†£àeÑåC)ŠD3ôaéæº =ý"cGªpšò*sªÌ$ 3«rY8{4þrp|uB!¼°ß~tœÀsçº*Km%¹¹p´ÔÍE§±Î2¸Sì8¥×”V…¿³´Pn¾öK¶Šqk±^RŠEzT?Ôát 9^Ä£`8Ä]ÒD˜ê‰¿Â¸Gñ\êvqs?9zµ ¶ïWƒÑè¯~WøX¥‘÷JW–äƒÈ±Õ@»e)sQÒxF9'a«©Ö®yÊ”u-àfÍJç(6!tÏœðþš½6„p€©¤ÊÊ„×`£œº¤“·©œšû41ççç51'=útŠ{‡SaðmK‘ã'<ü<9Ú„¶ÅÎE†b¨fsp¼ mîl”ûž ÈÀ×Äân!LÂÀm)c•.=¡m© õUá°aM©zð~˜[_Rý•QKu, Þ~"SUÈ$Ø ÀS…vt/Í’•¦*Fmöû\iºÈ–(·{JVÜI²™šÍå–*\~`[ïMøÓT~×ä"›Ñ£µFµq0’Ñq—^Ïe|G*%Î8XC½t·ÌðvÒù°|—·Þ~Òy¦Š²r“#„ÛvJ|,IùÂæ ib= é'T‰ws­þ”k/{l#ØNÚ"E”œË1žt°(|NŽºtÚš0’]/©6Ì\ ^‘¢¿ÏŸïEMÀökÝWºzô­tïœÌ[°=µ/ö\stí ZBË’fX[d’ÿ{}RŸ}fÅ…­/VD?²ÌÐÑv“Àa>,/¹½–níûò!¾£uà…6½CŸð¼BÖc]8¡ ²~öp0¢ÔHÎ\ôØ{#]e úåãû÷» !úºCÇî“–œÁ¶ƒ¯ôÈf¿½Q>—u}ïÝÙ¨7ñµwèÓ8Bë“Ç´ aü§ãWS¹.aÚeÕ‡[kÙV¼™£ésó¯Å±UÂÎÕ#) \7V.î–Ï»‘©4²ˆeBÓ%عF‰)ºf«sœ«ã+ˆ¸Rœ¼úA«¬ÂùÚ¶‰¶lXM꘬V±N$¬¤Ã*ÚÝ7Ë€©–;Q–F—Àâ$0eÐz…aðž) Þ˜Ú^y™¿aÕfc1ÕÜp¥„÷21Ô“ò¶H èÚ”éb& 2–Ö 4p– öˆb°äpϬœÎѼcô§%Yé@åÆ[ÆÛÝtÖ!º¯¯$ò[úØŽPuyœ¶ÓƒŸŸ†ôÑry4,x‰iª½¸Ç¦ $,Ï1!!(Œœ3du.1$áÉ̈ܓàç©&S¹X²HÖ!'¬XÅ!#@‡An ¤M²,~5W¨X_mRëã_³QûÝ÷ 4ë„ÃÜT{ÇIn¡Ûš]¹ø1.¢mácãYdÒItÅÇBô¨¹š®®ºìbãñ‘v½Ñ@5Å<å£uUšž·%³KnßÞ7DÂH‹9"Üî†lR±XÖFÑ~£†äšM“¦Ãœ5‡<<; N‡§4z1 Âz„½¾y÷¶? ÀûÛÏ*ŒõV[÷_Ô2ÿ&öÓÁ(F×ÑWG¡o#—ãƒßþ÷» Yendstream endobj 5892 0 obj<>/XObject<<>>>>>>endobj 5893 0 obj<>stream xWmsÚFþî_±™Iì§g&oN=Ó&iC›¥ã9¤Ã\"ÝÝɘ&ùï}öNÈ8NðË€no_Ÿ}vùt0 >~Oø7ÉžMúQ›Å%ŸhЧ鲓Çx“ús¼I:OÉmV2+J„¦¹¤ÒÊ”œ¡¥Ði&É-•Å‘•$,-L–™µ¥Ÿ§ŽÏútŬvاÞpÅ1>¥¹IK\5¥Å%‹ò1›íÓ”:™e–Þ½?Ŧ\!…#˜OM9ÇÅ#½2—ÚÑZ¹%i‘Kzø¦t‹¬”áI¥”ƒòJqÖV¥£+‰ˆÞˇYFbµ’á,e8ðÖð!)‹‚ÕÒ–¬,U²¤›Jáçe) ¡ )Avý¦¬#3ÿ Gó!jÅø J謃(àÕì°‰«>·l^o7o‚Î#Ó¥#3äñ/{b†N!z–á.Î “¿ð›uŽîf‡ûâjA³Î¬sï~®|ù‚'ÕG:ee¯–³Cœí{Åž5Âdö |%™·ßôÖï½ÝLËU&/ž/eò±±}‡Áé"äʇ}û,˯­“µ¹×r=ëÜš”pƒS{'ݹ“ù¬Ãp•®ÛïšámÉä{_÷*ÂOMìËÔÝmxϨ‰Ùà·ì™ïF¿ù;ù©”:A®N„›u€#K7Jÿâåó?_ž±Üݪ©‘úShw…³+ÔV-ºu/Ì›wGuWì?©œÚòÓH/Ž£Éäwþ­\Ó×ÚíIEt¦ ëºhÙ„‘Ghç\¤¸`ÈJI§ÐZòJ™ÒÖT ¯Ñß6¢óYt¢r|Ï•… uŽáŒËW´\ט²O»<Äw_ ©… $¢\Do@HÅZYÙõÔT±„ Y™Ò¦ÈE–m…)¼9›]”:qÊhÏVLÁØ;!ͳCöe›¯Ž7PÀ[ü¹e!å7}µ½^.…Vú‚ cæÌÆØZLƒsH@Ü )0 /Ü· Ž8 O-­ åœÔ!ÆFU^‚?E’È•£QCô¾rJ7 n»” ºµÁPb§Vé—Ša* …*ÁONÕÀ€Djt¶iÚ 5“¥­IaÁ†\É¥¸’¤ U)X”ªÝx3;Œ4‰4Uœ{‘5¨«†fj¨–¼ö¥úÎl¦„Ò]]æÞš=íß2-šîI­n¥éûðÏO|ÜfHß[4Üèžg4§LÔbÃùÝñ!Tl'~Ʊº&eѯf-¯dÑ%«@5uöÉ:Ê«ª„qi%Jˆ~3à;©õCºU ¹\@;,cgž×W)ðÅgM‚2!LóB ÞÞ›6à„GõÊÓ‰èýRê6ž­ƒ5Ääl ުǺUè¶ ‡°ÊDâ{¿å¯_‹Ú®DÌ‹ŠGn€ža¢ÍºÙ¯¶»ÔÝ(yòä TžV$:êŽCƒƒÃêÃç«‚iVÔîù•hÖéwiÆ]GÀTë/]w7ÝÿîVÒø˜ µ…_àzÃqͼñ$zèw,X\¯··'yZ@Z™'-󺱿®maÈÛà—Áç:`j2…‰…æBçÒeÐ8•£L©´ªðÕ†Þ•°¶¥œ@Cy­±v`꬚ñ;+«¼µhº2*eÌ^¤ªÀ~ošÞÿŒþÅ8âiöXl ÔˆÑÄMRV#Ï·ÛpgXñ$1*i„ ;­6î°…û~l͆¯àc„%LúuÙ§Ûg¡.É(pu Û Ué†o8¾zLsùxés¶zü&¨ üýøI5Œ'£hir2‰…ï¼ê÷â¨O/Lâ7{_k¾†,éÞ£€i­˜þ½`ÕiAåëùSS=ß÷'Q<Ä÷€i2ˆùÑËéÁÿ¬œñ°endstream endobj 5894 0 obj<>/XObject<<>>>>>>endobj 5895 0 obj<>stream x¥VýSÛFýÝņ!l!Ma†€a†¦´v¿3ž³t¶.X:åî„q3ùß»{'ìØnÚ°ñé>ö½Ý{o?UêàOšú “Ê»A%ð\¾©)õ8ñ›0˜@#€ÎiÝïtŽaÙY B@¤ÄÛƒÁÇJµ:F48¡w»äÙŒ.c> ½}‘f¹ àóÚôbÁ«ÛÅ…šŽn™ÒÜ.-U÷"|íU O2ûvXw ÷Ñܲ+Àí¢«Ô¨ÏMß(‘N)¨îS8,2ޤªîŠ’\ˆÙ#‡ðOxjôÞð`àKq“«>üzsóõã/_!Û¯Ã|G‘ß÷ë ¾àašoàãŸãæO €…ào wG°«¡ÚoG½P 'PÃ|ךÍ"ßÞ Øl&çd®€PRq¸Éžæf …ñ™ºgåFLòÔŽƒ‘0æâ6õDɳcb™Ó0‘nóïËŸË®ÖhøÍ&a䟟ÃÊYCoè~»ŠU[­ã_-ðm*†Õ ,šÆM_¤!·8–eXÊLp &Æødj(û 'Hm¡+,u‰c—À”b‹*è<ŒaüY¦$Ãÿç2ŸEJC@‘™`!E„V*ˆó)§°èš4ÝEWaœ;A'H h£ò+ŒãciÞ]= S"徃w ´Ñ/r­Ñ¡›ÿÔoÃ*Í?å¡"0YF­W™¡¥-¿E‹ûy–I,F3 ™Ãœ!­ò”+6ÑS™âBæøKèöà”˜¥þWpcÙ‹ÄdÂr Wj"iAUí‰˜ÆæJl…ƒ÷só¢2vÆÑ~ÎW‰œÔ S–.l†É|ŒqZîË#­h½.Îz"E‰róî.>üy?ôŠEöï×±Ô“à~ƒŒm—BT¶~‘Œo’Ão®®ª^†—Âez£씬UX*÷Oãx›G7<š¸”a„üê 6à'uÜ"\¿±Y^*î¦Àa.L\ný?x]<Ì(œoAÀå øåðp+ÞHTî‰{ÏÍ5–@ÉFUlöë}˜ðÞL2Sf[nu(ËÙè«îå/ÝÞÐÉë&A´âë¿2‹:6¡P¶ùn½Ã%èäuRiÌÞqorH/ô•½[[1Ü.F;P®²Ã7íÔ5¯zV÷ëÔéfÈ4' åðÈ”`tëö-m«¨äUEô­Íõ̉_ J;ícEðöóT£Ñ¡#¢P£f/ ×8WÐÁ$¡Œ8ªÝ ÏÄñRl¬ô—ú†â„Nr=î0z  cÑ»5ïQ 2¹”§§»:ÉÒjùØYc¦–³Ø]ë¾ZÊàøî¤\±•Oç–ÿXbƒTÆN(ÑÐ)Eª¹"«°j˹Z ª#*®žÝ£X¢ª 8íOØGñÂõä!È"jYÌg/®ð†'΢‚ܹ@¿œ*Î ¦@ñ(GW·q&2G×ÁÂ/£pé¡–µ›ÚןËS­5hÃŒ u»[ ÔN–ba»Û%±o2£gá}”æ_yÅZç|Ô;):¯úIËo7ÛÐ9 üc×#õ¿~_kú\É0§>cwMvAnvíØõé¶]h-Û…—½%3âZר%í ã7Øp`¿Ð©·h¨;¨ü\ùZ§Aendstream endobj 5896 0 obj<>/XObject<<>>>>>>endobj 5897 0 obj<>stream x¥WaSÛFýίØfHÆ€­ØÒ”‰1fRpƒÛ$3š³tÆGdIÑ0n§ÿ½oï$;6“™&„€t··ûÞÛwëï;jão‡º=þ æ;ïF;m¯‡«oÙ-½¿ïD14ÙÚÿ`“»&Ý'*¤ý}4E“ôBÝúŒ…¯âiBû†ñFŒi$nõx¯Ê%ÕTDGöð3KbBd8,UÓjài5DƒËÔ/ñòhF€}î|æg]%)Mi$ ƒ¤û¶¤,Jað\×EaµC½ú³¬­à“?ã{ÆÑ^ª„B©ƒL¥´”ånù(¢lCÐ’Z«yI’o: Ødí=‡”°´Hh¾û4c°®ß£ Ù1*eJËVb‹[¥‰õ¥ 9*zšòp9•Bi°øýáÕÅåhðÑ|‹«ËzâhÐ'7ž]\_}ªïr\NU¦~h.¾Ùv”`KéS&P¡]äC Sî‹ÑÁäâi оïR. #»šÜ®›žl&¤øD+e:æNŠå¢ì¦Räe15+¼TI¹qíŽÍ:‘µÏ [ùâFÅC„h5× Y…’w3oMðH8¨¾./n6Ǩ ªâPq3kx©´Ý€‰S¢¡gIÁ !§*Ý|nQ±¥ïÒÞ¡­ CÈJÍiXÍ÷\ÁÅy+zÓŠ†¸÷,}…@ksÏ`ÈkàF5BÁÃÙ;3Œ~,a1IrÃá+b›‹ø6‚[ÅbnÏäãCëÆ¢Æß[œº—‡ÞSà"£ˆÿ|3 ;4—ÜÇ!|¥pPIDÅpeNñè8 ×qhžšÈÎÜ5æÜUf[tB¬Â\ç¶=…í86hMîîÓ«Kkýq¡uxèu»øð6ìyÓêXaÛuýî³bÀÁ\\e˜^L›–¾Ñ—áÀO}s¿?ö:,>=Eç»–d#->Wl˜…ܬ¶6ôc5A<ÀL´É6äÓ.ðõÌãæ¤n9']@>– †[ v­ ";}`ÎXÁ¼žoJ53M„+!SÃn`ž WW[h§ ù æi$Ÿæ­6ÉZkŸ§,cw÷l ²Âãn§I•ÌšÝGW–išHÇq1¥žß99òŽ»ÇÔ;i{¯œù¬V×kÓYäór dp@•[Ýzå‚Ù¡ö˜~iÊ÷lù·u‚ùÆÎâÖ%Û=¯{ˆ{ïuŽ9Ö`´óÇÎkŒ¥vendstream endobj 5898 0 obj<>/XObject<<>>>>>>endobj 5899 0 obj<>stream x•X]oÛ8}ϯ ‚v× l5qR7ÝE¦mRè¤ÙÖƒéƒ-Q6[‰ÔTïbÿûž{IÉ–ÛÙÝéK¼çž{îe?:gø}..fô'¯^Ïβ3|ÙÿãVâÙÍ¥8?óïÎ^âCÁÏñ!ݖ¨\y/Ýv,ÂZ‰BùÜé&X'Jü•f+¶Q"—F,•°Ë µQ…h½6+>q2ÿzôìq°Ñ“…ÅhqŸvŒD-sg…6B²ÝZ6™¸#õ(ë¦Rë¬]eòôLL¦Óìâ?£§ Ž,FÚ,NpΊSñ/:‚×È1Ò¥€Ûѧ_oß}yc̓rá>¸Åè‰6MƋуՅ8=Åñ¿<9‹A¸lpq2“âÏýb×÷nïæ×¿\~s}?¿ýp·8ÇW¯fĤX§B댸ûåýû¿ÿ;‚Ñ7a0.²ÙìeúSÖ¶]­¹Õ&('ÖÒU¦lM´5^H§Dãt-®¶@>(S €TÝZÝ´• t¢²›I¥T%’1?K֦ʶ‚¹Ù.Ø)…cKq¿EDÎìãVä•ô^ùL|jT®KKœ‹Èî±å»:}Ϙ®*ÂÈiÚt©–ÎÖÌO»üªòd@þH˜Ë·ç$¬µB92Àಠ*dq b…&ä~ëÚÜG¬?,¿þˆàÔ(² ¶ªœ³X)£œ û´‡ .—B6M…·—•Zœp@Ïn^ŠóËì2¶ídzE‹ÑÅ,ÍßÚÜ#zÔìFIpGdG=s™]]щ_¸O‹î„§ÖKuÊm¡„öhëÜÖd­¶  ?躱.Hv_k«H¨tÕ&Ñð9RŒòÛ²x€ ¹‚v”ôr=¨£U˜¦TD¢Ôd þ@ÛZá}ª@‡œu^%–În¼Â7hc›¶6á|ÐÍ^r“ï zûöl|§T z#!mÄâ`çJÁJ&€–[hb)Û*ŒÅÖ¶ÊGÞ™•ƺšhÓAx[«˜T¥#; R·s—w}ùÅÈZ-F§Ò­üâäøž¨ÇÑç‡ô€Ú ¤"6k¯©|F=‚ü–⪠äxtJV}óRJÁ²”×zµÖC؇Ñùöÿ]‹—àBo=eqcÒV‡šžBfì+R¶±x-Ý©XJÇ?.NXêv³é@Üæ(B™ÈfҢŰ g†'‚Ô`›ÐA(é·¬h¨a&*Å.aòpéj[´ÀhÜÇYDu³Ul þôæ À[¨,ÐRÛ’]êÛ’ø(ôÆ  ¬Ðt$ a5@¶Û¨š)ØÓp‹…ùAíéÛ†ÔˆjDеO-TË6Ì…çò4š9̧€PèAý™í#šZŒz@_Ï)ÊO+L ü¯~ü1fz: ä€õ¿Rë…×€±ƒ“F|m=TX`°ƒ@€Ý’¿ø&ÑÃKYŒ_È¥®t@¡Xt+ü¿P!„ã†'ãÆ6œ’ÿÿÂ餠ß~xóiþñöî]W{ÞÕ€ž¿}®«ÊCYsõ[ÒøDÝÔBÈ'>¢dŽG•2-H70WI@(ãÜšà¸5iÏl¤Q¦NÈ3êPˆ]e%¯@qƒŸ~ÏÏX†I«9¼§X”à0ùÀò…qš€Ûç@ŸŠüèòX`LoîâXàçÝÎÆó;›Š§IÛ£cÚ@(P$žì¶½½†þ ]\U-…LÚ¶´ w¡Ýz=‰xؘ8·YÛÒ@Û8,qza¯cVó:ÆÒ bÅÆX¿a¿[ùcÝ&;˜y„M¾©íƺ¢ë;°ŸúÙÓJIpCö-£•&ÚB8N¦¬Gw‚ 5/ôƒ.ZŒ©þÏpÊâHÑ¢šÚ´ë4£óa<ä J(@g÷Ob‰)H–a:ˆB—ØE1Í:™F¸dˆ]”¤Õm¹4¶®¬ýF¼K KÕßyþH0)ïvÆâ-zädŒ^ ld™¦É>"<—(¯®²+ÏUº®œ²î¿†!l{2LŽÂ"ãoÆnö÷­ýÎVíÆz¯SX;Fí$Œ{ *CAR(}ÁøçÇÃ4A‚C8®N˜˜UË—Ž÷Ž^™z1eìqŠ&LAšNpЈ1…$¶•ÐÜ®Œþ'=‰Ä‚‹ØE ²3–Ê¿½e¹˜$u ³6>@>É݆Ö<§Í¢E.|áÀnã¬Ç•&^øx¥K^¤WÖâ €¤{X* FBšÍq’Pà? Jã­'p¯ Ý4Nû/w¸»È|Ô@^ãÓ¾(³œBе)—hM!ÿ“(†]µA~J"©‰#–Ôn„t„ïÕžžC†‡U¦Ú Àq%H—[^<ã÷.q!žóâÄE¯0×€4tƒn¡žÁHêØ)zµ¿ƒQ¼Y uˆ;¬(ßÝò=úÚŽEZ¹§Ýÿ[°Óƒƒß‰òˆth(?q¤7E-Ì:«1—øe§ì¸|‚ã9TÜ!4¸KKë1Û·ËIÚo=cõìæ*™›ž]fÏ/ž‹Ù‹YvÆ×;¢Õä"ã;áîâDþ0yâË“qœaö¼Ìf"Ý^ûÿ) wŸŸÍ²‹)VNL¸ÙùŒ¾ºžýãè?²„â)endstream endobj 5900 0 obj<>/XObject<<>>>>>>endobj 5901 0 obj<>stream x½WïoÛ6ýž¿â ,˜ìÚŠe'nšaûЮ) E†ºè-Q¶YôH*Žÿû½£D9râtÖÆ!ñÇñîÝ»wôß'1ð‰i2åÿd}òvv2ŠFl¿ô’ήßP<¢Y†µÓ7xHÝ<’p2âQ4Žb:ͤ°•–ó0•U©J‚£`ÞëÍþ:9»>om Çç°~]É’ y/ ^F¹¡ÊÈ”,ã‹ìn# ©Ì½l„ki¥6´Í‹¢69mL†T*Û=%¤…¤¼LŠ*…ͼ¶ØøEÆê¼\Ft­4ɱÞr@ËüÞœ¶4¢a-„v¯óž³¶Gu輘DÓék¶>cowvÇ•J*ò; ºÈ ƒ³”¥ÔÂÊôåxR™ºÙziÔïßmùiÞs1á/‚ƒØbrá¨p»Hð4ïÑð7b4°§ƒÛ‰¢¨FÛ3ð NO¿ñúÅÿŽ~ñ3ôkW±vcϸ= =±å…ÐícI"MsfÓ€^¬•ëeæ¯rd™d̳sÞƒáhÈÄ#f ™*YaZ`ŸÅ¾;ÔÈZiŒËÒ8\;MêáŽèVQRHËLjY&§§àEi`¤Ì{ åZÝs©Ôõ&ŒQIÎôpácEÇ•0.‚ýªæDçç<¬Ñ‚´€…§8¾×£-^?÷«ÊY©-SUk™Øb7ïE4slUúŽ„§Ø| ú(D©·9"ôîìÝ«Wµ›>+mù‚蜒ˆ>K> Ê ¬êšÎ <@­jQ¨‘1Ps[)î nQ»Æp¦vªÒ\UNH>4Ú!½œXÍï+;ÀA!K6ˆºäƒH†â´+¯‰ ¥«U-MUp¢|V»ýcÊ÷‰4=*e(Óÿ\Γ#å<>^Î7u#`2ãe¼è{Ú 8¼‰ìùÞQ·4‘×R2ßòj-K+\@•´¢éè!J±M¡Sª–x_ŒçÍFËû\ãm«áÌï-¹t6ªü’é)Øê³¥i<ßçÆº º +ómÛŸª?Ï?\q{r0OíŽO¡?\qã£þ³;Ñ4®¸¶Ó{^ì^rºÇ'eY ¥œ‘n²¹ü»ùe•4¨úš˜iµv›X9§=k±¡í*#;B×\´,k X$RZ`@ûky_¡ð²¦ä8ã±¢:åO¥It¾À”ºÈÁ`v²aq@1Ñ$à†¡Ö@ßÞB!_Öê§*»©¬Û'Ês׿IUˆo`‡{u{;r®±Ãg×­¦;E¨Ç<¼á¾^&òó—$®îî%é”Û "Â’qÆ]ÁJÁO±c.ÍC/ýW„1^Ί! šãôËRôŒÒ ïvoß÷Vë«@îzc÷ì•ñ¿\±ž£û(êàÈÅc°¨…Ùs»U‹nÙŸ]_67ƒøò<º˜\Ðôrä/П¿~ü0œD#úý±ø²ETo½zøº¾iúÛß·~|\Œ¦ÑdŒ_/Юiüšm½Ÿüqòã†Üfendstream endobj 5902 0 obj<>/XObject<<>>>>>>endobj 5903 0 obj<>stream x¥WïoÛ6ýž¿â``€ØŠ$®›bVl) lm†:è-Q6WIÔ(ÊŽþû½#EÙj–¶ÀÒ¤HDÝñîÝ»wç.f4Å¿-–üço×ÓhЇÝfGWwSZE Z§4ŸÒòõ,Z._Ñ:qoMi©ýJµ¾¥;­ér´þûbJ“Ž“îx+Ì-½¦;†»öx0°ÉÕÝkb›”&8›ÌíUÃÅ2šM£ytM?¥RØÚÈÍp j«Æ4X 6#ïàºuÀæ×ìþy¿AFVuf+RÙ½¤´.b«tA¥ÑVÛ¦”$**¥¡Ì›Ì´­-‰¬Òë UTβ9ÞMÅæ"£L’tJ¦Î%^tnSmHŠx°˜s4¥00¶¸¤×|ÑC¥ŠéšÍL¦ðŽ|y™á®î»»w²FX™ ¤DÒQemå­Oþ¼P“ùÔ=6%²ŠÚa±Õô%W.FÕœ¬ k¡P(bÊm•5Â4­Ii¹¼V>Yv-@'ÈM+ xeì×é¨ìÞ18EOmù#ú˜ ½}j(×I i·N\vá`:{Èd¥cåϹ3<‘® E„âCQ÷:©Bu‡¹…tmËÚFô>ež*+s¤m¤HÚC?C%]`2¢Šu¾…®'è¨6«³ Š„ódÐÂ%i‡(¤q·á—^0'SxF:Që= pããìf5£‰í^U·ß&5tz·8f89A×ÍÔ0¿š©9Ú£ªÀ .0¸ÌȈ­Ê”m;| gÕ_ÎæÌ×#„%(ÇàU—hEÈõ’9×,{{”ÄÁât·Óâ.#èð5w@h¤U4u+‰ÛfAêîEüE줣ÅÕ]@Þæ×ÑjÅýÓj"s>–%¶ÌqOMæGôN"úÓOd%y[hW¡¼›Æl‹™vF×%ØhÁCˆAÀw»8÷…`ƒ}!+ yžL_Zô |·›Uõö›C:CùÀè`ƒ>{lÂÄ{ ‡p°@[õ€pI“Ë„ÍuºO¾¢ÂN$Rjâ׫5(×ÝÂà…9Óâv|¤:ËôÑs´g(å¿áeTºatªØR•a¦º¾ t¶$Ì N”6CYæ¸ã•ÄÍQ¯T½$»Èì~3ŠèªÑÍ\ˆÖDÍÛ_Œ6°¸®Ç RÛÆ '^Ïý`¼ˆ1—¤` †߳ë߸NõÈ ¸½(ð’ÅNyQt øÁK#ú50–IãSIè<þâëHüøøîŽ8ôD[m~Ë¥–œE/‰gñw¶½iíWZÏ ÷¬¬ßÖ<@7ëâ]µ+ÿluÝ,nh¹‚ÌÜæûéóûw“E4¥ßÎWsbèßž¼òŸRÂGŒÞnÇĘ·ËÛÍt-æøÜýXÎVìë÷õÅ_ÿoá~endstream endobj 5904 0 obj<>/XObject<<>>>>>>endobj 5905 0 obj<>stream xµWßoÛ6~Ï_qXQÔYmùWâ¦ö°vËÖ·ñ°-Q1[ITI)¶÷×ï;’’-ÙɲK'‘ÈãÝwß}wüv1¥ ¾§4_ðOœ_|X^L¢ ¶æÆ·º‰æ´Li6¡Åûi´X¼£eâVMhʯÓñý½*Tu•ûËå—‹ ¦x™ø—¹Nfg_`ëìù­nöÏÃþñí±å”Fpg4›w‰LU!-UI©Î2½UÅ}ÞW]P)â¯âoE‘¬Õ™´?°ŸÝèF³Y4Ÿ#Vï7}½jlœD±‹aåùU8pzdŠ^NM1P­)ïçé">/ÂË9u,=‰Ìˆ”µ)µ•¤S@@MäÈA/wCJU&IÕ­Õ$¢[el5t0˲•,bgöå6UA‚ed\i³'U¤Úä>q>]MÈ3N„**iJ#ñ‰CE…øsØë¢ª@j{ÉŽèNâeâ}u‚@þMè8%Ó"‘ÉXîd\W2!QW:•ŠE–µ4w^n7²p˜¦1f\Jdê/ì\ Ü U‘6¤*K¶^ûüŽñW³éAâMH•—ÚTþaCýÁ™¬.#ú°'Ð^Ôr÷ç§_éAÒˆ D/Þu] ¥à€XÍ&W¤ Ù?ìû“* @ŠHŠxsºAõ\CØHU*b3¯Î?pÍi£·òQš! #©ÐUTBë½ Óîg7ºÎ°@Rl$pk5´ÀP.Eaþst¶H†‡¾ïÛ¹èY0^Âê’Ž€“xW˜ð%R×2[©4Ò[f©tj8­>lÑ&aÊkÒk&8׌´Êˆ5*2fâØ(dÝÄ›} ή¸tþ­Ø7uÑ($ÓÏoôzØŠ#¨&b¼tTª­4€íNç’Üß”ÃT!|²¥ŒÁoJxmà´­Aá*¹ Yb8Ê¿mÙLºd08hd¬÷kïkGK=B|PQ®HÈÈÌå>ÖyΉËЂq„8à5³JîÊ úÔð‘mÃøù„X(ü²Õñí{âÇ)zæh¶`|ç‹h:¦Ð™ }pÎwN×iÞx¹Ôüa› ~ ú°kjƒÿ!ÐPo-íu͹syK÷'‚ ÿ¼ÊÀÚª,ã’B^X½:Ø´ìà Gm4$oÕÄõãwÛÝw(“‰»Øôºù’E?àYZgîøs܈NÔ§iX=X_Ÿ•Q/"ÃBÑÛrÞö±èúBq( kkJ‹ ?Fƒ«XàŽù$é`ÈÌ Q¨ úô¥¶ÜàÚ "—CZש”ŸïAi0 ±²¬ôMq·EŒU\F8w«‹7>Í׈~ó¢Ìt¼h=ð¼`õÙ2X&‚UŽÂùÇ®õ`z¢Ájà¼Tˆ¦wØv”× W±Ö²¬Ü‰¼Ì$ŠÒÏa‚PqÙž¾Õ˜]R…xV±¶:ÄEîp#•XaDkXˆÎŸ[žLšúõ9EE2´ X欜9—¦ëQsZ(T4¤pM= <}ªÞ@JF;D³(óéÀ°Ð!Y¸ñ÷ :wNÐŒ¬ö›ÚvñqGÇwÔ¼bù&rË““‡xÈåǾnŠsx;*ù9»ç\ªõ©1Sž¿¹œJ.. SwKaå…Õn<=åm+ƒ%—WÔGÀýê0ä4.ˆGÚÏÇŽy·t·pìM€Ý—|·yÁ…¡)÷Íê{ÈxW—§G{ë¼Ùêö𵨠ÆÓÂSÔr«²ŠR£sú8þøö-õD«sÀa,ð8^7÷Q?Ìè§P:N“Ü€âÜ ,¶›‰£ùà®.ù¾†êž-ÌêvJ¡vàã ãöóœø/©@å¼üÒ>¾½ Ìôæ*ºž_Ó⣑¿K³¶ŽæÑ„~Ö1º$îkÍì ÌüêÑ;χZ#ŸÃ­Qºž,¢ù ³h´˜¾çG¿,/~¿ø8Žòendstream endobj 5906 0 obj<>/XObject<<>>>>>>endobj 5907 0 obj<>stream x¥WmÚFþί]É'álàh”FjÔ¦ŠÔkR•*_ø²à¶1^×/ǹ¿¾Ï¬_ÀNѸÞ™yæ™gÆÿöF4Äψü)ÿ®v½óÞP ñeó‘lhðqH3áÓ|MÞ¦?ŽÄtú@óÀžÒ|åÄß6£>¼Áξˆ‹ûù?½ÁÇ1ðxM.Ì\ϯ̜ßUFÙVÑÊD™Š²”ÌšJÄb ®9th©j‹Cd®ç ßGœ³ ešÒ£ÿ–büób4_©@gg#@6ÞI6É( ½Œ…!½‹M’Næ¡:ëä2.éˆL¨„=á~R´NÌŽÊøë+Pýv"Ž ¿’íY@€óÈcd'&N´Ì})²­‰w øÂT=©D†È Hû´6 ©g¹‹Cõ–݃®7f§:ÚÐ]'ˆ*ßwï;±ÜQZD™|¦½Î¶$—© sÜËÕ7¹QÉ]é¿M¦£’ý@–EGs2 CàTwòsÁh fßßœ¨êí-,s‡Ä£¿¸?KHã†.#a+‡ÛÜÉwç~œ2%*”—î Éét@¤…c¢°à*UEóă¥›’I¨U‚dj/gyˆ×ð+Ÿßwt–ÕïÞ×ír™> §¬*{É«> 3±ÈßïÂÅFfS÷»øÑÀø]`>Cóz’hJˆ^«ó¬®Mš=÷„1Í’|•i´í±Dl%3 ÒY“à —MѺ”J‹ÝÒ„$Ÿ¤å‡sî¹¶™{’” b£!wúÚ ‚…³Ì3ŠÌžòˆÅ«â*·Zíùµì,«PW€›œ=5ýýª"5ñb¥¦ãzXŒËJ¹¤o6cÁù©¥y›TÑ^‘…½Î¬‚œ1ºšců>x‚Á€GEeÙ¤÷ßñø€|•zùÓ«ÃÝâÞžnAñ¦j‹;ØøB[}nÁ½¢UgúòðªC<äOm«›s©,›.äb;¬J¨­Ý7Äü¡Àt\Ë<Ìúô××O¿ÑÞäa@a’aÊœæsnlc">´ÖÚ©ŽU‰k…@' ÖË£NÀÀ˜ouj‡ï3x+£ÂRÀ³ýÙöÌÐØ¡ìÖÒvþª•Ùí¸:¡Ž™˜»Ÿ¯9IïŠ]‰GZB…Ác’Œôh}»¬¤­T<°K‡ÜÚ Ÿg0 Âqêãò|Óô}$,3û­Š¬:¹qáCÄN²áC*b ÷‚>aÙbyê“^Saò›û¬‰óf.#+],‚ä:HX»NÎ`Kæé«S½o]Üfª&å.>l#mnuúòtA°BÑÝ¥:и_n¢Lº×e‚uwÿÚ<[ÃÅÅeìÆ&´³ÆÎ›btd”§*ÀP·Ä»㕱ðʳêUb4‹‰?¡éôÖ{®£ë‹!ýbVùo ØÐLÄa¢$åi÷¥1pü©„G?×û,3®îâºØr2„{/S0šzCþê×yïÏÞÿyF½vendstream endobj 5908 0 obj<>/XObject<<>>>>/Annots 3054 0 R>>endobj 5909 0 obj<>stream x¥WaoÛ6ýî_qÀPTbŶl'-†ëÖýÖ­† Z¦-6”¨‰RmØß;R”-ÏíZ¬M„H:òŽïÞ½;ý1šÒÿ§”,ù'ÍG“x‚'|™òå—7£é]¼¤ù‹%®9%‹ø®»Ñô~tr›Ó"‰““w¯N6s;V{º¹ŸÓtB;x]¾À[ç ¤Ñ!“]=|ÝÜû3ŠÆe›øGa]DÊRcå6æçÏæØ%úÝ4d3Óè-‰Fma¢Š=UR‹Z}”¤òÒTµ%Qð+IbcnjI¦–صü(+*µj£eL™¬`†_krI©°Ò^SflwíVô»w‘LgI𔋖6’ ™JkEÕº-i§*[“|y©¶tÇv>V‘–{‘¶«+z×Ö™)(5[ /;YY’E­j…`½¹¥MKeežZlªñ|3T¢–ÛA80zÿÛÛ7×îäª&am“úÎD‹<Ù‚±ý¡d1½—©l Á1bàFeD}8´U•Lj<)|ÊB‘$Íz­ U¯×qÙz‹cRk6²m¾1ÚÒ®29Ùf“›mÃÇ3ß•"}{Ür"9üÞ‚¶²”ņ¼qæañ*Ú*›6¼ vÈjuå¸tsÿ‚8Nææx¶ä\&Ëx:«_;S¥L¨ž7ݱ­Ì“Úá/cÇÌ,µ 'Óá±0‡kެ‹E¨R“— èFiU·¸ïaÓ*‚swÖ!¬Óè»ï‡¾#²mQ‹'Ðh#ëƒDUutš9Ô’˜Þº õy ¯0Ã*E¥ð[eajJ5ž1S9öÅ€X3>ë,NÜöÓΘaPcg–ÄËå-›uœFÖÕ¦kT•&Ÿ-Î4¿€cÎb÷PV¡ðˆÒ¦ªP ÔqN˜pÐBDËDvusÑ×Y)òœ©+z÷ú%³;· ×Æ g¨C naëªIëÆ,^ ÒÊ4ûŒfñ-‡E§ê ƒ¼ºÄÑNô:jý C'}ªcËJ¢ÎQËç|\]]ŽÆUšÁ  Xz;£µ90—µ*dp}1™®×ë]S7•\¯5C ¬} ~‹PÊg‰îDšÉj¸WEÁžÍŽ2œÛ«W¡;ý·ÔÎ¥ÙKrÜ©«H¹~´²à8¨:;ÇòYé”Ô¹%‹ô°Ø—!š‹€œîFÏþb[f÷±èËÁê—<ûÛ{ ºã±[„"ñê3§·®w1nO¨(âÜ‹Ž_ÂR|Èg4˜›]h}ObÕ:@ÜyLÙ°V¢\»ª{eh$¸•ywÛqÙp±º0¹öØ)rŸMÚ ­l™ Ð?¸/±2–¸iæÒ,´5ÜI¹és,ù®I‹j¤¸½2Ÿ\«Dqà}.´î…–)1ûóA,@§[k'|0( côH™c îõàþšªJY-Õ3ŸŸ÷ýÇ>‡#gÁ=ñ+`¿õª0 ‡š_¹íÔMàuðydí×¹qP¦‚eØâp9Aúdªvß1>­WM†ù4ÓÇCò£\³ëåùrûº„õê„™ŠýÕŸHRhÝHýεD[¢µ„`<‡<®]ó÷Ŧˆè3Ì­¡.nà.éC‡9Ðïï­‚bEdÊZ™"¦WÊHäý©ÔIÄÏVÖBiÑ m#}º™;ù°CÑx:˜êQ / Ëzãå}˜™Ôå®ÑCüh\çóÀQ¼Ã¹Šºî¬®>/^åã~zs"uÿ¾A'’yYcî Ñ8Asö¸Ìα}ÈÏ­¾>\¹oDõþä>èh¸ó‘Ïœøµ§A'~™ßõøqÖhÀ)NwŠcBÑzL|{ÁWN÷Åpñx½õEùÿ†.. æpˆq˜Ð-_‰nbšÞu_5ãÙmŒO®~fZÍ0 yÄã¹›.=_â¸S m£{c^¢m7´þïÀ|ê¾<0oïO|æü8Iž €›Þ¢7& Z.îðŠžËãÀ8‰'ô“IñUƒ©— ™7;æñ¶ã[O´¯å“eœÌð%/ËÙ”·|ý0úyô‡¡-endstream endobj 5910 0 obj<>/XObject<<>>>>>>endobj 5911 0 obj<>stream x•W]oÛF|÷¯XøÅtaÑe+Ž‘HP«0P¤)" /Œy”.¦xìÝÑ2ûë;{ü°(ÉJ‚J@ÞíÎîÎÎ.ÿ=ÑF4žðßx}òiv2 ‡xØý˜%]N‡tŽi–Òõ„&ïGádòŽf‰?5¤Y¨u¡£âi9 ñ…©Öç³ï'CŒp âLXKŸ„™½CáTëùù-xÍ.§WÄ7RÀÕ 7®‚ÏzC*%K²ð–UTZ™P}!ø;{8ú&ƒ RŽ6*Ëp¹Œ¤Be·­‘&ƨ£(qÜÝÝÑnx|¡ mfD,"~¢y°ÖÖ‘‘±ÌÅp@Û!¾Þ¢©Ê$~°.QùÝée a€.§k”™¼;x#¼ääñOtùø¨råâj-DÇ,¥F¯)\ÓÆƒrüÐ Žoy÷ð³Uîr÷Ñ9£¥“÷ÆhsKguôg¤ßeìh%,åšD{ŒÎ8ö3F½Å_°Ž)_KSeU¾Ì*ÀMi#I¾È^È­ä/R†…z:õ,)ÕÆ°2ÖyBN­%ì;²eK™Øf0o¤°:'+åÚ’Ó´mŽ#¦Sª³Loî–6+™Ó—Ê­øx¡ŽïÃ{«h¯á[A :7]G$L? ™àä²o„ËåÁ¿«i±c‡ ,Õ5lHfêiÄv$ÀïJ““àü%}ÑèG°†ì ¹ ŠÓÉÏ_á£IÅò ±û„0rí(-Y$¸Ñ”ÈÔœJ:ô9ª{*œB £c™”/,‰ØÕú‚€ðbi¤µósÆs#SO5!eš2×uºXd`SRñ…½ÂîjçtÜên/§–N™‰J&§ «e®LBºL„ÇÁX±–´:®(à ÄŒü¥jÊÙKäRæÒ‡t,*úúíáϰy]1Çÿ†šm´yF—(dÝ7ÈJ,PIü ã\S^É<´VÌ1ú¾Á¸ßßñJäû…=x¥îÉãš_7'´EvdžáÕ‘)Ö×&íwkžögMí·õÉþÛ´û!úK°Z:ü46Ðuä‹À€­K*/…ÊCú¦ÜÊ—ú‚*]RÁãLÊ\,p”¯Õ-Ô Ï -n]Ûúm;ÜÒ…ïT\›DBX5¨&°%±ÐÏýÎÝbn4 3Т`·¾×[-j¢‰Ìjó ®þÞ«Ãù¹'÷åô=®Bð;ÅÆ4ˆnø¿I0ž„ÆFÄÇôµ,xêËǯ›>ÏÍâÂgMcvø …pXO‘á>4ëDÒ^»!Àƒo×V‰; ª³Ðøi Dá ÷ú˜íMKƒ¬v£Þ+ù‘¬üâÁ?XÁ¢òüÛx\³8û¥©!JÇa]P´‡d5d¥ËŽ-d¬RS*dêÞÄÑØÒÝcœÐ=„‰y‰<-0v™2ÖëI"67Ûˆ&Ĥ5‰rù1¼ËƱ4ð=Oe™È–w€‹ofç‰Ä}ƒÈO¾)­ãÆX—ʺ%ÈMœmsDëðz|Mø<'Þ Âô‡ŽË5ÒÕaÔ‡ïêOd%#L•ÿ-Íàý¼ßúÎã4_'á8ª;pEüè~vòÏÉÿ:½ºendstream endobj 5912 0 obj<>/XObject<<>>>>/Annots 3057 0 R>>endobj 5913 0 obj<>stream xWÑnÛ8|÷Wì(ª¶"Û‰“ö®.¸¦×·ÜÕÀ½h‰¶ÕH¢JRqÔ¯¿YŠ’mÙH"IÔrwvf–ù>S„Ÿ1Mgüçƒ(Œp‡?ÆüñïçÁøæ*Œh6~Ïœ&Ñ$œø«Œ¾ö¯ñtr^ï=½›ïtQõš.î#º §4_!ÍÞÃÙìšæ‰Û6¢y%rE+¥‘ÙjHK¡?F‹³†áÙüÛàâþ’ÆXº¢BŒ&S"¸«,ÞÓ¤ž¥Î”HdB«ªˆmª Âí\ÚJ†d7’J¡®¥¦,5–¶ªÊ°XdÙRÄOd5·Qp.ôÚnpÌÞ²&áS‹‡$Ф¿üüüi{*p.jZJŽúÆÀˆ²”H÷…‚¶”ƒükU‘,Ä2Cµ\Ù“¬·J'„¸U. Ò|“š]mø;©$—ˆjOAeÈl„Æ 3é Ï´ ¯ÿ}ùLkYH-,6/µz©)΄1®MÜšKNý8%ÒŠ”S¬ŒXKRhpÛQÊ nÒŒ”£Á›àáÓMÇѵK§ãiK«À3ã=1\+Ðz4™ñæÓY8fÒÞU«ÐJ ô|%bWÕŽH.×Ðe뢫b•ÚJ€¡åsj>Ê~¨A£‚¦a€ÈŒ¢µH CùëT.¯[²u)sQÛTe©´¥e/Ãý‘p7‹ÐÎE¬â"h"-šx ËÈS³¬›˜aÚfÈ Ó´ÕÌÀä ½®…ÛTÂÌBǬ8–¥ãë-µü&c‹ÐÂ’|)•J€«J­{§Ê1ä‹ÈËL6êí!°–ö±v³g= v4++‹F8éÛ «¹TÐA¹›¹Ì•®©TLIѲ¦o´2úÐî¹3¯ÑdN§°²$xVi)´iÄ›ÅÙï‡éôü /œ~c=ëÔÁ–ð¥'îLj>Ð"à¼W*ËÔ–³öX¤Œ¦d©OX¡®Žœ‘ó›I8ƒ¨Ðx×ä¾ý,k+…Ö¢>Ì2p9ð½Î}°#3¸Ù ½âöí|‘·žmôÇŽŸ·mLxj¼m<æ•cÁcÓ”Eàá³ÚÈi¸W~ æ?ᛤ/\¯=F&MT<µûè´í샻Y¶C:NKÜ$ÚŠúuŠÜÞÞRIÁ+ú"cª@ÂkÚmAyâi ÚÚãG{A—ï.¸úb±x‰¢w}M“¼Ïü‚Ç8o2ižf`¼Ó¤ÍÓ Ö™TÜôöÈ£axðÃëqÛìf¢ûýZ¸®Ì^Ìx¨zxwÇ2k‘ìdæá´.Ǿæü¡«Ó øG¦p<\íIõ ÆbU`è4;àH– ;äãÛÏñK;^_¯‰u‚‘q¨¦Ù ¹ìÅò!½ù[ÂCqÚÓYòۛ뽼°¸÷ð@`.ʾ¸:p8±¦U-£G—ÌéîˆzÜÖô~FfxŒ?"xVkù½J5æ(?@ynñù!5æšÔ9DÃŽÝlÒœA› B7ìp\^õB4tÚ=ÁiÇ?^6âÒ‘ŒmùÆ?' žä#ÎTRï‘°£×÷“ñì2¼š^Ñìú&¼nF5ŸZGSü;ó—ŠÝÙ=]-“¨Y=ºnÆMsvÓýñQ•×_E³p:ÁQÃl6™ò­OóÁ?ƒÿýtø¯endstream endobj 5914 0 obj<>/XObject<<>>>>/Annots 3060 0 R>>endobj 5915 0 obj<>stream x¥WÛnÛF}×W –‰ÑÍŠœ¦â$ $HZ+è‹aE.%¦$—á.-³Eÿ½gvIɤe§A“€¡È¹íœ3~ë i€¿COùŸŸtÞOø2äËïï;ÃS3oJ þŸxÃêWL7û¿ §r²üöjqÏ µšoèù|BÃ-B hz»ÀzÄß½Nési¶*}y¶øÚy>ÐÌW²ýÑÈñ+è^^^ÒºéWZ—FŠ<å²»> •Z.ïƒÓ嫨ώœx"þ”«"ËdÉ"<"‘åQj޽lø˜úô˜r}º>Ž×½éôÇp¥Ì–êC¹ówO²¡„2_%…ëX®ÖQ*ò²i¨K" ¾¯ª âß´Usù­ˆrIf+)ËÕmÈ€S§d­%U®{¬Éq´rã±JI¾HIø¾Ì ‰v û¼´š2“pbXûŠ•~JQRy;fê˜Ï=<¯ãr:á¹s9[v3‘'=ÒÑ_rÅ·áÛú#«ºØFšáç ×L#½¤Ö_¥oNõ½ÔÊ<¹P–µÖO;VFHXßmé}<-® !%Q,Œ¦›=‡ƒ>I’É; #Ý4õ W­P8Fkfiꀘ#öè52ÆöæR±éYŽír (,RßD*%½UEPª %*ˆÂÒŠ9cÿ]Gk‡îÿ‚T lrÖ~Ù‡0=žÜŸã•Èõl™« Ñ·)B->ž~¤h”ªÈ(µèܨ爛є g<õ†h¤ôz8…oh-´$?ZKÝdëL<[3W%E©zL;Y)Ö¾5u]×*4Ë¡d?+Çm_% s.ŽRI*³ôÙmeŠ6ãÙ†nþ¸~ïh†Vv‡æä‚&Z7‹ä«Ôèçö({Šî¢8&Q•±¹’6³ÌÏ` ½_IâaN<š«µ%’,–Îy¨âXíê€4‰Pøòé™uâò'éU•¯Ëš vF^k¬Ð—¼è)8Òæ tl*©3šôwÃ<щ‘8N¹ì~Y-ϸû½Bô=>Âå/Ë_§æüAƒÝ²JKúŸ&”­Ñg“¿‘Åæ¸šð<Žj ÛŒ²6mväVæ‘ἇ¹JÚ:>PAGÏÑÞG7Na¦mÄ5ê'\Wgmêíyôã1Ü`ËÔ·uFݪõÕCÅVcøX-ÅZÕó›û˜›^.ÈÚ·y^PŒÍ軨a\w™B£Acø2äJãîÿ÷‚ö¶ß¨]Jož=sÕöŽï#ÉÊ jÏ—g–n‡„´(Ã5HTr¬¹ºÄ×#Ô#w.-ݼk­®Ø4»Ÿß}¦ñpxÁé8¼®ÑƒºG2÷:ä„®°[ÖC&ã…F¥·è- Y3Å¿}§Db…ˆ"-í†Z[Yv[ù[‘ÿÜ4Õ%œ½%†z~ùòèXAMæÒyÊ3—«â «[¸T yÁ¤; ¸‘wØÆ4}YÌû3ìd_£¦Øãžæ`ˆ>Öµu‘çjƒ*–ÚY›Ó$ñ6§-j,ÆÚT¤®n§1>ø]´AS¿눭©à"Õ(ô[GXSmþ«úAªßI÷_8¯nIÑ•ûRÁÄq#–…ÏSo<Âw+Úåt4áGïß:ÿÝüeéendstream endobj 5916 0 obj<>/XObject<<>>>>/Annots 3063 0 R>>endobj 5917 0 obj<>stream xVMoÛ8¼ûW<XXlÅ–Ç šº›½ì¦‹^õd©+“.IÅÉaÿû))µƒ]¤I`˜?æÍ›æÇhN3üÎ)]ú?¹Íâžø¹ÿøòq”\\Äç”\`L[JçËø¢5t?:ãmºˆo?¬6 »š ÞÎh§´.)™Ñ/—ç´.±3ZË蟓õ÷ÑŒ¦x½.¢ßÂðôvAsŒËðxš¤ýªè[ÅŠ\U[Ú²«tAø&EÓpA¥Ñ[º{ÆSE铘 »Ö(zMË~¦Vê¦ÑûZmÈñ“#ë ¾_z ÇP§I§)€Ñõõ5Yº"~Û]ñÒê¡uåêA>`ye'} r?ýèɸʲ¶|£iŸ¥Ë¥iŠqwæÿz_+Éðï=F’Z9Q+Kù³c_Œp¨])í(g*Xê4K_×·Ó•g@[p öýa<#;Ö•ëfVõ¦"Û£7Â1ÉJ!;ÀO|AÃIþ˜Öb¥Ó¤s%Ô¦ÞÔJ4á²ü£e`›Ò”Ús;‹Æ`tºOˆÆØ«ñ ,¶Rìxü,çÌÀ{îi~HΞdŠaþ6Õ)T.B-Š„s¼Ý9TÔeÉTQ€•L¨.Á³­ 8È"mÈÖÄ35,»fùÖ ýB'D  „tÙ·¢ÄZ0I`0uæy($ð½3Úi©›ü‹q×y0ØW«éü5S %=›÷Ò›¥Yò òûS;žP¥÷üÈÆK Z;ð L׉Ñûè¥Qú¡Nlßj*h_»*H¥àR´£NúˆàñÈ›Pºîáà‡G ²NT U4lbºÕ戫ޓoó0è+û8(m¼UÞ0eXŽ ê Ç1ùŸ¢Áe‘PY7|U¾R ¦ P‚þÖðçBþ mlµu0›ôòñùD°®oçË9D·Ø—Þ½·®¨Õõ» 55´˜@gŠÞouÑ6|}tÄWU{Vn‚gn¼Q.©7NO„<î{àg÷4ö[ï´­]˜œ_þlž%$€ŠžÇ­ðÑ|Ák¿6‡ºL…”Y1ªµw¹êçù†ògºÿöé£×;ŠÝ€Ô¼…¦È¢Aâ(hÂÎÞ`Ô9¶êC%¤´?"ç`©}";† á#)ÙÚ:§¨r¸ 1C§’…4ˆ(‡#Åø4×=˜®òŸÊ²± ¡c^¢cqNP\m™ƒÂ_]¯¸ £»›;JWi¨áåòîÊ( KÏh1_yÔž¾iŠ‹ù-Û-”Ê´ò[¡AÝÌéy§àtÏ\ÎâîP$Œ KÛ~åÙl§ þ+ÀþËäÌov³}ý rgm‡endstream endobj 5918 0 obj<>/XObject<<>>>>/Annots 3073 0 R>>endobj 5919 0 obj<>stream xµWmoÛ6þž_qÌEmÅ–mÙÐmÚdÁÒ!u¼õK€‚–i›­$jÛûõ{Ž”,yi³b[ Á™¼×çî9ú“õñ3 aÄ¿qzÒúø„ÿ øÏìêd}ŠÆQ0¤”ð/ª„„ÑÈŸç9ÏÆ˜Rt Zg-1¥©spÐk‰) £#EÌ0t§ÎƒØaKdÅ0Qt8lË8 œGsÚ’q:À~sê†}ç4šŠœÀN[bJçã ly½þÔéMÆX¯%r8\ÝæÐ)ŽÏ«’P/¸²6"J7‚ÃæÌëáC†êœS;õFýðŒ#ŸÅh2Á%/ñé›y y¿YÓÙå9 øÞ|…&‰¦a0 i¾tíѧyÜNèîãõ‰lI³óÏ-®{œ pyÅýÕ Q„q7åº8Öh¼¦•Joð¡¼ì܇фŽï?öÀ·{±ó[¡²5Í\dâ±êÿêêÖÈX§¹JØc"ÌZÂïJ%ò9ó»’™4"¡\'*Þ?cv7"[—9Å:{™U:{μ.^¾¤8Eñ¬Õ{—•)Ê÷¯“9»¬›ºN1U½pÄM7#U «Û›å’t.3*tibI……³Âªñ°ä‰¶–ûEfÊè,EeºÎVÚ¤., ]Z4R,2ZHZéjÂ~c:Ûí60½ÜèÏ2¶6믷D' ùýéNëYY¨l‰Xº‘7Òˆ­z´”2ѹŠ{Ú|¼È¬,£Õè î}éÒ2e†ÿˆZeVš•@æ¸ñ¡™½Q ÂqÆIëŒÞ£ F=ˆ£@nTVîh«ì†Öq\…JMxI¡i«Íg@ÅFzeé#Â×Û±íßUQ¢È裀m; y…1Z©!SEMA š}F2˜N̋Ҡ’ìÉ¢b+$zËVRØÒH_­L[RižH.cnhaô™ýÄÎã9WÂ,ü% ‘^Ql`‹µŒš«³Ë§È¯‰´EuôÚ±§­yÎ8ú¼Ÿ¶b¯ªRwpS™¾Æžïv•æš¡E´€ž.(ÕKÙ%¹“qiÑGDä@¿ íF¢áäNpƒ˜‡‡of"•\§ÅåÂIeæjWÀÉQãà0õY÷‰·-À9J<†–b«ÖÔ3gªVwËeFïßÒÝÏ7×oꟸšˆé7ߌ=›¶ÌÏv¬Ñ/E®Ý,aø¹ o ÷¢+Ï×wDã:BíéÚyKž×ß~K%Îó'SøU; À0ŽÅ ™Êq˜kϨmX ?Ÿm´\‚=xùQZ–™«V®uµ0ÂìA4Øíué:×jLÜGú¾†Ì 3îð`©f*g³²Óu%®`rSwvùdü§ò6 à¢Êëc|þ©Ø~Q0}µÎu©\åÎ2` 7Y¼=ê†âqºÍÀ4*5"",—aU&‰çzoïö—«OÏ»gA¸6þêô0î»Ý)JÑÐBü#ÔŸ«¹c†Šð°ž—eŒ1²[í_ˆ½¦å3¤b*6à‡zøZâ¹à£:ªBwyÃÔâ2Iºníº•{4|^ñ¨¬µÖ s«)ÑÛ{#ÁÝî©Úå'бTæH›{Ìîs›ù¦:,¿š»}Îߘ3$°ýûN. +ï;uYO»Ü&Âò+çÜÂhø–ù«ÓÓû÷/ê/ûÇS£ÌpçèF,â|/­x+¬¸ï üq³ªzn óô#,4[,ü"sí¾•oИ`<·›ÉŠè*ÀcÃnøa¦µÊ0NÊŠ Ïì+@ `AÜÇ+¡’êR§ÁâÀWÝI¿z‡üí Ô¸/}¡ÿÎ…'ûn~òáä/‘‡b/endstream endobj 5920 0 obj<>/XObject<<>>>>>>endobj 5921 0 obj<>stream x…UÁnÛ8½û+¹ÔAcÅ‘Û=ä°M“¢Àº®‹] ¾ÐÒØfC‘*IÅq¿~ßPrj£M‹¤ gÞ¼÷fø­wECü\Ñh"¿EÕ{»è ³!>>ÿñº¼ÓÕkÄNÞà¡LÿÇCÑ_l90Å£µ6¨P–VLÆ©’KÒ–”Ý“ó%ûóÅ×Þåýºgã6× ŸÉcÙM³}ô\¸ªÖFÛ å7Ló6i{ò†A>Îf39øÁ¢`@ÙÝ–=`lgH‡6Ç9ËT©¦ ™ Erë„P*E]1­öT—oí¼ªkö-¶H×uVJ¾Õ^0 ip• ŒÂ³Š)©àüŠ*››.¶T8•¶!\;cÜ'ÚÖ†4‰ßAžg£^Ê~p/xÙõVoî‘4›¿ZžêŠ }éhÙ7:Ä–}eÌÍbþùny~! nΞ ’³ `¨Ðf]ÔI®oË”îæÌº³¶Ì±ìƒ|”M&S)šÈØichÖ½ŠBj«o%YÆàí:W‘ÒɃIeU¹Æþ¤IÖRó’_Æô>U7T;£‹¤Ç)àƒGàÐé!Vä…+W6Ð ÚFGQ4LŸo/o_¿&ÐÖJ]PòÈëÙ§ÆÂÐf/ßÖ-¢vVÙ’<ØÝ¦ 9Å}Í’“QÂ>D®¤\íÝ£.Å®ac<ý¡Ýkú[ÙM£00Ò#ÛT²¥èWƒ±á¨¥’` ÝsƒA•ÎŽв¯3Îè;{'ͦ‘-uÁayžÑ—ßK0i³0/C‘’nõ•‹Š0¤ºª WèÅ@2?EöV‰6ßüsìNÇmâ± X*‡«À„˜Ë*Ln'eŠ‘AíZlAI½þÙªiSq,«Owÿ}„)Q /?Û´- ñŠ8ç÷,DœV+×D¨œªx‚ß0&nhï1Ås #ªâáÐ×))Ý*ñ\Á‰-Ë+踧µó?¶›€„ÅžöÔ±§61 ,9Ĥ¥ü¼ÆLg±ð3NéÎ6•Œ¾øþeåù(*I_lšƒÈ²°e)Š[\LíE••t/¶E?b¬pΊñóƒ°ƒnɃ[m9dôÖQg…£ª'lãÊÓGÿó®ËYw·åÃqv=º¦1n—t+}ú÷ÃûÁ(Ò;W ]L©ô+9‡ØÁTîÅtåô9²y/g%òz8ÉF9îMMò©|º[ôþéý£PT¯endstream endobj 5922 0 obj<>/XObject<<>>>>/Annots 3127 0 R>>endobj 5923 0 obj<>stream x½Y]ÓF}ß_1BªDU%xüû©*ËG‘ ¥lZ^x1‰wãâØ©ãÐî¿ï¹÷Žgn(ên¡‰Z-{8¹ŸsgÎLøãšÿY“äôÿj{Í#ü ý°ôãÍó‹$ŸG&Ïòyb¶¦(ñ‡€Ö\],bâÒ”9åóÔ!"5Þ›¤óL±bšÄΔ1Ó€ajóùÂäU˜s«Y…Áæ Ê8Ø* ¶XPž•¤âH’²é¼09#NJa˜Æ–’ ¬Â`³â˜Uliç±²•°QÁaËl^šœEU†R¹'5›–äÖ³ì6+eåJ*F» †q6Ï)†…[Ö˜Ö"cÄmP¦èüVa°Y‚š«0ز8òÌ“–!8MÚógPT·=‰§ œ¦–ja/œ®Â`óœÒ ¬Â[G ¬Z`5‹üPŒ·Å/È0wÃÂÃ/ˆÃ*Œ°<üŠU,6Wê<±­Â”TDqb5ÓšVz˜Ê(eÜ d© ‚Ú¹õ¤Æ’ÜzVjå€D›P9#ò+dìÆÅZ*†Q í´Ï¹RFDÊ‘MlÊ•zVü¢|š+~y¿i!…ÚˆÆYP 2ùs“2 d.éâ@+MÊ€8›;V$ç“fRŠ|’A0tœMè|2DDuîEDÁÐq6)q–RcäSØ#Vò‰¥’ƒàÖq6±T¥'ÅgIȇA0tœE^è€'Å͆ ‚¡ãlÑ‚x’ “RµN€7œ8‹$#HÑœŠU¬Â²S ÅÒN™0íÚÜÁVR*Ô¢$ BJ޳–šH‘RÊn½©¸å¼X.K+%Ü:ιñ¤Æä–d7˜ŠÛ ÂpË ¸uIZäIá–Ï€ÀŠÛIÀ1¶™I‘_ã ç5¢:ƒ Y;)ß›LÛ* –§3°|J%NgÑ´× ©¤Ä"C5pë%Mc°Ø.Hгl;Á³Œ‚8#…)_ºSVLä• öYì5MAŠI‡T Å?ùÂÄ•&f$1†)ŽÜB³ SFÔí`Ë=мd ÊÈk€‚PÊôˆSN£øˆÔ˜BÒ»•|èÃmNu2 R¤J8f I EYѯ|™8rxõ¤ÆpË™(Va°%·ÏÛJç'Ù‘Õõ²ãVb“rX…)lB³àYq<‰:ˆŒ½(Q' S,–Ô³bê%‹?ê%K„ˆN%ž•”nN‚¨ÁÜ|ëmA‡Šn>õ×:=Ã8‚ór¦ òAv…"5&¶ü„ ,ΆXÙr-Öé¤3õB©1L“Œô¬˜NjÈW!ë¥RD_0L--b¦œ¨YÇ“ZŠc/¥ÎñÄŠ£À*ì{VOz‰¢Å^/)Ç Ãƒ’iVa°yF{[qìôTÖÊË©‚0ä;¡×rvÐùJ7ž–8ÁÉ"ˆY…)(3Šå³ÙÉ-]/†[C¤+Ží&ÝC ¥ñÂF%9(UjŽí&aÃ`ãÉ5‰ž v ~¢xŽí&åJ©Ä \ÂihŽí¼l‘ ]bQ˜8lÜĨ‡¡§^²èÇ€9<¤ïB=¯Ç‘B›Ú ÍÍf4›ºZ׃¹nZI‹C†\Ñÿü²ßîš–ÂWf}ÛUÛfe¶ýúÐÖÇ5üïUÿº§ ·ýa8O¼«±QJý€À'.NºŠ€}gúksùÝw¦þk¬»=þ‚-,æ};ƒžF Ãó!ËwÝgfEJCùøÐ´kê7íóÔ§b ÚÛ¦[÷îñèôÓ’Zóù}`®‡~kžÔë¶ßÁìj<¬›þËZéÊ‘Ívÿrb.g‰B•ÌÆ~vùˆºûªÚíܲ†Ü_ña¿Ã ݱ}Ÿº-ô©ãü†SªzßÖæå™F¸ÛU7žº¬×}Óõpê0WãpX‡áô*¦qÕVûýY"½è6õÐ`V§>¯i—ýü±ÚÚ´6çšz‹Ã¦û“ÏÅ‚Öû]µ:Ëêõv×VãYbAÿºu5¬ÍÒÅ9ò~¨†[óîáÕòå»o¿ì¿÷1IÍEœó¬%…{³å\³sµ­†Ñœé@»úý~ö²ênÕM¨íí¶v›f¿=Vð§­êßD~톾¥»ÞÝK/WSwŸMR¹ÏÎð>®ã|=ö·\§ãqÄÂü„<.èbò.œ’Oí'õuÃwïÚ¦:ý1ŠGÀºYašWõ¸é×§V¢ÇX²3…¢—¤•_GWòûÝKÿ¹·Œ[å”×ìþ‹œó‹èE·;ŒœCé×]5à”½ŸèÓ%Ö½«î{å• c¿ÁÁ7M}˜2yЛë›Úïu3Ô¸Ì}<µ˜þèR’ûøã¶_}8õؽ©~qùbO0,ÀW]‡¾jô–·»z[í¸Ô°ôo7Õhl 3 ÿý—íŠ{kŸKÃìWx78Öe¿»¥—ž/îÄñžÔmÍ__œ+àë·³mÝô²v xêYæg³Ž†éAÓ=˜Ò¸»ÕŸÑÕ›"þ¸ûšèÅ_mêÕ‡3ÅÃi}¦HÕpÅ?W´u}]ÚsE;犡_½hîš'ß}zÍûäÛ§GÏü7 üÍõŒþ2Îù*ø¹of3ükB‹žçqAÛåéòâ—‹¿æž+Øendstream endobj 5924 0 obj<>/XObject<<>>>>/Annots 3173 0 R>>endobj 5925 0 obj<>stream xÅZ]oÛV}÷¯X¬ÛF*¿)í[š8A€ÉÖj‹òBQ´ÅFµ$Gÿ~Ï̼C¯Ñ8qì …áÓÃsgîÌÜ™KÖÿ=ñÉÃ?>… ÿ›oO¼©‡ÿÂ?|þñÛëß›M=JfsüÜ’EÓ¸Cº<±ìÌŸF–UmšvÚ³‚Të0kãihYÕ&±jãdšR"H´C;ǬjãPµ¡h‰Ö`hÓpšPâXÕFØ¿ì×畩ϳvÆZǪ6ècò~©ÖaÞ¯Çûu¬jý>VÉtN‰ Õ:ÌÚp:³¬j½>V>k‰6v˜µ3Ö:V´1"(ûM"ìH‘h ÞRàùcVµÈºh}ŽF,H´Ãn£r «Ú¤•¯bAº_‡¡Eͤ†MŒã.TÞœ¥‚Dj0¤™cUi¤æ3^V+ d¡Ç»H=qØÅÉX*H÷ê0ï5–5l’²KNk0Ø¹ÄØ±#³£›åÓ]PMðJ°³Ý`Ì ç _I´ƒ¼#·²ÁƒWŽÕÜ"R¡ø(HV6+Dz²c f»3®ÇÊÊѼK=žH‘‹F„NÒŸÝ1+©d[XKÎH‘Jf§ø˜;V¥I_çl=$R9¥Š! Bœ>à åè[Ö`°©?f +ÝÕ¬l0³\è–u˜OîØ®Åœ?®u§ÕíF]ú|n®‘ Ý®Ã0‹ÒFk0ØDÌ:Ö`°iÌÛu¬Á`ç1r`Õ©°?ô“‚4}CŠ C, Ë]]È©P$ZƒÕeT<+,\î1"ås_r¬:…iä– ÒH9ÌNIk0›uϪY‡Á¦·´ƒGì”[Ùà!¹‹é‡X “³Ëˆ8%€­ˆe}Ÿ—u$wݰ¿x!r§Hü5Ò(€Ô±¦°¿Ä¥ö¸/¶Ùþ‡Å_fy“E|8'«LpóŒðÆ·X½#ÆŒFVåñ‰°àtWܰÁ'²¶-¶Ë¢.wOdîcö¤¶ªCûDk×uuÓ<±UYy[!’OR‘½9óIíáÈ=•ɺxš­]oªe¶yļMôÄ„º^²Ð~E|ê²å¦hÆè®Î…™ê…]ë âÏ·.}¾³÷{S\6ôê°ËÛ²Ú‰9|ðêØô2k3î¡ µývXéíò/”ò=üz@Gµ†Ø°ñãóñx€Ý‹,¯«†®ªšþxþëïçjìüS^쇠KfÝo7Þ´E¡õ|]Æ&<±ù›™LÆ/(¯TFc_Î矲íþñ«ùEµûXÔm¹»¦L«5«ëìÈ%”Q¾ÎjúñÇÏçôAêEµÙà|ˆ õõa[ìÚ†Ð>2ZgÍú‘¿«ÊÒ S»zÖ5›s§YNU éÏ:Ûï»g\ÝÉoŸ/¾®,ôþóþ Ê"ˆ¸ºrø].~¥?d2ýå9gìÛÇi‚w–yÚ7¶—UÞ´˜Æ×ôªÈÚC­}Ö…ê¢Z6­úǾ½?£.ü+õâýÙivh+˜=}ÿÃ8yw<òŒN½î¹/N üýÝön³þ÷1|³á÷1;ßך`ï6©ÿ2WîêŸ~«OižèIÒ{¼aù8­x¹C¿x¾ú˜íòbE‹j_æ·.)o÷:à¨BïßTÙê^Mí.'ÿîPŒÎë‹ç•»ÇÅaÓ–“®[¼ËòÙõ£_Ù.÷E^^Å|ù £EÍßc¾ßµç.1h}üêÜ71‘ä墨Võ‘.²öÍ£nܳ.²úaÑåMQìéuV/ñu#²ª¹«êM•ÞÞ슺Y—÷øpW€î]¹E2xü”ØŽ®íÎQùíÖÐÖ^áëÆøáãóÆj…Ã.÷.Ÿv¢ùé'ºlÚ¯+š®ÌõV:”¹ûŠÄoasšhZ¬Ë†¯‹{¾K­Š&¯Ë%Þ€.ÿ|óúŸ 5‡ý¾ª[ª®ÄÃ);ôó+|?‹ðŤ<âÅ䞃˳OïêbSnËÞè´78«ü(>ÓÉYâÕñ·!Áö‡]uƒ/ÝT8A7e»Ö` Á5ü–†ç9X› .Néuù±ÀóS¾®Ê¼xFÇê@ͺ:lVth ¡øÙ¦¥¦å÷Jê–íîèî?Nmš 1€l¡ òŠ—®©96m±íc àr”mÊe-ûïVÇ]¶-sêšòT"ˆíl6fcx×â â»d¶wá–ö-ù[ï°ÚîKìq }]åEÓè’xe>J2$ªÜÎFyÌy<4´­‰uwçjtiôQ¼Ÿ4ØêÑnqƒæD\UÔ8|MÜ”¨†®*š)=Ww°èʬiŸÑ6ûP $u!áçȶ„¡¡µ|:®áþv&ný’5݈ûÿ3vvÚ;0¥7-;(éÉš/¼v¦N±%y À´ä ûÀö['ãÚí?‚þ†%Ä_±à+r0å„ÿÞË*—w‰;»?鞤üuuvw­Çü?Tý:?é`åùâäß'ÿȪ%Uendstream endobj 5926 0 obj<>/XObject<<>>>>>>endobj 5927 0 obj<>stream x•WkoÛFüî_±p H†%êiY ò¥Mœ4@ƒ´‰Š¦€ãDž¤‹HžrGFšþ÷Î.eÕM`CŽ÷˜›]~>PMø?LÎ~žõƒ>ë·¢Þ«i0¤Ùs'Ó)Í"yÞ§YØMƒA0 ÷yšštEþ|óúröé¬÷jLLà%Ýá8cQ{fi‘›8"…ù‹=%6ÊcÝ!—§²rÏ{dkMÅ€&{´»ó›û¶Én3cÓgÕÔi0ªÎ£~Dí ò;³"YNú^%ÛX¦¹“É /x³, 2E/®®°*Ó©ÇARQt\xuÕÜò»°aõwœ­§Ði•i„K?"«¼çÝΩm#›·+ÂJn›Óïï˜%…6Ùšø'óK¢2LH3eR Šc²Ka)´‘æ½À/‹'j§ZG © &¸ÔC@ÐÉҤƯbÁš¨ä²·9ñ^¼SLã@Ð"d¨4"@ÝÉhg²µ`qÚgÀÕ€ƒmm]9•Å¥dÞN²¨{H¯u–UÊtfµÎh­U¤œè›„èýMJÖñ´PM˜-†™¡NÉŒ!¾——¡b×:8‚uó¨ö! ÐVs.rŸ#û*2`ˤÐKdœ3ë$™êÈø<\“*/Ò§S™Ô˽ëÅfÑc ½A0íÝO'w“q\ç÷ÝUšË“"oŒÄÚÅ*ªøpí¤g&ÓI±ò`UÓ3ꔜ!ôÐh˜QŒ8å)Q{ú¢Üžð]˜¨pmR¹È3aO-ìý°„dû­Ž€â¬ å4¥6#fàLù#»µÆ§¸“>jŽ î Œê¨#ËC•ŠoÉTÄ‚ÈæY@¯¬«¬æ¼‰©¤®¦Ö6Ï<]< >Y“ÎÛçóyz>¿lq°ŸdÒ›Lß•ñ˜Ð)®3Xÿö­On;N‡ñƒCèDV]WF+™5¢ÎíS•˜°Ìó¦ÔÁCUE„ñcÓ€ó neŒEö’P¬zǯñ”maá”30N1-ö<Önë4>¡…Ü+QHòÀÙP›2“è€>˜4dŸizZ!L¸Pß!ö‚ÈE š.Mh« ¶‚ê»ÉÑ‚½i¡3b‘BH6ŽíNDì3½ íCgE3æ‚™ÚÞßþôòímpûqöˆ²Âwůú"ã3ì™×ÕsʾÚR•d $|$؇ã/·hÙ.ˆ­Ýx°½¾Ê”'ÓÁéÏ9‘ZÉ&Y6µ_”»»Dm4ßeÞn•5«5¿l`ÛÕÕpŒuÇE²ßAbÆ‹ž„¹©Uõ$Ò ˆ‰Û$¡NÔ ¸Ó¦‰¸`1­‰ƒð& : ó{˜f‚ÈñšÁ>$ôÂŒñ¬4¤ZmÓòíbØ×£kšÜ\‚Š_bº£ O/m˜'h¤ëà+t«¹Ý›¢Áùןëþ$ ñîCŒú¼ôvvöûÙ¿E»endstream endobj 5928 0 obj<>/XObject<<>>>>/Annots 3176 0 R>>endobj 5929 0 obj<>stream x­X]oÛ6}ϯ¸H;ÄAlù+qÒ{貦ËÃЭñP PÐms‘D•¤âdÃþûÎ%)Ųn†A,“÷ãÜsϽʗ£1ðoLÓÿO‹£Q2Âþ1æßÏ“Kº¸¼LFTÐù(™Æ9Ým},h6I®¶¾û~¾eÌ[4+ÞŒè &æK¸½'³Ù%Í3ïqDó´÷šìF­h`êÅ3É'QT¹LÔéü÷£ Æ8’áÈ*MiðaBƒåÏ·×4HÛƒé¿<øycD•ÀÈí°¶f˜ëTäÃ\-†ìvˆ¨†jv5䪬Ÿ™´kadÖºÕÍoÁ®¦Aû$±š oΉ£ç´“iL»7_˘„®œÒ%9™ç–Þ__“Ó´’¥4ÂIª´Uüõ@•™¬$~”ŽRIºïûSÚ¬Uº&eÉÈ/µâØ–ÚP¡­#aÒµr2uµ‘”;±TjGʉœtÙ$8apŸ®f}ZÔŽ¬SyN‚VZg¤2)HXR0—çzcƒ÷J¬`ritA™@#Ì3‡¾1ZH·‘²¤ÊèTZ+íýiBpÜÀFQ©\K…x¦R"jÑ &SË¥4œl„ÇV2UK…ƒª´NŠŒô2˜Ä‹“sÎâv‰”ézáúpSÚ:w>ÄB”5’Ž¢g]¿B¢ÌEù€àD&4…*¥¿šjc€"Y‰p–1"›Ðoº¦B­Ö Õ”®eúÐÉ‚¡ñº­…nèÝ}º}OŸÔC xû}Ó-=_E‘e¾úˆ[•(k!˜ >ááÍ£nV3N}z•Œ“súÕªr²+tVç’#è²ðÇpá#(¾œEŠö@œý+=*Er5H…ú¦¢b©?dÃyëGÔ‹©Ì°L¸¦>’-fì’ %ßbUL°™;]˜þl;d|f!~VEQî÷AíÕ‚óìõ8öÚ±ƽÄß…ù|üU-º ;Çza€ÝX9«(Do[|Jœ~”$*Œ ©ÆJü Z¿˜à¾ÅS#µ›8nœ‡·2,Ûݲ4Uƒ ¢ßa@¹„n1tq¿ÖíJ ¼´Al0ý¬.¤S¬¥äYƳ.«QFÜ ˆ!ë“§‰W‹Œ9cÑP [J¥qG ¤†Ñ‚ò#”îQš¾ƒ¾öv:¼Xóì-€Ç#_((è‰Sˆ=Gì(܆ž¥À0å!¶Õk<ê}gfþøvRu™# ¶adX<ïKMšŸÅ×4K­s8¬­¢<Ñ3Hy;¥©6›hëò¨óG^°ÀDy ßXÈkÏ8¾ n–.¬œYàJÛÖh°átuÕåÆ$º©[½hÐ ´½~1›C¥x†· ë‹Æ½! Bõ`D’qtœËW©>£k¿Òø²ƒë³³-'ݨ·˜ÿBj8Ñï^Œp‚€A=1|ý’’¡ šì©Ù§º$ÅÞÝÕ‘ŽŒ4ÛvŠÛÿ°ró‰½uûio;>p,.ÛOOÿiÝfƒÿ׺µ„8¸lŒÂ¬õb¸Ï1tË21‹n¹zdS£*¬‘šDgL´kºØåëOâA2£v-µ£ÃXæ>=HY±Š`õÌø*JÖl9Âaƒ‡€[~ºr Þ|£…¥ëÓÞDÄ+Ón¬,áyÛd«³³½“è, a3Nè-4&Ä ZíKçcjìØAš·Fûx u²aß rÌHl(¹Þª¨pØxáW†¥P¹W_È,k+ 4U¹p¸€²¾¥6Âèwô¸‘èE.‹N,PE^:hNñP,wñÛÅþÚi—³Ï1óûÞýéÞMéÖxŸbe² •”¾á»È)ç8¤F¯‚aþ"ÀÔMa²>ÉdëðvÚ.—œf³]Æ×lx³ôÀNR¯ùyŸŽQWÈÆqÈ‘)ê·É”‡“ü\Dæß÷N¢4`\Å%m2:O.¦4ß.®Ì;Ò`Š?4ü ÓºÀ$h'!Všpzpüø×œiÔ[?:Ú¡û²û]ŒfÉt‚Wnìá³é˜áz7?úåèorJ¦endstream endobj 5930 0 obj<>/XObject<<>>>>>>endobj 5931 0 obj<>stream x¥XoÛFýߟb •hK²'‡úGa µsµî‚VäJÚ˜ÜewÉÈê§¿7³¤d:r‘»C‹"—»3ï½y3ëßFtŠÿF4™òÿiqôóìè49ÅÃÝ?~E'7ïht–œÑl‰ÕÓ‹ódJ³LÖœÒ,íO.’1ý\›<3vE¿Õ‹-]?UÚãl ÚfÚÓgc3· ôîüänv<ûrtrsF#|Î[ÇgÉÅöìïvQôðùöÒí>T¹¸óíÈò®^­ó-S˜\y^^­5•Þ¥: ˆ 3Ú˜jMÿ°æ)¡;ç •çÛm]yÎ1!’Ñ˜ÃØ([ñø<«SMŠ®>~Ćª¢TYZhÊʰ¥±ÍA’5~i_zºqžpyjìöUûˆ‡[J"ƒ}|Yí5e:¤Þ,tÖ D-ÜWMó¾It‚$_œñq‚_ ¥Î.¿èÛ'Þ²¬æÇ’!mœŒ ´l¨@çÂÚÕyÆÉ©E®9ýsÊï<¥.Ó1ÛˆÅbÛ‰³Ú–ˆí}ØE2i™'“ ~dýË÷óyؘU¥Cõ7ò¬’nàŒ>z¹ÒêQ·‡½ö¡… hw`eM’éô-ï:ƒ¼.„=‚…j ÝV)òc‚öœ@3X’º¢49£Îj®´Õ^Uà]èÞ‰(²´~5©wÁ-+ú§ µÊéòÇiÚ°×fõ…åÆÊiWú«Î]‰ª:3Žn¯®’ŽVÇYg1#šBÙŒÓãò0?NèÖ’óœÒް}\QÞ…Ú’Õˆºr(P–u,q° ¥g&Ta- <×v©ÒGµÒ‚fÚšivEh‚Ç#Ž¥ÉuH"0$kœMC¼"a½µ-¬´ô® —8|ˤ8PÖ¿]ÊùJjF°ãD¤ª,s“*‰Ä{N²ÐA€D‡iêÙØ¯î!;Ei*„åïJÞ/!觃^k-­ó,]ž³Ã© )Tº $g…Áqò÷¥¶T—8Áê”c¬¨7 ‡>”ågó‡òÌÔ™CŸýàÀ/øÕ ;ºhÊøxJ]ÌÇPz7~×xÚ‡ µí S–’˜«ØÕ’`Ê S~“ù5?Ó~Z—¥óC|™åçQ2V:’¦ø ù8FɦÊf’zÍ%Ãq w‹â—g‹A?34U”¹þ7oš¤ÝŒú¬ù;WizOB¬Ú€ÒµsQAÃË¥ölº¡^.Í-aÅœ['ÈP§kÐÝ=z ~zÂÓÓ‹ ºrö ’tÞoɰ™¼Ø>s:ð ý„Š¢­®†Ã—=jÍŠðZbàÝT|Þ.Ùì ñ„õógÒT¢Š^ãé\¡]ÆŽtÅl*´­´K.éöá U$ïÕ»Œe"=»GMD þku^s뤋¢÷7#J#:ú˼ÿ veüüx>ǯ[[ÖÕ$>?n„Èkäé'U­çÇ/$± »'€´n=ïÃ¥yé^ü’K/¡aô`o^+ôxfݦy6Ëà–8BA&úI$?+¯‘=çpîß‘í«éÝ׉f ÙErzCüvîЯ:ÂjÕ¶«[”²Ý7(þ³ìå ·ÙJ-äy㘠á'¯Fù£+è•óÛ„Øïf?€.§¸+²o>ÉôÒXÃæØý1,<[$Ãkvp…'qXˆÝG{ï<>ûG 'Þþúéþ·Y[d˜w¡uµñìÐÁþ V ák Óýf{¾•O¬ÒÊy£ƒ (­Qt3$Åeî Ð4’/F—›&ø{ èÿdø£±‡þEƱü·Àˆ¡xÖ™:º½t™ŠBUèÏ?ØcU`ò—¦È£w—~dy. š^ùcÁ67 ¯Ð ¤•boÙ “Úc'€¸Š™‰÷˜û·ô“ÍÇñPè†/Í‘Ô+àTv2«Mì½C±¸šÁnLkXS'‚x.¿+\‡\-óÍGâ@Kú{(4U{p«×Üa8¾HÞµSÓÛðÔê‚§¾Rm`rqif¸vÔP5Æ6¨;å«$GºÍSBy~iƒ¢˜qÒµ²+PR`|m*´Ù‹9INó:Ôy…3â³ÐÛÁó!×Ü#yðk®‚‡F'ã*òÁâN "´ÝtÏ4“¶²^^=Ÿ#ùÓ›ÝHåõï5|!>moÞý¶IñØkåJÜ•.6(v@Ï×6‘8‚Ä…óOo|?ÈÊ÷_s7e³ΛpèÍu¬«7Mžcyû]2ÍÄiY[¹ µ8ÈûÒƒêÝ8G?Qo€¿6ÄâăõæsÛëæ‰c÷÷Àkø¾Í€b¦/âé¸è‚ÌÀ|FÑrûå¶Q{$[OÅ ð¡Èy=Þ²ã5†^Ý?œ\6w50_”ÕŸÂtàb|±˜ì$9©µÓÿøô,9ŸœÓôì,9ÉE[®ªXˆ5­1ÅUâ÷üÙ°]=|iøŸþrs~:M&ãxå˜NƼñõìèïGÿîiÂ{endstream endobj 5932 0 obj<>/XObject<<>>>>>>endobj 5933 0 obj<>stream x•WQoÛ6~÷¯8¢¬–b[‰›eèÚ5E:`‹b€_h‰²¹J¤CRMaÿ}w'Ê‘T;ÎТ(’÷Ýwß}wzMa‚¦ÎéoVÞ-F“d‚?Üÿc×pq÷3L/“KXxz~}•Ìa‘ó™ ,²(½NRXl$üY¯v±7ñíÅíë×ðIl·J¯Ï.î.aŠgé~<»L®¯ñh±QœÌ¼2ré2«VÒÇ—V©Ì)`cáþóÇP‰­ƒ[0èñ\f¥°‚®:Pv¦¶Í9¥½´…È$ª¤ç ã‚ Oz[gÞ% $LjÖB¢„8d ŸL^ãÅC¸‘‚-›HÍ ä3‹~¬øbÿ^¹²”âW n+3U¨¢•¤)]"šë |,(›pzwÓFa’ ˜ƒ³$M‘ò¼ ò›¨¶¥ìÇŽùlšÌçoè,Ò ¿J»ó¬ ùk$s$Y]@ðrhƒ‡ß a ÂÓsZ:—šŒËÔ:—–\—f%Ê}Ša~™ÐmŽÓ¢rä‘ÀSVbåŸO6ܲԸ£ˆ¹¢.Ë]üP‹’˜ÍCFO²x¨—n 2Y‡ªOàY"_ÆÜܬ„½¹q[Q½z–Ñ_5ˆÕ¦…—PI¿19U´Q à¢#SHwí$g0 8ÞZY¨oý¸˜-w 6 eÍ ‘™ª:‡Ri™pÿ=]ݳɥéÈ •ßàˆ!<ù¨ÊVðòVbÁrGAç ¹•nÞÞ—CiœT·I{ï7l÷ ìò éq¶Óï€b#|Þl‰ícÿ²Æù_õfª¬tu‰rÇÚ*."TôŽõŽuŠv «Ús¿S?ˆl£°C9=Gþ ‹Í£¯û—%FêíÇØIiÔ`k­©XTAß•÷ˆ,» ‚ÂëùÕàÕbK†Þ„N ^µeOT<½²w²{/¬'ÈŒ–qO“4™MÆOL–Î@¶1†ºÌ°Ñõ¼ DÔ3¦>ÏüûA-ãæü!§ß·Ü‰VƒJäÐŒž!©ñEìüŽ–‡Ø¹K°ÍsƒGV–,.rƒ0w¬|¨q>/XObject<<>>>>>>endobj 5935 0 obj<>stream xµVmoÛ6þî_qÈfTicYov°eñ húbt_üaŒDÙ\(Ò%©¸ÞÐÿ¾#õâHµÓ¢@‘ ˆÄ»ÓÝsÏ=ǃü !žÚß´ü¾~€/Û?jãy~ ‹§—¡?žÃ"sF,Rïg8]ü3ÏÃÆÌcê®zõÈs¢qf–^A˜XžÎ‚ œ¿~á­èÇ’) Ïè'Rl8}v,–Q%µg  ~]Åôs’š¥—,O’ê䨪}MêÚ½AH>ÅȧðЉ{&V•G¶T‹Ö(JüÄV}5¾zñV\Þµ—‚UnÙlhaC˜™ƒÆ`œ)  f-3 ¹T`Ö ™•œÎ@ FŠ÷úð’ZOkÓû‘50a)™WûjôeƇ9†®¡>sþ¹ä\n1xÿ×ÍŸÀ„¡ ñ¢3¬5£)ÇÄ5˜-~¿WÒ¬gdAˆü8FþdÞx|0â–™õ‘šŒk†UÙMš3ß÷;ÏC&8Ct†ÿu^:c–Ӷ üå°M&KÛÖ¦¿Q×lø¹ãU'0ž7¹ªã†,¯å¸”÷@ª^½+ïv{Pûˆuûa£UÁ­†ß!¼„È"ÕQzTÝÁ‘ÁŸܶ'=ç8k~|ì#Iè?õ䛾óµàû¾ÛÖµ]¿Éa'K(È=ŪŽ-õpà5[‰‚ sæ,·ŒsP4¥ìá‘GAµ&+Ú™Ò')ÓØÉ7•ˆPž¬)ýɱb» ½¶%Ì@H`(Ë,eR)¨Ò … Å(ç)ž+Y€6ªÖöÇîýÒ-€ÓÙd†PüÝöò¥#âÓ*§f¸ú “=¢L7âää´©¥RcsÕ¦Ë;Ct눰¢$IÁwmd~3†ƒ¢'­³'Ÿ*Ù­;§KŽÁDÛíF–"·èh¹ UÆQûà›^°"BŠt!\K(5j<êy¯!+ŠÒؽӫ2\›©AþÆendstream endobj 5936 0 obj<>/XObject<<>>>>>>endobj 5937 0 obj<>stream xÕVmoÛ6þî_qHWDNE²l%q_€6M†Å–%Þ†Z¢c’¨PTbcØß)±¶gý:4( óx¼—çyîz!ø/„(¦¿$ï}šö?ÀÝêN®8ó#˜.`@|úq| ÓÔX0M¼D•QhøôñÞC4|ÛŸ~ë\ DƒãÅãaÔ\ônxÎó9W %Ô½ä0™€,¹bZ*ô7õ|MÇ÷\Ódvæ†Ï<²¬æÕ¸ïÛ—\ˆôÐÐ"Œ7õ~{¶ xBÍw/P)ͼœ‰bÖŸA8 >ìÜVü¡ŠÃáåŠåeÆ÷ùÒªæt†Ñ<ç|øœóÆçdrýeŸÛÈGáøÜŸC8¤âRÆã¶´vÊõÄnpUY˶ d9òG”ìÁ¯%{¨ù”%›©¹ÐŠ©5\œ\¼yz]ò fžð¹ß|è%vƒ)^jà«2‰ÐÙRždøkJ­[ËZÁíŸ_~&Dpµ` ‡…Èø¬OáI±²DKf‚£a©—2Í@οñDW>ÜÊ, ÜÖy`Z/R„ {Î5kìœ(îA!ÊÆÄ´@tN:5xt0¹’Žiw )gÞ¬oÐëZ÷(E U{jlÉÎZíÅøF¯—¢‚„U|@Ùâ†A»}p»Mä\/e ŠëZ°KYiV`%åÂ~be –aª÷¼ Ú`E g°ÕNºÔx—íàóC;@îDºÉ6‹ïWï¨ã“Éô¯ëË»ò«4 V£`8ãñèÃv~Ó‚ ÉP‡ŒTx¿üþõ붽ׂ°œ,{bë KS*”X ¤Øo“¾½éœ"ëú²kdc“C1ÁÐð'†[$p‚Åçûd)RC k Ù­ ™zz ,IxU!*ls¯°ºDÕìk 4ó…l!`‹©å”Ÿ} ¯“t"Ga”›cãŠ]c½A‚—9ÐØÿüÃgÿn=eHe=Ï8¬°Þ&Ç?/+=æVm0ÙÛi}¯Û#â¦n¦­þmñ:nVƒî;«÷ÿe±î˜vtžYw½ø05“© +AªÎ9 µÔªéyÓ9D¹sý2Š·P2·ha6<ËäÓËìý_´Å¦ŠØVûj«ÚlTƒ³WïœäXc«!Á|Ÿ q–Û=7Nþ _ƒ}5Ò°ÇåhË}ÞB\™ìÙæ°u*w+r²Ò±RÉGh©ay]Ð2ˆ#¦—H6‘€HCwɆ¼r[MLbhƺٶã ibÃŒŽïX4’¥8Kibúð™pkJ8fY% Ì(C‰…3~¸ ˆqš¶n[“FÀ_‹<¯5C½è’âî”hñ¸ÍÜ/ Êm‡³¥8غ^r¶v±Ñf}£…í®ðC2GS¼«q¾oªêð=“mÑÚl`õNŽà¦­ «ÝÑ E¼á&Ybç –ó®›×M¡º¿wCiUö¬’áÙÈGcˆOq#´«.ßãÈà³Lê£Y|(\¾­õñ©¥™™q#¸ ­·i3âÆAìGCÜ%qÆÑ˜î]N{¿õþ/Øf5endstream endobj 5938 0 obj<>/XObject<<>>>>/Annots 3178 0 R>>endobj 5939 0 obj<>stream x•WÑnÛ6}÷W\ôaP[‘-ÛI6´@»-E¾¬ Їyh‰¶µI¤&RqŒaûöKJ¶¥¦ ‚؆e’—çž{î!ó÷`Bþ&/ø•ƒ(Œð LøãËÇÁ,š†sšG×aDÍâ(¼nžrºœ>ct‡³ÓÑ“gŒ^ÍÂéÉ臻“íÜžÕ†.nf4‰èn \‹k|I|I‚¯[©èìîÏÁÅ ð¹IA² ýíÊ€ Y¬deH¯I±Uغ’$ðÞU¢,e:"»•”he¥²ÆcêB¦d5­$¥{%Š,y¾'|èDXŒÕ&S›>†Â÷1èª?OÉ]wRDãÉ)Ë •¥T)׊v[ t!„Ò–n¿~úH™¡ªÆPf·z‡qr~Þ .m¦Õò,$Ç'|äÂSÄa´ž §GFvYžƒŽy€YÉ\ „›=ˆ¼•dzBú´8ÄÄ‹‘ó–+¹RÙëšvBa3÷ãcD2ßµAqÈîKYˆ’˜ “TÙ ;™­®l¾G ’éŒ {_Ub(3×UéŠë°o L„I‘޵Ê÷!Ý€|E™KNøÊ[¯Â˜57EªÓiÇxJO–jú§åeÊÒãïóèŸ:ÿºÇ£†Ç.`.—¼®¬tZ'r#ÖQޤ<`[×*ájQžýJðyl `d÷÷i—ƒ™¯—g߀­$Ô¯Pç|=~÷ø*Ĩg[6®¤‚Ú£[ŽìŸTSIß=¦.KîzãE–©7‡Ú+›)'Ç_×u`‘ž0ÒÈÂtg¶†„ô„¶epídJ™d"§bùöI5hßH%+ÕÕþÏI2Î1x¿~ë²ÍðÇÒ)÷ýŽ{–9bz¬f—¡/õjÏ­ÆCMš‡Æë+Ùµæa´#éS«½Eãå܆J ÀãºÒö#z­žÃ°í/öÕ4ðBænpM'|€×ö;…·~•¦Ú* j}õÃŒêdËé½ÜNñ@t¿öÀà†«ïËÿ‡Õø]h£ŸäƒÎRò¡óeàŽ\ÿásO„æô–x´G/Ä5±¿¯ãé¼õå /éçósJr;Òiû¨-æ}†“…øÌvàé7£Ó§‡An΂YpÞ—]p>õ‹.Éî 9p_à¬Ñ©¡5\ˆç•õ*ϬáÇR͉‘ +Ðsiš±_±åŽÚ5ÍŒÖËŽ1=“ã—Kì fÊX¡ á;#w¶40d³ä)Ç-ž êÍÕÂ;š¨!Ýêm²\ 8Çó”J`ƒ' •ç ×§ð93¶×«[Ì¥ë"ž¸ –g]Yý÷½6t#E•l—Í¥&³²ø6€S)X“âûÛÏ3+YèùüDÄ" †>hþ9—jc·ý_!r Jø09Іè–îÜŽFwÇÙ隯 î2û:\õ8°ÿéxÑóUaA»à‹Îá¾éëÊ/\´×Ɔê^¸Q–çù¥Yžäþ,r?HîMs$]ÜL®dãË/åÈ`9Å¥¡;›ÇšãKùùru—OAòßög.œg€ëÚ‘}nÙó~â }zC6‹æLƒ 8XÃñó ·lL.á™ñœW‘·C–É8Æ¿"¿è—uÅ¡cÁI5 ç˜;¾ô=èLvA·ííßyì>/XObject<<>>>>>>endobj 5941 0 obj<>stream x¥VßoÛ6~÷_q袴±"[þ·Ëдõ këa/ š¤".”¨’T\cØÿ¾#)ÙV'-–Ž%¿;~w÷¿õàïÒ‰û£EïjÙKâ_î>ô œ/F0H`™9£É~c޿Јœ.ÿî/&E•¥ /ÛmQÞHnU ·¹b) 6ç@%1&æƒYÒŸÆ.²%‹VÃɺ`ýá,¾€þpäÖ¯Kø\¯·gËpÈê’Z¡JDs¨ g@ ú’RmÌ<à$0‹Sw˜A†qšâ‹4ÿV Üsòá;)*ÉOœ±³ðaHøš…ùü£06.ù¦k‹ÒpmWÑ‹·’¿X6«Ž7Éýê«jûÄúGrÃõýõÆwì¹]Eò¼äåÍWѽ…¾ûÁŒ(VSn<á L`Um=»xШ÷Þ ÝÇÛyƒçë<§îé|qƒaKë8ž`Þðà)rÏàÝ«Wp]æ\ KJê·ï‹Ê±<Š}:—X_þºþì¶â}šszË5La-åÈÆ¥UeOìñbÀšcMñ3lU 9¹kª .Å-ÇÓ‹5€é=(_Œð:)-üÓ9$@û2ÝQõïëÆ ”HØû.’Áªz-ý9¨=#®êúô%kÛ;À³8 6šT7vš¹àšhšo7®vÆ6'É©õé7¤à¸m— 0V×ÔÖšÇðVJàÚ²65‘ª¶B »mÙÀ³(4±Ò·P*]LÏýþêr+ôzD”«Óy’ æÉeÓ׃¶#Š]æ l»ë|qج¡BysEô<ù>Jž±Ñe˜o´®—á£^\/ú2üª²ß‚C‡ñ˜3ä¦[ë]üô1üu?TÓ1‘æ)£#ÌWòÿB?ütÌÏ2y 9ôÅ›¦!ޱñ òô8òå3È;ž6Ù¢ÖXøºx !d7U~TFî”``*R¬¢FK^f«S/GÝ£ï2ès3šîÀ錅Að‚¾ïQ" ”òÊšûæ‡)Üá—€S—@¥P7PWv”VCq¾CIÉ´*~¬UÃ0ˆÿ,Q&Pi(J§ ó8ÈG³GâdFÏ^Ù™`å‰SW•ÒŠZZóöP“Î0,æåÚI¿A`é©a<#hkŽâ.”v²Lqƒ­4E(~nPâ\:Ñô“£UÒM.hÞ:ß…³&{É} x-Øâõ…àíÂ#«Ÿ1o¡šÇm¢ Ú<¸íñ°ŠŒå¬®¹3„qü¯‰»Ç¸óS¼ÎÌg—2˜pë¨Ñ{àf6ˆdÎPÎqV”ÀÃ}æl‡ƒàák #s#öݳ·6G³Ã@~j‚¾oji7¯ÍÁY;ÝÓ°=¿—í#³ö|ÑÞ³Q>/XObject<<>>>>/Annots 3181 0 R>>endobj 5943 0 obj<>stream xµWÛŽÛ6}÷W 6VAlÅ–³Þ­‹¢hš ö¡š¸Ø—-Q6SItIi·è¿÷ )Ê–Öiö¡EFdSs9sæÌðÑŒ¦ø7£ù‚ÿÒr4§ø†?füñþíhv…GJæø(iv}_û‡‚>ŒNKJf³89þörubÌY4zþfJ7ñœV9%SZ|;‹‹kZeÎå”Viô÷wOWŸFÏß¼ žsšàÜÞý¹è6To•¥TX9Æ%i›¢VÕ†Þ7륅°–>FÞ òpf¢WÒ¨{™õGŸÒ^éªÀ›º²*“†¯¾„«ÙàE–TmÉ6;iœË˜nkÚëê²&Umá­&QHççÌ%s—–¿@¦³hD¥,׈#oª´VˆŠu&j‹ܶnŒLõ¦RÊÇxà€EE¢J¥­µ¹8ÙyŒ€¥ŠeÌXû¨SRö7ñà Ô£.ê­Ú!Ò¦È(ªøø4îåx·•}¸»}K;£“•ÖWVUµ4¹H%åª@º¹D‰¬”$h/LÅ¥.ñ‚ØH*Ôïré#è˜Å„Iâù4Ë"ùY”»BÆjyµ¤»öí›ir|Èn›ù’¸Öî#!µ©´‘Y5x”E?3Õ`/Ô˜á Téš¹°Ó¦–(Qå¸è^=R¹Gäµ0Ž´{Uo=³x'SOjGåRg \q€¨{Ô"ëR±ŸÖ£;Qž‰,¦—2 RâF; -Òm¯ l<“¢`P](çì ¡Ú ”‰¬.và«Ìñü^zÇ•åRÔa¿¢æ ¢_+`󽨥wÔñ)ôhGÿIÙvÐZ©.K´ÀÑÊÖ׿ÿ²{µ¡IúìM «Cgš:bôôŠô«eXtcÀQy¯tcÃkcR9çÕV¦ÏYV’Z(ô­¶Pã rduh ƒv×QÖ+XKIZÒ®Y*u¬œOŸœŠ0jŽš…ºº'¢8îS÷+ÊÊÒÂ…2MÛ–Ž ÌP¨RÔAØ.BÖªãÈ\9»Ng%œ4Pæ¼8Õë/(‘ch,…Xè°ÓÌ‹–3Žë­‚v¢y”ÒÜè’Ö |ž—y|æÜP¿cºc¢ƒà(0J¶$ê®p1×[ùÊTžK#«±ï&…¼—E/Wx´˜@ã¤$³±ÇŠåàÒ#y·þ$ÓÚ‡æ%Êà äµS¦7¡^£ûY÷ñ 4!¸ËdŽ~b²â“e¥ÕJ”xd 5x÷’ð# ÁB½ŸÖê× µŽ;Ì YP˜²µSÚRÖ[Y'xLÍ#æÓb<­‚³vÙà®ôWWî®($r<ùå F£ä»ãÇÇ9ï†âÉIP<àÑ6¢ªÒ¢É$=0{< Àpñ•ãÀúýèÀ’ÿ5°“¦<É·%˃äUóy;¤—˯œHΞèprøŸ"ÿ…Ùünm¥¹o‡—ȱŽ0“Cwjµ‹eHëh+ <âÙ*Ú~„ ŠÑR©>ËlÂ]¢y_},•²Ècú±°šôi ¡ïš‹à¤¯Åæà¹X”±µóiÙ'ï®kÞuÚº|DŸ‡ödQÇ$ ‚‹yAP½VX 9k¹˜–&ÌŸä³{wF•Â(3b¿éïA ÇÔT¼Ê9 €“À2Ãî0ås ziÜ£˜Üб½ “êZë Þ\¨6<‘ÊÇ.Ç] °ê—؇ƒ¿uG¯?Ñ÷aÕŒ+¹ïé~Ý>ÝJÌ`ÐÜØ4ËT…5º°r8Öûï%ô„¿»(€@îm¶ã™†‡Õ]©n+ nðÊ·9Þh¶nãÖlŽëB–„… /|bðàZ‚QrØ=ØN„âhÓâúí˜çX‰g¹×Íf˵?@4üÝ©Ó_༕~V‘˺>:[òãæ€…n«Ö¸Sñ{ƒÛ/.¬ÑÅ«4]vLóþ™p©Å-²77íÍ(™¾ˆ¯æW´¸Y0óyyŸðú•N›óß±™ávëON®ý7ÇÀŠoè',¬· ž{|ôjºˆç në0¸˜ßðW¯W£_FÿŽ¢òendstream endobj 5944 0 obj<>/XObject<<>>>>>>endobj 5945 0 obj<>stream xµVmoÛ6þî_qèÐNYmE¶7ñ°k6où4l1P 00Ðeq‘H•¤ìÃþûîHùEj¼f†¦y1ÉãsÏ=÷ð>Æà¿1¤SúâÕàýbÄ ~xøfÖp9¿…ñ9îÞÜÀ"óë ,x”ÞÄi| woßÂÏaJÍ2‘Á¼QÜI­ìÅâÁåü Ƹ™Ž&Wñˆè€>È÷†P WèÌ© 8Æp¦áN ̨´uålS×Ú8¼jµƒ‡÷?Æ0×Ä«êR Aæ°Ó l#Àm5âC)¡B,”S¹BÚYÀ™fC@'„t§)þ•E-3ȵ^FR¹åÅ×ûã˜Óé"/˜¯x»á˜õÈGKãéôø qq¦ ±­H¿6˜þd€Ù2¹.\®Í–™ *¦”0}|xÒ¬–QŤZ^Ì’d‡L â ó>‹Üò‚¸D¶ÐWX] f†Þ·²,a-jEQ!VËÖ/Õ`kª±œ'3øÐƸNng§–l:ŒÈsÁF e˵ÒFd¾‡}x{Ü‹ÉHGZ±Ëô6XýI¹|ù!K<Ê_>Ïð$I2%0ŒÓ-ÀÃÅ*ZáÿœØÛ¿?ÿBH¯CeDè~oÕÒe¢ûfô-ä%z?t²¼—"\^Âwœc1!dêxs·{oÏgDú:Ôèÿ‡~´ðXéUÇòX]nО›ü„ÐŽ øœ’²Ù©à–ãK-Z†aê§+,6´í6ã\›Œb >!#þý„`±yH»ZŒj#¸È„âLS Ã5ƒ'Q]è]ÛBbv:3ô"-’º¤ªt,)‘VÌ9<)ž¸¨QìˆW:´10_Hp9évh‡Ò ;ù¨Ø#œYœzè‚\‹½{ÄÛŽÀÛÆ¹i‡²Ir_§×0NÃhFÄÒ8ï5o*¡œÇC@PMaïè]xF_0ý]'Ó8à臣Ï4½¥0?,¿ þnendstream endobj 5946 0 obj<>/XObject<<>>>>/Annots 3184 0 R>>endobj 5947 0 obj<>stream x•VmoÛ6þž_qè°UAlƲ9ñ¶k×ý°·&ؾ(h‰Š¹H¢KRq¼aÿ}©ËnœnHˆ"u÷ÜÝsïÓIHü„%î7-O&l‚7îOèþ|xw2‹YLÉå›PIá$fa»*èæd¸Æî wkìÆìb°E1»¢h6e ,GIĦíÊY®±;»`³áî`]R†°ÜXrßרMBv9Ø}};ˆÒ‡ªïèü:Fpt›#É2Ÿ<¤Á¯…àF¹ÐdÙ• ÓÛ?V|®`%xqóÇûwÄ«ŒÞœ½Ø?Ô¹ (]ñµ…­\i*•$+<–ÜJU_ªÚ’zºP<“Õsfί¯Þßxš_]²ˆ3<Ñ/k¡¹UÚ4gw±Œ§®|8} _x©Œ¥5×vÔû©î{″BÞòÚ*‡*åE±¥å–úè2E•²HɧZâ^mɬE*yAV nKQ!†Š¶ªÖÞ›bBcCÜ(’y³™ÜÊþka`i‹g™ôIéðH°.!B\F¦°;²(Â* ƒoT¹.Ä#ýík¿®¤c=’öMw²sq¶ºWß,N¿ýÂ÷ÿø;öŒ=˜ˆ%ÉÌ9tGXuaQHúP#‡ ¾, â…QdêõZië‹ÓǻΧT »R¥Jk‘ÚbÛAŸöMALC›•@\q^ZÖ²°cYõ†¥ñµ2užËT¢0#O™.^C)’¾´Ñ|½FÕkã°v$?¿† U9_kQñRìS,  H­|´ø—_þP_nÁ3'lëڣழð­e§Œ~@B@ª0 Ë@1 ¿sv–®_8¤râôÀ ™5‰•b“¹š‘c»xäŽóï¶´1y–}LÒ ó·!¶–TŸñâUÝÁÿfæ({~V›´Á‡7òÉq¥BbìJšÃ¸öš€Ó÷ô¶Þ¢a•Ø,‚鈢Åé«—GÇ#tÎÁétwš “ð-›³»€¨¾~rR— Š Ñ½ÌyÎ9º9ë²e3à»eð*!MZ~ )An,§ÂÆñ¤s¿­°õªg>øþžëeùy =DG<³æ©8.´žé`.ß8)I]h»ï$È{¿nž\Mžº事®TY]lh¿ß»nÅãÐsÈ®¸íŠê%–ZÝ‹Šêu“OS/›Ã†`AÜó;aözló²ŒmÇ)—ð_È{ׂҌžï¤IÛv-È!dpn®ÔgšŒjSÎS»ÜSõ¹è«ëÔÒï(+J:!;5$‡GÛÑ_‡‚Ý´“"ä z--m”¾w løÇ né¢P›çûMêå"(¹øùdÎ'¯ü„p~v—TÐÝ•/Û½<ÈfÁöòé1ïŸ>e¼íuÖ¤±mp'ÝíÙO:’>/XObject<<>>>>>>endobj 5949 0 obj<>stream x•V]oÛ6}ϯ¸H‘FAmU¶7õ²s<?»ˆÜßeƒüÖ3ÑAÀ„•ˆBU­ª¡Œ ‹d}ïÐ…_ìBò%ÑTkµÒ¢¤ÆæEþ·dwª1(†!•‘)EQPŠJ;ª¤±2=Ø6Þ×6·kB-*›'¢hk奴•E1àª^$Ü•´´] ëZ“J#õF†,õüþ%P± s9O¹t1f/Äg¿<{FV¢pÈßxÙ®å,; ',Ý“¢TU—yÂ+hݬ$§½,Ð0®7*¤ßÔVn¤`TIin-f ­´k²Ôfp#R¡Sš·ÀFïò¥zG‹àÃü]Wœ8÷{8Ó’Á°¬˜—˜,RœA6*ZcX‹þ¨TM¹¾ß[J‚p˜¸Ž»}*EíédoŒAµµÕUʱš[jðÆ"0 ˜„Õ¤E+cÓÙŒ÷ÀÞå N  À¦G¢Ää|Êìp§Ž /®€¤kÀ}ï>ÍŽ |ž{|Z5p€Ú±žs—Y·•Ž‚K#‹./\k¹c¤vÜ[¾6²Ê™_˜PÛÚѧ»'ŽišÙ¢fHä¥%µü„–Oh-vhS•ö¢ñ…1€èûÐS7?‰âžqå×ÚÙò¬’ )LáÝ4ôX±G2M]«–l4šéîR÷«â\óÁ³F«eMÆÁ Ò‹@ï JXsŒNî@ÛÃÓHÈé#BÜŽtÝ@yû·îñî)mDÑHçÇHù^ s _¾þVL´hüjÿ%gcp}!Þ­Î-ç™ó¼:ïÖÁ‘<÷YãˆÀâq—XÜuÑo”á3W¡(ßGè.‡^?ùÔ€C!yØøè“ s?úûÍéNÅL«Ò¿ïñÃo+~Ó^ ãh^Ç×4½™„7Lü,;ŒÃˆ^«¤)1»îaW¸ž½ìð…G|W#7nûSÔÝ_×Ñ4ŒÇ8Ô`p:±ö›ùÙŸgÿN¬»endstream endobj 5950 0 obj<>/XObject<<>>>>/Annots 3187 0 R>>endobj 5951 0 obj<>stream x…VmoÛ6þî_qÀEAdE/¶“¸I€,k²Ù†5Z÷¡.Z¢#¶”è’”_Ðî¿ïHJŽoš‘DïžçžçøuAˆÿ"H&æ'+aâó+2¿Þß F“qC4Ág(atg͇‡A÷¹„qxœv¾b ˆFçvgt¶{0J;gÙåœÜ†p$. ar“É)¤¹Í(„4óJ‘לÝrÉéQúy§¹wÀªŒ×9¥óÇÍ´kVDvÅ‚ ¢AÕåÌËD¥ðOO§né…ýxõ#¬¯©š½1[OnG`ö.ì!Ã8i2òÞ×óí¡‚‡ôÖ’,—¬zR°”bÅ0’çL3Q%Õ…Èh%ùBA´„9-ÈŠB)$&ËJƉä[³¤‰ZÍð{ƉRTm•#SeZÔʇ­¨!#䇅-S—sÅaI‚˜æÞ .á]¥?8h*ºî³‚‹ ˆ÷_%û¯FýW%Yßàûæ;,k­`7+3—W/÷c¾ —SN5}d‹&æ./!ÙÅt\ḇ?údúO–Ò‚ÂÃ_ïî,°ˆ·í†%„+a2gœé­E’pnßf±I4a•–¿ŒH¹"E]å.`Ó˜FH̼[¶©êÒoበê7ŽE¨ÎfG¦ °W\Lc¥ÀNä ›£¡_¬+¸–’l}ø…¨Âî È6î#ÚÑ_Qš›žÉéSòœ­]Ô>b™½tÔš=M§w7®ïÿ|ëÛƒ_o›Vs®Z§–½ßڬʺ¢‚þqp¿ÙÞv=h%†úuŒô›æ@S”8Ñtæu÷ „¯ðºlÓ‚)p%Xý ûU‹jëxu„ú}®O(ïJ³ •ý,×_N±V¯}+ëˆPÒ¯5CÝvá<ìØúX·ìàFÈÝÁ¿j9êµòþù±UÌtûú° œ‹6 §Yk>pýh•¿8}âºs¤[o…¿êi$ùæüɇæ~¸¸ž†›x4NâñÕëúý}¾b¢V•€L!jÈ.´óN¤ m’ ›æ¯@†V™mj7.T¿ÏÍ)Êš+Ûsв7Šv‹ÁVП‚8™<ë"dEä¤}|Ü_Þ2²‚,5•M/œƒÙ°ÀY;Œ'ÆsA4‚›ãc;CnëÊÌ+eÂ=»™Y> ¬í?ˆ³5Ù—BÇk;ô8¶ÀYRP&5šk7oމùjeì{˜£ƒ,š“?Û¿qnAãhtó2=cË&¡XhTÎç­‹  ÐqáDFqÊmmÍta±4BpÔK* V9ófGýB=ÔùXnò@ÑkÙ͉A¨Í MÐè׬LŽá‡=",»<ùšl|¡tiÁ¢¥Æð9•˜>¦Ý³x£gŒ(!"B/‡®3g»¥lÇýsfóy ×aÊ86Þ9–KsúmGƒ1|skÈ”)»¹+øØŠJS’·94ÍVK‰Þã´€(4.¡^¢lÝQQýaoÕÓ)Öò¿ëÌ©Ä6bûA‘©|/îný~ðFxƒ´wª8ãd “Ó°érœÕÃ/Š?‹¬.±Z¢2âÏ­žºiá”8ĩÈÒfdÀ=›K‚M9ód×mãp$1Jå7Ù‹ÎÛtðÇà ÌA’endstream endobj 5952 0 obj<>/XObject<<>>>>>>endobj 5953 0 obj<>stream x•WïoÛ6ýž¿â€¢¨ÓÚª$në%Öv ìözŠz(‰²ÙJ¤+Rq½uÿûÞ‘’ÙNŠ!AbSGòîÝ»w§/'#âgD“)ÿ&ÅÉëùÉ0b±ýS.éùõ†4Ï`;}…©ŽIo¾’”U:q¦´¤4ÙZ’(%%"ÏeJ§óO'ϯq‡ßßãdzÙZ”ÛkÞ¥ŒÍ =úž]¯ÕÛ"º6%½yöŒÖ¥LU"œ´´è)µîñECŒÆ çVÂQQYG¥tU©)6&'aI`ÁV¹[œ>àû¯ÍÿÓùû÷±uinU*Ó¨vt|ÆŽþ—4ɯ¢Xç²O*£¥º•šÜJÙ€v¦r9 Ž ée4áDèxM&ø–ö&­r‰ü8+ÝÍùœÉÞc¥“¼J%]X—Þàq¤®ºn»–…X/zï´{/XÎf0½àûÞ‹Ù,¤§®ü=;î ¼O“h:}Á÷~08Âq ˜ÊJþ@8“²Òô{oi£ÜŠUþo*‡Ô¢„LüI&øÆ¹j“ý0¥üR)@ü$ ð¤I™öîïÄþˆÞÊL€ dMé”^R,WâVÁ©TfJƒàà\št—øÛóëQ“`&²÷þòŠ>Žúãþä¯`ÑR€à-Ñð Þ°r¸so܉eÑ )ø‡¾‰~ü »®(¦iqº·é ʘ°ÔÒ/u£Œˆ’>Næ¨óqg>ÆÁø¼aÕüFç^ÞÏ¡wN–‚µ)ܨ csùúbcKTÓFæ9}Öf£)C†™LL“‘jމö +œ ]±,;´6ÖªÅæÙ›ª,ƒ½vŒÛZ‚CÒö)™Á›¥Ôð.o «u©9Þm f¬eKSb猣!Y­;^,µÑƒ½uïæ1—›HiYRRÒ hàáÖ‡z+òJzœ˜[3[„¢!:߬ 4ÞöÈ•¾˜cƒŠ-¥Hý‡w•‘÷uÎðoJ±^£À iÕzbƒ ã,Öž.¾àje¹½|ÝR’ ¤ô –n#¥æØ‘Là½{X§¿iCm€¡5$a­ +oæfÙ{½Ó±4¡„§A©À’ÂÓÁI(4RB÷ñ-FK:Ý€‹Ê)‘«¿±ÂäØÏ;rã*‘·ÙmIˆä:LÛB4™z Zf“9îªÀžtLÜX.•Ö'¤Zê”?úTZÆ“M‹Ð©z)“óþÏw?ûÚÈU\¢c“È9· DèT1´|0x˜ûc­¹D™2ý‚Ûþqj𔋬N4‰ š$Zužo}¬ˆ®®¬ƒ G Õ•>ª å Æ rõ¹‰Á”}ÍFÁ‡ñM‰w[jWP‹00p[i‚è÷×2A–ÂÔpî£N!>Ë_v7HSv5æè$ãw¡z¾³)®1Þ›P3P$.d â„Ô‚I`£ñp<â0ä¼ñ½O%Zn¨¥Åi3"„ó½Í7žt˜Qjµ¼펜»+¥½‘Áµ{w: öç0-¿ºE/´œÝYGáÆx€f]Ùcæ…ôâí‡W.PøσɊ«áN…Ü™@¬ªj :ëe-ÊòÐÍÓLžbŽñ¾üFãO“Pn=±J1®øñøŽ ؈>ÔS“È-*.½:ÙsµÀ´¢0*bH“kK\v ª-QÔ&,ô%Ô!¨îY´÷³Ë=^ …o]Äj©Á]“54žZúöïðKÒ`TÂÁ#츗"U)Ú¤ï¬ gC¹ |ÁÓ&½§jßuÿ–Ðv¯( kÑŸ(çý»<æ`Kxè“ÒÔ-wËdŪh6Ö«¼¾Ã­€™‡   M;I6eÝÃ:QwœÅYlÏï;^JÊ 1t½ wy4GµÔ`ëMïS… ÏšBz:ïãU_^Eæ« à„×+xf¼GA× |½©0úØv8¶Ö¤—õ àxxOÎiúrÆ/î1ƒI4¤·&©ØKÏD¾âl/‚ …Ùî¬íü d=Ú§ÑdŒ÷SÌóÓ³ ïÿi~òÛÉÔh£tendstream endobj 5954 0 obj<>/XObject<<>>>>>>endobj 5955 0 obj<>stream x}VOÛHý?ŸâµÂ±Iâh ‘Ú=¤öàÀº;érB{M¶g{S¯'jûÝ;»kGqZÑÎÎïyó6_:}ô诤?aÚytz^„›ù#Ž®z8õ|1=Œ^÷½ÑèAd´zBg/•Q™pD²œ%|ÉÃBæÁçN.Y‘³'²0)#UDöÞm‚§‹„|ê\//Óm2[›3`òF›] Ñ'ï± âü:-çºPÏee(æ<ÃŒ£T•99ÿRŠœc»°ý:o;ršÂlÒ¿(}‰slWäe¼jyXâì ýŸEƒŸE~-²M}ÕRxª”'l&©pN‡ W <ŽE(xV bkȘ†$²G,½”-^à+¾­¾au8À÷¶·ÖIP KoÆEÖ’s#çYÔ’VsAXxqÞº–,!áÑwù«»Ãs´ËF£¬#±dÇ f®Š–p7ƒ²£«~ƒ`‚¤Üd‚ý.†]ã?íâi<ÅXËr?5vÎsÌÙ’ã>øˆ0aJq…JsYÔóõxª« è"‰ñXd6 mA'†ã^Üÿ}ýáᛇËnoëàòîmps÷ðé2øýæâ¾–ƒŠ€ÜT;0-³LOSUâѳگѧ«˜öÚŒ´ŽO»ëõGxxˆû”ån ´ªí^ ½¡6¹Îò¼`"3V‹\>æ,¥’D¡Ê4•´VRoÔ¦ Åœ¶73NûVål± }£ESÒ Y’Ðá¥2 ,ê¼—øÀ3ÚÔ$YwiM…IIÈT'²¥L–Ô`j» EèehˆÂ¦; +ˆ;xJ W»=– KîdêLÚ;†LÜçy  yf&Ž`RÇ6í¼-r|m¦b8ð<3 Ø€¿µS1¶¥°kböñIL„‡A¦m:«sÒ¬fJêÚbŸ 6[É•”;¹/ˆÁEhÚ±•á«ÝŒµpÆrÝ×öÕws|2÷·h¡•Y‘†ŸkÌ1…X&‰¬Ôó£iFpF¥L° šxŸs"@:šÄptTK"ÂaÊç²ÂÔÉd¡W³Ê,$6•îaáNVäÒ£ÝËñxÕš´nÁšH¯éÄF“m¸é·pë™ ¤Ù3+PÕúMêBi(¯ äIÍ B'jÑÐ̳f¦òv§†æmDtõ“œìšS5»–rö™]ŸAH•ôði ™*XVjj;Ý5³§OeR*ÍMm#g¯Y¦Ýè指ôd±|íQ³sðÓ{ý<šßµ²õzZSlÿtèûÇÑ÷‰}ÓuS]ßëÑ£–š2X!¤aUšÕvOìa™óØ2'ñýuý£Â°Ôqoäù¢YâËÑp¨ã^?;?­D Ôendstream endobj 5956 0 obj<>/XObject<<>>>>/Annots 3189 0 R>>endobj 5957 0 obj<>stream x¥WkoÔFýž_q@uJÖì›°¥H%© ”lÅ—•¢Y{ØwÆŽ³­úß{îŒíÄaA•*ÐF^ÏÜç9çÞýó`Bcü›ÐlÉÿ£ü`Žñ Løã㻃ébÎh¾œ‡KÊiz2Á_ÿ”ÑåÁëõ½+îž¹¦ggc:Á¥uBÓ1-_àÊò9­cgxLë(Ãðhýù`L£ žãàI%ó2•Ü—¹0ÕEeδÞQ÷ô¯~Üim<;›Ihg£é¬u|ÐÍ1©‚>ÖÛÝ1ÉivUªŠk²©®³˜>×¶¢ÃF›/‡+6|/j¶3 g3¤Êl7A.T±9ZÇ“Õøùã“.É ¤Ÿéí­@ rµ:5‰pøÁæèထO‚,g:*µ**iÈê\¦º¤øèeoµ+ì®Æ·óñd™ÌãäÕàø0ÒéÞHÃ[Ä:Û^Ýì¹c}†Ögû­o…ùFÚÎ>^{×]Ï;Oh§k×**¤Œ©Ò$¢HZKU*©.bi²·°+š‘Um œÜîÚ¦¸ .¥•6£Wwu^R••YrLV¡i;ª­t.ºº´6®®àQ&WWûLä²JuÒ™v9q¦ŒÙ¡³Õ2á;˜šï«e‚>•ážzn1˜>ºØûµA¡éGïüqH (>š.:^ÌP8yjkG¿‰âº×’.t¶Ëµ)Seó¯{4çœÛå§ów?XG)Êu\g’l]–ÚT–"g/ëì•÷ìÑ&á—P„®È‡±22Bkì!%àJm$˜ŽN¨Lîy•ŠŠm¨uwâꂃê‹ì‡ôQ¸”Š‚âºÌTî9/ª€…\TJTi%X³0”œ­¡ÔA·‚{Žú—¨¥¢SaAY²Hm;)t%=Hc•$ÀLÔrT•C4ƒy>’ÜJ0’tBM* `‘íl·U¡FU©+¶SËggè§7÷Óõ£íe8üD²týQe°µ§‹ÜÃOpÆj:}ú”ºfP” ÍèšSÑ… 4¡eªZd”Ë|‹[I]øÄ#‘eÈõxP…­òÆA&— …ZDÖˆ«Î %à§¶*SÕÎW -”}Ê2®‘ÊÞõµœ"Ë^ï(–‰¨³Š=i¸¿ —¨«º.´‘ˆ£IU”vLÏ¥(|gÁ0(úû¨»w.o¤×!>à¼;µ €„ZÅjÜ@ÉÔ@O3N Êur+Sq£4@ÃÊ!ÅVj|s:µêqý¤#Dгdåã:ì†ÉˆùÖ©çU±è¾Gí¨C+ñs@kûu—.ÐìËÒ:•ƒº$€’n˜\õntÚ:I: 6åS4VÚ‡CÔMã~Š~71ú»s xÇ¡vF7tÙ¨ëÕêM«ï¬ÞvÙ¥1ÚlކkÁ?¾²]•, ~ß™ŽcHž‹uÝð˜E6输¡¾åd®6F”¥Œ{ÚzQá%¢f{Ù‰j9Ý7=z%F;½í!À(kNé—‹s‡0Qì<ôöt NÕÃ5õuZÓŽD·ßs‹ÇÔÆÊÉ;mq"ï§Å‰×{èËœ>ˆ|¿š„''Ü.G‹T°$BV ‘Îs(cáî᩸øB+mH§ø„JÀ7SôJ„ ÀsòÂP:îf 'áe ¶ JŽÖÎä^p²ƒ¼|ÚkOØmmz-u+„  ˆƒœ÷[›Í¢íÝbÙ ìû_Ö¿®VçCPa€ ÎÌ%ÙºPžMNZ£çe‡æÍËïÐ>¿k·…÷»SÖÝýö"ÿãùîÊd¯yÿê?ß3j~¾èêsa nLtÞò8œ`¹˜ž»ÑÙFc·#€x˜ÃËT@u0qŒueqSÛ2´sÕyßÿ c¥ªD¦þöŸ%:Qz”ÉŠWjLÖ®E+ˆŸªˆ²:˜ÚýåÆ6GÝ/?ayi“H+ƒ¥Çv‰µ¡‘¨±ÈHÏÁž­aöJ*…ÁwnHÜiNÿ%ãÇ–2B²¬:Î îS/lšÖ#L=?Uº„Ž[bܾ­×G»ÝÇCž«Â(…‰}é¬ô{¼üš ýšÉËF/ãÉB”idxßO¾%R¨†PãËý/²µ"¬Øbkt%ã(ºÍ{Tèo•R»½¦•©Ž_Óñ<\Ì´\â×¥“!.âhŽéŽêŠãPÄá`øÃ£ç¬Íqàצ¥ÛÜ+l¿n®;.ÆËp6õä]Îláíúà÷ƒ*;¢{endstream endobj 5958 0 obj<>/XObject<<>>>>/Annots 3191 0 R>>endobj 5959 0 obj<>stream xÝWmo7þž_1 E,ÒÝæÞ¸ZQÊQ>-Dê—HÈ·ë½3ÙµÛ›ã¨øï}Æ^ß[B%P?U‰.9¯=žyæ™™g? i€Ÿ!§ü[4'ƒ|€þòÇ»—'£ÁE~AÃÉ(ŸRC£óa>î¾Õôþdÿ{Cãá0?ß{úëåžÁ`Õ.èl6¡á€.+Ü<}ŒÊp!þ)²÷J’üR9*–B/$9µÐªR…оÞt‹;$­­X­¤¥Â”’RK+¼,i¾¡÷½zÙ#å f|k5VMUñ“RV¢­ñ@‡Mrœ.ò‡—OÔŽàLö»YËi“U-4[ð†æ²0 »'·†ÌÊ+£Ù^Õâ*IVÖR8é‚ͳÙcb£j4eëã‹|’é7Y)­ô‚žÕŠ·³ûÀôG“|Âû_ùŽUBYŽß4 ®[YQx¤p/{ó®ElóVÕ¾¯4¶ë’œÇ§°%Õjn…ݰÿ+knÀñNªŒ¥Fú¥)I‹>Ó +ò³hVµìE—¦Û\uð<³Vlî9õEúœ1ÚBGãlúð|Fñ`-õÂ/Žæôª¢iimÚš]¾Ê{þîY%£%²É»‘úZ8÷(p´€#ãzaØa(Â]Ûä2# µN†üÚè è™Ý—Ÿ½Ôå‘T*+øMpK”%2¢å:w8 Öˆ%„§BÔu$«±j¡´¨A CF`ý$yqâ[FL—Q>ã[™…(éõ&Hó^އ+'[µóZáüvè쌞€bÛÂsNd³òœ¹ƒÓ”¬^eWŸvp9 #ï$—OŽθ‡Ú¼Ëoøà)æ—í¬p!Yî~M_ã%ÚÉ‹£Ø‚ ]ØpÇ KçîíHµBçÿÙ¹së Bņ r²®ú?ïüO®Fω¾@¾í*¶Ï)óéôœÑ{†^á=š“3u;Ä–xL6u6Û±.P'.¦æ˜í‘î*kµúÔöqsoCÉ7¦lkyõ0§K]Yy£LëR#\M¸OÃŶ NéGèvÂý;ù@¥MÁýU:þäI„–N9#§ ÝH„ÿŘ1Ú2ã5ÆB{Ý6aL6Ι)T˜`kå—h0]gFg}›§…@ô\‰8îjå<×eêéènßO°É|ÑM¬ÝÙ„¾•LјVûÞ§ZùMo—ÜoB0³¦ ]I—}tb 6‡iµ2 –Ø}+±¦Í¶Y¢o–ªª°Î]¥µ–à46¢ûµ¡Ôê¥{J*—9?Ú[þ/¤8Œ8C* bw¸S3ÀØË[£k¿Ž«ôö K»w]iE–ÓV_¬¹0qÝ÷vÌ0ÀVö¢„)túÇ< "å ´¤ŠÀŽ:6ï#ÙÄS P·®ÅLˆc–%ŒvS5ŽeŒÝˆ@Ù®ÀS«=†¨SIf‚°yc<’ÇSòÇ P,R©YóµŽs×uÆÓJ –bîž³ŠTŽéIK#ð€õ5ÂK>iÑE#¨ð±>2̺VºtŒ`²Í”`W™“…deºâ†ulêhÈÞìôyë¼iÔÂ,yy¸=©d AŸˆÊRz¡j‡F¡½[UŽè+KHeû:ȺoËÊ8>⦘…n š «éFÔ˜8 +MAA.8ß{ =!éZ›5ž8>ÝÕ]rz…dÀmûøàÄ,ßêÕàY˜H ^ê¶ì”æŽqQJUóKDd75¯²õRËn¬ßxÐD·„+ãÌÊ•õ«€´9:Ô>/XObject<<>>>>/Annots 3194 0 R>>endobj 5961 0 obj<>stream xÕWßoÛ6~÷_qõLAÕ²;IÑm×t{¶¶Æö0-Ñ6ItIÊ®Wôßw¤äXŠ5Ãö0$qDñÈûî×wç„zøIh0âß´èôâÞðGÂo_w’‹a<¦áÙ8îQA}üOêUNï:ûkì^ŒãÑÞn2N°î'=|bw0ÄaåÏî­±;Æg{»/&{`<"³ ÇWCJz4™õ虋‡4rÛ•,ÄŠÜR8Ju¹–ÆY¬$Í«2uJ—ßZ©«DNFºÊ”ÄGÈiz[ͶØ<ž¼ï<¾‚é^CäL%ëFiDÚJÍEnÅbº‚ ü(ŠU./›kÏã#ï÷è´ß¬²èÈÈRru•½VîÚŠ¹|ÖÓírMŸð%|mŽŽj[§‘®Ë–nOžº´Uîè)M£‡ =xJ=H=£7l]ÒúI·}kû–Ö[Ÿ³öÓþ ÆŒâ9ͤsÒÕyÅþöfeáT¸½±»vçÑÊÈL¥Âz‹2e$´–€[•ê0âšw¿ýøAáØP¡³*—°ï3iÕ¢Ä5$¨n©3,µ®Ð¤Ï ƒDƒ‚ÔZéÊ6Ñ9TÀÞè*Ï(×ú†ruów1Û©ÚóúÎ_»(ÝןR[ðÌ$B»Ö72£¹ÑEðEª3éAzä‡ÙÅÚwÉ¥ÌlB•ÓãË^/¹ì}W%¡:£Wu’^ÞæÛ³&pµ ûÒ§ÝÝ‚`m»|˜ü³˜ÃhÅuRÈÒÁÐʪrÑ¿;—•*mŽI—¢T¶ QfH9Ÿb¥C\?T—.ù¤A¢XÎAøL›ºlB.h$€¡Uf–ôœš»I¬Vù¹geH\(Zq^#£ýù6'‚†¢îËÊ:]¨?…Ïû«e[¼a-Ô/cA‰ôuBåvz7_ƒcB;í8cçñLñBÀ˜Ÿ|~Û Ù°Kã!ˆâBpˆ•¢æ[øˆôì=ª tºÊEŠjÛ$þTÉ»òcš 8˶憰ݔzƒ]K3VRÑÆôœÅ=—±Û„ßõ–¶‹ ŀޥçƈí7V÷ mCD›¥J—Ä1] ^\šÚdÒp¡D9Y /%9Óˆ‰®þýþÈwEj#ƒºØ¿Âºíž~Úõµ1`Îô¸íø;8ï­ÿ”XÉ“i+¦ÿ bÒk?´€À…ïÂsÛñ{üúóLN (A/=Bãa¸¦ó¬¸ÒvVF¯0l*ÏcFW‹%-Âdä[UxܱéW† hk1IjúÔøÙ·aâwûå§É[´Æ¹ÀØzâé¢åa° üÜY=±3ý…Èíø ¶_{¬íˆF>ز0:Èָᇈ~Љo'èB¡gcÚ¬ ø›¸‡Ò¸}oÄô£/(6ä„o³žï‚üZ€^îétn"Ïõ&´Í=¯@½|x„Peëéð¼nÈý¾c Îh4ÅçÿjÒyÓù +G;endstream endobj 5962 0 obj<>/XObject<<>>>>>>endobj 5963 0 obj<>stream x½VMsÛ6½ëWìxÆZ±hŠÔ—•IgúetqÛ„i/º@$$£%–mi2ùïÝ(Jd%'¹tì±Ab±Ø}ûö-ÿé !ÀŸ!DúMòÞOq/ð|Ùü)·p·`æGo `r?ô'“)Ä©µ N0™‚ª - Vb†—ºá0òg3ŠüGHTž+ E©ÖÏAHÐ 3ÿ™ÞlÑêÝfÎÑ'.µæ)0 ZäEÆ¡P2Þæcò%ð£·/÷¤zHÓ•GÙînñz{÷¯_r]e±üÜ‚ ÞA²ìà5ìÛÈ~i'Û)»*ÝvCÓv!éz]!÷iѯãéïÏÄPrS•mýï Fvq¦×žÙŒràrâæˆ¥©˜JZÜq·Â—DÉCÜŽÍžÙG Xû´wÚžê'¾å¥M8¡ÞÕ+¤6œ¡\lšÖµòqáBWÑ‹7BRrf8–å`H©ûÄõ²_o…(b©·ÜØÚ¡ú¾¢^ÀŽ;¡;ɯî’þlΨ5.(|Vé½³‘Þ^ê¤kVÙ¾›W£üÿ[+¹8¬ö]ðÙ=9ðàK[èNí-0óF¶šgzõ’ضïh÷kãø«}º›JâèÄÑ’Wƃ¦,rMàŒ>#™ø›NèÛCŸ&'-j…Fò-z:¨óU¹¿Ã&¬¼þ®+>/XObject<<>>>>/Annots 3196 0 R>>endobj 5965 0 obj<>stream x•VÛrÛ6}×Wì¨ãZ‘¨ mEN'©¥~è-–ÇuǑĖ$X”¬xòï= ´ ºöÔöÈ ,örÎÙý»3¦~ÇLù/L;#„'ü1æ/Ÿ;ãàÌ?£ñäÂ(¥ñÅÄŸÕ«„®;‡ë”&Ø5>xûÃâÀ ±ª×4œhc‹MF4½ûÓé[ZDæÚ-Bï$ΤŠ$uË}.S‘~Ü=]üÙÑ`Œ‘çû¾³Þª8¢L®E)ï¼8+©wõó/7‹»ÓïyÛpŽpnEÜ8˜õÞUF_ªå¾O‚ÒªÄáˆr¡E*K©©Ø¨]AUN¢À{-ËJg´I%}š+MòA¤y"ßÙÚ˜ø‚‰0ò½§OvŸß¸Ü:¾çšγAàúíx½ØHJUQR¨ÒTeT’ÔŠÊÄ—"—a,ª3GºJdAqA¥¢È¢DÒªÊÂ2VžmDÙD–*-ùAF*“ÏÄÙoœp`…B’â¦Ek¯¶d³UT ‚*h'“Äf°ñLjì…*úWêLqÚÜ {TÈ,"\Rˆµì7ŽfUºDyñr_Âl*ûTTaˆÆ.ê‰sæž{¾‡zÃÆyƒÎ7›¾¯MßyáFhê•ò– |jsõêÉÔkˆZ(Úi‘³;›ƒÔÀ¿`Ù›Z¡PdË –XzÀê¯7 ·æž©‰¥Ú¾Œ87m'©ŠPóžNàÿŸXÿ•ª:1ÖogñZ†n7Ò@6B¢köqBPÒ.`j¶ŒBk±çb§T ¾Yh†ÿRâÐΣÅDÿ ï*ßýUt«tu˜¯(S€Š…–“I"KÛ®EówOùFï8´C€¹â%“B>oìPîö-®+¯Ÿ„Ì„ðrJì)Ð\X&´ ;”®F X3žÁá‰ÈR÷*‹CŸ –¦P ùÚÅÙºAXß³<Ø+_áƒ_V-­ªõÆ\[kßÑñÃ0Za~ž&µ:7¾}x&ö+–ôhW|͇&äo¦ ¡b/ô®µ,ï#èiV°0ßy?‰RÇÔKk[­Ù^mõ5šÕ­íÅî¤û4¨cRK‡áü‚Æ< 2ìfþÈôk/˜ùSt·PæÜMlw.l-pu·'¦þlÆMƒ`>¸)=Œ¥ÙžŽb-Ñ•¶†.ÎÍÝ‘·À—ãb·F싦×{ÔÚ¤J²”¬¾3$’«MNð=0+±4šéJ™ɧC•m¥.érxùæp)+Uƒƒrž&À‹ÚJá;æ’ó@™Í‰È»¬ŠR¥ñWa9—³†,ÜÍÍøä±+¥ˆÁ%Ó²#‰EÌ-+–ª>/XObject<<>>>>>>endobj 5967 0 obj<>stream xÍ–]oÛ6†ïý+‚-p[–íÄu·u@º$Å€]´‰»^ÔC@KGW™tI*®Wt¿½/EÙ±e]±], „Ð"ÏÇ{žsè÷­>ÅøíÓpäÿ’Eëù¤G1>Ü>Ìœz71£!M2Ä4zÚF£'4I«]1M’6áGÑ3²ò/þñlòg+¦noR¼ùT¯q´Z÷ztÅÖ½&¡H#Ö_érVð¥5mOÏèccQÊ;¦¥3îèÐß-»Ò(r9SÁjîrÒYµ:æ]*Wïú‚o¬©χŽ_°Û&IÒñ«”–l2m4Ó¥J-%9'駱G,ÓJš³ó'§m˜<ª†Ì±¶%ýüŒbì8=ÅZÒO¤¦gÓ³†Y_«:È÷VþÑ̃ˆ ËGN¹ÜèÝ 5çkc´ñú4©öÝ¿áA˔잪•yÅ#GÐüÂb3¡ Æ }]Gþ›ýÖŸ*½›sò댺h“î`XwXûNª„‘ÿQЂ]®AŒô,KS‹'Ú(„‚øCÂK'µ" æÙÓ¥ëê¬[³&’„­íÐZ—´óÜÑJ+§aÅ%y0[™gº-gÛÎøÞ厕õ¶gkZé-N0\…^ùŽÂ'Hâ‘g²àåL*¾¯¤ž¶O~yù²bÿ¤ã_òCC “†~8ètÚìÞi‘Ôf;tRµUN¢“/÷PMHi˜Ÿ¡ä;ò@¡(Ú$_!l‚ú=– G:…/d¢S& &•eã8¥TN\±öÅÕJ DúÏWFøÄ(+UUÑ›œ+ f± ƒži'¤o7e¬ó$Ï(–žL?*K ÞŸMYYÀ%'‰ ÏȨc‘úÉò“ 𬧥Ñ0±ð¦€æB*ÄN+‰›.yåq/–PöçÕKK6×+Õ© od·m%‹Âg!Ò4Äî›×÷˾N=g¸µ\÷lë¯r!¯8Ëd"ûN§îEç±–)5Ïm²Ûæ¯êˆ×ÈW+ˆßxbe—œHßÎ’B¾ !üã6­/¤ð¾©]ëyóÿoPTcsk¯îŒ¶ú šõnÆõ´ïÏ£‹áÆÛyx÷æ×ÝaÓ•NÊÀd ÓWCØÝ}&Ãp¢>½¶›úï8 í*ª{ü"EþéâÑEìIºž´^µ>ÎØöœendstream endobj 5968 0 obj<>/XObject<<>>>>/Annots 3198 0 R>>endobj 5969 0 obj<>stream x•Vmsâ6þίØfz=gŒ@^:ùpIàš™Ìõ¸ÞÜ 3Œ°¨±%Ÿ$‡Ð»ü÷îJb`Ò6/ËÒêÙgŸgåoµDøÛ‚Nþ⬅ŽÐG‹>î?ÐtOñ2èž…ò&…aíÅmç'áé‹gW£±\@=‡æ  1šA;‚Þy+ìõNa”¸#Å€Õ+ø~<ú«A£…c ŽüÌb+”܆˜Ùxã VÒX¸grÎûZ+ýËøø@c™1üùþîsâ<ç4.AO' Ÿ É'qÊŒGן>¹8Guzȇ–É„éÄÝÁ4I3a8")ÃÖáÈÁ¿‰`¸–gáÑ~€çJ@wלå?ƒrÕhwJ®‚[ v! ¦nx¿ràO1ωX Ì”kÀÇJ¦+`Ö²xÁ° 2n*1€S`VHǧÉ2|LÛSqü†ÁÜ#õ£k[¹3³ÌigfH÷ú„ê72æ0ürûá­ÙÅ*äœÀ†ë†+›¦˜ÕJÀ4©,¤"CÚ\ ×ïÞÂsGD¼`¹ÅôK¡TµŒú#Iµ Òua¬ÊÄß(dmÀ™-47õfÑZ´ÌP$™B8ü‰eyÊ˯98Š6£°í…휅½° ¿Q(³ûbº‚«TÅ.ö¶¤Ž›Ð±ó»ä fþBÌ)þ[¬ÞÌ/¦be ¥ÇQÁNˆÈÊT3´ ’G@iÊÔíU‡åB -Xšª¥W3+ˆ5æIùâDô‹²p÷>ï55´£Â¤ˆQ˜m™ †5eD•a©QÈrI{»êäˆÙÊ혣ˆÜ+c’ÖÌ‹ŒKL¥ÈÀù¬*ÔµÒ îKZeœD ýD‚k¬.b‹•0Ež+m7¹’Vb†¦ 5,ydÒ²ù†Ó7[s$BsTý#êËó³i ¨uÌjÓYœ<æ…8WRœÃú¶‚aÉÈiÊ“jÄWŠ„¬‰ÅY ž¢é(–‹êCû ¨ ›Ì°0ksm{d£Ý;ì˜Ià—2QËÒ_¾?V»e^LS»P$÷²ƒúeã@H Ou¬¤…•¿,ýe±ß”šMñ§Tú} 2¸¯`x^·DìUˆ—¾O’M©È@ŽR„á)j™šÒKí¶BíšOüEõ|þº×Üb†göfç‹Ék/'ù8<p¢C9ã>!ÿ§K\³Î1øÅ:NStï½Ú>ÍPòå8ˆêQ½Ó‹ê'gá†Ëò–a¬R$ù©}¸¸¸ïßì͘zw] ½Ë+_?pHÔ¾#”ðý™Ø¿ݨvÚx’bóèu[¢?ªýQû?Q%Ÿendstream endobj 5970 0 obj<>/XObject<<>>>>/Annots 3200 0 R>>endobj 5971 0 obj<>stream xYkoÛFüî_q`TNdZ%YJ>¥IhµÕ)u²˜P¤Ê‡e!ÈïìÞ™¤ÎK'-âØ1çnnfooo©üsÔW=üé+L_áæ¨çõð„¾õéÛåÛ£þ¸çùj<™z=µQƒ^ß›ÚßbuÕÏ“²ŒÀÀ†Õ ?ö†`›¨L«Õ‘A·ވŸõGà0z$!LÆ€Kfæð:ýɹå4ë´Ò jÌqéÚ502šZ“ IH=E6Ä^]Fœ@g È 1Ç¥k×ÀÈpØfHBê)²!Öæ*0â:kH@¬!F\ºv Œ ¦È`JÃ;$!õÙ¨Àè¬!±† 1âj`uý¡7 IH=Å%k¨vH ³†ÄbÄ¥k×@Èp:õPŠ„‘zŠlHTÀ†$:cHBŒ!ƒH† âj`u“a›! ©§¸d Õ® tÖ€XCŒ¸tíSýwHBê)²!Q1$ÐYCb 1"bÄÕÀêF>.2Ñ„ÔS\²†jW:kH@¬!F\ºv ŒøœÑ„ÔSdC¢cH ³†ÄbD4Ĉ«Õ ü6CROqɪ]è¬!±†qéÚ50Ò›xçòIH=E6$*0†:kH@¬!FDCŒ¸H?õÑ·I)'"õ—¬¡ÚUÀDg Iˆ1d—®]#ç“–æÔ—zŠhHV` tÖ€XCŒˆ†ö|ÛÔݶ?ö²ë7èfŠCöëìèìb¨ú=5[á…a<Å?–ØùÞfaç"ÍÔ&ŲQ²J³MPDi¢ðUì·zló®ÊµV'³/÷~¿ÀûBgfÂÄ­öèùÙÅTõfñÓÁ‹wP7Æhë.ƒ(’¥ïB½¥us3¾{: ~3fk ‰þë zvÁ>WEª2PèZeéF½zöL…éƒSuY.ö¬£§Àf¹Ô*Êò‚XTÄ<%XÌâx{âHu®þz÷öº’6ïDIÁ¤]|O09\™zºÉoæ'‡²;ž‚\µJã8Ý‘¿"XÄZåët‡µ€ ¬[&ïãâ‹‹O™¾Ò2÷¯u¬ ½¬Ââúmÿè$_“t—´rþDžR¡¡úg*Fä9jUÉ0Ó+”®)A²äçIZ¨EÅÅi”pi¬+‹ Í|S`ú¸ƒPhLÆM€Ò·ä²Y×^Z;ÿA¥J¯çtñ¥ËKW¡¸…BáD ‰*à¡ÌØU•®T¸J ©­j(ÏÌ‘Y(ºùV‡ÑjÏõ5—®3â© ºšwpßá÷`³uW=yo ç“ù [²@v…ÉBRœE|OòšŒcç)\¦‚,;×쳋žšàÖÃ-< »hàù>~[vŽù››þAï>¥¸jt†PÌ;F‹Ï>zs½½~‰ýÍ袼¢éxovUo~ ÏÛ<ù)šùÉ R_w §,âøÜ¤Œ/\–«2V»µNÔ>-‘¸‘[äÇ%,3Ç¢ì<”ZF~Äûû‹¹‹90–qá)3R`ípÚÏI•Áå˜ã2;"ÑjäWWøqµA<öÐ\@­ ­—軂²››J ·#šŸö¿yÑeó!š.ä Eqð*³aÇ”‡t“ÿ’«W*ØFÔ#˜h.ÓDÓ9’Ûôë}º:Fp{Û$ypfÔªLX·í:¨±9SÝ”Ú ÚD õØ¡ñ0Óé yê3¶½á\…e^ ñªâmÏ[†N’qÔ‰‡ÓòGÛÆ¡ªÒ¾Y±ê¤å>ÏtWe"¿‹Šµ9Å}öµ‚¸³Ú¤Ë’º³r»M³Â¸uâóƒ42ûÝâ¬îÖQ¸¶G„#-y”!Ó’Ö¶*YÅ:(¸2ãPqW±È=õÊVôjMv¶Cþ§P^PßmSZóþ"À ×Q¼lFµ’‰‚ç¬E ¥{EÕ›À=0_ê‘òhÈkc”‚ ]Ÿê‡Mb:½.ÊC–ÞFKÚB:•9—IP”™é/*T2o2óö²ÐÅN£6U¯TÏ™ššj›]mŸ’iÊË+Nl¾¤¹8Rvq?|%8ÔZ»Oe~¬LøTcžú¦¾νt‘¦ùÛrG!_äβ*u›FH)ó®¨oÈà,Ý5×y¡¾;TÕ²†å˜ñ³ |˜Ö•ê㣼‘? p&¨ÂÓ]sêãã×iÈEƒJ¬pmŸž²GßáF=¼ßácnâDðfvôûÑ¿þ<íuendstream endobj 5972 0 obj<>/XObject<<>>>>/Annots 3202 0 R>>endobj 5973 0 obj<>stream x}WïoÛ6ýî¿â`4˜‚ÚŠÅq:tCë&E>¬ØZýP#Ñ6W‰TE*®×íß;R’c')Ú&¶t<Þ½{ïîúµ3¤þ i<å¿IÞÄ<áCþñþmg2¹Œ§t>ºˆ/(§Éå0×ß2úÐy½¸wÄŸ+×tv=¡á€+øž^âCê]âC]—&§÷ÕíŽv¦¢DhÒf‹ßYFn£,åÒmLJ™ú"ýƒ§‹¿;gךá^ï±?Åã1¾¤ÑÊzIׯÄZnÙp@}¾8nåZéƒ'D°Ž´n-O^•Ò&•¤yeɯÊÒ”ôò’6DEå,uç¢Zo%Þ–$w ¥N‰Ü¡?ÇÓév çB·‘%Éo"/2I™1_H8²[µ>» íY Îä·DNýW’ kãàù’†“xÒÀ1ãi4ž¡B‹]!sQ؇Lâٌ͌²• ;¥™—êVZÚ  MEr“ªÕŽ>|¼yû“…ÍJT™£m)ŠBé5ÝʸSÈc…w¢T¦²4?›?N©pÂ!K•eS¤YƒByFD'ü!>ˆp8âðRUrlw2&)‚GDz't"Sr¦P Ü-ÀQå¸i%r•)„áv´Unã/õ ›Ó«ßo`G[ zá7‡“ 'K%2RÚÕ;¤=8ÝGr¯Š†âQ[tu²Üúò€ƒ#_×I*J“H™Ž)ycª,ˆdˆg9)N§†éâ B‚Jùµ)¢tdV5¨\—~¿ÏÉ<]å)ÀzðJmÀ[Î97ôVZ \³Åßit¶Ã ¸N­<¶B#,CHN¯®É%@,PŽ…¯/J•+.Íûq¥ÂJ$rOT\Ï} ?š6$‡ô‘3æÒ6iÿú€#Ïð4zÕ˜°= ‡y•3°€ ̠Ĥ’ÖRËRxN—$å!å œÉÆ¦¼Z@ó–©L³æxÆŒÎCrGø¥ú«/`· É2³µ´Œ|y,IdÆÃ§éSÇŸª^½ Ûòô¸••¶—5º€¿º~ê!O(QÉÒzËSE¦¸‚ÈúçÚ´–Vß;l;Mðrˆk@· }g@´@M=V54ÐÓ–kóE¡q•CøØ­däÁ8¥eÓ/`e+´îÖ•oÛáÊVð]¥½Xö 1ê7…®©ÜC#SºjÙÜåú‘¨:’B›]¤nOžvyJ]Te2ÕƇ€“å›vˆùÃ]¢&qƒ/—Ë »­Êcàj2MÉ“ç „|ᎇ P³Š¸/»w"«ä1h¯xÊJÝH„Ê­eè7>H3Ѓĕâfúð;¾¦…¬)¤@]‘©Y9‰þ¥ëgÐw% ñT_R»§2g/œÅc‰·éqgàaÀÆÐ†’š{/79¼j"Ù*4e„›lžÖ`ðy ¸«¨ ^ø{êÛ Râ7õ×£/Ð}&/&.1ÆTݳ®]Ñ'Ð •ÌÁ$úÜ`ë‰þ Éz9ýØònc„£Æ{•Éù },ÜÒ$X$æ Œ°í~ÅøLAœ5f%Ú9GØ#CìË`Àþ0 y00EsL|ÕoŽ5ÙŽhxÅ@ àÁœbÝ#ù >^î0æ˜ý ,†î?ЀŸÐ÷.—yaJQîü"!n3„ÒÂü¸`‚áõ#œòtÂuò[‘ nQ>/XObject<<>>>>>>endobj 5975 0 obj<>stream xÅW]o7|÷¯X"7ÖéË–mÑ&qꇭ­6( ŠGIPäùÈ“#ùï%ïdßÙq݇¢p`KwKrvwf¸¹=Ñ?#šLùŸÜü4;&C<Üÿ*V4¸Òy2¡Ù’ÆCšž’éôŒfiˆÒLöº™Ñ™QÔýëhöé`Hý§="õÙ«ÂPf<-…ôó2ó£oqÝ/üupqB¼nI}ÓOªcz³]®6"w$ EB߉>:ge&¼Jé.ókrv£ÈåJfËLâ->y²K’6U´RFÂgÖ$tiȯ3GR8uŒŠ:™éÐFùµM©PKU8ò–ßÔÇœ‹´f‹W؃·ÍL^zàY•e|Xðvðöõë„fØ1^x€¦˜*Òâ䛉öHÃ~N¾[gržòHjM äžç:Si<Ä•ñ½máDÂØµt( v‹¸=m….•{?F)7 UpJ¡xB#°ÈÄB+G9ª!$¶YìÙÊå° 7‡èÚÑ£vx} cÍ5ŽY[ª‚Ø?¡æK[à`måX õeµ}HèÜs`¸±½×%·‹O RRáŸ0>®UÅ"õYlr .í&Ï4ª….[À«76-uų¥ÕÚÞefE..bn¾‰Pöcâ“ÉjK{…º-3”õUuÌ«EPèè}DuMçGÍÔ:Ê @‹|+”+µöðk%U¶E>"èW­@“74­ DŸ‡ÏœWK­BÕVsm¯èÌ, ¸•², e$¨ÇMFâæÏé§NBÚ¢6,a¶¢ rô/ÈdÇUÇ;›³ ]'X–‹B@þHÏàoB`]¹] àKûötcwëàjSÄ uÝ*Ov¼ùQ0@Cmw<Ñw<!W¿ÿ2¾¼šÍ{‡}m$Èí[Î{ƒUÝt>7ãÃQ;.X)·=ÂøO¹nð½—ÖÝ ¶‹[£áÞ ¹ŽvôÀ2×Âsé¤GÈFxx^çq¿ÉÄgõÕÐë4¥Èvx$ƒ¿3qDðöMk%ÔDí 8]9wh¹C{¶VoÁ»…ÜüTqY¶Ç Öè@¡~¿Ê/\E -K4Ð µ*­\€9|óñòC@Ôw;çÕ&¡`;Ð5T½̆÷¸­ °ŽPººÔQEá úÇ¥!÷ÛRhÜ’*m$ü˜Õá ôB¸6Ü$ÎsŠ-<áNišñê¦ÈcÆïцœJÐÚU‘’ Xþ«‚üÏŠ«’ Š¿d:¨¢9ì<‰ª¨0Ñ`@?.ì$¬îþ{ŸlÖ©5#ýlïæ“Xþ𝬆¸jo¡_©yÐi0`d‹‘7ä& ¿Kº§+ij÷_«lš`{Ç”:ŽŒÅÔTÍ-ÞrÐþ²¯%ÍÿEÓSË bÅx´3¸Pœå‘)J, Z¶Ä‰¢0••,=î·½`6z¹ó7¹6ïɵ(èçÑ„´bÓÒîoÜG÷¿ÇM^}©¿FçgÒ–3w'é)aÑàâ¼QGç'Éé䔦ӓzaÿêO’!½³2L»A™Ü:P0F÷Ïâ809OÎ’ü öļ­yòGŸ§ÉdŒÿnàvœžžð£÷³ƒßþ<Ÿ¼0endstream endobj 5976 0 obj<>/XObject<<>>>>>>endobj 5977 0 obj<>stream x­VËŽÛ6Ýû+î&°i[{& ºhN³IÐÆÀl ´DYL$R©zŒ ÿÞ{IQ~Ä“Lš`ŒDQ÷qxιú<˜Áÿf,è—Vƒç«Á”Mq±ÿ×la²¼†ÙV9î]<Å‹Ì=Ç‹4º+„U[Z9æÍ¶­„²`÷µ¨x Ò@&r©D6[ ^á]¹ã{WY)2ภFªm)àïv³½ù(RË`U`^–zg\”¼U©•Z W“%ÖßÕ6žÅX[”êVYÿ,ÔհП'×>Ú:RÚÊT@¡w.t)ÔÖPó†WІ:Е´Vdëáo!á-K<ã8fI‚7YT·ÖÀ«{^Õ¥`®„ut¥¯FW Ìwº)³«õBLaL%gQì>*œÐÇs¶XÜгä–Ý0\î4©®ÅiS´ýš]Óæw {è‘æ=þ ž‚T¤‘ç&äº!(Aç®ßL¤%öJh¶œ64 þèƒT|OØ5¢Kàbdã5xÖ¡!½Á.†ç Ó"*KD–˜XxxÎqŒ©“ÈÉ$dž…ج'©Ö‘Të!ƶðådcìdåßî HôFÎSKìzø ÊD·iæöÁýÈ¥Ú_~ÁG>r'ÚŸï/)Yšº‘•¸PuGŸ@ò±Ã1 z§žŠšN„øO Â$:¡Ò iKa u<évlaEOĽ*ó«![„|ë¹Ãàq¯ šœ1·–§(±;„$ÔÝ¡y1sÀ$EØ€±M›ÚÃQR_ ž‹”cLOhiF²5€”|\›R§ŸœG™Ö™Ð9~7ÌiµXÜAk¨&¼ÖD¨]rq÷¾!i(ó#‡ü‰øK­¿¯€g]}ž¨?MÈŽ ¨æ¯sS—›’nNƒ.o@éΆ¼<‡0ðl@sFfPì]!‘['_ ½òº¼1èGhdÎÐÓ1ÎlÀ0YŸõB9uÚ^èzO’èÝÓS%ðýÈmÖˆ•“°nW-Í.œbFnMÁ8ÐÐA‡ÞöFY±Åáó;YOW|¨ãLå¨ ‹ãñÛ–z9üÞ¶ÕF4Îà’øƒ}L>šG~zëM*®øÖ÷RÅÙá'ɱÁuÌÿG„¸õ…ü‚§û zèL·èé~*|sß?¼9Ìïí¼ôð9tv+MlØ9úRç¸dlH-²;Z‘~eFÈîrJ»èf·Ý'O<½fód‹›»¥÷þîÍëq¦ðR§îKÌMvŠˆ¥ú½ãÜCßóé‚%1~‹`¸Å|Nï¾Z þü’àendstream endobj 5978 0 obj<>/XObject<<>>>>>>endobj 5979 0 obj<>stream xÍV]oÛ6}÷¯¸/ÝÔÔ–?;iò´¶KׇÛ* ` %ÊfG‘šH%óŠþ÷’úðGš"À–ÍË{Ï9—æ4Ã•ûËÊÑ«t4‹gìÿÕšÞÌè2N(-h1£ÕËy¼Z]PšûU3J³è«*¹#¡,}¦wÊò ¯éË5M§ôZW;bRúI»«xÉ*CVwËž§ŸF3šÌ'0ΘÞ7åúÛñÖÚn» ÄTÞnsñ§7çä(h‚&‹¤- J·œ*f-¯•¡B×V¿ºÍç0D„…Rê{²ØlXÉ©n$7ĎЖ|#¦œÆÿfe%ùUwêòd±ˆ“`r¦[5ûw#ë4ÀK÷P(¤æƒ{e[VÓÙº)ÆþR$W·Ïqo{¯ÃœÿpL†ð?7Ò äK¬Þ4%WÖ„Ä_Ò|1€»ìÀM.ã‹øœÞpÉ­Pbô îBα¥þЭ Œ)ZsÊÝ^žÓzGFªF ¡\4¥)Ó9 íñ·‘pƒ¬ ’³Œl±s,ÀÔ!r';Ç$µÚŒÉluýX˜ƒu߈Iíe^·,|„³÷¦™«! v»"ÊEÍ3+î8ùi0*l+ \e´Á´òƒOÒÇëü—úÎ   bŸ`Øoêê Øtß®Cúˇ…ú^ÛN&C„Ê8}øøîí÷ƃŸ`Í–Ý w‰~L¨@Ÿ®îq#ð±hT•(Ë0$ÅŸüØÚB‰ /”Z2¬µ[f=|Ԩưµì%EäQ£à †vº:FöB?¤ø=nIȲä¹`–ƒæ¬€'y‡ °éŠ×Ì ­âS'9'ž•;É‹mI¿H–qWÑ~äCbìé-m9ŸóL²ß ÒscO€pºÔkÀd2¤2öƒ F¯_¼ðNc*<ö¾ëܧŸCcžÂ­©Ñg—ïbDqìAèG¾´ó°válÏ'CÆæ'{}:˜©Aϸ> ѳãâ“§çu„&Ö} ù„_Áq먚µ™·þ½\ `2¬MëFß…ÏÔ¦ÌAø¯§î_ó[‡åGÇ~Ž<)À1þ¨i~ÜÂ2z3'´~o B‘{n÷7úòÑK,@g;ãØÄ‹¾ÁXÙZÍÚ ˜±Æ5¹ÛèS ¼$×¶ŒFÔ_¼W×Oúžß¹Nåv¶—G²„›cDê¬#¬CRË2ScJ·€ÒEt[ᮑ‘ì?tözðÿ„T_½ÔPsøï^.Èu´¡csƒF®®Ó]"Šéw¸“9ÁQÑDR¸ ‡Ùão–ÿ/šž9=w¹ÒÙ4¤{Ù¶‹ùåy¼L–´º\ÆóðnrTš$ñŒÞèÌ¿V¼ºmàsX=¹Šõæ™ø§êÉCe9[ÅɯdxËj¹rûLG¿ŽþêV endstream endobj 5980 0 obj<>/XObject<<>>>>>>endobj 5981 0 obj<>stream x•WýoÛ6ý=šȧˆeKþÎP ]–tư¢ë æTIÚœXËhâÞ…³`l ádŒhä±´®tÀÂɸÖÏhºhûq&Ü$19¥}§ç8ŒÀ¶ÃÁZÂ)ˆpOòXZW:` öÓaàL8ÇÒ¾Ós&Èy‡ƒ±D‹y0óä³´®tÀì§ÃÀš|p6 Ÿ¥}§ç8Ì‚ÐÐ|Lüy,̼E öÓaàÈyà\@KûNÎr˜qWw8XË4B“øZ.òXZW:`ŽñÓaàL8ÇÒ¾Ós e(DãqùòX,˜1øš²ŸGÎçòXÚw:p?¬N×Cš£·WhMP¼éŒV âBWq(‚³Õ»“!õC¼Iðæß£çæ °"—º±¤k¥èãÑI¢8Z“®«´¸û®cû¦~(e.Êu/-Ögî}¤Ás†º¸°·èù sï‹ø ®¡| ¸¡>xö¡¡6ÐÞ² z›jŠ…–çøUBæþÖ{E±ÊËLÖ2{ $ÕuZÄ59’GEM¢,a¬ÕÓã› {^ӺǤ9Û–DO×I‘µ4ôz$Šäø0g>âܶÒй´>kjùä²&½U»,¡[I…ªebùnTE:V%ÒϬ÷ªzN¿ý±|E[½/ÔÞ=æÂ\³Ž[Bâ„I —¹I ¸Ú§HiK)ª:w™¨èÐ QR“~ùà\s€‰ŸD’vÚÝJ×8‰DU¢NUA~íÎê²4.× bŸ,ÿ~4å,°$°âßînQCÛ|úø.C§px•ejÏœ2ôâ­Eš!YFjêh C¹¬·*q]‹‚ë°ÓÈ »Â9ã3WÉ.“Ö%Ø™þ4.ÙA§Ÿ¥Å³ØCÏ^ªâ^Vµ¶¸êöŒñ€z¦E¹«i³CërÒDu·ËÑ–:ÀLUä²î´¥ EÁhaHz¹LÑÔݱ> é½þý—hùzµî§ë³ã72ñÉ1<ή.eœŠŒîE•ŠÛL"Å<–÷È6?¾Lp8ãRšÿAÔúå ±¤Îæ T¯—&6'´UYÂõ»ÙÕR\—Ø&O&¦OúÍå~8ð©Ž!NõCÎ üû5·=Jß$x`ëTv²¯ ÒL³5„tO0_º9mT ÃýçêÈwüˆ7Ÿ¥ÉM @“Ò ••ºO™¬Ï>ƒÉMý„&WLÄõeº¤DÔ‚OQ.êxûØæn>Øð&û4ºÖé]Á'4·æþuSö¥'³`¸˜B>ÇM¬œ¼ î[ ÛăbŸ«o*Ùè˜cBÄÃK)NµF™Ç‹E‹Šâ®Už~@ì¶Ÿ˜¯6&b'’$åI4«æh²YEÔžнËoeÅÑzóP73ÖèZ3#›]ûå£<Ðò®Pˆð×0´»½=ëçLÃŒ²~1ÄBæÁ® &¼ ±Ød^â­W ¾eã׌ÿKàqeê4Ç0eø +EÐ(ÞMÏjô×ÃÓ‘5ÒîψžqÑ’ñûÿÓPnhÏi^FF¹Qn½+KUդЙ˜›ÃHB¢Š¤‘ý€°€s|@;ßl=DÁ²£¥¤ýK‚Ë\ñp¡KìJĺæN³“„‹M¥c³¾¢ÚÅ<ä༬dŒþ.bù‚×þÍê¯7W—?]]þ|é¾zuõÖÚ[ÖëåŸù›7Oßã‹ô ½µÆ·IS”p>&£ MgÔÐ*ûîó÷ØUl’ÙéF‚¢¡=ÝŸÙ–4KzBo2|¦4“Æ`·¬YÖ“!>x³NO'3ƸZüzòPF}endstream endobj 5982 0 obj<>/XObject<<>>>>/Annots 3205 0 R>>endobj 5983 0 obj<>stream xXÛnÛF}×W Ô• ‹uWÛ<¤N¤p4VÐÁŠ\JLxQx±£ý÷žÙ]RµiÒ†%qvngfÎŽü©ãÒ?.güëÅ¡3Ä“úO¶£>ÑÔà¯;æ¿CgA™¤ £$“åÜ™¨g.¿Qw:vÆd“4TZÆÜévµŸñlÙô£E6sÓÑm’¦NËœ‰a w­´d¾tFö„,’†JËXûiE`Ds&!‹¤©Ó2gb˜;s{B3×A9Ýv…,mL ì ÍÙO+œÅœIÈ"iê´Ìé¦KgjOh2r–ö„,mL ì )?­Lps&!‹¤©Ó2gbp1 ­´dĽo­EÒPi«"`?­ŒÈbÎ$d‘4uZæL cLJ+-Μ™=!‹¤¡Ò2VEÀ~Z‘ÅœIÈ"iê´Ì(Ïeò{û’™\wŒ†É½¤'.=ˆ,ÛHR˜“ˆÅ/”‡ñ%…ÜI(îEÁò\T¤àm’/2ña‹Ò„÷3–$)NÁx˜Ê‚D¶+c™°þÕúCgH}w„Èz|ÂK³Lz8À#MXú* cZÂE&’ùHÝ0骃±8(Kƒ°QÙöH$>«Ÿè±zF‡,Ýe"¦2—9¥2‹RáKŸb›úùµr’ïÓ2ò‘|žVB‹"„"µ4 n ]÷< Îñ8ô:ÅäËB„ܦȼزvÒG`T#Q¡¼2›Pwmô9zc⢎r3X-ëzö5.ã…3wf¸åºðPãqž; Ö‡oÒ&‹·cQf J•’ÓtCA™èôPPAoËí‘ÒíĦ 1X i7è¥Û9ã1>ù½ï ¤¼é!€Í·ýUaÂ-×#z’ɼŒ zJ¯îÖ£»w¯7=î´ÍÕÏgÿ>»¯¡ñgs6³Fhð¸Ãrtn(¢º[1ð€››WÅÌAçøà6L ì‡'|¾}óó·:>¯A]$ ´+š<É®;m·_éöÝ…ƒCYÎq"byaúâ Þn5ÚJNã1‡ƒT½jµê:Ž“\Ø|VÐ7yÿ¯‘ñàÕC¹é…OÉCˆ±Ø\±k{`ï¹î‘q‘„W”¨Ì ù¢|ŠbQ€f|BK±3Ó1ªF_0}Ùzž‡»Dz97óÈf¿Íái†úîtî —3Фj3Nê‘0 ¿:RœðÅY¦F0Œj E‘8ÄÆtÃÖ3WµD~¿¿•ó†HŽ V•à^€¬<¯9ú­™Fð ZeükMÒ,Qt;z2ÏEv¼¦-h'wûýÆ!eÄÔ³Ç#4Cþ‰PчQè &8°ßò³`Òÿ‰|qüºÇ|Ôýƒ‘¹{w{ w¶DT5í«Ñ;ñ‡AÜpÈÜ=—Lâ‚DØ•9*vl1‡)ꔺ¸>ˆèk<©ŠÚ>Û,ªbO ¯¬Ç¬itêçÿÈƈÁ!ˆÄ.·ãðüÅêÙ»ÛõûÕí³—÷@¸3Æ ‘ªSÔgæè M1ëxóùZq6šE=fw†˜O·g PÆç…1ZŒ›ŠéMÝmf°)À!CLeFÞ܉¡‡Žb;µP¡Ãq2«G ’ܵ|aj®²Q‹6 Œ ìC/“ÉååáfºzӋ †ÍæÕjP9bä-ÆOÕ~bT(=ð€¾ªÒb'ÈKoOÁßp½¨‹ùæ»k’AÀ÷öƒŒŽgÑ€œx‚9]}½êœÂŠþ}c²IÌëÉÅe®u³IU2}u¿I<ÐBZe‚™a+%°áñÕŒÓèËë–•±Ù@”³½xà-EM…ŽÃ/uü*¯ú+¸ÚGñ=¼æ›çZmp Ù¹¢Zi¡Ø«7PîÃLµG˜à.EäIKÝ3 Žyó¢C3Ü3êªMö›Fûüds°¹ @ŒºrÕj *öR™qëÖø™)ˆ™ª¢À¦ ÃÙR`ÝÓ«½›ª¡šUO«º¨Âj7èåÿÅ%*Ã$‡4Ç„z·×3Üø›ö±_žÒg•x°Â×tE@îbâLÇSš-ð…ÛUËÎý¯^öù?ÏSOíòª|œˆBŸîÏ5õ˜òŒšs+LñõhŒsð5›.øÑ‹uç÷Î?p·endstream endobj 5984 0 obj<>/XObject<<>>>>>>endobj 5985 0 obj<>stream x•WkÚFý¾¿â m*–,æ K«ýЦ»Q¤6UÚ~AŠ3€7¶ÇõŒ—¥Uÿ{Ï î# ZÀwæÌ¹¯s‡ß¯ÔÇÿ¦ü “«~ÐÇ“êO¾¥!¾ÑxÊwÓ`ëå’6WÎ2cûl0Ão˜àã¸ÑÂ`Öp6 æþœÑ`Š3Nα¦¸ÉpTáñòS Ç=pvÏ€×794œx'OѬC³† 0ǀϹ``M pÞ¡˰Üsg9Œ‚Y³CýY€<Ÿ…Ç:Ôha0khv!ŸýƒC pÞ¡‹wÈZÎúnqÕ{ìÓ]0¢ÅHÓù ˜Ng´XÃ>*t¶ ÿ>þöîí'ùÊÌD*]¶í÷_E\ȇ8öÄf¾"¶D¼ÍTVQ ¤}dv$RjEi‰n·‹˜ëhªFÕÈDÛTA' ‚¥Ya|NèÔå‹HÀäkÈÓè‡Áh„ŠX·{ú(Í @,Že¦¢6E‚ŒL2•‹ü€òH¬àa§WR±iåó¶lGé-¥Eb éûþòÜ u\b#†§Öö]èž¾bc½ ÊrBá€ññW0·H²Ør~ï[8Aø´“1ˆÂ<|~V¯Gß"ËéšÜ8¦w¯s©‘G°Z³#[D@ã ^ƒ¿ÜÊï*)Z.oÎ=ñ÷Ý3Z¶Kè[z÷~1|ÿËËvçz¢çM䛦,ÿ³¦á&ب8V{æ¦Ñ˜‘ˆ«ÌhT¼$ñ,¢˜09Îx†&šÚwÄÑ;ÉFV§ùxŽñ…çœïjõ„v÷íäJÜ à¨•X¤ÛBln·Ü‹Á`bkêÚfþ˜I«<ÚF)¸ºjõ‡d³\[žxú¤"‘ˆïñԆʖì%ÒìÔšV’ÃâúØÃûó`8™B£Æe˜O¨Ö’t‘eqä}ÄÃs%bÁð}šÅ"ÄB±1(î:.¹ªQz·¡JêJÄ)aºµÛä‹ÉûêieårµÂ!)±¥kGît ûÍJßmô*•üÉ6¹F°ü«.Á.ÈV¡ COÖrÝ”ˆ0W\ýZ!ª%,ÅÑgé†Ã‡buøäšÆÁ×ü(±W_Þt\£Žr“Y‚PýGÔmëIí ãdñEöï>ð"†z7Œ«ãÍ¥Aº 3Õ2çJBkršì`r ~^!·ôT +‰¾aKM® §ú(Õ+~æFf sͶ7 Òk+㉸lntRý¦#V*7”å¸â‚'ãÃHÅœZ©ÜsŽþ—Tœ¯­¤Ôã'és÷3¬ó¹’¹WpÓì<ë(Ç åû²Àm.oªkYv*%2Q¸ZYË —¼u\¶§³Á_*Ð}¢Ò‹/èácy{gQÞÚä<*; º–±Ä]øz`k»÷ˆxè  ~ƒÉhBÓ»橽‘ó/….ÿxü^…öž-øzÌa@é»ÕÝ™ë?/ãSj…;~®ef‚_e#ü$æ;Èt2çý‹«Ÿ¯þÔ„?endstream endobj 5986 0 obj<>/XObject<<>>>>/Annots 3207 0 R>>endobj 5987 0 obj<>stream x¥VkoãDýž_qUµ’ÛmÜ¼ê´ `Ù¬ö°Ä‚ª‰=޽Ø33N6‹øïœ;vZZ„Evæuî¹çž¹ô†4ÀgH㈿qÙ„üÃ?Cþùø¾7ŒÂ{º½›†*i2£î¥ ‡ÞÑkI˜rw4vôZÒp0 §GƒÇï½¼m¿Ÿáp`ôŠnfº Ç4Oi4 è~FÑ”æ‰C; yüu9ÿÔPˆ·$¸°ÛZ–¢^ª±‹K2VçÕŠ®èOoѹ–¦),}C?mܤǙVeû¸·ýoãG¬^‹ËÅå×ÞjÿÈ0 »Q d•ܨå'[J•òWæ¶pwð0‘r“of0Ç÷±aò]ÈÁƒ”äNò³–‚ÛóÔ¦’ÚdyM¢JèÄ_µã6>Mi£m&5%ÒŠ¼0.–›Ù}L8ªñ]8 £ÀÎJY.%h=£ŽlÞþ€z¿džÉ'&Sn¨12!«(Võ–a¥à¾Ý&êN‰BK‘l1±ZKm±*¯êÆÒZô 0„-§¼‰m£%µ@Cú`ùP€ÍcQ[w¼£ªqpX—±B’ÐZl»…Ʊ¨;¦–q. Š…‘&¤ˆ“ŸEYò«ƱLû£Q8C´ÇzܱQ(ý:ùíšÄ”R­%«ïšÎ]¤×4¹2ù©ÒE€eÏhñ@þ‰dÚȵÐaW2–ƽeê7:·O¥Çôûý‡_>¼ßS_kµÎ 2 ‘TpÍäw)++l®*§"Ç›¹îê  Ó£¸¥±­‹E6¤³µx­Âü™¾¼œj¨;¼’IVè•´TˆjÕˆÞ½uAð`ÝèZ!ǤRÆä«Šýà ëíÍÛ7ohU¨¥(¼ØX2¤y¡ñ×gÈ©'Íã—Škäâ†s½ª´pìñÔ§"Ô‚îüˆÃ¨::žcc“ÉŠ¸ê8îÝú6h”]¨þÿ zLg6Ójc^ôÉTZU]M“ÃîÔ[ ÍI~¤¬”6S mr›qüòs,k§Ü]^Z£¦3Ÿ€ v5Ýúpp gÒ´ïì™/g©Îo„µÓœµñ.í¹Îž¨¢RÆ0Ü”N{Θò`†",0­%J/.PÅØûîp`·^26yQ`ød5îõÌr¶,Îβ™7¨¡óÕŽ§ý¾•‚*­ÁŠ3»gOQg²Sä«Ì"7Iž¦RÃ/øH 5ƒ ²„‚q½„»&ð`Õàúò"u¸I ü©1‚,ò0ïà •oº1°{™²O{þ£g·bƒcƒ'c ùÒh%.N{ ½|Ô"70n<ÉMeóR¾cê`ãÃÓîˆú˜â¶õ›ƒ ¿¯X«<¡¥p¢EFiy©_øÎສh)ÉHÔ4_±Žµ•D— ø2U"1^¨ÍµE»!¾ú2ë.GÝVïê–…ŠÇ&e­sãl2s—ò¾0N ›y´ÐAçƒÏÜ™§M’ÅuJyÇ‹O ÏŸÃÆ8i-mW¹<Ýêß²Ç ü3žÍžxÃÍì®kg†w“ðv|KÑ4Úõ,ƒþö*nö×)ë·x;»?mûÄ®ûº§34—©–ÒóÊÛö¡¥GÃEÞáݼ÷sïo>R’'endstream endobj 5988 0 obj<>/XObject<<>>>>/Annots 3210 0 R>>endobj 5989 0 obj<>stream xíXÛnÛF}×W „‹æE¤¤}hÝ8ÈC 4QÑÁZ\‰L(RåÅŽPôß;³y½%i‹¢/EEäáœ=³»sv¨ßF„ø'‚$£¿ëÝ( B¼C}¼{=ŠÃ(XB6Ÿ!ì žÅAj®*x?r¯]`¨‹:×;HÂ0ˆÔ½F4}û D}k·Ói²ÀÏ(™ág, •°A„ÄQ0S÷¢9~Q@”&AÂ"NˆG¥3äÕã$ÙÒÇ@Ì@iœœ” èTŒG§5DKÎÓ ‘0Áù¢$Ÿ$Ä NˆGfT«q<bèLB âÆxtFCÌÙ„f‹4ÀÇ$Ä!ŠL|B¸1ç¸m™âètB¢ÒˆGg4$¸ç= É2¬ 6!qB<2«€Æñˆ¡3 1ˆãÑ )ˆ§A#³®›ƒ8!™U@ãx ÄЙ„Äñ茆9VЧA#Id|B â„xdVã)0Cgb7Æ£Óâ%VЧA#0»B â„xdFÇS` †Î$Ä nŒG§4Ä‹ìD ÅXÀ| qˆ&S!lBzOÇÑé„8Äñ茆ž,ž¤äKÜ Å â„xdVã)0Cgb7Æ£3ètö4h$!_bb'Ä#³ hO:“ƒ¸1Ñã‘ìiÐHD¾Ä&Ä NˆGfÐ8ž1t&!qc<:£!ÁJñ4($Z’/q qˆâ‘Y4ާ@CNˆCÜÎhHOt ÑœüMˆA4™Ø„¢%ã)0â:“ƒ¸1Ñ0ÇÓÆÓ ‘,<árƒ8!™U@ãx ÄЙ„Äñè~\.®°KaµÁw„l‰_r\’_ VëÉuÓKè ÑC¹C3´°“}Ñää ÔM…¸“ jŸ×rß—M Ý^®ËM¹êê {Œ—z¾/ÚæþáÉîÞÿúæ5¬EMLŸj ü×7KQ­>ŽB˜F1 šÜ—}A<»®šÔ5Ý‹=]ˆ:¯H¦ìä9tR}ÿø=ß.&¯ŽBUXYoA‘??fð8о–LxM)„_\a‰š9›Æ3’ˆo,¸\A4ƒ¼lñѦ-kè{¹{ò0Í&䲩ïdÛwpùâ4·1ªŒ²8Ù»[ÙÂf¨ÕÐeÛ·ûpope:h›a[T8…„f¿oº—­Ù¨ëqY­Žs؉O”rÙw*M;¿F'’ãD6›^â:–»²- I´ãfèynØn&6‘²¾9ÃÄzøÝŽJÛlð¬•ÝPõð=¼¹^Å׿¼½™<‹nξ{ôاoªFK‚,›É Åmšªjî)1µûDw¢-Åm%;øŠ(îæ‚—J8) ç¨8Sÿ#‡‘AãP%Îت÷;­N/ ¾köC[Ë\M‰h·¸µ+Qo±Õ¼S;¾“óÅN>¡¾Æ›´Dvm/taÁ­T[²û½Ì)Še‚ ¨ŸpþÐn‡ÄiþF’_TF«ŽYjÆ› À¾mîÊ\æ7g§…} Å¢ŒI¬ûWærÑ z 7c¿.p>qCÓ`fÛ¨5â³þPfïºr[ÓÖTGNd àïØ¥*»®jOP­pŽûa#[¬ò­­‘u%:,à¾“ÕÆ”ˆµ‰i”âO+Ë nfwuŒôXðXcvh ]gö-ãc_õ Ç_¾É2ÜZ?é_ð ÇrÌ<|³UàÐ_õ ô‰ýâ_öŠ—´ŒW”õ~èŸìpg=LùuT‰Æ=m•S»µÿC›øK:£ÿ=Cè'Mê{ç—CÛânªçÊ(í±JvQc;DæéXtö­j¼°P}˜¶|QRMˤv€ûXùÛƒÏLÎá–< Õ†Þ59uÆø±ÿ VÐnfQ•ýˆmux؉`ö|ƒ Ú€G¯ÖZÞÉVÅ€®)ŽñÔùa­à1£ùcg£ÎWc7X «ŽMω­£*Å‹«S&bƺ™ŒòŸÃ1:ÉÛÃ%¹òË—Vµê-2~ÒM`;eµ}C'7CEjíZ,¶Ðái6t°nrì>ï‹r]P§ŒÍ©.ÿ¼ìÖ¢ÅCçµë˪äS3lÎ;•º(ñ¦¨Íæ±#5Š¿«Õ‹ÃY&øû<þ¬f)µÔHOé·éŸšµ:°U÷­ÜÆ>=SôCŸšÀX5äݱ«£ÇÓ›"|ɤ'³,¢[¯V£ŸGAR#‰endstream endobj 5990 0 obj<>/XObject<<>>>>/Annots 3212 0 R>>endobj 5991 0 obj<>stream xX[oÛ6~÷¯ ‚ PÐXµlY²7ô!ËÚ¢@×a­»¾‰ŽUèV]Ãþû¾CR2©2í:ÄH,žï;÷CçË,` ülÑ+)f OÆ_Í[≭ã¿Ã­C¸a`‡™¬·~(? b¼‘‚hãoÙÚ!04l¨xá¯5Ç2¶H”ĵBèd1T&`š?†6¿„¿tºâ6”f'Ž »’8°´+‰¡2Sü+Š•Í¯˕ԆiVCÆRì’c®$,íŠCb¨LÀ4€°ù•`¢š\®8†† ¥Ù‰c®$,íŠCb¨LÀ4ÿ •ióKA¸‰‡+.¡aCiv☰K‰ K¹â’*0Í¿FKØüJ€œ®8†† ¥Ù‰c®$,íŠCb¨LÀ4Œ–°ù•`MÃÇ•‡Àа¡4;qLؕĥ]qH • ˜âiÀÚüJ°Zú+§+¡aC)vÉ1aW–vÅ!1T&`§%кyÿzRðÐ#[V°pɦröaöënöüÕ– ¶;`aE[¼Iáéš»Ä[müØü biÖˆ¤«ÞÜU}ǺÇZ¼¾Ø}†~8êÏ—!ô½?ú®Æ!œí Qv¬nªD´mVÞ±¬¡X!Š[ѰC_&]V•­¯àlƒhÞå‚Í—ˆü O©÷“æÜ{¶-—¤…“äCê~Gœ/Î`&Œ¸9мÍÙþÔûÛ:ÌØy#Ú>ïØ fß{ƒä’½ûøûòÍ»ÝÞ;²¿øÅ‚øGÙ<„`.m^ùQ“5»#z•çÕùÞÖ"ÉxÎîy“ñÛ\´ˆ`üžg9=þLPäï"†ß‘ü m" QÒá…HÐï•áÝ‘# ‚2†w†®oÊ–çZslü`-Ãyž•ÏW¨ýí#«n?#×ìVH£)]%9†L=Ù>%/Ä”>cÕÁ‚x^ˆîX¥šä¡áu-Ò§pß÷Ë)êÕP]?ngpã2óaæXº{/;PýÞg©H÷OZxCÕ95‘ÒÏ“®GίYÊ;N‡XÁ»ä(àú£ŒˆÑJ®47ù“Ðh©»’J‡Ý‹¦E Qþ¿lÝ1“õbÚõ³g°3k/QPÑ4Tº²²íx™ŒÉMrÞ¶,ëZ‘(§Ñ2—~¼E“†CY£%¦:ýÎ<¹Î/ûš¼JPW7z)ï…´ùDFcCΡcÃîòê–ç>F´ƒëƒè:òD×ZçÔ­£GK5,Ñ£Ôˆ’Ý®&âôø0¤M¸Z@áS†p–Œ¶\âmÙËQÞ¯‡D¸óóEœUvàÛæÀyçêy òP_ŒÚ‰7>»BÀòœåYÛ‘S§É“ð½‡áÔ—) eŒ¡9 ÷RïL>ßWä*Á—O»)#~Ú4ò‰ÏXräu'@½CÍ0¼øÈNcª¨`IRŠu´FN¾ç¯—Æü¶or¸Ê^!?y•à †y]•©Q¡ºû(ë*²‡ TþN9,›ÓÓ“5»>{U5P¦Ý¦êîRv†òRdEqðÇ0¦Œ¶¯ëª… è c•§ igÄT$j}ÅBløŠ_n-*’ª¿$!kæcRßcºKV•\X*å§pê 3â*.C’¼¿®Þ~|9ùDáçÒLⶉ*^Ã[„r òÜ&0-SþÚd?jš Ù×R±!¬¨ Œˆ±ïé´;\QÚ¹æ 6 z€ÉÅ'yx;Ìýo$ ·ÈSØÿu›|“d\(.–+¤èɽòÆöžšjªÞiƨAÄÐíô\ºù‘—é¼Å>¥‰ÄÙ5¥u,QÅ-oîmœ.†û =MdSuMF÷ø‚íš¡«LŒ2~H(1çHΫÑ.0\èñö0411‡¦”¨J_úåÄ 6¡¿^­Y„+õb³¦iùáÓ›×óþ“ó[•È+¯´›ÔPÅêô>/XObject<<>>>>>>endobj 5993 0 obj<>stream xµYkoÛØýî_q¸…XŠHJ”Ô¢òòÆØ4ÙÆö¦´DY\ó¡åÊ[ô¿÷ÌÌ%EÒ“4ýì±8œ3çÌ)ÿ~â˜1þsŒçÓÿëäd<ãJó#¿3.>™éx:ò3vF3Xç&Íö„-“ùvºæÌF18°,Œfi¹ôÀ×Më8sPM1ipÞx2rÔ@m§ g9Û±Ì(°*H±´\z`5ŽÓe`M œ¤XÚ>=AÎdΑ|©oRgM Þdæ@æD±´}œ.œ¨õ#OOÝÔµõñ¤‹€±¡—:Ë@âtX“g)–¶*hê Šz„7AQªµ XZ.=0{xG­ÎÖ‚b±plÑkA"©©Sðlê‹MDêÂYµº¿§V,Žo{øI-(––K¬ÖÊqÔÔ)p6uŠÅ±EOÇ‘ºZm<›:ÅÒöQ«Î™ÐÐTFª7÷G.W»èŽTÍ©C¬ÖÊq´Ôip’:Í"p6R®ÖÊ‘´Ôix’:Í"p6RŽÕºÓ äbìµFX¼öT·a]wJwkZmb胹>&™³˜a<4#Õ“7u©tÔ@-·'|„ès`‹³x2¬ ÍrtéƒY§Ç@L œ¤XlØ¢ BÓ/tA(xO?!Í‚ؠ ’8ª Î R,VDêÁg±@·ö9°eîÙò8:9!G³]ú`| 6N˜8¤jùh'äÌtJŸ³ó§¬õ£YŽ.}0ˀ㨂8+H±È Uï¡Sú˜ÝÄòDgOH³]ú`"H⨂8+H±XAlQM¦è”>fçΟš$ÃAÙÔo³*Ýà8E}B9˜_òì.’„"S>»šæ6ËîÏ òü&xˆ6 š%*X/ÓMÌ»*-GË3òã Q~.Sl6U˹9„&ŽŠÒ„¿WÊ!LËY.•«Ï—?¡ ¶Q¸­w¬;ÚPnã ½«‚»Ð¤aUæ¨Îu–>„yp³àØ;êQ“–ŠÔ‘ÀnßÜ„€‹CtwÄ,ªý>ËQ˳‘¹ÜòùQy—ù#—uf‹<ØqÅ0R}¢8–£EbÑI—ÑÖš/¤D¥‰ŠA–$!<6«(£õ= •¯Dh2J‹2 6uq§A¡¸è›Ó¦â™b—UñÆìÂx/2 ЊÀAI¥vÈÄYÉàh[/Nugjç‰Û¦è®šæœ¥o0ü^£<Ê€úS Ž¥¼)â‹‹©uÅLòÆ.:‰þQ­|ºyõOºÇ™x#o‚/®è"U„8Ö?tf3Ø=̇ùÈ™z\f®Ý7[bj¡zqÀQZJ%:cì¯Ók°ÕEž%+²ðÃ|±·Ñ©ko£ëà~}I«„Ð^aDU ѺóéhºðûÁ/.ÿ¡¯oæà]Ôå`àPs*¡Ô\Zþܹc½ òo*ãôSÕÆ†FÜ×$å·«¢ÌWixp—Œõü[1_#Ø/eŽ1pý+´ç¦À‡U} íü‡ç”á«2GYvI`²ÚC‰mœ%ÑX6Y…=Ô¥áwÕÞÒÜzNÈÍ|¤J’ÃgTwŸùú ã: ûêÅE]÷C”ìh1F â]Ý–¯m·Sóäßj A©+¹éžwaò¸ã‘b;ÛN¶_D—Užò\à%Úls¾Æ3³¹y“™4+1§«²vÄÀBGbˆ7Eé&Zcš¢Z¯Ã¢;˜–aY¯bnÁÕÇŸ»Ü4&?ïhòr îA¾!¹ØMD OØ}Ù¡à1„ë2wh2ðˆáÑ™‡4sF-Ý0ÏÑr haÔctÆÑ}øçšÒïò¼2Ä·ìžÇÝÿG J½<³u‡@—ÝË Sp\25\ /‹_ƒxeëtp¥û ©ûÓ©³<û El9E[þ½.‹?/Œ`ÿîÝg9ü²÷´õVÛ Š—’×ùÝ['Îç\(«‹,OPã×È‹5šg§ÎŠfžó¯¤îÙù³ú9WOƒœ~aÊD¤Ï÷?^ü©õ¸Ç5;Ä·I‹?ÆP¦0?]Ì¡åàC•„y´–¼¹cä/ð'Œ¦Õ$iðX~}ùþæ-–[ZÚù€vÛ[³™°1º~v•ÊÓ#Q`7߯ ö]]]É:ø.5µG$Y?<"¯4:œ÷?üô§C>ÍñЇoœã“’„ßd¬ tóDª½é”:ªjƒùòxáQú°B›ìÑR—åóí*'ç&ß.sŽóÜ¢b¬T!V"ŸWÜ×£¼îíN[„„ö¼^¡Òa>/XObject<<>>>>>>endobj 5995 0 obj<>stream xÕWaoÛ6ýî_q•ÂV8qÓ/2Ì-tÁê¸+ h‰¶¹J¤FRq¼_¿GQ’%5¶“¦C1$H ëxº{÷îÝñïÞ) ñsJ£±ûÒÞ¯³Þ0âËú^ÑëwoétH³%lÇoñ!.žãCŒ.Ã7áe8¢ßY¤•¡¥ÒôçÕ‡O““Ù_½×ïà¼<88;ÇÁ`z;›^ß¼¿û0¹™Æêù‰7ñOi¶âû}_M§W_|ØL?/lسíÏó ð:ø%bÛ‰{ »mòïw$ãn@Rxl#R vYùsš¯9àÑ„µK*ÛšŠÔ@~è>©—ƒNl‰ñÓ-Ïc܃t8³zŽD*Í7`÷kH]7L4Ë#ûÔ.Ã`&×bybRߔ˅͵4(ü‡k…¥ÂcU¨*†F½ Ѻê{e?Õö€j ÛV¾]?‘Ñv_7Ê^§Ù‘ÞÅ~, ­fšk•kE.£Ä©þnF€hŽ|uw&³ÞÇÞ¿t”‹endstream endobj 5996 0 obj<>/XObject<<>>>>>>endobj 5997 0 obj<>stream x­W]oÛF|÷¯Ø‡¥d‹ú²n 8©H¿%EQƉ_„çá½ÃîÂjSîî‰ÀÑ)C[iló[…¸Û¹‘ânÿÞÖG¿æ€’teI'ŽB™G©.9¼ŸDóTGw5´†ÛÐ>]¾ÿxÅGJ-gÿ¨çŸÛ·»?õË[ùXÊx)ƒ]ê¸èçCîS…ãZ«ž€w£d7€‘ÄÀ§Fäe"MIò«Œ*Ö-K“%·Ë²ïÞF•1PEjøjO¨%“ÚÆS[¸Y3"‡’¼¦Bú©J­*RI+‘r‘dbCsé6„ÂTÎë·2q+ؾ=”ǹr9½u\ÞßRÈ´•ÉËviYSÉ6r”¦Õˆ$p ·ÃÖºJQÍŽH‰šwPw6QŸª<áÂà3–õ6f$Ô©¨Iß!¤Ö¬±+¡R1™X#¸Œ“µ•¶Ï²lÄ2 º~ãY§~5ëœFæ€Ö?#ÎÝnVè”Û•£Ã¬‹Æ³y¯|ccvÄFCí%Œ°½€ rPÛÁ^nm4¤Ë'e:1:ó ¬Ó°ViŠL³k?åœ{co®âm›×n%Lú½¾©ºü˜J‰’ÄC]^mx?òïî/»»ûcÆ Ë·K”üRêZ±x ‚Âèè Ô*q…}8ñW_*…¶Ü•›ßw{åè<xÓ#ìÒèõAÜÿ,wÀã°ÐãÐJ4"Τk]®Ç½¤é¦@k-èê«Èà{-©ºÖºøé%„:;Vè[U솈D®a/~±ë~Ã2¤kt³L£I7_ŸÐFW”©ÅÒRªõÁlØÕ›ï[ÚÕ@PCë$c÷z[YÆÊ™67÷eünÔî¶T0 ­¤±Üq…m„ƒs®áwNLݽ3F§ž‚K8b–¡Aa°µŒñf"ßÐ~³0"Ôä-kSŸƒVÏ˸"R•Ûæ„ÖK±sHªÊÊÍfµÇb㦹`ý.ÛKÿüñýû]¬aŠÈT.xòcòÀX¢ÓT¯·ßß½p&" þŒ£õš'B7ì]:FÊKäˆðæ]±õs·l×ÿ£¤„Ùšýy8®gÓÞhŽÇøÏ3W|¼Y¬ø"œ-Ì’qÐï43)Ó´ôˆÂb|j*¾ë±”…Œ”HÑZJçqÌÛá¹õ2œ*ŸušÌÒ?õ1>ˆ¨ß¥·Ò‹%¿€×ƒ™WE·ßŠç~^ª¿%½¢›Ë››Ë?fÁ3••uz?`‡ ÇÎ1Ѥ.Z»<b=œÀË ð2N@„Á à͇³N—4¦V;ë´wy€=Q^(!Iö-V¥Dámh¿o}ÝšGo€÷{7ÀЬêÕà‚}ïn§ãcLYÖ}›TGk]h^Q¿81Ð7ø³ øVÝ}xDφª¿^Õ‘ŸxûÕ4vœÚìþ»G,¯æº¸àÔ^¡äÏTœÍÊ]½E©ÄèIUáÇJŸÈ“"bõ¡æŒø?Û>/XObject<<>>>>>>endobj 5999 0 obj<>stream xÅWaoÛ6ýž_q0XMmE¶S']Ñ]Ûl-º[½îC] ´DÙ\$Q%%»Æ°ÿ¾w¤$Gv€öÛ ±Ä#÷îÝ»óç³ Eø™Ðlοq~öãâ, #¼ìþ˜5]ÞFtÎh‘Ò4¢ùÓI8Ÿ_Ó"qV-âà¼Ú—2å2H”¬—(ÞCôÏ£Åßg'°L"¶XËÀ¯Ãð»ÉòѳžÑ¿Í¼aËå%ýªw$¨’¶¢´.âJ颷á\™*$÷©¢¢Òàï_¸’m]^àa ¿}["¶Vôœ¢þeˆv•IZ¼ï£úôÀVònÒe0pFçÉ'tn—Ëb0"5êv ¯¿lÃo3²ªMAªo×·:w—·WÄ»R»ñtÖd*øs# ª6ÊR®“ÑàS¬ó%#,HÚQ–2¡—ÂTu]J#< K©Î2½³ô=cìiÎf`Hù¹VFÒðÐö²ÄoÂûùø8x%¶r0ü¢îÜ?aöxz+ ~z«7Åh÷ÎpHFŒ.o=]šðwº4uKpqº4ã%v{ºtå–p^:àÛC÷ c+I~y™Ià¹Ó”¨4•F‚SMmBÀR[™„´€õ@ƒvÓÁ+Ti22–j+I ãEYWض®s>H ’Vl¥Qq®FM¼lo&è"ÆÙ¢4¥‘ü’IK N­Þ†ô&eÖåâ0ÀÞ‚è{]S®Ö›Šv‚™ŒÞªD’U¹ÊÐÚí¡ÊìÂCœ\iRËn±Ð•­ËA÷nƒ]Ä26{a±Â푌}\4-(œ8Ë=ßÅJ£ŽJ©Qˆw«*‘‘­°h+Ûc=sÒÙ ÚV«ñVx×{lâF¢ ´"ßÁ VPyPˆª2jUC0G\ªÑJ‘߱хc€mšÞARŽ$›«½õ ¢°BŠ@ r6R£s&ðdöqu0ðkVª2;*ê|~‚L'4bœ 1¸™ ×Mv;§ëG nLÐÛÚ$¹NM4ÜI¦Ãžÿ@ÓëètE䯦ý­^æ`ôôu¡í|ÆQ´wžy…ôй3ª4˜2­Á¦bóð|KY lhDè³lPçò pä³X72¤V 1mèòz‘¶˜¼¯y[‚÷HáWÚŒŽ,Á°äȈeÿØÎ3èÈs #LÀWe‡âéäRéÑ3¾8Ôˆº×íGD{2s=4î̺qgÁÒàáé”°ã54jtÜŠ;n%³ÌÒû?ßüp@¡¦¢FÖ $ñ™Øw‚F‰Œ!p^`œ9ºÕ‚x*UÌMLÅ` ¨ä‹ l18â 3m‡Fƒ¹ÌmW€âÙÊÏ J&ž¿×=àdgíÝüŸ Äý¡ï½0›ù‡[§UëÐÄ@õbÁô‘íÇæ ßébˆ@¡[Ð9̤>°e{L¥}»úò=ú8­mãᢆ|·.6<åc¡‡¬ÞMÛ¦u?µ®VÃ\jŸ™ö]{@çk2i%JÁ5à3`±¸ÏIšÚJ8 åD%Ô× pPß„ËÎSîA-é(¶D¦ü}Š'ÆŒ¶Â(nàI4gS̪4çó9¿z½8ûíì?kH¯µendstream endobj 6000 0 obj<>/XObject<<>>>>>>endobj 6001 0 obj<>stream xíXÛnÛF}×W ¦‰ÖŖݺ-:qcÀ5Ú˜i_+r)mLr•]ÒŠZôß{fyÑ¥V}è%ŽÙË™á\Ι™õûÎø7¤ñ„¿£¬óMÐø¶ÿ™_ èÜSÐh@“χþdrFAì¤DÞgÅj!3±=•‡]â‚rQFMËBÚE:·Esaèè(ÙúŒEEZJv»Á»Î€úCX=‚¡_ܼ}Ereï…1=biÕ£ö¸ùðâ_Xÿøj¸ánmër.£‡ûn†ÞÊeÑ£àþõ‹»×a÷¢Òjƒì#ÊZí׿{”{2×ñ{›F+߯N¨õHYzW"hA™ˆŒF0±LT.cAÅ\Ò›rº¢¹±4”¨”ãǹ@štž(“Ùê7u“0³2“œK:q6"mŒŒ â\JšŽ8Š%óC„*r’"¹(”Îi©Ò”¦’ŒPVÆ~­2:a•/ËåößShŠe!MÏi®—&_qAú®f´ÊXx&ia¤uÎUÑÍ…_ÐRâeÂZ5ãcÌËlŠ€a—CœHQ Ÿ-çÛ`Co»ÞÁ°:hSv} Ø6¾¥ª(RIÀ^ô°"«ò¿Ôé>¾¤ß_S¬%ç.ëGK(-Êiª"JÊÜòI%€ûšÍ0Üze¶zõ†P2舵Žý:i¶ØßµÀ¯¯üÑÓú ÓÓÊí0­[Ok¹~°‡HÁ\bºð„ ZÔÌšH—iÜàÓap/8«!Ú¶ï â*[`ò¢i/0 D4¯g^5—¸U°Ø¡žîáüÖ].Õ=<ô–sËF¥ÉyD¹ÉïˆÙÌqVG:™}x_N¶¦ TësN£í;we*yÀ¤ãiŠùâŒ|b\µÐ}T/oQçÈ´Å´íGÿ&žmì¼ã6 ÆoÍ ìŸM>Ýž|UëYãl‘› ?,°mÒ—t0Äçóç{ÚÍ^Ƴ-÷°uö{ÀYSQÔ[Ízyj¢Ü%¨T­EÕïdÐTÐþDJÂ(1E'p!ºEµž³>]ñäÖP³¯Þßw­ïu„p{ÕR`wÇ„ç%‘ç+4Øç Þ×­LlëÜÙÜÚìĪEÛmúv]ÀMa^ŸÁ˜¨Ýq{é§Nðï-¡˜bÔÞœÿz8¾:¯ïÃóÿt|J“s ðê¾p÷Óõ·ý±? —:rWSÁ·'5¶–JºVÝæÇçþ™?Ò¥NS\iÄÍϳêbŪ§ƒ‰?á¸à/ |ô*èüÐù wß×ïendstream endobj 6002 0 obj<>/XObject<<>>>>>>endobj 6003 0 obj<>stream xÕWaSÛFýî_±Ã¸S™ØB¶ÀЦíLJq eÚ $©:Ì!í ’Î9I·ÓÿÞ·:ÉØÆ`𤠲O»{{»OoŸ>´úäá·Oþÿ¢´õcÐò\‹‹fB{#Ž\Ÿ‚1 <~Ów‡ÃC âÊÊ£ r¨úkC¡£è{òž“¢ï¨ÝÇõÙ³°Cu‚÷­½Q¿‰³ïQ¯ר¹–s8˜«Kaæ—2+Ì<äµßM—TØyή½;»ÑH¬ãTäSXËqè´U6+‹.!@í¸”ûbKáoŽ»²¶ºR}Ûíç9¦ŽÞøõÑ@Ó•¤\Œe—>âÃT—ILb"TFe.©˜J²gF}«ÎñTF×—Á|&C'ìØ›Mt‡RM…¦HgceRDE†+¤rëñ. £²Éz‘Å•ÊSÊ~#u›•éšß·M²wî ®ï£í±óU¬S1Cw3t“/e¢@We!ó.gM…¡ÝÝL¤wklº[e“ÛS/Õ sþæçÁéy:ݸÌ"‘$wÈÁ–& \ý)wÂN—¼.œÎÎÂÎÆ˜ƒ*æÙYÔÕíüo©1ªˆt~ o㹈Ú7tê’Â(E¢:b¯]ÎLïöææ¼··½ÚÝì£>äÜ´!¶Õ‰MWët¿DÛØa¥rüˆ2î·3Ã=·§òÂ.ZvïRpy¼>=ù0 -»`gvþˆýÇü3Rà€A>‘Èøù»‘¦" °ÏëòjNúê½ŒŠœÐdËT*CÇ$?” y‚hÁ( Š¼Ð¦b«v¤KCÀ˜õ˜À¿bžÿ?ya¹+ÛXáËsBõä2a¬?Õ¹éÆ66ø\.ø &øÂ<ð/Yà“8ài °FËÙôì?b¾ù¹_ð‹¿pm~W€Óìä~Ëú—ÂTz§a˜;c«RÚ¾uY -l¶…ZVe Ñê÷ÇeÍ;ù5è ÓÅ:“4—…K*‹$ó tM¼.Bš¡t_Ѐtâ9”€â;§jx‰Â*£T¦ÚÌm@FØÉêa#– . !ÖD 3ÖºêQn04“2e’c‚dîÁ€¥L&qä63úFŲ*ÒÆÈ|¦³rŠvÆFJa&;Tk6æ5$ AVgž3£Z}†zAeº¹•HqíÒH›¢„B’ÌÑÅu¸•d*Y— ÚRäJ¢š>Uȧ²n+†û§K2«ÍÅ Æa¡P­bbáÐÔˆ{ÔÈ_7zi/’„ô˜; (ˆ¼é,¬9z+\”6/ÚÁ†ÖMŒ¨2@‰Ú"м-d–+AŒb Bu‰ ‡±¶€W£Åh8±›å{sß$Ðú{°‹•Á$eÄÖ_¼;}I±Ê­þÅž®…åQ ß·ïø4<2æØ¼ç»ý¤£ –¢€»à­ÂZöíëäºý>ë$ÁžŒHdd±ÌGÄI²ë7tý^ß°ÁpxÄK'Aë×Ö?ÍQâ9endstream endobj 6004 0 obj<>/XObject<<>>>>>>endobj 6005 0 obj<>stream x•XïoÛ6ýž¿â>´ƒ“ÙJ·iºaÒ,é tm–º 0h‰¶ÙÊ¢FJñ²aÿûÞ%Ù’ÝdCF"ïŽïîÞ=êƒ!à×Fgü;^¼œD'xØüåt|ý’†§4žcíÙù9yBã¸7:^DxycMVhGK•%©É‡ã/Ç×ÏhˆU¼opú,z†½÷q¬¼±™JÓû>™‚Vf±,h¦)Ó±ö^¹{*,Å6»Ó® ¼²{§ÒR{*–ª€; :#_X§*=<⦿¿yMÅ}®“A½ÓéÜi¯³Bpq`‡Ï“ô>˜,Ö¼ÑiRøã5œª”ÖêÞ“Éh½4ñ²ŽÁS¬2´±¨“¾xÛ4µk‰ami^f1»òb²ôòj®Ó{ʵ›[·Â6ã[¡„32?ì— v,–óM/67…›ô>]¼ýxEvö¥OwÖ$tt”®O~mSÆaj²¹¥£‚±Æþyª~rØÎΩ¤‡]T–9Ý–³{¶«ã"¬>«âéñÓ¶PÑep³ˆ& rÒãëÄØµ0é™HKvYh8º:¹â·úarÑ5h]ìå Yïw£/î;® Lòæ.Z曚¢DûØ™E‡Êse\”NGôfþ¨ öÙ‚ÂÂ:³½wß¾Ý FJœS‡„q©HÙ²º’Ð &QÊ‹b»Ê±dfRSܺ¯u˵MÊçH£';—r­öqƒq½í;ÔI'´pˆlð—v¶OèS@;g'Ŷd @¹'¥ ‰¨«há}ã˴ྠåÕFcР?†Ù+¶Ú @ÿëœ[ ]Èœ2è®Éìdà[ñ‡Ø}‰®Þ~mÒÝ „»)âä·®ÛÞûpÿ '‡µ-”l5’£~Ì:%é¡³é§ P:t2ß5zRmKÄQtvö‚m½áÁð¬Tþ ¬B÷¨T¤DYƒÓF ÖåXÂ(rFÍÒŽ2œn²ÐÉTH®þS­òT?üÓÊ ZÔˆš@ÚéïV(À³­ßöæáɰO­ ZYpÿ…2oTb_%Ê£ahùŸ«¡ßÊs”xØZW(XäT¤yH,¯žòÊéÑ8µÆŒSå}¥2'½£•r_'‡uùL7o˜ŒvßÔ@ˆîf‘úíññÚÜ¿‘¢}P<²¾¶`„K!¡ka¦r¼"9°ŒœP‹É0  ¯°Ý&´9éu\ñã¦s÷M>pgãQ‰Õ%¹³ž#áG £3±mIðǦ¸$íWŒ’½I ÎN¸VÃÓº ÀI2öÿ_jÛ–›è÷: ‡³~;T˜–A64ƒJFKȬpB𹩇mgMž˜î½YðPÁ@ž±w÷瑱ÜþÐÕ•³ž kS,Û¸5gÞí›n…÷˜Ã1nîê{Ný–(+¯uÑÉ#ȵžÁª_êï`!¹À#ºª(>ŒßÒ'¨¦zîÂ9Õ¹% I†/p|«bÙòR±³H,âePð3ªœÂZU„0¨LZY±Ù‡·wÁ-Ð¬Îæq/À-óê¥ÊÊq‡²‚jÙ*à¶HÅuŠßU¶pÉç«øÆ_¸WJ¸U|+Ÿü°š]`QZhhQã1t1ßò*Ë\úMœò)„b3g£é‚àvóaxÈýGæ(Ÿiiׂ¾“Ș%ÆŒÄ[ ò¸ŽŠ¡­äò³ò ­FrX(·`¡lM(Þ¬LªUØ”œp²Bê8çÍ ~GOÉE¦TO=ǰ ›ñíôÓÕåøýítü~zûñÕçéÅííÅgŒ@I£ÌGÖ¥ÈJþo`ŽH$ÒF"`A#t6Òwœrœf÷EÇ×ç‡ÏŸEÏGÏñ9îe4 Â%Þ`ÐÏ6–/òဓƒê«/B}´{~rNñÅ2ììì%ï¿üvð/¥¼*@endstream endobj 6006 0 obj<>/XObject<<>>>>/Annots 3214 0 R>>endobj 6007 0 obj<>stream xÕWmoÛ6þî_qKÓLNmE¶'K—nÞ h;GIW@€@KtÌF]Šªç ûﻣ$¿(N–nûЂ!QÇãÃÓ=Ï?7:àà¯n®0i8¶ƒ#ôס¿ÁEÃuöì躶 ¸ÝžÝ-b¸n,=â»Þ®í.½[<&°ëìڽŻ¥G|çî£o³ù|ã-0HÔìœ;p€Þ½tèýÔ±{½}ð"Õ/´nûW7gÀ”‚#PÀ©Yòi×·6;íãLüÁ}ËoúÍ×MïSÃv§E8í µTa̲,e ?<š+†C ÐÍò;‘ÒäžFå(ÞÑXÝÝ'ú¼ñÃYãÍ«Wà7k«Bq’gcßBÔ-8eš›×Zå¡ö­^¼€94ûž@¶À1×¶X·›Mų<Öˆ]®bûkÂK=›ð„M|KæÚoÖÃЂP¦™®ß+Nž ºýïcn¯ ¹ý½GñG|DÜ9ßÊ¿´1Û˜ûE:[o¥æ-Ðc¦ñÃFaŒd4Ækó¡´©Z 2È3H‰â%Cže˜™™æÐ"ŽIžˆ”êœÅ ‡Ÿ 0R21Ã&ñ€Ha—_½»Kœñ$-`L* S¡ÇÀŠD…s)iF2ŽåT¤w¢Ãj7 &·»]Ûu‘בõÞ·g'Þ»Aའ7o>ýÁ ÿÑ· †þ<’¶66Ž[´FÁ¨Gy©iUg&2ËÄ0FÀBÅ™æˆõÚ»*säùpVn?{åKü‚¶>B»À^¡“‰TIKM Duy@@ØzŒ‚[Hx2æá}à!¡QìD:Éu ¼2zª¦w°((•u²¯Ê`BiˆyŠÆƒòË‹ùÍö1Ž×Í %¤IâÈ1zHF$‡¸ÛºŽTJ"HtæúÍS­f‹=¡âÕØÙñV’-ÈÆ2£¦RÝÃ0×Iž¥?j)üòþæ·2—+ý'°A‚@ñ;í{ýu ο'ló˜'ˆ¿½¹ºzˆÍ(ú×sA/|Ï=´ ô°nü.íc*Á…÷¾õ¨éª°Ö,„³WñTV(8ȶEòçLÝý· Œòj³³~Í"Ö/Ÿ!€ÿÄ[ÃT,mlVè[bq¦™!DXFªÛ3©ü”è,}©ùí£4^[H¿†ÇÏí` –Â5J7-Ì–o]ÌÃôÿFû˜¯ü·ÙÈü/q™©›ÁVÀ43XñJd¦ã°øï,™`QÆê[v¢™ —#˜É¦ 5«uÕeP±6=†Â:Ý2&La¾jt–,QÒˆ©²©¸«XÒ%Á#±*<´`:áØÔHr¼K$ºC Ô1 Ä1à#®È/õ16EkGÈâ˜Vsãxõ „g N°Ó¿®x÷GÍÆU±êê¤ê`c™Öjçü lñºxPÚs÷ wÐ3¨?\^´éèu*ÜJ *œLÉ6Ž…e{¿PW÷ÀÞ·;.œ=4-έ9ÜÐNŒpöI8iöžÓ³Ý.ý02½}‡†Î¼Æ¯¿Îôendstream endobj 6008 0 obj<>/XObject<<>>>>>>endobj 6009 0 obj<>stream x•Wko9ýÞ_qU-j€tÈ£M³»b?ÀR„¬‚àC%pfœÄ0cÏÚž&ù÷{îõL¥bYQúH<öñ¹çœ{óÏÉø7¤ñ„¿òêäÙìd ðâî›_Ò“ë_ix‘]ÐlÕ“ée6¡Y!k4Ë{ãi6¥?]¢7vI×ZÅÆëðpöõäÉõ ±ˆ<]dÓ)žì}¼ÎR¶ _¸œÖzNµZê@ÆÒ»f¾¥Ò̽ò†_ ¤(wUå,Õ^åÑä:£—æV[Š+MkµÅOéýÇW/i©­ö*â9~Oo¢¶Á8h¾e@€11†B/TSÆ>m]ã© ÚZ›²$ë|¥Êr‹_"v‹¹%`l*m£ŠØ‹ΓÁ£š!˜Ÿ´%ßX:ãËœ–ðáà'ðU³œðH–o6´0¥ÎZ$#PZôfXºh9£B‡Ü›¹.˜ˆ¸Â݃Ʊc¥¾iœJZ…­ pŠŽTÑr˜èǽ]ºS劦ԡO‹ÆÊà|W:®\Áô€²\Ù#VÛÒœ¡«ŒI)ÎBªQt®äÍ;†i«r_¹>ôˆ§>}4¶pë@ùª’‹ e)ÛàÉtÕš/wLˆ(ȘĄÔ.¼«D6¸R3a¥Q®µÁ”+ k³ÜÁ+î¡úéªêR÷p•î°çË&"’³·û-‰z@ÓlÜ©z”Çø£èý’x:A(ôӜΉ".ùçµW5 mpèŠq6™\‰¸½Ëe VÁF{T0FSþ42/¶XX~Hþ„±vt6¤7¢ .jÒÖ÷Ø%Šž8¦áZ«ýz‚ÂØs½4Ö²œ˜EPàUøH‹½V¡ °—f—A³¬TˆúÛÚäbH˜´ªÁú8&é°dP®fûˆ¦º³°ŸÁ1É Y ‰ÐÔµó‘M€ ó £¢sGO§+##%ÄzÒ6ÇDô¨À °Ø-ré@bwÅ2â Ü©¥Ýꦷ£÷ééŒáð%ºD§-p˜p·îôæa§âc çrÂNOÙ>œ+Â*&¦·ôµ H5$¬M>r|^ZÉ®ó:* Ä'g gš›ÒÄmÇéÿd…n$ób,÷®ó{ŠâŸ§ ¡Í ÿüëùûÙ»Wo_2®=ŠSôÀž¦/ŸªòÈô\¡¼TŠL¬½[zUq,ËÛ`”·cYBt Dw´]©@]äçÎFïÊB¦VV—Èþ˜g,F„eéTe¦„²ôéÍkxvz´ßm ؾ†Jò=ØÝ EÞøœ—Kÿ“¦ÛtDÚîqÓ;UMtÐ ’<̙֫ïÍu²AáÐ&¿Y·æNæ·0¸Ps¾6+°ëlDN0”,Y»Ì)|Ø X98ZØ‚~x+Þ¤Và\GØFF7ê8‘&lñVêJm;¦[U6:À¦‚Rr%¬Lͽ9®P(6EÈ\CÄ8ï -‡m@~ L •RÙeƒ™BPs÷ä^jƒ Žøó‰*nÚûRö7±hêÐcx#\)­>¿JçŸ.“l<‡¨kr5äÇ_ÌNþ>ùkHKendstream endobj 6010 0 obj<>/XObject<<>>>>>>endobj 6011 0 obj<>stream xµXÛnÛF}÷W ‘ ‰‘D]Û&@‹Önžâ6 ò"ÀX‘K‹ ÉewIÙüûžÙ%)Ѧ#hmC6gwÎÜ/ô?ã{Bþ‚‚ôbìAi?ô=?Ðd2ñÖ´Zy3<®HKŠø&­çžo)“%Ž,yµô}ôözŠÌçäåÒ›ö÷ÐÜ’»(«5ÖŒ>›{ó£ê–Þ3ñ}˜ÙspdèY¹sÜ•Ëäùì¬'®é¡·×»(N(£w…ZzŒÓ¾çàÈвr—pLW.“g¬yö=ôözÅ eô®PKïqÚ÷º@,×_#ÿºr™í{èíõ.ŠjÑ»B-½Æißspdèýº¹xs½¦É˜6*p±Æ!t£ü6ÁÀ_y+oŠì}IQ”Zn—¢,T¨‚Ë!]N.·WW›¿1k!FÓ Ÿ÷2£b/ù©¼ˆUF±¡ÒÈÉî,Z¤²šŠ*—ÆA-j¨=ÄIÒ…ÐN:ŒØ!hhB¦ÐqvïÑûŒDÆ,kHE!Ó¼`¹©%ŠLœæIU ;¦Ñdʺ²š¬eІLì¡¢_¾/Ü =ÅÈÌX ¾þW¹«XíÑ­Š3˜0D߉¤–Y !;¤@eY¤X¾–©:ÈpHδ2ëñÁ+0@è+_Ú[åA$¥(BGÛÁf\üdª ‘<ˆÊ°ê4&*“!íÊ‚”þÂÚCÙhq*=ú(a¬Èäc»Hiz`³á¦PáO •4ÙëÂs‘nõ¹‰u壀Oaôëà–:CHAg9OâŒÀìâNrp°á&S&ì5² ¢–Ä_XÛØüØøn…jCºN¡ RÝ÷ñ¢2³vܱ?·Ä„‡@*¨ÒµR)õ6‹á™_…¦Ðü°½¢Ñ;Ú)eóŒãüyžç¤5µ1²Ò|o±Xòº0ü3…1}IaL_\¶l ¿–þ¨yàD„g+Ç‚ëIl5ìR¤EB"B®²im$9ó<úâz´íI\máôƵñ4GÕ¶Údz3>ö_âcÿ¼›[O¡•”©D-‡¨lÎ^"Nwq&l} ‚¸—qm_Â<›î=þêøö»jâ;|7¦ÿ±&ùÈøÛ¦W»:<©²_4âjk̯ëÈU_9CYâÚˉ:Å)*–O“ª¿çg2u#â|Æ\#ÊI‚Nj@¯G÷%n•ƵA.{)2!à{t/3©¹[úq¹dâ©r­G7Vá&F®Õ=F^ÊUЦ´2:éŽ#Ûy…H©È¹ÅÇÙA%èܘ&Uª¤{4`rò-@£æJ†°F]V«žÛLã^Œöî\Ñf½Èèy"0¹Ü˜hBa§ã9Û©{ ‰õ øz‡îß!ndq«ŒÚÛëÇÛ:wµ½B¸èäø§F-›[‡§§¶åÿ@>mn?mlão¶W–Óf,ŠÐ_¸Ç`£=éåNþ„Á; âdÛà‘yêtçC¡4Žwœ%n8ràÞL£x=X5DV!ßvq¡…®jìKˆnÁãй„Aˆ ±ä ï!Zv„ãL=jßDߣvC>VX Â#©uLd›!¬LËOÂÄ6Í-|€"Ͱ„ØcÛ«Ð.oíLáúQe‘—¶²ˆÓ4Æ*³µaE{^p›d“‘V$2´r}~k­:Q WÙi8éZ`kÛÄŒƒÄ+íhʯ‹nd¯é—ð °¡…´QyÔ'&Í ¾¼ðV«æ¶7¡9—9¬Än£%BÌ'£³ñ: ?¿¿‰z0XyŸ3Zk°™ñæÈó?Ûr™…]v³#}cqdÇ¥˜PÜ2ȩ㼅¾Àz٬֌ۀñÒd°T†R#óBŠ´Jé¶Bd³íU]ÖóziÅÊ5^ZWñoxöÆ6Ã'«:C¯¼ÉÜ.gwwZæúîŽeâUd²Äë:sƙɱ~2yTÓ;\(¤çL…º³ëåÒü9ÇÏoß\Ü?ç`*³¼¹Æ›3Tð¿ßÏç´XM½õzÍÚ³ƒG Òoõæ`+i:žysN£¥Û(_ø"5/<ÿm`ôÅrÊP¿o.þ¼øÁ ë…endstream endobj 6012 0 obj<>/XObject<<>>>>>>endobj 6013 0 obj<>stream x…YÛnÛF|÷WlZ8I%óN °Ý{о¤hk MkÐ-³HY¢Ò¤(úí=—µÉc$¬3;3g–â? ]@ÿBgü¹= æU_ök~ãò€_‹bžÐÛÂí+wË#]Vľæô‡Ô‹|žA 'X¡b1¼C’ÎÓÞAdÆñ|=«%æy:ÏQŠt1§‰ `OS@„¤nSh=§þA= ¨_d’ºÒh);Øh %?MP¬–˜ÓìF(E˜Ñ•E) BR·)´žÒ|ëé¢ð—ÿÉu@ iÝ i´l4’NB«¥æ]Tk.õ"˜ÇhšRô+äÙÁ:+”| € (VKÌó‚>÷Ö\êYDp±Sô+¤Îâ`J>@«%æio¼4Îñ‡‚M¡õŒ.*¨‡ ZRÐ4@„¤n…4ZÌ6š@ÉO@«¥æ¼³Ó œ¸ñ BRG)Bv°ÎÚPò)2 X-5çWkΕdj3B@O°BÞYàñf„”4BDKqФáò‘d)¾ñ m ¤Pë¬- Ÿ ŠÕRón©I’ã-"$”"cë¬- Ÿ ŠÕRó”v6k.õ¨ÀËG€ž`…¼3;Xg€’OÅj©9ŸÁ¬¹ÔC^ŸÀ• 'X!ïÌÖY äSd@±ZbðqКs=^Døô€ž`…ÔY¬³HIS d@±ZjÂ#NœóF®DH E¼`ë¬- Ÿ ŠÕRó®QqÊ{J’:J‘³ƒuÖ–€’OÅj©y8qÌ{J’:JAǦJ>@4… ÐGÜJI!u”B¬³¶”| € (VKÌé|€¾!Åt€ß BB@)ÄÁ:kKÀ§ȀbµÔœøÖœë@ài=Á ygv°Î %MÅj©9ñ­¹Ôé¿çEè VÈ;³ƒuV(ùP¬–š'4óÖ\êtЧO¾LFè VÈ;³ƒuV(ùP¬–š§p¥¢^i BB@)È®´Hɧ@æ¼;+¤ˆrxŒBÞ«À…I!”B¬³N,°ð)2 X-1§óZiÃEŒWZ°ÖQ q°ÎÒRÒP¬–˜)\£Â¬Àw7DH6…Öùˆêi€8!DHêVH£eì`£)”ü4d@±Zbž,àòƾñ BB@)ÄÁ:kKÀ§ȀbµÔœo.k.õ0ÁGœ=Á ygv°Î %Ÿ ŠÕRs>â[s®/2|ßúãp«âmYÞÚ t4z‚cü*Ÿxê¬"eÐþ‚Õ­©4d´{ô+ôÍÕÉٛą»ºuôÁrzºNÏñ±»ZÑÂÐWËÓëë¦mþ©öíõõË«¿NH-Ìé{9õÀ—\?{“z©™2‹Íxà·åfSÞl*øà¸Û”ýÈfIƒÆ\ý´~»ÙTË®n›g6U36 âº»cÞcãîÖUWwÕvÌûýIÎašsñÉ,oÛj_/Ÿ R®Vã†^O÷s¼ŸMßÁux59|U¿«ŸMß¶ ÷Ï&‡“:dh}’¶kÿ7õj:ÄæpWßvcÊùù¤Å~‚ry9I)ýóÉáÚý¸£?'‡£ÑÿNŽnªõX|öÕäø]{==¾¼ã©8iP7ï«=¸ÿ=ÃûöºždÜnÚsn'9˶Ú/«qv­3íÙµïëÕªæ•éàêÆ…óxÆÊ™X7 ¿éá4v.‹ \ͪûqŽ‹éákÐËô§{ z¹Tqzn•´ÜóŽórÿ¶í*×Ý•+7Ý]{\ß¹_ûñw8îví¾;V9':SËE[ÄCûý¾uê¶åº^ºmE*+×”[ú™ºÝ»Uu[7u³veãªûcý¾¤u~Y¹vWíË®ÝÁôÓu}pMëÕ®¤²ìO¼+EÜ¢—dµ;ºq7¤¦ e Ñ%írSwí%=u‡šÝ~9Þ|t$}¨4Põa·¯‡Ç}ªW*Ý‹ wóT¥”»åìM?îÅ»ÓÒ]ÐÐw/Ÿ žë{ú=[f+ èè§.£ÇTar žàù®]Ò&ÓtåÃŽ9{=Ë™½:¥çQüóøO~¶\K·&Ý:+?i@Ïé1Írù<uòóÉÿôâcendstream endobj 6014 0 obj<>/XObject<<>>>>/Annots 3216 0 R>>endobj 6015 0 obj<>stream xVmoÛ6þî_qhXAmù-vœ ûfu É6ÛCVÌC@“”ÍEo%©&ÆÐÿ¾;R²-¯ÉÖ"`‰¼çÞ=|ÈOtñ¯ƒýó¤Ñ »ø…=zL¯£~8„>GÀÙ8ì–/1Ì{¯ ôzãp°7¸ÿŽ£Ãa8Þ}7ßËåêt&gÐëÃ>7é‹‹Ùm’¶+þ N©¦wXl2X³Ïø ŒDq2K{Y\iÿ·*B«ÏR|‹>/XObject<<>>>>>>endobj 6017 0 obj<>stream x­VioÛFýî_1èˈHQ”%ËJ“IãÂ@Ž6U¬È¥´5ÉeÈe"µéï›]R—-§( _2w9Ç›7oæÃIŸ|õi0âï(;y6= ü7¿Êõ®ûš&¸<ºìû£ÑMc{) iÔù†Î¦œô®úíµNYÏ×$W&Òyâ—sw¼cÅë㟕R•/蕸•‰J%_ ¨9½k6õc¶‘—ü|ýœ¼yoBò®}üôêªì¥:i/UóÖëû=5¼TåõŠf³=·ö½ˆª¥(äûO¥(ühµÚ»±ˆ"òp^ʘ¼—ûÈÓîU¿j>87ý;®R ”×þ‰\rçÄð0Ú^8hÐî¼ÖF’Y C±,d3l:§µ®KRyeDšKwqI’®MQ›Š2±¦¹¤*U‹¥I׫$‘¥ÌÍc¾Vm/"<Ñx’è’½dh¼¹¨dÜærÉbùQ¦ºÈ`‚dþQ•:çÏ>MáaQ)«:5À@×i̾ãÁPÿR”kšu–¡Ûü³Év,à@mƒÎìŒÀ"#TÎsnà•Ì+¤J™ŽëTâ<–þ^”¯õ'R€]xCUT”:’U 8YˆRÍX•22!qÎ0í\Ûˆè¹*#GÊÞU[”Nãu—Ñ5^xθ¼­sºywýM ™K뀣e²´A"uçb“td=ìÑlÇÕìì1ßç~Fq§ï[Ðð¯×·ÕxW*ä!òC,[o|•ª`TåjæÕ•,+Š`Ÿ8Û˜\º¤8™W2R‰Š=ívîNä-¢Ûbígfò¬V  vÀWÔp[vh‹YL‡4·ú°IØòbàÀ¹õÂMÝÞä‘d N?Jš#Csm–¤Ž`l½:²U]¾m±2²b eZ<2 ½±f’]¿}fa„ü©2shsnñްƸg›€QMÛq¬ºpÕ~ˆŽqƒçàbHµˆÑr°…p”Q"UÊØrvOν0ôh{|Š«ãÊ£Y'CSÎÎ&AПO›Üvf€üP£ÁèÔ6öi›úf’4*oÊÚB°‘ý}Óღ]ûüWÛƒûlGô¤éûÉÄîçòÓ¬3ì¾Ã`vv,“¯¿s÷Û÷&ÁJ—a0~ʯIðüÞ ü[•Çïuò=YŽL&;T¹;G¿€áð~ i~A_å3ôwtIÌ?7†í<ŒýK,7VÖvˆ«¨ÿÊjråÞlYÍ“ìÜ·B9E¼åõ ù¢ Ȱ–U~Š‘Q…. e˜ª€®«ƒBí¢9 ) ?\&Ì:<÷!´*S+ BL²Ê ¾5}ÊM©¡`Q* üu…Û*XéäN«ÃŽTy”ÖñžÌ$fcìӜȕÈ]—TbCX H‡p99gÍ”NTαæŠÑfªH-÷áé XLp–"ç©KÒ_Xé:Ö­ÎÓ4mRv@–ƒd§ãÈd6g©B¿ý~p†9Ð< wLµ±nÈKÔñùŒþ¢ÏÙgZ+ õÎèï£FYÊâNãd;(˜› i«®(«:Ý_¦yAqçdž3óBŠJA E „Öô¤Î¡Ò:‡ ÍÄhfŠ<¨{hï,ºvÛÌâÐad›fe¹k$ï UÚBüp¤ÎØ=uÚšùÿ+5å%Ç?ªD†É‰'Awò°¶ò*ä¹Õ'vøÊÉi·Œ»ãð[Ô\5íÒ*G§ÙÒ0Z¹^n AéðvÏWu§û[þÙo•Àöãv!…3·`¯Ñ×ÙlTÌ5>/XObject<<>>>>/Annots 3220 0 R>>endobj 6019 0 obj<>stream xXmoÛ6þž_q00ÌEmÅ/‰ãt†4­ƒ}ÙÚý  %Úf#‘*)Ùõ†ý÷=GJ²e·i7¬K+м;>÷Üs§|9Òÿ i<á?qv2ˆXáCþñîæd4˜FS:]FÊht1ŒÆÕSJïOöŸ3‡ÑÅÞÛËI4¡ÑÙ9Žàå` «'>úünÏ›wi—t:ÐÛï4Ðd:Œ&“ ºK|Lº‹»q*œ£÷² ¿ŸÜ}>Pˆõ¤›—óTÅÏZkD§§tm´+lƼ„‘ûîý“ߪe8„æ¶VÒQ±²¦\®ÈÁ_&³¹´îÀÈÚ¨„¤ˆWû¦BHÿx˧³3âçõá¡?WWê¾.ÓB婤Ì$e g±Ð4Ç£ú*Rº0$(\w¾¥ÜšµJ”^ò¢É2Ñw2eB©r™Eeˆ´È8tƒè%q¸Œj¡û ¬+븺”(+ãB­ed´Œê3»LôG£hi=Þ¥“IÍ_ma,€féAéÄ1¤µmyžné¾ë$ßBå` í!>(P¹Û¹.]a2õ—(vÍê(½Ë¦Îj惈Äþ3c%%²*u÷OªT\Òð,:c1ƒ¦üϤ;žFHêk‰[z-´XzxÚ¹åýgÑtÊÞjÉWâè3Æ0˜r®_”¦¥ÔÌû[š<8Ø»,D@Ä÷F5°ß¬ñÑ ?È-3/lj{t€Å©¸&r¡4ûݬ¤O€ äpäýšùg”ÌFsMJ*u"qŽO\S(ox×OŸ†ŠñÁHÿ‹i’çÔ\¥ªPÒyÁ€ö%†ˆ¯°ï!‚X9$DÍQ©œ …•’ýr‡¾C˜!Ãi]öÐ=@Ò½AÌÚùáwý¡gß¡o·2eš6…÷ùˆC¨F,ÀfRmTš²Šp˜ !eGpÕ8™Dþ—H™w— N†Ù“Cq!@\W(×£]šð¸R9Þ +´[ “ k²€.©ºï"–µŠ%­±_ ™KÏ9®« ‹Å¢ÔP&ø£w=$$(6È›S˜kLÑ©’Çtœ–ŠÔÄ"mÏZX%P ضLÍ\¤t¼sǺÀž•°É†SdåM YöÔµ#⇈fÈ,7Pâ0ª(zß¹ú0”ª8€Ÿ1Y¤5 Å·%ÊêÈSwØþìüÓ2þÄ ¶Ë°Ë|㨃ƒ–}6s&CØÙtÐX tÒÒ:ôRÈZÈVs0ÍúZ‹ªû’³œg+Q1R£4`ò¾«–ÚØ :uÞ2µkÜ8µR$[T>²Ïne‚îIÞÛΙ%tJÝóu¹sá{^+ Ê’KL]^[]t€\âïÔ“HøÙ¡‰Êäé„H¢]-¸Y2“·D5~PÁb`³_èÖÏ'(€ ‹|hï}Ï»UÜr aÕ¿[®# ™yî·ÀˆG-Ö`0jž‡fø|óáÕ«ú\è²· ˜>ìaÒmHÉB±­¦±½ò€¦À†Ìã¯êÛ_ ”ðá­BOm%U!+…Zl½¿Æ}²?8'ußßi@se?x3ZFôA»ÒæVñ šn9hÔQ OÃM¶y0ƒV{Ÿƒ””UíC«¹|:*¥ºGõÅnS«Z¼¥DbH2Ûj©yò­Ëõ†tëj@cýñu„Ø ÿ_ZíMª€ŸAÝ#ùìóá €?·î»¸-¯ì(œä´·"úF ,©?yÏ€áãá…†Å0 ‡TÅøÌ"Í1ùO|é½0Èâb³À 9ç.|΄òßyЊ0=YéÇýÓY=šgÑùø¿hEÿÄß”ý1~×ñÂÄ%múæÀáë=lî_„ÏûG¾¿Îñ»Žñ( ý“‹ ywòçÉ¿Gã“dendstream endobj 6020 0 obj<>/XObject<<>>>>/Annots 3222 0 R>>endobj 6021 0 obj<>stream x•WÛnÛF}×W U‹ÖͲ"u%~©ÑX…_ ¼ ¥MH®ºKZ1ŒôÛ{fIJ$}‡/àrwçrfæÌðßÞˆ†øÑd&¿aÚzC¼‘#ù÷õso2z'4šžzCJi29õN«UB—½æ»'SoÔÜm¬Sš!³±Û\c÷hÒÚ=[4Œq™%Χ4Ò"sg§xŠœµxûW+Î(ô“DeKòé÷ïIß8̵êÌæ¦sm(6:¥¯Epw@—WçŸi£’„|kÕ2õ½Ø0ïQ\da®tFùŠ w”úßE.–în%úÝâ[oHƒÑ–ô Û5ô¨ aŠ"æúÎιr8SçÈàX s÷¯Ç³c*·k7es0žŠôGÜK9 ílõs2œ&³pe­U–³iº™éü-®¶Ü+²ˆMr'%*0¾¹ƒ®§=.±÷Þäî`|‚ô ¸px¡tä LØ7âKÂÏDëïgýŒø‡Ÿ®öèwk‹”iôòoþϵÆOg¾ĸ2gH'ÞDÒhŒàÇÞd‚UÔ?ܧ¹Bðö$;.6 Wjý©R°Ú£ýà ÜÃy'RÔÔ8¹·÷­Õº~h½#¹sÝ¿~G÷?;ÿ=±óó·ê`S3Üj]okvZh?Öú¦¾,)õ7 ÂĤH]}sÝÏxã¬|ÌÆê(ÝSĈ‡d;tP׸²OKÎo°]z[%çKç¡ûáÊ ‡jnµŠÈÖj Ôù,à¶Í#é£èîÊ(ÁÝ‘ËÀ¥ÅÄ›¡×\›8Q(2!%Eð*bÚÃù6¥ZeP ›<˜/±Ú)‘s[çB4’æ¾åƒɈ|GiÖ½kT`) têH¤ mé}Ç Ú©öó’ ÐŽ˜ÛS•1ÝÍØ/ ±¥M9¼¥¿ŠB…!E´¨¼ýV=rtÖaSKßþ^ë$wsTÂÑ¥eGÚA G礲–9‚%·KOèzú0°JÄu“p óÔ¡ \ýeì`ßkG÷7&GÙí:íà ës¥­­©ï=Zj´Šn˜ê.Ù»îB-h´‘vܽùX€»©-­²´q›ÞOæ¥dŒ34Ž]²´ãöO†6œ™Ÿs‚n/Æ ýÚh“DÛ«–¬’‚ÆèŽT 4зè+s´òêݳµþÚ€£8jvk‡â… WåWV_ÀhrJ† üÕCO'¬¸¨²Pp$.­Ù…ìJÀu+}So26ÒïHÇ­À–°I9qT=" ²C´_Ô`¤3&°aaëiçøX•~¤D¹ /™]`;C&æº>]¸I­a„4îgÐv6­ÇÁ¾ó>Õ†[+ { šÓY;Ç]5”©¿^Ãf„Ú ü‰Õ;¸ð„lpNÚ7rü¶ÐŸÎ)þmËBv_¿{&®TŽHå”êHÅ*tŽI6‹qÒ †~aeè±¼L9ËÝ!r|ÝåÚRÓ+jk©Ù’(Ö1ÙP¯Ñ™T^j“!YŠ¥…{£=½¥†=ú¢7|+Ã]›3¾*‹ž1ű»ä¨è”+;‡<®œÅ-C]¤kܽ×bRÑÚhÌø©”W¾ÂZ¹« Ù0~fcFéE凘Øì‰¹Ÿ)ÎûÒúã`<œzG“#š¸‰Xrw ŸIê%[EY®`b)OŽË39ñðá6®ëê¢.n9|4œy“1>ü0ÛÌŽåÕ§EïïÞÿ…0qendstream endobj 6022 0 obj<>/XObject<<>>>>>>endobj 6023 0 obj<>stream xU]oÓH}ϯ¸ê*’;±['„KƒúBa±„VŠ„&ö8Öž13vC©ÊoçÞ;Älº‹UöÌý8sçœã/£9ÌðoQL¿´½JF3†‹‡zÁúæ3HrŒŸâCf÷ñ!õš‚Ãyòy¬±Žñ o>åJ¹Õ>ÓƒŠ7…Ê@HYYò̇¤°/¶2%9lï 5Bî€ªšš§‚•ðúúÃÍÇ·ÐÜÕ*V?}!ÒöÌË2žA£lü_-¦o…̰€¡æ3˜ÎCë >^¿™ÎýÈc¿Û /h/)Zó¤Jkž66„l¸ÎYÊ!%?ìa÷šÐåJSGƒ;%3†<ÔªÂÒhR!vC?Šð-ó‚ ¬©a¼ÙK®M!ꫯ¬ªKî ˜=&®7®TÖ>= ¼ï^iò™÷‡iÙfÎNö)ÎÑã‡A-{X»{£ÑÙ’Ãu»-EjzˆÊÙx›ógƒêßO®?ôa8 „캾bz<ìj;À)õ©OvàNÃÁb'á<²Ž('°s”=äë9tI÷h¡Œ%ß«íg¢ %àñÜb"úÿLpð,nW» ý¿úȯòÎR0ùûÝL:êß#F{~7¼Ó½n•È “ÞÆë3ºkž§‡7NKÎ4ÝŸ­þèAú¶½–i Ó0òãxAwèd¬w)³Z6œKÔ˜½Øܱܹ4š¥ÿ †¬ƒõS …’¯LØjEK>Cݸ1']8±ãØ…¦á…ßÉ—ƒæ’„Y3ÝP9ªÅàE %a/Ê}…[—p„+ÅV3}¦P{‚\ª=Ù¶!6èG"Ϲæ²Aߪ†VL²¯h¥ái!Å—–›ÞKœÏ$èZÃú(d^¢OÁ7œ1“èU¤¨®ŠE6ˆÝÕ9º×¡{ô~€E’urÿs<ŽãÅ@S?woq.J÷»ŽÜ‡Ý3lâÿŽS¼´§´©µ¸ÅIþêäãÏÁ4Ùjå ü;«Ö ïªáÙ¯ ŽŠô×1ì÷h¦…íæ ’Uü·,)àO%1«Eë@0;;$fS8ªR¥Á(¡ÅÆCŠ$JÁôÄ6ÜœÃÊuÞx”†ï÷ÖɃõ²ûÏ—þet ñ"öîd¿‘?ƒ×*m‰ÄŒ¤A-QÌ.zºp¾ð¼œÅ~¢ZQ©ñbIéWÉèýèS÷gendstream endobj 6024 0 obj<>/XObject<<>>>>>>endobj 6025 0 obj<>stream x•VkOÛ0ýÞ_qÅ&‘V«ë$%-*£Ò¤i¬Ò¤-Så&¦˜5IqÆCü÷]Ç 4éC[©*ßÇ9ç>’»– ÿlp=ý ãÖÙ¤E Å›¯?r½1…!qar ïÐ&ž7€ITXQ˜„@¯W\å2uÃ%"f‹ý óöä¶E¡k£e„–ašd Â&;0çjªM+h—Ï M}Ÿ„ÓLI}z/µ8/Gå%"°á‚eüHÓšÑsíj)SÅCÅ#¿v2ùþ=ž¤ò؇ÎÉÞÞ¨d‘Õ3-óÙB„šþ¹æ%óP¡ðx©á©4‚ësÅÆÀGý:p.9S¨$üO™›@§W‹h™!œ wt@ß Ï©X« ê¶¡®à§Rs™Xel+ºU½Ööà4Šj0A¥EÙ×ùÞ§M£è[…»Äº ™9ÊÈ2Ïn¦3þ¬Êúj4ÁUá%Ó{þš5O|ª@`—­+ñæ“å 'HEdÝQ ã§øÕTàRq9y\røOÓƒÌø\$EÓ6Ђé5ݳ$Ħ×Þ4ªõ 5 „K–•öoÆUë¼ÖRrM «)Q}R“<ž!…ôºêvf„×kYŠXÌl—Úf«£»F·l²RJ¢#˜anXnÇÈ`™ŠD«\ö˜P7%ÔFŒªŒŸIX+u7C±^ý:D]ím=fÂ,žÞ¸úúºX†®ã–+ÑúÌ®½Œ=ÂcšÃ·ï—ŸŠvÂåéµé9I@æ \^[de»êHq]\µ‘õ¾ÀÑÛÕœiÎuƒ +fØvmŸRÛ§£5oÉïr!9ìó/|[¬“à«Ö¶é²z|gS|%æ\Ú8 &¾ï›Š\gµgŽ÷‚öŽ´ïŽ¾>}pfÜ:tTV{œþv8dõ ³#soGwSœ’UƸ Ý¥‰†#eÞNŽÞ–ìdu¹ïLˆÅŠƒmI6Ìü1íÿMQàvPH”“4V7ÝÉgsÇD}f‹Žé‡åœ:´OÜðýjÂôtv]Bácæ1Oô“5M4xjcݘùr‡Ä¦ø ôev‹/ 0‘øXÉ\ÛP¸¾FáÌzƒC}ëbÒúÚú Ëâ Gendstream endobj 6026 0 obj<>/XObject<<>>>>/Annots 3224 0 R>>endobj 6027 0 obj<>stream xWmsÚFþίØqÊ'FèÅ`›6î$nðôK_b:™iédiŠ%9IƤÓÿÞÝ»“Œ°¡uDZá»}yöÙ½G_:¸ôãA0âaÖq—¾á?ÿùpÝ^8>áãBžêÐn½Jᦳ½¦§£Sg¸õôÝtËž6ª0˜¸pî0ÉóèÂsF£3˜FÚ© Ó°—¨ù¬—‰$Ÿ]÷|ì^Âñôsg0ñês½2Y ò–Ÿr‘á¬7;6[¶L÷=²õÞ\‘Þîñú¾þ¾íåb¯ÏÁ/•H¿ŸY§=Å"-ÐDr ìŸsìûͱ÷‹ØÀJ¨2 «T(e‰y™ÈJ å!”Úd©ú¼q»/ŠÚKÏŸd‰dD”ÚR¹–ð¡šo@Î?cX B.ÍÂ0ƒ>Ì+½ÜX\<ŸñR£ÂÇ`Í0ëØ&,³%\ŠGj2P[ÔéÁÑUU'’¯fÜNL|… ÍþZ´Àn”J÷nÝ‹«Ušh–Žº›úóM_€¹(–rDêW:+!Nî5—íÝÈu¼{tC’:é?\‘ÝLFA}ÚrÓýË.Í5ø‚ê–V¤ެ}gY+³¡û·)J#£Ø“ÖBƒWD>ºôDÑ#XS?¦€Y1‡s\×5h¹ïÒ#Kýߥ[¾mÞv'u;êÆ÷# ÊŠtÌ ™ZÆ{úh?-i3ìîg0©GoÜRjvðP µ&ãÖ¤‡ðQÁZõúÆ6Nƒ1_òöÇÒ´-AŸT)ŠÄgBÊí¥­éË}¶Hæ@u'˜²¶íï×+é«÷V¯ßêáàP5g½Z8Ô¼/¾Û9;vïý9gÑùe«ìíp‚§äÓW)·c!"™@þkÌ<íÝÞAï§{¼;"Š,ë­à÷ú>(<ÝÑS^Œz¢4)YGaF3 ñètöoH&çö¥ÁwéE,Âè¬ÛÜÛý€^â~aÕÈL.1ßìAœ;žKoh?ëW˜ò=IØ÷Ý‘øôRCòdtîòWï§_;ÿuL#¶endstream endobj 6028 0 obj<>/XObject<<>>>>/Annots 3227 0 R>>endobj 6029 0 obj<>stream x¥WkoÛ6ýî_q‘m¨²ÆŠ¶ãxk‡4«³¶5îŠm Z¢-6’è’RÜô×ï^Rr$Åv‹ œÐ$ïãÜ×ᇞþøŽè7Êzžëá7ôáÓÇë«^èÜ! w„áÈ ì"…›^c‰{ÃÐõ{KÜnØØ{Xf0ðÇ(Û( ™%î Çî ±hK@çqoJŒgÏ¡P%§múù®­e¼_ <ƒ\¤DW»{$Ÿï’|uéê‚©âÿJõ½]R *îŠïr–ñ¹s#‹áQŠªŠï£káhŸÖÂ*`ÎT*(©9l LqyÁ×O@.Þó¨@ÜYt+ò "[§<ãx(†Å=èB*Úy]âÂÇ390H˜N `‹”Ëc¸å÷t®Hx2‡Ë§Ok£ŠîZ½Ú…Y¡Ìc®Rsáâ÷kT;逌áïcΆ!¦`ì` Á1ܼ½¾zGÖ\Äñ¬²{îÐÖ÷°.Ô üyñêÍËÊÔùñµ&Ÿ*AöÈVÒuŽßçG¬’æÇ°órÛŠ×<“w|‡!{T·o¿ÉS‘ßþf¢ [ºêÓiSª‡FTß&C×ñðEŠ3Rò 6"M•…Ì8–¦÷@ŸªL±O™dq¶(4ðlç“ÇŠ]¸™HcA³‰vÌSÞ±æ³úÛHvLpá±ËŠ¥Ê1M iÓs©dF‰wb’Ä‚Pbæ£×V\í4bé;·Î7R £¹rž”ð\—X@ ó›÷ ÙÇ?±õšòÞè6E‚цºV\xÅtqrÀºÔʃ=”&W4ªoÔ¢Õ+ Ý,©õ.É¢ÌP]ç°â9W,={YZ€dŽÉ‘s c…ÖÞÙe„ˆê ;¾P(p‰½gÛN¤Œ©[X–yT™£'º2ÏC'r“§rãÂ/rÃï8–³X[·rh¥€N.ç isGãÚ\ÇÒ%ÿ2v,Õ[ÕfÜÖ€Ex6LEÓíÚœ/Œ¡6ñ8žyl;õˆ"Ž]ßÃý+4­²Jê`ˆgðø[Q$˜ Q@&1# lçˆ/Æ€P$¬‚)J™ÖŠ…bŠz9µìÛ°Vûv†Ý˜æÿȨéîÁß>šï8‡j¶T¡šå­åшzt»ÊxRi²OÖçyA@òí¤D`å<З•w“‹\d,us¾™;õ`=8}¿ù±swâ} œØØŒ\ŠÈš’9Ÿ¤&nŸ¿Ü¥óÖâÝ~9ëýÑûE’œ«endstream endobj 6030 0 obj<>/XObject<<>>>>/Annots 3229 0 R>>endobj 6031 0 obj<>stream x¥VûoÛ6þ=ÅÍ]åaY~Äqœ&@›ÆA±nC›tÅ-Ñ6It%*i6ìßw¤äWcØ’@)ÞÝw¯ïøm¯I~›Ôîò_˜ì~€~4ùñé†w¨Û;Ã3¡vo±ˆévïíÝæùlJA‡šÝM ¸{†—ÈêÃKè ¤0E&óÚÁÝ×Qk¢MtF‰Î$EÒçÃߥz«MÞâecxÖ„—ˆìÞmUV¡¤HC£tJFÜËœå*Æ’D6-™šczœ©pFŠ¿ÍµJÌÈh23IWGG¤Ç_ehh,!Fl@Fç¤ å3]ÄÑ1)h.²ô˜BÇëxª7[ 4¦áˆ…‡ÞðàB¸)Ò'hÊHC€43aPR&E8cÀd:±˜Â"Ë»ÄåÓp²æ¥£6]d›ÁùCëMËa,ò¼ô„¿-ÃùLB¤Xë9éÄ,â"R•ìØðä6 @ò§ÖåÖ1‹ÞS1g •ѧbüTS~+ÔƒˆmôEñ‰ô?Çϧ_S‰Ìå¹â@©dKN¬°YWy¿JJÏos!¶àe«å·ÛXEÞ~¢£bò»`Á2 8Ãßþª‚b—¯TÆE$©Vög®t‘fwþï5ñÆ!ý$%üÏDxÏ¡KÄ|Ž*ÊQLæQÂå«WXn²"4yÃfCæk6QÑjè-MÁJ—ž¢p×*À§Ãki šT:Í™u-š2kçîT°rÊyè·sªÉ“Í÷šö]Êù 7¡Ø¨Æ«Þj/ÚÙ9¤e fRD(¾E*Ü6Ũ´Š¬ëleèñòæ&ÐzêˆÚê¼ ¡Ç œÁI‹Œ ‡ŽXT<7_U²¶L%ZµJS‘ÅYÐq rÐÙzÎpý‹,q Ït1u4ó]…/é%©ò´H¡ ´x^0ÚúåTšQZ$#×n9óÇ&fôéÐcA¡äD¯Žs::R[bAôÆ6ï!ªË6ñŠ-·}K;®p?¿½ùðùºŠÈÝ~y3â¾~_2×€‘”žÁ„sľäÓ.ècªâ­èˆV Ó lƒSµ[p}½¾Ú·Ëå8âŒ×[m¿Û=åVÿE¤©­:‚uNh÷DÁȈä\¦‘åcÌçò.DŸßþ>Z‰‘³±Q‰43Q⨰ÈQ) HLFWHöW;xS•ZЇ<2åáù„̸QªR”Kb¹ñ˜@x"ç)ƒÂ¬fžÕ>rA÷™£"ù:8ȹݼPF®Oä/Läf†À„Diÿ'sÜ©~¤\ÊÝ„üc™‚uy*W!Ød3|"G*ôƒ Õ.ŸI5•YóâÚñ{¿ïJßOåãЫ¹µj&¯¡+ª‹KzõzC¶|oe{<é]2®{¬ƒio³Ðrþ­i8»ÍÓ^°Ëng›]P ¸áÿ[äY¸ÓúÉ Ö}E%‡ =õžƒvÄöl›§n–²|/ܬ¤s§æf°MóÍ•“™—ªp©µ1è•wÑf¯ãŸ´OpYîTW îœzwæw:´WOÛ…¬däN×O]ÙájÝ üýÌ»Ayƒµ­}týv ·iV·×bé뻽{ÿP?\tendstream endobj 6032 0 obj<>/XObject<<>>>>/Annots 3231 0 R>>endobj 6033 0 obj<>stream x•WÛnÛF}÷WLܦc›¦.–¥6›S?4i Á’\J›\…»´¢í·÷Ì.u¡#Û(â¹;sæÌ™Ùá×½Eø×¡Þ€ÿ’b/ #<áK‡/7o÷:çp@ýg}\ êöúaÔüÊéÃÞöo¼=ï‡g[o_Ž· :«Õ”N¯"†=gÔhð æç4NÛˆÆI ªxB•“ÃQÔé¢K:Þ;½ê¬6VMeÕ¥ ú®u8•ö“(U!òIMýÚµ“ˆN:0›—ôÓ¯o¾‰bžËÑè…Û0оucÙ‹³á%oÃZ`ÂÚ6„³û!8ç¥(ä$xÐó¾CÜÙo¼xDm/xñØûÄï3æ¤Ûk Æ3e(Ñ©¤D”K2R–¤J2 5=•>2sZÕñò´Õ—OY]&Vé2ôfŸQ§Ëf9ÊGÙ†»ª¤¤«f±icàÅý°ÏË_.)•™¨s{L>^¿¥¤’ÂJC‚ö3˜Ø§•C²3a‰ÑŠ<—)-f*èÈHÇŸeâ^NE‹)¢ÑX”X™†4žIbSKF!_KgÈ!ãt"Š4°Xúê許w`€ÍتN¬®\¼8/üM/ä­¬ŽÉèBZU0` ™Ï+=¯ØÚI©ÆëR[’ß”±¤+2s™(‘–'ÒUN©”25d5ç`.«LW‚Œ%n$BoTmÔžhåÖ7T‚'½0´Ô5Û-DYãÉÒ;Ï–;¾U¹ª$¹[Ÿ8”®Oð Éi'4 TU [ÝJ£½kMïã»9¿œYÈÉ£ÚqÃÂ80P´QWÒìS!“êÓà=EXƒš!.k“ÓZÕ9ÈG@)IÒ`²btkL_T ÞíÊ6g,MT‚³ Gs+±·t-ãN;C÷ ö_ÕÆêB}\tµB魻ߪY¡¨–‚3›J+Tn&‡m}]ÿþÇû›ñ‹wczB't¹$¢PT)ù`e[ÔÇŒµtë  !Y0…‡(V‹Ä…S—©¬ò%“óˆÔ}M\C×iª8²cRÙªÖl%p7åŒ Î„ÐO«/ m¡,2y—“××Þ|w×JCz <÷jws¬2çzžº"¸lqrV¨7“ÝI·öz˜óÒÀÅð/®<$Ñß+7nÒ¢k”ÍIGA[ð©ÌÉ¥§Ì„±œbĶç÷ì’€ywžmoñ#gg°“çÞÕ“ 4Þô9ñÃù ñé*{ôÔmnãH%$›5w0þÓZê~m”΃æÖl÷‘+lŠõRæCÝÍI8bKº¾yÉïpÈ5<¯a¶±¦ùgÌ“ìrkÂæ£óÇ6êîh+ùµÆd@òî³…Aƒ–l¢Û10G½]ö¹n.h=€Ca)ÌÍ[;«ÈëQ&×£ûÇõÎ6Ÿ_a5ž?8Ãoañ{œTœüàÎÉØA6Ïõ?|À€ŒpSÕÿAÓyÐ}©ò(?¿Ç "n6î’Rù°Ùá.³o_…ÆŠÊ> µÏa3Žv#|öÎh0†ç¾-ðqÒÃ÷äk Ã¢)òáÉFÁ£_}rîå{ÿ—ÊY4{]|Ó Ï †=Þýf¼÷çÞ?Áwòendstream endobj 6034 0 obj<>/XObject<<>>>>>>endobj 6035 0 obj<>stream x•VO"IýŸOQaψ¸Œ(r¸š¬·jL.ë²ÙÜÓÌL¯C7;?Dvãw¿ªîfdpØË©Aºª^½zU]ßjmðé· Ýÿ³Úù°æ{>}X¼$S8¸ô¡ïua8¡Ã½~ÛëõŽašC> ƒ†LÆ£ÆLH5Úøþ¯ÿ ö†_k—í•]#“SLÚÞ³{%f8jŒöì‘5×­6y #ãooÐî àïóOWÿÀNg¨2‘I­`"ò8³¶‡ÀŒªÕé:Ta„€I¢ˆÄ|Ž*…1"O2úæ·ý}‡ò6Æ ¡äLÄe Ðã¯d S˜$ˆ!,"TÆÃ ¶³þ®õ˜zð>Î"O#²'½É•xÔ2ãßÂÙ eÒî0 P 2ˆQ¤Ì|¤üMøô 5„Ú:Oð[.¤(ŠüJ5]%’%"xàg¡B³yŒL©ù‚<ÍôÌ$ “\Ìs M–@ÄqZEÁÝçë«ûÛ|¼ü¤(âÃa.Ýdeå&TADH˜ø Ç VBL³D/1¤¼"C ë¯(´¥ç†T:“I¬°¥@‘0b|—‹b/™ÖÈKù•†X+R/<ŠXª”k弇o­û…Œc*Ã$À9RKGÝ$!’Y„ø$SCýȸ‚ø’þ: ®Y"$i˜dOì—JäYŠ‹êpt¼n—Z5lìÌt˜ÇLpµ]=é ÷cU^óøFª ÎC„º;ìEõÒç’ùAîæÈÉÒr© “4’s® M¥95ËÉõ‹ÛÄ÷czŠeed†÷N̓rtêãxiÈþõÇ4?\ßÝ|þ?à½QPs¥¤ç“M˜CV½+f ›~MOØJ§¯L_2D˜‰ä¡èŒWnx@°ºá‹ÖPç§{zW/{ÜÙα«I„‚$µHyðÀ£Â´(;5ø± ó,íA¹šL.iÂw‚s £?Ð):[†Ä©”¿k=ýH¡×»rƒ+>Kš†@çôzʾ[gfšç3W¶”‡úëÔî4ÑÉH’™BÿÞY/'°¿/+ÑXWȽ³*mØ,ÿ*+$Š[…ȸ·³Ê´Üz=º6*cWO ‘»M¶†ý¨àŒè6¡‹©ÌCÑÜÕ-Àôƒé3ho#nj×A_ڬܸì„*Î ¸í¶94#š‡+¨"û"÷MFŽ+ ¼€p!¹3LÖìvIº̬,>·¹§ YgtßKº¼+‡cfÀm†ZekCï<»«~µ'´Ì„,6¦ÁŒ ‚Ûhºy@j‡ëÛsº—!Eð`YÛgJ“öÚì÷Å(.F]y5êT­Fîʆ]7|w·ù:=£áš—'yÙ·Ê?³} ö ¾hí)\ül£@oÞ­ ü§Îý öÏJ¶ý¨*º]üÖØ¡m1Ôí×õíÛ`‹µ5pBqÜó§W‡ÈðDqÓŒÜ^º ßw{FÇ?ôŽºG´ìÒÞk¯SÖ|«ëùðAy±2¤*{ºulu×í{mß;‚KÖû¥Û§Ì>tä÷¼n‡öUºƒ{ýC¶¾Öþ¬ý ¢_Fendstream endobj 6036 0 obj<>/XObject<<>>>>>>endobj 6037 0 obj<>stream xWkOGýί¸_ªšÆ^Û q”H”BŠE*¸Í$:ÞÛvgÜ™Yç×÷Ü™YÛ 4}BÚÇÜǹçž{÷σ! ð;¤Ñ˜ÿòêàÇéÁ àæöŸ]Pÿj@gÙˆ¦s¼<~=ÌÆãSšá¥MóÎÛw¤Uy8ý|0 ÞnegwJ(}w8 N'ƒwÄÏûWÃÆTç«1ô¶9ØòÑÿhöì%³ï/2ç…õÑÝ^äÿÖêë—¬zµv˜-¤¿×¢’w»Ã¿spSk¯*yi­±š.•£s­*QÒ$J+E±!+K)œ,f1_š[SÑ]Àîp2L”¦?ßóÕÖÃöÃ!Ò‰¡ûá"öŽF©ˆÆ«\’_ O·Ÿ®ßS.4i³¦Bz™{Í!CŸT:7àdîËM+”m‹&=Žzƒmq§•žûò†mÏJ3\8D¿dfø†n‰l S5P7ʱ‰x´­Ñ>¤‘@+˜­ºl{Ó’É£^ØYr+Ü’G> rrQ¡K¢æÌvíÚ‡±žG%«(}f¾0ã› P ˜ÙÄÇ]cm"ŒÜPЦôš/Ó¾ðÄ—ÓK°ٱΰÏn{ÏY`ÎX 1__pŸZÄåë Fæ­5.X¼¿þx=½¿ž_üÒ‘AáÍêþæòÃåùíe|%`‰:%±ñãÌG6(I(qhû0†J%¾Æ4)4G’¦r”pÎp®¬ƒV@´I´bx–ÑNXW#ã_"+ÇϘöyó„Sqd£*¼¿î g _ÚgöªjHBÐ:¬­qÛ ²¸xðÜ ;7jÆþÞ×BØŽ²Ñß'Eç;Æ*ž½(1&ýLÚÆã"ê÷Áù è=~;P# “ lߢUI4S{IÿN-°Èoú€l,Œ™•ÿÏG; Žúé|<‰ž7”¤Ø1n쨼¶qû2 !·Õ¨—ŒGgpÁ·h4 ºØµÏrcý«³ô•1<;ÎNF'4³ÓXî‚Þ(ÐO&ÇÐN"Áǰ¯Å·{§ñ[è?¬ò'ƒq6:ÂW ê?>;as—Óƒ_þ±º×'endstream endobj 6038 0 obj<>/XObject<<>>>>/Annots 3277 0 R>>endobj 6039 0 obj<>stream x½ZËnÇÝë+:«ë$Åžgîæ"q$#8o¼‘Ci®çÁÌÖþ>§ªfº‹H)RHØ|tX]ÕÕõê–ÿ8³f‰?Ö„ ýÝÔgËÅ?¡/–¾|x{&‹¥IâdšÚ¤¾ ¨ÌõÙ* .Š˜³KˆÔ¸6Ö&‹ÕôYf¦ «Y…Á&+RËzXVa°éÊYá 1ÊF‹Ô$ŒD­Ç ,åY…ÁÆé!«0ØÌ.%+¾–¬6c- H«‚¤4^$&q¤.SŒ™I° ‡—9Rc°QFö8–—397ÐÙb7( Q8 Õ¬Â`ã¦)Y…ÁféÁÊ¢6B‚½3òÞ Ñ Åf«0©I­—U˜Ô&Ø­gE-¾R”Ú%B̈Õ*L,E“f=‹X³ ƒMØd·²¨M¦C§ÃЏ³H˲½Žä¬Š#9ôrÍ AÉÚ%‚ГÓ²+äb ó"Í*\›À†äB¶Ôj 6²Ž•ÂlqpB 3{ µaD.ô¬Â`QJd†Zl7Q²ƒ (ÆýÊbT Á–±ûx÷Oœ cò“#ÅýVÂ%b?0 Ak“°§`m 'ã8kc4§ <ÀÀ j 6á}èeÁ »3"[ÙQ*ad­…gyr%G–‘ç"ì±j¸ÂY{RVMææU‘ä¤ef‘³ÐéY…±pLæzVŽç,¥"1òæF’KûOLÄÈ“X|êB™‰‡¦4C¨D]ÅF)*Q9½ /8q1e)‚˹·Qˆ‘¤ÔÁ´ÍœàY…Á¦!-ìY…%à5K?c x>'ËF…™8÷-Àífæd7žÔ&!Ðñy•eSq½,ËÀ/;q ¸2¡#EEÑy7dà'Îâ$ÌôI¯ÑO™ xÁ‰³áQâIÑ8bª› Äù$CGjLGfÉŽå‚ò €¤qœÈ‘Ø ‰çÄ¢Kv«'‹á"T¢ƒEê…5&s3$’W«1X4ÃX±â£y¡rºiƒ«¤@2‰º’'EpEh7pƒ(4†(Z,r,;0˜Æ ¤½5È ¢j’=§ Å©IÁ¢ÅJTTN£Gtà¦!ˆ1Ë:R±YŠÚÕ 0pÌ=$Î5íÌC±5U$Ù:cb3‡hYÁ"ú%Ë~¦i ¥¹GI*A>0OŠ öC;™t0R:gËG&p¬ˆÎýÑR¡\´ “Vª`ŠUlÈ[õ² ƒiP² ƒEã€Ó¼¬Â`1 ÁÿžU,plȳ S]=´Y¶Ë]¢øŽíº«1XÔ*„‹gS™T¬Âdo×ÉŠÚ©{cTÆvÐù(AÜx°G² ;;Ú~‚F2WOj?3&{IÔ³"Ê­$÷*øRx5žµzÑ›ßÔÛQ¬ƒ ¹ "kâNARI•¬"qè1©¤ÑH± ƒEëL5«0X¤â¬Â`±ÉXË*Œ€@È+[f¹­Eh ˆŠOËs B% ©1X zZTc°˜°g-ì&…Á¦4»{µƒE¡=U˜¶JÓ®—•€àYŠ'S¸!µd0õOЦ©+áStƒ•‚xXÑ*Žûq­ø5¡»5WøQëÞìo˜õ–_–f½yfæúãÏoMÞl«o×ÿW«ðs¯¯àã;z°8‡ƒ£8Á*¯ÞwEUÖe“weÑ“(Ñ–¼z[ CÙÜšá®0]y{7˜»"ßÙ••|Ö¿zxc-Âõœ[ü0„ÉXêS/Íc†Éç'åoÚz_V¤>7Û‡&¯Ë©ÛíX‡Ëü늯‡|€.¨þ íGVö{O;|hÇî4›¯bƒmcÚyóý÷¦¸ЦÇøôOr¢»¶Ã«ÔùM9˜}•€õ±•_O±œ›}¾ùœßfß»òþ$ç‹è-zè}nÒœ‡áb¹2'ì§ Y=šJ4G"ÿRʽDzÚR˜¡6\¬?›Kwàfl(?–ͶýÚãî}ñëšâKÀ‡±iH”ëË®kkóSñ¥¨Ú=Ä®‡q[¶'qà¯ï~øåòyš&ß‘”¡§ú.€ë~0¥&2å&ïQÞ\PÆ|íòý~ª ÞUï¸8;ޝÆfCÙ{l=o«ö&¯Ì´…üæվ釼znbE3½ ¼oËf(ºcûñzèÆÍ0vÏM}_ÿÚÈû%sSå}MesWt%Nlsìv<ŸÓkƒz]t4ö¯—ÕHßiäÉ».8ö9RÞ·_Š®j1mÍîDiÈjQló¡=z¨’®—vª®CQSû?IÀ^×y7˜9˜^ÔJð»ŒÖKlÊ3ðÕØa’î̶ò²ê F0š¬Ñ•%q ¤Æ„Ãü¾kïN”ÛíL7‘ê¢^ä©ç5ÝŸ›ý8pf·ã@ÿÜ稧k|¦ÇS[½\v.ï7Åžçâ;ºx<¾õg+[?ì‹:ßsÑòÄÇ»|0%Z „ÿßã&¼èŽE¡7©:výœv|ÊÕš¯¯9§XUö¦98ws—wæ»ïŽìÛº>ÏÎÒ«ÝèT·#%Õ±ý{_ìÆêdM 7æf›wÛSÅÒTÅÍÓõï²äe—ªõt¸¹\äe‚*8EåÕ{¹f.³gWw±kН[ô”+w¤7Ÿ^!ð`ЧoÉ_lþ…®2yPêçÓ¯¥Ò`]Fq‰¼yB:üÕGWx²D¥ßá1‹þoÁ¹,û&©ˆÿ׬ïPI‘ê{ô *ªrÕíŠ}^vß+.®æ±å,| ³-ûÍHã4ŸðzÓû}‹!B|¼ƒßŒfÒ¡zÀxúÇXbÎç ÿÛGŽÜÐ|ӫм/æ2ïªÒÿ€ŒîÖ%ó»Û¤c&ÒjqÿÚÜ  ´#ümZSµÍ-Vqä(»¸š_Þ°¡¿§NøÎû7¯ƒ1~CÒ'“4!å—ë³ßÎþܵ5endstream endobj 6040 0 obj<>/XObject<<>>>>/Annots 3280 0 R>>endobj 6041 0 obj<>stream x•WmoÛ6þž_q(VÌAbù-/îö©oéôC·(h‰¶ÙH¤FRq¼ýù=GJ²¥¸]‡F$‘Ç»çž{îø×É„Æø7¡ÙÿO‹“q2Æþ™ðÏN..§ÉM¯§É+*èâzžŒë§œ>Ÿ>t9'—_ß, «vM£›W4¹€ÍÅ g_Í/“+ZdáÐ1-ÒÁìU2¡OVæªPZX%ÝéâëÉèæ‚&øÎ{†Ó‹d>ǦÁÂвRyF;s*LVåòœl¥éóÝíªœÒkòIÑ 6CŸæ]³2¥WFÓ/ÍÒy2ãó¦|à4™Íð” ~"·Ukâý$ŸDQæ2Q]Kðc–\]]óŽÛUô‘=ôöì û¼Ôg“Ȳ£î¥gg]£{?æ¶ÿå(µRxéàãJåÏ«cý²µ¢LÒg¾Ù>ÀÝõOOý~#<¥F{¡4ÎÌs2«€Dj2IZÊL™nz[ÜØ²2™2¾1é +¥•ÛìáæÄ7œØ™*˜e£©)JŽÑsÜ!Z¡3Ê•~ åi«ü&¸b¥óì¶Z*­Y[Q$1P‡G22}kÁÛÒû†rV­7ž6RdÒ†SŽuŽh2–—uœ“Äh—xÍ œ×ð×mˆÅ…WÑ£–Ú`f²éÃ}àjÃFø•«€þ®ÉPW:˜Í”•©7vר?Z£ÊÙQnR‘”Nó*“Ý£{ÅðF’Ø ËÐ#ÿÎ2\g;Ïd™9p:&EP½tU,‹ð^¤›ÈåB­…ˆ‹sŸ Ø8óncªæÃ©Ë¡ön Ù(qä îœÉ)4 +ÁTuË5l ª]v•ÒGT ör+¯p”3ð#SEQ@{™?Þ¯zHGC/Ho¥1“%þ£¨jíai¥ª2œøÞmØP";wh³ÁËíã€k±:¦È+@ç÷Â)MeJpxK‡óƒí t=bá|nMSõªº4•ƒæQâk‰¤yEk‚ø¡\s5vŒú`G"Õ6k篟w,½$VtF’LçÌÒìez’žÒïÑ)DDR{Ö„T,à Ƿ»ô¸7E¾ÎâàŒÏŽnݭãKÀš‹æ!uZ9”õF[e1(Û”húû;8 +],õˆøhJǽã×ÐÝ/ E:Ý»8Ý{´†ô¯éп^I"€\{/½/Óæ.jA<(abÌ PÂÎZ·âßnß‹=ãÚ¯~hСB¦ó†ø66—›«Êˆeí€ñÍLÄ&c¬+ŠTv£¶2… rÚ¬u¬tÝ›AX+{nùIJéÎ9¸äÈJÕÀX9çÝ:s7x²eõõ ˆãòÿ¼z÷XGG_Rçˆrãq4`OéÌ5I¶ÖÙ­,V’ED¥B« ŸÐÅ!¡q±ñµ/$#IH1’ß+T"jy0£ˆOØ Â:z?„ÙÅäN-YéJÃUôw¸Iœ_6¦+oß’T%X¸;[ƒ°‡V†V"žÅ <¶ò>ðèÊ}à\|ƒfñÃ4ƒ ÇXåû6òkUÊQ4r¸[”‡{5zAm…&¦¶åÒÙ âBíÓîj÷¿Ê¹ ±™¢NÄ~|àîà ÁUÁN7ú»b„²Ž³'°j†¹ïH]Cìd³;¢¦ôjë#ÙˆòøTÀ_ó»„ŒE :xXB½ófe*4‰®Õ!D«z¥>=2 œ©ÑPȶ«Ô½X¼Foáº}HM\6¦¦ý¾n¸×²‘a:Ë™>Y†b©Å$Y¯g´&\…cˆ@ñ8PT´Šê“ù£·ŠaâÑ÷0«.´mJ¬=±©žQ9mƒ} ½#êhÿ‚Â(”Aѱx¾ÂqVÜØÆ.ó5Ï/ˆAôÝ8àué„»ò!T Nh¸mCm?ÔäN\òq£0÷HÞ`®1(4<†óuŽ“X^b~¦ª±“djâ|wGW˜1¸}黎˜û­û¶‹ehÉGfU9/{=|6Û±R) Y"íl.tŒ/Ï»‰o:9MÏfg4??#‚¸Û,À‹³–1äùx´Î¸6yÛ³Œ3ú¸7åñʳÉ>/XObject<<>>>>>>endobj 6045 0 obj<>stream xµXïOÛHýÎ_1ª]*°H¡Ò}héÑC‡Ú^¡ê„TmìM²e½ëîÚ„ô¯¿7»¶ÁÒV§Ìz̼yóf–/[{4Â÷M¦ü“[//¶FéƒÝ‡[ÐðdŸöFt1ÇÜéòðÙàD¡õz—|]–ÖKª–¢¢µ­É›J¯¬¡Âæµ–¤­œ(ñgr6\ÚBgR|Õr=,ý,³Êq%zn-]^òA؜˾’n§ÔÛhHë} ™¤Óé3ž:‡µ’Zc#BlÜ_5è„ÿ™-J¥a·ð$¨ñ¡`—a£B-–-d6Ÿ[­íJ™Áþ™–­–Ò„‰ «,ÕÀ<ÀA~»mÒVä”[Ø¢‹™­un~­â´9,¥'w'?yÎÎÀE`óœ2aB²%,j\±3™xe°¤ÛùC²exCÖQ®&Z·î…`;Æ€P¿ü8BÒ9lƒ‡…4Ò‰ ˜Îd&ŽJ¾6¢PÌ᛼Ê0ñ¡¨u^}#v)}dÜ{S1t2`%ó]Þ¶ufÌüðk_!`ƺ‚S„¬ÁG¶”ÙÇ~.Wä+arárlÃ)>‚rD;› æœÃÚ;fî¦yXÿðTl¨XÒ…E n`, k8Lw}ãÙ1/¯¬æ¹fáé€#å6¥å| ËCˆe$v¤â½ÌùŽQ'¨H}eæŒ »Œ½dž»‰Î”©ozHr^Ä“ƒÝsüÿÖ‡¿J%.¸òˆÊüG}y¡+é @º–,°-¾‘† †œ½útvúòý‹÷ÿ|z÷ââM¢Hs­œ5…4] §Ä„åC™L×y“3mNF}ª²Éø”Nç½ØÀœŠõé§ÌÙE®’X1ÉB½h7 ¬ìÌã+S9T Ó‘I•Êd°¼”.0Èà…*JÍsfjJÏBQ–ZµùÕ–'r5¨‡d`8¯FrbKÔ4}WˆW€§ÜÆ”QI-òïQpÓFD~{„)U¦ý²²bÓÕÙ–,t‚ëIÁ´õ¾lè<³f®ý­ìÈQ„ò\q"ǽòÌ”öü:h¨œ‹ZWÔYܪ†ÖrM¿p°z@;ù¥…<9‹² ²Lz(¬c›W Á12Ý GÀxœ¹þòi<¢½ql5’ñ”etr”î¥t&žmçt¼³sÛ`3îv)Éx?ÝçÅ®¢%ƒ&µ €3 •TÙÕºÕǔΑ&1G@æ¤t¥“øä´rªB§ƒa:ŽÔiݬÄU_UÁ2À[à ‚þ³#QŠÁiX  B"´úÊM° „µ=–›FisÄÞq Õë€÷HÁå·ÜoùŠ ‘A·¥ßícÕ4c¨4K.öœˆMSV{Îc<ÛÔãzúü8í·É¯Ô‚’ ËPºUõTµ4 }Ö6-xÂüÝé1æv“²›Nô™Û;Ì¥ä4ÅPé{èœFÁÚŽ§kïºF±ùnÃj4SD\æv!Öµ[Amg"·šþ.ô>·Ñ‡è¬¬»êá»Kjvde¼Çy jíì´Þ!?òAÖ½s«!é1vÎdl)ÒÜpª ö¶†ÄLëš‹DC ã`Ûrq×úCíøýÑþó»1`ÖO…œ×¿î8Õ…¶ öÙЖÕðüÛÝO¼ t³@\ ¡ÅoçÈŽÚy§¶ÜBß‚8#„$ @^k’ÒºŠËW’$$r†±[¡Òx\\°-AqÁŽ}Rý˜äç˜Qá%z8iq¤ìše)åV8¨e1’u˜/XAx9ÙC’o*Ù-Ýî¦?/ bŃ]_×cb+N‘ͧ&ì­—,›PëP×E]-­cÌ`K¯áþu¢ªCŒ:" T©³;¥÷’­nÕé®ürcÙ3†ÍDuéúí&èš/emåÚŸ0zMBpÐré3§f,º3{Í‚ÚBñ›ƒpÃÃý{-*_gq€ï«}L7쎴FzË7¦»ÞŨÌj-FHúZŽ+&Ÿ Tøú* ¼‚*¡pÀÎ:^[p´è‹ýÝNF[{E¸›£âÊåCÓÆh€ 'Š”¸p³¦FuJ¤æ¶’0ˆQ':ñÐyGn•¬MI(ùGu“KÜs°  ûb"4°,Ðå_÷Ñ“"&ÑÃUó…æfˆ^5wìÃæ~4í§“šŽcÝ?ÿxú:™¤#ze³ºË!6¹ç&Ïâµ?ôûô!T¿àHhž|0š¦“1þíÁñÐï[mý ˆÎ|–endstream endobj 6046 0 obj<>/XObject<<>>>>>>endobj 6047 0 obj<>stream xXmoÛ6þž_q,Elű')°ëK¶ÛŠ¡Þú%À@K”ÍF"=’Šãýú=w”d+/۶Ie‰<Þ=÷Üs'ÿ}tFü=£ÙœÿåõÑ›ÅÑ$›àfÿ˯èôæœÎ&´(±v~‹Bžã"?66¯šBÓv­-í\C•±w|áI?Dmƒq–jW4•ÎèÆñ]Uo*ýúÕâËÑéÍ„®²[žNhÇßRU¶fÅËðˆ/Ž©ýS™eˆE~r2ÆU>ÏÎÆgYpÙ”¾ÿN›àOq›ž_t{aC;ZêÂ&×EF?»­¾×~Ä.ò ÿ# ØìB0|C½çqÑRãh0‹ëƒõ kÙ#- Få,5L` ˆLÊÈxMAWå8w6*p 8ìhëìwqÅÈHì#(ø¡%ðÄ k‡2Ú#‘”X ”á}TwCpBÔ‰KÝ;™Ð+N‰0˜JÕT1%Ï ´÷x’3Ø =°X«{ã8A%üôÈß*R9ld»2n9F¦Ÿ³0’WµY­ã M[>ÂEcïuˆf¥¢¦&°EN=L 95Ь¯‹Ðäk¦åÛ¿fléôæšÎÀ–ÖñtÎ…0»ÎÎ üàÍÈt̳ÛW# VÆlóúïÆxäCt~Ù˜ª`מ°-£v€P›o•¯ÁÓ2ð¢ÃZJËŽËguHîÙ´ÈL« ¬óXèÉmX½@_®¹¢0IËR Ž­4ªSU i_AH`mh6ŒÙÖK¡^VPˆ†‚ª!z{%œ=Áᨉ¦2ÿèÖbæ]¨\ ¥ó&‰Ä€à(O¯{­;TçÀá1ÃàÁ^ÛF´õX $ØãÑ ^‡õcG©6\q`¹´èû­˜¶5w¨{þ1²“94+d!Ù…¢ùbÌÖw{Z ãL5>¡+åAhÈ>%m²;;õ9øGX-@A­ì’|}`ÕDãb\ŒŠ 'ÛFuz©ºÞˆòÀ‹õZŠéÐq½ÎVÙˆÆn6•.7¶¸€i–€ÛW_Õ¥Kú¤cdsŠ6*¿S+öƒÀ{ð¬"¡"’N[NÀ¦}< øŽ›º,}úüá'Æžé æ>>E8ËÆæRûÈ=¤Œ{p;_@¸¸ GÎÂ89Þª«réªÊm}}8å±”ÆÝY¸q®›k33âÑàÕrVHˆ ¬õž¾I›0ŠcÎ-éx©üÐÌñ7ÜþÙk¨„T&]ÆŠ*ANjۧÀ“?q’€ç^£)J¹bX#ð3+g…„>v ±þõŒ{_eÍý!M±gÀËýëÇ #ƒ…s÷ºÚíù!€IèÌvMô+I W #ÛÁ3£t±rÇrü@÷kaÝ1â?Ó 7ôYð㬖I%%‘÷3¥»$¥*‘dBønj:<wc˜dsDK °€Õ™÷s3Ò¶§ù㨟+×ã6ä¡À~æwºÿ–ùåcªj¹Û¦‹[U[µC§Ës¼eð\Ácé0~A¥˜E¾~ý”†{Ê8”¦ª«4a®šÒ›nrA?>]ÜÑûîÛ ô3Æy–€ë‹ÓßC^HÏ®®xÌêí¨T½†³@µ¶Ÿ1(£”kVkŒÁÔ³oมñ …—ÐøÃš‡Œ~“ ²«æ{ůÄòÚÔM Ø.­BÑ»_~A¼«1%@ŸÊ©K@´Âš¸š°n›S@†ø%=gú$†u¾€’‰GRy’¢_Mî··šÐ`ZÄËD†ÌÆ5‡¸ªÀ»Sû’ÓG-ÆÒäÐMs©½ŸÞ\µ*8œg³ š_γsAÝϲ ½syÓÏüì d6-_¦¯ dоh§èôj€høm§O•ˆÐÅdž¡ûÉ× ønƒm½_ý~ô/üŒz9endstream endobj 6048 0 obj<>/XObject<<>>>>>>endobj 6049 0 obj<>stream xWaoÛ8ýž_1po±Z«Ž¦n,à:IÏXÇé%îæ>8Èm³¡E/IÅÉýú{CJr亇î¶ERICÎãÌ›™Ç?N¨‹¿'Ô?ãéúèÓì¨uñ²þa–ôöêôh¶€íÙ`@³ÌïÒ,m÷?D½è„n‹<—ù’îîÇŸiaôš.Ä£Pz# ݹ"“úxöíèíÕ)`oÔéF§Øª=^г.(1‚²°†7Â+CÉf£dš8©sÚJ·’9]ËÔh«®2†ë¼ ÎÓ$§¹ ™?ê‘Qb)¡´°æ…Té ïÑl%ðÙ²öÆèTXKFË•z¦…VJo-¹•°>ÄÆÒG^HŽc<óMᦠx|\òmüÛ/‰[ÅÇ{Œ¨Q·|<(Õë5"·m0ÝQߥu(N¡¯ü¨ŠC 9|–Ÿ€ÿC¼7…ÃQCm{¸!Ø­ƒ|û‰hOÅ“k¥bO]‡(M‰î]ö3ßN[£×¯?~1¢l­Ú´"â¶Åt“yªŠ =KS§Öoèÿ,U|¾ºbdn]¢T˜¨æ6’ÜÉuh¯ÃÇý™Œ\Il©žÿî‘'2 Ïrûâ¸8)97 úKè©:Ì8Åöá Bà“´ãÖ:]Ùº¨¤XÕÚÚ`ú aå>ce5ãw>Ò/ÛºÞ‘ƒ;Ä:qèšœŽÊ¨ ?­uVø!‚†Îv J@Q¦šwðÞlÚ?"~èq¡¬¼»¿3;½Aô¡šÃS½Å³¶Xóô@öh Nâ‡R¥*¨†WR@€F)§¸ Ûæ8 ” ¡І˜šé*É— è:cCgÝãgcòzoFØB9n~¾KÏ…ÇvÐ?vD ²‚¥ƒ—ÂX=†1„‹&Sx¼Æï êUä¼¼ÏÞ<äé%{ì*¼«4Y›À¶=³­üÞꥺÙ3W:ñÂ`'ôÚUçŒè%™½z{Õ¥AÔg=ØC©÷zQ¿§¬}}wqsG¿(nWƒ.;áVà›Õ/ÄNªª`î}†rtÚxÙk>þPW¢¶ã¿‹Î ¶àÜ+Ú}õJdz=üý2˜Wab¤¥t*¤= uÑ0|žëè[*¥(ËNGPH[ƒ†Å¥ëäAø.ÀRÆûðiÍxfK(²5¾Cí ©rmŠüQc‚;zLŒLæJx¡S÷GÞæúî´[¯£“ÇD*¶ª¥]ùÑi­ ˆ±/hhŽáÇ ô óßcdÚTâ§’ÄØ‚þaæ^í–0&>zÆGfغ°!DK‘ ÃY,©Z©`…s;º£úÏyl¯k&Œ¯Æ“Ëï­™Og—·WÃQ°;÷3Ÿ—¡qɆáýíðËn¿—†/d+§Þ|E]ÞKÊýCÚ“ˆ3‚·û=šKˆ}îK" ²¡Þavs3ÙñœÒq¼¶¸5P͆·Ÿ/gÕwØgýhTÙðoÞ;`ñ3—y§*Oõ}ÇŸa2žþ¾[u` O¦ïV§£É׋Kœ-xꌡUj_åPoœáz8úçxZ%êœÆÿœ•U0G4)Gc.D^ !zꀈ¸)5¬ñ<þT÷œÖö15Žç i•ñ³þÁw²:ܯè^æ_çêQ :ãVõ€›~å2øoà¿O᱊Ô9= ä…ê÷¼—${L6²|À•Ï”ÿ]fÕKÇL-Ë×·P5än†WWÀ“Áiô®ÿŽÎÞã¾Z"÷–N?ê⢒‚N¹óZˆ÷%ƒuç}èéJþ®{!™žgNxÃËÙÑ¿ŽþoÃ2endstream endobj 6050 0 obj<>/XObject<<>>>>>>endobj 6051 0 obj<>stream x•VýoâFý=ÅHmtDæ+áªH%Rt$\Ÿ"õ¨ÒÅ^Ã^Ì.µ×Éñß÷ÍÚ†˜»J-ùÐz™yóæÍ¬ÿ>jS ?mêöø7X]ùG-¯…ÍÝ¿dIÍq‹Î½.ùuZÔ»h{½ÞòCgÕ"?¨ýDSµHD¢dJY¯&kHÄ1]O§é‰ÿõ¨E6LÃÚtrõ@»Ï%ý<¯Áfr5œŸðúqr‡¬‹CˆCì_?Ë„ÌÆ*£<Î>ù¹ÃKj„r‘-ûQ†ÐùÚn7²¼Pónv=>O}ø§æýh:<Œx{:»™Q³òv0ümr7êP±¢†Ô6ÙöŸ®ãøV(=¼÷¬Hl¶ùµÝA°8>€ôéŸKªzuî´åÅjQI¡úýŠ«Ò‰çÍçü—¾ª%5`G ãªx?ø4žLGyM'wþè~<âñ‡^Àò°(NK~ìmÞùÎÃýð!_=îüÐc*-!×Kxög³)Íçû¬r!–9Àf:¹û˜ûBKX5Lfûò›Xob顲œüÁ 0+-Ìâk¹~zMÄÆÃãjŽO‰ƒEÔ@ÕÝnÑ85ßÐ"SqHv%qÒJBÖuJ2Mw·ƒ#š×¶&£µØ’–vÆ}÷¼ˆ$ív(RIjç'ù+•~mií–ÖJ«µˆéV<Ëâ«#’¥•ÙHnŠ-)[ ªEkIm²åŠ,AMYÕ2ôèQÙÇÊÚX¿¬ àFïÀÉBß³ÒKŠMÉD˜ñ>›ÔË)¸ ö©wÊ$€‚Î9/ÃZ÷ód€¨z:¢…H!àasøþ=1x­ÈgO½ós>|µ¥PF"‹m'7dÝàA 9©‚^dâ„Í0Á¨”¶2‰D 9QàOŠ` ¥GãL#5̉̀s‘RT~Q§ iŠñ‹RrŽ?ÖJ“Ðo㬄E1Ö*H]•S»‰LÒ3½ªd×é‹ÒAÂÿ,CEM¥ÃD $¡pAV¹/ $Ú*ä&Ò ÌªE ˪(‰Ü×€ó*ôÊxmº5aKçb¯×œnW*u,çÁuá];^»ƒÕ2Õ(T ‘ÄÐTÄW«\‹µKŸ×\‘ü´G“(3ÞÒ_?ŽR¶×A´wuö­IrÁ‘4´¨ªd#˜ëƒÊ£B»n+¸‹†o¸"­²§S7„÷ŒÔÐ*X“r Q:àÌêÜ H9ƒ~¸‡B£ßYÊRè ù¦œ»#šœøÍÛksÂW'4á æ*Àešiôž²ߦHáUØ`E˜O™„;?'Ò¹Ç$Ð/&~ax:[/ —ï®ÀFoõ¿P¾ÏèÞµ~¤tXIòÚ9ÕØˆ°Ìƒ´Á³^âL¥\C€o’gw—T_*Ž×íâ#¬ç>¼&â{y˜-÷˜,™Y€‰d2å·áÓD+[…ëfnçíÌÔ7€Ti…ÚlÐS¹®^fkôC< ƒ3ª:®å´±§ÿ• íÅLt½˜C<+¯žŠ^g?ŽªaßôäMlèþÝx:œ[Z¾:AíÔU( rC5…Æëe¦û—»·u(„U³í®h&Â4µó¯ôüä—*ÔêƒD Ë³Ó h'÷ú!Ûìµê«†’A\,œ”‘…sºåFã¦Æ¥†Ž“ÿµÕß%uìR¢ÓJ¦êã1”lé}aœÔû³b{œ?/FIûüÔ;ëžQ¯‡K¯í´Ís´ÑõZtm§7Á×c¹uãC.uh¡-|v³Æ½°ÙY«çáúwÍлèðÖÈ?úýè±Gqwendstream endobj 6052 0 obj<>/XObject<<>>>>/Annots 3283 0 R>>endobj 6053 0 obj<>stream xÅVMoÛF½ëW ä U™EI¶RôਲaÀ°[‹m/¹¬É¥´ÉrÉp—v„ ÿ½où%“ޏ—J‚€%ç{ÞÌÛÏ=—&øºä-ì/ˆ{g‚'öϵ·½ÙÌu<ò&3gA1ÍNæÎIu’´é=>Ç4wÎüÑ[¢érZhz Ç­Vñ½ÿÈWá0ÛÒø|Iî”üA-NOÉ‹X&äCoéxäB&wLÒ=Ë»“\¿ñ?öÆç3r!dÕŽ§3gÅáj¼zû–¶qb§‡Œ¥)énÃò‰ŒCçIFü ‹SÉß•&t çð0µ.¦ŽçáÇcÚüsyABžE,à Â잘µ† l ‡ƒ8 sHV^ZïÇiBI¡8 ¾¶ó/ð©(LrÔB®´0û_["ƒo­ceøP®ã"ÏY,NlP×ÉÉ$ùDÌÙñ¢8Mf/b@in4ýT…AÍçˆnrƒwè˜Ì9%­º•iÅصÎÒÜÔÙ ËyeúˆV;¦¶¼4lužÍë2¢}’SÌ>qbŠx–¡¿B5 "¦µØª˜+3*$„,à·‘Ž¹ÖlË_vàý—2é·R ˜úÙéõ«²õß‘¿O ¡p¤<0*«ºÜÁÅ’f‡ …F  ôÚ¦RC^LÍ0H”6mkà CP«‡ZŒ2ÎÂãDÉ}cÙ¡3cxœ¢ù&! ZD{hê²-˜T2ã:—0¦šzÖ‰L‹Qõ¡h{“d¡P,;ׇecP2Ê5/ÐÙÉa â87v't¡Pd(£¸U÷¾;kÁŽeôKÊÌîÅ9;„Ò«&öY+Uü…Ò³`ö1˜¯O´a{m[À£Õ \!«gR ­¡Ð¶„!zAä^r-Ôö‰ÏïÛ¡ ?´§Ã&Øðà d¬½J6»±÷Ãak¯Ôk‚b\ÐÊDQ„£<ÚʀlÄÔmPUCÿ1׆˜ÂF«PÆHc¬D$‚ÄÔ`gD:OS#WÌ ‚…7Åâÿ=ôi]nx ©r=‚˜n›Yý0 ±z‘ÿ˜Þ”ªù¶d‚yÍÙÎhe÷j‡ÑW!q•Ç?âÛb“” ZaÕ¥…¶GEÅ–q›.äÑ;ea¼œ%)¨ÝT{Ý!,‡Àb/­tϨX)8 yš,ŸÖ¬±Ž˜Í¢+cÏ ,JGmPûîèþ§íR…J\’ç¸3w¾¬#(.õë¿×·›Ë›kêƒkêccLlôžßó ¤D_éìj=¢«³‹õíˆ6þÍ_þ¶¯6×ë[úVï R³ÉÍ1t~sC¿ÑlZËT—“:ײàtXXîse0Ù¯6ÕiÅ#îéÌ™{sZÌO·¼ ÙÛѱ‡kàïI[‚-æÉf Ä•ÒÇ'¥×.xóÉÂñ¦¸Ý!õÅÒ³êk¿÷gï_kQôendstream endobj 6054 0 obj<>/XObject<<>>>>/Annots 3285 0 R>>endobj 6055 0 obj<>stream x­WïoÛ6ýž¿âÐ5˜»ÚŠÅIºOmÖ´Šv[=Ã2´DÙl(R%)'FÑÿ}ïHɱam!†cÑäñîÝ»wçOG#âoD“¿òêh˜ ±Âo#~ûýÅÑäbœMi6Å3U4ãzÒôîh÷ßNgÙlçÛgóƒÑª[ÒÉÕ”FCš—¸yvE¼òÞ•u$MSù>UâF’oœ¤°o’ Y*£‚²†lWx¯t".‰<4Bë ‰º–ÂyR†­¤(¤£RiI0Ž5¶tëxS»ìm%Wöv0¨òÑüãÑ£1ÜêmlCÈ•ß0Ñ·d÷ÝûW/ð)HWŠUXÙ&ÐÞRZ+³Œ7]Rn«·; Þ¡BÏ…Ü8nۙ͡µNŒ§ìÄ䄞k‘õíƒ,Hxâ½'WHð+©—[ãCZëP)âxÄ’5@j-œ -=b+ƒÖ´$ò\zóï¢8¼/±‹2ðÍçN-pZÞ²“a¯\+ÛxòØŠ4f4_I$ þv}Œq|F̉²q8ï¨P>o¼g$4ÃJ+^2Kdã€Á \/æê™ð*÷Ñ¥-Ç;Jö(_‰¹Ü‡þ’Ád'¶.$IGxÁ’“•¡:_™ó\ƒGìËZè”K<ÝnÉm£‹dUH"c‘µ4²Èþçb"˜x{®ÄQZ>œ±²ÑûÞ>¥ZæVÈiØðÅŠ½OLìîG$~'ëÊ6—ÂË“‘œwá6|Kã¤ècKmBæwY!">(´E†kq/–ÚÙ\\Ü [(ÙfYÞ‰ªÖòI2=¤ól¤ƒCãq6™à©èñQZh±¢Ï_èsgì/zD”|£«·o¿YG׿¤«ºRÄ«&ÙlvÆö^•Ü·t¢B²5%fioQ劀9Ù‘w̬DÆØ j<· »HRDÉUýxp;uVZ­í-NtÞG ›L«É5_粆{¡KtùöÍ»ùÓ7súïèËÏÑÖQM%CEÓñÞWYÖ1‹U¥è­­g…»î±á»ëGÑÒ½ŽÀö~%Q©L€Š25‹£[B®M+€ ú­ruþ¦å.#½4d°€¼[ÈÛB¨Q7í%ÐE¥…SqÙÆ–Е"¸ 3Âê7ÕÂj•S,DU*¤ÂˆJ&ÉùÈÈ”û>Æ%è€KýG\Kµ–¦ß–*ª3*zXi]Å­I¡tTŽJ^ ¿–uðÔÞ4u'BI‘Pu¬ê].ѵt,©Û¤GtæÌè÷N[wÍ7ˆJÁV*¨ZJêq_å¾?ϘX“‹l’Ò¯66Ò(Î÷¬â]SŒØwyrùø1Õí¶¨Æ?Ý7umn Å†Xæ‘»Ô**ëd?.1 h/\È\wèµî†à– br{Ö2@íPexf<ã@±ÇK ±bDȉ؊<ÎÚà¿U븲ªÚ%®å!äÑ]½zýœ~*m-ÍujàÜŽ–060!“T`>ˆ«°$ÛäæMp]–(1¿o OÉö¿nϵõòº½ý›jº!úăÑvZ`¢í4Œ® ÛùˈÐ8¡éVl¨t¶âùv ‹‚²“¸ÌÛ®†càÇèýþŠðaZ37tû÷Á–ˆ =x‰±ÌÒ{ëtq}mÐÃí´×š*#$íú=ä ]!ª=¨>BÑôïM-³" } ÕÙN­‰6à_!e©vÉ‚cÖV¯Qô‡AÀqP‘‹,·\‹ý{ªØDþ4^NvÑ%cnp5f+ÑÀÍ »­Å'L±âý``˜Óq4æ–'Î"’ úÍó!*‚V¸9²¯0™˜g‡à}ȇ³³Ñhxþ¡þÀœë|l‘åÇ“«óvJO³ÓÉ)ÍÎÆÙYêê\»ƒ ~ZübóØ#b ò1 ŸvÎ×£hLéò~8Ãì4ðöÓá,›Œ!1(¬ÙÅ”—žÏ~;ú %ôDendstream endobj 6056 0 obj<>/XObject<<>>>>>>endobj 6057 0 obj<>stream x…VïoÛ6ýž¿âP ¨›ØŠcÇn² Ú¬ÞņzÛ‡¥h‰²ØR¢FRvÔaÿûÞQ´c¹]‹…,‘wïÞ½ûñ÷ÉñsþKË“WË“q2ÆËývMç‹KºÓ2ÇÙù5²ðé`Y(GµQ•—–6B7’RQÑJRn¥Ô-ÕÂ9™‘°¦©2ò†2•çÒÊÊÓ åM•ze*G¾žäC-Sχ¬L¥ÚH‚)³úÀ/MN¾­%=_~89_t4XܾyM§ÝËÊABËB’©tËÆ4º˜ôÀªZSk†øÌSfà3€ €R rLnM‰umL.Ù~ûû›7ûc°`em¥CDˆsÕ#Î[öu–/CíYé¨lÒ‚„ 0Kµ.ô G^ºÌí!o•ÖÜg²–UÃTÁD%<+†ÍŒ˜%š×ÂçÆ–t7P‰L†´Rë_‡¾6.!­¼×2¾¹{žÐ;U*-Od‘<\zÓUŠªŒ§Âùƒ| G¤n;½BN•5ŽA&Z¤ŒŠ#f1:™p¼ ¨mÈÇÖØ@ôQ Äš(žŽÇZX¯Ò& ëáÉDµ–(3GÛBV;»9;‹A ·y0ZÉNKGÈ¥´`+påºjRŠòT “¶Vy6è 4QH]ãݾ€{HT—ø„°å!|ùŸà½J¦ÜJ&(ËÉ$™Nñ+w™„¹ okEîpšâðÚ#©»"xìp®á^„©„ÙÈU·å!É£¦\i‰ðiù)ÊÖ2ty´Úš j•?!´TB÷hÝÛí§gÇÔ˳CK` ¢?+/TaÚ4@EÃvøéHƒáç‘ê¦{Õ7D]9ÊÖfë¾Ñ+v86»¸:mÓ†“˜«5A£š&3µô"™«t·'á8˜ÃÉ÷´nž?½Ò»Èö`ŒwŸÞû§qÌï$uTTq”HyÌò$ŒYÊ®ÅÜ û÷w–a&¼à »‚y´rI¥šw(×_Dn«)öØáñÂz$~ÀÞ1›x¨óÂõ,2Ï8Øùnpÿb¶úvC½’] «.‘P¶VâòãfO÷›5¡„÷*#.®†fåEXg0µ1¡Õ@Ù삯ì;ÛQQ HxlW«ÆËž‚¿%šõ}¢ÙîûÖ Ÿû«+9½¸_Ý×÷Ð;,ÿ“ÖEc×bA,\¬LÓ…`%¶ Nj¡j,o~+196®ê]žÖ¥ƒf€5™;Xæzˆk Áœ´±]ÅÅw2¾LfÓÍg±Á¼ûóöçÑ4ÓO&mJ,£‡=vgG/º)ºÖŒ~í¶ö@ïl>/XObject<<>>>>>>endobj 6059 0 obj<>stream x¥VkoÛFü®_±@¡BqDZ[±´âÔE€¢hA‘Æñx™w,ïhIúß;{|ȤÝ8@mIx¯ÙÙÙ¹ý{²¤þ—´ÞðK“W7“E¸ÀÃþ£ÚÒé5æ,è&ÁÜÍ%¾Ä~_äLmݳ›O“Óë³vÒŒ UDª²dd]UKWWŠÞ•q`t~éµp¢Ÿ*…&‘[C‘¢ÄTRÅäü~Õ6Ó[r©¢æ¼ÔlšEíD”«18«”tÙ ydAÁrô³kS‘Ú‹¢ÌÕÝ^áš#\aÒj®×øÏìtm }évàøgD†ý¦Ý£#—ãÙ™v´‰eþïô„þìˆè)89/’©¨èD‹B=ØoÚFü`` ë?ã˜ÀG¸7›È»Té1ŸÍ± 1ß”Ô]%ÊRÅsŸ(Â)í¬O·°¶.ú\ÆÄ’I‘ç$;7R8Œ5ymŽësZøñ1äm4O«ÝpRŸä³X•JÇ,£i—*H§"l¡£·ïÞüB™¥ªÆPæR=ÏŸ“)]fô‡g!ynXoG 7Êæ…V¹&^“ÇÔǼËòfH=JåJX*4ÞÄt'òZ‘„¶A@Ho=ñbl|d¤Rq—ìÁÔ´‡ùo¼?FWGmQSä¥*DI¯•Uá¤ûV¡Å±:ãTã”ûÕȘE¦9O•8Ø9 )•µ¼±K oíŸ3¨Bh±å,¦•©·)•rF‡¨Œ¾’æÌ‚ÍbpÌÁ|Sa½‚¾¿tduUD\+´¿Ü|ªû )s|> Í4Ì)¿Ç™U÷8Í³Ï ðISb|Ñß”ÊÚ~‘Ü*GÁþã`øöb±¼Ø,ÅÙmy‹0cÓV»]I*ñ†Ð2Kl‡pÂõÃÂíÐ2“Ô~ž_8˜X ãøœ‚ÏAcã a6OÈÑf˧Ú:òD\±Öÿ‚Ìz†¶±¿jeÊ.®»H¼ze´¾Õ–¯€p¹¼ÚÊøº–ew€WÁ”$«)ɶ|oûû|Ã@¿£+SŽU„Q¸gd¸†:"™õÚ ³ÙVpªycÒ”™b^á!.ŽÁþü¸Yh¨›Jo1_dMàÍ­uç膰f(zí%Ø]DsZn:<É\b[¾Ew¦†Å@ !ìâW–ïU »ŸZòVë½ %™Ú>tlI¦J~à ²Ä»Ë ^‰¸ËWS)…8«Z €XµešëŽQçŽM´u xÌ#C¯ñÖÙÝîã>€ÎY•ühŽgì5)\2gÍ3ÂÇÔ4'[—%bã…;sôhëU=ˆàéRÿÚEÏ$s"n¼\ÛÕº÷Éc«å8ÒèofwŒÑ—9Ú¹3tØH©¿*“æwg+3Îá¨bâG“q<ý¹![ŽòL¼þghæ%îÃùÚ¸DX ½¿ózh¯¨<€éqhž=–›¿˜Æzg?bEMzÆ|®v‹¶«u@hq«´ª|»šº½B=ÆOôþþ&Ÿõp²§éû(ø)é:B4„¿ó¥ÚC¨iO¯/Ú¶zyqž¯Ïi³Ytí)71Á:\Ðk#Ñfµ5Ê$@RÍìàwîñl}¢ç£·]3nyÖùb®Wèê1aséíçç›É“Ç“‹žendstream endobj 6060 0 obj<>/XObject<<>>>>>>endobj 6061 0 obj<>stream xµVMoã6½ûW œp [ëX‰“loÛ6m-v=$‹€’)›Y‰Ô’”?þ}ß’'­ƒn[Ç0‘3œyóæ ¿öNiŒ¿SJ§üͫއYoœŒñr÷côîúŒNÇ4+°wz…‡yXÇC>øÕ¬åJÚ!-©–yS*a•ß’)Hä¹tNé rMæ¼mrßXI¥ú"É/•#|ýRxüH²‹ZÎi%ÊFÒÜHGkc¿Ð×FùÖhkªÔbéInpšOèÚØ“ÙcoL£Ó "ȨêR¾ç—ï®Çt™¤ù&“$Mñß|ð}–²ÎSÂ;'=mè.£|§QñùÅú¦]{ï•F¼jN¹©*¡ç¤E%©¿éÇ:äF!€4™N/ø°Y›|&sÑ8ãUþkáHO¹•Â¥£6¶%­Å– kª`§´—¶zÒÒý`زØEd²G@u’ÐÌP%€½ò] ³¢Ñ¹WF·îË팹8<³B]EV>«Þÿññ_ƒ<îâ¥:ˆíF¼¡eÂânðÆ 6ûÖª µS󘫱j¡4€ÞqرÏJ ÝR¶2sU¨\0p-QhÜÌÓµiÊù·ð4ý—-Ñ™”šj…_ohmE]£;v¾\B7iÉÒ#,˜¸ÀMÙ%(Ÿ OT ç` G]´Õò ®pÁ 6RМ.ä!©‚¸ÚKÁ{vnž4nAù%ZHGVŠåýàÚú¾¸?ùá Š|Ÿ‹² }ÙÎ1ËKD…)K³voõ'¸yF :¢ƒØ ^‹é†öaymU’ƒÝ3;¢@1ÄÒZµ'$fsãY®Dé º³‚õÖ¯“k 2)Ö±c!waRÄz€¼^èüMááßu*Ãäø Úþ³ø[1XÝ£[‡g†‚©^‘Þ*§Œî0·8ÞÝçYɰÔQ¼-Õñn”íöó$@Và‹ú…QÝ@Ž÷gãÃéø²âòò¡~xuÌÁ_³Œò@AUç]j aAÚÉ&¨; Ää– •¶T"g.y[–0YàeãY²\nj¬Ù'«M]ª\ùr‹£`´¼Ë.t}tôpçF(öà‹¶Ò†VtÇ´È[‚-¨ø//î)ßv|A£ˆÀÁÚün¼|4Ãè€Y(OìäFÏ¥-·Ì×6EèœòAÍZKë–ªNèVÆYÉÊØ-ë»XÈ C—©x¥×;Öha¹¥±(Oúl'òd|–œ§ç4½8ã»Ñí7¿ŒÒdL?™¼a_aIJ JÜ9ºˆj”^%¸RÑmw³t¼ë|>/XObject<<>>>>>>endobj 6063 0 obj<>stream xV]OÛ0}ﯸ҆>Ú¦-…=['$^¦VÚÃ:MnrÓš9qf;-m¿}×vBih@H¶¯ïǹççO« úíB4´qÖºš¶:a‡6Ÿþ©œŽÏ¡ÛƒiJ¶ÃѦ‰;ïÀ4¢ó0 ÏàúøbÁ´F}8½kŽûÐ¥s{£Ýë‡}º<³¦ÖŠ&À4°ðÞ`®¹ÌA¦ *cSÖF<_„0–ŠŒXV<žÂƒ,aÉVfɵ~âcw`F6xÏFï…QD«$pùÁ-×­!Ú“ (ç‚Ç[{à gÁìðScÿŸõ°ë€ç@#SñrÄK¦àˆÌ^zXIžÏ5*òó¦¡ÂL®ðuCïdäÏf‘¿Œé’˜/Ìr» ¿n¹iXÛ…Ãá™ÅÆ¢S{JÀ eMM øo»ít¼ñöý‚p_—÷MŒ,;Ã[¶@õâʇîÖî.'Ei4ü[ó¶GäçÖ­hku`W{á¹¶œ‡„fsTÄeb-‹c¤Y°]&z"h–!d,ÏQYº_o®Ã*ZÏÍÈÄ0ÃcÏæÝéúBÈ9–ylh`4Ðd¬˜âl.P‡0•À…(i†˜¡QÑeQHêÞÓ¼°Êý;›èÇfR°ì]cC¥¹ÉS)wMJmcI9gª&$1÷!oO<¬>”GHžp'”R)„\ë·j ûEyBõóìÎÅE•ú6À±ç£»C‰ÔÖ´ð<©•ÒÑ #'“#'“<_¢â†å±#ÿ†ZϤròýæ«­'-…x¶¶œ"YäZ—¨A¡ Î&`dÓ!5Ÿœc*UC#+mÞ ®ÏvÏÜú– ”Ç­úðf«Nß*›·ëœ¿vE¸\PVSI´ßçcƒBC.é=˜ßallýæ¡@¨3÷ïK@áüNýâN¯æh%+µÅXóåÕ¼Epã}A‘0y뱩'ïun¹ ÐD¦Y`a8J+UÞ[+)…—‹Ú3kïlvØLÝÒ¾ YÛU&5­I-’†Ôˆ8Äò‡J"æŠ@K•Ìš±_"æQ¢wÌqùu,R?càZ!1˜Òxò:ª¾º£~8ˆô1»þݶÃÐŽÂ|–q™an‡^æ¶*⊷nŸyBîþt†aÔ£OR—áùÈÞü2m}kýnˆ…Bendstream endobj 6064 0 obj<>/XObject<<>>>>>>endobj 6065 0 obj<>stream xV]sâ6}çWÜ™L2dÀ„„ö©Ù–6Ó‡Ý6L;ÒaË ]ÛòÊrX¦³ÿ½çJ¶ƒ)¤%€u¯î×9GúÜÓ?c güe½‡eoŒð°ýg6t³Ñ}Ò2¡Éˆfóq0›ÝÑ2vV#ZFýKz†Öä^ôÎHa% ~z½üØÑp »ve!2Jj»÷?ŸZõÛ\_½YL‰"øpÖÁû–TI¥H$YMU))«R«ŠT’Ê·Ò(+òHÒNÙ-=ýþøcÀ±nsOx7ÞkÆ9…ó æôA«ÜJSÈÈD _|~iÅï"I#ö¥ß¥É‰w™SÞç1§woßÈ"6jÇ_&ò=Å*qÛYÚÁ=Iª<²J甩ÍÖ"Z$Õ3ª¨Rî^”‘-ZhCò‹ÈP×7>öá0†“I†MÜÖ*ví¯ú ­éÍ—Õõ·~"77ôA”%­÷Tø2;}o='Þóê¤gÛ–Ó¾¡÷}q¥ƒ¨®§ý¦µßŸ5éÂï;n5é¤iƒ/¼iú1r@0mLäšbi…JeŒö—VÕ OÕ'`e«ÐÕ † BðƒCU¹J”ÄÒÔ¯H˜Ø}GVo$OØâ ÓΈ¢À×HÇÒ ©©àŠû*/ú¤ÚëŠDd+캧­ˆ¿Xk ½ÁPÎØ2ÁÜa˜ÊHÙ±v)¾>üKàD×¼ò3':à!›üx8î8€pŸ‚†'¬''¬m¨rÂ>º0endstream endobj 6066 0 obj<>/XObject<<>>>>>>endobj 6067 0 obj<>stream x­V]oÛ6}÷¯¸(–ÌilE¶ç£èÚ-Cž¶¡ò0MQ6YTI*NPô¿ï\J²-§M»bIìH"ïç9÷Pz#Šñ;¢dÂrÕ{7íÅQŒ‡›/» “›SÅ4Ͱwr‰‹4¬ãBö{P67"ÕÅ‚\U–ÆzÒŽ ãéC¥½"á(ËÕ£žçáZt}|Ñ{³R^¯”#¿TKøàÉÒ¤üDxzwû+IQüè)ÕN¬æzQ ¯"º1–Ô£X•¹º:šþÓ;¹‰é"J8½qLÃñ8JÜ¥ý£Sr¥XÍúºð³£7¼;¸”Ϊ["ëf}[ë0xK¢Éäœ÷ûõ`™1³þ;aéõü³á6ë‡íúÃÝf”*™ +¼6…Coå’{‰n9t«,•°z2­užÓBy´¶` ÐV'Šr}¯`¡ÝËjºé«ÑøŠî'gñåµðª´A§ihÓ2RY¦¤×*"½(ŒUé Óæߣ=ߨF²¸¥HÍ!æO»xEuÃ[îíá15”éÇP]Ý¥™IT(8ò¦É†@« ±Rd |2n`K´ÿÀ¥ƒÚɬÏ|ú»­¾&×.}6ôŠ¢þæþ ?Níìh=bËÉ ý$%ðDUhØ6ü‹Íù Yj¨ºXvÇãÌÿ¶æÅ‹ ‡i·Ê™ü’`QAÍYU€_<¢h9è¨rLs±« ØCN.úaEq_9L·ëN“ÒØ Y`Šhaóœ;LÓä©TÃÒ*©RUHE¶Ê•‹h öÀ<ƒ­—CÙÓz0y‘y¦‹²‚|”Ä‚¸ÞÃR=JU‚øÈW{hZ¨nÍ*ØI¤–<ퟠÚ)7¯W)œ„™¶¶BA^Ü#Ú6ñ–…ãS.î÷\Á‘!”ÎI¾ ½çîB˜_‘\Š’³Ì09+Ì3òÄ%R狹AA-<À ™ÑK¡y|> Ç”\FI4±K2¥‚Šëº ཧQHëZY/P]ؽÅ~cÈçÍ-‘e΃PyÃI‘Cw \Bgš$ÁÍ@ ‚Œ:÷­bXo¾6|¾<ÒÇ’pf”V?à jº™lÀŸn¶ÖHó¿î0•X×r߬‰1ë·öô–âAëMóÝ숮j¿³¾5Îqžaá#}ê$G´qȵûö–å®…>/XObject<<>>>>>>endobj 6069 0 obj<>stream x…V]oÛ6}ϯ¸è–ÕAlŶçcoí–-ØÃ0ÌX1ÔAÀˆ”ÍF5R²“ ûï;—K‘4H%мŸçœË¿Žf4ſŠþMò£Ë£i4Åb÷Ç®éìvJWQLË”æSZ\Ï¢Åâ’–ÒïšÒ2Ó·Št~²ür4¥É kr4›GS^8»='^Ii‚Ó“yÜžÝUä6¦Î$=*r•UÎ)IÕFTdJeEe¬#]ÐïŸî~¢Ø** Y•‰J›ÂmtI•éï\&YDw¥"©Æ°¤ÈÙ t±ö†ß;*KUðÂFY"žsÄÚ5ÞEÑ™¥L?)jÒ@¡|£öóÁ¸C2ª@˜…È9C‚rUmŒZŽhɥƪ&vW‰J媨†'?'tJò~èá[%2$ü¥v*·5Oȳ—"×dÍ0Ž®)†;“Lj>mkŽˆ¹p{UC(R¥º@V£®6$uš";$#ìºæ¬Üê¤Ë³ÂÊÎñVÙÌÉ=B'u¦+­Îõ»U-ý £w‚ÔŒ””Ÿ9©g‘—™º ¿‚x2ŸGq HK`÷£á]Ï”PLç¡\hõþ7I—t5øæTEŠÐ ºAÍÏ7t&«QœVùïV'e]9z÷Ü±êžøß¿ëmš‰¨Ôqë˜Øwê}ÏD=ߥ­³ôkg“Î&ç o_q@YükÁу¾:a^’ïvdz×KW—¥±fK3Ïk¼ xÌ€!CiÍø–$Þƒ•@KÀç}Õ T+Ì™4Ì“˜žd¹ˆn “NéÅÔ0-)1R5Ć2¸&»}…Û‡·ÔuðŸàɃ#Š¢Þ{jµ*d·9DºIS#¿1÷ð¬N¾ïYZü×>Xz¤Úª£4Êqmž ³£+(j)MÓ ®H¾K“ tµQI ÖÀÿ éu&CrÑä¡«™v´–õ2¢?Q¿4w•Î2ÚYQ†è»Ê‡¤ÇôXW¾à¹à~B¼‘*Qº ¤³BÁº+U¢E†Î7¡õÚös•]Z?)$ªÚ!çpíß*}ЄÐaK¡‹Û´dYgùB%_€eC¹ÀPaìuO%aéÔøÞ™jÇRÈï\ožÆí :VÏ ׬†);‚ÖZ…6oUD¿(UòT`1õh=»½†œð4æY¼`‘‹¯£8ÂÚÇÓSâ©åJ‘¨–Á(o>Îy{ ­.ÀÑtp®é|g§±ÈXô4o²Dã9›ÜÈ4êü÷Î5ëIµøh7ñµ ‡6ïÑš'0 .$TÕÕÍf”ÕB’'±Veˆ”jø÷#ž»1åýÿ9ÑFÒ•6\iP“×tSc¨/˜ ϳm5â§bˆ=ì€~ÖIE oˆý+<[¡çñËøï¾làc£d¿!àÞÎØ'»Â‰Q—š,3;÷á0Y¡ŸÑY[ƒÈ™Ð“v\²¦PÜ[\ôÞŽCŽÛÁò–Õ1Õë šüãòè·£ÿŠˆendstream endobj 6070 0 obj<>/XObject<<>>>>/Annots 3287 0 R>>endobj 6071 0 obj<>stream x•VmoãDþž_1*ê‘rÉ^b§I §~8 ¥Ä—Jhcošål¯Ù]'tüvžYÛqÜöÑ—(ë™yæíÿ1˜Ò¿SŠçü—䃉˜à Lùã—ÛÁ,¾EÓ¹˜SN³ùD,›SF÷ƒÓ3¤‹…XœJOÎ^-–øî»Õ‰»àÓ>Ò›› -EL« Eš_MÅ|¾ U@Mh• ™+WÊDÑ1ô÷Åê÷Á„ÆSÈÒ!áGž φßô¤› C·³óNÚÿoçÍÍŒØé†Æ°7ŽâèðnCSÑVîåÆ*ò[Y)ue‘²’¥½ZoèƒR%•¶äùÚdŽœ*¥•^(1…Ó©‚¶•e©‹GÖÌIv:tÿëÝmkÄÑå&­2å’dIý)ó2ƒ¥\~`< ŒÅQ8;$• ²¬3± `Â+ 0EsÕц ËdÛé÷´ð³ƒ :%–Jk­Ì©ò:Ó)vg*‡d82r¹Ì2J‘‰ì@…r^¥mWûÚk¿%ä¢ð:‘Y“«ZkD{•e#¡è!áj<*Oû­ô¡4©rÊî”`­77W4EÆ6˜ƒq4çÔÅW"Ó˜¾}ýš¼Bâ¿«uÛ’³îLÌX»§E©)¾ôˆPXIÛêQqØë ãŒq¡ý`öj§ìÍJÆriÑM¦C‘•u£® ôˆ-\î4{A¶·‚Ihd¨ÊÐÙmðå<ÚMK2 Z E¶tã©rukÔ‘‚BsÏÛûý )ÕV%^#§=öu{½âq‰8ÆH§Ãó¦ïš†l#óxÞå/t‘dUªè¬”ÚŠíY_¹?Ë-Æ·I&£ÕCS‹®{÷œ·U‚Áäó‘÷‡R¥jƒë´ÑÖùßøAŸBÀ/G­#ŠÑL_Vk<»¿jï=“0ªç¬—µ€iÀÜ«šð5zõ”âˆþyÙÊÇÖ[M~Ǫ> Y_뇋àå-Øs„ÿë þiŽ+ÀÄÙÔ:ÔšJŠiÖ«Â9ž%<’ãçž,î:Í:×=a0úIŒ?­wì’%€‡µkø˜§©ëSFI»­Ù<“<-k ú‘Y>/XObject<<>>>>/Annots 3290 0 R>>endobj 6073 0 obj<>stream xWmoÛF þî_A¤+଑"Y¶ã´[€®[º~صö¡Œ³tŠ•J:íîä— ýï#©Kž“4 Ÿtä‘Ï=|Èü=ðÁÃ_‚)ý…ÙÀs=|B>}||?MÜ ŒÆ@“‰;ª)|t–̦½w¾7q§­¡LÐAå†,»ë üɨoÛYãÛ«©{Õ±ýiÞ “cÕ÷pyëÁ ˜Ç0ò`zí»ÓéÌ#Nƃy8úIr »7çó‡ŽÏ£Ãó•Ћáâ¼ÿö+//oÇ@»cpл3 jï÷`2¡- =K [U¦¬$”FFx¼{õ „X¥©Úš×tr?Tg4rƒ†ŸÈÕÕ?Ü*uüï´Vâ’Ãø//ëg•ɵÚÂb˜+ ¿æ‹ó^f®ëöÖ…s³C§Á†âÄzdz^¿Þõ̳=Ú¡yѱmcˆï« k®`«EvBg¦`’¬H÷`eŠÌøóÃ{+UZÜ#¡r†ddì[€úg !L…1 òˆh'•™›cnÇ–jõ CëÂoâ‹Sj {UbdÆŠÜ&ˆ}?"ͨ{UÇþJ“ä÷Çç¾´3l5Ø !‰!—¡4F轋Ðk;[åÓÜu *ŽõYdkIÁAôg"†gÜVÂ$¡9ëïi!ãÝdzÒÁžöýG„kQà°`.ôŽ;h¶$⓪ÞÖ2背u²"fι£µmÉ”ÎÉ?¤ µàp¶êlk±‘x‰•Sf¹B«;@u¦’j/Uu37å*MBVø¶û°VÒ¼ðØŒe ‘-†¸ãxÎbËçò"¯9®Enb¥3#,ö"RX–",Í/‘CHr.™ªä4VÖ7·Y«\n—ø…„ó(ЏÒmù-uÒz}í­6*‰ðòRieå“OˆOz®¶AÜïÌ}4ºXî–÷Ò.†Ox«ãŒq|Ê!XyÄÎÜx¤^oa#ÒRž •¼âxÈØûåí¬žØüÙØ˜â?ž_ ¹8á9ëÁÏ*,3TSA¢L8áh]ív®ªÉ ;pý1ÏÐ<®À]5f3a'ÞÔ F(XÕW^@~™þü¿šendstream endobj 6074 0 obj<>/XObject<<>>>>>>endobj 6075 0 obj<>stream xµVÛnÛF}÷WL•‹¡.–ã(Л[?mQyˆ cEÅÉ]uwiY-òï=³K_¨ÄéSmC÷23{ÎÙ3üëhB9~'4[È_Ñ}·<ʳƒnC¯/sz“ÍhYÑ4§ÅÅ$[,ÎiYÆU9-‹Ñ‡“åû£œÆ<•#m]Z{í·ª]ð^V§$£Êm&«úg°œðã8tÎP5þ&mJ ¿¬‹I^_ÎI²T4F-ã鬯e´¬Ù3íœÚnÙydbREèTÓ쩲)Q…šQnC|Øxm µ¶ìÎP¯Ã¨j· ŸÒÞvT(C» ´A„Òb¯ö_IAC8ÆÓi6›œrtLU%e¯û@™·ƒ“ç@½3¼»,Ì fw׬yQ ¦òÁÓñ¸XG³ÁÜdðt,OÏ"ö³Ýñ-;a†TYê x„tÐÓUÑ(ïj™R H%B/œCH{ê<—¤€½!»~ÏE Â\W [u¦-$»óýB/y×Ll µõ]£—÷'™ ´)–Õ*e{C ÿðU߀ÑÚé¸!ª'_Û¹'@=%N%_Ð!+è~<]HìÙE6Ϧô ·Öí©UFm¸e†'”åól.¾õÞZjDÞP«¢î•Wö¨ ‡k½¥ªQ›CER(v˜h|˜nUÓ1Ù*Ê.m.9°kµaO»ÚJÇ~ „õºahÜ +¹á Í& ù³köòøý«W}]UQ‘À~’—»{Ên‹ ÉŽJ}v/¸ó“ÈÏé2m½ÛSÔ‰´Qn ô…¶i@—Oóå´AZ·‹‚Óë.°Ähµ÷(tuKJib‘(4bÂô4s Ú%®*¨xPnÖ×3콕Ú%ŠŒ…ãHæzU=•,*LƦ199¢º`[tý%¨&{®ûAOׄ·|Þ@Žb˜C‡ÜvëFqïƒÉŠkbåj´:Úd?Akå>žü×>k WFN÷ù"£ýÐРŽáj…×ø‰¤J=0¥¨¹ ½«¤ÄC|±ù¯@ÏÿkâÝ‚|Gµ2åiÒéÖFIã>¢'<ð Ñã¨Qc† l…ž 2Ú©½ØÑ±; €YD„ÈÅ+g[10Œâ¡U`j öG ¤Ø="ýÍÎþ*Ȳ{§ö{/€—©•~J‡[’,@Ø<:â§)–Óx¡Mâ~Įѳ8ì_‚س4Æî°æZÝjqO09†ÝJ#×íÖ¢%ãMè'ÛÁÅ‹MÍ^Ü×WZ6.âqøq…ËÝr¨mÙ‹‚ ^ÂÒ£%H¼©â}\yðº„g™$´Ô™Ò;CÉ•6:p|a0_H ¥Š©J|ï;(èQ Pè½Á’_$PÞô-všÏ³³Ù-Ωéüñöê§ñ,Ëé[ N)n(›ð"”ÖŽÏ“bC›ÐoÞÌ^žå‹l6EãC;Ïç2ôãòè÷£+ÿbendstream endobj 6076 0 obj<>/XObject<<>>>>>>endobj 6077 0 obj<>stream xVÛn7}×W `QíZ[vô¡uëÄMZ@^Ô.wň"îEŒü{ÏÚ•Ö©:+ÁÖ’œáðÌ™3üÚÑŸM¦üMV½ßg½a<Ä`ûÇåtz}F£!Í2¬¾ÆÔÏãGÒÿ[jQÊ”JK‰5¥PFºb@vÃÿjMª(*YP" § I›…4²–Ž0bç_dRb ‰¢P¹ Ž­äjŽÖQ®í\hªa+æZÆtAy'Vk-/g_zCŠFc„ÔÇö…JaU.àO™RºL$ò^tz=¤ËxÂGÃ`<Ž'¼¥ýã•M+-;‡Xƒ¹¢t‚»¶–î›üáBTº’o¾›c :1ò®ìÎ}k^ƒ^v²"¥_iè§ö@G>ÌI<^p(Ÿ€mœX¯2^©“Y¥b!]-Je±FiMð³r!ʃD$ ardâÿàÿõæˆèƒ ü\]Ö{ìŽ)£$—%Eœ&Ф3;ê¼S…¡ç8²“G¡¼1 ‰(䀮˜{ÆnhauªLNèeÒI“Hæt¹;’FQ´µ­ø8×[J­yQÒF€È¯M%c·¤Ê˜nÕJiáôvv³IR¹‚2ëšz(Ï‹«S¦RÞxþ œógäù³&Syå$ELòïv~à:ùìpц0ŸÌ33°²EIkáÊ+ƒu[Z #r¹’@'0N® >´Pi*MLïì†E†áG6!=Èc‚œ£H„Fú UV¾d|A`–“»Rù„µlBöYBn±_åíB^´g³½˜…\*S”B•6²”ØT’VKð Ì:ˉ†Ò{¶¸oBi¤çCÐÌ“ÿŸu5×*ñ®[„¡UµU)—Ò?Þäs¿õðù%݃ÕoèÛýâ8î {´¶ÞÛÍÁ9s™ÕÚn¸°¸H‚§~L»àjÙÎsDWN¢×ì¡î„và2›ð²·D©§mnwub u7=¢[ÈŸy°SýŒraÓGëŠÑ^l|ÉpÓ m·ïUrï¥Ïªõˆb…ýZ˺»?,¹1ú8(’ÛO7oÁ{–BHÚ–Õlɪè[ˆï§<éEÌɴ儯Ž„ \ç%· ؘeì—¬ËeThåÂV7Ðêz·mnsÙHªL}³rKºzõ*Œ£9C¸ã5éññÀL™Ú.Ñ)…Iˆ¤ï˜°ÙÉÊÕ2Z[TL7kà H„®’%•Â[Y!á^&@¡œÅ(4áLTºl@ŸqŸWë–Ð![!(†t€Fáo>ˆ´¶¸á†ÃØg'Q‹Y¦EÞiþòóø½\ŽRß`»qDoU -lc»«S`Ú`¸« ˜‹äk¥pìÃçˆ~Û¶Á.wT]žÅç“sš^â¾îXL®hé›T-Jl†[NX]„v0yŸÅcúë¡Èóâóá4žŒqœÃsúsÖûØûh (Qendstream endobj 6078 0 obj<>/XObject<<>>>>>>endobj 6079 0 obj<>stream x½VËrÓ0Ýç+î0tpÓØu⼠ÂW™l é° ,TKI¶d,9éôß¹’ì$IJ6L;­^W:÷qÎõïFBüiCÔ7¿qÚx;n„Aˆ‹ë?ù.¯»Ða<Á³ý+P»ƒØià H¢$dR)~Ÿ0Ð(# ,¸žâº šK¡ á¿ps†ç ÅÅô*c)É”ï„ΉˆEëŒÇ@¹Š ¥pžÍòà|ü³qy}ínÐuHüÎÐ ©]=‰¬Ð@Yh3ÌHNR†¦Ê™n\ð;Ý`84–o –i*d¹Dà)pJ¦ Þ™•)^ Œw3¼61€7wâЂ# L3t:“\˜×¸–9°%1«/ÝÛ! ƒÈ î„àw:AáŒzsÉ)úMï<4…e Ÿ×°rÿš9SE¢ïÎáÁÜv&Ô€r ^Ã.`õª¶ÿX÷Ö·/FA¿?0Öˆ,cù c~˜Á¡Š{‡«Yk®öÉ™.rÍåEó$$ãFgJ¬LÍØ0›aŠm— fw \Ä-¨€»‚ôª xÝq&‘m.Qìý;¯¹Ü’ãro$!ÆÞj´³ÂQÖÓèó±[ kÔÇûÖ19t]**Z¸¹ít5?íûOF¼”9RF›nB )` &PRÒJÂéâæAô´ºù‘‹Ù°äe{Ø zQúCì±mÛÕ¿~}ô£ „÷2.R&°L°^ŒЏ;í\XþåË¥öƒ¨ƒ_^(<ƒ°oîù0n|iüP Ê©endstream endobj 6080 0 obj<>/XObject<<>>>>>>endobj 6081 0 obj<>stream xµVßSÛF~÷_±Ã„ã€lc0¦™>¤Ò>$MS3<àLæ,ík¥;åtò0ôoï·'É úÐI··÷í·ßîÞ·F—:øéR¯Ï¿aÒøeØè|\ÿ±Sj_P·Cà lûçxˆü:Âæp&)1™£Ð$‰Ñ”g’Ì„ÜLâ!Ke¨DLn•ÊD¤dóXf¤2r†fBG±¤I®C§ŒÆ·™pd¥Ë­†G+ùƒ&£%ÍEœË€®Œ%¹IËÃá_u¦™™D:•ÀµXû+=ñ'+³{ÄÆ!e ¼­|zª‚-ÒÚüýzøézX÷Üôé"16ó:ù»™ÚOL„4W™ª¼¯t瑤½RY öê"e˜{«EwÅ[Eä½'€sï9 ‚ æàÇœ¾”Ê›™ôrŽp>”²¨ôµPÐR%WèKA–…R¡/–X¬2ç±=+ªLBðt˪$@{¿B£†nŒ£½/µÐؼPÙm¬t$—ôÊRgÛ¦bê‘U×[=Ôñ†jÞjƒØ¸×pREUFéË‘¡4ÁÈ·\ÚÕšŽ¬Vž»27*¢©t_#ԬθøGÍÂYµ¤VRêÝšEV>†&ÎؼPún¦°serJÔtæÖ’Ÿ»PzºÝÿ¥ßí€èRþ<µ^ÈÑG³`Ré“´ñnXlÈÝÖE¯’mÁY¢µÖxÏš 7L*AžS÷$8á~[HrtŠFÖ;út¹ eÊÓ¡˜ÈăŒ¹EŸƒï|Û]m_VûëÛšˆÌJŒ¹¤3f,Y$O¥ÐJá$ªìQ$'J‹±ïf5$¨°ÈÝzêÇ]hô\Z€è{¥%fÚªˆý¬ºh_¼~M©5S+XàLô–G»"¸Nœ’gÎ$ê»ðDL€/ÇDC­j'榟•‘ÄK ÝsÌ”Ça²OÔdêûšÀÑ#È£bœÃjt@›ð ÐÏÄž p·ìñË&:¶Ô°ãÅíµû Z<¿ïdæ¬Y1½ó–Í?5˜ÏÀ£HÆÒ‚1¢'Ïý\ÜÕX$¸§LqÙ).~Ï àLQi9jV(ÚWƒònÙœ§½Sêp›éú[ן7¿½?êðæ˜Î×LJnQX÷€ýâ´ÓzǸ»Big3Þ~9lüÑøŸJéendstream endobj 6082 0 obj<>/XObject<<>>>>>>endobj 6083 0 obj<>stream xåVkoÛ6ýî_qPl…ŒÆŠl%Nº­²Ö -æ(†z(hвØR¤JQqŒ¢ÿ½—z8ñ£k7ìÀÅl]^‘¼çžs¨½!"ú ý?Ï{¿ÍzQQps±K_F8cÌRŒ"ŒŸÃñø ³¤ÎŠ0ãê?+\e5ôÏýÙû^„ÁÆ’zìs¡ÇÛÈñ1®„ÓNäH­Éá2f-[S8A!ljlŽ…©tR‚g‚zîMž˜j¡–Âù©æÔrÞǧ½L@¦˜”‚_Ÿ!¢œÇé^âèyÞ?ðÐVU8ûVþ¹_ T)>é2kV˜2½k¥•ûûÄææ6RÿSdnLPnár„®[¦þ=Œpð 4ë~… Dû*í{@:˜öIÕE>×+_žÀGR ˆmƒQÜ’5˜»ÒJs'.ÁÊÒpÉœH°’.£mH☢08‘²ÙÃó'O`}!î¸(ü³ VzÞšÊ L:héÙò–sQ–!ÞˆzÎo§–º£ÈÈKÀT–t£hV'tég]¬Q‚ËtM$¯ž¥ÌÊß¼P´#I0NeHâûO~ÂmiF£0ŽI¨Iðãý~?u+·âsv} ?°™FÉ÷×F§%ÊjQ’¾*m•’+¦6xRµJí,³Û°Œyð@‡4J¨¼#öß8K•¿^¼ŸŽ"V”•rG.j{:wÛ xtHZ­tgÏ_¾›L§¯§»ÔÜÞb}÷Uú\™Y飺7÷èfäUÊ7‰›D—”‚l,I(g nÁ½²¬ ?ÛàâFjjdÍ:"^ir±Êù–i*¹Ú…øÃTÈå2s²5u8ÑW&4™©ÔYv6Dô¸ÑŠZUt¥»†^’#.3d©J~h¶ðÝTj=v>I©n÷-ý¶AQÇ‹ä¿Î o%u„Õ:ëÿ¯ªäÚ[§wRVŠƒJ!bÒpCLçêµL:JúƒÿÞ¤5ËiØóÇû\ãêAËÁ&Úy}P¿2ìd¶ýÙÉì^ F'Þ'¯S¬IfKÀ ŒƒI‘È4–$Ø)å¨Îñç«TrmËàÖ…W¹aUú 9ãÖ„¸¤Bܱ¼PâÊJ¼„¦¯®&EùÍn^þ–s7ež·0 ÏOÂÓøcún„›7×Wƒ8ŒðÂð*§ò˜?ÎücDí&{pÖ¦ñÓpŒÉæÄë<ÎçžFã0Ñ[#wûÐdÖû½÷ŒlôØendstream endobj 6084 0 obj<>/XObject<<>>>>/Annots 3293 0 R>>endobj 6085 0 obj<>stream xÅWkoÛFüî_±ìVi$Z/ËrŠ pTÛ0P4­, ( 8‘GñRòŽ9-«Eÿ{g¤^vš/Ek’ZÞÍÎÎÎRŸOúÔÃoŸ†cþ ³“^ÐÃ~éóËìîdôéb|ô(£ñ Õ‹”Nö–]M‚ÉÞg£Q?Òèê*¸Ä£É ¸ªW|ç»ùÞIþ8»¢óÛMpÓ<¦AÆWý`<¾¤yäñôh¶‰þz5ÿtÒ£nëëP¸0¡E{&ôJÞXkìâýyD¸7ýø ݃³J¯Þ/?-ÚW¬,ÊÔuZ×ÖŠ )É'2¥ëš¸»4¥ŽŠÖâÕ÷Ïö²Ò•VÓ|úÓÇ›Ùìýì8ââáêLê(’q½'²Dgò)”¹SFÓJ:ådF³ëŸïn^Ú}/¶øBìù툘˜ºØ¿;Ö,¶”%=|¸¿û¶ Ý™‰ÐQ VHTÒvOi±Le‡6¦$a%iã(U°Eä M_¿~aƒ€¤$—H ‘;iÉ膼'Úò«C¡ìíiY8“©?„çàV ð+‹ÃàF#íÅÆRf€J>‰,OepèùíõG'ç´'üoÔ²þæ›\f"÷[îèá¨Q0™pØ‘;§Ø«M]y_Ï/“ûN‚I¹5¡”èrT$¦L#ðF…C¹ ΃3¨™@†µðYù¹åÂ:2qÍ#K¹Ûír_.‡ª„Ô0)µ)W ç™™ÂÁ> èg+¦Ñé†;!"ûꯅ,ò†ÉPa2 ârT„±ðñ¹åæ@}hÚe’•Ÿ±åNš¨c%Ìq#KøêN˜‹ÙdýÃ3@¢^È×MÇ£V’o°-Ph" ÑÒV}dË”»±>À9&^*eì*†d¦[mt ÝÖÕñÙý(A7ç²’öÆØšŒMÕ»Aå™Z%Ž ¡4èÙ¢MÕï CoÉï,¾;Ã! &ˆöbÀ5ŽeýTYKbÑVî@/8<áõZ´êãt÷Úݤ÷z_޼sªt^ºÎ7§}ìòöíÎÁ±üš©óöÄuÖ.^´[3J”;â6äÝA½¡³h±Ð­ï8ކ€Ò0\Ig‡sJ>A4~;toè8[GHøp«3¿×ÎÅŽL¾éP¯d‘®Åê* *´xTYðV;%)( {vÈ»š€Ð[J·(“.1(‹! V>© VÙUè¥SðDCƒxÖgcÒÎßà}‘½ [›ã±#"ùÃ^h³ðÃöœ¼NÆ?_­5‚ ak0ØrªdTR”ÕŠ¦G8Ñ2ØÕ7;7x-ùG‘–l Ûü¹µé2[òT‹«‚]²Ïó¤„00ØŠ—VÀ·æ~zœ;ŸY;Žî‡oOÔ<Å1‰I#i9l;!xêJM¸ŠÝ såÏsj_â ÷O`˜÷ªºfù©±Ãä–D#ÒwG›މ‰¬õV›—&4Y®R вçTVᇈÉÙî0ï0Èb“¦fý5ŸG"¢à¼>#(LÃcå5¾÷h|pñån?Œ¹ô³;jÌFK;‹Ý-­õÊí$ `†¥µã½h†LµýVUÏ«¸íŒ€~Ã?´@–ì4¾‹!MßžøÌøgN‘6©ú' LXþ†Ì5ަ¿jàú·pMoÿSÞÔÏzýÉ(¸^Ðï½¾~þAfˆoX?šÐ›¤Ÿà\ˆ¨Šî^Vßxž=Ï^ôÆÁp€G^ ÑËÞßt3?ùõäo¶- Lendstream endobj 6086 0 obj<>/XObject<<>>>>>>endobj 6087 0 obj<>stream xWÛnÛF}÷W »  ‰ÖÅvœA‘ºqb hPG€_+r)m²Üe¸K9BÐï™åE¢l×AÃàe9—3gÎL¾Œi„cš^ðo’ü1;Å#<ìþ”K:½>£ñˆfÎ^¼ÄEÞã"‰n ù•r”'¸”ä7…ÌEA‰M%á5zCÂ{‘¬dJÞ’(—U.w8.<Éo"ñ8’ Ÿ¬èdöùàô1‘2žLý¬!Šù~DÃÉ"‰fp)ŠB«Dxe ÙŒD¼¹B&*S ¥Â ŽÍ‘0i‘ã‘2k«×¸Èm‰VÂSy¡q-¿ùaˆM™åpØd#¥lâO8ެÒHñÊe)<2Å¥ €|¼»y"ºó2én% mlE©Ì”Aü]À™-`ÆÀµ@‡ì:ÜÕwÑÛû4äþµÈ´—ÀZ”*@èÈU¨„pûækœç¼öŒÆˆ4U\€> êŒ)³ZÛû9@°g¨$ZDXs1]p„‹ñ[}rD—ñ”é8aLâéwitÜ2kæ''úÞæ>¥5?*£y4Kô§wÒß]ÚüÃâ3èeY Ž”)*?øåh ;¯_Óìê¯Oooo?Üâ¶”¾*ÍöÑ«G%LeóèÐÐk:Nçss8`kýÓÿö¾=VF3Žû17 …|«\ʲo•ˆ)C+ÍÑ“á…Wœðé)½YØõ¶5Ñ•5i:tŽC<Ûn|§ñÅÅ ï½½—kYÖn;‚û­­JÓ³OT5è€M’ªävƒ,HJU).3”í4Ú³c÷#ÑäW»ída@ ätd¬o³CK´‡Ý*¢æ0÷C†{V÷ĦÖ6–;0^;K dš8ÉKZ–¶* yäÏ8™T^÷Îïϳy%+QүΣ\j-™ä}ªp±Æ`\Cí4\vìîh=y@Ä–Q¨8*Íö[p)xMô˜÷ðÑ“t "'(¯´Wî¬(Tƒ[ͧö@V@{/6Ž Ã©†”BŠôØ,¡ÇHìâ3xÓŒ'¨¥…GOV™@§ýº£H•ƒ­¾°¸ã£yš¨DÒÊÞ‘œK¿¢º“KôS˜\¹òPòùÉ3ºScE’ßKCw¶Ôéa˼€è¸¦ÕKâa‘AµX¹ÎÛΚ¾Œ_ÄxÔ s}†iwó®(åZÙ B]·)­+0#Ì0óP™ÃÖR %ȈÎõ@p¿01®bzC,ýÒo˜¶©Ê2Yb:wߎ•MC]Ú”B3µ´_l€|nÓJËÉQ]˽ÀîQÄ+æ.K-Dò…o°ìÄ4*«åÊwÃùØÊoâ*ö"áŠ>S¢ÖyKÍlxØ:Ü5¥Ç$¸•´íæ¿ø[Þß~7XÈtP¿`{ÒÉKJ=¹ZaŒ¦Ò ¥}÷ÝÍ©EŸžÓÅå¤VÞU‡ÓxDÚ$,éa ã0Qîúìð“-‚h±Ëbenãw>}>ºˆ§üqž½üsð®‹Æendstream endobj 6088 0 obj<>/XObject<<>>>>/Annots 3295 0 R>>endobj 6089 0 obj<>stream xVMoÛF½ëW ¥‹ˆÖ—e»7Wƒœ‚Ör`¬–+‘Î’Ëì.í¨¿¾o–¤DÆ‘*Iœ™÷fæÍ~Œi„ט¦s~Ë|0ŠGø‡?Æüñ÷ÇÁ,ÆãÑ$žSN³ëø¦ù¡éqðDzcÙ-]=à숖8žßáKüዌ~ñ»Rå¢\EÂnMåW——ËçÁÕì91Ñp2ÑèsåËÊ̪\žJk¤r.+¶õ‰6ÆŒ'|äàܪžZ‰¢*ÉlhSÒg¦ ¨lA/BWÊ@šÂy/ÖÇó_X%‚k„YJMá„(¼£UÔ~'xЪõqQ8"M²·~ËØ©ˆY‘ù=Ú³æ*_+›­ñÛxÊ{”ƒytÞV ª+©…sT¦Dxq™[mÖBŸjAµ9je3¦ï¬r¥J~=ŽdÁÝžÊ n½ºâ3$j#*}¢å@ jÌjÇ´1–DqhðU”‹¯Ì'*eJn¡W—ç„ÇŒp}ãû„§þGõ"zƒ¤JZ+¤ÃOwܨ/Ê:Äwd¤¬lH¡3f¾‹¼ï\xŸ*§PnŸšÄÑk¦5‰²TÂ’Kõz×äG<¢¬ÃÉœguzßÄSZÖrðc1Ûf j=ø’ù4+¨Ñd™¨÷H¿¨¸MC–JäÁ$u‘*A^>…m¿’ÑEý»Q.vMö1Ý£FgÕØtœJÔl­P½ªHÐ(Ìûًлð«/¢ŨAºõ ±­fFïH¦¢ôÊÆ´L3Gx‹}tÄ Ü iòjµoýßû]ÌîÅ¸í «÷´ md‡'8µV¹Ò wš‚à Œ3Œ˜nrÌì&‘5Þ‰lu·3¢$³ òú¢bz@³w§ê=‚´(›„o­”·a&ü¯Ž\U–Æ!¤—ôú8´p+å0º‡ ŒÈŠWȼÜþÌ)JZ— Ôûø^T}ä]¶ë'­´GðõôyýL¿õODÓ/Bž¼0Ìúì5½ÛÑ 0¹g§FÞљԋo?ÖÿÉŽ«Rt¡9Z OB‡6^t'¨?"Óò³…¿DJaa) ¶ u¢W}"¼LUrÒ7·ê1¤ì»éèEØJ¡¯¯´ÞTü®&'ƒèSQîQ%ÜP¶¯%jD´QÉÿŠŠ[¨§-pÍ*Ó)æÛW«¦¢H†.K{´`¼{å©c‡Ë’)• ·,ZO`L6uNØÁ7L8ϵ…Ö@ÌXþPOެQØt ô{ óô–‰²É  ¹²¯½ û‘+èÕ2L»ß½8„=”(Ü#8ƒŠ/|ÀÌÇê„^#Ï_ר‘dÜáICÃCöírÛÜ-Ç·³øzzMóÛI½R¿|ú8œÆ#úÓÈpÉ ”qƘ¡ÚvxÃ7Ùf]aƒa.9´IòëÑ<žN°Õ`r3¢ûa9økð/b½f*endstream endobj 6090 0 obj<>/XObject<<>>>>>>endobj 6091 0 obj<>stream x}VmOãFþž_1BIe ;!zå½tâT.U?ÔÚØëd‘íõymÒõ¿÷™µ0ø¢(ë™—gž™ñ·Oþ}šÎù¦ƒ_Ïõðp÷U¬èø:-bèÎÏñ#²rü¡Ù¦™Håþâqp|}ÒèM<:šœ@ÑY¬%ÔbÒ1•8o ‘ç² ¸ÊÂR錖Re+ )J¹µ©sò'ìòˆmùÖÖôÜ=uOè£ÎždQòam'Ê”TjœÂµ(èà Œ÷Í%…:Má1/ô2‘)©ŒR‘mé#?Y"5¤Œ çPÃ^6_YD‰Ê$‰bU¥2+͘6k®ñ@Re*‘$[Ê…12bߢ[Üç€8 d9wÜÞR)‹Teœ/™²€ãcë$ÑöúõÏÏ70ÅX„¨žYhÞ¤½dç°#XP§ÞÖËéÄ!½|”aÙ íÑ™;e¨mÕ&îtŠSäŒRUì³X=5ñC‚ãcDÊ(É$1u˜¿ä굨c1¹ •H(Æòƒ°Få6—©ÈGeÁþîÒs “U"þu¾,QS.2Â~úð^ Ye¢L•25?TQ}Ò˜‡]Ý ÜÝÈò ìàsˆ(A>¦¡ÊòªÓOµühCB ´øxûpuÿåÇžLa!˪È^{"ùï}vCŸ.^SIO™aàNÉ¡ìõ¯Ôq«ìû=Öc]À’‚=ï)ú¥Å‹Ôááw£ú©¿q…ñ0_-[¯ ¨Ài1€ÎØëuÚ›RmÒëÆØjvi¶RO²¡™Ñ"a"EVåhÉH¢SAºJZI°Èp#Ĩ˜mâÝ„aIÚ Æ…”à8òo b† tŸ¥e#µB7%ËË6¯šüíi—åÞ qK‰!ÖÆkº±ªÌÎÑsç1Ó>Çè(>ˆÚ„ÏýÚ'ë×µï˜á1ÆÐéÃwQšÞë6ë4Û³š£ˆ‰12AíIw×{@àë Ù{I‹G«5}ò¦S»z£7G•…IBì•abÖ®Úã_’Ý"Ó©;ŸŸòûŒ. “ŸkïÍ¿WàÒóozÑM¥"M·˜êÛ®{›¸Ç`°^^+òYdo¿—MXfmvdÓ:¸ÎœÌÚì*œÑ½(¼-žDR¡Mxí´Û©6ЮäW[÷ PWå5£½Ã{¸Þ$çM Dm˜t¡V¼®ØUŒÞa[®îºtù"ÿi2ý\ìËëHÆ*cËktÂ+ß/¹ÐrKüÎE¬¦ì¶ç7‰Bš*);¸½4v!¸é Ëž¯…©¯‡yºÙE£Q >ÜÉÍ'{ÏŽ9ný÷ÔµŠÍθ´á5kc·5†u„cýöºåÏñõYóÂ䟸³éŒæ§3ׯ÷/ïÿ£©ëÑ'Ú×  ¯-·@æZûè´nË,íz«¢d…ÈØN‘™7w§¼¹ö§þ„±ºZ ~üwÖ/endstream endobj 6092 0 obj<>/XObject<<>>>>>>endobj 6093 0 obj<>stream x•WmsÚFþίØIëf@dÀn›nRÏd’Ô¦Íf:BZ@ޤSïN¨ž&ÿ½»w’@Ô.2ö€^nwŸ}öÙÕé¯Î\ú7åÿ éü²è¸ŽKë/¹áÜ…KǃÅÆ.L¯FÎt:ƒEhV¹°ºÃ!\ƒ~Ì0ñ3ÐÇQºûÏ·ï@ ˆ6©~ ¾Üä ¦ÖBB”f¹>_Rú…d²‰‰Íüî )ëÝ1ŸMU”Ö6 >Yv9‡Ûÿ¶HL7?qê1Æ„Mèê ‚¼%+Ú¹¼0[=IŸL„jZP§#°.uÀy5&s5Ažý­I豃][ ÞcºÑÛ–È^[¿·iˆ·sñÒÖÙ–yÚ)É©f-‹}‡YìØÓ:’Šžè\@ä©n 6lÿ«úgíãꃖ­f†ÅMžÅ¼µA²´IÑQϱ.ëe)w¸~ÃY½ÀìÛšqþæc¢©{š§>i8¿,â£Ë gâM`zyéÌìV‡_1žãÂÌ›E½‰£§Ÿ]=˜Ù— ³/™”[!ÞjØí8U¢ÞÆ™6q§Ž7¦·"Ú-ÌF÷×ÛEç·Î¿TÞ endstream endobj 6094 0 obj<>/XObject<<>>>>>>endobj 6095 0 obj<>stream x½V]oÛF|ׯØ5 ‰¦D}…_êD¢Im} œÈ£D‡ºcG)FÑÿÞÙ;Ò‰$§MZ °-™äÝîÌìÞ,ï )ÂÏâ)ÿ&ûÎOËNF¸ùüa¶t½xMÃ-3¬Îç´LÝóˆ–I¿gጬP©0)Ù§RîEY]-;׋1 ±Š÷ FãpŒÁr')ÓE¡¹Ú>/§j§ÄVS¢ÕAK‚2yÄÕ~¯}ÌUZ‘ÎHoeb+ÚH{”RDAHN·´ ø¶ùAb7VXi(O¥àˆÎ¨€…ɤA •ŽÚ|\]yÄ“/óª;eåQ<¨*×Ê/ŒhÆÌmÄäFaã* ~h¢®‚\­®(W¶ÏÜ ¾ ´ Kñ ²r_þxñ ![¿“ Fïßo9.H•}êæª¬öïFª›ZÞþ¼~{ÿþÞ³a¦md2ÒÖzµ‹.2v‡tƒœÝáº`ˆy ìÏæxzÊV×ö›è2¡GÈ‘éYÕ…í;ZЮ®Nq¹„׋¶.'wN§3°(´°ÜH¥f!ÿ]‘2Ò§T×›B^V¨¹©Wï‹"½qûÿ{þBýå¦JžÑI¡¾»BÖp}nÝ™þÞã“ì„¡ÞeI¸Ö…T§‚r¸nÎŒO|QŽWØwÞcØÙöµ?0íÕË]þ5Tj>ñ‰j_mëÖX}[OÚ¶v®:§ÜÔðž|­€ŠÞy^0Õ‡ßîÞù# MEÂH‚—2ewÑÎ!+W†ŠOˆ¹rÞ 'ÞÉO"•I¾DQÃ6ÙBqúC:uê¬V‰…û!„P°Vª+Ä·ºµ-g©‰‘Âúø/m!ùÐUèñcà| |ˆ¹šÌ`í›Ä~°Æ;4¤žÞ<öé ó”z½ÒØé1ß®â:W™¦ž}ê;Í ±­ZoErváOò8Ac„N!¸{*rÀóD`¸8ƒ‘ÆËâ]‹‡Š…ˆÐóŠ{›òŠÊB$­òü´ÙûO MJâ")X% ÏqÙ§³œIð½çqæz€e¡TV‰ÉK« ¡ìuÛG9}€VüÀ©õBЦ¬¾ç$Ic&ÙÉxëºCƒ•!Q•n CƒÏüCº³Œ,©‘Êõ3B¨&Íd™Õ ‹ä§R(–.¤{7Ÿ*¼,@ȪNY#Úq0ä;ÉY ¹cã§9>×/®“~‘ÇæðàÞ*ðíóíÝ3oZtÃI<Á[Oò{OÀÁqÑÔ{PÄôño€â×fÞCþîÍhMÃx¦9޹ o—_;i;Ó endstream endobj 6096 0 obj<>/XObject<<>>>>>>endobj 6097 0 obj<>stream xÅWioÛFýî_1H†v$Z‡-Ë-R — Aê¢*Š„¹”6&¹ w)Y(úßûfyHdli?Ô2t¬vgvÞ{sèóÑx i<áÿ 9z3;ø,6OùŠÎ®Ïi8 YD£M®ð.tð&ðÞæRXiHP*·Xˆ)Ó*µ2'½ü$ëÓÉìÓÑÙ5Ü8^fór¥6ê‘2dײ9h5:ÝÈÜöº‡í¿ýqó3Ù]&)”&ÈUfuNÆæE`‹\¼°Õ7K\ÞØÎ€úâñø`Dvýémú€CAQ,V”K#ó )‚¯¨pŽä}&R£têó¹>«\¼ÑvM:b×FbwXì20ò¹P |ƒ-‚L&%bj¢ê?•O³5 ÛG Ô¬P0ªR\)ìÄRö‹ˆ‘®b\=‰óÉø‡ÂŠ ~îóÅ6"–i  'C[Çüú¥£Š9•®>a¤èEBo_¾lA¯ÒµÌ•ðâÓ5€%À¡D¾εÖtÚa£Ç=Á;à)L!âxG"¤1׎të­ù¡ö0õÇ•¼û£‘?ãSè9ÑõmYöžŠhî1+‹·¥Bom>÷ŽUšëÜÛhÒééü„¾zŽ¾ÙŸ·ïÙÆz4Àú«WP^s ½¤ôñ÷j \ …¿,?Ñi½ÌyzÈ&zå,.>Êím™cØ7÷väNï3×)q4ö'“K¶v]8Ø‘=‚áZ1ÀŠ·bgh)÷ø†ÉeÜk™²\`ˆ6"WbË.sÇÃÅ^¿KÒå½H²X>MÈóÊÏÜS)tüÐ_-~ˆÈQô8I-ŽŽ‡=j]®Šž&©dãïv]t#CV›Èw%ºûð]±é®m RÆV/9o¡Í=¶¥ƒFüÇ{ so~ÒvïQ"‚\#÷¬þÿ¸ÞØq5?q)ð ø^ÑðÜ?çÔ,žúƒR¿ã+J3$KQ”u2Ñaí¡ùh,q'ºÁXIWŠ÷©€’<:÷§8ï’.á‡r@ […R¸Jœ’¼·ÒtÊ*kôf‡V‰"FÊ» ½’©ÌË.ˆ²Xy´°Pîe@ÜÔ\«ÄÝK3]«×µ!#]¡®¿'´@n%=2 Ù±sý¯×ÑF?»[U[»ºÐ÷€oÑ™­ZQß¾»„ª(\’úªí¥#þ×7ÿe¡â°®-B*‰êÑNˆ!×°-ƒÂr£–ô¬Â[$w7h÷mÏÞ3 œ •… Ѐ4µͺ.=]SŠTÝÓOå96ÎýÚÕÛçtà–ü&xÓPVm“÷ʶ¯ÕÄ5é’{“"‘>¢‹ÏGmcˆq«0:|Ùiª%9uÒ¼^¬ÖÛäDo mh ¥Âš:\'= :dŠeˆQ$Àè´£íZkZ£Y²Ãc‚›ª…Æ1·ìJ_Ú?«öÕž‚(ÙõoP¨×ðúæŒLŒ[ cHËÝ!=Ù«kôµÚÞƒ¢lcß!òZ¥½> ­F%.DoÓM­ª„ÌØT3WØW$óTv–Õ¸™Ÿ+k'UrF"°tÞZµ?>oGØ¡ü&ªÛêüŽ)wɈ®]ÓÌì Ès°O51˜7Q•õ¡–&}a‰-ô(Ôå* –Vÿ€Xd™„†*r}î°€ý7ˆÎ®§Õo¶áôÜ¿_ÐdzåO†n8æìéý½ÓA‘ r÷cƒ±‚åîþeYIÑ«/Ñ­«‘%% c É{/<ÂOP´âËá/½Ÿýzô_eEendstream endobj 6098 0 obj<>/XObject<<>>>>>>endobj 6099 0 obj<>stream x­VÝoÛ6÷_qÈÀlE²Çi¶‡v›‡=uCôÁ6†¢m6’¨‘T\ÏÈÿ¾;RÒ¢úc+Ö|4yw¿û¾û³Aˆ¿ÄúãYçÝC' B¼l>ô®gcˆBxX!íä‰{Çï½5À`%s–B®¬@¦Œ…ýÄg–©0(zƒ°Pv# ÿð©s=Ch'¶W0þÄÖÂßÖ`=à*ËXž˜fJƒ‘$ÅZ‘©rÒBÆvðˆ—ÌH¡áS‰àV É aPÝÞÈT±äÈÜXÁ’À¿ßA4ÆÞüáhJǤßwð®”i"ó5äb O5µB¯¤(Á ½b­_ôdNw‹~•ƒé”¤½Ïq’šÎŽ]K²™)·dô‡w¯4HÏЭªÎràZ0‹žÈ­Ô"ÝÕÉk„n"Dm9+UÛa*žEêqG+ úUæÜ’ß}8ªðÀ”E¡0®¤È†%˜©|ÔLïȤH LÃKÑñiÍvÞx·„0 bròˆ3 â¿%½ë+˜IŒúOH¸º®µ¥Lì]f*)‘ÀI«^P½È<•èØË}‹!Qå#Ò_aÌþðgŠÅôúK,úÐ&†êG [êcYs#eÆÒTñE¯èC­ê÷EÑ¿o¡¾´¾=+™@"RaE£C-™Tb¥…XôðýœèJÌZØCÉÊKüOÄç“ •¥lîÈ–ç œæ_€XþÎáÏ Kà„{k4øì&àB‡‡¯‰›ã;4’õk ¯þg¬H) Ô+ß8D„@:ŽàÁ¾M`.]†ÿ3*†TÇqL&·TŒ7TÅØj°QpU¦ umŽ$°°aq›î°­YjlµÄ†Æ\C5\ËÂbgy")ØûηB+o©ÁÀÞî áªûåHö¡s °æÔºŽ´Kµ¼lÕ+u¢ä*G„ÔÏ™°•ÀÛ–t™^EÕôÓ™9W9ÇFÞuz¤šåkQñFØÎ“å [iùºèþ@aB¡Ì0ØWe=m¸ ¤«Œu:\,]ôh^ºÖéý'Ùý;eÔe÷]ö¸êy5³Õ÷ EÎ24˜¬ß¿\Wäðöðæ;øÑ@~‘”ºlU%®4Ú.\†8P¥}tuï‚í“>ï»ø—‹W^%žÖ›Sî‹Z5µð¾ÄeÆç3­¡õeç'X3 ¬”<Ÿé¤7ƒ¹ÏõªÕFa¸|Âê|ÿÊCåœH[ª¯pÒ;gH±`º¾Ç-Ž2ç$DxôI^*˜¦²nÍßvu™s'J­²…ÕŽaECDã››#4WˆüìÎi˜Ég™”˜Õ8N3Ü~áz6­VËh:nâ˜L£`¹•‚–Óa„ð“â%q0Újˆ {–§ÞzpËÃý '¿[Äü>TíØQq“q½é7¿½ºuñ&œñeìy·Ñ„¤þüÐù½ó7ô­G_endstream endobj 6100 0 obj<>/XObject<<>>>>>>endobj 6101 0 obj<>stream x•V]SÛ8}çWÜ…Ì4,Ä8 èî ý Ó—n·ÍLH'£ØJ¢âX®dÇd2ü÷=W²IÜ„)K;„ttî¹çÞ«Ÿ] ñ¯Kýÿo†abñé›™ÑÙmHWAŸ†Sê…4¸îƒÁ% c·+¤aÔ¶2§ ݵÍð©~§g¿þ:¢/27J.%‰”d"2͇?Bê~;4%èîÆ±"•ætñ"ÐÞ)r‡…wØYauÖTZ3=Eá#­[Šþ>©42XìâcÅ•±)°ZÓñu(-pb$`„;¿ÕÛútYŸ|î'nü @È ÒX-U\ˆäE< ¿Q˜~ƒéUF²b¨é~ûÌwÒæF¯HìÄúB- å@ÎnÏá6§½ÓëW®jç’"­Êç*‘˜è"çÏ–D–-¢9ás>HjN q/ñœX,4 ™K3‘$Î|^jŠÕt* ìÒ[gbêò3SKèÍÝãtÏq_¨®ÙU·±¶œ×¥0гL‡5‹Ã&wÿÈ6xäF#ÓâÀd\ ì][rÅ*(7Ü1uºˆYø»7d\ïõ}ßÛ¯+ÙT8°æWt öSt‚Ð÷äîà-2H@­:úŠÊî»+õÀà¬xŽ»ûvV俉[qîp~ÜòÎ-¶ÂhÔ|j<— ñEæÒYéô”»vVœ%«øi-.gÃCG³µeÔÇñhÔâ õnüÊ{w0wo9¢¥òV‚—ج@SäÚògž¼ºÉVQÒáÚåß™*z_F¯Fžf[~t£ ¯€WHÏ«FgBOÇ@ð?.ÝLß”À ä¨&gHã@ýØÛj·R( Y?ëÐÅ÷¶ÆUS™Ëèñ"BºòNeÊ9‡ˆ /¬N]ƒ@]/vAvVðÒYÿqgäL>d´ß…kÑ™~ÿs½I-†7;ÖFÇ t‚~ïLÃËî%/½ü{ð‚Oü!endstream endobj 6102 0 obj<>/XObject<<>>>>/Annots 3298 0 R>>endobj 6103 0 obj<>stream x•VmoÓHþž_1 =)ÐÆy%MA÷ÚR•«8ŽîK¥ÈYoâ¥k¯Ù]7D¨÷ÛofÖiqh¤••ìÎû<ÏŒ¿´ÐÇ¿Œ&ô/òV?êã =ôøpÑŽGÑ 'Ñ1ä0î¢qýKìõ:þN…õì zoú0F/a؇ÉÉ šLŽ!NÙpbÑü“Î[³Aq GTÀÉÄŠìº#2DγÛDW]íHÞ•‚BÈYŒ$Hnã¹äÓ:åeŽrØ3"Ó#.Ù•¹¹•»†>ð)BM,­ÉS®W£ à  ƒ™^0$> 6T±/Î[Ëbå3¬éöƒ6b ZTÖJ´îÁ,·â|â•Χ´hñºC…‡gz[˜÷t ¦"–Ô fÝ^ƒw\ó½äzgÖXãXhpªÒ#ÕT±bÓèFÚe"dEÔ·½LÐ&I!êQ["g¸¾uò/á \Ñ-…˜Ñ@@M_·V«¹8<Œ<Æ>¤9 ä&ÝÀO¦m @žÀÊõÑ »ºFœ%·ÍÉùpõÖdÅ­‹J¥f÷.ÀëG‹e…åG³¡³sDQ#Äz.s€{ÛÀ1Fc¡¨üÉ"ô'Þvá×0•=¬½q°VˆÈ¤Øð8¨ë³¶IYʘý{yÁÏÊ/•²ÒAaÀ•R¨DÓ€,>e n-M…! µ÷Ö02qü'à2cý,j‚†¸ý'")`Á£v¡ tÉá°SdiÊÃuC”•èÚHáÓÕHÂ<ÆÕ‹ÃžFý”¾¦ÑID @è^|3_-x¿<ÔŒDÇÑtJ²4§‰¸YYSáäW.¯œº/žäpÙ,q¸UW‡“¸=ÍWÜóÌûòE¯·^¯ ‡‘¿é¥Fô2³ö¦ç(š(óyÀÙ½òö%¡³-ã3yÅ|äj ¢fuÄ XÉBZœ²)œöh“†vY¬ÆÉ;î‘ A-ë†mËL úìtÏ>ÎÎçñéÕ||= ·ÛeúóÈÆ¿YÝ•m55°¿ ^igŽ`cªš/‚,ãÖ*ÜŽ<7T¡ò*>/XObject<<>>>>/Annots 3348 0 R>>endobj 6105 0 obj<>stream x½YMsÓH½çWÌe«²‡¾}\ dS–x‹=pQ챣ŒŒ,òï÷u<Ó&„SPŽŸŸ»§¿¦{Fþr¦U€ZE)ýŸWgÁ$À'ô¢éåÃÕY”N•&é$R•Ê“I<€µº¸8¶\6ÉTÊÀsQÈ\¢'©J'`¥Ò|’NÀJM§÷rÖ–0`YJ:N+¥ƒdJ2$'‚œu˜Oô€X’Èdj=ÔGžÌ­‹Ó.& ˆKê±ñdÆzðJqÓXZ«„IJ 6aQÇZÑÔº©ƒˆDYQ!Ê1õ¬­£y†% HR@†)©u¤Ä`ÓhOÔªEøÉ¸ ICv‚1ŠGV0ÂÇö0`A!¨c”AâH‰ÁFSäÓ³\‰¶ÁÍ"âZakL~8N@RJëIkk° ;ýM±VJgœ„§ò$*ãQ1Ï¥6: ?bFDJ ƒ’ˆDËÅÉ®„Z“‘õ¢H'{V`°H³–¬À`Ó„|ó²ƒÅÆ€Q޵F!ÍC?ˆTÌ€lâ´ÄØ^Ì$Ç€¸ÜC¤%ÛãÄ‚X*‚ƒåÀzµ“±TSžµi›˜ŒšPÌ€ éI.8¡4Ú´J›Q4F(e@JD·LI©ã8rÑÔ¦“£jÉ H &PêI‰ÁÆ”Á 6 jÏÚE|.Íô2àE=$µ´=iѽ /8p»+Çø oi‡A8R#"%Æš!C°ƒMi³xÖ*¦ µÅLEnÜXr7°È¡­~:’³ 3…‹Ô²ÖrÃØH3 ,â¬TïqbAT\ %O)'N-ûî†B›*‹8z“(¥Ú³VtU6>¡›U“M9š‰g­(^)ÙZShCFvUÁb7„’,lr²Vñn”ñà ý(¢qB¢ž¸R!AÏZÅ<¾¸ËÃ$7ËÐåw¼Éà•'%RìÀd‡É)–,Ï/kMBÍp­½Œ8ˆ“Q¬Ø³ƒÅþGv<+0X4.ÄɳSœ2T›g­QæÌBT YiYꂘ–Í)RNÖ*æÉ Òf’{+0Ø8Ã~ kEÝ ¥vºA«É&”cYT»1LÉ³ÈÆØcMQÆ‚,ZR,X«x7Âi¼ÛÉBz§’ZªOZÁa¾çÔ±´àB Ñ“ƒEa•,<ÞcÞí /k÷ŠÅ`cMqðšÑkp¼çÍqHšÝx—l’‘Cžì4A^=kC1 tD]ƒz” T'¼;B&Ùzñzq0ƒ^Ï 7‘¬À`Ñ{÷XÉb:× Í#R ðÖ­+1XDyV`°¢+0XTž¬À•ŠPÒ_‰Á¦\©n]åáL£.w¨‘îbžB±g¦@²bÇbÀƒá\ÓÐJ€ÄYQtÎ5hß±â÷$æfd€8Æ#nß‘gнD+Ñ¹Ì U‘zŽà£ ®”tMå÷l„C I¡£‡ÈjϽœ‰Û0_‰Û•zñ† œ-qqNsUC5[ð•9P³ùy¨Ëo©e½R·¯¯Tרm¿Ù4m§jóU­‹zÕ+³ý}öŸX€¯Û¼v#4-éB~Âô$Åç×u×6‹~Þ•M½/éMÓÈ5‹^ÐQïçŸÂ4Sûߺ}ûB“çï[Óš/}¹-»ï-ü¥ëÌîzY®ÔûrÞõ­Ù·ð—®tùÍÌ{ŠšzÛ,ÌšV¢È:w7m37Û-Òõc#4,‹vM‚Ö~·VÑ>Ó*FÍZ3&}GùóG×µå]ßU•Ùn „ñÄ!¼}¬îšµšw듯EúÛÒTžjQ¶[ïaD¡ÓW(QuejÓã6úQ«q{*ê…ú÷íÍa™»ÀÐÕ¹EýD¯ rÛlʪ¤¨ª×EW¨Û®EC¸¹Œü&ÅçØ§®­?‹íýÉ‹ê¦Üv§väUSUèvÍf(¢S¯wÝñBw̓i»¨¨ªž%¢×/ÞUº<¾bLæ1Uî_ÅC¹Â…ÓäiUÔå¦_Û6èóFuã:ðÁƒúcÓ~¦å¿–ݽ*v­xD®^qö¸1jû¸íLEÿ~*SÏ>õ4KÕá»#l9ª{±=ó¦ÞrÛu,:~=œŠN¾É±…Yre•õ½iË®¨ç§=7ź?yÒÞõݦïÔ²¯ù${` cç°½û¾hq^AÓ±øÁ›å#’ÆÝAÝ ç}:~ök΢ß:þpZí§|øõ/|%ðû£*ø¶+Z¶ªé»Ãš¦·ëé-š6viQg\—µÁ(¢Ã̈påÝ«¦^–«ÞžœxólZól§ûKÜÏÕ¦)ëŽn|h…F­žë gKKa²ß_Ûbƒé¯¶ŸÍÚtcî‹Gþ¦ùz±6f½çu3fµî~—åéïúº++LA{Ÿ?ñÂv­EK›è®-P]Ïáâ?[ŽùVT›Ó‡s†aª-.µZP5›Ê`ÿPãèpý¢a{±íñ(bÿÀ4ÔÔ\Ÿ~Ç÷'~÷]óÄŽñp{𜆔^àùr‚G:üðãS8þNò9ðu3ïÉä縭í=šQ˦UÅ‚Ï[ÅÞs%…I‚9CMˆâÃw¼®|W?ý) 7XJͶ{„ «¾Ä#Œ€{ÿ0çõtHÏØgYa`³cîúÕŠÌy7v<ð¯ÈU º?þ«C`„ç¯ù¦o‘âV½{çºFeT#ëñéÊ/Þ¸gˆxà>/XObject<<>>>>>>endobj 6107 0 obj<>stream xX]s·}ׯ¸ãN[z,Rõ™¾)Š•j’ŒÝ˜Ó¼èÜIT»ÀÀR¢}ÏvI®èL'xbš‹îÇ9çð÷“s™â¿s¹¸æŸ¢>ù~~2Lñåî~%gßÉùåäRæK¬¾¾½š\˼Lk¦2/F—Óɹ<Úè]ÙÑ8û~þŸ“³‡K9Çc¾2ž]NnoñÎh¾6Aеj¢öRêPx³ÐA¾üöøã߃‹¯­ªÄù•²æ«âf¢l)q­¥ñ®Ð!Èb+/kS¬Åê‰Ê¯t”JÙU«VتPV{otå]NäÁøOE1*Är>c oôR^œ/Åáoå­±«ñxÌH„1:mUUmEo\µÁã‰Ì†±Kçëš±ˆì #|¬]ˆx§m$:)UÔ§²h#s¶ Oy=ˆÃÙ•K[|mtEÉY‹óƒ QÛÂè0é^™¡åè® îôè\ë¢ÔZÙÈsQ%8±¯]Ub‰mtÞ¨j"wBê†üVÒàtgëZ k×V%˼P ¤P9÷,*гš5Ê=¯_"w©Ñùª‹sˆ–ñì–À) ’™|öÚëß[LÔ[}%(¤¢_Q„2~*&²7mÐ˶âõÚè„¥«*÷ÂPªx^y×Úò<°úRÙ¬àK , .\‰œ«{¹ûü(èiú×<¥ÊŸ=œßvXßê@u9zš]ßÈ0>ëàu'+çJYyšÝA>HÜ6Z­ÿï­¿•¶­UƒÎ¢TÁÕ Un”-t `©Øú]—þtN_¸ïRÕ¦2Ê›š¸–|d5ï‘ÝÓ¨çaâ]ŠÖ{mÉ .F;o®zÿ§j@(}×wó (¢*ˆÈ¼qÀ &á³ùФVáêÆTÚ'üÔjKz¼ÁPªYã P ADˆ·O öoS®ÌÊð4ÂZ¨"Ø -µ;ŠÒú ŸÞg:"k?)´ Uh@ÃФÅ܉më^B a@ U% ¼ß‡]s~Œ~UuSAoÞQ¦îA6üÕ5»ós§ï¨ž?AdÍ òàò«‰ÅÚh4OMž' ¯ÿô·_ß!ð^wYÂDåK<}üòéìñã=&ÂíílÀ· 2fÞåPxä´ò@";ÚŸÆÃ^×ÞRüYë†xAx1I4zU…è7DÞCf}Â?ëEàÜèùýáC¦éuÇáQbaþ®ŸQ£ž”reÉ!+`¹@5“ÀרW$K½e:‹qmÈ"¯*ª?Uå Kã¡éf“ƒ{ÑlbH2±WQ²Ò–ñw¿xÕ  §„„ƒ;¥Çë˜hÛ„dÌE Éá•ö"MªïÍJ>›‚¤f{8‘û·£4­o\m;Ú䪩y ¥.*•cF6®O|9ˆÃÒI­ž©ÏœÎn ½L›³PõLqp= ä5”j­jÐ~ ¾œÎKª8z±IBöpÕõw/ùóN‡ÙÚN/QbȰÖKƒQÇÝ÷ÑžeaŽ¦Ù¢1p¨€V™¥)ÞôEîÐd¶hÜ~?B¹/ùBñdT„ë)ßàtëq¾¯OÈBp³ýÊoi#4ù+QJwrÏóÇ;»Ó(*X¤HvB­éHL¨swÑ!ŒT°‰ ªXR¿¾Ö<¸çH.çp~ä{0ûn¤¡ˆ–`dþ°ÇÜY(¥u܇‰¢«‘ÒR=ЀƒÓ䳆H윟Ê;÷ tÃ`ÐŽÝ$¤†\nÒq“„Z%è ŒÈU9v¶ÚfŸÄ%hÿ€ û§˜v@.žÖš:><»µÉ#ïW«²D …nR“éÚ6Ö4ËéLâz"ÿ6>f;JyÉÚF’v•J¥Ô¢5]0’¼ÇÐøî•ç tœ•Ú‘L$–)1 &[ù…‰^y ÖáÖ[J-Ø¢ìö0ù‰ÜS²Ô¬ó„i/ZÉaÒI w]µ»tIKˆÔÎöÓ*\¦KÅ¡îzJÔÝWàÐ^AŽà–؈šº¨×&ÁFEÛ Ó…Ôg'Ú㊗Zǵ+I»ò0§Èáv…(–2úk~}xüŽŸ»IOí×ݤÐË%ïh¸ª@aV„»Ó³BJøñeMÑt\襭k‹–OŸÃýRá*żîm©Ì­îoo}ïÇûéÙ9³ÜÇäÑMÝ·ÝuD× Ò!Óß  œêß3\Ãë\í@†@ÉñH€¤’2ÐÌ9k°—§ABìÌ‘öyÞU²j*ØAØ6šØƒÆ;ðnC=÷•ήŒWÅçä¹öz±pð¿;EæQ”zF¯v™¡½ð…ÆMÒ-X¡çkiMÞ qº¿TÛÙ>ᎇwôÃ[×¥||ÕFáp´:‚àîvþÛVƒ*èÛnJáªïå„ÌiÏF†@ ±#P18DÞoaTà$h “­íŠG+k¤áøRv0qî±½îø î¢O˜ÆUE…`@4~iVmöðj©—(©Ð åQrZÁ àF4æê6fÐÁ¡p_PÜäÀ~m€äÒ‰¤ÓùEQµéòX«ÂórÚ(ÜÓS•pÁB,y ¿šÈ?Ý ,®Üjp­d K[ήä–î´æ/ÙÊ  ‹‹«é¨òœàIÑÔÔþ¸\¸Úÿ$%>¿ÁïAWr}u1É¿­Ñã‹ÉT~pE›{—òM/'WX<¾¡,¦_Ž:ºš^O.fùš}3›òÅó“ü)-½endstream endobj 6108 0 obj<>/XObject<<>>>>>>endobj 6109 0 obj<>stream x•Waoã6ýž_1È]pÞ6–'›d÷>íe›^öpEò¡´D;Ü•HIÅq‹þ÷{3%Ûˆ‹mv‘ØÉ™yóæÍð'4Ç¿ º¼æÿesò¯‡“y1ÇÃá—_Óìkæô°âE×ïð©’øPNÎJgCT6¾yøt2»¿êWN¨Òe­¼Šï úÎ’ª*ÃßÎÉØ•ó¼"¯kuEÑÑÊÔzV«ÉvÍR{Š^•Ÿ]“ Ø´Ç‚íLç4½XÀɺ›Ý}ý5µÊã=NSU ø¤©õºõ®Ô!àpcÛ.’²­µÕpJR´êê:m„%­É­Há þð?ýüÝ·T¯Ëhžy=vß±ñÁön„´r­ z`ÓÉ8íuh¾YÖ <5ÊnI…g†l'lCÔ \,ë®â`½¶ªÁ‡ó]aÞº(ï#À~ဖa$ýÒ*Øs¶ »~Öþ<¡‘\ªÁ9@ÇU]©qê–\ ÿ佉p&¥2ÒÆÄ'9 *¿Ö‘je×Zë=œ…’Éwœn°-EÎêi«B Ò5-’ì%‰³û‹Ûž-Ó›BHˆ„>.®oˆ¹Ä/§W·)ÝqÛêiù¤1äTØiT¥||TÕ§.ÞT2AxpEü`Âoµ¯·ôôຼhظ°°Ò+|²™©öB¥A(¼cÔhâÁÍÐáÔó J×"‰¯Fš¨{,ÒÅUŠ4hÐ%š|t}ÀrLh¢-â)]]ƒSÈÛ«…•ÂnöäfD$É+]Ð=r¯_H¤…]Å##*ö7®«+0Ä95mž´„)É £î6\\€Puu„kߕѽžõ/ât•ε vïCÒ.E\WfÀÈJ‰ =?Ú'4ÃyXœ½4ðYˆl/í(…NÕ´ñªo³íCÒ ¦ú?uŸ)‚6Uo0xX²Ïî3žUOGÃ4j8ts-²“êBªû¯fº¸-ÞѺŒÒaí±ú%ÒJo(°n{Zz£W z¥CéÍÌtEB|½ÕwÄéX¡'LräÕ¼¸BõýwS„°_œ¼ôªʲýQvA hÒ–¹»à1ôÅfƒ“D0åm“²õ@K]* н5¤íQî%]ò  [Uï% Œ[™u—ZOª œ+áér+ÙC* R`Ù™»sZBÿäÍîNnGÜw¤ÞÄÛÚ,½ò[éf(œxÎU`ië:–=ñq¿|¸°¯ÙC’DMÁÓ†µi(?é{T›Ï–ûã¥ß§/ôZ¡÷‰¥ß¶,Ú{  - ˆ‹_)È7rÎ ’ßhXéX±ÙÃ=xîL‰Jñœ+Žá z‘óÜøêíã›÷)ßsº-.™ Îø¢¸¼Ä·jr–ú–¦Ó°1ë"lÖ§´û3›Ñ·µ["÷b7[ªg·0Gì”ì-²½ ÷œ´?ðf’ÍÁÐ÷}s…àKÌ!{(L”£H¡éÏÃq¿àÅA–’ñ<ãLŠËâ«/¿ì]—&“ý}“”q8%µëО³0…S+­bç5@ŸžŸ^Œ†RÞÀÇ­G6¨~()1šB½ÄYÜöý꘧yéãäåñÍ®¯ùܤ__~ýç뉶.¯Ûó5?Äæ¼qðõ̬1£Ì²ÏG™×/ò$#ö¦Á€Á—´¬ìÆxmdf§ÇY¿A„nHò±¿~’å+MèwÒûE‹¹¸-æo1;A“^ëYÙl/ÿˆ‰ã¯ ÆìÁ :˜[ûqH¤~hù6¦Ýã}ƒÝ›&¯úëòÌg·âÉGrIƒ/ˆðE¬`¼z6yœ™Š.fÑÊ©’Aüq¢‹u‘n–ã}L{ {£1Ýà/æ¾t-aeGnye£ÚÀ^ ÐËìÒ 8C€rm»L“¥f¾àò@ÿé§¢t]KôËŽW·;ÜüûÛÑr[ÃÒ.`ŠÇ(Ì0‚ÆéܹRóUt1¿*Þ^¾¥ë›ë4Õr±L/‹9}te7Œªm^;½I…ÍÓ2}ó¢ËŽGoúÍMFÓ·óëâr‘˜q³¸à½ß<œüxòx¾Ž‚endstream endobj 6110 0 obj<>/XObject<<>>>>>>endobj 6111 0 obj<>stream xX]sãÆ|ׯ˜ºS2 QÔÇÙqåÁw9%®Š«œ:Uå!ÌÃX‚ÈXxw!ŠNù¿»{€PvbŸ}¸3==Ýý|q#kü{#·ü“Õž.ÖÉÇÿÙB®±f-O;¬}øòð=>d‹öè÷¦IÜ¡¸|úÏÅõã]¿r!ÆJ|4l^´ÚV÷o,M¸n-«ÍŽ^|ïDI®Ó®(ʦUæz)~¯ÅëÊËçþðWÙi;ñFJïäã×_K«¬ÓV2ÕHªÅ¤^•Î%=Šíš†gÍâq‡²Õ')¯íNe:)gI$ò´/]Þ͆á™Î·—ÖšT¥ÕQJ×|…°Œ‘Îé]Wá4)t£­ª–’beéåPV•¸½9ÿ«Uf“½zÖT7¢_ZÕäU99h,ÅßúY[@˨uå<ó.ŒžƒÈMÀ¦2‡U…=•d¦qÞv™/M#f¾=XÕ||—ëöõã·ÂtXÑÕæyÝ­“»d#?D\:Å!Ô& ÕyB!²ÎZÝøSÐ÷H Ò¬œëR§=oFMùÑ8@Ðd¦n•/Ó²*}‰u‡Òïå£(«%ïá>_i¤Þê Å~b* ;M<×Y¥,ND¶‰|ÆžrWfªªŽË¸˜†sðH>^“§[xáÎT@ ø”n(žÙúO1÷|“Ü¡ ³ß$··ø)_8o¬*4×ܱwðÈÛðóæ>þ<\d,WÝ÷OË™«ªüE‡Çì©þ‚ÅwñÉV78yµ¹MÞÏ®<í/„­ä‹>ŒÍ^¶'mâIcÇ¡c´mâñ3—óUÎÈì­bš¹Þ-;ïóçÒúNU³•IífPˆ·³¤Z[Ö í‘+„†{/?ðv d'>0”±qŸM™Ïÿ_!Õêô¤%ÙÈ0ùÉnhØ@c5>°¿ghÊÙåo䳩P‰*°é•³0§ ;Y 5)Uë>´< ›—PÒÕD(j“3#‹íÞ«lÜ‚²ÊvÑš n‰nµêˆ¿­Þi@¦ñy×5AjðQû,Ù^&òéEÕ-Å=ü©£ T]®çì»z™sÆÏ«ó%qËY_þµYÿûì8hÓüÒíâêe{¹] µenº´ÒÛËÙ>jÿìÈÙ³.» ²x¢äYU4å\YÐ:êéüþ?Ï.#R“‰UZoe¶ÃNR o:ëíÿòˆ±¤I’ȯ³C§¾J'ëAs ØÁT2«qRS¨!Ó5¾™Ëe"3:R4b~ ÍhråÁ¡ÎÔú@ª ô|Wé—€2rØö$ʶB&5½yÒÓ!íþˆôu¤Í’†‰C½ÎöM”t©tA7Uf®Ø 8G¶ôЄݲ*¿ UèÁ*K/_Hþ8 JÍ`càGÓYz|aU á¼áJ°ú(9<˜ŽŸÄoÙ%¹VUl·à%™rÑd)â£gÆÕ¤D0*„†ëÛòâ,ÉîAñV+?¢†ÞeƒµÂ¶c¼q àè4Z£ŒI®ŒpóýgjpÄ*­Ô~»xÄLsõ²”ÊÊÕq{ÙÛÔÀøUØ7ºÇC`‚[fÌ™`]-8c/ŸÃþF›âêùª×±©µú¹4cQô.Ìzp@Öãæ T'öžšwraž8•ÎpFPK6cOŠBcŸõ4šEµer`+Žoâ\GÁÀ·«IÊ7lH Ìóhtû$Îv}Ó|äí¯™/ºáX±Z­{°H ‚ pìÃ@‡ÖéÆYxŸÕ¾³”(¸oFÐ%D«œ-ŠQãwãƒ7Lå$p”Í€°ÑÎ/od,Ž®UƒxµRÍ1vïÉ9ÄŽy9Œ¼1ÞàZ§8¾Âˆó8([›Ú`2 40ä3ɰClÁ›©/˜ºN(‘â͉·¸®mƒè¼B œ86 öUdUÂkB?¾Ö%$ÒNJL‚)›(­Ù)ft¦úí (É›Õ63êBª£¡1…±wPÐkè9Tô§£ñÄ^´Î›bâ‰H ´ ‹/"Þ*X>;¯Lš{•EëKaM×2ÙXhw±€íîGç?P–í¶û ÿ\_É÷ðK[âUJË‹\]Q†ÉšZ´]àþ`Ôýưg;äØïyíä™.=Ñe`;!ø]Ÿ"ð«÷Ú¾YTðT7‰3\$´+òTÊo† è÷/ mÏ7 6­¨Ãpäü­¤5ž KpðlÊ p/gª)S4—šqikÛàçÌx/?ê#ÝùÝ'˜-ÌÄŸŸþþÔqYç~’o£•®™ ÞÀ¸|ÅÅ¡—7 Я¦oPﯞáÕø:ð'y׃ÿêZ¯¼R•C#4¡Nh‰ø¾7Å,4\czY‰ ‚()UPÙ¢ Ö[×Ôð(­r¼ö°%ŽîV—ÅÞ#·P–¦8)ѳng ½LAâqb äÂÄ4!ÛlzšÑ^¦»Ç¾ŒêÓDå‡w6vô ^­‡ÔAáÅw ÉÓbàs00¦×_¸pt‰OÛ]œ cìý!‡ðˉ QðE¼@3•b¶Ã˜'ÉMÀœ’~†~H@}èVjœãûê‘g¶ (g±àL¸‡úÂå1éYøg³Õ&ŸžJ¨"_^(â×ßô¯›õ]r{/÷ñ7au›¬å/&  òÈM(a\»zÏ7ëþw7ò“Õ½0"n.¼_?$·›øöþ~³á£OOÿ¸ø 'ÒàJendstream endobj 6112 0 obj<>/XObject<<>>>>>>endobj 6113 0 obj<>stream xµX]â6}çW\*-«!ØQU©Ugª}©¶*R_öÅI ñ6_uœ¡©öÇ÷^;2" v5 ûÜã{Í=þg4‡þ›ƒ·¤ÿA2úe3š±þñðCí`úü æ.l¶8v¹^Ã&4Ïg° Æ‹[0¾pUØ(!Š›o£éóæøœf8î‚-pÎx øó¯Ï¿ANƒä* Ë@À!È’<ZØG ²-hœ!Ó¼Ô°•±_l3%€§ìÏsIJ‡ D KÇìD*×"dð㤠bC:´’plBàÄ¿ÓlŸ'w¿#Ø]=/­e(R-·R„àW8¨¨?‹ešï<— U‚´&øÐLJx!žÀ•/µâª‚´L|ä›mOX‘ŒC%R”“»øB«—dVR,Hy‚©Â¤ ¬LµP[ð“/ ”Eó I–…Lw`k€•55{¹'~¹s«S¢1®#S þåT„ÇfîËŠt©‚.ó<üލ¡çP?®±ƒû{pòJGYÚÔ€2ÙA¥: ·p t–Ã×qžÉÇù×M’ÚC.;ˆK¬÷Uƒ¿ÊEÂ)ÆTͦ¾àÿÅ¢š~QÙ7èbKJ š3ϼ³b¿{\]$qÄ=üf´ö^Q®Á]{—RxàLù·ù¹šýå(íB-.S’) zH¬Ò¦öÍì}á×—á¯Ù9ýù§NÆØðM°ìL®7ÕqÇ0Hð¬Å#´]÷ò¬CEŽ»s@¬¾}Ú]_Åfƒ æEÑâ=tw:Ã/üv9ŤB{Ê44ð=KíyŒ§ä1ÑãjH»`¡èÅšÏn BÄ'œæ®óL½#Î •u“ÔÃç&ôàܦ€óšvÁØ›¢ô Íѹðøh=Œ?A§C®âÌ/‘½!¿Õ4êµu8¶XöAãëÆô­¸•»͖Ħß´}$Ñr…b+Sô*uC„Ó2òI'C©piòEÖý žF¯e<)±tŠ2Ïc2_-fé äÿ¸‚×â‚¢XÏhsÒ4PîÁ}¶Cr‡­bïFj”X:²Y¸À8&†¸:ú¬µ’~©Åô…Ç%™5©ùg²b)YO[^‚±)6å¯@‰\‰fäI"^Dèíü˜RðscâšEïÄJŠŽ±«GSXÛ¾Ì×S=Äõ¡Çú1ý©Sà ì±*g5O;ÃÈ`SEPQ»Sí r›hä©Ñ"Ͻ1xFa-ݙⷓ]ûUÈrJo11§î1'] ¶ÝkÝÆž/ö2Ž¿d2<Éq‰hUA—¶æ2ŽšXí}¦xyÐТŶ¤ ”gÂЙÉióCÑ4Õ÷:¥¦Kü,(£:Wˆeä9}ž5Nºk´í²{ŒuƒÅ©¹>:j ×=ò¦p¾šÄY×m`¾›{ó+ýpàîàîêáÈ›||ëE±k’#;=¡-૚ðõ5B+ü÷WÁlRŒÉ¼†Øôy]ߤÌ× öà=à-˜ËVöF„n´Íà×,(Ü´FSD¿ ìhgeIöß•=Ì–Ìsñ¢ ³¸r=šù´ý1ú·ëÌendstream endobj 6114 0 obj<>/XObject<<>>>>>>endobj 6115 0 obj<>stream xíXMo›@½ó+FéÅ‘ YlŒöVµ©zk¤^¸¬—uBËWù°l•ö·gÖ $^ÇbíºV¤[/¼afÞ›ÁÂƮø²ØxçÄ"¸Øíò;¸º!0³Æà-`DÀ½¶-ׂl®"à±<Ùj`iÀ».|?y&,ªpÙ÷/øŠÆYÄ­{<ÆS—Þ7ƒ€i£¥`ÛÒÞ3ÃáZ‹¦æ¶×X ·îì{˜òζ‰¿ÿnèdIç вrˆ}íØé͈¯C·H›Lg r9ò^‚"Ê?GÒn j"²j…¬/ º'êGßYš  *V¦ù©DÖp”nZðQêiÁg‘<Æ=JoáüKK3u;ýå'va-)„ð‹áðífá—®½g¦!MA­MeÀÏÅäo­Ðø¿ÓþC¨Lz×ôOäræeE#Ýä«ÃB!Ó4_(™l£áµý– µ"WºYT«Q¨V¢î Ëu¶52ƒ»_ïÐyçNKÿ w’Öº9SIÒþ'é±Î´ºm j%ÅéR[*O‡`Uªp²ÉÒx-sÍãBVŒ’Í4¨eºLÃ@W®ç‹g)Ršsª¸Êÿ!Øgø9?žvÖ$û'ñ’FU×ÓqÝ|©"û‡gAÆó0æ%Ïus§jí`/UpW73¬ °gŽ5OÀáK„1¾F·_?}4Ç÷)«bž”´ ÓDÈÜyµ9•¼±|÷ð™æ/ç¼—MˆkGøîMGŽXúà_Œ;ZÙendstream endobj 6116 0 obj<>/XObject<<>>>>>>endobj 6117 0 obj<>stream xíXMs›0½ó+vrrÆæ3=ö#ÞÚ 3¹ä" 9¥åÑÀÓLé¯ÁMä$,‰™vŠXñöí>-º¶\ êã‚ê/+¬·‰E¢.nÄœœˆ’,„§®†$i7Š@ÂfðÈцæ þµáˆ'ß,¶«€éÀúf½Å¦U³Ì9-oŠ7ê¬éRÍmùá÷Ôw}‚›5j>ŸK9ËÁF¨Û¶ ¾¤EO_Q/åWºæË} ÕaŸïÝQ ;­¬+A¯n5SÓÊšÖâM¹³²ÆB«u§rN¥Ü—Ê»ú¾ËOíLa±¸ïY™‚ê„`šÎXt[XRÉå€ÛÖPàŽÕPG°¯<þƒôâ‘èC³S·.‰¤òŸ'\CkEãû«§ß‚µÈ6´ÆÚÑí~’ƒÙ‰™6‚¦Y3ªÿÀü¹v`ô$ÿFì•ÔVKÚÊÐÏΪRÖ¢aÊ7÷å-ƒhæ ‚sŠm&Ì4ôšŠâŽmôº£‚Ò‚™l«ËY¿ Ù¦ÊÒ Š£Ñ¨PªåÂè96™¨šci¿È£º6mg­òÿÒlYs‘¼æ;3e&ßàÞÜ{7ÙWÞ¼B¿z~Ý(ƒK”Ý~‹3›­õ«QøÜ~5Ї®ó±wÕ¹_=9‹Aó^ûNàÆjÀSÛéìüâÓGÛs¼¯XSðR¿êU¥6m{AúÑvÔGÍ'ޝö>S!9$‚s©‡$t¼…Ú{P7‹¾ô!±¾X¿ ÕELendstream endobj 6118 0 obj<>/XObject<<>>>>>>endobj 6119 0 obj<>stream xíWkoëDýÞ_1º)¥±ë<š¦!Ý«K/H¨‘R$´±×É‚ãõ]¯“F”ÿΙÝ87W”/ˆ4i«dgöÌ™3|ºèQ„Ÿ FüŒ—&QáÍÝ/3§ë‡ˆÆá€&)õ#ÝõÂÑè–&‰;Ñ$îЙÇÕÕʼnŒ3 Z>.'¿^Dôà69ëö™r±”»;z·V‰]¼kiìÕÖ0nkg7ÅÑ¥‰®f™liÝ ó%âX–å[ö›Ê“:dBÌ «ø­±Ç:/­©b«Í[Pn–÷»¬#€ÇO•0mÉ¡—×YÂ,Ëš½€|Þ[%ô™šbK§o?½ [ÒO±NŽ„÷;ýÑÖ”iÃËŠð= £ÞÝðvÕæˆŠD«|'ª$<á¶È Kö ½ܬø²ìBX`µ1Î9®¥àrfÌÇÖŸÏ[­¡N±A~òûTkÿA] òHOÈ Áe' ÁûäZ±:]õÝУÜ„w¾ì>V† ázÃß.‰,ÛJÕלWjBàƒCuEÌz2î N4Â=[\u9²3) IN4gÎ •;Žò¶-G{)3(¥2c±Kß,Pó?h³þM·5Ô^/_ÐL W‹ Ÿ…ô^Ë•„Ìù­†õçFžràKM­ŸÈiv\œUéD¼@mø‹V"«¸Ý5ÝŸ!3¤Ÿuå\—è— K¦):áá @&ÒlX V,ýRqëDÚ1fS®îSIµ,|ù‡°ïÖGÚ¿¯ÙÙÇ úýp0À7Τ³…2í ~QÓK”ªžvpáôòK6äîå¾,Ä®æÖ»v}Ny;ëhÿaÓØ_´ÿüÞ³-ý¸òcnP¹ÉBr»Çk%ŒÒÕ‹É’ÈY5šrÒw&–8zŠAi•q·B'…Ñœiv£qÃ¥éòz†è“Zô—[]ÔdºQðUþõ <¦©3oê[4²ØF°Vè, /:t\#¯qcÝ öpÑÜÜ™­Ï²š¹Ùtî”ΪMuõJÞD[ZŒ×Ïvã …RÍ_®Á“Ÿ7o^)¹F¡ ìJªxØ8wŒwïÛŠ©òœIüéûoÿZÆŸQ¹Vs vtÓ°^kRendstream endobj 6120 0 obj<>/XObject<<>>>>>>endobj 6121 0 obj<>stream xÝWmoÛ6þî_qZ@n*F~OÓO-¶ ýÔ 5P 0Pm±I¤âmþ{ïHI±•ÙhÑmê¼ ¢îŽw÷Üóù{0‚¿F0™Ów¾¼]–àb÷ˬáê6k6å Æ Ì_Ø|¾€eá­Xæcl¸ü4H ásÁÁçòòòBäÄßø9ê ØýæFñðñc¸Xiý—¼8ãГGp8gîól“'ó4’Ê¥CvÎiËÍÆ>:¡Ã™„Ü~²oºÓ²8œ*ÆÇ3_@r?MFóY²¸>½ÇÉ7ÿ9g+ùq( ]g•ø>4‚ÏÉ–|ŸsƒõãplÙ[n¾ t€ÿW·S =ZAŒº'nEoªŠ”$ÓUlDÅ( ×jUÉÜYàŠž6ÛŠ#‘ñ1Óµ}'L¥y!Õ¸q‹NZÕBúö‰Z} ËíöÜñª–Á­6 •u\åâ%¸RÀJW•Þaܶ+cPqÏ1µ¶¿Çs#»þR˜¦à4¬…+è¼â¶ô"}¬æñxÌ&Ôö"j⦊j:ÄÄPZù{Ý&çÕý ‹4 Dk-±á’ÄíL îuçžÛá i-ÒÈONÖ¼?‰ìÇR(ØëL­àÃÇw¿F®”Ö/*½ÃƸ›ÐºÃCí  Ï€]Ù\Cƒ“GÅw«7sï›±ÀY “ƒcÇ%n(×JQ0ðµwÅA:<jÆàwOêÚ²Ý;í¾ø¶Lš&þ+Y\ݾ‚ŽjË­YË­i¦lKíç+Á]l)¤¹“w½™%NNÙ”å ¨z“ z`ë\,Ø:/?¥¸ÏÅ–úà|$T}6B·kK´%²!Óâ IR=áT“j?T—F nþùjËN£‹â² ÇN:±iøŸÀ™ý“5<ïŸql[(ðànõ9wØ“4ÊH‘ qô#¢÷Ó[ÙÃѶíSàjßšâ`é^è-žÁ2÷-8È à}ö A†‡•¢Ö…ì\iôÎ&|Ìsº õxð&'©N–‰’#küØè:%nQè#ŠR€¤ÝƒàvOBY›™‰8–,͸sRY#(]à_%w°!LÐç¬í²—ò5ν‚­ÑNÓUƒ×(-90!^¢x ”@‰m‚zKóÎÕÁΨî4À½"›Í<>2€$ßnyŽ»ý‰b˜c(‹Éz!Ü¡D†0×Í©5N¦l6™Áü¹Kl$áŒ',_t^‰¼¬‘¤Á6^ötŸÁšÂ’ãýÌ’á,™³Éÿ¹Àp‹ñ‚–~]þ|A£DÛendstream endobj 6122 0 obj<>/XObject<<>>>>>>endobj 6123 0 obj<>stream xÍWmoÛ6þž_q6 i*Õ±]'õ^€½¹(0tj _ ”D;L$R#©Ø^×ÿ¾çHI¶t)†~˜c'’u<Þ=÷ÜÃËŸ'—4ÂÏ%MfüΫ“—'£t„/û_vC/SºÑr ÛÙ+\á9.ò3Ûh­ô†¶Êß¿‘t¾¼=y±€Ó°à,)dÖlojšÆG¯32µWF§´0–äNTu)çÝòëtÂŽG”ŒÇéd‚»âŒ...(/d^Rò™/ö ÖÿMn_͵¨$ñ+¡ÓôÊËêô¡]oó„]&8‹þÖ«3¥ýê<­ÓG>ka+w°…ÝÃ]ý¾Ž‘µ»þ–ÝÊÜ?r´–Â7VÎå.—µç4>¬Vš×x»§î·_‰œ!n~¤\ø„Ôµ0P¥67ži Âk·6<~À×ÔµŸ½iB§l­¨kÞ[P^ ç¨Twrÿ®ˆÑxa }è JW7Y©ò°ö ~èí{e=è ˆ==Ë„ jE»Õù7ƒåÃí';ýýÔ¡‚ ˆ5:£ÉÑu"–IƒJV YÚ Ø8~ÓŸÏÑÔ£Šž¥#4ÝiúÓè¯?^Ö¦R]Ó>×dÙêê<žƒ\•~Nmh=hÇŠW!¿dQÞ´îÂú¯…c±~æd¹†æ.»Ž0ü—IóCQ€Û ŒQ^¡ìÕèi©àŽŸÇ©b‚É©)=}G«3Ì[—«óäû ú¸¯ÎÛýÂáIÁ{<ž—ç˜ÔÍpprͱ¿ÛW™)ãdY¼½X\·ÿ\^OÓ—“—4»§Wq¨÷þÍëd’Žèg“7Œ~®Á|­“«8¿‡Ã¸öu7» RäÕ}h¨—£Y:cfÂTp5Óë/Ë“ßOþ|}Ôendstream endobj 6124 0 obj<>/XObject<<>>>>>>endobj 6125 0 obj<>stream x½WÛn7}÷W òR9°6ºØ²ì>9uÈÅ… ¤EUÔ.¥eÌ%·$WŠPôß{†ÔÊ–à¢V1{—3œ9s9gÿ<èSÿú4ñO^¼¾;èe=<Üüçæôêê˜ú=º›áìè ¿ñ=~É;׆B©<'ŒŸYW‰ ¬9"cƒÊ%•vIÂ( ÅÏ…¦Z8QÉ -…ç² `áD>z¥•°+¢=¿ò«jj5˜’ÅÓÆòðîËAºýbê”ðç84zEy)Ì®•sŽ Ï¥÷ÖQã•™'¢â_}^Jx-¤ÏšF“øúÅí§ë7ôZx•ûì¯FÐ]¯„Ö4sb^IÎV/DΙÂñÇ$´·4•ÒÐ\éDE·ûÎ]¼ºB)"Ì¥õyr”Þ´èa6#ž)#=ìSz-)¤Ó+ÎP—¶Èè®Ü«A?.²gX‰Ÿ•¸ñ©:mà$ˆC«Ä:éÁ1Cÿ`7b.©²E£ÓÒº{š®ÈÉ9J)‡‚ŠuŸ5&Bä ý‚,„æ·KJZ§lƒËW5œ Ð  T¨ÙL:ÆÛ\Ä/·`ßî?Î9à§°Fr Ê”ˆ"ðM3g+$âk™+4äôm*»¸çZxD‚žŒ¸³#k-c2ìB¹ÐÀcÂÜgteÝVò«¨j-bÉnV¨ŒY#¶)&|¦‹­íÒŸ·޳!Ïà ?dÃ!þ*:éôÍowo?~ sª›©V9µIÐ_íý<µÚÙ€pe}òà¤ÇÉhû!mÒYXUP%”™t0MG< Ž^ 7_üþÇäðÇ­¬p”Ðõ¤ó;êåœl›âSj¯gZåÖ LØÏŠ»LLµÜÏÊ`³-ö´©d5•®½ïm€gæ–lÛ ¿Å¶Åt?Ûx£kò`Ý~†˜Ôð-v±…÷»*š`{,…+.%þÂVÅÒ}&²ÊxéÂ¥r<º ù\«ª¶Ï°ú;Äevã¼³Ñè”G{˜œÕ-‹yùhòºÚ°/q›^Å=ûêꌘ㘀»ƒû9îeÇÙ˜"GñRúõý»´'Z¦à“ÇYÜÎäýćð”7..R01pà+ÕÜD6¶NÍHüY¿LUiyb…£ºL‰?q““5žóVŽDRú–5_hìºf^r˜¼•Á~m¸+² \ ³Âžçª`ÝPeZ”^±û¹Á‡ £– Œà˜‘$¦l7TT ,!|- H8'¨\™™n¤ÉS²‚‰!Döáhùv,ûÈ N¢çp7ó¦‹ô "Ùò*Z€±ú¤c­Iv3ÂRa+–J¬ 8•Y£Ï{)ë„33ˆKä÷œåÊ6Ž VÂfÎú¡3b™SoŒSÅÑ'tãTÆ[Hºd²¿m±óO5ÊxÌ]õÞ¢ÈëNá:mv i…ª‹¸ ŠvÓ;çò*ä ÙSÊuXË Ñø¨Ø"±Å 5;e¶Àñ¬õ–@ˆe2Á?ÔŸÙÀs%Ð*+ˆ8§êÈîz-Eýâ—&GÑ€!åP‚¥"H,€Ñ¤ó4éÄcËpÜè&pƒŸˆ­€*õ•ÕP”&\íK>ÈBÅõ“:ª¶zUYW—*o‡ ‰¤(I<ïÐþÔ)9Cï·Ÿd\Âõ¡cÊ1”?£ˆô“qìÍ(ÜÖªܳöB?c½Ü¾÷+¹õ=,[¸± ,ºZ.¤¦‹›ë4fInÄH1ImÀ´Àt#à”OêF$­Šï,n4¬·›«s|Avúñ¯Û¶?^kÝîiÆ_!°Ÿ °"“y+„ùÝZÝ¿Eižð+ö}žß¡AŸð¿A¾ÏsBä³uŸY3=qG˜525,vè$±µkšþÞñÿz9žø¿"ÙM‹.0Êë&NZ&GÄå8"òlrøœô[ìÆÙYۢ׬·±âráy=YŒ‚‹Y!îu ‡Ç¶Å·k¢ÅGã— I`7‹¬Þ,׸2ºåω™Ê™=7#ò¤dg|CðBæi»]ªùm éö·=ÝW­…E;8ýñqv2<¡Ñxõúñc€I¸;Ìztió†?NãZb´ BÒéîiÒüQ?œÒO¬ÍߤÏRL9=é²á äéàŒý|wðËÁ?vûˆendstream endobj 6126 0 obj<>/XObject<<>>>>>>endobj 6127 0 obj<>stream xµWmoÛ6þî_qè—9A¬È¯I·O™¬²$½ EYê$R•èþ÷»#¥8¡,;/[[†}¼{î¹çŽÇŸ­.øø· ýýãië÷yË÷|üòé¿|Ç>œz}˜‡Ðóaô¹ëF'0Œ•sÞÖëL"„/¬ˆà†åée\èßæ?Z>tºh¸FW*; fëT³‡&sŒ[Ù_|†n@ve§7,Q¶¾7ôº0Óy,A:¾èa 1ùNoà žý¯ÄÊ~¼ks% ]¼Wù=X‡,¹;°n¥Ðxç‚iQ)VP˜˜°Šu±ŒuÌÀãKöŒsœ9ä›qúUÆÊz4C1|Ÿe$ g|aM· 0ݬë£VWÖXŒGl•cîcr™ÊBäú|ªj¦ŠwäaíÏ#¨}ªlyDaºØµÅïk?Ç*"ñš:ØÙC Žl¸(µ6Ó)Y{@ŽŠLðÆ[crýåþüjâ Î$] 8ƒ35Ì›Q„dÄ8ƒ8^aøê“‹ò'e–ŦeÁïÚÌh§éÝA³:©ŒØ‘<Íå%«43ÔÙ{}?ͨU‡ WÖÌXгÐNƒÚÕ€Y›ÜöiC¸”œ¨ÚË| GX 8ÜÈÏöŽ’ ªŽ!N®xº¦“jșښÖZÆÕ7^üÿ–7×i§.Ê ñ¾YNÛ1ûª› a$+Ηy.$[š»ìÖ×—Êýr39~ˆ%íd‰Z¹6²z'›KËÑþrLj.ô×HÈÜ–ãHá8BÑ*x¸cA C9‹2]E1î÷32°ÛR9¤kÕ¶¿oY‚©¹oE– ÏgˆšF"J­é§\dvT„ [ìH© fÇúÃ=£¶rnQ´yÆ8YbÈ-µEÝWŽm×ÀÀ®¹£ÇWéC,™¹ŽÊõÌ®ÍÆûµ ¶y©vz=¯ßÇwkЦ›òöüæòl|~võ7¾QéO§¢X’À¦Á Чwëó³Ó‰=Ig¿±·Ü1ÄÞôq‹ç¨LÖdëá«ë¯]ÏÏMà‰’¿h@ö¨ê´äý\*Z,sÍ.¦·³¹Á°oçý¾AQ^E§å ³;xÃþF'§Þ‰ådö}úG§ïù0QܼK ½„hÖºsbŸîô„†›>/XObject<<>>>>>>endobj 6129 0 obj<>stream x½WQsÚH ~çWèÑaÀµöµíµ×¹\;wÉM_˜é,¶ˆÝÚ»Üî¿?i×6ÁئíM2‰´’ö“ô}ò¿ƒ"úŠa:ç祿¾DaDÿl~è;xñnq·+˜D0EO©3 ‡$øíFK6C›r‰Ô 4® ‘`‰Ò(Eаò¹[\„·_/Þ½‚xÂ>Çät<™“Ó`…—á~&Cã­â*2ÛÌÂ[ñÇ0üˆ[~X‹ où(G2eÃ7…E$n˵ÝAƇ­XX¥QpipFu€7j½[TÁ²þ ŠoHL&ŠBm!¡S Ãábùäd`&ôgq¯òÞbÏHÃxv¸\Z¸FyF¨îŠçK¹|~Ÿ–_1±0|VX«›LFª4n¬ÎåÝ¥¿$™Ð0ü†ÔL‡pºVrµ''Tx Ê;]iUžÌ¬m@ÝÔÊ;Xºz»d@i®}^® lŸöI¶w.„Äÿ\_M†TVj#Óþ†à ÝœM ›‡uÛ½(úa»±JÓÄ´ºˆŽ´ïqF¡Û^~œ!|XµÃt%k¾T)+d*tZ·Å"ðM5rœ3âr^çÆ.. ·; "âñ¬ ŒÙ”˜‚U¾Zu—›`Úfy’A" z§°1Þ‹ëj½¡–í;ø¬Ú˜ÛLpVt *RʳV³Ìù8p¿ø;oîVM ùNá¤äP&DŸ†šƒh\¡F™ Íâ†ú®uÿcØ÷Ms‡ÛŒÜ«5jas%k…HyHñ@§ÙöŒIš¡w#ˆ3¤,ô67OÐ6ÏÑàsGÍ¥5ºT7,÷¤°ÜµoÜÛ!åò$‚¾z‰Ò4pk%S¾U‡GZÙ…ÃPÈCP<¹m…¡ìJu)Áê4TÜä0üw¦aÙ~N¨©Šá(ø /£@W7iHzìxØIúÔMU¿¢ûtHÑÝð}§¢sJý¤é]{-÷Ïý7}BËÝÙVË?ø¿ëÅã\-?™FÝÏ×hùÉPk»ßÞú´üü {ÑqZÎÎA•ɈXË‚ì/AÐÓÒÝN¶¹ÍÈuŠíÉt³ß`ƒ.ªlÛ0É.qGCéÈéwµÒÔlŽ>¡4 ŽÈX»%™6ˆ±Ë¹Ä;bÁ{ô®V¹6–‹=nùȱe•ñÒZÐóÿ½´ËÒDZN0Ú¼þ|·<ÃO•dF¸ÁŸDþ'É3wLxª)¡ÜP7ÑbIš®…¼Ã>Õ,>b…¤›¢vº¹Í‹‚-µ 1<±-‰Iºú¢¿—ÍkÝ,¼œ^Âüj¾ä7 ›ÏÞ§aoUBK¤…œ4Ûµè$ò¶ã+~£©ÞÙâj9wÍÃé„„ˆ>½šÆ|ê·ÛÁ_ƒÿýz ™endstream endobj 6130 0 obj<>/XObject<<>>>>>>endobj 6131 0 obj<>stream xÍWÛnÛF}×W  ‰ÖÍŽ“¢mÇ\§ô…€±&—er—Ý]ù‚¢ÿÞ3»%Q–/ÈCk¹Ú™9;—3³u†4ÀïÆü—”_/;ƒh€ÅæŸùN{Çè2£Ñ€Þã)õðtd!´”;YÒÎ嬳w ~wW…÷…t—2£KrSIEn]ì4Ï\®¾{aK©¾S”g¤d"­æ!¢KM©7¤„uÁP®VÔÌ­ôo¶’I. ºÅ\®CP8îîÑ—“«OçGÀ´y|d†õáúðE­óVç)ýRUR¥q÷ '£Ýû%ZáéËõL&îJ›«d* íºxgÝ6«MZÐ`Û8Üúþ.9íO k¤³öîûÖîˆN7ölhÌ-)íHuB¥Â@±‡Ýƒ³ _ kç¥LÙòµÄ¶`£ s8YË0AË"8^01R8¾p†C,<ãÔSe¥qq·–Ùµ@¤U¯öoPö¼aA·h7NçQä.ת½èZ»‘ÇÈyvR9ûHÔÚ$Œ Õç‰$Ñ&…Ï .(ZËó¶õ- žűóÑÈ6“}s¿Én8#Wižpôr>³p«I¸(iŠ»Â×ÐÆ;ÿ‹ÜãP¬žåÉ<|OÌ*’E|UNÑ~4¡º,ql]I#8è­ˆù"Æ6”1G(ÓE¡ï|š7>¦ðNW^`,M¢((N¸‡JÚV)x¬/0í~ÔÕCܼÝoç‘ßÄ ×Y‚ýœj›PlíTÙàŠ¶Û.0ý‹ ,šBPØÅ+ ^H—å…\±Ø«ÙcɧÙv?@ÜúÓ³%J8ÅZáPTw¹›>ëúV“—3"¹©½:³YiãH£M;t+­aA\Ÿ7޲7öþ î§ã¿¹Zw+³ªÚ©q% ’š—×ÒüÞd”ðN ývØ'vpæ6fاSç)[Ú-¼Âý?¤È‰°SùO€W½(Ê“¹N1ꔋ!üDàjAS¨"Ç´Ñ ÝðK6W‰ç#O/LïÖ£ßðHÀ uǹ±è© ^y‚I¾J77ŠOSC…tM%nŠPiD¹’Œõ6ãÙþ|h_-RàÁ1,-çDá0$\ÏÑqjkÀ׿y(a!¦i?×y(ìÅ€…•Ft ¼Kë˜ØÇ-ó7òáÕÖEšúÎþ~h9­ÚH[itLd§ÀLC‚Í—»dó Èð F‡óogg«Ï¸±úBÜôàg²¹W+kògØ;>¬ïLÃI´?Þ§ƒÃq4 ¹øóôs èH'¸c G™Íøèè¢awÿ_'Ó®ŸÄÆ`yÃþà pÅwïÆ#^útÙù£ó/:ÜMendstream endobj 6132 0 obj<>/XObject<<>>>>>>endobj 6133 0 obj<>stream x­WmSÛFþίØa&Sáac 4i?´ N™2´ÉÍdÎÒɾDÒ9w†vúßûìßt˜À0°tûöìÞî³ßöúÔÃwŸgü“–{¿Ž÷zq×¿Ì”Ž†?Rÿ˜Æ9ΞŸÓ8sï{4N£“^|ŸÑåÑã/{GÃêã9Ÿ<<>‰Op6ÍeªDÁg(oª´Vº²$Œ¤ÆÊŒrmH©ª–¦òçbϤ•¤çÒ~¡ÍWÒ½%on;CÑðòê‚:mëéəֶK£Ú¨jºù,ªŒìÒ£P“*d[¢àÀ³h©Ž’h1SéÌy_J#‹;´0bGñP7ÐjÝå_rûcým¼Ø` ?ár'‘÷ý³6Ÿ}y—R`WS:†:yYw)Žãä íõ±Ÿ• µ)E]e€ÓH”’„¥z&ïã˜Ï—VCuÑ:k$oS9¯!/jÒM=oàŠ¨>«i")S ÃZ­‹ÝF>¦k]Ë×ÎtÐ Ûv :*Þûlå s XZ¨zF_Þjé>ê¡¶â(¦_Ph„®¥r_aÚXš‰éܳŒR)E…º ²tÈÐúŠXçéfgž6©óž3íw‘«.]¼º !ÞdÌ¥Ñ0JL IUSNà¯Î7ášiSʪF"µóاÂ]*êÖÜ @ÙM˯‘*ö 88¨uh+ië’+7ìC&ÈÛNˆ ·¹•xû„M&®èÓÙê²nüÃ@=RËNm(½©äï;õɨZîLëVu& n"@!«ÐÆ&•ßõpáM„ÒOõðƒÙS,Åíó}4ÎÈs]|/9³›{°la¡º'â•OºPú©x}¬¼<'íÿ,´f©÷¹~¤üº$_]:Ï­D‹g§3Y¥24óD𬳠oa^mo9èž„>“cÓ&wµ´q(ì]Ý!¬+Lô<<>º¸øýóèbtƒn㎽ýø!<††Ó>¹ncNââú] ?|÷ ¦0–E±#%!zO„¾vÚBá-è½w+°5`†`#Ô¹– þ'‰ZƒO*L©6(u†'W ¾SÉEŽC64¼ñú-nw 6@ÎŽç7 dÌ•8ÉmL£s²J¢P]D…šaî0)Š‚ç Ïv>/XObject<<>>>>>>endobj 6135 0 obj<>stream xWÛnÛ8}÷WÌ£ÛÆªoIÝÇ6mû쮽X,  %ÊæF"µ$e×ß3¤$_’Àq‘ $ÎÌ™33‡“ÿ{#âgD“þMËÞ×Eo˜ ñ²ûcWôñnJ£!-rœ½ùŒ‡,|ÇCÚŸ«R»+òkI•••5©tÎX:£JX'ñXd*i…—d49o•^ rUH—¼[ü×ûx÷™FÓdƒ Æ3~ÌúÓarC÷b£VÂà x,…VU]ÄÁ=y+¥‹nöHãi2›±—?CÞë‡wÇd‘Z4ùKúÚ‚MÈó°§(³ë±Ûp8ãKК©ýƒj²/pðwuÀ‘#© 4ùÃÏÕä­.E ˦ޱ&ûÈ Ý¡›åQV…Œ}®ùô-e2Eó£>‡ “±Q¦v¿†®µ~;ÂÎâ"”¹²Îß®U‘]H_0¤”-c¡Ž9S9Å–Ú@7rꇑØ+KŸ¶¡Cn?| pê\ðÂdcü¶¦†ÛØ0ûÖÊQî³&t0*e¹”ö\-pô—’d»£ÿ55•jµö„‰‹X‘éo·Bû8ƒ¢ª$ÆO–ÛX> &ãFw‹˜ë9¼hE©=wø…U‰†) ã™$ôw›E«u V\N*¦nñJ×B¯ C|äÁX]êD3¡{cKˆ·@äµnt™ÛèbÇ g´Ü5xøV ´upËaX ÁmI[åצöô¤£>nׇ°¿Ìð94V¡ž$\#[HvÆ0¡•íôL7FA­¤d2ñ W‰FoDÅ|4öIÛ×e2`å†9PÉd¯î¯÷àBwYŸÝëçÒǨ¬_. 墵br*^Dl]\õ1j¦çS|¦H±ûÛª4qGês]¸ Þ©8œ÷ÂX·ñªóù5³Í½*xÐñTÖ^ÊïNfª]Dá±^p'Âa³&ÑvžKf«É*÷Ôâiéënü@^Ô¸£{#Âkó Cë£ÝÑök×V#ã‚y<‘ªè-¾lÍûqˆ±¡ Aâ–25e³Cì+r¦Å3YH/yx:}åçW·œoá>/XObject<<>>>>>>endobj 6137 0 obj<>stream xÍWÛnÛF}÷W ô$4u³e×EܤNŒ)Z È‹cM.Å).³»”"ý÷žY^$RŠ“¾Õ ‹ÚËÌ9gÎ ¿œLhŒšÍù´:ùuq2ÇxØþ2KÝýD“‹ð‚ Vϯ/Ã9-b¿fL‹hx1¯è“6/*_ÒF¹”„sF=—NÚÓÅç“ÑÝM°’wŸO/Âëkl>¨<’Tc%9#%å:––„‘ô¹´ŽRaSrâ9“6Ø;Ð/Q$­•1•–ït©¤ê"$ã/¾“Žƒx>žvCý¥¯,yÜ_þVfÇOFr“)g¦ i„S:·!ÝiCò«X™¼iB¼g Ɣј†³>ÅC•;JÊ<â}ïqm&üG@Bgùã)ýÍ›ù¤ ?€¹Ÿåb%ùó/Ôæœ~:x<ýù›Ûìvåwv·áéÍ··nÔr±-‘ãß½ùÙÑÃ0ìDñO…C£‰sÃ,œÏ¯8µr³Ïv$rz–”@ Ù–¿Q Þ&áCÂR.e,ãÞë\KÐ&•9žvb]µÛãÒc1¼K™×tM˜žEˆjK6Ões…‘…ÌqO­pb˜l!XÃF&êëàºH«@Wl]ªó›XGÖ<ƒIæ˜Fgà]#•ö{:5a{iÔgïj®‡ï-})UôB±e&>p­EVJÒ q¸¯_R–W•\£‡Eæ7ß6kÔZ«hÊÔ ¡ìwª ¡ÇaÿX b‘´XÊA0X+ãJ‘AiǪøäs½ªìcÿºߤ"_6ã² ‘üª¬ãÇ-P–oY Æ@0æV¯¤SP ØÊ‘½&Å>°’(u6;ØžÈm¢Íªq‹VÁ 44´z56Ö0‘©Ži¥c•(öKT@Êñ•F‚]Sˆ‘Œšl–"¬†)Ï)øT†´QÈOdý0¬…&ËaªúåNØ¤Ü ÆŠ5’Utaü¦D3üMweìÐQ\ `²ß|€Ã<át À>ä) , ¶Â€:_ '‡¦ÓŒ=÷¿÷íß› :ú®aø"]l½ìwèp²£»¶—p¥Oªgiv^4=X$]¼ôª"¼po}HotÁ¤BbŒýaÞ¾"V>lÀ#xh,÷˼–ðwW1ÐG"×ZëT›TE©—¦tô\ܩײ‡h¸Ë’5Û18.¡­.)BDý¹Gã Ñz ‚}{Ž02<°Ý*«jÇø.n‚ƒ0UYZ_s㯀‚ÜΜù/‡•Yâç’h‘ƒ›ÈÍ`wc±kã ŒnH÷  ÂlY㨵º5qwWyUr‰BåëÒqBå¡1¬•.aGì­žÖ=JWj™ò˜³–È Ë'ã[å让oÞÕTÁ‚¶®ë½é +£ÄÿªåÞS[ͤg&ÕÄ™ýb2ؽa/+— ¤ÏÙÛ²€TÀüø™-ü Ýuº¾ç##žU³6õeÍìÿømP÷á„×Eù é=O[ñ *2ôRËÊd{ãD`¬U†Á æÅcɶ*§»Ñ· ¿4ù›¼V¡]D)›ëkŒµ*9ˆ.ƒšmõ›C$\{Ç(ÅrGË›é®Fº$f£%üòòÚ}¥ëŽï´{hz-Œâ)ÿdžÞ]ƒô6î¹Ì c+Ãù?NÁ<ÍÝëY<<-3ý쇛jÜãE£ù)µ]=ëÌ{[CÄîm žÍŸD?fÁïìˆÍèXuÇT}pF4âÛëéXÒÆDk|w輇ÛÕ­ ¼¿ìÒáCýòªý©?„f¤+MNŸîß=ýñ¡Ëf=¿]×ãÄd~^Î.i~yÎ'þÍŠ·ÏÂ1½Õ‘od~ÚâKà®Õêó«ê½ê{o²—ãy8›â5óÃÕì’ÏømqòçÉ¿/—qendstream endobj 6138 0 obj<>/XObject<<>>>>>>endobj 6139 0 obj<>stream xXÛrÛ6}÷Wìø¥”#3º8²“fÒIÓºõL“4§}ˆ25D‚j’ вòõ= P”(Éž(JDâ²8Xœ=»ÈÝÑø3¤ñ„¿IqôóõÑ  ±ýÇÌéù冺Î0vò©ïÇC©ÒÑ祚ÿkä]­ŒœF‰.­£d! ”¶Ot*ñÔ§N‡(äp¿iÔ§8Žû½ëÿŽt:a©èÃÕÓ·<¿ŠÌùR¬,Í$%ð-o1ÃAPmÁX³ºLØõÍ2/ixƒHÉKMø%Îñ]¯*Ive,¦5…=ƒã ŒH#ت¨rY€J‹`mÍï Û»gÏÈm¬€hI^§ ZS™áðË…4Ê1ûûTi„$" >eÒH4â™9µî!§©Å ƒbz˰Z¥Òy†RªlRÛuùõJ›óP5úf¹$,,cú]/%¢®O@üƒv¼ø],Ô|‘㯳_!¨YHNG“µ—â!}FlÁ½@«ýÞ»¼¨=ä4ïÝ·yFpäy²¼(œ¦ š +)Nxè¼{f5ŽÓñº’F€ ìsŽ~ŽWUÎñ'ñ9°!xiÇ òÀZ·‰¼ÐæX y€r¤¼LeT¡œº—Í!Ö âØîjެ»Óˆ @¡©©T×pùθ˜®r³-/€«åÜR®ne{öV°©ÍŒíS¬¦L·@¤2—ñâ}dd#{A¬?¼-z¥7uâÐã,É+–ÊDáX Q–Ò€5àŽ7Çë`‘‚Ùo_­=p™5^÷GñxŒ·4z·9`:ðñ¤h 5”!êyۜȢӧ>D÷®{+œŸø£ÿxoÂÉã3Ž«xoJHŸ¼ÒÁ‰˜r×$ßio6Ï›F'ÓÞ”sv?iÚÛ Y·ó°™/£Á×/ãÁ×­©ëÇc1F¬ß1ÿîí"à¸|õê¤AÒàíÓès˜CFîÆÚ¼†­7‡œ4#üv¦½7Þù›úÁëôhO&çÌ¿¤‚ŠHê²b§¡þ(.„U^ÓPdj^{µÒµóñÒ’JPå?ÎÖH9ÊŒ. ˆÆh2,‚1]"ªE#=Ýôúˆó}mCÇt³%MúéžUP0#]mJH4ç%—…¶©”$‚:Ïõ’…v-­â¢ì@4Ö6D¬Ç&`ž‚®~ßKQb™å„hÝnêX¨âî*áíÏðà›Î`0°wöf¼eceN²­Ïpeg"”éÀ‡Óp›P;ãÁÖ$G·»Ø{Ÿb×ÊËGç‡uæ‚âÂÌ÷¦Òåv…Ñjâû.GŠÛ]éS-r.òÌNºÜ¡ù”8M‘Œ4ŠqÂ\ÿYèñŠ«J¼BîÕ7`¶Bù æê“s §} l„# ®¹nê"$¸füÆóp7‹½žF\ã¯ÝàK|D(¿o4Šéoa”à#—國_3¯CyÄDÝ™ÚW¨Ž}êÙ}ïp?°ö^á·F"åþJ×´Lœš|Å™+.TáÞô:¯ aòÚF,›üÞ¤Â:Ÿª’‹{Sº%Ç¥4™H‹¸ 4EåL$·N%·–nn:~YryŵT£8FÃy5h ì7eôb­zp•dŽŒ+ fóúMF}:–o*Öí!ëv› Öhöiï"¢ƒòðf¶s ½÷c÷wèi”hƒ›N¥KÜ´àvŸ* ™*P ˜õì^éÚ²»DÀ <_ŸÆ¼†o‹«ÕæÆõe8øÚ4ô÷ûŸFýÖ*Ü`½œ3ØJ#!8¦A-}%ÉÁ±–p—À_=GHá 7'Ü¿¡PwThƒþJǶZ úvÐî%ŒkâPòuÇAÁ¥å:OiZjs;“‰à…˜¸(Î3y ¼Í¼P¥Lû–ú‹b¨·+8óéðÒúË …Ñ䜒øÞ‚ȵ¬1¶ž59Äßôl·Y/?Ò%Ã@↛|ñlÀ|D ßC·êËX¾~†]´ÿp¿¿ É9Òy{›:ÇúE'^1ü’< l ƒOÏCñwèŠöb0‰Ç#\PPœ'<ï×ë£OGÿ“.œendstream endobj 6140 0 obj<>/XObject<<>>>>>>endobj 6141 0 obj<>stream xåWKoã6¾ûW rr [+?âdÑS‹v‹zØ6Š¢) ZÙÌJ¤BR1Ü_ßJrV´8ÙÜŠ‰AÏ ¿y|è!¦Ÿ1Lçü›½Ÿ½8ŠépÿǬáçn¢),2˜Ä0ÿ8ŽæókX¤^*†EÒ—ÊÁ@ü=ÿùárqßûðicú"ƒ)Œ&ÓF¡/-”F'h-¦ Èp ¥D:Šà³·!‘DXÂNW°Hg+:·+.ê µ¿€¯î^Ù¿¡R¯•b’ #œ6 ³ãêâ®?ï.£2 ­D°ÐPˆ¯IžŒ'äv?“JäÞÜÐ_ã¶Jaœaî+ëà^KE.:½F‚o ²R­Á:Ãÿ­áP 'µjîýl;£lŒ&s¾dG7±Ï¤@ªUÂò]˜,>‹f¬° 0e:Ïõ–ïÈ*åÅkLÇÛé'C=…ü/ ²Ýè*O ¢÷”þ>éJºEê£gvl—Œ¬*I✟Ú)Û‰åÎX̳ƹq“,–±>j™ÂíV®Ù½¥HÓeIshîúí) Üîî²ë­/&ïìiJžA£Å¨jÉ}Y¸]Wµ@ñ…Y§³ &Åüµ`þÀB?"ãá,縇•]¼0Ž’Á ª_§½Þ{FŠ cÄ® fXWÜúb_j³L6ÂÀÀÊñ¥„ÒD`ƒ°•n©,PY*ù0„ôEÜ÷t‹ àˆ[§¡¤¿öá þw–×¶+jdKEÆ»Qž«Œ² ªbE“ˆa€ÏòÙÛÛ§Îó „Hƒïä]Q/C À3¯Oµ¸ð}t€7½´ÇàÓÊ"ü§ Ü`yÚµ[¤õðj¿ÎJÍ‘â'(A‡œ;þ¸©*‘ËL†Óø”ß§½nÆ´ß{«a¨Gü9œæ/!A×ÊDäù.¾ð µa-UéÑ„ C:§-c(ûšpÈwtÁ i’ÛƒúÍîPßÁm@ŒÇTÙ{Kkv{Ÿ\™\3-gèN¥!|¦øM#<ÓM™´6ÞTaÁ€€\ª¯˜ŽrF@Á!–& $žJ§¼±-¬Q!QDâG«'5$cÑDp‹žEO¤€öГ:´D· ‡hO StBædv¥+çQ#´¨Ü·\ff:,Jª½`Ó¿. ­ÿa@Û… ƒö±º²[§[¬]éLr©Ÿ(—Nƒâ¬î"ëý+]Ž—ƒ±ÆE[蔇ozîˆ)+»éú5ÜïbÏ'IôÒ¤&Ø3y]r'hcùiLB}Ð_Zëöq D¼¢—ÅQ—¥¶Òч¶ÑMQøêÞ*v³\“$Û Jkõ¦y‹LâYt5½‚ùü¦~?Ýþùù×Ñ4ŠágTÄ<ë–eßhðÕ²£k~t6o³qÃpø8¥ŒÞFäÇÃÚ«xM'ôœ#ñëé5›ùeÑû½÷Š…Êendstream endobj 6142 0 obj<>/XObject<<>>>>>>endobj 6143 0 obj<>stream xÍXKoÛF¾ëW |¢‹¡$¿r­[¹h# ÆŠRÛ»ÌîRŠúë;³|Ø¢$” À °-ÄÎÌ·ß¼ýu2ƒˆ~f°¸ç߸˜ü²œDaD/»“Á‡ç[˜E°LaÁýGzJüzˆƒ¿°Ð[´ òr‰TcÄt‰F8m,¤Fp½ügòᙬyMÛ×/ZÕ•€AWeÁm°ÿ_DZ(t"S‰IÏÚ~E™ã Ètˆô!¦¦³9].¸«`­®CúžñwJå®z€o¥¢B‘V*vR+Øé*o¯ÑGp¤¶¯ÑSà/´ïËÓe5™¤ƒðŒÁVäž»ÓÉ;„õéYã•)9¸áàóNfË}‰ð®}z)uùÒ^t´¯áÛ¯®¹a5ó[¦² WŠÚ¸RÅyU‡•ÚÃ×JääïX0Û? Bú~¸JWÅÅÄ©ˆ`:/ŽNó(aqt‘ø/Іµ°8< º´–Ç‘¥Sþé»r÷èB%§«OÛWãdœ§'ä…Úû+Õ•¦‹’Ì`*¿}±¥—üyY}õO?À“;í’ëˆÝÀµ;¥ºÃg|í¹ÂÇp¾Š9´Î)_£Br¹AHužë·¯¶ÆYˆ…‚5Be1Gõ–”@i¸€9I=Ïp"œàpî%×΂ ÚZù"m©éš¡~Ú`üÅlg”NÖQ&ÆNÕ›ßÃU`±F32ºÚÈÅØ(°Ñ Š×›KY{zÿžFÆÈ`Êü˜3’#U=D ÆÒÆìHpºœ ¨iÔãEzg`0$+y6‹¡Z{ÓÏþÐoÆ_Q–9O¨gÛ@/c­¬ ¦W^£Šg+Œ0™ Q£þ2LÉ—ÂæÍF¿ü—+ÿku?×e¨‹Ð¡i¢¡-Fª I•8n¦ñvÉ鵜5nÄVÒÚB¤vÆ›õÈ«;ìX$çä ¿jÐ8C=‰bÇ褊±™¥h“ÂÖ•¤8b7g´³0|¢v”¡é[*Äêp4ÂLP9Þ±š3-Fî³~]:£z§ÇBÕôážÁ¸ ;ƒÂd)aÞ™R©àóߟ~º°Õîxë‰5ùŸ×òOR‘ oC¥pÔ\ÂÅîå¦Êý5H$Co³ƒÝ¤%«gK…(i‹%ﱞTÄŽHÊ[æÑ i‘%+*^kv† !$ ™÷˜rm1ßׯ[òTY‘& ¾<ÈtO.\WYFؘ€Ì*ðŸ~À¢ ”Dá0•ß‚ùð]t.æôß:÷°xäW¿-'NþôD½fendstream endobj 6144 0 obj<>/XObject<<>>>>>>endobj 6145 0 obj<>stream xWÛrÛ6}÷W웕ŒDË’|I2yhÓ¸ñLš^¬Nª6“ „†h´¬N>¾gPåÈN+KEìbogÏ‚7Ç4Äß1Où/¾Ÿ ³!nnþÙ9]LèxHÓ²§/pQ„u\佩¡…ÐE%éÙô ì${~]ËB–ñn«ßëÓÕÇËéºQUáHPnªJæ^M¦$o¥t¸§½PZé9¥MÈÊJ°ËèÂX’wbYW²ßš<ÏÆìÝhHƒÑ(ñ«h ¥=]j/çÒ¾b±‹÷i‘ž§‹_üAÞéC³¼Þ·¯_©d0sŸ´Aðkœžž±ÙÚš¢É§_™q¥>Kò å^>í¾Ø`÷Ug)ˆN¤]ú‹Ò{÷þ#JGý‚Ïl¶£D_ök±RÐz¨öu­ä<…4B7f›wI+¨MLQ‹¨äŽV:SÝJ€ËBæ-TÝGº%•@ŸY1ÐÊFG*G“E*Äñ÷ƒÑ„‹wµRó)MÏÛ«OiûOÉîlKƯgϺî(„Þ,dþÙ‘*6NW¥G¹Ðt-㦠o›–«Ý*ÑF˜ÑeIÎô!é«0ÄØ †Emüýê‡ßß¿ÏØVÈáñˆããØÐµhM+Éèjݦ³@!¡ÜvÁœK†ðBxu-…åõèI·Gƒœ#ºî@@,Þ&}à® ÔÂBÄK‹^ÿ¸:9в‹•C¡…9/¬Gu0SIQ’6öù¢}x¼ø ¬Øê·ÂîÑH !+= »p‚¢FÂcõ¾8±ëpÊI¨ úH¯óV¨qIm"mÌnLt'u>/XObject<<>>>>>>endobj 6147 0 obj<>stream xÕWïOãFýÎ_1Ê”'ÀÝé>ôÇq: ]¯"UU)Zì5ìíõyׄ´êÿÞ7»¶‰M„„ŠTP{gvæÍ›Ù·ßfá{F‹%ÿÄùÁ«ƒ(Œð°û¨néø"¢ópA«”æ-ÏgáryF«Ä­Šhv[ÊD¦ëÂXŠïDEGt©¬¬Dön¼úzÑt†•IÐ<¤í;Â×ñ1±)½§ÃæÅá„2~ôþ° ÙÏ![_¼¡Ùœ÷Ÿ"€éü´ 8‰ÂópI¿Ô¶¬-¥u[…¼Í ñ–)œÎOÂÞ}u')ÕY¦7ª¸}\Oe¥“:–dl…†ì°$*<¨•7[U¤Ý6¡÷>Ûõξ¯œ-]mÔí \ÃÙ:hÿ£#»4øø•׺ºöH©Dëq?l—©‹ú£,¤•†ýÔÄè”+®¼1ŠérTÒ÷‚yAºd„DF‰Œ3¯º éÉÉ‘—™œJ‡¾ìv¯Q¦ë@v=ñ9‚ódh¸7ˆQªõhˆeåŠÅô@}“ -a[C£ab…¥up'ëq³ÿ ºQH+øíÊË™×F&d5à^V¶q*‹X'üºñ7B.8£Þ¹§Á Â{‘¡^(ö°âa@GOŸÉ:d¯Æ—’„dD.I˜!ò-í< ‡Ô PíX–Ö'Èn*iêÌ2R· ÙJ+ÍH‡Î¡¡ ©×àc»þ*.@WÂnk×Ç`‡/OÛ/ÏB c_ ¦Ý¶aÇÜòºäNBøÔ:€+.W°`äSîƒʶh¼¼ï .û(â¬N$~;Œ9@׈ŒÖ´óÅ]éÁîÆÀ÷uàf2Êàç©ߎÆàm;ðŒúâ¦Þí»fª6DõãqØÎˆÏë1Zî‰Çp§úo¹#]→ßk…Α˜[x8@ñ ½þ5¡xƒŽ>Cr½|Êâý?ð‰5H…WbX.ŠÛL>OÃáºÿÜöÆI{z»ƒÇ ¤Ô+ Î{x±Â$xÑE¶å#Í U'»D ͵£_JÃN§8Кs‹÷y/*-Uª$Dû÷ÇÇ…4ùW{t‚H÷¢Rº6Ä. û¼úýÓÇ Ý@xaU®Yøéœµ¢{gô Ó ‹Ê=ªZaQ:TEš·>©]ñ>ÏÃÅR> FœÐˆU8Mi'7·|ų«’‰§8OˆKXò¶ßÒn°leæÐÒIˆÖ{~*”UPTÊÊ…1´<¾h ê•ÿ¢Uþ«m©b‘ÿð@ ŠŒÖ \3úŒ®+û›-$ ÚÏi&@ljD3èÓQŸ AïYwÉu®EÕ5mDö ûtq¹ÂNØE7—Bý9$‰žÈÔ7ˆžÏ—ÌÇǹéߪšý‡|eY%îÞ‚ÊwÄÿòÁ^©› pà5Tô˜þj£sõåJ´*Žï-8Ä`öQâªÁWšr⩳÷÷sf~ly&ôÍož7ó³oæI³Ï. Bè˜ùw¿vÎ|1ÞzâPÇØ‚¾Š-*Á2·•Ò¾ümuM]g‰+nWU‰’ÙJJßíîswOû¡ ôµÝúN½°¼/<"[f‚‹‚>ÿvyI¥Æm³·Aß{¹ÂÈx2NµS¡*Äꧬ»Aí´}mU¦°÷ΠA7@‚ÝcÈ»»UÖ>/XObject<<>>>>>>endobj 6149 0 obj<>stream x•WmoÛ6þž_qð>T bÅ/‰›vŸÖ¬íŠõm‹‡¢˜‡€–(››Dª$•Äúß÷)ÙQê ©cz!ïž{î¹;úËÁ˜FøÓtÆß¬:x1?¥#<Üþ³+:y5¦ñˆæÖΞá"ïq‘%…­èèÂÔ¾Z´÷õâðÇÃùß'¯NÛ“ '§Øš`­’Ž9¥W¥¤ZXQI/mwt¾†¼e<á-lú­r~çˆï¢³øü15Ií••T²)Sì<»‡]+í©sUJýX§¿KßXíȯ%é¦ZJÛ÷HJƒ‚mìÓÃ(.½Yt´Eâ¼},’ £¯¥õÌxß xƒ§k0ŸÒ+cIÞŠª.å1ÕÖäM3Ý—êIƒ˜%¨&("Y$LÑQ}ÌæHSnš%Òzû’ÁwïÞ|G”sðì #Žî!ì“¶8ì 3AÄ™¬=2%ü†4Œ3ÈEز²ÉežÒNæÞd¥°œQúM-« HÁÊ/ T˜?6û•ÔY¡E¢šÚ+£E¹8äUSAéŽ%vŠú^ìmBžÑø4Eq¨Q.ºßäÉé(E’?YåY|‚Þ ½jÄJÒ;(£”}[¡¾ÓósÞøAKV;k_ ‡j÷dMãÁ'ˆsM]ÛšÔò†ÊÎlÌ’ Ë2´(’ÒJ‘oºm ÿ›õ¬WŽX0ŒjÛ8„Î VU±!åSz4È(PdkcÔ²³òßNUª–ÙÓE–‡2¾ƒ5¥ŸÊr·7"wT˜²47°Úéš›,dX~;dƘii•,Ê ¤Riæ‰åìeíHK ÝÈ Â3ä%T9\^wŸ‹ÂšŠ\f…ÏÖ)]B¶€[™É%ˆíá±²c×~‘¥ »`ªûÐr sjÙbÊ#FzUJ«J”ôqã×xYHé³iÈ­MSæ´^î\0·ÞŠÚÀ'C IîÁ1Ài·uibðäNf[Q¦czy+³&@[Y²©Ý´‰blÇ "_I-Á ïRÅ•Ël%ä¡á= =pȤE›ÛN×É¿ï*¡¬ÎSÖX ‚ÍÎ,´ÇÌ¥il&OÞ±‡Œôplj—£CdÞXH¢ ËOo^#™^ĪÙâC;çÊK2SU¬*VÅfH®†%õ©` 2£½…j# ¨”Br½Ì`:¯MLì‰ç!ZB=U j"è(ÓÄßI%Rù@Ž'»Q}Öï$xnZëäžvrL…²”ËÕÓ‰VõÚ5Ê Ìvò(´jT.ŸGï#:O§¬Æpš™¤Ó)îòä‡v:ÐÀݨ–®Ã”d’yB?ÏùðžžS©²];ý·c;,ŽoƒÇ­¢ke}ƒR»6 -M(DxÞ¢ÙgÞýê××þ… зGøÔ˜ï¾X$ƒ7Oª É~Å.zÐŽk¸äÁž'D_[X1†öëM½HÞsS9Òÿïñu[zÐ)7¡t¿/BëáSÐúÕ‡_ÃéñA,_»×:‹ÄÖÁÅ`ÇéQSÎËUºÔ"a ÷`n°„b¦É}N#»j Ãr2Mg³§ÌØ-ãŽhfŠŽV(ô?.3$k²2\²($ËmP¯ðŒ«*—PIÛ£ÚÙÙ‰®=i=ThKA%Æ-À.±®·ÒìØÇi\pÔa§H#7†P’÷FÉL§Ð©B>/XObject<<>>>>>>endobj 6151 0 obj<>stream xåXÛnÛF}÷W Œ‘k‰º9r.õCãVi€ÆIkAQÆŠ\I›’»Ì.)Y(úï=³KR¦,»з:†-S»3gÎÌœåËÑø7¤ñ„¿ãìèÍÍÑ àaóÃ.©?=£á€n8;y‰‰/âN±mMI™Ø’–2‰èÊ’šçneÊ49¹ù|ÔŸN*3Ò¦jËR:NËD’Ð[ZI‘HK •JL +qÂ"MeBU¬ðn„]Ê‚R¡—¥XʈnÂ%CNl»|ˆ ¨7xGey*3© Q(£É,¼™ëOïÞÒÇm±Â£Ì$e*)àÖÏ Z‰u@•È\êDêXN2€êÒ}À BÒÆŠ—ˆ±„7NWRfÙ–Ú¥ï¸Â7À0G¸í áò­¡Ôí€Âw¡í-D\»mèèÒ^øn£–·¹o§Ygv²Ç—šÔ1ž-j®(-PMhqËšù†'­†Zùû*P k^fhŽ`ëÔ4"±‡NÞÒj:¾<ÞFaAEè ’.C58ÀÂC,4›ƒ-¬ÉèÒwwDïÿ"ÅodGPn”†_&NÉ®Pü{©”} Çèª)½Mäƒ[ˆË{Í·s›¨ävÏW2§\ §¼ËCYW(­ Â2U“TäšE‘=±¾ù~=læeÜ JBåM£„"‰â»»½\£!0Kò”cóÎÃà‘v»†šÅ²ÿÞ+·h7²:”@|Á¶"­ZÛ pA° ò‰Þ†x’Ú•¬zˆÙº XUL– w>Hò×Ejôr7“ h¹'®h×ejáµ´ÄÇ¢ohiÔ/þ”|,ÙMœ¨zpr6jEX9OJ˜¡(ÑÚÜGâßn;ojv7u&”>¬Jv.àÛ%YÄÑìÄKt,r,õ z²[/¼ù!……Cai ³MýKůJ¨į^±ðÍ:|,²Ë¸Kñ †¾Åëõï`ºþU‡ÁŽ:äça8®è‚†¯IÑwþ&^ž¸@øR âlR²ÉGøK-fHaœåÍéîq¯YŽaýâ‚8©m4®N‡O9óyoñ;Æ]ÉÍ5F¥^Ö¾ýõ×{á'áç5ï‚™°Þ"4p2;ùšÓ§Ã§ÏƒÍÇÍýM2Eò÷“ó€Ýbã7–—Õ'Ì=e寧ïab–©™c+üïÓ ßòÇ+ÔØÿ$1ýé‹ê3ÖðÅYô|üœ&ø}†*–Þ8Ð&.›Ïøœ5Ì…pºwΣ²VÈ]³Ôñ0¥ÿ‰çƒI4AIqæülÄw¼9úåèB6yendstream endobj 6152 0 obj<>/XObject<<>>>>>>endobj 6153 0 obj<>stream x½WÛnÛF}÷W ü$"­›å¤E^ÒÆiŠ"IaAQŠ»¢¶&wÙ]R²Zäß{f)J¢d9yªm’¸;—3gÎŒþ¾èS¿}Žù/É/ÞL.zqîþ¹”®ïzô2ÒdAƒ_õãñø–&2œêÑ$éÐÁÏ׫É_=Šúx"ž|%•yEzAÓþ|é’¼˜v„KWê/Ý˨pöqs9½¢×¯©7½Â‹Ϙ" gg‹L¤ôšú?ž=w¿Öé,îa?ÓŽž^;{Þilj³¶Nî£{&¶Ê«ÙÃúÿ‰k©²â»‚ZUé§Ê‹Tu})•sÏ`qÏ8ŽŸxr\ðöûðîúnḊE`P4nÔ™,©G‘”äUIvA¶(µ5ž¤*”‘ž¬¡õR”´±­…)©´$-iß8Ê­¬2Ó;e”Y¶éÖ'm•IB!¨„ƒÆ&®&KaRE‰•ªÉdÀ4MÃ}vÍ&ü:öT8 —R‹ÔX_ê~Öå‚6P Flàý‚Ä6r*±©ÑÿÀŒ0[ï]ÒÈqâÙZl<%ˆ—8 î¯Î_§Wõó½Åt>È‹„§•È´Œ A0N1š5RåRûn+×ûÏïßÑZÃy©\®(Þ–K¶2»à%PÊsa$eÚ4 xc]HýúîõÞ  Æ Â¨÷{ñˆ~²f¡ÓÊœ`VH…–M”÷Ú¤íœøö—DCBJÊ€è3kpœPþ'BñÝ€¹ÐfÚ9Å-WåÒJÒÕñ¦ç™b¤ÈÛªdàUdðs9øÈüaÀZfzî„Ûe\hØ0‡M¯ŠÎö™pÀñ ©ýMÐ{Uƒx8„ÆÊÎÊj‰"sÌ>WÒeâ:zÄòËSʈÖ|$Ú÷,:Ö¡Ô×/èüÈÐ ä ò…JôìöÕ\j ´H-˜Ò$ûâºÁ ±ÃgÛdzÝÅiç²Øl]jÄöÛ®[!¿Éç6£S—Ÿv<²n&ÕÌ„?äÓ“_>~ þe—‡Ç÷;nW|¡ÁŠS·!ÓúäŒìrŒý:}&ÏrS¨\;¨1÷P~À«Ñü(ãOÛk3®ÐÎÕ›z´~[YÅÜ®¶Ü“jäÕŠU’9hRE$§R¤œL7\ݲ¾¡G£jA"¸ëT-gUQdší2Å÷´®aJÐÖ\$mÁÅ ­íCÛ±8ƒbÚ`0cêy)°í7è£Á­Z£j!/ÁÿâN¯º¡[iò8VFU¬B çËrëU[9™Pð¦·"\Ó—K[?Ø«oPÍ9rÎ+IsQˆaß„ùÅ6‘š‹| $g—a{b¼©/YT2èì,* ï ³Àôi:’Õê`ê1|ì®Õ¥Ó0RúMÏ3ÙY^ÅôÁ®÷ù$¯o¡vOtÇÖëÎ@Lwˆ C>/XObject<<>>>>>>endobj 6155 0 obj<>stream x¥VmoÛ6þî_qè'Ç­eùÝñ°[Þl­;Ä@1À@ÁH”ÅN"U’JÖýï»#)×oÉ–ŽY<Þïžç9~iõ!ÆO†úKÊÖ¯ËVÅøróO¯¡w9‚~ ËŒŒ&§ø”:|HÚ×RXÁ ñ›s¸×¬ª¸†D¥Tm«ÚF'ËÏ­Þeœt§Å]¦íÕ`2¿ÚD µn@«7Ü:—¥J낃d%®«‹RXL©,•Ñ$̬ÀŸ”è ÝâI3¥¨Ì¥œä¢HA¢kó\ß—BV5”‚É’‚3YWOrßÌ¢SèFTÞ_$õ§û”…. \ŸÛVU«öêd·7m(Å:·pË-~kâx§ß=°NÔ s8éÆÑ%a0Š£~Mà*4±¢‘ó/¸UÒûhÄ…Š;Šú? › ¹ÙdÞw5‚¿™¸ãP24 M3,snüê J§\{Ž .VÝòµs4¦Ù øÈ *XÂsUà§µáÚ€U€ éÕ’y¹s$<ˆÉYïìõë&IWÝ'‘~KQu-­(ù^z9’¹TÆ6ñ‚NRS ìx‘Jæœá¡÷ƒb% ¤<)˜vBŒ5Âþ ™µAŽ ¾hU:1Ä‹ q4>IöþÔznq‰œGƒP€=?{²Z:A@ #.­þ •"ѤBïð™ë yBP{Rj;b.² ¡Ž+¦­iZízìFõ½ÀR ÔnLä;^H¨+7.Ë ™E“3À3Ô—Û”³ÙÎ+Ž ÃîxÚȸîüí“ȺÓ9ŠÁ—È ®± ds¥ù—Z ; ¿ãšÀÒo„–àϹyÇ´Pµñ¬Cb›:Éqh=>¬‹ÆÀ‡?—oïaŽÄ¼-Dn–—§J+‹rÎSçÓÞ–Â+.]~ç‹· n?£$|êÚJ"@Õ¢ó7ÊŽ©å%M§NöÉÉÁ®2âlV?\÷Ü{p9ôÎ>/XObject<<>>>>>>endobj 6157 0 obj<>stream x•Wmoã6 þž_Áà©óÖ¦]†ûp[ÛC°îÚ]sè>[N´ÚRN’›eÃþûHÉ/iã½¾¤†LRäCò!û­3„~a<¡Ÿ8ïü2ï ÂÖzýë\„c˜§0Àä§a8™œÃ-ðhSØ›(ˆŽ¢£Ÿ_)DÁ¥¹èþ})€‘ý+­•¾f“±]}W‹=wWó¿…‚«?góÅõÇÙÍ×/W-Âÿ½¼,]èBZ‘sؽÕB®¢ ÛmQNQz—àš³„ëw‰n5Ûl¸6¯ ïçé &ÁX4MƒezÅ­­°k°kîð¯ÖL&Êfò~+V ]Úq©Zî$Ë1¡]—bÌeƒì½¡ìcvÚþ±Â7ÔKœ~…É÷Y(3é,”Ïßg€Òë´é¡QÝÇÿÖ8ä*)’s]ìPb•ð×_2)¹Ž‚סmoÌ«KÎN•†x-²DsÙrË “«‚­øtjÕ& d‹ÿÍ u[cë?ha9°,«\¹Ò:¬›Ë"G»uüU%•¨¯ƒ÷HVKöÁwÊb£¹µ;ü#$v¼ïʽý´ýšq&‹k ÓÞ%ϸŨ£kЫ¡jd^-ïF¤ŠçM;Ïˬå"׉:" ÐÒóÞíoÏ›ÔQ\ÿúÈ^êXþd4.'AðÕ ¿a–…¡lo´Š¹1ÀƒÉÖ¸¯k¢Ë“q8€K92‰k#Ê.ë^úäÜ»|:‡ƒp¿ûM„–vÜøêŽ64Ñ”$ݳÁ$ðÿìœóÓ3:ºšwþèü‚È»Dendstream endobj 6158 0 obj<>/XObject<<>>>>>>endobj 6159 0 obj<>stream x•VaoÛ6ýž_qßê´¶bˉÓf耶K‹bݺ¥Š Z:ÙldQ©¸Â°ÿ¾w¤GnÚfI`+"y÷îÝÝ;þ}4¡1~'4É_²=z9?Gc¼¼ý¨Ötòú”&cšgØ;{†‡Ô¯ã!Ì7ÚÒNç9fGeeÒ:a²fËT[Îêœt‘™j«œ66º.¨1uE»J•%W”霣ãù磓×czMÅO<¦QGÓ)þKY]$rüc{‚è‚nŒN)åœ/?lTÉ‹ÿ¢Ç–ólq,aD`§Úÿ(o ÂYRÕzòS»^¿çÍÛ_~YZv=gÃÔÔ«œé˼êŒñ¹8¾}ýü…ž øÇ@ZW”õ” ¨ØÖ¹ƒÃÅ óH:PÀ²8þ1 Ï~Ñ|“æhîç£9à#d1ŠÚ2yF“XªdäËä,šÍÎ%q§ãh2ŽÎéÙr¾áœ“2­¹àJ9SÙPdûZŧѩœ|aQ¥Ø§MmIYúðñíÒvHª"³¥vL 5®¥D•j¥sí4c36¸ Siv(e“ù¥ª,WC¿p?é§®ÅåÆá`W¯,ìLuMΠEÄ1š }’7ý¦t‘7´âD¡¹1V åªX×jÍÁj €°-8Í® ­*¼ÇU8®2• N±üêäÕ“'Í;ƒ°Õƒ±gN:¶íræ ×ƤT)WÖ±Šà7‡×l5-~<­w–eßýÉÆX.nÁ!8w é¨+–-=$uã_V”š¤Þr႞là»ñU!‚réÀ;4©4p "G¤ÖAãJ­€ªE¯SVGò€wžK«·%:Y$ ýñ¹¶HMÿ[Z‡’pB;;'aûZi™âNÔ|©‰üøtBÿ„“†Re\ýmÜ9þsc®I9_f RÒ*¤íJ˜Ó®"€§ÝF'O΢0sP ÄNwuÑ#Rò¨@0"h+Aœ„P¶U m8/}¶a%å;~|/áe‹³OúۢŘÓÖBç{B8Fhns Î%M‚î›Âò¸3@ÂáüÓ—S?[–·ÈËÉP>c(=>éâõb~u9ÿëê÷¥,ÓRB]ÊhºsüÅÕ›‹ãz‡È{šôfC7H¼£žXß]™R×¾‚él1€§‰cáû=¸€ö® H͔λ3=™ÏƒÄ(MGr|/ÍݦÖp|`T|×pÜ7,̵ „HmÏØLC™T_èp> <’2Üm”‘êÕ#íTáì¡¿Ô@Kr:m¨.W+vuUЋwï–ï=\ò|Ý™÷÷›ëXkÍ]^]½¿ê¬…µC=v3"L˜i7a>1fBL” »Qëê) iõ’䬪ˆ^ÖŽX¡A÷½U·{ €A•¼Vùû“×8é:”Šש~ÍUrû¦õò5ËyDyÅ8ÂÕÊí A’×Z ·ºVç{-&S\ø„t=ÔõX—Ê=¤ÐËeÍà[Ä$d×bn‚&OÛáè<’K$†Ö"ÆîÓ'k­Šû½‘‹öÙ+¨ØGMyY·(›QV†Ú¹§nþûQü4zv7þLc\.¿æÍãK9LmËÀš~½©)y«Jësòºã ŸFgÓ3šÍÆá>!3a4ÆôËÝi%ÐQPaïè<܃.-gãY4Íç§31t9?úóè?Ä4£oendstream endobj 6160 0 obj<>/XObject<<>>>>>>endobj 6161 0 obj<>stream xVmoâFþίñÉA`^¹žRéÚ’(*‚”ÐF•,¡Å^`ïÖ»ÜîUýïYÛp'¢$Ží×gž™ñ÷Z:øÓ…þ~ã´öË¢Ö ;øòx1hß  ÛÅe‡Ÿð&ñçx³ÌÀZëÀ:¾ƒƒVœ†ƒo¶bpXkW‹¯µö:ôÆ‚u¦b'´z6l·ã& ¢«\¢t„ð¼e„»Õ…–¥>àc.v]‚élq¦é[-3rЄ”._€åQ EÒhu{˜L@1±Ù:H„á>¤[TF µ½F¿6ã–rcIb¸µ!™AàZ½Ùù‹ÁV’ƒäjã¶ÀT _³L:Ø1ÃRî¸)bïÞÁ·F!UÕ£ÞpT@T@gE‹—·<þ&ÔÆ[VYºâ†âbf“¥\9ðçu0Ûs#5Kxea>jêAéÌù g™Ûá­V~滬và&ìåZ7á'¸öûøœ{a\Æ$Ì·ŒóH )1­¡¢+ø§¬°‡ Ý€ wY¾Î$0çŒXe«ÙhŸI>áB h+†ÿoáž;ÒˆÕ¬Û—ô':¨GWŸÏ5bCe‚†£ë¹&½¬Ðzd&l r$µçZþe…Zzö!‰{§cÃYÑt‡¼©@¯¾"¥/Ó,0ƒF)x S~8"yÊ®Ú| ½Å>÷Ý‹´ñx½†gãàoá QZÒý²ÐŒA•Ž¥>l&]ГjsáÁ¨@ã4Ê˨©-…4.=býÝ> ¥ÖÏ(ܬÏÇ‹?çÓåâïÇ1Ô›à³iB= ¾ÌpõæôaR™„ÀUÈÿ$ñ1#©c¼îËy¡8Ƕk’Í­N¹ª$ ÂýP’SŽ’8„ÓÀÛ¶íc·áß3œkÉ¥Ež ·DADÎ&M©ÔbrÅ@>2ü‡~ÆœzùÒè[¥@')Û¡;A=Z•á«eŒµ²Î0,MEÏV׌éù=p,;¢./Ýæ0ø¹O-þVö†»Ì(¬œÌ8`]q0ó‚ãâ|TUìˆNÊ÷CA‰%g*Ûå[õN•Úæ»¸„" ô·*¿ä§åX*3N8)b¿Û«§øÛwåFïÞ Âëþ5 Gƒri==?Ü·úa~Ó±_ÕŒL“Nï\º5¢¯¢$tÂn'ÁDZ’ï¹Ì ½áŠætþýp݆ý^þÙ0ŒÈÐxQû£ö¶ìÎ(endstream endobj 6162 0 obj<>/XObject<<>>>>/Annots 3351 0 R>>endobj 6163 0 obj<>stream xXkO#Çýί(ùK¼‘g°1“«HaY– d÷&Á«½Òr…Ú3=v_ÏtÏv÷`)ÿýžêž±±AÊC˶ûQuNS5|=ÑÿF4žðWV Ó!Þáo#þöÛÍÑx’éää4SEçx·}QÒÝÑÛÙ³ a—]Ðñû!M±zVÐÉ&£t29§YŽÒ,ëK&¿”T4:óÊh2§oßÌþw4¤d„•9V~¶¢®¥}¨­Òþ¾¿Ž/ÅCû›»ó¯v n [p¸Wù†šúåqïd)½Ä9ZTr·µ» ·n¯Ú-êηÒ7VÓÝçÛ›‡ÿÔÝøƒc9~Jü² {’“q‹@ÿúIfWzÄ•£Ìä’Öª,©¶&o2¼ˆé9Z/U¶¤¥x”€ÅÒ\8•‘[qô@j¤ÖÊ/1†ÐojY‰Ú ø••„³çsׯ®ÈÊM» Ñ ÆaM®Óa:¦Sº2ºP‹ÆŠ@E¡JéöSá§é)ï¹loU¢+b.k«8±A€…\SׯzGZ [nȯ¥ö*…^4b!hL°’B; <ÆC™“ZaƒÒT ÿ5ÙrÍYä}¬? :@°½ˆ*àŠT…)K³&g:v?",”žKi¶”N’xµTË”¢4 ‹ÁH‹¼RÎqµrЃ½h6¸GyßЕ)…;áèg·…´”FÂk±ÂQ¸?7¦¡•F„ëp;"Fù3€`E%ЪlòN5´’2Jȳǔbb*>Z$Ã:n«Ai®||Â5 Ѷèxý(×Û·~âl´x4*G]s|_÷‡ÈG´U :ŠÆµUA[«¸ªf«ü]ú¨yÔ/@GÕÁ+Pϵ•5 +8Y´Wˆïø°7gí¬³ºäŒ¾‹•sÖÖä(=Oáìgá'Þ8ø3¯§éôt‚Nw½…Oá«ýºKºEÉè,ž‡†Òs+U÷ȋŋSXW]—?xmëu+žcqž+Klÿü/OØxäß9 q<=Qã’ËhË–8@ @8§ sB¤P@Û`;`·–Ùõ(™Šl=L\m9ÌxàžË2„ÿ‚'fn¾á #&¬íÙ¢ñ†Ïß_Ö b}–ÂBjô†Ø…ÍfÚ~\}r™Uµç¦ˆxð›÷¦®Š=z)QŸq-V,X\€î݆&‘Y&‰d[üˆ*ÇƦº/÷´v aâóGYššìf n/›E+;(3Ê‚)D>ŒU0©y€§Ãz){³Ts cÄ:&ƒPt“Ôù1‡Q­ä–FVTAOES†ÖÅ7ÛaNnqF?Š3<)—ûòüÿä”#ÜÛ¶pyõpùÛÍÃçÛÙD¼hXúáîæáêÇ뫟n?Þü…åwŸÞÞÍÖµ¬ÏDýð¾â&ƒøv(£(C×ÓÐäø ‘—ì~m“~%¯/‡×reÄ÷¶¹ÿ÷pM¶Vdð_ö­×+, k:Z˜(`P’AmÜÈ^Å`;%` ‰÷íj”[hë¤â) ˆ)xÈ·8œ<Ÿ‡1öt³‘FÏp¨p¡ŸPçl¿¬ÈºÚ° ý‹ öî¶v¾sLHd°{ÃÅÉÚ“y5ÀÔ/Ò–góŽçdurâ1ýÓ—ÛvPG8ñÙ]%¦s£ u}ƒ‡ u„p¹zTóô†±†™»ýjG·çßÃü‹“Š¥#mWæ±¹%‰÷º%¶³ÃdgvÄJ²×¥Jï“¿[F©vÌìxvÔ1©|ãÏêì“à#Òd”ÛÎþ5¿Hé=Æ8f‹¡F¨v¬³=þ[WëqéQV†Ù‡3G™©EœþùNìE»ãn×ê —üÞ põÓk›mWíáa0T oJ GßÓJ~§Þ¿~úÏÅÅíÇ«Ÿ?½»þ¡G‰yööÏ·oïzt –ðp!F¦ól€ÛÎÂÁTQB²ªýf@ñæ«­ø‰È)¸#£;gd;‹ÀˆµÞÕ´0&ÔM»1b2E·<£Éù$=†9€“1þ\ðÎd¯Û±+ìÉð4¬NÎãCóŸ<ƒž 'éø$"ç§S>âzvôëÑÿð³Gñendstream endobj 6164 0 obj<>/XObject<<>>>>/Annots 3353 0 R>>endobj 6165 0 obj<>stream x¥XaoÛFýî_1 °Üš´,ÛJÜ¢Ò&éhÚ\ãCq8ÅŠ\J[“\–»´¬of—”H'iEY¹;3oÞ¼™å'—4Ç¿KºZòÿ¬:™§sü—üñów'‹Å2]ÒõMú‚*Z¼˜§7ᢤ÷'G—]Íçéâpï›»£ÍdÇvCo®érNw›[Þâ[.Öð%›™\+ò–ܽiHeÞØÚ‘ß*O•Ùl=µºÜ“­Éøôìî÷“9%‹kl0û§n5G»-ÙÛŽ*µ'U:K¹.L­IÕ¸4ÊÑj¶î<öÔ5?wZ–Tk³Ñû²Ë7š’$¡ÜÖ§ŸxθÕÙ—lìâ ǃ]ö3ù£{¤¯é«Yu{»: +úP^r¹`WPΗûsq²·\ÙÜ{Ò*Û’-hlm–muvŸÀû]kçÆ;ÏÎ?ü¸~TUSê¿ø´×Î'®3^OvnùØ!Ò¬“RÕ›Nmž˜Êª]¥ôo§lªMv_«JSa[þÁésª­$"$&¥­çg‘lN`†ŒÅFä´ÖX’»UœÑ={6øÃ18Âî}èä´§®ùJì¿U÷ B©©í€ ïì,¼qª6~O±©7n$_k;|OéÞÔ9¶.¨iíºÔ•ö]¼¹‰„H@å˜Þ×÷‹Þ`jê1¦‡gð–ºFgF•Ääý ^kÊlUéá o‰æ™$Q°Ÿ¥µ÷Ì[†W?çy¯!#tÅ_ð,¾½½ Ò›}ÌéWö áJÓ‹fï·¶>Ú€¢Ñ¾fn¤:»BÐ)ý„âtÝ:7-5º¥Åúqo0ë‹à¨~ô­JLí¼*ËO:ü}!|RyÎa!r¶‡ø&%VÒQÊôÆù)ŸsêéŠ ¤£èãÏí ¤'ÞC”ÓµŸ§f¼d :ç>Üêiöyêv›ñã3! èÒÚJ(ÒÇÝ “EØuæm U}¢;{²e(çÕÌ6¬Ìª\6N¼ù³ÜÌ7\R±dˆ ˆ¾€¢È™ –b0¸ÑC¹E¡´ÝzÌtHNpæ¥ùÙÏôÅ[›³ TUã0úœQ оi‚8qé¡…¶@/;o%ÃüsJwèÔ¡5}ÆÛ!ªÐš~‰†D´„þ†û K`Øðœ Ô W²™ë r¢‚\×µÞ‹ÅðœûôkÞU[¢×Àûܸ¦T{iS8p ëXШBïC«‰ù½%Ž® ‘ÞÅ’;ëõ<½œ§·ôsW{ÃÚÞ5m'B&yIehxe\Ö9ž/ôAá‹®îÇŽ}c2æ^ Æëý/ßÒ  Ùét“Nk’ýí[[?èÖ¿óíj6 ¾1z²øG½{gMíuûÓú÷¬GùqJ…'h­Ò¡øBœŒ\•Ü2Y¸ŸàQˬëcœ`ÉØ!‰a罇բטu« ²ë˜GˆÞÁ8ùKÉ*ëü@g' ¼÷Z7Ž6­ÝIvÁÿJyT‚ãºâ¡¡,ãm©ÔŠ©MÕ±²¼ª•¹e@¯s$.2@ç2Àq]‡šôûFWªq½Ä^¾èùó”çaiµX>íß‹]Þùü7ç[øû·¶x½û[”ÿßÚdñõAxD'³Íž)^0™bf®cÀéÏŸ°å’g½ÃôõQ’¼ŽS.3µïIlVæ2hí 2ÆøPñÈ׫p~öלwêJ’œë ‡ ÐiLÓf)¾ÐFÜÞ`X21ΛHåè:O°k Eä£B<%àÁ¥ÆÙVïOƒå¢+)Â6RfR•Gùw!Ô‘'8–ì4ÆúO|aþåÐÁ‡!OÜœ¸N¼ öhÏ’.)Næ³ ã.átY$™­½ÂÀZ®?‘‘Õ 2A<‹ÌTÚÞÆazœcET@P4«PYhpâg»7ÀÓ@T€8…´Vú”\Öš†‘†G‰ ZÝËNDÝ9jy.ìšÒKÌR!Û,uÒ±™'S•ÉW| cgœ90탽‘#‡³ÞÀ–×ý`ÿ_þ×Iè \^„¤°Ç6ýÎRV*ç0l ¤Ým Žynk»2Ç¡†MÂÍÊ"Ü/ø«_¬>©¡µß…²eKØä™3,ôÏèÛÞØÐž‰¸óÅý½¾˜øœ/ >îœ š}šÙw2ÕŸ¶pßæŸÂçÿàÃÎôxƒÙ€gp`œ&ëúhƒjƒqAª+=¨3$¹g%à°îL‰~s`¿àASD¹…껩‡qej›î,éú0ŽIY„1^0à dôqb`ãQäÌYË0¾œËáŽr`j”§0ÙfüίIf`Ba6]¨åCß=¼é_¨Ì¥‹7}[̯ӛ«Z.¯ð2¥Ïj‘\¥sze³ŽõIäÍâµDx6yÎo6>9BÝÌ—éÕ"4Çç×·¼üõÝÉ¿Nþx±›endstream endobj 6166 0 obj<>/XObject<<>>>>/Annots 3355 0 R>>endobj 6167 0 obj<>stream xXÛnÛF}÷W ‰ºÙ²Ó·ÔMÑ&òÁŠ\Ik“\vIJ&Šþ{ÏÌò"Ò6$PäÎ}Ιáß'sšáoNËÿ‡ÉÉ,˜áþ˜óLJw'Ë«EpAó׫`E Ϯܓ«˜>žürwtDι-Mo^Ó|AwÈ^]]Ñ]$"gtŽÎgÁÿ¸«ó‚"gö:¥Hïul³D§©4¢b§©ÀýI^šBŸÝ=œLoÎi,r²8Î!tôFzQH–9«Â™œBHu*¦ÂŠ\“àÖ^·ºŽuÛ }ütû. ÷Æ%62ªÂØ4çã|”ƒ`;TÚ$S©Ñ­+RQdø:½u:Ïq!væâZ¸Óá£I·¤b˜E²NóÒÁç*(µG'sÚ©½¦µF” ü°Qê(àH Ø‚;Dk ‹°ëÊ9¶Ë–ÛÆae|@Wu@Gß õ( –Ýe‚BD°͈TZ&ÚÙöËPåš Ôn£BMë׬ÒkCÑ4éóq{û¤’ OM;ñýD(2N‡…uˆjN€á»Pn« ŠUº-ÕVSžéÓD®L “xs\÷ô3KüòMú´CÔ‘·9«“)è``›~ÒaYpá¿c{à,ä…Îr\;Ò\M¬~fEh9Ô2§ðm}V*,S(N`!²š#ƒðJ LT„5Íb‰¸¬ËòE‰$ˆTa,r«SíT’¸ž^¿z…|FÖ;ÒøÐN¿&XëïŠ Çš-Ùõ²áSÛW¾*ÿݤ"êøŒ—¢(ªR• _±Y;…ÜÞ¢8žæ;4*U”ÜŸõ,‡ ïTZùÄÐÁ¿W³zé\æD «‰{asHëÆG_ÊcÛ†¶+½2ˬC7øSÜ2è#JʼŠSñAU90V êe½iÃ1å>…^LãÎèGL†"TÆZo ˆ…ÛOà`z3£«`É$·`p_Ë%®¢Ñ©÷ ÿ­ÜLäÀ2X­.Fhìmzœé†ÌC“¸Z‹t+ ˆjLe^‚™*± ø­Vز:‚§& ªíô ‚€NÿF3H0å1äq2õ`)*$§Oî>æ?©Ø™A„E+ë‡lÖ0ë1ÔôfÐó`Z)'2‚?Œ{lH‡ÉŽ©ƒeµq÷Þµ-þ¹‰Þ—¯“DŸõS1$‡1™z¡îì04¾ Z e(”ÒKÊê’¸³ÌÁÌpgd½7À"˜Ð-Ó±L¹–Þ§ßÔ^‰VÅŽÇ”>·‚E™¢ý¨Ôܦ Œ«©žš˜èâjÜw© ì ¬?}€½Ž¯cοCˆÿÉ™¸õ’ì¬H~^…[‹8׈Âåà‡QÉ?ð4’” u|gœ½ßrÏxÑèä`”ôì$*×|êèBç4؈èE§v[ÊMö$!¦þšõ(˜Ó‡2å|‹ƒ]ýùÚj¸°=‡Þ¶&·°Ûàä¬{”[Š2å –@üa»{LhA£)Ð:Ñ’ãJÈ ç º1[d0¢¨t0´ç&g¥}¡Iy³ÎX-”Þ«Gí—Fv<­7°Þn†%7BJ˜.Ë'A †¬0)×j‰FÖúL’-ÀiM,…f*|„i~@g›(žæŒ‚UëËAÇ£J˜#ÿÁÚŒx¤•‹v•v©n6äQnn7L%)×ñ )g0@ÙFÜxŸç±1U¶DÀ€BmѵÑt:ÀÈüÑd™ŽdI1iÄË,œmŸk3ÔËÏš˜zIÑxˆ-Ó ðͪª) L'lñˆËòìk›rê;|Ç¡î05Dÿ ýYã'¯–kÉ#p«êÍ”[lœ£r®ÖÖÄ.áU¬Õ"ì‚< ³øš?ZìÌ=VBy½¾ElT‚Í(æ÷Ý ¬Æn)|Ÿ1ª¼¸±*.Ä–[ûèýY;d¼8Ü%üü丌“N\¿Ñ‡^gGw‚Ò%ò}'¿ÛŽÁÐÀ;¬çþÚ/~Ž'/`Ù˜˜tÇ”i_àKøçÊut1wáw¸ã}ñZ¾×¥?¬ìÎ(ì3à ͽ_€‹0¹tÿÓýHàWr‚rº?û‰ ÆuôfÓUÝ Dê½§vàªi³óàbyA«Ë•­Ä>/XObject<<>>>>>>endobj 6169 0 obj<>stream x­W]oÛ6}ϯ¸à ±âÄÉöÖyÉ`ݲÆÅš" %Úf"‘*IÙͿ߹¤$GnšºCĨKêÞsÏ9¼þ|0¤~†4žðoZü6;$,¶vIÇ—:OÆ4[Ðh@“_†ÉdrF³,D h–ö~¢BiK üáda½J«\XÊ…^Vb)e º\èFÉx fd½H~Ó·:ÿ$â#Ÿùi'ðÅò·4¡ºNnº1«I\/f.òÀ³ø¬AµG…É$mP½¤û ü¹ù÷êRŽä™Ví¨þÀ™¢ìG”+ý@}ÇK5ÃjÐ0gÄp†Ì.Çjã©”X2Kè/ã3ÍÇlë )3ØÁáV~®ãˆØ«yò†;›keêóGü§jYY´™³ÊÐðéwòá•ÎtÉG| é­(£b[RpÎr÷ @qäü·N¡¶¥Pº¥ ØÎjáš^4ø1°^`œÔŒšm{é)D;4i$ð©øc´ºZУ©lè2šoi%Z½-izýሃà:’œ·F/¾ÈÖÊzt¥‚#!#óQC®”¬¿2`¡QkXNh¶ÖàpÖ-¿0Ø™Ð5Á:MÂq P õN¢ ùºD äQ”Ì[AY%r&Ò´&•Îá1 H.*UR3›¸ˆQ'¶¤{3w{´«?ªÍK°æÀàú¡WÛ¨—¯ˆ6¸ÓÜ{±;TxÑ1œ„J2ZZƒN@¯sM¸ÐK6¹FËJgj­P ŒÂV·2Už±òZ~ÃpXL¢š¥Upâ]­6eOÈ èÔûxD¼Îæ ¾w[䎷€GúÆÀÖ³@˜ÖX¸q(ÊC“‹OYrÓ7o°kã¬ao‘¼ ÙÆ*ï% "ÈT9а“_Á&ˆú Á›3z³R骦x¡tYùÖˆ‚·E3i`ïe™ øÄNu ?íTÎͶ͘ËÜl"íy]‹Vµè$ÉëÍyIýdt–Ë\4mÓkÃPp}>Ù+ÌêKoz7»¸™ÝMßÞ\ÜÀÙ’Ú)à¹öpÎF'ÅÃnM@½“p#Ñ-±Ø4öÒ‘£-t ,ÝùîËvƒ´¿ñÖ=!¸¾~]Ø”㙯VY~·è²²<ÍË%„˜ Ø¢ÌY_!š#€oñ¢Ê½‚Qò\PñxuÛcÎü¬ŠÒXOQ½j-oÙ¶%äÐ\Òí5Ñi<;¸[á®ÈÀ«¹Hç¶—åùq½hæ÷°ƒÛÃú>ŸW*÷ÑiL¼a$o˜î º…5Eà°Æçb¸„Þ>ËðN>\Ì»ήÝð^Èûµ:‘îÑçÛÌvÓ1æ”8Çíscu•Æsë‹J‹Ãm‡*\ô2ÎV¸oSÿÔÓ˜\u.˜)3Ü!ß¾#Sz˜ð >çÝÑçiĺoÆ|ñy} ÏO’Óñ)M&'Í4σqœ èw“VÆÁi3Bp Ý?‹_èNÉ¿£dHïëé¸1Þí׿ÓÁ$ð]®}v:äƒ.fÿü2Z¥Aendstream endobj 6170 0 obj<>/XObject<<>>>>/Annots 3360 0 R>>endobj 6171 0 obj<>stream xXïsã4ýÞ¿Bs_†Úͯ¦-3ýp-Ü pp``nd[‰EeËHrÒð×óve'q¯- s½¶±di÷íÛÝ·ýëd"Æø7³}åÕÉ8ã }›Ð·÷_ŸÌ/.Ò¹¸¸ºNÇ¢óëqzÝ}2âÃÉl2Mb:ã{%f³«tÒ}âÕ£ÏX],ÒËãÕ«E:Ý¿;ŸL«ÇŸqïôj¸zô«óëÁ½_.aoÜZœßÍÅd,–+x¼¸Æ/;Š_òÑ[)á”4B=Ȫ1Ê »JæåŸ-ÿ<9¿‹«tFïNÇ"™NÓÙ ŸŠQ%ï•H<^ ³ÝÇ4­Js£dM¯a+]øÜ¶ |xr[f­ñiÞ4ÏîÐUc]ðiÕš 6|LØÐYºX\’¯‹¬sUˆÖ˵"çB©ŸøV%V2×F‰Gµu­ëµd‡°µðO÷ÎJo”ð§øT,qc°‘NËŒpëñŠP>üòöëå»w߯Ç}FBÖÅp'5%Sßÿôý“/8ãáA°Â7*׫l"=qŠžØfvgB׋ÀÐÝtûªTÞ o:GàeÐð‹@Hů¶WÈb£»[6Zmûø°eÙÐèÑmG—ó”ç¹­*[§ÕýcŸWÚhëD¡‚Ô€6k–—ˆ§ðmUIè¦ÜHïuÞEL{r°Òìý,ÍÚéˆêa¹'ÿˆî8S©ÊºÈK•ß#Ø©¸ƒaûÏöÙ¼n+h}ïŶTõ!°óG ‰%ÝZad½n‰oºÊ5ÈåþCB ³‰)n^!ÅØM‘$dOÂö߬Zc^ á~”Ënµ1¢q6Uw‘¸tV5€Õ+± Œµ÷Böö¡AŒ:ÆÈÌ‚ûÒ âQˆÚ¶#—̃ Àƒnˆ«¢ô‰ŒSE:ÀI™Ë›ÀMivƒÓDŠL¢CZæ¹òÉÔzôÿëoeô .aÔap2WÀP›Â©úf§üË(¾u³v½VN ÒxK~Ä|+P0½°È1,‚‹z£‹E•BxÆNvë"ûn퉀àxö/&3Þ(íËùK«ïn_/zûaH ‘PõF;[Wª¢/p”…6Cú¢Ž4TNÀ¸[šk VCiA¦É‹À ÎåÈ at­¨jj?à¨ÙH‡JÞé ÒŒ&¦Ñ˸^ƒ¤‡ #Àyô/å·v¼BJмõÁVšØ•щÄÈÞL„Àµä˜ç¸ ¬écDw'ïØMœ#Ù¿•‘ëþœ†Ãu}F†R*§ 2‚ØL/gÒ—XPƼkà̵zˆ\Ëm…yš4;`Z'†ú$ӑл:È6Ä«8Ÿ¦ç°"ÏVÎVˆ^$k)Æd­@[*ÒHxæúÖ:”À½»]µëcïÏX¢ZR}¡þvªdÓe™„°÷¾ cñDU°÷æUÂÉ™„Ê+éòòåT^²ed%1:õTãT9g?=æÛ¶ÔyÉæ¢Tr9tj–ë©RXü¡ap¾m¥cAÍ—ÏCeó¤< Þ¢PrùE”íàôhm%Ú{ä¿E,Ü¡—hî:Õ(€ù5›?P—C¯Äªoa6N‰|¦eùǪmpy¤YtüYš¢Ü¡ëá@¬Îà¯/È`ê ÌÀZ(Ÿ;q† ïß+Û'ÄC4âü;K’ ©f%yÐu#î&çwׂÔiÙdº Ù4§|ÍÄW6çÌæ„7÷²‹6Ï¡æ±ý+[Ÿ²ø > ¾o©@U ŠÊñ!œGhGA¨lÑÂ:ñ¦uhD©åC”âQ} , CZ ‰„ª*’^(­)È$§ðN‰üCP)þèÄ¬Ë Õpè´`Ç "º«•Î5Uç(¨zql‡ƒ )$fæ—hQy¬¾û‘DÁ|émZóùçÃ-‡×;ï¢0FÞ?*óµ+ýãQ +ø…1>‹ž™PW’g‚£€Ù¨ ‚˜äIDj Q‚õTtbéÂÊ)JšÍ6Ú¶Íe+"ÎHÂDߪa7ÚcÞÖú¯…ËïõÌ”‰Ä£S° PÑê.ì¯<ð-µ/™*ÃSÃÌM[(®y;ÁIb䛣¹ï­Ï˜ :þEø&W~É%Æ@ž¸~Ÿb=ùi­1¾G7éAŸi¦Z¦ÂVAÛ¾9G„cZ?R±¹ÅÕ`ìjå¨Ñòm‡Ð„þAw‘Ì—þrêÄ4‹ Eáj,Ô1w .˜8HU.™^zÃLB® ª"ÊÑÊèá¾°ñ™C¯yÒz\ ÛbV{¼‘ŒE¬ÐjŒFï¸í«uÆX’K¤lfÙü©û…Užºƒ~44´r1yÅà Ô&IꎜîÂëJC1ÑO‹=S í¡f†$%åMqêb³ÉÓéíó»!+À3pì9Z̯hõRó”UC“9J5#Y«Z9._[GÈ@üÚ‚‡Œ¢%+ ì2‡øqö°8δ/¡¤Á5²†¥@?ù¡X >‡¡ÿ·P!èæ7΀˜Ü‘CÐ)€«_0›CCƧg$V8EIŽŠÒæñEºþ™H­°¢–Ø•K9„®9 ªÁSH: jjˆÄpÃôL&r¹ÁK׆hÇŒ>B»ÏÐÉåEº˜]ˆÚU,ð [ú¤mAÖÍÓ ìM.ã_QžïpãE:›ÆÌ¿¼˜±o—'?žüûç\endstream endobj 6172 0 obj<>/XObject<<>>>>/Annots 3362 0 R>>endobj 6173 0 obj<>stream x­XÛrÛF}×Wt¥R¦"B¼‰âníîC,ÉëÚMìØ¬ÊÃf†À€œÀ ˜(þýžî@]©J[eƒ¾œ>}º‡¿]Íi†ÿç´\óŸ8¿šE3<ásþññíÕâv­iu7ÃÏœ›y´i~ËèÓUÿ÷œ–³e´è}ÚÿŸ®Öƒw¿ßö܉ÏjO7¥ù‚¶)âZo6´M$œmãÉjÍñgE*]éßjãŒ×ŽR[‘JSìIQ¡”©b_«½¦Ü&u¦É[òMŸ~~÷–ã|evµ7¶øvûëÕÍãŠæ°Îþ¦‹U´‚ÇÉ»”N¶¦£q‡`ý’Ù>Ô ^ðqsMǃ‰tÔ¤‹ØÖG#qf•¶¬3Uuaºk¯Ò¤ø/…Pƒd’"É´Ò¹.¼‹èçƒAF°«Ê²Ò±Qù”§½ö^ €åJ{G6#r´ÕŸ:ÚâOÑámÆÇÖÞi9|ÈsS˜¼ÎqÑN#;ÕB«Ï(¶yn¼4¦hª`ÓÔ ìŒÞ¬z3¥Emu€úõ x¦µ¯+=€åYWõ“¹ªmj³Ì„Ri•e'DäêûƒzÒ)Ú*2#I˜*’ñéú/¼®£¬ÜU ÐÔ*¢™VxÃhH}®©´±a–ê¡Þ€´…õ óà4ˆYV¶ÔØ +ÚÙ—ÏRÓ'Š:~åOî`ë,!ç ´‚)Kà«{2eÉôg÷ÌEÇÉó«]µÚD¤Q?‹2ˆmǹÐ)ËsµÐ>h·‘ÖÃÔÕpFª`ǬŸYýe¢ï +™IZÓÿ²ÐÿoÊÁS£Dù¶ÕË‘GIŸÁÏUqõ«ý£Hå£þðÂR*qåêW[/JbðÈvØAæJÍàí5Œ@’ÐJ0 ¡ö¬EòèDD9 àm€°x–9[ˆœè¦ø–Ù…tDŒ ›©S…†ö0Kå_hß¾œtÐᢔ5 5*Ój\¦•}64©Ò”ÆÄÁç%6®y)‘PÓ!I®] Åhw^¡fÉäöì4ÔCÁMÁ£·"‡1c„ Àp#W2HT D:›"×ì9äü z»¯‘ ‹ºžn·Ž³TJdëqd¦àirM:Ç 8W$ÑÏ:ã^ÄXáÙ¯¨TsŸ ¢(éÆOÌŸ09fLBLÓ†7-X#bÊsM±®ø0hÔT]\ÁŽ®rq‡eàe–Íáiv÷.ä4]`Š…V|_`À©Qß º7¯‘Ž$+áëD4Rµ‘³ž5©ÝE˜xlPÔs“vÈ ØÉX„öê“KÏÇÞˆì|b½`ÅÐ/ØèBÈ@Ó?@Ÿ÷@öš¹ï`SD¶MܱñS)6†A8¬¹*ÃÓ„•!´#„R’ê;u‚tqeAðf_½¥7—¹øêþ¹uþž™Ûéã››7èó~ƒðâˆmм¼ýþý—P¡~XB4K™)R IJ(­l>L‡Ûm€ššÁ=öÕj¯Á¿ÄÄè|¼ß€Á/ô&¯)”1<ìV‘ÐÈ;­°x§¼Syk3,;Òn/XéyŽõÜôgEù÷‰½Ü®ÊMW| º‘€s1/•}=rü°ØL0îÅ¢ ƒ€VÕ(~y!ÞþÖfµ‰–|;åo-—ø-™|MqBÁU —Ç×a¶7yž¦l‰ÞýxÿðãöñÝþ]w£WC”¸/§‹e´^ß±“÷)ÔKd,·°Q”0À”I5.È•*Æe((W;θvÒØÎƒÃœó¦9HqžSQ‚{Ó*s¶Í,ÜDd¹NìS4Ó,Î,ÓÃaÙuÎì°AÑ¿ì2Qá¡výVUÏ UDTEf°q…+Y'¢×±h)“‚íàŠò]]瞤Ø=Õ°…¯9q§\5ÈwP|€žêçsÁ0BÒÝÄ)Xd[ÆÀÁkFãö…>°P^ ì÷›ÉÚúfƱ¡fè‡æäkÁ]Io€ÑëU–£¿¿Ä^ãÖʳ½_ß2â3ÿÛã@÷éâm)ÅØj–„?.þTêD§ðÑãd?à3áùhÍæ¥®l_d=ÎUyÙÃ’püuDr‡o0¶ûÁ¶ö›Îàö²x•¹ˆþ0®ÆX3.ÚºyÜ4_4Ì7«èvyKë»E´šËÈc©ž.£Ý÷—aº˜…ÓÓ;þš¢Û{þÔïéngëh¹À—t°w»d¿Û«Ÿ®þ_±~endstream endobj 6174 0 obj<>/XObject<<>>>>>>endobj 6175 0 obj<>stream x­VKsÛ6¾ëWì¨ÓebÒz[É­±ªL/M;á´_ ”R €rõïó-(J"åZ}Äöx@ì»ß>ÿìhˆßMæü'w½Ioqyúg7t¿šÒhHIÞù;Ò@ÇA’­"YìÊ\yE¹vžŠŒ/v¤ø6ŠŠÒëÂ8Ê KŸÿé# «Hì…ÎÅ:W´>­ŒÑfCo’/½ûì o ܳÞP´UyY#qýýŽFÓxZ›|LÓa<ÓÇJ§Š|A¥°«™"U®­iHÑx/,˜lµ#§$Kà”V¯•#ÿReÊ*ã¯Ô{ mIx‰Ê+w4ov ð 2U2Á¦-On”QVäô#d.¬¨ÑÓFæUÊ(í…ÕŒœ»£¬2Á^ƒ!‡R¥*s1ýp)Lp,à’pÔw¾°b£(¡eŸž·pŒmÀ –4d j>`ˆÃ# «´Œ)«Ÿ]Ö·¹…=0¤E<áðŒçq<™à+ôØ©>~"ZE‚0­1‡mÐçwZÜš×)is²-Î ½¬…žbí¼Ò?½i‹ýl¤#ú|)8AçyGê/¯¬¹ Þj\xwµìktE´:ƉáÂA§Î€e®‰l=«¸Ô±.Ò* ùT¸ª,s­Ò®‚½È« Œr&ªÜ#@xIö~Õ¤l"6‰çóŽDùz[I`°]¶ƒcj?¾} “N\—Ù÷o“ágT÷“ºv¬®Ðýåj›ñµ|x4ÀÓ³öÛ‹ÀtqüÇæÐ•Í”ð•UïzæX"­”箤Mª¥@ô tÃî‚…ŠõôŸNûèÄév(ÎLß"gmm|ÿ2· H¡@öÚúJä]`o&·«ÅK Öñ:²BJå^\œà5É­0u#­ÿ@ˆ[å[VëœHi «”z$¨KêµÒÆ×LÍ s+˜Å52I‹TS)OÓïC!ò%úéwhRÂ7¬½êÈ­"„ª Ï#âVOî0^Åé7n>¦ë\¨«ääH;횢һ]åyö_,,‘F…ɯ£Ëcíï å–Æt” Ôa/¢ŠÜ 9³Î”ÿ 0¯á•&WùóLák´nÌp6¡GýÊ`_áCÐÒ¯ å~µ8.£Å4žMf4_Ìâù(Ì_ÞÁ¢I<¤e!«¶š°a0 h55wôPš—©ǺÚlxõøT¯rÌ;ÎãÉ !Šãa6å«“Þ¯½¯þ&íñendstream endobj 6176 0 obj<>/XObject<<>>>>>>endobj 6177 0 obj<>stream x¥VßOÛ0~ï_qª„T éOئ=ƒ iš„è´—¾¸É¥5KãÌv`ÕÄÿ¾;;¡!S`ŒRA8Ûç»ï¾û.?{CˆègããMïlދˆŒ¿ô Ž.#8 Ç0OaÁìÝ0œÍŽaž¸]ÌãAßl7V,ûP}¸ÈãL™¯€––*ZÎ0ÜŸßö"†t*ôm’‹ 6NÍ·&˜›CøfR¥ÁVVcu[ø aœ¶¼‰%m±­üpƒd q&Œµ0P”áNj[Š 6h×*1-'Ka0“fçä ý*^¨\qtísÆ*-V¹ÐåÞPY (‘oûO(sv–Ô´b–ª .Ê£Ë)0r)T‡`4®ê0À¼Ü°ß£ËIµ—'Œñ-¡Vª¼òѬe0…ã1U–Šñ¤|¥È8s»FàÀ%aÊ¢È$&‹ýrÿ‰À³ +ëâ»êÒs¬Ð…¥;ù(¥Å€îDVzF?m׺óÒè "|M ꨸/þÜâ 5POÄk¡Ûdr®vç¸ ©jÎêk·’w˜·O¥(,õÅ{¹Ù”®Iût!·ŽU óDÆÂ"hI òlëiÖÁC.‹)DŒdNT÷ðìç'OûN uC‚êt/tÒü)ב×yì§J‚ô÷íòꜵÒþAÍ·œ°:wsŒÍ”b¿ÌIÒû‡Ð÷S‘Ÿœ—þ ‰ÊÜ ¶)žs9üòÞ \…ñ—Øž×á½V¢=¿10LFEúâéÖĸM‚+1‰W8²V>kX˜Ü%¾òÚ„ 5g¯EQ¸G´qø VÌUQ½BhšùVcÝ`'ÕtE“p:žÂìxÆ£óæûÕç`FðIÅ4msëÆ-û§9íwÇþ•g…Ã|.%áL=²»¸5 Ÿ™F³p<¢×2ò|<²ébÞ»îýOZ¬ïendstream endobj 6178 0 obj<>/XObject<<>>>>>>endobj 6179 0 obj<>stream xÍUÛŽÓ0}ÏWŒ*!uœÍ¥M‹xãÒB ÐFâe_²ñtkHâ`»”ñïø’´i‹ ¬„DUÑÌx|æxæøKC¤1¤™yË:xžQiãþO<Àõ*‚e˜B¾†$‚ìifÙrj£"ÈË餿t[áú‡À[k€¦¨ñ*ÿ\¯æëÐ5‚$iŸbŠß6Ô…Ìú0Óù§Oœ(X*öC8†C’$LS ŽN'f·=€3:±¡#eW«â~Kà¶«ïyÚX!ð5`SV\"YòvØ×SCѶUç+Á:¡-”BÑÀ÷á«bRÁßÔÓ¯`j”|+JrØÕÿ¨¦²ÂBøj²Î…©äÙåsY3!Õ‹ «¨-…À{G‡Åa´“‡_¦ÏbKû>:o’ÞýÈ.!°b}z`ó3 _`ã*õ!­[.”6f½ÿN7®>œÎûhœïôšR„ñFÎT×b]´>0½ûÑÔ¨6Üõ™#¹KÎnédnJNGªqXaì'¡Ÿw…x‡y|ƒÝŽ Úº­±Qî¦l EÓÝ]™‚üí4ÀêG\ºò/S¤•È+3g4ÁŽ© ˜%¶†c ‹æßv,KÂä%u:§_°ì¯€x9 çé²L_‹Â8›-£h¦-„Ô}¦–ëy”…i¢/?},晡ÿU|~£é@endstream endobj 6180 0 obj<>/XObject<<>>>>>>endobj 6181 0 obj<>stream xTÛnÓ@}÷WYŠäJñÆ—\¡%(B Œà¡/Ûõ:^ä»›”ñïÌÚNÓ"JI¢dlÏœ9çÌl¾{1"zÇH—î#jïuæE,¢›_zÙv8BVPîrCAÞ?§@öÔÉšwÊÊú*ûæÍ¶ó‡Ô0™Sj0SÐqk¥n>™ã^ÙÞuÕiЉ¨$×ô;æ²+š¥®o!L–¦t•þˆä£…Èç¸ 8Åš×’¢RÆÞ^9DBq:z]›±xŒ0V™‘ÂYyØSHÙr¹rާù—`ƒ\i)¬:ÊÅ<¥òŽè¢- è›õ(¢mŽ¢Íå !Ä5Ÿ/•(¡eWq! l)‘Ë‚* ÁU Í®Rj£Ú†Â\"ž‘)¸‰=£sxÿ«Ÿ`Œáuùn üÕ çìˆ÷tÿÚŸÂß¶ÚjÞP(­A6ˆçŒ–© -p›°fÑ0†yÄâÛƒ&©7ò(«¶«ec±kŠV×=“¿Ðgëµ›bFUÊ òV\y_~äªâw•yåÌT³ƒWÆÍçÓ—ÝÛ)^}Øáª&'îû½ó[]x0d%õRýÞ¸I&Žƒ)U×σä’¾Ù@›N'ml঳^àS9Á¸g­>f­ÇŠ$š³Eº@²‰YÒËuèaÊ"ÖE¦Ã#[‡äp5ÿ6v-YšÐIY-VìMæ}ô~4<>Ñendstream endobj 6182 0 obj<>endobj 6183 0 obj<>endobj 6184 0 obj<>endobj 6185 0 obj<>endobj 6186 0 obj<>endobj 6187 0 obj<>endobj 6188 0 obj<>endobj 6189 0 obj<>endobj 6190 0 obj<>endobj 6191 0 obj<>endobj 6192 0 obj<>endobj 6193 0 obj<>endobj 6194 0 obj<>endobj 6195 0 obj<>endobj 6196 0 obj<>endobj 6197 0 obj<>endobj 6198 0 obj<>endobj 6199 0 obj<>endobj 6200 0 obj<>endobj 6201 0 obj<>endobj 6202 0 obj<>endobj 6203 0 obj<>endobj 6204 0 obj<>endobj 6205 0 obj<>endobj 6206 0 obj<>endobj 6207 0 obj<>endobj 6208 0 obj<>endobj 6209 0 obj<>endobj 6210 0 obj<>endobj 6211 0 obj<>endobj 6212 0 obj<>endobj 6213 0 obj<>endobj 6214 0 obj<>endobj 6215 0 obj<>endobj 6216 0 obj<>endobj 6217 0 obj<>endobj 6218 0 obj<>endobj 6219 0 obj<>endobj 6220 0 obj<>endobj 6221 0 obj<>endobj 6222 0 obj<>endobj 6223 0 obj<>endobj 6224 0 obj<>endobj 6225 0 obj<>endobj 6226 0 obj<>endobj 6227 0 obj<>endobj 6228 0 obj<>endobj 6229 0 obj<>endobj 6230 0 obj<>endobj 6231 0 obj<>endobj 6232 0 obj<>endobj 6233 0 obj<>endobj 6234 0 obj<>endobj 6235 0 obj<>endobj 6236 0 obj<>endobj 6237 0 obj<>endobj 6238 0 obj<>endobj 6239 0 obj<>endobj 6240 0 obj<>endobj 6241 0 obj<>endobj 6242 0 obj<>endobj 6243 0 obj<>endobj 6244 0 obj<>endobj 6245 0 obj<>endobj 6246 0 obj<>endobj 6247 0 obj<>endobj 6248 0 obj<>endobj 6249 0 obj<>endobj 6250 0 obj<>endobj 6251 0 obj<>endobj 6252 0 obj<>endobj 6253 0 obj<>endobj 6254 0 obj<>endobj 6255 0 obj<>endobj 6256 0 obj<>endobj 6257 0 obj<>endobj 6258 0 obj<>endobj 6259 0 obj<>endobj 6260 0 obj<>endobj 6261 0 obj<>endobj 6262 0 obj<>endobj 6263 0 obj<>endobj 6264 0 obj<>endobj 6265 0 obj<>endobj 6266 0 obj<>endobj 6267 0 obj<>endobj 6268 0 obj<>endobj 6269 0 obj<>endobj 6270 0 obj<>endobj 6271 0 obj<>endobj 6272 0 obj<>endobj 6273 0 obj<>endobj 6274 0 obj<>endobj 6275 0 obj<>endobj 6276 0 obj<>endobj 6277 0 obj<>endobj 6278 0 obj<>endobj 6279 0 obj<>endobj 6280 0 obj<>endobj 6281 0 obj<>endobj 6282 0 obj<>endobj 6283 0 obj<>endobj 6284 0 obj<>endobj 6285 0 obj<>endobj 6286 0 obj<>endobj 6287 0 obj<>endobj 6288 0 obj<>endobj 6289 0 obj<>endobj 6290 0 obj<>endobj 6291 0 obj<>endobj 6292 0 obj<>endobj 6293 0 obj<>endobj 6294 0 obj<>endobj 6295 0 obj<>endobj 6296 0 obj<>endobj 6297 0 obj<>endobj 6298 0 obj<>endobj 6299 0 obj<>endobj 6300 0 obj<>endobj 6301 0 obj<>endobj 6302 0 obj<>endobj 6303 0 obj<>endobj 6304 0 obj<>endobj 6305 0 obj<>endobj 6306 0 obj<>endobj 6307 0 obj<>endobj 6308 0 obj<>endobj 6309 0 obj<>endobj 6310 0 obj<>endobj 6311 0 obj<>endobj 6312 0 obj<>endobj 6313 0 obj<>endobj 6314 0 obj<>endobj 6315 0 obj<>endobj 6316 0 obj<>endobj 6317 0 obj<>endobj 6318 0 obj<>endobj 6319 0 obj<>endobj 6320 0 obj<>endobj 6321 0 obj<>endobj 6322 0 obj<>endobj 6323 0 obj<>endobj 6324 0 obj<>endobj 6325 0 obj<>endobj 6326 0 obj<>endobj 6327 0 obj<>endobj 6328 0 obj<>endobj 6329 0 obj<>endobj 6330 0 obj<>endobj 6331 0 obj<>endobj 6332 0 obj<>endobj 6333 0 obj<>endobj 6334 0 obj<>endobj 6335 0 obj<>endobj 6336 0 obj<>endobj 6337 0 obj<>endobj 6338 0 obj<>endobj 6339 0 obj<>endobj 6340 0 obj<>endobj 6341 0 obj<>endobj 6342 0 obj<>endobj 6343 0 obj<>endobj 6344 0 obj<>endobj 6345 0 obj<>endobj 6346 0 obj<\(\))/Dest[4868 0 R/XYZ 0 514 0]/Prev 6345 0 R/Next 6347 0 R>>endobj 6347 0 obj<>endobj 6348 0 obj<>endobj 6349 0 obj<>endobj 6350 0 obj<>endobj 6351 0 obj<>endobj 6352 0 obj<>endobj 6353 0 obj<>endobj 6354 0 obj<>endobj 6355 0 obj<>endobj 6356 0 obj<>endobj 6357 0 obj<>endobj 6358 0 obj<>endobj 6359 0 obj<>endobj 6360 0 obj<>endobj 6361 0 obj<>endobj 6362 0 obj<>endobj 6363 0 obj<>endobj 6364 0 obj<>endobj 6365 0 obj<>endobj 6366 0 obj<>endobj 6367 0 obj<>endobj 6368 0 obj<>endobj 6369 0 obj<>endobj 6370 0 obj<>endobj 6371 0 obj<>endobj 6372 0 obj<>endobj 6373 0 obj<>endobj 6374 0 obj<>endobj 6375 0 obj<>endobj 6376 0 obj<>endobj 6377 0 obj<>endobj 6378 0 obj<>endobj 6379 0 obj<>endobj 6380 0 obj<>endobj 6381 0 obj<>endobj 6382 0 obj<>endobj 6383 0 obj<>endobj 6384 0 obj<>endobj 6385 0 obj<>endobj 6386 0 obj<>endobj 6387 0 obj<>endobj 6388 0 obj<>endobj 6389 0 obj<>endobj 6390 0 obj<>endobj 6391 0 obj<>endobj 6392 0 obj<>endobj 6393 0 obj<>endobj 6394 0 obj<>endobj 6395 0 obj<>endobj 6396 0 obj<>endobj 6397 0 obj<>endobj 6398 0 obj<>endobj 6399 0 obj<>endobj 6400 0 obj<>endobj 6401 0 obj<>endobj 6402 0 obj<>endobj 6403 0 obj<>endobj 6404 0 obj<>endobj 6405 0 obj<>endobj 6406 0 obj<>endobj 6407 0 obj<>endobj 6408 0 obj<>endobj 6409 0 obj<>endobj 6410 0 obj<>endobj 6411 0 obj<>endobj 6412 0 obj<>endobj 6413 0 obj<>endobj 6414 0 obj<>endobj 6415 0 obj<>endobj 6416 0 obj<>endobj 6417 0 obj<>endobj 6418 0 obj<>endobj 6419 0 obj<>endobj 6420 0 obj<>endobj 6421 0 obj<>endobj 6422 0 obj<>endobj 6423 0 obj<>endobj 6424 0 obj<>endobj 6425 0 obj<>endobj 6426 0 obj<>endobj 6427 0 obj<>endobj 6428 0 obj<>endobj 6429 0 obj<>endobj 6430 0 obj<>endobj 6431 0 obj<>endobj 6432 0 obj<>endobj 6433 0 obj<>endobj 6434 0 obj<>endobj 6435 0 obj<>endobj 6436 0 obj<>endobj 6437 0 obj<>endobj 6438 0 obj<>endobj 6439 0 obj<>endobj 6440 0 obj<>endobj 6441 0 obj<>endobj 6442 0 obj<>endobj 6443 0 obj<>endobj 6444 0 obj<>endobj 6445 0 obj<>endobj 6446 0 obj<>endobj 6447 0 obj<>endobj 6448 0 obj<>endobj 6449 0 obj<>endobj 6450 0 obj<>endobj 6451 0 obj<>endobj 6452 0 obj<>endobj 6453 0 obj<>endobj 6454 0 obj<>endobj 6455 0 obj<>endobj 6456 0 obj<>endobj 6457 0 obj<>endobj 6458 0 obj<>endobj 6459 0 obj<>endobj 6460 0 obj<>endobj 6461 0 obj<>endobj 6462 0 obj<>endobj 6463 0 obj<>endobj 6464 0 obj<>endobj 6465 0 obj<>endobj 6466 0 obj<>endobj 6467 0 obj<>endobj 6468 0 obj<>endobj 6469 0 obj<>endobj 6470 0 obj<>endobj 6471 0 obj<>endobj 6472 0 obj<>endobj 6473 0 obj<>endobj 6474 0 obj<>endobj 6475 0 obj<>endobj 6476 0 obj<>endobj 6477 0 obj<>endobj 6478 0 obj<>endobj 6479 0 obj<>endobj 6480 0 obj<>endobj 6481 0 obj<>endobj 6482 0 obj<>endobj 6483 0 obj<>endobj 6484 0 obj<>endobj 6485 0 obj<>endobj 6486 0 obj<>endobj 6487 0 obj<>endobj 6488 0 obj<>endobj 6489 0 obj<>endobj 6490 0 obj<>endobj 6491 0 obj<>endobj 6492 0 obj<>endobj 6493 0 obj<>endobj 6494 0 obj<>endobj 6495 0 obj<>endobj 6496 0 obj<>endobj 6497 0 obj<>endobj 6498 0 obj<>endobj 6499 0 obj<>endobj 6500 0 obj<>endobj 6501 0 obj<>endobj 6502 0 obj<>endobj 6503 0 obj<>endobj 6504 0 obj<>endobj 6505 0 obj<>endobj 6506 0 obj<>endobj 6507 0 obj<>endobj 6508 0 obj<>endobj 6509 0 obj<>endobj 6510 0 obj<>endobj 6511 0 obj<>endobj 6512 0 obj<>endobj 6513 0 obj<>endobj 6514 0 obj<>endobj 6515 0 obj<>endobj 6516 0 obj<>endobj 6517 0 obj<>endobj 6518 0 obj<>endobj 6519 0 obj<>endobj 6520 0 obj<>endobj 6521 0 obj<>endobj 6522 0 obj<>endobj 6523 0 obj<>endobj 6524 0 obj<>endobj 6525 0 obj<>endobj 6526 0 obj<>endobj 6527 0 obj<>endobj 6528 0 obj<>endobj 6529 0 obj<>endobj 6530 0 obj<>endobj 6531 0 obj<>endobj 6532 0 obj<>endobj 6533 0 obj<>endobj 6534 0 obj<>endobj 6535 0 obj<>endobj 6536 0 obj<>endobj 6537 0 obj<>endobj 6538 0 obj<>endobj 6539 0 obj<>endobj 6540 0 obj<>endobj 6541 0 obj<>endobj 6542 0 obj<>endobj 6543 0 obj<>endobj 6544 0 obj<>endobj 6545 0 obj<>endobj 6546 0 obj<>endobj 6547 0 obj<>endobj 6548 0 obj<>endobj 6549 0 obj<>endobj 6550 0 obj<>endobj 6551 0 obj<>endobj 6552 0 obj<>endobj 6553 0 obj<>endobj 6554 0 obj<>endobj 6555 0 obj<>endobj 6556 0 obj<>endobj 6557 0 obj<>endobj 6558 0 obj<>endobj 6559 0 obj<>endobj 6560 0 obj<>endobj 6561 0 obj<>endobj 6562 0 obj<>endobj 6563 0 obj<>endobj 6564 0 obj<>endobj 6565 0 obj<>endobj 6566 0 obj<>endobj 6567 0 obj<>endobj 6568 0 obj<>endobj 6569 0 obj<>endobj 6570 0 obj<>endobj 6571 0 obj<>endobj 6572 0 obj<>endobj 6573 0 obj<>endobj 6574 0 obj<>endobj 6575 0 obj<>endobj 6576 0 obj<>endobj 6577 0 obj<>endobj 6578 0 obj<>endobj 6579 0 obj<>endobj 6580 0 obj<>endobj 6581 0 obj<>endobj 6582 0 obj<>endobj 6583 0 obj<>endobj 6584 0 obj<>endobj 6585 0 obj<>endobj 6586 0 obj<>endobj 6587 0 obj<>endobj 6588 0 obj<>endobj 6589 0 obj<>endobj 6590 0 obj<>endobj 6591 0 obj<>endobj 6592 0 obj<>endobj 6593 0 obj<>endobj 6594 0 obj<>endobj 6595 0 obj<>endobj 6596 0 obj<>endobj 6597 0 obj<>endobj 6598 0 obj<>endobj 6599 0 obj<>endobj 6600 0 obj<>endobj 6601 0 obj<>endobj 6602 0 obj<>endobj 6603 0 obj<>endobj 6604 0 obj<>endobj 6605 0 obj<>endobj 6606 0 obj<>endobj 6607 0 obj<>endobj 6608 0 obj<>endobj 6609 0 obj<>endobj 6610 0 obj<>endobj 6611 0 obj<>endobj 6612 0 obj<>endobj 6613 0 obj<>endobj 6614 0 obj<>endobj 6615 0 obj<>endobj 6616 0 obj<>endobj 6617 0 obj<>endobj 6618 0 obj<>endobj 6619 0 obj<>endobj 6620 0 obj<>endobj 6621 0 obj<>endobj 6622 0 obj<>endobj 6623 0 obj<>endobj 6624 0 obj<>endobj 6625 0 obj<>endobj 6626 0 obj<>endobj 6627 0 obj<>endobj 6628 0 obj<>endobj 6629 0 obj<>endobj 6630 0 obj<>endobj 6631 0 obj<>endobj 6632 0 obj<>endobj 6633 0 obj<>endobj 6634 0 obj<>endobj 6635 0 obj<>endobj 6636 0 obj<>endobj 6637 0 obj<>endobj 6638 0 obj<>endobj 6639 0 obj<>endobj 6640 0 obj<>endobj 6641 0 obj<>endobj 6642 0 obj<>endobj 6643 0 obj<>endobj 6644 0 obj<>endobj 6645 0 obj<>endobj 6646 0 obj<>endobj 6647 0 obj<>endobj 6648 0 obj<>endobj 6649 0 obj<>endobj 6650 0 obj<>endobj 6651 0 obj<>endobj 6652 0 obj<>endobj 6653 0 obj<>endobj 6654 0 obj<>endobj 6655 0 obj<>endobj 6656 0 obj<>endobj 6657 0 obj<>endobj 6658 0 obj<>endobj 6659 0 obj<>endobj 6660 0 obj<>endobj 6661 0 obj<>endobj 6662 0 obj<>endobj 6663 0 obj<>endobj 6664 0 obj<>endobj 6665 0 obj<>endobj 6666 0 obj<>endobj 6667 0 obj<>endobj 6668 0 obj<>endobj 6669 0 obj<>endobj 6670 0 obj<>endobj 6671 0 obj<>endobj 6672 0 obj<>endobj 6673 0 obj<>endobj 6674 0 obj<>endobj 6675 0 obj<>endobj 6676 0 obj<>endobj 6677 0 obj<>endobj 6678 0 obj<>endobj 6679 0 obj<>endobj 6680 0 obj<>endobj 6681 0 obj<>endobj 6682 0 obj<>endobj 6683 0 obj<>endobj 6684 0 obj<>endobj 6685 0 obj<>endobj 6686 0 obj<>endobj 6687 0 obj<>endobj 6688 0 obj<>endobj 6689 0 obj< D name comparison)/Dest[5302 0 R/XYZ 0 550 0]/Next 6690 0 R>>endobj 6690 0 obj<>endobj 6691 0 obj<>endobj 6692 0 obj<>endobj 6693 0 obj<>endobj 6694 0 obj<>endobj 6695 0 obj<>endobj 6696 0 obj<>endobj 6697 0 obj<>endobj 6698 0 obj<>endobj 6699 0 obj<>endobj 6700 0 obj<>endobj 6701 0 obj<>endobj 6702 0 obj<>endobj 6703 0 obj<>endobj 6704 0 obj<>endobj 6705 0 obj<>endobj 6706 0 obj<>endobj 6707 0 obj<>endobj 6708 0 obj<>endobj 6709 0 obj<>endobj 6710 0 obj<>endobj 6711 0 obj<>endobj 6712 0 obj<>endobj 6713 0 obj<>endobj 6714 0 obj<>endobj 6715 0 obj<>endobj 6716 0 obj<>endobj 6717 0 obj<>endobj 6718 0 obj<>endobj 6719 0 obj<>endobj 6720 0 obj<>endobj 6721 0 obj<>endobj 6722 0 obj<>endobj 6723 0 obj<>endobj 6724 0 obj<>endobj 6725 0 obj<>endobj 6726 0 obj<>endobj 6727 0 obj<>endobj 6728 0 obj<>endobj 6729 0 obj<>endobj 6730 0 obj<>endobj 6731 0 obj<>endobj 6732 0 obj<>endobj 6733 0 obj<>endobj 6734 0 obj<>endobj 6735 0 obj<>endobj 6736 0 obj<>endobj 6737 0 obj<>endobj 6738 0 obj<>endobj 6739 0 obj<>endobj 6740 0 obj<>endobj 6741 0 obj<>endobj 6742 0 obj<>endobj 6743 0 obj<>endobj 6744 0 obj<>endobj 6745 0 obj<>endobj 6746 0 obj<>endobj 6747 0 obj<>endobj 6748 0 obj<>endobj 6749 0 obj<>endobj 6750 0 obj<>endobj 6751 0 obj<>endobj 6752 0 obj<>endobj 6753 0 obj<>endobj 6754 0 obj<>endobj 6755 0 obj<>endobj 6756 0 obj<>endobj 6757 0 obj<>endobj 6758 0 obj<>endobj 6759 0 obj<>endobj 6760 0 obj<>endobj 6761 0 obj<>endobj 6762 0 obj<>endobj 6763 0 obj<>endobj 6764 0 obj<>endobj 6765 0 obj<>endobj 6766 0 obj<>endobj 6767 0 obj<>endobj 6768 0 obj<>endobj 6769 0 obj<>endobj 6770 0 obj<>endobj 6771 0 obj<>endobj 6772 0 obj<>endobj 6773 0 obj<>endobj 6774 0 obj<>endobj 6775 0 obj<>endobj 6776 0 obj<>endobj 6777 0 obj<>endobj 6778 0 obj<>endobj 6779 0 obj<>endobj 6780 0 obj<>endobj 6781 0 obj<>endobj 6782 0 obj<>endobj 6783 0 obj<>endobj 6784 0 obj<>endobj 6785 0 obj<>endobj 6786 0 obj<>endobj 6787 0 obj<>endobj 6788 0 obj<>endobj 6789 0 obj<>endobj 6790 0 obj<>endobj 6791 0 obj<>endobj 6792 0 obj<>endobj 6793 0 obj<>endobj 6794 0 obj<>endobj 6795 0 obj<>endobj 6796 0 obj<>endobj 6797 0 obj<>endobj 6798 0 obj<>endobj 6799 0 obj<>endobj 6800 0 obj<>endobj 6801 0 obj<>endobj 6802 0 obj<>endobj 6803 0 obj<>endobj 6804 0 obj<>endobj 6805 0 obj<>endobj 6806 0 obj<>endobj 6807 0 obj<>endobj 6808 0 obj<>endobj 6809 0 obj<>endobj 6810 0 obj<>endobj 6811 0 obj<>endobj 6812 0 obj<>endobj 6813 0 obj<>endobj 6814 0 obj<>endobj 6815 0 obj<>endobj 6816 0 obj<>endobj 6817 0 obj<>endobj 6818 0 obj<>endobj 6819 0 obj<>endobj 6820 0 obj<>endobj 6821 0 obj<>endobj 6822 0 obj<>endobj 6823 0 obj<>endobj 6824 0 obj<>endobj 6825 0 obj<>endobj 6826 0 obj<>endobj 6827 0 obj<>endobj 6828 0 obj<>endobj 6829 0 obj<>endobj 6830 0 obj<>endobj 6831 0 obj<>endobj 6832 0 obj<>endobj 6833 0 obj<>endobj 6834 0 obj<>endobj 6835 0 obj<>endobj 6836 0 obj<>endobj 6837 0 obj<>endobj 6838 0 obj<>endobj 6839 0 obj<>endobj 6840 0 obj<>endobj 6841 0 obj<>endobj 6842 0 obj<>endobj 6843 0 obj<>endobj 6844 0 obj<>endobj 6845 0 obj<>endobj 6846 0 obj<>endobj 6847 0 obj<>endobj 6848 0 obj<>endobj 6849 0 obj<>endobj 6850 0 obj<>endobj 6851 0 obj<>endobj 6852 0 obj<>endobj 6853 0 obj<>endobj 6854 0 obj<>endobj 6855 0 obj<>endobj 6856 0 obj<>endobj 6857 0 obj<>endobj 6858 0 obj<>endobj 6859 0 obj<>endobj 6860 0 obj<>endobj 6861 0 obj<>endobj 6862 0 obj<>endobj 6863 0 obj<>endobj 6864 0 obj<>endobj 6865 0 obj<>endobj 6866 0 obj<>endobj 6867 0 obj<>endobj 6868 0 obj<>endobj 6869 0 obj<>endobj 6870 0 obj<>endobj 6871 0 obj<>endobj 6872 0 obj<>endobj 6873 0 obj<>endobj 6874 0 obj<>endobj 6875 0 obj<>endobj 6876 0 obj<>endobj 6877 0 obj<>endobj 6878 0 obj<>endobj 6879 0 obj<>endobj 6880 0 obj<>endobj 6881 0 obj<>endobj 6882 0 obj<>endobj 6883 0 obj<>endobj 6884 0 obj<>endobj 6885 0 obj<>endobj 6886 0 obj<>endobj 6887 0 obj<>endobj 6888 0 obj<>endobj 6889 0 obj<>endobj 6890 0 obj<>endobj 6891 0 obj<>endobj 6892 0 obj<>endobj 6893 0 obj<>endobj 6894 0 obj<>endobj 6895 0 obj<>endobj 6896 0 obj<>endobj 6897 0 obj<>endobj 6898 0 obj<>endobj 6899 0 obj<>endobj 6900 0 obj<>endobj 6901 0 obj<>endobj 6902 0 obj<>endobj 6903 0 obj<>endobj 6904 0 obj<>endobj 6905 0 obj<>endobj 6906 0 obj<>endobj 6907 0 obj<>endobj 6908 0 obj<>endobj 6909 0 obj<>endobj 6910 0 obj<>endobj 6911 0 obj<>endobj 6912 0 obj<>endobj 6913 0 obj<>endobj 6914 0 obj<>endobj 6915 0 obj<>endobj 6916 0 obj<>endobj 6917 0 obj<>endobj 6918 0 obj<>endobj 6919 0 obj<>endobj 6920 0 obj<>endobj 6921 0 obj<>endobj 6922 0 obj<>endobj 6923 0 obj<>endobj 6924 0 obj<>endobj 6925 0 obj<>endobj 6926 0 obj<>endobj 6927 0 obj<>endobj 6928 0 obj<>endobj 6929 0 obj<>endobj 6930 0 obj<>endobj 6931 0 obj<>endobj 6932 0 obj<>endobj 6933 0 obj<>endobj 6934 0 obj<>endobj 6935 0 obj<>endobj 6936 0 obj<>endobj 6937 0 obj<>endobj 6938 0 obj<>endobj 6939 0 obj<>endobj 6940 0 obj<>endobj 6941 0 obj<>endobj 6942 0 obj<>endobj 6943 0 obj<>endobj 6944 0 obj<>endobj 6945 0 obj<>endobj 6946 0 obj<>endobj 6947 0 obj<>endobj 6948 0 obj<>endobj 6949 0 obj<>endobj 6950 0 obj<>endobj 6951 0 obj<>endobj 6952 0 obj<>endobj 6953 0 obj<>endobj 6954 0 obj<>endobj 6955 0 obj<>endobj 6956 0 obj<>endobj 6957 0 obj<>endobj 6958 0 obj<>endobj 6959 0 obj<>endobj 6960 0 obj<>endobj 6961 0 obj<>endobj 6962 0 obj<>endobj 6963 0 obj<>endobj 6964 0 obj<>endobj 6965 0 obj<>endobj 6966 0 obj<>endobj 6967 0 obj<>endobj 6968 0 obj<>endobj 6969 0 obj<>endobj 6970 0 obj<>endobj 6971 0 obj<>endobj 6972 0 obj<>endobj 6973 0 obj<>endobj 6974 0 obj<>endobj 6975 0 obj<>endobj 6976 0 obj<>endobj 6977 0 obj<>endobj 6978 0 obj<>endobj 6979 0 obj<>endobj 6980 0 obj<>endobj 6981 0 obj<>endobj 6982 0 obj<>endobj 6983 0 obj<>endobj 6984 0 obj<>endobj 6985 0 obj<>endobj 6986 0 obj<>endobj 6987 0 obj<>endobj 6988 0 obj<>endobj 6989 0 obj<>endobj 6990 0 obj<>endobj 6991 0 obj<>endobj 6992 0 obj<>endobj 6993 0 obj<>endobj 6994 0 obj<>endobj 6995 0 obj<>endobj 6996 0 obj<>endobj 6997 0 obj<>endobj 6998 0 obj<>endobj 6999 0 obj<>endobj 7000 0 obj<>endobj 7001 0 obj<>endobj 7002 0 obj<>endobj 7003 0 obj<>endobj 7004 0 obj<>endobj 7005 0 obj<>endobj 7006 0 obj<>endobj 7007 0 obj<>endobj 7008 0 obj<>endobj 7009 0 obj<>endobj 7010 0 obj<>endobj 7011 0 obj<>endobj 7012 0 obj<>endobj 7013 0 obj<>endobj 7014 0 obj<>endobj 7015 0 obj<>endobj 7016 0 obj<>endobj 7017 0 obj<>endobj 7018 0 obj<>endobj 7019 0 obj<>endobj 7020 0 obj<>endobj 7021 0 obj<>endobj 7022 0 obj<>endobj 7023 0 obj<>endobj 7024 0 obj<>endobj 7025 0 obj<>endobj 7026 0 obj<>endobj 7027 0 obj<>endobj 7028 0 obj<>endobj 7029 0 obj<>endobj 7030 0 obj<>endobj 7031 0 obj<>endobj 7032 0 obj<>endobj 7033 0 obj<>endobj 7034 0 obj<>endobj 7035 0 obj<>endobj 7036 0 obj<>endobj 7037 0 obj<>endobj 7038 0 obj<>endobj 7039 0 obj<>endobj 7040 0 obj<>endobj 7041 0 obj<>endobj 7042 0 obj<>endobj 7043 0 obj<>endobj 7044 0 obj<>endobj 7045 0 obj<>endobj 7046 0 obj<>endobj 7047 0 obj<>endobj 7048 0 obj<>endobj 7049 0 obj<>endobj 7050 0 obj<>endobj 7051 0 obj<>endobj 7052 0 obj<>endobj 7053 0 obj<>endobj 7054 0 obj<>endobj 7055 0 obj<>endobj 7056 0 obj<>endobj 7057 0 obj<>endobj 7058 0 obj<>endobj 7059 0 obj<>endobj 7060 0 obj<>endobj 7061 0 obj<>endobj 7062 0 obj<>endobj 7063 0 obj<>endobj 7064 0 obj<>endobj 7065 0 obj<>endobj 7066 0 obj<>endobj 7067 0 obj<>endobj 7068 0 obj<>endobj 7069 0 obj<>endobj 7070 0 obj<>endobj 7071 0 obj<>endobj 7072 0 obj<>endobj 7073 0 obj<>endobj 7074 0 obj<>endobj 7075 0 obj<>endobj 7076 0 obj<>endobj 7077 0 obj<>endobj 7078 0 obj<>endobj 7079 0 obj<>endobj 7080 0 obj<>endobj 7081 0 obj<>endobj 7082 0 obj<>endobj 7083 0 obj<>endobj 7084 0 obj<>endobj 7085 0 obj<>endobj 7086 0 obj<>endobj 7087 0 obj<>endobj 7088 0 obj<>endobj 7089 0 obj<>endobj 7090 0 obj<>endobj 7091 0 obj<>endobj 7092 0 obj<>endobj 7093 0 obj<>endobj 7094 0 obj<>endobj 7095 0 obj<>endobj 7096 0 obj<>endobj 7097 0 obj<>endobj 7098 0 obj<>endobj 7099 0 obj<>endobj 7100 0 obj<>endobj 7101 0 obj<>endobj 7102 0 obj<>endobj 7103 0 obj<>endobj 7104 0 obj<>endobj 7105 0 obj<>endobj 7106 0 obj<>endobj 7107 0 obj<>endobj 7108 0 obj<>endobj 7109 0 obj<>endobj 7110 0 obj<>endobj 7111 0 obj<>endobj 7112 0 obj<>endobj 7113 0 obj<>endobj 7114 0 obj<>endobj 7115 0 obj<>endobj 7116 0 obj<>endobj 7117 0 obj<>endobj 7118 0 obj<>endobj 7119 0 obj<>endobj 7120 0 obj<>endobj 7121 0 obj<>endobj 7122 0 obj<>endobj 7123 0 obj<>endobj 7124 0 obj<>endobj 7125 0 obj<>endobj 7126 0 obj<>endobj 7127 0 obj<>endobj 7128 0 obj<>endobj 7129 0 obj<>endobj 7130 0 obj<>endobj 7131 0 obj<>endobj 7132 0 obj<>endobj 7133 0 obj<>endobj 7134 0 obj<>endobj 7135 0 obj<>endobj 7136 0 obj<>endobj 7137 0 obj<>endobj 7138 0 obj<>endobj 7139 0 obj<>endobj 7140 0 obj<>endobj 7141 0 obj<>endobj 7142 0 obj<>endobj 7143 0 obj<>endobj 7144 0 obj<>endobj 7145 0 obj<>endobj 7146 0 obj<>endobj 7147 0 obj<>endobj 7148 0 obj<>endobj 7149 0 obj<>endobj 7150 0 obj<>endobj 7151 0 obj<>endobj 7152 0 obj<>endobj 7153 0 obj<>endobj 7154 0 obj<>endobj 7155 0 obj<>endobj 7156 0 obj<>endobj 7157 0 obj<>endobj 7158 0 obj<>endobj 7159 0 obj<>endobj 7160 0 obj<>endobj 7161 0 obj<>endobj 7162 0 obj<>endobj 7163 0 obj<>endobj 7164 0 obj<>endobj 7165 0 obj<>endobj 7166 0 obj<>endobj 7167 0 obj<>endobj 7168 0 obj<>endobj 7169 0 obj<>endobj 7170 0 obj<>endobj 7171 0 obj<>endobj 7172 0 obj<>endobj 7173 0 obj<>endobj 7174 0 obj<>endobj 7175 0 obj<>endobj 7176 0 obj<>endobj 7177 0 obj<>endobj 7178 0 obj<>endobj 7179 0 obj<>endobj 7180 0 obj<>endobj 7181 0 obj<>endobj 7182 0 obj<>endobj 7183 0 obj<>endobj 7184 0 obj<>endobj 7185 0 obj<>endobj 7186 0 obj<>endobj 7187 0 obj<>endobj 7188 0 obj<>endobj 7189 0 obj<>endobj 7190 0 obj<>endobj 7191 0 obj<>endobj 7192 0 obj<>endobj 7193 0 obj<>endobj 7194 0 obj<>endobj 7195 0 obj<>endobj 7196 0 obj<>endobj 7197 0 obj<>endobj 7198 0 obj<>endobj 7199 0 obj<>endobj 7200 0 obj<>endobj 7201 0 obj<>endobj 7202 0 obj<>endobj 7203 0 obj<>endobj 7204 0 obj<>endobj 7205 0 obj<>endobj 7206 0 obj<>endobj 7207 0 obj<>endobj 7208 0 obj<>endobj 7209 0 obj<>endobj 7210 0 obj<>endobj 7211 0 obj<>endobj 7212 0 obj<>endobj 7213 0 obj<>endobj 7214 0 obj<>endobj 7215 0 obj<>endobj 7216 0 obj<>endobj 7217 0 obj<>endobj 7218 0 obj<>endobj 7219 0 obj<>endobj 7220 0 obj<>endobj 7221 0 obj<>endobj 7222 0 obj<>endobj 7223 0 obj<>endobj 7224 0 obj<>endobj 7225 0 obj<>endobj 7226 0 obj<>endobj 7227 0 obj<>endobj 7228 0 obj<>endobj 7229 0 obj<>endobj 7230 0 obj<>endobj 7231 0 obj<>endobj 7232 0 obj<>endobj 7233 0 obj<>endobj 7234 0 obj<>endobj 7235 0 obj<>endobj 7236 0 obj<>endobj 7237 0 obj<>endobj 7238 0 obj<>endobj 7239 0 obj<>endobj 7240 0 obj<>endobj 7241 0 obj<>endobj 7242 0 obj<>endobj 7243 0 obj<>endobj 7244 0 obj<>endobj 7245 0 obj<>endobj 7246 0 obj<>endobj 7247 0 obj<>endobj 7248 0 obj<>endobj 7249 0 obj<>endobj 7250 0 obj<>endobj 7251 0 obj<>endobj 7252 0 obj<>endobj 7253 0 obj<>endobj 7254 0 obj<>endobj 7255 0 obj<>endobj 7256 0 obj<>endobj 7257 0 obj<>endobj 7258 0 obj<>endobj 7259 0 obj<>endobj 7260 0 obj<>endobj 7261 0 obj<>endobj 7262 0 obj<>endobj 7263 0 obj<>endobj 7264 0 obj<>endobj 7265 0 obj<>endobj 7266 0 obj<>endobj 7267 0 obj<>endobj 7268 0 obj<>endobj 7269 0 obj<>endobj 7270 0 obj<>endobj 7271 0 obj<>endobj 7272 0 obj<>endobj 7273 0 obj<>endobj 7274 0 obj<>endobj 7275 0 obj<>endobj 7276 0 obj<>endobj 7277 0 obj<>endobj 7278 0 obj<>endobj 7279 0 obj<>endobj 7280 0 obj<>endobj 7281 0 obj<>endobj 7282 0 obj<>endobj 7283 0 obj<>endobj 7284 0 obj<>endobj 7285 0 obj<>endobj 7286 0 obj<>endobj 7287 0 obj<>endobj 7288 0 obj<>endobj 7289 0 obj<>endobj 7290 0 obj<>endobj 7291 0 obj<>endobj 7292 0 obj<>endobj 7293 0 obj<>endobj 7294 0 obj<>endobj 7295 0 obj<>endobj 7296 0 obj<>endobj 7297 0 obj<>endobj 7298 0 obj<>endobj 7299 0 obj<>endobj 7300 0 obj<>endobj 7301 0 obj<>endobj 7302 0 obj<>endobj 7303 0 obj<>endobj 7304 0 obj<>endobj 7305 0 obj<>endobj 7306 0 obj<>endobj 7307 0 obj<>endobj 7308 0 obj<>endobj 7309 0 obj<>endobj 7310 0 obj<>endobj 7311 0 obj<>endobj 7312 0 obj<>endobj 7313 0 obj<>endobj 7314 0 obj<>endobj 7315 0 obj<>endobj 7316 0 obj<>endobj 7317 0 obj<>endobj 7318 0 obj<>endobj 7319 0 obj<>endobj 7320 0 obj<>endobj 7321 0 obj<>endobj 7322 0 obj<>endobj 7323 0 obj<>endobj 7324 0 obj<>endobj 7325 0 obj<>endobj 7326 0 obj<>endobj 7327 0 obj<>endobj 7328 0 obj<>endobj 7329 0 obj<>endobj 7330 0 obj<>endobj 7331 0 obj<>endobj 7332 0 obj<>endobj 7333 0 obj<>endobj 7334 0 obj<>endobj 7335 0 obj<>endobj 7336 0 obj<>endobj 7337 0 obj<>endobj 7338 0 obj<>endobj 7339 0 obj<>endobj 7340 0 obj<>endobj 7341 0 obj<>endobj 7342 0 obj<>endobj 7343 0 obj<>endobj 7344 0 obj<>endobj 7345 0 obj<>endobj 7346 0 obj<>endobj 7347 0 obj<>endobj 7348 0 obj<>endobj 7349 0 obj<>endobj 7350 0 obj<>endobj 7351 0 obj<>endobj 7352 0 obj<>endobj 7353 0 obj<>endobj 7354 0 obj<>endobj 7355 0 obj<>endobj 7356 0 obj<>endobj 7357 0 obj<>endobj 7358 0 obj<>endobj 7359 0 obj<>endobj 7360 0 obj<>endobj 7361 0 obj<>endobj 7362 0 obj<>endobj 7363 0 obj<>endobj 7364 0 obj<>endobj 7365 0 obj<>endobj 7366 0 obj<>endobj 7367 0 obj<>endobj 7368 0 obj<>endobj 7369 0 obj<>endobj 7370 0 obj<>endobj 7371 0 obj<>endobj 7372 0 obj<>endobj 7373 0 obj<>endobj 7374 0 obj<>endobj 7375 0 obj<>endobj 7376 0 obj<>endobj 7377 0 obj<>endobj 7378 0 obj<>endobj 7379 0 obj<>endobj 7380 0 obj<>endobj 7381 0 obj<>1<>25<>26<>31<>37<>42<>47<>82<>133<>147<>152<>171<>177<>225<>238<>241<>252<>260<>264<>270<>295<>305<>334<>341<>349<>356<>366<>455<>470<>480<>510<>517<>519<>530<>542<>576<>588<>591<>650<>652<>710<>743<>]>>>>endobj xref 0 7382 0000000000 65535 f 0000000015 00000 n 0000000189 00000 n 0000001561 00000 n 0000001635 00000 n 0000001714 00000 n 0000001796 00000 n 0000001882 00000 n 0000001960 00000 n 0000002037 00000 n 0000002116 00000 n 0000002193 00000 n 0000002275 00000 n 0000002360 00000 n 0000002419 00000 n 0000024119 00000 n 0000034014 00000 n 0000035307 00000 n 0000035409 00000 n 0000035511 00000 n 0000035613 00000 n 0000035715 00000 n 0000035817 00000 n 0000035918 00000 n 0000036020 00000 n 0000036122 00000 n 0000036224 00000 n 0000036326 00000 n 0000036428 00000 n 0000036530 00000 n 0000036632 00000 n 0000036734 00000 n 0000036836 00000 n 0000036938 00000 n 0000037040 00000 n 0000037142 00000 n 0000037244 00000 n 0000037346 00000 n 0000037448 00000 n 0000037550 00000 n 0000037652 00000 n 0000037753 00000 n 0000037855 00000 n 0000037957 00000 n 0000038059 00000 n 0000038161 00000 n 0000038263 00000 n 0000038365 00000 n 0000038467 00000 n 0000038569 00000 n 0000038671 00000 n 0000038773 00000 n 0000038875 00000 n 0000038977 00000 n 0000039079 00000 n 0000039181 00000 n 0000039283 00000 n 0000039385 00000 n 0000039487 00000 n 0000039589 00000 n 0000039692 00000 n 0000039795 00000 n 0000039898 00000 n 0000040001 00000 n 0000040104 00000 n 0000040206 00000 n 0000040307 00000 n 0000040407 00000 n 0000040507 00000 n 0000040880 00000 n 0000040982 00000 n 0000041084 00000 n 0000041187 00000 n 0000041290 00000 n 0000041393 00000 n 0000041495 00000 n 0000041597 00000 n 0000041699 00000 n 0000041801 00000 n 0000041903 00000 n 0000042005 00000 n 0000042107 00000 n 0000042209 00000 n 0000042311 00000 n 0000042413 00000 n 0000042515 00000 n 0000042617 00000 n 0000042719 00000 n 0000042821 00000 n 0000042922 00000 n 0000043024 00000 n 0000043126 00000 n 0000043228 00000 n 0000043330 00000 n 0000043432 00000 n 0000043534 00000 n 0000043636 00000 n 0000043738 00000 n 0000043840 00000 n 0000043942 00000 n 0000044044 00000 n 0000044147 00000 n 0000044250 00000 n 0000044353 00000 n 0000044456 00000 n 0000044559 00000 n 0000044662 00000 n 0000044765 00000 n 0000044868 00000 n 0000044971 00000 n 0000045074 00000 n 0000045177 00000 n 0000045280 00000 n 0000045383 00000 n 0000045486 00000 n 0000045589 00000 n 0000045692 00000 n 0000045796 00000 n 0000045899 00000 n 0000046001 00000 n 0000046103 00000 n 0000046204 00000 n 0000046606 00000 n 0000046708 00000 n 0000046811 00000 n 0000046914 00000 n 0000047017 00000 n 0000047120 00000 n 0000047223 00000 n 0000047326 00000 n 0000047429 00000 n 0000047532 00000 n 0000047635 00000 n 0000047738 00000 n 0000047841 00000 n 0000047944 00000 n 0000048047 00000 n 0000048150 00000 n 0000048253 00000 n 0000048356 00000 n 0000048459 00000 n 0000048562 00000 n 0000048665 00000 n 0000048768 00000 n 0000048871 00000 n 0000048974 00000 n 0000049077 00000 n 0000049180 00000 n 0000049283 00000 n 0000049386 00000 n 0000049489 00000 n 0000049592 00000 n 0000049695 00000 n 0000049798 00000 n 0000049901 00000 n 0000050004 00000 n 0000050107 00000 n 0000050210 00000 n 0000050313 00000 n 0000050416 00000 n 0000050519 00000 n 0000050622 00000 n 0000050725 00000 n 0000050828 00000 n 0000050931 00000 n 0000051034 00000 n 0000051137 00000 n 0000051240 00000 n 0000051343 00000 n 0000051446 00000 n 0000051549 00000 n 0000051652 00000 n 0000051754 00000 n 0000051855 00000 n 0000051956 00000 n 0000052057 00000 n 0000052498 00000 n 0000052601 00000 n 0000052704 00000 n 0000052807 00000 n 0000052910 00000 n 0000053013 00000 n 0000053116 00000 n 0000053219 00000 n 0000053322 00000 n 0000053425 00000 n 0000053528 00000 n 0000053631 00000 n 0000053734 00000 n 0000053837 00000 n 0000053940 00000 n 0000054043 00000 n 0000054146 00000 n 0000054249 00000 n 0000054352 00000 n 0000054455 00000 n 0000054558 00000 n 0000054661 00000 n 0000054764 00000 n 0000054867 00000 n 0000054970 00000 n 0000055073 00000 n 0000055176 00000 n 0000055279 00000 n 0000055382 00000 n 0000055485 00000 n 0000055588 00000 n 0000055691 00000 n 0000055794 00000 n 0000055897 00000 n 0000056000 00000 n 0000056103 00000 n 0000056206 00000 n 0000056309 00000 n 0000056412 00000 n 0000056515 00000 n 0000056618 00000 n 0000056721 00000 n 0000056824 00000 n 0000056927 00000 n 0000057030 00000 n 0000057133 00000 n 0000057236 00000 n 0000057339 00000 n 0000057442 00000 n 0000057545 00000 n 0000057647 00000 n 0000057748 00000 n 0000057849 00000 n 0000057950 00000 n 0000058391 00000 n 0000058494 00000 n 0000058597 00000 n 0000058700 00000 n 0000058803 00000 n 0000058906 00000 n 0000059009 00000 n 0000059112 00000 n 0000059215 00000 n 0000059318 00000 n 0000059421 00000 n 0000059524 00000 n 0000059627 00000 n 0000059730 00000 n 0000059833 00000 n 0000059936 00000 n 0000060039 00000 n 0000060142 00000 n 0000060245 00000 n 0000060348 00000 n 0000060451 00000 n 0000060554 00000 n 0000060657 00000 n 0000060760 00000 n 0000060863 00000 n 0000060966 00000 n 0000061069 00000 n 0000061172 00000 n 0000061275 00000 n 0000061378 00000 n 0000061481 00000 n 0000061584 00000 n 0000061687 00000 n 0000061790 00000 n 0000061893 00000 n 0000061996 00000 n 0000062099 00000 n 0000062202 00000 n 0000062305 00000 n 0000062408 00000 n 0000062511 00000 n 0000062614 00000 n 0000062717 00000 n 0000062820 00000 n 0000062923 00000 n 0000063026 00000 n 0000063129 00000 n 0000063232 00000 n 0000063334 00000 n 0000063435 00000 n 0000063844 00000 n 0000063946 00000 n 0000064049 00000 n 0000064152 00000 n 0000064255 00000 n 0000064358 00000 n 0000064461 00000 n 0000064564 00000 n 0000064667 00000 n 0000064770 00000 n 0000064873 00000 n 0000064976 00000 n 0000065079 00000 n 0000065182 00000 n 0000065285 00000 n 0000065388 00000 n 0000065491 00000 n 0000065594 00000 n 0000065697 00000 n 0000065800 00000 n 0000065903 00000 n 0000066006 00000 n 0000066109 00000 n 0000066212 00000 n 0000066315 00000 n 0000066418 00000 n 0000066521 00000 n 0000066624 00000 n 0000066727 00000 n 0000066831 00000 n 0000066935 00000 n 0000067038 00000 n 0000067141 00000 n 0000067244 00000 n 0000067347 00000 n 0000067450 00000 n 0000067553 00000 n 0000067656 00000 n 0000067759 00000 n 0000067862 00000 n 0000067965 00000 n 0000068068 00000 n 0000068171 00000 n 0000068274 00000 n 0000068377 00000 n 0000068480 00000 n 0000068583 00000 n 0000068686 00000 n 0000068789 00000 n 0000068892 00000 n 0000068995 00000 n 0000069097 00000 n 0000069198 00000 n 0000069299 00000 n 0000069400 00000 n 0000069849 00000 n 0000069951 00000 n 0000070054 00000 n 0000070157 00000 n 0000070260 00000 n 0000070363 00000 n 0000070466 00000 n 0000070569 00000 n 0000070672 00000 n 0000070775 00000 n 0000070878 00000 n 0000070981 00000 n 0000071084 00000 n 0000071187 00000 n 0000071290 00000 n 0000071393 00000 n 0000071496 00000 n 0000071599 00000 n 0000071702 00000 n 0000071805 00000 n 0000071908 00000 n 0000072011 00000 n 0000072114 00000 n 0000072217 00000 n 0000072320 00000 n 0000072423 00000 n 0000072525 00000 n 0000072628 00000 n 0000072731 00000 n 0000072834 00000 n 0000072937 00000 n 0000073040 00000 n 0000073143 00000 n 0000073246 00000 n 0000073349 00000 n 0000073452 00000 n 0000073555 00000 n 0000073658 00000 n 0000073761 00000 n 0000073864 00000 n 0000073967 00000 n 0000074070 00000 n 0000074173 00000 n 0000074276 00000 n 0000074379 00000 n 0000074482 00000 n 0000074585 00000 n 0000074687 00000 n 0000074788 00000 n 0000074889 00000 n 0000074990 00000 n 0000075407 00000 n 0000075510 00000 n 0000075613 00000 n 0000075716 00000 n 0000075819 00000 n 0000075922 00000 n 0000076025 00000 n 0000076128 00000 n 0000076231 00000 n 0000076334 00000 n 0000076437 00000 n 0000076540 00000 n 0000076643 00000 n 0000076746 00000 n 0000076849 00000 n 0000076952 00000 n 0000077055 00000 n 0000077158 00000 n 0000077261 00000 n 0000077364 00000 n 0000077467 00000 n 0000077570 00000 n 0000077673 00000 n 0000077776 00000 n 0000077879 00000 n 0000077982 00000 n 0000078085 00000 n 0000078188 00000 n 0000078291 00000 n 0000078394 00000 n 0000078497 00000 n 0000078600 00000 n 0000078703 00000 n 0000078806 00000 n 0000078909 00000 n 0000079012 00000 n 0000079115 00000 n 0000079218 00000 n 0000079321 00000 n 0000079424 00000 n 0000079527 00000 n 0000079630 00000 n 0000079733 00000 n 0000079836 00000 n 0000079939 00000 n 0000080042 00000 n 0000080145 00000 n 0000080248 00000 n 0000080350 00000 n 0000080451 00000 n 0000080552 00000 n 0000080653 00000 n 0000081078 00000 n 0000081181 00000 n 0000081284 00000 n 0000081387 00000 n 0000081490 00000 n 0000081593 00000 n 0000081697 00000 n 0000081801 00000 n 0000081905 00000 n 0000082009 00000 n 0000082112 00000 n 0000082216 00000 n 0000082320 00000 n 0000082423 00000 n 0000082527 00000 n 0000082630 00000 n 0000082733 00000 n 0000082836 00000 n 0000082939 00000 n 0000083042 00000 n 0000083145 00000 n 0000083248 00000 n 0000083352 00000 n 0000083456 00000 n 0000083560 00000 n 0000083663 00000 n 0000083767 00000 n 0000083871 00000 n 0000083975 00000 n 0000084079 00000 n 0000084183 00000 n 0000084286 00000 n 0000084389 00000 n 0000084492 00000 n 0000084595 00000 n 0000084699 00000 n 0000084803 00000 n 0000084907 00000 n 0000085010 00000 n 0000085113 00000 n 0000085216 00000 n 0000085319 00000 n 0000085422 00000 n 0000085525 00000 n 0000085628 00000 n 0000085731 00000 n 0000085834 00000 n 0000085937 00000 n 0000086040 00000 n 0000086142 00000 n 0000086243 00000 n 0000086344 00000 n 0000086445 00000 n 0000086878 00000 n 0000086981 00000 n 0000087084 00000 n 0000087187 00000 n 0000087290 00000 n 0000087393 00000 n 0000087496 00000 n 0000087599 00000 n 0000087702 00000 n 0000087805 00000 n 0000087908 00000 n 0000088011 00000 n 0000088114 00000 n 0000088217 00000 n 0000088320 00000 n 0000088423 00000 n 0000088526 00000 n 0000088629 00000 n 0000088732 00000 n 0000088835 00000 n 0000088938 00000 n 0000089041 00000 n 0000089144 00000 n 0000089247 00000 n 0000089350 00000 n 0000089453 00000 n 0000089556 00000 n 0000089659 00000 n 0000089762 00000 n 0000089865 00000 n 0000089968 00000 n 0000090071 00000 n 0000090174 00000 n 0000090277 00000 n 0000090380 00000 n 0000090483 00000 n 0000090586 00000 n 0000090689 00000 n 0000090792 00000 n 0000090895 00000 n 0000090998 00000 n 0000091101 00000 n 0000091204 00000 n 0000091307 00000 n 0000091410 00000 n 0000091513 00000 n 0000091616 00000 n 0000091719 00000 n 0000091822 00000 n 0000091924 00000 n 0000092025 00000 n 0000092126 00000 n 0000092227 00000 n 0000092660 00000 n 0000092763 00000 n 0000092866 00000 n 0000092969 00000 n 0000093072 00000 n 0000093175 00000 n 0000093278 00000 n 0000093381 00000 n 0000093484 00000 n 0000093587 00000 n 0000093690 00000 n 0000093793 00000 n 0000093896 00000 n 0000093999 00000 n 0000094102 00000 n 0000094205 00000 n 0000094308 00000 n 0000094411 00000 n 0000094514 00000 n 0000094617 00000 n 0000094720 00000 n 0000094823 00000 n 0000094926 00000 n 0000095029 00000 n 0000095132 00000 n 0000095235 00000 n 0000095338 00000 n 0000095442 00000 n 0000095545 00000 n 0000095648 00000 n 0000095751 00000 n 0000095854 00000 n 0000095957 00000 n 0000096060 00000 n 0000096163 00000 n 0000096266 00000 n 0000096369 00000 n 0000096472 00000 n 0000096575 00000 n 0000096678 00000 n 0000096781 00000 n 0000096884 00000 n 0000096987 00000 n 0000097090 00000 n 0000097193 00000 n 0000097296 00000 n 0000097399 00000 n 0000097502 00000 n 0000097605 00000 n 0000097707 00000 n 0000097808 00000 n 0000097909 00000 n 0000098010 00000 n 0000098443 00000 n 0000098546 00000 n 0000098649 00000 n 0000098752 00000 n 0000098855 00000 n 0000098958 00000 n 0000099061 00000 n 0000099164 00000 n 0000099267 00000 n 0000099370 00000 n 0000099473 00000 n 0000099576 00000 n 0000099679 00000 n 0000099782 00000 n 0000099886 00000 n 0000099990 00000 n 0000100093 00000 n 0000100196 00000 n 0000100299 00000 n 0000100402 00000 n 0000100505 00000 n 0000100608 00000 n 0000100712 00000 n 0000100816 00000 n 0000100920 00000 n 0000101024 00000 n 0000101128 00000 n 0000101231 00000 n 0000101334 00000 n 0000101437 00000 n 0000101540 00000 n 0000101643 00000 n 0000101747 00000 n 0000101850 00000 n 0000101953 00000 n 0000102056 00000 n 0000102159 00000 n 0000102262 00000 n 0000102365 00000 n 0000102468 00000 n 0000102572 00000 n 0000102675 00000 n 0000102779 00000 n 0000102882 00000 n 0000102986 00000 n 0000103090 00000 n 0000103194 00000 n 0000103298 00000 n 0000103402 00000 n 0000103505 00000 n 0000103607 00000 n 0000103709 00000 n 0000103811 00000 n 0000103913 00000 n 0000104354 00000 n 0000104457 00000 n 0000104560 00000 n 0000104663 00000 n 0000104766 00000 n 0000104869 00000 n 0000104972 00000 n 0000105075 00000 n 0000105178 00000 n 0000105281 00000 n 0000105384 00000 n 0000105487 00000 n 0000105590 00000 n 0000105693 00000 n 0000105796 00000 n 0000105899 00000 n 0000106002 00000 n 0000106105 00000 n 0000106208 00000 n 0000106311 00000 n 0000106414 00000 n 0000106517 00000 n 0000106620 00000 n 0000106723 00000 n 0000106826 00000 n 0000106929 00000 n 0000107032 00000 n 0000107135 00000 n 0000107238 00000 n 0000107341 00000 n 0000107444 00000 n 0000107547 00000 n 0000107650 00000 n 0000107753 00000 n 0000107856 00000 n 0000107959 00000 n 0000108062 00000 n 0000108165 00000 n 0000108268 00000 n 0000108371 00000 n 0000108474 00000 n 0000108577 00000 n 0000108680 00000 n 0000108783 00000 n 0000108886 00000 n 0000108989 00000 n 0000109092 00000 n 0000109195 00000 n 0000109298 00000 n 0000109401 00000 n 0000109504 00000 n 0000109606 00000 n 0000109707 00000 n 0000109808 00000 n 0000109909 00000 n 0000110358 00000 n 0000110461 00000 n 0000110564 00000 n 0000110667 00000 n 0000110770 00000 n 0000110873 00000 n 0000110976 00000 n 0000111079 00000 n 0000111182 00000 n 0000111285 00000 n 0000111388 00000 n 0000111492 00000 n 0000111595 00000 n 0000111699 00000 n 0000111803 00000 n 0000111906 00000 n 0000112009 00000 n 0000112112 00000 n 0000112215 00000 n 0000112318 00000 n 0000112421 00000 n 0000112524 00000 n 0000112627 00000 n 0000112730 00000 n 0000112833 00000 n 0000112936 00000 n 0000113039 00000 n 0000113142 00000 n 0000113245 00000 n 0000113348 00000 n 0000113451 00000 n 0000113554 00000 n 0000113657 00000 n 0000113760 00000 n 0000113863 00000 n 0000113966 00000 n 0000114069 00000 n 0000114172 00000 n 0000114275 00000 n 0000114378 00000 n 0000114481 00000 n 0000114584 00000 n 0000114687 00000 n 0000114790 00000 n 0000114893 00000 n 0000114996 00000 n 0000115099 00000 n 0000115202 00000 n 0000115305 00000 n 0000115406 00000 n 0000115507 00000 n 0000115608 00000 n 0000116033 00000 n 0000116136 00000 n 0000116239 00000 n 0000116342 00000 n 0000116445 00000 n 0000116548 00000 n 0000116651 00000 n 0000116754 00000 n 0000116857 00000 n 0000116960 00000 n 0000117063 00000 n 0000117166 00000 n 0000117270 00000 n 0000117374 00000 n 0000117478 00000 n 0000117581 00000 n 0000117684 00000 n 0000117787 00000 n 0000117890 00000 n 0000117993 00000 n 0000118096 00000 n 0000118199 00000 n 0000118302 00000 n 0000118405 00000 n 0000118508 00000 n 0000118611 00000 n 0000118714 00000 n 0000118817 00000 n 0000118920 00000 n 0000119023 00000 n 0000119126 00000 n 0000119229 00000 n 0000119332 00000 n 0000119435 00000 n 0000119538 00000 n 0000119641 00000 n 0000119744 00000 n 0000119847 00000 n 0000119950 00000 n 0000120053 00000 n 0000120156 00000 n 0000120259 00000 n 0000120362 00000 n 0000120465 00000 n 0000120568 00000 n 0000120671 00000 n 0000120774 00000 n 0000120877 00000 n 0000120980 00000 n 0000121083 00000 n 0000121184 00000 n 0000121285 00000 n 0000121386 00000 n 0000121819 00000 n 0000121922 00000 n 0000122025 00000 n 0000122128 00000 n 0000122231 00000 n 0000122334 00000 n 0000122437 00000 n 0000122540 00000 n 0000122643 00000 n 0000122746 00000 n 0000122849 00000 n 0000122952 00000 n 0000123055 00000 n 0000123159 00000 n 0000123262 00000 n 0000123366 00000 n 0000123470 00000 n 0000123574 00000 n 0000123678 00000 n 0000123781 00000 n 0000123885 00000 n 0000123989 00000 n 0000124093 00000 n 0000124197 00000 n 0000124300 00000 n 0000124404 00000 n 0000124508 00000 n 0000124612 00000 n 0000124716 00000 n 0000124820 00000 n 0000124924 00000 n 0000125028 00000 n 0000125132 00000 n 0000125235 00000 n 0000125338 00000 n 0000125441 00000 n 0000125544 00000 n 0000125647 00000 n 0000125750 00000 n 0000125853 00000 n 0000125956 00000 n 0000126059 00000 n 0000126162 00000 n 0000126265 00000 n 0000126368 00000 n 0000126471 00000 n 0000126574 00000 n 0000126677 00000 n 0000126780 00000 n 0000126882 00000 n 0000126983 00000 n 0000127084 00000 n 0000127185 00000 n 0000127618 00000 n 0000127721 00000 n 0000127824 00000 n 0000127927 00000 n 0000128030 00000 n 0000128133 00000 n 0000128236 00000 n 0000128339 00000 n 0000128442 00000 n 0000128545 00000 n 0000128648 00000 n 0000128751 00000 n 0000128854 00000 n 0000128957 00000 n 0000129060 00000 n 0000129163 00000 n 0000129266 00000 n 0000129369 00000 n 0000129472 00000 n 0000129575 00000 n 0000129678 00000 n 0000129781 00000 n 0000129884 00000 n 0000129987 00000 n 0000130090 00000 n 0000130193 00000 n 0000130296 00000 n 0000130399 00000 n 0000130502 00000 n 0000130605 00000 n 0000130708 00000 n 0000130811 00000 n 0000130914 00000 n 0000131017 00000 n 0000131120 00000 n 0000131223 00000 n 0000131326 00000 n 0000131429 00000 n 0000131532 00000 n 0000131635 00000 n 0000131738 00000 n 0000131841 00000 n 0000131944 00000 n 0000132047 00000 n 0000132150 00000 n 0000132253 00000 n 0000132356 00000 n 0000132459 00000 n 0000132562 00000 n 0000132665 00000 n 0000132767 00000 n 0000132868 00000 n 0000132969 00000 n 0000133070 00000 n 0000133511 00000 n 0000133614 00000 n 0000133717 00000 n 0000133820 00000 n 0000133923 00000 n 0000134026 00000 n 0000134129 00000 n 0000134232 00000 n 0000134335 00000 n 0000134438 00000 n 0000134541 00000 n 0000134644 00000 n 0000134747 00000 n 0000134850 00000 n 0000134953 00000 n 0000135056 00000 n 0000135159 00000 n 0000135262 00000 n 0000135365 00000 n 0000135468 00000 n 0000135572 00000 n 0000135676 00000 n 0000135780 00000 n 0000135884 00000 n 0000135987 00000 n 0000136090 00000 n 0000136193 00000 n 0000136296 00000 n 0000136399 00000 n 0000136502 00000 n 0000136605 00000 n 0000136708 00000 n 0000136811 00000 n 0000136914 00000 n 0000137017 00000 n 0000137120 00000 n 0000137223 00000 n 0000137326 00000 n 0000137429 00000 n 0000137532 00000 n 0000137635 00000 n 0000137738 00000 n 0000137841 00000 n 0000137944 00000 n 0000138047 00000 n 0000138150 00000 n 0000138253 00000 n 0000138356 00000 n 0000138458 00000 n 0000138559 00000 n 0000138660 00000 n 0000138761 00000 n 0000139186 00000 n 0000139289 00000 n 0000139392 00000 n 0000139495 00000 n 0000139598 00000 n 0000139701 00000 n 0000139804 00000 n 0000139907 00000 n 0000140010 00000 n 0000140113 00000 n 0000140216 00000 n 0000140319 00000 n 0000140422 00000 n 0000140525 00000 n 0000140628 00000 n 0000140731 00000 n 0000140834 00000 n 0000140937 00000 n 0000141040 00000 n 0000141143 00000 n 0000141246 00000 n 0000141349 00000 n 0000141452 00000 n 0000141555 00000 n 0000141658 00000 n 0000141762 00000 n 0000141866 00000 n 0000141969 00000 n 0000142072 00000 n 0000142175 00000 n 0000142278 00000 n 0000142382 00000 n 0000142486 00000 n 0000142590 00000 n 0000142694 00000 n 0000142798 00000 n 0000142902 00000 n 0000143006 00000 n 0000143110 00000 n 0000143214 00000 n 0000143318 00000 n 0000143422 00000 n 0000143526 00000 n 0000143630 00000 n 0000143734 00000 n 0000143838 00000 n 0000143942 00000 n 0000144046 00000 n 0000144150 00000 n 0000144254 00000 n 0000144358 00000 n 0000144461 00000 n 0000144563 00000 n 0000144665 00000 n 0000144767 00000 n 0000145241 00000 n 0000145345 00000 n 0000145449 00000 n 0000145553 00000 n 0000145657 00000 n 0000145761 00000 n 0000145865 00000 n 0000145969 00000 n 0000146073 00000 n 0000146178 00000 n 0000146283 00000 n 0000146388 00000 n 0000146493 00000 n 0000146598 00000 n 0000146702 00000 n 0000146806 00000 n 0000146910 00000 n 0000147014 00000 n 0000147118 00000 n 0000147222 00000 n 0000147326 00000 n 0000147430 00000 n 0000147534 00000 n 0000147638 00000 n 0000147742 00000 n 0000147846 00000 n 0000147950 00000 n 0000148054 00000 n 0000148158 00000 n 0000148262 00000 n 0000148366 00000 n 0000148470 00000 n 0000148574 00000 n 0000148678 00000 n 0000148782 00000 n 0000148886 00000 n 0000148990 00000 n 0000149094 00000 n 0000149198 00000 n 0000149302 00000 n 0000149406 00000 n 0000149510 00000 n 0000149614 00000 n 0000149718 00000 n 0000149822 00000 n 0000149926 00000 n 0000150030 00000 n 0000150134 00000 n 0000150238 00000 n 0000150341 00000 n 0000150443 00000 n 0000150545 00000 n 0000150647 00000 n 0000151133 00000 n 0000151237 00000 n 0000151341 00000 n 0000151445 00000 n 0000151549 00000 n 0000151653 00000 n 0000151757 00000 n 0000151861 00000 n 0000151965 00000 n 0000152069 00000 n 0000152174 00000 n 0000152278 00000 n 0000152382 00000 n 0000152486 00000 n 0000152590 00000 n 0000152694 00000 n 0000152798 00000 n 0000152902 00000 n 0000153006 00000 n 0000153110 00000 n 0000153214 00000 n 0000153318 00000 n 0000153422 00000 n 0000153526 00000 n 0000153630 00000 n 0000153734 00000 n 0000153838 00000 n 0000153942 00000 n 0000154046 00000 n 0000154151 00000 n 0000154256 00000 n 0000154361 00000 n 0000154466 00000 n 0000154571 00000 n 0000154676 00000 n 0000154781 00000 n 0000154886 00000 n 0000154991 00000 n 0000155096 00000 n 0000155201 00000 n 0000155306 00000 n 0000155411 00000 n 0000155516 00000 n 0000155621 00000 n 0000155726 00000 n 0000155831 00000 n 0000155936 00000 n 0000156040 00000 n 0000156144 00000 n 0000156249 00000 n 0000156354 00000 n 0000156458 00000 n 0000156561 00000 n 0000156664 00000 n 0000156766 00000 n 0000157270 00000 n 0000157374 00000 n 0000157478 00000 n 0000157582 00000 n 0000157686 00000 n 0000157791 00000 n 0000157895 00000 n 0000157999 00000 n 0000158103 00000 n 0000158207 00000 n 0000158312 00000 n 0000158417 00000 n 0000158522 00000 n 0000158627 00000 n 0000158732 00000 n 0000158836 00000 n 0000158940 00000 n 0000159044 00000 n 0000159148 00000 n 0000159252 00000 n 0000159356 00000 n 0000159460 00000 n 0000159564 00000 n 0000159668 00000 n 0000159772 00000 n 0000159876 00000 n 0000159980 00000 n 0000160084 00000 n 0000160188 00000 n 0000160292 00000 n 0000160396 00000 n 0000160500 00000 n 0000160604 00000 n 0000160708 00000 n 0000160812 00000 n 0000160916 00000 n 0000161020 00000 n 0000161124 00000 n 0000161228 00000 n 0000161332 00000 n 0000161436 00000 n 0000161540 00000 n 0000161644 00000 n 0000161748 00000 n 0000161852 00000 n 0000161956 00000 n 0000162060 00000 n 0000162164 00000 n 0000162268 00000 n 0000162372 00000 n 0000162475 00000 n 0000162577 00000 n 0000162679 00000 n 0000162781 00000 n 0000163276 00000 n 0000163380 00000 n 0000163484 00000 n 0000163588 00000 n 0000163692 00000 n 0000163796 00000 n 0000163900 00000 n 0000164004 00000 n 0000164108 00000 n 0000164212 00000 n 0000164316 00000 n 0000164420 00000 n 0000164524 00000 n 0000164628 00000 n 0000164732 00000 n 0000164836 00000 n 0000164940 00000 n 0000165044 00000 n 0000165148 00000 n 0000165252 00000 n 0000165356 00000 n 0000165460 00000 n 0000165564 00000 n 0000165668 00000 n 0000165772 00000 n 0000165876 00000 n 0000165980 00000 n 0000166084 00000 n 0000166188 00000 n 0000166292 00000 n 0000166396 00000 n 0000166500 00000 n 0000166604 00000 n 0000166708 00000 n 0000166812 00000 n 0000166916 00000 n 0000167020 00000 n 0000167124 00000 n 0000167228 00000 n 0000167332 00000 n 0000167436 00000 n 0000167540 00000 n 0000167644 00000 n 0000167748 00000 n 0000167852 00000 n 0000167956 00000 n 0000168060 00000 n 0000168164 00000 n 0000168268 00000 n 0000168372 00000 n 0000168475 00000 n 0000168577 00000 n 0000168679 00000 n 0000168781 00000 n 0000169276 00000 n 0000169380 00000 n 0000169484 00000 n 0000169588 00000 n 0000169692 00000 n 0000169796 00000 n 0000169900 00000 n 0000170004 00000 n 0000170108 00000 n 0000170212 00000 n 0000170316 00000 n 0000170420 00000 n 0000170525 00000 n 0000170629 00000 n 0000170733 00000 n 0000170837 00000 n 0000170941 00000 n 0000171045 00000 n 0000171149 00000 n 0000171329 00000 n 0000171433 00000 n 0000171537 00000 n 0000171641 00000 n 0000171745 00000 n 0000171849 00000 n 0000171953 00000 n 0000172057 00000 n 0000172161 00000 n 0000172265 00000 n 0000172369 00000 n 0000172473 00000 n 0000172577 00000 n 0000172681 00000 n 0000172785 00000 n 0000172889 00000 n 0000172993 00000 n 0000173097 00000 n 0000173201 00000 n 0000173305 00000 n 0000173409 00000 n 0000173513 00000 n 0000173617 00000 n 0000173721 00000 n 0000173825 00000 n 0000173929 00000 n 0000174033 00000 n 0000174137 00000 n 0000174241 00000 n 0000174345 00000 n 0000174449 00000 n 0000174553 00000 n 0000174657 00000 n 0000174761 00000 n 0000174865 00000 n 0000174969 00000 n 0000175073 00000 n 0000175177 00000 n 0000175281 00000 n 0000175385 00000 n 0000175487 00000 n 0000175865 00000 n 0000175969 00000 n 0000176073 00000 n 0000176177 00000 n 0000176281 00000 n 0000176385 00000 n 0000176489 00000 n 0000176593 00000 n 0000176697 00000 n 0000176801 00000 n 0000176905 00000 n 0000177009 00000 n 0000177113 00000 n 0000177218 00000 n 0000177323 00000 n 0000177428 00000 n 0000177533 00000 n 0000177638 00000 n 0000177701 00000 n 0000177790 00000 n 0000177842 00000 n 0000177928 00000 n 0000178117 00000 n 0000178179 00000 n 0000178267 00000 n 0000178328 00000 n 0000178416 00000 n 0000178521 00000 n 0000178566 00000 n 0000178630 00000 n 0000178719 00000 n 0000178781 00000 n 0000178870 00000 n 0000178932 00000 n 0000179020 00000 n 0000179125 00000 n 0000179191 00000 n 0000179279 00000 n 0000179332 00000 n 0000179419 00000 n 0000179491 00000 n 0000179596 00000 n 0000179657 00000 n 0000179746 00000 n 0000179871 00000 n 0000179959 00000 n 0000180004 00000 n 0000180108 00000 n 0000180212 00000 n 0000180316 00000 n 0000180421 00000 n 0000180526 00000 n 0000180631 00000 n 0000180736 00000 n 0000180841 00000 n 0000180945 00000 n 0000181049 00000 n 0000181153 00000 n 0000181257 00000 n 0000181361 00000 n 0000181496 00000 n 0000181566 00000 n 0000181655 00000 n 0000181725 00000 n 0000181814 00000 n 0000181883 00000 n 0000181972 00000 n 0000182078 00000 n 0000182166 00000 n 0000182244 00000 n 0000182333 00000 n 0000182386 00000 n 0000182475 00000 n 0000182547 00000 n 0000182651 00000 n 0000182756 00000 n 0000182860 00000 n 0000182965 00000 n 0000183070 00000 n 0000183175 00000 n 0000183280 00000 n 0000183385 00000 n 0000183490 00000 n 0000183595 00000 n 0000183700 00000 n 0000183805 00000 n 0000183909 00000 n 0000184014 00000 n 0000184119 00000 n 0000184224 00000 n 0000184329 00000 n 0000184434 00000 n 0000184538 00000 n 0000184590 00000 n 0000184679 00000 n 0000184784 00000 n 0000184889 00000 n 0000184994 00000 n 0000185219 00000 n 0000185273 00000 n 0000185362 00000 n 0000185415 00000 n 0000185504 00000 n 0000185557 00000 n 0000185646 00000 n 0000185707 00000 n 0000185796 00000 n 0000185864 00000 n 0000185953 00000 n 0000186030 00000 n 0000186119 00000 n 0000186191 00000 n 0000186252 00000 n 0000186341 00000 n 0000186421 00000 n 0000186510 00000 n 0000186562 00000 n 0000186651 00000 n 0000186696 00000 n 0000186800 00000 n 0000186904 00000 n 0000187009 00000 n 0000187114 00000 n 0000187219 00000 n 0000187324 00000 n 0000187429 00000 n 0000187533 00000 n 0000187638 00000 n 0000187743 00000 n 0000187848 00000 n 0000187965 00000 n 0000188069 00000 n 0000188174 00000 n 0000188279 00000 n 0000188384 00000 n 0000188489 00000 n 0000188594 00000 n 0000188699 00000 n 0000188803 00000 n 0000188908 00000 n 0000189013 00000 n 0000189118 00000 n 0000189223 00000 n 0000189328 00000 n 0000189433 00000 n 0000189538 00000 n 0000189642 00000 n 0000189747 00000 n 0000189852 00000 n 0000189957 00000 n 0000190062 00000 n 0000190167 00000 n 0000190271 00000 n 0000190376 00000 n 0000190481 00000 n 0000190586 00000 n 0000190691 00000 n 0000190796 00000 n 0000190901 00000 n 0000191006 00000 n 0000191111 00000 n 0000191216 00000 n 0000191321 00000 n 0000191426 00000 n 0000191531 00000 n 0000191636 00000 n 0000191741 00000 n 0000191845 00000 n 0000191950 00000 n 0000192055 00000 n 0000192160 00000 n 0000192265 00000 n 0000192370 00000 n 0000192475 00000 n 0000192580 00000 n 0000192685 00000 n 0000192789 00000 n 0000192894 00000 n 0000192999 00000 n 0000193104 00000 n 0000193209 00000 n 0000193313 00000 n 0000193418 00000 n 0000193523 00000 n 0000193627 00000 n 0000193730 00000 n 0000193833 00000 n 0000194355 00000 n 0000194460 00000 n 0000194487 00000 n 0000194592 00000 n 0000194619 00000 n 0000194724 00000 n 0000194751 00000 n 0000194856 00000 n 0000194883 00000 n 0000194988 00000 n 0000195093 00000 n 0000195129 00000 n 0000195234 00000 n 0000195261 00000 n 0000195314 00000 n 0000195403 00000 n 0000195456 00000 n 0000195545 00000 n 0000195581 00000 n 0000195686 00000 n 0000195713 00000 n 0000195818 00000 n 0000195845 00000 n 0000195950 00000 n 0000196053 00000 n 0000196089 00000 n 0000196194 00000 n 0000196221 00000 n 0000196326 00000 n 0000196353 00000 n 0000196415 00000 n 0000196504 00000 n 0000196566 00000 n 0000196655 00000 n 0000196691 00000 n 0000196795 00000 n 0000196899 00000 n 0000197003 00000 n 0000197107 00000 n 0000197211 00000 n 0000197316 00000 n 0000197421 00000 n 0000197526 00000 n 0000197630 00000 n 0000197735 00000 n 0000197840 00000 n 0000197945 00000 n 0000198050 00000 n 0000198155 00000 n 0000198260 00000 n 0000198365 00000 n 0000198469 00000 n 0000198573 00000 n 0000198677 00000 n 0000198781 00000 n 0000198885 00000 n 0000198989 00000 n 0000199093 00000 n 0000199197 00000 n 0000199301 00000 n 0000199406 00000 n 0000199511 00000 n 0000199616 00000 n 0000199721 00000 n 0000199825 00000 n 0000199929 00000 n 0000200033 00000 n 0000200137 00000 n 0000200242 00000 n 0000200346 00000 n 0000200450 00000 n 0000200554 00000 n 0000200658 00000 n 0000200762 00000 n 0000200866 00000 n 0000200970 00000 n 0000201074 00000 n 0000201178 00000 n 0000201282 00000 n 0000201387 00000 n 0000201810 00000 n 0000201915 00000 n 0000201942 00000 n 0000202047 00000 n 0000202074 00000 n 0000202177 00000 n 0000202204 00000 n 0000202309 00000 n 0000202336 00000 n 0000202441 00000 n 0000202546 00000 n 0000202582 00000 n 0000202686 00000 n 0000202790 00000 n 0000202895 00000 n 0000203000 00000 n 0000203105 00000 n 0000203168 00000 n 0000203273 00000 n 0000203300 00000 n 0000203405 00000 n 0000203432 00000 n 0000203494 00000 n 0000203582 00000 n 0000203609 00000 n 0000203671 00000 n 0000203760 00000 n 0000203787 00000 n 0000203892 00000 n 0000203919 00000 n 0000204024 00000 n 0000204129 00000 n 0000204233 00000 n 0000204278 00000 n 0000204383 00000 n 0000204410 00000 n 0000204515 00000 n 0000204542 00000 n 0000204647 00000 n 0000204752 00000 n 0000204857 00000 n 0000204902 00000 n 0000205007 00000 n 0000205034 00000 n 0000205138 00000 n 0000205165 00000 n 0000205269 00000 n 0000205373 00000 n 0000205478 00000 n 0000205583 00000 n 0000205688 00000 n 0000205793 00000 n 0000205898 00000 n 0000206003 00000 n 0000206108 00000 n 0000206213 00000 n 0000206318 00000 n 0000206423 00000 n 0000206528 00000 n 0000206633 00000 n 0000206738 00000 n 0000206843 00000 n 0000206948 00000 n 0000207053 00000 n 0000207158 00000 n 0000207263 00000 n 0000207368 00000 n 0000207473 00000 n 0000207578 00000 n 0000207683 00000 n 0000207788 00000 n 0000207893 00000 n 0000207998 00000 n 0000208103 00000 n 0000208208 00000 n 0000208313 00000 n 0000208417 00000 n 0000208522 00000 n 0000208627 00000 n 0000208732 00000 n 0000208837 00000 n 0000208942 00000 n 0000209047 00000 n 0000209152 00000 n 0000209257 00000 n 0000209362 00000 n 0000209467 00000 n 0000209854 00000 n 0000209957 00000 n 0000209984 00000 n 0000210089 00000 n 0000210116 00000 n 0000210220 00000 n 0000210324 00000 n 0000210428 00000 n 0000210532 00000 n 0000210636 00000 n 0000210740 00000 n 0000210844 00000 n 0000210949 00000 n 0000211054 00000 n 0000211158 00000 n 0000211262 00000 n 0000211366 00000 n 0000211471 00000 n 0000211574 00000 n 0000211718 00000 n 0000211821 00000 n 0000211848 00000 n 0000211952 00000 n 0000212056 00000 n 0000212161 00000 n 0000212266 00000 n 0000212371 00000 n 0000212476 00000 n 0000212580 00000 n 0000212685 00000 n 0000212790 00000 n 0000212895 00000 n 0000213000 00000 n 0000213104 00000 n 0000213209 00000 n 0000213314 00000 n 0000213419 00000 n 0000213524 00000 n 0000213629 00000 n 0000213733 00000 n 0000213838 00000 n 0000214027 00000 n 0000214131 00000 n 0000214158 00000 n 0000214263 00000 n 0000214290 00000 n 0000214394 00000 n 0000214499 00000 n 0000214604 00000 n 0000214709 00000 n 0000214814 00000 n 0000214919 00000 n 0000215023 00000 n 0000215128 00000 n 0000215233 00000 n 0000215338 00000 n 0000215446 00000 n 0000215550 00000 n 0000215655 00000 n 0000215760 00000 n 0000215865 00000 n 0000215970 00000 n 0000216075 00000 n 0000216180 00000 n 0000216285 00000 n 0000216390 00000 n 0000216494 00000 n 0000216599 00000 n 0000216704 00000 n 0000216809 00000 n 0000216914 00000 n 0000217019 00000 n 0000217123 00000 n 0000217228 00000 n 0000217333 00000 n 0000217438 00000 n 0000217543 00000 n 0000217648 00000 n 0000217753 00000 n 0000217857 00000 n 0000217962 00000 n 0000218067 00000 n 0000218172 00000 n 0000218277 00000 n 0000218382 00000 n 0000218487 00000 n 0000218591 00000 n 0000218696 00000 n 0000218801 00000 n 0000218906 00000 n 0000219011 00000 n 0000219116 00000 n 0000219221 00000 n 0000219326 00000 n 0000219431 00000 n 0000219536 00000 n 0000219641 00000 n 0000219746 00000 n 0000219851 00000 n 0000219956 00000 n 0000220060 00000 n 0000220165 00000 n 0000220270 00000 n 0000220374 00000 n 0000220478 00000 n 0000220582 00000 n 0000220686 00000 n 0000220789 00000 n 0000220892 00000 n 0000220995 00000 n 0000221490 00000 n 0000221594 00000 n 0000221699 00000 n 0000221804 00000 n 0000221908 00000 n 0000222012 00000 n 0000222117 00000 n 0000222222 00000 n 0000222326 00000 n 0000222430 00000 n 0000222534 00000 n 0000222642 00000 n 0000222747 00000 n 0000222836 00000 n 0000222925 00000 n 0000223026 00000 n 0000223115 00000 n 0000223220 00000 n 0000223274 00000 n 0000223379 00000 n 0000223482 00000 n 0000223518 00000 n 0000223621 00000 n 0000223648 00000 n 0000223753 00000 n 0000223780 00000 n 0000223885 00000 n 0000223912 00000 n 0000224017 00000 n 0000224044 00000 n 0000224147 00000 n 0000224174 00000 n 0000224279 00000 n 0000224384 00000 n 0000224420 00000 n 0000224525 00000 n 0000224630 00000 n 0000224735 00000 n 0000224839 00000 n 0000224893 00000 n 0000224997 00000 n 0000225024 00000 n 0000225128 00000 n 0000225155 00000 n 0000225260 00000 n 0000225287 00000 n 0000225392 00000 n 0000225419 00000 n 0000225524 00000 n 0000225551 00000 n 0000225656 00000 n 0000225683 00000 n 0000225787 00000 n 0000225892 00000 n 0000225928 00000 n 0000226033 00000 n 0000226060 00000 n 0000226165 00000 n 0000226268 00000 n 0000226304 00000 n 0000226409 00000 n 0000226436 00000 n 0000226540 00000 n 0000226645 00000 n 0000226750 00000 n 0000226855 00000 n 0000226960 00000 n 0000227065 00000 n 0000227170 00000 n 0000227275 00000 n 0000227379 00000 n 0000227483 00000 n 0000227588 00000 n 0000227693 00000 n 0000227798 00000 n 0000227903 00000 n 0000228008 00000 n 0000228113 00000 n 0000228275 00000 n 0000228380 00000 n 0000228484 00000 n 0000228520 00000 n 0000228625 00000 n 0000228652 00000 n 0000228757 00000 n 0000228860 00000 n 0000228896 00000 n 0000229001 00000 n 0000229106 00000 n 0000229142 00000 n 0000229247 00000 n 0000229351 00000 n 0000229387 00000 n 0000229491 00000 n 0000229595 00000 n 0000229699 00000 n 0000229802 00000 n 0000229856 00000 n 0000229960 00000 n 0000230064 00000 n 0000230168 00000 n 0000230272 00000 n 0000230376 00000 n 0000230480 00000 n 0000230584 00000 n 0000230688 00000 n 0000230792 00000 n 0000230891 00000 n 0000230996 00000 n 0000231101 00000 n 0000231137 00000 n 0000231203 00000 n 0000231292 00000 n 0000231319 00000 n 0000231423 00000 n 0000231527 00000 n 0000231631 00000 n 0000231735 00000 n 0000231839 00000 n 0000231943 00000 n 0000232047 00000 n 0000232151 00000 n 0000232255 00000 n 0000232360 00000 n 0000232465 00000 n 0000232570 00000 n 0000232675 00000 n 0000232780 00000 n 0000232885 00000 n 0000232990 00000 n 0000233094 00000 n 0000233196 00000 n 0000233376 00000 n 0000233481 00000 n 0000233508 00000 n 0000233612 00000 n 0000233715 00000 n 0000233819 00000 n 0000233923 00000 n 0000234027 00000 n 0000234131 00000 n 0000234235 00000 n 0000234316 00000 n 0000234421 00000 n 0000234448 00000 n 0000234553 00000 n 0000234656 00000 n 0000234692 00000 n 0000234796 00000 n 0000234900 00000 n 0000235004 00000 n 0000235108 00000 n 0000235212 00000 n 0000235316 00000 n 0000235420 00000 n 0000235524 00000 n 0000235628 00000 n 0000235732 00000 n 0000235836 00000 n 0000235940 00000 n 0000236044 00000 n 0000236148 00000 n 0000236252 00000 n 0000236356 00000 n 0000236460 00000 n 0000236631 00000 n 0000236700 00000 n 0000236789 00000 n 0000236816 00000 n 0000236874 00000 n 0000236963 00000 n 0000237025 00000 n 0000237113 00000 n 0000237149 00000 n 0000237252 00000 n 0000237357 00000 n 0000237462 00000 n 0000237567 00000 n 0000237671 00000 n 0000237776 00000 n 0000237881 00000 n 0000237986 00000 n 0000238091 00000 n 0000238196 00000 n 0000238301 00000 n 0000238406 00000 n 0000238510 00000 n 0000238615 00000 n 0000238720 00000 n 0000238825 00000 n 0000238930 00000 n 0000239035 00000 n 0000239140 00000 n 0000239245 00000 n 0000239350 00000 n 0000239455 00000 n 0000239560 00000 n 0000239665 00000 n 0000239770 00000 n 0000239875 00000 n 0000239980 00000 n 0000240085 00000 n 0000240190 00000 n 0000240295 00000 n 0000240400 00000 n 0000240505 00000 n 0000240610 00000 n 0000240714 00000 n 0000240819 00000 n 0000240924 00000 n 0000241029 00000 n 0000241134 00000 n 0000241239 00000 n 0000241344 00000 n 0000241449 00000 n 0000241554 00000 n 0000241659 00000 n 0000241764 00000 n 0000241869 00000 n 0000241973 00000 n 0000242078 00000 n 0000242183 00000 n 0000242288 00000 n 0000242393 00000 n 0000242497 00000 n 0000242600 00000 n 0000242703 00000 n 0000243198 00000 n 0000243302 00000 n 0000243407 00000 n 0000243512 00000 n 0000243557 00000 n 0000243660 00000 n 0000243687 00000 n 0000243792 00000 n 0000243897 00000 n 0000243933 00000 n 0000244038 00000 n 0000244143 00000 n 0000244179 00000 n 0000244283 00000 n 0000244387 00000 n 0000244492 00000 n 0000244597 00000 n 0000244702 00000 n 0000244807 00000 n 0000244911 00000 n 0000245016 00000 n 0000245092 00000 n 0000245181 00000 n 0000245261 00000 n 0000245350 00000 n 0000245454 00000 n 0000245563 00000 n 0000245652 00000 n 0000245778 00000 n 0000245868 00000 n 0000245957 00000 n 0000245984 00000 n 0000246064 00000 n 0000246152 00000 n 0000246179 00000 n 0000246284 00000 n 0000246311 00000 n 0000246415 00000 n 0000246520 00000 n 0000246624 00000 n 0000246728 00000 n 0000246832 00000 n 0000246937 00000 n 0000247042 00000 n 0000247147 00000 n 0000247251 00000 n 0000247356 00000 n 0000247461 00000 n 0000247566 00000 n 0000247671 00000 n 0000247775 00000 n 0000247880 00000 n 0000247985 00000 n 0000248090 00000 n 0000248194 00000 n 0000248298 00000 n 0000248403 00000 n 0000248508 00000 n 0000248613 00000 n 0000248718 00000 n 0000248823 00000 n 0000248928 00000 n 0000249033 00000 n 0000249138 00000 n 0000249233 00000 n 0000249322 00000 n 0000249392 00000 n 0000249481 00000 n 0000249545 00000 n 0000249634 00000 n 0000249692 00000 n 0000249781 00000 n 0000249871 00000 n 0000249959 00000 n 0000250265 00000 n 0000250369 00000 n 0000250473 00000 n 0000250578 00000 n 0000250623 00000 n 0000250728 00000 n 0000250833 00000 n 0000250938 00000 n 0000251042 00000 n 0000251147 00000 n 0000251251 00000 n 0000251354 00000 n 0000251435 00000 n 0000251540 00000 n 0000251567 00000 n 0000251672 00000 n 0000251726 00000 n 0000251815 00000 n 0000251868 00000 n 0000251957 00000 n 0000252002 00000 n 0000252107 00000 n 0000252202 00000 n 0000252291 00000 n 0000252327 00000 n 0000252422 00000 n 0000252511 00000 n 0000252538 00000 n 0000252643 00000 n 0000252748 00000 n 0000252784 00000 n 0000252889 00000 n 0000252916 00000 n 0000253021 00000 n 0000253048 00000 n 0000253152 00000 n 0000253257 00000 n 0000253293 00000 n 0000253398 00000 n 0000253425 00000 n 0000253529 00000 n 0000253634 00000 n 0000253738 00000 n 0000253783 00000 n 0000253887 00000 n 0000253914 00000 n 0000254019 00000 n 0000254046 00000 n 0000254151 00000 n 0000254178 00000 n 0000254282 00000 n 0000254387 00000 n 0000254492 00000 n 0000254596 00000 n 0000254701 00000 n 0000254806 00000 n 0000254911 00000 n 0000255016 00000 n 0000255121 00000 n 0000255225 00000 n 0000255329 00000 n 0000255434 00000 n 0000255539 00000 n 0000255644 00000 n 0000255748 00000 n 0000255852 00000 n 0000255957 00000 n 0000256061 00000 n 0000256166 00000 n 0000256271 00000 n 0000256469 00000 n 0000256574 00000 n 0000256679 00000 n 0000256783 00000 n 0000256861 00000 n 0000256950 00000 n 0000257004 00000 n 0000257109 00000 n 0000257214 00000 n 0000257319 00000 n 0000257364 00000 n 0000257468 00000 n 0000257572 00000 n 0000257676 00000 n 0000257781 00000 n 0000257886 00000 n 0000257991 00000 n 0000258096 00000 n 0000258201 00000 n 0000258306 00000 n 0000258411 00000 n 0000258515 00000 n 0000258619 00000 n 0000258723 00000 n 0000258827 00000 n 0000258931 00000 n 0000259036 00000 n 0000259141 00000 n 0000259246 00000 n 0000259351 00000 n 0000259455 00000 n 0000259559 00000 n 0000259621 00000 n 0000259709 00000 n 0000259792 00000 n 0000259880 00000 n 0000259983 00000 n 0000260088 00000 n 0000260331 00000 n 0000260436 00000 n 0000260541 00000 n 0000260645 00000 n 0000260750 00000 n 0000260855 00000 n 0000260960 00000 n 0000261063 00000 n 0000261166 00000 n 0000261256 00000 n 0000261361 00000 n 0000261466 00000 n 0000261571 00000 n 0000261676 00000 n 0000261781 00000 n 0000261844 00000 n 0000261949 00000 n 0000262054 00000 n 0000262159 00000 n 0000262264 00000 n 0000262318 00000 n 0000262423 00000 n 0000262528 00000 n 0000262632 00000 n 0000262677 00000 n 0000262782 00000 n 0000262887 00000 n 0000262992 00000 n 0000263097 00000 n 0000263151 00000 n 0000263241 00000 n 0000263330 00000 n 0000263420 00000 n 0000263509 00000 n 0000263614 00000 n 0000263719 00000 n 0000263773 00000 n 0000263877 00000 n 0000263981 00000 n 0000264086 00000 n 0000264191 00000 n 0000264295 00000 n 0000264400 00000 n 0000264505 00000 n 0000264610 00000 n 0000264715 00000 n 0000264820 00000 n 0000264925 00000 n 0000265030 00000 n 0000265135 00000 n 0000265240 00000 n 0000265345 00000 n 0000265450 00000 n 0000265501 00000 n 0000265590 00000 n 0000265761 00000 n 0000265866 00000 n 0000265893 00000 n 0000265944 00000 n 0000266033 00000 n 0000266060 00000 n 0000266164 00000 n 0000266268 00000 n 0000266372 00000 n 0000266476 00000 n 0000266581 00000 n 0000266686 00000 n 0000266791 00000 n 0000266896 00000 n 0000267001 00000 n 0000267105 00000 n 0000267209 00000 n 0000267313 00000 n 0000267418 00000 n 0000267523 00000 n 0000267627 00000 n 0000267731 00000 n 0000267835 00000 n 0000267939 00000 n 0000268044 00000 n 0000268149 00000 n 0000268250 00000 n 0000268339 00000 n 0000268546 00000 n 0000268650 00000 n 0000268677 00000 n 0000268782 00000 n 0000268887 00000 n 0000268923 00000 n 0000269027 00000 n 0000269131 00000 n 0000269236 00000 n 0000269341 00000 n 0000269446 00000 n 0000269551 00000 n 0000269656 00000 n 0000269761 00000 n 0000269866 00000 n 0000269971 00000 n 0000270076 00000 n 0000270181 00000 n 0000270285 00000 n 0000270390 00000 n 0000270495 00000 n 0000270600 00000 n 0000270705 00000 n 0000270810 00000 n 0000270915 00000 n 0000271020 00000 n 0000271125 00000 n 0000271230 00000 n 0000271335 00000 n 0000271440 00000 n 0000271545 00000 n 0000271650 00000 n 0000271755 00000 n 0000271860 00000 n 0000271965 00000 n 0000272070 00000 n 0000272175 00000 n 0000272280 00000 n 0000272385 00000 n 0000272490 00000 n 0000272594 00000 n 0000272699 00000 n 0000272804 00000 n 0000272909 00000 n 0000273014 00000 n 0000273119 00000 n 0000273224 00000 n 0000273329 00000 n 0000273434 00000 n 0000273539 00000 n 0000273644 00000 n 0000273749 00000 n 0000273854 00000 n 0000273959 00000 n 0000274064 00000 n 0000274169 00000 n 0000274272 00000 n 0000274375 00000 n 0000274478 00000 n 0000274973 00000 n 0000275078 00000 n 0000275183 00000 n 0000275288 00000 n 0000275393 00000 n 0000275498 00000 n 0000275602 00000 n 0000275706 00000 n 0000275811 00000 n 0000275916 00000 n 0000276021 00000 n 0000276126 00000 n 0000276230 00000 n 0000276335 00000 n 0000276440 00000 n 0000276545 00000 n 0000276650 00000 n 0000276755 00000 n 0000276860 00000 n 0000276964 00000 n 0000277069 00000 n 0000277174 00000 n 0000277279 00000 n 0000277384 00000 n 0000277489 00000 n 0000277594 00000 n 0000277699 00000 n 0000277804 00000 n 0000277909 00000 n 0000278014 00000 n 0000278118 00000 n 0000278223 00000 n 0000278328 00000 n 0000278433 00000 n 0000278538 00000 n 0000278643 00000 n 0000278748 00000 n 0000278853 00000 n 0000278958 00000 n 0000279063 00000 n 0000279168 00000 n 0000279273 00000 n 0000279378 00000 n 0000279483 00000 n 0000279587 00000 n 0000279691 00000 n 0000279796 00000 n 0000279901 00000 n 0000280006 00000 n 0000280111 00000 n 0000280216 00000 n 0000280320 00000 n 0000280797 00000 n 0000280900 00000 n 0000281005 00000 n 0000281110 00000 n 0000281155 00000 n 0000281260 00000 n 0000281363 00000 n 0000281468 00000 n 0000281538 00000 n 0000281625 00000 n 0000281733 00000 n 0000281820 00000 n 0000281883 00000 n 0000281988 00000 n 0000282093 00000 n 0000282196 00000 n 0000282241 00000 n 0000282311 00000 n 0000282399 00000 n 0000282426 00000 n 0000282531 00000 n 0000282636 00000 n 0000282672 00000 n 0000282777 00000 n 0000282880 00000 n 0000282985 00000 n 0000283030 00000 n 0000283134 00000 n 0000283240 00000 n 0000283329 00000 n 0000283435 00000 n 0000283522 00000 n 0000283622 00000 n 0000283711 00000 n 0000283806 00000 n 0000283895 00000 n 0000283990 00000 n 0000284078 00000 n 0000284173 00000 n 0000284262 00000 n 0000284343 00000 n 0000284447 00000 n 0000284552 00000 n 0000284656 00000 n 0000284759 00000 n 0000284864 00000 n 0000284927 00000 n 0000285030 00000 n 0000285134 00000 n 0000285170 00000 n 0000285275 00000 n 0000285380 00000 n 0000285416 00000 n 0000285521 00000 n 0000285626 00000 n 0000285662 00000 n 0000285767 00000 n 0000285794 00000 n 0000285898 00000 n 0000286003 00000 n 0000286106 00000 n 0000286209 00000 n 0000286312 00000 n 0000286375 00000 n 0000286480 00000 n 0000286507 00000 n 0000286611 00000 n 0000286694 00000 n 0000286783 00000 n 0000286866 00000 n 0000286953 00000 n 0000286998 00000 n 0000287103 00000 n 0000287130 00000 n 0000287235 00000 n 0000287340 00000 n 0000287444 00000 n 0000287489 00000 n 0000287594 00000 n 0000287683 00000 n 0000287772 00000 n 0000287808 00000 n 0000287890 00000 n 0000287979 00000 n 0000288084 00000 n 0000288188 00000 n 0000288259 00000 n 0000288347 00000 n 0000288401 00000 n 0000288504 00000 n 0000288531 00000 n 0000288634 00000 n 0000288661 00000 n 0000288766 00000 n 0000288793 00000 n 0000288898 00000 n 0000288925 00000 n 0000289030 00000 n 0000289057 00000 n 0000289162 00000 n 0000289267 00000 n 0000289303 00000 n 0000289407 00000 n 0000289512 00000 n 0000289548 00000 n 0000289652 00000 n 0000289679 00000 n 0000289784 00000 n 0000289888 00000 n 0000289924 00000 n 0000290029 00000 n 0000290132 00000 n 0000290236 00000 n 0000290341 00000 n 0000290446 00000 n 0000290509 00000 n 0000290613 00000 n 0000290640 00000 n 0000290745 00000 n 0000290848 00000 n 0000290884 00000 n 0000290989 00000 n 0000291041 00000 n 0000291129 00000 n 0000291196 00000 n 0000291285 00000 n 0000291330 00000 n 0000291435 00000 n 0000291540 00000 n 0000291645 00000 n 0000291750 00000 n 0000291853 00000 n 0000291916 00000 n 0000292021 00000 n 0000292113 00000 n 0000292202 00000 n 0000292307 00000 n 0000292411 00000 n 0000292516 00000 n 0000292579 00000 n 0000292682 00000 n 0000292787 00000 n 0000292892 00000 n 0000292995 00000 n 0000293100 00000 n 0000293205 00000 n 0000293309 00000 n 0000293413 00000 n 0000293515 00000 n 0000293614 00000 n 0000293719 00000 n 0000293822 00000 n 0000293927 00000 n 0000294032 00000 n 0000294136 00000 n 0000294199 00000 n 0000294304 00000 n 0000294409 00000 n 0000294445 00000 n 0000294549 00000 n 0000294654 00000 n 0000294690 00000 n 0000294795 00000 n 0000294822 00000 n 0000294927 00000 n 0000294954 00000 n 0000295058 00000 n 0000295085 00000 n 0000295189 00000 n 0000295294 00000 n 0000295330 00000 n 0000295434 00000 n 0000295539 00000 n 0000295575 00000 n 0000295679 00000 n 0000295706 00000 n 0000295810 00000 n 0000295837 00000 n 0000295942 00000 n 0000296046 00000 n 0000296082 00000 n 0000296186 00000 n 0000296290 00000 n 0000296326 00000 n 0000296430 00000 n 0000296534 00000 n 0000296639 00000 n 0000296744 00000 n 0000296849 00000 n 0000296953 00000 n 0000297058 00000 n 0000297163 00000 n 0000297268 00000 n 0000297373 00000 n 0000297478 00000 n 0000297583 00000 n 0000297687 00000 n 0000297792 00000 n 0000297897 00000 n 0000298001 00000 n 0000298106 00000 n 0000298211 00000 n 0000298316 00000 n 0000298421 00000 n 0000298526 00000 n 0000298576 00000 n 0000298663 00000 n 0000298728 00000 n 0000298817 00000 n 0000298872 00000 n 0000298959 00000 n 0000299032 00000 n 0000299119 00000 n 0000299362 00000 n 0000299444 00000 n 0000299533 00000 n 0000299616 00000 n 0000299703 00000 n 0000299739 00000 n 0000299793 00000 n 0000299882 00000 n 0000300026 00000 n 0000300115 00000 n 0000300151 00000 n 0000300217 00000 n 0000300306 00000 n 0000300379 00000 n 0000300468 00000 n 0000300559 00000 n 0000300647 00000 n 0000300725 00000 n 0000300814 00000 n 0000300882 00000 n 0000300971 00000 n 0000301065 00000 n 0000301150 00000 n 0000301222 00000 n 0000301293 00000 n 0000301382 00000 n 0000301436 00000 n 0000301525 00000 n 0000301561 00000 n 0000301691 00000 n 0000301780 00000 n 0000301807 00000 n 0000301911 00000 n 0000302015 00000 n 0000302120 00000 n 0000302225 00000 n 0000302330 00000 n 0000302435 00000 n 0000302538 00000 n 0000302643 00000 n 0000302748 00000 n 0000302851 00000 n 0000302954 00000 n 0000303071 00000 n 0000303175 00000 n 0000303202 00000 n 0000303307 00000 n 0000303361 00000 n 0000303448 00000 n 0000303484 00000 n 0000303588 00000 n 0000303692 00000 n 0000303797 00000 n 0000303902 00000 n 0000304007 00000 n 0000304112 00000 n 0000304216 00000 n 0000304321 00000 n 0000304426 00000 n 0000304531 00000 n 0000304636 00000 n 0000304741 00000 n 0000304846 00000 n 0000304951 00000 n 0000305056 00000 n 0000305161 00000 n 0000305266 00000 n 0000305371 00000 n 0000305476 00000 n 0000305581 00000 n 0000305686 00000 n 0000305791 00000 n 0000305896 00000 n 0000306001 00000 n 0000306106 00000 n 0000306211 00000 n 0000306316 00000 n 0000306421 00000 n 0000306525 00000 n 0000306630 00000 n 0000306735 00000 n 0000306840 00000 n 0000306945 00000 n 0000307049 00000 n 0000307154 00000 n 0000307259 00000 n 0000307363 00000 n 0000307468 00000 n 0000307573 00000 n 0000307677 00000 n 0000307782 00000 n 0000307887 00000 n 0000307992 00000 n 0000308043 00000 n 0000308132 00000 n 0000308546 00000 n 0000308605 00000 n 0000308694 00000 n 0000308721 00000 n 0000308806 00000 n 0000308895 00000 n 0000308922 00000 n 0000309027 00000 n 0000309054 00000 n 0000309159 00000 n 0000309263 00000 n 0000309368 00000 n 0000309413 00000 n 0000309516 00000 n 0000309543 00000 n 0000309648 00000 n 0000309752 00000 n 0000309788 00000 n 0000309892 00000 n 0000309997 00000 n 0000310101 00000 n 0000310206 00000 n 0000310311 00000 n 0000310415 00000 n 0000310520 00000 n 0000310625 00000 n 0000310729 00000 n 0000310834 00000 n 0000310939 00000 n 0000311044 00000 n 0000311149 00000 n 0000311254 00000 n 0000311359 00000 n 0000311463 00000 n 0000311568 00000 n 0000311673 00000 n 0000311777 00000 n 0000311829 00000 n 0000311918 00000 n 0000312023 00000 n 0000312128 00000 n 0000312224 00000 n 0000312311 00000 n 0000312405 00000 n 0000312492 00000 n 0000312726 00000 n 0000312831 00000 n 0000312936 00000 n 0000313041 00000 n 0000313145 00000 n 0000313250 00000 n 0000313313 00000 n 0000313418 00000 n 0000313445 00000 n 0000313549 00000 n 0000313653 00000 n 0000313757 00000 n 0000313802 00000 n 0000313880 00000 n 0000313967 00000 n 0000314028 00000 n 0000314117 00000 n 0000314153 00000 n 0000314257 00000 n 0000314362 00000 n 0000314467 00000 n 0000314572 00000 n 0000314677 00000 n 0000314782 00000 n 0000314886 00000 n 0000314991 00000 n 0000315096 00000 n 0000315201 00000 n 0000315306 00000 n 0000315411 00000 n 0000315516 00000 n 0000315621 00000 n 0000315726 00000 n 0000315831 00000 n 0000315936 00000 n 0000316041 00000 n 0000316146 00000 n 0000316251 00000 n 0000316356 00000 n 0000316461 00000 n 0000316566 00000 n 0000316671 00000 n 0000316776 00000 n 0000316881 00000 n 0000316986 00000 n 0000317091 00000 n 0000317196 00000 n 0000317301 00000 n 0000317406 00000 n 0000317460 00000 n 0000317549 00000 n 0000317620 00000 n 0000317709 00000 n 0000318024 00000 n 0000318128 00000 n 0000318232 00000 n 0000318337 00000 n 0000318442 00000 n 0000318547 00000 n 0000318651 00000 n 0000318756 00000 n 0000318861 00000 n 0000318966 00000 n 0000319071 00000 n 0000319176 00000 n 0000319281 00000 n 0000319386 00000 n 0000319491 00000 n 0000319596 00000 n 0000319701 00000 n 0000319806 00000 n 0000319911 00000 n 0000320016 00000 n 0000320121 00000 n 0000320226 00000 n 0000320331 00000 n 0000320436 00000 n 0000320504 00000 n 0000320592 00000 n 0000320826 00000 n 0000320931 00000 n 0000320958 00000 n 0000321062 00000 n 0000321166 00000 n 0000321271 00000 n 0000321376 00000 n 0000321481 00000 n 0000321586 00000 n 0000321691 00000 n 0000321796 00000 n 0000321901 00000 n 0000322005 00000 n 0000322110 00000 n 0000322215 00000 n 0000322319 00000 n 0000322424 00000 n 0000322529 00000 n 0000322634 00000 n 0000322739 00000 n 0000322844 00000 n 0000322949 00000 n 0000323054 00000 n 0000323159 00000 n 0000323264 00000 n 0000323369 00000 n 0000323473 00000 n 0000323577 00000 n 0000323681 00000 n 0000323786 00000 n 0000323891 00000 n 0000323996 00000 n 0000324101 00000 n 0000324205 00000 n 0000324310 00000 n 0000324415 00000 n 0000324520 00000 n 0000324625 00000 n 0000324730 00000 n 0000324835 00000 n 0000324939 00000 n 0000325044 00000 n 0000325149 00000 n 0000325254 00000 n 0000325359 00000 n 0000325464 00000 n 0000325569 00000 n 0000325674 00000 n 0000325778 00000 n 0000325882 00000 n 0000325987 00000 n 0000326092 00000 n 0000326197 00000 n 0000326301 00000 n 0000326404 00000 n 0000326507 00000 n 0000327002 00000 n 0000327072 00000 n 0000327161 00000 n 0000327188 00000 n 0000327250 00000 n 0000327336 00000 n 0000327363 00000 n 0000327466 00000 n 0000327571 00000 n 0000327674 00000 n 0000327719 00000 n 0000327823 00000 n 0000327850 00000 n 0000327955 00000 n 0000327982 00000 n 0000328085 00000 n 0000328112 00000 n 0000328216 00000 n 0000328243 00000 n 0000328347 00000 n 0000328452 00000 n 0000328557 00000 n 0000328661 00000 n 0000328766 00000 n 0000328871 00000 n 0000328976 00000 n 0000329081 00000 n 0000329186 00000 n 0000329291 00000 n 0000329396 00000 n 0000329501 00000 n 0000329606 00000 n 0000329711 00000 n 0000329816 00000 n 0000329921 00000 n 0000330025 00000 n 0000330130 00000 n 0000330235 00000 n 0000330340 00000 n 0000330445 00000 n 0000330550 00000 n 0000330655 00000 n 0000330760 00000 n 0000330994 00000 n 0000331098 00000 n 0000331125 00000 n 0000331230 00000 n 0000331334 00000 n 0000331370 00000 n 0000331474 00000 n 0000331579 00000 n 0000331684 00000 n 0000331789 00000 n 0000331893 00000 n 0000331998 00000 n 0000332103 00000 n 0000332208 00000 n 0000332313 00000 n 0000332418 00000 n 0000332523 00000 n 0000332628 00000 n 0000332754 00000 n 0000332858 00000 n 0000332962 00000 n 0000333067 00000 n 0000333172 00000 n 0000333277 00000 n 0000333382 00000 n 0000333487 00000 n 0000333592 00000 n 0000333697 00000 n 0000333802 00000 n 0000333906 00000 n 0000334011 00000 n 0000334116 00000 n 0000334221 00000 n 0000334326 00000 n 0000334431 00000 n 0000334536 00000 n 0000334641 00000 n 0000334746 00000 n 0000334851 00000 n 0000334956 00000 n 0000335061 00000 n 0000335166 00000 n 0000335271 00000 n 0000335376 00000 n 0000335481 00000 n 0000335585 00000 n 0000335690 00000 n 0000335795 00000 n 0000335900 00000 n 0000336005 00000 n 0000336110 00000 n 0000336215 00000 n 0000336319 00000 n 0000336424 00000 n 0000336529 00000 n 0000336634 00000 n 0000336739 00000 n 0000336844 00000 n 0000336949 00000 n 0000337054 00000 n 0000337158 00000 n 0000337263 00000 n 0000337368 00000 n 0000337473 00000 n 0000337578 00000 n 0000337682 00000 n 0000337787 00000 n 0000337892 00000 n 0000337997 00000 n 0000338101 00000 n 0000338203 00000 n 0000338306 00000 n 0000338801 00000 n 0000338906 00000 n 0000339011 00000 n 0000339116 00000 n 0000339220 00000 n 0000339325 00000 n 0000339430 00000 n 0000339535 00000 n 0000339640 00000 n 0000339745 00000 n 0000339850 00000 n 0000339954 00000 n 0000340059 00000 n 0000340164 00000 n 0000340269 00000 n 0000340374 00000 n 0000340479 00000 n 0000340584 00000 n 0000340689 00000 n 0000340794 00000 n 0000340898 00000 n 0000341003 00000 n 0000341108 00000 n 0000341213 00000 n 0000341318 00000 n 0000341422 00000 n 0000341527 00000 n 0000341632 00000 n 0000341737 00000 n 0000341842 00000 n 0000341947 00000 n 0000342235 00000 n 0000342311 00000 n 0000342400 00000 n 0000342427 00000 n 0000342497 00000 n 0000342584 00000 n 0000342611 00000 n 0000342699 00000 n 0000342788 00000 n 0000342876 00000 n 0000342964 00000 n 0000343000 00000 n 0000343070 00000 n 0000343157 00000 n 0000343184 00000 n 0000343289 00000 n 0000343392 00000 n 0000343428 00000 n 0000343533 00000 n 0000343560 00000 n 0000343665 00000 n 0000343692 00000 n 0000343796 00000 n 0000343901 00000 n 0000344005 00000 n 0000344110 00000 n 0000344164 00000 n 0000344243 00000 n 0000344331 00000 n 0000344358 00000 n 0000344463 00000 n 0000344490 00000 n 0000344564 00000 n 0000344652 00000 n 0000344679 00000 n 0000344784 00000 n 0000344811 00000 n 0000344865 00000 n 0000344954 00000 n 0000344981 00000 n 0000345086 00000 n 0000345113 00000 n 0000345217 00000 n 0000345244 00000 n 0000345347 00000 n 0000345452 00000 n 0000345488 00000 n 0000345591 00000 n 0000345618 00000 n 0000345721 00000 n 0000345748 00000 n 0000345821 00000 n 0000345908 00000 n 0000345935 00000 n 0000346008 00000 n 0000346097 00000 n 0000346124 00000 n 0000346197 00000 n 0000346286 00000 n 0000346313 00000 n 0000346386 00000 n 0000346475 00000 n 0000346502 00000 n 0000346605 00000 n 0000346709 00000 n 0000346813 00000 n 0000346917 00000 n 0000347021 00000 n 0000347125 00000 n 0000347229 00000 n 0000347287 00000 n 0000347376 00000 n 0000347466 00000 n 0000347570 00000 n 0000347675 00000 n 0000347780 00000 n 0000347885 00000 n 0000347990 00000 n 0000348095 00000 n 0000348200 00000 n 0000348304 00000 n 0000348409 00000 n 0000348513 00000 n 0000348618 00000 n 0000348723 00000 n 0000348828 00000 n 0000348933 00000 n 0000349038 00000 n 0000349143 00000 n 0000349248 00000 n 0000349353 00000 n 0000349458 00000 n 0000349563 00000 n 0000349668 00000 n 0000349773 00000 n 0000349878 00000 n 0000349983 00000 n 0000350088 00000 n 0000350193 00000 n 0000350298 00000 n 0000350403 00000 n 0000350507 00000 n 0000350612 00000 n 0000350717 00000 n 0000350822 00000 n 0000350927 00000 n 0000351031 00000 n 0000351135 00000 n 0000351240 00000 n 0000351345 00000 n 0000351450 00000 n 0000351555 00000 n 0000351659 00000 n 0000351764 00000 n 0000351869 00000 n 0000351974 00000 n 0000352079 00000 n 0000352184 00000 n 0000352289 00000 n 0000352394 00000 n 0000352499 00000 n 0000352604 00000 n 0000352709 00000 n 0000352813 00000 n 0000352916 00000 n 0000353019 00000 n 0000353514 00000 n 0000353619 00000 n 0000353724 00000 n 0000353829 00000 n 0000353934 00000 n 0000354039 00000 n 0000354144 00000 n 0000354249 00000 n 0000354354 00000 n 0000354459 00000 n 0000354564 00000 n 0000354669 00000 n 0000354774 00000 n 0000354879 00000 n 0000354984 00000 n 0000355089 00000 n 0000355194 00000 n 0000355299 00000 n 0000355404 00000 n 0000355509 00000 n 0000355614 00000 n 0000355719 00000 n 0000355824 00000 n 0000355929 00000 n 0000356034 00000 n 0000356138 00000 n 0000356243 00000 n 0000356348 00000 n 0000356453 00000 n 0000356558 00000 n 0000356663 00000 n 0000356768 00000 n 0000356873 00000 n 0000356978 00000 n 0000357082 00000 n 0000357187 00000 n 0000357292 00000 n 0000357397 00000 n 0000357501 00000 n 0000357606 00000 n 0000357711 00000 n 0000357816 00000 n 0000357921 00000 n 0000358026 00000 n 0000358131 00000 n 0000358233 00000 n 0000358656 00000 n 0000358726 00000 n 0000358813 00000 n 0000358840 00000 n 0000358945 00000 n 0000358972 00000 n 0000359038 00000 n 0000359125 00000 n 0000359152 00000 n 0000359257 00000 n 0000359362 00000 n 0000359398 00000 n 0000359503 00000 n 0000359606 00000 n 0000359642 00000 n 0000359747 00000 n 0000359774 00000 n 0000359879 00000 n 0000359906 00000 n 0000360011 00000 n 0000360116 00000 n 0000360152 00000 n 0000360257 00000 n 0000360284 00000 n 0000360388 00000 n 0000360415 00000 n 0000360520 00000 n 0000360547 00000 n 0000360652 00000 n 0000360679 00000 n 0000360779 00000 n 0000360867 00000 n 0000360894 00000 n 0000360998 00000 n 0000361025 00000 n 0000361117 00000 n 0000361206 00000 n 0000361233 00000 n 0000361336 00000 n 0000361363 00000 n 0000361466 00000 n 0000361493 00000 n 0000361597 00000 n 0000361624 00000 n 0000361729 00000 n 0000361809 00000 n 0000361898 00000 n 0000361934 00000 n 0000362039 00000 n 0000362066 00000 n 0000362170 00000 n 0000362197 00000 n 0000362300 00000 n 0000362403 00000 n 0000362439 00000 n 0000362542 00000 n 0000362569 00000 n 0000362674 00000 n 0000362701 00000 n 0000362805 00000 n 0000362910 00000 n 0000363015 00000 n 0000363120 00000 n 0000363225 00000 n 0000363330 00000 n 0000363435 00000 n 0000363540 00000 n 0000363645 00000 n 0000363749 00000 n 0000363854 00000 n 0000363959 00000 n 0000364063 00000 n 0000364168 00000 n 0000364273 00000 n 0000364378 00000 n 0000364483 00000 n 0000364588 00000 n 0000364693 00000 n 0000364798 00000 n 0000364903 00000 n 0000365008 00000 n 0000365113 00000 n 0000365218 00000 n 0000365323 00000 n 0000365428 00000 n 0000365533 00000 n 0000365637 00000 n 0000365742 00000 n 0000365847 00000 n 0000365951 00000 n 0000366055 00000 n 0000366159 00000 n 0000366264 00000 n 0000366369 00000 n 0000366474 00000 n 0000366579 00000 n 0000366684 00000 n 0000366789 00000 n 0000366894 00000 n 0000366999 00000 n 0000367103 00000 n 0000367207 00000 n 0000367312 00000 n 0000367416 00000 n 0000367839 00000 n 0000367909 00000 n 0000367998 00000 n 0000368025 00000 n 0000368130 00000 n 0000368233 00000 n 0000368269 00000 n 0000368374 00000 n 0000368401 00000 n 0000368506 00000 n 0000368533 00000 n 0000368637 00000 n 0000368742 00000 n 0000368778 00000 n 0000368882 00000 n 0000368987 00000 n 0000369023 00000 n 0000369126 00000 n 0000369153 00000 n 0000369224 00000 n 0000369313 00000 n 0000369340 00000 n 0000369444 00000 n 0000369548 00000 n 0000369652 00000 n 0000369756 00000 n 0000369861 00000 n 0000369966 00000 n 0000370071 00000 n 0000370176 00000 n 0000370281 00000 n 0000370386 00000 n 0000370491 00000 n 0000370596 00000 n 0000370700 00000 n 0000370805 00000 n 0000370910 00000 n 0000371015 00000 n 0000371120 00000 n 0000371225 00000 n 0000371330 00000 n 0000371434 00000 n 0000371538 00000 n 0000371642 00000 n 0000371747 00000 n 0000371852 00000 n 0000371957 00000 n 0000372062 00000 n 0000372167 00000 n 0000372272 00000 n 0000372376 00000 n 0000372480 00000 n 0000372585 00000 n 0000372690 00000 n 0000372795 00000 n 0000372900 00000 n 0000373005 00000 n 0000373110 00000 n 0000373215 00000 n 0000373320 00000 n 0000373425 00000 n 0000373530 00000 n 0000373635 00000 n 0000373740 00000 n 0000373845 00000 n 0000373950 00000 n 0000374055 00000 n 0000374160 00000 n 0000374264 00000 n 0000374368 00000 n 0000374472 00000 n 0000374931 00000 n 0000375001 00000 n 0000375089 00000 n 0000375116 00000 n 0000375219 00000 n 0000375246 00000 n 0000375351 00000 n 0000375378 00000 n 0000375431 00000 n 0000375520 00000 n 0000375625 00000 n 0000375730 00000 n 0000375775 00000 n 0000375880 00000 n 0000375907 00000 n 0000375943 00000 n 0000375979 00000 n 0000406808 00000 n 0000406853 00000 n 0000406898 00000 n 0000406943 00000 n 0000406988 00000 n 0000407033 00000 n 0000407078 00000 n 0000407123 00000 n 0000407168 00000 n 0000407213 00000 n 0000407258 00000 n 0000407303 00000 n 0000407348 00000 n 0000407393 00000 n 0000407438 00000 n 0000407483 00000 n 0000407528 00000 n 0000407573 00000 n 0000407618 00000 n 0000407663 00000 n 0000407708 00000 n 0000407753 00000 n 0000407798 00000 n 0000407843 00000 n 0000407888 00000 n 0000407933 00000 n 0000407978 00000 n 0000408023 00000 n 0000408068 00000 n 0000408113 00000 n 0000408158 00000 n 0000408203 00000 n 0000408248 00000 n 0000408293 00000 n 0000408338 00000 n 0000408383 00000 n 0000408428 00000 n 0000408473 00000 n 0000408518 00000 n 0000408563 00000 n 0000408608 00000 n 0000408653 00000 n 0000408698 00000 n 0000408743 00000 n 0000408788 00000 n 0000408833 00000 n 0000408878 00000 n 0000408923 00000 n 0000408968 00000 n 0000409013 00000 n 0000409058 00000 n 0000409103 00000 n 0000409148 00000 n 0000409193 00000 n 0000409238 00000 n 0000409283 00000 n 0000409328 00000 n 0000409373 00000 n 0000409418 00000 n 0000409463 00000 n 0000409508 00000 n 0000409553 00000 n 0000409598 00000 n 0000409643 00000 n 0000409688 00000 n 0000409733 00000 n 0000409778 00000 n 0000409823 00000 n 0000409868 00000 n 0000409913 00000 n 0000409958 00000 n 0000410003 00000 n 0000410048 00000 n 0000410093 00000 n 0000410138 00000 n 0000410183 00000 n 0000410228 00000 n 0000410273 00000 n 0000410318 00000 n 0000410363 00000 n 0000410408 00000 n 0000410453 00000 n 0000410498 00000 n 0000410543 00000 n 0000410588 00000 n 0000410633 00000 n 0000410678 00000 n 0000410723 00000 n 0000410768 00000 n 0000410813 00000 n 0000410858 00000 n 0000410903 00000 n 0000410948 00000 n 0000410993 00000 n 0000411038 00000 n 0000411083 00000 n 0000411128 00000 n 0000411173 00000 n 0000411218 00000 n 0000411263 00000 n 0000411308 00000 n 0000411353 00000 n 0000411398 00000 n 0000411443 00000 n 0000411488 00000 n 0000411533 00000 n 0000411578 00000 n 0000411623 00000 n 0000411668 00000 n 0000411713 00000 n 0000411758 00000 n 0000411803 00000 n 0000411848 00000 n 0000411893 00000 n 0000411938 00000 n 0000411983 00000 n 0000412028 00000 n 0000412073 00000 n 0000412118 00000 n 0000412163 00000 n 0000412208 00000 n 0000412253 00000 n 0000412298 00000 n 0000412343 00000 n 0000412388 00000 n 0000412433 00000 n 0000412478 00000 n 0000412523 00000 n 0000412568 00000 n 0000412613 00000 n 0000412658 00000 n 0000412703 00000 n 0000412748 00000 n 0000412793 00000 n 0000412838 00000 n 0000412883 00000 n 0000412928 00000 n 0000412973 00000 n 0000413018 00000 n 0000413063 00000 n 0000413108 00000 n 0000413153 00000 n 0000413198 00000 n 0000413243 00000 n 0000413288 00000 n 0000413333 00000 n 0000413378 00000 n 0000413423 00000 n 0000413468 00000 n 0000413513 00000 n 0000413558 00000 n 0000413603 00000 n 0000413648 00000 n 0000413693 00000 n 0000413738 00000 n 0000413783 00000 n 0000413828 00000 n 0000413873 00000 n 0000413918 00000 n 0000413963 00000 n 0000414008 00000 n 0000414053 00000 n 0000414098 00000 n 0000414143 00000 n 0000414188 00000 n 0000414233 00000 n 0000414278 00000 n 0000414323 00000 n 0000414368 00000 n 0000414413 00000 n 0000414458 00000 n 0000414503 00000 n 0000414548 00000 n 0000414593 00000 n 0000414638 00000 n 0000414683 00000 n 0000414728 00000 n 0000414773 00000 n 0000414818 00000 n 0000414863 00000 n 0000414908 00000 n 0000414953 00000 n 0000414998 00000 n 0000415043 00000 n 0000415088 00000 n 0000415133 00000 n 0000415178 00000 n 0000415223 00000 n 0000415268 00000 n 0000415313 00000 n 0000415358 00000 n 0000415403 00000 n 0000415448 00000 n 0000415493 00000 n 0000415538 00000 n 0000415583 00000 n 0000415628 00000 n 0000415673 00000 n 0000415718 00000 n 0000415763 00000 n 0000415808 00000 n 0000415853 00000 n 0000415898 00000 n 0000415943 00000 n 0000415988 00000 n 0000416033 00000 n 0000416078 00000 n 0000416123 00000 n 0000416168 00000 n 0000416213 00000 n 0000416258 00000 n 0000416303 00000 n 0000416348 00000 n 0000416393 00000 n 0000416438 00000 n 0000416483 00000 n 0000416528 00000 n 0000416573 00000 n 0000416618 00000 n 0000416663 00000 n 0000416708 00000 n 0000416753 00000 n 0000416798 00000 n 0000416843 00000 n 0000416888 00000 n 0000416933 00000 n 0000416978 00000 n 0000417023 00000 n 0000417068 00000 n 0000417113 00000 n 0000417158 00000 n 0000417203 00000 n 0000417248 00000 n 0000417293 00000 n 0000417338 00000 n 0000417383 00000 n 0000417428 00000 n 0000417473 00000 n 0000417518 00000 n 0000417563 00000 n 0000417608 00000 n 0000417653 00000 n 0000417698 00000 n 0000417742 00000 n 0000417787 00000 n 0000417832 00000 n 0000417877 00000 n 0000417922 00000 n 0000417967 00000 n 0000418012 00000 n 0000418056 00000 n 0000418101 00000 n 0000418146 00000 n 0000418191 00000 n 0000418236 00000 n 0000418281 00000 n 0000418326 00000 n 0000418371 00000 n 0000418416 00000 n 0000418461 00000 n 0000418506 00000 n 0000418551 00000 n 0000418596 00000 n 0000418641 00000 n 0000418686 00000 n 0000418731 00000 n 0000418776 00000 n 0000418821 00000 n 0000418866 00000 n 0000418911 00000 n 0000418956 00000 n 0000419001 00000 n 0000419046 00000 n 0000419091 00000 n 0000419136 00000 n 0000419181 00000 n 0000419226 00000 n 0000419271 00000 n 0000419316 00000 n 0000419361 00000 n 0000419406 00000 n 0000419451 00000 n 0000419496 00000 n 0000419541 00000 n 0000419586 00000 n 0000419631 00000 n 0000419676 00000 n 0000419721 00000 n 0000419766 00000 n 0000419811 00000 n 0000419856 00000 n 0000419901 00000 n 0000419946 00000 n 0000419991 00000 n 0000420036 00000 n 0000420081 00000 n 0000420126 00000 n 0000420171 00000 n 0000420216 00000 n 0000420261 00000 n 0000420306 00000 n 0000420350 00000 n 0000420395 00000 n 0000420440 00000 n 0000420485 00000 n 0000420530 00000 n 0000420575 00000 n 0000420620 00000 n 0000420665 00000 n 0000420710 00000 n 0000420755 00000 n 0000420800 00000 n 0000420845 00000 n 0000420890 00000 n 0000420935 00000 n 0000420980 00000 n 0000421025 00000 n 0000421070 00000 n 0000421115 00000 n 0000421160 00000 n 0000421205 00000 n 0000421250 00000 n 0000421295 00000 n 0000421340 00000 n 0000421385 00000 n 0000421430 00000 n 0000421475 00000 n 0000421520 00000 n 0000421565 00000 n 0000421610 00000 n 0000421655 00000 n 0000421700 00000 n 0000421745 00000 n 0000421790 00000 n 0000421835 00000 n 0000421880 00000 n 0000421925 00000 n 0000421970 00000 n 0000422015 00000 n 0000422060 00000 n 0000422105 00000 n 0000422150 00000 n 0000422195 00000 n 0000422240 00000 n 0000422285 00000 n 0000422330 00000 n 0000422375 00000 n 0000422420 00000 n 0000422465 00000 n 0000422510 00000 n 0000422555 00000 n 0000422600 00000 n 0000422645 00000 n 0000422690 00000 n 0000422735 00000 n 0000422780 00000 n 0000422825 00000 n 0000422870 00000 n 0000422915 00000 n 0000422960 00000 n 0000423005 00000 n 0000423050 00000 n 0000423095 00000 n 0000423140 00000 n 0000423185 00000 n 0000423230 00000 n 0000423275 00000 n 0000423320 00000 n 0000423365 00000 n 0000423410 00000 n 0000423455 00000 n 0000423500 00000 n 0000423545 00000 n 0000423590 00000 n 0000423635 00000 n 0000423680 00000 n 0000423725 00000 n 0000423770 00000 n 0000423815 00000 n 0000423860 00000 n 0000423905 00000 n 0000423950 00000 n 0000423995 00000 n 0000424040 00000 n 0000424085 00000 n 0000424130 00000 n 0000424175 00000 n 0000424220 00000 n 0000424265 00000 n 0000424310 00000 n 0000424355 00000 n 0000424400 00000 n 0000424445 00000 n 0000424490 00000 n 0000424535 00000 n 0000424580 00000 n 0000424625 00000 n 0000424670 00000 n 0000424715 00000 n 0000424760 00000 n 0000424805 00000 n 0000424850 00000 n 0000424895 00000 n 0000424940 00000 n 0000424985 00000 n 0000425030 00000 n 0000425075 00000 n 0000425120 00000 n 0000425165 00000 n 0000425210 00000 n 0000425255 00000 n 0000425300 00000 n 0000425345 00000 n 0000425390 00000 n 0000425435 00000 n 0000425480 00000 n 0000425525 00000 n 0000425570 00000 n 0000425615 00000 n 0000425660 00000 n 0000425705 00000 n 0000425750 00000 n 0000425795 00000 n 0000425840 00000 n 0000425885 00000 n 0000425930 00000 n 0000425975 00000 n 0000426020 00000 n 0000426065 00000 n 0000426110 00000 n 0000426155 00000 n 0000426200 00000 n 0000426245 00000 n 0000426290 00000 n 0000426335 00000 n 0000426380 00000 n 0000426425 00000 n 0000426470 00000 n 0000426515 00000 n 0000426560 00000 n 0000426605 00000 n 0000426650 00000 n 0000426695 00000 n 0000426740 00000 n 0000426785 00000 n 0000426830 00000 n 0000426875 00000 n 0000426920 00000 n 0000426965 00000 n 0000427010 00000 n 0000427055 00000 n 0000427100 00000 n 0000427145 00000 n 0000427190 00000 n 0000427235 00000 n 0000427280 00000 n 0000427325 00000 n 0000427370 00000 n 0000427415 00000 n 0000427460 00000 n 0000427505 00000 n 0000427550 00000 n 0000427595 00000 n 0000427640 00000 n 0000427685 00000 n 0000427730 00000 n 0000427775 00000 n 0000427820 00000 n 0000427865 00000 n 0000427910 00000 n 0000427955 00000 n 0000428000 00000 n 0000428045 00000 n 0000428090 00000 n 0000428135 00000 n 0000428180 00000 n 0000428225 00000 n 0000428270 00000 n 0000428315 00000 n 0000428360 00000 n 0000428405 00000 n 0000428450 00000 n 0000428495 00000 n 0000428540 00000 n 0000428585 00000 n 0000428630 00000 n 0000428675 00000 n 0000428720 00000 n 0000428765 00000 n 0000428810 00000 n 0000428855 00000 n 0000428900 00000 n 0000428945 00000 n 0000428990 00000 n 0000429035 00000 n 0000429080 00000 n 0000429125 00000 n 0000429170 00000 n 0000429215 00000 n 0000429260 00000 n 0000429305 00000 n 0000429350 00000 n 0000429395 00000 n 0000429440 00000 n 0000429485 00000 n 0000429530 00000 n 0000429575 00000 n 0000429620 00000 n 0000429665 00000 n 0000429710 00000 n 0000429755 00000 n 0000429800 00000 n 0000429845 00000 n 0000429890 00000 n 0000429935 00000 n 0000429980 00000 n 0000430025 00000 n 0000430070 00000 n 0000430115 00000 n 0000430160 00000 n 0000430205 00000 n 0000430250 00000 n 0000430295 00000 n 0000430340 00000 n 0000430385 00000 n 0000430430 00000 n 0000430475 00000 n 0000430520 00000 n 0000430565 00000 n 0000430610 00000 n 0000430655 00000 n 0000430700 00000 n 0000430745 00000 n 0000430790 00000 n 0000430835 00000 n 0000430880 00000 n 0000430925 00000 n 0000430970 00000 n 0000431015 00000 n 0000431060 00000 n 0000431105 00000 n 0000431150 00000 n 0000431195 00000 n 0000431240 00000 n 0000431285 00000 n 0000431330 00000 n 0000431375 00000 n 0000431420 00000 n 0000431465 00000 n 0000431510 00000 n 0000431555 00000 n 0000431600 00000 n 0000431645 00000 n 0000431690 00000 n 0000431735 00000 n 0000431780 00000 n 0000431825 00000 n 0000431870 00000 n 0000431915 00000 n 0000431960 00000 n 0000432005 00000 n 0000432050 00000 n 0000432095 00000 n 0000432140 00000 n 0000432185 00000 n 0000432230 00000 n 0000432275 00000 n 0000432320 00000 n 0000432365 00000 n 0000432410 00000 n 0000432455 00000 n 0000432500 00000 n 0000432545 00000 n 0000432590 00000 n 0000432635 00000 n 0000432680 00000 n 0000432725 00000 n 0000432770 00000 n 0000432815 00000 n 0000432860 00000 n 0000432905 00000 n 0000432950 00000 n 0000432995 00000 n 0000433040 00000 n 0000433085 00000 n 0000433130 00000 n 0000433175 00000 n 0000433220 00000 n 0000433265 00000 n 0000433310 00000 n 0000433355 00000 n 0000433400 00000 n 0000433445 00000 n 0000433490 00000 n 0000433535 00000 n 0000433580 00000 n 0000433625 00000 n 0000433670 00000 n 0000433715 00000 n 0000433760 00000 n 0000433805 00000 n 0000433850 00000 n 0000433895 00000 n 0000433940 00000 n 0000433985 00000 n 0000434030 00000 n 0000434075 00000 n 0000434120 00000 n 0000434165 00000 n 0000434210 00000 n 0000434255 00000 n 0000434300 00000 n 0000434345 00000 n 0000434390 00000 n 0000434435 00000 n 0000434480 00000 n 0000434525 00000 n 0000434570 00000 n 0000434615 00000 n 0000434660 00000 n 0000434705 00000 n 0000434750 00000 n 0000434795 00000 n 0000434840 00000 n 0000434885 00000 n 0000434930 00000 n 0000434975 00000 n 0000435020 00000 n 0000435065 00000 n 0000435110 00000 n 0000435155 00000 n 0000435200 00000 n 0000435245 00000 n 0000435290 00000 n 0000435335 00000 n 0000435380 00000 n 0000435425 00000 n 0000435470 00000 n 0000435515 00000 n 0000435560 00000 n 0000435605 00000 n 0000435650 00000 n 0000435695 00000 n 0000435740 00000 n 0000435785 00000 n 0000435830 00000 n 0000435875 00000 n 0000435920 00000 n 0000435965 00000 n 0000436010 00000 n 0000436055 00000 n 0000436100 00000 n 0000436145 00000 n 0000436190 00000 n 0000436235 00000 n 0000436280 00000 n 0000436325 00000 n 0000436370 00000 n 0000436415 00000 n 0000436460 00000 n 0000436505 00000 n 0000436550 00000 n 0000436595 00000 n 0000436640 00000 n 0000436685 00000 n 0000436730 00000 n 0000436775 00000 n 0000436820 00000 n 0000436865 00000 n 0000436910 00000 n 0000436955 00000 n 0000437000 00000 n 0000437045 00000 n 0000437090 00000 n 0000437135 00000 n 0000437180 00000 n 0000437225 00000 n 0000437270 00000 n 0000437315 00000 n 0000437360 00000 n 0000437405 00000 n 0000437450 00000 n 0000437495 00000 n 0000437540 00000 n 0000437585 00000 n 0000437630 00000 n 0000437675 00000 n 0000437720 00000 n 0000437765 00000 n 0000437810 00000 n 0000437855 00000 n 0000437900 00000 n 0000437945 00000 n 0000437990 00000 n 0000438035 00000 n 0000438080 00000 n 0000438125 00000 n 0000438170 00000 n 0000438215 00000 n 0000438260 00000 n 0000438305 00000 n 0000438350 00000 n 0000438395 00000 n 0000438440 00000 n 0000438485 00000 n 0000438530 00000 n 0000438575 00000 n 0000438620 00000 n 0000438665 00000 n 0000438710 00000 n 0000438755 00000 n 0000438800 00000 n 0000438845 00000 n 0000438890 00000 n 0000438935 00000 n 0000438980 00000 n 0000439025 00000 n 0000439070 00000 n 0000439115 00000 n 0000439160 00000 n 0000439205 00000 n 0000439250 00000 n 0000439295 00000 n 0000439340 00000 n 0000439385 00000 n 0000439430 00000 n 0000439475 00000 n 0000439520 00000 n 0000439565 00000 n 0000439610 00000 n 0000439655 00000 n 0000439700 00000 n 0000439745 00000 n 0000439790 00000 n 0000439835 00000 n 0000439880 00000 n 0000439925 00000 n 0000439970 00000 n 0000440015 00000 n 0000440060 00000 n 0000440105 00000 n 0000440150 00000 n 0000440195 00000 n 0000440240 00000 n 0000440285 00000 n 0000440330 00000 n 0000440375 00000 n 0000440420 00000 n 0000440465 00000 n 0000440510 00000 n 0000440555 00000 n 0000440599 00000 n 0000440644 00000 n 0000440689 00000 n 0000440734 00000 n 0000440779 00000 n 0000440824 00000 n 0000440869 00000 n 0000440914 00000 n 0000440959 00000 n 0000441004 00000 n 0000441049 00000 n 0000441094 00000 n 0000441139 00000 n 0000441184 00000 n 0000441229 00000 n 0000441274 00000 n 0000441319 00000 n 0000441364 00000 n 0000441409 00000 n 0000441453 00000 n 0000441498 00000 n 0000441543 00000 n 0000441588 00000 n 0000441633 00000 n 0000441678 00000 n 0000441723 00000 n 0000441768 00000 n 0000441813 00000 n 0000441858 00000 n 0000441903 00000 n 0000441948 00000 n 0000441993 00000 n 0000442038 00000 n 0000442083 00000 n 0000442128 00000 n 0000442173 00000 n 0000442218 00000 n 0000442263 00000 n 0000442308 00000 n 0000442353 00000 n 0000442398 00000 n 0000442443 00000 n 0000442488 00000 n 0000442533 00000 n 0000442578 00000 n 0000442623 00000 n 0000442668 00000 n 0000442713 00000 n 0000442758 00000 n 0000442803 00000 n 0000442848 00000 n 0000442893 00000 n 0000442938 00000 n 0000442983 00000 n 0000443028 00000 n 0000443073 00000 n 0000443118 00000 n 0000443163 00000 n 0000443208 00000 n 0000443253 00000 n 0000443298 00000 n 0000443343 00000 n 0000443388 00000 n 0000443433 00000 n 0000443478 00000 n 0000443523 00000 n 0000443568 00000 n 0000443613 00000 n 0000443658 00000 n 0000443703 00000 n 0000443748 00000 n 0000443793 00000 n 0000443838 00000 n 0000443883 00000 n 0000443928 00000 n 0000443973 00000 n 0000444018 00000 n 0000444063 00000 n 0000444108 00000 n 0000444153 00000 n 0000444198 00000 n 0000444243 00000 n 0000444288 00000 n 0000444333 00000 n 0000444378 00000 n 0000444423 00000 n 0000444468 00000 n 0000444513 00000 n 0000444558 00000 n 0000444603 00000 n 0000444648 00000 n 0000444693 00000 n 0000444738 00000 n 0000444783 00000 n 0000444828 00000 n 0000444873 00000 n 0000444918 00000 n 0000444963 00000 n 0000445008 00000 n 0000445053 00000 n 0000445098 00000 n 0000445143 00000 n 0000445188 00000 n 0000445233 00000 n 0000445278 00000 n 0000445323 00000 n 0000445368 00000 n 0000445413 00000 n 0000445458 00000 n 0000445503 00000 n 0000445548 00000 n 0000445593 00000 n 0000445638 00000 n 0000445683 00000 n 0000445728 00000 n 0000445773 00000 n 0000445818 00000 n 0000445863 00000 n 0000445908 00000 n 0000445953 00000 n 0000445998 00000 n 0000446043 00000 n 0000446088 00000 n 0000446133 00000 n 0000446178 00000 n 0000446223 00000 n 0000446268 00000 n 0000446313 00000 n 0000446358 00000 n 0000446403 00000 n 0000446448 00000 n 0000446493 00000 n 0000446538 00000 n 0000446583 00000 n 0000446628 00000 n 0000446673 00000 n 0000446718 00000 n 0000446763 00000 n 0000446808 00000 n 0000446853 00000 n 0000446898 00000 n 0000446943 00000 n 0000446988 00000 n 0000447033 00000 n 0000447078 00000 n 0000447123 00000 n 0000447168 00000 n 0000447213 00000 n 0000447258 00000 n 0000447303 00000 n 0000447348 00000 n 0000447393 00000 n 0000447438 00000 n 0000447483 00000 n 0000447528 00000 n 0000447573 00000 n 0000447618 00000 n 0000447663 00000 n 0000447708 00000 n 0000447753 00000 n 0000447798 00000 n 0000447843 00000 n 0000447888 00000 n 0000447933 00000 n 0000447978 00000 n 0000448023 00000 n 0000448068 00000 n 0000448113 00000 n 0000448158 00000 n 0000448203 00000 n 0000448248 00000 n 0000448293 00000 n 0000448338 00000 n 0000448383 00000 n 0000448428 00000 n 0000448473 00000 n 0000448518 00000 n 0000448563 00000 n 0000448608 00000 n 0000448653 00000 n 0000448698 00000 n 0000448743 00000 n 0000448788 00000 n 0000448833 00000 n 0000448878 00000 n 0000448923 00000 n 0000448968 00000 n 0000449013 00000 n 0000449058 00000 n 0000449103 00000 n 0000449148 00000 n 0000449193 00000 n 0000449238 00000 n 0000449283 00000 n 0000449328 00000 n 0000449373 00000 n 0000449418 00000 n 0000449463 00000 n 0000449508 00000 n 0000449553 00000 n 0000449598 00000 n 0000449643 00000 n 0000449688 00000 n 0000449733 00000 n 0000449778 00000 n 0000449823 00000 n 0000449868 00000 n 0000449913 00000 n 0000449958 00000 n 0000450003 00000 n 0000450048 00000 n 0000450093 00000 n 0000450138 00000 n 0000450183 00000 n 0000450228 00000 n 0000450273 00000 n 0000450318 00000 n 0000450363 00000 n 0000450408 00000 n 0000450453 00000 n 0000450498 00000 n 0000450543 00000 n 0000450588 00000 n 0000450633 00000 n 0000450678 00000 n 0000450723 00000 n 0000450768 00000 n 0000450813 00000 n 0000450858 00000 n 0000450903 00000 n 0000450948 00000 n 0000450993 00000 n 0000451038 00000 n 0000451083 00000 n 0000451128 00000 n 0000451173 00000 n 0000451218 00000 n 0000451263 00000 n 0000451308 00000 n 0000451353 00000 n 0000451398 00000 n 0000451443 00000 n 0000451488 00000 n 0000451533 00000 n 0000451578 00000 n 0000451623 00000 n 0000451668 00000 n 0000451713 00000 n 0000451758 00000 n 0000451803 00000 n 0000451848 00000 n 0000451893 00000 n 0000451938 00000 n 0000451983 00000 n 0000452028 00000 n 0000452073 00000 n 0000452118 00000 n 0000452163 00000 n 0000452208 00000 n 0000452253 00000 n 0000452298 00000 n 0000452343 00000 n 0000452388 00000 n 0000452433 00000 n 0000452478 00000 n 0000452523 00000 n 0000452568 00000 n 0000452613 00000 n 0000452658 00000 n 0000452703 00000 n 0000452748 00000 n 0000452793 00000 n 0000452838 00000 n 0000452883 00000 n 0000452928 00000 n 0000452973 00000 n 0000453018 00000 n 0000453063 00000 n 0000453108 00000 n 0000453153 00000 n 0000453198 00000 n 0000453243 00000 n 0000453288 00000 n 0000453333 00000 n 0000453378 00000 n 0000453423 00000 n 0000453468 00000 n 0000453513 00000 n 0000453558 00000 n 0000453603 00000 n 0000453648 00000 n 0000453693 00000 n 0000453738 00000 n 0000453783 00000 n 0000453828 00000 n 0000453873 00000 n 0000453918 00000 n 0000453963 00000 n 0000454008 00000 n 0000454053 00000 n 0000454098 00000 n 0000454143 00000 n 0000454188 00000 n 0000454233 00000 n 0000454278 00000 n 0000454323 00000 n 0000454368 00000 n 0000454413 00000 n 0000454458 00000 n 0000454503 00000 n 0000454548 00000 n 0000454593 00000 n 0000454638 00000 n 0000454683 00000 n 0000454728 00000 n 0000454773 00000 n 0000454818 00000 n 0000454863 00000 n 0000454908 00000 n 0000454953 00000 n 0000454998 00000 n 0000455043 00000 n 0000455088 00000 n 0000455133 00000 n 0000455178 00000 n 0000455223 00000 n 0000455268 00000 n 0000455313 00000 n 0000455358 00000 n 0000455403 00000 n 0000455448 00000 n 0000455493 00000 n 0000455538 00000 n 0000455583 00000 n 0000455628 00000 n 0000455673 00000 n 0000455718 00000 n 0000455763 00000 n 0000455808 00000 n 0000455853 00000 n 0000455898 00000 n 0000455943 00000 n 0000455988 00000 n 0000456033 00000 n 0000456078 00000 n 0000456123 00000 n 0000456168 00000 n 0000456213 00000 n 0000456258 00000 n 0000456303 00000 n 0000456348 00000 n 0000456393 00000 n 0000456438 00000 n 0000456483 00000 n 0000456528 00000 n 0000456573 00000 n 0000456618 00000 n 0000456663 00000 n 0000456708 00000 n 0000456753 00000 n 0000456798 00000 n 0000456843 00000 n 0000456888 00000 n 0000456933 00000 n 0000456978 00000 n 0000457023 00000 n 0000457068 00000 n 0000457113 00000 n 0000457158 00000 n 0000457203 00000 n 0000457248 00000 n 0000457293 00000 n 0000457338 00000 n 0000457383 00000 n 0000457428 00000 n 0000457473 00000 n 0000457518 00000 n 0000457563 00000 n 0000457608 00000 n 0000457653 00000 n 0000457698 00000 n 0000457743 00000 n 0000457788 00000 n 0000457833 00000 n 0000457878 00000 n 0000457923 00000 n 0000457968 00000 n 0000458013 00000 n 0000458058 00000 n 0000458103 00000 n 0000458148 00000 n 0000458193 00000 n 0000458238 00000 n 0000458283 00000 n 0000458328 00000 n 0000458373 00000 n 0000458418 00000 n 0000458463 00000 n 0000458508 00000 n 0000458553 00000 n 0000458598 00000 n 0000458643 00000 n 0000458688 00000 n 0000458733 00000 n 0000458778 00000 n 0000458823 00000 n 0000458868 00000 n 0000458913 00000 n 0000458958 00000 n 0000459003 00000 n 0000459048 00000 n 0000459093 00000 n 0000459138 00000 n 0000459183 00000 n 0000459228 00000 n 0000459273 00000 n 0000459318 00000 n 0000459363 00000 n 0000459408 00000 n 0000459453 00000 n 0000459498 00000 n 0000459543 00000 n 0000459588 00000 n 0000459633 00000 n 0000459678 00000 n 0000459723 00000 n 0000459768 00000 n 0000459813 00000 n 0000459858 00000 n 0000459903 00000 n 0000459948 00000 n 0000459993 00000 n 0000460038 00000 n 0000460083 00000 n 0000460128 00000 n 0000460173 00000 n 0000460218 00000 n 0000460263 00000 n 0000460308 00000 n 0000460353 00000 n 0000460398 00000 n 0000460443 00000 n 0000460488 00000 n 0000460533 00000 n 0000460578 00000 n 0000460623 00000 n 0000460668 00000 n 0000460713 00000 n 0000460758 00000 n 0000460803 00000 n 0000460848 00000 n 0000460893 00000 n 0000460938 00000 n 0000460983 00000 n 0000461028 00000 n 0000461073 00000 n 0000461118 00000 n 0000461163 00000 n 0000461208 00000 n 0000461253 00000 n 0000461298 00000 n 0000461343 00000 n 0000461388 00000 n 0000461433 00000 n 0000461478 00000 n 0000461523 00000 n 0000461568 00000 n 0000461613 00000 n 0000461658 00000 n 0000461703 00000 n 0000461748 00000 n 0000461793 00000 n 0000461838 00000 n 0000461883 00000 n 0000461928 00000 n 0000461973 00000 n 0000462018 00000 n 0000462063 00000 n 0000462108 00000 n 0000462153 00000 n 0000462198 00000 n 0000462243 00000 n 0000462288 00000 n 0000462333 00000 n 0000462378 00000 n 0000462423 00000 n 0000462468 00000 n 0000462513 00000 n 0000462558 00000 n 0000462603 00000 n 0000462648 00000 n 0000462693 00000 n 0000462738 00000 n 0000462783 00000 n 0000462828 00000 n 0000462873 00000 n 0000462918 00000 n 0000462963 00000 n 0000463008 00000 n 0000463053 00000 n 0000463098 00000 n 0000470185 00000 n 0000470367 00000 n 0000474553 00000 n 0000474746 00000 n 0000478209 00000 n 0000478403 00000 n 0000482668 00000 n 0000482862 00000 n 0000487225 00000 n 0000487419 00000 n 0000491715 00000 n 0000491909 00000 n 0000495681 00000 n 0000495875 00000 n 0000499733 00000 n 0000499927 00000 n 0000503756 00000 n 0000503950 00000 n 0000507723 00000 n 0000507917 00000 n 0000512019 00000 n 0000512213 00000 n 0000516693 00000 n 0000516887 00000 n 0000520672 00000 n 0000520866 00000 n 0000524961 00000 n 0000525155 00000 n 0000530454 00000 n 0000530648 00000 n 0000534135 00000 n 0000534329 00000 n 0000537996 00000 n 0000538190 00000 n 0000542020 00000 n 0000542214 00000 n 0000546261 00000 n 0000546455 00000 n 0000549816 00000 n 0000550011 00000 n 0000554092 00000 n 0000554287 00000 n 0000557962 00000 n 0000558157 00000 n 0000561619 00000 n 0000561814 00000 n 0000565731 00000 n 0000565926 00000 n 0000569814 00000 n 0000570009 00000 n 0000571834 00000 n 0000572031 00000 n 0000573560 00000 n 0000573766 00000 n 0000575809 00000 n 0000576004 00000 n 0000578109 00000 n 0000578304 00000 n 0000580267 00000 n 0000580482 00000 n 0000583062 00000 n 0000583241 00000 n 0000584010 00000 n 0000584207 00000 n 0000586371 00000 n 0000586561 00000 n 0000588529 00000 n 0000588717 00000 n 0000590127 00000 n 0000590326 00000 n 0000592016 00000 n 0000592211 00000 n 0000594327 00000 n 0000594497 00000 n 0000595444 00000 n 0000595650 00000 n 0000597996 00000 n 0000598193 00000 n 0000599462 00000 n 0000599686 00000 n 0000601588 00000 n 0000601803 00000 n 0000603972 00000 n 0000604141 00000 n 0000604665 00000 n 0000604894 00000 n 0000606859 00000 n 0000607049 00000 n 0000608506 00000 n 0000608685 00000 n 0000610118 00000 n 0000610297 00000 n 0000611693 00000 n 0000611883 00000 n 0000613713 00000 n 0000613919 00000 n 0000616736 00000 n 0000616933 00000 n 0000618648 00000 n 0000618852 00000 n 0000620881 00000 n 0000621087 00000 n 0000623071 00000 n 0000623286 00000 n 0000624828 00000 n 0000625007 00000 n 0000627040 00000 n 0000627235 00000 n 0000629191 00000 n 0000629379 00000 n 0000631464 00000 n 0000631677 00000 n 0000633786 00000 n 0000633985 00000 n 0000636046 00000 n 0000636234 00000 n 0000637859 00000 n 0000638038 00000 n 0000639474 00000 n 0000639653 00000 n 0000641175 00000 n 0000641372 00000 n 0000642957 00000 n 0000643154 00000 n 0000644821 00000 n 0000645016 00000 n 0000646362 00000 n 0000646550 00000 n 0000648301 00000 n 0000648489 00000 n 0000650999 00000 n 0000651193 00000 n 0000653794 00000 n 0000653989 00000 n 0000655928 00000 n 0000656132 00000 n 0000657794 00000 n 0000657963 00000 n 0000659222 00000 n 0000659417 00000 n 0000660836 00000 n 0000661015 00000 n 0000662295 00000 n 0000662499 00000 n 0000664057 00000 n 0000664254 00000 n 0000665770 00000 n 0000665958 00000 n 0000667696 00000 n 0000667865 00000 n 0000668862 00000 n 0000669031 00000 n 0000670225 00000 n 0000670413 00000 n 0000671608 00000 n 0000671803 00000 n 0000673706 00000 n 0000673905 00000 n 0000675249 00000 n 0000675439 00000 n 0000677019 00000 n 0000677225 00000 n 0000678949 00000 n 0000679148 00000 n 0000680997 00000 n 0000681194 00000 n 0000683893 00000 n 0000684083 00000 n 0000686486 00000 n 0000686685 00000 n 0000688316 00000 n 0000688495 00000 n 0000689603 00000 n 0000689792 00000 n 0000691365 00000 n 0000691555 00000 n 0000692935 00000 n 0000693140 00000 n 0000694949 00000 n 0000695153 00000 n 0000696730 00000 n 0000696943 00000 n 0000698353 00000 n 0000698557 00000 n 0000699952 00000 n 0000700146 00000 n 0000702144 00000 n 0000702357 00000 n 0000704385 00000 n 0000704580 00000 n 0000706107 00000 n 0000706286 00000 n 0000707356 00000 n 0000707544 00000 n 0000709214 00000 n 0000709402 00000 n 0000710761 00000 n 0000710974 00000 n 0000713104 00000 n 0000713282 00000 n 0000714865 00000 n 0000715044 00000 n 0000716353 00000 n 0000716531 00000 n 0000717738 00000 n 0000717944 00000 n 0000719739 00000 n 0000719918 00000 n 0000721215 00000 n 0000721420 00000 n 0000722905 00000 n 0000723085 00000 n 0000724614 00000 n 0000724829 00000 n 0000726625 00000 n 0000726813 00000 n 0000728268 00000 n 0000728458 00000 n 0000729962 00000 n 0000730166 00000 n 0000731883 00000 n 0000732052 00000 n 0000733484 00000 n 0000733653 00000 n 0000735224 00000 n 0000735393 00000 n 0000736922 00000 n 0000737100 00000 n 0000738379 00000 n 0000738557 00000 n 0000739609 00000 n 0000739778 00000 n 0000740970 00000 n 0000741148 00000 n 0000742353 00000 n 0000742557 00000 n 0000744320 00000 n 0000744489 00000 n 0000745765 00000 n 0000745943 00000 n 0000747434 00000 n 0000747621 00000 n 0000749135 00000 n 0000749322 00000 n 0000750582 00000 n 0000750786 00000 n 0000752266 00000 n 0000752445 00000 n 0000753651 00000 n 0000753846 00000 n 0000755532 00000 n 0000755720 00000 n 0000757198 00000 n 0000757378 00000 n 0000758793 00000 n 0000758981 00000 n 0000760164 00000 n 0000760358 00000 n 0000761771 00000 n 0000761966 00000 n 0000763314 00000 n 0000763503 00000 n 0000764711 00000 n 0000764899 00000 n 0000766714 00000 n 0000766884 00000 n 0000767607 00000 n 0000767804 00000 n 0000770330 00000 n 0000770509 00000 n 0000772028 00000 n 0000772197 00000 n 0000773231 00000 n 0000773410 00000 n 0000774815 00000 n 0000774994 00000 n 0000776152 00000 n 0000776331 00000 n 0000777485 00000 n 0000777664 00000 n 0000778711 00000 n 0000778890 00000 n 0000780138 00000 n 0000780317 00000 n 0000781662 00000 n 0000781841 00000 n 0000783203 00000 n 0000783382 00000 n 0000784892 00000 n 0000785087 00000 n 0000786574 00000 n 0000786753 00000 n 0000788429 00000 n 0000788624 00000 n 0000790219 00000 n 0000790425 00000 n 0000792480 00000 n 0000792670 00000 n 0000794052 00000 n 0000794242 00000 n 0000795785 00000 n 0000795989 00000 n 0000797342 00000 n 0000797521 00000 n 0000798541 00000 n 0000798756 00000 n 0000800935 00000 n 0000801123 00000 n 0000802345 00000 n 0000802532 00000 n 0000804046 00000 n 0000804234 00000 n 0000805452 00000 n 0000805658 00000 n 0000807176 00000 n 0000807373 00000 n 0000808491 00000 n 0000808697 00000 n 0000810186 00000 n 0000810374 00000 n 0000811763 00000 n 0000811985 00000 n 0000813539 00000 n 0000813735 00000 n 0000815224 00000 n 0000815411 00000 n 0000816669 00000 n 0000816877 00000 n 0000818633 00000 n 0000818812 00000 n 0000820372 00000 n 0000820562 00000 n 0000822011 00000 n 0000822189 00000 n 0000823501 00000 n 0000823680 00000 n 0000825214 00000 n 0000825408 00000 n 0000827080 00000 n 0000827268 00000 n 0000828391 00000 n 0000828579 00000 n 0000829441 00000 n 0000829647 00000 n 0000831432 00000 n 0000831611 00000 n 0000832878 00000 n 0000833057 00000 n 0000834028 00000 n 0000834216 00000 n 0000835526 00000 n 0000835705 00000 n 0000837091 00000 n 0000837260 00000 n 0000837661 00000 n 0000837858 00000 n 0000840214 00000 n 0000840438 00000 n 0000842556 00000 n 0000842744 00000 n 0000844387 00000 n 0000844575 00000 n 0000846141 00000 n 0000846347 00000 n 0000847756 00000 n 0000847973 00000 n 0000849250 00000 n 0000849474 00000 n 0000851559 00000 n 0000851753 00000 n 0000853231 00000 n 0000853410 00000 n 0000854488 00000 n 0000854676 00000 n 0000855812 00000 n 0000856002 00000 n 0000857617 00000 n 0000857805 00000 n 0000858928 00000 n 0000859106 00000 n 0000860458 00000 n 0000860653 00000 n 0000862561 00000 n 0000862765 00000 n 0000864606 00000 n 0000864775 00000 n 0000865946 00000 n 0000866152 00000 n 0000867531 00000 n 0000867716 00000 n 0000869464 00000 n 0000869654 00000 n 0000871003 00000 n 0000871191 00000 n 0000872686 00000 n 0000872874 00000 n 0000874058 00000 n 0000874245 00000 n 0000876229 00000 n 0000876424 00000 n 0000878121 00000 n 0000878316 00000 n 0000879735 00000 n 0000879948 00000 n 0000881713 00000 n 0000881917 00000 n 0000883395 00000 n 0000883599 00000 n 0000884817 00000 n 0000885012 00000 n 0000886496 00000 n 0000886665 00000 n 0000887801 00000 n 0000887970 00000 n 0000889377 00000 n 0000889565 00000 n 0000891053 00000 n 0000891266 00000 n 0000893013 00000 n 0000893198 00000 n 0000894727 00000 n 0000894915 00000 n 0000896514 00000 n 0000896683 00000 n 0000898050 00000 n 0000898245 00000 n 0000899950 00000 n 0000900135 00000 n 0000901462 00000 n 0000901631 00000 n 0000903113 00000 n 0000903301 00000 n 0000904569 00000 n 0000904759 00000 n 0000906418 00000 n 0000906587 00000 n 0000908918 00000 n 0000909122 00000 n 0000911210 00000 n 0000911389 00000 n 0000912441 00000 n 0000912626 00000 n 0000914159 00000 n 0000914319 00000 n 0000915129 00000 n 0000915353 00000 n 0000917322 00000 n 0000917512 00000 n 0000919255 00000 n 0000919434 00000 n 0000920701 00000 n 0000920916 00000 n 0000922944 00000 n 0000923123 00000 n 0000924288 00000 n 0000924467 00000 n 0000925388 00000 n 0000925583 00000 n 0000927293 00000 n 0000927481 00000 n 0000928757 00000 n 0000928936 00000 n 0000930367 00000 n 0000930546 00000 n 0000932055 00000 n 0000932259 00000 n 0000933784 00000 n 0000933988 00000 n 0000935550 00000 n 0000935745 00000 n 0000937173 00000 n 0000937352 00000 n 0000938804 00000 n 0000939008 00000 n 0000940355 00000 n 0000940524 00000 n 0000940822 00000 n 0000941028 00000 n 0000942724 00000 n 0000942903 00000 n 0000944074 00000 n 0000944253 00000 n 0000945059 00000 n 0000945274 00000 n 0000947078 00000 n 0000947266 00000 n 0000949110 00000 n 0000949289 00000 n 0000950814 00000 n 0000951018 00000 n 0000953057 00000 n 0000953226 00000 n 0000954747 00000 n 0000954951 00000 n 0000956999 00000 n 0000957168 00000 n 0000958440 00000 n 0000958600 00000 n 0000959648 00000 n 0000959827 00000 n 0000961508 00000 n 0000961687 00000 n 0000963378 00000 n 0000963547 00000 n 0000965063 00000 n 0000965269 00000 n 0000967105 00000 n 0000967293 00000 n 0000968599 00000 n 0000968794 00000 n 0000970321 00000 n 0000970520 00000 n 0000971841 00000 n 0000972021 00000 n 0000973189 00000 n 0000973379 00000 n 0000974910 00000 n 0000975100 00000 n 0000976571 00000 n 0000976741 00000 n 0000977099 00000 n 0000977305 00000 n 0000979262 00000 n 0000979441 00000 n 0000980993 00000 n 0000981188 00000 n 0000983681 00000 n 0000983885 00000 n 0000985358 00000 n 0000985564 00000 n 0000986826 00000 n 0000987014 00000 n 0000988668 00000 n 0000988847 00000 n 0000990760 00000 n 0000990939 00000 n 0000993267 00000 n 0000993473 00000 n 0000995464 00000 n 0000995661 00000 n 0000996807 00000 n 0000997004 00000 n 0000999629 00000 n 0000999808 00000 n 0001001846 00000 n 0001002024 00000 n 0001003615 00000 n 0001003803 00000 n 0001005047 00000 n 0001005253 00000 n 0001007119 00000 n 0001007298 00000 n 0001008618 00000 n 0001008797 00000 n 0001010344 00000 n 0001010523 00000 n 0001011821 00000 n 0001012009 00000 n 0001013948 00000 n 0001014127 00000 n 0001015406 00000 n 0001015585 00000 n 0001016643 00000 n 0001016812 00000 n 0001017806 00000 n 0001017976 00000 n 0001018654 00000 n 0001018849 00000 n 0001020701 00000 n 0001020891 00000 n 0001022610 00000 n 0001022779 00000 n 0001023494 00000 n 0001023663 00000 n 0001024526 00000 n 0001024705 00000 n 0001025554 00000 n 0001025733 00000 n 0001026825 00000 n 0001027020 00000 n 0001028822 00000 n 0001029017 00000 n 0001030692 00000 n 0001030882 00000 n 0001032656 00000 n 0001032835 00000 n 0001034066 00000 n 0001034256 00000 n 0001035799 00000 n 0001035989 00000 n 0001036890 00000 n 0001037096 00000 n 0001039086 00000 n 0001039264 00000 n 0001040435 00000 n 0001040629 00000 n 0001042033 00000 n 0001042229 00000 n 0001043601 00000 n 0001043828 00000 n 0001044869 00000 n 0001045038 00000 n 0001045813 00000 n 0001045993 00000 n 0001047265 00000 n 0001047425 00000 n 0001048611 00000 n 0001048780 00000 n 0001049969 00000 n 0001050180 00000 n 0001050995 00000 n 0001051201 00000 n 0001054380 00000 n 0001054586 00000 n 0001056790 00000 n 0001056986 00000 n 0001059141 00000 n 0001059337 00000 n 0001060953 00000 n 0001061177 00000 n 0001063227 00000 n 0001063422 00000 n 0001065530 00000 n 0001065725 00000 n 0001067437 00000 n 0001067641 00000 n 0001069857 00000 n 0001070036 00000 n 0001071452 00000 n 0001071621 00000 n 0001072833 00000 n 0001073028 00000 n 0001074591 00000 n 0001074770 00000 n 0001076023 00000 n 0001076202 00000 n 0001078048 00000 n 0001078243 00000 n 0001079803 00000 n 0001079972 00000 n 0001081003 00000 n 0001081182 00000 n 0001082431 00000 n 0001082600 00000 n 0001084333 00000 n 0001084512 00000 n 0001085806 00000 n 0001086001 00000 n 0001088052 00000 n 0001088221 00000 n 0001089490 00000 n 0001089685 00000 n 0001091142 00000 n 0001091337 00000 n 0001092970 00000 n 0001093139 00000 n 0001094516 00000 n 0001094696 00000 n 0001096588 00000 n 0001096783 00000 n 0001098372 00000 n 0001098578 00000 n 0001100237 00000 n 0001100416 00000 n 0001101654 00000 n 0001101849 00000 n 0001103117 00000 n 0001103286 00000 n 0001103749 00000 n 0001103973 00000 n 0001106184 00000 n 0001106383 00000 n 0001107903 00000 n 0001108098 00000 n 0001110115 00000 n 0001110321 00000 n 0001112230 00000 n 0001112418 00000 n 0001114593 00000 n 0001114817 00000 n 0001117050 00000 n 0001117219 00000 n 0001117846 00000 n 0001118061 00000 n 0001120654 00000 n 0001120842 00000 n 0001122576 00000 n 0001122771 00000 n 0001124795 00000 n 0001124990 00000 n 0001126797 00000 n 0001126982 00000 n 0001128707 00000 n 0001128920 00000 n 0001130801 00000 n 0001131014 00000 n 0001133250 00000 n 0001133465 00000 n 0001135975 00000 n 0001136190 00000 n 0001138301 00000 n 0001138491 00000 n 0001140366 00000 n 0001140561 00000 n 0001142547 00000 n 0001142726 00000 n 0001144316 00000 n 0001144504 00000 n 0001146295 00000 n 0001146490 00000 n 0001147835 00000 n 0001148004 00000 n 0001148683 00000 n 0001148889 00000 n 0001150750 00000 n 0001150968 00000 n 0001152705 00000 n 0001152914 00000 n 0001154907 00000 n 0001155141 00000 n 0001157137 00000 n 0001157353 00000 n 0001159453 00000 n 0001159660 00000 n 0001161346 00000 n 0001161524 00000 n 0001162668 00000 n 0001162885 00000 n 0001164968 00000 n 0001165175 00000 n 0001166630 00000 n 0001166808 00000 n 0001167431 00000 n 0001167628 00000 n 0001170262 00000 n 0001170449 00000 n 0001173908 00000 n 0001174103 00000 n 0001176526 00000 n 0001176730 00000 n 0001178761 00000 n 0001178974 00000 n 0001180915 00000 n 0001181110 00000 n 0001183046 00000 n 0001183252 00000 n 0001185519 00000 n 0001185707 00000 n 0001187606 00000 n 0001187794 00000 n 0001189280 00000 n 0001189484 00000 n 0001191010 00000 n 0001191188 00000 n 0001192991 00000 n 0001193170 00000 n 0001194823 00000 n 0001195027 00000 n 0001197314 00000 n 0001197518 00000 n 0001199491 00000 n 0001199679 00000 n 0001201439 00000 n 0001201624 00000 n 0001203405 00000 n 0001203584 00000 n 0001204591 00000 n 0001204770 00000 n 0001206021 00000 n 0001206200 00000 n 0001207603 00000 n 0001207807 00000 n 0001209146 00000 n 0001209341 00000 n 0001211151 00000 n 0001211346 00000 n 0001212866 00000 n 0001213061 00000 n 0001214517 00000 n 0001214721 00000 n 0001216829 00000 n 0001217033 00000 n 0001218883 00000 n 0001219062 00000 n 0001220451 00000 n 0001220636 00000 n 0001222205 00000 n 0001222400 00000 n 0001223736 00000 n 0001223931 00000 n 0001225867 00000 n 0001226071 00000 n 0001228162 00000 n 0001228347 00000 n 0001229934 00000 n 0001230138 00000 n 0001231635 00000 n 0001231830 00000 n 0001233514 00000 n 0001233709 00000 n 0001234945 00000 n 0001235124 00000 n 0001236463 00000 n 0001236658 00000 n 0001238579 00000 n 0001238758 00000 n 0001240550 00000 n 0001240729 00000 n 0001242358 00000 n 0001242571 00000 n 0001244898 00000 n 0001245092 00000 n 0001246829 00000 n 0001246998 00000 n 0001248318 00000 n 0001248522 00000 n 0001250323 00000 n 0001250502 00000 n 0001251808 00000 n 0001251987 00000 n 0001253349 00000 n 0001253544 00000 n 0001255101 00000 n 0001255296 00000 n 0001256906 00000 n 0001257085 00000 n 0001258268 00000 n 0001258447 00000 n 0001259765 00000 n 0001259960 00000 n 0001261346 00000 n 0001261525 00000 n 0001263023 00000 n 0001263218 00000 n 0001265268 00000 n 0001265428 00000 n 0001266578 00000 n 0001266793 00000 n 0001269078 00000 n 0001269257 00000 n 0001271317 00000 n 0001271496 00000 n 0001272820 00000 n 0001273024 00000 n 0001275126 00000 n 0001275311 00000 n 0001277320 00000 n 0001277524 00000 n 0001280702 00000 n 0001280915 00000 n 0001282749 00000 n 0001282962 00000 n 0001284598 00000 n 0001284777 00000 n 0001286540 00000 n 0001286727 00000 n 0001287998 00000 n 0001288183 00000 n 0001289981 00000 n 0001290185 00000 n 0001292029 00000 n 0001292223 00000 n 0001293871 00000 n 0001294084 00000 n 0001295798 00000 n 0001295977 00000 n 0001297357 00000 n 0001297542 00000 n 0001299037 00000 n 0001299216 00000 n 0001300529 00000 n 0001300724 00000 n 0001302433 00000 n 0001302602 00000 n 0001303803 00000 n 0001303982 00000 n 0001305463 00000 n 0001305642 00000 n 0001307101 00000 n 0001307270 00000 n 0001308633 00000 n 0001308812 00000 n 0001310105 00000 n 0001310274 00000 n 0001311639 00000 n 0001311818 00000 n 0001313343 00000 n 0001313533 00000 n 0001315148 00000 n 0001315317 00000 n 0001316754 00000 n 0001316949 00000 n 0001318735 00000 n 0001318904 00000 n 0001320180 00000 n 0001320359 00000 n 0001321663 00000 n 0001321858 00000 n 0001323463 00000 n 0001323632 00000 n 0001324882 00000 n 0001325106 00000 n 0001327348 00000 n 0001327526 00000 n 0001329023 00000 n 0001329202 00000 n 0001330537 00000 n 0001330716 00000 n 0001332355 00000 n 0001332550 00000 n 0001334651 00000 n 0001334875 00000 n 0001336727 00000 n 0001336926 00000 n 0001338488 00000 n 0001338694 00000 n 0001340203 00000 n 0001340418 00000 n 0001341863 00000 n 0001342058 00000 n 0001343612 00000 n 0001343791 00000 n 0001344863 00000 n 0001345067 00000 n 0001346239 00000 n 0001346408 00000 n 0001347400 00000 n 0001347604 00000 n 0001349106 00000 n 0001349266 00000 n 0001350000 00000 n 0001350188 00000 n 0001351519 00000 n 0001351679 00000 n 0001352407 00000 n 0001352586 00000 n 0001353478 00000 n 0001353657 00000 n 0001354903 00000 n 0001355072 00000 n 0001355698 00000 n 0001355922 00000 n 0001357840 00000 n 0001358028 00000 n 0001359270 00000 n 0001359448 00000 n 0001360614 00000 n 0001360817 00000 n 0001362292 00000 n 0001362480 00000 n 0001363680 00000 n 0001363849 00000 n 0001364907 00000 n 0001365076 00000 n 0001366270 00000 n 0001366494 00000 n 0001368175 00000 n 0001368354 00000 n 0001369667 00000 n 0001369846 00000 n 0001370570 00000 n 0001370776 00000 n 0001373434 00000 n 0001373629 00000 n 0001375355 00000 n 0001375543 00000 n 0001377277 00000 n 0001377472 00000 n 0001379164 00000 n 0001379343 00000 n 0001380684 00000 n 0001380863 00000 n 0001382326 00000 n 0001382505 00000 n 0001383968 00000 n 0001384156 00000 n 0001385675 00000 n 0001385854 00000 n 0001387347 00000 n 0001387526 00000 n 0001388703 00000 n 0001388891 00000 n 0001390120 00000 n 0001390299 00000 n 0001391743 00000 n 0001391922 00000 n 0001393175 00000 n 0001393355 00000 n 0001394836 00000 n 0001395016 00000 n 0001396314 00000 n 0001396493 00000 n 0001397805 00000 n 0001398000 00000 n 0001399172 00000 n 0001399351 00000 n 0001400672 00000 n 0001400841 00000 n 0001402372 00000 n 0001402567 00000 n 0001403833 00000 n 0001404012 00000 n 0001405206 00000 n 0001405394 00000 n 0001407148 00000 n 0001407327 00000 n 0001408727 00000 n 0001408922 00000 n 0001410626 00000 n 0001410841 00000 n 0001412696 00000 n 0001412895 00000 n 0001414723 00000 n 0001414911 00000 n 0001416481 00000 n 0001416660 00000 n 0001418358 00000 n 0001418527 00000 n 0001420216 00000 n 0001420395 00000 n 0001421437 00000 n 0001421643 00000 n 0001423760 00000 n 0001423957 00000 n 0001426584 00000 n 0001426799 00000 n 0001429101 00000 n 0001429300 00000 n 0001431826 00000 n 0001432016 00000 n 0001434257 00000 n 0001434445 00000 n 0001436095 00000 n 0001436319 00000 n 0001438086 00000 n 0001438292 00000 n 0001439549 00000 n 0001439755 00000 n 0001441511 00000 n 0001441717 00000 n 0001444484 00000 n 0001444681 00000 n 0001446626 00000 n 0001446823 00000 n 0001448689 00000 n 0001448879 00000 n 0001451449 00000 n 0001451628 00000 n 0001453146 00000 n 0001453334 00000 n 0001455133 00000 n 0001455330 00000 n 0001456922 00000 n 0001457110 00000 n 0001458314 00000 n 0001458502 00000 n 0001460121 00000 n 0001460309 00000 n 0001462631 00000 n 0001462819 00000 n 0001463715 00000 n 0001463921 00000 n 0001465774 00000 n 0001465987 00000 n 0001467500 00000 n 0001467679 00000 n 0001469015 00000 n 0001469194 00000 n 0001470524 00000 n 0001470703 00000 n 0001472171 00000 n 0001472340 00000 n 0001473318 00000 n 0001473497 00000 n 0001475099 00000 n 0001475278 00000 n 0001476243 00000 n 0001476422 00000 n 0001477517 00000 n 0001477696 00000 n 0001478783 00000 n 0001478962 00000 n 0001480471 00000 n 0001480650 00000 n 0001481676 00000 n 0001481873 00000 n 0001484385 00000 n 0001484573 00000 n 0001486259 00000 n 0001486454 00000 n 0001488113 00000 n 0001488292 00000 n 0001489987 00000 n 0001490175 00000 n 0001492057 00000 n 0001492262 00000 n 0001494642 00000 n 0001494832 00000 n 0001496899 00000 n 0001497094 00000 n 0001498404 00000 n 0001498583 00000 n 0001499941 00000 n 0001500129 00000 n 0001501557 00000 n 0001501736 00000 n 0001502883 00000 n 0001503062 00000 n 0001504310 00000 n 0001504500 00000 n 0001505748 00000 n 0001505936 00000 n 0001507393 00000 n 0001507562 00000 n 0001508631 00000 n 0001508819 00000 n 0001509941 00000 n 0001510135 00000 n 0001511244 00000 n 0001511448 00000 n 0001513051 00000 n 0001513230 00000 n 0001514361 00000 n 0001514565 00000 n 0001515945 00000 n 0001516133 00000 n 0001517445 00000 n 0001517624 00000 n 0001519007 00000 n 0001519186 00000 n 0001520422 00000 n 0001520601 00000 n 0001521916 00000 n 0001522104 00000 n 0001523885 00000 n 0001524054 00000 n 0001525074 00000 n 0001525253 00000 n 0001527051 00000 n 0001527230 00000 n 0001528594 00000 n 0001528773 00000 n 0001530078 00000 n 0001530273 00000 n 0001531653 00000 n 0001531832 00000 n 0001533328 00000 n 0001533516 00000 n 0001536045 00000 n 0001536224 00000 n 0001538268 00000 n 0001538438 00000 n 0001539102 00000 n 0001539308 00000 n 0001541610 00000 n 0001541805 00000 n 0001543549 00000 n 0001543728 00000 n 0001545008 00000 n 0001545212 00000 n 0001546490 00000 n 0001546678 00000 n 0001548152 00000 n 0001548340 00000 n 0001549441 00000 n 0001549629 00000 n 0001550790 00000 n 0001550978 00000 n 0001552288 00000 n 0001552467 00000 n 0001553864 00000 n 0001554052 00000 n 0001556590 00000 n 0001556769 00000 n 0001558605 00000 n 0001558775 00000 n 0001559585 00000 n 0001559800 00000 n 0001561487 00000 n 0001561675 00000 n 0001562853 00000 n 0001563032 00000 n 0001563809 00000 n 0001564006 00000 n 0001566451 00000 n 0001566657 00000 n 0001569024 00000 n 0001569203 00000 n 0001570453 00000 n 0001570659 00000 n 0001572475 00000 n 0001572679 00000 n 0001574720 00000 n 0001574908 00000 n 0001576616 00000 n 0001576804 00000 n 0001578872 00000 n 0001579051 00000 n 0001581430 00000 n 0001581626 00000 n 0001583967 00000 n 0001584162 00000 n 0001585753 00000 n 0001585948 00000 n 0001587455 00000 n 0001587650 00000 n 0001589439 00000 n 0001589618 00000 n 0001591080 00000 n 0001591249 00000 n 0001592597 00000 n 0001592776 00000 n 0001593989 00000 n 0001594168 00000 n 0001595392 00000 n 0001595571 00000 n 0001596749 00000 n 0001596928 00000 n 0001598202 00000 n 0001598381 00000 n 0001599512 00000 n 0001599707 00000 n 0001600925 00000 n 0001601129 00000 n 0001602699 00000 n 0001602905 00000 n 0001604849 00000 n 0001605038 00000 n 0001606206 00000 n 0001606421 00000 n 0001608010 00000 n 0001608214 00000 n 0001609950 00000 n 0001610135 00000 n 0001611206 00000 n 0001611401 00000 n 0001613267 00000 n 0001613446 00000 n 0001614990 00000 n 0001615178 00000 n 0001617778 00000 n 0001617957 00000 n 0001619499 00000 n 0001619687 00000 n 0001621603 00000 n 0001621782 00000 n 0001623164 00000 n 0001623333 00000 n 0001624916 00000 n 0001625085 00000 n 0001626161 00000 n 0001626340 00000 n 0001627302 00000 n 0001627481 00000 n 0001628712 00000 n 0001628907 00000 n 0001630088 00000 n 0001630257 00000 n 0001631348 00000 n 0001631527 00000 n 0001632715 00000 n 0001632910 00000 n 0001634402 00000 n 0001634597 00000 n 0001636441 00000 n 0001636636 00000 n 0001638064 00000 n 0001638268 00000 n 0001639814 00000 n 0001640002 00000 n 0001640992 00000 n 0001641171 00000 n 0001642406 00000 n 0001642585 00000 n 0001643949 00000 n 0001644128 00000 n 0001645636 00000 n 0001645815 00000 n 0001647159 00000 n 0001647338 00000 n 0001648988 00000 n 0001649185 00000 n 0001651361 00000 n 0001651549 00000 n 0001652838 00000 n 0001653017 00000 n 0001654540 00000 n 0001654719 00000 n 0001656377 00000 n 0001656546 00000 n 0001657734 00000 n 0001657940 00000 n 0001659585 00000 n 0001659775 00000 n 0001661446 00000 n 0001661650 00000 n 0001663084 00000 n 0001663288 00000 n 0001664827 00000 n 0001665012 00000 n 0001666118 00000 n 0001666324 00000 n 0001667891 00000 n 0001668070 00000 n 0001669074 00000 n 0001669271 00000 n 0001671436 00000 n 0001671633 00000 n 0001673960 00000 n 0001674139 00000 n 0001675656 00000 n 0001675869 00000 n 0001677779 00000 n 0001677969 00000 n 0001679975 00000 n 0001680163 00000 n 0001681531 00000 n 0001681719 00000 n 0001682859 00000 n 0001683056 00000 n 0001684331 00000 n 0001684546 00000 n 0001685921 00000 n 0001686138 00000 n 0001687336 00000 n 0001687530 00000 n 0001689147 00000 n 0001689335 00000 n 0001690459 00000 n 0001690663 00000 n 0001692035 00000 n 0001692223 00000 n 0001693632 00000 n 0001693827 00000 n 0001695174 00000 n 0001695362 00000 n 0001696997 00000 n 0001697185 00000 n 0001698325 00000 n 0001698549 00000 n 0001700346 00000 n 0001700550 00000 n 0001702210 00000 n 0001702423 00000 n 0001703915 00000 n 0001704103 00000 n 0001705137 00000 n 0001705332 00000 n 0001706648 00000 n 0001706817 00000 n 0001707860 00000 n 0001708055 00000 n 0001709355 00000 n 0001709550 00000 n 0001711561 00000 n 0001711765 00000 n 0001713400 00000 n 0001713569 00000 n 0001714898 00000 n 0001715077 00000 n 0001716149 00000 n 0001716337 00000 n 0001717491 00000 n 0001717670 00000 n 0001719193 00000 n 0001719397 00000 n 0001721161 00000 n 0001721340 00000 n 0001722976 00000 n 0001723180 00000 n 0001724479 00000 n 0001724674 00000 n 0001726458 00000 n 0001726653 00000 n 0001728244 00000 n 0001728441 00000 n 0001730831 00000 n 0001731019 00000 n 0001732236 00000 n 0001732424 00000 n 0001733964 00000 n 0001734152 00000 n 0001735864 00000 n 0001736051 00000 n 0001737416 00000 n 0001737603 00000 n 0001738842 00000 n 0001739039 00000 n 0001741109 00000 n 0001741294 00000 n 0001742538 00000 n 0001742726 00000 n 0001744361 00000 n 0001744558 00000 n 0001746248 00000 n 0001746435 00000 n 0001748212 00000 n 0001748416 00000 n 0001749609 00000 n 0001749815 00000 n 0001751365 00000 n 0001751571 00000 n 0001753529 00000 n 0001753725 00000 n 0001755117 00000 n 0001755305 00000 n 0001756305 00000 n 0001756483 00000 n 0001757417 00000 n 0001757611 00000 n 0001759088 00000 n 0001759292 00000 n 0001760876 00000 n 0001761070 00000 n 0001762366 00000 n 0001762570 00000 n 0001764229 00000 n 0001764407 00000 n 0001765671 00000 n 0001765859 00000 n 0001767601 00000 n 0001767807 00000 n 0001770155 00000 n 0001770350 00000 n 0001772132 00000 n 0001772320 00000 n 0001774062 00000 n 0001774241 00000 n 0001776111 00000 n 0001776290 00000 n 0001778232 00000 n 0001778422 00000 n 0001780228 00000 n 0001780407 00000 n 0001781912 00000 n 0001782107 00000 n 0001783265 00000 n 0001783460 00000 n 0001785055 00000 n 0001785234 00000 n 0001786746 00000 n 0001786915 00000 n 0001788244 00000 n 0001788413 00000 n 0001789598 00000 n 0001789777 00000 n 0001790743 00000 n 0001790922 00000 n 0001792132 00000 n 0001792311 00000 n 0001793481 00000 n 0001793660 00000 n 0001795027 00000 n 0001795222 00000 n 0001796466 00000 n 0001796661 00000 n 0001798089 00000 n 0001798268 00000 n 0001799471 00000 n 0001799640 00000 n 0001800846 00000 n 0001801025 00000 n 0001802002 00000 n 0001802181 00000 n 0001803389 00000 n 0001803558 00000 n 0001804565 00000 n 0001804760 00000 n 0001806310 00000 n 0001806489 00000 n 0001807883 00000 n 0001808078 00000 n 0001809253 00000 n 0001809432 00000 n 0001810627 00000 n 0001810815 00000 n 0001812033 00000 n 0001812221 00000 n 0001813275 00000 n 0001813454 00000 n 0001814977 00000 n 0001815156 00000 n 0001816355 00000 n 0001816534 00000 n 0001818066 00000 n 0001818261 00000 n 0001819624 00000 n 0001819821 00000 n 0001822033 00000 n 0001822241 00000 n 0001824434 00000 n 0001824642 00000 n 0001826628 00000 n 0001826816 00000 n 0001828983 00000 n 0001829171 00000 n 0001830603 00000 n 0001830763 00000 n 0001831494 00000 n 0001831654 00000 n 0001832349 00000 n 0001832528 00000 n 0001833914 00000 n 0001834093 00000 n 0001835185 00000 n 0001835364 00000 n 0001836760 00000 n 0001836950 00000 n 0001838661 00000 n 0001838849 00000 n 0001840140 00000 n 0001840328 00000 n 0001841446 00000 n 0001841634 00000 n 0001842929 00000 n 0001843117 00000 n 0001844599 00000 n 0001844787 00000 n 0001845960 00000 n 0001846148 00000 n 0001847694 00000 n 0001847891 00000 n 0001849764 00000 n 0001849952 00000 n 0001851115 00000 n 0001851303 00000 n 0001852447 00000 n 0001852635 00000 n 0001854114 00000 n 0001854302 00000 n 0001855878 00000 n 0001856066 00000 n 0001857523 00000 n 0001857720 00000 n 0001859467 00000 n 0001859646 00000 n 0001861232 00000 n 0001861422 00000 n 0001862543 00000 n 0001862712 00000 n 0001864026 00000 n 0001864216 00000 n 0001865587 00000 n 0001865776 00000 n 0001866835 00000 n 0001867039 00000 n 0001869097 00000 n 0001869312 00000 n 0001871315 00000 n 0001871528 00000 n 0001873648 00000 n 0001873826 00000 n 0001875241 00000 n 0001875456 00000 n 0001877605 00000 n 0001877800 00000 n 0001879971 00000 n 0001880159 00000 n 0001881193 00000 n 0001881371 00000 n 0001882321 00000 n 0001882499 00000 n 0001883130 00000 n 0001883318 00000 n 0001883937 00000 n 0001883996 00000 n 0001884099 00000 n 0001884259 00000 n 0001884377 00000 n 0001884486 00000 n 0001884615 00000 n 0001884724 00000 n 0001884872 00000 n 0001884974 00000 n 0001885091 00000 n 0001885207 00000 n 0001885325 00000 n 0001885442 00000 n 0001885573 00000 n 0001885708 00000 n 0001885835 00000 n 0001885952 00000 n 0001886064 00000 n 0001886180 00000 n 0001886321 00000 n 0001886434 00000 n 0001886558 00000 n 0001886692 00000 n 0001886806 00000 n 0001886907 00000 n 0001887059 00000 n 0001887162 00000 n 0001887279 00000 n 0001887435 00000 n 0001887546 00000 n 0001887668 00000 n 0001887797 00000 n 0001887927 00000 n 0001888028 00000 n 0001888165 00000 n 0001888301 00000 n 0001888443 00000 n 0001888572 00000 n 0001888678 00000 n 0001888844 00000 n 0001888995 00000 n 0001889091 00000 n 0001889254 00000 n 0001889438 00000 n 0001889534 00000 n 0001889646 00000 n 0001889758 00000 n 0001889872 00000 n 0001889983 00000 n 0001890092 00000 n 0001890190 00000 n 0001890338 00000 n 0001890504 00000 n 0001890662 00000 n 0001890794 00000 n 0001890932 00000 n 0001891056 00000 n 0001891192 00000 n 0001891327 00000 n 0001891486 00000 n 0001891610 00000 n 0001891792 00000 n 0001891901 00000 n 0001892023 00000 n 0001892138 00000 n 0001892266 00000 n 0001892371 00000 n 0001892537 00000 n 0001892665 00000 n 0001892800 00000 n 0001892906 00000 n 0001893057 00000 n 0001893197 00000 n 0001893301 00000 n 0001893418 00000 n 0001893532 00000 n 0001893652 00000 n 0001893773 00000 n 0001893883 00000 n 0001894055 00000 n 0001894166 00000 n 0001894288 00000 n 0001894403 00000 n 0001894533 00000 n 0001894652 00000 n 0001894822 00000 n 0001894929 00000 n 0001895065 00000 n 0001895206 00000 n 0001895331 00000 n 0001895430 00000 n 0001895592 00000 n 0001895711 00000 n 0001895832 00000 n 0001895968 00000 n 0001896091 00000 n 0001896203 00000 n 0001896337 00000 n 0001896515 00000 n 0001896648 00000 n 0001896781 00000 n 0001896919 00000 n 0001897069 00000 n 0001897201 00000 n 0001897328 00000 n 0001897491 00000 n 0001897605 00000 n 0001897743 00000 n 0001897862 00000 n 0001897990 00000 n 0001898126 00000 n 0001898271 00000 n 0001898394 00000 n 0001898531 00000 n 0001898687 00000 n 0001898797 00000 n 0001898924 00000 n 0001899049 00000 n 0001899162 00000 n 0001899320 00000 n 0001899442 00000 n 0001899571 00000 n 0001899710 00000 n 0001899846 00000 n 0001899962 00000 n 0001900115 00000 n 0001900229 00000 n 0001900341 00000 n 0001900467 00000 n 0001900607 00000 n 0001900762 00000 n 0001900883 00000 n 0001901019 00000 n 0001901136 00000 n 0001901297 00000 n 0001901417 00000 n 0001901587 00000 n 0001901733 00000 n 0001901856 00000 n 0001901978 00000 n 0001902098 00000 n 0001902201 00000 n 0001902322 00000 n 0001902436 00000 n 0001902559 00000 n 0001902671 00000 n 0001902799 00000 n 0001902928 00000 n 0001903044 00000 n 0001903220 00000 n 0001903404 00000 n 0001903525 00000 n 0001903656 00000 n 0001903796 00000 n 0001903912 00000 n 0001904046 00000 n 0001904166 00000 n 0001904280 00000 n 0001904433 00000 n 0001904545 00000 n 0001904688 00000 n 0001904817 00000 n 0001904954 00000 n 0001905078 00000 n 0001905216 00000 n 0001905370 00000 n 0001905509 00000 n 0001905628 00000 n 0001905769 00000 n 0001905892 00000 n 0001906046 00000 n 0001906148 00000 n 0001906312 00000 n 0001906439 00000 n 0001906577 00000 n 0001906698 00000 n 0001906821 00000 n 0001906949 00000 n 0001907069 00000 n 0001907195 00000 n 0001907333 00000 n 0001907464 00000 n 0001907602 00000 n 0001907737 00000 n 0001907865 00000 n 0001907999 00000 n 0001908127 00000 n 0001908263 00000 n 0001908385 00000 n 0001908511 00000 n 0001908636 00000 n 0001908762 00000 n 0001908890 00000 n 0001909017 00000 n 0001909176 00000 n 0001909301 00000 n 0001909425 00000 n 0001909601 00000 n 0001909745 00000 n 0001909886 00000 n 0001909989 00000 n 0001910142 00000 n 0001910254 00000 n 0001910371 00000 n 0001910488 00000 n 0001910613 00000 n 0001910749 00000 n 0001910888 00000 n 0001911011 00000 n 0001911159 00000 n 0001911296 00000 n 0001911449 00000 n 0001911603 00000 n 0001911707 00000 n 0001911823 00000 n 0001911950 00000 n 0001912069 00000 n 0001912184 00000 n 0001912310 00000 n 0001912480 00000 n 0001912620 00000 n 0001912748 00000 n 0001912877 00000 n 0001913008 00000 n 0001913133 00000 n 0001913285 00000 n 0001913421 00000 n 0001913584 00000 n 0001913686 00000 n 0001913801 00000 n 0001913916 00000 n 0001914015 00000 n 0001914174 00000 n 0001914289 00000 n 0001914414 00000 n 0001914554 00000 n 0001914655 00000 n 0001914812 00000 n 0001914915 00000 n 0001915032 00000 n 0001915152 00000 n 0001915282 00000 n 0001915396 00000 n 0001915541 00000 n 0001915630 00000 n 0001915788 00000 n 0001915939 00000 n 0001916044 00000 n 0001916167 00000 n 0001916291 00000 n 0001916421 00000 n 0001916535 00000 n 0001916700 00000 n 0001916818 00000 n 0001916943 00000 n 0001917073 00000 n 0001917223 00000 n 0001917364 00000 n 0001917472 00000 n 0001917587 00000 n 0001917710 00000 n 0001917833 00000 n 0001917971 00000 n 0001918111 00000 n 0001918261 00000 n 0001918378 00000 n 0001918543 00000 n 0001918654 00000 n 0001918774 00000 n 0001918898 00000 n 0001919023 00000 n 0001919137 00000 n 0001919302 00000 n 0001919415 00000 n 0001919549 00000 n 0001919686 00000 n 0001919817 00000 n 0001919964 00000 n 0001920091 00000 n 0001920255 00000 n 0001920353 00000 n 0001920489 00000 n 0001920613 00000 n 0001920767 00000 n 0001920881 00000 n 0001921007 00000 n 0001921173 00000 n 0001921278 00000 n 0001921404 00000 n 0001921524 00000 n 0001921648 00000 n 0001921772 00000 n 0001921894 00000 n 0001922017 00000 n 0001922141 00000 n 0001922265 00000 n 0001922391 00000 n 0001922514 00000 n 0001922638 00000 n 0001922748 00000 n 0001922912 00000 n 0001923024 00000 n 0001923155 00000 n 0001923298 00000 n 0001923450 00000 n 0001923578 00000 n 0001923700 00000 n 0001923861 00000 n 0001923983 00000 n 0001924123 00000 n 0001924292 00000 n 0001924400 00000 n 0001924499 00000 n 0001924629 00000 n 0001924763 00000 n 0001924898 00000 n 0001925022 00000 n 0001925147 00000 n 0001925310 00000 n 0001925473 00000 n 0001925595 00000 n 0001925737 00000 n 0001925867 00000 n 0001926006 00000 n 0001926150 00000 n 0001926289 00000 n 0001926414 00000 n 0001926550 00000 n 0001926714 00000 n 0001926825 00000 n 0001926945 00000 n 0001927069 00000 n 0001927206 00000 n 0001927314 00000 n 0001927464 00000 n 0001927578 00000 n 0001927704 00000 n 0001927850 00000 n 0001927946 00000 n 0001928112 00000 n 0001928215 00000 n 0001928331 00000 n 0001928459 00000 n 0001928599 00000 n 0001928724 00000 n 0001928857 00000 n 0001928981 00000 n 0001929096 00000 n 0001929197 00000 n 0001929355 00000 n 0001929458 00000 n 0001929590 00000 n 0001929718 00000 n 0001929848 00000 n 0001929969 00000 n 0001930084 00000 n 0001930207 00000 n 0001930333 00000 n 0001930500 00000 n 0001930624 00000 n 0001930755 00000 n 0001930886 00000 n 0001931023 00000 n 0001931157 00000 n 0001931300 00000 n 0001931417 00000 n 0001931516 00000 n 0001931677 00000 n 0001931788 00000 n 0001931899 00000 n 0001932025 00000 n 0001932160 00000 n 0001932305 00000 n 0001932420 00000 n 0001932541 00000 n 0001932732 00000 n 0001932827 00000 n 0001932940 00000 n 0001933056 00000 n 0001933176 00000 n 0001933288 00000 n 0001933405 00000 n 0001933523 00000 n 0001933649 00000 n 0001933775 00000 n 0001933898 00000 n 0001934016 00000 n 0001934146 00000 n 0001934267 00000 n 0001934380 00000 n 0001934516 00000 n 0001934629 00000 n 0001934727 00000 n 0001934896 00000 n 0001935031 00000 n 0001935136 00000 n 0001935263 00000 n 0001935396 00000 n 0001935556 00000 n 0001935666 00000 n 0001935789 00000 n 0001935908 00000 n 0001936036 00000 n 0001936160 00000 n 0001936307 00000 n 0001936415 00000 n 0001936575 00000 n 0001936678 00000 n 0001936794 00000 n 0001936910 00000 n 0001937029 00000 n 0001937142 00000 n 0001937328 00000 n 0001937439 00000 n 0001937564 00000 n 0001937700 00000 n 0001937851 00000 n 0001938005 00000 n 0001938137 00000 n 0001938263 00000 n 0001938445 00000 n 0001938549 00000 n 0001938697 00000 n 0001938847 00000 n 0001938962 00000 n 0001939084 00000 n 0001939210 00000 n 0001939361 00000 n 0001939526 00000 n 0001939631 00000 n 0001939751 00000 n 0001939859 00000 n 0001940036 00000 n 0001940142 00000 n 0001940263 00000 n 0001940387 00000 n 0001940512 00000 n 0001940624 00000 n 0001940755 00000 n 0001940914 00000 n 0001941047 00000 n 0001941231 00000 n 0001941349 00000 n 0001941484 00000 n 0001941619 00000 n 0001941764 00000 n 0001941914 00000 n 0001942071 00000 n 0001942170 00000 n 0001942329 00000 n 0001942443 00000 n 0001942566 00000 n 0001942690 00000 n 0001942797 00000 n 0001942895 00000 n 0001943047 00000 n 0001943188 00000 n 0001943287 00000 n 0001943422 00000 n 0001943540 00000 n 0001943692 00000 n 0001943810 00000 n 0001943972 00000 n 0001944093 00000 n 0001944249 00000 n 0001944384 00000 n 0001944528 00000 n 0001944686 00000 n 0001944817 00000 n 0001944972 00000 n 0001945082 00000 n 0001945213 00000 n 0001945322 00000 n 0001945444 00000 n 0001945592 00000 n 0001945748 00000 n 0001945908 00000 n 0001946080 00000 n 0001946244 00000 n 0001946431 00000 n 0001946582 00000 n 0001946736 00000 n 0001946854 00000 n 0001947011 00000 n 0001947153 00000 n 0001947268 00000 n 0001947385 00000 n 0001947543 00000 n 0001947654 00000 n 0001947768 00000 n 0001947898 00000 n 0001948014 00000 n 0001948117 00000 n 0001948230 00000 n 0001948380 00000 n 0001948527 00000 n 0001948670 00000 n 0001948806 00000 n 0001948919 00000 n 0001949070 00000 n 0001949167 00000 n 0001949335 00000 n 0001949460 00000 n 0001949612 00000 n 0001949715 00000 n 0001949843 00000 n 0001949994 00000 n 0001950111 00000 n 0001950238 00000 n 0001950377 00000 n 0001950520 00000 n 0001950645 00000 n 0001950775 00000 n 0001950891 00000 n 0001951005 00000 n 0001951117 00000 n 0001951234 00000 n 0001951350 00000 n 0001951507 00000 n 0001951637 00000 n 0001951766 00000 n 0001951893 00000 n 0001952008 00000 n 0001952131 00000 n 0001952260 00000 n 0001952412 00000 n 0001952511 00000 n 0001952674 00000 n 0001952797 00000 n 0001952905 00000 n 0001953065 00000 n 0001953173 00000 n 0001953288 00000 n 0001953407 00000 n 0001953529 00000 n 0001953684 00000 n 0001953785 00000 n 0001953904 00000 n 0001954030 00000 n 0001954171 00000 n 0001954294 00000 n 0001954413 00000 n 0001954569 00000 n 0001954684 00000 n 0001954808 00000 n 0001954929 00000 n 0001955079 00000 n 0001955186 00000 n 0001955308 00000 n 0001955442 00000 n 0001955586 00000 n 0001955695 00000 n 0001955818 00000 n 0001955931 00000 n 0001956109 00000 n 0001956207 00000 n 0001956318 00000 n 0001956441 00000 n 0001956569 00000 n 0001956698 00000 n 0001956847 00000 n 0001956954 00000 n 0001957055 00000 n 0001957210 00000 n 0001957309 00000 n 0001957465 00000 n 0001957570 00000 n 0001957707 00000 n 0001957844 00000 n 0001957977 00000 n 0001958101 00000 n 0001958232 00000 n 0001958382 00000 n 0001958532 00000 n 0001958658 00000 n 0001958764 00000 n 0001958938 00000 n 0001959075 00000 n 0001959191 00000 n 0001959314 00000 n 0001959430 00000 n 0001959587 00000 n 0001959697 00000 n 0001959820 00000 n 0001959946 00000 n 0001960072 00000 n 0001960179 00000 n 0001960294 00000 n 0001960411 00000 n 0001960529 00000 n 0001960651 00000 n 0001960843 00000 n 0001960938 00000 n 0001961070 00000 n 0001961199 00000 n 0001961321 00000 n 0001961442 00000 n 0001961554 00000 n 0001961742 00000 n 0001961899 00000 n 0001962014 00000 n 0001962180 00000 n 0001962290 00000 n 0001962453 00000 n 0001962565 00000 n 0001962685 00000 n 0001962830 00000 n 0001963020 00000 n 0001963161 00000 n 0001963288 00000 n 0001963431 00000 n 0001963547 00000 n 0001963680 00000 n 0001963799 00000 n 0001963985 00000 n 0001964096 00000 n 0001964219 00000 n 0001964349 00000 n 0001964480 00000 n 0001964612 00000 n 0001964746 00000 n 0001964869 00000 n 0001965001 00000 n 0001965173 00000 n 0001965288 00000 n 0001965423 00000 n 0001965583 00000 n 0001965715 00000 n 0001965877 00000 n 0001966037 00000 n 0001966159 00000 n 0001966300 00000 n 0001966425 00000 n 0001966554 00000 n 0001966699 00000 n 0001966856 00000 n 0001966980 00000 n 0001967127 00000 n 0001967253 00000 n 0001967378 00000 n 0001967531 00000 n 0001967661 00000 n 0001967790 00000 n 0001967936 00000 n 0001968061 00000 n 0001968181 00000 n 0001968342 00000 n 0001968485 00000 n 0001968649 00000 n 0001968813 00000 n 0001968961 00000 n 0001969114 00000 n 0001969256 00000 n 0001969413 00000 n 0001969564 00000 n 0001969714 00000 n 0001969848 00000 n 0001970020 00000 n 0001970182 00000 n 0001970344 00000 n 0001970476 00000 n 0001970633 00000 n 0001970743 00000 n 0001970893 00000 n 0001971029 00000 n 0001971167 00000 n 0001971270 00000 n 0001971375 00000 n 0001971535 00000 n 0001971634 00000 n 0001971790 00000 n 0001971895 00000 n 0001972028 00000 n 0001972133 00000 n 0001972287 00000 n 0001972445 00000 n 0001972541 00000 n 0001972701 00000 n 0001972799 00000 n 0001972897 00000 n 0001973028 00000 n 0001973179 00000 n 0001973278 00000 n 0001973376 00000 n 0001973519 00000 n 0001973623 00000 n 0001973744 00000 n 0001973858 00000 n 0001973979 00000 n 0001974109 00000 n 0001974270 00000 n 0001974380 00000 n 0001974564 00000 n 0001974687 00000 n 0001974818 00000 n 0001974962 00000 n 0001975095 00000 n 0001975243 00000 n 0001975366 00000 n 0001975484 00000 n 0001975579 00000 n 0001975732 00000 n 0001975836 00000 n 0001975991 00000 n 0001976115 00000 n 0001976259 00000 n 0001976392 00000 n 0001976502 00000 n 0001976676 00000 n 0001976776 00000 n 0001976892 00000 n 0001977015 00000 n 0001977179 00000 n 0001977298 00000 n 0001977413 00000 n 0001977530 00000 n 0001977648 00000 n 0001977770 00000 n 0001977917 00000 n 0001978049 00000 n 0001978170 00000 n 0001978306 00000 n 0001978448 00000 n 0001978569 00000 n 0001978695 00000 n 0001978817 00000 n 0001978959 00000 n 0001979073 00000 n 0001979188 00000 n 0001979295 00000 n 0001979446 00000 n 0001979557 00000 n 0001979678 00000 n 0001979804 00000 n 0001979935 00000 n 0001980094 00000 n 0001980209 00000 n 0001980318 00000 n 0001980491 00000 n 0001980616 00000 n 0001980735 00000 n 0001980890 00000 n 0001981019 00000 n 0001981149 00000 n 0001981259 00000 n 0001981417 00000 n 0001981554 00000 n 0001981643 00000 n 0001981796 00000 n 0001981914 00000 n 0001982034 00000 n 0001982190 00000 n 0001982292 00000 n 0001982415 00000 n 0001982575 00000 n 0001982686 00000 n 0001982822 00000 n 0001982936 00000 n 0001983050 00000 n 0001983167 00000 n 0001983267 00000 n 0001983437 00000 n 0001983538 00000 n 0001983638 00000 n 0001983736 00000 n 0001983901 00000 n 0001984018 00000 n 0001984137 00000 n 0001984250 00000 n 0001984405 00000 n 0001984547 00000 n 0001984652 00000 n 0001984777 00000 n 0001984901 00000 n 0001985025 00000 n 0001985161 00000 n 0001985321 00000 n 0001985434 00000 n 0001985584 00000 n 0001985685 00000 n 0001985836 00000 n 0001985961 00000 n 0001986098 00000 n 0001986222 00000 n 0001986370 00000 n 0001986526 00000 n 0001986650 00000 n 0001986776 00000 n 0001986906 00000 n 0001987015 00000 n 0001987176 00000 n 0001987292 00000 n 0001987428 00000 n 0001987559 00000 n 0001987693 00000 n 0001987865 00000 n 0001987992 00000 n 0001988120 00000 n 0001988237 00000 n 0001988340 00000 n 0001988496 00000 n 0001988600 00000 n 0001988755 00000 n 0001988868 00000 n 0001989001 00000 n 0001989111 00000 n 0001989271 00000 n 0001989371 00000 n 0001989487 00000 n 0001989610 00000 n 0001989736 00000 n 0001989851 00000 n 0001989984 00000 n 0001990106 00000 n 0001990237 00000 n 0001990357 00000 n 0001990493 00000 n 0001990614 00000 n 0001990740 00000 n 0001990890 00000 n 0001991005 00000 n 0001991130 00000 n 0001991249 00000 n 0001991358 00000 n 0001991514 00000 n 0001991613 00000 n 0001991769 00000 n 0001991892 00000 n 0001992025 00000 n 0001992172 00000 n 0001992312 00000 n 0001992435 00000 n 0001992585 00000 n 0001992708 00000 n 0001992889 00000 n 0001993016 00000 n 0001993130 00000 n 0001993297 00000 n 0001993399 00000 n 0001993522 00000 n 0001993638 00000 n 0001993753 00000 n 0001993870 00000 n 0001993988 00000 n 0001994124 00000 n 0001994255 00000 n 0001994371 00000 n 0001994485 00000 n 0001994617 00000 n 0001994740 00000 n 0001994916 00000 n 0001995033 00000 n 0001995154 00000 n 0001995278 00000 n 0001995387 00000 n 0001995546 00000 n 0001995676 00000 n 0001995796 00000 n 0001995934 00000 n 0001996074 00000 n 0001996220 00000 n 0001996329 00000 n 0001996485 00000 n 0001996591 00000 n 0001996726 00000 n 0001996849 00000 n 0001996970 00000 n 0001997092 00000 n 0001997210 00000 n 0001997330 00000 n 0001997463 00000 n 0001997620 00000 n 0001997732 00000 n 0001997856 00000 n 0001997996 00000 n 0001998123 00000 n 0001998254 00000 n 0001998356 00000 n 0001998509 00000 n 0001998663 00000 n 0001998785 00000 n 0001998898 00000 n 0001999060 00000 n 0001999162 00000 n 0001999285 00000 n 0001999401 00000 n 0001999519 00000 n 0001999649 00000 n 0001999820 00000 n 0001999929 00000 n 0002000066 00000 n 0002000198 00000 n 0002000316 00000 n 0002000447 00000 n 0002000603 00000 n 0002000714 00000 n 0002000837 00000 n 0002000976 00000 n 0002001102 00000 n 0002001232 00000 n 0002001347 00000 n 0002001453 00000 n 0002001607 00000 n 0002001749 00000 n 0002001854 00000 n 0002001991 00000 n 0002002101 00000 n 0002002249 00000 n 0002002349 00000 n 0002002465 00000 n 0002002588 00000 n 0002002725 00000 n 0002002860 00000 n 0002002967 00000 n 0002003124 00000 n 0002003223 00000 n 0002003379 00000 n 0002003484 00000 n 0002003606 00000 n 0002003744 00000 n 0002003865 00000 n 0002003989 00000 n 0002004125 00000 n 0002004262 00000 n 0002004395 00000 n 0002004569 00000 n 0002004669 00000 n 0002004785 00000 n 0002004908 00000 n 0002005034 00000 n 0002005149 00000 n 0002005266 00000 n 0002005384 00000 n 0002005506 00000 n 0002005653 00000 n 0002005785 00000 n 0002005906 00000 n 0002006028 00000 n 0002006149 00000 n 0002006275 00000 n 0002006398 00000 n 0002006586 00000 n 0002006692 00000 n 0002006851 00000 n 0002006957 00000 n 0002007083 00000 n 0002007207 00000 n 0002007330 00000 n 0002007500 00000 n 0002007611 00000 n 0002007734 00000 n 0002007873 00000 n 0002007999 00000 n 0002008129 00000 n 0002008244 00000 n 0002008350 00000 n 0002008522 00000 n 0002008637 00000 n 0002008773 00000 n 0002008908 00000 n 0002009035 00000 n 0002009197 00000 n 0002009317 00000 n 0002009439 00000 n 0002009564 00000 n 0002009672 00000 n 0002009823 00000 n 0002009934 00000 n 0002010056 00000 n 0002010180 00000 n 0002010296 00000 n 0002010455 00000 n 0002010583 00000 n 0002010739 00000 n 0002010880 00000 n 0002011026 00000 n 0002011162 00000 n 0002011271 00000 n 0002011433 00000 n 0002011543 00000 n 0002011710 00000 n 0002011832 00000 n 0002011968 00000 n 0002012104 00000 n 0002012240 00000 n 0002012370 00000 n 0002012487 00000 n 0002012646 00000 n 0002012766 00000 n 0002012903 00000 n 0002013046 00000 n 0002013166 00000 n 0002013312 00000 n 0002013425 00000 n 0002013549 00000 n 0002013678 00000 n 0002013801 00000 n 0002013952 00000 n 0002014047 00000 n 0002014168 00000 n 0002014299 00000 n 0002014418 00000 n 0002014543 00000 n 0002014659 00000 n 0002014762 00000 n 0002014917 00000 n 0002015059 00000 n 0002015164 00000 n 0002015301 00000 n 0002015434 00000 n 0002015558 00000 n 0002015679 00000 n 0002015801 00000 n 0002015988 00000 n 0002016101 00000 n 0002016270 00000 n 0002016370 00000 n 0002016486 00000 n 0002016609 00000 n 0002016725 00000 n 0002016840 00000 n 0002016957 00000 n 0002017075 00000 n 0002017197 00000 n 0002017328 00000 n 0002017449 00000 n 0002017571 00000 n 0002017692 00000 n 0002017837 00000 n 0002017961 00000 n 0002018086 00000 n 0002018212 00000 n 0002018371 00000 n 0002018472 00000 n 0002018621 00000 n 0002018730 00000 n 0002018854 00000 n 0002018973 00000 n 0002019085 00000 n 0002019217 00000 n 0002019378 00000 n 0002019501 00000 n 0002019628 00000 n 0002019753 00000 n 0002019863 00000 n 0002020015 00000 n 0002020126 00000 n 0002020246 00000 n 0002020370 00000 n 0002020495 00000 n 0002020623 00000 n 0002020782 00000 n 0002020889 00000 n 0002021017 00000 n 0002021139 00000 n 0002021265 00000 n 0002021391 00000 n 0002021515 00000 n 0002021640 00000 n 0002021766 00000 n 0002021892 00000 n 0002022020 00000 n 0002022145 00000 n 0002022271 00000 n 0002022397 00000 n 0002022525 00000 n 0002022654 00000 n 0002022786 00000 n 0002022907 00000 n 0002023019 00000 n 0002023143 00000 n 0002023304 00000 n 0002023426 00000 n 0002023562 00000 n 0002023687 00000 n 0002023806 00000 n 0002023910 00000 n 0002024033 00000 n 0002024177 00000 n 0002024315 00000 n 0002024477 00000 n 0002024581 00000 n 0002024708 00000 n 0002024869 00000 n 0002024978 00000 n 0002025144 00000 n 0002025265 00000 n 0002025400 00000 n 0002025535 00000 n 0002025670 00000 n 0002025799 00000 n 0002025915 00000 n 0002026073 00000 n 0002026186 00000 n 0002026323 00000 n 0002026440 00000 n 0002026587 00000 n 0002026713 00000 n 0002026837 00000 n 0002026960 00000 n 0002027082 00000 n 0002027204 00000 n 0002027329 00000 n 0002027483 00000 n 0002027625 00000 n 0002027748 00000 n 0002027881 00000 n 0002028002 00000 n 0002028126 00000 n 0002028262 00000 n 0002028399 00000 n 0002028530 00000 n 0002028639 00000 n 0002028828 00000 n 0002028955 00000 n 0002029059 00000 n 0002029233 00000 n 0002029333 00000 n 0002029449 00000 n 0002029572 00000 n 0002029698 00000 n 0002029813 00000 n 0002029930 00000 n 0002030048 00000 n 0002030170 00000 n 0002030317 00000 n 0002030449 00000 n 0002030570 00000 n 0002030692 00000 n 0002030813 00000 n 0002030925 00000 n 0002031110 00000 n 0002031216 00000 n 0002031326 00000 n 0002031458 00000 n 0002031581 00000 n 0002031732 00000 n 0002031843 00000 n 0002031962 00000 n 0002032086 00000 n 0002032227 00000 n 0002032363 00000 n 0002032486 00000 n 0002032610 00000 n 0002032719 00000 n 0002032865 00000 n 0002033055 00000 n 0002033147 00000 n 0002033251 00000 n 0002033418 00000 n 0002033521 00000 n 0002033639 00000 n 0002033759 00000 n 0002033917 00000 n 0002034023 00000 n 0002034137 00000 n 0002034255 00000 n 0002034382 00000 n 0002034502 00000 n 0002034631 00000 n 0002034753 00000 n 0002034858 00000 n 0002035026 00000 n 0002035126 00000 n 0002035239 00000 n 0002035351 00000 n 0002035475 00000 n 0002035613 00000 n 0002035709 00000 n 0002035853 00000 n 0002035981 00000 n 0002036135 00000 n 0002036252 00000 n 0002036376 00000 n 0002036493 00000 n 0002036623 00000 n 0002036737 00000 n 0002036846 00000 n 0002036961 00000 n 0002037131 00000 n 0002037240 00000 n 0002037360 00000 n 0002037488 00000 n 0002037627 00000 n 0002037765 00000 n 0002037904 00000 n 0002038037 00000 n 0002038164 00000 n 0002038287 00000 n 0002038418 00000 n 0002038540 00000 n 0002038729 00000 n 0002038834 00000 n 0002038956 00000 n 0002039136 00000 n 0002039254 00000 n 0002039377 00000 n 0002039508 00000 n 0002039631 00000 n trailer <<0fd75976e7faed7da5a63462fbf86b1f>]>> startxref 2040723 %%EOF swig-3.0.2/Doc/Manual/android-simple.png0000664000175000017500000001726412343605122017714 0ustar williamwilliam‰PNG  IHDRÎv)r{IDATxœí”UU½Ço ©©é³Ÿýì­·ÞzÇwüð‡?¼þúë]Ô§>õ)µùý7>¨w¿üòËoºé¦t:ýàƒ®^½ú[ßúÖ7¿ùMIÔç?ÿù›o¾yîܹcÇŽÍ;rÄð“Ÿ0lð rGØ©NÞ 02Ž‹.ºhn€[n¹åÅ_üç?ÿù‹_üâöÛoFM:ÕåÒhpÙe—¹¨òòò7Þxã¯ýë»ï¾û—¿üå׿þµ”ÁÅ*eqqqìÙ¡÷!Ѽæšk¾öµ¯Iô~øay¾úÕ¯®\¹²¶¶öë_ÿú7¾ñÏ|æ3R’hÆ¢qE%M¾ás+î;ëŽû&訸ïlçYxß„›—ŸyÉôñg×¢ô£². ^_ÕÕ z_}õÕÁ¨É“'»\ãÇŸ5k–‹zÉã¹çž“æÈ³}ûöW_}ÕÅjà;ûì³;érCn¾ô¥/©WRwfjˆ~á…t¸sçΫ®º*6×–-[öíÛWUUež{î¹?þøþðÝ_ õ¹Ï¨Éᥗ^ZQQ!+@†Ciié%—\"W†Æµ×^k{F+Á¡\S&O™ûøûží·üùÄŠç<ŸyîîCw>:pê”)gÙ‡Œ™Of¢z«/¿ñÆe̼óÎ;ºÒ]…ŸwÞy.—ælúU«Ví‹cÍš56Rj{vèT}ôQ‰¬î…À†ÜvÛmo½õVccãOúS…k´æª¬¬´wð‹_ü¢ yöÙgß{ï=‰þÚµk—/_žû¤#FŒY¡û~×]w=ñį¿þúßÿþ÷_þò—O>ùä’%K®X‰{4ãy“λþ®1Ë·}¸z[BîkŽ™ué%Éä¬drvrÖœdòÒdòâ9³fNŸ9½èŒ"¥Ï[†Äqæ™gªk—¦>ýôÓê¶uÔ+H4ŠÉ°yûí·u!4&(z}—Ksp %%%jŒ®ò‹-¨Sq~õ%š@ŸvÚi±g‡ÎCÖ¶¤ݺurþóŸ»pÝq둱ºgÏyæÏŸ¯ýÝï~W~'Vuöºï_øÂl¬üšê^ËôÝïyO>ùdMùÔåÿñ”DmÛ¶M¢%÷•W^ùóŸÿ,C±Ã† å5bÄÉ¢÷ ªz&QõtŸª-‰O/ýÉiŸœ=köW¬yçÿÞÙ¹ó…ÊÊÏMŸ:}ÊESN;ÕˆSÇ(€¦#à4`©ºj§ì6Ín¥°¦OŸ®Jÿä'?QˆÒœ~úé­Õ5J×bµÇ† þ·Mÿûßÿ¾Í~ìã£|ît 7ÜpƒZ·5¨½“Éä—¿üe;J+Dcþ?þñ òë†J{ì1§ÿåÿñ,Wã€lãýž÷¬³Î’e¡þ^«Æù§L™"‰Ò$Xv„b‡L?|øÐqcO½å‘ƒïþŸßûTâž§þåž§so:éüIKÒé×_}m÷뻯H]9iây“&NRi#GÒ8)‰²}¦©jpœ1c†,6õ Ò{É®,Cpœ‡„Øå’Kî¾ûn…ÿà?pfzç× «ØÅ‹+¥¬Ø³Cg#kÛ*€ ‘aãn:c¨NB)ÅôkªúÈ#(Á½÷Þ«(« »víºÿþû52H$$ĹOªßÊ̲eËš››5åP‡¨ÙˆŒ*vðàÁÁôC‡ •VT®í·øÛN?‘Ho0ÇìkŽ¿éÆ›^ØþÂk¯¼¶mû¶]/¾¨š\TrÑØÓÆ=y¨ruŒH“ì,D›F¨t:-ãG  oݺUS7MÑÐÌ%Sï{ßûž:ŒçŸÞ ýo¼áüºè?ü°Ò(e¨ÁÐeD@]ò¢E‹48kœ×ýR袞yæ™ßÿþ÷êªëëë•K½Fo«wÞy§¬_¿^~W9Îxâ‰'Ú·ŸbÓ¦MÏ=÷ÜSO=%ÐDB]¡£½á¨Q#¦N›>;5¸ìþûÜc‰ÿ|,±øÛ‰’+Žqòˆ“‡Ÿ|ö¹g?ÞðdÍWª'Nœ4rÄÈ“†žtâ 'žÔ”[ uðwÙj2ߥåRwõ ÁZüñ.‹üj§¬Æ|ðg?û™ú_ýêWÎÿÒK/ÉpT¥Ìvjèl$pº/¿ür4J¢©(õúò«V'¥®:ô$CÝvMM<ÕÕÕJ¶qãFùeÇç8£dã„N°2£éŸ,u’%M!Ôo*P±AY 3z̸3ÆÏPù_ ‹þ;1ë¦)á ãYt¦ “aC‡§LÇ*,,ñ et±‡~¸j/#Rª)Wþ#Ž8ÂÅ*å!‡ÒI—zR€|ä#’Ýzý\¶l™:DM)e÷+ÄFÅ*€P͆fA¦—æ“ÇëÛWy+ÀÑq¨*z[oËĉïºë.Y~.D±cÇŽUÊ`®SN9EÃVl™A”æÔSO æ…ÞîµfºêccmT‡ÈCÇ(€l)Éú´ý¡4êÝ].‰õ9眳ß\– & z7îÑ£G“%Ž)S¦¨Cìå­‡ô"òV€€^ 4y+Àa½ˆ¼ vemíªZ\ÜÞá¶GªWV›ÌÞ!õ ÿ¨ZQ Ç¿çûóV€ê“Ó¹UË«ÒKÓUËZÜei£ ™iä*™Ñ7kÊY–öÝeUÁôÑÒ²¹¹Ï‚‹uójLN{È_¹¤²rQeùÂòÊ…•ò5ü-¯¦ñõd™¯!&AK¸ªZZeËÑáûU”Ó„@9¹ý¶|{È¿ßôøñç?x]²s%©ÍÛ›ß~ïm±cçI°t ½$mÜ¥ž,.1®Âeo)MÃÆ“Æ 7R¾$-åÑ¡Bö¾µWÇŽ—M!RM•Ù°¡Á/Е™Y²üpeaeõªê}ûö5nj4êä)¤IiÕ2³æ¸¸íU€ÀQ¿Öüé¡ik“d®isSyE¹‘¼…•ƳÐ<\ÉhÓ–&²lA™~ÚÃD-(¯[Sg Ùâ²Å"‘mÞÖœ‘xA¹óØ’Ûâ±çU”²¨(©™MïÒXÍ Užƒ#oÙÙ%pê°Kç”–Í/K]—Ú»w¯†‚²ËÔ—+J3c+”n¹õëë%ÓŠ²ÿ”·ÊS¿®Þ¦LÍK)£n[OãæF3>ìÝ«=oîQÞæ­Í©S¶äºµuŠRxåÒJUÉ(Àú†äܤ…›Äۛ̀#û*sv‹›ÿ°¼ÚZùÎ}û-cÿH¾ìÎ/3Ñ[o—Î-•ÈJ(5DHj•@ón#Óëê­¸K"¥ÐÔ‚”üJl Q·--ò`]½ ó_ÒWv™y¨«?êã¥3V…¤ Fз5KüŒKÓÆâÚР4¶äô"oˆÔ÷@vóVnêòKè%Uêò%vr%÷Ö(’ØI¦5>¨ó–\îÚ½K¹í­uÈSVaTE¢,¥óK]! Tˆ•{¥´¹$ÐÅïÙ³Gå”\X" Ç”° ÌŠ»,(JI” t;¯°ºaͰPýñàþ¼Àå´‡@òšœÜ±}Ǿ÷ö¥æ§di9ÞÖ¬~Z½µDVr)5p¢Y:¯T!J‰¦dW?•KÆŒ(åR¸¬—°¬­/™Z"m‘”Ë£~ÝW+ؽ+¨fv¬Z¹W¸õ„êÏq€ùKÓUK[ž½,M7mjÒ´U=´dZmºó¹¥Ö/¡—ŒÚXš`eZÂ* ±ÆIíªZ• ÑW®B¤ {vï1FÑÜT•gÊ[KÆz¤cVäñ ÂWɽòªLÙB.½¢lǯFš¹DMµ(‡êÿ÷ç?d–bì{ÍÞ{[‚[»ºÖôåóS;¶cF?ÍLÀ›†jÂêdº|a¹´Â΀nÔTK|m2‰xÝê:•à&ÁU-“Zé‰Q€Ý»ä±3oóòaI¥û÷°bíƒQ›^³e·ÅÊ•"ýø£þüG€àóø%iÍDÍÜ÷:s˜'ÞOç‰J¸Õ‹«c.™Q"¿(65Êcþ˜d-O<íRÿé§-Á{ j‹ÒØ¢\i¯¿7š6§ÔÔÁ‹²OE[ëИñŽwI» pøÒVxèz<¿ÐUlO|ÕU›ç¤ Êì«1‰¯Ñ“@ ¦k_Ôš«õ‘fù*Ê*R_UyýÒZêà¿ àày+€£ keNn(<6¥ÄÑØúÞ³|Y&ö•”a¿y£®rù¯½64˜ q‹ˆãâ¶ÝmÏÐîóU.ªtfŒŽÔu)¿ão—ìºÞÝõñÝ~5q?pnŒíÐÉ«[ãÐ>éOFžÊ¶?¸¸Q·KG\Üžævõ€‹Û£Ü¼|úè_<©89'Y:§´ó\¢=ÿÞèTúÔ¯zeµYë¶µ¹ikSç¹M››jWÕJÙº»Åª–WízŬ?3nç»}·ª&ÿuKÇ®—wííB¤ÝÝb€öOX{ßì:·»[ @BÙ*{:Ù}Ó,“îîPv1ÝÝb€¾Tîî׺»ÅöxÿеOi$¦î‰Mgùw3 †žD«ô¿²Ç=µì<¿t »[ ÀHçËæØñòŽNw=Mèîð¥çç&ú&† R8¨ÐìŠï×Óîn1@+æØî»ýêgý%SKjWÕºðŽqwîèî°BÙ¼½Yj]«òWy{5mn*šPdCRóRõëê›·6+’¿xR±”$˜7·ku »[ ÀHç¶æà!°ž¢ñE÷ÆMòسcܺú¦-M2“ä*$9#iT"³„¬Çvstw‹˜½ß¶íP§nÔsÍ`Ø©AÕŠ*…´*ÀÖf»e¢D_“¢y‚Ì$—w?î63tw‹H(ýË[|׎•Þ?tC œ“´ 0zÔè¶+€+ÙW0€žƒJ+[Œë+€ç/Tذ¡¡iSSÁQ6Jžº5uR £^³ôÊjù«–WÙ4A+³UPèQX¹4Çfß•XuMµú~ù%åR†â ÅÉÙIõ÷Ø4fÿÕÕÒ“‚‚…øž-M.$X²q·6uw‹˜ÿjYéÜÜÔ¸¹Ñz:ÉoÇîn1@óE£Ífû6}Xèî°Ý¿•ÎVIÝÔ þÍþ·Ãº»ÅZå~c—¸›»»Å¬ÞEÒïÝÝb€¾ôollØØÐé®§ÝÝb€þô—LÜÀï¡7v²Ÿz ëºbÜr4lhèîH/Mûo¬Ü“ÐÍî÷߈mijÏçœ:þýû×­©³«tÚ´¢³ÝîÖæúµõG±?.ô0 ’3’ö‘©ëRîÚ?ê… »»­kW×Ö­­+_PžèÛ1eŽ>utåBóÕ↠ukêt”W´µp—×Q4®¨uh{®ö•½YN_ó¼âIÅRfá`³£hFáËÚZ¸ËëÓ7Q»ª6ï´=Wûʇ^ƒ[—V:·TGÿýÓKÓå Ë­X$g˜ t7ݤb«WTW¯¬®]YÛ¯_?ý¬ZQ%uMµ~º2^2µ$á­± ^pT²ÛuóêzM5Õ•‹*ÍŒKÓG—×’šŸÒ¥Ø!ƒ‡ë#O°¡š(——+½,­:×­®2lˆMìÚ*8¬Œšï×TËüpHt¬4hXHx+…ê×Õ'<ù+WjÒ{â.IMÍK¹Ÿ1…{Ú¥XIçèQ£Ô„@ò§òÞ‚<¥ Ñ7Q¿¶Þz•ݨ¥gJ©œÂA­K*Â5 är*<½Ä, ¶1”8Ì@}êJ¿O•p¨§´Q2Z$¦Ë¯©–/%‘J(V}¹ü OC”×ýŒbæ«ë¤¶Sœ¢IHÑ„ˆ9Ðâ ‹u$= áš(׺zWBÙue}êéCmDtBKóƒYra‰™g¢Þ49;)²¢æÿ\S«¶põͲ4Vܰ(¬e ÊŠ'Dæ U}œ¨Ì”Q“`®©%f ®ÙÅ B@ œ8Щ_ŸqûeÈ\öýÌik?X+Å™:2WdB„~f-Ü›hJú•¾nm QÉÆâ œNÂ3jh& -‰eSW•Fkâr%ç$­u$ýBð¤W oŸ~D=Ð[É¡ Ï ²“NûhR?«Ãö©¡Ÿ9 —dÛÞ7u]J¢/ATmT® Øù«ÄÑžQÒL­‰Ëeû{)L6p)Íž§ž~F=Ð+ÐÔÓ.×±J41mcÆ6¦Ôd×Î_zb·C‰yÐÙ7|<’‹6§D çZz©A aCƒ{”.Yö³ªÖþ”†T.©,¯(W`(¥{:éVV–Î-µˆ@Ï¥jy•ÄÚ-ŒÉxìí­º‘ø*AÂS }4¥Yˆæ=ãwï¹Ì_;>xÉPèÑM(ò_-e*€ºy‰¾ºy÷þ(¸‚À¥,žT,¿:{öͱBR×¥l¬Ñ.z8~çëÖ%4 c^ f*@Æ ~/€v…O“r+ÜíXB]2”a­ñL –Ù@DÆT†™ªzÆ};–Ð$"K†-“`;if™ ôì“û† þî=ö…@—½íëŽòMÜ-ØE¡GŽláï‡ä³GFèt»­öCöå½}Iÿ>·½ˆYÒÒ×ÿ e÷ì¾û¯[[ç¯4ky,nÙïÕˆ¯yäŒCÕrÿï…q“²ÒöuGù&î&œˆôÐ?6A¶ðv#is²}ÝP«ýúõ³U’ Ù·õí&ª*PbíÄÑÿÃjߌ¿\çØs)÷Õˆ­yèŒFPì£LûÓÆF×ù8”2½4]¿¾^é º•B±¹B+‹r¯&RMT+ýTg¦kJìP.hÆ./Wë&g$]!ê Ír…•¥sKm§¢KŸ#*¾œU¶±î²8B«ž\'bJó¤Ó^UjZìé‚W2ØØ`2¹ºò**(—G¨’JúËhl×]ëmfŽ5]VF8š·ŸóRN¢ì_ÀMãÈq5²¥Œž±Ã*€äÌ ‘6ïm@hC6‰­Šî„.wp¥P|®Ì•E¹WéêÒ»\áEJÁm‚q™·U²oè”Ò¾wSU]mã£r–z±]õän˜êo‹µ’áÂCMËvºªÇn š‡vdÒe´;‹…@?ý“‰[ëlæ~×tÅÑ\½–}:œ5¨\V¸Cl¶«%TóNW€ÖMJn,S·]çãr¹•¤N¤\ÞØ\¡•E¹WÙaTꮢ \pú©K¦›¬’NjÛ¨yŽ’åˆÊ]޽,±'µBãn­[Bb×¶öy™MË}º­KD@eZ• )€±"âú×k½ÜÝϽ¤%·¸dºv¡#ÛÕ—©y§+@h†è:Ÿ v¬´ßóFsEWå^MdØI•¹4íUW¥¨d‹Ê]NhëŠ hP+U¡•T®i¹O—£u‰ˆ˜í½§®•¬#ÛqÚ¡#jpç^ëåî~Û jSJŽƒ!Ù®F0KlÍ»Z¢ë|Zé›Zx¹7Š®,Jä\M”cŸ‡?@·ØH±¶D; w9!ˆ®z &Viæ ™žn»ðPÓrŸ®õò¶Í²¸ÀZᱟå̽ÖË63fMW&Aq vêJl©ýoìmk©l5ïjHÄ­óññ.Š]J´q-¡\Ñ•E‰œ«‰rìó¬BëÞ½¡IpËCÀv(@îr¢›…V=ëŽJoýGC-áѦå8]èžHûU¹ª€?,¬©Ëèƒs®õrÍ µ.t¢8Úg:¬Å¯æÛ ëÈ6ȶµT¶šwŠ´ÕÃoUßÖ' öƒñÙ-ö;èã 4iÕè)7vKCèÙ¸…@Ù^ÚµÍ)íë=7= ]1ÐmD/¾Ì›,»  å‰˜#vÅ@·R€Ð‚“ض£î?´x&÷뀮&¨1/e²“B¢l/Ø#ôÎBÓbûH8ô&/Ç s€nÀÍÊ+Ê£ïÛcßÀ·iEÈÎA gòR€Ü#€#´œzí6rà$Þì}²Æÿ(˜]¨]1ÐdωL‚ç´Õþ±kBìBpkäw ­è*º~-P¶Ý]Ün6±i¢;ÌÈÜÖ7v'™þúÛ½rü±hºx-P"Ëî.ÁÝlbÓ„^¨÷2p®‹ÙIfEïÚ ]¼(·»Kt7›Pšè3ÁÄ:Eì®[ÿ€.^ d )@ìn6¡?\‡v˜1›²xªe¶Êü¿¶ÛIFu¥d*Ÿq@<]¼ÈÚO&~7›¸¿?w˜IÍKI²•Æý©?‘¹“Œ ôý}Ã+2|ºx-%(ܱ»Ù$²ÿÿ?´ÃŒp[n„v’‘æÖiÌdbèâµ@–XáÎ1äØaF:iwR‰î$ãO¼ÄŒOׯJ䯱;ÌØç›JcÕ#v'7iÇ zÁµ@9>‘ÔQŸ¾ò?0 g,ÁÈ› æxVÕ>ˆ~o {ÈxürSæç¢²}Ô©Ÿ jªo®Ï§tÙ ô¹¨¬Ÿ¸jÃgÅb?5Õ«¯ÚOp-PPBŸ‹ÊöQ§¶|V,öK;¬Ó„A¶ ü­¤,ujËgÅb@Û0€¶¯„?qՆϊÅ|j*si@·‘¯„>êÔÆÏŠ…>5Z=šÿ'ޝSé‹2ÃIEND®B`‚swig-3.0.2/preinst-swig.in0000775000175000017500000000032612343605122015332 0ustar williamwilliam#!/bin/sh builddir=`dirname $0` srcdir=`cd "$builddir" && cd '@srcdir@' && pwd` SWIG_LIB=$srcdir/Lib #SWIG_LIB=`cygpath -w $srcdir/Lib` # For native Windows version of SWIG export SWIG_LIB exec "$builddir/swig" $* swig-3.0.2/CHANGES0000664000175000017500000343205712343605122013354 0ustar williamwilliamSWIG (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.1 (27 May 2014) =========================== 2014-05-25: hfalcic [Python] Python 3 byte string output: use errors="surrogateescape" if available on the version of Python that's in use. This allows obtaining the original byte string (and potentially trying a fallback encoding) if the bytes can't be decoded as UTF-8. Previously, a UnicodeDecodeError would be raised with no way to treat the data as bytes or try another codec. 2014-05-18: vkalinin Bug #175 - Restore %extend to work for unnamed nested structures by using a C symbol comprising the outer structure name and unnamed variable instance name. 2014-05-15: kwwette Add #166 - 'make check' now works out of source. This required te examples to build out of source. The main languages have been tested - C#, Go, Guile, Java, Javascript, Lua, Octave, Perl, PHP, Python, Ruby and Tcl. 2014-05-01: Oliver Buchtala Javascript support added, see Javascript chapter in the documentation. 2014-05-01: olly [PHP] The generated __isset() method now returns true for read-only properties. 2014-04-24: kwwette [Go] Fix go ./configure parsing of gccgo --version, and goruntime.swg typo in __GNUC_PATCHLEVEL__ (SF Bug #1298) 2014-04-24: kwwette Fix {python|perl5|ruby|tcl}/java examples In Lib/gcj/cni.i, for compatibility with newer gcj versions: - remove JvAllocObject() which gcj no longer defines, from gcj Changelog: 2004-04-16 Bryce McKinlay * gcj/cni.h (JvAllocObject): Remove these obsolete, undocumented CNI calls. - change JvCreateJavaVM() argument from void* to JvVMInitArgs*, from gcj Changelog: 2005-02-23 Thomas Fitzsimmons PR libgcj/16923 ... (JvCreateJavaVM): Declare vm_args as JvVMInitArgs* rather than void*. *** POTENTIAL INCOMPATIBILITY *** 2014-04-08: wsfulton SF Bug #1366 - Remove duplicate declarations of strtoimax and strtoumax in inttypes.i 2014-04-08: wsfulton [Java C#] Enums which have been ignored via %ignore and are subsequently used are handled slightly differently. Type wrapper classes are now generated which are effectively a wrapper of an empty enum. Previously in Java uncompilable code was generated and in C# an int was used. 2014-04-04: wsfulton Fix regression in 3.0.0 where legal code following an operator<< definition might give a syntax error. SF Bug #1365. 2014-04-03: olly [PHP] Fix wrapping director constructors with default parameters with a ZTS-enabled build of PHP. 2014-04-02: olly [PHP] Pass the ZTS context we already have to avoid needing to call TSRMLS_FETCH, which is relatively expensive. 2014-04-02: olly [PHP] Pass ZTS context through to t_output_helper() so it works with a ZTS-enabled build of PHP. Reported by Pierre Labastie in github PR#155. 2014-03-28: wsfulton [Java C# D Go] Fixes for C enums used in an API and the definition of the enum has not been parsed. For D, this fixes a segfault in SWIG. The other languages now produce code that compiles, although the definition of the enum is needed in order to use the enum properly from the target language. 2014-03-23: v-for-vandal [Lua] Fix for usage of snprintf in Lua runtime which Visual Studio does not have. Version 3.0.0 (16 Mar 2014) =========================== 2014-03-16: wsfulton C++11 support initially developed as C++0x support by Matevz Jekovec as a Google Summer of Code project has been further extended. The C++11 support is comprehensive, but by no means complete or without limitations. Full details for each new feature in C++11 is covered in the CPlusPlus11.html chapter in the documentation which is included in SWIG and also available online at http://www.swig.org/Doc3.0/CPlusPlus11.html. 2014-03-14: v-for-vandal [Lua] Numerous Lua improvements: 1. %nspace support has been added. Namespaces are mapped to tables in the module, with the same name as the C++ namespace. 2. Inheritance is now handled differently. Each class metatable keeps a list of class bases instead of merging all members of all bases into the derived class. 3. The new metatables result in differences in accessing class members. For example: %module example struct Test { enum { TEST1 = 10, TEST2 = 20 }; static const int ICONST = 12; }; Now this can be used as follows: print(example.Test.TEST1) print(example.Test.ICONST) The old way was: print(example.Test_TEST1) print(example.Test_ICONST) 4. The special class metatable member ".constructor" was removed. Now SWIG generates the proxy function by itself and assigns it directly to the class table "__call" method. 5. eLua should also now support inheritance. 6. 'const' subtable in eLua is considered deprecated. Changes in behaviour: a. You can no longer assign to non-existing class members in classes without a __setitem__ method. It will cause a Lua error. b. You can no longer iterate over a module table and copy everything into the global namespace. Actually, this was never the case, but it is now explicitly prohibited. c. Now changing a base class will immediately affect all derived classes. d. There might be some issues with inheritance. Although the bases iteration scheme is the same as was used for merging base classes into derived one, some unknown issues may arise. The old metatable behaviour can be restored by using the -no-old-metatable-bindings option. *** POTENTIAL INCOMPATIBILITY *** 2014-03-06: wsfulton [Python] Change in default behaviour wrapping C++ bool. Only a Python True or False will now work for C++ bool parameters. This fixes overloading bool with other types. Python 2.3 minimum is now required for wrapping bool. When wrapping: const char* overloaded(bool value) { return "bool"; } const char* overloaded(int value) { return "int"; } Previous behaviour: >>> overloaded(False) 'int' >>> overloaded(True) 'int' >>> overloaded(0) 'int' Now we get the expected behaviour: >>> overloaded(False) 'bool' >>> overloaded(0) 'int' The consequence is when wrapping bool in non-overloaded functions: const char* boolfunction(bool value) { return value ? "true" : "false"; } The previous behaviour was very Pythonic: >>> boolfunction("") 'false' >>> boolfunction("hi") 'true' >>> boolfunction(12.34) 'true' >>> boolfunction(0) 'false' >>> boolfunction(1) 'true' Now the new behaviour more along the lines of C++ due to stricter type checking. The above calls result in an exception and need to be explicitly converted into a bool as follows: >>> boolfunction(0) Traceback (most recent call last): File "", line 1, in TypeError: in method 'boolfunction', argument 1 of type 'bool' >>> boolfunction(bool(0)) 'false' The old behaviour can be resurrected by passing the -DSWIG_PYTHON_LEGACY_BOOL command line parameter when executing SWIG. Typemaps can of course be written to customise the behaviour for specific parameters. *** POTENTIAL INCOMPATIBILITY *** 2014-03-06: wsfulton Fix SF Bug #1363 - Problem with method overloading when some methods are added by %extend and others are real methods and using template default parameters with smart pointers. This is noticeable as a regression since 2.0.12 when using the default smart pointer handling for some languages when the smart pointer wraps std::map and other STL containers. 2014-03-02: wsfulton [Python] SF Patch #346 from Jens Krueger. Correct exception thrown attempting to access a non-existent C/C++ global variable on the 'cvar' object. The exception thrown used to be a NameError. However, as this access is via a primary, an AttributeError is more correct and so the exception thrown now is an AttributeError. Reference: http://docs.python.org/2/reference/expressions.html#attribute-references *** POTENTIAL INCOMPATIBILITY *** 2014-03-01: wsfulton [Python] Patch #143 Fix type shown when using type() to include the module and package name when using -builtin. 2014-03-01: wsfulton [Python] SF patch #347 Fix missing argument count checking with -modern. Fixes regression introduced when builtin changes were introduced in SWIG-2.0.3. 2014-02-21: wsfulton [PHP] Fix warning suppression using %warnfilter for PHP reserved class names. 2014-02-19: olly [Lua] Add keyword warnings for Lua keywords and Basic Functions. 2014-02-19: olly -Wallkw now includes keywords for all languages with keyword warnings (previously Go and R were missing). 2014-02-19: olly [PHP] Update the lists of PHP keywords with new ones from PHP 5.4 and newer (and some missing ones from 5.3). Reserved PHP constants names are now checked against enum values and constants, instead of against function and method names. Built-in PHP function names no longer match methods added by %extend. Functions and methods named '__sleep', '__wakeup', 'not', 'parent', or 'virtual' are no longer needlessly renamed. 2014-02-15: wsfulton Fix the %$ismember %rename predicates to also apply to members added via %extend. Add %$isextendmember for %rename of members added via %extend. This can be used to distinguish between normal class/struct members and %extend members. For example '%$ismember, %$not %$isextendmember' will now identify just class/struct members. *** POTENTIAL INCOMPATIBILITY *** 2014-02-16: hfalcic [Python] Patch #137 - fix crashes/exceptions in exception handling in Python 3.3 2014-02-15: wsfulton [Java] Add support for the cdata library. 2014-02-08: vkalinin Nested class support added. This primarily allows SWIG to properly parse nested classes and keep the nested class information in the parse tree. Java and C# have utilised this information wrapping the C++ nested classes as Java/C# nested classes. The remaining target languages ignore nested classes as in previous versions. Help is needed by users of these remaining languages to design how C++ nested classes can be best wrapped. Please talk to us on the swig-devel mailing list if you think you can help. Previously, there was limited nested class support. Nested classes were treated as opaque pointers. However, the "nestedworkaround" feature provided a way to wrap a nested class as if it was a global class. This feature no longer exists and is replaced by the new "flatnested" feature. This effectively does the same thing with less manual code to be written. Please see the 'Nested classes' section in the documentation in SWIGPlus.html if you were previously using this feature. SWIG now parses the contents of nested classes where previously it did not. You may find that you will need to make adjustments to your interface file as effectively extra code is being wrapped. *** POTENTIAL INCOMPATIBILITY *** 2014-02-06: gjanssens [Guile] Patch #133. Make scm to string conversion work with non-ascii strings. Guile 2 has a completely rewritten string implementation. SWIG made some assumptions that are no longer valid as to the internals of guile's string representation. 2014-01-30: wsfulton [C#] Add new swigtype_inout.i library containing SWIGTYPE *& OUTPUT typemaps. Example usage wrapping: void f(XXX *& x) { x = new XXX(111); } would be: XXX x = null; f(out x); // use x x.Dispose(); // manually clear memory or otherwise leave out and leave it to the garbage collector 2014-01-21: ianlancetaylor [Go] Add %go_import directive. 2014-01-21: ianlancetaylor [Go] Add support for Go 1.3, not yet released. 2014-01-20: wsfulton Director exceptions (Swig::DirectorException) now derive from std::exception and hence provide the what() method. In Python and Ruby, this replaces the now deprecated DirectorException::getMessage() method. 2014-01-14: diorcety Patch #112 - Fix symbol resolution involving scopes that have multiple levels of typedefs - fixes some template resolutions as well as some typemap searches. 2014-01-11: wsfulton Fix and document the naturalvar feature override behaviour - the naturalvar feature attached to a variable name has precedence over the naturalvar feature attached to the variable's type. The overriding was not working when turning the feature off on the variable's name. Fix so that any use of the naturalvar feature will override the global setting. Previously when set globally by -naturalvar or %module(naturalvar=1), use of the naturalvar feature was not always honoured. 2014-01-06: ianlancetaylor [Go] Fix bug that broke using directors from a thread not created by Go. 2013-12-24: ptomulik [Python] SF Bug #1297 Resolve several issues related to python imports. For example, it's now possible to import modules having the same module names, but belonging in different packages. From the user's viewpoint, this patch gives a little bit more control on import statements generated by SWIG. The user may choose to use relative or absolute imports. Some details: - we (still) generate import statements in the form 'import a.b.c' which corresponds to absolute imports in python3 and (the only available) ambiguous one in python2. - added -relativeimport option to use explicit relative import syntax (python3), The "Python Packages" section in the documentation discusses how to work with importing packages including the new -relativeimport command line option. 2013-12-23: vadz [Octave, Perl, Python, R, Ruby, Tcl] Change the length of strings created from fixed-size char buffers in C code. This is a potential backwards compatibility break: a "char buf[5]" containing "ho\0la" was returned as a string of length 5 before, but is returned as a string of length 2 now. Also, it was possible to assign a (non-NUL-terminated) string "hello" to such a buffer before but now this fails and only "helo" can fit. Apply "char FIXSIZE[ANY]" typemaps to explicitly choose the old behaviour. *** POTENTIAL INCOMPATIBILITY *** 2013-12-23: talby [Perl] Add support for directors. 2013-12-18: ianlancetaylor [Go] Don't require that Go environment variables be set when running examples or testsuite when using Go 1 or later. 2013-12-17: ianlancetaylor [Go] Remove -longsize option (for backward compatibility, ignore it if seen). 2013-12-17: ianlancetaylor [Go] Add -go-pkgpath option. 2013-12-16: ianlancetaylor [Go] Update for Go 1.2 release. Add support for linking SWIG code directly into executable, rather than using a shared library. 2013-12-13: ianlancetaylor [Go] Add SWIG source file name as comments in generated files. This can be used by Go documentation tools. 2013-12-12: jleveque [Lua] Fix typo (wchar instead of wchar_t) which made wchar.i for Lua useless. 2013-12-12: vmiklos [PHP] PHP's peculiar call-time pass-by-reference feature was deprecated in PHP 5.3 and removed in PHP 5.4, so update the REF typemaps in phppointers.i to specify pass-by-reference in the function definition. Examples/php/pointer has been updated accordingly. 2013-12-12: olly [PHP] The usage of $input in PHP directorout typemaps has been changed to be consistent with other languages. The typemaps provided by SWIG have been updated accordingly, but if you have written your own directorout typemaps, you'll need to update $input to &$input (or make equivalent changes). *** POTENTIAL INCOMPATIBILITY *** 2013-11-27: vadz [C#, Java, Python] Add std_auto_ptr.i defining typemaps for returning std::auto_ptr<>. 2013-11-09: wsfulton [C#] Apply patch #79 from Brant Kyser - Remove using directives from the generated C# code and fully qualify the use of all .NET framework types in order to minimize potential name collisions from input files defining types, namespace, etc with the same name as .NET framework members. - Globally qualify the use of .NET framework types in the System namespace - Remove .NET 1.1 support, .NET 2 is the minimum for the C# module This is a potential backwards compatibility break if code has been added relying on these using statements that used to be generated: using System; using System.Runtime.InteropServices; The quick fix to add these back in is to add the -DSWIG2_CSHARP command line option when executing SWIG. See CSharp.html documentation for more info. *** POTENTIAL INCOMPATIBILITY *** 2013-11-05: wsfulton [Java] Fix some corner cases for the $packagepath/$javaclassname special variable substitution. 2013-11-05: wsfulton [Java] Apply patch #91 from Marvin Greenberg - Add director:except feature for improved exception handling in director methods for Java. 2013-10-15: vadz Allow using \l, \L, \u, \U and \E in the substitution part of %(regex:/pattern/subst/) inside %rename to change the case of the text being replaced. 2013-10-12: wsfulton [CFFI] Apply #96 - superclass not lispify 2013-10-12: wsfulton Merge in C++11 support from the gsoc2009-matevz branch where Matevz Jekovec first started the C++0x additions. Documentation of the C++11 features supported is in a new Chapter of the documentation, "SWIG and C++11" in Doc/Manual/CPlusPlus11.html. 2013-10-04: wsfulton Fix %naturalvar not having any affect on templated classes instantiated with an enum as the template parameter type. Problem reported by Vadim Zeitlin. 2013-09-20: wsfulton [Java] Fix a memory leak for the java char **STRING_ARRAY typemaps. Version 2.0.12 (9 Feb 2014) =========================== 2014-01-16: wsfulton [PHP] Fix compilation error in ZTS mode (64 bit windows) due to incorrect placement of TSRMLS_FETCH() in SWIG_Php_GetModule() as reported by Mark Dawson-Butterworth. 2014-01-13: kwwette [Octave] update support to Octave version 3.8.0 - Octave 3.8.0 no longer defines OCTAVE_API_VERSION_NUMBER, but 3.8.1 will define OCTAVE_{MAJOR,MINOR,PATCH}_VERSION instead: see http://hg.savannah.gnu.org/hgweb/octave/rev/b6b6e0dc700e So we now use a new macro SWIG_OCTAVE_PREREQ(major,minor,patch) to enable features requiring Octave version major.minor.patch or later. For Octave versions prior to 3.8.1, we reconstruct values for OCTAVE_{MAJOR,MINOR,PATCH}_VERSION based on OCTAVE_API_VERSION_NUMBER, extracted from Octave's ChangeLogs. An additional hack is needed to distinguish between Octave <= 3.2.x and 3.8.0, neither of which define OCTAVE_API_VERSION_NUMBER. - Octave 3.8.0 deprecates symbol_table::varref(), so remove its use for this and future versions of Octave. - Octave 3.8.0 removes octave_value::is_real_nd_array(), used in octave_swig_type::dims(). Its use is not required here, so remove it. - Retested against Octave versions 3.0.5, 3.2.4, 3.4.3, 3.6.4, and 3.8.0. - Updated Octave documentation with tested Octave versions, and added a warning against using versions <= 3.x.x, which are no longer tested. 2013-12-22: wsfulton C++11 support for new versions of erase and insert in the STL containers. The erase and insert methods in the containers use const_iterator instead of iterator in C++11. There are times when the methods wrapped must match the parameters exactly. Specifically when full type information for template types is missing or SWIG fails to look up the type correctly, for example: %include typedef float Real; %template(RealVector) std::vector; SWIG does not find std::vector::iterator because %template using typedefs does not always work and so SWIG doesn't know if the type is copyable and so uses SwigValueWrapper which does not support conversion to another type (const_iterator). This resulted in compilation errors when using the C++11 version of the containers. Closes #73 2013-10-17: wsfulton [R] Fix SF #1340 - Visual Studio compile error in C++ wrappers due to #include within extern "C" block. 2013-10-17: wsfulton [Python] Fix SF #1345 - Missing #include for offsetof when using -builtin. 2013-10-12: wsfulton [Lua] Apply #92 - missing return statements for SWIG_Lua_add_namespace_details() and SWIG_Lua_namespace_register(). Version 2.0.11 (15 Sep 2013) ============================ 2013-09-15: wsfulton [R] Fix attempt to free a non-heap object in OUTPUT typemaps for: unsigned short *OUTPUT unsigned long *OUTPUT signed long long *OUTPUT char *OUTPUT signed char*OUTPUT unsigned char*OUTPUT 2013-09-12: wsfulton [Lua] Pull Git patch #62. 1) Static members and static functions inside class can be accessed as ModuleName.ClassName.FunctionName (MemberName respectively). Old way such as ModuleName.ClassName_FunctionName still works. 2) Same goes for enums inside classes: ModuleName.ClassName.EnumValue1 etc. 2013-09-12: wsfulton [UTL] Infinity is now by default an acceptable value for type 'float'. This fix makes the handling of type 'float' and 'double' the same. The implementation requires the C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available. Users requiring the old behaviour of not accepting infinity, can define a 'check' typemap wherever a float is used, such as: %typemap(check,fragment="") float, const float & %{ if ($1 < -FLT_MAX || $1 > FLT_MAX) { SWIG_exception_fail(SWIG_TypeError, "Overflow in type float"); } %} *** POTENTIAL INCOMPATIBILITY *** 2013-08-30: wsfulton [Lua] Pull Git patch #81: Include Lua error locus in SWIG error messages. This is standard information in Lua error messages, and makes it much easier to find bugs. 2013-08-29: wsfulton Pull Git patch #75: Handle UTF-8 files with BOM at beginning of file. Was giving an 'Illegal token' syntax error. 2013-08-29: wsfulton [C#] Pull Git patch #77: Allow exporting std::map using non-default comparison function. 2013-08-28: wsfulton [Python] %implicitconv is improved for overloaded functions. Like in C++, the methods with the actual types are considered before trying implicit conversions. Example: %implicitconv A; struct A { A(int i); }; class CCC { public: int xx(int i) { return 11; } int xx(const A& i) { return 22; } }; The following python code: CCC().xx(-1) will now return 11 instead of 22 - the implicit conversion is not done. 2013-08-23: olly [Python] Fix clang++ warning in generated wrapper code. 2013-08-16: wsfulton [Python] %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer. Problem highlighted by Bo Peng. Closes SF patch #230. 2013-08-07: wsfulton [Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and make the generated wrapper use the default python implementations, which will fall back to repr (for -builtin option). Advantages: - it avoids the swig user having to jump through hoops to get print to work as expected when redefining repr/str slots. - typing the name of a variable on the python prompt now prints the result of a (possibly redefined) repr, without the swig user having to do any extra work. - when redefining repr, the swig user doesn't necessarily have to redefine str as it will call the redefined repr - the behaviour is exactly the same as without the -builtin option while requiring no extra work by the user (aside from adding the %feature("python:slot...) statements of course) Disadvantage: - default str() will give different (but clearer?) output on swigged classes 2013-07-30: wsfulton [Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation of a std::map was erroneously required in addition to an instantiation of std::multimap with the same template parameters to prevent compilation errors for the wrappers of a std::multimap. 2013-07-14: joequant [R] Change types file to allow for SEXP return values 2013-07-05: wsfulton [Python] Add %pythonbegin directive which works like %pythoncode, except the specified code is added at the beginning of the generated .py file. This is primarily needed for importing from __future__ statements required to be at the very beginning of the file. Example: %pythonbegin %{ from __future__ import print_function print("Loading", "Whizz", "Bang", sep=' ... ') %} 2013-07-01: wsfulton [Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr when using -builtin. 2013-07-01: wsfulton [Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating a <:: digraph when using the unary scope operator (::) (global scope) in a template type. 2013-07-01: wsfulton [Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on object deletion when using -builtin. Fixes SF bug #1301. 2013-06-11: wsfulton [Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example files have been modified to use this so that Debug builds will now work without having to install or build a Debug build of the interpreter. 2013-06-07: wsfulton [Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type. Also fix the Complex helper functions external visibility (to static by default). 2013-06-04: olly [PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL if the type lookup fails. Version 2.0.10 (27 May 2013) ============================ 2013-05-25: wsfulton [Python] Fix Python 3 inconsistency when negative numbers are passed where a parameter expects an unsigned C type. An OverFlow error is now consistently thrown instead of a TypeError. 2013-05-25: Artem Serebriyskiy SVN Patch ticket #338 - fixes to %attribute macros for template usage with %arg. 2013-05-19: wsfulton Fix ccache-swig internal error bug due to premature file cleanup. Fixes SF bug 1319 which shows up as a failure in the ccache tests on Debian 64 bit Wheezy, possibly because ENABLE_ZLIB is defined. This is a corner case which will be hit when the maximum number of files in the cache is set to be quite low (-F option), resulting in a cache miss. 2013-05-09: kwwette [Octave] Fix bugs in Octave module loading: - fix a memory leak in setting of global variables - install functions only once, to speed up module loads 2013-04-28: gjanssens [Guile] Updates in guile module: - Add support for guile 2.0 - Drop support for guile 1.6 - Drop support for generating wrappers using guile's gh interface. All generated wrappers will use the scm interface from now on. - Deprecate -gh and -scm options. They are no longer needed. A warning will be issued when these options are still used. - Fix all tests and examples to have a successful travis test 2013-04-18: wsfulton Apply Patch #36 from Jesus Lopez to add support for $descriptor() special variable macro expansion in fragments. For example: %fragment("nameDescriptor", "header") %{ static const char *nameDescriptor = "$descriptor(Name)"; %} which will generate into the wrapper if the fragment is used: static const char *nameDescriptor = "SWIGTYPE_Name"; 2013-04-18: wsfulton Fix SF Bug #428 - Syntax error when preprocessor macros are defined inside of enum lists, such as: typedef enum { eZero = 0 #define ONE 1 } EFoo; The macros are silently ignored. 2013-04-17: wsfulton [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjunction with directors. 2013-04-15: kwwette [Octave] Fix bugs in output of cleanup code. - Cleanup code is now written also after the "fail:" label, so it will be called if a SWIG_exception is raised by the wrapping function, consistent with other modules. - Octave module now also recognises the "$cleanup" special variable, if needed. 2013-04-08: kwwette Add -MP option to SWIG for generating phony targets for all dependencies. - Prevents make from complaining if header files have been deleted before the dependency file has been updated. - Modelled on similar option in GCC. 2013-04-09: olly [PHP] Add missing directorin typemap for char* and char[] which fixes director_string testcase failure. 2013-04-05: wsfulton [Ruby] SF Bug #1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL wrappers that override the default predicate, such as: %template(Map) std::map >; 2013-04-05: wsfulton [Ruby] SF Bug #1159 - Correctly check rb_respond_to call return values to fix some further 1.9 problems with functors and use of Complex wrappers. 2013-04-02: wsfulton [Ruby] Runtime fixes for std::complex wrappers for ruby-1.9 - new native Ruby complex numbers are used. 2013-03-30: wsfulton [Ruby] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT, on exit of the Ruby interpreter. More frequently observed in ruby-1.9. 2013-03-29: wsfulton [Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would sometimes seg fault or not work. 2013-03-25: wsfulton [Python] Fix some undefined behaviour deleting slices in the STL containers. 2013-03-19: wsfulton [C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are the same except being in different namespaces when the %nspace feature is not being used. 2013-02-19: kwwette Fix bug in SWIG's handling of qualified (e.g. const) variables of array type. Given the typedef a(7).q(volatile).double myarray // typedef volatile double[7] myarray; the type q(const).myarray // const myarray becomes a(7).q(const volatile).double // const volatile double[7] Previously, SwigType_typedef_resolve() produces the type q(const).a(7).q(volatile).double // non-sensical type which would never match %typemap declarations, whose types were parsed correctly. Add typemap_array_qualifiers.i to the test suite which checks for the correct behaviour. 2013-02-18: wsfulton Deprecate typedef names used as constructor and destructor names in %extend. The real class/struct name should be used. typedef struct tagEStruct { int ivar; } EStruct; %extend tagEStruct { EStruct() // illegal name, should be tagEStruct() { EStruct *s = new EStruct(); s->ivar = ivar0; return s; } ~EStruct() // illegal name, should be ~tagEStruct() { delete $self; } } For now these trigger a warning: extend_constructor_destructor.i:107: Warning 522: Use of an illegal constructor name 'EStruct' in %extend is deprecated, the constructor name should be 'tagEStruct'. extend_constructor_destructor.i:111: Warning 523: Use of an illegal destructor name 'EStruct' in %extend is deprecated, the destructor name should be 'tagEStruct'. These %extend destructor and constructor names were valid up to swig-2.0.4, however swig-2.0.5 ignored them altogether for C code as reported in SF bug #1306. The old behaviour of using them has been restored for now, but is officially deprecated. This does not apply to anonymously defined typedef classes/structs such as: typedef struct {...} X; 2013-02-17: kwwette When generating functions provided by %extend, use "(void)" for no-argument functions instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes". 2013-02-17: kwwette [Octave] Minor fix to autodoc generation: get the right type for functions returning structs. 2013-02-15: wsfulton Deprecate typedef names used in %extend that are not the real class/struct name. For example: typedef struct StructBName { int myint; } StructB; %extend StructB { void method() {} } will now trigger a warning: swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name StructBName should be used instead of the typedef name StructB. This is only partially working anyway (the %extend only worked if placed after the class definition). 2013-02-09: wsfulton [CFFI] Apply patch #22 - Fix missing package before &body 2013-01-29: wsfulton [Java] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5. 2013-01-28: wsfulton [Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False. 2013-01-28: wsfulton [Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore. 2013-01-18: Brant Kyser [Java] Patch #15 - Allow the use of the nspace feature without the -package commandline option. This works as long and the new jniclasspackage pragma is used to place the JNI intermediate class into a package and the nspace feature is used to place all exposed types into a package. 2013-01-15: wsfulton Fix Visual Studio examples to work when SWIG is unzipped into a directory containing spaces. 2013-01-15: wsfulton [C#] Fix cstype typemap lookup for member variables so that a fully qualified variable name matches. For example: %typemap(cstype) bool MVar::mvar "MyBool" struct MVar { bool mvar; }; 2013-01-11: Brant Kyser [Java, C#, D] SF Bug #1299 - Fix generated names for when %nspace is used on classes with the same name in two different namespaces. 2013-01-11: Vladimir Kalinin [C#] Add support for csdirectorin 'pre', 'post' and 'terminator' attributes. 2013-01-08: olly [PHP] Fix to work with a ZTS build of PHP (broken in 2.0.7). 2013-01-07: olly Fix bashism in configure, introduced in 2.0.9. 2013-01-06: wsfulton Pull patch #4 from ptomulik to fix SF Bug #1296 - Fix incorrect warning for virtual destructors in templates, such as: Warning 521: Illegal destructor name B< A >::~B(). Ignored. 2013-01-05: wsfulton [Python] Pull patch #3 from ptomulik to fix SF Bug #1295 - standard exceptions as classes using the SWIG_STD_EXCEPTIONS_AS_CLASSES macro. 2013-01-04: wsfulton [Java] Pull patch #2 from BrantKyser to fix SF Bug #1283 - fix smart pointers in conjuction with directors. 2013-01-03: wsfulton [Java] Pull patch #1 from BrantKyser to fix SF Bug #1278 - fix directors and nspace feature when multilevel namespaces are used. Version 2.0.9 (16 December 2012) ================================ 2012-12-16: wsfulton Fix garbage line number / empty file name reporting for some missing '}' or ')' error messages. 2012-12-15: kkaempf [Ruby] Apply patch 3530444, Class#methods and Class#constants returns array of symbols in Ruby 1.9+ 2012-12-14: kkaempf [Ruby] Apply patch 3530439 and finally replace all occurrences of the STR2CSTR() macro with StringValuePtr(). STR2CSTR was deprecated since years and got removed in Ruby 1.9 2012-12-14: kkaempf [Ruby] Applied patches #3530442 and 3530443 to adapt compile and runtime include paths to match Ruby 1.9+ 2012-12-14: wsfulton [CFFI] Fix #3161614 - Some string constants are incorrect 2012-12-13: wsfulton [CFFI] Fix #3529690 - Fix incorrect constant names. 2012-12-12: drjoe [R] add fix to finalizer that was missed earlier 2012-12-11: wsfulton [Python] Apply patch #3590522 - fully qualified package paths for Python 3 even if a module is in the same package. 2012-12-08: wsfulton [Python] Bug #3563647 - PyInt_FromSize_t unavailable prior to Python 2.5 for unsigned int types. 2012-12-08: wsfulton [Perl] Fix bug #3571361 - C++ comment in C wrappers. 2012-12-07: wsfulton [C#] Apply patch #3571029 which adds missing director support for const unsigned long long &. 2012-11-28: kwwette [Octave] Simplified module loading: now just the syntax $ example; is accepted, which loads functions globally but constants and variables relative to the current scope. This make module loading behaviour reliably consistent, and reduces problems when loading modules which depend on other modules which may not have been previously loaded. 2012-11-27: wsfulton [cffi] Fix junk output when wrapping single character literal constants. 2012-11-17: wsfulton [Tcl, Modula3] Add missing support for -outdir. 2012-11-17: wsfulton Fix segfaults when using filename paths greater than 1024 characters in length. 2012-11-14: wsfulton [ccache-swig] Apply patch #3586392 from Frederik Deweerdt to fix some error cases - incorrectly using memory after it has been deleted. 2012-11-09: vzeitlin [Python] Fix overflow when passing values greater than LONG_MAX from Python 3 for parameters with unsigned long C type. 2012-11-09: wsfulton Fix some feature matching issues for implicit destructors and implicit constructors and implicit copy constructors added with %copyctor. Previously a feature for these had to be fully qualified in order to match. Now the following will also match: %feature("xyz") ~XXX(); struct XXX {}; 2012-11-09: wsfulton Further consistency in named output typemap lookups for implicit constructors and destructors and implicit copy constructors added with %copyctor. Previously only the fully qualified name was being used, now the unqualified name will also be used. For example, previously: example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More Looking for: void Space::More::~More Looking for: void Now the unqualified name is also used: example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More Looking for: void Space::More::~More Looking for: void ~More Looking for: void 2012-11-02: wsfulton Fix some subtle named output typemap lookup misses, the fully qualified name was not always being used for variables, for example: struct Glob { int MyVar; }; Previously the search rules (as shown by -debug-tmsearch) for the getter wrapper were: example.i:44: Searching for a suitable 'out' typemap for: int MyVar Looking for: int MyVar Looking for: int Now the scope is named correctly: example.i:44: Searching for a suitable 'out' typemap for: int Glob::MyVar Looking for: int Glob::MyVar Looking for: int MyVar Looking for: int 2012-10-26: wsfulton Fix director typemap searching so that a typemap specified with a name will be correctly matched. Previously the name was ignored during the typemap search. Applies to the following list of typemaps: directorout, csdirectorout, cstype, imtype, ctype, ddirectorout, dtype, gotype, jtype, jni, javadirectorout. 2012-10-11: wsfulton Most of the special variables available for use in %exception are now also available for expansion in %extend blocks. These are: $name $symname $overname $decl $fulldecl $parentname $parentsymname, see docs on "Class extension" in SWIGPlus.html. Patch based on submission from Kris Thielemans. 2012-10-10: wsfulton Additional new special variables in %exception are expanded as follows: $parentname - The parent class name (if any) for a method. $parentsymname - The target language parent class name (if any) for a method. 2012-10-08: iant [Go] Generating Go code now requires using the -intgosize option to indicate the size of the 'int' type in Go. This is because the size of the type is changing from Go 1.0 to Go 1.1 for x86_64. 2012-09-14: wsfulton Add new warning if the empty template instantiation is used as a base class, for example: template class Base {}; %template() Base; class Derived : public Base {}; gives the following warning instead of silently ignoring the base: cpp_inherit.i:52: Warning 401: Base class 'Base< int >' has no name as it is an empty template instantiated with '%template()'. Ignored. cpp_inherit.i:51: Warning 401: The %template directive must be written before 'Base< int >' is used as a base class and be declared with a name. 2012-09-11: wsfulton [Java] Fix #3535304 - Direct use of a weak global reference in directors sometimes causing seg faults especially on Android. 2012-09-06: wsfulton [Java] Fix (char *STRING, size_t LENGTH) typemaps to accept NULL string. 2012-08-26: drjoe [R] make ExternalReference slot ref to contain reference 2012-08-26: drjoe [R] fix Examples/Makefile to use C in $(CC) rather than $(CXX) Version 2.0.8 (20 August 2012) ============================== 2012-08-15: wsfulton [Perl] Add size_type, value_type, const_reference to the STL containers. 2012-08-15: wsfulton [Python] Add discard and add methods to std::set wrappers so that pyabc.i can be used ensuring MutableSet is a valid abstract base class for std::set. As reported by Alexey Sokolov. Similarly for std::multiset. 2012-08-15: wsfulton [Python] Fix #3541744 - Missing PyInt_FromSize_t calls for Python 3. 2012-08-13: wsfulton [Java] Patch from David Baum to add the assumeoverride feature for Java directors to improve performance when all overridden methods can be assumed to be overridden. 2012-08-05: wsfulton [Python] #3530021 Fix unused variable warning. 2012-08-05: wsfulton [C#] Fix #3536360 - Invalid code sometimes being generated for director methods with many arguments. 2012-08-05: wsfulton [Perl] #3545877 - Don't undefine bool if defined by C99 stdbool.h - problem using Perl 5.16 and later. 2012-08-04: wsfulton Remove incorrect warning (314) about target language keywords which were triggered by using declarations and using directives. For example 'string' is a keyword in C#: namespace std { class string; } using std::string; 2012-07-21: wsfulton Fix display of pointers in various places on 64 bit systems - only 32 bits were being shown. 2012-07-21: wsfulton Fix gdb debugger functions 'swigprint' and 'locswigprint' to display to the gdb output window rather than stdout. This fixes display problems in gdbtui and the ensures the output appears where expected in other gdb based debuggers such as Eclipse CDT. 2012-07-20: kwwette [Octave] segfault-on-exit prevention hack now preserves exit status, and uses C99 _Exit(). 2012-07-02: wsfulton Fix Debian bug http://bugs.debian.org/672035, typemap copy failure - regression introduced in swig-2.0.5: %include using std::pair; %template(StrPair) pair; 2012-07-02: wsfulton Fix using declarations combined with using directives with forward class declarations so that types are correctly found in scope for templates. Example: namespace Outer2 { namespace Space2 { template class Thing2; } } using namespace Outer2; using Space2::Thing2; template class Thing2 {}; // STILL BROKEN void useit2(Thing2 t) {} void useit2a(Outer2::Space2::Thing2 t) {} void useit2b(::Outer2::Space2::Thing2 t) {} void useit2c(Space2::Thing2 t) {} namespace Outer2 { void useit2d(Space2::Thing2 t) {} } %template(Thing2Int) Thing2; 2012-06-30: wsfulton Fix template namespace problems for symbols declared with a forward class declarations, such as: namespace Space1 { namespace Space2 { template struct YYY; } template struct Space2::YYY { T yyy(T h) { return h; } }; void testYYY1(Space1::Space2::YYY yy) {} void testYYY2(Space2::YYY yy) {} void testYYY3(::Space1::Space2::YYY yy) {} } %template(YYYInt) Space1::Space2::YYY; 2012-06-30: wsfulton Fix namespace problems for symbols declared with a forward class declarations, such as: namespace Space1 { namespace Space2 { struct XXX; struct YYY; } struct Space2::YYY {}; struct Space1::Space2::XXX {}; void testXXX2(Space2::XXX xx) {} void testYYY2(Space2::YYY yy) {} } where xx and yy were not recognised as the proxy classes XXX and YYY. 2012-06-30: wsfulton Fix using declarations combined with using directives with forward class declarations so that types are correctly found in scope. namespace Outer2 { namespace Space2 { class Thing2; } } using namespace Outer2; using Space2::Thing2; class Thing2 {}; // None of the methods below correctly used the Thing2 proxy class void useit2(Thing2 t) {} void useit2a(Outer2::Space2::Thing2 t) {} void useit2b(::Outer2::Space2::Thing2 t) {} void useit2c(Space2::Thing2 t) {} namespace Outer2 { void useit2d(Space2::Thing2 t) {} } 2012-06-25: wsfulton Fix using declarations combined with using directives so that types are correctly found in scope. Example: namespace Outer2 { namespace Space2 { class Thing2 {}; } } using namespace Outer2; // using directive using Space2::Thing2; // using declaration void useit2(Thing2 t) {} Similarly for templated classes. 2012-05-29: wsfulton Fix #3529601 - seg fault when a protected method has the "director" feature but the parent class does not. Also fix similar problems with the allprotected feature. 2012-05-28: wsfulton Fix seg fault when attempting to warn about an illegal destructor - #3530055, 3530078 and #3530118. Version 2.0.7 (26 May 2012) =========================== 2012-05-26: wsfulton std::string typemap modifications so they can be used with %apply for other string classes. 2012-05-25: wsfulton [Lua] Fixes for -external-runtime to work again. 2012-05-22: szager [python] Disambiguate SWIG_From_unsigned_SS_int and SWIG_From_unsigned_SS_long. 2012-05-18: olly [PHP] Fix getters for template members. (SF#3428833, SF#3528035) 2012-05-14: wsfulton Fix some language's std::map wrappers to recognise difference_type, size_type, key_type and mapped_type. 2012-05-14: kwwette (signed off by xavier98) [Octave] Prevent Octave from seg-faulting at exit when SWIG modules are loaded, due to bugs in Octave's cleanup code: * Wrapping functions now declared with Octave DEFUN_DLD macro, and loaded through Octave's dynamic module loader * Global variables of swigref type are now assigned a new() copy of the swigref class, to prevent double-free errors * SWIG module at-exit cleanup function now created in Octave through eval(), so not dependent on loaded .oct library * For Octave versions 3.1.* to 3.3.*, register C-level at-exit function which terminates Octave immediately (with correct status code) without performing memory cleanup. This function can be controlled with macros in Lib/octave/octruntime.swg [Octave] New syntax for determing whether SWIG module should be loaded globally or non-globally. To load module "example" globally, type the module name $ example; as before; to load module non-globally, assign it to a variable: $ example = example; or $ ex = example; for a shorter (local) module name. -global/-noglobal command-line options and module command line are deprecated. Added usage info to module, so typing $ help example or incorrect usage should display proper usage, with examples. *** POTENTIAL INCOMPATIBILITY *** 2012-05-12: olly [PHP] Fix memory leak in code generated for a callback. Patch from SF bug #3510806. 2012-05-12: olly [PHP] Avoid using zend_error_noreturn() as it doesn't work with all builds of PHP (SF bug #3166423). Instead we now wrap it in a SWIG_FAIL() function which we annotate as "noreturn" for GCC to avoids warnings. This also reduces the size of the compiled wrapper (e.g. the stripped size is reduced by 6% for Xapian's PHP bindings). 2012-05-11: wsfulton [Java] SF patch #3522855 Fix unintended uninitialised memory access in OUTPUT typemaps. 2012-05-11: wsfulton [Java] SF patch #3522674 Fix possible uninitialised memory access in char **STRING_OUT typemap. 2012-05-11: wsfulton [Java] SF patch #3522611 Fix uninitialised size regression in char **STRING_ARRAY introduced in swig-2.0.6. 2012-05-11: wsfulton SF bug #3525050 - Fix regression introduced in swig-2.0.5 whereby defining one typemap method such as an 'out' typemap may hide another typemap method such as an 'in' typemap - only occurs when the type is a template type where the template parameters are the same via a typedef. 2012-05-10: olly [PHP] Fix the constant typemaps for SWIGTYPE, etc - previously these used the wrong name for renamed constants. Add autodoc_runme.php to the testsuite as a regression test for this. 2012-05-02: ianlancetaylor [Go] Remove compatibility support for gccgo 4.6. Using SWIG with gccgo will now require gccgo 4.7. Using SWIG with the more commonly used gc compiler is unaffected. 2012-05-01: wsfulton Fix generated code for C forward enum declarations in some languages. Version 2.0.6 (30 April 2012) ============================= 2012-04-25: wsfulton [Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson. 2012-04-28: wsfulton [Python] Fix compilation errors when wrapping STL containers on Mac OSX and possibly other systems. 2012-04-28: wsfulton [Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle null pointers. Version 2.0.5 (19 April 2012) ============================= 2012-04-14: wsfulton [Lua] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable 2012-04-14: wsfulton [Ruby] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR. 2012-04-13: wsfulton Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers. 2012-04-13: wsfulton [Lua] Apply #3219676 from Shane Liesegang which adds: - support for %factory - a __tostring method - a __disown method 2012-04-13: wsfulton [Xml] Apply #3513569 which adds a catchlist to the xml output. 2012-04-05: olly [Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader) 2012-03-26: xavier98 [octave] Apply patch #3425993 from jgillis: add extra logic to the octave_swig_type::dims(void) method: it checks if the user has defined a __dims__ method and uses this in stead of returning (1,1) [octave] Apply patch #3424833 from jgillis: make is_object return true for swig types 2012-03-24: wsfulton [D] Apply #3502431 to fix duplicate symbols in multiple modules. 2012-03-21: wsfulton Fix #3494791 - %$isglobal for %rename matching. 2012-03-20: wsfulton Fix #3487706 and #3391906 - missing stddef.h include for ptrdiff_t when using %import for STL containers and compiling with g++-4.6. An include of stddef.h is now only generated when SWIG generates STL helper templates which require ptrdiff_t. If you were previously relying on "#include " always being generated when using a %include of an STL header, you may now need to add this in manually. 2012-03-16: wsfulton Apply patch #3392264 from Sebastien Bine to parse (unsigned) long long types in enum value assignment. 2012-03-16: wsfulton Apply patch #3505530 from Karl Wette to allow custom allocators in STL string classes for the UTL languages. 2012-03-13: wsfulton Apply patch #3468362 from Karl Wette to fix %include inside %define. 2012-03-13: wsfulton [Python, Ruby, Octave, R] Fix #3475492 - iterating through std::vector wrappers of enumerations. 2012-02-27: xavier98 (patches from Karl Wette) [Octave] Use -globals . to load global variables in module namespace [Octave] Comment declaration of unimplemented function swig_register_director [Octave] Fix OCTAVE_PATH in octave Makefiles [Octave] Add support for std::list - fix li_std_containers_int test [Octave] Fix imports test 2012-02-16: wsfulton [Java] Make generated support functions in arrays_java.i static so that generated code from multiple instances of SWIG can be compiled and linked together - problem reported by Evan Krause. 2012-01-24: wsfulton Fix crash with bad regex - bug #3474250. 2012-01-24: wsfulton [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list). Assigning to a slice, reading a slice and deleting a slice with steps now work. For example: %template(vector_i) std::vector vi = vector_i(range(10)) print list(vi) vi[1:4:2] = [111, 333] print list(vi) del vi[3:10:3] print list(vi) print list(vi[::-1]) gives (same behaviour as native Python sequences such as list): [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [0, 111, 2, 333, 4, 5, 6, 7, 8, 9] [0, 111, 2, 4, 5, 7, 8] [8, 7, 5, 4, 2, 111, 0] 2012-01-23: klickverbot [D] Correctly annotate function pointers with C linkage. [D] Exception and Error have become blessed names; removed d_exception_name test case. 2012-01-20: wsfulton [Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg: %template(vector_i) std::vector iv=vector_i([0,1,2,3,4,5]) iv[-7:] now returns [0, 1, 2, 3, 4, 5] instead of [5]. vv[7:9] = [22,33] now returns [0, 1, 2, 3, 4, 5, 22, 33] instead of "index out range" error. Also fix some segfaults when replacing ranges, eg when il is a std::list wrapper: il[0:2] = [11] 2012-01-17: wsfulton [Go] Fix forward class declaration within a class when used as a base. 2012-01-07: wsfulton [C#] Add support for %nspace when using directors. 2012-01-06: wsfulton [Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors. 2011-12-21: wsfulton The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds - $1_name, $2_name etc. 2011-12-20: wsfulton [Java] Add (char *STRING, size_t LENGTH) director typemaps. 2011-12-20: wsfulton [C#, Go, Java, D] Add support for the 'directorargout' typemap. 2011-12-20: wsfulton [Ocaml, Octave, PHP, Python, Ruby] Correct special variables in 'directorargout' typemap. This change will break any 'directorargout' typemaps you may have written. Please change: $result to $1 $input to $result Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't previously compile and add in $1, $2 etc expansion. *** POTENTIAL INCOMPATIBILITY *** 2011-12-10: talby [perl5] SWIG_error() now gets decorated with perl source file/line number. [perl5] error handling now conforms to public XS api (fixes perl v5.14 issue). 2011-12-10: wsfulton [Android/Java] Fix directors to compile on Android. Added documentation and examples for Android. 2011-12-08: vadz Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes (they could be sometimes mysteriously not renamed or ignored there before). 2011-12-03: klickverbot [D] Fix exception glue code for newer DMD 2 versions. [D] Do not default to 32 bit glue code for DMD anymore. [D] Use stdc.config.c_long/c_ulong to represent C long types. 2011-12-01: szager [python] Fixed bug 3447426: memory leak in vector.__getitem__. 2011-11-30: wsfulton [R] Remove C++ comments from generated C code. 2011-11-27: olly [Python] Fix some warnings when compiling generated wrappers with certain GCC warning options (Debian bug #650246). 2011-11-28: wsfulton Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. 2011-11-28: olly [Perl] Fix warnings when compiling generated wrappers with certain GCC warning options (Debian bug #436711). 2011-11-28: olly [PHP] Update keyword list to include keywords added in PHP releases up to 5.3. 2011-11-25: wsfulton [C#] Provide an easy way to override the default visibility for the proxy class pointer constructors and getCPtr() method. The visibility is 'internal' by default and if multiple SWIG modules are being used and compiled into different assemblies, then they need to be 'public' in order to use the constructor or getCPtr() method from a different assembly. Use the following macros to change the visibilities in the proxy and type wrapper class: SWIG_CSBODY_PROXY(public, public, SWIGTYPE) SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE) [Java] Provide an easy way to override the default visibility for the proxy class pointer constructors and getCPtr() method. The visibility is 'protected' by default and if multiple SWIG modules are being used and compiled into different packages, then they need to be 'public' in order to use the constructor or getCPtr() method from a different package. Use the following macros to change the visibilities in the proxy and type wrapper class: SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) The default for Java has changed from public to protected for the proxy classes. Use the SWIG_JAVABODY_PROXY macro above to restore to the previous visibilities. *** POTENTIAL INCOMPATIBILITY *** 2011-11-22: szager [python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin isn't being used, to avoid unnecessary binary incompatibilities between python installations. 2011-11-17: wsfulton Bug fix: Remove root directory from directory search list in Windows. 2011-11-13: wsfulton [Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in different namespaces confusion when using multiple modules. 2011-11-11: wsfulton Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely. 2011-11-03: wsfulton Expand special variables in typemap warnings, eg: %typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..." 2011-11-01: wsfulton Fix named output typemaps not being used when the symbol uses a qualifier and contains a number, eg: %typemap(out) double ABC::m1 "..." 2011-10-24: talby [perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research is needed on a stable path for tail calls in XS. Also, fix for large long longs in 32 bit perl. 2011-10-13: xavier98 [octave] Allow Octave modules to be re-loaded after a "clear all". 2011-09-19: wsfulton Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code when using typedef and function pointer references, for example: typedef int FN(const int &a, int b); void *typedef_call1(FN *& precallback, FN * postcallback); 2011-09-14: wsfulton [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua) including options for targeting Lua Tiny RAM (LTR). 2011-09-14: wsfulton [C#] Add boost_intrusive_ptr.i library contribution from patch #3401571. 2011-09-13: wsfulton Add warnings for badly named destructors, eg: struct KStruct { ~NOT_KStruct() {} }; cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored. 2011-09-13: wsfulton Fix %extend and destructors for templates. The destructor in %extend was not always wrapped, for example: %extend FooT { ~FooT() { delete $self; } // was not wrapped as expected }; template class FooT {}; %template(FooTi) FooT; 2011-09-13: wsfulton Fix special variables such as "$decl" and "$fulldecl" in destructors to include the ~ character. 2011-09-10: talby [perl5] SF bug #1481958 - Improve range checking for integer types. Enhance li_typemaps_runme.pl 2011-09-08: wsfulton Fix %extend on typedef classes in a namespace using the typedef name, for example: namespace Space { %extend CStruct { ... } typedef struct tagCStruct { ... } CStruct; } 2011-08-31: xavier98 [octave] patches from Karl Wette: improvements to module loading behavior; added example of friend operator to operator example; fixed octave panic/crash in 3.0.5; documentation improvements 2011-08-30: szager [python] Bug 3400486, fix error signalling for built-in constructors. 2011-08-26: wsfulton [Go] Fix file/line number display for "gotype" when using typemap debugging options -tmsearch and -tmused. 2011-08-26: wsfulton [C#, D] Fix %callback which was generating uncompileable code. 2011-08-25: wsfulton Fix constructors in named typedef class declarations as reported by Gregory Bronner: typedef struct A { A(){} // Constructor which was not accepted by SWIG B(){} // NOT a constructor --illegal, but was accepted by SWIG } B; For C code, the fix now results in the use of 'struct A *' instead of just 'B *' in the generated code when wrapping members in A, but ultimately this does not matter, as they are the same thing. 2011-08-23: wsfulton Fix %newobject when used in conjunction with %feature("ref") as reported by Jan Becker. The code from the "ref" feature was not always being generated for the function specified by %newobject. Documentation for "ref" and "unref" moved from Python to the C++ chapter. 2011-08-22: szager [python] Fixed memory leak with --builtin option (bug 3385089). 2011-08-22: wsfulton [Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing the module table into the global namespace. Require call also returns the module table instead of a string. 2011-08-09: xavier98 Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette) 2011-08-04: wsfulton Add in $symname expansion for director methods. 2011-07-29: olly [PHP] Don't generate "return $r;" in cases where $r hasn't been set. This was basically harmless, except it generated a PHP E_NOTICE if the calling code had enabled them. 2011-07-26: wsfulton Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol was incorrectly put into the outer namespace, eg namespace std { template struct map { class iterator; }; } iterator was scoped as std::iterator, but now it is correctly std::map::iterator; Also fixed is %template and template parameters that are a typedef when the template contains default template parameters, eg: namespace Std { template struct Map { typedef Key key_type; typedef T mapped_type; }; } typedef double DOUBLE; %template(MM) Std::Map; All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the wrapped code uses Std::Map or std::Map or Std::Map Also fixes bug #3378145 - regression introduced in 2.0.4 - %template using traits. 2011-07-20 szager [python] Fix closure for tp_call slot. 2011-07-16: wsfulton [python] Fix director typemap using PyObject *. 2011-07-13: szager [python] SF patch #3365908 - Add all template parameters to map support code in std_map.i 2011-07-13: szager [python] Fix for bug 3324753: %rename member variables with -builtin. 2011-07-01: wsfulton Fix some scope and symbol lookup problems when template default parameters are being used with typedef. For example: template struct Foo { typedef XX X; typedef TT T; }; template struct UsesFoo { void x(typename Foo::T, typename Foo::X); }; Also fixes use of std::vector::size_type for Python as reported by Aubrey Barnard. 2011-06-23: olly [PHP] Fix director code to work when PHP is built with ZTS enabled, which is the standard configuration on Microsoft Windows. 2011-06-21: mutandiz [allegrocl] - various small tweaks and bug fixes. - Avoid name conflicts between smart pointer wrappers and the wrappers for the actual class. - Fix default typemaps for C bindings, which were incorrectly attempting to call non-existent destructors on user-defined types. - New feature, feature:aclmixins, for adding superclass to the foreign class wrappers. - Improve longlong typemaps. 2011-06-19: wsfulton Fix incorrect typemaps being used for a symbol within a templated type, eg: A::value_type would incorrectly use a typemap for type A. 2011-06-18: olly [Tcl] Fix variable declarations in middle of blocks which isn't permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663). Reported by Paul Obermeier in SF#3288586. 2011-06-17: wsfulton [Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[] using arrays_java.i. 2011-06-13: wsfulton [Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python. 2011-06-10: wsfulton [Python] Few subtle bugfixes in autodoc documentation generation, - Unnamed argument names fix for autodoc levels > 0. - Display of template types fixed for autodoc levels > 1. - Fix SF #3310528 - display of typedef structs for autodoc levels > 1. - Add missing type for self for autodoc levels 1 and 3. - autodoc levels 2 and 3 documented. - Minor tweaks to autodoc style to conform with PEP8. 2011-05-30: olly [PHP] Fix handling of directors when -prefix is used. 2011-05-24: olly [PHP] Fix handling of methods of classes with a virtual base class (SF#3124665). Version 2.0.4 (21 May 2011) =========================== 2011-05-19: wsfulton [Guile] Patch #3191625 fixing overloading of integer types. 2011-05-19: wsfulton [Perl] Patch #3260265 fixing overloading of non-primitive types and integers in Perl 5.12 and later. 2011-05-19: wsfulton [Ruby] Fix %import where one of the imported files %include one of the STL include files such as std_vector.i. 2011-05-17: wsfulton [Java] Apply #3289851 from Alan Harder to fix memory leak in directors when checking for pending exceptions. 2011-05-17: wsfulton [Tcl] Apply #3300072 from Christian Delbaere to fix multiple module loading not always sharing variables across modules. 2011-05-16: xavier98 [octave] Fix an incompatibility with never versions of Octave. Case on Octave API >= 40 to handle rename of Octave_map to octave_map. [octave] Add support for y.__rop__(x) operators when x.__op__(y) doesn't exist. [octave] Allow global operators to be defined by SWIG-wrapped functions. [octave] Fix several bugs around module namespaces; add -global, -noglobal, -globals command line options to the module. 2011-05-14: wsfulton %varargs when used with a numeric argument used to create an additional argument which was intended to provide a guaranteed sentinel value. This never worked and now the additional argument is not generated. 2011-05-13: wsfulton [python] Additional fixes for python3.2 support. 2011-05-07: szager [python] Fixed PyGetSetDescr for python3.2. 2011-05-05: wsfulton [Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded method with incorrect arguments improved to show always show fully qualified name and if a const method. Also fixed other Lua error messages in generated code which weren't consistently using the fully qualified C++ name - requested by Gedalia Pasternak. 2011-04-29: szager Bug 2635919: Convenience method to convert std::map to a python dict. 2011-04-29: szager [Python] Fixed bug 2811549: return non-const iterators from STL methods begin(), end(), rbegin(), rend(). 2011-04-25: szager [Python] Fixed bug 1498929: Access to member fields in map elements 2011-04-23: klickverbot [D] nspace: Correctly generate identifiers for base classes when not in split proxy mode. 2011-04-13: szager Fixed bug 3286333: infinite recursion with mutual 'using namespace' clauses. 2011-04-12: szager Fixed bug 1163440: vararg typemaps. 2011-04-12: szager Fixed bug #3285386: parse error from 'operator T*&()'. Added operator_pointer_ref test case to demonstrate. 2011-04-11: szager [Python] Fixed PyVarObject_HEAD_INIT to eliminate VC++ compiler errors about static initialization of struct members with pointers. 2011-04-11: wsfulton [Tcl] Apply patch #3284326 from Colin McDonald to fix some compiler warnings. 2011-04-11: szager [Python] Fixed PyVarObject_HEAD_INIT to eliminate VC++ compiler errors about static initialization of struct members with pointers. 2011-04-10: klickverbot [D] Fixed wrapping of enums that are type char, for example: enum { X = 'X'; } (this was already in 2.0.3 for C# and Java) 2011-04-10: klickverbot [D] nspace: Fixed referencing types in the root namespace when not in split proxy mode. 2011-04-09: szager [Python] Applied patch #1932484: migrate PyCObject to PyCapsule. 2011-04-09: szager [Python] Added preprocessor guards for python functions PyUnicode_AsWideChar and PySlice_GetIndices, which changed signatures in python3.2. 2011-04-07: wsfulton Fix wrapping of const array typedefs which were generating uncompileable code as reported by Karl Wette. 2011-04-03: szager [Python] Fixed the behavior of %pythonnondynamic to conform to the spec in Lib/pyuserdir.swg. 2011-04-03: szager [Python] Merged in the szager-python-builtin branch, adding the -builtin feature for python. The -builtin option may provide a significant performance gain in python wrappers. For full details and limitations, refer to Doc/Manual/Python.html. A small test suite designed to demonstrate the performance gain is in Examples/python/performance. 2011-04-01: wsfulton Add in missing wrappers for friend functions for some target languages, mostly the non-scripting languages like Java and C#. Version 2.0.3 (29 March 2011) ============================= 2011-03-29: wsfulton [R] Apply patch #3239076 from Marie White fixing strings for R >= 2.7.0 2011-03-29: wsfulton [Tcl] Apply patch #3248280 from Christian Delbaere which adds better error messages when the incorrect number or type of arguments are passed to overloaded methods. 2011-03-29: wsfulton [Tcl] Apply patch #3224663 from Christian Delbaere. 1. Fix when function returns a NULL value, a "NULL" command will be created in the Tcl interpreter and calling this command will cause a segmentation fault. 2. Previous implementation searches for class methods using a linear search causing performance issues in wrappers for classes with many member functions. The patch adds a method hash table to classes and changes method name lookup to use the hash table instead of doing a linear search. 2011-03-26: wsfulton [C#, Java] SF bug #3195112 - fix wrapping of enums that are type char, for example: enum { X = 'X'; } 2011-03-21: vadz Allow setting PCRE_CFLAGS and PCRE_LIBS during configuration to override the values returned by pcre-config, e.g. to allow using a static version of PCRE library. 2011-03-17: wsfulton [UTL] Add missing headers in generated STL wrappers to fix compilation with gcc-4.6. 2011-03-17: wsfulton Fix regression introduced in swig-2.0.2 where filenames with spaces were not found when used with %include and %import. Reported by Shane Liesegang. 2011-03-15: wsfulton [UTL] Fix overloading when using const char[], problem reported by David Maxwell. Similarly for char[ANY] and const char[ANY]. 2011-03-15: wsfulton [C#] Apply patch #3212624 fixing std::map Keys property. 2011-03-14: olly [PHP] Fix handling of overloaded methods/functions where some return void and others don't - whether this worked or not depended on the order they were encountered in (SF#3208299). 2011-03-13: klickverbot [D] Extended support for C++ namespaces (nspace feature). 2011-03-12: olly [PHP] Fix sharing of type information between multiple SWIG-wrapped modules (SF#3202463). 2011-03-09: wsfulton [Python] Fix SF #3194294 - corner case bug when 'NULL' is used as the default value for a primitive type parameter in a method declaration. 2011-03-07: olly [PHP] Don't use zend_error_noreturn() for cases where the function returns void - now this issue can only matter if you have a function or method which is directed and returns non-void. 2011-03-06: olly [PHP] Add casts to the typemaps for long long and unsigned long long to avoid issues when they are used with shorter types via %apply. 2011-03-02: wsfulton Templated smart pointers overloaded with both const and non const operator-> generated uncompilable code when the pointee was a class with either public member variables or static methods. Regression in 2.0.x reported as working in 1.3.40 by xantares on swig-user mailing list. Version 2.0.2 (20 February 2011) ================================ 2011-02-19: wsfulton [PHP] Add missing INPUT, OUTPUT and INOUT typemaps in the typemaps.i library for primitive reference types as well as signed char * and bool *. 2011-02-19: olly [PHP] Address bug in PHP on some platforms/architectures which results in zend_error_noreturn() not being available using SWIG_ZEND_ERROR_NORETURN which defaults to zend_error_noreturn but can be overridden when building the module by passing -DSWIG_ZEND_ERROR_NORETURN=zend_error to the compiler. This may result in compiler warnings, but should at least allow a module to be built on those platforms/architectures (SF#3166423). 2011-02-18: wsfulton Fix #3184549 - vararg functions and function overloading when using the -fastdispatch option. 2011-02-18: olly [PHP] An overloaded method which can return an object or a primitive type no longer causes SWIG to segfault. Reported by Paul Colby in SF#3168531. 2011-02-18: olly [PHP] Fix invalid erase during iteration of std::map in generated director code. Reported by Cory Bennett in SF#3175820. 2011-02-17: wsfulton Preprocessing now warns if extra tokens appear after #else and #end. 2011-02-16: wsfulton Fix #1653092 Preprocessor does not error out when #elif is missing an expression. This and other cases of missing preprocessor expressions now result in an error. 2011-02-14: wsfulton [Ocaml] Apply patch #3151788 from Joel Reymont. Brings Ocaml support up to date (ver 3.11 and 3.12), including std::string. 2011-02-13: wsfulton [Ruby] Apply patch #3176274 from James Masters - typecheck typemap for time_t. 2011-02-13: wsfulton Apply patch #3171793 from szager - protected director methods failing when -fvirtual is used. 2011-02-13: wsfulton Fix #1927852 - #include directives don't preprocess the file passed to it. The fix is for #include with -importall or -includeall, %include and %import, for example: #define FILENAME "abc.h" %include FILENAME 2011-02-12: wsfulton Fix #1940536, overactive preprocessor which was expanding defined(...) outside of #if and #elif preprocessor directives. 2011-02-05: wsfulton [MzScheme] SF #2942899 Add user supplied documentation to help getting started with MzScheme. Update chapter name to MzScheme/Racket accounting for the rename of MzScheme to Racket. 2011-02-05: wsfulton [C#] SF #3085906 - Possible fix running test-suite on Mac OSX. 2011-02-05: wsfulton SF #3173367 Better information during configure about Boost prerequisite for running the test-suite. 2011-02-05: wsfulton SF #3127633 Fix infinite loop in recursive typedef resolution. 2011-02-04: wsfulton [R] SF #3168676 Fix %rename not working for member variables and methods. 2011-02-04: wsfulton [clisp] SF #3148200 Fix segfault parsing nested unions. 2011-02-01: wsfulton [C#] Directors - a call to a method being defined in the base class, not overridden in a subclass, but again overridden in a class derived from the first subclass was not being dispatched correctly to the most derived class. See director_alternating.i for an example. 2011-02-01: wsfulton [C#, Java] Any 'using' statements in the protected section of a class were previously ignored with director protected (dirprot) mode. 2011-01-30: wsfulton Fix overloading with const pointer reference (SWIGTYPE *const&) parameters for a number of scripting languages. 2011-01-17: wsfulton New warning for smart pointers if only some of the classes in the inheritance chain are marked as smart pointer, eg, %shared_ptr should be used for all classes in an inheritance hierarchy, so this new warning highlights code where this is not the case. example.i:12: Warning 520: Base class 'A' of 'B' is not similarly marked as a smart pointer. example.i:16: Warning 520: Derived class 'C' of 'B' is not similarly marked as a smart pointer. 2011-01-14: wsfulton Added some missing multi-argument typemaps: (char *STRING, size_t LENGTH) and (char *STRING, int LENGTH). Documentation for this updated. Java patch from Volker Grabsch. 2011-01-11: iant Require Go version 7077 or later. 2010-12-30: klickverbot [C#, D, Java] Check for collision of parameter names with target language keywords when generating the director glue code. The situation in which the generated could would previously be invalid is illustrated in the new 'director_keywords' test case. 2010-12-23: wsfulton [C#] Fix $csinput special variable not being expanded for csvarin typemaps when used for global variables. Reported by Vadim Zeitlin. 2010-12-14: wsfulton Fix $basemangle expansion in array typemaps. For example if type is int *[3], $basemangle expands to _p_int. 2010-12-07: iant Check that we are using a sufficiently new version of the 6g or 8g Go compiler during configure time. If not, disable Go. Minimum version is now 6707. *** POTENTIAL INCOMPATIBILITY *** 2010-12-06: wsfulton Fix #3127394 - use of network paths on Windows/MSys. 2010-11-18: klickverbot [D] Added the D language module. 2010-11-12: vadz Fix handling of multiple regex-using %renames attached to the same declaration. For example, now %rename("%(regex/^Set(.*)/put\\1/)s") ""; %rename("%(regex/^Get(.*)/get\\1/)s") ""; works as expected whereas before only the last anonymous rename was taken into account. 2010-10-17: drjoe [R] Fix failure in overloaded functions which was breaking QuantLib-SWIG 2010-10-14: olly [PHP] Allow compilation on non-conforming Microsoft C++ compilers which don't accept: return function_returning_void(); Reported by Frank Vanden Berghen on the SWIG mailing list. 2010-10-12: wsfulton Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being incorrectly treated as opaque types. Also fixes #2958781 and some other type problems due to better typedef resolution, eg std::vector::value_type didn't resolve to T * when it should have. The mangled type was incorrectly SWIGTYPE_std__vectorT_Test_p_std__allocatorT_Test_p_t_t__value_type and now it is correctly SWIGTYPE_p_Test. Version 2.0.1 (4 October 2010) ============================== 2010-10-03: wsfulton Apply patch #3066958 from Mikael Johansson to fix default smart pointer handling when the smart pointer contains both a const and non-const operator->. 2010-10-01: wsfulton Add -pcreversion option to display PCRE version information. 2010-10-01: olly [Ruby] Avoid segfault when a method node has no parentNode (SF#3034054). 2010-10-01: olly [Python] Allow reinitialisation to work with an embedded Python interpreter (patch from Jim Carroll in SF#3075178). 2010-09-28: wsfulton [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid throwing exceptions with normal usage of iterators. 2010-09-27: olly [Python] Improve error message given when a parameter of the wrong type is passed to an overloaded method (SF#3027355). 2010-09-25: wsfulton Apply SF patch #3075150 - Java directors using static variables in named namespace. 2010-09-24: wsfulton More file and line error/warning reporting fixes where SWIG macros are used within {} braces (where the preprocessor expands macros), for example macros within %inline {...} and %fragment(...) {...} and nested structs. 2010-09-18: wsfulton More file and line error/warning reporting fixes for various inherited class problems. 2010-09-15: wsfulton A much improved debugging of SWIG source experience is now available and documented in the "Debugging SWIG" section in the Doc/Devel/internals.html file, including a swig.dbg support file for the gdb debugger. 2010-09-11: wsfulton Fix incorrect line number reporting in errors/warnings when a macro definition ends with '/' and it is not the end of a C comment. 2010-09-11: wsfulton Fix incorrect line number reporting in errors/warnings after parsing macro invocations with parameters given over more than one line. 2010-09-10: wsfulton Remove extraneous extra line in preprocessed output after including files which would sometimes lead to error/warning messages two lines after the end of the file. 2010-09-10: wsfulton Fix #2149523 - Incorrect line number reporting in errors after parsing macros containing C++ comments. 2010-09-08: olly [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394). 2010-09-03: wsfulton Fix erroneous line numbers in error messages for macro expansions, for example, the error message now points to instantiation of the macro, ie the last line here: #define MACRO2(a, b) #define MACRO1(NAME) MACRO2(NAME,2,3) MACRO1(abc) 2010-09-02: wsfulton Fix line numbers in error and warning messages for preprocessor messages within %inline, for example: %inline %{ #define FOOBAR 1 #define FOOBAR "hi" %} 2010-09-02: wsfulton Fix line numbers in error and warning messages which were cumulatively one less than they should have been after parsing each %include/%import - bug introduced in swig-1.3.32. Also fix line numbers in error and warning messages when new line characters appear between the %include / %import statement and the filename. 2010-08-30: wsfulton Fix line number and file name reporting for some macro preprocessor warnings. The line number of the macro argument has been corrected and the line number of the start of the macro instead of one past the end of the macro is used. Some examples: file.h:11: Error: Illegal macro argument name '..' file.h:19: Error: Macro 'DUPLICATE' redefined, file.h:15: Error: previous definition of 'DUPLICATE'. file.h:25: Error: Variable-length macro argument must be last parameter file.h:32: Error: Illegal character in macro argument name file.i:37: Error: Macro 'SIT' expects 2 arguments 2010-08-26: wsfulton Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this did not work at all. Also fixes SF #2822822. 2010-08-17: wsfulton [Perl] Fix corner case marshalling of doubles - errno was not being correctly set before calling strtod - patch from Justin Vallon - SF Bug #3038936. 2010-08-17: wsfulton Fix make distclean when some of the more obscure languages are detected by configure - fixes from Torsten Landschoff. 2010-07-28: wsfulton Restore configuring out of source for the test-suite since it broke in 1.3.37. As previously, if running 'make check-test-suite' out of source, it needs to be done by invoking configure with a relative path. Invoking configure with an absolute path will not work. Running the full 'make check' still needs to be done in the source tree. 2010-07-16: wsfulton Fix wrapping of function pointers and member function pointers when the function returns by reference. 2010-07-13: vadz Removed support for the old experimental "rxspencer" encoder and "[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and officially supported "regex" encoder and "[not]regexmatch" checks should be used instead (see the two previous entries). Please replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s" when upgrading. Notice that you will also need to replace the back- references of form "@1" with the more standard "\\1" and may need to adjust your regular expressions syntax as the new regex encoder uses Perl-compatible syntax and not (extended) POSIX syntax as the old one. *** POTENTIAL INCOMPATIBILITY *** 2010-07-13: vadz Add "regexmatch", "regextarget" and "notregexmatch" which can be used to apply %rename directives to the declarations matching the specified regular expression only. The first two can be used interchangeably, both of the %renames below do the same thing: %rename("$ignore", regexmatch$name="Old$") ""; %rename("$ignore", regextarget=1) "Old$"; (namely ignore the declarations having "Old" suffix). "notregexmatch" restricts the match to only the declarations which do not match the regular expression, e.g. here is how to rename to lower case versions all declarations except those consisting from capital letters only: %rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") ""; 2010-07-13: vadz Add the new "regex" encoder that can be used in %rename, e.g. %rename("regex:/(\\w+)_(.*)/\\2/") ""; to remove any alphabetical prefix from all identifiers. The syntax of the regular expressions is Perl-like and PCRE library (http://www.pcre.org/) is used to implement this feature but notice that backslashes need to be escaped as usual inside C strings. Original patch from Torsten Landschoff. 2010-07-08: wsfulton Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes the "unref" feature when used on classes with non-public destructors. 2010-06-17: ianlancetaylor [Go] Add the Go language module. 2010-06-10: wsfulton [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple modules and wrapping strings. Patch from 'Number Cruncher'. 2010-06-10: olly [PHP] Fix directors to correctly call a method with has a different name in PHP to C++ (we were always using the C++ name in this case). 2010-06-03: wsfulton Fix uncompileable code when %rename results in two enum items with the same name. Reported by Vadim Zeitlin. Version 2.0.0 (2 June 2010) =========================== 2010-06-02: wsfulton [C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with types containing commas, for example: SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >) 2010-06-01: wsfulton Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be wrapped if the following macro is defined: #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 %include shared_ptr is also documented in Library.html now. 2010-05-27: wsfulton Add the ability for $typemap special variable macros to call other $typemap special variable macros, for example: %typemap(cstype) CC "CC" %typemap(cstype) BB "$typemap(cstype, CC)" %typemap(cstype) AA "$typemap(cstype, BB)" void hah(AA aa); This also fixes C# std::vector containers of shared_ptr and %shared_ptr. Also added diagnostics for $typemap with -debug-tmsearch, for example, the above displays additional diagnostic lines starting "Containing: ": example.i:34: Searching for a suitable 'cstype' typemap for: AA aa Looking for: AA aa Looking for: AA Using: %typemap(cstype) AA Containing: $typemap(cstype, BB) example.i:31: Searching for a suitable 'cstype' typemap for: BB Looking for: BB Using: %typemap(cstype) BB Containing: $typemap(cstype, CC) example.i:29: Searching for a suitable 'cstype' typemap for: CC Looking for: CC Using: %typemap(cstype) CC 2010-05-26: olly Fix %attribute2ref not to produce a syntax error if the last argument (AccessorMethod) is omitted. Patch from David Piepgras in SF#2235756. 2010-05-26: olly [PHP] When using %throws or %catches, SWIG-generated PHP5 wrappers now throw PHP Exception objects instead of giving a PHP error of type E_ERROR. This change shouldn't cause incompatibility issues, since you can't set an error handler for E_ERROR, so previously PHP would just exit which also happens for unhandled exceptions. The benefit is you can now catch them if you want to. Fixes SF#2545578 and SF#2955522. 2010-05-25: olly [PHP] Add missing directorin typemap for const std::string &. Fixes SF#3006404 reported by t-Legiaw. 2010-05-23: wsfulton [C#] Fix #2957375 - SWIGStringHelper and SWIGExceptionHelper not always being initialized before use in .NET 4 as the classes were not marked beforefieldinit. A static constructor has been added to the intermediary class like this: %pragma(csharp) imclasscode=%{ static $imclassname() { } %} If you had added your own custom static constructor to the intermediary class in the same way as above, you will have to modify your approach to use static variable initialization or define SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR - See csharphead.swg. *** POTENTIAL INCOMPATIBILITY *** 2010-05-23: wsfulton Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an inheritance hierarchy. No special treatment is needed for derived classes. The proxy class also no longer needs to be specified, it is automatically deduced. The following macros are deprecated: SWIG_SHARED_PTR(PROXYCLASS, TYPE) SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) and have been replaced by %shared_ptr(TYPE) Similarly for intrusive_ptr wrappers, the following macro is deprecated: SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) and have been replaced by %intrusive_ptr(TYPE) 2010-05-21: olly [PHP] Stop generating a bogus line of code in certain constructors. This was mostly harmless, but caused a PHP notice to be issued, if enabled (SF#2985684). 2010-05-18: wsfulton [Java] Fix member pointers on 64 bit platforms. 2010-05-14: wsfulton Fix wrapping of C++ enum boolean values reported by Torsten Landschoff: typedef enum { PLAY = true, STOP = false } play_state; 2010-05-14: olly [PHP] Fix wrapping of global variables which was producing uncompilable code in some cases. 2010-05-12: drjoe [R] Add two more changes from Wil Nolan. Get garbage collection to work. Implement newfree 2010-05-09: drjoe Fix bug reported by Wil Nolan change creation of string so that R 2.7.0+ can use char hashes 2010-05-07: wsfulton Apply patch #2955146 from Sergey Satskiy to fix expressions containing divide by operator in constructor initialization lists. 2010-05-05: wsfulton [R] Memory leak fix handling const std::string & inputs, reported by Will Nolan. 2010-05-01: wsfulton Typemap matching enhancement for non-default typemaps. Previously all qualifiers were stripped in one step, now they are stripped one at a time starting with the left most qualifier. For example, int const*const is first stripped to int *const then int *. *** POTENTIAL INCOMPATIBILITY *** 2010-04-25: bhy [Python] Fix #2985655 - broken constructor renaming. 2010-04-14: wsfulton Typemap fragments are now official and documented in Typemaps.html. 2010-04-09: wsfulton [Ruby] Fix #2048064 and #2408020. Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit. https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/522874 2010-04-09: wsfulton [Mzscheme] Apply Ubuntu patch to fix std::map wrappers: https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/203876 2010-04-09: wsfulton [Python] Apply patch #2952374 - fix directors and the -nortti option. 2010-04-09: wsfulton [Lua] Fix #2887254 and #2946032 - SWIG_Lua_typename using wrong stack index. 2010-04-03: wsfulton [Python] Fix exceptions being thrown with the -threads option based on patch from Arto Vuori. Fixes bug #2818499. 2010-04-03: wsfulton Fix Makefile targets: distclean and maintainer-clean 2010-04-02: wsfulton [Lua] Fix char pointers, wchar_t pointers and char arrays so that nil can be passed as a valid value. Bug reported by Gedalia Pasternak. 2010-04-01: wsfulton Numerous subtle typemap matching rule fixes when using the default type. The typemap matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc), then look for the next best match by reducing the chosen default type. The type deduction now follows C++ class template partial specialization matching rules. Below are the set of changes made showing the default type deduction along with the old reduced type and the new version of the reduced type: SWIGTYPE const &[ANY] new: SWIGTYPE const &[] old: SWIGTYPE (&)[ANY] SWIGTYPE *const [ANY] new: SWIGTYPE const [ANY] old: SWIGTYPE *[ANY] SWIGTYPE const *const [ANY] new: SWIGTYPE *const [ANY] old: SWIGTYPE const *[ANY] SWIGTYPE const *const & new: SWIGTYPE *const & old: SWIGTYPE const *& SWIGTYPE *const * new: SWIGTYPE const * old: SWIGTYPE ** SWIGTYPE *const & new: SWIGTYPE const & old: SWIGTYPE *& Additionally, a const SWIGTYPE lookup is used now for any constant type. Some examples, where T is some reduced type, eg int, struct Foo: T const new: SWIGTYPE const old: SWIGTYPE T *const new: SWIGTYPE *const old: SWIGTYPE * T const[] new: SWIGTYPE const[] old: SWIGTYPE[] enum T const new: enum SWIGTYPE const old: enum SWIGTYPE T (*const )[] new: SWIGTYPE (*const )[] old: SWIGTYPE (*)[] Reminder: the typemap matching rules can now be seen for any types being wrapped by using either the -debug-tmsearch or -debug-tmused options. In practice this leads to some subtle matching rule changes and the majority of users won't notice any changes, except in the prime area of motivation for this change: Improve STL containers of const pointers and passing const pointers by reference. This is fixed because many of the STL containers use a type 'T const&' as parameters and when T is a const pointer, for example, 'K const*', then the full type is 'K const*const&'. This means that the 'SWIGTYPE *const&' typemaps now match when T is either a non-const or const pointer. Furthermore, some target languages incorrectly had 'SWIGTYPE *&' typemaps when these should have been 'SWIGTYPE *const&'. These have been corrected (Java, C#, Lua, PHP). *** POTENTIAL INCOMPATIBILITY *** 2010-03-13: wsfulton [Java] Some very old deprecated pragma warnings are now errors. 2010-03-13: wsfulton Improve handling of file names and directories containing double/multiple path separators. 2010-03-10: mutandiz (Mikel Bancroft) [allegrocl] Use fully qualified symbol name of cl::identity in emit_defun(). 2010-03-06: wsfulton [Java] The intermediary JNI class modifiers are now public by default meaning these intermediary low level functions are now accessible by default from outside any package used. The proxy class pointer constructor and getCPtr() methods are also now public. These are needed in order for the nspace option to work without any other mods. The previous default of protected access can be restored using: SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE) %pragma(java) jniclassclassmodifiers = "class" 2010-03-06: wsfulton [C#] Added the nspace feature for C#. Documentation for the nspace feature is now available. 2010-03-04: wsfulton Added the nspace feature. This adds some improved namespace support. Currently only Java is supported for target languages, where C++ namespaces are automatically translated into Java packages. The feature only applies to classes,struct,unions and enums declared within a namespace. Methods and variables declared in namespaces still effectively have their namespaces flattened. Example usage: %feature(nspace) Outer::Inner1::Color; %feature(nspace) Outer::Inner2::Color; namespace Outer { namespace Inner1 { struct Color { ... }; } namespace Inner2 { struct Color { ... }; } } For Java, the -package option is also required when using the nspace feature. Say we use -package com.myco, the two classes can then be accessed as follows from Java: com.myco.Outer.Inner1.Color and com.myco.Outer.Inner2.Color. 2010-02-27: wsfulton [Python] Remove -dirvtable from the optimizations included by -O as it this option currently leads to memory leaks as reported by Johan Blake. 2010-02-27: wsfulton License code changes: SWIG Source is GPL-v3 and library code license is now clearer and is provided under a very permissive license. See http://www.swig.org/legal.html. 2010-02-13: wsfulton [Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'. 2010-02-13: wsfulton [Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x used in various STL wrappers. 2010-02-13: wsfulton [C#, Java] Fix incorrect multiply defined symbol name error when an enum item and class name have the same name, as reported by Nathan Krieger. Example: class Vector {}; namespace Text { enum Preference { Vector }; } This also fixes other incorrect corner case target language symbol name clashes. 2010-02-11: wsfulton Add the -debug-lsymbols option for displaying the target language layer symbols. 2010-02-09: wsfulton Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as they should be. 2010-02-08: wsfulton Fix #1807329 - When Makefile dependencies are being generated using the -M family of options on Windows, the file paths have been corrected to use single backslashes rather than double backslashes as path separators. 2010-02-06: wsfulton Fix #2918902 - language specific files not being generated in correct directory on Windows when using forward slashes for -o, for example: swig -python -c++ -o subdirectory/theinterface_wrap.cpp subdirectory/theinterface.i 2010-02-05: wsfulton Fix #2894405 - assertion when using -xmlout. 2010-01-28: wsfulton Fix typemap matching bug when a templated type has a typemap both specialized and not specialized. For example: template struct XX { ... }; %typemap(in) const XX & "..." %typemap(in) const XX< int > & "..." resulted in the 2nd typemap being applied for all T in XX< T >. 2010-01-22: wsfulton Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote global scope, the typemap is now used in situations like this: struct X {}; %typemap(in) const X & "..." void m(const ::X &); and this: struct X {}; %typemap(in) const ::X & "..." void m(const X &); 2010-01-20: wsfulton Fix some unary scope operator (::) denoting global scope problems in the types generated into the C++ layer. Previously the unary scope operator was dropped in the generated code if the type had any sort of qualifier, for example when using pointers, references, like ::foo*, ::foo&, bar< ::foo* >. 2010-01-13: olly [PHP] Add datetime to the list of PHP predefined classes (patch from David Fletcher in SF#2931042). 2010-01-11: wsfulton Slight change to warning, error and diagnostic reporting. The warning number is no longer shown within brackets. This is to help default parsing of warning messages by other tools, vim on Unix in particular. Example original display using -Fstandard: example.i:20: Warning(401): Nothing known about base class 'B'. Ignored. New display: example.i:20: Warning 401: Nothing known about base class 'B'. Ignored. Also subtle fix to -Fmicrosoft format adding in missing space. Example original display: example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored. New display: example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored. 2010-01-10: wsfulton Fix a few inconsistencies in reporting of file/line numberings including modifying the overload warnings 509, 512, 516, 474, 475 to now be two line warnings. 2010-01-10: wsfulton Modify -debug-tags output to use standard file name/line reporting so that editors can easily navigate to the appropriate lines. Was typically: . top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312) . top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39) now: /usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include /usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include 2010-01-03: wsfulton Fix missing file/line numbers for typemap warnings and in output from the -debug-tmsearch/-debug-tmused options. 2010-01-03: wsfulton Add typemaps used debugging option (-debug-tmused). When used each line displays the typemap used for each type for which code is being generated including the file and line number related to the type. This is effectively a condensed form of the -debug-tmsearch option. Documented in Typemaps.html. 2009-12-23: wsfulton Fix for %javaexception and directors so that all the appropriate throws clauses are generated. Problem reported by Peter Greenwood. 2009-12-20: wsfulton Add -debug-tmsearch option for debugging the typemap pattern matching rules. Documented in Typemaps.html. 2009-12-12: wsfulton [Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER macro provided in the octave headers for determining the api version instead. 2009-12-04: olly [Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of SF#2859614. 2009-12-04: olly Fix handling of modulo operator (%) in constant expressions (SF#2818562). 2009-12-04: olly [PHP] "empty" is a reserved word in PHP, so rename empty() method on STL classes to "is_empty()" (previously this was automatically renamed to "c_empty()"). *** POTENTIAL INCOMPATIBILITY *** 2009-12-03: olly [PHP] Add typemaps for long long and unsigned long long, and for pointer to method. 2009-12-02: olly [PHP] Fix warning and rename of reserved class name to be case insensitive. 2009-12-01: wsfulton Revert support for %extend and memberin typemaps added in swig-1.3.39. The memberin typemaps are ignored again for member variables within a %extend block. Documentation inconsistency reported by Torsten Landschoff. 2009-11-29: wsfulton [Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for static const char member variables. %javaconst(1) A; %csconst(1) A; struct X { static const char A = 'A'; }; 2009-11-26: wsfulton [Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to use the actual constant value if it is specified, rather than the C++ code to access the member. %javaconst(1) EN; %csconst(1) EN; struct X { static const int EN = 2; }; 2009-11-23: wsfulton C++ nested typedef classes can now be handled too, for example: struct Outer { typedef Foo { } FooTypedef1, FooTypedef2; }; 2009-11-18: wsfulton The wrappers for C nested structs are now generated in the same order as declared in the parsed code. 2009-11-18: wsfulton Fix #491476 - multiple declarations of nested structs, for example: struct Outer { struct { int val; } inner1, inner2, *inner3, inner4[1]; } outer; 2009-11-17: wsfulton Fix parsing of enum declaration and initialization, for example: enum ABC { a, b, c } A = a, *pC = &C, array[3] = {a, b, c}; 2009-11-17: wsfulton Fix parsing of struct declaration and initialization, for example: struct S { int x; } instance = { 10 }; 2009-11-15: wsfulton Fix #1960977 - Syntax error parsing derived nested class declaration and member variable instance. 2009-11-14: wsfulton Fix #2310483 - function pointer typedef within extern "C" block. 2009-11-13: wsfulton Fix usage of nested template classes within templated classes so that compileable code is generated. 2009-11-13: olly [php] Fix place where class prefix (as specified with -prefix) wasn't being used. Patch from gverbruggen in SF#2892647. 2009-11-12: wsfulton Fix usage of nested template classes so that compileable code is generated - the nested template class is now treated like a normal nested classes, that is, as an opaque type unless the nestedworkaround feature is used. 2009-11-12: wsfulton Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively. Named nested class ignored warnings can now be suppressed by name using %warnfilter, eg: %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner; but clearly unnamed nested classes cannot and the global suppression is still required, eg: #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS 2009-11-11: wsfulton Added the nestedworkaround feature as a way to use the full functionality of a nested class (C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG had never parsed the nested class. The documented nested class workarounds using a global fake class stopped working when SWIG treated the nested class as an opaque pointer, and this feature reverts this behaviour. The documentation has been updated with details of how to use and implement it, see the "Nested classes" section in SWIGPlus.html. 2009-11-11: wsfulton There were a number of C++ cases where nested classes/structs/unions were being handled as if C code was being parsed which would oftentimes lead to uncompileable code as an attempt was made to wrap the nested structs like it is documented for C code. Now all nested structs/classes/unions are ignored in C++ mode, as was always documented. However, there is an improvement as usage of nested structs/classes/unions is now always treated as an opaque type by default, resulting in generated code that should always compile. *** POTENTIAL INCOMPATIBILITY *** 2009-11-09: drjoe Fix R for -fcompact and add std_map.i 2009-11-08: wsfulton Fix inconsistency for nested structs/unions/classes. Uncompileable code was being generated when inner struct and union declarations were used as types within the inner struct. The inner struct/union is now treated as a forward declaration making the behaviour the same as an inner class. (C++ code), eg: struct Outer { struct InnerStruct { int x; }; InnerStruct* getInnerStruct(); }; 2009-11-08: wsfulton Ignored nested class/struct warnings now display the name of the ignored class/struct. 2009-11-07: wsfulton Bug #1514681 - Fix nested template classes within a namespace generated uncompileable code and introduced strange side effects to other wrapper code especially code after the nested template class. Note that nested template classes are still ignored. 2009-11-07: wsfulton Add new debug options: -debug-symtabs - Display symbol tables information -debug-symbols - Display target language symbols in the symbol tables -debug-csymbols - Display C symbols in the symbol tables 2009-11-03: wsfulton Fix some usage of unary scope operator (::) denoting global scope, for example: namespace AA { /* ... */ } using namespace ::AA; and bug #1816802 - SwigValueWrapper should be used: struct CC { CC(int); // no default constructor }; ::CC x(); and in template parameter specializations: struct S {}; template struct X { void a() {}; }; template <> struct X { void b() {}; }; %template(MyTConcrete) X< ::S >; plus probably some other corner case usage of ::. 2009-11-02: olly [Python] Fix potential memory leak in initialisation code for the generated module. 2009-10-23: wsfulton Fix seg fault when using a named nested template instantiation using %template(name) within a class. A warning that these are not supported is now issued plus processing continues as if no name was given. 2009-10-20: wsfulton [Python] Fix std::vector. This would previously compile, but not run correctly. 2009-10-20: wsfulton Fixed previously fairly poor template partial specialization and explicit specialization support. Numerous bugs in this area have been fixed including: - Template argument deduction implemented for template type arguments, eg this now works: template class X {}; template class X {}; %template(X1) X; // Chooses T * specialization and more complex cases with multiple parameters and a mix of template argument deduction and explicitly specialised parameters, eg: template struct TwoParm { void a() {} }; template struct TwoParm { void e() {} }; %template(E) TwoParm; Note that the primary template must now be in scope, like in C++, when an explicit or partial specialization is instantiated with %template. *** POTENTIAL INCOMPATIBILITY *** 2009-09-14: wsfulton [C#] Add %csattributes for adding C# attributes to enum values, see docs for example. 2009-09-11: wsfulton Fix memmove regression in cdata.i as reported by Adriaan Renting. 2009-09-07: wsfulton Fix constant expressions containing <= or >=. 2009-09-02: wsfulton The following operators in constant expressions now result in type bool for C++ wrappers and remain as type int for C wrappers, as per each standard: && || == != < > <= >= (Actually the last 4 are still broken). For example: #define A 10 #define B 10 #define A_EQ_B A == B // now wrapped as type bool for C++ #define A_AND_B A && B // now wrapped as type bool for C++ 2009-09-02: wsfulton Fix #2845746. true and false are now recognised keywords (only when wrapping C++). Constants such as the following are now wrapped (as type bool): #define FOO true #define BAR FOO && false Version 1.3.40 (18 August 2009) =============================== 2009-08-17: olly [Perl] Add "#undef do_exec" to our clean up of Perl global namespace pollution. 2009-08-17: olly [PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217). 2009-08-17: wsfulton Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html is not available. 2009-08-16: wsfulton [Octave] Caught exceptions display the type of the C++ exception instead of the generic "c++-side threw an exception" message. 2009-08-16: wsfulton [Java] When %catches is used, fix so that any classes specified in the "throws" attribute of the "throws" typemap are generated into the Java method's throws clause. 2009-08-16: wsfulton [C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez. 2009-08-15: wsfulton Fix %template seg fault on some cases of overloading the templated method. Bug reported by Jan Kupec. 2009-08-15: wsfulton [Ruby] Add numerous missing wrapped methods for std::vector specialization as reported by Youssef Jones. 2009-08-14: wsfulton [Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer memory ownership control. shared_ptr support still to be added. Patch from David Fletcher. 2009-08-14: olly [PHP] PHP5 now wraps static member variables as documented. 2009-08-14: olly [PHP] Update the PHP "class" example to work with PHP5 and use modern wrapping features. 2009-08-13: wsfulton [PHP] std::vector wrappers overhaul. They no longer require the specialize_std_vector() macro. Added wrappers for capacity() and reserve(). 2009-08-13: wsfulton [PHP] Add const reference typemaps. const reference primitive types are now passed by value rather than pointer like the other target languages. Fixes SF#2524029. 2009-08-08: wsfulton [Python] More user friendly AttributeError is raised when there are no constructors generated for the proxy class in the event that the class is abstract - the error message is now "No constructor defined - class is abstract" whereas if there are no public constructors for any other reason and the class is not abstract, the message remains "No constructor defined". [tcl] Similarly for tcl when using -itcl. 2009-08-04: olly [PHP] Fix generated code to work with PHP 5.3. 2009-08-04: vmiklos [PHP] Various mathematical functions (which would conflict with the built-in PHP ones) are now automatically handled by adding a 'c_' prefix. 2009-08-03: wsfulton [C#] The std::vector implementation is improved and now uses $typemap such that the proxy class for T no longer has to be specified in some macros for correct C# compilation; the following macros are deprecated, where CSTYPE was the C# type for the C++ class CTYPE: SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE) usage should be removed altogether SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE) should be replaced with: SWIG_STD_VECTOR_ENHANCED(CTYPE) Some more details in csharp/std_vector.i *** POTENTIAL INCOMPATIBILITY *** 2009-07-31: olly [Python] Fix indentation so that we give a useful error if the module can't be loaded. Patch from Gaetan Lehmann in SF#2829853. 2009-07-29: wsfulton Add $typemap(method, typelist) special variable macro. This allows the contents of a typemap to be inserted within another typemap. Fully documented in Typemaps.html. 2009-07-29: vmiklos [PHP] Static member variables are now prefixed with the class name. This allows static member variables with the same name in different classes. 2009-07-29: olly [Python] Add missing locks to std::map wrappers. Patch from Paul Hampson in SF#2813836. 2009-07-29: olly [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi Amano in SF#2826322. 2009-07-29: olly [PHP] Fix memory leak in PHP resource destructor for classes without a destructor and non-class types. Patch from Hitoshi Amano in SF#2825303. 2009-07-28: olly [PHP] Update warnings about clashes between identifiers and PHP keywords and automatic renaming to work with the PHP5 class wrappers. Fixes SF#1613679. 2009-07-28: vmiklos [PHP] If a member function is not public but it has a base which is public, then now a warning is issued and the member function will be public, as PHP requires this. 2009-07-21: vmiklos [PHP] Director support added. 2009-07-15: olly [Perl] Don't specify Perl prototype "()" for a constructor with a different name to the class, as such constructors can still take parameters. 2009-07-12: xavier98 [Octave] Add support for Octave 3.2 API 2009-07-05: olly [PHP] Update the list of PHP keywords - "cfunction" is no longer a keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__", and "__NAMESPACE__". 2009-07-03: olly [Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter of the manual. Based on patch from SF#2810380 by Christian Gollwitzer. 2009-07-02: vmiklos [PHP] Added factory.i for PHP, see the li_factory testcase for more info on how to use it. 2009-07-02: wsfulton Fix -Wallkw option as reported by Solomon Gibbs. 2009-07-02: wsfulton Fix syntax error when a nested struct contains a comment containing a * followed eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs. 2009-07-01: vmiklos [PHP] Unknown properties are no longer ignored in proxy classes. 2009-07-01: vmiklos [PHP] Fixed %newobject behaviour, previously any method marked with %newobject was handled as a constructor. 2009-06-30: olly [Ruby] Undefine close and connect macros defined by Ruby API headers as we don't need them and they can clash with C++ methods being wrapped. Patch from Vit Ondruch in SF#2814430. 2009-06-26: olly [Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a double parameter. 2009-06-24: wsfulton Fix wrapping methods with default arguments and the compactdefaultargs feature where a class is passed by value and is assigned a default value. The SwigValueWrapper template workaround for a missing default constructor is no longer used as the code generated does not call the default constructor. 2009-06-16: wsfulton [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items. Incorrect enum values were being passed to the C++ layer or compilation errors resulted. 2009-06-02: talby [Perl] Resolved reference.i overload support problem identified by John Potowsky. 2009-05-26: wsfulton [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy now implements System.Collections.Generic.IDictionary<>. These std:map wrappers have a non-backwards compatible overhaul to make them like a .NET IDictionary. Some method names have changed as following: set -> setitem (use this[] property now) get -> getitem (use this[] property now) has_key -> ContainsKey del -> Remove clear -> Clear The following macros used for std::map wrappers are deprecated and will no longer work: specialize_std_map_on_key specialize_std_map_on_value specialize_std_map_on_both *** POTENTIAL INCOMPATIBILITY *** 2009-05-20: vmiklos [PHP] Add the 'thisown' member to classes. The usage of it is the same as the Python thisown one: it's 1 by default and you can set it to 0 if you want to prevent freeing it. (For example to prevent a double free.) 2009-05-14: bhy [Python] Fix the wrong pointer value returned by SwigPyObject_repr(). 2009-05-13: mutandiz (Mikel Bancroft) [allegrocl] Minor tweak when wrapping in -nocwrap mode. 2009-05-11: wsfulton [C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These implement IList<> instead of IEnumerable<> where possible. 2009-04-29: wsfulton [Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps. When this attribute is set, the typemap will not apply to classes that are derived from a C++ base class, eg %typemap(csbase, notderived="1") SWIGTYPE "CommonBase" 2009-04-29: olly [Python] Don't attempt to acquire the GIL in situations where we know that it will already be locked. This avoids some dead-locks with mod_python (due to mod_python bugs which are apparently unlikely to ever be fixed), and results in smaller wrappers which run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04, the stripped wrapper library was 11% smaller and ran 2.7% faster). 2009-04-21: wsfulton [C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation. 2009-04-09: wsfulton Fix #2746858 - C macro expression using floating point numbers 2009-03-30: olly [PHP] The default out typemap for char[ANY] now returns the string up to a zero byte, or the end of the array if there is no zero byte. This is the same as Python does, and seems more generally useful than the previous behaviour of returning the whole contents of the array including any zero bytes. If you want the old behaviour, you can provide your own typemap to do this: %typemap(out) char [ANY] %{ RETVAL_STRINGL($1, $1_dim0, 1); %} Version 1.3.39 (21 March 2009) ============================== 2009-03-19: bhy [Python] Fix the memory leak related to Python 3 unicode and C char* conversion, which can be shown in the following example before this fix: from li_cstring import * i=0 while True: i += 1 n = str(i)*10 test3(n) This fix affected SWIG_AsCharPtrAndSize() so you cannot call this function with a null alloc and non-null cptr argument in Python 3, otherwise a runtime error will be raised. 2009-03-18: wsfulton [C#] std::vector wrapper improvements for .NET 2 and also providing the necessary machinery to use the std::vector wrappers with more advanced features such as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to generate code requiring .NET 2 as a minimum, although the C# code can be compiled for .NET 1 by defining the SWIG_DOTNET_1 C# preprocessor constant. See the std_vector.i file for more details. *** POTENTIAL INCOMPATIBILITY *** 2009-03-12: wsfulton [Ruby] Fix #2676738 SWIG generated symbol name clashes. 2009-03-01: bhy [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement. Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect the drop of tp_compare and nb_long. 2009-03-01: bhy [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the case that module already imported at other place. 2009-02-28: bhy [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before the method calls, since some C compiler don't allow declaration in middle of function body. 2009-02-21: wsfulton [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types. 2009-02-20: wsfulton [CFFI] Fix seg faults when for %extend and using statements. 2009-02-20: wsfulton Fix SF #2605955: -co option which broke in 1.3.37. 2009-02-20: wsfulton New %insert("begin") section added. Also can be used as %begin. This is a new code section reserved entirely for users and the code within the section is generated at the top of the C/C++ wrapper file and so provides a means to put custom code into the wrapper file before anything else that SWIG generates. 2009-02-17: wsfulton 'make clean-test-suite' will now run clean on ALL languages. Previously it only ran the correctly configured languages. This way it is now possible to clean up properly after running 'make partialcheck-test-suite'. 2009-02-14: wsfulton Extend attribute library support for structs/classes and the accessor functions use pass/return by value semantics. Two new macros are available and usage is identical to %attribute. These are %attributeval for structs/classes and %attributestring for string classes, like std::string. See attribute.swg for more details. 2009-02-13: wsfulton Add support for %extend and memberin typemaps. Previously the memberin typemaps were ignored for member variables within a %extend block. 2009-02-12: wsfulton Remove unnecessary temporary variable when wrapping return values that are references. Example of generated code for wrapping: struct XYZ { std::string& refReturn(); }; used to be: std::string *result = 0 ; ... { std::string &_result_ref = (arg1)->refReturn(); result = (std::string *) &_result_ref; } Now it is: std::string *result = 0 ; ... result = (std::string *) &(arg1)->refReturn(); 2009-02-08: bhy Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from the length of the buffer to the number of items in the buffer. 2009-02-08: wsfulton Fix %feature not working for conversion operators, reported by Matt Sprague, for example: %feature("cs:methodmodifiers") operator bool "protected"; 2009-02-07: wsfulton [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions. Also fixes Makefile errors building SWIG executable when mzscheme package is installed (version 3.72 approx and later). 2009-02-04: talby [Perl] Fix SF#2564192 reported by David Kolovratnk. SWIG_AsCharPtrAndSize() now handles "get" magic. Version 1.3.38 (31 January 2009) ================================ 2009-01-31: bhy [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend and %pythonappend have correct indentation. 2009-01-31: bhy [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list of static member function in generated proxy code should not have the 'self' parameter. 2009-01-29: wsfulton Fix regression introduced in 1.3.37 where the default output directory for target language specific files (in the absence of -outdir) was no longer the same directory as the generated c/c++ file. 2009-01-28: wsfulton [Java, C#] Fix proxy class not being used when the global scope operator was used for parameters passed by value. Reported by David Piepgrass. 2009-01-15: wsfulton [Perl] Fix seg fault when running with -v option, reported by John Ky. Version 1.3.37 (13 January 2009) ================================ 2009-01-13: mgossage [Lua] Added contract support for requiring that unsigned numbers are >=0 Rewrote much of Examples/Lua/embed3. Added a lot to the Lua documentation. 2009-01-13: wsfulton Fix compilation error when using directors on protected virtual overloaded methods reported by Sam Hendley. 2009-01-12: drjoe [R] Fixed handling of integer arrays 2009-01-10: drjoe [R] Fix integer handling in r to deal correctly with signed and unsigned issues 2009-01-10: wsfulton Patch #1992756 from Colin McDonald - %contract not working for classes in namespace 2009-01-05: olly Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source code and remove documentation of them. 2008-12-30: wsfulton Bug #2430756. All the languages now define a macro in the generated C/C++ wrapper file indicating which language is being wrapped. The macro name is the same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc and are listed in the "Conditional Compilation" section in the documentation. 2008-12-23: wsfulton [Java] Fix #2153773 - %nojavaexception was clearing the exception feature instead of disabling it. Clearing checked Java exceptions also didn't work. The new %clearjavaexception can be used for clearing the exception feature. 2008-12-22: wsfulton Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors throw exceptions. 2008-12-21: wsfulton Apply patch #2440046 which fixes possible seg faults for member and global variable char arrays when the strings are larger than the string array size. 2008-12-20: wsfulton The ccache compiler cache has been adapted to work with SWIG and named ccache-swig. It now works with C/C++ compilers as well as SWIG and can result in impressive speedups when used to recompile unchanged code with either a C/C++ compiler or SWIG. Documentation is in CCache.html or the installed ccache-swig man page. 2008-12-12: wsfulton Apply patch from Kalyanov Dmitry which fixes parsing of nested structs containing comments. 2008-12-12: wsfulton Fix error message in some nested struct and %inline parsing error situations such as unterminated strings and comments. 2008-12-07: olly [PHP] Fix warnings when compiling generated wrapper with GCC 4.3. 2008-12-06: wsfulton [PHP] Deprecate %pragma(php4). Please use %pragma(php) instead. The following two warnings have been renamed: WARN_PHP4_MULTIPLE_INHERITANCE -> WARN_PHP_MULTIPLE_INHERITANCE WARN_PHP4_UNKNOWN_PRAGMA -> WARN_PHP_UNKNOWN_PRAGMA *** POTENTIAL INCOMPATIBILITY *** 2008-12-04: bhy [Python] Applied patch SF#2158938: all the SWIG symbol names started with Py are changed, since they are inappropriate and discouraged in Python documentation (from http://www.python.org/doc/2.5.2/api/includes.html): "All user visible names defined by Python.h (except those defined by the included standard headers) have one of the prefixes "Py" or "_Py". Names beginning with "_Py" are for internal use by the Python implementation and should not be used by extension writers. Structure member names do not have a reserved prefix. Important: user code should never define names that begin with "Py" or "_Py". This confuses the reader, and jeopardizes the portability of the user code to future Python versions, which may define additional names beginning with one of these prefixes." Here is a brief list of what changed: PySwig* -> SwigPy* PyObject_ptr -> SwigPtr_PyObject PyObject_var -> SwigVar_PyObject PySequence_Base, PySequence_Cont, PySequence_Ref -> SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref PyMap* -> SwigPyMap* We provided a pyname_compat.i for backward compatibility. Users whose code having these symbols and do not want to change it could simply include this file at front of your code. A better solution is to run the converting tool on your code, which has been put in SWIG's SVN trunk (Tools/pyname_patch.py) and you can download it here: https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py *** POTENTIAL INCOMPATIBILITY *** 2008-12-02: wsfulton [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes when the package option is specified in %module and that module is %import'ed. 2008-11-28: wsfulton [UTL] Fix #2080497. Some incorrect acceptance of types in the STL, eg a double * element passed into a vector constructor would be accepted, but the ensuing behaviour was undefined. Now the type conversion correctly raises an exception. 2008-11-24: wsfulton Add -outcurrentdir option. This sets the default output directory to the current directory instead of the path specified by the input file. This option enables behaviour similar to c/c++ compilers. Note that this controls the output directory, but only in the absence of the -o and/or -outdir options. 2008-11-23: wsfulton [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in ruby 1.9. 2008-11-23: wsfulton Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace. 2008-11-21: wsfulton The use of the include path to find the input file is now deprecated. This makes the behaviour of SWIG the same as C/C++ compilers in preparation for use with ccache. 2008-11-16: wsfulton Fix -nopreprocess option to: - correctly report file names in warning and error messages. - use the original input filename that created the preprocessed output when determining the C++ wrapper file name (in the absence of -o). Previously the name of the input file containing the preprocessed output was used. 2008-11-11: wsfulton [Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the Intel compiler 2008-11-01: wsfulton Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy class being reported for Python docstrings when %rename is used. 2008-11-01: wsfulton Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an easy way to rename symbols by stripping a commonly used prefix in all the function/struct names. It works in the same way as the other encoders, such as title, lower, command etc outlined in CHANGES file dated 12/30/2005. Example below will rename wxAnotherWidget to AnotherWidget and wxDoSomething to DoSomething: %rename("%(strip:[wx])s") ""; struct wxAnotherWidget { void wxDoSomething(); }; 2008-09-26: mutandiz [allegrocl] Lots of test-suite work. - Fix ordering of wrapper output and %{ %} header output. - Fix declarations of local vars in C wrappers. - Fix declaration of defined constants in C wrappers. - Fix declaration of EnumValues in C wrappers. - add some const typemaps to allegrocl.swg - add rename for operator bool() overloads. 2008-09-25: olly [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186). 2008-09-22: mutandiz (Mikel Bancroft) [allegrocl] - Support wrapping of types whose definitions are not seen by SWIG. They are treated as forward-referenced classes and if a definition is not seen are treated as (* :void). - Don't wrap the contents of unnamed namespaces. - More code cleanup. Removed some extraneous warnings. - start work on having the allegrocl mod pass the cpp test-suite. 2008-09-19: olly [PHP5] Add typemaps for long long and unsigned long long. 2008-09-18: wsfulton [C#] Added C# array typemaps provided by Antti Karanta. The arrays provide a way to use MarshalAs(UnmanagedType.LPArray) and pinning the array using 'fixed'. See arrays_csharp.i library file for details. 2008-09-18: wsfulton Document the optional module attribute in the %import directive, see Modules.html. Add a warning for Python wrappers when the module name for an imported base class is missing, requiring the module attribute to be added to %import, eg %import(module="FooModule") foo.h 2008-09-18: olly [PHP5] Change the default input typemap for char * to turn PHP Null into C NULL (previously it was converted to an empty string). The new behaviour is consistent with how the corresponding output typemap works (SF#2025719). If you want to keep the old behaviour, add the following typemap to your interface file (PHP's convert_to_string_ex() function does the converting from PHP Null to an empty string): %typemap(in) char * { convert_to_string_ex($input); $1 = Z_STRVAL_PP($input); } 2008-09-18: olly [PHP5] Fix extra code added to proxy class constructors in the case where the only constructor takes no arguments. 2008-09-18: olly [PHP5] Fix wrapping of a renamed enumerated value of an enum class member (SF#2095273). 2008-09-17: mutandiz (Mikel Bancroft) [allegrocl] - Fix how forward reference typedefs are handled, so as not to conflict with other legit typedefs. - Don't (for now) perform an ffitype typemap lookup when trying to when calling compose_foreign_type(). This is actually a useful thing to do in certain cases, the test cases for which I can't currently locate :/. It's breaking some wrapping behavior that is more commonly seen, however. I'll readd in a more appropriate way when I can recreate the needed test case, or a user complains (which means they probably have a test case). - document the -isolate command-line arg in the 'swig -help' output. It was in the html docs, but not there. - small amount of code cleanup, removed some unused code. - some minor aesthetic changes. 2008-09-12: bhy [Python] Python 3.0 support branch merged into SWIG trunk. Thanks to Google Summer of Code 2008 for supporting this project! By default SWIG will generate interface files compatible with both Python 2.x and 3.0. And there's also some Python 3 new features that can be enabled by passing a "-py3" command line option to SWIG. These features are: - Function annotation support Also, the parameter list of proxy function will be generated, even without the "-py3" option. However, the parameter list will fallback to *args if the function (or method) is overloaded. - Buffer interface support - Abstract base class support For details of Python 3 support and these features, please see the "Python 3 Support" section in the "SWIG and Python" chapter of the SWIG documentation. The "-apply" command line option and support of generating codes using apply() is removed. Since this is only required by very old Python. This merge also patched SWIG's parser to solve a bug. By this patch, SWIG features able to be correctly applied on C++ conversion operator, such like this: %feature("shadow") *::operator bool %{ ... %} 2008-09-02: richardb [Python] Commit patch #2089149: Director exception handling mangles returned exception. Exceptions raised by Python code in directors are now passed through to the caller without change. Also, remove the ": " prefix which used to be added to other director exceptions (eg, those due to incorrect return types). 2008-09-02: wsfulton [Python] Commit patch #1988296 GCItem multiple module linking issue when using directors. 2008-09-02: wsfulton [C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now possible through the use of the pre attribute and the new terminator attribute, eg %typemap(csin, pre=" using (CDate temp$csinput = new CDate($csinput)) {", terminator=" } // terminate temp$csinput using block", ) const CDate & "$csclassname.getCPtr(temp$csinput)" See CSharp.html for more info. 2008-09-01: wsfulton [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into no-eval context in DEFCENUM 2008-08-02: wuzzeb [Chicken,Allegro] Commit Patch 2019314 Fixes a build error in chicken, and several build errors and other errors in Allegro CL 2008-07-19: wsfulton Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson. 2008-07-17: wsfulton Fix SF #2019156 Configuring with --without-octave or --without-alllang did not disable octave. 2008-07-14: wsfulton [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly marshalled to C#/Java null in director methods. 2008-07-04: olly [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() since "empty" is a PHP reserved word. Based on patch from Mark Klein in SF#1943417. 2008-07-04: olly [PHP] The deprecated command line option "-make" has been removed. Searches on Google codesearch suggest that nobody is using it now anyway. 2008-07-04: olly [PHP] The SWIG cdata.i library module is now supported. 2008-07-03: olly [PHP] The deprecated command line option "-phpfull" has been removed. We recommend building your extension as a dynamically loadable module. 2008-07-02: olly [PHP4] Support for PHP4 has been removed. The PHP developers are no longer making new PHP4 releases, and won't even be providing patches for critical security issues after 2008-08-08. 2008-07-02: olly [Python] Import the C extension differently for Python 2.6 and later so that an implicit relative import doesn't produce a deprecation warning for 2.6 and a failure for 2.7 and later. Patch from Richard Boulton in SF#2008229, plus follow-up patches from Richard and Haoyu Bai. Version 1.3.36 (24 June 2008) ============================= 06/24/2008: wsfulton Remove deprecated -c commandline option (runtime library generation). 06/24/2008: olly [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) (testcase ignore_parameter). 06/24/2008: olly [PHP] Fix segfault when wrapping a non-class function marked with %newobject (testcase char_strings). 06/22/2008: wsfulton [Java] Add a way to use AttachCurrentThreadAsDaemon instead of AttachCurrentThread in director code. Define the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro, see Lib/java/director.swg. 06/21/2008: wsfulton [Ruby] Fix crashing in the STL wrappers (reject! and delete_if methods) 06/19/2008: wsfulton [Java, C#] C# and Java keywords will be renamed instead of just issuing a warning and then generating uncompileable code. Warning 314 gives the new name when a keyword is found. 06/19/2008: wsfulton [R] Keyword handling added. R Keywords will be renamed as necessary. Warning 314 gives the new name when a keyword is found. 06/17/2008: mgossage [Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase. (Bug #1938142) 06/07/2008: bhy Added test case keyword_rename, then made the keyword renaming works properly by fixing Swig_name_make() for a incomplete condition checking. 06/02/2008: wsfulton [Java, C#] Fix enum wrappers when using -noproxy. 05/30/2008: bhy Added std::wstring into Lib/typemaps/primtypes.swg, since it is also a primitive type in SWIG - fixed SF #1976978. 05/29/2008: wsfulton [Java, C#] Fix variable wrappers when using -noproxy. 05/29/2008: bhy [Python] Fixed a typo of %#ifdef in Lib/python/pycontainer.swg, which is related to -extranative SWIG option - SF #1971977. 05/20/2008: wsfulton New partialcheck makefile targets for partial testing of the test-suite. These just invoke SWIG, ie no compilation and no runtime testing. It can be faster when developing by just doing a directory diff of the files SWIG generates against those from a previous run. Example usage from the top level directory: make partialcheck-test-suite make partialcheck-java-test-suite This change also encompasses more flexibility in running the test-suite, eg it is possible to prefix the command line which runs any target language test with a tool. See the RUNTOOL, COMPILETOOL and SWIGTOOL targets in the common.mk file and makefiles in the test-suite directory. For example it is possible to run the runtime tests through valgrind using: make check RUNTOOL="valgrind --leak-check=full" or invoke SWIG under valgrind using: make check SWIGTOOL="valgrind --tool=memcheck" 05/19/2008: drjoe [R] Fixed define that was breaking pre-2.7. Checked in patch from Soren Sonnenburg that creates strings in version independent way 05/15/2008: wsfulton [Java] Fix variable name clash in directors - SF #1963316 reported by Tristan. 05/14/2008: wsfulton Add an optimisation for functions that return objects by value, reducing the number of copies of the object that are made. Implemented using an optional attribute in the "out" typemap called "optimal". Details in Typemaps.html. 05/11/2008: olly [PHP] Check for %feature("notabstract") when generating PHP5 class wrapper. 05/11/2008: wsfulton Fix SF #1943608 - $self substitution in %contract, patch submitted by Toon Verstraelen. 05/09/2008: olly [PHP] Fix char * typemaps to work when applied to signed char * and unsigned char * (uncovered by testcase apply_strings). 05/09/2008: wsfulton Fix wrapping of char * member variables when using allprotected mode. Bug reported by Warren Wang. 05/09/2008: olly [PHP] Fix bad PHP code generated when wrapping an enum in a namespace (uncovered by testcase arrays_scope). 05/09/2008: olly [PHP] SWIG now runs the PHP testsuite using PHP5, not PHP4. PHP4 is essentially obsolete now, so we care much more about solid PHP5 support. 05/07/2008: wsfulton STL fixes when using %import rather than %include and the Solaris Workshop compiler and the Roguewave STL. 05/07/2008: wsfulton Fix wrapping of overloaded protected methods when using allprotected mode. Bug reported by Warren Wang. 05/03/2008: wsfulton Commit patch #1956607 to add -MT support from Richard Boulton. This patch mirrors the gcc -MT option which allows one to change the default Makefile target being generated when generating makefiles with the -M family of options. For example: $ swig -java -MM -MT overriddenname -c++ example.i overriddenname: \ example.i \ example.h 04/30/2008: mgossage [Lua] Removed generation of _wrap_delete_XXXXX (wrappered destructor) which was unused and causing warning with g++ -Wall. Removed other unused warning in typemaps.i and other places. Added Examples/lua/embed3, and run tests a few test cases. 04/24/2008: olly [Python] Fix generated code for IBM's C++ compiler on AIX (patch from Goeran Uddeborg in SF#1928048). 04/24/2008: olly Rename BSIZE in Examples/test-suite/arrays_scope.i to BBSIZE to avoid a clash with BSIZE defined by headers on AIX with Perl (reported in SF#1928048). 04/20/2008: wsfulton Add the ability to wrap all protected members when using directors. Previously only the virtual methods were available to the target language. Now all protected members, (static and non-static variables, non-virtual methods and static methods) are wrapped when using the allprotected mode. The allprotected mode is turned on in the module declaration: %module(directors="1", allprotected="1") modulename Version 1.3.35 (7 April 2008) ============================= 04/07/2008: wsfulton [Lua] Add missing pointer reference typemaps 04/06/2008: wsfulton Fix stack overflow when using typemap warning suppression, eg %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) 04/05/2008: wsfulton [Python] Fix shared_ptr typemaps so that %pythonnondynamic can be used. Also corrects display of the proxy class type. Reported by Robert Lupton. 04/04/2008: olly [Python] Add %newobject reference to python memory management subsection of manual (patch from mdbeachy in SF#1894610). 03/27/2008: wsfulton [Python] Fix shared_ptr typemaps where the pointer type is a templated type with with more than one parameter. Reported by Robert Lupton. 03/27/2008: mgossage [Lua] Added a typemap DISOWN for SWIGTYPE* and SWIGTYPE[], and support for %delobject feature. Added Examples/lua/owner which demonstrates the use of the memory management. 03/26/2008: wsfulton [Java] Apply patch #1844301 from Monty Taylor to suppress enum constructor unused warnings. 03/26/2008: wsfulton [Python] Apply patch #1924524 from Casey Raymondson which ensures the "No constructor defined" message is displayed when attempting to call a constructor on a class that doesn't have a constructor wrapper, eg if the C++ class is abstract. 03/26/2008: wsfulton [Python] Apply patch #1925702 from Casey Raymondson which removes warning 512 for std::vector wrappers. 03/26/2008: olly [Python] Apply GCC 4.3 warnings patch from Philipp Thomas (SF#1925122). 03/21/2008: wsfulton [Python] Thread safety patch for STL iterators from Abhinandan Jain. 03/17/2008: mgossage [Lua] Added %luacode feature to add source code into wrappers. Updated documentation to document this. Added Examples/lua/arrays to show its use (and typemaps) 03/17/2008: olly Fix nonportable sed usage which failed on Mac OS X (and probably other platforms). Fixes SF#1903612. 03/17/2008: olly Fix memory leak in SWIG's parser (based on patch from Russell Bryant in SF#1914023). 03/12/2008: wsfulton Fix bug #1878285 - unnecessary cast for C struct creation wrappers. 03/12/2008: wsfulton [Python] Remove debugging info when using shared_ptr support 03/06/2008: mgossage [Lua] Updated documentation for Lua exceptions. Added Examples/lua/exception and Examples/lua/embed2. Small updates to the typemaps. 03/04/2008: wsfulton [Java, C#] Add char *& typemaps. 03/04/2008: wsfulton Fix occasional seg fault when attempting to report overloaded methods as being ignored. 02/29/2008: wsfulton [Perl] Fix #1904537 Swig causes a Perl warning "x used only once" in Perl 5.10 reported by Ari Jolma 02/29/2008: wsfulton [Python] Add shared_ptr varin/varout typemaps for wrapping global variables. 02/25/2008: wsfulton Fix $wrapname to work in %exception (fixes some wrap:name assertions) Version 1.3.34 (27 February 2008) ================================= 02/13/2008: wsfulton [R] Fix wrapping of global function pointer variables. 02/13/2008: wsfulton Add new special variables for use within %exception: $wrapname - language specific wrapper name $overname - if a method is overloaded this contains the extra mangling used on the overloaded method $decl - the fully qualified C/C++ declaration of the method being wrapped without the return type $fulldecl - the fully qualified C/C++ declaration of the method being wrapped including the return type 02/12/2008: drjoe [R] Now setting S4 flag in SWIG created objects. This fixes R-SWIG for 2.6 and warning for 2.6 failure has been removed. 02/11/2008: mgossage [Lua] Added a patch by Torsten Landschoff to fix the unary minus issue Ran 'astyle --style=kr -2' across lua.cxx to neaten it up 02/10/2008: wsfulton Bump SWIG_RUNTIME_VERSION to 4. This is because of the recently introduced API change in the conversion functions, ie change in definition of swig_converter_func. Anyone calling SWIG_TypeCast must pass in a valid value for the new additional (third) parameter and then handle the newly created memory if the returned value is set to SWIG_CAST_NEW_MEMORY else a memory leak will ensue. 02/09/2008: wsfulton [Python] Experimental shared_ptr typemaps added. Usage is the same as the recently added Java and C# shared_ptr typemaps. Two macros are available, although these may well change in a future version: For base classes or classes not in an inheritance chain: SWIG_SHARED_PTR(PROXYCLASS, TYPE) For derived classes: SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) The PROXYCLASS is the name of the proxy class, but is only required for Java/C#. Example usage: %include "boost_shared_ptr.i" SWIG_SHARED_PTR(Klass, Space::Klass) SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived) namespace Space { struct Klass { ... }; struct KlassDerived : Klass { ... }; } Further details to follow in future documentation, but the following features should be noted: - Not restricted to boost::shared_ptr, eg std::tr1::shared_ptr can also be used. - Available typemap groups: (a) Typemaps for shared_ptr passed by value, reference, pointer and pointer reference. - (b) Typemaps for passing by raw value, raw pointer, raw reference, raw pointer reference. - The code being wrapped does not even have to use shared_ptr, SWIG can use shared_ptr as the underlying storage mechanism instead of a raw pointer due to the typemaps in group (b) above. - No array support as shared_ptr does not support arrays. - This works quite differently to the usual SWIG smart pointer support when operator-> is parsed by SWIG: - An additional smart pointer class is not generated reducing code bloat in the wrappers. - Using smart pointers and raw pointers can be mixed seamlessly. - Missing constructors for the smart pointers is no longer a problem and so separate factory type functions do not have to be written and wrapped. - The implicit C++ shared_ptr< derived class > to shared_ptr< base class > cast also works in the target language. This negates the necessity to write an explicit helper cast function providing the upcast which would need calling prior to passing a derived class to a method taking a shared_ptr to a base class. 02/09/2008: wsfulton [Python] Add support for overriding the class registration function via a new "smartptr" feature. This is a very low level of customisation most users would never need to know. The feature will typically be used for intrusive smart pointers along with additional typemaps. Example usage of the feature: %feature("smartptr", noblock=1) Foo { boost::shared_ptr< Foo > } class Foo {}; The generated Foo_swigregister function will then register boost::shared < Foo > (SWIGTYPE_p_boost__shared_ptrTFoo_t instead of SWIGTYPE_p_Foo) as the underlying type for instantiations of Foo. 02/09/2008: wsfulton Features now supports the optional 'noblock' attribute for all usage of %feature. When specified, the { } braces are removed from the feature code. This is identical in behaviour to usage of 'noblock' in typemaps and is used when the preprocessor is required to operate on the code in the feature and the enclosing { } braces are not required. Example: #define FOO foo %feature("smartptr", noblock="1") { FOO::bar } The preprocessor then reduces this as if this had been used instead: %feature("smartptr") "foo::bar" 02/01/2008: olly [Python] Fix format string bug (SF#1882220). 01/31/2008: wsfulton Additions to the %types directive. Now the conversion / casting code can be overridden to some custom code in the %types directive, like so: %types(fromtype = totype) %{ ... code to convert fromtype to totype and return ... %} The special variable $from will be replaced by the name of the parameter of the type being converted from. The code must return the totype cast to void *. Example: class Time; class Date; Date &Time::dateFromTime(); %types(Time = Date) %{ Time *t = (Time *)$from; Date &d = t->dateFromTime(); return (void *) &d; %} resulting in the conversion / casting code looking something like: static void *_p_TimeTo_p_Date(void *x) { Time *t = (Time *)x; Date &d = t->dateFromTime(); return (void *) &d; } This is advanced usage, please use only if you understand the runtime type system. 01/30/2008: mgossage Small update to documentation in Typemaps.html, to warn about use of local variables in typemaps for multiple types. 01/25/2008: wsfulton [Java] Fix bug reported by Kevin Mills in ARRAYSOFCLASSES typemaps where any changes made to an array element passed from Java to C are not reflected back into Java. 01/24/2008: mgossage More updates to the configure script for detecting lua. Also looks in /usr/include/lua* Also changed typemaps.i not to check for NULL before freeing a pointer 01/21/2008: wsfulton [Python] For STL containers, SWIG no longer attempts to convert from one STL container to another, eg from std::vector to std::vector or std::list to std::vector or even std::vector to std::vector as it previously did. In fact SWIG no longer attempts to convert any SWIG wrapped C++ proxy class that is also a Python sequence, whereas previously it would. Any non-SWIG Python sequence will still be accepted wherever an STL container is accepted. Overloaded methods using containers should be faster. 01/18/2008: wsfulton [C#] Add 'directorinattributes' and 'directoroutattributes' typemap attributes for the imtype typemap. These should contain C# attributes which will be generated into the C# director delegate methods. 01/18/2008: olly Fix handling of byte value 255 in input files on platforms where char is signed (it was getting mapped to EOF). Fixes SF#1518219. 01/16/2008: wsfulton Fix template member variables wrapped by a smart pointer. Bug reported by Robert Lupton. 01/14/2008: mgossage Substantial changes to configure script for detecting lua. Code can now link to liblua.a, liblua50.a or liblua51.a It's also a lot neater now. 12/16/2007: wsfulton [Perl] Backed out #1798728 - numbers can be passed to functions taking char * 12/16/2007: wsfulton Fix #1832613 - Templates and some typedefs involving pointers or function pointers 12/12/2007: wsfulton [Java] Fix #1632625 - Compilation errors on Visual C++ 6 when using directors. 12/12/2007: wsfulton [Perl] Fix #1798728 - numbers can be passed to functions taking char *. 12/12/2007: wsfulton Fix #1819847 %template with just one default template parameter template class Foo {...}; %template(FooDefault) Foo<>; 12/12/2007: mgossage [Lua] Small correction on Lua.html 12/09/2007: wsfulton Apply patch #1838248 from Monty Taylor for vpath builds of SWIG. 12/08/2007: wsfulton [Lua] Fixes to remove gcc-4.2 warnings 12/06/2007: wsfulton Fix #1734415 - template template parameters with default arguments such as: template class t_alloc = pfc::alloc_fast > class list_t : public list_impl_t > { ... }; 12/04/2007: mgossage [lua] Fix a bug in the class hierachy code, where the methods were not propagated, if the name ordering was in a certain order. Added new example programs (dual, embed) and runtime tests for test-suite. 11/30/2007: wsfulton Fix using statements using a base class method where the methods were overloaded. Depending on the order of the using statements and method declarations, these were previously generating uncompileable wrappers, eg: struct Derived : Base { virtual void funk(); using Base::funk; }; Version 1.3.33 (November 23, 2007) ================================== 11/21/2007: mikel [allegrocl] omit private slot type info in the classes/types defined on the lisp side. Fix bug in mapping of C/++ types to lisp types. Fix typo in modules generated defpackage form. Have std::string *'s automatically marshalled between foreign and lisp strings. 11/20/2007: olly [Python] Fill in Python Dictionary functions list (patch from Jelmer Vernooij posted to swig-devel). 11/20/2007: beazley Fixed a bug in the C scanner related to backslash characters. 11/19/2007: wsfulton [Perl] Fix broken compilation of C++ wrappers on some compilers. 11/16/2007: olly [Python] Don't pass Py_ssize_t for a %d printf-like format as that's undefined behaviour when sizeof(Py_ssize_t) != sizeof(int). Version 1.3.32 (November 15, 2007) ================================== 11/14/2007: wsfulton [R] Package name and dll name is now the same as the SWIG module name. It used to be the module name with _wrap as a suffix. The package and dll names can be modified using the -package and -dll commandline options. *** POTENTIAL INCOMPATIBILITY *** 11/11/2007: wsfulton [R] Add support for Windows (Visual C++ 8 tested) 11/10/2007: olly [php] Fix makefile generated by -make (SF#1633679). Update documentation to mark "-make" as deprecated (none of the other SWIG backends seem to offer such a feature, it can't realistically generate a fully portable makefile, and the commands to build an extension are easy enough to write for the user's preferred build tool). Also recommend against the use of "-phpfull" (it's only really useful when static linking, and a dynamically loadable module is virtually always the better approach). 11/09/2007: olly Fix --help output to note that `export SWIG_FEATURES' is required. 10/29/2007: wsfulton [R] Fix seg fault on Windows [R] Examples R scripts are now platform independent 10/30/2007: mgossage [lua] fixed bug in template classes which cases template_default2 and template_specialization_defarg to fail. Added several warning filters into the overload's test cases. Added runtime tests for several codes. You can now make check-lua-test-suite with no errors and only a few warnings. 10/30/2007: olly [guile] Fix the configure test to put GUILELINK in LIBS not LDFLAGS (SF#1822430). 10/30/2007: olly [guile] Fix the guile examples on 64-bit platforms. 10/29/2007: wsfulton [C#] Fix member pointers on 64 bit platforms. 10/28/2007: olly [lua] Fix swig_lua_class instances to be static to allow multiple SWIG wrappers to be compiled into the same executable statically. Patch from Andreas Fredriksson (posted to the swig mailing list). 10/28/2007: olly [lua] Fix Examples/lua to pass SRCS for C tests rather than CXXSRCS. The code as it was happened to work on x86, but broke on x86_64 (and probably any other platforms which require -fPIC). 10/28/2007: wsfulton [Java, C#] New approach for fixing uninitialised variable usage on error in director methods using the new templated initialisation function SwigValueInit(). 10/28/2007: wsfulton [Perl] Use more efficient SvPV_nolen(x) instead of SvPV(x,PL_na) if SvPV_nolen is supported. 10/26/2007: wuzzeb [Chicken] Fix global variables of class member function pointers. Other minor fixes, so all tests in the chicken test suite now pass 10/25/2007: olly Fix UTL typecheck macro for a function taking char[] or const char[] (SF#1820132). 10/22/2007: mkoeppe [Guile] Filter out -ansi -pedantic from CFLAGS while compiling test programs for Guile in configure. This enables running the test suite for Guile if it is installed and usable. 10/22/2007: mkoeppe [Guile -scm] Fix testcases apply_signed_char and apply_strings by adding explicit casts to the appropriate $ltype. 10/22/2007: wsfulton [Java, C#] Fix uninitialised variable usage on error in director methods. 10/19/2007: wsfulton [Java, C#] Bug #1794247 - fix generated code for derived classes when csbase or javabase typemaps are used with the replace="1" attribute. 10/19/2007: wsfulton [Python] Docs updated to suggest using distutils. Patch #1796681 from Christopher Barker. 10/19/2007: olly [perl5] Clear errno before calls to strtol(), strtoul(), strtoll() and strtoull() which we check errno after to avoid seeing a junk value of errno if there isn't an error in the call. 10/16/2007: wsfulton Deprecate %attribute_ref and replace with %attributeref. There is just an argument order change in order to maintain consistency with %attribute, from: %attribute_ref(Class, AttributeType, AccessorMethod, AttributeName) to %attributeref(Class, AttributeType, AttributeName, AccessorMethod) 10/16/2007: olly [Tcl] Fix several ocurrences of "warning: deprecated conversion from string constant to 'char*'" from GCC 4.2 in generated C/C++ code. 10/16/2007: olly [PHP] Fix many occurrences of "warning: deprecated conversion from string constant to 'char*'" from GCC 4.2 in generated C/C++ code when compiling with a new enough version of PHP 5 (tested with PHP 5.2.3, but PHP 5.2.1 is probably the minimum requirement). 10/15/2007: wsfulton Patch #1797133 from David Piepgrass fixes %attribute when the getter has the same name as the attribute name and no longer generate non-functional setter for read-only attributes. 10/15/2007: olly [Tcl] Prevent SWIG_Tcl_ConvertPtr from calling the unknown proc. Add Examples/tcl/std_vector/ which this change fixes. Patch is from "Cliff C" in SF#1809819. 10/12/2007: wsfulton [Java] Add DetachCurrentThread back in for directors. See entry dated 08/11/2006 and search for DetachCurrentThread on the mailing lists for details. The crashes on Solaris seem to be only present in jdk-1.4.2 and lower (jdk-1.5.0 and jdk-1.6.0 are okay), so anyone using directors should use a recent jdk on Solaris, or define (see director.swg) SWIG_JAVA_NO_DETACH_CURRENT_THREAD to the C++ compiler to get old behaviour. 10/12/2007: wsfulton [Java] Ensure the premature garbage collection prevention parameter (pgcpp) is generated when there are C comments in the jtype and jstype typemaps. 10/12/2007: wuzzeb Added a testsuite entry for Bug #1735931 10/09/2007: olly Automatically rerun autogen.sh if configure.in is modified. 10/09/2007: olly Enhance check-%-test-suite rule and friends to give a more helpful error message if you try them for a language which doesn't exist (e.g. "make check-php-test-suite" rather than the correct "make check-php4-test-suite"). 10/09/2007: olly Add make rule to regenerate Makefile from Makefile.in if it has changed. 10/09/2007: olly [php] Fix long-standing memory leak in wrapped constructors and wrapped functions/methods which return an object. 10/08/2007: olly Fix Makefile.in to read check.list files correctly in a VPATH build. 10/07/2007: wsfulton [C#, Java] Experimental shared_ptr typemaps added 09/27/2007: mgossage [lua] added more verbose error messages for incorrect typechecks. Added a routine which checks the exact number of parameters passed to a function (breaks operator_overloading for unary minus operator, currently disabled). Reorganised the luatypemaps.swg to tidy it up. Added a lot of %ignores on the operators not supported by lua. Added support for constant member function pointers & runtest for member_pointer.i Added first version of wchar.i 09/25/2007: wsfulton [C#, Java] throws typemaps for std::wstring using C# patch #1799064 from David Piepgrass 09/24/2007: wsfulton [Tcl] Apply #1771313 to fix bug #1650229 - fixes long long and unsigned long long handling. 09/20/2007: olly [Java] Eliminate some unnecessary uses of a temporary buffer allocated using new[]. SF#1796609. 09/19/2007: wsfulton [C#] The $csinput special variable can be used in the csvarin typemap where it is always expanded to 'value'. 09/19/2007: wsfulton [C#] Fix bug reported by Glenn A Watson and #1795260 where the cstype typemap used the 'ref' keyword in the typemap body, it produced uncompilable C# properties (variable wrappers). The type for the property now correctly comes from the 'out' attribute in the cstype typemap. 09/19/2007: wsfulton [Java] Fix const std::wstring& typemaps 09/19/2007: wsfulton [Java] Ensure the premature garbage collection prevention parameter (pgcpp) is generated where a parameter is passed by pointer reference, eg in the std::vector wrappers. The pgcpp is also generated now when user's custom typemaps use a proxy class in the jstype typemap and a 'long' in the jtype typemap. 09/18/2007: olly [php] Add typemaps for handling parameters of type std::string & which are modified by the wrapped function. 09/17/2007: olly [python] Split potentially long string literals to avoid hitting MSVC's low fixed limit on string literal length - patch from SF#1723770, also reported as SF#1630855. 09/17/2007: olly [ocaml] Fix renaming of overloaded methods in the method_table - my patch from SF#940399. 09/17/2007: olly [python] Simpler code for SWIG_AsVal_bool() which fixes a "strict aliasing" warning from GCC - patch from SF#1724581 by Andrew Baumann. 09/17/2007: olly [perl5] Use sv_setpvn() to set a scalar from a pointer and length - patch from SF#174460 by "matsubaray". 09/17/2007: olly When wrapping C++ code, generate code which uses std::string::assign(PTR, LEN) rather than assigning std::string(PTR, LEN). Using assign generates more efficient code (tested with GCC 4.1.2). 09/07/2007: wsfulton Fix %ignore on constructors which are not explicitly declared [SF #1777712] 09/05/2007: wuzzeb (John Lenz) - Change r_ltype in typesys.c to store a hashtable instead of a single value. several very subtle bugs were being caused by multiple ltypes being mapped to a single mangled type, mostly when using typedefed template parameters. Now, r_ltype stores a hashtable of possible ltypes, and when generating the type table, all the ltypes are added into the swig_type_info structure. 08/31/2007: wsfulton SF #1754967 from James Bigler. - Fix bug in turning on warnings that were turned off by default. Eg 'swig -w+309' will now turn on the normally suppressed warning 309. - New -Wextra commandline option which enables the extra warning numbers: 202,309,403,512,321,322 (this is the list of warnings that have always been suppressed by default). By specifying -Wextra, all warnings will be turned on, but unlike -Wall, warnings can still be selectively turned on/off using %warnfilter, #pragma SWIG nowarn or further -w commandline options, eg: swig -Wextra -w309 will turn on all warnings except 309. 08/28/2007: wsfulton - New debugging options, -debug-module and -debug-top to display the parse tree at various stages, where is a comma separated list of stages 1-4.For example, to display top of parse tree at stages 1 and 3: swig -debug-top 1,3 - Deprecate the following options which have equivalents below: -dump_parse_module => -debug-module 1 -dump_module => -debug-module 4 -dump_parse_top => -debug-top 1 -dump_top => -debug-top 4 - Renamed some commandline options for naming consistency across all options: -debug_template => -debug-template -debug_typemap => -debug-typemap -dump_classes => -debug-classes -dump_tags => -debug-tags -dump_typedef => -debug-typedef -dump_memory => -debug-memory 08/25/2007: olly [PHP5] Fix handling of double or float parameters with an integer default value. 08/25/2007: olly [PHP5] Generate __isset() methods for setters for PHP 5.1 and later. 08/20/2007: wsfulton [Java C#] Fix director bug #1776651 reported by Stephane Routelous which occurred when the director class name is the same as the start of some other symbols used within the director class. 08/17/2007: wsfulton Correct behaviour for templated methods used with %rename or %ignore and the empty template declaration - %template(). A warning is issued if the method has not been renamed. 08/16/2007: mutandiz (Mikel Bancroft) [allegrocl] Name generated cl file based on input file rather than by module name. It was possible to end up with a mypackage.cl and a test_wrap.c when parsing a test.i input file. Confusing. Also, include external-format templates for :fat and :fat-le automatically to avoid these being compiled at runtime. 08/15/2007: efuzzyone [cffi] Apply patch #1766076 from Leigh Smith adding support for newly introduced in cffi :long-long and :unsigned-long-long. 08/10/2007: wsfulton [Java] Add documentation patch #1743573 from Jeffrey Sorensen. It contains a neat idea with respect to better memory management by the JVM of C++ allocated memory. 08/10/2007: wsfulton [Perl] Apply patch #1771410 from Wade Brainerd to fix typedef XS(SwigPerlWrapper) in perlrun.swg for ActiveState Perl build 822 and Perl 5.8.9 and 5.10 branches. 08/10/2007: wsfulton [Lua] const enum reference typemaps fixed. 08/09/2007: wsfulton [C#] Added missing support for C++ class member pointers. 08/09/2007: wsfulton [C#, Java] Add support for $owner in the "out" typemaps like in the scripting language modules. Note that $owner has always been supported in the "javaout" / "csout" typemaps. 08/01/2007: wsfulton Fix smart pointer handling for classes that have templated methods within the smart pointer type. Problem reported by craigdo at ee.washington.edu. 07/31/2007: efuzzyone [cffi] fixed memory access after being freed bug. thanks to Martin Percossi. package name clos changed to cl. thanks to Ralf Mattes 07/24/2007: wsfulton Parallel make support added for the examples and test-suite for developers who have more than one CPU. Now parallel make can be used for checking in addition to building the SWIG executable. Some typical checking examples: make -j8 -k check make -j4 check-java-test-suite make -j2 check-java-examples 07/19/2007: mgossage Fixed bug that stopped configure working on mingw (applied dos2unix to configure.in) 07/10/2007: mgossage [lua] Extra compatibility with Lua 5.1 (updated SWIG_init, docs, examples, test suite) Removed name clash for static link of multiple modules 07/05/2007: mgossage [lua] Fix a bug in SWIG_ALLOC_ARRAY() improved the error messages for incorrect arguments. Changed the output of swig_type() to use the human readable form of the type, rather than the raw swig type. 07/03/2007: wsfulton [C#] Fix directors for some overloaded methods where the imtype resulted in identical methods being generated in the C# director class, eg void foo(int *) and void foo(double *) used to generated two of these: private void SwigDirectorfoo(IntPtr p) { ... } 06/25/2007: wsfulton [Java, C#] Some parameter name changes in std_vector.i allowing better targeting of typemaps for method parameters (for memory management of containers of pointers). 06/07/2007: mutandiz (Mikel Bancroft) [allegrocl] fix foreign-type constructor to properly look for ffitype typemap bindings. fix inout_typemaps.i for strings. 06/06/2007: olly [Ruby] Use whichever of "long" or "long long" is the same size as "void*" to hold pointers as integers, rather than whichever matches off_t. Fixes compilation on OS X and GCC warnings on platforms where sizeof(void*) < sizeof(off_t) (SF patch #1731979). 06/06/2007: olly [PHP5] Fix handling of a particular case involving overloaded functions with default parameters. 06/05/2007: mutandiz (Mikel Bancroft) [allegrocl] Fix case where we'd pass fully qualified identifiers (i.e. NS1::NS2::FOO) to swig-insert-id. All namespaces should be stripped. Fix bug in TypedefHandler introduced by last fix. 06/05/2007: olly Fix reporting of filenames in errors after %include (patch from Leigh Smith in #1731040; also reported as #1699940). 05/31/2007: olly [Python] Fix "missing initialiser" warning when compiling generated C/C++ wrapper code with Python 2.5 with warnings enabled (patch from bug#1727668 from Luke Moore). 05/29/2007: olly [Python] Split docstrings into separate string literals at each newline when generating C/C++ wrapper code (the C/C++ compiler will just combine them back into a single string literal). This avoids MSVC complaining that the strings are too long (problem reported by Bo Peng on the mailing list). 05/28/2007: olly [Python] Escape backslashes in docstrings. 05/26/2007: olly [Python] Fix autodoc generation of enums to be more consistent with how the enums are wrapped - patch #1697226 from Josh Cherry. 05/26/2007: olly [PHP5] Fix wrapping of methods and functions which return a pointer to a class (bug#1700788) and those which have overloaded forms returning both classes and non-classes (bug#1712717, thanks to Simon Berthiaume for the patch). 05/25/2007: wsfulton Fixed %rename inconsistency in conversion operators as reported by Zhong Ren. The matching is now done on the operator name in the same way as it is done for parameters. For example: %rename(opABC) Space::ABC::operator ABC() const; %rename(methodABC) Space::ABC::method(ABC a) const; namespace Space { class ABC { public: void method(ABC a) const {} operator ABC() const { ABC a; return a; } }; } Note that qualifying the conversion operator previously may or may not have matched. Now it definitely won't, so this will not match: %rename(opABC) Space::ABC::operator Space::ABC() const; in the same way that this does not match: %rename(methodABC) Space::ABC::method(Space::ABC a) const; The documentation has been improved with respect to %rename, namespaces and templates. Conversion operators documentation too. *** POTENTIAL INCOMPATIBILITY *** 05/16/2007: mutandiz [allegrocl] Fix bad generation of local var ltype's in functionWrapper(). Try to work better with the backward order in which swig unrolls nested class definitions. cleaned up a little unnecessary code/debug printf's. Remove warning when replacing $ldestructor for ff:foreign-pointer 05/12/2007: olly [Python] swig -python -threads now generates C/C++ code which uses Python's own threading abstraction (from pythread.h) rather than OS specific code. The old code failed to compile on MS Windows. (See SF patch tracker #1710341). 05/04/2007: gga [Ruby] Changed STL renames to be global renames. This fixes STL functions not being renamed when autorename is on. This is a not a totally perfect work-around, but better. Someone really needs to fix the template renaming code. (See bug #1545634) 05/04/2007 gga [All] Changed %rename("%(undercase)s") a little so that single numbers at the end of a function are not undercased. That is: getSomething -> get_something get2D -> get_2d get234 -> get_234 BUT: asFloat2 -> as_float2 (Bug #1699714) 05/03/2007: gga [Ruby] Made __swigtype__ => @__swigtype__ so it can be accessed from the scripting language (and follows Ruby's official documentation, just in case). Made tracking => @__trackings__ for same reason. Currently storing ivars without the @ seems valid, but the PickAxe says this is not correct, so just in case... 05/03/2007: gga [Ruby] Applied patch for -minherit bug and exception classes. This issue should be revisited more closely, as Multiple Inheritance in Ruby is still problematic. (patch/bug #1604878) 05/03/2007: gga [Ruby] Overloaded functions in ruby will now report to the user the possible prototypes when the user mistypes the number or type of a parameter. 05/03/2007: gga [Ruby] Forgot to document the bug fixing of an old bug regarding exceptions. (bug #1458247) 05/03/2007: gga [Ruby] Fixed Ruby documentation to use the proper css styles for each section. Added autodoc section to Ruby's docs to document the features supported by Ruby in documenting its modules. Made rdoc documentation spit out the full name of the class + method name. Albeit this will make the current rdoc not recognize the method, this is still needed to disambiguate between different classes with similar methods (rdoc was created to document the ruby source which only contains one class per c file, unlike swig) I have patched rdoc to make it more friendly to swig. This patch needs to be merged in the ruby std library now. 05/03/2007: gga [Ruby] Changed flag -feature to be -init_name to better reflect its purpose and avoid confusion with -features. 05/03/2007: gga [Ruby] Improved autodoc generation. Added autodoc .swg files to Ruby library for easily adding documentation to common Ruby methods and STL methods. Fixed autodoc documenting of getters and setters and module. Made test suite always generate autodocs. 05/03/2007: gga [Ruby] Removed some warnings from STL and test suite. 05/02/2007: mgossage [Lua] Fixed issues with C++ classes and hierachies across multiple source files. Fixed imports test case & added run test. Added Examples/imports. Added typename for raw lua_State* Added documentation on native functions. 05/02/2007: gga [Ruby] Docstrings are now supported. %feature("autodoc") and %feature("docstring") are now properly supported in Ruby. These features will generate a _wrap.cxx file with rdoc comments in them. 05/02/2007: gga [Ruby] STL files have been upgraded to follow the new swig/python Lib/std conventions. This means std::vector, std::set, std::map, set::multimap, std::multiset, std::deque and std::string are now properly supported, including their iterators, support for containing ruby objects (swig::GC_VALUE) and several other ruby enhancements. std::complex, std::ios, std::iostream, std::iostreambuf and std::sstream are now also supported. std::wstring, std::wios, std::wiostream, std::wiostreambuf and std::wsstream are supported verbatim with no unicode conversion. std_vector.i now mimics the behavior of Ruby Arrays much more closely, supporting slicing, shifting, unshifting, multiple indexing and proper return values on assignment. COMPATABILITY NOTE: this changes the older api a little bit in that improper indexing would previously (incorrectly) raise exceptions. Now, nil is returned instead, following ruby's standard Array behavior. 05/02/2007: gga [Ruby] Changed the value of SWIG_TYPECHECK_BOOL to be 10000 (ie. higher than that of all integers). This is because Ruby allows typecasting integers down to booleans which can make overloaded functions on bools and integers to fail. (bug# 1488142) 05/02/2007: gga [Ruby] Fixed a subtle bug in multiple argouts that could get triggered if the user returned two or more arguments and the first one was an array. 05/01/2007: gga [Ruby] Improved the documentation to document the new features added, add directorin/out/argout typemaps, etc. 05/01/2007: gga [Ruby] Added %initstack and %ignorestack directives for director functions. These allow you to control whether a director function should re-init the Ruby stack. This is sometimes needed for an embedded Ruby where the director method is used as a C++ callback and not called by the user from ruby code. Explanation: Ruby's GC needs to be aware of the running OS stack in order to mark any VALUE (Ruby objects) it finds there to avoid collection of them. This allows the ruby API to be very simple and allows you to write code like "VALUE a = sth" anywhere without needing to do things like refcounting like python. By default, the start of the stack is set when ruby_init() is called. If ruby is inited within main(), as it usually is the case with the main ruby executable, ruby will be able to calculate its stack properly. However, when this is not possible, as when ruby is embedded as a plugin to an application where main is not available, ruby_init() will be called in the wrong place, and ruby will be incorrectly tracking the stack from the function that called ruby_init() forwards only, which can lead to all sorts of weird crashes or to ruby thinking it has run out of stack space incorrectly. To avoid this, director (callback) functions can now be tagged to try to reset the ruby stack, which will solve the issues. NOTE: ruby1.8.6 still contains a bug in it in that its function to reset the stack will not always do so. This bug is triggered very rarely, when ruby is called from two very distinct places in memory, like a branch of main() and another dso. This bug has now been reported to ruby-core and is pending further investigation. (bug #1700535 and patch #1702907) 04/30/2007: wsfulton Fix #1707582 - Restore building from read-only source directories. 04/30/2007: gga [Ruby] Ruby will now report the parameter index properly on type errors as well as the class and value of the incorrect argument passed. (feature request #1699670) 04/30/2007: gga [Ruby] Ruby no longer creates the free_Class function if the class contains its own user defined free function (%freefunc). (bug #1702882) 04/30/2007: gga [Ruby] Made directors raise a ruby exception for incorrect argout returned values if RUBY_EMBEDDED is set, instead of throwing an actual SwigDirector exception. This will prevent crashes when ruby is embedded and unaware of the SwigDirector exception. 04/30/2007: gga [Ruby] Removed the need for -DSWIGEXTERN. Changed swig_ruby_trackings to be a static variable, but also be kept within a hidden instance variable in the SWIG module. This allows properly dealing with trackings across multiple DSOs, which was previously broken. (bug #1700535 and improvement to patch #1702907) 04/29/2007: gga [Ruby] Fixed GC memory issues with trackings that could lead to segfaults when dealing, mainly, with static variables. (bug #1700535 and patch #1702907) 04/29/2007: gga [Ruby] Fixed String conversion using old ruby1.6 macros. Now StringValuePtr() is used if available. This removes warnings when converting strings with \0 in them. (bug #1700535 and patch #1702907) 04/29/2007: gga [Ruby] Fixed the argout count in directors for Ruby. Previously, ignored or "numinputs=0" typemaps would incorrectly not get counted towards the argout count. (bug/patch #1545585) 04/29/2007: gga [Ruby] Upgraded Ruby converter to recognize "numinputs=0". Previously, only the old "ignore" flag was checked (which would currently still work properly, but is deprecated). 04/29/2007: gga [Ruby - but should be made generic] %feature("numoutputs","0") added. This feature allows you to ignore the output of a function so that it is not added to a list of output values ( ie. argouts ). This should also become a feature of %typemap(directorout) as "numoutputs"=0, just like "numinputs"=0 exists. %feature("directors"=1) %include %feature("numoutputs","0") { Class::member_function1 }; %typemap(out) MStatus { // some code, like check mstatus // and raise exception if wrong }; %inline %{ typedef int MStatus; class Class { // one argument returned, but director out code added // MStatus is discarded as a return (out) parameter. virtual MStatus member_function1( int& OUTPUT ); // two arguments returned, director out code added // MStatus is not discarded virtual MStatus member_function2( int& OUTPUT ); }; %} 04/21/2007: olly Fix parsing of float constants with an exponent (e.g. 1e-02f) (bug #1699646). 04/20/2007: olly [Python] Fix lack of generation of docstrings when -O is used. Also, fix generation of docstrings containing a double quote character. Patch from Richard Boulton in bug#1700146. 04/17/2007: wsfulton [Java, C#] Support for adding in Java/C# code before and after the intermediary call, specifically related to the marshalling of the proxy type to the intermediary type. The javain/csin typemap now supports the 'pre' and 'post' attributes to achieve this. The javain typemap also supports an optional 'pgcppname' attribute for premature garbage collection prevention parameter naming and the csin typemap supports an optional 'cshin' attribute for the parameter type used in a constructor helper generated when the type is used in a constructor. Details in the Java.html and CSharp.html documentation. 04/16/2007: olly Don't treat `restrict' as a reserved identifier in C++ mode (bug#1685534). 04/16/2007: olly [PHP5] Fix how zend_throw_exception() is called (bug #1700785). 04/10/2007: olly Define SWIGTEMPLATEDISAMBIGUATOR to template for aCC (reported on swig-user that this is needed). 04/04/2007: olly [PHP5] If ZTS is enabled, release _globals_id in MSHUTDOWN to avoid PHP interpreter crash on shutdown. This solution was suggested here: http://bugs.php.net/bug.php?id=40985 04/03/2007: olly [PHP4] Add missing ZTS annotations to generated C++ wrapper code to fix compilation failures when using ZTS enabled SWIG (Linux distributions tend to disable ZTS, but notably the Windows build uses it by default). 04/01/2007: efuzzyone [CFFI] Patch #1684261: fixes handling of unsigned int literals, thanks Leigh Smith. Also, improved documentation. 03/30/2007: olly Avoid generating '<:' token when using SwigValueWrapper<> on a type which starts with '::' (patch #1690948). 03/25/2007: wuzzeb (John Lenz) [perl5] Add SWIG_fail to the SWIG_exception macro. Fixes a few problems reported on the mailing list. 03/23/2007: wsfulton String copying patch from Josh Cherry reducing memory consumption by about 25%. 03/21/2007: wsfulton [Java] Apply patch #1631987 from Ulrik Peterson - bool INOUT typemaps fail on big endian machines. 03/16/2007: wsfulton Fix seg fault given dodgy C++ code: namespace abc::def { } 03/16/2007: wsfulton [Java] Fixes so that ARRAYSOFCLASSES and ARRAYSOFENUMS in arrays_java.i can be applied to pointer types. 03/03/2007: olly [PHP5] When we know the literal numeric value for a constant, use that to initialise the const member in the PHP wrapper class. 03/02/2007: olly [PHP5] Fix PHP wrapper code generated for certain cases of overloaded forms with default arguments. 02/26/2007: efuzzyone [CFFI] Patch #1656395: fixed hex and octal values bug, thanks to Arthur Smyles. 02/22/2007: mgossage [Lua] Fixed bug in typemaps which caused derived_byvalue and rname test cases to fail. Updated derived_byvalue.i to explain how to find and fix the problem 01/25/2007: wsfulton Fix #1538522 and #1338527, forward templated class declarations without a name for the templated class parameters, such as: template class X; 01/23/2007: mgossage [Lua] Patch #1640862: replaced by Patch #1598063 Typo in typemaps.i 01/22/2007: mgossage [Lua] Added a lua specific carrays.i which adds the operator[] support. modified the main code to make it not emit all the class member functions & accessors Note: C structs are created using new_XXX() while C++ classes use XXX() (should be standardised) Updated test case: li_carrays Updated the documentation. 01/12/2007: wsfulton [Php] Add support for newfree typemaps (sometimes used by %newobject) 01/12/2007: beazley New command line option -macroerrors. When supplied, this will force the C scanner/parser to report proper location information for code contained inside SWIG macros (defined with %define). By default, SWIG merely reports errors on the line at which a macro is used. With this option, you can expand the error back to its source---something which may simplify debugging. 01/12/2007: beazley [Internals] Major overhaul of C/C++ scanning implementation. For quite some time, SWIG contained two completely independent C/C++ tokenizers-- the legacy scanner in CParse/cscanner.c and a general purpose scanner in Swig/scanner.c. SWIG still has two scanning modules, but the C parser scanner (CParse/cscanner.c) now relies upon the general purpose scanner found in Swig/scanner.c. As a result, it is much smaller and less complicated. This change also makes it possible to maintain all of the low-level C tokenizing in one central location instead of two places as before. ***POTENTIAL FLAKINESS*** This change may cause problems with accurate line number reporting as well as error reporting more generally. I have tried to resolve this as much as possible, but there might be some corner cases. 01/12/2007: mgossage [Lua] Added typemap throws for std::string*, typemap for SWIGTYPE DYNAMIC, changed the existing throws typemap to throw a string instead of making a copy of the object (updating a few test cases to deal with the change). fixed test case: dynamic_casts, exception_partial_info, li_std_string, size_t 01/03/2007: beazley [Internals]. Use of swigkeys.c/.h variables is revoked. Please use simple strings for attribute names. 12/30/2006: beazley Internal API functions HashGetAttr() and HashCheckAttr() have been revoked. Please use Getattr() to retrieve attributes. The function Checkattr() can be used to check attributes. Note: These functions have been revoked because they only added a marginal performance improvement at the expense code clarity. 12/26/2006: mgossage [Lua] Added more STL (more exceptions, map, size_t), fixed test case: conversion_ns_template. 12/21/2006: mgossage [Lua] Update to throw errors when setting immutables, and allowing user addition of module variables. 12/20/2006: wsfulton Fix typedef'd variable wrappers that use %naturalvar, eg, std::string. 12/14/2006: wsfulton [C#] Add std::wstring and wchar_t typemaps 12/14/2006: olly [php] Fix bug #1613673 (bad PHP5 code generated for getters and setters). 12/02/2006: wsfulton, John Lenz, Dave Beazley Move from cvs to Subversion for source control 11/30/2006: beazley Cleaned up swigwarnings.swg file not to use nested macro definitions. 11/12/2006: wsfulton [Java, C#] Fix for %extend to work for static member variables. Version 1.3.31 (November 20, 2006) ================================== 11/12/2006: Luigi Ballabio [Python] Alternate fix for Python exceptions bug #1578346 (the previous one broke Python properties in modern classes) 11/12/2006: wsfulton -fakeversion commandline option now generates the fake version into the generated wrappers as well as displaying it when the -version commandline option is used. 14/11/2006: mgossage [lua] update to typemap for object by value, to make it c89 compliant Version 1.3.30 (November 13, 2006) ================================== 11/12/2006: wsfulton [java] Remove DetachCurrentThread patch from 08/11/2006 - it causes segfaults on some systems. 11/12/2006: wsfulton [python] Fix #1578346 - Python exceptions with -modern 11/10/2006: wsfulton Fix #1593291 - Smart pointers and inheriting from templates 11/09/2006: wsfulton Fix director operator pointer/reference casts - #1592173. 11/07/2006: wsfulton Add $self special variable for %extend methods. Please use this instead of just 'self' as the C++ 'this' pointer. 11/07/2006: mutandiz [allegrocl] allegrocl.swg: swig-defvar updated to allow specifying of non-default foreign type (via :ftype keyword arg). allegrocl.cxx: Specify proper access type for enum values. 11/03/2006: wsfulton [Java/C#] Fix const std::string& return types for directors as reported by Mark Donselzmann 10/29/2006: wsfulton [Java] Remove DeleteLocalRef from end of director methods for now as it is causing a seg fault when run on Solaris 8. 10/29/2006: wuzzeb (John Lenz) [Guile] Patch from Chris Shoemaker to clean up some warnings in the generated code. 10/29/2006: wsfulton [Java] Important fix to prevent early garbage collection of the Java proxy class while it is being used in a native method. The finalizer could destroy the underlying C++ object while it was being used. The problem occurs when the proxy class is no longer strongly reachable after a native call. The problem seems to occur in memory stress situations on some JVMs. It does not seem to occur on the Sun client JVM up to jdk 1.5. However the 1.6 client jdk has a more aggressive garbage collector and so the problem does occur. It does occur on the Sun server JVMs (certainly 1.4 onwards). The fix entails passing the proxy class into the native method in addition to the C++ pointer in the long parameter, as Java classes are not collected when they are passed into JNI methods. The extra parameter can be suppressed by setting the nopgcpp attribute in the jtype typemap to "1" or using the new -nopgcpp commandline option. See Java.html#java_pgcpp for further details on this topic. 10/24/2006: wsfulton [C#] Fix smart pointer wrappers. The virtual/override/new keyword is not generated for each method as the smart pointer class does not mirror the underlying pointer class inheritance hierarchy. SF #1496535 10/24/2006: mgossage [lua] added support for native methods & member function pointers. fixed test cases arrays_dimensionless & cpp_basic. Added new example (functor). tidied up a little of the code (around classHandler). 10/17/2006: wsfulton [C#, Java] directorout typemap changes to fall in line with the other director languages. $result is now used where $1 used to be used. Please change your typemaps if you have a custom directorout typemap. 10/18/2006: wsfulton Some fixes for applying the char array typemaps to unsigned char arrays. 10/17/2006: wsfulton [C#, Java] Add in const size_t& and const std::size_t& typemaps. 10/15/2006: efuzzyone [CFFI] Suppress generating defctype for enums, thanks to Arthur Smyles. Patch 1560983. 10/14/2006: wuzzeb (John Lenz) [Chicken] Minor fix to make SWIG work with the (as yet unreleased) chicken 2.5 [Guile,Chicken] Fix SF Bug 1573892. Added an ext_test to the test suite to test this bug, but this test can not really be made generic because the external code must plug into the target language interpreter directly. See Examples/test-suite/chicken/ext_test.i and ext_test_external.cxx Added a %.externaltest to common.mk, and any interested language modules can copy and slightly modify either the chicken or the guile ext_test.i 10/14/2006: mgossage [Lua] added OUTPUT& for all number types, added a long long type fixed several test cases. update: changed typemaps to use SWIG_ConvertPtr rather than SWIG_MustGetPointer started spliting lua.swg into smaller parts to make it neater 10/13/2006: wsfulton [C#, Java] Marginally better support for multiple inheritance only in that you can control what the base class is. This is done using the new 'replace' attribute in the javabase/csbase typemap, eg in the following, 'Me' will be the base class, no matter what Foo is really derived from in the C++ layer. %typemap(javabase, replace="1") Foo "Me"; %typemap(csbase, replace="1") Foo "Me"; Previously it was not possible for the javabase/csbase typemaps to override the C++ base. 10/12/2006: wsfulton [Java] Remove potential race condition on the proxy class' delete() method (it is now a synchronized method, but is now customisable by changing the methodmodifiers attribute in the javadestruct or javadestruct_derived typemap) [C#] Remove potential race condition on the proxy class' Dispose() method, similar to Java's delete() above. *** POTENTIAL INCOMPATIBILITY *** 10/12/2006: wsfulton [Ruby, Python] Remove redundant director code in %extend methods (%extend methods cannot be director methods) 10/12/2006: wsfulton [Ruby, Python] Fix #1505594 - director objects not returned as director objects in %extend methods. 10/11/2006: wsfulton [Java] Fix #1238798 - Directors using unsigned long long or any other type marshalled across the JNI boundary using a Java class (where the jni typemap contains jobject). 10/06/2006: wsfulton Fix #1162194 - #include/%include within a structure 10/06/2006: wsfulton Fix #1450661, string truncation in String_seek truncating Java/C# enums. 10/06/2006: mgossage [Lua] Fix #1569587. The name is now correct. 10/04/2006: wsfulton Director fixes for virtual conversion operators 10/04/2006: olly [php] Fix #1569587 for PHP. Don't use sizeof() except with string literals. Change some "//" comments to "/* */" for portability. 10/04/2006: mgossage [Lua] Partial Fix #1569587. The type is now correct, but the name is still not correct. 10/03/2006: wsfulton [Ruby] Fix #1527885 - Overloaded director virtual methods sometimes produced uncompileable code when used with the director:except feature. 10/03/2006: wsfulton Directors: Directors are output in the order in which they are declared in the C++ class rather than in some pseudo-random order. 10/03/2006: mmatus Fix #1486281 and #1471039. 10/03/2006: olly [Perl] Fix for handling strings with zero bytes from Stephen Hutsal. 09/30/2006: efuzzyone [CFFI] Bitfield support and vararg support due to Arthur Smyles. C expression to Lisp conversion, thanks to Arthur Smyles for the initial idea, it now supports conversion for a whole range of C expressions. 09/28/2006: wsfulton Fix #1508327 - Overloaded methods are hidden when using -fvirtual optimisation. Overloaded methods are no longer candidates for elimination - this mimics C++ behaviour where all overloaded methods must be defined and implemented in a derived class in order for them to be available. 09/25/2006: wsfulton [Ruby, Python, Ocaml] Fix #1505591 Throwing exceptions in extended directors 09/25/2006: wsfulton Fix #1056100 - virtual operators. 09/24/2006: olly Don't accidentally create a "<:" token (which is the same as "[" in C++). Fixes bug # 1521788. 09/23/2006: olly [Ruby] Support building with recent versions of the Ruby 1.9 development branch. Fixes bug #1560092. 09/23/2006: olly Templates can now be instantiated using negative numbers and constant expressions, e.g.: template class x {}; %template(x_minus1) x<-1>; %template(x_1plus2) x<1+2>; Also, constant expressions can now include comparisons (>, <, >=, <=, !=, ==), modulus (%), and ternary conditionals (a ? b : c). Fixes bugs #646275, #925555, #956282, #994301. 09/22/2006: wsfulton Fix %ignore on director methods - Bugs #1546254, #1543533 09/20/2006: wsfulton Fix %ignore on director constructors 09/20/2006: wsfulton Fix seg faults and asserts when director methods are ignored (#1543533) 09/20/2006: wsfulton Fix out of source builds - bug #1544718 09/20/2006: olly Treat a nested class definition as a forward declaration rather than ignoring it completely, so that we generate correct code for passing opaque pointers to the nested class (fixes SF bug #909387). 09/20/2006: olly *** POTENTIAL INCOMPATIBILITY *** [php] Overload resolution now works. However to allow this, SWIG generated wrappers no longer coerce PHP types (which reverts a change made in 1.3.26). So for example, if a method takes a string, you can no longer pass a number without explicitly converting it to a string in PHP using: (string)x 09/18/2006: mgossage [ALL] fix on swiginit.swg, has been reported to crash on several test cases found and fixed problem in imports under python (mingw) 09/16/2006: wsfulton [Python] Patch from Michal Marek for Python 2.5 to fix 64 bit array indexes on 64 bit machines. 09/13/2006: wsfulton The explicitcall feature has been scrapped. This feature was introduced primarily to solve recursive director method calls. Director upcall improvements made instead: [Python, Ruby, Ocaml] The swig_up flag is no longer used. The required mutexes wrapping this flag are also no longer needed. The recursive calls going from C++ to the target language and back again etc are now avoided by a subtlely different approach. Instead of using the swig_up flag in each director method to indicate whether the explicit C++ call to the appropriate base class method or a normal polymorphic C++ call should be made, the new approach makes one of these calls directly from the wrapper method. [Java, C#] The recursive call problem when calling a C++ base class method from Java/C# is now fixed. The implementation is slightly different to the other languages as the detection as to whether the explicit call or a normal polymorphic call is made in the Java/C# layer rather than in the C++ layer. 09/11/2006: mgossage [ALL] updated swiginit.swg to allow multiple interpreters to use multiple swig modules at once. This has been tested in Lua (mingw & linux), perl5 & python (linux) only. 09/11/2006: mgossage [lua] added support for passing function pointers as well as native lua object into wrappered function. Added example funcptr3 to demonstrate this feature 09/05/2006: olly [php] Rename ErrorCode and ErrorMsg #define-s to SWIG_ErrorCode and SWIG_ErrorMsg to avoid clashes with code the user might be wrapping (patch from Darren Warner in SF bug #1466086). Any user typemaps which use ErrorCode and/or ErrorMsg directly will need adjusting - you can easily fix them to work with both old and new SWIG by changing to use SWIG_ErrorMsg and adding: #ifndef SWIG_ErrorMsg #define SWIG_ErrorMsg() ErrorMsg() #endif 08/29/2006: olly [php] Move constant initialisation from RINIT to MINIT to fix a warning when using Apache and mod_php. We only need to create PHP constants once when we're first initialised, not for every HTTP request. 08/21/2006: mgossage [Lua] Bugfix #1542466 added code to allow mapping Lua nil's <-> C/C++ NULL's updated various typemaps to work correctly with the changes added voidtest_runme.lua to show the features working 08/19/2006: wuzzeb (John Lenz) [Guile] Add feature:constasvar to export constants as variables instead of functions that return the constant value. 08/11/2006: wsfulton [Java] DetachCurrentThread calls have been added so that natively created threads no longer prevent the JVM from exiting. Bug reported by Thomas Dudziak and Paul Noll. 08/10/2006: wsfulton [C#] Fix director protected methods so they work 07/25/2006: mutandiz [allegrocl] more additions to std::string, some tweaks and small bug fixes -nocwrap mode. 07/21/2006: mgossage [Lua] Bugfix #1526022 pdated std::string to support strings with '\0' inside them updated typemaps.i to add support for pointer to pointers 07/19/2006: mutandiz [allegrocl] - Add std_string.i support. - Add newobject patch submitted by mkoeppe (thanks!) - Fix type name mismatch issue for nested type definitions. specifically typedefs in templated class defns. 07/18/2006: mgossage Bugfix #1522858 updated lua.cxx to support -external-runtime command 07/14/2006: wuzzeb (John Lenz) Increment the SWIG_RUNTIME_VERSION to 3, because of the addition of the owndata member in swig_type_info. Reported by: Prabhu Ramachandran 07/05/2006: wsfulton Search path fixes: - Fix search path for library files to behave as documented in Library.html. - Fix mingw/msys builds which did not find the SWIG library when installed. - Windows builds also output the mingw/msys install location when running swig -swiglib. - The non-existent and undocumented config directory in the search path has been removed. 07/05/2006: wsfulton Fix $symname special variable expansion. 07/04/2006: wuzzeb (John Lenz) [Chicken] Add %feature("constasvar"), which instead of exporting a constant as a scheme function, exports the constant as a scheme variable. Update the documentation as well. 07/04/2006: wsfulton [See entry of 09/13/2006 - explicitcall feature and documentation to it removed] New explicitcall feature which generates additional wrappers for virtual methods that call the method explicitly, not relying on polymorphism to make the method call. The feature is a feature flag and is enabled like any other feature flag. It also recognises an attribute, "suffix" for mangling the feature name, see SWIGPlus.html#SWIGPlus_explicitcall documentation for more details. [Java, C#] The explicitcall feature is also a workaround for solving the recursive calls problem when a director method makes a call to a base class method. See Java.html#java_directors_explicitcall for updated documentation. 06/28/2006: joe (Joseph Wang) [r] Initial support for R 06/20/2006: wuzzeb (John Lenz) [Chicken] Minor fixes to get apply_strings.i testsuite to pass Remove integers_runme.scm from the testsuite, because SWIG and Chicken does handle overflows. 06/19/2005: olly [php] Add support for generating PHP5 class wrappers for C++ classes (use "swig -php5"). 06/17/2006: olly [php] Added some missing keywords to the PHP4 keyword list, and fixed __LINE__ and __FILE__ which were in the wrong category. Also added all the keywords new in PHP5, and added comments noting the PHP4 keywords which aren't keywords in PHP5. 06/17/2006: olly [php] Don't segfault if PHP Null is passed as this pointer (e.g. Class_method(Null)) - give a PHP Error instead. 06/15/2006: mutandiz [allegrocl] Add initial support for std::list container class. Fix a few bugs in helper functions. 05/13/2006: wsfulton [Java] Replace JNIEXPORT with SWIGEXPORT, thereby enabling the possibility of using gcc -fvisibility=hidden for potentially smaller faster loading wrappers. 05/13/2006: wsfulton Fix for Makefiles for autoconf-2.60 beta 05/13/2006: wsfulton Vladimir Menshakov patch for compiling wrappers with python-2.5 alpha. 05/12/2006: wsfulton Fix buffer overflow error when using large %feature(docstring) reported by Joseph Winston. 05/12/2006: wsfulton [Perl] Operator overload fix from Daniel Moore. 05/25/2006: mutandiz [allegrocl] Fix bug in generation of CLOS type declarations for unions and equivalent types. 05/24/2006: mutandiz [allegrocl] Don't require a full class definition to generate a CLOS wrapper. 05/20/2006: olly [php] GCC Visibility support now works with PHP. 05/19/2006: olly [php] Removed support for -dlname (use -module instead). Fixed naming of PHP extension module to be consistent with PHP conventions (no "php_" prefix on Unix; on PHP >= 4.3.0, handle Unix platforms which use something other than ".so" as the extension.) 05/13/2006: wsfulton [C#] Director support added 05/07/2006: olly [php] Don't segfault if PHP Null is passed where a C++ reference is wanted. 05/05/2006: olly [php] Fix wrappers generated for global 'char' variables to not include a terminating zero byte in the PHP string. 05/03/2006: wsfulton Modify typemaps so that char * can be applied to unsigned char * or signed char * types and visa versa. 05/03/2006: efuzzyone [cffi]Thanks to Luke J Crook for this idea. - a struct/enum/union is replaced with :pointer only if that slot is actually a pointer to that type. So,: struct a_struct { int x; } and struct b_struct { a_struct struct_1; }; will be converted as: (cffi:defcstruct b_struct (struct_1 a_struct)) - Other minor fixes in lispifying names. 05/02/2006: wsfulton Fix possible redefinition of _CRT_SECURE_NO_DEPRECATE for VC++. 04/14/2006: efuzzyone [cffi] Thanks to Thomas Weidner for the patch. - when feature export is set (export 'foo) is generated for every symbol - when feature inline is set (declaim (inline foo)) is generated before every function definition - when feature intern_function is set #.(value-of-intern-function "name" "nodeType" package) is emitted instead of the plain symbol. A sample swig-lispify is provided. - every symbol is prefixed by it's package. 04/13/2006: efuzzyone [cffi] Fixed the generation of wrappers for global variables. Added the option [no]swig-lisp which turns on/off generation of code for swig helper lisp macro, functions, etc. Version 1.3.29 (March 21, 2006) =============================== 04/05/2006: mutandiz [allegrocl] Fix output typemap of char so it produces a character instead of an integer. Also adds input/output typemaps for 'char *'. add command-line argument -isolate to generate an interface file that won't interfere with other SWIG generated files that may be used in the same application. 03/20/2005: mutandiz [allegrocl] More tweaks to INPUT/OUTPUT typemaps for bool. Fix constantWrapper for char and string literals. find-definition keybindings should work in ELI/SLIME. Output (in-package ) to lisp wrapper instead of (in-package #.*swig-module-name*). slight rework of multiple return values. doc updates. 03/17/2005: mutandiz [allegrocl] mangle names of constants generated via constantWrapper. When using OUTPUT typemaps and the function has a non-void return value, it should be first in the values-list, followed by the OUTPUT mapped values. Fix bug with boolean parameters, which needed to be passed in as int values, rather than T or NIL. 03/15/2006: mutandiz [allegrocl] Generate wrappers for constants when in C++ or -cwrap mode. Make -cwrap the default, since it is most correct. Users can use the -nocwrap option to avoid the creation of a .cxx file when interfacing to C code. When in -nocwrap mode, improve the handling of converting infix literals to prefix notation for lisp. This is very basic and not likely to be improved upon since this only applies to the -nocwrap case. Literals we can't figure out will result in a warning and be included in the generated code. validIdentifier now more closely approximates what may be a legal common lisp symbol. Fix typemap error in allegrocl.swg 03/12/2006: mutandiz [allegrocl] fix up INPUT/OUTPUT typemaps for bool. Generate c++ style wrapper functions for struct/union members when -cwrap option specified. 03/10/2006: mutandiz [allegrocl] Fix bug in C wrapper generation introduced by last allegrocl commit. 03/10/2006: wsfulton [Java] Commit #1447337 - Delete LocalRefs at the end of director methods to fix potential leak 03/10/2006: wsfulton Fix #1444949 - configure does not honor --program-prefix. Removed non-standard configure option --with-release-suffix. Fix the autoconf standard options --program-prefix and --program-suffix which were being shown in the help, but were being ignored. Use --program-suffix instead of --with-release-suffix now. 03/10/2006: wsfulton [Java] Fix #1446319 with patch from andreasth - more than one wstring parameter in director methods 03/07/2006: mkoeppe [Guile] Fix for module names containing a "-" in non-"shadow" mode. Patch from Aaron VanDevender (#1441474). 03/04/2006: mmatus - Add -O to the main program, which now enables -fastdispatch [Python] - Add the -fastinit option to enable faster __init__ methods. Setting 'this' as 'self.this.append(this)' in the python code confuses PyLucene. Now the initialization is done in the the C++ side, as reported by Andi and Robin. - Add the -fastquery option to enable faster SWIG_TypeQuery via a python dict cache, as proposed by Andi Vajda - Avoid to call PyObject_GetAttr inside SWIG_Python_GetSwigThis, since this confuses PyLucene, as reported by Andi Vajda. 03/02/2006: wsfulton [Java] Removed extra (void *) cast when casting pointers to and from jlong as this was suppressing gcc's "dereferencing type-punned pointer will break strict-aliasing rules" warning. This warning could be ignored in versions of gcc prior to 4.0, but now the warning is useful as gcc -O2 and higher optimisation levels includes -fstrict-aliasing which generates code that doesn't work with these casts. The assignment is simply never made. Please use -fno-strict-aliasing to both suppress the warning and fix the bad assembly code generated. Note that the warning is only generated by the C compiler, but not the C++ compiler, yet the C++ compiler will also generate broken code. Alternatively use -Wno-strict-aliasing to suppress the warning for gcc-3.x. The typemaps affected are the "in" and "out" typemaps in java.swg and arrays_java.swg. Users ought to fix their own typemaps to do the same. Note that removal of the void * cast simply prevents suppression of the warning for the C compiler and nothing else. Typical change: From: %typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)(void *)&$input; %} To: %typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %} From: %typemap(out) SWIGTYPE * %{ *($&1_ltype)(void *)&$result = $1; %} To: %typemap(out) SWIGTYPE * %{ *($&1_ltype)&$result = $1; %} 03/02/2006: mkoeppe [Guile -scm] Add typemaps for "long long"; whether the generated code compiles, however, depends on the version and configuration of Guile. 03/02/2006: wsfulton [C#] Add support for inner exceptions. If any of the delegates are called which construct a pending exception and there is already a pending exception, it will create the new exception with the pending exception as an inner exception. 03/02/2006: wsfulton [Php] Added support for Php5 exceptions if compiling against Php5 (patch from Olly Betts). 03/01/2006: mmatus Use the GCC visibility attribute in SWIGEXPORT. Now you can compile (with gcc 3.4 or later) using CFLAGS="-fvisibility=hidden". Check the difference for the 'std_containers.i' python test case: Sizes: 3305432 _std_containers.so 2383992 _std_containers.so.hidden Exported symbols (nm -D .so | wc -l): 6146 _std_containers.so 174 _std_containers.so.hidden Execution times: real 0m0.050s user 0m0.039s sys 0m0.005s _std_containers.so real 0m0.039s user 0m0.026s sys 0m0.007s _std_containers.so.hidden Read http://gcc.gnu.org/wiki/Visibility for more details. 02/27/2006: mutandiz [allegrocl] Add support for INPUT, OUTPUT, and INOUT typemaps. For OUTPUT variables, the lisp wrapper returns multiple values. 02/26/2006: mmatus [Ruby] add argcargv.i library file. Use it as follow: %include argcargv.i %apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) } %inline { int mainApp(size_t argc, const char **argv) { return argc; } } then in the ruby side: args = ["asdf", "asdf2"] n = mainApp(args); This is the similar to the python version Lib/python/argcargv.i 02/24/2006: mgossage Small update Lua documents on troubleshooting problems 02/22/2006: mmatus Fix all the errors reported for 1.3.28. - fix bug #1158178 - fix bug #1060789 - fix bug #1263457 - fix 'const char*&' typemap in the UTL, reported by Geoff Hutchison - fixes for python 2.1 and the runtime library - fix copyctor + template bug #1432125 - fix [ 1432152 ] %rename friend operators in namespace - fix gcc warning reported by R. Bernstein - avoid assert when finding a recursive scope inheritance, emit a warning in the worst case, reported by Nitro - fix premature object deletion reported by Paul in tcl3d - fix warning reported by Nitro in VC7 - more fixes for old Solaris compiler - fix for python 2.3 and gc_refs issue reported by Luigi - fix fastproxy for methods using kwargs - fix overload + protected member issue reported by Colin McDonald - fix seterrormsg as reported by Colin McDonald - fix directors, now the test-suite runs again using -directors - fix for friend operator and Visual studio and bug 1432152 - fix bug #1435090 - fix using + %extend as reported by William - fix bug #1094964 - fix for Py_NotImplemented as reported by Olly and Amaury - fix nested namespace issue reported by Charlie and also: - allow director protected members by default - delete extra new lines in swigmacros[UTL] - cosmetic for generated python code - add the factory.i library for UTL - add swigregister proxy method and move __repr__ to a single global module [python] 02/22/2006: mmatus When using directors, now swig will emit all the virtual protected methods by default. In previous releases, you needed to use the 'dirprot' option to achieve the same. If you want, you can disable the new default behaviour, use the 'nodirprot' option: swig -nodirprot ... and/or the %nodirector feature for specific methods, i.e.: %nodirector Foo::bar; struct Foo { virtual ~Foo(); protected: virtual void bar(); }; As before, pure abstract protected members are allways emitted, independent of the 'dirprot/nodirprot' options. 02/22/2006: mmatus Add the factory.i library for languages using the UTL (python,tcl,ruby,perl). factory.i implements a more natural wrap for factory methods. For example, if you have: ---- geometry.h -------- struct Geometry { enum GeomType{ POINT, CIRCLE }; virtual ~Geometry() {} virtual int draw() = 0; // // Factory method for all the Geometry objects // static Geometry *create(GeomType i); }; struct Point : Geometry { int draw() { return 1; } double width() { return 1.0; } }; struct Circle : Geometry { int draw() { return 2; } double radius() { return 1.5; } }; // // Factory method for all the Geometry objects // Geometry *Geometry::create(GeomType type) { switch (type) { case POINT: return new Point(); case CIRCLE: return new Circle(); default: return 0; } } ---- geometry.h -------- You can use the %factory with the Geometry::create method as follows: %newobject Geometry::create; %factory(Geometry *Geometry::create, Point, Circle); %include "geometry.h" and Geometry::create will return a 'Point' or 'Circle' instance instead of the plain 'Geometry' type. For example, in python: circle = Geometry.create(Geometry.CIRCLE) r = circle.radius() where 'circle' now is a Circle proxy instance. 02/17/2006: mkoeppe [MzScheme] Typemaps for all integral types now accept the full range of integral values, and they signal an error when a value outside the valid range is passed. [Guile] Typemaps for all integral types now signal an error when a value outside the valid range is passed. 02/13/2006: mgossage [Documents] updated the extending documents to give a skeleton swigging code with a few typemaps. [Lua] added an extra typemap for void* [in], so a function which requires a void* can take any kind of pointer Version 1.3.28 (February 12, 2006) ================================== 02/11/2006: mmatus Fix many issues with line counting and error reports. 02/11/2006: mmatus [Python] Better static data member support, if you have struct Foo { static int bar; }; then now is valid to access the static data member, ie: f = Foo() f.bar = 3 just as in C++. 02/11/2006: wsfulton [Perl] Fixed code generation to work again with old versions of Perl (5.004 and later tested) 02/04/2006: mmatus [Python] Add the %extend_smart_pointer() directive to extend SWIG smart pointer support in python. For example, if you have a smart pointer as: template class RCPtr { public: ... RCPtr(Type *p); Type * operator->() const; ... }; you use the %extend_smart_pointer directive as: %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; then, if you have something like: RCPtr make_ptr(); int foo(A *); you can do the following: a = make_ptr(); b = foo(a); ie, swig will accept a RCPtr object where a 'A *' is expected. Also, when using vectors %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; %template(vector_A) std::vector >; you can type a = A(); v = vector_A(2) v[0] = a ie, an 'A *' object is accepted, via implicit conversion, where a RCPtr object is expected. Additionally x = v[0] returns (and sets 'x' as) a copy of v[0], making reference counting possible and consistent. %extend_smart_pointer is just a collections of new/old tricks, including %typemaps and the new %implicitconv directive. 02/02/2006: mgossage bugfix #1356577, changed double=>lua_number in a few places. added the std::pair wrapping 01/30/2006: wsfulton std::string and std::wstring member variables and global variables now use %naturalvar by default, meaning they will now be wrapped as expected in all languages. Previously these were wrapped as a pointer rather than a target language string. It is no longer necessary to add the following workaround to wrap these as strings: %apply const std::string & { std::string *} *** POTENTIAL INCOMPATIBILITY *** 01/28/2006: mkoeppe [Guile -scm] Add typemaps for handling of member function pointers. 01/24/2006: mmatus - Better support for the %naturalvar directive, now it works with the scripting languages as well as Java/C#. Now, it can also be applied to class types: %naturalvar std::string; %include that will tell swig to use the 'natural' wrapping mechanism to all std::string global and member variables. - Add support for the %allowexcept feature along the scripting languages, which allows the %exception feature to be applied to the variable access methods. Also, add the %exceptionvar directive to specify a distintic exception mechanism only for variables. - Add more docs for the %delobject directive to mark a method as a destructor, 'disowning' the first argument. For example: %newobject create_foo; %delobject destroy_foo; Foo *create_foo() { return new Foo(); } void destroy_foo(Foo *foo) { delete foo; } or in a member method as: %delobject Foo::destroy; class Foo { public: void destroy() { delete this;} private: ~Foo(); }; 01/24/2006: mgossage [Lua] - Removed the type swig_lua_command_info & replace with luaL_reg (which then broke the code), fixed this - added an additional cast in the typemaps for enum's due to the issue that VC.Net will not allow casting of a double to an enum directly. Therefore cast to int then to enum (thanks to Jason Rego for this observation) 01/16/2006: mmatus (Change disabled... will be back in CVS soon) Add initial support for regexp via the external library RxSpencer. SWIG doesn't require this library to compile and/or run. But if you specify --with-rxspencer, and the library is found during installation, then swig will use it in three places: - In %renames rules, via the new rxsmatch rules, for example: %rename("%(lowercase)",rxsmatch$name="GSL_.*") ""; %rename("%(lowercase)",rxsmatch$nodeType="enum GSL_.*") ""; rxsmatch is similar to the match rule, it just uses the RxSpencer regexp library to decide if there is a match with the provided regexp. As with the match rule, you can also use the negate rule notrxsmatch. - In the %rename target name via the rxstarget option, for example: %rename("%(lowercase)",rxstarget=1) "GSL_.*"; where the target name "GSL.*" is now understood as a regexp to be matched. - In the new encoder "rxspencer", which looks like: %(rxspencer:[regexp][replace])s where "regexp" is the regular expression and "replace" is a string used as a replacement, where the @0,@1,...,@9 pseudo arguments are used to represent the corresponding matching items in the reg expression. For example: %(rxspencer:[GSL.*][@0])s <- Hello -> %(rxspencer:[GSL.*][@0])s <- GSLHello -> GSLHello %(rxspencer:[GSL(.*)][@1])s <- GSLHello -> Hello %(rxspencer:[GSL(.*)][gsl@1])s <- GSLHello -> gslHello Another example could be: %rename("%(lowercase)s",sourcefmt="%(rxspencer:[GSL_(.*)][@1])s",%$isfunction) ""; which take out the prefix "GSL_" and returns all the function names in lower cases, as following: void GSL_Hello(); -> hello(); void GSL_Hi(); -> hi(); const int GSL_MAX; -> GSL_MAX; // no change, is not a function We use the RxSpencer as an initial test bed to implemention while we decide which library will be finally added to swig. You can obtain the RxSpencer library from http://arglist.com/regex (Unix) or http://gnuwin32.sourceforge.net/packages.html (Windows) Once installed, use "man rxspencer" to get more info about the regexp format, or just google rxspencer. Since now you can enable the rxsmatch rules (see above), the simple or '|' support for the match rules (01/12/2006: mmatus) is disabled. Still, if you have problems with the rxspencer library, you can re-enable the simple 'match or' support using -DSWIG_USE_SIMPLE_MATCHOR. 01/16/2006: mmatus Change the %rename predicates to use the prefix '%$', as in: %rename("%(utitle)s",%$isfunction,%$ismember) ""; to avoid clashes with other swig macros/directives. 01/14/2006: cfisavage [Ruby] Added support for Ruby bang! methods via a new %bang feature. Bang methods end in exclamation points and indicate that the object being processed will be modified in-place as opposed to being copied. 01/12/2006: cfisavage [Ruby] Updated the Ruby module to automatically convert method names to lower_case_with_underscores using the new %rename functionality. 01/12/2006: mmatus - Add aliases for 'case' encoders used with %rename/%namewarn %(uppercase)s hello_world -> HELLO_WORLD %(lowercase)s HelloWorld -> helloworld %(camelcase)s hello_world -> HelloWorld %(undercase)s HelloWorld -> hello_world 01/12/2006: mmatus - Add the -dump_parse_module and -dump_parse_top options, which are similar to -dump_module and -dump_top, but they dump the node trees just after parsing, showing only the attributes visible at the parsing stage, and not the added later in typemap.cxx, allocate.cxx, lang.cxx or elsewhere. Besides debugging porpuses, these options are very useful if you plan to use %rename in an "advance way", since it shows only and all the node's attributes you can use inside the match rules. 01/12/2006: mmatus - Add predicates to %rename, so, you don't need to remember, for example, how to match a member function. Now it is easy, for example to use the 'utitle' encoder in all the member methods, you type: %rename("%(utitle)s",%isfunction,%ismember) ""; or to ignore all the enumitems in a given class: %rename("$ignore", %isenumitem, %classname="MyClass") ""; Available predicates are (see swig.swg): %isenum %isenumitem %isaccess %isclass %isextend %isextend %isconstructor %isdestructor %isnamespace %istemplate %isconstant %isunion %isfunction %isvariable %isimmutable %isstatic %isfriend %istypedef %isvirtual %isexplicit %isextern %ismember %isglobal %innamespace %ispublic %isprotected %isprivate %classname These predicates correspond to specific 'match' declarations, which sometimes are not as evident as the predicates names. - Add the or '|' operation in %rename match, for example to capitalize all the constants (%constant or const cdecl): %rename("%(upper)s",match="cdecl|constant",%isimmutable) ""; 01/12/2006: mgossage - Partial fixed of errors under C89, bug #1356574 (converted C++ style comments to C style) - Added patches from neomantra@users.sf.net #1379988 and #1388343 missing a 'return' statement for error conditions also updated the %init block bug #1356586 01/10/2006: mmatus - Add the 'utitle' encoder, as an example of how to add your own encoder. I added the encoder method in misc.c but developers can add others, the same way, inside any target language. Well, 'utitle' is the reverse of 'ctitle', ie: %rename("%(ctitle)s") camel_case; -> CamelCase; %rename("%(utitle)s") CamelCase; -> camel_case; 01/10/2006: cfisavage [Ruby] Updated Ruby Exception handling. Classes that are specified in throws clauses, or are marked as %exceptionclass, are now inherited from rb_eRuntimeError. This allows instances of these classes to be returned to Ruby as exceptions. Thus if a C++ method throws an instance of MyException, the calling Ruby method will get back a MyException object. To see an example, look at ruby/examples/exception_class. 01/10/2006: mmatus - Add the %catches directive, which complements the %exception directive in a more automatic way. For example, if you have int foo() throw(E1); swig generates the proper try/catch code to dispatch E1. But if you have: int barfoo(int i) { if (i == 1) { throw E1(); } else { throw E2(); } return 0; } ie, where there is no explicit exception specification in the decl, you end up doing: %exception barfoo { try { $action } catch(E1) { ... } } catch(E2) { ... } } which is very tedious. Well, the %catches directive defines the list of exceptions to catch, and from swig: %catches(E1,E2) barfoo(int i); int barfoo(int i); is equivalent to int barfoo(int i) throw(E1,E2); Note, however, that the %catches list doesn't have to correspond to the C++ exception specification. For example, if you have: struct E {}; struct E1 : E {}; struct E2 : E {}; int barfoo(int i) throw(E1,E2); you can define %catches(E) barfoo(int i); and swig will generate an action code equivalent to try { $action } catch(E &_e) { ; } Of course, you still have to satisfy the C++ restrictions, and the catches list must be compatible (not the same) as the original list of types in the exception specification. Also, you can now specify that you want to catch the unknown exception '...', for example: %catches(E1,E2,...) barfoo(int); In any case, the %catches directive will emit the code to convert into the target language error/exception using the 'throws' typemap. For the '...' case to work, you need to write the proper typemap in your target language. In the UTL, this looks like: %typemap(throws) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } 01/09/2006: mutandiz [Allegrocl] Fixes a number of SEGVs primarily in the handling of various anonymous types. Found in a pass through the swig test-suite. Still more to do here, but this is a good checkpoint. Adds -cwrap and -nocwrap as an allegrocl specific command-line argument. Controls generating of a C wrapper file when wrapping C code. By default only a lisp file is created for C code wrapping. Doc updates for the command-line arguments and fixes as pointed out on swig-devel 01/05/2006: wsfulton [Java] Fix unsigned long long and const unsigned long long & typemaps - Bug #1398394 with patch from Dries Decock 01/06/2006: mmatus Add 'named' warning codes, now in addition to: %warnfilter(813); you can use %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE); just use the same code name found in Source/Include/swigwarn.h plus the 'SWIG' prefix. If a developer adds a new warning code, the Lib/swigwarn.swg file will be generated when running the top level make. 01/05/2006: cfisavage [Ruby] Reimplemented object tracking for Ruby. The new implementation works by expanding the swig_class structure for Ruby by adding a trackObjects field. This field can be set/unset via %trackobjects as explained in the Ruby documentation. The new implementation is more robust and takes less code to implement. 01/05/2006: wsfulton Fix for %extend and static const integral types, eg: class Foo { public: %extend { static const int bar = 42; } }; 12/30/2005: mmatus - Add info for old and new debug options: -dump_top - Print information of the entire node tree, including system nodes -dump_module - Print information of the module node tree, avoiding system nodes -dump_classes - Print information about the classes found in the interface -dump_typedef - Print information about the types and typedefs found in the interface -dump_tags - Print information about the tags found in the interface -debug_typemap - Print information for debugging typemaps -debug_template - Print information for debugging templates - Add the fakeversion. If you have a project that uses configure/setup.py, or another automatic building system and requires a specific swig version, let say 1.3.22 you can use: SWIG_FEATURES="-fakeversion 1.3.22" or swig -fakeversion 1.3.22 and then swig -version will report 1.3.22 instead of the current version. Typical use would be SWIG_FEATURES="-fakeversion 1.3.22" ./configure 12/30/2005: mmatus - Add option/format support to %rename and %namewarn. Now %namewarn can force renaming, for example: %namewarn("314: import is a keyword",rename="_%s") "import"; and rename can also support format forms: %rename("swig_%s") import; Now, since the format is processed via swig Printf, you can use encoders as follows: %rename("%(title)s") import; -> Import %rename("%(upper)s") import; -> IMPORT %rename("%(lower)s") Import; -> import %rename("%(ctitle)s") camel_case; -> CamelCase This will allow us to add more encoders, as the expected one for regular expressions. - Add the above 'ctitle' encoder, which does the camel case: camel_case -> CamelCase - Also, while we get the regexp support, add the 'command' encoder, you can use it as follows %rename("%(command:sed -e 's/\([a-z]\)/\U\\1/' <<< )s") import; then swig will popen the command "sed -e 's/\([a-z]\)/\U\\1/' <<< import" see below for anonymous renames for better examples. - The rename directive now also allows: - simple match: only apply the rename if a type match happen, for example %rename(%(title)s,match="enumitem") hello; enum Hello { hi, hello -> hi, Hello }; int hello() -> hello; - extended match: only apply the rename if the 'extended attribute' match occurred, for example: // same as simple match %rename(%(title)s,match$nodeType="enumitem") hello; enum Hello { hi, hello -> hi, Hello }; Note that the symbol '$' is used to define the attribute name in a 'recursive' way, for example: // match only hello in 'enum Hello' %rename(%(title)s,match$parentNode$type="enum Hello") hello; enum Hello { hi, hello -> hi, Hello // match }; enum Hi { hi, hello -> hi, hello // no match }; here, for Hello::hi, the "parentNode" is "Hello", and its "type" is "enum Hello". - Anonymous renames: you can use 'anonymous' rename directives, for example: // rename all the enum items in Hello %rename(%(title)s,match$parentNode$type="enum Hello") ""; enum Hello { hi, hello -> Hi, Hello // match both }; enum Hi { hi, hello -> hi, hello // no match }; // rename all the enum items %rename(%(title)s,match$nodeType="enumitem") ""; // rename all the items in given command (sloooow, but...) %rename(%(command:)s) ""; Anonymous renames with commands can be very powerful, since you can 'outsource' all the renaming mechanism (or part of it) to an external program: // Uppercase all (and only) the names that start with 'i' %rename("%(command:awk '/^i/{print toupper($1)}' <<<)s") ""; int imported() -> IMPORTED; int hello() -> hello Note that if the 'command' encoder returns an empty string, swig understands that no rename is necessary. Also note that %rename 'passes' the matched name. For example, in this case namespace ns1 { int foo(); } namespace ns2 { int bar(); } the external program only receives "foo" and "bar". If needed, however, you can request the 'fullname' %rename("%(command:awk 'awk '/ns1::/{l=split($1,a,"::"); print toupper(a[l])}'' <<<)s",fullname=1) ""; ns1::foo -> FOO ns2::bar -> bar - Mixing encoders and matching: of course, you can do mix commands and match fields, for example: %rename("%()",match="cdecl") ""; %rename("%()",match="enumitem") ""; %rename("%()",match="enumitem", match$parentNode$parentNode$nodeType="class") ""; Use "swig -dump_parse_module" to see the attribute names you can use to match a specific case. - 'sourcefmt' and 'targetfmt': sometimes you need to process the 'source' name before comparing, for example %namewarn("314: empty is a keyword",sourcefmt="%(lower)s") "empty"; then if you have int Empty(); // "Empty" is the source you will get the keyword warning since 'Empty' will be lower cased, via the sourcefmt="%(lower)s" option, before been compared to the 'target' "empty". There is an additional 'targetfmt' option to process the 'target' before comparing. - complementing 'match': you can use 'notmatch', for example %namewarn("314: empty is a keyword",sourcefmt="%(lower)s",notmatch="namespace") "empty"; here, the name warning will be applied to all the symbols except namespaces. 12/30/2005: mmatus - Add initial support for gcj and Java -> mechanism. See examples in: Examples/python/java Examples/ruby/java Examples/tcl/java to see how to use gcj+swig to export java classes into python/ruby/tcl. The idea is to put all the common code for gcj inside Lib/gcj and localize specific types such as jstring, as can be found in Lib/python/jstring.i Lib/ruby/jstring.i Lib/tcl/jstring.i Using the UTL, this is very easy, and the perl version for jstring.i will be next. 12/29/2005: mmatus - Add the copyctor feature/directive/option to enable the automatic generation of copy constructors. Use as in: %copyctor A; struct A { }; then this will work a1 = A(); a2 = A(a1); Also, since it is a feature, if you just type %copyctor; that will enable the automatic generation for all the classes. It is also equivalent to swig -copyctor -c++ ... Notes: 1.- The feature only works in C++ mode. 2.- The automatic creation of the copy constructor will usually produce overloading. Hence, if the target language doesn't support overloading, a special name will be used (A_copy). 3.- For the overloading reasons above, it is probably not a good idea to use the flag when, for example, you are using keywords in Python. 4.- The copyctor automatic mechanism follows more or less the same rules as the default constructor mechanism, i.e., a copy constructor will not be added if the class is abstract or if there is a pertinent non-public copy ctor in the class or its hierarchy. Hence, it might be necessary for you to complete the class declaration with the proper non-public copy ctor to avoid a wrong constructor addition. - Fix features/rename for templates ctor/dtor and other things around while adding the copyctor mechanism. 12/27/2005: mmatus - Add the 'match' option to typemaps. Assume you have: %typemap(in) SWIGTYPE * (int res) {..} %typemap(freearg) SWIGTYPE * { if (res$argnum) ...} then if you do %typemap(in) A * {...} swig will 'overload the 'in' typemap, but the 'freearg' typemap will be also applied, even when this is wrong. The old solutions is to write: %typemap(in) A * {...} %typemap(freeag) A * ""; overload 'freearg' with an empty definition. The problem is, however, there is no way to know you need to do that until you start getting broken C++ code, or worse, broken runtime code. The same applies to the infamous 'typecheck' typemap, which always confuses people, since the first thing you do is to just write the 'in' typemap. The 'match' option solves the problem, and if instead you write: %typemap(in) SWIGTYPE * (int res) {..} %typemap(freearg,match="in") SWIGTYPE * { if (res$argnum) ...} %typemap(typecheck,match="in",precedence...) SWIGTYPE * {...} it will tell swig to apply the 'freearg/typecheck' typemaps only if they 'match' the type of the 'in' typemap. The same can be done with other typemaps as: %typemap(directorout) SWIGTYPE * {...} %typemap(directorfree,match="directorout") SWIGTYPE * {...} 12/27/2005: mmatus - Add the 'naturalvar' option/mode/feature to treat member variables in a more natural way, ie, similar to the global variable behavior. You can use it in a global way via the command line swig -naturalvar ... or the module mode option %module(naturalvar=1) both forms make swig treat all the member variables in the same way it treats global variables. Also, you can use it in a case by case approach for specific member variables using the directive form: %naturalvar Bar::s; Then, in the following case for example: std::string s; struct Bar { std::string s; }; you can do: b = Bar() b.s ="hello" cvar.s = "hello" if (b.s != cvar.s): raise RuntimeError This is valid for all the languages, and the implementation is based on forcing the use of the const SWIGTYPE& (C++)/SWIGTYPE (C) typemaps for the get/set methods instead of the SWIGTYPE * typemaps. Hence, for 'naturalvar' to work, each target language must implement 'typemap(in/out) const Type&' properly. The 'naturalvar' option replaces or makes workarounds such as: %apply const std::string & { std::string *} unnecessary. Note1: If your interface has other kinds of workarounds to deal with the old 'unnatural' way to deal with member variables (returning/expecting pointers), the 'naturalvar' option could break them. Note2: the option has no effect on unnamed types, such as unnamed nested unions. 12/27/2005: mmatus - Add more 'expressive' result states for the typemap libraries. In the past, for scripting languages, you would do checking something like: if (ConvertPtr(obj,&vptr,ty,flags) != -1) { // success } else { // error } Now the result state can carry more information, including: - Error state: like the old -1/0, but with error codes from swigerrors.swg. int res = ConvertPtr(obj,&vptr,ty,flags); if (SWIG_IsOK(res)) { // success code } else { SWIG_Error(res); // res carries the error code } - Cast rank: when returning a simple successful conversion, you just return SWIG_OK, but if you need to do a 'cast', you can add the casting rank, ie: if (PyFloat_Check(obj)) { value = PyFloat_AsDouble(obj); return SWIG_OK; } else if (PyInt_Check(obj)) { value = (double) PyInt_AsLong(obj); return SWIG_AddCast(SWIG_OK); } later, the casting rank is used to properly dispatch the overloaded function, for example. This of course requires your language to support and use the new dispatch cast/rank mechanism (Now mainly supported in perl and python, and easily expandable to ruby and tcl). - [UTL] Add support for the new 'expressive' result states. 12/27/2005: mmatus - Add support for the C++ implicit conversion mechanism, which required some modifications in parser.y (to recognize 'explicit') and overload.cxx (to replace $implicitconv as needed). Still, real support in each target language requires each target language to be modified. Python provides an example, see below. - Add support for native C++ implicit conversions, ie, if you have %implicitconv A; struct A { int ii; A() {ii = 1;} A(int) {ii = 2;} A(double) {ii = 3;} explicit A(char *s) {ii = 4;} }; int get(const A& a) {return a.ii;} you can call: a = A() ai = A(1) ad = A(1.0) as = A("hello") # old forms get(a) -> 1 get(ai) -> 2 get(ad) -> 3 get(as) -> 4 #implicit conversions get(1) -> 2 get(1.0) -> 3 get("hello") -> Error, explicit constructor Also, as in C++, now implicit conversions are supported in variable assigments, and if you have: A ga; struct Bar { A a; }; you can do: cvar.ga = A(1) cvar.ga = 1 cvar.ga = 1.0 cvar.ga = A("hello") cvar.ga = "hello" -> error, explicit constructor b = Bar() b.a = A("hello") b.a = 1 b.a = 1.0 b.a = "hello" -> error, explicit constructor Note that the last case, assigning a member var directly, also requires the 'naturalvar' option. This support now makes the old '%implicit' macro, which was found in 'implicit.i' and it was fragile in many ways, obsolete, and you should use the new '%implicitconv' directive instead. Note that we follow the C++ conventions, ie, in the following the implicit conversion is allowed: int get(A a) {return a.ii;} int get(const A& a) {return a.ii;} but not in these cases: int get(A *a) {return a->ii;} int get(A& a) {return a.ii;} Also, it works for director methods that return a by value result, ie, the following will work: virtual A get_a() = 0; def get_a(self): return 1 but not in this case: virtual const A& get_a() = 0; virtual A& get_a() = 0; virtual A* get_a() = 0; Notes: - the implicitconv mechanism is implemented by directly calling/dispatching the python constructor, triggering a call to the __init__method. Hence, if you expanded the __init__ method, like in: class A: def __init__(self,args): then 'my code' will also be executed. - Since the %implicitconv directive is a SWIG feature, if you type: %implicitconv; that will enable implicit conversion for all the classes in your module. But if you are worried about performance, maybe that will be too much, especially if you have overloaded methods, since to resolve the dispatching problem, python will efectively try to call all the implicit constructors as needed. - For the same reason, it is highly recommended that you use the new 'castmode' when mixing implicit conversion and overloading. - [python] The %implicit directive is declared obsolete, and you should use %implicitconv instead. If you include the implicit.i file, a warning will remind you of this. Note: Since %implicit is fragile, just replacing it by %implicitconv could lead to different behavior. Hence, we don't automatically switch from to the other, and the user must migrate to the new %implicitconv directive manually. 12/26/2005: wsfulton [C#] Modify std::vector wrappers to use std::vector::value_type as this is closer to the real STL declarations for some methods, eg for push_back(). Fixes some compilation errors for some compilers eg when the templated type is a pointer. [Java] std::vector improvements - a few more methods are wrapped and specializations are no longer required. The specialize_std_vector macro is no longer needed (a warning is issued if an attempt is made to use it). 12/26/2005: wsfulton [Java, C#] Add in pointer reference typemaps. This also enables one to easily wrap std::vector where T is a pointer. 12/24/2005: efuzzyone [CFFI] The cffi module for SWIG: - Fully supports C, but provides limited supports for C++, in particular C++ support for templates and overloading needs to be worked upon. 12/23/2005: mmatus [python] Add the castmode that allows the python type casting to occur. For example, if you have 'int foo(int)', now class Ai(): def __init__(self,x): self.x = x def __int__(self): return self.x foo(1) // Ok foo(1.0) // Ok foo(1.3) // Error a = Ai(4) foo(ai) // Ok The castmode, which can be enabled either with the '-castmode' option or the %module("castmode") option, uses the new cast/rank dispatch mechanism. Hence, now if you have 'int foo(int); int foo(double);', the following works as expected: foo(1) -> foo(int) foo(1.0) -> foo(double) ai = Ai(4) foo(ai) -> foo(int) Note1: the 'castmode' could disrupt some specialized typemaps. In particular, the "implicit.i" library seems to have problem with the castmode. But besides that one, the entire test-suite compiles fine with and without the castmode. Note2: the cast mode can't be combined with the fast dispatch mode, ie, the -fastdispatch option has no effect when the cast mode is selected. The penalties, however, are minimum since the cast dispatch code is already based on the same fast dispatch mechanism. See the file overload_dispatch_cast_runme.py file for new cases and examples. 12/22/2005: mmatus Add the cast and rank mechanism to dispatch overloading functions. The UTF supports it now, but for each language it must be decided how to implement and/or when to use it. [perl] Now perl uses the new cast and rank dispatch mechanism, which solves all the past problems known in perl, such as the old '+ 1' problem: int foo(int); $n = 1 $n = $n + 1 $r = foo(n) also works: foo(1); foo("1"); foo(1.0); foo("1.0"); but fails foo("l"); and when overloading foo(int) and foo(double); foo(1) -> foo(int) foo(1.0) -> foo(double) foo("1") -> foo(int) foo("1.0") -> foo(double) foo("l") -> error foo($n) -> foo(int) for good perl versions foo($n) -> foo(double) for old bad perl versions when overloading foo(int), foo(char*) and foo(double): foo(1) -> foo(int) foo(1.0) -> foo(double) foo("1") -> foo(char*) foo("1.0") -> foo(char*) foo("l") -> foo(char*) Note: In perl the old dispatch mechanism was broken, so, we don't provide an option to enable the old one since, again, it was really really broken. See 'overload_simple_runme.pl' for more cases and tests. PS: all the old known issues are declared resolved, any new "problem" that could be discovered is declared, a priori, as "features" of the new dispatch mechanism (until we find another solution at least). *** POTENTIAL INCOMPATIBILITY *** As with the introduction of the UTF, some things could now start to work as expected, and people used to deal or workaround previous bugs related to the dispatch mechanism, could see now a difference in perl behavior. 12/21/2005: mmatus - The '-nodefault' flag (pragma and feature) now generates a warning, and recommends to use the explicit -nodefaultctor and -nodefaultdtor options. The reason to split the 'nodefault' behavior is that, in general, ignoring the default destructor generates memory leaks in the target language. Hence, is too risky just to disable both the default constructor and destructor at the same time. If you need to disable the default destructor, it is also recommended you use the directive form: %nodefaultdtor MyVerySpecialClass; for specific classes, and always avoid using the global -nodefault and -nodefaultdtor options. 12/21/2005: wsfulton [Java, C#] Fix incorrect code generation when the intermediary classname is changed in the module directive from its default. For example: %module(jniclassname="myimclassnewname") "mymodule" // Java %module(imclassname="myimclassnewname") "mymodule" // C# Add in new special variable $imclassname. See docs. 12/17/2005: mmatus [Python] - Add the -aliasobj0/-noaliasobj0 options to use with -fastunpack and/or -O and old typemaps that use 'obj0' directly. So, if you compile your code using -O and get errors about the undeclared 'obj0' variable, run again using swig -O -aliasobj0 -python .... For new typemaps, never use 'obj0' directly, if needed, use the '$self' name that will be properly expanded to 'obj0' (nofastunpack) or 'swig_obj[0]' (fastunpack). If you have no idea what I am talking about, better, that means you have no typemap with this problem. 12/14/2005: mmatus [Python] - Add the -fastunpack/-nofastunpack options to enable/disable the use of the internal UnpackTuple method, instead of calling the one from the python C API. The option -O now also implies -fastunpack. 12/11/2005: mmatus [Python] - Add the -proxydel/-noproxydel options to enable/disable the generation of proxy/shadow __del__ methods, even when now they are redundant, since they are empty. However, old interfaces could rely on calling them. The default behavior is to generate the __del__ methods as in 1.3.27 or older swig versions. The option -O now also implies -noproxydel. 12/10/2005: mmatus [UTF] - Fix unneccessary calls to SWIG_TypeQuery for 'char *' and 'wchar_t *', problem found by Clay Culver while profiling the PyOgre project. [Python] - Add the -dirvtable/-nodirvtable to enable/disable a pseudo virtual table used for directors, avoiding the need to resolve the python method at each call. - Add the -safecstrings/-nosafecstrings options to enable/disable the use of safe conversions from PyString to char *. Python requires you to never change the internal buffer directly, and hence 'safectrings' warranties that but returning a copy of the internal python string buffer. The default, as in previous releases, is to return a pointer to the buffer (nosafecstrings), so, it is the user's responsibility to avoid its modification. - Add the -O option to enable all the optimization options at once, initially equivalent to -modern -fastdispatch -dirvtable -nosafecstrings -fvirtual 12/08/2005: mmatus - Add the -fastdispatch option (fastdispatch feature). This enables the "fast dispatch" mechanism for overloaded methods provided by Salvador Fandi~no Garc'ia (#930586). The resulting code is smaller and faster since less type checking is performed. However, the error messages you get when the overloading is not resolved could be different from what the traditional method returns. With the old method you always get an error such as "No matching function for overloaded ..." with the new method you can also get errors such as "Type error in argument 1 of type ..." See bug report #930586 for more details. So, this optimization must be explicitly enabled by users. The new mechanism can be used as: swig -fastdispatch or using the feature form %feature("fastdispatch") method; or %fastdispatch method; 12/06/2005: mmatus - Several memory and speed improvements, specially for templates. Now swig is up to 20 faster than before for large template interfaces, such as the std_containers.i and template_matrix.i files in the python test-suite. Memory footprint is also reduced in consideration of small pcs/architectures. - add commandline options -cpperraswarn and -nocpperraswarn" to force the swig preprocessor to treat the #error directive as a #warning. the pragmas #pragma SWIG cpperraswarn=1 #pragma SWIG cpperraswarn=0 are equivalent to the command line options, respectively. 12/06/2005: mmatus [Python] The generated code is now more portable, especially for Windows. Following http://www.python.org/doc/faq/windows.html Py_None is never accessed as a structure, plus other tricks mentioned there. 12/06/2005: mmatus [Python] Added initial support for threads based in the proposal by Joseph Winston. The user interface is as follows: 1.- the module thread support is enable via the "threads" module option, i.e. %module("threads"=1) 2.- Equivalent to that, is the new '-threads' swig option swig -threads -python ... 3.- You can partially disable thread support for a given method using: %feature("nothread") method; or %nothread method; also, you can disable sections of the thread support, for example %feature("nothreadblock") method; or %nothreadblock method; %feature("nothreadallow") method; or %nothreadallow method; the first disables the C++/python thread protection, and the second disables the python/C++ thread protection. 4.- The current thread support is based in the PyGIL extension present in python version 2.3 or later, but you can provide the thread code for older versions by defining the macros in pythreads.swg. If you get a working implementation for older versions, please send us a patch. For the curious about performance, here are some numbers for the profiletest.i test, which is used to check the speed of the wrapped code: nothread 9.6s (no thread code) nothreadblock 12.2s (only 'allow' code) nothreadallow 13.6s (only 'block' code) full thread 15.5s ('allow' + 'block' code) i.e., full thread code decreases the wrapping performance by around 60%. If that is important to your application, you can tune each method using the different 'nothread', 'nothreadblock' or 'nothreadallow' features as needed. Note that for some methods deactivating the 'thread block' or 'thread allow' code is not an option, so, be careful. 11/26/2005: wsfulton SWIG library files use system angle brackets everywhere for %include, eg %include "std_common.i" becomes %include 11/26/2005: wsfulton [Java, C#] Typesafe enums and proper enums have an extra constructor so that enum item values that are initialised by another enum item value can be wrapped without having to use %javaconstvalue/ %csconstvalue for when using %javaconst(1)/%csconst(1). Suggestion by Bob Marinier/Douglas Pearson. For example: typedef enum { xyz, last = xyz } repeat; 11/21/2005: mmatus [ruby + python] Fixes for directors + pointers. This is an ugly problem without an easy solution. Before we identified this case as problematic: virtual const MyClass& my_method(); but it turns out that all the cases where a pointer, array or reference is returned, are problematic, even for primitive types (as int, double, char*, etc). To try to fix the issue, a new typemap was added, 'directorfree', which is used to 'free' the resources allocated during the 'directorout' phase. At the same time, a primitive garbage collector engine was added to deal with orphaned addresses, when needed. The situation is much better now, but still it is possible to have memory exhaustation if recursion is used. So, still you need to avoid returning pointers, arrays or references when using director methods. - Added stdint.i - typemaps for latest C99 integral types found in stdint.h. 11/14/2005: wsfulton More types added to windows.i, eg UINT8, WORD, BYTE etc. Including windows.i will also enable SWIG to parse the __declspec Microsoft extension, eg __declspec(dllimport). Also other Windows calling conventions such as __stdcall. 11/10/2005: wsfulton New library file for Windows - windows.i. This file will contain useful type information for users who include windows.h. Initial support is for the non ISO integral types: __int8, __int16, __int32, __int64 and unsigned versions. The unsigned versions previously could not be parsed by SWIG. SF #872013. 11/09/2005: wsfulton [Java, C#] Portability warning for files which will overwrite each other on case insensitive file systems such as FAT32/NTFS. This will occur, for example, when two class names are the same barring case. The warning is issued on all platforms and can be suppressed with the usual warning suppression techniques. SF bug #1084507. 11/09/2005: wsfulton ./configure --with-python --with-ruby --with-perl5 etc enable these languages, ie the --with-xxxx options, where no path is specified, work the same as if the option was not specified at all. Based on patches #1335042 #1329048 #1329047. 11/09/2005: dancy [Allegrocl] Add C++ support to the Allegrocl module. Further enhances the C support as well. Some of the features: - MUCH better generation of foreign types based on the C/C++ types for use in defining the FFI on the lisp side. We don't pass everything as a (* :void) any longer. - Uses typemaps for better control of type conversions and code generation in the generated lisp and c++ wrapper code. - CLOS wrapping of pointers returned from foreign space makes it easier to differentiate pointers in user code. The wrapping objects can be passed directly to FF calls. - Defun wrapping of FF calls, allowing for more lispy interface. Conversion, GCing, of lisp objects to foreign objects can be done in the wrapping defun via the use of typemaps. - overload dispatching implemented on the lisp side using generic functions. - Templates and synonymous types supported. 11/07/2005: mmatus [Python] Adding proper support for multi-inheritance in the python side, ie, if you have two C++ wrapped class, Foo and Bar, now: class MyPythonClass(Foo,Bar): .... will properly work, even with directors, and the deallocation of Foo.this and Bar.this will follow correctly. Before, a class could only have one 'this' instance (unlike C++), only the last base class was properly deleted, or detected with directors. Now 'self.this' can be a list, which will contain the C++ instance pointers for all the base classes. Also, swig.this is responsible for deallocating the C++ instance(s), and the __del__ method is not emitted unless the user preppend/append some code to it. - Swig can now detect memory leaks, ie, if you still don't use proxy/shadow classes, and type something like import _example f = _example.new_Foo() and forget to call _example.delete_Foo(f), then swig will tell you that there is a memory leak. Otherwise, if you always use the proxy classes, you probably you will never ever see this warning unless there is something wrong inside the swig wrapping code. *** POTENTIAL INCOMPATIBILITY *** If you overloaded the __del__ method, and call the base one without a try block, as in class MyClass(SwigClass): def __del__(self): SwigClass.__del__(self) python could complain that the method SwigClass.__del__ is undefined. Try to use instead: def __del__(self): try: SwigClass.__del__(self) except: pass or simply def __del__(self): 11/02/2005: mmatus [Python] Adding more fun to STL/STD containers, now you can do %template(pyset) std::set; %template(pyvector) std::vector; %template() std::pair; %template(pyvector) std::map; .... The same applies to std::list, std::deque, std::multiset, etc. Then, at the python side you can do now: # C++ std::vector as native python sequence v = pyvector([1,"hello",(1,2)]) print v[1] >> 'hello' print v[2] >> (1,2) # C++ std::set as native python sequence s = pyset() s.insert((1,2)) s.insert(1) s.insert("hello") sum=() for i in s: sum +=(i,) print sum >>> (1, 'hello', (1, 2)) # C++ std::map as native python sequence m = pymap() m["foo"] = "hello" m[1] = (1,2) pm = {} for k in m: pm[k] = m[k] print pm >>> {1: (1, 2), 'foo': 'hello'} ie, the STD/STL containers work as real native python container, with arbitrary item types and so. But since normal C++ containers do not properly ref/unref their items, you should use the safer versions: %template(pyset) std::set; %template(pyvector) std::vector; %template() std::pair; %template(pyvector) std::map; .... where swig::PyObject_ptr is a PyObject * envelope class provided to safely incref/decref the python object. So, now you can use all the STL/STD containers as native Python containers. Note 1: std::map, std::set and the other 'ordered' containers will properly use PyObject_Compare for sorting, when needed. Note 2: all the STL/STD containers have a limit size of SIZE_MAX, ie, you can have manage containers larger than INT_MAX, the python limit. 11/02/2005: mmatus [Python] - add 'iterator()' method for all sequences and additionally 'key_iterator()' for maps. 'iterator()' will always return the native C++ iterator. Additionally, in maps, 'key_iterator()' will return a python iterator using only the map keys. In general the sequence method __iter__ will call 'iterator()', returning the native C++ iterator, but in maps it will call 'key_iterator()', maintaining backward compatibility. Hence, for std::maps, you can play then with the native C++ iterator, which value is a (key, value) pair, by calling map.iterator(), as with map.begin(), map.end(), etc. The difference is that map.iterator() returns a safe 'closed' iterator, while map.begin() and map.end() are 'open' iterators. A 'closed' iterator knows the begin and the end of the sequence, and it never can seg. fault. An 'open' iterator, as in C++, can seg. fault at the C++ side. # a closed iterator is safe in the following example. # the next() method will throw a StopIteration # exception as needed i = seq.iterator() try: while True: sum += i.next() except: pass # an open iterator always need to be checked, # or it will crash at the C++ side current = seq.begin() end = seq.end() while (current != end): sum += current.next() [Python] - Finally, when we call f = Foo() the construction is 'one-way'. Before construction was done something like Foo() (python) -> _new_Foo() (C++) new_Foo() (C++) -> FooPtr() (python) FooPtr() (python) -> Foo() (python) and returning a pointer was done like NewPointerObj() (C++) -> FooPtr() (python) FooPtr(python) -> Foo() (python) ie, we when going back and forward between the C++ and python side. Now since there is no FooPtr the construction process is Foo() (python) -> _new_Foo() (C++) _new_Foo() (C++) -> NewPointerObj() (C++) (no shadow class) and returning a pointer is done NewPointerObj() (C++) (with shadow class) -> NewInstaceObj() (C++) where NewInstanceObj creates a new instance without calling __init__ and it doesn't go 'back' to python, is 'pure' C API. - With this change, and the other ones in the PySwigObject type, which now carries the thisown and swig_type_info pointer, the generated code should be as fast as boost::Python and/or the other python wrappers based in pure Python/C API calls. As a reference, the profiletest_runme.py example, which does a simple call function many times, such as this code: import profiletest a = profiletest.A() b = profiletest.B() for i in range(0,1000000) a = b.fn(a) where fn is defined as 'A* B::fn(A *a) {return a;}', produces the following times nomodern modern swig-1.3.26 19.70s 5.98s swig-CVS 0.99s 0.98s Clearly, there is a large improvement for the python 'nomodern' mode. Still, the 'modern' mode is around 6 times faster than before. For the same test, but using the non-shadow version of the module, we get _profiletest (non-shadow) swig-1.3.26 0.80s swig-CVS 0.60s Hence, now for practical purposes, the proxy overhead is insignificant. Note that the performance numbers we are showing is for a simple module (two types) and a simple function (one argument). For real situations, for modules with many more types and/or functions with many more parameters, you will see even better results. 10/31/2005: mmatus [Python] - Finally, no more ClassPtr proxy classes. You will see only a clean Class proxy class in the .py file. - No more 'real' thisown attribute either, the PySwigObject now carries the ownership info. You can also do something like print self.this.own() >>> True self.this.disown() self.this.own(0) print self.this.own() >>> False self.this.acquire() self.this.own(1) print self.this.own() >>> True Still the old way, print self.thisown >>> True self.thisown = 0 print self.thisown >>> False self.thisown = 1 print self.thisown >>> True is supported, and python dispatches the proper method calls as needed. - Support for iterators in STL/STD containers, for example, if you have %template std::set; you can use the C++ iterators as: s = set_string() s.append("c") s.append("a") s.append("b") b = s.begin() e = s.end() sum = "" while (b != e): sum += b.next() print sum >>> "abc" advance the iterator as in C++ current = s.begin() current += 1 print current.value() >>> "b" now using the reverse operators b = s.rbegin() e = s.rend() sum = "" while (b != e): sum += b.next() print sum >>> "cba" or the 'previous' method b = s.begin() e = s.end() sum = "" while (b != e): sum += e.previous() print sum >>> "cba" or just as in a python fashion for i in s: sum += i Note 1: Iterators in C++ are very powerful, but dangerous too. And in python you can shoot yourself in the foot just like in C++, so, be careful. Note 2: the iterators are 'light', ie, they do not convert sequence elements until you request to do so, via next(), value() or previous(). If you just increment/decrement one no conversion is performed, for example: b = s.begin() b += 1 b.incr() b.incr(2) b.decr(2) b.decr() b -= 1 only the iterator is modified, and not value wrapper is generated. Other typical C++ operations are also available, such as: print s.end() - s.begin() >>> 3 f = s.begin() + 1 print f.value() >>> "b" l = s.end() - 1 print l.value() >>> "c" etc. Of course, the 'find', 'insert', 'erase', and so on methods also supports iterators now, ie: i = s.begin() i += 1 s.erase(i) for i in s: sum += i print sum >>> "ac" *** POTENTIAL INCOMPATIBILITY *** There is no more 'thisown' attribute. If you use it, python will translate the following code as follows: if (self.thisown): ==> if (self.this.own()): self.thisown = 1 ==> self.this.own(1) self.thisown = 0 ==> self.this.own(0) Still, maybe in some unusual cases the translation will not be 100% correct, so if you have a problem, please report it and/or use the new 'self.this.own()' accessor. *** POTENTIAL INCOMPATIBILITY *** There is no more ClassPtr classes in the python code. Hence, if in the past you needed to resort to some kind of trickery with them, or overcome their presence, it is no longer required, but the extra code you added could now break things. If needed, you can use the option -classptr, i.e., swig -classptr -python ... to generate the old ClassPtr classes. 10/30/2005: mkoeppe [Guile] Make declared and defined linkage of SWIG_init consistent. Reported by Steven G. Johnson (SF patch 1315498). 10/26/2005: mmatus - Added the attribute.i file to the global library director. Now it can be used from other languages that do not use the unified typemap library as well. So, if you have something like: %include attribute.i %attribute(A, int, a, get_a, set_a); struct A { int get_a() const; void set_a(int aa); }; %attribute_ref(B, int, c); struct B { int& c(); }; then in the target language the 'A.a' and 'B.c' attributes will be visible, ie, you can access them as plain variables: f = A() f.a = 3 g = B() g.c = 3 h = f.a + g.c and the proper get/set methods will be dispatched. See attribute.i for more info. - More cleanups around and adding more test-cases. The DISOWN typemap now is tested and working in all the languages that use the unified typemap library, ie, tcl, ruby, perl and python. 10/25/2005: mmatus - Perl, complete the DISOWN typemap. - added the attribute.i file to the unified typemap library (before was only usable from python). - unify the names for the setter and getter methods in perl,tcl,ruby and python, so, the attribute.i library can work across them. - see the li_attribute.i test-case or the library file Lib/typemaps/attribute.swg for more info about how to use it. 10/24/2005: mmatus - Perl now uses the unified typemap library. - Changes in ruby to use the $track option in typemaps. - Changes in the unified typemap library to follow the convention that all macros that are not used in the C/C++ side starts with %, such as %delete %new_array etc. - Documenting fragments, see fragments.swg. - Cleaner way to use the unified typemap library, include just . Check some of the supported languages: perl, tcl, ruby, python. Always start with the head file, such as python/python.swg tcl/tcl8.swg ruby/ruby.swg perl5/perl5.swg and the principal file that invokes the unified library, such as python/pytypemaps.swg tcl/tcltypemaps.swg ruby/rubytypemaps.swg perl/perltypemaps.swg The file that provide the specialization for each language are the one that provides the basic types: python/pyprimtypes.swg ruby/rubyprimtypes.swg tcl/tclprimtypes.swg perl5/perlprimtypes.swg and the string manipulation: python/pystrings.swg ruby/rubystrings.swg tcl/tclstrings.swg perl5/perlstrings.swg The rest of the files, such as carray.i, are mostly one line files that include the proper typemap library version. *** POTENTIAL INCOMPATIBILITY in Perl *** Some missing/wrong typemaps could start working properly, and change the old expected behavior in Perl. 10/23/2005: wuzzeb Chicken: + pointers to member functions finally work properly + add test of member function pointers to cpp_basic.i 10/20/2005: dancy [allegrocl] Added C++ support. Large update, many changes. See newly added Allegro Common Lisp section in lisp.html 10/20/2005: mmatus Ruby, Tcl, Python: - Uniform way to fail (label fail:), now finally SWIG_exception works across the three languages and all the typemaps. - Add proper cleanup code to ruby - More valgrind fixes - Simplify the inline use, it seems a small interface of 20,000 lines (plus many many templates) can break gcc -O3 easily. - Finalize the typemaps library. All the old *.i files (carray.i, cpointer.i, exception.i) had been implemented in the new typemaps library. 10/19/2005: wuzzeb Update the Runtime Typemap documentation in Typemaps.html 10/18/2005: wuzzeb Chicken: - Correctly handle %ignored classes - Correctly convert long, long long, unsigned long, etc to chicken primitives. (Thanks to Felix Winkelmann) - Using argout parameters when the return value was a wrapped pointer caused a memory corruption. The chicken garbage collector moved a pointer out from under us. This is now fixed by running all the proxy creation functions as continuations after the wrapper function returns. As part of this, we no longer need the chickenfastproxy flag on output typemaps. - using -proxy and -nocollection together works now Before, it was not exporting the destructor in the proxy wrapper. 10/18/2005: mmatus Added the Unified Typemap Library (UTL). It unifies the typemaps for python, ruby, tcl and in the process, fixes several problems in each of the three languages to work in a "canonical" way now established in the typemap library SWIG/Lib/typempas The current status of the unification is that everything compiles and runs inside the test-suite and examples directories. And for the first time we have three languages than pass the primitive_types.i case. Also, we have a uniform way to treat the errors, for example if you do something like >>> from primitive_types import * >>> print val_uchar(10) 10 >>> print val_uchar(1000) Traceback (most recent call last): File "", line 1, in ? OverflowError: in argument 1 of type 'unsigned char' you get the same exception in all the three languages. And well, many more good things will come from this unification, for example, proper support of the STL/STD classes for all the languages, and hopefully, we can keep adding other languages. The hardest part, writing a common typemap library that suites the three different languages, is done, and adding another language should now be easy. Still the global unification is not complete, the STL/STD part is next, and probably as well as adding one or two more languages. If you are curious, look at the python, ruby and/or tcl directories to see what is needed to support the new common typemaps library. Still, the final way to integrate a new language could change as we move to integrate the STD/STL. *** POTENTIAL INCOMPATIBILITY in Ruby/Tcl *** Some missing/wrong typemaps could start working properly, and change the old behavior, specially in ruby and tcl. Version 1.3.27 (October 15, 2005) ================================= 10/15/2005: wsfulton [Java] Fix for typesafe enum wrapping so that it is possible to overload a method with 2 different enum types. 10/15/2005: wsfulton Fix for %feature("immutable","0") attempting to generate setters for constants. Restored %immutable and %makedefault to clear the feature as it behaved in SWIG-1.3.25 and earlier. 10/14/2005: mmatus Fix bug in anonymous typedef structures which was leading to strange behaviour. 10/13/2005: mmatus Several minor changes: - Improve the wchar_t type support - Add a warning for when you define the 'in' typemap but you don't define the 'typecheck' one. Very common mistake. - Add proper default rule for function pointers, now you can define a typemap such as: %typemap(in) SWIGTYPE ((*)(ANY)) {...} That will apply to all the pointer to functions. The rule in C++ also apply to the function 'reference', ie, in both cases typedef int (*fptr)(int a); typedef int (func)(int a); This was needed since it seems to be 'illegal' in C++ to do something like: void *ptr = static_cast(fptr); and probably, as for member functions, it is not warrantied that the pointer sizes will match. - Add the #error/#warning directives to swig's cpp. - Add the noblock option for typemaps, which is used as follows: supposed you a typemap, like this %typemap(in,noblock=1) Hello { .... } then the typemap will be inserted without the block imposed by the brackets, similar to %typemap(in) Hello "..."; So, why you don't just use the quote style?, because: 1.- The quote style doesn't get preprocessed, for example %typemap(in) Hello "$1= SWIG_macro($1);"; here, SWIG_macro doesn't get expanded 2.- Inside a quote typemap, you have to use quotes carefully %typemap(in) Hello "$1 = \"hello\" "; 3.- You can't make emacs and/or other editors to indent inside a string!. So, why do you want to remove the block?, because an extra block when not needed (no local variables in it): 1.- makes the code harder to read 2.- makes the code larger 3.- or in short, for the same reason we have the quote style. Version 1.3.26 (October 9, 2005) ================================ 10/08/2005: wsfulton [Php] Added 'throws' typemaps. 10/08/2005: wsfulton Fixes for languages that don't support multiple inheritance. The first non-ignored class in the public base class list is used for inheritance. by the proxy class. Previously, if the first class in the list was ignored, then the proxy class wouldn't have any base classes. 10/07/2005: mmatus Update more features to follow new convention, including: callback ref/unref except All of them use not only the feature as a flag, but also as code value. To deal with those features, we use now GetFlagAttr, which is similar to GetFlag, but instead or returning 1 or 0, it returns the attr value, if happens to be different of "0" of course. Now there are also more uniform directive names for the ones based in features, for example, for the old %newobject directive now we have tree directives defined: #define %newobject %feature("new") #define %nonewobject %feature("new","0") #define %clearnewobject %feature("new","") and so on for all the other feature directives. *** POTENTIAL INCOMPATIBILITY *** 09/30/2005: wsfulton Subtle change to some features. Previously it was not possible to disable many features once they had been enabled. This was for most features that behave as flags. These features now work as follows: %feature("name") // enables the feature %feature("name", "1") // enables the feature %feature("name", "0") // disables the feature %feature("name", "") // clears the feature In fact any non-empty value other than "0" will enable the feature (like C boolean logic). Previously "1", "0" or any other non-empty value would enable the feature and it would only be possible to disable the feature by clearing it (assuming there was no global enable). The following features are affected: allowexcept compactdefaultargs classic (Python) cs:const (C#) director exceptionclass (Python) ignore immutable java:const (Java) java:downcast (Java) kwargs modern (Python) new noautodoc (Python) nodefault nodirector noref notabstract nounref novaluewrapper python:maybecall (Python) python:nondynamic (Python) modula3:multiretval (Modula3) predicate (Ruby) trackobjects (Ruby) valuewrapper It is now possible, for example to ignore all methods/classes in a header file, except for a few targetted methods, for example: %feature("ignore"); // ignore all methods/classes %feature("ignore","0") some_function(int, double); // do not ignore this function %feature("ignore","0") SomeClass; // do not ignore this Class %feature("ignore","0") SomeClass::method; // do not ignore this method %include "bigheader.h" Removed %pythondynamic - it never worked properly. Use %pythonnondynamic instead. Removed %feature("nokwargs") - it wasn't fully implemented - use %feature("kwargs","0") instead. *** POTENTIAL INCOMPATIBILITY *** 09/25/2005: mkoeppe [Guile] Add "throws" typemaps. 09/24/2005: cfisavage [Ruby] Adds new %trackobjects functionality that maps C++ objects to Ruby objects. This functionality makes it much easier to implement mark functions for the garbage collector. For more information refer to the update documentation and examples. 09/20/2005: wsfulton [Perl] Patch 1116431 from Josh Cherry. Fixes non member functions inadvertently being called instead of member functions. 09/20/2005: wsfulton [Lua] Patch from Mark Gossage to add support for Lua-5.1, std::string, std::vector, std::exception and documentation. 09/14/2005: mmatus [Python] Add -nocppcast. Now the default behavior is to always use the cppcast operators. Before that was the case only when you used the -cppcast option. If this seems to break your code... your welcome!, it means it was broken before, and you never notice. If you thing the error is due to one of the SWIG typemaps, send us an example. Use -nocppcast only with very old C++ compilers that do not support the cppcast operations. So, here applies: This change doesn't break compatibility, it was broken before. 09/13/2005: wsfulton [Java] Fix for director methods when a class is passed by value as a parameter. 09/11/2005: mmatus Adding the module option to the %import directive. Now you can use it as %import(module="BigModule") foo.i where subfile could (or not) define the module name via the %module directive. The module option take precedence and it has the same effects than having the directive %module BigModule inside the imported file foo.i. You can use the option in mainly two cases: 1.- You used the -module option when you generated the module to be imported, and hence the module name in the imported %module directive is not really useful. 2.- The module you want to import is very large, and it has several .i/.h files. Then, if you just one to import a class or so from the module, says 'foo', and not the entire module via importing the main BigModule.i file, then you just do: %import(module="BigModule") foo.h or %import(module="BigModule") foo.i where foo.i contains the 'foo' declaration and maybe a couple of extra %include directives, as needed. 09/11/2005: mmatus Fix bug #1282637, about the -module option not having effect in places where it was needed. 09/11/2005: wsfulton When wrapping variables, ensure that none of the typemaps used for the set wrappers are used when generating the get wrappers. I doubt this was a problem for any languages except for the recently introduced null attribute in the out typemap (C# only). 09/08/2005: wsfulton More descriptive error messages when files fail to open. 09/06/2005: mmatus Allow a %define a macro inside another %define macro, for example %define hello(name, Type) %define name ## a(Type) %typemap(in) Type "hello;"; %enddef %enddef To learn how to use this new features in your own typemaps library, see python/cstring.i, python/cwstring.i and python/cwstrbase.i. [Python] Normalize the cstring.i implementation to use fragments, and add cwstring.i, which implements the same typemaps but for wchar_t strings. [Python] Bug fixed: 1247477, 1245591, 1249878 and others. 08/18/2005: wsfulton [Ruby] Implement support for SWIGTYPE* DISOWN typemap (like in Python) for better control of memory management, eg when adding an object created in Ruby to a C++ container. Patch #1261692 from Charlie Savage. 08/18/2005: wsfulton [Tcl] 64 bit platform fixes for the varargs handling in SWIG_GetArgs. This is an improved fix for bug #1011604 as suggested by Jeremy Lin. 08/18/2005: wsfulton [Tcl] Bug #1240469 - %newobject support for Tcl. Patch from Bob Marinier. 08/16/2005: wsfulton [Perl] Bug #1254494 - Fix for global namespace pollution by perl header files (bool define) prevented STL headers from being used on some systems, eg Windows with Visual Studio. 08/16/2005: wsfulton [Java] Bug #1240937 - Redefinition of __int64 typedef for Intel compilers. 08/15/2005: wsfulton [Xml] Bug #1251832 - C++ template may generate invalid XML file 08/15/2005: wsfulton [Lua] Support added for Lua. Patch #1242772 from Mark Gossage. It supports most C/C++ features (functions, struct, classes, arrays, pointers, exceptions), as well as lots of documentation and a few test cases & examples. 08/14/2005: wsfulton [Xml] Fix incorrect xml escaping in base class name when base class is a template. 08/13/2005: efuzzyone [CLISP] Added support for handling enums. Does not adds the return type declaration to the function definition, if a function returns void. 08/09/2005: mkoeppe New language module, Common Lisp with UFFI, from Utz-Uwe Haus. 08/09/2005: mkoeppe Fix the Lisp s-expression output module; it no longer complains about "unknown targets". 07/27/2005: wsfulton Modifications to STL wrappers so that it is possible for a user's %exception directive to be applied to the STL wrapper methods. Previously the following global %exception directive would not be used on the wrapper methods: %exception { try { $action } catch (...) { // handle uncaught exceptions } } This has been implemented by replacing %exception directives for specific STL wrapper methods with an exception specification declared on the wrapper methods. throws typemaps are now supplied for handling the STL exception specification. These can also be easily overridden, for example the std::out_of_range exception, which is used a lot in the STL wrappers, can be customised easily: %include "std_vector.i" %typemap(throws) std::out_of_range { // custom exception handler } %template(VectInt) std::vector; 07/22/2005: efuzzyone [CLISP] The clisp module for SWIG: - It can only handle C, clisp currently does not supports ffi bindings to C++. - It has two options, (a) -extern-all this will generate wrappers for all functions and variablestions, (b) -generate-typedef this will generate wrappers "def-c-type" wrappers for typedefs - Can handle pointers to functions, complex types such as n-dimensional arrays of pointers of depth d - Generates wrappers for constants as well as variables - Correctly distinguishes between the declaration of variables in structures and functions - Creates a defpackage "declaration" with the module name as the package name, the created package exports both functions and variables - tries to guess when should a pointer variable be declared as c-ptr or c-pointer 07/22/2005: wsfulton [C#] Changes to support C# structs returned by value. The changes required are: - Using an optional 'null' attribute in the out typemap. If this attribute is specified, then it is used for the $null special variable substitution. - The ctype used in the C/C++ wrappers is no longer initialised to 0 on declaration. Both of these changes fix the situations where an attempt was made to assign 0 to the returned struct. Marshalling structs as value types still requires user defined typemaps. See documentation for an example. 07/22/2005: wsfulton [C#, Java] Fix SWIG_exception usage to work with compilers that don't support empty macro arguments. Unfortunately this fix will stop usage of SWIG_exception being used within typemaps that use "" or %{ %} delimiters, but continues to work with typemaps using {} delimiters. Please use the SWIG_CSharpSetPendingExceptionArgument or SWIG_JavaThrowException methods instead as SWIG_exception is really intended as a platform independent macro for the SWIG library writers. 07/16/2005: mkoeppe [Allegro CL] Use specific foreign types rather than (* :void). Use *swig-identifier-converter*. 06/27/2005: wsfulton Functions declared as 'extern' no longer have an additional function declaration added to the wrapper files. There are some cases where SWIG does not get this right, eg bug #1205859 (extern functions with default arguments declared in a namespace). Also SWIG cannot get non-standard calling conventions correct, eg Windows calling conventions are usually handled like this: %{ #define DLLIMPORT __declspec(dllimport) #define STDCALL __stdcall %} #define DLLIMPORT #define STDCALL %inline %{ DLLIMPORT extern STDCALL void function(int); %} SWIG incorrectly generates: extern void function(int); To which there is no solution as SWIG doesn't handle non-standard calling conventions. The extra 'extern' function that SWIG generates is superfluous unless a user has forgotten to add the function declaration into the wrappers. The -noextern commandline argument is now redundant and a new commandline argument -addextern can be used to obtain the original behaviour. This shouldn't be necessary unless the header file containing the function declaration was inadvertently not added to the wrappers. To fix this add the function declaration into your wrappers, For example, replace: extern void foo(int); with: %inline %{ extern void foo(int); %} *** POTENTIAL INCOMPATIBILITY *** 06/22/2005: wsfulton [C#, Java, Modula3, Ocaml] The intermediary function names have been changed when wrapping variables to match the other language modules so that %extend for a member variable works uniformly across all language modules, eg: %extend ExtendMe { Var; }; %{ void ExtendMe_Var_set(ExtendMe *, double) {...} double ExtendMe_Var_get(ExtendMe *) {...} %} The methods implementing the get/set used to be: %{ void set_ExtendMe_Var(ExtendMe *, double) {...} double get_ExtendMe_Var(ExtendMe *) {...} %} This also changes the name of variable wrapper functions when using -noproxy. The original names can be generated with the -oldvarnames commandline option. *** POTENTIAL INCOMPATIBILITY *** Version 1.3.25 (June 11, 2005) ============================== 06/11/2006: mkoeppe [Guile] Fix handling of anonymous-enum variables. 06/10/2005: mkoeppe [Guile] Fix for function arguments that are passed by copy-of-value. Fix for global "const char *" variables. Fix testcases arrays_dimensionless, arrays_global. 06/08/2005: wsfulton Fix for when a base class defines a symbol as a member variable and a derived class defines the same symbol as a member method. 06/08/2005: wsfulton [C#] More fixes for virtual/new/override modifiers - when a method has protected access in base and public access in derived class. 06/02/2005: wsfulton Fix #1066363 - Follow convention of release tarball name matching directory name. 06/02/2005: wsfulton [C#, Java] Fix #1211353 - typesafe enums (and Java proper enums) wrappers when enum value is negative. 05/27/2005: wsfulton Modernised and tidied up Windows macros --> SWIGEXPORT, SWIGSTDCALL. They can be overridden by users via -D compiler directives if need be. 05/26/2005: wsfulton %csmethodmodifiers can be applied to variables as well as methods now. In addition to the default 'public' modifier that SWIG generates, %csmethodmodifiers will also replace the virtual/new/override modifiers that SWIG thinks is appropriate. This feature is useful for some obscure cases where SWIG might get the modifiers incorrect, for example with multiple inheritance and overriding a method in the base class. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 05/25/2005: wsfulton Added missing constructors to std::pair wrappers (std_pair.i) for all languages. 05/25/2005: wsfulton [C#] Added std::pair wrappers in std_pair.i 05/25/2005: wsfulton [C#] The C# 'new' and 'override' modifiers will be generated when a C++ class inherits methods via a C++ 'using' declaration. 05/25/2005: wsfulton Fix for exception specifications previously being ignored in classes that inherited methods from 'using' declarations, eg calls to Derived::bar below will convert C++ exceptions into a target language exception/error, like it always has done for Base::Bar. class Base { virtual bar() throw (std::string); }; class Derived : public Base { using Base::bar; }; 05/23/2005: wsfulton Fixes for detecting virtual methods in %extend for the -fvirtual option and C# override and new method modifiers. 05/23/2005: wsfulton [C#] The 'new' modifier is now generated on the proxy method when a method in a derived class is not polymorphic and the same method exists in the derived class (ie it hides the base class' non-virtual method). 05/23/2005: wsfulton [Java, C#] Fixes to detection of covariant return types - when the class hierarchy is more than 2 classes deep. 05/21/2005: wsfulton [Java] std::wstring typemaps moved from std_string.i to std_wstring.i 05/21/2005: wsfulton Fix for crash in DohStrstr, bug #1190921 05/21/2005: wsfulton [TCL] Fix for methods with similar names when showing list of names on error - bug #1191828. Patch from Jeroen Dobbelaere. 05/21/2005: wsfulton [TCL] long long overloading fix - bug #1191835, patch from Jeroen Dobbelaere. 05/21/2005: wsfulton Fix bug #1196755 to remove debug from swigtcl8.swg. 05/19/2005: wsfulton [C# and -fvirtual option] Fix for the override key not being generated in the derived class when a virtual method's return type was a typedef in either the base or derived class. Also ensures the method is eliminated when using the -fvirtual option. For example, Derived.method now has the C# override keyword generated: typedef int* IntegerPtr; struct Base { virtual IntegerPtr method(); }; struct Derived : Base { int * method() const; }; [C#] Fix for the override key being incorrectly generated for virtual methods when a base class is ignored with %ignore. 05/13/2005: wsfulton [Java] Fixes to remove "dereferencing type-punned pointer will break strict-aliasing rules" warnings in C wrappers when compiling C code with 'gcc -Wall -fstrict-aliasing'. Patch from Michael Cahill. This modifies many of the casts slightly, for example arg1 = *(DB_ENV **)&jarg1; to arg1 = *(DB_ENV **)(void *)&jarg1; 05/12/2005: wsfulton [C#] Support for C# attributes. C# attributes can be generated: 1) On a C/C++ type basis by specifying an inattributes and/or outattributes typemap attribute in the imtype or cstype typemaps (for C# return type or C# parameter type attributes). 2) On a wrapped method or variable by specifying a csattributes feature (%feature). 3) On a wrapped proxy class or enum by specifying a csattributes typemap. Examples are in the C# documentation (CSharp.html). 04/29/2005: wsfulton New configure option to turn off the default maximum compiler warning as they couldn't be removed even when overriding CFLAGS and CXXFLAGS with configure (./configure CFLAGS= CXXFLAGS=). To turn the maximum warnings off, run: ./configure --without-maximum-compile-warnings 04/28/2005: wsfulton Patch from Scott Michel which reworks the Java constructor and finalize/destructor typemaps, for directors to reduce the number of overall Java typemaps. Added the director_take and director_release typemaps to emulate other modules' __disown__ functionality. *** POTENTIAL INCOMPATIBILITY FOR JAVA DIRECTORS *** 04/28/2005: wsfulton [C#] Fixed problems due to the over eager garbage collector. Occasionally the garbage collector would collect a C# proxy class instance while it was being used in unmanaged code if the object was passed as a parameter to a wrapped function. Needless to say this caused havoc as the C# proxy class calls the C++ destructor when it is collected. Proxy classes and type wrapper classes now use a HandleRef, which holds an IntPtr, instead of a plain IntPtr to marshal the C++ pointer to unmanaged code. There doesn't appear to be any performance degradation as a result of this modification. The changes are in the proxy and type wrapper classes. The swigCPtr is now of type HandleRef instead of IntPtr and consequently the getCPtr method return type has also changed. The net effect is that any custom written typemaps might have to be modified to suite. Affected users should note that the implementation uses the new 'out' attribute in the imtype typemap as the input type is now a HandleRef and the output type is still an IntPtr. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 04/28/2005: wsfulton [C#] Support for asymmetric type marshalling added. Sometimes the output type needs to be different to the input type. Support for this comes in the form of a new optional 'out' attribute for the ctype, imtype and cstype typemaps. If this typemap attribute is not specified, then the type used for both input and output is the type specified in the typemap, as has always previously been the case. If this typemap attribute is specified, then the type specified in the attribute is used for output types and the type specified in the typemap itself is used for the input type. An output type is a return value from a wrapped method or wrapped constant and an input type is a parameter in a wrapped method. An example shows that char * could be marshalled in different ways, %typemap(imtype, out="IntPtr") char * "string" char * function(char *); The output type is thus IntPtr and the input type is string. The resulting intermediary C# code is: public static extern IntPtr function(string jarg1); 04/22/2005: mkoeppe (Matthias Koeppe) [Guile] Fix generation of "define-method" for methods of classes with a constructor. Reported by Luigi Ballabio. 04/15/2005: wuzzeb (John Lenz) [Chicken] For wrapped functions that return multiple values (using argout), SWIG CHICKEN now returns them as multiple values instead of as a list. They can then be accessed using (call-with-values). 04/14/2005: wuzzeb (John Lenz) [Chicken] + Added a whole bunch of new _runme scripts into the chicken test suite. Also fix some bugs these new scripts turned up. + Added optimization when returning a wrapped proxy class. Before, a minor garbage collection was invoked every time a function returned. + All the chicken Examples should now run correctly 04/14/2005: wsfulton [C#] More fixes for typemap matching when wrapping variables, in particular std::string, so that std::string variables can be easily marshalled with a C# string property using: %include "std_string.i" %apply const std::string & { std::string *variable_name }; std::string variable_name; (Recall that all class variables are wrapped using pointers) 04/05/2005: wuzzeb (John Lenz) [Chicken] + Added Examples/chicken/egg, an example on how to build a chicken extension library in the form of an egg. Also updated the documentation on the different linking options. + chicken test-suite now has support to check SWIG with the -proxy argument if there exists a _proxy_runme.ss file. + More fixes for overloaded functions and -proxy 03/31/2005: wsfulton Turned on extra template features for all languages which were previously only available to Python. This enables typemaps defined within a templated class to be used as expected. Requires %template on the templated class, %template() will also pick up the typemaps. Example: template struct Foo { ... %typemap(in) Foo "in typemap for Foo " or %typemap(in) Foo "in typemap for Foo " }; %template(Foo_i) Foo; %template() Foo; will generate the proper 'in' typemaps wherever Foo and Foo are used. 03/30/2005: mkoeppe (Matthias Koeppe) [MzScheme] Patch from Hans Oesterholt for supporting MzScheme 30x. 03/29/2005: wuzzeb (John Lenz) [Chicken] + Reallow older versions of chicken (1.40 to 1.89) by passing -nocollection argument to SWIG + %import now works correctly with tinyclos. (declare (uses ...)) will be exported correctly. + TinyCLOS proxy classes now work correctly with overloaded functions and constructors. 03/29/2005: wsfulton [Java] Patch from Scott Michel for directorout typemaps. Java directors require the directorout typemaps like the other languages now. The new typemaps provide fixes for methods where the return type is returned by reference (this cannot automatically be made thread safe though). 03/22/2005: wsfulton Enum casting fixes. Visual C++ didn't like the C type casting SWIG produced when wrapping C++ enum references, as reported by Admire Kandawasvika. 03/21/2005: wsfulton [Perl] SF #1124490. Fix Perl macro clashes when using Visual Studio's STL string, so now projects can #include . 03/21/2005: wsfulton Fixed %varargs which got broken with the recent default argument changes. Also works for Java and C# for the first time now. 03/17/2005: wuzzeb (John Lenz) [Chicken] + Fix a whole bunch of bugs in the chicken module. The entire test suite now compiles, with the exception of the tests that require std_vector.i, std_deque.i, and so on, which chicken does not have yet. + Add support for %exception and %typemap(exceptions). Exceptions are thrown with a call to (abort) and can be handled by (handle-exceptions) 03/15/2005: wsfulton [Java] Patch from Scott Michel for directors. Modifications to the typemaps giving users fine control over memory ownership and lifetime of director classes. Director classes no longer live forever by default as they are now collectable by the GC. 03/15/2005: wuzzeb (John Lenz) [Chicken] Add support for adding finalizers garbage collected objects. Functions that return new objects should be marked with %newobject and input arguments which consume (or take ownership) of a pointer should be marked with the DISOWN typemap. Also add support for correctly checking the number of arguments passed to a function, and raising an error if the wrong number are passed. 03/14/2005: wuzzeb (John Lenz) Add --without-alllang option to configure.in, which is the same as passing all the --without-python --without-perl5 etc... that Matthias added. 03/09/2005: wsfulton [Php] Memory leak fix for functions returning classes/structs by value. 03/08/2005: wsfulton [Perl] Fix for Perl incorrectly taking memory ownership for return types that are typedefs to a struct/class pointer. Reported by Josh Cherry. 03/07/2005: wsfulton [C#] Various exception changes for the std::vector wrappers. These now more accurately mirror the same exceptions that System.Collections.ArrayList throw. 03/07/2005: wsfulton [C#] Fix undefined behaviour after any of the std::vector methods throw an exception. 03/07/2005: wsfulton [C#] When null is passed for a C++ reference or value parameter, the exception thrown has been corrected to an ArgumentNullException instead of NullReferenceException as recommended in the .NET Framework documentation. The default throws typemaps turn a C++ exception into an ApplicationException, not a SystemException now. 03/07/2005: wsfulton [C#] Numerous changes in C# exception handling have been made over the past few weeks. A summary follows: The way in which C++ exceptions are mapped to C# exceptions is quite different. The change is to fix C# exceptions so that the C++ exception stack is correctly unwound as previously C++ exceptions were being thrown across the C PInvoke layer into the managed world. New typemap attributes (canthrow and excode) have been introduced to control the mapping of C++ to C# exceptions. Essentially a callback into the unmanaged world is made to set a pending exception. The exception to throw is stored in thread local storage (so the approach is thread-safe). The typemaps are expected to return from unmanaged code as soon as the pending exception is set. Any pending exceptions are checked for and thrown once managed code starts executing. There should be minimal impact on execution speed during normal behaviour. Full details will be documented in CSharp.html. The SWIG_CSharpThrowException() function has been removed and replaced with the SWIG_CSharpSetPendingExceptionArgument() and SWIG_CSharpSetPendingException() functions. The original name has been deliberately changed to break old code as the old approach was somewhat flawed. Any user defined exceptions that follow the same pattern as the old approach should also be fixed. Numerous new .NET framework exceptions are now available for easy throwing from unmanaged code. The complete list is: ApplicationException, ArithmeticException, DivideByZeroException, IndexOutOfRangeException, InvalidOperationException, IOException, NullReferenceException, OutOfMemoryException, OverflowException, SystemException, ArgumentException, ArgumentNullException and ArgumentOutOfRangeException. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 05/05/2005: mmatus Fix several memory leaks around. Even when we survive knowning swig is a memory leak factory, it was a little out of control. To run std_containers.i in the python test-suite, swig was using ~260MB, now it uses 'only' ~40MB, which is the same ammount that g++ uses, so, is not that bad. In the process, I found a couple of extra Deletes, which in some cases could trigger seg. faults and/or DOH/asserts. [python] Better support for directors + exception. More verbose errors and added an unexpected exception handler. [python] Fix memory leak for the std::vector > case,reported by Bo Peng. [python] Fix SwigPyObject compare problem reporte by Cameron Patrick. [python] Fix several warnings in the generated code for gnu-gcc, Intel and VC7.1 compilers. 02/25/2005: wuzzeb (John Lenz) Update documentation to use CSS and
instead of
I used a script to convert the docs, and it set all the box classes to be "code". There are actually 4 different classes, "shell", "code", "targetlang", and "diagram". We need to go through and convert the divs depending on what they contain. 02/23/2005: mmatus [Python] Added option -nortti to disable the use of native C++ RTTI with directors (dynamic_cast<> is not used). Add more code for directors to detect and report errors in the python side. Extend the use of SWIGINTERN whenever is possible. Remove template warnings reported by VC7.1. Remove warnings reported by gcc/g++. Finally you can compile using g++ -W -Wall -c mymodule_wrap.cxx and no spurious errors will be generated in the wrapper code. 02/23/2005: wuzzeb (John Lenz) Added -external-runtime argument. This argument is used to dump out all the code needed for external access to the runtime system, and it replaces including the files directly. This change adds two new virtual functions to the Language class, which are used to find the language specific runtime code. I also updated all languages that use the runtime to implement these two functions. 02/22/2005: mmatus Fix %template + private error SF#1099976. 02/21/2005: mmatus Fix swigrun.swg warnings reported when using "gcc -W -Wall" (static/inline not used in front of a function declaration), and add SWIGUNUSED attribute to avoid unused warnings elsewhere. Fix unused variable warnings. [Python] Use new SWIGUNUSED attribute to avoid warnings in SWIGINTERN methods. [Python] Fix PyOS_snprintf for python versions < 2.2 (SF #1104919). [Python] Fix map/multimap to allow empty maps (reported by Philippe Hetroy). [Docs] Add some documentation to Python.html and SWIGPlus.html, including for example the fact that 'friends' are now supported. 02/21/2005: wsfulton [PHP] Patch from Olly Betts, so that wrappers compile with Zend thread safety enabled. 02/17/2005: wsfulton Memory leak fix in some of the scripting language modules when using default arguments in constructors. The scripting language was not taking ownership of the C++ object memory when any of the constructors that use default arguments was called. 02/16/2005: wsfulton SF #1115055: Failed make install. Patch from Rob Stone. 02/16/2005: wsfulton [Java] SF #1123416 from Paul Moore. Correct memory allocation for STRINGARRAY typemaps in various.i. 02/15/2005: wsfulton Disabled typemap search changes for now (see entry 19/12/2004). It breaks old typemaps, lengthens the execution time by about 25% and introduces inconsistencies. 02/15/2005: wsfulton swig -help follows other software by printing to stdout instead of stderr now. swig -version also displays to stdout instead of stderr now. Behaviour reported by Torsten Landschoff. 02/15/2005: wsfulton [Ruby] Fix for the less commonly used ordering of %include and #include, so that the generated code compiles. Bug reported by reported by Max Bowsher. %include foo.h %{ #include foo.h %} 02/15/2005: wsfulton [C#, Java] SWIG_exception macro will now return from unmanaged code / native code as soon as it is called. Fixes possible JVM crashes and other code unexpectedly being executed. Note SWIG_exception is only occasionally used by SWIG library writers, and is best avoided by SWIG users. 02/15/2005: wsfulton [C#, Java] Typemaps can now be targeted at global variable names and static member variable names. Previously the typemaps for the setters were ignored, for example: %typemap(in) int globalint "..." int globalint; 02/13/2005: mkoeppe (Matthias Koeppe) [Guile] Add %typecheck for SWIGTYPE, add %typecheck for ptrdiff_t, fix typemaps for size_t. [Pike] Merge patch from Torsten Landschoff for improved Pike configuration. 02/12/2005: mkoeppe (Matthias Koeppe) New configure switches --without-tcl, --without-python etc. allow to disable the search for installed languages. 01/31/2005: wuzzeb (John Lenz) - Add DohSortList to DOH - Improve the runtime type system: + Speed. Type loading is now O(n log n) instead of O(N^2), which for large modules is a huge improvement. + A whole bunch of functions in swigrun.swg no longer need the swig_type_list_handle passed to them. The only one left is TypeQuery. This also makes runtime.swg a lot smaller. + Split up swig_type_info structure into two structures (swig_type_info and swig_cast_info) + Store a pointer to a swig_type_info rather than just the type name string in the linked list of casts. First off, this makes the guile module a little faster, and second, the SWIG_TypeClientData() function is faster too. + Add the idea of a module into the type system. Before, all the types were stored in one huge linked list. Now, another level is added, and the type system stores a linked list of modules, each of which stores an array of types associated with it. + For more information of how the runtime type system now works, please see Doc/Manual/typemaps.html and Doc/Devel/runtime.txt - Update all language modules to use the new type system. The changes to each language module are minor. All languages are now able to use runtime.swg for external access to the type system. Before only python and perl did. - [guile, mzscheme, ocaml, and php4] These languages opened up the init function inside the .cxx code, and any code in the .swg files in the init section was inside this function. This was a problem for swiginit.swg, which needs to be inserted before the SWIG_init function is opened. Thus I changed these languages to be like python or perl, where the init function is declared in the .swg file. - [Ruby] Instead of moving the init function to the .swg file, I added a new section initbeforefunc, and then added %insert(initbeforefunc) "swiginit.swg" - [MzScheme] Fix enums and fix Examples/Makefile.in so that if multiple -I arguments are specified in the INCLUDES variable, each gets a ++ccf. - [Guile GH] Update Guile GH to use the new type system. See Doc/Manual/Guile.html for how smobs are now used. 01/11/2005: wsfulton [C#] New typemap called 'csconstruct'. The code in this typemaps was previously hard coded and could not be customised by a user. This typemap contains the code that is generated into a proxy class's constructor. [Java] New typemap called 'javaconstruct'. The code in this typemaps was previously hard coded and could not be customised by a user. This typemap contains the code that is generated into a proxy class's constructor. Another typemap named 'javaconstruct_director' is used instead when the proxy class is a director class. [C#, Java] If a C++ class did not have a default constructor, a protected default constructor was automatically generated by SWIG. This seems is unnecessary and has been removed and thereby giving the user almost complete control over the generated code along with the new typemaps above. 19/12/2004: mmatus [Disabled, see entry 02/15/2004] - Fix typemap search, now the "out" typemap search is done as follows int *Foo::foo(int bar) -> int *Foo::foo(int bar) -> int *Foo::foo -> int *foo(int bar) -> int *foo -> int * then, now you can be more specific, and define /* apply only for 'Foo::foo' method */ %typemap(out) int * Foo::foo(int *bar) ...; /* apply for all 'foo' functions/methods */ %typemap(out) int * foo(int *bar) ...; %inline { struct Foo { int *foo(int *bar); }; } 15/12/2004: mmatus - More fixes for templates and template default args. See template_default.i for scary cases that now are supported, besides the already ugly STL/std cases. - Cosmetics and more use of 'const' where it was implicit. - Other fixes for OSS, which is now working again with 1.3.25. Version 1.3.24 (December 14, 2004) ================================== 12/12/2004: wuzzeb (John Lenz) [Chicken] Fix a bunch of bugs relating to -proxy support + non-class variables now export properly using -proxy + static member functions now export properly using -proxy + member class variables now export properly using -proxy + added a -nounit argument, which does not export the (declare (unit ...)) + correctly install swigclosprefix.scm + constants (enums, defines) now correcly export when using -proxy 12/11/2004: wsfulton configure fix for when more than one version of jni_md.h is found in the Java include directory (was generating lots of sed error messages). 12/08/2004: wsfulton [Java] Fixes to arrays_java.i so that one can apply the array typemaps to functions taking pointers as input, eg %include "arrays_java.i" %apply int[] {int*}; void foo(int *a); 12/05/2004: wsfulton [Java] Director mods contributed by Scott Michel. New typemaps directordisconnect and directordisconnect_derived for the swigDirectorDisconnect() method. Also fix to get the javapackage typemap working again. 12/05/2004: mmatus - Finishing the fixes for templates + default template args + specializations. - [Python] Now we use the new templates + default template args in the std/STL library. That means the internal swig files are getting uglier since we now support the original declarations: template > class vector { .... }; template, class _Alloc = std::allocator > > class map { .... }; and the user can use the %template directive as %template() std::vector; %template() std::vector >; %template() std::vector >; Now we are closer to the cleaning/rewriting of the python std/STL support, such that we recover support for MSVC++ 6.0, and we can add support for other languages too. 12/02/2004: wsfulton [Java] Fix for directors when wrapping methods using a member enum and typesafe/proper enums enabled. 12/01/2004: mmatus - Fix typemaps to work with templates and default template args, ie template struct Foo { }; %typemap(in) Foo *{...} %typemap(out) Foo *{...} Foo * foo( Foo *f1, Foo *f2); now 'f1', 'f2' and the return value resolve the provided typemaps properly. This is highly needed for proper STL support, see new std_basic_string.i, std_sstream.i, etc. - Added std_sstream.i, and fix std_basic_string.i to use the new typemaps + template def. arg mechanism. Also, added the needed std_alloc.i. Now, all the containers can be modified to support std::allocator, like in: template > class vector { public: .... }; This change is only completed by now for basic_string. - Fix for smart pointers + members + extensions: %extend Foo { int extension(int i, int j) { return i; } int extension() { return 1; } } %inline %{ class Foo { public: int y; static const int z; }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } Foo *operator->() { return f; } }; now you can f = Foo() f.y = 3 a = f.z f->extension() b = Bar(f) b.y = 3 a = b.z b->extension() - Other small errors fixes, mostly python. 11/25/2004: wsfulton [Java] Numerous director bug fixes so that the correct java types and canonicalized types in the JNI code are emitted. Use of the $javaclassname special variables in the director typemaps now consistent with the non-director typemaps. The types used for typemap lookups are also corrected in a few places. If you previously had your own director typemaps, ensure they are using the correct C++ type. *** POTENTIAL INCOMPATIBILITY FOR JAVA DIRECTORS *** 11/25/2004: wsfulton const enum SWIGTYPE & typemaps added. These wrap const enum references as if they were passed by value. Const enum references thus work the same as const reference primitive types such as const double &, const int & etc. Typemaps added for Java, C#, Ruby, Tcl, Perl and Pike. 11/25/2004: wsfulton [Java, C#] New special variable: $*javaclassname, similar to $javaclassname and $&javaclassname. The new one removes a pointer from the C type before obtaining the Java class name. One or more of $javaclassname, $&javaclassname or $*javaclassname may now appear in a typemap. Likewise for C# using csclassname instead of javaclassname. 11/25/2004: wsfulton The last vestiges of enums being handled as integers removed from the internals. The wrapper methods use the enum type rather than an int now. The net result is added type safety for enums when handled as pointers, references etc. Previously in situations such as a method taking a pointer to an enum, a pointer to an int or a pointer to an enum of some other type could inadvertantly be passed to the method. This is now fixed as the descriptor for an enum is no longer based on an int, but the enum type instead. Anonymous enums are still handled as integers. The consequence for scripting language users in correct usage of enums should not be noticeable. There is no change for any of the languages where enums are passed by value - most of the scripting languages will still accept an integer for an enum value and the strongly typed languages still use either typesafe enums, integers or proper enums depending on what the user configures. For Java and C# users a change in the typewrapper class name has occurred (for enum pointers, references etc). For example: enum Numbers { one=1, two }; enum Numbers* number(); In Java and C# this must now be coded as SWIGTYPE_p_Numbers n = modulename.number(); rather than SWIGTYPE_p_int n = modulename.number(); *** POTENTIAL INCOMPATIBILITY *** 11/21/2004: wsfulton/mmatus Added missing deprecated warning for %name and remove remaining %name usage in the SWIG libraries. 11/21/04: mmatus - [Python] Adding the PySwigObject to be used for carrying the instance C/C++ pointers. This is used instead of string and PyCObjects. The new PySwigObject is even safer than PyCObject, and more friendly than plain strings: now you can do print a.this print str(a.this) _00691608_p_A print long(a.this) 135686400 print "%s 0x%x" % (a.this, a.this) _00691608_p_A 0x8166900 the last one is very useful when debugging the C/C++ side, since is the pointer value you will usually get from the debugger. Also, if you have some old code that uses the string representation "_00691608_p_A", you can use it now again using 'str(ptr)', or by calling 'str = PyObject_Str(obj)' in the C/C++ side. This change is mainly for nostalgic swig users that miss the string representation, but also allows to say again if a.this == b.this: return "a is b" and well, since the change were really simple, maybe in the future we will be able to do next = a.this + 1 or add native python iteration over native C/C++ arrays, ie, no need to create/copy new tuples when returning and array or vector. Also, a PySwigPacked object was adding to carry a member method pointer, but this is probably a temporal solution until a more general object for methods is added. Be aware that to simplify maintaining and compatibility with other tools, the old string and PyCObjects representation could disappear very soon, and the SWIG_COBJECTS_TYPES or SWIG_NO_OBJECT_TYPES macros will have no effect at compilation time. Still, the three mechanisms are present in the code just for testing, debugging and comparison purposes. 11/21/04: mmatus - [Python] Adding back support for using the swig runtime code inside the user code. We just allow the user to include the minimal code needed to implement the runtime mechanism statically, just as in done in the swig modules. To use the swig runtime code, for example with python, the user needs include the following: #include // or using your favorite language #include #include // or using your favorite language #include the files swigrun.swg, pyrun.swg and runtime.swg can be checked out by using swig -co, or they can simply be found by adding the swig lib directory to the compiler include directory list, for example SWIGLIB=`swig -swiglib` c++ -I${SWIGLIB} .. of better, using the CPPFLAGS, but that depends on your environment. This change can be ported to the other languages too, you just need to isolate the needed runtime code in a single file like 'pyrun.swg', and provide the SWIG_Runtime_GetTypeList() method. Look at the Lib/python/pyrun.swg file and the Examples/python/swigrun example. 11/15/04: mmatus - Fix mixed_types.i + gcc-3.4, ie, arrays + references + typedefs - Fix multidim arrays + typedefs,ie typedef char character[1]; typedef character word[64]; - Process protected/private bases in the same way before we process protected/private members, ie, we check for constructors, operator new, virtual members, etc. - Fix Ruby/Java to work (or ignore) multi-inheritance + directors. Allow other languages to define if it is supported or not. - Now you can run SWIG_FEATURES="-directors -dirprot" make check-ruby-test-suite make check-python-test-suite make check-java-test-suite make check-ocaml-test-suite and you will get only 'real' errors. ruby and python compile with no errors, java shows some problems. Version 1.3.23 (November 11, 2004) ================================== 11/05/2004: wsfulton Patch #982753 from Fabrice Salvaire: Adds dependencies generation for constructing makefiles. New command line options -MF -MD -MMD to work with the current options -M and -MM. These options are named the same and work the same as in gcc. 11/05/2004: wsfulton %ignore/%rename changes for methods with default arguments to mirror %feature behaviour. See previous entry. *** POTENTIAL INCOMPATIBILITY *** 11/04/2004: wsfulton %feature improvements for fine tuning when wrapping methods with default arguments. Any %feature targeting a method with default arguments will apply to all the extra overloaded methods that SWIG generates if the default arguments are specified in the feature. If the default arguments are not specified in the feature, then the feature will match that exact wrapper method only and not the extra overloaded methods that SWIG generates. For example: %feature("except") void hello(int i=0, double d=0.0); void hello(int i=0, double d=0.0); will apply the feature to all three wrapper methods, that is: void hello(int i, double d); void hello(int i); void hello(); If the default arguments are not specified in the feature: %feature("except") void hello(int i, double d); void hello(int i=0, double d=0.0); then the feature will only apply to this wrapper method: void hello(int i, double d); and not these wrapper methods: void hello(int i); void hello(); This has been introduced to make %feature more powerful to ease the migration to new default arguments wrapping approach. *** POTENTIAL INCOMPATIBILITY *** If you previously had a %feature and didn't specify the default arguments, you will have to add them in now or you can obtain the original behaviour by using %feature("compactdefaultargs"). 11/04/2004: wsfulton [C#] Typemaps for std::vector added into std_vector.i. The proxy classes generated are modelled on the .NET ArrayList class. This isn't quite ready for general consumption yet, but will work with vectors of primitive types and some classes. 10/3/2004: wuzzeb (John Lenz) [GUILE] The -scm interface is now the default. The old GH interface can still be enabled by passing -gh to SWIG. 10/2/2004: mmatus - More fixes for namespace + class declarations. As an extra bonus, we get %template support for static/members class methods, ie, now you can say: namespace space { struct A { template static void fooT(Y y) { } }; } struct B { template void barT(Y y) {} }; %template(foo) space::A::fooT; %template(foo) space::A::fooT; %template(foo) space::A::fooT; %template(bar) B::barT; %template(bar) B::barT; %template(bar) B::barT; and call A.foo(1) b = B() b.bar(1) note the methods are emitted inside the classes, and hence, the %template name refers to the 'member' method name, not a global namespace name. 10/31/2004: mmatus - Solve namespace + class declarations, as in namespace foo { struct Bar; struct Foo { }; } struct foo::Bar : Foo { }; see namespace_class.i for more examples. - Fix %template directive to properly use namespaces, including the case: namespace one { template struct Ptr {}; } namespace one { struct Obj1 {}; typedef Ptr Obj1_ptr; %template(Obj1_ptr) Ptr; } namespace two { struct Obj2 {}; typedef one::Ptr Obj2_ptr; %template(Obj2_ptr) one::Ptr; } this is done by using the namespace name 'one' to create a namespace node to emit the template instantiation, just as before, but the template parameters are resolved and qualified in the current namespace ('one' or 'two'). This is same way that typedef works. This resolve the smart_pointer_namespace2.i case, and at the same time, several other ones where before swig was generating the "Can't instantiate template 'xx' inside namespace 'yy'" error message. In fact, that error doesn't exist anymore. You can only get an error if you use a bad namespace name or so. 10/30/2004: mmatus - [ruby] Directors fixes: - enums and std::strings are working now (several reports in bug track system) - added patch 1025861 for director + exceptions *** Attention ***: ruby with directors + protected members work with version 1.7+. Older versions seems to have a broken signature for'rb_protect'. If you need to use an old version, look at http://excruby.sourceforge.net/docs/html/ruby__hacks_8hpp-source.html for workarounds. - [ruby] Fix memory allocation problem in typemap (bug 1037259) - [tcl] Fix (enums|constants) + namespace option (reported by jason.m.surprise@intel.com). - [perl] Add patch 962168 for multiple inheretance - Fix 'defined' as variable name. 10/29/2004: wsfulton Seg fault fix for global scope operator used for friend methods: class B { friend void ::globalscope(); ... }; 10/28/2004:mmatus - Added module and swig option "templatereduce" to force swig to reduce any type needed with templates, ie, in these cases %module("templatereduce") test template struct A { }; typedef int Int; %template(A_Int) A ==> %template(A_Int) A typedef B* Bp; %template(A_Bp) A ==> %template(A_Bp) A swig reduces the types Int and Bp to their primitives int and B*. This is closer to the usual compiler resolution mechanism, and it is really needed sometimes when you mix templates + typedefs + specializations. Don't use it if you don't have any problem already, since the type reduction can interfere with some user typemaps, specially if you defined something like typedef int Int; %typemap(in) Int ...; in this case, when you use the "templatereduce" option, swig will ignore the user typemap, since the "typedef int Int" will take precedence, and the usual "int" typemap will be applied. Note that the previous case is not common, and should be avoided, ie, is not recommended to use a typedef and a typemap at the same time, specially if you are going to use templates + specializations. - Directors: virtual destructor is always emitted now, this doesn't cause any harm, and could solve some nasty and mysterious errors, like the one mentioned by Scott. also the destructor is not in-lined, so, that can solve some other mysterious errors when mixing directors + imports + embedded applications + some specific compilers. 10/27/2004: wsfulton [C#] typemaps.i library file with INPUT, OUTPUT and INOUT typemaps added. 10/27/2004: wsfulton [Java] std::wstring typemap fixes in std_string.i from Russell Keith-Magee. 10/25/2004: mmatus - Using + namespace is working now (using_namespace.i). - Derived + nested classes is working now (deriver_nested.i), but of course, we are still waiting for the nested class support. - Directors: - unnamed parameters support, - protected constructor support (automatic and with dirprot mode), - detection of really needed protected declarations (members and constructors) now is done automatically. Even if you don't use the 'dirprot' mode, swig will wrap what is minimally needed (and protected) for the code to compile. what is public, as usual, is always wrapped, and if you use the 'dirport' - Final fixes for the OSS to compile with SWIG 1.3.23 (my very very ugly C++ + templates + everything mounters wrap). 10/25/2004: wsfulton [C#] New commandline option -dllimport. This enables one to specify the name of the DLL for the DllImport attribute. Normally this name comes from the module name, so now it is possible to override this: swig -csharp -dllimport xyz example.i will generate for all the wrapped PInvoke methods: [DllImport("xyz", EntryPoint="...")] public static extern ... The wrappers from many different SWIG invocations can thus be compiled into one DLL. A new special variable $dllimport can also be used in typemaps, pragmas, features etc. This will get translated into the value specified by -dllimport if specified, otherwise the module name. 10/22/2004: wsfulton [Java] Patch #1049496 from Scott Michel fixes directors methods with enums when wrapped with typesafe or proper Java enums. 10/21/2004: wsfulton Fixes for default arguments in director constructors (Python, Ruby, Ocaml). 10/21/2004: mmatus - [Python] Add the '-cpluscast' option to enable the 'new' C++ casting operators, such as 'static_cast', inside the typemaps. By default swig use the old C cast style, even when parsing C++. - [Python] Add the '-new_vwm' option to enable the new SwigValueWrapper mode. Now this is mainly for testing that the typemaps are really safe for any future solution, but you can use it if you have a very strange error with default cosntructors missing + %apply + %typemap, and if everything else fails (see valuwrapper_opaque.i for alternative and current solutions). If you are a user that don't know what is SwigValueWrapper, don't even try it. - [Python] Add the '-noh' option to be used with directors and when you prefer to disable the generation of the director header file. If not used, swig will work as usual generating both the wrap.cxx and wrap.h files. If you use it, swig will only generate wrap.cxx. 10/21/2004: wuzzeb (John Lenz) - If you define SWIG_TYPE_TABLE when compiling a wrapper file, the runtime types will be stored in the given type table name. Using this, you can seperate different modules to share their own type systems. -DSWIG_TYPE_TABLE=Mytable - [Python] If you define SWIG_STATIC_RUNTIME then the type information will be static to this wrapper. Nothing will be shared with any other modules - [Python] If you define SWIG_LINK_RUNTIME, then instead of using the new way of sharing type information, the wrapper will expect to be linked against the Lib/linkruntime.c file. Any modules compiled with SWIG_LINK_RUNTIME and linked against linkruntime.c will all share type information. 10/20/2004: mmatus - [Python] Initial fix for python/import example. Please update the Makefile (autoconf, configure, etc, expert), since now probably is only working with g++, icc and a few other compilers that have the -shared option. We need to create additional shared libraries for the virtual destructors. Old and usually forgotten C++ requirement. Same fix need to be used in perl, I think. - [Python] Fix generation of header file for directors, now directors.swg is also included, so, it can be really used from C++, and it solves some problem with compiler that require that, even with the simple swig inclusion. - [Python] Reordering the methods and moving some bodies outside the class declaration. This is needed due to some gcc-2.96 internal compiler errors. It seems the PYTHON class is getting too large to been declared and defined at the same time. - Add the -oh option to change the output header file name if needed: swig -c++ -python test.i -o test.CC -oh test.HH this is mainly needed when using directors, and if the current default header file name is not good for you, which is generated as follow: swig -c++ -python test.i => test_wrap.h swig -c++ -python test.i -o test.CC => test.h 10/20/2004: wsfulton 1) Compact default arguments feature added. This feature allows one to use the default argument code generation that was used in SWIG-1.3.22 and earlier versions. It produces more compact wrappers as only one wrapper method is generated for any method with default arguments. So the advantage is it generates less code but has the original limitations, like it it does not work with all default arguments and default arguments cannot be taken advantage of in the strongly typed languages (C# and Java). It is implemented via the usual %feature mechanism: %feature("compactdefaultargs"); 2) Keyword arguments (kwargs) are working again for default arguments in the languages that support it, ie, Python and Ruby. The new default argument wrapping approach using overloaded methods cannot support kwargs so the compact default argument feature is automatically turned on when kwargs are specified, by %feature("kwargs"). 3) Compact default arguments are also automatically turned on when wrapping C (not C++) code. This is to support the bizarre notion of default arguments for C code. 10/20/2004: wsfulton Overloaded templated functions in namespaces also working now. Templated functions with default arguments in namespaces too. 10/19/2004: mmatus - Allow to disable the new SwigValueWrapper mechanism, if you add the following line in your language main. /* Turn on safe value wrapper use mode */ Swig_value_wrapper_mode(1); Now is only active in python. All the other languages are using the old resolution, but they can also use the "valuewrapper"/"novaluewrapper" features to fix some of the old broken cases. Note, however, that not all the broken cases can be solved in that way. The new mechanism seems to be working fine in perl, ruby and tcl, but failing in some typemaps in java. Hence, is upto the language maintainer to test it, and decide to enable it or not. Look at the valuewrapper_opaque.i for examples. - Fix more SwigValueWrapper cases when the new mechanism is active. Now it also check for local typemap variables, see valuewrapper_opaque.i for an example when this is needed. But again, this extra checking will only be activated when using the new value wrapper mode. - [Python] Fix variable wrapping of classes with private assign operators. It should be easy to fix in all the other modules, instead of checking if (!Getattr(n,"immutable")) ... you need to verify if (is_assignable(n)) ... Look at the private_assign.i for an example. 10/18/2004: mmatus - %features "director"/"nodirector" now work as expected. - General fixes in %feature to resolve function decl properly, %feature("hello") foo(); char foo() -> f() // was working char *foo() -> f().p // it wasn't - Template + specialization + default template args now is working, (don't confuse with template + default arg values, that was solved before), now this ugly case is working: template > struct Vector { Vector(T a){} }; template <> struct Vector { Vector(){} int foo() { return 0; } }; %template(V_c) Vector >; %template(V_i) Vector; // picks Vector > %template(V_d) Vector; // picks the specialization this is needed for automatic STL support (later will be). - Fix the template + typedef errors in test-suite, which probably will fix another group of strange template + namespaces + typedefs errors. - %warnfilter is working better now, parser.y tries to use them when needed. - **** New default type resolution method (stype.c) ***** It preserves the original mixed types, then it goes 'backward' first deleting the qualifier, then the inner types, for example: typedef A *Aptr; const Aptr&; r.q(const).Aptr -> r.q(const).p.SWIGTYPE r.q(const).p.SWIGTYPE -> r.p.SWIGTYPE r.p.SWIGTYPE -> r.SWIGTYPE r.SWIGTYPE -> SWIGTYPE enum Hello {}; const Hello& hi; r.q(const).Hello -> r.q(const).enum SWIGTYPE r.q(const).enum SWIGTYPE -> r.enum SWIGTYPE r.enum SWIGTYPE -> r.SWIGTYPE r.SWIGTYPE -> SWIGTYPE int a[2][4]; a(2).a(4).int -> a(ANY).a(ANY).SWIGTYPE a(ANY).a(ANY).SWIGTYPE -> a(ANY).a().SWIGTYPE a(ANY).a().SWIGTYPE -> a(ANY).p.SWIGTYPE a(ANY).p.SWIGTYPE -> a(ANY).SWIGTYPE a(ANY).SWIGTYPE -> a().SWIGTYPE a().SWIGTYPE -> p.SWIGTYPE p.SWIGTYPE -> SWIGTYPE before it always stops after finding ref/pointer/enum/array/etc. Now, then, you can define (use and apply) 'higher' typemaps such as: %typemap(in) SWIGTYPE* const& %typemap(out) char FIXSIZE[ANY] %typemap(in) SWIGTYPE* const& %typemap(in) const enum SWIGTYPE& %typemap(in) SWIGTYPE[ANY][ANY] %typemap(in) const char (&)[ANY] It is possible with this change that previous typemaps that were defined (but ignored), now will start to work. Also, it is necessary check for the '%typemap(varin) SWIGTYPE[]', before it was usually not defined (but char[] was), and that can produce some inconsistencies. *** POTENTIAL INCOMPATIBILITY *** This change was needed for STL, since std::vector std::vector, etc, will always generate methods that mix const references with the vector type. Now that is working, all the std::container specialization will not be needed anymore, well, in theory. In the practice, everythin is working as before until the proper mixed types are defined and the libraries simplified to use them. - Change the behavior of extern "java"/"fortran"/"etc", now swig produces a warning, and use extern "C" instead. The warning can also be disable with the "-w 313" flag. (WARN_PARSE_UNDEFINED_EXTERN). - SwigValueWrapper is now more selective (lang.cxx). [Perl/Tcl] - Fix some typemaps (perl/tcl) to work properly with SwigValueWrapper. This was not a problem with SwigValueWrapper, but with the typemaps that now are safe to use with %apply. [Python] - Fix %callback/%pythoncallback work now as before after the def args changes. Also, %callback now is an alias for %pythoncallback, so, they do the same. [Python/Ruby] - %callback is more usable and uniform: %callback("%s_cb") foo(); // for both, python/ruby %callback("%s_cb"); // for both, python/ruby %callback(1) foo(); // only in python. 10/17/2004: arty [OCAML] - Tweak to enum typing for soundness in the presence of multiple modules. - global functions are now unambiguous in multiple loaded modules. - Fixed test case code to build multimodule test cases correctly. - There is no way to share overload resolution across modules because of soundness issues. If the user wants to call some function foo from an arbitrary module bar, they will have to use Bar._foo to call it correctly. Later I will fix the camlp4 module to do something clever in this case. - Promided performance overhaul of class mechanism. - Removed symbol hack for ocaml-3.07 and below which is not needed for ocaml-3.08 and above. 10/16/2004: wuzzeb (John Lenz) [CHICKEN] - Completly change how chicken.cxx handles CLOS and generic code. chicken no longer exports -clos.scm and -generic.scm. The clos code is exported directly into the module.scm file if -proxy is passed. - The code now always exports a unit. Running the test-suite is now majorly broken, and needs to be fixed. - CLOS now generates virtual slots for member variables similar to how GOOPS support works in the guile module. - chicken no longer prefixes symbols by the module name, and no longer forces all names to lower case. It now has -useclassprefix and -closprefix similar to how guile handles GOOPS names. 10/16/2004: wsfulton Templated functions with default arguments working with new default argument wrapping approach. The new approach no longer fails with the following default argument pattern (previously failed with some primitive types, like unsigned primitive types): template int foo(const T& u = T()); %template(foo) foo; This relies on the templated function overloading support just added, so all the combinations of overloading by template parameters and normal parameters as well as overloading with default parameters works. 10/16/2004: wsfulton Added support for the large range of templated function overloading that C++ supports. - Overloaded templated functions, eg template int overload(T t); template int overload(T t, const T &r); - Fixes where the templated type is not used in the parameter list, eg template void xyz(); template<> void xyz(); - Fixes for overloading of plain functions by a templated function: void abc(double d); template void abc(T t); - Overloading by templated parameters fixed: template void foo(T t) {} template void foo(T t, U u) {} %template(foo) foo; - All combinations of the above also working including specializations, eg: void abc(double d); template void abc(T t); template<> void abc(double t); template<> void abc(int t); 10/16/2004: wuzzeb (John Lenz) - Remove the ability to share type information by using c linking. All type sharing happens through a global variable in the target language. + Remove SWIG_NOIMPORT, SWIG_RUNTIME, and related defines. + Deprecate -runtime, -noruntime command line options + Update test-suite common.mk to correctly build multicpptest + Remove reference to precommon.swg + Update the guile_gh interface to share data by a global var instead of c linkage. - Remove Advanced.html, since everything in it is now obsolete 10/09/2004: mmatus - Split the python std/STL C++ library files, now all the language independent definitions are under the directory Lib/std and hence, can be used from other languages. - Add more documentation to the Python STL, and clean unnecessary code. - Add initial C99 complex support, and some fixes for long double. 10/08/2004: mmatus - Fix the SwigValueWrapper for opaque types, now it is applied for opaque templates and classes, for which we don't know if there is or not a default constructor, ie struct A { A(int); }; Still, if you know that you class has a default constructor, and for some very very particular reason you want to avoid the SwigValueWrapper, and you don't want or can't expose the class to swig, now you can say %feature("novaluewrapper") A; class A; or the other way around, if the class has a default constructor, but you want to use the value wrapper, you can say %feature("valuewrapper") A; struct A { A(); .... }; - Fix for char > 128, ie const char tilde_a = '\341'; - Add patch 1041858 for $lextype, which carries the literal type of a symbol. See lextype.i in the test-suite for more details. 10/07/2004: wsfulton {Ruby, Java] Fix director + 'empty' throws struct A { A() throw(); virtual ~A() throw(); int foo() throw(); }; 10/06/2004: wuzzeb (John Lenz) [TCL] - Fix bug reported by William A. Hoffman propagating clientdata between modules. Added clientdata_prop.multicpptest to check for this bug. The fix involved the following changes: + SwigType_clientdata_collect does not need to check types in r_resolved because we only want to propagate clientdata to typedefed classes, and r_mangled already takes care of typedefs. + SWIG_TypeRegister now copies the clientdata field correctly + Move SWIG_Guile_PropagateClientData function from guile module into common.swg, because we need to call it from both guile and tcl. + Add base_names to swig_class to delay the lookup of bases. SWIG now exports the base names and only when the base swig_class is needed is SWIG_TypeQuery(name)->clientdata looked up. - conversion_ns_template testsuite test was failing because the name of the wrapped constructor function was not calculated correctly for structs. Fixed. 10/06/2004: wsfulton Fixes for default arguments used in directors - in virtual methods and director constructors. 10/06/2004: mmatus Fix the __cplusplus macro, and bug 1041170. Now it is working as supposed, ie, you can safely use #ifdef __cplusplus ... all over swig, including inside %defines and %{ %} bodies. *** POTENTIAL INCOMPATIBILITY *** The old trick of using #if __cplusplus doesn't work any more. So, if you have your own typemaps using that syntax, you will need to migrate them to use "#ifdef __cplusplus". 10/05/2004: wuzzeb (John Lenz) - Reorganize how runtime type information is stored and shared between modules. For chicken and mzscheme, I removed the ability to use runtime libraries, while perl, tcl, python, and ruby default to using the new method but can go back to the old method by declaring SWIG_ALLOW_RUNTIME. - line 582 in mzscheme.cxx was generating a segfault on imports.multicpptest, so I fixed it. 10/05/2004: wsfulton Fixes for %extend and overloaded static methods with default arguments. 10/05/2004: mmatus - [python] Fix director + method with 'empty' throw, ie struct A { virtual int foo() throw(); }; other languages should also easy to fix, look for Getattr(n,"throw") in python.cxx. - Fix director + destructor with 'empty' throw struct A { virtual ~A() throw(); }; - Now SWIG_FEATURES parse all and the same options you can pass to swig in the command line. - New command line flag: -features , as in swig -features autodoc=3,director ie, any global feature can be initialized from the command line. This is mainly for testing, but users can also take advantage of it. 10/04/2004: mmatus - Properly qualify type in syntax as 'long(2)' or 'Foo()', this solve old problem with default args, and probably other problems around. However, the default arg problem was also already solved by William (see bellow). - Fix feature_set and feature_get methods. Before they look from particular to general and keep the first feature found. This didn't work well with templates. Now the methods look from general to particular, and override any found feature. - Previously a feature could not be applied to constructors or destructors that weren't explicitly declared in the class. This is now fixed, for example: %feature("featurename") Foo() "..." %feature("featurename") ~Foo() "..." class Foo { // implicit Foo() and ~Foo() }; - Fix missing features for default const/dest, by really 'creating' the methods and applying the features. - Fix return_const_value.i case by adding SwigValueWrapper specialization. - Fix %extend + overload, including overloading actual class methods. - Adding more cases in related files in the test-suite. 10/04/2004: wsfulton Changes to the way default arguments are wrapped. Previously a single method was generated for each method that had default arguments. If a method had 5 arguments, say, of which 1 had a default argument then the call to the wrapped method would pass 5 arguments. The default value was copied into the wrapper method and used if the scripting language passed just 4 arguments. However, this was flawed as the default argument sometimes does not have global access, for example SWIG would generate code that couldn't compile when wrapping: class Tricky { public: void foo(int val = privatevalue); void bar(int val = Tricky::getDefault()); private: static int getDefault(); enum { privatevalue = 200 }; }; Also bugs in resolving symbols generated code that wouldn't compile, for example (probably fixable though): namespace Space { class Klass { }; Klass constructorcall(const Klass& k = Klass()); } The approach also does not work for statically typed languages (C# and Java) as these languages do not allow methods to have variable number of arguments. Although C# has a mechanism to pass a variable number of arguments they must be of the same type and are more like varargs. The new approach solves the above problems and wraps methods with default arguments as if the method was overloaded. So SWIG will now treat void foo(int val=0); as if it had parsed: void foo(int); void foo(); The code generated is then exactly the same as if SWIG had parsed the two overloaded methods. The scripting languages count the arguments passed and call the appropriate method, just like overloaded methods. C# and Java are now able to properly wrap methods with default arguments by generating extra methods, again as if the method was overloaded, so for: void bar(string s="hello", double d=10.0, int i=0); the following proxy methods are generated: void bar(string s, double d, int i); void bar(string s, double d); void bar(string s); void bar(); The new approach comes with a couple of minor knock on effects. 1) SWIG support for default arguments for C (not C++) code no longer works. Previously you could have this interface: %{ void foo(int val); %} void foo(int val=0); and call the wrapped method from a scripting language and pass no arguments whereupon the default of 0 was used. You can get the same behaviour for C code by using the "default" typemap: %typemap(default) int val "$1 = 0;"; %{ void foo(int val); %} void foo(int val); or you could of course compile your code as C++ if you want C++ features :) : %{ void foo(int val=0); %} void foo(int val=0); A couple of SWIG's libraries used this C extension and these have been modified to use the "default" typemap. The "default" typemap is thus unchanged (and still is not and is not fully supported by C# and Java, and is likely to remain so). 2) All features (%feature, %rename, %ignore etc) no longer work as if the method with default arguments is just one method. For example, previously %ignore foo(int); would have ignored the method completely. Now it will only ignore foo(int) but not the extra foo() method. Instead use: %ignore foo; to ignore them all. or %ignore foo(int); %ignore foo(); This of course allows one to fine tune the wrapping, for example one could use: %rename(fooint) foo(int); %rename(foodefaults) foo(); void foo(int val=0); and call them from any language like so: fooint(200) foodefaults() or for example ignore the extra overloaded method, so the defaults cannot be used: %ignore foo(); void foo(int val=0); *** POTENTIAL INCOMPATIBILITY *** 10/2/2004: mmatus [Python] - More cleaning up and uniformation on the Python Lib - Added Robin's docstring patch, plus some fixes, plus some extensions, see autodoc.i example in the test-suite, and try using %feature("autodoc","extended"). This patch is not a complete solution for the documentation problem, just enough to inform python about the parameter list. The expected swig documentation support is far far away yet. 10/1/2004: mmatus - Fix the %callback feature (only used in ruby and python examples, by now, but it should be generic), now member callbacks are working again - Fix wrapping of functions pointers like std::ostream& std::endl(std::ostream&); ie, the ones that return references or enums. [Python] Add the %pythoncallback directive, which is an improved version of %callback, ie, %pythoncallback(1) foo; %pythoncallback(1) A::bar; %pythoncallback(1) A::barm; int foo(int a) { return a; } struct A { static int bar(int a); int barm(int a); }; int foobar(int a, int (*pf)(int a)); in python you can use foo(2) foobar(2,foo) A.bar(2) foobar(2,A.bar) ie, no additional pointer elements are created, and the original 'foo' and 'A.bar' can be used as parameters. In the case of member fucntion however, still you need to use the special variable Class::_cb_ptr, ie: foobarm(3, a, A.barm_cb_ptr) we will try to fix this situation also, but later. [Python] Add more elements from the STL library, now you can use import std std.cout << "hello " << 123 << std.endl [Python] Fix in/out return mechanism, now swig will behave as 1.3.21 but using a python list when needed. The problem is that the types std::pair,std::vector,etc, use tuples, and they interfer with the previous inout tuple type. By using lists we solve the conflicts, swig acts as before, but returns a list when more than one parameter are using the OUT typemap. See the new inout.i example in the test-suite. *** POTENTIAL INCOMPATIBILITY FOR PYTHON MODULE *** [Python] Much better error messages for bad arguments, now you always get the argument number where the error occurred. 09/27/2004: wsfulton Patch from Bill Clarke - 1) Warning emitted when -importall and -includeall is used together, with -includeall taking precedence. 2) Ensure SWIGIMPORTED is always defined when a file is being imported with %import. Note that this is not the same as SWIGIMPORT, which gets defined in all generated wrapper files. 09/26/2004: mmatus - add %feature("exceptionclass") to identify a class used as exception. Before swig identified and marked a class using the "cplus:exceptionclass" attribute. However, the class needed to appear on an throw() statement. Now swig keeps trying to identify the exception classes, as before, but it also allows the user to mark a class by using the %feature explicitly. (mostly relevant for python and chicken) [Python] - fix -modern option + exceptions, which mix old class style with the new one. So, we always need to emit the "nonmodern" python code. - add the "python:nondynamic" feature and its handler now if you have %pythonnondynamic(1) A; struct A { int a; int b; }; then, in the python side aa = A() aa.a = 1 # ok aa.b = 2 # ok aa.c = 3 # error, the class can not be extended dynamically. Since this is a feature, you can use %pythonnondynamic(1); or %pythondynamic(0); [ Note: %pythondynamic since deprecated ] to force all the wrapped classes to be "nondynamic" ones. The default, as in regular python, is that all the wrapped classes are dynamics. So, careful with your spelling. 09/14/2004: mmatus - Support the -I- option. - Differentiate between %include and %include "file". This fix several corner cases. [Python] Several patches: - Normalize the Lib file names: *.swg internal files, *.i user files. - Fix Char[ANY] typemaps, so they also delete any extra '\0' chars, now they behave as before (1.3.21). Still, you can use the SWIG_PRESERVE_CARRAY_SIZE macro if you need to preserve the original size (see pystrbase.swg). - Add the Char FIXSIZE[ANY] typemaps, to preserve the original C array sizes (see above). Though, you can't use them yet since %apply and arrays are not working together. - Add pyfragments.swg, now the user can add fragments to override the default ones. 09/10/2004: wsfulton Patch from Bill Clarke which fixes spurious preprocessor bug which shows on Solaris and gcc, eg: Warning(202): Could not evaluate '!defined(SWIGJAVA) && !(defined(SWIGCSHARP)' Also fixes a bug where '#if "a" == "b" == 1' wouldn't have worked 09/10/2004: wsfulton Restored multiple build directories for the test-suite. Patch from Bill Clarke. 09/06/2004: wsfulton Added the missing runtime.dsp Visual Studio project files for the import examples to work. Version 1.3.22 (September 4, 2004) ================================== 09/03/2004: wsfulton The swig.m4 macro for use with the Autoconf/Automake/Libtool has been removed and is no longer installed. Please use the new and better maintained version derived from swig.m4 in the Autoconf macro archive. See http://www.gnu.org/software/ac-archive/htmldoc/ac_pkg_swig.html and http://www.gnu.org/software/ac-archive/htmldoc/ac_python_devel.html. 09/01/2004: wsfulton [Perl] Applied patch #1019669 from Christoph Flamm. Adds support for %feature("shadow") in the same way as it works in Python. This enables one to override the generated shadow/proxy methods, including constructors and destructors. For example: /* Let's make the constructor of the class Square more verbose */ %feature("shadow") Square(double w) %{ sub new { my $pkg = shift; my $self = examplec::new_Square(@_); print STDERR "Constructed an @{[ref($self)]}\n"; bless $self, $pkg if defined($self); } %} class Square { public: Square(double w); ... }; 08/31/2004: mmatus [Python] Incompatibility reported by Bill Clarke (llib@computer.org): If you are using Sun Studio 8 (and possibly earlier versions) to compile the output produced by swig 1.3.22rc1, and you are using C++ and STL templates then you need to use either "-runtime" or "-noruntime". If you use neither of these options then you will probably get compiler errors when trying to compile the wrapper file; the error message will be like this: The name SWIG_Python_ConvertPtr[...] is unusable in static swigpy::traits_asptr[...] If you get this error message, you need to regenerate your wrapper file using 'swig -runtime' or 'swig -noruntime'. You shouldn't get this problem with Sun Studio 9. *** POTENTIAL INCOMPATIBILITY FOR PYTHON MODULE *** 08/26/2004: wsfulton [Perl] Applied #932333 from Ikegami Tsutomu. Fixes long long *OUTPUT and unsigned long long *OUTPUT typemaps in typemaps.i. 08/26/2004: wsfulton Applied patch #857344 from Art Yerkes. Workaround for autoconf bug when running 'make install'. 08/26/2004: wsfulton [Perl] Part of patch #982753 applied. This implements a %perlcode directive. It allows one to add Perl code to the generated .pm file. Works the same as %pythoncode. 08/26/2004: wsfulton [Java] Fix for directors when wrapping virtual methods with exception specifications that were not simple types. Previously code was generated that didn't compile, for example when the exception specification was a pointer. 08/25/2004: wsfulton [C#] Typemap fix for methods that return char *. The CLR would incorrectly delete the memory pointed to by char *. Also applied the same correction to the char array typemaps. 08/24/2004: wsfulton Fixes for -fmicrosoft error/warning message display: - End of file (EOF) warning messages not displaying in correct format - Some messages containing a file path were displaying a double backslash instead of a single backslash 08/23/2004: wsfulton Applied patch #1011604 submitted by Charles Schwieters. Fix for 64 bit tcl interpreters. 08/23/2004: wsfulton Fix for bug #875583 - enum forward declarations previously gave a syntax error. 08/23/2004: mkoeppe [Allegro CL] Use typemaps "ffitype" and "lisptype" to determine the FFI type specifiers from the C type. This makes it possible, for instance, to control whether a C "char" argument takes a Lisp character or a Lisp integer value. The default (taking Lisp characters) is done by these built-in typemaps: %typemap(ffitype) char ":char"; %typemap(lisptype) char "character"; If char means an integer instead, use these typemaps: %typemap(ffitype) char ":char"; %typemap(lisptype) char "integer"; 08/22/2004: wsfulton As discussed in bug #772453, the SWIG library directory is now installed into a different default directory. The library used to be installed to /usr/local/lib/swig1.3. It is now in the more usual architecture independent directory and I have additionally used a version specific subdirectory as the library will rarely work with older versions of SWIG. This release will thus use /usr/local/share/swig/1.3.22 by default, which can be tailored as before using './configure --swiglibdir'. 08/17/2004: mkoeppe [MzScheme] Add support to create native MzScheme structures from C structures. To convert a C structure to an MzScheme structure, use the new runtime macro SWIG_NewStructFromPtr in a typemap. Patch from Dmitriy Zavin. 08/12/2004: wsfulton Patch #837715 from Ben Reser to correctly detect Python lib directory on 64 bit systems. 08/12/2004: wsfulton [C# and Java] Prevent memory leaks in the case of early return from wrapper methods using const std::string & parameters. Modified Mark Traudt patch #951565. 08/12/2004: wsfulton Bug #943783 with patch fixes php char * out typemap NULL values. 08/03/2004: Ahmon Dancy [allegrocl] Additional case mode fixes. Also, make sure foreign types are exported. 07/24/2004: mkoeppe [Guile] In -scm mode, SWIG modules now exchange their pointer type information via the Guile interpreter. It is no longer necessary to build a runtime library or to use -noruntime and -runtime etc. The module (Swig swigrun) which was introduced in the change of 05/17/2004 is no longer automatically built. If you need it, run SWIG on the interface file swigrun.i. 07/23/2004: wsfulton [C#] Bug #917601 Mapping C++ bool fix from Mark Traudt 07/23/2004: wsfulton RPM fixes for latest CVS version including removal of runtime library. 07/23/2004: wsfulton Patch #908955 from Robert H De Vries. RPM file generation fix for Fedore Core 1 and Redhat AS2.1. 07/12/2004: wsfulton Patch #864689 from Robin Dunn: This patch corrects two problems in the XML output of SWIG: 1. There were often extra '/>\n' in the output. 2. value attributes were output with '\n' in them but since that is not technically legal most (all?) XML parsers will strip them out. Replacing the '\n' with the ' ' entity reference solves this as that is legal and XML parsers will convert it to a '\n' when reading the values back in. This patch also adds a new global command line option that will allow the parse tree to be written out in XML *after* some other language module has been run, in order to be able to get extra info that the language module puts in the tree. In this way the XML is a post-processed version of the tree rather than a pre-processed version. Command line option is -dump_xml or -xmlout 07/12/2004: wsfulton [Java] Patch from Scott Michel to fix typesafe enums and proper enums with directors. 07/12/2004: wsfulton HTML documentation (makechap.py) file generator missing end of line patch #908951 from Robert de Vries. 07/08/2004: wsfulton The deprecated runtime library build has been removed. This also removes the dependency on Libtool. Libtool is no longer required to build SWIG. The associated -ldflags SWIG commandline option has also been removed. The examples and test-suite testcases that used the runtime library have been updated to use the replacement approach to using SWIG across multiple modules, that is they use the -noruntime and -runtime commandline options, see Modules.html. Effectively they build their own runtime libraries using -runtime. The examples are import and import_template. The test cases are in the imports and template_typedef_import directories. Anyone who wants the original runtime libraries can either run the test-suite or build the examples and use the appropriate shared object/DLL that is generated with the -runtime commandline option. For example libimports_runtime.so (Python calls it lib_imports_runtime.so) is generated after running the 'make imports.multicpptest' testcase in the Examples/test-suite/ directory. Or use libruntime.so / runtime.dll after building the import examples in Examples//import. 07/07/2004: mkoeppe [Allegro CL] Convert character and string literals in constants to CL syntax. Fix FF:DEF-FOREIGN-CALL for mixed-case C functions. 06/27/2004: wsfulton [Java] New feature for Java exceptions with format %javaexception(exceptionclasses). This feature is a slight enhancement to %exception and the only difference is the addition of the exception classes which are generated into a throws clause. The 'exceptionclasses' is a comma separated list of classes which will be added to the associated proxy method's throws clause. The 'exceptionclasses' are specified like the exception classes in the 'throws' attribute in the typemaps. This feature should be used for correctly handling checked exceptions thrown from JNI code. For example: %javaexception("java.lang.Exception") throwException %{ ... convert a std::logic_error into a java.lang.Exception using JNI code ... %} #include void throwException() { throw std::logic_error("Logic error!"); } will generate a method with a throws clause in the module class: public static void throwException() throws java.lang.Exception { ... } 06/27/2004: wsfulton [C#] New %csconstvalue(value) feature directive for use with constants and enums. This works the same way as %javaconstvalue. For C#, this directive is the only way that one can fix wrapping of C/C++ enums with proper C# enums if the enum item's initialiser cannot compile as C# code. This is because Java enums can use a call into C code to initialise the enum item, whereas in C#, the enum value must be a compile time constant. That is, using %csconst(0) cannot be used in C# to initialise the C# enum item via a PINVOKE call. 06/27/2004: wsfulton [Java] New %javaconstvalue(value) feature directive for use with constants and enums. Sometimes the use of %javaconst(1) will produce code that won't compile under Java. If a compile time constant is required, %javaconst(0) is not an option. The %javaconstvalue directive achieves this goal and the value specified is generated as Java code to initialise the constant. For example: %javaconst(1); %javaconstvalue(1000) BIG; %javaconstvalue("new java.math.BigInteger(\"2000\")") LARGE; %javaconstvalue(10) bar; %{ const int bar = 10; %} %inline %{ #define BIG 1000LL #define LARGE 2000ULL enum Foo { BAR = ::bar }; %} Generates: public interface exampleConstants { public final static long BIG = 1000; public final static java.math.BigInteger LARGE = new java.math.BigInteger("2000"); } public final class Foo { public final static Foo BAR = new Foo("BAR", 10); ... } Previously, none of BIG, LARGE or BAR would have produced compileable code when using %javaconst(1). 06/27/2004: wsfulton %feature enhancements. Features can now take an unlimited number of attributes in addition to the feature name and feature value. The attributes are optional and are much the same as the typemap attributes. For example, the following specifies two optional attributes, attrib1 and attrib2: %feature(featurename, attrib1="attribval1", attrib2="attribval2") name "val"; %feature(featurename, val, attrib1="attribval1", attrib2="attribval2") name; 06/27/2004: wsfulton %feature improvements for the syntax that takes the feature value within the %feature() brackets. The value specified is no longer restricted to being just a string. It can be a string or a number. For example, this is now acceptable syntax: %feature("featurename",20.0); whereas previously it would have to have been: %feature("featurename","20.0"); Useful for features that are implemented as a macro, for example: #define %somefeature(value) %feature("somefeature",value) These will now work accepting either a string or a number: %somefeature("Fred"); %somefeature(4); 06/06/2004: wuzzeb (John Lenz) [Chicken, Guile] - Created the Examples/test-suite/schemerunme directory, which holds all the runme scripts for guile and chicken (and possibly mzscheme...). The guile and chicken _runme files then (load "../schemerunme/foo.scm"). - In chicken module, fix a few bugs invlolving dynamic casts. 06/03/2004: wsfulton Patch to fix wrapping of templated methods. ISO compliant compilers, like Comeau and GCC-3.4.0, don't like the template specifier that SWIG was generating when calling the method. This fix may break some non standard compliant compilers, for example, Sun workshop compilers prior to version 6.2.p2. Patch submitted by Bill Clarke. 06/03/2004: wsfulton [Java, C#] Undocumented special variable $imclassname removed. New special variable $module is replaced by the module name, as specified by %module or -module commandline option. $imclassname can be created from $module. 06/03/2004: wsfulton [C#] Same as for Java below. The new typemaps are named differently, namely, csbody and csbody_derived. The deprecated typemaps are csgetcptr and csptrconstructormodifiers. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 06/03/2004: wsfulton [Java] Typemap changes for the Java proxy / typewrapper and enum classes. A new typemap called javabody contains the essential support code for generation into the body of these classes. There is also a new javabody_derived typemap which is used instead for wrapped classes that have a wrapped base class. The code is basically, the getCPtr() method and swigCPtr and swigCMemOwn member variables. These used to be hard coded with no way to modify the code. The introduction of this typemap makes it possible for the user to tailor nearly every aspect of the code generation. The exception now is the code for director classes. The javagetcptr and javaptrconstructormodifiers typemaps are deprecated and are no longer used as the code that these generated can be put in the more flexible javabody and javabody_derived typemaps. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** The following macros contributed by Scott Michel may help you upgrade if you have used the javagetcptr typemap: /* Utility macro for manipulating the Java body code method attributes */ %define SWIGJAVA_ATTRIBS(TYPENAME, CTOR_ATTRIB, GETCPTR_ATTRIB) %typemap(javabody) TYPENAME %{ private long swigCPtr; protected boolean swigCMemOwn; CTOR_ATTRIB $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } GETCPTR_ATTRIB static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javabody_derived) TYPENAME %{ private long swigCPtr; CTOR_ATTRIB $javaclassname(long cPtr, boolean cMemoryOwn) { super($moduleJNI.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } GETCPTR_ATTRIB static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %enddef /* The default is protected getCPtr, protected constructor */ SWIGJAVA_ATTRIBS(SWIGTYPE, protected, protected) /* Public getCPtr method, protected constructor */ %define PUBLIC_GETCPTR(TYPENAME) SWIGJAVA_ATTRIBS(TYPENAME, protected, public) %enddef /* Public getCPtr method, public constructor */ %define PUBLIC_BODYMETHODS(TYPENAME) SWIGJAVA_ATTRIBS(TYPENAME, public, public) %enddef 06/03/2004: wsfulton [Java, C#] The contents of the class modifier typemaps and pragmas have changed. They must now include the class type. Previously 'class' was hard coded. This change enables flexibility into what type of class is generated, for example the proxy class could be an interface instead of a class. For Java this affects the javaclassmodifiers typemap and the jniclassclassmodifiers and moduleclassmodifiers pragmas. For C# this affects the csclassmodifiers typemap and the imclassclassmodifiers and moduleclassmodifiers pragmas. Unless you have overridden the default versions of these typemaps or pragmas, you shouldn't be affected. However, if you have, upgrading is easy, for example class Foo {}; %typemap(javaclassmodifiers) Foo "public final" must now be: class Foo {}; %typemap(javaclassmodifiers) Foo "public final class" *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 05/31/2004: wsfulton Fix for C++ exception specifications that are references. Problem reported by Oren Miller. Also improves the generated exception declarations in the catch handler for pointers - a pointer is used instead of a reference to a pointer. Added default throws typemaps for SWIGTYPE &, SWIGTYPE * and SWIGTYPE[ANY] (Java and C#). 05/31/2004: wsfulton [Java, C#] Some minor typesafe enum improvements, including storing the name of the enum item. The toSring() / ToString() methods are overridden to return this name. 05/30/2004: wuzzeb (John Lenz) [Chicken] - Update how examples and the test suite are built. - Symbol names are no longer converted to lower case - Added union_runme.ss, which was copied and modified from the guile module 05/26/2004: lballabio (Luigi Ballabio) Committed on behalf of Marcelo (who still has problems with the SourceForge CVS.) Added Python typemaps for FILE* with (Python-only) test. 5/24/2004: dancy * Allegro CL module: Now using some macros (defined in Lib/allegrocl/allegrocl.swg), swig-defconstant and swig-defun, for defining constants and foreign functions. This makes the generated file a bit neater. Now strips a layer of parenthesis from constants. Uses (* :void) instead of :foreign-address now. 05/20/2004: wsfulton Unnamed enum global variables are now supported in addition to the recently added support for unnamed enum member variables. For example: struct Foo { enum { enum1, enum2 } MemberInstance; }; enum { enum3, enum4 } GlobalInstance; The int typemaps are used for wrapping the get/set accessor methods. If the sizeof an enum is not the same size as an int then setting the variable will silently do nothing as the casts cannot be easily and portably generated. If you need to solve this highly obscure situation, write the assignment using the %exception feature. 05/20/2004: wsfulton [C#] C# enum wrapping mods. Similar to the Java module, enums can be wrapped using one of 3 approaches: 1) Proper C# enums - use %include "enums.swg" 2) Typesafe enums - use %include "enumtypesafe.swg" 3) Simple constant integers (original approach) - use %include "enumsimple.swg" See each of these files for further details. Each of these files use typemaps and a new feature to control the generated code. The feature is: %csenum(wrapapproach); where wrapapproach should be one of: "proper", "typesafe", "typeunsafe" or "simple". [No implementation deemed necessary for type unsafe enums]. The default approach is proper C# enums. Anonymous enums are always wrapped by constant integers. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 05/20/2004: wsfulton [Java] Java enum support added. There are now 4 ways in which enums can be wrapped: 1) Proper Java enums - use %include "enums.swg" 2) Typesafe enums - use %include "enumtypesafe.swg" 3) Type unsafe enums (constant integers) - use %include "enumtypeunsafe.swg" 4) Simple constant integers (original approach) - use %include "enumsimple.swg" See each of these files for further details. Each of these files use typemaps and a new feature to control the generated code. The feature is: %javaenum(wrapapproach); where wrapapproach should be one of: "proper", "typesafe", "typeunsafe" or "simple". The default typemaps will handle enums that may or may not have specified initial values, for example ten is specified: enum Numbers { zero, ten(10) }; However, the amount of generated Java code can be cut down, by modifying these typemaps if none of the enums have initial values (proper Java enums and typesafe enums approach). The default approach is typesafe enums. Anonymous enums are always wrapped by constant integers. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 05/11/2004: wsfulton [Java, C#] Fix bug using %rename on enum items and when using %javaconst(1) / %csconst(1) For example, the following used to generate code that wouldn't compile: %rename(Obj) Object; enum Grammar { Subject, Object }; 04/28/2004: wsfulton [Java, C#] Minor fixes when using combinations of the javainterfaces, javabase, csinterfaces and csbase typemaps. 05/18/2004: wsfulton [Java] JVM link failure on some systems fixed when using std_vector.i. Also adds default vector constructor for use from Java. 05/17/2004: mkoeppe (Matthias Koeppe) [Guile] New runtime functions SWIG_PointerAddress, SWIG_PointerType, SWIG_IsPointerOfType, SWIG_IsPointer. [Guile] In -scm mode, wrap several SWIG runtime functions and export them into the module (Swig swigrun). The runtime module is now built with "module" linkage. [Guile] GOOPS proxy objects now also print the pointer address of the C object. 05/14/2004: lyle Added Kou's patch for the Ruby %import directive so that modules with "nested" names are handled properly. Consider an interface file foo.i that has this %module declaration at its top: %module "misc::text::foo" Now consider another interface file spam.i that imports foo.i: %import foo.i Before this patch, this would result in the following code being generated for spam_wrap.c: rb_require("misc::text::foo"); With this patch, however, you'll get the correct path name for the call to rb_require(), e.g. rb_require("misc/text/foo"); See SourceForge Bug #928299. 05/12/2004: wsfulton Patch for emitting directors when %feature("director") specified for a class with no virtual methods, but does have a virtual destructor. Submitted by Kevin Smith. 05/06/2004: mkoeppe (Matthias Koeppe) New SWIG runtime function SWIG_TypePrettyName, which returns an unmangled type name for a swig_type_info object. [Guile]: Use it for printing pointer objects. 05/03/2004: dancy (Ahmon Dancy) * Lib/allegrocl/allegrocl.swg: Updated comments about identifer conversion. * Sources/Modules/allegrocl.cxx: Register /dev/null for "header" target. Also, disregard "const" qualifiers during type conversion. 05/02/2004: wuzzeb (John Lenz) [Chicken] Fix bug 782468. To fix this bug, the runtime code has been rewritten, and pointers are now represented as a C_SWIG_POINTER_TYPE. Chicken version > 1.40 is now required! * Typemap incompatibility: typemaps no longer use chicken_words. If a typemap needs some space, it should just call C_alloc * argout typemaps no longer use the /* if ONE */ construct to build an output list. A SWIG_APPEND_VALUE macro, exactly like guile and mzscheme is now used. 04/25/2004: mkoeppe (Matthias Koeppe) [Guile] In the generated GOOPS code, don't create methods that would not specialize any arguments; simply re-export the primitive functions. (This is a performance optimization which reduces load time and execution time.) [Guile] In -gh mode, fix the "too many initializers" error which was caused by an incompatible swig_type_info layout. [Guile] The typemap for FILE * in ports.i now also accepts a regular FILE * pointer object. Also a bug with Scheme file ports that are open for input and output has been fixed. 04/25/2004: wsfulton Change entry 03/21/2004 revoked. The change introduced another inconsistency (reference typemaps beings used instead of pointer typemaps for member variables as well as static member variables and global variables for some languages, but only for C++ and not C). This would break user's current typemaps and introduce further inconsistencies. Alternative solution required and being discussed. 04/10/2004: mmatus (Marcelo Matus) Added the -directors flag. This enables the director mode for the interface and all the classes that don't set the "feature:nodirector" explicitly. You can use this in your module if you want to use the director feature in all your classes, but it is most intended for testing purposes, like: make check-python-test-suite SWIG="../../../swig -directors" make check-ruby-test-suite SWIG="../../../swig -directors" make check-java-test-suite SWIG="../../../../swig -directors" These commands will run the entire test-suite using directors, and not only the specific 'directors_*' cases. This should be done from time to time. 04/10/2004: mmatus (Marcelo Matus) [python] Added support for std::wstring and wchar_t, for compiler and python versions that support them. When needed, use %inlcude std_string.i // 'char' strings %inlcude std_wstring.i // 'wchar_t' strings 04/10/2004: mmatus (Marcelo Matus) [python] Fix the default behaviour (seg. fault) when an inplace operator (+=,-=,...) was wrapped, as reported by Lucriz (lucriz@sitilandia.it), when the most common form was used: A& A::operator+=(int i) { ...; return *this; } ^^^^ ^^^^^^ ie, an object is returned and its contains the same 'this' value than the input object, which is deleted after the operation "a += b", leaving the result with no real object, but a seg. fault. To fix it, we needed to introduce a new feature and use an old one: %feature("self:disown") A::operator+=; %feature("new") A::operator+=; here, "self:disown" disable the ownership of the 'self' or input object, and the "new" feature transfers the ownership to the result object. The feature/solution could also be used in other languages that use gc and implement the inplace operators, or other operators, in a similar way. *** POTENTIAL INCOMPATIBILITY FOR Python MODULE *** If you already are using the inplace operators in python, and you implemented some kind of workaround to the problem fixed here, it is possible you could end with 'free' objects that never get deleted. If that is the case, and you want to disable the current fix, use: %feature("self:disown","") A::operator+=; %feature("new","") A::operator+=; 04/07/2004: cheetah (William Fulton) [C#] C++ enums are no longer wrapped by integers, they are now wrapped by C# enums. For Example, given C++: enum AnEnum { foo, bar }; typedef AnEnum AnEnumeration; void something(AnEnum e, AnEnumeration f); The following is generated: public enum AnEnum { foo, bar } public static void something(AnEnum e, AnEnum f) {...} Note that a global enum like AnEnum above is generated into its own file called AnEnum.cs. Enums defined within a C++ class are defined within the C# proxy class. Some of the typemaps for modifying C# proxy classes also work for enums. For example global enums can use %typemap(csimports) to add in extra using statements. Global enums and class enums can use %typemap(csclassmodifiers) to make the enum private, public etc. %typemap(csbase) to change the underlying enum type (enum base) If we add this for the above example: %typemap(csclassmodifiers) AnEnum "protected" %typemap(csbase) AnEnum "long" the following is generated: protected enum AnEnum : long { foo, bar } *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 04/07/2004: cheetah (William Fulton) Seg fault fix for empty enums, like enum Foo {}; 03/21/2004: mmatus [Note: this change revoked on 04/25/2004] [Python] Makes the following 'var' cases more uniform: std::string ga; struct A { static std::string sa; std::string ma; }; now the three variables (ga, sa, ma) can be assigned as: cvar.ga = "hello"; A.sa = "hello"; a.ma = "hello"; ie, now 'ma' will also use a std::string typemap 'in' if defined, before it was only accepting a 'p_std_string' pointer. Note, however, that 'ma' will not use the 'varin/varout' typemaps (that probably could be more natural), but it will pick up the 'in' typemap for const std::string& (which is easier). The changes in cwrap.c and lang.cxx will probably fix the behaviour in other languages that do not overload the membervarHandler method "too much". 03/21/2004: mmatus [Python] Disabling the default instantiations like: %template() std::pair; for all the primitive types and STL containers/classes. They are expensive, specially for pair and map, and the previous behaviour also requires the user to perform manual instantiations. Still, if the speed difference is not important, it can be re-enabled by defining the macro SWIG_STD_DEFAULT_INSTANTIATION (see std_common.i). Also, normalizing the INPUT/OUTPUT/INOUT typemaps. Now they use the same conversors than the rest of the typemaps, and you can use them for std::pair, std::string and all the other STL types, like in: void p_inoutd(std::pair *INOUT); Added the attribute.i and implicit.i files with macros to transform functions pairs like 'set_x'/'get_x' (or 'T& x()'/'const T& x() const') into an attribute, and allowing the use of implicit constructors in typemaps (see the files for more details). 03/21/2004: mkoeppe [Guile] Fix the documentation strings of functions with anonymous arguments. 03/18/2004: mmatus [Python] More general std_string.i interface. Now you can wrap it using %template(string) std::basic_string; and use the std::string as a base class: struct A : std::string { }; But more important, swig will recognize both std::basic_string and std::string as the same type. 03/16/2004: mmatus Previously added, but not mentioned before: - friend declaration support, swig now emits a global function in the same class scope. - ref/unref features: to mix ref counting C++ classes and native script ref counting mechanisms (like in python). Use it like: %feature("ref") RCObj "$this->ref();" %feature("unref") RCObj "$this->unref();" And the class RCObj, and all the derived ones, will perform the right ref/unref calls when a new pointer is returned to the target language, or when the target language attempts to delete the object. See the refcount.i file in the test-suite for more details. 03/16/2004: mmatus [Python] Using the new %fragment support, major rewrote of the python swig library, including: - Almost automatic template/typemap instantiation for the STL components. For example, now you can write: %template(vector_i) std::vector; and a specialized vector_i class is emitted with all the needed typemaps. No need to use the old 'specialize_vector' macros. Note you can also define %template(matrix_i) std::vector >; %template(vector_pii) std::vector >; - The empty template instantiation %template() std::vector; defines the vector typemaps, but no proxy class. For all the fundamental types, the empty template instantiation are defined, so, you can say %include std_vector int func(const std::vector& a); where the proper typemap is applied to 'a', but no std::vector proxy is generated. - All the STL containers present a more uniform behavior and more complete interface declaration. The following are now supported: std::vector std::list std::deque std::set std::multiset std::map std::multimap not a container, but also supported: std::pair also, more typemaps are defined for all of them, including varin, varout, typecheck, etc. - Initial attempt to implement the STL containers considering allocators, ie: std::vector it is partially working, but it is just a workaround while swig improves its template type support. Please test with your particular setup. It seems to be working with g++ 3.2.2, g++ 2.96, Intel icc and SGI CC compilers, plus python 1.5.2, 2.0 and 2.3, but since we are using templates, there is a chance you can find some problems when using with an old C++ compiler. 03/16/2004: mmatus - Allowing the empty %template directive, such as %template() std::vector; to process the class "typedef"s and "typemap"s. Before only the internal "typedef"s were processed. This makes possible to emit the default in/out typemaps without the need of wrapping an specialized vector instance. - Adding the preprocessor extension #@ which mangles the following macro argument, like in: #define macro(X) #@X macro(int) -> int macro(std::string) -> std_s_s_string - Fragments can now be "type specialized", as the typemaps. The syntax is as follows %fragment("name","header") { /* a type independent fragment (old syntax) */ } %fragment("name" {Type}, "header") { /* the fragment is type dependent */} Now fragments can also be used inside templates: template struct A { %fragment("incode"{A},"header") { /* 'incode' specialized fragment */ } %typemap(in,fragment="incode"{A}) { /* here we use the 'type specialized' fragment "incode"{A} */ } }; 03/11/2004: cheetah (William Fulton) [Java] Director bug which meant that some virtual functions overridden in Java were not being called on some operating systems. Bug reported and fixed by Robert de Vries and Scott Michel. 03/02/2004: mkoeppe (Matthias Koeppe) [Guile] In -scm mode, don't forget to check the type of string arguments. 02/24/2004: cheetah (William Fulton) [C#] New commandline option -namespace . This allows one to specify a C# namespace into which all C# classes are generated. 02/23/2004: mkoeppe (Matthias Koeppe) [MzScheme] Use FUNC_NAME rather than a bogus typemap variable for signalling errors. Call scheme_wrong_type with a zero-based argument number. Reported by Ondrej Pacovsky, SF #902621. [Guile] Define FUNC_NAME also in the dispatch wrapper for overloaded functions. Patch by John Lenz, SF #896255. 02/22/2004: mkoeppe (Matthias Koeppe) [Guile] In -scm mode, don't try to invoke a null destructor function. 02/20/2004: cheetah (William Fulton) Fixes so that the SWIG source will compile using the Digital Mars Compiler (formerly Symantic compiler) on Windows. Submitted by Scott Michel. 02/13/2004: mkoeppe (Matthias Koeppe) [MzScheme] New command-line argument -noinit. Use it for building the runtime library, where we don't want to define the functions scheme_initialize etc. Reported by Tim Brown, SF #891754. [MzScheme] Don't produce invalid C code when invoked with the -declaremodule option. Reported by Tim Brown, SF #891108. [Guile] Build the runtime library with passive linkage, to rename the SWIG_init function uniquely. 02/12/2004: cheetah (William Fulton) [Java, C#] Patch submitted by Bill Hoffman which prevents SWIG from crashing when a file for the typewrapper class cannot be opened. 02/11/2004: cheetah (William Fulton) [Java, C#] Overloading changes: - Methods which are overloaded in const only no longer generate Java code that won't compile - the first method parsed is used and a warning is displayed. Note that this behaviour is slightly different to the scripting languages which always uses the non-const method. - Warning messages 509 and 512 replaced by new warning number 516, which is more relevant to these statically typed languages as the overloaded methods aren't 'shadowed', they are ignored. 01/23/2004: mkoeppe (Matthias Koeppe) [Guile] Replace the "known_classes" hash table by a node attribute. Methods of classes in C++ namespaces now get the proper specializer in the GOOPS declaration. Reported by rm@mh-freiburg.de. 01/23/2004: mkoeppe (Matthias Koeppe) [Guile] Uniquify the argument names in GOOPS shadow method declarations. Reported by rm@mh-freiburg.de. 01/21/2004: sunshine (Eric Sunshine) Revived the NextStep port of SWIG. Fixed fatal problem in DohStrstr() caused by difference in strstr() implementation which made %apply become entirely dysfunctional. On NextStep, strstr("foo","") evaluates to NULL; whereas, on modern platforms, it evaluates to "foo". %apply relies extensively upon strstr("foo","") evaluating to non-NULL, therefore it failed catastrophically when faced with NextStep's strstr(). Added `bool' check to configure.in since NextStep's C++ compiler does not supply this type. swig.h now fakes up `bool' if needed. Worked around NextStep C++ compiler bug in which C++ code is disallowed inside extern "C" functions. This problem affected all language modules, since they publish hook functions of the form: extern "C" Language *swig_foo(void) { return new FOO(); } Fixed by creating a C++ wrapper: static Language *new_swig_foo() { return new FOO(); } extern "C" Language *swig_foo(void) { return new_swig_foo(); } Ensured that Swig_copy_string() is used in place of strdup() since NextStep does not supply strdup(). Fixed detection of Ruby library name and location in configure.in. Problem 1: Assumed that library always resided in Ruby's "archdir", which was correct for Ruby 1.6.x, but which is incorrect for Ruby 1.8.x, in which case the library normally resides in Ruby's "libdir". Problem 2: Assumed that the library could always be linked via "-l"+RUBY_INSTALL_NAME (where RUBY_INSTALL_NAME typically is "ruby"), however this failed for platforms, such as NextStep, which do not support shared libraries. In this case, the static library name in 1.8.x is libruby-static.a, thus -lruby-static is required. The new logic works correctly for static and shared libraries for 1.6.x and 1.8.x. Fixed detection of Perl CFLAGS in configure.in for NextStep. Detection code extracted CFLAGS from Perl's %Config hash but neglected to add a newline to the value before passing it through `sed'. NextStep's ancient `sed' discards input which is not terminated with a newline, thus Perl CFLAGS always evaluated to the empty string. 01/16/2004: cheetah (William Fulton) Tidy up in the exception handling code that is generated when C++ exception specifications are wrapped with the throws typemap. This redundant code is no longer generated: catch(...) { throw; } 01/12/2004: wsfulton on behalf of mmatus (marcelo matus) if a method uses %exception and the method requires the use of the throws typemap, the code in a throws typemap will be generated inside the try body. For example: %exception method { try { // method action $action } catch (int i) { // method int catch handler } catch (...) { // method generic catch handler } } %typemap(throws) Except %{ // throws typemap Except catch handler %} %inline %{ class Except {}; void method(int i) throw (Except); Will generate: { try { // method action try { method(arg1); } catch(Except &_e) { // throws typemap Except catch handler } } catch (int i) { // method int catch handler } catch (...) { // method generic catch handler } } As can be seen, the inner try catch block is for the throws typemaps. Previously, this was reversed so that the inner try catch block was the %exception code. In the example above, it would have been impossible to catch Except as the catch all (...) would catch the exception instead. Version 1.3.21 (January 11, 2004) ================================= 01/10/2004: cheetah (William Fulton) The output format for both warnings and errors can be selected for integration with your favourite IDE/editor. Editors and IDEs can usually parse error messages and if in the appropriate format will easily take you directly to the source of the error. The standard format is used by default except on Windows where the Microsoft format is used by default. These can be overridden using command line options, for example: $ swig -python -Fstandard example.i example.i:4: Syntax error in input. $ swig -python -Fmicrosoft example.i example.i(4): Syntax error in input. 01/09/2004: beazley Fixed [ 871909 ] simple namespace problem. This was a problem using anonymous structures in a namespace. For example: namespace ns { typedef struct { int n; } S; }; Reported by Josh Cherry. 01/09/2004: beazley Fixed some broken Perl examples. 12/28/2003: cheetah (William Fulton) [Java and C#] Fixes for wrapping covariant (polymorphic) return types. For example: struct Base { virtual ~Base(); virtual Base* copy() const = 0; }; struct Derived : Base { virtual Derived* copy() const; }; The Derived::copy proxy method returns Base not Derived. A warning is issued about this. Previously the pointer used by the proxy class was incorrectly treated as a Base* instead of a Derived*. 12/18/2003: cheetah (William Fulton) Fix so that Windows paths are displayed correctly when reporting errors. An error previously would have been shown something like: .?xample.i:14: Syntax error in input. instead of: .\example.i:14: Syntax error in input. Version 1.3.20 (December 17, 2003) ================================== 12/17/2003: beazley Last minute modifications. Perl5 module now generates shadow classes by default like all of the other modules. PHP4 wrappers no longer include "config.h". 12/14/2003: beazley Weakened warning message related to constructor names so that an unusual nested-class wrapping technique would work again (apparently it worked in some older SWIG releases). For example: class Scope { class ClassA; class ClassB; }; class Scope::ClassA { ... }; class Scope::ClassB { ... } Note: There is still some odd interaction with the SWIG symbol table/type system that will need to be looked at in a future release. Reported by Gustavo Niemeyer. 12/11/2003: cheetah (William Fulton) [Java] Protected class methods are wrapped as protected Java methods when using the dirprot director feature. This can be changed using %javamethodmodifiers to something else should the need arise, for example, private or package access. 12/11/2003: cheetah (William Fulton) [Java, C#] %javamethodmodifiers (Java) and %csmethodmodifiers (C#) operate slightly differently. Previously this feature had to be present to set the method modifiers. Now it is only used if it exists for the method being wrapped. The default is "public" as previous however, when wrapping protected director methods it is "protected". This change will not affect existing use of the %javamethodmodifiers or %csmethodmodifiers. 12/11/2003: mmatus (Marcelo Matus) This fix some recurring reports about keywords not been properly identified and warned, and it solves the problem of how to add a test file to the test-suite such that it doesn't use any keyword of all the supported languages (and doing it without compiling the test for all the supported languages, thing that is not always possible, and without requiring you to know all the supported language keywords, thing that is always impossible). So these are the changes globally speaking: - Uniform the definition of the keyword warnings through the supported languages: all the languages has now a separate file that defines the keywords or bad names: python/pythonkw.swg chicken/chickenkw.swg .... - Added keyword list for most of the languages that didn't have one (using the new separated file). - Added the "All keywords" warning support: -Wallkw option. This option allows you to include all the known keywords for all the supported languages, and can be used as: swig -Wallkw .... This will help to the process of adding a test-suite file that can be compiled in all the swig supported languages, and it will be also helpful for users who want to create multi-language libraries. And these are the detailed changes (mostly file addition): - For the languages that already have some sort of keyword warning list, move it to an external languagekw.swg file, ie: move keywords from python.swg -> pythonkw.swg move keywords from chicken.swg -> chickenkw.swg move keywords from tcl8.swg -> tclkw.swg and re-include languagekw.swg from language.swg. - For the language that didn't have a keyword list, and for the ones that I could find a list, add the languagekw.swg file, ie: csharp/csharpkw.swg java/javakw.swg php4/phpkw.swg pike/pikekw.swg ruby/rubykw.swg also add a line in language.swg to include languagekw.swg, but now it is commented!!!, like in java.swg: /* java keywords */ /* please test and activate */ //%include "javakw.swg" ie, there will be no change in how swig runs normally until the language maintainer test and uncomment that line. So, please check each languagekw.swg file (I left the link to the keyword list source for checking), and after testing, uncomment the %include line. - Added the file allkw.swg, which includes all the languagekw.swg files. For the languages that has no languagekw.swg file right now, and if they need one, add the file into the language directory, and add the corresponding include line into the allkw.swg file. - Added the -Wallkw that includes the allkw.swg file. Note that the old -lallkw.swg option couldn't be used since it include the file after it would be needed. Hopefully, the -Wallkw option will be added to the default rules in the related test-suite Makefiles, so, when creating a new test, or adding a new swig library file (like _std_deque.i), swig will warn you if you are using a bad name, considering all the language where it needs to run. Right now you can test it by using: make check-python-test-suite SWIG="swig -Wallkw" or using your favorite target language, it doesn't matter. And yes, there are several examples that are using reserved keywords, specially from csharp. *** Remember ****: the new keyword warning lists are not included by default in any of language that before didn't have one. To enable the keyword warnings as the default behavior, the inclusion of the languagekw.swg file has to be uncommented at each language.swg file. So, all the language maintainers, please check the keywords list. Also, you can add buit-in names, and not only keywords, like 'True/False' in python. Remember that you can be more specific and refer only to member names, like *::configure or *::cget (see an example in the tcl8/tcl8kw.swg file), or only global names, like ::range (see an example in the python/pythonkw.swg file. Just to be consistent, use the following codes: - Use code 314 for keyword and/or fatal bad names. - Use code 321 for buit-in and/or not fatal bad names. so, they can't be disabled/enabled independently (see python/pyhtonkw.swg for examples). **** And don't add any new test file without checking it with the -Wallkw option!! (that includes me) *****. 12/11/2003: cheetah (William Fulton) SF bug #854634 Added support for accepting the Unix directory separator '/' on Windows and the Mac in addition to the native one ( '\' on Windows). This can be used in %import, %include and commandline options taking a path, for example -I. On Cygwin, both the Windows and Unix directory separator can now be used (was '/' only). 12/10/2003: mmatus (Marcelo Matus) [python] Implementing the runtime "reprotected" director members, if you have: %feature("director") B; class Bar { public: virtual ~Bar(); virtual int hello() { return do_hello();) protected: virtual int do_hi() {return 0;} virtual int do_hello() {return 0;} }; then, at the python side import my_module class Foo(my_module.Bar): def do_hello(self): return 1 pass b = Bar() # Pure C++ Director class f = Foo() # C++ Director + python methods b.hello() # Ok, and it calls C++ Bar::do_hello() f.hello() # Ok, and it calls Python Foo::do_hello() b.do_hi() # RuntimeError, do_hi() is protected!! f.do_hi() # RuntimeError, do_hi() is protected!! b.do_hello() # RuntimeError, do_hello() is protected!! f.do_hello() # Ok, since it its redefined in python. Here Bar.do_hello is always protected, but Foo.do_hello is "public", because it is redefined in python. Before, all the 'do_hello' methods were public. This seems to be a good compromise between C++ and python philosophies, ie, all the director protected methods keep protected at the user side (C++ way) until they are redefined (python way, were all defined methods are always public). And this is not only a good compromise, it also seems to be the only way to do it :). Now ruby has native director protected members, and python pure runtime support. I guess these are the two possible extreme cases. And hopefully, they could be used as templates to modify the other languages that support directors, so they can "reprotect" the protected director members at the target language side. This finished the director protected support for the python language. Ocalm will need to add the "reprotection" later. 12/10/2003: mmatus (Marcelo Matus) The following case (reported by Lyle Johnson) was fixed: %rename(x) Foo::y(); class Foo { public: void y(); protected: int x; }; swig warned that the symbol 'x' was already defined, and the renaming fails. 'x' was not emitted, since it is protected, but it was kept in the symbol table with too much information. Now swig works for all the cases (plain, director and dirprot) again. This was fixed by allowing the parser.y to decide much closer what to do with 'x'. Before all the discarding or generation was resolved at the lang.cxx stage. Also the changes in parser.y to implement the director protected mode are now much more encapsulated, and they get disabled if the mode is not enabled. Before the deactivation was done at the generation stage (lang.cxx). By the other hand, if the director mode is enabled, and %rename is done, reusing a protected member name, there is a pathological case: %rename(x) Foo::y(); class Foo : public A { public: void y(); protected: int x; /* works */ static int x; /* works */ static void x(); /* works */ typedef void x(); /* works */ virtual void x(); /* always fails, as it should, since Foo::x() will be emitted in the director */ void x(); /* always fails, but sometimes it shouldn't, since the Foo::x() will not be emitted if it is not virtual */ }; The last case is not always right because at the parser.py stage it is not possible to decide if the protected member Foo::x() could or not conflict with the renamed Foo::y(), since Foo::x() could be virtual by inheritance. I guess this just an intrinsic limitation, and no much can be done about it without resorting into larger changes to postpone, under certain conditions, the multiply symbol detection (lang.cxx stage). So, by now, it is just considered a well known "feature" in the director protected mode. The good news is that it seems to be a rare case, and it can be avoided by the user by hiding 'x' before renaming 'y': %rename(_x) Foo::x(); %rename(x) Foo::y(); 12/08/2003: mmatus (Marcelo Matus) The virtual method detections now properly treats the following cases: namespace foo { typedef int Int; } struct A {}; typedef A B; struct Foo { virtual ~Foo() {} virtual Foo* cloner() = 0; virtual int get_value() = 0; virtual A* get_class() = 0; virtual void just_do_it() = 0; }; struct Bar : Foo { Bar* cloner(); foo::Int get_value(); B* get_class(); void just_do_it(); }; All the Foo and Bar methods are virtual. A new attribute "virtual:type" record the base polymorphic type. In the previous cases we have: type : Bar virtual:type : Foo type : foo::Int virtual:type : int type : B virtual:type : A type : void virtual:type : void This attribute is useful in languages (java+directors) that could have problems redefining Bar* Bar::cloner(). If you never had code like the above, you will see no effects. But if you have some code like that, you will see some effects since some methods that before were not properly treated as virtual, will start to act like that. This could enlarge your director classes. 12/08/2003: mmatus (Marcelo Matus) The director protected member support (dirprot) is disabled by default. It can be enable by using '-dirprot' or by adding the option to the module declaration, like: %module(directors="1",dirprot="1") my_module This module option was added to properly compile the director_protected.i and director_nested.i examples. The feature has been tested with python[2.2,2.3] and ruby[1.6.7], both at compilation and runtime, and java[j2sdk1.4.1_01], but only at compilation (my java installation doesn't run any of the director examples, olds nor news). Please test for ocaml and java. The errors reported by William and Scott were fixed, except for a warning about SWIG_JavaThrowExecption() multiply defined. I can't reproduce this error with my examples. We will wait for Scott to send us a minimal case. 12/07/2003: mmatus (Marcelo Matus) The director protected member support has been completly moved out from python.cxx, and now resides in the common lang.cxx, emit.cxx and allocate.cxx files. This means it should work for all the other languages that currently support directors, ie, python, java, ocalm and ruby. The change has been tested with python (compilation+runtime) and java (just compilation). Please add runtime tests for the missing languages and test it. The '-nodirprot' option was moved to the principal main, and can be used from all the languages. 12/07/2003: cheetah (William Fulton) [Java] Fixed and improved error checking of STRING_OUT typemaps in various.i. 12/04/2003: mmatus (Marcelo Matus) - Now the virtual members with no explicit declarator are properly identified: struct A { virtual int f() = 0; }; struct B : A { int f(); }; Here, B::f() is virtual, and the director and the virtual elimination mechanism now recognize that. - [C#] This fix also fixes the problem where 'override' was not being used on any overridden virtual method, so for struct B above, this C# code is generated: public class B : A { ... public override int f() { ... } ... } - Initial support for protected virtual methods. They are now properly emitted when using with director (python only by now). %feature("director") A; struct A { protected: virtual int f1() = 0; }; %feature("director") B; struct B : A{ protected: int f1(); virtual f2(); }; This can be dissabled by using the '-nodirprot' option. - The feature 'nodirector' is working now at the top level, so, it must work for all the languages: %feature("director") A; %feature("nodirector") A::f2; struct A { virtual int f1(); virtual int f2(); }; in this case, only 'f1' is exported to the director class. - Added director support for const TYPE& arguments (python). 12/02/2003: cheetah (William Fulton) [Java] Fix for INOUT and OUTPUT typemaps in typemaps.i for when the JNI type is bigger than the C type. For example, unsigned long (32bits on most systems) is mapped to jlong (64bits). Returned value was incorrect. Bug reported by Brian Hawley. 12/02/2003: cheetah (William Fulton) [C# and Java] Better fix for entry dated 05/11/2003. Fixes the following typemaps: Java: javabase, javainterfaces, javaimports, javaclassmodifiers, javaptrconstructormodifiers, javafinalize, javagetcptr & javacode. C#: csbase, csinterfaces, csimports, csclassmodifiers, csptrconstructormodifiers, csfinalize, csgetcptr & cscode. It also fixes bug in using arrays of C structs with arrays_java.i as reported Scott Michel. 12/02/2003: beazley [Perl] Fixed [ 852119 ] recursive inheritance in output .pm, perl5. Reported by William Dowling. 12/02/2003: beazley [Tcl] Fixed [ 755382 ] calling func(const vector& p) evaluates p[0] in interp. The Tcl type checker was improperly handling the interpreter result when type violations were supposed to be ignored. Reported by Flaviu Popp-Nowak. 11/30/2003: cheetah (William Fulton) Fixed [ 545058 ] configure's --with-tclincl has no effect 11/30/2003: cheetah (William Fulton) [Java] Fixed [ 766409 ] missing symbol SWIG_JavaThrowException during module load SWIG's internal functions are all static as there is no need for different SWIG generated modules to share any code at runtime. 11/30/2003: beazley [Tcl] Added support for C++ pointers to members. 11/28/2003: cheetah (William Fulton) Fixed [ 848335 ] Directors: #include wrapper .h file - was incorrectly adding a directory to the generated #include "foo_wrap.h" statement in some situations. 11/28/2003: cheetah (William Fulton) [Java] Fixed [ 849064 ] JAVA : Access modifier for derived class wrong. The delete() method is always public now. It used to be protected whenever a destructor was non public. An UnsupportedOperationException runtime exception is thrown instead of making delete() protected now. 11/28/2003: beazley [Perl5] Added support for C++ pointers to members. 11/28/2003: beazley Fixed [ 850151 ] PYVERSION with python2.3 in configure of SWIG 1.3.19 (Maybe). 11/28/2003: beazley Fixed [ 850666 ] #include extra line added. This should fix some problems with getting correct line numbers on error messages. 11/26/2003: beazley Fixed another one of Marcelo's evil template bugs (infinite recursion). [ 849504 ] template and typedef -> inf. recursion. 11/26/2003: beazley Fixed parsing problem with declarations like this: int *x = &somearray[0]; 11/25/2003: beazley Fixed [ 756552 ] missing default argument class scope with "|". This is really only a band-aid fix for use of class-enums in expressions. For example: class A { public: enum Flag { flag1 = 0x1, flag2 = 0x2 }; void foo(int x = flag1 | flag2); }; Note: there are still some (more subtle) cases that are broken, but hard to fix due to an issue with template expansion. Will address later. Reported by Dmitry Mironov. 11/25/2003: beazley Incorporated [ 840878 ] support for %inline { ... } (PATCH). This adds support for the following: %inline { ... some code ... } The difference between this and %inline %{ ... %} is that the enclosed text is processed by the SWIG preprocessor. This allows special macros and other processing to be used in conjunction with %inline. Contributed by Salvador Fandino Garcia. 11/25/2003: beazley Fixed [ 836903 ] C++ inconsistency (with void arguments). SWIG was having difficulty with f() vs f(void) in C++ programs. For instance: class A { public: virtual void f(void) = 0; }; class B { public: virtual void f(); // Not matched to f(void) correctly }; The parser now normalizes all declarations of the form f(void) in C++ classes to f(). This should fix a variety of subtle problems with inheritance, optimizations, overloading, etc. Problem reported by Partho Bhowmick. 11/25/2003: beazley [Perl5] Incorporated [ 841074 ] better croaking (PATCH). This fixes some problems with strings and provides some new error functions. Contributed by Salvador Fandino Garcia. 11/25/2003: beazley Fixed [ 791835 ] Default argument with cast: txt = (char *)"txt" syntax Error. The parser should now accept things like this: void foo(char *s = (char *) "Hello"); Problem reported by Claudius Schnorr. 11/24/2003: beazley [Tcl] Fixed problem with cross module linking. Previously modules referred to base classes through a global variable. Now, the module looks up base classes through the type system itself---avoiding the need to link to a global like before. Caveat: modules with base classes must be loaded before modules with derived classes. 11/24/2003: mkoeppe (Matthias Koeppe) [Guile] In -scm mode, use () to represent null pointers, as it is done in -gh mode. 11/23/2003: mkoeppe (Matthias Koeppe) Add a generated script "preinst-swig", which can be used to invoke SWIG before it has been installed. It arranges that the runtime libraries from the source directory are used. 11/23/2003: mkoeppe (Matthias Koeppe) [Guile] In -gh mode, don't forget to call SWIG_Guile_Init. Add a SWIG_contract_assert macro. 11/23/2003: mkoeppe (Matthias Koeppe) [MzScheme] Update the configure check for the dynext object to work with MzScheme 205. 11/20/2003: mmatus Fixed the include/import error reported by Kerim Borchaev, where two files with names like 'dir1/hello.i' 'dir2/hello.i' can not be include at the same time. Swig was including just the first one, assuming the second one was not a different one, since it was checking/keeping just the basename 'hello.i'. 11/19/2003: beazley Changes to the SWIG runtime library support. - The -c command line option has been renamed to -noruntime - New command line option: -runtime. When supplied, this inserts the symbol SWIG_GLOBAL into the wrapper code. This, in turn, makes all of the runtime support functions globally visible. - New library file: swigrun.i. Used to create modules for runtime library (if needed). 11/18/2003: cheetah (William Fulton) 'make srcrpm' rpmbuild fix - patch from Joe Cooper 11/18/2003: mkoeppe (Matthias Koeppe) [Guile] Change meaning of configure option --with-guile to the name of the Guile executable. The new option --with-guile-prefix can be used to specify the tree where Guile is installed. (However, usually it suffices to use the single option --with-guile-config.) When running the run tests test-suite, make sure to use the version of Guile that SWIG was configured for. 11/17/2003: mkoeppe (Matthias Koeppe) [Guile] Improvements to object-ownership management in "-scm" mode. (They do not apply to the default "-gh" mode.) * Renamed the smob type that indicates that the object can be garbage collected from "collected swig" to "collectable swig", which is more precise. * Export the destructor functions again. It is now allowed to explicitly call destructors, even for garbage-collected pointer objects. A pointer object that has been passed to a destructor is marked in a special way using a new smob type, "destroyed swig". (This helps avoid nasty memory bugs, where references to dead C objects are still held in Scheme. Moreover, the garbage collector will not try to free a destroyed object once more.) * Destructor-like functions can also mark their arguments as destroyed by applying the typemap SWIGTYPE *DESTROYED. (It calls the function SWIG_Guile_MarkPointerDestroyed.) * Functions that "consume" their objects (or that "own" them after the call) can mark their arguments as not garbage collectable. This can be done by applying the typemap SWIGTYPE *CONSUMED. (It calls the function SWIG_Guile_MarkPointerNoncollectable.) * The macro TYPEMAP_POINTER_INPUT_OUTPUT from library pointer-in-out.i creates additional typemaps PTRTYPE *INPUT_CONSUMED, PTRTYPE *INPUT_DESTROYED. They mark the passed pointer object likewise. The typemap PTRTYPE *OUTPUT creates a garbage-collectable pointer object, like %newobject does for a returned pointer. Use the new typemap PTRTYPE *OUTPUT_NONCOLLECTABLE to create a pointer object that will not be garbage collected. 11/17/2003: mkoeppe (Matthias Koeppe) [Guile] Handle $input in "freearg" typemaps. Never qualify GOOPS slot names with the class name. Handle optional arguments properly in the GOOPS methods. 11/16/2003: cheetah (William Fulton) Fixes for installation to work with the upcoming Automake-1.8. mkinstalldirs was being used by a non-Automake makefile. mkinstalldirs is being phased out and so was not being created by Automake. install-sh used instead. 11/16/2003: cheetah (William Fulton) [Java] Numerous director improvements, tweaks and bug fixes since the initial implementation have been contributed by Scott Michel. 11/12/2003: beazley [Python] When %feature("shadow") is used to add code to shadow classes, the special variable $action expands to the name of the underlying wrapper function that would have been called normally. 11/12/2003: beazley [Python] When generating proxy class code, SWIG emits a few default methods for __repr__() and other Python special methods. Some of these methods are emitted after all of the contents of a class. However, this makes it hard to override the methods using %pythoncode and some other directives that allow code to be inserted into a class. These special methods are now emitted into the code *before* all of the other methods. Suggested by Eric Jones. 11/11/2003: beazley Preprocessor enhancement. For include statements like this: %include "foo/bar.i" the directory "foo" is now added to the search path while processing the contents of bar.i. Thus, if bar.i includes other files in the same directory, they will be found. Previously, you would have to add additional directories using -I to make this work correctly. Note: the C preprocessor seems to behave in an identical manner on many (most? all?) systems. Suggested by Kerim Borchaev. 11/11/2003: beazley Configuration changes to make SWIG work on Mac OSX 10.3.x (Panther). Tested with Python, Tcl, Perl, and Ruby---all of which seem to work. 11/08/2003: cheetah (William Fulton) [Java] Fixed the typemaps in various.i which were mostly broken. char **STRING_IN and char **STRING_RET typemaps replaced with STRING_ARRAY. float *FLOAT_ARRAY_RETURN typemap removed. 11/08/2003: beazley [Tcl] Tcl module now emits a safe module initialization function by default. It can be removed by running 'swig -nosafe'. 11/04/2003: mkoeppe (Matthias Koeppe) [Guile] Only use the SCM_ API when the function `scm_slot_exists_p' exists (needed for GOOPS support). This function was renamed during the Guile 1.5 series from `scm_slots_exists_p'. Report the right runtime library when invoked with -scm -ldflags. 11/03/2003: mkoeppe (Matthias Koeppe) [Chicken] Fix #782052. The --with-chickencfg configure option (and others) were not accepted. 11/02/2003: mkoeppe (Matthias Koeppe) [Guile] Merge new set of GOOPS changes by John Lenz. GOOPS objects are now manipulated directly by the C code. Some fixes to typemap-GOOPS interaction. 11/02/2003: mkoeppe (Matthias Koeppe) [Guile] Remove the file argument to -scmstub and -goops. The Scheme files are now always called MODULE.scm or MODULE-primitive.scm, where MODULE is the module name and "primitive" can be changed by the -primsuffix option. The Scheme files are now placed in the directory given by the -outdir option, or the current directory. (Patch by John Lenz, slightly modified.) *** INCOMPATIBILITY [Guile] *** 11/02/2003: mkoeppe (Matthias Koeppe) Unify the pointer-conversion runtime API. The standard functions are: * SWIG_NewPointerObj (POINTER, TYPE, FLAGS) -- Create an scripting object that represents a typed pointer. FLAGS are language specific. * SWIG_ConvertPtr (INPUT, RESULT, TYPE, FLAGS) -- Get a pointer from the scripting object INPUT and store it in the place RESULT. When a type mismatch occurs, return nonzero. * SWIG_MustGetPtr (INPUT, TYPE, ARGNUM, FLAGS) -- Get a pointer from the scripting object INPUT and return it. When a type mismatch occurs, throw an exception. If ARGNUM > 0, report it as the argument number that has the type mismatch. [Guile]: No changes. [MzScheme]: No changes. [Perl]: Add the function SWIG_NewPointerObj. The function SWIG_MakePtr is kept. The function SWIG_MustGetPtr is currently not supported. [Python]: Add the function SWIG_MustGetPtr. [Ruby]: Add the function SWIG_MustGetPtr. [Tcl]: Remove the "interp" argument of SWIG_NewInstanceObj, SWIG_ConvertPtr, SWIG_ConvertPacked, and SWIG_ConvertPtrFromString. The function SWIG_MustGetPtr is currently not supported. No changes to Pike because its pointer conversion code did not look complete. No changes to PHP4, because I did not understand its runtime code. No changes to Chicken because major changes are expected soon anyway. No changes to Java, OCaml, C# because they do not seem to have a pointer-conversion runtime API. *** INCOMPATIBILITY [Tcl] *** 11/02/2003: mkoeppe (Matthias Koeppe) [Perl5, PHP4, Pike, Python, Ruby, Tcl]: Use the preprocessor to rename external functions of the SWIG runtime API to follow the naming convention SWIG__. This should allow linking more than one interpreter into a program. 10/31/2003: cheetah (William Fulton) [C#] Fix since introducing the exception and std::string delegates. The fix overcomes linker errors when using more than one SWIG module. Problem reported by Andreas Schörk. 10/31/2003: beazley Incorporated patch: [ 823302 ] Incr Tcl support. Contributed by Alexey Dyachenko. Note: needs documentation. 10/31/2003: beazley Incorporated patch: [ 829325 ] new Python Module options and features. Robin Dunn writes: This patch makes a number of changes to the SWIG python module. 1. Add -apply option, and change the default code output to use the foo(*args, **kw) calling syntax instead of using apply(). If the -apply option is given then code is generated as before. This is very similar to Patch #737281 but the new -modern option makes the second half of that patch unnecessary so it is not included here. 2. Add -new_repr option. This is the same as my Patch #797002 which I will mark as closed since it is no longer needed. When this new option is used then the __repr__ methods that are generated for proxy classes will be more informative and give details about the python class and the C++ class. 3. Add %feature("addtofunc"). It allows you to insert one or more lines of code inside the shadow method or function that is already generated, instead of replacing the whole thing like %feature("shadow") does. For __init__ it goes at the end, for __del__ it goes at the begining and for all others the code generated is expanded out to be like def Bar(*args, **kwargs): val = _module.Foo_Bar(*args, **kwargs) return val and the "addtofunc" code is inserted just before the return statement. If the feature is not used for a particular method or function then the shorter code is generated just like before. 4. A little bit of refactoring to make implementing addtofunc a little easier. 5. Added a -modern command-line flag that will cause SWIG to omit the cruft in the proxy modules that allows it to work with versions of Python prior to 2.2. The result is a simpler, cleaner and faster python proxy module, but one that requires Python 2.2 or greater. 10/31/2003: beazley Incorporated patch: [ 829319 ] XML module tweaks. This adds a new command line option -xmllite that greatly reduces the amount of emitted XML code by eliminating some fields mostly used in SWIG's internal processing. Contributed by Robin Dunn. 10/31/2003: beazley Incorporated patch: [ 829317 ] Adds DohSplitLines function. Contributed by Robin Dunn. 10/29/2003: beazley Fixed [ 827907 ] argout objects not being wrapped properly (PATH). Patch contributed by Salvador Fandiño García. 10/29/2003: beazley Fixed [ 826996 ] perl type checking ignores perl subclasses. This enhancement makes it so wrapped classes and structs can be subclassed in Perl and used normally. Patch contributed by Salvador Fandiño García. 10/16/2003: cheetah (William Fulton) [C#] IntPtr marshalled with a void* instead of int in C function declarations. The casts thus look more conventional, for example: // old DllExport double SWIGSTDCALL CSharp_get_Shape_x(int jarg1) { ... Shape *arg1 = (Shape *) 0 ; arg1 = *(Shape **)&jarg1; ... } // new DllExport double SWIGSTDCALL CSharp_get_Shape_x(void * jarg1) { ... Shape *arg1 = (Shape *) 0 ; arg1 = (Shape *)jarg1; ... } 10/14/2003: beazley Fixed a subtle problem with overloaded methods and smart pointers. If a class has overloaded methods like this: class Foo { public: int bar(int x); static int bar(int x, int y); }; and the class is used as a smart pointer: class FooPtr { public: Foo *operator->(); }; The SWIG would try to expose the static member Foo::bar through FooPtr---resulting bogus wrapper code and a compiler error. Due to the way in which overloading is handled, it is extremely difficult to eliminate the static method in this case. Therefore, it is still exposed. However, the generated code now compiles and works. 10/05/2003: mkoeppe (Matthias Koeppe) [Guile, MzScheme, Chicken]: Remove symbol clashes between the runtime libraries by renaming all extern common.swg functions with the preprocessor. 10/05/2003: mkoeppe (Matthias Koeppe) [Guile] Added basic GOOPS support, contributed by John Lenz. See the documentation for details. *** NEW FEATURE *** 10/04/2003: mkoeppe (Matthias Koeppe) [Guile] New option, -only-setters, which disables traditional getter and setter procedures for structure slots. 10/03/2003: mkoeppe (Matthias Koeppe) [Guile] Added run test for reference_global_vars by John Lenz. 09/30/2003: beazley Partial solution to [ 792180 ] C++ smart-pointer/namespace mixup revisited. The problem is not easy to fix (at least it doesn't seem so), but is related to the instantiation of qualified templates inside of other namespaces. SWIG now generates an error message in this case rather than generating broken wrappers. 09/30/2003: beazley Fixed [ 800012 ] ENTER macro from CORE/scope.h clashes with libc search.h. Reported by Britton Leo Kerin. 09/30/2003: beazley Fixed [ 811518 ] Casting ints to doubles (w/ solution?) Addresses a problem with overloading in the Perl module. Reported by Gerald Dalley. 09/28/2003: mkoeppe [Guile with -scm option] Fix typo in generated code for procedures-with-setters. Reported by John Lenz. 09/26/2003: beazley Fixed [ 812528 ] externs not correct when throw is in signature. Reported by Joseph Winston. 09/23/2003: cheetah (William Fulton) SWIG was generating a number of symbols that didn't comply with the ISO C/C++ standard, in particular ISO/IEC 14882:1998(E) 17.4.3.1.2 where double underscores are forbidden as well as symbols starting with an underscore followed by an upper case letter. Most of these have been rooted out. See new section added to internals.html development manual 'Symbol Naming Guidelines for Generated C/C++ Code'. 09/23/2003: cheetah (William Fulton) Director typemap name changes: inv => directorin outv => directorout argoutv => directorargout *** POTENTIAL INCOMPATIBILITY *** 09/19/2003: mrose (Mark Rose) [Python] Director constructors now default to __disown = 0, which is the intended behavior and fixes the director_finalizer test case under python. 09/12/2003: cheetah (William Fulton) [C#] - Typemaps added for std::string and const std::string &. - New delegate for creating a C# string given a char *. It can be used by calling SWIG_csharp_string_callback as shown in the std::string 'out' typemap. Useful if the return type is mapped to a C# string and the calling function is responsible for cleaning up memory as the C# garbage collector doesn't free the memory created in C/C++ and then returned as a C# string. - The exception delegates have moved into an inner class in the intermediate class, thereby freeing up the static constructor. 09/11/2003: beazley (Internals) Major refactoring of iteration over lists and hashes. The DOH library now uses iterators. They work like this: List *l = (some list); Iterator i; for (i = First(l); i.item; i = Next(i)) { // i.item contains the actual list item. // i.item is NULL at end of list ... } Hash *h = (some hash); Iterator j; for (j = First(h); j.item; j = Next(j)) { // j.item contains hash table item // j.key contains hash table key // Both j.item and j.key are NULL at end ... } The old iteration functions Firstitem(), Nextitem(), Firstkey(), and Nextkey() are gone. The new iterators are simpler, result in better memory use, and may be faster. Also, there are no longer any problems iterating over the same list/hash in multiple places at the same time. For example, this is fine: Iterator i,j; for (i = First(l); i.item; i = Next(i)) { for (j = First(l); j.item; j = Next(j)) { ... } } (This never worked in previous versions). *** POTENTIAL INCOMPATIBILITY ***. This will probably break third party extensions to SWIG (or give them further encouragement to join the SWIG CVS-tree :-). 09/10/2003: mkoeppe (Matthias Koeppe) [Guile] Fix memory leaks in the "list-vector.i" typemaps. 09/09/2003: mkoeppe (Matthias Koeppe) [Chicken] Use C_mk_bool rather than C_mkbool. This fixes the wrapping of boolean values for Chicken 1.10 and newer. Reported by Dave / Felix Winkelmann . 09/05/2003: cheetah (William Fulton) [Java] Directors implemented for Java. In summary this is a big new feature which supports upcalls from C++ to Java. Code is generated to support C++ callbacks to call into Java and true polymorphic behaviour for Java classes derived from C++ classes. See java.html for details. Contributed by Scott Michel. 09/05/2003: Tiger Created contract example directory at /SWIG/Examples/contract Added simple contract examples (simple_c & simple_cxx) Modified contract module's output format *** NEW FEATURE *** 09/01/2003: cheetah (William Fulton) Test-suite build improvements: - Multiple build directories working for the test suite, so it is now possible to run configure in multiple subdirectories and run the test suite in each of these sub directories. - 'make distclean' fixed so it doesn't bomb out on the Examples directory when using multiple subdiretory builds. Required the following directories to be moved: Examples/GIFPlot/Perl -> Examples/GIFPlot/Perl5 Examples/GIFPlot/Php -> Examples/GIFPlot/Php4 These new directories used to be symbolic links to the old directory. Also the Examples/test-suite/Perl symbolic link has been removed. - Running the test-suite, other than from the root directory, say in Examples/test-suite/python will now display all the code being executed. - The following 3 C# compilers are detected during configure and work with the test-suite: Mono, Portable.NET and Microsoft. 09/01/2003: Tiger Added inheritance support for design by contract feature. 09/01/2003: beazley Fixed [ 794914 ] Wrong types in template specialization. SWIG was not handling arguments correctly in template partial specialization. For example, template class Foo { public: T *blah(); }; %template(FooInt) Foo; in this class, the return type of blah was set to 'int **', but it should really be 'int *'. This has been fixed, but it will affect all prior uses of partial specialization. 09/01/2003: beazley Fixed [ 786394 ] Patch for generated perl code does not compile under RedHat9. Reported by Scott Finneran. 09/01/2003: beazley Fixed [ 791579 ] (unsigned) long long handled incorrectly (Tcl). This was an error in the Tcl typemaps.i file. Reported by Kjell Wooding. 09/01/2003: beazley Fixed [ 797573 ] no way to rename classes coming from C structures. This problem relates to renaming of anonymous structures with a typedef. For example: %rename(Bar) Foo; typedef struct { ... } Foo; Reported by Britton Leo Kerin. 09/01/2003: beazley Fixed [ 797576 ] -help seems to imply that only tcl-specific options exist. Added a comment to alert user to other options. Reported by Britton Leo Kerin. 09/01/2003: beazley Fixed [ 798205 ] Segfault in SWIG_ConvertPtr. Reported by Prabhu Ramachandran. 08/30/2003: mrose (Mark Rose) Modified the director typemaps in python/std_complex.i to use the new-style macro and conversion functions, which eliminated some redundant code. Fixed a few bugs in these typemaps as well, although more testing is needed. 08/29/2003: mrose (Mark Rose) Completed initial support for wrapping abstract classes with directors. Constructor wrappers will be generated for abstract classes that have directors, and instances of the director classes will be created regardless of whether the proxy class has been subclassed in the target language. No checks are made during construction to ensure that all pure virtual methods are implemented in the target language. Instead, calls to unimplemented methods will throw SWIG_DIRECTOR_PURE_VIRTUAL_EXCEPTION exceptions in C++. Integrated Prabhu Ramachandran's typemap patches, which provide director typemap support for enums and std::size_t, and fix a couple bugs in the director std::vector<> typemaps. 08/29/2003: cheetah (William Fulton) [C#] Implemented exception handling for throwing C# exceptions from C/C++ code. A few delegate functions are available for calling which then throw the C# exception. Use the SWIG_CSharpThrowException function from C/C++ typemaps. See the generated wrapper code or csharphead.swg for all available exceptions. Example: SWIG_CSharpThrowException(SWIG_CSharpException, "exception description"); The 'throws' typemaps are also now implemented, so code is automatically generated to convert any C++ exception into a C# System.Exception when the C++ method declares an exception specification such as: int foo() throw(Bar); Also any parameters that are references to a C++ class or a class passed by value and are passed as a C# null will now throw a C# NullReferenceException. 08/29/2003: cheetah (William Fulton) [C#] Fix to match the calling convention of all pinvoke methods so that they match the calling convention used by default in the C# 'static extern' declarations (__stdcall is used on Windows). 08/19/2003: cheetah (William Fulton) [Java] Reworked std::string typemaps. Fixes a number of string in std namespace problems. For example %template vector. The templated class' get method wasn't returning a Java String, but a SWIGTYPE_p_string. Reported by Zach Baum. 08/15/2003: beazley Fixed [ 763522 ] 1.3.19 segfault in SwigType_add_pointer/DohInsertitem. Related to problem with unnamed class handling in Perl module. 08/15/2003: beazley Fixed [ 763563 ] Missing indication of optional arguments. Tcl module. Reported by Krzysztof Kozminski. 08/15/2003: beazley Fixed [ 787432 ] long param handled as int. Tcl module now uses Tcl_GetLongFromObj to convert integer values. 08/11/2003: beazley Fixed [ 775989 ] numeric template parameters. There were some errors in template expansion related to the use of arrays where the array dimension was a template parameter. It should work now. Reported by Bryan Green. 08/10/2003: mrose (Mark Rose) Added a director typemap (outv) for return by value and cleaned up up a few of the commented director typemaps. 08/10/2003: mrose (Mark Rose) Fixed constructor generation for director classes to ignore private constructors. Protected constructors are also ignored for now, pending a solution to the problem of wrapping classes that only define protected constructors. 08/07/2003: cheetah (William Fulton) New commandline option -outdir to specify where the language specific files are to be generated. This is useful for target languages like Python, Java etc which generate proxy files in the appropriate language. This option does not apply to the C/C++ wrapper file. 08/07/2003: cheetah (William Fulton) On Windows the generated files (other than the _wrap.c or _wrap.cxx files) were sometimes incorrectly being generated into the current directory unless the input file used the Unix path separator. The Windows path separator should now be used. Bug reported by Robert Davies. 08/07/2003: beazley Added array variable set typemap to Perl module. 08/07/2003: beazley Fixed [ 775677 ] Array init causes codegen bug.. 08/07/2003: beazley Fixed [ 779062 ] Class"\n"::foo not supported. SWIG should now correctly handle whitespace in between namespace qualifiers. For example "A :: Foo :: Bar". 07/31/2003: cheetah (William Fulton) Fixes for parameters which are classes that are passed by value and have a default value. A copy constructor for SwigValueWrapper is required (SF #780056). Also fixed memory leak in these circumstances. These mods also fix SF #780054. 07/28/2003: beazley Improved run-time error message for pointers in Python module. Contributed by Zooko. 07/10/2003: ballabio (Luigi Ballabio) [Almost all languages] Wrappers for std::pair added. Typemaps for Python, Ruby, Guile and MzScheme. 07/01/2003: mkoeppe (Matthias Koeppe) [Chicken] Handle the case of more than one argout typemap per function. 06/29/2003: cheetah (William Fulton) [Java, C#] SF #670949 request. The destructor wrapper function name is now configurable. A new attribute called methodname in the javadestruct/javadestruct_derived (Java) or csdestruct/csdestruct_derived (C#) typemaps specifies the method name. For example in Java the destructor is wrapped by default with the delete method: %typemap(javadestruct, methodname="delete") SWIGTYPE {...} 06/27/2003: cheetah (William Fulton) [Java, C#] The throws attribute for adding exception classes to the throws clause also now works with the following typemaps: newfree javain, javaout (Java) csin, csout (C#) For example, the 'AnException' will be added to the throws clause in the proxy function: %typemap(javaout, throws="AnException") int { int returnValue=$jnicall; if (returnValue==0) throw new AnException("Value must not be zero"); return returnValue; } 06/25/2003: mrose (Mark Rose) [Python] Director typemap marshalling checks for null pointers when walking the parameter list instead of relying soley on the parameter count. Cures a segfault that occurred for multiple argument inv typemaps. Someone with more Swig experience should probably review this code. 06/24/2003: mkoeppe (Matthias Koeppe) [Chicken] Don't emit calls to "C_check_for_interrupt", which may result in an endless loop. Patch by felix@proxima-mt.de. 06/20/2003: cheetah (William Fulton) [C#] Finalizers now use destructor syntax as the override which was used in the Finalize method is not in the ECMA standards, spotted by the MS compiler. 06/10/2003: cheetah (William Fulton) [C#] A number of changes have been made to remove the Java naming that was used in the C# module. Typemap name changes: jni -> ctype jtype -> imtype jstype -> cstype javain -> csin javaout -> csout javainterfaces -> csinterfaces javabase -> csbase javaclassmodifiers -> csclassmodifiers javacode -> cscode javaimports -> csimports javaptrconstructormodifiers -> csptrconstructormodifiers javagetcptr -> csgetcptr javafinalize -> csfinalize Feature name changes: javaconst -> csconst javamethodmodifiers -> csmethodmodifiers Pragma changes: pragma(java) -> pragma(csharp) jniclassbase -> imclassbase jniclassclassmodifiers -> imclassclassmodifiers jniclasscode -> imclasscode jniclassimports -> imclassimports jniclassinterfaces -> imclassinterfaces Special variable name changes: $javaclassname -> $csclassname $javainput -> $csinput $jnicall -> $imcall This will break SWIG interface files that use these typemaps, features and pragmas. Please update your code or use macros for backwards compatibility. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 06/10/2003: mkoeppe (Matthias Koeppe) [MzScheme] Applied MzScheme module updates contributed by John Lenz . - Updated mzscheme to use SWIG's common runtime type system from common.swg. - The Lib/mzscheme directory has been reorganized to standardize names across the language modules: mzscheme.i was moved to mzscheme.swg, mzscheme.swg and mzschemedec.swg have been removed, mzrun.swg (which contains the runtime code) has been added. - The swig_proxy structure was renamed to swig_mz_proxy. swig_mz_proxy now contains a pointer to a swig_type_info structure. - Added varin and varout typemaps for SWIGTYPE [] and SWIGTYPE &. - Garbage collection by calling scheme_add_finalizer() has been added. *** NEW FEATURE [MzScheme] *** 06/10/2003: cheetah (William Fulton) [Java] New typemaps: javadestruct and javadestruct_derived for the C++ destructor wrapper. The javadestruct version gets used by classes at the top of an inheritance chain and the javadestruct_derived version gets used by other classes. [C#] cildispose and cildisposeoverride typemaps replaced by csdestruct and csdestruct_derived typemaps. The delete() method has been removed and its functionality put into these typemaps designed for the Dispose() method. - New typemaps csinterfaces and csinterfaces_derived replace the javainterfaces typemap. Also fixes the peculiarity of all classes in an inheritance chain individually deriving from the IDisposable interface. - New typemap csfinalize for finalizers. C++ destructors are now called by garbage collector during finalization. Problem reported by Andreas Schörk. 06/10/2003: Tiger Modified contract code for error message output. Contract code can now print out simple error message. Modified contract code to prepare for inheritance 06/03/2003: mkoeppe [Guile] Applied Guile module updates contributed by John Lenz . - SWIG currently uses Guile's gh_ API, which is marked as deprecated in Guile 1.6 and will be removed in Guile 1.9. This change introduces a command-line flag "-scm" which causes SWIG to generate wrappers that use Guile's SCM API instead; this requires Guile >= 1.6. - The Lib/guile directory has been reorganized to standardize names across language modules: guiledec.swg and guile.swg have been moved into guile_gh_run.swg, guile.i has been moved to guile_gh.swg, guile_scm.swg and guile_scm_run.swg which contain the SCM API stuff have been added - ghinterface.i, which contains the defines from the gh_ functions to the scm_functions has been added - The API for dealing with pointer objects is now SWIG_ConvertPtr, SWIG_MustGetPtr, SWIG_NewPointerObj. - Added varin and varout typemaps for SWIGTYPE [] and SWIGTYPE & - Garbage collection has been added. *** NEW FEATURE [Guile] *** 06/01/2003: cheetah (William Fulton) Dimensionless arrays such as int foo[] = {1, 2}; extern int bar[]; produce a warning that the variable is read-only. Depending on the target language, this used to cause compile errors or generate a setter that generated a runtime error. A setter cannot be automatically generated because the array size cannot be determined by SWIG. A varin, globalin or memberin typemap (depending on the target language) must be written by the user. 05/29/2003: beazley Refinement to default typemap matching and arrays. When an array is declared like this: int foo[4]; The default typemap now resolves to SWIGTYPE [ANY] If no match is found for that, it then resolves to SWIGTYPE [] If no array dimension is specified in the original declaration, the SWIGTYPE [] is used right away. Note: This change has been made to resolve problems related to arrays with and without dimensions. For example, sometimes SWIG was generating setter functions for array variables with no dimensions (an error). Likewise, SWIG sometimes made arrays with dimensions read-only (also an error). This fixes the arrays_global test problem. 05/28/2003: beazley Fixed subtle type handling bug with references and pointers. If you had functions like this: typedef Foo Bar; Foo *func1(); void func2(Bar &x); Then func2() wouldn't accept objects returned by func1() because of a type error. It should work now. Reported by Brian Yang. 05/21/2003: cheetah (William Fulton) Fixes to some of the Visual C++ example project files which would not work with spaces in the paths held in the environment variables used to point to the target language's library / include directory. SF bug #740769 05/21/2003: songyanf (Tiger) Added -contracts option. First try of the idea of "Wrap by Contract": build up realiable cross-language module by wrapping with SWIG. Implemented basic assertion (preassertion & postassertion & invariant) for simple C/C++ functions. Current format of contracts are: %contract class_name :: func_name (paras...) { require: boolean exprs; exprs; ensure: boolean expr; exprs; invariant: boolean expr; exprs; } *** NEW FEATURE *** 05/19/2003: cheetah (William Fulton) Build tweaks. There were a few preprocessor definitions which were specified in the Makefile for passing on the commandline when compiling. These are now all defined in swigconfig.h. Autoconf doesn't normally allow installation directories to be defined in this config header file, but an autoconf archive macro enables this. This macro along with future autoconf macros are going to be put in the Tools/config directory. 'swig -version' now reports the target build platform. 05/11/2003: cheetah (William Fulton) [C# and Java] Fix to the following typemaps: javabase, javainterfaces, javaimports, javaclassmodifiers, javaptrconstructormodifiers, javafinalize, javagetcptr & javacode. These are the typemaps for modifying/generating proxy classes. Previously the typemaps would use the proxy class name and not the C++ type, which was inconsistent with all other typemaps. In most circumstances the proxy class name and the C++ class name/type is the same except for classes in namespace, templated classes etc. so this shouldn't affect most cases. *** POTENTIAL INCOMPATIBILITY FOR JAVA and C# MODULES *** 05/09/2003: cheetah (William Fulton) Visual C++ Project files have been added so that the runtime libraries can be built on Windows (for Tcl, Perl, Python and Ruby). 05/01/2003: beazley Fixed problem with return by value, const, and private constructors. For example: class B { private: B(); public: B(const B&); }; class A { ... const B returnB() const; ... }; Problem and patch suggestion reported by Bill Hoffman. 04/29/2003: cheetah (William Fulton) Build changes: - Single autoconf invocation - autoconf in the Tools directory has gone. - Libtool bootstrapped when running autogen.sh. This requires anyone using the cvs version of SWIG to have libtool installed on their machine. Suggest version 1.4.2 or higher, preferably the latest - 1.5. - Automake is now used to build the runtime libraries in conjunction with libtool. - Runtime libraries are now successfully built as DLLs on Cygwin. - Skipping languages is no longer just determined in the top level makefile but in configure.in. This info is used for building the runtime libraries and for running the examples and test-suite. - These changes have fixed multiple build directory builds, that is building from directories other than the top level directory. Installation from multiple build directories also working. An initial configure in the top level directory is no longer needed as described in 04/02/2003 entry. A 'make distclean' will be needed before building in a directory other than the top level directory if the autotools have been run from this top level directory at some point, but autoconf will tell you this. Note that 'make check' only works from the top level directory at the moment. 04/28/2003: beazley Fixed [ 723471 ] Wrapper_print() fails with preprocessor directives. 04/28/2003: beazley Minor refinement of const static member variable handling described in CHANGES 08/11/2002. Previously, SWIG merely checked to see if there was an initializer in the declaration. Now, SWIG additionally checks to make sure the static member is const. 04/25/2003: ljohnson (Lyle Johnson) [Ruby] Added a kind of limited support for multiple inheritance, activated using the -minherit command-line option. I've also updated the "C++ Inheritance" section of the Ruby documentation to discuss how this works, and its limitations. Also also modified the minherit.i test case to run against this. 04/25/2003: ljohnson (Lyle Johnson) [Ruby] Added the -globalmodule command-line option for the Ruby module, for wrapping stuff into the global module (Kernel) instead of a nested module. Updated documentation accordingly. 04/23/2003: mrose (Mark Rose) Fixed symname error in director calls to Python methods that extend C++ operators. Stopped director destructor wrappers from calling __set_up, which was leaving the director flag in an inconsistent state. 04/23/2003: beazley Fixed problem with namespace resolution and nested namespaces. Reported by Alfred Lorber (and Marcelo Matus). 04/16/2003: cheetah (William Fulton) Patch for Java examples and test-suite to run on Mac OS X. 04/15/2003: ljohnson (Lyle Johnson) [Ruby] Incorporated Nobu Nakada's patches for supporting the Ruby 1.8 allocation framework. 04/15/2003: ljohnson (Lyle Johnson) [Ruby] Replaced all uses of the deprecated STR2CSTR() macro with the safer StringValuePtr() macro. For more information, see ruby-talk:67059 and follow-ups to that post. 04/11/2003: beazley Fixed problem with preprocessor macro expansion. For example: #define min(x,y) ((x) < (y)) ? (x) : (y) int f(int min); Reported by Sebastien Recio. 04/10/2003: cheetah (William Fulton) [Java] Added a runtime check to typemaps in arrays_java.i library to check that the Java array passed in is the same size as the C array and throw an exception if not. Also fix to use delete instead of free for arrays created using new. 04/07/2003: cheetah (William Fulton) Remove GCC3 warning when compiling the examples and test-suite: cc1plus: warning: changing search order for system directory "/usr/include" cc1plus: warning: as it has already been specified as a non-system directory See SF patch #715531 submitted by Gerald Williams 04/03/2003: cheetah (William Fulton) [C#] Improved wrapping of enums and constants. These were previously wrapped as C# variables rather than constants. Either these are wrapped as readonly (runtime) constants or compile time constants, depending on the %javaconst directive (The directive is likely to change name soon). For example wrapping: %javaconst(0); #define ABC 22 %javaconst(1) XYZ; #define XYZ 33 is now: public static readonly int ABC = examplePINVOKE.get_ABC(); public const int XYZ = 33; 04/03/2003: cheetah (William Fulton) [Java] Global constants and enums are put in their own interface called xxxConstants, where xxx is the module name. This is an improvement as it is possible to derive (implement) a Java class from the xxxConstants interface to improve the syntax; namely when wrapping: enum {ONE=1, TWO, THREE}; accessing these from a Java class implementing xxxConstants is neater: int number = ONE; than the previous: int number = xxx.ONE; Patch submitted by Dave Dribin. 04/02/2003: cheetah (William Fulton) Build improvements for multiple builds. This allows one to build the SWIG executable and runtime libraries for different platforms/compilers etc by running configure in different directories. This isn't 100% just yet and won't be until libtool is better configured... a 'configure' and 'make distclean' needs to be run in the root directory before it all works. For example: $ ./configure $ make distclean $ mkdir config1; cd config1; ../configure CC=gcc CXX=g++; make; cd .. $ mkdir config2; cd config2; ../configure CC=cc CXX=c++; make; cd .. To be improved. A 'make check' does not work yet either. 04/01/2003: beazley Fixed template partial specialization argument expansion bug. This showed up when trying to use std_vector.i with vectors of pointers. 03/31/2003: cheetah (William Fulton) Fix for parallel make builds of SWIG, for example make -j 4 Build failure reported by Bill Clarke. 03/28/2003: beazley Released 1.3.19. Version 1.3.19 (March 28, 2003) =============================== 03/28/2003: beazley Variety of minor bug fixes to the 1.3.18 release including: - Segmentation fault with %extend directive. - Typemap variable substitution bug. - Expression evaluation bug. - Large memory leak with template expansion. Version 1.3.18 (March 23, 2003) =============================== 03/21/2003: beazley Fixed two problems with the %extend directive, overloading, and template expansion. See the 'template_extend_overload' and 'template_extend_overload_2' tests in Examples/test-suite for details. 03/20/2003: cheetah (William Fulton) [C#] Added some typemaps as suggested by Andreas Schoerk for handling parameters that are passed as pointers or by reference. These have been put in typemaps.i. 03/20/2003: beazley Fixed a C++ scoping bug related to code like this: class Foo { public: int Foo::bar(); }; Previously, SWIG just tossed out the Foo::bar() declaration. Now, the declaration is wrapped provided that the prefix is exactly the same as the current scope (including any enclosing namespaces). Reported by Bruce Lowery. 03/20/2003: beazley Incorporated [ 696516 ] Enabling exception processing for data member access. In some compilers, attribute access can generate exceptions. However, SWIG ordinarily assumes that no exceptions will be raised. To disable this, use the %feature("allowexcept"). For example: %feature("allowexcept") Foo::x; ... class Foo { public: int x; /* Exception handling enabled */ ... }; Patch contributed by Yakov Markovitch. 03/20/2003: beazley Incorporated Patch. [ 701860 ] Improve Performance (python proxies). Gives a performance boost to proxy class code and the management of the .this and .thisown attributes. Contributed by Mike Romberg. 03/19/2003: cheetah (William Fulton) [C# and Java] Added missing vararg support. 03/18/2003: mrose (Mark Rose) Removed code related to tagging individual methods for directors. The concept of having directors for some but not all virtual methods of a class is deeply flawed. The %feature("nodirector") tag is also gone. Directors are off by default. To enable them for a class, issue %feature("director") classname; which will create director methods for every virtual method in the hierarchy of the class. 03/17/2003: beazley Fixed a subtle problem with passing arguments of type function. For example: int foo(int x(int, int)); or typedef int binop_t(int, int); int foo(binop_t x); In old versions, this would produce code that wouldn't compile. Now, SWIG merely adds an extra pointer, making these declarations the same as: int foo(int (*x)(int, int)); typedef int binop_t(int, int); int foo(binop_t *x); Reported by Garth Bushell. 03/17/2003: mrose (Mark Rose) Fixed the return statement for director base class calls that have no return value. 03/15/2003: beazley Fixed a problem with const smart-pointer wrapping. For example: class Foo { public: int x; void bar() const; void spam(); }; class Blah { ... const Foo *operator->(); ... }; In this case, only "x" and "bar" are visible from Blah (since application of spam violates constness). Moreover, access to "x" is read-only. 03/15/2003: mrose (Mark Rose) Cleaned up two signed versus unsigned comparisons in python/std_vector.i. 03/15/2003: cheetah (William Fulton) [C#] Global variables are wrapped using properties instead of get and set methods. Member variable wrapping bug fixes, for example wrapping pointers work now. Typemaps are used for all variable wrapping to generate the property code. 03/13/2003: mrose (Mark Rose) Fixed a bug in the virtual method unrolling for directors. The order of unrolling is now from base to derived, to ensure that the most derived implementation of a director method is found. Director methods for pure virtual methods now throw DIRECTOR_PURE_VIRTUAL_EXCEPTION if _up is set. 03/12/2003: cheetah (William Fulton) [C#] Polymorphism fix: virtual functions now use the appropriate keyword in the C# proxy class, virtual or override. Some 'using System;' statement fixes needed by the Mono compiler. 03/11/2003: beazley Fixed subtle bug in the application of SwigValueWrapper<> to template classes with default constructors. Reported by Bruce Lowery. 03/11/2003: beazley The $descriptor(type) variable is now expanded in code supplied to %extend. This is useful for certain kinds of advanced wrapping (especially container classes). 03/11/2003: luigi Support for std::map. (a) Integration with scripting language (a la std::vector) for Python, Ruby, MzScheme, and Guile; (b) Simple wrapper for other languages 03/10/2003: beazley Fixed problem with escape sequences in string and character constants. SWIG wasn't parsing certain octal codes correctly. 03/07/2003: beazley Fixed a variety of subtle preprocessor problems reported by Sebastien Recio. (a) Empty preprocessor values no longer generate "bad constant value" errors. For example: #define FOO #define FOO BAR (b) Macro names can now span multiple lines (technically valid, although questionable practice). For example: #define A_LONG_MACRO_\ NAME 42 (c) Whitespace is no longer required before certain macro values. For example: #define FOO"Hello" #define BAR\ "Hello" 03/07/2003: ljohnson (Lyle Johnson) [Ruby] Added missing long long and unsigned long long typemaps in the Lib/ruby/typemaps.i library file. 03/07/2003: mrose (Mark Rose) Added Examples/python/callback to demostrate how directors can be used to implement callbacks in Python Added Examples/python/extend to demonstrate virtual method calls from C++ to Python (really the same as the callback example, just a different context). Added four tests for very basic director functionality. These have runtime tests under python. The Python module now emits #define SWIG_DIRECTORS near the top of the output file if directors are enabled. This is useful for disabling parts of tests in target languages that don't support directors. 03/06/2003: mrose (Mark Rose) Added a section to Doc/Manual/Python.html on cross language polymorphism (directors). 03/06/2003: mrose (Mark Rose) The short-lived "-fdirectors" command line option has been removed. To enable directors, instead use the extended %module directive as follows: %module(directors="1") modulename 03/06/2003: cheetah (William Fulton) The long long typemaps have been rewritten so that they can be more easily used with non ISO compilers, like Visual C++. For example if you are wrapping the Windows 64 bit type __int64 the long long typemaps can be used with %apply: %apply long long { __int64 }; __int64 value1(__int64 x); __int64 will now appear in the generated code instead of long long. 03/06/2003: beazley *** DEVELOPER CHANGE *** Swig module mutation has been changed slightly. When a language class method wants to save node attributes, it now uses one of the following functions: Swig_require() Swig_save() The first argument to these functions is a namespace in which saved attributes are placed. For example,this code Node *n; Swig_save("cDeclaration",n,"type","parms","name",NIL); saves the attributes as "cDeclaration:type", "cDeclaration:parms", and so forth. If necessary, a language module can refer to old values by using this special namespace qualifier. In addition to this, a special attribute "view" contains the name of the last namespace used to save attributes. In the above example, "view" would have the value "cDeclaration". The value of "cDeclaration:view" would have the previous view and so forth. Swig_restore(n) restores a node to the state before the last Swig_require() or Swig_save() call. Note: This change makes it easier for language modules to refer to old values of attributes. 03/06/2003: mrose (Mark Rose) Merged the cross-language polymorphism patch. When enabled, C++ "proxy" classes (called directors) are generated for each specified C++ class. Directors pass method calls from C++ to Python, similar to the way the usual proxy (shadow) classes pass method calls from Python to C++. Together, these two types of proxies allow C++ classes that are extended in Python to behave just like ordinary C++ classes and be used in C++ like native objects. This feature is still very experimental and is disabled by default. To enable director support, specify '-fdirectors' on the SWIG command line or in the SWIG_FEATURES environment variable. In the interface file, add %feature("director") to generate directors for all classes that have virtual methods. See http://stm.lbl.gov/~tm2/swig/ProxyDoc.html for more details. 03/03/2003: beazley Fixed a small glitch in typemap local variable replacement. If you had a typemap like this: %typemap(in) type ($1_type temp) { ... temp = ...; ... } and no occurrence of "$1_type" appeared in the body, then the local variable type wouldn't be substituted. 03/03/2003: cheetah (William Fulton) [C#] New version of the CSharp module which is typemap based. It also uses ECMA C# and no longer uses Microsoft Visual C++.NET glue. This means that it will work on non-Windows platforms. Contributed by Neil Cawse. 02/27/2003: beazley Fixed [ 653548 ] error parsing casting operator definition. SWIG now ignores casting operators declared outside of a class. For example: inline A::operator char *() { ... } Bug reported by Martin Casado. 02/27/2003: beazley Added support for anonymous bit-fields. For example: struct Foo { int x : 4; int : 4; int y : 8; }; Anonymous bit-fields are ignored by SWIG. Problem reported by Franz Höpfinger. 02/26/2003: cheetah (William Fulton) [Java] Better typemaps in the Examples/java/typemap example and also fixes subtle bug when using the StringBuffer typemaps more than once. 02/26/2003: beazley Fixed [ 642112 ] Constants char bug. 02/26/2003: beazley Fixed [ 675337 ] Partial template specialization not entirely working. There was a subtle problem related to the naming and ordering of template partial specialization arguments. Matching worked okay, the resulting templates weren't expanded correctly. 02/25/2003: beazley Fixed problem with parsing (and generating code) for references to arrays. For example: int foo(int (&x)[10]); 02/25/2003: beazley Fixed [ 635347 ] Compilation warning from libpy.c. Reported by Daniel L. Rall. 02/25/2003: beazley Fixed a subtle problem with virtual method implementation checking and typedef. typedef int *intptr; struct A { virtual int *foo() = 0; }; struct B : public A { virtual intptr foo() { }; }; SWIG was treating these declarations as different even though they are the same (via typedef). 02/25/2003: ljohnson (Lyle Johnson) [Ruby] Added range checking for the NUM2USHRT macro, per [ 675353 ]. 02/24/2003: beazley Fixed a subtle problem with the code that determined if a class is abstract and can be instantiated. If you had classes like this: struct A { virtual int foo(int) = 0; }; struct B : virtual A { virtual int foo(int); }; struct C : virtual A { }; /* Note order of base classes */ struct D : B, C { }; /* Ok */ struct E : C, B { }; /* Broken */ then SWIG determined that it could instantiate D(), but not E(). This inconsistency arose from the depth-first search of the inheritance hierarchy to locate the implementations of virtual methods. This problem should now be fixed---SWIG will attempt to locate any valid implementation of a virtual method by traversing over the entire hierarchy. 02/22/2003: cheetah (William Fulton) [Java] Fix for using enum typemaps. The Java final static variable type can be set using the jstype typemap, enabling enums to be mapped to something other than int. Bug reported by Heiner Petith. 02/21/2003: songyanf (Tiger) Added CSharp (C#) module prototype i.e. csharp.cxx & csharp.h at Source/Modules/. They are for test usage only now and need improvement. The interface also need to be modified. *** NEW FEATURE *** 02/20/2003: songyanf (Tiger) Fixed problem with typedef with -fvirtual. Similar as beazley's modification today. 02/20/2003: beazley Added support for gcc-style variadic preprocessor macros. Patch [ 623258 ] GCC-style vararg macro support. Contributed by Joe Mason. 02/20/2003: beazley Fixed [ 605162 ] Typemap local variables. Reported by Lyle Johnson. 02/20/2003: beazley Fixed problem with abstract classes and typedef. For example: class Foo { public: virtual void foo(int x) = 0; }; typedef int Integer; class Bar : public Foo { public: virtual void foo(Integer x); }; SWIG was getting confused about the latter method---making Bar abstract. Reported by Marcelo Matus. 02/19/2003: cheetah (William Fulton) [Java] %javaconst(flag) can also be used on enums as well as constants. This feature enables true Java compiler constants so that they can be used in Java switch statements. Thanks to Heiner Petith for patches. 02/19/2003: songyanf (Tiger) Modified -fcompact feature to deal with PP lines 02/18/2003: beazley Fixed [ 689040 ] Missing return value in std_vector.i. Reported by Robert H. de Vries. 02/18/2003: beazley Fixed a few evil scoping problems with templates, namespaces, and the %extend directive. Problem reported by Luigi Ballabio. 02/18/2003: cheetah (William Fulton) [Ruby] Improved support for Visual C++ and other native Windows compilers. It is no longer necessary to specify "/EXPORT:Init_", where is the swig module name when linking using these native Windows compilers. 02/15/2003: songyanf (Tiger) Added -fvirtual option. Reduce the lines and size of the wrapper file by omitting redifined virtual function in children classes. Modified -compact option to -fcompact option Added -small option. -small = -fvirtual -fcompact And it can be extended by future feature options, which are used to reduce wrapper file szie. Added SWIG_FEATURES environment variable check. To dynamically set the feature options such as -fcompact & -fvirtual *** NEW FEATURE *** 02/13/2003: lenz Updated Doc/Manual/Perl5.html to talk about C++ compile problems configure.in now checks for PERL5_CCFLAGS Runtime/Makefile.in and Example/Makefile.in now use PERL5_CCFLAGS Added Lib/perl5/noembed.h which contains all the known macro conflicts 02/12/2003: beazley Fixed [ 685410 ] C++ Explicit template instantiation causes SWIG to exit. Fixes a syntax error with declarations similar to this: template class std::vector; SWIG now ignores the instantiation and generates a warning message. We might do more later. Reported by Thomas Williamson. 02/11/2003: cheetah (William Fulton) Rewrote bool typemaps to remove performance warning for compiling generated code under Visual C++. 02/11/2003: cheetah (William Fulton) Fix for wrapping reference variables (const non-primitive and all non-const types) for example: int& i; Class& c; const Class& c; 02/11/2003: beazley Fixed more very subtle preprocessor corner cases related to recursive macro expansion. For example: #define cat(x,y) x ## y cat(cat(1,2),3) // Produces: cat(1,2)3 #define xcat(x,y) cat(x,y) xcat(xcat(1,2),3) // Produces 123 See K&R, 2nd Ed. p. 231. 02/10/2003: cheetah (William Fulton) Fixed [ 683882 ] - patch submitted by F. Postma for SWIG to compile on HP-UX. 02/10/2003: beazley Fixed subtle preprocessor argument expansion bug. Reported by Marcelo Matus. 02/10/2003: songyanf Added -compact option. Reduce the lines and size of the wrapper file by omitting comments and combining short lines. *** NEW FEATURE *** 02/07/2003: beazley Fixed [ 651355 ] Syntax error with cstring.i Reported by Omri Barel. 02/07/2003: beazley Fixed [ 663632 ] incompatibility with standard cpp. This is a refinement that fixes this problem: // Some macro with an argument #define FOO(x) x int FOO; /* Not a macro---no arguments */ 02/05/2003: beazley Fixed [ 675491 ] parse error with global namespace qualification. Submitted by Jeremy Yallop. 02/04/2003: beazley Fixed bug in varargs processing introduced by the numinputs typemap parameter. 01/08/2003: ttn [xml] Fix string-replacement ordering buglet. Thanks to Gary Herron. 12/23/2002: cheetah (William Fulton) Further build changes: - The SWIG executable is now built using a single Makefile. - This makefile is generated by Automake (Source/Makefile.am). - Dependency tracking and tags support are in this makefile. - Automake 1.7.2 and Autoconf 2.54 minimum versions are needed to build SWIG from CVS. - Running ./autogen.sh now installs Autoconf/Automake support files into Tools/config and these files are no longer stored in CVS. - Bug fixes in 'make install' for systems using .exe executable extension and ./configure --with-release-suffix=whatever 12/16/2002: cheetah (William Fulton) More build changes: - Autoconf's AC_CANONICAL_HOST replaces proprietary approach for detecting build host. - Autoconf support files moved to Tools/config. 12/16/2002: cheetah (William Fulton) Modifications to run on MacOS, submitted by Bernard Desgraupes. Mainly ensuring generated files are output in the appropriate directory for some modules. 12/11/2002: cheetah (William Fulton) Various build modifications and bug fixes: - Simplification of version string. Use autoconf's PACKAGE_VERSION instead. - Build time removed from SWIG version. - Using standard autoconf config header generation. - Updated old autoconf macros as reported by autoupdate. - Removed $prefix in autoconf from search paths as autoconf won't expand them. - Subtle bug fix where 'make prefix=/somewhere; make clean; make prefix=/somwhere/else' produced an executable using the incorrect library directories. - Added -ldflags commandline option for MzScheme, Ocaml, Pike and PHP. - Fixed reporting of compiler used when using -version commandline option. - SWIG web address added to -version commandline option. 12/11/2002: beazley Minor fix to Tcl dynamic cast typemaps. Reported by Kristopher Blom. 12/10/2002: beazley Fixed subtle template argument replace bug. Reported by Chris Flatley. 12/10/2002: beazley Reverted CHANGES 09/03/2002, preprocessor argument evaluation. Arguments are not evaluated during collection, K&R, p. 230. 12/06/2002: beazley Fixed [ 649022 ] Compilation problems with KAI/KCC 12/02/2002: beazley SWIG 'rel-1-3' CVS branch merged back into the main branch. Version 1.3.17 (November 22, 2002) ================================== 11/19/2002: beazley Fixed [ 613922 ] preprocessor errors with HAVE_LONG_LONG. 11/19/2002: beazley Fixed [ 615480 ] mzscheme SWIG_MustGetPtr_. 11/19/2002: beazley Fixed [ 635119 ] SWIG_croak causes compiler warning. 11/16/2002: cheetah (William Fulton) [Java] Added typemaps for pointers to class members. 11/15/2002: cheetah (William Fulton) [Java] Bug fix: Overloaded C++ functions which cannot be overloaded in Java once again issue a warning. 11/14/2002: cheetah (William Fulton) [Java] Handling of NULL pointers is improved. A java null object will now be translated to and from a NULL C/C++ pointer by default. Previously when wrapping: class SomeClass {...}; void foo(SomeClass *s); and it was called from Java with null: modulename.foo(null) a Java NullPointerException was thrown. Extra typemaps had to be written in order to obtain a NULL pointer to pass to functions like this one. Now the default wrapping will detect 'null' and translate it into a NULL pointer. Also if a function returns a NULL pointer, eg: SomeClass *bar() { return NULL; } Then this used to be wrapped with a SomeClass proxy class holding a NULL pointer. Now null is returned instead. These changes are subtle but useful. The original behaviour can be obtained by using the original typemaps: %typemap(javaout) SWIGTYPE { return new $&javaclassname($jnicall, true); } %typemap(javaout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { return new $javaclassname($jnicall, $owner); } %typemap(javagetcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ protected static long getCPtr($javaclassname obj) { return obj.swigCPtr; } %} *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 11/12/2002: beazley Fixed problem with abstract methods and signatures. For example: class abstract_foo { public: virtual int meth(int meth_param) = 0; }; class abstract_bar : public abstract_foo { public: int meth(int meth_param_1, int meth_param_2) { return 0; } }; In this case, abstract_bar is still abstract. Fixes [ 628438 ] Derived abstract class not abstract. Reported and patched by Scott Michel. 11/11/2002: beazley Fixed a matching problem with typemaps and array dimensions. For example, if you had this: typedef char blah[20]; and a typemap: %typemap() char [ANY] { ... $1_dim0 ... } then $1_dim* variables weren't be expanded properly. It should work now. Problem reported by Pankaj Kumar Goel. 11/07/2002: mkoeppe Added an experimental new module that dumps SWIG's parse tree as (Common) Lisp s-expressions. The module is invoked with SWIG's -sexp command-line switch. The output can be read into Common Lisp. There is (prototype) example Lisp code that generates Foreign Function Interface definitions for use with Kevin Rosenberg's UFFI. *** EXPERIMENTAL NEW FEATURE *** 11/07/2002: mkoeppe Removed duplicate declaration of "cpp_template_decl" in parser.y; bison 1.75 complained. 11/06/2002: cheetah (William Fulton) [Java] Default primitive array handling has changed like arrays of classes. C primitive arrays are no longer wrapped by a Java array but with a pointer (type wrapper class). Again the changes have been made for efficiency reasons. The original typemaps have been moved into arrays_java.i, so the original behaviour can be obtained merely including this file: %include "arrays_java.i" The array support functions are no longer generated by default. They are only generated when including this file, thus this often unused code is only generated when specifically requiring this type of array support. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 11/05/2002: ljohnson (Lyle Johnson) [Ruby] Added support for nested module declarations (as was previously added for the Perl module). So a %module directive of the form: %module "Outer::Inner::Foo" will nest everything as (in Ruby code): module Outer module Inner module Foo # stuff goes here end end end 11/05/2002: mkoeppe [MzScheme] Add an argument (-declaremodule) that generates code to correctly declare a primitive module extension. Patch submitted by Bruce Butterfield. 11/02/2002: cheetah (William Fulton) [Java] Added patch submitted by Michael Cahill to remove unused parameter warnings for the jenv and cls parameters. This patch also also allows one to use "void" in the jni typemap for any type without code being generated attempting to return a value. 10/29/2002: cheetah (William Fulton) [Java] Array handling is different. Arrays of classes are no longer wrapped with proxy arrays, eg wrapping class X {...}; X foo[10]; used to be wrapped with these Java getters and setters: public static void setFoo(X[] value) {...} public static X[] getFoo() {...} This approach is very inefficient as the entire array is copied numerous times on each invocation of the getter or setter. These arrays are now wrapped with a pointer so it is only possible to access the first array element using a proxy class: public static void setFoo(X value) {...} public static X getFoo() {...} Arrays of enums have also been similarly changed. This behaviour is now like the other SWIG language's implementation and the array library should be used to access the other elements. The original behaviour can be achieved using the macros and typemaps in arrays_java.i, for example: %include "arrays_java.i" JAVA_ARRAYSOFCLASSES(X) class X {...}; X foo[10]; *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 10/29/2002: cheetah (William Fulton) [Java] Two new typemaps javain and javaout for generating the proxy class and type wrapper class method calls to the JNI class. The new typemaps are really used for transforming the jstype (used in proxy class and type wrapper classes) to the jtype (used in the JNI class) and visa versa. A javain typemap is required whenever an in typemap is written and similarly javaout for an out typemap. An example is probably best to show them working: %typemap(javain) Class "Class.getCPtr($javainput)" %typemap(javain) unsigned short "$javainput" %typemap(javaout) Class * { return new Class($jnicall, $owner); } %inline %{ class Class {}; Class * bar(Class cls, unsigned short ush) { return new Class(); }; %} The generated proxy code is then: public static Class bar(Class cls, int ush) { return new Class(exampleJNI.bar(Class.getCPtr(cls), ush), false); } Some new special variables have been introduced in order to use these typemaps. Here $javainput has been replaced by 'cls' and 'ush'. $jnicall has been replaced by the native method call, 'exampleJNI.bar(...)' and $owner has been replaced by 'false'. $javainput is analogous to the $input special variable. It is replaced by the parameter name. $jnicall is analogous to $action in %exception. It is replaced by the call to the native method in the JNI class. $owner is replaced by either true if %newobject has been used otherwise false. The java.swg file contains default javain and javout typemaps which will produce the same code as previously. This change is only of concern to those who have written their own typemaps as you will then most likely have to write your own javain and javaout typemaps. The javaout typemap also makes it possible to use a Java downcast to be used on abstract proxy base classes. See the Java documentation on dynamic_cast. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 10/24/2002: ttn [Methodology] Upgaded to libtool 1.4.3, presumably w/ better support for newish platforms (like MacOS X). 10/21/2002: ttn Fixed Runtime/Makefile.in bug -- thanks to Richard Calmbach. 10/18/2002: ttn Fixed typo in doh.h -- thanks to Max Horn. Version 1.3.16 (October 14, 2002) ================================= 10/13/2002: beazley Fixed bug with %extend directive and %feature reported by William Fulton. 10/13/2002: beazley Added OpenVMS build directory (vms). Contributed by Jean-François Pieronne. 10/09/2002: cheetah (William Fulton) [Java] Added throws clause to the native functions in the JNI class. The throws clause is the same as the one generated for proxy functions and module class functions. 09/27/2002: beazley Fixed some problems with the %import directive and classes that were defined but not wrapped. Problem reported by Leslie Brooks, Gerry Woods, and others. 09/23/2002: cheetah (William Fulton) [Java] Some error checking added: 1) OutOfMemoryException check in the char * typemaps. 2) As SWIG treats pointers, references and passing by value all the same, it is possible to pass a NULL pointer to a function that expects an object passed by value or by reference. A NullPointerException is now thrown under this scenario. 09/20/2002: ttn [Methodology] Reworked "make clean" and "make install" to be more table driven. [Docs] Explain how to extend "make install" w/ extra-install.list. 09/15/2002: beazley Deprecation of the "ignore" typemap. The "ignore" typemap has been deprecated in favor of a generalization of the "in" typemap. To ignore an argument, use something like this instead: %typemap(in,numinputs=0) int *output (int temp) { $1 = &temp; } This change fixes a number of subtle bugs related to the interaction of the "in" and "ignore" typemaps (which were supposed to be mutually exclusive). The use of the numinputs argument is reserved for future expansion. Currently, values >1 will generate an error. However, future releases of SWIG may utilize that to support multi-input typemaps. %typemap(ignore) still works, but generates a warning message and is translated to %typemap(in,numinputs=0). *** POTENTIAL INCOMPATIBILITY *** *** NEW FEATURE *** 09/15/2002: beazley Fixed segmentation fault for unnamed structures. For example: typedef struct { } *blah; Reported by Roger Gibson. Note: we might be able to generate wrappers in special cases. 09/13/2002: beazley Minor modification to generated wrapper functions. Pointer arguments are now always set to an initial value of 0. Simplifies typemap writing and cleanup code (since you can rely on zero-value initialization). This also greatly reduces the need to ever write an "arginit" typemap. 09/12/2002: beazley Minor enhancement to smart-pointer support. If operator->() is part of an ignored base class like this, %ignore Bar; class Foo { public: int blah(); }; class Bar { /* Ignored */ public: ... Foo *operator->(); ... }; class Spam : public Bar { }; then methods from Foo are still available. For example, >>> s = Spam() >>> s.blah() 0 >>> The only catch is that the operator->() itself is not available (since it wasn't wrapped). Therefore, there won't be any __deref__() operation unless it is explicitly added to Spam (either using %extend or just placing operator->() in the definition of Spam). 09/11/2002: ttn [Methodology] Reworked "make check" to be more table driven. [Docs] Docuemented methodology in Manual/Extending.html. 09/11/2002: ttn [Docs] Prefixed Manual/*.html with "" to pander dotingly to (over-)sensitive editors. 09/10/2002: ttn [Guile] Converted Examples/guile/simple "make check" behavior to actually check execution results. Reduced iteration counts so that the test doesn't take too long. 09/10/2002: beazley SWIG-1.3.15 released. Version 1.3.15 (September 9, 2002) ================================== 09/09/2002: beazley Fixed nasty runtime type checking bug with subtypes and inheritance and templates. 09/09/2002: cheetah (William Fulton) [Java] Java exception classes for a method's throws clause can be generated by specifying them in a comma separated list in the throws attribute in any one of the following typemaps: in, out, check, freearg, argout and throws. A classic example would be to convert C++ exceptions into a standard Java exception: %typemap(throws, throws="java.io.IOException") file_exception { jclass excep = jenv->FindClass("java/io/IOException"); if (excep) jenv->ThrowNew(excep, $1.what()); return $null; // or use SWIG_fail } class file_exception {...}; void open(const char *filename) throw(file_exception); The Java method will then be declared with a throws clause: public static void open(String filename) throws java.io.IOException {...} 09/08/2002: mkoeppe * [Guile] Improved the documentation system. The arglist no longer gets cluttered with type specification, making it more readable. (Also the ILISP function C-u M-x `arglist-lisp' RET works better this way.) The types of arguments are explained in an extra sentence after the arglist. There are now two documentation-related typemap arguments: %typemap(in, doc="$NAME is a vector of integers", arglist="$name") int *VECTOR { ... } The "arglist" texts of all arguments of a function make up its arglist in the documentation. The "doc" texts of all arguments are collected to make a sentence that describes the types of the arguments. Reasonable defaults are provided. As usual, $name is substituted by the name of the argument. The new typemap variable $NAME is like $name, but marked-up as a variable. This means that it is upper-cased; in TeXinfo mode ("-procdocformat texinfo") it comes out as @var{name}. The directives %values_as_list, %values_as_vector, %multiple_values now also have an effect on the documentation. (This is achieved via the new pragmas return_nothing_doc, return_one_doc, return_multi_doc.) Documentation has also improved for variables that are wrapped as procedures-with-setters (command-line switch "-emit-setters"). * [Guile] Emit constants as _immutable_ variables. (This was broken recently.) 09/07/2002: mkoeppe [Guile] Updated the typemaps in list-vector.i. 09/07/2002: mkoeppe Short-circuit the typechecks for overloaded functions. (The changes in code generation are visible in the new testcase "overload_complicated".) 09/06/2002: cheetah (William Fulton) [Java] Solution for [ 596413 ] New typemap so that the Java proxy classes and type wrapper classes wrapper constructor modifier can be tailored by users. The default value is protected. Normally SWIG generates a constructor like this which can only be accessed within one package: protected Bar(long cPtr, boolean cMemoryOwn) { ... } If you are using SWIG across multiple packages or want to use this constructor anyway, it can now be accessed outside the package. To modify use for example: %typemap(javaptrconstructormodifiers) SWIGTYPE "public" to change to public for all proxy classes and similarly for all type wrapper classes: %typemap(javaptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "public" 09/06/2002: cheetah (William Fulton) [Java] Added throws typemaps for the Java module. C++ exceptions get converted into java.lang.RuntimeException Java exceptions. Warning: This may change from java.lang.Runtime exception in the future. 09/05/2002: cheetah (William Fulton) [Java] Fix for variables declared as references. 09/05/2002: beazley Fixed [ 605162 ] Typemap local variables. Reported by Lyle Johnson. 09/05/2002: ljohnson (Lyle Johnson) [Ruby] More updates to the Ruby module documentation, including a new typemap example that demonstrates how to collect key-value pairs from an argument list into a Hash. 09/05/2002: beazley Fixed bug with template expansion and constructors. template class Foo { public: Foo() { } }; The extra in the constructor was carried through in the name--causing runtime problems in generated modules. Reported by Jordi Arnabat Benedicto. 09/05/2002: mkoeppe [Guile] Support overloading. 09/04/2002: ljohnson (Lyle Johnson) [Ruby] Updated typemaps for long long and unsigned long long types to use Ruby 1.7 support for these types when available. 09/04/2002: ljohnson (Lyle Johnson) [Ruby] Added output typemaps for const reference to primitive types. 09/04/2002: mkoeppe [Guile] Fix pass-by-value typemaps. Reported by Arno Peters via Debian bugtracking (#156902), patch by Torsten Landschoff . 09/03/2002: samjam (Sam Liddicott) Better reference support. Functions that want a void** can take a NULL by reference and the void* will be made for you and then passed-by-reference Also all integer-class native types can be passed by reference where an int* or int& etc is needed 09/03/2002: beazley Changed the evaluation order of preprocessor macro arguments. Arguments are now expanded by the preprocessor *before* they are passed to macro expansion. This fixes a subtle expansion bug reported by Anthony Heading. 09/03/2002: beazley Fixed the file include order (again, apparently). See 2/27/99. 09/02/2002: beazley [Perl] Better exception handling support. Since Perl error handling relies on setjmp/longjmp, wrapper functions have been modified slightly to provide an extra block scope: XS(foo) { char _swigmsg[SWIG_MAX_ERRMSG] = ""; const char *_swigerr = _swigmsg; { /* Normal wrapper function here */ ... SWIG_croak("An error occurred\n"); ... XSRETURN(argvi); /* Successful return */ fail: /* cleanup code */ } croak(_swig_err); } The macro SWIG_croak(x) sets the value of _swigerr to x and executes a "goto fail". The whole wrapper function is enclosed block scope to provide proper cleanup of C++ objects. Since croak executes a longjmp(), there is no way to properly reclaim resources if this executes in the same scope as the wrapper function. The _swigmsg[] variable is normally unused, but can be used to store small error messages using sprintf or snprintf. It has a capacity of at least 256 bytes (SWIG_MAX_ERRMSG). 09/02/2002: beazley [Tcl] Added better support for exceptions. Instead of returning TCL_ERROR, use the macro SWIG_fail to return with an error. This ensures that arguments are properly cleaned up. Exception specifiers are now handled by default. 09/02/2002: ljohnson (Lyle Johnson) [Ruby] The type-checking system for the Ruby module has had a flaw in that some types which should be considered equivalent weren't. This bug was best demonstrated by the inherit_missing.i test suite case, which defines a base class "Foo" that is subclassed by "Bar". The "Foo" class isn't actually wrapped (i.e. it's not directly accessible from Ruby) but we'd still like to be able to pass "Bar" instances to functions expecting Foos and have that work; it wasn't. The revised implementation (similar to that used for some other language modules) adds a new instance variable (__swigtype__) to each object that indicates its SWIG type; that is, each "Bar" instance will now have a string instance variable called "__swigtype__" whose value is "_p_Bar". Unless developers were taking advantage of this low-level implementation detail, they shouldn't notice any compatibility problems; nevertheless, I'm marking it as a "potential incompatibility". *** POTENTIAL INCOMPATIBILITY *** 09/01/2002: ljohnson (Lyle Johnson) [Ruby] Fixed SF Bug #603199. 08/08/2002: cheetah (William Fulton) [Java] Added OUTPUT, INPUT and INOUT typemaps in typemaps.i for C++ references. 08/27/2002: mkoeppe [Guile] Fixed error in "lib_std_vector" testcase and compiler warning in "lib_cdata" testcase. 08/27/2002: ljohnson (Lyle Johnson) [Ruby] Added the "%mixin" directive, which allows the user to specify a comma-separated list of module names to mix-in to a class. So, for example, if you'd like to specify that Ruby's Enumerable module should be mixed-in to your class Foo, you'd write: %mixin Foo "Enumerable"; or to specify that the modules Fee, Fie and Fo should be mixed in to Foo: %mixin Foo "Fee,Fie,Fo"; *** NEW FEATURE *** 08/27/2002: ljohnson (Lyle Johnson) [Ruby] Modified the %alias directive so that multiple aliases can be specified for an instance method by using a comma-separated list of aliases. 08/27/2002: ljohnson (Lyle Johnson) [Ruby] Added "throw" typemaps for the Ruby module. 08/26/2002: beazley Two new command line options for printing dependencies. 'swig -M' lists all file dependencies. 'swig -MM' lists dependencies, but excludes files in the SWIG library. Example: % swig -M -python example.i example_wrap.cxx: \ /u0/beazley/Projects/lib/swig1.3/swig.swg \ /u0/beazley/Projects/lib/swig1.3/python/python.swg \ example.i \ example.h % swig -MM -python example.i example_wrap.cxx: \ example.i \ example.h *** NEW FEATURE *** 08/26/2002: beazley Fixed [ 597599 ] union in class: incorrect scope. Reported by Art Yerkes. 08/26/2002: beazley Fixed [ 600132 ] Default argument with namespace. Reported by Shibukawa Yoshiki. 08/24/2002: beazley Automatic C++ exception handling enabled for all language modules. This is pretty simple. If you have a class like this: class Foo { }; class Bar { public: void blah() throw(Foo); } then the generated wrapper code looks like this: wrap_Bar_blah() { ... try { arg1->blah(); } catch (Foo &_e) { /* "throw" typemap code inserted. $1 = _e */ } catch (...) { throw; } } The "throw" typemap can be used to raise an error in the target language. It can do anything. Here is a very simple example: %typemap("throw") Foo { PyErr_SetString(PyExc_RuntimeError, "Foo exception"); return NULL; } To make this work in each language module, simply define a few default "throw" typemaps for SWIGTYPE, SWIGTYPE *, int, const char *, and a few common exception types. That's all there is to it. Automatic exception handling can be disabled using -noexcept or setting the NoExcept global variable to 1. *** NEW FEATURE *** 08/23/2002: beazley [ Python ] Automatic translation of C++ exception specifications into error handling code. For example: class Foo { }; class Bar { public: void blah() throw(Foo); } In this case, Foo is wrapped as a classic-style class (compatible with exception handling). Furthermore, you can write Python code like this: b = Bar() try: b.blah(); except Foo,e: # Note use of exception class here! # Handle Foo error ... The object "e" in the exception handler is just a wrapped Foo object. Access it like a normal object. If an exception is not wrapped as a class, a RuntimeError exception is raised. The argument to this exception is the exception object. For example: class Bar { public: void blah() throw(int); } b = Bar() try: b.blah(); except RuntimeError,e: print e.args[0] # Integer exception value Comments: - If a class is used as an exception, it *must* be wrapped as a Python classic-style class (new classes don't work). - Automatic exception handling is compatible with %exception. - Use -noexcept to turn off this feature. - The newly introduced "throw" typemap is used to raise Python errors (naturally). *** EXPERIMENTAL NEW FEATURE *** 08/23/2002: beazley Information from throw() specifiers is now stored in the parse tree. For example: class Foo { public: int blah() throw(spam,bar); } The stored information is fully corrected for namespaces and works with templates. Uses will follow. 08/22/2002: beazley Exception handling code is no longer applied to member access function. For example, in this code %exception { try { $action } catch(whatever) { ... } } class Foo { public: int x; ... } The exception handling code is not applied to accessor functions for Foo::x. This should reduce the amount of extra code generated. Caveat: Exception handling code *is* used when attributes are accessed through a smart-pointer or a synthesized attributed added with %extend is used. 08/22/2002: beazley Made more patches to hopefully eliminate problems when compiling SWIG as a 64-bit executable. 08/22/2002: beazley Fixed a bug with const reference members, variables, and static members. For example: class Foo { public: static const int &ref; }; SWIG was trying to generate "set" functions which wouldn't compile. 08/21/2002: beazley Made the warning message for "Class X might abstract" off by default. Enable with -Wall. 08/21/2002: beazley Refined handling of const and non-const overloaded methods. If a class defines a method like this: class Foo { public: int bar(int); int bar(int) const; } Then the non-const method is *always* selected in overloading and the const method silently discarded. If running with -Wall, a warning message will be generated. 08/19/2002: beazley Better support for using declarations and inheritance. Consider this: class Foo { public: int blah(int x); }; class Bar { public: double blah(double x); }; class FooBar : public Foo, public Bar { public: char *blah(char *x); using Foo::blah; using Bar::blah; }; Now SWIG wraps FooBar::blah as an overloaded method that uses all accessible versions of blah(). See section 15.2.2 in Stroustrup, 3rd Ed. SWIG also supports access change through using declarations. For example: class Foo { protected: int x; int blah(int x); }; class Bar : public Foo { public: using Foo::x; using Foo::blah; }; Caveat: SWIG does not actually check to see if declarations imported via 'using' are in the inheritance hierarchy. If this occurs, the wrapper code won't compile anyways---not sure it's worth worrying about. 08/18/2002: beazley Modified overloading dispatch to not include nodes with an "error" attribute. A language module can set this if a node couldn't be wrapped and you don't want it included in the dispatch function. 08/18/2002: beazley Enhancement to overloaded function dispatch. The dispatcher is now aware of inheritance relationships. For example: class Foo { }; class Bar : public Foo { }; void spam(Foo *f); void spam(Bar *b); In this case, the dispatcher re-orders the functions so that spam(Bar *b) is checked first---it is more specific than spam(Foo *f). 08/17/2002: beazley Added -Werror command line option. If supplied, warning messages are treated as errors and SWIG will return a non-zero exit code. 08/17/2002: beazley Fixed [ 596135 ] Typedef of reference can't compile. For example: typedef int &IntRef; void foo(IntRef i); SWIG-1.3.14 generated code that wouldn't compile. Version 1.3.14 (August 12, 2002) ================================ 08/11/2002: mmatus Static const members initialized during declaration, and only them, ie: struct A { static const int a = 1 ; // this one static const int b; // not this one }; are emitted like constants (equivalent to enums or explicit %constant). This is because they cannot be added directly to 'cvar' since they lack the needed reference (well, you can force them to have a real reference, but in an ugly way which goes completely again the original purpose of initialize them during declaration, you also have to deal with extra linking matters, and it take a while to figure out what is the problem and how to solve it). Please test it with your preferred target language, and not only the code generation, but really run the example in the test-suite (static-const-member-2.i) because the problem and the solution cannot be "fully" appreciated until you try to load the module and run it. In some target languages (python specially), this can produces a difference in the way that the static constant members 'a' and 'b' are internally wrapped. Hopefully, they still can be accessed in the same way. 08/11/2002: mmatus [python] Now static const members can be accessed in a more natural way, ie, if you have struct A { typedef unsigned int viewflags; static const viewflags forward_field = 0; static const viewflags backward_field; }; now you can do: print A.backward_field and also a = A() print a.forward_field Note that if the static const members don't have an initializer (like backward_field), still you can access them in the same way in the python side, but the implementation is a quite different: backward_field will still appear in the cvar entity, and also, you are responsible to initialize it in some code unit, and link it properly. forward_field, by the other hand, will not appear in the cvar entity but only as a A member, similar to what happen with enum or %constant members. 08/11/2002: mmatus [python] Common code in the __setattr__/__getattr__ now goes to two "free" methods at the beginning of the proxy file, from where each class use it. This change reduces the size of the proxy file, specially if you wrap a lot of small classes in one module (up to 33% in some cases), making it faster to load too. 08/09/2002: beazley [Perl5] If a function that returns char * returns NULL, undef is returned to the Perl interpreter. 08/09/2002: beazley Fix to conversion operators and namespaces. For example: namespace ns { struct Foo { }; struct Bar { operator Foo*(); }; } In the wrapper code, SWIG was using ->operator Foo*() when it should have been using ->operator ns::Foo*(). Note: if using %rename with a conversion operator, you might have to do this: %rename(toFooPtr) ns::operator ns::Foo*(); // ^^^^ note extra qualifier namespace ns { ... 08/09/2002: beazley [Python] Minor enhancement to 'const' variable declarations. Normally const declarations are wrapped as read-only variables accessible only through the cvar attribute (see SWIG.html for a discussion of why). However, in many programs, "const" declarations may just be constants---making the cvar. access awkward. To fix this, "const" declarations are now available both through cvar. and as a simple name. For example: const int FOO = 42; In Python: >>> print example.cvar.FOO 42 >>> print example.FOO 42 Note: There are cases where the value of a "const" variable might change. For example: char *const BAR = "Hello World"; In this case, the pointer itself can not change, but the data being pointed to could be modified. In these situations, cvar.BAR should be accessed to obtained the current value. 08/08/2002: beazley [Python] Fixed generation of the proxy code (.py files) to more closely follow the order of declarations as they appear in the .i file. In the past, all of the class wrappers appeared first, followed by function stubs, inserted Python code, and other details. 08/08/2002: cheetah (William Fulton) [Java] Proxy method _delete() changed to delete(). There shouldn't ever be a wrapped function called delete() as it is a C++ keyword and there is no such thing as a member function in C. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** Backwards compatibility can be achieved by adding the function back in for all proxy classes: %typemap(javacode) SWIGTYPE %{ public void _delete() { delete(); } %} Java backwards compatibility summary ------------------------------------ There are a number of changes that have been made in improving the Java module for ver 1.3.14. If at all possible change your code to take advantages of the improvements. If you were using proxy classes you may not notice any backwards compatibility issues. Here is an example which will help with most backwards compatibility problems where it is not possible to modify the code that uses the generated output: Replace: %module modulename With: %module (jniclassname="modulename") modulename; %typemap(javacode) SWIGTYPE %{ public long getCPtr$javaclassname() { return swigCPtr; } public void _delete() { delete(); } %} %pragma(java) jniclassclassmodifiers="public"; The proxy constructors that took parameters (long cPtr, boolean cMemoryOwn) were public and are now protected. If you were making use of these then you'll have to modify your code and the best solution would be to use the new type wrapper classes. The other main areas are the pragmas and global variable wrapping. Replace the pragmas with one of the new directives or typemaps mentioned below and use %rename on the variables. If you were not using proxy classes, you will have to define a jstype typemap as well as a jtype typemap. 08/08/2002: cheetah (William Fulton) [Java] Fix for wrapping two dimension array variables. 08/07/2002: beazley [Python,Tcl] Object management now has a much better sense of ownership. Ownership bits is changed whenever an object is stored in a global variable or structure member. For example: struct Foo { int val; Foo *next; }; Now in Python >>> f = Foo() >>> f.thisown 1 >>> g = Foo() >>> g.next = f # Assign a pointer >>> f.thisown # Notice ownership change 0 >>> This scheme is mostly a conservative heuristic designed to provide segmentation faults. It could cause a memory leak if ownership is changed unnecessarily. In this case, you can either write a typemap (that doesn't change ownership), or manually set the thisown attribute back to 1. 08/07/2002: beazley [Tcl] Major usability improvements to the object interface. Suppose you had code like this: struct Foo { int x; int spam(); }; void blah(Foo *f); In past versions of SWIG, you could create objects and use them like this: % Foo f % f configure -x 3 % f spam 37 The only problem is that if you tried to call blah(), it didn't work: % blah f Type Error. Expected _p_Foo % Instead, you had to do this: % blah [f cget -this] SWIG now automatically extracts the -this pointer, avoiding this problem. This means that saying "blah f" is perfectly legal and everything will still work normally. Caveat: Since pointer strings start with a leading underscore (_), don't use this in object names. For example: % Foo _f % blah _f # Potential crash Objects now have a -thisown attribute that shows the ownership. This builds upon the CHANGES 11/24/2001 entry. 08/07/2002: samjam, Sam Liddicott Properly implemented pointer system using php resources. Still need to work out whether or not to let script-users call destructors directly 08/06/2002: beazley Upgraded mzscheme module to support version 201 and added overloading support. 08/05/2002: beazley Added parsing support for extra grouping (in very limited cases). For example: typedef int (FuncPtr)(int, double); *** EXPERIMENTAL *** 08/03/2002: ljohnson (Lyle Johnson) [Ruby] Updates to typemaps.i as those done previously for Perl, Python and Tcl modules. Now supports reference types with INPUT, OUTPUT and INOUT typemaps. 08/02/2002: beazley New library file cstring.i added. Provides macros for manipulating char * data. 08/02/2002: beazley Deprecated the %new directive. Use %newobject instead. For example: %newobject foo; ... char *foo(); %newobject follows the same rules as %rename, %ignore, %feature, etc. *** POTENTIAL INCOMPATIBILITY *** 08/01/2002: cheetah (William Fulton) [Java] New attribute 'jniclassname' for the module directive allows a way of changing the JNI class name from the default which uses the modulename with JNI appended after it. %module (jniclassname="name") modulename If 'name' is the same as 'modulename' then the module class name gets changed from 'modulename' to modulenameModule. 08/01/2002: beazley Fixed problem with file include order. Language specific directories should take precedence over generic directories. For example: "swig_lib/python/foo.i" should be loaded before "swig_lib/foo.i". I thought this was the case already, but apparently it has been broken for quite some time. 08/01/2002: beazley Added std_deque.i library file. Work in progress. 08/01/2002: beazley [Python,Tcl,Perl] Improvements to typemaps.i. INPUT/INOUT typemaps perform better error checking. Typemaps are now supplied for references like int &OUTPUT, double &INOUT, etc. 08/01/2002: beazley [Python] Deprecated the T_* and L_* typemaps in typemaps.i. Multiple return values are always placed in a tuple. Deprecated the BOTH typemaps. This is now INOUT (e.g., int *INOUT). *** POTENTIAL INCOMPATIBILITY FOR PYTHON MODULE *** 08/01/2002: beazley Deprecated the array.i, carray.i, and timer.i library files. 08/01/2002: beazley Deprecated the pointer.i library file. Use cpointer.i instead. *** POTENTIAL INCOMPATIBILITY *** 08/01/2002: cheetah (William Fulton) [Java] For consistency the global variable getters and setters use the JavaBean property design pattern like member variables always have. This means if you are wrapping a variable called foo, the getter is called getFoo() and the setter is called setFoo(). Before the recent changes to the Java module the getters and setters were called get_foo() and set_foo(). If you really want the original function names use the %rename directive like this: %rename(_foo) Foo; 07/31/2002: beazley Fixed casting problem with multiple inheritance. If you had this, class foo {}; class bar : public foo {}; class baz : public foo {}; class spam : public bar, public baz {}; then the wrappers wouldn't compile due to an ambiguous cast. Reported by Art Yerkes. 07/30/2002: cheetah (William Fulton) [Java] Due to new static typechecking all pointers held in a Java long are part of the internal workings and this pointer value in the Java long has become abstracted data. The type wrapper constructor and getCPtr() methods are as such protected. If you need to mess around with pointers from Java or for example create a proxy class or type wrapper class around a null pointer, add a function/constructor to do so with the %javacode typemap. You can also make getCPtr() public again with the %javagetcptr typemap. 07/30/2002: cheetah (William Fulton) [Java] Fixes for %typemap(ignore). In particular when ignoring the last parameter in a function. Also for all parameters in constructors. These mods have also fixed multi-argument typemaps for proxy classes - SF 581791. 07/30/2002: cheetah (William Fulton) [Java] %newobject (replacement for %new) now implemented for Java. 07/29/2002: beazley Fixed problem with typemap copies, %apply, and %clear inside C++ namespaces. 07/28/2002: cheetah (William Fulton) [Java] The JNI class now has package access as the class modifier has been changed from "public" to nothing. This has been done as this class is now more for the internal workings of SWIG since the module class has static type checking for all types. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** Backwards compatibility can be achieved by using the %jniclassclassmodifier pragma to change it back to "public". 07/28/2002: cheetah (William Fulton) [Java] Proxy/Shadow classes are generated by default. The -proxy and -shadow command line options are deprecated. If you want to use the low-level functional interface then use the new -noproxy commandline option. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 07/28/2002: cheetah (William Fulton) [Java] Remaining pragmas shakeup. These were the remaining pragmas and their new names where changed: modulebase modulecode moduleclassmodifiers moduleimport => moduleimports moduleinterface => moduleinterfaces The moduleimports works slightly differently to how the moduleimport pragma worked. Now it actually takes code which gets placed before the class definition so the whole import statement has to be given, for example: %pragma(java) moduleimports=%{ import java.io.*; import java.math.*; %} The moduleinterfaces is slightly different to the old moduleinterface in that if more than one interface is required they must be comma separated in one use of the pragma, for example: %pragma(java) moduleinterfaces="Serializable, MyInterface" These last two pragmas are consistent with the javainterfaces and javaimports typemap. A similar set of pragmas has been introduced, namely: jniclassbase jniclasscode jniclassclassmodifiers jniclassimport jniclassinterface These work in the same way as their module counterparts. Note that previously the moduleXXX pragmas worked on the old module class which is now called the JNI class (the class with the native functions). The jniclassXXX pragmas now work on the new module class (the class that has all the global functions and global variable getters and setters when using proxy classes, plus all other remaining functions when using the low-level procedural interface). In summary the contents of the pragmas make up a class like this: class modulename extends implements { ... SWIG generated functions ... } } *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 07/28/2002: cheetah (William Fulton) [Java] Deprecated modulemethodmodifiers pragma and replaced with a better %feature based directive called %javamethodmodifiers. A useful example would be for synchronisation in multi-threaded apps: %javamethodmodifiers foo(int a) "public synchronized"; Changes this function from the default ("public") to "public synchronized". *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 07/26/2002: beazley Several directives now allow optional configuration parameters. These include: %module(name="value", name="value", ...) modulename %import(name="value", ...) "filename.i" %extend(name="value", ...) classname { ... } These currently have no effect and are reserved for future expansion. 07/26/2002: beazley Enhancements to smart-pointer handling. SWIG only provides extra support for a smart-pointer if operator->() returns a proper pointer. For example: Foo *operator->(); If operator->() returns an object by value or reference, then SWIG examines the returned object to see if it also implements operator->(). If so, SWIG chases operator->() until it can find one that returns a pointer. This allows cases like this to work: class Foo { public: void blah(); }; class Bar { ... Foo *operator->(); ... }; class Spam { ... Bar operator->(); ... }; For example: >>> s = Spam() >>> s.blah() # Invokes Foo::blah() The s.blah() call actually invokes: ((s.operator->()).operator->())->blah(); 07/26/2002: beazley Fixed a bug with typedef and references. For example: typedef Foo & FooRef; FooRef blah(); Previous versions of SWIG generated code that wouldn't compile. 07/25/2002: beazley Wrapping of static methods has been improved in proxy classes. In older versions of SWIG, if you had this: class Foo { public: static void bar(); }; The static method was only available as a function Foo_bar(). For example: >>> Foo_bar() Now, the static method can also be invoked through an instance like this: >>> f = Foo() >>> f.bar() # Invokes static method This works with all versions of Python. Additionally, for Python-2.2, the static method can be invoked as: >>> Foo.bar() The old-style function is still support for backwards compatibility. If you care about making your code across different versions of Python, either use Foo_bar() or access the method through an instance. 07/25/2002: beazley Changes to the Python module. Proxy classes now utilize new Python-2.2 features including properties and static methods. However, these features are supported in a way that provides backwards compatibility with older Python versions. In other words, proxy classes work with all versions of Python and only use new features when running on Python-2.2. 07/25/2002: beazley Modified %extend so that overloaded methods can be added. For example: %extend Foo { void bar(int x) { }; void bar(char *s) { }; ... } This works with both C++ *and* C. 07/24/2002: cheetah (William Fulton) [Java] More new typemaps so that the Java proxy classes and type wrapper classes can be further tailored by users. These are the default code for generating the finalize() methods (proxy classes only) and the getCPtr() methods for proxy classes and type wrapper classes: %typemap(javafinalize) SWIGTYPE %{ protected void finalize() { _delete(); } %} %typemap(javagetcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ public static long getCPtr($javaclassname obj) { return obj.swigCPtr; } %} The javagetcptr typemap will enable users to handle Java null by overriding this typemap - a requested feature. The -nofinalize commandline option has been deprecated. The javafinalize typemap is more powerful as it will allow the removal of the finalize methods for all or any one or more particular proxy class. 07/23/2002: cheetah (William Fulton) [Java] The getCPtrXXX() function has been changed to a static function and is now of the form: protected static long getCPtr(XXX obj) {...} This is a requested change which will allow Java null pointers to be used as null can be passed in for obj. However, to achieve this the appropriate code must be written using the new javagetcptr typemap directive. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** Backwards compatibility can be achieved by adding this function back in using the new javacode typemap: %typemap(javacode) SWIGTYPE %{ // SWIG-1.3.12 and SWIG-1.3.13 public long getCPtr$javaclassname() { return swigCPtr; } // SWIG-1.3.11 and earlier public long getCPtr() { return swigCPtr; } %} 07/23/2002: cheetah (William Fulton) [Java] New directive to control constant code generation - %javaconst. The default handling for handling constants is to get the value through a JNI call, eg #define YELLOW 5 #define BIG 1234LL results in: public final static int YELLOW = modulename.get_YELLOW(); public final static long BIG = modulename.get_BIG(); Earlier versions of the Java module initialised the value using the C value: public final static int YELLOW = 5; public final static long BIG = 1234LL; This works in most cases, but the value for BIG won't compile as 1234LL is not valid Java code and this is one of the reasons why the default is now to get the values through a JNI call. The side effect is that these 'constants' cannot be used in switch statements. The %javaconst directive allows one to specify the way the constant value is initialised and works like other %feature directives, eg %javaconst(0); // all constants from this point on are initialised using the C value %javaconst(1) BIG; // just BIG initialised using JNI call (must be parsed before BIG is defined) 07/23/2002: beazley *** IMPORTANT CHANGES TO THE PYTHON MODULE *** (1) The Python module now enables shadow/proxy classes by default. This means that two files are always created by SWIG. For instance, if you have this: // file: foo.i %module foo ... Then swig generates two files "foo_wrap.c" and "foo.py". (2) The name of the low-level C extension module has been changed to start with a leading underscore. This means that you have to compile the module as follows: $ cc -c -I/usr/local/include/python2.2 foo_wrap.c $ cc -shared foo_wrap.o $(OBJS) -o _foo.so ^^^^ note extra underscore This naming scheme is consistent with other Python modules that utilize extension code. For instance, the socket module consists of "_socket.so" and "socket.py". In previous versions of SWIG, the shared object file was named "foocmodule.so". (3) A new directive can be used to insert Python code into the corresponding .py file. For example: %pythoncode %{ def foo(): print "Hello World" %} This directive allows you to create modules as a mix of C and Python. Python code is seamlessly added to the module. (4) The -shadow command line option is deprecated. This is turned on by default. (5) To disable the generation of the extra python file, use the "-noproxy" command line option. *** POTENTIAL INCOMPATIBILITY *** This change will likely break the build environment of projects that utilize shadow classes. To fix this, you probably only need to change the name of the target .so file. For example, if you have Makefile information like this: TARGET = examplecmodule.so Just change it to: TARGET = _example.so *** DOCUMENTATION UPDATE *** The file Doc/Manual/Python.html has been updated to describe these changes. 07/23/2002: beazley Added -noextern option. If supplied, SWIG will not generate extra extern declarations. This is sometimes an issue on non-unix platforms. 07/23/2002: beazley Added a warning for ignored friend functions. 07/23/2002: beazley Fixed [ 574498 ] -proxy and %include "pointer.i" clash. Reported by David Creasy. 07/23/2002: beazley Fixed [ 576103 ] global destruction warning with shadow. Perl extensions should no longer report the warning "Use of uninitialized value during global destruction." when running with "perl -w". Reported by Brett Williams. 07/23/2002: beazley In C++ mode, SWIG now always defines namespace std. By default, it's empty. However, this will silence errors from programs that include statements such as "using namespace std;". This fixes Bug [ 584017 ] using namespace std generates error. Reported by Joseph Winston. 07/22/2002: beazley Added a new warning message for %apply. If you use %apply but no typemaps are defined, you will get a warning message. This should help with problems like this: %apply char *OUTPUT { ... }; In old versions of SWIG, this silently did nothing. Now you get an error like this: file:line. Warning. Can't apply (char *OUTPUT). No typemaps are defined. 07/22/2002: cheetah (William Fulton) [Java] Started Java pragma deprecation. Replacements use %typemap based directives and enable proxy classes and the new type wrapper classes to be tailored in various ways. These are the new typemaps: %typemap(javabase) - base (extends) for Java class %typemap(javaclassmodifiers) - class modifiers for the Java class: default is "public" %typemap(javacode) - java code is copied verbatim to the Java class %typemap(javaimports) - import statements for Java class %typemap(javainterfaces) - interfaces (extends) for Java class And these are the %pragma directives being deprecated: allshadowbase allshadowclassmodifiers allshadowcode allshadowimport allshadowinterface shadowbase shadowclassmodifiers shadowcode shadowimport shadowinterface Note that it is possible to target a particular proxy class: %typemap(javaimports) Foo "import java.util.*"; or a particular type wrapper class: %typemap(javaimports) double* "import java.math.*"; Note that $javaclassname in these typemaps are substituted with either the proxy classname when using proxy classes or the SWIGTYPE class name. 07/18/2002: cheetah (William Fulton) [Java] Java module overhaul to implement static type checking of all types. 1) Changes when using Java Proxy classes ---------------------------------------- Previously when wrapping global functions: class SomeClass{}; void foo(SomeClass* s); SomeClass* bar(); The native method prototypes used a long for pointers and looked like this: public class modulename { ... public final static native void foo(long jarg1); public final static native long bar(); } and unlike member functions of a C++ class there was no wrapper around the native calls to make the use of them more user friendly. They would be used from Java like this: SomeClass s = new SomeClass(modulename.bar(), false); modulename.foo(s.getCPtrSomeClass()); Note that the following will have the same effect, but then it would not have been possible to call any proxy member functions in SomeClass: long s = modulename.bar(); modulename.foo(s); Now wrapper functions are generated: public class modulename { public static void foo(SomeClass s) { // calls the native function } public static SomeClass bar() { // calls the native function } } Which means these functions can now be used more naturally with proxy classes: SomeClass s = modulename.bar(); modulename.foo(s); 2) Changes when not using Java Proxy classes -------------------------------------------- The so called low-level interface was rather low-level indeed. The new static type checking implementation makes it less so but it remains a functional interface to the C/C++ world. Proxy classes are the obvious way to use SWIG generated code, but for those who want a functional interface all non-primitive types now have a simple Java class wrapper around the C/C++ type. Pointers and references to primitive types are also wrapped by type wrapper classes. The type wrapper classnames are based on the SWIG descriptors used by the other language modules. For example: C/C++ type Java type wrapper class name ---------- ---------------------------- int* SWIGTYPE_p_int double** SWIGTYPE_p_p_double SomeClass* SWIGTYPE_p_SomeClass SomeClass& SWIGTYPE_p_SomeClass SomeClass SWIGTYPE_p_SomeClass Note that everything wrapped by SWIG is accessed via a pointer even when wrapping functions that pass by value or reference. So the previous example would now be used like this: SWIGTYPE_p_SomeClass s = example.bar(); example.foo(s); Note that typedefs that SWIG knows about are resolved, so that if one has class Foo{}; typedef Foo Bar; then any use of Bar will require one to use SWIGTYPE_p_Foo; Some considerations: Make sure you make a firm decision to use either proxy classes or the functional interface early on as the classnames are different. 3) Pointers and non-parsed types -------------------------------- Sometimes SWIG cannot generate a proxy class. This occurs when the definition of a type is not parsed by SWIG, but is then used as a variable or a parameter. For example, void foo(Snazzy sds); If SWIG has not parsed Snazzy it handles it simply as a pointer to a Snazzy. The Java module gives it a type wrapper class around the pointer and calls it SWIGTYPE_p_Snazzy. In other words it handles it in the same manner as types are handled in the low-level functional interface. This approach is used for all non-proxy classes, eg all pointer to pointers and pointers to primitive types. 4) Backwards compatibility ----------------------- Backwards compatibility is not an issue if you have been using proxy classes and no global variables/functions. Otherwise some changes will have to be made. The native methods still exist but they are now in a JNI class, which is called modulenameJNI. As this class is really part of the internal workings, it should not be required so the class has become protected. Some pragmas/directives will hopefully be added to help with backwards compatibility. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 07/18/2002: beazley Modified wrapping of uninstantiated templates returned by value. Just to be safe, they are now wrapped by SwigValueWrapper<> just in case they don't define a default constructor. This would be used if you had code like this Foo blah(); void moreblah(Foo x); but you didn't instantiate Foo using %template. We should probably add a warning for this. 07/17/2002: beazley Added an error check to detect shadowed template paramaters. For example: template class Foo { public: int T; }; This results in an error, not a warning. This warning is also needed to fix some rather insidious problems like this: struct T { int blah; }; template class Foo { public: typedef T Traits; // Which T is this???? }; In this case, the template parameter T shadows the outer structure (which is what you want). 07/16/2002: beazley Improved support for templates with integer arguments. SWIG is much more aware of situations such as this: const int Size = 100; %template(Foo100) Foo<100>; void bar(Foo *x); // Knows that Foo is the same as Foo<100>; 07/15/2002: beazley Fixed bug with %feature/%ignore/%rename and namespaces. For example: %ignore Foo::Bar namespace Foo { class Bar { ... }; } Reported by Marcelo Matus. 07/09/2002: beazley Added parsing support for constructors that try to catch exceptions in initializers. For example: class Foo { Bar b; public: Foo(int x) try : b(x) { ... } catch(int) { ... } } This has no effect on the generated wrappers. However, the try and catch parts of the declaration are ignored. See Stroustrup, 3rd Ed, section 14.4.6.1 for details. 07/06/2002: beazley Fixed bug in template symbol table management. This fixes two bugs. First, mixing abstract methods, templates, and inheritance no longer generates a failed assertion. template class A { public: virtual void foo() = 0; }; template class B : public A { }; %template(A_int) A; %template(B_int) B; This fix also fixes a subtle problem with default values and templates. For example: template struct B { typedef unsigned int size_type; static const size_type nindex = static_cast(-1); void foo(size_type index = nindex); }; Bugs reported by Marcelo Matus. 07/05/2002: ljohnson (Lyle Johnson) [Ruby] Changed the definition of the SWIG_ConvertPtr() function for the SWIG/Ruby runtime support so that it looks like the Python version. If the last argument (flags) is non-zero, SWIG_ConvertPtr() will raise an exception for type mismatches as before. If flags is zero, this function will return -1 for type mismatches without raising an exception. *** POTENTIAL INCOMPATIBILITY FOR RUBY MODULE *** 07/04/2002: beazley Overloaded functions/methods/constructors now work in many language modules. The support is completely transparent--just call the function normally and SWIG will dispatch to the correct implementation. There are a variety of issues associated with this. Please refer to the overloading section of Doc/Manual/SWIGPlus.html for details. *** NEW FEATURE *** 07/04/2002: beazley Fixed a bug with namespaces, enums, and templates. For example: namespace hello { enum Hello { Hi, Hola }; template struct traits { typedef double value_type; }; traits::value_type say_hi() { return traits::value_type(1); } } SWIG wasn't generating wrappers that properly qualified traits. Reported by Marcelo Matus. 06/30/2002: beazley Supplied array variable typemaps for Tcl module. If you have a variable like this: int foo[10]; then a set function like this is generated: void foo_set(int *x) { memmove(foo,x,10*sizeof(int)); } 06/30/2002: beazley New %fragment directive. When writing typemaps, it can be easy to get carried away and write a lot of code. However, doing so causes tremendous code bloat. A common way to solve this is to write helper functions. For example: %{ void some_helper_function() { ... } %} %typemap(in) type { some_helper_function(...); } The only problem with this is that the wrapper file gets polluted with helper functions even if they aren't used. To fix this, a new fragment directive is available. For example: (corrected typo in line below - 06/26/2008) %fragment("type_header","header") %{ void some_helper_function() { ... } %} %typemap(in, fragment="type_header") type { some_helper_function(...); } In this case, the code fragment is only emitted if the typemap is actually used. A similar capability is provided for declaration annotation and the %feature directive. For example: %feature("fragment","type_header") SomeDeclaration; The first argument to %fragment is the fragment name. The second argument is the file section where the fragment should be emitted. The primary use of this directive is for writers of language modules and advanced users wanting to streamline typemap code. *** EXPERIMENTAL NEW FEATURE *** 06/30/2002: beazley Supplied memberin typemaps for all arrays in an attempt to eliminate confusion about their use. 06/29/2002: beazley Experimental support for smart-pointers. When a class defines operator->() like this class Foo { ... Bar *operator->(); ... }; SWIG locates class Bar and tries to wrap its member variables and methods as part of Foo. For example, if Bar was defined like this: class Bar { public: int x; int spam(); }; You could do this (in the target language): f = Foo() f.x = 4 # Accesses Bar::x f.spam() # Accesses Bar::spam The primary use of this feature is to emulate the behavior of C++ smart-pointers---which allow attributes to accessed transparently through operator->. This feature is supported automatically in SWIG---no special directives are needed. To disable this behavior. Use %ignore to ignore operator->. *** NEW FEATURE *** 06/26/2002: beazley Deprecated the %except directive. %exception should be used instead. 06/25/2002: beazley Major cleanup of the modules directory. Eliminated most header files, consolidated module code into single files. 06/24/2002: beazley Reworked the instantiation of language modules. All language modules must now define a factory function similar to this: extern "C" Language * swig_python(void) { return new PYTHON(); } This function is then placed in a table and associated with a command line option in swigmain.cxx. This approach has a number of benefits. It decouples the SWIG main program from having to know about the class definitions for each module. Also, by using a factory function, it will be easier to implement dynamic loading of modules (simply load the file and invoke the factory function). 06/24/2002: beazley Fixed syntax error for reference conversions. For example: operator Foo &(); 06/24/2002: beazley Fixed syntax error for operator new[] and operator delete[]. 06/24/2002: beazley Fixed code generation problem for constants and default arguments involving templates. 06/19/2002: ljohnson (Lyle Johnson) [Ruby] Fixed a bug for the '-feature' command line argument; that setting was effectively being ignored and so the feature name was always set equal to the module name. 06/17/2002: beazley Fixed problems with static members and enums in templates. Version 1.3.13 (June 17, 2002) ============================== 06/16/2002: beazley Fixed a bug with __FILE__ expansion in the preprocessor. On Windows, the backslash (\) is now converted to (\\) in the string literal used for __FILE__. Reported by Steve Glaser. 06/14/2002: beazley Fixed warning message about 'name private in this context'. The warning is only generated for public methods. Reported by Scott Michel. 06/14/2002: beazley Fixed some problems related to template instantiation and namespaces. When SWIG expands a template, it does so with fully resolved types. For example, if you have this: template class foo { }; typedef double Double; %template(foo_d) foo; then, it is handled as foo in the typesystem. This fixes a number of subtle problems with inheritance and templates. 06/14/2002: ljohnson (Lyle Johnson) [Ruby] Added missing bool typemaps for INPUT, OUTPUT and INOUT in Lib/ruby/typemaps.i. 05/29/2002: cheetah (William Fulton) [Java] Fix for a couple of broken pragmas. 05/29/2002: cheetah (William Fulton) Fix for unnecessary cast when wrapping global variable where the type is not parsed by SWIG - Java variables example failure as reported by Larry Virden. 06/10/2002: beazley Modified %template to allow for empty instantiations. %template() foo; This registers foo with the type system, but doesn't wrap it (same as %ignore). This may only be a temporary measure. SWIG might be able to automatically instantiate templates in certain cases. 06/10/2002: beazley Fixed function prototype problems with Tcl 8.4 06/09/2002: beazley Fixed problem with templates and location of base classes. This one is a little mind-bending, but here is an example that illustrates: template struct traits { typedef ArgType arg_type; typedef ResType res_type; }; template struct Function { }; template struct Class : Function::arg_type, typename traits::res_type> { }; %template(traits_dd) traits ; %template(Function_dd) Function ; %template(Class_dd) Class ; In this example, the base class of 'Class' is determined from the Function template, but the types are obtained through typedefs. Because of this, SWIG could not locate the wrapped base class (Function). Should be fixed in 1.3.13 even though I can think of a million other things that might also be broken. 06/07/2002: beazley Fixed a problem with conversion operators. If you had an operator like this, operator double() const; SWIG was ommitting the "const" qualifier. This affected %rename and other directives. Reported by Zhong Ren. 06/07/2002: beazley Lessened the strictness of abstract class checking. If you have code like this: class Foo { public: virtual int method() = 0; }; class Bar : public Foo { public: Bar(); ~Bar(); }; SWIG will go ahead and generate constructor/destructors for Bar. However, it will also generate a warning message that "Bar" might be abstract (since method() isn't defined). In SWIG-1.3.12, SWIG refused to generate a constructor at all. 06/07/2002: beazley Change to %template directive. If you specify something like this: %template(vi) std::vector; It is *exactly* the same as this: namespace std { %template(vi) vector; } SWIG-1.3.12 tried to instantiate the template outside of the namespace using some trick. However, this was extremely problematic and full holes. This version is safer. 06/07/2002: beazley Fixed bug with scope qualification and templates. For example: A::DD Before, this was separated as scopes A, and DD. Fixed now. 06/06/2002: beazley Allow the following syntax: class A { }; struct B : A { ... }; A base class without a specifier is assumed to be public for a struct. 06/06/2002: beazley Fixed syntax error with template constructor initializers. Reported by Marcelo Matus. 06/06/2002: beazley Fixed bug with default template arguments. Reported by Marcelo Matus. 06/05/2002: beazley Fixed subtle problems with %rename directive and template expansion. Code like this should now work: %rename(blah) foo::method; ... template class foo { public: void method(); }; %template(whatever) foo; 06/05/2002: beazley Resolved some tricky issues of multi-pass compilation and and inheritance. The following situation now generates an error: class Foo : public Bar { ... }; class Bar { ... }; The following code generates a warning about incomplete classes. class Bar; class Foo : public Bar { }; The following code generates a warning about an undefined class. class Foo : public Bar { }; // Bar undefined This fixes a failed assertion bug reported by Jason Stewart. 06/05/2002: ljohnson [Ruby] Added a warning message for the Ruby module about the lack of support for multiple inheritance. Only the first base class listed is used and the others are ignored. (Reported by Craig Files). 06/03/2002: beazley Fixed a bug with struct declarations and typedef. For example: typedef struct Foo Foo; struct Foo { ... }; A few other subtle struct related typing problems were also resolved. Version 1.3.12 (June 2, 2002) ============================= 05/30/2002: beazley Fixed problem related to forward template class declarations and namespaces. Bug reported by Marcelo Matus. 05/30/2002: beazley Added 'make uninstall' target. Contributed by Joel Reed. 05/29/2002: beazley Fixed rather insidious bug with %rename, %feature and template specialization. For example: %exception vector::__getitem__ { ... some exception ... } template class vector { ... T __getitem__(int index); // Fine ... }; template<> class vector { ... T __getitem__(int index); // Oops. ... }; Now, the %exception directive (and other features) should correctly apply to both vector and specializations. 05/29/2002: beazley Subtle changes to %template() directive. Template arguments are now reduced to primitive types in template matching. For example: template class vector { ... partial specialization ... } typedef int *IntPtr; // Gross typedef // Gets the above partial specialization %template(vectorIntPtr) vector; This change is extremely subtle, but it fixes a number of potential holes in Luigi's STL library modules. For example: typedef int Integer; %template(vectori) vector; 05/29/2002: beazley Fixed rather insidious typemap bug related to const. const was being discarded through typedefs. 05/29/2002: ljohnson (Lyle Johnson) [Ruby] Added input typemaps for const references to primitive types (in Lib/ruby/ruby.swg). 05/29/2002: cheetah (William Fulton) [Java] The java arrray support functions are enclosed by a SWIG_NOARRAYS #define. Useful if not using arrays and it is desirable to minimise the amount of compiled code. 05/29/2002: cheetah (William Fulton) [Java] Enums were not renamed when using %name or %rename fix. 05/28/2002: ljohnson [Ruby] Modified the name of the wrapper functions for the "new" singleton method and "initialize" instance method for consistency with the other language modules. The wrapper name for the function that implements "new" is alloc_classname and the wrapper name for the function that implements "initialize" is new_classname. 05/27/2002: beazley Changes to runtime. Pointer conversion/creation functions now almost always have an extra "flags" argument. For example: SWIG_ConvertPtr(obj, void **, swig_type_info *ty, int flags); ^^^^^^^^^^ This extra parameter is reserved for future expansion and will be used for more control over pointers in future versions. 05/27/2002: beazley Fix for C++ classes with private assignment operators. It is now possible to safely return objects like this by value. Caveat: the class must provide a copy constructor. 05/26/2002: beazley -proxy option added to many language modules. This is the same as -shadow. We are merely changing terminology. 05/26/2002: beazley [perl] Fixed some inconsistencies in the -package option. -package merely sets the package name to be used on the wrappers. It does not change the name of the shared library file or the name of the generated .pm file. This was broken at some point, but works again now. 05/25/2002: beazley [perl] Fixed [ 475452 ] memory leak in return-by-value. Problem related to static member variables returning newly allocated objects. Reported by Roy Lecates. 05/25/2002: beazley [perl] Fixed [ 513134 ] %BLESSEDMEMBERS isn't always right. Reported by Fleur Diana Dragan. 05/25/2002: beazley Fixed [ 540735 ] -importall and the -I option. 05/25/2002: beazley [guile] Fixed [ 532723 ] Default arg for char* can SegV. Error in guile module. Reported by Brett Williams. 05/25/2002: beazley Subtle change to typemap application code. The "freearg" typemap must exactly match up with the "in" or "ignore" typemap. For example: %typemap(in) (char *data, int len) { ... }; %typemap(freearg) char *data { ... }; void foo(char *data, int len); In this case, the "in" typemap is applied, but the freearg typemap is not. This is because the freearg typemap doesn't match up with the input argument sequence. 05/25/2002: beazley Fixed [ 548272 ] Default argument code missing braces. Reported by Brett Williams. 05/25/2002: beazley Fixed [ 547730 ] SwigValueWrapper needed for constructors. Reported by William Fulton. 05/25/2002: beazley Undefined identifiers now evaluate to 0 when evaluating preprocessor expressions. For example: #if !FOO ... #endif where FOO is undefined or set to some non-numeric value. Fixes [ 540868 ] #if defined whatever - not parsed. Reported by Adam Hupp. 05/24/2002: beazley SWIG now ignores the C++ 'export' keyword. 05/23/2002: beazley Some refinement of type-name mangling to account for pointers, arrays, references, and other embedded type constructs. 05/23/2002: beazley Initial attempt at supporting template partial specialization. At the very least, it is parsed and the classes are stored. Matching of instantiations to specialized version is more limited and based on the SWIG default typemap rules: SWIGTYPE * SWIGTYPE [] SWIGTYPE & Now, why in the world would you want to use this feature? Other than allowing for slightly modified class APIs, this capability is primarily used to provide advanced wrapping support for STL-like objects. It can also be mixed with typemaps. Here is an example: /* Generic version */ template class vector { %typemap(in) vector * { // A container of objects } }; /* Partial specialization (pointers) */ template class vector { %typemap(in) vector * { // A container of pointers to objects. } }; /* Specialization (integers). */ template<> class vector { %typemap(in) vector * { // A container of integers. } }; *** EXPERIMENTAL FEATURE *** 05/23/2002: beazley Enhancement to typemaps. Normally, typemap variables are renamed to avoid conflicts. For example: %typemap(in) int * (int temp) { $1 = &temp; } This results in code that creates and uses variables "temp1","temp2", "temp3" and so forth depending on how many times the typemap is used. Sometimes you want a single variable instead. To do that, using the following naming scheme: %typemap(in) int *(int _global_temp) { } Is this case, a single variable _global_temp is emitted in the wrapper functions. It is shared across all typemaps. Repeated typemaps do not replicate the variable---they use the first one emitted. *** NEW FEATURE *** 05/23/2002: beazley Minor enhancement to typemaps. If you have this code, %typemap(in) Foo (int somevar = 3) { ... } the default value for somevar is now emitted into the wrapper code. 05/22/2002: beazley Fixed %extend to be better behaved in namespaces. If you have code like this: namespace foo { struct bar { %extend { void blah(); }; }; } SWIG matches the blah() method to a C function named void foo_bar_blah(foo::bar *self). This is consistent with the non-namespace version. Bug reported by Marcelo Matus. 05/22/2002: beazley New library files: cpointer.i, carrays.i, cmalloc.i. These provide access to C pointers and memory allocation functions. See Doc/Manual/Library.html for details. 05/22/2002: cheetah (William Fulton) [Java] C type char no longer maps to Java type byte, but to Java type char. It is now treated as a character rather than a signed number. This fits in with the other language modules and is a more natural mapping as char* is mapped as a string of characters. Note that the C signed char type is still mapped to a Java byte. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 05/22/2002: cheetah (William Fulton) [Java] Improved constants wrapping. Constants (#define and %constant) values are now obtained through a JNI call. Previously the value was compiled as Java code, but this didn't work for all cases, eg #define 123ULL. 05/22/2002: beazley Fixed bogus error message with %extend directive and C++ access specifiers. Reported by Marcelo Matus. 05/22/2002: beazley Namespaces and enums now work correctly. For example: namespace Foo { enum Bar { A, B }; } Bug reported by Marcelo Matus. 05/21/2002: beazley The %types directive can now be used to specify inheritance relationships in the runtime type system. For example, %types(Foo = Bar); specifies that Foo isa Bar. Using this is potentially quite dangerous. However, this is useful in certain cases (and in the SWIG library). 05/20/2002: beazley %nodefault and %makedefault directives now require a trailing semicolon. For example: %nodefault; ... %makedefault; In addition both directives can take a class name. For example: %nodefault Foo; class Foo { /* No default constructor/destructor */ }; class Bar { /* Default constructor/destructor generated */ }; *** POTENTIAL INCOMPATIBILITY *** If you don't use the trailing semicolon, things will mysteriously break. 05/20/2002: beazley More improvements to type system handling. SWIG now correctly handles template names and parameters in a namespace. For example: namespace foo { template class bar { }; typedef int Integer; void blah(bar *x); }; In the generated code, all of the typenames are properly qualified. 05/17/2002: cheetah (William Fulton) [Java] deprecated broken -jnic and -jnicpp commandline options. The C or C++ JNI calling convention is now determined from the -c++ commandline option. 05/16/2002: cheetah (William Fulton) [Java] The JCALL macros which exist so that the same typemaps can be used for generating both the C and C++ JNI calling conventions no longer appear in the generated code. This is because the output is now passed through the SWIG preprocessor which does the macro expansion for either C or C++ (depending on whether -c++ is passed on the SWIG commandline). The generation of the functions used in the array typemaps have been adjusted to take account of this. The side effect is that any typemaps which contained JCALL macros within %{ %} brackets will have to be moved within {} brackets so that the SWIG preprocessor can expand the macros. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 05/13/2002: beazley Class templates may now be used as template parameters. For example: template class C> class Foo { ... }; template class Bar { ... }; %template(Fooi) Foo; SWIG doesn't really do anything special with this---it's just another way of specifying a template parameter. 05/13/2002: beazley Minor refinement of template support. Template parameter names are no longer required for types. For example: template class Foo { }; Obviously, names are required for template; 05/12/2002: beazley New macro expansion in typemaps. The sequence: $descriptor(type) Will expand into the SWIG type descriptor structor for the given type. Type may be any abstract datatype. For example: $descriptor(int *) $descriptor(int (*)(int,double)) $descriptor(vector *) Caveat: It is *NOT* currently legal to use other typemap substitution variables in the macro. For example $descriptor($1_type). The primary purpose of this modification is to better support typemaps for container objects or to allow typemaps that might be performing type conversions. *** NEW FEATURE *** 05/11/2002: beazley The wrapping of references to primitive types has been changed as follows: Arguments of type 'const primitive &' are now passed by value as opposed to pointers. Return values of type 'const primitive &' are returned as values instead of pointers. 'primitive' is any one of int, short, long, long long, char, float, double, bool (as well as unsigned variants). This change is being made to better support C++ wrapping--especially code that makes use of templates and the STL. 05/11/2002: beazley The %template directive can now be used to access templates in a namespace. For example: namespace std { template class complex { T re, im; public: complex(T _r = T(), T _i = T()) : re(_r), im(_i) { } T real() { return re; } T imag() { return im; } }; } %template(complex) std::complex; Note: There are some very subtle namespace/symbol table management issues involved in the implementation of this. It may not work in certain cases. 05/10/2002: beazley Member template constructor support added. For example: template struct pair { _T1 first; _T2 second; pair() : first(_T1()), second(_T2()) { } template pair(const pair<_U1,_U2> &x); }; To instantiate the template, use %template and %extend. For example, this expands the constructor into a default copy constructor: %extend pair { %template(pair) pair<_T1,_T2>; } Highly experimental. Other uses may be broken. 05/10/2002: beazley The %extend (%addmethods) directive no longer works unless it appears in the public section of a class. An error message is now generated (as opposed to a segmentation fault). 05/09/2002: beazley New %warnfilter() directive. This directive attaches a warning filter to specific declarations and has the same semantics as %rename, %ignore, %feature, and so forth. For example: %warnfilter(501) foo; // Suppress overloaded warning int foo(int); int foo(double); or %warnfilter(501) Object::foo(double); class Object { public: int foo(int); int foo(double); }; This feature only suppresses warnings in later stages of code generation. It does not suppress warnings related to preprocessing or parsing. *** NEW FEATURE *** 05/09/2002: beazley SWIG now supports C99 variadic preprocessor macros. For example: #define debugf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__) The argument "..." is used to indicate variable arguments which are all placed into the special argument name __VA_ARGS__ in the macro expansion. SWIG also implements the GNU (##) extension for swallowing the preceding comma when __VA_ARGS__ is empty. For example: #define debugf(fmt,...) fprintf(stderr,fmt, ##__VA_ARGS__) Here is how this is expanded: debugf("%d", 3) --> fprintf(stderr,"%d",3) debugf("Hello") --> fprintf(stderr,"Hello" ) (notice the deleted comma). *** NEW FEATURE *** 05/08/2002: samjam (Sam Liddicott) Many changes to php module. Shadow classes are now implemented entirely in native C and no need for php-code shadow wrappers Populated template config.m4 and Makefile.in as needed by phpize are generated. 05/08/2002: ljohnson (Lyle Johnson) [Ruby] A copy constructor is now turned into a "clone" instance method (see Dave's change for copy constructors dated 4/7/2002). This seems like the appropriate thing to do for Ruby code. 05/08/2002: ljohnson (Lyle Johnson) [Ruby] Fixed [ 553864 ] Inline destructor code not written. 05/08/2002: beazley %ignore behaves better with constructors, destructors, and the type system in general. For constructors and destructors, %ignore now suppresses the creation of a default constructor or destructor. For example: %ignore ~Foo; class Foo { public: Foo(); ~Foo(); ... }; In SWIG-1.3.11, ~Foo() simply "disappeared" and the code generator created a wrapper for a default destructor (as if it was never declared in the interface). In SWIG-1.3.12, %ignore suppresses the creation of a destructor if one is actually defined. Similarly, even though a declaration is ignored, information may still be needed to properly handle types. For example, here is a very subtle error that is fixed by this change: %ignore std::string; // Prevent class wrapping namespace std { class string { ... }; %typemap(in) string * { ... } } void foo(std::string *s); // Broken. Before this fix, %ignore would cause the class definition to disappear. This, in turn, would cause the typemap to be misapplied. 05/08/2002: beazley Minor changes to %rename, %ignore, %feature, and related directives for better support of destructors. Destructors can now be precisely tagged. For example: %ignore Foo::~Foo; %feature("action") ~Bar { ... } *Developer warning* Operations such as renaming and feature attachment for classes used to be applied to destructors as well. For instance, if you did this: %rename(Bar) Foo; The operation applied to the class itself, the constructor, and the destructor. This is no longer the case. Now such operations will only apply to the class and the constructor. Note: if you were relying on this for class renaming, be aware that renamed classes should really only be handled at the level of the class itself and not the level of individual declarations in the class (although they can be renamed individually if needed). As far as I know, the Language class is already taking care of this case correctly. 05/07/2002: beazley New set of tests. The Examples/test-suite/errors directory contains tests that try to exercise all of SWIG's error and warning messages. 05/07/2002: beazley Start of a warning framework. Warning messages are now assigned numeric values that are shown in warning messages. These can be suppressed using the -w option. For example: swig -w302 example.i swig -w302,305 example.i Alternatively, the #pragma preprocessor directive can be used to disable this: #pragma SWIG nowarn=302 #pragma SWIG nowarn=302,305 Note: Since SWIG is a multi-pass compiler, this pragma should only be used to change global settings of the warning filter. It should not be used to selectively enable/disable warnings in an interface file. The handling of #pragma occurs in the C++ preprocoessor and affects all subsequent stages of compilation. The -Wall option turns on all warnings and overrides any filters that might have been set. Warnings can be issued from an interface using %warn. For example: %warn "110:%section is deprecated" The first part of a warning message is an optional warning number. A complete set of warning numbers is found in Source/Include/swigwarn.h. *** NEW FEATURE *** 05/07/2002: beazley Internal parsing change. Directives to include files now use brackets [ ... ] instead of { ... }. %includefile "foo.i" [ ... ] The use of { ... } was a bad choice because they were included implicitly by the preprocessor and made it impossible to properly detect legitimate missing '}' errors. 04/16/2002- 05/02/2002: beazley SWIG European Tour: Paris-Amsterdam-Bath. 04/23/2002: beazley The %addmethods directive has been renamed to %extend. For example: class Foo { ... }; %extend Foo { int blah() { ... }; int bar() { ... }; ... }; Motivation: the %addmethods directive can be used for many other tasks including adding synthesized attributes, constructors, and typemaps. Because of this, "addmethods" is somewhat misleading. %extend more precisely describes this operation---extension of a class or structure. *** POTENTIAL INCOMPATIBILITY *** %addmethods still works via a macro definition. However, a warning message may be generated. Errors involving %addmethods will actually refer to the %extend directive. 04/23/2002: beazley Further refinement of the type system. Typedef now propagates through functions, pointers to functions, and pointers to member functions. For example: typedef int Integer; void foo(int (*x)(int), Integer (*y)(Integer)); In this case, arguments 'x' and 'y' have exactly the same type (and would obviously accept objects of either type). Similarly, consider this: class Foo { }; typedef Foo Bar; void bar(int (Foo::*x)(int), int (Bar::*y)(int)); In this case, arguments x and y are the same type (via typedef). 04/22/2002: beazley SWIG now generates a warning message if any part of an expression involves values from a private part of a class. For example: class Foo { private: static int X; public: void blah(int a, int b = X); // Warning }; In this case, the default argument is ignored. There are workarounds, but they are rather clumsy. For instance, you might do this: %feature("action") blah(int,int) { if ($nargs == 1) { result = blah(arg1); } else { result = blah(arg1,arg2); } } void blah(int a, int b = 0); 04/21/2002: beazley Use of the %inline directive inside a namespace is forbidden and now generates an error message. This is not allowed since the inlined code that is emitted is not placed inside a namespace. This confuses other stages of parsing. 04/21/2002: beazley Some bug fixes to casting operations and expression parsing. Due to some parsing issues, it is not currently possible to use casts for all possible datatypes. However, the common cases work. 04/20/2002: beazley (Amsterdam) Member templates now work. Simply use the %template directive inside a class or %addmethods to create instantiations (see Doc/Manual/SWIGPlus.html). Supporting this was easy---earlier changes to templates made it possible using only a two-line modification to the parser and a few minor modifications elsewhere. Hmmm, come to think of it, the smoke was rather thick in that Internet "cafe". *** NEW FEATURE *** 04/19/2002: beazley (TGV) Improved handling of non-type template parameters. For example: vector; Simple numbers and strings can be used with the %template directive as well. For example: %template(vecint100) vector; Note: Arithmetic expressions are not currently allowed. Default template arguments now work and do not have to be given to %template. 04/18/2002: beazley (Paris) Change in internal template handling. Template parameters are now fully integrated into the type system and are aware of typedefs, etc. This builds upon the change below. *** DEVELOPER WARNING *** Word of caution to language module writers. The "name" parameter of certain parse tree nodes (classes, functions, etc.) may be parameterized with types. This parameterization is done using SWIG type-strings and not the underlying C version. For example, int max(int *,int *) has a name of "max<(p.int)>". If you use the name directly, you may get syntax errors in the generated code. To fix this, use SwigType_namestr(name) to convert a parameterized name to a C name with valid syntax. The internal version is used to reduce template types to a common representation and to handle issues of typedef. 04/16/2002: beazley (somewhere over the Atlantic) Enhancement of typedef resolution. The type system is now aware of template arguments and typedef. For example: typedef int Integer; foo(vector *x, vector *y); In this case, vector and vector are the same type. There is some interaction between this mechanism and the implementation of typemaps. For example, a typemap defined for vector * would apply to either type. However, a typemap for vector * would only apply to that type. Typedefs and typemaps and matched by left-most expansion. For example: vector --> vector --> vector 04/24/2002: cheetah (William Fulton) [Java] Changes to Java shadow classes. Overcomes a bug where the module assumed that a pointer to a derived class could be used in place of a pointer to a base class. Thanks to Stephen McCaul for analysing the bug and submitting patches. A consequence is that the getCPtr() method in each shadow class has disappeared and has been replaced with a getCPtrXXX(), where XXX is the shadow class name. If you have code that previously used getCPtr(), and the associated class is wrapping a C struct or a C++ class that is not involved in an inheritance chain, just use the new method. If however, the class is involved in an inheritance chain, you'll have to choose which pointer you really want. Backwards compatibility has been broken as not using the correct pointer can lead to weird bugs through ill-defined behaviour. If you are sure you want the old methods, you could add them back into all shadow classes by adding this at the beginning of your interface file: %pragma(java) allshadowcode=%{ public long getCPtr(){ return swigCPtr; } %} Please see entry dated 07/23/2002 to see how to do this after the deprecation of the allshadowcode pragma. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 04/13/2002: beazley Fixed problem with default arguments and references. Declarations such as this should now work: void foo(const string &x = "Hello"); 04/12/2002: beazley Added typemap $* substitutions for typemaps involving arrays. Requested by William Fulton. 04/11/2002: beazley Template specialization is now supported. For example: template<> class vector { ... }; When the %template directive is used, it will use a specialization if one is defined. There are still some limitations. Partial specialization is not supported. A template of type does not match all pointers. *** NEW FEATURE *** 04/11/2002: beazley Major change to template wrapping internals. Template declarations are no longer processed as macros but now result in real parse-tree nodes. The %template directive expands these nodes into a specific instantiation. This change enables a number of new and interesting capabilities: Directives such as %rename, %feature, and %addmethods can now be applied to uninstantiated templates. For example: %rename(barsize) vector::bar(char *buf, int len); ... template class vector { public: ... void bar(char *buf); void bar(char *buf, int len); // Renamed ... }; %template(intvector) vector; // Renaming carries through By parsing templates into an internal data structure, it will be possible to support specialization (and maybe partial specialization). This is highly experimental and a work in progress. *** POTENTIAL INCOMPATIBILITY *** In SWIG-1.3.11, template declarations were simply processed as weird macros. No other information was retained. This made it impossible to support more advanced features and complicated many other parts of the implementation. 04/09/2002: beazley Change to template class wrapping. There were a variety of "issues" with the old approach related to parsing, the type system, and namespaces. These changes are meant to rectify some of these problems: A specific instantiation of a template can now be specified by including the class inline like this: class vector { public: vector(); ~vector(); ... whatever ... }; This is template specialization, but partial specialization is not yet implemented. The %template directive has been modified to expand roughly as follows: %template(vecint) vector; becomes %rename(vecint> vector; class vector { public: vector(); ... }; Note that this simply builds upon the code above (templates included inline). This modified approach to wrapping fixes some subtle type issues. For instance, you can now define typemaps and typedefs like this: %typemap(in) vector * { ... } typedef vector intvector; ... void blah(intvector *v); // Gets the above typemap This did not work in SWIG-1.3.11 due to a peculiarity of the template implementation. %template(name) no longer installs the template as a class with name "name". This might break %addmethods as described in the manual. For example: %template(vecint) vector; %addmethods vecint { // Fails. vecint not a class ... }; To fix this, just use the template name instead: %addmethods vector { ... } Note: This technique might be a way to implement some bizarre template specialization techniques. For example: %addmethods vector { // Only applied if vector instantiated later %typemap(in) vector * { ... } ... }; *** POTENTIAL INCOMPATIBILITY *** 04/08/2002: beazley Fixed [ 540868 ] #if defined whatever - not parsed. SWIG should now correctly handle preprocessor directives like this: #if defined __cplusplus ... #endif Note: was implemented previously, but there was a minor bug. Reported by Adam Hupp. 04/07/2002: beazley %readonly and %readwrite are deprecated due to a change in the implementation. Instead of being pragmas, mutability is now controlled as a "feature" using the following two directives: %immutable; int x; // read-only variable int y; // read-only variable %mutable; int z; // Modifiable %immutable and %mutable are much more powerful than their older counterparts. They can now pinpoint a specific declaration like this: %immutable x; /* Any x */ %immutable Foo::x; /* x in class Foo */ In fact, the matching algorithm is the same as for %rename, %ignore, and other directives. This means that the declaration %immutable Foo::x; would not only apply to class Foo but to all derived classes as well. *** POTENTIAL INCOMPATIBILITY *** %immutable and %mutable must be terminated by a semi-colon. This differs slightly from the older %readonly and %readwrite directives. Since %immutable and %mutable can be applied to declarations the semicolon is needed to distinguish between a global feature and one targeted to a single declaration. Note: this incompatibility is the primary reason for changing the name of the directive. 04/07/2002: beazley New handling of copy constructors. If a class defines constructors like this: class Foo { public: Foo(); Foo(const Foo &); // Copy constructor ... }; SWIG now generates a function copy_Foo() for the copy constructor. In previous verions, this generated a name-clash and an error message. To preserve backwards compatibility, SWIG does not change the behavior if %rename is used to resolve the name conflict. However, if no name resolution is made, this new approach is used. Copy constructors may be handled as a special case in the target language. However, this is up to the language module itself. 04/07/2002: beazley The %template directive is now namespace aware. This allows code like this: namespace foo { template max(T a, T b) { return a > b ? a : b; } } using namespace foo; %template(maxint) max; // Ok namespace bar { using foo::max; %template(maxdouble) max; // Ok } Caveat: the template name supplied to %template must be defined in the same scope in which the %template directive appears. This code is illegal: %template(maxint) foo::max; 04/07/2002: beazley Minor enhancement to preprocessor. The preprocessor can now perform string comparison. For example: #define A "hello" ... #if A == "hello" ... #endif The primary use of this is in SWIG macros. For example: %define FOO(x) #if #x == "int" /* Special handling for int */ ... #endif %enddef Normal users can probably safely ignore this feature. However, it may be used in parts of the SWIG library. 04/07/2002: beazley Further refinement of default constructor/destructor wrapper generation. SWIG is now much more aware of pure virtual methods. For instance: class A { /* Abstract */ public: virtual void method1() = 0; virtual void method2() = 0; }; class B : public A { /* Abstract */ public: virtual void method1() { }; }; class C : public B { /* Ok */ public: virtual void method2() { }; }; In this case, SWIG will only generate default constructors for C. Even though B looks fine, it's missing a required method and is abstract. 04/04/2002: beazley Subtle change to structure data member access. If you have a structure like this: struct Foo { Bar b; }; The accessor functions for b are generated as follows: (1) If b is *not* defined as a structure or class: Bar Foo_b_get(Foo *self) { return self->b; } void Foo_b_set(Foo *self, Bar value) { self->b = value; } (2) If b *is* defined as a structure or class: Bar *Foo_b_get(Foo *self) { return &self->b; } void Foo_b_set(Foo *self, Bar *value) { self->b = *value; } See the "Structure data members" section of Doc/Manual/SWIG.html for further details. *** POTENTIAL INCOMPATIBILITY *** This may break interfaces that relied on a lot of a undeclared structure and class names. To get the old behavior, simply use a forward declaration such as "struct Bar;" 04/04/2002: beazley C++ namespace support added. SWIG supports all aspects of namespaces including namespace, using, and namespace alias declarations. The default behavior of SWIG is to flatten namespaces in the target language. However, namespaces are fully supported at the C++ level and in the type system. See Doc/Manual/SWIGPlus.html for details on the implementation. 04/02/2002: cheetah (William Fulton) [Java] Sun has modified javac in jdk1.4 to no longer compile an import of an unnamed namespace. To fix this SWIG no longer generates the import for packageless classes. http://developer.java.sun.com/developer/bugParade/bugs/4361575.html As reported SF #538415. 03/27/2002: ljohnson (Lyle Johnson) [Ruby] Added support for pointer-to-member, similar to that for the Python module. Remarkably similar. Also added a new example for this (Examples/ruby/mpointer), which is remarkably similar to the Python example of the same name. 03/26/2002: ljohnson (Lyle Johnson) [Ruby] Made a few minor edits to the "Advanced Topics" chapter of the SWIG manual and added a new major section about how to create multi-module Ruby packages with SWIG. 03/26/2002: ljohnson (Lyle Johnson) [Ruby] Removed all of the old Ruby pragmas. If any of this functionality is truly missed we can resurrect it, preferably with some kind of feature-based directive. 03/25/2002: ljohnson (Lyle Johnson) [Ruby] Fixed SWIG exception library support for Ruby, which has apparently been broken for some time. Luckily, no one seems to have noticed. 03/23/2002: beazley C++-namespace support in SWIG directives. %addmethods: The %addmethods directive now accepts a fully qualified classname and can be used inside C++ namespace declarations. For example: // Attaches to the class Foo::Bar below %addmethods Foo::Bar { int somemethod() { ... } }; namespace Foo { class Bar { public: ... }; // Attaches to the class Bar above %addmethods Bar { int othermethod() { ... }; } } %feature, %rename, %ignore, %exception, and related directives: Namespaces are fully integrated into the renaming and declaration matcher. For example: %rename(display) Foo::print; // Rename in namespace Foo %ignore Foo::Bar::blah; // Ignore a declaration %rename directives can be placed inside namespace blocks as well. For example: namespace Foo { %rename(display) print; // Applies to print below void print(); }; Most other SWIG directives should work properly inside namespaces. No other changes are needed. 03/22/2002: beazley Some changes to internal symbol table handling. SWIG no longer manages structures and unions in a separate namespace than normal declarations like ANSI C. This means you can't have a structure with the same name as a function. For example: struct Foo { ... } int Foo() { ... } This approach is more like C++. It's not clear that SWIG ever really supported the ANSI C anyways---using the same name would almost certainly generate a name-clash in the target language. 03/22/2002: ljohnson (Lyle Johnson) [Ruby] Fixed [ 517302 ] for handling of renamed overloaded constructors. Now, renamed overloaded constructors are converted into class singleton methods (basically acting as "factory" methods). 03/21/2002: beazley Fixed [ 532957 ] %ignore parse error and casting operator. Reported by William Fulton. 03/18/2002: beazley (** ADVANCED USERS ONLY **) Added support for dynamic casting in return values. A somewhat common problem in certain C++ programs is functions that hide the identity of underlying objects when they are returned from methods and functions. For example, a program might include some generic method like this: Node *getNode(); However, Node * may just be base class to a whole hierarchy of different objects. Instead of returning this generic Node *, it might be nice to automatically downcast the object into the appropriate type using some kind dynamic cast. Assuming you understand the peril involved, a downcast can now be performed using the following function in the run-time type checker: swig_type_info *SWIG_TypeDynamicCast(swig_type_info *, void **ptr); This function checks to see if the type can be converted to another type. If so, a different type descriptor (for the converted type) is returned. This type descriptor would then be used to create a pointer in the target language. To use this, you would write a typemap similar to this: %typemap(out) Node * { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); $result = SWIG_NewPointerObj($1, ty); } Alternatively, %typemap(out) Node * = SWIGTYPE *DYNAMIC; To make the typemap have any effect, you have to write a supporting function that knows how to perform downcasting. For example: %{ static swig_type_info * Node_dynamic_cast(void **ptr) { Node **nptr = (Node **) ptr; Element *e = dynamic_cast(*nptr); if (e) { *ptr = (void *) e; return SWIGTYPE_p_Element; } Data *d = dynamic_cast(*nptr); if (d) { *ptr = (void *) d; return SWIGTYPE_p_Data; } return 0; } %} There is no restriction on how types are determined. dynamic_cast<> uses C++ RTTI. However, if you had some other mechanism for determining the type, you could use that here. Note: it is important to save the new pointer value back into the argument as shown. When downcasting, the value of the pointer could change. Finally, to make the casting function available, you have to register it with the run-time type checker. Put this macro in your interface file. DYNAMIC_CAST(SWIGTYPE_p_Node, Node_dynamic_cast); Note: this feature does not introduce a performance penalty on normal SWIG operation. The feature is only enabled by writing a new typemap that explicitly calls SWIG_TypeDynamicCast() to make a conversion. Examples/test-suite/dynamic_cast.i contains a simple example. This feature is not supported in the Java module due to differences in the type-checking implementation. *** EXPERIMENTAL FEATURE *** 03/17/2002: beazley Small change to type-name handling of unnamed structures and typedef. If a structure of this form appears: typedef struct { ... } Foo; Then 'Foo' is used as the proper typename for the structure. Furthermore, Foo can now be used as a name in C++ inheritance. SWIG was already kind of doing this, but this modification refines the implementation to more closely follow the C++ ARM, section 7.1.3, p. 106. This fixes a couple of obscure corner cases. 03/16/2002: beazley Modified C++ inheritance with a few enhancements. First, type information needed for casting and type-equivalence is generated even when base-classes aren't defined in the interface. For example: class Foo : public Bar { /* Bar unspecified */ public: ... }; void blah(Bar *b); In this case, the blah() function still accepts Foo * even though nothing is really known about Bar. Previous SWIG versions would just generate a type error. Inheritance has also been modified to work through typedef. For example: class Bar { }; typedef Bar OtherBar; class Foo: public OtherBar { } In this case, the base class of OtherBar is correctly resolved back to Bar. The use of the name OtherBar is lost in this resolution (the wrappers will simply use Bar instead of the typedef name OtherBar). 03/13/2002: beazley %typemap, %apply, and related directives can now appear inside class definitions. 03/13/2002: beazley Fixed a variety of problems related to compiling SWIG on 64-bit platforms. 03/12/2002: beazley Fixed problem with "ignore" and "in" typemaps. Local variables associated with "in" were being added to the wrapper function even though they were never used. Mostly harmless, but it would lead to a variety of compilation warnings. 03/12/2002: beazley Some changes to the internal type system and handling of nested C++ types. In previous versions of SWIG, if you had the following: class Foo { public: typedef int Blah; }; class Bar : public Foo { public: void somemethod(Blah x); }; The argument type in somemethod() would implicitly be set to Bar::Blah. Although this is technically allowed, it breaks typemaps. For example: %typemap(in) Foo::Blah { ... } doesn't match like you expect. This has been changed in SWIG-1.3.12. Now, types are expanded using the class in which they were defined. So, the argument type in somemethod() will be Foo::Blah---since the type Blah was defined in Foo. 03/10/2002: beazley Fixed some subtle type scoping problems with typedef and C++ classes. For example: typedef int Blah; class Bar { public: typedef double Blah; void foo(Blah x, ::Blah y); ... } 03/10/2002: beazley Highly experimental change to handle variable length arguments. First, there is no portable or reliable way to wrap a varargs function in full generality. However, you *can* change the function signature using %varargs. %varargs(char *) fprintf; ... void fprintf(FILE *f, char *fmt, ...); In this case, the variable length parameter "..." is simply replaced by the parameters given in %varargs. This results in a function like this: void fprintf(FILE *f, char *fmt, char *s); More than one argument can be used and default values can be defined. For example, this code specifies a maximum of four arguments. %varargs(char *x1 = 0, char *x2 = 0, char *x3 = 0, char *x4 = 0) fprintf; *** EXPERIMENTAL NEW FEATURE *** 03/10/2002: beazley Change to handling of variable length arguments. varargs is now handled as a proper parameter and is passed to the code generator. However, it still can't be handled correctly (and will generate a typemap warning). This change has been made to better incorporate variable length arguments with other directives such as %ignore, %rename, %feature, and so forth. 03/10/2002: beazley Fixed [ 522555 ] Syntax error parsing "define" construct. SWIG is a little more restrictive in determining #define statements that will be wrapped as constants. Also added a better parser error rule for handling bad constants. 03/08/2002: cheetah (William Fulton) [Java] Bug fix: Classes renamed with %rename that are derived from another class generate more appropriate shadow class code. 03/08/2002: cheetah (William Fulton) [Java] Fixed SF [ #523632 ] and [ #513335 ] both reported by Israel Tanner. Support for types that are used which are in a typedef. The appropriate shadow class name is generated. Also generated correct shadow classname when a templated class is used within another templated class. See the cpp_typedef.i testcase. 03/08/2002: cheetah (William Fulton) [Java] Bug fix: No type was generated in shadow classes for types that weren't wrapped by SWIG. The type is treated as a raw pointer, ie no shadow class. 02/22/2002: beazley Refined the matching algorithm used by %rename, %ignore, and %feature. If a type signature is supplied, it must exactly match that used in the declaration---including any use of const. For example: %rename(foo1) foo(int); %rename(bar1) bar(int) const; class Blah { public: void foo(int); // Matched --> foo1 void foo(int) const; // Not matched void bar(int); // Not matched void bar(int) const; // Matched --> bar1 } In previous versions, a non-const specification would match both the non-const and const declarations. However, the whole point of %rename and related directives is that they be able to precisely pinpoint exact declarations in an interface. This fixes the problem. 02/21/2002: beazley Reworked the handling of default constructor and destructors. SWIG now makes a preliminary pass over the parse tree to discover which classes support default allocation. This fixes a number of very subtle issues in code generation and call/return by value. 02/18/2002: cheetah (William Fulton) Improved support on Cygwin: Perl, Python, Tcl, Ruby and Java should work out of the box, barring the runtime library. Removed dllwrap and replaced with newly working gcc -shared instead for Cygwin. All this will require the new improved binutils 20010802 and later, but the latest Cygwin is usually the best recommendation. 02/15/2002: beazley Fixed some problems related to wrapping of global variables and Perl shadow classes. Reported by Chia-liang Kao. 02/15/2002: ljohnson (Lyle Johnson) [Ruby] Made a fix to the code generation for C++ class constructors so that we get both a "new" singleton method and an "initialize" instance method for each class. This change enables developers to derive new Ruby classes from SWIG-wrapped C++ classes and then override their initialize methods to provide subclass-specific instance initialization. 02/15/2002: ljohnson (Lyle Johnson) [Ruby] Massive documentation update for the Ruby module, contributed by Craig Files. 02/14/2002: ljohnson (Lyle Johnson) [Ruby] Bug fix: An error in the SWIG runtime support for Ruby was causing several of the examples to fail. Reported by William Fulton. 02/14/2002: ljohnson (Lyle Johnson) [Ruby] Bug fix: Enumerations defined within a class (such as those seen in the Examples/ruby/enum example) were not being exported with the correct names. Reported by William Fulton. 02/13/2002: ljohnson (Lyle Johnson) [Ruby] Added a warning message when we run across overloaded class constructors for C++ code, that this is currently not supported (even if the overloads have been %renamed). For an example of where this doesn't work, see Examples/ruby/operator. 02/13/2002: ljohnson (Lyle Johnson) [Ruby] Added an "ignored" warning message when the parser runs across an operator!=() declaration for C++ code. 02/11/2002: ljohnson (Lyle Johnson) [Ruby] Added the "import", "import_template", "operator" and "template" examples. 02/11/2002: ljohnson (Lyle Johnson) [Ruby] Added multi-module support. 02/09/2002: ljohnson (Lyle Johnson) [Ruby] Added the missing "#define SWIG_NOINCLUDE" at the top of the wrapper code when the '-c' option is used. 02/09/2002: ljohnson (Lyle Johnson) Corrected a minor off-by-one error for the size of the swig_types[] array that's generated in the wrapper code. 02/08/2002: beazley Fixed SF [ #515058 ] Wrong code for C++ templates. Reported by Israel Taller. Version 1.3.11 (January 31, 2002) ================================= 01/30/2002: beazley Fix to pass/return by value for C++ objects that define no default constructor. Changes to the typemap system made it impossible to wrap C++ objects with no default constructor. This has been fixed, but the solution involves some clever template magic contributed by William Fulton. Please see the comments in the file Lib/swig.swg for further details. This solution is experimental and may be refined in a future release. 01/30/2002: beazley Global variables and member data of type "const char *" can be set, but the old value is silently discarded without any garbage collection. This may generate a memory leak. This change is needed to more safely handle variables like this: const char *foo = "Hello World\n"; In this case, it's not safe to free the old value. However, SWIG can dynamically allocate a new value and make foo point to it. To fix this memory leak, you can probably do this: %clear const char *foo; %apply char * {const char *foo}; *** POTENTIAL INCOMPATIBILITY *** 01/30/2002: beazley Two minor typemap enhancements have been added. First, typemaps can issue a warning message by including a special warning attribute. For example: %typemap(in,warning="I'm going to do something dangerous") ... The warning message will show up whenever the typemap is applied. Second, a typemap can force a no-match by defining %typemap(in) sometype "pass"; If this is used, the typemap system will *not* record a typemap match for "sometype". This can be used to block selected typemaps. For example, if you wanted to disable a typemap feature for some type, you could do this. // Do not allow global variables of type 'const char *' to be set. %typemap(varin) const char * "pass"; It might also be possible to use this to do subtle and strange things with typemaps. For example, if you wanted to make 'blah *' an output value and 'const blah *' an input parameter, you might do this: %typemap(ignore) blah *(blah temp) { $1 = &temp; } %typemap(argout) blah * { ... return a value ... } /* Block unqualified typemaps defined above */ %typemap(ignore) const blah * "pass"; %typemap(argout) const blah * "pass"; %typemap(in) const blah * { ... get input value ... } (This potential applications of typemaps suggested by Greg Stein). *** NEW FEATURE *** 01/29/2002: cheetah (william fulton) [Java] Bug fix: No enumerations were wrapped when the -shadow commandline option was not specified. Reported by Israel Taller. 01/28/2002: cheetah (william fulton) [Java] Global arrays are successfully wrapped. In fact they started mostly working in SWIG-1.3.10. 01/28/2002:richardp Added first attempt at C++ and -shadow support for PHP4 module, please test and mail me if any problems/ideas on improving it. There is a known problem with uninitialized member variables, please see Examples/php4/sync/README for details. Also more PHP documentation added to Doc/Manual/Php.html 01/27/2002:beazley The ANSI C size_t type is now recognized as an integer by default. 01/26/2002:beazley long long and unsigned long long support added to many language modules. This is not a portable feature and will require compiler support for the long long type. In target languages that do not support long long (e.g., Tcl and Perl), numbers are converted to a string of digits. This prevents their use in arithmetic calculations, but still allows values to be set from a string. long long support requires the use of the strtoll() and strtoull() functions as well as the 'lld' and 'llu' format specifiers of sprintf(). 01/26/2002:beazley Fixed [ #501827 ] Delete method is not called. The Tcl module wasn't correctly calling destructors when they were defined using %addmethods. This has been fixed. Reported by Reinhard Fobbe. 01/26/2002: beazley Better support for long long and unsigned long long. Typemaps have been included in a number of modules for handling these types. In addition, the parser has been modified to accept long long literals such as 1234LL and 1234ULL. 01/27/2002: cheetah (william fulton) [Java] A C char[] is mapped to a Java String which is the default SWIG handling of char[] and char*. It used to be mapped to byte[]. Note that a C signed char[] array is mapped to byte[]. *** POTENTIAL INCOMPATIBILITY *** 01/25/2002: beazley Fixed a problem with return-by-value, C++, and objects that define no default constructor. Reported by Joel Reed. 01/25/2002: cheetah (william fulton) [Java] Overhaul of the Java module. The C code generation is now done from typemaps. 01/24/2002: cheetah (william fulton) [Java] Support for arrays of enum pointers 01/20/2002: cheetah (william fulton) [Java] Error checking for null Java objects being passed to native functions. Exception thrown now whereas before the JVM crashed. 01/18/2002: cheetah (william fulton) [Java] Corrected behaviour for functions that take arrays. For example, when this c function: void arrayfn(int array[]); is wrapped the corresponding native function public final static native void arrayfn(int[] array); is produced. Previously if the C function made any changes to the array elements, these were not reflected back into the Java array. This has now been corrected so that the changes are propogated back to Java and the calling function will see these changes. This is how pure Java functions work, ie arrays are passed by reference. 01/15/2002:mkoeppe [Guile] New file cplusplus.i with C++ typemaps contributed by Marcio Luis Teixeira . 01/11/2002: cheetah (william fulton) [Java] Changed mapping of C long to Java type. Was mapped to Java long, now mapped to Java int. If you want the previous mapping to Java long use this approach in your interface file: %clear long; %typemap(jni) long "jlong" %typemap(jtype) long "long" %typemap(jstype) long "long" %clear long[ANY]; %typemap(jni) long[ANY] "jlongArray" %typemap(jtype) long[ANY] "long[]" %typemap(jstype) long[ANY] "long[]" %typemap(in) long[ANY] {write me for array support} %typemap(out) long[ANY] {write me for array support} %typemap(argout) long[ANY] {write me for array support} %typemap(freearg) long[ANY] {write me for array support} *** POTENTIAL INCOMPATIBILITY *** This new mapping is more appropriate when interfacing to 32 bit applications which are used in the current 32-bit JVMs. For future 64-bit JVMs you may have to change these mappings - eg on Unix LP64 systems, but not on Microsoft 64bit Windows which will be using a P64 IL32 model. This may be automated in a future version of SWIG. 01/10/2002:beazley Fixed [ 501677 ] %init block in wrong place. Reported by Luigi Ballabio. 01/09/2002: cheetah (william fulton) [Java] Default support for the long long type. signed long long is mapped to a Java long. unsigned long long is mapped to BigInteger. 01/09/2002:beazley Experimental change to parser to better support mixing of int, long, short, unsigned, float, and double. The parser should now support types like this: short unsigned int int unsigned short unsigned short int unsigned int short This change also enables a type of 'long double' (previously unsupported) to be used. *** NEW FEATURE *** 01/05/2002: cheetah (william fulton) [Java] Casting fix for when function return type is a pointer as reported by Gary Pennington 2002-01-05. The upper 32bits of the 64 bit jlong will have contained junk for 32bit pointers. 01/05/2002: cheetah (william fulton) [Java] Better pointer handling in Java is possible as the INPUT, OUTPUT and INOUT typemaps have been added into typemaps.i. 01/05/2002: cheetah (william fulton) [Java] $null can be used in input typemaps to return early from JNI functions that have either void or a non-void return type. Example: %typemap(check) int * %{ if (error) { SWIG_exception(SWIG_IndexError, "Array element error"); return $null; } %} If the typemap gets put into a function with void as return, $null will expand to nothing: void jni_fn(...) { if (error) { SWIG_exception(SWIG_IndexError, "Array element error"); return ; } ... } otherwise $null expands to zero, where javareturntype is either a pointer or a primitive type: javareturntype jni_fn(...) { if (error) { SWIG_exception(SWIG_IndexError, "Array element error"); return 0; } ... } 01/02/2002: cheetah (william fulton) [Java] The Java module incorrectly used argout typemaps for strings. This is now corrected and the code now resides in the freearg typemap. The argout array typemaps have been split into argout and freearg typemaps. This correction may require some user written typemaps to be modified. *** POTENTIAL INCOMPATIBILITY *** 12/28/2001: cheetah (william fulton) [Java] Multi typemaps now working for Java see multimap example. [Java] Fix for recently introduced bug - freearg typemap code was appearing before the function call. 12/28/2001: cheetah (william fulton) [Java] JCALL macro for JNI calls that work in both C and C++ typemaps have been replaced with JCALL0, JCALL1, JCALL2, JCALL3 and JCALL4 macros. *** POTENTIAL INCOMPATIBILITY *** 12/22/2001:beazley Resolved some inconsistent behavior with %rename and class renaming. If you specify the following: %rename(Foo) Bar; class Bar { public: Bar(); ~Bar(); } Then the %rename directive applies to the class itself, the constructor, and the destructor (all will be renamed to Foo). If a class defines more than one constructor, the overloaded variants can still be renamed by specifying parameters to %rename. For example: %rename(Bar_copy) Bar(Bar &); class Bar { public: Bar(); Bar(Bar &); ~Bar(); }; There are still some odd corner cases. If you specify %rename(Foo) ::Bar; then only the name of the class is changed and the constructor/destructor names are left unmodified. If you specify %rename(Foo) *::Bar; then the names of the constructor/destructor functions are modified but the name of the class is not. 12/21/2001: cheetah (william fulton) [Java] jni, jtype and jstype typemaps no longer hardcoded but real typemaps. New variable substitution, $javaclassname, can be used in the jstype typemaps. It is replaced with the Java shadow class name where applicable. [Java] Fix for recently introduced bug to do with inheritance when using %import. [Java] A few more bug fixes, todo with %rename and using the kind with the type, eg void fn(union uni myuni, struct str mystr, class cl mycl); 12/20/2001:beazley Fixed [ #494524 ] Preprocessor bug - apostrophe and #subst. 12/20/2001:beazley Added SWIG_VERSION preprocessor symbol. This is a hexadecimal integer such as 0x010311 (corresponding to SWIG-1.3.11). This can be used in the interface as follows: #if SWIG_VERSION >= 0x010311 /* Use some fancy new feature */ #endif Note: The version symbol is not defined in the generated SWIG wrapper file. *** NEW FEATURE *** 12/20/2001:mkoeppe [MzScheme]: Renamed mzswig_make_boolean to swig_make_boolean, as the latter is used in the typemaps. Reported by Luigi Ballabio. 12/17/2001:mkoeppe [Guile]: Rewrote list-vector.i using multi-dispatch typemaps. Updated pointer-in-out.i. Make the deprecated typemap-substitution of "$source" in "argout" work as before. 12/16/2001:mkoeppe [Guile]: Fixed macros %values_as_list, %values_as_vector, %multiple_values to use the proper %pragma syntax. New Guile example/test "multivalue"; new Guile run-test for test-suite item "list-vector" (currently broken). 12/14/2001:mkoeppe [Guile]: Fixed typemap-substition bug for "varin". Relaxed valid-identifier check to allow all R5RS identifiers. Version 1.3.10 (December 10, 2001) ================================== 12/08/2001:beazley Modified %typemap so that %{ ... %} can also be used as a code block (mostly for completeness). For example: %typemap(in) blah %{ ... %} This form does not introduce a new block scope. Also, the code enclosed in %{ ... %} is not processed by the preprocessor. 12/08/2001:beazley Fixed [ #459614 ] SWIG with multiple TCL interpreters. 12/08/2001:beazley Fixed [ #417141 ] rubydec.swg is wrong Reported by Paul Brannan. 12/08/2001:beazley Fixed [ #410557 ] Problem with %addmethods on NT. Reported by Magnus Ljung. 12/08/2001:beazley Fixed [ #445233 ] Enhancement: handle access change. SWIG now parses (but ignores) C++ access changes for the the following: class A { protected: void something() { } public: A() {} }; class B : private A { public: B() : A() { } protected: A::something; <---- Parsed, but ignored }; Suggested by Krzysztof Kozminski. 12/08/2001: cheetah (william fulton) Fix for Ruby to work using Visual C++. 12/06/2001:beazley Fixed [ #465687 ] unsigned short parameters fail. Reported by Gerald Williams. 12/06/2001:beazley Fixed SF [ #489594 ] PyString_FromString can't take NULL arg. Reported by John Merritt. SWIG now converts string values to Python using code like this: resultobj = result ? PyString_FromString(result) : Py_BuildValue(""); 12/06/2001:beazley Fixed SF [ #463561 ] Type conversions not generated. Reported by Gerald Williams. 12/04/2001:beazley Fixed SF [ #470217 ] Tcl default argument handling. Reported by Shaun Lowry. 12/04/2001:beazley Fixed SF [ #472088 ] defined(MACRO) expanded everywhere. Embedded preprocessor directives such as %#if defined(FOO) are not expanded by the SWIG preprocessor. Reported by Gerald Williams. 12/04/2001:beazley Fixed SF [ #476467 ] Problems with #define & commas. 12/04/2001:beazley Fixed SF [ #477547 ] wrong declaration of pointer functions. Bad prototypes in Lib/tcl/ptrlang.i. 12/04/2001:beazley Fixed SF [ #483182 ] Constants can take args by mistake. When swig -perl5 -const is used, constants are declared with a void prototype. For example: sub ICONST () { $examplec::ICONST } Patch submitted by Rich Wales. 12/03/2001:beazley New %exception directive. This is intended to replace %except. It works in exactly the same manner except it does not accept a language specifier. For example: %exception { try { $action } catch(SomeError) { error } } %exception is also name aware---allowing it to be applied to specific declarations in an interface. For example: %exception foo { ... exception for any function/method foo ... } %exception Foo::bar { ... exception for method bar in class Foo ... } %exception Foo::bar(double) { ... exception for method bar(double) in class Foo ... } The semantics of this name matching is exactly the same as for %rename. *** NEW FEATURE *** 12/03/2001:beazley Substantial cleanup of the Python shadow class code. Shadow classes used to be created in this rather complicated manner involving about a half-dozen strings created in bits and pieces. Shadow classes are now generated in a more straightforward manner--in the same order that appears in the interface file. *** POTENTIAL INCOMPATIBILITY *** The order in which declarations appear in the shadow file may differ. 12/03/2001:beazley The %insert directive (%{ ... %}, %runtime, %header, %wrapper, etc.) can now be used inside of a class definition. This has potential uses when generating shadow class code. For example: class Foo { ... %insert("shadow") %{ # Some python code def blah(self): print "I'm blah!" %} ... }; The support for class code insertion depends on the language module. However, the intent of this feature is to simplify the task of extending shadow class code. In the Python module, this inserts code with the proper level of indendation (regardless of what was used in the SWIG interface). *** NEW FEATURE *** 11/29/2001: cheetah (william fulton) Modifications for Java and Python modules to work on cygwin. Unfortunately a lot of the python module has started to produces code which cannot be auto-imported using cygwin libtools so most of it is still broken. 11/28/2001:beazley The %rename and %feature directive can now be used inside of a class definition. For example: class Foo { %rename(foo_i) foo(int); %rename(foo_d) foo(double); public: ... void foo(int); void foo(double); ... }; When used in this manner, the %rename directive only applies to members of the class in which it appears as well as all derived classes. In fact, this is really just the same as saying: %rename(foo_i) Foo::foo(int); %rename(foo_d) Foo::foo(double); class Foo { ... }; *** NEW FEATURE *** 11/26/2001:beazley Added the experimental %feature directive. %feature can be used to attach arbitrary string attributes to parse tree nodes. For example: %feature("except") blah { try { $function } catch (Error) { whatever; } } or %feature("set") *::x_set "x"; or %feature("blah") Foo::bar(int,double) const "spam"; The syntax is borrowed from the %rename directive. In fact, the exact same semantics apply (inheritance, matching, etc.). %feature is a very powerful low-level primitive that can be used to customize individual language modules and to provide hints to any stage of code generation. Features are attached to parse tree nodes as attributes with names like "feature:*" where * is replaced by the feature name (e.g., "feature:except", "feature:set", etc.). Language modules can then look for the features using a simple attribute lookup. %feature is intended to be a replacement for a number of older SWIG directives including %except and specialized pragmas. It is more powerful (due to its parameterized name matching) and it provides very precise control over how customization features are attached to individual declarations. There are future expansion plans that will build upon this capability as well. It's not certain that %feature will ever be used directly by SWIG users. Instead, it may be a low-level primitive that is used in high-level macro definitions. For instance, to support properties, you might define a macro like this: %define %property(name, setf, getf) %feature("set") setf #name; %feature("get") getf #name; %enddef Which allows a user to specify things like this: %property(p, get_p, set_p); class Blah { public: int get_p(); void set_p(int); }; *** EXPERIMENTAL NEW FEATURE *** 11/24/2001:beazley The Tcl module has been expanded with some new features for managing object ownership. For example: set c [Circle -args 20] $c area # Invoke a method $c -disown # Releases ownership of the object $c -acquire # Acquires ownership of the object If Tcl owns the object, its destructor is invoked when the corresponding object command is deleted in Tcl. To simplify the destruction of objects, the following syntax can be used: $c -delete # Delete an object This is an alternative for the more obscure variant of rename $c {} These features also add functionality at the C API level. The following functions manage ownership from C and can be used in typemaps. SWIG_Acquire(void *ptr); SWIG_Disown(void *ptr); A new function for constructing instances is also available: Tcl_Obj * SWIG_NewInstanceObj(Tcl_Interp *interp, void *ptr, swig_type_info *type, int own); When used in a typemap, this creates a pointer object and an interpreter command that can be used to issue methods and access attributes as shown above. *** NEW FEATURE *** 11/23/2001:beazley All Python-related %pragma operations have been eliminated. Most of these were written for older SWIG versions in order to compensate for limitations in earlier releases. In an effort to reduce the amount of code-clutter and potential for errors, it is easier to simply eliminate the pragmas and to start over (if needed). To be honest, I'm not even sure the pragmas worked in 1.3.9 and recent releases. Note: If you need to insert code into the shadow class file created by SWIG, simply use the %shadow directive like this: %shadow %{ def some_python_code(): print "blah!" %} *** POTENTIAL INCOMPATIBILITY *** 11/22/2001:beazley Sweeping changes to the way in which the Python module handles shadow classes. In early implementations, shadow classes were merely Python wrappers around typed pointer objects. However, some users actually wanted to receive the shadow class object in C. To accommodate this, the dereferencing of the "this" pointer in a shadow class was moved to C as described in CHANGES [8/8/99]. However, the process of returning pointers to Python was still somewhat problematic. Specifically, shadow classes never worked in situations such as these: - Use of any kind of output typemap ('out' or 'argout') - Global variables (broken as far as I can tell). In the past, some users have dealt with this by manually trying to create shadow class objects themselves from C/C++. However, this was difficult because the C wrappers don't really know how to get access to the corresponding Python class. The Python module has now been modified to automatically attach shadow class objects to pointers when they are returned to Python. This process occurs in the function SWIG_NewPointerObj() so the process is completely transparent to users. As a result, shadow classes are now more seamlessly integrated with typemaps and other features of SWIG. This change may introduce a number of incompatibilities. The SWIG_NewPointerObj() now takes an extra parameter "own" to indicate object ownership. This can be used to return a pointer to Python that Python should destroy. In addition, older code that tries to manually construct shadow class objects or which expects bare pointers may break---such pointers may already be encapsulated by a shadow class. *** POTENTIAL INCOMPATIBILITY *** 11/20/2001:beazley Modified the %insert directive to accept single braces { ... }. For example: %insert("header") { ... some code ... } This works exactly like %{ ... %} except that the code in the braces is processed using the preprocessor. This can be useful in certain contexts such as low-level code generation in language modules. *** NEW FEATURE *** 11/20/2001:beazley Command line options are now translated into preprocessor symbols. For example: ./swig -python -shadow -module blah interface.i Creates the symbols: SWIGOPT_PYTHON 1 SWIGOPT_SHADOW 1 SWIGOPT_MODULE blah Modules can look for these symbols to alter their code generation if needed. *** NEW FEATURE *** 11/20/2001:beazley Massive overhaul of the Perl5 module. A lot of code generation is now driven by tables and typemaps. The generated wrapper code also makes use of tables to install constants, variables, and functions instead of inlining a bunch of procedure calls. The separate variable initialization function is gone. Most code generation is controlled via the perl5.swg file in the library. *** POTENTIAL INCOMPATIBILITY *** 11/13/2001:beazley Added parsing support for the C++ typename keyword. Primarily this is added to better support templates. For example: template void blah(C& v) { typename C::iterator i = v.begin(); } Note: typename is supported in the parser in the same way as 'struct' or 'class'. You probably shouldn't use it anywhere except in templates. *** NEW FEATURE *** 11/11/2001:beazley Massive overhaul of the language module API. Most functions now use a common, very simple, API. There are also a number of interesting semantic side-effects of how code is actually generated. Details will be forthcoming in Doc/Manual/Extending.html. *** POTENTIAL INCOMPATIBILITY *** Language modules written for previous versions of SWIG will no longer work, 11/10/2001:beazley Fixed a very subtle bug due to unnamed class wrapping. For example, if you did this typedef struct { int x,y; } gdPoint, *gdPointPtr; void foo(gdPointPtr x); Then the foo function would get a type-error. The problem has to do with internal typedef handling and the fact that the typedef declarations after the struct appear later in the parse tree. It should work now. Problem reported by Vin Jovanovic. 11/09/2001:beazley Subtle change to "out" typemaps (and related variations). The name that is attached to the typemap is now the raw C identifier that appears on a declaration. This changes the behavior of member functions. For example: %typemap(out) int foo { ... } class Blah { public: int foo(); // typemap gets applied } Previous versions never really specified how this was supposed to work. In SWIG1.1, you could probably write a typemap for the wrapper name like this: %typemap(out) int Blah_foo { ... } However, this old behavior is now withdrawn and not supported. Just use the member name without any sort of special prefix. *** POTENTIAL INCOMPATIBILITY *** 11/06/2001:beazley Changes to Tcl module initialization: (1) SWIG now automatically includes the code needed to work with Tcl stubs. Simply compile with -DUSE_TCL_STUBS. (2) SWIG now automatically calls Tcl_PkgProvide to register a package name. The package name is the same as the name specified with the %module directive. The version number is set to "0.0" by default. To change the version number, use swig -pkgversion 1.2 interface.i. *** POTENTIAL INCOMPATIBILITY *** Modules that provided stubs and Tcl_PkgProvide on their own might break. Simply remove that code. 11/05/2001:beazley Changed code generation of constants in the Tcl module. Constants are now stored in a large table that get installed at module startup. There are also no longer any static variables so it should generate somewhat less code. 11/04/2001:beazley The "const" typemap has been renamed to "constant" in many language modules. "const" is a C keyword which made the handling of the typemap directive somewhat awkward in the parser. *** POTENTIAL INCOMPATIBILITY *** 11/04/2001:beazley %typemap directive can now accept nearly arbitrary keyword parameters. For example: %typemap(in,parse="i",doc="integer") int "..."; The purpose of the keyword parameters is to supply code generation hints to the target language module. The intepretation of the parameters is language specific. *** NEW FEATURE *** 11/04/2001:beazley Slight semantic change to internal call/return by value handling. In previous versions of SWIG, call-by-value was translated into pointers. For example: double dot_product(Vector a, Vector b); turned into this: double wrap_dot_product(Vector *a, Vector *b) { return dot_product(*a,*b); } This translation was normally performed by the SWIG core, outside of the control of language modules. However, a side effect of this was a lot of bizarre typemap behavior. For example, if you did something like this: %typemap(in) int32 { ... } You would find that int32 was transformed into a pointer everywhere! (needless to say, such behavior is unexpected and quite awkward to deal with). To make matters worse, if a typedef was also used, the pointer behavior suddenly disappeared. To fix this, the pointer transformation is now pushed to the language modules. This produces wrappers that look roughly like this: double wrap_dot_product(Vector *a, Vector *b) { Vector arg1 = *a; Vector arg2 = *b; return dot_product(arg1,arg2); } This change also makes it easy to define typemaps for arbitrary undefined types. For example, you can do this (and it will work regardless what int32 is): %typemap(in) int32 { $1 = (int32) PyInt_AsLong($input); } *** POTENTIAL IMCOMPATIBILITY *** This change may break call/return by value code generation in some language modules. 11/03/2001:beazley Changed the name of the default typemaps to the following: %typemap() SWIGTYPE { ... an object ... } %typemap() SWIGTYPE * { ... a pointer ... } %typemap() SWIGTYPE & { ... a reference ... } %typemap() SWIGTYPE [] { ... an array ... } %typemap() enum SWIGTYPE { ... an enum value ... } %typemap() SWIGTYPE (CLASS::*) { ... pointer to member ... } These types are used as the default for all types that don't match anything else. See CHANGES log entry for 8/27/2000 for the old behavior. The role of these types is also described in Doc/Manual/Typemaps.html *** POTENTIAL INCOMPATIBILITY *** 10/25/2001:beazley Modified Guile and Mzscheme modules to support multi-argument typemaps. 10/25/2001: cheetah (william fulton) [Java] Fix to handle pointers to arrays. 10/24/2001:beazley Defining a typemap rule for enum SWIGENUM can now be used to define default behavior for enum variables. 10/22/2001:beazley Ruby module modified to support multi-argument typemaps. 10/22/2001:beazley The Ruby module can now handle functions with an arbitrary number of arguments. Previous versions were limited to to functions with only 9 or 16 arguments depending on the use of default arguments. Note: from some inspection of the Ruby interpreter source, the new approach might be a little faster as well. 10/18/2001:beazley Fixed a bug with forward class declarations and templates. class Foo ; Bug reported by Irina Kotlova. 10/16/2001:beazley Support for multivalued typemaps added. The typemaps are specified using the syntax below. Within each typemap, variable substitution is handled as follows: %typemap(in) (int argc, char *argv[]) { $arg; // The input object in the target language $1; // C local variable for first argument $2; // C local variable for second argument // These variables refer to either argument $1_type, $1_ltype, $1_basetype, etc... (argc) $2_type, $2_ltype, $2_basetype, etc... (argv[]) // Array dimension of argv $2_dim0 } Basically any variable that was available in normal typemaps is available for either argument by prefacing the variable name by '$n_' where n is the argument position. Notes: (1) Multi-valued typemaps can only be applied to a single object in the target scripting language. For example, you can split a string into a (char *, int) pair or split a list into a (int, char []) pair. It is not possible to map multiple objects to multiple arguments. (2) To maintain compatibility with older SWIG versions, the variables such as $target and $type are preserved and are mapped onto the first argument only. (3) This should not affect compatibility with older code. Multi-valued typemaps are an extension to typemap handling. Single valued typemaps can be specified in the usual way. The old $source and $target variables are officially deprecated. Input variables are referenced through $arg$ and output values are reference through $result$. *** NEW FEATURE *** 10/16/2001:beazley Added parsing support for multivalued typemaps. The syntax is a little funky, but here goes: // Define a multivalued typemap %typemap(in) (int argc, char *argv[]) { ... typemap code ... } // Multivalued typemap with locals %typemap(in) (int argc, char *argv[])(int temp) { ... typemap code ... } // Copy a multivalued typemap %typemap(in) (int argcount, char **argv) = (int argc, char *argv[]); // Apply a multivalued typemap %apply (int argc, char *argv[]) { (int argcount, char **argv) }; Note: this extra parsing support is added for future extension. No language modules currently support multi-valued typemaps. 10/11/2001:beazley Modified the typemap matching code to discard qualifiers when checking for a match. For example, if you have a declaration like this: void blah(const char *x); The typemap checker checks for a match in the following order: const char *x const char * char *x char * If typedef's are involved, qualifier stripping occurs before typedef resolution. So if you had this, typedef char *string; void blah(const string x); typemap checking would be as follows: const string x const string string x string const char *x const char * char *x char * The primary reason for this change is to simplify the implementation of language modules. Without qualifier stripping, one has to write seperate typemaps for all variations of const and volatile (which is a pain). *** POTENTIAL INCOMPATIBILITY *** Typemaps might be applied in places where they weren't before. 10/9/2001: beazley SWIG now generates wrappers that properly disambiguate overloaded methods that only vary in constness. For example: class Foo { ... void blah(); void blah() const; ... }; To handle this, the %rename directive can be used normally. %rename(blah_const) blah() const; In the resulting wrapper code, method calls like this are now generated: (obj)->blah() // Non-const version ((Foo const *)obj)->blah() // const version This should force the right method to be invoked. Admittedly, this is probably obscure, but we might as well get it right. 10/8/2001: beazley The preprocessor now ignores '\r' in the input. This should fix the following bug: [ #468416 ] SWIG thinks macro defs are declarations? 10/8/2001: beazley Added support for ||, &&, and ! in constants. This fixes SF [ #468988 ] Logical ops break preprocessor. However, at this time, constants using these operators are not supported (the parser will issue a warning). 10/4/2001: beazley Added -show_templates command line option. This makes SWIG display the code it actually parses to generate template wrappers. Mostly useful for debugging. *** NEW FEATURE *** 10/4/2001: beazley Change to semantics of %template directive. When using %template, the template arguments are handled as types by default. For example: %template(vecint) vector; %template(vecdouble) vector; To specify a template argument that is *not* a type, you need to use default-value syntax. For example: %template(vecint) vector; %template(vecdouble) vector; In this case, the type name doesn't really matter--only the default value (e.g., 50, 100) is used during expansion. This differs from normal C++, but I couldn't figure out a better way to do it in the parser. Might implement an alternative later. *** POTENTIAL INCOMPATIBILITY *** 10/4/2001: beazley Major changes to template handling in order to provide better integration with the C++ type-system. The main problem is as follows: Suppose you have a template like this: template void blah(const T x) { stuff }; Now suppose, that you instantiate the template on a type like this in SWIG: %template(blahint) blah; In C++, this is *supposed* to generate code like this: void blah(int *const x) { stuff }; However, in SWIG-1.3.9, the template substitution gets it wrong and produces void blah(const int *x) { stuff }; (notice the bad placement of the 'const' qualifier). To fix this, the SWIG parser now generates implicit typedefs for template type arguments that produces code roughly equivalent to doing this: typedef int *__swigtmpl1; %template(blahint) blah<__swigtmpl1>; which generates code like this: void blah(const __swigtmpl1 x) { stuff }; Since this is correct in both C++ and SWIG, it provides the right semantics and allows everything to compile properly. However, to clean up the generated code a little bit, the parser keeps track of the template types and performs back-substitution to the original type when building the parse tree. Thus, even though the implicit typedef is used in the input and may appear in the generated wrapper file (for proper compilation), the parse tree will hide a lot of these details. For example: void blah(const __swigtmpl1 x) { stuff }; will look like it was declared as follows (which is what you want): void blah(int *const x) { stuff } The only place you are likely to notice the typedef hack is in bodies of template functions. For example, if you did this, template class blah { ... %addmethods { void spam() { T tempvalue; ... } } } you will find that 'T tempvalue' got expanded into some strange typedef type. This *still* compiles correctly so it's not a big deal (other than looking kind of ugly in the wrapper file). 10/4/2001: beazley Fixed some inheritance problems in Tcl Object interface. 10/1/2001: beazley Tcl module has changed to use byte-backed pointer strings. This implementation should be safe on 64-bit platforms. However, the order in which digits appear in pointer values no longer directly corresponds to the actual numerical value of a pointer (on little-endian machines, pairs of digits appear in reverse order). 10/1/2001: beazley Perl5 module is now driven by a configuration file 'perl5.swg' in the SWIG library. 10/1/2001: beazley The perl5 module no longer tries to apply the "out" typemap in code generated for magic variables. I'm surprised that this ever worked at all (since all of the code that was there was wrong anyways). Use the "varout" typemap to handle global variables. 10/1/2001: beazley Fixed a bug related to character array members of structures. For example: struct Foo { char name[32]; }; SWIG is normally supposed to return a string, but this was broken in 1.3.9. The reason it was broken was actually due to a subtle new feature of typemaps. When a data member is set to an array like this, the return type of the related accessor function is actually set to an array. This means that you can now write typemaps like this: %typemap(python,out) char [ANY] { $target = PyString_FromStringAndSize($source,$dim0); } This functionality can be used to replace the defunct memberout typemap in a more elegant manner. 9/29/2001: beazley Some further refinement of qualified C++ member functions. For example: class Foo { ... void foo() const; ... }; (i) The SWIG parser was extended slightly to allow 'volatile' and combinations of 'const' and 'volatile' to be used. This is probably rare, but technically legal. Only added for completeness. (ii) For the purposes of overloading, qualified and non-qualified functions are different. Thus, when a class has methods like this: void foo(); void foo() const; Two distinct methods are declared. To deal with this, %rename and similar directives have been extended to recognize const. Thus, one can disambiguate the two functions like this: %rename(fooconst) Foo::foo() const; or simply ignore the const variant like this: %ignore Foo::foo() const; Note: SWIG currently has no way to actually invoke the const member since the 'const' is discarded when generating wrappers for objects. 9/27/2001: beazley New directive. %namewarn can be used to issue warning messages for certain declaration names. The name matching is the same as for the %rename directive. The intent of this directive is to issue warnings for possible namespace conflicts. For example: %namewarn("print is a python keyword") print; The name matching algorithm is performed after a name has been resolved using %rename. Therefore, a declaration like this will not generate a warning: %rename("Print") print; ... void print(); /* No warning generated */ Since the warning mechanism follows %rename semantics, it is also to issue warnings for specific classes or just for certain member function names. (Dave - I've been thinking about adding something like this for quite some time. Just never got around to it) *** NEW FEATURE *** 9/27/2001: beazley Enhanced the %ignore directive so that warning messages can be issued to users. This is done using %ignorewarn like this: %ignorewarn("operator new ignored") operator new; The names and semantics of %ignorewarn is exactly the same as %ignore. The primary purpose of this directive is for module writers who want to ignore certain types of declarations, but who also want to alert users about it. A user might also use this for debugging (since messages will appear whenever an ignored declaration appears). *** NEW FEATURE *** 9/26/2001: beazley Super-experimental support for overloaded operators. This implementation consists of a few different parts. (i) Operator names such as 'operator+' are now allowed as valid declarator names. Thus the 'operator' syntax can appear *anyplace* a normal declarator name was used before. On the surface, this means that operators can be parsed just like normal functions and methods. However, it also means that operator names can be used in many other SWIG directives like %rename. For example: %rename(__add__) Complex::operator+(const Complex &); (ii) Operators are wrapped *exactly* like normal functions and methods. Internally, the operator name is used directly meaning that the wrapper code might contain statements like this: arg0->operator*((Complex const &)*arg1); This all seems to parse and compile correctly (at least on my machine). (iii) SWIG will no longer wrap a declaration if its symbol table name contains illegal identifier characters. If illegal characters are detected, you will see an error like this: Warning. Can't wrap operator* unless renamed to a valid identifier. The only way to fix this is to use %rename or %name to bind the operator to a nice name like "add" or something. Note: the legal identifier characters are determined by the target language. There are certain issues with friend functions and operators. Sometimes, friends are used to define mixed operators such as adding a Complex and a double together. Currently, SWIG ignores all friend declarations in a class. A global operator declaration can probably be made to work, but you'll have to rename it and it probably won't work very cleanly in the target language since it's not a class member. SWIG doesn't know how to handle operator specifications sometimes used for automatic type conversion. For example: class String { ... operator const char*(); ... }; (this doesn't parse correctly and generates a syntax error). Also: operators no longer show up as separate parse-tree nodes (instead they are normal 'cdecl' nodes). I may separate them as a special case later. See Examples/python/operator for an example. *** SUPER-EXPERIMENTAL NEW FEATURE *** Version 1.3.9 (September 25, 2001) ================================== 9/25/2001: beazley Fixed parsing problem with type declarations like 'char ** const'. SWIG parsed this correctly, but the internal type was represented incorrectly (the pointers and qualifiers were in the wrong order). 9/25/2001: beazley Withdrew experimental feature (noted below) that was causing serious parsing problems. Version 1.3.8 (September 23, 2001) ================================== 9/23/2001: beazley Included improved distutils setup.py file in the Tools directory (look for the setup.py.tmpl file). Contributed by Tony Seward. 9/23/2001: beazley Included two new RPM spec files in the Tools directory. Contributed by Tony Seward and Uwe Steinmann. 9/21/2001: beazley Fixed SF Bug [ #463635 ] Perl5.swg does not compile in Visual C++ 9/21/2001: beazley Two new directives control the creation of default constructors and destructors: %nodefault %makedefault These replace %pragma nodefault and %pragma makedefault. (old code will still work, but documentation will only describe the new directives). 9/21/2001: beazley Fixed SF Bug [ #462354 ] %import broken in 1.3.7. 9/20/2001: beazley Parser modified to ignore out-of-class constructor and destructor declarations. For example: inline Foo::Foo() : Bar("foo") { } inline Foo::~Foo() { } Suggested by Jason Stewart. *** EXPERIMENTAL FEATURE *** 9/20/2001: beazley Modified the parser to ignore forward template class declarations. For example: template class MapIter; Suggested by an email example from Irina Kotlova. 9/20/2001: beazley Fixed problem with undeclared tcl_result variable in the "out" typemap for Tcl. Reported by Shaun Lowry. 9/20/2001: beazley Incorporated changes to make SWIG work with ActivePerl. Contributed by Joel Reed. 9/20/2001: beazley Slight change to the parsing of C++ constructor initializers. For example: class Foo : public Bar { public: Foo() : Bar(...) {...} }; SWIG now discards the contents of the (...) regardless of what might enclosed (even if syntactically wrong). SWIG doesn't need this information and there is no reason to needless add syntax rules to handle all of the possibilities here. 9/20/2001: beazley Change to typemaps for structure members. If you have a structure like this: struct Vector { int *bar; }; The member name 'bar' is now used in any accessor functions. This allows the "in" typemap to be used when setting the value. For example, this typemap %typemap(python,in) int *bar { ... } now matches Vector::bar. It should be noted that this will also match any function with an argument of "int *bar" (so you should be careful). *** NEW FEATURE. POTENTIAL INCOMPATIBILITY *** 9/20/2001: beazley Fixed SF bug #462642 setting string values in structures 9/20/2001: beazley Fixed SF bug #462398 problem with nested templates. 9/20/2001: beazley Fixed SF bug #461626 problem with formatting and C++ comments. 9/20/2001: beazley Fixed SF bug #462845 Wrong ownership of returned objects. 9/19/2001: beazley Fixed SF bug #459367. Default constructors for classes with pure virtual methods. 9/19/2001: beazley Fixed problem with default arguments and class scope. For example: class Foo { public: enum bar { FOO, BAR }; void blah(bar b = FOO); ... } SWIG now correctly generates a default value of "Foo::FOO" for the blah() method above. This used to work in 1.1, but was broken in 1.3.7. Bug reported by Mike Romberg. Version 1.3.7 (September 3, 2001) ================================== 9/02/2001: beazley Added special %ignore directive to ignore declarations. This feature works exactly like %rename. For example: %ignore foo; // Ignore all declarations foo %ignore ::foo; // Only ignore foo in global scope %ignore Spam::foo; // Only ignore in class Spam %ignore *::foo; // Ignore in all classes %ignore can also be parameterized. For example: %ignore foo(int); %ignore ::foo(int); %ignore Spam::foo(int); %ignore *::foo(int); *** NEW FEATURE *** 9/02/2001: cheetah (william fulton) [Java] shadowcode pragma modified so that the code that is output in the shadow file is placed relative to where it is placed in the c/c++ code. This allows support for JavaDoc function comments. 9/01/2001: beazley Fixed SF Patch [ #447791 ] Fix for python -interface option. Submitted by Tarn Weisner Burton. 9/01/2001: beazley SWIG no longer generates default constructors/destructors for a class if it only defines a private/protected constructor or destructor or if any one of its base classes only has private constructors/destructors. This was reported in SF Patch [ #444281 ] nonpublic/default/inhereted ctor/dtor by Marcelo Matus. 9/01/2001: beazley Added patch to Perl5 module that allows constants to be wrapped as constants that don't require the leading $. This feature is enabled using the -const option. Patch contributed by Rich Wales. *** NEW FEATURE *** 8/31/2001: beazley Added parsing support for the 'volatile' type qualifier. volatile doesn't mean anything to SWIG, but it is needed to properly generate prototypes for declarations that use it. It's also been added to make the SWIG type system more complete. *** NEW FEATURE *** 8/30/2001: beazley Added support for parameterized %rename directive. *** This new feature can be used to greatly simplify the task of resolving overloaded methods and functions. *** In prior versions of SWIG, the %rename directive was used to consistently apply an identifier renaming. For example, if you said this: %rename foo bar; Every occurrence of 'foo' would be renamed to 'bar'. Although this works fine for resolving a conflict with a target language reserved word, it is useless for for dealing with overloaded methods. This is because all methods are simply renamed to the same thing (generating the same conflict as before). Therefore, the only way to deal with overloaded methods was to go through and individually rename them all using %name. For example: class Foo { public: virtual void bar(void); %name(bar_i) virtual void bar(int); ... }; To make matters worse, you had to do this for all derived classes too. class Spam : public Foo { public: virtual void bar(void); %name(bar_i) virtual void bar(int); ... }; Needless to say, this makes it extremely hard to resolve overloading without a lot of work and makes it almost impossible to use SWIG on raw C++ .h files. To fix this, %rename now accepts parameter declarators. The syntax has also been changed slightly. For example, the following declaration renames all occurrences of 'bar(int)' to 'bar_i', leaving any other occurrence of 'bar' alone. %rename(bar_i) bar(int); Using this feature, you can now selectively rename certain declarations in advance. For example: %rename(bar_i) bar(int); %rename(bar_d) bar(double); // Include raw C++ header %include "header.h" When %rename is used in this manner, all occurrence of bar(int) are renamed wherever they might occur. More control is obtained through explicit qualification. For example, %rename(bar_i) ::bar(int); only applies the renaming if bar(int) is defined in the global scope. The declaration, %rename(bar_i) Foo::bar(int); applies the renaming if bar(int) is defined in a class Foo. This latter form also supports inheritance. Therefore, if you had a class like this: class Spam : public Foo { public: void bar(int); } The Spam::bar(int) method would also be renamed (since Spam is a subclass of Foo). This latter feature makes it easy for SWIG to apply a consistent renaming across an entire class hierarchy simply by specifying renaming rules for the base class. A class wildcard of * can be used if you want to renaming all matching members of all classes. For example: %rename(bar_i) *::bar(int); will rename all members bar(int) that are defined in classes. It will not renamed definitions of bar(int) in the global scope. The old use of %rename is still supported, but is somewhat enhanced. %rename(foo) bar; // Renames all occurrences of 'bar'. %rename(foo) ::bar; // Rename all 'bar' in global scope only. %rename(foo) *::bar; // Rename all 'bar' in classes only. %rename(foo) Foo::bar; // Rename all 'bar' defined in class Foo. *** NEW FEATURE *** 8/30/2001: beazley Added support for data-member to member-function transformation. For example, suppose you had a structure like this: struct Vector { double x,y; }; Now suppose that you wanted to access x and y through a member function interface instead of the usual SWIG behavior. For example: f.set_x(3.4) # instead of f.x = 3.4 x = f.get_x() # instead of x = f.x To do this, simply use the new %attributefunc directive. For example: %attributefunc(get_%s,set_%s) struct Vector { double x,y; }; %noattributefunc The arguments to %attributefunc are C-style printf format strings that determine the naming convention to use. %s is replaced with the actual name of the data member. SWIG provides a number of printf extensions that might help. For example, if you wanted to title case all of the attributes, you could do this: %attributefunc(get%(title)s,set%(title)s); This will turn an attribute 'bar' to 'getBar()' and 'setBar()'. (someone requested this long ago, but I finally figured how to implement it in a straightforward manner). *** EXPERIMENTAL NEW FEATURE *** 8/30/2001: beazley SWIG now automatically generates default constructors and destructors if none are defined. This used to be enabled with a command line switch -make_default, but most people want these functions anyways. To turn off this behavior use the -no_default option or include the following pragma in the interface file: %pragma no_default; This may break certain interfaces that defined their own constructors/destructors using the same naming convention as SWIG. If so, you will get duplicate symbols when compiling the SWIG wrapper file. *** POTENTIAL INCOMPATIBILITY *** 8/29/2001: beazley Changes to Perl5 shadow class code generation. Iterators are no longer supported (FIRSTKEY, NEXTKEY). Also, attribute access has been changed to rely on inheritance in order to provide better behavior across modules. 8/28/2001: beazley Various obscure improvements to the type system and classes. Strange declarations like this are now wrapped correctly (i.e., the generated wrapper code doesn't cause the C++ compiler to die with a type error). class Foo { public: typedef double Real; Real foo(Real (*op)(Real,Real), Real x, Real y); }; Inheritance of types is also handled correctly. 8/28/2001: beazley Changes to class wrappers. When SWIG sees two classes like this, class X { public: void foo(); ... } class Y : public X { public: void bar(); ... } it now only generates two wrapper functions: X_foo(X *x) { x->foo(); } Y_bar(Y *y) { y->bar(); } Unlike SWIG1.15, the foo() method does *not* propagate to a wrapper function Y_foo(). Instead, the base class method X_foo() must be used. This change should not affect modules that use shadow classes, but it might break modules that directly use the low-level C wrappers. This change is being made for a number of reasons: - It greatly simplifies the implementation of SWIG--especially with anticipated future changes such as overloaded methods. - It results in substantially less wrapper code--especially for big C++ class hierarchies (inherited declarations are no longer copied into every single derived class). - It allows for better code generation across multiple SWIG generated modules (code isn't replicated in every single module). *** POTENTIAL INCOMPATIBILITY *** 8/22/2001: cheetah (william fulton) Provided some Windows documentation in the Win directory and some Visual C++ project files for running examples on Windows. 8/28/2001: mkoeppe [Guile] Handle renamed overloaded functions properly; thanks to Marc Zonzon for the patch. See the new test case name_cxx. 8/27/2001: mkoeppe [Tcl] Removed lots of warnings issued by the Sun Forte compilers, which were caused by mixing function pointers of different linkages (C++/C). 8/23/2001: mkoeppe Improved the MzScheme module by porting Guile's pointer type checking system and making type dispatch typemap-driven. 8/22/2001: beazley Entirely new symbol table processing. SWIG should be able to report much better error messages for multiple declarations. Also, the new symbol table allows for overloaded functions (although overloading isn't quite supported in the language modules yet). 8/22/2001: cheetah (william fulton) * [Java] %new support added. * [Java] Package JNI name refixed! 8/19/2001: beazley Python module modified to support pointers to C++ members. This is an experimental feature. *** NEW FEATURE *** 8/19/2001: beazley Added limited parsing and full type-system support for pointers to members. None of SWIG's language modules really know how to deal with this so this is really only provided for completeness and future expansion. Note: SWIG does not support pointers to members which are themselves pointers to members, references to pointers to members, or other complicated declarations like this. *** NEW FEATURE *** 8/19/2001: beazley SWIG is much better at parsing certain C++ declarations. Operators and friends generally don't cause anymore syntax errors. However, neither are really supported. 8/18/2001: beazley Added *highly* experimental support for wrapping of C++ template declarations. Since C++ templates are essentially glorified macros and SWIG has a fully operational C preprocessor with macro support, the parser now converts template declarations to macros. For example, a function template like this template T max(T a, T b); is internally converted into a macro like this: %define %_template_max(__name,T) %name(__name) T max(T a, T b); %enddef To instantiate a version of the template, a special %template declaration is used like this: %template(maxint) max; %template(maxdouble) max; The parameter to the %template directive must be proper C identifier that's used to uniquely name the resulting instantiation. When used, the the expanded macro looks like this: %name(maxint) int max(int a, int b); %name(maxdouble) double max(double a, double b); A similar technique is used for template classes. For instance: template class vector { T *data; int sz; public: vector(int nitems); T *get(int n); ... }; Gets converted into a macro like this: %define %_template_vector(__name, T) %{ typedef vector __name; %} class __name { T *data; int sz; public: __name(int nitems); T *get(int n); ... }; typedef __name vector; %enddef An a specific instantiation is created in exactly the same way: %template(intvec) vector; The resulting code parsed by SWIG is then: %{ typedef vector intvec; %} class intvec { int *data; int sz; public: intvec(int nitems); int *get(int n); ... }; typedef intvec vector; Note: the last typedef is non-standard C and is used by SWIG to provide an association between the name "intvec" and the template type "vector". CAUTION: This is an experimental feature and the first time SWIG has supported C++ templates. Error reporting is essential non-existent. It will probably break in certain cases. *** EXPERIMENTAL NEW FEATURE **** 8/15/2001: beazley Change to wrapping of multi-dimensional arrays. Arrays are now properly mapped to a pointer to an array of one less dimension. For example: int [10]; --> int * int [10][20]; --> int (*)[20]; int [10][20][30]; --> int (*)[20][30]; This change may break certain SWIG extensions because older versions simply mapped all arrays into a single pointer such as "int *". Although possibly unusual, the new version is correct in terms of the C type system. *** POTENTIAL INCOMPATIBILITY *** 8/06/2001: cheetah (william fulton) * [Java] Array setters generated for struct/class array members. 8/13/2001: beazley Many improvements to Tcl/Perl/Python modules to better work with multiple interface files and the %import directive. 8/13/2001: beazley Fixed up the behavior of %import in the Python module. SWIG no longer pollutes the module namespace by using 'from module import *' to refer to the other module. Instead, it does a proper 'import module'. Also, SWIG may work a lot better when importing modules that include references to other imported modules. 8/13/2001: mkoeppe Added new typemap substitutions, generalizing those of the Guile-specific 5/27/2001 changes: * $descriptor is the same as SWIGTYPE$mangle, but also ensures that the type descriptor of this name gets defined. * $*type, $*ltype, $*mangle, $*descriptor are the same as the variants without star, but they REMOVE one level of pointers from the type. (This is only valid for pointer types.) * $&type, $<ype, $&mangle, $&descriptor are the same as the variants without ampersand, but they ADD one level of pointers to the type. The Guile-specific substitution $basedescriptor was removed because it was useless. 8/12/2001: beazley The %extern directive is now deprecated and withdrawn. The purpose of this directive was to import selected definitions from other interface files and headers. However, the same functionality is better handled through %import. This leaves SWIG with two file inclusion directives: %include filename - Inserts into current interface %import filename - Import types and classes from another module *** POTENTIAL INCOMPATIBILITY *** 8/09/2001: beazley Added new support for wrapping C/C++ callback functions. A common problem with some C libraries is that many functions take a function pointer as an argument. For example: int do_op(..., int (*op)(int,int), ...); Unfortunately, the only way to call such a function is to pass it a function pointer of some compatible type. In previous versions of SWIG, you had to solve this problem with some really gross hacks. For example, if you wanted to use the following function as a callback, int foo(int, int); you had to install a pointer to it as a constant. For example: %constant int (*FOO)(int,int) = foo; or const int (*FOO)(int,int) = foo; or if you had a really old SWIG version: typedef int (*OP_FUNC)(int,int); int do_op(..., OP_FUNC, ...); const OP_FUNC FOO = foo; Now, you can do one of two things: %constant int foo(int,int); This creates a constant 'foo' of type int (*)(int,int). Alternatively, you can do this: %callback("%s"); int foo(int,int); int bar(int,int); %nocallback; In this case, the functions are installed as constants where the name is defined by the format string given to %callback(). If the names generated by the format string differ from the actual function name, both a function wrapper and a callback constant are created. For example: %callback("%(upper)s"); int foo(int,int); int bar(int,int); %nocallback; Creates two wrapper functions 'foo', 'bar' and additionally creates two callback constants 'FOO', 'BAR'. Note: SWIG still does not provide automatic support for writing callback functions in the target language. *** NEW FEATURE *** 8/06/2001: cheetah (william fulton) * struct nesting fixes as per SF bug #447488. 8/03/2001: beazley The %name directive now applies to constants created with #define and %constant. However, most language modules were never written to support this and will have to be modified to make it work. Tcl, Python, and Perl modules are working now. *** NEW FEATURE *** 8/03/2001: beazley Massive changes and simplification of C declaration parsing. Although SWIG is still not a full C parser, its ability to handle complex datatypes including pointers to functions and pointers to arrays has been vastly improved. 8/03/2001: cheetah (william fulton) * Distribution fixes: autoconf no longer needed to install SWIG. 8/02/2001: beazley Removed two undocumented parsing features. SWIG no longer supports out-of-class static function or variable declarations. For example: static int Foo::bar; This feature may return if there is sufficient demand. However, since SWIG is most often used with header files, it is more likely for these definitions to be included in the class definition. *** POTENTIAL INCOMPATIBILITY *** 8/02/2001: cheetah (william fulton) * Cleanup of the GIFPlot examples. Upgraded Java GIFPlot example. 8/01/2001: cheetah (william fulton) * [Java] Efficiency changes: _cPtr used where possible rather than getCPtr(). Bug fixes for inheritance - derived class sometimes didn't delete the c memory when _delete() was called. * [Java] Abstract c++ classes are wrapped with a java abstract shadow class. Also a pure virtual function is mapped with an abstract method. * The default output file has always been _wrap.c. It is now _wrap.cxx if the -c++ commandline option is passed to swig. This has been done as otherwise c++ code would appear in a c file. *** POTENTIAL INCOMPATIBILITY *** 7/31/2001: beazley Modified the %constant directive to be more C-like in syntax. The syntax is now: %constant NAME = VALUE; %constant TYPE NAME = VALUE; For example: %constant Foo *Bar = &Spam; A more subtle case is as follows: %constant int (*FOO)(int,int) = blah; *** POTENTIAL INCOMPATIBILITY *** Modules that were using the %constant directive directly will need to be modified. 7/30/2001: beazley Removed obscure and undocumented form of the %inline directive: %inline int blah(int a, int b) { ... } *** POTENTIAL INCOMPATIBILITY *** (note: this feature was never documented and is withdrawn) 7/30/2001: beazley Removed support for functions with no explicitly declared return type. For example: foo(int); In C, such functions were implicitly assumed to return an 'int'. In C++, this is illegal. Either way, it's considered bad style. Removing support for this in SWIG will simplify certain issues in parsing. *** POTENTIAL INCOMPATIBILITY *** 7/30/2001: mkoeppe * Partial merge from the CVS trunk. The Source/DOH directory and most of the Source/Swig directory is up-to-date now. * [Guile] %scheme is now a macro for %insert("scheme"). New syntax: %scheme "FILENAME"; New syntax: %scheme %{ SCHEME-CODE %} New macros %multiple_values, %values_as_list, %values_as_vector. 7/29/2001: beazley %readonly and %readwrite have been turned into SWIG pragmas. %pragma(swig) readonly and %pragma(swig) readwrite. Macros are used to provide backwards compatibility. 7/29/2001: beazley Minor changes to %pragma directive. %pragma must always be directed to a specific language. For example: %pragma(swig) make_default; %pragma(perl5) include = "blah.i"; Also extended the pragma directive to allow code blocks %pragma(foo) code = %{ ... some code ... %} *** POTENTIAL INCOMPATIBILITY *** 7/29/2001: beazley Change to the way 'const' variables are wrapped. In previous versions of SWIG, a 'const' variable was wrapped as a constant. Now, 'const' variables are wrapped as read-only variables. There are several reasons for making this change, mostly pertaining to subtle details of how 'const' actually works. This will probably break old interfaces that used 'const' to create constants. As a replacement, consider using this: const int a = 4; ===> %constant int a = 4; *** POTENTIAL INCOMPATIBILITY *** 7/29/2001: beazley Reorganization and simplification of type parsing. Types with 'const' should work correctly now. 7/29/2001: beazley Most swig directives related to the documentation system are now deprecated. 7/29/2001: beazley Removed support for Objective-C in order to simplify parser reconstruction. Will return if there is sufficient demand. *** POTENTIAL INCOMPATIBILITY *** 7/29/2001: beazley Code inclusion has been modified in the parser. A common directive %insert is now used for everything. This inserts a file into the output: %insert(header) "foo.swg" This inserts some inline code into the output %insert(header) %{ ... some code ... %} There are five predefined targets for the insert directive: "header" - Header section of wrapper file "runtime" - Runtime section of wrapper file "wrapper" - Wrapper section "init" - Initialization function "null" - Nothing. Discard. The following directives are still supported, but are now defined in terms of macros: %{ ... %} -> %insert(header) %{ ... %} %init %{ ... %} -> %insert(init) %{ ... %} %wrapper %{ ... %} -> %insert(wrapper) %{ ... %} %runtime %{ ... %} -> %insert(runtime) %{ ... %} Language modules can define new named targets by using the C API function Swig_register_filebyname() (see main.cxx). For example, if you wanted to expose a shadow class file, you could do this: Swig_register_filebyname("shadow", f_shadow); Then in the interface file: %insert(shadow) %{ ... %} Note: this change should not affect any old interfaces, but does open up new possibilities for enhancements. 7/29/2001: beazley SWIG now always includes a standard library file 'swig.swg'. This file defines a large number of macro definitions that define the behavior of various SWIG directives. Previously, all SWIG directives were handled as special cases in the parser. This made the parser a large bloated mess. Now, the parser is stripped down to a few simple directives and macros are used to handle everything else. 7/26/2001: cheetah (william fulton) * Fixes for Sourceforge bug #444748 - new testcase cpp_static: [TCL] Class with just static member variable/function fix [Java] Fixed static variables support [Ruby] Static variables workaround removed 7/27/2001: mkoeppe * stype.c (SwigType_default): Strip qualifiers first. The default type of "int * const" is now "SWIGPOINTER *". * main.cxx: Define "__cplusplus" in SWIG's preprocessor if in C++ mode. * [Guile]: Added some support for arrays and C++ references, fixing the "constant_pointers" test case. * Moved most tests from the old Guile-specific test-suite to the new test-suite. Also moved perl5/pointer-cxx example there. 7/26/2001: cheetah (william fulton) * Test-suite added. * Initial testcases: constant_pointers cpp_enum defines sizeof_pointers unions virtual_destructor * Make clean improvements. 7/24/2001: cheetah (william fulton) * [Java] Underscores in the package name and/or module name no longer give linking problems. 7/17/2001: cheetah (william fulton) * More parser bug fixes for constant pointers 7/19/2001: mkoeppe * [Guile] Aesthetic improvement in variable wrappers. 7/18/2001: beazley * Fixed core-dump problem in pointer library when freeing character arrays. SF Bug [ #415837 ] pointer lib core dump 7/18/2001: beazley * Fixed problem with default destructors and shadow classes. SF bug #221128. 7/18/2001: beazley * To provide better line-number tracking in interfaces with lots of macros, special locator comments are now generated by the SWIG preprocessor. For example: /*@foo.i,42,BLAH@*/expanded macro/*@@*/ The first /*@...@*/ sequence sets the context to point to the macro code. The /*@@*/ comment terminates the context. The SWIG parser should ignore all of the locator comments as should the C compiler (should such comments end up in generated wrapper code). 7/18/2001: mkoeppe * The parser now handles severely constified types in typemaps. This introduced a new shift/reduce conflict, but only with a heuristic function-pointer catch-all rule. * [Guile]: Added typemaps for severely constified types. * Fixed the "template-whitespace" problem by canonicalizing whitespace, especially around angle brackets and commas. 7/17/2001: mkoeppe * [Guile]: A Scheme file is emitted if the -scmstub FILE.SCM command-line option is used. The %scheme directive (implemented as a macro for a pragma) allows to insert arbitrary code here. In "simple" and "passive" linkage, the file gets filled with define-module and export declarations. 7/17/2001: cheetah (william fulton) * Parser bug fix to support constant pointers, eg int* const ptr. Fixed everywhere - variables, parameters, return types etc. Note that when wrapping a constant pointer variable only the getter is generated. 7/17/2001: mkoeppe * Fixed SF bug #441470 (#define X "//" would not be parsed, see test-suite entry "preproc-1"), reported by T. W. Burton . * Changed the type of character constants to "char", rather than "char *". Changed the individual language modules to keep the old behaviour, except for the Guile module, where it is desired to make them Scheme characters. This fixes SF bug #231409, test-suite entry "char-constant". * Applied patch for DOH/Doh/memory.c by Les Schaffer (avoid required side effects in assert). 7/17/2001: cheetah (william fulton) * Bug fix in parser for virtual destructor with void as parameter * Bug fix in parser #defines embedded within classes/structs/unions Consequently %constant can now also be placed within a struct/class/union. * Bug fix in parser to allow sizeof(*I_am_a_pointer) within a #define 7/16/2001: mkoeppe * Added changes for the Macintosh contributed by Luigi Ballabio . * Some "const" fixes in the code. * [Guile]: Made the constant-wrapper functions much shorter. 7/13/2001: mkoeppe * [Guile]: Some "const" fixes for Guile version 1.3.4. * Handle anonymous arguments with default values and static array members of classes. Both bugs reported by Annalisa Terracina ; see the files Examples/guile/test-suite/static-array-member.i and anonymous-arg.i. Version 1.3.6 (July 9, 2001) ============================= 7/09/2001: cheetah (william fulton) * GIFPlot examples: FOREGROUND and BACKGROUND definition missing after TRANSPARENT #define fix in GIFPlot 7/03/2001: beazley Fixed up the version numbers so that the release is known as 1.3.6. All future releases should have a similar version format. 7/02/2001: mkoeppe * [Python]: Prevent the problem of self.thisown not being defined if the C++ class constructor raised an exception. Thanks to Luigi Ballabio . 6/29/2001: mkoeppe * More portability fixes; fixed "gcc -Wall" warnings. 6/29/2001: cheetah (william fulton) * GIFPlot examples: TRANSPARENT #define multiple times on Solaris (clashes with stream.h). * Multiple definition bug fix for shadow classes. The perl and python modules had workarounds which have been replaced with fixes in the core. Many of the Language::cpp_xxxx functions now set a flag which the derived classes can access through is_multiple_definition() to see whether or not code should be generated. The code below would have produced varying degrees of incorrect shadow class code for the various modules: class TestClass { public: TestClass() {}; TestClass(int a) {}; ~TestClass() {}; unsigned long xyz(short k) {}; unsigned long xyz(int n) {}; static void static_func() {}; static void static_func(int a) {}; }; void delete_TestClass(int a); 6/27/2001: mkoeppe * [Perl] Another const-related portability fix. 6/26/2001: cheetah (william fulton) * [Java] Added in cpp_pragma() support with a host of new pragmas - see jswig.html. These are designed for better mixing of Java and c++. It enables the user to specify pure Java classes as bases and/or interfaces for the wrapped c/c++. * [Java] Old pragmas renamed. Warning given for the moment if used. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 6/25/2001: mkoeppe * Incorporated more build changes contributed by Wyss Clemens for swig/ruby on cygwin. 6/20/2001: cheetah (william fulton) * Makefile mods so that 'make check' uses the swig options in the makefiles * [Java] Removed Generating wrappers message * [Java] NULL pointer bug fix * [Java] Bug fix for Kaffe JVM 6/20/2001: mkoeppe * SWIG_TypeQuery from common.swg now returns a swig_type_info* rather than a void*. This fixes a problem when using pointer.i and C++, as illustrated by the new test-suite example perl5/pointer-cxx. * Portability fixes (const char *). * Incorporated build changes contributed by Wyss Clemens , which make swig runnable on cygwin. 6/19/2001: cheetah (william fulton) * [Java] Bug fix for SF bug #211144. This fix is a workaround until fixed in the core. 6/19/2001: mkoeppe * [Guile]: Portability fixes for use with the Sun Forte compilers. * [Tcl]: Portability fix (const char *). * [Tcl]: Configure now first tries to find a tclConfig.sh file in order to find the Tcl include directory, library location and library name. * [Python]: Added a few possible library locations. 6/18/2001: mkoeppe * [Guile]: Don't call scm_c_export if nothing is to be exported. Don't warn on %module if module has been set already (this frequently occurs when %import is used). 6/16/2001: mkoeppe * [Guile]: New "passive" linkage, which is appropriate for multi-module extensions without Guile module magic. 6/15/2001: mkoeppe * [Guile]: Fixed printing of smobs (space and angle were missing). * Properly generate type information for base classes imported with the %import directive. Thanks to Marcelo Matus for the report and the patch; this closes SF bug #231619; see also Examples/guile/test-suite/import*. * [Guile]: Fix casting between class and base class; the runtime type system had it the wrong way around; see Examples/guile/test-suite/casts.i * Make typemaps for SWIGPOINTER * with arg name take precedence over those without arg name, to match normal typemap precedence rules. * Fixed the random-line-numbers problem reported as SF bug #217310; thanks to Michael Scharf . * [Guile]: Handle the %name and %rename directives. * New syntax: %name and %rename now optionally take double quotes around the scripting name. This is to allow scripting names that aren't valid C identifiers. 6/14/2001: beazley Made a minor change to the way files are loaded in order to get file/line number reporting correct in the preprocessor. 6/14/2001: mkoeppe * The parser now understands the (non-standard) "long long" types. It is up to the individual language modules to provide typemaps if needed. Reported by Sam Steingold, SF bug #429176. * The parser now understands arguments like "const int * const i". This fixes SF bug #215649. * Fixed the Guile test-suite. 6/13/2001: mkoeppe Partial merge from the CVS trunk at tag "mkoeppe-merge-1". This covers the following changes: | 01/16/01: ttn | Wrote table of contents for Doc/engineering.html. Added section | on CVS tagging conventions. Added copyright to other docs. | 9/25/00 : beazley | Modified the preprocessor so that macro names can start with a '%'. | This may allow new SWIG "directives" to be defined as macros instead | of having to be hard-coded into the parser. | | *** Also a yet-to-be-documented quoting mechanism with backquotes | *** has been implemented? 6/13/2001: mkoeppe * When configure does not find a language, don't use default paths like /usr/local/include; this only causes build problems. * New directory: Examples/Guile/test-suite, where a few bugs in 1.3a5 are demonstrated. * Handle C++ methods that have both a "const" and a "throw" directive (see Examples/Guile/test-suite/cplusplus-throw.i); thanks to Scott B. Drummonds for the report and the fix. * Handle C++ pointer-reference arguments (like "int *& arg") (see Examples/Guile/test-suite/pointer-reference.i, reported as SF bug #432224). * [Ruby] Fixed typo in rubydec.swg; thanks to Lyle Johnson! * Don't stop testing when one test fails. * [Guile, MzScheme] Don't print "Generating wrappers...". 6/12/2001: mkoeppe [Guile] VECTORLENINPUT and LISTLENINPUT now have separate list length variables. TYPEMAP_POINTER_INPUT_OUTPUT attaches argument documentation involving SCM_TYPE to the standard pointer typemaps. INOUT is now an alias for BOTH. 6/12/2001: cheetah (william fulton) Some Java documentation added. [Java] Fixed bugs in import pragma and shadow pragma. 6/12/2001: mkoeppe Fix declarations of SWIG_define_class (Lib/ruby/rubydec.swg) and SWIG_TypeQuery (Lib/common.swg). Thanks to Lyle Johnson for the patches. 6/11/2001: mkoeppe [Guile] Use long instead of scm_bits_t; this makes the generated wrapper code compatible with Guile 1.3.4 again. Thanks to Masaki Fukushima for pointing this out. 6/11/2001: cheetah (william fulton) The generic INSTALL file from autoconf added. Few changes to README file. 6/11/2001: mkoeppe Fixed typo in Makefile.in; thanks to Greg Troxel . 6/08/2001: cheetah (william fulton) make check works again. Examples/GIFPlot configure generated by top level autoconf now. 6/08/2001: mkoeppe Another build change: The new script autogen.sh runs autoconf in the appropriate directories. The top-level configure also configures in Examples/GIFPlot. 6/07/2001: mkoeppe Made the Makefile work with non-GNU make again. 6/07/2001: cheetah (william fulton) [Java] Class/struct members that are arrays of pointers to classes/structs - Shadow class's get/set accessors now use Java classes instead of longs (pointers). [Java] Shadow classes will now clean up memory if function return type is a class/struct. [Java] New example called reference based on the same example from other modules. 6/06/2001: mkoeppe New configure option --with-release-suffix allows for attaching a suffix to the swig binary and the swig runtime libraries. Minor changes to the build system. "swig -swiglib" works again. If invoked with the new option "-ldflags", SWIG prints a line of linker flags needed to link with the runtime library of the selected language module. 6/06/2001: mkoeppe [Guile] gswig_list_p is an int, not a SCM. This typo caused warnings when compiling with a Guile configured with strict C type checking. In INPUT and BOTH typemaps generated by the SIMPLE_MAP macro, use the SCM_TO_C function to convert from Guile to C (rather than C_TO_SCM). Use scm_intprint to print pointers (rather than sprintf). Allow using "-linkage" instead of "-Linkage". 6/05/2001: cheetah (william fulton) [Java] Mods for using inherited c++ classes from Java [Java] New example called class based on the same example from other modules 6/05/2001: cheetah (william fulton) [Java] destructor (_delete()) was not aware of %name renaming [Java] extends baseclass did not know about %name renaming [Java] extends baseclass did extend even when the baseclass was not known to swig [Java] sometimes enum-declarations occurred before the Java class declaration [Java] unrelated enum initialisations no longer appear in Java class [Java] if module ends in '_' correct JNI names are now produced 6/04/2001: cheetah (william fulton) [Java] Shadow class mods - Modified constructor replaces newInstance(). _delete() now thread safe. getCPtr() replaces _self. _selfClass() removed as now redundant. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** [Java] Not all output java files had SWIG banner. New banner. [Java] Shadow class finalizers are output by default: Command line option -finalize deprecated and replaced with -nofinalize. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 6/ 1/2001: mkoeppe [Guile] Cast SCM_CAR() to scm_bits_t before shifting it. This is required for compiling with a Guile configured with strict C type checking. 6/ 1/2001: mkoeppe Added configure option "--with-swiglibdir". 5/31/2001: mkoeppe [Guile] Support multiple parallel lists or vectors in the typemaps provided by list-vector.i. New typemaps file, pointer-in-out.i. 5/25/2001: cheetah (william fulton) [Java] HTML update for examples. 5/28/2001: mkoeppe Minor changes to the build system. Added subdirectory for Debian package control files. 5/28/2001: mkoeppe [Guile] Build a runtime library, libswigguile. 5/28/2001: mkoeppe [Guile] New typemap substitution $*descriptor. Use the {} syntax, rather than the "" syntax for the standard typemaps, in order to work around strange macro-expansion behavior of the SWIG preprocessor. This introduces some extra braces. 5/27/2001: mkoeppe [Guile] Handle pointer types with typemaps, rather than hard-coded. New typemap substitutions $descriptor, $basedescriptor; see documentation. Some clean-up in the variable/constants wrapper generator code. New convenience macro SWIG_Guile_MustGetPtr, which allows getting pointers from smobs in a functional style. New typemap file "list-vector.i", providing macros that define typemaps for converting between C arrays and Scheme lists and vectors. 5/25/2001: cheetah (william fulton) [Java] STL string moved into its own typemap as it is c++ code and it break any c code using the typemaps.i file. - Fixes for wrappers around global variables - applies to primitive types and user types (class/struct) and pointers to these. - Structure member variables and class public member variables getters and setters pass a pointer to the member as was in 1.3a3 and 1.1 (1.3a5 was passing by value) - Parameters that were arrays and return types were incorrectly being passed to create_function() as pointers. - Fix for arrays of enums. [Java] Updated java examples and added two more. [Java] Java module updated from SWIG1.3a3 including code cleanup etc. [Java] enum support added. [Java] Array support implemented [Java] Shadow classes improved - Java objects used rather than longs holding the c pointer to the wrapped structure/c++class 5/22/2001: mkoeppe [Guile] Fixed extern "C" declarations in C++ mode. Thanks to Greg Troxel . 5/21/2001: mkoeppe [Guile] New linkage "module" for creating Guile modules for Guile versions >= 1.5.0. 4/18/2001: mkoeppe [MzScheme] Added typemaps for passing through Scheme_Object pointers. 4/9/2001 : mkoeppe [MzScheme] Added typemaps for `bool'. Inclusion of headers and support routines is now data-driven via mzscheme.i. Headers come from the new file mzschemdec.swg. Don't abort immediately when a type-handling error is reported. When searching for typemaps for enums, fall back to using int, like the Guile backend does. Support char constants. Emit correct wrapper code for variables. 3/12/2001: mkoeppe [Guile] Fixed typemaps for char **OUTPUT, char **BOTH. 3/2/2001 : mkoeppe [Guile] Every wrapper function now gets a boolean variable gswig_list_p which indicates whether multiple values are present. The macros GUILE_APPEND_RESULT, GUILE_MAYBE_VALUES and GUILE_MAYBE_VECTOR use this variable, rather than checking whether the current return value is a list. This allows for typemaps returning a list as a single value (a list was erroneously converted into a vector or a multiple-value object in this case). 3/1/2001 : mkoeppe [Guile] Added support for returning multiple values as vectors, or passing them to a muliple-value continuation. By default, multiple values still get returned as a list. 3/1/2001 : mkoeppe [Guile] Added a "beforereturn" pragma. The value of this pragma is inserted just before every return statement. 3/1/2001 : mkoeppe [Guile] Added support for Guile 1.4.1 procedure documentation formats, see internals.html. 2/26/2001: mkoeppe [Guile] Made the wrapper code compile with C++ if the "-c++" command-line switch is given. Thanks to . 2/26/2001: mkoeppe [Guile] Now two type tables, swig_types and swig_types_initial, are used, as all other SWIG language modules do. This removes the need for the tricky construction used before that the broken Redhat 7.0 gcc doesn't parse. Reported by . 2/26/2001: mkoeppe [Guile] Fixed typemaps for char *OUTPUT, char *BOTH; a bad free() would be emitted. Added typemap for SCM. Version 1.3 Alpha 5 =================== 9/19/00 : beazley [Python] Python module generates more efficient code for creating the return value of a wrapper function. Modification suggested by Jon Travis. 9/19/00 : beazley Library files specified with the -l option are now included at the end of the interface file (reverting to the old behavior). 9/19/00 : beazley Fixed some problems with enum handling. enums are now manipulated as 'int', but cast into the enum type when values are passed to the corresponding C function. 9/19/00 : mkoeppe [Guile] Removed "-with-smobs" command-line option, as this is the default now. Added "-emit-setters" command-line option, which turns on generating procedures-with-setters; see internals.html. 9/18/00 : mkoeppe Incorporated patch #101430, fixing bugs in the Guile module: 1. Some arguments were erroneously taken as *optional* arguments when ignored arguments were present. 2. Guile 1.3.4 was not supported since functions introduced in Guile 1.4 were used. 3. Added handling of `const char *'. 9/17/00 : beazley Fixed problem with failed assertion and large files. 9/17/00 : beazley Fixed problem with the '%' character appearing in added methods and function bodies. Preprocessor bug. Version 1.3 Alpha 4 (September 4, 2000) ======================================= 9/3/00 : ttn Added instructions for maintainers in Examples/README on how to make examples also be useful in the testing framework. Also, "make check" now uses ./Lib by via env var `SWIG_LIB'. This is overridable like so: make chk-swiglib=/my/experimental/swig/Lib check 9/3/00 : beazley Added $typemap variable to typemaps. This gets replaced with a string indicating the typemap that is applied. Feature request from rsalz. 9/3/00 : beazley Experimental optimization to code generation for virtual member functions. If you have two classes like this: class A() { virtual void foo(); } class B() : public A { virtual void foo(); } Swig now will generate a single wrapper function for this A_foo(A *a) { a->foo(); } and use it as the implementation of both A_foo() and B_foo(). This optimization only takes place if both methods are declared as virtual and both take identical parameters. *** EXPERIMENTAL FEATURE *** 9/3/00 : beazley Restored the "memberin" typemap for setting structure members. Unlike the old version, the new version is expanded inline in the wrapper function allowing access to scripting language internals (a sometimes requested feature). The "memberout" typemap is gone. Use the "out" typemaps instead. *** POTENTIAL INCOMPATIBILITY *** 9/3/00 : beazley Attribute set methods no longer return the value of a member. For example: struct Foo { int x; ... } now gets set as follows: void Foo_x_set(Foo *f, int x) { f->x = x; } In SWIG1.1 it used to be this: int Foo_x_set(Foo *f, int x) { return (f->x = x); } This has been changed due to the complexity created by trying to do this with more exotic datatypes such as arrays. It also complicates inlining and handling of the "memberin" typemap. *** POTENTIAL INCOMPATIBILITY *** 9/2/00 : beazley Removed the ptrcast() and ptrmap() functions from the pointer.i library file. Old implementation is incompatible with new type system. *** POTENTIAL INCOMPATIBILITY *** 9/2/00 : beazley New runtime function SWIG_TypeQuery(const char *name) added. This function can be used to extract the type info structure that is used for type-checking. It works with either the nice C name or mangled version of a datatype. For example: swig_type_info *ty = Swig_TypeQuery("int *"); swig_type_info *ty = Swig_TypeQuery("_p_int"); This is an advanced feature that has been added to support some exotic extension modules that need to directly manipulate scripting language objects. *** NEW FEATURE *** 9/2/00 : beazley New directive %types() added. This is used to explicitly list datatypes that should be included in the runtime type-checking code. Normally it is never necessary to use this but sometimes advanced extensions (such as the pointer.i library) may need to manually add types to the type-checker. *** NEW FEATURE *** 8/31/00 : beazley Improved handling of string array variables. For example, a global variable of the form "char name[64]" is automatically managed as a 64 character string. Previously this didn't work at all or required the use of a special typemap. *** NEW FEATURE (Tcl, Perl, Python) *** 8/31/00 : ttn Added Makefile target `check-c++-examples', which uses new files under Examples/C++ contributed by Tal Shalif. Now "make check" also does "make check-c++-examples". Also, expanded actions in `check-gifplot-example' and `check-aliveness'. 8/30/00 : mkoeppe Major clean-up in the Guile module. Added typemap-driven documentation system. Changed to handle more than 10 args. Updated and extended examples. *** NEW FEATURE *** 8/29/00 : beazley Added new %insert directive that inserts the contents of a file into a portion of the output wrapper file. This is only intended for use by writers of language modules. Works as follows: %insert(headers) "file.swg"; %insert(runtime) "file.swg"; %insert(wrappers) "file.swg"; %insert(init) "file.swg"; *** NEW FEATURE *** 8/29/00 : beazley Added new %runtime directive which includes code into the runtime portion of the wrapper code. For example: %runtime %{ ... some internal runtime code ... %} There is no practical reason for ordinary users to use this feature (almost everything can be done using %{ ... %} instead). However, writers of language modules may want to use this in language configuration files. *** NEW FEATURE *** 8/28/00 : beazley Typemaps can now be specified using string literals like this: %typemap(in) int "$target = SvIV($source);"; When code is specified like this, it is *NOT* enclosed inside a local scope (as with older typemap declarations). Note: character escape sequences are interpreted in the code string so if you want to include a quote or some other special character, make sure you use a (\). *** NEW FEATURE *** 8/27/00 : beazley Typemaps have been modified to follow typedef declarations. For example, if you have this: typedef int Number; %typemap(in) int { ... get an integer ... } void foo(Number a); The typemap for 'int' will be applied to the argument 'Number a'. Of course, if you specify a typemap for 'Number' it will take precedence (nor will it ever be applied to an 'int'). *** POTENTIAL INCOMPATIBILITY *** 8/27/00 : beazley Default typemap specification has changed. In older versions of swig, you could do this: %typemap(in) int SWIG_DEFAULT_TYPE { ... } To specify the default handling of a datatype. Now that SWIG follows typedef declarations, this is unnecessary. Simply specifying a typemap for 'int' will work for all variations of integers that are typedef'd to 'int'. Caveat, specifying the default behavior for pointers, references, arrays, and user defined types is a little different. This must be done as follows: %typemap() SWIGPOINTER * { ... a pointer ... } %typemap() SWIGREFERENCE & { ... a reference ... } %typemap() SWIGARRAY [] { ... an array ... } %typemap() SWIGTYPE { ... a user-defined type (by value) ... } *** POTENTIAL INCOMPATIBILITY *** 8/15/00 : dustin The file swig-1.3a1-1.spec has been added to the Tools directory. It can be used to build a redhat package for SWIG, although it will need to be updated for the next public release. 8/15/00 : beazley Typemaps have been completely rewritten. Eventually they may be replaced with something better, but for now they stay. However, there are a number of a significant changes that may trip some people up: 1. Typemap scoping is currently broken. Because of this, the following code won't work. %typemap(in) blah * { ... } class Foo { ... int bar(blah *x); } %typemap(in) blah *; /* Clear typemap */ (this breaks because the code for the class Foo is actually generated after the entire interface file has been processed). This is only a temporary bug. 2. In SWIG1.1, the %apply directive worked by performing a very complex type-aliasing procedure. From this point on, %apply is simply a generalized typemap copy operation. For example, %apply double *OUTPUT { double *x, double *y }; Copies *ALL* currently defined typemaps for 'double *OUTPUT' and copies them to 'double *x' and 'double *y'. Most people probably won't even notice this change in %apply. However, where it will break things is in code like this: %apply double *OUTPUT { double *x }; %typemap(in) double *OUTPUT { ... whatever ... } void foo(double *x); In SWIG1.1, you will find that 'foo' uses the 'double *OUTPUT' rule even though it was defined after the %apply directive (this is the weird aliasing scheme at work). In SWIG1.3 and later, the 'double *OUTPUT' rule is ignored because it is defined after the %apply directive. 3. The %clear directive has been modified to erase all currently defined typemaps for a particular type. This differs from SWIG1.1 where %clear only removed rules that were added using the %apply directive. 4. Typemap matching is now performed using *exact* types. This means that things like this %typemap(in) char * { } %typemap(in) const char * { } are different typemaps. A similar rule applies for pointers, arrays, and references. For example: %typemap(in) double * { } used to apply to 'double &', 'double []', Now, it only applies to 'double *'. If you want a 'double &', you'll need to handle that separately. 5. Array matching has been simplfied. In SWIG1.1, array matching was performed by trying various combinations of dimensions. For example, 'double a[10][20]' was matched as follows: double [10][20] double [ANY][20] double [10][ANY] double [ANY][ANY] In SWIG1.3, only the following matches are attempted: double [10][20] double [ANY][ANY] On the positive side, typemap matching is now *significantly* faster than before. *** POTENTIAL INCOMPATIBILITY *** 8/15/00 : beazley Secret developer feature. Since datatypes are now represented as strings internally, you can bypass limitations of the parser and create a wild datatype by simply enclosing the raw string encoding in backticks (``) and sticking it in the interface file anywhere a type is expected. For example, `a(20).a(10).p.f(int,int)`. This feature is only intended for testing (i.e., you want to see what happens to your language module if it gets a reference to a pointer to an array of pointers to functions or something). *** SICK HACK *** 8/14/00 : beazley Completely new type-system added to the implementation. More details later. 8/11/00 : beazley Cleaned up some of the I/O handling. SWIG no longer generates any temporary files such as _wrap.wrap, _wrap.ii, _wrap.init. Instead, these "files" are kept around in memory as strings (although this is transparent to language modules). 8/4/00 : ttn Added Makefile target "check" and variants. This can be used like "make check" or, to explicitly skip a language LANG: "make skip-LANG=true check". LANG is skipped automatically if ./configure determines that LANG support is insufficient. Currently, the check is limited to doing the equivalent of "make all" in some of the Examples directories. This should be expanded both horizontally (different types of tests) and vertically (after "make all" in an Examples subdir succeeds, do some additional tests with the resulting interpreter, etc). 8/4/00 : ttn Added Makefile target "distclean", which deletes all the files ./configure creates, including config.status and friends. 8/3/00 : harcoh java changes??? [todo: document changes] 7/23/00 : beazley Typemaps have been modified to key off of the real datatypes used in the interface file. This means that typemaps for "const char *" and "char *" will be difference as will typemaps for "Vector" and "Vector *." *** POTENTIAL INCOMPATIBILITY *** This is likely to break interfaces that rely on the odd type handling behavior of typemaps in SWIG1.1--especially with respect to interfaces involving pass-by-value. 7/23/00 : beazley New %constant directive. This directive can be used to create true constants in the target scripting language. It's most simple form is something like this: %constant FOO 42; In this case, the type is inferred from the syntax of the value (in reality, all #define macros are translated into directives of this form). An expanded version is as follows: %constant(Foo *) FOO = &FooObj; In this case, an explicit type can be specified. This latter form may be useful for creating constants that used to be specified as const Foo *FOO = &FooObj; (which are now treated as variables). *** EXPERIMENTAL FEATURE *** The syntax may change in the final release. 7/23/00 : beazley Modified the parser so that variable declarations of the form "const type *a" are handled as variables, not constants. Note: SWIG1.1 handled this case erroneously because const char *a is a pointer variable that can be reassigned. *** POTENTIAL INCOMPATIBILITY *** Note: just because this is the "right" way to do things, doesn't mean it's the most appropriate interpretation. I suspect that many C programmers might use 'const char *' with the intent of creating a constant, without realizing that they've created a reassignable global variable. 7/23/00 : beazley The C/C++ wrapping layer has been completely redesigned and reimplemented. This change should iron out a few rough spots with the handling of datatypes. In addition, the wrapper code is somewhat cleaner. *** POTENTIAL INCOMPATIBILITY *** This change may break interfaces that involve subtle corner-cases with typemaps and the %addmethods directive since some of these features had somewhat type handling behavior in SWIG1.1. 7/23/00 : beazley The "memberin" and "memberout" typemaps are gone for the moment, but they might return as soon as I figure out how to integrate them with some of the streamlined C wrapper functions. *** POTENTIAL INCOMPATIBILITY *** 7/22/00 : beazley A variety of old type handling functions such as print_type(), print_full(), print_mangle(), etc... are gone and have been replaced with a smaller set of functions. See the file Doc/internals.html for details. This will break all third party language modules. *** POTENTIAL INCOMPATIBILITY *** 7/20/00 : beazley Deprecated the %val and %out directives. These directives shouldn't really be necessary since typemaps can be used to achieve similar results. This also cleans up the handling of types and parameters quite a bit. *** POTENTIAL INCOMPATIBILITY *** 7/20/00 : ttn Fixed unspecified-module bug in Guile support and removed more non-"with-smobs" functionality using patches submitted by Matthias Koeppe. Re-enable recognition of "-with-smobs" (with no effect since we use smobs by default now) for the time being. After the 1.3a4 release, this option will signal an error. 7/17/00 : ttn Fixed NULL-input bug in parameter list handling. Reported by Matthias Koeppe. 7/12/00 : beazley Fixed memory leak in Python type-checking code. Reported by Keith Davidson. Bug #109379. 7/10/00 : beazley Changed internal data structures related to function parameters. 7/10/00 : beazley Fixed some bugs related to the handling of the %name() directive and classes in the Tcl module. Problem reported by James Bailey. 7/10/00 : beazley Fixed parsing and enum handling problems with character constants. Reported by Greg Kochanski. 7/10/00 : beazley Removed WrapperFunction class from the core and updated the language module. This will break third party modules. *** POTENTIAL INCOMPATIBILITY *** 7/9/00 : beazley Implementation of SWIG no longer makes use of C++ operator overloading. This will almost certainly break *all* third party language modules that are not part of the main SWIG CVS tree. Sorry. *** POTENTIAL INCOMPATIBILITY *** 7/8/00 : beazley Removed the experimental and undocumented "build" typemap that was intended to work with multiple arguments. Simply too weird to keep around. Besides, a better replacement is in the works. 7/6/00 : ttn Removed non-"with-smobs" functionality (Guile support), i.e., "-with-smobs" is now the default and no longer needs to be specified on the command-line. 7/5/00 : ttn Incorporated Ruby support contributed by Masaki Fukushima. 6/28/00 : ttn Applied more-than-10-args bugfix patch contributed by Matthias Koeppe. 6/27/00 : beazley Rewrote some of the string handling and eliminated the C++ implementation (which is now just a wrapper). 6/27/00 : ttn Added Doc/index.html and Doc/internals.html. The target audience for the latter is new SWIG developers. Version 1.3 Alpha 3 (June 18, 2000) =================================== 6/18/00 : beazley Removed the naming.cxx, hash.cxx, and symbol.cxx files from the SWIG1.1 directory. Continued to migrate things away from the C++ base (although there's still a lot of work to do). 6/17/00 : beazley Added a few more examples to the Examples directory. Still need to do a lot of work on this. 6/16/00 : beazley Added -includeall to follow all #include statements in the preprocessor. 6/15/00 : beazley Tried to fix as many C++ warnings as possible when compiling with the Sun Workshop C++ compiler. Unfortunately, this means that there are a lot of statements that contain string literals of the form (char*)"Blah". 6/15/00: beazley A variety of cleanup and performance optimization in the low-level DOH library. This seems to result in a speedup of 50-100% for preprocessing and other related tasks. 5/10/00 : ttn Applied variable-wrapping bugfix patch contributed by Matthias Koeppe. 4/17/00 : ttn Updated MzScheme support contributed by Oleg Tolmatcev. We now use a `Scheme_Type'-based structure to wrap pointers. 4/11/00 : ttn Incorporated further Guile-support patch by Matthias Koeppe. Typemaps previously deleted have been re-added. There is now exception handling (see Doc/engineering.html). `SWIG_init' is now declared extern only for simple linkage. Some bugs were fixed. 4/06/00 : ttn Incorporated MzScheme support contributed by Oleg Tolmatcev. This includes new directories Lib/mzscheme and Examples/mzscheme. 4/03/00 : ttn Added Examples/guile and children. This is an adaptation of the same-named directory from the SWIG-1.1p5 distribution. Added Guile-specific section to Doc/engineering.html. 4/02/00 : ttn Incorporated new guilemain.i by Martin Froehlich. Incorporated Guile-support rewrite patch by Matthias Koeppe. The command line option "-with-smobs" enables implementation of pointer type handling using smobs, the canonical mechanism for defining new types in Guile. Previous implementation (using strings) is at the moment still supported but deprecated. At some point, "-with-smobs" will be the default and no longer required. 3/13/00 : beazley Added purify patches submitted by Ram Bhamidipaty. 3/02/00 : ttn Added support for different Guile "linkage" schemes. Currently, "-Linkage hobbit" works. Version 1.3 Alpha 2 (March 1, 2000) =================================== 2/29/00 : beazley Made SWIG ignore the 'mutable' keyword. 2/29/00 : beazley Incorporated some patches to the Perl5 module related to the -hide option and the destruction of objects. Patch submitted by Karl Forner. 2/27/00 : ttn Incorporated Guile support contributed by Matthias Koeppe. This includes a cpp macro in Lib/guile/guile.swg and the entire file Lib/guile/typemaps.i. 2/25/00 : ttn Modified configure.in and Makefile.in files to support non-local build (useful in multi-arch environments). 2/24/00 : ttn Incorporated Guile support contributed by Clark McGrew. This works with Guile 1.3, but since it depends heavily on the gh_ interface, it should work for all later versions. It has not been tested with versions before 1.3. WARNING: Code is unstable due to experimentation by ttn. 2/16/00 : beazley A variety of performance improvements to the Python shadow class code generation. Many of these result in substantial runtime performance gains. However, these have come at a cost of requiring the use of Python 1.5.2. For older versions, use 'swig -noopt -python' to turn off these optimization features. Version 1.3 Alpha 1 (February 11, 2000) ======================================= 2/11/00 : Added 'void' to prototype of Python module initializer. Reported by Mark Howson (1/20/00). 2/11/00 : beazley Modified the Python shadow class code to discard ownership of an object whenever it is assigned to a member of another object. This problem has been around for awhile, but was most recently reported by Burkhard Kloss (12/30/99). 2/11/00 : beazley Added braces around macros in the exception.i library. Reported by Buck Hodges (12/19/99) 2/11/00 : beazley Fixed bug in the constraints.i library. Reported by Buck Hodges (12/14/99) 2/11/00 : beazley The %native directive now generates Tcl8 object-style command calls. A full solution for Tcl7 and Tcl8 is still needed. Patch suggested by Mike Weiblen (11/29/99) 2/11/00 : beazley Modified the typemap code to include the $ndim variable for arrays. Patch provided by Michel Sanner (11/12/99). 2/11/00 : beazley Modified the Python module to raise a Runtime error if an attempt is made to set a read-only member of a shadow class. Reported by Michel Sanner (11/5/99). 2/10/00 : The documentation system has been removed. However, it is likely to return at some point in the future. 2/1/00 : Added a number of performance enhancements to the Python shadow classing and type-checking code. Contributed by Vadim Chugunov. 1. Remove _kwargs argument from the shadow wrappers when -keyword option is not specified. This saves us a construction of keyword dictionary on each method call. def method1(self, *_args, **_kwargs): val = apply(test2c.PyClass1_method1, (self,) + _args, _kwargs) return val becomes def method1(self, *_args): val = apply(test2c.PyClass1_method1, (self,) + _args) return val 2. Incorporate self into the _args tuple. This saves at least one tuple allocation per method call. def method1(self, *_args): val = apply(test2c.PyClass1_method1, (self,) + _args) return val becomes def method1(*_args): val = apply(test2c.PyClass1_method1, _args) return val 3. Remove *Ptr classes. Assume that we are SWIGging a c++ class CppClass. Currently SWIG will generate both CppClassPtr class that hosts all methods and also CppClass that is derived from the former and contains just the constructor. When CppClass method is called, the interpreter will try to find it in the CppClass's dictionary first, and only then check the base class. CppClassPtr functionality may be emulated with: import new _new_instance = new.instance def CppClassPtr(this): return _new_instance(CppClass, {"this":this,"thisown":0}) This saves us one dictionary lookup per call. The new module was first added in Python-1.5.2 so it won't work with older versions. I've implemented an alternative that achieves the same thing 4. Use CObjects instead of strings for pointers. Dave: This enhancements result in speedups of up to 50% in some of the preliminary tests I ran. 2/1/00 : Upgraded the Python module to use a new type-checking scheme that is more memory efficient, provides better performance, and is less error prone. Unfortunately, it will break all code that depends on the SWIG_GetPtr() function call in typemaps. These functions should be changed as follows: if (SWIG_GetPtr(string,&ptr,"_Foo_p")) { return NULL; } becomes if (SWIG_ConvertPtr(pyobj, &ptr, SWIG_TYPE_Foo_p) == -1) { return NULL; } Note: In the new implementation SWIG_TYPE_Foo_p is no longer a type-signature string, but rather an index into a type encoding table that contains type information. *** POTENTIAL INCOMPATIBILITY *** 1/30/00 : loic Conditionally compile experimental code with --enable-experiment configure flag. Fix .cvsignore to ignore configure & yacc generated files 1/28/00 : loic Apply automake everywhere Keep configure scripts so that people are not *forced* to autoconf Keep sources generated by yacc so that compilation without yacc is possible. Source/LParse/cscanner.c: change lyacc.h into parser.h to please default yacc generation rules. Use AC_CONFIG_SUBDIRS in configure.in instead of hand made script. Update all relevant .cvsignore to include .deps Fixed missing ; line 136 Source/Swig/swig.h 1/13/00 : beazley Fixed a number of minor end-of-file parsing problems in the preprocessor. 1/13/00 : beazley Added -freeze option that forces SWIG to freeze upon exit. This is only used as a debugging tool so that I can more easily examine SWIG's memory footprint. 1/13/00 : beazley Added patch to guile module for supporting optional arguments Patch contributed by Dieter Baron. 1/13/00 : loic Added .cvsignore, Examples/.cvsignore, Source/DOH/Doh/.cvsignore Source/SWIG1.1/main.cxx: Fixed -I handling bug Source/Modules1.1/java.cxx: fixed char* -> const char* warnings that are errors when compiling with gcc-2.95.2 Source/SWIG1.1/main.cxx: cast const char* to char* for String_replace token and rep should really be const. 1/12/00 : beazley Added Harco's Java modules. 1/12/00 : beazley Revoked the %ifdef, %ifndef, %endif, %if, %elif, and %else directives. These are no longer needed as SWIG now has a real preprocessor. *** POTENTIAL INCOMPATIBILITY *** 1/12/00 : beazley Moved the documentation modules from the SWIG directory to the Modules directory (where they really should have been to begin with). 1/12/00 : beazley Removed the -stat option for printing statistics. The statistics reporting was inadequate and mostly broken anyway. *** POTENTIAL INCOMPATIBILITY *** 1/12/00 : beazley Removed the -t option for reading a typemap file. More trouble than it's worth. Just include typemaps at the top of the interface file. *** POTENTIAL INCOMPATIBILITY *** 1/12/00 : beazley Removed the %checkout directive. *** POTENTIAL INCOMPATIBILITY *** 1/12/00 : beazley Removed the -ci option for file checkin. Too problematic to implement. Probably better to just put your SWIG library under CVS instead. *** POTENTIAL INCOMPATIBILITY ***. 1/11/00 : beazley Deleted the LATEX module. Sorry... Didn't know anyone who was using it. Besides, I'm looking to simplify the documentation system. *** POTENTIAL INCOMPATIBILITY *** 1/11/00 : beazley Modified the ASCII documentation module to use a .txt suffix for its output file instead of .doc. 1/11/00 : beazley Added the long-lost SWIG preprocessor back to the system. It should be enabled by default. Raw preprocessed output can be viewed using swig -E file.i. *** NEW FEATURE *** 1/11/00 : beazley and djmitche Completely reorganized the SWIG directory structure. The basic organization is now: Source/ SWIG source code Lib/ SWIG library files (swig_lib) Doc/ Documentation Examples/ Examples More directories will be added as needed. 12/08/99: Loic Dachary (loic@senga.org) Enhanced package handling for perl5 and c++. With new option -hide Foo::Bar, every perl5 object (Frob) is qualified by Foo::Bar::Frob. The package name is solely used to encapsulate C/C++ wrappers output in _wrap.c and the corresponding perl package in .pm. Note that a package name may contain :: (Frob::Nitz) and will be relative to the package name provided by -hide (Foo::Bar::Frob::Nitz). In *_wrap.c, SWIG_init macro is used. Was previously defined but not used and simplifies code. Added typemap(perl5,perl5in) and typemap(perl5,perl5out) that do the equivalent of typemap(perl5,in) and typemap(perl5,out) but contain perl code and applies to wrappers generated by -shadow. Lacking proper regression tests I used Examples/perl5/{c++,constraint,defarg,except, graph/graph[1234],multinherit,nested,shadow,simple,tree, typemaps/{argv,argv2,arraymember,database,file,ignore,integer, output,passref,reference,return}}/. I ran swig with and without the patches, diff the generatedsources, run the .pl files and checked that the results are identical. In all those examples I had no error. 11/21/99: Modified the Tcl module to provide full variable linking capabilities to all datatypes. In previous versions, a pair of accessor functions were created for datatypes incompatible with the Tcl_LinkVar() function. Now, we simply use variable traces to support everything. This may break scripts that rely upon the older behavior. *** POTENTIAL INCOMPATIBILITY *** 11/21/99: Added slight tweak to wrapper generator to collect local variables of similar type. Produces somewhat more compact wrapper code. 11/20/99: Modified the Tcl module to use SWIG_GetArgs() to parse arguments. This is a technique borrowed from Python in which arguments are converted using a format string convention similiar to fprintf(). This results in a *substantial* reduction in the size of the resulting wrapper code with only a modest runtime overhead in going through the extra conversion function. 11/13/99: Completely rewrote the class/structure generation code for the Tcl module. Now, a small set of runtime functions are used to implement the functionality for all classes (instead of a massive amount of runtime code being generated for each class). Class specific information is simply encoded in a series of static tables. This results in a *HUGE* reduction in wrapper code size--especially for C++. 11/13/99: Removed the -tcl (Tcl 7.x) module. Tcl 8.0 is now several years old and the defacto standard--no real reason to keep supporting the old version at this point. 11/13/99: Cleaned up -c option for Python module. The pyexp.swg file is now gone. 11/13/99: Fixed external declarations to work better with static linking on Windows. Static linking should now be possible by defining the -DSTATIC_LINK option on the command line. Patch contributed by Alberto Fonseca. 11/5/99 : Fixed an obscure code generation bug related to the generation of default constructors. Bug reported by Brad Clements. 11/5/99 : Fixed a few memory problems found by purify. 11/5/99 : Officially deprecated the -htcl, -htk, and -plugin options from the Tcl and Tcl8 modules. 10/26/99: Removed unused variable from python/typemaps.i. Patch contributed by Keith Davidson. 8/16/99 : Added _WIN32 symbol to libraries to better support Windows. 8/16/99 : Deprecated the Perl4 module. It is no longer included in the distribution and no longer supported. In the entire 3 years SWIG has been around I never received a single comment about it so I'm assuming no one will miss it... 8/16/99 : Modified the type-checking code to register type mappings using a table instead of repeated calls to SWIG_RegisterMapping(). This reduces the size of the module initialization function somewhat. 8/15/99 : Cleaned up the pointer type-checking code in the Tcl module. 8/15/99 : Many changes to the libraries to support runtime libraries. 8/13/99 : Eliminated C++ compiler warning messages about extern "C" linkage. 8/13/99 : Some cleanup of Python .swg files to better support runtime libraries on Windows. 8/13/99 : Modified the %pragma directive to attach pragmas declared inside a class definition to the class itself. For example: class foo { ... %pragma(python) addtomethod = "insert:print `hello world'" ... } Most people don't need to worry about how this works. For people writing backend modules, class-based pragmas work like this: lang->cpp_open_class() // Open a class lang->cpp_pragma() // Supply pragmas ... // Emit members lang->cpp_close_class() // Close the class All of the pragmas are passed first since they might be used to affect the code generation of other members. Please see the Python module for an example. Patches contributed by Robin Dunn. 8/13/99 : Patch to Python shadow classes to eliminate ignored exception errors in destructors. Patch contributed by Robin Dunn. 8/11/99 : Minor patch to swig_lib/python/swigptr.swg (added SWIGSTATIC declaration). Patch contributed by Lyle Johnson. 8/11/99 : Added FIRSTKEY/NEXTKEY methods to Perl5 shadow classes Patch contributed by Dennis Marsa. 8/11/99 : Modified Python module so that NULL pointers are returned and passed as 'None.' Patch contributed by Tal Shalif. 8/10/99 : Fixed missing 'int' specifiers in various places. 8/10/99 : Added Windows makefile for Runtime libraries. Contributed by Bob Techentin. 8/10/99 : Fixed minor problem in Python runtime makefile introduced by keyword arguments. 8/8/99 : Changed $target of perl5(out) typemap from ST(0) to ST(argvi). Patch contributed by Geoffrey Hort. 8/8/99 : Fixed bug in typemap checking related to the ANY keyword in arrays and ignored arguments. Error reported by Geoffrey Hort. 8/8/99 : %enabledoc and %disabledoc directives can now be used inside class/structure definitions. However, no check is made to see if they are balanced (i.e., a %disabledoc directive inside a class does not have to have a matching %enabledoc in the same class). 8/8/99 : Keyword argument handling is now supported in the Python module. For example: int foo(char *bar, int spam, double x); Can be called from Python as foo(x = 3.4, bar="hello", spam=42) To enable this feature, run SWIG with the '-keyword' command line option. Mixing keyword and default arguments should work as well. Unnamed arguments are assigned names such as "arg1", "arg2", etc... *** POTENTIAL INCOMPATIBILITY *** Functions with duplicate argument names such as bar(int *OUTPUT, int *OUTPUT) will likely cause problematic wrapper code to be generated. To fix this, use different names or use %apply to map typemaps to alternate names. 8/8/99 : Handling of the 'this' pointer has been changed in Python shadow classes. Previously, dereferencing of '.this' occurred in the Python shadow class itself. Now, this step occurs in the C wrappers using the following function: SWIG_GetPtrObj(PyObject *, void **ptr, char *type) This function can accept either a string containing a pointer or a shadow class instance with a '.this' attribute of appropriate type. This change allows the following: 1. The real shadow class instance for an object is passed to the C wrappers where it can be examined/modified by typemaps. 2. Handling of default/keyword arguments is now greatly simplified. 3. The Python wrapper code is much more simple. Plus, it eliminated more than 300 lines of C++ code in the Python module. *** CAVEAT : This requires the abstract object interface. It should work with Python 1.4, but probably nothing older than that. 8/8/99 : Fixed handling of "const" and pointers in classes. In particular, declarations such as class foo { ... const char *msg; const int *iptr; } are handled as assignable variables as opposed to constant values (this is the correct behavior in C/C++). Note: declarations such as "char *const msg" are still unsupported. Constants declared at the global level using const are also broken (because I have a number of interfaces that rely upon this behavior). *** POTENTIAL INCOMPATIBILITY *** This may break interfaces that mistakenly treat 'const char *' types as constant values. 8/8/99 : Modified the parser to support bit-fields. For example: typedef struct { unsigned int is_keyword : 1; unsigned int is_extern : 1; unsigned int is_static : 1; } flags; Bit-fields can only be applied to integer types and their are other restrictions. SWIG performs no such type-checking (although the C compiler will catch problems when it tries to compile the wrapper code). 8/8/99 : Removed trailing space of $basetype substitution in typemaps. This is to allow things like this: %typemap(python, argout) spam** OUTPUT{ ... char* a = "$basetype_p"; ... } (Patch suggested by Nathan Dunfield). 6/22/99 : Made a very slight tweak to the Perl5 shadow class code that allows typemaps to alter the return type of objects (to support polymorphic types). Patch contributed by Drake Diedrich. 4/8/99 : Fixed null pointer handling bug in Perl module. Patch contributed by Junio Hamano. 3/17/99 : Fixed bug in perl5ptr.swg for ActiveState Perl. Patch contributed by Greg Anderson. 2/27/99 : Eliminated segmentation fault when Swig runs on empty files. 2/27/99 : Added patch to Guile module to eliminate unused variables. Contributed by Mike Simons. 2/27/99 : Fixed problem with %addmethods returning references. 2/27/99 : Fixed Runtime/Makefile. Patch contributed by Mike Romberg. 2/27/99 : Incorporated patches to the type-checker. 2/27/99 : Fixed problem with -exportall switch and shadow classes in Perl5 module. Patch contributed by Dennis Marsa. 2/27/99 : Modified Perl5 module to recognize 'undef' as a NULL char *. Patch contributed by Junio Hamano. 2/27/99 : Fixed the Perl5 module to support the newer versions of ActiveState Perl for Win32. 2/27/99 : Fixed the include order of files specified with the -I option. 2/5/98- : Dave finishes his dissertation, goes job hunting, moves to 2/5/99 Chicago and generally thrashes about. Version 1.1 Patch 5 (February 5, 1998) ====================================== 2/4/98 : Fixed a bug in the configure script when different package locations are specified (--with-tclincl, etc...). 2/2/98 : Fixed name-clash bug related to the switch to C macros for accessor functions. The new scheme did not work correctly for objects with members such as 'obj', 'val', etc... Fixed the bug by appending the word 'swig' to macro argument names. Patch contributed by Rudy Albachten. 2/2/98 : Slight fix to the Perl5 module to eliminate warning messages about 'varname used only once : possible typo'. Fix contributed by Rudy Albachten. 1/9/98 : Fixed a bug in the Perl 5 module related to the creation of constants and shadow classes. 1/9/98 : Fixed linking bug with Python 1.5 embed.i library file. Version 1.1 Patch 4 (January 4, 1998) ===================================== 1/4/98 : Changed structured of the Examples directory to be more friendly to Borland C++. 1/4/98 : Added the function Makefile.win.bc for compiling the examples under Borland 5.2. 1/4/98 : Slight change to the perl5 module and C++ compilation. The library is now included before any Perl headers because Perl the extern "C" linkage of math.h screws alot of things up (especially on Windows). 1/2/98 : Change to the Python module that reduces the number of constants created by C++ classes, inheritance, and shadow classes. This modification may introduce a few slight incompatibilities if you attempt to use the non-shadow class interface with shadow classes enabled. Patch contributed by Mike Romberg. 1/2/98 : Support for Tcl 8.0 namespaces has been added. This *replaces* the original SWIG mechanism that assumed [incr Tcl] namespaces. To use namespaces, simply run SWIG with the following options swig -tcl -namespace foo.i This places everything in a namespace that matches the module name swig -tcl -namespace -prefix bar foo.i This places everything in the namespace 'bar' The use of namespaces is new in Tcl 8.0. However, the wrapper code generated by SWIG will still work with all versions of Tcl newer than and including Tcl 7.3/Tk3.6 even if the -namespace option is used. *** POTENTIAL INCOMPATIBILITY *** This change may break existing applications that relied on the -prefix and -namespace options. 1/2/98 : Added the following constants to the Tcl wrapper code SWIG_name - Name of the SWIG module SWIG_prefix - Prefix/namespace appended to command names SWIG_namespace - Name of the namespace SWIG library writers can use these to their advantages. 1/2/98 : Fixed a bug in the Tcl8 module related to the creation of pointer constants (the function SWIG_MakePtr was missing from the wrapper code). 1/2/98 : Added the consthash.i library file to the Tcl and Tcl8 modules. 1/1/98 : Changed and cleaned up the Python typemaps.i file. The following significant changes were made : 1. The OUTPUT typemap now returns Python tuples instead of lists. Lists can be returned as before by using the L_OUTPUT type. If compatibility with older versions is needed, run SWIG with the -DOUTPUT_LIST option. 2. The BOTH typemap has been renamed to INOUT. For backwards compatibility, the "BOTH" method still exists however. 3. Output typemaps now generate less code than before. Changes to typemaps.i may break existing Python scripts that assume output in the form of a list. *** POTENTIAL INCOMPATIBILITY *** 12/31/97: Fixed long overdue problems with the testing scripts and certain makefiles that required the use of the bash shell. Everything should work properly with the standard Bourne shell (sh) now. 12/31/97: Modified typemaps to allow $basetype as a valid local variable. This allows for all sorts of bizarre hackish typemaps that do cool things. Patch contributed by Dominique Dumont. 12/31/97: Switched accessor functions generated for member data to C preprocessor macros (except in cases involving typemaps or char *). 12/31/97: Fixed a bug related to C++ member data involving references. 12/31/97: Changed accessor functions for C++ member functions to preprocessor macros. This cleans up the wrapper code and results in fewer function definitions. 12/31/97: Changed the default C constructor to use calloc() instead of malloc() 12/30/97: Changed the creation of constants in the Perl5 module. For all practical purposes, they should work in exactly the same way as before except that they now require much less wrapper code. Modules containing large numbers of constants may see greater than a 50% reduction in wrapper code size. 12/30/97: Modified the Python module to be more intelligent about the creation of constants. SWIG no longer generates redundant global variables and the size of the module initialization function should be reduced. (Many thanks to Jim Fulton). 12/29/97: Fixed a bug in C++ code generation related to member functions, default arguments, and references. 12/29/97: Fixed configure script and a few makefiles to support Python 1.5 12/29/97: Added 'embed15.i' library file. This file should be used to statically link versions of Python 1.5. To make it the default, simply copy 'swig_lib/python/embed15.i' to 'swig_lib/python/embed.i' Version 1.1 Patch 3 (November 24, 1997) ======================================== 11/23/97: Fixed a bug in the Perl5 module with shadow classes and static class functions that return class instances. Note : The fix for this bug requires a slight restructuring of of the .pm files created by SWIG. 11/23/97: Fixed a bug in the Tcl/Tcl8 modules related to variable linking of character arrays. If you declared a global variable 'char foo[10]', the generated wrapper code would either cause a segmentation fault immediately upon loading or weird memory corruption elsewhere. This should now be fixed although character arrays can only be read-only. 11/23/97: Fixed a bug with the %import directive that caused it to fail if files were imported from directories other than the current working directory. 11/23/97: Fixed incorrect diagnostic message in the ASCII documentation module. 11/23/97: Changed the behavior of the -o option when used with shadow classes. If -o was used to specify both the pathname and filename of SWIG's output such as swig -o /home/swig/wrapper.c -shadow -perl5 foo.i The wrapper code would be placed the file specified with -o, but the .pm file and documentation would be placed in the directory where SWIG was run. Now, these files are placed in the same directory as the file specified with the -o option. This change is also needed for proper operation on the Macintosh. 11/23/97: Added a 'this()' method to Perl5 shadow classes. This can be used to return the normal pointer value from a shadow class that is represented as a tied hash. To use just invoke as a method like this : $l = new List; # Create an object $ptr = $l->this(); # Get the normal pointer value *** NEW FEATURE *** 11/23/97: Fixed the Tcl 8 pointer.i library file (which was completely broken in 1.1p2). 11/23/97: Modified the Perl5 type-checker to fix a few problems with global variables of pointer types and to allow tied hashes to be used interchangably with normal pointer values. 11/23/97: Modified the typemap mechanism to allow output typemaps of type 'void'. These were ignored previously, but now if you specify, %typemap(lang,out) void { ... return a void ... } You can change or assign a return value to the function. 11/23/97: Fixed processing of 'bool' datatypes in the Python module. 11/23/97: Fixed minor parsing error with C++ initializers. For example, class B : public A { public: B() : A() { ... }; ... } 11/23/97: Fixed the Tcl8 module so that C functions that call back into Tcl don't corrupt the return result object (SWIG was gathering the result object too early which leads to problems if subsequent Tcl calls are made). 11/23/97: Fixed a code generation bug in the Python module when two or more output parameters were used as the first arguments of a function. For example : %include typemaps.i void foo(double *OUTPUT, double *OUTPUT, double a); Previously, doing this resulted in the creation of an extraneous comma in the output, resulting in a C syntax error. 11/22/97: Fixed a bug when template handling that was stripping whitespace around nested templates. For example : Foo > was getting munged into Foo> which is a syntax error in in the C++ compiler. 11/22/97: Fixed bugs in the Borland C++ makefiles. 11/22/97: Fixed memory corruption bug when processing integer arguments in Tcl8 module. 11/21/97: Fixed a bug in the Runtime/Makefile related to Tcl 8. 11/21/97: Fixed a bug with the %new directive and Perl5 shadow classes. No longer generates a perl syntax error. 11/9/97 : Changed a strncpy() to strcpy() in the pointer type-checker. This results in a substantial performance improvement in type-checking. 10/29/97: Fixed a bug in the code generation of default arguments and user-defined types. For example : void foo(Vector a, Vector b = d); should now work properly. Version 1.1 Patch 2 (September 4, 1997) ======================================= 9/4/97 : Fixed problem with handling of virtual functions that was introduced by some changes in the C++ module. Version 1.1 Patch 1 (August 27, 1997) ===================================== 8/26/97 : Fixed compilation and run-time bugs with Tcl 8.0 final. 8/21/97 : Fixed code generation bug with arrays appearing as arguments to C++ member functions. For example : class Foo { public: void Bar(int a[20][20]); }; There is still a bug using arrays with added methods however. 8/20/97 : Fixed a bug with generating the code for added methods involving pass-by-value. 8/19/97 : Modified the typemapper to substitute the '$arg' value when declaring local variables. For example : %typemap(in) double * (double temp_$arg) { ... do something ... } When applied to a real function such as the following : void foo(double *a, double *b, double *result); three local variables will be created as follows : double temp_a; double temp_b; double temp_result; This can be used when writing multiple typemaps that need to access the same local variables. 7/27/97 : Fixed a variety of problems with the %apply directive and arrays. The following types of declarations should now work : %apply double [ANY] { Real [ANY] }; %apply double [4] { double [10] }; A generic version of apply like this : %apply double { Real }; should now work--even if arrays involving doubles and Reals are used later. 7/27/97 : Changed warning message about "Array X has been converted to Y" to only appear if running SWIG in verbose mode. 7/27/97 : Added the variables $parmname and $basemangle to the typemap generator. $parmname is the name of the parameter used when the typemap was matched. It may be "" if no parameter was used. $basemangle is a mangled version of the base datatype. Sometimes used for array handling. 7/27/97 : Changed the behavior of output arguments with Python shadow classes. Originally, if a function returned an object 'Foo', the shadow class mechanism would create code like this : def return_foo(): val = FooPtr(shadowc.return_foo()) val.this = 1 return val The problem with this is that typemaps allow a user to redefine the output behavior of a function--as a result, we can no longer make any assumptions about the return type being a pointer or even being a single value for that matter (it could be a list, tuple, etc...). If SWIG detects the use of output typemaps (either "out" or "argout") it returns the result unmodified like this : def return_foo(): val = shadowc.return_foo() return val In this case, it is up to the user to figure out what to do with the return value (including the possibility of converting it into a Python class). 7/26/97 : Fixed a parsing problem with types like 'unsigned long int', 'unsigned short int', etc... 7/24/97 : Minor bug fix to Tcl 8 module to parse enums properly. Also fixed a memory corruption problem in the type-checker. (patch contributed by Henry Rowley. 7/24/97 : Added Python-tuple typemaps contributed by Robin Dunn. 7/24/97 : Incorporated some changes to the Python module in support of Mark Hammond's COM support. I'm not entirely sure they work yet however. Needs documentation and testing. 7/24/97 : Fixed code generation bugs when structures had array members and typemaps were used. For example : %typemap(memberin) double [20][20] { ... get a double [20][20] ... } struct Foo { double a[20][20]; } Originally, this would generate a compiler-type error when the wrapper code was compiled. Now, a helper function like this is generated : double *Foo_a_set(Foo *a, double val[20][20]) { ... memberin typemap here ... return (double *) val; } When writing typemaps, one can assume that the source variable is an array of the *same* type as the structure member. This may break some codes that managed to work around the array bug. *** POTENTIAL INCOMPATIBILITY *** 7/13/97 : Fixed bug in Perl5 module when using C global variables that are pointers. When used in function calls and other operations, the value of the pointer would be invalid---causing core dumps and other problems. SWIG implements global variables using Perl magic variables. As it turns out, the error was caused by the fact that the pointer-extraction code was somehow bypassing the procedure used to resolve magical variables (hence, leaving the value undefined). To fix the problem, SWIG now explicitly resolves magic before extracting pointer values. 7/12/97 : Eliminated the last remnants of free() and malloc() from the SWIG compiler. 7/12/97 : Fixed parsing problems with typemaps involving arrays and temporary variables of arrays. Also made it possible for SWIG to handle typemaps like this : %typemap(in) double [ANY] (double temp[$dim0]) { ... store data in temp[$dim0] ... } Not only does this typemap match any double [] array, it creates a local variable with precisely the right dimensions. (ie. $dim0 gets filled in with the real number of dimensions). Of course, off the record, this will be a way to add more functionality to the typemaps.i libraries. 7/9/97 : Fixed some problems with Perl5, static linking, and shadow classes. When statically linking multiple modules together, write a top-level interface file like this when shadow classes are not used : %module swig, foo, bar, glob; %include perlmain.i When shadow classes are used, the module names have an extra 'c' appended so it should read as : %module swig, fooc, barc, globc; %include perlmain.i When linking multiple modules, consider using the SWIG runtime library. 7/8/97 : Incorporated fixed versions of the Borland C++ Makefiles. 7/8/97 : First cut at trying to eliminate excessive compiler warnings. As it turns out, alot of warnings go away if you just make declarations like this clientData = clientData; in the resulting wrapper code. Most compilers should just ignore this code (at least would can hope). 7/8/97 : Fixed bizarre code generation bug with typemaps and C++ classes. In some cases, typemaps containing printf formatting strings such as %typemap(memberout) int * { printf("%d",42); } Would generate completely bogus code with garbage replacing the '%d'. Caused by one faulty use of printf (wasn't able to find any other occurrences). 7/7/97 : Fixed bug in Python shadow class generation with non-member functions that are returning more than one value. 7/7/97 : Incorporated modifications to make SWIG work with Guile 1.2. Still need to test it out, but it is rumored to work. 7/2/97 : Fixed some bugs related to output arguments and Python shadow classes. If an output argument is detected, SWIG assumes that the result is a list and handles it appropriately. If the normal return type of an function is an object, it will be converted into a shadow class as before, but with the assumption that it is the first element of a list. *** NOTE : This behavior has been subsequently changed *** 6/29/97 : Changed EXPORT to SWIGEXPORT in all of the language modules. Should provide better compatibility with Windows. 6/29/97 : Modified Python shadow classes so that output arguments work correctly (when typemaps are used). Version 1.1 (June 24, 1997) =========================== 6/24/97 : Fixed Objective-C constructor bug when working with Perl5 shadow classes. 6/23/97 : Fixed some parsing problems with Objective-C. Declarations such as the following should work now : - foo : (int) a with: (int) b; 6/22/97 : Added SWIG Runtime library. This library contains the SWIG pointer type-checker and support functions that are normally included in every module. By using the library, it is easier to work with multiple SWIG generated modules. 6/22/97 : Fixed minor bug in Perl5 module related to static linking of multiple modules. 6/22/97 : Fixed some bugs with the %import directive. When used with Perl5 shadow classes, this generates a 'require' statement to load in external modules. 6/22/97 : Added -swiglib option. This prints out the location of the SWIG library and exits. This option is only really useful to configuration tools that are looking for SWIG and its library location (e.g. autoconf, configure, etc...). 6/21/97 : Fixed export bug with Perl5.004 on Windows-NT. 6/20/97 : Minor change to code generation of class/structure members in order to work better with typemaps. Should have no noticable impact on existing SWIG modules. 6/19/97 : Added -t option. This allows SWIG to load a typemap file before processing any declarations. For example : swig -t typemaps.i -python example.i At most, only one typemap file can be specified in this manner. *** NEW FEATURE *** 6/18/97 : Need a Makefile fast? Type swig [-tcl, -perl5, -python] -co Makefile and you will get a Makefile specific to that target language. You just need to modify it for your application and you're ready to run. 6/18/97 : Completed the -ci option. This option checks a file into the SWIG library. It should be used in conjunction with a language option. For example : swig -tcl -ci foobar.i Checks the file foobar.i into the Tcl part of the library. In order to check a file into the general library (accessible to all languages modules), do the following swig -ci -o ../foobar.i foobar.i (Admittedly this looks a little strange but is unavoidable). The check-in option is primarily designed for SWIG maintenance and library development. The command will fail if the user does not have write permission to the SWIG library. Third party library extensions can easily install themselves by simply providing a shell script that uses 'swig -ci' to install the appropriate library files. It is not necessary to know where the SWIG library is located if you use this mechanism. *** NEW FEATURE *** 6/16/97 : Fixed a bug in shadow class generation when %name() was applied to a class definition. Unfortunately, fixing the bug required a change in the Language C API by adding an extra argument to the Language::cpp_class_decl() function. This may break SWIG C++ extensions. *** POTENTIAL INCOMPATIBILITY *** 6/15/97 : Added a warning message if no module name is specified with the %module directive or -module option. 6/15/97 : Fixed line number bug when reporting errors for undefined base classes. 6/15/97 : Added new %rename directive. This allows the forward declaration of a renaming. For example : %rename OldName NewName; .... later ... int OldName(int); Unlike %name, %rename will rename any occurrence of the old name. This applies to functions, variables, class members and so forth. There is no way to disable %rename once set, but you can change the name by redeclaring it to something else. *** NEW FEATURE *** 6/15/97 : Improved the implementation of the %name directive so that it could be used with conditional compilation : #ifdef SWIG %name(NewName) #endif int OldName(int); 6/15/97 : Added support for functions with no return datatype. In this case, SWIG assumes a return type of 'int'. 6/11/97 : Improved error reporting in the parser. It should be a little less sensitive to errors that occur inside class definitions now. Also reports errors for function pointers. 6/11/97 : Made '$' a legal symbol in identifiers. This is to support some Objective-C libraries. Some compilers (such as gcc) may also allow identifiers to contain a $ in C/C++ code as well (this is an obscure feature of C). When '$' appears in identifier, SWIG remaps it to the string '_S_' when creating the scripting language function. Thus a function 'foo$bar' would be called 'foo_S_bar'. 6/11/97 : Fixed bug in Python shadow classes with __repr__ method. If supplied by the user, it was ignored, but now it should work. 6/9/97 : Fixed the Tcl 8.0 module to work with Tcl 8.0b1. SWIG is no longer compatible with *any* alpha release of Tcl 8.0. *** POTENTIAL INCOMPATIBILITY *** 6/7/97 : Put a maximal error count in (currently set to 20). SWIG will bail out if it generates more errors than this (useful for preventing SWIG from printing 4000 syntax errors when it gets confused). 6/7/97 : Fixed segmentation fault when parsing variable length arguments. 6/7/97 : Minor change to Perl5 module. C++ static functions are now put in the same package as their class when using shadow classes. 6/7/97 : Centralized the naming of functions, members, wrappers etc... By centralizing the naming scheme, it should be possible to make some multi-file optimizations. Also, it should be possible to change SWIG's naming scheme (perhaps a new feature to be added later). 6/2/97 : Added 'arginit' typemap. This can be used to assign initial values to function arguments. Doing so makes it somewhat easier to detect improper argument passing when working with other typemaps. 6/2/97 : Fixed code generation bug when read-only variables were inherited into other classes. Under inheritance, the variables would become writable, but this has now been corrected. 5/30/97 : An empty %name() directive is no longer allowed or supported. This directive was originally used to strip the prefix off of a class or structure. Unfortunately, this never really seemed to work right and it complicated the C++ code generator significantly. As far as I can tell no one uses it, so it is now history. *** POTENTIAL INCOMPATIBILITY *** 5/28/97 : Fixed a parsing bug with #define and C++ comments. Declarations such as the following now work properly : #define CONST 4 // A Comment 5/28/97 : Made some performance improvements to the SWIG String class. (only affects the SWIG compiler itself). 5/28/97 : Modified the parser to skip template definitions and issue a warning message. 5/28/97 : Preliminary support for parameterized types added (ie. templates). Types such as the following should pass through the SWIG compiler void foo(vector *a, vector *b); When used, the entire name 'vector' becomes the name of the datatype. Due to space limitations in datatype representations, the name should not exceed 96 characters. Note : This is only part of what is needed for template support. Template class definitions are not yet supported by SWIG. The template notation above may also be used when specifying Objective-C protocol lists. *** NEW FEATURE *** 5/24/97 : First cut at Objective-C support added. As it turns out, almost everything can be handled with only a few minor modifications to the C++ module. *** NEW FEATURE *** 5/23/97 : Fixed repeated definition bug in multiple inheritance handling when multiple base classes share a common base class (ie. the evil diamond). 5/21/97 : Fixed rather embarrassing typo that worked its way into the Tests/Build directory. 5/19/97 : Fixed code generation bug when using native methods and shadow classes with Python and Perl5 modules. 5/19/97 : Modified the %apply directive slightly so that it would work with pointers a little better. For example : %apply unsigned long { DWORD }; Applies *all* typemaps associated with "unsigned long" to "DWORD". This now includes pointers to the two datatypes. For example, a typemap applied to "unsigned long **" would also be applied to any occurrence of "DWORD **" as well. 5/19/97 : Fixed an ownership assignment bug in the Perl5 module when class members were returning new objects belonging to different classes. 5/17/97 : Added a few more typemap variables. $name - Name of function/variable/member $basetype - Base datatype (type without pointers) $argnum - Argument number 5/16/97 : Fixed embarrassing underscore error in local variable allocator. 5/16/97 : Fixed namespace clash bug in parameterized typemaps when creating arrays as new local variables. 5/15/97 : Fixed some bugs with inheritance of added methods across multiple files. SWIG now uses names of base classes when generating such functions. 5/14/97 : Finished support for default typemaps. Primarily used internally, they can be used to match the basic built-in datatypes used inside of SWIG. You can specify them in interface files as well like this : %typemap(tcl,in) int SWIG_DEFAULT_TYPE { $target = atoi($target); } Unlike normal typemaps, this default map will get applied to *all* integer datatypes encountered, including those renamed with typedef, etc... 5/13/97 : Fixed substring bug in type checker. 5/12/97 : Fixed bug in parameterized typemaps when declaring local variables of structures. Version 1.1 Beta6 (May 9, 1997) =============================== 5/9/97 : Fixed bizarre NULL pointer handling bug in Perl5 module. 5/8/97 : Fixed mysterious segmentation fault when running SWIG on an empty file. 5/7/97 : The code generator will now replace the special symbol "$cleanup" with the cleanup code specified with the "freearg" typemap. This change needed to properly manage memory and exceptions. 5/5/97 : Added the 'typemaps.i' library file. This contains a variety of common typemaps for input values, pointers, and so on. 5/5/97 : Changed behavior of "argout" typemap in Python module. Old versions automatically turned the result into a Python list. The new version does nothing, leaving the implementation up to the user. This provides more flexibility but may break older codes that rely on typemaps. *** POTENTIAL INCOMPATIBILITY *** 5/5/97 : Fixed bug in Python module related to the interaction of "argout" and "ignore" typemaps. 5/5/97 : Fixed bug in Python module that would generate incorrect code if all function arguments are "ignored". 5/4/97 : Added %apply and %clear directives. These form a higher level interface to the typemap mechanism. In a nutshell, they can be used to change the processing of various datatypes without ever having to write a typemap. See the SWIG documentation for more details. ** NEW FEATURE ** 5/4/97 : Added a local variable extension to the typemap handler. For example : %typemap(tcl,in) double *(double temp) { temp = atof($source); $target = &temp; } In this case, 'temp' is a local variable that exists in the entire wrapper function (not just the typemap code). This mechanism provides better support for certain types of argument handling and also makes it possible to write thread-safe typemaps. Any number local variables can be declared by supplying a comma separated list. Local variables are guaranteed to be unique, even if the same typemap is applied many times in a given function. ** Not currently supported in Perl4 or Guile modules. 5/2/97 : Fixed processing of %ifdef, %endif, %if, etc... (These are SWIG equivalents of the C preprocessor directives that can pass through the C preprocessor without modification). 5/2/97 : Fixed major (but subtle) bug in the run-time type checker related to searching and type-checking for C++ inheritance. To make a long story short, if you had two classes named "Foo" and "FooObject" the type checker would sometimes get confused and be unable to locate "Foo" in an internal table. 5/2/97 : Fixed some bugs in the -co option. 4/24/97 : Pointer library added to the SWIG library. 4/19/97 : Added the %new directive. This is a "hint" that can be used to tell SWIG that a function is returning a new object. For example : %new Foo *create_foo(); This tells SWIG that create_foo() is creating a new object and returning a pointer to it. Many language modules may choose to ignore the hint, but when working with shadow classes, the %new is used to handle proper ownership of objects. %new can also be used with dynamically allocated strings. For example : %new char *create_string(); When used, all of the language modules will automatically cleanup the returned string--eliminating memory leaks. ** NEW FEATURE ** 4/19/97 : Added a new typemap "newfree". This is used in conjunction with the %new directive and can be used to change the method by which a new object returned by a function is deleted. 4/19/97 : The symbol "__cplusplus" is now defined in the SWIG interpreter when running with the -c++ option. 4/17/97 : Added support for static member functions when used inside the %addmethods directive. 4/15/97 : Added a special typemap symbol PREVIOUS that can be used to restore a previous typemap. For example : %typemap(tcl,in) int * = PREVIOUS; This is primarily used in library files. 4/13/97 : Added %pragma directive for Perl5 module. Two new pragmas are available : %pragma(perl5) code = "string" %pragma(perl5) include = "file.pl" Both insert code into the .pm file created by SWIG. This can be used to automatically customize the .pm file created by SWIG. 4/13/97 : Scanner modified to only recognize C++ keywords when the -c++ option has been specified. This provides support for C programs that make use of these keywords for identifiers. SWIG may need to be explicitly run with the -c++ option when compiling C++ code (this was allowed, but not recommended in previous versions). **POTENTIAL INCOMPATIBILITY** 4/11/97 : Fixed a rather nasty bug in the Perl5 module related to using variable linking with complex datatypes and pointers. On Unix, code would work (somehow), but would cause an access violation under Windows-NT. The fix should correct the problem, but there may still be a problem using global variables of complex datatypes in conjunction with shadow classes. Fortunately, this sort of thing seems to be relatively rare (considering that the bug has been around for more than a year - yikes!). 4/11/97 : Fixed bizarre constant evaluation bug in Perl5 code generation when running under Windows-NT. 4/8/97 : Bug when using default arguments and C++ references fixed. 4/8/97 : Fixed code generation bugs in Python and Perl5 modules related to using class renaming (applying the %name directive to a class definition) and shadow classes. 4/7/97 : Fixed minor bugs in swigptr.swg, tcl8ptr.swg, and perl5ptr.swg to prevent infinite loops when weird datatypes are passed. 3/29/97 : 'Makefile.win' added. This is used to build most of the examples in the Examples directory under Windows NT/95. 3/27/97 : Fixes to SWIG's error return codes. SWIG now returns non-zero exit codes for certain kinds of errors (which makes it more friendly to makefiles). An overhaul of the error handling is on the to-do list and will probably show up in a later release. 3/25/97 : Bug fix. "freearg" and "argout" typemaps have been fixed in the Perl5 module. In previous versions, function input parameters and function output parameters shared the same memory space--causing all sorts of nasty problems when trying to pass perl values by reference. SWIG now internally makes a "copy" (which is really just a pointer) of affected parameters and uses that. This is done transparently so there is no noticable impact on any SWIG generated modules. This change is probably only noticable to expert users. 3/25/97 : Added type-check to verbose and stat mode. SWIG will now generate a list of all datatypes that were used but undefined (useful for tracking down weird bugs). This is enabled with the -v option (which is now officially known as "overly verbose" mode) or the -stat option. 3/25/97 : Slight change to the parser to make include guards work correctly. For example : #ifndef INTERFACE_I #define INTERFACE_I %module foobar.i ... declarations ... #endif 3/24/97 : %checkout directive added. This allows an interface file to extract files from the SWIG library and place them in the current directory. This can be used to extract scripts and other helper code that might be associated with library files. For example : %checkout array.tcl Will look for a file "array.tcl" in the library and copy it to the current directory. If the file already exists in the directory, this directive does nothing (it will not overwrite an existing file). This only an experimental feature for now. 3/24/97 : SWIG will now look in the SWIG Library for a file if it can't find it in the current directory. As a result, it is easy to make modules from SWIG library files. For example, if you want to make a Python module from the SWIG timers library, just type this in any directory : swig -python timers.i You will get the files timers_wrap.c and timers_wrap.doc in the current directory that you can now compile. The file remains in the SWIG library (although you can check it out using the -co option). *** New Feature *** 3/24/97 : -co option added to SWIG to allow easy access to the SWIG library. When used, this instructs SWIG to check out a library file and place it in the current directory. For example : unix > swig -co array.i array.i checked out from the SWIG library unix > Once in your directory you can customize the file to suit your particular purposes. The checkout option makes it easy to grab library files without knowing anything about the SWIG installation, but it also makes it possible to start including scripts, C code, and other miscellaneous files in the library. For example, you could put a cool script in the library and check it out whenever you wanted to use it. *** New Feature *** 3/24/97 : #pragma export directives added to Tcl output for compiling shared libraries on the Mac. 3/24/97 : Minor changes to wish.i and tclsh.i library files to provide support for the Macintosh. 3/19/97 : SWIG's policy towards NULL pointers has been relaxed. The policy of requiring a special compiler directive -DALLOW_NULL to use NULL pointers is no longer supported. While this may seem "unsafe", it turns out that you can use a "check" typemap to achieve some safety. For example : %typemap(perl5,check) Node * { if (!$target) croak("NULL Pointers not allowed."); } This prevents any NULL value of a "Node *" pointer to be passed to a function. (I think this is much cleaner than the old -DALLOW_NULL hack anyways). 3/19/97 : Fixed pointer handling errors in Perl5 module. Modules no longer core dump when a Perl reference is inadvertently passed in as a C pointer. 3/18/97 : Added a "check" typemap. This can be used to check the validity of function input values. For example : %typemap(perl5,check) int posint { if ($target < 0) croak("Argument is not a positive integer"); } 3/18/97 : Added an $arg variable to Tcl typemaps. This makes it easier to return argument values by "reference". 3/18/97 : Fixed a code generation bug when using C++ references and the %addmethods directive. 3/18/97 : Fixed a few glitches in the typemap module with respect to chaining. For example : %typemap(tcl,in) int { $in // Inserts prexisting typemap printf("Received a %d\n", $target); } This has been allowed for quite some time, but didn't work if no existing typemap was defined. Now, it still doesn't work if no existing typemap is defined, but it issues a warning message. There is some support using default typemaps, but none of the language modules take advantage of it. This should be considered experimental at this time. Version 1.1b5 Patch 1 (March 16, 1997) ====================================== 3/16/97 : Fixed references bug with C++ code generation. 3/16/97 : Fixed initialization bug in the documentation system that was causing weird problems. 3/16/97 : Fixed fatal bug with -c option in the Python module. 3/13/97 : Fixed bug in the documentation system involving the %text directive and sorting. In the old system, %text entries would float to the top of a section because they were "nameless". Now they are attached to the previous declaration and will stay in the proper location relative to the previous entry. Version 1.1b5 (March 12, 1997) ============================== 3/11/97 : Fixed compilation problems introduced by Tcl/Tk 8.0a2. *** INCOMPATIBILITY *** SWIG no longer works with Tcl/Tk 8.0a1. 3/10/97 : Fixed bug with ignored arguments and C++ member functions in the Python module. 3/9/97 : Parsing bugs with nested class definitions and privately declared nested class definitions fixed. 3/9/97 : Fixed a few minor code generation bugs with C++ classes and constructors. In some cases, the resulting wrapper code would not compile properly. SWIG now attempts to use the default copy constructor instead. 3/8/97 : Added a -l option to SWIG that allows additional SWIG library files to be grabbed without having them specified in the interface file. This makes it easier to keep the interface file clean and move certain options into a Makefile. For example : swig -tcl example.i # Build a normal Tcl extension swig -tcl -lwish.i example.i # Build it as a wish extension # by including the 'wish.i' file. swig -python example.i # Build a dynamically loaded extension swig -python -lembed.i example.i # Build a static extension These kinds of options could previously be accomplished with conditional compilation such as : %module example ... #ifdef STATIC %include embed.i #endif 3/8/97 : Incorporated changes to Guile module to use the new gh interface in FSF Guile 1.0. The older gscm interface used in Cygnus Guile releases is no longer supported by SWIG. 3/8/97 : Cleaned up the Tcl Netscape plugin example. It should work with version 1.1 of the plugin now. 3/8/97 : Added better array support to the typemap module. The keyword ANY can now be used to match any array dimension. For example : %typemap(tcl,in) double [ANY] { ... get an array ... } This will match any single-dimensional double array. The array dimension is passed in the variables $dim0, $dim1, ... $dim9. For example : %typemap(tcl,in) double [ANY][ANY][ANY] { printf("Received a double[%d][%d][%d]\n",$dim0,$dim1,$dim2); } Any typemap involving a specific array dimension will override any specified with the ANY tag. Thus, a %typemap(tcl,in) double [5][4][ANY] {} would override a double [ANY][ANY][ANY]. However, overuse of the ANY tag in arrays of high-dimensions may not work as you expect due to the pattern matching rule used. For example, which of the following typemaps has precedence? %typemap(in) double [ANY][5] {} // Avoid this! %typemap(in) double [5][ANY] {} 3/7/97 : Fixed a number of bugs related to multi-dimensional array handling. Typedefs involving multi-dimensional arrays now works correctly. For example : typedef double MATRIX[4][4]; ... extern double foo(MATRIX a); Typecasting of pointers into multi-dimensional arrays is now implemented properly when making C/C++ function calls. 3/6/97 : Fixed potentially dangerous bug in the Tcl Object-oriented interface. Well, actually, didn't fix it but issued a Tcl error instead. The bug would manifest itself as follows: % set l [List] # Create an object ... % set m [List -this $l] # Make $m into an object assuming $l # contains a pointer. # Since $m == $l, $l gets destroyed # (since its the same command name) % $m insert Foo Segmentation fault # Note : the list no longer exists! Now, an error will be generated instead of redefining the command. As in : % set l [List] ... % set m [List -this $l] Object name already exists! Use catch{} to ignore the error. 3/3/97 : Better support for enums added. Datatypes of 'enum MyEnum' and typedefs such as 'typedef enum MyEnum Foo;' now work. 3/3/97 : Parser modified to ignore constructor initializers such as : class Foo : public Bar { int a,b; public: Foo(int i) : a(0), b(i), Bar(i,0) { }; }; 3/3/97 : Modified parser to ignore C++ exception specifications such as : int foo(double) throw(X,Y); 3/3/97 : Added %import directive. This works exactly like %extern except it tells the language module that the declarations are coming from a separate module. This is usually only needed when working with shadow classes. 3/2/97 : Changed pointer type-checker to be significantly more efficient when working with derived datatypes. This has been accomplished by storing type-mappings in sorted order, using binary search schemes, and caching recently used datatypes. For SWIG generated C++ modules that make a large number of C function calls with derived types, this could result in speedups of between 100 and 50000 percent. However, due to the required sorting operation, module loading time may increased slightly when there are lots of datatypes. 3/2/97 : Fixed some C++ compilation problems with Python embed.i library files. 2/27/97 : Slight change to C++ code generation to use copy constructors when returning complex data type by value. 2/26/97 : Fixed bug in Python module with -c option. 2/26/97 : Slight tweak of parser to allow trailing comma in enumerations such as enum Value (ALE, STOUT, LAGER, }; 2/25/97 : Fixed code generation bug in Tcl module when using the %name() directive on a classname. 2/25/97 : Finished code-size optimization of C++ code generation with inheritance of attributes. Inherited attributes now only generate one set of wrapper functions that are re-used in any derived classes. This could provide big code size improvements in some scripting language interfaces. 2/25/97 : Perl5 module modified to support both the Unix and Windows versions. The windows version has been tested with the Activeware port of Perl 5.003 running under Windows 95. The C source generated by SWIG should compile without modification under both versions of Perl, but is now even more hideous than before. 2/25/97 : Modified parser to allow scope resolution operation to appear in expressions and default arguments as in : void foo(int a = Bar::defvalue); 2/25/97 : Fixed bug when resolving symbols inside C++ classes. For example : class Foo { public: enum Value {ALE, STOUT, LAGER}; ... void defarg(Value v = STOUT); }; 2/24/97 : Fixed bug with member functions returning void *. 2/23/97 : Modified Python module to be better behaved under Windows - Module initialization function is now properly exported. It should not be neccessary to explicitly export this function yourself. - Bizarre compilation problems when compiling the SWIG wrapper code as ANSI C under Visual C++ 4.x fixed. - Tested with both the stock Python-1.4 distribution and Pythonwin running under Win95. 2/19/97 : Fixed typedef handling bug in Perl5 shadow classes. 2/19/97 : Added exception support. To use it, do the following : %except(lang) { ... try part of the exception ... $function ... catch part of exception ... } $function is a SWIG variable that will be replaced by the actual C/C++ function call in a wrapper function. Thus, a real exception specification might look like this : %except(perl5) { try { $function } catch (char *& sz) { ... process an exception ... } catch(...) { croak("Unknown exception. Bailing out..."); } } 2/19/97 : Added support for managing generic code fragments (needed for exceptions). 2/19/97 : Fixed some really obscure typemap scoping bugs in the C++ handler. 2/18/97 : Cleaned up perlmain.i file by removing some problematic, but seemingly unnecessary declarations. 2/18/97 : Optimized handling of member functions under inheritance. SWIG can now use wrapper functions generated for a base class instead of regenerating wrappers for the same functions in a derived class. This could make a drastic reduction in wrapper code size for C++ applications with deep inheritance hierarchies and lots of functions. 2/18/97 : Additional methods specified with %addmethods can now be inherited along with normal C++ member functions. 2/18/97 : Minor internal fixes to make SWIG's string handling a little safer. 2/16/97 : Moved some code generation of Tcl shadow classes to library files. 2/16/97 : Fixed documentation error of '-configure' method in Tcl modules. 2/16/97 : Modified Perl5 module slightly to allow typemaps to use Perl references. 2/12/97 : Fixed argument checking bug that was introduced by default arguments (function calls with too many arguments would still be executed). Functions now must have the same number of arguments as C version (with possibility of default/optional arguments still supported). 2/12/97 : Fixed default argument bug in Perl5 module when generating wrapper functions involving default arguments of complex datatypes. 2/12/97 : Fixed typemap scoping problems. For example : %typemap(tcl,in) double { .. get a double .. } class Foo { public: double bar(double); } %typemap(tcl,in) double { .. new get double .. } Would apply the second typemap to all functions in Foo due to delayed generation of C++ wrapper code (clearly this is not the desired effect). Problem has been fixed by assigning unique numerical identifiers to every datatype in an interface file and recording the "range of effect" of each typemap. 2/11/97 : Added support for "ignore" and "default" typemaps. Only use if you absolutely know what you're doing. 2/9/97 : Added automatic creation of constructors and destructors for C structs and C++ classes that do not specify any sort of constructor or destructor. This feature can be enabled by running SWIG with the '-make_default' option or by inserting the following pragma into an interface file : %pragma make_default The following pragma disables automatic constructor generation %pragma no_default 2/9/97 : Added -make_default option for producing default constructors and destructors for classes without them. 2/9/97 : Changed the syntax of the SWIG %pragma directive to %pragma option=value or %pragma(lang) option=value. This change makes the syntax a little more consistent between general pragmas and language-specific pragmas. The old syntax still works, but will probably be phased out (a warning message is currently printed). 2/9/97 : Improved Tcl support of global variables that are of structures, classes, and unions. 2/9/97 : Fixed C++ compilation problem in Python 'embed.i' library file. 2/9/97 : Fixed missing return value in perlmain.i library file. 2/9/97 : Fixed Python shadow classes to return an AttributeError when undefined attributes are accessed (older versions returned a NameError). 2/9/97 : Fixed bug when %addmethods is used after a class definition whose last section is protected or private. 2/8/97 : Made slight changes in include file processing to support the Macintosh. 2/8/97 : Extended swigmain.cxx to provide a rudimentary Macintosh interface. It's a really bad interface, but works until something better is written. 1/29/97 : Fixed type-casting bug introduced by 1.1b4 when setting/getting the value of global variables involving complex data types. 1/29/97 : Removed erroneous white space before an #endif in the code generated by the Python module (was causing errors on DEC Alpha compilers). 1/26/97 : Fixed errors when using default/optional arguments in Python shadow shadow classes. 1/23/97 : Fixed bug with nested %extern declarations. 1/21/97 : Fixed problem with typedef involving const datatypes. 1/21/97 : Somewhat obscure, but serious bug with having multiple levels of typedefs fixed. For example : typedef char *String; typedef String Name; Version 1.1 Beta4 (January 16, 1997) ==================================== Note : SWIG 1.1b3 crashed and burned shortly after take off due to a few major run-time problems that surfaced after release. This release should fix most, if not all, of those problems. 1/16/97 : Fixed major memory management bug on Linux 1/14/97 : Fixed bug in functions returning constant C++ references. 1/14/97 : Modified C++ module to handle datatypes better. 1/14/97 : Modified parser to allow a *single* scope resolution operator in datatypes. Ie : Foo::bar. SWIG doesn't yet handle nested classes, so this should be sufficient for now. 1/14/97 : Modified parser to allow typedef inside a C++ class. 1/14/97 : Fixed some problems related to datatypes defined inside a C++ class. SWIG was not generating correct code, but a new scoping mechanism and method for handling datatypes inside a C++ class have been added. 1/14/97 : Changed enumerations to use the value name instead of any values that might have appeared in the interface file. This makes the code a little more friendly to C++ compilers. 1/14/97 : Removed typedef bug that made all enumerations equivalent to each other in the type checker (since it generated alot of unnecessary code). Version 1.1 Beta3 (January 9, 1997) =================================== Note : A *huge* number of changes related to ongoing modifications. 1. Support for C++ multiple inheritance added. 2. Typemaps added. 3. Some support for nested structure definitions added. 4. Default argument handling added. 5. -c option added for building bare wrapper code modules. 6. Rewrote Pointer type-checking to support multiple inheritance correctly. 7. Tcl 8.0 module added. 8. Perl4 and Guile modules resurrected from the dead (well, they at least work again). 9. New Object Oriented Tcl interface added. 10. Bug fixes to Perl5 shadow classes. 11. Cleaned up many of the internal modules of the parser. 12. Tons of examples and testing modules added. 13. Fixed bugs related to use of "const" return values. 14. Fixed bug with C++ member functions returning void *. 15. Changed SWIG configuration script. Version 1.1 Beta2 (December 3, 1996) ==================================== 1. Completely rewrote the SWIG documentation system. The changes involved are too numerous to mention. Basically, take everything you knew about the old system, throw them out, and read the file Doc/doc.ps. 2. Limited support for #if defined() added. 3. Type casts are now allowed in constant expressions. ie #define A (int) 3 4. Added support for typedef lists. For example : typedef struct { double x,y,z; } Vector, *VectorPtr; 5. New SWIG directives (related to documentation system) %style %localstyle %subsection %subsubsection 6. Reorganized the C++ handling and made it a little easier to work with internally. 7. Fixed problem with inheriting data members in Python shadow classes. 8. Fixed symbol table problems with shadow classes in both Python and Perl. 9. Fixed annoying segmentation fault bug in wrapper code generated for Perl5. 10. Fixed bug with %addmethods directive. Now it can be placed anywhere in a class. 11. More test cases added to the SWIG self-test. Documentation tests are now performed along with other things. 12. Reorganized the SWIG library a little bit and set it up to self-document itself using SWIG. 13. Lots and lots of minor bug fixes (mostly obscure, but bugs nonetheless). Version 1.1 Beta1 (October 30, 1996) ==================================== 1. Added new %extern directive for handling multiple files 2. Perl5 shadow classes added 3. Rewrote conditional compilation to work better 4. Added 'bool' datatype 5. %{,%} block is now optional. 6. Fixed some bugs in the Python shadow class module 7. Rewrote all of the SWIG tests to be more informative (and less scary). 8. Rewrote parameter list handling to be more memory efficient and flexible. 9. Changed parser to ignore 'static' declarations. 10. Initializers are now ignored. For example : struct FooBar a = {3,4,5}; 11. Somewhat better parsing of arrays (although it's usually just a better error message now). 12. Lot's of minor bug fixes. Version 1.0 Final (August 31, 1996) =================================== 1. Fixed minor bug in C++ module 2. Fixed minor bug in pointer type-checker when using -DALLOW_NULL. 3. Fixed configure script to work with Python 1.4beta3 4. Changed configure script to allow compilation without yacc or bison. Version 1.0 Final (August 28, 1996) =================================== 1. Changed parser to support more C/C++ datatypes (well, more variants). Types like "unsigned", "short int", "long int", etc... now work. 2. "unions" added to parser. 3. Use of "typedef" as in : typedef struct { double x,y,z; } Vector; Now works correctly. The name of the typedef is used as the structure name. 4. Conditional compilation with #ifdef, #else, #endif, etc... added. 5. New %disabledoc, %enabledoc directives allow documentation to selectively be disabled for certain parts of a wrapper file. 6. New Python module supports better variable linking, constants, and shadow classes. 7. Perl5 module improved with better compatibility with XS and xsubpp. SWIG pointers and now created so that they are compatible with xsubpp pointers. 8. Support for [incr Tcl] namespaces added to Tcl module. 9. %pragma directive added. 10. %addmethods directive added. 11. %native directive added to allow pre-existing wrapper functions to be used. 12. Wrote configure script for SWIG installation. 13. Function pointers now allowed with typedef statements. 14. %typedef modified to insert a corresponding C typedef into the output file. 15. Fixed some problems related to C++ references. 16. New String and WrapperFunction classes add to make generating wrapper code easier. 17. Fixed command line option processing to eliminate core dumps and to allow help messages. 18. Lot's of minor bug fixes to almost all code modules Version 1.0 Beta 3 (Patch 1) July 17, 1996 ========================================== 1.0 Final is not quite ready yet, but this release fixes a number of immediate problems : 1. Compiler errors when using -strict 1 type checking have been fixed. 2. Pointer type checker now recognizes pointers of the form _0_Type correctly. 3. A few minor fixes were made in the Makefile Version 1.0 Beta 3 (June 14, 1996) ================================== There are lots of changes in this release : 1. SWIG is now invoked using the "swig" command instead of "wrap". Hey, swig sounds cooler. 2. The SWIG_LIB environment variable can be set to change the location where SWIG looks for library files. 3. C++ support has been added. You should use the -c++ option to enable it. 4. The %init directive has been replaced by the %module directive. %module constructs a valid name for the initialization function for whatever target language you're using (actually this makes SWIG files a little cleaner). The old %init directive still works. 5. The syntax of the %name directive has been changed. Use of the old one should generate a warning message, but may still work. 6. To support Tcl/Tk on non-unix platforms, SWIG imports a file called swigtcl.cfg from the $(SWIG_LIB)/tcl directory. I don't have access to an NT machine, but this file is supposedly allows SWIG to produce wrapper code that compiles on both UNIX and non UNIX machines. If this doesn't work, you'll have to edit the file swigtcl.cfg. Please let me know if this doesn't work so I can update the file as necessary. 7. The SWIG run-time typechecker has been improved. You can also now redefine how it works by supplying a file called "swigptr.cfg" in the same directory as your SWIG interface files. By default, SWIG reads this file from $(SWIG_LIB)/config. 8. The documentation system has been changed to support the following : - Documentation order is printed in interface file order by default. This can be overridden by putting an %alpha directive in the beginning of the interface file. - You can supply additional documentation text using %text %{ put your text here %} - A few minor bugs were fixed. 9. A few improvements have been made to the handling of command line options (but it's still not finished). 10. Lots of minor bug fixes in most of the language modules have been made. 11. Filenames have been changed to 8.3 for compatibility with a SWIG port to non-unix platforms (work in progress). 12. C++ file suffix is now .cxx (for same reason). 13. The documentation has been upgraded significantly and is now around 100 pages. I added new examples and a section on C++. The documentation now includes a Table of Contents. 14. The SWIG Examples directory is still woefully sparse, but is getting better. Special notice about C++ ------------------------ This is the first version of SWIG to support C++ parsing. Currently the C++ is far from complete, but seems to work for simple cases. No work has been done to add special C++ processing to any of the target languages. See the user manual for details about how C++ is handled. If you find problems with the C++ implementation, please let me know. Expect major improvements in this area. Note : I have only successfully used SWIG and C++ with Tcl and Python. Notice about Version 1.0Final ----------------------------- Version 1.0B3 is the last Beta release before version 1.0 Final is released. I have frozen the list of features supported in version 1.0 and will only fix bugs as they show up. Work on SWIG version 2.0 is already in progress, but is going to result in rather significant changes to SWIG's internal structure (hopefully for the better). No anticipated date for version 2.0 is set, but if you've got an idea, let me know. Version 1.0 Beta 2 (April 26, 1996) =================================== This release is identical to Beta1 except a few minor bugs are fixed and the SWIG library has been updated to work with Tcl 7.5/Tk 4.1. A tcl7.5 examples directory is now included. - Fixed a bug in the Makefile that didn't install the libraries correctly. - SWIG Library files are now updated to work with Tcl 7.5 and Tk 4.1. - Minor bug fixes in other modules. Version 1.0 Beta 1 (April 10, 1996). ===================================== This is the first "semi-official" release of SWIG. It has a number of substantial improvements over the Alpha release. These notes are in no particular order--hope I remembered everything.... 1. Tcl/Tk SWIG is known to work with Tcl7.3, Tk3.6 and later versions. I've also tested SWIG with expect-5.19. Normally SWIG expects to use the header files "tcl.h" and "tk.h". Newer versions of Tcl/Tk use version numbers. You can specify these in SWIG as follows : % wrap -htcl tcl7.4.h -htk tk4.0.h example.i Of course, I prefer to simply set up symbolic links between "tcl.h" and the most recent stable version on the machine. 2. Perl4 This implementation has been based on Perl-4.035. SWIG's interface to Perl4 is based on the documentation provided in the "Programming Perl" book by Larry Wall, and files located in the "usub" directory of the Perl4 distribution. In order to compile with Perl4, you'll need to link with the uperl.o file found in the Perl4 source directory. You may want to move this file to a more convenient location. 3. Perl5 This is a somewhat experimental implementation, but is alot less buggy than the alpha release. SWIG operates independently of the XS language and xsubpp supplied with Perl5. Currently SWIG produces the necessary C code and .pm file needed to dynamically load a module into Perl5. To support Perl5's notion of modules and packages (as with xsubpp), you can use the following command line options : % wrap -perl5 -module MyModule -package MyPackage example.i Note : In order for dynamic loading to be effective, you need to be careful about naming. For a module named "MyModule", you'll need to create a shared object file called "MyModule.so" using something like % ld -shared my_obj.o -o MyModule.so The use of the %init directive must match the module name since Perl5 calls a function "boot_ModuleName" in order to initialize things. See the Examples directory for some examples of how to get things to work. 4. Python1.3 This is the first release supporting Python. The Python port is experimental and may be rewritten. Variable linkage is done through functions which is sort of a kludge. I also think it would be nice to import SWIG pointers into Python as a new object (instead of strings). Of course, this needs a little more work. 5. Guile3 If you really want to live on the edge, pick up a copy of Guile-iii and play around with this. This is highly experimental---especially since I'm not sure what the official state of Guile is these days. This implementation may change at any time should I suddenly figure out better ways to do things. 6. Extending SWIG SWIG is written in C++ although I tend to think of the code as mostly being ANSI C with a little inheritance thrown in. Each target language is implemented as a C++ class that can be plugged into the system. If you want to add your own modifications, see Appendix C of the user manual. Then take a look at the "user" directory which contains some code for building your own extenions. 7. The SWIG library The SWIG library is still incomplete. Some of the files mentioned in the user manual are unavailable. These files will be made available when they are ready. Subscribe to the SWIG mailing list for announcements and updates. 8. SWIG Documentation I have sometimes experienced problems viewing the SWIG documentation in some postscript viewers. However, the documentation seems to print normally. I'm working on making much of the documentation online, but this takes time. Version 0.1 Alpha (February 9, 1996) ==================================== 1. Run-time type-checking of SWIG pointers. Pointers are now represented as strings with both numeric and encoded type information. This makes it a little harder to shoot yourself in the foot (and it eliminates some segmentation faults and other oddities). 2. Python 1.3 now supported. 3. #define and enum can be used to install constants. 4. Completely rewrote the %include directive and made it alot more powerful. 5. Restructured the SWIG library to make it work better. 6. Various bug fixes to Tcl, Perl4, Perl5, and Guile implementations. 7. Better implementation of %typedef directive. 8. Made some changes to SWIG's class structure to make it easier to expand. SWIG is now built into a library file that you can use to make your own extenions. 9. Made extensive changes to the documentation. 10. Minor changes to the SWIG parser to make it use less memory. Also took out some extraneous rules that were undocumented and didn't work in the first place. 11. The SWIG library files "tclsh", "wish", "expect", etc... in the first release have been restructured and renamed to "tclsh.i", "wish.i", and so on. swig-3.0.2/LICENSE-UNIVERSITIES0000664000175000017500000001106012343605122015275 0ustar williamwilliamSWIG is distributed under the following terms: I. Copyright (c) 1995-1998 The University of Utah and the Regents of the University of California All Rights Reserved Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that (1) The above copyright notice and the following two paragraphs appear in all copies of the source code and (2) redistributions including binaries reproduces these notices in the supporting documentation. Substantial modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated in all files where they apply. IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. II. This software includes contributions that are Copyright (c) 1998-2005 University of Chicago. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the University of Chicago nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF CHICAGO AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF CHICAGO OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. III. This software includes contributions that are Copyright (c) 2005-2006 Arizona Board of Regents (University of Arizona). All Rights Reserved Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that (1) The above copyright notice and the following paragraph appear in all copies of the source code and (2) redistributions including binaries reproduces these notices in the supporting documentation. Substantial modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated in all files where they apply. THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF ARIZONA AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF ARIZONA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. swig-3.0.2/autogen.sh0000775000175000017500000000111212343605122014337 0ustar williamwilliam#! /bin/sh # Bootstrap the development environment - add extra files needed to run configure. # Note autoreconf should do what this file achieves, but it has a bug when working with automake! # The latest config.guess and config.sub should be copied into Tools/config. # This script will ensure the latest is copied from your autotool installation. set -e set -x test -d Tools/config || mkdir Tools/config ${ACLOCAL-aclocal} -I Tools/config ${AUTOHEADER-autoheader} ${AUTOMAKE-automake} --add-missing --copy --force-missing ${AUTOCONF-autoconf} cd CCache && ${AUTORECONF-autoreconf} swig-3.0.2/aclocal.m40000664000175000017500000010726012343706573014225 0ustar williamwilliam# generated automatically by aclocal 1.11.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, # Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, # 2010, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 12 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_PROG_CC_C_O # -------------- # Like AC_PROG_CC_C_O, but changed for automake. AC_DEFUN([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC_C_O])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi dnl Make sure AC_PROG_CC is never called again, or it will override our dnl setting of CC. m4_define([AC_PROG_CC], [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([Tools/config/ac_compare_version.m4]) m4_include([Tools/config/ac_compile_warnings.m4]) m4_include([Tools/config/ac_define_dir.m4]) m4_include([Tools/config/ax_boost_base.m4]) m4_include([Tools/config/ax_compare_version.m4]) m4_include([Tools/config/ax_cxx_compile_stdcxx_11.m4]) m4_include([Tools/config/ax_path_generic.m4]) swig-3.0.2/CCache/0000775000175000017500000000000012343706605013461 5ustar williamwilliamswig-3.0.2/CCache/test.sh0000775000175000017500000002523412343605122014775 0ustar williamwilliam#!/bin/sh # a simple test suite for ccache # tridge@samba.org if test -n "$CC"; then COMPILER="$CC" else COMPILER=cc fi if test -n "$SWIG"; then SWIG="$SWIG" else SWIG=swig fi CCACHE=../ccache-swig TESTDIR=test.$$ test_failed() { reason="$1" echo $1 $CCACHE -s cd .. rm -rf $TESTDIR echo TEST FAILED exit 1 } randcode() { outfile="$1" nlines=$2 i=0; ( while [ $i -lt $nlines ]; do echo "int foo$nlines$i(int x) { return x; }" i=`expr $i + 1` done ) >> "$outfile" } genswigcode() { outfile="$1" nlines=$2 i=0; ( echo "%module swigtest$2;" while [ $i -lt $nlines ]; do echo "int foo$nlines$i(int x);" echo "struct Bar$nlines$i { int y; };" i=`expr $i + 1` done ) >> "$outfile" } getstat() { stat="$1" value=`$CCACHE -s | grep "$stat" | cut -c34-40` echo $value } checkstat() { stat="$1" expected_value="$2" value=`getstat "$stat"` # echo "exp: $expected_value got: $value $testname" if [ "$expected_value" != "$value" ]; then test_failed "SUITE: $testsuite TEST: $testname - Expected $stat to be $expected_value got $value" fi } basetests() { echo "starting testsuite $testsuite" rm -rf "$CCACHE_DIR" checkstat 'cache hit' 0 checkstat 'cache miss' 0 j=1 rm -f *.c while [ $j -lt 32 ]; do randcode test$j.c $j j=`expr $j + 1` done testname="BASIC" $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 0 checkstat 'cache miss' 1 testname="BASIC2" $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 1 checkstat 'cache miss' 1 testname="debug" $CCACHE_COMPILE -c test1.c -g checkstat 'cache hit' 1 checkstat 'cache miss' 2 testname="debug2" $CCACHE_COMPILE -c test1.c -g checkstat 'cache hit' 2 checkstat 'cache miss' 2 testname="output" $CCACHE_COMPILE -c test1.c -o foo.o checkstat 'cache hit' 3 checkstat 'cache miss' 2 testname="link" $CCACHE_COMPILE test1.c -o test 2> /dev/null checkstat 'called for link' 1 testname="multiple" $CCACHE_COMPILE -c test1.c test2.c checkstat 'multiple source files' 1 testname="find" $CCACHE blahblah -c test1.c 2> /dev/null checkstat "couldn't find the compiler" 1 testname="bad" $CCACHE_COMPILE -c test1.c -I 2> /dev/null checkstat 'bad compiler arguments' 1 testname="c/c++" ln -f test1.c test1.ccc $CCACHE_COMPILE -c test1.ccc 2> /dev/null checkstat 'not a C/C++ file' 1 testname="unsupported" $CCACHE_COMPILE -M foo -c test1.c > /dev/null 2>&1 checkstat 'unsupported compiler option' 1 testname="stdout" $CCACHE echo foo -c test1.c > /dev/null checkstat 'compiler produced stdout' 1 testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1 rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" $CCACHE_COMPILE -c -O2 2> /dev/null checkstat 'no input file' 1 testname="CCACHE_DISABLE" CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null checkstat 'cache hit' 3 $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 4 testname="CCACHE_CPP2" CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 4 checkstat 'cache miss' 3 CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 5 checkstat 'cache miss' 3 testname="CCACHE_NOSTATS" CCACHE_NOSTATS=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 5 checkstat 'cache miss' 3 testname="CCACHE_RECACHE" CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 5 checkstat 'cache miss' 4 # strictly speaking should be 6 - RECACHE causes a double counting! checkstat 'files in cache' 8 $CCACHE -c > /dev/null checkstat 'files in cache' 6 testname="CCACHE_HASHDIR" CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 5 checkstat 'cache miss' 5 CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 6 checkstat 'cache miss' 5 checkstat 'files in cache' 8 testname="comments" echo '/* a silly comment */' > test1-comment.c cat test1.c >> test1-comment.c $CCACHE_COMPILE -c test1-comment.c rm -f test1-comment* checkstat 'cache hit' 6 checkstat 'cache miss' 6 testname="CCACHE_UNIFY" CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 6 checkstat 'cache miss' 7 mv test1.c test1-saved.c echo '/* another comment */' > test1.c cat test1-saved.c >> test1.c CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c mv test1-saved.c test1.c checkstat 'cache hit' 7 checkstat 'cache miss' 7 testname="cache-size" for f in *.c; do $CCACHE_COMPILE -c $f done checkstat 'cache hit' 8 checkstat 'cache miss' 37 checkstat 'files in cache' 72 $CCACHE -F 48 -c > /dev/null if [ `getstat 'files in cache'` -gt 48 ]; then test_failed '-F test failed' fi testname="cpp call" $CCACHE_COMPILE -c test1.c -E > test1.i checkstat 'cache hit' 8 checkstat 'cache miss' 37 testname="direct .i compile" $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 8 checkstat 'cache miss' 38 $CCACHE_COMPILE -c test1.i checkstat 'cache hit' 9 checkstat 'cache miss' 38 $CCACHE_COMPILE -c test1.i checkstat 'cache hit' 10 checkstat 'cache miss' 38 # removed these tests as some compilers (including newer versions of gcc) # determine which language to use based on .ii/.i extension, and C++ may # not be installed # testname="direct .ii file" # mv test1.i test1.ii # $CCACHE_COMPILE -c test1.ii # checkstat 'cache hit' 10 # checkstat 'cache miss' 39 # $CCACHE_COMPILE -c test1.ii # checkstat 'cache hit' 11 # checkstat 'cache miss' 39 testname="stripc" # This test might not be portable CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 10 checkstat 'cache miss' 39 CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 11 checkstat 'cache miss' 39 testname="zero-stats" $CCACHE -z > /dev/null checkstat 'cache hit' 0 checkstat 'cache miss' 0 testname="clear" $CCACHE -C > /dev/null checkstat 'files in cache' 0 rm -f test1.c } swigtests() { echo "starting swig testsuite $testsuite" rm -rf "$CCACHE_DIR" checkstat 'cache hit' 0 checkstat 'cache miss' 0 j=1 rm -f *.i genswigcode testswig1.i 1 testname="BASIC" $CCACHE_COMPILE -java testswig1.i checkstat 'cache hit' 0 checkstat 'cache miss' 1 checkstat 'files in cache' 6 testname="BASIC2" $CCACHE_COMPILE -java testswig1.i checkstat 'cache hit' 1 checkstat 'cache miss' 1 testname="output" $CCACHE_COMPILE -java testswig1.i -o foo_wrap.c checkstat 'cache hit' 1 checkstat 'cache miss' 2 testname="bad" $CCACHE_COMPILE -java testswig1.i -I 2> /dev/null checkstat 'bad compiler arguments' 1 testname="stdout" $CCACHE_COMPILE -v -java testswig1.i > /dev/null checkstat 'compiler produced stdout' 1 testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -java testswig1.i > /dev/null 2>&1 rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" $CCACHE_COMPILE -java 2> /dev/null checkstat 'no input file' 1 testname="CCACHE_DISABLE" CCACHE_DISABLE=1 $CCACHE_COMPILE -java testswig1.i 2> /dev/null checkstat 'cache hit' 1 $CCACHE_COMPILE -java testswig1.i checkstat 'cache hit' 2 testname="CCACHE_CPP2" CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 2 checkstat 'cache miss' 3 CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 3 checkstat 'cache miss' 3 testname="CCACHE_NOSTATS" CCACHE_NOSTATS=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 3 checkstat 'cache miss' 3 testname="CCACHE_RECACHE" CCACHE_RECACHE=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 3 checkstat 'cache miss' 4 # strictly speaking should be 3x6=18 instead of 4x6=24 - RECACHE causes a double counting! checkstat 'files in cache' 24 $CCACHE -c > /dev/null checkstat 'files in cache' 18 testname="CCACHE_HASHDIR" CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 3 checkstat 'cache miss' 5 CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 4 checkstat 'cache miss' 5 checkstat 'files in cache' 24 testname="cpp call" $CCACHE_COMPILE -java -E testswig1.i > testswig1-preproc.i checkstat 'cache hit' 4 checkstat 'cache miss' 5 testname="direct .i compile" $CCACHE_COMPILE -java testswig1.i checkstat 'cache hit' 5 checkstat 'cache miss' 5 # No cache hit due to different input file name, -nopreprocess should not be given twice to SWIG $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i checkstat 'cache hit' 5 checkstat 'cache miss' 6 $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i checkstat 'cache hit' 6 checkstat 'cache miss' 6 testname="stripc" CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 7 checkstat 'cache miss' 6 CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O -O testswig1.i checkstat 'cache hit' 7 checkstat 'cache miss' 7 rm -f testswig1-preproc.i rm -f testswig1.i } ###### # main program rm -rf $TESTDIR mkdir $TESTDIR cd $TESTDIR || exit 1 CCACHE_DIR="ccache dir" # with space in directory name (like Windows default) mkdir "$CCACHE_DIR" export CCACHE_DIR testsuite="base" CCACHE_COMPILE="$CCACHE $COMPILER" basetests CCACHE_COMPILE="$CCACHE $SWIG" swigtests if test -z "$NOSOFTLINKSTEST"; then testsuite="link" ln -s $CCACHE $COMPILER CCACHE_COMPILE="./$COMPILER" basetests rm "./$COMPILER" ln -s $CCACHE $SWIG CCACHE_COMPILE="./$SWIG" swigtests rm "./$SWIG" else echo "skipping testsuite link" fi testsuite="hardlink" CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $COMPILER" basetests CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $SWIG" swigtests testsuite="cpp2" CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $COMPILER" basetests CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $SWIG" swigtests testsuite="nlevels4" CCACHE_COMPILE="env CCACHE_NLEVELS=4 $CCACHE $COMPILER" basetests testsuite="nlevels1" CCACHE_COMPILE="env CCACHE_NLEVELS=1 $CCACHE $COMPILER" basetests cd .. rm -rf $TESTDIR echo test done - OK exit 0 swig-3.0.2/CCache/configure.ac0000664000175000017500000000460412343605122015743 0ustar williamwilliamdnl Process this file with autoconf to produce a configure script. AC_INIT([ccache-swig], [0.0]) # Get version from SWIG in ccache_swig_config.h.in AC_PREREQ(2.52) AC_CONFIG_SRCDIR([ccache.h]) AC_MSG_NOTICE([Configuring ccache]) AC_CONFIG_HEADER(config.h) dnl Checks for programs. AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_ARG_PROGRAM # for program_transform_name AC_DEFINE([_GNU_SOURCE], 1, [Define _GNU_SOURCE so that we get all necessary prototypes]) # If GCC, turn on warnings. if test "x$GCC" = "xyes" then CFLAGS="$CFLAGS -Wall -W" else CFLAGS="$CFLAGS -O" fi AC_HEADER_DIRENT AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h) AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) AC_CHECK_FUNCS(gethostname getpwuid) AC_CHECK_FUNCS(utimes) AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ AC_TRY_COMPILE( [#include ], [ void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); } ], ccache_cv_COMPAR_FN_T=yes,ccache_cv_COMPAR_FN_T=no)]) if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then AC_DEFINE(HAVE_COMPAR_FN_T, 1, [ ]) fi dnl Note: This could be replaced by AC_FUNC_SNPRINTF() in the autoconf macro archive AC_CACHE_CHECK([for C99 vsnprintf],ccache_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ #include #include void foo(const char *format, ...) { va_list ap; int len; char buf[5]; va_start(ap, format); len = vsnprintf(0, 0, format, ap); va_end(ap); if (len != 5) exit(1); if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); exit(0); } main() { foo("hello"); } ], ccache_cv_HAVE_C99_VSNPRINTF=yes,ccache_cv_HAVE_C99_VSNPRINTF=no,ccache_cv_HAVE_C99_VSNPRINTF=cross)]) if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) fi dnl Check for zlib. dnl Note: This could be replaced by CHECK_ZLIB() in the autoconf macro archive AC_ARG_ENABLE([zlib], AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, [enable_zlib=yes]) if test x"$enable_zlib" = x"yes"; then AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, [LIBS="-lz $LIBS" AC_DEFINE([ENABLE_ZLIB], 1, [Define to 1 if you would like to have zlib compression for ccache.]) ] )) fi AC_CONFIG_FILES([Makefile]) AC_OUTPUT swig-3.0.2/CCache/unify.c0000664000175000017500000001603012343605122014747 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* C/C++ unifier the idea is that changes that don't affect the resulting C code should not change the hash. This is achieved by folding white-space and other non-semantic fluff in the input into a single unified format. This unifier was design to match the output of the unifier in compilercache, which is flex based. The major difference is that this unifier is much faster (about 2x) and more forgiving of syntactic errors. Continuing on syntactic errors is important to cope with C/C++ extensions in the local compiler (for example, inline assembly systems). */ #include "ccache.h" static char *s_tokens[] = { "...", ">>=", "<<=", "+=", "-=", "*=", "/=", "%=", "&=", "^=", "|=", ">>", "<<", "++", "--", "->", "&&", "||", "<=", ">=", "==", "!=", ";", "{", "<%", "}", "%>", ",", ":", "=", "(", ")", "[", "<:", "]", ":>", ".", "&", "!", "~", "-", "+", "*", "/", "%", "<", ">", "^", "|", "?", 0 }; #define C_ALPHA 1 #define C_SPACE 2 #define C_TOKEN 4 #define C_QUOTE 8 #define C_DIGIT 16 #define C_HEX 32 #define C_FLOAT 64 #define C_SIGN 128 static struct { unsigned char type; unsigned char num_toks; char *toks[7]; } tokens[256]; /* build up the table used by the unifier */ static void build_table(void) { unsigned char c; int i; static int done; if (done) return; done = 1; memset(tokens, 0, sizeof(tokens)); for (c=0;c<128;c++) { if (isalpha(c) || c == '_') tokens[c].type |= C_ALPHA; if (isdigit(c)) tokens[c].type |= C_DIGIT; if (isspace(c)) tokens[c].type |= C_SPACE; if (isxdigit(c)) tokens[c].type |= C_HEX; } tokens['\''].type |= C_QUOTE; tokens['"'].type |= C_QUOTE; tokens['l'].type |= C_FLOAT; tokens['L'].type |= C_FLOAT; tokens['f'].type |= C_FLOAT; tokens['F'].type |= C_FLOAT; tokens['U'].type |= C_FLOAT; tokens['u'].type |= C_FLOAT; tokens['-'].type |= C_SIGN; tokens['+'].type |= C_SIGN; for (i=0;s_tokens[i];i++) { c = s_tokens[i][0]; tokens[c].type |= C_TOKEN; tokens[c].toks[tokens[c].num_toks] = s_tokens[i]; tokens[c].num_toks++; } } /* buffer up characters before hashing them */ static void pushchar(unsigned char c) { static unsigned char buf[64]; static int len; if (c == 0) { if (len > 0) { hash_buffer((char *)buf, len); len = 0; } hash_buffer(NULL, 0); return; } buf[len++] = c; if (len == 64) { hash_buffer((char *)buf, len); len = 0; } } /* hash some C/C++ code after unifying */ static void unify(unsigned char *p, size_t size) { size_t ofs; unsigned char q; int i; build_table(); for (ofs=0; ofs 2 && p[ofs+1] == ' ' && isdigit(p[ofs+2])) { do { ofs++; } while (ofs < size && p[ofs] != '\n'); ofs++; } else { do { pushchar(p[ofs]); ofs++; } while (ofs < size && p[ofs] != '\n'); pushchar('\n'); ofs++; } continue; } if (tokens[p[ofs]].type & C_ALPHA) { do { pushchar(p[ofs]); ofs++; } while (ofs < size && (tokens[p[ofs]].type & (C_ALPHA|C_DIGIT))); pushchar('\n'); continue; } if (tokens[p[ofs]].type & C_DIGIT) { do { pushchar(p[ofs]); ofs++; } while (ofs < size && ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.')); if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) { do { pushchar(p[ofs]); ofs++; } while (ofs < size && (tokens[p[ofs]].type & C_HEX)); } if (ofs < size && (p[ofs] == 'E' || p[ofs] == 'e')) { pushchar(p[ofs]); ofs++; while (ofs < size && (tokens[p[ofs]].type & (C_DIGIT|C_SIGN))) { pushchar(p[ofs]); ofs++; } } while (ofs < size && (tokens[p[ofs]].type & C_FLOAT)) { pushchar(p[ofs]); ofs++; } pushchar('\n'); continue; } if (tokens[p[ofs]].type & C_SPACE) { do { ofs++; } while (ofs < size && (tokens[p[ofs]].type & C_SPACE)); continue; } if (tokens[p[ofs]].type & C_QUOTE) { q = p[ofs]; pushchar(p[ofs]); do { ofs++; while (ofs < size-1 && p[ofs] == '\\') { pushchar(p[ofs]); pushchar(p[ofs+1]); ofs+=2; } pushchar(p[ofs]); } while (ofs < size && p[ofs] != q); pushchar('\n'); ofs++; continue; } if (tokens[p[ofs]].type & C_TOKEN) { q = p[ofs]; for (i=0;i= ofs+len && memcmp(&p[ofs], s, len) == 0) { int j; for (j=0;s[j];j++) { pushchar(s[j]); ofs++; } pushchar('\n'); break; } } if (i < tokens[q].num_toks) { continue; } } pushchar(p[ofs]); pushchar('\n'); ofs++; } pushchar(0); } /* hash a file that consists of preprocessor output, but remove any line number information from the hash */ int unify_hash(const char *fname) { #ifdef _WIN32 HANDLE file; HANDLE section; DWORD filesize_low; char *map; int ret = -1; file = CreateFileA(fname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (file != INVALID_HANDLE_VALUE) { filesize_low = GetFileSize(file, NULL); if (!(filesize_low == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)) { section = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL); CloseHandle(file); if (section != NULL) { map = MapViewOfFile(section, FILE_MAP_READ, 0, 0, 0); CloseHandle(section); if (map != NULL) ret = 0; } } } if (ret == -1) { cc_log("Failed to open preprocessor output %s\n", fname); stats_update(STATS_PREPROCESSOR); return -1; } /* pass it through the unifier */ unify((unsigned char *)map, filesize_low); UnmapViewOfFile(map); return 0; #else int fd; struct stat st; char *map; fd = open(fname, O_RDONLY|O_BINARY); if (fd == -1 || fstat(fd, &st) != 0) { cc_log("Failed to open preprocessor output %s\n", fname); stats_update(STATS_PREPROCESSOR); return -1; } /* we use mmap() to make it easy to handle arbitrarily long lines in preprocessor output. I have seen lines of over 100k in length, so this is well worth it */ map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (map == (char *)-1) { cc_log("Failed to mmap %s\n", fname); stats_update(STATS_PREPROCESSOR); return -1; } close(fd); /* pass it through the unifier */ unify((unsigned char *)map, st.st_size); munmap(map, st.st_size); return 0; #endif } swig-3.0.2/CCache/README0000664000175000017500000000125512343605122014334 0ustar williamwilliamThis is a re-implementation of "compilercache" in C The original compilercache scripts were by Erik Thiele (erikyyy@erikyyy.de) and I would like to thank him for an excellent piece of work. See http://www.erikyyy.de/compilercache/ for the original shell scripts. I wrote ccache because I wanted to get a bit more speed out of a compiler cache and I wanted to remove some of the limitations of the shell-script version. Please see the manual page and documentation at http://ccache.samba.org/ INSTALLATION ------------ Please run: ./configure make make install then read the ccache manual page ----------- Andrew Tridgell http://samba.org/~tridge/ bugs@ccache.samba.org swig-3.0.2/CCache/util.c0000664000175000017500000004140412343605122014575 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" static FILE *logfile; /* log a message to the CCACHE_LOGFILE location */ void cc_log(const char *format, ...) { va_list ap; extern char *cache_logfile; if (!cache_logfile) return; if (!logfile) logfile = fopen(cache_logfile, "a"); if (!logfile) return; va_start(ap, format); vfprintf(logfile, format, ap); va_end(ap); fflush(logfile); } /* something went badly wrong! */ void fatal(const char *msg) { cc_log("FATAL: %s\n", msg); exit(1); } int safe_rename(const char* oldpath, const char* newpath) { /* safe_rename is for creating entries in the cache. Works like rename(), but it never overwrites an existing cache entry. This avoids corruption on NFS. */ #ifndef _WIN32 int status = link(oldpath, newpath); if( status == 0 || errno == EEXIST ) #else int status = CreateHardLinkA(newpath, oldpath, NULL) ? 0 : -1; if( status == 0 || GetLastError() == ERROR_ALREADY_EXISTS ) #endif { return unlink( oldpath ); } else { return -1; } } #ifndef ENABLE_ZLIB /* copy all data from one file descriptor to another */ void copy_fd(int fd_in, int fd_out) { char buf[10240]; int n; while ((n = read(fd_in, buf, sizeof(buf))) > 0) { if (write(fd_out, buf, n) != n) { fatal("Failed to copy fd"); } } } #ifndef HAVE_MKSTEMP /* cheap and nasty mkstemp replacement */ int mkstemp(char *template) { mktemp(template); return open(template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600); } #endif /* move a file using rename */ int move_file(const char *src, const char *dest) { return safe_rename(src, dest); } /* copy a file - used when hard links don't work the copy is done via a temporary file and atomic rename */ static int copy_file(const char *src, const char *dest) { int fd1, fd2; char buf[10240]; int n; char *tmp_name; mode_t mask; x_asprintf(&tmp_name, "%s.XXXXXX", dest); fd1 = open(src, O_RDONLY|O_BINARY); if (fd1 == -1) { free(tmp_name); return -1; } fd2 = mkstemp(tmp_name); if (fd2 == -1) { close(fd1); free(tmp_name); return -1; } while ((n = read(fd1, buf, sizeof(buf))) > 0) { if (write(fd2, buf, n) != n) { close(fd2); close(fd1); unlink(tmp_name); free(tmp_name); return -1; } } close(fd1); /* get perms right on the tmp file */ #ifndef _WIN32 mask = umask(0); fchmod(fd2, 0666 & ~mask); umask(mask); #else (void)mask; #endif /* the close can fail on NFS if out of space */ if (close(fd2) == -1) { unlink(tmp_name); free(tmp_name); return -1; } unlink(dest); if (rename(tmp_name, dest) == -1) { unlink(tmp_name); free(tmp_name); return -1; } free(tmp_name); return 0; } /* copy a file to the cache */ static int copy_file_to_cache(const char *src, const char *dest) { return copy_file(src, dest); } /* copy a file from the cache */ static int copy_file_from_cache(const char *src, const char *dest) { return copy_file(src, dest); } #else /* ENABLE_ZLIB */ /* copy all data from one file descriptor to another possibly decompressing it */ void copy_fd(int fd_in, int fd_out) { char buf[10240]; int n; gzFile gz_in; gz_in = gzdopen(dup(fd_in), "rb"); if (!gz_in) { fatal("Failed to copy fd"); } while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { if (write(fd_out, buf, n) != n) { fatal("Failed to copy fd"); } } } static int _copy_file(const char *src, const char *dest, int mode) { int fd_in, fd_out; gzFile gz_in, gz_out = NULL; char buf[10240]; int n, ret; char *tmp_name; mode_t mask; struct stat st; x_asprintf(&tmp_name, "%s.XXXXXX", dest); if (getenv("CCACHE_NOCOMPRESS")) { mode = COPY_UNCOMPRESSED; } /* open source file */ fd_in = open(src, O_RDONLY); if (fd_in == -1) { return -1; } gz_in = gzdopen(fd_in, "rb"); if (!gz_in) { close(fd_in); return -1; } /* open destination file */ fd_out = mkstemp(tmp_name); if (fd_out == -1) { gzclose(gz_in); free(tmp_name); return -1; } if (mode == COPY_TO_CACHE) { /* The gzip file format occupies at least 20 bytes. So it will always occupy an entire filesystem block, even for empty files. Since most stderr files will be empty, we turn off compression in this case to save space. */ if (fstat(fd_in, &st) != 0) { gzclose(gz_in); close(fd_out); free(tmp_name); return -1; } if (file_size(&st) == 0) { mode = COPY_UNCOMPRESSED; } } if (mode == COPY_TO_CACHE) { gz_out = gzdopen(dup(fd_out), "wb"); if (!gz_out) { gzclose(gz_in); close(fd_out); free(tmp_name); return -1; } } while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { if (mode == COPY_TO_CACHE) { ret = gzwrite(gz_out, buf, n); } else { ret = write(fd_out, buf, n); } if (ret != n) { gzclose(gz_in); if (gz_out) { gzclose(gz_out); } close(fd_out); unlink(tmp_name); free(tmp_name); return -1; } } gzclose(gz_in); if (gz_out) { gzclose(gz_out); } /* get perms right on the tmp file */ mask = umask(0); fchmod(fd_out, 0666 & ~mask); umask(mask); /* the close can fail on NFS if out of space */ if (close(fd_out) == -1) { unlink(tmp_name); free(tmp_name); return -1; } unlink(dest); if (rename(tmp_name, dest) == -1) { unlink(tmp_name); free(tmp_name); return -1; } free(tmp_name); return 0; } /* move a file to the cache, compressing it */ int move_file(const char *src, const char *dest) { int ret; ret = _copy_file(src, dest, COPY_TO_CACHE); if (ret != -1) unlink(src); return ret; } /* copy a file to the cache, compressing it */ static int copy_file_to_cache(const char *src, const char *dest) { return _copy_file(src, dest, COPY_TO_CACHE); } /* copy a file from the cache, decompressing it */ static int copy_file_from_cache(const char *src, const char *dest) { return _copy_file(src, dest, COPY_FROM_CACHE); } #endif /* ENABLE_ZLIB */ /* test if a file is zlib compressed */ int test_if_compressed(const char *filename) { FILE *f; f = fopen(filename, "rb"); if (!f) { return 0; } /* test if file starts with 1F8B, which is zlib's * magic number */ if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) { fclose(f); return 0; } fclose(f); return 1; } /* copy file to the cache with error checking taking into account compression and hard linking if desired */ int commit_to_cache(const char *src, const char *dest, int hardlink) { int ret = -1; struct stat st; if (stat(src, &st) == 0) { unlink(dest); if (hardlink) { #ifdef _WIN32 ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1; #else ret = link(src, dest); #endif } if (ret == -1) { ret = copy_file_to_cache(src, dest); if (ret == -1) { cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno)); stats_update(STATS_ERROR); } } } else { cc_log("failed to put %s in the cache (%s)\n", src, strerror(errno)); stats_update(STATS_ERROR); } return ret; } /* copy file out of the cache with error checking taking into account compression and hard linking if desired */ int retrieve_from_cache(const char *src, const char *dest, int hardlink) { int ret = 0; x_utimes(src); if (strcmp(dest, "/dev/null") == 0) { ret = 0; } else { unlink(dest); /* only make a hardlink if the cache file is uncompressed */ if (hardlink && test_if_compressed(src) == 0) { #ifdef _WIN32 ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1; #else ret = link(src, dest); #endif } else { ret = copy_file_from_cache(src, dest); } } /* the cached file might have been deleted by some external process */ if (ret == -1 && errno == ENOENT) { cc_log("hashfile missing for %s\n", dest); stats_update(STATS_MISSING); return -1; } if (ret == -1) { ret = copy_file_from_cache(src, dest); if (ret == -1) { cc_log("failed to retrieve %s -> %s (%s)\n", src, dest, strerror(errno)); stats_update(STATS_ERROR); return -1; } } return ret; } /* make sure a directory exists */ int create_dir(const char *dir) { struct stat st; if (stat(dir, &st) == 0) { if (S_ISDIR(st.st_mode)) { return 0; } errno = ENOTDIR; return 1; } #ifdef _WIN32 if (mkdir(dir) != 0 && errno != EEXIST) { return 1; } #else if (mkdir(dir, 0777) != 0 && errno != EEXIST) { return 1; } #endif return 0; } char const CACHEDIR_TAG[] = "Signature: 8a477f597d28d172789f06886806bc55\n" "# This file is a cache directory tag created by ccache.\n" "# For information about cache directory tags, see:\n" "# http://www.brynosaurus.com/cachedir/\n"; int create_cachedirtag(const char *dir) { char *filename; struct stat st; FILE *f; x_asprintf(&filename, "%s/CACHEDIR.TAG", dir); if (stat(filename, &st) == 0) { if (S_ISREG(st.st_mode)) { goto success; } errno = EEXIST; goto error; } f = fopen(filename, "w"); if (!f) goto error; if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) { goto error; } if (fclose(f)) goto error; success: free(filename); return 0; error: free(filename); return 1; } /* this is like asprintf() but dies if the malloc fails note that we use vsnprintf in a rather poor way to make this more portable */ void x_asprintf(char **ptr, const char *format, ...) { va_list ap; *ptr = NULL; va_start(ap, format); if (vasprintf(ptr, format, ap) == -1) { fatal("out of memory in x_asprintf"); } va_end(ap); if (!ptr) fatal("out of memory in x_asprintf"); } /* this is like strdup() but dies if the malloc fails */ char *x_strdup(const char *s) { char *ret; ret = strdup(s); if (!ret) { fatal("out of memory in strdup\n"); } return ret; } /* this is like malloc() but dies if the malloc fails */ void *x_malloc(size_t size) { void *ret; ret = malloc(size); if (!ret) { fatal("out of memory in malloc\n"); } return ret; } /* this is like realloc() but dies if the malloc fails */ void *x_realloc(void *ptr, size_t size) { void *p2; #if 1 /* Avoid invalid read in memcpy below */ p2 = realloc(ptr, size); if (!p2) { fatal("out of memory in x_realloc"); } #else if (!ptr) return x_malloc(size); p2 = malloc(size); if (!p2) { fatal("out of memory in x_realloc"); } if (ptr) { /* Note invalid read as the memcpy reads beyond the memory allocated by ptr */ memcpy(p2, ptr, size); free(ptr); } #endif return p2; } /* revsusive directory traversal - used for cleanup fn() is called on all files/dirs in the tree */ void traverse(const char *dir, void (*fn)(const char *, struct stat *)) { DIR *d; struct dirent *de; d = opendir(dir); if (!d) return; while ((de = readdir(d))) { char *fname; struct stat st; if (strcmp(de->d_name,".") == 0) continue; if (strcmp(de->d_name,"..") == 0) continue; if (strlen(de->d_name) == 0) continue; x_asprintf(&fname, "%s/%s", dir, de->d_name); #ifdef _WIN32 if (stat(fname, &st)) #else if (lstat(fname, &st)) #endif { if (errno != ENOENT) { perror(fname); } free(fname); continue; } if (S_ISDIR(st.st_mode)) { traverse(fname, fn); } fn(fname, &st); free(fname); } closedir(d); } /* return the base name of a file - caller frees */ char *str_basename(const char *s) { char *p = strrchr(s, '/'); if (p) { s = (p+1); } #ifdef _WIN32 p = strrchr(s, '\\'); if (p) { s = (p+1); } #endif return x_strdup(s); } /* return the dir name of a file - caller frees */ char *dirname(char *s) { char *p; s = x_strdup(s); p = strrchr(s, '/'); #ifdef _WIN32 p = strrchr(s, '\\'); #endif if (p) { *p = 0; } return s; } /* http://www.ecst.csuchico.edu/~beej/guide/ipc/flock.html http://cvs.php.net/viewvc.cgi/php-src/win32/flock.c?revision=1.2&view=markup Should return 0 for success, >0 otherwise */ int lock_fd(int fd) { #ifdef _WIN32 # if 1 return _locking(fd, _LK_NBLCK, 1); # else HANDLE fl = (HANDLE)_get_osfhandle(fd); OVERLAPPED o; memset(&o, 0, sizeof(o)); return (LockFileEx(fl, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &o)) ? 0 : GetLastError(); # endif #else struct flock fl; int ret; fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 1; fl.l_pid = 0; /* not sure why we would be getting a signal here, but one user claimed it is possible */ do { ret = fcntl(fd, F_SETLKW, &fl); } while (ret == -1 && errno == EINTR); return ret; #endif } /* return size on disk of a file */ size_t file_size(struct stat *st) { #ifdef _WIN32 return (st->st_size + 1023) & ~1023; #else size_t size = st->st_blocks * 512; if ((size_t)st->st_size > size) { /* probably a broken stat() call ... */ size = (st->st_size + 1023) & ~1023; } return size; #endif } /* a safe open/create for read-write */ int safe_open(const char *fname) { int fd = open(fname, O_RDWR|O_BINARY); if (fd == -1 && errno == ENOENT) { fd = open(fname, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0666); if (fd == -1 && errno == EEXIST) { fd = open(fname, O_RDWR|O_BINARY); } } return fd; } /* display a kilobyte unsigned value in M, k or G */ void display_size(unsigned v) { if (v > 1024*1024) { printf("%8.1f Gbytes", v/((double)(1024*1024))); } else if (v > 1024) { printf("%8.1f Mbytes", v/((double)(1024))); } else { printf("%8u Kbytes", v); } } /* return a value in multiples of 1024 give a string that can end in K, M or G */ size_t value_units(const char *s) { char m; double v = atof(s); m = s[strlen(s)-1]; switch (m) { case 'G': case 'g': default: v *= 1024*1024; break; case 'M': case 'm': v *= 1024; break; case 'K': case 'k': v *= 1; break; } return (size_t)v; } /* a sane realpath() function, trying to cope with stupid path limits and a broken API */ char *x_realpath(const char *path) { #ifdef _WIN32 char namebuf[MAX_PATH]; DWORD ret; ret = GetFullPathNameA(path, sizeof(namebuf), namebuf, NULL); if (ret == 0 || ret >= sizeof(namebuf)) { return NULL; } return x_strdup(namebuf); #else int maxlen; char *ret, *p; #ifdef PATH_MAX maxlen = PATH_MAX; #elif defined(MAXPATHLEN) maxlen = MAXPATHLEN; #elif defined(_PC_PATH_MAX) maxlen = pathconf(path, _PC_PATH_MAX); #endif if (maxlen < 4096) maxlen = 4096; ret = x_malloc(maxlen); #if HAVE_REALPATH p = realpath(path, ret); #else /* yes, there are such systems. This replacement relies on the fact that when we call x_realpath we only care about symlinks */ { int len = readlink(path, ret, maxlen-1); if (len == -1) { free(ret); return NULL; } ret[len] = 0; p = ret; } #endif if (p) { p = x_strdup(p); free(ret); return p; } free(ret); return NULL; #endif } /* a getcwd that will returns an allocated buffer */ char *gnu_getcwd(void) { unsigned size = 128; while (1) { char *buffer = (char *)x_malloc(size); if (getcwd(buffer, size) == buffer) { return buffer; } free(buffer); if (errno != ERANGE) { return 0; } size *= 2; } } /* create an empty file */ int create_empty_file(const char *fname) { int fd; fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { return -1; } close(fd); return 0; } /* return current users home directory or die */ const char *get_home_directory(void) { #ifdef _WIN32 static char home_path[MAX_PATH] = {0}; HRESULT ret; /* we already have the path */ if (home_path[0] != 0) { return home_path; } /* get the path to "Application Data" folder */ ret = SHGetFolderPathA(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, home_path); if (SUCCEEDED(ret)) { return home_path; } fprintf(stderr, "ccache: Unable to determine home directory\n"); return NULL; #else const char *p = getenv("HOME"); if (p) { return p; } #ifdef HAVE_GETPWUID { struct passwd *pwd = getpwuid(getuid()); if (pwd) { return pwd->pw_dir; } } #endif fatal("Unable to determine home directory"); return NULL; #endif } int x_utimes(const char *filename) { #ifdef HAVE_UTIMES return utimes(filename, NULL); #else return utime(filename, NULL); #endif } #ifdef _WIN32 /* perror for Win32 API calls, using GetLastError() instead of errno */ void perror_win32(LPTSTR pszFunction) { LPTSTR pszMessage; DWORD dwLastError = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwLastError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&pszMessage, 0, NULL ); fprintf(stderr, "%s: %s\n", pszFunction, pszMessage); LocalFree(pszMessage); } #endif swig-3.0.2/CCache/README.swig0000664000175000017500000000072012343605122015300 0ustar williamwilliamThis directory contains a version of ccache. The initial version was based on ccache-2.4 plus 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 output has been retained. Additional features added are the CCACHE_VERBOSE and CCACHE_SWIG environment variables, see docs. swig-3.0.2/CCache/ccache-swig.10000664000175000017500000004221412343706605015723 0ustar williamwilliam.TH "ccache\-swig" "1" "" "" "" .PP .SH "NAME" ccache\-swig \- a fast compiler cache .PP .SH "SYNOPSIS" .PP ccache\-swig [OPTION] .PP ccache\-swig [COMPILER OPTIONS] .PP [COMPILER OPTIONS] .PP .SH "DESCRIPTION" .PP ccache\-swig is a compiler cache\&. It speeds up re\-compilation of C/C++/SWIG code by caching previous compiles and detecting when the same compile is being done again\&. ccache\-swig is ccache plus support for SWIG\&. ccache and ccache\-swig are used interchangeably in this document\&. .PP .SH "OPTIONS SUMMARY" .PP Here is a summary of the options to ccache\-swig\&. .PP .nf \-s show statistics summary \-z zero statistics \-c run a cache cleanup \-C clear the cache completely \-F set maximum files in cache \-M set maximum size of cache (use G, M or K) \-h this help page \-V print version number .fi .PP .SH "OPTIONS" .PP These options only apply when you invoke ccache as \(dq\&ccache\-swig\(dq\&\&. When invoked as a compiler none of these options apply\&. In that case your normal compiler options apply and you should refer to your compilers documentation\&. .PP .IP "\fB\-h\fP" Print a options summary page .IP .IP "\fB\-s\fP" Print the current statistics summary for the cache\&. The statistics are stored spread across the subdirectories of the cache\&. Using \(dq\&ccache\-swig \-s\(dq\& adds up the statistics across all subdirectories and prints the totals\&. .IP .IP "\fB\-z\fP" Zero the cache statistics\&. .IP .IP "\fB\-V\fP" Print the ccache version number .IP .IP "\fB\-c\fP" Clean the cache and re\-calculate the cache file count and size totals\&. Normally the \-c option should not be necessary as ccache keeps the cache below the specified limits at runtime and keeps statistics up to date on each compile\&. This option is mostly useful if you manually modify the cache contents or believe that the cache size statistics may be inaccurate\&. .IP .IP "\fB\-C\fP" Clear the entire cache, removing all cached files\&. .IP .IP "\fB\-F \fP" This sets the maximum number of files allowed in the cache\&. The value is stored inside the cache directory and applies to all future compiles\&. Due to the way the value is stored the actual value used is always rounded down to the nearest multiple of 16\&. .IP .IP "\fB\-M \fP" This sets the maximum cache size\&. You can specify a value in gigabytes, megabytes or kilobytes by appending a G, M or K to the value\&. The default is gigabytes\&. The actual value stored is rounded down to the nearest multiple of 16 kilobytes\&. .IP .SH "INSTALLATION" .PP There are two ways to use ccache\&. You can either prefix your compile commands with \(dq\&ccache\-swig\(dq\& or you can create a symbolic link between ccache\-swig and the names of your compilers\&. The first method is most convenient if you just want to try out ccache or wish to use it for some specific projects\&. The second method is most useful for when you wish to use ccache for all your compiles\&. .PP To install for usage by the first method just copy ccache\-swig to somewhere in your path\&. .PP To install for the second method do something like this: .nf cp ccache\-swig /usr/local/bin/ ln \-s /usr/local/bin/ccache\-swig /usr/local/bin/gcc ln \-s /usr/local/bin/ccache\-swig /usr/local/bin/g++ ln \-s /usr/local/bin/ccache\-swig /usr/local/bin/cc ln \-s /usr/local/bin/ccache\-swig /usr/local/bin/swig .fi This will work as long as /usr/local/bin comes before the path to gcc (which is usually in /usr/bin)\&. After installing you may wish to run \(dq\&which gcc\(dq\& to make sure that the correct link is being used\&. .PP Note! Do not use a hard link, use a symbolic link\&. A hardlink will cause \(dq\&interesting\(dq\& problems\&. .PP .SH "EXTRA OPTIONS" .PP When run as a compiler front end ccache usually just takes the same command line options as the compiler you are using\&. The only exception to this is the option \(cq\&\-\-ccache\-skip\(cq\&\&. That option can be used to tell ccache that the next option is definitely not a input filename, and should be passed along to the compiler as\-is\&. .PP The reason this can be important is that ccache does need to parse the command line and determine what is an input filename and what is a compiler option, as it needs the input filename to determine the name of the resulting object file (among other things)\&. The heuristic ccache uses in this parse is that any string on the command line that exists as a file is treated as an input file name (usually a C file)\&. By using \-\-ccache\-skip you can force an option to not be treated as an input file name and instead be passed along to the compiler as a command line option\&. .PP .SH "ENVIRONMENT VARIABLES" .PP ccache uses a number of environment variables to control operation\&. In most cases you won\(cq\&t need any of these as the defaults will be fine\&. .PP .IP "\fBCCACHE_DIR\fP" the CCACHE_DIR environment variable specifies where ccache will keep its cached compiler output\&. The default is \(dq\&$HOME/\&.ccache\(dq\&\&. .IP .IP "\fBCCACHE_TEMPDIR\fP" the CCACHE_TEMPDIR environment variable specifies where ccache will put temporary files\&. The default is the same as CCACHE_DIR\&. Note that the CCACHE_TEMPDIR path must be on the same filesystem as the CCACHE_DIR path, so that renames of files between the two directories can work\&. .IP .IP "\fBCCACHE_LOGFILE\fP" If you set the CCACHE_LOGFILE environment variable then ccache will write some log information on cache hits and misses in that file\&. This is useful for tracking down problems\&. .IP .IP "\fBCCACHE_VERBOSE\fP" If you set the CCACHE_VERBOSE environment variable then ccache will display on stdout all the compiler invocations that it makes\&. This can useful for debugging unexpected problems\&. .IP .IP "\fBCCACHE_PATH\fP" You can optionally set CCACHE_PATH to a colon separated path where ccache will look for the real compilers\&. If you don\(cq\&t do this then ccache will look for the first executable matching the compiler name in the normal PATH that isn\(cq\&t a symbolic link to ccache itself\&. .IP .IP "\fBCCACHE_CC\fP" You can optionally set CCACHE_CC to force the name of the compiler to use\&. If you don\(cq\&t do this then ccache works it out from the command line\&. .IP .IP "\fBCCACHE_PREFIX\fP" This option adds a prefix to the command line that ccache runs when invoking the compiler\&. Also see the section below on using ccache with distcc\&. .IP .IP "\fBCCACHE_DISABLE\fP" If you set the environment variable CCACHE_DISABLE then ccache will just call the real compiler, bypassing the cache completely\&. .IP .IP "\fBCCACHE_READONLY\fP" the CCACHE_READONLY environment variable tells ccache to attempt to use existing cached object files, but not to try to add anything new to the cache\&. If you are using this because your CCACHE_DIR is read\-only, then you may find that you also need to set CCACHE_TEMPDIR as otherwise ccache will fail to create the temporary files\&. .IP .IP "\fBCCACHE_CPP2\fP" If you set the environment variable CCACHE_CPP2 then ccache will not use the optimisation of avoiding the 2nd call to the pre\-processor by compiling the pre\-processed output that was used for finding the hash in the case of a cache miss\&. This is primarily a debugging option, although it is possible that some unusual compilers will have problems with the intermediate filename extensions used in this optimisation, in which case this option could allow ccache to be used\&. .IP .IP "\fBCCACHE_NOCOMPRESS\fP" If you set the environment variable CCACHE_NOCOMPRESS then there is no compression used on files that go into the cache\&. However, this setting has no effect on how files are retrieved from the cache, compressed results will still be usable\&. .IP .IP "\fBCCACHE_NOSTATS\fP" If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile\&. .IP .IP "\fBCCACHE_NLEVELS\fP" The environment variable CCACHE_NLEVELS allows you to choose the number of levels of hash in the cache directory\&. The default is 2\&. The minimum is 1 and the maximum is 8\&. .IP .IP "\fBCCACHE_HARDLINK\fP" If you set the environment variable CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy\&. Using hard links is faster, but can confuse programs like \(cq\&make\(cq\& that rely on modification times\&. Hard links are never made for compressed cache files\&. .IP .IP "\fBCCACHE_RECACHE\fP" This forces ccache to not use any cached results, even if it finds them\&. New results are still cached, but existing cache entries are ignored\&. .IP .IP "\fBCCACHE_UMASK\fP" This sets the umask for ccache and all child processes (such as the compiler)\&. This is mostly useful when you wish to share your cache with other users\&. Note that this also affects the file permissions set on the object files created from your compilations\&. .IP .IP "\fBCCACHE_HASHDIR\fP" This tells ccache to hash the current working directory when calculating the hash that is used to distinguish two compiles\&. This prevents a problem with the storage of the current working directory in the debug info of a object file, which can lead ccache to give a cached object file that has the working directory in the debug info set incorrectly\&. This option is off by default as the incorrect setting of this debug info rarely causes problems\&. If you strike problems with gdb not using the correct directory then enable this option\&. .IP .IP "\fBCCACHE_UNIFY\fP" If you set the environment variable CCACHE_UNIFY then ccache will use the C/C++ unifier when hashing the pre\-processor output if \-g is not used in the compile\&. The unifier is slower than a normal hash, so setting this environment variable loses a little bit of speed, but it means that ccache can take advantage of not recompiling when the changes to the source code consist of reformatting only\&. Note that using CCACHE_UNIFY changes the hash, so cached compiles with CCACHE_UNIFY set cannot be used when CCACHE_UNIFY is not set and vice versa\&. The reason the unifier is off by default is that it can give incorrect line number information in compiler warning messages\&. .IP .IP "\fBCCACHE_EXTENSION\fP" Normally ccache tries to automatically determine the extension to use for intermediate C pre\-processor files based on the type of file being compiled\&. Unfortunately this sometimes doesn\(cq\&t work, for example when using the aCC compiler on HP\-UX\&. On systems like this you can use the CCACHE_EXTENSION option to override the default\&. On HP\-UX set this environment variable to \(dq\&i\(dq\& if you use the aCC compiler\&. .IP .IP "\fBCCACHE_STRIPC\fP" If you set the environment variable CCACHE_STRIPC then ccache will strip the \-c option when invoking the preprocessor\&. This option is primarily for the Sun Workshop C++ compiler as without this option an unwarranted warning is displayed: CC: Warning: \(dq\&\-E\(dq\& redefines product from \(dq\&object\(dq\& to \(dq\&source (stdout)\(dq\& when \-E and \-c is used together\&. .IP .IP "\fBCCACHE_SWIG\fP" When using SWIG as the compiler and it does not have \(cq\&swig\(cq\& in the executable name, then the CCACHE_SWIG environment variable needs to be set in order for ccache to work correctly with SWIG\&. The use of CCACHE_CPP2 is also recommended for SWIG due to some preprocessor quirks, however, use of CCACHE_CPP2 can often be skipped \-\- check your generated code with and without this option set\&. Known problems are using preprocessor directives within %inline blocks and the use of \(cq\&#pragma SWIG\(cq\&\&. .IP .SH "CACHE SIZE MANAGEMENT" .PP By default ccache has a one gigabyte limit on the cache size and no maximum number of files\&. You can set a different limit using the \(dq\&ccache \-M\(dq\& and \(dq\&ccache \-F\(dq\& options, which set the size and number of files limits\&. .PP When these limits are reached ccache will reduce the cache to 20% below the numbers you specified in order to avoid doing the cache clean operation too often\&. .PP .SH "CACHE COMPRESSION" .PP By default on most platforms ccache will compress all files it puts into the cache using the zlib compression\&. While this involves a negligible performance slowdown, it significantly increases the number of files that fit in the cache\&. You can turn off compression setting the CCACHE_NOCOMPRESS environment variable\&. .PP .SH "HOW IT WORKS" .PP The basic idea is to detect when you are compiling exactly the same code a 2nd time and use the previously compiled output\&. You detect that it is the same code by forming a hash of: .PP .IP o the pre\-processor output from running the compiler with \-E .IP o the command line options .IP o the real compilers size and modification time .IP o any stderr output generated by the compiler .PP These are hashed using md4 (a strong hash) and a cache file is formed based on that hash result\&. When the same compilation is done a second time ccache is able to supply the correct compiler output (including all warnings etc) from the cache\&. .PP ccache has been carefully written to always produce exactly the same compiler output that you would get without the cache\&. If you ever discover a case where ccache changes the output of your compiler then please let me know\&. .PP .SH "USING CCACHE WITH DISTCC" .PP distcc is a very useful program for distributing compilation across a range of compiler servers\&. It is often useful to combine distcc with ccache, so that compiles that are done are sped up by distcc, but that ccache avoids the compile completely where possible\&. .PP To use distcc with ccache I recommend using the CCACHE_PREFIX option\&. You just need to set the environment variable CCACHE_PREFIX to \(cq\&distcc\(cq\& and ccache will prefix the command line used with the compiler with the command \(cq\&distcc\(cq\&\&. .PP .SH "SHARING A CACHE" .PP A group of developers can increase the cache hit rate by sharing a cache directory\&. The hard links however cause unwanted side effects, as all links to a cached file share the file\(cq\&s modification timestamp\&. This results in false dependencies to be triggered by timestamp\-based build systems whenever another user links to an existing file\&. Typically, users will see that their libraries and binaries are relinked without reason\&. To share a cache without side effects, the following conditions need to be met: .PP .IP o Use the same \fBCCACHE_DIR\fP environment variable setting .IP o Unset the \fBCCACHE_HARDLINK\fP environment variable .IP o Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in the group\&. .IP o Make sure that all users have write permission in the entire cache directory (and that you trust all users of the shared cache)\&. .IP o Make sure that the setgid bit is set on all directories in the cache\&. This tells the filesystem to inherit group ownership for new directories\&. The command \(dq\&chmod g+s `find $CCACHE_DIR \-type d`\(dq\& might be useful for this\&. .IP o Set \fBCCACHE_NOCOMPRESS\fP for all users, if there are users with versions of ccache that do not support compression\&. .PP .SH "HISTORY" .PP ccache was inspired by the compilercache shell script script written by Erik Thiele and I would like to thank him for an excellent piece of work\&. See http://www\&.erikyyy\&.de/compilercache/ for the Erik\(cq\&s scripts\&. ccache\-swig is a port of the original ccache with support added for use with SWIG\&. .PP I wrote ccache because I wanted to get a bit more speed out of a compiler cache and I wanted to remove some of the limitations of the shell\-script version\&. .PP .SH "DIFFERENCES FROM COMPILERCACHE" .PP The biggest differences between Erik\(cq\&s compilercache script and ccache are: .IP o ccache is written in C, which makes it a bit faster (calling out to external programs is mostly what slowed down the scripts)\&. .IP o ccache can automatically find the real compiler .IP o ccache keeps statistics on hits/misses .IP o ccache can do automatic cache management .IP o ccache can cache compiler output that includes warnings\&. In many cases this gives ccache a much higher cache hit rate\&. .IP o ccache can handle a much wider ranger of compiler options .IP o ccache avoids a double call to cpp on a cache miss .PP .SH "CREDITS" .PP Thanks to the following people for their contributions to ccache .IP o Erik Thiele for the original compilercache script .IP o Luciano Rocha for the idea of compiling the pre\-processor output to avoid a 2nd cpp pass .IP o Paul Russell for many suggestions and the debian packaging .PP .SH "AUTHOR" .PP ccache was written by Andrew Tridgell http://samba\&.org/~tridge/\&. ccache was adapted to create ccache\-swig for use with SWIG by William Fulton\&. .PP If you wish to report a problem or make a suggestion then please email the SWIG developers on the swig\-devel mailing list, see http://www\&.swig\&.org/mail\&.html .PP ccache is released under the GNU General Public License version 2 or later\&. Please see the file COPYING for license details\&. .PP swig-3.0.2/CCache/COPYING0000664000175000017500000004307612343605122014516 0ustar williamwilliam GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. swig-3.0.2/CCache/ccache_swig_config.h.in0000664000175000017500000000005112343605122020007 0ustar williamwilliam#define SWIG_VERSION "@PACKAGE_VERSION@" swig-3.0.2/CCache/ccache.h0000664000175000017500000001101212343605122015023 0ustar williamwilliam#include "ccache_swig_config.h" #define CCACHE_VERSION SWIG_VERSION #ifndef _WIN32 #include "config.h" #else #include #define PACKAGE_NAME "ccache-swig.exe" #endif #include #include #include #include #include #include #ifndef _WIN32 #include #include #else #define _WIN32_WINNT 0x0500 #include #include #endif #include #include #include #include #include #include #include #include #include #ifdef HAVE_PWD_H #include #endif #ifdef HAVE_SYS_TIME_H #include #endif #ifdef ENABLE_ZLIB #include #endif #define STATUS_NOTFOUND 3 #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 #define MYNAME PACKAGE_NAME #define LIMIT_MULTIPLE 0.8 /* default maximum cache size */ #ifndef DEFAULT_MAXSIZE #define DEFAULT_MAXSIZE (1000*1000) #endif /* file copy mode */ #ifdef ENABLE_ZLIB #define COPY_UNCOMPRESSED 0 #define COPY_FROM_CACHE 1 #define COPY_TO_CACHE 2 #endif enum stats { STATS_NONE=0, STATS_STDOUT, STATS_STATUS, STATS_ERROR, STATS_TOCACHE, STATS_PREPROCESSOR, STATS_COMPILER, STATS_MISSING, STATS_CACHED, STATS_ARGS, STATS_LINK, STATS_NUMFILES, STATS_TOTALSIZE, STATS_MAXFILES, STATS_MAXSIZE, STATS_NOTC, STATS_DEVICE, STATS_NOINPUT, STATS_ENVIRONMMENT, STATS_MULTIPLE, STATS_CONFTEST, STATS_UNSUPPORTED, STATS_OUTSTDOUT, STATS_END }; typedef unsigned uint32; #include "mdfour.h" void hash_start(void); void hash_string(const char *s); void hash_int(int x); void hash_file(const char *fname); char *hash_result(void); void hash_buffer(const char *s, int len); void cc_log(const char *format, ...); void fatal(const char *msg); void copy_fd(int fd_in, int fd_out); int safe_rename(const char* oldpath, const char* newpath); int move_file(const char *src, const char *dest); int test_if_compressed(const char *filename); int commit_to_cache(const char *src, const char *dest, int hardlink); int retrieve_from_cache(const char *src, const char *dest, int hardlink); int create_dir(const char *dir); int create_cachedirtag(const char *dir); void x_asprintf(char **ptr, const char *format, ...); char *x_strdup(const char *s); void *x_realloc(void *ptr, size_t size); void *x_malloc(size_t size); void traverse(const char *dir, void (*fn)(const char *, struct stat *)); char *str_basename(const char *s); char *dirname(char *s); int lock_fd(int fd); size_t file_size(struct stat *st); int safe_open(const char *fname); char *x_realpath(const char *path); char *gnu_getcwd(void); int create_empty_file(const char *fname); const char *get_home_directory(void); int x_utimes(const char *filename); #ifdef _WIN32 void perror_win32(LPTSTR pszFunction); #endif void stats_update(enum stats stat); void stats_zero(void); void stats_summary(void); void stats_tocache(size_t size, size_t numfiles); void stats_read(const char *stats_file, unsigned counters[STATS_END]); int stats_set_limits(long maxfiles, long maxsize); size_t value_units(const char *s); void display_size(unsigned v); void stats_set_sizes(const char *dir, size_t num_files, size_t total_size); int unify_hash(const char *fname); #ifndef HAVE_VASPRINTF int vasprintf(char **, const char *, va_list ); #endif #ifndef HAVE_ASPRINTF int asprintf(char **ptr, const char *format, ...); #endif #ifndef HAVE_SNPRINTF int snprintf(char *,size_t ,const char *, ...); #endif void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles); void cleanup_all(const char *dir); void wipe_all(const char *dir); #ifdef _WIN32 char *argvtos(char **argv); #endif int execute(char **argv, const char *path_stdout, const char *path_stderr); char *find_executable(const char *name, const char *exclude_name); void display_execute_args(char **argv); typedef struct { char **argv; int argc; } ARGS; ARGS *args_init(int , char **); void args_add(ARGS *args, const char *s); void args_add_prefix(ARGS *args, const char *s); void args_pop(ARGS *args, int n); void args_strip(ARGS *args, const char *prefix); void args_remove_first(ARGS *args); extern int ccache_verbose; #if HAVE_COMPAR_FN_T #define COMPAR_FN_T __compar_fn_t #else typedef int (*COMPAR_FN_T)(const void *, const void *); #endif /* work with silly DOS binary open */ #ifndef O_BINARY #define O_BINARY 0 #endif /* mkstemp() on some versions of cygwin don't handle binary files, so override */ /* Seems okay in Cygwin 1.7.0 #ifdef __CYGWIN__ #undef HAVE_MKSTEMP #endif */ swig-3.0.2/CCache/args.c0000664000175000017500000000454012343605122014554 0ustar williamwilliam/* convenient routines for argument list handling Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" ARGS *args_init(int init_argc, char **init_args) { ARGS *args; int i; args = (ARGS *)x_malloc(sizeof(ARGS)); args->argc = 0; args->argv = (char **)x_malloc(sizeof(char *)); args->argv[0] = NULL; for (i=0;iargv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *)); args->argv[args->argc] = x_strdup(s); args->argc++; args->argv[args->argc] = NULL; } /* pop the last element off the args list */ void args_pop(ARGS *args, int n) { while (n--) { args->argc--; free(args->argv[args->argc]); args->argv[args->argc] = NULL; } } /* remove the first element of the argument list */ void args_remove_first(ARGS *args) { free(args->argv[0]); memmove(&args->argv[0], &args->argv[1], args->argc * sizeof(args->argv[0])); args->argc--; } /* add an argument into the front of the argument list */ void args_add_prefix(ARGS *args, const char *s) { args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *)); memmove(&args->argv[1], &args->argv[0], (args->argc+1) * sizeof(args->argv[0])); args->argv[0] = x_strdup(s); args->argc++; } /* strip any arguments beginning with the specified prefix */ void args_strip(ARGS *args, const char *prefix) { int i; for (i=0; iargc; ) { if (strncmp(args->argv[i], prefix, strlen(prefix)) == 0) { free(args->argv[i]); memmove(&args->argv[i], &args->argv[i+1], args->argc * sizeof(args->argv[i])); args->argc--; } else { i++; } } } swig-3.0.2/CCache/snprintf.c0000664000175000017500000005346612343605122015476 0ustar williamwilliam/* * Copyright Patrick Powell 1995 * This code is based on code written by Patrick Powell (papowell@astart.com) * It may be used for any purpose as long as this notice remains intact * on all source code distributions */ /************************************************************** * Original: * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 * A bombproof version of doprnt (dopr) included. * Sigh. This sort of thing is always nasty do deal with. Note that * the version here does not include floating point... * * snprintf() is used instead of sprintf() as it does limit checks * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from * causing nast effects. * * More Recently: * Brandon Long 9/15/96 for mutt 0.43 * This was ugly. It is still ugly. I opted out of floating point * numbers, but the formatter understands just about everything * from the normal C string format, at least as far as I can tell from * the Solaris 2.5 printf(3S) man page. * * Brandon Long 10/22/97 for mutt 0.87.1 * Ok, added some minimal floating point support, which means this * 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 * 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 * and run snprintf for results. * * Thomas Roessler 01/27/98 for mutt 0.89i * The PGP code was using unsigned hexadecimal formats. * Unfortunately, unsigned formats simply didn't work. * * Michael Elkins 03/05/98 for mutt 0.90.8 * The original code assumed that both snprintf() and vsnprintf() were * missing. Some systems only have snprintf() but not vsnprintf(), so * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. * * Andrew Tridgell (tridge@samba.org) Oct 1998 * fixed handling of %.0f * added test for HAVE_LONG_DOUBLE * * tridge@samba.org, idra@samba.org, April 2001 * got rid of fcvt code (twas buggy and made testing harder) * added C99 semantics * **************************************************************/ #ifndef NO_CONFIG_H /* for some tests */ #include "config.h" #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_CTYPE_H #include #endif #include #include #ifdef HAVE_STDLIB_H #include #endif #if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) /* only include stdio.h if we are not re-defining snprintf or vsnprintf */ #include /* make the compiler happy with an empty file */ void dummy_snprintf(void) {} #else #ifdef HAVE_LONG_DOUBLE #define LDOUBLE long double #else #define LDOUBLE double #endif #ifdef HAVE_LONG_LONG #define LLONG long long #else #define LLONG long #endif static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args); static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max); static void fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags); static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags); static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); /* * dopr(): poor man's version of doprintf */ /* format read states */ #define DP_S_DEFAULT 0 #define DP_S_FLAGS 1 #define DP_S_MIN 2 #define DP_S_DOT 3 #define DP_S_MAX 4 #define DP_S_MOD 5 #define DP_S_CONV 6 #define DP_S_DONE 7 /* format flags - Bits */ #define DP_F_MINUS (1 << 0) #define DP_F_PLUS (1 << 1) #define DP_F_SPACE (1 << 2) #define DP_F_NUM (1 << 3) #define DP_F_ZERO (1 << 4) #define DP_F_UP (1 << 5) #define DP_F_UNSIGNED (1 << 6) /* Conversion Flags */ #define DP_C_SHORT 1 #define DP_C_LONG 2 #define DP_C_LDOUBLE 3 #define DP_C_LLONG 4 #define char_to_int(p) ((p)- '0') #ifndef MAX #define MAX(p,q) (((p) >= (q)) ? (p) : (q)) #endif static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args) { char ch; LLONG value; LDOUBLE fvalue; char *strvalue; int min; int max; int state; int flags; int cflags; size_t currlen; state = DP_S_DEFAULT; currlen = flags = cflags = min = 0; max = -1; ch = *format++; while (state != DP_S_DONE) { if (ch == '\0') state = DP_S_DONE; switch(state) { case DP_S_DEFAULT: if (ch == '%') state = DP_S_FLAGS; else dopr_outch (buffer, &currlen, maxlen, ch); ch = *format++; break; case DP_S_FLAGS: switch (ch) { case '-': flags |= DP_F_MINUS; ch = *format++; break; case '+': flags |= DP_F_PLUS; ch = *format++; break; case ' ': flags |= DP_F_SPACE; ch = *format++; break; case '#': flags |= DP_F_NUM; ch = *format++; break; case '0': flags |= DP_F_ZERO; ch = *format++; break; default: state = DP_S_MIN; break; } break; case DP_S_MIN: if (isdigit((unsigned char)ch)) { min = 10*min + char_to_int (ch); ch = *format++; } else if (ch == '*') { min = va_arg (args, int); ch = *format++; state = DP_S_DOT; } else { state = DP_S_DOT; } break; case DP_S_DOT: if (ch == '.') { state = DP_S_MAX; ch = *format++; } else { state = DP_S_MOD; } break; case DP_S_MAX: if (isdigit((unsigned char)ch)) { if (max < 0) max = 0; max = 10*max + char_to_int (ch); ch = *format++; } else if (ch == '*') { max = va_arg (args, int); ch = *format++; state = DP_S_MOD; } else { state = DP_S_MOD; } break; case DP_S_MOD: switch (ch) { case 'h': cflags = DP_C_SHORT; ch = *format++; break; case 'l': cflags = DP_C_LONG; ch = *format++; if (ch == 'l') { /* It's a long long */ cflags = DP_C_LLONG; ch = *format++; } break; case 'L': cflags = DP_C_LDOUBLE; ch = *format++; break; default: break; } state = DP_S_CONV; break; case DP_S_CONV: switch (ch) { case 'd': case 'i': if (cflags == DP_C_SHORT) value = va_arg (args, int); else if (cflags == DP_C_LONG) value = va_arg (args, long int); else if (cflags == DP_C_LLONG) value = va_arg (args, LLONG); else value = va_arg (args, int); fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); break; case 'o': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (long)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); break; case 'u': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (LLONG)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); break; case 'X': flags |= DP_F_UP; case 'x': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (LLONG)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); break; case 'f': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); /* um, floating point? */ fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); break; case 'E': flags |= DP_F_UP; case 'e': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'G': flags |= DP_F_UP; case 'g': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'c': dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); break; case 's': strvalue = va_arg (args, char *); if (!strvalue) strvalue = "(NULL)"; if (max == -1) { max = strlen(strvalue); } if (min > 0 && max >= 0 && min > max) max = min; fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); break; case 'p': strvalue = (char *)va_arg(args, void *); fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); break; case 'n': if (cflags == DP_C_SHORT) { short int *num; num = va_arg (args, short int *); *num = currlen; } else if (cflags == DP_C_LONG) { long int *num; num = va_arg (args, long int *); *num = (long int)currlen; } else if (cflags == DP_C_LLONG) { LLONG *num; num = va_arg (args, LLONG *); *num = (LLONG)currlen; } else { int *num; num = va_arg (args, int *); *num = currlen; } break; case '%': dopr_outch (buffer, &currlen, maxlen, ch); break; case 'w': /* not supported yet, treat as next char */ ch = *format++; break; default: /* Unknown, skip */ break; } ch = *format++; state = DP_S_DEFAULT; flags = cflags = min = 0; max = -1; break; case DP_S_DONE: break; default: /* hmm? */ break; /* some picky compilers need this */ } } if (maxlen != 0) { if (currlen < maxlen - 1) buffer[currlen] = '\0'; else if (maxlen > 0) buffer[maxlen - 1] = '\0'; } return currlen; } static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max) { int padlen, strln; /* amount to pad */ int cnt = 0; #ifdef DEBUG_SNPRINTF printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value); #endif if (value == 0) { value = ""; } for (strln = 0; value[strln]; ++strln); /* strlen */ padlen = min - strln; if (padlen < 0) padlen = 0; if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justify */ while ((padlen > 0) && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, ' '); --padlen; ++cnt; } while (*value && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, *value++); ++cnt; } while ((padlen < 0) && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; ++cnt; } } /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ static void fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags) { int signvalue = 0; unsigned long uvalue; char convert[20]; int place = 0; int spadlen = 0; /* amount to space pad */ int zpadlen = 0; /* amount to zero pad */ int caps = 0; if (max < 0) max = 0; uvalue = value; if(!(flags & DP_F_UNSIGNED)) { if( value < 0 ) { signvalue = '-'; uvalue = -value; } else { if (flags & DP_F_PLUS) /* Do a sign (+/i) */ signvalue = '+'; else if (flags & DP_F_SPACE) signvalue = ' '; } } if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ do { convert[place++] = (caps? "0123456789ABCDEF":"0123456789abcdef") [uvalue % (unsigned)base ]; uvalue = (uvalue / (unsigned)base ); } while(uvalue && (place < 20)); if (place == 20) place--; convert[place] = 0; zpadlen = max - place; spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); if (zpadlen < 0) zpadlen = 0; if (spadlen < 0) spadlen = 0; if (flags & DP_F_ZERO) { zpadlen = MAX(zpadlen, spadlen); spadlen = 0; } if (flags & DP_F_MINUS) spadlen = -spadlen; /* Left Justifty */ #ifdef DEBUG_SNPRINTF printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", zpadlen, spadlen, min, max, place); #endif /* Spaces */ while (spadlen > 0) { dopr_outch (buffer, currlen, maxlen, ' '); --spadlen; } /* Sign */ if (signvalue) dopr_outch (buffer, currlen, maxlen, signvalue); /* Zeros */ if (zpadlen > 0) { while (zpadlen > 0) { dopr_outch (buffer, currlen, maxlen, '0'); --zpadlen; } } /* Digits */ while (place > 0) dopr_outch (buffer, currlen, maxlen, convert[--place]); /* Left Justified spaces */ while (spadlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); ++spadlen; } } static LDOUBLE abs_val(LDOUBLE value) { LDOUBLE result = value; if (value < 0) result = -value; return result; } static LDOUBLE POW10(int exp) { LDOUBLE result = 1; while (exp) { result *= 10; exp--; } return result; } static LLONG ROUND(LDOUBLE value) { LLONG intpart; intpart = (LLONG)value; value = value - intpart; if (value >= 0.5) intpart++; return intpart; } /* a replacement for modf that doesn't need the math library. Should be portable, but slow */ static double my_modf(double x0, double *iptr) { int i; long l; double x = x0; double f = 1.0; for (i=0;i<100;i++) { l = (long)x; if (l <= (x+1) && l >= (x-1)) break; x *= 0.1; f *= 10.0; } if (i == 100) { /* yikes! the number is beyond what we can handle. What do we do? */ (*iptr) = 0; return 0; } if (i != 0) { double i2; double ret; ret = my_modf(x0-l*f, &i2); (*iptr) = l*f + i2; return ret; } (*iptr) = l; return x - (*iptr); } static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags) { int signvalue = 0; double ufvalue; char iconvert[311]; char fconvert[311]; int iplace = 0; int fplace = 0; int padlen = 0; /* amount to pad */ int zpadlen = 0; int caps = 0; int index; double intpart; double fracpart; double temp; /* * AIX manpage says the default is 0, but Solaris says the default * is 6, and sprintf on AIX defaults to 6 */ if (max < 0) max = 6; ufvalue = abs_val (fvalue); if (fvalue < 0) { signvalue = '-'; } else { if (flags & DP_F_PLUS) { /* Do a sign (+/i) */ signvalue = '+'; } else { if (flags & DP_F_SPACE) signvalue = ' '; } } #if 0 if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ #endif #if 0 if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */ #endif /* * Sorry, we only support 16 digits past the decimal because of our * conversion method */ if (max > 16) max = 16; /* We "cheat" by converting the fractional part to integer by * multiplying by a factor of 10 */ temp = ufvalue; my_modf(temp, &intpart); fracpart = ROUND((POW10(max)) * (ufvalue - intpart)); if (fracpart >= POW10(max)) { intpart++; fracpart -= POW10(max); } /* Convert integer part */ do { temp = intpart; my_modf(intpart*0.1, &intpart); temp = temp*0.1; index = (int) ((temp -intpart +0.05)* 10.0); /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ /* printf ("%llf, %f, %x\n", temp, intpart, index); */ iconvert[iplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; } while (intpart && (iplace < 311)); if (iplace == 311) iplace--; iconvert[iplace] = 0; /* Convert fractional part */ if (fracpart) { do { temp = fracpart; my_modf(fracpart*0.1, &fracpart); temp = temp*0.1; index = (int) ((temp -fracpart +0.05)* 10.0); /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */ /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */ fconvert[fplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; } while(fracpart && (fplace < 311)); if (fplace == 311) fplace--; } fconvert[fplace] = 0; /* -1 for decimal point, another -1 if we are printing a sign */ padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); zpadlen = max - fplace; if (zpadlen < 0) zpadlen = 0; if (padlen < 0) padlen = 0; if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justifty */ if ((flags & DP_F_ZERO) && (padlen > 0)) { if (signvalue) { dopr_outch (buffer, currlen, maxlen, signvalue); --padlen; signvalue = 0; } while (padlen > 0) { dopr_outch (buffer, currlen, maxlen, '0'); --padlen; } } while (padlen > 0) { dopr_outch (buffer, currlen, maxlen, ' '); --padlen; } if (signvalue) dopr_outch (buffer, currlen, maxlen, signvalue); while (iplace > 0) dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); #ifdef DEBUG_SNPRINTF printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen); #endif /* * Decimal point. This should probably use locale to find the correct * char to print out. */ if (max > 0) { dopr_outch (buffer, currlen, maxlen, '.'); while (fplace > 0) dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); } while (zpadlen > 0) { dopr_outch (buffer, currlen, maxlen, '0'); --zpadlen; } while (padlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; } } static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) { if (*currlen < maxlen) { buffer[(*currlen)] = c; } (*currlen)++; } /* yes this really must be a ||. Don't muck with this (tridge) */ #if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) int vsnprintf (char *str, size_t count, const char *fmt, va_list args) { return dopr(str, count, fmt, args); } #endif /* yes this really must be a ||. Don't muck wiith this (tridge) * * The logic for these two is that we need our own definition if the * OS *either* has no definition of *sprintf, or if it does have one * that doesn't work properly according to the autoconf test. Perhaps * these should really be smb_snprintf to avoid conflicts with buggy * linkers? -- mbp */ #if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_SNPRINTF) int snprintf(char *str,size_t count,const char *fmt,...) { size_t ret; va_list ap; va_start(ap, fmt); ret = vsnprintf(str, count, fmt, ap); va_end(ap); return ret; } #endif #endif #ifndef HAVE_VASPRINTF int vasprintf(char **ptr, const char *format, va_list ap) { int ret; ret = vsnprintf(0, 0, format, ap); if (ret <= 0) return ret; (*ptr) = (char *)malloc(ret+1); if (!*ptr) return -1; ret = vsnprintf(*ptr, ret+1, format, ap); return ret; } #endif #ifndef HAVE_ASPRINTF int asprintf(char **ptr, const char *format, ...) { va_list ap; int ret; *ptr = 0; va_start(ap, format); ret = vasprintf(ptr, format, ap); va_end(ap); return ret; } #endif #ifndef HAVE_VSYSLOG #ifdef HAVE_SYSLOG void vsyslog (int facility_priority, char *format, va_list arglist) { char *msg = 0; vasprintf(&msg, format, arglist); if (!msg) return; syslog(facility_priority, "%s", msg); free(msg); } #endif /* HAVE_SYSLOG */ #endif /* HAVE_VSYSLOG */ #ifdef TEST_SNPRINTF int sprintf(char *str,const char *fmt,...); int main (void) { char buf1[1024]; char buf2[1024]; char *fp_fmt[] = { "%1.1f", "%-1.5f", "%1.5f", "%123.9f", "%10.5f", "% 10.5f", "%+22.9f", "%+4.9f", "%01.3f", "%4f", "%3.1f", "%3.2f", "%.0f", "%f", "-16.16f", 0 }; double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 0.9996, 1.996, 4.136, 0}; char *int_fmt[] = { "%-1.5d", "%1.5d", "%123.9d", "%5.5d", "%10.5d", "% 10.5d", "%+22.33d", "%01.3d", "%4d", "%d", 0 }; long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; char *str_fmt[] = { "10.5s", "5.10s", "10.1s", "0.10s", "10.0s", "1.10s", "%s", "%.1s", "%.10s", "%10s", 0 }; char *str_vals[] = {"hello", "a", "", "a longer string", 0}; int x, y; int fail = 0; int num = 0; printf ("Testing snprintf format codes against system sprintf...\n"); for (x = 0; fp_fmt[x] ; x++) { for (y = 0; fp_nums[y] != 0 ; y++) { int l1 = snprintf(0, 0, fp_fmt[x], fp_nums[y]); int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); sprintf (buf2, fp_fmt[x], fp_nums[y]); if (strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", fp_fmt[x], buf1, buf2); fail++; } if (l1 != l2) { printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]); fail++; } num++; } } for (x = 0; int_fmt[x] ; x++) { for (y = 0; int_nums[y] != 0 ; y++) { int l1 = snprintf(0, 0, int_fmt[x], int_nums[y]); int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); sprintf (buf2, int_fmt[x], int_nums[y]); if (strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", int_fmt[x], buf1, buf2); fail++; } if (l1 != l2) { printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]); fail++; } num++; } } for (x = 0; str_fmt[x] ; x++) { for (y = 0; str_vals[y] != 0 ; y++) { int l1 = snprintf(0, 0, str_fmt[x], str_vals[y]); int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); sprintf (buf2, str_fmt[x], str_vals[y]); if (strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", str_fmt[x], buf1, buf2); fail++; } if (l1 != l2) { printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]); fail++; } num++; } } printf ("%d tests failed out of %d.\n", fail, num); printf("seeing how many digits we support\n"); { double v0 = 0.12345678901234567890123456789012345678901; for (x=0; x<100; x++) { snprintf(buf1, sizeof(buf1), "%1.1f", v0*pow(10, x)); sprintf(buf2, "%1.1f", v0*pow(10, x)); if (strcmp(buf1, buf2)) { printf("we seem to support %d digits\n", x-1); break; } } } return 0; } #endif /* SNPRINTF_TEST */ swig-3.0.2/CCache/packaging/0000775000175000017500000000000012343605122015375 5ustar williamwilliamswig-3.0.2/CCache/packaging/README0000664000175000017500000000037312343605122016260 0ustar williamwilliamThese packaging files are contributd by users of ccache. I do not maintain them, and they may well need updating before you use them. I don't distribute binary packages of ccache myself, but if you wish to add ccache to a distribution then that's OK swig-3.0.2/CCache/packaging/ccache.spec0000664000175000017500000000133512343605122017461 0ustar williamwilliamSummary: Compiler Cache Name: ccache Version: 2.3 Release: 1 Group: Development/Languages License: GPL URL: http://ccache.samba.org/ Source: ccache-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-root %description ccache caches gcc output files %prep %setup -q %build %configure make install -d -m 0755 $RPM_BUILD_ROOT%{_bindir} install -m 0755 ccache $RPM_BUILD_ROOT%{_bindir} install -d -m 0755 $RPM_BUILD_ROOT%{_mandir}/man1 install -m 0644 ccache.1 $RPM_BUILD_ROOT%{_mandir}/man1 %files %defattr(-,root,root) %doc README %{_mandir}/man1/ccache.1* %{_bindir}/ccache %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %changelog * Mon Apr 01 2002 Peter Jones - Created the package swig-3.0.2/CCache/install-sh0000775000175000017500000001124512343605122015460 0ustar williamwilliam#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 swig-3.0.2/CCache/cleanup.c0000664000175000017500000001205112343605122015243 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* functions to cleanup the cache directory when it gets too large */ #include "ccache.h" static struct files { char *fname; time_t mtime; size_t size; } **files; static unsigned allocated; static unsigned num_files; static size_t total_size; static size_t total_files; static size_t size_threshold; static size_t files_threshold; /* file comparison function to try to delete the oldest files first */ static int files_compare(struct files **f1, struct files **f2) { if ((*f2)->mtime == (*f1)->mtime) { return strcmp((*f2)->fname, (*f1)->fname); } if ((*f2)->mtime > (*f1)->mtime) { return -1; } return 1; } /* this builds the list of files in the cache */ static void traverse_fn(const char *fname, struct stat *st) { char *p; if (!S_ISREG(st->st_mode)) return; p = str_basename(fname); if (strcmp(p, "stats") == 0) { free(p); return; } free(p); if (num_files == allocated) { allocated = 10000 + num_files*2; files = (struct files **)x_realloc(files, sizeof(struct files *)*allocated); } files[num_files] = (struct files *)x_malloc(sizeof(struct files)); files[num_files]->fname = x_strdup(fname); files[num_files]->mtime = st->st_mtime; files[num_files]->size = file_size(st) / 1024; total_size += files[num_files]->size; num_files++; } /* sort the files we've found and delete the oldest ones until we are below the thresholds */ static void sort_and_clean(size_t minfiles) { unsigned i; size_t adjusted_minfiles = minfiles; if (num_files > 1) { /* sort in ascending data order */ qsort(files, num_files, sizeof(struct files *), (COMPAR_FN_T)files_compare); } /* ensure newly cached files (minfiles) are kept - instead of matching the filenames of those newly cached, a faster and simpler approach assumes these are the most recent in the cache and if any other cached files have an identical time stamp, they will also be kept - this approach would not be needed if the cleanup was done at exit. */ if (minfiles != 0 && minfiles < num_files) { unsigned minfiles_index = num_files - minfiles; time_t minfiles_time = files[minfiles_index]->mtime; for (i=1; i<=minfiles_index; i++) { if (files[minfiles_index-i]->mtime == minfiles_time) adjusted_minfiles++; else break; } } /* delete enough files to bring us below the threshold */ for (i=0;ifname) != 0 && errno != ENOENT) { fprintf(stderr, "unlink %s - %s\n", files[i]->fname, strerror(errno)); continue; } total_size -= files[i]->size; } total_files = num_files - i; } /* cleanup in one cache subdir */ void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles) { unsigned i; size_threshold = maxsize * LIMIT_MULTIPLE; files_threshold = maxfiles * LIMIT_MULTIPLE; num_files = 0; total_size = 0; /* build a list of files */ traverse(dir, traverse_fn); /* clean the cache */ sort_and_clean(minfiles); stats_set_sizes(dir, total_files, total_size); /* free it up */ for (i=0;ifname); free(files[i]); files[i] = NULL; } if (files) free(files); allocated = 0; files = NULL; num_files = 0; total_size = 0; } /* cleanup in all cache subdirs */ void cleanup_all(const char *dir) { unsigned counters[STATS_END]; char *dname, *sfile; int i; for (i=0;i<=0xF;i++) { x_asprintf(&dname, "%s/%1x", dir, i); x_asprintf(&sfile, "%s/%1x/stats", dir, i); memset(counters, 0, sizeof(counters)); stats_read(sfile, counters); cleanup_dir(dname, counters[STATS_MAXFILES], counters[STATS_MAXSIZE], 0); free(dname); free(sfile); } } /* traverse function for wiping files */ static void wipe_fn(const char *fname, struct stat *st) { char *p; if (!S_ISREG(st->st_mode)) return; p = str_basename(fname); if (strcmp(p, "stats") == 0) { free(p); return; } free(p); unlink(fname); } /* wipe all cached files in all subdirs */ void wipe_all(const char *dir) { char *dname; int i; for (i=0;i<=0xF;i++) { x_asprintf(&dname, "%s/%1x", dir, i); traverse(dir, wipe_fn); free(dname); } /* and fix the counters */ cleanup_all(dir); } swig-3.0.2/CCache/execute.c0000664000175000017500000001431412343605122015262 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" #ifdef _WIN32 char *argvtos(char **argv) { int i, len; char *ptr, *str; for (i = 0, len = 0; argv[i]; i++) { len += strlen(argv[i]) + 3; } str = ptr = (char *)malloc(len + 1); if (str == NULL) return NULL; for (i = 0; argv[i]; i++) { len = strlen(argv[i]); *ptr++ = '"'; memcpy(ptr, argv[i], len); ptr += len; *ptr++ = '"'; *ptr++ = ' '; } *ptr = 0; return str; } #endif /* execute a compiler backend, capturing all output to the given paths the full path to the compiler to run is in argv[0] */ int execute(char **argv, const char *path_stdout, const char *path_stderr) { #ifdef _WIN32 #if 1 PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; BOOL ret; DWORD exitcode; char *args; HANDLE fd_out, fd_err; SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; /* TODO: needs moving after possible exit() below, but before stdout is redirected */ if (ccache_verbose) { display_execute_args(argv); } fd_out = CreateFile(path_stdout, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fd_out == INVALID_HANDLE_VALUE) { return STATUS_NOCACHE; } fd_err = CreateFile(path_stderr, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fd_err == INVALID_HANDLE_VALUE) { return STATUS_NOCACHE; } ZeroMemory(&pinfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&sinfo, sizeof(STARTUPINFO)); sinfo.cb = sizeof(STARTUPINFO); sinfo.hStdError = fd_err; sinfo.hStdOutput = fd_out; sinfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE); sinfo.dwFlags |= STARTF_USESTDHANDLES; args = argvtos(argv); ret = CreateProcessA(argv[0], args, NULL, NULL, TRUE, 0, NULL, NULL, &sinfo, &pinfo); free(args); CloseHandle(fd_out); CloseHandle(fd_err); if (ret == 0) return -1; WaitForSingleObject(pinfo.hProcess, INFINITE); GetExitCodeProcess(pinfo.hProcess, &exitcode); CloseHandle(pinfo.hProcess); CloseHandle(pinfo.hThread); return exitcode; #else /* possibly slightly faster */ /* needs fixing to quote commandline options to handle spaces in CCACHE_DIR etc */ int status = -2; int fd, std_od = -1, std_ed = -1; /* TODO: needs moving after possible exit() below, but before stdout is redirected */ if (ccache_verbose) { display_execute_args(argv); } unlink(path_stdout); std_od = _dup(1); fd = _open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { exit(STATUS_NOCACHE); } _dup2(fd, 1); _close(fd); unlink(path_stderr); fd = _open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); std_ed = _dup(2); if (fd == -1) { exit(STATUS_NOCACHE); } _dup2(fd, 2); _close(fd); /* Spawn process (_exec* familly doesn't return) */ status = _spawnv(_P_WAIT, argv[0], (const char **)argv); /* Restore descriptors */ if (std_od != -1) _dup2(std_od, 1); if (std_ed != -1) _dup2(std_ed, 2); _flushall(); return (status>0); #endif #else pid_t pid; int status; pid = fork(); if (pid == -1) fatal("Failed to fork"); if (pid == 0) { int fd; /* TODO: needs moving after possible exit() below, but before stdout is redirected */ if (ccache_verbose) { display_execute_args(argv); } unlink(path_stdout); fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { exit(STATUS_NOCACHE); } dup2(fd, 1); close(fd); unlink(path_stderr); fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { exit(STATUS_NOCACHE); } dup2(fd, 2); close(fd); exit(execv(argv[0], argv)); } if (waitpid(pid, &status, 0) != pid) { fatal("waitpid failed"); } if (WEXITSTATUS(status) == 0 && WIFSIGNALED(status)) { return -1; } return WEXITSTATUS(status); #endif } /* find an executable by name in $PATH. Exclude any that are links to exclude_name */ char *find_executable(const char *name, const char *exclude_name) { #if _WIN32 (void)exclude_name; DWORD ret; char namebuf[MAX_PATH]; ret = SearchPathA(getenv("CCACHE_PATH"), name, ".exe", sizeof(namebuf), namebuf, NULL); if (ret != 0) { return x_strdup(namebuf); } return NULL; #else char *path; char *tok; struct stat st1, st2; if (*name == '/') { return x_strdup(name); } path = getenv("CCACHE_PATH"); if (!path) { path = getenv("PATH"); } if (!path) { cc_log("no PATH variable!?\n"); stats_update(STATS_ENVIRONMMENT); return NULL; } path = x_strdup(path); /* search the path looking for the first compiler of the right name that isn't us */ for (tok=strtok(path,":"); tok; tok = strtok(NULL, ":")) { char *fname; x_asprintf(&fname, "%s/%s", tok, name); /* look for a normal executable file */ if (access(fname, X_OK) == 0 && lstat(fname, &st1) == 0 && stat(fname, &st2) == 0 && S_ISREG(st2.st_mode)) { /* if its a symlink then ensure it doesn't point at something called exclude_name */ if (S_ISLNK(st1.st_mode)) { char *buf = x_realpath(fname); if (buf) { char *p = str_basename(buf); if (strcmp(p, exclude_name) == 0) { /* its a link to "ccache" ! */ free(p); free(buf); continue; } free(buf); free(p); } } /* found it! */ free(path); return fname; } free(fname); } return NULL; #endif } void display_execute_args(char **argv) { if (argv) { printf("ccache executing: "); while (*argv) { printf("%s ", *argv); ++argv; } printf("\n"); fflush(stdout); } } swig-3.0.2/CCache/ccache.c0000664000175000017500000010345112343605122015027 0ustar williamwilliam/* a re-implementation of the compilercache scripts in C The idea is based on the shell-script compilercache by Erik Thiele Copyright (C) Andrew Tridgell 2002 Copyright (C) Martin Pool 2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" /* verbose mode */ int ccache_verbose = 0; /* the base cache directory */ char *cache_dir = NULL; /* the directory for temporary files */ static char *temp_dir = NULL; /* the debug logfile name, if set */ char *cache_logfile = NULL; /* the argument list after processing */ static ARGS *stripped_args; /* the original argument list */ static ARGS *orig_args; /* the output filename being compiled to */ static char *output_file; /* the source file */ static char *input_file; /* the name of the file containing the cached object code */ static char *hashname; /* the extension of the file after pre-processing */ static const char *i_extension; /* the name of the temporary pre-processor file */ static char *i_tmpfile; /* are we compiling a .i or .ii file directly? */ static int direct_i_file; /* the name of the cpp stderr file */ static char *cpp_stderr; /* the name of the statistics file */ char *stats_file = NULL; /* can we safely use the unification hashing backend? */ static int enable_unify; /* should we strip -c when running the preprocessor only? */ static int strip_c_option; /* customisation for using the SWIG compiler */ static int swig; /* a list of supported file extensions, and the equivalent extension for code that has been through the pre-processor */ static struct { char *extension; char *i_extension; } extensions[] = { {"c", "i"}, {"C", "ii"}, {"m", "mi"}, {"cc", "ii"}, {"CC", "ii"}, {"cpp", "ii"}, {"CPP", "ii"}, {"cxx", "ii"}, {"CXX", "ii"}, {"c++", "ii"}, {"C++", "ii"}, {"i", "i"}, {"ii", "ii"}, {NULL, NULL}}; /* something went badly wrong - just execute the real compiler */ static void failed(void) { char *e; /* delete intermediate pre-processor file if needed */ if (i_tmpfile) { if (!direct_i_file) { unlink(i_tmpfile); } free(i_tmpfile); i_tmpfile = NULL; } /* delete the cpp stderr file if necessary */ if (cpp_stderr) { unlink(cpp_stderr); free(cpp_stderr); cpp_stderr = NULL; } /* strip any local args */ args_strip(orig_args, "--ccache-"); if ((e=getenv("CCACHE_PREFIX"))) { char *p = find_executable(e, MYNAME); if (!p) { cc_log("could not find executable (%s)\n", e); perror(e); exit(1); } args_add_prefix(orig_args, p); } if (ccache_verbose) { display_execute_args(orig_args->argv); } if (swig) { putenv("CCACHE_OUTFILES"); } #ifndef _WIN32 execv(orig_args->argv[0], orig_args->argv); cc_log("execv returned (%s)!\n", strerror(errno)); perror(orig_args->argv[0]); exit(1); #else /* execv on Windows causes the 'non-regular' testcase to fail, so use Win32 API instead */ { PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; BOOL ret; DWORD exitcode; char *args; ZeroMemory(&pinfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&sinfo, sizeof(STARTUPINFO)); sinfo.cb = sizeof(STARTUPINFO); args = argvtos(orig_args->argv); ret = CreateProcessA(orig_args->argv[0], args, NULL, NULL, TRUE, 0, NULL, NULL, &sinfo, &pinfo); if (!ret) { exitcode = 1; cc_log("CreateProcessA failed starting %s\n", orig_args->argv[0]); perror_win32(orig_args->argv[0]); } else { WaitForSingleObject(pinfo.hProcess, INFINITE); GetExitCodeProcess(pinfo.hProcess, &exitcode); CloseHandle(pinfo.hProcess); CloseHandle(pinfo.hThread); } free(args); exit(exitcode); } #endif } /* return a string to be used to distinguish temporary files this also tries to cope with NFS by adding the local hostname */ static const char *tmp_string(void) { static char *ret; if (!ret) { char hostname[200]; strcpy(hostname, "unknown"); #if HAVE_GETHOSTNAME gethostname(hostname, sizeof(hostname)-1); #endif hostname[sizeof(hostname)-1] = 0; if (asprintf(&ret, "%s.%u", hostname, (unsigned)getpid()) == -1) { fatal("could not allocate tmp_string"); } } return ret; } /* update cached file sizes and count helper function for to_cache() */ static void to_cache_stats_helper(struct stat *pstat, char *cached_filename, char *tmp_outfiles, int *files_size, int *cached_files_count) { #if ENABLE_ZLIB /* do an extra stat on the cache file for the size statistics */ if (stat(cached_filename, pstat) != 0) { cc_log("failed to stat cache files - %s\n", strerror(errno)); stats_update(STATS_ERROR); if (tmp_outfiles) { unlink(tmp_outfiles); } failed(); } #else (void)cached_filename; (void)tmp_outfiles; #endif (*files_size) += file_size(pstat); (*cached_files_count)++; } /* run the real compiler and put the result in cache */ static void to_cache(ARGS *args) { char *path_stderr; char *tmp_stdout, *tmp_stderr, *tmp_outfiles; struct stat st1; int status; int cached_files_count = 0; int files_size = 0; x_asprintf(&tmp_stdout, "%s/tmp.stdout.%s", temp_dir, tmp_string()); x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string()); x_asprintf(&tmp_outfiles, "%s/tmp.outfiles.%s", temp_dir, tmp_string()); if (strip_c_option && !swig) { args_add(stripped_args, "-c"); } if (output_file) { args_add(args, "-o"); args_add(args, output_file); } /* Turn off DEPENDENCIES_OUTPUT when running cc1, because * otherwise it will emit a line like * * tmp.stdout.vexed.732.o: /home/mbp/.ccache/tmp.stdout.vexed.732.i * * unsetenv() is on BSD and Linux but not portable. */ putenv("DEPENDENCIES_OUTPUT"); /* Give SWIG a filename for it to create and populate with a list of files that it generates */ if (swig) { char *ccache_outfiles; x_asprintf(&ccache_outfiles, "CCACHE_OUTFILES=%s", tmp_outfiles); unlink(tmp_outfiles); if (getenv("CCACHE_OUTFILES") || putenv(ccache_outfiles) == -1) { cc_log("CCACHE_OUTFILES env variable already set or could not be set\n"); stats_update(STATS_ERROR); failed(); } } if (getenv("CCACHE_CPP2")) { args_add(args, input_file); } else { if (swig) { args_add(args, "-nopreprocess"); } args_add(args, i_tmpfile); } status = execute(args->argv, tmp_stdout, tmp_stderr); args_pop(args, 3); if (stat(tmp_stdout, &st1) != 0 || st1.st_size != 0) { cc_log("compiler produced stdout for %s\n", input_file); stats_update(STATS_STDOUT); unlink(tmp_stdout); unlink(tmp_stderr); unlink(tmp_outfiles); if (!swig) unlink(output_file); failed(); } unlink(tmp_stdout); if (status != 0) { int fd; cc_log("compile of %s gave status = %d\n", input_file, status); stats_update(STATS_STATUS); fd = open(tmp_stderr, O_RDONLY | O_BINARY); if (fd != -1) { if (cpp_stderr) { /* we might have some stderr from cpp */ int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); if (fd2 != -1) { copy_fd(fd2, 2); close(fd2); unlink(cpp_stderr); cpp_stderr = NULL; } } /* we can use a quick method of getting the failed output */ copy_fd(fd, 2); close(fd); unlink(tmp_stderr); if (i_tmpfile && !direct_i_file) { unlink(i_tmpfile); } exit(status); } unlink(tmp_stderr); unlink(tmp_outfiles); if (!swig) unlink(output_file); failed(); } else { int hardlink = (getenv("CCACHE_NOCOMPRESS") != 0) && (getenv("CCACHE_HARDLINK") != 0); if (swig) { /* read the list of generated files and copy each of them into the cache */ FILE *file; file = fopen(tmp_outfiles, "r"); if (file) { char out_filename[FILENAME_MAX + 1]; char out_filename_cache[FILENAME_MAX + 1]; while (fgets(out_filename, FILENAME_MAX, file)) { char *linefeed = strchr(out_filename, '\n'); if (linefeed) { char *potential_cr = linefeed - 1; if (potential_cr >= out_filename && *potential_cr == '\r') *potential_cr = 0; *linefeed = 0; if (cached_files_count == 0) { strcpy(out_filename_cache, hashname); } else { sprintf(out_filename_cache, "%s.%d", hashname, cached_files_count); } if (commit_to_cache(out_filename, out_filename_cache, hardlink) != 0) { fclose(file); unlink(tmp_outfiles); failed(); } to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count); } else { cached_files_count = 0; break; } } fclose(file); if (cached_files_count == 0) { cc_log("failed to copy output files to cache - internal error\n"); stats_update(STATS_ERROR); unlink(tmp_outfiles); failed(); } /* also copy the (uncompressed) file containing the list of generated files into the cache */ sprintf(out_filename_cache, "%s.outfiles", hashname); if (stat(tmp_outfiles, &st1) != 0 || safe_rename(tmp_outfiles, out_filename_cache) != 0) { cc_log("failed to copy outfiles file to cache - %s\n", strerror(errno)); stats_update(STATS_ERROR); unlink(tmp_outfiles); failed(); } to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count); unlink(tmp_outfiles); } else { cc_log("failed to open temp outfiles file - %s\n", strerror(errno)); stats_update(STATS_ERROR); failed(); } } else { if (commit_to_cache(output_file, hashname, hardlink) != 0) { failed(); } to_cache_stats_helper(&st1, hashname, 0, &files_size, &cached_files_count); } } x_asprintf(&path_stderr, "%s.stderr", hashname); if (stat(tmp_stderr, &st1) != 0 || move_file(tmp_stderr, path_stderr) != 0) { cc_log("failed to rename tmp files - %s\n", strerror(errno)); stats_update(STATS_ERROR); failed(); } to_cache_stats_helper(&st1, path_stderr, 0, &files_size, &cached_files_count); cc_log("Placed %d files for %s into cache\n", cached_files_count, input_file); stats_tocache(files_size, cached_files_count); free(tmp_stderr); free(tmp_stdout); free(tmp_outfiles); free(path_stderr); } /* find the hash for a command. The hash includes all argument lists, plus the output from running the compiler with -E */ static void find_hash(ARGS *args) { int i; char *path_stdout, *path_stderr; char *hash_dir; char *s; struct stat st; int status; int nlevels = 2; char *input_base; char *tmp; if ((s = getenv("CCACHE_NLEVELS"))) { nlevels = atoi(s); if (nlevels < 1) nlevels = 1; if (nlevels > 8) nlevels = 8; } hash_start(); /* when we are doing the unifying tricks we need to include the input file name in the hash to get the warnings right */ if (enable_unify || swig) { hash_string(input_file); } if (swig) { if (output_file) { hash_string(output_file); } } else { /* we have to hash the extension, as a .i file isn't treated the same by the compiler as a .ii file */ hash_string(i_extension); } /* first the arguments */ for (i=1;iargc;i++) { /* some arguments don't contribute to the hash. The theory is that these arguments will change the output of -E if they are going to have any effect at all, or they only affect linking */ if (i < args->argc-1) { if (strcmp(args->argv[i], "-I") == 0 || strcmp(args->argv[i], "-include") == 0 || strcmp(args->argv[i], "-L") == 0 || strcmp(args->argv[i], "-D") == 0 || strcmp(args->argv[i], "-idirafter") == 0 || strcmp(args->argv[i], "-isystem") == 0) { i++; continue; } } if (strncmp(args->argv[i], "-I", 2) == 0 || strncmp(args->argv[i], "-L", 2) == 0 || strncmp(args->argv[i], "-D", 2) == 0 || strncmp(args->argv[i], "-idirafter", 10) == 0 || strncmp(args->argv[i], "-isystem", 8) == 0) { continue; } if (strncmp(args->argv[i], "--specs=", 8) == 0 && stat(args->argv[i]+8, &st) == 0) { /* if given a explicit specs file, then hash that file, but don't include the path to it in the hash */ hash_file(args->argv[i]+8); continue; } /* all other arguments are included in the hash */ hash_string(args->argv[i]); } /* the compiler driver size and date. This is a simple minded way to try and detect compiler upgrades. It is not 100% reliable */ if (stat(args->argv[0], &st) != 0) { cc_log("Couldn't stat the compiler!? (argv[0]='%s')\n", args->argv[0]); stats_update(STATS_COMPILER); failed(); } /* also include the hash of the compiler name - as some compilers use hard links and behave differently depending on the real name */ if (st.st_nlink > 1) { hash_string(str_basename(args->argv[0])); } hash_int(st.st_size); hash_int(st.st_mtime); /* possibly hash the current working directory */ if (getenv("CCACHE_HASHDIR")) { char *cwd = gnu_getcwd(); if (cwd) { hash_string(cwd); free(cwd); } } /* ~/hello.c -> tmp.hello.123.i limit the basename to 10 characters in order to cope with filesystem with small maximum filename length limits */ input_base = str_basename(input_file); tmp = strchr(input_base, '.'); if (tmp != NULL) { *tmp = 0; } if (strlen(input_base) > 10) { input_base[10] = 0; } /* now the run */ x_asprintf(&path_stdout, "%s/%s.tmp.%s.%s", temp_dir, input_base, tmp_string(), i_extension); x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string()); if (!direct_i_file) { /* run cpp on the input file to obtain the .i */ args_add(args, "-E"); args_add(args, input_file); status = execute(args->argv, path_stdout, path_stderr); args_pop(args, 2); } else { /* we are compiling a .i or .ii file - that means we can skip the cpp stage and directly form the correct i_tmpfile */ path_stdout = x_strdup(input_file); if (create_empty_file(path_stderr) != 0) { cc_log("failed to create empty stderr file\n"); stats_update(STATS_ERROR); failed(); } status = 0; } if (status != 0) { if (!direct_i_file) { unlink(path_stdout); } unlink(path_stderr); cc_log("the preprocessor gave %d\n", status); stats_update(STATS_PREPROCESSOR); failed(); } /* if the compilation is with -g then we have to include the whole of the preprocessor output, which means we are sensitive to line number information. Otherwise we can discard line number info, which makes us less sensitive to reformatting changes Note! I have now disabled the unification code by default as it gives the wrong line numbers for warnings. Pity. */ if (!enable_unify) { hash_file(path_stdout); } else { if (unify_hash(path_stdout) != 0) { stats_update(STATS_ERROR); failed(); } } hash_file(path_stderr); i_tmpfile = path_stdout; if (!getenv("CCACHE_CPP2")) { /* if we are using the CPP trick then we need to remember this stderr data and output it just before the main stderr from the compiler pass */ cpp_stderr = path_stderr; } else { unlink(path_stderr); free(path_stderr); } /* we use a N level subdir for the cache path to reduce the impact on filesystems which are slow for large directories */ s = hash_result(); x_asprintf(&hash_dir, "%s/%c", cache_dir, s[0]); x_asprintf(&stats_file, "%s/stats", hash_dir); for (i=1; i= out_filename && *potential_cr == '\r') *potential_cr = 0; *linefeed = 0; if (retrieved_files_count == 0) { strcpy(out_filename_cache, hashname); } else { sprintf(out_filename_cache, "%s.%d", hashname, retrieved_files_count); } passfail = retrieve_from_cache(out_filename_cache, out_filename, hardlink); if (passfail == -1) { break; } retrieved_files_count++; } else { cc_log("failed to copy output files from cache - internal error\n"); stats_update(STATS_ERROR); passfail = -1; break; } } if (retrieved_files_count == 0) { cc_log("failed to copy output files from cache - internal error\n"); stats_update(STATS_ERROR); passfail = -1; } fclose(file); } else { cc_log("failed to open cached outfiles file - %s\n", strerror(errno)); stats_update(STATS_ERROR); } } else { passfail = retrieve_from_cache(hashname, output_file, hardlink); } if (passfail == -1) { close(fd_stderr); unlink(stderr_file); free(stderr_file); return; } free(stderr_file); } /* get rid of the intermediate preprocessor file */ if (i_tmpfile) { if (!direct_i_file) { unlink(i_tmpfile); } free(i_tmpfile); i_tmpfile = NULL; } /* send the cpp stderr, if applicable */ fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY); if (fd_cpp_stderr != -1) { copy_fd(fd_cpp_stderr, 2); close(fd_cpp_stderr); unlink(cpp_stderr); free(cpp_stderr); cpp_stderr = NULL; } /* send the stderr */ copy_fd(fd_stderr, 2); close(fd_stderr); /* and exit with the right status code */ if (first) { cc_log("got cached result for %s\n", input_file); stats_update(STATS_CACHED); } exit(0); } /* find the real compiler. We just search the PATH to find a executable of the same name that isn't a link to ourselves */ static void find_compiler(int argc, char **argv) { char *base; char *path; orig_args = args_init(argc, argv); base = str_basename(argv[0]); /* we might be being invoked like "ccache gcc -c foo.c" */ if (strcmp(base, MYNAME) == 0) { args_remove_first(orig_args); free(base); if (strchr(argv[1],'/') #ifdef _WIN32 || strchr(argv[1],'\\') #endif ) { /* a full path was given */ return; } base = str_basename(argv[1]); } /* support user override of the compiler */ if ((path=getenv("CCACHE_CC"))) { base = x_strdup(path); } orig_args->argv[0] = find_executable(base, MYNAME); /* can't find the compiler! */ if (!orig_args->argv[0]) { stats_update(STATS_COMPILER); cc_log("could not find compiler (%s)\n", base); perror(base); exit(1); } } /* check a filename for C/C++ extension. Return the pre-processor extension */ static const char *check_extension(const char *fname, int *direct_i) { int i; const char *p; if (direct_i) { *direct_i = 0; } if (swig) return "ii"; /* any file extension is acceptable as input for SWIG */ p = strrchr(fname, '.'); if (!p) return NULL; p++; for (i=0; extensions[i].extension; i++) { if (strcmp(p, extensions[i].extension) == 0) { if (direct_i && strcmp(p, extensions[i].i_extension) == 0) { *direct_i = 1; } p = getenv("CCACHE_EXTENSION"); if (p) return p; return extensions[i].i_extension; } } return NULL; } /* process the compiler options to form the correct set of options for obtaining the preprocessor output */ static void process_args(int argc, char **argv) { int i; int found_c_opt = 0; int found_S_opt = 0; struct stat st; char *e; /* is gcc being asked to output dependencies? */ int generating_dependencies = 0; /* is the dependency makefile name overridden with -MF? */ int dependency_filename_specified = 0; /* is the dependency makefile target name specified with -MQ or -MF? */ int dependency_target_specified = 0; stripped_args = args_init(0, NULL); args_add(stripped_args, argv[0]); /* -c not required for SWIG */ if (swig) { found_c_opt = 1; } for (i=1; iargv[0]); if (strstr(basename, "swig") || getenv("CCACHE_SWIG")) { swig = 1; } free(basename); } /* the main ccache driver function */ static void ccache(int argc, char *argv[]) { /* find the real compiler */ find_compiler(argc, argv); /* use the real compiler if HOME is not set */ if (!cache_dir) { cc_log("Unable to determine home directory\n"); cc_log("ccache is disabled\n"); failed(); } /* we might be disabled */ if (getenv("CCACHE_DISABLE")) { cc_log("ccache is disabled\n"); failed(); } if (getenv("CCACHE_STRIPC")) { strip_c_option = 1; } if (getenv("CCACHE_UNIFY")) { enable_unify = 1; } detect_swig(); /* process argument list, returning a new set of arguments for pre-processing */ process_args(orig_args->argc, orig_args->argv); /* run with -E to find the hash */ find_hash(stripped_args); /* if we can return from cache at this point then do */ from_cache(1); if (getenv("CCACHE_READONLY")) { cc_log("read-only set - doing real compile\n"); failed(); } /* run real compiler, sending output to cache */ to_cache(stripped_args); /* return from cache */ from_cache(0); /* oh oh! */ cc_log("secondary from_cache failed!\n"); stats_update(STATS_ERROR); failed(); } static void usage(void) { printf("%s, a compiler cache including support for SWIG. Version %s\n", MYNAME, CCACHE_VERSION); printf("Copyright Andrew Tridgell, 2002\n\n"); printf("Usage:\n"); printf("\t" MYNAME " [options]\n"); printf("\t" MYNAME " compiler [compile options]\n"); printf("\tcompiler [compile options] (via symbolic link)\n"); printf("\nOptions:\n"); printf("-s show statistics summary\n"); printf("-z zero statistics\n"); printf("-c run a cache cleanup\n"); printf("-C clear the cache completely\n"); printf("-F set maximum files in cache\n"); printf("-M set maximum size of cache (use G, M or K)\n"); printf("-h this help page\n"); printf("-V print version number\n"); } static void check_cache_dir(void) { if (!cache_dir) { fatal("Unable to determine home directory"); } } /* the main program when not doing a compile */ static int ccache_main(int argc, char *argv[]) { int c; size_t v; while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { switch (c) { case 'V': printf("%s version %s\n", MYNAME, CCACHE_VERSION); printf("Copyright Andrew Tridgell 2002\n"); printf("Released under the GNU GPL v2 or later\n"); exit(0); case 'h': usage(); exit(0); case 's': check_cache_dir(); stats_summary(); break; case 'c': check_cache_dir(); cleanup_all(cache_dir); printf("Cleaned cache\n"); break; case 'C': check_cache_dir(); wipe_all(cache_dir); printf("Cleared cache\n"); break; case 'z': check_cache_dir(); stats_zero(); printf("Statistics cleared\n"); break; case 'F': check_cache_dir(); v = atoi(optarg); if (stats_set_limits(v, -1) == 0) { printf("Set cache file limit to %u\n", (unsigned)v); } else { printf("Could not set cache file limit.\n"); exit(1); } break; case 'M': check_cache_dir(); v = value_units(optarg); if (stats_set_limits(-1, v) == 0) { printf("Set cache size limit to %uk\n", (unsigned)v); } else { printf("Could not set cache size limit.\n"); exit(1); } break; default: usage(); exit(1); } } return 0; } /* Make a copy of stderr that will not be cached, so things like distcc can send networking errors to it. */ static void setup_uncached_err(void) { char *buf; int uncached_fd; uncached_fd = dup(2); if (uncached_fd == -1) { cc_log("dup(2) failed\n"); stats_update(STATS_ERROR); failed(); } /* leak a pointer to the environment */ x_asprintf(&buf, "UNCACHED_ERR_FD=%d", uncached_fd); if (putenv(buf) == -1) { cc_log("putenv failed\n"); stats_update(STATS_ERROR); failed(); } } int main(int argc, char *argv[]) { char *p; cache_dir = getenv("CCACHE_DIR"); if (!cache_dir) { const char *home_directory = get_home_directory(); if (home_directory) { x_asprintf(&cache_dir, "%s/.ccache", home_directory); } } cache_logfile = getenv("CCACHE_LOGFILE"); if (getenv("CCACHE_VERBOSE")) { ccache_verbose = 1; } setup_uncached_err(); /* the user might have set CCACHE_UMASK */ p = getenv("CCACHE_UMASK"); if (p) { mode_t mask; errno = 0; mask = strtol(p, NULL, 8); if (errno == 0) { umask(mask); } } /* check if we are being invoked as "ccache" */ if (strlen(argv[0]) >= strlen(MYNAME) && strcmp(argv[0] + strlen(argv[0]) - strlen(MYNAME), MYNAME) == 0) { if (argc < 2) { usage(); exit(1); } /* if the first argument isn't an option, then assume we are being passed a compiler name and options */ if (argv[1][0] == '-') { return ccache_main(argc, argv); } } /* make sure the cache dir exists */ if (cache_dir && (create_dir(cache_dir) != 0)) { fprintf(stderr,"ccache: failed to create %s (%s)\n", cache_dir, strerror(errno)); exit(1); } temp_dir = getenv("CCACHE_TEMPDIR"); if (!temp_dir) { x_asprintf(&temp_dir, "%s/temp", cache_dir); /* make sure temp dir exists if not supplied by user */ if (temp_dir && create_dir(temp_dir) != 0) { fprintf(stderr,"ccache: failed to create %s (%s)\n", temp_dir, strerror(errno)); exit(1); } } if (!getenv("CCACHE_READONLY")) { if (create_cachedirtag(cache_dir) != 0) { fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n", cache_dir, strerror(errno)); exit(1); } } ccache(argc, argv); return 1; } swig-3.0.2/CCache/mdfour.c0000664000175000017500000001401312343605122015110 0ustar williamwilliam/* a implementation of MD4 designed for use in the SMB authentication protocol Copyright (C) Andrew Tridgell 1997-1998. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" /* NOTE: This code makes no attempt to be fast! It assumes that a int is at least 32 bits long */ static struct mdfour *m; #define MASK32 (0xffffffff) #define F(X,Y,Z) ((((X)&(Y)) | ((~(X))&(Z)))) #define G(X,Y,Z) ((((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))) #define H(X,Y,Z) (((X)^(Y)^(Z))) #define lshift(x,s) (((((x)<<(s))&MASK32) | (((x)>>(32-(s)))&MASK32))) #define ROUND1(a,b,c,d,k,s) a = lshift((a + F(b,c,d) + M[k])&MASK32, s) #define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c,d) + M[k] + 0x5A827999)&MASK32,s) #define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s) /* this applies md4 to 64 byte chunks */ static void mdfour64(uint32 *M) { uint32 AA, BB, CC, DD; uint32 A,B,C,D; A = m->A; B = m->B; C = m->C; D = m->D; AA = A; BB = B; CC = C; DD = D; ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7); ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19); ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7); ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19); ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7); ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19); ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7); ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19); ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5); ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13); ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5); ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13); ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5); ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13); ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5); ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13); ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9); ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15); ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9); ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15); ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9); ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15); ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9); ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15); A += AA; B += BB; C += CC; D += DD; A &= MASK32; B &= MASK32; C &= MASK32; D &= MASK32; m->A = A; m->B = B; m->C = C; m->D = D; } static void copy64(uint32 *M, const unsigned char *in) { int i; for (i=0;i<16;i++) M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | (in[i*4+1]<<8) | (in[i*4+0]<<0); } static void copy4(unsigned char *out,uint32 x) { out[0] = x&0xFF; out[1] = (x>>8)&0xFF; out[2] = (x>>16)&0xFF; out[3] = (x>>24)&0xFF; } void mdfour_begin(struct mdfour *md) { md->A = 0x67452301; md->B = 0xefcdab89; md->C = 0x98badcfe; md->D = 0x10325476; md->totalN = 0; md->tail_len = 0; } static void mdfour_tail(const unsigned char *in, int n) { unsigned char buf[128]; uint32 M[16]; uint32 b; m->totalN += n; b = m->totalN * 8; memset(buf, 0, 128); if (n) memcpy(buf, in, n); buf[n] = 0x80; if (n <= 55) { copy4(buf+56, b); copy64(M, buf); mdfour64(M); } else { copy4(buf+120, b); copy64(M, buf); mdfour64(M); copy64(M, buf+64); mdfour64(M); } } void mdfour_update(struct mdfour *md, const unsigned char *in, int n) { uint32 M[16]; m = md; if (in == NULL) { mdfour_tail(md->tail, md->tail_len); return; } if (md->tail_len) { int len = 64 - md->tail_len; if (len > n) len = n; memcpy(md->tail+md->tail_len, in, len); md->tail_len += len; n -= len; in += len; if (md->tail_len == 64) { copy64(M, md->tail); mdfour64(M); m->totalN += 64; md->tail_len = 0; } } while (n >= 64) { copy64(M, in); mdfour64(M); in += 64; n -= 64; m->totalN += 64; } if (n) { memcpy(md->tail, in, n); md->tail_len = n; } } void mdfour_result(struct mdfour *md, unsigned char *out) { m = md; copy4(out, m->A); copy4(out+4, m->B); copy4(out+8, m->C); copy4(out+12, m->D); } void mdfour(unsigned char *out, const unsigned char *in, int n) { struct mdfour md; mdfour_begin(&md); mdfour_update(&md, in, n); mdfour_update(&md, NULL, 0); mdfour_result(&md, out); } #ifdef TEST_MDFOUR static void file_checksum1(char *fname) { int fd, i; struct mdfour md; unsigned char buf[1024], sum[16]; unsigned chunk; fd = open(fname,O_RDONLY|O_BINARY); if (fd == -1) { perror("fname"); exit(1); } chunk = 1 + random() % (sizeof(buf) - 1); mdfour_begin(&md); while (1) { int n = read(fd, buf, chunk); if (n >= 0) { mdfour_update(&md, buf, n); } if (n < chunk) break; } close(fd); mdfour_update(&md, NULL, 0); mdfour_result(&md, sum); for (i=0;i<16;i++) printf("%02x", sum[i]); printf("\n"); } #if 0 #include "../md4.h" static void file_checksum2(char *fname) { int fd, i; MDstruct md; unsigned char buf[64], sum[16]; fd = open(fname,O_RDONLY|O_BINARY); if (fd == -1) { perror("fname"); exit(1); } MDbegin(&md); while (1) { int n = read(fd, buf, sizeof(buf)); if (n <= 0) break; MDupdate(&md, buf, n*8); } if (!md.done) { MDupdate(&md, buf, 0); } close(fd); memcpy(sum, md.buffer, 16); for (i=0;i<16;i++) printf("%02x", sum[i]); printf("\n"); } #endif int main(int argc, char *argv[]) { file_checksum1(argv[1]); #if 0 file_checksum2(argv[1]); #endif return 0; } #endif swig-3.0.2/CCache/ccache.yo0000664000175000017500000004202712343605122015235 0ustar williamwilliamwhenman( COMMENT(html output not great if included when using html2doc) manpage(ccache-swig)(1)()()() ) whenhtml(htmlcommand( ccache-swig(1) manpage

Using SWIG with ccache - ccache-swig(1) manpage

)) manpagename(ccache-swig)(a fast compiler cache) whenhtml(htmlcommand( ccache-swig - a fast compiler cache )) manpagesynopsis() ccache-swig [OPTION] ccache-swig [COMPILER OPTIONS] [COMPILER OPTIONS] manpagedescription() ccache-swig is a compiler cache. It speeds up re-compilation of C/C++/SWIG code by caching previous compiles and detecting when the same compile is being done again. ccache-swig is ccache plus support for SWIG. ccache and ccache-swig are used interchangeably in this document. manpagesection(OPTIONS SUMMARY) Here is a summary of the options to ccache-swig. verb( -s show statistics summary -z zero statistics -c run a cache cleanup -C clear the cache completely -F set maximum files in cache -M set maximum size of cache (use G, M or K) -h this help page -V print version number ) manpageoptions() These options only apply when you invoke ccache as "ccache-swig". When invoked as a compiler none of these options apply. In that case your normal compiler options apply and you should refer to your compilers documentation. startdit() dit(bf(-h)) Print a options summary page dit(bf(-s)) Print the current statistics summary for the cache. The statistics are stored spread across the subdirectories of the cache. Using "ccache-swig -s" adds up the statistics across all subdirectories and prints the totals. dit(bf(-z)) Zero the cache statistics. dit(bf(-V)) Print the ccache version number dit(bf(-c)) Clean the cache and re-calculate the cache file count and size totals. Normally the -c option should not be necessary as ccache keeps the cache below the specified limits at runtime and keeps statistics up to date on each compile. This option is mostly useful if you manually modify the cache contents or believe that the cache size statistics may be inaccurate. dit(bf(-C)) Clear the entire cache, removing all cached files. dit(bf(-F )) This sets the maximum number of files allowed in the cache. The value is stored inside the cache directory and applies to all future compiles. Due to the way the value is stored the actual value used is always rounded down to the nearest multiple of 16. dit(bf(-M )) This sets the maximum cache size. You can specify a value in gigabytes, megabytes or kilobytes by appending a G, M or K to the value. The default is gigabytes. The actual value stored is rounded down to the nearest multiple of 16 kilobytes. enddit() manpagesection(INSTALLATION) There are two ways to use ccache. You can either prefix your compile commands with "ccache-swig" or you can create a symbolic link between ccache-swig and the names of your compilers. The first method is most convenient if you just want to try out ccache or wish to use it for some specific projects. The second method is most useful for when you wish to use ccache for all your compiles. To install for usage by the first method just copy ccache-swig to somewhere in your path. To install for the second method do something like this: verb( cp ccache-swig /usr/local/bin/ ln -s /usr/local/bin/ccache-swig /usr/local/bin/gcc ln -s /usr/local/bin/ccache-swig /usr/local/bin/g++ ln -s /usr/local/bin/ccache-swig /usr/local/bin/cc ln -s /usr/local/bin/ccache-swig /usr/local/bin/swig ) This will work as long as /usr/local/bin comes before the path to gcc (which is usually in /usr/bin). After installing you may wish to run "which gcc" to make sure that the correct link is being used. Note! Do not use a hard link, use a symbolic link. A hardlink will cause "interesting" problems. manpagesection(EXTRA OPTIONS) When run as a compiler front end ccache usually just takes the same command line options as the compiler you are using. The only exception to this is the option '--ccache-skip'. That option can be used to tell ccache that the next option is definitely not a input filename, and should be passed along to the compiler as-is. The reason this can be important is that ccache does need to parse the command line and determine what is an input filename and what is a compiler option, as it needs the input filename to determine the name of the resulting object file (among other things). The heuristic ccache uses in this parse is that any string on the command line that exists as a file is treated as an input file name (usually a C file). By using --ccache-skip you can force an option to not be treated as an input file name and instead be passed along to the compiler as a command line option. manpagesection(ENVIRONMENT VARIABLES) ccache uses a number of environment variables to control operation. In most cases you won't need any of these as the defaults will be fine. startdit() dit(bf(CCACHE_DIR)) the CCACHE_DIR environment variable specifies where ccache will keep its cached compiler output. The default is "$HOME/.ccache". dit(bf(CCACHE_TEMPDIR)) the CCACHE_TEMPDIR environment variable specifies where ccache will put temporary files. The default is the same as CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same filesystem as the CCACHE_DIR path, so that renames of files between the two directories can work. dit(bf(CCACHE_LOGFILE)) If you set the CCACHE_LOGFILE environment variable then ccache will write some log information on cache hits and misses in that file. This is useful for tracking down problems. dit(bf(CCACHE_VERBOSE)) If you set the CCACHE_VERBOSE environment variable then ccache will display on stdout all the compiler invocations that it makes. This can useful for debugging unexpected problems. dit(bf(CCACHE_PATH)) You can optionally set CCACHE_PATH to a colon separated path where ccache will look for the real compilers. If you don't do this then ccache will look for the first executable matching the compiler name in the normal PATH that isn't a symbolic link to ccache itself. dit(bf(CCACHE_CC)) You can optionally set CCACHE_CC to force the name of the compiler to use. If you don't do this then ccache works it out from the command line. dit(bf(CCACHE_PREFIX)) This option adds a prefix to the command line that ccache runs when invoking the compiler. Also see the section below on using ccache with distcc. dit(bf(CCACHE_DISABLE)) If you set the environment variable CCACHE_DISABLE then ccache will just call the real compiler, bypassing the cache completely. dit(bf(CCACHE_READONLY)) the CCACHE_READONLY environment variable tells ccache to attempt to use existing cached object files, but not to try to add anything new to the cache. If you are using this because your CCACHE_DIR is read-only, then you may find that you also need to set CCACHE_TEMPDIR as otherwise ccache will fail to create the temporary files. dit(bf(CCACHE_CPP2)) If you set the environment variable CCACHE_CPP2 then ccache will not use the optimisation of avoiding the 2nd call to the pre-processor by compiling the pre-processed output that was used for finding the hash in the case of a cache miss. This is primarily a debugging option, although it is possible that some unusual compilers will have problems with the intermediate filename extensions used in this optimisation, in which case this option could allow ccache to be used. dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable CCACHE_NOCOMPRESS then there is no compression used on files that go into the cache. However, this setting has no effect on how files are retrieved from the cache, compressed results will still be usable. dit(bf(CCACHE_NOSTATS)) If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile. dit(bf(CCACHE_NLEVELS)) The environment variable CCACHE_NLEVELS allows you to choose the number of levels of hash in the cache directory. The default is 2. The minimum is 1 and the maximum is 8. dit(bf(CCACHE_HARDLINK)) If you set the environment variable CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy. Using hard links is faster, but can confuse programs like 'make' that rely on modification times. Hard links are never made for compressed cache files. dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached results, even if it finds them. New results are still cached, but existing cache entries are ignored. dit(bf(CCACHE_UMASK)) This sets the umask for ccache and all child processes (such as the compiler). This is mostly useful when you wish to share your cache with other users. Note that this also affects the file permissions set on the object files created from your compilations. dit(bf(CCACHE_HASHDIR)) This tells ccache to hash the current working directory when calculating the hash that is used to distinguish two compiles. This prevents a problem with the storage of the current working directory in the debug info of a object file, which can lead ccache to give a cached object file that has the working directory in the debug info set incorrectly. This option is off by default as the incorrect setting of this debug info rarely causes problems. If you strike problems with gdb not using the correct directory then enable this option. dit(bf(CCACHE_UNIFY)) If you set the environment variable CCACHE_UNIFY then ccache will use the C/C++ unifier when hashing the pre-processor output if -g is not used in the compile. The unifier is slower than a normal hash, so setting this environment variable loses a little bit of speed, but it means that ccache can take advantage of not recompiling when the changes to the source code consist of reformatting only. Note that using CCACHE_UNIFY changes the hash, so cached compiles with CCACHE_UNIFY set cannot be used when CCACHE_UNIFY is not set and vice versa. The reason the unifier is off by default is that it can give incorrect line number information in compiler warning messages. dit(bf(CCACHE_EXTENSION)) Normally ccache tries to automatically determine the extension to use for intermediate C pre-processor files based on the type of file being compiled. Unfortunately this sometimes doesn't work, for example when using the aCC compiler on HP-UX. On systems like this you can use the CCACHE_EXTENSION option to override the default. On HP-UX set this environment variable to "i" if you use the aCC compiler. dit(bf(CCACHE_STRIPC)) If you set the environment variable CCACHE_STRIPC then ccache will strip the -c option when invoking the preprocessor. This option is primarily for the Sun Workshop C++ compiler as without this option an unwarranted warning is displayed: CC: Warning: "-E" redefines product from "object" to "source (stdout)" when -E and -c is used together. dit(bf(CCACHE_SWIG)) When using SWIG as the compiler and it does not have 'swig' in the executable name, then the CCACHE_SWIG environment variable needs to be set in order for ccache to work correctly with SWIG. The use of CCACHE_CPP2 is also recommended for SWIG due to some preprocessor quirks, however, use of CCACHE_CPP2 can often be skipped -- check your generated code with and without this option set. Known problems are using preprocessor directives within %inline blocks and the use of '#pragma SWIG'. enddit() manpagesection(CACHE SIZE MANAGEMENT) By default ccache has a one gigabyte limit on the cache size and no maximum number of files. You can set a different limit using the "ccache -M" and "ccache -F" options, which set the size and number of files limits. When these limits are reached ccache will reduce the cache to 20% below the numbers you specified in order to avoid doing the cache clean operation too often. manpagesection(CACHE COMPRESSION) By default on most platforms ccache will compress all files it puts into the cache using the zlib compression. While this involves a negligible performance slowdown, it significantly increases the number of files that fit in the cache. You can turn off compression setting the CCACHE_NOCOMPRESS environment variable. manpagesection(HOW IT WORKS) The basic idea is to detect when you are compiling exactly the same code a 2nd time and use the previously compiled output. You detect that it is the same code by forming a hash of: itemization( it() the pre-processor output from running the compiler with -E it() the command line options it() the real compilers size and modification time it() any stderr output generated by the compiler ) These are hashed using md4 (a strong hash) and a cache file is formed based on that hash result. When the same compilation is done a second time ccache is able to supply the correct compiler output (including all warnings etc) from the cache. ccache has been carefully written to always produce exactly the same compiler output that you would get without the cache. If you ever discover a case where ccache changes the output of your compiler then please let me know. manpagesection(USING CCACHE WITH DISTCC) distcc is a very useful program for distributing compilation across a range of compiler servers. It is often useful to combine distcc with ccache, so that compiles that are done are sped up by distcc, but that ccache avoids the compile completely where possible. To use distcc with ccache I recommend using the CCACHE_PREFIX option. You just need to set the environment variable CCACHE_PREFIX to 'distcc' and ccache will prefix the command line used with the compiler with the command 'distcc'. manpagesection(SHARING A CACHE) A group of developers can increase the cache hit rate by sharing a cache directory. The hard links however cause unwanted side effects, as all links to a cached file share the file's modification timestamp. This results in false dependencies to be triggered by timestamp-based build systems whenever another user links to an existing file. Typically, users will see that their libraries and binaries are relinked without reason. To share a cache without side effects, the following conditions need to be met: itemization( it() Use the same bf(CCACHE_DIR) environment variable setting it() Unset the bf(CCACHE_HARDLINK) environment variable it() Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in the group. it() Make sure that all users have write permission in the entire cache directory (and that you trust all users of the shared cache). it() Make sure that the setgid bit is set on all directories in the cache. This tells the filesystem to inherit group ownership for new directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might be useful for this. it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with versions of ccache that do not support compression. ) manpagesection(HISTORY) ccache was inspired by the compilercache shell script script written by Erik Thiele and I would like to thank him for an excellent piece of work. See url(http://www.erikyyy.de/compilercache/)(http://www.erikyyy.de/compilercache/) for the Erik's scripts. ccache-swig is a port of the original ccache with support added for use with SWIG. I wrote ccache because I wanted to get a bit more speed out of a compiler cache and I wanted to remove some of the limitations of the shell-script version. manpagesection(DIFFERENCES FROM COMPILERCACHE) The biggest differences between Erik's compilercache script and ccache are: itemization( it() ccache is written in C, which makes it a bit faster (calling out to external programs is mostly what slowed down the scripts). it() ccache can automatically find the real compiler it() ccache keeps statistics on hits/misses it() ccache can do automatic cache management it() ccache can cache compiler output that includes warnings. In many cases this gives ccache a much higher cache hit rate. it() ccache can handle a much wider ranger of compiler options it() ccache avoids a double call to cpp on a cache miss ) manpagesection(CREDITS) Thanks to the following people for their contributions to ccache itemization( it() Erik Thiele for the original compilercache script it() Luciano Rocha for the idea of compiling the pre-processor output to avoid a 2nd cpp pass it() Paul Russell for many suggestions and the debian packaging ) manpageauthor() ccache was written by Andrew Tridgell url(http://samba.org/~tridge/)(http://samba.org/~tridge/). ccache was adapted to create ccache-swig for use with SWIG by William Fulton. If you wish to report a problem or make a suggestion then please email the SWIG developers on the swig-devel mailing list, see url(http://www.swig.org/mail.html)(http://www.swig.org/mail.html) ccache is released under the GNU General Public License version 2 or later. Please see the file COPYING for license details. whenhtml(htmlcommand( )) swig-3.0.2/CCache/stats.c0000664000175000017500000002147512343605122014764 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* routines to handle the stats files the stats file is stored one per cache subdirectory to make this more scalable */ #include "ccache.h" extern char *stats_file; extern char *cache_dir; #define STATS_VERSION 1 #define FLAG_NOZERO 1 /* don't zero with the -z option */ #define FLAG_ALWAYS 2 /* always show, even if zero */ static struct { enum stats stat; char *message; void (*fn)(unsigned ); unsigned flags; } stats_info[] = { { STATS_CACHED, "cache hit ", NULL, FLAG_ALWAYS }, { STATS_TOCACHE, "cache miss ", NULL, FLAG_ALWAYS }, { STATS_LINK, "called for link ", NULL, 0 }, { STATS_MULTIPLE, "multiple source files ", NULL, 0 }, { STATS_STDOUT, "compiler produced stdout ", NULL, 0 }, { STATS_STATUS, "compile failed ", NULL, 0 }, { STATS_ERROR, "ccache internal error ", NULL, 0 }, { STATS_PREPROCESSOR, "preprocessor error ", NULL, 0 }, { STATS_COMPILER, "couldn't find the compiler ", NULL, 0 }, { STATS_MISSING, "cache file missing ", NULL, 0 }, { STATS_ARGS, "bad compiler arguments ", NULL, 0 }, { STATS_NOTC, "not a C/C++ file ", NULL, 0 }, { STATS_CONFTEST, "autoconf compile/link ", NULL, 0 }, { STATS_UNSUPPORTED, "unsupported compiler option ", NULL, 0 }, { STATS_OUTSTDOUT, "output to stdout ", NULL, 0 }, { STATS_DEVICE, "output to a non-regular file ", NULL, 0 }, { STATS_NOINPUT, "no input file ", NULL, 0 }, { STATS_ENVIRONMMENT, "error due to bad env variable ", NULL, 0 }, { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS }, { STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO|FLAG_ALWAYS }, { STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO }, { STATS_MAXSIZE, "max cache size ", display_size, FLAG_NOZERO }, { STATS_NONE, NULL, NULL, 0 } }; /* parse a stats file from a buffer - adding to the counters */ static void parse_stats(unsigned counters[STATS_END], char *buf) { int i; char *p, *p2; p = buf; for (i=0;i= (int)sizeof(buf)-1) fatal("stats too long?!"); } len += snprintf(buf+len, sizeof(buf)-(len+1), "\n"); if (len >= (int)sizeof(buf)-1) fatal("stats too long?!"); lseek(fd, 0, SEEK_SET); if (write(fd, buf, len) == -1) fatal("could not write stats"); } /* fill in some default stats values */ static void stats_default(unsigned counters[STATS_END]) { counters[STATS_MAXSIZE] += DEFAULT_MAXSIZE / 16; } /* read in the stats from one dir and add to the counters */ static void stats_read_fd(int fd, unsigned counters[STATS_END]) { char buf[1024]; int len; len = read(fd, buf, sizeof(buf)-1); if (len <= 0) { stats_default(counters); return; } buf[len] = 0; parse_stats(counters, buf); } /* update the stats counter for this compile */ static void stats_update_size(enum stats stat, size_t size, size_t numfiles) { int fd; unsigned counters[STATS_END]; int need_cleanup = 0; if (getenv("CCACHE_NOSTATS")) return; if (!stats_file) { if (!cache_dir) return; x_asprintf(&stats_file, "%s/stats", cache_dir); } /* open safely to try to prevent symlink races */ fd = safe_open(stats_file); /* still can't get it? don't bother ... */ if (fd == -1) return; memset(counters, 0, sizeof(counters)); if (lock_fd(fd) != 0) return; /* read in the old stats */ stats_read_fd(fd, counters); /* update them */ counters[stat]++; /* on a cache miss we up the file count and size */ if (stat == STATS_TOCACHE) { counters[STATS_NUMFILES] += numfiles; counters[STATS_TOTALSIZE] += size; } /* and write them out */ write_stats(fd, counters); close(fd); /* we might need to cleanup if the cache has now got too big */ if (counters[STATS_MAXFILES] != 0 && counters[STATS_NUMFILES] > counters[STATS_MAXFILES]) { need_cleanup = 1; } if (counters[STATS_MAXSIZE] != 0 && counters[STATS_TOTALSIZE] > counters[STATS_MAXSIZE]) { need_cleanup = 1; } if (need_cleanup) { char *p = dirname(stats_file); cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE], numfiles); free(p); } } /* record a cache miss */ void stats_tocache(size_t size, size_t numfiles) { /* convert size to kilobytes */ size = size / 1024; stats_update_size(STATS_TOCACHE, size, numfiles); } /* update a normal stat */ void stats_update(enum stats stat) { stats_update_size(stat, 0, 0); } /* read in the stats from one dir and add to the counters */ void stats_read(const char *stats_file, unsigned counters[STATS_END]) { int fd; fd = open(stats_file, O_RDONLY|O_BINARY); if (fd == -1) { stats_default(counters); return; } lock_fd(fd); stats_read_fd(fd, counters); close(fd); } /* sum and display the total stats for all cache dirs */ void stats_summary(void) { int dir, i; unsigned counters[STATS_END]; memset(counters, 0, sizeof(counters)); /* add up the stats in each directory */ for (dir=-1;dir<=0xF;dir++) { char *fname; if (dir == -1) { x_asprintf(&fname, "%s/stats", cache_dir); } else { x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir); } stats_read(fname, counters); free(fname); /* oh what a nasty hack ... */ if (dir == -1) { counters[STATS_MAXSIZE] = 0; } } printf("cache directory %s\n", cache_dir); /* and display them */ for (i=0;stats_info[i].message;i++) { enum stats stat = stats_info[i].stat; if (counters[stat] == 0 && !(stats_info[i].flags & FLAG_ALWAYS)) { continue; } printf("%s ", stats_info[i].message); if (stats_info[i].fn) { stats_info[i].fn(counters[stat]); printf("\n"); } else { printf("%8u\n", counters[stat]); } } } /* zero all the stats structures */ void stats_zero(void) { int dir, fd; unsigned i; char *fname; unsigned counters[STATS_END]; x_asprintf(&fname, "%s/stats", cache_dir); unlink(fname); free(fname); for (dir=0;dir<=0xF;dir++) { x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir); fd = safe_open(fname); if (fd == -1) { free(fname); continue; } memset(counters, 0, sizeof(counters)); lock_fd(fd); stats_read_fd(fd, counters); for (i=0;stats_info[i].message;i++) { if (!(stats_info[i].flags & FLAG_NOZERO)) { counters[stats_info[i].stat] = 0; } } write_stats(fd, counters); close(fd); free(fname); } } /* set the per directory limits */ int stats_set_limits(long maxfiles, long maxsize) { int dir; unsigned counters[STATS_END]; if (maxfiles != -1) { maxfiles /= 16; } if (maxsize != -1) { maxsize /= 16; } if (create_dir(cache_dir) != 0) { return 1; } /* set the limits in each directory */ for (dir=0;dir<=0xF;dir++) { char *fname, *cdir; int fd; x_asprintf(&cdir, "%s/%1x", cache_dir, dir); if (create_dir(cdir) != 0) { return 1; } x_asprintf(&fname, "%s/stats", cdir); free(cdir); memset(counters, 0, sizeof(counters)); fd = safe_open(fname); if (fd != -1) { lock_fd(fd); stats_read_fd(fd, counters); if (maxfiles != -1) { counters[STATS_MAXFILES] = maxfiles; } if (maxsize != -1) { counters[STATS_MAXSIZE] = maxsize; } write_stats(fd, counters); close(fd); } free(fname); } return 0; } /* set the per directory sizes */ void stats_set_sizes(const char *dir, size_t num_files, size_t total_size) { int fd; unsigned counters[STATS_END]; char *stats_file; create_dir(dir); x_asprintf(&stats_file, "%s/stats", dir); memset(counters, 0, sizeof(counters)); fd = safe_open(stats_file); if (fd != -1) { lock_fd(fd); stats_read_fd(fd, counters); counters[STATS_NUMFILES] = num_files; counters[STATS_TOTALSIZE] = total_size; write_stats(fd, counters); close(fd); } free(stats_file); } swig-3.0.2/CCache/hash.c0000664000175000017500000000332312343605122014541 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* simple front-end functions to mdfour code */ #include "ccache.h" static struct mdfour md; void hash_buffer(const char *s, int len) { mdfour_update(&md, (unsigned char *)s, len); } void hash_start(void) { mdfour_begin(&md); } void hash_string(const char *s) { hash_buffer(s, strlen(s)); } void hash_int(int x) { hash_buffer((char *)&x, sizeof(x)); } /* add contents of a file to the hash */ void hash_file(const char *fname) { char buf[1024]; int fd, n; fd = open(fname, O_RDONLY|O_BINARY); if (fd == -1) { cc_log("Failed to open %s\n", fname); fatal("hash_file"); } while ((n = read(fd, buf, sizeof(buf))) > 0) { hash_buffer(buf, n); } close(fd); } /* return the hash result as a static string */ char *hash_result(void) { unsigned char sum[16]; static char ret[53]; int i; hash_buffer(NULL, 0); mdfour_result(&md, sum); for (i=0;i<16;i++) { sprintf(&ret[i*2], "%02x", (unsigned)sum[i]); } sprintf(&ret[i*2], "-%u", (unsigned)md.totalN); return ret; } swig-3.0.2/CCache/configure0000775000175000017500000044336312343706577015415 0ustar williamwilliam#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for ccache-swig 0.0. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ccache-swig' PACKAGE_TARNAME='ccache-swig' PACKAGE_VERSION='0.0' PACKAGE_STRING='ccache-swig 0.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="ccache.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS EGREP GREP INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_zlib ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures ccache-swig 0.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/ccache-swig] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of ccache-swig 0.0:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-zlib enable zlib support for ccache compression Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF ccache-swig configure 0.0 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by ccache-swig $as_me 0.0, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Get version from SWIG in ccache_swig_config.h.in { $as_echo "$as_me:${as_lineno-$LINENO}: Configuring ccache" >&5 $as_echo "$as_me: Configuring ccache" >&6;} ac_config_headers="$ac_config_headers config.h" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # for program_transform_name $as_echo "#define _GNU_SOURCE 1" >>confdefs.h # If GCC, turn on warnings. if test "x$GCC" = "xyes" then CFLAGS="$CFLAGS -Wall -W" else CFLAGS="$CFLAGS -O" fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } if eval \${$as_ac_Header+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$as_ac_Header=yes" else eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$as_ac_Header { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' dir; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' x; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if ${ac_cv_header_sys_wait_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in ctype.h strings.h stdlib.h string.h pwd.h sys/time.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in realpath snprintf vsnprintf vasprintf asprintf mkstemp do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in gethostname getpwuid do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in utimes do : ac_fn_c_check_func "$LINENO" "utimes" "ac_cv_func_utimes" if test "x$ac_cv_func_utimes" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UTIMES 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compar_fn_t in stdlib.h" >&5 $as_echo_n "checking for compar_fn_t in stdlib.h... " >&6; } if ${ccache_cv_COMPAR_FN_T+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); } ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ccache_cv_COMPAR_FN_T=yes else ccache_cv_COMPAR_FN_T=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ccache_cv_COMPAR_FN_T" >&5 $as_echo "$ccache_cv_COMPAR_FN_T" >&6; } if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then $as_echo "#define HAVE_COMPAR_FN_T 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C99 vsnprintf" >&5 $as_echo_n "checking for C99 vsnprintf... " >&6; } if ${ccache_cv_HAVE_C99_VSNPRINTF+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ccache_cv_HAVE_C99_VSNPRINTF=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include void foo(const char *format, ...) { va_list ap; int len; char buf[5]; va_start(ap, format); len = vsnprintf(0, 0, format, ap); va_end(ap); if (len != 5) exit(1); if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); exit(0); } main() { foo("hello"); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ccache_cv_HAVE_C99_VSNPRINTF=yes else ccache_cv_HAVE_C99_VSNPRINTF=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ccache_cv_HAVE_C99_VSNPRINTF" >&5 $as_echo "$ccache_cv_HAVE_C99_VSNPRINTF" >&6; } if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then $as_echo "#define HAVE_C99_VSNPRINTF 1" >>confdefs.h fi # Check whether --enable-zlib was given. if test "${enable_zlib+set}" = set; then : enableval=$enable_zlib; else enable_zlib=yes fi if test x"$enable_zlib" = x"yes"; then ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzdopen in -lz" >&5 $as_echo_n "checking for gzdopen in -lz... " >&6; } if ${ac_cv_lib_z_gzdopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gzdopen (); int main () { return gzdopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_z_gzdopen=yes else ac_cv_lib_z_gzdopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzdopen" >&5 $as_echo "$ac_cv_lib_z_gzdopen" >&6; } if test "x$ac_cv_lib_z_gzdopen" = xyes; then : LIBS="-lz $LIBS" $as_echo "#define ENABLE_ZLIB 1" >>confdefs.h fi fi fi ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by ccache-swig $as_me 0.0, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ ccache-swig config.status 0.0 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi swig-3.0.2/CCache/mdfour.h0000664000175000017500000000231112343605122015113 0ustar williamwilliam/* Unix SMB/Netbios implementation. Version 1.9. a implementation of MD4 designed for use in the SMB authentication protocol Copyright (C) Andrew Tridgell 1997-1998. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ struct mdfour { uint32 A, B, C, D; uint32 totalN; unsigned char tail[64]; unsigned tail_len; }; void mdfour_begin(struct mdfour *md); void mdfour_update(struct mdfour *md, const unsigned char *in, int n); void mdfour_result(struct mdfour *md, unsigned char *out); void mdfour(unsigned char *out, const unsigned char *in, int n); swig-3.0.2/CCache/config.h.in0000664000175000017500000000610712343706600015503 0ustar williamwilliam/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you would like to have zlib compression for ccache. */ #undef ENABLE_ZLIB /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF /* */ #undef HAVE_C99_VSNPRINTF /* */ #undef HAVE_COMPAR_FN_T /* Define to 1 if you have the header file. */ #undef HAVE_CTYPE_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the `getpwuid' function. */ #undef HAVE_GETPWUID /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mkstemp' function. */ #undef HAVE_MKSTEMP /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_PWD_H /* Define to 1 if you have the `realpath' function. */ #undef HAVE_REALPATH /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `utimes' function. */ #undef HAVE_UTIMES /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define _GNU_SOURCE so that we get all necessary prototypes */ #undef _GNU_SOURCE swig-3.0.2/CCache/Makefile.in0000664000175000017500000000535112343605122015522 0ustar williamwilliamdatarootdir = @datarootdir@ srcdir=@srcdir@ VPATH=@srcdir@ prefix=@prefix@ exec_prefix=@exec_prefix@ bindir=@bindir@ mandir=@mandir@ INSTALLCMD=@INSTALL@ PACKAGE_NAME=@PACKAGE_NAME@ # Soft link test can be skipped on systems that don't support soft linking NOSOFTLINKSTEST= CC=@CC@ CFLAGS=@CFLAGS@ -I. SWIG=swig SWIG_LIB=../$(srcdir)/../Lib EXEEXT=@EXEEXT@ # Use standard autoconf approach to transform executable name using --program-prefix and --program-suffix transform = @program_transform_name@ LIBS= @LIBS@ OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ cleanup.o snprintf.o unify.o HEADERS = ccache.h mdfour.h all: $(PACKAGE_NAME)$(EXEEXT) # Regenerate Makefile if Makefile.in or config.status have changed. Makefile: $(srcdir)/Makefile.in ./config.status $(SHELL) ./config.status # Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile docs: $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html $(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(srcdir)/$(PACKAGE_NAME).1: $(srcdir)/ccache.yo -yodl2man -o $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/ccache.yo $(srcdir)/web/ccache-man.html: $(srcdir)/ccache.yo yodl2html -o $(srcdir)/web/ccache-man.html $(srcdir)/ccache.yo install: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1 @echo "Installing $(PACKAGE_NAME)" @echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)" ${INSTALLCMD} -d $(DESTDIR)${bindir} ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) @echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1" ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 ${INSTALLCMD} -m 644 $(srcdir)/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 uninstall: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1 rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 clean: /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) test: test.sh SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' $(srcdir)/test.sh check: test distclean: clean /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h /bin/rm -rf autom4te.cache maintainer-clean: distclean /bin/rm -f $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html # FIXME: To fix this, test.sh needs to be able to take ccache from the # installed prefix, not from the source dir. installcheck: @echo "WARNING! This is not really \"installcheck\" yet." $(MAKE) check swig-3.0.2/CCache/web/0000775000175000017500000000000012343605122014226 5ustar williamwilliamswig-3.0.2/CCache/web/index.html0000664000175000017500000001237712343605122016235 0ustar williamwilliam ccache

ccache

ccache is a compiler cache. It acts as a caching pre-processor to C/C++ compilers, using the -E compiler switch and a hash to detect when a compilation can be satisfied from cache. This often results in a 5 to 10 times speedup in common compilations.

The idea came from Erik Thiele wrote the original compilercache program as a bourne shell script. ccache is a re-implementation of Erik's idea in C with more features and better performance.

Latest release

The latest release is ccache 2.4.
  • Added CCACHE_READONLY option
  • Added CCACHE_TEMPDIR option
  • fixed handling of hard-linked compilers on AIX
  • added O_BINARY support, to try and support win32 compiles
  • show cache directory in stats output
  • fixed handling of HOME environment variable
See the manual page for details on the new options.

You can get this release from the download directory

NOTE! This release changes the hash input slighly, so you will probably find that you will not get any hits against your existing cache when you upgrade.

Why bother?

Why bother with a compiler cache? If you ever run "make clean; make" then you can probably benefit from ccache. It is very common for developers to do a clean build of a project for a whole host of reasons, and this throws away all the information from your previous compiles.

By using ccache you can get exactly the same effect as "make clean; make" but much faster. It also helps a lot when doing RPM builds, as RPM can make doing incremental builds tricky.

I put the effort into writing ccache for 2 reasons. The first is the Samba build farm (http://build.samba.org/) which constantly does clean builds of Samba on about 30 machines after each CVS commit. On some of those machines the build took over an hour. By using ccache we get the same effect as clean builds but about 6 times faster.

The second reason is the autobuild system I used to run for Quantum. That system builds our whole Linux based OS from scratch after every CVS commit to catch compilation problems quickly. Using ccache those builds are much faster.

Is it safe?

Yes. The most important aspect of a compiler cache is to always produce exactly the same output that the real compiler would produce. The includes providing exactly the same object files and exactly the same compiler warnings that would be produced if you use the real compiler. The only way you should be able to tell that you are using ccache is the speed.

I have coded ccache very carefully to try to provide these guarantees.

Features

  • keeps statistics on hits/misses
  • automatic cache size management
  • can cache compiles that generate warnings
  • easy installation
  • very low overhead
  • uses hard links where possible to avoid copies

Documentation

See the manual page

Performance

Here are some results for compiling Samba on my Linux laptop. I have also included the results of using Erik's compilercache program (version 1.0.10) for comparison.

    ccache  compilercache
normal 13m 4s 13m 4s
uncached 13m 15s 15m 41s
cached 2m 45s 4m 26s

How to use it

You can use ccache in two ways. The first is just to prefix your compile commands with "ccache". For example, you could change the "CC=gcc" line in your Makefile to be "CC=ccache gcc".

Alternatively, you can create symbolic links from your compilers name to ccache. This allows you to use ccache without any changes to your build system.

Download

You can download the latest release from the download directory.

For the bleeding edge, you can fetch ccache via CVS or rsync. To fetch via cvs use the following command:

  cvs -d :pserver:cvs@pserver.samba.org:/cvsroot co ccache
To fetch via rsync use this command:
  rsync -Pavz samba.org::ftp/unpacked/ccache .

Related projects

Here are some related programs you may find interesting
  • distcc - a distributed compilation system
  • cachecc1 - a gcc specific cache
  • gocache - a cross platform compiler cache

Mailing list

A mailing list is available for discussion of ccache.


Andrew Tridgell
bugs@ccache.samba.org
swig-3.0.2/CCache/debian/0000775000175000017500000000000012343605122014673 5ustar williamwilliamswig-3.0.2/CCache/debian/control0000664000175000017500000000131612343605122016277 0ustar williamwilliamSource: ccache Section: devel Priority: optional Maintainer: Francois Marier Build-Depends: debhelper (>> 6), autotools-dev, zlib1g-dev Standards-Version: 3.7.3 Homepage: http://ccache.samba.org Vcs-Svn: svn://svn.debian.org/svn/collab-maint/deb-maint/ccache/ Vcs-Browser: http://svn.debian.org/wsvn/collab-maint/deb-maint/ccache/ Package: ccache Architecture: any Depends: ${shlibs:Depends} Suggests: distcc Description: Compiler results cacher, for fast recompiles ccache is a compiler cache. It speeds up re-compilation of C/C++ code by caching previous compiles and detecting when the same compile is being done again. . This is similar to, but faster than, the compilercache package. swig-3.0.2/CCache/debian/watch0000664000175000017500000000007312343605122015724 0ustar williamwilliamversion=2 http://samba.org/ftp/ccache/ccache-(.*)\.tar\.gz swig-3.0.2/CCache/debian/dirs0000664000175000017500000000005212343605122015554 0ustar williamwilliamusr/bin usr/lib/ccache usr/share/man/man1 swig-3.0.2/CCache/debian/compat0000664000175000017500000000000212343605122016071 0ustar williamwilliam6 swig-3.0.2/CCache/debian/examples0000664000175000017500000000004512343605122016433 0ustar williamwilliamdebian/update-ccache manage-cache.sh swig-3.0.2/CCache/debian/changelog0000664000175000017500000001637712343605122016563 0ustar williamwilliamccache (2.4-15) unstable; urgency=low * Add a new patch which improve the consistency of timestamps on cached objects to make sure clean-up is based on least recently used objects. * Patch the set_limit call so that non-writable cache directories return an error when attempting to size the max(files|size) (closes: #332527) -- Francois Marier Sun, 13 Apr 2008 15:07:05 +1200 ccache (2.4-14) unstable; urgency=low * Mention the long options everywhere in the manpage * Merge Gentoo patches: - respect user's LDFLAGS - use utimes() for timestamp if possible -- Francois Marier Sun, 23 Mar 2008 16:30:11 +1300 ccache (2.4-13) unstable; urgency=low * Update CACHEDIR.TAG patch to avoid creating the tag file when the CCACHE_READONLY environment variable is set. (closes: #464356) * Mention the GNU-style long options in the manpage -- Francois Marier Thu, 07 Feb 2008 10:50:42 +1300 ccache (2.4-12) unstable; urgency=low * Add symlink for gcc 4.3 (closes: #463590) * Add support for the CACHEDIR.TAG spec, thanks to Karl Chen. (see http://www.brynosaurus.com/cachedir/) * Fix hyphens in manpage (lintian notice) * Bump Standards-Version up to 3.7.3 (no changes) * Bump debhelper compatibility to 6 -- Francois Marier Sat, 02 Feb 2008 10:37:22 +1300 ccache (2.4-11) unstable; urgency=low * Add the collab-maint repo to debian/control -- Francois Marier Tue, 20 Nov 2007 15:26:37 +1300 ccache (2.4-10) unstable; urgency=low * Document where the patches are from in debian/patches/CREDITS * debian/rules: - Fixed "make distclean" lintian warning - Removed commented-out entries * Set debhelper compatibility to 5 * Add homepage field in debian/control * Add symlinks for MinGW (closes: #445782) * Bump the version to 5 in the debhelper dependency -- Francois Marier Fri, 19 Oct 2007 16:04:37 +1300 ccache (2.4-9) unstable; urgency=low * Add a symlink for gcc 4.2 (closes: #431007) * Fix dependencies when using -o (closes: #217713) -- Francois Marier Sat, 30 Jun 2007 17:58:44 +1200 ccache (2.4-8) unstable; urgency=low * Enable zlib compression of the cache by default (closes: #409848). Thanks to Sami Liedes for suggesting this. * Disable ccache when profiling (closes: #215849). Thanks to Ted Percival for the Patch. * Fix NFS renaming issues and add instructions to the README. Thanks to John Coiner and instructions. * Put all patches in debian/patches and apply them at build time. -- Francois Marier Sun, 20 May 2007 19:42:34 +1200 ccache (2.4-7) unstable; urgency=low * Use the real compiler when HOME is not set (closes: #396350) * Include user script under doc/examples (closes: #392435) Thanks to Behan Webster! * Add support for GNU --long options (closes: #297126) -- Francois Marier Sat, 18 Nov 2006 00:50:59 -0500 ccache (2.4-6) unstable; urgency=low * Include symlinks for gcc 4.1 (closes: #372838) * Update watch file -- Francois Marier Tue, 13 Jun 2006 22:17:37 -0400 ccache (2.4-5) unstable; urgency=low * Document the fact that cross-compiling is supported (closes: #349221) * Bump Standards-Version up to 3.7.2 (no changes) -- Francois Marier Sun, 4 Jun 2006 01:20:07 -0400 ccache (2.4-4) unstable; urgency=low * Mention another way to use ccache in README.Debian (thanks to Benjamin Drieu for the suggestion) (closes: #267632) * Update FSF address * Fix watch file -- Francois Marier Sat, 26 Nov 2005 00:15:13 -0500 ccache (2.4-3) unstable; urgency=low * Actually use the configuration flags in debian/rules * Bump Standards-Version up to 3.6.2 (no changes) -- Francois Marier Sun, 26 Jun 2005 13:33:19 -0400 ccache (2.4-2) unstable; urgency=low * Add gcc and g++ symlinks to /usr/lib/ccache (closes: #313490) * Remove invalid entry from Depends -- Francois Marier Wed, 15 Jun 2005 20:51:03 -0400 ccache (2.4-1) unstable; urgency=low * New maintainer (closes: #312867) * New upstream version: (closes: #273753, #239640) - New CCACHE_READONLY and CCACHE_TEMPDIR options - Fixed handling of hard-linked compilers on AIX - Fixed handling of HOME environment variable (closes: #299880) - Show cache directory in stats output * Fix copyright file * Add 'distcc' to Suggests (closes: #269158) * Add a note about whitespace in README.Debian (closes: #229116) * Update rules to add symmlinks for gcc 3.4 & 4.0 (closes: #261177) * Acknowledge NMUs (closes: #200185, #177129, #174417) -- Francois Marier Sun, 12 Jun 2005 12:05:34 -0400 ccache (2.3-1.1) unstable; urgency=low * Non-maintainer upload during BSP * Re-apply patch for #200185 ccache: Incorrect symlinks in /usr/lib/ccache (Closes: #200185) -- Frank Lichtenheld Fri, 19 Mar 2004 11:14:50 +0100 ccache (2.3-1) unstable; urgency=low * New upstream release: obsoletes existing caches. * Tweak package description in arbitrary way (closes: #181721) -- Paul Russell Mon, 29 Sep 2003 02:53:20 +0200 ccache (2.2-2) unstable; urgency=low * Insert more symlinks in ccache dir (closes: #197468) -- Paul Russell Mon, 16 Jun 2003 10:52:50 +0100 ccache (2.2-1) unstable; urgency=low * New upstream release (closes: #150755) * Insert more symlinks in ccache dir (closes: #144462) -- Paul Russell Mon, 17 Feb 2003 07:19:36 +0100 ccache (2.1.1-2) unstable; urgency=low * Restored /usr/lib/ccache symlinks (closes: #179393) * Fixed manpage typo (closes: #179564) * With thanks to Andreas Rottmann. -- Paul Russell Wed, 5 Feb 2003 10:01:10 +0100 ccache (2.1.1-1) unstable; urgency=low * NMU (with maintainer consent). * New upstream release (closes: #174417, #177129). * debian/control: + Build-Depend on and use dephelper 4 (DH_COMPAT = 4). + Bumped Standards-Version to 3.5.8. + No full stop on short package description (fixes linda warning). * debian/copright: + Make lintian feel comfortable; fixes warnings: - copyright-should-refer-to-common-license-file-for-gpl - copyright-lists-upstream-authors-with-dh_make-boilerplate * Built with g++ 3.2 :-). -- Andreas Rottmann Thu, 16 Jan 2003 11:42:38 +0100 ccache (1.9-1) unstable; urgency=low * New upstream release (closes: #144920) -- Paul Russell Mon, 13 May 2002 10:01:09 +0200 ccache (1.8-1) unstable; urgency=low * New upstream release (closes: #145401) -- Paul Russell Fri, 3 May 2002 02:26:32 +0200 ccache (1.7-1) unstable; urgency=low * New upstream release * Install symlinks in /usr/lib/ccache (closes: #141337) -- Paul Russell Wed, 10 Apr 2002 17:51:21 +0200 ccache (1.4-1) unstable; urgency=low * New upstream release -- Paul Russell Wed, 3 Apr 2002 03:41:46 +0200 ccache (1.2-1) unstable; urgency=low * Initial Release. -- Paul Russell Sun, 31 Mar 2002 14:08:57 +0200 swig-3.0.2/CCache/debian/rules0000664000175000017500000001160112343605122015747 0ustar williamwilliam#!/usr/bin/make -f # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) confflags += --build $(DEB_HOST_GNU_TYPE) else confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) endif ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) CFLAGS += -g endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif config.status: configure dh_testdir # Apply Debian specific patches cp $(CURDIR)/ccache.c $(CURDIR)/ccache.c.unpatched cp $(CURDIR)/util.c $(CURDIR)/util.c.unpatched cp $(CURDIR)/ccache.1 $(CURDIR)/ccache.1.unpatched cp $(CURDIR)/ccache.h $(CURDIR)/ccache.h.unpatched cp $(CURDIR)/ccache.yo $(CURDIR)/ccache.yo.unpatched cp $(CURDIR)/config.h.in $(CURDIR)/config.h.in.unpatched cp $(CURDIR)/configure $(CURDIR)/configure.unpatched cp $(CURDIR)/configure.in $(CURDIR)/configure.in.unpatched cp $(CURDIR)/Makefile.in $(CURDIR)/Makefile.in.unpatched if test ! -f patch-stamp; then \ for patch in $(CURDIR)/debian/patches/*.diff ;\ do \ echo APPLYING PATCH\: $${patch##*/};\ patch -p0 < $$patch ;\ done ;\ touch patch-stamp ;\ fi chmod +x $(CURDIR)/manage-cache.sh ./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info build: build-stamp build-stamp: config.status dh_testdir $(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp # Unapply patches -test -r $(CURDIR)/ccache.c.unpatched && mv $(CURDIR)/ccache.c.unpatched $(CURDIR)/ccache.c -test -r $(CURDIR)/util.c.unpatched && mv $(CURDIR)/util.c.unpatched $(CURDIR)/util.c -test -r $(CURDIR)/ccache.1.unpatched && mv $(CURDIR)/ccache.1.unpatched $(CURDIR)/ccache.1 -test -r $(CURDIR)/ccache.h.unpatched && mv $(CURDIR)/ccache.h.unpatched $(CURDIR)/ccache.h -test -r $(CURDIR)/ccache.yo.unpatched && mv $(CURDIR)/ccache.yo.unpatched $(CURDIR)/ccache.yo -test -r $(CURDIR)/config.h.in.unpatched && mv $(CURDIR)/config.h.in.unpatched $(CURDIR)/config.h.in -test -r $(CURDIR)/configure.unpatched && mv $(CURDIR)/configure.unpatched $(CURDIR)/configure -test -r $(CURDIR)/configure.in.unpatched && mv $(CURDIR)/configure.in.unpatched $(CURDIR)/configure.in -test -r $(CURDIR)/Makefile.in.unpatched && mv $(CURDIR)/Makefile.in.unpatched $(CURDIR)/Makefile.in -rm -f $(CURDIR)/manage-cache.sh -rm -f patch-stamp [ ! -f Makefile ] || $(MAKE) distclean dh_clean # Update config.sub and config.guess -test -r /usr/share/misc/config.sub && \ cp -f /usr/share/misc/config.sub config.sub -test -r /usr/share/misc/config.guess && \ cp -f /usr/share/misc/config.guess config.guess install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/ccache. $(MAKE) install prefix=$(CURDIR)/debian/ccache/usr ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++ set -e; for ver in 2.95 3.0 3.2 3.3 3.4 4.0 4.1 4.2 4.3; do \ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc-$$ver; \ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc-$$ver; \ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++-$$ver; \ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++-$$ver; \ done ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/cc ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/c++ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-c++ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-cc ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-g++ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-gcc # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installdocs dh_installexamples dh_installmenu dh_installcron dh_installman dh_installinfo dh_installchangelogs dh_link dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install swig-3.0.2/CCache/debian/copyright0000664000175000017500000000240612343605122016630 0ustar williamwilliamThis package was debianized by Paul Russell on Sun, 31 Mar 2002 14:08:57 +0200. It was downloaded from http://ccache.samba.org/ftp/ccache/ The ccache-zlib patch was downloaded from http://www.gustaebel.de/lars/ccache/ Upstream Author: Andrew Tridgell Copyright: 2002-2005 Andrew Tridgell This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA You are free to distribute this software under the terms of the GNU General Public License. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL file. swig-3.0.2/CCache/debian/README.Debian0000664000175000017500000000401012343605122016727 0ustar williamwilliamInstalling ccache ----------------- The recommended way to use this with Debian is to either create "cc" and "gcc" symlinks to /usr/bin/ccache in your private bin directory (which must be before the real cc and gcc in your path), or use CC="ccache gcc" on the make command line. Another option is to just prepend /usr/lib/ccache in your PATH environment variable, like export PATH="/usr/lib/ccache:$PATH" Note that ccache works with both native and cross compilers. Ignoring whitespace ------------------- If you wish to set up ccache so that it ignores blank lines, have a look at the CCACHE_UNIFY option. However, please note that this option is off by default since the reported line numbers may not match the source files anymore. NFS Issues ---------- (from John Coiner on the ccache mailing list) When CCache creates a hardlinked output file, it calls utime() to update the timestamp on the object, so that Make realizes that the object has changed. On NFS, utime() has no coherency guarantee, AFAIK. When utime() runs on host A, and our parallel implementation of Make is running on host B, sometimes Make doesn't see the new timestamp soon enough -- and neglects to relink the final binary. That's a one-way ticket to Silent Mysterious Failure Town. Instead of relying on the object file timestamp, we create a dummy file with a reliable timestamp: objs/foo.o objs/foo.o.built : if ( ccache gcc -o foo.o -c foo.c ) ; \ then touch objs/foo.o.built ; \ else exit 1; \ fi binary : objs/foo.o.built gcc -o binary objs/foo.o NFS does make a coherency guarantee, that if a file is written and close()d on host A, and subsequently open()ed on host B, that the second open() will reflect all modifications and attributes from the close(). Since Make does open() when checking timestamps, and the dummy file is close()d when it's created, the binary will always relink after the object is recompiled. -- Francois Marier Sun, 20 May 2007 17:35:36 +1200 swig-3.0.2/CCache/debian/docs0000664000175000017500000000000712343605122015543 0ustar williamwilliamREADME swig-3.0.2/CCache/debian/NEWS0000664000175000017500000000164212343605122015375 0ustar williamwilliamccache (2.4-8) unstable; urgency=high zlib compression is now enabled by default in order to increase the amount of object files that can fit in the cache. The impact on performance is supposed to be almost negligible (see http://www.gustaebel.de/lars/ccache/). If you do want to disable it however, simply export the CCACHE_NOCOMPRESS environment variable. Note that a zlib-enabled ccache will still read your existing uncompressed cache. If you want to compress/uncompress your cache, see the manage-cache.sh script under /usr/share/doc/ccache/examples/. -- Francois Marier Sun, 20 May 2007 19:45:07 +1200 ccache (2.4-1) unstable; urgency=low * This release changes the hash input slighly, so you will probably find that you will not get any hits against your existing cache when you upgrade. -- Francois Marier Sat, 11 Jun 2005 13:54:33 -0400 swig-3.0.2/CCache/debian/patches/0000775000175000017500000000000012343605122016322 5ustar williamwilliamswig-3.0.2/CCache/debian/patches/CREDITS0000664000175000017500000000317212343605122017345 0ustar williamwilliam01_no_home.diff: Francois Marier Made especially for the Debian package. 02_ccache_compressed.diff: Lars Gustäbel http://www.gustaebel.de/lars/ccache/ (downloaded on 2007-05-20) 03_long_options.diff: Francois Marier Made especially for the Debian package. 04_ignore_profile.diff: Ted Percival http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=20;filename=ccache-profile.patch;att=1;bug=215849 05_nfs_fix.diff: John Coiner http://lists.samba.org/archive/ccache/2007q1/000265.html 06_md.diff: Andrea Bittau http://darkircop.org/ccache/ccache-2.4-md.patch (downloaded on 2007-06-30) 07_cachedirtag.diff: Karl Chen http://lists.samba.org/archive/ccache/2008q1/000316.html (downloaded on 2008-02-02) 08_manpage_hyphens.diff: Francois Marier Made especially for the Debian package. 09_respect_ldflags.diff: Lisa Seelye http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-respectflags.patch?rev=1.1&view=markup 10_lru_cleanup.diff: RW http://lists.samba.org/archive/ccache/2008q2/000339.html (downloaded on 2008-04-11) 11_utimes.diff: Robin H. Johnson http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-utimes.patch?rev=1.1&view=markup 12_cachesize_permissions.diff: Francois Marier Made especially for the Debian package to fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332527 swig-3.0.2/CCache/debian/patches/02_ccache-compressed.diff0000664000175000017500000007377112343605122023044 0ustar williamwilliamIndex: ccache.1 =================================================================== RCS file: /home/cvsroot/lars/ccache/ccache.1,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.6 diff -u -r1.1.1.1.2.1 -r1.6 --- ccache.1 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ ccache.1 21 Nov 2004 18:19:28 -0000 1.6 @@ -210,7 +210,8 @@ CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy\&. Using hard links is faster, but can confuse programs like -\&'make\&' that rely on modification times\&. +\&'make\&' that rely on modification times\&. Hard links are never made for +compressed cache files\&. .IP .IP "\fBCCACHE_RECACHE\fP" This forces ccache to not use any cached @@ -257,6 +258,11 @@ the default\&. On HP-UX set this environment variable to "i" if you use the aCC compiler\&. .IP +.IP "\fBCCACHE_NOCOMPRESS\fP" +If you set the environment variable +CCACHE_NOCOMPRESS then there is no compression used on files that go +into the cache\&. +.IP .PP .SH "CACHE SIZE MANAGEMENT" .PP @@ -269,6 +275,14 @@ below the numbers you specified in order to avoid doing the cache clean operation too often\&. .PP +.SH "CACHE COMPRESSION" +.PP +By default ccache will compress all files it puts into the cache +using the zlib compression\&. While this involves a negligible +performance slowdown, it significantly increases the number of files +that fit in the cache\&. You can turn off compression setting the +CCACHE_NOCOMPRESS environment variable\&. +.PP .SH "HOW IT WORKS" .PP The basic idea is to detect when you are compiling exactly the same Index: ccache.c =================================================================== RCS file: /home/cvsroot/lars/ccache/ccache.c,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.9 diff -u -r1.1.1.1.2.1 -r1.9 --- ccache.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ ccache.c 21 Nov 2004 18:19:28 -0000 1.9 @@ -199,7 +199,7 @@ fd = open(tmp_stderr, O_RDONLY | O_BINARY); if (fd != -1) { if (strcmp(output_file, "/dev/null") == 0 || - rename(tmp_hashname, output_file) == 0 || errno == ENOENT) { + move_file(tmp_hashname, output_file) == 0 || errno == ENOENT) { if (cpp_stderr) { /* we might have some stderr from cpp */ int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); @@ -231,14 +231,25 @@ x_asprintf(&path_stderr, "%s.stderr", hashname); if (stat(tmp_stderr, &st1) != 0 || - stat(tmp_hashname, &st2) != 0 || - rename(tmp_hashname, hashname) != 0 || - rename(tmp_stderr, path_stderr) != 0) { + stat(tmp_hashname, &st2) != 0 || + move_file(tmp_hashname, hashname) != 0 || + move_file(tmp_stderr, path_stderr) != 0) { cc_log("failed to rename tmp files - %s\n", strerror(errno)); stats_update(STATS_ERROR); failed(); } +#if ENABLE_ZLIB + /* do an extra stat on the cache files for + the size statistics */ + if (stat(path_stderr, &st1) != 0 || + stat(hashname, &st2) != 0) { + cc_log("failed to stat cache files - %s\n", strerror(errno)); + stats_update(STATS_ERROR); + failed(); + } +#endif + cc_log("Placed %s into cache\n", output_file); stats_tocache(file_size(&st1) + file_size(&st2)); @@ -474,7 +485,13 @@ } /* the user might be disabling cache hits */ +#ifndef ENABLE_ZLIB + /* if the cache file is compressed we must recache */ + if ((first && getenv("CCACHE_RECACHE")) || + test_if_compressed(hashname) == 1) { +#else if (first && getenv("CCACHE_RECACHE")) { +#endif close(fd_stderr); unlink(stderr_file); free(stderr_file); @@ -487,7 +504,9 @@ ret = 0; } else { unlink(output_file); - if (getenv("CCACHE_HARDLINK")) { + /* only make a hardlink if the cache file is uncompressed */ + if (getenv("CCACHE_HARDLINK") && + test_if_compressed(hashname) == 0) { ret = link(hashname, output_file); } else { ret = copy_file(hashname, output_file); Index: ccache.h =================================================================== RCS file: /home/cvsroot/lars/ccache/ccache.h,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.7 diff -u -r1.1.1.1.2.1 -r1.7 --- ccache.h 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ ccache.h 21 Nov 2004 18:19:28 -0000 1.7 @@ -23,6 +23,10 @@ #include #endif +#ifdef ENABLE_ZLIB +#include +#endif + #define STATUS_NOTFOUND 3 #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 @@ -36,6 +40,13 @@ #define DEFAULT_MAXSIZE (1000*1000) #endif +/* file copy mode */ +#ifdef ENABLE_ZLIB +#define COPY_UNCOMPRESSED 0 +#define COPY_FROM_CACHE 1 +#define COPY_TO_CACHE 2 +#endif + enum stats { STATS_NONE=0, STATS_STDOUT, @@ -79,6 +90,8 @@ void copy_fd(int fd_in, int fd_out); int copy_file(const char *src, const char *dest); +int move_file(const char *src, const char *dest); +int test_if_compressed(const char *filename); int create_dir(const char *dir); void x_asprintf(char **ptr, const char *format, ...); Index: ccache.yo =================================================================== RCS file: /home/cvsroot/lars/ccache/ccache.yo,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.5 diff -u -r1.1.1.1.2.1 -r1.5 --- ccache.yo 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ ccache.yo 21 Nov 2004 18:19:28 -0000 1.5 @@ -169,6 +169,11 @@ this optimisation, in which case this option could allow ccache to be used. +dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable +CCACHE_NOCOMPRESS then there is no compression used on files that go +into the cache. However, this setting has no effect on how files are +retrieved from the cache, compressed results will still be usable. + dit(bf(CCACHE_NOSTATS)) If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile. @@ -181,7 +186,8 @@ CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy. Using hard links is faster, but can confuse programs like -'make' that rely on modification times. +'make' that rely on modification times. Hard links are never made for +compressed cache files. dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached results, even if it finds them. New results are still cached, but @@ -236,6 +242,14 @@ below the numbers you specified in order to avoid doing the cache clean operation too often. +manpagesection(CACHE COMPRESSION) + +By default ccache will compress all files it puts into the cache +using the zlib compression. While this involves a negligible +performance slowdown, it significantly increases the number of files +that fit in the cache. You can turn off compression setting the +CCACHE_NOCOMPRESS environment variable. + manpagesection(HOW IT WORKS) The basic idea is to detect when you are compiling exactly the same @@ -294,6 +308,8 @@ cache. This tells the filesystem to inherit group ownership for new directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might be useful for this. + it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with + versions of ccache that do not support compression. ) manpagesection(HISTORY) Index: config.h.in =================================================================== RCS file: /home/cvsroot/lars/ccache/config.h.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- config.h.in 30 Apr 2004 13:13:41 -0000 1.1.1.1 +++ config.h.in 4 May 2004 20:49:26 -0000 1.2 @@ -98,3 +98,6 @@ /* Define _GNU_SOURCE so that we get all necessary prototypes */ #undef _GNU_SOURCE + +/* Define to 1 if you like to have zlib compression for the ccache. */ +#undef ENABLE_ZLIB Index: configure =================================================================== RCS file: /home/cvsroot/lars/ccache/configure,v retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1.2.1 configure --- configure 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ configure 21 Nov 2004 18:24:42 -0000 @@ -836,6 +836,11 @@ cat <<\_ACEOF +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-zlib enable zlib support for ccache compression + Some influential environment variables: CC C compiler command CFLAGS C compiler flags @@ -936,7 +941,7 @@ else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd "$ac_popdir" + cd $ac_popdir done fi @@ -1859,7 +1864,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -1917,7 +1923,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2033,7 +2040,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2087,7 +2095,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2132,7 +2141,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2176,7 +2186,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2609,7 +2620,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2681,7 +2693,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2735,7 +2748,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2806,7 +2820,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2860,7 +2875,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2927,7 +2943,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2997,7 +3014,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3078,7 +3096,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3248,7 +3267,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3319,7 +3339,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3509,7 +3530,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3611,7 +3633,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3676,7 +3699,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3775,6 +3799,229 @@ fi +# Check whether --enable-zlib or --disable-zlib was given. +if test "${enable_zlib+set}" = set; then + enableval="$enable_zlib" + +else + enable_zlib=yes +fi; + +if test x"$enable_zlib" = x"yes"; then + if test "${ac_cv_header_zlib_h+set}" = set; then + echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking zlib.h usability" >&5 +echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking zlib.h presence" >&5 +echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_zlib_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 + +fi +if test $ac_cv_header_zlib_h = yes; then + echo "$as_me:$LINENO: checking for gzdopen in -lz" >&5 +echo $ECHO_N "checking for gzdopen in -lz... $ECHO_C" >&6 +if test "${ac_cv_lib_z_gzdopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gzdopen (); +int +main () +{ +gzdopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_z_gzdopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_z_gzdopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzdopen" >&5 +echo "${ECHO_T}$ac_cv_lib_z_gzdopen" >&6 +if test $ac_cv_lib_z_gzdopen = yes; then + LIBS="-lz $LIBS"; cat >>confdefs.h <<\_ACEOF +#define ENABLE_ZLIB 1 +_ACEOF + +fi + +fi + + +fi + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -4568,6 +4815,11 @@ *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -4606,12 +4858,6 @@ fi;; esac done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub Index: configure.in =================================================================== RCS file: /home/cvsroot/lars/ccache/configure.in,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.4 diff -u -r1.1.1.1.2.1 -r1.4 --- configure.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ configure.in 21 Nov 2004 18:19:28 -0000 1.4 @@ -68,5 +68,14 @@ AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) fi +dnl Check for zlib. +AC_ARG_ENABLE([zlib], + AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, + [enable_zlib=yes]) + +if test x"$enable_zlib" = x"yes"; then + AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, LIBS="-lz $LIBS"; AC_DEFINE(ENABLE_ZLIB))) +fi + AC_CONFIG_FILES([Makefile]) AC_OUTPUT Index: util.c =================================================================== RCS file: /home/cvsroot/lars/ccache/util.c,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.11 diff -u -r1.1.1.1.2.1 -r1.11 --- util.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ util.c 21 Nov 2004 18:19:28 -0000 1.11 @@ -44,6 +44,7 @@ exit(1); } +#ifndef ENABLE_ZLIB /* copy all data from one file descriptor to another */ void copy_fd(int fd_in, int fd_out) { @@ -57,6 +58,11 @@ } } +/* move a file using rename */ +int move_file(const char *src, const char *dest) { + return rename(src, dest); +} + /* copy a file - used when hard links don't work the copy is done via a temporary file and atomic rename */ @@ -120,6 +126,174 @@ return 0; } +#else /* ENABLE_ZLIB */ + +/* copy all data from one file descriptor to another + possibly decompressing it +*/ +void copy_fd(int fd_in, int fd_out) { + char buf[10240]; + int n; + gzFile gz_in; + + gz_in = gzdopen(dup(fd_in), "rb"); + + if (!gz_in) { + fatal("Failed to copy fd"); + } + + while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { + if (write(fd_out, buf, n) != n) { + fatal("Failed to copy fd"); + } + } +} + +static int _copy_file(const char *src, const char *dest, int mode) { + int fd_in, fd_out; + gzFile gz_in, gz_out = NULL; + char buf[10240]; + int n, ret; + char *tmp_name; + mode_t mask; + struct stat st; + + x_asprintf(&tmp_name, "%s.XXXXXX", dest); + + if (getenv("CCACHE_NOCOMPRESS")) { + mode = COPY_UNCOMPRESSED; + } + + /* open source file */ + fd_in = open(src, O_RDONLY); + if (fd_in == -1) { + return -1; + } + + gz_in = gzdopen(fd_in, "rb"); + if (!gz_in) { + close(fd_in); + return -1; + } + + /* open destination file */ + fd_out = mkstemp(tmp_name); + if (fd_out == -1) { + gzclose(gz_in); + free(tmp_name); + return -1; + } + + if (mode == COPY_TO_CACHE) { + /* The gzip file format occupies at least 20 bytes. So + it will always occupy an entire filesystem block, + even for empty files. + Since most stderr files will be empty, we turn off + compression in this case to save space. + */ + if (fstat(fd_in, &st) != 0) { + gzclose(gz_in); + close(fd_out); + free(tmp_name); + return -1; + } + if (file_size(&st) == 0) { + mode = COPY_UNCOMPRESSED; + } + } + + if (mode == COPY_TO_CACHE) { + gz_out = gzdopen(dup(fd_out), "wb"); + if (!gz_out) { + gzclose(gz_in); + close(fd_out); + free(tmp_name); + return -1; + } + } + + while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { + if (mode == COPY_TO_CACHE) { + ret = gzwrite(gz_out, buf, n); + } else { + ret = write(fd_out, buf, n); + } + if (ret != n) { + gzclose(gz_in); + if (gz_out) { + gzclose(gz_out); + } + close(fd_out); + unlink(tmp_name); + free(tmp_name); + return -1; + } + } + + gzclose(gz_in); + if (gz_out) { + gzclose(gz_out); + } + + /* get perms right on the tmp file */ + mask = umask(0); + fchmod(fd_out, 0666 & ~mask); + umask(mask); + + /* the close can fail on NFS if out of space */ + if (close(fd_out) == -1) { + unlink(tmp_name); + free(tmp_name); + return -1; + } + + unlink(dest); + + if (rename(tmp_name, dest) == -1) { + unlink(tmp_name); + free(tmp_name); + return -1; + } + + free(tmp_name); + + return 0; +} + +/* move a file to the cache, compressing it */ +int move_file(const char *src, const char *dest) { + int ret; + + ret = _copy_file(src, dest, COPY_TO_CACHE); + if (ret != -1) unlink(src); + return ret; +} + +/* copy a file from the cache, decompressing it */ +int copy_file(const char *src, const char *dest) { + return _copy_file(src, dest, COPY_FROM_CACHE); +} +#endif /* ENABLE_ZLIB */ + +/* test if a file is zlib compressed */ +int test_if_compressed(const char *filename) { + FILE *f; + + f = fopen(filename, "rb"); + if (!f) { + return 0; + } + + /* test if file starts with 1F8B, which is zlib's + * magic number */ + if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) { + fclose(f); + return 0; + } + + fclose(f); + return 1; +} /* make sure a directory exists */ int create_dir(const char *dir) Index: manage-cache.sh =================================================================== RCS file: manage-cache.sh diff -N manage-cache.sh --- manage-cache.sh 1 Jan 1970 00:00:00 -0000 +++ manage-cache.sh-cache.sh 12 May 2004 19:22:20 -0000 1.1 @@ -0,0 +1,68 @@ +#!/bin/bash +# +# 2004-05-12 lars@gustaebel.de + +CCACHE_DIR=${CCACHE_DIR:-$HOME/.ccache} + +echo "Do you want to compress or decompress the ccache in $CCACHE_DIR?" +read -p "Type c or d: " mode + +if [ "$mode" != "c" ] && [ "$mode" != "d" ] +then + exit 1 +fi + +is_compressed() { + test "$(head -c 2 $1)" = $'\x1f\x8b' + return $? +} + +tmpfile=$(mktemp) + +for dir in 0 1 2 3 4 5 6 7 8 9 a b c d e f +do + # process ccache subdir + echo -n "$dir " + + # find cache files + find $CCACHE_DIR/$dir -type f -name '*-*' | + sort > $tmpfile + + oldsize=$(cat $CCACHE_DIR/$dir/stats | cut -d ' ' -f 13) + newsize=0 + + while read file + do + # empty files will be ignored since compressing + # them makes them bigger + test $(stat -c %s $file) -eq 0 && continue + + if [ $mode = c ] + then + if ! is_compressed $file + then + gzip $file + mv $file.gz $file + fi + else + if is_compressed $file + then + mv $file $file.gz + gzip -d $file.gz + fi + fi + + # calculate new size statistic for this subdir + let newsize=$newsize+$(stat -c "%B*%b" $file)/1024 + done < $tmpfile + + # update statistic file + read -a numbers < $CCACHE_DIR/$dir/stats + numbers[12]=$newsize + echo "${numbers[*]} " > $CCACHE_DIR/$dir/stats +done +echo + +# clean up +rm $tmpfile + Index: Makefile.in =================================================================== RCS file: /home/cvsroot/lars/ccache/Makefile.in,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.12 diff -u -r1.1.1.1.2.1 -r1.12 --- Makefile.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ Makefile.in 21 Nov 2004 18:19:28 -0000 1.12 @@ -11,6 +11,7 @@ CFLAGS=@CFLAGS@ -I. EXEEXT=@EXEEXT@ +LIBS= @LIBS@ OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ cleanup.o snprintf.o unify.o HEADERS = ccache.h mdfour.h @@ -20,7 +21,7 @@ docs: ccache.1 web/ccache-man.html ccache$(EXEEXT): $(OBJS) $(HEADERS) - $(CC) $(CFLAGS) -o $@ $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) ccache.1: ccache.yo -yodl2man -o ccache.1 ccache.yo swig-3.0.2/CCache/debian/patches/05_nfs_fix.diff0000664000175000017500000000230712343605122021116 0ustar williamwilliam--- ccache.1.orig 2007-05-20 17:30:57.000000000 +1200 +++ ccache.1 2007-05-20 17:31:27.000000000 +1200 @@ -367,12 +367,6 @@ .IP o ccache avoids a double call to cpp on a cache miss .PP -.SH "BUGS" -.PP -When the cache is stored on an NFS filesystem, the filesystem must be -exported with the \fBno_subtree_check\fP option to make renames between -directories reliable\&. -.PP .SH "CREDITS" .PP Thanks to the following people for their contributions to ccache --- util.c.patched 2007-05-20 18:19:11.000000000 +1200 +++ util.c 2007-05-20 18:20:55.000000000 +1200 @@ -58,9 +58,26 @@ } } +static int safe_rename(const char* oldpath, const char* newpath) +{ + /* safe_rename is for creating entries in the cache. + + Works like rename(), but it never overwrites an existing + cache entry. This avoids corruption on NFS. */ + int status = link( oldpath, newpath ); + if( status == 0 || errno == EEXIST ) + { + return unlink( oldpath ); + } + else + { + return -1; + } +} + /* move a file using rename */ int move_file(const char *src, const char *dest) { - return rename(src, dest); + return safe_rename(src, dest); } /* copy a file - used when hard links don't work swig-3.0.2/CCache/debian/patches/07_cachedirtag.diff0000664000175000017500000000361012343605122021720 0ustar williamwilliamIndex: ccache.c =================================================================== --- ccache.c (révision 7695) +++ ccache.c (copie de travail) @@ -1029,6 +1029,14 @@ exit(1); } + if (!getenv("CCACHE_READONLY")) { + if (create_cachedirtag(cache_dir) != 0) { + fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n", + cache_dir, strerror(errno)); + exit(1); + } + } + ccache(argc, argv); return 1; } Index: ccache.h =================================================================== --- ccache.h (révision 7695) +++ ccache.h (copie de travail) @@ -81,6 +81,7 @@ int copy_file(const char *src, const char *dest); int create_dir(const char *dir); +int create_cachedirtag(const char *dir); void x_asprintf(char **ptr, const char *format, ...); char *x_strdup(const char *s); void *x_realloc(void *ptr, size_t size); Index: util.c =================================================================== --- util.c (révision 7695) +++ util.c (copie de travail) @@ -138,6 +138,39 @@ return 0; } +char const CACHEDIR_TAG[] = + "Signature: 8a477f597d28d172789f06886806bc55\n" + "# This file is a cache directory tag created by ccache.\n" + "# For information about cache directory tags, see:\n" + "# http://www.brynosaurus.com/cachedir/\n"; + +int create_cachedirtag(const char *dir) +{ + char *filename; + struct stat st; + FILE *f; + x_asprintf(&filename, "%s/CACHEDIR.TAG", dir); + if (stat(filename, &st) == 0) { + if (S_ISREG(st.st_mode)) { + goto success; + } + errno = EEXIST; + goto error; + } + f = fopen(filename, "w"); + if (!f) goto error; + if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) { + goto error; + } + if (fclose(f)) goto error; +success: + free(filename); + return 0; +error: + free(filename); + return 1; +} + /* this is like asprintf() but dies if the malloc fails note that we use vsnprintf in a rather poor way to make this more portable swig-3.0.2/CCache/debian/patches/04_ignore_profile.diff0000664000175000017500000000077712343605122022475 0ustar williamwilliamdiff -ru ccache-2.4/ccache.c ccache-2.4-tp/ccache.c --- ccache.c 2007-05-20 03:14:19.000000000 +1000 +++ ccache.c 2007-05-20 03:17:54.000000000 +1000 @@ -641,6 +641,9 @@ /* these are too hard */ if (strcmp(argv[i], "-fbranch-probabilities")==0 || + strcmp(argv[i], "-fprofile-arcs") == 0 || + strcmp(argv[i], "-ftest-coverage") == 0 || + strcmp(argv[i], "--coverage") == 0 || strcmp(argv[i], "-M") == 0 || strcmp(argv[i], "-MM") == 0 || strcmp(argv[i], "-x") == 0) { swig-3.0.2/CCache/debian/patches/14_hardlink_doc.diff0000664000175000017500000000366612343605122022114 0ustar williamwilliamIndex: ccache.1 =================================================================== RCS file: /cvsroot/ccache/ccache.1,v retrieving revision 1.26 diff -u -r1.26 ccache.1 --- ccache.1 24 Nov 2005 21:10:08 -0000 1.26 +++ ccache.1 21 Jul 2007 21:03:32 -0000 @@ -330,7 +330,7 @@ .IP o Use the same \fBCCACHE_DIR\fP environment variable setting .IP o -Set the \fBCCACHE_NOLINK\fP environment variable +Unset the \fBCCACHE_HARDLINK\fP environment variable .IP o Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in Index: ccache.yo =================================================================== RCS file: /cvsroot/ccache/ccache.yo,v retrieving revision 1.27 diff -u -r1.27 ccache.yo --- ccache.yo 24 Nov 2005 21:54:09 -0000 1.27 +++ ccache.yo 21 Jul 2007 21:03:32 -0000 @@ -289,7 +289,7 @@ itemize( it() Use the same bf(CCACHE_DIR) environment variable setting - it() Set the bf(CCACHE_NOLINK) environment variable + it() Unset the bf(CCACHE_HARDLINK) environment variable it() Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in the group. Index: web/ccache-man.html =================================================================== RCS file: /cvsroot/ccache/web/ccache-man.html,v retrieving revision 1.25 diff -u -r1.25 ccache-man.html --- web/ccache-man.html 13 Sep 2004 10:38:17 -0000 1.25 +++ web/ccache-man.html 21 Jul 2007 21:03:32 -0000 @@ -256,7 +256,7 @@ following conditions need to be met:

  • Use the same CCACHE_DIR environment variable setting -
  • Set the CCACHE_NOLINK environment variable +
  • Unset the CCACHE_HARDLINK environment variable
  • Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in the group. swig-3.0.2/CCache/debian/patches/13_html_links.diff0000664000175000017500000000222612343605122021625 0ustar williamwilliam--- web/index.html~ 2004-09-13 13:38:30.000000000 +0300 +++ web/index.html 2004-09-26 01:04:38.458008118 +0300 @@ -29,10 +29,10 @@
  • fixed handling of HOME environment variable
-See the manual page for details +See the manual page for details on the new options.

-You can get this release from the download directory +You can get this release from the download directory

NOTE! This release changes the hash input slighly, so you will probably find that you will not get any hits against your existing @@ -87,7 +87,7 @@

Documentation

-See the manual page +See the manual page

Performance

@@ -116,7 +116,7 @@

Download

You can download the latest release from the download directory.

+href="http://ccache.samba.org/ftp/ccache/">download directory.

For the bleeding edge, you can fetch ccache via CVS or rsync. To fetch via cvs use the following command: swig-3.0.2/CCache/debian/patches/06_md.diff0000664000175000017500000000422512343605122020064 0ustar williamwilliam--- ccache.c Mon Sep 13 11:38:30 2004 +++ ccache.c Thu Jun 21 22:17:32 2007 @@ -627,6 +627,13 @@ static void process_args(int argc, char int found_S_opt = 0; struct stat st; char *e; + /* is gcc being asked to output dependencies? */ + int generating_dependencies = 0; + /* is the dependency makefile name overridden with -MF? */ + int dependency_filename_specified = 0; + /* is the dependency makefile target name specified with -MQ or -MF? */ + int dependency_target_specified = 0; + stripped_args = args_init(0, NULL); @@ -702,6 +709,18 @@ static void process_args(int argc, char continue; } + /* These options require special handling, because they + behave differently with gcc -E, when the output + file is not specified. */ + + if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) { + generating_dependencies = 1; + } else if (strcmp(argv[i], "-MF") == 0) { + dependency_filename_specified = 1; + } else if (strcmp(argv[i], "-MQ") == 0 || strcmp(argv[i], "-MT") == 0) { + dependency_target_specified = 1; + } + /* options that take an argument */ { const char *opts[] = {"-I", "-include", "-imacros", "-iprefix", @@ -812,6 +831,41 @@ static void process_args(int argc, char } p[1] = found_S_opt ? 's' : 'o'; p[2] = 0; + } + + /* If dependencies are generated, configure the preprocessor */ + + if (generating_dependencies && output_file) { + if (!dependency_filename_specified) { + char *default_depfile_name = x_strdup(output_file); + char *p = strrchr(default_depfile_name, '.'); + + if (p) { + if (strlen(p) < 2) { + stats_update(STATS_ARGS); + failed(); + return; + } + *p = 0; + } + else { + int len = p - default_depfile_name; + + p = x_malloc(len + 3); + strncpy(default_depfile_name, p, len - 1); + free(default_depfile_name); + default_depfile_name = p; + } + + strcat(default_depfile_name, ".d"); + args_add(stripped_args, "-MF"); + args_add(stripped_args, default_depfile_name); + } + + if (!dependency_target_specified) { + args_add(stripped_args, "-MT"); + args_add(stripped_args, output_file); + } } /* cope with -o /dev/null */ swig-3.0.2/CCache/debian/patches/03_long_options.diff0000664000175000017500000001150412343605122022171 0ustar williamwilliamIndex: ccache.c =================================================================== --- ccache.c (révision 7695) +++ ccache.c (copie de travail) @@ -22,6 +22,7 @@ */ #include "ccache.h" +#include /* the base cache directory */ char *cache_dir = NULL; @@ -885,14 +886,14 @@ printf("\tcompiler [compile options] (via symbolic link)\n"); printf("\nOptions:\n"); - printf("-s show statistics summary\n"); - printf("-z zero statistics\n"); - printf("-c run a cache cleanup\n"); - printf("-C clear the cache completely\n"); - printf("-F set maximum files in cache\n"); - printf("-M set maximum size of cache (use G, M or K)\n"); - printf("-h this help page\n"); - printf("-V print version number\n"); + printf("-s, --show-stats show statistics summary\n"); + printf("-z, --zero-stats zero statistics\n"); + printf("-c, --cleanup run a cache cleanup\n"); + printf("-C, --clear clear the cache completely\n"); + printf("-F , --max-files= set maximum files in cache\n"); + printf("-M , --max-size= set maximum size of cache (use G, M or K)\n"); + printf("-h, --help this help page\n"); + printf("-V, --version print version number\n"); } /* the main program when not doing a compile */ @@ -901,7 +902,21 @@ int c; size_t v; - while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { + static struct option long_options[] = + { + {"show-stats", no_argument, 0, 's'}, + {"zero-stats", no_argument, 0, 'z'}, + {"cleanup", no_argument, 0, 'c'}, + {"clear", no_argument, 0, 'C'}, + {"max-files", required_argument, 0, 'F'}, + {"max-size", required_argument, 0, 'M'}, + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'V'}, + {0, 0, 0, 0} + }; + int option_index = 0; + + while ((c = getopt_long(argc, argv, "hszcCF:M:V", long_options, &option_index)) != -1) { switch (c) { case 'V': printf("ccache version %s\n", CCACHE_VERSION); Index: ccache.1 =================================================================== --- ccache.1 (révision 7695) +++ ccache.1 (copie de travail) @@ -23,14 +23,14 @@ .nf --s show statistics summary --z zero statistics --c run a cache cleanup --C clear the cache completely --F set maximum files in cache --M set maximum size of cache (use G, M or K) --h this help page --V print version number +\-s, \-\-show-stats show statistics summary +\-z, \-\-zero-stats zero statistics +\-c, \-\-cleanup run a cache cleanup +\-C, \-\-clear clear the cache completely +\-F , \-\-max-files= set maximum files in cache +\-M , \-\-max-size= set maximum size of cache (use G, M or K) +\-h, \-\-help this help page +\-V, \-\-version print version number .fi @@ -43,22 +43,22 @@ normal compiler options apply and you should refer to your compilers documentation\&. .PP -.IP "\fB-h\fP" +.IP "\fB-h, --help\fP" Print a options summary page .IP -.IP "\fB-s\fP" +.IP "\fB-s, --show-stats\fP" Print the current statistics summary for the cache\&. The statistics are stored spread across the subdirectories of the cache\&. Using "ccache -s" adds up the statistics across all subdirectories and prints the totals\&. .IP -.IP "\fB-z\fP" +.IP "\fB-z, --zero-stats\fP" Zero the cache statistics\&. .IP -.IP "\fB-V\fP" +.IP "\fB-V, --version\fP" Print the ccache version number .IP -.IP "\fB-c\fP" +.IP "\fB-c, --cleanup\fP" Clean the cache and re-calculate the cache file count and size totals\&. Normally the -c option should not be necessary as ccache keeps the cache below the specified limits at runtime and keeps @@ -66,16 +66,16 @@ if you manually modify the cache contents or believe that the cache size statistics may be inaccurate\&. .IP -.IP "\fB-C\fP" +.IP "\fB-C, --clear\fP" Clear the entire cache, removing all cached files\&. .IP -.IP "\fB-F maxfiles\fP" +.IP "\fB-F , --max-files=\fP" This sets the maximum number of files allowed in the cache\&. The value is stored inside the cache directory and applies to all future compiles\&. Due to the way the value is stored the actual value used is always rounded down to the nearest multiple of 16\&. .IP -.IP "\fB-M maxsize\fP" +.IP "\fB-M , --max-size=\fP" This sets the maximum cache size\&. You can specify a value in gigabytes, megabytes or kilobytes by appending a G, M or K to the value\&. The default is gigabytes\&. The actual value stored is swig-3.0.2/CCache/debian/patches/10_lru_cleanup.diff0000664000175000017500000000105712343605122021770 0ustar williamwilliam--- ccache.c (révision 8804) +++ ccache.c (copie de travail) @@ -481,6 +481,9 @@ return; } + /* update timestamps for LRU cleanup + also gives output_file a sensible mtime when hard-linking (for make) */ + utime(hashname, NULL); utime(stderr_file, NULL); if (strcmp(output_file, "/dev/null") == 0) { @@ -513,10 +516,6 @@ failed(); } } - if (ret == 0) { - /* update the mtime on the file so that make doesn't get confused */ - utime(output_file, NULL); - } /* get rid of the intermediate preprocessor file */ if (i_tmpfile) { swig-3.0.2/CCache/debian/patches/12_cachesize_permissions.diff0000664000175000017500000000374512343605122024060 0ustar williamwilliam--- stats.c (révision 8804) +++ stats.c (copie de travail) @@ -286,7 +286,7 @@ /* set the per directory limits */ -void stats_set_limits(long maxfiles, long maxsize) +int stats_set_limits(long maxfiles, long maxsize) { int dir; unsigned counters[STATS_END]; @@ -298,7 +298,9 @@ maxsize /= 16; } - create_dir(cache_dir); + if (create_dir(cache_dir) != 0) { + return 1; + } /* set the limits in each directory */ for (dir=0;dir<=0xF;dir++) { @@ -306,7 +308,9 @@ int fd; x_asprintf(&cdir, "%s/%1x", cache_dir, dir); - create_dir(cdir); + if (create_dir(cdir) != 0) { + return 1; + } x_asprintf(&fname, "%s/stats", cdir); free(cdir); @@ -326,6 +330,8 @@ } free(fname); } + + return 0; } /* set the per directory sizes */ --- ccache.c (révision 8804) +++ ccache.c (copie de travail) @@ -935,15 +934,23 @@ case 'F': check_cache_dir(); v = atoi(optarg); - stats_set_limits(v, -1); - printf("Set cache file limit to %u\n", (unsigned)v); + if (stats_set_limits(v, -1) == 0) { + printf("Set cache file limit to %u\n", (unsigned)v); + } else { + printf("Could not set cache file limit.\n"); + exit(1); + } break; case 'M': check_cache_dir(); v = value_units(optarg); - stats_set_limits(-1, v); - printf("Set cache size limit to %uk\n", (unsigned)v); + if (stats_set_limits(-1, v) == 0) { + printf("Set cache size limit to %uk\n", (unsigned)v); + } else { + printf("Could not set cache size limit.\n"); + exit(1); + } break; default: --- ccache.h (révision 8804) +++ ccache.h (copie de travail) @@ -101,7 +101,7 @@ void stats_summary(void); void stats_tocache(size_t size); void stats_read(const char *stats_file, unsigned counters[STATS_END]); -void stats_set_limits(long maxfiles, long maxsize); +int stats_set_limits(long maxfiles, long maxsize); size_t value_units(const char *s); void display_size(unsigned v); void stats_set_sizes(const char *dir, size_t num_files, size_t total_size); swig-3.0.2/CCache/debian/patches/08_manpage_hyphens.diff0000664000175000017500000000722712343605122022641 0ustar williamwilliamIndex: ccache.1 =================================================================== --- ccache.1 (révision 7695) +++ ccache.1 (copie de travail) @@ -49,7 +49,7 @@ .IP "\fB-s\fP" Print the current statistics summary for the cache\&. The statistics are stored spread across the subdirectories of the -cache\&. Using "ccache -s" adds up the statistics across all +cache\&. Using "ccache \-s" adds up the statistics across all subdirectories and prints the totals\&. .IP .IP "\fB-z\fP" @@ -60,7 +60,7 @@ .IP .IP "\fB-c\fP" Clean the cache and re-calculate the cache file count and -size totals\&. Normally the -c option should not be necessary as ccache +size totals\&. Normally the \-c option should not be necessary as ccache keeps the cache below the specified limits at runtime and keeps statistics up to date on each compile\&. This option is mostly useful if you manually modify the cache contents or believe that the cache @@ -100,9 +100,9 @@ cp ccache /usr/local/bin/ - ln -s /usr/local/bin/ccache /usr/local/bin/gcc - ln -s /usr/local/bin/ccache /usr/local/bin/g++ - ln -s /usr/local/bin/ccache /usr/local/bin/cc + ln \-s /usr/local/bin/ccache /usr/local/bin/gcc + ln \-s /usr/local/bin/ccache /usr/local/bin/g++ + ln \-s /usr/local/bin/ccache /usr/local/bin/cc .fi @@ -118,7 +118,7 @@ .PP When run as a compiler front end ccache usually just takes the same command line options as the compiler you are using\&. The only exception -to this is the option \&'--ccache-skip\&'\&. That option can be used to tell +to this is the option \&'\-\-ccache-skip\&'\&. That option can be used to tell ccache that the next option is definitely not a input filename, and should be passed along to the compiler as-is\&. .PP @@ -128,7 +128,7 @@ of the resulting object file (among other things)\&. The heuristic ccache uses in this parse is that any string on the command line that exists as a file is treated as an input file name (usually a C -file)\&. By using --ccache-skip you can force an option to not be +file)\&. By using \-\-ccache-skip you can force an option to not be treated as an input file name and instead be passed along to the compiler as a command line option\&. .PP @@ -238,7 +238,7 @@ .IP "\fBCCACHE_UNIFY\fP" If you set the environment variable CCACHE_UNIFY then ccache will use the C/C++ unifier when hashing the pre-processor -output if -g is not used in the compile\&. The unifier is slower than a +output if \-g is not used in the compile\&. The unifier is slower than a normal hash, so setting this environment variable loses a little bit of speed, but it means that ccache can take advantage of not recompiling when the changes to the source code consist of @@ -262,7 +262,7 @@ .PP By default ccache has a one gigabyte limit on the cache size and no maximum number of files\&. You can set a different limit using the -"ccache -M" and "ccache -F" options, which set the size and number of +"ccache \-M" and "ccache \-F" options, which set the size and number of files limits\&. .PP When these limits are reached ccache will reduce the cache to 20% @@ -276,7 +276,7 @@ that it is the same code by forming a hash of: .PP .IP o -the pre-processor output from running the compiler with -E +the pre-processor output from running the compiler with \-E .IP o the command line options .IP o @@ -331,7 +331,7 @@ .IP o Make sure that the setgid bit is set on all directories in the cache\&. This tells the filesystem to inherit group ownership for new -directories\&. The command "chmod g+s `find $CCACHE_DIR -type d`" might +directories\&. The command "chmod g+s `find $CCACHE_DIR \-type d`" might be useful for this\&. .PP .SH "HISTORY" swig-3.0.2/CCache/debian/patches/11_utimes.diff0000664000175000017500000000460212343605122020765 0ustar williamwilliam--- ccache.c 2004-09-13 03:38:30.000000000 -0700 +++ ccache.c 2006-06-09 16:29:16.695117780 -0700 @@ -481,8 +481,13 @@ /* update timestamps for LRU cleanup also gives output_file a sensible mtime when hard-linking (for make) */ +#ifdef HAVE_UTIMES + utimes(hashname, NULL); + utimes(stderr_file, NULL); +#else utime(hashname, NULL); utime(stderr_file, NULL); +#endif if (strcmp(output_file, "/dev/null") == 0) { ret = 0; --- ccache.h 2004-09-13 03:38:30.000000000 -0700 +++ ccache.h 2006-06-09 16:28:16.601658626 -0700 @@ -22,6 +22,9 @@ #ifdef HAVE_PWD_H #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif #define STATUS_NOTFOUND 3 #define STATUS_FATAL 4 --- config.h.in 2003-09-27 21:48:17.000000000 -0700 +++ config.h.in 2006-06-09 16:25:43.000000000 -0700 @@ -19,6 +19,9 @@ /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME +/* Define to 1 if you have the `getpwuid' function. */ +#undef HAVE_GETPWUID + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -31,6 +34,9 @@ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_PWD_H + /* Define to 1 if you have the `realpath' function. */ #undef HAVE_REALPATH @@ -60,6 +66,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H @@ -69,6 +78,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `utimes' function. */ +#undef HAVE_UTIMES + /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF --- configure.in 2004-09-13 03:38:30.000000000 -0700 +++ configure.in 2006-06-09 16:25:15.541288184 -0700 @@ -27,10 +27,11 @@ AC_HEADER_TIME AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h) +AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h) AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) AC_CHECK_FUNCS(gethostname getpwuid) +AC_CHECK_FUNCS(utimes) AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ AC_TRY_COMPILE( swig-3.0.2/CCache/debian/patches/01_no_home.diff0000664000175000017500000000414212343605122021101 0ustar williamwilliam--- ccache.c +++ ccache.c @@ -836,6 +836,13 @@ { /* find the real compiler */ find_compiler(argc, argv); + + /* use the real compiler if HOME is not set */ + if (!cache_dir) { + cc_log("Unable to determine home directory\n"); + cc_log("ccache is disabled\n"); + failed(); + } /* we might be disabled */ if (getenv("CCACHE_DISABLE")) { @@ -895,6 +902,13 @@ printf("-V print version number\n"); } +static void check_cache_dir(void) +{ + if (!cache_dir) { + fatal("Unable to determine home directory"); + } +} + /* the main program when not doing a compile */ static int ccache_main(int argc, char *argv[]) { @@ -914,31 +928,37 @@ exit(0); case 's': + check_cache_dir(); stats_summary(); break; case 'c': + check_cache_dir(); cleanup_all(cache_dir); printf("Cleaned cache\n"); break; case 'C': + check_cache_dir(); wipe_all(cache_dir); printf("Cleared cache\n"); break; case 'z': + check_cache_dir(); stats_zero(); printf("Statistics cleared\n"); break; case 'F': + check_cache_dir(); v = atoi(optarg); stats_set_limits(v, -1); printf("Set cache file limit to %u\n", (unsigned)v); break; case 'M': + check_cache_dir(); v = value_units(optarg); stats_set_limits(-1, v); printf("Set cache size limit to %uk\n", (unsigned)v); @@ -983,7 +1003,10 @@ cache_dir = getenv("CCACHE_DIR"); if (!cache_dir) { - x_asprintf(&cache_dir, "%s/.ccache", get_home_directory()); + const char *home_directory = get_home_directory(); + if (home_directory) { + x_asprintf(&cache_dir, "%s/.ccache", home_directory); + } } temp_dir = getenv("CCACHE_TEMPDIR"); @@ -1023,7 +1046,7 @@ } /* make sure the cache dir exists */ - if (create_dir(cache_dir) != 0) { + if (cache_dir && (create_dir(cache_dir) != 0)) { fprintf(stderr,"ccache: failed to create %s (%s)\n", cache_dir, strerror(errno)); exit(1); --- util.c +++ util.c @@ -448,7 +448,7 @@ } } #endif - fatal("Unable to determine home directory"); + cc_log("Unable to determine home directory"); return NULL; } swig-3.0.2/CCache/debian/patches/09_respect_ldflags.diff0000664000175000017500000000053612343605122022631 0ustar williamwilliam--- Makefile.in.orig 2008-03-23 17:01:19.000000000 +1300 +++ Makefile.in 2008-03-23 17:03:03.000000000 +1300 @@ -21,7 +21,7 @@ docs: ccache.1 web/ccache-man.html ccache$(EXEEXT): $(OBJS) $(HEADERS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ccache.1: ccache.yo -yodl2man -o ccache.1 ccache.yo swig-3.0.2/CCache/debian/update-ccache0000664000175000017500000000171512343605122017310 0ustar williamwilliam#!/bin/sh # # Update compiler links to ccache (in /usr/local/bin) # # The idea is that /usr/local/bin is ahead of /usr/bin in your PATH, so adding # the link /usr/local/bin/cc -> /usr/bin/ccache means that it is run instead of # /usr/bin/cc # # Written by: Behan Webster # DIRECTORY=/usr/local/bin CCACHE=/usr/bin/ccache CCDIR=/usr/lib/ccache usage() { echo "Usage: `basename $0` [--directory

] [--remove]" exit 0 } while [ $# -gt 0 ] ; do case "$1" in -d*|--d*|--directory) DIRECTORY=$2; shift; shift;; -h*|--h*|--help) usage;; -r*|--r*|--remove) REMOVE=1; shift;; -t*|--t*|--test) TEST=echo; shift;; esac done for FILE in `cd $CCDIR; ls` ; do LINK=$DIRECTORY/$FILE if [ -z "$REMOVE" ] ; then # Add link $TEST ln -fs $CCACHE $LINK else # Remove link if [ -L "$LINK" ] ; then $TEST rm -f $LINK fi fi done # vim: sw=4 ts=4 swig-3.0.2/INSTALL0000664000175000017500000002200512343605122013373 0ustar williamwilliamBasic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. (Caching is disabled by default to prevent problems with accidental use of stale cache files.) If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You only need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for variables by setting them in the environment. You can do that on the command line like this: ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix *Note Environment Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not support the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it cannot guess the host type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are _building_ compiler tools for cross-compiling, you should use the `--target=TYPE' option to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the host platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. In this case, you should also specify the build platform with `--build=TYPE', because, in this case, it may not be possible to guess the build platform (it sometimes involves compiling and running simple test programs, and this can't be done if the compiler is a cross compiler). Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Environment Variables ===================== Variables not defined in a site shell script can be set in the environment passed to configure. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc will cause the specified gcc to be used as the C compiler (unless it is overridden in the site shell script). `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. swig-3.0.2/Source/0000775000175000017500000000000012343706574013620 5ustar williamwilliamswig-3.0.2/Source/CParse/0000775000175000017500000000000012343706600014763 5ustar williamwilliamswig-3.0.2/Source/CParse/cparse.h0000664000175000017500000000537112343605122016414 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * cparse.h * * SWIG parser module. * ----------------------------------------------------------------------------- */ #ifndef SWIG_CPARSE_H_ #define SWIG_CPARSE_H_ #include "swig.h" #include "swigwarn.h" #ifdef __cplusplus extern "C" { #endif /* cscanner.c */ extern String *cparse_file; extern int cparse_line; extern int cparse_cplusplus; extern int cparse_cplusplusout; extern int cparse_start_line; extern void Swig_cparse_cplusplus(int); extern void Swig_cparse_cplusplusout(int); extern void scanner_file(File *); extern void scanner_next_token(int); extern void skip_balanced(int startchar, int endchar); extern String *get_raw_text_balanced(int startchar, int endchar); extern void skip_decl(void); extern void scanner_check_typedef(void); extern void scanner_ignore_typedef(void); extern void scanner_last_id(int); extern void scanner_clear_rename(void); extern void scanner_set_location(String *file, int line); extern void scanner_set_main_input_file(String *file); extern String *scanner_get_main_input_file(); extern void Swig_cparse_follow_locators(int); extern void start_inline(char *, int); extern String *scanner_ccode; extern int yylex(void); /* parser.y */ extern SwigType *Swig_cparse_type(String *); extern Node *Swig_cparse(File *); extern Hash *Swig_cparse_features(void); extern void SWIG_cparse_set_compact_default_args(int defargs); extern int SWIG_cparse_template_reduce(int treduce); /* util.c */ extern void Swig_cparse_replace_descriptor(String *s); extern void cparse_normalize_void(Node *); extern Parm *Swig_cparse_parm(String *s); extern ParmList *Swig_cparse_parms(String *s, Node *file_line_node); extern Node *new_node(const_String_or_char_ptr tag); /* templ.c */ extern int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *tscope); extern Node *Swig_cparse_template_locate(String *name, ParmList *tparms, Symtab *tscope); extern void Swig_cparse_debug_templates(int); #ifdef __cplusplus } #endif #define SWIG_WARN_NODE_BEGIN(Node) \ { \ String *wrnfilter = Node ? Getattr(Node,"feature:warnfilter") : 0; \ if (wrnfilter) Swig_warnfilter(wrnfilter,1) #define SWIG_WARN_NODE_END(Node) \ if (wrnfilter) Swig_warnfilter(wrnfilter,0); \ } #endif swig-3.0.2/Source/CParse/parser.c0000664000175000017500000153177712343706600016450 0ustar williamwilliam/* A Bison parser, made by GNU Bison 2.5. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "2.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Using locations. */ #define YYLSP_NEEDED 0 /* Copy the first part of user declarations. */ /* Line 268 of yacc.c */ #line 22 "parser.y" #define yylex yylex #include "swig.h" #include "cparse.h" #include "preprocessor.h" #include /* We do this for portability */ #undef alloca #define alloca malloc /* ----------------------------------------------------------------------------- * Externals * ----------------------------------------------------------------------------- */ int yyparse(); /* NEW Variables */ static Node *top = 0; /* Top of the generated parse tree */ static int unnamed = 0; /* Unnamed datatype counter */ static Hash *classes = 0; /* Hash table of classes */ static Hash *classes_typedefs = 0; /* Hash table of typedef classes: typedef struct X {...} Y; */ static Symtab *prev_symtab = 0; static Node *current_class = 0; String *ModuleName = 0; static Node *module_node = 0; static String *Classprefix = 0; static String *Namespaceprefix = 0; static int inclass = 0; static Node *currentOuterClass = 0; /* for nested classes */ static char *last_cpptype = 0; static int inherit_list = 0; static Parm *template_parameters = 0; static int extendmode = 0; static int compact_default_args = 0; static int template_reduce = 0; static int cparse_externc = 0; int ignore_nested_classes = 0; /* ----------------------------------------------------------------------------- * Assist Functions * ----------------------------------------------------------------------------- */ /* Called by the parser (yyparse) when an error is found.*/ static void yyerror (const char *e) { (void)e; } /* Copies a node. Does not copy tree links or symbol table data (except for sym:name) */ static Node *copy_node(Node *n) { Node *nn; Iterator k; nn = NewHash(); Setfile(nn,Getfile(n)); Setline(nn,Getline(n)); for (k = First(n); k.key; k = Next(k)) { String *ci; String *key = k.key; char *ckey = Char(key); if ((strcmp(ckey,"nextSibling") == 0) || (strcmp(ckey,"previousSibling") == 0) || (strcmp(ckey,"parentNode") == 0) || (strcmp(ckey,"lastChild") == 0)) { continue; } if (Strncmp(key,"csym:",5) == 0) continue; /* We do copy sym:name. For templates */ if ((strcmp(ckey,"sym:name") == 0) || (strcmp(ckey,"sym:weak") == 0) || (strcmp(ckey,"sym:typename") == 0)) { String *ci = Copy(k.item); Setattr(nn,key, ci); Delete(ci); continue; } if (strcmp(ckey,"sym:symtab") == 0) { Setattr(nn,"sym:needs_symtab", "1"); } /* We don't copy any other symbol table attributes */ if (strncmp(ckey,"sym:",4) == 0) { continue; } /* If children. We copy them recursively using this function */ if (strcmp(ckey,"firstChild") == 0) { /* Copy children */ Node *cn = k.item; while (cn) { Node *copy = copy_node(cn); appendChild(nn,copy); Delete(copy); cn = nextSibling(cn); } continue; } /* We don't copy the symbol table. But we drop an attribute requires_symtab so that functions know it needs to be built */ if (strcmp(ckey,"symtab") == 0) { /* Node defined a symbol table. */ Setattr(nn,"requires_symtab","1"); continue; } /* Can't copy nodes */ if (strcmp(ckey,"node") == 0) { continue; } if ((strcmp(ckey,"parms") == 0) || (strcmp(ckey,"pattern") == 0) || (strcmp(ckey,"throws") == 0) || (strcmp(ckey,"kwargs") == 0)) { ParmList *pl = CopyParmList(k.item); Setattr(nn,key,pl); Delete(pl); continue; } if (strcmp(ckey,"nested:outer") == 0) { /* don't copy outer classes links, they will be updated later */ Setattr(nn, key, k.item); continue; } /* Looks okay. Just copy the data using Copy */ ci = Copy(k.item); Setattr(nn, key, ci); Delete(ci); } return nn; } /* ----------------------------------------------------------------------------- * Variables * ----------------------------------------------------------------------------- */ static char *typemap_lang = 0; /* Current language setting */ static int cplus_mode = 0; /* C++ modes */ #define CPLUS_PUBLIC 1 #define CPLUS_PRIVATE 2 #define CPLUS_PROTECTED 3 /* include types */ static int import_mode = 0; void SWIG_typemap_lang(const char *tm_lang) { typemap_lang = Swig_copy_string(tm_lang); } void SWIG_cparse_set_compact_default_args(int defargs) { compact_default_args = defargs; } int SWIG_cparse_template_reduce(int treduce) { template_reduce = treduce; return treduce; } /* ----------------------------------------------------------------------------- * Assist functions * ----------------------------------------------------------------------------- */ static int promote_type(int t) { if (t <= T_UCHAR || t == T_CHAR) return T_INT; return t; } /* Perform type-promotion for binary operators */ static int promote(int t1, int t2) { t1 = promote_type(t1); t2 = promote_type(t2); return t1 > t2 ? t1 : t2; } static String *yyrename = 0; /* Forward renaming operator */ static String *resolve_create_node_scope(String *cname); Hash *Swig_cparse_features(void) { static Hash *features_hash = 0; if (!features_hash) features_hash = NewHash(); return features_hash; } /* Fully qualify any template parameters */ static String *feature_identifier_fix(String *s) { String *tp = SwigType_istemplate_templateprefix(s); if (tp) { String *ts, *ta, *tq; ts = SwigType_templatesuffix(s); ta = SwigType_templateargs(s); tq = Swig_symbol_type_qualify(ta,0); Append(tp,tq); Append(tp,ts); Delete(ts); Delete(ta); Delete(tq); return tp; } else { return NewString(s); } } static void set_access_mode(Node *n) { if (cplus_mode == CPLUS_PUBLIC) Setattr(n, "access", "public"); else if (cplus_mode == CPLUS_PROTECTED) Setattr(n, "access", "protected"); else Setattr(n, "access", "private"); } static void restore_access_mode(Node *n) { String *mode = Getattr(n, "access"); if (Strcmp(mode, "private") == 0) cplus_mode = CPLUS_PRIVATE; else if (Strcmp(mode, "protected") == 0) cplus_mode = CPLUS_PROTECTED; else cplus_mode = CPLUS_PUBLIC; } /* Generate the symbol table name for an object */ /* This is a bit of a mess. Need to clean up */ static String *add_oldname = 0; static String *make_name(Node *n, String *name,SwigType *decl) { int destructor = name && (*(Char(name)) == '~'); if (yyrename) { String *s = NewString(yyrename); Delete(yyrename); yyrename = 0; if (destructor && (*(Char(s)) != '~')) { Insert(s,0,"~"); } return s; } if (!name) return 0; return Swig_name_make(n,Namespaceprefix,name,decl,add_oldname); } /* Generate an unnamed identifier */ static String *make_unnamed() { unnamed++; return NewStringf("$unnamed%d$",unnamed); } /* Return if the node is a friend declaration */ static int is_friend(Node *n) { return Cmp(Getattr(n,"storage"),"friend") == 0; } static int is_operator(String *name) { return Strncmp(name,"operator ", 9) == 0; } /* Add declaration list to symbol table */ static int add_only_one = 0; static void add_symbols(Node *n) { String *decl; String *wrn = 0; if (inclass && n) { cparse_normalize_void(n); } while (n) { String *symname = 0; /* for friends, we need to pop the scope once */ String *old_prefix = 0; Symtab *old_scope = 0; int isfriend = inclass && is_friend(n); int iscdecl = Cmp(nodeType(n),"cdecl") == 0; int only_csymbol = 0; if (inclass) { String *name = Getattr(n, "name"); if (isfriend) { /* for friends, we need to add the scopename if needed */ String *prefix = name ? Swig_scopename_prefix(name) : 0; old_prefix = Namespaceprefix; old_scope = Swig_symbol_popscope(); Namespaceprefix = Swig_symbol_qualifiedscopename(0); if (!prefix) { if (name && !is_operator(name) && Namespaceprefix) { String *nname = NewStringf("%s::%s", Namespaceprefix, name); Setattr(n,"name",nname); Delete(nname); } } else { Symtab *st = Swig_symbol_getscope(prefix); String *ns = st ? Getattr(st,"name") : prefix; String *base = Swig_scopename_last(name); String *nname = NewStringf("%s::%s", ns, base); Setattr(n,"name",nname); Delete(nname); Delete(base); Delete(prefix); } Namespaceprefix = 0; } else { /* for member functions, we need to remove the redundant class scope if provided, as in struct Foo { int Foo::method(int a); }; */ String *prefix = name ? Swig_scopename_prefix(name) : 0; if (prefix) { if (Classprefix && (Equal(prefix,Classprefix))) { String *base = Swig_scopename_last(name); Setattr(n,"name",base); Delete(base); } Delete(prefix); } } } if (!isfriend && (inclass || extendmode)) { Setattr(n,"ismember","1"); } if (extendmode) { Setattr(n,"isextendmember","1"); } if (!isfriend && inclass) { if ((cplus_mode != CPLUS_PUBLIC)) { only_csymbol = 1; if (cplus_mode == CPLUS_PROTECTED) { Setattr(n,"access", "protected"); only_csymbol = !Swig_need_protected(n); } else { Setattr(n,"access", "private"); /* private are needed only when they are pure virtuals - why? */ if ((Cmp(Getattr(n,"storage"),"virtual") == 0) && (Cmp(Getattr(n,"value"),"0") == 0)) { only_csymbol = 0; } } } else { Setattr(n,"access", "public"); } } if (Getattr(n,"sym:name")) { n = nextSibling(n); continue; } decl = Getattr(n,"decl"); if (!SwigType_isfunction(decl)) { String *name = Getattr(n,"name"); String *makename = Getattr(n,"parser:makename"); if (iscdecl) { String *storage = Getattr(n, "storage"); if (Cmp(storage,"typedef") == 0) { Setattr(n,"kind","typedef"); } else { SwigType *type = Getattr(n,"type"); String *value = Getattr(n,"value"); Setattr(n,"kind","variable"); if (value && Len(value)) { Setattr(n,"hasvalue","1"); } if (type) { SwigType *ty; SwigType *tmp = 0; if (decl) { ty = tmp = Copy(type); SwigType_push(ty,decl); } else { ty = type; } if (!SwigType_ismutable(ty) || (storage && Strstr(storage, "constexpr"))) { SetFlag(n,"hasconsttype"); SetFlag(n,"feature:immutable"); } if (tmp) Delete(tmp); } if (!type) { Printf(stderr,"notype name %s\n", name); } } } Swig_features_get(Swig_cparse_features(), Namespaceprefix, name, 0, n); if (makename) { symname = make_name(n, makename,0); Delattr(n,"parser:makename"); /* temporary information, don't leave it hanging around */ } else { makename = name; symname = make_name(n, makename,0); } if (!symname) { symname = Copy(Getattr(n,"unnamed")); } if (symname) { wrn = Swig_name_warning(n, Namespaceprefix, symname,0); } } else { String *name = Getattr(n,"name"); SwigType *fdecl = Copy(decl); SwigType *fun = SwigType_pop_function(fdecl); if (iscdecl) { Setattr(n,"kind","function"); } Swig_features_get(Swig_cparse_features(),Namespaceprefix,name,fun,n); symname = make_name(n, name,fun); wrn = Swig_name_warning(n, Namespaceprefix,symname,fun); Delete(fdecl); Delete(fun); } if (!symname) { n = nextSibling(n); continue; } if (cparse_cplusplus) { String *value = Getattr(n, "value"); if (value && Strcmp(value, "delete") == 0) { /* C++11 deleted definition / deleted function */ SetFlag(n,"deleted"); SetFlag(n,"feature:ignore"); } } if (only_csymbol || GetFlag(n,"feature:ignore")) { /* Only add to C symbol table and continue */ Swig_symbol_add(0, n); } else if (strncmp(Char(symname),"$ignore",7) == 0) { char *c = Char(symname)+7; SetFlag(n,"feature:ignore"); if (strlen(c)) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1); SWIG_WARN_NODE_END(n); } Swig_symbol_add(0, n); } else { Node *c; if ((wrn) && (Len(wrn))) { String *metaname = symname; if (!Getmeta(metaname,"already_warned")) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(0,Getfile(n),Getline(n), "%s\n", wrn); SWIG_WARN_NODE_END(n); Setmeta(metaname,"already_warned","1"); } } c = Swig_symbol_add(symname,n); if (c != n) { /* symbol conflict attempting to add in the new symbol */ if (Getattr(n,"sym:weak")) { Setattr(n,"sym:name",symname); } else { String *e = NewStringEmpty(); String *en = NewStringEmpty(); String *ec = NewStringEmpty(); int redefined = Swig_need_redefined_warn(n,c,inclass); if (redefined) { Printf(en,"Identifier '%s' redefined (ignored)",symname); Printf(ec,"previous definition of '%s'",symname); } else { Printf(en,"Redundant redeclaration of '%s'",symname); Printf(ec,"previous declaration of '%s'",symname); } if (Cmp(symname,Getattr(n,"name"))) { Printf(en," (Renamed from '%s')", SwigType_namestr(Getattr(n,"name"))); } Printf(en,","); if (Cmp(symname,Getattr(c,"name"))) { Printf(ec," (Renamed from '%s')", SwigType_namestr(Getattr(c,"name"))); } Printf(ec,"."); SWIG_WARN_NODE_BEGIN(n); if (redefined) { Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en); Swig_warning(WARN_PARSE_REDEFINED,Getfile(c),Getline(c),"%s\n",ec); } else if (!is_friend(n) && !is_friend(c)) { Swig_warning(WARN_PARSE_REDUNDANT,Getfile(n),Getline(n),"%s\n",en); Swig_warning(WARN_PARSE_REDUNDANT,Getfile(c),Getline(c),"%s\n",ec); } SWIG_WARN_NODE_END(n); Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(n),Getline(n),en, Getfile(c),Getline(c),ec); Setattr(n,"error",e); Delete(e); Delete(en); Delete(ec); } } } /* restore the class scope if needed */ if (isfriend) { Swig_symbol_setscope(old_scope); if (old_prefix) { Delete(Namespaceprefix); Namespaceprefix = old_prefix; } } Delete(symname); if (add_only_one) return; n = nextSibling(n); } } /* add symbols a parse tree node copy */ static void add_symbols_copy(Node *n) { String *name; int emode = 0; while (n) { char *cnodeType = Char(nodeType(n)); if (strcmp(cnodeType,"access") == 0) { String *kind = Getattr(n,"kind"); if (Strcmp(kind,"public") == 0) { cplus_mode = CPLUS_PUBLIC; } else if (Strcmp(kind,"private") == 0) { cplus_mode = CPLUS_PRIVATE; } else if (Strcmp(kind,"protected") == 0) { cplus_mode = CPLUS_PROTECTED; } n = nextSibling(n); continue; } add_oldname = Getattr(n,"sym:name"); if ((add_oldname) || (Getattr(n,"sym:needs_symtab"))) { int old_inclass = -1; Node *old_current_class = 0; if (add_oldname) { DohIncref(add_oldname); /* Disable this, it prevents %rename to work with templates */ /* If already renamed, we used that name */ /* if (Strcmp(add_oldname, Getattr(n,"name")) != 0) { Delete(yyrename); yyrename = Copy(add_oldname); } */ } Delattr(n,"sym:needs_symtab"); Delattr(n,"sym:name"); add_only_one = 1; add_symbols(n); if (Getattr(n,"partialargs")) { Swig_symbol_cadd(Getattr(n,"partialargs"),n); } add_only_one = 0; name = Getattr(n,"name"); if (Getattr(n,"requires_symtab")) { Swig_symbol_newscope(); Swig_symbol_setscopename(name); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } if (strcmp(cnodeType,"class") == 0) { old_inclass = inclass; inclass = 1; old_current_class = current_class; current_class = n; if (Strcmp(Getattr(n,"kind"),"class") == 0) { cplus_mode = CPLUS_PRIVATE; } else { cplus_mode = CPLUS_PUBLIC; } } if (strcmp(cnodeType,"extend") == 0) { emode = cplus_mode; cplus_mode = CPLUS_PUBLIC; } add_symbols_copy(firstChild(n)); if (strcmp(cnodeType,"extend") == 0) { cplus_mode = emode; } if (Getattr(n,"requires_symtab")) { Setattr(n,"symtab", Swig_symbol_popscope()); Delattr(n,"requires_symtab"); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } if (add_oldname) { Delete(add_oldname); add_oldname = 0; } if (strcmp(cnodeType,"class") == 0) { inclass = old_inclass; current_class = old_current_class; } } else { if (strcmp(cnodeType,"extend") == 0) { emode = cplus_mode; cplus_mode = CPLUS_PUBLIC; } add_symbols_copy(firstChild(n)); if (strcmp(cnodeType,"extend") == 0) { cplus_mode = emode; } } n = nextSibling(n); } } /* Check a set of declarations to see if any are pure-abstract */ static List *pure_abstracts(Node *n) { List *abstracts = 0; while (n) { if (Cmp(nodeType(n),"cdecl") == 0) { String *decl = Getattr(n,"decl"); if (SwigType_isfunction(decl)) { String *init = Getattr(n,"value"); if (Cmp(init,"0") == 0) { if (!abstracts) { abstracts = NewList(); } Append(abstracts,n); SetFlag(n,"abstract"); } } } else if (Cmp(nodeType(n),"destructor") == 0) { if (Cmp(Getattr(n,"value"),"0") == 0) { if (!abstracts) { abstracts = NewList(); } Append(abstracts,n); SetFlag(n,"abstract"); } } n = nextSibling(n); } return abstracts; } /* Make a classname */ static String *make_class_name(String *name) { String *nname = 0; String *prefix; if (Namespaceprefix) { nname= NewStringf("%s::%s", Namespaceprefix, name); } else { nname = NewString(name); } prefix = SwigType_istemplate_templateprefix(nname); if (prefix) { String *args, *qargs; args = SwigType_templateargs(nname); qargs = Swig_symbol_type_qualify(args,0); Append(prefix,qargs); Delete(nname); Delete(args); Delete(qargs); nname = prefix; } return nname; } /* Use typedef name as class name */ static void add_typedef_name(Node *n, Node *decl, String *oldName, Symtab *cscope, String *scpname) { String *class_rename = 0; SwigType *decltype = Getattr(decl, "decl"); if (!decltype || !Len(decltype)) { String *cname; String *tdscopename; String *class_scope = Swig_symbol_qualifiedscopename(cscope); String *name = Getattr(decl, "name"); cname = Copy(name); Setattr(n, "tdname", cname); tdscopename = class_scope ? NewStringf("%s::%s", class_scope, name) : Copy(name); class_rename = Getattr(n, "class_rename"); if (class_rename && (Strcmp(class_rename, oldName) == 0)) Setattr(n, "class_rename", NewString(name)); if (!classes_typedefs) classes_typedefs = NewHash(); if (!Equal(scpname, tdscopename) && !Getattr(classes_typedefs, tdscopename)) { Setattr(classes_typedefs, tdscopename, n); } Setattr(n, "decl", decltype); Delete(class_scope); Delete(cname); Delete(tdscopename); } } /* If the class name is qualified. We need to create or lookup namespace entries */ static Symtab *set_scope_to_global() { Symtab *symtab = Swig_symbol_global_scope(); Swig_symbol_setscope(symtab); return symtab; } /* Remove the block braces, { and }, if the 'noblock' attribute is set. * Node *kw can be either a Hash or Parmlist. */ static String *remove_block(Node *kw, const String *inputcode) { String *modified_code = 0; while (kw) { String *name = Getattr(kw,"name"); if (name && (Cmp(name,"noblock") == 0)) { char *cstr = Char(inputcode); size_t len = Len(inputcode); if (len && cstr[0] == '{') { --len; ++cstr; if (len && cstr[len - 1] == '}') { --len; } /* we now remove the extra spaces */ while (len && isspace((int)cstr[0])) { --len; ++cstr; } while (len && isspace((int)cstr[len - 1])) { --len; } modified_code = NewStringWithSize(cstr, len); break; } } kw = nextSibling(kw); } return modified_code; } static Node *nscope = 0; static Node *nscope_inner = 0; /* Remove the scope prefix from cname and return the base name without the prefix. * The scopes required for the symbol name are resolved and/or created, if required. * For example AA::BB::CC as input returns CC and creates the namespace AA then inner * namespace BB in the current scope. If cname is found to already exist as a weak symbol * (forward reference) then the scope might be changed to match, such as when a symbol match * is made via a using reference. */ static String *resolve_create_node_scope(String *cname) { Symtab *gscope = 0; Node *cname_node = 0; int skip_lookup = 0; nscope = 0; nscope_inner = 0; if (Strncmp(cname,"::",2) == 0) skip_lookup = 1; cname_node = skip_lookup ? 0 : Swig_symbol_clookup_no_inherit(cname, 0); if (cname_node) { /* The symbol has been defined already or is in another scope. If it is a weak symbol, it needs replacing and if it was brought into the current scope via a using declaration, the scope needs adjusting appropriately for the new symbol. Similarly for defined templates. */ Symtab *symtab = Getattr(cname_node, "sym:symtab"); Node *sym_weak = Getattr(cname_node, "sym:weak"); if ((symtab && sym_weak) || Equal(nodeType(cname_node), "template")) { /* Check if the scope is the current scope */ String *current_scopename = Swig_symbol_qualifiedscopename(0); String *found_scopename = Swig_symbol_qualifiedscopename(symtab); int len; if (!current_scopename) current_scopename = NewString(""); if (!found_scopename) found_scopename = NewString(""); len = Len(current_scopename); if ((len > 0) && (Strncmp(current_scopename, found_scopename, len) == 0)) { if (Len(found_scopename) > len + 2) { /* A matching weak symbol was found in non-global scope, some scope adjustment may be required */ String *new_cname = NewString(Char(found_scopename) + len + 2); /* skip over "::" prefix */ String *base = Swig_scopename_last(cname); Printf(new_cname, "::%s", base); cname = new_cname; Delete(base); } else { /* A matching weak symbol was found in the same non-global local scope, no scope adjustment required */ assert(len == Len(found_scopename)); } } else { String *base = Swig_scopename_last(cname); if (Len(found_scopename) > 0) { /* A matching weak symbol was found in a different scope to the local scope - probably via a using declaration */ cname = NewStringf("%s::%s", found_scopename, base); } else { /* Either: 1) A matching weak symbol was found in a different scope to the local scope - this is actually a symbol with the same name in a different scope which we don't want, so no adjustment required. 2) A matching weak symbol was found in the global scope - no adjustment required. */ cname = Copy(base); } Delete(base); } Delete(current_scopename); Delete(found_scopename); } } if (Swig_scopename_check(cname)) { Node *ns; String *prefix = Swig_scopename_prefix(cname); String *base = Swig_scopename_last(cname); if (prefix && (Strncmp(prefix,"::",2) == 0)) { /* I don't think we can use :: global scope to declare classes and hence neither %template. - consider reporting error instead - wsfulton. */ /* Use the global scope */ String *nprefix = NewString(Char(prefix)+2); Delete(prefix); prefix= nprefix; gscope = set_scope_to_global(); } if (Len(prefix) == 0) { /* Use the global scope, but we need to add a 'global' namespace. */ if (!gscope) gscope = set_scope_to_global(); /* note that this namespace is not the "unnamed" one, and we don't use Setattr(nscope,"name", ""), because the unnamed namespace is private */ nscope = new_node("namespace"); Setattr(nscope,"symtab", gscope);; nscope_inner = nscope; return base; } /* Try to locate the scope */ ns = Swig_symbol_clookup(prefix,0); if (!ns) { Swig_error(cparse_file,cparse_line,"Undefined scope '%s'\n", prefix); } else { Symtab *nstab = Getattr(ns,"symtab"); if (!nstab) { Swig_error(cparse_file,cparse_line, "'%s' is not defined as a valid scope.\n", prefix); ns = 0; } else { /* Check if the node scope is the current scope */ String *tname = Swig_symbol_qualifiedscopename(0); String *nname = Swig_symbol_qualifiedscopename(nstab); if (tname && (Strcmp(tname,nname) == 0)) { ns = 0; cname = base; } Delete(tname); Delete(nname); } if (ns) { /* we will try to create a new node using the namespaces we can find in the scope name */ List *scopes; String *sname; Iterator si; String *name = NewString(prefix); scopes = NewList(); while (name) { String *base = Swig_scopename_last(name); String *tprefix = Swig_scopename_prefix(name); Insert(scopes,0,base); Delete(base); Delete(name); name = tprefix; } for (si = First(scopes); si.item; si = Next(si)) { Node *ns1,*ns2; sname = si.item; ns1 = Swig_symbol_clookup(sname,0); assert(ns1); if (Strcmp(nodeType(ns1),"namespace") == 0) { if (Getattr(ns1,"alias")) { ns1 = Getattr(ns1,"namespace"); } } else { /* now this last part is a class */ si = Next(si); /* or a nested class tree, which is unrolled here */ for (; si.item; si = Next(si)) { if (si.item) { Printf(sname,"::%s",si.item); } } /* we get the 'inner' class */ nscope_inner = Swig_symbol_clookup(sname,0); /* set the scope to the inner class */ Swig_symbol_setscope(Getattr(nscope_inner,"symtab")); /* save the last namespace prefix */ Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); /* and return the node name, including the inner class prefix */ break; } /* here we just populate the namespace tree as usual */ ns2 = new_node("namespace"); Setattr(ns2,"name",sname); Setattr(ns2,"symtab", Getattr(ns1,"symtab")); add_symbols(ns2); Swig_symbol_setscope(Getattr(ns1,"symtab")); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); if (nscope_inner) { if (Getattr(nscope_inner,"symtab") != Getattr(ns2,"symtab")) { appendChild(nscope_inner,ns2); Delete(ns2); } } nscope_inner = ns2; if (!nscope) nscope = ns2; } cname = base; Delete(scopes); } } Delete(prefix); } return cname; } /* look for simple typedef name in typedef list */ static String *try_to_find_a_name_for_unnamed_structure(const char *storage, Node *decls) { String *name = 0; Node *n = decls; if (storage && (strcmp(storage, "typedef") == 0)) { for (; n; n = nextSibling(n)) { if (!Len(Getattr(n, "decl"))) { name = Copy(Getattr(n, "name")); break; } } } return name; } /* traverse copied tree segment, and update outer class links*/ static void update_nested_classes(Node *n) { Node *c = firstChild(n); while (c) { if (Getattr(c, "nested:outer")) Setattr(c, "nested:outer", n); update_nested_classes(c); c = nextSibling(c); } } /* ----------------------------------------------------------------------------- * nested_forward_declaration() * * Nested struct handling for C++ code if the nested classes are disabled. * Create the nested class/struct/union as a forward declaration. * ----------------------------------------------------------------------------- */ static Node *nested_forward_declaration(const char *storage, const char *kind, String *sname, String *name, Node *cpp_opt_declarators) { Node *nn = 0; int warned = 0; if (sname) { /* Add forward declaration of the nested type */ Node *n = new_node("classforward"); Setattr(n, "kind", kind); Setattr(n, "name", sname); Setattr(n, "storage", storage); Setattr(n, "sym:weak", "1"); add_symbols(n); nn = n; } /* Add any variable instances. Also add in any further typedefs of the nested type. Note that anonymous typedefs (eg typedef struct {...} a, b;) are treated as class forward declarations */ if (cpp_opt_declarators) { int storage_typedef = (storage && (strcmp(storage, "typedef") == 0)); int variable_of_anonymous_type = !sname && !storage_typedef; if (!variable_of_anonymous_type) { int anonymous_typedef = !sname && (storage && (strcmp(storage, "typedef") == 0)); Node *n = cpp_opt_declarators; SwigType *type = name; while (n) { Setattr(n, "type", type); Setattr(n, "storage", storage); if (anonymous_typedef) { Setattr(n, "nodeType", "classforward"); Setattr(n, "sym:weak", "1"); } n = nextSibling(n); } add_symbols(cpp_opt_declarators); if (nn) { set_nextSibling(nn, cpp_opt_declarators); } else { nn = cpp_opt_declarators; } } } if (!GetFlag(currentOuterClass, "nested")) { if (nn && Equal(nodeType(nn), "classforward")) { Node *n = nn; SWIG_WARN_NODE_BEGIN(n); Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", kind, sname ? sname : name); SWIG_WARN_NODE_END(n); warned = 1; } if (!warned) { Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", kind); } } return nn; } Node *Swig_cparse(File *f) { scanner_file(f); top = 0; yyparse(); return top; } static void single_new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) { String *fname; String *name; String *fixname; SwigType *t = Copy(type); /* Printf(stdout, "single_new_feature: [%s] [%s] [%s] [%s] [%s] [%s]\n", featurename, val, declaratorid, t, ParmList_str_defaultargs(declaratorparms), qualifier); */ /* Warn about deprecated features */ if (strcmp(featurename, "nestedworkaround") == 0) Swig_warning(WARN_DEPRECATED_NESTED_WORKAROUND, cparse_file, cparse_line, "The 'nestedworkaround' feature is deprecated.\n"); fname = NewStringf("feature:%s",featurename); if (declaratorid) { fixname = feature_identifier_fix(declaratorid); } else { fixname = NewStringEmpty(); } if (Namespaceprefix) { name = NewStringf("%s::%s",Namespaceprefix, fixname); } else { name = fixname; } if (declaratorparms) Setmeta(val,"parms",declaratorparms); if (!Len(t)) t = 0; if (t) { if (qualifier) SwigType_push(t,qualifier); if (SwigType_isfunction(t)) { SwigType *decl = SwigType_pop_function(t); if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",name); Swig_feature_set(Swig_cparse_features(), nname, decl, fname, val, featureattribs); Delete(nname); } else { Swig_feature_set(Swig_cparse_features(), name, decl, fname, val, featureattribs); } Delete(decl); } else if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",name); Swig_feature_set(Swig_cparse_features(),nname,0,fname,val, featureattribs); Delete(nname); } } else { /* Global feature, that is, feature not associated with any particular symbol */ Swig_feature_set(Swig_cparse_features(),name,0,fname,val, featureattribs); } Delete(fname); Delete(name); } /* Add a new feature to the Hash. Additional features are added if the feature has a parameter list (declaratorparms) * and one or more of the parameters have a default argument. An extra feature is added for each defaulted parameter, * simulating the equivalent overloaded method. */ static void new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) { ParmList *declparms = declaratorparms; /* remove the { and } braces if the noblock attribute is set */ String *newval = remove_block(featureattribs, val); val = newval ? newval : val; /* Add the feature */ single_new_feature(featurename, val, featureattribs, declaratorid, type, declaratorparms, qualifier); /* Add extra features if there are default parameters in the parameter list */ if (type) { while (declparms) { if (ParmList_has_defaultargs(declparms)) { /* Create a parameter list for the new feature by copying all but the last (defaulted) parameter */ ParmList* newparms = CopyParmListMax(declparms, ParmList_len(declparms)-1); /* Create new declaration - with the last parameter removed */ SwigType *newtype = Copy(type); Delete(SwigType_pop_function(newtype)); /* remove the old parameter list from newtype */ SwigType_add_function(newtype,newparms); single_new_feature(featurename, Copy(val), featureattribs, declaratorid, newtype, newparms, qualifier); declparms = newparms; } else { declparms = 0; } } } } /* check if a function declaration is a plain C object */ static int is_cfunction(Node *n) { if (!cparse_cplusplus || cparse_externc) return 1; if (Swig_storage_isexternc(n)) { return 1; } return 0; } /* If the Node is a function with parameters, check to see if any of the parameters * have default arguments. If so create a new function for each defaulted argument. * The additional functions form a linked list of nodes with the head being the original Node n. */ static void default_arguments(Node *n) { Node *function = n; if (function) { ParmList *varargs = Getattr(function,"feature:varargs"); if (varargs) { /* Handles the %varargs directive by looking for "feature:varargs" and * substituting ... with an alternative set of arguments. */ Parm *p = Getattr(function,"parms"); Parm *pp = 0; while (p) { SwigType *t = Getattr(p,"type"); if (Strcmp(t,"v(...)") == 0) { if (pp) { ParmList *cv = Copy(varargs); set_nextSibling(pp,cv); Delete(cv); } else { ParmList *cv = Copy(varargs); Setattr(function,"parms", cv); Delete(cv); } break; } pp = p; p = nextSibling(p); } } /* Do not add in functions if kwargs is being used or if user wants old default argument wrapping (one wrapped method per function irrespective of number of default arguments) */ if (compact_default_args || is_cfunction(function) || GetFlag(function,"feature:compactdefaultargs") || GetFlag(function,"feature:kwargs")) { ParmList *p = Getattr(function,"parms"); if (p) Setattr(p,"compactdefargs", "1"); /* mark parameters for special handling */ function = 0; /* don't add in extra methods */ } } while (function) { ParmList *parms = Getattr(function,"parms"); if (ParmList_has_defaultargs(parms)) { /* Create a parameter list for the new function by copying all but the last (defaulted) parameter */ ParmList* newparms = CopyParmListMax(parms,ParmList_len(parms)-1); /* Create new function and add to symbol table */ { SwigType *ntype = Copy(nodeType(function)); char *cntype = Char(ntype); Node *new_function = new_node(ntype); SwigType *decl = Copy(Getattr(function,"decl")); int constqualifier = SwigType_isconst(decl); String *ccode = Copy(Getattr(function,"code")); String *cstorage = Copy(Getattr(function,"storage")); String *cvalue = Copy(Getattr(function,"value")); SwigType *ctype = Copy(Getattr(function,"type")); String *cthrow = Copy(Getattr(function,"throw")); Delete(SwigType_pop_function(decl)); /* remove the old parameter list from decl */ SwigType_add_function(decl,newparms); if (constqualifier) SwigType_add_qualifier(decl,"const"); Setattr(new_function,"name", Getattr(function,"name")); Setattr(new_function,"code", ccode); Setattr(new_function,"decl", decl); Setattr(new_function,"parms", newparms); Setattr(new_function,"storage", cstorage); Setattr(new_function,"value", cvalue); Setattr(new_function,"type", ctype); Setattr(new_function,"throw", cthrow); Delete(ccode); Delete(cstorage); Delete(cvalue); Delete(ctype); Delete(cthrow); Delete(decl); { Node *throws = Getattr(function,"throws"); ParmList *pl = CopyParmList(throws); if (throws) Setattr(new_function,"throws",pl); Delete(pl); } /* copy specific attributes for global (or in a namespace) template functions - these are not templated class methods */ if (strcmp(cntype,"template") == 0) { Node *templatetype = Getattr(function,"templatetype"); Node *symtypename = Getattr(function,"sym:typename"); Parm *templateparms = Getattr(function,"templateparms"); if (templatetype) { Node *tmp = Copy(templatetype); Setattr(new_function,"templatetype",tmp); Delete(tmp); } if (symtypename) { Node *tmp = Copy(symtypename); Setattr(new_function,"sym:typename",tmp); Delete(tmp); } if (templateparms) { Parm *tmp = CopyParmList(templateparms); Setattr(new_function,"templateparms",tmp); Delete(tmp); } } else if (strcmp(cntype,"constructor") == 0) { /* only copied for constructors as this is not a user defined feature - it is hard coded in the parser */ if (GetFlag(function,"feature:new")) SetFlag(new_function,"feature:new"); } add_symbols(new_function); /* mark added functions as ones with overloaded parameters and point to the parsed method */ Setattr(new_function,"defaultargs", n); /* Point to the new function, extending the linked list */ set_nextSibling(function, new_function); Delete(new_function); function = new_function; Delete(ntype); } } else { function = 0; } } } /* ----------------------------------------------------------------------------- * mark_nodes_as_extend() * * Used by the %extend to mark subtypes with "feature:extend". * template instances declared within %extend are skipped * ----------------------------------------------------------------------------- */ static void mark_nodes_as_extend(Node *n) { for (; n; n = nextSibling(n)) { if (Getattr(n, "template") && Strcmp(nodeType(n), "class") == 0) continue; /* Fix me: extend is not a feature. Replace with isextendmember? */ Setattr(n, "feature:extend", "1"); mark_nodes_as_extend(firstChild(n)); } } /* Line 268 of yacc.c */ #line 1348 "y.tab.c" /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE # define YYTOKEN_TABLE 0 #endif /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { ID = 258, HBLOCK = 259, POUND = 260, STRING = 261, WSTRING = 262, INCLUDE = 263, IMPORT = 264, INSERT = 265, CHARCONST = 266, WCHARCONST = 267, NUM_INT = 268, NUM_FLOAT = 269, NUM_UNSIGNED = 270, NUM_LONG = 271, NUM_ULONG = 272, NUM_LONGLONG = 273, NUM_ULONGLONG = 274, NUM_BOOL = 275, TYPEDEF = 276, TYPE_INT = 277, TYPE_UNSIGNED = 278, TYPE_SHORT = 279, TYPE_LONG = 280, TYPE_FLOAT = 281, TYPE_DOUBLE = 282, TYPE_CHAR = 283, TYPE_WCHAR = 284, TYPE_VOID = 285, TYPE_SIGNED = 286, TYPE_BOOL = 287, TYPE_COMPLEX = 288, TYPE_TYPEDEF = 289, TYPE_RAW = 290, TYPE_NON_ISO_INT8 = 291, TYPE_NON_ISO_INT16 = 292, TYPE_NON_ISO_INT32 = 293, TYPE_NON_ISO_INT64 = 294, LPAREN = 295, RPAREN = 296, COMMA = 297, SEMI = 298, EXTERN = 299, INIT = 300, LBRACE = 301, RBRACE = 302, PERIOD = 303, CONST_QUAL = 304, VOLATILE = 305, REGISTER = 306, STRUCT = 307, UNION = 308, EQUAL = 309, SIZEOF = 310, MODULE = 311, LBRACKET = 312, RBRACKET = 313, BEGINFILE = 314, ENDOFFILE = 315, ILLEGAL = 316, CONSTANT = 317, NAME = 318, RENAME = 319, NAMEWARN = 320, EXTEND = 321, PRAGMA = 322, FEATURE = 323, VARARGS = 324, ENUM = 325, CLASS = 326, TYPENAME = 327, PRIVATE = 328, PUBLIC = 329, PROTECTED = 330, COLON = 331, STATIC = 332, VIRTUAL = 333, FRIEND = 334, THROW = 335, CATCH = 336, EXPLICIT = 337, STATIC_ASSERT = 338, CONSTEXPR = 339, THREAD_LOCAL = 340, DECLTYPE = 341, AUTO = 342, NOEXCEPT = 343, OVERRIDE = 344, FINAL = 345, USING = 346, NAMESPACE = 347, NATIVE = 348, INLINE = 349, TYPEMAP = 350, EXCEPT = 351, ECHO = 352, APPLY = 353, CLEAR = 354, SWIGTEMPLATE = 355, FRAGMENT = 356, WARN = 357, LESSTHAN = 358, GREATERTHAN = 359, DELETE_KW = 360, DEFAULT = 361, LESSTHANOREQUALTO = 362, GREATERTHANOREQUALTO = 363, EQUALTO = 364, NOTEQUALTO = 365, ARROW = 366, QUESTIONMARK = 367, TYPES = 368, PARMS = 369, NONID = 370, DSTAR = 371, DCNOT = 372, TEMPLATE = 373, OPERATOR = 374, COPERATOR = 375, PARSETYPE = 376, PARSEPARM = 377, PARSEPARMS = 378, CAST = 379, LOR = 380, LAND = 381, OR = 382, XOR = 383, AND = 384, RSHIFT = 385, LSHIFT = 386, MINUS = 387, PLUS = 388, MODULO = 389, SLASH = 390, STAR = 391, LNOT = 392, NOT = 393, UMINUS = 394, DCOLON = 395 }; #endif /* Tokens. */ #define ID 258 #define HBLOCK 259 #define POUND 260 #define STRING 261 #define WSTRING 262 #define INCLUDE 263 #define IMPORT 264 #define INSERT 265 #define CHARCONST 266 #define WCHARCONST 267 #define NUM_INT 268 #define NUM_FLOAT 269 #define NUM_UNSIGNED 270 #define NUM_LONG 271 #define NUM_ULONG 272 #define NUM_LONGLONG 273 #define NUM_ULONGLONG 274 #define NUM_BOOL 275 #define TYPEDEF 276 #define TYPE_INT 277 #define TYPE_UNSIGNED 278 #define TYPE_SHORT 279 #define TYPE_LONG 280 #define TYPE_FLOAT 281 #define TYPE_DOUBLE 282 #define TYPE_CHAR 283 #define TYPE_WCHAR 284 #define TYPE_VOID 285 #define TYPE_SIGNED 286 #define TYPE_BOOL 287 #define TYPE_COMPLEX 288 #define TYPE_TYPEDEF 289 #define TYPE_RAW 290 #define TYPE_NON_ISO_INT8 291 #define TYPE_NON_ISO_INT16 292 #define TYPE_NON_ISO_INT32 293 #define TYPE_NON_ISO_INT64 294 #define LPAREN 295 #define RPAREN 296 #define COMMA 297 #define SEMI 298 #define EXTERN 299 #define INIT 300 #define LBRACE 301 #define RBRACE 302 #define PERIOD 303 #define CONST_QUAL 304 #define VOLATILE 305 #define REGISTER 306 #define STRUCT 307 #define UNION 308 #define EQUAL 309 #define SIZEOF 310 #define MODULE 311 #define LBRACKET 312 #define RBRACKET 313 #define BEGINFILE 314 #define ENDOFFILE 315 #define ILLEGAL 316 #define CONSTANT 317 #define NAME 318 #define RENAME 319 #define NAMEWARN 320 #define EXTEND 321 #define PRAGMA 322 #define FEATURE 323 #define VARARGS 324 #define ENUM 325 #define CLASS 326 #define TYPENAME 327 #define PRIVATE 328 #define PUBLIC 329 #define PROTECTED 330 #define COLON 331 #define STATIC 332 #define VIRTUAL 333 #define FRIEND 334 #define THROW 335 #define CATCH 336 #define EXPLICIT 337 #define STATIC_ASSERT 338 #define CONSTEXPR 339 #define THREAD_LOCAL 340 #define DECLTYPE 341 #define AUTO 342 #define NOEXCEPT 343 #define OVERRIDE 344 #define FINAL 345 #define USING 346 #define NAMESPACE 347 #define NATIVE 348 #define INLINE 349 #define TYPEMAP 350 #define EXCEPT 351 #define ECHO 352 #define APPLY 353 #define CLEAR 354 #define SWIGTEMPLATE 355 #define FRAGMENT 356 #define WARN 357 #define LESSTHAN 358 #define GREATERTHAN 359 #define DELETE_KW 360 #define DEFAULT 361 #define LESSTHANOREQUALTO 362 #define GREATERTHANOREQUALTO 363 #define EQUALTO 364 #define NOTEQUALTO 365 #define ARROW 366 #define QUESTIONMARK 367 #define TYPES 368 #define PARMS 369 #define NONID 370 #define DSTAR 371 #define DCNOT 372 #define TEMPLATE 373 #define OPERATOR 374 #define COPERATOR 375 #define PARSETYPE 376 #define PARSEPARM 377 #define PARSEPARMS 378 #define CAST 379 #define LOR 380 #define LAND 381 #define OR 382 #define XOR 383 #define AND 384 #define RSHIFT 385 #define LSHIFT 386 #define MINUS 387 #define PLUS 388 #define MODULO 389 #define SLASH 390 #define STAR 391 #define LNOT 392 #define NOT 393 #define UMINUS 394 #define DCOLON 395 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { /* Line 293 of yacc.c */ #line 1298 "parser.y" char *id; List *bases; struct Define { String *val; String *rawval; int type; String *qualifier; String *bitfield; Parm *throws; String *throwf; String *nexcept; } dtype; struct { const char *type; String *filename; int line; } loc; struct { char *id; SwigType *type; String *defarg; ParmList *parms; short have_parms; ParmList *throws; String *throwf; String *nexcept; } decl; Parm *tparms; struct { String *method; Hash *kwargs; } tmap; struct { String *type; String *us; } ptype; SwigType *type; String *str; Parm *p; ParmList *pl; int intvalue; Node *node; /* Line 293 of yacc.c */ #line 1711 "y.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif /* Copy the second part of user declarations. */ /* Line 343 of yacc.c */ #line 1723 "y.tab.c" #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #elif (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ # define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(e) ((void) (e)) #else # define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int YYID (int yyi) #else static int YYID (yyi) int yyi; #endif { return yyi; } #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0)) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (YYID (0)) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 61 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 5166 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 141 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 167 /* YYNRULES -- Number of rules. */ #define YYNRULES 568 /* YYNRULES -- Number of states. */ #define YYNSTATES 1113 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 395 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint16 yyprhs[] = { 0, 0, 3, 5, 9, 12, 16, 19, 25, 29, 32, 34, 36, 38, 40, 42, 44, 46, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 92, 100, 106, 110, 116, 122, 126, 129, 132, 138, 141, 147, 150, 155, 157, 159, 167, 175, 181, 182, 190, 192, 194, 197, 200, 202, 208, 214, 220, 224, 229, 233, 241, 250, 256, 260, 262, 264, 268, 270, 275, 283, 290, 292, 294, 302, 312, 321, 332, 338, 346, 353, 362, 364, 366, 372, 377, 383, 391, 393, 397, 404, 411, 420, 422, 425, 429, 431, 434, 438, 445, 451, 461, 464, 466, 468, 470, 471, 478, 480, 484, 493, 499, 507, 509, 514, 516, 518, 521, 524, 528, 530, 532, 534, 537, 539, 541, 543, 555, 569, 577, 579, 581, 583, 584, 588, 590, 593, 596, 599, 601, 607, 616, 627, 634, 636, 638, 640, 642, 644, 646, 647, 657, 658, 667, 669, 673, 678, 679, 686, 690, 695, 697, 699, 701, 703, 705, 707, 709, 711, 714, 716, 718, 720, 724, 726, 730, 735, 736, 743, 744, 750, 756, 759, 760, 761, 769, 771, 773, 774, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 825, 832, 840, 849, 858, 867, 877, 885, 891, 894, 897, 900, 903, 905, 907, 909, 911, 913, 915, 917, 919, 921, 923, 925, 928, 933, 936, 939, 944, 947, 953, 955, 957, 959, 962, 964, 966, 968, 971, 975, 977, 979, 981, 983, 985, 987, 990, 992, 995, 998, 1001, 1004, 1006, 1008, 1011, 1013, 1017, 1019, 1022, 1030, 1034, 1036, 1039, 1041, 1045, 1047, 1049, 1051, 1054, 1060, 1063, 1066, 1068, 1071, 1074, 1076, 1078, 1080, 1082, 1085, 1089, 1093, 1095, 1098, 1101, 1105, 1110, 1116, 1121, 1127, 1134, 1141, 1146, 1152, 1158, 1165, 1173, 1182, 1191, 1199, 1207, 1209, 1212, 1216, 1221, 1227, 1231, 1236, 1241, 1243, 1246, 1251, 1256, 1261, 1267, 1271, 1276, 1281, 1287, 1289, 1292, 1295, 1298, 1302, 1306, 1308, 1311, 1314, 1316, 1318, 1321, 1325, 1330, 1334, 1339, 1342, 1346, 1350, 1355, 1359, 1363, 1366, 1369, 1371, 1373, 1376, 1378, 1380, 1382, 1384, 1387, 1389, 1392, 1396, 1398, 1400, 1402, 1405, 1408, 1410, 1412, 1415, 1417, 1422, 1424, 1426, 1429, 1431, 1433, 1435, 1437, 1439, 1441, 1443, 1445, 1447, 1449, 1451, 1453, 1455, 1457, 1458, 1461, 1463, 1465, 1467, 1469, 1471, 1473, 1475, 1477, 1479, 1485, 1489, 1493, 1495, 1497, 1501, 1503, 1505, 1507, 1509, 1511, 1517, 1526, 1528, 1530, 1532, 1534, 1538, 1543, 1549, 1555, 1561, 1568, 1575, 1578, 1581, 1584, 1586, 1588, 1590, 1592, 1594, 1596, 1598, 1600, 1604, 1608, 1612, 1616, 1620, 1624, 1628, 1632, 1636, 1640, 1644, 1648, 1652, 1656, 1660, 1664, 1670, 1673, 1676, 1679, 1682, 1685, 1689, 1691, 1693, 1695, 1696, 1700, 1702, 1704, 1708, 1709, 1714, 1715, 1722, 1724, 1726, 1728, 1730, 1732, 1737, 1742, 1744, 1746, 1748, 1750, 1752, 1754, 1756, 1759, 1762, 1767, 1769, 1771, 1774, 1779, 1781, 1783, 1786, 1788, 1792, 1796, 1801, 1806, 1810, 1815, 1818, 1820, 1822, 1826, 1831, 1838, 1841, 1844, 1848, 1850, 1852, 1854, 1856, 1858, 1860, 1862, 1864, 1866, 1869, 1874, 1876, 1880, 1882, 1886, 1890, 1893, 1896, 1899, 1902, 1905, 1910, 1912, 1916, 1918, 1922, 1926, 1929, 1932, 1935, 1938, 1940, 1943, 1945, 1947, 1949, 1951, 1955, 1957, 1961, 1967, 1969, 1973, 1977, 1983, 1985, 1987 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { 142, 0, -1, 143, -1, 121, 235, 43, -1, 121, 1, -1, 122, 235, 43, -1, 122, 1, -1, 123, 40, 232, 41, 43, -1, 123, 1, 43, -1, 143, 144, -1, 307, -1, 145, -1, 182, -1, 198, -1, 43, -1, 1, -1, 197, -1, 1, 120, -1, 146, -1, 148, -1, 149, -1, 150, -1, 151, -1, 152, -1, 155, -1, 156, -1, 159, -1, 160, -1, 161, -1, 162, -1, 163, -1, 164, -1, 167, -1, 169, -1, 172, -1, 174, -1, 179, -1, 180, -1, 181, -1, -1, 66, 304, 296, 46, 147, 215, 47, -1, 98, 178, 46, 176, 47, -1, 99, 176, 43, -1, 62, 293, 54, 258, 43, -1, 62, 251, 243, 240, 43, -1, 62, 1, 43, -1, 97, 4, -1, 97, 301, -1, 96, 40, 293, 41, 46, -1, 96, 46, -1, 96, 40, 293, 41, 43, -1, 96, 43, -1, 301, 46, 235, 47, -1, 301, -1, 153, -1, 101, 40, 154, 42, 305, 41, 4, -1, 101, 40, 154, 42, 305, 41, 46, -1, 101, 40, 154, 41, 43, -1, -1, 158, 304, 301, 59, 157, 143, 60, -1, 8, -1, 9, -1, 94, 4, -1, 94, 46, -1, 4, -1, 10, 40, 294, 41, 301, -1, 10, 40, 294, 41, 4, -1, 10, 40, 294, 41, 46, -1, 56, 304, 294, -1, 63, 40, 294, 41, -1, 63, 40, 41, -1, 93, 40, 293, 41, 231, 293, 43, -1, 93, 40, 293, 41, 231, 251, 243, 43, -1, 67, 166, 293, 54, 165, -1, 67, 166, 293, -1, 301, -1, 4, -1, 40, 293, 41, -1, 307, -1, 168, 243, 294, 43, -1, 168, 40, 305, 41, 243, 287, 43, -1, 168, 40, 305, 41, 301, 43, -1, 64, -1, 65, -1, 68, 40, 294, 41, 243, 287, 170, -1, 68, 40, 294, 42, 306, 41, 243, 287, 43, -1, 68, 40, 294, 171, 41, 243, 287, 170, -1, 68, 40, 294, 42, 306, 171, 41, 243, 287, 43, -1, 68, 40, 294, 41, 170, -1, 68, 40, 294, 42, 306, 41, 43, -1, 68, 40, 294, 171, 41, 170, -1, 68, 40, 294, 42, 306, 171, 41, 43, -1, 303, -1, 43, -1, 114, 40, 232, 41, 43, -1, 42, 294, 54, 306, -1, 42, 294, 54, 306, 171, -1, 69, 40, 173, 41, 243, 287, 43, -1, 232, -1, 13, 42, 235, -1, 95, 40, 175, 41, 176, 303, -1, 95, 40, 175, 41, 176, 43, -1, 95, 40, 175, 41, 176, 54, 178, 43, -1, 305, -1, 178, 177, -1, 42, 178, 177, -1, 307, -1, 251, 242, -1, 40, 232, 41, -1, 40, 232, 41, 40, 232, 41, -1, 113, 40, 232, 41, 170, -1, 100, 40, 295, 41, 299, 103, 236, 104, 43, -1, 102, 301, -1, 184, -1, 196, -1, 195, -1, -1, 44, 301, 46, 183, 143, 47, -1, 188, -1, 91, 296, 54, -1, 118, 103, 207, 104, 91, 296, 54, 293, -1, 231, 251, 243, 186, 185, -1, 231, 87, 243, 111, 187, 186, 185, -1, 43, -1, 42, 243, 186, 185, -1, 46, -1, 240, -1, 249, 240, -1, 286, 240, -1, 249, 286, 240, -1, 255, -1, 32, -1, 30, -1, 34, 292, -1, 35, -1, 296, -1, 254, -1, 231, 87, 296, 54, 189, 40, 232, 41, 287, 190, 191, -1, 231, 87, 296, 54, 189, 40, 232, 41, 287, 111, 251, 190, 191, -1, 231, 87, 296, 54, 189, 190, 191, -1, 57, -1, 46, -1, 43, -1, -1, 40, 192, 43, -1, 70, -1, 70, 71, -1, 70, 52, -1, 76, 253, -1, 307, -1, 231, 193, 263, 194, 43, -1, 231, 193, 263, 194, 46, 265, 47, 43, -1, 231, 193, 263, 194, 46, 265, 47, 243, 186, 185, -1, 231, 251, 40, 232, 41, 288, -1, 199, -1, 203, -1, 204, -1, 211, -1, 212, -1, 223, -1, -1, 231, 283, 296, 274, 46, 200, 215, 47, 202, -1, -1, 231, 283, 274, 46, 201, 215, 47, 202, -1, 43, -1, 243, 186, 185, -1, 231, 283, 296, 43, -1, -1, 118, 103, 207, 104, 205, 206, -1, 118, 283, 296, -1, 44, 118, 283, 296, -1, 184, -1, 199, -1, 220, -1, 224, -1, 204, -1, 203, -1, 222, -1, 208, -1, 209, 210, -1, 307, -1, 282, -1, 235, -1, 42, 209, 210, -1, 307, -1, 91, 296, 43, -1, 91, 92, 296, 43, -1, -1, 92, 296, 46, 213, 143, 47, -1, -1, 92, 46, 214, 143, 47, -1, 92, 293, 54, 296, 43, -1, 219, 215, -1, -1, -1, 66, 46, 216, 215, 47, 217, 215, -1, 156, -1, 307, -1, -1, 1, 218, 215, -1, 182, -1, 220, -1, 221, -1, 224, -1, 225, -1, 226, -1, 222, -1, 203, -1, 199, -1, 231, 296, 43, -1, 211, -1, 204, -1, 223, -1, 180, -1, 181, -1, 229, -1, 155, -1, 179, -1, 43, -1, 231, 251, 40, 232, 41, 288, -1, 138, 298, 40, 232, 41, 227, -1, 78, 138, 298, 40, 232, 41, 228, -1, 231, 120, 251, 248, 40, 232, 41, 228, -1, 231, 120, 251, 129, 40, 232, 41, 228, -1, 231, 120, 251, 126, 40, 232, 41, 228, -1, 231, 120, 251, 248, 129, 40, 232, 41, 228, -1, 231, 120, 251, 40, 232, 41, 228, -1, 81, 40, 232, 41, 46, -1, 83, 40, -1, 74, 76, -1, 73, 76, -1, 75, 76, -1, 164, -1, 150, -1, 162, -1, 167, -1, 169, -1, 172, -1, 160, -1, 174, -1, 148, -1, 149, -1, 151, -1, 287, 43, -1, 287, 54, 260, 43, -1, 287, 46, -1, 287, 43, -1, 287, 54, 258, 43, -1, 287, 46, -1, 231, 230, 76, 268, 43, -1, 255, -1, 32, -1, 30, -1, 34, 292, -1, 35, -1, 296, -1, 44, -1, 44, 301, -1, 44, 301, 85, -1, 77, -1, 21, -1, 78, -1, 79, -1, 82, -1, 84, -1, 77, 84, -1, 85, -1, 85, 77, -1, 77, 85, -1, 44, 85, -1, 85, 44, -1, 307, -1, 233, -1, 235, 234, -1, 307, -1, 42, 235, 234, -1, 307, -1, 252, 241, -1, 118, 103, 283, 104, 283, 296, 240, -1, 48, 48, 48, -1, 237, -1, 239, 238, -1, 307, -1, 42, 239, 238, -1, 307, -1, 235, -1, 269, -1, 54, 258, -1, 54, 258, 57, 268, 58, -1, 54, 46, -1, 76, 268, -1, 307, -1, 243, 240, -1, 246, 240, -1, 240, -1, 243, -1, 246, -1, 307, -1, 248, 244, -1, 248, 129, 244, -1, 248, 126, 244, -1, 245, -1, 129, 244, -1, 126, 244, -1, 296, 116, 244, -1, 248, 296, 116, 244, -1, 248, 296, 116, 129, 244, -1, 296, 116, 129, 244, -1, 248, 48, 48, 48, 244, -1, 248, 129, 48, 48, 48, 244, -1, 248, 126, 48, 48, 48, 244, -1, 48, 48, 48, 245, -1, 129, 48, 48, 48, 244, -1, 126, 48, 48, 48, 244, -1, 296, 116, 48, 48, 48, 244, -1, 248, 296, 116, 48, 48, 48, 244, -1, 248, 296, 116, 129, 48, 48, 48, 244, -1, 248, 296, 116, 126, 48, 48, 48, 244, -1, 296, 116, 129, 48, 48, 48, 244, -1, 296, 116, 126, 48, 48, 48, 244, -1, 296, -1, 138, 296, -1, 40, 296, 41, -1, 40, 248, 244, 41, -1, 40, 296, 116, 244, 41, -1, 244, 57, 58, -1, 244, 57, 268, 58, -1, 244, 40, 232, 41, -1, 296, -1, 138, 296, -1, 40, 248, 245, 41, -1, 40, 129, 245, 41, -1, 40, 126, 245, 41, -1, 40, 296, 116, 245, 41, -1, 245, 57, 58, -1, 245, 57, 268, 58, -1, 245, 40, 232, 41, -1, 119, 3, 40, 232, 41, -1, 248, -1, 248, 247, -1, 248, 129, -1, 248, 126, -1, 248, 129, 247, -1, 248, 126, 247, -1, 247, -1, 129, 247, -1, 126, 247, -1, 129, -1, 126, -1, 296, 116, -1, 248, 296, 116, -1, 248, 296, 116, 247, -1, 247, 57, 58, -1, 247, 57, 268, 58, -1, 57, 58, -1, 57, 268, 58, -1, 40, 246, 41, -1, 247, 40, 232, 41, -1, 40, 232, 41, -1, 136, 249, 248, -1, 136, 248, -1, 136, 249, -1, 136, -1, 250, -1, 250, 249, -1, 49, -1, 50, -1, 51, -1, 252, -1, 249, 253, -1, 253, -1, 253, 249, -1, 249, 253, 249, -1, 255, -1, 32, -1, 30, -1, 34, 292, -1, 193, 296, -1, 35, -1, 296, -1, 283, 296, -1, 254, -1, 86, 40, 296, 41, -1, 256, -1, 257, -1, 257, 256, -1, 22, -1, 24, -1, 25, -1, 28, -1, 29, -1, 26, -1, 27, -1, 31, -1, 23, -1, 33, -1, 36, -1, 37, -1, 38, -1, 39, -1, -1, 259, 268, -1, 260, -1, 261, -1, 262, -1, 105, -1, 106, -1, 293, -1, 307, -1, 150, -1, 307, -1, 265, 42, 264, 266, 264, -1, 265, 42, 264, -1, 264, 266, 264, -1, 264, -1, 293, -1, 293, 54, 267, -1, 268, -1, 269, -1, 251, -1, 270, -1, 301, -1, 55, 40, 251, 241, 41, -1, 55, 48, 48, 48, 40, 251, 241, 41, -1, 271, -1, 302, -1, 11, -1, 12, -1, 40, 268, 41, -1, 40, 268, 41, 268, -1, 40, 268, 248, 41, 268, -1, 40, 268, 129, 41, 268, -1, 40, 268, 126, 41, 268, -1, 40, 268, 248, 129, 41, 268, -1, 40, 268, 248, 126, 41, 268, -1, 129, 268, -1, 126, 268, -1, 136, 268, -1, 13, -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, -1, 19, -1, 20, -1, 268, 133, 268, -1, 268, 132, 268, -1, 268, 136, 268, -1, 268, 135, 268, -1, 268, 134, 268, -1, 268, 129, 268, -1, 268, 127, 268, -1, 268, 128, 268, -1, 268, 131, 268, -1, 268, 130, 268, -1, 268, 126, 268, -1, 268, 125, 268, -1, 268, 109, 268, -1, 268, 110, 268, -1, 268, 108, 268, -1, 268, 107, 268, -1, 268, 112, 268, 76, 268, -1, 132, 268, -1, 133, 268, -1, 138, 268, -1, 137, 268, -1, 251, 40, -1, 48, 48, 48, -1, 272, -1, 307, -1, 275, -1, -1, 76, 276, 277, -1, 307, -1, 278, -1, 277, 42, 278, -1, -1, 284, 279, 296, 273, -1, -1, 284, 281, 280, 284, 296, 273, -1, 74, -1, 73, -1, 75, -1, 71, -1, 72, -1, 71, 48, 48, 48, -1, 72, 48, 48, 48, -1, 282, -1, 52, -1, 53, -1, 78, -1, 307, -1, 89, -1, 90, -1, 90, 89, -1, 89, 90, -1, 80, 40, 232, 41, -1, 88, -1, 285, -1, 88, 285, -1, 88, 40, 268, 41, -1, 249, -1, 286, -1, 249, 286, -1, 307, -1, 287, 289, 43, -1, 287, 289, 46, -1, 40, 232, 41, 43, -1, 40, 232, 41, 46, -1, 54, 258, 43, -1, 286, 54, 260, 43, -1, 76, 290, -1, 307, -1, 291, -1, 290, 42, 291, -1, 291, 48, 48, 48, -1, 290, 42, 291, 48, 48, 48, -1, 296, 40, -1, 296, 46, -1, 103, 236, 104, -1, 307, -1, 3, -1, 89, -1, 90, -1, 293, -1, 260, -1, 301, -1, 294, -1, 307, -1, 298, 297, -1, 115, 140, 298, 297, -1, 298, -1, 115, 140, 298, -1, 119, -1, 115, 140, 119, -1, 140, 298, 297, -1, 140, 298, -1, 140, 119, -1, 117, 298, -1, 293, 292, -1, 293, 300, -1, 115, 140, 293, 300, -1, 293, -1, 115, 140, 293, -1, 119, -1, 115, 140, 119, -1, 140, 293, 300, -1, 140, 293, -1, 140, 119, -1, 117, 293, -1, 301, 6, -1, 6, -1, 302, 7, -1, 7, -1, 301, -1, 46, -1, 4, -1, 40, 305, 41, -1, 307, -1, 294, 54, 306, -1, 294, 54, 306, 42, 305, -1, 294, -1, 294, 42, 305, -1, 294, 54, 153, -1, 294, 54, 153, 42, 305, -1, 301, -1, 270, -1, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 1463, 1463, 1475, 1479, 1482, 1485, 1488, 1491, 1496, 1501, 1506, 1507, 1508, 1509, 1510, 1516, 1532, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1569, 1569, 1651, 1661, 1672, 1693, 1715, 1726, 1735, 1754, 1760, 1766, 1771, 1778, 1785, 1789, 1802, 1811, 1826, 1839, 1839, 1894, 1895, 1902, 1921, 1952, 1956, 1966, 1971, 1989, 2032, 2038, 2051, 2057, 2083, 2089, 2096, 2097, 2100, 2101, 2108, 2154, 2200, 2211, 2214, 2241, 2247, 2253, 2259, 2267, 2273, 2279, 2285, 2293, 2294, 2295, 2298, 2303, 2313, 2349, 2350, 2385, 2402, 2410, 2423, 2448, 2454, 2458, 2461, 2472, 2477, 2490, 2502, 2788, 2798, 2805, 2806, 2810, 2810, 2835, 2841, 2852, 2868, 2928, 2986, 2990, 3013, 3019, 3026, 3033, 3040, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3066, 3071, 3076, 3083, 3089, 3094, 3097, 3097, 3110, 3113, 3116, 3125, 3128, 3135, 3157, 3186, 3284, 3336, 3337, 3338, 3339, 3340, 3341, 3346, 3346, 3585, 3585, 3730, 3731, 3743, 3761, 3761, 4018, 4024, 4030, 4033, 4036, 4039, 4042, 4045, 4048, 4053, 4089, 4093, 4096, 4099, 4104, 4108, 4113, 4123, 4154, 4154, 4183, 4183, 4205, 4232, 4249, 4254, 4249, 4262, 4263, 4264, 4264, 4280, 4281, 4298, 4299, 4300, 4301, 4302, 4303, 4304, 4305, 4306, 4307, 4308, 4309, 4310, 4311, 4312, 4313, 4314, 4323, 4351, 4378, 4409, 4424, 4441, 4459, 4478, 4497, 4504, 4511, 4518, 4526, 4534, 4537, 4541, 4544, 4545, 4546, 4547, 4548, 4549, 4550, 4551, 4554, 4561, 4568, 4577, 4586, 4595, 4607, 4610, 4613, 4614, 4615, 4616, 4618, 4627, 4628, 4638, 4648, 4649, 4650, 4651, 4652, 4653, 4654, 4655, 4656, 4657, 4658, 4659, 4660, 4667, 4678, 4682, 4685, 4689, 4693, 4703, 4711, 4719, 4732, 4736, 4739, 4743, 4747, 4775, 4783, 4795, 4810, 4820, 4829, 4840, 4844, 4848, 4855, 4872, 4889, 4897, 4905, 4914, 4923, 4927, 4936, 4947, 4958, 4970, 4980, 4994, 5002, 5011, 5020, 5024, 5033, 5044, 5055, 5067, 5077, 5087, 5098, 5111, 5118, 5126, 5142, 5150, 5161, 5172, 5183, 5202, 5210, 5227, 5235, 5242, 5249, 5260, 5271, 5282, 5302, 5323, 5329, 5335, 5342, 5349, 5358, 5367, 5370, 5379, 5388, 5395, 5402, 5409, 5419, 5430, 5441, 5452, 5459, 5466, 5469, 5486, 5496, 5503, 5509, 5514, 5520, 5524, 5530, 5531, 5532, 5538, 5544, 5548, 5549, 5553, 5560, 5563, 5564, 5565, 5566, 5567, 5569, 5572, 5575, 5580, 5591, 5616, 5619, 5673, 5677, 5681, 5685, 5689, 5693, 5697, 5701, 5705, 5709, 5713, 5717, 5721, 5725, 5731, 5731, 5745, 5761, 5764, 5770, 5783, 5797, 5798, 5801, 5802, 5806, 5812, 5815, 5819, 5824, 5832, 5844, 5859, 5860, 5879, 5880, 5884, 5889, 5894, 5895, 5900, 5913, 5928, 5935, 5952, 5959, 5966, 5973, 5981, 5989, 5993, 5997, 6003, 6004, 6005, 6006, 6007, 6008, 6009, 6010, 6013, 6017, 6021, 6025, 6029, 6033, 6037, 6041, 6045, 6049, 6053, 6057, 6061, 6065, 6079, 6083, 6087, 6093, 6097, 6101, 6105, 6109, 6125, 6130, 6133, 6138, 6143, 6143, 6144, 6147, 6164, 6173, 6173, 6191, 6191, 6209, 6210, 6211, 6215, 6219, 6223, 6227, 6233, 6236, 6240, 6246, 6247, 6250, 6253, 6256, 6259, 6264, 6269, 6274, 6279, 6284, 6291, 6297, 6301, 6305, 6313, 6321, 6329, 6338, 6347, 6354, 6363, 6364, 6367, 6368, 6369, 6370, 6373, 6385, 6391, 6397, 6401, 6402, 6403, 6406, 6407, 6408, 6411, 6412, 6415, 6420, 6424, 6427, 6430, 6433, 6438, 6442, 6445, 6452, 6458, 6467, 6472, 6476, 6479, 6482, 6485, 6490, 6494, 6497, 6500, 6506, 6511, 6514, 6526, 6529, 6532, 6536, 6541, 6554, 6558, 6563, 6569, 6573, 6578, 6582, 6589, 6592, 6597 }; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "ID", "HBLOCK", "POUND", "STRING", "WSTRING", "INCLUDE", "IMPORT", "INSERT", "CHARCONST", "WCHARCONST", "NUM_INT", "NUM_FLOAT", "NUM_UNSIGNED", "NUM_LONG", "NUM_ULONG", "NUM_LONGLONG", "NUM_ULONGLONG", "NUM_BOOL", "TYPEDEF", "TYPE_INT", "TYPE_UNSIGNED", "TYPE_SHORT", "TYPE_LONG", "TYPE_FLOAT", "TYPE_DOUBLE", "TYPE_CHAR", "TYPE_WCHAR", "TYPE_VOID", "TYPE_SIGNED", "TYPE_BOOL", "TYPE_COMPLEX", "TYPE_TYPEDEF", "TYPE_RAW", "TYPE_NON_ISO_INT8", "TYPE_NON_ISO_INT16", "TYPE_NON_ISO_INT32", "TYPE_NON_ISO_INT64", "LPAREN", "RPAREN", "COMMA", "SEMI", "EXTERN", "INIT", "LBRACE", "RBRACE", "PERIOD", "CONST_QUAL", "VOLATILE", "REGISTER", "STRUCT", "UNION", "EQUAL", "SIZEOF", "MODULE", "LBRACKET", "RBRACKET", "BEGINFILE", "ENDOFFILE", "ILLEGAL", "CONSTANT", "NAME", "RENAME", "NAMEWARN", "EXTEND", "PRAGMA", "FEATURE", "VARARGS", "ENUM", "CLASS", "TYPENAME", "PRIVATE", "PUBLIC", "PROTECTED", "COLON", "STATIC", "VIRTUAL", "FRIEND", "THROW", "CATCH", "EXPLICIT", "STATIC_ASSERT", "CONSTEXPR", "THREAD_LOCAL", "DECLTYPE", "AUTO", "NOEXCEPT", "OVERRIDE", "FINAL", "USING", "NAMESPACE", "NATIVE", "INLINE", "TYPEMAP", "EXCEPT", "ECHO", "APPLY", "CLEAR", "SWIGTEMPLATE", "FRAGMENT", "WARN", "LESSTHAN", "GREATERTHAN", "DELETE_KW", "DEFAULT", "LESSTHANOREQUALTO", "GREATERTHANOREQUALTO", "EQUALTO", "NOTEQUALTO", "ARROW", "QUESTIONMARK", "TYPES", "PARMS", "NONID", "DSTAR", "DCNOT", "TEMPLATE", "OPERATOR", "COPERATOR", "PARSETYPE", "PARSEPARM", "PARSEPARMS", "CAST", "LOR", "LAND", "OR", "XOR", "AND", "RSHIFT", "LSHIFT", "MINUS", "PLUS", "MODULO", "SLASH", "STAR", "LNOT", "NOT", "UMINUS", "DCOLON", "$accept", "program", "interface", "declaration", "swig_directive", "extend_directive", "$@1", "apply_directive", "clear_directive", "constant_directive", "echo_directive", "except_directive", "stringtype", "fname", "fragment_directive", "include_directive", "$@2", "includetype", "inline_directive", "insert_directive", "module_directive", "name_directive", "native_directive", "pragma_directive", "pragma_arg", "pragma_lang", "rename_directive", "rename_namewarn", "feature_directive", "stringbracesemi", "featattr", "varargs_directive", "varargs_parms", "typemap_directive", "typemap_type", "tm_list", "tm_tail", "typemap_parm", "types_directive", "template_directive", "warn_directive", "c_declaration", "$@3", "c_decl", "c_decl_tail", "initializer", "cpp_alternate_rettype", "cpp_lambda_decl", "lambda_introducer", "lambda_body", "lambda_tail", "$@4", "c_enum_key", "c_enum_inherit", "c_enum_forward_decl", "c_enum_decl", "c_constructor_decl", "cpp_declaration", "cpp_class_decl", "@5", "@6", "cpp_opt_declarators", "cpp_forward_class_decl", "cpp_template_decl", "$@7", "cpp_temp_possible", "template_parms", "templateparameters", "templateparameter", "templateparameterstail", "cpp_using_decl", "cpp_namespace_decl", "$@8", "$@9", "cpp_members", "$@10", "$@11", "$@12", "cpp_member", "cpp_constructor_decl", "cpp_destructor_decl", "cpp_conversion_operator", "cpp_catch_decl", "cpp_static_assert", "cpp_protection_decl", "cpp_swig_directive", "cpp_end", "cpp_vend", "anonymous_bitfield", "anon_bitfield_type", "storage_class", "parms", "rawparms", "ptail", "parm", "valparms", "rawvalparms", "valptail", "valparm", "def_args", "parameter_declarator", "typemap_parameter_declarator", "declarator", "notso_direct_declarator", "direct_declarator", "abstract_declarator", "direct_abstract_declarator", "pointer", "type_qualifier", "type_qualifier_raw", "type", "rawtype", "type_right", "decltype", "primitive_type", "primitive_type_list", "type_specifier", "definetype", "$@13", "default_delete", "deleted_definition", "explicit_default", "ename", "optional_constant_directive", "enumlist", "edecl", "etype", "expr", "valexpr", "exprnum", "exprcompound", "ellipsis", "variadic", "inherit", "raw_inherit", "$@14", "base_list", "base_specifier", "@15", "@16", "access_specifier", "templcpptype", "cpptype", "opt_virtual", "virt_specifier_seq", "exception_specification", "cpp_const", "ctor_end", "ctor_initializer", "mem_initializer_list", "mem_initializer", "template_decl", "identifier", "idstring", "idstringopt", "idcolon", "idcolontail", "idtemplate", "idcolonnt", "idcolontailnt", "string", "wstring", "stringbrace", "options", "kwargs", "stringnum", "empty", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { 0, 141, 142, 142, 142, 142, 142, 142, 142, 143, 143, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 147, 146, 148, 149, 150, 150, 150, 151, 151, 152, 152, 152, 152, 153, 154, 154, 155, 155, 155, 157, 156, 158, 158, 159, 159, 160, 160, 160, 160, 161, 162, 162, 163, 163, 164, 164, 165, 165, 166, 166, 167, 167, 167, 168, 168, 169, 169, 169, 169, 169, 169, 169, 169, 170, 170, 170, 171, 171, 172, 173, 173, 174, 174, 174, 175, 176, 177, 177, 178, 178, 178, 179, 180, 181, 182, 182, 182, 183, 182, 182, 182, 182, 184, 184, 185, 185, 185, 186, 186, 186, 186, 187, 187, 187, 187, 187, 187, 187, 188, 188, 188, 189, 190, 191, 192, 191, 193, 193, 193, 194, 194, 195, 196, 196, 197, 198, 198, 198, 198, 198, 198, 200, 199, 201, 199, 202, 202, 203, 205, 204, 204, 204, 206, 206, 206, 206, 206, 206, 206, 207, 208, 208, 209, 209, 210, 210, 211, 211, 213, 212, 214, 212, 212, 215, 216, 217, 215, 215, 215, 218, 215, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 220, 221, 221, 222, 222, 222, 222, 222, 223, 224, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 228, 228, 228, 229, 230, 230, 230, 230, 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 232, 233, 233, 234, 234, 235, 235, 235, 236, 237, 237, 238, 238, 239, 239, 240, 240, 240, 240, 240, 241, 241, 241, 242, 242, 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 244, 244, 244, 244, 244, 244, 244, 244, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 247, 247, 247, 247, 247, 247, 247, 248, 248, 248, 248, 249, 249, 250, 250, 250, 251, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, 253, 253, 253, 254, 255, 256, 256, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 259, 258, 258, 260, 260, 261, 262, 263, 263, 264, 264, 265, 265, 265, 265, 266, 266, 267, 268, 268, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 270, 270, 270, 270, 270, 270, 270, 270, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 272, 273, 273, 274, 276, 275, 275, 277, 277, 279, 278, 280, 278, 281, 281, 281, 282, 282, 282, 282, 283, 283, 283, 284, 284, 285, 285, 285, 285, 286, 286, 286, 286, 286, 287, 287, 287, 287, 288, 288, 288, 288, 288, 288, 289, 289, 290, 290, 290, 290, 291, 291, 292, 292, 293, 293, 293, 294, 294, 294, 295, 295, 296, 296, 296, 296, 296, 296, 297, 297, 297, 297, 298, 299, 299, 299, 299, 299, 299, 300, 300, 300, 300, 301, 301, 302, 302, 303, 303, 303, 304, 304, 305, 305, 305, 305, 305, 305, 306, 306, 307 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 3, 2, 3, 2, 5, 3, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 7, 5, 3, 5, 5, 3, 2, 2, 5, 2, 5, 2, 4, 1, 1, 7, 7, 5, 0, 7, 1, 1, 2, 2, 1, 5, 5, 5, 3, 4, 3, 7, 8, 5, 3, 1, 1, 3, 1, 4, 7, 6, 1, 1, 7, 9, 8, 10, 5, 7, 6, 8, 1, 1, 5, 4, 5, 7, 1, 3, 6, 6, 8, 1, 2, 3, 1, 2, 3, 6, 5, 9, 2, 1, 1, 1, 0, 6, 1, 3, 8, 5, 7, 1, 4, 1, 1, 2, 2, 3, 1, 1, 1, 2, 1, 1, 1, 11, 13, 7, 1, 1, 1, 0, 3, 1, 2, 2, 2, 1, 5, 8, 10, 6, 1, 1, 1, 1, 1, 1, 0, 9, 0, 8, 1, 3, 4, 0, 6, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 3, 4, 0, 6, 0, 5, 5, 2, 0, 0, 7, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 6, 7, 8, 8, 8, 9, 7, 5, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 4, 2, 5, 1, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 1, 3, 1, 2, 7, 3, 1, 2, 1, 3, 1, 1, 1, 2, 5, 2, 2, 1, 2, 2, 1, 1, 1, 1, 2, 3, 3, 1, 2, 2, 3, 4, 5, 4, 5, 6, 6, 4, 5, 5, 6, 7, 8, 8, 7, 7, 1, 2, 3, 4, 5, 3, 4, 4, 1, 2, 4, 4, 4, 5, 3, 4, 4, 5, 1, 2, 2, 2, 3, 3, 1, 2, 2, 1, 1, 2, 3, 4, 3, 4, 2, 3, 3, 4, 3, 3, 2, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 3, 1, 1, 1, 2, 2, 1, 1, 2, 1, 4, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 3, 3, 1, 1, 3, 1, 1, 1, 1, 1, 5, 8, 1, 1, 1, 1, 3, 4, 5, 5, 5, 6, 6, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 2, 2, 2, 2, 2, 3, 1, 1, 1, 0, 3, 1, 1, 3, 0, 4, 0, 6, 1, 1, 1, 1, 1, 4, 4, 1, 1, 1, 1, 1, 1, 1, 2, 2, 4, 1, 1, 2, 4, 1, 1, 2, 1, 3, 3, 4, 4, 3, 4, 2, 1, 1, 3, 4, 6, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 1, 3, 1, 3, 3, 2, 2, 2, 2, 2, 4, 1, 3, 1, 3, 3, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 3, 1, 3, 5, 1, 3, 3, 5, 1, 1, 0 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. Performed when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint16 yydefact[] = { 568, 0, 0, 0, 0, 0, 10, 4, 522, 386, 394, 387, 388, 391, 392, 389, 390, 375, 393, 374, 395, 568, 378, 396, 397, 398, 399, 0, 365, 366, 367, 489, 490, 145, 484, 485, 0, 523, 524, 0, 0, 534, 0, 0, 0, 363, 568, 370, 381, 373, 383, 384, 488, 0, 568, 379, 532, 6, 0, 0, 568, 1, 15, 64, 60, 61, 0, 260, 14, 256, 568, 0, 0, 82, 83, 568, 568, 0, 0, 259, 261, 262, 0, 263, 264, 266, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11, 18, 19, 20, 21, 22, 23, 24, 25, 568, 26, 27, 28, 29, 30, 31, 32, 0, 33, 34, 35, 36, 37, 38, 12, 113, 118, 115, 114, 16, 13, 154, 155, 156, 157, 158, 159, 0, 271, 568, 376, 521, 0, 147, 146, 0, 0, 0, 0, 0, 377, 3, 369, 364, 568, 0, 400, 0, 0, 534, 348, 347, 362, 0, 294, 277, 568, 301, 568, 344, 338, 328, 291, 371, 385, 380, 540, 0, 0, 530, 5, 8, 0, 272, 568, 274, 17, 0, 552, 269, 0, 257, 0, 0, 559, 0, 0, 368, 568, 0, 0, 0, 0, 78, 0, 568, 265, 268, 568, 270, 267, 0, 0, 189, 568, 0, 0, 62, 63, 0, 0, 51, 49, 46, 47, 568, 0, 568, 0, 568, 568, 0, 112, 568, 568, 0, 0, 0, 0, 0, 0, 0, 328, 0, 568, 0, 568, 554, 426, 427, 438, 439, 440, 441, 442, 443, 444, 445, 0, 0, 0, 0, 0, 0, 0, 0, 0, 285, 0, 280, 568, 419, 368, 0, 418, 420, 424, 421, 425, 282, 279, 0, 0, 0, 535, 533, 0, 372, 568, 348, 347, 0, 0, 338, 379, 0, 289, 405, 406, 287, 0, 402, 403, 404, 354, 0, 418, 290, 0, 568, 0, 0, 303, 346, 320, 0, 302, 345, 360, 361, 329, 292, 568, 0, 293, 568, 0, 0, 341, 340, 298, 339, 320, 349, 539, 538, 537, 0, 0, 273, 276, 526, 525, 0, 527, 0, 551, 116, 258, 562, 0, 68, 45, 0, 568, 400, 70, 0, 0, 0, 74, 0, 0, 0, 98, 0, 0, 185, 119, 568, 0, 187, 0, 0, 103, 0, 0, 0, 107, 295, 296, 297, 42, 0, 104, 106, 528, 0, 529, 54, 0, 53, 0, 0, 178, 568, 182, 488, 180, 169, 0, 0, 0, 0, 525, 0, 0, 0, 0, 0, 0, 320, 0, 0, 328, 568, 568, 408, 568, 568, 472, 0, 471, 380, 474, 0, 0, 0, 436, 435, 463, 464, 437, 466, 465, 520, 0, 281, 284, 467, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 553, 486, 487, 382, 531, 0, 348, 347, 338, 379, 0, 328, 0, 358, 356, 341, 340, 0, 328, 349, 0, 0, 401, 355, 568, 338, 379, 0, 321, 568, 0, 0, 359, 0, 334, 0, 0, 352, 0, 0, 0, 300, 343, 0, 299, 342, 350, 0, 0, 0, 304, 536, 7, 568, 0, 170, 568, 0, 0, 558, 0, 0, 69, 39, 77, 0, 0, 0, 0, 0, 0, 0, 186, 0, 0, 568, 568, 0, 0, 108, 0, 568, 0, 0, 0, 0, 0, 167, 0, 179, 184, 58, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 149, 0, 379, 0, 498, 493, 494, 0, 126, 568, 499, 568, 568, 162, 166, 0, 428, 0, 0, 362, 0, 568, 0, 568, 461, 460, 458, 459, 0, 457, 456, 452, 453, 451, 455, 454, 447, 446, 450, 449, 448, 0, 0, 349, 332, 331, 330, 350, 0, 311, 0, 0, 0, 320, 322, 349, 0, 0, 325, 0, 0, 336, 335, 357, 353, 0, 0, 0, 0, 0, 0, 305, 351, 0, 0, 0, 307, 275, 66, 67, 65, 0, 563, 564, 567, 566, 560, 44, 43, 0, 76, 73, 75, 557, 93, 556, 0, 88, 568, 555, 92, 0, 566, 0, 0, 99, 568, 227, 190, 191, 0, 256, 0, 0, 50, 48, 568, 41, 105, 0, 545, 543, 0, 57, 0, 0, 110, 0, 568, 568, 568, 568, 0, 0, 132, 131, 568, 134, 568, 136, 130, 135, 140, 0, 148, 150, 568, 568, 568, 0, 500, 496, 495, 0, 123, 125, 121, 127, 568, 128, 491, 473, 475, 477, 492, 0, 160, 429, 0, 0, 362, 361, 0, 0, 0, 0, 0, 283, 0, 568, 333, 288, 337, 323, 0, 313, 327, 326, 312, 308, 0, 0, 0, 0, 0, 306, 0, 0, 0, 117, 0, 0, 198, 218, 0, 0, 0, 0, 261, 0, 0, 240, 241, 233, 242, 216, 196, 238, 234, 232, 235, 236, 237, 239, 217, 213, 214, 200, 208, 207, 211, 210, 0, 0, 201, 202, 206, 212, 203, 204, 205, 215, 0, 271, 568, 502, 503, 0, 505, 0, 0, 0, 0, 90, 568, 0, 188, 257, 0, 568, 101, 0, 100, 0, 0, 0, 0, 541, 568, 0, 52, 0, 256, 0, 171, 172, 176, 175, 168, 173, 177, 174, 0, 183, 0, 0, 81, 133, 0, 568, 141, 0, 409, 414, 0, 410, 568, 400, 503, 568, 153, 0, 0, 568, 129, 568, 482, 481, 483, 0, 479, 0, 0, 432, 431, 430, 0, 0, 422, 0, 462, 278, 324, 310, 309, 0, 0, 0, 314, 0, 0, 565, 561, 0, 193, 230, 229, 231, 0, 228, 0, 40, 192, 375, 374, 568, 378, 0, 0, 0, 373, 379, 0, 504, 84, 566, 95, 89, 568, 0, 0, 97, 0, 71, 0, 109, 546, 544, 550, 549, 548, 0, 55, 56, 0, 568, 0, 59, 80, 122, 0, 143, 142, 139, 568, 415, 568, 0, 0, 0, 0, 0, 0, 513, 497, 501, 0, 476, 568, 568, 0, 0, 434, 433, 568, 315, 0, 0, 319, 318, 199, 0, 0, 568, 376, 0, 0, 568, 209, 0, 96, 0, 91, 568, 86, 72, 102, 542, 547, 0, 120, 0, 568, 0, 413, 0, 412, 151, 568, 0, 510, 0, 512, 514, 0, 506, 507, 124, 0, 469, 478, 470, 0, 164, 163, 568, 0, 0, 317, 316, 0, 568, 0, 568, 0, 0, 0, 0, 0, 94, 85, 0, 111, 167, 0, 144, 416, 417, 568, 0, 508, 509, 511, 0, 0, 518, 519, 0, 568, 0, 161, 423, 194, 0, 568, 0, 568, 568, 568, 0, 249, 568, 87, 0, 0, 411, 152, 515, 0, 468, 480, 165, 0, 568, 220, 0, 568, 0, 0, 0, 568, 219, 0, 137, 0, 516, 195, 221, 0, 243, 245, 0, 226, 568, 568, 568, 0, 0, 0, 246, 248, 400, 0, 224, 223, 222, 568, 138, 517, 0, 244, 225, 247 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 4, 5, 100, 101, 102, 649, 771, 772, 773, 774, 107, 390, 391, 775, 776, 690, 110, 111, 777, 113, 778, 115, 779, 651, 203, 780, 118, 781, 657, 526, 782, 364, 783, 374, 229, 385, 230, 784, 785, 786, 787, 514, 126, 716, 567, 698, 127, 703, 851, 943, 993, 42, 559, 128, 129, 130, 131, 788, 872, 725, 1014, 789, 790, 688, 838, 394, 395, 396, 547, 791, 136, 533, 370, 792, 971, 1072, 893, 793, 794, 795, 796, 797, 798, 799, 800, 1074, 1087, 801, 908, 802, 292, 184, 340, 185, 269, 270, 438, 271, 568, 166, 379, 167, 313, 168, 169, 170, 242, 44, 45, 272, 198, 47, 48, 49, 50, 51, 300, 301, 342, 303, 304, 416, 853, 854, 944, 1036, 274, 307, 276, 277, 1009, 1010, 422, 423, 572, 721, 722, 869, 959, 870, 52, 53, 723, 570, 806, 1088, 860, 952, 1002, 1003, 177, 54, 350, 388, 55, 180, 56, 682, 827, 278, 279, 660, 194, 351, 646, 186 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -957 static const yytype_int16 yypact[] = { 686, 4260, 4332, 196, 66, 3750, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -68, -957, -957, -957, -957, -957, 25, -957, -957, -957, -957, -957, 330, 122, 126, 182, -957, -957, -18, 110, -957, 97, 222, 4977, 811, 763, 811, -957, -957, -957, 2891, -957, 97, -68, -957, 2, -957, 237, 247, 4694, -957, 185, -957, -957, -957, 271, -957, -957, 47, 297, 4404, 337, -957, -957, 297, 399, 466, 468, 382, -957, -957, 489, -957, -957, 252, 272, 407, 496, 257, 498, 547, 114, 4765, 4765, 506, 515, 562, 533, 180, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, 297, -957, -957, -957, -957, -957, -957, -957, 988, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, 4836, -957, 2182, -957, -957, 502, -957, -957, 532, 534, 97, 120, 420, -957, -957, 811, -957, 3374, 552, 313, 2310, 3078, 444, 1257, 3245, 452, 97, -957, -957, 312, 381, 312, 383, 1254, 500, -957, -957, -957, -957, -957, 151, 173, -957, -957, -957, 550, -957, 576, -957, -957, 471, -957, -957, 420, 52, 471, 471, -957, 581, 1660, -957, 154, 1029, 97, 151, 151, -957, 471, 4622, -957, -957, 4694, -957, -957, 97, 332, -957, 195, 583, 151, -957, -957, 471, 151, -957, -957, -957, 624, 4694, 591, 264, 607, 627, 471, 562, 624, 4694, 4694, 97, 562, 1461, 1314, 1390, 471, 477, 559, 1660, 97, 1810, 135, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, 3078, 363, 3078, 3078, 3078, 3078, 3078, 3078, 3078, -957, 568, -957, 653, 665, 394, 2406, 23, -957, -957, 624, 712, -957, -957, 673, 676, 687, -957, 2, 636, -957, 3491, 198, 198, 700, 704, 1695, 631, 707, -957, -957, -957, 705, 3078, -957, -957, -957, -957, 4408, -957, 2406, 724, 3491, 719, 97, 401, 383, -957, 720, 401, 383, -957, 638, -957, -957, 4694, 2438, -957, 4694, 2566, 728, 3251, 3257, 401, 383, 668, 1844, -957, -957, 2, 743, 4694, -957, -957, -957, -957, 748, 624, 97, -957, -957, -957, 331, 751, -957, -957, 654, 312, 499, -957, 757, 754, 764, 762, 614, 776, 783, -957, 784, 794, -957, -957, -957, 97, -957, 786, 797, -957, 799, 801, 4765, -957, -957, -957, -957, -957, 4765, -957, -957, -957, 804, -957, -957, 637, 55, 806, 744, -957, 809, -957, 74, -957, -957, 200, 261, 261, 261, 346, 742, 826, 60, 834, 2264, 2392, 752, 1844, 768, 31, 805, 349, -957, 3563, 1634, -957, 838, -957, 53, -957, 2149, 4907, 837, 3027, 2156, -957, -957, -957, -957, -957, -957, 2182, -957, -957, -957, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, 3078, -957, -957, -957, -957, -957, 420, 484, 484, 1157, 771, 372, -957, 464, -957, -957, 484, 484, 487, 774, 261, 261, 3078, 2406, -957, 4694, 1866, 19, 852, -957, 4694, 2694, 858, -957, 876, -957, 4769, 881, -957, 4856, 879, 880, 401, 383, 883, 401, 383, 1823, 888, 890, 2520, 401, -957, -957, 576, 296, -957, -957, 471, 2025, -957, 886, 896, -957, -957, -957, 403, 1252, 2006, 901, 4694, 1660, 878, -957, 3852, 902, -957, 825, 4765, 389, 909, 904, 627, 279, 911, 471, 4694, 63, 864, 4694, -957, -957, -957, 261, 220, 851, 43, -957, 1879, 5047, 903, 4977, 436, -957, 921, 742, 923, 189, 884, 887, 745, -957, 556, -957, 312, 908, -957, -957, 922, 3078, 2822, 2950, 3206, -1, 763, 931, 653, 699, 699, 889, 889, 2279, 2661, 3027, 3220, 2669, 2156, 780, 780, 739, 739, -957, -957, -957, 97, 774, -957, -957, -957, -957, 484, 508, 381, 4981, 946, 544, 774, -957, 851, 851, 947, -957, 4993, 851, -957, -957, -957, -957, 851, 942, 953, 959, 960, 2648, 401, 383, 961, 962, 963, 401, -957, -957, -957, 624, 3954, -957, 952, -957, 55, 970, -957, -957, 2054, -957, -957, 624, -957, -957, -957, 973, -957, 1100, 624, -957, 976, 49, 693, 1252, -957, 1100, -957, -957, -957, 4056, 46, 4907, 400, -957, -957, 4694, -957, -957, 874, -957, 78, 913, -957, 993, 992, -957, 97, 1061, 809, -957, 1100, 287, 851, -957, -957, -68, -957, 1634, -957, -957, -957, -957, 441, -957, -957, 955, 1360, 4694, 3078, -957, -957, -957, 1660, -957, -957, -957, -957, 312, -957, -957, 998, -957, 821, -957, 2054, -957, 2406, 3078, 3078, 3206, 3633, 3078, 1000, 1001, 1002, 1005, -957, 3078, 312, -957, -957, -957, -957, 554, 401, -957, -957, 401, 401, 851, 851, 999, 1003, 1007, 401, 851, 1008, 1009, -957, 471, 471, -957, -957, 1012, 977, 983, 984, 924, 1006, 151, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, -957, 1016, 2054, -957, -957, -957, -957, -957, -957, -957, -957, 4475, 1022, 4694, 733, -957, 63, -957, 2025, 1151, 471, 1034, -957, 1100, 1028, -957, 83, 1660, 141, -957, 4765, -957, 1038, 255, 151, 375, -957, 2182, 270, -957, 995, 47, 404, -957, -957, -957, -957, -957, -957, -957, -957, 4547, -957, 4158, 1041, -957, -957, 745, 4694, -957, 475, -957, 151, 510, -957, 4694, 499, 1031, 1010, -957, 1046, 2771, 1634, -957, 908, -957, -957, -957, 97, -957, 1044, 2054, 2406, 2406, 2406, 3078, 3078, -957, 4907, 2534, -957, -957, 401, 401, 851, 1049, 1050, 401, 851, 851, -957, -957, 2054, -957, -957, -957, -957, 151, -957, 1052, -957, -957, 1024, 1025, -68, 1026, 4907, 1033, 1828, 1036, 265, 1063, -957, -957, 624, 1068, -957, 1100, 1372, 63, -957, 1070, -957, 1072, -957, -957, 78, -957, -957, 78, 1017, -957, -957, 151, 4694, 1660, -957, -957, -957, 1082, -957, -957, -957, 955, 1071, 955, 1489, 1091, 1090, 499, 97, 543, -957, -957, -957, 745, -957, 1088, 908, 1617, 1095, 2406, 2406, 763, 401, 851, 851, 401, 401, -957, 2054, 1097, 4694, 1076, 64, 3078, 3563, -957, 1105, -957, 1110, -957, 1100, -957, -957, -957, -957, -957, 1113, -957, 1058, 1100, 1124, -957, 3078, 151, -957, 1634, 592, -957, 1125, 1128, 1123, 470, -957, -957, -957, 1129, -957, -957, -957, 97, -957, -957, 1634, 1617, 1131, 401, 401, 1126, 4694, 1135, 4694, 1138, 1142, -17, 2899, 1144, -957, -957, 1150, -957, -957, 4, -957, -957, 2406, 955, 745, -957, -957, -957, 97, 1139, -957, -957, 1148, 1088, 745, -957, -957, -957, 1154, 1100, 1159, 4694, 4694, 4694, 1163, -957, 1360, -957, 4907, 475, -957, -957, 1156, 1158, -957, -957, -957, 2054, 1100, -957, 588, 1100, 1164, 1166, 1170, 4694, -957, 1169, -957, 1168, -957, -957, -957, 605, -957, -957, 499, -957, 1100, 1100, 1100, 1176, 475, 1172, -957, -957, 499, 1178, -957, -957, -957, 1100, -957, -957, 1182, -957, -957, -957 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -957, -957, -350, -957, -957, -957, -957, 32, 39, 6, 44, -957, 711, -957, 67, 76, -957, -957, -957, 81, -957, 82, -957, 86, -957, -957, 88, -957, 89, -531, -635, 90, -957, 112, -957, -331, 689, -85, 129, 131, 134, 136, -957, 545, -812, -672, -957, -957, -957, -956, -683, -957, -119, -957, -957, -957, -957, -957, 12, -957, -957, 216, 22, 27, -957, -957, 299, -957, 690, 548, 140, -957, -957, -957, -701, -957, -957, -957, -957, 551, -957, 555, 156, 557, -957, -957, -957, -467, -957, -957, 11, -54, -957, 727, 13, 414, -957, 661, 814, -7, -580, -957, -39, 1147, -183, -107, -5, 18, 35, -957, -64, 8, -11, 696, -525, 1203, -957, -338, -957, -154, -957, -957, -957, -887, -957, 263, -957, 1192, -115, -482, -957, -957, 215, 840, -957, -957, -957, 409, -957, -957, -957, -231, -48, 310, 714, -375, -561, 214, -957, -957, 236, -19, 981, -117, -957, 919, -224, -137, -957, -266, 1030, -957, 608, 209, -182, -503, 0 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -569 static const yytype_int16 yytable[] = { 6, 735, 141, 302, 398, 139, 183, 197, 227, 46, 46, 105, 286, 686, 43, 58, 138, 132, 519, 245, 531, 142, 663, 1058, 871, 275, 848, 133, 812, 228, 228, 700, 134, 153, 644, 140, 939, 103, 375, 165, 732, 335, 337, 644, 104, 571, 173, 538, 293, 106, 850, 236, 189, 189, 142, 347, 407, 994, 347, 996, 614, 347, 462, 8, 171, -286, 61, 653, 46, 189, 195, 344, 108, 143, 246, 195, 204, 352, 1064, 241, 154, 109, 174, 358, 614, 557, 112, 114, 362, 347, 247, 116, 902, 117, 119, 120, 574, 807, 348, -568, 8, 543, 287, -527, 1023, 815, 654, 468, 470, 655, 195, 475, 1059, 509, 387, 1063, -181, 121, 224, 178, 189, 381, 149, 8, 409, 733, 1097, -286, 734, 421, 845, 190, 190, 813, 122, 615, 123, 349, 8, 124, 280, 125, 179, 346, 1007, 135, 859, 413, 273, 37, 38, 1065, 365, 268, 8, 366, 314, 318, 355, 693, 322, 137, 325, 46, 641, 191, 332, 173, 349, 173, 146, 961, 377, 294, 147, 39, 8, 656, -181, 41, 393, 319, 293, 670, 923, 341, 37, 38, 288, 380, 1024, 956, 970, 1025, 718, 825, 163, 59, 320, 142, 163, 8, 302, 293, 673, 414, 347, 420, 356, 37, 38, 421, 39, 150, 46, 142, 41, 46, 826, 468, 470, 475, 148, 8, 37, 38, 189, 1066, 382, 709, 386, 389, 31, 32, 46, 399, 60, 1071, 155, 285, 37, 38, 46, 46, 140, 418, 171, 425, 397, 371, 39, 34, 35, 920, 41, 158, 404, 140, 8, 549, 354, 218, 37, 38, 8, 152, 165, 8, 156, 491, 1020, 439, 494, 173, 932, 8, 914, 910, 565, 566, 181, 980, 8, 235, 201, 314, 318, 37, 38, 332, 182, 171, 336, 347, 608, 609, 210, 46, 140, 539, 638, 354, 189, 219, 155, 187, 916, 466, 978, 37, 38, 188, 156, 39, 228, 398, 933, 160, 46, 237, 228, 158, 275, 571, 500, 503, 1039, 644, 483, 211, 846, 46, 858, 642, 46, 39, 164, 193, 490, 160, 844, -255, 639, 1049, 37, 38, 239, 46, 518, 240, 37, 38, 511, 37, 38, 173, 163, 981, 164, 297, 684, 37, 38, 581, 212, 561, 157, 608, 37, 38, 6, 1086, 404, 515, 926, 368, 39, 200, 8, 39, 160, 1083, 144, 160, 1017, 516, 369, 39, 159, 984, 161, 41, -407, 162, 679, -407, 548, 8, 680, 164, 163, 145, 164, 427, 653, 142, 189, 650, 661, 189, 8, 428, 323, 604, 1107, 601, 560, 142, 298, 299, 173, 323, 1031, 326, 425, -407, 552, 46, 611, 324, 913, 1034, 674, 617, 155, 675, -568, 404, 324, 202, 327, 487, 156, 820, 580, 273, 655, 309, 157, 140, 268, 158, 140, 214, 821, 569, 31, 32, 488, 314, 318, 332, -568, -568, 37, 38, 207, 208, 500, 503, 159, 228, 31, 32, 8, 34, 35, 189, 332, 705, 8, 849, 706, 37, 38, 658, -568, 850, 571, 666, 46, 34, 35, 1075, 929, 46, 37, 38, -568, 632, 859, 28, 29, 30, 323, 605, 205, 935, 206, 39, 1045, 341, 691, 160, 6, 941, 1046, 408, 942, 949, 161, 324, 39, 162, 289, 328, 41, 323, 606, 209, 163, 139, 164, 6, 139, 46, 217, 105, 220, 386, 665, 158, 138, 132, 324, 672, 231, 704, 323, 740, 281, 46, 946, 133, 46, 232, 685, 947, 134, 397, 37, 38, 717, 103, 719, 324, 37, 38, 189, 173, 104, 173, 724, 234, 165, 106, 298, 299, 891, 892, 282, 173, 283, 439, 487, 743, 1005, 221, 163, 1006, 222, 338, 39, 223, 487, 882, 41, 319, 108, 171, 296, 488, 632, 410, 298, 299, 411, 109, 818, 1092, 157, 488, 112, 114, 731, 312, 334, 116, 339, 117, 119, 120, 823, 571, 353, 814, 1103, 1104, 1105, 372, 347, 1089, 159, 900, 1090, 1040, 563, 378, 1041, 1111, 571, 139, 1091, 121, 564, 565, 566, 105, 1099, 803, 383, 1100, 138, 132, 861, 524, 525, 8, 808, 1101, 122, 987, 123, 133, 988, 124, 808, 125, 134, 384, 139, 135, 436, 103, 863, 413, 105, 847, 541, 542, 104, 138, 132, 245, 46, 106, 858, 137, 139, 548, 6, 808, 133, 805, 661, 437, 142, 134, 173, 842, 835, 805, 103, 302, 398, 440, 855, 808, 108, 104, 836, 864, 852, 275, 106, 837, 46, 109, 173, 458, 153, 459, 112, 114, 460, 803, 805, 116, 461, 117, 119, 120, 881, 569, 810, 811, 924, 108, 909, 173, 463, 471, 805, 37, 38, 472, 109, 477, 319, 490, 912, 112, 114, 121, 247, 478, 116, 228, 117, 119, 120, 972, 479, 1109, 482, 731, 8, 485, 489, 39, 122, 918, 123, 41, 163, 124, 497, 125, 909, 922, 402, 135, 121, 403, 504, 236, 510, 713, 714, 512, 163, 715, 517, 803, 247, 940, 1001, 137, 520, 122, 521, 123, 948, 155, 124, 522, 125, 1, 2, 3, 135, 156, 46, 563, 808, 964, 523, 157, 527, 142, 158, 564, 565, 566, 528, 529, 137, 534, 280, 451, 452, 453, 454, 455, 456, 457, 273, 530, 535, 159, 536, 268, 537, 975, 139, 540, 67, 544, 545, 805, 105, 546, 37, 38, 8, 138, 132, 46, 550, 953, 28, 29, 30, 173, 46, 724, 133, 551, 555, 671, 420, 134, 803, 455, 456, 457, 103, 554, 39, 556, 983, 558, 160, 104, 573, 582, 974, 603, 106, 161, 607, 408, 162, 803, 866, 867, 868, 414, 569, 163, 616, 164, 79, 80, 81, 142, 620, 83, 998, 84, 85, 108, 453, 454, 455, 456, 457, 621, 808, 1022, 109, 1015, 623, 1028, 667, 112, 114, 625, 626, 647, 116, 627, 117, 119, 120, 399, 633, 1102, 634, 648, 37, 38, 664, 46, 855, 669, 855, 302, 397, 676, 852, 677, 852, 805, 683, 687, 121, 165, 1011, 724, 702, 151, 707, 708, 173, 172, 39, 1053, 726, 1055, 41, 803, 176, 122, 711, 123, 712, 1015, 124, 736, 125, 46, 171, 808, 135, 46, 720, 742, 746, 312, 750, 8, 808, 1026, 760, 404, 441, 442, 173, 1082, 137, 751, 1077, 1078, 1079, 213, 216, 752, 753, 756, 757, 758, 761, 804, 824, 173, 828, 71, 805, 451, 452, 453, 454, 455, 456, 457, 1096, 805, 238, 46, 809, 46, 8, 569, 829, 189, 156, 243, 855, 830, 865, 876, 877, 878, 852, 879, 899, 885, 1011, 934, 569, 886, 199, 895, 808, 887, 889, 890, 894, 896, 897, 808, 898, 901, 46, 46, 46, 284, 215, -197, 357, 921, 803, 808, 295, 919, 808, 37, 38, 925, 315, 315, 67, 321, 938, 950, 951, 954, 46, 805, 333, 960, 973, 808, 808, 808, 805, 966, 967, 192, -252, -251, -254, 39, 979, 832, 808, 160, 805, 976, 811, 805, -250, 985, 239, 986, 243, 240, 37, 38, 359, 989, 225, 992, 163, 995, 164, 233, 805, 805, 805, 367, 999, 1000, 298, 299, 1008, 1021, 79, 80, 81, 805, 1016, 83, 769, 84, 85, 172, 1029, 28, 29, 30, -253, 1030, 8, 400, 1032, 406, 315, 315, 8, 412, 1033, 415, 151, 243, 424, 1035, 1042, 343, 1043, 1044, 1051, 1052, 343, 343, 1054, 1047, 1056, 833, 563, 343, 1057, 360, 361, 1061, 343, 1068, 564, 565, 566, 354, 172, 1062, 917, 1073, 1069, 289, 373, 156, 1076, 343, 376, 1080, 1084, 1093, 1085, 1094, 467, 469, 469, 1095, 343, 476, 158, 850, 1098, 1106, 345, 405, 1108, 1110, 343, 345, 345, 1112, 417, 643, 678, 484, 345, 486, 1050, 834, 991, 345, 689, 843, 637, 839, 37, 38, 931, 840, 737, 841, 37, 38, 315, 315, 345, 583, 699, 315, 175, 8, 653, 8, 189, 1038, 8, 345, 392, 1070, 575, 513, 39, 401, 345, 1012, 160, 345, 39, 406, 957, 1081, 41, 239, 710, 1067, 240, 822, 0, 473, 0, 0, 474, 163, 0, 164, 532, 0, 354, 0, 310, 654, 0, 310, 655, 0, 156, 0, 328, 0, 0, 311, 0, 0, 0, 317, 0, 158, 0, 0, 158, 0, 0, 8, 331, 0, 0, 469, 469, 469, 0, 0, 0, 553, 0, 315, 315, 0, 315, 0, 0, 0, 0, 0, 562, 0, 0, 37, 38, 37, 38, 0, 37, 38, 0, 0, 306, 308, 0, 0, 408, 0, 0, 0, 0, 0, 0, 0, 311, 0, 0, 0, 656, 39, 0, 39, 0, 160, 39, 41, 0, 8, 41, 0, 239, 0, 329, 240, 0, 330, 0, 602, 0, 317, 163, 331, 164, 0, 312, 8, 0, 312, 469, 469, 0, 0, 856, 0, 613, 37, 38, 0, 0, 0, 0, 28, 29, 30, 354, 0, 857, 982, 0, 0, 0, 0, 156, 0, 0, 315, 0, 0, 315, 0, 0, 39, 408, 0, 0, 41, 0, 0, 0, 0, 316, 0, 563, 0, 0, 243, 0, 0, 0, 243, 564, 565, 566, 426, 312, 429, 430, 431, 432, 433, 434, 435, 0, 37, 38, 0, 8, 0, 0, 189, 0, 469, 243, 315, 0, 0, 315, 701, 499, 502, 0, 37, 38, 508, 0, 0, 0, 0, 0, 39, 0, 0, 0, 160, 8, 480, 0, 0, 343, 0, 239, 0, 172, 240, 0, 0, 0, 39, 343, 0, 163, 41, 164, 0, 0, 0, 0, 0, 493, 0, 0, 496, 739, 681, 0, 343, 0, 0, 0, 0, 312, 354, 0, 0, 997, 0, 315, 315, 0, 156, 0, 315, 0, 0, 640, 0, 315, 345, 645, 0, 0, 315, 37, 38, 0, 652, 659, 662, 0, 499, 502, 0, 508, 0, 0, 0, 0, 0, 298, 299, 0, 0, 0, 0, 345, 0, 659, 0, 39, 0, 37, 38, 41, 692, 0, 243, 0, 0, 0, 402, 0, 0, 403, 0, 0, 0, 0, 0, 0, 163, 0, 0, 0, 0, 0, 0, 39, 0, 831, 0, 160, 0, 0, 0, 315, 0, 0, 239, 0, 0, 240, 0, 8, 0, 0, 0, 0, 163, 0, 164, 0, 0, 612, 0, 243, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 0, 631, 0, 819, 636, 0, 0, 354, 0, 0, 1013, 0, 0, 8, 0, 156, 0, 0, 0, 315, 315, 610, 0, 0, 0, 315, 0, 0, 0, 0, 619, 0, 0, 28, 29, 30, 0, 0, 157, 0, 0, 0, 0, 0, 659, 0, 0, 0, 8, 612, 354, 817, 631, 659, 0, 0, 37, 38, 156, 0, 159, 0, 0, 0, 563, 0, 0, 0, 0, 0, 0, 911, 564, 565, 566, 0, 0, 0, 0, 243, 0, 0, 39, 0, 0, 155, 160, 243, 0, 0, 0, 343, 343, 239, 0, 0, 240, 0, 0, 37, 38, 0, 158, 163, 0, 164, 0, 0, 0, 0, 0, 0, 744, 745, 0, 0, 0, 748, 727, 590, 593, 600, 749, 0, 0, 39, 0, 755, 0, 160, 0, 0, 0, 0, 37, 38, 239, 0, 958, 240, 345, 345, 343, 0, 0, 0, 163, 0, 164, 0, 0, 0, 0, 0, 315, 927, 928, 930, 315, 315, 39, 0, 0, 8, 160, 0, 0, 0, 0, 0, 0, 473, 0, 0, 474, 0, 8, 0, 243, 0, 0, 8, 0, 164, 945, 0, 0, 659, 243, 915, 744, 345, 0, 0, 0, 0, 0, 8, 0, 0, 419, 0, 0, 0, 0, 243, 0, 0, 156, 0, 0, 0, 817, 310, 0, 0, 243, 0, 977, 8, 1004, 628, 0, 0, 0, 0, 156, 0, 0, 243, 158, 0, 8, 172, 408, 315, 315, 0, 0, 0, 0, 0, 505, 0, 0, 0, 562, 883, 884, 37, 38, 862, 0, 888, 0, 0, 310, 0, 0, 0, 0, 0, 37, 38, 0, 990, 0, 37, 38, 408, 873, 874, 433, 158, 875, 39, 0, 628, 0, 160, 880, 1048, 0, 37, 38, 243, 239, 0, 39, 240, 0, 0, 41, 39, 0, 0, 163, 160, 164, 629, 659, 0, 630, 0, 239, 37, 38, 240, 0, 39, 0, 312, 1004, 41, 163, 0, 164, 0, 37, 38, 506, 0, 0, 507, 0, 0, 0, 945, 0, 0, 0, 39, 312, 0, 0, 41, 0, 0, 0, 0, 0, 0, 473, 0, 39, 474, 0, 0, 41, 0, 0, 0, 0, 0, 312, 629, 0, 0, 630, 8, 0, 0, 189, 0, 0, 0, 0, 312, 0, 251, 252, 253, 254, 255, 256, 257, 258, 0, 0, 0, 0, 189, 965, 0, 0, 0, 968, 969, 251, 252, 253, 254, 255, 256, 257, 258, 0, 0, 0, 0, 0, 0, 0, 0, 0, 762, 0, -568, 63, 0, 0, 0, 64, 65, 66, 0, 0, 0, 962, 963, 0, 0, 0, 0, 0, 67, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, 0, 37, 38, 763, 69, 0, 0, -568, 0, -568, -568, -568, -568, -568, 0, 0, 0, 298, 299, 1018, 1019, 0, 71, 72, 73, 74, 764, 76, 77, 78, -568, -568, -568, 765, 766, 767, 0, 79, 768, 81, 0, 82, 83, 769, 84, 85, -568, -568, 0, -568, -568, 86, 0, 0, 0, 90, 0, 92, 93, 94, 95, 96, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 1027, -568, 0, 0, 99, -568, -568, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 1037, 189, 248, 576, 0, 770, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 259, 0, 0, 0, 0, 0, 0, 0, 27, 28, 29, 30, 31, 32, 0, 260, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 441, 442, 443, 444, 0, 445, 0, 441, 442, 443, 444, 8, 36, 0, 0, 37, 38, 0, 446, 577, 448, 449, 578, 451, 452, 453, 454, 455, 456, 579, 451, 452, 453, 454, 455, 456, 457, 0, 0, 0, 0, 39, 0, 0, 40, 41, 0, 0, 408, 0, 0, 0, 261, 0, 0, 262, 498, 8, 263, 264, 189, 248, 265, 266, 267, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 259, 0, 0, 37, 38, 738, 0, 0, 0, 28, 29, 30, 31, 32, 0, 260, 0, 0, 305, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 33, 34, 35, 41, 0, 0, 441, 442, 443, 444, 0, 445, 0, 0, 0, 8, 36, 0, 0, 37, 38, 0, 312, 0, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 41, 0, 0, 408, 0, 0, 0, 261, 0, 0, 262, 501, 8, 263, 264, 189, 248, 265, 266, 267, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 259, 0, 0, 37, 38, 0, 0, 0, 0, 28, 29, 30, 31, 32, 0, 260, 0, 0, 492, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 33, 34, 35, 41, 0, 441, 442, 443, 444, 0, 445, 0, 0, 0, 0, 8, 36, 0, 0, 37, 38, 0, 312, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 41, 0, 0, 408, 0, 0, 0, 261, 0, 0, 262, 635, 8, 263, 264, 189, 248, 265, 266, 267, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 259, 0, 0, 37, 38, 0, 0, 0, 0, 28, 29, 30, 31, 32, 0, 260, 0, 0, 495, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 33, 34, 35, 41, 0, 441, 442, 443, 444, 0, 0, 0, 0, 0, 0, 8, 36, 0, 0, 37, 38, 0, 312, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 41, 0, 0, 408, 0, 0, 0, 261, 0, 0, 262, 754, 8, 263, 264, 189, 248, 265, 266, 267, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 259, 0, 0, 37, 38, 0, 0, 0, 0, 28, 29, 30, 31, 32, 0, 260, 0, 0, 618, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 33, 34, 35, 41, 441, 442, 443, 444, 0, 0, 0, 0, 441, 442, 443, 444, 36, 0, 0, 37, 38, 0, 312, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 450, 451, 452, 453, 454, 455, 456, 457, 0, 0, 0, 39, 0, 0, 955, 41, 0, 0, 0, 0, 0, 0, 261, 0, 0, 262, 0, 8, 263, 264, 189, 248, 265, 266, 267, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 259, 728, 0, 0, 0, 0, 0, 0, 0, 28, 29, 30, 31, 32, 0, 260, 441, 442, 443, 444, 0, 445, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 36, 0, 0, 37, 38, 9, 10, 11, 12, 13, 14, 15, 16, 0, 18, 0, 20, 0, 0, 23, 24, 25, 26, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 41, 1060, 0, 0, 0, 0, 0, 261, 0, 0, 262, 0, 8, 263, 264, 189, 248, 265, 266, 267, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 259, 729, 0, 0, 0, 0, 0, 0, 0, 28, 29, 30, 31, 32, 0, 260, 441, 442, 443, 444, 0, 445, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 36, 0, 0, 37, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 261, 0, 0, 262, 0, 8, 263, 264, 189, 248, 265, 266, 267, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 259, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 30, 31, 32, 0, 260, 441, 442, 443, 444, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 0, 0, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 36, 0, 0, 37, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 261, 0, 0, 262, 0, 8, 263, 264, 189, 248, 265, 266, 267, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 259, 0, 8, 0, 0, 0, 0, 0, 8, 28, 29, 30, 31, 32, 8, 260, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 0, 0, 0, 0, 0, 310, 0, 0, 0, 0, 0, 310, 36, 316, 0, 37, 38, 310, 0, 498, 0, 0, 158, 0, 0, 501, 0, 0, 158, 0, 0, 0, 0, 0, 158, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 41, 0, 441, 442, 443, 444, 0, 0, 0, 37, 38, 0, 0, 263, 264, 37, 38, 730, 266, 267, 0, 37, 38, 449, 450, 451, 452, 453, 454, 455, 456, 457, 0, 0, 0, 39, 0, 0, 0, 41, 0, 39, 0, 0, 0, 41, 0, 39, 0, 0, 0, 41, 8, 0, 0, 0, 0, 0, 312, 0, 0, 0, 0, 0, 312, 0, 0, 0, 0, 0, 312, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 289, 0, 0, 0, 0, 0, 0, 0, 27, 28, 29, 30, 31, 32, 0, 0, 0, 158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 40, 41, 8, 0, 0, 0, 0, 0, 290, 0, 0, 291, 0, 0, 0, 0, 0, 0, 163, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 289, 0, 0, 0, 0, 0, 0, 0, 27, 28, 29, 30, 31, 32, 0, 0, 0, 158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 39, 0, 0, 40, 41, 27, 28, 29, 30, 31, 32, 464, 0, 0, 465, 0, 0, 0, 0, 0, 0, 163, 0, 0, 0, 0, 0, 33, 34, 35, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 39, 0, 0, 40, 41, 0, 0, 31, 32, 0, 0, 402, 0, 0, 403, 0, 0, 0, 0, 0, 0, 163, 0, 0, 0, 33, 34, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, -2, 62, 41, -568, 63, 0, 0, 0, 64, 65, 66, 0, 0, 0, 0, 0, 0, 0, 0, 163, 0, 67, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, 0, 0, 0, 68, 69, 0, 0, 0, 0, -568, -568, -568, -568, -568, 0, 0, 70, 0, 0, 0, 0, 0, 71, 72, 73, 74, 75, 76, 77, 78, -568, -568, -568, 0, 0, 0, 0, 79, 80, 81, 0, 82, 83, 0, 84, 85, -568, -568, 0, -568, -568, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 62, 0, -568, 63, 0, 0, 0, 64, 65, 66, 98, 0, -568, 0, 0, 99, -568, 0, 0, 0, 67, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, 0, 0, 0, 68, 69, 0, 0, 668, 0, -568, -568, -568, -568, -568, 0, 0, 70, 0, 0, 0, 0, 0, 71, 72, 73, 74, 75, 76, 77, 78, -568, -568, -568, 0, 0, 0, 0, 79, 80, 81, 0, 82, 83, 0, 84, 85, -568, -568, 0, -568, -568, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 62, 0, -568, 63, 0, 0, 0, 64, 65, 66, 98, 0, -568, 0, 0, 99, -568, 0, 0, 0, 67, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, 0, 0, 0, 68, 69, 0, 0, 759, 0, -568, -568, -568, -568, -568, 0, 0, 70, 0, 0, 0, 0, 0, 71, 72, 73, 74, 75, 76, 77, 78, -568, -568, -568, 0, 0, 0, 0, 79, 80, 81, 0, 82, 83, 0, 84, 85, -568, -568, 0, -568, -568, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 62, 0, -568, 63, 0, 0, 0, 64, 65, 66, 98, 0, -568, 0, 0, 99, -568, 0, 0, 0, 67, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, 0, 0, 0, 68, 69, 0, 0, 816, 0, -568, -568, -568, -568, -568, 0, 0, 70, 0, 0, 0, 0, 0, 71, 72, 73, 74, 75, 76, 77, 78, -568, -568, -568, 0, 0, 0, 0, 79, 80, 81, 0, 82, 83, 0, 84, 85, -568, -568, 0, -568, -568, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 62, 0, -568, 63, 0, 0, 0, 64, 65, 66, 98, 0, -568, 0, 0, 99, -568, 0, 0, 0, 67, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, -568, 0, 0, 0, 68, 69, 0, 0, 0, 0, -568, -568, -568, -568, -568, 0, 0, 70, 0, 0, 0, 937, 0, 71, 72, 73, 74, 75, 76, 77, 78, -568, -568, -568, 0, 0, 0, 0, 79, 80, 81, 0, 82, 83, 0, 84, 85, -568, -568, 0, -568, -568, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 7, 0, 8, 0, 0, 0, 0, 0, 0, 0, 98, 0, -568, 0, 0, 99, -568, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 0, 0, 0, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 57, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 39, 0, 0, 40, 41, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 196, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 39, 0, 0, 40, 41, 0, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 481, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 903, 18, 904, 20, 905, 906, 23, 24, 25, 26, 441, 442, 443, 444, 39, 445, 0, 0, 41, 28, 29, 30, 31, 32, 0, 0, 0, 0, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 33, 34, 35, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 244, 0, 37, 38, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 39, 0, 0, 0, 41, 907, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 36, 936, 363, 37, 38, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 39, 0, 0, 0, 41, 907, 0, 0, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 39, 0, 0, 40, 41, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 226, 0, 0, 0, 39, 0, 0, 40, 41, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 622, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 441, 442, 443, 444, 39, 445, 0, 0, 41, 28, 29, 30, 31, 32, 0, 0, 0, 0, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 33, 34, 35, 0, 8, 0, 0, 0, 624, 0, 0, 0, 0, 0, 0, 0, 36, 244, 0, 37, 38, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 39, 0, 0, 0, 41, 28, 29, 30, 31, 32, 0, 0, 441, 442, 443, 444, 0, 445, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 8, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 36, 0, 0, 37, 38, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, 39, 0, 0, 0, 41, 0, 0, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 741, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 8, 747, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 9, 10, 11, 12, 13, 14, 15, 16, 694, 18, 695, 20, 696, 697, 23, 24, 25, 26, 0, 441, 442, 443, 444, 39, 445, 0, 0, 41, 0, 0, 0, 441, 442, 443, 444, 0, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 41 }; #define yypact_value_is_default(yystate) \ ((yystate) == (-957)) #define yytable_value_is_error(yytable_value) \ YYID (0) static const yytype_int16 yycheck[] = { 0, 581, 21, 157, 235, 5, 60, 71, 93, 1, 2, 5, 149, 544, 1, 2, 5, 5, 356, 138, 370, 21, 525, 40, 725, 140, 698, 5, 663, 93, 94, 556, 5, 44, 516, 103, 848, 5, 220, 46, 41, 178, 179, 525, 5, 420, 46, 378, 155, 5, 46, 99, 6, 6, 54, 6, 238, 944, 6, 946, 41, 6, 286, 3, 46, 42, 0, 4, 60, 6, 70, 188, 5, 48, 138, 75, 76, 194, 1034, 118, 45, 5, 47, 200, 41, 54, 5, 5, 205, 6, 138, 5, 793, 5, 5, 5, 43, 658, 46, 46, 3, 46, 150, 54, 40, 666, 43, 290, 291, 46, 110, 294, 129, 337, 231, 111, 42, 5, 4, 117, 6, 228, 140, 3, 241, 126, 1082, 104, 129, 76, 691, 85, 85, 664, 5, 116, 5, 85, 3, 5, 140, 5, 140, 191, 956, 5, 707, 116, 140, 89, 90, 1038, 206, 140, 3, 209, 161, 162, 197, 116, 167, 5, 169, 155, 514, 118, 171, 167, 85, 169, 48, 872, 226, 155, 48, 115, 3, 114, 104, 119, 234, 163, 289, 533, 43, 185, 89, 90, 153, 228, 126, 863, 893, 129, 569, 117, 136, 1, 163, 199, 136, 3, 356, 310, 535, 244, 6, 246, 54, 89, 90, 76, 115, 103, 206, 215, 119, 209, 140, 402, 403, 404, 40, 3, 89, 90, 6, 1039, 228, 40, 230, 231, 52, 53, 226, 235, 40, 1049, 40, 119, 89, 90, 234, 235, 103, 245, 228, 247, 235, 54, 115, 71, 72, 814, 119, 57, 238, 103, 3, 59, 40, 4, 89, 90, 3, 43, 273, 3, 48, 323, 971, 271, 326, 273, 4, 3, 807, 802, 89, 90, 43, 916, 3, 103, 75, 290, 291, 89, 90, 294, 43, 273, 119, 6, 477, 478, 44, 289, 103, 384, 4, 40, 6, 46, 40, 120, 809, 289, 43, 89, 90, 40, 48, 115, 378, 546, 46, 119, 310, 110, 384, 57, 437, 698, 329, 330, 998, 809, 310, 77, 43, 323, 707, 515, 326, 115, 138, 40, 320, 119, 690, 76, 46, 1015, 89, 90, 126, 339, 355, 129, 89, 90, 339, 89, 90, 355, 136, 918, 138, 46, 542, 89, 90, 427, 92, 419, 54, 550, 89, 90, 370, 1072, 354, 42, 119, 43, 115, 40, 3, 115, 119, 1064, 52, 119, 964, 54, 54, 115, 76, 920, 126, 119, 43, 129, 115, 46, 396, 3, 119, 138, 136, 71, 138, 40, 4, 405, 6, 4, 525, 6, 3, 48, 40, 41, 1097, 463, 416, 417, 105, 106, 420, 40, 983, 40, 424, 76, 408, 419, 482, 57, 805, 992, 43, 487, 40, 46, 42, 419, 57, 40, 57, 40, 48, 43, 426, 437, 46, 3, 54, 103, 437, 57, 103, 46, 54, 420, 52, 53, 57, 464, 465, 466, 116, 117, 89, 90, 84, 85, 473, 474, 76, 535, 52, 53, 3, 71, 72, 6, 483, 43, 3, 40, 46, 89, 90, 524, 140, 46, 863, 528, 482, 71, 72, 1054, 119, 487, 89, 90, 104, 504, 1061, 49, 50, 51, 40, 41, 40, 103, 40, 115, 40, 511, 551, 119, 514, 40, 46, 40, 43, 857, 126, 57, 115, 129, 40, 48, 119, 40, 41, 40, 136, 531, 138, 533, 534, 527, 40, 531, 40, 539, 527, 57, 531, 531, 57, 534, 40, 558, 40, 41, 48, 543, 42, 531, 546, 40, 543, 47, 531, 546, 89, 90, 569, 531, 571, 57, 89, 90, 6, 569, 531, 571, 572, 40, 581, 531, 105, 106, 760, 761, 48, 581, 48, 583, 40, 41, 43, 40, 136, 46, 43, 41, 115, 46, 40, 41, 119, 579, 531, 581, 48, 57, 607, 126, 105, 106, 129, 531, 672, 1076, 54, 57, 531, 531, 579, 138, 116, 531, 42, 531, 531, 531, 676, 998, 43, 664, 1093, 1094, 1095, 46, 6, 43, 76, 770, 46, 43, 80, 46, 46, 1106, 1015, 641, 54, 531, 88, 89, 90, 641, 43, 649, 43, 46, 641, 641, 708, 41, 42, 3, 658, 54, 531, 927, 531, 641, 930, 531, 666, 531, 641, 42, 670, 531, 104, 641, 713, 116, 670, 696, 41, 42, 641, 670, 670, 802, 676, 641, 1061, 531, 688, 689, 690, 691, 670, 658, 811, 42, 696, 670, 698, 688, 688, 666, 670, 857, 935, 40, 706, 707, 641, 670, 688, 718, 706, 828, 670, 688, 708, 641, 718, 7, 731, 48, 641, 641, 48, 725, 691, 641, 41, 641, 641, 641, 739, 698, 41, 42, 821, 670, 802, 739, 104, 41, 707, 89, 90, 41, 670, 116, 730, 731, 804, 670, 670, 641, 802, 48, 670, 821, 670, 670, 670, 898, 57, 1101, 40, 730, 3, 48, 48, 115, 641, 810, 641, 119, 136, 641, 48, 641, 842, 818, 126, 641, 670, 129, 116, 833, 43, 42, 43, 41, 136, 46, 41, 793, 842, 849, 950, 641, 41, 670, 46, 670, 856, 40, 670, 41, 670, 121, 122, 123, 670, 48, 804, 80, 814, 879, 54, 54, 42, 819, 57, 88, 89, 90, 41, 41, 670, 41, 828, 130, 131, 132, 133, 134, 135, 136, 828, 43, 41, 76, 41, 828, 41, 907, 844, 41, 21, 41, 104, 814, 844, 42, 89, 90, 3, 844, 844, 849, 116, 859, 49, 50, 51, 863, 856, 865, 844, 41, 116, 44, 909, 844, 872, 134, 135, 136, 844, 43, 115, 111, 919, 76, 119, 844, 46, 48, 905, 116, 844, 126, 116, 40, 129, 893, 73, 74, 75, 936, 863, 136, 48, 138, 77, 78, 79, 905, 48, 82, 947, 84, 85, 844, 132, 133, 134, 135, 136, 41, 918, 973, 844, 960, 41, 977, 46, 844, 844, 48, 48, 43, 844, 48, 844, 844, 844, 935, 48, 1091, 48, 43, 89, 90, 41, 935, 944, 43, 946, 1101, 935, 40, 944, 47, 946, 918, 43, 91, 844, 964, 958, 959, 57, 42, 41, 40, 964, 46, 115, 1021, 46, 1023, 119, 971, 53, 844, 90, 844, 89, 1016, 844, 48, 844, 973, 964, 983, 844, 977, 78, 41, 41, 138, 48, 3, 992, 975, 42, 977, 107, 108, 998, 1063, 844, 48, 1056, 1057, 1058, 86, 87, 48, 48, 48, 48, 48, 42, 40, 140, 1015, 103, 62, 983, 130, 131, 132, 133, 134, 135, 136, 1080, 992, 40, 1021, 54, 1023, 3, 998, 41, 6, 48, 118, 1038, 47, 42, 41, 41, 41, 1038, 40, 40, 48, 1048, 54, 1015, 48, 71, 76, 1054, 48, 48, 48, 46, 76, 76, 1061, 138, 47, 1056, 1057, 1058, 148, 87, 47, 41, 43, 1072, 1073, 155, 41, 1076, 89, 90, 41, 161, 162, 21, 164, 43, 54, 76, 41, 1080, 1054, 171, 47, 40, 1093, 1094, 1095, 1061, 48, 48, 69, 76, 76, 76, 115, 41, 44, 1106, 119, 1073, 76, 42, 1076, 76, 43, 126, 43, 197, 129, 89, 90, 201, 104, 92, 41, 136, 54, 138, 97, 1093, 1094, 1095, 212, 41, 43, 105, 106, 48, 40, 77, 78, 79, 1106, 47, 82, 83, 84, 85, 228, 43, 49, 50, 51, 76, 43, 3, 236, 43, 238, 239, 240, 3, 242, 104, 244, 245, 246, 247, 43, 43, 188, 42, 48, 41, 47, 193, 194, 41, 48, 40, 118, 80, 200, 40, 202, 203, 41, 205, 48, 88, 89, 90, 40, 273, 43, 43, 41, 48, 40, 217, 48, 41, 220, 221, 40, 48, 41, 48, 41, 289, 290, 291, 41, 231, 294, 57, 46, 48, 41, 188, 238, 48, 43, 241, 193, 194, 43, 245, 516, 539, 310, 200, 312, 1016, 688, 935, 205, 546, 689, 511, 688, 89, 90, 828, 688, 583, 688, 89, 90, 329, 330, 220, 437, 556, 334, 51, 3, 4, 3, 6, 996, 3, 231, 232, 1048, 424, 346, 115, 237, 238, 959, 119, 241, 115, 354, 865, 1061, 119, 126, 564, 1043, 129, 673, -1, 126, -1, -1, 129, 136, -1, 138, 371, -1, 40, -1, 40, 43, -1, 40, 46, -1, 48, -1, 48, -1, -1, 48, -1, -1, -1, 162, -1, 57, -1, -1, 57, -1, -1, 3, 171, -1, -1, 402, 403, 404, -1, -1, -1, 408, -1, 410, 411, -1, 413, -1, -1, -1, -1, -1, 419, -1, -1, 89, 90, 89, 90, -1, 89, 90, -1, -1, 158, 159, -1, -1, 40, -1, -1, -1, -1, -1, -1, -1, 48, -1, -1, -1, 114, 115, -1, 115, -1, 119, 115, 119, -1, 3, 119, -1, 126, -1, 126, 129, -1, 129, -1, 466, -1, 240, 136, 242, 138, -1, 138, 3, -1, 138, 477, 478, -1, -1, 40, -1, 483, 89, 90, -1, -1, -1, -1, 49, 50, 51, 40, -1, 54, 43, -1, -1, -1, -1, 48, -1, -1, 504, -1, -1, 507, -1, -1, 115, 40, -1, -1, 119, -1, -1, -1, -1, 48, -1, 80, -1, -1, 524, -1, -1, -1, 528, 88, 89, 90, 259, 138, 261, 262, 263, 264, 265, 266, 267, -1, 89, 90, -1, 3, -1, -1, 6, -1, 550, 551, 552, -1, -1, 555, 556, 329, 330, -1, 89, 90, 334, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, 3, 301, -1, -1, 515, -1, 126, -1, 581, 129, -1, -1, -1, 115, 525, -1, 136, 119, 138, -1, -1, -1, -1, -1, 324, -1, -1, 327, 601, 540, -1, 542, -1, -1, -1, -1, 138, 40, -1, -1, 43, -1, 615, 616, -1, 48, -1, 620, -1, -1, 512, -1, 625, 515, 516, -1, -1, 630, 89, 90, -1, 523, 524, 525, -1, 410, 411, -1, 413, -1, -1, -1, -1, -1, 105, 106, -1, -1, -1, -1, 542, -1, 544, -1, 115, -1, 89, 90, 119, 551, -1, 664, -1, -1, -1, 126, -1, -1, 129, -1, -1, -1, -1, -1, -1, 136, -1, -1, -1, -1, -1, -1, 115, -1, 687, -1, 119, -1, -1, -1, 693, -1, -1, 126, -1, -1, 129, -1, 3, -1, -1, -1, -1, 136, -1, 138, -1, -1, 483, -1, 713, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, -1, 504, -1, 672, 507, -1, -1, 40, -1, -1, 43, -1, -1, 3, -1, 48, -1, -1, -1, 750, 751, 479, -1, -1, -1, 756, -1, -1, -1, -1, 488, -1, -1, 49, 50, 51, -1, -1, 54, -1, -1, -1, -1, -1, 664, -1, -1, -1, 3, 552, 40, 671, 555, 673, -1, -1, 89, 90, 48, -1, 76, -1, -1, -1, 80, -1, -1, -1, -1, -1, -1, 802, 88, 89, 90, -1, -1, -1, -1, 810, -1, -1, 115, -1, -1, 40, 119, 818, -1, -1, -1, 760, 761, 126, -1, -1, 129, -1, -1, 89, 90, -1, 57, 136, -1, 138, -1, -1, -1, -1, -1, -1, 615, 616, -1, -1, -1, 620, 576, 577, 578, 579, 625, -1, -1, 115, -1, 630, -1, 119, -1, -1, -1, -1, 89, 90, 126, -1, 869, 129, 760, 761, 811, -1, -1, -1, 136, -1, 138, -1, -1, -1, -1, -1, 885, 824, 825, 826, 889, 890, 115, -1, -1, 3, 119, -1, -1, -1, -1, -1, -1, 126, -1, -1, 129, -1, 3, -1, 909, -1, -1, 3, -1, 138, 853, -1, -1, 807, 919, 809, 693, 811, -1, -1, -1, -1, -1, 3, -1, -1, 40, -1, -1, -1, -1, 936, -1, -1, 48, -1, -1, -1, 832, 40, -1, -1, 947, -1, 40, 3, 951, 48, -1, -1, -1, -1, 48, -1, -1, 960, 57, -1, 3, 964, 40, 966, 967, -1, -1, -1, -1, -1, 48, -1, -1, -1, 977, 750, 751, 89, 90, 709, -1, 756, -1, -1, 40, -1, -1, -1, -1, -1, 89, 90, -1, 934, -1, 89, 90, 40, 728, 729, 730, 57, 732, 115, -1, 48, -1, 119, 738, 1012, -1, 89, 90, 1016, 126, -1, 115, 129, -1, -1, 119, 115, -1, -1, 136, 119, 138, 126, 920, -1, 129, -1, 126, 89, 90, 129, -1, 115, -1, 138, 1043, 119, 136, -1, 138, -1, 89, 90, 126, -1, -1, 129, -1, -1, -1, 996, -1, -1, -1, 115, 138, -1, -1, 119, -1, -1, -1, -1, -1, -1, 126, -1, 115, 129, -1, -1, 119, -1, -1, -1, -1, -1, 138, 126, -1, -1, 129, 3, -1, -1, 6, -1, -1, -1, -1, 138, -1, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, 6, 885, -1, -1, -1, 889, 890, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 3, 4, -1, -1, -1, 8, 9, 10, -1, -1, -1, 876, 877, -1, -1, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, 89, 90, 43, 44, -1, -1, 47, -1, 49, 50, 51, 52, 53, -1, -1, -1, 105, 106, 966, 967, -1, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, -1, 77, 78, 79, -1, 81, 82, 83, 84, 85, 86, 87, -1, 89, 90, 91, -1, -1, -1, 95, -1, 97, 98, 99, 100, 101, 102, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 976, 115, -1, -1, 118, 119, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, -1, 995, 6, 7, 41, -1, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, -1, -1, -1, -1, -1, 48, 49, 50, 51, 52, 53, -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, 107, 108, 109, 110, -1, 112, -1, 107, 108, 109, 110, 3, 86, -1, -1, 89, 90, -1, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 130, 131, 132, 133, 134, 135, 136, -1, -1, -1, -1, 115, -1, -1, 118, 119, -1, -1, 40, -1, -1, -1, 126, -1, -1, 129, 48, 3, 132, 133, 6, 7, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, 89, 90, 76, -1, -1, -1, 49, 50, 51, 52, 53, -1, 55, -1, -1, 58, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, 70, 71, 72, 119, -1, -1, 107, 108, 109, 110, -1, 112, -1, -1, -1, 3, 86, -1, -1, 89, 90, -1, 138, -1, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, -1, -1, 40, -1, -1, -1, 126, -1, -1, 129, 48, 3, 132, 133, 6, 7, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, 89, 90, -1, -1, -1, -1, 49, 50, 51, 52, 53, -1, 55, -1, -1, 58, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, 70, 71, 72, 119, -1, 107, 108, 109, 110, -1, 112, -1, -1, -1, -1, 3, 86, -1, -1, 89, 90, -1, 138, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, -1, -1, 40, -1, -1, -1, 126, -1, -1, 129, 48, 3, 132, 133, 6, 7, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, 89, 90, -1, -1, -1, -1, 49, 50, 51, 52, 53, -1, 55, -1, -1, 58, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, 70, 71, 72, 119, -1, 107, 108, 109, 110, -1, -1, -1, -1, -1, -1, 3, 86, -1, -1, 89, 90, -1, 138, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, -1, -1, 40, -1, -1, -1, 126, -1, -1, 129, 48, 3, 132, 133, 6, 7, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, 89, 90, -1, -1, -1, -1, 49, 50, 51, 52, 53, -1, 55, -1, -1, 58, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, 70, 71, 72, 119, 107, 108, 109, 110, -1, -1, -1, -1, 107, 108, 109, 110, 86, -1, -1, 89, 90, -1, 138, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 129, 130, 131, 132, 133, 134, 135, 136, -1, -1, -1, 115, -1, -1, 41, 119, -1, -1, -1, -1, -1, -1, 126, -1, -1, 129, -1, 3, 132, 133, 6, 7, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, -1, -1, -1, -1, -1, -1, 49, 50, 51, 52, 53, -1, 55, 107, 108, 109, 110, -1, 112, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 86, -1, -1, 89, 90, 22, 23, 24, 25, 26, 27, 28, 29, -1, 31, -1, 33, -1, -1, 36, 37, 38, 39, -1, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, 43, -1, -1, -1, -1, -1, 126, -1, -1, 129, -1, 3, 132, 133, 6, 7, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, -1, -1, -1, -1, -1, -1, 49, 50, 51, 52, 53, -1, 55, 107, 108, 109, 110, -1, 112, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 86, -1, -1, 89, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, 126, -1, -1, 129, -1, 3, 132, 133, 6, 7, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, -1, -1, -1, -1, -1, -1, 49, 50, 51, 52, 53, -1, 55, 107, 108, 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, -1, -1, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 86, -1, -1, 89, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, 126, -1, -1, 129, -1, 3, 132, 133, 6, 7, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, 3, -1, -1, -1, -1, -1, 3, 49, 50, 51, 52, 53, 3, 55, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, -1, -1, -1, -1, -1, 40, -1, -1, -1, -1, -1, 40, 86, 48, -1, 89, 90, 40, -1, 48, -1, -1, 57, -1, -1, 48, -1, -1, 57, -1, -1, -1, -1, -1, 57, -1, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, -1, 107, 108, 109, 110, -1, -1, -1, 89, 90, -1, -1, 132, 133, 89, 90, 136, 137, 138, -1, 89, 90, 128, 129, 130, 131, 132, 133, 134, 135, 136, -1, -1, -1, 115, -1, -1, -1, 119, -1, 115, -1, -1, -1, 119, -1, 115, -1, -1, -1, 119, 3, -1, -1, -1, -1, -1, 138, -1, -1, -1, -1, -1, 138, -1, -1, -1, -1, -1, 138, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, -1, -1, -1, -1, -1, 48, 49, 50, 51, 52, 53, -1, -1, -1, 57, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, -1, -1, 118, 119, 3, -1, -1, -1, -1, -1, 126, -1, -1, 129, -1, -1, -1, -1, -1, -1, 136, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, -1, -1, -1, -1, -1, 48, 49, 50, 51, 52, 53, -1, -1, -1, 57, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 115, -1, -1, 118, 119, 48, 49, 50, 51, 52, 53, 126, -1, -1, 129, -1, -1, -1, -1, -1, -1, 136, -1, -1, -1, -1, -1, 70, 71, 72, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 115, -1, -1, 118, 119, -1, -1, 52, 53, -1, -1, 126, -1, -1, 129, -1, -1, -1, -1, -1, -1, 136, -1, -1, -1, 70, 71, 72, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, -1, 0, 1, 119, 3, 4, -1, -1, -1, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, 136, -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 43, 44, -1, -1, -1, -1, 49, 50, 51, 52, 53, -1, -1, 56, -1, -1, -1, -1, -1, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, -1, -1, -1, -1, 77, 78, 79, -1, 81, 82, -1, 84, 85, 86, 87, -1, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 1, -1, 3, 4, -1, -1, -1, 8, 9, 10, 113, -1, 115, -1, -1, 118, 119, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 43, 44, -1, -1, 47, -1, 49, 50, 51, 52, 53, -1, -1, 56, -1, -1, -1, -1, -1, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, -1, -1, -1, -1, 77, 78, 79, -1, 81, 82, -1, 84, 85, 86, 87, -1, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 1, -1, 3, 4, -1, -1, -1, 8, 9, 10, 113, -1, 115, -1, -1, 118, 119, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 43, 44, -1, -1, 47, -1, 49, 50, 51, 52, 53, -1, -1, 56, -1, -1, -1, -1, -1, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, -1, -1, -1, -1, 77, 78, 79, -1, 81, 82, -1, 84, 85, 86, 87, -1, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 1, -1, 3, 4, -1, -1, -1, 8, 9, 10, 113, -1, 115, -1, -1, 118, 119, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 43, 44, -1, -1, 47, -1, 49, 50, 51, 52, 53, -1, -1, 56, -1, -1, -1, -1, -1, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, -1, -1, -1, -1, 77, 78, 79, -1, 81, 82, -1, 84, 85, 86, 87, -1, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 1, -1, 3, 4, -1, -1, -1, 8, 9, 10, 113, -1, 115, -1, -1, 118, 119, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 43, 44, -1, -1, -1, -1, 49, 50, 51, 52, 53, -1, -1, 56, -1, -1, -1, 60, -1, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, -1, -1, -1, -1, 77, 78, 79, -1, 81, 82, -1, 84, 85, 86, 87, -1, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 113, -1, 115, -1, -1, 118, 119, -1, -1, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, -1, -1, -1, 48, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, 1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 115, -1, -1, 118, 119, 48, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, 1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 115, -1, -1, 118, 119, -1, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, 58, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 107, 108, 109, 110, 115, 112, -1, -1, 119, 49, 50, 51, 52, 53, -1, -1, -1, -1, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 70, 71, 72, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, 87, -1, 89, 90, -1, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 115, -1, -1, -1, 119, 120, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, -1, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 86, 87, 13, 89, 90, -1, -1, -1, -1, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 115, -1, -1, -1, 119, 120, -1, -1, 48, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, 115, -1, -1, 118, 119, 48, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, -1, 115, -1, -1, 118, 119, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, 58, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 107, 108, 109, 110, 115, 112, -1, -1, 119, 49, 50, 51, 52, 53, -1, -1, -1, -1, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 70, 71, 72, -1, 3, -1, -1, -1, 58, -1, -1, -1, -1, -1, -1, -1, 86, 87, -1, 89, 90, -1, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, 115, -1, -1, -1, 119, 49, 50, 51, 52, 53, -1, -1, 107, 108, 109, 110, -1, 112, -1, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, 3, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 86, -1, -1, 89, 90, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, -1, -1, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, 58, -1, -1, -1, -1, -1, -1, -1, 70, 71, 72, 3, 58, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, 89, 90, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, 107, 108, 109, 110, 115, 112, -1, -1, 119, -1, -1, -1, 107, 108, 109, 110, -1, 112, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, -1, -1, -1, 86, -1, -1, 89, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, -1, -1, -1, 119 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { 0, 121, 122, 123, 142, 143, 307, 1, 3, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 48, 49, 50, 51, 52, 53, 70, 71, 72, 86, 89, 90, 115, 118, 119, 193, 235, 249, 250, 252, 253, 254, 255, 256, 257, 282, 283, 293, 296, 298, 1, 235, 1, 40, 0, 1, 4, 8, 9, 10, 21, 43, 44, 56, 62, 63, 64, 65, 66, 67, 68, 69, 77, 78, 79, 81, 82, 84, 85, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 113, 118, 144, 145, 146, 148, 149, 150, 151, 152, 155, 156, 158, 159, 160, 161, 162, 163, 164, 167, 168, 169, 172, 174, 179, 180, 181, 182, 184, 188, 195, 196, 197, 198, 199, 203, 204, 211, 212, 223, 231, 307, 103, 292, 307, 48, 52, 71, 48, 48, 40, 140, 103, 296, 43, 253, 249, 40, 48, 54, 57, 76, 119, 126, 129, 136, 138, 240, 241, 243, 245, 246, 247, 248, 296, 307, 249, 256, 296, 292, 117, 140, 297, 43, 43, 232, 233, 235, 307, 120, 40, 6, 85, 118, 301, 40, 304, 307, 1, 251, 252, 293, 40, 304, 40, 166, 307, 40, 40, 84, 85, 40, 44, 77, 92, 296, 46, 293, 296, 40, 4, 46, 40, 40, 43, 46, 4, 301, 40, 178, 251, 176, 178, 40, 40, 301, 40, 103, 283, 304, 40, 126, 129, 243, 248, 296, 87, 193, 251, 283, 7, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 40, 55, 126, 129, 132, 133, 136, 137, 138, 235, 236, 237, 239, 251, 252, 268, 269, 270, 271, 301, 302, 307, 48, 48, 48, 296, 119, 298, 283, 249, 40, 126, 129, 232, 246, 248, 296, 48, 46, 105, 106, 258, 259, 260, 261, 262, 58, 268, 269, 268, 3, 40, 48, 138, 244, 247, 296, 48, 244, 247, 248, 249, 296, 240, 40, 57, 240, 40, 57, 48, 126, 129, 244, 247, 296, 116, 298, 119, 298, 41, 42, 234, 307, 260, 293, 294, 301, 283, 6, 46, 85, 294, 305, 294, 43, 40, 243, 54, 41, 294, 296, 293, 293, 294, 13, 173, 232, 232, 296, 43, 54, 214, 54, 46, 293, 175, 305, 293, 232, 46, 242, 243, 246, 307, 43, 42, 177, 307, 294, 295, 307, 153, 154, 301, 232, 207, 208, 209, 235, 282, 307, 296, 301, 126, 129, 248, 293, 296, 305, 40, 294, 126, 129, 296, 116, 243, 296, 263, 293, 307, 40, 243, 76, 274, 275, 296, 307, 268, 40, 48, 268, 268, 268, 268, 268, 268, 268, 104, 42, 238, 307, 40, 107, 108, 109, 110, 112, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 7, 48, 48, 41, 297, 104, 126, 129, 248, 296, 245, 296, 245, 41, 41, 126, 129, 245, 296, 116, 48, 57, 268, 58, 40, 248, 296, 48, 296, 40, 57, 48, 248, 232, 58, 268, 232, 58, 268, 48, 48, 244, 247, 48, 244, 247, 116, 48, 126, 129, 244, 297, 43, 235, 41, 296, 183, 42, 54, 41, 240, 258, 41, 46, 41, 54, 41, 42, 171, 42, 41, 41, 43, 143, 296, 213, 41, 41, 41, 41, 176, 178, 41, 41, 42, 46, 41, 104, 42, 210, 307, 59, 116, 41, 248, 296, 43, 116, 111, 54, 76, 194, 307, 232, 296, 80, 88, 89, 90, 186, 240, 249, 285, 286, 276, 46, 43, 274, 41, 126, 129, 136, 248, 251, 48, 239, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 283, 296, 116, 41, 41, 41, 116, 245, 245, 268, 232, 244, 296, 41, 116, 48, 232, 58, 268, 48, 41, 58, 41, 58, 48, 48, 48, 48, 126, 129, 244, 247, 48, 48, 48, 244, 234, 4, 46, 301, 143, 305, 153, 270, 301, 306, 43, 43, 147, 4, 165, 301, 4, 43, 46, 114, 170, 243, 301, 303, 294, 301, 306, 41, 235, 243, 46, 47, 43, 143, 44, 231, 176, 43, 46, 40, 47, 177, 115, 119, 293, 299, 43, 305, 235, 170, 91, 205, 209, 157, 243, 301, 116, 30, 32, 34, 35, 187, 254, 255, 296, 57, 189, 253, 43, 46, 41, 40, 40, 285, 90, 89, 42, 43, 46, 185, 240, 286, 240, 78, 277, 278, 284, 307, 201, 46, 268, 41, 41, 136, 249, 41, 126, 129, 241, 48, 238, 76, 296, 41, 58, 41, 41, 244, 244, 41, 58, 244, 244, 48, 48, 48, 48, 48, 244, 48, 48, 48, 47, 42, 42, 1, 43, 66, 73, 74, 75, 78, 83, 138, 148, 149, 150, 151, 155, 156, 160, 162, 164, 167, 169, 172, 174, 179, 180, 181, 182, 199, 203, 204, 211, 215, 219, 220, 221, 222, 223, 224, 225, 226, 229, 231, 307, 40, 249, 286, 287, 307, 54, 41, 42, 171, 170, 243, 287, 47, 301, 251, 293, 43, 54, 303, 232, 140, 117, 140, 300, 103, 41, 47, 296, 44, 118, 184, 199, 203, 204, 206, 220, 222, 224, 231, 210, 143, 287, 43, 292, 186, 40, 46, 190, 150, 264, 265, 307, 40, 54, 286, 287, 288, 232, 268, 243, 240, 42, 73, 74, 75, 279, 281, 215, 200, 268, 268, 268, 41, 41, 41, 40, 268, 240, 41, 244, 244, 48, 48, 48, 244, 48, 48, 305, 305, 218, 46, 76, 76, 76, 138, 40, 298, 47, 215, 30, 32, 34, 35, 120, 230, 251, 255, 296, 232, 286, 170, 301, 306, 43, 243, 41, 287, 43, 243, 43, 178, 41, 119, 293, 293, 119, 293, 236, 4, 46, 54, 103, 87, 60, 43, 185, 232, 40, 43, 191, 266, 293, 42, 47, 232, 258, 54, 76, 289, 307, 41, 41, 186, 278, 296, 280, 47, 215, 268, 268, 251, 244, 48, 48, 244, 244, 215, 216, 298, 40, 292, 251, 76, 40, 43, 41, 171, 287, 43, 243, 170, 43, 43, 300, 300, 104, 293, 207, 41, 192, 264, 54, 264, 43, 243, 41, 43, 260, 290, 291, 296, 43, 46, 185, 48, 272, 273, 307, 284, 43, 202, 243, 47, 241, 244, 244, 215, 40, 232, 40, 126, 129, 248, 268, 232, 43, 43, 287, 43, 104, 287, 43, 267, 268, 266, 186, 43, 46, 43, 42, 48, 40, 46, 48, 296, 186, 202, 41, 47, 232, 41, 232, 40, 40, 40, 129, 43, 41, 43, 111, 190, 264, 185, 291, 48, 48, 273, 185, 217, 41, 227, 287, 41, 232, 232, 232, 40, 288, 251, 191, 48, 48, 215, 228, 287, 43, 46, 54, 228, 41, 41, 41, 232, 190, 48, 43, 46, 54, 260, 228, 228, 228, 41, 191, 48, 258, 43, 228, 43 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. However, YYFAIL appears to be in use. Nevertheless, it is formally deprecated in Bison 2.4.2's NEWS entry, where a plan to phase it out is discussed. */ #define YYFAIL goto yyerrlab #if defined YYFAIL /* This is here to suppress warnings from the GCC cpp's -Wunused-macros. Normally we don't worry about that warning, but some users do, and we want to make it easy for users to remove YYFAIL uses, which will produce warnings from Bison 2.5. */ #endif #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (1); \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (YYID (0)) #endif /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (YYLEX_PARAM) #else # define YYLEX yylex () #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; #endif { if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # else YYUSE (yyoutput); # endif switch (yytype) { default: break; } } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; #endif { if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void yy_stack_print (yybottom, yytop) yytype_int16 *yybottom; yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_reduce_print (YYSTYPE *yyvsp, int yyrule) #else static void yy_reduce_print (yyvsp, yyrule) YYSTYPE *yyvsp; int yyrule; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, Rule); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) #else static YYSIZE_T yystrlen (yystr) const char *yystr; #endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) #else static char * yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = 0; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - Assume YYFAIL is not used. It's too flawed to consider. See for details. YYERROR is fine as it does not invoke this function. - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else static void yydestruct (yymsg, yytype, yyvaluep) const char *yymsg; int yytype; YYSTYPE *yyvaluep; #endif { YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM) #else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else int yyparse () #endif #endif { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: `yyss': related to states. `yyvs': related to semantic values. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yytoken = 0; yyss = yyssa; yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: /* Line 1806 of yacc.c */ #line 1463 "parser.y" { if (!classes) classes = NewHash(); Setattr((yyvsp[(1) - (1)].node),"classes",classes); Setattr((yyvsp[(1) - (1)].node),"name",ModuleName); if ((!module_node) && ModuleName) { module_node = new_node("module"); Setattr(module_node,"name",ModuleName); } Setattr((yyvsp[(1) - (1)].node),"module",module_node); top = (yyvsp[(1) - (1)].node); } break; case 3: /* Line 1806 of yacc.c */ #line 1475 "parser.y" { top = Copy(Getattr((yyvsp[(2) - (3)].p),"type")); Delete((yyvsp[(2) - (3)].p)); } break; case 4: /* Line 1806 of yacc.c */ #line 1479 "parser.y" { top = 0; } break; case 5: /* Line 1806 of yacc.c */ #line 1482 "parser.y" { top = (yyvsp[(2) - (3)].p); } break; case 6: /* Line 1806 of yacc.c */ #line 1485 "parser.y" { top = 0; } break; case 7: /* Line 1806 of yacc.c */ #line 1488 "parser.y" { top = (yyvsp[(3) - (5)].pl); } break; case 8: /* Line 1806 of yacc.c */ #line 1491 "parser.y" { top = 0; } break; case 9: /* Line 1806 of yacc.c */ #line 1496 "parser.y" { /* add declaration to end of linked list (the declaration isn't always a single declaration, sometimes it is a linked list itself) */ appendChild((yyvsp[(1) - (2)].node),(yyvsp[(2) - (2)].node)); (yyval.node) = (yyvsp[(1) - (2)].node); } break; case 10: /* Line 1806 of yacc.c */ #line 1501 "parser.y" { (yyval.node) = new_node("top"); } break; case 11: /* Line 1806 of yacc.c */ #line 1506 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 12: /* Line 1806 of yacc.c */ #line 1507 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 13: /* Line 1806 of yacc.c */ #line 1508 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 14: /* Line 1806 of yacc.c */ #line 1509 "parser.y" { (yyval.node) = 0; } break; case 15: /* Line 1806 of yacc.c */ #line 1510 "parser.y" { (yyval.node) = 0; Swig_error(cparse_file, cparse_line,"Syntax error in input(1).\n"); exit(1); } break; case 16: /* Line 1806 of yacc.c */ #line 1516 "parser.y" { if ((yyval.node)) { add_symbols((yyval.node)); } (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 17: /* Line 1806 of yacc.c */ #line 1532 "parser.y" { (yyval.node) = 0; skip_decl(); } break; case 18: /* Line 1806 of yacc.c */ #line 1542 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 19: /* Line 1806 of yacc.c */ #line 1543 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 20: /* Line 1806 of yacc.c */ #line 1544 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 21: /* Line 1806 of yacc.c */ #line 1545 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 22: /* Line 1806 of yacc.c */ #line 1546 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 23: /* Line 1806 of yacc.c */ #line 1547 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 24: /* Line 1806 of yacc.c */ #line 1548 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 25: /* Line 1806 of yacc.c */ #line 1549 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 26: /* Line 1806 of yacc.c */ #line 1550 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 27: /* Line 1806 of yacc.c */ #line 1551 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 28: /* Line 1806 of yacc.c */ #line 1552 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 29: /* Line 1806 of yacc.c */ #line 1553 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 30: /* Line 1806 of yacc.c */ #line 1554 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 31: /* Line 1806 of yacc.c */ #line 1555 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 32: /* Line 1806 of yacc.c */ #line 1556 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 33: /* Line 1806 of yacc.c */ #line 1557 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 34: /* Line 1806 of yacc.c */ #line 1558 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 35: /* Line 1806 of yacc.c */ #line 1559 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 36: /* Line 1806 of yacc.c */ #line 1560 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 37: /* Line 1806 of yacc.c */ #line 1561 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 38: /* Line 1806 of yacc.c */ #line 1562 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 39: /* Line 1806 of yacc.c */ #line 1569 "parser.y" { Node *cls; String *clsname; extendmode = 1; cplus_mode = CPLUS_PUBLIC; if (!classes) classes = NewHash(); if (!classes_typedefs) classes_typedefs = NewHash(); clsname = make_class_name((yyvsp[(3) - (4)].str)); cls = Getattr(classes,clsname); if (!cls) { cls = Getattr(classes_typedefs, clsname); if (!cls) { /* No previous definition. Create a new scope */ Node *am = Getattr(Swig_extend_hash(),clsname); if (!am) { Swig_symbol_newscope(); Swig_symbol_setscopename((yyvsp[(3) - (4)].str)); prev_symtab = 0; } else { prev_symtab = Swig_symbol_setscope(Getattr(am,"symtab")); } current_class = 0; } else { /* Previous typedef class definition. Use its symbol table. Deprecated, just the real name should be used. Note that %extend before the class typedef never worked, only %extend after the class typdef. */ prev_symtab = Swig_symbol_setscope(Getattr(cls, "symtab")); current_class = cls; SWIG_WARN_NODE_BEGIN(cls); Swig_warning(WARN_PARSE_EXTEND_NAME, cparse_file, cparse_line, "Deprecated %%extend name used - the %s name '%s' should be used instead of the typedef name '%s'.\n", Getattr(cls, "kind"), SwigType_namestr(Getattr(cls, "name")), (yyvsp[(3) - (4)].str)); SWIG_WARN_NODE_END(cls); } } else { /* Previous class definition. Use its symbol table */ prev_symtab = Swig_symbol_setscope(Getattr(cls,"symtab")); current_class = cls; } Classprefix = NewString((yyvsp[(3) - (4)].str)); Namespaceprefix= Swig_symbol_qualifiedscopename(0); Delete(clsname); } break; case 40: /* Line 1806 of yacc.c */ #line 1609 "parser.y" { String *clsname; extendmode = 0; (yyval.node) = new_node("extend"); Setattr((yyval.node),"symtab",Swig_symbol_popscope()); if (prev_symtab) { Swig_symbol_setscope(prev_symtab); } Namespaceprefix = Swig_symbol_qualifiedscopename(0); clsname = make_class_name((yyvsp[(3) - (7)].str)); Setattr((yyval.node),"name",clsname); mark_nodes_as_extend((yyvsp[(6) - (7)].node)); if (current_class) { /* We add the extension to the previously defined class */ appendChild((yyval.node),(yyvsp[(6) - (7)].node)); appendChild(current_class,(yyval.node)); } else { /* We store the extensions in the extensions hash */ Node *am = Getattr(Swig_extend_hash(),clsname); if (am) { /* Append the members to the previous extend methods */ appendChild(am,(yyvsp[(6) - (7)].node)); } else { appendChild((yyval.node),(yyvsp[(6) - (7)].node)); Setattr(Swig_extend_hash(),clsname,(yyval.node)); } } current_class = 0; Delete(Classprefix); Delete(clsname); Classprefix = 0; prev_symtab = 0; (yyval.node) = 0; } break; case 41: /* Line 1806 of yacc.c */ #line 1651 "parser.y" { (yyval.node) = new_node("apply"); Setattr((yyval.node),"pattern",Getattr((yyvsp[(2) - (5)].p),"pattern")); appendChild((yyval.node),(yyvsp[(4) - (5)].p)); } break; case 42: /* Line 1806 of yacc.c */ #line 1661 "parser.y" { (yyval.node) = new_node("clear"); appendChild((yyval.node),(yyvsp[(2) - (3)].p)); } break; case 43: /* Line 1806 of yacc.c */ #line 1672 "parser.y" { if (((yyvsp[(4) - (5)].dtype).type != T_ERROR) && ((yyvsp[(4) - (5)].dtype).type != T_SYMBOL)) { SwigType *type = NewSwigType((yyvsp[(4) - (5)].dtype).type); (yyval.node) = new_node("constant"); Setattr((yyval.node),"name",(yyvsp[(2) - (5)].id)); Setattr((yyval.node),"type",type); Setattr((yyval.node),"value",(yyvsp[(4) - (5)].dtype).val); if ((yyvsp[(4) - (5)].dtype).rawval) Setattr((yyval.node),"rawval", (yyvsp[(4) - (5)].dtype).rawval); Setattr((yyval.node),"storage","%constant"); SetFlag((yyval.node),"feature:immutable"); add_symbols((yyval.node)); Delete(type); } else { if ((yyvsp[(4) - (5)].dtype).type == T_ERROR) { Swig_warning(WARN_PARSE_UNSUPPORTED_VALUE,cparse_file,cparse_line,"Unsupported constant value (ignored)\n"); } (yyval.node) = 0; } } break; case 44: /* Line 1806 of yacc.c */ #line 1693 "parser.y" { if (((yyvsp[(4) - (5)].dtype).type != T_ERROR) && ((yyvsp[(4) - (5)].dtype).type != T_SYMBOL)) { SwigType_push((yyvsp[(2) - (5)].type),(yyvsp[(3) - (5)].decl).type); /* Sneaky callback function trick */ if (SwigType_isfunction((yyvsp[(2) - (5)].type))) { SwigType_add_pointer((yyvsp[(2) - (5)].type)); } (yyval.node) = new_node("constant"); Setattr((yyval.node),"name",(yyvsp[(3) - (5)].decl).id); Setattr((yyval.node),"type",(yyvsp[(2) - (5)].type)); Setattr((yyval.node),"value",(yyvsp[(4) - (5)].dtype).val); if ((yyvsp[(4) - (5)].dtype).rawval) Setattr((yyval.node),"rawval", (yyvsp[(4) - (5)].dtype).rawval); Setattr((yyval.node),"storage","%constant"); SetFlag((yyval.node),"feature:immutable"); add_symbols((yyval.node)); } else { if ((yyvsp[(4) - (5)].dtype).type == T_ERROR) { Swig_warning(WARN_PARSE_UNSUPPORTED_VALUE,cparse_file,cparse_line,"Unsupported constant value\n"); } (yyval.node) = 0; } } break; case 45: /* Line 1806 of yacc.c */ #line 1715 "parser.y" { Swig_warning(WARN_PARSE_BAD_VALUE,cparse_file,cparse_line,"Bad constant value (ignored).\n"); (yyval.node) = 0; } break; case 46: /* Line 1806 of yacc.c */ #line 1726 "parser.y" { char temp[64]; Replace((yyvsp[(2) - (2)].str),"$file",cparse_file, DOH_REPLACE_ANY); sprintf(temp,"%d", cparse_line); Replace((yyvsp[(2) - (2)].str),"$line",temp,DOH_REPLACE_ANY); Printf(stderr,"%s\n", (yyvsp[(2) - (2)].str)); Delete((yyvsp[(2) - (2)].str)); (yyval.node) = 0; } break; case 47: /* Line 1806 of yacc.c */ #line 1735 "parser.y" { char temp[64]; String *s = NewString((yyvsp[(2) - (2)].id)); Replace(s,"$file",cparse_file, DOH_REPLACE_ANY); sprintf(temp,"%d", cparse_line); Replace(s,"$line",temp,DOH_REPLACE_ANY); Printf(stderr,"%s\n", s); Delete(s); (yyval.node) = 0; } break; case 48: /* Line 1806 of yacc.c */ #line 1754 "parser.y" { skip_balanced('{','}'); (yyval.node) = 0; Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, "%%except is deprecated. Use %%exception instead.\n"); } break; case 49: /* Line 1806 of yacc.c */ #line 1760 "parser.y" { skip_balanced('{','}'); (yyval.node) = 0; Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, "%%except is deprecated. Use %%exception instead.\n"); } break; case 50: /* Line 1806 of yacc.c */ #line 1766 "parser.y" { (yyval.node) = 0; Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, "%%except is deprecated. Use %%exception instead.\n"); } break; case 51: /* Line 1806 of yacc.c */ #line 1771 "parser.y" { (yyval.node) = 0; Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, "%%except is deprecated. Use %%exception instead.\n"); } break; case 52: /* Line 1806 of yacc.c */ #line 1778 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"value",(yyvsp[(1) - (4)].id)); Setattr((yyval.node),"type",Getattr((yyvsp[(3) - (4)].p),"type")); } break; case 53: /* Line 1806 of yacc.c */ #line 1785 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"value",(yyvsp[(1) - (1)].id)); } break; case 54: /* Line 1806 of yacc.c */ #line 1789 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 55: /* Line 1806 of yacc.c */ #line 1802 "parser.y" { Hash *p = (yyvsp[(5) - (7)].node); (yyval.node) = new_node("fragment"); Setattr((yyval.node),"value",Getattr((yyvsp[(3) - (7)].node),"value")); Setattr((yyval.node),"type",Getattr((yyvsp[(3) - (7)].node),"type")); Setattr((yyval.node),"section",Getattr(p,"name")); Setattr((yyval.node),"kwargs",nextSibling(p)); Setattr((yyval.node),"code",(yyvsp[(7) - (7)].str)); } break; case 56: /* Line 1806 of yacc.c */ #line 1811 "parser.y" { Hash *p = (yyvsp[(5) - (7)].node); String *code; skip_balanced('{','}'); (yyval.node) = new_node("fragment"); Setattr((yyval.node),"value",Getattr((yyvsp[(3) - (7)].node),"value")); Setattr((yyval.node),"type",Getattr((yyvsp[(3) - (7)].node),"type")); Setattr((yyval.node),"section",Getattr(p,"name")); Setattr((yyval.node),"kwargs",nextSibling(p)); Delitem(scanner_ccode,0); Delitem(scanner_ccode,DOH_END); code = Copy(scanner_ccode); Setattr((yyval.node),"code",code); Delete(code); } break; case 57: /* Line 1806 of yacc.c */ #line 1826 "parser.y" { (yyval.node) = new_node("fragment"); Setattr((yyval.node),"value",Getattr((yyvsp[(3) - (5)].node),"value")); Setattr((yyval.node),"type",Getattr((yyvsp[(3) - (5)].node),"type")); Setattr((yyval.node),"emitonly","1"); } break; case 58: /* Line 1806 of yacc.c */ #line 1839 "parser.y" { (yyvsp[(1) - (4)].loc).filename = Copy(cparse_file); (yyvsp[(1) - (4)].loc).line = cparse_line; scanner_set_location(NewString((yyvsp[(3) - (4)].id)),1); if ((yyvsp[(2) - (4)].node)) { String *maininput = Getattr((yyvsp[(2) - (4)].node), "maininput"); if (maininput) scanner_set_main_input_file(NewString(maininput)); } } break; case 59: /* Line 1806 of yacc.c */ #line 1848 "parser.y" { String *mname = 0; (yyval.node) = (yyvsp[(6) - (7)].node); scanner_set_location((yyvsp[(1) - (7)].loc).filename,(yyvsp[(1) - (7)].loc).line+1); if (strcmp((yyvsp[(1) - (7)].loc).type,"include") == 0) set_nodeType((yyval.node),"include"); if (strcmp((yyvsp[(1) - (7)].loc).type,"import") == 0) { mname = (yyvsp[(2) - (7)].node) ? Getattr((yyvsp[(2) - (7)].node),"module") : 0; set_nodeType((yyval.node),"import"); if (import_mode) --import_mode; } Setattr((yyval.node),"name",(yyvsp[(3) - (7)].id)); /* Search for the module (if any) */ { Node *n = firstChild((yyval.node)); while (n) { if (Strcmp(nodeType(n),"module") == 0) { if (mname) { Setattr(n,"name", mname); mname = 0; } Setattr((yyval.node),"module",Getattr(n,"name")); break; } n = nextSibling(n); } if (mname) { /* There is no module node in the import node, ie, you imported a .h file directly. We are forced then to create a new import node with a module node. */ Node *nint = new_node("import"); Node *mnode = new_node("module"); Setattr(mnode,"name", mname); appendChild(nint,mnode); Delete(mnode); appendChild(nint,firstChild((yyval.node))); (yyval.node) = nint; Setattr((yyval.node),"module",mname); } } Setattr((yyval.node),"options",(yyvsp[(2) - (7)].node)); } break; case 60: /* Line 1806 of yacc.c */ #line 1894 "parser.y" { (yyval.loc).type = "include"; } break; case 61: /* Line 1806 of yacc.c */ #line 1895 "parser.y" { (yyval.loc).type = "import"; ++import_mode;} break; case 62: /* Line 1806 of yacc.c */ #line 1902 "parser.y" { String *cpps; if (Namespaceprefix) { Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n"); (yyval.node) = 0; } else { (yyval.node) = new_node("insert"); Setattr((yyval.node),"code",(yyvsp[(2) - (2)].str)); /* Need to run through the preprocessor */ Seek((yyvsp[(2) - (2)].str),0,SEEK_SET); Setline((yyvsp[(2) - (2)].str),cparse_start_line); Setfile((yyvsp[(2) - (2)].str),cparse_file); cpps = Preprocessor_parse((yyvsp[(2) - (2)].str)); start_inline(Char(cpps), cparse_start_line); Delete((yyvsp[(2) - (2)].str)); Delete(cpps); } } break; case 63: /* Line 1806 of yacc.c */ #line 1921 "parser.y" { String *cpps; int start_line = cparse_line; skip_balanced('{','}'); if (Namespaceprefix) { Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n"); (yyval.node) = 0; } else { String *code; (yyval.node) = new_node("insert"); Delitem(scanner_ccode,0); Delitem(scanner_ccode,DOH_END); code = Copy(scanner_ccode); Setattr((yyval.node),"code", code); Delete(code); cpps=Copy(scanner_ccode); start_inline(Char(cpps), start_line); Delete(cpps); } } break; case 64: /* Line 1806 of yacc.c */ #line 1952 "parser.y" { (yyval.node) = new_node("insert"); Setattr((yyval.node),"code",(yyvsp[(1) - (1)].str)); } break; case 65: /* Line 1806 of yacc.c */ #line 1956 "parser.y" { String *code = NewStringEmpty(); (yyval.node) = new_node("insert"); Setattr((yyval.node),"section",(yyvsp[(3) - (5)].id)); Setattr((yyval.node),"code",code); if (Swig_insert_file((yyvsp[(5) - (5)].id),code) < 0) { Swig_error(cparse_file, cparse_line, "Couldn't find '%s'.\n", (yyvsp[(5) - (5)].id)); (yyval.node) = 0; } } break; case 66: /* Line 1806 of yacc.c */ #line 1966 "parser.y" { (yyval.node) = new_node("insert"); Setattr((yyval.node),"section",(yyvsp[(3) - (5)].id)); Setattr((yyval.node),"code",(yyvsp[(5) - (5)].str)); } break; case 67: /* Line 1806 of yacc.c */ #line 1971 "parser.y" { String *code; skip_balanced('{','}'); (yyval.node) = new_node("insert"); Setattr((yyval.node),"section",(yyvsp[(3) - (5)].id)); Delitem(scanner_ccode,0); Delitem(scanner_ccode,DOH_END); code = Copy(scanner_ccode); Setattr((yyval.node),"code", code); Delete(code); } break; case 68: /* Line 1806 of yacc.c */ #line 1989 "parser.y" { (yyval.node) = new_node("module"); if ((yyvsp[(2) - (3)].node)) { Setattr((yyval.node),"options",(yyvsp[(2) - (3)].node)); if (Getattr((yyvsp[(2) - (3)].node),"directors")) { Wrapper_director_mode_set(1); if (!cparse_cplusplus) { Swig_error(cparse_file, cparse_line, "Directors are not supported for C code and require the -c++ option\n"); } } if (Getattr((yyvsp[(2) - (3)].node),"dirprot")) { Wrapper_director_protected_mode_set(1); } if (Getattr((yyvsp[(2) - (3)].node),"allprotected")) { Wrapper_all_protected_mode_set(1); } if (Getattr((yyvsp[(2) - (3)].node),"templatereduce")) { template_reduce = 1; } if (Getattr((yyvsp[(2) - (3)].node),"notemplatereduce")) { template_reduce = 0; } } if (!ModuleName) ModuleName = NewString((yyvsp[(3) - (3)].id)); if (!import_mode) { /* first module included, we apply global ModuleName, which can be modify by -module */ String *mname = Copy(ModuleName); Setattr((yyval.node),"name",mname); Delete(mname); } else { /* import mode, we just pass the idstring */ Setattr((yyval.node),"name",(yyvsp[(3) - (3)].id)); } if (!module_node) module_node = (yyval.node); } break; case 69: /* Line 1806 of yacc.c */ #line 2032 "parser.y" { Swig_warning(WARN_DEPRECATED_NAME,cparse_file,cparse_line, "%%name is deprecated. Use %%rename instead.\n"); Delete(yyrename); yyrename = NewString((yyvsp[(3) - (4)].id)); (yyval.node) = 0; } break; case 70: /* Line 1806 of yacc.c */ #line 2038 "parser.y" { Swig_warning(WARN_DEPRECATED_NAME,cparse_file,cparse_line, "%%name is deprecated. Use %%rename instead.\n"); (yyval.node) = 0; Swig_error(cparse_file,cparse_line,"Missing argument to %%name directive.\n"); } break; case 71: /* Line 1806 of yacc.c */ #line 2051 "parser.y" { (yyval.node) = new_node("native"); Setattr((yyval.node),"name",(yyvsp[(3) - (7)].id)); Setattr((yyval.node),"wrap:name",(yyvsp[(6) - (7)].id)); add_symbols((yyval.node)); } break; case 72: /* Line 1806 of yacc.c */ #line 2057 "parser.y" { if (!SwigType_isfunction((yyvsp[(7) - (8)].decl).type)) { Swig_error(cparse_file,cparse_line,"%%native declaration '%s' is not a function.\n", (yyvsp[(7) - (8)].decl).id); (yyval.node) = 0; } else { Delete(SwigType_pop_function((yyvsp[(7) - (8)].decl).type)); /* Need check for function here */ SwigType_push((yyvsp[(6) - (8)].type),(yyvsp[(7) - (8)].decl).type); (yyval.node) = new_node("native"); Setattr((yyval.node),"name",(yyvsp[(3) - (8)].id)); Setattr((yyval.node),"wrap:name",(yyvsp[(7) - (8)].decl).id); Setattr((yyval.node),"type",(yyvsp[(6) - (8)].type)); Setattr((yyval.node),"parms",(yyvsp[(7) - (8)].decl).parms); Setattr((yyval.node),"decl",(yyvsp[(7) - (8)].decl).type); } add_symbols((yyval.node)); } break; case 73: /* Line 1806 of yacc.c */ #line 2083 "parser.y" { (yyval.node) = new_node("pragma"); Setattr((yyval.node),"lang",(yyvsp[(2) - (5)].id)); Setattr((yyval.node),"name",(yyvsp[(3) - (5)].id)); Setattr((yyval.node),"value",(yyvsp[(5) - (5)].str)); } break; case 74: /* Line 1806 of yacc.c */ #line 2089 "parser.y" { (yyval.node) = new_node("pragma"); Setattr((yyval.node),"lang",(yyvsp[(2) - (3)].id)); Setattr((yyval.node),"name",(yyvsp[(3) - (3)].id)); } break; case 75: /* Line 1806 of yacc.c */ #line 2096 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].id)); } break; case 76: /* Line 1806 of yacc.c */ #line 2097 "parser.y" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; case 77: /* Line 1806 of yacc.c */ #line 2100 "parser.y" { (yyval.id) = (yyvsp[(2) - (3)].id); } break; case 78: /* Line 1806 of yacc.c */ #line 2101 "parser.y" { (yyval.id) = (char *) "swig"; } break; case 79: /* Line 1806 of yacc.c */ #line 2108 "parser.y" { SwigType *t = (yyvsp[(2) - (4)].decl).type; Hash *kws = NewHash(); String *fixname; fixname = feature_identifier_fix((yyvsp[(2) - (4)].decl).id); Setattr(kws,"name",(yyvsp[(3) - (4)].id)); if (!Len(t)) t = 0; /* Special declarator check */ if (t) { if (SwigType_isfunction(t)) { SwigType *decl = SwigType_pop_function(t); if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",fixname); if ((yyvsp[(1) - (4)].intvalue)) { Swig_name_rename_add(Namespaceprefix, nname,decl,kws,(yyvsp[(2) - (4)].decl).parms); } else { Swig_name_namewarn_add(Namespaceprefix,nname,decl,kws); } Delete(nname); } else { if ((yyvsp[(1) - (4)].intvalue)) { Swig_name_rename_add(Namespaceprefix,(fixname),decl,kws,(yyvsp[(2) - (4)].decl).parms); } else { Swig_name_namewarn_add(Namespaceprefix,(fixname),decl,kws); } } Delete(decl); } else if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",fixname); if ((yyvsp[(1) - (4)].intvalue)) { Swig_name_rename_add(Namespaceprefix,(nname),0,kws,(yyvsp[(2) - (4)].decl).parms); } else { Swig_name_namewarn_add(Namespaceprefix,(nname),0,kws); } Delete(nname); } } else { if ((yyvsp[(1) - (4)].intvalue)) { Swig_name_rename_add(Namespaceprefix,(fixname),0,kws,(yyvsp[(2) - (4)].decl).parms); } else { Swig_name_namewarn_add(Namespaceprefix,(fixname),0,kws); } } (yyval.node) = 0; scanner_clear_rename(); } break; case 80: /* Line 1806 of yacc.c */ #line 2154 "parser.y" { String *fixname; Hash *kws = (yyvsp[(3) - (7)].node); SwigType *t = (yyvsp[(5) - (7)].decl).type; fixname = feature_identifier_fix((yyvsp[(5) - (7)].decl).id); if (!Len(t)) t = 0; /* Special declarator check */ if (t) { if ((yyvsp[(6) - (7)].dtype).qualifier) SwigType_push(t,(yyvsp[(6) - (7)].dtype).qualifier); if (SwigType_isfunction(t)) { SwigType *decl = SwigType_pop_function(t); if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",fixname); if ((yyvsp[(1) - (7)].intvalue)) { Swig_name_rename_add(Namespaceprefix, nname,decl,kws,(yyvsp[(5) - (7)].decl).parms); } else { Swig_name_namewarn_add(Namespaceprefix,nname,decl,kws); } Delete(nname); } else { if ((yyvsp[(1) - (7)].intvalue)) { Swig_name_rename_add(Namespaceprefix,(fixname),decl,kws,(yyvsp[(5) - (7)].decl).parms); } else { Swig_name_namewarn_add(Namespaceprefix,(fixname),decl,kws); } } Delete(decl); } else if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",fixname); if ((yyvsp[(1) - (7)].intvalue)) { Swig_name_rename_add(Namespaceprefix,(nname),0,kws,(yyvsp[(5) - (7)].decl).parms); } else { Swig_name_namewarn_add(Namespaceprefix,(nname),0,kws); } Delete(nname); } } else { if ((yyvsp[(1) - (7)].intvalue)) { Swig_name_rename_add(Namespaceprefix,(fixname),0,kws,(yyvsp[(5) - (7)].decl).parms); } else { Swig_name_namewarn_add(Namespaceprefix,(fixname),0,kws); } } (yyval.node) = 0; scanner_clear_rename(); } break; case 81: /* Line 1806 of yacc.c */ #line 2200 "parser.y" { if ((yyvsp[(1) - (6)].intvalue)) { Swig_name_rename_add(Namespaceprefix,(yyvsp[(5) - (6)].id),0,(yyvsp[(3) - (6)].node),0); } else { Swig_name_namewarn_add(Namespaceprefix,(yyvsp[(5) - (6)].id),0,(yyvsp[(3) - (6)].node)); } (yyval.node) = 0; scanner_clear_rename(); } break; case 82: /* Line 1806 of yacc.c */ #line 2211 "parser.y" { (yyval.intvalue) = 1; } break; case 83: /* Line 1806 of yacc.c */ #line 2214 "parser.y" { (yyval.intvalue) = 0; } break; case 84: /* Line 1806 of yacc.c */ #line 2241 "parser.y" { String *val = (yyvsp[(7) - (7)].str) ? NewString((yyvsp[(7) - (7)].str)) : NewString("1"); new_feature((yyvsp[(3) - (7)].id), val, 0, (yyvsp[(5) - (7)].decl).id, (yyvsp[(5) - (7)].decl).type, (yyvsp[(5) - (7)].decl).parms, (yyvsp[(6) - (7)].dtype).qualifier); (yyval.node) = 0; scanner_clear_rename(); } break; case 85: /* Line 1806 of yacc.c */ #line 2247 "parser.y" { String *val = Len((yyvsp[(5) - (9)].id)) ? NewString((yyvsp[(5) - (9)].id)) : 0; new_feature((yyvsp[(3) - (9)].id), val, 0, (yyvsp[(7) - (9)].decl).id, (yyvsp[(7) - (9)].decl).type, (yyvsp[(7) - (9)].decl).parms, (yyvsp[(8) - (9)].dtype).qualifier); (yyval.node) = 0; scanner_clear_rename(); } break; case 86: /* Line 1806 of yacc.c */ #line 2253 "parser.y" { String *val = (yyvsp[(8) - (8)].str) ? NewString((yyvsp[(8) - (8)].str)) : NewString("1"); new_feature((yyvsp[(3) - (8)].id), val, (yyvsp[(4) - (8)].node), (yyvsp[(6) - (8)].decl).id, (yyvsp[(6) - (8)].decl).type, (yyvsp[(6) - (8)].decl).parms, (yyvsp[(7) - (8)].dtype).qualifier); (yyval.node) = 0; scanner_clear_rename(); } break; case 87: /* Line 1806 of yacc.c */ #line 2259 "parser.y" { String *val = Len((yyvsp[(5) - (10)].id)) ? NewString((yyvsp[(5) - (10)].id)) : 0; new_feature((yyvsp[(3) - (10)].id), val, (yyvsp[(6) - (10)].node), (yyvsp[(8) - (10)].decl).id, (yyvsp[(8) - (10)].decl).type, (yyvsp[(8) - (10)].decl).parms, (yyvsp[(9) - (10)].dtype).qualifier); (yyval.node) = 0; scanner_clear_rename(); } break; case 88: /* Line 1806 of yacc.c */ #line 2267 "parser.y" { String *val = (yyvsp[(5) - (5)].str) ? NewString((yyvsp[(5) - (5)].str)) : NewString("1"); new_feature((yyvsp[(3) - (5)].id), val, 0, 0, 0, 0, 0); (yyval.node) = 0; scanner_clear_rename(); } break; case 89: /* Line 1806 of yacc.c */ #line 2273 "parser.y" { String *val = Len((yyvsp[(5) - (7)].id)) ? NewString((yyvsp[(5) - (7)].id)) : 0; new_feature((yyvsp[(3) - (7)].id), val, 0, 0, 0, 0, 0); (yyval.node) = 0; scanner_clear_rename(); } break; case 90: /* Line 1806 of yacc.c */ #line 2279 "parser.y" { String *val = (yyvsp[(6) - (6)].str) ? NewString((yyvsp[(6) - (6)].str)) : NewString("1"); new_feature((yyvsp[(3) - (6)].id), val, (yyvsp[(4) - (6)].node), 0, 0, 0, 0); (yyval.node) = 0; scanner_clear_rename(); } break; case 91: /* Line 1806 of yacc.c */ #line 2285 "parser.y" { String *val = Len((yyvsp[(5) - (8)].id)) ? NewString((yyvsp[(5) - (8)].id)) : 0; new_feature((yyvsp[(3) - (8)].id), val, (yyvsp[(6) - (8)].node), 0, 0, 0, 0); (yyval.node) = 0; scanner_clear_rename(); } break; case 92: /* Line 1806 of yacc.c */ #line 2293 "parser.y" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; case 93: /* Line 1806 of yacc.c */ #line 2294 "parser.y" { (yyval.str) = 0; } break; case 94: /* Line 1806 of yacc.c */ #line 2295 "parser.y" { (yyval.str) = (yyvsp[(3) - (5)].pl); } break; case 95: /* Line 1806 of yacc.c */ #line 2298 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"name",(yyvsp[(2) - (4)].id)); Setattr((yyval.node),"value",(yyvsp[(4) - (4)].id)); } break; case 96: /* Line 1806 of yacc.c */ #line 2303 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"name",(yyvsp[(2) - (5)].id)); Setattr((yyval.node),"value",(yyvsp[(4) - (5)].id)); set_nextSibling((yyval.node),(yyvsp[(5) - (5)].node)); } break; case 97: /* Line 1806 of yacc.c */ #line 2313 "parser.y" { Parm *val; String *name; SwigType *t; if (Namespaceprefix) name = NewStringf("%s::%s", Namespaceprefix, (yyvsp[(5) - (7)].decl).id); else name = NewString((yyvsp[(5) - (7)].decl).id); val = (yyvsp[(3) - (7)].pl); if ((yyvsp[(5) - (7)].decl).parms) { Setmeta(val,"parms",(yyvsp[(5) - (7)].decl).parms); } t = (yyvsp[(5) - (7)].decl).type; if (!Len(t)) t = 0; if (t) { if ((yyvsp[(6) - (7)].dtype).qualifier) SwigType_push(t,(yyvsp[(6) - (7)].dtype).qualifier); if (SwigType_isfunction(t)) { SwigType *decl = SwigType_pop_function(t); if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",name); Swig_feature_set(Swig_cparse_features(), nname, decl, "feature:varargs", val, 0); Delete(nname); } else { Swig_feature_set(Swig_cparse_features(), name, decl, "feature:varargs", val, 0); } Delete(decl); } else if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",name); Swig_feature_set(Swig_cparse_features(),nname,0,"feature:varargs",val, 0); Delete(nname); } } else { Swig_feature_set(Swig_cparse_features(),name,0,"feature:varargs",val, 0); } Delete(name); (yyval.node) = 0; } break; case 98: /* Line 1806 of yacc.c */ #line 2349 "parser.y" { (yyval.pl) = (yyvsp[(1) - (1)].pl); } break; case 99: /* Line 1806 of yacc.c */ #line 2350 "parser.y" { int i; int n; Parm *p; n = atoi(Char((yyvsp[(1) - (3)].dtype).val)); if (n <= 0) { Swig_error(cparse_file, cparse_line,"Argument count in %%varargs must be positive.\n"); (yyval.pl) = 0; } else { String *name = Getattr((yyvsp[(3) - (3)].p), "name"); (yyval.pl) = Copy((yyvsp[(3) - (3)].p)); if (name) Setattr((yyval.pl), "name", NewStringf("%s%d", name, n)); for (i = 1; i < n; i++) { p = Copy((yyvsp[(3) - (3)].p)); name = Getattr(p, "name"); if (name) Setattr(p, "name", NewStringf("%s%d", name, n-i)); set_nextSibling(p,(yyval.pl)); Delete((yyval.pl)); (yyval.pl) = p; } } } break; case 100: /* Line 1806 of yacc.c */ #line 2385 "parser.y" { (yyval.node) = 0; if ((yyvsp[(3) - (6)].tmap).method) { String *code = 0; (yyval.node) = new_node("typemap"); Setattr((yyval.node),"method",(yyvsp[(3) - (6)].tmap).method); if ((yyvsp[(3) - (6)].tmap).kwargs) { ParmList *kw = (yyvsp[(3) - (6)].tmap).kwargs; code = remove_block(kw, (yyvsp[(6) - (6)].str)); Setattr((yyval.node),"kwargs", (yyvsp[(3) - (6)].tmap).kwargs); } code = code ? code : NewString((yyvsp[(6) - (6)].str)); Setattr((yyval.node),"code", code); Delete(code); appendChild((yyval.node),(yyvsp[(5) - (6)].p)); } } break; case 101: /* Line 1806 of yacc.c */ #line 2402 "parser.y" { (yyval.node) = 0; if ((yyvsp[(3) - (6)].tmap).method) { (yyval.node) = new_node("typemap"); Setattr((yyval.node),"method",(yyvsp[(3) - (6)].tmap).method); appendChild((yyval.node),(yyvsp[(5) - (6)].p)); } } break; case 102: /* Line 1806 of yacc.c */ #line 2410 "parser.y" { (yyval.node) = 0; if ((yyvsp[(3) - (8)].tmap).method) { (yyval.node) = new_node("typemapcopy"); Setattr((yyval.node),"method",(yyvsp[(3) - (8)].tmap).method); Setattr((yyval.node),"pattern", Getattr((yyvsp[(7) - (8)].p),"pattern")); appendChild((yyval.node),(yyvsp[(5) - (8)].p)); } } break; case 103: /* Line 1806 of yacc.c */ #line 2423 "parser.y" { Hash *p; String *name; p = nextSibling((yyvsp[(1) - (1)].node)); if (p && (!Getattr(p,"value"))) { /* this is the deprecated two argument typemap form */ Swig_warning(WARN_DEPRECATED_TYPEMAP_LANG,cparse_file, cparse_line, "Specifying the language name in %%typemap is deprecated - use #ifdef SWIG instead.\n"); /* two argument typemap form */ name = Getattr((yyvsp[(1) - (1)].node),"name"); if (!name || (Strcmp(name,typemap_lang))) { (yyval.tmap).method = 0; (yyval.tmap).kwargs = 0; } else { (yyval.tmap).method = Getattr(p,"name"); (yyval.tmap).kwargs = nextSibling(p); } } else { /* one-argument typemap-form */ (yyval.tmap).method = Getattr((yyvsp[(1) - (1)].node),"name"); (yyval.tmap).kwargs = p; } } break; case 104: /* Line 1806 of yacc.c */ #line 2448 "parser.y" { (yyval.p) = (yyvsp[(1) - (2)].p); set_nextSibling((yyval.p),(yyvsp[(2) - (2)].p)); } break; case 105: /* Line 1806 of yacc.c */ #line 2454 "parser.y" { (yyval.p) = (yyvsp[(2) - (3)].p); set_nextSibling((yyval.p),(yyvsp[(3) - (3)].p)); } break; case 106: /* Line 1806 of yacc.c */ #line 2458 "parser.y" { (yyval.p) = 0;} break; case 107: /* Line 1806 of yacc.c */ #line 2461 "parser.y" { Parm *parm; SwigType_push((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).type); (yyval.p) = new_node("typemapitem"); parm = NewParmWithoutFileLineInfo((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).id); Setattr((yyval.p),"pattern",parm); Setattr((yyval.p),"parms", (yyvsp[(2) - (2)].decl).parms); Delete(parm); /* $$ = NewParmWithoutFileLineInfo($1,$2.id); Setattr($$,"parms",$2.parms); */ } break; case 108: /* Line 1806 of yacc.c */ #line 2472 "parser.y" { (yyval.p) = new_node("typemapitem"); Setattr((yyval.p),"pattern",(yyvsp[(2) - (3)].pl)); /* Setattr($$,"multitype",$2); */ } break; case 109: /* Line 1806 of yacc.c */ #line 2477 "parser.y" { (yyval.p) = new_node("typemapitem"); Setattr((yyval.p),"pattern", (yyvsp[(2) - (6)].pl)); /* Setattr($$,"multitype",$2); */ Setattr((yyval.p),"parms",(yyvsp[(5) - (6)].pl)); } break; case 110: /* Line 1806 of yacc.c */ #line 2490 "parser.y" { (yyval.node) = new_node("types"); Setattr((yyval.node),"parms",(yyvsp[(3) - (5)].pl)); if ((yyvsp[(5) - (5)].str)) Setattr((yyval.node),"convcode",NewString((yyvsp[(5) - (5)].str))); } break; case 111: /* Line 1806 of yacc.c */ #line 2502 "parser.y" { Parm *p, *tp; Node *n; Symtab *tscope = 0; int specialized = 0; int variadic = 0; (yyval.node) = 0; tscope = Swig_symbol_current(); /* Get the current scope */ /* If the class name is qualified, we need to create or lookup namespace entries */ if (!inclass) { (yyvsp[(5) - (9)].str) = resolve_create_node_scope((yyvsp[(5) - (9)].str)); } /* We use the new namespace entry 'nscope' only to emit the template node. The template parameters are resolved in the current 'tscope'. This is closer to the C++ (typedef) behavior. */ n = Swig_cparse_template_locate((yyvsp[(5) - (9)].str),(yyvsp[(7) - (9)].p),tscope); /* Patch the argument types to respect namespaces */ p = (yyvsp[(7) - (9)].p); while (p) { SwigType *value = Getattr(p,"value"); if (!value) { SwigType *ty = Getattr(p,"type"); if (ty) { SwigType *rty = 0; int reduce = template_reduce; if (reduce || !SwigType_ispointer(ty)) { rty = Swig_symbol_typedef_reduce(ty,tscope); if (!reduce) reduce = SwigType_ispointer(rty); } ty = reduce ? Swig_symbol_type_qualify(rty,tscope) : Swig_symbol_type_qualify(ty,tscope); Setattr(p,"type",ty); Delete(ty); Delete(rty); } } else { value = Swig_symbol_type_qualify(value,tscope); Setattr(p,"value",value); Delete(value); } p = nextSibling(p); } /* Look for the template */ { Node *nn = n; Node *linklistend = 0; while (nn) { Node *templnode = 0; if (Strcmp(nodeType(nn),"template") == 0) { int nnisclass = (Strcmp(Getattr(nn,"templatetype"),"class") == 0); /* if not a templated class it is a templated function */ Parm *tparms = Getattr(nn,"templateparms"); if (!tparms) { specialized = 1; } else if (Getattr(tparms,"variadic") && strncmp(Char(Getattr(tparms,"variadic")), "1", 1)==0) { variadic = 1; } if (nnisclass && !variadic && !specialized && (ParmList_len((yyvsp[(7) - (9)].p)) > ParmList_len(tparms))) { Swig_error(cparse_file, cparse_line, "Too many template parameters. Maximum of %d.\n", ParmList_len(tparms)); } else if (nnisclass && !specialized && ((ParmList_len((yyvsp[(7) - (9)].p)) < (ParmList_numrequired(tparms) - (variadic?1:0))))) { /* Variadic parameter is optional */ Swig_error(cparse_file, cparse_line, "Not enough template parameters specified. %d required.\n", (ParmList_numrequired(tparms)-(variadic?1:0)) ); } else if (!nnisclass && ((ParmList_len((yyvsp[(7) - (9)].p)) != ParmList_len(tparms)))) { /* must be an overloaded templated method - ignore it as it is overloaded with a different number of template parameters */ nn = Getattr(nn,"sym:nextSibling"); /* repeat for overloaded templated functions */ continue; } else { String *tname = Copy((yyvsp[(5) - (9)].str)); int def_supplied = 0; /* Expand the template */ Node *templ = Swig_symbol_clookup((yyvsp[(5) - (9)].str),0); Parm *targs = templ ? Getattr(templ,"templateparms") : 0; ParmList *temparms; if (specialized) temparms = CopyParmList((yyvsp[(7) - (9)].p)); else temparms = CopyParmList(tparms); /* Create typedef's and arguments */ p = (yyvsp[(7) - (9)].p); tp = temparms; if (!p && ParmList_len(p) != ParmList_len(temparms)) { /* we have no template parameters supplied in %template for a template that has default args*/ p = tp; def_supplied = 1; } while (p) { String *value = Getattr(p,"value"); if (def_supplied) { Setattr(p,"default","1"); } if (value) { Setattr(tp,"value",value); } else { SwigType *ty = Getattr(p,"type"); if (ty) { Setattr(tp,"type",ty); } Delattr(tp,"value"); } /* fix default arg values */ if (targs) { Parm *pi = temparms; Parm *ti = targs; String *tv = Getattr(tp,"value"); if (!tv) tv = Getattr(tp,"type"); while(pi != tp && ti && pi) { String *name = Getattr(ti,"name"); String *value = Getattr(pi,"value"); if (!value) value = Getattr(pi,"type"); Replaceid(tv, name, value); pi = nextSibling(pi); ti = nextSibling(ti); } } p = nextSibling(p); tp = nextSibling(tp); if (!p && tp) { p = tp; def_supplied = 1; } else if (p && !tp) { /* Variadic template - tp < p */ SWIG_WARN_NODE_BEGIN(nn); Swig_warning(WARN_CPP11_VARIADIC_TEMPLATE,cparse_file, cparse_line,"Only the first variadic template argument is currently supported.\n"); SWIG_WARN_NODE_END(nn); break; } } templnode = copy_node(nn); update_nested_classes(templnode); /* update classes nested withing template */ /* We need to set the node name based on name used to instantiate */ Setattr(templnode,"name",tname); Delete(tname); if (!specialized) { Delattr(templnode,"sym:typename"); } else { Setattr(templnode,"sym:typename","1"); } /* for now, nested %template is allowed only in the same scope as the template declaration */ if ((yyvsp[(3) - (9)].id) && !(nnisclass && ((currentOuterClass && (currentOuterClass != Getattr(nn, "nested:outer"))) ||(extendmode && current_class && (current_class != Getattr(nn, "nested:outer")))))) { /* Comment this out for 1.3.28. We need to re-enable it later but first we need to move %ignore from using %rename to use %feature(ignore). String *symname = Swig_name_make(templnode,0,$3,0,0); */ String *symname = (yyvsp[(3) - (9)].id); Swig_cparse_template_expand(templnode,symname,temparms,tscope); Setattr(templnode,"sym:name",symname); } else { static int cnt = 0; String *nname = NewStringf("__dummy_%d__", cnt++); Swig_cparse_template_expand(templnode,nname,temparms,tscope); Setattr(templnode,"sym:name",nname); Delete(nname); Setattr(templnode,"feature:onlychildren", "typemap,typemapitem,typemapcopy,typedef,types,fragment"); if ((yyvsp[(3) - (9)].id)) { Swig_warning(WARN_PARSE_NESTED_TEMPLATE, cparse_file, cparse_line, "Named nested template instantiations not supported. Processing as if no name was given to %%template().\n"); } } Delattr(templnode,"templatetype"); Setattr(templnode,"template",nn); Setfile(templnode,cparse_file); Setline(templnode,cparse_line); Delete(temparms); if (currentOuterClass) { SetFlag(templnode, "nested"); Setattr(templnode, "nested:outer", currentOuterClass); } add_symbols_copy(templnode); if (Strcmp(nodeType(templnode),"class") == 0) { /* Identify pure abstract methods */ Setattr(templnode,"abstracts", pure_abstracts(firstChild(templnode))); /* Set up inheritance in symbol table */ { Symtab *csyms; List *baselist = Getattr(templnode,"baselist"); csyms = Swig_symbol_current(); Swig_symbol_setscope(Getattr(templnode,"symtab")); if (baselist) { List *bases = Swig_make_inherit_list(Getattr(templnode,"name"),baselist, Namespaceprefix); if (bases) { Iterator s; for (s = First(bases); s.item; s = Next(s)) { Symtab *st = Getattr(s.item,"symtab"); if (st) { Setfile(st,Getfile(s.item)); Setline(st,Getline(s.item)); Swig_symbol_inherit(st); } } Delete(bases); } } Swig_symbol_setscope(csyms); } /* Merge in %extend methods for this class */ /* !!! This may be broken. We may have to add the %extend methods at the beginning of the class */ { String *stmp = 0; String *clsname; Node *am; if (Namespaceprefix) { clsname = stmp = NewStringf("%s::%s", Namespaceprefix, Getattr(templnode,"name")); } else { clsname = Getattr(templnode,"name"); } am = Getattr(Swig_extend_hash(),clsname); if (am) { Symtab *st = Swig_symbol_current(); Swig_symbol_setscope(Getattr(templnode,"symtab")); /* Printf(stdout,"%s: %s %p %p\n", Getattr(templnode,"name"), clsname, Swig_symbol_current(), Getattr(templnode,"symtab")); */ Swig_extend_merge(templnode,am); Swig_symbol_setscope(st); Swig_extend_append_previous(templnode,am); Delattr(Swig_extend_hash(),clsname); } if (stmp) Delete(stmp); } /* Add to classes hash */ if (!classes) classes = NewHash(); if (Namespaceprefix) { String *temp = NewStringf("%s::%s", Namespaceprefix, Getattr(templnode,"name")); Setattr(classes,temp,templnode); Delete(temp); } else { String *qs = Swig_symbol_qualifiedscopename(templnode); Setattr(classes, qs,templnode); Delete(qs); } } } /* all the overloaded templated functions are added into a linked list */ if (nscope_inner) { /* non-global namespace */ if (templnode) { appendChild(nscope_inner,templnode); Delete(templnode); if (nscope) (yyval.node) = nscope; } } else { /* global namespace */ if (!linklistend) { (yyval.node) = templnode; } else { set_nextSibling(linklistend,templnode); Delete(templnode); } linklistend = templnode; } } nn = Getattr(nn,"sym:nextSibling"); /* repeat for overloaded templated functions. If a templated class there will never be a sibling. */ } } Swig_symbol_setscope(tscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } break; case 112: /* Line 1806 of yacc.c */ #line 2788 "parser.y" { Swig_warning(0,cparse_file, cparse_line,"%s\n", (yyvsp[(2) - (2)].id)); (yyval.node) = 0; } break; case 113: /* Line 1806 of yacc.c */ #line 2798 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); if ((yyval.node)) { add_symbols((yyval.node)); default_arguments((yyval.node)); } } break; case 114: /* Line 1806 of yacc.c */ #line 2805 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 115: /* Line 1806 of yacc.c */ #line 2806 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 116: /* Line 1806 of yacc.c */ #line 2810 "parser.y" { if (Strcmp((yyvsp[(2) - (3)].id),"C") == 0) { cparse_externc = 1; } } break; case 117: /* Line 1806 of yacc.c */ #line 2814 "parser.y" { cparse_externc = 0; if (Strcmp((yyvsp[(2) - (6)].id),"C") == 0) { Node *n = firstChild((yyvsp[(5) - (6)].node)); (yyval.node) = new_node("extern"); Setattr((yyval.node),"name",(yyvsp[(2) - (6)].id)); appendChild((yyval.node),n); while (n) { SwigType *decl = Getattr(n,"decl"); if (SwigType_isfunction(decl) && !Equal(Getattr(n, "storage"), "typedef")) { Setattr(n,"storage","externc"); } n = nextSibling(n); } } else { Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", (yyvsp[(2) - (6)].id)); (yyval.node) = new_node("extern"); Setattr((yyval.node),"name",(yyvsp[(2) - (6)].id)); appendChild((yyval.node),firstChild((yyvsp[(5) - (6)].node))); } } break; case 118: /* Line 1806 of yacc.c */ #line 2835 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); SWIG_WARN_NODE_BEGIN((yyval.node)); Swig_warning(WARN_CPP11_LAMBDA, cparse_file, cparse_line, "Lambda expressions and closures are not fully supported yet.\n"); SWIG_WARN_NODE_END((yyval.node)); } break; case 119: /* Line 1806 of yacc.c */ #line 2841 "parser.y" { skip_decl(); (yyval.node) = new_node("using"); Setattr((yyval.node),"name",(yyvsp[(2) - (3)].str)); add_symbols((yyval.node)); SWIG_WARN_NODE_BEGIN((yyval.node)); Swig_warning(WARN_CPP11_ALIAS_DECLARATION, cparse_file, cparse_line, "The 'using' keyword in type aliasing is not fully supported yet.\n"); SWIG_WARN_NODE_END((yyval.node)); (yyval.node) = 0; /* TODO - ignored for now */ } break; case 120: /* Line 1806 of yacc.c */ #line 2852 "parser.y" { skip_decl(); (yyval.node) = new_node("using"); Setattr((yyval.node),"uname",(yyvsp[(8) - (8)].id)); Setattr((yyval.node),"name",(yyvsp[(6) - (8)].str)); add_symbols((yyval.node)); SWIG_WARN_NODE_BEGIN((yyval.node)); Swig_warning(WARN_CPP11_ALIAS_TEMPLATE, cparse_file, cparse_line, "The 'using' keyword in template aliasing is not fully supported yet.\n"); SWIG_WARN_NODE_END((yyval.node)); } break; case 121: /* Line 1806 of yacc.c */ #line 2868 "parser.y" { (yyval.node) = new_node("cdecl"); if ((yyvsp[(4) - (5)].dtype).qualifier) SwigType_push((yyvsp[(3) - (5)].decl).type,(yyvsp[(4) - (5)].dtype).qualifier); Setattr((yyval.node),"type",(yyvsp[(2) - (5)].type)); Setattr((yyval.node),"storage",(yyvsp[(1) - (5)].id)); Setattr((yyval.node),"name",(yyvsp[(3) - (5)].decl).id); Setattr((yyval.node),"decl",(yyvsp[(3) - (5)].decl).type); Setattr((yyval.node),"parms",(yyvsp[(3) - (5)].decl).parms); Setattr((yyval.node),"value",(yyvsp[(4) - (5)].dtype).val); Setattr((yyval.node),"throws",(yyvsp[(4) - (5)].dtype).throws); Setattr((yyval.node),"throw",(yyvsp[(4) - (5)].dtype).throwf); Setattr((yyval.node),"noexcept",(yyvsp[(4) - (5)].dtype).nexcept); if (!(yyvsp[(5) - (5)].node)) { if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr((yyval.node),"code",code); Delete(code); } } else { Node *n = (yyvsp[(5) - (5)].node); /* Inherit attributes */ while (n) { String *type = Copy((yyvsp[(2) - (5)].type)); Setattr(n,"type",type); Setattr(n,"storage",(yyvsp[(1) - (5)].id)); n = nextSibling(n); Delete(type); } } if ((yyvsp[(4) - (5)].dtype).bitfield) { Setattr((yyval.node),"bitfield", (yyvsp[(4) - (5)].dtype).bitfield); } /* Look for "::" declarations (ignored) */ if (Strstr((yyvsp[(3) - (5)].decl).id,"::")) { /* This is a special case. If the scope name of the declaration exactly matches that of the declaration, then we will allow it. Otherwise, delete. */ String *p = Swig_scopename_prefix((yyvsp[(3) - (5)].decl).id); if (p) { if ((Namespaceprefix && Strcmp(p,Namespaceprefix) == 0) || (inclass && Strcmp(p,Classprefix) == 0)) { String *lstr = Swig_scopename_last((yyvsp[(3) - (5)].decl).id); Setattr((yyval.node),"name",lstr); Delete(lstr); set_nextSibling((yyval.node),(yyvsp[(5) - (5)].node)); } else { Delete((yyval.node)); (yyval.node) = (yyvsp[(5) - (5)].node); } Delete(p); } else { Delete((yyval.node)); (yyval.node) = (yyvsp[(5) - (5)].node); } } else { set_nextSibling((yyval.node),(yyvsp[(5) - (5)].node)); } } break; case 122: /* Line 1806 of yacc.c */ #line 2928 "parser.y" { (yyval.node) = new_node("cdecl"); if ((yyvsp[(6) - (7)].dtype).qualifier) SwigType_push((yyvsp[(3) - (7)].decl).type,(yyvsp[(6) - (7)].dtype).qualifier); Setattr((yyval.node),"type",(yyvsp[(5) - (7)].node)); Setattr((yyval.node),"storage",(yyvsp[(1) - (7)].id)); Setattr((yyval.node),"name",(yyvsp[(3) - (7)].decl).id); Setattr((yyval.node),"decl",(yyvsp[(3) - (7)].decl).type); Setattr((yyval.node),"parms",(yyvsp[(3) - (7)].decl).parms); Setattr((yyval.node),"value",(yyvsp[(6) - (7)].dtype).val); Setattr((yyval.node),"throws",(yyvsp[(6) - (7)].dtype).throws); Setattr((yyval.node),"throw",(yyvsp[(6) - (7)].dtype).throwf); Setattr((yyval.node),"noexcept",(yyvsp[(6) - (7)].dtype).nexcept); if (!(yyvsp[(7) - (7)].node)) { if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr((yyval.node),"code",code); Delete(code); } } else { Node *n = (yyvsp[(7) - (7)].node); while (n) { String *type = Copy((yyvsp[(5) - (7)].node)); Setattr(n,"type",type); Setattr(n,"storage",(yyvsp[(1) - (7)].id)); n = nextSibling(n); Delete(type); } } if ((yyvsp[(6) - (7)].dtype).bitfield) { Setattr((yyval.node),"bitfield", (yyvsp[(6) - (7)].dtype).bitfield); } if (Strstr((yyvsp[(3) - (7)].decl).id,"::")) { String *p = Swig_scopename_prefix((yyvsp[(3) - (7)].decl).id); if (p) { if ((Namespaceprefix && Strcmp(p,Namespaceprefix) == 0) || (inclass && Strcmp(p,Classprefix) == 0)) { String *lstr = Swig_scopename_last((yyvsp[(3) - (7)].decl).id); Setattr((yyval.node),"name",lstr); Delete(lstr); set_nextSibling((yyval.node),(yyvsp[(7) - (7)].node)); } else { Delete((yyval.node)); (yyval.node) = (yyvsp[(7) - (7)].node); } Delete(p); } else { Delete((yyval.node)); (yyval.node) = (yyvsp[(7) - (7)].node); } } else { set_nextSibling((yyval.node),(yyvsp[(7) - (7)].node)); } } break; case 123: /* Line 1806 of yacc.c */ #line 2986 "parser.y" { (yyval.node) = 0; Clear(scanner_ccode); } break; case 124: /* Line 1806 of yacc.c */ #line 2990 "parser.y" { (yyval.node) = new_node("cdecl"); if ((yyvsp[(3) - (4)].dtype).qualifier) SwigType_push((yyvsp[(2) - (4)].decl).type,(yyvsp[(3) - (4)].dtype).qualifier); Setattr((yyval.node),"name",(yyvsp[(2) - (4)].decl).id); Setattr((yyval.node),"decl",(yyvsp[(2) - (4)].decl).type); Setattr((yyval.node),"parms",(yyvsp[(2) - (4)].decl).parms); Setattr((yyval.node),"value",(yyvsp[(3) - (4)].dtype).val); Setattr((yyval.node),"throws",(yyvsp[(3) - (4)].dtype).throws); Setattr((yyval.node),"throw",(yyvsp[(3) - (4)].dtype).throwf); Setattr((yyval.node),"noexcept",(yyvsp[(3) - (4)].dtype).nexcept); if ((yyvsp[(3) - (4)].dtype).bitfield) { Setattr((yyval.node),"bitfield", (yyvsp[(3) - (4)].dtype).bitfield); } if (!(yyvsp[(4) - (4)].node)) { if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr((yyval.node),"code",code); Delete(code); } } else { set_nextSibling((yyval.node),(yyvsp[(4) - (4)].node)); } } break; case 125: /* Line 1806 of yacc.c */ #line 3013 "parser.y" { skip_balanced('{','}'); (yyval.node) = 0; } break; case 126: /* Line 1806 of yacc.c */ #line 3019 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); (yyval.dtype).qualifier = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 127: /* Line 1806 of yacc.c */ #line 3026 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); (yyval.dtype).qualifier = (yyvsp[(1) - (2)].str); (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 128: /* Line 1806 of yacc.c */ #line 3033 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); (yyval.dtype).qualifier = 0; (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf; (yyval.dtype).nexcept = (yyvsp[(1) - (2)].dtype).nexcept; } break; case 129: /* Line 1806 of yacc.c */ #line 3040 "parser.y" { (yyval.dtype) = (yyvsp[(3) - (3)].dtype); (yyval.dtype).qualifier = (yyvsp[(1) - (3)].str); (yyval.dtype).throws = (yyvsp[(2) - (3)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(2) - (3)].dtype).throwf; (yyval.dtype).nexcept = (yyvsp[(2) - (3)].dtype).nexcept; } break; case 130: /* Line 1806 of yacc.c */ #line 3049 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].type); } break; case 131: /* Line 1806 of yacc.c */ #line 3050 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].type); } break; case 132: /* Line 1806 of yacc.c */ #line 3051 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].type); } break; case 133: /* Line 1806 of yacc.c */ #line 3052 "parser.y" { (yyval.node) = NewStringf("%s%s",(yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].id)); } break; case 134: /* Line 1806 of yacc.c */ #line 3053 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].type); } break; case 135: /* Line 1806 of yacc.c */ #line 3054 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].str); } break; case 136: /* Line 1806 of yacc.c */ #line 3055 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].type); } break; case 137: /* Line 1806 of yacc.c */ #line 3066 "parser.y" { (yyval.node) = new_node("lambda"); Setattr((yyval.node),"name",(yyvsp[(3) - (11)].str)); add_symbols((yyval.node)); } break; case 138: /* Line 1806 of yacc.c */ #line 3071 "parser.y" { (yyval.node) = new_node("lambda"); Setattr((yyval.node),"name",(yyvsp[(3) - (13)].str)); add_symbols((yyval.node)); } break; case 139: /* Line 1806 of yacc.c */ #line 3076 "parser.y" { (yyval.node) = new_node("lambda"); Setattr((yyval.node),"name",(yyvsp[(3) - (7)].str)); add_symbols((yyval.node)); } break; case 140: /* Line 1806 of yacc.c */ #line 3083 "parser.y" { skip_balanced('[',']'); (yyval.node) = 0; } break; case 141: /* Line 1806 of yacc.c */ #line 3089 "parser.y" { skip_balanced('{','}'); (yyval.node) = 0; } break; case 142: /* Line 1806 of yacc.c */ #line 3094 "parser.y" { (yyval.pl) = 0; } break; case 143: /* Line 1806 of yacc.c */ #line 3097 "parser.y" { skip_balanced('(',')'); } break; case 144: /* Line 1806 of yacc.c */ #line 3099 "parser.y" { (yyval.pl) = 0; } break; case 145: /* Line 1806 of yacc.c */ #line 3110 "parser.y" { (yyval.node) = (char *)"enum"; } break; case 146: /* Line 1806 of yacc.c */ #line 3113 "parser.y" { (yyval.node) = (char *)"enum class"; } break; case 147: /* Line 1806 of yacc.c */ #line 3116 "parser.y" { (yyval.node) = (char *)"enum struct"; } break; case 148: /* Line 1806 of yacc.c */ #line 3125 "parser.y" { (yyval.node) = (yyvsp[(2) - (2)].type); } break; case 149: /* Line 1806 of yacc.c */ #line 3128 "parser.y" { (yyval.node) = 0; } break; case 150: /* Line 1806 of yacc.c */ #line 3135 "parser.y" { SwigType *ty = 0; int scopedenum = (yyvsp[(3) - (5)].id) && !Equal((yyvsp[(2) - (5)].node), "enum"); (yyval.node) = new_node("enumforward"); ty = NewStringf("enum %s", (yyvsp[(3) - (5)].id)); Setattr((yyval.node),"enumkey",(yyvsp[(2) - (5)].node)); if (scopedenum) SetFlag((yyval.node), "scopedenum"); Setattr((yyval.node),"name",(yyvsp[(3) - (5)].id)); Setattr((yyval.node),"inherit",(yyvsp[(4) - (5)].node)); Setattr((yyval.node),"type",ty); Setattr((yyval.node),"sym:weak", "1"); add_symbols((yyval.node)); } break; case 151: /* Line 1806 of yacc.c */ #line 3157 "parser.y" { SwigType *ty = 0; int scopedenum = (yyvsp[(3) - (8)].id) && !Equal((yyvsp[(2) - (8)].node), "enum"); (yyval.node) = new_node("enum"); ty = NewStringf("enum %s", (yyvsp[(3) - (8)].id)); Setattr((yyval.node),"enumkey",(yyvsp[(2) - (8)].node)); if (scopedenum) SetFlag((yyval.node), "scopedenum"); Setattr((yyval.node),"name",(yyvsp[(3) - (8)].id)); Setattr((yyval.node),"inherit",(yyvsp[(4) - (8)].node)); Setattr((yyval.node),"type",ty); appendChild((yyval.node),(yyvsp[(6) - (8)].node)); add_symbols((yyval.node)); /* Add to tag space */ if (scopedenum) { Swig_symbol_newscope(); Swig_symbol_setscopename((yyvsp[(3) - (8)].id)); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } add_symbols((yyvsp[(6) - (8)].node)); /* Add enum values to appropriate enum or enum class scope */ if (scopedenum) { Setattr((yyval.node),"symtab", Swig_symbol_popscope()); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } } break; case 152: /* Line 1806 of yacc.c */ #line 3186 "parser.y" { Node *n; SwigType *ty = 0; String *unnamed = 0; int unnamedinstance = 0; int scopedenum = (yyvsp[(3) - (10)].id) && !Equal((yyvsp[(2) - (10)].node), "enum"); (yyval.node) = new_node("enum"); Setattr((yyval.node),"enumkey",(yyvsp[(2) - (10)].node)); if (scopedenum) SetFlag((yyval.node), "scopedenum"); Setattr((yyval.node),"inherit",(yyvsp[(4) - (10)].node)); if ((yyvsp[(3) - (10)].id)) { Setattr((yyval.node),"name",(yyvsp[(3) - (10)].id)); ty = NewStringf("enum %s", (yyvsp[(3) - (10)].id)); } else if ((yyvsp[(8) - (10)].decl).id) { unnamed = make_unnamed(); ty = NewStringf("enum %s", unnamed); Setattr((yyval.node),"unnamed",unnamed); /* name is not set for unnamed enum instances, e.g. enum { foo } Instance; */ if ((yyvsp[(1) - (10)].id) && Cmp((yyvsp[(1) - (10)].id),"typedef") == 0) { Setattr((yyval.node),"name",(yyvsp[(8) - (10)].decl).id); } else { unnamedinstance = 1; } Setattr((yyval.node),"storage",(yyvsp[(1) - (10)].id)); } if ((yyvsp[(8) - (10)].decl).id && Cmp((yyvsp[(1) - (10)].id),"typedef") == 0) { Setattr((yyval.node),"tdname",(yyvsp[(8) - (10)].decl).id); Setattr((yyval.node),"allows_typedef","1"); } appendChild((yyval.node),(yyvsp[(6) - (10)].node)); n = new_node("cdecl"); Setattr(n,"type",ty); Setattr(n,"name",(yyvsp[(8) - (10)].decl).id); Setattr(n,"storage",(yyvsp[(1) - (10)].id)); Setattr(n,"decl",(yyvsp[(8) - (10)].decl).type); Setattr(n,"parms",(yyvsp[(8) - (10)].decl).parms); Setattr(n,"unnamed",unnamed); if (unnamedinstance) { SwigType *cty = NewString("enum "); Setattr((yyval.node),"type",cty); SetFlag((yyval.node),"unnamedinstance"); SetFlag(n,"unnamedinstance"); Delete(cty); } if ((yyvsp[(10) - (10)].node)) { Node *p = (yyvsp[(10) - (10)].node); set_nextSibling(n,p); while (p) { SwigType *cty = Copy(ty); Setattr(p,"type",cty); Setattr(p,"unnamed",unnamed); Setattr(p,"storage",(yyvsp[(1) - (10)].id)); Delete(cty); p = nextSibling(p); } } else { if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr(n,"code",code); Delete(code); } } /* Ensure that typedef enum ABC {foo} XYZ; uses XYZ for sym:name, like structs. * Note that class_rename/yyrename are bit of a mess so used this simple approach to change the name. */ if ((yyvsp[(8) - (10)].decl).id && (yyvsp[(3) - (10)].id) && Cmp((yyvsp[(1) - (10)].id),"typedef") == 0) { String *name = NewString((yyvsp[(8) - (10)].decl).id); Setattr((yyval.node), "parser:makename", name); Delete(name); } add_symbols((yyval.node)); /* Add enum to tag space */ set_nextSibling((yyval.node),n); Delete(n); if (scopedenum) { Swig_symbol_newscope(); Swig_symbol_setscopename((yyvsp[(3) - (10)].id)); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } add_symbols((yyvsp[(6) - (10)].node)); /* Add enum values to appropriate enum or enum class scope */ if (scopedenum) { Setattr((yyval.node),"symtab", Swig_symbol_popscope()); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } add_symbols(n); Delete(unnamed); } break; case 153: /* Line 1806 of yacc.c */ #line 3284 "parser.y" { /* This is a sick hack. If the ctor_end has parameters, and the parms parameter only has 1 parameter, this could be a declaration of the form: type (id)(parms) Otherwise it's an error. */ int err = 0; (yyval.node) = 0; if ((ParmList_len((yyvsp[(4) - (6)].pl)) == 1) && (!Swig_scopename_check((yyvsp[(2) - (6)].type)))) { SwigType *ty = Getattr((yyvsp[(4) - (6)].pl),"type"); String *name = Getattr((yyvsp[(4) - (6)].pl),"name"); err = 1; if (!name) { (yyval.node) = new_node("cdecl"); Setattr((yyval.node),"type",(yyvsp[(2) - (6)].type)); Setattr((yyval.node),"storage",(yyvsp[(1) - (6)].id)); Setattr((yyval.node),"name",ty); if ((yyvsp[(6) - (6)].decl).have_parms) { SwigType *decl = NewStringEmpty(); SwigType_add_function(decl,(yyvsp[(6) - (6)].decl).parms); Setattr((yyval.node),"decl",decl); Setattr((yyval.node),"parms",(yyvsp[(6) - (6)].decl).parms); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr((yyval.node),"code",code); Delete(code); } } if ((yyvsp[(6) - (6)].decl).defarg) { Setattr((yyval.node),"value",(yyvsp[(6) - (6)].decl).defarg); } Setattr((yyval.node),"throws",(yyvsp[(6) - (6)].decl).throws); Setattr((yyval.node),"throw",(yyvsp[(6) - (6)].decl).throwf); Setattr((yyval.node),"noexcept",(yyvsp[(6) - (6)].decl).nexcept); err = 0; } } if (err) { Swig_error(cparse_file,cparse_line,"Syntax error in input(2).\n"); exit(1); } } break; case 154: /* Line 1806 of yacc.c */ #line 3336 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 155: /* Line 1806 of yacc.c */ #line 3337 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 156: /* Line 1806 of yacc.c */ #line 3338 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 157: /* Line 1806 of yacc.c */ #line 3339 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 158: /* Line 1806 of yacc.c */ #line 3340 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 159: /* Line 1806 of yacc.c */ #line 3341 "parser.y" { (yyval.node) = 0; } break; case 160: /* Line 1806 of yacc.c */ #line 3346 "parser.y" { String *prefix; List *bases = 0; Node *scope = 0; String *code; (yyval.node) = new_node("class"); Setline((yyval.node),cparse_start_line); Setattr((yyval.node),"kind",(yyvsp[(2) - (5)].id)); if ((yyvsp[(4) - (5)].bases)) { Setattr((yyval.node),"baselist", Getattr((yyvsp[(4) - (5)].bases),"public")); Setattr((yyval.node),"protectedbaselist", Getattr((yyvsp[(4) - (5)].bases),"protected")); Setattr((yyval.node),"privatebaselist", Getattr((yyvsp[(4) - (5)].bases),"private")); } Setattr((yyval.node),"allows_typedef","1"); /* preserve the current scope */ Setattr((yyval.node),"prev_symtab",Swig_symbol_current()); /* If the class name is qualified. We need to create or lookup namespace/scope entries */ scope = resolve_create_node_scope((yyvsp[(3) - (5)].str)); /* save nscope_inner to the class - it may be overwritten in nested classes*/ Setattr((yyval.node), "nested:innerscope", nscope_inner); Setattr((yyval.node), "nested:nscope", nscope); Setfile(scope,cparse_file); Setline(scope,cparse_line); (yyvsp[(3) - (5)].str) = scope; Setattr((yyval.node),"name",(yyvsp[(3) - (5)].str)); if (currentOuterClass) { SetFlag((yyval.node), "nested"); Setattr((yyval.node), "nested:outer", currentOuterClass); set_access_mode((yyval.node)); } Swig_features_get(Swig_cparse_features(), Namespaceprefix, Getattr((yyval.node), "name"), 0, (yyval.node)); /* save yyrename to the class attribute, to be used later in add_symbols()*/ Setattr((yyval.node), "class_rename", make_name((yyval.node), (yyvsp[(3) - (5)].str), 0)); Setattr((yyval.node), "Classprefix", (yyvsp[(3) - (5)].str)); Classprefix = NewString((yyvsp[(3) - (5)].str)); /* Deal with inheritance */ if ((yyvsp[(4) - (5)].bases)) bases = Swig_make_inherit_list((yyvsp[(3) - (5)].str),Getattr((yyvsp[(4) - (5)].bases),"public"),Namespaceprefix); prefix = SwigType_istemplate_templateprefix((yyvsp[(3) - (5)].str)); if (prefix) { String *fbase, *tbase; if (Namespaceprefix) { fbase = NewStringf("%s::%s", Namespaceprefix,(yyvsp[(3) - (5)].str)); tbase = NewStringf("%s::%s", Namespaceprefix, prefix); } else { fbase = Copy((yyvsp[(3) - (5)].str)); tbase = Copy(prefix); } Swig_name_inherit(tbase,fbase); Delete(fbase); Delete(tbase); } if (strcmp((yyvsp[(2) - (5)].id),"class") == 0) { cplus_mode = CPLUS_PRIVATE; } else { cplus_mode = CPLUS_PUBLIC; } if (!cparse_cplusplus) { set_scope_to_global(); } Swig_symbol_newscope(); Swig_symbol_setscopename((yyvsp[(3) - (5)].str)); Swig_inherit_base_symbols(bases); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); cparse_start_line = cparse_line; /* If there are active template parameters, we need to make sure they are placed in the class symbol table so we can catch shadows */ if (template_parameters) { Parm *tp = template_parameters; while(tp) { String *tpname = Copy(Getattr(tp,"name")); Node *tn = new_node("templateparm"); Setattr(tn,"name",tpname); Swig_symbol_cadd(tpname,tn); tp = nextSibling(tp); Delete(tpname); } } Delete(prefix); inclass = 1; currentOuterClass = (yyval.node); if (cparse_cplusplusout) { /* save the structure declaration to declare it in global scope for C++ to see */ code = get_raw_text_balanced('{', '}'); Setattr((yyval.node), "code", code); Delete(code); } } break; case 161: /* Line 1806 of yacc.c */ #line 3439 "parser.y" { Node *p; SwigType *ty; Symtab *cscope; Node *am = 0; String *scpname = 0; (void) (yyvsp[(6) - (9)].node); (yyval.node) = currentOuterClass; currentOuterClass = Getattr((yyval.node), "nested:outer"); nscope_inner = Getattr((yyval.node), "nested:innerscope"); nscope = Getattr((yyval.node), "nested:nscope"); Delattr((yyval.node), "nested:innerscope"); Delattr((yyval.node), "nested:nscope"); if (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0) /* actual parent class for this class */ Setattr((yyval.node), "nested:outer", nscope_inner); if (!currentOuterClass) inclass = 0; cscope = Getattr((yyval.node), "prev_symtab"); Delattr((yyval.node), "prev_symtab"); /* Check for pure-abstract class */ Setattr((yyval.node),"abstracts", pure_abstracts((yyvsp[(7) - (9)].node))); /* This bit of code merges in a previously defined %extend directive (if any) */ { String *clsname = Swig_symbol_qualifiedscopename(0); am = Getattr(Swig_extend_hash(), clsname); if (am) { Swig_extend_merge((yyval.node), am); Delattr(Swig_extend_hash(), clsname); } Delete(clsname); } if (!classes) classes = NewHash(); scpname = Swig_symbol_qualifiedscopename(0); Setattr(classes, scpname, (yyval.node)); appendChild((yyval.node), (yyvsp[(7) - (9)].node)); if (am) Swig_extend_append_previous((yyval.node), am); p = (yyvsp[(9) - (9)].node); if (p && !nscope_inner) { if (!cparse_cplusplus && currentOuterClass) appendChild(currentOuterClass, p); else appendSibling((yyval.node), p); } if (nscope_inner) { ty = NewString(scpname); /* if the class is declared out of scope, let the declarator use fully qualified type*/ } else if (cparse_cplusplus && !cparse_externc) { ty = NewString((yyvsp[(3) - (9)].str)); } else { ty = NewStringf("%s %s", (yyvsp[(2) - (9)].id), (yyvsp[(3) - (9)].str)); } while (p) { Setattr(p, "storage", (yyvsp[(1) - (9)].id)); Setattr(p, "type" ,ty); if (!cparse_cplusplus && currentOuterClass && (!Getattr(currentOuterClass, "name"))) { SetFlag(p, "hasconsttype"); SetFlag(p, "feature:immutable"); } p = nextSibling(p); } if ((yyvsp[(9) - (9)].node) && Cmp((yyvsp[(1) - (9)].id),"typedef") == 0) add_typedef_name((yyval.node), (yyvsp[(9) - (9)].node), (yyvsp[(3) - (9)].str), cscope, scpname); Delete(scpname); if (cplus_mode != CPLUS_PUBLIC) { /* we 'open' the class at the end, to allow %template to add new members */ Node *pa = new_node("access"); Setattr(pa, "kind", "public"); cplus_mode = CPLUS_PUBLIC; appendChild((yyval.node), pa); Delete(pa); } if (currentOuterClass) restore_access_mode((yyval.node)); Setattr((yyval.node), "symtab", Swig_symbol_popscope()); Classprefix = Getattr((yyval.node), "Classprefix"); Delattr((yyval.node), "Classprefix"); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); if (cplus_mode == CPLUS_PRIVATE) { (yyval.node) = 0; /* skip private nested classes */ } else if (cparse_cplusplus && currentOuterClass && ignore_nested_classes && !GetFlag((yyval.node), "feature:flatnested")) { (yyval.node) = nested_forward_declaration((yyvsp[(1) - (9)].id), (yyvsp[(2) - (9)].id), (yyvsp[(3) - (9)].str), Copy((yyvsp[(3) - (9)].str)), (yyvsp[(9) - (9)].node)); } else if (nscope_inner) { /* this is tricky */ /* we add the declaration in the original namespace */ appendChild(nscope_inner, (yyval.node)); Swig_symbol_setscope(Getattr(nscope_inner, "symtab")); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); yyrename = Copy(Getattr((yyval.node), "class_rename")); add_symbols((yyval.node)); Delattr((yyval.node), "class_rename"); /* but the variable definition in the current scope */ Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols((yyvsp[(9) - (9)].node)); if (nscope) { (yyval.node) = nscope; /* here we return recreated namespace tower instead of the class itself */ if ((yyvsp[(9) - (9)].node)) { appendSibling((yyval.node), (yyvsp[(9) - (9)].node)); } } else if (!SwigType_istemplate(ty) && template_parameters == 0) { /* for tempalte we need the class itself */ (yyval.node) = (yyvsp[(9) - (9)].node); } } else { Delete(yyrename); yyrename = 0; if (!cparse_cplusplus && currentOuterClass) { /* nested C structs go into global scope*/ Node *outer = currentOuterClass; while (Getattr(outer, "nested:outer")) outer = Getattr(outer, "nested:outer"); appendSibling(outer, (yyval.node)); add_symbols((yyvsp[(9) - (9)].node)); set_scope_to_global(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); yyrename = Copy(Getattr((yyval.node), "class_rename")); add_symbols((yyval.node)); if (!cparse_cplusplusout) Delattr((yyval.node), "nested:outer"); Delattr((yyval.node), "class_rename"); (yyval.node) = 0; } else { yyrename = Copy(Getattr((yyval.node), "class_rename")); add_symbols((yyval.node)); add_symbols((yyvsp[(9) - (9)].node)); Delattr((yyval.node), "class_rename"); } } Delete(ty); Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } break; case 162: /* Line 1806 of yacc.c */ #line 3585 "parser.y" { String *unnamed; String *code; unnamed = make_unnamed(); (yyval.node) = new_node("class"); Setline((yyval.node),cparse_start_line); Setattr((yyval.node),"kind",(yyvsp[(2) - (4)].id)); if ((yyvsp[(3) - (4)].bases)) { Setattr((yyval.node),"baselist", Getattr((yyvsp[(3) - (4)].bases),"public")); Setattr((yyval.node),"protectedbaselist", Getattr((yyvsp[(3) - (4)].bases),"protected")); Setattr((yyval.node),"privatebaselist", Getattr((yyvsp[(3) - (4)].bases),"private")); } Setattr((yyval.node),"storage",(yyvsp[(1) - (4)].id)); Setattr((yyval.node),"unnamed",unnamed); Setattr((yyval.node),"allows_typedef","1"); if (currentOuterClass) { SetFlag((yyval.node), "nested"); Setattr((yyval.node), "nested:outer", currentOuterClass); set_access_mode((yyval.node)); } Swig_features_get(Swig_cparse_features(), Namespaceprefix, 0, 0, (yyval.node)); /* save yyrename to the class attribute, to be used later in add_symbols()*/ Setattr((yyval.node), "class_rename", make_name((yyval.node),0,0)); if (strcmp((yyvsp[(2) - (4)].id),"class") == 0) { cplus_mode = CPLUS_PRIVATE; } else { cplus_mode = CPLUS_PUBLIC; } Swig_symbol_newscope(); cparse_start_line = cparse_line; currentOuterClass = (yyval.node); inclass = 1; Classprefix = NewStringEmpty(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); /* save the structure declaration to make a typedef for it later*/ code = get_raw_text_balanced('{', '}'); Setattr((yyval.node), "code", code); Delete(code); } break; case 163: /* Line 1806 of yacc.c */ #line 3624 "parser.y" { String *unnamed; List *bases = 0; String *name = 0; Node *n; Classprefix = 0; (yyval.node) = currentOuterClass; currentOuterClass = Getattr((yyval.node), "nested:outer"); if (!currentOuterClass) inclass = 0; else restore_access_mode((yyval.node)); unnamed = Getattr((yyval.node),"unnamed"); /* Check for pure-abstract class */ Setattr((yyval.node),"abstracts", pure_abstracts((yyvsp[(6) - (8)].node))); n = (yyvsp[(8) - (8)].node); if (cparse_cplusplus && currentOuterClass && ignore_nested_classes && !GetFlag((yyval.node), "feature:flatnested")) { String *name = n ? Copy(Getattr(n, "name")) : 0; (yyval.node) = nested_forward_declaration((yyvsp[(1) - (8)].id), (yyvsp[(2) - (8)].id), 0, name, n); Swig_symbol_popscope(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } else if (n) { appendSibling((yyval.node),n); /* If a proper typedef name was given, we'll use it to set the scope name */ name = try_to_find_a_name_for_unnamed_structure((yyvsp[(1) - (8)].id), n); if (name) { String *scpname = 0; SwigType *ty; Setattr((yyval.node),"tdname",name); Setattr((yyval.node),"name",name); Swig_symbol_setscopename(name); if ((yyvsp[(3) - (8)].bases)) bases = Swig_make_inherit_list(name,Getattr((yyvsp[(3) - (8)].bases),"public"),Namespaceprefix); Swig_inherit_base_symbols(bases); /* If a proper name was given, we use that as the typedef, not unnamed */ Clear(unnamed); Append(unnamed, name); if (cparse_cplusplus && !cparse_externc) { ty = NewString(name); } else { ty = NewStringf("%s %s", (yyvsp[(2) - (8)].id),name); } while (n) { Setattr(n,"storage",(yyvsp[(1) - (8)].id)); Setattr(n, "type", ty); if (!cparse_cplusplus && currentOuterClass && (!Getattr(currentOuterClass, "name"))) { SetFlag(n,"hasconsttype"); SetFlag(n,"feature:immutable"); } n = nextSibling(n); } n = (yyvsp[(8) - (8)].node); /* Check for previous extensions */ { String *clsname = Swig_symbol_qualifiedscopename(0); Node *am = Getattr(Swig_extend_hash(),clsname); if (am) { /* Merge the extension into the symbol table */ Swig_extend_merge((yyval.node),am); Swig_extend_append_previous((yyval.node),am); Delattr(Swig_extend_hash(),clsname); } Delete(clsname); } if (!classes) classes = NewHash(); scpname = Swig_symbol_qualifiedscopename(0); Setattr(classes,scpname,(yyval.node)); Delete(scpname); } else { /* no suitable name was found for a struct */ Setattr((yyval.node), "nested:unnamed", Getattr(n, "name")); /* save the name of the first declarator for later use in name generation*/ while (n) { /* attach unnamed struct to the declarators, so that they would receive proper type later*/ Setattr(n, "nested:unnamedtype", (yyval.node)); Setattr(n, "storage", (yyvsp[(1) - (8)].id)); n = nextSibling(n); } n = (yyvsp[(8) - (8)].node); Swig_symbol_setscopename(""); } appendChild((yyval.node),(yyvsp[(6) - (8)].node)); /* Pop the scope */ Setattr((yyval.node),"symtab",Swig_symbol_popscope()); if (name) { Delete(yyrename); yyrename = Copy(Getattr((yyval.node), "class_rename")); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols((yyval.node)); add_symbols(n); Delattr((yyval.node), "class_rename"); }else if (cparse_cplusplus) (yyval.node) = 0; /* ignore unnamed structs for C++ */ Delete(unnamed); } else { /* unnamed struct w/o declarator*/ Swig_symbol_popscope(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols((yyvsp[(6) - (8)].node)); Delete((yyval.node)); (yyval.node) = (yyvsp[(6) - (8)].node); /* pass member list to outer class/namespace (instead of self)*/ } } break; case 164: /* Line 1806 of yacc.c */ #line 3730 "parser.y" { (yyval.node) = 0; } break; case 165: /* Line 1806 of yacc.c */ #line 3731 "parser.y" { (yyval.node) = new_node("cdecl"); Setattr((yyval.node),"name",(yyvsp[(1) - (3)].decl).id); Setattr((yyval.node),"decl",(yyvsp[(1) - (3)].decl).type); Setattr((yyval.node),"parms",(yyvsp[(1) - (3)].decl).parms); set_nextSibling((yyval.node),(yyvsp[(3) - (3)].node)); } break; case 166: /* Line 1806 of yacc.c */ #line 3743 "parser.y" { if ((yyvsp[(1) - (4)].id) && (Strcmp((yyvsp[(1) - (4)].id),"friend") == 0)) { /* Ignore */ (yyval.node) = 0; } else { (yyval.node) = new_node("classforward"); Setattr((yyval.node),"kind",(yyvsp[(2) - (4)].id)); Setattr((yyval.node),"name",(yyvsp[(3) - (4)].str)); Setattr((yyval.node),"sym:weak", "1"); add_symbols((yyval.node)); } } break; case 167: /* Line 1806 of yacc.c */ #line 3761 "parser.y" { if (currentOuterClass) Setattr(currentOuterClass, "template_parameters", template_parameters); template_parameters = (yyvsp[(3) - (4)].tparms); } break; case 168: /* Line 1806 of yacc.c */ #line 3765 "parser.y" { String *tname = 0; int error = 0; /* check if we get a namespace node with a class declaration, and retrieve the class */ Symtab *cscope = Swig_symbol_current(); Symtab *sti = 0; Node *ntop = (yyvsp[(6) - (6)].node); Node *ni = ntop; SwigType *ntype = ni ? nodeType(ni) : 0; while (ni && Strcmp(ntype,"namespace") == 0) { sti = Getattr(ni,"symtab"); ni = firstChild(ni); ntype = nodeType(ni); } if (sti) { Swig_symbol_setscope(sti); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); (yyvsp[(6) - (6)].node) = ni; } (yyval.node) = (yyvsp[(6) - (6)].node); if ((yyval.node)) tname = Getattr((yyval.node),"name"); /* Check if the class is a template specialization */ if (((yyval.node)) && (Strchr(tname,'<')) && (!is_operator(tname))) { /* If a specialization. Check if defined. */ Node *tempn = 0; { String *tbase = SwigType_templateprefix(tname); tempn = Swig_symbol_clookup_local(tbase,0); if (!tempn || (Strcmp(nodeType(tempn),"template") != 0)) { SWIG_WARN_NODE_BEGIN(tempn); Swig_warning(WARN_PARSE_TEMPLATE_SP_UNDEF, Getfile((yyval.node)),Getline((yyval.node)),"Specialization of non-template '%s'.\n", tbase); SWIG_WARN_NODE_END(tempn); tempn = 0; error = 1; } Delete(tbase); } Setattr((yyval.node),"specialization","1"); Setattr((yyval.node),"templatetype",nodeType((yyval.node))); set_nodeType((yyval.node),"template"); /* Template partial specialization */ if (tempn && ((yyvsp[(3) - (6)].tparms)) && ((yyvsp[(6) - (6)].node))) { List *tlist; String *targs = SwigType_templateargs(tname); tlist = SwigType_parmlist(targs); /* Printf(stdout,"targs = '%s' %s\n", targs, tlist); */ if (!Getattr((yyval.node),"sym:weak")) { Setattr((yyval.node),"sym:typename","1"); } if (Len(tlist) != ParmList_len(Getattr(tempn,"templateparms"))) { Swig_error(Getfile((yyval.node)),Getline((yyval.node)),"Inconsistent argument count in template partial specialization. %d %d\n", Len(tlist), ParmList_len(Getattr(tempn,"templateparms"))); } else { /* This code builds the argument list for the partial template specialization. This is a little hairy, but the idea is as follows: $3 contains a list of arguments supplied for the template. For example template. tlist is a list of the specialization arguments--which may be different. For example class. tp is a copy of the arguments in the original template definition. The patching algorithm walks through the list of supplied arguments ($3), finds the position in the specialization arguments (tlist), and then patches the name in the argument list of the original template. */ { String *pn; Parm *p, *p1; int i, nargs; Parm *tp = CopyParmList(Getattr(tempn,"templateparms")); nargs = Len(tlist); p = (yyvsp[(3) - (6)].tparms); while (p) { for (i = 0; i < nargs; i++){ pn = Getattr(p,"name"); if (Strcmp(pn,SwigType_base(Getitem(tlist,i))) == 0) { int j; Parm *p1 = tp; for (j = 0; j < i; j++) { p1 = nextSibling(p1); } Setattr(p1,"name",pn); Setattr(p1,"partialarg","1"); } } p = nextSibling(p); } p1 = tp; i = 0; while (p1) { if (!Getattr(p1,"partialarg")) { Delattr(p1,"name"); Setattr(p1,"type", Getitem(tlist,i)); } i++; p1 = nextSibling(p1); } Setattr((yyval.node),"templateparms",tp); Delete(tp); } #if 0 /* Patch the parameter list */ if (tempn) { Parm *p,*p1; ParmList *tp = CopyParmList(Getattr(tempn,"templateparms")); p = (yyvsp[(3) - (6)].tparms); p1 = tp; while (p && p1) { String *pn = Getattr(p,"name"); Printf(stdout,"pn = '%s'\n", pn); if (pn) Setattr(p1,"name",pn); else Delattr(p1,"name"); pn = Getattr(p,"type"); if (pn) Setattr(p1,"type",pn); p = nextSibling(p); p1 = nextSibling(p1); } Setattr((yyval.node),"templateparms",tp); Delete(tp); } else { Setattr((yyval.node),"templateparms",(yyvsp[(3) - (6)].tparms)); } #endif Delattr((yyval.node),"specialization"); Setattr((yyval.node),"partialspecialization","1"); /* Create a specialized name for matching */ { Parm *p = (yyvsp[(3) - (6)].tparms); String *fname = NewString(Getattr((yyval.node),"name")); String *ffname = 0; ParmList *partialparms = 0; char tmp[32]; int i, ilen; while (p) { String *n = Getattr(p,"name"); if (!n) { p = nextSibling(p); continue; } ilen = Len(tlist); for (i = 0; i < ilen; i++) { if (Strstr(Getitem(tlist,i),n)) { sprintf(tmp,"$%d",i+1); Replaceid(fname,n,tmp); } } p = nextSibling(p); } /* Patch argument names with typedef */ { Iterator tt; Parm *parm_current = 0; List *tparms = SwigType_parmlist(fname); ffname = SwigType_templateprefix(fname); Append(ffname,"<("); for (tt = First(tparms); tt.item; ) { SwigType *rtt = Swig_symbol_typedef_reduce(tt.item,0); SwigType *ttr = Swig_symbol_type_qualify(rtt,0); Parm *newp = NewParmWithoutFileLineInfo(ttr, 0); if (partialparms) set_nextSibling(parm_current, newp); else partialparms = newp; parm_current = newp; Append(ffname,ttr); tt = Next(tt); if (tt.item) Putc(',',ffname); Delete(rtt); Delete(ttr); } Delete(tparms); Append(ffname,")>"); } { Node *new_partial = NewHash(); String *partials = Getattr(tempn,"partials"); if (!partials) { partials = NewList(); Setattr(tempn,"partials",partials); Delete(partials); } /* Printf(stdout,"partial: fname = '%s', '%s'\n", fname, Swig_symbol_typedef_reduce(fname,0)); */ Setattr(new_partial, "partialparms", partialparms); Setattr(new_partial, "templcsymname", ffname); Append(partials, new_partial); } Setattr((yyval.node),"partialargs",ffname); Swig_symbol_cadd(ffname,(yyval.node)); } } Delete(tlist); Delete(targs); } else { /* An explicit template specialization */ /* add default args from primary (unspecialized) template */ String *ty = Swig_symbol_template_deftype(tname,0); String *fname = Swig_symbol_type_qualify(ty,0); Swig_symbol_cadd(fname,(yyval.node)); Delete(ty); Delete(fname); } } else if ((yyval.node)) { Setattr((yyval.node),"templatetype",nodeType((yyvsp[(6) - (6)].node))); set_nodeType((yyval.node),"template"); Setattr((yyval.node),"templateparms", (yyvsp[(3) - (6)].tparms)); if (!Getattr((yyval.node),"sym:weak")) { Setattr((yyval.node),"sym:typename","1"); } add_symbols((yyval.node)); default_arguments((yyval.node)); /* We also place a fully parameterized version in the symbol table */ { Parm *p; String *fname = NewStringf("%s<(", Getattr((yyval.node),"name")); p = (yyvsp[(3) - (6)].tparms); while (p) { String *n = Getattr(p,"name"); if (!n) n = Getattr(p,"type"); Append(fname,n); p = nextSibling(p); if (p) Putc(',',fname); } Append(fname,")>"); Swig_symbol_cadd(fname,(yyval.node)); } } (yyval.node) = ntop; Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); if (error) (yyval.node) = 0; if (currentOuterClass) template_parameters = Getattr(currentOuterClass, "template_parameters"); else template_parameters = 0; } break; case 169: /* Line 1806 of yacc.c */ #line 4018 "parser.y" { Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n"); (yyval.node) = 0; } break; case 170: /* Line 1806 of yacc.c */ #line 4024 "parser.y" { Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n"); (yyval.node) = 0; } break; case 171: /* Line 1806 of yacc.c */ #line 4030 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 172: /* Line 1806 of yacc.c */ #line 4033 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 173: /* Line 1806 of yacc.c */ #line 4036 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 174: /* Line 1806 of yacc.c */ #line 4039 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 175: /* Line 1806 of yacc.c */ #line 4042 "parser.y" { (yyval.node) = 0; } break; case 176: /* Line 1806 of yacc.c */ #line 4045 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 177: /* Line 1806 of yacc.c */ #line 4048 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 178: /* Line 1806 of yacc.c */ #line 4053 "parser.y" { /* Rip out the parameter names */ Parm *p = (yyvsp[(1) - (1)].pl); (yyval.tparms) = (yyvsp[(1) - (1)].pl); while (p) { String *name = Getattr(p,"name"); if (!name) { /* Hmmm. Maybe it's a 'class T' parameter */ char *type = Char(Getattr(p,"type")); /* Template template parameter */ if (strncmp(type,"template ",16) == 0) { type += 16; } if ((strncmp(type,"class ",6) == 0) || (strncmp(type,"typename ", 9) == 0)) { char *t = strchr(type,' '); Setattr(p,"name", t+1); } else /* Variadic template args */ if ((strncmp(type,"class... ",9) == 0) || (strncmp(type,"typename... ", 12) == 0)) { char *t = strchr(type,' '); Setattr(p,"name", t+1); Setattr(p,"variadic", "1"); } else { /* Swig_error(cparse_file, cparse_line, "Missing template parameter name\n"); $$.rparms = 0; $$.parms = 0; break; */ } } p = nextSibling(p); } } break; case 179: /* Line 1806 of yacc.c */ #line 4089 "parser.y" { set_nextSibling((yyvsp[(1) - (2)].p),(yyvsp[(2) - (2)].pl)); (yyval.pl) = (yyvsp[(1) - (2)].p); } break; case 180: /* Line 1806 of yacc.c */ #line 4093 "parser.y" { (yyval.pl) = 0; } break; case 181: /* Line 1806 of yacc.c */ #line 4096 "parser.y" { (yyval.p) = NewParmWithoutFileLineInfo(NewString((yyvsp[(1) - (1)].id)), 0); } break; case 182: /* Line 1806 of yacc.c */ #line 4099 "parser.y" { (yyval.p) = (yyvsp[(1) - (1)].p); } break; case 183: /* Line 1806 of yacc.c */ #line 4104 "parser.y" { set_nextSibling((yyvsp[(2) - (3)].p),(yyvsp[(3) - (3)].pl)); (yyval.pl) = (yyvsp[(2) - (3)].p); } break; case 184: /* Line 1806 of yacc.c */ #line 4108 "parser.y" { (yyval.pl) = 0; } break; case 185: /* Line 1806 of yacc.c */ #line 4113 "parser.y" { String *uname = Swig_symbol_type_qualify((yyvsp[(2) - (3)].str),0); String *name = Swig_scopename_last((yyvsp[(2) - (3)].str)); (yyval.node) = new_node("using"); Setattr((yyval.node),"uname",uname); Setattr((yyval.node),"name", name); Delete(uname); Delete(name); add_symbols((yyval.node)); } break; case 186: /* Line 1806 of yacc.c */ #line 4123 "parser.y" { Node *n = Swig_symbol_clookup((yyvsp[(3) - (4)].str),0); if (!n) { Swig_error(cparse_file, cparse_line, "Nothing known about namespace '%s'\n", (yyvsp[(3) - (4)].str)); (yyval.node) = 0; } else { while (Strcmp(nodeType(n),"using") == 0) { n = Getattr(n,"node"); } if (n) { if (Strcmp(nodeType(n),"namespace") == 0) { Symtab *current = Swig_symbol_current(); Symtab *symtab = Getattr(n,"symtab"); (yyval.node) = new_node("using"); Setattr((yyval.node),"node",n); Setattr((yyval.node),"namespace", (yyvsp[(3) - (4)].str)); if (current != symtab) { Swig_symbol_inherit(symtab); } } else { Swig_error(cparse_file, cparse_line, "'%s' is not a namespace.\n", (yyvsp[(3) - (4)].str)); (yyval.node) = 0; } } else { (yyval.node) = 0; } } } break; case 187: /* Line 1806 of yacc.c */ #line 4154 "parser.y" { Hash *h; (yyvsp[(1) - (3)].node) = Swig_symbol_current(); h = Swig_symbol_clookup((yyvsp[(2) - (3)].str),0); if (h && ((yyvsp[(1) - (3)].node) == Getattr(h,"sym:symtab")) && (Strcmp(nodeType(h),"namespace") == 0)) { if (Getattr(h,"alias")) { h = Getattr(h,"namespace"); Swig_warning(WARN_PARSE_NAMESPACE_ALIAS, cparse_file, cparse_line, "Namespace alias '%s' not allowed here. Assuming '%s'\n", (yyvsp[(2) - (3)].str), Getattr(h,"name")); (yyvsp[(2) - (3)].str) = Getattr(h,"name"); } Swig_symbol_setscope(Getattr(h,"symtab")); } else { Swig_symbol_newscope(); Swig_symbol_setscopename((yyvsp[(2) - (3)].str)); } Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } break; case 188: /* Line 1806 of yacc.c */ #line 4172 "parser.y" { Node *n = (yyvsp[(5) - (6)].node); set_nodeType(n,"namespace"); Setattr(n,"name",(yyvsp[(2) - (6)].str)); Setattr(n,"symtab", Swig_symbol_popscope()); Swig_symbol_setscope((yyvsp[(1) - (6)].node)); (yyval.node) = n; Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols((yyval.node)); } break; case 189: /* Line 1806 of yacc.c */ #line 4183 "parser.y" { Hash *h; (yyvsp[(1) - (2)].node) = Swig_symbol_current(); h = Swig_symbol_clookup(" ",0); if (h && (Strcmp(nodeType(h),"namespace") == 0)) { Swig_symbol_setscope(Getattr(h,"symtab")); } else { Swig_symbol_newscope(); /* we don't use "__unnamed__", but a long 'empty' name */ Swig_symbol_setscopename(" "); } Namespaceprefix = 0; } break; case 190: /* Line 1806 of yacc.c */ #line 4195 "parser.y" { (yyval.node) = (yyvsp[(4) - (5)].node); set_nodeType((yyval.node),"namespace"); Setattr((yyval.node),"unnamed","1"); Setattr((yyval.node),"symtab", Swig_symbol_popscope()); Swig_symbol_setscope((yyvsp[(1) - (5)].node)); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols((yyval.node)); } break; case 191: /* Line 1806 of yacc.c */ #line 4205 "parser.y" { /* Namespace alias */ Node *n; (yyval.node) = new_node("namespace"); Setattr((yyval.node),"name",(yyvsp[(2) - (5)].id)); Setattr((yyval.node),"alias",(yyvsp[(4) - (5)].str)); n = Swig_symbol_clookup((yyvsp[(4) - (5)].str),0); if (!n) { Swig_error(cparse_file, cparse_line, "Unknown namespace '%s'\n", (yyvsp[(4) - (5)].str)); (yyval.node) = 0; } else { if (Strcmp(nodeType(n),"namespace") != 0) { Swig_error(cparse_file, cparse_line, "'%s' is not a namespace\n",(yyvsp[(4) - (5)].str)); (yyval.node) = 0; } else { while (Getattr(n,"alias")) { n = Getattr(n,"namespace"); } Setattr((yyval.node),"namespace",n); add_symbols((yyval.node)); /* Set up a scope alias */ Swig_symbol_alias((yyvsp[(2) - (5)].id),Getattr(n,"symtab")); } } } break; case 192: /* Line 1806 of yacc.c */ #line 4232 "parser.y" { (yyval.node) = (yyvsp[(1) - (2)].node); /* Insert cpp_member (including any siblings) to the front of the cpp_members linked list */ if ((yyval.node)) { Node *p = (yyval.node); Node *pp =0; while (p) { pp = p; p = nextSibling(p); } set_nextSibling(pp,(yyvsp[(2) - (2)].node)); if ((yyvsp[(2) - (2)].node)) set_previousSibling((yyvsp[(2) - (2)].node), pp); } else { (yyval.node) = (yyvsp[(2) - (2)].node); } } break; case 193: /* Line 1806 of yacc.c */ #line 4249 "parser.y" { extendmode = 1; if (cplus_mode != CPLUS_PUBLIC) { Swig_error(cparse_file,cparse_line,"%%extend can only be used in a public section\n"); } } break; case 194: /* Line 1806 of yacc.c */ #line 4254 "parser.y" { extendmode = 0; } break; case 195: /* Line 1806 of yacc.c */ #line 4256 "parser.y" { (yyval.node) = new_node("extend"); mark_nodes_as_extend((yyvsp[(4) - (7)].node)); appendChild((yyval.node),(yyvsp[(4) - (7)].node)); set_nextSibling((yyval.node),(yyvsp[(7) - (7)].node)); } break; case 196: /* Line 1806 of yacc.c */ #line 4262 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 197: /* Line 1806 of yacc.c */ #line 4263 "parser.y" { (yyval.node) = 0;} break; case 198: /* Line 1806 of yacc.c */ #line 4264 "parser.y" { int start_line = cparse_line; skip_decl(); Swig_error(cparse_file,start_line,"Syntax error in input(3).\n"); exit(1); } break; case 199: /* Line 1806 of yacc.c */ #line 4269 "parser.y" { (yyval.node) = (yyvsp[(3) - (3)].node); } break; case 200: /* Line 1806 of yacc.c */ #line 4280 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 201: /* Line 1806 of yacc.c */ #line 4281 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); if (extendmode && current_class) { String *symname; symname= make_name((yyval.node),Getattr((yyval.node),"name"), Getattr((yyval.node),"decl")); if (Strcmp(symname,Getattr((yyval.node),"name")) == 0) { /* No renaming operation. Set name to class name */ Delete(yyrename); yyrename = NewString(Getattr(current_class,"sym:name")); } else { Delete(yyrename); yyrename = symname; } } add_symbols((yyval.node)); default_arguments((yyval.node)); } break; case 202: /* Line 1806 of yacc.c */ #line 4298 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 203: /* Line 1806 of yacc.c */ #line 4299 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 204: /* Line 1806 of yacc.c */ #line 4300 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 205: /* Line 1806 of yacc.c */ #line 4301 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 206: /* Line 1806 of yacc.c */ #line 4302 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 207: /* Line 1806 of yacc.c */ #line 4303 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 208: /* Line 1806 of yacc.c */ #line 4304 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 209: /* Line 1806 of yacc.c */ #line 4305 "parser.y" { (yyval.node) = 0; } break; case 210: /* Line 1806 of yacc.c */ #line 4306 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 211: /* Line 1806 of yacc.c */ #line 4307 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 212: /* Line 1806 of yacc.c */ #line 4308 "parser.y" { (yyval.node) = 0; } break; case 213: /* Line 1806 of yacc.c */ #line 4309 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 214: /* Line 1806 of yacc.c */ #line 4310 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 215: /* Line 1806 of yacc.c */ #line 4311 "parser.y" { (yyval.node) = 0; } break; case 216: /* Line 1806 of yacc.c */ #line 4312 "parser.y" {(yyval.node) = (yyvsp[(1) - (1)].node); } break; case 217: /* Line 1806 of yacc.c */ #line 4313 "parser.y" {(yyval.node) = (yyvsp[(1) - (1)].node); } break; case 218: /* Line 1806 of yacc.c */ #line 4314 "parser.y" { (yyval.node) = 0; } break; case 219: /* Line 1806 of yacc.c */ #line 4323 "parser.y" { if (inclass || extendmode) { SwigType *decl = NewStringEmpty(); (yyval.node) = new_node("constructor"); Setattr((yyval.node),"storage",(yyvsp[(1) - (6)].id)); Setattr((yyval.node),"name",(yyvsp[(2) - (6)].type)); Setattr((yyval.node),"parms",(yyvsp[(4) - (6)].pl)); SwigType_add_function(decl,(yyvsp[(4) - (6)].pl)); Setattr((yyval.node),"decl",decl); Setattr((yyval.node),"throws",(yyvsp[(6) - (6)].decl).throws); Setattr((yyval.node),"throw",(yyvsp[(6) - (6)].decl).throwf); Setattr((yyval.node),"noexcept",(yyvsp[(6) - (6)].decl).nexcept); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr((yyval.node),"code",code); Delete(code); } SetFlag((yyval.node),"feature:new"); if ((yyvsp[(6) - (6)].decl).defarg) Setattr((yyval.node),"value",(yyvsp[(6) - (6)].decl).defarg); } else { (yyval.node) = 0; } } break; case 220: /* Line 1806 of yacc.c */ #line 4351 "parser.y" { String *name = NewStringf("%s",(yyvsp[(2) - (6)].str)); if (*(Char(name)) != '~') Insert(name,0,"~"); (yyval.node) = new_node("destructor"); Setattr((yyval.node),"name",name); Delete(name); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr((yyval.node),"code",code); Delete(code); } { String *decl = NewStringEmpty(); SwigType_add_function(decl,(yyvsp[(4) - (6)].pl)); Setattr((yyval.node),"decl",decl); Delete(decl); } Setattr((yyval.node),"throws",(yyvsp[(6) - (6)].dtype).throws); Setattr((yyval.node),"throw",(yyvsp[(6) - (6)].dtype).throwf); Setattr((yyval.node),"noexcept",(yyvsp[(6) - (6)].dtype).nexcept); if ((yyvsp[(6) - (6)].dtype).val) Setattr((yyval.node),"value",(yyvsp[(6) - (6)].dtype).val); add_symbols((yyval.node)); } break; case 221: /* Line 1806 of yacc.c */ #line 4378 "parser.y" { String *name; (yyval.node) = new_node("destructor"); Setattr((yyval.node),"storage","virtual"); name = NewStringf("%s",(yyvsp[(3) - (7)].str)); if (*(Char(name)) != '~') Insert(name,0,"~"); Setattr((yyval.node),"name",name); Delete(name); Setattr((yyval.node),"throws",(yyvsp[(7) - (7)].dtype).throws); Setattr((yyval.node),"throw",(yyvsp[(7) - (7)].dtype).throwf); Setattr((yyval.node),"noexcept",(yyvsp[(7) - (7)].dtype).nexcept); if ((yyvsp[(7) - (7)].dtype).val) Setattr((yyval.node),"value",(yyvsp[(7) - (7)].dtype).val); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr((yyval.node),"code",code); Delete(code); } { String *decl = NewStringEmpty(); SwigType_add_function(decl,(yyvsp[(5) - (7)].pl)); Setattr((yyval.node),"decl",decl); Delete(decl); } add_symbols((yyval.node)); } break; case 222: /* Line 1806 of yacc.c */ #line 4409 "parser.y" { (yyval.node) = new_node("cdecl"); Setattr((yyval.node),"type",(yyvsp[(3) - (8)].type)); Setattr((yyval.node),"name",(yyvsp[(2) - (8)].str)); Setattr((yyval.node),"storage",(yyvsp[(1) - (8)].id)); SwigType_add_function((yyvsp[(4) - (8)].type),(yyvsp[(6) - (8)].pl)); if ((yyvsp[(8) - (8)].dtype).qualifier) { SwigType_push((yyvsp[(4) - (8)].type),(yyvsp[(8) - (8)].dtype).qualifier); } Setattr((yyval.node),"decl",(yyvsp[(4) - (8)].type)); Setattr((yyval.node),"parms",(yyvsp[(6) - (8)].pl)); Setattr((yyval.node),"conversion_operator","1"); add_symbols((yyval.node)); } break; case 223: /* Line 1806 of yacc.c */ #line 4424 "parser.y" { SwigType *decl; (yyval.node) = new_node("cdecl"); Setattr((yyval.node),"type",(yyvsp[(3) - (8)].type)); Setattr((yyval.node),"name",(yyvsp[(2) - (8)].str)); Setattr((yyval.node),"storage",(yyvsp[(1) - (8)].id)); decl = NewStringEmpty(); SwigType_add_reference(decl); SwigType_add_function(decl,(yyvsp[(6) - (8)].pl)); if ((yyvsp[(8) - (8)].dtype).qualifier) { SwigType_push(decl,(yyvsp[(8) - (8)].dtype).qualifier); } Setattr((yyval.node),"decl",decl); Setattr((yyval.node),"parms",(yyvsp[(6) - (8)].pl)); Setattr((yyval.node),"conversion_operator","1"); add_symbols((yyval.node)); } break; case 224: /* Line 1806 of yacc.c */ #line 4441 "parser.y" { SwigType *decl; (yyval.node) = new_node("cdecl"); Setattr((yyval.node),"type",(yyvsp[(3) - (8)].type)); Setattr((yyval.node),"name",(yyvsp[(2) - (8)].str)); Setattr((yyval.node),"storage",(yyvsp[(1) - (8)].id)); decl = NewStringEmpty(); SwigType_add_rvalue_reference(decl); SwigType_add_function(decl,(yyvsp[(6) - (8)].pl)); if ((yyvsp[(8) - (8)].dtype).qualifier) { SwigType_push(decl,(yyvsp[(8) - (8)].dtype).qualifier); } Setattr((yyval.node),"decl",decl); Setattr((yyval.node),"parms",(yyvsp[(6) - (8)].pl)); Setattr((yyval.node),"conversion_operator","1"); add_symbols((yyval.node)); } break; case 225: /* Line 1806 of yacc.c */ #line 4459 "parser.y" { SwigType *decl; (yyval.node) = new_node("cdecl"); Setattr((yyval.node),"type",(yyvsp[(3) - (9)].type)); Setattr((yyval.node),"name",(yyvsp[(2) - (9)].str)); Setattr((yyval.node),"storage",(yyvsp[(1) - (9)].id)); decl = NewStringEmpty(); SwigType_add_pointer(decl); SwigType_add_reference(decl); SwigType_add_function(decl,(yyvsp[(7) - (9)].pl)); if ((yyvsp[(9) - (9)].dtype).qualifier) { SwigType_push(decl,(yyvsp[(9) - (9)].dtype).qualifier); } Setattr((yyval.node),"decl",decl); Setattr((yyval.node),"parms",(yyvsp[(7) - (9)].pl)); Setattr((yyval.node),"conversion_operator","1"); add_symbols((yyval.node)); } break; case 226: /* Line 1806 of yacc.c */ #line 4478 "parser.y" { String *t = NewStringEmpty(); (yyval.node) = new_node("cdecl"); Setattr((yyval.node),"type",(yyvsp[(3) - (7)].type)); Setattr((yyval.node),"name",(yyvsp[(2) - (7)].str)); Setattr((yyval.node),"storage",(yyvsp[(1) - (7)].id)); SwigType_add_function(t,(yyvsp[(5) - (7)].pl)); if ((yyvsp[(7) - (7)].dtype).qualifier) { SwigType_push(t,(yyvsp[(7) - (7)].dtype).qualifier); } Setattr((yyval.node),"decl",t); Setattr((yyval.node),"parms",(yyvsp[(5) - (7)].pl)); Setattr((yyval.node),"conversion_operator","1"); add_symbols((yyval.node)); } break; case 227: /* Line 1806 of yacc.c */ #line 4497 "parser.y" { skip_balanced('{','}'); (yyval.node) = 0; } break; case 228: /* Line 1806 of yacc.c */ #line 4504 "parser.y" { skip_balanced('(',')'); (yyval.node) = 0; } break; case 229: /* Line 1806 of yacc.c */ #line 4511 "parser.y" { (yyval.node) = new_node("access"); Setattr((yyval.node),"kind","public"); cplus_mode = CPLUS_PUBLIC; } break; case 230: /* Line 1806 of yacc.c */ #line 4518 "parser.y" { (yyval.node) = new_node("access"); Setattr((yyval.node),"kind","private"); cplus_mode = CPLUS_PRIVATE; } break; case 231: /* Line 1806 of yacc.c */ #line 4526 "parser.y" { (yyval.node) = new_node("access"); Setattr((yyval.node),"kind","protected"); cplus_mode = CPLUS_PROTECTED; } break; case 232: /* Line 1806 of yacc.c */ #line 4534 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 233: /* Line 1806 of yacc.c */ #line 4537 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 234: /* Line 1806 of yacc.c */ #line 4541 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 235: /* Line 1806 of yacc.c */ #line 4544 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 236: /* Line 1806 of yacc.c */ #line 4545 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 237: /* Line 1806 of yacc.c */ #line 4546 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 238: /* Line 1806 of yacc.c */ #line 4547 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 239: /* Line 1806 of yacc.c */ #line 4548 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 240: /* Line 1806 of yacc.c */ #line 4549 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 241: /* Line 1806 of yacc.c */ #line 4550 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 242: /* Line 1806 of yacc.c */ #line 4551 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 243: /* Line 1806 of yacc.c */ #line 4554 "parser.y" { Clear(scanner_ccode); (yyval.dtype).val = 0; (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf; (yyval.dtype).nexcept = (yyvsp[(1) - (2)].dtype).nexcept; } break; case 244: /* Line 1806 of yacc.c */ #line 4561 "parser.y" { Clear(scanner_ccode); (yyval.dtype).val = (yyvsp[(3) - (4)].dtype).val; (yyval.dtype).throws = (yyvsp[(1) - (4)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(1) - (4)].dtype).throwf; (yyval.dtype).nexcept = (yyvsp[(1) - (4)].dtype).nexcept; } break; case 245: /* Line 1806 of yacc.c */ #line 4568 "parser.y" { skip_balanced('{','}'); (yyval.dtype).val = 0; (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf; (yyval.dtype).nexcept = (yyvsp[(1) - (2)].dtype).nexcept; } break; case 246: /* Line 1806 of yacc.c */ #line 4577 "parser.y" { Clear(scanner_ccode); (yyval.dtype).val = 0; (yyval.dtype).qualifier = (yyvsp[(1) - (2)].dtype).qualifier; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf; (yyval.dtype).nexcept = (yyvsp[(1) - (2)].dtype).nexcept; } break; case 247: /* Line 1806 of yacc.c */ #line 4586 "parser.y" { Clear(scanner_ccode); (yyval.dtype).val = (yyvsp[(3) - (4)].dtype).val; (yyval.dtype).qualifier = (yyvsp[(1) - (4)].dtype).qualifier; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = (yyvsp[(1) - (4)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(1) - (4)].dtype).throwf; (yyval.dtype).nexcept = (yyvsp[(1) - (4)].dtype).nexcept; } break; case 248: /* Line 1806 of yacc.c */ #line 4595 "parser.y" { skip_balanced('{','}'); (yyval.dtype).val = 0; (yyval.dtype).qualifier = (yyvsp[(1) - (2)].dtype).qualifier; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf; (yyval.dtype).nexcept = (yyvsp[(1) - (2)].dtype).nexcept; } break; case 249: /* Line 1806 of yacc.c */ #line 4607 "parser.y" { } break; case 250: /* Line 1806 of yacc.c */ #line 4610 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); /* Printf(stdout,"primitive = '%s'\n", $$);*/ } break; case 251: /* Line 1806 of yacc.c */ #line 4613 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 252: /* Line 1806 of yacc.c */ #line 4614 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 253: /* Line 1806 of yacc.c */ #line 4615 "parser.y" { (yyval.type) = NewStringf("%s%s",(yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].id)); } break; case 254: /* Line 1806 of yacc.c */ #line 4616 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 255: /* Line 1806 of yacc.c */ #line 4618 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].str); } break; case 256: /* Line 1806 of yacc.c */ #line 4627 "parser.y" { (yyval.id) = "extern"; } break; case 257: /* Line 1806 of yacc.c */ #line 4628 "parser.y" { if (strcmp((yyvsp[(2) - (2)].id),"C") == 0) { (yyval.id) = "externc"; } else if (strcmp((yyvsp[(2) - (2)].id),"C++") == 0) { (yyval.id) = "extern"; } else { Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", (yyvsp[(2) - (2)].id)); (yyval.id) = 0; } } break; case 258: /* Line 1806 of yacc.c */ #line 4638 "parser.y" { if (strcmp((yyvsp[(2) - (3)].id),"C") == 0) { (yyval.id) = "externc thread_local"; } else if (strcmp((yyvsp[(2) - (3)].id),"C++") == 0) { (yyval.id) = "extern thread_local"; } else { Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", (yyvsp[(2) - (3)].id)); (yyval.id) = 0; } } break; case 259: /* Line 1806 of yacc.c */ #line 4648 "parser.y" { (yyval.id) = "static"; } break; case 260: /* Line 1806 of yacc.c */ #line 4649 "parser.y" { (yyval.id) = "typedef"; } break; case 261: /* Line 1806 of yacc.c */ #line 4650 "parser.y" { (yyval.id) = "virtual"; } break; case 262: /* Line 1806 of yacc.c */ #line 4651 "parser.y" { (yyval.id) = "friend"; } break; case 263: /* Line 1806 of yacc.c */ #line 4652 "parser.y" { (yyval.id) = "explicit"; } break; case 264: /* Line 1806 of yacc.c */ #line 4653 "parser.y" { (yyval.id) = "constexpr"; } break; case 265: /* Line 1806 of yacc.c */ #line 4654 "parser.y" { (yyval.id) = "static constexpr"; } break; case 266: /* Line 1806 of yacc.c */ #line 4655 "parser.y" { (yyval.id) = "thread_local"; } break; case 267: /* Line 1806 of yacc.c */ #line 4656 "parser.y" { (yyval.id) = "static thread_local"; } break; case 268: /* Line 1806 of yacc.c */ #line 4657 "parser.y" { (yyval.id) = "static thread_local"; } break; case 269: /* Line 1806 of yacc.c */ #line 4658 "parser.y" { (yyval.id) = "extern thread_local"; } break; case 270: /* Line 1806 of yacc.c */ #line 4659 "parser.y" { (yyval.id) = "extern thread_local"; } break; case 271: /* Line 1806 of yacc.c */ #line 4660 "parser.y" { (yyval.id) = 0; } break; case 272: /* Line 1806 of yacc.c */ #line 4667 "parser.y" { Parm *p; (yyval.pl) = (yyvsp[(1) - (1)].pl); p = (yyvsp[(1) - (1)].pl); while (p) { Replace(Getattr(p,"type"),"typename ", "", DOH_REPLACE_ANY); p = nextSibling(p); } } break; case 273: /* Line 1806 of yacc.c */ #line 4678 "parser.y" { set_nextSibling((yyvsp[(1) - (2)].p),(yyvsp[(2) - (2)].pl)); (yyval.pl) = (yyvsp[(1) - (2)].p); } break; case 274: /* Line 1806 of yacc.c */ #line 4682 "parser.y" { (yyval.pl) = 0; } break; case 275: /* Line 1806 of yacc.c */ #line 4685 "parser.y" { set_nextSibling((yyvsp[(2) - (3)].p),(yyvsp[(3) - (3)].pl)); (yyval.pl) = (yyvsp[(2) - (3)].p); } break; case 276: /* Line 1806 of yacc.c */ #line 4689 "parser.y" { (yyval.pl) = 0; } break; case 277: /* Line 1806 of yacc.c */ #line 4693 "parser.y" { SwigType_push((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).type); (yyval.p) = NewParmWithoutFileLineInfo((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).id); Setfile((yyval.p),cparse_file); Setline((yyval.p),cparse_line); if ((yyvsp[(2) - (2)].decl).defarg) { Setattr((yyval.p),"value",(yyvsp[(2) - (2)].decl).defarg); } } break; case 278: /* Line 1806 of yacc.c */ #line 4703 "parser.y" { (yyval.p) = NewParmWithoutFileLineInfo(NewStringf("template %s %s", (yyvsp[(5) - (7)].id),(yyvsp[(6) - (7)].str)), 0); Setfile((yyval.p),cparse_file); Setline((yyval.p),cparse_line); if ((yyvsp[(7) - (7)].dtype).val) { Setattr((yyval.p),"value",(yyvsp[(7) - (7)].dtype).val); } } break; case 279: /* Line 1806 of yacc.c */ #line 4711 "parser.y" { SwigType *t = NewString("v(...)"); (yyval.p) = NewParmWithoutFileLineInfo(t, 0); Setfile((yyval.p),cparse_file); Setline((yyval.p),cparse_line); } break; case 280: /* Line 1806 of yacc.c */ #line 4719 "parser.y" { Parm *p; (yyval.p) = (yyvsp[(1) - (1)].p); p = (yyvsp[(1) - (1)].p); while (p) { if (Getattr(p,"type")) { Replace(Getattr(p,"type"),"typename ", "", DOH_REPLACE_ANY); } p = nextSibling(p); } } break; case 281: /* Line 1806 of yacc.c */ #line 4732 "parser.y" { set_nextSibling((yyvsp[(1) - (2)].p),(yyvsp[(2) - (2)].p)); (yyval.p) = (yyvsp[(1) - (2)].p); } break; case 282: /* Line 1806 of yacc.c */ #line 4736 "parser.y" { (yyval.p) = 0; } break; case 283: /* Line 1806 of yacc.c */ #line 4739 "parser.y" { set_nextSibling((yyvsp[(2) - (3)].p),(yyvsp[(3) - (3)].p)); (yyval.p) = (yyvsp[(2) - (3)].p); } break; case 284: /* Line 1806 of yacc.c */ #line 4743 "parser.y" { (yyval.p) = 0; } break; case 285: /* Line 1806 of yacc.c */ #line 4747 "parser.y" { (yyval.p) = (yyvsp[(1) - (1)].p); { /* We need to make a possible adjustment for integer parameters. */ SwigType *type; Node *n = 0; while (!n) { type = Getattr((yyvsp[(1) - (1)].p),"type"); n = Swig_symbol_clookup(type,0); /* See if we can find a node that matches the typename */ if ((n) && (Strcmp(nodeType(n),"cdecl") == 0)) { SwigType *decl = Getattr(n,"decl"); if (!SwigType_isfunction(decl)) { String *value = Getattr(n,"value"); if (value) { String *v = Copy(value); Setattr((yyvsp[(1) - (1)].p),"type",v); Delete(v); n = 0; } } } else { break; } } } } break; case 286: /* Line 1806 of yacc.c */ #line 4775 "parser.y" { (yyval.p) = NewParmWithoutFileLineInfo(0,0); Setfile((yyval.p),cparse_file); Setline((yyval.p),cparse_line); Setattr((yyval.p),"value",(yyvsp[(1) - (1)].dtype).val); } break; case 287: /* Line 1806 of yacc.c */ #line 4783 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); if ((yyvsp[(2) - (2)].dtype).type == T_ERROR) { Swig_warning(WARN_PARSE_BAD_DEFAULT,cparse_file, cparse_line, "Can't set default argument (ignored)\n"); (yyval.dtype).val = 0; (yyval.dtype).rawval = 0; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } } break; case 288: /* Line 1806 of yacc.c */ #line 4795 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (5)].dtype); if ((yyvsp[(2) - (5)].dtype).type == T_ERROR) { Swig_warning(WARN_PARSE_BAD_DEFAULT,cparse_file, cparse_line, "Can't set default argument (ignored)\n"); (yyval.dtype) = (yyvsp[(2) - (5)].dtype); (yyval.dtype).val = 0; (yyval.dtype).rawval = 0; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } else { (yyval.dtype).val = NewStringf("%s[%s]",(yyvsp[(2) - (5)].dtype).val,(yyvsp[(4) - (5)].dtype).val); } } break; case 289: /* Line 1806 of yacc.c */ #line 4810 "parser.y" { skip_balanced('{','}'); (yyval.dtype).val = NewString(scanner_ccode); (yyval.dtype).rawval = 0; (yyval.dtype).type = T_INT; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 290: /* Line 1806 of yacc.c */ #line 4820 "parser.y" { (yyval.dtype).val = 0; (yyval.dtype).rawval = 0; (yyval.dtype).type = 0; (yyval.dtype).bitfield = (yyvsp[(2) - (2)].dtype).val; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 291: /* Line 1806 of yacc.c */ #line 4829 "parser.y" { (yyval.dtype).val = 0; (yyval.dtype).rawval = 0; (yyval.dtype).type = T_INT; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 292: /* Line 1806 of yacc.c */ #line 4840 "parser.y" { (yyval.decl) = (yyvsp[(1) - (2)].decl); (yyval.decl).defarg = (yyvsp[(2) - (2)].dtype).rawval ? (yyvsp[(2) - (2)].dtype).rawval : (yyvsp[(2) - (2)].dtype).val; } break; case 293: /* Line 1806 of yacc.c */ #line 4844 "parser.y" { (yyval.decl) = (yyvsp[(1) - (2)].decl); (yyval.decl).defarg = (yyvsp[(2) - (2)].dtype).rawval ? (yyvsp[(2) - (2)].dtype).rawval : (yyvsp[(2) - (2)].dtype).val; } break; case 294: /* Line 1806 of yacc.c */ #line 4848 "parser.y" { (yyval.decl).type = 0; (yyval.decl).id = 0; (yyval.decl).defarg = (yyvsp[(1) - (1)].dtype).rawval ? (yyvsp[(1) - (1)].dtype).rawval : (yyvsp[(1) - (1)].dtype).val; } break; case 295: /* Line 1806 of yacc.c */ #line 4855 "parser.y" { (yyval.decl) = (yyvsp[(1) - (1)].decl); if (SwigType_isfunction((yyvsp[(1) - (1)].decl).type)) { Delete(SwigType_pop_function((yyvsp[(1) - (1)].decl).type)); } else if (SwigType_isarray((yyvsp[(1) - (1)].decl).type)) { SwigType *ta = SwigType_pop_arrays((yyvsp[(1) - (1)].decl).type); if (SwigType_isfunction((yyvsp[(1) - (1)].decl).type)) { Delete(SwigType_pop_function((yyvsp[(1) - (1)].decl).type)); } else { (yyval.decl).parms = 0; } SwigType_push((yyvsp[(1) - (1)].decl).type,ta); Delete(ta); } else { (yyval.decl).parms = 0; } } break; case 296: /* Line 1806 of yacc.c */ #line 4872 "parser.y" { (yyval.decl) = (yyvsp[(1) - (1)].decl); if (SwigType_isfunction((yyvsp[(1) - (1)].decl).type)) { Delete(SwigType_pop_function((yyvsp[(1) - (1)].decl).type)); } else if (SwigType_isarray((yyvsp[(1) - (1)].decl).type)) { SwigType *ta = SwigType_pop_arrays((yyvsp[(1) - (1)].decl).type); if (SwigType_isfunction((yyvsp[(1) - (1)].decl).type)) { Delete(SwigType_pop_function((yyvsp[(1) - (1)].decl).type)); } else { (yyval.decl).parms = 0; } SwigType_push((yyvsp[(1) - (1)].decl).type,ta); Delete(ta); } else { (yyval.decl).parms = 0; } } break; case 297: /* Line 1806 of yacc.c */ #line 4889 "parser.y" { (yyval.decl).type = 0; (yyval.decl).id = 0; (yyval.decl).parms = 0; } break; case 298: /* Line 1806 of yacc.c */ #line 4897 "parser.y" { (yyval.decl) = (yyvsp[(2) - (2)].decl); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (2)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (2)].type); } break; case 299: /* Line 1806 of yacc.c */ #line 4905 "parser.y" { (yyval.decl) = (yyvsp[(3) - (3)].decl); SwigType_add_reference((yyvsp[(1) - (3)].type)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (3)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (3)].type); } break; case 300: /* Line 1806 of yacc.c */ #line 4914 "parser.y" { (yyval.decl) = (yyvsp[(3) - (3)].decl); SwigType_add_rvalue_reference((yyvsp[(1) - (3)].type)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (3)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (3)].type); } break; case 301: /* Line 1806 of yacc.c */ #line 4923 "parser.y" { (yyval.decl) = (yyvsp[(1) - (1)].decl); if (!(yyval.decl).type) (yyval.decl).type = NewStringEmpty(); } break; case 302: /* Line 1806 of yacc.c */ #line 4927 "parser.y" { (yyval.decl) = (yyvsp[(2) - (2)].decl); (yyval.decl).type = NewStringEmpty(); SwigType_add_reference((yyval.decl).type); if ((yyvsp[(2) - (2)].decl).type) { SwigType_push((yyval.decl).type,(yyvsp[(2) - (2)].decl).type); Delete((yyvsp[(2) - (2)].decl).type); } } break; case 303: /* Line 1806 of yacc.c */ #line 4936 "parser.y" { /* Introduced in C++11, move operator && */ /* Adds one S/R conflict */ (yyval.decl) = (yyvsp[(2) - (2)].decl); (yyval.decl).type = NewStringEmpty(); SwigType_add_rvalue_reference((yyval.decl).type); if ((yyvsp[(2) - (2)].decl).type) { SwigType_push((yyval.decl).type,(yyvsp[(2) - (2)].decl).type); Delete((yyvsp[(2) - (2)].decl).type); } } break; case 304: /* Line 1806 of yacc.c */ #line 4947 "parser.y" { SwigType *t = NewStringEmpty(); (yyval.decl) = (yyvsp[(3) - (3)].decl); SwigType_add_memberpointer(t,(yyvsp[(1) - (3)].str)); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 305: /* Line 1806 of yacc.c */ #line 4958 "parser.y" { SwigType *t = NewStringEmpty(); (yyval.decl) = (yyvsp[(4) - (4)].decl); SwigType_add_memberpointer(t,(yyvsp[(2) - (4)].str)); SwigType_push((yyvsp[(1) - (4)].type),t); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (4)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (4)].type); Delete(t); } break; case 306: /* Line 1806 of yacc.c */ #line 4970 "parser.y" { (yyval.decl) = (yyvsp[(5) - (5)].decl); SwigType_add_memberpointer((yyvsp[(1) - (5)].type),(yyvsp[(2) - (5)].str)); SwigType_add_reference((yyvsp[(1) - (5)].type)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (5)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (5)].type); } break; case 307: /* Line 1806 of yacc.c */ #line 4980 "parser.y" { SwigType *t = NewStringEmpty(); (yyval.decl) = (yyvsp[(4) - (4)].decl); SwigType_add_memberpointer(t,(yyvsp[(1) - (4)].str)); SwigType_add_reference(t); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 308: /* Line 1806 of yacc.c */ #line 4994 "parser.y" { (yyval.decl) = (yyvsp[(5) - (5)].decl); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (5)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (5)].type); } break; case 309: /* Line 1806 of yacc.c */ #line 5002 "parser.y" { (yyval.decl) = (yyvsp[(6) - (6)].decl); SwigType_add_reference((yyvsp[(1) - (6)].type)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (6)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (6)].type); } break; case 310: /* Line 1806 of yacc.c */ #line 5011 "parser.y" { (yyval.decl) = (yyvsp[(6) - (6)].decl); SwigType_add_rvalue_reference((yyvsp[(1) - (6)].type)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (6)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (6)].type); } break; case 311: /* Line 1806 of yacc.c */ #line 5020 "parser.y" { (yyval.decl) = (yyvsp[(4) - (4)].decl); if (!(yyval.decl).type) (yyval.decl).type = NewStringEmpty(); } break; case 312: /* Line 1806 of yacc.c */ #line 5024 "parser.y" { (yyval.decl) = (yyvsp[(5) - (5)].decl); (yyval.decl).type = NewStringEmpty(); SwigType_add_reference((yyval.decl).type); if ((yyvsp[(5) - (5)].decl).type) { SwigType_push((yyval.decl).type,(yyvsp[(5) - (5)].decl).type); Delete((yyvsp[(5) - (5)].decl).type); } } break; case 313: /* Line 1806 of yacc.c */ #line 5033 "parser.y" { /* Introduced in C++11, move operator && */ /* Adds one S/R conflict */ (yyval.decl) = (yyvsp[(5) - (5)].decl); (yyval.decl).type = NewStringEmpty(); SwigType_add_rvalue_reference((yyval.decl).type); if ((yyvsp[(5) - (5)].decl).type) { SwigType_push((yyval.decl).type,(yyvsp[(5) - (5)].decl).type); Delete((yyvsp[(5) - (5)].decl).type); } } break; case 314: /* Line 1806 of yacc.c */ #line 5044 "parser.y" { SwigType *t = NewStringEmpty(); (yyval.decl) = (yyvsp[(6) - (6)].decl); SwigType_add_memberpointer(t,(yyvsp[(1) - (6)].str)); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 315: /* Line 1806 of yacc.c */ #line 5055 "parser.y" { SwigType *t = NewStringEmpty(); (yyval.decl) = (yyvsp[(7) - (7)].decl); SwigType_add_memberpointer(t,(yyvsp[(2) - (7)].str)); SwigType_push((yyvsp[(1) - (7)].type),t); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (7)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (7)].type); Delete(t); } break; case 316: /* Line 1806 of yacc.c */ #line 5067 "parser.y" { (yyval.decl) = (yyvsp[(8) - (8)].decl); SwigType_add_memberpointer((yyvsp[(1) - (8)].type),(yyvsp[(2) - (8)].str)); SwigType_add_reference((yyvsp[(1) - (8)].type)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (8)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (8)].type); } break; case 317: /* Line 1806 of yacc.c */ #line 5077 "parser.y" { (yyval.decl) = (yyvsp[(8) - (8)].decl); SwigType_add_memberpointer((yyvsp[(1) - (8)].type),(yyvsp[(2) - (8)].str)); SwigType_add_rvalue_reference((yyvsp[(1) - (8)].type)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (8)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (8)].type); } break; case 318: /* Line 1806 of yacc.c */ #line 5087 "parser.y" { SwigType *t = NewStringEmpty(); (yyval.decl) = (yyvsp[(7) - (7)].decl); SwigType_add_memberpointer(t,(yyvsp[(1) - (7)].str)); SwigType_add_reference(t); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 319: /* Line 1806 of yacc.c */ #line 5098 "parser.y" { SwigType *t = NewStringEmpty(); (yyval.decl) = (yyvsp[(7) - (7)].decl); SwigType_add_memberpointer(t,(yyvsp[(1) - (7)].str)); SwigType_add_rvalue_reference(t); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 320: /* Line 1806 of yacc.c */ #line 5111 "parser.y" { /* Note: This is non-standard C. Template declarator is allowed to follow an identifier */ (yyval.decl).id = Char((yyvsp[(1) - (1)].str)); (yyval.decl).type = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 321: /* Line 1806 of yacc.c */ #line 5118 "parser.y" { (yyval.decl).id = Char(NewStringf("~%s",(yyvsp[(2) - (2)].str))); (yyval.decl).type = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 322: /* Line 1806 of yacc.c */ #line 5126 "parser.y" { (yyval.decl).id = Char((yyvsp[(2) - (3)].str)); (yyval.decl).type = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 323: /* Line 1806 of yacc.c */ #line 5142 "parser.y" { (yyval.decl) = (yyvsp[(3) - (4)].decl); if ((yyval.decl).type) { SwigType_push((yyvsp[(2) - (4)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(2) - (4)].type); } break; case 324: /* Line 1806 of yacc.c */ #line 5150 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(4) - (5)].decl); t = NewStringEmpty(); SwigType_add_memberpointer(t,(yyvsp[(2) - (5)].str)); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 325: /* Line 1806 of yacc.c */ #line 5161 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (3)].decl); t = NewStringEmpty(); SwigType_add_array(t,""); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 326: /* Line 1806 of yacc.c */ #line 5172 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (4)].decl); t = NewStringEmpty(); SwigType_add_array(t,(yyvsp[(3) - (4)].dtype).val); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 327: /* Line 1806 of yacc.c */ #line 5183 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (4)].decl); t = NewStringEmpty(); SwigType_add_function(t,(yyvsp[(3) - (4)].pl)); if (!(yyval.decl).have_parms) { (yyval.decl).parms = (yyvsp[(3) - (4)].pl); (yyval.decl).have_parms = 1; } if (!(yyval.decl).type) { (yyval.decl).type = t; } else { SwigType_push(t, (yyval.decl).type); Delete((yyval.decl).type); (yyval.decl).type = t; } } break; case 328: /* Line 1806 of yacc.c */ #line 5202 "parser.y" { /* Note: This is non-standard C. Template declarator is allowed to follow an identifier */ (yyval.decl).id = Char((yyvsp[(1) - (1)].str)); (yyval.decl).type = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 329: /* Line 1806 of yacc.c */ #line 5210 "parser.y" { (yyval.decl).id = Char(NewStringf("~%s",(yyvsp[(2) - (2)].str))); (yyval.decl).type = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 330: /* Line 1806 of yacc.c */ #line 5227 "parser.y" { (yyval.decl) = (yyvsp[(3) - (4)].decl); if ((yyval.decl).type) { SwigType_push((yyvsp[(2) - (4)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(2) - (4)].type); } break; case 331: /* Line 1806 of yacc.c */ #line 5235 "parser.y" { (yyval.decl) = (yyvsp[(3) - (4)].decl); if (!(yyval.decl).type) { (yyval.decl).type = NewStringEmpty(); } SwigType_add_reference((yyval.decl).type); } break; case 332: /* Line 1806 of yacc.c */ #line 5242 "parser.y" { (yyval.decl) = (yyvsp[(3) - (4)].decl); if (!(yyval.decl).type) { (yyval.decl).type = NewStringEmpty(); } SwigType_add_rvalue_reference((yyval.decl).type); } break; case 333: /* Line 1806 of yacc.c */ #line 5249 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(4) - (5)].decl); t = NewStringEmpty(); SwigType_add_memberpointer(t,(yyvsp[(2) - (5)].str)); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 334: /* Line 1806 of yacc.c */ #line 5260 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (3)].decl); t = NewStringEmpty(); SwigType_add_array(t,""); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 335: /* Line 1806 of yacc.c */ #line 5271 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (4)].decl); t = NewStringEmpty(); SwigType_add_array(t,(yyvsp[(3) - (4)].dtype).val); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 336: /* Line 1806 of yacc.c */ #line 5282 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (4)].decl); t = NewStringEmpty(); SwigType_add_function(t,(yyvsp[(3) - (4)].pl)); if (!(yyval.decl).have_parms) { (yyval.decl).parms = (yyvsp[(3) - (4)].pl); (yyval.decl).have_parms = 1; } if (!(yyval.decl).type) { (yyval.decl).type = t; } else { SwigType_push(t, (yyval.decl).type); Delete((yyval.decl).type); (yyval.decl).type = t; } } break; case 337: /* Line 1806 of yacc.c */ #line 5302 "parser.y" { SwigType *t; Append((yyvsp[(1) - (5)].str), " "); /* intervening space is mandatory */ Append((yyvsp[(1) - (5)].str), Char((yyvsp[(2) - (5)].id))); (yyval.decl).id = Char((yyvsp[(1) - (5)].str)); t = NewStringEmpty(); SwigType_add_function(t,(yyvsp[(4) - (5)].pl)); if (!(yyval.decl).have_parms) { (yyval.decl).parms = (yyvsp[(4) - (5)].pl); (yyval.decl).have_parms = 1; } if (!(yyval.decl).type) { (yyval.decl).type = t; } else { SwigType_push(t, (yyval.decl).type); Delete((yyval.decl).type); (yyval.decl).type = t; } } break; case 338: /* Line 1806 of yacc.c */ #line 5323 "parser.y" { (yyval.decl).type = (yyvsp[(1) - (1)].type); (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 339: /* Line 1806 of yacc.c */ #line 5329 "parser.y" { (yyval.decl) = (yyvsp[(2) - (2)].decl); SwigType_push((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).type); (yyval.decl).type = (yyvsp[(1) - (2)].type); Delete((yyvsp[(2) - (2)].decl).type); } break; case 340: /* Line 1806 of yacc.c */ #line 5335 "parser.y" { (yyval.decl).type = (yyvsp[(1) - (2)].type); SwigType_add_reference((yyval.decl).type); (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 341: /* Line 1806 of yacc.c */ #line 5342 "parser.y" { (yyval.decl).type = (yyvsp[(1) - (2)].type); SwigType_add_rvalue_reference((yyval.decl).type); (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 342: /* Line 1806 of yacc.c */ #line 5349 "parser.y" { (yyval.decl) = (yyvsp[(3) - (3)].decl); SwigType_add_reference((yyvsp[(1) - (3)].type)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (3)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (3)].type); } break; case 343: /* Line 1806 of yacc.c */ #line 5358 "parser.y" { (yyval.decl) = (yyvsp[(3) - (3)].decl); SwigType_add_rvalue_reference((yyvsp[(1) - (3)].type)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (3)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (3)].type); } break; case 344: /* Line 1806 of yacc.c */ #line 5367 "parser.y" { (yyval.decl) = (yyvsp[(1) - (1)].decl); } break; case 345: /* Line 1806 of yacc.c */ #line 5370 "parser.y" { (yyval.decl) = (yyvsp[(2) - (2)].decl); (yyval.decl).type = NewStringEmpty(); SwigType_add_reference((yyval.decl).type); if ((yyvsp[(2) - (2)].decl).type) { SwigType_push((yyval.decl).type,(yyvsp[(2) - (2)].decl).type); Delete((yyvsp[(2) - (2)].decl).type); } } break; case 346: /* Line 1806 of yacc.c */ #line 5379 "parser.y" { (yyval.decl) = (yyvsp[(2) - (2)].decl); (yyval.decl).type = NewStringEmpty(); SwigType_add_rvalue_reference((yyval.decl).type); if ((yyvsp[(2) - (2)].decl).type) { SwigType_push((yyval.decl).type,(yyvsp[(2) - (2)].decl).type); Delete((yyvsp[(2) - (2)].decl).type); } } break; case 347: /* Line 1806 of yacc.c */ #line 5388 "parser.y" { (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; (yyval.decl).type = NewStringEmpty(); SwigType_add_reference((yyval.decl).type); } break; case 348: /* Line 1806 of yacc.c */ #line 5395 "parser.y" { (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; (yyval.decl).type = NewStringEmpty(); SwigType_add_rvalue_reference((yyval.decl).type); } break; case 349: /* Line 1806 of yacc.c */ #line 5402 "parser.y" { (yyval.decl).type = NewStringEmpty(); SwigType_add_memberpointer((yyval.decl).type,(yyvsp[(1) - (2)].str)); (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 350: /* Line 1806 of yacc.c */ #line 5409 "parser.y" { SwigType *t = NewStringEmpty(); (yyval.decl).type = (yyvsp[(1) - (3)].type); (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; SwigType_add_memberpointer(t,(yyvsp[(2) - (3)].str)); SwigType_push((yyval.decl).type,t); Delete(t); } break; case 351: /* Line 1806 of yacc.c */ #line 5419 "parser.y" { (yyval.decl) = (yyvsp[(4) - (4)].decl); SwigType_add_memberpointer((yyvsp[(1) - (4)].type),(yyvsp[(2) - (4)].str)); if ((yyval.decl).type) { SwigType_push((yyvsp[(1) - (4)].type),(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = (yyvsp[(1) - (4)].type); } break; case 352: /* Line 1806 of yacc.c */ #line 5430 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (3)].decl); t = NewStringEmpty(); SwigType_add_array(t,""); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 353: /* Line 1806 of yacc.c */ #line 5441 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (4)].decl); t = NewStringEmpty(); SwigType_add_array(t,(yyvsp[(3) - (4)].dtype).val); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 354: /* Line 1806 of yacc.c */ #line 5452 "parser.y" { (yyval.decl).type = NewStringEmpty(); (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; SwigType_add_array((yyval.decl).type,""); } break; case 355: /* Line 1806 of yacc.c */ #line 5459 "parser.y" { (yyval.decl).type = NewStringEmpty(); (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; SwigType_add_array((yyval.decl).type,(yyvsp[(2) - (3)].dtype).val); } break; case 356: /* Line 1806 of yacc.c */ #line 5466 "parser.y" { (yyval.decl) = (yyvsp[(2) - (3)].decl); } break; case 357: /* Line 1806 of yacc.c */ #line 5469 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (4)].decl); t = NewStringEmpty(); SwigType_add_function(t,(yyvsp[(3) - (4)].pl)); if (!(yyval.decl).type) { (yyval.decl).type = t; } else { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); (yyval.decl).type = t; } if (!(yyval.decl).have_parms) { (yyval.decl).parms = (yyvsp[(3) - (4)].pl); (yyval.decl).have_parms = 1; } } break; case 358: /* Line 1806 of yacc.c */ #line 5486 "parser.y" { (yyval.decl).type = NewStringEmpty(); SwigType_add_function((yyval.decl).type,(yyvsp[(2) - (3)].pl)); (yyval.decl).parms = (yyvsp[(2) - (3)].pl); (yyval.decl).have_parms = 1; (yyval.decl).id = 0; } break; case 359: /* Line 1806 of yacc.c */ #line 5496 "parser.y" { (yyval.type) = NewStringEmpty(); SwigType_add_pointer((yyval.type)); SwigType_push((yyval.type),(yyvsp[(2) - (3)].str)); SwigType_push((yyval.type),(yyvsp[(3) - (3)].type)); Delete((yyvsp[(3) - (3)].type)); } break; case 360: /* Line 1806 of yacc.c */ #line 5503 "parser.y" { (yyval.type) = NewStringEmpty(); SwigType_add_pointer((yyval.type)); SwigType_push((yyval.type),(yyvsp[(2) - (2)].type)); Delete((yyvsp[(2) - (2)].type)); } break; case 361: /* Line 1806 of yacc.c */ #line 5509 "parser.y" { (yyval.type) = NewStringEmpty(); SwigType_add_pointer((yyval.type)); SwigType_push((yyval.type),(yyvsp[(2) - (2)].str)); } break; case 362: /* Line 1806 of yacc.c */ #line 5514 "parser.y" { (yyval.type) = NewStringEmpty(); SwigType_add_pointer((yyval.type)); } break; case 363: /* Line 1806 of yacc.c */ #line 5520 "parser.y" { (yyval.str) = NewStringEmpty(); if ((yyvsp[(1) - (1)].id)) SwigType_add_qualifier((yyval.str),(yyvsp[(1) - (1)].id)); } break; case 364: /* Line 1806 of yacc.c */ #line 5524 "parser.y" { (yyval.str) = (yyvsp[(2) - (2)].str); if ((yyvsp[(1) - (2)].id)) SwigType_add_qualifier((yyval.str),(yyvsp[(1) - (2)].id)); } break; case 365: /* Line 1806 of yacc.c */ #line 5530 "parser.y" { (yyval.id) = "const"; } break; case 366: /* Line 1806 of yacc.c */ #line 5531 "parser.y" { (yyval.id) = "volatile"; } break; case 367: /* Line 1806 of yacc.c */ #line 5532 "parser.y" { (yyval.id) = 0; } break; case 368: /* Line 1806 of yacc.c */ #line 5538 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); Replace((yyval.type),"typename ","", DOH_REPLACE_ANY); } break; case 369: /* Line 1806 of yacc.c */ #line 5544 "parser.y" { (yyval.type) = (yyvsp[(2) - (2)].type); SwigType_push((yyval.type),(yyvsp[(1) - (2)].str)); } break; case 370: /* Line 1806 of yacc.c */ #line 5548 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 371: /* Line 1806 of yacc.c */ #line 5549 "parser.y" { (yyval.type) = (yyvsp[(1) - (2)].type); SwigType_push((yyval.type),(yyvsp[(2) - (2)].str)); } break; case 372: /* Line 1806 of yacc.c */ #line 5553 "parser.y" { (yyval.type) = (yyvsp[(2) - (3)].type); SwigType_push((yyval.type),(yyvsp[(3) - (3)].str)); SwigType_push((yyval.type),(yyvsp[(1) - (3)].str)); } break; case 373: /* Line 1806 of yacc.c */ #line 5560 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); /* Printf(stdout,"primitive = '%s'\n", $$);*/ } break; case 374: /* Line 1806 of yacc.c */ #line 5563 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 375: /* Line 1806 of yacc.c */ #line 5564 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 376: /* Line 1806 of yacc.c */ #line 5565 "parser.y" { (yyval.type) = NewStringf("%s%s",(yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].id)); } break; case 377: /* Line 1806 of yacc.c */ #line 5566 "parser.y" { (yyval.type) = NewStringf("enum %s", (yyvsp[(2) - (2)].str)); } break; case 378: /* Line 1806 of yacc.c */ #line 5567 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 379: /* Line 1806 of yacc.c */ #line 5569 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].str); } break; case 380: /* Line 1806 of yacc.c */ #line 5572 "parser.y" { (yyval.type) = NewStringf("%s %s", (yyvsp[(1) - (2)].id), (yyvsp[(2) - (2)].str)); } break; case 381: /* Line 1806 of yacc.c */ #line 5575 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 382: /* Line 1806 of yacc.c */ #line 5580 "parser.y" { Node *n = Swig_symbol_clookup((yyvsp[(3) - (4)].str),0); if (!n) { Swig_error(cparse_file, cparse_line, "Identifier %s not defined.\n", (yyvsp[(3) - (4)].str)); (yyval.type) = (yyvsp[(3) - (4)].str); } else { (yyval.type) = Getattr(n, "type"); } } break; case 383: /* Line 1806 of yacc.c */ #line 5591 "parser.y" { if (!(yyvsp[(1) - (1)].ptype).type) (yyvsp[(1) - (1)].ptype).type = NewString("int"); if ((yyvsp[(1) - (1)].ptype).us) { (yyval.type) = NewStringf("%s %s", (yyvsp[(1) - (1)].ptype).us, (yyvsp[(1) - (1)].ptype).type); Delete((yyvsp[(1) - (1)].ptype).us); Delete((yyvsp[(1) - (1)].ptype).type); } else { (yyval.type) = (yyvsp[(1) - (1)].ptype).type; } if (Cmp((yyval.type),"signed int") == 0) { Delete((yyval.type)); (yyval.type) = NewString("int"); } else if (Cmp((yyval.type),"signed long") == 0) { Delete((yyval.type)); (yyval.type) = NewString("long"); } else if (Cmp((yyval.type),"signed short") == 0) { Delete((yyval.type)); (yyval.type) = NewString("short"); } else if (Cmp((yyval.type),"signed long long") == 0) { Delete((yyval.type)); (yyval.type) = NewString("long long"); } } break; case 384: /* Line 1806 of yacc.c */ #line 5616 "parser.y" { (yyval.ptype) = (yyvsp[(1) - (1)].ptype); } break; case 385: /* Line 1806 of yacc.c */ #line 5619 "parser.y" { if ((yyvsp[(1) - (2)].ptype).us && (yyvsp[(2) - (2)].ptype).us) { Swig_error(cparse_file, cparse_line, "Extra %s specifier.\n", (yyvsp[(2) - (2)].ptype).us); } (yyval.ptype) = (yyvsp[(2) - (2)].ptype); if ((yyvsp[(1) - (2)].ptype).us) (yyval.ptype).us = (yyvsp[(1) - (2)].ptype).us; if ((yyvsp[(1) - (2)].ptype).type) { if (!(yyvsp[(2) - (2)].ptype).type) (yyval.ptype).type = (yyvsp[(1) - (2)].ptype).type; else { int err = 0; if ((Cmp((yyvsp[(1) - (2)].ptype).type,"long") == 0)) { if ((Cmp((yyvsp[(2) - (2)].ptype).type,"long") == 0) || (Strncmp((yyvsp[(2) - (2)].ptype).type,"double",6) == 0)) { (yyval.ptype).type = NewStringf("long %s", (yyvsp[(2) - (2)].ptype).type); } else if (Cmp((yyvsp[(2) - (2)].ptype).type,"int") == 0) { (yyval.ptype).type = (yyvsp[(1) - (2)].ptype).type; } else { err = 1; } } else if ((Cmp((yyvsp[(1) - (2)].ptype).type,"short")) == 0) { if (Cmp((yyvsp[(2) - (2)].ptype).type,"int") == 0) { (yyval.ptype).type = (yyvsp[(1) - (2)].ptype).type; } else { err = 1; } } else if (Cmp((yyvsp[(1) - (2)].ptype).type,"int") == 0) { (yyval.ptype).type = (yyvsp[(2) - (2)].ptype).type; } else if (Cmp((yyvsp[(1) - (2)].ptype).type,"double") == 0) { if (Cmp((yyvsp[(2) - (2)].ptype).type,"long") == 0) { (yyval.ptype).type = NewString("long double"); } else if (Cmp((yyvsp[(2) - (2)].ptype).type,"complex") == 0) { (yyval.ptype).type = NewString("double complex"); } else { err = 1; } } else if (Cmp((yyvsp[(1) - (2)].ptype).type,"float") == 0) { if (Cmp((yyvsp[(2) - (2)].ptype).type,"complex") == 0) { (yyval.ptype).type = NewString("float complex"); } else { err = 1; } } else if (Cmp((yyvsp[(1) - (2)].ptype).type,"complex") == 0) { (yyval.ptype).type = NewStringf("%s complex", (yyvsp[(2) - (2)].ptype).type); } else { err = 1; } if (err) { Swig_error(cparse_file, cparse_line, "Extra %s specifier.\n", (yyvsp[(1) - (2)].ptype).type); } } } } break; case 386: /* Line 1806 of yacc.c */ #line 5673 "parser.y" { (yyval.ptype).type = NewString("int"); (yyval.ptype).us = 0; } break; case 387: /* Line 1806 of yacc.c */ #line 5677 "parser.y" { (yyval.ptype).type = NewString("short"); (yyval.ptype).us = 0; } break; case 388: /* Line 1806 of yacc.c */ #line 5681 "parser.y" { (yyval.ptype).type = NewString("long"); (yyval.ptype).us = 0; } break; case 389: /* Line 1806 of yacc.c */ #line 5685 "parser.y" { (yyval.ptype).type = NewString("char"); (yyval.ptype).us = 0; } break; case 390: /* Line 1806 of yacc.c */ #line 5689 "parser.y" { (yyval.ptype).type = NewString("wchar_t"); (yyval.ptype).us = 0; } break; case 391: /* Line 1806 of yacc.c */ #line 5693 "parser.y" { (yyval.ptype).type = NewString("float"); (yyval.ptype).us = 0; } break; case 392: /* Line 1806 of yacc.c */ #line 5697 "parser.y" { (yyval.ptype).type = NewString("double"); (yyval.ptype).us = 0; } break; case 393: /* Line 1806 of yacc.c */ #line 5701 "parser.y" { (yyval.ptype).us = NewString("signed"); (yyval.ptype).type = 0; } break; case 394: /* Line 1806 of yacc.c */ #line 5705 "parser.y" { (yyval.ptype).us = NewString("unsigned"); (yyval.ptype).type = 0; } break; case 395: /* Line 1806 of yacc.c */ #line 5709 "parser.y" { (yyval.ptype).type = NewString("complex"); (yyval.ptype).us = 0; } break; case 396: /* Line 1806 of yacc.c */ #line 5713 "parser.y" { (yyval.ptype).type = NewString("__int8"); (yyval.ptype).us = 0; } break; case 397: /* Line 1806 of yacc.c */ #line 5717 "parser.y" { (yyval.ptype).type = NewString("__int16"); (yyval.ptype).us = 0; } break; case 398: /* Line 1806 of yacc.c */ #line 5721 "parser.y" { (yyval.ptype).type = NewString("__int32"); (yyval.ptype).us = 0; } break; case 399: /* Line 1806 of yacc.c */ #line 5725 "parser.y" { (yyval.ptype).type = NewString("__int64"); (yyval.ptype).us = 0; } break; case 400: /* Line 1806 of yacc.c */ #line 5731 "parser.y" { /* scanner_check_typedef(); */ } break; case 401: /* Line 1806 of yacc.c */ #line 5731 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); if ((yyval.dtype).type == T_STRING) { (yyval.dtype).rawval = NewStringf("\"%(escape)s\"",(yyval.dtype).val); } else if ((yyval.dtype).type != T_CHAR && (yyval.dtype).type != T_WSTRING && (yyval.dtype).type != T_WCHAR) { (yyval.dtype).rawval = 0; } (yyval.dtype).qualifier = 0; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; scanner_ignore_typedef(); } break; case 402: /* Line 1806 of yacc.c */ #line 5745 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 403: /* Line 1806 of yacc.c */ #line 5761 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 404: /* Line 1806 of yacc.c */ #line 5764 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 405: /* Line 1806 of yacc.c */ #line 5770 "parser.y" { (yyval.dtype).val = NewString("delete"); (yyval.dtype).rawval = 0; (yyval.dtype).type = T_STRING; (yyval.dtype).qualifier = 0; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 406: /* Line 1806 of yacc.c */ #line 5783 "parser.y" { (yyval.dtype).val = NewString("default"); (yyval.dtype).rawval = 0; (yyval.dtype).type = T_STRING; (yyval.dtype).qualifier = 0; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 407: /* Line 1806 of yacc.c */ #line 5797 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 408: /* Line 1806 of yacc.c */ #line 5798 "parser.y" { (yyval.id) = (char *) 0;} break; case 409: /* Line 1806 of yacc.c */ #line 5801 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 410: /* Line 1806 of yacc.c */ #line 5802 "parser.y" { (yyval.node) = 0; } break; case 411: /* Line 1806 of yacc.c */ #line 5806 "parser.y" { Node *leftSibling = Getattr((yyvsp[(1) - (5)].node),"_last"); set_nextSibling(leftSibling,(yyvsp[(4) - (5)].node)); Setattr((yyvsp[(1) - (5)].node),"_last",(yyvsp[(4) - (5)].node)); (yyval.node) = (yyvsp[(1) - (5)].node); } break; case 412: /* Line 1806 of yacc.c */ #line 5812 "parser.y" { (yyval.node) = (yyvsp[(1) - (3)].node); } break; case 413: /* Line 1806 of yacc.c */ #line 5815 "parser.y" { Setattr((yyvsp[(2) - (3)].node),"_last",(yyvsp[(2) - (3)].node)); (yyval.node) = (yyvsp[(2) - (3)].node); } break; case 414: /* Line 1806 of yacc.c */ #line 5819 "parser.y" { (yyval.node) = 0; } break; case 415: /* Line 1806 of yacc.c */ #line 5824 "parser.y" { SwigType *type = NewSwigType(T_INT); (yyval.node) = new_node("enumitem"); Setattr((yyval.node),"name",(yyvsp[(1) - (1)].id)); Setattr((yyval.node),"type",type); SetFlag((yyval.node),"feature:immutable"); Delete(type); } break; case 416: /* Line 1806 of yacc.c */ #line 5832 "parser.y" { SwigType *type = NewSwigType((yyvsp[(3) - (3)].dtype).type == T_BOOL ? T_BOOL : ((yyvsp[(3) - (3)].dtype).type == T_CHAR ? T_CHAR : T_INT)); (yyval.node) = new_node("enumitem"); Setattr((yyval.node),"name",(yyvsp[(1) - (3)].id)); Setattr((yyval.node),"type",type); SetFlag((yyval.node),"feature:immutable"); Setattr((yyval.node),"enumvalue", (yyvsp[(3) - (3)].dtype).val); Setattr((yyval.node),"value",(yyvsp[(1) - (3)].id)); Delete(type); } break; case 417: /* Line 1806 of yacc.c */ #line 5844 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); if (((yyval.dtype).type != T_INT) && ((yyval.dtype).type != T_UINT) && ((yyval.dtype).type != T_LONG) && ((yyval.dtype).type != T_ULONG) && ((yyval.dtype).type != T_LONGLONG) && ((yyval.dtype).type != T_ULONGLONG) && ((yyval.dtype).type != T_SHORT) && ((yyval.dtype).type != T_USHORT) && ((yyval.dtype).type != T_SCHAR) && ((yyval.dtype).type != T_UCHAR) && ((yyval.dtype).type != T_CHAR) && ((yyval.dtype).type != T_BOOL)) { Swig_error(cparse_file,cparse_line,"Type error. Expecting an integral type\n"); } } break; case 418: /* Line 1806 of yacc.c */ #line 5859 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 419: /* Line 1806 of yacc.c */ #line 5860 "parser.y" { Node *n; (yyval.dtype).val = (yyvsp[(1) - (1)].type); (yyval.dtype).type = T_INT; /* Check if value is in scope */ n = Swig_symbol_clookup((yyvsp[(1) - (1)].type),0); if (n) { /* A band-aid for enum values used in expressions. */ if (Strcmp(nodeType(n),"enumitem") == 0) { String *q = Swig_symbol_qualified(n); if (q) { (yyval.dtype).val = NewStringf("%s::%s", q, Getattr(n,"name")); Delete(q); } } } } break; case 420: /* Line 1806 of yacc.c */ #line 5879 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 421: /* Line 1806 of yacc.c */ #line 5880 "parser.y" { (yyval.dtype).val = NewString((yyvsp[(1) - (1)].id)); (yyval.dtype).type = T_STRING; } break; case 422: /* Line 1806 of yacc.c */ #line 5884 "parser.y" { SwigType_push((yyvsp[(3) - (5)].type),(yyvsp[(4) - (5)].decl).type); (yyval.dtype).val = NewStringf("sizeof(%s)",SwigType_str((yyvsp[(3) - (5)].type),0)); (yyval.dtype).type = T_ULONG; } break; case 423: /* Line 1806 of yacc.c */ #line 5889 "parser.y" { SwigType_push((yyvsp[(6) - (8)].type),(yyvsp[(7) - (8)].decl).type); (yyval.dtype).val = NewStringf("sizeof...(%s)",SwigType_str((yyvsp[(6) - (8)].type),0)); (yyval.dtype).type = T_ULONG; } break; case 424: /* Line 1806 of yacc.c */ #line 5894 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 425: /* Line 1806 of yacc.c */ #line 5895 "parser.y" { (yyval.dtype).val = NewString((yyvsp[(1) - (1)].id)); (yyval.dtype).rawval = NewStringf("L\"%s\"", (yyval.dtype).val); (yyval.dtype).type = T_WSTRING; } break; case 426: /* Line 1806 of yacc.c */ #line 5900 "parser.y" { (yyval.dtype).val = NewString((yyvsp[(1) - (1)].str)); if (Len((yyval.dtype).val)) { (yyval.dtype).rawval = NewStringf("'%(escape)s'", (yyval.dtype).val); } else { (yyval.dtype).rawval = NewString("'\\0'"); } (yyval.dtype).type = T_CHAR; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 427: /* Line 1806 of yacc.c */ #line 5913 "parser.y" { (yyval.dtype).val = NewString((yyvsp[(1) - (1)].str)); if (Len((yyval.dtype).val)) { (yyval.dtype).rawval = NewStringf("L\'%s\'", (yyval.dtype).val); } else { (yyval.dtype).rawval = NewString("L'\\0'"); } (yyval.dtype).type = T_WCHAR; (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 428: /* Line 1806 of yacc.c */ #line 5928 "parser.y" { (yyval.dtype).val = NewStringf("(%s)",(yyvsp[(2) - (3)].dtype).val); (yyval.dtype).type = (yyvsp[(2) - (3)].dtype).type; } break; case 429: /* Line 1806 of yacc.c */ #line 5935 "parser.y" { (yyval.dtype) = (yyvsp[(4) - (4)].dtype); if ((yyvsp[(4) - (4)].dtype).type != T_STRING) { switch ((yyvsp[(2) - (4)].dtype).type) { case T_FLOAT: case T_DOUBLE: case T_LONGDOUBLE: case T_FLTCPLX: case T_DBLCPLX: (yyval.dtype).val = NewStringf("(%s)%s", (yyvsp[(2) - (4)].dtype).val, (yyvsp[(4) - (4)].dtype).val); /* SwigType_str and decimal points don't mix! */ break; default: (yyval.dtype).val = NewStringf("(%s) %s", SwigType_str((yyvsp[(2) - (4)].dtype).val,0), (yyvsp[(4) - (4)].dtype).val); break; } } } break; case 430: /* Line 1806 of yacc.c */ #line 5952 "parser.y" { (yyval.dtype) = (yyvsp[(5) - (5)].dtype); if ((yyvsp[(5) - (5)].dtype).type != T_STRING) { SwigType_push((yyvsp[(2) - (5)].dtype).val,(yyvsp[(3) - (5)].type)); (yyval.dtype).val = NewStringf("(%s) %s", SwigType_str((yyvsp[(2) - (5)].dtype).val,0), (yyvsp[(5) - (5)].dtype).val); } } break; case 431: /* Line 1806 of yacc.c */ #line 5959 "parser.y" { (yyval.dtype) = (yyvsp[(5) - (5)].dtype); if ((yyvsp[(5) - (5)].dtype).type != T_STRING) { SwigType_add_reference((yyvsp[(2) - (5)].dtype).val); (yyval.dtype).val = NewStringf("(%s) %s", SwigType_str((yyvsp[(2) - (5)].dtype).val,0), (yyvsp[(5) - (5)].dtype).val); } } break; case 432: /* Line 1806 of yacc.c */ #line 5966 "parser.y" { (yyval.dtype) = (yyvsp[(5) - (5)].dtype); if ((yyvsp[(5) - (5)].dtype).type != T_STRING) { SwigType_add_rvalue_reference((yyvsp[(2) - (5)].dtype).val); (yyval.dtype).val = NewStringf("(%s) %s", SwigType_str((yyvsp[(2) - (5)].dtype).val,0), (yyvsp[(5) - (5)].dtype).val); } } break; case 433: /* Line 1806 of yacc.c */ #line 5973 "parser.y" { (yyval.dtype) = (yyvsp[(6) - (6)].dtype); if ((yyvsp[(6) - (6)].dtype).type != T_STRING) { SwigType_push((yyvsp[(2) - (6)].dtype).val,(yyvsp[(3) - (6)].type)); SwigType_add_reference((yyvsp[(2) - (6)].dtype).val); (yyval.dtype).val = NewStringf("(%s) %s", SwigType_str((yyvsp[(2) - (6)].dtype).val,0), (yyvsp[(6) - (6)].dtype).val); } } break; case 434: /* Line 1806 of yacc.c */ #line 5981 "parser.y" { (yyval.dtype) = (yyvsp[(6) - (6)].dtype); if ((yyvsp[(6) - (6)].dtype).type != T_STRING) { SwigType_push((yyvsp[(2) - (6)].dtype).val,(yyvsp[(3) - (6)].type)); SwigType_add_rvalue_reference((yyvsp[(2) - (6)].dtype).val); (yyval.dtype).val = NewStringf("(%s) %s", SwigType_str((yyvsp[(2) - (6)].dtype).val,0), (yyvsp[(6) - (6)].dtype).val); } } break; case 435: /* Line 1806 of yacc.c */ #line 5989 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); (yyval.dtype).val = NewStringf("&%s",(yyvsp[(2) - (2)].dtype).val); } break; case 436: /* Line 1806 of yacc.c */ #line 5993 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); (yyval.dtype).val = NewStringf("&&%s",(yyvsp[(2) - (2)].dtype).val); } break; case 437: /* Line 1806 of yacc.c */ #line 5997 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); (yyval.dtype).val = NewStringf("*%s",(yyvsp[(2) - (2)].dtype).val); } break; case 438: /* Line 1806 of yacc.c */ #line 6003 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 439: /* Line 1806 of yacc.c */ #line 6004 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 440: /* Line 1806 of yacc.c */ #line 6005 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 441: /* Line 1806 of yacc.c */ #line 6006 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 442: /* Line 1806 of yacc.c */ #line 6007 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 443: /* Line 1806 of yacc.c */ #line 6008 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 444: /* Line 1806 of yacc.c */ #line 6009 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 445: /* Line 1806 of yacc.c */ #line 6010 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 446: /* Line 1806 of yacc.c */ #line 6013 "parser.y" { (yyval.dtype).val = NewStringf("%s+%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type); } break; case 447: /* Line 1806 of yacc.c */ #line 6017 "parser.y" { (yyval.dtype).val = NewStringf("%s-%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type); } break; case 448: /* Line 1806 of yacc.c */ #line 6021 "parser.y" { (yyval.dtype).val = NewStringf("%s*%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type); } break; case 449: /* Line 1806 of yacc.c */ #line 6025 "parser.y" { (yyval.dtype).val = NewStringf("%s/%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type); } break; case 450: /* Line 1806 of yacc.c */ #line 6029 "parser.y" { (yyval.dtype).val = NewStringf("%s%%%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type); } break; case 451: /* Line 1806 of yacc.c */ #line 6033 "parser.y" { (yyval.dtype).val = NewStringf("%s&%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type); } break; case 452: /* Line 1806 of yacc.c */ #line 6037 "parser.y" { (yyval.dtype).val = NewStringf("%s|%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type); } break; case 453: /* Line 1806 of yacc.c */ #line 6041 "parser.y" { (yyval.dtype).val = NewStringf("%s^%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type); } break; case 454: /* Line 1806 of yacc.c */ #line 6045 "parser.y" { (yyval.dtype).val = NewStringf("%s << %s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote_type((yyvsp[(1) - (3)].dtype).type); } break; case 455: /* Line 1806 of yacc.c */ #line 6049 "parser.y" { (yyval.dtype).val = NewStringf("%s >> %s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = promote_type((yyvsp[(1) - (3)].dtype).type); } break; case 456: /* Line 1806 of yacc.c */ #line 6053 "parser.y" { (yyval.dtype).val = NewStringf("%s&&%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = cparse_cplusplus ? T_BOOL : T_INT; } break; case 457: /* Line 1806 of yacc.c */ #line 6057 "parser.y" { (yyval.dtype).val = NewStringf("%s||%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = cparse_cplusplus ? T_BOOL : T_INT; } break; case 458: /* Line 1806 of yacc.c */ #line 6061 "parser.y" { (yyval.dtype).val = NewStringf("%s==%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = cparse_cplusplus ? T_BOOL : T_INT; } break; case 459: /* Line 1806 of yacc.c */ #line 6065 "parser.y" { (yyval.dtype).val = NewStringf("%s!=%s",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = cparse_cplusplus ? T_BOOL : T_INT; } break; case 460: /* Line 1806 of yacc.c */ #line 6079 "parser.y" { (yyval.dtype).val = NewStringf("%s >= %s", (yyvsp[(1) - (3)].dtype).val, (yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = cparse_cplusplus ? T_BOOL : T_INT; } break; case 461: /* Line 1806 of yacc.c */ #line 6083 "parser.y" { (yyval.dtype).val = NewStringf("%s <= %s", (yyvsp[(1) - (3)].dtype).val, (yyvsp[(3) - (3)].dtype).val); (yyval.dtype).type = cparse_cplusplus ? T_BOOL : T_INT; } break; case 462: /* Line 1806 of yacc.c */ #line 6087 "parser.y" { (yyval.dtype).val = NewStringf("%s?%s:%s", (yyvsp[(1) - (5)].dtype).val, (yyvsp[(3) - (5)].dtype).val, (yyvsp[(5) - (5)].dtype).val); /* This may not be exactly right, but is probably good enough * for the purposes of parsing constant expressions. */ (yyval.dtype).type = promote((yyvsp[(3) - (5)].dtype).type, (yyvsp[(5) - (5)].dtype).type); } break; case 463: /* Line 1806 of yacc.c */ #line 6093 "parser.y" { (yyval.dtype).val = NewStringf("-%s",(yyvsp[(2) - (2)].dtype).val); (yyval.dtype).type = (yyvsp[(2) - (2)].dtype).type; } break; case 464: /* Line 1806 of yacc.c */ #line 6097 "parser.y" { (yyval.dtype).val = NewStringf("+%s",(yyvsp[(2) - (2)].dtype).val); (yyval.dtype).type = (yyvsp[(2) - (2)].dtype).type; } break; case 465: /* Line 1806 of yacc.c */ #line 6101 "parser.y" { (yyval.dtype).val = NewStringf("~%s",(yyvsp[(2) - (2)].dtype).val); (yyval.dtype).type = (yyvsp[(2) - (2)].dtype).type; } break; case 466: /* Line 1806 of yacc.c */ #line 6105 "parser.y" { (yyval.dtype).val = NewStringf("!%s",(yyvsp[(2) - (2)].dtype).val); (yyval.dtype).type = T_INT; } break; case 467: /* Line 1806 of yacc.c */ #line 6109 "parser.y" { String *qty; skip_balanced('(',')'); qty = Swig_symbol_type_qualify((yyvsp[(1) - (2)].type),0); if (SwigType_istemplate(qty)) { String *nstr = SwigType_namestr(qty); Delete(qty); qty = nstr; } (yyval.dtype).val = NewStringf("%s%s",qty,scanner_ccode); Clear(scanner_ccode); (yyval.dtype).type = T_INT; Delete(qty); } break; case 468: /* Line 1806 of yacc.c */ #line 6125 "parser.y" { (yyval.str) = NewString("..."); } break; case 469: /* Line 1806 of yacc.c */ #line 6130 "parser.y" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; case 470: /* Line 1806 of yacc.c */ #line 6133 "parser.y" { (yyval.str) = 0; } break; case 471: /* Line 1806 of yacc.c */ #line 6138 "parser.y" { (yyval.bases) = (yyvsp[(1) - (1)].bases); } break; case 472: /* Line 1806 of yacc.c */ #line 6143 "parser.y" { inherit_list = 1; } break; case 473: /* Line 1806 of yacc.c */ #line 6143 "parser.y" { (yyval.bases) = (yyvsp[(3) - (3)].bases); inherit_list = 0; } break; case 474: /* Line 1806 of yacc.c */ #line 6144 "parser.y" { (yyval.bases) = 0; } break; case 475: /* Line 1806 of yacc.c */ #line 6147 "parser.y" { Hash *list = NewHash(); Node *base = (yyvsp[(1) - (1)].node); Node *name = Getattr(base,"name"); List *lpublic = NewList(); List *lprotected = NewList(); List *lprivate = NewList(); Setattr(list,"public",lpublic); Setattr(list,"protected",lprotected); Setattr(list,"private",lprivate); Delete(lpublic); Delete(lprotected); Delete(lprivate); Append(Getattr(list,Getattr(base,"access")),name); (yyval.bases) = list; } break; case 476: /* Line 1806 of yacc.c */ #line 6164 "parser.y" { Hash *list = (yyvsp[(1) - (3)].bases); Node *base = (yyvsp[(3) - (3)].node); Node *name = Getattr(base,"name"); Append(Getattr(list,Getattr(base,"access")),name); (yyval.bases) = list; } break; case 477: /* Line 1806 of yacc.c */ #line 6173 "parser.y" { (yyval.intvalue) = cparse_line; } break; case 478: /* Line 1806 of yacc.c */ #line 6175 "parser.y" { (yyval.node) = NewHash(); Setfile((yyval.node),cparse_file); Setline((yyval.node),(yyvsp[(2) - (4)].intvalue)); Setattr((yyval.node),"name",(yyvsp[(3) - (4)].str)); Setfile((yyvsp[(3) - (4)].str),cparse_file); Setline((yyvsp[(3) - (4)].str),(yyvsp[(2) - (4)].intvalue)); if (last_cpptype && (Strcmp(last_cpptype,"struct") != 0)) { Setattr((yyval.node),"access","private"); Swig_warning(WARN_PARSE_NO_ACCESS, Getfile((yyval.node)), Getline((yyval.node)), "No access specifier given for base class '%s' (ignored).\n", SwigType_namestr((yyvsp[(3) - (4)].str))); } else { Setattr((yyval.node),"access","public"); } if ((yyvsp[(4) - (4)].str)) SetFlag((yyval.node), "variadic"); } break; case 479: /* Line 1806 of yacc.c */ #line 6191 "parser.y" { (yyval.intvalue) = cparse_line; } break; case 480: /* Line 1806 of yacc.c */ #line 6193 "parser.y" { (yyval.node) = NewHash(); Setfile((yyval.node),cparse_file); Setline((yyval.node),(yyvsp[(3) - (6)].intvalue)); Setattr((yyval.node),"name",(yyvsp[(5) - (6)].str)); Setfile((yyvsp[(5) - (6)].str),cparse_file); Setline((yyvsp[(5) - (6)].str),(yyvsp[(3) - (6)].intvalue)); Setattr((yyval.node),"access",(yyvsp[(2) - (6)].id)); if (Strcmp((yyvsp[(2) - (6)].id),"public") != 0) { Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile((yyval.node)), Getline((yyval.node)), "%s inheritance from base '%s' (ignored).\n", (yyvsp[(2) - (6)].id), SwigType_namestr((yyvsp[(5) - (6)].str))); } if ((yyvsp[(6) - (6)].str)) SetFlag((yyval.node), "variadic"); } break; case 481: /* Line 1806 of yacc.c */ #line 6209 "parser.y" { (yyval.id) = (char*)"public"; } break; case 482: /* Line 1806 of yacc.c */ #line 6210 "parser.y" { (yyval.id) = (char*)"private"; } break; case 483: /* Line 1806 of yacc.c */ #line 6211 "parser.y" { (yyval.id) = (char*)"protected"; } break; case 484: /* Line 1806 of yacc.c */ #line 6215 "parser.y" { (yyval.id) = (char*)"class"; if (!inherit_list) last_cpptype = (yyval.id); } break; case 485: /* Line 1806 of yacc.c */ #line 6219 "parser.y" { (yyval.id) = (char *)"typename"; if (!inherit_list) last_cpptype = (yyval.id); } break; case 486: /* Line 1806 of yacc.c */ #line 6223 "parser.y" { (yyval.id) = (char *)"class..."; if (!inherit_list) last_cpptype = (yyval.id); } break; case 487: /* Line 1806 of yacc.c */ #line 6227 "parser.y" { (yyval.id) = (char *)"typename..."; if (!inherit_list) last_cpptype = (yyval.id); } break; case 488: /* Line 1806 of yacc.c */ #line 6233 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 489: /* Line 1806 of yacc.c */ #line 6236 "parser.y" { (yyval.id) = (char*)"struct"; if (!inherit_list) last_cpptype = (yyval.id); } break; case 490: /* Line 1806 of yacc.c */ #line 6240 "parser.y" { (yyval.id) = (char*)"union"; if (!inherit_list) last_cpptype = (yyval.id); } break; case 493: /* Line 1806 of yacc.c */ #line 6250 "parser.y" { (yyval.str) = 0; } break; case 494: /* Line 1806 of yacc.c */ #line 6253 "parser.y" { (yyval.str) = 0; } break; case 495: /* Line 1806 of yacc.c */ #line 6256 "parser.y" { (yyval.str) = 0; } break; case 496: /* Line 1806 of yacc.c */ #line 6259 "parser.y" { (yyval.str) = 0; } break; case 497: /* Line 1806 of yacc.c */ #line 6264 "parser.y" { (yyval.dtype).throws = (yyvsp[(3) - (4)].pl); (yyval.dtype).throwf = NewString("1"); (yyval.dtype).nexcept = 0; } break; case 498: /* Line 1806 of yacc.c */ #line 6269 "parser.y" { (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = NewString("true"); } break; case 499: /* Line 1806 of yacc.c */ #line 6274 "parser.y" { (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; } break; case 500: /* Line 1806 of yacc.c */ #line 6279 "parser.y" { (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = NewString("true"); } break; case 501: /* Line 1806 of yacc.c */ #line 6284 "parser.y" { (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = (yyvsp[(3) - (4)].dtype).val; } break; case 502: /* Line 1806 of yacc.c */ #line 6291 "parser.y" { (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; (yyval.dtype).qualifier = (yyvsp[(1) - (1)].str); } break; case 503: /* Line 1806 of yacc.c */ #line 6297 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); (yyval.dtype).qualifier = 0; } break; case 504: /* Line 1806 of yacc.c */ #line 6301 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); (yyval.dtype).qualifier = (yyvsp[(1) - (2)].str); } break; case 505: /* Line 1806 of yacc.c */ #line 6305 "parser.y" { (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; (yyval.dtype).nexcept = 0; (yyval.dtype).qualifier = 0; } break; case 506: /* Line 1806 of yacc.c */ #line 6313 "parser.y" { Clear(scanner_ccode); (yyval.decl).have_parms = 0; (yyval.decl).defarg = 0; (yyval.decl).throws = (yyvsp[(1) - (3)].dtype).throws; (yyval.decl).throwf = (yyvsp[(1) - (3)].dtype).throwf; (yyval.decl).nexcept = (yyvsp[(1) - (3)].dtype).nexcept; } break; case 507: /* Line 1806 of yacc.c */ #line 6321 "parser.y" { skip_balanced('{','}'); (yyval.decl).have_parms = 0; (yyval.decl).defarg = 0; (yyval.decl).throws = (yyvsp[(1) - (3)].dtype).throws; (yyval.decl).throwf = (yyvsp[(1) - (3)].dtype).throwf; (yyval.decl).nexcept = (yyvsp[(1) - (3)].dtype).nexcept; } break; case 508: /* Line 1806 of yacc.c */ #line 6329 "parser.y" { Clear(scanner_ccode); (yyval.decl).parms = (yyvsp[(2) - (4)].pl); (yyval.decl).have_parms = 1; (yyval.decl).defarg = 0; (yyval.decl).throws = 0; (yyval.decl).throwf = 0; (yyval.decl).nexcept = 0; } break; case 509: /* Line 1806 of yacc.c */ #line 6338 "parser.y" { skip_balanced('{','}'); (yyval.decl).parms = (yyvsp[(2) - (4)].pl); (yyval.decl).have_parms = 1; (yyval.decl).defarg = 0; (yyval.decl).throws = 0; (yyval.decl).throwf = 0; (yyval.decl).nexcept = 0; } break; case 510: /* Line 1806 of yacc.c */ #line 6347 "parser.y" { (yyval.decl).have_parms = 0; (yyval.decl).defarg = (yyvsp[(2) - (3)].dtype).val; (yyval.decl).throws = 0; (yyval.decl).throwf = 0; (yyval.decl).nexcept = 0; } break; case 511: /* Line 1806 of yacc.c */ #line 6354 "parser.y" { (yyval.decl).have_parms = 0; (yyval.decl).defarg = (yyvsp[(3) - (4)].dtype).val; (yyval.decl).throws = (yyvsp[(1) - (4)].dtype).throws; (yyval.decl).throwf = (yyvsp[(1) - (4)].dtype).throwf; (yyval.decl).nexcept = (yyvsp[(1) - (4)].dtype).nexcept; } break; case 518: /* Line 1806 of yacc.c */ #line 6373 "parser.y" { skip_balanced('(',')'); Clear(scanner_ccode); } break; case 519: /* Line 1806 of yacc.c */ #line 6385 "parser.y" { skip_balanced('{','}'); Clear(scanner_ccode); } break; case 520: /* Line 1806 of yacc.c */ #line 6391 "parser.y" { String *s = NewStringEmpty(); SwigType_add_template(s,(yyvsp[(2) - (3)].p)); (yyval.id) = Char(s); scanner_last_id(1); } break; case 521: /* Line 1806 of yacc.c */ #line 6397 "parser.y" { (yyval.id) = (char*)""; } break; case 522: /* Line 1806 of yacc.c */ #line 6401 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 523: /* Line 1806 of yacc.c */ #line 6402 "parser.y" { (yyval.id) = Swig_copy_string("override"); } break; case 524: /* Line 1806 of yacc.c */ #line 6403 "parser.y" { (yyval.id) = Swig_copy_string("final"); } break; case 525: /* Line 1806 of yacc.c */ #line 6406 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 526: /* Line 1806 of yacc.c */ #line 6407 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].dtype).val; } break; case 527: /* Line 1806 of yacc.c */ #line 6408 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 528: /* Line 1806 of yacc.c */ #line 6411 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 529: /* Line 1806 of yacc.c */ #line 6412 "parser.y" { (yyval.id) = 0; } break; case 530: /* Line 1806 of yacc.c */ #line 6415 "parser.y" { (yyval.str) = 0; if (!(yyval.str)) (yyval.str) = NewStringf("%s%s", (yyvsp[(1) - (2)].str),(yyvsp[(2) - (2)].str)); Delete((yyvsp[(2) - (2)].str)); } break; case 531: /* Line 1806 of yacc.c */ #line 6420 "parser.y" { (yyval.str) = NewStringf("::%s%s",(yyvsp[(3) - (4)].str),(yyvsp[(4) - (4)].str)); Delete((yyvsp[(4) - (4)].str)); } break; case 532: /* Line 1806 of yacc.c */ #line 6424 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].str)); } break; case 533: /* Line 1806 of yacc.c */ #line 6427 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(3) - (3)].str)); } break; case 534: /* Line 1806 of yacc.c */ #line 6430 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].str)); } break; case 535: /* Line 1806 of yacc.c */ #line 6433 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(3) - (3)].str)); } break; case 536: /* Line 1806 of yacc.c */ #line 6438 "parser.y" { (yyval.str) = NewStringf("::%s%s",(yyvsp[(2) - (3)].str),(yyvsp[(3) - (3)].str)); Delete((yyvsp[(3) - (3)].str)); } break; case 537: /* Line 1806 of yacc.c */ #line 6442 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(2) - (2)].str)); } break; case 538: /* Line 1806 of yacc.c */ #line 6445 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(2) - (2)].str)); } break; case 539: /* Line 1806 of yacc.c */ #line 6452 "parser.y" { (yyval.str) = NewStringf("::~%s",(yyvsp[(2) - (2)].str)); } break; case 540: /* Line 1806 of yacc.c */ #line 6458 "parser.y" { (yyval.str) = NewStringf("%s%s",(yyvsp[(1) - (2)].id),(yyvsp[(2) - (2)].id)); /* if (Len($2)) { scanner_last_id(1); } */ } break; case 541: /* Line 1806 of yacc.c */ #line 6467 "parser.y" { (yyval.str) = 0; if (!(yyval.str)) (yyval.str) = NewStringf("%s%s", (yyvsp[(1) - (2)].id),(yyvsp[(2) - (2)].str)); Delete((yyvsp[(2) - (2)].str)); } break; case 542: /* Line 1806 of yacc.c */ #line 6472 "parser.y" { (yyval.str) = NewStringf("::%s%s",(yyvsp[(3) - (4)].id),(yyvsp[(4) - (4)].str)); Delete((yyvsp[(4) - (4)].str)); } break; case 543: /* Line 1806 of yacc.c */ #line 6476 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].id)); } break; case 544: /* Line 1806 of yacc.c */ #line 6479 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(3) - (3)].id)); } break; case 545: /* Line 1806 of yacc.c */ #line 6482 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].str)); } break; case 546: /* Line 1806 of yacc.c */ #line 6485 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(3) - (3)].str)); } break; case 547: /* Line 1806 of yacc.c */ #line 6490 "parser.y" { (yyval.str) = NewStringf("::%s%s",(yyvsp[(2) - (3)].id),(yyvsp[(3) - (3)].str)); Delete((yyvsp[(3) - (3)].str)); } break; case 548: /* Line 1806 of yacc.c */ #line 6494 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(2) - (2)].id)); } break; case 549: /* Line 1806 of yacc.c */ #line 6497 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(2) - (2)].str)); } break; case 550: /* Line 1806 of yacc.c */ #line 6500 "parser.y" { (yyval.str) = NewStringf("::~%s",(yyvsp[(2) - (2)].id)); } break; case 551: /* Line 1806 of yacc.c */ #line 6506 "parser.y" { (yyval.id) = (char *) malloc(strlen((yyvsp[(1) - (2)].id))+strlen((yyvsp[(2) - (2)].id))+1); strcpy((yyval.id),(yyvsp[(1) - (2)].id)); strcat((yyval.id),(yyvsp[(2) - (2)].id)); } break; case 552: /* Line 1806 of yacc.c */ #line 6511 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id);} break; case 553: /* Line 1806 of yacc.c */ #line 6514 "parser.y" { (yyval.id) = (char *) malloc(strlen((yyvsp[(1) - (2)].id))+strlen((yyvsp[(2) - (2)].id))+1); strcpy((yyval.id),(yyvsp[(1) - (2)].id)); strcat((yyval.id),(yyvsp[(2) - (2)].id)); } break; case 554: /* Line 1806 of yacc.c */ #line 6526 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id);} break; case 555: /* Line 1806 of yacc.c */ #line 6529 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].id)); } break; case 556: /* Line 1806 of yacc.c */ #line 6532 "parser.y" { skip_balanced('{','}'); (yyval.str) = NewString(scanner_ccode); } break; case 557: /* Line 1806 of yacc.c */ #line 6536 "parser.y" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; case 558: /* Line 1806 of yacc.c */ #line 6541 "parser.y" { Hash *n; (yyval.node) = NewHash(); n = (yyvsp[(2) - (3)].node); while(n) { String *name, *value; name = Getattr(n,"name"); value = Getattr(n,"value"); if (!value) value = (String *) "1"; Setattr((yyval.node),name, value); n = nextSibling(n); } } break; case 559: /* Line 1806 of yacc.c */ #line 6554 "parser.y" { (yyval.node) = 0; } break; case 560: /* Line 1806 of yacc.c */ #line 6558 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"name",(yyvsp[(1) - (3)].id)); Setattr((yyval.node),"value",(yyvsp[(3) - (3)].id)); } break; case 561: /* Line 1806 of yacc.c */ #line 6563 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"name",(yyvsp[(1) - (5)].id)); Setattr((yyval.node),"value",(yyvsp[(3) - (5)].id)); set_nextSibling((yyval.node),(yyvsp[(5) - (5)].node)); } break; case 562: /* Line 1806 of yacc.c */ #line 6569 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"name",(yyvsp[(1) - (1)].id)); } break; case 563: /* Line 1806 of yacc.c */ #line 6573 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"name",(yyvsp[(1) - (3)].id)); set_nextSibling((yyval.node),(yyvsp[(3) - (3)].node)); } break; case 564: /* Line 1806 of yacc.c */ #line 6578 "parser.y" { (yyval.node) = (yyvsp[(3) - (3)].node); Setattr((yyval.node),"name",(yyvsp[(1) - (3)].id)); } break; case 565: /* Line 1806 of yacc.c */ #line 6582 "parser.y" { (yyval.node) = (yyvsp[(3) - (5)].node); Setattr((yyval.node),"name",(yyvsp[(1) - (5)].id)); set_nextSibling((yyval.node),(yyvsp[(5) - (5)].node)); } break; case 566: /* Line 1806 of yacc.c */ #line 6589 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 567: /* Line 1806 of yacc.c */ #line 6592 "parser.y" { (yyval.id) = Char((yyvsp[(1) - (1)].dtype).val); } break; /* Line 1806 of yacc.c */ #line 12672 "y.tab.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } *++yyvsp = yylval; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif /* Make sure YYID is used. */ return YYID (yyresult); } /* Line 2067 of yacc.c */ #line 6599 "parser.y" SwigType *Swig_cparse_type(String *s) { String *ns; ns = NewStringf("%s;",s); Seek(ns,0,SEEK_SET); scanner_file(ns); top = 0; scanner_next_token(PARSETYPE); yyparse(); /* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */ return top; } Parm *Swig_cparse_parm(String *s) { String *ns; ns = NewStringf("%s;",s); Seek(ns,0,SEEK_SET); scanner_file(ns); top = 0; scanner_next_token(PARSEPARM); yyparse(); /* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */ Delete(ns); return top; } ParmList *Swig_cparse_parms(String *s, Node *file_line_node) { String *ns; char *cs = Char(s); if (cs && cs[0] != '(') { ns = NewStringf("(%s);",s); } else { ns = NewStringf("%s;",s); } Setfile(ns, Getfile(file_line_node)); Setline(ns, Getline(file_line_node)); Seek(ns,0,SEEK_SET); scanner_file(ns); top = 0; scanner_next_token(PARSEPARMS); yyparse(); /* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */ return top; } swig-3.0.2/Source/CParse/util.c0000664000175000017500000000554212343605122016107 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * util.c * * Parsing utilities. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "cparse.h" /* ----------------------------------------------------------------------------- * Swig_cparse_replace_descriptor() * * Replaces type descriptor string $descriptor() with the SWIG type descriptor * string. * ----------------------------------------------------------------------------- */ void Swig_cparse_replace_descriptor(String *s) { char tmp[512]; String *arg = 0; SwigType *t; char *c = 0; while ((c = strstr(Char(s), "$descriptor("))) { char *d = tmp; int level = 0; while (*c) { if (*c == '(') level++; if (*c == ')') { level--; if (level == 0) { break; } } *d = *c; d++; c++; } *d = 0; arg = NewString(tmp + 12); t = Swig_cparse_type(arg); Delete(arg); arg = 0; if (t) { String *mangle; String *descriptor; mangle = SwigType_manglestr(t); descriptor = NewStringf("SWIGTYPE%s", mangle); SwigType_remember(t); *d = ')'; d++; *d = 0; Replace(s, tmp, descriptor, DOH_REPLACE_ANY); Delete(mangle); Delete(descriptor); Delete(t); } else { Swig_error(Getfile(s), Getline(s), "Bad $descriptor() macro.\n"); break; } } } /* ----------------------------------------------------------------------------- * cparse_normalize_void() * * This function is used to replace arguments of the form (void) with empty * arguments in C++ * ----------------------------------------------------------------------------- */ void cparse_normalize_void(Node *n) { String *decl = Getattr(n, "decl"); Parm *parms = Getattr(n, "parms"); if (SwigType_isfunction(decl)) { if ((ParmList_len(parms) == 1) && (SwigType_type(Getattr(parms, "type")) == T_VOID)) { Replaceall(decl, "f(void).", "f()."); Delattr(n, "parms"); } } } /* ----------------------------------------------------------------------------- * new_node() * * Create an empty parse node, setting file and line number information * ----------------------------------------------------------------------------- */ Node *new_node(const_String_or_char_ptr tag) { Node *n = NewHash(); set_nodeType(n,tag); Setfile(n,cparse_file); Setline(n,cparse_line); return n; } swig-3.0.2/Source/CParse/templ.c0000664000175000017500000006541112343605122016254 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * templ.c * * Expands a template into a specialized version. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "cparse.h" static int template_debug = 0; const char *baselists[3]; void SwigType_template_init() { baselists[0] = "baselist"; baselists[1] = "protectedbaselist"; baselists[2] = "privatebaselist"; } static void add_parms(ParmList *p, List *patchlist, List *typelist) { while (p) { SwigType *ty = Getattr(p, "type"); SwigType *val = Getattr(p, "value"); Append(typelist, ty); Append(typelist, val); Append(patchlist, val); p = nextSibling(p); } } void Swig_cparse_debug_templates(int x) { template_debug = x; } /* ----------------------------------------------------------------------------- * cparse_template_expand() * * Expands a template node into a specialized version. This is done by * patching typenames and other aspects of the node according to a list of * template parameters * ----------------------------------------------------------------------------- */ static int cparse_template_expand(Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) { static int expanded = 0; int ret; String *nodeType; if (!n) return 0; nodeType = nodeType(n); if (Getattr(n, "error")) return 0; if (Equal(nodeType, "template")) { /* Change the node type back to normal */ if (!expanded) { expanded = 1; set_nodeType(n, Getattr(n, "templatetype")); ret = cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); expanded = 0; return ret; } else { /* Called when template appears inside another template */ /* Member templates */ set_nodeType(n, Getattr(n, "templatetype")); ret = cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); set_nodeType(n, "template"); return ret; } } else if (Equal(nodeType, "cdecl")) { /* A simple C declaration */ SwigType *t, *v, *d; String *code; t = Getattr(n, "type"); v = Getattr(n, "value"); d = Getattr(n, "decl"); code = Getattr(n, "code"); Append(typelist, t); Append(typelist, d); Append(patchlist, v); Append(cpatchlist, code); if (Getattr(n, "conversion_operator")) { Append(cpatchlist, Getattr(n, "name")); if (Getattr(n, "sym:name")) { Append(cpatchlist, Getattr(n, "sym:name")); } } add_parms(Getattr(n, "parms"), cpatchlist, typelist); add_parms(Getattr(n, "throws"), cpatchlist, typelist); } else if (Equal(nodeType, "class")) { /* Patch base classes */ { int b = 0; for (b = 0; b < 3; ++b) { List *bases = Getattr(n, baselists[b]); if (bases) { int i; int ilen = Len(bases); for (i = 0; i < ilen; i++) { String *name = Copy(Getitem(bases, i)); Setitem(bases, i, name); Append(typelist, name); } } } } /* Patch children */ { Node *cn = firstChild(n); while (cn) { cparse_template_expand(cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); cn = nextSibling(cn); } } } else if (Equal(nodeType, "constructor")) { String *name = Getattr(n, "name"); if (!(Getattr(n, "templatetype"))) { String *symname; String *stripped_name = SwigType_templateprefix(name); if (Strstr(tname, stripped_name)) { Replaceid(name, stripped_name, tname); } Delete(stripped_name); symname = Getattr(n, "sym:name"); if (symname) { stripped_name = SwigType_templateprefix(symname); if (Strstr(tname, stripped_name)) { Replaceid(symname, stripped_name, tname); } Delete(stripped_name); } if (strchr(Char(name), '<')) { Append(patchlist, Getattr(n, "name")); } else { Append(name, templateargs); } name = Getattr(n, "sym:name"); if (name) { if (strchr(Char(name), '<')) { Clear(name); Append(name, rname); } else { String *tmp = Copy(name); Replace(tmp, tname, rname, DOH_REPLACE_ANY); Clear(name); Append(name, tmp); Delete(tmp); } } /* Setattr(n,"sym:name",name); */ } Append(cpatchlist, Getattr(n, "code")); Append(typelist, Getattr(n, "decl")); add_parms(Getattr(n, "parms"), cpatchlist, typelist); add_parms(Getattr(n, "throws"), cpatchlist, typelist); } else if (Equal(nodeType, "destructor")) { String *name = Getattr(n, "name"); if (name) { if (strchr(Char(name), '<')) Append(patchlist, Getattr(n, "name")); else Append(name, templateargs); } name = Getattr(n, "sym:name"); if (name) { if (strchr(Char(name), '<')) { String *sn = Copy(tname); Setattr(n, "sym:name", sn); Delete(sn); } else { Replace(name, tname, rname, DOH_REPLACE_ANY); } } /* Setattr(n,"sym:name",name); */ Append(cpatchlist, Getattr(n, "code")); } else if (Equal(nodeType, "using")) { String *uname = Getattr(n, "uname"); if (uname && strchr(Char(uname), '<')) { Append(patchlist, uname); } if (Getattr(n, "namespace")) { /* Namespace link. This is nasty. Is other namespace defined? */ } } else { /* Look for obvious parameters */ Node *cn; Append(cpatchlist, Getattr(n, "code")); Append(typelist, Getattr(n, "type")); Append(typelist, Getattr(n, "decl")); add_parms(Getattr(n, "parms"), cpatchlist, typelist); add_parms(Getattr(n, "kwargs"), cpatchlist, typelist); add_parms(Getattr(n, "pattern"), cpatchlist, typelist); add_parms(Getattr(n, "throws"), cpatchlist, typelist); cn = firstChild(n); while (cn) { cparse_template_expand(cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); cn = nextSibling(cn); } } return 0; } static String *partial_arg(String *s, String *p) { char *c; char *cp = Char(p); String *prefix; String *newarg; /* Find the prefix on the partial argument */ c = strchr(cp, '$'); if (!c) { return Copy(s); } prefix = NewStringWithSize(cp, c - cp); newarg = Copy(s); Replace(newarg, prefix, "", DOH_REPLACE_ANY | DOH_REPLACE_FIRST); Delete(prefix); return newarg; } /* ----------------------------------------------------------------------------- * Swig_cparse_template_expand() * ----------------------------------------------------------------------------- */ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *tscope) { List *patchlist, *cpatchlist, *typelist; String *templateargs; String *tname; String *iname; String *tbase; patchlist = NewList(); cpatchlist = NewList(); typelist = NewList(); { String *tmp = NewStringEmpty(); if (tparms) { SwigType_add_template(tmp, tparms); } templateargs = Copy(tmp); Delete(tmp); } tname = Copy(Getattr(n, "name")); tbase = Swig_scopename_last(tname); /* Look for partial specialization matching */ if (Getattr(n, "partialargs")) { Parm *p, *tp; ParmList *ptargs = SwigType_function_parms(Getattr(n, "partialargs"), n); p = ptargs; tp = tparms; while (p && tp) { SwigType *ptype; SwigType *tptype; SwigType *partial_type; ptype = Getattr(p, "type"); tptype = Getattr(tp, "type"); if (ptype && tptype) { partial_type = partial_arg(tptype, ptype); /* Printf(stdout,"partial '%s' '%s' ---> '%s'\n", tptype, ptype, partial_type); */ Setattr(tp, "type", partial_type); Delete(partial_type); } p = nextSibling(p); tp = nextSibling(tp); } assert(ParmList_len(ptargs) == ParmList_len(tparms)); Delete(ptargs); } /* Parm *p = tparms; while (p) { Printf(stdout, "tparm: '%s' '%s' '%s'\n", Getattr(p, "name"), Getattr(p, "type"), Getattr(p, "value")); p = nextSibling(p); } */ /* Printf(stdout,"targs = '%s'\n", templateargs); Printf(stdout,"rname = '%s'\n", rname); Printf(stdout,"tname = '%s'\n", tname); */ cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); /* Set the name */ { String *name = Getattr(n, "name"); if (name) { Append(name, templateargs); } iname = name; } /* Patch all of the types */ { Parm *tp = Getattr(n, "templateparms"); Parm *p = tparms; /* Printf(stdout,"%s\n", ParmList_str_defaultargs(tp)); */ if (tp) { Symtab *tsdecl = Getattr(n, "sym:symtab"); while (p && tp) { String *name, *value, *valuestr, *tmp, *tmpr; int sz, i; String *dvalue = 0; String *qvalue = 0; name = Getattr(tp, "name"); value = Getattr(p, "value"); if (name) { if (!value) value = Getattr(p, "type"); qvalue = Swig_symbol_typedef_reduce(value, tsdecl); dvalue = Swig_symbol_type_qualify(qvalue, tsdecl); if (SwigType_istemplate(dvalue)) { String *ty = Swig_symbol_template_deftype(dvalue, tscope); Delete(dvalue); dvalue = ty; } assert(dvalue); valuestr = SwigType_str(dvalue, 0); /* Need to patch default arguments */ { Parm *rp = nextSibling(p); while (rp) { String *rvalue = Getattr(rp, "value"); if (rvalue) { Replace(rvalue, name, dvalue, DOH_REPLACE_ID); } rp = nextSibling(rp); } } sz = Len(patchlist); for (i = 0; i < sz; i++) { String *s = Getitem(patchlist, i); Replace(s, name, dvalue, DOH_REPLACE_ID); } sz = Len(typelist); for (i = 0; i < sz; i++) { String *s = Getitem(typelist, i); /* Replace(s,name,value, DOH_REPLACE_ID); */ /* Printf(stdout,"name = '%s', value = '%s', tbase = '%s', iname='%s' s = '%s' --> ", name, dvalue, tbase, iname, s); */ SwigType_typename_replace(s, name, dvalue); SwigType_typename_replace(s, tbase, iname); /* Printf(stdout,"'%s'\n", s); */ } tmp = NewStringf("#%s", name); tmpr = NewStringf("\"%s\"", valuestr); sz = Len(cpatchlist); for (i = 0; i < sz; i++) { String *s = Getitem(cpatchlist, i); Replace(s, tmp, tmpr, DOH_REPLACE_ID); Replace(s, name, valuestr, DOH_REPLACE_ID); } Delete(tmp); Delete(tmpr); Delete(valuestr); Delete(dvalue); Delete(qvalue); } p = nextSibling(p); tp = nextSibling(tp); if (!p) p = tp; } } else { /* No template parameters at all. This could be a specialization */ int i, sz; sz = Len(typelist); for (i = 0; i < sz; i++) { String *s = Getitem(typelist, i); SwigType_typename_replace(s, tbase, iname); } } } /* Patch bases */ { List *bases = Getattr(n, "baselist"); if (bases) { Iterator b; for (b = First(bases); b.item; b = Next(b)) { String *qn = Swig_symbol_type_qualify(b.item, tscope); Clear(b.item); Append(b.item, qn); Delete(qn); } } } Delete(patchlist); Delete(cpatchlist); Delete(typelist); Delete(tbase); Delete(tname); Delete(templateargs); /* set_nodeType(n,"template"); */ return 0; } typedef enum { ExactNoMatch = -2, PartiallySpecializedNoMatch = -1, PartiallySpecializedMatch = 1, ExactMatch = 2 } EMatch; /* ----------------------------------------------------------------------------- * does_parm_match() * * Template argument deduction - check if a template type matches a partially specialized * template parameter type. Typedef reduce 'partial_parm_type' to see if it matches 'type'. * * type - template parameter type to match against * partial_parm_type - partially specialized template type - a possible match * partial_parm_type_base - base type of partial_parm_type * tscope - template scope * specialization_priority - (output) contains a value indicating how good the match is * (higher is better) only set if return is set to PartiallySpecializedMatch or ExactMatch. * ----------------------------------------------------------------------------- */ static EMatch does_parm_match(SwigType *type, SwigType *partial_parm_type, const char *partial_parm_type_base, Symtab *tscope, int *specialization_priority) { static const int EXACT_MATCH_PRIORITY = 99999; /* a number bigger than the length of any conceivable type */ int matches; int substitutions; EMatch match; SwigType *ty = Swig_symbol_typedef_reduce(type, tscope); String *base = SwigType_base(ty); SwigType *t = Copy(partial_parm_type); substitutions = Replaceid(t, partial_parm_type_base, base); /* eg: Replaceid("p.$1", "$1", "int") returns t="p.int" */ matches = Equal(ty, t); *specialization_priority = -1; if (substitutions == 1) { /* we have a non-explicit specialized parameter (in partial_parm_type) because a substitution for $1, $2... etc has taken place */ SwigType *tt = Copy(partial_parm_type); int len; /* check for match to partial specialization type, for example, all of the following could match the type in the %template: template struct XX {}; template struct XX {}; // r.$1 template struct XX {}; // r.q(const).$1 template struct XX {}; // r.q(const).p.$1 %template(XXX) XX; // r.q(const).p.int where type="r.q(const).p.int" will match either of tt="r.", tt="r.q(const)" tt="r.q(const).p" */ Replaceid(tt, partial_parm_type_base, ""); /* remove the $1, $2 etc, eg tt="p.$1" => "p." */ len = Len(tt); if (Strncmp(tt, ty, len) == 0) { match = PartiallySpecializedMatch; *specialization_priority = len; } else { match = PartiallySpecializedNoMatch; } Delete(tt); } else { match = matches ? ExactMatch : ExactNoMatch; if (matches) *specialization_priority = EXACT_MATCH_PRIORITY; /* exact matches always take precedence */ } /* Printf(stdout, " does_parm_match %2d %5d [%s] [%s]\n", match, *specialization_priority, type, partial_parm_type); */ Delete(t); Delete(base); Delete(ty); return match; } /* ----------------------------------------------------------------------------- * template_locate() * * Search for a template that matches name with given parameters. * ----------------------------------------------------------------------------- */ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) { Node *n = 0; String *tname = 0; Node *templ; Symtab *primary_scope = 0; List *possiblepartials = 0; Parm *p; Parm *parms = 0; Parm *targs; ParmList *expandedparms; int *priorities_matrix = 0; int max_possible_partials = 0; int posslen = 0; /* Search for primary (unspecialized) template */ templ = Swig_symbol_clookup(name, 0); if (template_debug) { tname = Copy(name); SwigType_add_template(tname, tparms); Printf(stdout, "\n"); Swig_diagnostic(cparse_file, cparse_line, "template_debug: Searching for match to: '%s'\n", tname); Delete(tname); tname = 0; } if (templ) { tname = Copy(name); parms = CopyParmList(tparms); /* All template specializations must be in the primary template's scope, store the symbol table for this scope for specialization lookups */ primary_scope = Getattr(templ, "sym:symtab"); /* Add default values from primary template */ targs = Getattr(templ, "templateparms"); expandedparms = Swig_symbol_template_defargs(parms, targs, tscope, primary_scope); /* reduce the typedef */ p = expandedparms; while (p) { SwigType *ty = Getattr(p, "type"); if (ty) { SwigType *nt = Swig_symbol_type_qualify(ty, tscope); Setattr(p, "type", nt); Delete(nt); } p = nextSibling(p); } SwigType_add_template(tname, expandedparms); /* Search for an explicit (exact) specialization. Example: template<> class name { ... } */ { if (template_debug) { Printf(stdout, " searching for : '%s' (explicit specialization)\n", tname); } n = Swig_symbol_clookup_local(tname, primary_scope); if (!n) { SwigType *rname = Swig_symbol_typedef_reduce(tname, tscope); if (!Equal(rname, tname)) { if (template_debug) { Printf(stdout, " searching for : '%s' (explicit specialization with typedef reduction)\n", rname); } n = Swig_symbol_clookup_local(rname, primary_scope); } Delete(rname); } if (n) { Node *tn; String *nodeType = nodeType(n); if (Equal(nodeType, "template")) { if (template_debug) { Printf(stdout, " explicit specialization found: '%s'\n", Getattr(n, "name")); } goto success; } tn = Getattr(n, "template"); if (tn) { if (template_debug) { Printf(stdout, " previous instantiation found: '%s'\n", Getattr(n, "name")); } n = tn; goto success; /* Previously wrapped by a template instantiation */ } Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType(n)); Delete(tname); Delete(parms); return 0; /* Found a match, but it's not a template of any kind. */ } } /* Search for partial specializations. * Example: template class name { ... } * There are 3 types of template arguments: * (1) Template type arguments * (2) Template non type arguments * (3) Template template arguments * only (1) is really supported for partial specializations */ /* Rank each template parameter against the desired template parameters then build a matrix of best matches */ possiblepartials = NewList(); { char tmp[32]; List *partials; partials = Getattr(templ, "partials"); /* note that these partial specializations do not include explicit specializations */ if (partials) { Iterator pi; int parms_len = ParmList_len(parms); int *priorities_row; max_possible_partials = Len(partials); priorities_matrix = (int *)malloc(sizeof(int) * max_possible_partials * parms_len); /* slightly wasteful allocation for max possible matches */ priorities_row = priorities_matrix; for (pi = First(partials); pi.item; pi = Next(pi)) { Parm *p = parms; int all_parameters_match = 1; int i = 1; Parm *partialparms = Getattr(pi.item, "partialparms"); Parm *pp = partialparms; String *templcsymname = Getattr(pi.item, "templcsymname"); if (template_debug) { Printf(stdout, " checking match: '%s' (partial specialization)\n", templcsymname); } if (ParmList_len(partialparms) == parms_len) { while (p && pp) { SwigType *t; sprintf(tmp, "$%d", i); t = Getattr(p, "type"); if (!t) t = Getattr(p, "value"); if (t) { EMatch match = does_parm_match(t, Getattr(pp, "type"), tmp, tscope, priorities_row + i - 1); if (match < (int)PartiallySpecializedMatch) { all_parameters_match = 0; break; } } i++; p = nextSibling(p); pp = nextSibling(pp); } if (all_parameters_match) { Append(possiblepartials, pi.item); priorities_row += parms_len; } } } } } posslen = Len(possiblepartials); if (template_debug) { int i; if (posslen == 0) Printf(stdout, " matched partials: NONE\n"); else if (posslen == 1) Printf(stdout, " chosen partial: '%s'\n", Getattr(Getitem(possiblepartials, 0), "templcsymname")); else { Printf(stdout, " possibly matched partials:\n"); for (i = 0; i < posslen; i++) { Printf(stdout, " '%s'\n", Getattr(Getitem(possiblepartials, i), "templcsymname")); } } } if (posslen > 1) { /* Now go through all the possibly matched partial specialization templates and look for a non-ambiguous match. * Exact matches rank the highest and deduced parameters are ranked by how specialized they are, eg looking for * a match to const int *, the following rank (highest to lowest): * const int * (exact match) * const T * * T * * T * * An ambiguous example when attempting to match as either specialization could match: %template() X; * template X class {}; // primary template * template X class {}; // specialization (1) * template X class {}; // specialization (2) */ if (template_debug) { int row, col; int parms_len = ParmList_len(parms); Printf(stdout, " parameter priorities matrix (%d parms):\n", parms_len); for (row = 0; row < posslen; row++) { int *priorities_row = priorities_matrix + row*parms_len; Printf(stdout, " "); for (col = 0; col < parms_len; col++) { Printf(stdout, "%5d ", priorities_row[col]); } Printf(stdout, "\n"); } } { int row, col; int parms_len = ParmList_len(parms); /* Printf(stdout, " parameter priorities inverse matrix (%d parms):\n", parms_len); */ for (col = 0; col < parms_len; col++) { int *priorities_col = priorities_matrix + col; int maxpriority = -1; /* Printf(stdout, "max_possible_partials: %d col:%d\n", max_possible_partials, col); Printf(stdout, " "); */ /* determine the highest rank for this nth parameter */ for (row = 0; row < posslen; row++) { int *element_ptr = priorities_col + row*parms_len; int priority = *element_ptr; if (priority > maxpriority) maxpriority = priority; /* Printf(stdout, "%5d ", priority); */ } /* Printf(stdout, "\n"); */ /* flag all the parameters which equal the highest rank */ for (row = 0; row < posslen; row++) { int *element_ptr = priorities_col + row*parms_len; int priority = *element_ptr; *element_ptr = (priority >= maxpriority) ? 1 : 0; } } } { int row, col; int parms_len = ParmList_len(parms); Iterator pi = First(possiblepartials); Node *chosenpartials = NewList(); if (template_debug) Printf(stdout, " priority flags matrix:\n"); for (row = 0; row < posslen; row++) { int *priorities_row = priorities_matrix + row*parms_len; int highest_count = 0; /* count of highest priority parameters */ for (col = 0; col < parms_len; col++) { highest_count += priorities_row[col]; } if (template_debug) { Printf(stdout, " "); for (col = 0; col < parms_len; col++) { Printf(stdout, "%5d ", priorities_row[col]); } Printf(stdout, "\n"); } if (highest_count == parms_len) { Append(chosenpartials, pi.item); } pi = Next(pi); } if (Len(chosenpartials) > 0) { /* one or more best match found */ Delete(possiblepartials); possiblepartials = chosenpartials; posslen = Len(possiblepartials); } else { /* no best match found */ Delete(chosenpartials); } } } if (posslen > 0) { String *s = Getattr(Getitem(possiblepartials, 0), "templcsymname"); n = Swig_symbol_clookup_local(s, primary_scope); if (posslen > 1) { int i; if (n) { Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, cparse_file, cparse_line, "Instantiation of template '%s' is ambiguous,\n", SwigType_namestr(tname)); Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(n), Getline(n), " instantiation '%s' used,\n", SwigType_namestr(Getattr(n, "name"))); } for (i = 1; i < posslen; i++) { String *templcsymname = Getattr(Getitem(possiblepartials, i), "templcsymname"); Node *ignored_node = Swig_symbol_clookup_local(templcsymname, primary_scope); assert(ignored_node); Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(ignored_node), Getline(ignored_node), " instantiation '%s' ignored.\n", SwigType_namestr(Getattr(ignored_node, "name"))); } } } if (!n) { if (template_debug) { Printf(stdout, " chosen primary template: '%s'\n", Getattr(templ, "name")); } n = templ; } } else { if (template_debug) { Printf(stdout, " primary template not found\n"); } /* Give up if primary (unspecialized) template not found as specializations will only exist if there is a primary template */ n = 0; } if (!n) { Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name); } else if (n) { String *nodeType = nodeType(n); if (!Equal(nodeType, "template")) { Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType); n = 0; } } success: Delete(tname); Delete(possiblepartials); if ((template_debug) && (n)) { /* Printf(stdout, "Node: %p\n", n); Swig_print_node(n); */ Printf(stdout, " chosen template:'%s'\n", Getattr(n, "name")); } Delete(parms); free(priorities_matrix); return n; } /* ----------------------------------------------------------------------------- * Swig_cparse_template_locate() * * Search for a template that matches name with given parameters. * For templated classes finds the specialized template should there be one. * For templated functions finds the unspecialized template even if a specialized * template exists. * ----------------------------------------------------------------------------- */ Node *Swig_cparse_template_locate(String *name, Parm *tparms, Symtab *tscope) { Node *n = template_locate(name, tparms, tscope); /* this function does what we want for templated classes */ if (n) { String *nodeType = nodeType(n); int isclass = 0; assert(Equal(nodeType, "template")); isclass = (Equal(Getattr(n, "templatetype"), "class")); if (!isclass) { /* If not a templated class we must have a templated function. The template found is not necessarily the one we want when dealing with templated functions. We don't want any specialized templated functions as they won't have the default parameters. Let's look for the unspecialized template. Also make sure the number of template parameters is correct as it is possible to overload a templated function with different numbers of template parameters. */ if (template_debug) { Printf(stdout, " Not a templated class, seeking most appropriate templated function\n"); } n = Swig_symbol_clookup_local(name, 0); while (n) { Parm *tparmsfound = Getattr(n, "templateparms"); if (ParmList_len(tparms) == ParmList_len(tparmsfound)) { /* successful match */ break; } /* repeat until we find a match with correct number of templated parameters */ n = Getattr(n, "sym:nextSibling"); } if (!n) { Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name); } if ((template_debug) && (n)) { Printf(stdout, "Templated function found: %p\n", n); Swig_print_node(n); } } } return n; } swig-3.0.2/Source/CParse/cscanner.c0000664000175000017500000006110312343605122016721 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * scanner.c * * SWIG tokenizer. This file is a wrapper around the generic C scanner * found in Swig/scanner.c. Extra logic is added both to accommodate the * bison-based grammar and certain peculiarities of C++ parsing (e.g., * operator overloading, typedef resolution, etc.). This code also splits * C identifiers up into keywords and SWIG directives. * ----------------------------------------------------------------------------- */ #include "cparse.h" #include "parser.h" #include #include /* Scanner object */ static Scanner *scan = 0; /* Global string containing C code. Used by the parser to grab code blocks */ String *scanner_ccode = 0; /* The main file being parsed */ static String *main_input_file = 0; /* Error reporting/location information */ int cparse_line = 1; String *cparse_file = 0; int cparse_start_line = 0; /* C++ mode */ int cparse_cplusplus = 0; /* Generate C++ compatible code when wrapping C code */ int cparse_cplusplusout = 0; /* Private vars */ static int scan_init = 0; static int num_brace = 0; static int last_brace = 0; static int last_id = 0; static int rename_active = 0; /* ----------------------------------------------------------------------------- * Swig_cparse_cplusplus() * ----------------------------------------------------------------------------- */ void Swig_cparse_cplusplus(int v) { cparse_cplusplus = v; } /* ----------------------------------------------------------------------------- * Swig_cparse_cplusplusout() * ----------------------------------------------------------------------------- */ void Swig_cparse_cplusplusout(int v) { cparse_cplusplusout = v; } /* ---------------------------------------------------------------------------- * scanner_init() * * Initialize buffers * ------------------------------------------------------------------------- */ void scanner_init() { scan = NewScanner(); Scanner_idstart(scan,"%"); scan_init = 1; scanner_ccode = NewStringEmpty(); } /* ---------------------------------------------------------------------------- * scanner_file(DOHFile *f) * * Start reading from new file * ------------------------------------------------------------------------- */ void scanner_file(DOHFile * f) { if (!scan_init) scanner_init(); Scanner_clear(scan); Scanner_push(scan,f); } /* ---------------------------------------------------------------------------- * start_inline(char *text, int line) * * Take a chunk of text and recursively feed it back into the scanner. Used * by the %inline directive. * ------------------------------------------------------------------------- */ void start_inline(char *text, int line) { String *stext = NewString(text); Seek(stext,0,SEEK_SET); Setfile(stext,cparse_file); Setline(stext,line); Scanner_push(scan,stext); Delete(stext); } /* ----------------------------------------------------------------------------- * skip_balanced() * * Skips a piece of code enclosed in begin/end symbols such as '{...}' or * (...). Ignores symbols inside comments or strings. * ----------------------------------------------------------------------------- */ void skip_balanced(int startchar, int endchar) { int start_line = Scanner_line(scan); Clear(scanner_ccode); if (Scanner_skip_balanced(scan,startchar,endchar) < 0) { Swig_error(cparse_file, start_line, "Missing '%c'. Reached end of input.\n", endchar); return; } cparse_line = Scanner_line(scan); cparse_file = Scanner_file(scan); Append(scanner_ccode, Scanner_text(scan)); if (endchar == '}') num_brace--; return; } /* ----------------------------------------------------------------------------- * get_raw_text_balanced() * * Returns raw text between 2 braces * ----------------------------------------------------------------------------- */ String *get_raw_text_balanced(int startchar, int endchar) { return Scanner_get_raw_text_balanced(scan, startchar, endchar); } /* ---------------------------------------------------------------------------- * void skip_decl(void) * * This tries to skip over an entire declaration. For example * * friend ostream& operator<<(ostream&, const char *s); * * or * friend ostream& operator<<(ostream&, const char *s) { }; * * ------------------------------------------------------------------------- */ void skip_decl(void) { int tok; int done = 0; int start_line = Scanner_line(scan); while (!done) { tok = Scanner_token(scan); if (tok == 0) { if (!Swig_error_count()) { Swig_error(cparse_file, start_line, "Missing semicolon. Reached end of input.\n"); } return; } if (tok == SWIG_TOKEN_LBRACE) { if (Scanner_skip_balanced(scan,'{','}') < 0) { Swig_error(cparse_file, start_line, "Missing '}'. Reached end of input.\n"); } break; } if (tok == SWIG_TOKEN_SEMI) { done = 1; } } cparse_file = Scanner_file(scan); cparse_line = Scanner_line(scan); } /* ---------------------------------------------------------------------------- * int yylook() * * Lexical scanner. * ------------------------------------------------------------------------- */ static int yylook(void) { int tok = 0; while (1) { if ((tok = Scanner_token(scan)) == 0) return 0; if (tok == SWIG_TOKEN_ERROR) return 0; cparse_start_line = Scanner_start_line(scan); cparse_line = Scanner_line(scan); cparse_file = Scanner_file(scan); switch(tok) { case SWIG_TOKEN_ID: return ID; case SWIG_TOKEN_LPAREN: return LPAREN; case SWIG_TOKEN_RPAREN: return RPAREN; case SWIG_TOKEN_SEMI: return SEMI; case SWIG_TOKEN_COMMA: return COMMA; case SWIG_TOKEN_STAR: return STAR; case SWIG_TOKEN_RBRACE: num_brace--; if (num_brace < 0) { Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '}'\n"); num_brace = 0; } else { return RBRACE; } break; case SWIG_TOKEN_LBRACE: last_brace = num_brace; num_brace++; return LBRACE; case SWIG_TOKEN_EQUAL: return EQUAL; case SWIG_TOKEN_EQUALTO: return EQUALTO; case SWIG_TOKEN_PLUS: return PLUS; case SWIG_TOKEN_MINUS: return MINUS; case SWIG_TOKEN_SLASH: return SLASH; case SWIG_TOKEN_AND: return AND; case SWIG_TOKEN_LAND: return LAND; case SWIG_TOKEN_OR: return OR; case SWIG_TOKEN_LOR: return LOR; case SWIG_TOKEN_XOR: return XOR; case SWIG_TOKEN_NOT: return NOT; case SWIG_TOKEN_LNOT: return LNOT; case SWIG_TOKEN_NOTEQUAL: return NOTEQUALTO; case SWIG_TOKEN_LBRACKET: return LBRACKET; case SWIG_TOKEN_RBRACKET: return RBRACKET; case SWIG_TOKEN_QUESTION: return QUESTIONMARK; case SWIG_TOKEN_LESSTHAN: return LESSTHAN; case SWIG_TOKEN_LTEQUAL: return LESSTHANOREQUALTO; case SWIG_TOKEN_LSHIFT: return LSHIFT; case SWIG_TOKEN_GREATERTHAN: return GREATERTHAN; case SWIG_TOKEN_GTEQUAL: return GREATERTHANOREQUALTO; case SWIG_TOKEN_RSHIFT: return RSHIFT; case SWIG_TOKEN_ARROW: return ARROW; case SWIG_TOKEN_PERIOD: return PERIOD; case SWIG_TOKEN_MODULO: return MODULO; case SWIG_TOKEN_COLON: return COLON; case SWIG_TOKEN_DCOLONSTAR: return DSTAR; case SWIG_TOKEN_DCOLON: { int nexttok = Scanner_token(scan); if (nexttok == SWIG_TOKEN_STAR) { return DSTAR; } else if (nexttok == SWIG_TOKEN_NOT) { return DCNOT; } else { Scanner_pushtoken(scan,nexttok,Scanner_text(scan)); if (!last_id) { scanner_next_token(DCOLON); return NONID; } else { return DCOLON; } } } break; /* Look for multi-character sequences */ case SWIG_TOKEN_RSTRING: yylval.type = NewString(Scanner_text(scan)); return TYPE_RAW; case SWIG_TOKEN_STRING: yylval.id = Swig_copy_string(Char(Scanner_text(scan))); return STRING; case SWIG_TOKEN_WSTRING: yylval.id = Swig_copy_string(Char(Scanner_text(scan))); return WSTRING; case SWIG_TOKEN_CHAR: yylval.str = NewString(Scanner_text(scan)); if (Len(yylval.str) == 0) { Swig_error(cparse_file, cparse_line, "Empty character constant\n"); } return CHARCONST; case SWIG_TOKEN_WCHAR: yylval.str = NewString(Scanner_text(scan)); if (Len(yylval.str) == 0) { Swig_error(cparse_file, cparse_line, "Empty character constant\n"); } return WCHARCONST; /* Numbers */ case SWIG_TOKEN_INT: return NUM_INT; case SWIG_TOKEN_UINT: return NUM_UNSIGNED; case SWIG_TOKEN_LONG: return NUM_LONG; case SWIG_TOKEN_ULONG: return NUM_ULONG; case SWIG_TOKEN_LONGLONG: return NUM_LONGLONG; case SWIG_TOKEN_ULONGLONG: return NUM_ULONGLONG; case SWIG_TOKEN_DOUBLE: case SWIG_TOKEN_FLOAT: return NUM_FLOAT; case SWIG_TOKEN_BOOL: return NUM_BOOL; case SWIG_TOKEN_POUND: Scanner_skip_line(scan); yylval.id = Swig_copy_string(Char(Scanner_text(scan))); return POUND; break; case SWIG_TOKEN_CODEBLOCK: yylval.str = NewString(Scanner_text(scan)); return HBLOCK; case SWIG_TOKEN_COMMENT: { String *cmt = Scanner_text(scan); char *loc = Char(cmt); if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) { Scanner_locator(scan, cmt); } } break; case SWIG_TOKEN_ENDLINE: break; case SWIG_TOKEN_BACKSLASH: break; default: Swig_error(cparse_file, cparse_line, "Illegal token '%s'.\n", Scanner_text(scan)); return (ILLEGAL); } } } static int check_typedef = 0; void scanner_set_location(String *file, int line) { Scanner_set_location(scan,file,line-1); } void scanner_check_typedef() { check_typedef = 1; } void scanner_ignore_typedef() { check_typedef = 0; } void scanner_last_id(int x) { last_id = x; } void scanner_clear_rename() { rename_active = 0; } /* Used to push a fictitious token into the scanner */ static int next_token = 0; void scanner_next_token(int tok) { next_token = tok; } void scanner_set_main_input_file(String *file) { main_input_file = file; } String *scanner_get_main_input_file() { return main_input_file; } /* ---------------------------------------------------------------------------- * int yylex() * * Gets the lexene and returns tokens. * ------------------------------------------------------------------------- */ int yylex(void) { int l; char *yytext; if (!scan_init) { scanner_init(); } if (next_token) { l = next_token; next_token = 0; return l; } l = yylook(); /* Swig_diagnostic(cparse_file, cparse_line, ":::%d: '%s'\n", l, Scanner_text(scan)); */ if (l == NONID) { last_id = 1; } else { last_id = 0; } /* We got some sort of non-white space object. We set the start_line variable unless it has already been set */ if (!cparse_start_line) { cparse_start_line = cparse_line; } /* Copy the lexene */ switch (l) { case NUM_INT: case NUM_FLOAT: case NUM_ULONG: case NUM_LONG: case NUM_UNSIGNED: case NUM_LONGLONG: case NUM_ULONGLONG: case NUM_BOOL: if (l == NUM_INT) yylval.dtype.type = T_INT; if (l == NUM_FLOAT) yylval.dtype.type = T_DOUBLE; if (l == NUM_ULONG) yylval.dtype.type = T_ULONG; if (l == NUM_LONG) yylval.dtype.type = T_LONG; if (l == NUM_UNSIGNED) yylval.dtype.type = T_UINT; if (l == NUM_LONGLONG) yylval.dtype.type = T_LONGLONG; if (l == NUM_ULONGLONG) yylval.dtype.type = T_ULONGLONG; if (l == NUM_BOOL) yylval.dtype.type = T_BOOL; yylval.dtype.val = NewString(Scanner_text(scan)); yylval.dtype.bitfield = 0; yylval.dtype.throws = 0; return (l); case ID: yytext = Char(Scanner_text(scan)); if (yytext[0] != '%') { /* Look for keywords now */ if (strcmp(yytext, "int") == 0) { yylval.type = NewSwigType(T_INT); return (TYPE_INT); } if (strcmp(yytext, "double") == 0) { yylval.type = NewSwigType(T_DOUBLE); return (TYPE_DOUBLE); } if (strcmp(yytext, "void") == 0) { yylval.type = NewSwigType(T_VOID); return (TYPE_VOID); } if (strcmp(yytext, "char") == 0) { yylval.type = NewSwigType(T_CHAR); return (TYPE_CHAR); } if (strcmp(yytext, "wchar_t") == 0) { yylval.type = NewSwigType(T_WCHAR); return (TYPE_WCHAR); } if (strcmp(yytext, "short") == 0) { yylval.type = NewSwigType(T_SHORT); return (TYPE_SHORT); } if (strcmp(yytext, "long") == 0) { yylval.type = NewSwigType(T_LONG); return (TYPE_LONG); } if (strcmp(yytext, "float") == 0) { yylval.type = NewSwigType(T_FLOAT); return (TYPE_FLOAT); } if (strcmp(yytext, "signed") == 0) { yylval.type = NewSwigType(T_INT); return (TYPE_SIGNED); } if (strcmp(yytext, "unsigned") == 0) { yylval.type = NewSwigType(T_UINT); return (TYPE_UNSIGNED); } if (strcmp(yytext, "bool") == 0) { yylval.type = NewSwigType(T_BOOL); return (TYPE_BOOL); } /* Non ISO (Windows) C extensions */ if (strcmp(yytext, "__int8") == 0) { yylval.type = NewString(yytext); return (TYPE_NON_ISO_INT8); } if (strcmp(yytext, "__int16") == 0) { yylval.type = NewString(yytext); return (TYPE_NON_ISO_INT16); } if (strcmp(yytext, "__int32") == 0) { yylval.type = NewString(yytext); return (TYPE_NON_ISO_INT32); } if (strcmp(yytext, "__int64") == 0) { yylval.type = NewString(yytext); return (TYPE_NON_ISO_INT64); } /* C++ keywords */ if (cparse_cplusplus) { if (strcmp(yytext, "and") == 0) return (LAND); if (strcmp(yytext, "or") == 0) return (LOR); if (strcmp(yytext, "not") == 0) return (LNOT); if (strcmp(yytext, "class") == 0) return (CLASS); if (strcmp(yytext, "private") == 0) return (PRIVATE); if (strcmp(yytext, "public") == 0) return (PUBLIC); if (strcmp(yytext, "protected") == 0) return (PROTECTED); if (strcmp(yytext, "friend") == 0) return (FRIEND); if (strcmp(yytext, "constexpr") == 0) return (CONSTEXPR); if (strcmp(yytext, "thread_local") == 0) return (THREAD_LOCAL); if (strcmp(yytext, "decltype") == 0) return (DECLTYPE); if (strcmp(yytext, "virtual") == 0) return (VIRTUAL); if (strcmp(yytext, "static_assert") == 0) return (STATIC_ASSERT); if (strcmp(yytext, "operator") == 0) { int nexttok; String *s = NewString("operator "); /* If we have an operator, we have to collect the operator symbol and attach it to the operator identifier. To do this, we need to scan ahead by several tokens. Cases include: (1) If the next token is an operator as determined by Scanner_isoperator(), it means that the operator applies to one of the standard C++ mathematical, assignment, or logical operator symbols (e.g., '+','<=','==','&', etc.) In this case, we merely append the symbol text to the operator string above. (2) If the next token is (, we look for ). This is operator (). (3) If the next token is [, we look for ]. This is operator []. (4) If the next token is an identifier. The operator is possibly a conversion operator. (a) Must check for special case new[] and delete[] Error handling is somewhat tricky here. We'll try to back out gracefully if we can. */ nexttok = Scanner_token(scan); if (Scanner_isoperator(nexttok)) { /* One of the standard C/C++ symbolic operators */ Append(s,Scanner_text(scan)); yylval.str = s; return OPERATOR; } else if (nexttok == SWIG_TOKEN_LPAREN) { /* Function call operator. The next token MUST be a RPAREN */ nexttok = Scanner_token(scan); if (nexttok != SWIG_TOKEN_RPAREN) { Swig_error(Scanner_file(scan),Scanner_line(scan),"Syntax error. Bad operator name.\n"); } else { Append(s,"()"); yylval.str = s; return OPERATOR; } } else if (nexttok == SWIG_TOKEN_LBRACKET) { /* Array access operator. The next token MUST be a RBRACKET */ nexttok = Scanner_token(scan); if (nexttok != SWIG_TOKEN_RBRACKET) { Swig_error(Scanner_file(scan),Scanner_line(scan),"Syntax error. Bad operator name.\n"); } else { Append(s,"[]"); yylval.str = s; return OPERATOR; } } else if (nexttok == SWIG_TOKEN_STRING) { /* Operator "" or user-defined string literal ""_suffix */ Append(s,"\"\""); yylval.str = s; return OPERATOR; } else if (nexttok == SWIG_TOKEN_ID) { /* We have an identifier. This could be any number of things. It could be a named version of an operator (e.g., 'and_eq') or it could be a conversion operator. To deal with this, we're going to read tokens until we encounter a ( or ;. Some care is needed for formatting. */ int needspace = 1; int termtoken = 0; const char *termvalue = 0; Append(s,Scanner_text(scan)); while (1) { nexttok = Scanner_token(scan); if (nexttok <= 0) { Swig_error(Scanner_file(scan),Scanner_line(scan),"Syntax error. Bad operator name.\n"); } if (nexttok == SWIG_TOKEN_LPAREN) { termtoken = SWIG_TOKEN_LPAREN; termvalue = "("; break; } else if (nexttok == SWIG_TOKEN_CODEBLOCK) { termtoken = SWIG_TOKEN_CODEBLOCK; termvalue = Char(Scanner_text(scan)); break; } else if (nexttok == SWIG_TOKEN_LBRACE) { termtoken = SWIG_TOKEN_LBRACE; termvalue = "{"; break; } else if (nexttok == SWIG_TOKEN_SEMI) { termtoken = SWIG_TOKEN_SEMI; termvalue = ";"; break; } else if (nexttok == SWIG_TOKEN_STRING) { termtoken = SWIG_TOKEN_STRING; termvalue = Swig_copy_string(Char(Scanner_text(scan))); break; } else if (nexttok == SWIG_TOKEN_ID) { if (needspace) { Append(s," "); } Append(s,Scanner_text(scan)); } else { Append(s,Scanner_text(scan)); needspace = 0; } } yylval.str = s; if (!rename_active) { String *cs; char *t = Char(s) + 9; if (!((strcmp(t, "new") == 0) || (strcmp(t, "delete") == 0) || (strcmp(t, "new[]") == 0) || (strcmp(t, "delete[]") == 0) || (strcmp(t, "and") == 0) || (strcmp(t, "and_eq") == 0) || (strcmp(t, "bitand") == 0) || (strcmp(t, "bitor") == 0) || (strcmp(t, "compl") == 0) || (strcmp(t, "not") == 0) || (strcmp(t, "not_eq") == 0) || (strcmp(t, "or") == 0) || (strcmp(t, "or_eq") == 0) || (strcmp(t, "xor") == 0) || (strcmp(t, "xor_eq") == 0) )) { /* retract(strlen(t)); */ /* The operator is a conversion operator. In order to deal with this, we need to feed the type information back into the parser. For now this is a hack. Needs to be cleaned up later. */ cs = NewString(t); if (termtoken) Append(cs,termvalue); Seek(cs,0,SEEK_SET); Setline(cs,cparse_line); Setfile(cs,cparse_file); Scanner_push(scan,cs); Delete(cs); return COPERATOR; } } if (termtoken) Scanner_pushtoken(scan, termtoken, termvalue); return (OPERATOR); } } if (strcmp(yytext, "throw") == 0) return (THROW); if (strcmp(yytext, "noexcept") == 0) return (NOEXCEPT); if (strcmp(yytext, "try") == 0) return (yylex()); if (strcmp(yytext, "catch") == 0) return (CATCH); if (strcmp(yytext, "inline") == 0) return (yylex()); if (strcmp(yytext, "mutable") == 0) return (yylex()); if (strcmp(yytext, "explicit") == 0) return (EXPLICIT); if (strcmp(yytext, "auto") == 0) return (AUTO); if (strcmp(yytext, "export") == 0) return (yylex()); if (strcmp(yytext, "typename") == 0) return (TYPENAME); if (strcmp(yytext, "template") == 0) { yylval.intvalue = cparse_line; return (TEMPLATE); } if (strcmp(yytext, "delete") == 0) return (DELETE_KW); if (strcmp(yytext, "default") == 0) return (DEFAULT); if (strcmp(yytext, "using") == 0) return (USING); if (strcmp(yytext, "namespace") == 0) return (NAMESPACE); if (strcmp(yytext, "override") == 0) return (OVERRIDE); if (strcmp(yytext, "final") == 0) return (FINAL); } else { if (strcmp(yytext, "class") == 0) { Swig_warning(WARN_PARSE_CLASS_KEYWORD, cparse_file, cparse_line, "class keyword used, but not in C++ mode.\n"); } if (strcmp(yytext, "complex") == 0) { yylval.type = NewSwigType(T_COMPLEX); return (TYPE_COMPLEX); } if (strcmp(yytext, "restrict") == 0) return (yylex()); } /* Misc keywords */ if (strcmp(yytext, "extern") == 0) return (EXTERN); if (strcmp(yytext, "const") == 0) return (CONST_QUAL); if (strcmp(yytext, "static") == 0) return (STATIC); if (strcmp(yytext, "struct") == 0) return (STRUCT); if (strcmp(yytext, "union") == 0) return (UNION); if (strcmp(yytext, "enum") == 0) return (ENUM); if (strcmp(yytext, "sizeof") == 0) return (SIZEOF); if (strcmp(yytext, "typedef") == 0) { yylval.intvalue = 0; return (TYPEDEF); } /* Ignored keywords */ if (strcmp(yytext, "volatile") == 0) return (VOLATILE); if (strcmp(yytext, "register") == 0) return (REGISTER); if (strcmp(yytext, "inline") == 0) return (yylex()); /* SWIG directives */ } else { if (strcmp(yytext, "%module") == 0) return (MODULE); if (strcmp(yytext, "%insert") == 0) return (INSERT); if (strcmp(yytext, "%name") == 0) return (NAME); if (strcmp(yytext, "%rename") == 0) { rename_active = 1; return (RENAME); } if (strcmp(yytext, "%namewarn") == 0) { rename_active = 1; return (NAMEWARN); } if (strcmp(yytext, "%includefile") == 0) return (INCLUDE); if (strcmp(yytext, "%beginfile") == 0) return (BEGINFILE); if (strcmp(yytext, "%endoffile") == 0) return (ENDOFFILE); if (strcmp(yytext, "%val") == 0) { Swig_warning(WARN_DEPRECATED_VAL, cparse_file, cparse_line, "%%val directive deprecated (ignored).\n"); return (yylex()); } if (strcmp(yytext, "%out") == 0) { Swig_warning(WARN_DEPRECATED_OUT, cparse_file, cparse_line, "%%out directive deprecated (ignored).\n"); return (yylex()); } if (strcmp(yytext, "%constant") == 0) return (CONSTANT); if (strcmp(yytext, "%typedef") == 0) { yylval.intvalue = 1; return (TYPEDEF); } if (strcmp(yytext, "%native") == 0) return (NATIVE); if (strcmp(yytext, "%pragma") == 0) return (PRAGMA); if (strcmp(yytext, "%extend") == 0) return (EXTEND); if (strcmp(yytext, "%fragment") == 0) return (FRAGMENT); if (strcmp(yytext, "%inline") == 0) return (INLINE); if (strcmp(yytext, "%typemap") == 0) return (TYPEMAP); if (strcmp(yytext, "%feature") == 0) { /* The rename_active indicates we don't need the information of the * following function's return type. This applied for %rename, so do * %feature. */ rename_active = 1; return (FEATURE); } if (strcmp(yytext, "%except") == 0) return (EXCEPT); if (strcmp(yytext, "%importfile") == 0) return (IMPORT); if (strcmp(yytext, "%echo") == 0) return (ECHO); if (strcmp(yytext, "%apply") == 0) return (APPLY); if (strcmp(yytext, "%clear") == 0) return (CLEAR); if (strcmp(yytext, "%types") == 0) return (TYPES); if (strcmp(yytext, "%parms") == 0) return (PARMS); if (strcmp(yytext, "%varargs") == 0) return (VARARGS); if (strcmp(yytext, "%template") == 0) { return (SWIGTEMPLATE); } if (strcmp(yytext, "%warn") == 0) return (WARN); } /* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */ /* Need to fix this */ if (check_typedef) { if (SwigType_istypedef(yytext)) { yylval.type = NewString(yytext); return (TYPE_TYPEDEF); } } yylval.id = Swig_copy_string(yytext); last_id = 1; return (ID); case POUND: return yylex(); default: return (l); } } swig-3.0.2/Source/CParse/parser.y0000664000175000017500000063125412343605122016461 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * parser.y * * YACC parser for SWIG. The grammar is a somewhat broken subset of C/C++. * This file is a bit of a mess and probably needs to be rewritten at * some point. Beware. * ----------------------------------------------------------------------------- */ /* Removed until we know more about the min versions of Bison and Yacc required for this to work, see Byacc man page: http://invisible-island.net/byacc/manpage/yacc.html %expect 6 */ %{ #define yylex yylex #include "swig.h" #include "cparse.h" #include "preprocessor.h" #include /* We do this for portability */ #undef alloca #define alloca malloc /* ----------------------------------------------------------------------------- * Externals * ----------------------------------------------------------------------------- */ int yyparse(); /* NEW Variables */ static Node *top = 0; /* Top of the generated parse tree */ static int unnamed = 0; /* Unnamed datatype counter */ static Hash *classes = 0; /* Hash table of classes */ static Hash *classes_typedefs = 0; /* Hash table of typedef classes: typedef struct X {...} Y; */ static Symtab *prev_symtab = 0; static Node *current_class = 0; String *ModuleName = 0; static Node *module_node = 0; static String *Classprefix = 0; static String *Namespaceprefix = 0; static int inclass = 0; static Node *currentOuterClass = 0; /* for nested classes */ static char *last_cpptype = 0; static int inherit_list = 0; static Parm *template_parameters = 0; static int extendmode = 0; static int compact_default_args = 0; static int template_reduce = 0; static int cparse_externc = 0; int ignore_nested_classes = 0; /* ----------------------------------------------------------------------------- * Assist Functions * ----------------------------------------------------------------------------- */ /* Called by the parser (yyparse) when an error is found.*/ static void yyerror (const char *e) { (void)e; } /* Copies a node. Does not copy tree links or symbol table data (except for sym:name) */ static Node *copy_node(Node *n) { Node *nn; Iterator k; nn = NewHash(); Setfile(nn,Getfile(n)); Setline(nn,Getline(n)); for (k = First(n); k.key; k = Next(k)) { String *ci; String *key = k.key; char *ckey = Char(key); if ((strcmp(ckey,"nextSibling") == 0) || (strcmp(ckey,"previousSibling") == 0) || (strcmp(ckey,"parentNode") == 0) || (strcmp(ckey,"lastChild") == 0)) { continue; } if (Strncmp(key,"csym:",5) == 0) continue; /* We do copy sym:name. For templates */ if ((strcmp(ckey,"sym:name") == 0) || (strcmp(ckey,"sym:weak") == 0) || (strcmp(ckey,"sym:typename") == 0)) { String *ci = Copy(k.item); Setattr(nn,key, ci); Delete(ci); continue; } if (strcmp(ckey,"sym:symtab") == 0) { Setattr(nn,"sym:needs_symtab", "1"); } /* We don't copy any other symbol table attributes */ if (strncmp(ckey,"sym:",4) == 0) { continue; } /* If children. We copy them recursively using this function */ if (strcmp(ckey,"firstChild") == 0) { /* Copy children */ Node *cn = k.item; while (cn) { Node *copy = copy_node(cn); appendChild(nn,copy); Delete(copy); cn = nextSibling(cn); } continue; } /* We don't copy the symbol table. But we drop an attribute requires_symtab so that functions know it needs to be built */ if (strcmp(ckey,"symtab") == 0) { /* Node defined a symbol table. */ Setattr(nn,"requires_symtab","1"); continue; } /* Can't copy nodes */ if (strcmp(ckey,"node") == 0) { continue; } if ((strcmp(ckey,"parms") == 0) || (strcmp(ckey,"pattern") == 0) || (strcmp(ckey,"throws") == 0) || (strcmp(ckey,"kwargs") == 0)) { ParmList *pl = CopyParmList(k.item); Setattr(nn,key,pl); Delete(pl); continue; } if (strcmp(ckey,"nested:outer") == 0) { /* don't copy outer classes links, they will be updated later */ Setattr(nn, key, k.item); continue; } /* Looks okay. Just copy the data using Copy */ ci = Copy(k.item); Setattr(nn, key, ci); Delete(ci); } return nn; } /* ----------------------------------------------------------------------------- * Variables * ----------------------------------------------------------------------------- */ static char *typemap_lang = 0; /* Current language setting */ static int cplus_mode = 0; /* C++ modes */ #define CPLUS_PUBLIC 1 #define CPLUS_PRIVATE 2 #define CPLUS_PROTECTED 3 /* include types */ static int import_mode = 0; void SWIG_typemap_lang(const char *tm_lang) { typemap_lang = Swig_copy_string(tm_lang); } void SWIG_cparse_set_compact_default_args(int defargs) { compact_default_args = defargs; } int SWIG_cparse_template_reduce(int treduce) { template_reduce = treduce; return treduce; } /* ----------------------------------------------------------------------------- * Assist functions * ----------------------------------------------------------------------------- */ static int promote_type(int t) { if (t <= T_UCHAR || t == T_CHAR) return T_INT; return t; } /* Perform type-promotion for binary operators */ static int promote(int t1, int t2) { t1 = promote_type(t1); t2 = promote_type(t2); return t1 > t2 ? t1 : t2; } static String *yyrename = 0; /* Forward renaming operator */ static String *resolve_create_node_scope(String *cname); Hash *Swig_cparse_features(void) { static Hash *features_hash = 0; if (!features_hash) features_hash = NewHash(); return features_hash; } /* Fully qualify any template parameters */ static String *feature_identifier_fix(String *s) { String *tp = SwigType_istemplate_templateprefix(s); if (tp) { String *ts, *ta, *tq; ts = SwigType_templatesuffix(s); ta = SwigType_templateargs(s); tq = Swig_symbol_type_qualify(ta,0); Append(tp,tq); Append(tp,ts); Delete(ts); Delete(ta); Delete(tq); return tp; } else { return NewString(s); } } static void set_access_mode(Node *n) { if (cplus_mode == CPLUS_PUBLIC) Setattr(n, "access", "public"); else if (cplus_mode == CPLUS_PROTECTED) Setattr(n, "access", "protected"); else Setattr(n, "access", "private"); } static void restore_access_mode(Node *n) { String *mode = Getattr(n, "access"); if (Strcmp(mode, "private") == 0) cplus_mode = CPLUS_PRIVATE; else if (Strcmp(mode, "protected") == 0) cplus_mode = CPLUS_PROTECTED; else cplus_mode = CPLUS_PUBLIC; } /* Generate the symbol table name for an object */ /* This is a bit of a mess. Need to clean up */ static String *add_oldname = 0; static String *make_name(Node *n, String *name,SwigType *decl) { int destructor = name && (*(Char(name)) == '~'); if (yyrename) { String *s = NewString(yyrename); Delete(yyrename); yyrename = 0; if (destructor && (*(Char(s)) != '~')) { Insert(s,0,"~"); } return s; } if (!name) return 0; return Swig_name_make(n,Namespaceprefix,name,decl,add_oldname); } /* Generate an unnamed identifier */ static String *make_unnamed() { unnamed++; return NewStringf("$unnamed%d$",unnamed); } /* Return if the node is a friend declaration */ static int is_friend(Node *n) { return Cmp(Getattr(n,"storage"),"friend") == 0; } static int is_operator(String *name) { return Strncmp(name,"operator ", 9) == 0; } /* Add declaration list to symbol table */ static int add_only_one = 0; static void add_symbols(Node *n) { String *decl; String *wrn = 0; if (inclass && n) { cparse_normalize_void(n); } while (n) { String *symname = 0; /* for friends, we need to pop the scope once */ String *old_prefix = 0; Symtab *old_scope = 0; int isfriend = inclass && is_friend(n); int iscdecl = Cmp(nodeType(n),"cdecl") == 0; int only_csymbol = 0; if (inclass) { String *name = Getattr(n, "name"); if (isfriend) { /* for friends, we need to add the scopename if needed */ String *prefix = name ? Swig_scopename_prefix(name) : 0; old_prefix = Namespaceprefix; old_scope = Swig_symbol_popscope(); Namespaceprefix = Swig_symbol_qualifiedscopename(0); if (!prefix) { if (name && !is_operator(name) && Namespaceprefix) { String *nname = NewStringf("%s::%s", Namespaceprefix, name); Setattr(n,"name",nname); Delete(nname); } } else { Symtab *st = Swig_symbol_getscope(prefix); String *ns = st ? Getattr(st,"name") : prefix; String *base = Swig_scopename_last(name); String *nname = NewStringf("%s::%s", ns, base); Setattr(n,"name",nname); Delete(nname); Delete(base); Delete(prefix); } Namespaceprefix = 0; } else { /* for member functions, we need to remove the redundant class scope if provided, as in struct Foo { int Foo::method(int a); }; */ String *prefix = name ? Swig_scopename_prefix(name) : 0; if (prefix) { if (Classprefix && (Equal(prefix,Classprefix))) { String *base = Swig_scopename_last(name); Setattr(n,"name",base); Delete(base); } Delete(prefix); } } } if (!isfriend && (inclass || extendmode)) { Setattr(n,"ismember","1"); } if (extendmode) { Setattr(n,"isextendmember","1"); } if (!isfriend && inclass) { if ((cplus_mode != CPLUS_PUBLIC)) { only_csymbol = 1; if (cplus_mode == CPLUS_PROTECTED) { Setattr(n,"access", "protected"); only_csymbol = !Swig_need_protected(n); } else { Setattr(n,"access", "private"); /* private are needed only when they are pure virtuals - why? */ if ((Cmp(Getattr(n,"storage"),"virtual") == 0) && (Cmp(Getattr(n,"value"),"0") == 0)) { only_csymbol = 0; } } } else { Setattr(n,"access", "public"); } } if (Getattr(n,"sym:name")) { n = nextSibling(n); continue; } decl = Getattr(n,"decl"); if (!SwigType_isfunction(decl)) { String *name = Getattr(n,"name"); String *makename = Getattr(n,"parser:makename"); if (iscdecl) { String *storage = Getattr(n, "storage"); if (Cmp(storage,"typedef") == 0) { Setattr(n,"kind","typedef"); } else { SwigType *type = Getattr(n,"type"); String *value = Getattr(n,"value"); Setattr(n,"kind","variable"); if (value && Len(value)) { Setattr(n,"hasvalue","1"); } if (type) { SwigType *ty; SwigType *tmp = 0; if (decl) { ty = tmp = Copy(type); SwigType_push(ty,decl); } else { ty = type; } if (!SwigType_ismutable(ty) || (storage && Strstr(storage, "constexpr"))) { SetFlag(n,"hasconsttype"); SetFlag(n,"feature:immutable"); } if (tmp) Delete(tmp); } if (!type) { Printf(stderr,"notype name %s\n", name); } } } Swig_features_get(Swig_cparse_features(), Namespaceprefix, name, 0, n); if (makename) { symname = make_name(n, makename,0); Delattr(n,"parser:makename"); /* temporary information, don't leave it hanging around */ } else { makename = name; symname = make_name(n, makename,0); } if (!symname) { symname = Copy(Getattr(n,"unnamed")); } if (symname) { wrn = Swig_name_warning(n, Namespaceprefix, symname,0); } } else { String *name = Getattr(n,"name"); SwigType *fdecl = Copy(decl); SwigType *fun = SwigType_pop_function(fdecl); if (iscdecl) { Setattr(n,"kind","function"); } Swig_features_get(Swig_cparse_features(),Namespaceprefix,name,fun,n); symname = make_name(n, name,fun); wrn = Swig_name_warning(n, Namespaceprefix,symname,fun); Delete(fdecl); Delete(fun); } if (!symname) { n = nextSibling(n); continue; } if (cparse_cplusplus) { String *value = Getattr(n, "value"); if (value && Strcmp(value, "delete") == 0) { /* C++11 deleted definition / deleted function */ SetFlag(n,"deleted"); SetFlag(n,"feature:ignore"); } } if (only_csymbol || GetFlag(n,"feature:ignore")) { /* Only add to C symbol table and continue */ Swig_symbol_add(0, n); } else if (strncmp(Char(symname),"$ignore",7) == 0) { char *c = Char(symname)+7; SetFlag(n,"feature:ignore"); if (strlen(c)) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1); SWIG_WARN_NODE_END(n); } Swig_symbol_add(0, n); } else { Node *c; if ((wrn) && (Len(wrn))) { String *metaname = symname; if (!Getmeta(metaname,"already_warned")) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(0,Getfile(n),Getline(n), "%s\n", wrn); SWIG_WARN_NODE_END(n); Setmeta(metaname,"already_warned","1"); } } c = Swig_symbol_add(symname,n); if (c != n) { /* symbol conflict attempting to add in the new symbol */ if (Getattr(n,"sym:weak")) { Setattr(n,"sym:name",symname); } else { String *e = NewStringEmpty(); String *en = NewStringEmpty(); String *ec = NewStringEmpty(); int redefined = Swig_need_redefined_warn(n,c,inclass); if (redefined) { Printf(en,"Identifier '%s' redefined (ignored)",symname); Printf(ec,"previous definition of '%s'",symname); } else { Printf(en,"Redundant redeclaration of '%s'",symname); Printf(ec,"previous declaration of '%s'",symname); } if (Cmp(symname,Getattr(n,"name"))) { Printf(en," (Renamed from '%s')", SwigType_namestr(Getattr(n,"name"))); } Printf(en,","); if (Cmp(symname,Getattr(c,"name"))) { Printf(ec," (Renamed from '%s')", SwigType_namestr(Getattr(c,"name"))); } Printf(ec,"."); SWIG_WARN_NODE_BEGIN(n); if (redefined) { Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en); Swig_warning(WARN_PARSE_REDEFINED,Getfile(c),Getline(c),"%s\n",ec); } else if (!is_friend(n) && !is_friend(c)) { Swig_warning(WARN_PARSE_REDUNDANT,Getfile(n),Getline(n),"%s\n",en); Swig_warning(WARN_PARSE_REDUNDANT,Getfile(c),Getline(c),"%s\n",ec); } SWIG_WARN_NODE_END(n); Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(n),Getline(n),en, Getfile(c),Getline(c),ec); Setattr(n,"error",e); Delete(e); Delete(en); Delete(ec); } } } /* restore the class scope if needed */ if (isfriend) { Swig_symbol_setscope(old_scope); if (old_prefix) { Delete(Namespaceprefix); Namespaceprefix = old_prefix; } } Delete(symname); if (add_only_one) return; n = nextSibling(n); } } /* add symbols a parse tree node copy */ static void add_symbols_copy(Node *n) { String *name; int emode = 0; while (n) { char *cnodeType = Char(nodeType(n)); if (strcmp(cnodeType,"access") == 0) { String *kind = Getattr(n,"kind"); if (Strcmp(kind,"public") == 0) { cplus_mode = CPLUS_PUBLIC; } else if (Strcmp(kind,"private") == 0) { cplus_mode = CPLUS_PRIVATE; } else if (Strcmp(kind,"protected") == 0) { cplus_mode = CPLUS_PROTECTED; } n = nextSibling(n); continue; } add_oldname = Getattr(n,"sym:name"); if ((add_oldname) || (Getattr(n,"sym:needs_symtab"))) { int old_inclass = -1; Node *old_current_class = 0; if (add_oldname) { DohIncref(add_oldname); /* Disable this, it prevents %rename to work with templates */ /* If already renamed, we used that name */ /* if (Strcmp(add_oldname, Getattr(n,"name")) != 0) { Delete(yyrename); yyrename = Copy(add_oldname); } */ } Delattr(n,"sym:needs_symtab"); Delattr(n,"sym:name"); add_only_one = 1; add_symbols(n); if (Getattr(n,"partialargs")) { Swig_symbol_cadd(Getattr(n,"partialargs"),n); } add_only_one = 0; name = Getattr(n,"name"); if (Getattr(n,"requires_symtab")) { Swig_symbol_newscope(); Swig_symbol_setscopename(name); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } if (strcmp(cnodeType,"class") == 0) { old_inclass = inclass; inclass = 1; old_current_class = current_class; current_class = n; if (Strcmp(Getattr(n,"kind"),"class") == 0) { cplus_mode = CPLUS_PRIVATE; } else { cplus_mode = CPLUS_PUBLIC; } } if (strcmp(cnodeType,"extend") == 0) { emode = cplus_mode; cplus_mode = CPLUS_PUBLIC; } add_symbols_copy(firstChild(n)); if (strcmp(cnodeType,"extend") == 0) { cplus_mode = emode; } if (Getattr(n,"requires_symtab")) { Setattr(n,"symtab", Swig_symbol_popscope()); Delattr(n,"requires_symtab"); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } if (add_oldname) { Delete(add_oldname); add_oldname = 0; } if (strcmp(cnodeType,"class") == 0) { inclass = old_inclass; current_class = old_current_class; } } else { if (strcmp(cnodeType,"extend") == 0) { emode = cplus_mode; cplus_mode = CPLUS_PUBLIC; } add_symbols_copy(firstChild(n)); if (strcmp(cnodeType,"extend") == 0) { cplus_mode = emode; } } n = nextSibling(n); } } /* Check a set of declarations to see if any are pure-abstract */ static List *pure_abstracts(Node *n) { List *abstracts = 0; while (n) { if (Cmp(nodeType(n),"cdecl") == 0) { String *decl = Getattr(n,"decl"); if (SwigType_isfunction(decl)) { String *init = Getattr(n,"value"); if (Cmp(init,"0") == 0) { if (!abstracts) { abstracts = NewList(); } Append(abstracts,n); SetFlag(n,"abstract"); } } } else if (Cmp(nodeType(n),"destructor") == 0) { if (Cmp(Getattr(n,"value"),"0") == 0) { if (!abstracts) { abstracts = NewList(); } Append(abstracts,n); SetFlag(n,"abstract"); } } n = nextSibling(n); } return abstracts; } /* Make a classname */ static String *make_class_name(String *name) { String *nname = 0; String *prefix; if (Namespaceprefix) { nname= NewStringf("%s::%s", Namespaceprefix, name); } else { nname = NewString(name); } prefix = SwigType_istemplate_templateprefix(nname); if (prefix) { String *args, *qargs; args = SwigType_templateargs(nname); qargs = Swig_symbol_type_qualify(args,0); Append(prefix,qargs); Delete(nname); Delete(args); Delete(qargs); nname = prefix; } return nname; } /* Use typedef name as class name */ static void add_typedef_name(Node *n, Node *decl, String *oldName, Symtab *cscope, String *scpname) { String *class_rename = 0; SwigType *decltype = Getattr(decl, "decl"); if (!decltype || !Len(decltype)) { String *cname; String *tdscopename; String *class_scope = Swig_symbol_qualifiedscopename(cscope); String *name = Getattr(decl, "name"); cname = Copy(name); Setattr(n, "tdname", cname); tdscopename = class_scope ? NewStringf("%s::%s", class_scope, name) : Copy(name); class_rename = Getattr(n, "class_rename"); if (class_rename && (Strcmp(class_rename, oldName) == 0)) Setattr(n, "class_rename", NewString(name)); if (!classes_typedefs) classes_typedefs = NewHash(); if (!Equal(scpname, tdscopename) && !Getattr(classes_typedefs, tdscopename)) { Setattr(classes_typedefs, tdscopename, n); } Setattr(n, "decl", decltype); Delete(class_scope); Delete(cname); Delete(tdscopename); } } /* If the class name is qualified. We need to create or lookup namespace entries */ static Symtab *set_scope_to_global() { Symtab *symtab = Swig_symbol_global_scope(); Swig_symbol_setscope(symtab); return symtab; } /* Remove the block braces, { and }, if the 'noblock' attribute is set. * Node *kw can be either a Hash or Parmlist. */ static String *remove_block(Node *kw, const String *inputcode) { String *modified_code = 0; while (kw) { String *name = Getattr(kw,"name"); if (name && (Cmp(name,"noblock") == 0)) { char *cstr = Char(inputcode); size_t len = Len(inputcode); if (len && cstr[0] == '{') { --len; ++cstr; if (len && cstr[len - 1] == '}') { --len; } /* we now remove the extra spaces */ while (len && isspace((int)cstr[0])) { --len; ++cstr; } while (len && isspace((int)cstr[len - 1])) { --len; } modified_code = NewStringWithSize(cstr, len); break; } } kw = nextSibling(kw); } return modified_code; } static Node *nscope = 0; static Node *nscope_inner = 0; /* Remove the scope prefix from cname and return the base name without the prefix. * The scopes required for the symbol name are resolved and/or created, if required. * For example AA::BB::CC as input returns CC and creates the namespace AA then inner * namespace BB in the current scope. If cname is found to already exist as a weak symbol * (forward reference) then the scope might be changed to match, such as when a symbol match * is made via a using reference. */ static String *resolve_create_node_scope(String *cname) { Symtab *gscope = 0; Node *cname_node = 0; int skip_lookup = 0; nscope = 0; nscope_inner = 0; if (Strncmp(cname,"::",2) == 0) skip_lookup = 1; cname_node = skip_lookup ? 0 : Swig_symbol_clookup_no_inherit(cname, 0); if (cname_node) { /* The symbol has been defined already or is in another scope. If it is a weak symbol, it needs replacing and if it was brought into the current scope via a using declaration, the scope needs adjusting appropriately for the new symbol. Similarly for defined templates. */ Symtab *symtab = Getattr(cname_node, "sym:symtab"); Node *sym_weak = Getattr(cname_node, "sym:weak"); if ((symtab && sym_weak) || Equal(nodeType(cname_node), "template")) { /* Check if the scope is the current scope */ String *current_scopename = Swig_symbol_qualifiedscopename(0); String *found_scopename = Swig_symbol_qualifiedscopename(symtab); int len; if (!current_scopename) current_scopename = NewString(""); if (!found_scopename) found_scopename = NewString(""); len = Len(current_scopename); if ((len > 0) && (Strncmp(current_scopename, found_scopename, len) == 0)) { if (Len(found_scopename) > len + 2) { /* A matching weak symbol was found in non-global scope, some scope adjustment may be required */ String *new_cname = NewString(Char(found_scopename) + len + 2); /* skip over "::" prefix */ String *base = Swig_scopename_last(cname); Printf(new_cname, "::%s", base); cname = new_cname; Delete(base); } else { /* A matching weak symbol was found in the same non-global local scope, no scope adjustment required */ assert(len == Len(found_scopename)); } } else { String *base = Swig_scopename_last(cname); if (Len(found_scopename) > 0) { /* A matching weak symbol was found in a different scope to the local scope - probably via a using declaration */ cname = NewStringf("%s::%s", found_scopename, base); } else { /* Either: 1) A matching weak symbol was found in a different scope to the local scope - this is actually a symbol with the same name in a different scope which we don't want, so no adjustment required. 2) A matching weak symbol was found in the global scope - no adjustment required. */ cname = Copy(base); } Delete(base); } Delete(current_scopename); Delete(found_scopename); } } if (Swig_scopename_check(cname)) { Node *ns; String *prefix = Swig_scopename_prefix(cname); String *base = Swig_scopename_last(cname); if (prefix && (Strncmp(prefix,"::",2) == 0)) { /* I don't think we can use :: global scope to declare classes and hence neither %template. - consider reporting error instead - wsfulton. */ /* Use the global scope */ String *nprefix = NewString(Char(prefix)+2); Delete(prefix); prefix= nprefix; gscope = set_scope_to_global(); } if (Len(prefix) == 0) { /* Use the global scope, but we need to add a 'global' namespace. */ if (!gscope) gscope = set_scope_to_global(); /* note that this namespace is not the "unnamed" one, and we don't use Setattr(nscope,"name", ""), because the unnamed namespace is private */ nscope = new_node("namespace"); Setattr(nscope,"symtab", gscope);; nscope_inner = nscope; return base; } /* Try to locate the scope */ ns = Swig_symbol_clookup(prefix,0); if (!ns) { Swig_error(cparse_file,cparse_line,"Undefined scope '%s'\n", prefix); } else { Symtab *nstab = Getattr(ns,"symtab"); if (!nstab) { Swig_error(cparse_file,cparse_line, "'%s' is not defined as a valid scope.\n", prefix); ns = 0; } else { /* Check if the node scope is the current scope */ String *tname = Swig_symbol_qualifiedscopename(0); String *nname = Swig_symbol_qualifiedscopename(nstab); if (tname && (Strcmp(tname,nname) == 0)) { ns = 0; cname = base; } Delete(tname); Delete(nname); } if (ns) { /* we will try to create a new node using the namespaces we can find in the scope name */ List *scopes; String *sname; Iterator si; String *name = NewString(prefix); scopes = NewList(); while (name) { String *base = Swig_scopename_last(name); String *tprefix = Swig_scopename_prefix(name); Insert(scopes,0,base); Delete(base); Delete(name); name = tprefix; } for (si = First(scopes); si.item; si = Next(si)) { Node *ns1,*ns2; sname = si.item; ns1 = Swig_symbol_clookup(sname,0); assert(ns1); if (Strcmp(nodeType(ns1),"namespace") == 0) { if (Getattr(ns1,"alias")) { ns1 = Getattr(ns1,"namespace"); } } else { /* now this last part is a class */ si = Next(si); /* or a nested class tree, which is unrolled here */ for (; si.item; si = Next(si)) { if (si.item) { Printf(sname,"::%s",si.item); } } /* we get the 'inner' class */ nscope_inner = Swig_symbol_clookup(sname,0); /* set the scope to the inner class */ Swig_symbol_setscope(Getattr(nscope_inner,"symtab")); /* save the last namespace prefix */ Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); /* and return the node name, including the inner class prefix */ break; } /* here we just populate the namespace tree as usual */ ns2 = new_node("namespace"); Setattr(ns2,"name",sname); Setattr(ns2,"symtab", Getattr(ns1,"symtab")); add_symbols(ns2); Swig_symbol_setscope(Getattr(ns1,"symtab")); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); if (nscope_inner) { if (Getattr(nscope_inner,"symtab") != Getattr(ns2,"symtab")) { appendChild(nscope_inner,ns2); Delete(ns2); } } nscope_inner = ns2; if (!nscope) nscope = ns2; } cname = base; Delete(scopes); } } Delete(prefix); } return cname; } /* look for simple typedef name in typedef list */ static String *try_to_find_a_name_for_unnamed_structure(const char *storage, Node *decls) { String *name = 0; Node *n = decls; if (storage && (strcmp(storage, "typedef") == 0)) { for (; n; n = nextSibling(n)) { if (!Len(Getattr(n, "decl"))) { name = Copy(Getattr(n, "name")); break; } } } return name; } /* traverse copied tree segment, and update outer class links*/ static void update_nested_classes(Node *n) { Node *c = firstChild(n); while (c) { if (Getattr(c, "nested:outer")) Setattr(c, "nested:outer", n); update_nested_classes(c); c = nextSibling(c); } } /* ----------------------------------------------------------------------------- * nested_forward_declaration() * * Nested struct handling for C++ code if the nested classes are disabled. * Create the nested class/struct/union as a forward declaration. * ----------------------------------------------------------------------------- */ static Node *nested_forward_declaration(const char *storage, const char *kind, String *sname, String *name, Node *cpp_opt_declarators) { Node *nn = 0; int warned = 0; if (sname) { /* Add forward declaration of the nested type */ Node *n = new_node("classforward"); Setattr(n, "kind", kind); Setattr(n, "name", sname); Setattr(n, "storage", storage); Setattr(n, "sym:weak", "1"); add_symbols(n); nn = n; } /* Add any variable instances. Also add in any further typedefs of the nested type. Note that anonymous typedefs (eg typedef struct {...} a, b;) are treated as class forward declarations */ if (cpp_opt_declarators) { int storage_typedef = (storage && (strcmp(storage, "typedef") == 0)); int variable_of_anonymous_type = !sname && !storage_typedef; if (!variable_of_anonymous_type) { int anonymous_typedef = !sname && (storage && (strcmp(storage, "typedef") == 0)); Node *n = cpp_opt_declarators; SwigType *type = name; while (n) { Setattr(n, "type", type); Setattr(n, "storage", storage); if (anonymous_typedef) { Setattr(n, "nodeType", "classforward"); Setattr(n, "sym:weak", "1"); } n = nextSibling(n); } add_symbols(cpp_opt_declarators); if (nn) { set_nextSibling(nn, cpp_opt_declarators); } else { nn = cpp_opt_declarators; } } } if (!GetFlag(currentOuterClass, "nested")) { if (nn && Equal(nodeType(nn), "classforward")) { Node *n = nn; SWIG_WARN_NODE_BEGIN(n); Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", kind, sname ? sname : name); SWIG_WARN_NODE_END(n); warned = 1; } if (!warned) { Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", kind); } } return nn; } Node *Swig_cparse(File *f) { scanner_file(f); top = 0; yyparse(); return top; } static void single_new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) { String *fname; String *name; String *fixname; SwigType *t = Copy(type); /* Printf(stdout, "single_new_feature: [%s] [%s] [%s] [%s] [%s] [%s]\n", featurename, val, declaratorid, t, ParmList_str_defaultargs(declaratorparms), qualifier); */ /* Warn about deprecated features */ if (strcmp(featurename, "nestedworkaround") == 0) Swig_warning(WARN_DEPRECATED_NESTED_WORKAROUND, cparse_file, cparse_line, "The 'nestedworkaround' feature is deprecated.\n"); fname = NewStringf("feature:%s",featurename); if (declaratorid) { fixname = feature_identifier_fix(declaratorid); } else { fixname = NewStringEmpty(); } if (Namespaceprefix) { name = NewStringf("%s::%s",Namespaceprefix, fixname); } else { name = fixname; } if (declaratorparms) Setmeta(val,"parms",declaratorparms); if (!Len(t)) t = 0; if (t) { if (qualifier) SwigType_push(t,qualifier); if (SwigType_isfunction(t)) { SwigType *decl = SwigType_pop_function(t); if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",name); Swig_feature_set(Swig_cparse_features(), nname, decl, fname, val, featureattribs); Delete(nname); } else { Swig_feature_set(Swig_cparse_features(), name, decl, fname, val, featureattribs); } Delete(decl); } else if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",name); Swig_feature_set(Swig_cparse_features(),nname,0,fname,val, featureattribs); Delete(nname); } } else { /* Global feature, that is, feature not associated with any particular symbol */ Swig_feature_set(Swig_cparse_features(),name,0,fname,val, featureattribs); } Delete(fname); Delete(name); } /* Add a new feature to the Hash. Additional features are added if the feature has a parameter list (declaratorparms) * and one or more of the parameters have a default argument. An extra feature is added for each defaulted parameter, * simulating the equivalent overloaded method. */ static void new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) { ParmList *declparms = declaratorparms; /* remove the { and } braces if the noblock attribute is set */ String *newval = remove_block(featureattribs, val); val = newval ? newval : val; /* Add the feature */ single_new_feature(featurename, val, featureattribs, declaratorid, type, declaratorparms, qualifier); /* Add extra features if there are default parameters in the parameter list */ if (type) { while (declparms) { if (ParmList_has_defaultargs(declparms)) { /* Create a parameter list for the new feature by copying all but the last (defaulted) parameter */ ParmList* newparms = CopyParmListMax(declparms, ParmList_len(declparms)-1); /* Create new declaration - with the last parameter removed */ SwigType *newtype = Copy(type); Delete(SwigType_pop_function(newtype)); /* remove the old parameter list from newtype */ SwigType_add_function(newtype,newparms); single_new_feature(featurename, Copy(val), featureattribs, declaratorid, newtype, newparms, qualifier); declparms = newparms; } else { declparms = 0; } } } } /* check if a function declaration is a plain C object */ static int is_cfunction(Node *n) { if (!cparse_cplusplus || cparse_externc) return 1; if (Swig_storage_isexternc(n)) { return 1; } return 0; } /* If the Node is a function with parameters, check to see if any of the parameters * have default arguments. If so create a new function for each defaulted argument. * The additional functions form a linked list of nodes with the head being the original Node n. */ static void default_arguments(Node *n) { Node *function = n; if (function) { ParmList *varargs = Getattr(function,"feature:varargs"); if (varargs) { /* Handles the %varargs directive by looking for "feature:varargs" and * substituting ... with an alternative set of arguments. */ Parm *p = Getattr(function,"parms"); Parm *pp = 0; while (p) { SwigType *t = Getattr(p,"type"); if (Strcmp(t,"v(...)") == 0) { if (pp) { ParmList *cv = Copy(varargs); set_nextSibling(pp,cv); Delete(cv); } else { ParmList *cv = Copy(varargs); Setattr(function,"parms", cv); Delete(cv); } break; } pp = p; p = nextSibling(p); } } /* Do not add in functions if kwargs is being used or if user wants old default argument wrapping (one wrapped method per function irrespective of number of default arguments) */ if (compact_default_args || is_cfunction(function) || GetFlag(function,"feature:compactdefaultargs") || GetFlag(function,"feature:kwargs")) { ParmList *p = Getattr(function,"parms"); if (p) Setattr(p,"compactdefargs", "1"); /* mark parameters for special handling */ function = 0; /* don't add in extra methods */ } } while (function) { ParmList *parms = Getattr(function,"parms"); if (ParmList_has_defaultargs(parms)) { /* Create a parameter list for the new function by copying all but the last (defaulted) parameter */ ParmList* newparms = CopyParmListMax(parms,ParmList_len(parms)-1); /* Create new function and add to symbol table */ { SwigType *ntype = Copy(nodeType(function)); char *cntype = Char(ntype); Node *new_function = new_node(ntype); SwigType *decl = Copy(Getattr(function,"decl")); int constqualifier = SwigType_isconst(decl); String *ccode = Copy(Getattr(function,"code")); String *cstorage = Copy(Getattr(function,"storage")); String *cvalue = Copy(Getattr(function,"value")); SwigType *ctype = Copy(Getattr(function,"type")); String *cthrow = Copy(Getattr(function,"throw")); Delete(SwigType_pop_function(decl)); /* remove the old parameter list from decl */ SwigType_add_function(decl,newparms); if (constqualifier) SwigType_add_qualifier(decl,"const"); Setattr(new_function,"name", Getattr(function,"name")); Setattr(new_function,"code", ccode); Setattr(new_function,"decl", decl); Setattr(new_function,"parms", newparms); Setattr(new_function,"storage", cstorage); Setattr(new_function,"value", cvalue); Setattr(new_function,"type", ctype); Setattr(new_function,"throw", cthrow); Delete(ccode); Delete(cstorage); Delete(cvalue); Delete(ctype); Delete(cthrow); Delete(decl); { Node *throws = Getattr(function,"throws"); ParmList *pl = CopyParmList(throws); if (throws) Setattr(new_function,"throws",pl); Delete(pl); } /* copy specific attributes for global (or in a namespace) template functions - these are not templated class methods */ if (strcmp(cntype,"template") == 0) { Node *templatetype = Getattr(function,"templatetype"); Node *symtypename = Getattr(function,"sym:typename"); Parm *templateparms = Getattr(function,"templateparms"); if (templatetype) { Node *tmp = Copy(templatetype); Setattr(new_function,"templatetype",tmp); Delete(tmp); } if (symtypename) { Node *tmp = Copy(symtypename); Setattr(new_function,"sym:typename",tmp); Delete(tmp); } if (templateparms) { Parm *tmp = CopyParmList(templateparms); Setattr(new_function,"templateparms",tmp); Delete(tmp); } } else if (strcmp(cntype,"constructor") == 0) { /* only copied for constructors as this is not a user defined feature - it is hard coded in the parser */ if (GetFlag(function,"feature:new")) SetFlag(new_function,"feature:new"); } add_symbols(new_function); /* mark added functions as ones with overloaded parameters and point to the parsed method */ Setattr(new_function,"defaultargs", n); /* Point to the new function, extending the linked list */ set_nextSibling(function, new_function); Delete(new_function); function = new_function; Delete(ntype); } } else { function = 0; } } } /* ----------------------------------------------------------------------------- * mark_nodes_as_extend() * * Used by the %extend to mark subtypes with "feature:extend". * template instances declared within %extend are skipped * ----------------------------------------------------------------------------- */ static void mark_nodes_as_extend(Node *n) { for (; n; n = nextSibling(n)) { if (Getattr(n, "template") && Strcmp(nodeType(n), "class") == 0) continue; /* Fix me: extend is not a feature. Replace with isextendmember? */ Setattr(n, "feature:extend", "1"); mark_nodes_as_extend(firstChild(n)); } } %} %union { char *id; List *bases; struct Define { String *val; String *rawval; int type; String *qualifier; String *bitfield; Parm *throws; String *throwf; String *nexcept; } dtype; struct { const char *type; String *filename; int line; } loc; struct { char *id; SwigType *type; String *defarg; ParmList *parms; short have_parms; ParmList *throws; String *throwf; String *nexcept; } decl; Parm *tparms; struct { String *method; Hash *kwargs; } tmap; struct { String *type; String *us; } ptype; SwigType *type; String *str; Parm *p; ParmList *pl; int intvalue; Node *node; }; %token ID %token HBLOCK %token POUND %token STRING WSTRING %token INCLUDE IMPORT INSERT %token CHARCONST WCHARCONST %token NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL %token TYPEDEF %token TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64 %token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD %token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET %token BEGINFILE ENDOFFILE %token ILLEGAL CONSTANT %token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS %token ENUM %token CLASS TYPENAME PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND THROW CATCH EXPLICIT %token STATIC_ASSERT CONSTEXPR THREAD_LOCAL DECLTYPE AUTO NOEXCEPT /* C++11 keywords */ %token OVERRIDE FINAL /* C++11 identifiers with special meaning */ %token USING %token NAMESPACE %token NATIVE INLINE %token TYPEMAP EXCEPT ECHO APPLY CLEAR SWIGTEMPLATE FRAGMENT %token WARN %token LESSTHAN GREATERTHAN DELETE_KW DEFAULT %token LESSTHANOREQUALTO GREATERTHANOREQUALTO EQUALTO NOTEQUALTO %token ARROW %token QUESTIONMARK %token TYPES PARMS %token NONID DSTAR DCNOT %token TEMPLATE %token OPERATOR %token COPERATOR %token PARSETYPE PARSEPARM PARSEPARMS %left CAST %left QUESTIONMARK %left LOR %left LAND %left OR %left XOR %left AND %left EQUALTO NOTEQUALTO %left GREATERTHAN LESSTHAN GREATERTHANOREQUALTO LESSTHANOREQUALTO %left LSHIFT RSHIFT %left PLUS MINUS %left STAR SLASH MODULO %left UMINUS NOT LNOT %left DCOLON %type program interface declaration swig_directive ; /* SWIG directives */ %type extend_directive apply_directive clear_directive constant_directive ; %type echo_directive except_directive fragment_directive include_directive inline_directive ; %type insert_directive module_directive name_directive native_directive ; %type pragma_directive rename_directive feature_directive varargs_directive typemap_directive ; %type types_directive template_directive warn_directive ; /* C declarations */ %type c_declaration c_decl c_decl_tail c_enum_key c_enum_inherit c_enum_decl c_enum_forward_decl c_constructor_decl; %type enumlist edecl; /* C++ declarations */ %type cpp_declaration cpp_class_decl cpp_forward_class_decl cpp_template_decl cpp_alternate_rettype; %type cpp_members cpp_member; %type cpp_constructor_decl cpp_destructor_decl cpp_protection_decl cpp_conversion_operator cpp_static_assert; %type cpp_swig_directive cpp_temp_possible cpp_opt_declarators ; %type cpp_using_decl cpp_namespace_decl cpp_catch_decl cpp_lambda_decl; %type kwargs options; /* Misc */ %type identifier; %type initializer cpp_const exception_specification; %type storage_class; %type parms ptail rawparms varargs_parms ; %type templateparameters templateparameterstail; %type

parm valparm rawvalparms valparms valptail ; %type

typemap_parm tm_list tm_tail ; %type

templateparameter ; %type templcpptype cpptype access_specifier; %type base_specifier; %type ellipsis variadic; %type type rawtype type_right anon_bitfield_type decltype ; %type base_list inherit raw_inherit; %type definetype def_args etype default_delete deleted_definition explicit_default; %type expr exprnum exprcompound valexpr; %type ename ; %type template_decl; %type type_qualifier ; %type type_qualifier_raw; %type idstring idstringopt; %type pragma_lang; %type pragma_arg; %type includetype; %type pointer primitive_type; %type declarator direct_declarator notso_direct_declarator parameter_declarator typemap_parameter_declarator; %type abstract_declarator direct_abstract_declarator ctor_end; %type typemap_type; %type idcolon idcolontail idcolonnt idcolontailnt idtemplate stringbrace stringbracesemi; %type string stringnum wstring; %type template_parms; %type cpp_end cpp_vend; %type rename_namewarn; %type type_specifier primitive_type_list ; %type fname stringtype; %type featattr; %type lambda_introducer lambda_body; %type lambda_tail; %type optional_constant_directive; %type virt_specifier_seq; %% /* ====================================================================== * High-level Interface file * * An interface is just a sequence of declarations which may be SWIG directives * or normal C declarations. * ====================================================================== */ program : interface { if (!classes) classes = NewHash(); Setattr($1,"classes",classes); Setattr($1,"name",ModuleName); if ((!module_node) && ModuleName) { module_node = new_node("module"); Setattr(module_node,"name",ModuleName); } Setattr($1,"module",module_node); top = $1; } | PARSETYPE parm SEMI { top = Copy(Getattr($2,"type")); Delete($2); } | PARSETYPE error { top = 0; } | PARSEPARM parm SEMI { top = $2; } | PARSEPARM error { top = 0; } | PARSEPARMS LPAREN parms RPAREN SEMI { top = $3; } | PARSEPARMS error SEMI { top = 0; } ; interface : interface declaration { /* add declaration to end of linked list (the declaration isn't always a single declaration, sometimes it is a linked list itself) */ appendChild($1,$2); $$ = $1; } | empty { $$ = new_node("top"); } ; declaration : swig_directive { $$ = $1; } | c_declaration { $$ = $1; } | cpp_declaration { $$ = $1; } | SEMI { $$ = 0; } | error { $$ = 0; Swig_error(cparse_file, cparse_line,"Syntax error in input(1).\n"); exit(1); } /* Out of class constructor/destructor declarations */ | c_constructor_decl { if ($$) { add_symbols($$); } $$ = $1; } /* Out of class conversion operator. For example: inline A::operator char *() const { ... }. This is nearly impossible to parse normally. We just let the first part generate a syntax error and then resynchronize on the COPERATOR token---discarding the rest of the definition. Ugh. */ | error COPERATOR { $$ = 0; skip_decl(); } ; /* ====================================================================== * SWIG DIRECTIVES * ====================================================================== */ swig_directive : extend_directive { $$ = $1; } | apply_directive { $$ = $1; } | clear_directive { $$ = $1; } | constant_directive { $$ = $1; } | echo_directive { $$ = $1; } | except_directive { $$ = $1; } | fragment_directive { $$ = $1; } | include_directive { $$ = $1; } | inline_directive { $$ = $1; } | insert_directive { $$ = $1; } | module_directive { $$ = $1; } | name_directive { $$ = $1; } | native_directive { $$ = $1; } | pragma_directive { $$ = $1; } | rename_directive { $$ = $1; } | feature_directive { $$ = $1; } | varargs_directive { $$ = $1; } | typemap_directive { $$ = $1; } | types_directive { $$ = $1; } | template_directive { $$ = $1; } | warn_directive { $$ = $1; } ; /* ------------------------------------------------------------ %extend classname { ... } ------------------------------------------------------------ */ extend_directive : EXTEND options idcolon LBRACE { Node *cls; String *clsname; extendmode = 1; cplus_mode = CPLUS_PUBLIC; if (!classes) classes = NewHash(); if (!classes_typedefs) classes_typedefs = NewHash(); clsname = make_class_name($3); cls = Getattr(classes,clsname); if (!cls) { cls = Getattr(classes_typedefs, clsname); if (!cls) { /* No previous definition. Create a new scope */ Node *am = Getattr(Swig_extend_hash(),clsname); if (!am) { Swig_symbol_newscope(); Swig_symbol_setscopename($3); prev_symtab = 0; } else { prev_symtab = Swig_symbol_setscope(Getattr(am,"symtab")); } current_class = 0; } else { /* Previous typedef class definition. Use its symbol table. Deprecated, just the real name should be used. Note that %extend before the class typedef never worked, only %extend after the class typdef. */ prev_symtab = Swig_symbol_setscope(Getattr(cls, "symtab")); current_class = cls; SWIG_WARN_NODE_BEGIN(cls); Swig_warning(WARN_PARSE_EXTEND_NAME, cparse_file, cparse_line, "Deprecated %%extend name used - the %s name '%s' should be used instead of the typedef name '%s'.\n", Getattr(cls, "kind"), SwigType_namestr(Getattr(cls, "name")), $3); SWIG_WARN_NODE_END(cls); } } else { /* Previous class definition. Use its symbol table */ prev_symtab = Swig_symbol_setscope(Getattr(cls,"symtab")); current_class = cls; } Classprefix = NewString($3); Namespaceprefix= Swig_symbol_qualifiedscopename(0); Delete(clsname); } cpp_members RBRACE { String *clsname; extendmode = 0; $$ = new_node("extend"); Setattr($$,"symtab",Swig_symbol_popscope()); if (prev_symtab) { Swig_symbol_setscope(prev_symtab); } Namespaceprefix = Swig_symbol_qualifiedscopename(0); clsname = make_class_name($3); Setattr($$,"name",clsname); mark_nodes_as_extend($6); if (current_class) { /* We add the extension to the previously defined class */ appendChild($$,$6); appendChild(current_class,$$); } else { /* We store the extensions in the extensions hash */ Node *am = Getattr(Swig_extend_hash(),clsname); if (am) { /* Append the members to the previous extend methods */ appendChild(am,$6); } else { appendChild($$,$6); Setattr(Swig_extend_hash(),clsname,$$); } } current_class = 0; Delete(Classprefix); Delete(clsname); Classprefix = 0; prev_symtab = 0; $$ = 0; } ; /* ------------------------------------------------------------ %apply ------------------------------------------------------------ */ apply_directive : APPLY typemap_parm LBRACE tm_list RBRACE { $$ = new_node("apply"); Setattr($$,"pattern",Getattr($2,"pattern")); appendChild($$,$4); }; /* ------------------------------------------------------------ %clear ------------------------------------------------------------ */ clear_directive : CLEAR tm_list SEMI { $$ = new_node("clear"); appendChild($$,$2); } ; /* ------------------------------------------------------------ %constant name = value; %constant type name = value; ------------------------------------------------------------ */ constant_directive : CONSTANT identifier EQUAL definetype SEMI { if (($4.type != T_ERROR) && ($4.type != T_SYMBOL)) { SwigType *type = NewSwigType($4.type); $$ = new_node("constant"); Setattr($$,"name",$2); Setattr($$,"type",type); Setattr($$,"value",$4.val); if ($4.rawval) Setattr($$,"rawval", $4.rawval); Setattr($$,"storage","%constant"); SetFlag($$,"feature:immutable"); add_symbols($$); Delete(type); } else { if ($4.type == T_ERROR) { Swig_warning(WARN_PARSE_UNSUPPORTED_VALUE,cparse_file,cparse_line,"Unsupported constant value (ignored)\n"); } $$ = 0; } } | CONSTANT type declarator def_args SEMI { if (($4.type != T_ERROR) && ($4.type != T_SYMBOL)) { SwigType_push($2,$3.type); /* Sneaky callback function trick */ if (SwigType_isfunction($2)) { SwigType_add_pointer($2); } $$ = new_node("constant"); Setattr($$,"name",$3.id); Setattr($$,"type",$2); Setattr($$,"value",$4.val); if ($4.rawval) Setattr($$,"rawval", $4.rawval); Setattr($$,"storage","%constant"); SetFlag($$,"feature:immutable"); add_symbols($$); } else { if ($4.type == T_ERROR) { Swig_warning(WARN_PARSE_UNSUPPORTED_VALUE,cparse_file,cparse_line,"Unsupported constant value\n"); } $$ = 0; } } | CONSTANT error SEMI { Swig_warning(WARN_PARSE_BAD_VALUE,cparse_file,cparse_line,"Bad constant value (ignored).\n"); $$ = 0; } ; /* ------------------------------------------------------------ %echo "text" %echo %{ ... %} ------------------------------------------------------------ */ echo_directive : ECHO HBLOCK { char temp[64]; Replace($2,"$file",cparse_file, DOH_REPLACE_ANY); sprintf(temp,"%d", cparse_line); Replace($2,"$line",temp,DOH_REPLACE_ANY); Printf(stderr,"%s\n", $2); Delete($2); $$ = 0; } | ECHO string { char temp[64]; String *s = NewString($2); Replace(s,"$file",cparse_file, DOH_REPLACE_ANY); sprintf(temp,"%d", cparse_line); Replace(s,"$line",temp,DOH_REPLACE_ANY); Printf(stderr,"%s\n", s); Delete(s); $$ = 0; } ; /* ------------------------------------------------------------ %except(lang) { ... } %except { ... } %except(lang); %except; ------------------------------------------------------------ */ except_directive : EXCEPT LPAREN identifier RPAREN LBRACE { skip_balanced('{','}'); $$ = 0; Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, "%%except is deprecated. Use %%exception instead.\n"); } | EXCEPT LBRACE { skip_balanced('{','}'); $$ = 0; Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, "%%except is deprecated. Use %%exception instead.\n"); } | EXCEPT LPAREN identifier RPAREN SEMI { $$ = 0; Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, "%%except is deprecated. Use %%exception instead.\n"); } | EXCEPT SEMI { $$ = 0; Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, "%%except is deprecated. Use %%exception instead.\n"); } ; /* fragment keyword arguments */ stringtype : string LBRACE parm RBRACE { $$ = NewHash(); Setattr($$,"value",$1); Setattr($$,"type",Getattr($3,"type")); } ; fname : string { $$ = NewHash(); Setattr($$,"value",$1); } | stringtype { $$ = $1; } ; /* ------------------------------------------------------------ %fragment(name, section) %{ ... %} %fragment("name" {type}, "section") %{ ... %} %fragment("name", "section", fragment="fragment1", fragment="fragment2") %{ ... %} Also as above but using { ... } %fragment("name"); ------------------------------------------------------------ */ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK { Hash *p = $5; $$ = new_node("fragment"); Setattr($$,"value",Getattr($3,"value")); Setattr($$,"type",Getattr($3,"type")); Setattr($$,"section",Getattr(p,"name")); Setattr($$,"kwargs",nextSibling(p)); Setattr($$,"code",$7); } | FRAGMENT LPAREN fname COMMA kwargs RPAREN LBRACE { Hash *p = $5; String *code; skip_balanced('{','}'); $$ = new_node("fragment"); Setattr($$,"value",Getattr($3,"value")); Setattr($$,"type",Getattr($3,"type")); Setattr($$,"section",Getattr(p,"name")); Setattr($$,"kwargs",nextSibling(p)); Delitem(scanner_ccode,0); Delitem(scanner_ccode,DOH_END); code = Copy(scanner_ccode); Setattr($$,"code",code); Delete(code); } | FRAGMENT LPAREN fname RPAREN SEMI { $$ = new_node("fragment"); Setattr($$,"value",Getattr($3,"value")); Setattr($$,"type",Getattr($3,"type")); Setattr($$,"emitonly","1"); } ; /* ------------------------------------------------------------ %includefile(option1="xyz", ...) "filename" [ declarations ] %importfile(option1="xyz", ...) "filename" [ declarations ] ------------------------------------------------------------ */ include_directive: includetype options string BEGINFILE { $1.filename = Copy(cparse_file); $1.line = cparse_line; scanner_set_location(NewString($3),1); if ($2) { String *maininput = Getattr($2, "maininput"); if (maininput) scanner_set_main_input_file(NewString(maininput)); } } interface ENDOFFILE { String *mname = 0; $$ = $6; scanner_set_location($1.filename,$1.line+1); if (strcmp($1.type,"include") == 0) set_nodeType($$,"include"); if (strcmp($1.type,"import") == 0) { mname = $2 ? Getattr($2,"module") : 0; set_nodeType($$,"import"); if (import_mode) --import_mode; } Setattr($$,"name",$3); /* Search for the module (if any) */ { Node *n = firstChild($$); while (n) { if (Strcmp(nodeType(n),"module") == 0) { if (mname) { Setattr(n,"name", mname); mname = 0; } Setattr($$,"module",Getattr(n,"name")); break; } n = nextSibling(n); } if (mname) { /* There is no module node in the import node, ie, you imported a .h file directly. We are forced then to create a new import node with a module node. */ Node *nint = new_node("import"); Node *mnode = new_node("module"); Setattr(mnode,"name", mname); appendChild(nint,mnode); Delete(mnode); appendChild(nint,firstChild($$)); $$ = nint; Setattr($$,"module",mname); } } Setattr($$,"options",$2); } ; includetype : INCLUDE { $$.type = "include"; } | IMPORT { $$.type = "import"; ++import_mode;} ; /* ------------------------------------------------------------ %inline %{ ... %} ------------------------------------------------------------ */ inline_directive : INLINE HBLOCK { String *cpps; if (Namespaceprefix) { Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n"); $$ = 0; } else { $$ = new_node("insert"); Setattr($$,"code",$2); /* Need to run through the preprocessor */ Seek($2,0,SEEK_SET); Setline($2,cparse_start_line); Setfile($2,cparse_file); cpps = Preprocessor_parse($2); start_inline(Char(cpps), cparse_start_line); Delete($2); Delete(cpps); } } | INLINE LBRACE { String *cpps; int start_line = cparse_line; skip_balanced('{','}'); if (Namespaceprefix) { Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n"); $$ = 0; } else { String *code; $$ = new_node("insert"); Delitem(scanner_ccode,0); Delitem(scanner_ccode,DOH_END); code = Copy(scanner_ccode); Setattr($$,"code", code); Delete(code); cpps=Copy(scanner_ccode); start_inline(Char(cpps), start_line); Delete(cpps); } } ; /* ------------------------------------------------------------ %{ ... %} %insert(section) "filename" %insert("section") "filename" %insert(section) %{ ... %} %insert("section") %{ ... %} ------------------------------------------------------------ */ insert_directive : HBLOCK { $$ = new_node("insert"); Setattr($$,"code",$1); } | INSERT LPAREN idstring RPAREN string { String *code = NewStringEmpty(); $$ = new_node("insert"); Setattr($$,"section",$3); Setattr($$,"code",code); if (Swig_insert_file($5,code) < 0) { Swig_error(cparse_file, cparse_line, "Couldn't find '%s'.\n", $5); $$ = 0; } } | INSERT LPAREN idstring RPAREN HBLOCK { $$ = new_node("insert"); Setattr($$,"section",$3); Setattr($$,"code",$5); } | INSERT LPAREN idstring RPAREN LBRACE { String *code; skip_balanced('{','}'); $$ = new_node("insert"); Setattr($$,"section",$3); Delitem(scanner_ccode,0); Delitem(scanner_ccode,DOH_END); code = Copy(scanner_ccode); Setattr($$,"code", code); Delete(code); } ; /* ------------------------------------------------------------ %module modname %module "modname" ------------------------------------------------------------ */ module_directive: MODULE options idstring { $$ = new_node("module"); if ($2) { Setattr($$,"options",$2); if (Getattr($2,"directors")) { Wrapper_director_mode_set(1); if (!cparse_cplusplus) { Swig_error(cparse_file, cparse_line, "Directors are not supported for C code and require the -c++ option\n"); } } if (Getattr($2,"dirprot")) { Wrapper_director_protected_mode_set(1); } if (Getattr($2,"allprotected")) { Wrapper_all_protected_mode_set(1); } if (Getattr($2,"templatereduce")) { template_reduce = 1; } if (Getattr($2,"notemplatereduce")) { template_reduce = 0; } } if (!ModuleName) ModuleName = NewString($3); if (!import_mode) { /* first module included, we apply global ModuleName, which can be modify by -module */ String *mname = Copy(ModuleName); Setattr($$,"name",mname); Delete(mname); } else { /* import mode, we just pass the idstring */ Setattr($$,"name",$3); } if (!module_node) module_node = $$; } ; /* ------------------------------------------------------------ %name(newname) declaration %name("newname") declaration ------------------------------------------------------------ */ name_directive : NAME LPAREN idstring RPAREN { Swig_warning(WARN_DEPRECATED_NAME,cparse_file,cparse_line, "%%name is deprecated. Use %%rename instead.\n"); Delete(yyrename); yyrename = NewString($3); $$ = 0; } | NAME LPAREN RPAREN { Swig_warning(WARN_DEPRECATED_NAME,cparse_file,cparse_line, "%%name is deprecated. Use %%rename instead.\n"); $$ = 0; Swig_error(cparse_file,cparse_line,"Missing argument to %%name directive.\n"); } ; /* ------------------------------------------------------------ %native(scriptname) name; %native(scriptname) type name (parms); ------------------------------------------------------------ */ native_directive : NATIVE LPAREN identifier RPAREN storage_class identifier SEMI { $$ = new_node("native"); Setattr($$,"name",$3); Setattr($$,"wrap:name",$6); add_symbols($$); } | NATIVE LPAREN identifier RPAREN storage_class type declarator SEMI { if (!SwigType_isfunction($7.type)) { Swig_error(cparse_file,cparse_line,"%%native declaration '%s' is not a function.\n", $7.id); $$ = 0; } else { Delete(SwigType_pop_function($7.type)); /* Need check for function here */ SwigType_push($6,$7.type); $$ = new_node("native"); Setattr($$,"name",$3); Setattr($$,"wrap:name",$7.id); Setattr($$,"type",$6); Setattr($$,"parms",$7.parms); Setattr($$,"decl",$7.type); } add_symbols($$); } ; /* ------------------------------------------------------------ %pragma(lang) name=value %pragma(lang) name %pragma name = value %pragma name ------------------------------------------------------------ */ pragma_directive : PRAGMA pragma_lang identifier EQUAL pragma_arg { $$ = new_node("pragma"); Setattr($$,"lang",$2); Setattr($$,"name",$3); Setattr($$,"value",$5); } | PRAGMA pragma_lang identifier { $$ = new_node("pragma"); Setattr($$,"lang",$2); Setattr($$,"name",$3); } ; pragma_arg : string { $$ = NewString($1); } | HBLOCK { $$ = $1; } ; pragma_lang : LPAREN identifier RPAREN { $$ = $2; } | empty { $$ = (char *) "swig"; } ; /* ------------------------------------------------------------ %rename(newname) identifier; ------------------------------------------------------------ */ rename_directive : rename_namewarn declarator idstring SEMI { SwigType *t = $2.type; Hash *kws = NewHash(); String *fixname; fixname = feature_identifier_fix($2.id); Setattr(kws,"name",$3); if (!Len(t)) t = 0; /* Special declarator check */ if (t) { if (SwigType_isfunction(t)) { SwigType *decl = SwigType_pop_function(t); if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",fixname); if ($1) { Swig_name_rename_add(Namespaceprefix, nname,decl,kws,$2.parms); } else { Swig_name_namewarn_add(Namespaceprefix,nname,decl,kws); } Delete(nname); } else { if ($1) { Swig_name_rename_add(Namespaceprefix,(fixname),decl,kws,$2.parms); } else { Swig_name_namewarn_add(Namespaceprefix,(fixname),decl,kws); } } Delete(decl); } else if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",fixname); if ($1) { Swig_name_rename_add(Namespaceprefix,(nname),0,kws,$2.parms); } else { Swig_name_namewarn_add(Namespaceprefix,(nname),0,kws); } Delete(nname); } } else { if ($1) { Swig_name_rename_add(Namespaceprefix,(fixname),0,kws,$2.parms); } else { Swig_name_namewarn_add(Namespaceprefix,(fixname),0,kws); } } $$ = 0; scanner_clear_rename(); } | rename_namewarn LPAREN kwargs RPAREN declarator cpp_const SEMI { String *fixname; Hash *kws = $3; SwigType *t = $5.type; fixname = feature_identifier_fix($5.id); if (!Len(t)) t = 0; /* Special declarator check */ if (t) { if ($6.qualifier) SwigType_push(t,$6.qualifier); if (SwigType_isfunction(t)) { SwigType *decl = SwigType_pop_function(t); if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",fixname); if ($1) { Swig_name_rename_add(Namespaceprefix, nname,decl,kws,$5.parms); } else { Swig_name_namewarn_add(Namespaceprefix,nname,decl,kws); } Delete(nname); } else { if ($1) { Swig_name_rename_add(Namespaceprefix,(fixname),decl,kws,$5.parms); } else { Swig_name_namewarn_add(Namespaceprefix,(fixname),decl,kws); } } Delete(decl); } else if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",fixname); if ($1) { Swig_name_rename_add(Namespaceprefix,(nname),0,kws,$5.parms); } else { Swig_name_namewarn_add(Namespaceprefix,(nname),0,kws); } Delete(nname); } } else { if ($1) { Swig_name_rename_add(Namespaceprefix,(fixname),0,kws,$5.parms); } else { Swig_name_namewarn_add(Namespaceprefix,(fixname),0,kws); } } $$ = 0; scanner_clear_rename(); } | rename_namewarn LPAREN kwargs RPAREN string SEMI { if ($1) { Swig_name_rename_add(Namespaceprefix,$5,0,$3,0); } else { Swig_name_namewarn_add(Namespaceprefix,$5,0,$3); } $$ = 0; scanner_clear_rename(); } ; rename_namewarn : RENAME { $$ = 1; } | NAMEWARN { $$ = 0; }; /* ------------------------------------------------------------ Feature targeting a symbol name (non-global feature): %feature(featurename) name "val"; %feature(featurename, val) name; where "val" could instead be the other bracket types, that is, { val } or %{ val %} or indeed omitted whereupon it defaults to "1". Or, the global feature which does not target a symbol name: %feature(featurename) "val"; %feature(featurename, val); An empty val (empty string) clears the feature. Any number of feature attributes can optionally be added, for example a non-global feature with 2 attributes: %feature(featurename, attrib1="attribval1", attrib2="attribval2") name "val"; %feature(featurename, val, attrib1="attribval1", attrib2="attribval2") name; ------------------------------------------------------------ */ /* Non-global feature */ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbracesemi { String *val = $7 ? NewString($7) : NewString("1"); new_feature($3, val, 0, $5.id, $5.type, $5.parms, $6.qualifier); $$ = 0; scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum RPAREN declarator cpp_const SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, 0, $7.id, $7.type, $7.parms, $8.qualifier); $$ = 0; scanner_clear_rename(); } | FEATURE LPAREN idstring featattr RPAREN declarator cpp_const stringbracesemi { String *val = $8 ? NewString($8) : NewString("1"); new_feature($3, val, $4, $6.id, $6.type, $6.parms, $7.qualifier); $$ = 0; scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum featattr RPAREN declarator cpp_const SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, $6, $8.id, $8.type, $8.parms, $9.qualifier); $$ = 0; scanner_clear_rename(); } /* Global feature */ | FEATURE LPAREN idstring RPAREN stringbracesemi { String *val = $5 ? NewString($5) : NewString("1"); new_feature($3, val, 0, 0, 0, 0, 0); $$ = 0; scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum RPAREN SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, 0, 0, 0, 0, 0); $$ = 0; scanner_clear_rename(); } | FEATURE LPAREN idstring featattr RPAREN stringbracesemi { String *val = $6 ? NewString($6) : NewString("1"); new_feature($3, val, $4, 0, 0, 0, 0); $$ = 0; scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum featattr RPAREN SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, $6, 0, 0, 0, 0); $$ = 0; scanner_clear_rename(); } ; stringbracesemi : stringbrace { $$ = $1; } | SEMI { $$ = 0; } | PARMS LPAREN parms RPAREN SEMI { $$ = $3; } ; featattr : COMMA idstring EQUAL stringnum { $$ = NewHash(); Setattr($$,"name",$2); Setattr($$,"value",$4); } | COMMA idstring EQUAL stringnum featattr { $$ = NewHash(); Setattr($$,"name",$2); Setattr($$,"value",$4); set_nextSibling($$,$5); } ; /* %varargs() directive. */ varargs_directive : VARARGS LPAREN varargs_parms RPAREN declarator cpp_const SEMI { Parm *val; String *name; SwigType *t; if (Namespaceprefix) name = NewStringf("%s::%s", Namespaceprefix, $5.id); else name = NewString($5.id); val = $3; if ($5.parms) { Setmeta(val,"parms",$5.parms); } t = $5.type; if (!Len(t)) t = 0; if (t) { if ($6.qualifier) SwigType_push(t,$6.qualifier); if (SwigType_isfunction(t)) { SwigType *decl = SwigType_pop_function(t); if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",name); Swig_feature_set(Swig_cparse_features(), nname, decl, "feature:varargs", val, 0); Delete(nname); } else { Swig_feature_set(Swig_cparse_features(), name, decl, "feature:varargs", val, 0); } Delete(decl); } else if (SwigType_ispointer(t)) { String *nname = NewStringf("*%s",name); Swig_feature_set(Swig_cparse_features(),nname,0,"feature:varargs",val, 0); Delete(nname); } } else { Swig_feature_set(Swig_cparse_features(),name,0,"feature:varargs",val, 0); } Delete(name); $$ = 0; }; varargs_parms : parms { $$ = $1; } | NUM_INT COMMA parm { int i; int n; Parm *p; n = atoi(Char($1.val)); if (n <= 0) { Swig_error(cparse_file, cparse_line,"Argument count in %%varargs must be positive.\n"); $$ = 0; } else { String *name = Getattr($3, "name"); $$ = Copy($3); if (name) Setattr($$, "name", NewStringf("%s%d", name, n)); for (i = 1; i < n; i++) { p = Copy($3); name = Getattr(p, "name"); if (name) Setattr(p, "name", NewStringf("%s%d", name, n-i)); set_nextSibling(p,$$); Delete($$); $$ = p; } } } ; /* ------------------------------------------------------------ %typemap(method) type { ... } %typemap(method) type "..." %typemap(method) type; - typemap deletion %typemap(method) type1,type2,... = type; - typemap copy %typemap type1,type2,... = type; - typemap copy ------------------------------------------------------------ */ typemap_directive : TYPEMAP LPAREN typemap_type RPAREN tm_list stringbrace { $$ = 0; if ($3.method) { String *code = 0; $$ = new_node("typemap"); Setattr($$,"method",$3.method); if ($3.kwargs) { ParmList *kw = $3.kwargs; code = remove_block(kw, $6); Setattr($$,"kwargs", $3.kwargs); } code = code ? code : NewString($6); Setattr($$,"code", code); Delete(code); appendChild($$,$5); } } | TYPEMAP LPAREN typemap_type RPAREN tm_list SEMI { $$ = 0; if ($3.method) { $$ = new_node("typemap"); Setattr($$,"method",$3.method); appendChild($$,$5); } } | TYPEMAP LPAREN typemap_type RPAREN tm_list EQUAL typemap_parm SEMI { $$ = 0; if ($3.method) { $$ = new_node("typemapcopy"); Setattr($$,"method",$3.method); Setattr($$,"pattern", Getattr($7,"pattern")); appendChild($$,$5); } } ; /* typemap method type (lang,method) or (method) */ typemap_type : kwargs { Hash *p; String *name; p = nextSibling($1); if (p && (!Getattr(p,"value"))) { /* this is the deprecated two argument typemap form */ Swig_warning(WARN_DEPRECATED_TYPEMAP_LANG,cparse_file, cparse_line, "Specifying the language name in %%typemap is deprecated - use #ifdef SWIG instead.\n"); /* two argument typemap form */ name = Getattr($1,"name"); if (!name || (Strcmp(name,typemap_lang))) { $$.method = 0; $$.kwargs = 0; } else { $$.method = Getattr(p,"name"); $$.kwargs = nextSibling(p); } } else { /* one-argument typemap-form */ $$.method = Getattr($1,"name"); $$.kwargs = p; } } ; tm_list : typemap_parm tm_tail { $$ = $1; set_nextSibling($$,$2); } ; tm_tail : COMMA typemap_parm tm_tail { $$ = $2; set_nextSibling($$,$3); } | empty { $$ = 0;} ; typemap_parm : type typemap_parameter_declarator { Parm *parm; SwigType_push($1,$2.type); $$ = new_node("typemapitem"); parm = NewParmWithoutFileLineInfo($1,$2.id); Setattr($$,"pattern",parm); Setattr($$,"parms", $2.parms); Delete(parm); /* $$ = NewParmWithoutFileLineInfo($1,$2.id); Setattr($$,"parms",$2.parms); */ } | LPAREN parms RPAREN { $$ = new_node("typemapitem"); Setattr($$,"pattern",$2); /* Setattr($$,"multitype",$2); */ } | LPAREN parms RPAREN LPAREN parms RPAREN { $$ = new_node("typemapitem"); Setattr($$,"pattern", $2); /* Setattr($$,"multitype",$2); */ Setattr($$,"parms",$5); } ; /* ------------------------------------------------------------ %types(parmlist); %types(parmlist) %{ ... %} ------------------------------------------------------------ */ types_directive : TYPES LPAREN parms RPAREN stringbracesemi { $$ = new_node("types"); Setattr($$,"parms",$3); if ($5) Setattr($$,"convcode",NewString($5)); } ; /* ------------------------------------------------------------ %template(name) tname; ------------------------------------------------------------ */ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN valparms GREATERTHAN SEMI { Parm *p, *tp; Node *n; Symtab *tscope = 0; int specialized = 0; int variadic = 0; $$ = 0; tscope = Swig_symbol_current(); /* Get the current scope */ /* If the class name is qualified, we need to create or lookup namespace entries */ if (!inclass) { $5 = resolve_create_node_scope($5); } /* We use the new namespace entry 'nscope' only to emit the template node. The template parameters are resolved in the current 'tscope'. This is closer to the C++ (typedef) behavior. */ n = Swig_cparse_template_locate($5,$7,tscope); /* Patch the argument types to respect namespaces */ p = $7; while (p) { SwigType *value = Getattr(p,"value"); if (!value) { SwigType *ty = Getattr(p,"type"); if (ty) { SwigType *rty = 0; int reduce = template_reduce; if (reduce || !SwigType_ispointer(ty)) { rty = Swig_symbol_typedef_reduce(ty,tscope); if (!reduce) reduce = SwigType_ispointer(rty); } ty = reduce ? Swig_symbol_type_qualify(rty,tscope) : Swig_symbol_type_qualify(ty,tscope); Setattr(p,"type",ty); Delete(ty); Delete(rty); } } else { value = Swig_symbol_type_qualify(value,tscope); Setattr(p,"value",value); Delete(value); } p = nextSibling(p); } /* Look for the template */ { Node *nn = n; Node *linklistend = 0; while (nn) { Node *templnode = 0; if (Strcmp(nodeType(nn),"template") == 0) { int nnisclass = (Strcmp(Getattr(nn,"templatetype"),"class") == 0); /* if not a templated class it is a templated function */ Parm *tparms = Getattr(nn,"templateparms"); if (!tparms) { specialized = 1; } else if (Getattr(tparms,"variadic") && strncmp(Char(Getattr(tparms,"variadic")), "1", 1)==0) { variadic = 1; } if (nnisclass && !variadic && !specialized && (ParmList_len($7) > ParmList_len(tparms))) { Swig_error(cparse_file, cparse_line, "Too many template parameters. Maximum of %d.\n", ParmList_len(tparms)); } else if (nnisclass && !specialized && ((ParmList_len($7) < (ParmList_numrequired(tparms) - (variadic?1:0))))) { /* Variadic parameter is optional */ Swig_error(cparse_file, cparse_line, "Not enough template parameters specified. %d required.\n", (ParmList_numrequired(tparms)-(variadic?1:0)) ); } else if (!nnisclass && ((ParmList_len($7) != ParmList_len(tparms)))) { /* must be an overloaded templated method - ignore it as it is overloaded with a different number of template parameters */ nn = Getattr(nn,"sym:nextSibling"); /* repeat for overloaded templated functions */ continue; } else { String *tname = Copy($5); int def_supplied = 0; /* Expand the template */ Node *templ = Swig_symbol_clookup($5,0); Parm *targs = templ ? Getattr(templ,"templateparms") : 0; ParmList *temparms; if (specialized) temparms = CopyParmList($7); else temparms = CopyParmList(tparms); /* Create typedef's and arguments */ p = $7; tp = temparms; if (!p && ParmList_len(p) != ParmList_len(temparms)) { /* we have no template parameters supplied in %template for a template that has default args*/ p = tp; def_supplied = 1; } while (p) { String *value = Getattr(p,"value"); if (def_supplied) { Setattr(p,"default","1"); } if (value) { Setattr(tp,"value",value); } else { SwigType *ty = Getattr(p,"type"); if (ty) { Setattr(tp,"type",ty); } Delattr(tp,"value"); } /* fix default arg values */ if (targs) { Parm *pi = temparms; Parm *ti = targs; String *tv = Getattr(tp,"value"); if (!tv) tv = Getattr(tp,"type"); while(pi != tp && ti && pi) { String *name = Getattr(ti,"name"); String *value = Getattr(pi,"value"); if (!value) value = Getattr(pi,"type"); Replaceid(tv, name, value); pi = nextSibling(pi); ti = nextSibling(ti); } } p = nextSibling(p); tp = nextSibling(tp); if (!p && tp) { p = tp; def_supplied = 1; } else if (p && !tp) { /* Variadic template - tp < p */ SWIG_WARN_NODE_BEGIN(nn); Swig_warning(WARN_CPP11_VARIADIC_TEMPLATE,cparse_file, cparse_line,"Only the first variadic template argument is currently supported.\n"); SWIG_WARN_NODE_END(nn); break; } } templnode = copy_node(nn); update_nested_classes(templnode); /* update classes nested withing template */ /* We need to set the node name based on name used to instantiate */ Setattr(templnode,"name",tname); Delete(tname); if (!specialized) { Delattr(templnode,"sym:typename"); } else { Setattr(templnode,"sym:typename","1"); } /* for now, nested %template is allowed only in the same scope as the template declaration */ if ($3 && !(nnisclass && ((currentOuterClass && (currentOuterClass != Getattr(nn, "nested:outer"))) ||(extendmode && current_class && (current_class != Getattr(nn, "nested:outer")))))) { /* Comment this out for 1.3.28. We need to re-enable it later but first we need to move %ignore from using %rename to use %feature(ignore). String *symname = Swig_name_make(templnode,0,$3,0,0); */ String *symname = $3; Swig_cparse_template_expand(templnode,symname,temparms,tscope); Setattr(templnode,"sym:name",symname); } else { static int cnt = 0; String *nname = NewStringf("__dummy_%d__", cnt++); Swig_cparse_template_expand(templnode,nname,temparms,tscope); Setattr(templnode,"sym:name",nname); Delete(nname); Setattr(templnode,"feature:onlychildren", "typemap,typemapitem,typemapcopy,typedef,types,fragment"); if ($3) { Swig_warning(WARN_PARSE_NESTED_TEMPLATE, cparse_file, cparse_line, "Named nested template instantiations not supported. Processing as if no name was given to %%template().\n"); } } Delattr(templnode,"templatetype"); Setattr(templnode,"template",nn); Setfile(templnode,cparse_file); Setline(templnode,cparse_line); Delete(temparms); if (currentOuterClass) { SetFlag(templnode, "nested"); Setattr(templnode, "nested:outer", currentOuterClass); } add_symbols_copy(templnode); if (Strcmp(nodeType(templnode),"class") == 0) { /* Identify pure abstract methods */ Setattr(templnode,"abstracts", pure_abstracts(firstChild(templnode))); /* Set up inheritance in symbol table */ { Symtab *csyms; List *baselist = Getattr(templnode,"baselist"); csyms = Swig_symbol_current(); Swig_symbol_setscope(Getattr(templnode,"symtab")); if (baselist) { List *bases = Swig_make_inherit_list(Getattr(templnode,"name"),baselist, Namespaceprefix); if (bases) { Iterator s; for (s = First(bases); s.item; s = Next(s)) { Symtab *st = Getattr(s.item,"symtab"); if (st) { Setfile(st,Getfile(s.item)); Setline(st,Getline(s.item)); Swig_symbol_inherit(st); } } Delete(bases); } } Swig_symbol_setscope(csyms); } /* Merge in %extend methods for this class */ /* !!! This may be broken. We may have to add the %extend methods at the beginning of the class */ { String *stmp = 0; String *clsname; Node *am; if (Namespaceprefix) { clsname = stmp = NewStringf("%s::%s", Namespaceprefix, Getattr(templnode,"name")); } else { clsname = Getattr(templnode,"name"); } am = Getattr(Swig_extend_hash(),clsname); if (am) { Symtab *st = Swig_symbol_current(); Swig_symbol_setscope(Getattr(templnode,"symtab")); /* Printf(stdout,"%s: %s %p %p\n", Getattr(templnode,"name"), clsname, Swig_symbol_current(), Getattr(templnode,"symtab")); */ Swig_extend_merge(templnode,am); Swig_symbol_setscope(st); Swig_extend_append_previous(templnode,am); Delattr(Swig_extend_hash(),clsname); } if (stmp) Delete(stmp); } /* Add to classes hash */ if (!classes) classes = NewHash(); if (Namespaceprefix) { String *temp = NewStringf("%s::%s", Namespaceprefix, Getattr(templnode,"name")); Setattr(classes,temp,templnode); Delete(temp); } else { String *qs = Swig_symbol_qualifiedscopename(templnode); Setattr(classes, qs,templnode); Delete(qs); } } } /* all the overloaded templated functions are added into a linked list */ if (nscope_inner) { /* non-global namespace */ if (templnode) { appendChild(nscope_inner,templnode); Delete(templnode); if (nscope) $$ = nscope; } } else { /* global namespace */ if (!linklistend) { $$ = templnode; } else { set_nextSibling(linklistend,templnode); Delete(templnode); } linklistend = templnode; } } nn = Getattr(nn,"sym:nextSibling"); /* repeat for overloaded templated functions. If a templated class there will never be a sibling. */ } } Swig_symbol_setscope(tscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } ; /* ------------------------------------------------------------ %warn "text" %warn(no) ------------------------------------------------------------ */ warn_directive : WARN string { Swig_warning(0,cparse_file, cparse_line,"%s\n", $2); $$ = 0; } ; /* ====================================================================== * C Parsing * ====================================================================== */ c_declaration : c_decl { $$ = $1; if ($$) { add_symbols($$); default_arguments($$); } } | c_enum_decl { $$ = $1; } | c_enum_forward_decl { $$ = $1; } /* An extern C type declaration, disable cparse_cplusplus if needed. */ | EXTERN string LBRACE { if (Strcmp($2,"C") == 0) { cparse_externc = 1; } } interface RBRACE { cparse_externc = 0; if (Strcmp($2,"C") == 0) { Node *n = firstChild($5); $$ = new_node("extern"); Setattr($$,"name",$2); appendChild($$,n); while (n) { SwigType *decl = Getattr(n,"decl"); if (SwigType_isfunction(decl) && !Equal(Getattr(n, "storage"), "typedef")) { Setattr(n,"storage","externc"); } n = nextSibling(n); } } else { Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2); $$ = new_node("extern"); Setattr($$,"name",$2); appendChild($$,firstChild($5)); } } | cpp_lambda_decl { $$ = $1; SWIG_WARN_NODE_BEGIN($$); Swig_warning(WARN_CPP11_LAMBDA, cparse_file, cparse_line, "Lambda expressions and closures are not fully supported yet.\n"); SWIG_WARN_NODE_END($$); } | USING idcolon EQUAL { skip_decl(); $$ = new_node("using"); Setattr($$,"name",$2); add_symbols($$); SWIG_WARN_NODE_BEGIN($$); Swig_warning(WARN_CPP11_ALIAS_DECLARATION, cparse_file, cparse_line, "The 'using' keyword in type aliasing is not fully supported yet.\n"); SWIG_WARN_NODE_END($$); $$ = 0; /* TODO - ignored for now */ } | TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL identifier { skip_decl(); $$ = new_node("using"); Setattr($$,"uname",$8); Setattr($$,"name",$6); add_symbols($$); SWIG_WARN_NODE_BEGIN($$); Swig_warning(WARN_CPP11_ALIAS_TEMPLATE, cparse_file, cparse_line, "The 'using' keyword in template aliasing is not fully supported yet.\n"); SWIG_WARN_NODE_END($$); } ; /* ------------------------------------------------------------ A C global declaration of some kind (may be variable, function, typedef, etc.) ------------------------------------------------------------ */ c_decl : storage_class type declarator initializer c_decl_tail { $$ = new_node("cdecl"); if ($4.qualifier) SwigType_push($3.type,$4.qualifier); Setattr($$,"type",$2); Setattr($$,"storage",$1); Setattr($$,"name",$3.id); Setattr($$,"decl",$3.type); Setattr($$,"parms",$3.parms); Setattr($$,"value",$4.val); Setattr($$,"throws",$4.throws); Setattr($$,"throw",$4.throwf); Setattr($$,"noexcept",$4.nexcept); if (!$5) { if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); Delete(code); } } else { Node *n = $5; /* Inherit attributes */ while (n) { String *type = Copy($2); Setattr(n,"type",type); Setattr(n,"storage",$1); n = nextSibling(n); Delete(type); } } if ($4.bitfield) { Setattr($$,"bitfield", $4.bitfield); } /* Look for "::" declarations (ignored) */ if (Strstr($3.id,"::")) { /* This is a special case. If the scope name of the declaration exactly matches that of the declaration, then we will allow it. Otherwise, delete. */ String *p = Swig_scopename_prefix($3.id); if (p) { if ((Namespaceprefix && Strcmp(p,Namespaceprefix) == 0) || (inclass && Strcmp(p,Classprefix) == 0)) { String *lstr = Swig_scopename_last($3.id); Setattr($$,"name",lstr); Delete(lstr); set_nextSibling($$,$5); } else { Delete($$); $$ = $5; } Delete(p); } else { Delete($$); $$ = $5; } } else { set_nextSibling($$,$5); } } /* Alternate function syntax introduced in C++11: auto funcName(int x, int y) -> int; */ | storage_class AUTO declarator ARROW cpp_alternate_rettype initializer c_decl_tail { $$ = new_node("cdecl"); if ($6.qualifier) SwigType_push($3.type,$6.qualifier); Setattr($$,"type",$5); Setattr($$,"storage",$1); Setattr($$,"name",$3.id); Setattr($$,"decl",$3.type); Setattr($$,"parms",$3.parms); Setattr($$,"value",$6.val); Setattr($$,"throws",$6.throws); Setattr($$,"throw",$6.throwf); Setattr($$,"noexcept",$6.nexcept); if (!$7) { if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); Delete(code); } } else { Node *n = $7; while (n) { String *type = Copy($5); Setattr(n,"type",type); Setattr(n,"storage",$1); n = nextSibling(n); Delete(type); } } if ($6.bitfield) { Setattr($$,"bitfield", $6.bitfield); } if (Strstr($3.id,"::")) { String *p = Swig_scopename_prefix($3.id); if (p) { if ((Namespaceprefix && Strcmp(p,Namespaceprefix) == 0) || (inclass && Strcmp(p,Classprefix) == 0)) { String *lstr = Swig_scopename_last($3.id); Setattr($$,"name",lstr); Delete(lstr); set_nextSibling($$,$7); } else { Delete($$); $$ = $7; } Delete(p); } else { Delete($$); $$ = $7; } } else { set_nextSibling($$,$7); } } ; /* Allow lists of variables and functions to be built up */ c_decl_tail : SEMI { $$ = 0; Clear(scanner_ccode); } | COMMA declarator initializer c_decl_tail { $$ = new_node("cdecl"); if ($3.qualifier) SwigType_push($2.type,$3.qualifier); Setattr($$,"name",$2.id); Setattr($$,"decl",$2.type); Setattr($$,"parms",$2.parms); Setattr($$,"value",$3.val); Setattr($$,"throws",$3.throws); Setattr($$,"throw",$3.throwf); Setattr($$,"noexcept",$3.nexcept); if ($3.bitfield) { Setattr($$,"bitfield", $3.bitfield); } if (!$4) { if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); Delete(code); } } else { set_nextSibling($$,$4); } } | LBRACE { skip_balanced('{','}'); $$ = 0; } ; initializer : def_args { $$ = $1; $$.qualifier = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } | type_qualifier def_args { $$ = $2; $$.qualifier = $1; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } | exception_specification def_args { $$ = $2; $$.qualifier = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } | type_qualifier exception_specification def_args { $$ = $3; $$.qualifier = $1; $$.throws = $2.throws; $$.throwf = $2.throwf; $$.nexcept = $2.nexcept; } ; cpp_alternate_rettype : primitive_type { $$ = $1; } | TYPE_BOOL { $$ = $1; } | TYPE_VOID { $$ = $1; } | TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); } | TYPE_RAW { $$ = $1; } | idcolon { $$ = $1; } | decltype { $$ = $1; } ; /* ------------------------------------------------------------ Lambda functions and expressions, such as: auto myFunc = [] { return something; }; auto myFunc = [](int x, int y) { return x+y; }; auto myFunc = [](int x, int y) -> int { return x+y; }; auto myFunc = [](int x, int y) throw() -> int { return x+y; }; auto six = [](int x, int y) { return x+y; }(4, 2); ------------------------------------------------------------ */ cpp_lambda_decl : storage_class AUTO idcolon EQUAL lambda_introducer LPAREN parms RPAREN cpp_const lambda_body lambda_tail { $$ = new_node("lambda"); Setattr($$,"name",$3); add_symbols($$); } | storage_class AUTO idcolon EQUAL lambda_introducer LPAREN parms RPAREN cpp_const ARROW type lambda_body lambda_tail { $$ = new_node("lambda"); Setattr($$,"name",$3); add_symbols($$); } | storage_class AUTO idcolon EQUAL lambda_introducer lambda_body lambda_tail { $$ = new_node("lambda"); Setattr($$,"name",$3); add_symbols($$); } ; lambda_introducer : LBRACKET { skip_balanced('[',']'); $$ = 0; } ; lambda_body : LBRACE { skip_balanced('{','}'); $$ = 0; } lambda_tail : SEMI { $$ = 0; } | LPAREN { skip_balanced('(',')'); } SEMI { $$ = 0; } ; /* ------------------------------------------------------------ enum or enum class ------------------------------------------------------------ */ c_enum_key : ENUM { $$ = (char *)"enum"; } | ENUM CLASS { $$ = (char *)"enum class"; } | ENUM STRUCT { $$ = (char *)"enum struct"; } ; /* ------------------------------------------------------------ base enum type (eg. unsigned short) ------------------------------------------------------------ */ c_enum_inherit : COLON type_right { $$ = $2; } | empty { $$ = 0; } ; /* ------------------------------------------------------------ enum [class] Name; enum [class] Name [: base_type]; ------------------------------------------------------------ */ c_enum_forward_decl : storage_class c_enum_key ename c_enum_inherit SEMI { SwigType *ty = 0; int scopedenum = $3 && !Equal($2, "enum"); $$ = new_node("enumforward"); ty = NewStringf("enum %s", $3); Setattr($$,"enumkey",$2); if (scopedenum) SetFlag($$, "scopedenum"); Setattr($$,"name",$3); Setattr($$,"inherit",$4); Setattr($$,"type",ty); Setattr($$,"sym:weak", "1"); add_symbols($$); } ; /* ------------------------------------------------------------ enum [class] Name [: base_type] { ... }; or enum [class] Name [: base_type] { ... } MyEnum [= ...]; * ------------------------------------------------------------ */ c_enum_decl : storage_class c_enum_key ename c_enum_inherit LBRACE enumlist RBRACE SEMI { SwigType *ty = 0; int scopedenum = $3 && !Equal($2, "enum"); $$ = new_node("enum"); ty = NewStringf("enum %s", $3); Setattr($$,"enumkey",$2); if (scopedenum) SetFlag($$, "scopedenum"); Setattr($$,"name",$3); Setattr($$,"inherit",$4); Setattr($$,"type",ty); appendChild($$,$6); add_symbols($$); /* Add to tag space */ if (scopedenum) { Swig_symbol_newscope(); Swig_symbol_setscopename($3); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } add_symbols($6); /* Add enum values to appropriate enum or enum class scope */ if (scopedenum) { Setattr($$,"symtab", Swig_symbol_popscope()); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } } | storage_class c_enum_key ename c_enum_inherit LBRACE enumlist RBRACE declarator initializer c_decl_tail { Node *n; SwigType *ty = 0; String *unnamed = 0; int unnamedinstance = 0; int scopedenum = $3 && !Equal($2, "enum"); $$ = new_node("enum"); Setattr($$,"enumkey",$2); if (scopedenum) SetFlag($$, "scopedenum"); Setattr($$,"inherit",$4); if ($3) { Setattr($$,"name",$3); ty = NewStringf("enum %s", $3); } else if ($8.id) { unnamed = make_unnamed(); ty = NewStringf("enum %s", unnamed); Setattr($$,"unnamed",unnamed); /* name is not set for unnamed enum instances, e.g. enum { foo } Instance; */ if ($1 && Cmp($1,"typedef") == 0) { Setattr($$,"name",$8.id); } else { unnamedinstance = 1; } Setattr($$,"storage",$1); } if ($8.id && Cmp($1,"typedef") == 0) { Setattr($$,"tdname",$8.id); Setattr($$,"allows_typedef","1"); } appendChild($$,$6); n = new_node("cdecl"); Setattr(n,"type",ty); Setattr(n,"name",$8.id); Setattr(n,"storage",$1); Setattr(n,"decl",$8.type); Setattr(n,"parms",$8.parms); Setattr(n,"unnamed",unnamed); if (unnamedinstance) { SwigType *cty = NewString("enum "); Setattr($$,"type",cty); SetFlag($$,"unnamedinstance"); SetFlag(n,"unnamedinstance"); Delete(cty); } if ($10) { Node *p = $10; set_nextSibling(n,p); while (p) { SwigType *cty = Copy(ty); Setattr(p,"type",cty); Setattr(p,"unnamed",unnamed); Setattr(p,"storage",$1); Delete(cty); p = nextSibling(p); } } else { if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr(n,"code",code); Delete(code); } } /* Ensure that typedef enum ABC {foo} XYZ; uses XYZ for sym:name, like structs. * Note that class_rename/yyrename are bit of a mess so used this simple approach to change the name. */ if ($8.id && $3 && Cmp($1,"typedef") == 0) { String *name = NewString($8.id); Setattr($$, "parser:makename", name); Delete(name); } add_symbols($$); /* Add enum to tag space */ set_nextSibling($$,n); Delete(n); if (scopedenum) { Swig_symbol_newscope(); Swig_symbol_setscopename($3); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } add_symbols($6); /* Add enum values to appropriate enum or enum class scope */ if (scopedenum) { Setattr($$,"symtab", Swig_symbol_popscope()); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } add_symbols(n); Delete(unnamed); } ; c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { /* This is a sick hack. If the ctor_end has parameters, and the parms parameter only has 1 parameter, this could be a declaration of the form: type (id)(parms) Otherwise it's an error. */ int err = 0; $$ = 0; if ((ParmList_len($4) == 1) && (!Swig_scopename_check($2))) { SwigType *ty = Getattr($4,"type"); String *name = Getattr($4,"name"); err = 1; if (!name) { $$ = new_node("cdecl"); Setattr($$,"type",$2); Setattr($$,"storage",$1); Setattr($$,"name",ty); if ($6.have_parms) { SwigType *decl = NewStringEmpty(); SwigType_add_function(decl,$6.parms); Setattr($$,"decl",decl); Setattr($$,"parms",$6.parms); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); Delete(code); } } if ($6.defarg) { Setattr($$,"value",$6.defarg); } Setattr($$,"throws",$6.throws); Setattr($$,"throw",$6.throwf); Setattr($$,"noexcept",$6.nexcept); err = 0; } } if (err) { Swig_error(cparse_file,cparse_line,"Syntax error in input(2).\n"); exit(1); } } ; /* ====================================================================== * C++ Support * ====================================================================== */ cpp_declaration : cpp_class_decl { $$ = $1; } | cpp_forward_class_decl { $$ = $1; } | cpp_template_decl { $$ = $1; } | cpp_using_decl { $$ = $1; } | cpp_namespace_decl { $$ = $1; } | cpp_catch_decl { $$ = 0; } ; /* A simple class/struct/union definition */ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { String *prefix; List *bases = 0; Node *scope = 0; String *code; $$ = new_node("class"); Setline($$,cparse_start_line); Setattr($$,"kind",$2); if ($4) { Setattr($$,"baselist", Getattr($4,"public")); Setattr($$,"protectedbaselist", Getattr($4,"protected")); Setattr($$,"privatebaselist", Getattr($4,"private")); } Setattr($$,"allows_typedef","1"); /* preserve the current scope */ Setattr($$,"prev_symtab",Swig_symbol_current()); /* If the class name is qualified. We need to create or lookup namespace/scope entries */ scope = resolve_create_node_scope($3); /* save nscope_inner to the class - it may be overwritten in nested classes*/ Setattr($$, "nested:innerscope", nscope_inner); Setattr($$, "nested:nscope", nscope); Setfile(scope,cparse_file); Setline(scope,cparse_line); $3 = scope; Setattr($$,"name",$3); if (currentOuterClass) { SetFlag($$, "nested"); Setattr($$, "nested:outer", currentOuterClass); set_access_mode($$); } Swig_features_get(Swig_cparse_features(), Namespaceprefix, Getattr($$, "name"), 0, $$); /* save yyrename to the class attribute, to be used later in add_symbols()*/ Setattr($$, "class_rename", make_name($$, $3, 0)); Setattr($$, "Classprefix", $3); Classprefix = NewString($3); /* Deal with inheritance */ if ($4) bases = Swig_make_inherit_list($3,Getattr($4,"public"),Namespaceprefix); prefix = SwigType_istemplate_templateprefix($3); if (prefix) { String *fbase, *tbase; if (Namespaceprefix) { fbase = NewStringf("%s::%s", Namespaceprefix,$3); tbase = NewStringf("%s::%s", Namespaceprefix, prefix); } else { fbase = Copy($3); tbase = Copy(prefix); } Swig_name_inherit(tbase,fbase); Delete(fbase); Delete(tbase); } if (strcmp($2,"class") == 0) { cplus_mode = CPLUS_PRIVATE; } else { cplus_mode = CPLUS_PUBLIC; } if (!cparse_cplusplus) { set_scope_to_global(); } Swig_symbol_newscope(); Swig_symbol_setscopename($3); Swig_inherit_base_symbols(bases); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); cparse_start_line = cparse_line; /* If there are active template parameters, we need to make sure they are placed in the class symbol table so we can catch shadows */ if (template_parameters) { Parm *tp = template_parameters; while(tp) { String *tpname = Copy(Getattr(tp,"name")); Node *tn = new_node("templateparm"); Setattr(tn,"name",tpname); Swig_symbol_cadd(tpname,tn); tp = nextSibling(tp); Delete(tpname); } } Delete(prefix); inclass = 1; currentOuterClass = $$; if (cparse_cplusplusout) { /* save the structure declaration to declare it in global scope for C++ to see */ code = get_raw_text_balanced('{', '}'); Setattr($$, "code", code); Delete(code); } } cpp_members RBRACE cpp_opt_declarators { Node *p; SwigType *ty; Symtab *cscope; Node *am = 0; String *scpname = 0; (void) $6; $$ = currentOuterClass; currentOuterClass = Getattr($$, "nested:outer"); nscope_inner = Getattr($$, "nested:innerscope"); nscope = Getattr($$, "nested:nscope"); Delattr($$, "nested:innerscope"); Delattr($$, "nested:nscope"); if (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0) /* actual parent class for this class */ Setattr($$, "nested:outer", nscope_inner); if (!currentOuterClass) inclass = 0; cscope = Getattr($$, "prev_symtab"); Delattr($$, "prev_symtab"); /* Check for pure-abstract class */ Setattr($$,"abstracts", pure_abstracts($7)); /* This bit of code merges in a previously defined %extend directive (if any) */ { String *clsname = Swig_symbol_qualifiedscopename(0); am = Getattr(Swig_extend_hash(), clsname); if (am) { Swig_extend_merge($$, am); Delattr(Swig_extend_hash(), clsname); } Delete(clsname); } if (!classes) classes = NewHash(); scpname = Swig_symbol_qualifiedscopename(0); Setattr(classes, scpname, $$); appendChild($$, $7); if (am) Swig_extend_append_previous($$, am); p = $9; if (p && !nscope_inner) { if (!cparse_cplusplus && currentOuterClass) appendChild(currentOuterClass, p); else appendSibling($$, p); } if (nscope_inner) { ty = NewString(scpname); /* if the class is declared out of scope, let the declarator use fully qualified type*/ } else if (cparse_cplusplus && !cparse_externc) { ty = NewString($3); } else { ty = NewStringf("%s %s", $2, $3); } while (p) { Setattr(p, "storage", $1); Setattr(p, "type" ,ty); if (!cparse_cplusplus && currentOuterClass && (!Getattr(currentOuterClass, "name"))) { SetFlag(p, "hasconsttype"); SetFlag(p, "feature:immutable"); } p = nextSibling(p); } if ($9 && Cmp($1,"typedef") == 0) add_typedef_name($$, $9, $3, cscope, scpname); Delete(scpname); if (cplus_mode != CPLUS_PUBLIC) { /* we 'open' the class at the end, to allow %template to add new members */ Node *pa = new_node("access"); Setattr(pa, "kind", "public"); cplus_mode = CPLUS_PUBLIC; appendChild($$, pa); Delete(pa); } if (currentOuterClass) restore_access_mode($$); Setattr($$, "symtab", Swig_symbol_popscope()); Classprefix = Getattr($$, "Classprefix"); Delattr($$, "Classprefix"); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); if (cplus_mode == CPLUS_PRIVATE) { $$ = 0; /* skip private nested classes */ } else if (cparse_cplusplus && currentOuterClass && ignore_nested_classes && !GetFlag($$, "feature:flatnested")) { $$ = nested_forward_declaration($1, $2, $3, Copy($3), $9); } else if (nscope_inner) { /* this is tricky */ /* we add the declaration in the original namespace */ appendChild(nscope_inner, $$); Swig_symbol_setscope(Getattr(nscope_inner, "symtab")); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); yyrename = Copy(Getattr($$, "class_rename")); add_symbols($$); Delattr($$, "class_rename"); /* but the variable definition in the current scope */ Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols($9); if (nscope) { $$ = nscope; /* here we return recreated namespace tower instead of the class itself */ if ($9) { appendSibling($$, $9); } } else if (!SwigType_istemplate(ty) && template_parameters == 0) { /* for tempalte we need the class itself */ $$ = $9; } } else { Delete(yyrename); yyrename = 0; if (!cparse_cplusplus && currentOuterClass) { /* nested C structs go into global scope*/ Node *outer = currentOuterClass; while (Getattr(outer, "nested:outer")) outer = Getattr(outer, "nested:outer"); appendSibling(outer, $$); add_symbols($9); set_scope_to_global(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); yyrename = Copy(Getattr($$, "class_rename")); add_symbols($$); if (!cparse_cplusplusout) Delattr($$, "nested:outer"); Delattr($$, "class_rename"); $$ = 0; } else { yyrename = Copy(Getattr($$, "class_rename")); add_symbols($$); add_symbols($9); Delattr($$, "class_rename"); } } Delete(ty); Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } /* An unnamed struct, possibly with a typedef */ | storage_class cpptype inherit LBRACE { String *unnamed; String *code; unnamed = make_unnamed(); $$ = new_node("class"); Setline($$,cparse_start_line); Setattr($$,"kind",$2); if ($3) { Setattr($$,"baselist", Getattr($3,"public")); Setattr($$,"protectedbaselist", Getattr($3,"protected")); Setattr($$,"privatebaselist", Getattr($3,"private")); } Setattr($$,"storage",$1); Setattr($$,"unnamed",unnamed); Setattr($$,"allows_typedef","1"); if (currentOuterClass) { SetFlag($$, "nested"); Setattr($$, "nested:outer", currentOuterClass); set_access_mode($$); } Swig_features_get(Swig_cparse_features(), Namespaceprefix, 0, 0, $$); /* save yyrename to the class attribute, to be used later in add_symbols()*/ Setattr($$, "class_rename", make_name($$,0,0)); if (strcmp($2,"class") == 0) { cplus_mode = CPLUS_PRIVATE; } else { cplus_mode = CPLUS_PUBLIC; } Swig_symbol_newscope(); cparse_start_line = cparse_line; currentOuterClass = $$; inclass = 1; Classprefix = NewStringEmpty(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); /* save the structure declaration to make a typedef for it later*/ code = get_raw_text_balanced('{', '}'); Setattr($$, "code", code); Delete(code); } cpp_members RBRACE cpp_opt_declarators { String *unnamed; List *bases = 0; String *name = 0; Node *n; Classprefix = 0; $$ = currentOuterClass; currentOuterClass = Getattr($$, "nested:outer"); if (!currentOuterClass) inclass = 0; else restore_access_mode($$); unnamed = Getattr($$,"unnamed"); /* Check for pure-abstract class */ Setattr($$,"abstracts", pure_abstracts($6)); n = $8; if (cparse_cplusplus && currentOuterClass && ignore_nested_classes && !GetFlag($$, "feature:flatnested")) { String *name = n ? Copy(Getattr(n, "name")) : 0; $$ = nested_forward_declaration($1, $2, 0, name, n); Swig_symbol_popscope(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } else if (n) { appendSibling($$,n); /* If a proper typedef name was given, we'll use it to set the scope name */ name = try_to_find_a_name_for_unnamed_structure($1, n); if (name) { String *scpname = 0; SwigType *ty; Setattr($$,"tdname",name); Setattr($$,"name",name); Swig_symbol_setscopename(name); if ($3) bases = Swig_make_inherit_list(name,Getattr($3,"public"),Namespaceprefix); Swig_inherit_base_symbols(bases); /* If a proper name was given, we use that as the typedef, not unnamed */ Clear(unnamed); Append(unnamed, name); if (cparse_cplusplus && !cparse_externc) { ty = NewString(name); } else { ty = NewStringf("%s %s", $2,name); } while (n) { Setattr(n,"storage",$1); Setattr(n, "type", ty); if (!cparse_cplusplus && currentOuterClass && (!Getattr(currentOuterClass, "name"))) { SetFlag(n,"hasconsttype"); SetFlag(n,"feature:immutable"); } n = nextSibling(n); } n = $8; /* Check for previous extensions */ { String *clsname = Swig_symbol_qualifiedscopename(0); Node *am = Getattr(Swig_extend_hash(),clsname); if (am) { /* Merge the extension into the symbol table */ Swig_extend_merge($$,am); Swig_extend_append_previous($$,am); Delattr(Swig_extend_hash(),clsname); } Delete(clsname); } if (!classes) classes = NewHash(); scpname = Swig_symbol_qualifiedscopename(0); Setattr(classes,scpname,$$); Delete(scpname); } else { /* no suitable name was found for a struct */ Setattr($$, "nested:unnamed", Getattr(n, "name")); /* save the name of the first declarator for later use in name generation*/ while (n) { /* attach unnamed struct to the declarators, so that they would receive proper type later*/ Setattr(n, "nested:unnamedtype", $$); Setattr(n, "storage", $1); n = nextSibling(n); } n = $8; Swig_symbol_setscopename(""); } appendChild($$,$6); /* Pop the scope */ Setattr($$,"symtab",Swig_symbol_popscope()); if (name) { Delete(yyrename); yyrename = Copy(Getattr($$, "class_rename")); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols($$); add_symbols(n); Delattr($$, "class_rename"); }else if (cparse_cplusplus) $$ = 0; /* ignore unnamed structs for C++ */ Delete(unnamed); } else { /* unnamed struct w/o declarator*/ Swig_symbol_popscope(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols($6); Delete($$); $$ = $6; /* pass member list to outer class/namespace (instead of self)*/ } } ; cpp_opt_declarators : SEMI { $$ = 0; } | declarator initializer c_decl_tail { $$ = new_node("cdecl"); Setattr($$,"name",$1.id); Setattr($$,"decl",$1.type); Setattr($$,"parms",$1.parms); set_nextSibling($$,$3); } ; /* ------------------------------------------------------------ class Name; ------------------------------------------------------------ */ cpp_forward_class_decl : storage_class cpptype idcolon SEMI { if ($1 && (Strcmp($1,"friend") == 0)) { /* Ignore */ $$ = 0; } else { $$ = new_node("classforward"); Setattr($$,"kind",$2); Setattr($$,"name",$3); Setattr($$,"sym:weak", "1"); add_symbols($$); } } ; /* ------------------------------------------------------------ template<...> decl ------------------------------------------------------------ */ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { if (currentOuterClass) Setattr(currentOuterClass, "template_parameters", template_parameters); template_parameters = $3; } cpp_temp_possible { String *tname = 0; int error = 0; /* check if we get a namespace node with a class declaration, and retrieve the class */ Symtab *cscope = Swig_symbol_current(); Symtab *sti = 0; Node *ntop = $6; Node *ni = ntop; SwigType *ntype = ni ? nodeType(ni) : 0; while (ni && Strcmp(ntype,"namespace") == 0) { sti = Getattr(ni,"symtab"); ni = firstChild(ni); ntype = nodeType(ni); } if (sti) { Swig_symbol_setscope(sti); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); $6 = ni; } $$ = $6; if ($$) tname = Getattr($$,"name"); /* Check if the class is a template specialization */ if (($$) && (Strchr(tname,'<')) && (!is_operator(tname))) { /* If a specialization. Check if defined. */ Node *tempn = 0; { String *tbase = SwigType_templateprefix(tname); tempn = Swig_symbol_clookup_local(tbase,0); if (!tempn || (Strcmp(nodeType(tempn),"template") != 0)) { SWIG_WARN_NODE_BEGIN(tempn); Swig_warning(WARN_PARSE_TEMPLATE_SP_UNDEF, Getfile($$),Getline($$),"Specialization of non-template '%s'.\n", tbase); SWIG_WARN_NODE_END(tempn); tempn = 0; error = 1; } Delete(tbase); } Setattr($$,"specialization","1"); Setattr($$,"templatetype",nodeType($$)); set_nodeType($$,"template"); /* Template partial specialization */ if (tempn && ($3) && ($6)) { List *tlist; String *targs = SwigType_templateargs(tname); tlist = SwigType_parmlist(targs); /* Printf(stdout,"targs = '%s' %s\n", targs, tlist); */ if (!Getattr($$,"sym:weak")) { Setattr($$,"sym:typename","1"); } if (Len(tlist) != ParmList_len(Getattr(tempn,"templateparms"))) { Swig_error(Getfile($$),Getline($$),"Inconsistent argument count in template partial specialization. %d %d\n", Len(tlist), ParmList_len(Getattr(tempn,"templateparms"))); } else { /* This code builds the argument list for the partial template specialization. This is a little hairy, but the idea is as follows: $3 contains a list of arguments supplied for the template. For example template. tlist is a list of the specialization arguments--which may be different. For example class. tp is a copy of the arguments in the original template definition. The patching algorithm walks through the list of supplied arguments ($3), finds the position in the specialization arguments (tlist), and then patches the name in the argument list of the original template. */ { String *pn; Parm *p, *p1; int i, nargs; Parm *tp = CopyParmList(Getattr(tempn,"templateparms")); nargs = Len(tlist); p = $3; while (p) { for (i = 0; i < nargs; i++){ pn = Getattr(p,"name"); if (Strcmp(pn,SwigType_base(Getitem(tlist,i))) == 0) { int j; Parm *p1 = tp; for (j = 0; j < i; j++) { p1 = nextSibling(p1); } Setattr(p1,"name",pn); Setattr(p1,"partialarg","1"); } } p = nextSibling(p); } p1 = tp; i = 0; while (p1) { if (!Getattr(p1,"partialarg")) { Delattr(p1,"name"); Setattr(p1,"type", Getitem(tlist,i)); } i++; p1 = nextSibling(p1); } Setattr($$,"templateparms",tp); Delete(tp); } #if 0 /* Patch the parameter list */ if (tempn) { Parm *p,*p1; ParmList *tp = CopyParmList(Getattr(tempn,"templateparms")); p = $3; p1 = tp; while (p && p1) { String *pn = Getattr(p,"name"); Printf(stdout,"pn = '%s'\n", pn); if (pn) Setattr(p1,"name",pn); else Delattr(p1,"name"); pn = Getattr(p,"type"); if (pn) Setattr(p1,"type",pn); p = nextSibling(p); p1 = nextSibling(p1); } Setattr($$,"templateparms",tp); Delete(tp); } else { Setattr($$,"templateparms",$3); } #endif Delattr($$,"specialization"); Setattr($$,"partialspecialization","1"); /* Create a specialized name for matching */ { Parm *p = $3; String *fname = NewString(Getattr($$,"name")); String *ffname = 0; ParmList *partialparms = 0; char tmp[32]; int i, ilen; while (p) { String *n = Getattr(p,"name"); if (!n) { p = nextSibling(p); continue; } ilen = Len(tlist); for (i = 0; i < ilen; i++) { if (Strstr(Getitem(tlist,i),n)) { sprintf(tmp,"$%d",i+1); Replaceid(fname,n,tmp); } } p = nextSibling(p); } /* Patch argument names with typedef */ { Iterator tt; Parm *parm_current = 0; List *tparms = SwigType_parmlist(fname); ffname = SwigType_templateprefix(fname); Append(ffname,"<("); for (tt = First(tparms); tt.item; ) { SwigType *rtt = Swig_symbol_typedef_reduce(tt.item,0); SwigType *ttr = Swig_symbol_type_qualify(rtt,0); Parm *newp = NewParmWithoutFileLineInfo(ttr, 0); if (partialparms) set_nextSibling(parm_current, newp); else partialparms = newp; parm_current = newp; Append(ffname,ttr); tt = Next(tt); if (tt.item) Putc(',',ffname); Delete(rtt); Delete(ttr); } Delete(tparms); Append(ffname,")>"); } { Node *new_partial = NewHash(); String *partials = Getattr(tempn,"partials"); if (!partials) { partials = NewList(); Setattr(tempn,"partials",partials); Delete(partials); } /* Printf(stdout,"partial: fname = '%s', '%s'\n", fname, Swig_symbol_typedef_reduce(fname,0)); */ Setattr(new_partial, "partialparms", partialparms); Setattr(new_partial, "templcsymname", ffname); Append(partials, new_partial); } Setattr($$,"partialargs",ffname); Swig_symbol_cadd(ffname,$$); } } Delete(tlist); Delete(targs); } else { /* An explicit template specialization */ /* add default args from primary (unspecialized) template */ String *ty = Swig_symbol_template_deftype(tname,0); String *fname = Swig_symbol_type_qualify(ty,0); Swig_symbol_cadd(fname,$$); Delete(ty); Delete(fname); } } else if ($$) { Setattr($$,"templatetype",nodeType($6)); set_nodeType($$,"template"); Setattr($$,"templateparms", $3); if (!Getattr($$,"sym:weak")) { Setattr($$,"sym:typename","1"); } add_symbols($$); default_arguments($$); /* We also place a fully parameterized version in the symbol table */ { Parm *p; String *fname = NewStringf("%s<(", Getattr($$,"name")); p = $3; while (p) { String *n = Getattr(p,"name"); if (!n) n = Getattr(p,"type"); Append(fname,n); p = nextSibling(p); if (p) Putc(',',fname); } Append(fname,")>"); Swig_symbol_cadd(fname,$$); } } $$ = ntop; Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); if (error) $$ = 0; if (currentOuterClass) template_parameters = Getattr(currentOuterClass, "template_parameters"); else template_parameters = 0; } /* Explicit template instantiation */ | TEMPLATE cpptype idcolon { Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n"); $$ = 0; } /* Explicit template instantiation without the translation unit */ | EXTERN TEMPLATE cpptype idcolon { Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n"); $$ = 0; } ; cpp_temp_possible: c_decl { $$ = $1; } | cpp_class_decl { $$ = $1; } | cpp_constructor_decl { $$ = $1; } | cpp_static_assert { $$ = $1; } | cpp_template_decl { $$ = 0; } | cpp_forward_class_decl { $$ = $1; } | cpp_conversion_operator { $$ = $1; } ; template_parms : templateparameters { /* Rip out the parameter names */ Parm *p = $1; $$ = $1; while (p) { String *name = Getattr(p,"name"); if (!name) { /* Hmmm. Maybe it's a 'class T' parameter */ char *type = Char(Getattr(p,"type")); /* Template template parameter */ if (strncmp(type,"template ",16) == 0) { type += 16; } if ((strncmp(type,"class ",6) == 0) || (strncmp(type,"typename ", 9) == 0)) { char *t = strchr(type,' '); Setattr(p,"name", t+1); } else /* Variadic template args */ if ((strncmp(type,"class... ",9) == 0) || (strncmp(type,"typename... ", 12) == 0)) { char *t = strchr(type,' '); Setattr(p,"name", t+1); Setattr(p,"variadic", "1"); } else { /* Swig_error(cparse_file, cparse_line, "Missing template parameter name\n"); $$.rparms = 0; $$.parms = 0; break; */ } } p = nextSibling(p); } } ; templateparameters : templateparameter templateparameterstail { set_nextSibling($1,$2); $$ = $1; } | empty { $$ = 0; } ; templateparameter : templcpptype { $$ = NewParmWithoutFileLineInfo(NewString($1), 0); } | parm { $$ = $1; } ; templateparameterstail : COMMA templateparameter templateparameterstail { set_nextSibling($2,$3); $$ = $2; } | empty { $$ = 0; } ; /* Namespace support */ cpp_using_decl : USING idcolon SEMI { String *uname = Swig_symbol_type_qualify($2,0); String *name = Swig_scopename_last($2); $$ = new_node("using"); Setattr($$,"uname",uname); Setattr($$,"name", name); Delete(uname); Delete(name); add_symbols($$); } | USING NAMESPACE idcolon SEMI { Node *n = Swig_symbol_clookup($3,0); if (!n) { Swig_error(cparse_file, cparse_line, "Nothing known about namespace '%s'\n", $3); $$ = 0; } else { while (Strcmp(nodeType(n),"using") == 0) { n = Getattr(n,"node"); } if (n) { if (Strcmp(nodeType(n),"namespace") == 0) { Symtab *current = Swig_symbol_current(); Symtab *symtab = Getattr(n,"symtab"); $$ = new_node("using"); Setattr($$,"node",n); Setattr($$,"namespace", $3); if (current != symtab) { Swig_symbol_inherit(symtab); } } else { Swig_error(cparse_file, cparse_line, "'%s' is not a namespace.\n", $3); $$ = 0; } } else { $$ = 0; } } } ; cpp_namespace_decl : NAMESPACE idcolon LBRACE { Hash *h; $1 = Swig_symbol_current(); h = Swig_symbol_clookup($2,0); if (h && ($1 == Getattr(h,"sym:symtab")) && (Strcmp(nodeType(h),"namespace") == 0)) { if (Getattr(h,"alias")) { h = Getattr(h,"namespace"); Swig_warning(WARN_PARSE_NAMESPACE_ALIAS, cparse_file, cparse_line, "Namespace alias '%s' not allowed here. Assuming '%s'\n", $2, Getattr(h,"name")); $2 = Getattr(h,"name"); } Swig_symbol_setscope(Getattr(h,"symtab")); } else { Swig_symbol_newscope(); Swig_symbol_setscopename($2); } Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } interface RBRACE { Node *n = $5; set_nodeType(n,"namespace"); Setattr(n,"name",$2); Setattr(n,"symtab", Swig_symbol_popscope()); Swig_symbol_setscope($1); $$ = n; Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols($$); } | NAMESPACE LBRACE { Hash *h; $1 = Swig_symbol_current(); h = Swig_symbol_clookup(" ",0); if (h && (Strcmp(nodeType(h),"namespace") == 0)) { Swig_symbol_setscope(Getattr(h,"symtab")); } else { Swig_symbol_newscope(); /* we don't use "__unnamed__", but a long 'empty' name */ Swig_symbol_setscopename(" "); } Namespaceprefix = 0; } interface RBRACE { $$ = $4; set_nodeType($$,"namespace"); Setattr($$,"unnamed","1"); Setattr($$,"symtab", Swig_symbol_popscope()); Swig_symbol_setscope($1); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols($$); } | NAMESPACE identifier EQUAL idcolon SEMI { /* Namespace alias */ Node *n; $$ = new_node("namespace"); Setattr($$,"name",$2); Setattr($$,"alias",$4); n = Swig_symbol_clookup($4,0); if (!n) { Swig_error(cparse_file, cparse_line, "Unknown namespace '%s'\n", $4); $$ = 0; } else { if (Strcmp(nodeType(n),"namespace") != 0) { Swig_error(cparse_file, cparse_line, "'%s' is not a namespace\n",$4); $$ = 0; } else { while (Getattr(n,"alias")) { n = Getattr(n,"namespace"); } Setattr($$,"namespace",n); add_symbols($$); /* Set up a scope alias */ Swig_symbol_alias($2,Getattr(n,"symtab")); } } } ; cpp_members : cpp_member cpp_members { $$ = $1; /* Insert cpp_member (including any siblings) to the front of the cpp_members linked list */ if ($$) { Node *p = $$; Node *pp =0; while (p) { pp = p; p = nextSibling(p); } set_nextSibling(pp,$2); if ($2) set_previousSibling($2, pp); } else { $$ = $2; } } | EXTEND LBRACE { extendmode = 1; if (cplus_mode != CPLUS_PUBLIC) { Swig_error(cparse_file,cparse_line,"%%extend can only be used in a public section\n"); } } cpp_members RBRACE { extendmode = 0; } cpp_members { $$ = new_node("extend"); mark_nodes_as_extend($4); appendChild($$,$4); set_nextSibling($$,$7); } | include_directive { $$ = $1; } | empty { $$ = 0;} | error { int start_line = cparse_line; skip_decl(); Swig_error(cparse_file,start_line,"Syntax error in input(3).\n"); exit(1); } cpp_members { $$ = $3; } ; /* ====================================================================== * C++ Class members * ====================================================================== */ /* A class member. May be data or a function. Static or virtual as well */ cpp_member : c_declaration { $$ = $1; } | cpp_constructor_decl { $$ = $1; if (extendmode && current_class) { String *symname; symname= make_name($$,Getattr($$,"name"), Getattr($$,"decl")); if (Strcmp(symname,Getattr($$,"name")) == 0) { /* No renaming operation. Set name to class name */ Delete(yyrename); yyrename = NewString(Getattr(current_class,"sym:name")); } else { Delete(yyrename); yyrename = symname; } } add_symbols($$); default_arguments($$); } | cpp_destructor_decl { $$ = $1; } | cpp_static_assert { $$ = $1; } | cpp_protection_decl { $$ = $1; } | cpp_swig_directive { $$ = $1; } | cpp_conversion_operator { $$ = $1; } | cpp_forward_class_decl { $$ = $1; } | cpp_class_decl { $$ = $1; } | storage_class idcolon SEMI { $$ = 0; } | cpp_using_decl { $$ = $1; } | cpp_template_decl { $$ = $1; } | cpp_catch_decl { $$ = 0; } | template_directive { $$ = $1; } | warn_directive { $$ = $1; } | anonymous_bitfield { $$ = 0; } | fragment_directive {$$ = $1; } | types_directive {$$ = $1; } | SEMI { $$ = 0; } ; /* Possibly a constructor */ /* Note: the use of 'type' is here to resolve a shift-reduce conflict. For example: typedef Foo (); typedef Foo (*ptr)(); */ cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { if (inclass || extendmode) { SwigType *decl = NewStringEmpty(); $$ = new_node("constructor"); Setattr($$,"storage",$1); Setattr($$,"name",$2); Setattr($$,"parms",$4); SwigType_add_function(decl,$4); Setattr($$,"decl",decl); Setattr($$,"throws",$6.throws); Setattr($$,"throw",$6.throwf); Setattr($$,"noexcept",$6.nexcept); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); Delete(code); } SetFlag($$,"feature:new"); if ($6.defarg) Setattr($$,"value",$6.defarg); } else { $$ = 0; } } ; /* A destructor (hopefully) */ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end { String *name = NewStringf("%s",$2); if (*(Char(name)) != '~') Insert(name,0,"~"); $$ = new_node("destructor"); Setattr($$,"name",name); Delete(name); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); Delete(code); } { String *decl = NewStringEmpty(); SwigType_add_function(decl,$4); Setattr($$,"decl",decl); Delete(decl); } Setattr($$,"throws",$6.throws); Setattr($$,"throw",$6.throwf); Setattr($$,"noexcept",$6.nexcept); if ($6.val) Setattr($$,"value",$6.val); add_symbols($$); } /* A virtual destructor */ | VIRTUAL NOT idtemplate LPAREN parms RPAREN cpp_vend { String *name; $$ = new_node("destructor"); Setattr($$,"storage","virtual"); name = NewStringf("%s",$3); if (*(Char(name)) != '~') Insert(name,0,"~"); Setattr($$,"name",name); Delete(name); Setattr($$,"throws",$7.throws); Setattr($$,"throw",$7.throwf); Setattr($$,"noexcept",$7.nexcept); if ($7.val) Setattr($$,"value",$7.val); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); Delete(code); } { String *decl = NewStringEmpty(); SwigType_add_function(decl,$5); Setattr($$,"decl",decl); Delete(decl); } add_symbols($$); } ; /* C++ type conversion operator */ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAREN cpp_vend { $$ = new_node("cdecl"); Setattr($$,"type",$3); Setattr($$,"name",$2); Setattr($$,"storage",$1); SwigType_add_function($4,$6); if ($8.qualifier) { SwigType_push($4,$8.qualifier); } Setattr($$,"decl",$4); Setattr($$,"parms",$6); Setattr($$,"conversion_operator","1"); add_symbols($$); } | storage_class COPERATOR type AND LPAREN parms RPAREN cpp_vend { SwigType *decl; $$ = new_node("cdecl"); Setattr($$,"type",$3); Setattr($$,"name",$2); Setattr($$,"storage",$1); decl = NewStringEmpty(); SwigType_add_reference(decl); SwigType_add_function(decl,$6); if ($8.qualifier) { SwigType_push(decl,$8.qualifier); } Setattr($$,"decl",decl); Setattr($$,"parms",$6); Setattr($$,"conversion_operator","1"); add_symbols($$); } | storage_class COPERATOR type LAND LPAREN parms RPAREN cpp_vend { SwigType *decl; $$ = new_node("cdecl"); Setattr($$,"type",$3); Setattr($$,"name",$2); Setattr($$,"storage",$1); decl = NewStringEmpty(); SwigType_add_rvalue_reference(decl); SwigType_add_function(decl,$6); if ($8.qualifier) { SwigType_push(decl,$8.qualifier); } Setattr($$,"decl",decl); Setattr($$,"parms",$6); Setattr($$,"conversion_operator","1"); add_symbols($$); } | storage_class COPERATOR type pointer AND LPAREN parms RPAREN cpp_vend { SwigType *decl; $$ = new_node("cdecl"); Setattr($$,"type",$3); Setattr($$,"name",$2); Setattr($$,"storage",$1); decl = NewStringEmpty(); SwigType_add_pointer(decl); SwigType_add_reference(decl); SwigType_add_function(decl,$7); if ($9.qualifier) { SwigType_push(decl,$9.qualifier); } Setattr($$,"decl",decl); Setattr($$,"parms",$7); Setattr($$,"conversion_operator","1"); add_symbols($$); } | storage_class COPERATOR type LPAREN parms RPAREN cpp_vend { String *t = NewStringEmpty(); $$ = new_node("cdecl"); Setattr($$,"type",$3); Setattr($$,"name",$2); Setattr($$,"storage",$1); SwigType_add_function(t,$5); if ($7.qualifier) { SwigType_push(t,$7.qualifier); } Setattr($$,"decl",t); Setattr($$,"parms",$5); Setattr($$,"conversion_operator","1"); add_symbols($$); } ; /* isolated catch clause. */ cpp_catch_decl : CATCH LPAREN parms RPAREN LBRACE { skip_balanced('{','}'); $$ = 0; } ; /* static_assert(bool, const char*); */ cpp_static_assert : STATIC_ASSERT LPAREN { skip_balanced('(',')'); $$ = 0; } ; /* public: */ cpp_protection_decl : PUBLIC COLON { $$ = new_node("access"); Setattr($$,"kind","public"); cplus_mode = CPLUS_PUBLIC; } /* private: */ | PRIVATE COLON { $$ = new_node("access"); Setattr($$,"kind","private"); cplus_mode = CPLUS_PRIVATE; } /* protected: */ | PROTECTED COLON { $$ = new_node("access"); Setattr($$,"kind","protected"); cplus_mode = CPLUS_PROTECTED; } ; /* These directives can be included inside a class definition */ cpp_swig_directive: pragma_directive { $$ = $1; } /* A constant (includes #defines) inside a class */ | constant_directive { $$ = $1; } /* This is the new style rename */ | name_directive { $$ = $1; } /* rename directive */ | rename_directive { $$ = $1; } | feature_directive { $$ = $1; } | varargs_directive { $$ = $1; } | insert_directive { $$ = $1; } | typemap_directive { $$ = $1; } | apply_directive { $$ = $1; } | clear_directive { $$ = $1; } | echo_directive { $$ = $1; } ; cpp_end : cpp_const SEMI { Clear(scanner_ccode); $$.val = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } | cpp_const EQUAL default_delete SEMI { Clear(scanner_ccode); $$.val = $3.val; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } | cpp_const LBRACE { skip_balanced('{','}'); $$.val = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } ; cpp_vend : cpp_const SEMI { Clear(scanner_ccode); $$.val = 0; $$.qualifier = $1.qualifier; $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } | cpp_const EQUAL definetype SEMI { Clear(scanner_ccode); $$.val = $3.val; $$.qualifier = $1.qualifier; $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } | cpp_const LBRACE { skip_balanced('{','}'); $$.val = 0; $$.qualifier = $1.qualifier; $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } ; anonymous_bitfield : storage_class anon_bitfield_type COLON expr SEMI { }; /* Equals type_right without the ENUM keyword and cpptype (templates etc.): */ anon_bitfield_type : primitive_type { $$ = $1; /* Printf(stdout,"primitive = '%s'\n", $$);*/ } | TYPE_BOOL { $$ = $1; } | TYPE_VOID { $$ = $1; } | TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); } | TYPE_RAW { $$ = $1; } | idcolon { $$ = $1; } ; /* ====================================================================== * PRIMITIVES * ====================================================================== */ storage_class : EXTERN { $$ = "extern"; } | EXTERN string { if (strcmp($2,"C") == 0) { $$ = "externc"; } else if (strcmp($2,"C++") == 0) { $$ = "extern"; } else { Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2); $$ = 0; } } | EXTERN string THREAD_LOCAL { if (strcmp($2,"C") == 0) { $$ = "externc thread_local"; } else if (strcmp($2,"C++") == 0) { $$ = "extern thread_local"; } else { Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2); $$ = 0; } } | STATIC { $$ = "static"; } | TYPEDEF { $$ = "typedef"; } | VIRTUAL { $$ = "virtual"; } | FRIEND { $$ = "friend"; } | EXPLICIT { $$ = "explicit"; } | CONSTEXPR { $$ = "constexpr"; } | STATIC CONSTEXPR { $$ = "static constexpr"; } | THREAD_LOCAL { $$ = "thread_local"; } | THREAD_LOCAL STATIC { $$ = "static thread_local"; } | STATIC THREAD_LOCAL { $$ = "static thread_local"; } | EXTERN THREAD_LOCAL { $$ = "extern thread_local"; } | THREAD_LOCAL EXTERN { $$ = "extern thread_local"; } | empty { $$ = 0; } ; /* ------------------------------------------------------------------------------ Function parameter lists ------------------------------------------------------------------------------ */ parms : rawparms { Parm *p; $$ = $1; p = $1; while (p) { Replace(Getattr(p,"type"),"typename ", "", DOH_REPLACE_ANY); p = nextSibling(p); } } ; rawparms : parm ptail { set_nextSibling($1,$2); $$ = $1; } | empty { $$ = 0; } ; ptail : COMMA parm ptail { set_nextSibling($2,$3); $$ = $2; } | empty { $$ = 0; } ; parm : rawtype parameter_declarator { SwigType_push($1,$2.type); $$ = NewParmWithoutFileLineInfo($1,$2.id); Setfile($$,cparse_file); Setline($$,cparse_line); if ($2.defarg) { Setattr($$,"value",$2.defarg); } } | TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon def_args { $$ = NewParmWithoutFileLineInfo(NewStringf("template %s %s", $5,$6), 0); Setfile($$,cparse_file); Setline($$,cparse_line); if ($7.val) { Setattr($$,"value",$7.val); } } | PERIOD PERIOD PERIOD { SwigType *t = NewString("v(...)"); $$ = NewParmWithoutFileLineInfo(t, 0); Setfile($$,cparse_file); Setline($$,cparse_line); } ; valparms : rawvalparms { Parm *p; $$ = $1; p = $1; while (p) { if (Getattr(p,"type")) { Replace(Getattr(p,"type"),"typename ", "", DOH_REPLACE_ANY); } p = nextSibling(p); } } ; rawvalparms : valparm valptail { set_nextSibling($1,$2); $$ = $1; } | empty { $$ = 0; } ; valptail : COMMA valparm valptail { set_nextSibling($2,$3); $$ = $2; } | empty { $$ = 0; } ; valparm : parm { $$ = $1; { /* We need to make a possible adjustment for integer parameters. */ SwigType *type; Node *n = 0; while (!n) { type = Getattr($1,"type"); n = Swig_symbol_clookup(type,0); /* See if we can find a node that matches the typename */ if ((n) && (Strcmp(nodeType(n),"cdecl") == 0)) { SwigType *decl = Getattr(n,"decl"); if (!SwigType_isfunction(decl)) { String *value = Getattr(n,"value"); if (value) { String *v = Copy(value); Setattr($1,"type",v); Delete(v); n = 0; } } } else { break; } } } } | valexpr { $$ = NewParmWithoutFileLineInfo(0,0); Setfile($$,cparse_file); Setline($$,cparse_line); Setattr($$,"value",$1.val); } ; def_args : EQUAL definetype { $$ = $2; if ($2.type == T_ERROR) { Swig_warning(WARN_PARSE_BAD_DEFAULT,cparse_file, cparse_line, "Can't set default argument (ignored)\n"); $$.val = 0; $$.rawval = 0; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } } | EQUAL definetype LBRACKET expr RBRACKET { $$ = $2; if ($2.type == T_ERROR) { Swig_warning(WARN_PARSE_BAD_DEFAULT,cparse_file, cparse_line, "Can't set default argument (ignored)\n"); $$ = $2; $$.val = 0; $$.rawval = 0; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } else { $$.val = NewStringf("%s[%s]",$2.val,$4.val); } } | EQUAL LBRACE { skip_balanced('{','}'); $$.val = NewString(scanner_ccode); $$.rawval = 0; $$.type = T_INT; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } | COLON expr { $$.val = 0; $$.rawval = 0; $$.type = 0; $$.bitfield = $2.val; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } | empty { $$.val = 0; $$.rawval = 0; $$.type = T_INT; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } ; parameter_declarator : declarator def_args { $$ = $1; $$.defarg = $2.rawval ? $2.rawval : $2.val; } | abstract_declarator def_args { $$ = $1; $$.defarg = $2.rawval ? $2.rawval : $2.val; } | def_args { $$.type = 0; $$.id = 0; $$.defarg = $1.rawval ? $1.rawval : $1.val; } ; typemap_parameter_declarator : declarator { $$ = $1; if (SwigType_isfunction($1.type)) { Delete(SwigType_pop_function($1.type)); } else if (SwigType_isarray($1.type)) { SwigType *ta = SwigType_pop_arrays($1.type); if (SwigType_isfunction($1.type)) { Delete(SwigType_pop_function($1.type)); } else { $$.parms = 0; } SwigType_push($1.type,ta); Delete(ta); } else { $$.parms = 0; } } | abstract_declarator { $$ = $1; if (SwigType_isfunction($1.type)) { Delete(SwigType_pop_function($1.type)); } else if (SwigType_isarray($1.type)) { SwigType *ta = SwigType_pop_arrays($1.type); if (SwigType_isfunction($1.type)) { Delete(SwigType_pop_function($1.type)); } else { $$.parms = 0; } SwigType_push($1.type,ta); Delete(ta); } else { $$.parms = 0; } } | empty { $$.type = 0; $$.id = 0; $$.parms = 0; } ; declarator : pointer notso_direct_declarator { $$ = $2; if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | pointer AND notso_direct_declarator { $$ = $3; SwigType_add_reference($1); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | pointer LAND notso_direct_declarator { $$ = $3; SwigType_add_rvalue_reference($1); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | direct_declarator { $$ = $1; if (!$$.type) $$.type = NewStringEmpty(); } | AND notso_direct_declarator { $$ = $2; $$.type = NewStringEmpty(); SwigType_add_reference($$.type); if ($2.type) { SwigType_push($$.type,$2.type); Delete($2.type); } } | LAND notso_direct_declarator { /* Introduced in C++11, move operator && */ /* Adds one S/R conflict */ $$ = $2; $$.type = NewStringEmpty(); SwigType_add_rvalue_reference($$.type); if ($2.type) { SwigType_push($$.type,$2.type); Delete($2.type); } } | idcolon DSTAR notso_direct_declarator { SwigType *t = NewStringEmpty(); $$ = $3; SwigType_add_memberpointer(t,$1); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | pointer idcolon DSTAR notso_direct_declarator { SwigType *t = NewStringEmpty(); $$ = $4; SwigType_add_memberpointer(t,$2); SwigType_push($1,t); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; Delete(t); } | pointer idcolon DSTAR AND notso_direct_declarator { $$ = $5; SwigType_add_memberpointer($1,$2); SwigType_add_reference($1); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | idcolon DSTAR AND notso_direct_declarator { SwigType *t = NewStringEmpty(); $$ = $4; SwigType_add_memberpointer(t,$1); SwigType_add_reference(t); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } /* Variadic versions eg. MyClasses&... myIds */ | pointer PERIOD PERIOD PERIOD notso_direct_declarator { $$ = $5; if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | pointer AND PERIOD PERIOD PERIOD notso_direct_declarator { $$ = $6; SwigType_add_reference($1); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | pointer LAND PERIOD PERIOD PERIOD notso_direct_declarator { $$ = $6; SwigType_add_rvalue_reference($1); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | PERIOD PERIOD PERIOD direct_declarator { $$ = $4; if (!$$.type) $$.type = NewStringEmpty(); } | AND PERIOD PERIOD PERIOD notso_direct_declarator { $$ = $5; $$.type = NewStringEmpty(); SwigType_add_reference($$.type); if ($5.type) { SwigType_push($$.type,$5.type); Delete($5.type); } } | LAND PERIOD PERIOD PERIOD notso_direct_declarator { /* Introduced in C++11, move operator && */ /* Adds one S/R conflict */ $$ = $5; $$.type = NewStringEmpty(); SwigType_add_rvalue_reference($$.type); if ($5.type) { SwigType_push($$.type,$5.type); Delete($5.type); } } | idcolon DSTAR PERIOD PERIOD PERIOD notso_direct_declarator { SwigType *t = NewStringEmpty(); $$ = $6; SwigType_add_memberpointer(t,$1); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | pointer idcolon DSTAR PERIOD PERIOD PERIOD notso_direct_declarator { SwigType *t = NewStringEmpty(); $$ = $7; SwigType_add_memberpointer(t,$2); SwigType_push($1,t); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; Delete(t); } | pointer idcolon DSTAR AND PERIOD PERIOD PERIOD notso_direct_declarator { $$ = $8; SwigType_add_memberpointer($1,$2); SwigType_add_reference($1); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | pointer idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator { $$ = $8; SwigType_add_memberpointer($1,$2); SwigType_add_rvalue_reference($1); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | idcolon DSTAR AND PERIOD PERIOD PERIOD notso_direct_declarator { SwigType *t = NewStringEmpty(); $$ = $7; SwigType_add_memberpointer(t,$1); SwigType_add_reference(t); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator { SwigType *t = NewStringEmpty(); $$ = $7; SwigType_add_memberpointer(t,$1); SwigType_add_rvalue_reference(t); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } ; notso_direct_declarator : idcolon { /* Note: This is non-standard C. Template declarator is allowed to follow an identifier */ $$.id = Char($1); $$.type = 0; $$.parms = 0; $$.have_parms = 0; } | NOT idcolon { $$.id = Char(NewStringf("~%s",$2)); $$.type = 0; $$.parms = 0; $$.have_parms = 0; } /* This generates a shift-reduce conflict with constructors */ | LPAREN idcolon RPAREN { $$.id = Char($2); $$.type = 0; $$.parms = 0; $$.have_parms = 0; } /* | LPAREN AND idcolon RPAREN { $$.id = Char($3); $$.type = 0; $$.parms = 0; $$.have_parms = 0; } */ /* Technically, this should be LPAREN declarator RPAREN, but we get reduce/reduce conflicts */ | LPAREN pointer notso_direct_declarator RPAREN { $$ = $3; if ($$.type) { SwigType_push($2,$$.type); Delete($$.type); } $$.type = $2; } | LPAREN idcolon DSTAR notso_direct_declarator RPAREN { SwigType *t; $$ = $4; t = NewStringEmpty(); SwigType_add_memberpointer(t,$2); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | notso_direct_declarator LBRACKET RBRACKET { SwigType *t; $$ = $1; t = NewStringEmpty(); SwigType_add_array(t,""); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | notso_direct_declarator LBRACKET expr RBRACKET { SwigType *t; $$ = $1; t = NewStringEmpty(); SwigType_add_array(t,$3.val); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | notso_direct_declarator LPAREN parms RPAREN { SwigType *t; $$ = $1; t = NewStringEmpty(); SwigType_add_function(t,$3); if (!$$.have_parms) { $$.parms = $3; $$.have_parms = 1; } if (!$$.type) { $$.type = t; } else { SwigType_push(t, $$.type); Delete($$.type); $$.type = t; } } ; direct_declarator : idcolon { /* Note: This is non-standard C. Template declarator is allowed to follow an identifier */ $$.id = Char($1); $$.type = 0; $$.parms = 0; $$.have_parms = 0; } | NOT idcolon { $$.id = Char(NewStringf("~%s",$2)); $$.type = 0; $$.parms = 0; $$.have_parms = 0; } /* This generate a shift-reduce conflict with constructors */ /* | LPAREN idcolon RPAREN { $$.id = Char($2); $$.type = 0; $$.parms = 0; $$.have_parms = 0; } */ /* Technically, this should be LPAREN declarator RPAREN, but we get reduce/reduce conflicts */ | LPAREN pointer direct_declarator RPAREN { $$ = $3; if ($$.type) { SwigType_push($2,$$.type); Delete($$.type); } $$.type = $2; } | LPAREN AND direct_declarator RPAREN { $$ = $3; if (!$$.type) { $$.type = NewStringEmpty(); } SwigType_add_reference($$.type); } | LPAREN LAND direct_declarator RPAREN { $$ = $3; if (!$$.type) { $$.type = NewStringEmpty(); } SwigType_add_rvalue_reference($$.type); } | LPAREN idcolon DSTAR direct_declarator RPAREN { SwigType *t; $$ = $4; t = NewStringEmpty(); SwigType_add_memberpointer(t,$2); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | direct_declarator LBRACKET RBRACKET { SwigType *t; $$ = $1; t = NewStringEmpty(); SwigType_add_array(t,""); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | direct_declarator LBRACKET expr RBRACKET { SwigType *t; $$ = $1; t = NewStringEmpty(); SwigType_add_array(t,$3.val); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | direct_declarator LPAREN parms RPAREN { SwigType *t; $$ = $1; t = NewStringEmpty(); SwigType_add_function(t,$3); if (!$$.have_parms) { $$.parms = $3; $$.have_parms = 1; } if (!$$.type) { $$.type = t; } else { SwigType_push(t, $$.type); Delete($$.type); $$.type = t; } } /* User-defined string literals. eg. int operator"" _mySuffix(const char* val, int length) {...} */ /* This produces one S/R conflict. */ | OPERATOR ID LPAREN parms RPAREN { SwigType *t; Append($1, " "); /* intervening space is mandatory */ Append($1, Char($2)); $$.id = Char($1); t = NewStringEmpty(); SwigType_add_function(t,$4); if (!$$.have_parms) { $$.parms = $4; $$.have_parms = 1; } if (!$$.type) { $$.type = t; } else { SwigType_push(t, $$.type); Delete($$.type); $$.type = t; } } ; abstract_declarator : pointer { $$.type = $1; $$.id = 0; $$.parms = 0; $$.have_parms = 0; } | pointer direct_abstract_declarator { $$ = $2; SwigType_push($1,$2.type); $$.type = $1; Delete($2.type); } | pointer AND { $$.type = $1; SwigType_add_reference($$.type); $$.id = 0; $$.parms = 0; $$.have_parms = 0; } | pointer LAND { $$.type = $1; SwigType_add_rvalue_reference($$.type); $$.id = 0; $$.parms = 0; $$.have_parms = 0; } | pointer AND direct_abstract_declarator { $$ = $3; SwigType_add_reference($1); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | pointer LAND direct_abstract_declarator { $$ = $3; SwigType_add_rvalue_reference($1); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } | direct_abstract_declarator { $$ = $1; } | AND direct_abstract_declarator { $$ = $2; $$.type = NewStringEmpty(); SwigType_add_reference($$.type); if ($2.type) { SwigType_push($$.type,$2.type); Delete($2.type); } } | LAND direct_abstract_declarator { $$ = $2; $$.type = NewStringEmpty(); SwigType_add_rvalue_reference($$.type); if ($2.type) { SwigType_push($$.type,$2.type); Delete($2.type); } } | AND { $$.id = 0; $$.parms = 0; $$.have_parms = 0; $$.type = NewStringEmpty(); SwigType_add_reference($$.type); } | LAND { $$.id = 0; $$.parms = 0; $$.have_parms = 0; $$.type = NewStringEmpty(); SwigType_add_rvalue_reference($$.type); } | idcolon DSTAR { $$.type = NewStringEmpty(); SwigType_add_memberpointer($$.type,$1); $$.id = 0; $$.parms = 0; $$.have_parms = 0; } | pointer idcolon DSTAR { SwigType *t = NewStringEmpty(); $$.type = $1; $$.id = 0; $$.parms = 0; $$.have_parms = 0; SwigType_add_memberpointer(t,$2); SwigType_push($$.type,t); Delete(t); } | pointer idcolon DSTAR direct_abstract_declarator { $$ = $4; SwigType_add_memberpointer($1,$2); if ($$.type) { SwigType_push($1,$$.type); Delete($$.type); } $$.type = $1; } ; direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET { SwigType *t; $$ = $1; t = NewStringEmpty(); SwigType_add_array(t,""); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | direct_abstract_declarator LBRACKET expr RBRACKET { SwigType *t; $$ = $1; t = NewStringEmpty(); SwigType_add_array(t,$3.val); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); } $$.type = t; } | LBRACKET RBRACKET { $$.type = NewStringEmpty(); $$.id = 0; $$.parms = 0; $$.have_parms = 0; SwigType_add_array($$.type,""); } | LBRACKET expr RBRACKET { $$.type = NewStringEmpty(); $$.id = 0; $$.parms = 0; $$.have_parms = 0; SwigType_add_array($$.type,$2.val); } | LPAREN abstract_declarator RPAREN { $$ = $2; } | direct_abstract_declarator LPAREN parms RPAREN { SwigType *t; $$ = $1; t = NewStringEmpty(); SwigType_add_function(t,$3); if (!$$.type) { $$.type = t; } else { SwigType_push(t,$$.type); Delete($$.type); $$.type = t; } if (!$$.have_parms) { $$.parms = $3; $$.have_parms = 1; } } | LPAREN parms RPAREN { $$.type = NewStringEmpty(); SwigType_add_function($$.type,$2); $$.parms = $2; $$.have_parms = 1; $$.id = 0; } ; pointer : STAR type_qualifier pointer { $$ = NewStringEmpty(); SwigType_add_pointer($$); SwigType_push($$,$2); SwigType_push($$,$3); Delete($3); } | STAR pointer { $$ = NewStringEmpty(); SwigType_add_pointer($$); SwigType_push($$,$2); Delete($2); } | STAR type_qualifier { $$ = NewStringEmpty(); SwigType_add_pointer($$); SwigType_push($$,$2); } | STAR { $$ = NewStringEmpty(); SwigType_add_pointer($$); } ; type_qualifier : type_qualifier_raw { $$ = NewStringEmpty(); if ($1) SwigType_add_qualifier($$,$1); } | type_qualifier_raw type_qualifier { $$ = $2; if ($1) SwigType_add_qualifier($$,$1); } ; type_qualifier_raw : CONST_QUAL { $$ = "const"; } | VOLATILE { $$ = "volatile"; } | REGISTER { $$ = 0; } ; /* Data type must be a built in type or an identifier for user-defined types This type can be preceded by a modifier. */ type : rawtype { $$ = $1; Replace($$,"typename ","", DOH_REPLACE_ANY); } ; rawtype : type_qualifier type_right { $$ = $2; SwigType_push($$,$1); } | type_right { $$ = $1; } | type_right type_qualifier { $$ = $1; SwigType_push($$,$2); } | type_qualifier type_right type_qualifier { $$ = $2; SwigType_push($$,$3); SwigType_push($$,$1); } ; type_right : primitive_type { $$ = $1; /* Printf(stdout,"primitive = '%s'\n", $$);*/ } | TYPE_BOOL { $$ = $1; } | TYPE_VOID { $$ = $1; } | TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); } | c_enum_key idcolon { $$ = NewStringf("enum %s", $2); } | TYPE_RAW { $$ = $1; } | idcolon { $$ = $1; } | cpptype idcolon { $$ = NewStringf("%s %s", $1, $2); } | decltype { $$ = $1; } ; decltype : DECLTYPE LPAREN idcolon RPAREN { Node *n = Swig_symbol_clookup($3,0); if (!n) { Swig_error(cparse_file, cparse_line, "Identifier %s not defined.\n", $3); $$ = $3; } else { $$ = Getattr(n, "type"); } } ; primitive_type : primitive_type_list { if (!$1.type) $1.type = NewString("int"); if ($1.us) { $$ = NewStringf("%s %s", $1.us, $1.type); Delete($1.us); Delete($1.type); } else { $$ = $1.type; } if (Cmp($$,"signed int") == 0) { Delete($$); $$ = NewString("int"); } else if (Cmp($$,"signed long") == 0) { Delete($$); $$ = NewString("long"); } else if (Cmp($$,"signed short") == 0) { Delete($$); $$ = NewString("short"); } else if (Cmp($$,"signed long long") == 0) { Delete($$); $$ = NewString("long long"); } } ; primitive_type_list : type_specifier { $$ = $1; } | type_specifier primitive_type_list { if ($1.us && $2.us) { Swig_error(cparse_file, cparse_line, "Extra %s specifier.\n", $2.us); } $$ = $2; if ($1.us) $$.us = $1.us; if ($1.type) { if (!$2.type) $$.type = $1.type; else { int err = 0; if ((Cmp($1.type,"long") == 0)) { if ((Cmp($2.type,"long") == 0) || (Strncmp($2.type,"double",6) == 0)) { $$.type = NewStringf("long %s", $2.type); } else if (Cmp($2.type,"int") == 0) { $$.type = $1.type; } else { err = 1; } } else if ((Cmp($1.type,"short")) == 0) { if (Cmp($2.type,"int") == 0) { $$.type = $1.type; } else { err = 1; } } else if (Cmp($1.type,"int") == 0) { $$.type = $2.type; } else if (Cmp($1.type,"double") == 0) { if (Cmp($2.type,"long") == 0) { $$.type = NewString("long double"); } else if (Cmp($2.type,"complex") == 0) { $$.type = NewString("double complex"); } else { err = 1; } } else if (Cmp($1.type,"float") == 0) { if (Cmp($2.type,"complex") == 0) { $$.type = NewString("float complex"); } else { err = 1; } } else if (Cmp($1.type,"complex") == 0) { $$.type = NewStringf("%s complex", $2.type); } else { err = 1; } if (err) { Swig_error(cparse_file, cparse_line, "Extra %s specifier.\n", $1.type); } } } } ; type_specifier : TYPE_INT { $$.type = NewString("int"); $$.us = 0; } | TYPE_SHORT { $$.type = NewString("short"); $$.us = 0; } | TYPE_LONG { $$.type = NewString("long"); $$.us = 0; } | TYPE_CHAR { $$.type = NewString("char"); $$.us = 0; } | TYPE_WCHAR { $$.type = NewString("wchar_t"); $$.us = 0; } | TYPE_FLOAT { $$.type = NewString("float"); $$.us = 0; } | TYPE_DOUBLE { $$.type = NewString("double"); $$.us = 0; } | TYPE_SIGNED { $$.us = NewString("signed"); $$.type = 0; } | TYPE_UNSIGNED { $$.us = NewString("unsigned"); $$.type = 0; } | TYPE_COMPLEX { $$.type = NewString("complex"); $$.us = 0; } | TYPE_NON_ISO_INT8 { $$.type = NewString("__int8"); $$.us = 0; } | TYPE_NON_ISO_INT16 { $$.type = NewString("__int16"); $$.us = 0; } | TYPE_NON_ISO_INT32 { $$.type = NewString("__int32"); $$.us = 0; } | TYPE_NON_ISO_INT64 { $$.type = NewString("__int64"); $$.us = 0; } ; definetype : { /* scanner_check_typedef(); */ } expr { $$ = $2; if ($$.type == T_STRING) { $$.rawval = NewStringf("\"%(escape)s\"",$$.val); } else if ($$.type != T_CHAR && $$.type != T_WSTRING && $$.type != T_WCHAR) { $$.rawval = 0; } $$.qualifier = 0; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; scanner_ignore_typedef(); } | default_delete { $$ = $1; } /* | string { $$.val = NewString($1); $$.rawval = NewStringf("\"%(escape)s\"",$$.val); $$.type = T_STRING; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } */ ; default_delete : deleted_definition { $$ = $1; } | explicit_default { $$ = $1; } ; /* For C++ deleted definition '= delete' */ deleted_definition : DELETE_KW { $$.val = NewString("delete"); $$.rawval = 0; $$.type = T_STRING; $$.qualifier = 0; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } ; /* For C++ explicitly defaulted functions '= default' */ explicit_default : DEFAULT { $$.val = NewString("default"); $$.rawval = 0; $$.type = T_STRING; $$.qualifier = 0; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } ; /* Some stuff for handling enums */ ename : identifier { $$ = $1; } | empty { $$ = (char *) 0;} ; optional_constant_directive : constant_directive { $$ = $1; } | empty { $$ = 0; } ; /* Enum lists - any #define macros (constant directives) within the enum list are ignored. Trailing commas accepted. */ enumlist : enumlist COMMA optional_constant_directive edecl optional_constant_directive { Node *leftSibling = Getattr($1,"_last"); set_nextSibling(leftSibling,$4); Setattr($1,"_last",$4); $$ = $1; } | enumlist COMMA optional_constant_directive { $$ = $1; } | optional_constant_directive edecl optional_constant_directive { Setattr($2,"_last",$2); $$ = $2; } | optional_constant_directive { $$ = 0; } ; edecl : identifier { SwigType *type = NewSwigType(T_INT); $$ = new_node("enumitem"); Setattr($$,"name",$1); Setattr($$,"type",type); SetFlag($$,"feature:immutable"); Delete(type); } | identifier EQUAL etype { SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : ($3.type == T_CHAR ? T_CHAR : T_INT)); $$ = new_node("enumitem"); Setattr($$,"name",$1); Setattr($$,"type",type); SetFlag($$,"feature:immutable"); Setattr($$,"enumvalue", $3.val); Setattr($$,"value",$1); Delete(type); } ; etype : expr { $$ = $1; if (($$.type != T_INT) && ($$.type != T_UINT) && ($$.type != T_LONG) && ($$.type != T_ULONG) && ($$.type != T_LONGLONG) && ($$.type != T_ULONGLONG) && ($$.type != T_SHORT) && ($$.type != T_USHORT) && ($$.type != T_SCHAR) && ($$.type != T_UCHAR) && ($$.type != T_CHAR) && ($$.type != T_BOOL)) { Swig_error(cparse_file,cparse_line,"Type error. Expecting an integral type\n"); } } ; /* Arithmetic expressions. Used for constants, C++ templates, and other cool stuff. */ expr : valexpr { $$ = $1; } | type { Node *n; $$.val = $1; $$.type = T_INT; /* Check if value is in scope */ n = Swig_symbol_clookup($1,0); if (n) { /* A band-aid for enum values used in expressions. */ if (Strcmp(nodeType(n),"enumitem") == 0) { String *q = Swig_symbol_qualified(n); if (q) { $$.val = NewStringf("%s::%s", q, Getattr(n,"name")); Delete(q); } } } } ; valexpr : exprnum { $$ = $1; } | string { $$.val = NewString($1); $$.type = T_STRING; } | SIZEOF LPAREN type parameter_declarator RPAREN { SwigType_push($3,$4.type); $$.val = NewStringf("sizeof(%s)",SwigType_str($3,0)); $$.type = T_ULONG; } | SIZEOF PERIOD PERIOD PERIOD LPAREN type parameter_declarator RPAREN { SwigType_push($6,$7.type); $$.val = NewStringf("sizeof...(%s)",SwigType_str($6,0)); $$.type = T_ULONG; } | exprcompound { $$ = $1; } | wstring { $$.val = NewString($1); $$.rawval = NewStringf("L\"%s\"", $$.val); $$.type = T_WSTRING; } | CHARCONST { $$.val = NewString($1); if (Len($$.val)) { $$.rawval = NewStringf("'%(escape)s'", $$.val); } else { $$.rawval = NewString("'\\0'"); } $$.type = T_CHAR; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } | WCHARCONST { $$.val = NewString($1); if (Len($$.val)) { $$.rawval = NewStringf("L\'%s\'", $$.val); } else { $$.rawval = NewString("L'\\0'"); } $$.type = T_WCHAR; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } /* grouping */ | LPAREN expr RPAREN %prec CAST { $$.val = NewStringf("(%s)",$2.val); $$.type = $2.type; } /* A few common casting operations */ | LPAREN expr RPAREN expr %prec CAST { $$ = $4; if ($4.type != T_STRING) { switch ($2.type) { case T_FLOAT: case T_DOUBLE: case T_LONGDOUBLE: case T_FLTCPLX: case T_DBLCPLX: $$.val = NewStringf("(%s)%s", $2.val, $4.val); /* SwigType_str and decimal points don't mix! */ break; default: $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val); break; } } } | LPAREN expr pointer RPAREN expr %prec CAST { $$ = $5; if ($5.type != T_STRING) { SwigType_push($2.val,$3); $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $5.val); } } | LPAREN expr AND RPAREN expr %prec CAST { $$ = $5; if ($5.type != T_STRING) { SwigType_add_reference($2.val); $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $5.val); } } | LPAREN expr LAND RPAREN expr %prec CAST { $$ = $5; if ($5.type != T_STRING) { SwigType_add_rvalue_reference($2.val); $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $5.val); } } | LPAREN expr pointer AND RPAREN expr %prec CAST { $$ = $6; if ($6.type != T_STRING) { SwigType_push($2.val,$3); SwigType_add_reference($2.val); $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $6.val); } } | LPAREN expr pointer LAND RPAREN expr %prec CAST { $$ = $6; if ($6.type != T_STRING) { SwigType_push($2.val,$3); SwigType_add_rvalue_reference($2.val); $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $6.val); } } | AND expr { $$ = $2; $$.val = NewStringf("&%s",$2.val); } | LAND expr { $$ = $2; $$.val = NewStringf("&&%s",$2.val); } | STAR expr { $$ = $2; $$.val = NewStringf("*%s",$2.val); } ; exprnum : NUM_INT { $$ = $1; } | NUM_FLOAT { $$ = $1; } | NUM_UNSIGNED { $$ = $1; } | NUM_LONG { $$ = $1; } | NUM_ULONG { $$ = $1; } | NUM_LONGLONG { $$ = $1; } | NUM_ULONGLONG { $$ = $1; } | NUM_BOOL { $$ = $1; } ; exprcompound : expr PLUS expr { $$.val = NewStringf("%s+%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } | expr MINUS expr { $$.val = NewStringf("%s-%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } | expr STAR expr { $$.val = NewStringf("%s*%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } | expr SLASH expr { $$.val = NewStringf("%s/%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } | expr MODULO expr { $$.val = NewStringf("%s%%%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } | expr AND expr { $$.val = NewStringf("%s&%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } | expr OR expr { $$.val = NewStringf("%s|%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } | expr XOR expr { $$.val = NewStringf("%s^%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } | expr LSHIFT expr { $$.val = NewStringf("%s << %s",$1.val,$3.val); $$.type = promote_type($1.type); } | expr RSHIFT expr { $$.val = NewStringf("%s >> %s",$1.val,$3.val); $$.type = promote_type($1.type); } | expr LAND expr { $$.val = NewStringf("%s&&%s",$1.val,$3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr LOR expr { $$.val = NewStringf("%s||%s",$1.val,$3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr EQUALTO expr { $$.val = NewStringf("%s==%s",$1.val,$3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr NOTEQUALTO expr { $$.val = NewStringf("%s!=%s",$1.val,$3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } /* Sadly this causes 2 reduce-reduce conflicts with templates. FIXME resolve these. | expr GREATERTHAN expr { $$.val = NewStringf("%s < %s", $1.val, $3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr LESSTHAN expr { $$.val = NewStringf("%s > %s", $1.val, $3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } */ | expr GREATERTHANOREQUALTO expr { $$.val = NewStringf("%s >= %s", $1.val, $3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr LESSTHANOREQUALTO expr { $$.val = NewStringf("%s <= %s", $1.val, $3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr QUESTIONMARK expr COLON expr %prec QUESTIONMARK { $$.val = NewStringf("%s?%s:%s", $1.val, $3.val, $5.val); /* This may not be exactly right, but is probably good enough * for the purposes of parsing constant expressions. */ $$.type = promote($3.type, $5.type); } | MINUS expr %prec UMINUS { $$.val = NewStringf("-%s",$2.val); $$.type = $2.type; } | PLUS expr %prec UMINUS { $$.val = NewStringf("+%s",$2.val); $$.type = $2.type; } | NOT expr { $$.val = NewStringf("~%s",$2.val); $$.type = $2.type; } | LNOT expr { $$.val = NewStringf("!%s",$2.val); $$.type = T_INT; } | type LPAREN { String *qty; skip_balanced('(',')'); qty = Swig_symbol_type_qualify($1,0); if (SwigType_istemplate(qty)) { String *nstr = SwigType_namestr(qty); Delete(qty); qty = nstr; } $$.val = NewStringf("%s%s",qty,scanner_ccode); Clear(scanner_ccode); $$.type = T_INT; Delete(qty); } ; ellipsis : PERIOD PERIOD PERIOD { $$ = NewString("..."); } ; variadic : ellipsis { $$ = $1; } | empty { $$ = 0; } ; inherit : raw_inherit { $$ = $1; } ; raw_inherit : COLON { inherit_list = 1; } base_list { $$ = $3; inherit_list = 0; } | empty { $$ = 0; } ; base_list : base_specifier { Hash *list = NewHash(); Node *base = $1; Node *name = Getattr(base,"name"); List *lpublic = NewList(); List *lprotected = NewList(); List *lprivate = NewList(); Setattr(list,"public",lpublic); Setattr(list,"protected",lprotected); Setattr(list,"private",lprivate); Delete(lpublic); Delete(lprotected); Delete(lprivate); Append(Getattr(list,Getattr(base,"access")),name); $$ = list; } | base_list COMMA base_specifier { Hash *list = $1; Node *base = $3; Node *name = Getattr(base,"name"); Append(Getattr(list,Getattr(base,"access")),name); $$ = list; } ; base_specifier : opt_virtual { $$ = cparse_line; } idcolon variadic { $$ = NewHash(); Setfile($$,cparse_file); Setline($$,$2); Setattr($$,"name",$3); Setfile($3,cparse_file); Setline($3,$2); if (last_cpptype && (Strcmp(last_cpptype,"struct") != 0)) { Setattr($$,"access","private"); Swig_warning(WARN_PARSE_NO_ACCESS, Getfile($$), Getline($$), "No access specifier given for base class '%s' (ignored).\n", SwigType_namestr($3)); } else { Setattr($$,"access","public"); } if ($4) SetFlag($$, "variadic"); } | opt_virtual access_specifier { $$ = cparse_line; } opt_virtual idcolon variadic { $$ = NewHash(); Setfile($$,cparse_file); Setline($$,$3); Setattr($$,"name",$5); Setfile($5,cparse_file); Setline($5,$3); Setattr($$,"access",$2); if (Strcmp($2,"public") != 0) { Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile($$), Getline($$), "%s inheritance from base '%s' (ignored).\n", $2, SwigType_namestr($5)); } if ($6) SetFlag($$, "variadic"); } ; access_specifier : PUBLIC { $$ = (char*)"public"; } | PRIVATE { $$ = (char*)"private"; } | PROTECTED { $$ = (char*)"protected"; } ; templcpptype : CLASS { $$ = (char*)"class"; if (!inherit_list) last_cpptype = $$; } | TYPENAME { $$ = (char *)"typename"; if (!inherit_list) last_cpptype = $$; } | CLASS PERIOD PERIOD PERIOD { $$ = (char *)"class..."; if (!inherit_list) last_cpptype = $$; } | TYPENAME PERIOD PERIOD PERIOD { $$ = (char *)"typename..."; if (!inherit_list) last_cpptype = $$; } ; cpptype : templcpptype { $$ = $1; } | STRUCT { $$ = (char*)"struct"; if (!inherit_list) last_cpptype = $$; } | UNION { $$ = (char*)"union"; if (!inherit_list) last_cpptype = $$; } ; opt_virtual : VIRTUAL | empty ; virt_specifier_seq : OVERRIDE { $$ = 0; } | FINAL { $$ = 0; } | FINAL OVERRIDE { $$ = 0; } | OVERRIDE FINAL { $$ = 0; } ; exception_specification : THROW LPAREN parms RPAREN { $$.throws = $3; $$.throwf = NewString("1"); $$.nexcept = 0; } | NOEXCEPT { $$.throws = 0; $$.throwf = 0; $$.nexcept = NewString("true"); } | virt_specifier_seq { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } | NOEXCEPT virt_specifier_seq { $$.throws = 0; $$.throwf = 0; $$.nexcept = NewString("true"); } | NOEXCEPT LPAREN expr RPAREN { $$.throws = 0; $$.throwf = 0; $$.nexcept = $3.val; } ; cpp_const : type_qualifier { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; $$.qualifier = $1; } | exception_specification { $$ = $1; $$.qualifier = 0; } | type_qualifier exception_specification { $$ = $2; $$.qualifier = $1; } | empty { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; $$.qualifier = 0; } ; ctor_end : cpp_const ctor_initializer SEMI { Clear(scanner_ccode); $$.have_parms = 0; $$.defarg = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } | cpp_const ctor_initializer LBRACE { skip_balanced('{','}'); $$.have_parms = 0; $$.defarg = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } | LPAREN parms RPAREN SEMI { Clear(scanner_ccode); $$.parms = $2; $$.have_parms = 1; $$.defarg = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } | LPAREN parms RPAREN LBRACE { skip_balanced('{','}'); $$.parms = $2; $$.have_parms = 1; $$.defarg = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } | EQUAL definetype SEMI { $$.have_parms = 0; $$.defarg = $2.val; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } | exception_specification EQUAL default_delete SEMI { $$.have_parms = 0; $$.defarg = $3.val; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } ; ctor_initializer : COLON mem_initializer_list | empty ; mem_initializer_list : mem_initializer | mem_initializer_list COMMA mem_initializer | mem_initializer PERIOD PERIOD PERIOD | mem_initializer_list COMMA mem_initializer PERIOD PERIOD PERIOD ; mem_initializer : idcolon LPAREN { skip_balanced('(',')'); Clear(scanner_ccode); } /* Uniform initialization in C++11. Example: struct MyStruct { MyStruct(int x, double y) : x_{x}, y_{y} {} int x_; double y_; }; */ | idcolon LBRACE { skip_balanced('{','}'); Clear(scanner_ccode); } ; template_decl : LESSTHAN valparms GREATERTHAN { String *s = NewStringEmpty(); SwigType_add_template(s,$2); $$ = Char(s); scanner_last_id(1); } | empty { $$ = (char*)""; } ; /* Identifiers including the C++11 identifiers with special meaning */ identifier : ID { $$ = $1; } | OVERRIDE { $$ = Swig_copy_string("override"); } | FINAL { $$ = Swig_copy_string("final"); } ; idstring : identifier { $$ = $1; } | default_delete { $$ = $1.val; } | string { $$ = $1; } ; idstringopt : idstring { $$ = $1; } | empty { $$ = 0; } ; idcolon : idtemplate idcolontail { $$ = 0; if (!$$) $$ = NewStringf("%s%s", $1,$2); Delete($2); } | NONID DCOLON idtemplate idcolontail { $$ = NewStringf("::%s%s",$3,$4); Delete($4); } | idtemplate { $$ = NewString($1); } | NONID DCOLON idtemplate { $$ = NewStringf("::%s",$3); } | OPERATOR { $$ = NewString($1); } | NONID DCOLON OPERATOR { $$ = NewStringf("::%s",$3); } ; idcolontail : DCOLON idtemplate idcolontail { $$ = NewStringf("::%s%s",$2,$3); Delete($3); } | DCOLON idtemplate { $$ = NewStringf("::%s",$2); } | DCOLON OPERATOR { $$ = NewStringf("::%s",$2); } /* | DCOLON COPERATOR { $$ = NewString($2); } */ | DCNOT idtemplate { $$ = NewStringf("::~%s",$2); } ; idtemplate : identifier template_decl { $$ = NewStringf("%s%s",$1,$2); /* if (Len($2)) { scanner_last_id(1); } */ } ; /* Identifier, but no templates */ idcolonnt : identifier idcolontailnt { $$ = 0; if (!$$) $$ = NewStringf("%s%s", $1,$2); Delete($2); } | NONID DCOLON identifier idcolontailnt { $$ = NewStringf("::%s%s",$3,$4); Delete($4); } | identifier { $$ = NewString($1); } | NONID DCOLON identifier { $$ = NewStringf("::%s",$3); } | OPERATOR { $$ = NewString($1); } | NONID DCOLON OPERATOR { $$ = NewStringf("::%s",$3); } ; idcolontailnt : DCOLON identifier idcolontailnt { $$ = NewStringf("::%s%s",$2,$3); Delete($3); } | DCOLON identifier { $$ = NewStringf("::%s",$2); } | DCOLON OPERATOR { $$ = NewStringf("::%s",$2); } | DCNOT identifier { $$ = NewStringf("::~%s",$2); } ; /* Concatenated strings */ string : string STRING { $$ = (char *) malloc(strlen($1)+strlen($2)+1); strcpy($$,$1); strcat($$,$2); } | STRING { $$ = $1;} ; /* Concatenated wide strings: L"str1" L"str2" */ wstring : wstring WSTRING { $$ = (char *) malloc(strlen($1)+strlen($2)+1); strcpy($$,$1); strcat($$,$2); } /* Concatenated wide string and normal string literal: L"str1" "str2" */ /*not all the compilers support this concatenation mode, so perhaps better to postpone it*/ /*| wstring STRING { here $2 comes unescaped, we have to escape it back first via NewStringf("%(escape)s)" $$ = (char *) malloc(strlen($1)+strlen($2)+1); strcpy($$,$1); strcat($$,$2); }*/ | WSTRING { $$ = $1;} ; stringbrace : string { $$ = NewString($1); } | LBRACE { skip_balanced('{','}'); $$ = NewString(scanner_ccode); } | HBLOCK { $$ = $1; } ; options : LPAREN kwargs RPAREN { Hash *n; $$ = NewHash(); n = $2; while(n) { String *name, *value; name = Getattr(n,"name"); value = Getattr(n,"value"); if (!value) value = (String *) "1"; Setattr($$,name, value); n = nextSibling(n); } } | empty { $$ = 0; }; /* Keyword arguments */ kwargs : idstring EQUAL stringnum { $$ = NewHash(); Setattr($$,"name",$1); Setattr($$,"value",$3); } | idstring EQUAL stringnum COMMA kwargs { $$ = NewHash(); Setattr($$,"name",$1); Setattr($$,"value",$3); set_nextSibling($$,$5); } | idstring { $$ = NewHash(); Setattr($$,"name",$1); } | idstring COMMA kwargs { $$ = NewHash(); Setattr($$,"name",$1); set_nextSibling($$,$3); } | idstring EQUAL stringtype { $$ = $3; Setattr($$,"name",$1); } | idstring EQUAL stringtype COMMA kwargs { $$ = $3; Setattr($$,"name",$1); set_nextSibling($$,$5); } ; stringnum : string { $$ = $1; } | exprnum { $$ = Char($1.val); } ; empty : ; %% SwigType *Swig_cparse_type(String *s) { String *ns; ns = NewStringf("%s;",s); Seek(ns,0,SEEK_SET); scanner_file(ns); top = 0; scanner_next_token(PARSETYPE); yyparse(); /* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */ return top; } Parm *Swig_cparse_parm(String *s) { String *ns; ns = NewStringf("%s;",s); Seek(ns,0,SEEK_SET); scanner_file(ns); top = 0; scanner_next_token(PARSEPARM); yyparse(); /* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */ Delete(ns); return top; } ParmList *Swig_cparse_parms(String *s, Node *file_line_node) { String *ns; char *cs = Char(s); if (cs && cs[0] != '(') { ns = NewStringf("(%s);",s); } else { ns = NewStringf("%s;",s); } Setfile(ns, Getfile(file_line_node)); Setline(ns, Getline(file_line_node)); Seek(ns,0,SEEK_SET); scanner_file(ns); top = 0; scanner_next_token(PARSEPARMS); yyparse(); /* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */ return top; } swig-3.0.2/Source/CParse/parser.h0000664000175000017500000002054312343706600016434 0ustar williamwilliam/* A Bison parser, made by GNU Bison 2.5. */ /* Bison interface for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { ID = 258, HBLOCK = 259, POUND = 260, STRING = 261, WSTRING = 262, INCLUDE = 263, IMPORT = 264, INSERT = 265, CHARCONST = 266, WCHARCONST = 267, NUM_INT = 268, NUM_FLOAT = 269, NUM_UNSIGNED = 270, NUM_LONG = 271, NUM_ULONG = 272, NUM_LONGLONG = 273, NUM_ULONGLONG = 274, NUM_BOOL = 275, TYPEDEF = 276, TYPE_INT = 277, TYPE_UNSIGNED = 278, TYPE_SHORT = 279, TYPE_LONG = 280, TYPE_FLOAT = 281, TYPE_DOUBLE = 282, TYPE_CHAR = 283, TYPE_WCHAR = 284, TYPE_VOID = 285, TYPE_SIGNED = 286, TYPE_BOOL = 287, TYPE_COMPLEX = 288, TYPE_TYPEDEF = 289, TYPE_RAW = 290, TYPE_NON_ISO_INT8 = 291, TYPE_NON_ISO_INT16 = 292, TYPE_NON_ISO_INT32 = 293, TYPE_NON_ISO_INT64 = 294, LPAREN = 295, RPAREN = 296, COMMA = 297, SEMI = 298, EXTERN = 299, INIT = 300, LBRACE = 301, RBRACE = 302, PERIOD = 303, CONST_QUAL = 304, VOLATILE = 305, REGISTER = 306, STRUCT = 307, UNION = 308, EQUAL = 309, SIZEOF = 310, MODULE = 311, LBRACKET = 312, RBRACKET = 313, BEGINFILE = 314, ENDOFFILE = 315, ILLEGAL = 316, CONSTANT = 317, NAME = 318, RENAME = 319, NAMEWARN = 320, EXTEND = 321, PRAGMA = 322, FEATURE = 323, VARARGS = 324, ENUM = 325, CLASS = 326, TYPENAME = 327, PRIVATE = 328, PUBLIC = 329, PROTECTED = 330, COLON = 331, STATIC = 332, VIRTUAL = 333, FRIEND = 334, THROW = 335, CATCH = 336, EXPLICIT = 337, STATIC_ASSERT = 338, CONSTEXPR = 339, THREAD_LOCAL = 340, DECLTYPE = 341, AUTO = 342, NOEXCEPT = 343, OVERRIDE = 344, FINAL = 345, USING = 346, NAMESPACE = 347, NATIVE = 348, INLINE = 349, TYPEMAP = 350, EXCEPT = 351, ECHO = 352, APPLY = 353, CLEAR = 354, SWIGTEMPLATE = 355, FRAGMENT = 356, WARN = 357, LESSTHAN = 358, GREATERTHAN = 359, DELETE_KW = 360, DEFAULT = 361, LESSTHANOREQUALTO = 362, GREATERTHANOREQUALTO = 363, EQUALTO = 364, NOTEQUALTO = 365, ARROW = 366, QUESTIONMARK = 367, TYPES = 368, PARMS = 369, NONID = 370, DSTAR = 371, DCNOT = 372, TEMPLATE = 373, OPERATOR = 374, COPERATOR = 375, PARSETYPE = 376, PARSEPARM = 377, PARSEPARMS = 378, CAST = 379, LOR = 380, LAND = 381, OR = 382, XOR = 383, AND = 384, RSHIFT = 385, LSHIFT = 386, MINUS = 387, PLUS = 388, MODULO = 389, SLASH = 390, STAR = 391, LNOT = 392, NOT = 393, UMINUS = 394, DCOLON = 395 }; #endif /* Tokens. */ #define ID 258 #define HBLOCK 259 #define POUND 260 #define STRING 261 #define WSTRING 262 #define INCLUDE 263 #define IMPORT 264 #define INSERT 265 #define CHARCONST 266 #define WCHARCONST 267 #define NUM_INT 268 #define NUM_FLOAT 269 #define NUM_UNSIGNED 270 #define NUM_LONG 271 #define NUM_ULONG 272 #define NUM_LONGLONG 273 #define NUM_ULONGLONG 274 #define NUM_BOOL 275 #define TYPEDEF 276 #define TYPE_INT 277 #define TYPE_UNSIGNED 278 #define TYPE_SHORT 279 #define TYPE_LONG 280 #define TYPE_FLOAT 281 #define TYPE_DOUBLE 282 #define TYPE_CHAR 283 #define TYPE_WCHAR 284 #define TYPE_VOID 285 #define TYPE_SIGNED 286 #define TYPE_BOOL 287 #define TYPE_COMPLEX 288 #define TYPE_TYPEDEF 289 #define TYPE_RAW 290 #define TYPE_NON_ISO_INT8 291 #define TYPE_NON_ISO_INT16 292 #define TYPE_NON_ISO_INT32 293 #define TYPE_NON_ISO_INT64 294 #define LPAREN 295 #define RPAREN 296 #define COMMA 297 #define SEMI 298 #define EXTERN 299 #define INIT 300 #define LBRACE 301 #define RBRACE 302 #define PERIOD 303 #define CONST_QUAL 304 #define VOLATILE 305 #define REGISTER 306 #define STRUCT 307 #define UNION 308 #define EQUAL 309 #define SIZEOF 310 #define MODULE 311 #define LBRACKET 312 #define RBRACKET 313 #define BEGINFILE 314 #define ENDOFFILE 315 #define ILLEGAL 316 #define CONSTANT 317 #define NAME 318 #define RENAME 319 #define NAMEWARN 320 #define EXTEND 321 #define PRAGMA 322 #define FEATURE 323 #define VARARGS 324 #define ENUM 325 #define CLASS 326 #define TYPENAME 327 #define PRIVATE 328 #define PUBLIC 329 #define PROTECTED 330 #define COLON 331 #define STATIC 332 #define VIRTUAL 333 #define FRIEND 334 #define THROW 335 #define CATCH 336 #define EXPLICIT 337 #define STATIC_ASSERT 338 #define CONSTEXPR 339 #define THREAD_LOCAL 340 #define DECLTYPE 341 #define AUTO 342 #define NOEXCEPT 343 #define OVERRIDE 344 #define FINAL 345 #define USING 346 #define NAMESPACE 347 #define NATIVE 348 #define INLINE 349 #define TYPEMAP 350 #define EXCEPT 351 #define ECHO 352 #define APPLY 353 #define CLEAR 354 #define SWIGTEMPLATE 355 #define FRAGMENT 356 #define WARN 357 #define LESSTHAN 358 #define GREATERTHAN 359 #define DELETE_KW 360 #define DEFAULT 361 #define LESSTHANOREQUALTO 362 #define GREATERTHANOREQUALTO 363 #define EQUALTO 364 #define NOTEQUALTO 365 #define ARROW 366 #define QUESTIONMARK 367 #define TYPES 368 #define PARMS 369 #define NONID 370 #define DSTAR 371 #define DCNOT 372 #define TEMPLATE 373 #define OPERATOR 374 #define COPERATOR 375 #define PARSETYPE 376 #define PARSEPARM 377 #define PARSEPARMS 378 #define CAST 379 #define LOR 380 #define LAND 381 #define OR 382 #define XOR 383 #define AND 384 #define RSHIFT 385 #define LSHIFT 386 #define MINUS 387 #define PLUS 388 #define MODULO 389 #define SLASH 390 #define STAR 391 #define LNOT 392 #define NOT 393 #define UMINUS 394 #define DCOLON 395 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { /* Line 2068 of yacc.c */ #line 1298 "parser.y" char *id; List *bases; struct Define { String *val; String *rawval; int type; String *qualifier; String *bitfield; Parm *throws; String *throwf; String *nexcept; } dtype; struct { const char *type; String *filename; int line; } loc; struct { char *id; SwigType *type; String *defarg; ParmList *parms; short have_parms; ParmList *throws; String *throwf; String *nexcept; } decl; Parm *tparms; struct { String *method; Hash *kwargs; } tmap; struct { String *type; String *us; } ptype; SwigType *type; String *str; Parm *p; ParmList *pl; int intvalue; Node *node; /* Line 2068 of yacc.c */ #line 377 "y.tab.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif extern YYSTYPE yylval; swig-3.0.2/Source/README0000664000175000017500000000136612343605122014471 0ustar williamwilliamSWIG Source directory Source/DOH - A core set of basic datatypes including strings, lists, hashes, and files. Used extensively by the rest of SWIG. Source/Swig - Swig core. Type-system, utility functions. Source/Preprocessor - SWIG C Preprocessor Source/CParse - SWIG C Parser (still messy) Source/Modules - Language modules. Source/Include - Include files. Historic directories which may be in CVS, but have been removed: Source/Modules1.1 - Old SWIG-1.1 modules. Empty. Source/LParse - Experimental parser. Officially dead as CParse is more capable. Source/SWIG1.1 - Old SWIG1.1 core. Completely empty now. swig-3.0.2/Source/Include/0000775000175000017500000000000012343706573015202 5ustar williamwilliamswig-3.0.2/Source/Include/swigconfig.h.in0000664000175000017500000000474112343706573020125 0ustar williamwilliam/* Source/Include/swigconfig.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if the system has the type `bool'. */ #undef HAVE_BOOL /* define if the Boost library is available */ #undef HAVE_BOOST /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `dl' library (-ldl). */ #undef HAVE_LIBDL /* Define to 1 if you have the `dld' library (-ldld). */ #undef HAVE_LIBDLD /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define if you have PCRE library */ #undef HAVE_PCRE /* Define if popen is available */ #undef HAVE_POPEN /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Compiler that built SWIG */ #undef SWIG_CXX /* Directory for SWIG system-independent libraries */ #undef SWIG_LIB /* Directory for SWIG system-independent libraries (Unix install on native Windows) */ #undef SWIG_LIB_WIN_UNIX /* Platform that SWIG is built for */ #undef SWIG_PLATFORM /* Version number of package */ #undef VERSION /* Default language */ #define SWIG_LANG "-tcl" /* Deal with attempt by Microsoft to deprecate C standard runtime functions */ #if defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif swig-3.0.2/Source/Include/swigwarn.h0000664000175000017500000003032112343605122017177 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swigwarn.h * * SWIG warning message numbers * This file serves as the main registry of warning message numbers. Some of these * numbers are used internally in the C/C++ source code of SWIG. However, some * of the numbers are used in SWIG configuration files (swig.swg and others). * * The numbers are roughly organized into a few different classes by functionality. * * Even though symbolic constants are used in the SWIG source, this is * not always the case in SWIG interface files. Do not change the * numbers in this file. * ----------------------------------------------------------------------------- */ #ifndef SWIGWARN_H_ #define SWIGWARN_H_ #define WARN_NONE 0 /* -- Deprecated features -- */ #define WARN_DEPRECATED_EXTERN 101 #define WARN_DEPRECATED_VAL 102 #define WARN_DEPRECATED_OUT 103 #define WARN_DEPRECATED_DISABLEDOC 104 #define WARN_DEPRECATED_ENABLEDOC 105 #define WARN_DEPRECATED_DOCONLY 106 #define WARN_DEPRECATED_STYLE 107 #define WARN_DEPRECATED_LOCALSTYLE 108 #define WARN_DEPRECATED_TITLE 109 #define WARN_DEPRECATED_SECTION 110 #define WARN_DEPRECATED_SUBSECTION 111 #define WARN_DEPRECATED_SUBSUBSECTION 112 #define WARN_DEPRECATED_ADDMETHODS 113 #define WARN_DEPRECATED_READONLY 114 #define WARN_DEPRECATED_READWRITE 115 #define WARN_DEPRECATED_EXCEPT 116 #define WARN_DEPRECATED_NEW 117 #define WARN_DEPRECATED_EXCEPT_TM 118 #define WARN_DEPRECATED_IGNORE_TM 119 #define WARN_DEPRECATED_OPTC 120 #define WARN_DEPRECATED_NAME 121 #define WARN_DEPRECATED_NOEXTERN 122 #define WARN_DEPRECATED_NODEFAULT 123 #define WARN_DEPRECATED_TYPEMAP_LANG 124 #define WARN_DEPRECATED_INPUT_FILE 125 #define WARN_DEPRECATED_NESTED_WORKAROUND 126 /* -- Preprocessor -- */ #define WARN_PP_MISSING_FILE 201 #define WARN_PP_EVALUATION 202 #define WARN_PP_INCLUDEALL_IMPORTALL 203 #define WARN_PP_CPP_WARNING 204 #define WARN_PP_CPP_ERROR 205 #define WARN_PP_UNEXPECTED_TOKENS 206 /* -- C/C++ Parser -- */ #define WARN_PARSE_CLASS_KEYWORD 301 #define WARN_PARSE_REDEFINED 302 #define WARN_PARSE_EXTEND_UNDEF 303 #define WARN_PARSE_UNSUPPORTED_VALUE 304 #define WARN_PARSE_BAD_VALUE 305 #define WARN_PARSE_PRIVATE 306 #define WARN_PARSE_BAD_DEFAULT 307 #define WARN_PARSE_NAMESPACE_ALIAS 308 #define WARN_PARSE_PRIVATE_INHERIT 309 #define WARN_PARSE_TEMPLATE_REPEAT 310 #define WARN_PARSE_TEMPLATE_PARTIAL 311 #define WARN_PARSE_UNNAMED_NESTED_CLASS 312 #define WARN_PARSE_UNDEFINED_EXTERN 313 #define WARN_PARSE_KEYWORD 314 #define WARN_PARSE_USING_UNDEF 315 #define WARN_PARSE_MODULE_REPEAT 316 #define WARN_PARSE_TEMPLATE_SP_UNDEF 317 #define WARN_PARSE_TEMPLATE_AMBIG 318 #define WARN_PARSE_NO_ACCESS 319 #define WARN_PARSE_EXPLICIT_TEMPLATE 320 #define WARN_PARSE_BUILTIN_NAME 321 #define WARN_PARSE_REDUNDANT 322 #define WARN_PARSE_REC_INHERITANCE 323 #define WARN_PARSE_NESTED_TEMPLATE 324 #define WARN_PARSE_NAMED_NESTED_CLASS 325 #define WARN_PARSE_EXTEND_NAME 326 #define WARN_CPP11_LAMBDA 340 #define WARN_CPP11_ALIAS_DECLARATION 341 #define WARN_CPP11_ALIAS_TEMPLATE 342 #define WARN_CPP11_VARIADIC_TEMPLATE 343 #define WARN_IGNORE_OPERATOR_NEW 350 /* new */ #define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */ #define WARN_IGNORE_OPERATOR_PLUS 352 /* + */ #define WARN_IGNORE_OPERATOR_MINUS 353 /* - */ #define WARN_IGNORE_OPERATOR_MUL 354 /* * */ #define WARN_IGNORE_OPERATOR_DIV 355 /* / */ #define WARN_IGNORE_OPERATOR_MOD 356 /* % */ #define WARN_IGNORE_OPERATOR_XOR 357 /* ^ */ #define WARN_IGNORE_OPERATOR_AND 358 /* & */ #define WARN_IGNORE_OPERATOR_OR 359 /* | */ #define WARN_IGNORE_OPERATOR_NOT 360 /* ~ */ #define WARN_IGNORE_OPERATOR_LNOT 361 /* ! */ #define WARN_IGNORE_OPERATOR_EQ 362 /* = */ #define WARN_IGNORE_OPERATOR_LT 363 /* < */ #define WARN_IGNORE_OPERATOR_GT 364 /* > */ #define WARN_IGNORE_OPERATOR_PLUSEQ 365 /* += */ #define WARN_IGNORE_OPERATOR_MINUSEQ 366 /* -= */ #define WARN_IGNORE_OPERATOR_MULEQ 367 /* *= */ #define WARN_IGNORE_OPERATOR_DIVEQ 368 /* /= */ #define WARN_IGNORE_OPERATOR_MODEQ 369 /* %= */ #define WARN_IGNORE_OPERATOR_XOREQ 370 /* ^= */ #define WARN_IGNORE_OPERATOR_ANDEQ 371 /* &= */ #define WARN_IGNORE_OPERATOR_OREQ 372 /* |= */ #define WARN_IGNORE_OPERATOR_LSHIFT 373 /* << */ #define WARN_IGNORE_OPERATOR_RSHIFT 374 /* >> */ #define WARN_IGNORE_OPERATOR_LSHIFTEQ 375 /* <<= */ #define WARN_IGNORE_OPERATOR_RSHIFTEQ 376 /* >>= */ #define WARN_IGNORE_OPERATOR_EQUALTO 377 /* == */ #define WARN_IGNORE_OPERATOR_NOTEQUAL 378 /* != */ #define WARN_IGNORE_OPERATOR_LTEQUAL 379 /* <= */ #define WARN_IGNORE_OPERATOR_GTEQUAL 380 /* >= */ #define WARN_IGNORE_OPERATOR_LAND 381 /* && */ #define WARN_IGNORE_OPERATOR_LOR 382 /* || */ #define WARN_IGNORE_OPERATOR_PLUSPLUS 383 /* ++ */ #define WARN_IGNORE_OPERATOR_MINUSMINUS 384 /* -- */ #define WARN_IGNORE_OPERATOR_COMMA 385 /* , */ #define WARN_IGNORE_OPERATOR_ARROWSTAR 386 /* ->* */ #define WARN_IGNORE_OPERATOR_ARROW 387 /* -> */ #define WARN_IGNORE_OPERATOR_CALL 388 /* () */ #define WARN_IGNORE_OPERATOR_INDEX 389 /* [] */ #define WARN_IGNORE_OPERATOR_UPLUS 390 /* + */ #define WARN_IGNORE_OPERATOR_UMINUS 391 /* - */ #define WARN_IGNORE_OPERATOR_UMUL 392 /* * */ #define WARN_IGNORE_OPERATOR_UAND 393 /* & */ #define WARN_IGNORE_OPERATOR_NEWARR 394 /* new [] */ #define WARN_IGNORE_OPERATOR_DELARR 395 /* delete [] */ #define WARN_IGNORE_OPERATOR_REF 396 /* operator *() */ /* 394-399 are reserved */ /* -- Type system and typemaps -- */ #define WARN_TYPE_UNDEFINED_CLASS 401 #define WARN_TYPE_INCOMPLETE 402 #define WARN_TYPE_ABSTRACT 403 #define WARN_TYPE_REDEFINED 404 #define WARN_TYPEMAP_SOURCETARGET 450 #define WARN_TYPEMAP_CHARLEAK 451 #define WARN_TYPEMAP_SWIGTYPE 452 #define WARN_TYPEMAP_APPLY_UNDEF 453 #define WARN_TYPEMAP_SWIGTYPELEAK 454 #define WARN_TYPEMAP_IN_UNDEF 460 #define WARN_TYPEMAP_OUT_UNDEF 461 #define WARN_TYPEMAP_VARIN_UNDEF 462 #define WARN_TYPEMAP_VAROUT_UNDEF 463 #define WARN_TYPEMAP_CONST_UNDEF 464 #define WARN_TYPEMAP_UNDEF 465 #define WARN_TYPEMAP_VAR_UNDEF 466 #define WARN_TYPEMAP_TYPECHECK 467 #define WARN_TYPEMAP_THROW 468 #define WARN_TYPEMAP_DIRECTORIN_UNDEF 469 #define WARN_TYPEMAP_THREAD_UNSAFE 470 /* mostly used in directorout typemaps */ #define WARN_TYPEMAP_DIRECTOROUT_UNDEF 471 #define WARN_TYPEMAP_TYPECHECK_UNDEF 472 #define WARN_TYPEMAP_DIRECTOROUT_PTR 473 #define WARN_TYPEMAP_OUT_OPTIMAL_IGNORED 474 #define WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE 475 #define WARN_TYPEMAP_INITIALIZER_LIST 476 #define WARN_TYPEMAP_DIRECTORTHROWS_UNDEF 477 /* -- Fragments -- */ #define WARN_FRAGMENT_NOT_FOUND 490 /* -- General code generation -- */ #define WARN_LANG_OVERLOAD_DECL 501 #define WARN_LANG_OVERLOAD_CONSTRUCT 502 #define WARN_LANG_IDENTIFIER 503 #define WARN_LANG_RETURN_TYPE 504 #define WARN_LANG_VARARGS 505 #define WARN_LANG_VARARGS_KEYWORD 506 #define WARN_LANG_NATIVE_UNIMPL 507 #define WARN_LANG_DEREF_SHADOW 508 #define WARN_LANG_OVERLOAD_SHADOW 509 #define WARN_LANG_FRIEND_IGNORE 510 #define WARN_LANG_OVERLOAD_KEYWORD 511 #define WARN_LANG_OVERLOAD_CONST 512 #define WARN_LANG_CLASS_UNNAMED 513 #define WARN_LANG_DIRECTOR_VDESTRUCT 514 #define WARN_LANG_DISCARD_CONST 515 #define WARN_LANG_OVERLOAD_IGNORED 516 #define WARN_LANG_DIRECTOR_ABSTRACT 517 #define WARN_LANG_PORTABILITY_FILENAME 518 #define WARN_LANG_TEMPLATE_METHOD_IGNORE 519 #define WARN_LANG_SMARTPTR_MISSING 520 #define WARN_LANG_ILLEGAL_DESTRUCTOR 521 #define WARN_LANG_EXTEND_CONSTRUCTOR 522 #define WARN_LANG_EXTEND_DESTRUCTOR 523 /* -- Reserved (600-799) -- */ /* -- Language module specific warnings (700 - 899) -- */ /* Feel free to claim any number in this space that's not currently being used. Just make sure you add an entry here */ #define WARN_D_TYPEMAP_CTYPE_UNDEF 700 #define WARN_D_TYPEMAP_IMTYPE_UNDEF 701 #define WARN_D_TYPEMAP_DTYPE_UNDEF 702 #define WARN_D_MULTIPLE_INHERITANCE 703 #define WARN_D_TYPEMAP_CLASSMOD_UNDEF 704 #define WARN_D_TYPEMAP_DBODY_UNDEF 705 #define WARN_D_TYPEMAP_DOUT_UNDEF 706 #define WARN_D_TYPEMAP_DIN_UNDEF 707 #define WARN_D_TYPEMAP_DDIRECTORIN_UNDEF 708 #define WARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF 709 #define WARN_D_EXCODE_MISSING 710 #define WARN_D_CANTHROW_MISSING 711 #define WARN_D_NO_DIRECTORCONNECT_ATTR 712 #define WARN_D_NAME_COLLISION 713 /* please leave 700-719 free for D */ #define WARN_RUBY_WRONG_NAME 801 #define WARN_RUBY_MULTIPLE_INHERITANCE 802 /* please leave 800-809 free for Ruby */ #define WARN_JAVA_TYPEMAP_JNI_UNDEF 810 #define WARN_JAVA_TYPEMAP_JTYPE_UNDEF 811 #define WARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812 #define WARN_JAVA_MULTIPLE_INHERITANCE 813 #define WARN_JAVA_TYPEMAP_GETCPTR_UNDEF 814 #define WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF 815 #define WARN_JAVA_TYPEMAP_JAVABODY_UNDEF 816 #define WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF 817 #define WARN_JAVA_TYPEMAP_JAVAIN_UNDEF 818 #define WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF 819 #define WARN_JAVA_TYPEMAP_JAVADIRECTOROUT_UNDEF 820 #define WARN_JAVA_COVARIANT_RET 822 #define WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF 823 #define WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824 #define WARN_JAVA_NO_DIRECTORCONNECT_ATTR 825 #define WARN_JAVA_NSPACE_WITHOUT_PACKAGE 826 /* please leave 810-829 free for Java */ #define WARN_CSHARP_TYPEMAP_CTYPE_UNDEF 830 #define WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF 831 #define WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF 832 #define WARN_CSHARP_MULTIPLE_INHERITANCE 833 #define WARN_CSHARP_TYPEMAP_GETCPTR_UNDEF 834 #define WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF 835 #define WARN_CSHARP_TYPEMAP_CSBODY_UNDEF 836 #define WARN_CSHARP_TYPEMAP_CSOUT_UNDEF 837 #define WARN_CSHARP_TYPEMAP_CSIN_UNDEF 838 #define WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF 839 #define WARN_CSHARP_TYPEMAP_CSDIRECTOROUT_UNDEF 840 #define WARN_CSHARP_COVARIANT_RET 842 #define WARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF 843 #define WARN_CSHARP_EXCODE 844 #define WARN_CSHARP_CANTHROW 845 #define WARN_CSHARP_NO_DIRECTORCONNECT_ATTR 846 /* please leave 830-849 free for C# */ #define WARN_MODULA3_TYPEMAP_TYPE_UNDEF 850 #define WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF 851 #define WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF 852 #define WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF 853 #define WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN 854 #define WARN_MODULA3_MULTIPLE_INHERITANCE 855 #define WARN_MODULA3_TYPECONSTRUCTOR_UNKNOWN 856 #define WARN_MODULA3_UNKNOWN_PRAGMA 857 #define WARN_MODULA3_BAD_ENUMERATION 858 #define WARN_MODULA3_DOUBLE_ID 859 #define WARN_MODULA3_BAD_IMPORT 860 /* please leave 850-869 free for Modula 3 */ #define WARN_PHP_MULTIPLE_INHERITANCE 870 #define WARN_PHP_UNKNOWN_PRAGMA 871 #define WARN_PHP_PUBLIC_BASE 872 /* please leave 870-889 free for PHP */ #define WARN_GO_NAME_CONFLICT 890 /* please leave 890-899 free for Go */ /* -- User defined warnings (900 - 999) -- */ #endif swig-3.0.2/Source/Modules/0000775000175000017500000000000012343605122015213 5ustar williamwilliamswig-3.0.2/Source/Modules/README0000664000175000017500000000047212343605122016076 0ustar williamwilliam06/25/2002 This directory contains all of the SWIG language modules. Many of these modules contain code that dates back to SWIG1.0. The module API has changed a lot in the development releases so this is fairly messy. We're working on cleaning it up, but you'll have to bear with us until it's done. -- Dave swig-3.0.2/Source/Modules/clisp.cxx0000664000175000017500000003202212343605122017050 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * clisp.cxx * * clisp language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" static const char *usage = "\ CLISP Options (available with -clisp)\n\ -extern-all - Create clisp definitions for all the functions and\n\ global variables otherwise only definitions for\n\ externed functions and variables are created.\n\ -generate-typedef - Use def-c-type to generate shortcuts according to the\n\ typedefs in the input.\n\ "; class CLISP:public Language { public: File *f_cl; String *module; virtual void main(int argc, char *argv[]); virtual int top(Node *n); virtual int functionWrapper(Node *n); virtual int variableWrapper(Node *n); virtual int constantWrapper(Node *n); virtual int classDeclaration(Node *n); virtual int enumDeclaration(Node *n); virtual int typedefHandler(Node *n); List *entries; private: String *get_ffi_type(Node *n, SwigType *ty); String *convert_literal(String *num_param, String *type); String *strip_parens(String *string); int extern_all_flag; int generate_typedef_flag; int is_function; }; void CLISP::main(int argc, char *argv[]) { int i; Preprocessor_define("SWIGCLISP 1", 0); SWIG_library_directory("clisp"); SWIG_config_file("clisp.swg"); generate_typedef_flag = 0; extern_all_flag = 0; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-help")) { Printf(stdout, "%s\n", usage); } else if ((Strcmp(argv[i], "-extern-all") == 0)) { extern_all_flag = 1; Swig_mark_arg(i); } else if ((Strcmp(argv[i], "-generate-typedef") == 0)) { generate_typedef_flag = 1; Swig_mark_arg(i); } } } int CLISP::top(Node *n) { File *f_null = NewString(""); module = Getattr(n, "name"); String *output_filename; entries = NewList(); /* Get the output file name */ String *outfile = Getattr(n, "outfile"); if (!outfile) { Printf(stderr, "Unable to determine outfile\n"); SWIG_exit(EXIT_FAILURE); } output_filename = NewStringf("%s%s.lisp", SWIG_output_directory(), module); f_cl = NewFile(output_filename, "w+", SWIG_output_files()); if (!f_cl) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); } Swig_register_filebyname("header", f_null); Swig_register_filebyname("begin", f_null); Swig_register_filebyname("runtime", f_null); Swig_register_filebyname("wrapper", f_null); String *header = NewString(""); Swig_banner_target_lang(header, ";;"); Printf(header, "\n(defpackage :%s\n (:use :common-lisp :ffi)", module); Language::top(n); Iterator i; long len = Len(entries); if (len > 0) { Printf(header, "\n (:export"); } //else nothing to export for (i = First(entries); i.item; i = Next(i)) { Printf(header, "\n\t:%s", i.item); } if (len > 0) { Printf(header, ")"); } Printf(header, ")\n"); Printf(header, "\n(in-package :%s)\n", module); Printf(header, "\n(default-foreign-language :stdc)\n"); len = Tell(f_cl); Printf(f_cl, "%s", header); long end = Tell(f_cl); for (len--; len >= 0; len--) { end--; (void)Seek(f_cl, len, SEEK_SET); int ch = Getc(f_cl); (void)Seek(f_cl, end, SEEK_SET); Putc(ch, f_cl); } Seek(f_cl, 0, SEEK_SET); Write(f_cl, Char(header), Len(header)); Delete(f_cl); return SWIG_OK; } int CLISP::functionWrapper(Node *n) { is_function = 1; String *storage = Getattr(n, "storage"); if (!extern_all_flag && (!storage || (!Swig_storage_isextern(n) && !Swig_storage_isexternc(n)))) return SWIG_OK; String *func_name = Getattr(n, "sym:name"); ParmList *pl = Getattr(n, "parms"); int argnum = 0, first = 1; Printf(f_cl, "\n(ffi:def-call-out %s\n\t(:name \"%s\")\n", func_name, func_name); Append(entries, func_name); if (ParmList_len(pl) != 0) { Printf(f_cl, "\t(:arguments "); } for (Parm *p = pl; p; p = nextSibling(p), argnum++) { String *argname = Getattr(p, "name"); // SwigType *argtype; String *ffitype = get_ffi_type(n, Getattr(p, "type")); int tempargname = 0; if (!argname) { argname = NewStringf("arg%d", argnum); tempargname = 1; } if (!first) { Printf(f_cl, "\n\t\t"); } Printf(f_cl, "(%s %s)", argname, ffitype); first = 0; Delete(ffitype); if (tempargname) Delete(argname); } if (ParmList_len(pl) != 0) { Printf(f_cl, ")\n"); /* finish arg list */ } String *ffitype = get_ffi_type(n, Getattr(n, "type")); if (Strcmp(ffitype, "NIL")) { //when return type is not nil Printf(f_cl, "\t(:return-type %s)\n", ffitype); } Printf(f_cl, "\t(:library +library-name+))\n"); return SWIG_OK; } int CLISP::constantWrapper(Node *n) { is_function = 0; String *type = Getattr(n, "type"); String *converted_value = convert_literal(Getattr(n, "value"), type); String *name = Getattr(n, "sym:name"); Printf(f_cl, "\n(defconstant %s %s)\n", name, converted_value); Append(entries, name); Delete(converted_value); return SWIG_OK; } int CLISP::variableWrapper(Node *n) { is_function = 0; String *storage = Getattr(n, "storage"); if (!extern_all_flag && (!storage || (!Swig_storage_isextern(n) && !Swig_storage_isexternc(n)))) return SWIG_OK; String *var_name = Getattr(n, "sym:name"); String *lisp_type = get_ffi_type(n, Getattr(n, "type")); Printf(f_cl, "\n(ffi:def-c-var %s\n (:name \"%s\")\n (:type %s)\n", var_name, var_name, lisp_type); Printf(f_cl, "\t(:library +library-name+))\n"); Append(entries, var_name); Delete(lisp_type); return SWIG_OK; } int CLISP::typedefHandler(Node *n) { if (generate_typedef_flag) { is_function = 0; Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(n, Getattr(n, "type"))); } return Language::typedefHandler(n); } int CLISP::enumDeclaration(Node *n) { is_function = 0; String *name = Getattr(n, "sym:name"); Printf(f_cl, "\n(ffi:def-c-enum %s ", name); for (Node *c = firstChild(n); c; c = nextSibling(c)) { String *slot_name = Getattr(c, "name"); String *value = Getattr(c, "enumvalue"); Printf(f_cl, "(%s %s)", slot_name, value); Append(entries, slot_name); Delete(value); } Printf(f_cl, ")\n"); return SWIG_OK; } // Includes structs int CLISP::classDeclaration(Node *n) { is_function = 0; String *name = Getattr(n, "sym:name"); String *kind = Getattr(n, "kind"); if (Strcmp(kind, "struct")) { Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind); Printf(stderr, " (name: %s)\n", name); SWIG_exit(EXIT_FAILURE); } Printf(f_cl, "\n(ffi:def-c-struct %s", name); Append(entries, NewStringf("make-%s", name)); for (Node *c = firstChild(n); c; c = nextSibling(c)) { if (Strcmp(nodeType(c), "cdecl")) { Printf(stderr, "Structure %s has a slot that we can't deal with.\n", name); Printf(stderr, "nodeType: %s, name: %s, type: %s\n", nodeType(c), Getattr(c, "name"), Getattr(c, "type")); SWIG_exit(EXIT_FAILURE); } String *temp = Copy(Getattr(c, "decl")); if (temp) { Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type String *lisp_type = get_ffi_type(n, temp); Delete(temp); String *slot_name = Getattr(c, "sym:name"); Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type); Append(entries, NewStringf("%s-%s", name, slot_name)); Delete(lisp_type); } } Printf(f_cl, ")\n"); /* Add this structure to the known lisp types */ //Printf(stdout, "Adding %s foreign type\n", name); // add_defined_foreign_type(name); return SWIG_OK; } /* utilities */ /* returns new string w/ parens stripped */ String *CLISP::strip_parens(String *string) { char *s = Char(string), *p; int len = Len(string); String *res; if (len == 0 || s[0] != '(' || s[len - 1] != ')') { return NewString(string); } p = (char *) malloc(len - 2 + 1); if (!p) { Printf(stderr, "Malloc failed\n"); SWIG_exit(EXIT_FAILURE); } strncpy(p, s + 1, len - 1); p[len - 2] = 0; /* null terminate */ res = NewString(p); free(p); return res; } String *CLISP::convert_literal(String *num_param, String *type) { String *num = strip_parens(num_param), *res; char *s = Char(num); /* Make sure doubles use 'd' instead of 'e' */ if (!Strcmp(type, "double")) { String *updated = Copy(num); if (Replace(updated, "e", "d", DOH_REPLACE_ANY) > 1) { Printf(stderr, "Weird!! number %s looks invalid.\n", num); SWIG_exit(EXIT_FAILURE); } Delete(num); return updated; } if (SwigType_type(type) == T_CHAR) { /* Use CL syntax for character literals */ return NewStringf("#\\%s", num_param); } else if (SwigType_type(type) == T_STRING) { /* Use CL syntax for string literals */ return NewStringf("\"%s\"", num_param); } if (Len(num) < 2 || s[0] != '0') { return num; } /* octal or hex */ res = NewStringf("#%c%s", s[1] == 'x' ? 'x' : 'o', s + 2); Delete(num); return res; } String *CLISP::get_ffi_type(Node *n, SwigType *ty) { Node *node = NewHash(); Setattr(node, "type", ty); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup("in", node, "", 0); Delete(node); if (tm) { return NewString(tm); } else if (SwigType_ispointer(ty)) { SwigType *cp = Copy(ty); SwigType_del_pointer(cp); String *inner_type = get_ffi_type(n, cp); if (SwigType_isfunction(cp)) { return inner_type; } SwigType *base = SwigType_base(ty); String *base_name = SwigType_str(base, 0); String *str; if (!Strcmp(base_name, "int") || !Strcmp(base_name, "float") || !Strcmp(base_name, "short") || !Strcmp(base_name, "double") || !Strcmp(base_name, "long") || !Strcmp(base_name, "char")) { str = NewStringf("(ffi:c-ptr %s)", inner_type); } else { str = NewStringf("(ffi:c-pointer %s)", inner_type); } Delete(base_name); Delete(base); Delete(cp); Delete(inner_type); return str; } else if (SwigType_isarray(ty)) { SwigType *cp = Copy(ty); String *array_dim = SwigType_array_getdim(ty, 0); if (!Strcmp(array_dim, "")) { //dimension less array convert to pointer Delete(array_dim); SwigType_del_array(cp); SwigType_add_pointer(cp); String *str = get_ffi_type(n, cp); Delete(cp); return str; } else { SwigType_pop_arrays(cp); String *inner_type = get_ffi_type(n, cp); Delete(cp); int ndim = SwigType_array_ndim(ty); String *dimension; if (ndim == 1) { dimension = array_dim; } else { dimension = array_dim; for (int i = 1; i < ndim; i++) { array_dim = SwigType_array_getdim(ty, i); Append(dimension, " "); Append(dimension, array_dim); Delete(array_dim); } String *temp = dimension; dimension = NewStringf("(%s)", dimension); Delete(temp); } String *str; if (is_function) str = NewStringf("(ffi:c-ptr (ffi:c-array %s %s))", inner_type, dimension); else str = NewStringf("(ffi:c-array %s %s)", inner_type, dimension); Delete(inner_type); Delete(dimension); return str; } } else if (SwigType_isfunction(ty)) { SwigType *cp = Copy(ty); SwigType *fn = SwigType_pop_function(cp); String *args = NewString(""); ParmList *pl = SwigType_function_parms(fn, n); if (ParmList_len(pl) != 0) { Printf(args, "(:arguments "); } int argnum = 0, first = 1; for (Parm *p = pl; p; p = nextSibling(p), argnum++) { String *argname = Getattr(p, "name"); SwigType *argtype = Getattr(p, "type"); String *ffitype = get_ffi_type(n, argtype); int tempargname = 0; if (!argname) { argname = NewStringf("arg%d", argnum); tempargname = 1; } if (!first) { Printf(args, "\n\t\t"); } Printf(args, "(%s %s)", argname, ffitype); first = 0; Delete(ffitype); if (tempargname) Delete(argname); } if (ParmList_len(pl) != 0) { Printf(args, ")\n"); /* finish arg list */ } String *ffitype = get_ffi_type(n, cp); String *str = NewStringf("(ffi:c-function %s \t\t\t\t(:return-type %s))", args, ffitype); Delete(fn); Delete(args); Delete(cp); Delete(ffitype); return str; } String *str = SwigType_str(ty, 0); if (str) { char *st = Strstr(str, "struct"); if (st) { st += 7; return NewString(st); } char *cl = Strstr(str, "class"); if (cl) { cl += 6; return NewString(cl); } } return str; } extern "C" Language *swig_clisp(void) { return new CLISP(); } swig-3.0.2/Source/Modules/cffi.cxx0000664000175000017500000010100612343605122016644 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * cffi.cxx * * cffi language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" #include //#define CFFI_DEBUG //#define CFFI_WRAP_DEBUG static const char *usage = "\ CFFI Options (available with -cffi)\n\ -generate-typedef - Use defctype to generate shortcuts according to the\n\ typedefs in the input.\n\ -[no]cwrap - Turn on or turn off generation of an intermediate C\n\ file when creating a C interface. By default this is\n\ only done for C++ code.\n\ -[no]swig-lisp - Turn on or off generation of code for helper lisp\n\ macro, functions, etc. which SWIG uses while\n\ generating wrappers. These macros, functions may still\n\ be used by generated wrapper code.\n\ "; class CFFI:public Language { public: String *f_cl; String *f_clhead; String *f_clwrap; bool CWrap; // generate wrapper file for C code? File *f_begin; File *f_runtime; File *f_cxx_header; File *f_cxx_wrapper; File *f_clos; String *module; virtual void main(int argc, char *argv[]); virtual int top(Node *n); virtual int functionWrapper(Node *n); virtual int variableWrapper(Node *n); virtual int constantWrapper(Node *n); // virtual int classDeclaration(Node *n); virtual int enumDeclaration(Node *n); virtual int typedefHandler(Node *n); //c++ specific code virtual int constructorHandler(Node *n); virtual int destructorHandler(Node *n); virtual int memberfunctionHandler(Node *n); virtual int membervariableHandler(Node *n); virtual int classHandler(Node *n); private: void emit_defun(Node *n, String *name); void emit_defmethod(Node *n); void emit_initialize_instance(Node *n); void emit_getter(Node *n); void emit_setter(Node *n); void emit_class(Node *n); void emit_struct_union(Node *n, bool un); void emit_export(Node *n, String *name); void emit_inline(Node *n, String *name); String *lispy_name(char *name); String *lispify_name(Node *n, String *ty, const char *flag, bool kw = false); String *convert_literal(String *num_param, String *type, bool try_to_split = true); String *infix_to_prefix(String *val, char split_op, const String *op, String *type); String *strip_parens(String *string); String *trim(String *string); int generate_typedef_flag; bool no_swig_lisp; }; void CFFI::main(int argc, char *argv[]) { int i; Preprocessor_define("SWIGCFFI 1", 0); SWIG_library_directory("cffi"); SWIG_config_file("cffi.swg"); generate_typedef_flag = 0; no_swig_lisp = false; CWrap = false; for (i = 1; i < argc; i++) { if (!Strcmp(argv[i], "-help")) { Printf(stdout, "%s\n", usage); } else if (!strcmp(argv[i], "-cwrap")) { CWrap = true; Swig_mark_arg(i); } else if ((Strcmp(argv[i], "-generate-typedef") == 0)) { generate_typedef_flag = 1; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-nocwrap")) { CWrap = false; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-swig-lisp")) { no_swig_lisp = false; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-noswig-lisp")) { no_swig_lisp = true; Swig_mark_arg(i); } } f_clhead = NewString(""); f_clwrap = NewString(""); f_cl = NewString(""); allow_overloading(); } int CFFI::top(Node *n) { File *f_null = NewString(""); module = Getattr(n, "name"); String *cxx_filename = Getattr(n, "outfile"); String *lisp_filename = NewString(""); Printf(lisp_filename, "%s%s.lisp", SWIG_output_directory(), module); File *f_lisp = NewFile(lisp_filename, "w", SWIG_output_files()); if (!f_lisp) { FileErrorDisplay(lisp_filename); SWIG_exit(EXIT_FAILURE); } if (CPlusPlus || CWrap) { f_begin = NewFile(cxx_filename, "w", SWIG_output_files()); if (!f_begin) { Delete(f_lisp); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); SWIG_exit(EXIT_FAILURE); } String *clos_filename = NewString(""); Printf(clos_filename, "%s%s-clos.lisp", SWIG_output_directory(), module); f_clos = NewFile(clos_filename, "w", SWIG_output_files()); if (!f_clos) { Delete(f_lisp); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); SWIG_exit(EXIT_FAILURE); } } else { f_begin = NewString(""); f_clos = NewString(""); } f_runtime = NewString(""); f_cxx_header = f_runtime; f_cxx_wrapper = NewString(""); Swig_register_filebyname("header", f_cxx_header); Swig_register_filebyname("wrapper", f_cxx_wrapper); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("lisphead", f_clhead); if (!no_swig_lisp) Swig_register_filebyname("swiglisp", f_cl); else Swig_register_filebyname("swiglisp", f_null); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGCFFI\n"); Printf(f_runtime, "\n"); Swig_banner_target_lang(f_lisp, ";;;"); Language::top(n); Printf(f_lisp, "%s\n", f_clhead); Printf(f_lisp, "%s\n", f_cl); Printf(f_lisp, "%s\n", f_clwrap); Delete(f_lisp); Delete(f_cl); Delete(f_clhead); Delete(f_clwrap); Dump(f_runtime, f_begin); Delete(f_runtime); Delete(f_begin); Delete(f_cxx_wrapper); Delete(f_null); return SWIG_OK; } int CFFI::classHandler(Node *n) { #ifdef CFFI_DEBUG Printf(stderr, "class %s::%s\n", "some namespace", //current_namespace, Getattr(n, "sym:name")); #endif String *name = Getattr(n, "sym:name"); String *kind = Getattr(n, "kind"); // maybe just remove this check and get rid of the else clause below. if (Strcmp(kind, "struct") == 0) { emit_struct_union(n, false); return SWIG_OK; } else if (Strcmp(kind, "union") == 0) { emit_struct_union(n, true); return SWIG_OK; } else if (Strcmp(kind, "class") == 0) { emit_class(n); Language::classHandler(n); } else { Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind); Printf(stderr, " (name: %s)\n", name); SWIG_exit(EXIT_FAILURE); return SWIG_OK; } return SWIG_OK; } int CFFI::constructorHandler(Node *n) { #ifdef CFFI_DEBUG Printf(stderr, "constructor %s\n", Getattr(n, "name")); Printf(stderr, "constructor %s\n and %s and %s", Getattr(n, "kind"), Getattr(n, "sym:name"), Getattr(n, "allegrocl:old-sym:name")); #endif Setattr(n, "cffi:constructorfunction", "1"); // Let SWIG generate a global forwarding function. return Language::constructorHandler(n); } int CFFI::destructorHandler(Node *n) { #ifdef CFFI_DEBUG Printf(stderr, "destructor %s\n", Getattr(n, "name")); #endif // Let SWIG generate a global forwarding function. return Language::destructorHandler(n); } void CFFI::emit_defmethod(Node *n) { String *args_placeholder = NewStringf(""); String *args_call = NewStringf(""); ParmList *pl = Getattr(n, "parms"); int argnum = 0; Node *parent = getCurrentClass(); bool first = 0; for (Parm *p = pl; p; p = nextSibling(p), argnum++) { String *argname = Getattr(p, "name"); String *ffitype = Swig_typemap_lookup("lispclass", p, "", 0); int tempargname = 0; if(!first) first = true; else Printf(args_placeholder, " "); if (!argname) { argname = NewStringf("arg%d", argnum); tempargname = 1; } else if (Strcmp(argname, "t") == 0 || Strcmp(argname, "T") == 0) { argname = NewStringf("t-arg%d", argnum); tempargname = 1; } if (Len(ffitype) > 0) Printf(args_placeholder, "(%s %s)", argname, ffitype); else Printf(args_placeholder, "%s", argname); if (ffitype && Strcmp(ffitype, lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'classname")) == 0) Printf(args_call, " (ff-pointer %s)", argname); else Printf(args_call, " %s", argname); Delete(ffitype); if (tempargname) Delete(argname); } String *method_name = Getattr(n, "name"); int x = Replace(method_name, "operator ", "", DOH_REPLACE_FIRST); // if (x == 1) Printf(f_clos, "(cl:shadow \"%s\")\n", method_name); Printf(f_clos, "(cl:defmethod %s (%s)\n (%s%s))\n\n", lispify_name(n, lispy_name(Char(method_name)), "'method"), args_placeholder, lispify_name(n, Getattr(n, "sym:name"), "'function"), args_call); } void CFFI::emit_initialize_instance(Node *n) { String *args_placeholder = NewStringf(""); String *args_call = NewStringf(""); ParmList *pl = Getattr(n, "parms"); int argnum = 0; Node *parent = getCurrentClass(); for (Parm *p = pl; p; p = nextSibling(p), argnum++) { String *argname = Getattr(p, "name"); String *ffitype = Swig_typemap_lookup("lispclass", p, "", 0); int tempargname = 0; if (!argname) { argname = NewStringf("arg%d", argnum); tempargname = 1; } else if (Strcmp(argname, "t") == 0 || Strcmp(argname, "T") == 0) { argname = NewStringf("t-arg%d", argnum); tempargname = 1; } if (Len(ffitype) > 0) Printf(args_placeholder, " (%s %s)", argname, ffitype); else Printf(args_placeholder, " %s", argname); if (ffitype && Strcmp(ffitype, lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'classname")) == 0) Printf(args_call, " (ff-pointer %s)", argname); else Printf(args_call, " %s", argname); Delete(ffitype); if (tempargname) Delete(argname); } Printf(f_clos, "(cl:defmethod initialize-instance :after ((obj %s) &key%s)\n (setf (slot-value obj 'ff-pointer) (%s%s)))\n\n", lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), args_placeholder, lispify_name(n, Getattr(n, "sym:name"), "'function"), args_call); } void CFFI::emit_setter(Node *n) { Node *parent = getCurrentClass(); Printf(f_clos, "(cl:defmethod (cl:setf %s) (arg0 (obj %s))\n (%s (ff-pointer obj) arg0))\n\n", lispify_name(n, Getattr(n, "name"), "'method"), lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); } void CFFI::emit_getter(Node *n) { Node *parent = getCurrentClass(); Printf(f_clos, "(cl:defmethod %s ((obj %s))\n (%s (ff-pointer obj)))\n\n", lispify_name(n, Getattr(n, "name"), "'method"), lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); } int CFFI::memberfunctionHandler(Node *n) { // Let SWIG generate a global forwarding function. Setattr(n, "cffi:memberfunction", "1"); return Language::memberfunctionHandler(n); } int CFFI::membervariableHandler(Node *n) { // Let SWIG generate a get/set function pair. Setattr(n, "cffi:membervariable", "1"); return Language::membervariableHandler(n); } int CFFI::functionWrapper(Node *n) { ParmList *parms = Getattr(n, "parms"); String *iname = Getattr(n, "sym:name"); Wrapper *f = NewWrapper(); String *raw_return_type = Swig_typemap_lookup("ctype", n, "", 0); SwigType *return_type = Swig_cparse_type(raw_return_type); SwigType *resolved = SwigType_typedef_resolve_all(return_type); int is_void_return = (Cmp(resolved, "void") == 0); Delete(resolved); if (!is_void_return) { String *lresult_init = NewStringf("lresult = (%s)0", raw_return_type); Wrapper_add_localv(f, "lresult", raw_return_type, lresult_init, NIL); Delete(lresult_init); } String *overname = 0; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) { DelWrapper(f); return SWIG_ERROR; } } String *wname = Swig_name_wrapper(iname); if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); // Emit all of the local variables for holding arguments. emit_parameter_variables(parms, f); // Attach the standard typemaps Swig_typemap_attach_parms("ctype", parms, f); emit_attach_parmmaps(parms, f); int num_arguments = emit_num_arguments(parms); String *name_and_parms = NewStringf("%s (", wname); int i; Parm *p; int gencomma = 0; #ifdef CFFI_DEBUG Printf(stderr, "function - %s - %d\n", Getattr(n, "name"), num_arguments); #endif for (i = 0, p = parms; i < num_arguments; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *c_parm_type = Swig_cparse_type(Getattr(p, "tmap:ctype")); String *arg = NewStringf("l%s", Getattr(p, "lname")); // Emit parameter declaration if (gencomma) Printf(name_and_parms, ", "); String *parm_decl = SwigType_str(c_parm_type, arg); Printf(name_and_parms, "%s", parm_decl); #ifdef CFFI_DEBUG Printf(stderr, " param: %s\n", parm_decl); #endif Delete(parm_decl); gencomma = 1; // Emit parameter conversion code String *parm_code = Getattr(p, "tmap:in"); { Replaceall(parm_code, "$input", arg); Setattr(p, "emit:input", arg); Printf(f->code, "%s\n", parm_code); p = Getattr(p, "tmap:in:next"); } Delete(arg); } Printf(name_and_parms, ")"); // Emit the function definition String *signature = SwigType_str(return_type, name_and_parms); Printf(f->def, "EXPORT %s {", signature); Printf(f->code, " try {\n"); String *actioncode = emit_action(n); String *result_convert = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode); if (result_convert) { Replaceall(result_convert, "$result", "lresult"); Printf(f->code, "%s\n", result_convert); if(!is_void_return) Printf(f->code, " return lresult;\n"); Delete(result_convert); } emit_return_variable(n, Getattr(n, "type"), f); Printf(f->code, " } catch (...) {\n"); if (!is_void_return) Printf(f->code, " return (%s)0;\n", raw_return_type); Printf(f->code, " }\n"); Printf(f->code, "}\n"); if (CPlusPlus) Wrapper_print(f, f_runtime); if (CPlusPlus) { emit_defun(n, wname); if (Getattr(n, "cffi:memberfunction")) emit_defmethod(n); else if (Getattr(n, "cffi:membervariable")) { if (Getattr(n, "memberget")) emit_getter(n); else if (Getattr(n, "memberset")) emit_setter(n); } else if (Getattr(n, "cffi:constructorfunction")) { emit_initialize_instance(n); } } else emit_defun(n, iname); // if (!overloaded || !Getattr(n, "sym:nextSibling")) { // update_package_if_needed(n); // emit_buffered_defuns(n); // // this is the last overload. // if (overloaded) { // emit_dispatch_defun(n); // } // } Delete(wname); DelWrapper(f); return SWIG_OK; } void CFFI::emit_defun(Node *n, String *name) { String *func_name = Getattr(n, "sym:name"); ParmList *pl = Getattr(n, "parms"); int argnum = 0; func_name = lispify_name(n, func_name, "'function"); emit_inline(n, func_name); Printf(f_cl, "\n(cffi:defcfun (\"%s\" %s)", name, func_name); String *ffitype = Swig_typemap_lookup("cout", n, ":pointer", 0); Printf(f_cl, " %s", ffitype); Delete(ffitype); for (Parm *p = pl; p; p = nextSibling(p), argnum++) { if (SwigType_isvarargs(Getattr(p, "type"))) { Printf(f_cl, "\n %s", NewString("&rest")); continue; } String *argname = Getattr(p, "name"); ffitype = Swig_typemap_lookup("cin", p, "", 0); int tempargname = 0; if (!argname) { argname = NewStringf("arg%d", argnum); tempargname = 1; } else if (Strcmp(argname, "t") == 0 || Strcmp(argname, "T") == 0) { argname = NewStringf("t_arg%d", argnum); tempargname = 1; } Printf(f_cl, "\n (%s %s)", argname, ffitype); Delete(ffitype); if (tempargname) Delete(argname); } Printf(f_cl, ")\n"); /* finish arg list */ emit_export(n, func_name); } int CFFI::constantWrapper(Node *n) { String *type = Getattr(n, "type"); String *converted_value; if (SwigType_type(type) == T_STRING) { converted_value = NewString(Getattr(n, "rawval")); } else { converted_value = convert_literal(Getattr(n, "value"), type); } String *name = lispify_name(n, Getattr(n, "sym:name"), "'constant"); if (Strcmp(name, "t") == 0 || Strcmp(name, "T") == 0) name = NewStringf("t_var"); Printf(f_cl, "\n(cl:defconstant %s %s)\n", name, converted_value); Delete(converted_value); emit_export(n, name); return SWIG_OK; } int CFFI::variableWrapper(Node *n) { String *var_name = Getattr(n, "sym:name"); String *lisp_type = Swig_typemap_lookup("cin", n, "", 0); String *lisp_name = lispify_name(n, var_name, "'variable"); if (Strcmp(lisp_name, "t") == 0 || Strcmp(lisp_name, "T") == 0) lisp_name = NewStringf("t_var"); Printf(f_cl, "\n(cffi:defcvar (\"%s\" %s)\n %s)\n", var_name, lisp_name, lisp_type); Delete(lisp_type); emit_export(n, lisp_name); return SWIG_OK; } int CFFI::typedefHandler(Node *n) { if (generate_typedef_flag && strncmp(Char(Getattr(n, "type")), "enum", 4)) { String *lisp_name = lispify_name(n, Getattr(n, "name"), "'typename"); Printf(f_cl, "\n(cffi:defctype %s %s)\n", lisp_name, Swig_typemap_lookup("cin", n, "", 0)); emit_export(n, lisp_name); } return Language::typedefHandler(n); } int CFFI::enumDeclaration(Node *n) { String *name = Getattr(n, "sym:name"); bool slot_name_keywords; String *lisp_name = 0; if (name && Len(name) != 0) { lisp_name = lispify_name(n, name, "'enumname"); if (GetFlag(n, "feature:bitfield")) { Printf(f_cl, "\n(cffi:defbitfield %s", lisp_name); } else { Printf(f_cl, "\n(cffi:defcenum %s", lisp_name); } slot_name_keywords = true; //Registering the enum name to the cin and cout typemaps Parm *pattern = NewParm(name, NULL, n); Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL); Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL); Delete(pattern); //Registering with the kind, i.e., enum pattern = NewParm(NewStringf("enum %s", name), NULL, n); Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL); Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL); Delete(pattern); } else { Printf(f_cl, "\n(defanonenum %s", name); slot_name_keywords = false; } for (Node *c = firstChild(n); c; c = nextSibling(c)) { String *slot_name = lispify_name(c, Getattr(c, "name"), "'enumvalue", slot_name_keywords); String *value = Getattr(c, "enumvalue"); if (!value || GetFlag(n, "feature:bitfield:ignore_values")) Printf(f_cl, "\n\t%s", slot_name); else { String *type = Getattr(c, "type"); String *converted_value = convert_literal(value, type); Printf(f_cl, "\n\t(%s #.%s)", slot_name, converted_value); Delete(converted_value); } Delete(value); } Printf(f_cl, ")\n"); // No need to export keywords if (lisp_name && Len(lisp_name) != 0) { emit_export(n, lisp_name); } else { for (Node *c = firstChild(n); c; c = nextSibling(c)) emit_export(c, lispify_name(c, Getattr(c, "name"), "'enumvalue")); } return SWIG_OK; } void CFFI::emit_class(Node *n) { #ifdef CFFI_WRAP_DEBUG Printf(stderr, "emit_class: ENTER... '%s'(%p)\n", Getattr(n, "sym:name"), n); #endif String *name = Getattr(n, "sym:name"); String *lisp_name = lispify_name(n, lispy_name(Char(name)), "'classname"); String *bases = Getattr(n, "bases"); String *supers = NewString("("); if (bases) { int first = 1; for (Iterator i = First(bases); i.item; i = Next(i)) { if (!first) Printf(supers, " "); String *s = Getattr(i.item, "name"); Printf(supers, "%s", lispify_name(i.item, lispy_name(Char(s)), "'classname")); } } else { // Printf(supers,"ff:foreign-pointer"); } Printf(supers, ")"); Printf(f_clos, "\n(cl:defclass %s%s", lisp_name, supers); Printf(f_clos, "\n ((ff-pointer :reader ff-pointer)))\n\n"); Parm *pattern = NewParm(Getattr(n, "name"), NULL, n); Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL); SwigType_add_pointer(Getattr(pattern, "type")); Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL); SwigType_add_qualifier(Getattr(pattern, "type"), "const"); Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL); SwigType_del_pointer(Getattr(pattern, "type")); SwigType_add_reference(Getattr(pattern, "type")); Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL); #ifdef CFFI_WRAP_DEBUG Printf(stderr, " pattern %s name %s .. ... %s .\n", pattern, lisp_name); #endif Delete(pattern); // Walk children to generate type definition. String *slotdefs = NewString(" "); #ifdef CFFI_WRAP_DEBUG Printf(stderr, " walking children...\n"); #endif Node *c; for (c = firstChild(n); c; c = nextSibling(c)) { String *storage_type = Getattr(c, "storage"); if ((!Strcmp(nodeType(c), "cdecl") && (!storage_type || Strcmp(storage_type, "typedef")))) { String *access = Getattr(c, "access"); // hack. why would decl have a value of "variableHandler" and now "0"? String *childDecl = Getattr(c, "decl"); // Printf(stderr,"childDecl = '%s' (%s)\n", childDecl, Getattr(c,"view")); if (!Strcmp(childDecl, "0")) childDecl = NewString(""); SwigType *childType = NewStringf("%s%s", childDecl, Getattr(c, "type")); String *cname = (access && Strcmp(access, "public")) ? NewString("nil") : Copy(Getattr(c, "name")); if (!SwigType_isfunction(childType)) { // Printf(slotdefs, ";;; member functions don't appear as slots.\n "); // Printf(slotdefs, ";; "); // String *ns = listify_namespace(Getattr(n, "cffi:package")); String *ns = NewString(""); #ifdef CFFI_WRAP_DEBUG Printf(stderr, "slot name = '%s' ns = '%s' class-of '%s' and type = '%s'\n", cname, ns, name, childType); #endif Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, childType); //compose_foreign_type(childType) Delete(ns); if (access && Strcmp(access, "public")) Printf(slotdefs, " ;; %s member", access); Printf(slotdefs, "\n "); } Delete(childType); Delete(cname); } } // String *ns_list = listify_namespace(Getattr(n,"cffi:namespace")); // update_package_if_needed(n,f_clhead); // Printf(f_clos, // "(swig-def-foreign-class \"%s\"\n %s\n (:%s\n%s))\n\n", // name, supers, kind, slotdefs); Delete(supers); // Delete(ns_list); // Parm *pattern = NewParm(name, NULL, n); // Swig_typemap_register("cin",pattern,lisp_name,NULL,NULL); //Swig_typemap_register("cout",pattern,lisp_name,NULL,NULL); //Delete(pattern); #ifdef CFFI_WRAP_DEBUG Printf(stderr, "emit_class: EXIT\n"); #endif } // Includes structs void CFFI::emit_struct_union(Node *n, bool un = false) { #ifdef CFFI_DEBUG Printf(stderr, "struct/union %s\n", Getattr(n, "name")); Printf(stderr, "struct/union %s\n and %s", Getattr(n, "kind"), Getattr(n, "sym:name")); #endif String *name = Getattr(n, "sym:name"); String *kind = Getattr(n, "kind"); if (Strcmp(kind, "struct") != 0 && Strcmp(kind, "union") != 0) { Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind); Printf(stderr, " (name: %s)\n", name); SWIG_exit(EXIT_FAILURE); } String *lisp_name = lispify_name(n, name, "'classname"); //Register the struct/union name to the cin and cout typemaps Parm *pattern = NewParm(name, NULL, n); Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL); Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL); Delete(pattern); //Registering with the kind, i.e., struct or union pattern = NewParm(NewStringf("%s %s", kind, name), NULL, n); Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL); Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL); Delete(pattern); if (un) { Printf(f_cl, "\n(cffi:defcunion %s", lisp_name); } else Printf(f_cl, "\n(cffi:defcstruct %s", lisp_name); for (Node *c = firstChild(n); c; c = nextSibling(c)) { #ifdef CFFI_DEBUG Printf(stderr, "struct/union %s\n", Getattr(c, "name")); Printf(stderr, "struct/union %s and %s \n", Getattr(c, "kind"), Getattr(c, "sym:name")); #endif if (Strcmp(nodeType(c), "cdecl")) { //C declaration ignore // Printf(stderr, "Structure %s has a slot that we can't deal with.\n", // name); // Printf(stderr, "nodeType: %s, name: %s, type: %s\n", // nodeType(c), // Getattr(c, "name"), // Getattr(c, "type")); // SWIG_exit(EXIT_FAILURE); } else { SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type")); Node *node = NewHash(); Setattr(node, "type", childType); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup("cin", node, "", 0); String *typespec = tm ? NewString(tm) : NewString(""); String *slot_name = lispify_name(c, Getattr(c, "sym:name"), "'slotname"); if (slot_name && (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0)) slot_name = NewStringf("t_var"); Printf(f_cl, "\n\t(%s %s)", slot_name, typespec); Delete(node); Delete(childType); Delete(typespec); } } Printf(f_cl, ")\n"); emit_export(n, lisp_name); for (Node *child = firstChild(n); child; child = nextSibling(child)) { if (!Strcmp(nodeType(child), "cdecl")) { emit_export(child, lispify_name(child, Getattr(child, "sym:name"), "'slotname")); } } /* Add this structure to the known lisp types */ //Printf(stdout, "Adding %s foreign type\n", name); // add_defined_foreign_type(name); } void CFFI::emit_export(Node *n, String *name) { if (GetInt(n, "feature:export")) Printf(f_cl, "\n(cl:export '%s)\n", name); } void CFFI::emit_inline(Node *n, String *name) { if (GetInt(n, "feature:inline")) Printf(f_cl, "\n(cl:declaim (cl:inline %s))\n", name); } String *CFFI::lispify_name(Node *n, String *ty, const char *flag, bool kw) { String *intern_func = Getattr(n, "feature:intern_function"); if (intern_func) { if (Strcmp(intern_func, "1") == 0) intern_func = NewStringf("swig-lispify"); return NewStringf("#.(%s \"%s\" %s%s)", intern_func, ty, flag, kw ? " :keyword" : ""); } else if (kw) return NewStringf(":%s", ty); else return ty; } /* utilities */ /* returns new string w/ parens stripped */ String *CFFI::strip_parens(String *string) { char *s = Char(string), *p; int len = Len(string); String *res; if (len == 0 || s[0] != '(' || s[len - 1] != ')') { return NewString(string); } p = (char *) malloc(len - 2 + 1); if (!p) { Printf(stderr, "Malloc failed\n"); SWIG_exit(EXIT_FAILURE); } strncpy(p, s + 1, len - 1); p[len - 2] = 0; /* null terminate */ res = NewString(p); free(p); return res; } String *CFFI::trim(String *str) { char *c = Char(str); while (*c != '\0' && isspace((int) *c)) ++c; String *result = NewString(c); Chop(result); return result; } String *CFFI::infix_to_prefix(String *val, char split_op, const String *op, String *type) { List *ored = Split(val, split_op, -1); // some float hackery //i don't understand it, if you do then please explain // if ( ((split_op == '+') || (split_op == '-')) && Len(ored) == 2 && // (SwigType_type(type) == T_FLOAT || SwigType_type(type) == T_DOUBLE || // SwigType_type(type) == T_LONGDOUBLE) ) { // // check that we're not splitting a float // String *possible_result = convert_literal(val, type, false); // if (possible_result) return possible_result; // } // try parsing the split results. if any part fails, kick out. bool part_failed = false; if (Len(ored) > 1) { String *result = NewStringf("(%s", op); for (Iterator i = First(ored); i.item; i = Next(i)) { String *converted = convert_literal(i.item, type); if (converted) { Printf(result, " %s", converted); Delete(converted); } else { part_failed = true; break; } } Printf(result, ")"); Delete(ored); return part_failed ? 0 : result; } else { Delete(ored); } return 0; } /* To be called by code generating the lisp interface Will return a String containing the literal based on type. Will return null if there are problems. try_to_split defaults to true (see stub above). */ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split) { String *num_param = Copy(literal); String *trimmed = trim(num_param); String *num = strip_parens(trimmed), *res = 0; Delete(trimmed); char *s = Char(num); // very basic parsing of infix expressions. if (try_to_split) { if ((res = infix_to_prefix(num, '|', "cl:logior", type))) return res; if ((res = infix_to_prefix(num, '&', "cl:logand", type))) return res; if ((res = infix_to_prefix(num, '^', "cl:logxor", type))) return res; if ((res = infix_to_prefix(num, '*', "cl:*", type))) return res; if ((res = infix_to_prefix(num, '/', "cl:/", type))) return res; if ((res = infix_to_prefix(num, '+', "cl:+", type))) return res; if ((res = infix_to_prefix(num, '-', "cl:-", type))) return res; } if (SwigType_type(type) == T_FLOAT || SwigType_type(type) == T_DOUBLE || SwigType_type(type) == T_LONGDOUBLE) { // Use CL syntax for float literals // careful. may be a float identifier or float constant. char *num_start = Char(num); char *num_end = num_start + strlen(num_start) - 1; bool is_literal = isdigit(*num_start) || (*num_start == '.') || (*num_start == '+') || (*num_start == '-'); String *lisp_exp = 0; if (is_literal) { if (*num_end == 'f' || *num_end == 'F') { lisp_exp = NewString("f"); } else { lisp_exp = NewString("d"); } if (*num_end == 'l' || *num_end == 'L' || *num_end == 'f' || *num_end == 'F') { *num_end = '\0'; num_end--; } int exponents = Replaceall(num, "e", lisp_exp) + Replaceall(num, "E", lisp_exp); if (!exponents) Printf(num, "%s0", lisp_exp); if (exponents > 1 || (exponents + Replaceall(num, ".", ".") == 0)) { Delete(num); num = 0; } } return num; } else if (SwigType_type(type) == T_CHAR) { /* Use CL syntax for character literals */ String* result = NewStringf("#\\%c", s[0]); Delete(num); return result; } else if (SwigType_type(type) == T_STRING) { /* Use CL syntax for string literals */ String* result = NewStringf("\"%s\"", num_param); Delete(num); return result; } else if (SwigType_type(type) == T_INT || SwigType_type(type) == T_UINT) { // Printf(stderr, "Is a T_INT or T_UINT %s, before replaceall\n", s); const char *num_start = Char(num); bool is_literal = isdigit(*num_start) || (*num_start == '.') || (*num_start == '+') || (*num_start == '-'); if (is_literal) { Replaceall(num, "u", ""); Replaceall(num, "U", ""); Replaceall(num, "l", ""); Replaceall(num, "L", ""); } int i, j; if (sscanf(s, "%d >> %d", &i, &j) == 2) { String* result = NewStringf("(cl:ash %d -%d)", i, j); Delete(num); return result; } else if (sscanf(s, "%d << %d", &i, &j) == 2) { String* result = NewStringf("(cl:ash %d %d)", i, j); Delete(num); return result; } } if (Len(num) >= 2 && s[0] == '0') { /* octal or hex */ if (s[1] == 'x'){ Replace(num,"0","#",DOH_REPLACE_FIRST); } else{ Replace(num,"0","#o",DOH_REPLACE_FIRST); } } return num; } //less flexible as it does the conversion in C, the lispify name does the conversion in lisp String *CFFI::lispy_name(char *name) { bool helper = false; String *new_name = NewString(""); for (unsigned int i = 0; i < strlen(name); i++) { if (name[i] == '_' || name[i] == '-') { Printf(new_name, "%c", '-'); helper = false; } else if (name[i] >= 'A' && name[i] <= 'Z') { if (helper) Printf(new_name, "%c", '-'); Printf(new_name, "%c", ('a' + (name[i] - 'A'))); helper = false; } else { helper = true; Printf(new_name, "%c", name[i]); } } return new_name; } extern "C" Language *swig_cffi(void) { return new CFFI(); } swig-3.0.2/Source/Modules/d.cxx0000664000175000017500000047601412343605122016176 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * d.cxx * * D language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" #include // Hash type used for storing information about director callbacks for a class. typedef DOH UpcallData; class D : public Language { static const char *usage; const String *empty_string; const String *public_string; const String *protected_string; /* * Files and file sections containing C/C++ code. */ File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; File *f_wrappers; File *f_init; File *f_directors; File *f_directors_h; List *filenames_list; /* * Command line-set modes of operation. */ // Whether a single proxy D module is generated or classes and enums are // written to their own files. bool split_proxy_dmodule; // The major D version targeted (currently 1 or 2). unsigned short d_version; /* * State variables which indicate what is being wrapped at the moment. * This is probably not the most elegant way of handling state, but it has * proven to work in the C# and Java modules. */ // Indicates if wrapping a native function. bool native_function_flag; // Indicates if wrapping a static functions or member variables bool static_flag; // Indicates if wrapping a nonstatic member variable bool variable_wrapper_flag; // Indicates if wrapping a member variable/enum/const. bool wrapping_member_flag; // Indicates if wrapping a global variable. bool global_variable_flag; // Name of a variable being wrapped. String *variable_name; /* * Variables temporarily holding the generated C++ code. */ // C++ code for the generated wrapper functions for casts up the C++ // for inheritance hierarchies. String *upcasts_code; // Function pointer typedefs for handling director callbacks on the C++ side. String *director_callback_typedefs; // Variables for storing the function pointers to the director callbacks on // the C++ side. String *director_callback_pointers; /* * Names of generated D entities. */ // The name of the D module containing the interface to the C wrapper. String *im_dmodule_name; // The fully qualified name of the wrap D module (package name included). String *im_dmodule_fq_name; // The name of the proxy module which exposes the (SWIG) module contents as a // D module. String *proxy_dmodule_name; // The fully qualified name of the proxy D module. String *proxy_dmodule_fq_name; // Optional: Package the D modules are placed in (set via the -package // command line option). String *package; // The directory the generated D module files are written to. Is constructed // from the package path if a target package is set, points to the general // output directory otherwise. String *dmodule_directory; // The name of the library which contains the C wrapper (used when generating // the dynamic library loader). Can be overridden via the -wrapperlibrary // command line flag. String *wrap_library_name; /* * Variables temporarily holding the generated D code. */ // Import statements written to the intermediary D module header set via // %pragma(d) imdmoduleimports. String *im_dmodule_imports; // The code for the intermediary D module body. String *im_dmodule_code; // Import statements for all proxy modules (the main proxy module and, if in // split proxy module mode, the proxy class modules) from // %pragma(d) globalproxyimports. String *global_proxy_imports; // The D code for the main proxy modules. nspace_proxy_dmodules is a hash from // the namespace name as key to an {"imports", "code"}. If the nspace feature // is not active, only proxy_dmodule_imports and proxy_dmodule_code are used, // which contain the code for the root proxy module. // // These variables should not be accessed directly but rather via the // proxy{Imports, Code}Buffer)() helper functions which return the right // buffer for a given namespace. If not in split proxy mode, they contain the // whole proxy code. String *proxy_dmodule_imports; String *proxy_dmodule_code; Hash *nspace_proxy_dmodules; // The D code generated for the currently processed enum. String *proxy_enum_code; /* * D data for the current proxy class. * * These strings are mainly used to temporarily accumulate code from the * various member handling functions while a single class is processed and are * no longer relevant once that class has been finished, i.e. after * classHandler() has returned. */ // The unqualified name of the current proxy class. String *proxy_class_name; // The name of the current proxy class, qualified with the name of the // namespace it is in, if any. String *proxy_class_qname; // The import directives for the current proxy class. They are written to the // same D module the proxy class is written to. String *proxy_class_imports; // Code for enumerations nested in the current proxy class. Is emitted earlier // than the rest of the body to work around forward referencing-issues. String *proxy_class_enums_code; // The generated D code making up the body of the current proxy class. String *proxy_class_body_code; // D code which is emitted right after the proxy class. String *proxy_class_epilogue_code; // The full code for the current proxy class, including the epilogue. String* proxy_class_code; // Contains a D call to the function wrapping C++ the destructor of the // current class (if there is a public C++ destructor). String *destructor_call; // D code for the director callbacks generated for the current class. String *director_dcallbacks_code; /* * Code for dynamically loading the wrapper library on the D side. */ // D code which is inserted into the im D module if dynamic linking is used. String *wrapper_loader_code; // The D code to bind a function pointer to a library symbol. String *wrapper_loader_bind_command; // The cumulated binding commands binding all the functions declared in the // intermediary D module to the C/C++ library symbols. String *wrapper_loader_bind_code; /* * Director data. */ List *dmethods_seq; Hash *dmethods_table; int n_dmethods; int first_class_dmethod; int curr_class_dmethod; /* * SWIG types data. */ // Collects information about encountered types SWIG does not know about (e.g. // incomplete types). This is used later to generate type wrapper proxy // classes for the unknown types. Hash *unknown_types; public: /* --------------------------------------------------------------------------- * D::D() * --------------------------------------------------------------------------- */ D():empty_string(NewString("")), public_string(NewString("public")), protected_string(NewString("protected")), f_begin(NULL), f_runtime(NULL), f_runtime_h(NULL), f_header(NULL), f_wrappers(NULL), f_init(NULL), f_directors(NULL), f_directors_h(NULL), filenames_list(NULL), split_proxy_dmodule(false), d_version(1), native_function_flag(false), static_flag(false), variable_wrapper_flag(false), wrapping_member_flag(false), global_variable_flag(false), variable_name(NULL), upcasts_code(NULL), director_callback_typedefs(NULL), director_callback_pointers(NULL), im_dmodule_name(NULL), im_dmodule_fq_name(NULL), proxy_dmodule_name(NULL), proxy_dmodule_fq_name(NULL), package(NULL), dmodule_directory(NULL), wrap_library_name(NULL), im_dmodule_imports(NULL), im_dmodule_code(NULL), global_proxy_imports(NULL), proxy_dmodule_imports(NULL), proxy_dmodule_code(NULL), nspace_proxy_dmodules(NULL), proxy_enum_code(NULL), proxy_class_name(NULL), proxy_class_qname(NULL), proxy_class_imports(NULL), proxy_class_enums_code(NULL), proxy_class_body_code(NULL), proxy_class_epilogue_code(NULL), proxy_class_code(NULL), destructor_call(NULL), director_dcallbacks_code(NULL), wrapper_loader_code(NULL), wrapper_loader_bind_command(NULL), wrapper_loader_bind_code(NULL), dmethods_seq(NULL), dmethods_table(NULL), n_dmethods(0), first_class_dmethod(0), curr_class_dmethod(0), unknown_types(NULL) { // For now, multiple inheritance with directors is not possible. It should be // easy to implement though. director_multiple_inheritance = 0; director_language = 1; // Not used: Delete(none_comparison); none_comparison = NewString(""); } /* --------------------------------------------------------------------------- * D::main() * --------------------------------------------------------------------------- */ virtual void main(int argc, char *argv[]) { SWIG_library_directory("d"); // Look for certain command line options for (int i = 1; i < argc; i++) { if (argv[i]) { if ((strcmp(argv[i], "-d2") == 0)) { Swig_mark_arg(i); d_version = 2; } else if (strcmp(argv[i], "-wrapperlibrary") == 0) { if (argv[i + 1]) { wrap_library_name = NewString(""); Printf(wrap_library_name, argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-package") == 0) { if (argv[i + 1]) { package = NewString(""); Printf(package, argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if ((strcmp(argv[i], "-splitproxy") == 0)) { Swig_mark_arg(i); split_proxy_dmodule = true; } else if (strcmp(argv[i], "-help") == 0) { Printf(stdout, "%s\n", usage); } } } // Add a symbol to the parser for conditional compilation Preprocessor_define("SWIGD 1", 0); // Also make the target D version available as preprocessor symbol for // use in our library files. String *version_define = NewStringf("SWIG_D_VERSION %u", d_version); Preprocessor_define(version_define, 0); Delete(version_define); // Add typemap definitions SWIG_typemap_lang("d"); SWIG_config_file("d.swg"); allow_overloading(); } /* --------------------------------------------------------------------------- * D::top() * --------------------------------------------------------------------------- */ virtual int top(Node *n) { // Get any options set in the module directive Node *optionsnode = Getattr(Getattr(n, "module"), "options"); if (optionsnode) { if (Getattr(optionsnode, "imdmodulename")) { im_dmodule_name = Copy(Getattr(optionsnode, "imdmodulename")); } if (Getattr(optionsnode, "directors")) { // Check if directors are enabled for this module. Note: This is a // "master switch", if it is not set, not director code will be emitted // at all. %feature("director") statements are also required to enable // directors for individual classes or methods. // // Use the »directors« attributte of the %module directive to enable // director generation (e.g. »%module(directors="1") modulename«). allow_directors(); } if (Getattr(optionsnode, "dirprot")) { allow_dirprot(); } allow_allprotected(GetFlag(optionsnode, "allprotected")); } /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); String *outfile_h = Getattr(n, "outfile_h"); if (!outfile) { Printf(stderr, "Unable to determine outfile\n"); SWIG_exit(EXIT_FAILURE); } f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } if (directorsEnabled()) { if (!outfile_h) { Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); } } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); f_directors_h = NewString(""); f_directors = NewString(""); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); unknown_types = NewHash(); filenames_list = NewList(); // Make the package name and the resulting module output path. if (package) { // Append a dot so we can prepend the package variable directly to the // module names in the rest of the code. Printv(package, ".", NIL); } else { // Write the generated D modules to the »root« package by default. package = NewString(""); } dmodule_directory = Copy(SWIG_output_directory()); if (Len(package) > 0) { String *package_directory = Copy(package); Replaceall(package_directory, ".", SWIG_FILE_DELIMITER); Printv(dmodule_directory, package_directory, NIL); Delete(package_directory); } // Make the wrap and proxy D module names. // The wrap module name can be set in the module directive. if (!im_dmodule_name) { im_dmodule_name = NewStringf("%s_im", Getattr(n, "name")); } im_dmodule_fq_name = NewStringf("%s%s", package, im_dmodule_name); proxy_dmodule_name = Copy(Getattr(n, "name")); proxy_dmodule_fq_name = NewStringf("%s%s", package, proxy_dmodule_name); im_dmodule_code = NewString(""); proxy_class_imports = NewString(""); proxy_class_enums_code = NewString(""); proxy_class_body_code = NewString(""); proxy_class_epilogue_code = NewString(""); proxy_class_code = NewString(""); destructor_call = NewString(""); proxy_dmodule_code = NewString(""); proxy_dmodule_imports = NewString(""); nspace_proxy_dmodules = NewHash(); im_dmodule_imports = NewString(""); upcasts_code = NewString(""); global_proxy_imports = NewString(""); wrapper_loader_code = NewString(""); wrapper_loader_bind_command = NewString(""); wrapper_loader_bind_code = NewString(""); dmethods_seq = NewList(); dmethods_table = NewHash(); n_dmethods = 0; // By default, expect the dynamically loaded wrapper library to be named // [lib]_wrap[.so/.dll]. if (!wrap_library_name) wrap_library_name = NewStringf("%s_wrap", Getattr(n, "name")); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGD\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); /* Emit initial director header and director code: */ Swig_banner(f_directors_h); Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", proxy_dmodule_name); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", proxy_dmodule_name); Printf(f_directors, "\n\n"); Printf(f_directors, "/* ---------------------------------------------------\n"); Printf(f_directors, " * C++ director class methods\n"); Printf(f_directors, " * --------------------------------------------------- */\n\n"); if (outfile_h) { String *filename = Swig_file_filename(outfile_h); Printf(f_directors, "#include \"%s\"\n\n", filename); Delete(filename); } } Printf(f_runtime, "\n"); Swig_name_register("wrapper", "D_%f"); Printf(f_wrappers, "\n#ifdef __cplusplus\n"); Printf(f_wrappers, "extern \"C\" {\n"); Printf(f_wrappers, "#endif\n\n"); // Emit all the wrapper code. Language::top(n); if (directorsEnabled()) { // Insert director runtime into the f_runtime file (before %header section). Swig_insert_file("director.swg", f_runtime); } // Generate the wrap D module. // TODO: Add support for »static« linking. { String *filen = NewStringf("%s%s.d", dmodule_directory, im_dmodule_name); File *im_d_file = NewFile(filen, "w", SWIG_output_files()); if (!im_d_file) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the intermediary class file. emitBanner(im_d_file); Printf(im_d_file, "module %s;\n", im_dmodule_fq_name); Printv(im_d_file, im_dmodule_imports, "\n", NIL); Replaceall(wrapper_loader_code, "$wraplibrary", wrap_library_name); Replaceall(wrapper_loader_code, "$wrapperloaderbindcode", wrapper_loader_bind_code); Replaceall(wrapper_loader_code, "$module", proxy_dmodule_name); Printf(im_d_file, "%s\n", wrapper_loader_code); // Add the wrapper function declarations. replaceModuleVariables(im_dmodule_code); Printv(im_d_file, im_dmodule_code, NIL); Delete(im_d_file); } // Generate the main D proxy module. { String *filen = NewStringf("%s%s.d", dmodule_directory, proxy_dmodule_name); File *proxy_d_file = NewFile(filen, "w", SWIG_output_files()); if (!proxy_d_file) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; emitBanner(proxy_d_file); Printf(proxy_d_file, "module %s;\n", proxy_dmodule_fq_name); Printf(proxy_d_file, "\nstatic import %s;\n", im_dmodule_fq_name); Printv(proxy_d_file, global_proxy_imports, NIL); Printv(proxy_d_file, proxy_dmodule_imports, NIL); Printv(proxy_d_file, "\n", NIL); // Write a D type wrapper class for each SWIG type to the proxy module code. for (Iterator swig_type = First(unknown_types); swig_type.key; swig_type = Next(swig_type)) { writeTypeWrapperClass(swig_type.key, swig_type.item); } // Add the proxy functions (and classes, if they are not written to a separate file). replaceModuleVariables(proxy_dmodule_code); Printv(proxy_d_file, proxy_dmodule_code, NIL); Delete(proxy_d_file); } // Generate the additional proxy modules for nspace support. for (Iterator it = First(nspace_proxy_dmodules); it.key; it = Next(it)) { String *module_name = createLastNamespaceName(it.key); String *filename = NewStringf("%s%s.d", outputDirectory(it.key), module_name); File *file = NewFile(filename, "w", SWIG_output_files()); if (!file) { FileErrorDisplay(filename); SWIG_exit(EXIT_FAILURE); } Delete(filename); emitBanner(file); Printf(file, "module %s%s.%s;\n", package, it.key, module_name); Printf(file, "\nstatic import %s;\n", im_dmodule_fq_name); Printv(file, global_proxy_imports, NIL); Printv(file, Getattr(it.item, "imports"), NIL); Printv(file, "\n", NIL); String *code = Getattr(it.item, "code"); replaceModuleVariables(code); Printv(file, code, NIL); Delete(file); Delete(module_name); } if (upcasts_code) Printv(f_wrappers, upcasts_code, NIL); Printf(f_wrappers, "#ifdef __cplusplus\n"); Printf(f_wrappers, "}\n"); Printf(f_wrappers, "#endif\n"); // Check for overwriting file problems on filesystems that are case insensitive Iterator it1; Iterator it2; for (it1 = First(filenames_list); it1.item; it1 = Next(it1)) { String *item1_lower = Swig_string_lower(it1.item); for (it2 = Next(it1); it2.item; it2 = Next(it2)) { String *item2_lower = Swig_string_lower(it2.item); if (it1.item && it2.item) { if (Strcmp(item1_lower, item2_lower) == 0) { Swig_warning(WARN_LANG_PORTABILITY_FILENAME, input_file, line_number, "Portability warning: File %s will be overwritten by %s on case insensitive filesystems such as " "Windows' FAT32 and NTFS unless the class/module name is renamed\n", it1.item, it2.item); } } Delete(item2_lower); } Delete(item1_lower); } Delete(unknown_types); unknown_types = NULL; Delete(filenames_list); filenames_list = NULL; Delete(im_dmodule_name); im_dmodule_name = NULL; Delete(im_dmodule_fq_name); im_dmodule_fq_name = NULL; Delete(im_dmodule_code); im_dmodule_code = NULL; Delete(proxy_class_imports); proxy_class_imports = NULL; Delete(proxy_class_enums_code); proxy_class_enums_code = NULL; Delete(proxy_class_body_code); proxy_class_body_code = NULL; Delete(proxy_class_epilogue_code); proxy_class_epilogue_code = NULL; Delete(proxy_class_code); proxy_class_code = NULL; Delete(destructor_call); destructor_call = NULL; Delete(proxy_dmodule_name); proxy_dmodule_name = NULL; Delete(proxy_dmodule_fq_name); proxy_dmodule_fq_name = NULL; Delete(proxy_dmodule_code); proxy_dmodule_code = NULL; Delete(proxy_dmodule_imports); proxy_dmodule_imports = NULL; Delete(nspace_proxy_dmodules); nspace_proxy_dmodules = NULL; Delete(im_dmodule_imports); im_dmodule_imports = NULL; Delete(upcasts_code); upcasts_code = NULL; Delete(global_proxy_imports); global_proxy_imports = NULL; Delete(wrapper_loader_code); wrapper_loader_code = NULL; Delete(wrapper_loader_bind_code); wrapper_loader_bind_code = NULL; Delete(wrapper_loader_bind_command); wrapper_loader_bind_command = NULL; Delete(dmethods_seq); dmethods_seq = NULL; Delete(dmethods_table); dmethods_table = NULL; Delete(package); package = NULL; Delete(dmodule_directory); dmodule_directory = NULL; n_dmethods = 0; // Merge all the generated C/C++ code and close the output files. Dump(f_runtime, f_begin); Dump(f_header, f_begin); if (directorsEnabled()) { Dump(f_directors, f_begin); Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); Delete(f_runtime_h); f_runtime_h = NULL; Delete(f_directors); f_directors = NULL; Delete(f_directors_h); f_directors_h = NULL; } Dump(f_wrappers, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /* --------------------------------------------------------------------------- * D::insertDirective() * --------------------------------------------------------------------------- */ virtual int insertDirective(Node *n) { String *code = Getattr(n, "code"); replaceModuleVariables(code); return Language::insertDirective(n); } /* --------------------------------------------------------------------------- * D::pragmaDirective() * * Valid Pragmas: * imdmodulecode - text (D code) is copied verbatim to the wrap module * imdmoduleimports - import statements for the im D module * * proxydmodulecode - text (D code) is copied verbatim to the proxy module * (the main proxy module if in split proxy mode). * globalproxyimports - import statements inserted into _all_ proxy modules. * * wrapperloadercode - D code for loading the wrapper library (is copied to * the im D module). * wrapperloaderbindcommand - D code for binding a symbol from the wrapper * library to the declaration in the im D module. * --------------------------------------------------------------------------- */ virtual int pragmaDirective(Node *n) { if (!ImportMode) { String *lang = Getattr(n, "lang"); String *code = Getattr(n, "name"); String *value = Getattr(n, "value"); if (Strcmp(lang, "d") == 0) { String *strvalue = NewString(value); Replaceall(strvalue, "\\\"", "\""); if (Strcmp(code, "imdmodulecode") == 0) { Printf(im_dmodule_code, "%s\n", strvalue); } else if (Strcmp(code, "imdmoduleimports") == 0) { replaceImportTypeMacros(strvalue); Chop(strvalue); Printf(im_dmodule_imports, "%s\n", strvalue); } else if (Strcmp(code, "proxydmodulecode") == 0) { Printf(proxyCodeBuffer(0), "%s\n", strvalue); } else if (Strcmp(code, "globalproxyimports") == 0) { replaceImportTypeMacros(strvalue); Chop(strvalue); Printf(global_proxy_imports, "%s\n", strvalue); } else if (Strcmp(code, "wrapperloadercode") == 0) { Delete(wrapper_loader_code); wrapper_loader_code = Copy(strvalue); } else if (Strcmp(code, "wrapperloaderbindcommand") == 0) { Delete(wrapper_loader_bind_command); wrapper_loader_bind_command = Copy(strvalue); } else { Swig_error(input_file, line_number, "Unrecognized pragma.\n"); } Delete(strvalue); } } return Language::pragmaDirective(n); } /* --------------------------------------------------------------------------- * D::enumDeclaration() * * Wraps C/C++ enums as D enums. * --------------------------------------------------------------------------- */ virtual int enumDeclaration(Node *n) { if (ImportMode) return SWIG_OK; if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; proxy_enum_code = NewString(""); String *symname = Getattr(n, "sym:name"); String *typemap_lookup_type = Getattr(n, "name"); // Emit the enum declaration. if (typemap_lookup_type) { const String *enummodifiers = lookupCodeTypemap(n, "dclassmodifiers", typemap_lookup_type, WARN_D_TYPEMAP_CLASSMOD_UNDEF); Printv(proxy_enum_code, "\n", enummodifiers, " ", symname, " {\n", NIL); } else { // Handle anonymous enums. Printv(proxy_enum_code, "\nenum {\n", NIL); } // Emit each enum item. Language::enumDeclaration(n); if (!GetFlag(n, "nonempty")) { // Do not wrap empty enums; the resulting D code would be illegal. Delete(proxy_enum_code); return SWIG_NOWRAP; } // Finish the enum. if (typemap_lookup_type) { Printv(proxy_enum_code, lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), // Extra D code "\n}\n", NIL); } else { // Handle anonymous enums. Printv(proxy_enum_code, "\n}\n", NIL); } Replaceall(proxy_enum_code, "$dclassname", symname); const String* imports = lookupCodeTypemap(n, "dimports", typemap_lookup_type, WARN_NONE); String* imports_trimmed; if (Len(imports) > 0) { imports_trimmed = Copy(imports); Chop(imports_trimmed); replaceImportTypeMacros(imports_trimmed); Printv(imports_trimmed, "\n", NIL); } else { imports_trimmed = NewString(""); } if (is_wrapping_class()) { // Enums defined within the C++ class are written into the proxy // class. Printv(proxy_class_imports, imports_trimmed, NIL); Printv(proxy_class_enums_code, proxy_enum_code, NIL); } else { // Write non-anonymous enums to their own file if in split proxy module // mode. if (split_proxy_dmodule && typemap_lookup_type) { assertClassNameValidity(proxy_class_name); String *nspace = Getattr(n, "sym:nspace"); String *output_directory = outputDirectory(nspace); String *filename = NewStringf("%s%s.d", output_directory, symname); Delete(output_directory); File *class_file = NewFile(filename, "w", SWIG_output_files()); if (!class_file) { FileErrorDisplay(filename); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filename)); Delete(filename); emitBanner(class_file); if (nspace) { Printf(class_file, "module %s%s.%s;\n", package, nspace, symname); } else { Printf(class_file, "module %s%s;\n", package, symname); } Printv(class_file, imports_trimmed, NIL); Printv(class_file, proxy_enum_code, NIL); Delete(class_file); } else { String *nspace = Getattr(n, "sym:nspace"); Printv(proxyImportsBuffer(nspace), imports, NIL); Printv(proxyCodeBuffer(nspace), proxy_enum_code, NIL); } } Delete(imports_trimmed); Delete(proxy_enum_code); proxy_enum_code = NULL; return SWIG_OK; } /* --------------------------------------------------------------------------- * D::enumvalueDeclaration() * --------------------------------------------------------------------------- */ virtual int enumvalueDeclaration(Node *n) { if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL); String *value = Getattr(n, "value"); String *name = Getattr(n, "name"); Node *parent = parentNode(n); String *tmpValue; // Strange hack from parent method. // RESEARCH: What is this doing? if (value) tmpValue = NewString(value); else tmpValue = NewString(name); // Note that this is used in enumValue() amongst other places Setattr(n, "value", tmpValue); // Deal with enum values that are not int int swigtype = SwigType_type(Getattr(n, "type")); if (swigtype == T_BOOL) { const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0"; Setattr(n, "enumvalue", val); } else if (swigtype == T_CHAR) { String *val = NewStringf("'%s'", Getattr(n, "enumvalue")); Setattr(n, "enumvalue", val); Delete(val); } // Emit the enum item. { if (!GetFlag(n, "firstenumitem")) Printf(proxy_enum_code, ",\n"); Printf(proxy_enum_code, " %s", Getattr(n, "sym:name")); // Check for the %dconstvalue feature String *value = Getattr(n, "feature:d:constvalue"); // Note that in D, enum values must be compile-time constants. Thus, // %dmanifestconst(0) (getting the enum values at runtime) is not supported. value = value ? value : Getattr(n, "enumvalue"); if (value) { Printf(proxy_enum_code, " = %s", value); } // Keep track that the currently processed enum has at least one value. SetFlag(parent, "nonempty"); } Delete(tmpValue); Swig_restore(n); return SWIG_OK; } /* --------------------------------------------------------------------------- * D::memberfunctionHandler() * --------------------------------------------------------------------------- */ virtual int memberfunctionHandler(Node *n) { Language::memberfunctionHandler(n); String *overloaded_name = getOverloadedName(n); String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name); Setattr(n, "imfuncname", intermediary_function_name); String *proxy_func_name = Getattr(n, "sym:name"); Setattr(n, "proxyfuncname", proxy_func_name); if (split_proxy_dmodule && Len(Getattr(n, "parms")) == 0 && Strncmp(proxy_func_name, package, Len(proxy_func_name)) == 0) { // If we are in split proxy mode and the function is named like the // target package, the D compiler is unable to resolve the ambiguity // between the package name and an argument-less function call. // TODO: This might occur with nspace as well, augment the check. Swig_warning(WARN_D_NAME_COLLISION, input_file, line_number, "%s::%s might collide with the package name, consider using %%rename to resolve the ambiguity.\n", proxy_class_name, proxy_func_name); } writeProxyClassFunction(n); Delete(overloaded_name); // For each function, look if we have to alias in the parent class function // for the overload resolution process to work as expected from C++ // (http://www.digitalmars.com/d/2.0/function.html#function-inheritance). // For multiple overloads, only emit the alias directive once (for the // last method, »sym:nextSibling« is null then). // Smart pointer classes do not mirror the inheritance hierarchy of the // underlying types, so aliasing the base class methods in is not required // for them. // DMD BUG: We have to emit the alias after the last function becasue // taking a delegate in the overload checking code fails otherwise // (http://d.puremagic.com/issues/show_bug.cgi?id=4860). if (!Getattr(n, "sym:nextSibling") && !is_smart_pointer() && !areAllOverloadsOverridden(n)) { String *name = Getattr(n, "sym:name"); Printf(proxy_class_body_code, "\nalias $dbaseclass.%s %s;\n", name, name); } return SWIG_OK; } /* --------------------------------------------------------------------------- * D::staticmemberfunctionHandler() * --------------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { static_flag = true; Language::staticmemberfunctionHandler(n); String *overloaded_name = getOverloadedName(n); String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); writeProxyClassFunction(n); Delete(overloaded_name); static_flag = false; return SWIG_OK; } /* --------------------------------------------------------------------------- * D::globalvariableHandler() * --------------------------------------------------------------------------- */ virtual int globalvariableHandler(Node *n) { variable_name = Getattr(n, "sym:name"); global_variable_flag = true; int ret = Language::globalvariableHandler(n); global_variable_flag = false; return ret; } /* --------------------------------------------------------------------------- * D::membervariableHandler() * --------------------------------------------------------------------------- */ virtual int membervariableHandler(Node *n) { variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; variable_wrapper_flag = true; Language::membervariableHandler(n); wrapping_member_flag = false; variable_wrapper_flag = false; return SWIG_OK; } /* --------------------------------------------------------------------------- * D::staticmembervariableHandler() * --------------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { if (GetFlag(n, "feature:d:manifestconst") != 1) { Delattr(n, "value"); } variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; static_flag = true; Language::staticmembervariableHandler(n); wrapping_member_flag = false; static_flag = false; return SWIG_OK; } /* --------------------------------------------------------------------------- * D::memberconstantHandler() * --------------------------------------------------------------------------- */ virtual int memberconstantHandler(Node *n) { variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; Language::memberconstantHandler(n); wrapping_member_flag = false; return SWIG_OK; } /* --------------------------------------------------------------------------- * D::constructorHandler() * --------------------------------------------------------------------------- */ virtual int constructorHandler(Node *n) { Language::constructorHandler(n); // Wrappers not wanted for some methods where the parameters cannot be overloadedprocess in D. if (Getattr(n, "overload:ignore")) { return SWIG_OK; } ParmList *l = Getattr(n, "parms"); String *tm; String *proxy_constructor_code = NewString(""); int i; // Holds code for the constructor helper method generated only when the din // typemap has code in the pre or post attributes. String *helper_code = NewString(""); String *helper_args = NewString(""); String *pre_code = NewString(""); String *post_code = NewString(""); String *terminator_code = NewString(""); NewString(""); String *overloaded_name = getOverloadedName(n); String *mangled_overname = Swig_name_construct(getNSpace(), overloaded_name); String *imcall = NewString(""); const String *methodmods = Getattr(n, "feature:d:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); // Typemaps were attached earlier to the node, get the return type of the // call to the C++ constructor wrapper. const String *wrapper_return_type = lookupDTypemap(n, "imtype", true); String *imtypeout = Getattr(n, "tmap:imtype:out"); if (imtypeout) { // The type in the imtype typemap's out attribute overrides the type in // the typemap itself. wrapper_return_type = imtypeout; } Printf(proxy_constructor_code, "\n%s this(", methodmods); Printf(helper_code, "static private %s SwigConstruct%s(", wrapper_return_type, proxy_class_name); Printv(imcall, im_dmodule_fq_name, ".", mangled_overname, "(", NIL); /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); Swig_typemap_attach_parms("dtype", l, NULL); Swig_typemap_attach_parms("din", l, NULL); emit_mark_varargs(l); int gencomma = 0; /* Output each parameter */ Parm *p = l; for (i = 0; p; i++) { if (checkAttribute(p, "varargs:ignore", "1")) { // Skip ignored varargs. p = nextSibling(p); continue; } if (checkAttribute(p, "tmap:in:numinputs", "0")) { // Skip ignored parameters. p = Getattr(p, "tmap:in:next"); continue; } SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); // Get the D parameter type. if ((tm = lookupDTypemap(p, "dtype", true))) { const String *inattributes = Getattr(p, "tmap:dtype:inattributes"); Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm); } else { Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number, "No dtype typemap defined for %s\n", SwigType_str(pt, 0)); } if (gencomma) Printf(imcall, ", "); String *arg = makeParameterName(n, p, i, false); String *parmtype = 0; // Get the D code to convert the parameter value to the type used in the // intermediary D module. if ((tm = lookupDTypemap(p, "din"))) { Replaceall(tm, "$dinput", arg); String *pre = Getattr(p, "tmap:din:pre"); if (pre) { replaceClassname(pre, pt); Replaceall(pre, "$dinput", arg); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:din:post"); if (post) { replaceClassname(post, pt); Replaceall(post, "$dinput", arg); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } String *terminator = Getattr(p, "tmap:din:terminator"); if (terminator) { replaceClassname(terminator, pt); Replaceall(terminator, "$dinput", arg); if (Len(terminator_code) > 0) Insert(terminator_code, 0, "\n"); Insert(terminator_code, 0, terminator); } parmtype = Getattr(p, "tmap:din:parmtype"); if (parmtype) Replaceall(parmtype, "$dinput", arg); Printv(imcall, tm, NIL); } else { Swig_warning(WARN_D_TYPEMAP_DIN_UNDEF, input_file, line_number, "No din typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to proxy function */ if (gencomma) { Printf(proxy_constructor_code, ", "); Printf(helper_code, ", "); Printf(helper_args, ", "); } Printf(proxy_constructor_code, "%s %s", param_type, arg); Printf(helper_code, "%s %s", param_type, arg); Printf(helper_args, "%s", parmtype ? parmtype : arg); ++gencomma; Delete(parmtype); Delete(arg); Delete(param_type); p = Getattr(p, "tmap:in:next"); } Printf(imcall, ")"); Printf(proxy_constructor_code, ")"); Printf(helper_code, ")"); // Insert the dconstructor typemap (replacing $directorconnect as needed). Hash *attributes = NewHash(); String *construct_tm = Copy(lookupCodeTypemap(n, "dconstructor", Getattr(n, "name"), WARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF, attributes)); if (construct_tm) { const bool use_director = (parentNode(n) && Swig_directorclass(n)); if (!use_director) { Replaceall(construct_tm, "$directorconnect", ""); } else { String *connect_attr = Getattr(attributes, "tmap:dconstructor:directorconnect"); if (connect_attr) { Replaceall(construct_tm, "$directorconnect", connect_attr); } else { Swig_warning(WARN_D_NO_DIRECTORCONNECT_ATTR, input_file, line_number, "\"directorconnect\" attribute missing in %s \"dconstructor\" typemap.\n", Getattr(n, "name")); Replaceall(construct_tm, "$directorconnect", ""); } } Printv(proxy_constructor_code, " ", construct_tm, NIL); } replaceExcode(n, proxy_constructor_code, "dconstructor", attributes); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; bool is_terminator_code = Len(terminator_code) > 0; if (is_pre_code || is_post_code || is_terminator_code) { Printf(helper_code, " {\n"); if (is_pre_code) { Printv(helper_code, pre_code, "\n", NIL); } if (is_post_code) { Printf(helper_code, " try {\n"); Printv(helper_code, " return ", imcall, ";\n", NIL); Printv(helper_code, " } finally {\n", post_code, "\n }", NIL); } else { Printv(helper_code, " return ", imcall, ";", NIL); } if (is_terminator_code) { Printv(helper_code, "\n", terminator_code, NIL); } Printf(helper_code, "\n}\n"); String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args); Replaceall(proxy_constructor_code, "$imcall", helper_name); Delete(helper_name); } else { Replaceall(proxy_constructor_code, "$imcall", imcall); } Printv(proxy_class_body_code, proxy_constructor_code, "\n", NIL); Delete(helper_args); Delete(pre_code); Delete(post_code); Delete(terminator_code); Delete(construct_tm); Delete(attributes); Delete(overloaded_name); Delete(imcall); return SWIG_OK; } /* --------------------------------------------------------------------------- * D::destructorHandler() * --------------------------------------------------------------------------- */ virtual int destructorHandler(Node *n) { Language::destructorHandler(n); String *symname = Getattr(n, "sym:name"); Printv(destructor_call, im_dmodule_fq_name, ".", Swig_name_destroy(getNSpace(),symname), "(cast(void*)swigCPtr)", NIL); return SWIG_OK; } /* --------------------------------------------------------------------------- * D::classHandler() * --------------------------------------------------------------------------- */ virtual int classHandler(Node *n) { String *nspace = getNSpace(); File *class_file = NULL; proxy_class_name = Copy(Getattr(n, "sym:name")); if (nspace) { proxy_class_qname = NewStringf("%s.%s", nspace, proxy_class_name); } else { proxy_class_qname = Copy(proxy_class_name); } if (!addSymbol(proxy_class_name, n, nspace)) { return SWIG_ERROR; } assertClassNameValidity(proxy_class_name); if (split_proxy_dmodule) { String *output_directory = outputDirectory(nspace); String *filename = NewStringf("%s%s.d", output_directory, proxy_class_name); class_file = NewFile(filename, "w", SWIG_output_files()); Delete(output_directory); if (!class_file) { FileErrorDisplay(filename); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filename)); Delete(filename); emitBanner(class_file); if (nspace) { Printf(class_file, "module %s%s.%s;\n", package, nspace, proxy_class_name); } else { Printf(class_file, "module %s%s;\n", package, proxy_class_name); } Printf(class_file, "\nstatic import %s;\n", im_dmodule_fq_name); } Clear(proxy_class_imports); Clear(proxy_class_enums_code); Clear(proxy_class_body_code); Clear(proxy_class_epilogue_code); Clear(proxy_class_code); Clear(destructor_call); // Traverse the tree for this class, using the *Handler()s to generate code // to the proxy_class_* variables. Language::classHandler(n); writeProxyClassAndUpcasts(n); writeDirectorConnectWrapper(n); Replaceall(proxy_class_code, "$dclassname", proxy_class_name); String *dclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); Replaceall(proxy_class_code, "$dclazzname", dclazzname); Delete(dclazzname); if (split_proxy_dmodule) { Printv(class_file, global_proxy_imports, NIL); Printv(class_file, proxy_class_imports, NIL); replaceModuleVariables(proxy_class_code); Printv(class_file, proxy_class_code, NIL); Delete(class_file); } else { Printv(proxyImportsBuffer(getNSpace()), proxy_class_imports, NIL); Printv(proxyCodeBuffer(getNSpace()), proxy_class_code, NIL); } Delete(proxy_class_qname); proxy_class_qname = NULL; Delete(proxy_class_name); proxy_class_name = NULL; return SWIG_OK; } /* --------------------------------------------------------------------------- * D::constantWrapper() * * Used for wrapping constants declared by #define or %constant and also for * (primitive) static member constants initialised inline. * * If the %dmanifestconst feature is used, the C/C++ constant value is used to * initialize a D »const«. If not, a »getter« method is generated which * retrieves the value via a call to the C wrapper. However, if there is a * %dconstvalue specified, it overrides all other settings. * --------------------------------------------------------------------------- */ virtual int constantWrapper(Node *n) { String *symname = Getattr(n, "sym:name"); if (!addSymbol(symname, n)) return SWIG_ERROR; // The %dmanifestconst feature determines if a D manifest constant // (const/enum) or a getter function is created. if (GetFlag(n, "feature:d:manifestconst") != 1) { // Default constant handling will work with any type of C constant. It // generates a getter function (which is the same as a read only property // in D) which retrieves the value via by calling the C wrapper. // Note that this is only called for global constants, static member // constants are already handled in staticmemberfunctionHandler(). Swig_save("constantWrapper", n, "value", NIL); Swig_save("constantWrapper", n, "tmap:ctype:out", "tmap:imtype:out", "tmap:dtype:out", "tmap:out:null", "tmap:imtype:outattributes", "tmap:dtype:outattributes", NIL); // Add the stripped quotes back in. String *old_value = Getattr(n, "value"); SwigType *t = Getattr(n, "type"); if (SwigType_type(t) == T_STRING) { Setattr(n, "value", NewStringf("\"%s\"", old_value)); Delete(old_value); } else if (SwigType_type(t) == T_CHAR) { Setattr(n, "value", NewStringf("\'%s\'", old_value)); Delete(old_value); } SetFlag(n, "feature:immutable"); int result = globalvariableHandler(n); Swig_restore(n); return result; } String *constants_code = NewString(""); SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); // Attach the non-standard typemaps to the parameter list. Swig_typemap_attach_parms("dtype", l, NULL); // Get D return type. String *return_type = NewString(""); String *tm; if ((tm = lookupDTypemap(n, "dtype"))) { String *dtypeout = Getattr(n, "tmap:dtype:out"); if (dtypeout) { // The type in the out attribute of the typemap overrides the type // in the dtype typemap. tm = dtypeout; replaceClassname(tm, t); } Printf(return_type, "%s", tm); } else { Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number, "No dtype typemap defined for %s\n", SwigType_str(t, 0)); } const String *itemname = wrapping_member_flag ? variable_name : symname; String *attributes = Getattr(n, "feature:d:methodmodifiers"); if (attributes) { attributes = Copy(attributes); } else { attributes = Copy(is_public(n) ? public_string : protected_string); } if (d_version == 1) { if (static_flag) { Printv(attributes, " static", NIL); } Printf(constants_code, "\n%s const %s %s = ", attributes, return_type, itemname); } else { Printf(constants_code, "\n%s enum %s %s = ", attributes, return_type, itemname); } Delete(attributes); // Retrive the override value set via %dconstvalue, if any. String *override_value = Getattr(n, "feature:d:constvalue"); if (override_value) { Printf(constants_code, "%s;\n", override_value); } else { // Just take the value from the C definition and hope it compiles in D. String* value = Getattr(n, "wrappedasconstant") ? Getattr(n, "staticmembervariableHandler:value") : Getattr(n, "value"); // Add the stripped quotes back in. if (SwigType_type(t) == T_STRING) { Printf(constants_code, "\"%s\";\n", value); } else if (SwigType_type(t) == T_CHAR) { Printf(constants_code, "\'%s\';\n", value); } else { Printf(constants_code, "%s;\n", value); } } // Emit the generated code to appropriate place. if (wrapping_member_flag) { Printv(proxy_class_body_code, constants_code, NIL); } else { Printv(proxyCodeBuffer(getNSpace()), constants_code, NIL); } // Cleanup. Delete(return_type); Delete(constants_code); return SWIG_OK; } /* --------------------------------------------------------------------------- * D::functionWrapper() * * Generates the C wrapper code for a function and the corresponding * declaration in the wrap D module. * --------------------------------------------------------------------------- */ virtual int functionWrapper(Node *n) { String *symname = Getattr(n, "sym:name"); SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *tm; Parm *p; int i; String *c_return_type = NewString(""); String *im_return_type = NewString(""); String *cleanup = NewString(""); String *outarg = NewString(""); String *body = NewString(""); int num_arguments = 0; bool is_void_return; String *overloaded_name = getOverloadedName(n); if (!Getattr(n, "sym:overloaded")) { if (!addSymbol(Getattr(n, "sym:name"), n)) return SWIG_ERROR; } // A new wrapper function object Wrapper *f = NewWrapper(); // Make a wrapper name for this function String *wname = Swig_name_wrapper(overloaded_name); /* Attach the non-standard typemaps to the parameter list. */ Swig_typemap_attach_parms("ctype", l, f); Swig_typemap_attach_parms("imtype", l, f); /* Get return types */ if ((tm = lookupDTypemap(n, "ctype"))) { String *ctypeout = Getattr(n, "tmap:ctype:out"); if (ctypeout) { // The type in the ctype typemap's out attribute overrides the type in // the typemap itself. tm = ctypeout; } Printf(c_return_type, "%s", tm); } else { Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(t, 0)); } if ((tm = lookupDTypemap(n, "imtype"))) { String *imtypeout = Getattr(n, "tmap:imtype:out"); if (imtypeout) { // The type in the imtype typemap's out attribute overrides the type in // the typemap itself. tm = imtypeout; } Printf(im_return_type, "%s", tm); } else { Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(t, 0)); } is_void_return = (Cmp(c_return_type, "void") == 0); if (!is_void_return) Wrapper_add_localv(f, "jresult", c_return_type, "jresult", NIL); Printv(f->def, " SWIGEXPORT ", c_return_type, " ", wname, "(", NIL); // Emit all of the local variables for holding arguments. emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); // Parameter overloading Setattr(n, "wrap:parms", l); Setattr(n, "wrap:name", wname); // Wrappers not wanted for some methods where the parameters cannot be overloaded in D if (Getattr(n, "sym:overloaded")) { // Emit warnings for the few cases that can't be overloaded in D and give up on generating wrapper Swig_overload_check(n); if (Getattr(n, "overload:ignore")) { DelWrapper(f); return SWIG_OK; } } // Collect the parameter list for the intermediary D module declaration of // the generated wrapper function. String *im_dmodule_parameters = NewString("("); /* Get number of required and total arguments */ num_arguments = emit_num_arguments(l); int gencomma = 0; // Now walk the function parameter list and generate code to get arguments for (i = 0, p = l; i < num_arguments; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); String *im_param_type = NewString(""); String *c_param_type = NewString(""); String *arg = NewString(""); Printf(arg, "j%s", ln); /* Get the ctype types of the parameter */ if ((tm = lookupDTypemap(p, "ctype", true))) { Printv(c_param_type, tm, NIL); } else { Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(pt, 0)); } /* Get the intermediary class parameter types of the parameter */ if ((tm = lookupDTypemap(p, "imtype", true))) { const String *inattributes = Getattr(p, "tmap:imtype:inattributes"); Printf(im_param_type, "%s%s", inattributes ? inattributes : empty_string, tm); } else { Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to intermediary class method */ if (gencomma) Printf(im_dmodule_parameters, ", "); Printf(im_dmodule_parameters, "%s %s", im_param_type, arg); // Add parameter to C function Printv(f->def, gencomma ? ", " : "", c_param_type, " ", arg, NIL); gencomma = 1; // Get typemap for this argument if ((tm = Getattr(p, "tmap:in"))) { canThrow(n, "in", p); Replaceall(tm, "$input", arg); Setattr(p, "emit:input", arg); Printf(f->code, "%s\n", tm); p = Getattr(p, "tmap:in:next"); } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); p = nextSibling(p); } Delete(im_param_type); Delete(c_param_type); Delete(arg); } /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { canThrow(n, "check", p); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { canThrow(n, "freearg", p); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { canThrow(n, "argout", p); Replaceall(tm, "$result", "jresult"); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } // Look for usage of throws typemap and the canthrow flag ParmList *throw_parm_list = NULL; if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { canThrow(n, "throws", p); } } } String *null_attribute = 0; // Now write code to make the function call if (!native_function_flag) { if (Cmp(nodeType(n), "constant") == 0) { // Wrapping a constant hack Swig_save("functionWrapper", n, "wrap:action", NIL); // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); Setattr(n, "wrap:action", NewStringf("%s = (%s) %s;", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value"))); } Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); if (Cmp(nodeType(n), "constant") == 0) Swig_restore(n); /* Return value if necessary */ if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { canThrow(n, "out", n); Replaceall(tm, "$result", "jresult"); if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "1"); else Replaceall(tm, "$owner", "0"); Printf(f->code, "%s", tm); null_attribute = Getattr(n, "tmap:out:null"); if (Len(tm)) Printf(f->code, "\n"); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), Getattr(n, "name")); } emit_return_variable(n, t, f); } /* Output argument output code */ Printv(f->code, outarg, NIL); /* Output cleanup code */ Printv(f->code, cleanup, NIL); /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { canThrow(n, "newfree", n); Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if (!native_function_flag) { if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { canThrow(n, "ret", n); Printf(f->code, "%s\n", tm); } } // Complete D im parameter list and emit the declaration/binding code. Printv(im_dmodule_parameters, ")", NIL); writeImDModuleFunction(overloaded_name, im_return_type, im_dmodule_parameters, wname); Delete(im_dmodule_parameters); // Finish C function header. Printf(f->def, ") {"); if (!is_void_return) Printv(f->code, " return jresult;\n", NIL); Printf(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); /* Substitute the function name */ Replaceall(f->code, "$symname", symname); /* Contract macro modification */ if (Replaceall(f->code, "SWIG_contract_assert(", "SWIG_contract_assert($null, ") > 0) { Setattr(n, "d:canthrow", "1"); } if (!null_attribute) Replaceall(f->code, "$null", "0"); else Replaceall(f->code, "$null", null_attribute); /* Dump the function out */ if (!native_function_flag) { Wrapper_print(f, f_wrappers); // Handle %exception which sets the canthrow attribute. if (Getattr(n, "feature:except:canthrow")) { Setattr(n, "d:canthrow", "1"); } // A very simple check (it is not foolproof) to assist typemap writers // with setting the correct features when the want to throw D exceptions // from C++ code. It checks for the common methods which set // a pending D exception and issues a warning if one of them has been found // in the typemap, but the »canthrow« attribute/feature is not set. if (!Getattr(n, "d:canthrow")) { if (Strstr(f->code, "SWIG_exception")) { Swig_warning(WARN_D_CANTHROW_MISSING, input_file, line_number, "C code contains a call to SWIG_exception and D code does not handle pending exceptions via the canthrow attribute.\n"); } else if (Strstr(f->code, "SWIG_DSetPendingException")) { Swig_warning(WARN_D_CANTHROW_MISSING, input_file, line_number, "C code contains a call to a SWIG_DSetPendingException method and D code does not handle pending exceptions via the canthrow attribute.\n"); } } } // If we are not processing an enum or constant, and we were not generating // a wrapper function which will be accessed via a proxy class, write a // function to the proxy D module. if (!is_wrapping_class()) { writeProxyDModuleFunction(n); } // If we are processing a public member variable, write the property-style // member function to the proxy class. if (wrapping_member_flag) { Setattr(n, "proxyfuncname", variable_name); Setattr(n, "imfuncname", symname); writeProxyClassFunction(n); } Delete(c_return_type); Delete(im_return_type); Delete(cleanup); Delete(outarg); Delete(body); Delete(overloaded_name); DelWrapper(f); return SWIG_OK; } /* --------------------------------------------------------------------------- * D::nativeWrapper() * --------------------------------------------------------------------------- */ virtual int nativeWrapper(Node *n) { String *wrapname = Getattr(n, "wrap:name"); if (!addSymbol(wrapname, n)) return SWIG_ERROR; if (Getattr(n, "type")) { Swig_save("nativeWrapper", n, "name", NIL); Setattr(n, "name", wrapname); native_function_flag = true; functionWrapper(n); Swig_restore(n); native_function_flag = false; } else { Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name")); } return SWIG_OK; } /* --------------------------------------------------------------------------- * D::classDirector() * --------------------------------------------------------------------------- */ virtual int classDirector(Node *n) { String *nspace = Getattr(n, "sym:nspace"); proxy_class_name = NewString(Getattr(n, "sym:name")); if (nspace) { proxy_class_qname = NewStringf("%s.%s", nspace, proxy_class_name); } else { proxy_class_qname = Copy(proxy_class_name); } int success = Language::classDirector(n); Delete(proxy_class_qname); proxy_class_qname = NULL; Delete(proxy_class_name); proxy_class_name = NULL; return success; } /* --------------------------------------------------------------------------- * D::classDirectorInit() * --------------------------------------------------------------------------- */ virtual int classDirectorInit(Node *n) { Delete(director_ctor_code); director_ctor_code = NewString("$director_new"); // Write C++ director class declaration, for example: // class SwigDirector_myclass : public myclass, public Swig::Director { String *classname = Swig_class_name(n); String *directorname = directorClassName(n); String *declaration = Swig_class_declaration(n, directorname); const String *base = Getattr(n, "classtype"); Printf(f_directors_h, "%s : public %s, public Swig::Director {\n", declaration, base); Printf(f_directors_h, "\npublic:\n"); Delete(declaration); Delete(directorname); Delete(classname); // Stash for later. Setattr(n, "director:ctor", NewString("Swig::Director()")); // Keep track of the director methods for this class. first_class_dmethod = curr_class_dmethod = n_dmethods; director_callback_typedefs = NewString(""); director_callback_pointers = NewString(""); director_dcallbacks_code = NewString(""); return Language::classDirectorInit(n); } /* --------------------------------------------------------------------------- * D::classDirectorMethod() * * Emit a virtual director method to pass a method call on to the * underlying D object. * --------------------------------------------------------------------------- */ virtual int classDirectorMethod(Node *n, Node *parent, String *super) { String *classname = Getattr(parent, "sym:name"); String *c_classname = Getattr(parent, "name"); String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *returntype = Getattr(n, "type"); String *overloaded_name = getOverloadedName(n); String *storage = Getattr(n, "storage"); String *value = Getattr(n, "value"); String *decl = Getattr(n, "decl"); String *declaration = NewString(""); String *tm; Parm *p; int i; Wrapper *w = NewWrapper(); ParmList *l = Getattr(n, "parms"); bool is_void = !(Cmp(returntype, "void")); String *qualified_return = 0; bool pure_virtual = (!(Cmp(storage, "virtual")) && !(Cmp(value, "0"))); int status = SWIG_OK; bool output_director = true; String *dirclassname = directorClassName(parent); String *qualified_name = NewStringf("%s::%s", dirclassname, name); SwigType *c_ret_type = NULL; String *dcallback_call_args = NewString(""); String *imclass_dmethod; String *callback_typedef_parms = NewString(""); String *delegate_parms = NewString(""); String *proxy_method_param_list = NewString(""); String *proxy_callback_return_type = NewString(""); String *callback_def = NewString(""); String *callback_code = NewString(""); String *imcall_args = NewString(""); bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; // Kludge Alert: functionWrapper sets sym:overload properly, but it // isn't at this point, so we have to manufacture it ourselves. At least // we're consistent with the sym:overload name in functionWrapper. (?? when // does the overloaded method name get set?) imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), classname, overloaded_name)); qualified_return = SwigType_rcaststr(returntype, "c_result"); if (!is_void && !ignored_method) { if (!SwigType_isclass(returntype)) { if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); Delete(construct_result); } else { String *base_typename = SwigType_base(returntype); String *resolved_typename = SwigType_typedef_resolve_all(base_typename); Symtab *symtab = Getattr(n, "sym:symtab"); Node *typenode = Swig_symbol_clookup(resolved_typename, symtab); if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstracts"))) { /* initialize pointers to something sane. Same for abstract classes when a reference is returned. */ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); } else { /* If returning a reference, initialize the pointer to a sane default - if a D exception occurs, then the pointer returns something other than a NULL-initialized reference. */ String *non_ref_type = Copy(returntype); /* Remove reference and const qualifiers */ Replaceall(non_ref_type, "r.", ""); Replaceall(non_ref_type, "q(const).", ""); Wrapper_add_localv(w, "result_default", "static", SwigType_str(non_ref_type, "result_default"), "=", SwigType_str(non_ref_type, "()"), NIL); Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= &result_default", NIL); Delete(non_ref_type); } Delete(base_typename); Delete(resolved_typename); } } else { SwigType *vt; vt = cplus_value_type(returntype); if (!vt) { Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL); } else { Wrapper_add_localv(w, "c_result", SwigType_lstr(vt, "c_result"), NIL); Delete(vt); } } } /* Create the intermediate class wrapper */ tm = lookupDTypemap(n, "imtype"); if (tm) { String *imtypeout = Getattr(n, "tmap:imtype:out"); if (imtypeout) { // The type in the imtype typemap's out attribute overrides the type // in the typemap. tm = imtypeout; } Printf(callback_def, "\nprivate extern(C) %s swigDirectorCallback_%s_%s(void* dObject", tm, classname, overloaded_name); Printv(proxy_callback_return_type, tm, NIL); } else { Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0)); } if ((c_ret_type = Swig_typemap_lookup("ctype", n, "", 0))) { if (!is_void && !ignored_method) { String *jretval_decl = NewStringf("%s jresult", c_ret_type); Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL); Delete(jretval_decl); } } else { Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } Swig_director_parms_fixup(l); // Attach the standard typemaps. Swig_typemap_attach_parms("out", l, 0); Swig_typemap_attach_parms("ctype", l, 0); Swig_typemap_attach_parms("imtype", l, 0); Swig_typemap_attach_parms("dtype", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("ddirectorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); // Preamble code. if (!ignored_method) Printf(w->code, "if (!swig_callback_%s) {\n", overloaded_name); if (!pure_virtual) { String *super_call = Swig_method_call(super, l); if (is_void) { Printf(w->code, "%s;\n", super_call); if (!ignored_method) Printf(w->code, "return;\n"); } else { Printf(w->code, "return %s;\n", super_call); } Delete(super_call); } else { Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } if (!ignored_method) Printf(w->code, "} else {\n"); // Go through argument list. for (i = 0, p = l; p; ++i) { /* Is this superfluous? */ while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } SwigType *pt = Getattr(p, "type"); String *ln = makeParameterName(n, p, i, false); String *c_param_type = NULL; String *c_decl = NewString(""); String *arg = NewString(""); Printf(arg, "j%s", ln); // Add each parameter to the D callback invocation arguments. Printf(dcallback_call_args, ", %s", arg); /* Get parameter's intermediary C type */ if ((c_param_type = lookupDTypemap(p, "ctype", true))) { String *ctypeout = Getattr(p, "tmap:ctype:out"); if (ctypeout) { // The type in the ctype typemap's out attribute overrides the type // in the typemap itself. c_param_type = ctypeout; } /* Add to local variables */ Printf(c_decl, "%s %s", c_param_type, arg); if (!ignored_method) Wrapper_add_localv(w, arg, c_decl, (!(SwigType_ispointer(pt) || SwigType_isreference(pt)) ? "" : "= 0"), NIL); /* Add input marshalling code */ if ((tm = Getattr(p, "tmap:directorin"))) { Setattr(p, "emit:directorinput", arg); Replaceall(tm, "$input", arg); Replaceall(tm, "$owner", "0"); if (Len(tm)) if (!ignored_method) Printf(w->code, "%s\n", tm); // Add parameter type to the C typedef for the D callback function. Printf(callback_typedef_parms, ", %s", c_param_type); /* Add parameter to the intermediate class code if generating the * intermediate's upcall code */ if ((tm = lookupDTypemap(p, "imtype", true))) { String *imtypeout = Getattr(p, "tmap:imtype:out"); if (imtypeout) { // The type in the imtype typemap's out attribute overrides the // type in the typemap itself. tm = imtypeout; } const String *im_directorinattributes = Getattr(p, "tmap:imtype:directorinattributes"); // TODO: Is this copy really needed? String *din = Copy(lookupDTypemap(p, "ddirectorin", true)); if (din) { Replaceall(din, "$winput", ln); Printf(delegate_parms, ", "); if (i > 0) { Printf(proxy_method_param_list, ", "); Printf(imcall_args, ", "); } Printf(delegate_parms, "%s%s %s", im_directorinattributes ? im_directorinattributes : empty_string, tm, ln); if (Cmp(din, ln)) { Printv(imcall_args, din, NIL); } else { Printv(imcall_args, ln, NIL); } Delete(din); // Get the parameter type in the proxy D class (used later when // generating the overload checking code for the directorConnect // function). if ((tm = lookupDTypemap(p, "dtype", true))) { Printf(proxy_method_param_list, "%s", tm); } else { Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number, "No dtype typemap defined for %s\n", SwigType_str(pt, 0)); } } else { Swig_warning(WARN_D_TYPEMAP_DDIRECTORIN_UNDEF, input_file, line_number, "No ddirectorin typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } } else { Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } p = Getattr(p, "tmap:directorin:next"); } else { Swig_warning(WARN_D_TYPEMAP_DDIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = nextSibling(p); output_director = false; } } else { Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; p = nextSibling(p); } Delete(arg); Delete(c_decl); Delete(c_param_type); Delete(ln); } /* header declaration, start wrapper definition */ String *target; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); target = Swig_method_decl(rtype, decl, name, l, 0, 1); Printf(declaration, " virtual %s", target); Delete(target); // Add any exception specifications to the methods in the director class ParmList *throw_parm_list = NULL; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { int gencomma = 0; Append(w->def, " throw("); Append(declaration, " throw("); if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); } Printf(w->def, "%s", SwigType_str(Getattr(p, "type"), 0)); Printf(declaration, "%s", SwigType_str(Getattr(p, "type"), 0)); } } Append(w->def, ")"); Append(declaration, ")"); } Append(w->def, " {"); Append(declaration, ";\n"); // Finish the callback function declaraction. Printf(callback_def, "%s)", delegate_parms); Printf(callback_def, " {\n"); /* Emit the intermediate class's upcall to the actual class */ String *upcall = NewStringf("(cast(%s)dObject).%s(%s)", classname, symname, imcall_args); if (!is_void) { if ((tm = lookupDTypemap(n, "ddirectorout"))) { Replaceall(tm, "$dcall", upcall); Printf(callback_code, " return %s;\n", tm); } } else { Printf(callback_code, " %s;\n", upcall); } Printf(callback_code, "}\n"); Delete(upcall); if (!ignored_method) { if (!is_void) Printf(w->code, "jresult = (%s) ", c_ret_type); Printf(w->code, "swig_callback_%s(d_object%s);\n", overloaded_name, dcallback_call_args); if (!is_void) { String *jresult_str = NewString("jresult"); String *result_str = NewString("c_result"); /* Copy jresult into c_result... */ if ((tm = Swig_typemap_lookup("directorout", n, result_str, w))) { Replaceall(tm, "$input", jresult_str); Replaceall(tm, "$result", result_str); Printf(w->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use return type %s used in %s::%s (skipping director method)\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } Delete(jresult_str); Delete(result_str); } /* Marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout"))) { canThrow(n, "directorargout", p); Replaceall(tm, "$result", "jresult"); Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } /* Terminate wrapper code */ Printf(w->code, "}\n"); if (!is_void) Printf(w->code, "return %s;", qualified_return); } Printf(w->code, "}"); // We expose virtual protected methods via an extra public inline method which makes a straight call to the wrapped class' method String *inline_extra_method = NewString(""); if (dirprot_mode() && !is_public(n) && !pure_virtual) { Printv(inline_extra_method, declaration, NIL); String *extra_method_name = NewStringf("%sSwigPublic", name); Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, ";\n", " {\n "); if (!is_void) Printf(inline_extra_method, "return "); String *methodcall = Swig_method_call(super, l); Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Delete(methodcall); Delete(extra_method_name); } /* emit the director method */ if (status == SWIG_OK && output_director) { if (!is_void) { Replaceall(w->code, "$null", qualified_return); } else { Replaceall(w->code, "$null", ""); } if (!ignored_method) Printv(director_dcallbacks_code, callback_def, callback_code, NIL); if (!Getattr(n, "defaultargs")) { Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); } } if (!ignored_method) { // Register the upcall method so that the callback registering code can // be written later. // We cannot directly use n here because its »type« attribute does not // the full return type any longer after Language::functionHandler has // returned. String *dp_return_type = lookupDTypemap(n, "dtype"); if (dp_return_type) { String *dtypeout = Getattr(n, "tmap:dtype:out"); if (dtypeout) { // The type in the dtype typemap's out attribute overrides the type // in the typemap itself. dp_return_type = dtypeout; replaceClassname(dp_return_type, returntype); } } else { Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number, "No dtype typemap defined for %s\n", SwigType_str(returntype, 0)); dp_return_type = NewString(""); } UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, decl, overloaded_name, dp_return_type, proxy_method_param_list); Delete(dp_return_type); // Write the global callback function pointer on the C code. String *methid = Getattr(udata, "class_methodidx"); Printf(director_callback_typedefs, " typedef %s (* SWIG_Callback%s_t)", c_ret_type, methid); Printf(director_callback_typedefs, "(void *dobj%s);\n", callback_typedef_parms); Printf(director_callback_pointers, " SWIG_Callback%s_t swig_callback_%s;\n", methid, overloaded_name); // Write the type alias for the callback to the intermediary D module. String *proxy_callback_type = NewString(""); String *dirClassName = directorClassName(parent); Printf(proxy_callback_type, "%s_Callback%s", dirClassName, methid); Printf(im_dmodule_code, "alias extern(C) %s function(void*%s) %s;\n", proxy_callback_return_type, delegate_parms, proxy_callback_type); Delete(proxy_callback_type); Delete(dirClassName); } Delete(qualified_return); Delete(c_ret_type); Delete(declaration); Delete(callback_typedef_parms); Delete(delegate_parms); Delete(proxy_method_param_list); Delete(callback_def); Delete(callback_code); DelWrapper(w); return status; } /* --------------------------------------------------------------------------- * D::classDirectorConstructor() * --------------------------------------------------------------------------- */ virtual int classDirectorConstructor(Node *n) { Node *parent = parentNode(n); String *decl = Getattr(n, "decl");; String *supername = Swig_class_name(parent); String *dirclassname = directorClassName(parent); String *sub = NewString(""); Parm *p; ParmList *superparms = Getattr(n, "parms"); ParmList *parms; int argidx = 0; /* Assign arguments to superclass's parameters, if not already done */ for (p = superparms; p; p = nextSibling(p)) { String *pname = Getattr(p, "name"); if (!pname) { pname = NewStringf("arg%d", argidx++); Setattr(p, "name", pname); } } // TODO: Is this copy needed? parms = CopyParmList(superparms); if (!Getattr(n, "defaultargs")) { /* constructor */ { String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 0); String *call = Swig_csuperclass_call(0, basetype, superparms); String *classtype = SwigType_namestr(Getattr(n, "name")); Printf(f_directors, "%s::%s : %s, %s {\n", dirclassname, target, call, Getattr(parent, "director:ctor")); Printf(f_directors, " swig_init_callbacks();\n"); Printf(f_directors, "}\n\n"); Delete(classtype); Delete(target); Delete(call); } /* constructor header */ { String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } } Delete(sub); Delete(supername); Delete(parms); Delete(dirclassname); return Language::classDirectorConstructor(n); } /* --------------------------------------------------------------------------- * D::classDirectorDefaultConstructor() * --------------------------------------------------------------------------- */ virtual int classDirectorDefaultConstructor(Node *n) { String *dirclassname = directorClassName(n); String *classtype = SwigType_namestr(Getattr(n, "name")); Wrapper *w = NewWrapper(); Printf(w->def, "%s::%s() : %s {", dirclassname, dirclassname, Getattr(n, "director:ctor")); Printf(w->code, "}\n"); Wrapper_print(w, f_directors); Printf(f_directors_h, " %s();\n", dirclassname); DelWrapper(w); Delete(classtype); Delete(dirclassname); return Language::classDirectorDefaultConstructor(n); } /* --------------------------------------------------------------------------- * D::classDirectorDestructor() * --------------------------------------------------------------------------- */ virtual int classDirectorDestructor(Node *n) { Node *current_class = getCurrentClass(); String *dirclassname = directorClassName(current_class); Wrapper *w = NewWrapper(); if (Getattr(n, "throw")) { Printf(f_directors_h, " virtual ~%s() throw ();\n", dirclassname); Printf(w->def, "%s::~%s() throw () {\n", dirclassname, dirclassname); } else { Printf(f_directors_h, " virtual ~%s();\n", dirclassname); Printf(w->def, "%s::~%s() {\n", dirclassname, dirclassname); } Printv(w->code, "}\n", NIL); Wrapper_print(w, f_directors); DelWrapper(w); Delete(dirclassname); return SWIG_OK; } /* --------------------------------------------------------------------------- * D::classDirectorEnd() * --------------------------------------------------------------------------- */ virtual int classDirectorEnd(Node *n) { int i; String *director_classname = directorClassName(n); Wrapper *w = NewWrapper(); if (Len(director_callback_typedefs) > 0) { Printf(f_directors_h, "\n%s", director_callback_typedefs); } Printf(f_directors_h, " void swig_connect_director(void* dobj"); Printf(w->def, "void %s::swig_connect_director(void* dobj", director_classname); Printf(w->code, "d_object = dobj;"); for (i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *methid = Getattr(udata, "class_methodidx"); String *overname = Getattr(udata, "overname"); Printf(f_directors_h, ", SWIG_Callback%s_t callback%s", methid, overname); Printf(w->def, ", SWIG_Callback%s_t callback_%s", methid, overname); Printf(w->code, "swig_callback_%s = callback_%s;\n", overname, overname); } Printf(f_directors_h, ");\n"); Printf(w->def, ") {"); Printf(f_directors_h, "\nprivate:\n"); Printf(f_directors_h, " void swig_init_callbacks();\n"); Printf(f_directors_h, " void *d_object;\n"); if (Len(director_callback_pointers) > 0) { Printf(f_directors_h, "%s", director_callback_pointers); } Printf(f_directors_h, "};\n\n"); Printf(w->code, "}\n\n"); Printf(w->code, "void %s::swig_init_callbacks() {\n", director_classname); for (i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *overname = Getattr(udata, "overname"); Printf(w->code, "swig_callback_%s = 0;\n", overname); } Printf(w->code, "}"); Wrapper_print(w, f_directors); DelWrapper(w); return Language::classDirectorEnd(n); } /* --------------------------------------------------------------------------- * D::classDirectorDisown() * --------------------------------------------------------------------------- */ virtual int classDirectorDisown(Node *n) { (void) n; return SWIG_OK; } /* --------------------------------------------------------------------------- * D::replaceSpecialVariables() * --------------------------------------------------------------------------- */ virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) { (void)method; SwigType *type = Getattr(parm, "type"); // Just assume that this goes to the proxy class, we cannot know. replaceClassname(tm, type); } protected: /* --------------------------------------------------------------------------- * D::extraDirectorProtectedCPPMethodsRequired() * --------------------------------------------------------------------------- */ virtual bool extraDirectorProtectedCPPMethodsRequired() const { return false; } private: /* --------------------------------------------------------------------------- * D::writeImDModuleFunction() * * Writes a function declaration for the given (C) wrapper function to the * intermediary D module. * * d_name - The name the function in the intermediary D module will get. * return type - The return type of the function in the C wrapper. * parameters - The parameter list of the C wrapper function. * wrapper_function_name - The name of the exported function in the C wrapper * (usually d_name prefixed by »D_«). * --------------------------------------------------------------------------- */ void writeImDModuleFunction(const_String_or_char_ptr d_name, const_String_or_char_ptr return_type, const_String_or_char_ptr parameters, const_String_or_char_ptr wrapper_function_name) { // TODO: Add support for static linking here. Printf(im_dmodule_code, "extern(C) %s function%s %s;\n", return_type, parameters, d_name); Printv(wrapper_loader_bind_code, wrapper_loader_bind_command, NIL); Replaceall(wrapper_loader_bind_code, "$function", d_name); Replaceall(wrapper_loader_bind_code, "$symbol", wrapper_function_name); } /* --------------------------------------------------------------------------- * D::writeProxyClassFunction() * * Creates a D proxy function for a C++ function in the wrapped class. Used * for both static and non-static C++ class functions. * * The Node must contain two extra attributes. * - "proxyfuncname": The name of the D proxy function. * - "imfuncname": The corresponding function in the intermediary D module. * --------------------------------------------------------------------------- */ void writeProxyClassFunction(Node *n) { SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *intermediary_function_name = Getattr(n, "imfuncname"); String *proxy_function_name = Getattr(n, "proxyfuncname"); String *tm; Parm *p; int i; String *imcall = NewString(""); String *return_type = NewString(""); String *function_code = NewString(""); bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); String *terminator_code = NewString(""); // Wrappers not wanted for some methods where the parameters cannot be // overloaded in D. if (Getattr(n, "overload:ignore")) return; // Don't generate proxy method for additional explicitcall method used in // directors. if (GetFlag(n, "explicitcall")) return; // RESEARCH: What is this good for? if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { l = nextSibling(l); } } /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); Swig_typemap_attach_parms("dtype", l, NULL); Swig_typemap_attach_parms("din", l, NULL); // Get return types. if ((tm = lookupDTypemap(n, "dtype"))) { String *dtypeout = Getattr(n, "tmap:dtype:out"); if (dtypeout) { // The type in the dtype typemap's out attribute overrides the type in // the typemap. tm = dtypeout; replaceClassname(tm, t); } Printf(return_type, "%s", tm); } else { Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number, "No dtype typemap defined for %s\n", SwigType_str(t, 0)); } if (wrapping_member_flag) { // Check if this is a setter method for a public member. const String *setter_name = Swig_name_set(getNSpace(), Swig_name_member(0, proxy_class_name, variable_name)); if (Cmp(Getattr(n, "sym:name"), setter_name) == 0) { setter_flag = true; } } // Write function modifiers. { String *modifiers; const String *mods_override = Getattr(n, "feature:d:methodmodifiers"); if (mods_override) { modifiers = Copy(mods_override); } else { modifiers = Copy(is_public(n) ? public_string : protected_string); if (Getattr(n, "override")) { Printf(modifiers, " override"); } } if (is_smart_pointer()) { // Smart pointer classes do not mirror the inheritance hierarchy of the // underlying pointer type, so no override required. Replaceall(modifiers, "override", ""); } Chop(modifiers); if (static_flag) { Printf(modifiers, " static"); } Printf(function_code, "%s ", modifiers); Delete(modifiers); } // Complete the function declaration up to the parameter list. Printf(function_code, "%s %s(", return_type, proxy_function_name); // Write the wrapper function call up to the parameter list. Printv(imcall, im_dmodule_fq_name, ".$imfuncname(", NIL); if (!static_flag) { Printf(imcall, "cast(void*)swigCPtr"); } String *proxy_param_types = NewString(""); // Write the parameter list for the proxy function declaration and the // wrapper function call. emit_mark_varargs(l); int gencomma = !static_flag; for (i = 0, p = l; p; i++) { // Ignored varargs. if (checkAttribute(p, "varargs:ignore", "1")) { p = nextSibling(p); continue; } // Ignored parameters. if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } // Ignore the 'this' argument for variable wrappers. if (!(variable_wrapper_flag && i == 0)) { String *param_name = makeParameterName(n, p, i, setter_flag); SwigType *pt = Getattr(p, "type"); // Write the wrapper function call argument. { if (gencomma) { Printf(imcall, ", "); } if ((tm = lookupDTypemap(p, "din", true))) { Replaceall(tm, "$dinput", param_name); String *pre = Getattr(p, "tmap:din:pre"); if (pre) { replaceClassname(pre, pt); Replaceall(pre, "$dinput", param_name); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:din:post"); if (post) { replaceClassname(post, pt); Replaceall(post, "$dinput", param_name); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } String *terminator = Getattr(p, "tmap:din:terminator"); if (terminator) { replaceClassname(terminator, pt); Replaceall(terminator, "$dinput", param_name); if (Len(terminator_code) > 0) Insert(terminator_code, 0, "\n"); Insert(terminator_code, 0, terminator); } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_D_TYPEMAP_DIN_UNDEF, input_file, line_number, "No din typemap defined for %s\n", SwigType_str(pt, 0)); } } // Write the D proxy function parameter. { String *proxy_type = NewString(""); if ((tm = lookupDTypemap(p, "dtype"))) { const String *inattributes = Getattr(p, "tmap:dtype:inattributes"); Printf(proxy_type, "%s%s", inattributes ? inattributes : empty_string, tm); } else { Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number, "No dtype typemap defined for %s\n", SwigType_str(pt, 0)); } if (gencomma >= 2) { Printf(function_code, ", "); Printf(proxy_param_types, ", "); } gencomma = 2; Printf(function_code, "%s %s", proxy_type, param_name); Append(proxy_param_types, proxy_type); Delete(proxy_type); } Delete(param_name); } p = Getattr(p, "tmap:in:next"); } Printf(imcall, ")"); Printf(function_code, ") "); if (d_version > 1 && wrapping_member_flag) { Printf(function_code, "@property "); } if (wrapMemberFunctionAsDConst(n)) { Printf(function_code, "const "); } // Lookup the code used to convert the wrapper return value to the proxy // function return type. if ((tm = lookupDTypemap(n, "dout"))) { replaceExcode(n, tm, "dout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; bool is_terminator_code = Len(terminator_code) > 0; if (is_pre_code || is_post_code || is_terminator_code) { if (is_post_code) { Insert(tm, 0, "\n try "); Printv(tm, " finally {\n", post_code, "\n }", NIL); } else { Insert(tm, 0, "\n "); } if (is_pre_code) { Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } if (is_terminator_code) { Printv(tm, "\n", terminator_code, NIL); } Insert(tm, 0, "{"); Printv(tm, "}", NIL); } if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); replaceClassname(tm, t); // For director methods: generate code to selectively make a normal // polymorphic call or an explicit method call. Needed to prevent infinite // recursion when calling director methods. Node *explicit_n = Getattr(n, "explicitcallnode"); if (explicit_n) { String *ex_overloaded_name = getOverloadedName(explicit_n); String *ex_intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, ex_overloaded_name); String *ex_imcall = Copy(imcall); Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name); Replaceall(imcall, "$imfuncname", intermediary_function_name); String *excode = NewString(""); if (!Cmp(return_type, "void")) Printf(excode, "if (swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) %s; else %s", return_type, proxy_param_types, return_type, proxy_param_types, proxy_function_name, ex_imcall, imcall); else Printf(excode, "((swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) ? %s : %s)", return_type, proxy_param_types, return_type, proxy_param_types, proxy_function_name, ex_imcall, imcall); Clear(imcall); Printv(imcall, excode, NIL); Delete(ex_overloaded_name); Delete(excode); } else { Replaceall(imcall, "$imfuncname", intermediary_function_name); } Replaceall(tm, "$imcall", imcall); } else { Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number, "No dout typemap defined for %s\n", SwigType_str(t, 0)); } Delete(proxy_param_types); // The whole function body is now in stored tm (if there was a matching type // map, of course), so simply append it to the code buffer. The braces are // included in the typemap. Printv(function_code, tm, NIL); // Write function code buffer to the class code. Printv(proxy_class_body_code, "\n", function_code, "\n", NIL); Delete(pre_code); Delete(post_code); Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); } /* --------------------------------------------------------------------------- * D::writeProxyDModuleFunction() * --------------------------------------------------------------------------- */ void writeProxyDModuleFunction(Node *n) { SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *tm; Parm *p; int i; String *imcall = NewString(""); String *return_type = NewString(""); String *function_code = NewString(""); int num_arguments = 0; String *overloaded_name = getOverloadedName(n); String *func_name = NULL; String *pre_code = NewString(""); String *post_code = NewString(""); String *terminator_code = NewString(""); // RESEARCH: What is this good for? if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { l = nextSibling(l); } } /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("dtype", l, NULL); Swig_typemap_attach_parms("din", l, NULL); /* Get return types */ if ((tm = lookupDTypemap(n, "dtype"))) { String *dtypeout = Getattr(n, "tmap:dtype:out"); if (dtypeout) { // The type in the dtype typemap's out attribute overrides the type in // the typemap. tm = dtypeout; replaceClassname(tm, t); } Printf(return_type, "%s", tm); } else { Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number, "No dtype typemap defined for %s\n", SwigType_str(t, 0)); } /* Change function name for global variables */ if (global_variable_flag) { // RESEARCH: Is the Copy() needed here? func_name = Copy(variable_name); } else { func_name = Copy(Getattr(n, "sym:name")); } /* Start generating the function */ const String *outattributes = Getattr(n, "tmap:dtype:outattributes"); if (outattributes) Printf(function_code, " %s\n", outattributes); const String *methodmods = Getattr(n, "feature:d:methodmodifiers"); // TODO: Check if is_public(n) could possibly make any sense here // (private global functions would be useless anyway?). methodmods = methodmods ? methodmods : empty_string; Printf(function_code, "\n%s%s %s(", methodmods, return_type, func_name); Printv(imcall, im_dmodule_fq_name, ".", overloaded_name, "(", NIL); /* Get number of required and total arguments */ num_arguments = emit_num_arguments(l); int gencomma = 0; /* Output each parameter */ for (i = 0, p = l; i < num_arguments; i++) { /* Ignored parameters */ while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); // Get the D parameter type. if ((tm = lookupDTypemap(p, "dtype", true))) { const String *inattributes = Getattr(p, "tmap:dtype:inattributes"); Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm); } else { Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number, "No dtype typemap defined for %s\n", SwigType_str(pt, 0)); } if (gencomma) Printf(imcall, ", "); const bool generating_setter = global_variable_flag || wrapping_member_flag; String *arg = makeParameterName(n, p, i, generating_setter); // Get the D code to convert the parameter value to the type used in the // wrapper D module. if ((tm = lookupDTypemap(p, "din", true))) { Replaceall(tm, "$dinput", arg); String *pre = Getattr(p, "tmap:din:pre"); if (pre) { replaceClassname(pre, pt); Replaceall(pre, "$dinput", arg); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:din:post"); if (post) { replaceClassname(post, pt); Replaceall(post, "$dinput", arg); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } String *terminator = Getattr(p, "tmap:din:terminator"); if (terminator) { replaceClassname(terminator, pt); Replaceall(terminator, "$dinput", arg); if (Len(terminator_code) > 0) Insert(terminator_code, 0, "\n"); Insert(terminator_code, 0, terminator); } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_D_TYPEMAP_DIN_UNDEF, input_file, line_number, "No din typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to module class function */ if (gencomma >= 2) Printf(function_code, ", "); gencomma = 2; Printf(function_code, "%s %s", param_type, arg); p = Getattr(p, "tmap:in:next"); Delete(arg); Delete(param_type); } Printf(imcall, ")"); Printf(function_code, ") "); if (global_variable_flag && (d_version > 1)) { Printf(function_code, "@property "); } // Lookup the code used to convert the wrapper return value to the proxy // function return type. if ((tm = lookupDTypemap(n, "dout"))) { replaceExcode(n, tm, "dout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; bool is_terminator_code = Len(terminator_code) > 0; if (is_pre_code || is_post_code || is_terminator_code) { if (is_post_code) { Insert(tm, 0, "\n try "); Printv(tm, " finally {\n", post_code, "\n }", NIL); } else { Insert(tm, 0, "\n "); } if (is_pre_code) { Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } if (is_terminator_code) { Printv(tm, "\n", terminator_code, NIL); } Insert(tm, 0, " {"); Printf(tm, "\n}"); } if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); replaceClassname(tm, t); Replaceall(tm, "$imcall", imcall); } else { Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number, "No dout typemap defined for %s\n", SwigType_str(t, 0)); } // The whole function code is now stored in tm (if there was a matching // type map, of course), so simply append it to the code buffer. Printf(function_code, "%s\n", tm ? (const String *) tm : empty_string); Printv(proxyCodeBuffer(getNSpace()), function_code, NIL); Delete(pre_code); Delete(post_code); Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); Delete(func_name); } /* --------------------------------------------------------------------------- * D::writeProxyClassAndUpcasts() * * Collects all the code fragments generated by the handler function while * traversing the tree from the proxy_class_* variables and writes the * class definition (including any epilogue code) to proxy_class_code. * * Also writes the upcast function to the wrapper layer when processing a * derived class. * * Inputs: * n – The class node currently processed. * --------------------------------------------------------------------------- */ void writeProxyClassAndUpcasts(Node *n) { SwigType *typemap_lookup_type = Getattr(n, "classtypeobj"); /* * Handle inheriting from D and C++ classes. */ String *c_classname = SwigType_namestr(Getattr(n, "name")); String *c_baseclass = NULL; Node *basenode = NULL; String *basename = NULL; String *c_baseclassname = NULL; // Inheritance from pure D classes. Node *attributes = NewHash(); const String *pure_baseclass = lookupCodeTypemap(n, "dbase", typemap_lookup_type, WARN_NONE, attributes); bool purebase_replace = GetFlag(attributes, "tmap:dbase:replace") ? true : false; bool purebase_notderived = GetFlag(attributes, "tmap:dbase:notderived") ? true : false; Delete(attributes); // C++ inheritance. if (!purebase_replace) { List *baselist = Getattr(n, "bases"); if (baselist) { Iterator base = First(baselist); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } if (base.item) { basenode = base.item; c_baseclassname = Getattr(base.item, "name"); basename = createProxyName(c_baseclassname); if (basename) c_baseclass = SwigType_namestr(Getattr(base.item, "name")); base = Next(base); /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { if (GetFlag(base.item, "feature:ignore")) { base = Next(base); continue; } String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Base %s of class %s ignored: multiple inheritance is not supported in D.\n", baseclassname, proxyclassname); base = Next(base); } } } } bool derived = (basename != NULL); if (derived && purebase_notderived) { pure_baseclass = empty_string; } const String *wanted_base = basename ? basename : pure_baseclass; if (purebase_replace) { wanted_base = pure_baseclass; derived = false; basenode = NULL; Delete(basename); basename = NULL; if (purebase_notderived) { Swig_error(Getfile(n), Getline(n), "The dbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); } } else if (basename && Len(pure_baseclass) > 0) { Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base class %s ignored. Multiple inheritance is not supported in D. " "Perhaps you need one of the 'replace' or 'notderived' attributes in the dbase typemap?\n", typemap_lookup_type, pure_baseclass); } // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { writeClassUpcast(n, proxy_class_name, c_classname, c_baseclass); } /* * Write needed imports. */ // If this class is derived from a C++ class, we need to have the D class // generated for it in scope. if (derived) { requireDType(Getattr(basenode, "sym:nspace"), Getattr(basenode, "sym:name")); } // Write any custom import statements to the proxy module header. const String *imports = lookupCodeTypemap(n, "dimports", typemap_lookup_type, WARN_NONE); if (Len(imports) > 0) { String* imports_trimmed = Copy(imports); Chop(imports_trimmed); replaceImportTypeMacros(imports_trimmed); Printv(proxy_class_imports, imports_trimmed, "\n", NIL); Delete(imports_trimmed); } /* * Write the proxy class header. */ // Class modifiers. const String *modifiers = lookupCodeTypemap(n, "dclassmodifiers", typemap_lookup_type, WARN_D_TYPEMAP_CLASSMOD_UNDEF); // User-defined interfaces. const String *interfaces = lookupCodeTypemap(n, derived ? "dinterfaces_derived" : "dinterfaces", typemap_lookup_type, WARN_NONE); Printv(proxy_class_code, "\n", modifiers, " $dclassname", (*Char(wanted_base) || *Char(interfaces)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(interfaces)) ? ", " : "", interfaces, " {", NIL); /* * Write the proxy class body. */ String* body = NewString(""); // Default class body. const String *dbody; if (derived) { dbody = lookupCodeTypemap(n, "dbody_derived", typemap_lookup_type, WARN_D_TYPEMAP_DBODY_UNDEF); } else { dbody = lookupCodeTypemap(n, "dbody", typemap_lookup_type, WARN_D_TYPEMAP_DBODY_UNDEF); } Printv(body, dbody, NIL); // Destructor and dispose(). // If the C++ destructor is accessible (public), it is wrapped by the // dispose() method which is also called by the emitted D constructor. If it // is not accessible, no D destructor is written and the generated dispose() // method throws an exception. // This enables C++ classes with protected or private destructors to be used // in D as it would be used in C++ (GC finalization is a no-op then because // of the empty D destructor) while preventing usage in »scope« variables. // The method name for the dispose() method is specified in a typemap // attribute called »methodname«. const String *tm = NULL; String *dispose_methodname; String *dispose_methodmodifiers; attributes = NewHash(); if (derived) { tm = lookupCodeTypemap(n, "ddispose_derived", typemap_lookup_type, WARN_NONE, attributes); dispose_methodname = Getattr(attributes, "tmap:ddispose_derived:methodname"); dispose_methodmodifiers = Getattr(attributes, "tmap:ddispose_derived:methodmodifiers"); } else { tm = lookupCodeTypemap(n, "ddispose", typemap_lookup_type, WARN_NONE, attributes); dispose_methodname = Getattr(attributes, "tmap:ddispose:methodname"); dispose_methodmodifiers = Getattr(attributes, "tmap:ddispose:methodmodifiers"); } if (tm && *Char(tm)) { if (!dispose_methodname) { Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in the ddispose%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); } if (!dispose_methodmodifiers) { Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in ddispose%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); } } if (tm) { // Write the destructor if the C++ one is accessible. if (*Char(destructor_call)) { Printv(body, lookupCodeTypemap(n, "ddestructor", typemap_lookup_type, WARN_NONE), NIL); } // Write the dispose() method. String *dispose_code = NewString(""); Printv(dispose_code, tm, NIL); if (*Char(destructor_call)) { Replaceall(dispose_code, "$imcall", destructor_call); } else { Replaceall(dispose_code, "$imcall", "throw new object.Exception(\"C++ destructor does not have public access\")"); } if (*Char(dispose_code)) { Printv(body, "\n", dispose_methodmodifiers, (derived ? " override" : ""), " void ", dispose_methodname, "() ", dispose_code, "\n", NIL); } } if (Swig_directorclass(n)) { // If directors are enabled for the current class, generate the // director connect helper function which is called from the constructor // and write it to the class body. writeDirectorConnectProxy(n); } // Write all constants and enumerations first to prevent forward reference // errors. Printv(body, proxy_class_enums_code, NIL); // Write the code generated in other methods to the class body. Printv(body, proxy_class_body_code, NIL); // Append extra user D code to the class body. Printv(body, lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), "\n", NIL); // Write the class body and the curly bracket closing the class definition // to the proxy module. indentCode(body); Replaceall(body, "$dbaseclass", basename); Delete(basename); Printv(proxy_class_code, body, "\n}\n", NIL); Delete(body); // Write the epilogue code if there is any. Printv(proxy_class_code, proxy_class_epilogue_code, NIL); } /* --------------------------------------------------------------------------- * D::writeClassUpcast() * --------------------------------------------------------------------------- */ void writeClassUpcast(Node *n, const String* d_class_name, String* c_class_name, String* c_base_name) { String *smartptr = Getattr(n, "feature:smartptr"); String *upcast_name = Swig_name_member(getNSpace(), d_class_name, (smartptr != 0 ? "SmartPtrUpcast" : "Upcast")); String *upcast_wrapper_name = Swig_name_wrapper(upcast_name); writeImDModuleFunction(upcast_name, "void*", "(void* objectRef)", upcast_wrapper_name); if (smartptr) { SwigType *spt = Swig_cparse_type(smartptr); if (spt) { SwigType *smart = SwigType_typedef_resolve_all(spt); Delete(spt); SwigType *bsmart = Copy(smart); SwigType *rclassname = SwigType_typedef_resolve_all(c_class_name); SwigType *rbaseclass = SwigType_typedef_resolve_all(c_base_name); Replaceall(bsmart, rclassname, rbaseclass); Delete(rclassname); Delete(rbaseclass); String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(bsmart); Printv(upcasts_code, "SWIGEXPORT ", bsmartnamestr, " * ", upcast_wrapper_name, "(", smartnamestr, " *objectRef) {\n", " return objectRef ? new ", bsmartnamestr, "(*objectRef) : 0;\n" "}\n", "\n", NIL); Delete(bsmartnamestr); Delete(smartnamestr); Delete(bsmart); } else { Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, c_class_name); } } else { Printv(upcasts_code, "SWIGEXPORT ", c_base_name, " * ", upcast_wrapper_name, "(", c_base_name, " *objectRef) {\n", " return (", c_base_name, " *)objectRef;\n" "}\n", "\n", NIL); } Replaceall(upcasts_code, "$cclass", c_class_name); Replaceall(upcasts_code, "$cbaseclass", c_base_name); Delete(upcast_name); Delete(upcast_wrapper_name); } /* --------------------------------------------------------------------------- * D::writeTypeWrapperClass() * --------------------------------------------------------------------------- */ void writeTypeWrapperClass(String *classname, SwigType *type) { Node *n = NewHash(); Setfile(n, input_file); Setline(n, line_number); assertClassNameValidity(classname); String* imports_target; String* code_target; File *class_file = NULL; if (split_proxy_dmodule) { String *filename = NewStringf("%s%s.d", dmodule_directory, classname); class_file = NewFile(filename, "w", SWIG_output_files()); if (!class_file) { FileErrorDisplay(filename); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filename)); Delete(filename); emitBanner(class_file); Printf(class_file, "module %s%s;\n", package, classname); Printf(class_file, "\nstatic import %s;\n", im_dmodule_fq_name); imports_target = NewString(""); code_target = NewString(""); } else { imports_target = proxyImportsBuffer(0); code_target = proxyCodeBuffer(0); } // Import statements. const String *imports = lookupCodeTypemap(n, "dimports", type, WARN_NONE); if (Len(imports) > 0) { String *imports_trimmed = Copy(imports); Chop(imports_trimmed); replaceImportTypeMacros(imports_trimmed); Printv(imports_target, imports_trimmed, "\n", NIL); Delete(imports_trimmed); } // Pure D baseclass and interfaces (no C++ inheritance possible. const String *pure_baseclass = lookupCodeTypemap(n, "dbase", type, WARN_NONE); const String *pure_interfaces = lookupCodeTypemap(n, "dinterfaces", type, WARN_NONE); // Emit the class. Printv(code_target, "\n", lookupCodeTypemap(n, "dclassmodifiers", type, WARN_D_TYPEMAP_CLASSMOD_UNDEF), " $dclassname", (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? ", " : "", pure_interfaces, " {", NIL); String* body = NewString(""); Printv(body, lookupCodeTypemap(n, "dbody", type, WARN_D_TYPEMAP_DBODY_UNDEF), lookupCodeTypemap(n, "dcode", type, WARN_NONE), NIL); indentCode(body); Printv(code_target, body, "\n}\n", NIL); Delete(body); Replaceall(code_target, "$dclassname", classname); if (split_proxy_dmodule) { Printv(class_file, imports_target, NIL); Delete(imports_target); replaceModuleVariables(code_target); Printv(class_file, code_target, NIL); Delete(code_target); Delete(class_file); } Delete(n); } /* --------------------------------------------------------------------------- * D::writeDirectorConnectProxy(Node *classNode) * * Writes the helper method which registers the director callbacks by calling * the director connect function from the D side to the proxy class. * --------------------------------------------------------------------------- */ void writeDirectorConnectProxy(Node* classNode) { String *dirClassName = directorClassName(classNode); String *connect_name = Swig_name_member(getNSpace(), proxy_class_name, "director_connect"); Printf(proxy_class_body_code, "\nprivate void swigDirectorConnect() {\n"); int i; for (i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *method = Getattr(udata, "method"); String *overloaded_name = Getattr(udata, "overname"); String *return_type = Getattr(udata, "return_type"); String *param_list = Getattr(udata, "param_list"); String *methid = Getattr(udata, "class_methodidx"); Printf(proxy_class_body_code, " %s.%s_Callback%s callback%s;\n", im_dmodule_fq_name, dirClassName, methid, methid); Printf(proxy_class_body_code, " if (swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) {\n", return_type, param_list, return_type, param_list, method); Printf(proxy_class_body_code, " callback%s = &swigDirectorCallback_%s_%s;\n", methid, proxy_class_name, overloaded_name); Printf(proxy_class_body_code, " }\n\n"); } Printf(proxy_class_body_code, " %s.%s(cast(void*)swigCPtr, cast(void*)this", im_dmodule_fq_name, connect_name); for (i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *methid = Getattr(udata, "class_methodidx"); Printf(proxy_class_body_code, ", callback%s", methid); } Printf(proxy_class_body_code, ");\n"); Printf(proxy_class_body_code, "}\n"); // Helper function to determine if a method has been overridden in a // subclass of the wrapped class. If not, we just pass null to the // director_connect_function since the method from the C++ class should // be called as usual (see above). // Only emit it if the proxy class has at least one method. if (first_class_dmethod < curr_class_dmethod) { Printf(proxy_class_body_code, "\n"); Printf(proxy_class_body_code, "private bool swigIsMethodOverridden(DelegateType, FunctionType, alias fn)() %s{\n", (d_version > 1) ? "const " : ""); Printf(proxy_class_body_code, " DelegateType dg = &fn;\n"); Printf(proxy_class_body_code, " return dg.funcptr != SwigNonVirtualAddressOf!(FunctionType, fn);\n"); Printf(proxy_class_body_code, "}\n"); Printf(proxy_class_body_code, "\n"); Printf(proxy_class_body_code, "private static Function SwigNonVirtualAddressOf(Function, alias fn)() {\n"); Printf(proxy_class_body_code, " return cast(Function) &fn;\n"); Printf(proxy_class_body_code, "}\n"); } if (Len(director_dcallbacks_code) > 0) { Printv(proxy_class_epilogue_code, director_dcallbacks_code, NIL); } Delete(director_callback_typedefs); director_callback_typedefs = NULL; Delete(director_callback_pointers); director_callback_pointers = NULL; Delete(director_dcallbacks_code); director_dcallbacks_code = NULL; Delete(dirClassName); Delete(connect_name); } /* --------------------------------------------------------------------------- * D::writeDirectorConnectWrapper() * * Writes the director connect function and the corresponding declaration to * the C++ wrapper respectively the D wrapper. * --------------------------------------------------------------------------- */ void writeDirectorConnectWrapper(Node *n) { if (!Swig_directorclass(n)) return; // Output the director connect method. String *norm_name = SwigType_namestr(Getattr(n, "name")); String *connect_name = Swig_name_member(getNSpace(), proxy_class_name, "director_connect"); String *dirClassName = directorClassName(n); Wrapper *code_wrap; Printv(wrapper_loader_bind_code, wrapper_loader_bind_command, NIL); Replaceall(wrapper_loader_bind_code, "$function", connect_name); Replaceall(wrapper_loader_bind_code, "$symbol", Swig_name_wrapper(connect_name)); Printf(im_dmodule_code, "extern(C) void function(void* cObject, void* dObject"); code_wrap = NewWrapper(); Printf(code_wrap->def, "SWIGEXPORT void D_%s(void *objarg, void *dobj", connect_name); Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name); Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); Printf(code_wrap->code, " if (director) {\n"); Printf(code_wrap->code, " director->swig_connect_director(dobj"); for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *methid = Getattr(udata, "class_methodidx"); Printf(code_wrap->def, ", %s::SWIG_Callback%s_t callback%s", dirClassName, methid, methid); Printf(code_wrap->code, ", callback%s", methid); Printf(im_dmodule_code, ", %s_Callback%s callback%s", dirClassName, methid, methid); } Printf(code_wrap->def, ") {\n"); Printf(code_wrap->code, ");\n"); Printf(im_dmodule_code, ") %s;\n", connect_name); Printf(code_wrap->code, " }\n"); Printf(code_wrap->code, "}\n"); Wrapper_print(code_wrap, f_wrappers); DelWrapper(code_wrap); Delete(connect_name); Delete(dirClassName); } /* --------------------------------------------------------------------------- * D::requireDType() * * If the given type is not already in scope in the current module, adds an * import statement for it. The name is considered relative to the global root * package if one is set. * * This is only used for dependencies created in generated code, user- * (i.e. typemap-) specified import statements are handled separately. * --------------------------------------------------------------------------- */ void requireDType(const String *nspace, const String *symname) { String *dmodule = createModuleName(nspace, symname); if (!inProxyModule(dmodule)) { String *import = createImportStatement(dmodule); Append(import, "\n"); if (is_wrapping_class()) { addImportStatement(proxy_class_imports, import); } else { addImportStatement(proxyImportsBuffer(getNSpace()), import); } Delete(import); } Delete(dmodule); } /* --------------------------------------------------------------------------- * D::addImportStatement() * * Adds the given import statement to the given list of import statements if * there is no statement importing that module present yet. * --------------------------------------------------------------------------- */ void addImportStatement(String *target, const String *import) const { char *position = Strstr(target, import); if (position) { // If the import statement has been found in the target string, we have to // check if the previous import was static, which would lead to problems // if this import is not. // Thus, we check if the seven characters in front of the occurrence are // »static «. If the import string passed is also static, the checks fail // even if the found statement is also static because the last seven // characters would be part of the previous import statement then. if (position - Char(target) < 7) { return; } if (strncmp(position - 7, "static ", 7)) { return; } } Printv(target, import, NIL); } /* --------------------------------------------------------------------------- * D::createImportStatement() * * Creates a string containing an import statement for the given module. * --------------------------------------------------------------------------- */ String *createImportStatement(const String *dmodule_name, bool static_import = true) const { if (static_import) { return NewStringf("static import %s%s;", package, dmodule_name); } else { return NewStringf("import %s%s;", package, dmodule_name); } } /* --------------------------------------------------------------------------- * D::inProxyModule() * * Determines if the specified proxy type is declared in the currently * processed proxy D module. * * This function is used to determine if fully qualified type names have to * be used (package, module and type name). If the split proxy mode is not * used, this solely depends on whether the type is in the current namespace. * --------------------------------------------------------------------------- */ bool inProxyModule(const String *type_name) const { if (!split_proxy_dmodule) { String *nspace = createOuterNamespaceNames(type_name); // Check if strings are either both null (no namespace) or are both // non-null and have the same contents. Cannot use Strcmp for this // directly because of its strange way of handling the case where only // one argument is 0 ("<"). bool result = !nspace && !getNSpace(); if (nspace && getNSpace()) result = (Strcmp(nspace, getNSpace()) == 0); Delete(nspace); return result; } if (!is_wrapping_class()) { return false; } return (Strcmp(proxy_class_qname, type_name) == 0); } /* --------------------------------------------------------------------------- * D::addUpcallMethod() * * Adds new director upcall signature. * --------------------------------------------------------------------------- */ UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *decl, String *overloaded_name, String *return_type, String *param_list) { String *key = NewStringf("%s|%s", imclass_method, decl); ++curr_class_dmethod; String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); n_dmethods++; Hash *new_udata = NewHash(); Append(dmethods_seq, new_udata); Setattr(dmethods_table, key, new_udata); Setattr(new_udata, "method", Copy(class_method)); Setattr(new_udata, "class_methodidx", class_methodidx); Setattr(new_udata, "decl", Copy(decl)); Setattr(new_udata, "overname", Copy(overloaded_name)); Setattr(new_udata, "return_type", Copy(return_type)); Setattr(new_udata, "param_list", Copy(param_list)); Delete(key); return new_udata; } /* --------------------------------------------------------------------------- * D::assertClassNameValidity() * --------------------------------------------------------------------------- */ void assertClassNameValidity(const String* class_name) const { // TODO: With nspace support, there could arise problems also when not in // split proxy mode, warnings for these should be added. if (split_proxy_dmodule) { if (Cmp(class_name, im_dmodule_name) == 0) { Swig_error(input_file, line_number, "Class name cannot be equal to intermediary D module name: %s\n", class_name); SWIG_exit(EXIT_FAILURE); } String *nspace = getNSpace(); if (nspace) { // Check the root package/outermost namespace (a class A in module // A.B leads to problems if another module A.C is also imported) if (Len(package) > 0) { String *dotless_package = NewStringWithSize(package, Len(package) - 1); if (Cmp(class_name, dotless_package) == 0) { Swig_error(input_file, line_number, "Class name cannot be the same as the root package it is in: %s\n", class_name); SWIG_exit(EXIT_FAILURE); } Delete(dotless_package); } else { String *outer = createFirstNamespaceName(nspace); if (Cmp(class_name, outer) == 0) { Swig_error(input_file, line_number, "Class name cannot be the same as the outermost namespace it is in: %s\n", class_name); SWIG_exit(EXIT_FAILURE); } Delete(outer); } // … and the innermost one (because of the conflict with the main proxy // module named like the namespace). String *inner = createLastNamespaceName(nspace); if (Cmp(class_name, inner) == 0) { Swig_error(input_file, line_number, "Class name cannot be the same as the innermost namespace it is in: %s\n", class_name); SWIG_exit(EXIT_FAILURE); } Delete(inner); } else { if (Cmp(class_name, proxy_dmodule_name) == 0) { Swig_error(input_file, line_number, "Class name cannot be equal to proxy D module name: %s\n", class_name); SWIG_exit(EXIT_FAILURE); } } } } /* --------------------------------------------------------------------------- * D::getPrimitiveDptype() * * Returns the D proxy type for the passed type if it is a primitive type in * both C and D. * --------------------------------------------------------------------------- */ String *getPrimitiveDptype(Node *node, SwigType *type) { SwigType *stripped_type = SwigType_typedef_resolve_all(type); // A reference can only be the »outermost element« of a type. bool mutable_ref = false; if (SwigType_isreference(stripped_type)) { SwigType_del_reference(stripped_type); if (SwigType_isconst(stripped_type)) { SwigType_del_qualifier(stripped_type); } else { mutable_ref = true; } } // Strip all the pointers from the type. int indirection_count = 0; while (SwigType_ispointer(stripped_type)) { ++indirection_count; SwigType_del_pointer(stripped_type); } // Now that we got rid of the pointers, see if we are dealing with a // primitive type. String *dtype = 0; if (SwigType_isfunction(stripped_type) && indirection_count > 0) { // type was a function pointer, split it up. SwigType_add_pointer(stripped_type); --indirection_count; SwigType *return_type = Copy(stripped_type); SwigType *params_type = SwigType_functionpointer_decompose(return_type); String *return_dtype = getPrimitiveDptype(node, return_type); Delete(return_type); if (!return_dtype) { return 0; } List *parms = SwigType_parmlist(params_type); List *param_dtypes = NewList(); for (Iterator it = First(parms); it.item; it = Next(it)) { String *current_dtype = getPrimitiveDptype(node, it.item); if (Cmp(current_dtype, "void") == 0) { // void somefunc(void) is legal syntax in C, but not in D, so simply // skip the void parameter. Delete(current_dtype); continue; } if (!current_dtype) { Delete(return_dtype); Delete(param_dtypes); return 0; } Append(param_dtypes, current_dtype); } String *param_list = NewString(""); { bool gen_comma = false; for (Iterator it = First(param_dtypes); it.item; it = Next(it)) { if (gen_comma) { Append(param_list, ", "); } Append(param_list, it.item); Delete(it.item); gen_comma = true; } } dtype = NewStringf("%s.SwigExternC!(%s function(%s))", im_dmodule_fq_name, return_dtype, param_list); Delete(param_list); Delete(param_dtypes); Delete(return_dtype); } else { Hash *attributes = NewHash(); const String *tm = lookupCodeTypemap(node, "dtype", stripped_type, WARN_NONE, attributes); if(!GetFlag(attributes, "tmap:dtype:cprimitive")) { dtype = 0; } else { dtype = Copy(tm); // We need to call replaceClassname here with the stripped type to avoid // $dclassname in the enum typemaps being replaced later with the full // type. replaceClassname(dtype, stripped_type); } Delete(attributes); } Delete(stripped_type); if (!dtype) { // The type passed is no primitive type. return 0; } // The type is ultimately a primitive type, now append the right number of // indirection levels (pointers). for (int i = 0; i < indirection_count; ++i) { Append(dtype, "*"); } // Add a level of indirection for a mutable reference since it is wrapped // as a pointer. if (mutable_ref) { Append(dtype, "*"); } return dtype; } /* --------------------------------------------------------------------------- * D::lookupCodeTypemap() * * Looks up a D code fragment for generating the wrapper class for the given * type. * * n - for input only and must contain info for Getfile(n) and Getline(n) to work * tmap_method - typemap method name * type - typemap type to lookup * warning - warning number to issue if no typemaps found * typemap_attributes - the typemap attributes are attached to this node and will * also be used for temporary storage if non null * return is never NULL, unlike Swig_typemap_lookup() * --------------------------------------------------------------------------- */ const String *lookupCodeTypemap(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) const { Node *node = !typemap_attributes ? NewHash() : typemap_attributes; Setattr(node, "type", type); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0); if (!tm) { tm = empty_string; if (warning != WARN_NONE) { Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0)); } } if (!typemap_attributes) { Delete(node); } return tm; } /* --------------------------------------------------------------------------- * D::lookupDTypemap() * * Looks up a D typemap for the given node, replacing D-specific special * variables as needed. * * The method parameter specifies the typemap method to use. If attached is * true, the value is just fetched from the tmap: node attribute, * Swig_typemap_lookup is used otherwise. * --------------------------------------------------------------------------- */ String *lookupDTypemap(Node *n, const_String_or_char_ptr method, bool attached = false) { String *result = 0; if (attached) { String *attr_name = NewStringf("tmap:%s", method); result = Copy(Getattr(n, attr_name)); Delete(attr_name); } else { // FIXME: As a workaround for a bug so far only surfacing in the // smart_pointer_const_overload test case, remove the nativepointer // typemap attribute since it seems to be already there from a dout // typemap of a different type in that test. String *np_key = NewStringf("tmap:%s:nativepointer", method); Delattr(n, np_key); Delete(np_key); result = Swig_typemap_lookup(method, n, "", 0); } if (!result) { return 0; } // Check if the passed node actually has type information attached. This // is not the case e.g. in constructorWrapper. SwigType *type = Getattr(n, "type"); if (type) { String *np_key = NewStringf("tmap:%s:nativepointer", method); String *np_value = Getattr(n, np_key); Delete(np_key); String *dtype; if (np_value && (dtype = getPrimitiveDptype(n, type))) { // If the typemap in question has a »nativepointer« attribute and we // are dealing with a primitive type, use it instead. result = Copy(np_value); Replaceall(result, "$dtype", dtype); } replaceClassname(result, type); } return result; } /* --------------------------------------------------------------------------- * D::replaceClassname() * * Replaces the special variable $dclassname with the proxy class name for * classes/structs/unions SWIG knows about. Also substitutes the enumeration * name for non-anonymous enums. Otherwise, $classname is replaced with a * $descriptor(type)-like name. * * $*dclassname and $&classname work like with descriptors (see manual section * 10.4.3), they remove a prointer from respectively add a pointer to the type. * * Inputs: * tm - String to perform the substitution at (will usually come from a * typemap. * pt - The type to substitute for the variables. * Outputs: * tm - String with the variables substituted. * Return: * substitution_performed - flag indicating if a substitution was performed * --------------------------------------------------------------------------- */ bool replaceClassname(String *tm, SwigType *pt) { bool substitution_performed = false; SwigType *type = Copy(SwigType_typedef_resolve_all(pt)); SwigType *strippedtype = SwigType_strip_qualifiers(type); if (Strstr(tm, "$dclassname")) { SwigType *classnametype = Copy(strippedtype); replaceClassnameVariable(tm, "$dclassname", classnametype); substitution_performed = true; Delete(classnametype); } if (Strstr(tm, "$*dclassname")) { SwigType *classnametype = Copy(strippedtype); Delete(SwigType_pop(classnametype)); replaceClassnameVariable(tm, "$*dclassname", classnametype); substitution_performed = true; Delete(classnametype); } if (Strstr(tm, "$&dclassname")) { SwigType *classnametype = Copy(strippedtype); SwigType_add_pointer(classnametype); replaceClassnameVariable(tm, "$&dclassname", classnametype); substitution_performed = true; Delete(classnametype); } Delete(strippedtype); Delete(type); return substitution_performed; } /* --------------------------------------------------------------------------- * D::replaceClassnameVariable() * * See D::replaceClassname(). * --------------------------------------------------------------------------- */ void replaceClassnameVariable(String *target, const char *variable, SwigType *type) { // TODO: Fix const-correctness of methods called in here and make type const. // We make use of the fact that this function is called at least once for // every type encountered which is written to a separate file, which allows // us to handle imports here. // When working in split proxy module mode, each generated proxy class/enum // is written to a separate module. This requires us to add a corresponding // import when a type is used in another generated module. If we are not // working in split proxy module mode, this is not relevant and the // generated module name is discarded. String *type_name; if (SwigType_isenum(type)) { // RESEARCH: Make sure that we really cannot get here for anonymous enums. Node *n = enumLookup(type); if (n) { String *enum_name = Getattr(n, "sym:name"); Node *p = parentNode(n); if (p && !Strcmp(nodeType(p), "class")) { // This is a nested enum. String *parent_name = Getattr(p, "sym:name"); String *nspace = Getattr(p, "sym:nspace"); // An enum nested in a class is not written to a separate module (this // would not even be possible in D), so just import the parent. requireDType(nspace, parent_name); String *module = createModuleName(nspace, parent_name); if (inProxyModule(module)) { type_name = NewStringf("%s.%s", parent_name, enum_name); } else { type_name = NewStringf("%s%s.%s.%s", package, module, parent_name, enum_name); } } else { // A non-nested enum is written to a separate module, import it. String *nspace = Getattr(n, "sym:nspace"); requireDType(nspace, enum_name); String *module = createModuleName(nspace, enum_name); if (inProxyModule(module)) { type_name = Copy(enum_name); } else { type_name = NewStringf("%s%s.%s", package, module, enum_name); } } } else { type_name = NewStringf("int"); } } else { Node *n = classLookup(type); if (n) { String *class_name = Getattr(n, "sym:name"); String *nspace = Getattr(n, "sym:nspace"); requireDType(nspace, class_name); String *module = createModuleName(nspace, class_name); if (inProxyModule(module)) { type_name = Copy(class_name); } else { type_name = NewStringf("%s%s.%s", package, module, class_name); } Delete(module); } else { // SWIG does not know anything about the type (after resolving typedefs). // Just mangle the type name string like $descriptor(type) would do. String *descriptor = NewStringf("SWIGTYPE%s", SwigType_manglestr(type)); requireDType(NULL, descriptor); String *module = createModuleName(NULL, descriptor); if (inProxyModule(module)) { type_name = Copy(descriptor); } else { type_name = NewStringf("%s%s.%s", package, module, descriptor); } Delete(module); // Add to hash table so that a type wrapper class can be created later. Setattr(unknown_types, descriptor, type); Delete(descriptor); } } Replaceall(target, variable, type_name); Delete(type_name); } /* --------------------------------------------------------------------------- * D::createModuleName() * * Returns a string holding the name of the module to import to bring the * given type in scope. * --------------------------------------------------------------------------- */ String *createModuleName(const String *nspace, const String *type_name) const { String *module; if (nspace) { module = NewStringf("%s.", nspace); if (split_proxy_dmodule) { Printv(module, type_name, NIL); } else { String *inner = createLastNamespaceName(nspace); Printv(module, inner, NIL); Delete(inner); } } else { if (split_proxy_dmodule) { module = Copy(type_name); } else { module = Copy(proxy_dmodule_name); } } return module; } /* --------------------------------------------------------------------------- * D::replaceModuleVariables() * * Replaces the $imdmodule and $module variables with their values in the * target string. * --------------------------------------------------------------------------- */ void replaceModuleVariables(String *target) const { Replaceall(target, "$imdmodule", im_dmodule_fq_name); Replaceall(target, "$module", proxy_dmodule_name); } /* --------------------------------------------------------------------------- * D::replaceExcode() * * If a C++ method can throw a exception, additional code is added to the * proxy method to check if an exception is pending so that it can be * rethrown on the D side. * * This method replaces the $excode variable with the exception handling code * in the excode typemap attribute if it »canthrow« an exception. * --------------------------------------------------------------------------- */ void replaceExcode(Node *n, String *code, const String *typemap, Node *parameter) const { String *excode_attribute = NewStringf("tmap:%s:excode", typemap); String *excode = Getattr(parameter, excode_attribute); if (Getattr(n, "d:canthrow")) { int count = Replaceall(code, "$excode", excode); if (count < 1 || !excode) { Swig_warning(WARN_D_EXCODE_MISSING, input_file, line_number, "D exception may not be thrown – no $excode or excode attribute in '%s' typemap.\n", typemap); } } else { Replaceall(code, "$excode", ""); } Delete(excode_attribute); } /* --------------------------------------------------------------------------- * D::replaceImportTypeMacros() * * Replaces the $importtype(SomeDClass) macro with an import statement if it * is required to get SomeDClass in scope for the currently generated proxy * D module. * --------------------------------------------------------------------------- */ void replaceImportTypeMacros(String *target) const { // Code from replace_embedded_typemap. char *start = 0; while ((start = Strstr(target, "$importtype("))) { char *end = 0; char *param_start = 0; char *param_end = 0; int level = 0; char *c = start; while (*c) { if (*c == '(') { if (level == 0) { param_start = c + 1; } level++; } if (*c == ')') { level--; if (level == 0) { param_end = c; end = c + 1; break; } } c++; } if (end) { String *current_macro = NewStringWithSize(start, (int)(end - start)); String *current_param = NewStringWithSize(param_start, (int)(param_end - param_start)); if (inProxyModule(current_param)) { Replace(target, current_macro, "", DOH_REPLACE_ANY); } else { String *import = createImportStatement(current_param, false); Replace(target, current_macro, import, DOH_REPLACE_ANY); Delete(import); } Delete(current_param); Delete(current_macro); } else { String *current_macro = NewStringWithSize(start, (int)(c - start)); Swig_error(Getfile(target), Getline(target), "Syntax error in: %s\n", current_macro); Replace(target, current_macro, "", DOH_REPLACE_ANY); Delete(current_macro); } } } /* --------------------------------------------------------------------------- * D::getOverloadedName() * --------------------------------------------------------------------------- */ String *getOverloadedName(Node *n) const { // A void* parameter is used for all wrapped classes in the wrapper code. // Thus, the wrapper function names for overloaded functions are postfixed // with a counter string to make them unique. String *overloaded_name = Copy(Getattr(n, "sym:name")); if (Getattr(n, "sym:overloaded")) { Append(overloaded_name, Getattr(n, "sym:overname")); } return overloaded_name; } /* --------------------------------------------------------------------------- * D::createProxyName() * * Returns the D class name if a type corresponds to something wrapped with a * proxy class, NULL otherwise. * --------------------------------------------------------------------------- */ String *createProxyName(SwigType *t) { String *proxyname = NULL; Node *n = classLookup(t); if (n) { String *nspace = Getattr(n, "sym:nspace"); String *symname = Getattr(n, "sym:name"); String *module = createModuleName(nspace, symname); if (inProxyModule(module)) { proxyname = Copy(symname); } else { proxyname = NewStringf("%s%s.%s", package, module, symname); } } return proxyname; } /* --------------------------------------------------------------------------- * D::makeParameterName() * * Inputs: * n - Node * p - parameter node * arg_num - parameter argument number * setter - set this flag when wrapping variables * Return: * arg - a unique parameter name * --------------------------------------------------------------------------- */ String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) const { String *arg = 0; String *pn = Getattr(p, "name"); // Use C parameter name unless it is a duplicate or an empty parameter name int count = 0; ParmList *plist = Getattr(n, "parms"); while (plist) { if ((Cmp(pn, Getattr(plist, "name")) == 0)) count++; plist = nextSibling(plist); } String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); if (setter && Cmp(arg, "self") != 0) { // In theory, we could use the normal parameter name for setter functions. // Unfortunately, it is set to "Class::VariableName" for static public // members by the parser, which is not legal D syntax. Thus, we just force // it to "value". Delete(arg); arg = NewString("value"); } if (split_proxy_dmodule && Strncmp(arg, package, Len(arg)) == 0) { // If we are in split proxy mode and the argument is named like the target // package, we append an underscore to its name to avoid clashes. Append(arg, "_"); } return arg; } /* --------------------------------------------------------------------------- * D::canThrow() * * Determines whether the code in the typemap can throw a D exception. * If so, note it for later when excodeSubstitute() is called. * --------------------------------------------------------------------------- */ void canThrow(Node *n, const String *typemap, Node *parameter) const { String *canthrow_attribute = NewStringf("tmap:%s:canthrow", typemap); String *canthrow = Getattr(parameter, canthrow_attribute); if (canthrow) Setattr(n, "d:canthrow", "1"); Delete(canthrow_attribute); } /* --------------------------------------------------------------------------- * D::wrapMemberFunctionAsDConst() * * Determines whether the member function represented by the passed node is * wrapped as D »const« or not. * --------------------------------------------------------------------------- */ bool wrapMemberFunctionAsDConst(Node *n) const { if (d_version == 1) return false; if (static_flag) return false; // Never emit »const« for static member functions. return GetFlag(n, "memberget") || SwigType_isconst(Getattr(n, "decl")); } /* --------------------------------------------------------------------------- * D::areAllOverloadsOverridden() * * Determines whether the class the passed function node belongs to overrides * all the overlaods for the passed function node defined somewhere up the * inheritance hierachy. * --------------------------------------------------------------------------- */ bool areAllOverloadsOverridden(Node *n) const { List *base_list = Getattr(parentNode(n), "bases"); if (!base_list) { // If the class which contains n is not derived from any other class, // there cannot be any not-overridden overloads. return true; } // In case of multiple base classes, skip to the one which has not been // ignored. // RESEARCH: Also emit a warning in case of multiple inheritance here? Iterator it = First(base_list); while (it.item && GetFlag(it.item, "feature:ignore")) { it = Next(it); } Node *base_class = it.item; if (!base_class) { // If all base classes have been ignored, there cannot be one either. return true; } // We try to find at least a single overload which exists in the base class // so we can progress up the inheritance hierachy even if there have been // new overloads introduced after the topmost class. Node *base_function = NULL; String *symname = Getattr(n, "sym:name"); if (symname) { for (Node *tmp = firstChild(base_class); tmp; tmp = nextSibling(tmp)) { String *child_symname = Getattr(tmp, "sym:name"); if (child_symname && (Strcmp(child_symname, symname) == 0)) { base_function = tmp; break; } } } if (!base_function) { // If there is no overload which also exists in the super class, there // cannot be any base class overloads not overridden. return true; } size_t base_overload_count = 0; for (Node *tmp = firstSibling(base_function); tmp; tmp = Getattr(tmp, "sym:nextSibling")) { if (is_protected(base_function) && !(Swig_director_mode() && Swig_director_protected_mode() && Swig_all_protected_mode())) { // If the base class function is »protected« and were are not in // director mode, it is not emitted to the base class and thus we do // not count it. Otherwise, we would run into issues if the visiblity // of some functions was changed from protected to public in a child // class with the using directive. continue; } ++base_overload_count; } return ((base_overload_count <= overridingOverloadCount(n)) && areAllOverloadsOverridden(base_function)); } /* --------------------------------------------------------------------------- * D::overridingOverloadCount() * * Given a member function node, this function counts how many of the * overloads of the function (including itself) override a function in the * base class. * --------------------------------------------------------------------------- */ size_t overridingOverloadCount(Node *n) const { size_t result = 0; Node *tmp = firstSibling(n); do { // KLUDGE: We also have to count the function if the access attribute is // not present, since this means that it has been promoted into another // protection level in the base class with the C++ »using« directive, and // is thus taken into account when counting the base class overloads, even // if it is not marked as »override« by the SWIG parser. if (Getattr(n, "override") || !Getattr(n, "access")) { ++result; } } while((tmp = Getattr(tmp, "sym:nextSibling"))); return result; } /* --------------------------------------------------------------------------- * D::firstSibling() * * Returns the first sibling of the passed node. * --------------------------------------------------------------------------- */ Node *firstSibling(Node *n) const { Node *result = n; while (Node *tmp = Getattr(result, "sym:previousSibling")) { result = tmp; } return result; } /* --------------------------------------------------------------------------- * D::indentCode() * * Helper function to indent a code (string) by one level. * --------------------------------------------------------------------------- */ void indentCode(String* code) const { Replaceall(code, "\n", "\n "); Replaceall(code, " \n", "\n"); Chop(code); } /* --------------------------------------------------------------------------- * D::emitBanner() * --------------------------------------------------------------------------- */ void emitBanner(File *f) const { Printf(f, "/* ----------------------------------------------------------------------------\n"); Swig_banner_target_lang(f, " *"); Printf(f, " * ----------------------------------------------------------------------------- */\n\n"); } /* --------------------------------------------------------------------------- * D::outputDirectory() * * Returns the directory to write the D modules for the given namespace to and * and creates the subdirectory if it doesn't exist. * --------------------------------------------------------------------------- */ String *outputDirectory(String *nspace) { String *output_directory = Copy(dmodule_directory); if (nspace) { String *nspace_subdirectory = Copy(nspace); Replaceall(nspace_subdirectory, ".", SWIG_FILE_DELIMITER); String *newdir_error = Swig_new_subdirectory(output_directory, nspace_subdirectory); if (newdir_error) { Printf(stderr, "%s\n", newdir_error); Delete(newdir_error); SWIG_exit(EXIT_FAILURE); } Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0); Delete(nspace_subdirectory); } return output_directory; } /* --------------------------------------------------------------------------- * D::proxyCodeBuffer() * * Returns the buffer to write proxy code for the given namespace to. * --------------------------------------------------------------------------- */ String *proxyCodeBuffer(String *nspace) { if (!nspace) { return proxy_dmodule_code; } Hash *hash = Getattr(nspace_proxy_dmodules, nspace); if (!hash) { hash = NewHash(); Setattr(hash, "code", NewString("")); Setattr(hash, "imports", NewString("")); Setattr(nspace_proxy_dmodules, nspace, hash); } return Getattr(hash, "code"); } /* --------------------------------------------------------------------------- * D::proxyCodeBuffer() * * Returns the buffer to write imports for the proxy code for the given * namespace to. * --------------------------------------------------------------------------- */ String *proxyImportsBuffer(String *nspace) { if (!nspace) { return proxy_dmodule_imports; } Hash *hash = Getattr(nspace_proxy_dmodules, nspace); if (!hash) { hash = NewHash(); Setattr(hash, "code", NewString("")); Setattr(hash, "imports", NewString("")); Setattr(nspace_proxy_dmodules, nspace, hash); } return Getattr(hash, "imports"); } /* --------------------------------------------------------------------------- * D::createFirstNamespaceName() * * Returns a new string containing the name of the outermost namespace, e.g. * »A« for the argument »A.B.C«. * --------------------------------------------------------------------------- */ String *createFirstNamespaceName(const String *nspace) const { char *tmp = Char(nspace); char *c = tmp; char *co = 0; if (!strstr(c, ".")) return 0; co = c + Len(nspace); while (*c && (c != co)) { if (*c == '.') { break; } c++; } if (!*c || (c == tmp)) { return NULL; } return NewStringWithSize(tmp, (int)(c - tmp)); } /* --------------------------------------------------------------------------- * D::createLastNamespaceName() * * Returns a new string containing the name of the innermost namespace, e.g. * »C« for the argument »A.B.C«. * --------------------------------------------------------------------------- */ String *createLastNamespaceName(const String *nspace) const { if (!nspace) return NULL; char *c = Char(nspace); char *cc = c; if (!strstr(c, ".")) return NewString(nspace); while (*c) { if (*c == '.') { cc = c; } ++c; } return NewString(cc + 1); } /* --------------------------------------------------------------------------- * D::createOuterNamespaceNames() * * Returns a new string containing the name of the outer namespace, e.g. * »A.B« for the argument »A.B.C«. * --------------------------------------------------------------------------- */ String *createOuterNamespaceNames(const String *nspace) const { if (!nspace) return NULL; char *tmp = Char(nspace); char *c = tmp; char *cc = c; if (!strstr(c, ".")) return NULL; while (*c) { if (*c == '.') { cc = c; } ++c; } if (cc == tmp) { return NULL; } return NewStringWithSize(tmp, (int)(cc - tmp)); } }; static Language *new_swig_d() { return new D(); } /* ----------------------------------------------------------------------------- * swig_d() - Instantiate module * ----------------------------------------------------------------------------- */ extern "C" Language *swig_d(void) { return new_swig_d(); } /* ----------------------------------------------------------------------------- * Usage information displayed at the command line. * ----------------------------------------------------------------------------- */ const char *D::usage = "\ D Options (available with -d)\n\ -d2 - Generate code for D2/Phobos (default: D1/Tango)\n\ -package - Write generated D modules into package \n\ -splitproxy - Write each D type to a dedicated file instead of\n\ generating a single proxy D module.\n\ -wrapperlibrary - Set the name of the wrapper library to \n\ \n"; swig-3.0.2/Source/Modules/browser.cxx0000664000175000017500000002626012343605122017430 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * browser.cxx * * A web-base parse tree browser using SWILL. This is an optional * feature that's normally disabled. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #ifdef SWIG_SWILL extern "C" { #include "swill.h" } static FILE *out = 0; static Node *view_top = 0; class Browser:public Dispatcher { void show_checkbox(Node *t, Node *n) { int v = 0; if (Getmeta(n, "visible")) { v = 1; } if (v) { Printf(out, "[-] ", n, t, n, n); } else { Printf(out, "[+] ", n, t, n, n); } } void show_attributes(Node *obj) { if (!Getmeta(obj, "visible")) return; String *os = NewString(""); String *k; Iterator ki; ki = First(obj); while (ki.key) { k = ki.key; if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) || (Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) { /* Do nothing */ } else if (Cmp(k, "parms") == 0) { String *o = NewString(""); Printf(o, "%s", ParmList_protostr(Getattr(obj, k))); Replaceall(o, "&", "&"); Replaceall(o, "<", "<"); Replaceall(o, ">", ">"); Printf(os, "? %-12s - %s\n", Getattr(obj, k), k, o); Delete(o); } else { DOH *o; char *trunc = ""; if (DohIsString(Getattr(obj, k))) { o = Str(Getattr(obj, k)); if (Len(o) > 70) { trunc = "..."; } Replaceall(o, "&", "&"); Replaceall(o, "<", "<"); Printf(os, "? %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc); Delete(o); } else { Printf(os, "? %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k)); } } ki = Next(ki); } Printf(out, "

\n%s
\n", Char(os)); Delete(os); } public: virtual int emit_one(Node *n) { char *tag = Char(nodeType(n)); char *file = Char(Getfile(n)); int line = Getline(n); char *name = GetChar(n, "name"); show_checkbox(view_top, n); Printf(out, "%s", n, tag); if (name) { Printf(out, " (%s)", name); } Printf(out, ". %s:%d\n", file, line); Printf(out, "
"); Dispatcher::emit_one(n); return SWIG_OK; } virtual int emit_children(Node *n) { if (Getmeta(n, "visible")) { Printf(out, "
\n"); Dispatcher::emit_children(n); Printf(out, "
\n"); } return SWIG_OK; } virtual int defaultHandler(Node *n) { show_attributes(n); return SWIG_OK; } virtual int top(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int includeDirective(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int importDirective(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int extendDirective(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int classDeclaration(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int templateDeclaration(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int lambdaDeclaration(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int enumDeclaration(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int typemapDirective(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int namespaceDeclaration(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } virtual int usingDeclaration(Node *n) { show_attributes(n); emit_children(n); return SWIG_OK; } }; static int browser_exit = 0; static Node *tree_top = 0; static Browser *browse = 0; /* ---------------------------------------------------------------------- * exit_handler() - Force the browser to exit * ---------------------------------------------------------------------- */ void exit_handler(FILE *f) { browser_exit = 1; Printf(f, "Terminated.\n"); } /* ---------------------------------------------------------------------- * node_handler() - Generate information about a specific node * ---------------------------------------------------------------------- */ static void display(FILE *f, Node *n) { /* Print standard HTML header */ Printf(f, "SWIG-%s\n", Swig_package_version()); Printf(f, "SWIG-%s
\n", Swig_package_version()); Printf(f, "[ Exit ]"); Printf(f, " [ Top ]", tree_top); if (n != tree_top) { Printf(f, " [ Up ]", parentNode(n)); } Printf(f, " [ Symbols ]"); Printf(f, "

\n"); out = f; browse->emit_one(n); /* Print standard footer */ Printf(f, "


\n"); } void node_handler(FILE *f) { Node *n = 0; if (!swill_getargs("p(node)", &n)) { n = tree_top; } view_top = n; display(f, n); } /* ---------------------------------------------------------------------- * hide_handler() - Hide a node * ---------------------------------------------------------------------- */ void hide_handler(FILE *f) { Node *n = 0; if (!swill_getargs("p(hn)", &n)) { n = 0; } if (n) { Delmeta(n, "visible"); } node_handler(f); } void show_handler(FILE *f) { Node *n = 0; if (!swill_getargs("p(hn)", &n)) { n = 0; } if (n) { Setmeta(n, "visible", "1"); } node_handler(f); } void raw_data(FILE *out, Node *obj) { if (!obj) return; if (DohIsMapping(obj)) { String *k; Iterator ki; String *os = NewString(""); Printf(os, "Hash {\n"); ki = First(obj); while (ki.key) { k = ki.key; DOH *o; const char *trunc = ""; if (DohIsString(Getattr(obj, k))) { o = Str(Getattr(obj, k)); if (Len(o) > 70) { trunc = "..."; } Replaceall(o, "<", "<"); Printf(os, " ? %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc); Delete(o); } else { Printf(os, " ? %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k)); } ki = Next(ki); } Printf(os, "}\n"); Printf(out, "
\n%s
\n", Char(os)); Delete(os); } else if (DohIsString(obj)) { String *o = Str(obj); Replaceall(o, "<", "<"); Printf(out, "
\n%s
\n", Char(o)); Delete(o); } else if (DohIsSequence(obj)) { int i; String *os = NewString(""); Printf(os, "List [\n"); for (i = 0; i < Len(obj); i++) { DOH *o = Getitem(obj, i); const char *trunc = ""; if (DohIsString(o)) { String *s = Str(o); if (Len(s) > 70) { trunc = "..."; } Replaceall(o, "<", "<"); Printf(os, " ? [%d] - \"%(escape)-0.70s%s\"\n", o, i, s, trunc); Delete(s); } else { Printf(os, " ? [%d] - %p\n", o, i, o); } } Printf(os, "\n]\n"); Printf(out, "
\n%s
\n", Char(os)); Delete(os); } } void data_handler(FILE *f) { DOH *n = 0; if (!swill_getargs("p(n)", &n)) { n = 0; } Printf(f, "SWIG-%s\n", Swig_package_version()); Printf(f, "SWIG-%s
\n", Swig_package_version()); Printf(f, "[ Exit ]"); Printf(f, " [ Top ]", tree_top); Printf(f, "

\n"); if (n) { raw_data(f, n); } /* Print standard footer */ Printf(f, "


\n"); } void symbol_handler(FILE *f) { Symtab *sym; char *name = 0; Printf(f, "SWIG-%s\n", Swig_package_version()); Printf(f, "SWIG-%s
\n", Swig_package_version()); Printf(f, "[ Exit ]"); Printf(f, " [ Top ]", tree_top); Printf(f, " [ Symbols ]"); Printf(f, "

\n"); if (!swill_getargs("p(sym)|s(name)", &sym, &name)) { sym = Swig_symbol_getscope(""); name = 0; } if (!sym) { Printf(f, "No symbol table specified!\n"); return; } { String *q = Swig_symbol_qualifiedscopename(sym); if (!Len(q)) { Printf(f, "Symbol table: :: (global)
\n"); } else { Printf(f, "Symbol table: %s
\n", q); } Delete(q); } fprintf(f, "

\n"); fprintf(f, "Symbol lookup:
\n"); fprintf(f, "\n", sym); fprintf(f, "Submit : \n"); fprintf(f, "
"); if (name) { Node *n = Swig_symbol_clookup(name, sym); Printf(f, "Symbol '%s':\n", name); Printf(f, "
\n"); if (!n) { Printf(f, "Not defined!\n"); } else { raw_data(f, n); } Printf(f, "
\n"); } Printf(f, "

Nested scopes
\n"); Printf(f, "

\n");
  {
    Hash *h;
    h = firstChild(sym);
    while (h) {
      Printf(f, "%s\n", h, Getattr(h, "name"));
      h = nextSibling(h);
    }
  }
  Printf(f, "
\n"); Printf(f, "

Symbol table contents
\n"); raw_data(f, Getattr(sym, "symtab")); Printf(f, "


\n"); } #endif void Swig_browser(Node *top, int port) { #ifdef SWIG_SWILL int sport; browser_exit = 0; /* Initialize the server */ sport = swill_init(port); if (sport < 0) { Printf(stderr, "Couldn't open socket on port %d. Sorry.\n", port); return; } browse = new Browser(); Setmeta(top, "visible", "1"); tree_top = top; Printf(stderr, "SWIG: Tree browser listening on port %d\n", sport); swill_handle("exit.html", exit_handler, 0); swill_handle("index.html", node_handler, 0); swill_handle("hide.html", hide_handler, 0); swill_handle("show.html", show_handler, 0); swill_handle("data.html", data_handler, 0); swill_handle("symbol.html", symbol_handler, 0); swill_netscape("index.html"); while (!browser_exit) { swill_serve(); } Printf(stderr, "Browser terminated.\n"); swill_close(); delete browse; return; #else (void) top; (void) port; #endif } swig-3.0.2/Source/Modules/ocaml.cxx0000664000175000017500000016726112343605122017047 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * ocaml.cxx * * Ocaml language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include static const char *usage = "\ Ocaml Options (available with -ocaml)\n\ -oldvarnames - Old intermediary method names for variable wrappers\n\ -prefix - Set a prefix to be prepended to all names\n\ -suffix - Change .cxx to something else\n\ -where - Emit library location\n\ \n"; static int classmode = 0; static int in_constructor = 0, in_destructor = 0, in_copyconst = 0; static int const_enum = 0; static int static_member_function = 0; static int generate_sizeof = 0; static String *prefix = 0; static const char *ocaml_path = "ocaml"; static bool old_variable_names = false; static String *classname = 0; static String *module = 0; static String *init_func_def = 0; static String *f_classtemplate = 0; static SwigType *name_qualifier_type = 0; static Hash *seen_enums = 0; static Hash *seen_enumvalues = 0; static Hash *seen_constructors = 0; static File *f_header = 0; static File *f_begin = 0; static File *f_runtime = 0; static File *f_wrappers = 0; static File *f_directors = 0; static File *f_directors_h = 0; static File *f_init = 0; static File *f_mlout = 0; static File *f_mliout = 0; static File *f_mlbody = 0; static File *f_mlibody = 0; static File *f_mltail = 0; static File *f_mlitail = 0; static File *f_enumtypes_type = 0; static File *f_enumtypes_value = 0; static File *f_class_ctors = 0; static File *f_class_ctors_end = 0; static File *f_enum_to_int = 0; static File *f_int_to_enum = 0; class OCAML:public Language { public: OCAML() { director_prot_ctor_code = NewString(""); Printv(director_prot_ctor_code, "if ( $comparison ) { /* subclassed */\n", " $director_new \n", "} else {\n", " failwith(\"accessing abstract class or protected constructor\"); \n", "}\n", NIL); director_multiple_inheritance = 1; director_language = 1; } String *Swig_class_name(Node *n) { String *name; name = Copy(Getattr(n, "sym:name")); return name; } void PrintIncludeArg() { Printv(stdout, SWIG_LIB, SWIG_FILE_DELIMITER, ocaml_path, "\n", NIL); } /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { int i; prefix = 0; SWIG_library_directory(ocaml_path); // Look for certain command line options for (i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); SWIG_exit(0); } else if (strcmp(argv[i], "-where") == 0) { PrintIncludeArg(); SWIG_exit(0); } else if (strcmp(argv[i], "-prefix") == 0) { if (argv[i + 1]) { prefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-suffix") == 0) { if (argv[i + 1]) { SWIG_config_cppext(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else Swig_arg_error(); } else if (strcmp(argv[i], "-oldvarnames") == 0) { Swig_mark_arg(i); old_variable_names = true; } } } // If a prefix has been specified make sure it ends in a '_' (not actually used!) if (prefix) { const char *px = Char(prefix); if (px[Len(prefix) - 1] != '_') Printf(prefix, "_"); } else prefix = NewString("swig_"); // Add a symbol for this module Preprocessor_define("SWIGOCAML 1", 0); // Set name of typemaps SWIG_typemap_lang("ocaml"); // Read in default typemaps */ SWIG_config_file("ocaml.i"); allow_overloading(); } /* Swig_director_declaration() * * Generate the full director class declaration, complete with base classes. * e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {" * */ String *Swig_director_declaration(Node *n) { String *classname = Swig_class_name(n); String *directorname = NewStringf("SwigDirector_%s", classname); String *base = Getattr(n, "classtype"); String *declaration = Swig_class_declaration(n, directorname); Printf(declaration, " : public %s, public Swig::Director {\n", base); Delete(classname); Delete(directorname); return declaration; } /* ------------------------------------------------------------ * top() * * Recognize the %module, and capture the module name. * Create the default enum cases. * Set up the named outputs: * * init * ml * mli * wrapper * header * runtime * directors * directors_h * ------------------------------------------------------------ */ virtual int top(Node *n) { /* Set comparison with none for ConstructorToFunction */ setSubclassInstanceCheck(NewString("caml_list_nth(args,0) != Val_unit")); /* check if directors are enabled for this module. note: this * is a "master" switch, without which no director code will be * emitted. %feature("director") statements are also required * to enable directors for individual classes or methods. * * use %module(directors="1") modulename at the start of the * interface file to enable director generation. */ { Node *module = Getattr(n, "module"); if (module) { Node *options = Getattr(module, "options"); if (options) { if (Getattr(options, "directors")) { allow_directors(); } if (Getattr(options, "dirprot")) { allow_dirprot(); } if (Getattr(options, "sizeof")) { generate_sizeof = 1; } } } } /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); f_directors = NewString(""); f_directors_h = NewString(""); f_enumtypes_type = NewString(""); f_enumtypes_value = NewString(""); init_func_def = NewString(""); f_mlbody = NewString(""); f_mlibody = NewString(""); f_mltail = NewString(""); f_mlitail = NewString(""); f_class_ctors = NewString(""); f_class_ctors_end = NewString(""); f_enum_to_int = NewString(""); f_int_to_enum = NewString(""); f_classtemplate = NewString(""); module = Getattr(n, "name"); seen_constructors = NewHash(); seen_enums = NewHash(); seen_enumvalues = NewHash(); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("init", init_func_def); Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("mli", f_mlibody); Swig_register_filebyname("ml", f_mlbody); Swig_register_filebyname("mlitail", f_mlitail); Swig_register_filebyname("mltail", f_mltail); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); Swig_register_filebyname("classtemplate", f_classtemplate); Swig_register_filebyname("class_ctors", f_class_ctors); if (old_variable_names) { Swig_name_register("set", "%n%v__set__"); Swig_name_register("get", "%n%v__get__"); } Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGOCAML\n"); Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module); /* Module name */ Printf(f_mlbody, "let module_name = \"%s\"\n", module); Printf(f_mlibody, "val module_name : string\n"); Printf(f_enum_to_int, "let enum_to_int x (v : c_obj) =\n" " match v with\n" " C_enum _y ->\n" " (let y = _y in match (x : c_enum_type) with\n" " `unknown -> " " (match y with\n" " `Int x -> (Swig.C_int x)\n" " | _ -> raise (LabelNotFromThisEnum v))\n"); Printf(f_int_to_enum, "let int_to_enum x y =\n" " match (x : c_enum_type) with\n" " `unknown -> C_enum (`Int y)\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } Printf(f_runtime, "\n"); /* Produce the enum_to_int and int_to_enum functions */ Printf(f_enumtypes_type, "open Swig\n" "type c_enum_type = [ \n `unknown\n"); Printf(f_enumtypes_value, "type c_enum_value = [ \n `Int of int\n"); String *mlfile = NewString(""); String *mlifile = NewString(""); Printv(mlfile, module, ".ml", NIL); Printv(mlifile, module, ".mli", NIL); String *mlfilen = NewStringf("%s%s", SWIG_output_directory(), mlfile); if ((f_mlout = NewFile(mlfilen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(mlfilen); SWIG_exit(EXIT_FAILURE); } String *mlifilen = NewStringf("%s%s", SWIG_output_directory(), mlifile); if ((f_mliout = NewFile(mlifilen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(mlifilen); SWIG_exit(EXIT_FAILURE); } Language::top(n); Printf(f_enum_to_int, ") | _ -> (C_int (get_int v))\n" "let _ = Callback.register \"%s_enum_to_int\" enum_to_int\n", module); Printf(f_mlibody, "val enum_to_int : c_enum_type -> c_obj -> Swig.c_obj\n"); Printf(f_int_to_enum, "let _ = Callback.register \"%s_int_to_enum\" int_to_enum\n", module); Printf(f_mlibody, "val int_to_enum : c_enum_type -> int -> c_obj\n"); Printf(f_init, "#define SWIG_init f_%s_init\n" "%s" "}\n", module, init_func_def); Printf(f_mlbody, "external f_init : unit -> unit = \"f_%s_init\" ;;\n" "let _ = f_init ()\n", module); Printf(f_enumtypes_type, "]\n"); Printf(f_enumtypes_value, "]\n\n" "type c_obj = c_enum_value c_obj_t\n"); if (directorsEnabled()) { // Insert director runtime into the f_runtime file (make it occur before %header section) Swig_insert_file("director.swg", f_runtime); } SwigType_emit_type_table(f_runtime, f_wrappers); /* Close all of the files */ Dump(f_runtime, f_begin); Dump(f_directors_h, f_header); Dump(f_header, f_begin); Dump(f_directors, f_wrappers); Dump(f_wrappers, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_runtime); Delete(f_begin); Dump(f_enumtypes_type, f_mlout); Dump(f_enumtypes_value, f_mlout); Dump(f_mlbody, f_mlout); Dump(f_enum_to_int, f_mlout); Dump(f_int_to_enum, f_mlout); Delete(f_int_to_enum); Delete(f_enum_to_int); Dump(f_class_ctors, f_mlout); Dump(f_class_ctors_end, f_mlout); Dump(f_mltail, f_mlout); Delete(f_mlout); Dump(f_enumtypes_type, f_mliout); Dump(f_enumtypes_value, f_mliout); Dump(f_mlibody, f_mliout); Dump(f_mlitail, f_mliout); Delete(f_mliout); return SWIG_OK; } /* Produce an error for the given type */ void throw_unhandled_ocaml_type_error(SwigType *d, const char *types) { Swig_warning(WARN_TYPEMAP_UNDEF, input_file, line_number, "Unable to handle type %s (%s).\n", SwigType_str(d, 0), types); } /* Return true iff T is a pointer type */ int is_a_pointer(SwigType *t) { return SwigType_ispointer(SwigType_typedef_resolve_all(t)); } /* * Delete one reference from a given type. */ void oc_SwigType_del_reference(SwigType *t) { char *c = Char(t); if (strncmp(c, "q(", 2) == 0) { Delete(SwigType_pop(t)); c = Char(t); } if (strncmp(c, "r.", 2)) { printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n"); abort(); } Replace(t, "r.", "", DOH_REPLACE_ANY | DOH_REPLACE_FIRST); } void oc_SwigType_del_array(SwigType *t) { char *c = Char(t); if (strncmp(c, "q(", 2) == 0) { Delete(SwigType_pop(t)); c = Char(t); } if (strncmp(c, "a(", 2) == 0) { Delete(SwigType_pop(t)); } } /* * Return true iff T is a reference type */ int is_a_reference(SwigType *t) { return SwigType_isreference(SwigType_typedef_resolve_all(t)); } int is_an_array(SwigType *t) { return SwigType_isarray(SwigType_typedef_resolve_all(t)); } /* ------------------------------------------------------------ * functionWrapper() * Create a function declaration and register it with the interpreter. * ------------------------------------------------------------ */ virtual int functionWrapper(Node *n) { char *iname = GetChar(n, "sym:name"); SwigType *d = Getattr(n, "type"); String *return_type_normalized = normalizeTemplatedClassName(d); ParmList *l = Getattr(n, "parms"); int director_method = 0; Parm *p; Wrapper *f = NewWrapper(); String *proc_name = NewString(""); String *source = NewString(""); String *target = NewString(""); String *arg = NewString(""); String *cleanup = NewString(""); String *outarg = NewString(""); String *build = NewString(""); String *tm; int i = 0; int numargs; int numreq; int newobj = GetFlag(n, "feature:new"); String *nodeType = Getattr(n, "nodeType"); int destructor = (!Cmp(nodeType, "destructor")); String *overname = 0; bool isOverloaded = Getattr(n, "sym:overloaded") ? true : false; // Make a wrapper name for this String *wname = Swig_name_wrapper(iname); if (isOverloaded) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) { DelWrapper(f); return SWIG_ERROR; } } if (overname) { Append(wname, overname); } /* Do this to disambiguate functions emitted from different modules */ Append(wname, module); Setattr(n, "wrap:name", wname); // Build the name for Scheme. Printv(proc_name, "_", iname, NIL); String *mangled_name = mangleNameForCaml(proc_name); if (classmode && in_constructor) { // Emit constructor for object String *mangled_name_nounder = NewString((char *) (Char(mangled_name)) + 1); Printf(f_class_ctors_end, "let %s clst = _%s clst\n", mangled_name_nounder, mangled_name_nounder); Printf(f_mlibody, "val %s : c_obj -> c_obj\n", mangled_name_nounder); Delete(mangled_name_nounder); } else if (classmode && in_destructor) { Printf(f_class_ctors, " \"~\", %s ;\n", mangled_name); } else if (classmode && !in_constructor && !in_destructor && !static_member_function) { String *opname = Copy(Getattr(n, "memberfunctionHandler:sym:name")); Replaceall(opname, "operator ", ""); if (strstr(Char(mangled_name), "__get__")) { String *set_name = Copy(mangled_name); if (!GetFlag(n, "feature:immutable")) { Replaceall(set_name, "__get__", "__set__"); Printf(f_class_ctors, " \"%s\", (fun args -> " "if args = (C_list [ raw_ptr ]) then %s args else %s args) ;\n", opname, mangled_name, set_name); Delete(set_name); } else { Printf(f_class_ctors, " \"%s\", (fun args -> " "if args = (C_list [ raw_ptr ]) then %s args else C_void) ;\n", opname, mangled_name); } } else if (strstr(Char(mangled_name), "__set__")) { ; /* Nothing ... handled by the case above */ } else { Printf(f_class_ctors, " \"%s\", %s ;\n", opname, mangled_name); } Delete(opname); } if (classmode && in_constructor) { Setattr(seen_constructors, mangled_name, "true"); } // writing the function wrapper function Printv(f->def, "SWIGEXT CAML_VALUE ", wname, " (", NIL); Printv(f->def, "CAML_VALUE args", NIL); Printv(f->def, ")\n{", NIL); /* Define the scheme name in C. This define is used by several macros. */ //Printv(f->def, "#define FUNC_NAME \"", mangled_name, "\"", NIL); // adds local variables Wrapper_add_local(f, "args", "CAMLparam1(args)"); Wrapper_add_local(f, "ret", "SWIG_CAMLlocal2(swig_result,rv)"); Wrapper_add_local(f, "_v", "int _v = 0"); if (isOverloaded) { Wrapper_add_local(f, "i", "int i"); Wrapper_add_local(f, "argc", "int argc = caml_list_length(args)"); Wrapper_add_local(f, "argv", "CAML_VALUE *argv"); Printv(f->code, "argv = (CAML_VALUE *)malloc( argc * sizeof( CAML_VALUE ) );\n" "for( i = 0; i < argc; i++ ) {\n" " argv[i] = caml_list_nth(args,i);\n" "}\n", NIL); } d = SwigType_typedef_qualified(d); emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); numargs = emit_num_arguments(l); numreq = emit_num_required(l); Printf(f->code, "swig_result = Val_unit;\n"); // Now write code to extract the parameters (this is super ugly) for (i = 0, p = l; i < numargs; i++) { /* Skip ignored arguments */ while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); pt = SwigType_typedef_qualified(pt); // Produce names of source and target Clear(source); Clear(target); Clear(arg); Printf(source, "caml_list_nth(args,%d)", i); Printf(target, "%s", ln); Printv(arg, Getattr(p, "name"), NIL); if (i >= numreq) { Printf(f->code, "if (caml_list_length(args) > %d) {\n", i); } // Handle parameter types. if ((tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$source", source); Replaceall(tm, "$target", target); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:in:next"); } else { // no typemap found // check if typedef and resolve throw_unhandled_ocaml_type_error(pt, "in"); p = nextSibling(p); } if (i >= numreq) { Printf(f->code, "}\n"); } } /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } // Pass output arguments back to the caller. for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { Replaceall(tm, "$source", Getattr(p, "emit:input")); /* Deprecated */ Replaceall(tm, "$target", Getattr(p, "lname")); /* Deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Replaceall(tm, "$ntype", normalizeTemplatedClassName(Getattr(p, "type"))); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } // Free up any memory allocated for the arguments. /* Insert cleanup code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* if the object is a director, and the method call originated from its * underlying python object, resolve the call by going up the c++ * inheritance chain. otherwise try to resolve the method in python. * without this check an infinite loop is set up between the director and * shadow class method calls. */ // NOTE: this code should only be inserted if this class is the // base class of a director class. however, in general we haven't // yet analyzed all classes derived from this one to see if they are // directors. furthermore, this class may be used as the base of // a director class defined in a completely different module at a // later time, so this test must be included whether or not directorbase // is true. we do skip this code if directors have not been enabled // at the command line to preserve source-level compatibility with // non-polymorphic swig. also, if this wrapper is for a smart-pointer // method, there is no need to perform the test since the calling object // (the smart-pointer) and the director object (the "pointee") are // distinct. director_method = is_member_director(n) && !is_smart_pointer() && !destructor; if (director_method) { Wrapper_add_local(f, "director", "Swig::Director *director = 0"); Printf(f->code, "director = dynamic_cast(arg1);\n"); Wrapper_add_local(f, "upcall", "bool upcall = false"); Append(f->code, "upcall = (director);\n"); } // Now write code to make the function call Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$source", "swig_result"); Replaceall(tm, "$target", "rv"); Replaceall(tm, "$result", "rv"); Replaceall(tm, "$ntype", return_type_normalized); Printv(f->code, tm, "\n", NIL); } else { throw_unhandled_ocaml_type_error(d, "out"); } emit_return_variable(n, d, f); // Dump the argument output code Printv(f->code, Char(outarg), NIL); // Dump the argument cleanup code Printv(f->code, Char(cleanup), NIL); // Look for any remaining cleanup if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", "swig_result"); Printv(f->code, tm, "\n", NIL); } } // Free any memory allocated by the function being wrapped.. if ((tm = Swig_typemap_lookup("swig_result", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } // Wrap things up (in a manner of speaking) Printv(f->code, tab4, "swig_result = caml_list_append(swig_result,rv);\n", NIL); if (isOverloaded) Printv(f->code, "free(argv);\n", NIL); Printv(f->code, tab4, "CAMLreturn(swig_result);\n", NIL); Printv(f->code, "}\n", NIL); /* Substitute the function name */ Replaceall(f->code, "$symname", iname); Wrapper_print(f, f_wrappers); if (isOverloaded) { if (!Getattr(n, "sym:nextSibling")) { int maxargs; Wrapper *df = NewWrapper(); String *dispatch = Swig_overload_dispatch(n, "free(argv);\n" "CAMLreturn(%s(args));\n", &maxargs); Wrapper_add_local(df, "_v", "int _v = 0"); Wrapper_add_local(df, "argv", "CAML_VALUE *argv"); /* Undifferentiate name .. this is the dispatch function */ wname = Swig_name_wrapper(iname); /* Do this to disambiguate functions emitted from different * modules */ Append(wname, module); Printv(df->def, "SWIGEXT CAML_VALUE ", wname, "(CAML_VALUE args) {\n" " CAMLparam1(args);\n" " int i;\n" " int argc = caml_list_length(args);\n", NIL); Printv(df->code, "argv = (CAML_VALUE *)malloc( argc * sizeof( CAML_VALUE ) );\n" "for( i = 0; i < argc; i++ ) {\n" " argv[i] = caml_list_nth(args,i);\n" "}\n", NIL); Printv(df->code, dispatch, "\n", NIL); Printf(df->code, "failwith(\"No matching function for overloaded '%s'\");\n", iname); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); DelWrapper(df); Delete(dispatch); } } Printf(f_mlbody, "external %s_f : c_obj list -> c_obj list = \"%s\" ;;\n" "let %s arg = match %s_f (fnhelper arg) with\n" " [] -> C_void\n" "| [x] -> (if %s then Gc.finalise \n" " (fun x -> ignore ((invoke x) \"~\" C_void)) x) ; x\n" "| lst -> C_list lst ;;\n", mangled_name, wname, mangled_name, mangled_name, newobj ? "true" : "false"); if (!classmode || in_constructor || in_destructor || static_member_function) Printf(f_mlibody, "val %s : c_obj -> c_obj\n", mangled_name); Delete(proc_name); Delete(source); Delete(target); Delete(arg); Delete(outarg); Delete(cleanup); Delete(build); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * variableWrapper() * * Create a link to a C variable. * This creates a single function _wrap_swig_var_varname(). * This function takes a single optional argument. If supplied, it means * we are setting this variable to some value. If omitted, it means we are * simply evaluating this variable. In the set case we return C_void. * * symname is the name of the variable with respect to C. This * may need to differ from the original name in the case of enums. * enumvname is the name of the variable with respect to ocaml. This * will vary if the variable has been renamed. * ------------------------------------------------------------ */ virtual int variableWrapper(Node *n) { char *name = GetChar(n, "feature:symname"); String *iname = Getattr(n, "feature:enumvname"); String *mname = mangleNameForCaml(iname); SwigType *t = Getattr(n, "type"); String *proc_name = NewString(""); String *tm; String *tm2 = NewString(""); String *argnum = NewString("0"); String *arg = NewString("SWIG_Field(args,0)"); Wrapper *f; if (!name) { name = GetChar(n, "name"); } if (!iname) { iname = Getattr(n, "sym:name"); mname = mangleNameForCaml(NewString(iname)); } if (!iname || !addSymbol(iname, n)) return SWIG_ERROR; f = NewWrapper(); // evaluation function names String *var_name = Swig_name_wrapper(iname); // Build the name for scheme. Printv(proc_name, iname, NIL); Setattr(n, "wrap:name", proc_name); Printf(f->def, "SWIGEXT CAML_VALUE %s(CAML_VALUE args) {\n", var_name); // Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL); Wrapper_add_local(f, "swig_result", "CAML_VALUE swig_result"); if (!GetFlag(n, "feature:immutable")) { /* Check for a setting of the variable value */ Printf(f->code, "if (args != Val_int(0)) {\n"); if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { Replaceall(tm, "$source", "args"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "args"); /* Printv(f->code, tm, "\n",NIL); */ emit_action_code(n, f->code, tm); } else if ((tm = Swig_typemap_lookup("in", n, name, 0))) { Replaceall(tm, "$source", "args"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "args"); Printv(f->code, tm, "\n", NIL); } else { throw_unhandled_ocaml_type_error(t, "varin/in"); } Printf(f->code, "}\n"); } // Now return the value of the variable (regardless // of evaluating or setting) if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$source", name); Replaceall(tm, "$target", "swig_result"); Replaceall(tm, "$result", "swig_result"); emit_action_code(n, f->code, tm); } else if ((tm = Swig_typemap_lookup("out", n, name, 0))) { Replaceall(tm, "$source", name); Replaceall(tm, "$target", "swig_result"); Replaceall(tm, "$result", "swig_result"); Printf(f->code, "%s\n", tm); } else { throw_unhandled_ocaml_type_error(t, "varout/out"); } Printf(f->code, "\nreturn swig_result;\n"); Printf(f->code, "}\n"); Wrapper_print(f, f_wrappers); // Now add symbol to the Ocaml interpreter if (GetFlag(n, "feature:immutable")) { Printf(f_mlbody, "external _%s : c_obj -> Swig.c_obj = \"%s\" \n", mname, var_name); Printf(f_mlibody, "val _%s : c_obj -> Swig.c_obj\n", iname); if (const_enum) { Printf(f_enum_to_int, " | `%s -> _%s C_void\n", mname, mname); Printf(f_int_to_enum, " if y = (get_int (_%s C_void)) then `%s else\n", mname, mname); } } else { Printf(f_mlbody, "external _%s : c_obj -> c_obj = \"%s\"\n", mname, var_name); Printf(f_mlibody, "external _%s : c_obj -> c_obj = \"%s\"\n", mname, var_name); } Delete(var_name); Delete(proc_name); Delete(argnum); Delete(arg); Delete(tm2); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * staticmemberfunctionHandler -- * Overridden to set static_member_function * ------------------------------------------------------------ */ virtual int staticmemberfunctionHandler(Node *n) { static_member_function = 1; Language::staticmemberfunctionHandler(n); static_member_function = 0; return SWIG_OK; } /* ------------------------------------------------------------ * constantWrapper() * * The one trick here is that we have to make sure we rename the * constant to something useful that doesn't collide with the * original if any exists. * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { String *name = Getattr(n, "feature:symname"); SwigType *type = Getattr(n, "type"); String *value = Getattr(n, "value"); SwigType *qname = Getattr(n, "qualified:name"); String *rvalue = NewString(""); String *temp = 0; if (qname) value = qname; if (!name) { name = mangleNameForCaml(Getattr(n, "name")); Insert(name, 0, "_swig_wrap_"); Setattr(n, "feature:symname", name); } // See if there's a typemap Printv(rvalue, value, NIL); if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 1)) { temp = Copy(rvalue); Clear(rvalue); Printv(rvalue, "\"", temp, "\"", NIL); Delete(temp); } if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 0)) { temp = Copy(rvalue); Clear(rvalue); Printv(rvalue, "'", temp, "'", NIL); Delete(temp); } // Create variable and assign it a value Printf(f_header, "static %s = ", SwigType_lstr(type, name)); bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); if ((SwigType_type(type) == T_STRING)) { Printf(f_header, "\"%s\";\n", value); } else if (SwigType_type(type) == T_CHAR && !is_enum_item) { Printf(f_header, "\'%s\';\n", value); } else { Printf(f_header, "%s;\n", value); } SetFlag(n, "feature:immutable"); variableWrapper(n); return SWIG_OK; } int constructorHandler(Node *n) { int ret; in_constructor = 1; ret = Language::constructorHandler(n); in_constructor = 0; return ret; } /* destructorHandler: * Turn on destructor flag to inform decisions in functionWrapper */ int destructorHandler(Node *n) { int ret; in_destructor = 1; ret = Language::destructorHandler(n); in_destructor = 0; return ret; } /* copyconstructorHandler: * Turn on constructor and copyconstructor flags for functionWrapper */ int copyconstructorHandler(Node *n) { int ret; in_copyconst = 1; in_constructor = 1; ret = Language::copyconstructorHandler(n); in_constructor = 0; in_copyconst = 0; return ret; } /** * A simple, somewhat general purpose function for writing to multiple * streams from a source template. This allows the user to define the * class definition in ways different from the one I have here if they * want to. It will also make the class definition system easier to * fiddle with when I want to change methods, etc. */ void Multiwrite(String *s) { char *find_marker = strstr(Char(s), "(*Stream:"); while (find_marker) { char *next = strstr(find_marker, "*)"); find_marker += strlen("(*Stream:"); if (next) { int num_chars = next - find_marker; String *stream_name = NewString(find_marker); Delslice(stream_name, num_chars, Len(stream_name)); File *fout = Swig_filebyname(stream_name); if (fout) { next += strlen("*)"); char *following = strstr(next, "(*Stream:"); find_marker = following; if (!following) following = next + strlen(next); String *chunk = NewString(next); Delslice(chunk, following - next, Len(chunk)); Printv(fout, chunk, NIL); } } } } bool isSimpleType(String *name) { char *ch = Char(name); return !(strchr(ch, '(') || strchr(ch, '<') || strchr(ch, ')') || strchr(ch, '>')); } /* We accept all chars in identifiers because we use strings to index * them. */ int validIdentifier(String *name) { return Len(name) > 0 ? 1 : 0; } /* classHandler * * Create a "class" definition for ocaml. I thought quite a bit about * how I should do this part of it, and arrived here, using a function * invocation to select a method, and dispatch. This can obviously be * done better, but I can't see how, given that I want to support * overloaded methods, out parameters, and operators. * * I needed a system that would do this: * * a Be able to call these methods: * int foo( int x ); * float foo( int x, int &out ); * * b Be typeable, even in the presence of mutually dependent classes. * * c Support some form of operator invocation. * * (c) I chose strings for the method names so that "+=" would be a * valid method name, and the somewhat natural << (invoke x) "+=" y >> * would work. * * (a) (b) Since the c_obj type exists, it's easy to return C_int in one * case and C_list [ C_float ; C_int ] in the other. This makes tricky * problems with out parameters disappear; they're simply appended to the * return list. * * (b) Since every item that comes from C++ is the same type, there is no * problem with the following: * * class Foo; * class Bar { Foo *toFoo(); } * class Foo { Bar *toBar(); } * * Since the Objective caml types of Foo and Bar are the same. Now that * I correctly incorporate SWIG's typechecking, this isn't a big deal. * * The class is in the form of a function returning a c_obj. The c_obj * is a C_obj containing a function which invokes a method on the * underlying object given its type. * * The name emitted here is normalized before being sent to * Callback.register, because we need this string to look up properly * when the typemap passes the descriptor string. I've been considering * some, possibly more forgiving method that would do some transformations * on the $descriptor in order to find a potential match. This is for * later. * * Important things to note: * * We rely on exception handling (BadMethodName) in order to call an * ancestor. This can be improved. * * The method used to get :classof could be improved to look at the type * info that the base pointer contains. It's really an error to have a * SWIG-generated object that does not contain type info, since the * existence of the object means that SWIG knows the type. * * :parents could use :classof to tell what class it is and make a better * decision. This could be nice, (i.e. provide a run-time graph of C++ * classes represented);. * * I can't think of a more elegant way of converting a C_obj fun to a * pointer than "operator &"... * * Added a 'sizeof' that will allow you to do the expected thing. * This should help users to fill buffer structs and the like (as is * typical in windows-styled code). It's only enabled if you give * %feature(sizeof) and then, only for simple types. * * Overall, carrying the list of methods and base classes has worked well. * It allows me to give the Ocaml user introspection over their objects. */ int classHandler(Node *n) { String *name = Getattr(n, "name"); if (!name) return SWIG_OK; String *mangled_sym_name = mangleNameForCaml(name); String *this_class_def = NewString(f_classtemplate); String *name_normalized = normalizeTemplatedClassName(name); String *old_class_ctors = f_class_ctors; String *base_classes = NewString(""); f_class_ctors = NewString(""); bool sizeof_feature = generate_sizeof && isSimpleType(name); classname = mangled_sym_name; classmode = true; int rv = Language::classHandler(n); classmode = false; if (sizeof_feature) { Printf(f_wrappers, "SWIGEXT CAML_VALUE _wrap_%s_sizeof( CAML_VALUE args ) {\n" " CAMLparam1(args);\n" " CAMLreturn(Val_int(sizeof(%s)));\n" "}\n", mangled_sym_name, name_normalized); Printf(f_mlbody, "external __%s_sizeof : unit -> int = " "\"_wrap_%s_sizeof\"\n", classname, mangled_sym_name); } /* Insert sizeof operator for concrete classes */ if (sizeof_feature) { Printv(f_class_ctors, "\"sizeof\" , (fun args -> C_int (__", classname, "_sizeof ())) ;\n", NIL); } /* Handle up-casts in a nice way */ List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist)) { Iterator b; b = First(baselist); while (b.item) { String *bname = Getattr(b.item, "name"); if (bname) { String *base_create = NewString(""); Printv(base_create, "(create_class \"", bname, "\")", NIL); Printv(f_class_ctors, " \"::", bname, "\", (fun args -> ", base_create, " args) ;\n", NIL); Printv(base_classes, base_create, " ;\n", NIL); } b = Next(b); } } Replaceall(this_class_def, "$classname", classname); Replaceall(this_class_def, "$normalized", name_normalized); Replaceall(this_class_def, "$realname", name); Replaceall(this_class_def, "$baselist", base_classes); Replaceall(this_class_def, "$classbody", f_class_ctors); Delete(f_class_ctors); f_class_ctors = old_class_ctors; // Actually write out the class definition Multiwrite(this_class_def); Setattr(n, "ocaml:ctor", classname); return rv; } String *normalizeTemplatedClassName(String *name) { String *name_normalized = SwigType_typedef_resolve_all(name); bool took_action; do { took_action = false; if (is_a_pointer(name_normalized)) { SwigType_del_pointer(name_normalized); took_action = true; } if (is_a_reference(name_normalized)) { oc_SwigType_del_reference(name_normalized); took_action = true; } if (is_an_array(name_normalized)) { oc_SwigType_del_array(name_normalized); took_action = true; } } while (took_action); return SwigType_str(name_normalized, 0); } /* * Produce the symbol name that ocaml will use when referring to the * target item. I wonder if there's a better way to do this: * * I shudder to think about doing it with a hash lookup, but that would * make a couple of things easier: */ String *mangleNameForCaml(String *s) { String *out = Copy(s); Replaceall(out, " ", "_xx"); Replaceall(out, "::", "_xx"); Replaceall(out, ",", "_x"); Replaceall(out, "+", "_xx_plus"); Replaceall(out, "-", "_xx_minus"); Replaceall(out, "<", "_xx_ldbrace"); Replaceall(out, ">", "_xx_rdbrace"); Replaceall(out, "!", "_xx_not"); Replaceall(out, "%", "_xx_mod"); Replaceall(out, "^", "_xx_xor"); Replaceall(out, "*", "_xx_star"); Replaceall(out, "&", "_xx_amp"); Replaceall(out, "|", "_xx_or"); Replaceall(out, "(", "_xx_lparen"); Replaceall(out, ")", "_xx_rparen"); Replaceall(out, "[", "_xx_lbrace"); Replaceall(out, "]", "_xx_rbrace"); Replaceall(out, "~", "_xx_bnot"); Replaceall(out, "=", "_xx_equals"); Replaceall(out, "/", "_xx_slash"); Replaceall(out, ".", "_xx_dot"); return out; } SwigType *fully_qualified_enum_type(Node *n) { Node *parent = 0; String *fully_qualified_name = NewString(""); String *parent_type = 0; parent = parentNode(n); while (parent) { parent_type = nodeType(parent); if (Getattr(parent, "name")) { String *parent_copy = NewStringf("%s::", Getattr(parent, "name")); if (Cmp(parent_type, "class") == 0 || Cmp(parent_type, "namespace") == 0) Insert(fully_qualified_name, 0, parent_copy); Delete(parent_copy); } if (!Cmp(parent_type, "class")) break; parent = parentNode(parent); } return fully_qualified_name; } /* Benedikt Grundmann inspired --> Enum wrap styles */ int enumvalueDeclaration(Node *n) { String *name = Getattr(n, "name"); SwigType *qtype = 0; if (name_qualifier_type) { qtype = Copy(name_qualifier_type); Printv(qtype, name, NIL); } if (const_enum && qtype && name && !Getattr(seen_enumvalues, name)) { Setattr(seen_enumvalues, name, "true"); SetFlag(n, "feature:immutable"); Setattr(n, "feature:enumvalue", "1"); // this does not appear to be used Setattr(n, "qualified:name", SwigType_namestr(qtype)); String *evname = SwigType_manglestr(qtype); Insert(evname, 0, "SWIG_ENUM_"); Setattr(n, "feature:enumvname", name); Setattr(n, "feature:symname", evname); Delete(evname); Printf(f_enumtypes_value, "| `%s\n", name); return Language::enumvalueDeclaration(n); } else return SWIG_OK; } /* ------------------------------------------------------------------- * This function is a bit uglier than it deserves. * * I used to direct lookup the name of the enum. Now that certain fixes * have been made in other places, the names of enums are now fully * qualified, which is a good thing, overall, but requires me to do * some legwork. * * The other thing that uglifies this function is the varying way that * typedef enum and enum are handled. I need to produce consistent names, * which means looking up and registering by typedef and enum name. */ int enumDeclaration(Node *n) { String *name = Getattr(n, "name"); if (name) { String *oname = NewString(name); /* name is now fully qualified */ String *fully_qualified_name = NewString(name); bool seen_enum = false; if (name_qualifier_type) Delete(name_qualifier_type); char *strip_position; name_qualifier_type = fully_qualified_enum_type(n); strip_position = strstr(Char(oname), "::"); while (strip_position) { strip_position += 2; oname = NewString(strip_position); strip_position = strstr(Char(oname), "::"); } seen_enum = (Getattr(seen_enums, fully_qualified_name) ? true : false); if (!seen_enum) { const_enum = true; Printf(f_enum_to_int, "| `%s -> (match y with\n", oname); Printf(f_int_to_enum, "| `%s -> C_enum (\n", oname); /* * * * A note about enum name resolution * * * * * This code should now work, but I think we can do a bit better. * The problem I'm having is that swig isn't very precise about * typedef name resolution. My opinion is that SwigType_typedef * resolve_all should *always* return the enum tag if one exists, * rather than the admittedly friendlier enclosing typedef. * * This would make one of the cases below unnecessary. * * * */ Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", fully_qualified_name, oname); if (!strncmp(Char(fully_qualified_name), "enum ", 5)) { String *fq_noenum = NewString(Char(fully_qualified_name) + 5); Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n" "let _ = Callback.register \"%s_marker\" (`%s)\n", fq_noenum, oname, fq_noenum, name); } Printf(f_enumtypes_type, "| `%s\n", oname); Insert(fully_qualified_name, 0, "enum "); Setattr(seen_enums, fully_qualified_name, n); } } int ret = Language::enumDeclaration(n); if (const_enum) { Printf(f_int_to_enum, "`Int y)\n"); Printf(f_enum_to_int, "| `Int x -> Swig.C_int x\n" "| _ -> raise (LabelNotFromThisEnum v))\n"); } const_enum = false; return ret; } /* ---------------------------------------------------------------------------- * BEGIN C++ Director Class modifications * ------------------------------------------------------------------------- */ /* * Modified polymorphism code for Ocaml language module. * Original: * C++/Python polymorphism demo code, copyright (C) 2002 Mark Rose * * * TODO * * Move some boilerplate code generation to Swig_...() functions. * */ /* --------------------------------------------------------------- * classDirectorMethod() * * Emit a virtual director method to pass a method call on to the * underlying Python object. * * --------------------------------------------------------------- */ int classDirectorMethod(Node *n, Node *parent, String *super) { int is_void = 0; int is_pointer = 0; String *storage = Getattr(n, "storage"); String *value = Getattr(n, "value"); String *decl = Getattr(n, "decl"); String *returntype = Getattr(n, "type"); String *name = Getattr(n, "name"); String *classname = Getattr(parent, "sym:name"); String *c_classname = Getattr(parent, "name"); String *symname = Getattr(n, "sym:name"); String *declaration = NewString(""); ParmList *l = Getattr(n, "parms"); Wrapper *w = NewWrapper(); String *tm; String *wrap_args = NewString(""); int status = SWIG_OK; int idx; bool pure_virtual = false; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; if (Cmp(storage, "virtual") == 0) { if (Cmp(value, "0") == 0) { pure_virtual = true; } } Wrapper_add_local(w, "swig_result", "CAMLparam0();\n" "SWIG_CAMLlocal2(swig_result,args)"); /* determine if the method returns a pointer */ is_pointer = SwigType_ispointer_return(decl); is_void = (!Cmp(returntype, "void") && !is_pointer); /* virtual method definition */ String *target; String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); Printf(w->def, "%s {", target); Delete(qualified_name); Delete(target); /* header declaration */ target = Swig_method_decl(rtype, decl, name, l, 0, 1); Printf(declaration, " virtual %s;", target); Delete(target); /* declare method return value * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ if (!is_void) { if (!(ignored_method && !pure_virtual)) { Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL); } } if (ignored_method) { if (!pure_virtual) { if (!is_void) Printf(w->code, "return "); String *super_call = Swig_method_call(super, l); Printf(w->code, "%s;\n", super_call); Delete(super_call); } else { Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } } else { /* attach typemaps to arguments (C/C++ -> Ocaml) */ String *arglist = NewString(""); Swig_director_parms_fixup(l); Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); Parm *p; int num_arguments = emit_num_arguments(l); int i; char source[256]; int outputs = 0; if (!is_void) outputs++; /* build argument list and type conversion string */ for (i = 0, idx = 0, p = l; i < num_arguments; i++) { while (Getattr(p, "tmap:ignore")) { p = Getattr(p, "tmap:ignore:next"); } if (Getattr(p, "tmap:directorargout") != 0) outputs++; String *pname = Getattr(p, "name"); String *ptype = Getattr(p, "type"); Putc(',', arglist); if ((tm = Getattr(p, "tmap:directorin")) != 0) { Setattr(p, "emit:directorinput", pname); Replaceall(tm, "$input", pname); Replaceall(tm, "$owner", "0"); if (Len(tm) == 0) Append(tm, pname); Printv(wrap_args, tm, "\n", NIL); p = Getattr(p, "tmap:directorin:next"); continue; } else if (Cmp(ptype, "void")) { /* special handling for pointers to other C++ director classes. * ideally this would be left to a typemap, but there is currently no * way to selectively apply the dynamic_cast<> to classes that have * directors. in other words, the type "SwigDirector_$1_lname" only exists * for classes with directors. we avoid the problem here by checking * module.wrap::directormap, but it's not clear how to get a typemap to * do something similar. perhaps a new default typemap (in addition * to SWIGTYPE) called DIRECTORTYPE? */ if (SwigType_ispointer(ptype) || SwigType_isreference(ptype)) { Node *module = Getattr(parent, "module"); Node *target = Swig_directormap(module, ptype); sprintf(source, "obj%d", idx++); String *nonconst = 0; /* strip pointer/reference --- should move to Swig/stype.c */ String *nptype = NewString(Char(ptype) + 2); /* name as pointer */ String *ppname = Copy(pname); if (SwigType_isreference(ptype)) { Insert(ppname, 0, "&"); } /* if necessary, cast away const since Python doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", pname); String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, "Target language argument '%s' discards const in director method %s::%s.\n", SwigType_str(ptype, pname), SwigType_namestr(c_classname), SwigType_namestr(name)); } else { nonconst = Copy(ppname); } Delete(nptype); Delete(ppname); String *mangle = SwigType_manglestr(ptype); if (target) { String *director = NewStringf("director_%s", mangle); Wrapper_add_localv(w, director, "Swig::Director *", director, "= 0", NIL); Wrapper_add_localv(w, source, "CAML_VALUE", source, "= Val_unit", NIL); Printf(wrap_args, "%s = dynamic_cast(%s);\n", director, nonconst); Printf(wrap_args, "if (!%s) {\n", director); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); Printf(wrap_args, "} else {\n"); Printf(wrap_args, "%s = %s->swig_get_self();\n", source, director); Printf(wrap_args, "}\n"); Delete(director); Printv(arglist, source, NIL); } else { Wrapper_add_localv(w, source, "CAML_VALUE", source, "= Val_unit", NIL); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); //Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n", // source, nonconst, base); Printv(arglist, source, NIL); } Delete(mangle); Delete(nonconst); } else { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_NOWRAP; break; } } p = nextSibling(p); } Printv(w->code, "swig_result = Val_unit;\n", 0); Printf(w->code, "args = Val_unit;\n"); /* wrap complex arguments to values */ Printv(w->code, wrap_args, NIL); /* pass the method call on to the Python object */ Printv(w->code, "swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0); Printf(w->code, "swig_result = " "callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),copy_string(\"%s\"),args);\n", Getattr(n, "name")); /* exception handling */ tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { tm = Getattr(n, "feature:director:except"); } if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { Printf(w->code, "if (!%s) {\n", Swig_cresult_name()); Printf(w->code, " CAML_VALUE error = *caml_named_value(\"director_except\");\n"); Replaceall(tm, "$error", "error"); Printv(w->code, Str(tm), "\n", NIL); Printf(w->code, "}\n"); } /* * Python method may return a simple object, or a tuple. * for in/out aruments, we have to extract the appropriate values from the * argument list, then marshal everything back to C/C++ (return value and * output arguments). */ /* marshal return value and other outputs (if any) from value to C/C++ * type */ String *cleanup = NewString(""); String *outarg = NewString(""); tm = Swig_typemap_lookup("directorout", n, "c_result", w); if (tm != 0) { Replaceall(tm, "$input", "swig_result"); /* TODO check this */ if (Getattr(n, "wrap:disown")) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } Replaceall(tm, "$result", "c_result"); Printv(w->code, tm, "\n", NIL); } /* marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { Replaceall(tm, "$result", "swig_result"); Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } Delete(arglist); Delete(cleanup); Delete(outarg); } /* any existing helper functions to handle this? */ if (!is_void) { if (!(ignored_method && !pure_virtual)) { /* A little explanation: * The director_enum test case makes a method whose return type * is an enum type. returntype here is "int". gcc complains * about an implicit enum conversion, and although i don't strictly * agree with it, I'm working on fixing the error: * * Below is what I came up with. It's not great but it should * always essentially work. */ if (!SwigType_isreference(returntype)) { Printf(w->code, "CAMLreturn_type((%s)c_result);\n", SwigType_lstr(returntype, "")); } else { Printf(w->code, "CAMLreturn_type(*c_result);\n"); } } } Printf(w->code, "}\n"); // We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method String *inline_extra_method = NewString(""); if (dirprot_mode() && !is_public(n) && !pure_virtual) { Printv(inline_extra_method, declaration, NIL); String *extra_method_name = NewStringf("%sSwigPublic", name); Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, ";\n", " {\n "); if (!is_void) Printf(inline_extra_method, "return "); String *methodcall = Swig_method_call(super, l); Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Delete(methodcall); Delete(extra_method_name); } /* emit the director method */ if (status == SWIG_OK) { if (!Getattr(n, "defaultargs")) { Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); } } /* clean up */ Delete(wrap_args); Delete(pclassname); DelWrapper(w); return status; } /* ------------------------------------------------------------ * classDirectorConstructor() * ------------------------------------------------------------ */ int classDirectorConstructor(Node *n) { Node *parent = Getattr(n, "parentNode"); String *sub = NewString(""); String *decl = Getattr(n, "decl"); String *supername = Swig_class_name(parent); String *classname = NewString(""); Printf(classname, "SwigDirector_%s", supername); /* insert self parameter */ Parm *p, *q; ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("CAML_VALUE"); p = NewParm(type, NewString("self"), n); q = Copy(p); set_nextSibling(q, superparms); set_nextSibling(p, parms); parms = p; if (!Getattr(n, "defaultargs")) { /* constructor */ { Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self) { }", classname, target, call); Delete(target); Wrapper_print(w, f_directors); Delete(call); DelWrapper(w); } /* constructor header */ { String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } } Setattr(n, "parms", q); Language::classDirectorConstructor(n); Delete(sub); Delete(classname); Delete(supername); //Delete(parms); return SWIG_OK; } /* ------------------------------------------------------------ * classDirectorDefaultConstructor() * ------------------------------------------------------------ */ int classDirectorDefaultConstructor(Node *n) { String *classname; classname = Swig_class_name(n); /* insert self parameter */ Parm *p, *q; ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("CAML_VALUE"); p = NewParm(type, NewString("self"), n); q = Copy(p); set_nextSibling(p, parms); { Wrapper *w = NewWrapper(); Printf(w->def, "SwigDirector_%s::SwigDirector_%s(CAML_VALUE self) : Swig::Director(self) { }", classname, classname); Wrapper_print(w, f_directors); DelWrapper(w); } Printf(f_directors_h, " SwigDirector_%s(CAML_VALUE self);\n", classname); Delete(classname); Setattr(n, "parms", q); return Language::classDirectorDefaultConstructor(n); } int classDirectorInit(Node *n) { String *declaration = Swig_director_declaration(n); Printf(f_directors_h, "\n" "%s\n" "public:\n", declaration); Delete(declaration); return Language::classDirectorInit(n); } int classDirectorEnd(Node *n) { Printf(f_directors_h, "};\n\n"); return Language::classDirectorEnd(n); } /* --------------------------------------------------------------------- * typedefHandler * * This is here in order to maintain the correct association between * typedef names and enum names. * * Since I implement enums as polymorphic variant tags, I need to call * back into ocaml to evaluate them. This requires a string that can * be generated in the typemaps, and also at SWIG time to be the same * string. The problem that arises is that SWIG variously generates * enum e_name_tag * e_name_tag * e_typedef_name * for * typedef enum e_name_tag { ... } e_typedef_name; * * Since I need these strings to be consistent, I must maintain a correct * association list between typedef and enum names. * --------------------------------------------------------------------- */ int typedefHandler(Node *n) { String *type = Getattr(n, "type"); Node *enum_node = type ? Getattr(seen_enums, type) : 0; if (enum_node) { String *name = Getattr(enum_node, "name"); Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", Getattr(n, "name"), name); } return SWIG_OK; } String *runtimeCode() { String *s = Swig_include_sys("ocaml.swg"); if (!s) { Printf(stderr, "*** Unable to open 'ocaml.swg'\n"); s = NewString(""); } return s; } String *defaultExternalRuntimeFilename() { return NewString("swigocamlrun.h"); } }; /* ------------------------------------------------------------------------- * swig_ocaml() - Instantiate module * ------------------------------------------------------------------------- */ static Language *new_swig_ocaml() { return new OCAML(); } extern "C" Language *swig_ocaml(void) { return new_swig_ocaml(); } swig-3.0.2/Source/Modules/chicken.cxx0000664000175000017500000013350512343605122017352 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * chicken.cxx * * CHICKEN language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include static const char *usage = "\ \ CHICKEN Options (available with -chicken)\n\ -closprefix - Prepend to all clos identifiers\n\ -noclosuses - Do not (declare (uses ...)) in scheme file\n\ -nocollection - Do not register pointers with chicken garbage\n\ collector and export destructors\n\ -nounit - Do not (declare (unit ...)) in scheme file\n\ -proxy - Export TinyCLOS class definitions\n\ -unhideprimitive - Unhide the primitive: symbols\n\ -useclassprefix - Prepend the class name to all clos identifiers\n\ \n"; static char *module = 0; static const char *chicken_path = "chicken"; static int num_methods = 0; static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; static File *f_init = 0; static String *chickentext = 0; static String *closprefix = 0; static String *swigtype_ptr = 0; static String *f_sym_size = 0; /* some options */ static int declare_unit = 1; static int no_collection = 0; static int clos_uses = 1; /* C++ Support + Clos Classes */ static int clos = 0; static String *c_class_name = 0; static String *class_name = 0; static String *short_class_name = 0; static int in_class = 0; static int have_constructor = 0; static bool exporting_destructor = false; static bool exporting_constructor = false; static String *constructor_name = 0; static String *member_name = 0; /* sections of the .scm code */ static String *scm_const_defs = 0; static String *clos_class_defines = 0; static String *clos_methods = 0; /* Some clos options */ static int useclassprefix = 0; static String *clossymnameprefix = 0; static int hide_primitive = 1; static Hash *primitive_names = 0; /* Used for overloading constructors */ static int has_constructor_args = 0; static List *constructor_arg_types = 0; static String *constructor_dispatch = 0; static Hash *overload_parameter_lists = 0; class CHICKEN:public Language { public: virtual void main(int argc, char *argv[]); virtual int top(Node *n); virtual int functionWrapper(Node *n); virtual int variableWrapper(Node *n); virtual int constantWrapper(Node *n); virtual int classHandler(Node *n); virtual int memberfunctionHandler(Node *n); virtual int membervariableHandler(Node *n); virtual int constructorHandler(Node *n); virtual int destructorHandler(Node *n); virtual int validIdentifier(String *s); virtual int staticmembervariableHandler(Node *n); virtual int staticmemberfunctionHandler(Node *n); virtual int importDirective(Node *n); protected: void addMethod(String *scheme_name, String *function); /* Return true iff T is a pointer type */ int isPointer(SwigType *t); void dispatchFunction(Node *n); String *chickenNameMapping(String *, const_String_or_char_ptr ); String *chickenPrimitiveName(String *); String *runtimeCode(); String *defaultExternalRuntimeFilename(); String *buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname); }; /* ----------------------------------------------------------------------- * swig_chicken() - Instantiate module * ----------------------------------------------------------------------- */ static Language *new_swig_chicken() { return new CHICKEN(); } extern "C" { Language *swig_chicken(void) { return new_swig_chicken(); } } void CHICKEN::main(int argc, char *argv[]) { int i; SWIG_library_directory(chicken_path); // Look for certain command line options for (i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); SWIG_exit(0); } else if (strcmp(argv[i], "-proxy") == 0) { clos = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-closprefix") == 0) { if (argv[i + 1]) { clossymnameprefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-useclassprefix") == 0) { useclassprefix = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-unhideprimitive") == 0) { hide_primitive = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nounit") == 0) { declare_unit = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-noclosuses") == 0) { clos_uses = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nocollection") == 0) { no_collection = 1; Swig_mark_arg(i); } } } if (!clos) hide_primitive = 0; // Add a symbol for this module Preprocessor_define("SWIGCHICKEN 1", 0); // Set name of typemaps SWIG_typemap_lang("chicken"); // Read in default typemaps */ SWIG_config_file("chicken.swg"); allow_overloading(); } int CHICKEN::top(Node *n) { String *chicken_filename = NewString(""); File *f_scm; String *scmmodule; /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); chickentext = NewString(""); closprefix = NewString(""); f_sym_size = NewString(""); primitive_names = NewHash(); overload_parameter_lists = NewHash(); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("chicken", chickentext); Swig_register_filebyname("closprefix", closprefix); clos_class_defines = NewString(""); clos_methods = NewString(""); scm_const_defs = NewString(""); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGCHICKEN\n"); if (no_collection) Printf(f_runtime, "#define SWIG_CHICKEN_NO_COLLECTION 1\n"); Printf(f_runtime, "\n"); /* Set module name */ module = Swig_copy_string(Char(Getattr(n, "name"))); scmmodule = NewString(module); Replaceall(scmmodule, "_", "-"); Printf(f_header, "#define SWIG_init swig_%s_init\n", module); Printf(f_header, "#define SWIG_name \"%s\"\n", scmmodule); Printf(f_wrappers, "#ifdef __cplusplus\n"); Printf(f_wrappers, "extern \"C\" {\n"); Printf(f_wrappers, "#endif\n\n"); Language::top(n); SwigType_emit_type_table(f_runtime, f_wrappers); Printf(f_wrappers, "#ifdef __cplusplus\n"); Printf(f_wrappers, "}\n"); Printf(f_wrappers, "#endif\n"); Printf(f_init, "C_kontinue (continuation, ret);\n"); Printf(f_init, "}\n\n"); Printf(f_init, "#ifdef __cplusplus\n"); Printf(f_init, "}\n"); Printf(f_init, "#endif\n"); Printf(chicken_filename, "%s%s.scm", SWIG_output_directory(), module); if ((f_scm = NewFile(chicken_filename, "w", SWIG_output_files())) == 0) { FileErrorDisplay(chicken_filename); SWIG_exit(EXIT_FAILURE); } Swig_banner_target_lang(f_scm, ";;"); Printf(f_scm, "\n"); if (declare_unit) Printv(f_scm, "(declare (unit ", scmmodule, "))\n\n", NIL); Printv(f_scm, "(declare \n", tab4, "(hide swig-init swig-init-return)\n", tab4, "(foreign-declare \"C_extern void swig_", module, "_init(C_word,C_word,C_word) C_noret;\"))\n", NIL); Printv(f_scm, "(define swig-init (##core#primitive \"swig_", module, "_init\"))\n", NIL); Printv(f_scm, "(define swig-init-return (swig-init))\n\n", NIL); if (clos) { //Printf (f_scm, "(declare (uses tinyclos))\n"); //New chicken versions have tinyclos as an egg Printf(f_scm, "(require-extension tinyclos)\n"); Replaceall(closprefix, "$module", scmmodule); Printf(f_scm, "%s\n", closprefix); Printf(f_scm, "%s\n", clos_class_defines); Printf(f_scm, "%s\n", clos_methods); } else { Printf(f_scm, "%s\n", scm_const_defs); } Printf(f_scm, "%s\n", chickentext); Delete(f_scm); char buftmp[20]; sprintf(buftmp, "%d", num_methods); Replaceall(f_init, "$nummethods", buftmp); Replaceall(f_init, "$symsize", f_sym_size); if (hide_primitive) Replaceall(f_init, "$veclength", buftmp); else Replaceall(f_init, "$veclength", "0"); Delete(chicken_filename); Delete(chickentext); Delete(closprefix); Delete(overload_parameter_lists); Delete(clos_class_defines); Delete(clos_methods); Delete(scm_const_defs); /* Close all of the files */ Delete(primitive_names); Delete(scmmodule); Dump(f_runtime, f_begin); Dump(f_header, f_begin); Dump(f_wrappers, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_sym_size); Delete(f_init); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } int CHICKEN::functionWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); Parm *p; int i; String *wname; Wrapper *f; String *mangle = NewString(""); String *get_pointers; String *cleanup; String *argout; String *tm; String *overname = 0; String *declfunc = 0; String *scmname; bool any_specialized_arg = false; List *function_arg_types = NewList(); int num_required; int num_arguments; int have_argout; Printf(mangle, "\"%s\"", SwigType_manglestr(d)); if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) return SWIG_ERROR; } f = NewWrapper(); wname = NewString(""); get_pointers = NewString(""); cleanup = NewString(""); argout = NewString(""); declfunc = NewString(""); scmname = NewString(iname); Replaceall(scmname, "_", "-"); /* Local vars */ Wrapper_add_local(f, "resultobj", "C_word resultobj"); /* Write code to extract function parameters. */ emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); /* Get number of required and total arguments */ num_arguments = emit_num_arguments(l); num_required = emit_num_required(l); Append(wname, Swig_name_wrapper(iname)); if (overname) { Append(wname, overname); } // Check for interrupts Printv(f->code, "C_trace(\"", scmname, "\");\n", NIL); Printv(f->def, "static ", "void ", wname, " (C_word argc, C_word closure, C_word continuation", NIL); Printv(declfunc, "void ", wname, "(C_word,C_word,C_word", NIL); /* Generate code for argument marshalling */ for (i = 0, p = l; i < num_arguments; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); Printf(f->def, ", C_word scm%d", i + 1); Printf(declfunc, ",C_word"); /* Look for an input typemap */ if ((tm = Getattr(p, "tmap:in"))) { String *parse = Getattr(p, "tmap:in:parse"); if (!parse) { String *source = NewStringf("scm%d", i + 1); Replaceall(tm, "$source", source); Replaceall(tm, "$target", ln); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); /* Save the location of the object */ if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } if (i >= num_required) Printf(get_pointers, "if (argc-2>%i && (%s)) {\n", i, source); Printv(get_pointers, tm, "\n", NIL); if (i >= num_required) Printv(get_pointers, "}\n", NIL); if (clos) { if (i < num_required) { if (strcmp("void", Char(pt)) != 0) { Node *class_node = 0; String *clos_code = Getattr(p, "tmap:in:closcode"); class_node = classLookup(pt); if (clos_code && class_node) { String *class_name = NewStringf("<%s>", Getattr(class_node, "sym:name")); Replaceall(class_name, "_", "-"); Append(function_arg_types, class_name); Append(function_arg_types, Copy(clos_code)); any_specialized_arg = true; Delete(class_name); } else { Append(function_arg_types, ""); Append(function_arg_types, "$input"); } } } } Delete(source); } p = Getattr(p, "tmap:in:next"); continue; } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } } /* finish argument marshalling */ Printf(f->def, ") {"); Printf(declfunc, ")"); if (num_required != num_arguments) { Append(function_arg_types, "^^##optional$$"); } /* First check the number of arguments is correct */ if (num_arguments != num_required) Printf(f->code, "if (argc-2<%i || argc-2>%i) C_bad_argc(argc,%i);\n", num_required, num_arguments, num_required + 2); else Printf(f->code, "if (argc!=%i) C_bad_argc(argc,%i);\n", num_arguments + 2, num_arguments + 2); /* Now piece together the first part of the wrapper function */ Printv(f->code, get_pointers, NIL); /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ have_argout = 0; for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { if (!have_argout) { have_argout = 1; // Print initial argument output code Printf(argout, "SWIG_Chicken_SetupArgout\n"); } Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printf(argout, "%s", tm); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } Setattr(n, "wrap:name", wname); /* Emit the function call */ String *actioncode = emit_action(n); /* Return the function value */ if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "1"); } else { Replaceall(tm, "$owner", "0"); } Printf(f->code, "%s", tm); if (have_argout) Printf(f->code, "\nSWIG_APPEND_VALUE(resultobj);\n"); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); } emit_return_variable(n, d, f); /* Insert the argumetn output code */ Printv(f->code, argout, NIL); /* Output cleanup code */ Printv(f->code, cleanup, NIL); /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } if (have_argout) { Printf(f->code, "C_kontinue(continuation,C_SCHEME_END_OF_LIST);\n"); } else { if (exporting_constructor && clos && hide_primitive) { /* Don't return a proxy, the wrapped CLOS class is the proxy */ Printf(f->code, "C_kontinue(continuation,resultobj);\n"); } else { // make the continuation the proxy creation function, if one exists Printv(f->code, "{\n", "C_word func;\n", "SWIG_Chicken_FindCreateProxy(func, resultobj)\n", "if (C_swig_is_closurep(func))\n", " ((C_proc4)(void *)C_block_item(func, 0))(4,func,continuation,resultobj,C_SCHEME_FALSE);\n", "else\n", " C_kontinue(continuation, resultobj);\n", "}\n", NIL); } } /* Error handling code */ #ifdef USE_FAIL Printf(f->code, "fail:\n"); Printv(f->code, cleanup, NIL); Printf(f->code, "swig_panic (\"failure in " "'$symname' SWIG function wrapper\");\n"); #endif Printf(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); /* Substitute the function name */ Replaceall(f->code, "$symname", iname); Replaceall(f->code, "$result", "resultobj"); /* Dump the function out */ Printv(f_wrappers, "static ", declfunc, " C_noret;\n", NIL); Wrapper_print(f, f_wrappers); /* Now register the function with the interpreter. */ if (!Getattr(n, "sym:overloaded")) { if (exporting_destructor && !no_collection) { Printf(f_init, "((swig_chicken_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (swig_chicken_destructor) %s;\n", swigtype_ptr, wname); } else { addMethod(scmname, wname); } /* Only export if we are not in a class, or if in a class memberfunction */ if (!in_class || member_name) { String *method_def; String *clos_name; if (in_class) clos_name = NewString(member_name); else clos_name = chickenNameMapping(scmname, ""); if (!any_specialized_arg) { method_def = NewString(""); Printv(method_def, "(define ", clos_name, " ", chickenPrimitiveName(scmname), ")", NIL); } else { method_def = buildClosFunctionCall(function_arg_types, clos_name, chickenPrimitiveName(scmname)); } Printv(clos_methods, method_def, "\n", NIL); Delete(clos_name); Delete(method_def); } if (have_constructor && !has_constructor_args && any_specialized_arg) { has_constructor_args = 1; constructor_arg_types = Copy(function_arg_types); } } else { /* add function_arg_types to overload hash */ List *flist = Getattr(overload_parameter_lists, scmname); if (!flist) { flist = NewList(); Setattr(overload_parameter_lists, scmname, flist); } Append(flist, Copy(function_arg_types)); if (!Getattr(n, "sym:nextSibling")) { dispatchFunction(n); } } Delete(wname); Delete(get_pointers); Delete(cleanup); Delete(declfunc); Delete(mangle); Delete(function_arg_types); DelWrapper(f); return SWIG_OK; } int CHICKEN::variableWrapper(Node *n) { char *name = GetChar(n, "name"); char *iname = GetChar(n, "sym:name"); SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *wname = NewString(""); String *mangle = NewString(""); String *tm; String *tm2 = NewString(""); String *argnum = NewString("0"); String *arg = NewString("argv[0]"); Wrapper *f; String *overname = 0; String *scmname; scmname = NewString(iname); Replaceall(scmname, "_", "-"); Printf(mangle, "\"%s\"", SwigType_manglestr(t)); if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) return SWIG_ERROR; } f = NewWrapper(); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); // evaluation function names Append(wname, Swig_name_wrapper(iname)); if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); // Check for interrupts Printv(f->code, "C_trace(\"", scmname, "\");\n", NIL); if (1 || (SwigType_type(t) != T_USER) || (isPointer(t))) { Printv(f->def, "static ", "void ", wname, "(C_word, C_word, C_word, C_word) C_noret;\n", NIL); Printv(f->def, "static " "void ", wname, "(C_word argc, C_word closure, " "C_word continuation, C_word value) {\n", NIL); Wrapper_add_local(f, "resultobj", "C_word resultobj"); Printf(f->code, "if (argc!=2 && argc!=3) C_bad_argc(argc,2);\n"); /* Check for a setting of the variable value */ if (!GetFlag(n, "feature:immutable")) { Printf(f->code, "if (argc > 2) {\n"); if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { Replaceall(tm, "$source", "value"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "value"); /* Printv(f->code, tm, "\n",NIL); */ emit_action_code(n, f->code, tm); } else { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); } Printf(f->code, "}\n"); } String *varname; if (SwigType_istemplate((char *) name)) { varname = SwigType_namestr((char *) name); } else { varname = name; } // Now return the value of the variable - regardless // of evaluating or setting. if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$source", varname); Replaceall(tm, "$varname", varname); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); /* Printf(f->code, "%s\n", tm); */ emit_action_code(n, f->code, tm); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0)); } Printv(f->code, "{\n", "C_word func;\n", "SWIG_Chicken_FindCreateProxy(func, resultobj)\n", "if (C_swig_is_closurep(func))\n", " ((C_proc4)(void *)C_block_item(func, 0))(4,func,continuation,resultobj,C_SCHEME_FALSE);\n", "else\n", " C_kontinue(continuation, resultobj);\n", "}\n", NIL); /* Error handling code */ #ifdef USE_FAIL Printf(f->code, "fail:\n"); Printf(f->code, "swig_panic (\"failure in " "'%s' SWIG wrapper\");\n", proc_name); #endif Printf(f->code, "}\n"); Wrapper_print(f, f_wrappers); /* Now register the variable with the interpreter. */ addMethod(scmname, wname); if (!in_class || member_name) { String *clos_name; if (in_class) clos_name = NewString(member_name); else clos_name = chickenNameMapping(scmname, ""); Node *class_node = classLookup(t); String *clos_code = Getattr(n, "tmap:varin:closcode"); if (class_node && clos_code && !GetFlag(n, "feature:immutable")) { Replaceall(clos_code, "$input", "(car lst)"); Printv(clos_methods, "(define (", clos_name, " . lst) (if (null? lst) (", chickenPrimitiveName(scmname), ") (", chickenPrimitiveName(scmname), " ", clos_code, ")))\n", NIL); } else { /* Simply re-export the procedure */ if (GetFlag(n, "feature:immutable") && GetFlag(n, "feature:constasvar")) { Printv(clos_methods, "(define ", clos_name, " (", chickenPrimitiveName(scmname), "))\n", NIL); Printv(scm_const_defs, "(set! ", scmname, " (", scmname, "))\n", NIL); } else { Printv(clos_methods, "(define ", clos_name, " ", chickenPrimitiveName(scmname), ")\n", NIL); } } Delete(clos_name); } } else { Swig_warning(WARN_TYPEMAP_VAR_UNDEF, input_file, line_number, "Unsupported variable type %s (ignored).\n", SwigType_str(t, 0)); } Delete(wname); Delete(argnum); Delete(arg); Delete(tm2); Delete(mangle); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * constantWrapper() * ------------------------------------------------------------ */ int CHICKEN::constantWrapper(Node *n) { char *name = GetChar(n, "name"); char *iname = GetChar(n, "sym:name"); SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *value = Getattr(n, "value"); String *proc_name = NewString(""); String *wname = NewString(""); String *mangle = NewString(""); String *tm; String *tm2 = NewString(""); String *source = NewString(""); String *argnum = NewString("0"); String *arg = NewString("argv[0]"); Wrapper *f; String *overname = 0; String *scmname; String *rvalue; SwigType *nctype; scmname = NewString(iname); Replaceall(scmname, "_", "-"); Printf(source, "swig_const_%s", iname); Replaceall(source, "::", "__"); Printf(mangle, "\"%s\"", SwigType_manglestr(t)); if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) return SWIG_ERROR; } Append(wname, Swig_name_wrapper(iname)); if (overname) { Append(wname, overname); } nctype = NewString(t); if (SwigType_isconst(nctype)) { Delete(SwigType_pop(nctype)); } bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); if (SwigType_type(nctype) == T_STRING) { rvalue = NewStringf("\"%s\"", value); } else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) { rvalue = NewStringf("\'%s\'", value); } else { rvalue = NewString(value); } /* Special hook for member pointer */ if (SwigType_type(t) == T_MPOINTER) { Printf(f_header, "static %s = %s;\n", SwigType_str(t, source), rvalue); } else { if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) { Replaceall(tm, "$source", rvalue); Replaceall(tm, "$target", source); Replaceall(tm, "$result", source); Replaceall(tm, "$value", rvalue); Printf(f_header, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); return SWIG_NOWRAP; } } f = NewWrapper(); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); // evaluation function names // Check for interrupts Printv(f->code, "C_trace(\"", scmname, "\");\n", NIL); if (1 || (SwigType_type(t) != T_USER) || (isPointer(t))) { Setattr(n, "wrap:name", wname); Printv(f->def, "static ", "void ", wname, "(C_word, C_word, C_word) C_noret;\n", NIL); Printv(f->def, "static ", "void ", wname, "(C_word argc, C_word closure, " "C_word continuation) {\n", NIL); Wrapper_add_local(f, "resultobj", "C_word resultobj"); Printf(f->code, "if (argc!=2) C_bad_argc(argc,2);\n"); // Return the value of the variable if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$source", source); Replaceall(tm, "$varname", source); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); /* Printf(f->code, "%s\n", tm); */ emit_action_code(n, f->code, tm); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0)); } Printv(f->code, "{\n", "C_word func;\n", "SWIG_Chicken_FindCreateProxy(func, resultobj)\n", "if (C_swig_is_closurep(func))\n", " ((C_proc4)(void *)C_block_item(func, 0))(4,func,continuation,resultobj,C_SCHEME_FALSE);\n", "else\n", " C_kontinue(continuation, resultobj);\n", "}\n", NIL); /* Error handling code */ #ifdef USE_FAIL Printf(f->code, "fail:\n"); Printf(f->code, "swig_panic (\"failure in " "'%s' SWIG wrapper\");\n", proc_name); #endif Printf(f->code, "}\n"); Wrapper_print(f, f_wrappers); /* Now register the variable with the interpreter. */ addMethod(scmname, wname); if (!in_class || member_name) { String *clos_name; if (in_class) clos_name = NewString(member_name); else clos_name = chickenNameMapping(scmname, ""); if (GetFlag(n, "feature:constasvar")) { Printv(clos_methods, "(define ", clos_name, " (", chickenPrimitiveName(scmname), "))\n", NIL); Printv(scm_const_defs, "(set! ", scmname, " (", scmname, "))\n", NIL); } else { Printv(clos_methods, "(define ", clos_name, " ", chickenPrimitiveName(scmname), ")\n", NIL); } Delete(clos_name); } } else { Swig_warning(WARN_TYPEMAP_VAR_UNDEF, input_file, line_number, "Unsupported variable type %s (ignored).\n", SwigType_str(t, 0)); } Delete(wname); Delete(nctype); Delete(proc_name); Delete(argnum); Delete(arg); Delete(tm2); Delete(mangle); Delete(source); Delete(rvalue); DelWrapper(f); return SWIG_OK; } int CHICKEN::classHandler(Node *n) { /* Create new strings for building up a wrapper function */ have_constructor = 0; constructor_dispatch = 0; constructor_name = 0; c_class_name = NewString(Getattr(n, "sym:name")); class_name = NewString(""); short_class_name = NewString(""); Printv(class_name, "<", c_class_name, ">", NIL); Printv(short_class_name, c_class_name, NIL); Replaceall(class_name, "_", "-"); Replaceall(short_class_name, "_", "-"); if (!addSymbol(class_name, n)) return SWIG_ERROR; /* Handle inheritance */ String *base_class = NewString(""); List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist)) { Iterator base = First(baselist); while (base.item) { if (!Getattr(base.item, "feature:ignore")) Printv(base_class, "<", Getattr(base.item, "sym:name"), "> ", NIL); base = Next(base); } } Replaceall(base_class, "_", "-"); String *scmmod = NewString(module); Replaceall(scmmod, "_", "-"); Printv(clos_class_defines, "(define ", class_name, "\n", " (make 'name \"", short_class_name, "\"\n", NIL); Delete(scmmod); if (Len(base_class)) { Printv(clos_class_defines, " 'direct-supers (list ", base_class, ")\n", NIL); } else { Printv(clos_class_defines, " 'direct-supers (list )\n", NIL); } Printf(clos_class_defines, " 'direct-slots (list 'swig-this\n"); String *mangled_classname = Swig_name_mangle(Getattr(n, "sym:name")); SwigType *ct = NewStringf("p.%s", Getattr(n, "name")); swigtype_ptr = SwigType_manglestr(ct); Printf(f_runtime, "static swig_chicken_clientdata _swig_chicken_clientdata%s = { 0 };\n", mangled_classname); Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_chicken_clientdata", mangled_classname, ");\n", NIL); SwigType_remember(ct); /* Emit all of the members */ in_class = 1; Language::classHandler(n); in_class = 0; Printf(clos_class_defines, ")))\n\n"); if (have_constructor) { Printv(clos_methods, "(define-method (initialize (obj ", class_name, ") initargs)\n", " (swig-initialize obj initargs ", NIL); if (constructor_arg_types) { String *initfunc_name = NewStringf("%s@@SWIG@initmethod", class_name); String *func_call = buildClosFunctionCall(constructor_arg_types, initfunc_name, chickenPrimitiveName(constructor_name)); Printf(clos_methods, "%s)\n)\n", initfunc_name); Printf(clos_methods, "(declare (hide %s))\n", initfunc_name); Printf(clos_methods, "%s\n", func_call); Delete(func_call); Delete(initfunc_name); Delete(constructor_arg_types); constructor_arg_types = 0; } else if (constructor_dispatch) { Printf(clos_methods, "%s)\n)\n", constructor_dispatch); Delete(constructor_dispatch); constructor_dispatch = 0; } else { Printf(clos_methods, "%s)\n)\n", chickenPrimitiveName(constructor_name)); } Delete(constructor_name); constructor_name = 0; } else { Printv(clos_methods, "(define-method (initialize (obj ", class_name, ") initargs)\n", " (swig-initialize obj initargs (lambda x #f)))\n", NIL); } /* export class initialization function */ if (clos) { String *funcname = NewString(mangled_classname); Printf(funcname, "_swig_chicken_setclosclass"); String *closfuncname = NewString(funcname); Replaceall(closfuncname, "_", "-"); Printv(f_wrappers, "static void ", funcname, "(C_word,C_word,C_word,C_word) C_noret;\n", "static void ", funcname, "(C_word argc, C_word closure, C_word continuation, C_word cl) {\n", " C_trace(\"", funcname, "\");\n", " if (argc!=3) C_bad_argc(argc,3);\n", " swig_chicken_clientdata *cdata = (swig_chicken_clientdata *) SWIGTYPE", swigtype_ptr, "->clientdata;\n", " cdata->gc_proxy_create = CHICKEN_new_gc_root();\n", " CHICKEN_gc_root_set(cdata->gc_proxy_create, cl);\n", " C_kontinue(continuation, C_SCHEME_UNDEFINED);\n", "}\n", NIL); addMethod(closfuncname, funcname); Printv(clos_methods, "(", chickenPrimitiveName(closfuncname), " (lambda (x lst) (if lst ", "(cons (make ", class_name, " 'swig-this x) lst) ", "(make ", class_name, " 'swig-this x))))\n\n", NIL); Delete(closfuncname); Delete(funcname); } Delete(mangled_classname); Delete(swigtype_ptr); swigtype_ptr = 0; Delete(class_name); Delete(short_class_name); Delete(c_class_name); class_name = 0; short_class_name = 0; c_class_name = 0; return SWIG_OK; } int CHICKEN::memberfunctionHandler(Node *n) { String *iname = Getattr(n, "sym:name"); String *proc = NewString(iname); Replaceall(proc, "_", "-"); member_name = chickenNameMapping(proc, short_class_name); Language::memberfunctionHandler(n); Delete(member_name); member_name = NULL; Delete(proc); return SWIG_OK; } int CHICKEN::staticmemberfunctionHandler(Node *n) { String *iname = Getattr(n, "sym:name"); String *proc = NewString(iname); Replaceall(proc, "_", "-"); member_name = NewStringf("%s-%s", short_class_name, proc); Language::staticmemberfunctionHandler(n); Delete(member_name); member_name = NULL; Delete(proc); return SWIG_OK; } int CHICKEN::membervariableHandler(Node *n) { String *iname = Getattr(n, "sym:name"); //String *pb = SwigType_typedef_resolve_all(SwigType_base(Getattr(n, "type"))); Language::membervariableHandler(n); String *proc = NewString(iname); Replaceall(proc, "_", "-"); //Node *class_node = Swig_symbol_clookup(pb, Getattr(n, "sym:symtab")); Node *class_node = classLookup(Getattr(n, "type")); //String *getfunc = NewStringf("%s-%s-get", short_class_name, proc); //String *setfunc = NewStringf("%s-%s-set", short_class_name, proc); String *getfunc = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname)); Replaceall(getfunc, "_", "-"); String *setfunc = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname)); Replaceall(setfunc, "_", "-"); Printv(clos_class_defines, " (list '", proc, " ':swig-virtual ':swig-get ", chickenPrimitiveName(getfunc), NIL); if (!GetFlag(n, "feature:immutable")) { if (class_node) { Printv(clos_class_defines, " ':swig-set (lambda (x y) (", chickenPrimitiveName(setfunc), " x (slot-ref y 'swig-this))))\n", NIL); } else { Printv(clos_class_defines, " ':swig-set ", chickenPrimitiveName(setfunc), ")\n", NIL); } } else { Printf(clos_class_defines, ")\n"); } Delete(proc); Delete(setfunc); Delete(getfunc); return SWIG_OK; } int CHICKEN::staticmembervariableHandler(Node *n) { String *iname = Getattr(n, "sym:name"); String *proc = NewString(iname); Replaceall(proc, "_", "-"); member_name = NewStringf("%s-%s", short_class_name, proc); Language::staticmembervariableHandler(n); Delete(member_name); member_name = NULL; Delete(proc); return SWIG_OK; } int CHICKEN::constructorHandler(Node *n) { have_constructor = 1; has_constructor_args = 0; exporting_constructor = true; Language::constructorHandler(n); exporting_constructor = false; has_constructor_args = 1; String *iname = Getattr(n, "sym:name"); constructor_name = Swig_name_construct(NSPACE_TODO, iname); Replaceall(constructor_name, "_", "-"); return SWIG_OK; } int CHICKEN::destructorHandler(Node *n) { if (no_collection) member_name = NewStringf("delete-%s", short_class_name); exporting_destructor = true; Language::destructorHandler(n); exporting_destructor = false; if (no_collection) { Delete(member_name); member_name = NULL; } return SWIG_OK; } int CHICKEN::importDirective(Node *n) { String *modname = Getattr(n, "module"); if (modname && clos_uses) { // Find the module node for this imported module. It should be the // first child but search just in case. Node *mod = firstChild(n); while (mod && Strcmp(nodeType(mod), "module") != 0) mod = nextSibling(mod); if (mod) { String *name = Getattr(mod, "name"); if (name) { Printf(closprefix, "(declare (uses %s))\n", name); } } } return Language::importDirective(n); } String *CHICKEN::buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname) { String *method_signature = NewString(""); String *func_args = NewString(""); String *func_call = NewString(""); Iterator arg_type; int arg_count = 0; int optional_arguments = 0; for (arg_type = First(types); arg_type.item; arg_type = Next(arg_type)) { if (Strcmp(arg_type.item, "^^##optional$$") == 0) { optional_arguments = 1; } else { Printf(method_signature, " (arg%i %s)", arg_count, arg_type.item); arg_type = Next(arg_type); if (!arg_type.item) break; String *arg = NewStringf("arg%i", arg_count); String *access_arg = Copy(arg_type.item); Replaceall(access_arg, "$input", arg); Printf(func_args, " %s", access_arg); Delete(arg); Delete(access_arg); } arg_count++; } if (optional_arguments) { Printf(func_call, "(define-method (%s %s . args) (apply %s %s args))", closname, method_signature, funcname, func_args); } else { Printf(func_call, "(define-method (%s %s) (%s %s))", closname, method_signature, funcname, func_args); } Delete(method_signature); Delete(func_args); return func_call; } extern "C" { /* compares based on non-primitive names */ static int compareTypeListsHelper(const DOH *a, const DOH *b, int opt_equal) { List *la = (List *) a; List *lb = (List *) b; Iterator ia = First(la); Iterator ib = First(lb); while (ia.item && ib.item) { int ret = Strcmp(ia.item, ib.item); if (ret) return ret; ia = Next(Next(ia)); ib = Next(Next(ib)); } if (opt_equal && ia.item && Strcmp(ia.item, "^^##optional$$") == 0) return 0; if (ia.item) return -1; if (opt_equal && ib.item && Strcmp(ib.item, "^^##optional$$") == 0) return 0; if (ib.item) return 1; return 0; } static int compareTypeLists(const DOH *a, const DOH *b) { return compareTypeListsHelper(a, b, 0); } } void CHICKEN::dispatchFunction(Node *n) { /* Last node in overloaded chain */ int maxargs; String *tmp = NewString(""); String *dispatch = Swig_overload_dispatch(n, "%s (2+$numargs,closure," "continuation$commaargs);", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *f = NewWrapper(); String *iname = Getattr(n, "sym:name"); String *wname = NewString(""); String *scmname = NewString(iname); Replaceall(scmname, "_", "-"); Append(wname, Swig_name_wrapper(iname)); Printv(f->def, "static void real_", wname, "(C_word, C_word, C_word, C_word) C_noret;\n", NIL); Printv(f->def, "static void real_", wname, "(C_word oldargc, C_word closure, C_word continuation, C_word args) {", NIL); Wrapper_add_local(f, "argc", "int argc"); Printf(tmp, "C_word argv[%d]", maxargs + 1); Wrapper_add_local(f, "argv", tmp); Wrapper_add_local(f, "ii", "int ii"); Wrapper_add_local(f, "t", "C_word t = args"); Printf(f->code, "if (!C_swig_is_list (args)) {\n"); Printf(f->code, " swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, " "\"Argument #1 must be a list of overloaded arguments\");\n"); Printf(f->code, "}\n"); Printf(f->code, "argc = C_unfix (C_i_length (args));\n"); Printf(f->code, "for (ii = 0; (ii < argc) && (ii < %d); ii++, t = C_block_item (t, 1)) {\n", maxargs); Printf(f->code, "argv[ii] = C_block_item (t, 0);\n"); Printf(f->code, "}\n"); Printv(f->code, dispatch, "\n", NIL); Printf(f->code, "swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE," "\"No matching function for overloaded '%s'\");\n", iname); Printv(f->code, "}\n", NIL); Wrapper_print(f, f_wrappers); addMethod(scmname, wname); DelWrapper(f); f = NewWrapper(); /* varargs */ Printv(f->def, "void ", wname, "(C_word, C_word, C_word, ...) C_noret;\n", NIL); Printv(f->def, "void ", wname, "(C_word c, C_word t0, C_word t1, ...) {", NIL); Printv(f->code, "C_word t2;\n", "va_list v;\n", "C_word *a, c2 = c;\n", "C_save_rest (t1, c2, 2);\n", "a = C_alloc((c-2)*3);\n", "t2 = C_restore_rest (a, C_rest_count (0));\n", "real_", wname, " (3, t0, t1, t2);\n", NIL); Printv(f->code, "}\n", NIL); Wrapper_print(f, f_wrappers); /* Now deal with overloaded function when exporting clos */ if (clos) { List *flist = Getattr(overload_parameter_lists, scmname); if (flist) { Delattr(overload_parameter_lists, scmname); SortList(flist, compareTypeLists); String *clos_name; if (have_constructor && !has_constructor_args) { has_constructor_args = 1; constructor_dispatch = NewStringf("%s@SWIG@new@dispatch", short_class_name); clos_name = Copy(constructor_dispatch); Printf(clos_methods, "(declare (hide %s))\n", clos_name); } else if (in_class) clos_name = NewString(member_name); else clos_name = chickenNameMapping(scmname, ""); Iterator f; List *prev = 0; int all_primitive = 1; /* first check for duplicates and an empty call */ String *newlist = NewList(); for (f = First(flist); f.item; f = Next(f)) { /* check if cur is a duplicate of prev */ if (prev && compareTypeListsHelper(f.item, prev, 1) == 0) { Delete(f.item); } else { Append(newlist, f.item); prev = f.item; Iterator j; for (j = First(f.item); j.item; j = Next(j)) { if (Strcmp(j.item, "^^##optional$$") != 0 && Strcmp(j.item, "") != 0) all_primitive = 0; } } } Delete(flist); flist = newlist; if (all_primitive) { Printf(clos_methods, "(define %s %s)\n", clos_name, chickenPrimitiveName(scmname)); } else { for (f = First(flist); f.item; f = Next(f)) { /* now export clos code for argument */ String *func_call = buildClosFunctionCall(f.item, clos_name, chickenPrimitiveName(scmname)); Printf(clos_methods, "%s\n", func_call); Delete(f.item); Delete(func_call); } } Delete(clos_name); Delete(flist); } } DelWrapper(f); Delete(dispatch); Delete(tmp); Delete(wname); } int CHICKEN::isPointer(SwigType *t) { return SwigType_ispointer(SwigType_typedef_resolve_all(t)); } void CHICKEN::addMethod(String *scheme_name, String *function) { String *sym = NewString(""); if (clos) { Append(sym, "primitive:"); } Append(sym, scheme_name); /* add symbol to Chicken internal symbol table */ if (hide_primitive) { Printv(f_init, "{\n", " C_word *p0 = a;\n", " *(a++)=C_CLOSURE_TYPE|1;\n", " *(a++)=(C_word)", function, ";\n", " C_mutate(return_vec++, (C_word)p0);\n", "}\n", NIL); } else { Printf(f_sym_size, "+C_SIZEOF_INTERNED_SYMBOL(%d)", Len(sym)); Printf(f_init, "sym = C_intern (&a, %d, \"%s\");\n", Len(sym), sym); Printv(f_init, "C_mutate ((C_word*)sym+1, (*a=C_CLOSURE_TYPE|1, a[1]=(C_word)", function, ", tmp=(C_word)a, a+=2, tmp));\n", NIL); } if (hide_primitive) { Setattr(primitive_names, scheme_name, NewStringf("(vector-ref swig-init-return %i)", num_methods)); } else { Setattr(primitive_names, scheme_name, Copy(sym)); } num_methods++; Delete(sym); } String *CHICKEN::chickenPrimitiveName(String *name) { String *value = Getattr(primitive_names, name); if (value) return value; else { Swig_error(input_file, line_number, "Internal Error: attempting to reference non-existant primitive name %s\n", name); return NewString("#f"); } } int CHICKEN::validIdentifier(String *s) { char *c = Char(s); /* Check whether we have an R5RS identifier. */ /* --> * | */ /* --> | */ if (!(isalpha(*c) || (*c == '!') || (*c == '$') || (*c == '%') || (*c == '&') || (*c == '*') || (*c == '/') || (*c == ':') || (*c == '<') || (*c == '=') || (*c == '>') || (*c == '?') || (*c == '^') || (*c == '_') || (*c == '~'))) { /* --> + | - | ... */ if ((strcmp(c, "+") == 0) || strcmp(c, "-") == 0 || strcmp(c, "...") == 0) return 1; else return 0; } /* --> | | */ while (*c) { if (!(isalnum(*c) || (*c == '!') || (*c == '$') || (*c == '%') || (*c == '&') || (*c == '*') || (*c == '/') || (*c == ':') || (*c == '<') || (*c == '=') || (*c == '>') || (*c == '?') || (*c == '^') || (*c == '_') || (*c == '~') || (*c == '+') || (*c == '-') || (*c == '.') || (*c == '@'))) return 0; c++; } return 1; } /* ------------------------------------------------------------ * closNameMapping() * Maps the identifier from C++ to the CLOS based on command * line parameters and such. * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ String *CHICKEN::chickenNameMapping(String *name, const_String_or_char_ptr class_name) { String *n = NewString(""); if (Strcmp(class_name, "") == 0) { // not part of a class, so no class name to prefix if (clossymnameprefix) { Printf(n, "%s%s", clossymnameprefix, name); } else { Printf(n, "%s", name); } } else { if (useclassprefix) { Printf(n, "%s-%s", class_name, name); } else { if (clossymnameprefix) { Printf(n, "%s%s", clossymnameprefix, name); } else { Printf(n, "%s", name); } } } return n; } String *CHICKEN::runtimeCode() { String *s = Swig_include_sys("chickenrun.swg"); if (!s) { Printf(stderr, "*** Unable to open 'chickenrun.swg'\n"); s = NewString(""); } return s; } String *CHICKEN::defaultExternalRuntimeFilename() { return NewString("swigchickenrun.h"); } swig-3.0.2/Source/Modules/lang.cxx0000664000175000017500000035035712343605122016675 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * lang.cxx * * Language base class functions. Default C++ handling is also implemented here. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" #include /* default mode settings */ static int director_mode = 0; static int director_protected_mode = 1; static int all_protected_mode = 0; static int naturalvar_mode = 0; Language *Language::this_ = 0; /* Set director_protected_mode */ void Wrapper_director_mode_set(int flag) { director_mode = flag; } void Wrapper_director_protected_mode_set(int flag) { director_protected_mode = flag; } void Wrapper_all_protected_mode_set(int flag) { all_protected_mode = flag; } void Wrapper_naturalvar_mode_set(int flag) { naturalvar_mode = flag; } extern "C" { int Swig_director_mode() { return director_mode; } int Swig_director_protected_mode() { return director_protected_mode; } int Swig_all_protected_mode() { return all_protected_mode; } void Language_replace_special_variables(String *method, String *tm, Parm *parm) { Language::instance()->replaceSpecialVariables(method, tm, parm); } } /* Some status variables used during parsing */ static int InClass = 0; /* Parsing C++ or not */ static String *ClassName = 0; /* This is the real name of the current class */ static String *ClassPrefix = 0; /* Class prefix */ static String *NSpace = 0; /* Namespace for the nspace feature */ static String *ClassType = 0; /* Fully qualified type name to use */ static String *DirectorClassName = 0; /* Director name of the current class */ int Abstract = 0; int ImportMode = 0; int IsVirtual = 0; static String *AttributeFunctionGet = 0; static String *AttributeFunctionSet = 0; static Node *CurrentClass = 0; int line_number = 0; String *input_file = 0; int SmartPointer = 0; static Hash *classhash; extern int GenerateDefault; extern int ForceExtern; extern int AddExtern; /* import modes */ #define IMPORT_MODE 1 #define IMPORT_MODULE 2 /* ---------------------------------------------------------------------- * Dispatcher::emit_one() * * Dispatch a single node * ---------------------------------------------------------------------- */ int Dispatcher::emit_one(Node *n) { int ret = SWIG_OK; char *tag = Char(nodeType(n)); if (!tag) { /* Printf(stderr,"SWIG: Fatal internal error. Malformed parse tree node!\n"); */ return SWIG_OK; } /* Do not proceed if marked with an error */ if (Getattr(n, "error")) return SWIG_OK; /* Look for warnings */ String *wrn = Getattr(n, "feature:warnfilter"); if (wrn) Swig_warnfilter(wrn, 1); /* ============================================================ * C/C++ parsing * ============================================================ */ if (strcmp(tag, "extern") == 0) { ret = externDeclaration(n); } else if (strcmp(tag, "cdecl") == 0) { ret = cDeclaration(n); } else if (strcmp(tag, "enum") == 0) { ret = enumDeclaration(n); } else if (strcmp(tag, "enumitem") == 0) { ret = enumvalueDeclaration(n); } else if (strcmp(tag, "enumforward") == 0) { ret = enumforwardDeclaration(n); } else if (strcmp(tag, "class") == 0) { ret = classDeclaration(n); } else if (strcmp(tag, "classforward") == 0) { ret = classforwardDeclaration(n); } else if (strcmp(tag, "constructor") == 0) { ret = constructorDeclaration(n); } else if (strcmp(tag, "destructor") == 0) { ret = destructorDeclaration(n); } else if (strcmp(tag, "access") == 0) { ret = accessDeclaration(n); } else if (strcmp(tag, "using") == 0) { ret = usingDeclaration(n); } else if (strcmp(tag, "namespace") == 0) { ret = namespaceDeclaration(n); } else if (strcmp(tag, "template") == 0) { ret = templateDeclaration(n); } else if (strcmp(tag, "lambda") == 0) { ret = lambdaDeclaration(n); } /* =============================================================== * SWIG directives * =============================================================== */ else if (strcmp(tag, "top") == 0) { ret = top(n); } else if (strcmp(tag, "extend") == 0) { ret = extendDirective(n); } else if (strcmp(tag, "apply") == 0) { ret = applyDirective(n); } else if (strcmp(tag, "clear") == 0) { ret = clearDirective(n); } else if (strcmp(tag, "constant") == 0) { ret = constantDirective(n); } else if (strcmp(tag, "fragment") == 0) { ret = fragmentDirective(n); } else if (strcmp(tag, "import") == 0) { ret = importDirective(n); } else if (strcmp(tag, "include") == 0) { ret = includeDirective(n); } else if (strcmp(tag, "insert") == 0) { ret = insertDirective(n); } else if (strcmp(tag, "module") == 0) { ret = moduleDirective(n); } else if (strcmp(tag, "native") == 0) { ret = nativeDirective(n); } else if (strcmp(tag, "pragma") == 0) { ret = pragmaDirective(n); } else if (strcmp(tag, "typemap") == 0) { ret = typemapDirective(n); } else if (strcmp(tag, "typemapcopy") == 0) { ret = typemapcopyDirective(n); } else if (strcmp(tag, "typemapitem") == 0) { ret = typemapitemDirective(n); } else if (strcmp(tag, "types") == 0) { ret = typesDirective(n); } else { Swig_error(input_file, line_number, "Unrecognized parse tree node type '%s'\n", tag); ret = SWIG_ERROR; } if (wrn) Swig_warnfilter(wrn, 0); return ret; } /* ---------------------------------------------------------------------- * Dispatcher::emit_children() * * Emit all children that match the given type. type = 0 means all types. * ---------------------------------------------------------------------- */ int Dispatcher::emit_children(Node *n) { Node *c; char *eo = Char(Getattr(n, "feature:emitonlychildren")); for (c = firstChild(n); c; c = nextSibling(c)) { if (eo) { const char *tag = Char(nodeType(c)); if (strcmp(tag, "cdecl") == 0) { if (checkAttribute(c, "storage", "typedef")) tag = "typedef"; } if (strstr(eo, tag) == 0) { continue; } } emit_one(c); } return SWIG_OK; } /* Stubs for dispatcher class. We don't do anything by default---up to derived class to fill in traversal code */ int Dispatcher::defaultHandler(Node *) { return SWIG_OK; } int Dispatcher::extendDirective(Node *n) { return defaultHandler(n); } int Dispatcher::applyDirective(Node *n) { return defaultHandler(n); } int Dispatcher::clearDirective(Node *n) { return defaultHandler(n); } int Dispatcher::constantDirective(Node *n) { return defaultHandler(n); } int Dispatcher::fragmentDirective(Node *n) { return defaultHandler(n); } int Dispatcher::importDirective(Node *n) { return defaultHandler(n); } int Dispatcher::includeDirective(Node *n) { return defaultHandler(n); } int Dispatcher::insertDirective(Node *n) { return defaultHandler(n); } int Dispatcher::moduleDirective(Node *n) { return defaultHandler(n); } int Dispatcher::nativeDirective(Node *n) { return defaultHandler(n); } int Dispatcher::pragmaDirective(Node *n) { return defaultHandler(n); } int Dispatcher::typemapDirective(Node *n) { return defaultHandler(n); } int Dispatcher::typemapitemDirective(Node *n) { return defaultHandler(n); } int Dispatcher::typemapcopyDirective(Node *n) { return defaultHandler(n); } int Dispatcher::typesDirective(Node *n) { return defaultHandler(n); } int Dispatcher::cDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::externDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::enumDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::enumvalueDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::enumforwardDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::classDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::templateDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::lambdaDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::classforwardDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::constructorDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::destructorDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::accessDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::usingDeclaration(Node *n) { return defaultHandler(n); } int Dispatcher::namespaceDeclaration(Node *n) { return defaultHandler(n); } /* Allocators */ Language::Language(): none_comparison(NewString("$arg != 0")), director_ctor_code(NewString("")), director_prot_ctor_code(0), symtabs(NewHash()), classtypes(NewHash()), enumtypes(NewHash()), overloading(0), multiinput(0), cplus_runtime(0), directors(0) { symbolAddScope(""); // create top level/global symbol table scope argc_template_string = NewString("argc"); argv_template_string = NewString("argv[%d]"); /* Default director constructor code, passed to Swig_ConstructorToFunction */ Printv(director_ctor_code, "if ( $comparison ) { /* subclassed */\n", " $director_new \n", "} else {\n", " $nondirector_new \n", "}\n", NIL); /* Default director 'protected' constructor code, disabled by default. Each language that needs it, has to define it. */ director_prot_ctor_code = 0; director_multiple_inheritance = 1; director_language = 0; assert(!this_); this_ = this; } Language::~Language() { Delete(symtabs); Delete(classtypes); Delete(enumtypes); Delete(director_ctor_code); Delete(none_comparison); this_ = 0; } /* ----------------------------------------------------------------------------- * directorClassName() * ----------------------------------------------------------------------------- */ String *Language::directorClassName(Node *n) { String *dirclassname; String *nspace = NewString(Getattr(n, "sym:nspace")); const char *attrib = "director:classname"; String *classname = getClassPrefix(); Replace(nspace, NSPACE_SEPARATOR, "_", DOH_REPLACE_ANY); if (Len(nspace) > 0) dirclassname = NewStringf("SwigDirector_%s_%s", nspace, classname); else dirclassname = NewStringf("SwigDirector_%s", classname); Setattr(n, attrib, dirclassname); Delete(nspace); return dirclassname; } /* ---------------------------------------------------------------------- emit_one() ---------------------------------------------------------------------- */ int Language::emit_one(Node *n) { int ret; int oldext; if (!n) return SWIG_OK; if (GetFlag(n, "feature:ignore") && !Getattr(n, "feature:onlychildren")) return SWIG_OK; oldext = Extend; if (Getattr(n, "feature:extend")) Extend = 1; line_number = Getline(n); input_file = Getfile(n); /* symtab = Getattr(n,"symtab"); if (symtab) { symtab = Swig_symbol_setscope(symtab); } */ ret = Dispatcher::emit_one(n); /* if (symtab) { Swig_symbol_setscope(symtab); } */ Extend = oldext; return ret; } static Parm *nonvoid_parms(Parm *p) { if (p) { SwigType *t = Getattr(p, "type"); if (SwigType_type(t) == T_VOID) return 0; } return p; } /* ----------------------------------------------------------------------------- * cplus_value_type() * * Returns the alternative value type needed in C++ for class value * types. When swig is not sure about using a plain $ltype value, * since the class doesn't have a default constructor, or it can't be * assigned, you will get back 'SwigValueWrapper'. * * ----------------------------------------------------------------------------- */ SwigType *cplus_value_type(SwigType *t) { return SwigType_alttype(t, 0); } static Node *first_nontemplate(Node *n) { while (n) { if (Strcmp(nodeType(n), "template") != 0) return n; n = Getattr(n, "sym:nextSibling"); } return n; } /* -------------------------------------------------------------------------- * swig_pragma() * * Handle swig pragma directives. * -------------------------------------------------------------------------- */ void swig_pragma(char *lang, char *name, char *value) { if (strcmp(lang, "swig") == 0) { if ((strcmp(name, "make_default") == 0) || ((strcmp(name, "makedefault") == 0))) { GenerateDefault = 1; } else if ((strcmp(name, "no_default") == 0) || ((strcmp(name, "nodefault") == 0))) { Swig_warning(WARN_DEPRECATED_NODEFAULT, "SWIG", 1, "dangerous, use %%nodefaultctor, %%nodefaultdtor instead.\n"); GenerateDefault = 0; } else if (strcmp(name, "attributefunction") == 0) { String *nvalue = NewString(value); char *s = strchr(Char(nvalue), ':'); if (!s) { Swig_error(input_file, line_number, "Bad value for attributefunction. Expected \"fmtget:fmtset\".\n"); } else { *s = 0; AttributeFunctionGet = NewString(Char(nvalue)); AttributeFunctionSet = NewString(s + 1); } Delete(nvalue); } else if (strcmp(name, "noattributefunction") == 0) { AttributeFunctionGet = 0; AttributeFunctionSet = 0; } } } /* -------------------------------------------------------------------------- * Language::use_naturalvar_mode() * * Determine whether to use const ref typemaps instead of pointer typemaps * for variable access. * -------------------------------------------------------------------------- */ int Language::use_naturalvar_mode(Node *n) const { if (Getattr(n, "unnamed")) return 0; // The naturalvar feature can be attached to either the variable name or the variable's type // naturalvar on the variable name is more specific and overrides naturalvar on the variable's type String *naturalvar = Getattr(n, "feature:naturalvar"); bool explicitly_off = naturalvar && Strcmp(naturalvar, "0") == 0; int nvar = GetFlag(n, "feature:naturalvar"); if (!explicitly_off && !nvar) { /* look for feature in the class */ SwigType *ty = Getattr(n, "type"); SwigType *fullty = SwigType_typedef_resolve_all(ty); if (SwigType_isclass(fullty)) { SwigType *tys = SwigType_strip_qualifiers(fullty); if (!CPlusPlus) { Replaceall(tys, "struct ", ""); Replaceall(tys, "union ", ""); Replaceall(tys, "class ", ""); } Node *typenode = Swig_symbol_clookup(tys, 0); if (typenode) { naturalvar = Getattr(typenode, "feature:naturalvar"); explicitly_off = naturalvar && Strcmp(naturalvar, "0") == 0; nvar = nvar || GetFlag(typenode, "feature:naturalvar"); } Delete(tys); } Delete(fullty); } nvar = nvar || naturalvar_mode; return explicitly_off ? 0 : nvar ? CWRAP_NATURAL_VAR : 0; } /* ---------------------------------------------------------------------- * Language::top() - Top of parsing tree * ---------------------------------------------------------------------- */ int Language::top(Node *n) { Node *mod = Getattr(n, "module"); if (mod) { Node *options = Getattr(mod, "options"); if (options) { if (Getattr(options, "naturalvar")) { naturalvar_mode = 1; } } } classhash = Getattr(n, "classes"); return emit_children(n); } /* ---------------------------------------------------------------------- * Language::extendDirective() * ---------------------------------------------------------------------- */ int Language::extendDirective(Node *n) { save_value oldam(Extend, CWRAP_EXTEND); save_value oldmode(cplus_mode, PUBLIC); emit_children(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::applyDirective() * ---------------------------------------------------------------------- */ int Language::applyDirective(Node *n) { Parm *pattern = Getattr(n, "pattern"); Node *c = firstChild(n); while (c) { Parm *apattern = Getattr(c, "pattern"); if (ParmList_len(pattern) != ParmList_len(apattern)) { Swig_error(input_file, line_number, "Can't apply (%s) to (%s). Number of arguments don't match.\n", ParmList_str(pattern), ParmList_str(apattern)); } else { if (!Swig_typemap_apply(pattern, apattern)) { Swig_warning(WARN_TYPEMAP_APPLY_UNDEF, input_file, line_number, "Can't apply (%s). No typemaps are defined.\n", ParmList_str(pattern)); } } c = nextSibling(c); } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::clearDirective() * ---------------------------------------------------------------------- */ int Language::clearDirective(Node *n) { Node *p; for (p = firstChild(n); p; p = nextSibling(p)) { ParmList *pattern = Getattr(p, "pattern"); Swig_typemap_clear_apply(pattern); } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::constantDirective() * ---------------------------------------------------------------------- */ int Language::constantDirective(Node *n) { if (CurrentClass && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; if (!GetFlag(n, "feature:allowexcept")) { UnsetFlag(n, "feature:except"); } if (Getattr(n, "feature:exceptvar")) { Setattr(n, "feature:except", Getattr(n, "feature:exceptvar")); } if (!ImportMode) { Swig_require("constantDirective", n, "name", "?value", NIL); String *name = Getattr(n, "name"); String *value = Getattr(n, "value"); if (!value) { value = Copy(name); } else { /* if (checkAttribute(n,"type","char")) { value = NewString(value); } else { value = NewStringf("%(escape)s", value); } */ Setattr(n, "rawvalue", value); value = NewStringf("%(escape)s", value); if (!Len(value)) Append(value, "\\0"); /* Printf(stdout,"'%s' = '%s'\n", name, value); */ } Setattr(n, "value", value); this->constantWrapper(n); Swig_restore(n); return SWIG_OK; } return SWIG_NOWRAP; } /* ---------------------------------------------------------------------- * Language::fragmentDirective() * ---------------------------------------------------------------------- */ int Language::fragmentDirective(Node *n) { Swig_fragment_register(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::importDirective() * ---------------------------------------------------------------------- */ int Language::importDirective(Node *n) { int oldim = ImportMode; ImportMode = IMPORT_MODE; emit_children(n); ImportMode = oldim; return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::includeDirective() * ---------------------------------------------------------------------- */ int Language::includeDirective(Node *n) { emit_children(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::insertDirective() * ---------------------------------------------------------------------- */ int Language::insertDirective(Node *n) { /* %insert directive */ if ((!ImportMode) || Getattr(n, "generated")) { String *code = Getattr(n, "code"); String *section = Getattr(n, "section"); File *f = 0; if (!section) { /* %{ ... %} */ f = Swig_filebyname("header"); } else { f = Swig_filebyname(section); } if (f) { Printf(f, "%s\n", code); } else { Swig_error(input_file, line_number, "Unknown target '%s' for %%insert directive.\n", section); } return SWIG_OK; } else { return SWIG_NOWRAP; } } /* ---------------------------------------------------------------------- * Language::moduleDirective() * ---------------------------------------------------------------------- */ int Language::moduleDirective(Node *n) { (void) n; /* %module directive */ return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::nativeDirective() * ---------------------------------------------------------------------- */ int Language::nativeDirective(Node *n) { if (!ImportMode) { return nativeWrapper(n); } else { return SWIG_NOWRAP; } } /* ---------------------------------------------------------------------- * Language::pragmaDirective() * ---------------------------------------------------------------------- */ int Language::pragmaDirective(Node *n) { /* %pragma directive */ if (!ImportMode) { String *lan = Getattr(n, "lang"); String *name = Getattr(n, "name"); String *value = Getattr(n, "value"); swig_pragma(Char(lan), Char(name), Char(value)); /* pragma(Char(lan),Char(name),Char(value)); */ return SWIG_OK; } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::typemapDirective() * ---------------------------------------------------------------------- */ int Language::typemapDirective(Node *n) { /* %typemap directive */ String *method = Getattr(n, "method"); String *code = Getattr(n, "code"); Parm *kwargs = Getattr(n, "kwargs"); Node *items = firstChild(n); static int namewarn = 0; if (code && (Strstr(code, "$source") || (Strstr(code, "$target")))) { Swig_warning(WARN_TYPEMAP_SOURCETARGET, Getfile(n), Getline(n), "Deprecated typemap feature ($source/$target).\n"); if (!namewarn) { Swig_warning(WARN_TYPEMAP_SOURCETARGET, Getfile(n), Getline(n), "The use of $source and $target in a typemap declaration is deprecated.\n\ For typemaps related to argument input (in,ignore,default,arginit,check), replace\n\ $source by $input and $target by $1. For typemaps related to return values (out,\n\ argout,ret,except), replace $source by $1 and $target by $result. See the file\n\ Doc/Manual/Typemaps.html for complete details.\n"); namewarn = 1; } } if (Strcmp(method, "except") == 0) { Swig_warning(WARN_DEPRECATED_EXCEPT_TM, Getfile(n), Getline(n), "%%typemap(except) is deprecated. Use the %%exception directive.\n"); } if (Strcmp(method, "in") == 0) { Hash *k; k = kwargs; while (k) { if (checkAttribute(k, "name", "numinputs")) { if (!multiinput && (GetInt(k, "value") > 1)) { Swig_error(Getfile(n), Getline(n), "Multiple-input typemaps (numinputs > 1) not supported by this target language module.\n"); return SWIG_ERROR; } break; } k = nextSibling(k); } if (!k) { k = NewHash(); Setattr(k, "name", "numinputs"); Setattr(k, "value", "1"); set_nextSibling(k, kwargs); Setattr(n, "kwargs", k); kwargs = k; } } if (Strcmp(method, "ignore") == 0) { Swig_warning(WARN_DEPRECATED_IGNORE_TM, Getfile(n), Getline(n), "%%typemap(ignore) has been replaced by %%typemap(in,numinputs=0).\n"); Clear(method); Append(method, "in"); Hash *k = NewHash(); Setattr(k, "name", "numinputs"); Setattr(k, "value", "0"); set_nextSibling(k, kwargs); Setattr(n, "kwargs", k); kwargs = k; } /* Replace $descriptor() macros */ if (code) { Setfile(code, Getfile(n)); Setline(code, Getline(n)); Swig_cparse_replace_descriptor(code); } while (items) { Parm *pattern = Getattr(items, "pattern"); Parm *parms = Getattr(items, "parms"); if (code) { Swig_typemap_register(method, pattern, code, parms, kwargs); } else { Swig_typemap_clear(method, pattern); } items = nextSibling(items); } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::typemapcopyDirective() * ---------------------------------------------------------------------- */ int Language::typemapcopyDirective(Node *n) { String *method = Getattr(n, "method"); Parm *pattern = Getattr(n, "pattern"); Node *items = firstChild(n); int nsrc = 0; nsrc = ParmList_len(pattern); while (items) { ParmList *npattern = Getattr(items, "pattern"); if (nsrc != ParmList_len(npattern)) { Swig_error(input_file, line_number, "Can't copy typemap. Number of types differ.\n"); } else { if (Swig_typemap_copy(method, pattern, npattern) < 0) { Swig_error(input_file, line_number, "Can't copy typemap (%s) %s = %s\n", method, ParmList_str(pattern), ParmList_str(npattern)); } } items = nextSibling(items); } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::typesDirective() * ---------------------------------------------------------------------- */ int Language::typesDirective(Node *n) { Parm *parms = Getattr(n, "parms"); String *convcode = Getattr(n, "convcode"); /* optional user supplied conversion code for custom casting */ while (parms) { SwigType *t = Getattr(parms, "type"); String *v = Getattr(parms, "value"); if (!v) { SwigType_remember(t); } else { if (SwigType_issimple(t)) { SwigType_inherit(t, v, 0, convcode); } } parms = nextSibling(parms); } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::cDeclaration() * ---------------------------------------------------------------------- */ int Language::cDeclaration(Node *n) { String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); SwigType *decl = Getattr(n, "decl"); String *storage = Getattr(n, "storage"); Node *over; File *f_header = 0; SwigType *ty, *fullty; if (Getattr(n, "feature:onlychildren")) { if (GetFlag(n, "feature:ignore")) { return SWIG_NOWRAP; } else { // Found an unignored templated method that has an empty template instantiation (%template()) // Ignore it unless it has been %rename'd if (Strncmp(symname, "__dummy_", 8) == 0) { SetFlag(n, "feature:ignore"); Swig_warning(WARN_LANG_TEMPLATE_METHOD_IGNORE, input_file, line_number, "%%template() contains no name. Template method ignored: %s\n", Swig_name_decl(n)); return SWIG_NOWRAP; } } } /* discards nodes following the access control rules */ if (cplus_mode != PUBLIC || !is_public(n)) { /* except for friends, they are not affected by access control */ int isfriend = Cmp(storage, "friend") == 0; if (!isfriend) { /* Check what the director needs. If the method is pure virtual, it is always needed. * Also wrap non-virtual protected members if asked for (allprotected mode). */ if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || isNonVirtualProtectedAccess(n)))) { return SWIG_NOWRAP; } // Prevent wrapping protected overloaded director methods more than once - // This bit of code is only needed due to the cDeclaration call in classHandler() String *wrapname = NewStringf("nonpublic_%s%s", symname, Getattr(n, "sym:overname")); if (Getattr(CurrentClass, wrapname)) { Delete(wrapname); return SWIG_NOWRAP; } SetFlag(CurrentClass, wrapname); Delete(wrapname); } } if (Cmp(storage, "typedef") == 0) { Swig_save("cDeclaration", n, "type", NIL); SwigType *t = Copy(type); if (t) { SwigType_push(t, decl); Setattr(n, "type", t); typedefHandler(n); } Swig_restore(n); return SWIG_OK; } /* If in import mode, we proceed no further */ if (ImportMode) return SWIG_NOWRAP; /* If we're in extend mode and there is code, replace the $descriptor macros */ if (Extend) { String *code = Getattr(n, "code"); if (code) { Setfile(code, Getfile(n)); Setline(code, Getline(n)); Swig_cparse_replace_descriptor(code); } } /* Overloaded symbol check */ over = Swig_symbol_isoverloaded(n); if (!overloading) { if (over) over = first_nontemplate(over); if (over && (over != n)) { Swig_warning(WARN_LANG_OVERLOAD_DECL, input_file, line_number, "Overloaded declaration ignored. %s\n", Swig_name_decl(n)); Swig_warning(WARN_LANG_OVERLOAD_DECL, Getfile(over), Getline(over), "Previous declaration is %s\n", Swig_name_decl(over)); return SWIG_NOWRAP; } } if (!validIdentifier(symname)) { Swig_warning(WARN_LANG_IDENTIFIER, input_file, line_number, "Can't wrap '%s' unless renamed to a valid identifier.\n", symname); return SWIG_NOWRAP; } ty = NewString(type); SwigType_push(ty, decl); fullty = SwigType_typedef_resolve_all(ty); if (SwigType_isfunction(fullty)) { if (!SwigType_isfunction(ty)) { Delete(ty); ty = fullty; fullty = 0; ParmList *parms = SwigType_function_parms(ty, n); Setattr(n, "parms", parms); } /* Transform the node into a 'function' node and emit */ if (!CurrentClass) { f_header = Swig_filebyname("header"); if (AddExtern) { if (f_header) { if (Swig_storage_isextern(n) || (ForceExtern && !storage)) { /* we don't need the 'extern' part in the C/C++ declaration, and it produces some problems when namespace and SUN Studio is used. Printf(f_header,"extern %s", SwigType_str(ty,name)); In fact generating extern declarations is quite error prone and is no longer the default. Getting it right seems impossible with namespaces and default arguments and when a method is declared with the various Windows calling conventions - SWIG doesn't understand Windows (non standard) calling conventions in the first place, so can't regenerate them. */ String *str = SwigType_str(ty, name); Printf(f_header, "%s", str); Delete(str); { DOH *t = Getattr(n, "throws"); if (t) { Printf(f_header, " throw("); while (t) { Printf(f_header, "%s", Getattr(t, "type")); t = nextSibling(t); if (t) Printf(f_header, ","); } Printf(f_header, ")"); } } Printf(f_header, ";\n"); } else if (Swig_storage_isexternc(n)) { /* here 'extern "C"' is needed */ String *str = SwigType_str(ty, name); Printf(f_header, "extern \"C\" %s;\n", str); Delete(str); } } } } /* This needs to check qualifiers */ if (SwigType_isqualifier(ty)) { SwigType *qual = SwigType_pop(ty); Setattr(n, "qualifier", qual); Delete(qual); } Delete(SwigType_pop_function(ty)); DohIncref(type); Setattr(n, "type", ty); functionHandler(n); Setattr(n, "type", type); Delete(ty); Delete(type); return SWIG_OK; } else { /* Some kind of variable declaration */ String *declaration = Copy(decl); Delattr(n, "decl"); if (!CurrentClass) { if (Swig_storage_isextern(n) || ForceExtern) { if (AddExtern) { f_header = Swig_filebyname("header"); if (f_header) { String *str = SwigType_str(ty, name); Printf(f_header, "%s %s;\n", Getattr(n, "storage"), str); Delete(str); } } } } if (!SwigType_ismutable(ty)) { SetFlag(n, "feature:immutable"); } /* If an array and elements are const, then read-only */ if (SwigType_isarray(ty)) { SwigType *tya = SwigType_array_type(ty); if (SwigType_isconst(tya)) { SetFlag(n, "feature:immutable"); } Delete(tya); } DohIncref(type); Setattr(n, "type", ty); variableHandler(n); Setattr(n, "type", type); Setattr(n, "decl", declaration); Delete(ty); Delete(type); Delete(fullty); return SWIG_OK; } } /* ---------------------------------------------------------------------- * Language::functionHandler() * ---------------------------------------------------------------------- */ int Language::functionHandler(Node *n) { String *storage = Getattr(n, "storage"); int isfriend = CurrentClass && Cmp(storage, "friend") == 0; int isstatic = CurrentClass && Swig_storage_isstatic(n) && !(SmartPointer && Getattr(n, "allocate:smartpointeraccess")); Parm *p = Getattr(n, "parms"); if (GetFlag(n, "feature:del")) { /* the method acts like a delete operator, ie, we need to disown the parameter */ if (CurrentClass && !isstatic && !isfriend) { SetFlag(n, "feature:self:disown"); } else { if (p) SetFlag(p, "wrap:disown"); } } if (!CurrentClass) { globalfunctionHandler(n); } else { if (isstatic) { staticmemberfunctionHandler(n); } else if (isfriend) { int oldInClass = InClass; InClass = 0; globalfunctionHandler(n); InClass = oldInClass; } else { Node *explicit_n = 0; if (directorsEnabled() && is_member_director(CurrentClass, n) && !extraDirectorProtectedCPPMethodsRequired()) { bool virtual_but_not_pure_virtual = (!(Cmp(storage, "virtual")) && (Cmp(Getattr(n, "value"), "0") != 0)); if (virtual_but_not_pure_virtual) { // Add additional wrapper which makes an explicit call to the virtual method (ie not a virtual call) explicit_n = Copy(n); String *new_symname = Copy(Getattr(n, "sym:name")); String *suffix = Getattr(parentNode(n), "sym:name"); Printv(new_symname, "SwigExplicit", suffix, NIL); Setattr(explicit_n, "sym:name", new_symname); Delattr(explicit_n, "storage"); Delattr(explicit_n, "override"); Delattr(explicit_n, "hides"); SetFlag(explicit_n, "explicitcall"); Setattr(n, "explicitcallnode", explicit_n); } } memberfunctionHandler(n); if (explicit_n) { memberfunctionHandler(explicit_n); Delattr(explicit_n, "explicitcall"); Delete(explicit_n); } } } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::globalfunctionHandler() * ---------------------------------------------------------------------- */ int Language::globalfunctionHandler(Node *n) { Swig_require("globalfunctionHandler", n, "name", "sym:name", "type", "?parms", NIL); String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); ParmList *parms = Getattr(n, "parms"); /* Check for callback mode */ String *cb = GetFlagAttr(n, "feature:callback"); if (cb) { String *cbname = Getattr(n, "feature:callback:name"); if (!cbname) { cbname = NewStringf(cb, symname); Setattr(n, "feature:callback:name", cbname); } callbackfunctionHandler(n); if (Cmp(cbname, symname) == 0) { Delete(cbname); Swig_restore(n); return SWIG_NOWRAP; } Delete(cbname); } Setattr(n, "parms", nonvoid_parms(parms)); String *call = Swig_cfunction_call(name, parms); String *cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); functionWrapper(n); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::callbackfunctionHandler() * ---------------------------------------------------------------------- */ int Language::callbackfunctionHandler(Node *n) { Swig_require("callbackfunctionHandler", n, "name", "*sym:name", "*type", "?value", NIL); String *type = Getattr(n, "type"); String *name = Getattr(n, "name"); String *parms = Getattr(n, "parms"); String *cbname = Getattr(n, "feature:callback:name"); String *calltype = NewStringf("(%s (*)(%s))(%s)", SwigType_str(type, 0), ParmList_str(parms), SwigType_namestr(name)); SwigType *cbty = Copy(type); SwigType_add_function(cbty, parms); SwigType_add_pointer(cbty); Setattr(n, "sym:name", cbname); Setattr(n, "type", cbty); Setattr(n, "value", calltype); Node *ns = symbolLookup(cbname); if (!ns) constantWrapper(n); Delete(cbty); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::memberfunctionHandler() * ---------------------------------------------------------------------- */ int Language::memberfunctionHandler(Node *n) { Swig_require("memberfunctionHandler", n, "*name", "*sym:name", "*type", "?parms", "?value", NIL); String *storage = Getattr(n, "storage"); String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *value = Getattr(n, "value"); ParmList *parms = Getattr(n, "parms"); String *cb = GetFlagAttr(n, "feature:callback"); if (Cmp(storage, "virtual") == 0) { if (Cmp(value, "0") == 0) { IsVirtual = PURE_VIRTUAL; } else { IsVirtual = PLAIN_VIRTUAL; } } else { IsVirtual = 0; } if (cb) { Node *cbn = NewHash(); String *cbname = Getattr(n, "feature:callback:name"); if (!cbname) { cbname = NewStringf(cb, symname); } SwigType *cbty = Copy(type); SwigType_add_function(cbty, parms); SwigType_add_memberpointer(cbty, ClassName); String *cbvalue = NewStringf("&%s::%s", ClassName, name); Setattr(cbn, "sym:name", cbname); Setattr(cbn, "type", cbty); Setattr(cbn, "value", cbvalue); Setattr(cbn, "name", name); Setfile(cbn, Getfile(n)); Setline(cbn, Getline(n)); memberconstantHandler(cbn); Setattr(n, "feature:callback:name", Swig_name_member(NSpace, ClassPrefix, cbname)); Delete(cb); Delete(cbn); Delete(cbvalue); Delete(cbty); Delete(cbname); if (Cmp(cbname, symname) == 0) { Swig_restore(n); return SWIG_NOWRAP; } } String *fname = Swig_name_member(NSpace, ClassPrefix, symname); if (Extend && SmartPointer) { if (!Getattr(n, "extendsmartclassname")) { Setattr(n, "extendsmartclassname", Getattr(CurrentClass, "allocate:smartpointerpointeeclassname")); } } // Set up the type for the cast to this class for use when wrapping const director (virtual) methods. // Note: protected director methods or when allprotected mode turned on. String *director_type = 0; if (!is_public(n) && (is_member_director(CurrentClass, n) || GetFlag(n, "explicitcall") || isNonVirtualProtectedAccess(n))) { director_type = Copy(DirectorClassName); String *qualifier = Getattr(n, "qualifier"); if (qualifier) SwigType_push(director_type, qualifier); SwigType_add_pointer(director_type); } int DirectorExtraCall = 0; if (directorsEnabled() && is_member_director(CurrentClass, n) && !SmartPointer) if (extraDirectorProtectedCPPMethodsRequired()) DirectorExtraCall = CWRAP_DIRECTOR_TWO_CALLS; if (GetFlag(n, "explicitcall")) DirectorExtraCall = CWRAP_DIRECTOR_ONE_CALL; Swig_MethodToFunction(n, NSpace, ClassType, Getattr(n, "template") ? SmartPointer : Extend | SmartPointer | DirectorExtraCall, director_type, is_member_director(CurrentClass, n)); Setattr(n, "sym:name", fname); functionWrapper(n); Delete(director_type); Delete(fname); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::staticmemberfunctionHandler() * ---------------------------------------------------------------------- */ int Language::staticmemberfunctionHandler(Node *n) { Swig_require("staticmemberfunctionHandler", n, "*name", "*sym:name", "*type", NIL); Swig_save("staticmemberfunctionHandler", n, "storage", NIL); String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); ParmList *parms = Getattr(n, "parms"); String *cb = GetFlagAttr(n, "feature:callback"); String *cname, *mrename; if (!Extend) { Node *sb = Getattr(n, "cplus:staticbase"); String *sname = Getattr(sb, "name"); if (isNonVirtualProtectedAccess(n)) cname = NewStringf("%s::%s", DirectorClassName, name); else cname = NewStringf("%s::%s", sname, name); } else { String *mname = Swig_name_mangle(ClassName); cname = Swig_name_member(NSpace, mname, name); Delete(mname); } mrename = Swig_name_member(NSpace, ClassPrefix, symname); if (Extend) { String *code = Getattr(n, "code"); String *defaultargs = Getattr(n, "defaultargs"); String *mangled = Swig_name_mangle(mrename); Delete(mrename); mrename = mangled; if (Getattr(n, "sym:overloaded") && code) { Append(cname, Getattr(defaultargs ? defaultargs : n, "sym:overname")); } if (!defaultargs && code) { /* Hmmm. An added static member. We have to create a little wrapper for this */ Swig_add_extension_code(n, cname, parms, type, code, CPlusPlus, 0); } } Setattr(n, "name", cname); Setattr(n, "sym:name", mrename); if (cb) { String *cbname = NewStringf(cb, symname); Setattr(n, "feature:callback:name", Swig_name_member(NSpace, ClassPrefix, cbname)); Setattr(n, "feature:callback:staticname", name); } Delattr(n, "storage"); globalfunctionHandler(n); Delete(cname); Delete(mrename); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::variableHandler() * ---------------------------------------------------------------------- */ int Language::variableHandler(Node *n) { /* If not a smart-pointer access or added method. We clear feature:except. There is no way C++ or C would throw an exception merely for accessing a member data. Caveat: Some compilers seem to route attribute access through methods which can generate exceptions. The feature:allowexcept allows this. Also, the feature:exceptvar can be used to match only variables. */ if (!(Extend | SmartPointer)) { if (!GetFlag(n, "feature:allowexcept")) { UnsetFlag(n, "feature:except"); } if (Getattr(n, "feature:exceptvar")) { Setattr(n, "feature:except", Getattr(n, "feature:exceptvar")); } } if (!CurrentClass) { globalvariableHandler(n); } else { Swig_save("variableHandler", n, "feature:immutable", NIL); if (SmartPointer) { /* If a smart-pointer and it's a constant access, we have to set immutable */ if (!Getattr(CurrentClass, "allocate:smartpointermutable")) { SetFlag(n, "feature:immutable"); } } if (Swig_storage_isstatic(n) && !(SmartPointer && Getattr(n, "allocate:smartpointeraccess"))) { staticmembervariableHandler(n); } else { membervariableHandler(n); } Swig_restore(n); } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::globalvariableHandler() * ---------------------------------------------------------------------- */ int Language::globalvariableHandler(Node *n) { variableWrapper(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::membervariableHandler() * ---------------------------------------------------------------------- */ int Language::membervariableHandler(Node *n) { Swig_require("membervariableHandler", n, "*name", "*sym:name", "*type", NIL); Swig_save("membervariableHandler", n, "parms", NIL); String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); if (!AttributeFunctionGet) { String *mname = Swig_name_member(0, ClassPrefix, symname); String *mrename_get = Swig_name_get(NSpace, mname); String *mrename_set = Swig_name_set(NSpace, mname); Delete(mname); /* Create a function to set the value of the variable */ int assignable = is_assignable(n); if (SmartPointer) { if (!Getattr(CurrentClass, "allocate:smartpointermutable")) { assignable = 0; } } if (assignable) { int make_set_wrapper = 1; String *tm = 0; String *target = 0; if (!Extend) { if (SmartPointer) { if (Swig_storage_isstatic(n)) { Node *sn = Getattr(n, "cplus:staticbase"); String *base = Getattr(sn, "name"); target = NewStringf("%s::%s", base, name); } else { String *pname = Swig_cparm_name(0, 0); target = NewStringf("(*%s)->%s", pname, name); Delete(pname); } } else { String *pname = isNonVirtualProtectedAccess(n) ? NewString("darg") : Swig_cparm_name(0, 0); target = NewStringf("%s->%s", pname, name); Delete(pname); } // This is an input type typemap lookup and so it should not use Node n // otherwise qualification is done on the parameter name for the setter function Parm *nin = NewParm(type, name, n); tm = Swig_typemap_lookup("memberin", nin, target, 0); Delete(nin); } int flags = Extend | SmartPointer | use_naturalvar_mode(n); if (isNonVirtualProtectedAccess(n)) flags = flags | CWRAP_ALL_PROTECTED_ACCESS; Swig_MembersetToFunction(n, ClassType, flags); Setattr(n, "memberset", "1"); if (!Extend) { /* Check for a member in typemap here */ if (!tm) { if (SwigType_isarray(type)) { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0)); make_set_wrapper = 0; } } else { String *pname0 = Swig_cparm_name(0, 0); String *pname1 = Swig_cparm_name(0, 1); Replace(tm, "$source", pname1, DOH_REPLACE_ANY); Replace(tm, "$target", target, DOH_REPLACE_ANY); Replace(tm, "$input", pname1, DOH_REPLACE_ANY); Replace(tm, "$self", pname0, DOH_REPLACE_ANY); Setattr(n, "wrap:action", tm); Delete(tm); Delete(pname0); Delete(pname1); } Delete(target); } if (make_set_wrapper) { Setattr(n, "sym:name", mrename_set); functionWrapper(n); } else { SetFlag(n, "feature:immutable"); } /* Restore parameters */ Setattr(n, "type", type); Setattr(n, "name", name); Setattr(n, "sym:name", symname); Delattr(n, "memberset"); /* Delete all attached typemaps and typemap attributes */ Iterator ki; for (ki = First(n); ki.key; ki = Next(ki)) { if (Strncmp(ki.key, "tmap:", 5) == 0) Delattr(n, ki.key); } } /* Emit get function */ { int flags = Extend | SmartPointer | use_naturalvar_mode(n); if (isNonVirtualProtectedAccess(n)) flags = flags | CWRAP_ALL_PROTECTED_ACCESS; Swig_MembergetToFunction(n, ClassType, flags); Setattr(n, "sym:name", mrename_get); Setattr(n, "memberget", "1"); functionWrapper(n); Delattr(n, "memberget"); } Delete(mrename_get); Delete(mrename_set); } else { /* This code is used to support the attributefunction directive where member variables are converted automagically to accessor functions */ #if 0 Parm *p; String *gname; SwigType *vty; p = NewParm(type, 0, n); gname = NewStringf(AttributeFunctionGet, symname); if (!Extend) { ActionFunc = Copy(Swig_cmemberget_call(name, type)); cpp_member_func(Char(gname), Char(gname), type, 0); Delete(ActionFunc); } else { String *cname = Swig_name_get(NSpace, name); cpp_member_func(Char(cname), Char(gname), type, 0); Delete(cname); } Delete(gname); if (!GetFlag(n, "feature:immutable")) { gname = NewStringf(AttributeFunctionSet, symname); vty = NewString("void"); if (!Extend) { ActionFunc = Copy(Swig_cmemberset_call(name, type)); cpp_member_func(Char(gname), Char(gname), vty, p); Delete(ActionFunc); } else { String *cname = Swig_name_set(NSpace, name); cpp_member_func(Char(cname), Char(gname), vty, p); Delete(cname); } Delete(gname); } ActionFunc = 0; #endif } Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::staticmembervariableHandler() * ---------------------------------------------------------------------- */ int Language::staticmembervariableHandler(Node *n) { Swig_require("staticmembervariableHandler", n, "*name", "*sym:name", "*type", "?value", NIL); String *value = Getattr(n, "value"); String *classname = !SmartPointer ? (isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName) : Getattr(CurrentClass, "allocate:smartpointerpointeeclassname"); if (!value || !Getattr(n, "hasconsttype")) { String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); String *cname, *mrename; /* Create the variable name */ mrename = Swig_name_member(0, ClassPrefix, symname); cname = NewStringf("%s::%s", classname, name); Setattr(n, "sym:name", mrename); Setattr(n, "name", cname); /* Wrap as an ordinary global variable */ variableWrapper(n); Delete(mrename); Delete(cname); } else { /* This is a C++ static member declaration with an initializer and it's const. Certain C++ compilers optimize this out so that there is no linkage to a memory address. Example: class Foo { public: static const int x = 3; }; Some discussion of this in section 9.4 of the C++ draft standard. Also, we have to manage the case: class Foo { public: %extend { static const int x = 3; } }; in which there's no actual Foo::x variable to refer to. In this case, the best we can do is to wrap the given value verbatim. */ String *name = Getattr(n, "name"); String *cname = NewStringf("%s::%s", classname, name); if (Extend) { /* the variable is a synthesized one. There's nothing we can do; we just keep the given value */ } else { /* we refer to the value as Foo::x */ String *value = SwigType_namestr(cname); Setattr(n, "value", value); } SwigType *t1 = SwigType_typedef_resolve_all(Getattr(n, "type")); SwigType *t2 = SwigType_strip_qualifiers(t1); Setattr(n, "type", t2); Delete(t1); Delete(t2); SetFlag(n, "wrappedasconstant"); memberconstantHandler(n); Delete(cname); } Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::externDeclaration() * ---------------------------------------------------------------------- */ int Language::externDeclaration(Node *n) { return emit_children(n); } /* ---------------------------------------------------------------------- * Language::enumDeclaration() * ---------------------------------------------------------------------- */ int Language::enumDeclaration(Node *n) { String *oldNSpace = NSpace; NSpace = Getattr(n, "sym:nspace"); if (!ImportMode) { emit_children(n); } NSpace = oldNSpace; return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::enumvalueDeclaration() * ---------------------------------------------------------------------- */ int Language::enumvalueDeclaration(Node *n) { if (CurrentClass && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL); String *value = Getattr(n, "value"); String *name = Getattr(n, "name"); String *tmpValue; if (value) tmpValue = NewString(value); else tmpValue = NewString(name); Setattr(n, "value", tmpValue); if (!CurrentClass || !cparse_cplusplus) { Setattr(n, "name", tmpValue); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); } else { memberconstantHandler(n); } Delete(tmpValue); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::enumforwardDeclaration() * ---------------------------------------------------------------------- */ int Language::enumforwardDeclaration(Node *n) { (void) n; if (GetFlag(n, "enumMissing")) enumDeclaration(n); // Generate an empty enum in target language return SWIG_OK; } /* ----------------------------------------------------------------------------- * Language::memberconstantHandler() * ----------------------------------------------------------------------------- */ int Language::memberconstantHandler(Node *n) { Swig_require("memberconstantHandler", n, "*name", "*sym:name", "value", NIL); if (!GetFlag(n, "feature:allowexcept")) { UnsetFlag(n, "feature:except"); } if (Getattr(n, "feature:exceptvar")) { Setattr(n, "feature:except", Getattr(n, "feature:exceptvar")); } String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); String *value = Getattr(n, "value"); String *mrename = Swig_name_member(0, ClassPrefix, symname); Setattr(n, "sym:name", mrename); String *new_name = 0; if (Extend) new_name = Copy(value); else new_name = NewStringf("%s::%s", isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName, name); Setattr(n, "name", new_name); constantWrapper(n); Delete(mrename); Delete(new_name); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::typedefHandler() * ---------------------------------------------------------------------- */ int Language::typedefHandler(Node *n) { /* since this is a recurring issue, we are going to remember the typedef pointer, if already it is not a pointer or reference, as in typedef void NT; int func(NT *p); see director_basic.i for example. */ SwigType *name = Getattr(n, "name"); SwigType *decl = Getattr(n, "decl"); if (!SwigType_ispointer(decl) && !SwigType_isreference(decl)) { SwigType *pname = Copy(name); SwigType_add_pointer(pname); SwigType_remember(pname); Delete(pname); } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirectorMethod() * ---------------------------------------------------------------------- */ int Language::classDirectorMethod(Node *n, Node *parent, String *super) { (void) n; (void) parent; (void) super; return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirectorConstructor() * ---------------------------------------------------------------------- */ int Language::classDirectorConstructor(Node *n) { (void) n; return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirectorDefaultConstructor() * ---------------------------------------------------------------------- */ int Language::classDirectorDefaultConstructor(Node *n) { (void) n; return SWIG_OK; } static String *vtable_method_id(Node *n) { String *nodeType = Getattr(n, "nodeType"); int is_destructor = (Cmp(nodeType, "destructor") == 0); if (is_destructor) return 0; String *name = Getattr(n, "name"); String *decl = Getattr(n, "decl"); String *local_decl = SwigType_typedef_resolve_all(decl); String *tmp = SwigType_pop_function(local_decl); Delete(local_decl); local_decl = tmp; Node *method_id = NewStringf("%s|%s", name, local_decl); Delete(local_decl); return method_id; } /* ---------------------------------------------------------------------- * Language::unrollVirtualMethods() * ---------------------------------------------------------------------- */ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_director, int &virtual_destructor, int protectedbase) { Node *ni; String *nodeType; String *classname; String *decl; bool first_base = false; // recurse through all base classes to build the vtable List *bl = Getattr(n, "bases"); if (bl) { Iterator bi; for (bi = First(bl); bi.item; bi = Next(bi)) { if (first_base && !director_multiple_inheritance) break; unrollVirtualMethods(bi.item, parent, vm, default_director, virtual_destructor); first_base = true; } } // recurse through all protected base classes to build the vtable, as needed bl = Getattr(n, "protectedbases"); if (bl) { Iterator bi; for (bi = First(bl); bi.item; bi = Next(bi)) { if (first_base && !director_multiple_inheritance) break; unrollVirtualMethods(bi.item, parent, vm, default_director, virtual_destructor, 1); first_base = true; } } // find the methods that need directors classname = Getattr(n, "name"); for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { /* we only need to check the virtual members */ nodeType = Getattr(ni, "nodeType"); int is_using = (Cmp(nodeType, "using") == 0); Node *nn = is_using ? firstChild(ni) : ni; /* assume there is only one child node for "using" nodes */ if (is_using) { if (nn) nodeType = Getattr(nn, "nodeType"); else continue; // A private "using" node } if (!checkAttribute(nn, "storage", "virtual")) continue; /* we need to add methods(cdecl) and destructor (to check for throw decl) */ int is_destructor = (Cmp(nodeType, "destructor") == 0); if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) { decl = Getattr(nn, "decl"); /* extra check for function type and proper access */ if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(nn)) || need_nonpublic_member(nn))) { String *name = Getattr(nn, "name"); Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(nn); /* Make sure that the new method overwrites the existing: */ int len = Len(vm); const int DO_NOT_REPLACE = -1; int replace = DO_NOT_REPLACE; for (int i = 0; i < len; i++) { Node *item = Getitem(vm, i); String *check_vmid = Getattr(item, "vmid"); if (Strcmp(method_id, check_vmid) == 0) { replace = i; break; } } /* filling a new method item */ String *fqdname = NewStringf("%s::%s", classname, name); Hash *item = NewHash(); Setattr(item, "fqdname", fqdname); Node *m = Copy(nn); /* Store the complete return type - needed for non-simple return types (pointers, references etc.) */ SwigType *ty = NewString(Getattr(m, "type")); SwigType_push(ty, decl); if (SwigType_isqualifier(ty)) { Delete(SwigType_pop(ty)); } Delete(SwigType_pop_function(ty)); Setattr(m, "returntype", ty); String *mname = NewStringf("%s::%s", Getattr(parent, "name"), name); /* apply the features of the original method found in the base class */ Swig_features_get(Swig_cparse_features(), 0, mname, Getattr(m, "decl"), m); Setattr(item, "methodNode", m); Setattr(item, "vmid", method_id); if (replace == DO_NOT_REPLACE) Append(vm, item); else Setitem(vm, replace, item); Setattr(nn, "directorNode", m); Delete(mname); } if (is_destructor) { virtual_destructor = 1; } } } /* We delete all the nodirector methods. This prevents the generation of 'empty' director classes. But this has to be done outside the previous 'for' an the recursive loop!. */ if (n == parent) { int len = Len(vm); for (int i = 0; i < len; i++) { Node *item = Getitem(vm, i); Node *m = Getattr(item, "methodNode"); /* retrieve the director features */ int mdir = GetFlag(m, "feature:director"); int mndir = GetFlag(m, "feature:nodirector"); /* 'nodirector' has precedence over 'director' */ int dir = (mdir || mndir) ? (mdir && !mndir) : 1; /* check if the method was found only in a base class */ Node *p = Getattr(m, "parentNode"); if (p != n) { Node *c = Copy(m); Setattr(c, "parentNode", n); int cdir = GetFlag(c, "feature:director"); int cndir = GetFlag(c, "feature:nodirector"); dir = (cdir || cndir) ? (cdir && !cndir) : dir; Delete(c); } if (dir) { /* be sure the 'nodirector' feature is disabled */ if (mndir) Delattr(m, "feature:nodirector"); } else { /* or just delete from the vm, since is not a director method */ Delitem(vm, i); len--; i--; } } } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirectorDisown() * ---------------------------------------------------------------------- */ int Language::classDirectorDisown(Node *n) { Node *disown = NewHash(); String *mrename; String *symname = Getattr(n, "sym:name"); mrename = Swig_name_disown(NSpace, symname); String *type = NewString(ClassType); String *name = NewString("self"); SwigType_add_pointer(type); Parm *p = NewParm(type, name, n); Delete(name); Delete(type); type = NewString("void"); String *action = NewString(""); Printv(action, "{\n", "Swig::Director *director = SWIG_DIRECTOR_CAST(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL); Setfile(disown, Getfile(n)); Setline(disown, Getline(n)); Setattr(disown, "wrap:action", action); Setattr(disown, "name", mrename); Setattr(disown, "sym:name", mrename); Setattr(disown, "type", type); Setattr(disown, "parms", p); Delete(action); Delete(mrename); Delete(type); Delete(p); functionWrapper(disown); Delete(disown); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirectorConstructors() * ---------------------------------------------------------------------- */ int Language::classDirectorConstructors(Node *n) { Node *ni; String *nodeType; Node *parent = Swig_methodclass(n); int default_ctor = Getattr(parent, "allocate:default_constructor") ? 1 : 0; int protected_ctor = 0; int constructor = 0; /* emit constructors */ for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { nodeType = Getattr(ni, "nodeType"); if (Cmp(nodeType, "constructor") == 0) { if (GetFlag(ni, "feature:ignore")) continue; Parm *parms = Getattr(ni, "parms"); if (is_public(ni)) { /* emit public constructor */ classDirectorConstructor(ni); constructor = 1; if (default_ctor) default_ctor = !ParmList_numrequired(parms); } else { /* emit protected constructor if needed */ if (need_nonpublic_ctor(ni)) { classDirectorConstructor(ni); constructor = 1; protected_ctor = 1; if (default_ctor) default_ctor = !ParmList_numrequired(parms); } } } } /* emit default constructor if needed */ if (!constructor) { if (!default_ctor) { /* we get here because the class has no public, protected or default constructor, therefore, the director class can't be created, ie, is kind of abstract. */ Swig_warning(WARN_LANG_DIRECTOR_ABSTRACT, Getfile(n), Getline(n), "Director class '%s' can't be constructed\n", SwigType_namestr(Getattr(n, "name"))); return SWIG_OK; } classDirectorDefaultConstructor(n); default_ctor = 1; } /* this is just to support old java behavior, ie, the default constructor is always emitted, even when protected, and not needed, since there is a public constructor already defined. (scottm) This code is needed here to make the director_abstract + test generate compileable code (Example2 in director_abastract.i). (mmatus) This is very strange, since swig compiled with gcc3.2.3 doesn't need it here.... */ if (!default_ctor && !protected_ctor) { if (Getattr(parent, "allocate:default_base_constructor")) { classDirectorDefaultConstructor(n); } } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirectorMethods() * ---------------------------------------------------------------------- */ int Language::classDirectorMethods(Node *n) { Node *vtable = Getattr(n, "vtable"); int len = Len(vtable); for (int i = 0; i < len; i++) { Node *item = Getitem(vtable, i); String *method = Getattr(item, "methodNode"); String *fqdname = Getattr(item, "fqdname"); if (GetFlag(method, "feature:nodirector")) continue; String *wrn = Getattr(method, "feature:warnfilter"); if (wrn) Swig_warnfilter(wrn, 1); String *type = Getattr(method, "nodeType"); if (!Cmp(type, "destructor")) { classDirectorDestructor(method); } else { Swig_require("classDirectorMethods", method, "*type", NIL); assert(Getattr(method, "returntype")); Setattr(method, "type", Getattr(method, "returntype")); if (classDirectorMethod(method, n, fqdname) == SWIG_OK) SetFlag(item, "director"); Swig_restore(method); } if (wrn) Swig_warnfilter(wrn, 0); } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirectorInit() * ---------------------------------------------------------------------- */ int Language::classDirectorInit(Node *n) { (void) n; return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirectorDestructor() * ---------------------------------------------------------------------- */ int Language::classDirectorDestructor(Node *n) { /* Always emit the virtual destructor in the declaration and in the compilation unit. Been explicit here can't make any damage, and can solve some nasty C++ compiler problems. */ File *f_directors = Swig_filebyname("director"); File *f_directors_h = Swig_filebyname("director_h"); if (Getattr(n, "throw")) { Printf(f_directors_h, " virtual ~%s() throw ();\n", DirectorClassName); Printf(f_directors, "%s::~%s() throw () {\n}\n\n", DirectorClassName, DirectorClassName); } else { Printf(f_directors_h, " virtual ~%s();\n", DirectorClassName); Printf(f_directors, "%s::~%s() {\n}\n\n", DirectorClassName, DirectorClassName); } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirectorEnd() * ---------------------------------------------------------------------- */ int Language::classDirectorEnd(Node *n) { (void) n; return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDirector() * ---------------------------------------------------------------------- */ int Language::classDirector(Node *n) { Node *module = Getattr(n, "module"); String *classtype = Getattr(n, "classtype"); Hash *directormap = 0; if (module) { directormap = Getattr(module, "wrap:directormap"); if (directormap == 0) { directormap = NewHash(); Setattr(module, "wrap:directormap", directormap); } } List *vtable = NewList(); int virtual_destructor = 0; unrollVirtualMethods(n, n, vtable, 0, virtual_destructor); // Emit all the using base::member statements for non virtual members (allprotected mode) Node *ni; String *using_protected_members_code = NewString(""); for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { Node *nodeType = Getattr(ni, "nodeType"); bool cdeclaration = (Cmp(nodeType, "cdecl") == 0); if (cdeclaration && !GetFlag(ni, "feature:ignore")) { if (isNonVirtualProtectedAccess(ni)) { Node *overloaded = Getattr(ni, "sym:overloaded"); // emit the using base::member statement (but only once if the method is overloaded) if (!overloaded || (overloaded && (overloaded == ni))) Printf(using_protected_members_code, " using %s::%s;\n", SwigType_namestr(ClassName), Getattr(ni, "name")); } } } if (virtual_destructor || Len(vtable) > 0) { if (!virtual_destructor) { String *classtype = Getattr(n, "classtype"); Swig_warning(WARN_LANG_DIRECTOR_VDESTRUCT, input_file, line_number, "Director base class %s has no virtual destructor.\n", classtype); } Setattr(n, "vtable", vtable); if (directormap != 0) { Setattr(directormap, classtype, n); } classDirectorInit(n); classDirectorConstructors(n); classDirectorMethods(n); File *f_directors_h = Swig_filebyname("director_h"); Printv(f_directors_h, using_protected_members_code, NIL); classDirectorEnd(n); } Delete(vtable); Delete(using_protected_members_code); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classDeclaration() * ---------------------------------------------------------------------- */ static void addCopyConstructor(Node *n) { Node *cn = NewHash(); set_nodeType(cn, "constructor"); Setattr(cn, "access", "public"); Setfile(cn, Getfile(n)); Setline(cn, Getline(n)); String *cname = Getattr(n, "name"); SwigType *type = Copy(cname); String *name = Swig_scopename_last(cname); String *cc = NewStringf("r.q(const).%s", type); String *decl = NewStringf("f(%s).", cc); String *oldname = Getattr(n, "sym:name"); if (Getattr(n, "allocate:has_constructor")) { // to work properly with '%rename Class', we must look // for any other constructor in the class, which has not been // renamed, and use its name as oldname. Node *c; for (c = firstChild(n); c; c = nextSibling(c)) { const char *tag = Char(nodeType(c)); if (strcmp(tag, "constructor") == 0) { String *cname = Getattr(c, "name"); String *csname = Getattr(c, "sym:name"); String *clast = Swig_scopename_last(cname); if (Equal(csname, clast)) { oldname = csname; break; } } } } String *symname = Swig_name_make(cn, cname, name, decl, oldname); if (Strcmp(symname, "$ignore") != 0) { Parm *p = NewParm(cc, "other", n); Setattr(cn, "name", name); Setattr(cn, "sym:name", symname); SetFlag(cn, "feature:new"); Setattr(cn, "decl", decl); Setattr(cn, "parentNode", n); Setattr(cn, "parms", p); Setattr(cn, "copy_constructor", "1"); Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab")); Node *on = Swig_symbol_add(symname, cn); Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn); Swig_symbol_setscope(oldscope); if (on == cn) { Node *access = NewHash(); set_nodeType(access, "access"); Setattr(access, "kind", "public"); appendChild(n, access); appendChild(n, cn); Setattr(n, "has_copy_constructor", "1"); Setattr(n, "copy_constructor_decl", decl); Setattr(n, "allocate:copy_constructor", "1"); Delete(access); } } Delete(cn); Delete(name); Delete(decl); Delete(symname); } static void addDefaultConstructor(Node *n) { Node *cn = NewHash(); set_nodeType(cn, "constructor"); Setattr(cn, "access", "public"); Setfile(cn, Getfile(n)); Setline(cn, Getline(n)); String *cname = Getattr(n, "name"); String *name = Swig_scopename_last(cname); String *decl = NewString("f()."); String *oldname = Getattr(n, "sym:name"); String *symname = Swig_name_make(cn, cname, name, decl, oldname); if (Strcmp(symname, "$ignore") != 0) { Setattr(cn, "name", name); Setattr(cn, "sym:name", symname); SetFlag(cn, "feature:new"); Setattr(cn, "decl", decl); Setattr(cn, "parentNode", n); Setattr(cn, "default_constructor", "1"); Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab")); Node *on = Swig_symbol_add(symname, cn); Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn); Swig_symbol_setscope(oldscope); if (on == cn) { Node *access = NewHash(); set_nodeType(access, "access"); Setattr(access, "kind", "public"); appendChild(n, access); appendChild(n, cn); Setattr(n, "has_default_constructor", "1"); Setattr(n, "allocate:default_constructor", "1"); Delete(access); } } Delete(cn); Delete(name); Delete(decl); Delete(symname); } static void addDestructor(Node *n) { Node *cn = NewHash(); set_nodeType(cn, "destructor"); Setattr(cn, "access", "public"); Setfile(cn, Getfile(n)); Setline(cn, Getline(n)); String *cname = Getattr(n, "name"); String *name = Swig_scopename_last(cname); Insert(name, 0, "~"); String *decl = NewString("f()."); String *symname = Swig_name_make(cn, cname, name, decl, 0); if (Strcmp(symname, "$ignore") != 0) { String *possible_nonstandard_symname = NewStringf("~%s", Getattr(n, "sym:name")); Setattr(cn, "name", name); Setattr(cn, "sym:name", symname); Setattr(cn, "decl", "f()."); Setattr(cn, "parentNode", n); Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab")); Node *nonstandard_destructor = Equal(possible_nonstandard_symname, symname) ? 0 : Swig_symbol_clookup(possible_nonstandard_symname, 0); Node *on = Swig_symbol_add(symname, cn); Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn); Swig_symbol_setscope(oldscope); if (on == cn) { // SWIG accepts a non-standard named destructor in %extend that uses a typedef for the destructor name // For example: typedef struct X {} XX; %extend X { ~XX() {...} } // Don't add another destructor if a nonstandard one has been declared if (!nonstandard_destructor) { Node *access = NewHash(); set_nodeType(access, "access"); Setattr(access, "kind", "public"); appendChild(n, access); appendChild(n, cn); Setattr(n, "has_destructor", "1"); Setattr(n, "allocate:destructor", "1"); Delete(access); } } Delete(possible_nonstandard_symname); } Delete(cn); Delete(name); Delete(decl); Delete(symname); } int Language::classDeclaration(Node *n) { String *ochildren = Getattr(n, "feature:onlychildren"); if (ochildren) { Setattr(n, "feature:emitonlychildren", ochildren); emit_children(n); Delattr(n, "feature:emitonlychildren"); SetFlag(n, "feature:ignore"); return SWIG_NOWRAP; } // save class local variables for nested classes support int oldInClass = InClass; String *oldClassType = ClassType; String *oldClassPrefix = ClassPrefix; String *oldClassName = ClassName; String *oldDirectorClassName = DirectorClassName; String *oldNSpace = NSpace; Node *oldCurrentClass = CurrentClass; int dir = 0; String *kind = Getattr(n, "kind"); String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); String *unnamed = Getattr(n, "unnamed"); String *symname = Getattr(n, "sym:name"); int strip = CPlusPlus ? 1 : unnamed && tdname; if (cplus_mode != PUBLIC) return SWIG_NOWRAP; if (!name) { Swig_warning(WARN_LANG_CLASS_UNNAMED, input_file, line_number, "Can't generate wrappers for unnamed struct/class.\n"); return SWIG_NOWRAP; } /* Check symbol name for template. If not renamed. Issue a warning */ if (!validIdentifier(symname)) { Swig_warning(WARN_LANG_IDENTIFIER, input_file, line_number, "Can't wrap class %s unless renamed to a valid identifier.\n", SwigType_namestr(symname)); return SWIG_NOWRAP; } AccessMode oldAccessMode = cplus_mode; Node *outerClass = Getattr(n, "nested:outer"); if (outerClass && oldAccessMode != PUBLIC) return SWIG_NOWRAP; ClassName = Copy(name); ClassPrefix = Copy(symname); if (Cmp(kind, "class") == 0) { cplus_mode = PRIVATE; } else { cplus_mode = PUBLIC; } for (; outerClass; outerClass = Getattr(outerClass, "nested:outer")) { Push(ClassPrefix, "_"); Push(ClassPrefix, Getattr(outerClass, "sym:name")); } if (strip) { ClassType = Copy(name); } else { ClassType = NewStringf("%s %s", kind, name); } Setattr(n, "classtypeobj", Copy(ClassType)); Setattr(n, "classtype", SwigType_namestr(ClassType)); InClass = 1; CurrentClass = n; NSpace = Getattr(n, "sym:nspace"); int oldAbstract = Abstract; /* Call classHandler() here */ if (!ImportMode) { if (directorsEnabled()) { int ndir = GetFlag(n, "feature:director"); int nndir = GetFlag(n, "feature:nodirector"); /* 'nodirector' has precedence over 'director' */ dir = (ndir || nndir) ? (ndir && !nndir) : 0; } int abstract = !dir && abstractClassTest(n); int odefault = (GenerateDefault && !GetFlag(n, "feature:nodefault")); /* default constructor */ if (!abstract && !GetFlag(n, "feature:nodefaultctor") && odefault) { if (!Getattr(n, "has_constructor") && !Getattr(n, "allocate:has_constructor") && (Getattr(n, "allocate:default_constructor"))) { addDefaultConstructor(n); } } /* copy constructor */ if (CPlusPlus && !abstract && GetFlag(n, "feature:copyctor")) { if (!Getattr(n, "has_copy_constructor") && !Getattr(n, "allocate:has_copy_constructor") && (Getattr(n, "allocate:copy_constructor")) && (!GetFlag(n, "feature:ignore"))) { addCopyConstructor(n); } } /* default destructor */ if (!GetFlag(n, "feature:nodefaultdtor") && odefault) { if (!Getattr(n, "has_destructor") && (!Getattr(n, "allocate:has_destructor")) && (Getattr(n, "allocate:default_destructor")) && (!GetFlag(n, "feature:ignore"))) { addDestructor(n); } } if (dir) { DirectorClassName = directorClassName(n); classDirector(n); } /* check for abstract after resolving directors */ Abstract = abstractClassTest(n); classHandler(n); } else { Abstract = abstractClassTest(n); Language::classHandler(n); } Abstract = oldAbstract; cplus_mode = oldAccessMode; NSpace = oldNSpace; InClass = oldInClass; CurrentClass = oldCurrentClass; Delete(ClassType); ClassType = oldClassType; Delete(ClassPrefix); ClassPrefix = oldClassPrefix; Delete(ClassName); ClassName = oldClassName; if (dir) { Delete(DirectorClassName); } DirectorClassName = oldDirectorClassName; return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classHandler() * ---------------------------------------------------------------------- */ int Language::classHandler(Node *n) { save_value oldExtend(Extend); if (Getattr(n, "template")) Extend = 0; bool hasDirector = Swig_directorclass(n) ? true : false; /* Emit all of the class members */ emit_children(n); /* Look for smart pointer handling */ if (Getattr(n, "allocate:smartpointer")) { List *methods = Getattr(n, "allocate:smartpointer"); cplus_mode = PUBLIC; SmartPointer = CWRAP_SMART_POINTER; if (Getattr(n, "allocate:smartpointerconst") && Getattr(n, "allocate:smartpointermutable")) { SmartPointer |= CWRAP_SMART_POINTER_OVERLOAD; } Iterator c; for (c = First(methods); c.item; c = Next(c)) { emit_one(c.item); } SmartPointer = 0; } cplus_mode = PUBLIC; /* emit director disown method */ if (hasDirector) { classDirectorDisown(n); /* Emit additional protected virtual methods - only needed if the language module * codes logic in the C++ layer instead of the director proxy class method - primarily * to catch public use of protected methods by the scripting languages. */ if (dirprot_mode() && extraDirectorProtectedCPPMethodsRequired()) { Node *vtable = Getattr(n, "vtable"); String *symname = Getattr(n, "sym:name"); save_value old_mode(cplus_mode); cplus_mode = PROTECTED; int len = Len(vtable); for (int i = 0; i < len; i++) { Node *item = Getitem(vtable, i); Node *method = Getattr(item, "methodNode"); SwigType *type = Getattr(method, "nodeType"); if (Strcmp(type, "cdecl") != 0) continue; if (GetFlag(method, "feature:ignore")) continue; String *methodname = Getattr(method, "sym:name"); String *wrapname = NewStringf("%s_%s", symname, methodname); if (!symbolLookup(wrapname, "") && (!is_public(method))) { Node *m = Copy(method); Setattr(m, "director", "1"); Setattr(m, "parentNode", n); /* * There is a bug that needs fixing still... * This area of code is creating methods which have not been overridden in a derived class (director methods that are protected in the base) * If the method is overloaded, then Swig_overload_dispatch() incorrectly generates a call to the base wrapper, _wrap_xxx method * See director_protected_overloaded.i - Possibly sym:overname needs correcting here. Printf(stdout, "new method: %s::%s(%s)\n", Getattr(parentNode(m), "name"), Getattr(m, "name"), ParmList_str_defaultargs(Getattr(m, "parms"))); */ cDeclaration(m); Delete(m); } Delete(wrapname); } } } return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classforwardDeclaration() * ---------------------------------------------------------------------- */ int Language::classforwardDeclaration(Node *n) { (void) n; return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::constructorDeclaration() * ---------------------------------------------------------------------- */ int Language::constructorDeclaration(Node *n) { String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); if (!symname) return SWIG_NOWRAP; if (!CurrentClass) return SWIG_NOWRAP; if (ImportMode) return SWIG_NOWRAP; if (Extend) { /* extend default constructor can be safely ignored if there is already one */ int num_required = ParmList_numrequired(Getattr(n, "parms")); if ((num_required == 0) && Getattr(CurrentClass, "has_default_constructor")) { return SWIG_NOWRAP; } if ((num_required == 1) && Getattr(CurrentClass, "has_copy_constructor")) { String *ccdecl = Getattr(CurrentClass, "copy_constructor_decl"); if (ccdecl && (Strcmp(ccdecl, Getattr(n, "decl")) == 0)) { return SWIG_NOWRAP; } } } /* clean protected overloaded constructors, in case they are not needed anymore */ Node *over = Swig_symbol_isoverloaded(n); if (over && !Getattr(CurrentClass, "sym:cleanconstructor")) { int dirclass = Swig_directorclass(CurrentClass); Node *nn = over; while (nn) { if (!is_public(nn)) { if (!dirclass || !need_nonpublic_ctor(nn)) { SetFlag(nn, "feature:ignore"); } } nn = Getattr(nn, "sym:nextSibling"); } clean_overloaded(over); Setattr(CurrentClass, "sym:cleanconstructor", "1"); } if ((cplus_mode != PUBLIC)) { /* check only for director classes */ if (!Swig_directorclass(CurrentClass) || !need_nonpublic_ctor(n)) return SWIG_NOWRAP; } /* Name adjustment for %name */ Swig_save("constructorDeclaration", n, "sym:name", NIL); { String *base = Swig_scopename_last(name); if ((Strcmp(base, symname) == 0) && (Strcmp(symname, ClassPrefix) != 0)) { Setattr(n, "sym:name", ClassPrefix); } Delete(base); } /* Only create a constructor if the class is not abstract */ if (!Abstract) { Node *over; over = Swig_symbol_isoverloaded(n); if (over) over = first_nontemplate(over); if ((over) && (!overloading)) { /* If the symbol is overloaded. We check to see if it is a copy constructor. If so, we invoke copyconstructorHandler() as a special case. */ if (Getattr(n, "copy_constructor") && (!Getattr(CurrentClass, "has_copy_constructor"))) { copyconstructorHandler(n); Setattr(CurrentClass, "has_copy_constructor", "1"); } else { if (Getattr(over, "copy_constructor")) over = Getattr(over, "sym:nextSibling"); if (over != n) { Swig_warning(WARN_LANG_OVERLOAD_CONSTRUCT, input_file, line_number, "Overloaded constructor ignored. %s\n", Swig_name_decl(n)); Swig_warning(WARN_LANG_OVERLOAD_CONSTRUCT, Getfile(over), Getline(over), "Previous declaration is %s\n", Swig_name_decl(over)); } else { constructorHandler(n); } } } else { String *expected_name = ClassName; String *scope = Swig_scopename_check(ClassName) ? Swig_scopename_prefix(ClassName) : 0; String *actual_name = scope ? NewStringf("%s::%s", scope, name) : NewString(name); Delete(scope); if (!Equal(actual_name, expected_name) && !SwigType_istemplate(expected_name)) { bool illegal_name = true; if (Extend) { // Check for typedef names used as a constructor name in %extend. This is deprecated except for anonymous // typedef structs which have had their symbol names adjusted to the typedef name in the parser. SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name); SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name); if (!CPlusPlus) { if (Strncmp(name_resolved, "struct ", 7) == 0) Replace(name_resolved, "struct ", "", DOH_REPLACE_FIRST); else if (Strncmp(name_resolved, "union ", 6) == 0) Replace(name_resolved, "union ", "", DOH_REPLACE_FIRST); } illegal_name = !Equal(name_resolved, expected_name_resolved); if (!illegal_name) Swig_warning(WARN_LANG_EXTEND_CONSTRUCTOR, input_file, line_number, "Use of an illegal constructor name '%s' in %%extend is deprecated, the constructor name should be '%s'.\n", SwigType_str(Swig_scopename_last(actual_name), 0), SwigType_str(Swig_scopename_last(expected_name), 0)); Delete(name_resolved); Delete(expected_name_resolved); } if (illegal_name) { Swig_warning(WARN_LANG_RETURN_TYPE, input_file, line_number, "Function %s must have a return type. Ignored.\n", Swig_name_decl(n)); Swig_restore(n); return SWIG_NOWRAP; } } constructorHandler(n); } } Setattr(CurrentClass, "has_constructor", "1"); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * get_director_ctor_code() * ---------------------------------------------------------------------- */ static String *get_director_ctor_code(Node *n, String *director_ctor_code, String *director_prot_ctor_code, List *&abstracts) { String *director_ctor = director_ctor_code; int use_director = Swig_directorclass(n); if (use_director) { Node *pn = Swig_methodclass(n); abstracts = Getattr(pn, "abstracts"); if (director_prot_ctor_code) { int is_notabstract = GetFlag(pn, "feature:notabstract"); int is_abstract = abstracts && !is_notabstract; if (is_protected(n) || is_abstract) { director_ctor = director_prot_ctor_code; abstracts = Copy(abstracts); Delattr(pn, "abstracts"); } else { if (is_notabstract) { abstracts = Copy(abstracts); Delattr(pn, "abstracts"); } else { abstracts = 0; } } } } return director_ctor; } /* ---------------------------------------------------------------------- * Language::constructorHandler() * ---------------------------------------------------------------------- */ int Language::constructorHandler(Node *n) { Swig_require("constructorHandler", n, "?name", "*sym:name", "?type", "?parms", NIL); String *symname = Getattr(n, "sym:name"); String *mrename = Swig_name_construct(NSpace, symname); String *nodeType = Getattr(n, "nodeType"); int constructor = (!Cmp(nodeType, "constructor")); List *abstracts = 0; String *director_ctor = get_director_ctor_code(n, director_ctor_code, director_prot_ctor_code, abstracts); if (!constructor) { /* if not originally a constructor, still handle it as one */ Setattr(n, "handled_as_constructor", "1"); } Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend, DirectorClassName); Setattr(n, "sym:name", mrename); functionWrapper(n); Delete(mrename); Swig_restore(n); if (abstracts) Setattr(Swig_methodclass(n), "abstracts", abstracts); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::copyconstructorHandler() * ---------------------------------------------------------------------- */ int Language::copyconstructorHandler(Node *n) { Swig_require("copyconstructorHandler", n, "?name", "*sym:name", "?type", "?parms", NIL); String *symname = Getattr(n, "sym:name"); String *mrename = Swig_name_copyconstructor(NSpace, symname); List *abstracts = 0; String *director_ctor = get_director_ctor_code(n, director_ctor_code, director_prot_ctor_code, abstracts); Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend, DirectorClassName); Setattr(n, "sym:name", mrename); functionWrapper(n); Delete(mrename); Swig_restore(n); if (abstracts) Setattr(Swig_methodclass(n), "abstracts", abstracts); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::destructorDeclaration() * ---------------------------------------------------------------------- */ int Language::destructorDeclaration(Node *n) { if (!CurrentClass) return SWIG_NOWRAP; if (cplus_mode != PUBLIC && !Getattr(CurrentClass, "feature:unref")) return SWIG_NOWRAP; if (ImportMode) return SWIG_NOWRAP; Swig_save("destructorDeclaration", n, "name", "sym:name", NIL); char *c = GetChar(n, "sym:name"); if (c && (*c == '~')) { Setattr(n, "sym:name", c + 1); } String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); if ((Strcmp(name, symname) == 0) || (Strcmp(symname, ClassPrefix) != 0)) { Setattr(n, "sym:name", ClassPrefix); } String *expected_name = ClassName; String *scope = Swig_scopename_check(ClassName) ? Swig_scopename_prefix(ClassName) : 0; String *actual_name = scope ? NewStringf("%s::%s", scope, name) : NewString(name); Delete(scope); Replace(actual_name, "~", "", DOH_REPLACE_FIRST); if (!Equal(actual_name, expected_name) && !(Getattr(n, "template"))) { bool illegal_name = true; if (Extend) { // Check for typedef names used as a destructor name in %extend. This is deprecated except for anonymous // typedef structs which have had their symbol names adjusted to the typedef name in the parser. SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name); SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name); if (!CPlusPlus) { if (Strncmp(name_resolved, "struct ", 7) == 0) Replace(name_resolved, "struct ", "", DOH_REPLACE_FIRST); else if (Strncmp(name_resolved, "union ", 6) == 0) Replace(name_resolved, "union ", "", DOH_REPLACE_FIRST); } illegal_name = !Equal(name_resolved, expected_name_resolved); if (!illegal_name) Swig_warning(WARN_LANG_EXTEND_DESTRUCTOR, input_file, line_number, "Use of an illegal destructor name '%s' in %%extend is deprecated, the destructor name should be '%s'.\n", SwigType_str(Swig_scopename_last(actual_name), 0), SwigType_str(Swig_scopename_last(expected_name), 0)); Delete(name_resolved); Delete(expected_name_resolved); } if (illegal_name) { Swig_warning(WARN_LANG_ILLEGAL_DESTRUCTOR, input_file, line_number, "Illegal destructor name %s. Ignored.\n", Swig_name_decl(n)); Swig_restore(n); return SWIG_NOWRAP; } } destructorHandler(n); Setattr(CurrentClass, "has_destructor", "1"); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::destructorHandler() * ---------------------------------------------------------------------- */ int Language::destructorHandler(Node *n) { Swig_require("destructorHandler", n, "?name", "*sym:name", NIL); Swig_save("destructorHandler", n, "type", "parms", NIL); String *symname = Getattr(n, "sym:name"); String *mrename; char *csymname = Char(symname); if (*csymname == '~') csymname += 1; mrename = Swig_name_destroy(NSpace, csymname); Swig_DestructorToFunction(n, NSpace, ClassType, CPlusPlus, Extend); Setattr(n, "sym:name", mrename); functionWrapper(n); Delete(mrename); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::accessDeclaration() * ---------------------------------------------------------------------- */ int Language::accessDeclaration(Node *n) { String *kind = Getattr(n, "kind"); if (Cmp(kind, "public") == 0) { cplus_mode = PUBLIC; } else if (Cmp(kind, "private") == 0) { cplus_mode = PRIVATE; } else if (Cmp(kind, "protected") == 0) { cplus_mode = PROTECTED; } return SWIG_OK; } /* ----------------------------------------------------------------------------- * Language::namespaceDeclaration() * ----------------------------------------------------------------------------- */ int Language::namespaceDeclaration(Node *n) { if (Getattr(n, "alias")) return SWIG_OK; if (Getattr(n, "unnamed")) return SWIG_OK; emit_children(n); return SWIG_OK; } int Language::validIdentifier(String *s) { char *c = Char(s); while (*c) { if (!(isalnum(*c) || (*c == '_'))) return 0; c++; } return 1; } /* ----------------------------------------------------------------------------- * Language::usingDeclaration() * ----------------------------------------------------------------------------- */ int Language::usingDeclaration(Node *n) { if ((cplus_mode == PUBLIC) || (!is_public(n) && dirprot_mode())) { Node *np = Copy(n); Node *c; for (c = firstChild(np); c; c = nextSibling(c)) { /* it seems for some cases this is needed, like A* A::boo() */ if (CurrentClass) Setattr(c, "parentNode", CurrentClass); emit_one(c); } Delete(np); } return SWIG_OK; } /* Stubs. Language modules need to implement these */ /* ---------------------------------------------------------------------- * Language::constantWrapper() * ---------------------------------------------------------------------- */ int Language::constantWrapper(Node *n) { String *name = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *value = Getattr(n, "value"); String *str = SwigType_str(type, name); Printf(stdout, "constantWrapper : %s = %s\n", str, value); Delete(str); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::variableWrapper() * ---------------------------------------------------------------------- */ int Language::variableWrapper(Node *n) { Swig_require("variableWrapper", n, "*name", "*sym:name", "*type", "?parms", "?varset", "?varget", NIL); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *name = Getattr(n, "name"); Delattr(n,"varset"); Delattr(n,"varget"); /* If no way to set variables. We simply create functions */ int assignable = is_assignable(n); int flags = use_naturalvar_mode(n); if (!GetFlag(n, "wrappedasconstant")) flags = flags | Extend; if (assignable) { int make_set_wrapper = 1; String *tm = Swig_typemap_lookup("globalin", n, name, 0); Swig_VarsetToFunction(n, flags); String *sname = Swig_name_set(NSpace, symname); Setattr(n, "sym:name", sname); Delete(sname); if (!tm) { if (SwigType_isarray(type)) { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0)); make_set_wrapper = 0; } } else { String *pname0 = Swig_cparm_name(0, 0); Replace(tm, "$source", pname0, DOH_REPLACE_ANY); Replace(tm, "$target", name, DOH_REPLACE_ANY); Replace(tm, "$input", pname0, DOH_REPLACE_ANY); Setattr(n, "wrap:action", tm); Delete(tm); Delete(pname0); } if (make_set_wrapper) { Setattr(n, "varset", "1"); functionWrapper(n); } else { SetFlag(n, "feature:immutable"); } /* Restore parameters */ Setattr(n, "sym:name", symname); Setattr(n, "type", type); Setattr(n, "name", name); Delattr(n, "varset"); /* Delete all attached typemaps and typemap attributes */ Iterator ki; for (ki = First(n); ki.key; ki = Next(ki)) { if (Strncmp(ki.key, "tmap:", 5) == 0) Delattr(n, ki.key); } } Swig_VargetToFunction(n, flags); String *gname = Swig_name_get(NSpace, symname); Setattr(n, "sym:name", gname); Delete(gname); Setattr(n, "varget", "1"); functionWrapper(n); Delattr(n, "varget"); Swig_restore(n); return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::functionWrapper() * ---------------------------------------------------------------------- */ int Language::functionWrapper(Node *n) { String *name = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); ParmList *parms = Getattr(n, "parms"); Printf(stdout, "functionWrapper : %s\n", SwigType_str(type, NewStringf("%s(%s)", name, ParmList_str_defaultargs(parms)))); Printf(stdout, " action : %s\n", Getattr(n, "wrap:action")); return SWIG_OK; } /* ----------------------------------------------------------------------------- * Language::nativeWrapper() * ----------------------------------------------------------------------------- */ int Language::nativeWrapper(Node *n) { (void) n; return SWIG_OK; } void Language::main(int argc, char *argv[]) { (void) argc; (void) argv; } /* ----------------------------------------------------------------------------- * Language::addSymbol() * * Adds a symbol entry into the target language symbol tables. * Returns 1 if the symbol is added successfully. * Prints an error message and returns 0 if a conflict occurs. * The scope is optional for target languages and if supplied must be a fully * qualified scope and the symbol s must not contain any scope qualifiers. * ----------------------------------------------------------------------------- */ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope) { //Printf( stdout, "addSymbol: %s %s\n", s, scope ); Hash *symbols = Getattr(symtabs, scope ? scope : ""); if (!symbols) { symbols = symbolAddScope(scope); } else { Node *c = Getattr(symbols, s); if (c && (c != n)) { if (scope && Len(scope) > 0) Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module in scope '%s'.\n", s, scope); else Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s); Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s); return 0; } } Setattr(symbols, s, n); return 1; } /* ----------------------------------------------------------------------------- * Language::symbolAddScope() * * Creates a scope (symbols Hash) for given name. This method is auxiliary, * you don't have to call it - addSymbols will lazily create scopes automatically. * If scope with given name already exists, then do nothing. * Returns newly created (or already existing) scope. * ----------------------------------------------------------------------------- */ Hash* Language::symbolAddScope(const_String_or_char_ptr scope) { Hash *symbols = symbolScopeLookup(scope); if(!symbols) { // The order in which the following code is executed is important. In the Language // constructor addScope("") is called to create a top level scope. // Thus we must first add a symbols hash to symtab and only then add pseudo // symbols to the top-level scope. // New scope which has not been added by the target language - lazily created. symbols = NewHash(); Setattr(symtabs, scope, symbols); // Add the new scope as a symbol in the top level scope. // Alternatively the target language must add it in before attempting to add symbols into the scope. const_String_or_char_ptr top_scope = ""; Hash *topscope_symbols = Getattr(symtabs, top_scope); Hash *pseudo_symbol = NewHash(); Setattr(pseudo_symbol, "sym:scope", "1"); Setattr(topscope_symbols, scope, pseudo_symbol); } return symbols; } /* ----------------------------------------------------------------------------- * Language::symbolScopeLookup() * * Lookup and returns a symtable (hash) representing given scope. Hash contains * all symbols in this scope. * ----------------------------------------------------------------------------- */ Hash* Language::symbolScopeLookup( const_String_or_char_ptr scope ) { Hash *symbols = Getattr(symtabs, scope ? scope : ""); return symbols; } /* ----------------------------------------------------------------------------- * Language::symbolScopePseudoSymbolLookup() * * For every scope there is a special pseudo-symbol in the top scope (""). It * exists solely to detect name clashes. This pseudo symbol may contain a few properties, * but more could be added. This is also true for the top level scope (""). * It contains a pseudo symbol with name "" (empty). Pseudo symbol contains the * following properties: * sym:scope = "1" - a flag that this is a scope pseudo symbol * * Pseudo symbols are a Hash*, not a Node*. * There is no difference from symbolLookup() method except for signature * and return type. * ----------------------------------------------------------------------------- */ Hash* Language::symbolScopePseudoSymbolLookup( const_String_or_char_ptr scope ) { /* Getting top scope */ const_String_or_char_ptr top_scope = ""; Hash *symbols = Getattr(symtabs, top_scope); return Getattr(symbols, scope); } /* ----------------------------------------------------------------------------- * Language::dumpSymbols() * ----------------------------------------------------------------------------- */ void Language::dumpSymbols() { Printf(stdout, "LANGUAGE SYMBOLS start =======================================\n"); Node *table = symtabs; Iterator ki = First(table); while (ki.key) { String *k = ki.key; Printf(stdout, "===================================================\n"); Printf(stdout, "%s -\n", k); { Symtab *symtab = Getattr(table, k); Iterator it = First(symtab); while (it.key) { String *symname = it.key; Printf(stdout, " %s\n", symname); it = Next(it); } } ki = Next(ki); } Printf(stdout, "LANGUAGE SYMBOLS finish =======================================\n"); } /* ----------------------------------------------------------------------------- * Language::symbolLookup() * ----------------------------------------------------------------------------- */ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) { Hash *symbols = Getattr(symtabs, scope ? scope : ""); if (!symbols) { return NULL; } return Getattr(symbols, s); } /* ----------------------------------------------------------------------------- * Language::classLookup() * * Tries to locate a class from a type definition * ----------------------------------------------------------------------------- */ Node *Language::classLookup(const SwigType *s) const { Node *n = 0; /* Look in hash of cached values */ n = Getattr(classtypes, s); if (!n) { Symtab *stab = 0; SwigType *ty1 = SwigType_typedef_resolve_all(s); SwigType *ty2 = SwigType_strip_qualifiers(ty1); String *base = SwigType_base(ty2); Replaceall(base, "class ", ""); Replaceall(base, "struct ", ""); Replaceall(base, "union ", ""); if (strncmp(Char(base), "::", 2) == 0) { String *oldbase = base; base = NewString(Char(base) + 2); Delete(oldbase); } String *prefix = SwigType_prefix(ty2); /* Do a symbol table search on the base type */ while (!n) { Hash *nstab; n = Swig_symbol_clookup(base, stab); if (!n) break; if (Strcmp(nodeType(n), "class") == 0) break; n = parentNode(n); if (!n) break; nstab = Getattr(n, "sym:symtab"); n = 0; if ((!nstab) || (nstab == stab)) { break; } stab = nstab; } if (n) { /* Found a match. Look at the prefix. We only allow the cases where where we want a proxy class for the particular type */ bool acceptable_prefix = (Len(prefix) == 0) || // simple type (pass by value) (Strcmp(prefix, "p.") == 0) || // pointer (Strcmp(prefix, "r.") == 0) || // reference (Strcmp(prefix, "z.") == 0) || // rvalue reference SwigType_prefix_is_simple_1D_array(prefix); // Simple 1D array (not arrays of pointers/references) // Also accept pointer by const reference, not non-const pointer reference if (!acceptable_prefix && (Strcmp(prefix, "r.p.") == 0)) { Delete(prefix); prefix = SwigType_prefix(ty1); acceptable_prefix = (Strncmp(prefix, "r.q(const", 9) == 0); } if (acceptable_prefix) { SwigType *cs = Copy(s); Setattr(classtypes, cs, n); Delete(cs); } else { n = 0; } } Delete(prefix); Delete(base); Delete(ty2); Delete(ty1); } if (n && (GetFlag(n, "feature:ignore") || Getattr(n, "feature:onlychildren"))) { n = 0; } return n; } /* ----------------------------------------------------------------------------- * Language::enumLookup() * * Finds and returns the Node containing the enum declaration for the (enum) * type passed in. * ----------------------------------------------------------------------------- */ Node *Language::enumLookup(SwigType *s) { Node *n = 0; /* Look in hash of cached values */ n = Getattr(enumtypes, s); if (!n) { Symtab *stab = 0; SwigType *lt = SwigType_ltype(s); SwigType *ty1 = SwigType_typedef_resolve_all(lt); SwigType *ty2 = SwigType_strip_qualifiers(ty1); String *base = SwigType_base(ty2); Replaceall(base, "enum ", ""); String *prefix = SwigType_prefix(ty2); if (strncmp(Char(base), "::", 2) == 0) { String *oldbase = base; base = NewString(Char(base) + 2); Delete(oldbase); } /* Look for type in symbol table */ while (!n) { Hash *nstab; n = Swig_symbol_clookup(base, stab); if (!n) break; if (Equal(nodeType(n), "enum")) break; if (Equal(nodeType(n), "enumforward") && GetFlag(n, "enumMissing")) break; n = parentNode(n); if (!n) break; nstab = Getattr(n, "sym:symtab"); n = 0; if ((!nstab) || (nstab == stab)) { break; } stab = nstab; } if (n) { /* Found a match. Look at the prefix. We only allow simple types. */ if (Len(prefix) == 0) { /* Simple type */ Setattr(enumtypes, Copy(s), n); } else { n = 0; } } Delete(prefix); Delete(base); Delete(ty2); Delete(ty1); Delete(lt); } if (n && (GetFlag(n, "feature:ignore"))) { n = 0; } return n; } /* ----------------------------------------------------------------------------- * Language::allow_overloading() * ----------------------------------------------------------------------------- */ void Language::allow_overloading(int val) { overloading = val; } /* ----------------------------------------------------------------------------- * Language::allow_multiple_input() * ----------------------------------------------------------------------------- */ void Language::allow_multiple_input(int val) { multiinput = val; } /* ----------------------------------------------------------------------------- * Language::enable_cplus_runtime_mode() * ----------------------------------------------------------------------------- */ void Language::enable_cplus_runtime_mode() { cplus_runtime = 1; } /* ----------------------------------------------------------------------------- * Language::cplus_runtime_mode() * ----------------------------------------------------------------------------- */ int Language::cplus_runtime_mode() { return cplus_runtime; } /* ----------------------------------------------------------------------------- * Language::allow_directors() * ----------------------------------------------------------------------------- */ void Language::allow_directors(int val) { directors = val; } /* ----------------------------------------------------------------------------- * Language::directorsEnabled() * ----------------------------------------------------------------------------- */ int Language::directorsEnabled() const { return director_language && CPlusPlus && (directors || director_mode); } /* ----------------------------------------------------------------------------- * Language::allow_dirprot() * ----------------------------------------------------------------------------- */ void Language::allow_dirprot(int val) { director_protected_mode = val; } /* ----------------------------------------------------------------------------- * Language::allow_allprotected() * ----------------------------------------------------------------------------- */ void Language::allow_allprotected(int val) { all_protected_mode = val; } /* ----------------------------------------------------------------------------- * Language::dirprot_mode() * ----------------------------------------------------------------------------- */ int Language::dirprot_mode() const { return directorsEnabled() ? director_protected_mode : 0; } /* ----------------------------------------------------------------------------- * Language::need_nonpublic_ctor() * ----------------------------------------------------------------------------- */ int Language::need_nonpublic_ctor(Node *n) { /* detects when a protected constructor is needed, which is always the case if 'dirprot' mode is used. However, if that is not the case, we will try to strictly emit what is minimal to don't break the generated, while preserving compatibility with java, which always try to emit the default constructor. rules: - when dirprot mode is used, the protected constructors are always needed. - the protected default constructor is always needed. - if dirprot mode is not used, the protected constructors will be needed only if: - there is no any public constructor in the class, and - there is no protected default constructor In that case, all the declared protected constructors are needed since we don't know which one to pick up. Note: given all the complications here, I am always in favor to always enable 'dirprot', since is the C++ idea of protected members, and use %ignore for the method you don't whan to add in the director class. */ if (directorsEnabled()) { if (is_protected(n)) { if (dirprot_mode()) { /* when using dirprot mode, the protected constructors are always needed */ return 1; } else { int is_default_ctor = !ParmList_numrequired(Getattr(n, "parms")); if (is_default_ctor) { /* the default protected constructor is always needed, for java compatibility */ return 1; } else { /* check if there is a public constructor */ Node *parent = Swig_methodclass(n); int public_ctor = Getattr(parent, "allocate:default_constructor") || Getattr(parent, "allocate:public_constructor"); if (!public_ctor) { /* if not, the protected constructor will be needed only if there is no protected default constructor declared */ int no_prot_default_ctor = !Getattr(parent, "allocate:default_base_constructor"); return no_prot_default_ctor; } } } } } return 0; } /* ----------------------------------------------------------------------------- * Language::need_nonpublic_member() * ----------------------------------------------------------------------------- */ int Language::need_nonpublic_member(Node *n) { if (directorsEnabled() && DirectorClassName) { if (is_protected(n)) { if (dirprot_mode()) { /* when using dirprot mode, the protected members are always needed. */ return 1; } else { /* if the method is pure virtual, we need it. */ int pure_virtual = (Cmp(Getattr(n, "value"), "0") == 0); return pure_virtual; } } } return 0; } /* ----------------------------------------------------------------------------- * Language::is_smart_pointer() * ----------------------------------------------------------------------------- */ int Language::is_smart_pointer() const { return SmartPointer; } /* ----------------------------------------------------------------------------- * Language::() * ----------------------------------------------------------------------------- */ bool Language::isNonVirtualProtectedAccess(Node *n) const { // Ideally is_non_virtual_protected_access() would contain all this logic, see // comments therein about vtable. return DirectorClassName && is_non_virtual_protected_access(n); } /* ----------------------------------------------------------------------------- * Language::extraDirectorProtectedCPPMethodsRequired() * ----------------------------------------------------------------------------- */ bool Language::extraDirectorProtectedCPPMethodsRequired() const { return true; } Language::NestedClassSupport Language::nestedClassesSupport() const { return NCS_Unknown; } /* ----------------------------------------------------------------------------- * Language::is_wrapping_class() * ----------------------------------------------------------------------------- */ int Language::is_wrapping_class() const { return InClass; } /* ----------------------------------------------------------------------------- * Language::getCurrentClass() * ----------------------------------------------------------------------------- */ Node *Language::getCurrentClass() const { return CurrentClass; } /* ----------------------------------------------------------------------------- * Language::getNSpace() * ----------------------------------------------------------------------------- */ String *Language::getNSpace() const { return NSpace; } /* ----------------------------------------------------------------------------- * Language::getClassName() * ----------------------------------------------------------------------------- */ String *Language::getClassName() const { return ClassName; } /* ----------------------------------------------------------------------------- * Language::getClassPrefix() * ----------------------------------------------------------------------------- */ String *Language::getClassPrefix() const { return ClassPrefix; } /* ----------------------------------------------------------------------------- * Language::getClassType() * ----------------------------------------------------------------------------- */ String *Language::getClassType() const { return ClassType; } /* ----------------------------------------------------------------------------- * Language::abstractClassTest() * ----------------------------------------------------------------------------- */ //#define SWIG_DEBUG int Language::abstractClassTest(Node *n) { /* check for non public operator new */ if (GetFlag(n, "feature:notabstract")) return 0; if (Getattr(n, "allocate:nonew")) return 1; /* now check for the rest */ List *abstracts = Getattr(n, "abstracts"); if (!abstracts) return 0; int labs = Len(abstracts); #ifdef SWIG_DEBUG List *bases = Getattr(n, "allbases"); Printf(stderr, "testing %s %d %d\n", Getattr(n, "name"), labs, Len(bases)); #endif if (!labs) return 0; /*strange, but need to be fixed */ if (abstracts && !directorsEnabled()) return 1; if (!GetFlag(n, "feature:director")) return 1; Node *dirabstract = 0; Node *vtable = Getattr(n, "vtable"); if (vtable) { #ifdef SWIG_DEBUG Printf(stderr, "vtable %s %d %d\n", Getattr(n, "name"), Len(vtable), labs); #endif for (int i = 0; i < labs; i++) { Node *ni = Getitem(abstracts, i); Node *method_id = vtable_method_id(ni); if (!method_id) continue; bool exists_item = false; int len = Len(vtable); for (int i = 0; i < len; i++) { Node *item = Getitem(vtable, i); String *check_item = Getattr(item, "vmid"); if (Strcmp(method_id, check_item) == 0) { exists_item = true; break; } } #ifdef SWIG_DEBUG Printf(stderr, "method %s %d\n", method_id, exists_item ? 1 : 0); #endif Delete(method_id); if (!exists_item) { dirabstract = ni; break; } } if (dirabstract) { if (is_public(dirabstract)) { Swig_warning(WARN_LANG_DIRECTOR_ABSTRACT, Getfile(n), Getline(n), "Director class '%s' is abstract, abstract method '%s' is not accesible, maybe due to multiple inheritance or 'nodirector' feature\n", SwigType_namestr(Getattr(n, "name")), Getattr(dirabstract, "name")); } else { Swig_warning(WARN_LANG_DIRECTOR_ABSTRACT, Getfile(n), Getline(n), "Director class '%s' is abstract, abstract method '%s' is private\n", SwigType_namestr(Getattr(n, "name")), Getattr(dirabstract, "name")); } return 1; } } else { return 1; } return 0; } void Language::setSubclassInstanceCheck(String *nc) { none_comparison = nc; } void Language::setOverloadResolutionTemplates(String *argc, String *argv) { Delete(argc_template_string); argc_template_string = Copy(argc); Delete(argv_template_string); argv_template_string = Copy(argv); } int Language::is_assignable(Node *n) { if (GetFlag(n, "feature:immutable")) return 0; SwigType *type = Getattr(n, "type"); Node *cn = 0; SwigType *ftd = SwigType_typedef_resolve_all(type); SwigType *td = SwigType_strip_qualifiers(ftd); if (SwigType_type(td) == T_USER) { cn = Swig_symbol_clookup(td, 0); if (cn) { if ((Strcmp(nodeType(cn), "class") == 0)) { if (Getattr(cn, "allocate:noassign")) { SetFlag(n, "feature:immutable"); Delete(ftd); Delete(td); return 0; } } } } Delete(ftd); Delete(td); return 1; } String *Language::runtimeCode() { return NewString(""); } String *Language::defaultExternalRuntimeFilename() { return 0; } /* ----------------------------------------------------------------------------- * Language::replaceSpecialVariables() * Language modules should implement this if special variables are to be handled * correctly in the $typemap(...) special variable macro. * method - typemap method name * tm - string containing typemap contents * parm - a parameter describing the typemap type to be handled * ----------------------------------------------------------------------------- */ void Language::replaceSpecialVariables(String *method, String *tm, Parm *parm) { (void)method; (void)tm; (void)parm; } Language *Language::instance() { return this_; } Hash *Language::getClassHash() const { return classhash; } swig-3.0.2/Source/Modules/xml.cxx0000664000175000017500000002071312343605122016542 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * xml.cxx * * An Xml parse tree generator. * ----------------------------------------------------------------------------- */ #include "swigmod.h" static const char *usage = "\ XML Options (available with -xml)\n\ -xmllang - Typedef language\n\ -xmllite - More lightweight version of XML\n\ ------\n\ deprecated (use -o): -xml - Use as output file (extension .xml mandatory)\n"; static File *out = 0; static int xmllite = 0; class XML:public Language { public: int indent_level; long id; XML() :indent_level(0) , id(0) { } virtual ~ XML() { } virtual void main(int argc, char *argv[]) { SWIG_typemap_lang("xml"); for (int iX = 0; iX < argc; iX++) { if (strcmp(argv[iX], "-xml") == 0) { char *extension = 0; if (iX + 1 >= argc) continue; extension = argv[iX + 1] + strlen(argv[iX + 1]) - 4; if (strcmp(extension, ".xml")) continue; iX++; Swig_mark_arg(iX); String *outfile = NewString(argv[iX]); out = NewFile(outfile, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } continue; } if (strcmp(argv[iX], "-xmllang") == 0) { Swig_mark_arg(iX); iX++; SWIG_typemap_lang(argv[iX]); Swig_mark_arg(iX); continue; } if (strcmp(argv[iX], "-help") == 0) { fputs(usage, stdout); } if (strcmp(argv[iX], "-xmllite") == 0) { Swig_mark_arg(iX); xmllite = 1; } } // Add a symbol to the parser for conditional compilation Preprocessor_define("SWIGXML 1", 0); } /* Top of the parse tree */ virtual int top(Node *n) { if (out == 0) { String *outfile = Getattr(n, "outfile"); Replaceall(outfile, ".cxx", ".xml"); Replaceall(outfile, ".cpp", ".xml"); Replaceall(outfile, ".c", ".xml"); out = NewFile(outfile, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } } Printf(out, " \n"); Xml_print_tree(n); return SWIG_OK; } void print_indent(int l) { int i; for (i = 0; i < indent_level; i++) { Printf(out, " "); } if (l) { Printf(out, " "); } } void Xml_print_tree(DOH *obj) { while (obj) { Xml_print_node(obj); obj = nextSibling(obj); } } void Xml_print_attributes(Node *obj) { String *k; indent_level += 4; print_indent(0); Printf(out, "\n", ++id, obj); indent_level += 4; Iterator ki; ki = First(obj); while (ki.key) { k = ki.key; if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) || (Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) { /* Do nothing */ } else if (Cmp(k, "module") == 0) { Xml_print_module(Getattr(obj, k)); } else if (Cmp(k, "baselist") == 0) { Xml_print_baselist(Getattr(obj, k)); } else if (!xmllite && Cmp(k, "typescope") == 0) { Xml_print_typescope(Getattr(obj, k)); } else if (!xmllite && Cmp(k, "typetab") == 0) { Xml_print_typetab(Getattr(obj, k)); } else if (Cmp(k, "kwargs") == 0) { Xml_print_kwargs(Getattr(obj, k)); } else if (Cmp(k, "parms") == 0 || Cmp(k, "pattern") == 0) { Xml_print_parmlist(Getattr(obj, k)); } else if (Cmp(k, "catchlist") == 0) { Xml_print_parmlist(Getattr(obj, k), "catchlist"); } else { DOH *o; print_indent(0); if (DohIsString(Getattr(obj, k))) { String *ck = NewString(k); o = Str(Getattr(obj, k)); Replaceall(ck, ":", "_"); Replaceall(ck, "<", "<"); /* Do first to avoid aliasing errors. */ Replaceall(o, "&", "&"); Replaceall(o, "<", "<"); Replaceall(o, "\"", """); Replaceall(o, "\\", "\\\\"); Replaceall(o, "\n", " "); Printf(out, "\n", ck, o, ++id, o); Delete(o); Delete(ck); } else { o = Getattr(obj, k); String *ck = NewString(k); Replaceall(ck, ":", "_"); Printf(out, "\n", ck, o, ++id, o); Delete(ck); } } ki = Next(ki); } indent_level -= 4; print_indent(0); Printf(out, "\n"); indent_level -= 4; } void Xml_print_node(Node *obj) { Node *cobj; print_indent(0); Printf(out, "<%s id=\"%ld\" addr=\"%p\" >\n", nodeType(obj), ++id, obj); Xml_print_attributes(obj); cobj = firstChild(obj); if (cobj) { indent_level += 4; Printf(out, "\n"); Xml_print_tree(cobj); indent_level -= 4; } else { print_indent(1); Printf(out, "\n"); } print_indent(0); Printf(out, "\n", nodeType(obj)); } void Xml_print_parmlist(ParmList *p, const char* markup = "parmlist") { print_indent(0); Printf(out, "<%s id=\"%ld\" addr=\"%p\" >\n", markup, ++id, p); indent_level += 4; while (p) { print_indent(0); Printf(out, "\n", ++id); Xml_print_attributes(p); print_indent(0); Printf(out, "\n"); p = nextSibling(p); } indent_level -= 4; print_indent(0); Printf(out, "\n", markup); } void Xml_print_baselist(List *p) { print_indent(0); Printf(out, "\n", ++id, p); indent_level += 4; Iterator s; for (s = First(p); s.item; s = Next(s)) { print_indent(0); String *item_name = Xml_escape_string(s.item); Printf(out, "\n", item_name, ++id, s.item); Delete(item_name); } indent_level -= 4; print_indent(0); Printf(out, "\n"); } String *Xml_escape_string(String *str) { String *escaped_str = 0; if (str) { escaped_str = NewString(str); Replaceall(escaped_str, "&", "&"); Replaceall(escaped_str, "<", "<"); Replaceall(escaped_str, "\"", """); Replaceall(escaped_str, "\\", "\\\\"); Replaceall(escaped_str, "\n", " "); } return escaped_str; } void Xml_print_module(Node *p) { print_indent(0); Printf(out, "\n", Getattr(p, "name"), ++id, p); } void Xml_print_kwargs(Hash *p) { Xml_print_hash(p, "kwargs"); } void Xml_print_typescope(Hash *p) { Xml_print_hash(p, "typescope"); } void Xml_print_typetab(Hash *p) { Xml_print_hash(p, "typetab"); } void Xml_print_hash(Hash *p, const char *markup) { print_indent(0); Printf(out, "<%s id=\"%ld\" addr=\"%p\" >\n", markup, ++id, p); Xml_print_attributes(p); indent_level += 4; Iterator n = First(p); while (n.key) { print_indent(0); Printf(out, "<%ssitem id=\"%ld\" addr=\"%p\" >\n", markup, ++id, n.item); Xml_print_attributes(n.item); print_indent(0); Printf(out, "\n", markup); n = Next(n); } indent_level -= 4; print_indent(0); Printf(out, "\n", markup); } }; /* ----------------------------------------------------------------------------- * Swig_print_xml * * Dump an XML version of the parse tree. This is different from using the -xml * language module normally as it allows the real language module to process the * tree first, possibly stuffing in new attributes, so the XML that is output ends * up being a post-processing version of the tree. * ----------------------------------------------------------------------------- */ void Swig_print_xml(DOH *obj, String *filename) { XML xml; xmllite = 1; if (!filename) { out = stdout; } else { out = NewFile(filename, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(filename); SWIG_exit(EXIT_FAILURE); } } Printf(out, " \n"); xml.Xml_print_tree(obj); } static Language *new_swig_xml() { return new XML(); } extern "C" Language *swig_xml(void) { return new_swig_xml(); } swig-3.0.2/Source/Modules/swigmain.cxx0000664000175000017500000001367512343605122017571 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swigmain.cxx * * Simplified Wrapper and Interface Generator (SWIG) * * This file is the main entry point to SWIG. It collects the command * line options, registers built-in language modules, and instantiates * a module for code generation. If adding new language modules * to SWIG, you would modify this file. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include /* Module factories. These functions are used to instantiate the built-in language modules. If adding a new language module to SWIG, place a similar function here. Make sure the function has "C" linkage. This is required so that modules can be dynamically loaded in future versions. */ extern "C" { Language *swig_tcl(void); Language *swig_python(void); Language *swig_perl5(void); Language *swig_ruby(void); Language *swig_guile(void); Language *swig_modula3(void); Language *swig_mzscheme(void); Language *swig_java(void); Language *swig_php(void); Language *swig_php4(void); Language *swig_ocaml(void); Language *swig_octave(void); Language *swig_pike(void); Language *swig_sexp(void); Language *swig_xml(void); Language *swig_chicken(void); Language *swig_csharp(void); Language *swig_allegrocl(void); Language *swig_lua(void); Language *swig_clisp(void); Language *swig_cffi(void); Language *swig_uffi(void); Language *swig_r(void); Language *swig_go(void); Language *swig_d(void); Language *swig_javascript(void); } struct swig_module { const char *name; ModuleFactory fac; const char *help; }; /* Association of command line options to language modules. Place an entry for new language modules here, keeping the list sorted alphabetically. */ static swig_module modules[] = { {"-allegrocl", swig_allegrocl, "ALLEGROCL"}, {"-chicken", swig_chicken, "CHICKEN"}, {"-clisp", swig_clisp, "CLISP"}, {"-cffi", swig_cffi, "CFFI"}, {"-csharp", swig_csharp, "C#"}, {"-d", swig_d, "D"}, {"-go", swig_go, "Go"}, {"-guile", swig_guile, "Guile"}, {"-java", swig_java, "Java"}, {"-javascript", swig_javascript, "Javascript"}, {"-lua", swig_lua, "Lua"}, {"-modula3", swig_modula3, "Modula 3"}, {"-mzscheme", swig_mzscheme, "Mzscheme"}, {"-ocaml", swig_ocaml, "Ocaml"}, {"-octave", swig_octave, "Octave"}, {"-perl", swig_perl5, "Perl"}, {"-perl5", swig_perl5, 0}, {"-php", swig_php, "PHP"}, {"-php4", swig_php4, 0}, {"-php5", swig_php, 0}, {"-pike", swig_pike, "Pike"}, {"-python", swig_python, "Python"}, {"-r", swig_r, "R (aka GNU S)"}, {"-ruby", swig_ruby, "Ruby"}, {"-sexp", swig_sexp, "Lisp S-Expressions"}, {"-tcl", swig_tcl, "Tcl"}, {"-tcl8", swig_tcl, 0}, {"-uffi", swig_uffi, "Common Lisp / UFFI"}, {"-xml", swig_xml, "XML"}, {NULL, NULL, NULL} }; #ifdef MACSWIG #include #include #endif #ifndef SWIG_LANG #define SWIG_LANG "-python" #endif //----------------------------------------------------------------- // main() // // Main program. Initializes the files and starts the parser. //----------------------------------------------------------------- void SWIG_merge_envopt(const char *env, int oargc, char *oargv[], int *nargc, char ***nargv) { if (!env) { *nargc = oargc; *nargv = oargv; return; } int argc = 1; int arge = oargc + 1024; char **argv = (char **) malloc(sizeof(char *) * (arge)); char *buffer = (char *) malloc(2048); char *b = buffer; char *be = b + 1023; const char *c = env; while ((b != be) && *c && (argc < arge)) { while (isspace(*c) && *c) ++c; if (*c) { argv[argc] = b; ++argc; } while ((b != be) && *c && !isspace(*c)) { *(b++) = *(c++); } *b++ = 0; } argv[0] = oargv[0]; for (int i = 1; (i < oargc) && (argc < arge); ++i, ++argc) { argv[argc] = oargv[i]; } *nargc = argc; *nargv = argv; } int main(int margc, char **margv) { int i; Language *dl = 0; ModuleFactory fac = 0; int argc; char **argv; SWIG_merge_envopt(getenv("SWIG_FEATURES"), margc, margv, &argc, &argv); #ifdef MACSWIG SIOUXSettings.asktosaveonclose = false; argc = ccommand(&argv); #endif /* Register built-in modules */ for (i = 0; modules[i].name; i++) { Swig_register_module(modules[i].name, modules[i].fac); } Swig_init_args(argc, argv); /* Get options */ for (i = 1; i < argc; i++) { if (argv[i]) { fac = Swig_find_module(argv[i]); if (fac) { dl = (fac) (); Swig_mark_arg(i); } else if (strcmp(argv[i], "-nolang") == 0) { dl = new Language; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-dnone") == 0) || (strcmp(argv[i], "-dhtml") == 0) || (strcmp(argv[i], "-dlatex") == 0) || (strcmp(argv[i], "-dascii") == 0) || (strcmp(argv[i], "-stat") == 0)) { Printf(stderr, "swig: Warning. %s option deprecated.\n", argv[i]); Swig_mark_arg(i); } else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) { if (strcmp(argv[i], "--help") == 0) strcpy(argv[i], "-help"); Printf(stdout, "Target Language Options\n"); for (int j = 0; modules[j].name; j++) { if (modules[j].help) { Printf(stdout, " %-15s - Generate %s wrappers\n", modules[j].name, modules[j].help); } } // Swig_mark_arg not called as the general -help options also need to be displayed later on } } } if (!dl) { fac = Swig_find_module(SWIG_LANG); if (fac) { dl = (fac) (); } } int res = SWIG_main(argc, argv, dl); return res; } swig-3.0.2/Source/Modules/php.cxx0000664000175000017500000026402312343605122016535 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * php.cxx * * PHP language module for SWIG. * ----------------------------------------------------------------------------- */ /* FIXME: PHP5 OO wrapping TODO list: * * Medium term: * * Handle default parameters on overloaded methods in PHP where possible. * (Mostly done - just need to handle cases of overloaded methods with * default parameters...) * This is an optimisation - we could handle this case using a PHP * default value, but currently we treat it as we would for a default * value which is a compound C++ expression (i.e. as if we had a * method with two overloaded forms instead of a single method with * a default parameter value). * * Long term: * * Sort out locale-dependent behaviour of strtod() - it's harmless unless * SWIG ever sets the locale and DOH/base.c calls atof, so we're probably * OK currently at least. */ /* * TODO: Replace remaining stderr messages with Swig_error or Swig_warning * (may need to add more WARN_PHP_xxx codes...) */ #include "swigmod.h" #include #include static const char *usage = "\ PHP Options (available with -php)\n\ -cppext - Change C++ file extension to (default is cpp)\n\ -noproxy - Don't generate proxy classes.\n\ -prefix - Prepend to all class names in PHP wrappers\n\ \n"; /* The original class wrappers for PHP stored the pointer to the C++ class in * the object property _cPtr. If we use the same name for the member variable * which we put the pointer to the C++ class in, then the flat function * wrappers will automatically pull it out without any changes being required. * FIXME: Isn't using a leading underscore a bit suspect here? */ #define SWIG_PTR "_cPtr" /* This is the name of the hash where the variables existing only in PHP * classes are stored. */ #define SWIG_DATA "_pData" static int constructors = 0; static String *NOTCLASS = NewString("Not a class"); static Node *classnode = 0; static String *module = 0; static String *cap_module = 0; static String *prefix = 0; static String *shadow_classname = 0; static File *f_begin = 0; static File *f_runtime = 0; static File *f_runtime_h = 0; static File *f_h = 0; static File *f_phpcode = 0; static File *f_directors = 0; static File *f_directors_h = 0; static String *phpfilename = 0; static String *s_header; static String *s_wrappers; static String *s_init; static String *r_init; // RINIT user code static String *s_shutdown; // MSHUTDOWN user code static String *r_shutdown; // RSHUTDOWN user code static String *s_vinit; // varinit initialization code. static String *s_vdecl; static String *s_cinit; // consttab initialization code. static String *s_oinit; static String *s_arginfo; static String *s_entry; static String *cs_entry; static String *all_cs_entry; static String *pragma_incl; static String *pragma_code; static String *pragma_phpinfo; static String *s_oowrappers; static String *s_fakeoowrappers; static String *s_phpclasses; /* Variables for using PHP classes */ static Node *current_class = 0; static Hash *shadow_get_vars; static Hash *shadow_set_vars; static Hash *zend_types = 0; static int shadow = 1; static bool class_has_ctor = false; static String *wrapping_member_constant = NULL; // These static variables are used to pass some state from Handlers into functionWrapper static enum { standard = 0, memberfn, staticmemberfn, membervar, staticmembervar, constructor, directorconstructor } wrapperType = standard; extern "C" { static void (*r_prevtracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0; } static void SwigPHP_emit_resource_registrations() { Iterator ki; if (!zend_types) return; ki = First(zend_types); if (ki.key) Printf(s_oinit, "\n/* Register resource destructors for pointer types */\n"); while (ki.key) { DOH *key = ki.key; Node *class_node = ki.item; String *human_name = key; // Write out destructor function header Printf(s_wrappers, "static ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); // write out body if (class_node != NOTCLASS) { String *destructor = Getattr(class_node, "destructor"); human_name = Getattr(class_node, "sym:name"); if (!human_name) human_name = Getattr(class_node, "name"); // Do we have a known destructor for this type? if (destructor) { Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key); } else { Printf(s_wrappers, " /* No destructor for class %s */\n", human_name); Printf(s_wrappers, " efree(rsrc->ptr);\n"); } } else { Printf(s_wrappers, " /* No destructor for simple type %s */\n", key); Printf(s_wrappers, " efree(rsrc->ptr);\n"); } // close function Printf(s_wrappers, "}\n"); // declare le_swig_ to store php registration Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); // register with php Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key); // store php type in class struct Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); ki = Next(ki); } } class PHP : public Language { String *emit_action(Node *n) { // Adjust wrap:action to add TSRMLS_CC. String * action = Getattr(n, "wrap:action"); if (action) { char * p = Strstr(action, "Swig::DirectorPureVirtualException::raise(\""); if (p) { p += strlen("Swig::DirectorPureVirtualException::raise(\""); p = strchr(p, '"'); if (p) { ++p; Insert(action, p - Char(action), " TSRMLS_CC"); } } } return ::emit_action(n); } public: PHP() { director_language = 1; } /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { SWIG_library_directory("php"); SWIG_config_cppext("cpp"); for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "-prefix") == 0) { if (argv[i + 1]) { prefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-cppext") == 0) { if (argv[i + 1]) { SWIG_config_cppext(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) { shadow = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); } else if (strcmp(argv[i], "-make") == 0 || strcmp(argv[i], "-withc") == 0 || strcmp(argv[i], "-withcxx") == 0) { Printf(stderr, "*** %s is no longer supported.\n", argv[i]); SWIG_exit(EXIT_FAILURE); } else if (strcmp(argv[i], "-phpfull") == 0 || strcmp(argv[i], "-withlibs") == 0 || strcmp(argv[i], "-withincs") == 0) { Printf(stderr, "*** %s is no longer supported.\n*** We recommend building as a dynamically loadable module.\n", argv[i]); SWIG_exit(EXIT_FAILURE); } else if (strcmp(argv[i], "-dlname") == 0) { Printf(stderr, "*** -dlname is no longer supported.\n*** If you want to change the module name, use -module instead.\n"); SWIG_exit(EXIT_FAILURE); } } Preprocessor_define("SWIGPHP 1", 0); // SWIGPHP5 is deprecated, and no longer documented. Preprocessor_define("SWIGPHP5 1", 0); SWIG_typemap_lang("php"); SWIG_config_file("php.swg"); allow_overloading(); } /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ virtual int top(Node *n) { String *filen; /* Check if directors are enabled for this module. */ Node *mod = Getattr(n, "module"); if (mod) { Node *options = Getattr(mod, "options"); if (options && Getattr(options, "directors")) { allow_directors(); } } /* Set comparison with null for ConstructorToFunction */ setSubclassInstanceCheck(NewString("$arg->type != IS_NULL")); /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); String *outfile_h = Getattr(n, "outfile_h"); /* main output file */ f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewStringEmpty(); /* sections of the output file */ s_init = NewString("/* init section */\n"); r_init = NewString("/* rinit section */\n"); s_shutdown = NewString("/* shutdown section */\n"); r_shutdown = NewString("/* rshutdown section */\n"); s_header = NewString("/* header section */\n"); s_wrappers = NewString("/* wrapper section */\n"); /* subsections of the init section */ s_vinit = NewString("/* vinit subsection */\n"); s_vdecl = NewString("/* vdecl subsection */\n"); s_cinit = NewString("/* cinit subsection */\n"); s_oinit = NewString("/* oinit subsection */\n"); pragma_phpinfo = NewStringEmpty(); s_phpclasses = NewString("/* PHP Proxy Classes */\n"); f_directors_h = NewStringEmpty(); f_directors = NewStringEmpty(); if (directorsEnabled()) { f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); } } /* Register file targets with the SWIG file handler */ Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", s_init); Swig_register_filebyname("rinit", r_init); Swig_register_filebyname("shutdown", s_shutdown); Swig_register_filebyname("rshutdown", r_shutdown); Swig_register_filebyname("header", s_header); Swig_register_filebyname("wrapper", s_wrappers); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPHP\n"); Printf(f_runtime, "\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } /* Set the module name */ module = Copy(Getattr(n, "name")); cap_module = NewStringf("%(upper)s", module); if (!prefix) prefix = NewStringEmpty(); Printf(f_runtime, "#define SWIG_PREFIX \"%s\"\n", prefix); Printf(f_runtime, "#define SWIG_PREFIX_LEN %lu\n", (unsigned long)Len(prefix)); if (directorsEnabled()) { Swig_banner(f_directors_h); Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", cap_module); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", cap_module); String *filename = Swig_file_filename(outfile_h); Printf(f_directors, "\n#include \"%s\"\n\n", filename); Delete(filename); } /* PHP module file */ filen = NewStringEmpty(); Printv(filen, SWIG_output_directory(), module, ".php", NIL); phpfilename = NewString(filen); f_phpcode = NewFile(filen, "w", SWIG_output_files()); if (!f_phpcode) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Printf(f_phpcode, "error_msg = default_error_msg;\n"); Printf(s_header, " globals->error_code = default_error_code;\n"); Printf(s_header, "}\n"); Printf(s_header, "static void %s_destroy_globals(zend_%s_globals * globals) { (void)globals; }\n", module, module); Printf(s_header, "\n"); Printf(s_header, "static void SWIG_ResetError(TSRMLS_D) {\n"); Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n"); Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n"); Printf(s_header, "}\n"); Append(s_header, "\n"); Printf(s_header, "ZEND_NAMED_FUNCTION(_wrap_swig_%s_alter_newobject) {\n", module); Append(s_header, " zval **args[2];\n"); Append(s_header, " swig_object_wrapper *value;\n"); Append(s_header, " int type;\n"); Append(s_header, "\n"); Append(s_header, " SWIG_ResetError(TSRMLS_C);\n"); Append(s_header, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n"); Append(s_header, " WRONG_PARAM_COUNT;\n"); Append(s_header, " }\n"); Append(s_header, "\n"); Append(s_header, " value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type);\n"); Append(s_header, " value->newobject = zval_is_true(*args[1]);\n"); Append(s_header, "\n"); Append(s_header, " return;\n"); Append(s_header, "}\n"); Printf(s_header, "ZEND_NAMED_FUNCTION(_wrap_swig_%s_get_newobject) {\n", module); Append(s_header, " zval **args[1];\n"); Append(s_header, " swig_object_wrapper *value;\n"); Append(s_header, " int type;\n"); Append(s_header, "\n"); Append(s_header, " SWIG_ResetError(TSRMLS_C);\n"); Append(s_header, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n"); Append(s_header, " WRONG_PARAM_COUNT;\n"); Append(s_header, " }\n"); Append(s_header, "\n"); Append(s_header, " value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type);\n"); Append(s_header, " RETVAL_LONG(value->newobject);\n"); Append(s_header, "\n"); Append(s_header, " return;\n"); Append(s_header, "}\n"); Printf(s_header, "#define SWIG_name \"%s\"\n", module); Printf(s_header, "#ifdef __cplusplus\n"); Printf(s_header, "extern \"C\" {\n"); Printf(s_header, "#endif\n"); Printf(s_header, "#include \"php.h\"\n"); Printf(s_header, "#include \"php_ini.h\"\n"); Printf(s_header, "#include \"ext/standard/info.h\"\n"); Printf(s_header, "#include \"php_%s.h\"\n", module); Printf(s_header, "#ifdef __cplusplus\n"); Printf(s_header, "}\n"); Printf(s_header, "#endif\n\n"); if (directorsEnabled()) { // Insert director runtime Swig_insert_file("director.swg", s_header); } /* Create the .h file too */ filen = NewStringEmpty(); Printv(filen, SWIG_output_directory(), "php_", module, ".h", NIL); f_h = NewFile(filen, "w", SWIG_output_files()); if (!f_h) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Swig_banner(f_h); Printf(f_h, "\n"); Printf(f_h, "#ifndef PHP_%s_H\n", cap_module); Printf(f_h, "#define PHP_%s_H\n\n", cap_module); Printf(f_h, "extern zend_module_entry %s_module_entry;\n", module); Printf(f_h, "#define phpext_%s_ptr &%s_module_entry\n\n", module, module); Printf(f_h, "#ifdef PHP_WIN32\n"); Printf(f_h, "# define PHP_%s_API __declspec(dllexport)\n", cap_module); Printf(f_h, "#else\n"); Printf(f_h, "# define PHP_%s_API\n", cap_module); Printf(f_h, "#endif\n\n"); Printf(f_h, "#ifdef ZTS\n"); Printf(f_h, "#include \"TSRM.h\"\n"); Printf(f_h, "#endif\n\n"); Printf(f_h, "PHP_MINIT_FUNCTION(%s);\n", module); Printf(f_h, "PHP_MSHUTDOWN_FUNCTION(%s);\n", module); Printf(f_h, "PHP_RINIT_FUNCTION(%s);\n", module); Printf(f_h, "PHP_RSHUTDOWN_FUNCTION(%s);\n", module); Printf(f_h, "PHP_MINFO_FUNCTION(%s);\n\n", module); /* start the arginfo section */ s_arginfo = NewString("/* arginfo subsection */\n"); /* start the function entry section */ s_entry = NewString("/* entry subsection */\n"); /* holds all the per-class function entry sections */ all_cs_entry = NewString("/* class entry subsection */\n"); cs_entry = NULL; Printf(s_entry, "/* Every non-class user visible function must have an entry here */\n"); Printf(s_entry, "static zend_function_entry %s_functions[] = {\n", module); /* start the init section */ Append(s_init, "#if ZEND_MODULE_API_NO <= 20090626\n"); Append(s_init, "#undef ZEND_MODULE_BUILD_ID\n"); Append(s_init, "#define ZEND_MODULE_BUILD_ID (char*)\"API\" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA\n"); Append(s_init, "#endif\n"); Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n", NIL); Printf(s_init, " STANDARD_MODULE_HEADER,\n"); Printf(s_init, " (char*)\"%s\",\n", module); Printf(s_init, " %s_functions,\n", module); Printf(s_init, " PHP_MINIT(%s),\n", module); Printf(s_init, " PHP_MSHUTDOWN(%s),\n", module); Printf(s_init, " PHP_RINIT(%s),\n", module); Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module); Printf(s_init, " PHP_MINFO(%s),\n", module); Printf(s_init, " NO_VERSION_YET,\n"); Printf(s_init, " STANDARD_MODULE_PROPERTIES\n"); Printf(s_init, "};\n"); Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module); Printf(s_init, "#ifdef __cplusplus\n"); Printf(s_init, "extern \"C\" {\n"); Printf(s_init, "#endif\n"); // We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but ZEND_GET_MODULE // in PHP5 has "extern "C" { ... }" around it so we can't do that. Printf(s_init, "SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\n", module); Printf(s_init, "#ifdef __cplusplus\n"); Printf(s_init, "}\n"); Printf(s_init, "#endif\n\n"); /* We have to register the constants before they are (possibly) used * by the pointer typemaps. This all needs re-arranging really as * things are being called in the wrong order */ Printf(s_init, "#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module); /* Emit all of the code */ Language::top(n); SwigPHP_emit_resource_registrations(); // Printv(s_init,s_resourcetypes,NIL); /* We need this after all classes written out by ::top */ Printf(s_oinit, "CG(active_class_entry) = NULL;\n"); Printf(s_oinit, "/* end oinit subsection */\n"); Printf(s_init, "%s\n", s_oinit); /* Constants generated during top call */ Printf(s_cinit, "/* end cinit subsection */\n"); Printf(s_init, "%s\n", s_cinit); Clear(s_cinit); Delete(s_cinit); Printf(s_init, " return SUCCESS;\n"); Printf(s_init, "}\n\n"); // Now do REQUEST init which holds any user specified %rinit, and also vinit Printf(s_init, "PHP_RINIT_FUNCTION(%s)\n{\n", module); Printf(s_init, "%s\n", r_init); /* finish our init section which will have been used by class wrappers */ Printf(s_vinit, "/* end vinit subsection */\n"); Printf(s_init, "%s\n", s_vinit); Clear(s_vinit); Delete(s_vinit); Printf(s_init, " return SUCCESS;\n"); Printf(s_init, "}\n\n"); Printv(s_init, "PHP_MSHUTDOWN_FUNCTION(", module, ")\n" "{\n", s_shutdown, "#ifdef ZTS\n" " ts_free_id(", module, "_globals_id);\n" "#endif\n" " return SUCCESS;\n" "}\n\n", NIL); Printf(s_init, "PHP_RSHUTDOWN_FUNCTION(%s)\n{\n", module); Printf(s_init, "%s\n", r_shutdown); Printf(s_init, " return SUCCESS;\n"); Printf(s_init, "}\n\n"); Printf(s_init, "PHP_MINFO_FUNCTION(%s)\n{\n", module); Printf(s_init, "%s", pragma_phpinfo); Printf(s_init, "}\n"); Printf(s_init, "/* end init section */\n"); Printf(f_h, "#endif /* PHP_%s_H */\n", cap_module); Delete(f_h); String *type_table = NewStringEmpty(); SwigType_emit_type_table(f_runtime, type_table); Printf(s_header, "%s", type_table); Delete(type_table); /* Oh dear, more things being called in the wrong order. This whole * function really needs totally redoing. */ if (directorsEnabled()) { Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); Delete(f_runtime_h); } Printf(s_header, "/* end header section */\n"); Printf(s_wrappers, "/* end wrapper section */\n"); Printf(s_vdecl, "/* end vdecl subsection */\n"); Dump(f_runtime, f_begin); Printv(f_begin, s_header, NIL); if (directorsEnabled()) { Dump(f_directors, f_begin); } Printv(f_begin, s_vdecl, s_wrappers, NIL); Printv(f_begin, all_cs_entry, "\n\n", s_arginfo, "\n\n", s_entry, " SWIG_ZEND_NAMED_FE(swig_", module, "_alter_newobject,_wrap_swig_", module, "_alter_newobject,NULL)\n" " SWIG_ZEND_NAMED_FE(swig_", module, "_get_newobject,_wrap_swig_", module, "_get_newobject,NULL)\n" "{NULL, NULL, NULL}\n};\n\n", NIL); Printv(f_begin, s_init, NIL); Delete(s_header); Delete(s_wrappers); Delete(s_init); Delete(s_vdecl); Delete(all_cs_entry); Delete(s_entry); Delete(s_arginfo); Delete(f_runtime); Delete(f_begin); Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code); if (s_fakeoowrappers) { Printf(f_phpcode, "abstract class %s {", Len(prefix) ? prefix : module); Printf(f_phpcode, "%s", s_fakeoowrappers); Printf(f_phpcode, "}\n\n"); Delete(s_fakeoowrappers); s_fakeoowrappers = NULL; } Printf(f_phpcode, "%s\n?>\n", s_phpclasses); Delete(f_phpcode); return SWIG_OK; } /* Just need to append function names to function table to register with PHP. */ void create_command(String *cname, String *iname, Node *n) { // This is for the single main zend_function_entry record Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", iname); String * s = cs_entry; if (!s) s = s_entry; Printf(s, " SWIG_ZEND_NAMED_FE(%(lower)s,%s,swig_arginfo_%(lower)s)\n", cname, iname, cname); // This is the above referenced arginfo structure. ParmList *l = Getattr(n, "parms"); Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%(lower)s, 0, 0, 0)\n", cname); for (Parm *p = l; p; p = Getattr(p, "tmap:in:next")) { /* Ignored parameters */ if (checkAttribute(p, "tmap:in:numinputs", "0")) { continue; } int byref = GetFlag(p, "tmap:in:byref"); Printf(s_arginfo, " ZEND_ARG_PASS_INFO(%d)\n", byref); } Printf(s_arginfo, "ZEND_END_ARG_INFO()\n"); } /* ------------------------------------------------------------ * dispatchFunction() * ------------------------------------------------------------ */ void dispatchFunction(Node *n) { /* Last node in overloaded chain */ int maxargs; String *tmp = NewStringEmpty(); if (Swig_directorclass(n) && wrapperType == directorconstructor) { /* We have an extra 'this' parameter. */ SetFlag(n, "wrap:this"); } String *dispatch = Swig_overload_dispatch(n, "%s(INTERNAL_FUNCTION_PARAM_PASSTHRU); return;", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *f = NewWrapper(); String *symname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(symname); create_command(symname, wname, n); Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); Wrapper_add_local(f, "argc", "int argc"); Printf(tmp, "zval **argv[%d]", maxargs); Wrapper_add_local(f, "argv", tmp); Printf(f->code, "argc = ZEND_NUM_ARGS();\n"); Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); Replaceall(dispatch, "$args", "self,args"); Printv(f->code, dispatch, "\n", NIL); Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n"); Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname); Printv(f->code, "SWIG_FAIL(TSRMLS_C);\n", NIL); Printv(f->code, "}\n", NIL); Wrapper_print(f, s_wrappers); DelWrapper(f); Delete(dispatch); Delete(tmp); Delete(wname); } /* ------------------------------------------------------------ * functionWrapper() * ------------------------------------------------------------ */ /* Helper method for PHP::functionWrapper */ bool is_class(SwigType *t) { Node *n = classLookup(t); if (n) { String *r = Getattr(n, "php:proxy"); // Set by classDeclaration() if (!r) r = Getattr(n, "sym:name"); // Not seen by classDeclaration yet, but this is the name if (r) return true; } return false; } virtual int functionWrapper(Node *n) { String *name = GetChar(n, "name"); String *iname = GetChar(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *nodeType = Getattr(n, "nodeType"); int newobject = GetFlag(n, "feature:new"); int constructor = (Cmp(nodeType, "constructor") == 0); Parm *p; int i; int numopt; String *tm; Wrapper *f; String *wname; int overloaded = 0; String *overname = 0; if (Cmp(nodeType, "destructor") == 0) { // We just generate the Zend List Destructor and let Zend manage the // reference counting. There's no explicit destructor, but the user can // just do `$obj = null;' to remove a reference to an object. return CreateZendListDestructor(n); } // Test for overloading; if (Getattr(n, "sym:overloaded")) { overloaded = 1; overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) return SWIG_ERROR; } wname = Swig_name_wrapper(iname); if (overname) { Printf(wname, "%s", overname); } f = NewWrapper(); String *outarg = NewStringEmpty(); String *cleanup = NewStringEmpty(); Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); emit_parameter_variables(l, f); /* Attach standard typemaps */ emit_attach_parmmaps(l, f); // Not issued for overloaded functions. if (!overloaded) { create_command(iname, wname, n); } // wrap:parms is used by overload resolution. Setattr(n, "wrap:parms", l); int num_arguments = emit_num_arguments(l); int num_required = emit_num_required(l); numopt = num_arguments - num_required; if (wrapperType == directorconstructor) num_arguments++; if (num_arguments > 0) { String *args = NewStringEmpty(); if (wrapperType == directorconstructor) Wrapper_add_local(f, "arg0", "zval *arg0"); Printf(args, "zval **args[%d]", num_arguments); Wrapper_add_local(f, "args", args); Delete(args); args = NULL; } if (is_member_director(n)) { Wrapper_add_local(f, "director", "Swig::Director *director = 0"); Printf(f->code, "director = dynamic_cast(arg1);\n"); Wrapper_add_local(f, "upcall", "bool upcall = false"); Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\");\n", prefix, Swig_class_name(Swig_methodclass(n)), name); } // This generated code may be called: // 1) as an object method, or // 2) as a class-method/function (without a "this_ptr") // Option (1) has "this_ptr" for "this", option (2) needs it as // first parameter // NOTE: possible we ignore this_ptr as a param for native constructor Printf(f->code, "SWIG_ResetError(TSRMLS_C);\n"); if (numopt > 0) { // membervariable wrappers do not have optional args Wrapper_add_local(f, "arg_count", "int arg_count"); Printf(f->code, "arg_count = ZEND_NUM_ARGS();\n"); Printf(f->code, "if(arg_count<%d || arg_count>%d ||\n", num_required, num_arguments); Printf(f->code, " zend_get_parameters_array_ex(arg_count,args)!=SUCCESS)\n"); Printf(f->code, "\tWRONG_PARAM_COUNT;\n\n"); } else { if (num_arguments == 0) { Printf(f->code, "if(ZEND_NUM_ARGS() != 0) {\n"); } else { Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num_arguments, num_arguments); } Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n"); } if (wrapperType == directorconstructor) Printf(f->code, "arg0 = *args[0];\n \n"); /* Now convert from PHP to C variables */ // At this point, argcount if used is the number of deliberately passed args // not including this_ptr even if it is used. // It means error messages may be out by argbase with error // reports. We can either take argbase into account when raising // errors, or find a better way of dealing with _thisptr. // I would like, if objects are wrapped, to assume _thisptr is always // _this and not the first argument. // This may mean looking at Language::memberfunctionHandler int limit = num_arguments; if (wrapperType == directorconstructor) limit--; for (i = 0, p = l; i < limit; i++) { String *source; /* Skip ignored arguments */ //while (Getattr(p,"tmap:ignore")) { p = Getattr(p,"tmap:ignore:next");} while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); if (wrapperType == directorconstructor) { source = NewStringf("args[%d]", i+1); } else { source = NewStringf("args[%d]", i); } String *ln = Getattr(p, "lname"); /* Check if optional */ if (i >= num_required) { Printf(f->code, "\tif(arg_count > %d) {\n", i); } if ((tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$source", source); Replaceall(tm, "$target", ln); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); Printf(f->code, "%s\n", tm); if (i == 0 && Getattr(p, "self")) { Printf(f->code, "\tif(!arg1) SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");\n"); } p = Getattr(p, "tmap:in:next"); if (i >= num_required) { Printf(f->code, "}\n"); } continue; } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); } if (i >= num_required) { Printf(f->code, "\t}\n"); } Delete(source); } Swig_director_emit_dynamic_cast(n, f); /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ for (i = 0, p = l; p; i++) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ bool hasargout = false; for (i = 0, p = l; p; i++) { if ((tm = Getattr(p, "tmap:argout"))) { hasargout = true; Replaceall(tm, "$source", Getattr(p, "lname")); // Replaceall(tm,"$input",Getattr(p,"lname")); Replaceall(tm, "$target", "return_value"); Replaceall(tm, "$result", "return_value"); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } Setattr(n, "wrap:name", wname); /* emit function call */ String *actioncode = emit_action(n); if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "return_value"); Replaceall(tm, "$result", "return_value"); Replaceall(tm, "$owner", newobject ? "1" : "0"); Printf(f->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); } emit_return_variable(n, d, f); if (outarg) { Printv(f->code, outarg, NIL); } if (cleanup) { Printv(f->code, cleanup, NIL); } /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Printf(f->code, "%s\n", tm); Delete(tm); } } /* See if there is any return cleanup code */ if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Printf(f->code, "%s\n", tm); Delete(tm); } Printf(f->code, "return;\n"); /* Error handling code */ Printf(f->code, "fail:\n"); Printv(f->code, cleanup, NIL); Append(f->code, "SWIG_FAIL(TSRMLS_C);\n"); Printf(f->code, "}\n"); Replaceall(f->code, "$cleanup", cleanup); Replaceall(f->code, "$symname", iname); Wrapper_print(f, s_wrappers); DelWrapper(f); f = NULL; if (overloaded && !Getattr(n, "sym:nextSibling")) { dispatchFunction(n); } Delete(wname); wname = NULL; if (!shadow) { return SWIG_OK; } // Handle getters and setters. if (wrapperType == membervar) { const char *p = Char(iname); if (strlen(p) > 4) { p += strlen(p) - 4; String *varname = Getattr(n, "membervariableHandler:sym:name"); if (strcmp(p, "_get") == 0) { Setattr(shadow_get_vars, varname, Getattr(n, "type")); } else if (strcmp(p, "_set") == 0) { Setattr(shadow_set_vars, varname, iname); } } return SWIG_OK; } // Only look at non-overloaded methods and the last entry in each overload // chain (we check the last so that wrap:parms and wrap:name have been set // for them all). if (overloaded && Getattr(n, "sym:nextSibling") != 0) return SWIG_OK; if (!s_oowrappers) s_oowrappers = NewStringEmpty(); if (newobject || wrapperType == memberfn || wrapperType == staticmemberfn || wrapperType == standard || wrapperType == staticmembervar) { bool handle_as_overload = false; String **arg_names; String **arg_values; // Method or static method or plain function. const char *methodname = 0; String *output = s_oowrappers; if (constructor) { class_has_ctor = true; // Skip the Foo:: prefix. char *ptr = strrchr(GetChar(Swig_methodclass(n), "sym:name"), ':'); if (ptr) { ptr++; } else { ptr = GetChar(Swig_methodclass(n), "sym:name"); } if (strcmp(ptr, GetChar(n, "constructorHandler:sym:name")) == 0) { methodname = "__construct"; } else { // The class has multiple constructors and this one is // renamed, so this will be a static factory function methodname = GetChar(n, "constructorHandler:sym:name"); } } else if (wrapperType == memberfn) { methodname = Char(Getattr(n, "memberfunctionHandler:sym:name")); } else if (wrapperType == staticmemberfn) { methodname = Char(Getattr(n, "staticmemberfunctionHandler:sym:name")); } else if (wrapperType == staticmembervar) { // Static member variable, wrapped as a function due to PHP limitations. methodname = Char(Getattr(n, "staticmembervariableHandler:sym:name")); } else { // wrapperType == standard methodname = Char(iname); if (!s_fakeoowrappers) s_fakeoowrappers = NewStringEmpty(); output = s_fakeoowrappers; } bool really_overloaded = overloaded ? true : false; int min_num_of_arguments = emit_num_required(l); int max_num_of_arguments = emit_num_arguments(l); Hash *ret_types = NewHash(); Setattr(ret_types, d, d); bool non_void_return = (Cmp(d, "void") != 0); if (overloaded) { // Look at all the overloaded versions of this method in turn to // decide if it's really an overloaded method, or just one where some // parameters have default values. Node *o = Getattr(n, "sym:overloaded"); while (o) { if (o == n) { o = Getattr(o, "sym:nextSibling"); continue; } SwigType *d2 = Getattr(o, "type"); if (!d2) { assert(constructor); } else if (!Getattr(ret_types, d2)) { Setattr(ret_types, d2, d2); non_void_return = non_void_return || (Cmp(d2, "void") != 0); } ParmList *l2 = Getattr(o, "wrap:parms"); int num_arguments = emit_num_arguments(l2); int num_required = emit_num_required(l2); if (num_required < min_num_of_arguments) min_num_of_arguments = num_required; if (num_arguments > max_num_of_arguments) { max_num_of_arguments = num_arguments; } o = Getattr(o, "sym:nextSibling"); } o = Getattr(n, "sym:overloaded"); while (o) { if (o == n) { o = Getattr(o, "sym:nextSibling"); continue; } ParmList *l2 = Getattr(o, "wrap:parms"); Parm *p = l, *p2 = l2; if (wrapperType == memberfn) { p = nextSibling(p); p2 = nextSibling(p2); } while (p && p2) { if (Cmp(Getattr(p, "type"), Getattr(p2, "type")) != 0) break; if (Cmp(Getattr(p, "name"), Getattr(p2, "name")) != 0) break; String *value = Getattr(p, "value"); String *value2 = Getattr(p2, "value"); if (value && !value2) break; if (!value && value2) break; if (value) { if (Cmp(value, value2) != 0) break; } p = nextSibling(p); p2 = nextSibling(p2); } if (p && p2) break; // One parameter list is a prefix of the other, so check that all // remaining parameters of the longer list are optional. if (p2) p = p2; while (p && Getattr(p, "value")) p = nextSibling(p); if (p) break; o = Getattr(o, "sym:nextSibling"); } if (!o) { // This "overloaded method" is really just one with default args. really_overloaded = false; } } if (wrapperType == memberfn) { // Allow for the "this" pointer. --min_num_of_arguments; --max_num_of_arguments; } arg_names = (String **) malloc(max_num_of_arguments * sizeof(String *)); if (!arg_names) { /* FIXME: How should this be handled? The rest of SWIG just seems * to not bother checking for malloc failing! */ fprintf(stderr, "Malloc failed!\n"); exit(1); } for (i = 0; i < max_num_of_arguments; ++i) { arg_names[i] = NULL; } arg_values = (String **) malloc(max_num_of_arguments * sizeof(String *)); if (!arg_values) { /* FIXME: How should this be handled? The rest of SWIG just seems * to not bother checking for malloc failing! */ fprintf(stderr, "Malloc failed!\n"); exit(1); } for (i = 0; i < max_num_of_arguments; ++i) { arg_values[i] = NULL; } Node *o; if (overloaded) { o = Getattr(n, "sym:overloaded"); } else { o = n; } while (o) { int argno = 0; Parm *p = Getattr(o, "wrap:parms"); if (wrapperType == memberfn) p = nextSibling(p); while (p) { if (GetInt(p, "tmap:in:numinputs") == 0) { p = nextSibling(p); continue; } assert(0 <= argno && argno < max_num_of_arguments); String *&pname = arg_names[argno]; const char *pname_cstr = GetChar(p, "name"); // Just get rid of the C++ namespace part for now. const char *ptr = NULL; if (pname_cstr && (ptr = strrchr(pname_cstr, ':'))) { pname_cstr = ptr + 1; } if (!pname_cstr) { // Unnamed parameter, e.g. int foo(int); } else if (!pname) { pname = NewString(pname_cstr); } else { size_t len = strlen(pname_cstr); size_t spc = 0; size_t len_pname = strlen(Char(pname)); while (spc + len <= len_pname) { if (strncmp(pname_cstr, Char(pname) + spc, len) == 0) { char ch = ((char *) Char(pname))[spc + len]; if (ch == '\0' || ch == ' ') { // Already have this pname_cstr. pname_cstr = NULL; break; } } char *p = strchr(Char(pname) + spc, ' '); if (!p) break; spc = (p + 4) - Char(pname); } if (pname_cstr) { Printf(pname, " or_%s", pname_cstr); } } String *value = NewString(Getattr(p, "value")); if (Len(value)) { /* Check that value is a valid constant in PHP (and adjust it if * necessary, or replace it with "?" if it's just not valid). */ SwigType *type = Getattr(p, "type"); switch (SwigType_type(type)) { case T_BOOL: { if (Strcmp(value, "true") == 0 || Strcmp(value, "false") == 0) break; char *p; errno = 0; int n = strtol(Char(value), &p, 0); Clear(value); if (errno || *p) { Append(value, "?"); } else if (n) { Append(value, "true"); } else { Append(value, "false"); } break; } case T_CHAR: case T_SCHAR: case T_SHORT: case T_INT: case T_LONG: { char *p; errno = 0; unsigned int n = strtol(Char(value), &p, 0); (void) n; if (errno || *p) { Clear(value); Append(value, "?"); } break; } case T_UCHAR: case T_USHORT: case T_UINT: case T_ULONG: { char *p; errno = 0; unsigned int n = strtoul(Char(value), &p, 0); (void) n; if (errno || *p) { Clear(value); Append(value, "?"); } break; } case T_FLOAT: case T_DOUBLE:{ char *p; errno = 0; /* FIXME: strtod is locale dependent... */ double val = strtod(Char(value), &p); if (errno || *p) { Clear(value); Append(value, "?"); } else if (strchr(Char(value), '.') == 0) { // Ensure value is a double constant, not an integer one. Append(value, ".0"); double val2 = strtod(Char(value), &p); if (errno || *p || val != val2) { Clear(value); Append(value, "?"); } } break; } case T_REFERENCE: case T_RVALUE_REFERENCE: case T_USER: case T_ARRAY: Clear(value); Append(value, "?"); break; case T_STRING: if (Len(value) < 2) { // How can a string (including "" be less than 2 characters?) Clear(value); Append(value, "?"); } else { const char *v = Char(value); if (v[0] != '"' || v[Len(value) - 1] != '"') { Clear(value); Append(value, "?"); } // Strings containing "$" require special handling, but we do // that later. } break; case T_VOID: assert(false); break; case T_POINTER: { const char *v = Char(value); if (v[0] == '(') { // Handle "(void*)0", "(TYPE*)0", "(char*)NULL", etc. v += strcspn(v + 1, "*()") + 1; if (*v == '*') { do { v++; v += strspn(v, " \t"); } while (*v == '*'); if (*v++ == ')') { v += strspn(v, " \t"); String * old = value; value = NewString(v); Delete(old); } } } if (Strcmp(value, "NULL") == 0 || Strcmp(value, "nullptr") == 0 || Strcmp(value, "0") == 0 || Strcmp(value, "0L") == 0) { Clear(value); Append(value, "null"); } else { Clear(value); Append(value, "?"); } break; } } if (!arg_values[argno]) { arg_values[argno] = value; value = NULL; } else if (Cmp(arg_values[argno], value) != 0) { // If a parameter has two different default values in // different overloaded forms of the function, we can't // set its default in PHP. Flag this by setting its // default to `?'. Delete(arg_values[argno]); arg_values[argno] = NewString("?"); } } else if (arg_values[argno]) { // This argument already has a default value in another overloaded // form, but doesn't in this form. So don't try to do anything // clever, just let the C wrappers resolve the overload and set the // default values. // // This handling is safe, but I'm wondering if it may be overly // conservative (FIXME) in some cases. It seems it's only bad when // there's an overloaded form with the appropriate number of // parameters which doesn't want the default value, but I need to // think about this more. Delete(arg_values[argno]); arg_values[argno] = NewString("?"); } Delete(value); p = nextSibling(p); ++argno; } if (!really_overloaded) break; o = Getattr(o, "sym:nextSibling"); } /* Clean up any parameters which haven't yet got names, or whose * names clash. */ Hash *seen = NewHash(); /* We need $this to refer to the current class, so can't allow it * to be used as a parameter. */ Setattr(seen, "this", seen); /* We use $r to store the return value, so disallow that as a parameter * name in case the user uses the "call-time pass-by-reference" feature * (it's deprecated and off by default in PHP5, but we want to be * maximally portable). Similarly we use $c for the classname or new * stdClass object. */ Setattr(seen, "r", seen); Setattr(seen, "c", seen); for (int argno = 0; argno < max_num_of_arguments; ++argno) { String *&pname = arg_names[argno]; if (pname) { Replaceall(pname, " ", "_"); } else { /* We get here if the SWIG .i file has "int foo(int);" */ pname = NewStringEmpty(); Printf(pname, "arg%d", argno + 1); } // Check if we've already used this parameter name. while (Getattr(seen, pname)) { // Append "_" to clashing names until they stop clashing... Printf(pname, "_"); } Setattr(seen, Char(pname), seen); if (arg_values[argno] && Cmp(arg_values[argno], "?") == 0) { handle_as_overload = true; } } Delete(seen); seen = NULL; String *invoke = NewStringEmpty(); String *prepare = NewStringEmpty(); String *args = NewStringEmpty(); if (!handle_as_overload && !(really_overloaded && max_num_of_arguments > min_num_of_arguments)) { Printf(invoke, "%s(", iname); if (wrapperType == memberfn) { Printf(invoke, "$this->%s", SWIG_PTR); } for (int i = 0; i < max_num_of_arguments; ++i) { if (i) Printf(args, ","); if (i || wrapperType == memberfn) Printf(invoke, ","); String *value = arg_values[i]; if (value) { const char *v = Char(value); if (v[0] == '"') { /* In a PHP double quoted string, $ needs to be escaped as \$. */ Replaceall(value, "$", "\\$"); } Printf(args, "$%s=%s", arg_names[i], value); } else { Printf(args, "$%s", arg_names[i]); } Printf(invoke, "$%s", arg_names[i]); } Printf(invoke, ")"); } else { int i; for (i = 0; i < min_num_of_arguments; ++i) { if (i) Printf(args, ","); Printf(args, "$%s", arg_names[i]); } String *invoke_args = NewStringEmpty(); if (wrapperType == memberfn) { Printf(invoke_args, "$this->%s", SWIG_PTR); if (min_num_of_arguments > 0) Printf(invoke_args, ","); } Printf(invoke_args, "%s", args); bool had_a_case = false; int last_handled_i = i - 1; for (; i < max_num_of_arguments; ++i) { if (i) Printf(args, ","); const char *value = Char(arg_values[i]); // FIXME: (really_overloaded && handle_as_overload) is perhaps a // little conservative, but it doesn't hit any cases that it // shouldn't for Xapian at least (and we need it to handle // "Enquire::get_mset()" correctly). bool non_php_default = ((really_overloaded && handle_as_overload) || !value || strcmp(value, "?") == 0); if (non_php_default) value = "null"; Printf(args, "$%s=%s", arg_names[i], value); if (non_php_default) { if (!had_a_case) { Printf(prepare, "\t\tswitch (func_num_args()) {\n"); had_a_case = true; } Printf(prepare, "\t\t"); while (last_handled_i < i) { Printf(prepare, "case %d: ", ++last_handled_i); } if (non_void_return) { if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) { Append(prepare, "$r="); } else { Printf(prepare, "$this->%s=", SWIG_PTR); } } if (!directorsEnabled() || !Swig_directorclass(n) || !newobject) { Printf(prepare, "%s(%s); break;\n", iname, invoke_args); } else if (!i) { Printf(prepare, "%s($_this%s); break;\n", iname, invoke_args); } else { Printf(prepare, "%s($_this, %s); break;\n", iname, invoke_args); } } if (i || wrapperType == memberfn) Printf(invoke_args, ","); Printf(invoke_args, "$%s", arg_names[i]); } Printf(prepare, "\t\t"); if (had_a_case) Printf(prepare, "default: "); if (non_void_return) { if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) { Append(prepare, "$r="); } else { Printf(prepare, "$this->%s=", SWIG_PTR); } } if (!directorsEnabled() || !Swig_directorclass(n) || !newobject) { Printf(prepare, "%s(%s);\n", iname, invoke_args); } else { Printf(prepare, "%s($_this, %s);\n", iname, invoke_args); } if (had_a_case) Printf(prepare, "\t\t}\n"); Delete(invoke_args); Printf(invoke, "$r"); } Printf(output, "\n"); // If it's a member function or a class constructor... if (wrapperType == memberfn || (constructor && current_class)) { String *acc = NewString(Getattr(n, "access")); // If a base has the same method with public access, then PHP // requires to have it here as public as well Node *bases = Getattr(Swig_methodclass(n), "bases"); if (bases && Strcmp(acc, "public") != 0) { String *warnmsg = 0; int haspublicbase = 0; Iterator i = First(bases); while (i.item) { Node *j = firstChild(i.item); while (j) { String *jname = Getattr(j, "name"); if (!jname || Strcmp(jname, Getattr(n, "name")) != 0) { j = nextSibling(j); continue; } if (Strcmp(nodeType(j), "cdecl") == 0) { if (!Getattr(j, "access") || checkAttribute(j, "access", "public")) { haspublicbase = 1; } } else if (Strcmp(nodeType(j), "using") == 0 && firstChild(j) && Strcmp(nodeType(firstChild(j)), "cdecl") == 0) { if (!Getattr(firstChild(j), "access") || checkAttribute(firstChild(j), "access", "public")) { haspublicbase = 1; } } if (haspublicbase) { warnmsg = NewStringf("Modifying the access of '%s::%s' to public, as the base '%s' has it as public as well.\n", Getattr(current_class, "classtype"), Getattr(n, "name"), Getattr(i.item, "classtype")); break; } j = nextSibling(j); } i = Next(i); if (haspublicbase) { break; } } if (Getattr(n, "access") && haspublicbase) { Delete(acc); acc = NewStringEmpty(); // implicitly public Swig_warning(WARN_PHP_PUBLIC_BASE, input_file, line_number, Char(warnmsg)); Delete(warnmsg); } } if (Cmp(acc, "public") == 0) { // The default visibility for methods is public, so don't specify // that explicitly to keep the wrapper size down. Delete(acc); acc = NewStringEmpty(); } else if (Cmp(acc, "") != 0) { Append(acc, " "); } if (constructor) { const char * arg0; if (max_num_of_arguments > 0) { arg0 = Char(arg_names[0]); } else { arg0 = "res"; Delete(args); args = NewString("$res=null"); } String *mangled_type = SwigType_manglestr(Getattr(n, "type")); Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args); Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '%s') {\n", arg0, arg0, mangled_type); Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0); Printf(output, "\t\t\treturn;\n"); Printf(output, "\t\t}\n"); } else { Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args); } Delete(acc); } else if (wrapperType == staticmembervar) { // We're called twice for a writable static member variable - first // with "foo_set" and then with "foo_get" - so generate half the // wrapper function each time. // // For a const static member, we only get called once. static bool started = false; if (!started) { Printf(output, "\tstatic function %s() {\n", methodname); if (max_num_of_arguments) { // Setter. Printf(output, "\t\tif (func_num_args()) {\n"); Printf(output, "\t\t\t%s(func_get_arg(0));\n", iname); Printf(output, "\t\t\treturn;\n"); Printf(output, "\t\t}\n"); started = true; goto done; } } started = false; } else { Printf(output, "\tstatic function %s(%s) {\n", methodname, args); } if (!newobject) Printf(output, "%s", prepare); if (constructor) { if (!directorsEnabled() || !Swig_directorclass(n)) { if (!Len(prepare)) { if (strcmp(methodname, "__construct") == 0) { Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke); } else { String *classname = Swig_class_name(current_class); Printf(output, "\t\treturn new %s%s(%s);\n", prefix, classname, invoke); } } } else { Node *parent = Swig_methodclass(n); String *classname = Swig_class_name(parent); Printf(output, "\t\tif (get_class($this) === '%s%s') {\n", prefix, classname); Printf(output, "\t\t\t$_this = null;\n"); Printf(output, "\t\t} else {\n"); Printf(output, "\t\t\t$_this = $this;\n"); Printf(output, "\t\t}\n"); if (!Len(prepare)) { if (num_arguments > 1) { Printf(output, "\t\t$this->%s=%s($_this, %s);\n", SWIG_PTR, iname, args); } else { Printf(output, "\t\t$this->%s=%s($_this);\n", SWIG_PTR, iname); } } } Printf(output, "%s", prepare); } else if (!non_void_return && !hasargout) { if (Cmp(invoke, "$r") != 0) Printf(output, "\t\t%s;\n", invoke); } else if (is_class(d)) { if (Cmp(invoke, "$r") != 0) Printf(output, "\t\t$r=%s;\n", invoke); if (Len(ret_types) == 1) { /* If d is abstract we can't create a new wrapper type d. */ Node *d_class = classLookup(d); int is_abstract = 0; if (Getattr(d_class, "abstracts")) { is_abstract = 1; } if (newobject || !is_abstract) { Printf(output, "\t\tif (is_resource($r)) {\n"); if (Getattr(classLookup(Getattr(n, "type")), "module")) { /* * _p_Foo -> Foo, _p_ns__Bar -> Bar * TODO: do this in a more elegant way */ if (Len(prefix) == 0) { Printf(output, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n"); } else { Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); } Printf(output, "\t\t\tif (class_exists($c)) return new $c($r);\n"); Printf(output, "\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name")); } else { Printf(output, "\t\t\t$c = new stdClass();\n"); Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n"); Printf(output, "\t\t\treturn $c;\n"); } Printf(output, "\t\t}\n\t\treturn $r;\n"); } else { Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR); Printf(output, "\t\treturn $this;\n"); } } else { Printf(output, "\t\tif (!is_resource($r)) return $r;\n"); Printf(output, "\t\tswitch (get_resource_type($r)) {\n"); Iterator i = First(ret_types); while (i.item) { SwigType *ret_type = i.item; i = Next(i); String *mangled = NewString("_p"); Printf(mangled, "%s", SwigType_manglestr(ret_type)); Node *class_node = Getattr(zend_types, mangled); if (!class_node) { /* This is needed when we're returning a pointer to a type * rather than returning the type by value or reference. */ Delete(mangled); mangled = NewString(SwigType_manglestr(ret_type)); class_node = Getattr(zend_types, mangled); if (!class_node) { // Return type isn't an object, so will be handled by the // !is_resource() check before the switch. continue; } } Printf(output, "\t\t"); if (i.item) { Printf(output, "case '%s': ", mangled); } else { Printf(output, "default: "); } const char *classname = GetChar(class_node, "sym:name"); if (!classname) classname = GetChar(class_node, "name"); if (classname) Printf(output, "return new %s%s($r);\n", prefix, classname); else Printf(output, "return $r;\n"); Delete(mangled); } Printf(output, "\t\t}\n"); } } else { if (non_void_return) { Printf(output, "\t\treturn %s;\n", invoke); } else if (Cmp(invoke, "$r") != 0) { Printf(output, "\t\t%s;\n", invoke); } } Printf(output, "\t}\n"); done: Delete(prepare); Delete(invoke); free(arg_values); Delete(args); args = NULL; for (int i = 0; i < max_num_of_arguments; ++i) { Delete(arg_names[i]); } free(arg_names); arg_names = NULL; } return SWIG_OK; } /* ------------------------------------------------------------ * globalvariableHandler() * ------------------------------------------------------------ */ virtual int globalvariableHandler(Node *n) { char *name = GetChar(n, "name"); char *iname = GetChar(n, "sym:name"); SwigType *t = Getattr(n, "type"); String *tm; /* First do the wrappers such as name_set(), name_get() * as provided by the baseclass's implementation of variableWrapper */ if (Language::globalvariableHandler(n) == SWIG_NOWRAP) { return SWIG_NOWRAP; } if (!addSymbol(iname, n)) return SWIG_ERROR; /* First link C variables to PHP */ tm = Swig_typemap_lookup("varinit", n, name, 0); if (tm) { Replaceall(tm, "$target", name); Printf(s_vinit, "%s\n", tm); } else { Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0)); } /* Now generate PHP -> C sync blocks */ /* tm = Swig_typemap_lookup("varin", n, name, 0); if(tm) { Replaceall(tm, "$symname", iname); Printf(f_c->code, "%s\n", tm); } else { Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0)); } */ /* Now generate C -> PHP sync blocks */ /* if(!GetFlag(n,"feature:immutable")) { tm = Swig_typemap_lookup("varout", n, name, 0); if(tm) { Replaceall(tm, "$symname", iname); Printf(f_php->code, "%s\n", tm); } else { Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0)); } } */ return SWIG_OK; } /* ------------------------------------------------------------ * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { String *name = GetChar(n, "name"); String *iname = GetChar(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); String *tm; if (!addSymbol(iname, n)) return SWIG_ERROR; SwigType_remember(type); if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); Replaceall(tm, "$value", value); Printf(s_cinit, "%s\n", tm); } if (shadow) { String *enumvalue = GetChar(n, "enumvalue"); String *set_to = iname; if (!enumvalue) { enumvalue = GetChar(n, "enumvalueex"); } if (enumvalue) { // Check for a simple constant expression which is valid in PHP. // If we find one, initialise the const member with it; otherwise // we initialise it using the C/C++ wrapped constant. const char *p; for (p = Char(enumvalue); *p; ++p) { if (!isdigit((unsigned char)*p) && !strchr(" +-", *p)) { // FIXME: enhance to handle ` + 1' which is what // we get for enums that don't have an explicit value set. break; } } if (!*p) set_to = enumvalue; } if (wrapping_member_constant) { if (!s_oowrappers) s_oowrappers = NewStringEmpty(); Printf(s_oowrappers, "\n\tconst %s = %s;\n", wrapping_member_constant, set_to); } else { if (!s_fakeoowrappers) s_fakeoowrappers = NewStringEmpty(); Printf(s_fakeoowrappers, "\n\tconst %s = %s;\n", iname, set_to); } } return SWIG_OK; } /* * PHP::pragma() * * Pragma directive. * * %pragma(php) code="String" # Includes a string in the .php file * %pragma(php) include="file.php" # Includes a file in the .php file */ virtual int pragmaDirective(Node *n) { if (!ImportMode) { String *lang = Getattr(n, "lang"); String *type = Getattr(n, "name"); String *value = Getattr(n, "value"); if (Strcmp(lang, "php") == 0 || Strcmp(lang, "php4") == 0) { if (Strcmp(type, "code") == 0) { if (value) { Printf(pragma_code, "%s\n", value); } } else if (Strcmp(type, "include") == 0) { if (value) { Printf(pragma_incl, "include '%s';\n", value); } } else if (Strcmp(type, "phpinfo") == 0) { if (value) { Printf(pragma_phpinfo, "%s\n", value); } } else { Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); } } } return Language::pragmaDirective(n); } /* ------------------------------------------------------------ * classDeclaration() * ------------------------------------------------------------ */ virtual int classDeclaration(Node *n) { if (!Getattr(n, "feature:onlychildren")) { String *symname = Getattr(n, "sym:name"); Setattr(n, "php:proxy", symname); } return Language::classDeclaration(n); } /* ------------------------------------------------------------ * classHandler() * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { constructors = 0; current_class = n; if (shadow) { char *rename = GetChar(n, "sym:name"); if (!addSymbol(rename, n)) return SWIG_ERROR; shadow_classname = NewString(rename); shadow_get_vars = NewHash(); shadow_set_vars = NewHash(); /* Deal with inheritance */ List *baselist = Getattr(n, "bases"); if (baselist) { Iterator base = First(baselist); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } base = Next(base); if (base.item) { /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { if (GetFlag(base.item, "feature:ignore")) { base = Next(base); continue; } String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); Swig_warning(WARN_PHP_MULTIPLE_INHERITANCE, input_file, line_number, "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname); base = Next(base); } } } } classnode = n; Language::classHandler(n); classnode = 0; if (shadow) { List *baselist = Getattr(n, "bases"); Iterator ki, base; if (baselist) { base = First(baselist); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } } else { base.item = NULL; } if (Getattr(n, "abstracts") && !GetFlag(n, "feature:notabstract")) { Printf(s_phpclasses, "abstract "); } Printf(s_phpclasses, "class %s%s ", prefix, shadow_classname); String *baseclass = NULL; if (base.item && Getattr(base.item, "module")) { baseclass = Getattr(base.item, "sym:name"); if (!baseclass) baseclass = Getattr(base.item, "name"); Printf(s_phpclasses, "extends %s%s ", prefix, baseclass); } else if (GetFlag(n, "feature:exceptionclass")) { Append(s_phpclasses, "extends Exception "); } Printf(s_phpclasses, "{\n\tpublic $%s=null;\n", SWIG_PTR); if (!baseclass) { // Only store this in the base class (NB !baseclass means we *are* // a base class...) Printf(s_phpclasses, "\tprotected $%s=array();\n", SWIG_DATA); } // Write property SET handlers ki = First(shadow_set_vars); if (ki.key) { // This class has setters. Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n"); // FIXME: tune this threshold... if (Len(shadow_set_vars) <= 2) { // Not many setters, so avoid call_user_func. for (; ki.key; ki = Next(ki)) { DOH *key = ki.key; String *iname = ki.item; Printf(s_phpclasses, "\t\tif ($var === '%s') return %s($this->%s,$value);\n", key, iname, SWIG_PTR); } } else { Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_set';\n", shadow_classname); Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s,$value);\n", SWIG_PTR); } Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); if (baseclass) { Printf(s_phpclasses, "\t\t%s%s::__set($var,$value);\n", prefix, baseclass); } else { Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); } Printf(s_phpclasses, "\t}\n"); } else { Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); if (baseclass) { Printf(s_phpclasses, "\t\t%s%s::__set($var,$value);\n", prefix, baseclass); } else { Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); } Printf(s_phpclasses, "\t}\n"); } // Write property GET handlers ki = First(shadow_get_vars); if (ki.key) { // This class has getters. Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); int non_class_getters = 0; for (; ki.key; ki = Next(ki)) { DOH *key = ki.key; SwigType *d = ki.item; if (!is_class(d)) { ++non_class_getters; continue; } Printv(s_phpclasses, "\t\tif ($var === '", key, "') return new ", prefix, Getattr(classLookup(d), "sym:name"), "(", shadow_classname, "_", key, "_get($this->", SWIG_PTR, "));\n", NIL); } // FIXME: tune this threshold... if (non_class_getters <= 2) { // Not many non-class getters, so avoid call_user_func. for (ki = First(shadow_get_vars); non_class_getters && ki.key; ki = Next(ki)) { DOH *key = ki.key; SwigType *d = ki.item; if (is_class(d)) continue; Printv(s_phpclasses, "\t\tif ($var === '", key, "') return ", shadow_classname, "_", key, "_get($this->", SWIG_PTR, ");\n", NIL); --non_class_getters; } } else { Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname); Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s);\n", SWIG_PTR); } Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); if (baseclass) { Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass); } else { // Reading an unknown property name gives null in PHP. Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA); } Printf(s_phpclasses, "\t}\n"); /* Create __isset for PHP 5.1 and later; PHP 5.0 will just ignore it. */ /* __isset() should return true for read-only properties, so check for * *_get() not *_set(). */ Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); Printf(s_phpclasses, "\t\tif (function_exists('%s_'.$var.'_get')) return true;\n", shadow_classname); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); if (baseclass) { Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass); } else { Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); } Printf(s_phpclasses, "\t}\n"); } else { Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); if (baseclass) { Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass); } else { Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA); } Printf(s_phpclasses, "\t}\n"); Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); if (baseclass) { Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass); } else { Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); } Printf(s_phpclasses, "\t}\n"); } if (!class_has_ctor) { Printf(s_phpclasses, "\tfunction __construct($h) {\n"); Printf(s_phpclasses, "\t\t$this->%s=$h;\n", SWIG_PTR); Printf(s_phpclasses, "\t}\n"); } if (s_oowrappers) { Printf(s_phpclasses, "%s", s_oowrappers); Delete(s_oowrappers); s_oowrappers = NULL; } class_has_ctor = false; Printf(s_phpclasses, "}\n\n"); Delete(shadow_classname); shadow_classname = NULL; Delete(shadow_set_vars); shadow_set_vars = NULL; Delete(shadow_get_vars); shadow_get_vars = NULL; } return SWIG_OK; } /* ------------------------------------------------------------ * memberfunctionHandler() * ------------------------------------------------------------ */ virtual int memberfunctionHandler(Node *n) { wrapperType = memberfn; Language::memberfunctionHandler(n); wrapperType = standard; return SWIG_OK; } /* ------------------------------------------------------------ * membervariableHandler() * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { wrapperType = membervar; Language::membervariableHandler(n); wrapperType = standard; return SWIG_OK; } /* ------------------------------------------------------------ * staticmembervariableHandler() * ------------------------------------------------------------ */ virtual int staticmembervariableHandler(Node *n) { wrapperType = staticmembervar; Language::staticmembervariableHandler(n); wrapperType = standard; return SWIG_OK; } /* ------------------------------------------------------------ * staticmemberfunctionHandler() * ------------------------------------------------------------ */ virtual int staticmemberfunctionHandler(Node *n) { wrapperType = staticmemberfn; Language::staticmemberfunctionHandler(n); wrapperType = standard; return SWIG_OK; } int abstractConstructorHandler(Node *) { return SWIG_OK; } /* ------------------------------------------------------------ * constructorHandler() * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { constructors++; if (Swig_directorclass(n)) { String *name = GetChar(Swig_methodclass(n), "name"); String *ctype = GetChar(Swig_methodclass(n), "classtype"); String *sname = GetChar(Swig_methodclass(n), "sym:name"); String *args = NewStringEmpty(); ParmList *p = Getattr(n, "parms"); int i; for (i = 0; p; p = nextSibling(p), i++) { if (i) { Printf(args, ", "); } if (Strcmp(GetChar(p, "type"), SwigType_str(GetChar(p, "type"), 0))) { SwigType *t = Getattr(p, "type"); Printf(args, "%s", SwigType_rcaststr(t, 0)); if (SwigType_isreference(t)) { Append(args, "*"); } } Printf(args, "arg%d", i+1); } /* director ctor code is specific for each class */ Delete(director_ctor_code); director_ctor_code = NewStringEmpty(); director_prot_ctor_code = NewStringEmpty(); Printf(director_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n"); Printf(director_prot_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n"); Printf(director_ctor_code, " %s = (%s *)new %s(%s);\n", Swig_cresult_name(), ctype, ctype, args); Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args); if (i) { Insert(args, 0, ", "); } Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args); Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args); Delete(args); wrapperType = directorconstructor; } else { wrapperType = constructor; } Language::constructorHandler(n); wrapperType = standard; return SWIG_OK; } /* ------------------------------------------------------------ * CreateZendListDestructor() * ------------------------------------------------------------ */ //virtual int destructorHandler(Node *n) { //} int CreateZendListDestructor(Node *n) { String *name = GetChar(Swig_methodclass(n), "name"); String *iname = GetChar(n, "sym:name"); ParmList *l = Getattr(n, "parms"); String *destructorname = NewStringEmpty(); Printf(destructorname, "_%s", Swig_name_wrapper(iname)); Setattr(classnode, "destructor", destructorname); Wrapper *f = NewWrapper(); Printf(f->def, "/* This function is designed to be called by the zend list destructors */\n"); Printf(f->def, "/* to typecast and do the actual destruction */\n"); Printf(f->def, "static void %s(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) {\n", destructorname); Wrapper_add_localv(f, "value", "swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr", NIL); Wrapper_add_localv(f, "ptr", "void *ptr=value->ptr", NIL); Wrapper_add_localv(f, "newobject", "int newobject=value->newobject", NIL); emit_parameter_variables(l, f); emit_attach_parmmaps(l, f); // Get type of first arg, thing to be destructed // Skip ignored arguments Parm *p = l; //while (Getattr(p,"tmap:ignore")) {p = Getattr(p,"tmap:ignore:next");} while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); Printf(f->code, " efree(value);\n"); Printf(f->code, " if (! newobject) return; /* can't delete it! */\n"); Printf(f->code, " arg1 = (%s)SWIG_ZTS_ConvertResourceData(ptr,type_name,SWIGTYPE%s TSRMLS_CC);\n", SwigType_lstr(pt, 0), SwigType_manglestr(pt)); Printf(f->code, " if (! arg1) zend_error(E_ERROR, \"%s resource already free'd\");\n", Char(name)); Setattr(n, "wrap:name", destructorname); String *actioncode = emit_action(n); Append(f->code, actioncode); Delete(actioncode); Append(f->code, "return;\n"); Append(f->code, "fail:\n"); Append(f->code, "SWIG_FAIL(TSRMLS_C);\n"); Printf(f->code, "}\n"); Wrapper_print(f, s_wrappers); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * memberconstantHandler() * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { wrapping_member_constant = Getattr(n, "sym:name"); Language::memberconstantHandler(n); wrapping_member_constant = NULL; return SWIG_OK; } int classDirectorInit(Node *n) { String *declaration = Swig_director_declaration(n); Printf(f_directors_h, "%s\n", declaration); Printf(f_directors_h, "public:\n"); Delete(declaration); return Language::classDirectorInit(n); } int classDirectorEnd(Node *n) { Printf(f_directors_h, "};\n"); return Language::classDirectorEnd(n); } int classDirectorConstructor(Node *n) { Node *parent = Getattr(n, "parentNode"); String *decl = Getattr(n, "decl"); String *supername = Swig_class_name(parent); String *classname = NewStringEmpty(); Printf(classname, "SwigDirector_%s", supername); /* insert self parameter */ Parm *p; ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("zval"); SwigType_add_pointer(type); p = NewParm(type, NewString("self"), n); set_nextSibling(p, parms); parms = p; if (!Getattr(n, "defaultargs")) { // There should always be a "self" parameter first. assert(ParmList_len(parms) > 0); /* constructor */ { Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); // We put TSRMLS_DC after the self parameter in order to cope with // any default parameters. String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); const char * p = Char(target); const char * comma = strchr(p, ','); size_t ins = comma ? comma - p : Len(target) - 1; Insert(target, ins, " TSRMLS_DC"); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call); Append(w->def, "}"); Delete(target); Wrapper_print(w, f_directors); Delete(call); DelWrapper(w); } /* constructor header */ { // We put TSRMLS_DC after the self parameter in order to cope with // any default parameters. String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); const char * p = Char(target); const char * comma = strchr(p, ','); size_t ins = comma ? comma - p : Len(target) - 1; Insert(target, ins, " TSRMLS_DC"); Printf(f_directors_h, " %s;\n", target); Delete(target); } } return Language::classDirectorConstructor(n); } int classDirectorMethod(Node *n, Node *parent, String *super) { int is_void = 0; int is_pointer = 0; String *decl = Getattr(n, "decl"); String *returntype = Getattr(n, "type"); String *name = Getattr(n, "name"); String *classname = Getattr(parent, "sym:name"); String *c_classname = Getattr(parent, "name"); String *symname = Getattr(n, "sym:name"); String *declaration = NewStringEmpty(); ParmList *l = Getattr(n, "parms"); Wrapper *w = NewWrapper(); String *tm; String *wrap_args = NewStringEmpty(); String *value = Getattr(n, "value"); String *storage = Getattr(n, "storage"); bool pure_virtual = false; int status = SWIG_OK; int idx; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; if (Cmp(storage, "virtual") == 0) { if (Cmp(value, "0") == 0) { pure_virtual = true; } } /* determine if the method returns a pointer */ is_pointer = SwigType_ispointer_return(decl); is_void = (Cmp(returntype, "void") == 0 && !is_pointer); /* virtual method definition */ String *target; String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ target = Swig_method_decl(rtype, decl, name, l, 0, 1); Printf(declaration, " virtual %s", target); Delete(target); // Get any exception classes in the throws typemap ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { Parm *p; int gencomma = 0; Append(w->def, " throw("); Append(declaration, " throw("); if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); } String *str = SwigType_str(Getattr(p, "type"), 0); Append(w->def, str); Append(declaration, str); Delete(str); } } Append(w->def, ")"); Append(declaration, ")"); } Append(w->def, " {"); Append(declaration, ";\n"); Printf(w->code, "TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);\n"); /* declare method return value * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ if (!is_void) { if (!(ignored_method && !pure_virtual)) { String *cres = SwigType_lstr(returntype, "c_result"); Printf(w->code, "%s;\n", cres); Delete(cres); } } if (ignored_method) { if (!pure_virtual) { if (!is_void) Printf(w->code, "return "); String *super_call = Swig_method_call(super, l); Printf(w->code, "%s;\n", super_call); Delete(super_call); } else { Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\" TSRMLS_CC);\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } } else { /* attach typemaps to arguments (C/C++ -> PHP) */ String *parse_args = NewStringEmpty(); Swig_director_parms_fixup(l); /* remove the wrapper 'w' since it was producing spurious temps */ Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); Parm *p; char source[256]; int outputs = 0; if (!is_void) outputs++; /* build argument list and type conversion string */ idx = 0; p = l; while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } if (Getattr(p, "tmap:directorargout") != 0) outputs++; String *pname = Getattr(p, "name"); String *ptype = Getattr(p, "type"); if ((tm = Getattr(p, "tmap:directorin")) != 0) { String *parse = Getattr(p, "tmap:directorin:parse"); if (!parse) { sprintf(source, "obj%d", idx++); String *input = NewStringf("&%s", source); Setattr(p, "emit:directorinput", input); Replaceall(tm, "$input", input); Delete(input); Replaceall(tm, "$owner", "0"); Printv(wrap_args, "zval ", source, ";\n", NIL); Printf(wrap_args, "args[%d] = &%s;\n", idx - 1, source); Printv(wrap_args, "INIT_ZVAL(", source, ");\n", NIL); Printv(wrap_args, tm, "\n", NIL); Putc('O', parse_args); } else { Append(parse_args, parse); Setattr(p, "emit:directorinput", pname); Replaceall(tm, "$input", pname); Replaceall(tm, "$owner", "0"); if (Len(tm) == 0) Append(tm, pname); } p = Getattr(p, "tmap:directorin:next"); continue; } else if (Cmp(ptype, "void")) { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_NOWRAP; break; } p = nextSibling(p); } /* exception handling */ tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { tm = Getattr(n, "feature:director:except"); if (tm) tm = Copy(tm); } if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { if (Replaceall(tm, "$error", "error")) { /* Only declare error if it is used by the typemap. */ Append(w->code, "int error;\n"); } } else { Delete(tm); tm = NULL; } if (!idx) { Printf(w->code, "zval **args = NULL;\n"); } else { Printf(w->code, "zval *args[%d];\n", idx); } Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name()); Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name()); const char * funcname = GetChar(n, "sym:name"); Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname)); Append(w->code, "if (!swig_self) {\n"); Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");"); Append(w->code, "}\n\n"); /* wrap complex arguments to zvals */ Printv(w->code, wrap_args, NIL); Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,"); Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx); if (tm) { Printv(w->code, Str(tm), "\n", NIL); Delete(tm); } /* marshal return value from PHP to C/C++ type */ String *cleanup = NewStringEmpty(); String *outarg = NewStringEmpty(); idx = 0; /* marshal return value */ if (!is_void) { tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); if (tm != 0) { Replaceall(tm, "$input", Swig_cresult_name()); char temp[24]; sprintf(temp, "%d", idx); Replaceall(tm, "$argnum", temp); /* TODO check this */ if (Getattr(n, "wrap:disown")) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } Replaceall(tm, "$result", "c_result"); Printv(w->code, tm, "\n", NIL); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_ERROR; } } /* marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { Replaceall(tm, "$result", Swig_cresult_name()); Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } Printf(w->code, "FREE_ZVAL(%s);\n", Swig_cresult_name()); Delete(parse_args); Delete(cleanup); Delete(outarg); } if (!is_void) { if (!(ignored_method && !pure_virtual)) { String *rettype = SwigType_str(returntype, 0); if (!SwigType_isreference(returntype)) { Printf(w->code, "return (%s) c_result;\n", rettype); } else { Printf(w->code, "return (%s) *c_result;\n", rettype); } Delete(rettype); } } else { Append(w->code, "return;\n"); } Append(w->code, "fail:\n"); Append(w->code, "SWIG_FAIL(TSRMLS_C);\n"); Append(w->code, "}\n"); // We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method String *inline_extra_method = NewStringEmpty(); if (dirprot_mode() && !is_public(n) && !pure_virtual) { Printv(inline_extra_method, declaration, NIL); String *extra_method_name = NewStringf("%sSwigPublic", name); Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, ";\n", " {\n "); if (!is_void) Printf(inline_extra_method, "return "); String *methodcall = Swig_method_call(super, l); Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Delete(methodcall); Delete(extra_method_name); } /* emit the director method */ if (status == SWIG_OK) { if (!Getattr(n, "defaultargs")) { Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); } } /* clean up */ Delete(wrap_args); Delete(pclassname); DelWrapper(w); return status; } int classDirectorDisown(Node *) { return SWIG_OK; } }; /* class PHP */ static PHP *maininstance = 0; // We use this function to be able to write out zend_register_list_destructor_ex // lines for most things in the type table // NOTE: it's a function NOT A PHP::METHOD extern "C" void typetrace(const SwigType *ty, String *mangled, String *clientdata) { Node *class_node; if (!zend_types) { zend_types = NewHash(); } // we want to know if the type which reduced to this has a constructor if ((class_node = maininstance->classLookup(ty))) { if (!Getattr(zend_types, mangled)) { // OK it may have been set before by a different SwigType but it would // have had the same underlying class node I think // - it is certainly required not to have different originating class // nodes for the same SwigType Setattr(zend_types, mangled, class_node); } } else { // a non-class pointer Setattr(zend_types, mangled, NOTCLASS); } if (r_prevtracefunc) (*r_prevtracefunc) (ty, mangled, (String *) clientdata); } /* ----------------------------------------------------------------------------- * new_swig_php() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_php() { maininstance = new PHP; if (!r_prevtracefunc) { r_prevtracefunc = SwigType_remember_trace(typetrace); } else { Printf(stderr, "php Typetrace vector already saved!\n"); assert(0); } return maininstance; } extern "C" Language *swig_php4(void) { Printf(stderr, "*** -php4 is no longer supported.\n" "*** Either upgrade to PHP5 or use SWIG 1.3.36 or earlier.\n"); SWIG_exit(EXIT_FAILURE); return NULL; // To avoid compiler warnings. } extern "C" Language *swig_php(void) { return new_swig_php(); } swig-3.0.2/Source/Modules/directors.cxx0000664000175000017500000002164312343605122017743 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * directors.cxx * * Director support functions. * Not all of these may be necessary, and some may duplicate existing functionality * in SWIG. --MR * ----------------------------------------------------------------------------- */ #include "swigmod.h" /* Swig_csuperclass_call() * * Generates a fully qualified method call, including the full parameter list. * e.g. "base::method(i, j)" * */ String *Swig_csuperclass_call(String *base, String *method, ParmList *l) { String *call = NewString(""); int arg_idx = 0; Parm *p; if (base) { Printf(call, "%s::", base); } Printf(call, "%s(", method); for (p = l; p; p = nextSibling(p)) { String *pname = Getattr(p, "name"); if (!pname && Cmp(Getattr(p, "type"), "void")) { pname = NewString(""); Printf(pname, "arg%d", arg_idx++); } if (p != l) Printf(call, ", "); Printv(call, pname, NIL); } Printf(call, ")"); return call; } /* Swig_class_declaration() * * Generate the start of a class/struct declaration. * e.g. "class myclass" * */ String *Swig_class_declaration(Node *n, String *name) { if (!name) { name = Getattr(n, "sym:name"); } String *result = NewString(""); String *kind = Getattr(n, "kind"); Printf(result, "%s %s", kind, name); return result; } String *Swig_class_name(Node *n) { String *name; name = Copy(Getattr(n, "sym:name")); return name; } /* Swig_director_declaration() * * Generate the full director class declaration, complete with base classes. * e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {" * */ String *Swig_director_declaration(Node *n) { String *classname = Swig_class_name(n); String *directorname = Language::instance()->directorClassName(n); String *base = Getattr(n, "classtype"); String *declaration = Swig_class_declaration(n, directorname); Printf(declaration, " : public %s, public Swig::Director {\n", base); Delete(classname); Delete(directorname); return declaration; } String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) { String *func; int i = 0; int comma = 0; Parm *p = parms; SwigType *pt; String *nname; func = NewString(""); nname = SwigType_namestr(name); Printf(func, "%s(", nname); while (p) { String *pname; pt = Getattr(p, "type"); if ((SwigType_type(pt) != T_VOID)) { if (comma) Printf(func, ","); pname = Getattr(p, "name"); Printf(func, "%s", pname); comma = 1; i++; } p = nextSibling(p); } Printf(func, ")"); return func; } /* Swig_method_decl * * Misnamed and misappropriated! Taken from SWIG's type string manipulation utilities * and modified to generate full (or partial) type qualifiers for method declarations, * local variable declarations, and return value casting. More importantly, it merges * parameter type information with actual parameter names to produce a complete method * declaration that fully mirrors the original method declaration. * * There is almost certainly a saner way to do this. * * This function needs to be cleaned up and possibly split into several smaller * functions. For instance, attaching default names to parameters should be done in a * separate function. * */ String *Swig_method_decl(SwigType *rettype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) { String *result; List *elements; String *element = 0, *nextelement; int is_const = 0; int nelements, i; int is_func = 0; int arg_idx = 0; if (id) { result = NewString(Char(id)); } else { result = NewString(""); } elements = SwigType_split(decl); nelements = Len(elements); if (nelements > 0) { element = Getitem(elements, 0); } for (i = 0; i < nelements; i++) { if (i < (nelements - 1)) { nextelement = Getitem(elements, i + 1); } else { nextelement = 0; } if (SwigType_isqualifier(element)) { int skip = 0; DOH *q = 0; if (!strip) { q = SwigType_parm(element); if (!Cmp(q, "const")) { is_const = 1; is_func = SwigType_isfunction(nextelement); if (is_func) skip = 1; skip = 1; } if (!skip) { Insert(result, 0, " "); Insert(result, 0, q); } Delete(q); } } else if (SwigType_isfunction(element)) { Parm *parm; String *p; Append(result, "("); parm = args; while (parm != 0) { String *type = Getattr(parm, "type"); String *name = Getattr(parm, "name"); if (!name && Cmp(type, "void")) { name = NewString(""); Printf(name, "arg%d", arg_idx++); Setattr(parm, "name", name); } if (!name) { name = NewString(""); } p = SwigType_str(type, name); Append(result, p); String *value = Getattr(parm, "value"); if (values && (value != 0)) { Printf(result, " = %s", value); } parm = nextSibling(parm); if (parm != 0) Append(result, ", "); } Append(result, ")"); } else if (rettype) { // This check is intended for conversion operators to a pointer/reference which needs the pointer/reference ignoring in the declaration if (SwigType_ispointer(element)) { Insert(result, 0, "*"); if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) { Insert(result, 0, "("); Append(result, ")"); } } else if (SwigType_ismemberpointer(element)) { String *q; q = SwigType_parm(element); Insert(result, 0, "::*"); Insert(result, 0, q); if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) { Insert(result, 0, "("); Append(result, ")"); } Delete(q); } else if (SwigType_isreference(element)) { Insert(result, 0, "&"); } else if (SwigType_isarray(element)) { DOH *size; Append(result, "["); size = SwigType_parm(element); Append(result, size); Append(result, "]"); Delete(size); } else { if (Strcmp(element, "v(...)") == 0) { Insert(result, 0, "..."); } else { String *bs = SwigType_namestr(element); Insert(result, 0, " "); Insert(result, 0, bs); Delete(bs); } } } element = nextelement; } Delete(elements); if (is_const) { if (is_func) { Append(result, " "); Append(result, "const"); } else { Insert(result, 0, "const "); } } Chop(result); if (rettype) { Insert(result, 0, " "); String *rtype = SwigType_str(rettype, 0); Insert(result, 0, rtype); Delete(rtype); } return result; } /* ----------------------------------------------------------------------------- * Swig_director_emit_dynamic_cast() * * In order to call protected virtual director methods from the target language, we need * to add an extra dynamic_cast to call the public C++ wrapper in the director class. * Also for non-static protected members when the allprotected option is on. * ----------------------------------------------------------------------------- */ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) { // TODO: why is the storage element removed in staticmemberfunctionHandler ?? if ((!is_public(n) && (is_member_director(n) || GetFlag(n, "explicitcall"))) || (is_non_virtual_protected_access(n) && !(Swig_storage_isstatic_custom(n, "staticmemberfunctionHandler:storage") || Swig_storage_isstatic(n)) && !Equal(nodeType(n), "constructor"))) { Node *parent = Getattr(n, "parentNode"); String *dirname; String *dirdecl; dirname = Language::instance()->directorClassName(parent); dirdecl = NewStringf("%s *darg = 0", dirname); Wrapper_add_local(f, "darg", dirdecl); Printf(f->code, "darg = dynamic_cast<%s *>(arg1);\n", dirname); Delete(dirname); Delete(dirdecl); } } /* ------------------------------------------------------------ * Swig_director_parms_fixup() * * For each parameter in the C++ member function, copy the parameter name * to its "lname"; this ensures that Swig_typemap_attach_parms() will do * the right thing when it sees strings like "$1" in "directorin" typemaps. * ------------------------------------------------------------ */ void Swig_director_parms_fixup(ParmList *parms) { Parm *p; int i; for (i = 0, p = parms; p; p = nextSibling(p), ++i) { String *arg = Getattr(p, "name"); String *lname = 0; if (!arg && !Equal(Getattr(p, "type"), "void")) { lname = NewStringf("arg%d", i); Setattr(p, "name", lname); } else lname = Copy(arg); Setattr(p, "lname", lname); Delete(lname); } } swig-3.0.2/Source/Modules/s-exp.cxx0000664000175000017500000002404312343605122016776 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * s-exp.cxx * * A parse tree represented as Lisp s-expressions. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "dohint.h" static const char *usage = "\ S-Exp Options (available with -sexp)\n\ -typemaplang - Typemap language\n\n"; //static Node *view_top = 0; static File *out = 0; class Sexp:public Language { int indent_level; DOHHash *print_circle_hash; int print_circle_count; int hanging_parens; bool need_whitespace; bool need_newline; public: Sexp(): indent_level(0), print_circle_hash(0), print_circle_count(0), hanging_parens(0), need_whitespace(0), need_newline(0) { } virtual ~ Sexp() { } virtual void main(int argc, char *argv[]) { // Add a symbol to the parser for conditional compilation Preprocessor_define("SWIGSEXP 1", 0); SWIG_typemap_lang("sexp"); for (int iX = 0; iX < argc; iX++) { if (strcmp(argv[iX], "-typemaplang") == 0) { Swig_mark_arg(iX); iX++; SWIG_typemap_lang(argv[iX]); Swig_mark_arg(iX); continue; } if (strcmp(argv[iX], "-help") == 0) { fputs(usage, stdout); } } } /* Top of the parse tree */ virtual int top(Node *n) { if (out == 0) { String *outfile = Getattr(n, "outfile"); Replaceall(outfile, "_wrap.cxx", ".lisp"); Replaceall(outfile, "_wrap.c", ".lisp"); out = NewFile(outfile, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } } String *f_sink = NewString(""); Swig_register_filebyname("header", f_sink); Swig_register_filebyname("wrapper", f_sink); Swig_register_filebyname("begin", f_sink); Swig_register_filebyname("runtime", f_sink); Swig_register_filebyname("init", f_sink); Swig_banner_target_lang(out, ";;;"); Language::top(n); Printf(out, "\n"); Printf(out, ";;; Lisp parse tree produced by SWIG\n"); print_circle_hash = NewHash(); print_circle_count = 0; hanging_parens = 0; need_whitespace = 0; need_newline = 0; Sexp_print_node(n); flush_parens(); return SWIG_OK; } void print_indent() { int i; for (i = 0; i < indent_level; i++) { Printf(out, " "); } } void open_paren(const String *oper) { flush_parens(); Printf(out, "("); if (oper) Printf(out, "%s ", oper); indent_level += 2; } void close_paren(bool neednewline = false) { hanging_parens++; if (neednewline) print_lazy_whitespace(); indent_level -= 2; } void flush_parens() { int i; if (hanging_parens) { for (i = 0; i < hanging_parens; i++) Printf(out, ")"); hanging_parens = 0; need_newline = true; need_whitespace = true; } if (need_newline) { Printf(out, "\n"); print_indent(); need_newline = false; need_whitespace = false; } else if (need_whitespace) { Printf(out, " "); need_whitespace = false; } } void print_lazy_whitespace() { need_whitespace = 1; } void print_lazy_newline() { need_newline = 1; } bool internal_key_p(DOH *key) { return ((Cmp(key, "nodeType") == 0) || (Cmp(key, "firstChild") == 0) || (Cmp(key, "lastChild") == 0) || (Cmp(key, "parentNode") == 0) || (Cmp(key, "nextSibling") == 0) || (Cmp(key, "previousSibling") == 0) || (Cmp(key, "csym:nextSibling") == 0) || (Cmp(key, "csym:previousSibling") == 0) || (Cmp(key, "typepass:visit") == 0) || (Cmp(key, "allocate:visit") == 0) || (*(Char(key)) == '$')); } bool boolean_key_p(DOH *key) { return ((Cmp(key, "allocate:default_constructor") == 0) || (Cmp(key, "allocate:default_destructor") == 0) || (Cmp(key, "allows_typedef") == 0) || (Cmp(key, "feature:immutable") == 0)); } bool list_key_p(DOH *key) { return ((Cmp(key, "parms") == 0) || (Cmp(key, "baselist") == 0)); } bool plist_key_p(DOH *key) // true if KEY is the name of data that is a mapping from keys to // values, which should be printed as a plist. { return ((Cmp(key, "typescope") == 0)); } bool maybe_plist_key_p(DOH *key) { return (Strncmp(key, "tmap:", 5) == 0); } bool print_circle(DOH *obj, bool list_p) // We have a complex object, which might be referenced several // times, or even recursively. Use Lisp's reader notation for // circular structures (#n#, #n=). // // An object can be printed in list-mode or object-mode; LIST_P toggles. // return TRUE if OBJ still needs to be printed { flush_parens(); // Following is a silly hack. It works around the limitation of // DOH's hash tables that only work with string keys! char address[32]; sprintf(address, "%p%c", obj, list_p ? 'L' : 'O'); DOH *placeholder = Getattr(print_circle_hash, address); if (placeholder) { Printv(out, placeholder, NIL); return false; } else { String *placeholder = NewStringf("#%d#", ++print_circle_count); Setattr(print_circle_hash, address, placeholder); Printf(out, "#%d=", print_circle_count); return true; } } void Sexp_print_value_of_key(DOH *value, DOH *key) { if ((Cmp(key, "parms") == 0) || (Cmp(key, "wrap:parms") == 0) || (Cmp(key, "kwargs") == 0) || (Cmp(key, "pattern") == 0)) Sexp_print_parms(value); else if (plist_key_p(key)) Sexp_print_plist(value); else if (maybe_plist_key_p(key)) { if (DohIsMapping(value)) Sexp_print_plist(value); else Sexp_print_doh(value); } else if (list_key_p(key)) Sexp_print_list(value); else if (boolean_key_p(key)) Sexp_print_boolean(value); else Sexp_print_doh(value); } void Sexp_print_boolean(DOH *obj) { flush_parens(); /* See DOH/Doh/base.c, DohGetInt() */ if (DohIsString(obj)) { if (atoi(Char(obj)) != 0) Printf(out, "t"); else Printf(out, "nil"); } else Printf(out, "nil"); } void Sexp_print_list(DOH *obj) { if (print_circle(obj, true)) { open_paren(NIL); for (; obj; obj = nextSibling(obj)) { Sexp_print_doh(obj); print_lazy_whitespace(); } close_paren(true); } } void Sexp_print_parms(DOH *obj) { // print it as a list of plists if (print_circle(obj, true)) { open_paren(NIL); for (; obj; obj = nextSibling(obj)) { if (DohIsMapping(obj)) { Iterator k; open_paren(NIL); for (k = First(obj); k.key; k = Next(k)) { if (!internal_key_p(k.key)) { DOH *value = Getattr(obj, k.key); Sexp_print_as_keyword(k.key); Sexp_print_value_of_key(value, k.key); print_lazy_whitespace(); } } close_paren(true); } else Sexp_print_doh(obj); print_lazy_whitespace(); } close_paren(true); } } void Sexp_print_doh(DOH *obj) { flush_parens(); if (DohIsString(obj)) { String *o = Str(obj); Replaceall(o, "\\", "\\\\"); Replaceall(o, "\"", "\\\""); Printf(out, "\"%s\"", o); Delete(o); } else { if (print_circle(obj, false)) { // Dispatch type if (nodeType(obj)) { Sexp_print_node(obj); } else if (DohIsMapping(obj)) { Iterator k; open_paren(NIL); for (k = First(obj); k.key; k = Next(k)) { if (!internal_key_p(k.key)) { DOH *value = Getattr(obj, k.key); flush_parens(); open_paren(NIL); Sexp_print_doh(k.key); Printf(out, " . "); Sexp_print_value_of_key(value, k.key); close_paren(); } } close_paren(); } else if (strcmp(ObjType(obj)->objname, "List") == 0) { int i; open_paren(NIL); for (i = 0; i < Len(obj); i++) { DOH *item = Getitem(obj, i); Sexp_print_doh(item); } close_paren(); } else { // What is it? Printf(out, "#", ObjType(obj)->objname, obj); } } } } void Sexp_print_as_keyword(const DOH *k) { /* Print key, replacing ":" with "-" because : is CL's package prefix */ flush_parens(); String *key = NewString(k); Replaceall(key, ":", "-"); Replaceall(key, "_", "-"); Printf(out, ":%s ", key); Delete(key); } void Sexp_print_plist_noparens(DOH *obj) { /* attributes map names to objects */ Iterator k; bool first; for (k = First(obj), first = true; k.key; k = Next(k), first = false) { if (!internal_key_p(k.key)) { DOH *value = Getattr(obj, k.key); flush_parens(); if (!first) { Printf(out, " "); } Sexp_print_as_keyword(k.key); /* Print value */ Sexp_print_value_of_key(value, k.key); } } } void Sexp_print_plist(DOH *obj) { flush_parens(); if (print_circle(obj, true)) { open_paren(NIL); Sexp_print_plist_noparens(obj); close_paren(); } } void Sexp_print_attributes(Node *obj) { Sexp_print_plist_noparens(obj); } void Sexp_print_node(Node *obj) { Node *cobj; open_paren(nodeType(obj)); /* A node has an attribute list... */ Sexp_print_attributes(obj); /* ... and child nodes. */ cobj = firstChild(obj); if (cobj) { print_lazy_newline(); flush_parens(); Sexp_print_as_keyword("children"); open_paren(NIL); for (; cobj; cobj = nextSibling(cobj)) { Sexp_print_node(cobj); } close_paren(); } close_paren(); } virtual int functionWrapper(Node *n) { ParmList *l = Getattr(n, "parms"); Wrapper *f = NewWrapper(); emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); DelWrapper(f); return SWIG_OK; } }; static Language *new_swig_sexp() { return new Sexp(); } extern "C" Language *swig_sexp(void) { return new_swig_sexp(); } swig-3.0.2/Source/Modules/octave.cxx0000664000175000017500000014122212343605122017222 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * octave.cxx * * Octave language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" static String *global_name = 0; static String *op_prefix = 0; static const char *usage = "\ Octave Options (available with -octave)\n\ -globals - Set used to access C global variables [default: 'cvar']\n\ Use '.' to load C global variables into module namespace\n\ -opprefix - Prefix for global operator functions [default: 'op_']\n\ \n"; class OCTAVE:public Language { private: File *f_begin; File *f_runtime; File *f_header; File *f_doc; File *f_wrappers; File *f_init; File *f_initbeforefunc; File *f_directors; File *f_directors_h; String *s_global_tab; String *s_members_tab; String *class_name; int have_constructor; int have_destructor; String *constructor_name; Hash *docs; void Octave_begin_function(Node *n, File *f, const_String_or_char_ptr cname, const_String_or_char_ptr wname, bool dld) { if (dld) { String *tname = texinfo_name(n, "std::string()"); Printf(f, "SWIG_DEFUN( %s, %s, %s ) {", cname, wname, tname); } else { Printf(f, "static octave_value_list %s (const octave_value_list& args, int nargout) {", wname); } } public: OCTAVE(): f_begin(0), f_runtime(0), f_header(0), f_doc(0), f_wrappers(0), f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0), s_global_tab(0), s_members_tab(0), class_name(0), have_constructor(0), have_destructor(0), constructor_name(0), docs(0) { /* Add code to manage protected constructors and directors */ director_prot_ctor_code = NewString(""); Printv(director_prot_ctor_code, "if ( $comparison ) { /* subclassed */\n", " $director_new \n", "} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL); enable_cplus_runtime_mode(); allow_overloading(); director_multiple_inheritance = 1; director_language = 1; docs = NewHash(); } virtual void main(int argc, char *argv[]) { for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); } else if (strcmp(argv[i], "-globals") == 0) { if (argv[i + 1]) { global_name = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-opprefix") == 0) { if (argv[i + 1]) { op_prefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } } } if (!global_name) global_name = NewString("cvar"); if (!op_prefix) op_prefix = NewString("op_"); SWIG_library_directory("octave"); Preprocessor_define("SWIGOCTAVE 1", 0); SWIG_config_file("octave.swg"); SWIG_typemap_lang("octave"); allow_overloading(); // Octave API is C++, so output must be C++ compatibile even when wrapping C code if (!cparse_cplusplus) Swig_cparse_cplusplusout(1); } virtual int top(Node *n) { { Node *mod = Getattr(n, "module"); if (mod) { Node *options = Getattr(mod, "options"); if (options) { int dirprot = 0; if (Getattr(options, "dirprot")) { dirprot = 1; } if (Getattr(options, "nodirprot")) { dirprot = 0; } if (Getattr(options, "directors")) { allow_directors(); if (dirprot) allow_dirprot(); } } } } String *module = Getattr(n, "name"); String *outfile = Getattr(n, "outfile"); f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_header = NewString(""); f_doc = NewString(""); f_wrappers = NewString(""); f_init = NewString(""); f_initbeforefunc = NewString(""); f_directors_h = NewString(""); f_directors = NewString(""); s_global_tab = NewString(""); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("header", f_header); Swig_register_filebyname("doc", f_doc); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("init", f_init); Swig_register_filebyname("initbeforefunc", f_initbeforefunc); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGOCTAVE\n"); Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name); Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); Swig_banner(f_directors_h); if (dirprot_mode()) { // Printf(f_directors_h, "#include \n"); // Printf(f_directors_h, "#include \n\n"); } } Printf(f_runtime, "\n"); Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n"); Printf(f_init, "static bool SWIG_init_user(octave_swig_type* module_ns)\n{\n"); if (!CPlusPlus) Printf(f_header,"extern \"C\" {\n"); Language::top(n); if (!CPlusPlus) Printf(f_header,"}\n"); if (Len(docs)) emit_doc_texinfo(); if (directorsEnabled()) Swig_insert_file("director.swg", f_runtime); Printf(f_init, "return true;\n}\n"); Printf(s_global_tab, "{0,0,0,0,0}\n};\n"); Printv(f_wrappers, s_global_tab, NIL); SwigType_emit_type_table(f_runtime, f_wrappers); Dump(f_runtime, f_begin); Dump(f_header, f_begin); Dump(f_doc, f_begin); if (directorsEnabled()) { Dump(f_directors_h, f_begin); Dump(f_directors, f_begin); } Dump(f_wrappers, f_begin); Dump(f_initbeforefunc, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(s_global_tab); Delete(f_initbeforefunc); Delete(f_init); Delete(f_wrappers); Delete(f_doc); Delete(f_header); Delete(f_directors); Delete(f_directors_h); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } String *texinfo_escape(String *_s) { const char* s=(const char*)Data(_s); while (*s&&(*s=='\t'||*s=='\r'||*s=='\n'||*s==' ')) ++s; String *r = NewString(""); for (int j=0;s[j];++j) { if (s[j] == '\n') { Append(r, "\\n\\\n"); } else if (s[j] == '\r') { Append(r, "\\r"); } else if (s[j] == '\t') { Append(r, "\\t"); } else if (s[j] == '\\') { Append(r, "\\\\"); } else if (s[j] == '\'') { Append(r, "\\\'"); } else if (s[j] == '\"') { Append(r, "\\\""); } else Putc(s[j], r); } return r; } void emit_doc_texinfo() { for (Iterator it = First(docs); it.key; it = Next(it)) { String *wrap_name = it.key; String *synopsis = Getattr(it.item, "synopsis"); String *decl_info = Getattr(it.item, "decl_info"); String *cdecl_info = Getattr(it.item, "cdecl_info"); String *args_info = Getattr(it.item, "args_info"); String *doc_str = NewString(""); Printv(doc_str, synopsis, decl_info, cdecl_info, args_info, NIL); String *escaped_doc_str = texinfo_escape(doc_str); if (Len(doc_str)>0) { Printf(f_doc,"static const char* %s_texinfo = ",wrap_name); Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str); if (Len(decl_info)) Printf(f_doc,"\\n\\\n@end deftypefn"); Printf(f_doc,"\";\n"); } Delete(escaped_doc_str); Delete(doc_str); Delete(wrap_name); } Printf(f_doc,"\n"); } bool is_empty_doc_node(Node* n) { if (!n) return true; String *synopsis = Getattr(n, "synopsis"); String *decl_info = Getattr(n, "decl_info"); String *cdecl_info = Getattr(n, "cdecl_info"); String *args_info = Getattr(n, "args_info"); return !Len(synopsis) && !Len(decl_info) && !Len(cdecl_info) && !Len(args_info); } String *texinfo_name(Node* n, const char* defval = "0") { String *tname = NewString(""); String *iname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(iname); Node* d = Getattr(docs, wname); if (is_empty_doc_node(d)) Printf(tname, defval); else Printf(tname, "%s_texinfo", wname); return tname; } void process_autodoc(Node *n) { String *iname = Getattr(n, "sym:name"); String *name = Getattr(n, "name"); String *wname = Swig_name_wrapper(iname); String *str = Getattr(n, "feature:docstring"); bool autodoc_enabled = !Cmp(Getattr(n, "feature:autodoc"), "1"); Node* d = Getattr(docs, wname); if (!d) { d = NewHash(); Setattr(d, "synopsis", NewString("")); Setattr(d, "decl_info", NewString("")); Setattr(d, "cdecl_info", NewString("")); Setattr(d, "args_info", NewString("")); Setattr(docs, wname, d); } String *synopsis = Getattr(d, "synopsis"); String *decl_info = Getattr(d, "decl_info"); // String *cdecl_info = Getattr(d, "cdecl_info"); String *args_info = Getattr(d, "args_info"); // * couldn't we just emit the docs here? if (autodoc_enabled) { String *decl_str = NewString(""); String *args_str = NewString(""); make_autodocParmList(n, decl_str, args_str); Append(decl_info, "@deftypefn {Loadable Function} "); SwigType *type = Getattr(n, "type"); if (type && Strcmp(type, "void")) { Node *nn = classLookup(Getattr(n, "type")); String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); Append(decl_info, "@var{retval} = "); Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str); Delete(type_str); } Append(decl_info, name); Append(decl_info, " ("); Append(decl_info, decl_str); Append(decl_info, ")\n"); Append(args_info, args_str); Delete(decl_str); Delete(args_str); } if (str && Len(str) > 0) { // strip off {} if necessary char *t = Char(str); if (*t == '{') { Delitem(str, 0); Delitem(str, DOH_END); } // emit into synopsis section Append(synopsis, str); } } virtual int importDirective(Node *n) { String *modname = Getattr(n, "module"); if (modname) Printf(f_init, "if (!SWIG_Octave_LoadModule(\"%s\")) return false;\n", modname); return Language::importDirective(n); } const char *get_implicitconv_flag(Node *n) { int conv = 0; if (n && GetFlag(n, "feature:implicitconv")) { conv = 1; } return conv ? "SWIG_POINTER_IMPLICIT_CONV" : "0"; } /* ----------------------------------------------------------------------------- * addMissingParameterNames() * For functions that have not had nameless parameters set in the Language class. * * Inputs: * plist - entire parameter list * arg_offset - argument number for first parameter * Side effects: * The "lname" attribute in each parameter in plist will be contain a parameter name * ----------------------------------------------------------------------------- */ void addMissingParameterNames(ParmList *plist, int arg_offset) { Parm *p = plist; int i = arg_offset; while (p) { if (!Getattr(p, "lname")) { String *pname = Swig_cparm_name(p, i); Delete(pname); } i++; p = nextSibling(p); } } void make_autodocParmList(Node *n, String *decl_str, String *args_str) { String *pdocs = 0; ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; int start_arg_num = is_wrapping_class() ? 1 : 0; addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); for (p = plist; p; p = pnext) { String *tm = Getattr(p, "tmap:in"); if (tm) { pnext = Getattr(p, "tmap:in:next"); if (checkAttribute(p, "tmap:in:numinputs", "0")) { continue; } } else { pnext = nextSibling(p); } String *name = 0; String *type = 0; String *value = 0; String *pdoc = Getattr(p, "tmap:doc"); if (pdoc) { name = Getattr(p, "tmap:doc:name"); type = Getattr(p, "tmap:doc:type"); value = Getattr(p, "tmap:doc:value"); } // Note: the generated name should be consistent with that in kwnames[] name = name ? name : Getattr(p, "name"); name = name ? name : Getattr(p, "lname"); name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); if (SwigType_isvarargs(type)) break; String *tex_name = NewString(""); if (name) Printf(tex_name, "@var{%s}", name); else Printf(tex_name, "@var{?}"); if (Len(decl_str)) Append(decl_str, ", "); Append(decl_str, tex_name); if (value) { String *new_value = convertValue(value, Getattr(p, "type")); if (new_value) { value = new_value; } else { Node *lookup = Swig_symbol_clookup(value, 0); if (lookup) value = Getattr(lookup, "sym:name"); } Printf(decl_str, " = %s", value); } Node *nn = classLookup(Getattr(p, "type")); String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); Printf(args_str, "%s is of type %s. ", tex_name, type_str); Delete(type_str); Delete(tex_name); Delete(name); } if (pdocs) Setattr(n, "feature:pdocs", pdocs); Delete(plist); } /* ------------------------------------------------------------ * convertValue() * Check if string v can be an Octave value literal, * (eg. number or string), or translate it to an Octave literal. * ------------------------------------------------------------ */ String *convertValue(String *v, SwigType *t) { if (v && Len(v) > 0) { char fc = (Char(v))[0]; if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) { /* number or string (or maybe NULL pointer) */ if (SwigType_ispointer(t) && Strcmp(v, "0") == 0) return NewString("None"); else return v; } if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) return SwigType_ispointer(t) ? NewString("nil") : NewString("0"); if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) return NewString("true"); if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("false"); } return 0; } virtual int functionWrapper(Node *n) { Parm *p; String *tm; int j; String *nodeType = Getattr(n, "nodeType"); int constructor = (!Cmp(nodeType, "constructor")); int destructor = (!Cmp(nodeType, "destructor")); String *storage = Getattr(n, "storage"); bool overloaded = !!Getattr(n, "sym:overloaded"); bool last_overload = overloaded && !Getattr(n, "sym:nextSibling"); String *iname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(iname); String *overname = Copy(wname); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); if (!overloaded && !addSymbol(iname, n)) return SWIG_ERROR; if (overloaded) Append(overname, Getattr(n, "sym:overname")); if (!overloaded || last_overload) process_autodoc(n); Wrapper *f = NewWrapper(); Octave_begin_function(n, f->def, iname, overname, !overloaded); emit_parameter_variables(l, f); emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); int num_arguments = emit_num_arguments(l); int num_required = emit_num_required(l); int varargs = emit_isvarargs(l); char source[64]; Printf(f->code, "if (!SWIG_check_num_args(\"%s\",args.length(),%i,%i,%i)) " "{\n SWIG_fail;\n }\n", iname, num_arguments, num_required, varargs); if (constructor && num_arguments == 1 && num_required == 1) { if (Cmp(storage, "explicit") == 0) { Node *parent = Swig_methodclass(n); if (GetFlag(parent, "feature:implicitconv")) { String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n, "type"))); Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc); Delete(desc); } } } for (j = 0, p = l; j < num_arguments; ++j) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *tm = Getattr(p, "tmap:in"); if (tm) { if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) { p = nextSibling(p); continue; } sprintf(source, "args(%d)", j); Setattr(p, "emit:input", source); Replaceall(tm, "$source", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Replaceall(tm, "$target", Getattr(p, "lname")); if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } if (Getattr(p, "tmap:in:implicitconv")) { const char *convflag = "0"; if (!Getattr(p, "hidden")) { SwigType *ptype = Getattr(p, "type"); convflag = get_implicitconv_flag(classLookup(ptype)); } Replaceall(tm, "$implicitconv", convflag); Setattr(p, "implicitconv", convflag); } String *getargs = NewString(""); if (j >= num_required) Printf(getargs, "if (%dcode, getargs, "\n", NIL); Delete(getargs); p = Getattr(p, "tmap:in:next"); continue; } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } } // Check for trailing varargs if (varargs) { if (p && (tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$input", "varargs"); Printv(f->code, tm, "\n", NIL); } } // Insert constraint checking code for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } // Insert cleanup code String *cleanup = NewString(""); for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { if (Getattr(p, "tmap:freearg:implicitconv")) { const char *convflag = "0"; if (!Getattr(p, "hidden")) { SwigType *ptype = Getattr(p, "type"); convflag = get_implicitconv_flag(classLookup(ptype)); } if (strcmp(convflag, "0") == 0) { tm = 0; } } if (tm && (Len(tm) != 0)) { Replaceall(tm, "$source", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); } p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } // Insert argument output code String *outarg = NewString(""); for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$target", "_outp"); Replaceall(tm, "$result", "_outp"); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } int director_method = is_member_director(n) && !is_smart_pointer() && !destructor; if (director_method) { Wrapper_add_local(f, "upcall", "bool upcall = false"); Append(f->code, "upcall = !!dynamic_cast(arg1);\n"); } Setattr(n, "wrap:name", overname); Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); Wrapper_add_local(f, "_out", "octave_value_list _out"); Wrapper_add_local(f, "_outp", "octave_value_list *_outp=&_out"); Wrapper_add_local(f, "_outv", "octave_value _outv"); // Return the function value if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "_outv"); Replaceall(tm, "$result", "_outv"); if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "1"); else Replaceall(tm, "$owner", "0"); Printf(f->code, "%s\n", tm); Printf(f->code, "if (_outv.is_defined()) _outp = " "SWIG_Octave_AppendOutput(_outp, _outv);\n"); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), iname); } emit_return_variable(n, d, f); Printv(f->code, outarg, NIL); Printv(f->code, cleanup, NIL); if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$result", "_outv"); Printf(f->code, "%s\n", tm); Delete(tm); } Printf(f->code, "return _out;\n"); Printf(f->code, "fail:\n"); // we should free locals etc if this happens Printv(f->code, cleanup, NIL); Printf(f->code, "return octave_value_list();\n"); Printf(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); Replaceall(f->code, "$symname", iname); Wrapper_print(f, f_wrappers); DelWrapper(f); if (last_overload) dispatchFunction(n); if (!overloaded || last_overload) { String *tname = texinfo_name(n); Printf(s_global_tab, "{\"%s\",%s,0,0,2,%s},\n", iname, wname, tname); Delete(tname); } Delete(overname); Delete(wname); Delete(cleanup); Delete(outarg); return SWIG_OK; } void dispatchFunction(Node *n) { Wrapper *f = NewWrapper(); String *iname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(iname); int maxargs; String *dispatch = Swig_overload_dispatch(n, "return %s(args, nargout);", &maxargs); String *tmp = NewString(""); Octave_begin_function(n, f->def, iname, wname, true); Wrapper_add_local(f, "argc", "int argc = args.length()"); Printf(tmp, "octave_value_ref argv[%d]={", maxargs); for (int j = 0; j < maxargs; ++j) Printf(tmp, "%soctave_value_ref(args,%d)", j ? "," : " ", j); Printf(tmp, "}"); Wrapper_add_local(f, "argv", tmp); Printv(f->code, dispatch, "\n", NIL); Printf(f->code, "error(\"No matching function for overload\");\n", iname); Printf(f->code, "return octave_value_list();\n"); Printv(f->code, "}\n", NIL); Wrapper_print(f, f_wrappers); Delete(tmp); DelWrapper(f); Delete(dispatch); Delete(wname); } virtual int variableWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *t = Getattr(n, "type"); if (!addSymbol(iname, n)) return SWIG_ERROR; String *tm; Wrapper *getf = NewWrapper(); Wrapper *setf = NewWrapper(); String *getname = Swig_name_get(NSPACE_TODO, iname); String *setname = Swig_name_set(NSPACE_TODO, iname); String *getwname = Swig_name_wrapper(getname); String *setwname = Swig_name_wrapper(setname); Octave_begin_function(n, setf->def, setname, setwname, true); Printf(setf->def, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname); if (is_assignable(n)) { Setattr(n, "wrap:name", setname); if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { Replaceall(tm, "$source", "args(0)"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "args(0)"); if (Getattr(n, "tmap:varin:implicitconv")) { Replaceall(tm, "$implicitconv", get_implicitconv_flag(n)); } emit_action_code(n, setf->code, tm); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); } Append(setf->code, "fail:\n"); Printf(setf->code, "return octave_value_list();\n"); } else { Printf(setf->code, "return octave_set_immutable(args,nargout);"); } Append(setf->code, "}\n"); Wrapper_print(setf, f_wrappers); Setattr(n, "wrap:name", getname); int addfail = 0; Octave_begin_function(n, getf->def, getname, getwname, true); Wrapper_add_local(getf, "obj", "octave_value obj"); if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$source", name); Replaceall(tm, "$target", "obj"); Replaceall(tm, "$result", "obj"); addfail = emit_action_code(n, getf->code, tm); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0)); } Append(getf->code, " return obj;\n"); if (addfail) { Append(getf->code, "fail:\n"); Append(getf->code, " return octave_value_list();\n"); } Append(getf->code, "}\n"); Wrapper_print(getf, f_wrappers); Printf(s_global_tab, "{\"%s\",0,%s,%s,2,0},\n", iname, getwname, setwname); Delete(getwname); Delete(setwname); DelWrapper(setf); DelWrapper(getf); return SWIG_OK; } virtual int constantWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); String *cppvalue = Getattr(n, "cppvalue"); String *tm; if (!addSymbol(iname, n)) return SWIG_ERROR; if (SwigType_type(type) == T_MPOINTER) { String *wname = Swig_name_wrapper(iname); String *str = SwigType_str(type, wname); Printf(f_header, "static %s = %s;\n", str, value); Delete(str); value = wname; } if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); Replaceall(tm, "$value", cppvalue ? cppvalue : value); Replaceall(tm, "$nsname", iname); Printf(f_init, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); return SWIG_NOWRAP; } return SWIG_OK; } virtual int nativeWrapper(Node *n) { return Language::nativeWrapper(n); } virtual int enumDeclaration(Node *n) { return Language::enumDeclaration(n); } virtual int enumvalueDeclaration(Node *n) { return Language::enumvalueDeclaration(n); } virtual int classDeclaration(Node *n) { return Language::classDeclaration(n); } virtual int classHandler(Node *n) { have_constructor = 0; have_destructor = 0; constructor_name = 0; class_name = Getattr(n, "sym:name"); if (!addSymbol(class_name, n)) return SWIG_ERROR; // This is a bug, due to the fact that swig_type -> octave_class mapping // is 1-to-n. static Hash *emitted = NewHash(); String *mangled_classname = Swig_name_mangle(Getattr(n, "name")); if (Getattr(emitted, mangled_classname)) { Delete(mangled_classname); return SWIG_NOWRAP; } Setattr(emitted, mangled_classname, "1"); Delete(mangled_classname); assert(!s_members_tab); s_members_tab = NewString(""); Printv(s_members_tab, "static swig_octave_member swig_", class_name, "_members[] = {\n", NIL); Language::classHandler(n); SwigType *t = Copy(Getattr(n, "name")); SwigType_add_pointer(t); String *wrap_class = NewStringf("&_wrap_class_%s", class_name); SwigType_remember_clientdata(t, wrap_class); int use_director = Swig_directorclass(n); if (use_director) { String *nspace = Getattr(n, "sym:nspace"); String *cname = Swig_name_disown(nspace, class_name); String *wcname = Swig_name_wrapper(cname); String *cnameshdw = NewStringf("%s_shadow", cname); String *wcnameshdw = Swig_name_wrapper(cnameshdw); Octave_begin_function(n, f_wrappers, cnameshdw, wcnameshdw, true); Printf(f_wrappers, " if (args.length()!=1) {\n"); Printf(f_wrappers, " error(\"disown takes no arguments\");\n"); Printf(f_wrappers, " return octave_value_list();\n"); Printf(f_wrappers, " }\n"); Printf(f_wrappers, " %s (args, nargout);\n", wcname); Printf(f_wrappers, " return args;\n"); Printf(f_wrappers, "}\n"); Printf(s_members_tab, "{\"__disown\",%s,0,0,0,0},\n", wcnameshdw); Delete(wcname); Delete(cname); Delete(wcnameshdw); Delete(cnameshdw); } Printf(s_members_tab, "{0,0,0,0}\n};\n"); Printv(f_wrappers, s_members_tab, NIL); String *base_class_names = NewString(""); String *base_class = NewString(""); List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist)) { Iterator b; int index = 0; b = First(baselist); while (b.item) { String *bname = Getattr(b.item, "name"); if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) { b = Next(b); continue; } String *bname_mangled = SwigType_manglestr(SwigType_add_pointer(Copy(bname))); Printf(base_class_names, "\"%s\",", bname_mangled); Printf(base_class, "0,"); b = Next(b); index++; Delete(bname_mangled); } } Printv(f_wrappers, "static const char *swig_", class_name, "_base_names[] = {", base_class_names, "0};\n", NIL); Printv(f_wrappers, "static const swig_type_info *swig_", class_name, "_base[] = {", base_class, "0};\n", NIL); Printv(f_wrappers, "static swig_octave_class _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL); Printv(f_wrappers, Swig_directorclass(n) ? "1," : "0,", NIL); if (have_constructor) { String *nspace = Getattr(n, "sym:nspace"); String *cname = Swig_name_construct(nspace, constructor_name); String *wcname = Swig_name_wrapper(cname); String *tname = texinfo_name(n); Printf(f_wrappers, "%s,%s,", wcname, tname); Delete(tname); Delete(wcname); Delete(cname); } else Printv(f_wrappers, "0,0,", NIL); if (have_destructor) { String *nspace = Getattr(n, "sym:nspace"); String *cname = Swig_name_destroy(nspace, class_name); String *wcname = Swig_name_wrapper(cname); Printf(f_wrappers, "%s,", wcname); Delete(wcname); Delete(cname); } else Printv(f_wrappers, "0", ",", NIL); Printf(f_wrappers, "swig_%s_members,swig_%s_base_names,swig_%s_base };\n\n", class_name, class_name, class_name); Delete(base_class); Delete(base_class_names); Delete(t); Delete(s_members_tab); s_members_tab = 0; class_name = 0; return SWIG_OK; } virtual int memberfunctionHandler(Node *n) { Language::memberfunctionHandler(n); assert(s_members_tab); assert(class_name); String *name = Getattr(n, "name"); String *iname = GetChar(n, "sym:name"); String *realname = iname ? iname : name; String *wname = Getattr(n, "wrap:name"); assert(wname); if (!Getattr(n, "sym:nextSibling")) { String *tname = texinfo_name(n); String *rname = Copy(wname); bool overloaded = !!Getattr(n, "sym:overloaded"); if (overloaded) Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END); Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n", realname, rname, tname); Delete(rname); Delete(tname); } return SWIG_OK; } virtual int membervariableHandler(Node *n) { Setattr(n, "feature:autodoc", "0"); Language::membervariableHandler(n); assert(s_members_tab); assert(class_name); String *symname = Getattr(n, "sym:name"); String *getname = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)); String *setname = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)); String *getwname = Swig_name_wrapper(getname); String *setwname = GetFlag(n, "feature:immutable") ? NewString("octave_set_immutable") : Swig_name_wrapper(setname); assert(s_members_tab); Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getwname, setwname); Delete(getname); Delete(setname); Delete(getwname); Delete(setwname); return SWIG_OK; } virtual int constructorHandler(Node *n) { have_constructor = 1; if (!constructor_name) constructor_name = NewString(Getattr(n, "sym:name")); int use_director = Swig_directorclass(n); if (use_director) { Parm *parms = Getattr(n, "parms"); Parm *self; String *name = NewString("self"); String *type = NewString("void"); SwigType_add_pointer(type); self = NewParm(type, name, n); Delete(type); Delete(name); Setattr(self, "lname", "self_obj"); if (parms) set_nextSibling(self, parms); Setattr(n, "parms", self); Setattr(n, "wrap:self", "1"); Setattr(n, "hidden", "1"); Delete(self); } return Language::constructorHandler(n); } virtual int destructorHandler(Node *n) { have_destructor = 1; return Language::destructorHandler(n); } virtual int staticmemberfunctionHandler(Node *n) { Language::staticmemberfunctionHandler(n); assert(s_members_tab); assert(class_name); String *name = Getattr(n, "name"); String *iname = GetChar(n, "sym:name"); String *realname = iname ? iname : name; String *wname = Getattr(n, "wrap:name"); assert(wname); if (!Getattr(n, "sym:nextSibling")) { String *tname = texinfo_name(n); String *rname = Copy(wname); bool overloaded = !!Getattr(n, "sym:overloaded"); if (overloaded) Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END); Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n", realname, rname, tname); Delete(rname); Delete(tname); } return SWIG_OK; } virtual int memberconstantHandler(Node *n) { return Language::memberconstantHandler(n); } virtual int staticmembervariableHandler(Node *n) { Setattr(n, "feature:autodoc", "0"); Language::staticmembervariableHandler(n); if (!GetFlag(n, "wrappedasconstant")) { assert(s_members_tab); assert(class_name); String *symname = Getattr(n, "sym:name"); String *getname = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)); String *setname = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)); String *getwname = Swig_name_wrapper(getname); String *setwname = GetFlag(n, "feature:immutable") ? NewString("octave_set_immutable") : Swig_name_wrapper(setname); assert(s_members_tab); Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getwname, setwname); Delete(getname); Delete(setname); Delete(getwname); Delete(setwname); } return SWIG_OK; } int classDirectorInit(Node *n) { String *declaration = Swig_director_declaration(n); Printf(f_directors_h, "\n"); Printf(f_directors_h, "%s\n", declaration); Printf(f_directors_h, "public:\n"); Delete(declaration); return Language::classDirectorInit(n); } int classDirectorEnd(Node *n) { Printf(f_directors_h, "};\n\n"); return Language::classDirectorEnd(n); } int classDirectorConstructor(Node *n) { Node *parent = Getattr(n, "parentNode"); String *sub = NewString(""); String *decl = Getattr(n, "decl"); String *supername = Swig_class_name(parent); String *classname = NewString(""); Printf(classname, "SwigDirector_%s", supername); // insert self parameter Parm *p; ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("void"); SwigType_add_pointer(type); p = NewParm(type, NewString("self"), n); set_nextSibling(p, parms); parms = p; if (!Getattr(n, "defaultargs")) { // constructor { Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s," "\nSwig::Director(static_cast<%s*>(this)) { \n", classname, target, call, basetype); Append(w->def, "}\n"); Delete(target); Wrapper_print(w, f_directors); Delete(call); DelWrapper(w); } // constructor header { String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } } Delete(sub); Delete(classname); Delete(supername); Delete(parms); return Language::classDirectorConstructor(n); } int classDirectorDefaultConstructor(Node *n) { String *classname = Swig_class_name(n); { Wrapper *w = NewWrapper(); Printf(w->def, "SwigDirector_%s::SwigDirector_%s(void* self) :" "\nSwig::Director((octave_swig_type*)self,static_cast<%s*>(this)) { \n", classname, classname, classname); Append(w->def, "}\n"); Wrapper_print(w, f_directors); DelWrapper(w); } Printf(f_directors_h, " SwigDirector_%s(octave_swig_type* self);\n", classname); Delete(classname); return Language::classDirectorDefaultConstructor(n); } int classDirectorMethod(Node *n, Node *parent, String *super) { int is_void = 0; int is_pointer = 0; String *decl = Getattr(n, "decl"); String *returntype = Getattr(n, "type"); String *name = Getattr(n, "name"); String *classname = Getattr(parent, "sym:name"); String *c_classname = Getattr(parent, "name"); String *symname = Getattr(n, "sym:name"); String *declaration = NewString(""); ParmList *l = Getattr(n, "parms"); Wrapper *w = NewWrapper(); String *tm; String *wrap_args = NewString(""); String *value = Getattr(n, "value"); String *storage = Getattr(n, "storage"); bool pure_virtual = false; int status = SWIG_OK; int idx; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; if (Cmp(storage, "virtual") == 0) { if (Cmp(value, "0") == 0) { pure_virtual = true; } } // determine if the method returns a pointer is_pointer = SwigType_ispointer_return(decl); is_void = (!Cmp(returntype, "void") && !is_pointer); // virtual method definition String *target; String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); // header declaration target = Swig_method_decl(rtype, decl, name, l, 0, 1); Printf(declaration, " virtual %s", target); Delete(target); // Get any exception classes in the throws typemap ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { Parm *p; int gencomma = 0; Append(w->def, " throw("); Append(declaration, " throw("); if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); } String *str = SwigType_str(Getattr(p, "type"), 0); Append(w->def, str); Append(declaration, str); Delete(str); } } Append(w->def, ")"); Append(declaration, ")"); } Append(w->def, " {"); Append(declaration, ";\n"); // declare method return value // if the return value is a reference or const reference, a specialized typemap must // handle it, including declaration of c_result ($result). if (!is_void) { if (!(ignored_method && !pure_virtual)) { String *cres = SwigType_lstr(returntype, "c_result"); Printf(w->code, "%s;\n", cres); Delete(cres); } } if (ignored_method) { if (!pure_virtual) { if (!is_void) Printf(w->code, "return "); String *super_call = Swig_method_call(super, l); Printf(w->code, "%s;\n", super_call); Delete(super_call); } else { Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } } else { // attach typemaps to arguments (C/C++ -> Python) String *parse_args = NewString(""); Swig_director_parms_fixup(l); Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); Parm *p; int outputs = 0; if (!is_void) outputs++; // build argument list and type conversion string p = l; while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } if (Getattr(p, "tmap:directorargout") != 0) outputs++; String *pname = Getattr(p, "name"); String *ptype = Getattr(p, "type"); Wrapper_add_local(w, "tmpv", "octave_value tmpv"); if ((tm = Getattr(p, "tmap:directorin")) != 0) { String *parse = Getattr(p, "tmap:directorin:parse"); if (!parse) { Setattr(p, "emit:directorinput", "tmpv"); Replaceall(tm, "$input", "tmpv"); Replaceall(tm, "$owner", "0"); Printv(wrap_args, tm, "\n", NIL); Printf(wrap_args, "args.append(tmpv);\n"); Putc('O', parse_args); } else { Append(parse_args, parse); Setattr(p, "emit:directorinput", pname); Replaceall(tm, "$input", pname); Replaceall(tm, "$owner", "0"); if (Len(tm) == 0) Append(tm, pname); } p = Getattr(p, "tmap:directorin:next"); continue; } else if (Cmp(ptype, "void")) { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_NOWRAP; break; } p = nextSibling(p); } String *method_name = Getattr(n, "sym:name"); Printv(w->code, wrap_args, NIL); // emit method invocation Wrapper_add_local(w, "args", "octave_value_list args"); Wrapper_add_local(w, "out", "octave_value_list out"); Wrapper_add_local(w, "idx", "std::list idx"); Printf(w->code, "idx.push_back(octave_value_list(\"%s\"));\n", method_name); Printf(w->code, "idx.push_back(args);\n"); Printf(w->code, "out=swig_get_self()->subsref(\".(\",idx,%d);\n", outputs); String *cleanup = NewString(""); String *outarg = NewString(""); idx = 0; // marshal return value if (!is_void) { Printf(w->code, "if (out.length()<%d) {\n", outputs); Printf(w->code, "Swig::DirectorTypeMismatchException::raise(\"Octave " "method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name); Printf(w->code, "}\n"); tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); if (tm != 0) { char temp[24]; sprintf(temp, "out(%d)", idx); Replaceall(tm, "$input", temp); // Replaceall(tm, "$argnum", temp); Replaceall(tm, "$disown", Getattr(n, "wrap:disown") ? "SWIG_POINTER_DISOWN" : "0"); if (Getattr(n, "tmap:directorout:implicitconv")) { Replaceall(tm, "$implicitconv", get_implicitconv_flag(n)); } Replaceall(tm, "$result", "c_result"); Printv(w->code, tm, "\n", NIL); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_ERROR; } } idx++; // marshal outputs for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { char temp[24]; sprintf(temp, "out(%d)", idx); Replaceall(tm, "$result", temp); Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } Delete(parse_args); Delete(cleanup); Delete(outarg); } if (!is_void) { if (!(ignored_method && !pure_virtual)) { String *rettype = SwigType_str(returntype, 0); if (!SwigType_isreference(returntype)) { Printf(w->code, "return (%s) c_result;\n", rettype); } else { Printf(w->code, "return (%s) *c_result;\n", rettype); } Delete(rettype); } } Append(w->code, "}\n"); // We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method String *inline_extra_method = NewString(""); if (dirprot_mode() && !is_public(n) && !pure_virtual) { Printv(inline_extra_method, declaration, NIL); String *extra_method_name = NewStringf("%sSwigPublic", name); Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, ";\n", " {\n "); if (!is_void) Printf(inline_extra_method, "return "); String *methodcall = Swig_method_call(super, l); Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Delete(methodcall); Delete(extra_method_name); } // emit the director method if (status == SWIG_OK) { if (!Getattr(n, "defaultargs")) { Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); } } // clean up Delete(wrap_args); Delete(pclassname); DelWrapper(w); return status; } String *runtimeCode() { String *s = NewString(""); String *srun = Swig_include_sys("octrun.swg"); if (!srun) { Printf(stderr, "*** Unable to open 'octrun.swg'\n"); } else { Append(s, srun); Delete(srun); } return s; } String *defaultExternalRuntimeFilename() { return NewString("swigoctaverun.h"); } }; extern "C" Language *swig_octave(void) { return new OCTAVE(); } swig-3.0.2/Source/Modules/ruby.cxx0000664000175000017500000032377712343605122016743 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * ruby.cxx * * Ruby language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" static int treduce = SWIG_cparse_template_reduce(0); #define SWIG_PROTECTED_TARGET_METHODS 1 #include #include #include /* for INT_MAX */ class RClass { private: String *temp; public: String *name; /* class name (renamed) */ String *cname; /* original C class/struct name */ String *mname; /* Mangled name */ /** * The C variable name used in the SWIG-generated wrapper code to refer to * this class; usually it is of the form "SwigClassXXX.klass", where SwigClassXXX * is a swig_class struct instance and klass is a member of that struct. */ String *vname; /** * The C variable name used in the SWIG-generated wrapper code to refer to * the module that implements this class's methods (when we're trying to * support C++ multiple inheritance). Usually it is of the form * "SwigClassClassName.mImpl", where SwigClassXXX is a swig_class struct instance * and mImpl is a member of that struct. */ String *mImpl; String *type; String *prefix; String *init; int constructor_defined; int destructor_defined; RClass() { temp = NewString(""); name = NewString(""); cname = NewString(""); mname = NewString(""); vname = NewString(""); mImpl = NewString(""); type = NewString(""); prefix = NewString(""); init = NewString(""); constructor_defined = 0; destructor_defined = 0; } ~RClass() { Delete(name); Delete(cname); Delete(vname); Delete(mImpl); Delete(mname); Delete(type); Delete(prefix); Delete(init); Delete(temp); } void set_name(const_String_or_char_ptr cn, const_String_or_char_ptr rn, const_String_or_char_ptr valn) { /* Original C/C++ class (or struct) name */ Clear(cname); Append(cname, cn); /* Mangled name */ Delete(mname); mname = Swig_name_mangle(cname); /* Renamed class name */ Clear(name); Append(name, valn); /* Variable name for the VALUE that refers to the Ruby Class object */ Clear(vname); Printf(vname, "SwigClass%s.klass", name); /* Variable name for the VALUE that refers to the Ruby Class object */ Clear(mImpl); Printf(mImpl, "SwigClass%s.mImpl", name); /* Prefix */ Clear(prefix); Printv(prefix, (rn ? rn : cn), "_", NIL); } char *strip(const_String_or_char_ptr s) { Clear(temp); Append(temp, s); if (Strncmp(s, prefix, Len(prefix)) == 0) { Replaceall(temp, prefix, ""); } return Char(temp); } }; /* flags for the make_autodoc function */ enum autodoc_t { AUTODOC_CLASS, AUTODOC_CTOR, AUTODOC_DTOR, AUTODOC_STATICFUNC, AUTODOC_FUNC, AUTODOC_METHOD, AUTODOC_GETTER, AUTODOC_SETTER, AUTODOC_NONE }; static const char *usage = "\ Ruby Options (available with -ruby)\n\ -autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\ -cppcast - Enable C++ casting operators (default)\n\ -globalmodule - Wrap everything into the global module\n\ -initname - Set entry function to Init_ (used by `require')\n\ -minherit - Attempt to support multiple inheritance\n\ -noautorename - Disable renaming of classes and methods (default)\n\ -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -prefix - Set a prefix to be prepended to all names\n\ "; #define RCLASS(hash, name) (RClass*)(Getattr(hash, name) ? Data(Getattr(hash, name)) : 0) #define SET_RCLASS(hash, name, klass) Setattr(hash, name, NewVoid(klass, 0)) class RUBY:public Language { private: String *module; String *modvar; String *feature; String *prefix; int current; Hash *classes; /* key=cname val=RClass */ RClass *klass; /* Currently processing class */ Hash *special_methods; /* Python style special method name table */ File *f_directors; File *f_directors_h; File *f_directors_helpers; File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; File *f_wrappers; File *f_init; File *f_initbeforefunc; bool useGlobalModule; bool multipleInheritance; // Wrap modes enum WrapperMode { NO_CPP, MEMBER_FUNC, CONSTRUCTOR_ALLOCATE, CONSTRUCTOR_INITIALIZE, DESTRUCTOR, MEMBER_VAR, CLASS_CONST, STATIC_FUNC, STATIC_VAR }; /* ------------------------------------------------------------ * autodoc level declarations * ------------------------------------------------------------ */ enum autodoc_l { NO_AUTODOC = -2, // no autodoc STRING_AUTODOC = -1, // use provided string NAMES_AUTODOC = 0, // only parameter names TYPES_AUTODOC = 1, // parameter names and types EXTEND_AUTODOC = 2, // extended documentation and parameter names EXTEND_TYPES_AUTODOC = 3 // extended documentation and parameter types + names }; autodoc_t last_mode; String* last_autodoc; autodoc_l autodoc_level(String *autodoc) { autodoc_l dlevel = NO_AUTODOC; char *c = Char(autodoc); if (c) { if (isdigit(c[0])) { dlevel = (autodoc_l) atoi(c); } else { if (strcmp(c, "extended") == 0) { dlevel = EXTEND_AUTODOC; } else { dlevel = STRING_AUTODOC; } } } return dlevel; } /* ------------------------------------------------------------ * have_docstring() * Check if there is a docstring directive and it has text, * or there is an autodoc flag set * ------------------------------------------------------------ */ bool have_docstring(Node *n) { String *str = Getattr(n, "feature:docstring"); return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); } /* ------------------------------------------------------------ * docstring() * Get the docstring text, stripping off {} if neccessary, * and enclose in triple double quotes. If autodoc is also * set then it will build a combined docstring. * ------------------------------------------------------------ */ String *docstring(Node *n, autodoc_t ad_type) { String *str = Getattr(n, "feature:docstring"); bool have_ds = (str && Len(str) > 0); bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); String *autodoc = NULL; String *doc = NULL; if (have_ds) { char *t = Char(str); if (*t == '{') { Delitem(str, 0); Delitem(str, DOH_END); } } if (have_auto) { autodoc = make_autodoc(n, ad_type); have_auto = (autodoc && Len(autodoc) > 0); } // If there is more than one line then make docstrings like this: // // This is line1 // And here is line2 followed by the rest of them // // otherwise, put it all on a single line // if (have_auto && have_ds) { // Both autodoc and docstring are present doc = NewString(""); Printv(doc, "\n", autodoc, "\n", str, NIL); } else if (!have_auto && have_ds) { // only docstring if (Strchr(str, '\n') == 0) { doc = NewString(str); } else { doc = NewString(""); Printv(doc, str, NIL); } } else if (have_auto && !have_ds) { // only autodoc if (Strchr(autodoc, '\n') == 0) { doc = NewStringf("%s", autodoc); } else { doc = NewString(""); Printv(doc, "\n", autodoc, NIL); } } else doc = NewString(""); // Save the generated strings in the parse tree in case they are used later // by post processing tools Setattr(n, "ruby:docstring", doc); Setattr(n, "ruby:autodoc", autodoc); return doc; } /* ----------------------------------------------------------------------------- * addMissingParameterNames() * For functions that have not had nameless parameters set in the Language class. * * Inputs: * plist - entire parameter list * arg_offset - argument number for first parameter * Side effects: * The "lname" attribute in each parameter in plist will be contain a parameter name * ----------------------------------------------------------------------------- */ void addMissingParameterNames(ParmList *plist, int arg_offset) { Parm *p = plist; int i = arg_offset; while (p) { if (!Getattr(p, "lname")) { String *pname = Swig_cparm_name(p, i); Delete(pname); } i++; p = nextSibling(p); } } /* ------------------------------------------------------------ * make_autodocParmList() * Generate the documentation for the function parameters * ------------------------------------------------------------ */ String *make_autodocParmList(Node *n, bool showTypes) { String *doc = NewString(""); String *pdocs = 0; ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; int lines = 0; int start_arg_num = is_wrapping_class() ? 1 : 0; const int maxwidth = 80; addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); if (Strcmp(ParmList_protostr(plist), "void") == 0) { //No parameters actually return doc; } for (p = plist; p; p = pnext) { String *tm = Getattr(p, "tmap:in"); if (tm) { pnext = Getattr(p, "tmap:in:next"); if (checkAttribute(p, "tmap:in:numinputs", "0")) { continue; } } else { pnext = nextSibling(p); } String *name = 0; String *type = 0; String *value = 0; String *pdoc = Getattr(p, "tmap:doc"); if (pdoc) { name = Getattr(p, "tmap:doc:name"); type = Getattr(p, "tmap:doc:type"); value = Getattr(p, "tmap:doc:value"); } // Note: the generated name should be consistent with that in kwnames[] name = name ? name : Getattr(p, "name"); name = name ? name : Getattr(p, "lname"); name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); if (SwigType_isvarargs(type)) break; // Skip the 'self' parameter which in ruby is implicit if ( Cmp(name, "self") == 0 ) continue; // Make __p parameters just p (as used in STL) Replace( name, "__", "", DOH_REPLACE_FIRST ); if (Len(doc)) { // add a comma to the previous one if any Append(doc, ", "); // Do we need to wrap a long line? if ((Len(doc) - lines * maxwidth) > maxwidth) { Printf(doc, "\n%s", tab4); lines += 1; } } // Do the param type too? Node *nn = classLookup(Getattr(p, "type")); String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); if (showTypes) Printf(doc, "%s ", type_str); Append(doc, name); if (pdoc) { if (!pdocs) pdocs = NewString("Parameters:\n"); Printf(pdocs, " %s.\n", pdoc); } if (value) { String *new_value = convertValue(value, Getattr(p, "type")); if (new_value) { value = new_value; } else { Node *lookup = Swig_symbol_clookup(value, 0); if (lookup) value = Getattr(lookup, "sym:name"); } Printf(doc, "=%s", value); } Delete(type_str); Delete(name); } if (pdocs) Setattr(n, "feature:pdocs", pdocs); Delete(plist); return doc; } /* ------------------------------------------------------------ * make_autodoc() * Build a docstring for the node, using parameter and other * info in the parse tree. If the value of the autodoc * attribute is "0" then do not include parameter types, if * it is "1" (the default) then do. If it has some other * value then assume it is supplied by the extension writer * and use it directly. * ------------------------------------------------------------ */ String *make_autodoc(Node *n, autodoc_t ad_type) { int extended = 0; // If the function is overloaded then this funciton is called // for the last one. Rewind to the first so the docstrings are // in order. while (Getattr(n, "sym:previousSibling")) n = Getattr(n, "sym:previousSibling"); Node *pn = Swig_methodclass(n); String* super_names = NewString(""); String* class_name = Getattr(pn, "sym:name") ; if ( !class_name ) { class_name = NewString(""); } else { class_name = Copy(class_name); List *baselist = Getattr(pn, "bases"); if (baselist && Len(baselist)) { Iterator base = First(baselist); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } int count = 0; for ( ;base.item; ++count) { if ( count ) Append(super_names, ", "); String *basename = Getattr(base.item, "sym:name"); String* basenamestr = NewString(basename); Node* parent = parentNode(base.item); while (parent) { String *parent_name = Copy( Getattr(parent, "sym:name") ); if ( !parent_name ) { Node* mod = Getattr(parent, "module"); if ( mod ) parent_name = Copy( Getattr(mod, "name") ); if ( parent_name ) (Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]); } if ( parent_name ) { Insert(basenamestr, 0, "::"); Insert(basenamestr, 0, parent_name); Delete(parent_name); } parent = parentNode(parent); } Append(super_names, basenamestr ); Delete(basenamestr); base = Next(base); } } } String* full_name; if ( module ) { full_name = NewString(module); if (Len(class_name) > 0) Append(full_name, "::"); } else full_name = NewString(""); Append(full_name, class_name); String* symname = Getattr(n, "sym:name"); if ( Getattr( special_methods, symname ) ) symname = Getattr( special_methods, symname ); String* methodName = NewString(full_name); Append(methodName, symname); // Each overloaded function will try to get documented, // so we keep the name of the last overloaded function and its type. // Documenting just from functionWrapper() is not possible as // sym:name has already been changed to include the class name if ( last_mode == ad_type && Cmp(methodName, last_autodoc) == 0 ) { Delete(full_name); Delete(class_name); Delete(super_names); Delete(methodName); return NewString(""); } last_mode = ad_type; last_autodoc = Copy(methodName); String *doc = NewString("/*\n"); int counter = 0; bool skipAuto = false; Node* on = n; for ( ; n; ++counter ) { String *type_str = NULL; skipAuto = false; bool showTypes = false; String *autodoc = Getattr(n, "feature:autodoc"); autodoc_l dlevel = autodoc_level(autodoc); switch (dlevel) { case NO_AUTODOC: break; case NAMES_AUTODOC: showTypes = false; break; case TYPES_AUTODOC: showTypes = true; break; case EXTEND_AUTODOC: extended = 1; showTypes = false; break; case EXTEND_TYPES_AUTODOC: extended = 1; showTypes = true; break; case STRING_AUTODOC: skipAuto = true; break; } SwigType *type = Getattr(n, "type"); if (type) { if (Strcmp(type, "void") == 0) { type_str = NULL; } else { SwigType *qt = SwigType_typedef_resolve_all(type); if (SwigType_isenum(qt)) { type_str = NewString("int"); } else { Node *nn = classLookup(type); type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); } } } if (counter == 0) { switch (ad_type) { case AUTODOC_CLASS: Printf(doc, " Document-class: %s", full_name); if ( Len(super_names) > 0 ) Printf( doc, " < %s", super_names); Append(doc, "\n\n"); break; case AUTODOC_CTOR: Printf(doc, " Document-method: %s.new\n\n", full_name); break; case AUTODOC_DTOR: break; case AUTODOC_STATICFUNC: Printf(doc, " Document-method: %s.%s\n\n", full_name, symname); break; case AUTODOC_FUNC: case AUTODOC_METHOD: case AUTODOC_GETTER: Printf(doc, " Document-method: %s.%s\n\n", full_name, symname); break; case AUTODOC_SETTER: Printf(doc, " Document-method: %s.%s=\n\n", full_name, symname); break; case AUTODOC_NONE: break; } } if (skipAuto) { if ( counter == 0 ) Printf(doc, " call-seq:\n"); switch( ad_type ) { case AUTODOC_STATICFUNC: case AUTODOC_FUNC: case AUTODOC_METHOD: case AUTODOC_GETTER: { String *paramList = make_autodocParmList(n, showTypes); if (Len(paramList)) Printf(doc, " %s(%s)", symname, paramList); else Printf(doc, " %s", symname); if (type_str) Printf(doc, " -> %s", type_str); break; } case AUTODOC_SETTER: { Printf(doc, " %s=(x)", symname); if (type_str) Printf(doc, " -> %s", type_str); break; } default: break; } } else { switch (ad_type) { case AUTODOC_CLASS: { // Only do the autodoc if there isn't a docstring for the class String *str = Getattr(n, "feature:docstring"); if (counter == 0 && (str == 0 || Len(str) == 0)) { if (CPlusPlus) { Printf(doc, " Proxy of C++ %s class", full_name); } else { Printf(doc, " Proxy of C %s struct", full_name); } } } break; case AUTODOC_CTOR: if (counter == 0) Printf(doc, " call-seq:\n"); if (Strcmp(class_name, symname) == 0) { String *paramList = make_autodocParmList(n, showTypes); if (Len(paramList)) Printf(doc, " %s.new(%s)", class_name, paramList); else Printf(doc, " %s.new", class_name); } else { Printf(doc, " %s.new(%s)", class_name, make_autodocParmList(n, showTypes)); } break; case AUTODOC_DTOR: break; case AUTODOC_STATICFUNC: case AUTODOC_FUNC: case AUTODOC_METHOD: case AUTODOC_GETTER: { if (counter == 0) Printf(doc, " call-seq:\n"); String *paramList = make_autodocParmList(n, showTypes); if (Len(paramList)) Printf(doc, " %s(%s)", symname, paramList); else Printf(doc, " %s", symname); if (type_str) Printf(doc, " -> %s", type_str); break; } case AUTODOC_SETTER: { Printf(doc, " call-seq:\n"); Printf(doc, " %s=(x)", symname); if (type_str) Printf(doc, " -> %s", type_str); break; } case AUTODOC_NONE: break; } } // if it's overloaded then get the next decl and loop around again n = Getattr(n, "sym:nextSibling"); if (n) Append(doc, "\n"); Delete(type_str); } Printf(doc, "\n\n"); if (!skipAuto) { switch (ad_type) { case AUTODOC_CLASS: case AUTODOC_DTOR: break; case AUTODOC_CTOR: Printf(doc, "Class constructor.\n"); break; case AUTODOC_STATICFUNC: Printf(doc, "A class method.\n"); break; case AUTODOC_FUNC: Printf(doc, "A module function.\n"); break; case AUTODOC_METHOD: Printf(doc, "An instance method.\n"); break; case AUTODOC_GETTER: Printf(doc, "Get value of attribute.\n"); break; case AUTODOC_SETTER: Printf(doc, "Set new value for attribute.\n"); break; case AUTODOC_NONE: break; } } n = on; while ( n ) { String *autodoc = Getattr(n, "feature:autodoc"); autodoc_l dlevel = autodoc_level(autodoc); switch (dlevel) { case NO_AUTODOC: case NAMES_AUTODOC: case TYPES_AUTODOC: extended = 0; break; case STRING_AUTODOC: extended = 2; Replaceall( autodoc, "$class", class_name ); Printv(doc, autodoc, ".", NIL); break; case EXTEND_AUTODOC: case EXTEND_TYPES_AUTODOC: extended = 1; break; } if (extended) { String *pdocs = Getattr(n, "feature:pdocs"); if (pdocs) { Printv(doc, "\n\n", pdocs, NULL); break; } if ( extended == 2 ) break; } n = Getattr(n, "sym:nextSibling"); } Append(doc, "\n*/\n"); Delete(full_name); Delete(class_name); Delete(super_names); Delete(methodName); return doc; } /* ------------------------------------------------------------ * convertValue() * Check if string v can be a Ruby value literal, * (eg. number or string), or translate it to a Ruby literal. * ------------------------------------------------------------ */ String *convertValue(String *v, SwigType *t) { if (v && Len(v) > 0) { char fc = (Char(v))[0]; if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) { /* number or string (or maybe NULL pointer) */ if (SwigType_ispointer(t) && Strcmp(v, "0") == 0) return NewString("None"); else return v; } if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) return SwigType_ispointer(t) ? NewString("nil") : NewString("0"); if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) return NewString("True"); if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("False"); } return 0; } public: /* --------------------------------------------------------------------- * RUBY() * * Initialize member data * --------------------------------------------------------------------- */ RUBY() : module(0), modvar(0), feature(0), prefix(0), current(0), classes(0), klass(0), special_methods(0), f_directors(0), f_directors_h(0), f_directors_helpers(0), f_begin(0), f_runtime(0), f_runtime_h(0), f_header(0), f_wrappers(0), f_init(0), f_initbeforefunc(0), useGlobalModule(false), multipleInheritance(false), last_mode(AUTODOC_NONE), last_autodoc(NewString("")) { current = NO_CPP; director_prot_ctor_code = NewString(""); Printv(director_prot_ctor_code, "if ( $comparison ) { /* subclassed */\n", " $director_new \n", "} else {\n", " rb_raise(rb_eRuntimeError,\"accessing abstract class or protected constructor\"); \n", " return Qnil;\n", "}\n", NIL); director_multiple_inheritance = 0; director_language = 1; } /* --------------------------------------------------------------------- * main() * * Parse command line options and initializes variables. * --------------------------------------------------------------------- */ virtual void main(int argc, char *argv[]) { int cppcast = 1; int autorename = 0; /* Set location of SWIG library */ SWIG_library_directory("ruby"); /* Look for certain command line options */ for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-initname") == 0) { if (argv[i + 1]) { char *name = argv[i + 1]; feature = NewString(name); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-feature") == 0) { fprintf( stderr, "Warning: Ruby -feature option is deprecated, " "please use -initname instead.\n"); if (argv[i + 1]) { char *name = argv[i + 1]; feature = NewString(name); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-globalmodule") == 0) { useGlobalModule = true; Swig_mark_arg(i); } else if (strcmp(argv[i], "-minherit") == 0) { multipleInheritance = true; director_multiple_inheritance = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-cppcast") == 0) { cppcast = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nocppcast") == 0) { cppcast = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-autorename") == 0) { autorename = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-noautorename") == 0) { autorename = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-prefix") == 0) { if (argv[i + 1]) { char *name = argv[i + 1]; prefix = NewString(name); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-help") == 0) { Printf(stdout, "%s\n", usage); } } } if (cppcast) { /* Turn on cppcast mode */ Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); } if (autorename) { /* Turn on the autorename mode */ Preprocessor_define((DOH *) "SWIG_RUBY_AUTORENAME", 0); } /* Add a symbol to the parser for conditional compilation */ Preprocessor_define("SWIGRUBY 1", 0); /* Add typemap definitions */ SWIG_typemap_lang("ruby"); SWIG_config_file("ruby.swg"); allow_overloading(); } /** * Generate initialization code to define the Ruby module(s), * accounting for nested modules as necessary. */ void defineRubyModule() { List *modules = Split(module, ':', INT_MAX); if (modules != 0 && Len(modules) > 0) { String *mv = 0; Iterator m; m = First(modules); while (m.item) { if (Len(m.item) > 0) { if (mv != 0) { Printv(f_init, tab4, modvar, " = rb_define_module_under(", modvar, ", \"", m.item, "\");\n", NIL); } else { Printv(f_init, tab4, modvar, " = rb_define_module(\"", m.item, "\");\n", NIL); mv = NewString(modvar); } } m = Next(m); } Delete(mv); Delete(modules); } } void registerMagicMethods() { special_methods = NewHash(); /* Python->Ruby style special method name. */ /* Basic */ Setattr(special_methods, "__repr__", "inspect"); Setattr(special_methods, "__str__", "to_s"); Setattr(special_methods, "__cmp__", "<=>"); Setattr(special_methods, "__hash__", "hash"); Setattr(special_methods, "__nonzero__", "nonzero?"); /* Callable */ Setattr(special_methods, "__call__", "call"); /* Collection */ Setattr(special_methods, "__len__", "length"); Setattr(special_methods, "__getitem__", "[]"); Setattr(special_methods, "__setitem__", "[]="); /* Operators */ Setattr(special_methods, "__add__", "+"); Setattr(special_methods, "__pos__", "+@"); Setattr(special_methods, "__sub__", "-"); Setattr(special_methods, "__neg__", "-@"); Setattr(special_methods, "__mul__", "*"); Setattr(special_methods, "__div__", "/"); Setattr(special_methods, "__mod__", "%"); Setattr(special_methods, "__lshift__", "<<"); Setattr(special_methods, "__rshift__", ">>"); Setattr(special_methods, "__and__", "&"); Setattr(special_methods, "__or__", "|"); Setattr(special_methods, "__xor__", "^"); Setattr(special_methods, "__invert__", "~"); Setattr(special_methods, "__lt__", "<"); Setattr(special_methods, "__le__", "<="); Setattr(special_methods, "__gt__", ">"); Setattr(special_methods, "__ge__", ">="); Setattr(special_methods, "__eq__", "=="); /* Other numeric */ Setattr(special_methods, "__divmod__", "divmod"); Setattr(special_methods, "__pow__", "**"); Setattr(special_methods, "__abs__", "abs"); Setattr(special_methods, "__int__", "to_i"); Setattr(special_methods, "__float__", "to_f"); Setattr(special_methods, "__coerce__", "coerce"); } /* --------------------------------------------------------------------- * top() * --------------------------------------------------------------------- */ virtual int top(Node *n) { /** * See if any Ruby module options have been specified as options * to the %module directive. */ Node *swigModule = Getattr(n, "module"); if (swigModule) { Node *options = Getattr(swigModule, "options"); if (options) { if (Getattr(options, "directors")) { allow_directors(); } if (Getattr(options, "dirprot")) { allow_dirprot(); } if (Getattr(options, "ruby_globalmodule")) { useGlobalModule = true; } if (Getattr(options, "ruby_minherit")) { multipleInheritance = true; director_multiple_inheritance = 1; } } } /* Set comparison with none for ConstructorToFunction */ setSubclassInstanceCheck(NewStringf("strcmp(rb_obj_classname(self), classname) != 0")); // setSubclassInstanceCheck(NewString("CLASS_OF(self) != cFoo.klass")); /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); String *outfile_h = Getattr(n, "outfile_h"); if (!outfile) { Printf(stderr, "Unable to determine outfile\n"); SWIG_exit(EXIT_FAILURE); } f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); f_directors_h = NewString(""); f_directors = NewString(""); f_directors_helpers = NewString(""); f_initbeforefunc = NewString(""); if (directorsEnabled()) { if (!outfile_h) { Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); } } /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); Swig_register_filebyname("director_helpers", f_directors_helpers); Swig_register_filebyname("initbeforefunc", f_initbeforefunc); modvar = 0; current = NO_CPP; klass = 0; classes = NewHash(); registerMagicMethods(); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGRUBY\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } Printf(f_runtime, "\n"); /* typedef void *VALUE */ SwigType *value = NewSwigType(T_VOID); SwigType_add_pointer(value); SwigType_typedef(value, "VALUE"); Delete(value); /* Set module name */ set_module(Char(Getattr(n, "name"))); if (directorsEnabled()) { /* Build a version of the module name for use in a C macro name. */ String *module_macro = Copy(module); Replaceall(module_macro, "::", "__"); Swig_banner(f_directors_h); Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_macro); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_macro); Printf(f_directors_h, "namespace Swig {\n"); Printf(f_directors_h, " class Director;\n"); Printf(f_directors_h, "}\n\n"); Printf(f_directors_helpers, "/* ---------------------------------------------------\n"); Printf(f_directors_helpers, " * C++ director class helpers\n"); Printf(f_directors_helpers, " * --------------------------------------------------- */\n\n"); Printf(f_directors, "\n\n"); Printf(f_directors, "/* ---------------------------------------------------\n"); Printf(f_directors, " * C++ director class methods\n"); Printf(f_directors, " * --------------------------------------------------- */\n\n"); if (outfile_h) { String *filename = Swig_file_filename(outfile_h); Printf(f_directors, "#include \"%s\"\n\n", filename); Delete(filename); } Delete(module_macro); } Printf(f_header, "#define SWIG_init Init_%s\n", feature); Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); Printf(f_header, "static VALUE %s;\n", modvar); /* Start generating the initialization function */ String* docs = docstring(n, AUTODOC_CLASS); Printf(f_init, "/*\n%s\n*/", docs ); Printv(f_init, "\n", "#ifdef __cplusplus\n", "extern \"C\"\n", "#endif\n", "SWIGEXPORT void Init_", feature, "(void) {\n", "size_t i;\n", "\n", NIL); Printv(f_init, tab4, "SWIG_InitRuntime();\n", NIL); if (!useGlobalModule) defineRubyModule(); Printv(f_init, "\n", "SWIG_InitializeModule(0);\n", "for (i = 0; i < swig_module.size; i++) {\n", "SWIG_define_class(swig_module.types[i]);\n", "}\n", NIL); Printf(f_init, "\n"); /* Initialize code to keep track of objects */ Printf(f_init, "SWIG_RubyInitializeTrackings();\n"); Language::top(n); if (directorsEnabled()) { // Insert director runtime into the f_runtime file (make it occur before %header section) Swig_insert_file("director.swg", f_runtime); } /* Finish off our init function */ Printf(f_init, "}\n"); SwigType_emit_type_table(f_runtime, f_wrappers); /* Close all of the files */ Dump(f_runtime, f_begin); Dump(f_header, f_begin); if (directorsEnabled()) { Dump(f_directors_helpers, f_begin); Dump(f_directors, f_begin); Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); Delete(f_runtime_h); } Dump(f_wrappers, f_begin); Dump(f_initbeforefunc, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_initbeforefunc); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /* ----------------------------------------------------------------------------- * importDirective() * ----------------------------------------------------------------------------- */ virtual int importDirective(Node *n) { String *modname = Getattr(n, "module"); if (modname) { if (prefix) { Insert(modname, 0, prefix); } List *modules = Split(modname, ':', INT_MAX); if (modules && Len(modules) > 0) { modname = NewString(""); String *last = NULL; Iterator m = First(modules); while (m.item) { if (Len(m.item) > 0) { if (last) { Append(modname, "/"); } Append(modname, m.item); last = m.item; } m = Next(m); } Printf(f_init, "rb_require(\"%s\");\n", modname); Delete(modname); } Delete(modules); } return Language::importDirective(n); } /* --------------------------------------------------------------------- * set_module(const char *mod_name) * * Sets the module name. Does nothing if it's already set (so it can * be overridden as a command line option). *---------------------------------------------------------------------- */ void set_module(const char *s) { String *mod_name = NewString(s); if (module == 0) { /* Start with the empty string */ module = NewString(""); if (prefix) { Insert(mod_name, 0, prefix); } /* Account for nested modules */ List *modules = Split(mod_name, ':', INT_MAX); if (modules != 0 && Len(modules) > 0) { String *last = 0; Iterator m = First(modules); while (m.item) { if (Len(m.item) > 0) { String *cap = NewString(m.item); (Char(cap))[0] = (char)toupper((Char(cap))[0]); if (last != 0) { Append(module, "::"); } Append(module, cap); last = m.item; } m = Next(m); } if (last) { if (feature == 0) { feature = Copy(last); } (Char(last))[0] = (char)toupper((Char(last))[0]); modvar = NewStringf("m%s", last); } } Delete(modules); } Delete(mod_name); } /* -------------------------------------------------------------------------- * nativeWrapper() * -------------------------------------------------------------------------- */ virtual int nativeWrapper(Node *n) { String *funcname = Getattr(n, "wrap:name"); Swig_warning(WARN_LANG_NATIVE_UNIMPL, input_file, line_number, "Adding native function %s not supported (ignored).\n", funcname); return SWIG_NOWRAP; } /** * Process the comma-separated list of aliases (if any). */ void defineAliases(Node *n, const_String_or_char_ptr iname) { String *aliasv = Getattr(n, "feature:alias"); if (aliasv) { List *aliases = Split(aliasv, ',', INT_MAX); if (aliases && Len(aliases) > 0) { Iterator alias = First(aliases); while (alias.item) { if (Len(alias.item) > 0) { if (multipleInheritance) { Printv(klass->init, tab4, "rb_define_alias(", klass->mImpl, ", \"", alias.item, "\", \"", iname, "\");\n", NIL); } else { Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias.item, "\", \"", iname, "\");\n", NIL); } } alias = Next(alias); } } Delete(aliases); } } /* --------------------------------------------------------------------- * create_command(Node *n, char *iname) * * Creates a new command from a C function. * iname = Name of function in scripting language * * A note about what "protected" and "private" mean in Ruby: * * A private method is accessible only within the class or its subclasses, * and it is callable only in "function form", with 'self' (implicit or * explicit) as a receiver. * * A protected method is callable only from within its class, but unlike * a private method, it can be called with a receiver other than self, such * as another instance of the same class. * --------------------------------------------------------------------- */ void create_command(Node *n, const_String_or_char_ptr iname) { String *alloc_func = Swig_name_wrapper(iname); String *wname = Swig_name_wrapper(iname); if (CPlusPlus) { Insert(wname, 0, "VALUEFUNC("); Append(wname, ")"); } if (current != NO_CPP) iname = klass->strip(iname); if (Getattr(special_methods, iname)) { iname = GetChar(special_methods, iname); } String *s = NewString(""); String *temp = NewString(""); #ifdef SWIG_PROTECTED_TARGET_METHODS const char *rb_define_method = is_public(n) ? "rb_define_method" : "rb_define_protected_method"; #else const char *rb_define_method = "rb_define_method"; #endif switch (current) { case MEMBER_FUNC: { if (multipleInheritance) { Printv(klass->init, tab4, rb_define_method, "(", klass->mImpl, ", \"", iname, "\", ", wname, ", -1);\n", NIL); } else { Printv(klass->init, tab4, rb_define_method, "(", klass->vname, ", \"", iname, "\", ", wname, ", -1);\n", NIL); } } break; case CONSTRUCTOR_ALLOCATE: Printv(s, tab4, "rb_define_alloc_func(", klass->vname, ", ", alloc_func, ");\n", NIL); Replaceall(klass->init, "$allocator", s); break; case CONSTRUCTOR_INITIALIZE: Printv(s, tab4, rb_define_method, "(", klass->vname, ", \"initialize\", ", wname, ", -1);\n", NIL); Replaceall(klass->init, "$initializer", s); break; case MEMBER_VAR: Append(temp, iname); /* Check for _set or _get at the end of the name. */ if (Len(temp) > 4) { const char *p = Char(temp) + (Len(temp) - 4); if (strcmp(p, "_set") == 0) { Delslice(temp, Len(temp) - 4, DOH_END); Append(temp, "="); } else if (strcmp(p, "_get") == 0) { Delslice(temp, Len(temp) - 4, DOH_END); } } if (multipleInheritance) { Printv(klass->init, tab4, "rb_define_method(", klass->mImpl, ", \"", temp, "\", ", wname, ", -1);\n", NIL); } else { Printv(klass->init, tab4, "rb_define_method(", klass->vname, ", \"", temp, "\", ", wname, ", -1);\n", NIL); } break; case STATIC_FUNC: Printv(klass->init, tab4, "rb_define_singleton_method(", klass->vname, ", \"", iname, "\", ", wname, ", -1);\n", NIL); break; case NO_CPP: if (!useGlobalModule) { Printv(s, tab4, "rb_define_module_function(", modvar, ", \"", iname, "\", ", wname, ", -1);\n", NIL); Printv(f_init, s, NIL); } else { Printv(s, tab4, "rb_define_global_function(\"", iname, "\", ", wname, ", -1);\n", NIL); Printv(f_init, s, NIL); } break; case DESTRUCTOR: case CLASS_CONST: case STATIC_VAR: assert(false); // Should not have gotten here for these types default: assert(false); } defineAliases(n, iname); Delete(temp); Delete(s); Delete(wname); Delete(alloc_func); } /* --------------------------------------------------------------------- * applyInputTypemap() * * Look up the appropriate "in" typemap for this parameter (p), * substitute the correct strings for the $target and $input typemap * parameters, and dump the resulting code to the wrapper file. * --------------------------------------------------------------------- */ Parm *applyInputTypemap(Parm *p, String *ln, String *source, Wrapper *f, String *symname) { String *tm; SwigType *pt = Getattr(p, "type"); if ((tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$target", ln); Replaceall(tm, "$source", source); Replaceall(tm, "$input", source); Replaceall(tm, "$symname", symname); if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } Setattr(p, "emit:input", Copy(source)); Printf(f->code, "%s\n", tm); p = Getattr(p, "tmap:in:next"); } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); p = nextSibling(p); } return p; } Parm *skipIgnoredArgs(Parm *p) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } return p; } /* --------------------------------------------------------------------- * marshalInputArgs() * * Process all of the arguments passed into the scripting language * method and convert them into C/C++ function arguments using the * supplied typemaps. * --------------------------------------------------------------------- */ void marshalInputArgs(Node *n, ParmList *l, int numarg, int numreq, String *kwargs, bool allow_kwargs, Wrapper *f) { int i; Parm *p; String *tm; String *source; String *target; source = NewString(""); target = NewString(""); bool ctor_director = (current == CONSTRUCTOR_INITIALIZE && Swig_directorclass(n)); /** * The 'start' value indicates which of the C/C++ function arguments * produced here corresponds to the first value in Ruby's argv[] array. * The value of start is either zero or one. If start is zero, then * the first argument (with name arg1) is based on the value of argv[0]. * If start is one, then arg1 is based on the value of argv[1]. */ int start = (current == MEMBER_FUNC || current == MEMBER_VAR || ctor_director) ? 1 : 0; int varargs = emit_isvarargs(l); Printf(kwargs, "{ "); for (i = 0, p = l; i < numarg; i++) { p = skipIgnoredArgs(p); String *pn = Getattr(p, "name"); String *ln = Getattr(p, "lname"); /* Produce string representation of source argument */ Clear(source); /* First argument is a special case */ if (i == 0) { Printv(source, (start == 0) ? "argv[0]" : "self", NIL); } else { Printf(source, "argv[%d]", i - start); } /* Produce string representation of target argument */ Clear(target); Printf(target, "%s", Char(ln)); if (i >= (numreq)) { /* Check if parsing an optional argument */ Printf(f->code, " if (argc > %d) {\n", i - start); } /* Record argument name for keyword argument handling */ if (Len(pn)) { Printf(kwargs, "\"%s\",", pn); } else { Printf(kwargs, "\"arg%d\",", i + 1); } /* Look for an input typemap */ p = applyInputTypemap(p, ln, source, f, Getattr(n, "name")); if (i >= numreq) { Printf(f->code, "}\n"); } } /* Finish argument marshalling */ Printf(kwargs, " NULL }"); if (allow_kwargs) { Printv(f->locals, tab4, "const char *kwnames[] = ", kwargs, ";\n", NIL); } /* Trailing varargs */ if (varargs) { if (p && (tm = Getattr(p, "tmap:in"))) { Clear(source); Printf(source, "argv[%d]", i - start); Replaceall(tm, "$input", source); Setattr(p, "emit:input", Copy(source)); Printf(f->code, "if (argc > %d) {\n", i - start); Printv(f->code, tm, "\n", NIL); Printf(f->code, "}\n"); } } Delete(source); Delete(target); } /* --------------------------------------------------------------------- * insertConstraintCheckingCode(ParmList *l, Wrapper *f) * * Checks each of the parameters in the parameter list for a "check" * typemap and (if it finds one) inserts the typemapping code into * the function wrapper. * --------------------------------------------------------------------- */ void insertConstraintCheckingCode(ParmList *l, Wrapper *f) { Parm *p; String *tm; for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } } /* --------------------------------------------------------------------- * insertCleanupCode(ParmList *l, String *cleanup) * * Checks each of the parameters in the parameter list for a "freearg" * typemap and (if it finds one) inserts the typemapping code into * the function wrapper. * --------------------------------------------------------------------- */ void insertCleanupCode(ParmList *l, String *cleanup) { String *tm; for (Parm *p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { if (Len(tm) != 0) { Replaceall(tm, "$source", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); } p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } } /* --------------------------------------------------------------------- * insertArgOutputCode(ParmList *l, String *outarg, int& need_result) * * Checks each of the parameters in the parameter list for a "argout" * typemap and (if it finds one) inserts the typemapping code into * the function wrapper. * --------------------------------------------------------------------- */ void insertArgOutputCode(ParmList *l, String *outarg, int &need_result) { String *tm; for (Parm *p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$target", "vresult"); Replaceall(tm, "$result", "vresult"); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); need_result += 1; p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } } /* --------------------------------------------------------------------- * validIdentifier() * * Is this a valid identifier in the scripting language? * Ruby method names can include any combination of letters, numbers * and underscores. A Ruby method name may optionally end with * a question mark ("?"), exclamation point ("!") or equals sign ("="). * * Methods whose names end with question marks are, by convention, * predicate methods that return true or false (e.g. Array#empty?). * * Methods whose names end with exclamation points are, by convention, * called bang methods that modify the instance in place (e.g. Array#sort!). * * Methods whose names end with an equals sign are attribute setters * (e.g. Thread#critical=). * --------------------------------------------------------------------- */ virtual int validIdentifier(String *s) { char *c = Char(s); while (*c) { if (!(isalnum(*c) || (*c == '_') || (*c == '?') || (*c == '!') || (*c == '='))) return 0; c++; } return 1; } /* --------------------------------------------------------------------- * functionWrapper() * * Create a function declaration and register it with the interpreter. * --------------------------------------------------------------------- */ virtual int functionWrapper(Node *n) { String *nodeType; bool destructor; String *symname = Copy(Getattr(n, "sym:name")); SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); int director_method = 0; String *tm; int need_result = 0; /* Ruby needs no destructor wrapper */ if (current == DESTRUCTOR) return SWIG_NOWRAP; nodeType = Getattr(n, "nodeType"); destructor = (!Cmp(nodeType, "destructor")); /* If the C++ class constructor is overloaded, we only want to * write out the "new" singleton method once since it is always * the same. (It's the "initialize" method that will handle the * overloading). */ if (current == CONSTRUCTOR_ALLOCATE && Swig_symbol_isoverloaded(n) && Getattr(n, "sym:nextSibling") != 0) return SWIG_OK; String *overname = 0; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(symname, n)) return SWIG_ERROR; } String *cleanup = NewString(""); String *outarg = NewString(""); String *kwargs = NewString(""); Wrapper *f = NewWrapper(); /* Rename predicate methods */ if (GetFlag(n, "feature:predicate")) { Append(symname, "?"); } /* Rename bang methods */ if (GetFlag(n, "feature:bang")) { Append(symname, "!"); } /* Determine the name of the SWIG wrapper function */ String *wname = Swig_name_wrapper(symname); if (overname && current != CONSTRUCTOR_ALLOCATE) { Append(wname, overname); } /* Emit arguments */ if (current != CONSTRUCTOR_ALLOCATE) { emit_parameter_variables(l, f); } /* Attach standard typemaps */ if (current != CONSTRUCTOR_ALLOCATE) { emit_attach_parmmaps(l, f); } Setattr(n, "wrap:parms", l); /* Get number of arguments */ int numarg = emit_num_arguments(l); int numreq = emit_num_required(l); int varargs = emit_isvarargs(l); bool allow_kwargs = GetFlag(n, "feature:kwargs") ? true : false; bool ctor_director = (current == CONSTRUCTOR_INITIALIZE && Swig_directorclass(n)); int start = (current == MEMBER_FUNC || current == MEMBER_VAR || ctor_director) ? 1 : 0; /* Now write the wrapper function itself */ if (current == CONSTRUCTOR_ALLOCATE) { Printf(f->def, "#ifdef HAVE_RB_DEFINE_ALLOC_FUNC\n"); Printv(f->def, "SWIGINTERN VALUE\n", wname, "(VALUE self) {", NIL); Printf(f->def, "#else\n"); Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL); Printf(f->def, "#endif\n"); } else if (current == CONSTRUCTOR_INITIALIZE) { Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL); if (!varargs) { Printf(f->code, "if ((argc < %d) || (argc > %d)) ", numreq - start, numarg - start); } else { Printf(f->code, "if (argc < %d) ", numreq - start); } Printf(f->code, "{rb_raise(rb_eArgError, \"wrong # of arguments(%%d for %d)\",argc); SWIG_fail;}\n", numreq - start); } else { if ( current == NO_CPP ) { String* docs = docstring(n, AUTODOC_FUNC); Printf(f_wrappers, "%s", docs); Delete(docs); } Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL); if (!varargs) { Printf(f->code, "if ((argc < %d) || (argc > %d)) ", numreq - start, numarg - start); } else { Printf(f->code, "if (argc < %d) ", numreq - start); } Printf(f->code, "{rb_raise(rb_eArgError, \"wrong # of arguments(%%d for %d)\",argc); SWIG_fail;}\n", numreq - start); } /* Now walk the function parameter list and generate code */ /* to get arguments */ if (current != CONSTRUCTOR_ALLOCATE) { marshalInputArgs(n, l, numarg, numreq, kwargs, allow_kwargs, f); } // FIXME? if (ctor_director) { numarg--; numreq--; } /* Insert constraint checking code */ insertConstraintCheckingCode(l, f); /* Insert cleanup code */ insertCleanupCode(l, cleanup); /* Insert argument output code */ insertArgOutputCode(l, outarg, need_result); /* if the object is a director, and the method call originated from its * underlying Ruby object, resolve the call by going up the c++ * inheritance chain. otherwise try to resolve the method in python. * without this check an infinite loop is set up between the director and * shadow class method calls. */ // NOTE: this code should only be inserted if this class is the // base class of a director class. however, in general we haven't // yet analyzed all classes derived from this one to see if they are // directors. furthermore, this class may be used as the base of // a director class defined in a completely different module at a // later time, so this test must be included whether or not directorbase // is true. we do skip this code if directors have not been enabled // at the command line to preserve source-level compatibility with // non-polymorphic swig. also, if this wrapper is for a smart-pointer // method, there is no need to perform the test since the calling object // (the smart-pointer) and the director object (the "pointee") are // distinct. director_method = is_member_director(n) && !is_smart_pointer() && !destructor; if (director_method) { Wrapper_add_local(f, "director", "Swig::Director *director = 0"); Printf(f->code, "director = dynamic_cast(arg1);\n"); Wrapper_add_local(f, "upcall", "bool upcall = false"); Append(f->code, "upcall = (director && (director->swig_get_self() == self));\n"); } /* Now write code to make the function call */ if (current != CONSTRUCTOR_ALLOCATE) { if (current == CONSTRUCTOR_INITIALIZE) { Node *pn = Swig_methodclass(n); String *symname = Getattr(pn, "sym:name"); String *action = Getattr(n, "wrap:action"); if (directorsEnabled()) { String *classname = NewStringf("const char *classname SWIGUNUSED = \"%s::%s\"", module, symname); Wrapper_add_local(f, "classname", classname); } if (action) { Printf(action, "\nDATA_PTR(self) = %s;", Swig_cresult_name()); if (GetFlag(pn, "feature:trackobjects")) { Printf(action, "\nSWIG_RubyAddTracking(%s, self);", Swig_cresult_name()); } } } /* Emit the function call */ if (director_method) { Printf(f->code, "try {\n"); } Setattr(n, "wrap:name", wname); Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); if (director_method) { Printf(actioncode, "} catch (Swig::DirectorException& e) {\n"); Printf(actioncode, " rb_exc_raise(e.getError());\n"); Printf(actioncode, " SWIG_fail;\n"); Printf(actioncode, "}\n"); } /* Return value if necessary */ if (SwigType_type(t) != T_VOID && current != CONSTRUCTOR_INITIALIZE) { need_result = 1; if (GetFlag(n, "feature:predicate")) { Printv(actioncode, tab4, "vresult = (", Swig_cresult_name(), " ? Qtrue : Qfalse);\n", NIL); } else { tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode); actioncode = 0; if (tm) { Replaceall(tm, "$result", "vresult"); Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "vresult"); if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "SWIG_POINTER_OWN"); else Replaceall(tm, "$owner", "0"); #if 1 // FIXME: this will not try to unwrap directors returned as non-director // base class pointers! /* New addition to unwrap director return values so that the original * Ruby object is returned instead. */ bool unwrap = false; String *decl = Getattr(n, "decl"); int is_pointer = SwigType_ispointer_return(decl); int is_reference = SwigType_isreference_return(decl); if (is_pointer || is_reference) { String *type = Getattr(n, "type"); Node *parent = Swig_methodclass(n); Node *modname = Getattr(parent, "module"); Node *target = Swig_directormap(modname, type); if (target) unwrap = true; } if (unwrap) { Wrapper_add_local(f, "director", "Swig::Director *director = 0"); Printf(f->code, "director = dynamic_cast(%s);\n", Swig_cresult_name()); Printf(f->code, "if (director) {\n"); Printf(f->code, " vresult = director->swig_get_self();\n"); Printf(f->code, "} else {\n"); Printf(f->code, "%s\n", tm); Printf(f->code, "}\n"); director_method = 0; } else { Printf(f->code, "%s\n", tm); } #else Printf(f->code, "%s\n", tm); #endif Delete(tm); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s.\n", SwigType_str(t, 0)); } } } if (actioncode) { Append(f->code, actioncode); Delete(actioncode); } emit_return_variable(n, t, f); } /* Extra code needed for new and initialize methods */ if (current == CONSTRUCTOR_ALLOCATE) { need_result = 1; Printf(f->code, "VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE%s);\n", Char(SwigType_manglestr(t))); Printf(f->code, "#ifndef HAVE_RB_DEFINE_ALLOC_FUNC\n"); Printf(f->code, "rb_obj_call_init(vresult, argc, argv);\n"); Printf(f->code, "#endif\n"); } else if (current == CONSTRUCTOR_INITIALIZE) { need_result = 1; } else { if ( need_result > 1 ) { if ( SwigType_type(t) == T_VOID ) Printf(f->code, "vresult = rb_ary_new();\n"); else { Printf(f->code, "if (vresult == Qnil) vresult = rb_ary_new();\n"); Printf(f->code, "else vresult = SWIG_Ruby_AppendOutput( " "rb_ary_new(), vresult);\n"); } } } /* Dump argument output code; */ Printv(f->code, outarg, NIL); /* Dump the argument cleanup code */ int need_cleanup = (current != CONSTRUCTOR_ALLOCATE) && (Len(cleanup) != 0); if (need_cleanup) { Printv(f->code, cleanup, NIL); } /* Look for any remaining cleanup. This processes the %new directive */ if (current != CONSTRUCTOR_ALLOCATE && GetFlag(n, "feature:new")) { tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0); if (tm) { Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); Delete(tm); } } /* Special processing on return value. */ tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0); if (tm) { Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, NIL); Delete(tm); } if (director_method) { if ((tm = Swig_typemap_lookup("directorfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$result", "vresult"); Printf(f->code, "%s\n", tm); } } /* Wrap things up (in a manner of speaking) */ if (need_result) { if (current == CONSTRUCTOR_ALLOCATE) { Printv(f->code, tab4, "return vresult;\n", NIL); } else if (current == CONSTRUCTOR_INITIALIZE) { Printv(f->code, tab4, "return self;\n", NIL); Printv(f->code, "fail:\n", NIL); if (need_cleanup) { Printv(f->code, cleanup, NIL); } Printv(f->code, tab4, "return Qnil;\n", NIL); } else { Wrapper_add_local(f, "vresult", "VALUE vresult = Qnil"); Printv(f->code, tab4, "return vresult;\n", NIL); Printv(f->code, "fail:\n", NIL); if (need_cleanup) { Printv(f->code, cleanup, NIL); } Printv(f->code, tab4, "return Qnil;\n", NIL); } } else { Printv(f->code, tab4, "return Qnil;\n", NIL); Printv(f->code, "fail:\n", NIL); if (need_cleanup) { Printv(f->code, cleanup, NIL); } Printv(f->code, tab4, "return Qnil;\n", NIL); } Printf(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); /* Substitute the function name */ Replaceall(f->code, "$symname", symname); /* Emit the function */ Wrapper_print(f, f_wrappers); /* Now register the function with the interpreter */ if (!Swig_symbol_isoverloaded(n)) { create_command(n, symname); } else { if (current == CONSTRUCTOR_ALLOCATE) { create_command(n, symname); } else { if (!Getattr(n, "sym:nextSibling")) dispatchFunction(n); } } Delete(kwargs); Delete(cleanup); Delete(outarg); DelWrapper(f); Delete(symname); return SWIG_OK; } /* ------------------------------------------------------------ * dispatchFunction() * ------------------------------------------------------------ */ void dispatchFunction(Node *n) { /* Last node in overloaded chain */ int maxargs; String *tmp = NewString(""); String *dispatch = Swig_overload_dispatch(n, "return %s(nargs, args, self);", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *f = NewWrapper(); String *symname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(symname); Printv(f->def, "SWIGINTERN VALUE ", wname, "(int nargs, VALUE *args, VALUE self) {", NIL); Wrapper_add_local(f, "argc", "int argc"); bool ctor_director = (current == CONSTRUCTOR_INITIALIZE && Swig_directorclass(n)); if (current == MEMBER_FUNC || current == MEMBER_VAR || ctor_director) { Printf(tmp, "VALUE argv[%d]", maxargs + 1); } else { Printf(tmp, "VALUE argv[%d]", maxargs); } Wrapper_add_local(f, "argv", tmp); Wrapper_add_local(f, "ii", "int ii"); if (current == MEMBER_FUNC || current == MEMBER_VAR || ctor_director) { maxargs += 1; Printf(f->code, "argc = nargs + 1;\n"); Printf(f->code, "argv[0] = self;\n"); Printf(f->code, "if (argc > %d) SWIG_fail;\n", maxargs); Printf(f->code, "for (ii = 1; (ii < argc); ++ii) {\n"); Printf(f->code, "argv[ii] = args[ii-1];\n"); Printf(f->code, "}\n"); } else { Printf(f->code, "argc = nargs;\n"); Printf(f->code, "if (argc > %d) SWIG_fail;\n", maxargs); Printf(f->code, "for (ii = 0; (ii < argc); ++ii) {\n"); Printf(f->code, "argv[ii] = args[ii];\n"); Printf(f->code, "}\n"); } Replaceall(dispatch, "$args", "nargs, args, self"); Printv(f->code, dispatch, "\n", NIL); // Generate prototype list, go to first node Node *sibl = n; String* type = SwigType_str(Getattr(sibl,"type"),NULL); while (Getattr(sibl, "sym:previousSibling")) sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up // Constructors will be treated specially const bool isCtor = Cmp(Getattr(sibl,"feature:new"), "1") == 0; const bool isMethod = ( Cmp(Getattr(sibl, "ismember"), "1") == 0 && (!isCtor) ); // Construct real method name String* methodName = NewString(""); if ( isMethod ) { // Sometimes a method node has no parent (SF#3034054). // This value is used in an exception message, so just skip the class // name in this case so at least we don't segfault. This is probably // just working around a problem elsewhere though. Node *parent_node = parentNode(sibl); if (parent_node) Printv( methodName, Getattr(parent_node,"sym:name"), ".", NIL ); } Append( methodName, Getattr(sibl,"sym:name" ) ); if ( isCtor ) Append( methodName, ".new" ); // Generate prototype list String *protoTypes = NewString(""); do { Append( protoTypes, "\n\" "); if ( !isCtor ) Printv( protoTypes, type, " ", NIL ); Printv(protoTypes, methodName, NIL ); Parm* p = Getattr(sibl, "wrap:parms"); if (p && (current == MEMBER_FUNC || current == MEMBER_VAR || ctor_director) ) p = nextSibling(p); // skip self Append( protoTypes, "(" ); while(p) { Append( protoTypes, SwigType_str(Getattr(p,"type"), Getattr(p,"name")) ); if ( ( p = nextSibling(p)) ) Append(protoTypes, ", "); } Append( protoTypes, ")\\n\"" ); } while ((sibl = Getattr(sibl, "sym:nextSibling"))); Append(f->code, "fail:\n"); Printf(f->code, "Ruby_Format_OverloadedError( argc, %d, \"%s\", %s);\n", maxargs, methodName, protoTypes); Append(f->code, "\nreturn Qnil;\n"); Delete(methodName); Delete(type); Delete(protoTypes); Printv(f->code, "}\n", NIL); Wrapper_print(f, f_wrappers); create_command(n, Char(symname)); DelWrapper(f); Delete(dispatch); Delete(tmp); Delete(wname); } /* --------------------------------------------------------------------- * variableWrapper() * --------------------------------------------------------------------- */ virtual int variableWrapper(Node *n) { String* docs = docstring(n, AUTODOC_GETTER); Printf(f_wrappers, "%s", docs); Delete(docs); char *name = GetChar(n, "name"); char *iname = GetChar(n, "sym:name"); SwigType *t = Getattr(n, "type"); String *tm; String *getfname, *setfname; Wrapper *getf, *setf; getf = NewWrapper(); setf = NewWrapper(); /* create getter */ int addfail = 0; String *getname = Swig_name_get(NSPACE_TODO, iname); getfname = Swig_name_wrapper(getname); Setattr(n, "wrap:name", getfname); Printv(getf->def, "SWIGINTERN VALUE\n", getfname, "(", NIL); Printf(getf->def, "VALUE self"); Printf(getf->def, ") {"); Wrapper_add_local(getf, "_val", "VALUE _val"); tm = Swig_typemap_lookup("varout", n, name, 0); if (tm) { Replaceall(tm, "$result", "_val"); Replaceall(tm, "$target", "_val"); Replaceall(tm, "$source", name); /* Printv(getf->code,tm, NIL); */ addfail = emit_action_code(n, getf->code, tm); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0)); } Printv(getf->code, tab4, "return _val;\n", NIL); if (addfail) { Append(getf->code, "fail:\n"); Append(getf->code, " return Qnil;\n"); } Append(getf->code, "}\n"); Wrapper_print(getf, f_wrappers); if (!is_assignable(n)) { setfname = NewString("NULL"); } else { /* create setter */ String* docs = docstring(n, AUTODOC_SETTER); Printf(f_wrappers, "%s", docs); Delete(docs); String *setname = Swig_name_set(NSPACE_TODO, iname); setfname = Swig_name_wrapper(setname); Setattr(n, "wrap:name", setfname); Printv(setf->def, "SWIGINTERN VALUE\n", setfname, "(VALUE self, ", NIL); Printf(setf->def, "VALUE _val) {"); tm = Swig_typemap_lookup("varin", n, name, 0); if (tm) { Replaceall(tm, "$input", "_val"); Replaceall(tm, "$source", "_val"); Replaceall(tm, "$target", name); /* Printv(setf->code,tm,"\n",NIL); */ emit_action_code(n, setf->code, tm); } else { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s\n", SwigType_str(t, 0)); } Printv(setf->code, tab4, "return _val;\n", NIL); Printf(setf->code, "fail:\n"); Printv(setf->code, tab4, "return Qnil;\n", NIL); Printf(setf->code, "}\n"); Wrapper_print(setf, f_wrappers); Delete(setname); } /* define accessor method */ if (CPlusPlus) { Insert(getfname, 0, "VALUEFUNC("); Append(getfname, ")"); Insert(setfname, 0, "VALUEFUNC("); Append(setfname, ")"); } String *s = NewString(""); switch (current) { case STATIC_VAR: /* C++ class variable */ Printv(s, tab4, "rb_define_singleton_method(", klass->vname, ", \"", klass->strip(iname), "\", ", getfname, ", 0);\n", NIL); if (!GetFlag(n, "feature:immutable")) { Printv(s, tab4, "rb_define_singleton_method(", klass->vname, ", \"", klass->strip(iname), "=\", ", setfname, ", 1);\n", NIL); } Printv(klass->init, s, NIL); break; default: /* C global variable */ /* wrapped in Ruby module attribute */ assert(current == NO_CPP); if (!useGlobalModule) { Printv(s, tab4, "rb_define_singleton_method(", modvar, ", \"", iname, "\", ", getfname, ", 0);\n", NIL); if (!GetFlag(n, "feature:immutable")) { Printv(s, tab4, "rb_define_singleton_method(", modvar, ", \"", iname, "=\", ", setfname, ", 1);\n", NIL); } } else { Printv(s, tab4, "rb_define_global_method(\"", iname, "\", ", getfname, ", 0);\n", NIL); if (!GetFlag(n, "feature:immutable")) { Printv(s, tab4, "rb_define_global_method(\"", iname, "=\", ", setfname, ", 1);\n", NIL); } } Printv(f_init, s, NIL); Delete(s); break; } Delete(getname); Delete(getfname); Delete(setfname); DelWrapper(setf); DelWrapper(getf); return SWIG_OK; } /* --------------------------------------------------------------------- * validate_const_name(char *name) * * Validate constant name. * --------------------------------------------------------------------- */ char *validate_const_name(char *name, const char *reason) { if (!name || name[0] == '\0') return name; if (isupper(name[0])) return name; if (islower(name[0])) { name[0] = (char)toupper(name[0]); Swig_warning(WARN_RUBY_WRONG_NAME, input_file, line_number, "Wrong %s name (corrected to `%s')\n", reason, name); return name; } Swig_warning(WARN_RUBY_WRONG_NAME, input_file, line_number, "Wrong %s name %s\n", reason, name); return name; } /* --------------------------------------------------------------------- * constantWrapper() * --------------------------------------------------------------------- */ virtual int constantWrapper(Node *n) { Swig_require("constantWrapper", n, "*sym:name", "type", "value", NIL); char *iname = GetChar(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); if (current == CLASS_CONST) { iname = klass->strip(iname); } validate_const_name(iname, "constant"); SetChar(n, "sym:name", iname); /* Special hook for member pointer */ if (SwigType_type(type) == T_MPOINTER) { String *wname = Swig_name_wrapper(iname); Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value); value = Char(wname); } String *tm = Swig_typemap_lookup("constant", n, value, 0); if (!tm) tm = Swig_typemap_lookup("constcode", n, value, 0); if (tm) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", iname); Replaceall(tm, "$symname", iname); Replaceall(tm, "$value", value); if (current == CLASS_CONST) { if (multipleInheritance) { Replaceall(tm, "$module", klass->mImpl); Printv(klass->init, tm, "\n", NIL); } else { Replaceall(tm, "$module", klass->vname); Printv(klass->init, tm, "\n", NIL); } } else { if (!useGlobalModule) { Replaceall(tm, "$module", modvar); } else { Replaceall(tm, "$module", "rb_cObject"); } Printf(f_init, "%s\n", tm); } } else { Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value %s = %s\n", SwigType_str(type, 0), value); } Swig_restore(n); return SWIG_OK; } /* ----------------------------------------------------------------------------- * classDeclaration() * * Records information about classes---even classes that might be defined in * other modules referenced by %import. * ----------------------------------------------------------------------------- */ virtual int classDeclaration(Node *n) { if (!Getattr(n, "feature:onlychildren")) { String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); String *namestr = SwigType_namestr(name); klass = RCLASS(classes, Char(namestr)); if (!klass) { klass = new RClass(); String *valid_name = NewString(symname ? symname : namestr); validate_const_name(Char(valid_name), "class"); klass->set_name(namestr, symname, valid_name); SET_RCLASS(classes, Char(namestr), klass); Delete(valid_name); } Delete(namestr); } return Language::classDeclaration(n); } /** * Process the comma-separated list of mixed-in module names (if any). */ void includeRubyModules(Node *n) { String *mixin = Getattr(n, "feature:mixin"); if (mixin) { List *modules = Split(mixin, ',', INT_MAX); if (modules && Len(modules) > 0) { Iterator mod = First(modules); while (mod.item) { if (Len(mod.item) > 0) { Printf(klass->init, "rb_include_module(%s, rb_eval_string(\"%s\"));\n", klass->vname, mod.item); } mod = Next(mod); } } Delete(modules); } } void handleBaseClasses(Node *n) { List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist)) { Iterator base = First(baselist); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } while (base.item) { String *basename = Getattr(base.item, "name"); String *basenamestr = SwigType_namestr(basename); RClass *super = RCLASS(classes, Char(basenamestr)); Delete(basenamestr); if (super) { SwigType *btype = NewString(basename); SwigType_add_pointer(btype); SwigType_remember(btype); if (multipleInheritance) { String *bmangle = SwigType_manglestr(btype); Insert(bmangle, 0, "((swig_class *) SWIGTYPE"); Append(bmangle, "->clientdata)->mImpl"); Printv(klass->init, "rb_include_module(", klass->mImpl, ", ", bmangle, ");\n", NIL); Delete(bmangle); } else { String *bmangle = SwigType_manglestr(btype); Insert(bmangle, 0, "((swig_class *) SWIGTYPE"); Append(bmangle, "->clientdata)->klass"); Replaceall(klass->init, "$super", bmangle); Delete(bmangle); } Delete(btype); } base = Next(base); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } if (!multipleInheritance) { /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { if (GetFlag(base.item, "feature:ignore")) { base = Next(base); continue; } String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", proxyclassname, baseclassname); base = Next(base); } } } } } /** * Check to see if a %markfunc was specified. */ void handleMarkFuncDirective(Node *n) { String *markfunc = Getattr(n, "feature:markfunc"); if (markfunc) { Printf(klass->init, "SwigClass%s.mark = (void (*)(void *)) %s;\n", klass->name, markfunc); } else { Printf(klass->init, "SwigClass%s.mark = 0;\n", klass->name); } } /** * Check to see if a %freefunc was specified. */ void handleFreeFuncDirective(Node *n) { String *freefunc = Getattr(n, "feature:freefunc"); if (freefunc) { Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) %s;\n", klass->name, freefunc); } else { if (klass->destructor_defined) { Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) free_%s;\n", klass->name, klass->mname); } } } /** * Check to see if tracking is enabled for this class. */ void handleTrackDirective(Node *n) { int trackObjects = GetFlag(n, "feature:trackobjects"); if (trackObjects) { Printf(klass->init, "SwigClass%s.trackObjects = 1;\n", klass->name); } else { Printf(klass->init, "SwigClass%s.trackObjects = 0;\n", klass->name); } } /* ---------------------------------------------------------------------- * classHandler() * ---------------------------------------------------------------------- */ virtual int classHandler(Node *n) { String* docs = docstring(n, AUTODOC_CLASS); Printf(f_wrappers, "%s", docs); Delete(docs); String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); String *namestr = SwigType_namestr(name); // does template expansion klass = RCLASS(classes, Char(namestr)); assert(klass != 0); Delete(namestr); String *valid_name = NewString(symname); validate_const_name(Char(valid_name), "class"); Clear(klass->type); Printv(klass->type, Getattr(n, "classtype"), NIL); Printv(f_wrappers, "static swig_class SwigClass", valid_name, ";\n\n", NIL); Printv(klass->init, "\n", tab4, NIL); if (!useGlobalModule) { Printv(klass->init, klass->vname, " = rb_define_class_under(", modvar, ", \"", klass->name, "\", $super);\n", NIL); } else { Printv(klass->init, klass->vname, " = rb_define_class(\"", klass->name, "\", $super);\n", NIL); } if (multipleInheritance) { Printv(klass->init, klass->mImpl, " = rb_define_module_under(", klass->vname, ", \"Impl\");\n", NIL); } SwigType *tt = NewString(name); SwigType_add_pointer(tt); SwigType_remember(tt); String *tm = SwigType_manglestr(tt); Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &SwigClass%s);\n", tm, valid_name); Delete(tm); Delete(tt); Delete(valid_name); includeRubyModules(n); Printv(klass->init, "$allocator", NIL); Printv(klass->init, "$initializer", NIL); Language::classHandler(n); handleBaseClasses(n); handleMarkFuncDirective(n); handleFreeFuncDirective(n); handleTrackDirective(n); if (multipleInheritance) { Printv(klass->init, "rb_include_module(", klass->vname, ", ", klass->mImpl, ");\n", NIL); } String *s = NewString(""); Printv(s, tab4, "rb_undef_alloc_func(", klass->vname, ");\n", NIL); Replaceall(klass->init, "$allocator", s); Replaceall(klass->init, "$initializer", ""); if (GetFlag(n, "feature:exceptionclass")) { Replaceall(klass->init, "$super", "rb_eRuntimeError"); } else { Replaceall(klass->init, "$super", "rb_cObject"); } Delete(s); Printv(f_init, klass->init, NIL); klass = 0; return SWIG_OK; } /* ---------------------------------------------------------------------- * memberfunctionHandler() * * Method for adding C++ member function * * By default, we're going to create a function of the form : * * Foo_bar(this,args) * * Where Foo is the classname, bar is the member name and the this pointer * is explicitly attached to the beginning. * * The renaming only applies to the member function part, not the full * classname. * * --------------------------------------------------------------------- */ virtual int memberfunctionHandler(Node *n) { current = MEMBER_FUNC; String* docs = docstring(n, AUTODOC_METHOD); Printf(f_wrappers, "%s", docs); Delete(docs); Language::memberfunctionHandler(n); current = NO_CPP; return SWIG_OK; } /* --------------------------------------------------------------------- * constructorHandler() * * Method for adding C++ member constructor * -------------------------------------------------------------------- */ void set_director_ctor_code(Node *n) { /* director ctor code is specific for each class */ Delete(director_prot_ctor_code); director_prot_ctor_code = NewString(""); Node *pn = Swig_methodclass(n); String *symname = Getattr(pn, "sym:name"); String *name = Copy(symname); char *cname = Char(name); if (cname) cname[0] = (char)toupper(cname[0]); Printv(director_prot_ctor_code, "if ( $comparison ) { /* subclassed */\n", " $director_new \n", "} else {\n", " rb_raise(rb_eNameError,\"accessing abstract class or protected constructor\"); \n", " return Qnil;\n", "}\n", NIL); Delete(director_ctor_code); director_ctor_code = NewString(""); Printv(director_ctor_code, "if ( $comparison ) { /* subclassed */\n", " $director_new \n", "} else {\n", " $nondirector_new \n", "}\n", NIL); Delete(name); } virtual int constructorHandler(Node *n) { int use_director = Swig_directorclass(n); if (use_director) { set_director_ctor_code(n); } /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; Swig_name_register("construct", "%n%c_allocate"); Language::constructorHandler(n); String* docs = docstring(n, AUTODOC_CTOR); Printf(f_wrappers, "%s", docs); Delete(docs); /* * If we're wrapping the constructor of a C++ director class, prepend a new parameter * to receive the scripting language object (e.g. 'self') * */ Swig_save("ruby:constructorHandler", n, "parms", NIL); if (use_director) { Parm *parms = Getattr(n, "parms"); Parm *self; String *name = NewString("self"); String *type = NewString("VALUE"); self = NewParm(type, name, n); Delete(type); Delete(name); Setattr(self, "lname", "Qnil"); if (parms) set_nextSibling(self, parms); Setattr(n, "parms", self); Setattr(n, "wrap:self", "1"); Delete(self); } /* Now do the instance initialize method */ current = CONSTRUCTOR_INITIALIZE; Swig_name_register("construct", "new_%n%c"); Language::constructorHandler(n); /* Restore original parameter list */ Delattr(n, "wrap:self"); Swig_restore(n); /* Done */ Swig_name_unregister("construct"); current = NO_CPP; klass->constructor_defined = 1; return SWIG_OK; } virtual int copyconstructorHandler(Node *n) { int use_director = Swig_directorclass(n); if (use_director) { set_director_ctor_code(n); } /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; Swig_name_register("construct", "%n%c_allocate"); return Language::copyconstructorHandler(n); } /* --------------------------------------------------------------------- * destructorHandler() * -------------------------------------------------------------------- */ virtual int destructorHandler(Node *n) { /* Do no spit free function if user defined his own for this class */ Node *pn = Swig_methodclass(n); String *freefunc = Getattr(pn, "feature:freefunc"); if (freefunc) return SWIG_OK; current = DESTRUCTOR; Language::destructorHandler(n); freefunc = NewString(""); String *freebody = NewString(""); String *pname0 = Swig_cparm_name(0, 0); Printv(freefunc, "free_", klass->mname, NIL); Printv(freebody, "SWIGINTERN void\n", freefunc, "(", klass->type, " *", pname0, ") {\n", tab4, NIL); /* Check to see if object tracking is activated for the class that owns this destructor. */ if (GetFlag(pn, "feature:trackobjects")) { Printf(freebody, "SWIG_RubyRemoveTracking(%s);\n", pname0); Printv(freebody, tab4, NIL); } if (Extend) { String *wrap = Getattr(n, "wrap:code"); if (wrap) { Printv(f_wrappers, wrap, NIL); } /* Printv(freebody, Swig_name_destroy(name), "(", pname0, ")", NIL); */ Printv(freebody, Getattr(n, "wrap:action"), "\n", NIL); } else { String *action = Getattr(n, "wrap:action"); if (action) { Printv(freebody, action, "\n", NIL); } else { /* In the case swig emits no destroy function. */ if (CPlusPlus) Printf(freebody, "delete %s;\n", pname0); else Printf(freebody, "free((char*) %s);\n", pname0); } } Printv(freebody, "}\n\n", NIL); Printv(f_wrappers, freebody, NIL); klass->destructor_defined = 1; current = NO_CPP; Delete(freefunc); Delete(freebody); Delete(pname0); return SWIG_OK; } /* --------------------------------------------------------------------- * membervariableHandler() * * This creates a pair of functions to set/get the variable of a member. * -------------------------------------------------------------------- */ virtual int membervariableHandler(Node *n) { String* docs = docstring(n, AUTODOC_GETTER); Printf(f_wrappers, "%s", docs); Delete(docs); if (is_assignable(n)) { String* docs = docstring(n, AUTODOC_SETTER); Printf(f_wrappers, "%s", docs); Delete(docs); } current = MEMBER_VAR; Language::membervariableHandler(n); current = NO_CPP; return SWIG_OK; } /* ----------------------------------------------------------------------- * staticmemberfunctionHandler() * * Wrap a static C++ function * ---------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { String* docs = docstring(n, AUTODOC_STATICFUNC); Printf(f_wrappers, "%s", docs); Delete(docs); current = STATIC_FUNC; Language::staticmemberfunctionHandler(n); current = NO_CPP; return SWIG_OK; } /* ---------------------------------------------------------------------- * memberconstantHandler() * * Create a C++ constant * --------------------------------------------------------------------- */ virtual int memberconstantHandler(Node *n) { String* docs = docstring(n, AUTODOC_STATICFUNC); Printf(f_wrappers, "%s", docs); Delete(docs); current = CLASS_CONST; Language::memberconstantHandler(n); current = NO_CPP; return SWIG_OK; } /* --------------------------------------------------------------------- * staticmembervariableHandler() * --------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { String* docs = docstring(n, AUTODOC_GETTER); Printf(f_wrappers, "%s", docs); Delete(docs); if (is_assignable(n)) { String* docs = docstring(n, AUTODOC_SETTER); Printf(f_wrappers, "%s", docs); Delete(docs); } current = STATIC_VAR; Language::staticmembervariableHandler(n); current = NO_CPP; return SWIG_OK; } /* C++ director class generation */ virtual int classDirector(Node *n) { return Language::classDirector(n); } virtual int classDirectorInit(Node *n) { String *declaration; declaration = Swig_director_declaration(n); Printf(f_directors_h, "\n"); Printf(f_directors_h, "%s\n", declaration); Printf(f_directors_h, "public:\n"); Delete(declaration); return Language::classDirectorInit(n); } virtual int classDirectorEnd(Node *n) { Printf(f_directors_h, "};\n\n"); return Language::classDirectorEnd(n); } /* ------------------------------------------------------------ * classDirectorConstructor() * ------------------------------------------------------------ */ virtual int classDirectorConstructor(Node *n) { Node *parent = Getattr(n, "parentNode"); String *sub = NewString(""); String *decl = Getattr(n, "decl"); String *supername = Swig_class_name(parent); String *classname = NewString(""); Printf(classname, "SwigDirector_%s", supername); /* insert self parameter */ Parm *p; ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("VALUE"); p = NewParm(type, NewString("self"), n); set_nextSibling(p, parms); parms = p; if (!Getattr(n, "defaultargs")) { /* constructor */ { Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self) { }", classname, target, call); Delete(target); Wrapper_print(w, f_directors); Delete(call); DelWrapper(w); } /* constructor header */ { String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } } Delete(sub); Delete(classname); Delete(supername); Delete(parms); return Language::classDirectorConstructor(n); } /* ------------------------------------------------------------ * classDirectorDefaultConstructor() * ------------------------------------------------------------ */ virtual int classDirectorDefaultConstructor(Node *n) { String *classname; Wrapper *w; classname = Swig_class_name(n); w = NewWrapper(); Printf(w->def, "SwigDirector_%s::SwigDirector_%s(VALUE self) : Swig::Director(self) { }", classname, classname); Wrapper_print(w, f_directors); DelWrapper(w); Printf(f_directors_h, " SwigDirector_%s(VALUE self);\n", classname); Delete(classname); return Language::classDirectorDefaultConstructor(n); } /* --------------------------------------------------------------- * exceptionSafeMethodCall() * * Emit a virtual director method to pass a method call on to the * underlying Ruby instance. * * --------------------------------------------------------------- */ void exceptionSafeMethodCall(String *className, Node *n, Wrapper *w, int argc, String *args, bool initstack) { Wrapper *body = NewWrapper(); Wrapper *rescue = NewWrapper(); String *methodName = Getattr(n, "sym:name"); String *bodyName = NewStringf("%s_%s_body", className, methodName); String *rescueName = NewStringf("%s_%s_rescue", className, methodName); String *depthCountName = NewStringf("%s_%s_call_depth", className, methodName); // Check for an exception typemap of some kind String *tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { tm = Getattr(n, "feature:director:except"); } if ((tm != 0) && (Len(tm) > 0) && (Strcmp(tm, "1") != 0)) { // Declare a global to hold the depth count if (!Getattr(n, "sym:nextSibling")) { Printf(body->def, "static int %s = 0;\n", depthCountName); // Function body Printf(body->def, "VALUE %s(VALUE data) {\n", bodyName); Wrapper_add_localv(body, "args", "Swig::body_args *", "args", "= reinterpret_cast(data)", NIL); Wrapper_add_localv(body, Swig_cresult_name(), "VALUE", Swig_cresult_name(), "= Qnil", NIL); Printf(body->code, "%s++;\n", depthCountName); Printv(body->code, Swig_cresult_name(), " = rb_funcall2(args->recv, args->id, args->argc, args->argv);\n", NIL); Printf(body->code, "%s--;\n", depthCountName); Printv(body->code, "return ", Swig_cresult_name(), ";\n", NIL); Printv(body->code, "}", NIL); // Exception handler Printf(rescue->def, "VALUE %s(VALUE args, VALUE error) {\n", rescueName); Replaceall(tm, "$error", "error"); Printf(rescue->code, "%s--;\n", depthCountName); Printf(rescue->code, "if (%s == 0) ", depthCountName); Printv(rescue->code, Str(tm), "\n", NIL); Printv(rescue->code, "rb_exc_raise(error);\n", NIL); Printv(rescue->code, "}", NIL); } // Main code Wrapper_add_localv(w, "args", "Swig::body_args", "args", NIL); Wrapper_add_localv(w, "status", "int", "status", NIL); Printv(w->code, "args.recv = swig_get_self();\n", NIL); Printf(w->code, "args.id = rb_intern(\"%s\");\n", methodName); Printf(w->code, "args.argc = %d;\n", argc); if (argc > 0) { Printf(w->code, "args.argv = new VALUE[%d];\n", argc); for (int i = 0; i < argc; i++) { Printf(w->code, "args.argv[%d] = obj%d;\n", i, i); } } else { Printv(w->code, "args.argv = 0;\n", NIL); } Printf(w->code, "%s = rb_protect(PROTECTFUNC(%s), reinterpret_cast(&args), &status);\n", Swig_cresult_name(), bodyName); if ( initstack ) Printf(w->code, "SWIG_RELEASE_STACK;\n"); Printf(w->code, "if (status) {\n"); Printf(w->code, "VALUE lastErr = rb_gv_get(\"$!\");\n"); Printf(w->code, "%s(reinterpret_cast(&args), lastErr);\n", rescueName); Printf(w->code, "}\n"); if (argc > 0) { Printv(w->code, "delete [] args.argv;\n", NIL); } // Dump wrapper code Wrapper_print(body, f_directors_helpers); Wrapper_print(rescue, f_directors_helpers); } else { if (argc > 0) { Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), %d%s);\n", Swig_cresult_name(), methodName, argc, args); } else { Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), 0, NULL);\n", Swig_cresult_name(), methodName); } if ( initstack ) Printf(w->code, "SWIG_RELEASE_STACK;\n"); } // Clean up Delete(bodyName); Delete(rescueName); Delete(depthCountName); DelWrapper(body); DelWrapper(rescue); } virtual int classDirectorMethod(Node *n, Node *parent, String *super) { int is_void = 0; int is_pointer = 0; String *decl = Getattr(n, "decl"); String *name = Getattr(n, "name"); String *classname = Getattr(parent, "sym:name"); String *c_classname = Getattr(parent, "name"); String *symname = Getattr(n, "sym:name"); String *declaration = NewString(""); ParmList *l = Getattr(n, "parms"); Wrapper *w = NewWrapper(); String *tm; String *wrap_args = NewString(""); String *returntype = Getattr(n, "type"); Parm *p; String *value = Getattr(n, "value"); String *storage = Getattr(n, "storage"); bool pure_virtual = false; int status = SWIG_OK; int idx; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; bool asvoid = checkAttribute( n, "feature:numoutputs", "0") ? true : false; bool initstack = checkAttribute( n, "feature:initstack", "1") ? true : false; if (Cmp(storage, "virtual") == 0) { if (Cmp(value, "0") == 0) { pure_virtual = true; } } String *overnametmp = NewString(Getattr(n, "sym:name")); if (Getattr(n, "sym:overloaded")) { Printf(overnametmp, "::%s", Getattr(n, "sym:overname")); } /* determine if the method returns a pointer */ is_pointer = SwigType_ispointer_return(decl); is_void = (!Cmp(returntype, "void") && !is_pointer); /* virtual method definition */ String *target; String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ target = Swig_method_decl(rtype, decl, name, l, 0, 1); Printf(declaration, " virtual %s", target); Delete(target); // Get any exception classes in the throws typemap ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { Parm *p; int gencomma = 0; Append(w->def, " throw("); Append(declaration, " throw("); if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); } Printf(w->def, "%s", SwigType_str(Getattr(p, "type"), 0)); Printf(declaration, "%s", SwigType_str(Getattr(p, "type"), 0)); } } Append(w->def, ")"); Append(declaration, ")"); } Append(w->def, " {"); Append(declaration, ";\n"); if (initstack && !(ignored_method && !pure_virtual)) { Append(w->def, "\nSWIG_INIT_STACK;\n"); } /* declare method return value * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ if (!is_void) { if (!(ignored_method && !pure_virtual)) { Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL); } } if (ignored_method) { if (!pure_virtual) { if (!is_void) Printf(w->code, "return "); String *super_call = Swig_method_call(super, l); Printf(w->code, "%s;\n", super_call); Delete(super_call); } else { Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } } else { /* attach typemaps to arguments (C/C++ -> Ruby) */ String *arglist = NewString(""); Swig_director_parms_fixup(l); Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); char source[256]; int outputs = 0; if (!is_void && !asvoid) outputs++; /* build argument list and type conversion string */ idx = 0; p = l; while ( p ) { if (Getattr(p, "tmap:ignore")) { p = Getattr(p, "tmap:ignore:next"); continue; } if (Getattr(p, "tmap:directorargout") != 0) outputs++; if ( checkAttribute( p, "tmap:in:numinputs", "0") ) { p = Getattr(p, "tmap:in:next"); continue; } String *parameterName = Getattr(p, "name"); String *parameterType = Getattr(p, "type"); Putc(',', arglist); if ((tm = Getattr(p, "tmap:directorin")) != 0) { sprintf(source, "obj%d", idx++); String *input = NewString(source); Setattr(p, "emit:directorinput", input); Replaceall(tm, "$input", input); Replaceall(tm, "$owner", "0"); Delete(input); Printv(wrap_args, tm, "\n", NIL); Wrapper_add_localv(w, source, "VALUE", source, "= Qnil", NIL); Printv(arglist, source, NIL); p = Getattr(p, "tmap:directorin:next"); continue; } else if (Cmp(parameterType, "void")) { /** * Special handling for pointers to other C++ director classes. * Ideally this would be left to a typemap, but there is currently no * way to selectively apply the dynamic_cast<> to classes that have * directors. In other words, the type "SwigDirector_$1_lname" only exists * for classes with directors. We avoid the problem here by checking * module.wrap::directormap, but it's not clear how to get a typemap to * do something similar. Perhaps a new default typemap (in addition * to SWIGTYPE) called DIRECTORTYPE? */ if (SwigType_ispointer(parameterType) || SwigType_isreference(parameterType)) { Node *modname = Getattr(parent, "module"); Node *target = Swig_directormap(modname, parameterType); sprintf(source, "obj%d", idx++); String *nonconst = 0; /* strip pointer/reference --- should move to Swig/stype.c */ String *nptype = NewString(Char(parameterType) + 2); /* name as pointer */ String *ppname = Copy(parameterName); if (SwigType_isreference(parameterType)) { Insert(ppname, 0, "&"); } /* if necessary, cast away const since Ruby doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", parameterName); String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(parameterType, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(parameterType, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, "Target language argument '%s' discards const in director method %s::%s.\n", SwigType_str(parameterType, parameterName), SwigType_namestr(c_classname), SwigType_namestr(name)); } else { nonconst = Copy(ppname); } Delete(nptype); Delete(ppname); String *mangle = SwigType_manglestr(parameterType); if (target) { String *director = NewStringf("director_%s", mangle); Wrapper_add_localv(w, director, "Swig::Director *", director, "= 0", NIL); Wrapper_add_localv(w, source, "VALUE", source, "= Qnil", NIL); Printf(wrap_args, "%s = dynamic_cast(%s);\n", director, nonconst); Printf(wrap_args, "if (!%s) {\n", director); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); Printf(wrap_args, "} else {\n"); Printf(wrap_args, "%s = %s->swig_get_self();\n", source, director); Printf(wrap_args, "}\n"); Delete(director); Printv(arglist, source, NIL); } else { Wrapper_add_localv(w, source, "VALUE", source, "= Qnil", NIL); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); //Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n", // source, nonconst, base); Printv(arglist, source, NIL); } Delete(mangle); Delete(nonconst); } else { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(parameterType, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_NOWRAP; break; } } p = nextSibling(p); } /* declare Ruby return value */ String *value_result = NewStringf("VALUE %s", Swig_cresult_name()); Wrapper_add_local(w, Swig_cresult_name(), value_result); Delete(value_result); /* wrap complex arguments to VALUEs */ Printv(w->code, wrap_args, NIL); /* pass the method call on to the Ruby object */ exceptionSafeMethodCall(classname, n, w, idx, arglist, initstack); /* * Ruby method may return a simple object, or an Array of objects. * For in/out arguments, we have to extract the appropriate VALUEs from the Array, * then marshal everything back to C/C++ (return value and output arguments). */ /* Marshal return value and other outputs (if any) from VALUE to C/C++ type */ String *cleanup = NewString(""); String *outarg = NewString(""); if (outputs > 1) { Wrapper_add_local(w, "output", "VALUE output"); Printf(w->code, "if (TYPE(%s) != T_ARRAY) {\n", Swig_cresult_name()); Printf(w->code, "Ruby_DirectorTypeMismatchException(\"Ruby method failed to return an array.\");\n"); Printf(w->code, "}\n"); } idx = 0; /* Marshal return value */ if (!is_void) { tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); if (tm != 0) { if (outputs > 1 && !asvoid ) { Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++); Replaceall(tm, "$input", "output"); } else { Replaceall(tm, "$input", Swig_cresult_name()); } /* TODO check this */ if (Getattr(n, "wrap:disown")) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } Replaceall(tm, "$result", "c_result"); Printv(w->code, tm, "\n", NIL); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_ERROR; } } /* Marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { if (outputs > 1) { Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++); Replaceall(tm, "$result", "output"); } else { Replaceall(tm, "$result", Swig_cresult_name()); } Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } Delete(arglist); Delete(cleanup); Delete(outarg); } /* any existing helper functions to handle this? */ if (!is_void) { if (!(ignored_method && !pure_virtual)) { String *rettype = SwigType_str(returntype, 0); if (!SwigType_isreference(returntype)) { Printf(w->code, "return (%s) c_result;\n", rettype); } else { Printf(w->code, "return (%s) *c_result;\n", rettype); } Delete(rettype); } } Printf(w->code, "}\n"); // We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method String *inline_extra_method = NewString(""); if (dirprot_mode() && !is_public(n) && !pure_virtual) { Printv(inline_extra_method, declaration, NIL); String *extra_method_name = NewStringf("%sSwigPublic", name); Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, ";\n", " {\n "); if (!is_void) Printf(inline_extra_method, "return "); String *methodcall = Swig_method_call(super, l); Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Delete(methodcall); Delete(extra_method_name); } /* emit the director method */ if (status == SWIG_OK) { if (!Getattr(n, "defaultargs")) { Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); } } /* clean up */ Delete(wrap_args); Delete(pclassname); DelWrapper(w); return status; } virtual int classDirectorConstructors(Node *n) { return Language::classDirectorConstructors(n); } virtual int classDirectorMethods(Node *n) { return Language::classDirectorMethods(n); } virtual int classDirectorDisown(Node *n) { return Language::classDirectorDisown(n); } String *runtimeCode() { String *s = NewString(""); String *shead = Swig_include_sys("rubyhead.swg"); if (!shead) { Printf(stderr, "*** Unable to open 'rubyhead.swg'\n"); } else { Append(s, shead); Delete(shead); } String *serrors = Swig_include_sys("rubyerrors.swg"); if (!serrors) { Printf(stderr, "*** Unable to open 'rubyerrors.swg'\n"); } else { Append(s, serrors); Delete(serrors); } String *strack = Swig_include_sys("rubytracking.swg"); if (!strack) { Printf(stderr, "*** Unable to open 'rubytracking.swg'\n"); } else { Append(s, strack); Delete(strack); } String *sapi = Swig_include_sys("rubyapi.swg"); if (!sapi) { Printf(stderr, "*** Unable to open 'rubyapi.swg'\n"); } else { Append(s, sapi); Delete(sapi); } String *srun = Swig_include_sys("rubyrun.swg"); if (!srun) { Printf(stderr, "*** Unable to open 'rubyrun.swg'\n"); } else { Append(s, srun); Delete(srun); } return s; } String *defaultExternalRuntimeFilename() { return NewString("swigrubyrun.h"); } }; /* class RUBY */ /* ----------------------------------------------------------------------------- * swig_ruby() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_ruby() { return new RUBY(); } extern "C" Language *swig_ruby(void) { return new_swig_ruby(); } /* * Local Variables: * c-basic-offset: 2 * End: */ swig-3.0.2/Source/Modules/modula3.cxx0000664000175000017500000040643312343605122017315 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * modula3.cxx * * Modula3 language module for SWIG. * ----------------------------------------------------------------------------- */ /* Text formatted with indent -sob -br -ce -nut -npsl */ /* Report: - It's not a good concept to use member variables or global variables for passing parameters to functions. It's not a good concept to use functions of superclasses for specific services. E.g. For SWIG this means: Generating accessor functions for member variables is the most common but no general task to be processed in membervariableHandler. Better provide a service function which generates accessor function code and equip this service function with all parameters needed for input (parse node) and output (generated code). - How can I make globalvariableHandler not to generate interface functions to two accessor functions (that don't exist) ? - How can I generate a typemap that turns every C reference argument into its Modula 3 counterpart, that is void test(Complex &z); PROCEDURE test(VAR z:Complex); - neither $*n_mangle nor $*n_type nor $*n_ltype return the type without pointer converted to Modula3 equivalent, $*n_mangle is the variant closest to what I expect - using a typemap like typemap(m3wrapintype) int * %{VAR $1_name: INTEGER%} has the advantages: - one C parameter can be turned into multiple M3 parameters - the argument can be renamed - using typemaps like typemap(m3wrapinmode) int * "VAR" typemap(m3wrapintype) int * "INTEGER" has the advantages: - multiple parameters with same type and default value can be bundled - more conform to the other language modules - Where takes the reduction of multi-typemaps place? How can I preserve all parameters for functions of the intermediary class? The answer is Getattrs(n,"tmap:m3rawintype:next") - Char() can be used to transform a String to (char *) which can be used for output with printf - What is the while (checkAttribute()) loop in functionWrapper good for? Appearently for skipping (numinputs=0) typemaps. - SWIGTYPE const * - typemap is ignored, whereas SWIGTYPE * - typemap is invoked, why? Had it been (const SWIGTYPE *) instead? - enumeration items should definitely be equipped with its plain numerical value One could add tag 'numvalue' in CParse/parser.y, but it is still possible that someone declares an enumeration using a symbolic constant. I have quickly hacked that the successive number is assigned if "enumvalue" has suffix "+1". The ultimate solution would be to generate a C program which includes the header and outputs all constants. This program might be compiled and run by 'make' or by SWIG and the resulting output is fed back to SWIG. - It's a bad idea to interpret feature value "" 'disable feature' because the value "" might be sensible in case of feature:modula3:oldprefix. - What's the difference between "sym:name" and "name" ? "name" is the original name and "sym:name" is probably modified by the user using %rename - Is it possible for 'configure' to find out if m3pp is installed and to invoke it for generated Modula3 files? - It would be better to separate an arguments purpose and its name, because an output variable with name "OUTPUT" is not very descriptive. In case of PLPlot this could be solved by typedefs that assign special purposes to the array types. - Can one interpret $n_basetype as the identifier matched with SWIGTYPE ? SWIG's odds: - arguments of type (Node *) for SWIG functions should be most often better (const Node *): Swig_symbol_qualified, Getattr, nodeType, parentNode - unique identifier style instead of NewString, Getattr, firstChild - 'class'.name is qualified, 'enum'.name and 'enumitem'.name is not - Swig_symbol_qualified() returns NIL for enumeration nodes - Is there a function that creates a C representation of a SWIG type string? ToDo: - create WeakRefs only for resources returned by function marked with %newobject -> part of output conversion - clean typemap conception - should a multi-typemap for m3wrapouttype skip the corresponding input parameters? when yes - How to handle inout-arguments? In this case like in-argument. - C++ classes - C++ exceptions - allow for moving RECORD and OBJECT definitions to separate files, with the main type called T - call-back functions - special option: fast access to class members by pointer arithmetic, member offsets can be determined by a C++ program that print them. - emit enumeration definitions when its first item is declared, currently enumerations are emitted at the beginning of the file Done: - addThrow should convert the typemap by itself - not possible because routine for attaching mapped types to parameter nodes won't work for the function node - turning error codes into exceptions -> part of output value checking - create WeakRefs for resources allocated by the library -> part of output conversion - TRY..FINALLY..END; can be omitted - if there is no m3wrapfreearg - no exception can be raised in the body (empty RAISES) list */ #include "swigmod.h" #include // for INT_MAX #include #define USAGE_ARG_DIR "m3wrapargdir typemap expect values: in, out, inout\n" class MODULA3:public Language { public: enum block_type { no_block, constant, variable, blocktype, revelation }; private: struct M3File { String *f; Hash *import; block_type bt; /* VC++ 6 doesn't allow the access to 'no_block' if it is a private member of MODULA3 class */ M3File():f(NewString("")), import(NewHash()), bt(no_block) { } ~M3File() { Delete(f); Delete(import); } /* ----------------------------------------------------------------------------- * enterBlock() * * Make sure that a given declaration is written to the right declaration block, * that is constants are written after "CONST" and so on ... * ----------------------------------------------------------------------------- */ void enterBlock(block_type newbt) { static const char *ident[] = { "", "\nCONST\n", "\nVAR\n", "\nTYPE\n", "\nREVEAL\n" }; #ifdef DEBUG if ((bt < 0) || (4 < bt)) { printf("bt %d out of range\n", bt); } #endif if (newbt != bt) { Append(f, ident[newbt]); bt = newbt; } } }; static const char *usage; const String *empty_string; Hash *swig_types_hash; File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; File *f_init; bool proxy_flag; // Flag for generating proxy classes bool have_default_constructor_flag; bool native_function_flag; // Flag for when wrapping a native function bool enum_constant_flag; // Flag for when wrapping an enum or constant bool static_flag; // Flag for when wrapping a static functions or member variables bool variable_wrapper_flag; // Flag for when wrapping a nonstatic member variable bool wrapping_member_flag; // Flag for when wrapping a member variable/enum/const bool global_variable_flag; // Flag for when wrapping a global variable bool old_variable_names; // Flag for old style variable names in the intermediary class bool unsafe_module; String *m3raw_name; // raw interface name M3File m3raw_intf; // raw interface M3File m3raw_impl; // raw implementation (usually empty) String *m3wrap_name; // wrapper module M3File m3wrap_intf; M3File m3wrap_impl; String *m3makefile; String *targetlibrary; String *proxy_class_def; String *proxy_class_code; String *proxy_class_name; String *variable_name; //Name of a variable being wrapped String *variable_type; //Type of this variable Hash *enumeration_coll; //Collection of all enumerations. /* The items are nodes with members: "items" - hash of with key 'itemname' and content 'itemvalue' "max" - maximum value in item list */ String *constant_values; String *constantfilename; String *renamefilename; String *typemapfilename; String *m3raw_imports; //intermediary class imports from %pragma String *module_imports; //module imports from %pragma String *m3raw_baseclass; //inheritance for intermediary class class from %pragma String *module_baseclass; //inheritance for module class from %pragma String *m3raw_interfaces; //interfaces for intermediary class class from %pragma String *module_interfaces; //interfaces for module class from %pragma String *m3raw_class_modifiers; //class modifiers for intermediary class overriden by %pragma String *m3wrap_modifiers; //class modifiers for module class overriden by %pragma String *upcasts_code; //C++ casts for inheritance hierarchies C++ code String *m3raw_cppcasts_code; //C++ casts up inheritance hierarchies intermediary class code String *destructor_call; //C++ destructor call if any String *outfile; enum type_additions { none, pointer, reference }; public: /* ----------------------------------------------------------------------------- * MODULA3() * ----------------------------------------------------------------------------- */ MODULA3(): empty_string(NewString("")), swig_types_hash(NULL), f_begin(NULL), f_runtime(NULL), f_header(NULL), f_wrappers(NULL), f_init(NULL), proxy_flag(true), have_default_constructor_flag(false), native_function_flag(false), enum_constant_flag(false), static_flag(false), variable_wrapper_flag(false), wrapping_member_flag(false), global_variable_flag(false), old_variable_names(false), unsafe_module(false), m3raw_name(NULL), m3raw_intf(), m3raw_impl(), m3wrap_name(NULL), m3wrap_intf(), m3wrap_impl(), m3makefile(NULL), targetlibrary(NULL), proxy_class_def(NULL), proxy_class_code(NULL), proxy_class_name(NULL), variable_name(NULL), variable_type(NULL), enumeration_coll(NULL), constant_values(NULL), constantfilename(NULL), renamefilename(NULL), typemapfilename(NULL), m3raw_imports(NULL), module_imports(NULL), m3raw_baseclass(NULL), module_baseclass(NULL), m3raw_interfaces(NULL), module_interfaces(NULL), m3raw_class_modifiers(NULL), m3wrap_modifiers(NULL), upcasts_code(NULL), m3raw_cppcasts_code(NULL), destructor_call(NULL), outfile(NULL) { } /************** some utility functions ***************/ /* ----------------------------------------------------------------------------- * getMappedType() * * Return the type of 'p' mapped by 'map'. * Print a standard warning if 'p' can't be mapped. * ----------------------------------------------------------------------------- */ String *getMappedType(Node *p, const char *map) { String *mapattr = NewString("tmap:"); Append(mapattr, map); String *tm = Getattr(p, mapattr); if (tm == NIL) { Swig_warning(WARN_MODULA3_TYPEMAP_TYPE_UNDEF, input_file, line_number, "No '%s' typemap defined for type '%s'\n", map, SwigType_str(Getattr(p, "type"), 0)); } Delete(mapattr); return tm; } /* ----------------------------------------------------------------------------- * getMappedTypeNew() * * Similar to getMappedType but uses Swig_type_lookup_new. * ----------------------------------------------------------------------------- */ String *getMappedTypeNew(Node *n, const char *map, const char *lname = "", bool warn = true) { String *tm = Swig_typemap_lookup(map, n, lname, 0); if ((tm == NIL) && warn) { Swig_warning(WARN_MODULA3_TYPEMAP_TYPE_UNDEF, input_file, line_number, "No '%s' typemap defined for type '%s'\n", map, SwigType_str(Getattr(n, "type"), 0)); } return tm; } /* ----------------------------------------------------------------------------- * attachMappedType() * * Obtain the type mapped by 'map' and attach it to the node * ----------------------------------------------------------------------------- */ void attachMappedType(Node *n, const char *map, const char *lname = "") { String *tm = Swig_typemap_lookup(map, n, lname, 0); if (tm != NIL) { String *attr = NewStringf("tmap:%s", map); Setattr(n, attr, tm); Delete(attr); } } /* ----------------------------------------------------------------------------- * skipIgnored() * * Skip all parameters that have 'numinputs=0' * with respect to a given typemap. * ----------------------------------------------------------------------------- */ Node *skipIgnored(Node *p, const char *map) { String *niattr = NewStringf("tmap:%s:numinputs", map); String *nextattr = NewStringf("tmap:%s:next", map); while ((p != NIL) && checkAttribute(p, niattr, "0")) { p = Getattr(p, nextattr); } Delete(nextattr); Delete(niattr); return p; } /* ----------------------------------------------------------------------------- * isInParam() * isOutParam() * * Check if the parameter is intended for input or for output. * ----------------------------------------------------------------------------- */ bool isInParam(Node *p) { String *dir = Getattr(p, "tmap:m3wrapargdir"); //printf("dir for %s: %s\n", Char(Getattr(p,"name")), Char(dir)); if ((dir == NIL) || (Strcmp(dir, "in") == 0) || (Strcmp(dir, "inout") == 0)) { return true; } else if (Strcmp(dir, "out") == 0) { return false; } else { printf("%s", USAGE_ARG_DIR); return false; } } bool isOutParam(Node *p) { String *dir = Getattr(p, "tmap:m3wrapargdir"); if ((dir == NIL) || (Strcmp(dir, "in") == 0)) { return false; } else if ((Strcmp(dir, "out") == 0) || (Strcmp(dir, "inout") == 0)) { return true; } else { printf("%s", USAGE_ARG_DIR); return false; } } /* ----------------------------------------------------------------------------- * printAttrs() * * For debugging: Show all attributes of a node and their values. * ----------------------------------------------------------------------------- */ void printAttrs(Node *n) { Iterator it; for (it = First(n); it.key != NIL; it = Next(it)) { printf("%s = %s\n", Char(it.key), Char(Getattr(n, it.key))); } } /* ----------------------------------------------------------------------------- * hasPrefix() * * Check if a string have a given prefix. * ----------------------------------------------------------------------------- */ bool hasPrefix(const String *str, const String *prefix) { int len_prefix = Len(prefix); return (Len(str) > len_prefix) && (Strncmp(str, prefix, len_prefix) == 0); } /* ----------------------------------------------------------------------------- * getQualifiedName() * * Return fully qualified identifier of n. * ----------------------------------------------------------------------------- */ #if 0 // Swig_symbol_qualified returns NIL for enumeration nodes String *getQualifiedName(Node *n) { String *qual = Swig_symbol_qualified(n); String *name = Getattr(n, "name"); if (hasContent(qual)) { return NewStringf("%s::%s", qual, name); } else { return name; } } #else String *getQualifiedName(Node *n) { String *name = Copy(Getattr(n, "name")); n = parentNode(n); while (n != NIL) { const String *type = nodeType(n); if ((Strcmp(type, "class") == 0) || (Strcmp(type, "struct") == 0) || (Strcmp(type, "namespace") == 0)) { String *newname = NewStringf("%s::%s", Getattr(n, "name"), name); Delete(name); //name = newname; // Hmpf, the class name is already qualified. return newname; } n = parentNode(n); } //printf("qualified name: %s\n", Char(name)); return name; } #endif /* ----------------------------------------------------------------------------- * nameToModula3() * * Turn usual C identifiers like "this_is_an_identifier" * into usual Modula 3 identifier like "thisIsAnIdentifier" * ----------------------------------------------------------------------------- */ String *nameToModula3(const String *sym, bool leadingCap) { int len_sym = Len(sym); char *csym = Char(sym); char *m3sym = new char[len_sym + 1]; int i, j; bool cap = leadingCap; for (i = 0, j = 0; j < len_sym; j++) { char c = csym[j]; if ((c == '_') || (c == ':')) { cap = true; } else { if (isdigit(c)) { m3sym[i] = c; cap = true; } else { if (cap) { m3sym[i] = (char)toupper(c); } else { m3sym[i] = (char)tolower(c); } cap = false; } i++; } } m3sym[i] = 0; String *result = NewString(m3sym); delete[]m3sym; return result; } /* ----------------------------------------------------------------------------- * capitalizeFirst() * * Make the first character upper case. * ----------------------------------------------------------------------------- */ String *capitalizeFirst(const String *str) { return NewStringf("%c%s", toupper(*Char(str)), Char(str) + 1); } /* ----------------------------------------------------------------------------- * prefixedNameToModula3() * * If feature modula3:oldprefix and modula3:newprefix is present * and the C identifier has leading 'oldprefix' * then it is replaced by the 'newprefix'. * The rest is converted to Modula style. * ----------------------------------------------------------------------------- */ String *prefixedNameToModula3(Node *n, const String *sym, bool leadingCap) { String *oldPrefix = Getattr(n, "feature:modula3:oldprefix"); String *newPrefix = Getattr(n, "feature:modula3:newprefix"); String *result = NewString(""); char *short_sym = Char(sym); // if at least one prefix feature is present // the replacement takes place if ((oldPrefix != NIL) || (newPrefix != NIL)) { if ((oldPrefix == NIL) || hasPrefix(sym, oldPrefix)) { short_sym += Len(oldPrefix); if (newPrefix != NIL) { Append(result, newPrefix); } } } String *suffix = nameToModula3(short_sym, leadingCap || hasContent(newPrefix)); Append(result, suffix); Delete(suffix); return result; } /* ----------------------------------------------------------------------------- * hasContent() * * Check if the string exists and contains something. * ----------------------------------------------------------------------------- */ bool hasContent(const String *str) { return (str != NIL) && (Strcmp(str, "") != 0); } /* ----------------------------------------------------------------------------- * openWriteFile() * * Caution: The file must be freshly allocated and will be destroyed * by this routine. * ----------------------------------------------------------------------------- */ File *openWriteFile(String *name) { File *file = NewFile(name, "w", SWIG_output_files()); if (!file) { FileErrorDisplay(name); SWIG_exit(EXIT_FAILURE); } Delete(name); return file; } /* ----------------------------------------------------------------------------- * aToL() * * like atol but with additional user warning * ----------------------------------------------------------------------------- */ long aToL(const String *value) { char *endptr; long numvalue = strtol(Char(value), &endptr, 0); if (*endptr != 0) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "The string <%s> does not denote a numeric value.\n", value); } return numvalue; } /* ----------------------------------------------------------------------------- * strToL() * * like strtol but returns if the conversion was successful * ----------------------------------------------------------------------------- */ bool strToL(const String *value, long &numvalue) { char *endptr; numvalue = strtol(Char(value), &endptr, 0); return (*endptr == 0); } /* ----------------------------------------------------------------------------- * evalExpr() * * Evaluate simple expression as they may occur in "enumvalue" attributes. * ----------------------------------------------------------------------------- */ bool evalExpr(String *value, long &numvalue) { // Split changes file status of String and thus cannot receive 'const' strings //printf("evaluate <%s>\n", Char(value)); List *summands = Split(value, '+', INT_MAX); Iterator sm = First(summands); numvalue = 0; for (; sm.item != NIL; sm = Next(sm)) { String *smvalue = Getattr(constant_values, sm.item); long smnumvalue; if (smvalue != NIL) { if (!strToL(smvalue, smnumvalue)) { //printf("evaluation: abort 0 <%s>\n", Char(smvalue)); return false; } } else { if (!strToL(sm.item, smnumvalue)) { //printf("evaluation: abort 1 <%s>\n", Char(sm)); return false; } } numvalue += smnumvalue; } //printf("evaluation: return %ld\n", numvalue); return true; } /* ----------------------------------------------------------------------------- * log2() * * Determine the position of the single bit of a power of two. * Returns true if the given number is a power of two. * ----------------------------------------------------------------------------- */ bool log2(long n, long &exp) { exp = 0; while (n > 0) { if ((n & 1) != 0) { return n == 1; } exp++; n >>= 1; } return false; } /* ----------------------------------------------------------------------------- * writeArg * * Write a function argument or RECORD entry definition. * Bundles arguments of same type and default value. * 'name.next==NIL' denotes the end of the entry or argument list. * ----------------------------------------------------------------------------- */ bool equalNilStr(const String *str0, const String *str1) { if (str0 == NIL) { return (str1 == NIL); //return (str0==NIL) == (str1==NIL); } else { return (str1 != NIL) && (Cmp(str0, str1) == 0); //return Cmp(str0,str1)==0; } } struct writeArgState { String *mode, *name, *type, *value; bool hold; writeArgState():mode(NIL), name(NIL), type(NIL), value(NIL), hold(false) { } }; void writeArg(File *f, writeArgState & state, String *mode, String *name, String *type, String *value) { /* skip the first argument, only store the information for the next call in this case */ if (state.name != NIL) { if ((!state.hold) && (state.mode != NIL)) { Printf(f, "%s ", state.mode); } if ((name != NIL) && equalNilStr(state.mode, mode) && equalNilStr(state.type, type) && (state.value == NIL) && (value == NIL) /* the same expression may have different values due to side effects of the called function */ /*equalNilStr(state.value,value) */ ) { Printf(f, "%s, ", state.name); state.hold = true; } else { Append(f, state.name); if (state.type != NIL) { Printf(f, ": %s", state.type); } if (state.value != NIL) { Printf(f, ":= %s", state.value); } Append(f, ";\n"); state.hold = false; } } /* at the next call the current argument will be the previous one */ state.mode = mode; state.name = name; state.type = type; state.value = value; } /* ----------------------------------------------------------------------------- * getProxyName() * * Test to see if a type corresponds to something wrapped with a proxy class * Return NULL if not otherwise the proxy class name * ----------------------------------------------------------------------------- */ String *getProxyName(SwigType *t) { if (proxy_flag) { Node *n = classLookup(t); if (n) { return Getattr(n, "sym:name"); } } return NULL; } /*************** language processing ********************/ /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { SWIG_library_directory("modula3"); // Look for certain command line options for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-generateconst") == 0) { if (argv[i + 1]) { constantfilename = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-generaterename") == 0) { if (argv[i + 1]) { renamefilename = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-generatetypemap") == 0) { if (argv[i + 1]) { typemapfilename = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-noproxy") == 0) { Swig_mark_arg(i); proxy_flag = false; } else if (strcmp(argv[i], "-oldvarnames") == 0) { Swig_mark_arg(i); old_variable_names = true; } else if (strcmp(argv[i], "-help") == 0) { Printf(stdout, "%s\n", usage); } } } // Add a symbol to the parser for conditional compilation Preprocessor_define("SWIGMODULA3 1", 0); // Add typemap definitions SWIG_typemap_lang("modula3"); SWIG_config_file("modula3.swg"); allow_overloading(); } /* --------------------------------------------------------------------- * top() * --------------------------------------------------------------------- */ virtual int top(Node *n) { if (hasContent(constantfilename) || hasContent(renamefilename) || hasContent(typemapfilename)) { int result = SWIG_OK; if (hasContent(constantfilename)) { result = generateConstantTop(n) && result; } if (hasContent(renamefilename)) { result = generateRenameTop(n) && result; } if (hasContent(typemapfilename)) { result = generateTypemapTop(n) && result; } return result; } else { return generateM3Top(n); } } void scanConstant(File *file, Node *n) { Node *child = firstChild(n); while (child != NIL) { String *constname = NIL; String *type = nodeType(child); if ((Strcmp(type, "enumitem") == 0) || (Strcmp(type, "constant") == 0)) { #if 1 constname = getQualifiedName(child); #else constname = Getattr(child, "value"); if ((!hasContent(constname)) || (('0' <= *Char(constname)) && (*Char(constname) <= '9'))) { constname = Getattr(child, "name"); } #endif } if (constname != NIL) { Printf(file, " printf(\"%%%%constnumeric(%%Lg) %s;\\n\", (long double)%s);\n", constname, constname); } scanConstant(file, child); child = nextSibling(child); } } int generateConstantTop(Node *n) { File *file = openWriteFile(NewStringf("%s.c", constantfilename)); if (CPlusPlus) { Printf(file, "#include \n"); } else { Printf(file, "#include \n"); } Printf(file, "#include \"%s\"\n", input_file); Printf(file, "\n"); Printf(file, "int main (int argc, char *argv[]) {\n"); Printf(file, "\ /*This progam must work for floating point numbers and integers.\n\ Thus all numbers are converted to double precision floating point format.*/\n"); scanConstant(file, n); Printf(file, " return 0;\n"); Printf(file, "}\n"); Delete(file); return SWIG_OK; } void scanRename(File *file, Node *n) { Node *child = firstChild(n); while (child != NIL) { String *type = nodeType(child); if (Strcmp(type, "cdecl") == 0) { ParmList *p = Getattr(child, "parms"); if (p != NIL) { String *name = getQualifiedName(child); String *m3name = nameToModula3(name, true); /*don't know how to get the original C type identifiers */ //String *arguments = createCSignature (child); Printf(file, "%%rename(\"%s\") %s;\n", m3name, name); /*Printf(file, "%%rename(\"%s\") %s %s(%s);\n", m3name, Getattr(n,"type"), name, arguments); */ Delete(name); Delete(m3name); //Delete (arguments); } } scanRename(file, child); child = nextSibling(child); } } int generateRenameTop(Node *n) { File *file = openWriteFile(NewStringf("%s.i", renamefilename)); Printf(file, "\ /* This file was generated from %s\n\ by SWIG with option -generaterename. */\n\ \n", input_file); scanRename(file, n); Delete(file); return SWIG_OK; } void scanTypemap(File *file, Node *n) { Node *child = firstChild(n); while (child != NIL) { String *type = nodeType(child); //printf("nodetype %s\n", Char(type)); String *storage = Getattr(child, "storage"); if ((Strcmp(type, "class") == 0) || ((Strcmp(type, "cdecl") == 0) && (storage != NIL) && (Strcmp(storage, "typedef") == 0))) { String *name = getQualifiedName(child); String *m3name = nameToModula3(name, true); Printf(file, "%%typemap(\"m3wrapintype\") %s %%{%s%%}\n", name, m3name); Printf(file, "%%typemap(\"m3rawintype\") %s %%{%s%%}\n", name, m3name); Printf(file, "\n"); } scanTypemap(file, child); child = nextSibling(child); } } int generateTypemapTop(Node *n) { File *file = openWriteFile(NewStringf("%s.i", typemapfilename)); Printf(file, "\ /* This file was generated from %s\n\ by SWIG with option -generatetypemap. */\n\ \n", input_file); scanTypemap(file, n); Delete(file); return SWIG_OK; } int generateM3Top(Node *n) { /* Initialize all of the output files */ outfile = Getattr(n, "outfile"); f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); m3makefile = NewString(""); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("m3rawintf", m3raw_intf.f); Swig_register_filebyname("m3rawimpl", m3raw_impl.f); Swig_register_filebyname("m3wrapintf", m3wrap_intf.f); Swig_register_filebyname("m3wrapimpl", m3wrap_impl.f); Swig_register_filebyname("m3makefile", m3makefile); swig_types_hash = NewHash(); String *name = Getattr(n, "name"); // Make the intermediary class and module class names. The intermediary class name can be set in the module directive. Node *optionsnode = Getattr(Getattr(n, "module"), "options"); if (optionsnode != NIL) { String *m3raw_name_tmp = Getattr(optionsnode, "m3rawname"); if (m3raw_name_tmp != NIL) { m3raw_name = Copy(m3raw_name_tmp); } } if (m3raw_name == NIL) { m3raw_name = NewStringf("%sRaw", name); } Setattr(m3wrap_impl.import, m3raw_name, ""); m3wrap_name = Copy(name); proxy_class_def = NewString(""); proxy_class_code = NewString(""); m3raw_baseclass = NewString(""); m3raw_interfaces = NewString(""); m3raw_class_modifiers = NewString(""); // package access only to the intermediary class by default m3raw_imports = NewString(""); m3raw_cppcasts_code = NewString(""); m3wrap_modifiers = NewString("public"); module_baseclass = NewString(""); module_interfaces = NewString(""); module_imports = NewString(""); upcasts_code = NewString(""); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGMODULA3\n"); Printf(f_runtime, "\n"); Swig_name_register("wrapper", "Modula3_%f"); if (old_variable_names) { Swig_name_register("set", "set_%n%v"); Swig_name_register("get", "get_%n%v"); } Printf(f_wrappers, "\n#ifdef __cplusplus\n"); Printf(f_wrappers, "extern \"C\" {\n"); Printf(f_wrappers, "#endif\n\n"); constant_values = NewHash(); scanForConstPragmas(n); enumeration_coll = NewHash(); collectEnumerations(enumeration_coll, n); /* Emit code */ Language::top(n); // Generate m3makefile // This will be unnecessary if SWIG is invoked from Quake. { File *file = openWriteFile(NewStringf("%sm3makefile", SWIG_output_directory())); Printf(file, "%% automatically generated quake file for %s\n\n", name); /* Write the fragments written by '%insert' collected while 'top' processed the parse tree */ Printv(file, m3makefile, NIL); Printf(file, "import(\"libm3\")\n"); //Printf(file, "import_lib(\"%s\",\"/usr/lib\")\n", name); Printf(file, "module(\"%s\")\n", m3raw_name); Printf(file, "module(\"%s\")\n\n", m3wrap_name); if (targetlibrary != NIL) { Printf(file, "library(\"%s\")\n", targetlibrary); } else { Printf(file, "library(\"m3%s\")\n", name); } Delete(file); } // Generate the raw interface { File *file = openWriteFile(NewStringf("%s%s.i3", SWIG_output_directory(), m3raw_name)); emitBanner(file); Printf(file, "INTERFACE %s;\n\n", m3raw_name); emitImportStatements(m3raw_intf.import, file); Printf(file, "\n"); // Write the interface generated within 'top' Printv(file, m3raw_intf.f, NIL); Printf(file, "\nEND %s.\n", m3raw_name); Delete(file); } // Generate the raw module { File *file = openWriteFile(NewStringf("%s%s.m3", SWIG_output_directory(), m3raw_name)); emitBanner(file); Printf(file, "MODULE %s;\n\n", m3raw_name); emitImportStatements(m3raw_impl.import, file); Printf(file, "\n"); // will be empty usually Printv(file, m3raw_impl.f, NIL); Printf(file, "BEGIN\nEND %s.\n", m3raw_name); Delete(file); } // Generate the interface for the comfort wrappers { File *file = openWriteFile(NewStringf("%s%s.i3", SWIG_output_directory(), m3wrap_name)); emitBanner(file); Printf(file, "INTERFACE %s;\n", m3wrap_name); emitImportStatements(m3wrap_intf.import, file); Printf(file, "\n"); { Iterator it = First(enumeration_coll); if (it.key != NIL) { Printf(file, "TYPE\n"); } for (; it.key != NIL; it = Next(it)) { Printf(file, "\n"); emitEnumeration(file, it.key, it.item); } } // Add the wrapper methods Printv(file, m3wrap_intf.f, NIL); // Finish off the class Printf(file, "\nEND %s.\n", m3wrap_name); Delete(file); } // Generate the wrapper routines implemented in Modula 3 { File *file = openWriteFile(NewStringf("%s%s.m3", SWIG_output_directory(), m3wrap_name)); emitBanner(file); if (unsafe_module) { Printf(file, "UNSAFE "); } Printf(file, "MODULE %s;\n\n", m3wrap_name); emitImportStatements(m3wrap_impl.import, file); Printf(file, "\n"); // Add the wrapper methods Printv(file, m3wrap_impl.f, NIL); Printf(file, "\nBEGIN\nEND %s.\n", m3wrap_name); Delete(file); } if (upcasts_code) Printv(f_wrappers, upcasts_code, NIL); Printf(f_wrappers, "#ifdef __cplusplus\n"); Printf(f_wrappers, "}\n"); Printf(f_wrappers, "#endif\n"); // Output a Modula 3 type wrapper class for each SWIG type for (Iterator swig_type = First(swig_types_hash); swig_type.item != NIL; swig_type = Next(swig_type)) { emitTypeWrapperClass(swig_type.key, swig_type.item); } Delete(swig_types_hash); swig_types_hash = NULL; Delete(constant_values); constant_values = NULL; Delete(enumeration_coll); enumeration_coll = NULL; Delete(m3raw_name); m3raw_name = NULL; Delete(m3raw_baseclass); m3raw_baseclass = NULL; Delete(m3raw_interfaces); m3raw_interfaces = NULL; Delete(m3raw_class_modifiers); m3raw_class_modifiers = NULL; Delete(m3raw_imports); m3raw_imports = NULL; Delete(m3raw_cppcasts_code); m3raw_cppcasts_code = NULL; Delete(proxy_class_def); proxy_class_def = NULL; Delete(proxy_class_code); proxy_class_code = NULL; Delete(m3wrap_name); m3wrap_name = NULL; Delete(m3wrap_modifiers); m3wrap_modifiers = NULL; Delete(targetlibrary); targetlibrary = NULL; Delete(module_baseclass); module_baseclass = NULL; Delete(module_interfaces); module_interfaces = NULL; Delete(module_imports); module_imports = NULL; Delete(upcasts_code); upcasts_code = NULL; Delete(constantfilename); constantfilename = NULL; Delete(renamefilename); renamefilename = NULL; Delete(typemapfilename); typemapfilename = NULL; /* Close all of the files */ Dump(f_runtime, f_begin); Dump(f_header, f_begin); Dump(f_wrappers, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /* ----------------------------------------------------------------------------- * emitBanner() * ----------------------------------------------------------------------------- */ void emitBanner(File *f) { Printf(f, "(*******************************************************************************\n"); Swig_banner_target_lang(f, " *"); Printf(f, "*******************************************************************************)\n\n"); } /* ---------------------------------------------------------------------- * nativeWrapper() * ---------------------------------------------------------------------- */ virtual int nativeWrapper(Node *n) { String *wrapname = Getattr(n, "wrap:name"); if (!addSymbol(wrapname, n)) return SWIG_ERROR; if (Getattr(n, "type")) { Swig_save("nativeWrapper", n, "name", NIL); Setattr(n, "name", wrapname); native_function_flag = true; functionWrapper(n); Swig_restore(n); native_function_flag = false; } else { Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name")); } return SWIG_OK; } /* ---------------------------------------------------------------------- * functionWrapper() * ---------------------------------------------------------------------- */ virtual int functionWrapper(Node *n) { String *type = nodeType(n); String *funcType = Getattr(n, "modula3:functype"); String *rawname = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); String *capname = capitalizeFirst(symname); //String *wname = Swig_name_wrapper(symname); //printf("function: %s\n", Char(symname)); //printf(" purpose: %s\n", Char(funcType)); if (Strcmp(type, "cdecl") == 0) { if (funcType == NIL) { // no wrapper needed for plain functions emitM3RawPrototype(n, rawname, symname); emitM3Wrapper(n, symname); } else if (Strcmp(funcType, "method") == 0) { Setattr(n, "modula3:funcname", capname); emitCWrapper(n, capname); emitM3RawPrototype(n, capname, capname); emitM3Wrapper(n, capname); } else if (Strcmp(funcType, "accessor") == 0) { /* * Generate the proxy class properties for public member variables. * Not for enums and constants. */ if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { // Capitalize the first letter in the function name Setattr(n, "proxyfuncname", capname); Setattr(n, "imfuncname", symname); if (hasPrefix(capname, "Set")) { Setattr(n, "modula3:setname", capname); } else { Setattr(n, "modula3:getname", capname); } emitCWrapper(n, capname); emitM3RawPrototype(n, capname, capname); emitM3Wrapper(n, capname); //proxyClassFunctionHandler(n); } #ifdef DEBUG } else { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Function type <%s> unknown.\n", Char(funcType)); #endif } } else if ((Strcmp(type, "constructor") == 0) || (Strcmp(type, "destructor") == 0)) { emitCWrapper(n, capname); emitM3RawPrototype(n, capname, capname); emitM3Wrapper(n, capname); } // a Java relict #if 0 if (!(proxy_flag && is_wrapping_class()) && !enum_constant_flag) { emitM3Wrapper(n, capname); } #endif Delete(capname); return SWIG_OK; } /* ---------------------------------------------------------------------- * emitCWrapper() * * Generate the wrapper in C which calls C++ methods. * ---------------------------------------------------------------------- */ virtual int emitCWrapper(Node *n, const String *wname) { String *rawname = Getattr(n, "name"); String *c_return_type = NewString(""); String *cleanup = NewString(""); String *outarg = NewString(""); String *body = NewString(""); Hash *throws_hash = NewHash(); ParmList *l = Getattr(n, "parms"); SwigType *t = Getattr(n, "type"); String *symname = Getattr(n, "sym:name"); if (!Getattr(n, "sym:overloaded")) { if (!addSymbol(wname, n)) { return SWIG_ERROR; } } // A new wrapper function object Wrapper *f = NewWrapper(); /* Attach the non-standard typemaps to the parameter list. */ Swig_typemap_attach_parms("ctype", l, f); /* Get return types */ { String *tm = getMappedTypeNew(n, "ctype", ""); if (tm != NIL) { Printf(c_return_type, "%s", tm); } } bool is_void_return = (Cmp(c_return_type, "void") == 0); if (!is_void_return) { Wrapper_add_localv(f, "cresult", c_return_type, "cresult = 0", NIL); } Printv(f->def, " SWIGEXPORT ", c_return_type, " ", wname, "(", NIL); // Emit all of the local variables for holding arguments. emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); // Generate signature and argument conversion for C wrapper { Parm *p; attachParameterNames(n, "tmap:name", "c:wrapname", "m3arg%d"); bool gencomma = false; for (p = skipIgnored(l, "in"); p; p = skipIgnored(p, "in")) { String *arg = Getattr(p, "c:wrapname"); { /* Get the ctype types of the parameter */ String *c_param_type = getMappedType(p, "ctype"); // Add parameter to C function Printv(f->def, gencomma ? ", " : "", c_param_type, " ", arg, NIL); Delete(c_param_type); gencomma = true; } // Get typemap for this argument String *tm = getMappedType(p, "in"); if (tm != NIL) { addThrows(throws_hash, "in", p); Replaceall(tm, "$input", arg); Setattr(p, "emit:input", arg); /*??? */ Printf(f->code, "%s\n", tm); p = Getattr(p, "tmap:in:next"); } else { p = nextSibling(p); } } } /* Insert constraint checking code */ { Parm *p; for (p = l; p;) { String *tm = Getattr(p, "tmap:check"); if (tm != NIL) { addThrows(throws_hash, "check", p); Replaceall(tm, "$target", Getattr(p, "lname")); /* deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); /* deprecated? */ Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } } /* Insert cleanup code */ { Parm *p; for (p = l; p;) { String *tm = Getattr(p, "tmap:freearg"); if (tm != NIL) { addThrows(throws_hash, "freearg", p); Replaceall(tm, "$source", Getattr(p, "emit:input")); /* deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); /* deprecated? */ Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } } /* Insert argument output code */ { Parm *p; for (p = l; p;) { String *tm = Getattr(p, "tmap:argout"); if (tm != NIL) { addThrows(throws_hash, "argout", p); Replaceall(tm, "$source", Getattr(p, "emit:input")); /* deprecated */ Replaceall(tm, "$target", Getattr(p, "lname")); /* deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); /* deprecated? */ Replaceall(tm, "$result", "cresult"); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } } // Get any Modula 3 exception classes in the throws typemap ParmList *throw_parm_list = NULL; if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); Parm *p; for (p = throw_parm_list; p; p = nextSibling(p)) { addThrows(throws_hash, "throws", p); } } if (Cmp(nodeType(n), "constant") == 0) { // Wrapping a constant hack Swig_save("functionWrapper", n, "wrap:action", NIL); // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value"))); } Setattr(n, "wrap:name", wname); // Now write code to make the function call if (!native_function_flag) { String *actioncode = emit_action(n); if (Cmp(nodeType(n), "constant") == 0) { Swig_restore(n); } /* Return value if necessary */ String *tm; if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { addThrows(throws_hash, "out", n); Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Replaceall(tm, "$target", "cresult"); /* deprecated */ Replaceall(tm, "$result", "cresult"); Printf(f->code, "%s", tm); if (hasContent(tm)) Printf(f->code, "\n"); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), rawname); } emit_return_variable(n, t, f); } /* Output argument output code */ Printv(f->code, outarg, NIL); /* Output cleanup code */ Printv(f->code, cleanup, NIL); /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0); if (tm != NIL) { addThrows(throws_hash, "newfree", n); Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if (!native_function_flag) { String *tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0); if (tm != NIL) { Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } /* Finish C wrapper */ Printf(f->def, ") {"); if (!is_void_return) Printv(f->code, " return cresult;\n", NIL); Printf(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); /* Substitute the function name */ Replaceall(f->code, "$symname", symname); if (!is_void_return) { Replaceall(f->code, "$null", "0"); } else { Replaceall(f->code, "$null", ""); } /* Dump the function out */ if (!native_function_flag) { Wrapper_print(f, f_wrappers); } Delete(c_return_type); Delete(cleanup); Delete(outarg); Delete(body); Delete(throws_hash); DelWrapper(f); return SWIG_OK; } /* ---------------------------------------------------------------------- * emitM3RawPrototype() * * Generate an EXTERNAL procedure declaration in Modula 3 * which is the interface to an existing C routine or a C wrapper. * ---------------------------------------------------------------------- */ virtual int emitM3RawPrototype(Node *n, const String *cname, const String *m3name) { String *im_return_type = NewString(""); //String *symname = Getattr(n,"sym:name"); ParmList *l = Getattr(n, "parms"); /* Attach the non-standard typemaps to the parameter list. */ Swig_typemap_attach_parms("m3rawinmode", l, NULL); Swig_typemap_attach_parms("m3rawintype", l, NULL); /* Get return types */ bool has_return; { String *tm = getMappedTypeNew(n, "m3rawrettype", ""); if (tm != NIL) { Printf(im_return_type, "%s", tm); } has_return = hasContent(tm); } /* cname is the original name if 'n' denotes a C function and it is the relabeled name (sym:name) if 'n' denotes a C++ method or similar */ m3raw_intf.enterBlock(no_block); Printf(m3raw_intf.f, "\n<* EXTERNAL %s *>\nPROCEDURE %s (", cname, m3name); // Generate signature for raw interface { Parm *p; writeArgState state; attachParameterNames(n, "tmap:rawinname", "modula3:rawname", "arg%d"); for (p = skipIgnored(l, "m3rawintype"); p; p = skipIgnored(p, "m3rawintype")) { /* Get argument passing mode, should be one of VALUE, VAR, READONLY */ String *mode = Getattr(p, "tmap:m3rawinmode"); String *argname = Getattr(p, "modula3:rawname"); String *im_param_type = getMappedType(p, "m3rawintype"); addImports(m3raw_intf.import, "m3rawintype", p); writeArg(m3raw_intf.f, state, mode, argname, im_param_type, NIL); if (im_param_type != NIL) { p = Getattr(p, "tmap:m3rawintype:next"); } else { p = nextSibling(p); } } writeArg(m3raw_intf.f, state, NIL, NIL, NIL, NIL); } /* Finish M3 raw prototype */ Printf(m3raw_intf.f, ")"); // neither a C wrapper nor a plain C function may throw an exception //generateThrowsClause(throws_hash, m3raw_intf.f); if (has_return) { Printf(m3raw_intf.f, ": %s", im_return_type); } Printf(m3raw_intf.f, ";\n"); Delete(im_return_type); return SWIG_OK; } /* ----------------------------------------------------------------------- * variableWrapper() * ----------------------------------------------------------------------- */ virtual int variableWrapper(Node *n) { Language::variableWrapper(n); return SWIG_OK; } /* ----------------------------------------------------------------------- * globalvariableHandler() * ----------------------------------------------------------------------- */ virtual int globalvariableHandler(Node *n) { SwigType *t = Getattr(n, "type"); String *tm; // Get the variable type if ((tm = getMappedTypeNew(n, "m3wraptype", ""))) { substituteClassname(t, tm); } variable_name = Getattr(n, "sym:name"); variable_type = Copy(tm); // Get the variable type expressed in terms of Modula 3 equivalents of C types if ((tm = getMappedTypeNew(n, "m3rawtype", ""))) { m3raw_intf.enterBlock(no_block); Printf(m3raw_intf.f, "\n<* EXTERNAL *> VAR %s: %s;\n", variable_name, tm); } // Output the property's accessor methods /* global_variable_flag = true; int ret = Language::globalvariableHandler(n); global_variable_flag = false; */ Printf(m3wrap_impl.f, "\n\n"); //return ret; return 1; } long getConstNumeric(Node *n) { String *constnumeric = Getfeature(n, "constnumeric"); String *name = Getattr(n, "name"); long numvalue; if (constnumeric == NIL) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Feature 'constnumeric' is necessary to obtain value of %s.\n", name); return 0; } else if (!strToL(constnumeric, numvalue)) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "The feature 'constnumeric' of %s specifies value <%s> which is not an integer constant.\n", name, constnumeric); return 0; } else { return numvalue; } } /* ------------------------------------------------------------------------ * generateIntConstant() * * Considers node as an integer constant definition * and generate a Modula 3 constant definition. * ------------------------------------------------------------------------ */ void generateIntConstant(Node *n, String *name) { String *value = Getattr(n, "value"); String *type = Getfeature(n, "modula3:constint:type"); String *conv = Getfeature(n, "modula3:constint:conv"); if (name == NIL) { name = Getattr(n, "sym:name"); } long numvalue; bool isSimpleNum = strToL(value, numvalue); if (!isSimpleNum) { numvalue = getConstNumeric(n); } String *m3value; if ((conv == NIL) || ((Strcmp(conv, "set:int") != 0) && (Strcmp(conv, "int:set") != 0))) { /* The original value of the constant has precedence over 'constnumeric' feature since we like to keep the style (that is the base) of simple numeric constants */ if (isSimpleNum) { if (hasPrefix(value, "0x")) { m3value = NewStringf("16_%s", Char(value) + 2); } else if ((Len(value) > 1) && (*Char(value) == '0')) { m3value = NewStringf("8_%s", Char(value) + 1); } else { m3value = Copy(value); } /* If we cannot easily obtain the value of a numeric constant, we use the results given by a C compiler. */ } else { m3value = Copy(Getfeature(n, "constnumeric")); } } else { // if the value can't be converted, it is ignored if (convertInt(numvalue, numvalue, conv)) { m3value = NewStringf("%d", numvalue); } else { m3value = NIL; } } if (m3value != NIL) { m3wrap_intf.enterBlock(constant); Printf(m3wrap_intf.f, "%s", name); if (hasContent(type)) { Printf(m3wrap_intf.f, ": %s", type); } Printf(m3wrap_intf.f, " = %s;\n", m3value); Delete(m3value); } } /* ----------------------------------------------------------------------- * generateSetConstant() * * Considers node as a set constant definition * and generate a Modula 3 constant definition. * ------------------------------------------------------------------------ */ void generateSetConstant(Node *n, String *name) { String *value = Getattr(n, "value"); String *type = Getfeature(n, "modula3:constset:type"); String *setname = Getfeature(n, "modula3:constset:set"); String *basename = Getfeature(n, "modula3:constset:base"); String *conv = Getfeature(n, "modula3:constset:conv"); m3wrap_intf.enterBlock(constant); Printf(m3wrap_intf.f, "%s", name); if (type != NIL) { Printf(m3wrap_intf.f, ":%s ", type); } Printf(m3wrap_intf.f, " = %s{", setname); long numvalue = 0; if (!strToL(value, numvalue)) { numvalue = getConstNumeric(n); } convertInt(numvalue, numvalue, conv); bool isIntType = Strcmp(basename, "CARDINAL") == 0; Hash *items = NIL; if (!isIntType) { Hash *enumeration = Getattr(enumeration_coll, basename); if (enumeration == NIL) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "There is no enumeration <%s> as needed for the set.\n", setname); isIntType = true; } else { items = Getattr(enumeration, "items"); } } bool gencomma = false; int bitpos = 0; while (numvalue > 0) { if ((numvalue & 1) != 0) { if (isIntType) { if (gencomma) { Printv(m3wrap_intf.f, ",", NIL); } gencomma = true; Printf(m3wrap_intf.f, "%d", bitpos); } else { char bitval[15]; sprintf(bitval, "%d", bitpos); String *bitname = Getattr(items, bitval); if (bitname == NIL) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Enumeration <%s> has no value <%s>.\n", setname, bitval); } else { if (gencomma) { Printv(m3wrap_intf.f, ",", NIL); } gencomma = true; Printf(m3wrap_intf.f, "%s.%s", basename, bitname); } } } numvalue >>= 1; bitpos++; } Printf(m3wrap_intf.f, "};\n"); } void generateConstant(Node *n) { // any of the special interpretation disables the default behaviour String *enumitem = Getfeature(n, "modula3:enumitem:name"); String *constset = Getfeature(n, "modula3:constset:name"); String *constint = Getfeature(n, "modula3:constint:name"); if (hasContent(enumitem) || hasContent(constset) || hasContent(constint)) { if (hasContent(constset)) { generateSetConstant(n, constset); } if (hasContent(constint)) { generateIntConstant(n, constint); } } else { String *value = Getattr(n, "value"); String *name = Getattr(n, "sym:name"); if (name == NIL) { name = Getattr(n, "name"); } m3wrap_intf.enterBlock(constant); Printf(m3wrap_intf.f, "%s = %s;\n", name, value); } } void emitEnumeration(File *file, String *name, Node *n) { Printf(file, "%s = {", name); int i; bool gencomma = false; int max = aToL(Getattr(n, "max")); Hash *items = Getattr(n, "items"); for (i = 0; i <= max; i++) { if (gencomma) { Printf(file, ","); } Printf(file, "\n"); gencomma = true; char numstr[15]; sprintf(numstr, "%d", i); String *name = Getattr(items, numstr); if (name != NIL) { Printv(file, name, NIL); } else { Printf(file, "Dummy%d", i); } } Printf(file, "\n};\n"); } /* ----------------------------------------------------------------------- * constantWrapper() * * Handles constants and enumeration items. * ------------------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { generateConstant(n); return SWIG_OK; } #if 0 // enumerations are handled like constant definitions /* ----------------------------------------------------------------------------- * enumDeclaration() * ----------------------------------------------------------------------------- */ virtual int enumDeclaration(Node *n) { String *symname = nameToModula3(Getattr(n, "sym:name"), true); enumerationStart(symname); int result = Language::enumDeclaration(n); enumerationStop(); Delete(symname); return result; } #endif /* ----------------------------------------------------------------------------- * enumvalueDeclaration() * ----------------------------------------------------------------------------- */ virtual int enumvalueDeclaration(Node *n) { generateConstant(n); /* This call would continue processing in the constantWrapper which cannot handle values like "RED+1". return Language::enumvalueDeclaration(n); */ return SWIG_OK; } /* ----------------------------------------------------------------------------- * pragmaDirective() * * Valid Pragmas: * imclassbase - base (extends) for the intermediary class * imclassclassmodifiers - class modifiers for the intermediary class * imclasscode - text (Modula 3 code) is copied verbatim to the intermediary class * imclassimports - import statements for the intermediary class * imclassinterfaces - interface (implements) for the intermediary class * * modulebase - base (extends) for the module class * moduleclassmodifiers - class modifiers for the module class * modulecode - text (Modula 3 code) is copied verbatim to the module class * moduleimports - import statements for the module class * moduleinterfaces - interface (implements) for the module class * * ----------------------------------------------------------------------------- */ virtual int pragmaDirective(Node *n) { if (!ImportMode) { String *lang = Getattr(n, "lang"); String *code = Getattr(n, "name"); String *value = Getattr(n, "value"); if (Strcmp(lang, "modula3") == 0) { String *strvalue = NewString(value); Replaceall(strvalue, "\\\"", "\""); /* bool isEnumItem = Strcmp(code, "enumitem") == 0; bool isSetItem = Strcmp(code, "setitem") == 0; */ if (Strcmp(code, "imclassbase") == 0) { Delete(m3raw_baseclass); m3raw_baseclass = Copy(strvalue); } else if (Strcmp(code, "imclassclassmodifiers") == 0) { Delete(m3raw_class_modifiers); m3raw_class_modifiers = Copy(strvalue); } else if (Strcmp(code, "imclasscode") == 0) { Printf(m3raw_intf.f, "%s\n", strvalue); } else if (Strcmp(code, "imclassimports") == 0) { Delete(m3raw_imports); m3raw_imports = Copy(strvalue); } else if (Strcmp(code, "imclassinterfaces") == 0) { Delete(m3raw_interfaces); m3raw_interfaces = Copy(strvalue); } else if (Strcmp(code, "modulebase") == 0) { Delete(module_baseclass); module_baseclass = Copy(strvalue); } else if (Strcmp(code, "moduleclassmodifiers") == 0) { Delete(m3wrap_modifiers); m3wrap_modifiers = Copy(strvalue); } else if (Strcmp(code, "modulecode") == 0) { Printf(m3wrap_impl.f, "%s\n", strvalue); } else if (Strcmp(code, "moduleimports") == 0) { Delete(module_imports); module_imports = Copy(strvalue); } else if (Strcmp(code, "moduleinterfaces") == 0) { Delete(module_interfaces); module_interfaces = Copy(strvalue); } else if (Strcmp(code, "unsafe") == 0) { unsafe_module = true; } else if (Strcmp(code, "library") == 0) { if (targetlibrary) { Delete(targetlibrary); } targetlibrary = Copy(strvalue); } else if (Strcmp(code, "enumitem") == 0) { } else if (Strcmp(code, "constset") == 0) { } else if (Strcmp(code, "constint") == 0) { } else if (Strcmp(code, "makesetofenum") == 0) { m3wrap_intf.enterBlock(blocktype); Printf(m3wrap_intf.f, "%sSet = SET OF %s;\n", value, value); } else { Swig_warning(WARN_MODULA3_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", code); } Delete(strvalue); } } return Language::pragmaDirective(n); } void Setfeature(Node *n, const char *feature, const String *value, bool warn = false) { //printf("tag feature <%s> with value <%s>\n", feature, Char(value)); String *attr = NewStringf("feature:%s", feature); if ((Setattr(n, attr, value) != 0) && warn) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Feature <%s> of %s did already exist.\n", feature, Getattr(n, "name")); } Delete(attr); } String *Getfeature(Node *n, const char *feature) { //printf("retrieve feature <%s> with value <%s>\n", feature, Char(value)); String *attr = NewStringf("feature:%s", feature); String *result = Getattr(n, attr); Delete(attr); return result; } bool convertInt(long in, long &out, const String *mode) { if ((mode == NIL) || (Strcmp(mode, "int:int") == 0) || (Strcmp(mode, "set:set") == 0)) { out = in; return true; } else if (Strcmp(mode, "set:int") == 0) { return log2(in, out); } else if (Strcmp(mode, "int:set") == 0) { out = 1L << in; return unsigned (in) < (sizeof(out) * 8); } else { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Unknown integer conversion method <%s>.\n", mode); return false; } } void collectEnumerations(Hash *enums, Node *n) { Node *child = firstChild(n); while (child != NIL) { String *name = Getattr(child, "name"); const bool isConstant = Strcmp(nodeType(child), "constant") == 0; const bool isEnumItem = Strcmp(nodeType(child), "enumitem") == 0; if (isConstant || isEnumItem) { //printf("%s%s name %s\n", isConstant?"constant":"", isEnumItem?"enumitem":"", Char(name)); { String *m3name = Getfeature(child, "modula3:enumitem:name"); String *m3enum = Getfeature(child, "modula3:enumitem:enum"); String *conv = Getfeature(child, "modula3:enumitem:conv"); if (m3enum != NIL) { //printf("m3enum %s\n", Char(m3enum)); if (m3name == NIL) { m3name = name; } long max = -1; Hash *items; Hash *enumnode = Getattr(enums, m3enum); if (enumnode == NIL) { enumnode = NewHash(); items = NewHash(); Setattr(enumnode, "items", items); Setattr(enums, m3enum, enumnode); } else { String *maxstr = Getattr(enumnode, "max"); if (maxstr != NIL) { max = aToL(maxstr); } items = Getattr(enumnode, "items"); } long numvalue; String *value = Getattr(child, "value"); //printf("value: %s\n", Char(value)); if ((value == NIL) || (!strToL(value, numvalue))) { value = Getattr(child, "enumvalue"); if ((value == NIL) || (!evalExpr(value, numvalue))) { numvalue = getConstNumeric(child); } //printf("constnumeric: %s\n", Char(value)); } Setattr(constant_values, name, NewStringf("%d", numvalue)); if (convertInt(numvalue, numvalue, conv)) { String *newvalue = NewStringf("%d", numvalue); String *oldname = Getattr(items, newvalue); if (oldname != NIL) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "The value <%s> is already assigned to <%s>.\n", value, oldname); } //printf("items %p, set %s = %s\n", items, Char(newvalue), Char(m3name)); Setattr(items, newvalue, m3name); if (max < numvalue) { max = numvalue; } Setattr(enumnode, "max", NewStringf("%d", max)); } } } } collectEnumerations(enums, child); child = nextSibling(child); } } enum const_pragma_type { cpt_none, cpt_constint, cpt_constset, cpt_enumitem }; struct const_id_pattern { String *prefix, *parentEnum; }; void tagConstants(Node *first, String *parentEnum, const const_id_pattern & pat, const String *pragma, List *convdesc) { Node *n = first; while (n != NIL) { String *name = getQualifiedName(n); bool isConstant = Strcmp(nodeType(n), "constant") == 0; bool isEnumItem = Strcmp(nodeType(n), "enumitem") == 0; if ((isConstant || isEnumItem) && ((pat.prefix == NIL) || (hasPrefix(name, pat.prefix))) && ((pat.parentEnum == NIL) || ((parentEnum != NIL) && (Strcmp (pat.parentEnum, parentEnum) == 0)))) { //printf("tag %s\n", Char(name)); String *srctype = Getitem(convdesc, 1); String *relationstr = Getitem(convdesc, 3); List *relationdesc = Split(relationstr, ',', 2); // transform name from C to Modula3 style String *srcstyle = NIL; String *newprefix = NIL; { //printf("name conversion <%s>\n", Char(Getitem(convdesc,2))); List *namedesc = Split(Getitem(convdesc, 2), ',', INT_MAX); Iterator nameit = First(namedesc); for (; nameit.item != NIL; nameit = Next(nameit)) { List *nameassign = Split(nameit.item, '=', 2); String *tag = Getitem(nameassign, 0); String *data = Getitem(nameassign, 1); //printf("name conv <%s> = <%s>\n", Char(tag), Char(data)); if (Strcmp(tag, "srcstyle") == 0) { srcstyle = Copy(data); } else if (Strcmp(tag, "prefix") == 0) { newprefix = Copy(data); } else { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Unknown name conversion tag <%s> with value <%s>.\n", tag, data); } Delete(nameassign); } Delete(namedesc); } const char *stem = Char(name); if (pat.prefix != NIL) { //printf("pat.prefix %s for %s\n", Char(pat.prefix), Char(name)); stem += Len(pat.prefix); } String *newname; if (srcstyle && Strcmp(srcstyle, "underscore") == 0) { if (newprefix != NIL) { String *newstem = nameToModula3(stem, true); newname = NewStringf("%s%s", newprefix, newstem); Delete(newstem); } else { newname = nameToModula3(stem, true); } } else { if (srcstyle != NIL) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Unknown C identifier style <%s>.\n", srcstyle); } newname = Copy(name); } if (Strcmp(pragma, "enumitem") == 0) { if (Len(relationdesc) != 1) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Expected , got <%s>.\n", relationstr); } Setfeature(n, "modula3:enumitem:name", newname, true); Setfeature(n, "modula3:enumitem:enum", relationstr, true); Setfeature(n, "modula3:enumitem:conv", NewStringf("%s:int", srctype), true); } else if (Strcmp(pragma, "constint") == 0) { if (Len(relationdesc) != 1) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Expected , got <%s>.\n", relationstr); } Setfeature(n, "modula3:constint:name", newname, true); Setfeature(n, "modula3:constint:type", Getitem(relationdesc, 0), true); Setfeature(n, "modula3:constint:conv", NewStringf("%s:int", srctype), true); } else if (Strcmp(pragma, "constset") == 0) { if (Len(relationdesc) != 2) { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Expected , got <%s>.\n", relationstr); } String *settype = Getitem(relationdesc, 0); Setfeature(n, "modula3:constset:name", newname, true); //Setfeature(n,"modula3:constset:type",settype,true); Setfeature(n, "modula3:constset:set", settype, true); Setfeature(n, "modula3:constset:base", Getitem(relationdesc, 1), true); Setfeature(n, "modula3:constset:conv", NewStringf("%s:set", srctype), true); } Delete(newname); Delete(relationdesc); } if (Strcmp(nodeType(n), "enum") == 0) { //printf("explore enum %s, qualification %s\n", Char(name), Char(Swig_symbol_qualified(n))); tagConstants(firstChild(n), name, pat, pragma, convdesc); } else { tagConstants(firstChild(n), NIL, pat, pragma, convdesc); } n = nextSibling(n); } } void scanForConstPragmas(Node *n) { Node *child = firstChild(n); while (child != NIL) { const String *type = nodeType(child); if (Strcmp(type, "pragma") == 0) { const String *lang = Getattr(child, "lang"); const String *code = Getattr(child, "name"); String *value = Getattr(child, "value"); if (Strcmp(lang, "modula3") == 0) { const_pragma_type cpt = cpt_none; if (Strcmp(code, "constint") == 0) { cpt = cpt_constint; } else if (Strcmp(code, "constset") == 0) { cpt = cpt_constset; } else if (Strcmp(code, "enumitem") == 0) { cpt = cpt_enumitem; } if (cpt != cpt_none) { const_id_pattern pat = { NIL, NIL }; List *convdesc = Split(value, ';', 4); List *patterndesc = Split(Getitem(convdesc, 0), ',', INT_MAX); Iterator patternit; for (patternit = First(patterndesc); patternit.item != NIL; patternit = Next(patternit)) { List *patternassign = Split(patternit.item, '=', 2); String *tag = Getitem(patternassign, 0); String *data = Getitem(patternassign, 1); if (Strcmp(tag, "prefix") == 0) { pat.prefix = Copy(data); } else if (Strcmp(tag, "enum") == 0) { pat.parentEnum = Copy(data); } else { Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "Unknown identification tag <%s> with value <%s>.\n", tag, data); } Delete(patternassign); } tagConstants(child, NIL, pat, code, convdesc); Delete(patterndesc); } } } scanForConstPragmas(child); child = nextSibling(child); } } /* ----------------------------------------------------------------------------- * emitProxyClassDefAndCPPCasts() * ----------------------------------------------------------------------------- */ void emitProxyClassDefAndCPPCasts(Node *n) { String *c_classname = SwigType_namestr(Getattr(n, "name")); String *c_baseclass = NULL; String *baseclass = NULL; String *c_baseclassname = NULL; String *name = Getattr(n, "name"); /* Deal with inheritance */ List *baselist = Getattr(n, "bases"); if (baselist != NIL) { Iterator base = First(baselist); if (base.item) { c_baseclassname = Getattr(base.item, "name"); baseclass = Copy(getProxyName(c_baseclassname)); if (baseclass) { c_baseclass = SwigType_namestr(Getattr(base.item, "name")); } base = Next(base); if (base.item != NIL) { Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, Getattr(base.item, "name")); } } } bool derived = baseclass && getProxyName(c_baseclassname); if (!baseclass) baseclass = NewString(""); // Inheritance from pure Modula 3 classes const String *pure_baseclass = typemapLookup(n, "m3base", name, WARN_NONE); if (hasContent(pure_baseclass) && hasContent(baseclass)) { Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, pure_baseclass); } // Pure Modula 3 interfaces const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces", name, WARN_NONE); // Start writing the proxy class Printv(proxy_class_def, typemapLookup(n, "m3imports", name, WARN_NONE), // Import statements "\n", typemapLookup(n, "m3classmodifiers", name, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " class $m3classname", // Class name and bases (derived || *Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", baseclass, pure_baseclass, ((derived || *Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces ", " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", // Member variables for memory handling derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", name, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers " $m3classname(IntPtr cPtr, bool cMemoryOwn) ", // Constructor used for wrapping pointers derived ? ": base($imclassname.$m3classnameTo$baseclass(cPtr), cMemoryOwn) {\n" : "{\n swigCMemOwn = cMemoryOwn;\n", " swigCPtr = cPtr;\n", " }\n", NIL); if (!have_default_constructor_flag) { // All proxy classes need a constructor Printv(proxy_class_def, "\n", " protected $m3classname() : this(IntPtr.Zero, false) {\n", " }\n", NIL); } // C++ destructor is wrapped by the Dispose method // Note that the method name is specified in a typemap attribute called methodname String *destruct = NewString(""); const String *tm = NULL; Node *attributes = NewHash(); String *destruct_methodname = NULL; if (derived) { tm = typemapLookup(n, "m3destruct_derived", name, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:m3destruct_derived:methodname"); } else { tm = typemapLookup(n, "m3destruct", name, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname"); } if (!destruct_methodname) { Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); } // Emit the Finalize and Dispose methods if (tm) { // Finalize method if (*Char(destructor_call)) { Printv(proxy_class_def, typemapLookup(n, "m3finalize", name, WARN_NONE), NIL); } // Dispose method Printv(destruct, tm, NIL); if (*Char(destructor_call)) Replaceall(destruct, "$imcall", destructor_call); else Replaceall(destruct, "$imcall", "throw new MethodAccessException(\"C++ destructor does not have public access\")"); if (*Char(destruct)) Printv(proxy_class_def, "\n public ", derived ? "override" : "virtual", " void ", destruct_methodname, "() ", destruct, "\n", NIL); } Delete(attributes); Delete(destruct); // Emit various other methods Printv(proxy_class_def, typemapLookup(n, "m3getcptr", name, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method typemapLookup(n, "m3code", name, WARN_NONE), // extra Modula 3 code "\n", NIL); // Substitute various strings into the above template Replaceall(proxy_class_def, "$m3classname", proxy_class_name); Replaceall(proxy_class_code, "$m3classname", proxy_class_name); Replaceall(proxy_class_def, "$baseclass", baseclass); Replaceall(proxy_class_code, "$baseclass", baseclass); Replaceall(proxy_class_def, "$imclassname", m3raw_name); Replaceall(proxy_class_code, "$imclassname", m3raw_name); // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { Printv(m3raw_cppcasts_code, "\n [DllImport(\"", m3wrap_name, "\", EntryPoint=\"Modula3_", proxy_class_name, "To", baseclass, "\")]\n", NIL); Printv(m3raw_cppcasts_code, " public static extern IntPtr ", "$m3classnameTo$baseclass(IntPtr objectRef);\n", NIL); Replaceall(m3raw_cppcasts_code, "$m3classname", proxy_class_name); Replaceall(m3raw_cppcasts_code, "$baseclass", baseclass); Printv(upcasts_code, "SWIGEXPORT long Modula3_$imclazznameTo$imbaseclass", "(long objectRef) {\n", " long baseptr = 0;\n" " *($cbaseclass **)&baseptr = *($cclass **)&objectRef;\n" " return baseptr;\n" "}\n", "\n", NIL); Replaceall(upcasts_code, "$imbaseclass", baseclass); Replaceall(upcasts_code, "$cbaseclass", c_baseclass); Replaceall(upcasts_code, "$imclazzname", proxy_class_name); Replaceall(upcasts_code, "$cclass", c_classname); } Delete(baseclass); } /* ---------------------------------------------------------------------- * getAttrString() * * If necessary create and return the string * associated with a certain attribute of 'n'. * ---------------------------------------------------------------------- */ String *getAttrString(Node *n, const char *attr) { String *str = Getattr(n, attr); if (str == NIL) { str = NewString(""); Setattr(n, attr, str); } return str; } /* ---------------------------------------------------------------------- * getMethodDeclarations() * * If necessary create and return the handle * where the methods of the current access can be written to. * 'n' must be a member of a struct or a class. * ---------------------------------------------------------------------- */ String *getMethodDeclarations(Node *n) { String *acc_str = Getattr(n, "access"); String *methodattr; if (acc_str == NIL) { methodattr = NewString("modula3:method:public"); } else { methodattr = NewStringf("modula3:method:%s", acc_str); } String *methods = getAttrString(parentNode(n), Char(methodattr)); Delete(methodattr); return methods; } /* ---------------------------------------------------------------------- * classHandler() * ---------------------------------------------------------------------- */ virtual int classHandler(Node *n) { File *f_proxy = NULL; proxy_class_name = Copy(Getattr(n, "sym:name")); //String *rawname = Getattr(n,"name"); if (proxy_flag) { if (!addSymbol(proxy_class_name, n)) return SWIG_ERROR; if (Cmp(proxy_class_name, m3raw_name) == 0) { Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name); SWIG_exit(EXIT_FAILURE); } if (Cmp(proxy_class_name, m3wrap_name) == 0) { Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name); SWIG_exit(EXIT_FAILURE); } String *filen = NewStringf("%s%s.m3", SWIG_output_directory(), proxy_class_name); f_proxy = NewFile(filen, "w", SWIG_output_files()); if (!f_proxy) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Delete(filen); filen = NULL; emitBanner(f_proxy); Clear(proxy_class_def); Clear(proxy_class_code); have_default_constructor_flag = false; destructor_call = NewString(""); } /* This will invoke memberfunctionHandler, membervariableHandler ... and finally it may invoke functionWrapper for wrappers and member variable accessors. It will invoke Language:constructorDeclaration which decides whether to call MODULA3::constructorHandler */ Language::classHandler(n); { String *kind = Getattr(n, "kind"); if (Cmp(kind, "struct") == 0) { String *entries = NewString(""); Node *child; writeArgState state; for (child = firstChild(n); child != NIL; child = nextSibling(child)) { String *childType = nodeType(child); if (Strcmp(childType, "cdecl") == 0) { String *member = Getattr(child, "sym:name"); ParmList *pl = Getattr(child, "parms"); if (pl == NIL) { // Get the variable type in Modula 3 type equivalents String *m3ct = getMappedTypeNew(child, "m3rawtype", ""); writeArg(entries, state, NIL, member, m3ct, NIL); } } } writeArg(entries, state, NIL, NIL, NIL, NIL); m3raw_intf.enterBlock(blocktype); Printf(m3raw_intf.f, "%s =\nRECORD\n%sEND;\n", proxy_class_name, entries); Delete(entries); } else if (Cmp(kind, "class") == 0) { enum access_privilege { acc_public, acc_protected, acc_private }; int max_acc = acc_public; const char *acc_name[3] = { "public", "protected", "private" }; String *methods[3]; int acc; for (acc = acc_public; acc <= acc_private; acc++) { String *methodattr = NewStringf("modula3:method:%s", acc_name[acc]); methods[acc] = Getattr(n, methodattr); Delete(methodattr); max_acc = max_acc > acc ? max_acc : acc; } /* Determine the name of the base class */ String *baseclassname = NewString(""); { List *baselist = Getattr(n, "bases"); if (baselist) { /* Look for the first (principal?) base class - Modula 3 does not support multiple inheritance */ Iterator base = First(baselist); if (base.item) { Append(baseclassname, Getattr(base.item, "sym:name")); base = Next(base); if (base.item) { Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", proxy_class_name, Getattr(base.item, "name")); } } } } /* the private class of the base class and only this need a pointer to the C++ object */ bool need_private = !hasContent(baseclassname); max_acc = need_private ? acc_private : max_acc; /* Declare C++ object as abstract pointer in Modula 3 */ /* The revelation system does not allow us to imitate the whole class hierarchy of the C++ library, but at least we can distinguish between classes of different roots. */ if (hasContent(baseclassname)) { m3raw_intf.enterBlock(blocktype); Printf(m3raw_intf.f, "%s = %s;\n", proxy_class_name, baseclassname); } else { m3raw_intf.enterBlock(blocktype); Printf(m3raw_intf.f, "%s <: ADDRESS;\n", proxy_class_name); m3raw_impl.enterBlock(revelation); Printf(m3raw_impl.f, "%s = UNTRACED BRANDED REF RECORD (*Dummy*) END;\n", proxy_class_name); } String *superclass; m3wrap_intf.enterBlock(blocktype); if (hasContent(methods[acc_public])) { superclass = NewStringf("%sPublic", proxy_class_name); } else if (hasContent(baseclassname)) { superclass = Copy(baseclassname); } else { superclass = NewString("ROOT"); } Printf(m3wrap_intf.f, "%s <: %s;\n", proxy_class_name, superclass); Delete(superclass); { static const char *acc_m3suffix[] = { "Public", "Protected", "Private" }; int acc; for (acc = acc_public; acc <= acc_private; acc++) { bool process_private = (acc == acc_private) && need_private; if (hasContent(methods[acc]) || process_private) { String *subclass = NewStringf("%s%s", proxy_class_name, acc_m3suffix[acc]); /* m3wrap_intf.enterBlock(revelation); Printf(m3wrap_intf.f, "%s <: %s;\n", proxy_class_name, subclass); */ if (acc == max_acc) { m3wrap_intf.enterBlock(revelation); Printf(m3wrap_intf.f, "%s =\n", proxy_class_name); } else { m3wrap_intf.enterBlock(blocktype); Printf(m3wrap_intf.f, "%s =\n", subclass); } Printf(m3wrap_intf.f, "%s BRANDED OBJECT\n", baseclassname); if (process_private) { Setattr(m3wrap_intf.import, m3raw_name, ""); Printf(m3wrap_intf.f, "cxxObj:%s.%s;\n", m3raw_name, proxy_class_name); } if (hasContent(methods[acc])) { Printf(m3wrap_intf.f, "METHODS\n%s", methods[acc]); } if (acc == max_acc) { String *overrides = Getattr(n, "modula3:override"); Printf(m3wrap_intf.f, "OVERRIDES\n%s", overrides); } Printf(m3wrap_intf.f, "END;\n"); Delete(baseclassname); baseclassname = subclass; } } } Delete(methods[acc_public]); Delete(methods[acc_protected]); Delete(methods[acc_private]); } else { Swig_warning(WARN_MODULA3_TYPECONSTRUCTOR_UNKNOWN, input_file, line_number, "Unknown type constructor %s\n", kind); } } if (proxy_flag) { emitProxyClassDefAndCPPCasts(n); Printv(f_proxy, proxy_class_def, proxy_class_code, NIL); Printf(f_proxy, "}\n"); Delete(f_proxy); f_proxy = NULL; Delete(proxy_class_name); proxy_class_name = NULL; Delete(destructor_call); destructor_call = NULL; } return SWIG_OK; } /* ---------------------------------------------------------------------- * memberfunctionHandler() * ---------------------------------------------------------------------- */ virtual int memberfunctionHandler(Node *n) { //printf("begin memberfunctionHandler(%s)\n", Char(Getattr(n,"name"))); Setattr(n, "modula3:functype", "method"); Language::memberfunctionHandler(n); { /* Language::memberfunctionHandler will remove the mapped types that emitM3Wrapper may attach */ ParmList *pl = Getattr(n, "parms"); Swig_typemap_attach_parms("m3wrapinmode", pl, NULL); Swig_typemap_attach_parms("m3wrapinname", pl, NULL); Swig_typemap_attach_parms("m3wrapintype", pl, NULL); Swig_typemap_attach_parms("m3wrapindefault", pl, NULL); attachParameterNames(n, "tmap:m3wrapinname", "autoname", "arg%d"); String *rettype = getMappedTypeNew(n, "m3wrapouttype", ""); String *methodname = Getattr(n, "sym:name"); /* if (methodname==NIL) { methodname = Getattr(n,"name"); } */ String *arguments = createM3Signature(n); String *storage = Getattr(n, "storage"); String *overridden = Getattr(n, "override"); bool isVirtual = (storage != NIL) && (Strcmp(storage, "virtual") == 0); bool isOverridden = (overridden != NIL) && (Strcmp(overridden, "1") == 0); if ((!isVirtual) || (!isOverridden)) { { String *methods = getMethodDeclarations(n); Printf(methods, "%s(%s)%s%s;%s\n", methodname, arguments, hasContent(rettype) ? ": " : "", hasContent(rettype) ? (const String *) rettype : "", isVirtual ? " (* base method *)" : ""); } { /* this was attached by functionWrapper invoked by Language::memberfunctionHandler */ String *fname = Getattr(n, "modula3:funcname"); String *overrides = getAttrString(parentNode(n), "modula3:override"); Printf(overrides, "%s := %s;\n", methodname, fname); } } } if (proxy_flag) { String *overloaded_name = getOverloadedName(n); String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); Delete(overloaded_name); } //printf("end memberfunctionHandler(%s)\n", Char(Getattr(n,"name"))); return SWIG_OK; } /* ---------------------------------------------------------------------- * staticmemberfunctionHandler() * ---------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { static_flag = true; Language::staticmemberfunctionHandler(n); if (proxy_flag) { String *overloaded_name = getOverloadedName(n); String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); Delete(overloaded_name); } static_flag = false; return SWIG_OK; } /* ----------------------------------------------------------------------------- * proxyClassFunctionHandler() * * Function called for creating a Modula 3 wrapper function around a c++ function in the * proxy class. Used for both static and non-static C++ class functions. * C++ class static functions map to Modula 3 static functions. * Two extra attributes in the Node must be available. These are "proxyfuncname" - * the name of the Modula 3 class proxy function, which in turn will call "imfuncname" - * the intermediary (PInvoke) function name in the intermediary class. * ----------------------------------------------------------------------------- */ void proxyClassFunctionHandler(Node *n) { SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); Hash *throws_hash = NewHash(); String *intermediary_function_name = Getattr(n, "imfuncname"); String *proxy_function_name = Getattr(n, "proxyfuncname"); String *tm; Parm *p; int i; String *imcall = NewString(""); String *return_type = NewString(""); String *function_code = NewString(""); bool setter_flag = false; if (!proxy_flag) return; if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { l = nextSibling(l); } } /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); Swig_typemap_attach_parms("m3wraptype", l, NULL); Swig_typemap_attach_parms("m3in", l, NULL); /* Get return types */ if ((tm = getMappedTypeNew(n, "m3wraptype", ""))) { substituteClassname(t, tm); Printf(return_type, "%s", tm); } if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { // Properties setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, variable_name))) == 0); } /* Start generating the proxy function */ Printf(function_code, " %s ", Getattr(n, "feature:modula3:methodmodifiers")); if (static_flag) Printf(function_code, "static "); if (Getattr(n, "override")) Printf(function_code, "override "); else if (checkAttribute(n, "storage", "virtual")) Printf(function_code, "virtual "); Printf(function_code, "%s %s(", return_type, proxy_function_name); Printv(imcall, m3raw_name, ".", intermediary_function_name, "(", NIL); if (!static_flag) Printv(imcall, "swigCPtr", NIL); emit_mark_varargs(l); int gencomma = !static_flag; /* Output each parameter */ for (i = 0, p = l; p; i++) { /* Ignored varargs */ if (checkAttribute(p, "varargs:ignore", "1")) { p = nextSibling(p); continue; } /* Ignored parameters */ if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } /* Ignore the 'this' argument for variable wrappers */ if (!(variable_wrapper_flag && i == 0)) { SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); /* Get the Modula 3 parameter type */ if ((tm = getMappedType(p, "m3wraptype"))) { substituteClassname(pt, tm); Printf(param_type, "%s", tm); } if (gencomma) Printf(imcall, ", "); String *arg = variable_wrapper_flag ? NewString("value") : makeParameterName(n, p, i); // Use typemaps to transform type used in Modula 3 wrapper function (in proxy class) to type used in PInvoke function (in intermediary class) if ((tm = getMappedType(p, "in"))) { addThrows(throws_hash, "in", p); substituteClassname(pt, tm); Replaceall(tm, "$input", arg); Printv(imcall, tm, NIL); } /* Add parameter to proxy function */ if (gencomma >= 2) Printf(function_code, ", "); gencomma = 2; Printf(function_code, "%s %s", param_type, arg); Delete(arg); Delete(param_type); } p = Getattr(p, "tmap:in:next"); } Printf(imcall, ")"); Printf(function_code, ")"); // Transform return type used in PInvoke function (in intermediary class) to type used in Modula 3 wrapper function (in proxy class) if ((tm = getMappedTypeNew(n, "m3out", ""))) { addThrows(throws_hash, "m3out", n); if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); Replaceall(tm, "$imcall", imcall); } generateThrowsClause(throws_hash, function_code); Printf(function_code, " %s\n\n", tm ? (const String *) tm : empty_string); if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { // Properties if (setter_flag) { // Setter method if ((tm = getMappedTypeNew(n, "m3varin", ""))) { if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); Replaceall(tm, "$imcall", imcall); Printf(proxy_class_code, "%s", tm); } } else { // Getter method if ((tm = getMappedTypeNew(n, "m3varout", ""))) { if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); Replaceall(tm, "$imcall", imcall); Printf(proxy_class_code, "%s", tm); } } } else { // Normal function call Printv(proxy_class_code, function_code, NIL); } Delete(function_code); Delete(return_type); Delete(imcall); Delete(throws_hash); } /* ---------------------------------------------------------------------- * constructorHandler() * ---------------------------------------------------------------------- */ virtual int constructorHandler(Node *n) { // this invokes functionWrapper Language::constructorHandler(n); if (proxy_flag) { ParmList *l = Getattr(n, "parms"); Hash *throws_hash = NewHash(); String *overloaded_name = getOverloadedName(n); String *imcall = NewString(""); Printf(proxy_class_code, " %s %s(", Getattr(n, "feature:modula3:methodmodifiers"), proxy_class_name); Printv(imcall, " : this(", m3raw_name, ".", Swig_name_construct(NSPACE_TODO, overloaded_name), "(", NIL); /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); Swig_typemap_attach_parms("m3wraptype", l, NULL); Swig_typemap_attach_parms("m3in", l, NULL); emit_mark_varargs(l); int gencomma = 0; String *tm; Parm *p = l; int i; /* Output each parameter */ for (i = 0; p; i++) { /* Ignored varargs */ if (checkAttribute(p, "varargs:ignore", "1")) { p = nextSibling(p); continue; } /* Ignored parameters */ if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); /* Get the Modula 3 parameter type */ if ((tm = getMappedType(p, "m3wraptype"))) { substituteClassname(pt, tm); Printf(param_type, "%s", tm); } if (gencomma) Printf(imcall, ", "); String *arg = makeParameterName(n, p, i); // Use typemaps to transform type used in Modula 3 wrapper function (in proxy class) to type used in PInvoke function (in intermediary class) if ((tm = getMappedType(p, "in"))) { addThrows(throws_hash, "in", p); substituteClassname(pt, tm); Replaceall(tm, "$input", arg); Printv(imcall, tm, NIL); } /* Add parameter to proxy function */ if (gencomma) Printf(proxy_class_code, ", "); Printf(proxy_class_code, "%s %s", param_type, arg); gencomma = 1; Delete(arg); Delete(param_type); p = Getattr(p, "tmap:in:next"); } Printf(imcall, "), true)"); Printf(proxy_class_code, ")"); Printf(proxy_class_code, "%s", imcall); generateThrowsClause(throws_hash, proxy_class_code); Printf(proxy_class_code, " {\n"); Printf(proxy_class_code, " }\n\n"); if (!gencomma) // We must have a default constructor have_default_constructor_flag = true; Delete(overloaded_name); Delete(imcall); Delete(throws_hash); } return SWIG_OK; } /* ---------------------------------------------------------------------- * destructorHandler() * ---------------------------------------------------------------------- */ virtual int destructorHandler(Node *n) { Language::destructorHandler(n); String *symname = Getattr(n, "sym:name"); if (proxy_flag) { Printv(destructor_call, m3raw_name, ".", Swig_name_destroy(NSPACE_TODO, symname), "(swigCPtr)", NIL); } return SWIG_OK; } /* ---------------------------------------------------------------------- * membervariableHandler() * ---------------------------------------------------------------------- */ virtual int membervariableHandler(Node *n) { //printf("begin membervariableHandler(%s)\n", Char(Getattr(n,"name"))); SwigType *t = Getattr(n, "type"); String *tm; // Get the variable type if ((tm = getMappedTypeNew(n, "m3wraptype", ""))) { substituteClassname(t, tm); } variable_name = Getattr(n, "sym:name"); //printf("member variable: %s\n", Char(variable_name)); // Output the property's field declaration and accessor methods Printf(proxy_class_code, " public %s %s {", tm, variable_name); Setattr(n, "modula3:functype", "accessor"); wrapping_member_flag = true; variable_wrapper_flag = true; Language::membervariableHandler(n); wrapping_member_flag = false; variable_wrapper_flag = false; Printf(proxy_class_code, "\n }\n\n"); { String *methods = getMethodDeclarations(n); String *overrides = getAttrString(parentNode(n), "modula3:override"); SwigType *type = Getattr(n, "type"); String *m3name = capitalizeFirst(variable_name); //String *m3name = nameToModula3(variable_name,true); if (!SwigType_isconst(type)) { { String *inmode = getMappedTypeNew(n, "m3wrapinmode", "", false); String *intype = getMappedTypeNew(n, "m3wrapintype", ""); Printf(methods, "set%s(%s val:%s);\n", m3name, (inmode != NIL) ? (const String *) inmode : "", intype); } { /* this was attached by functionWrapper invoked by Language::memberfunctionHandler */ String *fname = Getattr(n, "modula3:setname"); Printf(overrides, "set%s := %s;\n", m3name, fname); } } { { String *outtype = getMappedTypeNew(n, "m3wrapouttype", ""); Printf(methods, "get%s():%s;\n", m3name, outtype); } { /* this was attached by functionWrapper invoked by Language::memberfunctionHandler */ String *fname = Getattr(n, "modula3:getname"); Printf(overrides, "get%s := %s;\n", m3name, fname); } } Delete(m3name); } //printf("end membervariableHandler(%s)\n", Char(Getattr(n,"name"))); return SWIG_OK; } /* ---------------------------------------------------------------------- * staticmembervariableHandler() * ---------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { bool static_const_member_flag = (Getattr(n, "value") == 0); if (static_const_member_flag) { SwigType *t = Getattr(n, "type"); String *tm; // Get the variable type if ((tm = getMappedTypeNew(n, "m3wraptype", ""))) { substituteClassname(t, tm); } // Output the property's field declaration and accessor methods Printf(proxy_class_code, " public static %s %s {", tm, Getattr(n, "sym:name")); } variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; static_flag = true; Language::staticmembervariableHandler(n); wrapping_member_flag = false; static_flag = false; if (static_const_member_flag) Printf(proxy_class_code, "\n }\n\n"); return SWIG_OK; } /* ---------------------------------------------------------------------- * memberconstantHandler() * ---------------------------------------------------------------------- */ virtual int memberconstantHandler(Node *n) { variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; Language::memberconstantHandler(n); wrapping_member_flag = false; return SWIG_OK; } /* ----------------------------------------------------------------------------- * getOverloadedName() * ----------------------------------------------------------------------------- */ String *getOverloadedName(Node *n) { String *overloaded_name = Copy(Getattr(n, "sym:name")); if (Getattr(n, "sym:overloaded")) { Printv(overloaded_name, Getattr(n, "sym:overname"), NIL); } return overloaded_name; } /* ----------------------------------------------------------------------------- * emitM3Wrapper() * It is also used for set and get methods of global variables. * ----------------------------------------------------------------------------- */ void emitM3Wrapper(Node *n, const String *func_name) { SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); Hash *throws_hash = NewHash(); int num_exceptions = 0; int num_returns = 0; String *rawcall = NewString(""); String *reccall = NewString(""); String *local_variables = NewString(""); String *local_constants = NewString(""); String *incheck = NewString(""); String *outcheck = NewString(""); String *setup = NewString(""); String *cleanup = NewString(""); String *outarg = NewString(""); /* don't mix up with 'autark' :-] */ String *storeout = NewString(""); String *result_name = NewString(""); String *return_variables = NewString(""); const char *result_return = "ret"; String *function_code = NewString(""); /*several names for the same function */ String *raw_name = Getattr(n, "name"); /*original C function name */ //String *func_name = Getattr(n,"sym:name"); /*final Modula3 name chosen by the user*/ bool setter_flag = false; int multiretval = GetFlag(n, "feature:modula3:multiretval"); if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { l = nextSibling(l); } } /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("m3wrapargvar", l, NULL); Swig_typemap_attach_parms("m3wrapargconst", l, NULL); Swig_typemap_attach_parms("m3wrapargraw", l, NULL); Swig_typemap_attach_parms("m3wrapargdir", l, NULL); Swig_typemap_attach_parms("m3wrapinmode", l, NULL); Swig_typemap_attach_parms("m3wrapinname", l, NULL); Swig_typemap_attach_parms("m3wrapintype", l, NULL); Swig_typemap_attach_parms("m3wrapindefault", l, NULL); Swig_typemap_attach_parms("m3wrapinconv", l, NULL); Swig_typemap_attach_parms("m3wrapincheck", l, NULL); Swig_typemap_attach_parms("m3wrapoutname", l, NULL); Swig_typemap_attach_parms("m3wrapouttype", l, NULL); Swig_typemap_attach_parms("m3wrapoutconv", l, NULL); Swig_typemap_attach_parms("m3wrapoutcheck", l, NULL); attachMappedType(n, "m3wrapretraw"); attachMappedType(n, "m3wrapretname"); attachMappedType(n, "m3wraprettype"); attachMappedType(n, "m3wrapretvar"); attachMappedType(n, "m3wrapretconv"); attachMappedType(n, "m3wrapretcheck"); Swig_typemap_attach_parms("m3wrapfreearg", l, NULL); /* Swig_typemap_attach_parms("m3wrapargvar:throws", l, NULL); Swig_typemap_attach_parms("m3wrapargraw:throws", l, NULL); Swig_typemap_attach_parms("m3wrapinconv:throws", l, NULL); Swig_typemap_attach_parms("m3wrapincheck:throws", l, NULL); Swig_typemap_attach_parms("m3wrapoutconv:throws", l, NULL); Swig_typemap_attach_parms("m3wrapoutcheck:throws", l, NULL); attachMappedType(n, "m3wrapretvar:throws"); attachMappedType(n, "m3wrapretconv:throws"); attachMappedType(n, "m3wrapretcheck:throws"); Swig_typemap_attach_parms("m3wrapfreearg:throws", l, NULL); */ /* Attach argument names to the parameter list */ /* should be a separate procedure making use of hashes */ attachParameterNames(n, "tmap:m3wrapinname", "autoname", "arg%d"); /* Get return types */ String *result_m3rawtype = Copy(getMappedTypeNew(n, "m3rawrettype", "")); String *result_m3wraptype = Copy(getMappedTypeNew(n, "m3wraprettype", "")); bool has_return_raw = hasContent(result_m3rawtype); bool has_return_m3 = hasContent(result_m3wraptype); if (has_return_m3) { num_returns++; //printf("%s: %s\n", Char(func_name),Char(result_m3wraptype)); } String *arguments = createM3Signature(n); /* Create local variables or RECORD fields for return values and determine return type that might result from a converted VAR argument. */ { writeArgState state; if (multiretval && has_return_m3) { writeArg(return_variables, state, NIL, NewString(result_return), result_m3wraptype, NIL); } Parm *p = skipIgnored(l, "m3wrapouttype"); while (p != NIL) { String *arg = Getattr(p, "tmap:m3wrapoutname"); if (arg == NIL) { arg = Getattr(p, "name"); } String *tm = Getattr(p, "tmap:m3wrapouttype"); if (tm != NIL) { if (isOutParam(p)) { if (!multiretval) { if (num_returns == 0) { Printv(result_name, arg, NIL); Clear(result_m3wraptype); Printv(result_m3wraptype, tm, NIL); } else { Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN, input_file, line_number, "Typemap m3wrapargdir set to 'out' for %s implies a RETURN value, but the routine %s has already one.\nUse %%multiretval feature.\n", SwigType_str(Getattr(p, "type"), 0), raw_name); } } num_returns++; addImports(m3wrap_intf.import, "m3wrapouttype", p); writeArg(return_variables, state, NIL, arg, tm, NIL); } p = skipIgnored(Getattr(p, "tmap:m3wrapouttype:next"), "m3wrapouttype"); } else { p = nextSibling(p); } } writeArg(return_variables, state, NIL, NIL, NIL, NIL); if (multiretval) { Printv(result_name, Swig_cresult_name(), NIL); Printf(result_m3wraptype, "%sResult", func_name); m3wrap_intf.enterBlock(blocktype); Printf(m3wrap_intf.f, "%s =\nRECORD\n%sEND;\n", result_m3wraptype, return_variables); Printf(local_variables, "%s: %s;\n", result_name, result_m3wraptype); } else { Append(local_variables, return_variables); } } /* Declare local constants e.g. for storing argument names. */ { Parm *p = l; while (p != NIL) { String *arg = Getattr(p, "autoname"); String *tm = Getattr(p, "tmap:m3wrapargconst"); if (tm != NIL) { addImports(m3wrap_impl.import, "m3wrapargconst", p); Replaceall(tm, "$input", arg); Printv(local_constants, tm, "\n", NIL); p = Getattr(p, "tmap:m3wrapargconst:next"); } else { p = nextSibling(p); } } } /* Declare local variables e.g. for converted input values. */ { String *tm = getMappedTypeNew(n, "m3wrapretvar", "", false); if (tm != NIL) { addImports(m3wrap_impl.import, "m3wrapretvar", n); addThrows(throws_hash, "m3wrapretvar", n); Printv(local_variables, tm, "\n", NIL); } Parm *p = l; while (p != NIL) { String *arg = Getattr(p, "autoname"); tm = Getattr(p, "tmap:m3wrapargvar"); if (tm != NIL) { /* exceptions that may be raised but can't be catched, thus we won't count them in num_exceptions */ addImports(m3wrap_impl.import, "m3wrapargvar", p); addThrows(throws_hash, "m3wrapargvar", p); Replaceall(tm, "$input", arg); Printv(local_variables, tm, "\n", NIL); p = Getattr(p, "tmap:m3wrapargvar:next"); } else { p = nextSibling(p); } } } /* Convert input values from Modula 3 to C. */ { Parm *p = l; while (p != NIL) { String *arg = Getattr(p, "autoname"); String *tm = Getattr(p, "tmap:m3wrapinconv"); if (tm != NIL) { addImports(m3wrap_impl.import, "m3wrapinconv", p); num_exceptions += addThrows(throws_hash, "m3wrapinconv", p); Replaceall(tm, "$input", arg); Printv(setup, tm, "\n", NIL); p = Getattr(p, "tmap:m3wrapinconv:next"); } else { p = nextSibling(p); } } } /* Generate checks for input value integrity. */ { Parm *p = l; while (p != NIL) { String *arg = Getattr(p, "autoname"); String *tm = Getattr(p, "tmap:m3wrapincheck"); if (tm != NIL) { addImports(m3wrap_impl.import, "m3wrapincheck", p); num_exceptions += addThrows(throws_hash, "m3wrapincheck", p); Replaceall(tm, "$input", arg); Printv(incheck, tm, "\n", NIL); p = Getattr(p, "tmap:m3wrapincheck:next"); } else { p = nextSibling(p); } } } Printv(rawcall, m3raw_name, ".", func_name, "(", NIL); /* Arguments to the raw C function */ { bool gencomma = false; Parm *p = l; while (p != NIL) { if (gencomma) { Printf(rawcall, ", "); } gencomma = true; addImports(m3wrap_impl.import, "m3wrapargraw", p); num_exceptions += addThrows(throws_hash, "m3wrapargraw", p); String *arg = Getattr(p, "autoname"); String *qualarg = NewString(""); if (!isInParam(p)) { String *tmparg = Getattr(p, "tmap:m3wrapoutname"); if (tmparg != NIL) { arg = tmparg; } if (multiretval /*&& isOutParam(p) - automatically fulfilled */ ) { Printf(qualarg, "%s.", result_name); } } Append(qualarg, arg); Setattr(p, "m3outarg", qualarg); String *tm = Getattr(p, "tmap:m3wrapargraw"); if (tm != NIL) { Replaceall(tm, "$input", arg); Replaceall(tm, "$output", qualarg); Printv(rawcall, tm, NIL); p = Getattr(p, "tmap:m3wrapargraw:next"); } else { //Printv(rawcall, Getattr(p,"lname"), NIL); Printv(rawcall, qualarg, NIL); p = nextSibling(p); } Delete(qualarg); } } Printf(rawcall, ")"); /* Check for error codes and integrity of results */ { String *tm = getMappedTypeNew(n, "m3wrapretcheck", "", false); if (tm != NIL) { addImports(m3wrap_impl.import, "m3wrapretcheck", n); num_exceptions += addThrows(throws_hash, "m3wrapretcheck", n); Printv(outcheck, tm, "\n", NIL); } Parm *p = l; while (p != NIL) { tm = Getattr(p, "tmap:m3wrapoutcheck"); if (tm != NIL) { String *arg = Getattr(p, "autoname"); String *outarg = Getattr(p, "m3outarg"); addImports(m3wrap_impl.import, "m3wrapoutcheck", p); num_exceptions += addThrows(throws_hash, "m3wrapoutcheck", p); //substituteClassname(Getattr(p,"type"), tm); Replaceall(tm, "$input", arg); Replaceall(tm, "$output", outarg); Printv(outcheck, tm, "\n", NIL); p = Getattr(p, "tmap:m3wrapoutcheck:next"); } else { p = nextSibling(p); } } } /* Convert the results to Modula 3 data structures and put them in the record prepared for returning */ { /* m3wrapretconv is processed when it is clear if there is some output conversion and checking code */ Parm *p = l; while (p != NIL) { String *tm = Getattr(p, "tmap:m3wrapoutconv"); if (tm != NIL) { String *arg = Getattr(p, "autoname"); String *outarg = Getattr(p, "m3outarg"); addImports(m3wrap_impl.import, "m3wrapoutconv", n); num_exceptions += addThrows(throws_hash, "m3wrapoutconv", p); //substituteClassname(Getattr(p,"type"), tm); Replaceall(tm, "$input", arg); Replaceall(tm, "$output", outarg); Printf(storeout, "%s := %s;\n", outarg, tm); p = Getattr(p, "tmap:m3wrapoutconv:next"); } else { p = nextSibling(p); } } } /* Generate cleanup code */ { Parm *p = l; while (p != NIL) { String *tm = Getattr(p, "tmap:m3wrapfreearg"); if (tm != NIL) { String *arg = Getattr(p, "autoname"); String *outarg = Getattr(p, "m3outarg"); addImports(m3wrap_impl.import, "m3wrapfreearg", p); num_exceptions += addThrows(throws_hash, "m3wrapfreearg", p); //substituteClassname(Getattr(p,"type"), tm); Replaceall(tm, "$input", arg); Replaceall(tm, "$output", outarg); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:m3wrapfreearg:next"); } else { p = nextSibling(p); } } } { /* Currently I don't know how a typemap similar to the original 'out' typemap could help returning the return value. */ /* Receive result from call to raw library function */ if (!has_return_raw) { /* rawcall(arg1); result.val := arg1; RETURN result; */ /* rawcall(arg1); RETURN arg1; */ Printf(reccall, "%s;\n", rawcall); if (hasContent(result_name)) { Printf(outarg, "RETURN %s;\n", result_name); } } else { /* arg0 := rawcall(arg1); result.ret := Convert(arg0); result.val := arg1; RETURN result; */ /* arg0 := rawcall(); RETURN Convert(arg0); */ /* RETURN rawcall(); */ String *return_raw = getMappedTypeNew(n, "m3wrapretraw", "", false); String *return_conv = getMappedTypeNew(n, "m3wrapretconv", "", false); /* immediate RETURN would skip result checking */ if ((hasContent(outcheck) || hasContent(storeout) || hasContent(cleanup)) && (!hasContent(result_name)) && (return_raw == NIL)) { Printv(result_name, Swig_cresult_name(), NIL); Printf(local_variables, "%s: %s;\n", result_name, result_m3wraptype); } String *result_lvalue = Copy(result_name); if (multiretval) { Printf(result_lvalue, ".%s", result_return); } if (return_raw != NIL) { Printf(reccall, "%s := %s;\n", return_raw, rawcall); } else if (hasContent(result_name)) { Printf(reccall, "%s := %s;\n", result_lvalue, rawcall); } else { Printf(outarg, "RETURN %s;\n", rawcall); } if (return_conv != NIL) { addImports(m3wrap_impl.import, "m3wrapretconv", n); num_exceptions += addThrows(throws_hash, "m3wrapretconv", n); if (hasContent(result_name)) { Printf(reccall, "%s := %s;\n", result_lvalue, return_conv); Printf(outarg, "RETURN %s;\n", result_name); } else { Printf(outarg, "RETURN %s;\n", return_conv); } } else { if (hasContent(result_name)) { Printf(outarg, "RETURN %s;\n", result_name); } } } } /* Create procedure header */ { String *header = NewStringf("PROCEDURE %s (%s)", func_name, arguments); if ((num_returns > 0) || multiretval) { Printf(header, ": %s", result_m3wraptype); } generateThrowsClause(throws_hash, header); Append(function_code, header); m3wrap_intf.enterBlock(no_block); Printf(m3wrap_intf.f, "%s;\n\n", header); } { String *body = NewStringf("%s%s%s%s%s", incheck, setup, reccall, outcheck, storeout); String *exc_handler; if (hasContent(cleanup) && (num_exceptions > 0)) { exc_handler = NewStringf("TRY\n%sFINALLY\n%sEND;\n", body, cleanup); } else { exc_handler = NewStringf("%s%s", body, cleanup); } Printf(function_code, " =\n%s%s%s%sBEGIN\n%s%sEND %s;\n\n", hasContent(local_constants) ? "CONST\n" : "", local_constants, hasContent(local_variables) ? "VAR\n" : "", local_variables, exc_handler, outarg, func_name); Delete(exc_handler); Delete(body); } m3wrap_impl.enterBlock(no_block); if (proxy_flag && global_variable_flag) { setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, variable_name)) == 0); // Properties if (setter_flag) { // Setter method String *tm = getMappedTypeNew(n, "m3varin", ""); if (tm != NIL) { if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "true"); } else { Replaceall(tm, "$owner", "false"); } substituteClassname(t, tm); Replaceall(tm, "$rawcall", rawcall); Replaceall(tm, "$vartype", variable_type); /* $type is already replaced by some super class */ Replaceall(tm, "$var", variable_name); Printf(m3wrap_impl.f, "%s", tm); } } else { // Getter method String *tm = getMappedTypeNew(n, "m3varout", ""); if (tm != NIL) { if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); Replaceall(tm, "$rawcall", rawcall); Replaceall(tm, "$vartype", variable_type); Replaceall(tm, "$var", variable_name); Printf(m3wrap_impl.f, "%s", tm); } } } else { // Normal function call Printv(m3wrap_impl.f, function_code, NIL); } Delete(arguments); Delete(return_variables); Delete(local_variables); Delete(local_constants); Delete(outarg); Delete(incheck); Delete(outcheck); Delete(setup); Delete(cleanup); Delete(storeout); Delete(function_code); Delete(result_name); Delete(result_m3wraptype); Delete(reccall); Delete(rawcall); Delete(throws_hash); } /*---------------------------------------------------------------------- * replaceSpecialVariables() *--------------------------------------------------------------------*/ virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) { (void)method; SwigType *type = Getattr(parm, "type"); substituteClassname(type, tm); } /* ----------------------------------------------------------------------------- * substituteClassname() * * Substitute the special variable $m3classname with the proxy class name for classes/structs/unions * that SWIG knows about. * Otherwise use the $descriptor name for the Modula 3 class name. Note that the $&m3classname substitution * is the same as a $&descriptor substitution, ie one pointer added to descriptor name. * Inputs: * pt - parameter type * tm - typemap contents that might contain the special variable to be replaced * Outputs: * tm - typemap contents complete with the special variable substitution * Return: * substitution_performed - flag indicating if a substitution was performed * ----------------------------------------------------------------------------- */ bool substituteClassname(SwigType *pt, String *tm) { bool substitution_performed = false; if (Strstr(tm, "$m3classname") || Strstr(tm, "$&m3classname")) { String *classname = getProxyName(pt); if (classname) { Replaceall(tm, "$&m3classname", classname); // getProxyName() works for pointers to classes too Replaceall(tm, "$m3classname", classname); } else { // use $descriptor if SWIG does not know anything about this type. Note that any typedefs are resolved. String *descriptor = NULL; SwigType *type = Copy(SwigType_typedef_resolve_all(pt)); if (Strstr(tm, "$&m3classname")) { SwigType_add_pointer(type); descriptor = NewStringf("SWIGTYPE%s", SwigType_manglestr(type)); Replaceall(tm, "$&m3classname", descriptor); } else { // $m3classname descriptor = NewStringf("SWIGTYPE%s", SwigType_manglestr(type)); Replaceall(tm, "$m3classname", descriptor); } // Add to hash table so that the type wrapper classes can be created later Setattr(swig_types_hash, descriptor, type); Delete(descriptor); Delete(type); } substitution_performed = true; } return substitution_performed; } /* ----------------------------------------------------------------------------- * makeParameterName() * * Inputs: * n - Node * p - parameter node * arg_num - parameter argument number * Return: * arg - a unique parameter name * ----------------------------------------------------------------------------- */ String *makeParameterName(Node *n, Parm *p, int arg_num) { // Use C parameter name unless it is a duplicate or an empty parameter name String *pn = Getattr(p, "name"); int count = 0; ParmList *plist = Getattr(n, "parms"); while (plist) { if ((Cmp(pn, Getattr(plist, "name")) == 0)) count++; plist = nextSibling(plist); } String *arg = (!pn || (count > 1)) ? NewStringf("arg%d", arg_num) : Copy(Getattr(p, "name")); return arg; } /* ----------------------------------------------------------------------------- * attachParameterNames() * * Inputs: * n - Node of a function declaration * tmid - attribute name for overriding C argument names, * e.g. "tmap:m3wrapinname", * don't forget to attach the mapped types before * nameid - attribute for attaching the names, * e.g. "modula3:inname" * fmt - format for the argument name containing %d * e.g. "arg%d" * ----------------------------------------------------------------------------- */ void attachParameterNames(Node *n, const char *tmid, const char *nameid, const char *fmt) { /* Use C parameter name if present and unique, otherwise create an 'arg%d' name */ Hash *hash = NewHash(); Parm *p = Getattr(n, "parms"); int count = 0; while (p != NIL) { String *name = Getattr(p, tmid); if (name == NIL) { name = Getattr(p, "name"); } String *newname; if ((!hasContent(name)) || (Getattr(hash, name) != NIL)) { newname = NewStringf(fmt, count); } else { newname = Copy(name); } if (1 == Setattr(hash, newname, "1")) { Swig_warning(WARN_MODULA3_DOUBLE_ID, input_file, line_number, "Argument '%s' twice.\n", newname); } Setattr(p, nameid, newname); // Delete(newname); p = nextSibling(p); count++; } Delete(hash); } /* ----------------------------------------------------------------------------- * createM3Signature() * * Create signature of M3 wrapper procedure * Call attachParameterNames and attach mapped types before! * m3wrapintype, m3wrapinmode, m3wrapindefault * ----------------------------------------------------------------------------- */ String *createM3Signature(Node *n) { String *arguments = NewString(""); Parm *p = skipIgnored(Getattr(n, "parms"), "m3wrapintype"); writeArgState state; while (p != NIL) { /* Get the M3 parameter type */ String *tm = getMappedType(p, "m3wrapintype"); if (tm != NIL) { if (isInParam(p)) { addImports(m3wrap_intf.import, "m3wrapintype", p); addImports(m3wrap_impl.import, "m3wrapintype", p); String *mode = Getattr(p, "tmap:m3wrapinmode"); String *deflt = Getattr(p, "tmap:m3wrapindefault"); String *arg = Getattr(p, "autoname"); SwigType *pt = Getattr(p, "type"); substituteClassname(pt, tm); /* do we need this ? */ writeArg(arguments, state, mode, arg, tm, deflt); } p = skipIgnored(Getattr(p, "tmap:m3wrapintype:next"), "m3wrapintype"); } else { p = nextSibling(p); } } writeArg(arguments, state, NIL, NIL, NIL, NIL); return (arguments); } /* not used any longer - try SwigType_str if required again */ #if 0 /* ----------------------------------------------------------------------------- * createCSignature() * * Create signature of C function * ----------------------------------------------------------------------------- */ String *createCSignature(Node *n) { String *arguments = NewString(""); bool gencomma = false; Node *p; for (p = Getattr(n, "parms"); p != NIL; p = nextSibling(p)) { if (gencomma) { Append(arguments, ","); } gencomma = true; String *type = Getattr(p, "type"); String *ctype = getMappedTypeNew(type, "ctype"); Append(arguments, ctype); } return arguments; } #endif /* ----------------------------------------------------------------------------- * emitTypeWrapperClass() * ----------------------------------------------------------------------------- */ void emitTypeWrapperClass(String *classname, SwigType *type) { Node *n = NewHash(); Setfile(n, input_file); Setline(n, line_number); String *filen = NewStringf("%s%s.m3", SWIG_output_directory(), classname); File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); if (!f_swigtype) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } String *swigtype = NewString(""); // Emit banner name emitBanner(f_swigtype); // Pure Modula 3 baseclass and interfaces const String *pure_baseclass = typemapLookup(n, "m3base", type, WARN_NONE); const String *pure_interfaces = typemapLookup(n, "m3interfaces", type, WARN_NONE); // Emit the class Printv(swigtype, typemapLookup(n, "m3imports", type, WARN_NONE), // Import statements "\n", typemapLookup(n, "m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " class $m3classname", // Class name and bases *Char(pure_baseclass) ? " : " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces " : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers " $m3classname(IntPtr cPtr, bool bFutureUse) {\n", // Constructor used for wrapping pointers " swigCPtr = cPtr;\n", " }\n", "\n", " protected $m3classname() {\n", // Default constructor " swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup(n, "m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method typemapLookup(n, "m3code", type, WARN_NONE), // extra Modula 3 code "}\n", "\n", NIL); Replaceall(swigtype, "$m3classname", classname); Printv(f_swigtype, swigtype, NIL); Delete(f_swigtype); Delete(filen); Delete(swigtype); } /* ----------------------------------------------------------------------------- * typemapLookup() * n - for input only and must contain info for Getfile(n) and Getline(n) to work * tmap_method - typemap method name * type - typemap type to lookup * warning - warning number to issue if no typemaps found * typemap_attributes - the typemap attributes are attached to this node and will * also be used for temporary storage if non null * return is never NULL, unlike Swig_typemap_lookup() * ----------------------------------------------------------------------------- */ const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) { Node *node = !typemap_attributes ? NewHash() : typemap_attributes; Setattr(node, "type", type); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0); if (!tm) { tm = empty_string; if (warning != WARN_NONE) Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0)); } if (!typemap_attributes) Delete(node); return tm; } /* ----------------------------------------------------------------------------- * addThrows() * * Add all exceptions to a hash that are associated with the 'typemap'. * Return number the number of these exceptions. * ----------------------------------------------------------------------------- */ int addThrows(Hash *throws_hash, const String *typemap, Node *parameter) { // Get the comma separated throws clause - held in "throws" attribute in the typemap passed in int len = 0; String *throws_attribute = NewStringf("%s:throws", typemap); addImports(m3wrap_intf.import, throws_attribute, parameter); addImports(m3wrap_impl.import, throws_attribute, parameter); String *throws = getMappedTypeNew(parameter, Char(throws_attribute), "", false); //printf("got exceptions %s for %s\n", Char(throws), Char(throws_attribute)); if (throws) { // Put the exception classes in the throws clause into a temporary List List *temp_classes_list = Split(throws, ',', INT_MAX); len = Len(temp_classes_list); // Add the exception classes to the node throws list, but don't duplicate if already in list if (temp_classes_list /*&& hasContent(temp_classes_list) */ ) { for (Iterator cls = First(temp_classes_list); cls.item != NIL; cls = Next(cls)) { String *exception_class = NewString(cls.item); Replaceall(exception_class, " ", ""); // remove spaces Replaceall(exception_class, "\t", ""); // remove tabs if (hasContent(exception_class)) { // $m3classname substitution SwigType *pt = Getattr(parameter, "type"); substituteClassname(pt, exception_class); // Don't duplicate the exception class in the throws clause //printf("add exception %s\n", Char(exception_class)); Setattr(throws_hash, exception_class, "1"); } Delete(exception_class); } } Delete(temp_classes_list); } Delete(throws_attribute); return len; } /* ----------------------------------------------------------------------------- * generateThrowsClause() * ----------------------------------------------------------------------------- */ void generateThrowsClause(Hash *throws_hash, String *code) { // Add the throws clause into code if (Len(throws_hash) > 0) { Iterator cls = First(throws_hash); Printf(code, " RAISES {%s", cls.key); for (cls = Next(cls); cls.key != NIL; cls = Next(cls)) { Printf(code, ", %s", cls.key); } Printf(code, "}"); } } /* ----------------------------------------------------------------------------- * addImports() * * Add all imports that are needed for contents of 'typemap'. * ----------------------------------------------------------------------------- */ void addImports(Hash *imports_hash, const String *typemap, Node *node) { // Get the comma separated throws clause - held in "throws" attribute in the typemap passed in String *imports_attribute = NewStringf("%s:import", typemap); String *imports = getMappedTypeNew(node, Char(imports_attribute), "", false); //printf("got imports %s for %s\n", Char(imports), Char(imports_attribute)); if (imports != NIL) { List *import_list = Split(imports, ',', INT_MAX); // Add the exception classes to the node imports list, but don't duplicate if already in list if (import_list != NIL) { for (Iterator imp = First(import_list); imp.item != NIL; imp = Next(imp)) { List *import_pair = Split(imp.item, ' ', 3); if (Len(import_pair) == 1) { Setattr(imports_hash, Getitem(import_pair, 0), ""); } else if ((Len(import_pair) == 3) && Strcmp(Getitem(import_pair, 1), "AS") == 0) { Setattr(imports_hash, Getitem(import_pair, 0), Getitem(import_pair, 2)); } else { Swig_warning(WARN_MODULA3_BAD_IMPORT, input_file, line_number, "Malformed import '%s' for typemap '%s' defined for type '%s'\n", imp, typemap, SwigType_str(Getattr(node, "type"), 0)); } Delete(import_pair); } } Delete(import_list); } Delete(imports_attribute); } /* ----------------------------------------------------------------------------- * emitImportStatements() * ----------------------------------------------------------------------------- */ void emitImportStatements(Hash *imports_hash, String *code) { // Add the imports statements into code Iterator imp = First(imports_hash); while (imp.key != NIL) { Printf(code, "IMPORT %s", imp.key); String *imp_as = imp.item; if (hasContent(imp_as)) { Printf(code, " AS %s", imp_as); } Printf(code, ";\n"); imp = Next(imp); } } }; /* class MODULA3 */ /* ----------------------------------------------------------------------------- * swig_modula3() - Instantiate module * ----------------------------------------------------------------------------- */ extern "C" Language *swig_modula3(void) { return new MODULA3(); } /* ----------------------------------------------------------------------------- * Static member variables * ----------------------------------------------------------------------------- */ const char *MODULA3::usage = "\ Modula 3 Options (available with -modula3)\n\ -generateconst - Generate code for computing numeric values of constants\n\ -generaterename - Generate suggestions for %rename\n\ -generatetypemap - Generate templates for some basic typemaps\n\ -oldvarnames - Old intermediary method names for variable wrappers\n\ \n"; /* -generateconst - stem of the .c source file for computing the numeric values of constants\n\ -generaterename - stem of the .i source file containing %rename suggestions\n\ -generatetypemap - stem of the .i source file containing typemap patterns\n\ */ swig-3.0.2/Source/Modules/tcl8.cxx0000664000175000017500000012075112343605122016617 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * tcl8.cxx * * Tcl8 language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" static int treduce = SWIG_cparse_template_reduce(0); static const char *usage = "\ Tcl 8 Options (available with -tcl)\n\ -itcl - Enable ITcl support\n\ -nosafe - Leave out SafeInit module function.\n\ -prefix - Set a prefix to be prepended to all names\n\ -namespace - Build module into a Tcl 8 namespace\n\ -pkgversion - Set package version\n\n"; static String *cmd_tab = 0; /* Table of command names */ static String *var_tab = 0; /* Table of global variables */ static String *const_tab = 0; /* Constant table */ static String *methods_tab = 0; /* Methods table */ static String *attr_tab = 0; /* Attribute table */ static String *prefix = 0; static String *module = 0; static int namespace_option = 0; static String *init_name = 0; static String *ns_name = 0; static int have_constructor; static String *constructor_name; static int have_destructor; static int have_base_classes; static String *destructor_action = 0; static String *version = (String *) "0.0"; static String *class_name = 0; static int have_attributes; static int have_methods; static int nosafe = 0; static File *f_header = 0; static File *f_wrappers = 0; static File *f_init = 0; static File *f_begin = 0; static File *f_runtime = 0; // Itcl support static int itcl = 0; static File *f_shadow = 0; static File *f_shadow_stubs = 0; static String *constructor = 0; static String *destructor = 0; static String *base_classes = 0; static String *base_class_init = 0; static String *methods = 0; static String *imethods = 0; static String *attributes = 0; static String *attribute_traces = 0; static String *iattribute_traces = 0; class TCL8:public Language { public: /* ------------------------------------------------------------ * TCL8::main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { int cppcast = 1; SWIG_library_directory("tcl"); for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-prefix") == 0) { if (argv[i + 1]) { prefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else Swig_arg_error(); } else if (strcmp(argv[i], "-pkgversion") == 0) { if (argv[i + 1]) { version = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } } else if (strcmp(argv[i], "-namespace") == 0) { namespace_option = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-itcl") == 0) { itcl = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nosafe") == 0) { nosafe = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-cppcast") == 0) { cppcast = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nocppcast") == 0) { cppcast = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); } } } if (cppcast) { Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); } Preprocessor_define("SWIGTCL 1", 0); // SWIGTCL8 is deprecated, and no longer documented. Preprocessor_define("SWIGTCL8 1", 0); SWIG_typemap_lang("tcl8"); SWIG_config_file("tcl8.swg"); allow_overloading(); } /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ virtual int top(Node *n) { /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); /* Initialize some variables for the object interface */ cmd_tab = NewString(""); var_tab = NewString(""); methods_tab = NewString(""); const_tab = NewString(""); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGTCL\n"); Printf(f_runtime, "\n"); /* Set the module name, namespace, and prefix */ module = NewStringf("%(lower)s", Getattr(n, "name")); init_name = NewStringf("%(title)s_Init", module); ns_name = prefix ? Copy(prefix) : Copy(module); if (prefix) Append(prefix, "_"); /* If shadow classing is enabled, we're going to change the module name to "_module" */ if (itcl) { String *filen; filen = NewStringf("%s%s.itcl", SWIG_output_directory(), module); Insert(module, 0, "_"); if ((f_shadow = NewFile(filen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } f_shadow_stubs = NewString(""); Swig_register_filebyname("shadow", f_shadow); Swig_register_filebyname("itcl", f_shadow); Swig_banner_target_lang(f_shadow, "#"); Printv(f_shadow, "\npackage require Itcl\n\n", NIL); Delete(filen); } /* Generate some macros used throughout code generation */ Printf(f_header, "#define SWIG_init %s\n", init_name); Printf(f_header, "#define SWIG_name \"%s\"\n", module); if (namespace_option) { Printf(f_header, "#define SWIG_prefix \"%s::\"\n", ns_name); Printf(f_header, "#define SWIG_namespace \"%s\"\n\n", ns_name); } else { Printf(f_header, "#define SWIG_prefix \"%s\"\n", prefix); } Printf(f_header, "#define SWIG_version \"%s\"\n", version); Printf(cmd_tab, "\nstatic swig_command_info swig_commands[] = {\n"); Printf(var_tab, "\nstatic swig_var_info swig_variables[] = {\n"); Printf(const_tab, "\nstatic swig_const_info swig_constants[] = {\n"); Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); /* Start emitting code */ Language::top(n); /* Done. Close up the module */ Printv(cmd_tab, tab4, "{0, 0, 0}\n", "};\n", NIL); Printv(var_tab, tab4, "{0,0,0,0}\n", "};\n", NIL); Printv(const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL); Printv(f_wrappers, cmd_tab, var_tab, const_tab, NIL); /* Dump the pointer equivalency table */ SwigType_emit_type_table(f_runtime, f_wrappers); Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n"); /* Close the init function and quit */ Printf(f_init, "return TCL_OK;\n}\n"); if (!nosafe) { Printf(f_init, "SWIGEXPORT int %(title)s_SafeInit(Tcl_Interp *interp) {\n", module); Printf(f_init, " return SWIG_init(interp);\n"); Printf(f_init, "}\n"); } if (itcl) { Printv(f_shadow, f_shadow_stubs, "\n", NIL); Delete(f_shadow); } /* Close all of the files */ Dump(f_runtime, f_begin); Printv(f_begin, f_header, f_wrappers, NIL); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /* ------------------------------------------------------------ * functionWrapper() * ------------------------------------------------------------ */ virtual int functionWrapper(Node *n) { String *name = Getattr(n, "name"); /* Like to get rid of this */ String *iname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); ParmList *parms = Getattr(n, "parms"); String *overname = 0; Parm *p; int i; String *tm; Wrapper *f; String *incode, *cleanup, *outarg, *argstr, *args; int num_arguments = 0; int num_required = 0; int varargs = 0; char source[64]; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) return SWIG_ERROR; } incode = NewString(""); cleanup = NewString(""); outarg = NewString(""); argstr = NewString("\""); args = NewString(""); f = NewWrapper(); #ifdef SWIG_USE_RESULTOBJ Wrapper_add_local(f, "resultobj", "Tcl_Obj *resultobj = NULL"); #endif String *wname = Swig_name_wrapper(iname); if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); Printv(f->def, "SWIGINTERN int\n ", wname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {", NIL); // Emit all of the local variables for holding arguments. emit_parameter_variables(parms, f); /* Attach standard typemaps */ emit_attach_parmmaps(parms, f); Setattr(n, "wrap:parms", parms); /* Get number of require and total arguments */ num_arguments = emit_num_arguments(parms); num_required = emit_num_required(parms); varargs = emit_isvarargs(parms); /* Unmarshal parameters */ for (i = 0, p = parms; i < num_arguments; i++) { /* Skip ignored arguments */ while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); /* Produce string representations of the source and target arguments */ sprintf(source, "objv[%d]", i + 1); if (i == num_required) Putc('|', argstr); if ((tm = Getattr(p, "tmap:in"))) { String *parse = Getattr(p, "tmap:in:parse"); if (!parse) { Replaceall(tm, "$target", ln); Replaceall(tm, "$source", source); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } Putc('o', argstr); Printf(args, ",(void *)0"); if (i >= num_required) { Printf(incode, "if (objc > %d) {\n", i + 1); } Printf(incode, "%s\n", tm); if (i >= num_required) { Printf(incode, "}\n"); } } else { Printf(argstr, "%s", parse); Printf(args, ",&%s", ln); if (Strcmp(parse, "p") == 0) { SwigType *lt = SwigType_ltype(pt); SwigType_remember(pt); if (Cmp(lt, "p.void") == 0) { Printf(args, ",(void *)0"); } else { Printf(args, ",SWIGTYPE%s", SwigType_manglestr(pt)); } Delete(lt); } } p = Getattr(p, "tmap:in:next"); continue; } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); } p = nextSibling(p); } if (!varargs) { Putc(':', argstr); } else { Putc(';', argstr); /* If variable length arguments we need to emit the in typemap here */ if (p && (tm = Getattr(p, "tmap:in"))) { sprintf(source, "objv[%d]", i + 1); Printf(incode, "if (objc > %d) {\n", i); Replaceall(tm, "$input", source); Printv(incode, tm, "\n", NIL); Printf(incode, "}\n"); } } Printf(argstr, "%s\"", usage_string(Char(iname), type, parms)); Printv(f->code, "if (SWIG_GetArgs(interp, objc, objv,", argstr, args, ") == TCL_ERROR) SWIG_fail;\n", NIL); Printv(f->code, incode, NIL); /* Insert constraint checking code */ for (p = parms; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ for (i = 0, p = parms; p; i++) { if (!checkAttribute(p, "tmap:in:numinputs", "0") && !Getattr(p, "tmap:in:parse") && (tm = Getattr(p, "tmap:freearg"))) { if (Len(tm) != 0) { Replaceall(tm, "$source", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); } p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ for (i = 0, p = parms; p; i++) { if ((tm = Getattr(p, "tmap:argout"))) { Replaceall(tm, "$source", Getattr(p, "lname")); #ifdef SWIG_USE_RESULTOBJ Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); #else Replaceall(tm, "$target", "(Tcl_GetObjResult(interp))"); Replaceall(tm, "$result", "(Tcl_GetObjResult(interp))"); #endif Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } /* Now write code to make the function call */ String *actioncode = emit_action(n); /* Need to redo all of this code (eventually) */ /* Return value if necessary */ if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$source", Swig_cresult_name()); #ifdef SWIG_USE_RESULTOBJ Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); #else Replaceall(tm, "$target", "(Tcl_GetObjResult(interp))"); Replaceall(tm, "$result", "(Tcl_GetObjResult(interp))"); #endif if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "SWIG_POINTER_OWN"); } else { Replaceall(tm, "$owner", "0"); } Printf(f->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), name); } emit_return_variable(n, type, f); /* Dump output argument code */ Printv(f->code, outarg, NIL); /* Dump the argument cleanup code */ Printv(f->code, cleanup, NIL); /* Look for any remaining cleanup */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } #ifdef SWIG_USE_RESULTOBJ Printv(f->code, "if (resultobj) Tcl_SetObjResult(interp, resultobj);\n", NIL); #endif Printv(f->code, "return TCL_OK;\n", NIL); Printv(f->code, "fail:\n", cleanup, "return TCL_ERROR;\n", NIL); Printv(f->code, "}\n", NIL); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); Replaceall(f->code, "$symname", iname); /* Dump out the function */ Wrapper_print(f, f_wrappers); if (!Getattr(n, "sym:overloaded")) { /* Register the function with Tcl */ Printv(cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), ", NULL},\n", NIL); } else { if (!Getattr(n, "sym:nextSibling")) { /* Emit overloading dispatch function */ int maxargs; String *dispatch = Swig_overload_dispatch(n, "return %s(clientData, interp, objc, argv - 1);", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *df = NewWrapper(); String *dname = Swig_name_wrapper(iname); Printv(df->def, "SWIGINTERN int\n", dname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {", NIL); Printf(df->code, "Tcl_Obj *CONST *argv = objv+1;\n"); Printf(df->code, "int argc = objc-1;\n"); Printv(df->code, dispatch, "\n", NIL); Node *sibl = n; while (Getattr(sibl, "sym:previousSibling")) sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up String *protoTypes = NewString(""); do { String *fulldecl = Swig_name_decl(sibl); Printf(protoTypes, "\n\" %s\\n\"", fulldecl); Delete(fulldecl); } while ((sibl = Getattr(sibl, "sym:nextSibling"))); Printf(df->code, "Tcl_SetResult(interp,(char *) " "\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s, TCL_STATIC);\n", iname, protoTypes); Delete(protoTypes); Printf(df->code, "return TCL_ERROR;\n"); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); Printv(cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", dname, ", NULL},\n", NIL); DelWrapper(df); Delete(dispatch); Delete(dname); } } Delete(incode); Delete(cleanup); Delete(outarg); Delete(argstr); Delete(args); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * variableWrapper() * ------------------------------------------------------------ */ virtual int variableWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *t = Getattr(n, "type"); String *setname = 0; String *setfname = 0; Wrapper *setf = 0, *getf = 0; int readonly = 0; String *tm; if (!addSymbol(iname, n)) return SWIG_ERROR; /* Create a function for getting a variable */ int addfail = 0; getf = NewWrapper(); String *getname = Swig_name_get(NSPACE_TODO, iname); String *getfname = Swig_name_wrapper(getname); Setattr(n, "wrap:name", getfname); Printv(getf->def, "SWIGINTERN const char *", getfname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {", NIL); Wrapper_add_local(getf, "value", "Tcl_Obj *value = 0"); if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$source", name); Replaceall(tm, "$target", "value"); Replaceall(tm, "$result", "value"); /* Printf(getf->code, "%s\n",tm); */ addfail = emit_action_code(n, getf->code, tm); Printf(getf->code, "if (value) {\n"); Printf(getf->code, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n"); Printf(getf->code, "Tcl_DecrRefCount(value);\n"); Printf(getf->code, "}\n"); Printf(getf->code, "return NULL;\n"); if (addfail) { Append(getf->code, "fail:\n"); Printf(getf->code, "return \"%s\";\n", iname); } Printf(getf->code, "}\n"); Wrapper_print(getf, f_wrappers); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0)); DelWrapper(getf); return SWIG_NOWRAP; } DelWrapper(getf); /* Try to create a function setting a variable */ if (is_assignable(n)) { setf = NewWrapper(); setname = Swig_name_set(NSPACE_TODO, iname); setfname = Swig_name_wrapper(setname); Setattr(n, "wrap:name", setfname); if (setf) { Printv(setf->def, "SWIGINTERN const char *", setfname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2 SWIGUNUSED, int flags) {", NIL); Wrapper_add_local(setf, "value", "Tcl_Obj *value = 0"); Wrapper_add_local(setf, "name1o", "Tcl_Obj *name1o = 0"); if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { Replaceall(tm, "$source", "value"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "value"); Printf(setf->code, "name1o = Tcl_NewStringObj(name1,-1);\n"); Printf(setf->code, "value = Tcl_ObjGetVar2(interp, name1o, 0, flags);\n"); Printf(setf->code, "Tcl_DecrRefCount(name1o);\n"); Printf(setf->code, "if (!value) SWIG_fail;\n"); /* Printf(setf->code,"%s\n", tm); */ emit_action_code(n, setf->code, tm); Printf(setf->code, "return NULL;\n"); Printf(setf->code, "fail:\n"); Printf(setf->code, "return \"%s\";\n", iname); Printf(setf->code, "}\n"); Wrapper_print(setf, f_wrappers); } else { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); readonly = 1; } } DelWrapper(setf); } else { readonly = 1; } Printv(var_tab, tab4, "{ SWIG_prefix \"", iname, "\", 0, (swig_variable_func) ", getfname, ",", NIL); if (readonly) { static int readonlywrap = 0; if (!readonlywrap) { Wrapper *ro = NewWrapper(); Printf(ro->def, "SWIGINTERN const char *swig_readonly(ClientData clientData SWIGUNUSED, Tcl_Interp *interp SWIGUNUSED, char *name1 SWIGUNUSED, char *name2 SWIGUNUSED, int flags SWIGUNUSED) {"); Printv(ro->code, "return \"Variable is read-only\";\n", "}\n", NIL); Wrapper_print(ro, f_wrappers); readonlywrap = 1; DelWrapper(ro); } Printf(var_tab, "(swig_variable_func) swig_readonly},\n"); } else { Printv(var_tab, "(swig_variable_func) ", setfname, "},\n", NIL); } Delete(getfname); Delete(setfname); Delete(setname); Delete(getname); return SWIG_OK; } /* ------------------------------------------------------------ * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); String *nsname = !namespace_option ? Copy(iname) : NewStringf("%s::%s", ns_name, iname); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); String *tm; if (!addSymbol(iname, n)) return SWIG_ERROR; if (namespace_option) Setattr(n, "sym:name", nsname); /* Special hook for member pointer */ if (SwigType_type(type) == T_MPOINTER) { String *wname = Swig_name_wrapper(iname); Printf(f_wrappers, "static %s = %s;\n", SwigType_str(type, wname), value); value = Char(wname); } if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); Replaceall(tm, "$value", value); Replaceall(tm, "$nsname", nsname); Printf(const_tab, "%s,\n", tm); } else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); Replaceall(tm, "$value", value); Replaceall(tm, "$nsname", nsname); Printf(f_init, "%s\n", tm); } else { Delete(nsname); Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); return SWIG_NOWRAP; } Delete(nsname); return SWIG_OK; } /* ------------------------------------------------------------ * nativeWrapper() * ------------------------------------------------------------ */ virtual int nativeWrapper(Node *n) { String *name = Getattr(n, "sym:name"); String *funcname = Getattr(n, "wrap:name"); if (!addSymbol(funcname, n)) return SWIG_ERROR; Printf(f_init, "\t Tcl_CreateObjCommand(interp, SWIG_prefix \"%s\", (swig_wrapper_func) %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n", name, funcname); return SWIG_OK; } /* ------------------------------------------------------------ * classHandler() * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { static Hash *emitted = NewHash(); String *mangled_classname = 0; String *real_classname = 0; have_constructor = 0; have_destructor = 0; destructor_action = 0; constructor_name = 0; if (itcl) { constructor = NewString(""); destructor = NewString(""); base_classes = NewString(""); base_class_init = NewString(""); methods = NewString(""); imethods = NewString(""); attributes = NewString(""); attribute_traces = NewString(""); iattribute_traces = NewString(""); have_base_classes = 0; have_methods = 0; have_attributes = 0; } class_name = Getattr(n, "sym:name"); if (!addSymbol(class_name, n)) return SWIG_ERROR; real_classname = Getattr(n, "name"); mangled_classname = Swig_name_mangle(real_classname); if (Getattr(emitted, mangled_classname)) return SWIG_NOWRAP; Setattr(emitted, mangled_classname, "1"); attr_tab = NewString(""); Printf(attr_tab, "static swig_attribute swig_"); Printv(attr_tab, mangled_classname, "_attributes[] = {\n", NIL); methods_tab = NewStringf(""); Printf(methods_tab, "static swig_method swig_"); Printv(methods_tab, mangled_classname, "_methods[] = {\n", NIL); /* Generate normal wrappers */ Language::classHandler(n); SwigType *t = Copy(Getattr(n, "name")); SwigType_add_pointer(t); // Catch all: eg. a class with only static functions and/or variables will not have 'remembered' // SwigType_remember(t); String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname); SwigType_remember_clientdata(t, wrap_class); String *rt = Copy(getClassType()); SwigType_add_pointer(rt); // Register the class structure with the type checker /* Printf(f_init,"SWIG_TypeClientData(SWIGTYPE%s, (void *) &_wrap_class_%s);\n", SwigType_manglestr(t), mangled_classname); */ if (have_destructor) { Printv(f_wrappers, "SWIGINTERN void swig_delete_", class_name, "(void *obj) {\n", NIL); if (destructor_action) { Printv(f_wrappers, SwigType_str(rt, "arg1"), " = (", SwigType_str(rt, 0), ") obj;\n", NIL); Printv(f_wrappers, destructor_action, "\n", NIL); } else { if (CPlusPlus) { Printv(f_wrappers, " delete (", SwigType_str(rt, 0), ") obj;\n", NIL); } else { Printv(f_wrappers, " free((char *) obj);\n", NIL); } } Printf(f_wrappers, "}\n"); } Printf(methods_tab, " {0,0}\n};\n"); Printv(f_wrappers, methods_tab, NIL); Printf(attr_tab, " {0,0,0}\n};\n"); Printv(f_wrappers, attr_tab, NIL); /* Handle inheritance */ String *base_class = NewString(""); String *base_class_names = NewString(""); if (itcl) { base_classes = NewString(""); } List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist)) { Iterator b; int index = 0; b = First(baselist); while (b.item) { String *bname = Getattr(b.item, "name"); if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) { b = Next(b); continue; } if (itcl) { have_base_classes = 1; Printv(base_classes, bname, " ", NIL); Printv(base_class_init, " ", bname, "Ptr::constructor $ptr\n", NIL); } String *bmangle = Swig_name_mangle(bname); // Printv(f_wrappers,"extern swig_class _wrap_class_", bmangle, ";\n", NIL); // Printf(base_class,"&_wrap_class_%s",bmangle); Printf(base_class, "0"); Printf(base_class_names, "\"%s *\",", SwigType_namestr(bname)); /* Put code to register base classes in init function */ //Printf(f_init,"/* Register base : %s */\n", bmangle); //Printf(f_init,"swig_%s_bases[%d] = (swig_class *) SWIG_TypeQuery(\"%s *\")->clientdata;\n", mangled_classname, index, SwigType_namestr(bname)); b = Next(b); index++; Putc(',', base_class); Delete(bmangle); } } if (itcl) { String *ptrclass = NewString(""); // First, build the pointer base class Printv(ptrclass, "itcl::class ", class_name, "Ptr {\n", NIL); if (have_base_classes) Printv(ptrclass, " inherit ", base_classes, "\n", NIL); // Define protected variables for SWIG object pointer Printv(ptrclass, " protected variable swigobj\n", " protected variable thisown\n", NIL); // Define public variables if (have_attributes) { Printv(ptrclass, attributes, NIL); // base class swig_getset was being called for complex inheritance trees if (namespace_option) { Printv(ptrclass, " protected method ", class_name, "_swig_getset {var name1 name2 op} {\n", NIL); Printv(ptrclass, " switch -exact -- $op {\n", " r {set $var [", ns_name, "::", class_name, "_[set var]_get $swigobj]}\n", " w {", ns_name, "::", class_name, "_${var}_set $swigobj [set $var]}\n", " }\n", " }\n", NIL); } else { Printv(ptrclass, " protected method ", class_name, "_swig_getset {var name1 name2 op} {\n", " switch -exact -- $op {\n", " r {set $var [", class_name, "_[set var]_get $swigobj]}\n", " w {", class_name, "_${var}_set $swigobj [set $var]}\n", " }\n", " }\n", NIL); } } // Add the constructor, which may include // calls to base class class constructors Printv(ptrclass, " constructor { ptr } {\n", NIL); if (have_base_classes) { Printv(ptrclass, base_class_init, NIL); Printv(ptrclass, " } {\n", NIL); } Printv(ptrclass, " set swigobj $ptr\n", " set thisown 0\n", NIL); if (have_attributes) { Printv(ptrclass, attribute_traces, NIL); } Printv(ptrclass, " }\n", NIL); // Add destructor Printv(ptrclass, " destructor {\n", " set d_func delete_", class_name, "\n", " if { $thisown && ([info command $d_func] != \"\") } {\n" " $d_func $swigobj\n", " }\n", " }\n", NIL); // Add methods if (have_methods) { Printv(ptrclass, imethods, NIL); }; // Close out the pointer class Printv(ptrclass, "}\n\n", NIL); Printv(f_shadow, ptrclass, NIL); // pointer class end // Create the "real" class. Printv(f_shadow, "itcl::class ", class_name, " {\n", NIL); Printv(f_shadow, " inherit ", class_name, "Ptr\n", NIL); // If we have a constructor, then use it. // If not, then we must have an abstract class without // any constructor. So we create a class constructor // which will fail for this class (but not for inherited // classes). Note that the constructor must fail before // calling the ptrclass constructor. if (have_constructor) { Printv(f_shadow, constructor, NIL); } else { Printv(f_shadow, " constructor { } {\n", NIL); Printv(f_shadow, " # This constructor will fail if called directly\n", NIL); Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL); Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstracts") ? " - class is abstract" : ""), "\"\n", NIL); Printv(f_shadow, " }\n", NIL); Printv(f_shadow, " }\n", NIL); } Printv(f_shadow, "}\n\n", NIL); } Printv(f_wrappers, "static swig_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL); Printv(f_wrappers, "static const char * swig_", mangled_classname, "_base_names[] = {", base_class_names, "0};\n", NIL); Delete(base_class); Delete(base_class_names); Printv(f_wrappers, "static swig_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL); if (have_constructor) { Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); Delete(constructor_name); constructor_name = 0; } else { Printf(f_wrappers, "0"); } if (have_destructor) { Printv(f_wrappers, ", swig_delete_", class_name, NIL); } else { Printf(f_wrappers, ",0"); } Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname, "_bases,", "swig_", mangled_classname, "_base_names, &swig_module };\n", NIL); if (!itcl) { Printv(cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, (ClientData)&_wrap_class_", mangled_classname, "},\n", NIL); }; Delete(t); Delete(mangled_classname); return SWIG_OK; } /* ------------------------------------------------------------ * memberfunctionHandler() * ------------------------------------------------------------ */ virtual int memberfunctionHandler(Node *n) { String *name = Getattr(n, "name"); String *iname = GetChar(n, "sym:name"); String *realname, *rname; Language::memberfunctionHandler(n); realname = iname ? iname : name; rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname)); if (!Getattr(n, "sym:nextSibling")) { Printv(methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL); } if (itcl) { ParmList *l = Getattr(n, "parms"); Parm *p = 0; String *pname = NewString(""); // Add this member to our class handler function Printv(imethods, tab2, "method ", realname, " [list ", NIL); int pnum = 0; for (p = l; p; p = nextSibling(p)) { String *pn = Getattr(p, "name"); String *dv = Getattr(p, "value"); SwigType *pt = Getattr(p, "type"); Printv(pname, ",(", pt, ")", NIL); Clear(pname); /* Only print an argument if not void */ if (Cmp(pt, "void") != 0) { if (Len(pn) > 0) { Printv(pname, pn, NIL); } else { Printf(pname, "p%d", pnum); } if (Len(dv) > 0) { String *defval = NewString(dv); if (namespace_option) { Insert(defval, 0, "::"); Insert(defval, 0, ns_name); } if (Strncmp(dv, "(", 1) == 0) { Insert(defval, 0, "$"); Replaceall(defval, "(", ""); Replaceall(defval, ")", ""); } Printv(imethods, "[list ", pname, " ", defval, "] ", NIL); } else { Printv(imethods, pname, " ", NIL); } } ++pnum; } Printv(imethods, "] ", NIL); if (namespace_option) { Printv(imethods, "{ ", ns_name, "::", class_name, "_", realname, " $swigobj", NIL); } else { Printv(imethods, "{ ", class_name, "_", realname, " $swigobj", NIL); }; pnum = 0; for (p = l; p; p = nextSibling(p)) { String *pn = Getattr(p, "name"); SwigType *pt = Getattr(p, "type"); Clear(pname); /* Only print an argument if not void */ if (Cmp(pt, "void") != 0) { if (Len(pn) > 0) { Printv(pname, pn, NIL); } else { Printf(pname, "p%d", pnum); } Printv(imethods, " $", pname, NIL); } ++pnum; } Printv(imethods, " }\n", NIL); have_methods = 1; } Delete(rname); return SWIG_OK; } /* ------------------------------------------------------------ * membervariableHandler() * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { String *symname = Getattr(n, "sym:name"); String *rname; Language::membervariableHandler(n); Printv(attr_tab, tab4, "{ \"-", symname, "\",", NIL); rname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); Printv(attr_tab, rname, ", ", NIL); Delete(rname); if (!GetFlag(n, "feature:immutable")) { rname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); Printv(attr_tab, rname, "},\n", NIL); Delete(rname); } else { Printf(attr_tab, "0 },\n"); } if (itcl) { Printv(attributes, " public variable ", symname, "\n", NIL); Printv(attribute_traces, " trace variable ", symname, " rw [list ", class_name, "_swig_getset ", symname, "]\n", NIL); Printv(attribute_traces, " set ", symname, "\n", NIL); have_attributes = 1; } return SWIG_OK; } /* ------------------------------------------------------------ * constructorHandler() * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { Language::constructorHandler(n); if (itcl) { String *name = Getattr(n, "name"); String *iname = GetChar(n, "sym:name"); String *realname; ParmList *l = Getattr(n, "parms"); Parm *p = 0; String *pname = NewString(""); realname = iname ? iname : name; if (!have_constructor) { // Add this member to our class handler function Printf(constructor, " constructor { "); // Add parameter list int pnum = 0; for (p = l; p; p = nextSibling(p)) { SwigType *pt = Getattr(p, "type"); String *pn = Getattr(p, "name"); String *dv = Getattr(p, "value"); Clear(pname); /* Only print an argument if not void */ if (Cmp(pt, "void") != 0) { if (Len(pn) > 0) { Printv(pname, pn, NIL); } else { Printf(pname, "p%d", pnum); } if (Len(dv) > 0) { Printv(constructor, "{", pname, " {", dv, "} } ", NIL); } else { Printv(constructor, pname, " ", NIL); } } ++pnum; } Printf(constructor, "} { \n"); // [BRE] 08/17/00 Added test to see if we are instantiating this object // type, or, if this constructor is being called as part of the itcl // inheritance hierarchy. // In the former case, we need to call the C++ constructor, in the // latter we don't, or we end up with two C++ objects. // Check to see if we are instantiating a 'realname' or something // derived from it. // Printv(constructor, " if { [string equal -nocase \"", realname, "\" \"[namespace tail [info class]]\" ] } {\n", NIL); // Call to constructor wrapper and parent Ptr class // [BRE] add -namespace/-prefix support if (namespace_option) { Printv(constructor, " ", realname, "Ptr::constructor [", ns_name, "::new_", realname, NIL); } else { Printv(constructor, " ", realname, "Ptr::constructor [new_", realname, NIL); } pnum = 0; for (p = l; p; p = nextSibling(p)) { SwigType *pt = Getattr(p, "type"); String *pn = Getattr(p, "name"); Clear(pname); /* Only print an argument if not void */ if (Cmp(pt, "void") != 0) { if (Len(pn) > 0) { Printv(pname, pn, NIL); } else { Printf(pname, "p%d", pnum); } Printv(constructor, " $", pname, NIL); } ++pnum; } Printv(constructor, "]\n", " }\n", " } {\n", " set thisown 1\n", " }\n", NIL); } } if (!have_constructor) constructor_name = NewString(Getattr(n, "sym:name")); have_constructor = 1; return SWIG_OK; } /* ------------------------------------------------------------ * destructorHandler() * ------------------------------------------------------------ */ virtual int destructorHandler(Node *n) { Language::destructorHandler(n); have_destructor = 1; destructor_action = Getattr(n, "wrap:action"); return SWIG_OK; } /* ------------------------------------------------------------ * validIdentifier() * ------------------------------------------------------------ */ virtual int validIdentifier(String *s) { if (Strchr(s, ' ')) return 0; return 1; } /* ------------------------------------------------------------ * usage_string() * ------------------------------------------------------------ */ char *usage_string(char *iname, SwigType *, ParmList *l) { static String *temp = 0; Parm *p; int i, numopt, pcount; if (!temp) temp = NewString(""); Clear(temp); if (namespace_option) { Printf(temp, "%s::%s ", ns_name, iname); } else { Printf(temp, "%s ", iname); } /* Now go through and print parameters */ i = 0; pcount = emit_num_arguments(l); numopt = pcount - emit_num_required(l); for (p = l; p; p = nextSibling(p)) { SwigType *pt = Getattr(p, "type"); String *pn = Getattr(p, "name"); /* Only print an argument if not ignored */ if (!checkAttribute(p, "tmap:in:numinputs", "0")) { if (i >= (pcount - numopt)) Putc('?', temp); if (Len(pn) > 0) { Printf(temp, "%s", pn); } else { Printf(temp, "%s", SwigType_str(pt, 0)); } if (i >= (pcount - numopt)) Putc('?', temp); Putc(' ', temp); i++; } } return Char(temp); } String *runtimeCode() { String *s = NewString(""); String *serrors = Swig_include_sys("tclerrors.swg"); if (!serrors) { Printf(stderr, "*** Unable to open 'tclerrors.swg'\n"); } else { Append(s, serrors); Delete(serrors); } String *sapi = Swig_include_sys("tclapi.swg"); if (!sapi) { Printf(stderr, "*** Unable to open 'tclapi.swg'\n"); } else { Append(s, sapi); Delete(sapi); } String *srun = Swig_include_sys("tclrun.swg"); if (!srun) { Printf(stderr, "*** Unable to open 'tclrun.swg'\n"); } else { Append(s, srun); Delete(srun); } return s; } String *defaultExternalRuntimeFilename() { return NewString("swigtclrun.h"); } }; /* ---------------------------------------------------------------------- * swig_tcl() - Instantiate module * ---------------------------------------------------------------------- */ static Language *new_swig_tcl() { return new TCL8(); } extern "C" Language *swig_tcl(void) { return new_swig_tcl(); } swig-3.0.2/Source/Modules/perl5.cxx0000664000175000017500000024207512343605122017000 0ustar williamwilliam/* ---------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * perl5.cxx * * Perl5 language module for SWIG. * ------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" static int treduce = SWIG_cparse_template_reduce(0); #include static const char *usage = "\ Perl5 Options (available with -perl5)\n\ -compat - Compatibility mode\n\ -const - Wrap constants as constants and not variables (implies -proxy)\n\ -cppcast - Enable C++ casting operators\n\ -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nopm - Do not generate the .pm file\n\ -noproxy - Don't create proxy classes\n\ -proxy - Create proxy classes\n\ -static - Omit code related to dynamic loading\n\ \n"; static int compat = 0; static int no_pmfile = 0; static int export_all = 0; /* * pmfile * set by the -pm flag, overrides the name of the .pm file */ static String *pmfile = 0; /* * module * set by the %module directive, e.g. "Xerces". It will determine * the name of the .pm file, and the dynamic library, and the name * used by any module wanting to %import the module. */ static String *module = 0; /* * namespace_module * the fully namespace qualified name of the module. It will be used * to set the package namespace in the .pm file, as well as the name * of the initialization methods in the glue library. This will be * the same as module, above, unless the %module directive is given * the 'package' option, e.g. %module(package="Foo::Bar") "baz" */ static String *namespace_module = 0; /* * cmodule * the namespace of the internal glue code, set to the value of * module with a 'c' appended */ static String *cmodule = 0; /* * dest_package * an optional namespace to put all classes into. Specified by using * the %module(package="Foo::Bar") "baz" syntax */ static String *dest_package = 0; static String *command_tab = 0; static String *constant_tab = 0; static String *variable_tab = 0; static File *f_begin = 0; static File *f_runtime = 0; static File *f_runtime_h = 0; static File *f_header = 0; static File *f_wrappers = 0; static File *f_directors = 0; static File *f_directors_h = 0; static File *f_init = 0; static File *f_pm = 0; static String *pm; /* Package initialization code */ static String *magic; /* Magic variable wrappers */ static int staticoption = 0; // controlling verbose output static int verbose = 0; /* The following variables are used to manage Perl5 classes */ static int blessed = 1; /* Enable object oriented features */ static int do_constants = 0; /* Constant wrapping */ static List *classlist = 0; /* List of classes */ static int have_constructor = 0; static int have_destructor = 0; static int have_data_members = 0; static String *class_name = 0; /* Name of the class (what Perl thinks it is) */ static String *real_classname = 0; /* Real name of C/C++ class */ static String *fullclassname = 0; static String *pcode = 0; /* Perl code associated with each class */ /* static String *blessedmembers = 0; *//* Member data associated with each class */ static int member_func = 0; /* Set to 1 when wrapping a member function */ static String *func_stubs = 0; /* Function stubs */ static String *const_stubs = 0; /* Constant stubs */ static int num_consts = 0; /* Number of constants */ static String *var_stubs = 0; /* Variable stubs */ static String *exported = 0; /* Exported symbols */ static String *pragma_include = 0; static String *additional_perl_code = 0; /* Additional Perl code from %perlcode %{ ... %} */ static Hash *operators = 0; static int have_operators = 0; class PERL5:public Language { public: PERL5():Language () { Clear(argc_template_string); Printv(argc_template_string, "items", NIL); Clear(argv_template_string); Printv(argv_template_string, "ST(%d)", NIL); director_language = 1; } /* Test to see if a type corresponds to something wrapped with a shadow class */ Node *is_shadow(SwigType *t) { Node *n; n = classLookup(t); /* Printf(stdout,"'%s' --> '%p'\n", t, n); */ if (n) { if (!Getattr(n, "perl5:proxy")) { setclassname(n); } return Getattr(n, "perl5:proxy"); } return 0; } /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { int i = 1; int cppcast = 1; SWIG_library_directory("perl5"); for (i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-package") == 0) { Printv(stderr, "*** -package is no longer supported\n*** use the directive '%module A::B::C' in your interface file instead\n*** see the Perl section in the manual for details.\n", NIL); SWIG_exit(EXIT_FAILURE); } else if (strcmp(argv[i], "-interface") == 0) { Printv(stderr, "*** -interface is no longer supported\n*** use the directive '%module A::B::C' in your interface file instead\n*** see the Perl section in the manual for details.\n", NIL); SWIG_exit(EXIT_FAILURE); } else if (strcmp(argv[i], "-exportall") == 0) { export_all = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-static") == 0) { staticoption = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-shadow") == 0) || ((strcmp(argv[i], "-proxy") == 0))) { blessed = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-noproxy") == 0)) { blessed = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-const") == 0) { do_constants = 1; blessed = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nopm") == 0) { no_pmfile = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-pm") == 0) { Swig_mark_arg(i); i++; pmfile = NewString(argv[i]); Swig_mark_arg(i); } else if (strcmp(argv[i],"-v") == 0) { Swig_mark_arg(i); verbose++; } else if (strcmp(argv[i], "-cppcast") == 0) { cppcast = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nocppcast") == 0) { cppcast = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-compat") == 0) { compat = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); } } } if (cppcast) { Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); } Preprocessor_define("SWIGPERL 1", 0); // SWIGPERL5 is deprecated, and no longer documented. Preprocessor_define("SWIGPERL5 1", 0); SWIG_typemap_lang("perl5"); SWIG_config_file("perl5.swg"); allow_overloading(); } /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ virtual int top(Node *n) { /* check if directors are enabled for this module. note: this * is a "master" switch, without which no director code will be * emitted. %feature("director") statements are also required * to enable directors for individual classes or methods. * * use %module(directors="1") modulename at the start of the * interface file to enable director generation. * * TODO: directors are disallowed in conjunction with many command * line options. Some of them are probably safe, but it will take * some effort to validate each one. */ { Node *mod = Getattr(n, "module"); if (mod) { Node *options = Getattr(mod, "options"); if (options) { int dirprot = 0; if (Getattr(options, "dirprot")) dirprot = 1; if (Getattr(options, "nodirprot")) dirprot = 0; if (Getattr(options, "directors")) { int allow = 1; if (export_all) { Printv(stderr, "*** directors are not supported with -exportall\n", NIL); allow = 0; } if (staticoption) { Printv(stderr, "*** directors are not supported with -static\n", NIL); allow = 0; } if (!blessed) { Printv(stderr, "*** directors are not supported with -noproxy\n", NIL); allow = 0; } if (no_pmfile) { Printv(stderr, "*** directors are not supported with -nopm\n", NIL); allow = 0; } if (compat) { Printv(stderr, "*** directors are not supported with -compat\n", NIL); allow = 0; } if (allow) { allow_directors(); if (dirprot) allow_dirprot(); } } } } } /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); String *outfile_h = Getattr(n, "outfile_h"); f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); f_directors_h = NewString(""); f_directors = NewString(""); if (directorsEnabled()) { f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); } } /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); classlist = NewList(); pm = NewString(""); func_stubs = NewString(""); var_stubs = NewString(""); const_stubs = NewString(""); exported = NewString(""); magic = NewString(""); pragma_include = NewString(""); additional_perl_code = NewString(""); command_tab = NewString("static swig_command_info swig_commands[] = {\n"); constant_tab = NewString("static swig_constant_info swig_constants[] = {\n"); variable_tab = NewString("static swig_variable_info swig_variables[] = {\n"); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPERL\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n"); Printf(f_runtime, "\n"); // Is the imported module in another package? (IOW, does it use the // %module(package="name") option and it's different than the package // of this module.) Node *mod = Getattr(n, "module"); Node *options = Getattr(mod, "options"); module = Copy(Getattr(n,"name")); if (directorsEnabled()) { Swig_banner(f_directors_h); Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module); if (dirprot_mode()) { Printf(f_directors_h, "#include \n"); Printf(f_directors_h, "#include \n\n"); } Printf(f_directors, "\n\n"); Printf(f_directors, "/* ---------------------------------------------------\n"); Printf(f_directors, " * C++ director class methods\n"); Printf(f_directors, " * --------------------------------------------------- */\n\n"); if (outfile_h) { String *filename = Swig_file_filename(outfile_h); Printf(magic, "#include \"%s\"\n\n", filename); Delete(filename); } } if (verbose > 0) { fprintf(stdout, "top: using module: %s\n", Char(module)); } dest_package = options ? Getattr(options, "package") : 0; if (dest_package) { namespace_module = Copy(dest_package); if (verbose > 0) { fprintf(stdout, "top: Found package: %s\n",Char(dest_package)); } } else { namespace_module = Copy(module); if (verbose > 0) { fprintf(stdout, "top: No package found\n"); } } String *underscore_module = Copy(module); Replaceall(underscore_module,":","_"); if (verbose > 0) { fprintf(stdout, "top: using namespace_module: %s\n", Char(namespace_module)); } /* If we're in blessed mode, change the package name to "packagec" */ if (blessed) { cmodule = NewStringf("%sc",namespace_module); } else { cmodule = NewString(namespace_module); } /* Create a .pm file * Need to strip off any prefixes that might be found in * the module name */ if (no_pmfile) { f_pm = NewString(0); } else { if (!pmfile) { char *m = Char(module) + Len(module); while (m != Char(module)) { if (*m == ':') { m++; break; } m--; } pmfile = NewStringf("%s.pm", m); } String *filen = NewStringf("%s%s", SWIG_output_directory(), pmfile); if ((f_pm = NewFile(filen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Delete(filen); filen = NULL; Swig_register_filebyname("pm", f_pm); Swig_register_filebyname("perl", f_pm); } { String *boot_name = NewStringf("boot_%s", underscore_module); Printf(f_header,"#define SWIG_init %s\n\n", boot_name); Printf(f_header,"#define SWIG_name \"%s::%s\"\n", cmodule, boot_name); Printf(f_header,"#define SWIG_prefix \"%s::\"\n", cmodule); Delete(boot_name); } Swig_banner_target_lang(f_pm, "#"); Printf(f_pm, "\n"); Printf(f_pm, "package %s;\n", module); /* * If the package option has been given we are placing our * symbols into some other packages namespace, so we do not * mess with @ISA or require for that package */ if (dest_package) { Printf(f_pm,"use base qw(DynaLoader);\n"); } else { Printf(f_pm,"use base qw(Exporter);\n"); if (!staticoption) { Printf(f_pm,"use base qw(DynaLoader);\n"); } } /* Start creating magic code */ Printv(magic, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n", "#ifdef PERL_OBJECT\n", "#define MAGIC_CLASS _wrap_", underscore_module, "_var::\n", "class _wrap_", underscore_module, "_var : public CPerlObj {\n", "public:\n", "#else\n", "#define MAGIC_CLASS\n", "#endif\n", "SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) {\n", tab4, "MAGIC_PPERL\n", tab4, "croak(\"Value is read-only.\");\n", tab4, "return 0;\n", "}\n", NIL); Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); /* emit wrappers */ Language::top(n); if (directorsEnabled()) { // Insert director runtime into the f_runtime file (make it occur before %header section) Swig_insert_file("director.swg", f_runtime); } String *base = NewString(""); /* Dump out variable wrappers */ Printv(magic, "\n\n#ifdef PERL_OBJECT\n", "};\n", "#endif\n", NIL); Printv(magic, "\n#ifdef __cplusplus\n}\n#endif\n", NIL); Printf(f_header, "%s\n", magic); String *type_table = NewString(""); /* Patch the type table to reflect the names used by shadow classes */ if (blessed) { Iterator cls; for (cls = First(classlist); cls.item; cls = Next(cls)) { String *pname = Getattr(cls.item, "perl5:proxy"); if (pname) { SwigType *type = Getattr(cls.item, "classtypeobj"); if (!type) continue; /* If unnamed class, no type will be found */ type = Copy(type); SwigType_add_pointer(type); String *mangled = SwigType_manglestr(type); SwigType_remember_mangleddata(mangled, NewStringf("\"%s\"", pname)); Delete(type); Delete(mangled); } } } SwigType_emit_type_table(f_runtime, type_table); Printf(f_wrappers, "%s", type_table); Delete(type_table); Printf(constant_tab, "{0,0,0,0,0,0}\n};\n"); Printv(f_wrappers, constant_tab, NIL); Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n"); Printf(f_init, "\t ST(0) = &PL_sv_yes;\n"); Printf(f_init, "\t XSRETURN(1);\n"); Printf(f_init, "}\n"); /* Finish off tables */ Printf(variable_tab, "{0,0,0,0}\n};\n"); Printv(f_wrappers, variable_tab, NIL); Printf(command_tab, "{0,0}\n};\n"); Printv(f_wrappers, command_tab, NIL); Printf(f_pm, "package %s;\n", cmodule); if (!staticoption) { Printf(f_pm,"bootstrap %s;\n", module); } else { Printf(f_pm,"package %s;\n", cmodule); Printf(f_pm,"boot_%s();\n", underscore_module); } Printf(f_pm, "package %s;\n", module); /* * If the package option has been given we are placing our * symbols into some other packages namespace, so we do not * mess with @EXPORT */ if (!dest_package) { Printf(f_pm,"@EXPORT = qw(%s);\n", exported); } Printf(f_pm, "%s", pragma_include); if (blessed) { /* * These methods will be duplicated if package * has been specified, so we do not output them */ if (!dest_package) { Printv(base, "\n# ---------- BASE METHODS -------------\n\n", "package ", namespace_module, ";\n\n", NIL); /* Write out the TIE method */ Printv(base, "sub TIEHASH {\n", tab4, "my ($classname,$obj) = @_;\n", tab4, "return bless $obj, $classname;\n", "}\n\n", NIL); /* Output a CLEAR method. This is just a place-holder, but by providing it we * can make declarations such as * %$u = ( x => 2, y=>3, z =>4 ); * * Where x,y,z are the members of some C/C++ object. */ Printf(base, "sub CLEAR { }\n\n"); /* Output default firstkey/nextkey methods */ Printf(base, "sub FIRSTKEY { }\n\n"); Printf(base, "sub NEXTKEY { }\n\n"); /* Output a FETCH method. This is actually common to all classes */ Printv(base, "sub FETCH {\n", tab4, "my ($self,$field) = @_;\n", tab4, "my $member_func = \"swig_${field}_get\";\n", tab4, "$self->$member_func();\n", "}\n\n", NIL); /* Output a STORE method. This is also common to all classes (might move to base class) */ Printv(base, "sub STORE {\n", tab4, "my ($self,$field,$newval) = @_;\n", tab4, "my $member_func = \"swig_${field}_set\";\n", tab4, "$self->$member_func($newval);\n", "}\n\n", NIL); /* Output a 'this' method */ Printv(base, "sub this {\n", tab4, "my $ptr = shift;\n", tab4, "return tied(%$ptr);\n", "}\n\n", NIL); Printf(f_pm, "%s", base); } /* Emit function stubs for stand-alone functions */ Printf(f_pm, "\n# ------- FUNCTION WRAPPERS --------\n\n"); Printf(f_pm, "package %s;\n\n", namespace_module); Printf(f_pm, "%s", func_stubs); /* Emit package code for different classes */ Printf(f_pm, "%s", pm); if (num_consts > 0) { /* Emit constant stubs */ Printf(f_pm, "\n# ------- CONSTANT STUBS -------\n\n"); Printf(f_pm, "package %s;\n\n", namespace_module); Printf(f_pm, "%s", const_stubs); } /* Emit variable stubs */ Printf(f_pm, "\n# ------- VARIABLE STUBS --------\n\n"); Printf(f_pm, "package %s;\n\n", namespace_module); Printf(f_pm, "%s", var_stubs); } /* Add additional Perl code at the end */ Printf(f_pm, "%s", additional_perl_code); Printf(f_pm, "1;\n"); Delete(f_pm); Delete(base); Delete(dest_package); Delete(underscore_module); /* Close all of the files */ Dump(f_runtime, f_begin); Dump(f_header, f_begin); if (directorsEnabled()) { Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); Dump(f_directors, f_begin); } Dump(f_wrappers, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_directors); Delete(f_directors_h); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /* ------------------------------------------------------------ * importDirective(Node *n) * ------------------------------------------------------------ */ virtual int importDirective(Node *n) { if (blessed) { String *modname = Getattr(n, "module"); if (modname) { Printf(f_pm, "require %s;\n", modname); } } return Language::importDirective(n); } /* ------------------------------------------------------------ * functionWrapper() * ------------------------------------------------------------ */ virtual int functionWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *overname = 0; int director_method = 0; Parm *p; int i; Wrapper *f; char source[256], temp[256]; String *tm; String *cleanup, *outarg; int num_saved = 0; int num_arguments, num_required; int varargs = 0; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) return SWIG_ERROR; } f = NewWrapper(); cleanup = NewString(""); outarg = NewString(""); String *wname = Swig_name_wrapper(iname); if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); Printv(f->def, "XS(", wname, ") {\n", "{\n", /* scope to destroy C++ objects before croaking */ NIL); emit_parameter_variables(l, f); emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); num_arguments = emit_num_arguments(l); num_required = emit_num_required(l); varargs = emit_isvarargs(l); Wrapper_add_local(f, "argvi", "int argvi = 0"); /* Check the number of arguments */ if (!varargs) { Printf(f->code, " if ((items < %d) || (items > %d)) {\n", num_required, num_arguments); } else { Printf(f->code, " if (items < %d) {\n", num_required); } Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, l)); Printf(f->code, "}\n"); /* Write code to extract parameters. */ for (i = 0, p = l; i < num_arguments; i++) { /* Skip ignored arguments */ while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); /* Produce string representation of source and target arguments */ sprintf(source, "ST(%d)", i); String *target = Getattr(p, "lname"); if (i >= num_required) { Printf(f->code, " if (items > %d) {\n", i); } if ((tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$target", target); Replaceall(tm, "$source", source); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); /* Save input location */ if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } Printf(f->code, "%s\n", tm); p = Getattr(p, "tmap:in:next"); } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); p = nextSibling(p); } if (i >= num_required) { Printf(f->code, " }\n"); } } if (varargs) { if (p && (tm = Getattr(p, "tmap:in"))) { sprintf(source, "ST(%d)", i); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); Printf(f->code, "if (items >= %d) {\n", i); Printv(f->code, tm, "\n", NIL); Printf(f->code, "}\n"); } } /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ for (i = 0, p = l; p; i++) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ num_saved = 0; for (i = 0, p = l; p; i++) { if ((tm = Getattr(p, "tmap:argout"))) { SwigType *t = Getattr(p, "type"); Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$target", "ST(argvi)"); Replaceall(tm, "$result", "ST(argvi)"); if (is_shadow(t)) { Replaceall(tm, "$shadow", "SWIG_SHADOW"); } else { Replaceall(tm, "$shadow", "0"); } String *in = Getattr(p, "emit:input"); if (in) { sprintf(temp, "_saved[%d]", num_saved); Replaceall(tm, "$arg", temp); Replaceall(tm, "$input", temp); Printf(f->code, "_saved[%d] = %s;\n", num_saved, in); num_saved++; } Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } /* If there were any saved arguments, emit a local variable for them */ if (num_saved) { sprintf(temp, "_saved[%d]", num_saved); Wrapper_add_localv(f, "_saved", "SV *", temp, NIL); } director_method = is_member_director(n) && !is_smart_pointer() && 0 != Cmp(nodeType(n), "destructor"); if (director_method) { Wrapper_add_local(f, "director", "Swig::Director *director = 0"); Append(f->code, "director = SWIG_DIRECTOR_CAST(arg1);\n"); if (dirprot_mode() && !is_public(n)) { Printf(f->code, "if (!director || !(director->swig_get_inner(\"%s\"))) {\n", name); Printf(f->code, "SWIG_exception_fail(SWIG_RuntimeError, \"accessing protected member %s\");\n", name); Append(f->code, "}\n"); } Wrapper_add_local(f, "upcall", "bool upcall = false"); Printf(f->code, "upcall = director && SvSTASH(SvRV(ST(0))) == gv_stashpv(director->swig_get_class(), 0);\n"); } /* Emit the function call */ if (director_method) { Append(f->code, "try {\n"); } /* Now write code to make the function call */ Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); if (director_method) { Append(actioncode, "} catch (Swig::DirectorException& swig_err) {\n"); Append(actioncode, " sv_setsv(ERRSV, swig_err.getNative());\n"); Append(actioncode, " SWIG_fail;\n"); Append(actioncode, "}\n"); } if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { SwigType *t = Getattr(n, "type"); Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "ST(argvi)"); Replaceall(tm, "$result", "ST(argvi)"); if (is_shadow(t)) { Replaceall(tm, "$shadow", "SWIG_SHADOW"); } else { Replaceall(tm, "$shadow", "0"); } if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "SWIG_OWNER"); } else { Replaceall(tm, "$owner", "0"); } Printf(f->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); } emit_return_variable(n, d, f); /* If there were any output args, take care of them. */ Printv(f->code, outarg, NIL); /* If there was any cleanup, do that. */ Printv(f->code, cleanup, NIL); if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } Printv(f->code, "XSRETURN(argvi);\n", "fail:\n", cleanup, "SWIG_croak_null();\n" "}\n" "}\n", NIL); /* Add the dXSARGS last */ Wrapper_add_local(f, "dXSARGS", "dXSARGS"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); Replaceall(f->code, "$symname", iname); /* Dump the wrapper function */ Wrapper_print(f, f_wrappers); /* Now register the function */ if (!Getattr(n, "sym:overloaded")) { Printf(command_tab, "{\"%s::%s\", %s},\n", cmodule, iname, wname); } else if (!Getattr(n, "sym:nextSibling")) { /* Generate overloaded dispatch function */ int maxargs; String *dispatch = Swig_overload_dispatch_cast(n, "PUSHMARK(MARK); SWIG_CALLXS(%s); return;", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *df = NewWrapper(); String *dname = Swig_name_wrapper(iname); Printv(df->def, "XS(", dname, ") {\n", NIL); Wrapper_add_local(df, "dXSARGS", "dXSARGS"); Printv(df->code, dispatch, "\n", NIL); Printf(df->code, "croak(\"No matching function for overloaded '%s'\");\n", iname); Printf(df->code, "XSRETURN(0);\n"); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); Printf(command_tab, "{\"%s::%s\", %s},\n", cmodule, iname, dname); DelWrapper(df); Delete(dispatch); Delete(dname); } if (!Getattr(n, "sym:nextSibling")) { if (export_all) { Printf(exported, "%s ", iname); } /* -------------------------------------------------------------------- * Create a stub for this function, provided it's not a member function * -------------------------------------------------------------------- */ if ((blessed) && (!member_func)) { Printv(func_stubs, "*", iname, " = *", cmodule, "::", iname, ";\n", NIL); } } Delete(cleanup); Delete(outarg); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * variableWrapper() * ------------------------------------------------------------ */ virtual int variableWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *t = Getattr(n, "type"); Wrapper *getf, *setf; String *tm; String *getname = Swig_name_get(NSPACE_TODO, iname); String *setname = Swig_name_set(NSPACE_TODO, iname); String *get_name = Swig_name_wrapper(getname); String *set_name = Swig_name_wrapper(setname); if (!addSymbol(iname, n)) return SWIG_ERROR; getf = NewWrapper(); setf = NewWrapper(); /* Create a Perl function for setting the variable value */ if (!GetFlag(n, "feature:immutable")) { Setattr(n, "wrap:name", set_name); Printf(setf->def, "SWIGCLASS_STATIC int %s(pTHX_ SV* sv, MAGIC * SWIGUNUSEDPARM(mg)) {\n", set_name); Printv(setf->code, tab4, "MAGIC_PPERL\n", NIL); /* Check for a few typemaps */ tm = Swig_typemap_lookup("varin", n, name, 0); if (tm) { Replaceall(tm, "$source", "sv"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "sv"); /* Printf(setf->code,"%s\n", tm); */ emit_action_code(n, setf->code, tm); } else { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); DelWrapper(setf); DelWrapper(getf); return SWIG_NOWRAP; } Printf(setf->code, "fail:\n"); Printf(setf->code, " return 1;\n}\n"); Replaceall(setf->code, "$symname", iname); Wrapper_print(setf, magic); } /* Now write a function to evaluate the variable */ Setattr(n, "wrap:name", get_name); int addfail = 0; Printf(getf->def, "SWIGCLASS_STATIC int %s(pTHX_ SV *sv, MAGIC *SWIGUNUSEDPARM(mg)) {\n", get_name); Printv(getf->code, tab4, "MAGIC_PPERL\n", NIL); if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$target", "sv"); Replaceall(tm, "$result", "sv"); Replaceall(tm, "$source", name); if (is_shadow(t)) { Replaceall(tm, "$shadow", "SWIG_SHADOW"); } else { Replaceall(tm, "$shadow", "0"); } /* Printf(getf->code,"%s\n", tm); */ addfail = emit_action_code(n, getf->code, tm); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0)); DelWrapper(setf); DelWrapper(getf); return SWIG_NOWRAP; } Printf(getf->code, " return 1;\n"); if (addfail) { Append(getf->code, "fail:\n"); Append(getf->code, " return 0;\n"); } Append(getf->code, "}\n"); Replaceall(getf->code, "$symname", iname); Wrapper_print(getf, magic); String *tt = Getattr(n, "tmap:varout:type"); if (tt) { String *tm = NewStringf("&SWIGTYPE%s", SwigType_manglestr(t)); if (Replaceall(tt, "$1_descriptor", tm)) { SwigType_remember(t); } Delete(tm); SwigType *st = Copy(t); SwigType_add_pointer(st); tm = NewStringf("&SWIGTYPE%s", SwigType_manglestr(st)); if (Replaceall(tt, "$&1_descriptor", tm)) { SwigType_remember(st); } Delete(tm); Delete(st); } else { tt = (String *) "0"; } /* Now add symbol to the PERL interpreter */ if (GetFlag(n, "feature:immutable")) { Printv(variable_tab, tab4, "{ \"", cmodule, "::", iname, "\", MAGIC_CLASS swig_magic_readonly, MAGIC_CLASS ", get_name, ",", tt, " },\n", NIL); } else { Printv(variable_tab, tab4, "{ \"", cmodule, "::", iname, "\", MAGIC_CLASS ", set_name, ", MAGIC_CLASS ", get_name, ",", tt, " },\n", NIL); } /* If we're blessed, try to figure out what to do with the variable 1. If it's a Perl object of some sort, create a tied-hash around it. 2. Otherwise, just hack Perl's symbol table */ if (blessed) { if (is_shadow(t)) { Printv(var_stubs, "\nmy %__", iname, "_hash;\n", "tie %__", iname, "_hash,\"", is_shadow(t), "\", $", cmodule, "::", iname, ";\n", "$", iname, "= \\%__", iname, "_hash;\n", "bless $", iname, ", ", is_shadow(t), ";\n", NIL); } else { Printv(var_stubs, "*", iname, " = *", cmodule, "::", iname, ";\n", NIL); } } if (export_all) Printf(exported, "$%s ", iname); DelWrapper(setf); DelWrapper(getf); Delete(getname); Delete(setname); Delete(set_name); Delete(get_name); return SWIG_OK; } /* ------------------------------------------------------------ * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); String *tm; if (!addSymbol(iname, n)) return SWIG_ERROR; /* Special hook for member pointer */ if (SwigType_type(type) == T_MPOINTER) { String *wname = Swig_name_wrapper(iname); Printf(f_wrappers, "static %s = %s;\n", SwigType_str(type, wname), value); value = Char(wname); } if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); Replaceall(tm, "$value", value); if (is_shadow(type)) { Replaceall(tm, "$shadow", "SWIG_SHADOW"); } else { Replaceall(tm, "$shadow", "0"); } Printf(constant_tab, "%s,\n", tm); } else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); Replaceall(tm, "$value", value); if (is_shadow(type)) { Replaceall(tm, "$shadow", "SWIG_SHADOW"); } else { Replaceall(tm, "$shadow", "0"); } Printf(f_init, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); return SWIG_NOWRAP; } if (blessed) { if (is_shadow(type)) { Printv(var_stubs, "\nmy %__", iname, "_hash;\n", "tie %__", iname, "_hash,\"", is_shadow(type), "\", $", cmodule, "::", iname, ";\n", "$", iname, "= \\%__", iname, "_hash;\n", "bless $", iname, ", ", is_shadow(type), ";\n", NIL); } else if (do_constants) { Printv(const_stubs, "sub ", name, " () { $", cmodule, "::", name, " }\n", NIL); num_consts++; } else { Printv(var_stubs, "*", iname, " = *", cmodule, "::", iname, ";\n", NIL); } } if (export_all) { if (do_constants && !is_shadow(type)) { Printf(exported, "%s ", name); } else { Printf(exported, "$%s ", iname); } } return SWIG_OK; } /* ------------------------------------------------------------ * usage_func() * ------------------------------------------------------------ */ char *usage_func(char *iname, SwigType *, ParmList *l) { static String *temp = 0; Parm *p; int i; if (!temp) temp = NewString(""); Clear(temp); Printf(temp, "%s(", iname); /* Now go through and print parameters */ p = l; i = 0; while (p != 0) { SwigType *pt = Getattr(p, "type"); String *pn = Getattr(p, "name"); if (!checkAttribute(p,"tmap:in:numinputs","0")) { /* If parameter has been named, use that. Otherwise, just print a type */ if (SwigType_type(pt) != T_VOID) { if (Len(pn) > 0) { Printf(temp, "%s", pn); } else { Printf(temp, "%s", SwigType_str(pt, 0)); } } i++; p = nextSibling(p); if (p) if (!checkAttribute(p,"tmap:in:numinputs","0")) Putc(',', temp); } else { p = nextSibling(p); if (p) if ((i > 0) && (!checkAttribute(p,"tmap:in:numinputs","0"))) Putc(',', temp); } } Printf(temp, ");"); return Char(temp); } /* ------------------------------------------------------------ * nativeWrapper() * ------------------------------------------------------------ */ virtual int nativeWrapper(Node *n) { String *name = Getattr(n, "sym:name"); String *funcname = Getattr(n, "wrap:name"); if (!addSymbol(funcname, n)) return SWIG_ERROR; Printf(command_tab, "{\"%s::%s\", %s},\n", cmodule, name, funcname); if (export_all) Printf(exported, "%s ", name); if (blessed) { Printv(func_stubs, "*", name, " = *", cmodule, "::", name, ";\n", NIL); } return SWIG_OK; } /* ---------------------------------------------------------------------------- * OBJECT-ORIENTED FEATURES * * These extensions provide a more object-oriented interface to C++ * classes and structures. The code here is based on extensions * provided by David Fletcher and Gary Holt. * * I have generalized these extensions to make them more general purpose * and to resolve object-ownership problems. * * The approach here is very similar to the Python module : * 1. All of the original methods are placed into a single * package like before except that a 'c' is appended to the * package name. * * 2. All methods and function calls are wrapped with a new * perl function. While possibly inefficient this allows * us to catch complex function arguments (which are hard to * track otherwise). * * 3. Classes are represented as tied-hashes in a manner similar * to Gary Holt's extension. This allows us to access * member data. * * 4. Stand-alone (global) C functions are modified to take * tied hashes as arguments for complex datatypes (if * appropriate). * * 5. Global variables involving a class/struct is encapsulated * in a tied hash. * * ------------------------------------------------------------------------- */ void setclassname(Node *n) { String *symname = Getattr(n, "sym:name"); String *fullname; String *actualpackage; Node *clsmodule = Getattr(n, "module"); if (!clsmodule) { /* imported module does not define a module name. Oh well */ return; } /* Do some work on the class name */ if (verbose > 0) { String *modulename = Getattr(clsmodule, "name"); fprintf(stdout, "setclassname: Found sym:name: %s\n", Char(symname)); fprintf(stdout, "setclassname: Found module: %s\n", Char(modulename)); fprintf(stdout, "setclassname: No package found\n"); } if (dest_package) { fullname = NewStringf("%s::%s", namespace_module, symname); } else { actualpackage = Getattr(clsmodule,"name"); if (verbose > 0) { fprintf(stdout, "setclassname: Found actualpackage: %s\n", Char(actualpackage)); } if ((!compat) && (!Strchr(symname,':'))) { fullname = NewStringf("%s::%s",actualpackage,symname); } else { fullname = NewString(symname); } } if (verbose > 0) { fprintf(stdout, "setclassname: setting proxy: %s\n", Char(fullname)); } Setattr(n, "perl5:proxy", fullname); } /* ------------------------------------------------------------ * classDeclaration() * ------------------------------------------------------------ */ virtual int classDeclaration(Node *n) { /* Do some work on the class name */ if (!Getattr(n, "feature:onlychildren")) { if (blessed) { setclassname(n); Append(classlist, n); } } return Language::classDeclaration(n); } /* ------------------------------------------------------------ * classHandler() * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { if (blessed) { have_constructor = 0; have_operators = 0; have_destructor = 0; have_data_members = 0; operators = NewHash(); class_name = Getattr(n, "sym:name"); if (!addSymbol(class_name, n)) return SWIG_ERROR; /* Use the fully qualified name of the Perl class */ if (!compat) { fullclassname = NewStringf("%s::%s", namespace_module, class_name); } else { fullclassname = NewString(class_name); } real_classname = Getattr(n, "name"); pcode = NewString(""); // blessedmembers = NewString(""); } /* Emit all of the members */ Language::classHandler(n); /* Finish the rest of the class */ if (blessed) { /* Generate a client-data entry */ SwigType *ct = NewStringf("p.%s", real_classname); Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", SwigType_manglestr(ct), ", (void*) \"", fullclassname, "\");\n", NIL); SwigType_remember(ct); Delete(ct); Printv(pm, "\n############# Class : ", fullclassname, " ##############\n", "\npackage ", fullclassname, ";\n", NIL); if (have_operators) { Printf(pm, "use overload\n"); Iterator ki; for (ki = First(operators); ki.key; ki = Next(ki)) { char *name = Char(ki.key); // fprintf(stderr,"found name: <%s>\n", name); if (strstr(name, "__eq__")) { Printv(pm, tab4, "\"==\" => sub { $_[0]->__eq__($_[1])},\n",NIL); } else if (strstr(name, "__ne__")) { Printv(pm, tab4, "\"!=\" => sub { $_[0]->__ne__($_[1])},\n",NIL); // there are no tests for this in operator_overload_runme.pl // it is likely to be broken // } else if (strstr(name, "__assign__")) { // Printv(pm, tab4, "\"=\" => sub { $_[0]->__assign__($_[1])},\n",NIL); } else if (strstr(name, "__str__")) { Printv(pm, tab4, "'\"\"' => sub { $_[0]->__str__()},\n",NIL); } else if (strstr(name, "__plusplus__")) { Printv(pm, tab4, "\"++\" => sub { $_[0]->__plusplus__()},\n",NIL); } else if (strstr(name, "__minmin__")) { Printv(pm, tab4, "\"--\" => sub { $_[0]->__minmin__()},\n",NIL); } else if (strstr(name, "__add__")) { Printv(pm, tab4, "\"+\" => sub { $_[0]->__add__($_[1])},\n",NIL); } else if (strstr(name, "__sub__")) { Printv(pm, tab4, "\"-\" => sub { if( not $_[2] ) { $_[0]->__sub__($_[1]) }\n",NIL); Printv(pm, tab8, "elsif( $_[0]->can('__rsub__') ) { $_[0]->__rsub__($_[1]) }\n",NIL); Printv(pm, tab8, "else { die(\"reverse subtraction not supported\") }\n",NIL); Printv(pm, tab8, "},\n",NIL); } else if (strstr(name, "__mul__")) { Printv(pm, tab4, "\"*\" => sub { $_[0]->__mul__($_[1])},\n",NIL); } else if (strstr(name, "__div__")) { Printv(pm, tab4, "\"/\" => sub { $_[0]->__div__($_[1])},\n",NIL); } else if (strstr(name, "__mod__")) { Printv(pm, tab4, "\"%\" => sub { $_[0]->__mod__($_[1])},\n",NIL); // there are no tests for this in operator_overload_runme.pl // it is likely to be broken // } else if (strstr(name, "__and__")) { // Printv(pm, tab4, "\"&\" => sub { $_[0]->__and__($_[1])},\n",NIL); // there are no tests for this in operator_overload_runme.pl // it is likely to be broken // } else if (strstr(name, "__or__")) { // Printv(pm, tab4, "\"|\" => sub { $_[0]->__or__($_[1])},\n",NIL); } else if (strstr(name, "__gt__")) { Printv(pm, tab4, "\">\" => sub { $_[0]->__gt__($_[1])},\n",NIL); } else if (strstr(name, "__ge__")) { Printv(pm, tab4, "\">=\" => sub { $_[0]->__ge__($_[1])},\n",NIL); } else if (strstr(name, "__not__")) { Printv(pm, tab4, "\"!\" => sub { $_[0]->__not__()},\n",NIL); } else if (strstr(name, "__lt__")) { Printv(pm, tab4, "\"<\" => sub { $_[0]->__lt__($_[1])},\n",NIL); } else if (strstr(name, "__le__")) { Printv(pm, tab4, "\"<=\" => sub { $_[0]->__le__($_[1])},\n",NIL); } else if (strstr(name, "__pluseq__")) { Printv(pm, tab4, "\"+=\" => sub { $_[0]->__pluseq__($_[1])},\n",NIL); } else if (strstr(name, "__mineq__")) { Printv(pm, tab4, "\"-=\" => sub { $_[0]->__mineq__($_[1])},\n",NIL); } else if (strstr(name, "__neg__")) { Printv(pm, tab4, "\"neg\" => sub { $_[0]->__neg__()},\n",NIL); } else { fprintf(stderr,"Unknown operator: %s\n", name); } } Printv(pm, tab4, "\"=\" => sub { my $class = ref($_[0]); $class->new($_[0]) },\n", NIL); Printv(pm, tab4, "\"fallback\" => 1;\n", NIL); } // make use strict happy Printv(pm, "use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);\n", NIL); /* If we are inheriting from a base class, set that up */ Printv(pm, "@ISA = qw(", NIL); /* Handle inheritance */ List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist)) { Iterator b; b = First(baselist); while (b.item) { String *bname = Getattr(b.item, "perl5:proxy"); if (!bname) { b = Next(b); continue; } Printv(pm, " ", bname, NIL); b = Next(b); } } /* Module comes last */ if (!compat || Cmp(namespace_module, fullclassname)) { Printv(pm, " ", namespace_module, NIL); } Printf(pm, " );\n"); /* Dump out a hash table containing the pointers that we own */ Printf(pm, "%%OWNER = ();\n"); if (have_data_members || have_destructor) Printf(pm, "%%ITERATORS = ();\n"); /* Dump out the package methods */ Printv(pm, pcode, NIL); Delete(pcode); /* Output methods for managing ownership */ String *director_disown; if (Getattr(n, "perl5:directordisown")) { director_disown = NewStringf("%s%s($self);\n", tab4, Getattr(n, "perl5:directordisown")); } else { director_disown = NewString(""); } Printv(pm, "sub DISOWN {\n", tab4, "my $self = shift;\n", director_disown, tab4, "my $ptr = tied(%$self);\n", tab4, "delete $OWNER{$ptr};\n", "}\n\n", "sub ACQUIRE {\n", tab4, "my $self = shift;\n", tab4, "my $ptr = tied(%$self);\n", tab4, "$OWNER{$ptr} = 1;\n", "}\n\n", NIL); Delete(director_disown); /* Only output the following methods if a class has member data */ Delete(operators); operators = 0; if (Swig_directorclass(n)) { /* director classes need a way to recover subclass instance attributes */ Node *get_attr = NewHash(); String *mrename; String *symname = Getattr(n, "sym:name"); mrename = Swig_name_disown(NSPACE_TODO, symname); Replaceall(mrename, "disown", "swig_get_attr"); String *type = NewString(getClassType()); String *name = NewString("self"); SwigType_add_pointer(type); Parm *p = NewParm(type, name, n); Delete(name); Delete(type); type = NewString("SV"); SwigType_add_pointer(type); String *action = NewString(""); Printv(action, "{\n", " Swig::Director *director = SWIG_DIRECTOR_CAST(arg1);\n", " result = sv_newmortal();\n" " if (director) sv_setsv(result, director->swig_get_self());\n", "}\n", NIL); Setfile(get_attr, Getfile(n)); Setline(get_attr, Getline(n)); Setattr(get_attr, "wrap:action", action); Setattr(get_attr, "name", mrename); Setattr(get_attr, "sym:name", mrename); Setattr(get_attr, "type", type); Setattr(get_attr, "parms", p); Delete(action); Delete(type); Delete(p); member_func = 1; functionWrapper(get_attr); member_func = 0; Delete(get_attr); Printv(pm, "sub FETCH {\n", tab4, "my ($self,$field) = @_;\n", tab4, "my $member_func = \"swig_${field}_get\";\n", tab4, "if (not $self->can($member_func)) {\n", tab8, "my $h = ", cmodule, "::", mrename, "($self);\n", tab8, "return $h->{$field} if $h;\n", tab4, "}\n", tab4, "return $self->$member_func;\n", "}\n", "\n", "sub STORE {\n", tab4, "my ($self,$field,$newval) = @_;\n", tab4, "my $member_func = \"swig_${field}_set\";\n", tab4, "if (not $self->can($member_func)) {\n", tab8, "my $h = ", cmodule, "::", mrename, "($self);\n", tab8, "return $h->{$field} = $newval if $h;\n", tab4, "}\n", tab4, "return $self->$member_func($newval);\n", "}\n", NIL); Delete(mrename); } } return SWIG_OK; } /* ------------------------------------------------------------ * memberfunctionHandler() * ------------------------------------------------------------ */ virtual int memberfunctionHandler(Node *n) { String *symname = Getattr(n, "sym:name"); member_func = 1; Language::memberfunctionHandler(n); member_func = 0; if ((blessed) && (!Getattr(n, "sym:nextSibling"))) { if (Strstr(symname, "__eq__")) { DohSetInt(operators, "__eq__", 1); have_operators = 1; } else if (Strstr(symname, "__ne__")) { DohSetInt(operators, "__ne__", 1); have_operators = 1; } else if (Strstr(symname, "__assign__")) { DohSetInt(operators, "__assign__", 1); have_operators = 1; } else if (Strstr(symname, "__str__")) { DohSetInt(operators, "__str__", 1); have_operators = 1; } else if (Strstr(symname, "__add__")) { DohSetInt(operators, "__add__", 1); have_operators = 1; } else if (Strstr(symname, "__sub__")) { DohSetInt(operators, "__sub__", 1); have_operators = 1; } else if (Strstr(symname, "__mul__")) { DohSetInt(operators, "__mul__", 1); have_operators = 1; } else if (Strstr(symname, "__div__")) { DohSetInt(operators, "__div__", 1); have_operators = 1; } else if (Strstr(symname, "__mod__")) { DohSetInt(operators, "__mod__", 1); have_operators = 1; } else if (Strstr(symname, "__and__")) { DohSetInt(operators, "__and__", 1); have_operators = 1; } else if (Strstr(symname, "__or__")) { DohSetInt(operators, "__or__", 1); have_operators = 1; } else if (Strstr(symname, "__not__")) { DohSetInt(operators, "__not__", 1); have_operators = 1; } else if (Strstr(symname, "__gt__")) { DohSetInt(operators, "__gt__", 1); have_operators = 1; } else if (Strstr(symname, "__ge__")) { DohSetInt(operators, "__ge__", 1); have_operators = 1; } else if (Strstr(symname, "__lt__")) { DohSetInt(operators, "__lt__", 1); have_operators = 1; } else if (Strstr(symname, "__le__")) { DohSetInt(operators, "__le__", 1); have_operators = 1; } else if (Strstr(symname, "__neg__")) { DohSetInt(operators, "__neg__", 1); have_operators = 1; } else if (Strstr(symname, "__plusplus__")) { DohSetInt(operators, "__plusplus__", 1); have_operators = 1; } else if (Strstr(symname, "__minmin__")) { DohSetInt(operators, "__minmin__", 1); have_operators = 1; } else if (Strstr(symname, "__mineq__")) { DohSetInt(operators, "__mineq__", 1); have_operators = 1; } else if (Strstr(symname, "__pluseq__")) { DohSetInt(operators, "__pluseq__", 1); have_operators = 1; } if (Getattr(n, "feature:shadow")) { String *plcode = perlcode(Getattr(n, "feature:shadow"), 0); String *plaction = NewStringf("%s::%s", cmodule, Swig_name_member(NSPACE_TODO, class_name, symname)); Replaceall(plcode, "$action", plaction); Delete(plaction); Printv(pcode, plcode, NIL); } else { Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL); } } return SWIG_OK; } /* ------------------------------------------------------------ * membervariableHandler() * * Adds an instance member. * ----------------------------------------------------------------------------- */ virtual int membervariableHandler(Node *n) { String *symname = Getattr(n, "sym:name"); /* SwigType *t = Getattr(n,"type"); */ /* Emit a pair of get/set functions for the variable */ member_func = 1; Language::membervariableHandler(n); member_func = 0; if (blessed) { Printv(pcode, "*swig_", symname, "_get = *", cmodule, "::", Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL); Printv(pcode, "*swig_", symname, "_set = *", cmodule, "::", Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL); /* Now we need to generate a little Perl code for this */ /* if (is_shadow(t)) { *//* This is a Perl object that we have already seen. Add an entry to the members list *//* Printv(blessedmembers, tab4, symname, " => '", is_shadow(t), "',\n", NIL); } */ } have_data_members++; return SWIG_OK; } /* ------------------------------------------------------------ * constructorDeclaration() * * Emits a blessed constructor for our class. In addition to our construct * we manage a Perl hash table containing all of the pointers created by * the constructor. This prevents us from accidentally trying to free * something that wasn't necessarily allocated by malloc or new * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { String *symname = Getattr(n, "sym:name"); member_func = 1; Swig_save("perl5:constructorHandler", n, "parms", NIL); if (Swig_directorclass(n)) { Parm *parms = Getattr(n, "parms"); Parm *self; String *name = NewString("self"); String *type = NewString("SV"); SwigType_add_pointer(type); self = NewParm(type, name, n); Delete(type); Delete(name); Setattr(self, "lname", "O"); if (parms) set_nextSibling(self, parms); Setattr(n, "parms", self); Setattr(n, "wrap:self", "1"); Setattr(n, "hidden", "1"); Delete(self); } String *saved_nc = none_comparison; none_comparison = NewStringf("strcmp(SvPV_nolen(ST(0)), \"%s::%s\") != 0", module, class_name); String *saved_director_prot_ctor_code = director_prot_ctor_code; director_prot_ctor_code = NewStringf("if ($comparison) { /* subclassed */\n" " $director_new\n" "} else {\n" "SWIG_exception_fail(SWIG_RuntimeError, \"accessing abstract class or protected constructor\");\n" "}\n"); Language::constructorHandler(n); Delete(none_comparison); none_comparison = saved_nc; Delete(director_prot_ctor_code); director_prot_ctor_code = saved_director_prot_ctor_code; Swig_restore(n); if ((blessed) && (!Getattr(n, "sym:nextSibling"))) { if (Getattr(n, "feature:shadow")) { String *plcode = perlcode(Getattr(n, "feature:shadow"), 0); String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname)); Replaceall(plcode, "$action", plaction); Delete(plaction); Printv(pcode, plcode, NIL); } else { if ((Cmp(symname, class_name) == 0)) { /* Emit a blessed constructor */ Printf(pcode, "sub new {\n"); } else { /* Constructor doesn't match classname so we'll just use the normal name */ Printv(pcode, "sub ", Swig_name_construct(NSPACE_TODO, symname), " {\n", NIL); } const char *pkg = getCurrentClass() && Swig_directorclass(getCurrentClass())? "$_[0]" : "shift"; Printv(pcode, tab4, "my $pkg = ", pkg, ";\n", tab4, "my $self = ", cmodule, "::", Swig_name_construct(NSPACE_TODO, symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL); have_constructor = 1; } } member_func = 0; return SWIG_OK; } /* ------------------------------------------------------------ * destructorHandler() * ------------------------------------------------------------ */ virtual int destructorHandler(Node *n) { String *symname = Getattr(n, "sym:name"); member_func = 1; Language::destructorHandler(n); if (blessed) { if (Getattr(n, "feature:shadow")) { String *plcode = perlcode(Getattr(n, "feature:shadow"), 0); String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname)); Replaceall(plcode, "$action", plaction); Delete(plaction); Printv(pcode, plcode, NIL); } else { Printv(pcode, "sub DESTROY {\n", tab4, "return unless $_[0]->isa('HASH');\n", tab4, "my $self = tied(%{$_[0]});\n", tab4, "return unless defined $self;\n", tab4, "delete $ITERATORS{$self};\n", tab4, "if (exists $OWNER{$self}) {\n", tab8, cmodule, "::", Swig_name_destroy(NSPACE_TODO, symname), "($self);\n", tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", NIL); have_destructor = 1; } } member_func = 0; return SWIG_OK; } /* ------------------------------------------------------------ * staticmemberfunctionHandler() * ------------------------------------------------------------ */ virtual int staticmemberfunctionHandler(Node *n) { member_func = 1; Language::staticmemberfunctionHandler(n); member_func = 0; if ((blessed) && (!Getattr(n, "sym:nextSibling"))) { String *symname = Getattr(n, "sym:name"); Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL); } return SWIG_OK; } /* ------------------------------------------------------------ * staticmembervariableHandler() * ------------------------------------------------------------ */ virtual int staticmembervariableHandler(Node *n) { Language::staticmembervariableHandler(n); if (blessed) { String *symname = Getattr(n, "sym:name"); Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL); } return SWIG_OK; } /* ------------------------------------------------------------ * memberconstantHandler() * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { String *symname = Getattr(n, "sym:name"); int oldblessed = blessed; /* Create a normal constant */ blessed = 0; Language::memberconstantHandler(n); blessed = oldblessed; if (blessed) { Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL); } return SWIG_OK; } /* ------------------------------------------------------------ * pragma() * * Pragma directive. * * %pragma(perl5) code="String" # Includes a string in the .pm file * %pragma(perl5) include="file.pl" # Includes a file in the .pm file * ------------------------------------------------------------ */ virtual int pragmaDirective(Node *n) { String *lang; String *code; String *value; if (!ImportMode) { lang = Getattr(n, "lang"); code = Getattr(n, "name"); value = Getattr(n, "value"); if (Strcmp(lang, "perl5") == 0) { if (Strcmp(code, "code") == 0) { /* Dump the value string into the .pm file */ if (value) { Printf(pragma_include, "%s\n", value); } } else if (Strcmp(code, "include") == 0) { /* Include a file into the .pm file */ if (value) { FILE *f = Swig_include_open(value); if (!f) { Swig_error(input_file, line_number, "Unable to locate file %s\n", value); } else { char buffer[4096]; while (fgets(buffer, 4095, f)) { Printf(pragma_include, "%s", buffer); } fclose(f); } } } else { Swig_error(input_file, line_number, "Unrecognized pragma.\n"); } } } return Language::pragmaDirective(n); } /* ------------------------------------------------------------ * perlcode() - Output perlcode code into the shadow file * ------------------------------------------------------------ */ String *perlcode(String *code, const String *indent) { String *out = NewString(""); String *temp; char *t; if (!indent) indent = ""; temp = NewString(code); t = Char(temp); if (*t == '{') { Delitem(temp, 0); Delitem(temp, DOH_END); } /* Split the input text into lines */ List *clist = SplitLines(temp); Delete(temp); int initial = 0; String *s = 0; Iterator si; /* Get the initial indentation */ for (si = First(clist); si.item; si = Next(si)) { s = si.item; if (Len(s)) { char *c = Char(s); while (*c) { if (!isspace(*c)) break; initial++; c++; } if (*c && !isspace(*c)) break; else { initial = 0; } } } while (si.item) { s = si.item; if (Len(s) > initial) { char *c = Char(s); c += initial; Printv(out, indent, c, "\n", NIL); } else { Printv(out, "\n", NIL); } si = Next(si); } Delete(clist); return out; } /* ------------------------------------------------------------ * insertDirective() * * Hook for %insert directive. * ------------------------------------------------------------ */ virtual int insertDirective(Node *n) { String *code = Getattr(n, "code"); String *section = Getattr(n, "section"); if ((!ImportMode) && (Cmp(section, "perl") == 0)) { Printv(additional_perl_code, code, NIL); } else { Language::insertDirective(n); } return SWIG_OK; } String *runtimeCode() { String *s = NewString(""); String *shead = Swig_include_sys("perlhead.swg"); if (!shead) { Printf(stderr, "*** Unable to open 'perlhead.swg'\n"); } else { Append(s, shead); Delete(shead); } String *serrors = Swig_include_sys("perlerrors.swg"); if (!serrors) { Printf(stderr, "*** Unable to open 'perlerrors.swg'\n"); } else { Append(s, serrors); Delete(serrors); } String *srun = Swig_include_sys("perlrun.swg"); if (!srun) { Printf(stderr, "*** Unable to open 'perlrun.swg'\n"); } else { Append(s, srun); Delete(srun); } return s; } String *defaultExternalRuntimeFilename() { return NewString("swigperlrun.h"); } virtual int classDirectorInit(Node *n) { String *declaration = Swig_director_declaration(n); Printf(f_directors_h, "\n"); Printf(f_directors_h, "%s\n", declaration); Printf(f_directors_h, "public:\n"); Delete(declaration); return Language::classDirectorInit(n); } virtual int classDirectorEnd(Node *n) { if (dirprot_mode()) { /* This implementation uses a std::map. It should be possible to rewrite it using a more elegant way, like copying the Java approach for the 'override' array. But for now, this seems to be the least intrusive way. */ Printf(f_directors_h, "\n"); Printf(f_directors_h, "/* Internal director utilities */\n"); Printf(f_directors_h, "public:\n"); Printf(f_directors_h, " bool swig_get_inner(const char *swig_protected_method_name) const {\n"); Printf(f_directors_h, " std::map::const_iterator iv = swig_inner.find(swig_protected_method_name);\n"); Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n"); Printf(f_directors_h, " }\n"); Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool val) const {\n"); Printf(f_directors_h, " swig_inner[swig_protected_method_name] = val;\n"); Printf(f_directors_h, " }\n"); Printf(f_directors_h, "private:\n"); Printf(f_directors_h, " mutable std::map swig_inner;\n"); } Printf(f_directors_h, "};\n"); return Language::classDirectorEnd(n); } virtual int classDirectorConstructor(Node *n) { Node *parent = Getattr(n, "parentNode"); String *sub = NewString(""); String *decl = Getattr(n, "decl"); String *supername = Swig_class_name(parent); String *classname = NewString(""); Printf(classname, "SwigDirector_%s", supername); /* insert self parameter */ Parm *p; ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("SV"); SwigType_add_pointer(type); p = NewParm(type, NewString("self"), n); set_nextSibling(p, parms); parms = p; if (!Getattr(n, "defaultargs")) { /* constructor */ { Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self) { \n", classname, target, call); Printf(w->def, " SWIG_DIRECTOR_RGTR((%s *)this, this); \n", basetype); Append(w->def, "}\n"); Delete(target); Wrapper_print(w, f_directors); Delete(call); DelWrapper(w); } /* constructor header */ { String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } } Delete(sub); Delete(classname); Delete(supername); Delete(parms); return Language::classDirectorConstructor(n); } virtual int classDirectorMethod(Node *n, Node *parent, String *super) { int is_void = 0; int is_pointer = 0; String *decl = Getattr(n, "decl"); String *name = Getattr(n, "name"); String *classname = Getattr(parent, "sym:name"); String *c_classname = Getattr(parent, "name"); String *symname = Getattr(n, "sym:name"); String *declaration = NewString(""); ParmList *l = Getattr(n, "parms"); Wrapper *w = NewWrapper(); String *tm; String *wrap_args = NewString(""); String *returntype = Getattr(n, "type"); String *value = Getattr(n, "value"); String *storage = Getattr(n, "storage"); bool pure_virtual = false; int status = SWIG_OK; int idx; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; if (Cmp(storage, "virtual") == 0) { if (Cmp(value, "0") == 0) { pure_virtual = true; } } /* determine if the method returns a pointer */ is_pointer = SwigType_ispointer_return(decl); is_void = (!Cmp(returntype, "void") && !is_pointer); /* virtual method definition */ String *target; String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ target = Swig_method_decl(rtype, decl, name, l, 0, 1); Printf(declaration, " virtual %s", target); Delete(target); // Get any exception classes in the throws typemap ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { Parm *p; int gencomma = 0; Append(w->def, " throw("); Append(declaration, " throw("); if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); } String *str = SwigType_str(Getattr(p, "type"), 0); Append(w->def, str); Append(declaration, str); Delete(str); } } Append(w->def, ")"); Append(declaration, ")"); } Append(w->def, " {"); Append(declaration, ";\n"); /* declare method return value * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ if (!is_void) { if (!(ignored_method && !pure_virtual)) { String *cres = SwigType_lstr(returntype, "c_result"); Printf(w->code, "%s;\n", cres); Delete(cres); String *pres = NewStringf("SV *%s", Swig_cresult_name()); Wrapper_add_local(w, Swig_cresult_name(), pres); Delete(pres); } } if (ignored_method) { if (!pure_virtual) { if (!is_void) Printf(w->code, "return "); String *super_call = Swig_method_call(super, l); Printf(w->code, "%s;\n", super_call); Delete(super_call); } else { Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } } else { /* attach typemaps to arguments (C/C++ -> Perl) */ String *parse_args = NewString(""); String *pstack = NewString(""); Swig_director_parms_fixup(l); /* remove the wrapper 'w' since it was producing spurious temps */ Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); Wrapper_add_local(w, "SP", "dSP"); { String *ptype = Copy(getClassType()); SwigType_add_pointer(ptype); String *mangle = SwigType_manglestr(ptype); Wrapper_add_local(w, "self", "SV *self"); Printf(w->code, "self = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE%s, SWIG_SHADOW);\n", mangle); Printf(w->code, "sv_bless(self, gv_stashpv(swig_get_class(), 0));\n"); Delete(mangle); Delete(ptype); Append(pstack, "XPUSHs(self);\n"); } Parm *p; char source[256]; int outputs = 0; if (!is_void) outputs++; /* build argument list and type conversion string */ idx = 0; p = l; while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } /* old style? caused segfaults without the p!=0 check in the for() condition, and seems dangerous in the while loop as well. while (Getattr(p, "tmap:ignore")) { p = Getattr(p, "tmap:ignore:next"); } */ if (Getattr(p, "tmap:directorargout") != 0) outputs++; String *pname = Getattr(p, "name"); String *ptype = Getattr(p, "type"); if ((tm = Getattr(p, "tmap:directorin")) != 0) { sprintf(source, "obj%d", idx++); String *input = NewString(source); Setattr(p, "emit:directorinput", input); Replaceall(tm, "$input", input); Delete(input); Replaceall(tm, "$owner", "0"); Replaceall(tm, "$shadow", "0"); /* Wrapper_add_localv(w, source, "SV *", source, "= 0", NIL); */ Printv(wrap_args, "SV *", source, ";\n", NIL); Printv(wrap_args, tm, "\n", NIL); Putc('O', parse_args); Printv(pstack, "XPUSHs(", source, ");\n", NIL); p = Getattr(p, "tmap:directorin:next"); continue; } else if (Cmp(ptype, "void")) { /* special handling for pointers to other C++ director classes. * ideally this would be left to a typemap, but there is currently no * way to selectively apply the dynamic_cast<> to classes that have * directors. in other words, the type "SwigDirector_$1_lname" only exists * for classes with directors. we avoid the problem here by checking * module.wrap::directormap, but it's not clear how to get a typemap to * do something similar. perhaps a new default typemap (in addition * to SWIGTYPE) called DIRECTORTYPE? */ if (SwigType_ispointer(ptype) || SwigType_isreference(ptype)) { Node *module = Getattr(parent, "module"); Node *target = Swig_directormap(module, ptype); sprintf(source, "obj%d", idx++); String *nonconst = 0; /* strip pointer/reference --- should move to Swig/stype.c */ String *nptype = NewString(Char(ptype) + 2); /* name as pointer */ String *ppname = Copy(pname); if (SwigType_isreference(ptype)) { Insert(ppname, 0, "&"); } /* if necessary, cast away const since Python doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", pname); String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, "Target language argument '%s' discards const in director method %s::%s.\n", SwigType_str(ptype, pname), SwigType_namestr(c_classname), SwigType_namestr(name)); } else { nonconst = Copy(ppname); } Delete(nptype); Delete(ppname); String *mangle = SwigType_manglestr(ptype); if (target) { String *director = NewStringf("director_%s", mangle); Wrapper_add_localv(w, director, "Swig::Director *", director, "= 0", NIL); Wrapper_add_localv(w, source, "SV *", source, "= 0", NIL); Printf(wrap_args, "%s = SWIG_DIRECTOR_CAST(%s);\n", director, nonconst); Printf(wrap_args, "if (!%s) {\n", director); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); Append(wrap_args, "} else {\n"); Printf(wrap_args, "%s = %s->swig_get_self();\n", source, director); Printf(wrap_args, "SvREFCNT_inc((SV *)%s);\n", source); Append(wrap_args, "}\n"); Delete(director); } else { Wrapper_add_localv(w, source, "SV *", source, "= 0", NIL); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); Printf(pstack, "XPUSHs(sv_2mortal(%s));\n", source); } Putc('O', parse_args); Delete(mangle); Delete(nonconst); } else { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_NOWRAP; break; } } p = nextSibling(p); } /* add the method name as a PyString */ String *pyname = Getattr(n, "sym:name"); /* wrap complex arguments to PyObjects */ Printv(w->code, wrap_args, NIL); /* pass the method call on to the Python object */ if (dirprot_mode() && !is_public(n)) { Printf(w->code, "swig_set_inner(\"%s\", true);\n", name); } Append(w->code, "ENTER;\n"); Append(w->code, "SAVETMPS;\n"); Append(w->code, "PUSHMARK(SP);\n"); Append(w->code, pstack); Delete(pstack); Append(w->code, "PUTBACK;\n"); Printf(w->code, "call_method(\"%s\", G_EVAL | G_SCALAR);\n", pyname); if (dirprot_mode() && !is_public(n)) Printf(w->code, "swig_set_inner(\"%s\", false);\n", name); /* exception handling */ tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { tm = Getattr(n, "feature:director:except"); if (tm) tm = Copy(tm); } Append(w->code, "if (SvTRUE(ERRSV)) {\n"); Append(w->code, " PUTBACK;\n FREETMPS;\n LEAVE;\n"); if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { Replaceall(tm, "$error", "ERRSV"); Printv(w->code, Str(tm), "\n", NIL); } else { Printf(w->code, " Swig::DirectorMethodException::raise(ERRSV);\n", classname, pyname); } Append(w->code, "}\n"); Delete(tm); /* * Python method may return a simple object, or a tuple. * for in/out aruments, we have to extract the appropriate PyObjects from the tuple, * then marshal everything back to C/C++ (return value and output arguments). * */ /* marshal return value and other outputs (if any) from PyObject to C/C++ type */ String *cleanup = NewString(""); String *outarg = NewString(""); if (outputs > 1) { Wrapper_add_local(w, "output", "SV *output"); Printf(w->code, "if (count != %d) {\n", outputs); Printf(w->code, " Swig::DirectorTypeMismatchException::raise(\"Perl method %s.%sfailed to return a list.\");\n", classname, pyname); Append(w->code, "}\n"); } idx = 0; /* marshal return value */ if (!is_void) { Append(w->code, "SPAGAIN;\n"); Printf(w->code, "%s = POPs;\n", Swig_cresult_name()); tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); if (tm != 0) { if (outputs > 1) { Printf(w->code, "output = POPs;\n"); Replaceall(tm, "$input", "output"); } else { Replaceall(tm, "$input", Swig_cresult_name()); } char temp[24]; sprintf(temp, "%d", idx); Replaceall(tm, "$argnum", temp); /* TODO check this */ if (Getattr(n, "wrap:disown")) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } Replaceall(tm, "$result", "c_result"); Printv(w->code, tm, "\n", NIL); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_ERROR; } } /* marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { if (outputs > 1) { Printf(w->code, "output = POPs;\n"); Replaceall(tm, "$result", "output"); } else { Replaceall(tm, "$result", Swig_cresult_name()); } Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } Delete(parse_args); Delete(cleanup); Delete(outarg); } if (!ignored_method) { Append(w->code, "PUTBACK;\n"); Append(w->code, "FREETMPS;\n"); Append(w->code, "LEAVE;\n"); } if (!is_void) { if (!(ignored_method && !pure_virtual)) { String *rettype = SwigType_str(returntype, 0); if (!SwigType_isreference(returntype)) { Printf(w->code, "return (%s) c_result;\n", rettype); } else { Printf(w->code, "return (%s) *c_result;\n", rettype); } Delete(rettype); } } Append(w->code, "}\n"); // We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method String *inline_extra_method = NewString(""); if (dirprot_mode() && !is_public(n) && !pure_virtual) { Printv(inline_extra_method, declaration, NIL); String *extra_method_name = NewStringf("%sSwigPublic", name); Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, ";\n", " {\n "); if (!is_void) Printf(inline_extra_method, "return "); String *methodcall = Swig_method_call(super, l); Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Delete(methodcall); Delete(extra_method_name); } /* emit the director method */ if (status == SWIG_OK) { if (!Getattr(n, "defaultargs")) { Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); } } /* clean up */ Delete(wrap_args); Delete(pclassname); DelWrapper(w); return status; } int classDirectorDisown(Node *n) { int rv; member_func = 1; rv = Language::classDirectorDisown(n); member_func = 0; if (rv == SWIG_OK && Swig_directorclass(n)) { String *symname = Getattr(n, "sym:name"); String *disown = Swig_name_disown(NSPACE_TODO, symname); Setattr(n, "perl5:directordisown", NewStringf("%s::%s", cmodule, disown)); } return rv; } int classDirectorDestructor(Node *n) { /* TODO: it would be nice if this didn't have to copy the body of Language::classDirectorDestructor() */ String *DirectorClassName = directorClassName(getCurrentClass()); String *body = NewString("\n"); String *ptype = Copy(getClassType()); SwigType_add_pointer(ptype); String *mangle = SwigType_manglestr(ptype); Printv(body, tab4, "dSP;\n", tab4, "SV *self = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE", mangle, ", SWIG_SHADOW);\n", tab4, "\n", tab4, "sv_bless(self, gv_stashpv(swig_get_class(), 0));\n", tab4, "ENTER;\n", tab4, "SAVETMPS;\n", tab4, "PUSHMARK(SP);\n", tab4, "XPUSHs(self);\n", tab4, "XPUSHs(&PL_sv_yes);\n", tab4, "PUTBACK;\n", tab4, "call_method(\"DESTROY\", G_EVAL | G_VOID);\n", tab4, "FREETMPS;\n", tab4, "LEAVE;\n", NIL); Delete(mangle); Delete(ptype); if (Getattr(n, "throw")) { Printf(f_directors_h, " virtual ~%s() throw ();\n", DirectorClassName); Printf(f_directors, "%s::~%s() throw () {%s}\n\n", DirectorClassName, DirectorClassName, body); } else { Printf(f_directors_h, " virtual ~%s();\n", DirectorClassName); Printf(f_directors, "%s::~%s() {%s}\n\n", DirectorClassName, DirectorClassName, body); } return SWIG_OK; } }; /* ----------------------------------------------------------------------------- * swig_perl5() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_perl5() { return new PERL5(); } extern "C" Language *swig_perl5(void) { return new_swig_perl5(); } swig-3.0.2/Source/Modules/csharp.cxx0000664000175000017500000047263712343605122017242 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * csharp.cxx * * C# language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include // for INT_MAX #include "cparse.h" #include /* Hash type used for upcalls from C/C++ */ typedef DOH UpcallData; class CSHARP:public Language { static const char *usage; const String *empty_string; const String *public_string; const String *protected_string; Hash *swig_types_hash; File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; File *f_wrappers; File *f_init; File *f_directors; File *f_directors_h; List *filenames_list; bool proxy_flag; // Flag for generating proxy classes bool native_function_flag; // Flag for when wrapping a native function bool enum_constant_flag; // Flag for when wrapping an enum or constant bool static_flag; // Flag for when wrapping a static functions or member variables bool variable_wrapper_flag; // Flag for when wrapping a nonstatic member variable bool wrapping_member_flag; // Flag for when wrapping a member variable/enum/const bool global_variable_flag; // Flag for when wrapping a global variable bool old_variable_names; // Flag for old style variable names in the intermediary class bool generate_property_declaration_flag; // Flag for generating properties String *imclass_name; // intermediary class name String *module_class_name; // module class name String *imclass_class_code; // intermediary class code String *proxy_class_def; String *proxy_class_code; String *module_class_code; String *proxy_class_name; // proxy class name String *full_imclass_name; // fully qualified intermediary class name when using nspace feature, otherwise same as imclass_name String *variable_name; //Name of a variable being wrapped String *proxy_class_constants_code; String *module_class_constants_code; String *enum_code; String *dllimport; // DllImport attribute name String *namespce; // Optional namespace name String *imclass_imports; //intermediary class imports from %pragma String *module_imports; //module imports from %pragma String *imclass_baseclass; //inheritance for intermediary class class from %pragma String *module_baseclass; //inheritance for module class from %pragma String *imclass_interfaces; //interfaces for intermediary class class from %pragma String *module_interfaces; //interfaces for module class from %pragma String *imclass_class_modifiers; //class modifiers for intermediary class overriden by %pragma String *module_class_modifiers; //class modifiers for module class overriden by %pragma String *upcasts_code; //C++ casts for inheritance hierarchies C++ code String *imclass_cppcasts_code; //C++ casts up inheritance hierarchies intermediary class code String *director_callback_typedefs; // Director function pointer typedefs for callbacks String *director_callbacks; // Director callback function pointer member variables String *director_delegate_callback; // Director callback method that delegates are set to call String *director_delegate_definitions; // Director delegates definitions in proxy class String *director_delegate_instances; // Director delegates member variables in proxy class String *director_method_types; // Director method types String *director_connect_parms; // Director delegates parameter list for director connect call String *destructor_call; //C++ destructor call if any // Director method stuff: List *dmethods_seq; Hash *dmethods_table; int n_dmethods; int n_directors; int first_class_dmethod; int curr_class_dmethod; int nesting_depth; enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum }; public: /* ----------------------------------------------------------------------------- * CSHARP() * ----------------------------------------------------------------------------- */ CSHARP():empty_string(NewString("")), public_string(NewString("public")), protected_string(NewString("protected")), swig_types_hash(NULL), f_begin(NULL), f_runtime(NULL), f_runtime_h(NULL), f_header(NULL), f_wrappers(NULL), f_init(NULL), f_directors(NULL), f_directors_h(NULL), filenames_list(NULL), proxy_flag(true), native_function_flag(false), enum_constant_flag(false), static_flag(false), variable_wrapper_flag(false), wrapping_member_flag(false), global_variable_flag(false), old_variable_names(false), generate_property_declaration_flag(false), imclass_name(NULL), module_class_name(NULL), imclass_class_code(NULL), proxy_class_def(NULL), proxy_class_code(NULL), module_class_code(NULL), proxy_class_name(NULL), full_imclass_name(NULL), variable_name(NULL), proxy_class_constants_code(NULL), module_class_constants_code(NULL), enum_code(NULL), dllimport(NULL), namespce(NULL), imclass_imports(NULL), module_imports(NULL), imclass_baseclass(NULL), module_baseclass(NULL), imclass_interfaces(NULL), module_interfaces(NULL), imclass_class_modifiers(NULL), module_class_modifiers(NULL), upcasts_code(NULL), imclass_cppcasts_code(NULL), director_callback_typedefs(NULL), director_callbacks(NULL), director_delegate_callback(NULL), director_delegate_definitions(NULL), director_delegate_instances(NULL), director_method_types(NULL), director_connect_parms(NULL), destructor_call(NULL), dmethods_seq(NULL), dmethods_table(NULL), n_dmethods(0), n_directors(0), first_class_dmethod(0), curr_class_dmethod(0), nesting_depth(0){ /* for now, multiple inheritance in directors is disabled, this should be easy to implement though */ director_multiple_inheritance = 0; director_language = 1; } /* ----------------------------------------------------------------------------- * getProxyName() * * Test to see if a type corresponds to something wrapped with a proxy class. * Return NULL if not otherwise the proxy class name, fully qualified with * a namespace if the nspace feature is used. * ----------------------------------------------------------------------------- */ String *getProxyName(SwigType *t) { String *proxyname = NULL; if (proxy_flag) { Node *n = classLookup(t); if (n) { proxyname = Getattr(n, "proxyname"); if (!proxyname) { String *nspace = Getattr(n, "sym:nspace"); String *symname = Copy(Getattr(n, "sym:name")); if (symname && !GetFlag(n, "feature:flatnested")) { for (Node *outer_class = Getattr(n, "nested:outer"); outer_class; outer_class = Getattr(outer_class, "nested:outer")) { Push(symname, "."); Push(symname, Getattr(outer_class, "sym:name")); } } if (nspace) { if (namespce) proxyname = NewStringf("%s.%s.%s", namespce, nspace, symname); else proxyname = NewStringf("%s.%s", nspace, symname); } else { proxyname = Copy(symname); } Setattr(n, "proxyname", proxyname); Delete(proxyname); Delete(symname); } } } return proxyname; } /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { SWIG_library_directory("csharp"); // Look for certain command line options for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-dllimport") == 0) { if (argv[i + 1]) { dllimport = NewString(""); Printf(dllimport, argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-namespace") == 0) { if (argv[i + 1]) { namespce = NewString(""); Printf(namespce, argv[i + 1]); if (Len(namespce) == 0) { Delete(namespce); namespce = 0; } Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if ((strcmp(argv[i], "-noproxy") == 0)) { Swig_mark_arg(i); proxy_flag = false; } else if (strcmp(argv[i], "-oldvarnames") == 0) { Swig_mark_arg(i); old_variable_names = true; } else if (strcmp(argv[i], "-help") == 0) { Printf(stdout, "%s\n", usage); } } } // Add a symbol to the parser for conditional compilation Preprocessor_define("SWIGCSHARP 1", 0); // Add typemap definitions SWIG_typemap_lang("csharp"); SWIG_config_file("csharp.swg"); allow_overloading(); } /* --------------------------------------------------------------------- * top() * --------------------------------------------------------------------- */ virtual int top(Node *n) { // Get any options set in the module directive Node *optionsnode = Getattr(Getattr(n, "module"), "options"); if (optionsnode) { if (Getattr(optionsnode, "imclassname")) imclass_name = Copy(Getattr(optionsnode, "imclassname")); /* check if directors are enabled for this module. note: this * is a "master" switch, without which no director code will be * emitted. %feature("director") statements are also required * to enable directors for individual classes or methods. * * use %module(directors="1") modulename at the start of the * interface file to enable director generation. */ if (Getattr(optionsnode, "directors")) { allow_directors(); } if (Getattr(optionsnode, "dirprot")) { allow_dirprot(); } allow_allprotected(GetFlag(optionsnode, "allprotected")); } /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); String *outfile_h = Getattr(n, "outfile_h"); if (!outfile) { Printf(stderr, "Unable to determine outfile\n"); SWIG_exit(EXIT_FAILURE); } f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } if (directorsEnabled()) { if (!outfile_h) { Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); } } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); f_directors_h = NewString(""); f_directors = NewString(""); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); swig_types_hash = NewHash(); filenames_list = NewList(); // Make the intermediary class and module class names. The intermediary class name can be set in the module directive. if (!imclass_name) { imclass_name = NewStringf("%sPINVOKE", Getattr(n, "name")); module_class_name = Copy(Getattr(n, "name")); } else { // Rename the module name if it is the same as intermediary class name - a backwards compatibility solution if (Cmp(imclass_name, Getattr(n, "name")) == 0) module_class_name = NewStringf("%sModule", Getattr(n, "name")); else module_class_name = Copy(Getattr(n, "name")); } // module class and intermediary classes are always created if (!addSymbol(imclass_name, n)) return SWIG_ERROR; if (!addSymbol(module_class_name, n)) return SWIG_ERROR; imclass_class_code = NewString(""); proxy_class_def = NewString(""); proxy_class_code = NewString(""); module_class_constants_code = NewString(""); imclass_baseclass = NewString(""); imclass_interfaces = NewString(""); imclass_class_modifiers = NewString(""); module_class_code = NewString(""); module_baseclass = NewString(""); module_interfaces = NewString(""); module_imports = NewString(""); module_class_modifiers = NewString(""); imclass_imports = NewString(""); imclass_cppcasts_code = NewString(""); director_connect_parms = NewString(""); upcasts_code = NewString(""); dmethods_seq = NewList(); dmethods_table = NewHash(); n_dmethods = 0; n_directors = 0; if (!dllimport) dllimport = Copy(module_class_name); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGCSHARP\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); /* Emit initial director header and director code: */ Swig_banner(f_directors_h); Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name); Printf(f_directors, "\n\n"); Printf(f_directors, "/* ---------------------------------------------------\n"); Printf(f_directors, " * C++ director class methods\n"); Printf(f_directors, " * --------------------------------------------------- */\n\n"); if (outfile_h) { String *filename = Swig_file_filename(outfile_h); Printf(f_directors, "#include \"%s\"\n\n", filename); Delete(filename); } } Printf(f_runtime, "\n"); Swig_name_register("wrapper", "CSharp_%f"); if (old_variable_names) { Swig_name_register("set", "set_%n%v"); Swig_name_register("get", "get_%n%v"); } Printf(f_wrappers, "\n#ifdef __cplusplus\n"); Printf(f_wrappers, "extern \"C\" {\n"); Printf(f_wrappers, "#endif\n\n"); /* Emit code */ Language::top(n); if (directorsEnabled()) { // Insert director runtime into the f_runtime file (make it occur before %header section) Swig_insert_file("director.swg", f_runtime); } // Generate the intermediary class { String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), imclass_name); File *f_im = NewFile(filen, "w", SWIG_output_files()); if (!f_im) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the intermediary class file emitBanner(f_im); addOpenNamespace(0, f_im); if (imclass_imports) Printf(f_im, "%s\n", imclass_imports); if (Len(imclass_class_modifiers) > 0) Printf(f_im, "%s ", imclass_class_modifiers); Printf(f_im, "%s ", imclass_name); if (imclass_baseclass && *Char(imclass_baseclass)) Printf(f_im, ": %s ", imclass_baseclass); if (Len(imclass_interfaces) > 0) Printv(f_im, "implements ", imclass_interfaces, " ", NIL); Printf(f_im, "{\n"); // Add the intermediary class methods Replaceall(imclass_class_code, "$module", module_class_name); Replaceall(imclass_class_code, "$imclassname", imclass_name); Replaceall(imclass_class_code, "$dllimport", dllimport); Printv(f_im, imclass_class_code, NIL); Printv(f_im, imclass_cppcasts_code, NIL); // Finish off the class Printf(f_im, "}\n"); addCloseNamespace(0, f_im); Delete(f_im); } // Generate the C# module class { String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), module_class_name); File *f_module = NewFile(filen, "w", SWIG_output_files()); if (!f_module) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the module class file emitBanner(f_module); addOpenNamespace(0, f_module); if (module_imports) Printf(f_module, "%s\n", module_imports); if (Len(module_class_modifiers) > 0) Printf(f_module, "%s ", module_class_modifiers); Printf(f_module, "%s ", module_class_name); if (module_baseclass && *Char(module_baseclass)) Printf(f_module, ": %s ", module_baseclass); if (Len(module_interfaces) > 0) Printv(f_module, "implements ", module_interfaces, " ", NIL); Printf(f_module, "{\n"); Replaceall(module_class_code, "$module", module_class_name); Replaceall(module_class_constants_code, "$module", module_class_name); Replaceall(module_class_code, "$imclassname", imclass_name); Replaceall(module_class_constants_code, "$imclassname", imclass_name); Replaceall(module_class_code, "$dllimport", dllimport); Replaceall(module_class_constants_code, "$dllimport", dllimport); // Add the wrapper methods Printv(f_module, module_class_code, NIL); // Write out all the global constants Printv(f_module, module_class_constants_code, NIL); // Finish off the class Printf(f_module, "}\n"); addCloseNamespace(0, f_module); Delete(f_module); } if (upcasts_code) Printv(f_wrappers, upcasts_code, NIL); Printf(f_wrappers, "#ifdef __cplusplus\n"); Printf(f_wrappers, "}\n"); Printf(f_wrappers, "#endif\n"); // Output a C# type wrapper class for each SWIG type for (Iterator swig_type = First(swig_types_hash); swig_type.key; swig_type = Next(swig_type)) { emitTypeWrapperClass(swig_type.key, swig_type.item); } // Check for overwriting file problems on filesystems that are case insensitive Iterator it1; Iterator it2; for (it1 = First(filenames_list); it1.item; it1 = Next(it1)) { String *item1_lower = Swig_string_lower(it1.item); for (it2 = Next(it1); it2.item; it2 = Next(it2)) { String *item2_lower = Swig_string_lower(it2.item); if (it1.item && it2.item) { if (Strcmp(item1_lower, item2_lower) == 0) { Swig_warning(WARN_LANG_PORTABILITY_FILENAME, input_file, line_number, "Portability warning: File %s will be overwritten by %s on case insensitive filesystems such as " "Windows' FAT32 and NTFS unless the class/module name is renamed\n", it1.item, it2.item); } } Delete(item2_lower); } Delete(item1_lower); } Delete(swig_types_hash); swig_types_hash = NULL; Delete(filenames_list); filenames_list = NULL; Delete(imclass_name); imclass_name = NULL; Delete(imclass_class_code); imclass_class_code = NULL; Delete(proxy_class_def); proxy_class_def = NULL; Delete(proxy_class_code); proxy_class_code = NULL; Delete(module_class_constants_code); module_class_constants_code = NULL; Delete(imclass_baseclass); imclass_baseclass = NULL; Delete(imclass_interfaces); imclass_interfaces = NULL; Delete(imclass_class_modifiers); imclass_class_modifiers = NULL; Delete(module_class_name); module_class_name = NULL; Delete(module_class_code); module_class_code = NULL; Delete(module_baseclass); module_baseclass = NULL; Delete(module_interfaces); module_interfaces = NULL; Delete(module_imports); module_imports = NULL; Delete(module_class_modifiers); module_class_modifiers = NULL; Delete(imclass_imports); imclass_imports = NULL; Delete(imclass_cppcasts_code); imclass_cppcasts_code = NULL; Delete(upcasts_code); upcasts_code = NULL; Delete(dmethods_seq); dmethods_seq = NULL; Delete(dmethods_table); dmethods_table = NULL; Delete(namespce); namespce = NULL; n_dmethods = 0; /* Close all of the files */ Dump(f_runtime, f_begin); Dump(f_header, f_begin); if (directorsEnabled()) { Dump(f_directors, f_begin); Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); Delete(f_runtime_h); f_runtime_h = NULL; Delete(f_directors); f_directors = NULL; Delete(f_directors_h); f_directors_h = NULL; } Dump(f_wrappers, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /* ----------------------------------------------------------------------------- * emitBanner() * ----------------------------------------------------------------------------- */ void emitBanner(File *f) { Printf(f, "/* ----------------------------------------------------------------------------\n"); Swig_banner_target_lang(f, " *"); Printf(f, " * ----------------------------------------------------------------------------- */\n\n"); } /*----------------------------------------------------------------------- * Add new director upcall signature *----------------------------------------------------------------------*/ UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *decl, String *overloaded_name) { String *key = NewStringf("%s|%s", imclass_method, decl); ++curr_class_dmethod; String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); n_dmethods++; Hash *new_udata = NewHash(); Append(dmethods_seq, new_udata); Setattr(dmethods_table, key, new_udata); Setattr(new_udata, "method", Copy(class_method)); Setattr(new_udata, "class_methodidx", class_methodidx); Setattr(new_udata, "decl", Copy(decl)); Setattr(new_udata, "overname", Copy(overloaded_name)); Delete(key); return new_udata; } /*----------------------------------------------------------------------- * Get director upcall signature *----------------------------------------------------------------------*/ /* UpcallData * getUpcallMethodData(String *director_class, String *decl) { String *key = NewStringf("%s|%s", director_class, decl); UpcallData *udata = Getattr(dmethods_table, key); Delete(key); return udata; } */ /* ---------------------------------------------------------------------- * nativeWrapper() * ---------------------------------------------------------------------- */ virtual int nativeWrapper(Node *n) { String *wrapname = Getattr(n, "wrap:name"); if (!addSymbol(wrapname, n, imclass_name)) return SWIG_ERROR; if (Getattr(n, "type")) { Swig_save("nativeWrapper", n, "name", NIL); Setattr(n, "name", wrapname); native_function_flag = true; functionWrapper(n); Swig_restore(n); native_function_flag = false; } else { Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name")); } return SWIG_OK; } /* ---------------------------------------------------------------------- * functionWrapper() * ---------------------------------------------------------------------- */ virtual int functionWrapper(Node *n) { String *symname = Getattr(n, "sym:name"); SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *tm; Parm *p; int i; String *c_return_type = NewString(""); String *im_return_type = NewString(""); String *cleanup = NewString(""); String *outarg = NewString(""); String *body = NewString(""); String *im_outattributes = 0; int num_arguments = 0; bool is_void_return; String *overloaded_name = getOverloadedName(n); if (!Getattr(n, "sym:overloaded")) { if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name)) return SWIG_ERROR; } /* The rest of this function deals with generating the intermediary class wrapper function (that wraps a c/c++ function) and generating the PInvoke c code. Each C# wrapper function has a matching PInvoke c function call. */ // A new wrapper function object Wrapper *f = NewWrapper(); // Make a wrapper name for this function String *wname = Swig_name_wrapper(overloaded_name); /* Attach the non-standard typemaps to the parameter list. */ Swig_typemap_attach_parms("ctype", l, f); Swig_typemap_attach_parms("imtype", l, f); /* Get return types */ if ((tm = Swig_typemap_lookup("ctype", n, "", 0))) { String *ctypeout = Getattr(n, "tmap:ctype:out"); // the type in the ctype typemap's out attribute overrides the type in the typemap if (ctypeout) tm = ctypeout; Printf(c_return_type, "%s", tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(t, 0)); } if ((tm = Swig_typemap_lookup("imtype", n, "", 0))) { String *imtypeout = Getattr(n, "tmap:imtype:out"); // the type in the imtype typemap's out attribute overrides the type in the typemap if (imtypeout) tm = imtypeout; Printf(im_return_type, "%s", tm); im_outattributes = Getattr(n, "tmap:imtype:outattributes"); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(t, 0)); } is_void_return = (Cmp(c_return_type, "void") == 0); if (!is_void_return) Wrapper_add_localv(f, "jresult", c_return_type, "jresult", NIL); Printv(f->def, " SWIGEXPORT ", c_return_type, " SWIGSTDCALL ", wname, "(", NIL); // Emit all of the local variables for holding arguments. emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); // Parameter overloading Setattr(n, "wrap:parms", l); Setattr(n, "wrap:name", wname); // Wrappers not wanted for some methods where the parameters cannot be overloaded in C# if (Getattr(n, "sym:overloaded")) { // Emit warnings for the few cases that can't be overloaded in C# and give up on generating wrapper Swig_overload_check(n); if (Getattr(n, "overload:ignore")) { DelWrapper(f); return SWIG_OK; } } Printv(imclass_class_code, "\n [global::System.Runtime.InteropServices.DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); if (im_outattributes) Printf(imclass_class_code, " %s\n", im_outattributes); Printf(imclass_class_code, " public static extern %s %s(", im_return_type, overloaded_name); /* Get number of required and total arguments */ num_arguments = emit_num_arguments(l); int gencomma = 0; // Now walk the function parameter list and generate code to get arguments for (i = 0, p = l; i < num_arguments; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); String *im_param_type = NewString(""); String *c_param_type = NewString(""); String *arg = NewString(""); Printf(arg, "j%s", ln); /* Get the ctype types of the parameter */ if ((tm = Getattr(p, "tmap:ctype"))) { Printv(c_param_type, tm, NIL); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(pt, 0)); } /* Get the intermediary class parameter types of the parameter */ if ((tm = Getattr(p, "tmap:imtype"))) { const String *inattributes = Getattr(p, "tmap:imtype:inattributes"); Printf(im_param_type, "%s%s", inattributes ? inattributes : empty_string, tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to intermediary class method */ if (gencomma) Printf(imclass_class_code, ", "); Printf(imclass_class_code, "%s %s", im_param_type, arg); // Add parameter to C function Printv(f->def, gencomma ? ", " : "", c_param_type, " ", arg, NIL); gencomma = 1; // Get typemap for this argument if ((tm = Getattr(p, "tmap:in"))) { canThrow(n, "in", p); Replaceall(tm, "$source", arg); /* deprecated */ Replaceall(tm, "$target", ln); /* deprecated */ Replaceall(tm, "$arg", arg); /* deprecated? */ Replaceall(tm, "$input", arg); Setattr(p, "emit:input", arg); Printf(f->code, "%s\n", tm); p = Getattr(p, "tmap:in:next"); } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); p = nextSibling(p); } Delete(im_param_type); Delete(c_param_type); Delete(arg); } /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { canThrow(n, "check", p); Replaceall(tm, "$target", Getattr(p, "lname")); /* deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); /* deprecated? */ Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { canThrow(n, "freearg", p); Replaceall(tm, "$source", Getattr(p, "emit:input")); /* deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); /* deprecated? */ Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { canThrow(n, "argout", p); Replaceall(tm, "$source", Getattr(p, "emit:input")); /* deprecated */ Replaceall(tm, "$target", Getattr(p, "lname")); /* deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); /* deprecated? */ Replaceall(tm, "$result", "jresult"); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } // Look for usage of throws typemap and the canthrow flag ParmList *throw_parm_list = NULL; if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { canThrow(n, "throws", p); } } } String *null_attribute = 0; // Now write code to make the function call if (!native_function_flag) { if (Cmp(nodeType(n), "constant") == 0) { // Wrapping a constant hack Swig_save("functionWrapper", n, "wrap:action", NIL); // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value"))); } Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); if (Cmp(nodeType(n), "constant") == 0) Swig_restore(n); /* Return value if necessary */ if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { canThrow(n, "out", n); Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Replaceall(tm, "$target", "jresult"); /* deprecated */ Replaceall(tm, "$result", "jresult"); if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "1"); else Replaceall(tm, "$owner", "0"); Printf(f->code, "%s", tm); null_attribute = Getattr(n, "tmap:out:null"); if (Len(tm)) Printf(f->code, "\n"); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), Getattr(n, "name")); } emit_return_variable(n, t, f); } /* Output argument output code */ Printv(f->code, outarg, NIL); /* Output cleanup code */ Printv(f->code, cleanup, NIL); /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { canThrow(n, "newfree", n); Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if (!native_function_flag) { if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { canThrow(n, "ret", n); Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } /* Finish C function and intermediary class function definitions */ Printf(imclass_class_code, ")"); Printf(imclass_class_code, ";\n"); Printf(f->def, ") {"); if (!is_void_return) Printv(f->code, " return jresult;\n", NIL); Printf(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); /* Substitute the function name */ Replaceall(f->code, "$symname", symname); /* Contract macro modification */ if (Replaceall(f->code, "SWIG_contract_assert(", "SWIG_contract_assert($null, ") > 0) { Setattr(n, "csharp:canthrow", "1"); } if (!null_attribute) Replaceall(f->code, "$null", "0"); else Replaceall(f->code, "$null", null_attribute); /* Dump the function out */ if (!native_function_flag) { Wrapper_print(f, f_wrappers); // Handle %csexception which sets the canthrow attribute if (Getattr(n, "feature:except:canthrow")) Setattr(n, "csharp:canthrow", "1"); // A very simple check (it is not foolproof) to help typemap/feature writers for // throwing C# exceptions from unmanaged code. It checks for the common methods which // set a pending C# exception... the 'canthrow' typemap/feature attribute must be set // so that code which checks for pending exceptions is added in the C# proxy method. if (!Getattr(n, "csharp:canthrow")) { if (Strstr(f->code, "SWIG_exception")) { Swig_warning(WARN_CSHARP_CANTHROW, input_file, line_number, "Unmanaged code contains a call to SWIG_exception and C# code does not handle pending exceptions via the canthrow attribute.\n"); } else if (Strstr(f->code, "SWIG_CSharpSetPendingException")) { Swig_warning(WARN_CSHARP_CANTHROW, input_file, line_number, "Unmanaged code contains a call to a SWIG_CSharpSetPendingException method and C# code does not handle pending exceptions via the canthrow attribute.\n"); } } } if (!(proxy_flag && is_wrapping_class()) && !enum_constant_flag) { moduleClassFunctionHandler(n); } /* * Generate the proxy class properties for public member variables. * Not for enums and constants. */ if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { // Capitalize the first letter in the variable in the getter/setter function name bool getter_flag = Cmp(symname, Swig_name_set(getNSpace(), Swig_name_member(0, getClassPrefix(), variable_name))) != 0; String *getter_setter_name = NewString(""); if (!getter_flag) Printf(getter_setter_name, "set"); else Printf(getter_setter_name, "get"); Putc(toupper((int) *Char(variable_name)), getter_setter_name); Printf(getter_setter_name, "%s", Char(variable_name) + 1); Setattr(n, "proxyfuncname", getter_setter_name); Setattr(n, "imfuncname", symname); proxyClassFunctionHandler(n); Delete(getter_setter_name); } Delete(c_return_type); Delete(im_return_type); Delete(cleanup); Delete(outarg); Delete(body); Delete(overloaded_name); DelWrapper(f); return SWIG_OK; } /* ----------------------------------------------------------------------- * variableWrapper() * ----------------------------------------------------------------------- */ virtual int variableWrapper(Node *n) { Language::variableWrapper(n); return SWIG_OK; } /* ----------------------------------------------------------------------- * globalvariableHandler() * ------------------------------------------------------------------------ */ virtual int globalvariableHandler(Node *n) { generate_property_declaration_flag = true; variable_name = Getattr(n, "sym:name"); global_variable_flag = true; int ret = Language::globalvariableHandler(n); global_variable_flag = false; generate_property_declaration_flag = false; if (proxy_flag) { Printf(module_class_code, "\n }\n\n"); } return ret; } String *getCurrentScopeName(String *nspace) { String *scope = 0; if (nspace || getCurrentClass()) { scope = NewString(""); if (nspace) Printf(scope, "%s", nspace); if (Node* cls = getCurrentClass()) { if (Node *outer = Getattr(cls, "nested:outer")) { String *outerClassesPrefix = Copy(Getattr(outer, "sym:name")); for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) { Push(outerClassesPrefix, "."); Push(outerClassesPrefix, Getattr(outer, "sym:name")); } Printv(scope, nspace ? "." : "", outerClassesPrefix, ".", proxy_class_name, NIL); Delete(outerClassesPrefix); } else Printv(scope, nspace ? "." : "", proxy_class_name, NIL); } } return scope; } /* ---------------------------------------------------------------------- * enumDeclaration() * * C/C++ enums can be mapped in one of 4 ways, depending on the cs:enum feature specified: * 1) Simple enums - simple constant within the proxy class or module class * 2) Typeunsafe enums - simple constant in a C# class (class named after the c++ enum name) * 3) Typesafe enum - typesafe enum pattern (class named after the c++ enum name) * 4) Proper enums - proper C# enum * Anonymous enums always default to 1) * ---------------------------------------------------------------------- */ virtual int enumDeclaration(Node *n) { if (!ImportMode) { if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call if (proxy_flag && !is_wrapping_class()) { // Global enums / enums in a namespace assert(!full_imclass_name); if (!nspace) { full_imclass_name = NewStringf("%s", imclass_name); } else { if (namespce) { full_imclass_name = NewStringf("%s.%s", namespce, imclass_name); } else { full_imclass_name = NewStringf("%s", imclass_name); } } } enum_code = NewString(""); String *symname = Getattr(n, "sym:name"); String *constants_code = (proxy_flag && is_wrapping_class())? proxy_class_constants_code : module_class_constants_code; EnumFeature enum_feature = decodeEnumFeature(n); String *typemap_lookup_type = Getattr(n, "name"); if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum String *scope = getCurrentScopeName(nspace); if (!addSymbol(symname, n, scope)) return SWIG_ERROR; // Pure C# baseclass and interfaces const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE); const String *pure_interfaces = typemapLookup(n, "csinterfaces", typemap_lookup_type, WARN_NONE); // Class attributes const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE); if (csattributes && *Char(csattributes)) Printf(enum_code, "%s\n", csattributes); // Emit the enum Printv(enum_code, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really) " ", symname, (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces ", " : "", pure_interfaces, " {\n", NIL); Delete(scope); } else { // Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort if (symname && !Getattr(n, "unnamedinstance")) Printf(constants_code, " // %s \n", symname); } // Emit each enum item Language::enumDeclaration(n); if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum // Finish the enum declaration // Typemaps are used to generate the enum definition in a similar manner to proxy classes. Printv(enum_code, (enum_feature == ProperEnum) ? "\n" : typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code "}", NIL); Replaceall(enum_code, "$csclassname", symname); // Substitute $enumvalues - intended usage is for typesafe enums if (Getattr(n, "enumvalues")) Replaceall(enum_code, "$enumvalues", Getattr(n, "enumvalues")); else Replaceall(enum_code, "$enumvalues", ""); if (proxy_flag && is_wrapping_class()) { // Enums defined within the C++ class are defined within the proxy class // Add extra indentation Replaceall(enum_code, "\n", "\n "); Replaceall(enum_code, " \n", "\n"); Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { // Global enums are defined in their own file String *output_directory = outputDirectory(nspace); String *filen = NewStringf("%s%s.cs", output_directory, symname); File *f_enum = NewFile(filen, "w", SWIG_output_files()); if (!f_enum) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the enum file emitBanner(f_enum); addOpenNamespace(nspace, f_enum); Printv(f_enum, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", enum_code, "\n", NIL); addCloseNamespace(nspace, f_enum); Delete(f_enum); Delete(output_directory); } } else { // Wrap C++ enum with simple constant Printf(enum_code, "\n"); if (proxy_flag && is_wrapping_class()) Printv(proxy_class_constants_code, enum_code, NIL); else Printv(module_class_constants_code, enum_code, NIL); } Delete(enum_code); enum_code = NULL; if (proxy_flag && !is_wrapping_class()) { Delete(full_imclass_name); full_imclass_name = 0; } } return SWIG_OK; } /* ---------------------------------------------------------------------- * enumvalueDeclaration() * ---------------------------------------------------------------------- */ virtual int enumvalueDeclaration(Node *n) { if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL); String *symname = Getattr(n, "sym:name"); String *value = Getattr(n, "value"); String *name = Getattr(n, "name"); Node *parent = parentNode(n); int unnamedinstance = GetFlag(parent, "unnamedinstance"); String *parent_name = Getattr(parent, "name"); String *nspace = getNSpace(); String *tmpValue; // Strange hack from parent method if (value) tmpValue = NewString(value); else tmpValue = NewString(name); // Note that this is used in enumValue() amongst other places Setattr(n, "value", tmpValue); // Deal with enum values that are not int int swigtype = SwigType_type(Getattr(n, "type")); if (swigtype == T_BOOL) { const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0"; Setattr(n, "enumvalue", val); } else if (swigtype == T_CHAR) { String *val = NewStringf("'%s'", Getattr(n, "enumvalue")); Setattr(n, "enumvalue", val); Delete(val); } { EnumFeature enum_feature = decodeEnumFeature(parent); // Add to language symbol table String *scope = 0; if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) { if (proxy_class_name) { scope = NewString(""); if (nspace) Printf(scope, "%s.", nspace); Printf(scope, "%s", proxy_class_name); } else { scope = Copy(module_class_name); } } else { scope = getCurrentScopeName(nspace); if (!scope) scope = Copy(Getattr(parent, "sym:name")); else Printf(scope, ".%s", Getattr(parent, "sym:name")); } if (!addSymbol(name, n, scope)) return SWIG_ERROR; const String *csattributes = Getattr(n, "feature:cs:attributes"); if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) C/C++ enum with a proper C# enum // Emit the enum item. if (!GetFlag(n, "firstenumitem")) Printf(enum_code, ",\n"); if (csattributes) Printf(enum_code, " %s\n", csattributes); Printf(enum_code, " %s", symname); // Check for the %csconstvalue feature String *value = Getattr(n, "feature:cs:constvalue"); // Note that the enum value must be a true constant and cannot be set from a PINVOKE call, thus no support for %csconst(0) value = value ? value : Getattr(n, "enumvalue"); if (value) { Printf(enum_code, " = %s", value); } } else { // Wrap C/C++ enums with constant integers or use the typesafe enum pattern SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum "); Setattr(n, "type", typemap_lookup_type); const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF); String *return_type = Copy(tm); substituteClassname(typemap_lookup_type, return_type); const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); if (csattributes) Printf(enum_code, " %s\n", csattributes); if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) enum using the typesafe enum pattern if (Getattr(n, "enumvalue")) { String *value = enumValue(n); Printf(enum_code, " %s static readonly %s %s = new %s(\"%s\", %s);\n", methodmods, return_type, symname, return_type, symname, value); Delete(value); } else { Printf(enum_code, " %s static readonly %s %s = new %s(\"%s\");\n", methodmods, return_type, symname, return_type, symname); } } else { // Simple integer constants // Note these are always generated for anonymous enums, no matter what enum_feature is specified // Code generated is the same for SimpleEnum and TypeunsafeEnum -> the class it is generated into is determined later // The %csconst feature determines how the constant value is obtained int const_feature_flag = GetFlag(n, "feature:cs:const"); const char *const_readonly = const_feature_flag ? "const" : "static readonly"; String *value = enumValue(n); Printf(enum_code, " %s %s %s %s = %s;\n", methodmods, const_readonly, return_type, symname, value); Delete(value); } Delete(return_type); } // Add the enum value to the comma separated list being constructed in the enum declaration. String *enumvalues = Getattr(parent, "enumvalues"); if (!enumvalues) Setattr(parent, "enumvalues", Copy(symname)); else Printv(enumvalues, ", ", symname, NIL); Delete(scope); } Delete(tmpValue); Swig_restore(n); return SWIG_OK; } /* ----------------------------------------------------------------------- * constantWrapper() * Used for wrapping constants - #define or %constant. * Also for inline initialised const static primitive type member variables (short, int, double, enums etc). * C# static const variables are generated for these. * If the %csconst(1) feature is used then the C constant value is used to initialise the C# const variable. * If not, a PINVOKE method is generated to get the C constant value for initialisation of the C# const variable. * However, if the %csconstvalue feature is used, it overrides all other ways to generate the initialisation. * Also note that this method might be called for wrapping enum items (when the enum is using %csconst(0)). * ------------------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { String *symname = Getattr(n, "sym:name"); SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *tm; String *return_type = NewString(""); String *constants_code = NewString(""); Swig_save("constantWrapper", n, "value", NIL); Swig_save("constantWrapper", n, "tmap:ctype:out", "tmap:imtype:out", "tmap:cstype:out", "tmap:out:null", "tmap:imtype:outattributes", "tmap:cstype:outattributes", NIL); bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname; if (!is_enum_item) { String *scope = 0; if (proxy_class_name) { String *nspace = getNSpace(); scope = NewString(""); if (nspace) Printf(scope, "%s.", nspace); Printf(scope, "%s", proxy_class_name); } else { scope = Copy(module_class_name); } if (!addSymbol(itemname, n, scope)) return SWIG_ERROR; Delete(scope); } // The %csconst feature determines how the constant value is obtained int const_feature_flag = GetFlag(n, "feature:cs:const"); /* Adjust the enum type for the Swig_typemap_lookup. * We want the same jstype typemap for all the enum items so we use the enum type (parent node). */ if (is_enum_item) { t = Getattr(parentNode(n), "enumtype"); Setattr(n, "type", t); } /* Attach the non-standard typemaps to the parameter list. */ Swig_typemap_attach_parms("cstype", l, NULL); /* Get C# return types */ bool classname_substituted_flag = false; if ((tm = Swig_typemap_lookup("cstype", n, "", 0))) { String *cstypeout = Getattr(n, "tmap:cstype:out"); // the type in the cstype typemap's out attribute overrides the type in the typemap if (cstypeout) tm = cstypeout; classname_substituted_flag = substituteClassname(t, tm); Printf(return_type, "%s", tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(t, 0)); } // Add the stripped quotes back in String *new_value = NewString(""); if (SwigType_type(t) == T_STRING) { Printf(new_value, "\"%s\"", Copy(Getattr(n, "value"))); Setattr(n, "value", new_value); } else if (SwigType_type(t) == T_CHAR) { Printf(new_value, "\'%s\'", Copy(Getattr(n, "value"))); Setattr(n, "value", new_value); } const String *outattributes = Getattr(n, "tmap:cstype:outattributes"); if (outattributes) Printf(constants_code, " %s\n", outattributes); const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); Printf(constants_code, " %s %s %s %s = ", methodmods, (const_feature_flag ? "const" : "static readonly"), return_type, itemname); // Check for the %csconstvalue feature String *value = Getattr(n, "feature:cs:constvalue"); if (value) { Printf(constants_code, "%s;\n", value); } else if (!const_feature_flag) { // Default enum and constant handling will work with any type of C constant and initialises the C# variable from C through a PINVOKE call. if (classname_substituted_flag) { if (SwigType_isenum(t)) { // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on) Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } } else { Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } // Each constant and enum value is wrapped with a separate PInvoke function call SetFlag(n, "feature:immutable"); enum_constant_flag = true; variableWrapper(n); enum_constant_flag = false; } else { // Alternative constant handling will use the C syntax to make a true C# constant and hope that it compiles as C# code if (Getattr(n, "wrappedasconstant")) { if (SwigType_type(t) == T_CHAR) Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value")); else Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value")); } else { Printf(constants_code, "%s;\n", Getattr(n, "value")); } } // Emit the generated code to appropriate place // Enums only emit the intermediate and PINVOKE methods, so no proxy or module class wrapper methods needed if (!is_enum_item) { if (proxy_flag && wrapping_member_flag) Printv(proxy_class_constants_code, constants_code, NIL); else Printv(module_class_constants_code, constants_code, NIL); } // Cleanup Swig_restore(n); Delete(new_value); Delete(return_type); Delete(constants_code); return SWIG_OK; } /* ----------------------------------------------------------------------------- * insertDirective() * ----------------------------------------------------------------------------- */ virtual int insertDirective(Node *n) { String *code = Getattr(n, "code"); Replaceall(code, "$module", module_class_name); Replaceall(code, "$imclassname", imclass_name); Replaceall(code, "$dllimport", dllimport); return Language::insertDirective(n); } /* ----------------------------------------------------------------------------- * pragmaDirective() * * Valid Pragmas: * imclassbase - base (extends) for the intermediary class * imclassclassmodifiers - class modifiers for the intermediary class * imclasscode - text (C# code) is copied verbatim to the intermediary class * imclassimports - import statements for the intermediary class * imclassinterfaces - interface (implements) for the intermediary class * * modulebase - base (extends) for the module class * moduleclassmodifiers - class modifiers for the module class * modulecode - text (C# code) is copied verbatim to the module class * moduleimports - import statements for the module class * moduleinterfaces - interface (implements) for the module class * * ----------------------------------------------------------------------------- */ virtual int pragmaDirective(Node *n) { if (!ImportMode) { String *lang = Getattr(n, "lang"); String *code = Getattr(n, "name"); String *value = Getattr(n, "value"); if (Strcmp(lang, "csharp") == 0) { String *strvalue = NewString(value); Replaceall(strvalue, "\\\"", "\""); if (Strcmp(code, "imclassbase") == 0) { Delete(imclass_baseclass); imclass_baseclass = Copy(strvalue); } else if (Strcmp(code, "imclassclassmodifiers") == 0) { Delete(imclass_class_modifiers); imclass_class_modifiers = Copy(strvalue); } else if (Strcmp(code, "imclasscode") == 0) { Printf(imclass_class_code, "%s\n", strvalue); } else if (Strcmp(code, "imclassimports") == 0) { Delete(imclass_imports); imclass_imports = Copy(strvalue); } else if (Strcmp(code, "imclassinterfaces") == 0) { Delete(imclass_interfaces); imclass_interfaces = Copy(strvalue); } else if (Strcmp(code, "modulebase") == 0) { Delete(module_baseclass); module_baseclass = Copy(strvalue); } else if (Strcmp(code, "moduleclassmodifiers") == 0) { Delete(module_class_modifiers); module_class_modifiers = Copy(strvalue); } else if (Strcmp(code, "modulecode") == 0) { Printf(module_class_code, "%s\n", strvalue); } else if (Strcmp(code, "moduleimports") == 0) { Delete(module_imports); module_imports = Copy(strvalue); } else if (Strcmp(code, "moduleinterfaces") == 0) { Delete(module_interfaces); module_interfaces = Copy(strvalue); } else { Swig_error(input_file, line_number, "Unrecognized pragma.\n"); } Delete(strvalue); } } return Language::pragmaDirective(n); } /* ----------------------------------------------------------------------------- * emitProxyClassDefAndCPPCasts() * ----------------------------------------------------------------------------- */ void emitProxyClassDefAndCPPCasts(Node *n) { String *c_classname = SwigType_namestr(Getattr(n, "name")); String *c_baseclass = NULL; String *baseclass = NULL; String *c_baseclassname = NULL; SwigType *typemap_lookup_type = Getattr(n, "classtypeobj"); bool feature_director = Swig_directorclass(n) ? true : false; bool has_outerclass = Getattr(n, "nested:outer") != 0 && !GetFlag(n, "feature:flatnested"); // Inheritance from pure C# classes Node *attributes = NewHash(); const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE, attributes); bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false; bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false; Delete(attributes); // C++ inheritance if (!purebase_replace) { List *baselist = Getattr(n, "bases"); if (baselist) { Iterator base = First(baselist); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } if (base.item) { c_baseclassname = Getattr(base.item, "name"); baseclass = Copy(getProxyName(c_baseclassname)); if (baseclass) c_baseclass = SwigType_namestr(Getattr(base.item, "name")); base = Next(base); /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { if (GetFlag(base.item, "feature:ignore")) { base = Next(base); continue; } String *proxyclassname = Getattr(n, "classtypeobj"); String *baseclassname = Getattr(base.item, "name"); Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname)); base = Next(base); } } } } bool derived = baseclass && getProxyName(c_baseclassname); if (derived && purebase_notderived) pure_baseclass = empty_string; const String *wanted_base = baseclass ? baseclass : pure_baseclass; if (purebase_replace) { wanted_base = pure_baseclass; derived = false; Delete(baseclass); baseclass = NULL; if (purebase_notderived) Swig_error(Getfile(n), Getline(n), "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); } else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) { Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. " "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass); } // Pure C# interfaces const String *pure_interfaces = typemapLookup(n, derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE); // Start writing the proxy class if (!has_outerclass) Printv(proxy_class_def, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", NIL); // Class attributes const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE); if (csattributes && *Char(csattributes)) Printf(proxy_class_def, "%s\n", csattributes); Printv(proxy_class_def, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $csclassname", // Class name and base class (*Char(wanted_base) || *Char(pure_interfaces)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(pure_interfaces)) ? // Interfaces ", " : "", pure_interfaces, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class NIL); // C++ destructor is wrapped by the Dispose method // Note that the method name is specified in a typemap attribute called methodname String *destruct = NewString(""); const String *tm = NULL; attributes = NewHash(); String *destruct_methodname = NULL; String *destruct_methodmodifiers = NULL; if (derived) { tm = typemapLookup(n, "csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:csdestruct_derived:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct_derived:methodmodifiers"); } else { tm = typemapLookup(n, "csdestruct", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:csdestruct:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct:methodmodifiers"); } if (tm && *Char(tm)) { if (!destruct_methodname) { Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); } if (!destruct_methodmodifiers) { Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in csdestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); } } // Emit the Finalize and Dispose methods if (tm) { // Finalize method if (*Char(destructor_call)) { Printv(proxy_class_def, typemapLookup(n, "csfinalize", typemap_lookup_type, WARN_NONE), NIL); } // Dispose method Printv(destruct, tm, NIL); if (*Char(destructor_call)) Replaceall(destruct, "$imcall", destructor_call); else Replaceall(destruct, "$imcall", "throw new global::System.MethodAccessException(\"C++ destructor does not have public access\")"); if (*Char(destruct)) Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " ", derived ? "override" : "virtual", " void ", destruct_methodname, "() ", destruct, "\n", NIL); } if (feature_director) { // Generate director connect method // put this in classDirectorEnd ??? Printf(proxy_class_code, " private void SwigDirectorConnect() {\n"); int i; for (i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *method = Getattr(udata, "method"); String *methid = Getattr(udata, "class_methodidx"); String *overname = Getattr(udata, "overname"); Printf(proxy_class_code, " if (SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s))\n", method, methid); Printf(proxy_class_code, " swigDelegate%s = new SwigDelegate%s_%s(SwigDirector%s);\n", methid, proxy_class_name, methid, overname); } String *director_connect_method_name = Swig_name_member(getNSpace(), getClassPrefix(), "director_connect"); Printf(proxy_class_code, " %s.%s(swigCPtr", imclass_name, director_connect_method_name); for (i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *methid = Getattr(udata, "class_methodidx"); Printf(proxy_class_code, ", swigDelegate%s", methid); } Printf(proxy_class_code, ");\n"); Printf(proxy_class_code, " }\n"); if (first_class_dmethod < curr_class_dmethod) { // Only emit if there is at least one director method Printf(proxy_class_code, "\n"); Printf(proxy_class_code, " private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes) {\n"); Printf(proxy_class_code, " global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);\n"); Printf(proxy_class_code, " bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(%s));\n", proxy_class_name); /* Could add this code to cover corner case where the GetMethod() returns a method which allows type * promotion, eg it will return foo(double), if looking for foo(int). if (hasDerivedMethod) { hasDerivedMethod = false; if (methodInfo != null) { hasDerivedMethod = true; ParameterInfo[] parameterArray1 = methodInfo.GetParameters(); for (int i=0; i 0) Printv(proxy_class_code, director_delegate_callback, NIL); if (Len(director_delegate_definitions) > 0) Printv(proxy_class_code, "\n", director_delegate_definitions, NIL); if (Len(director_delegate_instances) > 0) Printv(proxy_class_code, "\n", director_delegate_instances, NIL); if (Len(director_method_types) > 0) Printv(proxy_class_code, "\n", director_method_types, NIL); Delete(director_callback_typedefs); director_callback_typedefs = NULL; Delete(director_callbacks); director_callbacks = NULL; Delete(director_delegate_callback); director_delegate_callback = NULL; Delete(director_delegate_definitions); director_delegate_definitions = NULL; Delete(director_delegate_instances); director_delegate_instances = NULL; Delete(director_method_types); director_method_types = NULL; Delete(director_connect_parms); director_connect_parms = NULL; Delete(director_connect_method_name); } Delete(attributes); Delete(destruct); // Emit extra user code Printv(proxy_class_def, typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code "\n", NIL); // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { String *smartptr = Getattr(n, "feature:smartptr"); String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smartptr != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast"); String *wname = Swig_name_wrapper(upcast_method); Printv(imclass_cppcasts_code, "\n [global::System.Runtime.InteropServices.DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); Printf(imclass_cppcasts_code, " public static extern global::System.IntPtr %s(global::System.IntPtr jarg1);\n", upcast_method); Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); if (smartptr) { SwigType *spt = Swig_cparse_type(smartptr); if (spt) { SwigType *smart = SwigType_typedef_resolve_all(spt); Delete(spt); SwigType *bsmart = Copy(smart); SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); Replaceall(bsmart, rclassname, rbaseclass); Delete(rclassname); Delete(rbaseclass); String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(bsmart); Printv(upcasts_code, "SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n", " return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n" "}\n", "\n", NIL); Delete(bsmartnamestr); Delete(smartnamestr); Delete(bsmart); } else { Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, c_classname); } } else { Printv(upcasts_code, "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n", " return (", c_baseclass, " *)jarg1;\n" "}\n", "\n", NIL); } Delete(wname); Delete(upcast_method); } Delete(baseclass); } /* ---------------------------------------------------------------------- * classHandler() * ---------------------------------------------------------------------- */ virtual int classHandler(Node *n) { String *nspace = getNSpace(); File *f_proxy = NULL; // save class local variables String *old_proxy_class_name = proxy_class_name; String *old_full_imclass_name = full_imclass_name; String *old_destructor_call = destructor_call; String *old_proxy_class_constants_code = proxy_class_constants_code; String *old_proxy_class_def = proxy_class_def; String *old_proxy_class_code = proxy_class_code; bool has_outerclass = Getattr(n, "nested:outer") && !GetFlag(n, "feature:flatnested"); if (proxy_flag) { proxy_class_name = NewString(Getattr(n, "sym:name")); if (Node *outer = Getattr(n, "nested:outer")) { String *outerClassesPrefix = Copy(Getattr(outer, "sym:name")); for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) { Push(outerClassesPrefix, "."); Push(outerClassesPrefix, Getattr(outer, "sym:name")); } String *fnspace = nspace ? NewStringf("%s.%s", nspace, outerClassesPrefix) : outerClassesPrefix; if (!addSymbol(proxy_class_name, n, fnspace)) return SWIG_ERROR; if (nspace) Delete(fnspace); Delete(outerClassesPrefix); } else { if (!addSymbol(proxy_class_name, n, nspace)) return SWIG_ERROR; } if (!nspace) { full_imclass_name = NewStringf("%s", imclass_name); if (Cmp(proxy_class_name, imclass_name) == 0) { Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name); SWIG_exit(EXIT_FAILURE); } if (Cmp(proxy_class_name, module_class_name) == 0) { Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name); SWIG_exit(EXIT_FAILURE); } } else { if (namespce) { full_imclass_name = NewStringf("%s.%s", namespce, imclass_name); } else { full_imclass_name = NewStringf("%s", imclass_name); } } // Each outer proxy class goes into a separate file if (!has_outerclass) { String *output_directory = outputDirectory(nspace); String *filen = NewStringf("%s%s.cs", output_directory, proxy_class_name); f_proxy = NewFile(filen, "w", SWIG_output_files()); if (!f_proxy) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the proxy class file emitBanner(f_proxy); addOpenNamespace(nspace, f_proxy); } else ++nesting_depth; proxy_class_def = NewString(""); proxy_class_code = NewString(""); destructor_call = NewString(""); proxy_class_constants_code = NewString(""); } Language::classHandler(n); if (proxy_flag) { emitProxyClassDefAndCPPCasts(n); String *csclazzname = Swig_name_member(getNSpace(), getClassPrefix(), ""); // mangled full proxy class name Replaceall(proxy_class_def, "$csclassname", proxy_class_name); Replaceall(proxy_class_code, "$csclassname", proxy_class_name); Replaceall(proxy_class_constants_code, "$csclassname", proxy_class_name); Replaceall(proxy_class_def, "$csclazzname", csclazzname); Replaceall(proxy_class_code, "$csclazzname", csclazzname); Replaceall(proxy_class_constants_code, "$csclazzname", csclazzname); Replaceall(proxy_class_def, "$module", module_class_name); Replaceall(proxy_class_code, "$module", module_class_name); Replaceall(proxy_class_constants_code, "$module", module_class_name); Replaceall(proxy_class_def, "$imclassname", full_imclass_name); Replaceall(proxy_class_code, "$imclassname", full_imclass_name); Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name); Replaceall(proxy_class_def, "$dllimport", dllimport); Replaceall(proxy_class_code, "$dllimport", dllimport); Replaceall(proxy_class_constants_code, "$dllimport", dllimport); if (!has_outerclass) Printv(f_proxy, proxy_class_def, proxy_class_code, NIL); else { Swig_offset_string(proxy_class_def, nesting_depth); Append(old_proxy_class_code, proxy_class_def); Swig_offset_string(proxy_class_code, nesting_depth); Append(old_proxy_class_code, proxy_class_code); } // Write out all the constants if (Len(proxy_class_constants_code) != 0) { if (!has_outerclass) Printv(f_proxy, proxy_class_constants_code, NIL); else { Swig_offset_string(proxy_class_constants_code, nesting_depth); Append(old_proxy_class_code, proxy_class_constants_code); } } if (!has_outerclass) { Printf(f_proxy, "}\n"); addCloseNamespace(nspace, f_proxy); Delete(f_proxy); f_proxy = NULL; } else { for (int i = 0; i < nesting_depth; ++i) Append(old_proxy_class_code, " "); Append(old_proxy_class_code, "}\n\n"); --nesting_depth; } /* Output the downcast method, if necessary. Note: There's no other really good place to put this code, since Abstract Base Classes (ABCs) can and should have downcasts, making the constructorHandler() a bad place (because ABCs don't get to have constructors emitted.) */ if (GetFlag(n, "feature:javadowncast")) { String *downcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGDowncast"); String *wname = Swig_name_wrapper(downcast_method); String *norm_name = SwigType_namestr(Getattr(n, "name")); Printf(imclass_class_code, " public final static native %s %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method); Wrapper *dcast_wrap = NewWrapper(); Printf(dcast_wrap->def, "SWIGEXPORT jobject SWIGSTDCALL %s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", wname); Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n"); Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n"); Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name); Printf(dcast_wrap->code, " if (obj) director = dynamic_cast(obj);\n"); Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n"); Printf(dcast_wrap->code, " return jresult;\n"); Printf(dcast_wrap->code, "}\n"); Wrapper_print(dcast_wrap, f_wrappers); DelWrapper(dcast_wrap); Delete(norm_name); Delete(wname); Delete(downcast_method); } emitDirectorExtraMethods(n); Delete(csclazzname); Delete(proxy_class_name); proxy_class_name = old_proxy_class_name; Delete(full_imclass_name); full_imclass_name = old_full_imclass_name; Delete(destructor_call); destructor_call = old_destructor_call; Delete(proxy_class_constants_code); proxy_class_constants_code = old_proxy_class_constants_code; Delete(proxy_class_def); proxy_class_def = old_proxy_class_def; Delete(proxy_class_code); proxy_class_code = old_proxy_class_code; } return SWIG_OK; } /* ---------------------------------------------------------------------- * memberfunctionHandler() * ---------------------------------------------------------------------- */ virtual int memberfunctionHandler(Node *n) { Language::memberfunctionHandler(n); if (proxy_flag) { String *overloaded_name = getOverloadedName(n); String *intermediary_function_name = Swig_name_member(getNSpace(), getClassPrefix(), overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); Delete(overloaded_name); } return SWIG_OK; } /* ---------------------------------------------------------------------- * staticmemberfunctionHandler() * ---------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { static_flag = true; Language::staticmemberfunctionHandler(n); if (proxy_flag) { String *overloaded_name = getOverloadedName(n); String *intermediary_function_name = Swig_name_member(getNSpace(), getClassPrefix(), overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); Delete(overloaded_name); } static_flag = false; return SWIG_OK; } /* ----------------------------------------------------------------------------- * proxyClassFunctionHandler() * * Function called for creating a C# wrapper function around a c++ function in the * proxy class. Used for both static and non-static C++ class functions. * C++ class static functions map to C# static functions. * Two extra attributes in the Node must be available. These are "proxyfuncname" - * the name of the C# class proxy function, which in turn will call "imfuncname" - * the intermediary (PInvoke) function name in the intermediary class. * ----------------------------------------------------------------------------- */ void proxyClassFunctionHandler(Node *n) { SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *intermediary_function_name = Getattr(n, "imfuncname"); String *proxy_function_name = Getattr(n, "proxyfuncname"); String *tm; Parm *p; Parm *last_parm = 0; int i; String *imcall = NewString(""); String *return_type = NewString(""); String *function_code = NewString(""); bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); String *terminator_code = NewString(""); if (!proxy_flag) return; // Wrappers not wanted for some methods where the parameters cannot be overloaded in C# if (Getattr(n, "overload:ignore")) return; // Don't generate proxy method for additional explicitcall method used in directors if (GetFlag(n, "explicitcall")) return; if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { l = nextSibling(l); } } /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); Swig_typemap_attach_parms("cstype", l, NULL); Swig_typemap_attach_parms("csin", l, NULL); /* Get return types */ if ((tm = Swig_typemap_lookup("cstype", n, "", 0))) { // Note that in the case of polymorphic (covariant) return types, the method's return type is changed to be the base of the C++ return type SwigType *covariant = Getattr(n, "covariant"); String *cstypeout = Getattr(n, "tmap:cstype:out"); // the type in the cstype typemap's out attribute overrides the type in the typemap if (cstypeout) tm = cstypeout; substituteClassname(covariant ? covariant : t, tm); Printf(return_type, "%s", tm); if (covariant) Swig_warning(WARN_CSHARP_COVARIANT_RET, input_file, line_number, "Covariant return types not supported in C#. Proxy method will return %s.\n", SwigType_str(covariant, 0)); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(t, 0)); } if (wrapping_member_flag && !enum_constant_flag) { // Properties setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), Swig_name_member(0, getClassPrefix(), variable_name))) == 0); if (setter_flag) Swig_typemap_attach_parms("csvarin", l, NULL); } /* Start generating the proxy function */ const String *outattributes = Getattr(n, "tmap:cstype:outattributes"); if (outattributes) Printf(function_code, " %s\n", outattributes); const String *csattributes = Getattr(n, "feature:cs:attributes"); if (csattributes) Printf(function_code, " %s\n", csattributes); const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); if (methodmods) { if (is_smart_pointer()) { // Smart pointer classes do not mirror the inheritance hierarchy of the underlying pointer type, so no virtual/override/new required. String *mmods = Copy(methodmods); Replaceall(mmods, "override", ""); Replaceall(mmods, "virtual", ""); Replaceall(mmods, "new", ""); Chop(mmods); // remove trailing whitespace Printf(function_code, " %s ", mmods); Delete(mmods); } else { Printf(function_code, " %s ", methodmods); } } else { methodmods = (is_public(n) ? public_string : protected_string); Printf(function_code, " %s ", methodmods); if (!is_smart_pointer()) { // Smart pointer classes do not mirror the inheritance hierarchy of the underlying pointer type, so no virtual/override/new required. if (Getattr(n, "override")) Printf(function_code, "override "); else if (checkAttribute(n, "storage", "virtual")) Printf(function_code, "virtual "); if (Getattr(n, "hides")) Printf(function_code, "new "); } } if (static_flag) Printf(function_code, "static "); Printf(function_code, "%s %s(", return_type, proxy_function_name); Printv(imcall, full_imclass_name, ".$imfuncname(", NIL); if (!static_flag) Printf(imcall, "swigCPtr"); emit_mark_varargs(l); int gencomma = !static_flag; /* Output each parameter */ for (i = 0, p = l; p; i++) { /* Ignored varargs */ if (checkAttribute(p, "varargs:ignore", "1")) { p = nextSibling(p); continue; } /* Ignored parameters */ if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } /* Ignore the 'this' argument for variable wrappers */ if (!(variable_wrapper_flag && i == 0)) { SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); if (setter_flag) last_parm = p; /* Get the C# parameter type */ if ((tm = Getattr(p, "tmap:cstype"))) { substituteClassname(pt, tm); const String *inattributes = Getattr(p, "tmap:cstype:inattributes"); Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(pt, 0)); } if (gencomma) Printf(imcall, ", "); String *arg = makeParameterName(n, p, i, setter_flag); // Use typemaps to transform type used in C# wrapper function (in proxy class) to type used in PInvoke function (in intermediary class) if ((tm = Getattr(p, "tmap:csin"))) { substituteClassname(pt, tm); Replaceall(tm, "$csinput", arg); String *pre = Getattr(p, "tmap:csin:pre"); if (pre) { substituteClassname(pt, pre); Replaceall(pre, "$csinput", arg); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:csin:post"); if (post) { substituteClassname(pt, post); Replaceall(post, "$csinput", arg); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } String *terminator = Getattr(p, "tmap:csin:terminator"); if (terminator) { substituteClassname(pt, terminator); Replaceall(terminator, "$csinput", arg); if (Len(terminator_code) > 0) Insert(terminator_code, 0, "\n"); Insert(terminator_code, 0, terminator); } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to proxy function */ if (gencomma >= 2) Printf(function_code, ", "); gencomma = 2; Printf(function_code, "%s %s", param_type, arg); Delete(arg); Delete(param_type); } p = Getattr(p, "tmap:in:next"); } Printf(imcall, ")"); Printf(function_code, ")"); // Transform return type used in PInvoke function (in intermediary class) to type used in C# wrapper function (in proxy class) if ((tm = Swig_typemap_lookup("csout", n, "", 0))) { excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; bool is_terminator_code = Len(terminator_code) > 0; if (is_pre_code || is_post_code || is_terminator_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); Printv(tm, " finally {\n", post_code, "\n }", NIL); } else { Insert(tm, 0, "\n "); } if (is_pre_code) { Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } if (is_terminator_code) { Printv(tm, "\n", terminator_code, NIL); } Insert(tm, 0, "{"); Printf(tm, "\n }"); } if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); // For director methods: generate code to selectively make a normal polymorphic call or // an explicit method call - needed to prevent infinite recursion calls in director methods. Node *explicit_n = Getattr(n, "explicitcallnode"); if (explicit_n) { String *ex_overloaded_name = getOverloadedName(explicit_n); String *ex_intermediary_function_name = Swig_name_member(getNSpace(), getClassPrefix(), ex_overloaded_name); String *ex_imcall = Copy(imcall); Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name); Replaceall(imcall, "$imfuncname", intermediary_function_name); String *excode = NewString(""); Node *directorNode = Getattr(n, "directorNode"); if (directorNode) { UpcallData *udata = Getattr(directorNode, "upcalldata"); String *methid = Getattr(udata, "class_methodidx"); if (!Cmp(return_type, "void")) Printf(excode, "if (SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s)) %s; else %s", proxy_function_name, methid, ex_imcall, imcall); else Printf(excode, "(SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s) ? %s : %s)", proxy_function_name, methid, ex_imcall, imcall); Clear(imcall); Printv(imcall, excode, NIL); } else { // probably an ignored method or nodirector } Delete(excode); Delete(ex_overloaded_name); } else { Replaceall(imcall, "$imfuncname", intermediary_function_name); } Replaceall(tm, "$imcall", imcall); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csout typemap defined for %s\n", SwigType_str(t, 0)); } if (wrapping_member_flag && !enum_constant_flag) { // Properties if (generate_property_declaration_flag) { // Ensure the declaration is generated just once should the property contain both a set and get // Get the C# variable type - obtained differently depending on whether a setter is required. String *variable_type = return_type; if (setter_flag) { assert(last_parm); // (last parameter is the only parameter for properties) /* Get variable type - ensure the variable name is fully resolved during typemap lookup via the symbol table set in NewParmNode */ SwigType *cvariable_type = Getattr(last_parm, "type"); Parm *variable_parm = NewParmNode(cvariable_type, n); if ((tm = Swig_typemap_lookup("cstype", variable_parm, "", 0))) { String *cstypeout = Getattr(variable_parm, "tmap:cstype:out"); // the type in the cstype typemap's out attribute overrides the type in the typemap if (cstypeout) tm = cstypeout; substituteClassname(cvariable_type, tm); variable_type = tm; } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(cvariable_type, 0)); } } const String *csattributes = Getattr(n, "feature:cs:attributes"); if (csattributes) Printf(proxy_class_code, " %s\n", csattributes); const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); if (!methodmods) methodmods = (is_public(n) ? public_string : protected_string); Printf(proxy_class_code, " %s %s%s %s {", methodmods, static_flag ? "static " : "", variable_type, variable_name); } generate_property_declaration_flag = false; if (setter_flag) { // Setter method assert(last_parm); // (last parameter is the only parameter for properties) SwigType *cvariable_type = Getattr(last_parm, "type"); Parm *variable_parm = NewParmNode(cvariable_type, n); if ((tm = Swig_typemap_lookup("csvarin", variable_parm, "", 0))) { substituteClassname(cvariable_type, tm); Replaceall(tm, "$csinput", "value"); Replaceall(tm, "$imcall", imcall); excodeSubstitute(n, tm, "csvarin", variable_parm); Printf(proxy_class_code, "%s", tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csvarin typemap defined for %s\n", SwigType_str(cvariable_type, 0)); } } else { // Getter method if ((tm = Swig_typemap_lookup("csvarout", n, "", 0))) { if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); Replaceall(tm, "$imcall", imcall); excodeSubstitute(n, tm, "csvarout", n); Printf(proxy_class_code, "%s", tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csvarout typemap defined for %s\n", SwigType_str(t, 0)); } } } else { // Normal function call Printf(function_code, " %s\n\n", tm ? (const String *) tm : empty_string); Printv(proxy_class_code, function_code, NIL); } Delete(pre_code); Delete(post_code); Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); } /* ---------------------------------------------------------------------- * constructorHandler() * ---------------------------------------------------------------------- */ virtual int constructorHandler(Node *n) { ParmList *l = Getattr(n, "parms"); String *tm; Parm *p; int i; String *function_code = NewString(""); String *helper_code = NewString(""); // Holds code for the constructor helper method generated only when the csin typemap has code in the pre or post attributes String *helper_args = NewString(""); String *pre_code = NewString(""); String *post_code = NewString(""); String *terminator_code = NewString(""); String *im_return_type = NewString(""); bool feature_director = (parentNode(n) && Swig_directorclass(n)); Language::constructorHandler(n); // Wrappers not wanted for some methods where the parameters cannot be overloaded in C# if (Getattr(n, "overload:ignore")) return SWIG_OK; if (proxy_flag) { String *overloaded_name = getOverloadedName(n); String *mangled_overname = Swig_name_construct(getNSpace(), overloaded_name); String *imcall = NewString(""); const String *csattributes = Getattr(n, "feature:cs:attributes"); if (csattributes) { Printf(function_code, " %s\n", csattributes); Printf(helper_code, " %s\n", csattributes); } const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); tm = Getattr(n, "tmap:imtype"); // typemaps were attached earlier to the node String *imtypeout = Getattr(n, "tmap:imtype:out"); // the type in the imtype typemap's out attribute overrides the type in the typemap if (imtypeout) tm = imtypeout; Printf(im_return_type, "%s", tm); Printf(function_code, " %s %s(", methodmods, proxy_class_name); Printf(helper_code, " static private %s SwigConstruct%s(", im_return_type, proxy_class_name); Printv(imcall, full_imclass_name, ".", mangled_overname, "(", NIL); /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); Swig_typemap_attach_parms("cstype", l, NULL); Swig_typemap_attach_parms("csin", l, NULL); emit_mark_varargs(l); int gencomma = 0; /* Output each parameter */ for (i = 0, p = l; p; i++) { /* Ignored varargs */ if (checkAttribute(p, "varargs:ignore", "1")) { p = nextSibling(p); continue; } /* Ignored parameters */ if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); /* Get the C# parameter type */ if ((tm = Getattr(p, "tmap:cstype"))) { substituteClassname(pt, tm); const String *inattributes = Getattr(p, "tmap:cstype:inattributes"); Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(pt, 0)); } if (gencomma) Printf(imcall, ", "); String *arg = makeParameterName(n, p, i, false); String *cshin = 0; // Use typemaps to transform type used in C# wrapper function (in proxy class) to type used in PInvoke function (in intermediary class) if ((tm = Getattr(p, "tmap:csin"))) { substituteClassname(pt, tm); Replaceall(tm, "$csinput", arg); String *pre = Getattr(p, "tmap:csin:pre"); if (pre) { substituteClassname(pt, pre); Replaceall(pre, "$csinput", arg); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:csin:post"); if (post) { substituteClassname(pt, post); Replaceall(post, "$csinput", arg); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } String *terminator = Getattr(p, "tmap:csin:terminator"); if (terminator) { substituteClassname(pt, terminator); Replaceall(terminator, "$csinput", arg); if (Len(terminator_code) > 0) Insert(terminator_code, 0, "\n"); Insert(terminator_code, 0, terminator); } cshin = Getattr(p, "tmap:csin:cshin"); if (cshin) Replaceall(cshin, "$csinput", arg); Printv(imcall, tm, NIL); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to proxy function */ if (gencomma) { Printf(function_code, ", "); Printf(helper_code, ", "); Printf(helper_args, ", "); } Printf(function_code, "%s %s", param_type, arg); Printf(helper_code, "%s %s", param_type, arg); Printf(helper_args, "%s", cshin ? cshin : arg); ++gencomma; Delete(cshin); Delete(arg); Delete(param_type); p = Getattr(p, "tmap:in:next"); } Printf(imcall, ")"); Printf(function_code, ")"); Printf(helper_code, ")"); /* Insert the csconstruct typemap, doing the replacement for $directorconnect, as needed */ Hash *attributes = NewHash(); String *construct_tm = Copy(typemapLookup(n, "csconstruct", Getattr(n, "name"), WARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF, attributes)); if (construct_tm) { if (!feature_director) { Replaceall(construct_tm, "$directorconnect", ""); } else { String *connect_attr = Getattr(attributes, "tmap:csconstruct:directorconnect"); if (connect_attr) { Replaceall(construct_tm, "$directorconnect", connect_attr); } else { Swig_warning(WARN_CSHARP_NO_DIRECTORCONNECT_ATTR, input_file, line_number, "\"directorconnect\" attribute missing in %s \"csconstruct\" typemap.\n", Getattr(n, "name")); Replaceall(construct_tm, "$directorconnect", ""); } } Printv(function_code, " ", construct_tm, NIL); } excodeSubstitute(n, function_code, "csconstruct", attributes); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; bool is_terminator_code = Len(terminator_code) > 0; if (is_pre_code || is_post_code || is_terminator_code) { Printf(helper_code, " {\n"); if (is_pre_code) { Printv(helper_code, pre_code, "\n", NIL); } if (is_post_code) { Printf(helper_code, " try {\n"); Printv(helper_code, " return ", imcall, ";\n", NIL); Printv(helper_code, " } finally {\n", post_code, "\n }", NIL); } else { Printv(helper_code, " return ", imcall, ";", NIL); } if (is_terminator_code) { Printv(helper_code, "\n", terminator_code, NIL); } Printf(helper_code, "\n }\n"); String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args); String *im_outattributes = Getattr(n, "tmap:imtype:outattributes"); if (im_outattributes) Printf(proxy_class_code, " %s\n", im_outattributes); Printv(proxy_class_code, helper_code, "\n", NIL); Replaceall(function_code, "$imcall", helper_name); Delete(helper_name); } else { Replaceall(function_code, "$imcall", imcall); } Printv(proxy_class_code, function_code, "\n", NIL); Delete(helper_args); Delete(im_return_type); Delete(pre_code); Delete(post_code); Delete(terminator_code); Delete(construct_tm); Delete(attributes); Delete(overloaded_name); Delete(imcall); } return SWIG_OK; } /* ---------------------------------------------------------------------- * destructorHandler() * ---------------------------------------------------------------------- */ virtual int destructorHandler(Node *n) { Language::destructorHandler(n); String *symname = Getattr(n, "sym:name"); if (proxy_flag) { Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL); } return SWIG_OK; } /* ---------------------------------------------------------------------- * membervariableHandler() * ---------------------------------------------------------------------- */ virtual int membervariableHandler(Node *n) { generate_property_declaration_flag = true; variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; variable_wrapper_flag = true; Language::membervariableHandler(n); wrapping_member_flag = false; variable_wrapper_flag = false; generate_property_declaration_flag = false; Printf(proxy_class_code, "\n }\n\n"); return SWIG_OK; } /* ---------------------------------------------------------------------- * staticmembervariableHandler() * ---------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { bool static_const_member_flag = (Getattr(n, "value") == 0); generate_property_declaration_flag = true; variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; static_flag = true; Language::staticmembervariableHandler(n); wrapping_member_flag = false; static_flag = false; generate_property_declaration_flag = false; if (static_const_member_flag) Printf(proxy_class_code, "\n }\n\n"); return SWIG_OK; } /* ---------------------------------------------------------------------- * memberconstantHandler() * ---------------------------------------------------------------------- */ virtual int memberconstantHandler(Node *n) { variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; Language::memberconstantHandler(n); wrapping_member_flag = false; return SWIG_OK; } /* ----------------------------------------------------------------------------- * getOverloadedName() * ----------------------------------------------------------------------------- */ String *getOverloadedName(Node *n) { /* A C# HandleRef is used for all classes in the SWIG intermediary class. * The intermediary class methods are thus mangled when overloaded to give * a unique name. */ String *overloaded_name = NewStringf("%s", Getattr(n, "sym:name")); if (Getattr(n, "sym:overloaded")) { Printv(overloaded_name, Getattr(n, "sym:overname"), NIL); } return overloaded_name; } /* ----------------------------------------------------------------------------- * moduleClassFunctionHandler() * ----------------------------------------------------------------------------- */ void moduleClassFunctionHandler(Node *n) { SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *tm; Parm *p; Parm *last_parm = 0; int i; String *imcall = NewString(""); String *return_type = NewString(""); String *function_code = NewString(""); int num_arguments = 0; String *overloaded_name = getOverloadedName(n); String *func_name = NULL; bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); String *terminator_code = NewString(""); if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { l = nextSibling(l); } } /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("cstype", l, NULL); Swig_typemap_attach_parms("csin", l, NULL); /* Get return types */ if ((tm = Swig_typemap_lookup("cstype", n, "", 0))) { String *cstypeout = Getattr(n, "tmap:cstype:out"); // the type in the cstype typemap's out attribute overrides the type in the typemap if (cstypeout) tm = cstypeout; substituteClassname(t, tm); Printf(return_type, "%s", tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(t, 0)); } /* Change function name for global variables */ if (proxy_flag && global_variable_flag) { // Capitalize the first letter in the variable to create the getter/setter function name func_name = NewString(""); setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), variable_name)) == 0); if (setter_flag) Printf(func_name, "set"); else Printf(func_name, "get"); Putc(toupper((int) *Char(variable_name)), func_name); Printf(func_name, "%s", Char(variable_name) + 1); if (setter_flag) Swig_typemap_attach_parms("csvarin", l, NULL); } else { func_name = Copy(Getattr(n, "sym:name")); } /* Start generating the function */ const String *outattributes = Getattr(n, "tmap:cstype:outattributes"); if (outattributes) Printf(function_code, " %s\n", outattributes); const String *csattributes = Getattr(n, "feature:cs:attributes"); if (csattributes) Printf(function_code, " %s\n", csattributes); const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); Printf(function_code, " %s static %s %s(", methodmods, return_type, func_name); Printv(imcall, imclass_name, ".", overloaded_name, "(", NIL); /* Get number of required and total arguments */ num_arguments = emit_num_arguments(l); bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag); int gencomma = 0; /* Output each parameter */ for (i = 0, p = l; i < num_arguments; i++) { /* Ignored parameters */ while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); last_parm = p; /* Get the C# parameter type */ if ((tm = Getattr(p, "tmap:cstype"))) { substituteClassname(pt, tm); const String *inattributes = Getattr(p, "tmap:cstype:inattributes"); Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(pt, 0)); } if (gencomma) Printf(imcall, ", "); String *arg = makeParameterName(n, p, i, global_or_member_variable); // Use typemaps to transform type used in C# wrapper function (in proxy class) to type used in PInvoke function (in intermediary class) if ((tm = Getattr(p, "tmap:csin"))) { substituteClassname(pt, tm); Replaceall(tm, "$csinput", arg); String *pre = Getattr(p, "tmap:csin:pre"); if (pre) { substituteClassname(pt, pre); Replaceall(pre, "$csinput", arg); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:csin:post"); if (post) { substituteClassname(pt, post); Replaceall(post, "$csinput", arg); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } String *terminator = Getattr(p, "tmap:csin:terminator"); if (terminator) { substituteClassname(pt, terminator); Replaceall(terminator, "$csinput", arg); if (Len(terminator_code) > 0) Insert(terminator_code, 0, "\n"); Insert(terminator_code, 0, terminator); } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to module class function */ if (gencomma >= 2) Printf(function_code, ", "); gencomma = 2; Printf(function_code, "%s %s", param_type, arg); p = Getattr(p, "tmap:in:next"); Delete(arg); Delete(param_type); } Printf(imcall, ")"); Printf(function_code, ")"); // Transform return type used in PInvoke function (in intermediary class) to type used in C# wrapper function (in module class) if ((tm = Swig_typemap_lookup("csout", n, "", 0))) { excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; bool is_terminator_code = Len(terminator_code) > 0; if (is_pre_code || is_post_code || is_terminator_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); Printv(tm, " finally {\n", post_code, "\n }", NIL); } else { Insert(tm, 0, "\n "); } if (is_pre_code) { Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } if (is_terminator_code) { Printv(tm, "\n", terminator_code, NIL); } Insert(tm, 0, "{"); Printf(tm, "\n }"); } if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); Replaceall(tm, "$imcall", imcall); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csout typemap defined for %s\n", SwigType_str(t, 0)); } if (proxy_flag && global_variable_flag) { // Properties if (generate_property_declaration_flag) { // Ensure the declaration is generated just once should the property contain both a set and get // Get the C# variable type - obtained differently depending on whether a setter is required. String *variable_type = return_type; if (setter_flag) { p = last_parm; // (last parameter is the only parameter for properties) SwigType *pt = Getattr(p, "type"); if ((tm = Getattr(p, "tmap:cstype"))) { substituteClassname(pt, tm); String *cstypeout = Getattr(p, "tmap:cstype:out"); // the type in the cstype typemap's out attribute overrides the type in the typemap variable_type = cstypeout ? cstypeout : tm; } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csvarin typemap defined for %s\n", SwigType_str(pt, 0)); } } const String *csattributes = Getattr(n, "feature:cs:attributes"); if (csattributes) Printf(module_class_code, " %s\n", csattributes); const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); if (!methodmods) methodmods = (is_public(n) ? public_string : protected_string); Printf(module_class_code, " %s static %s %s {", methodmods, variable_type, variable_name); } generate_property_declaration_flag = false; if (setter_flag) { // Setter method p = last_parm; // (last parameter is the only parameter for properties) SwigType *pt = Getattr(p, "type"); if ((tm = Getattr(p, "tmap:csvarin"))) { substituteClassname(pt, tm); Replaceall(tm, "$csinput", "value"); Replaceall(tm, "$imcall", imcall); excodeSubstitute(n, tm, "csvarin", p); Printf(module_class_code, "%s", tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csvarin typemap defined for %s\n", SwigType_str(pt, 0)); } } else { // Getter method if ((tm = Swig_typemap_lookup("csvarout", n, "", 0))) { if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); Replaceall(tm, "$imcall", imcall); excodeSubstitute(n, tm, "csvarout", n); Printf(module_class_code, "%s", tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csvarout typemap defined for %s\n", SwigType_str(t, 0)); } } } else { // Normal function call Printf(function_code, " %s\n\n", tm ? (const String *) tm : empty_string); Printv(module_class_code, function_code, NIL); } Delete(pre_code); Delete(post_code); Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); Delete(func_name); } /*---------------------------------------------------------------------- * replaceSpecialVariables() *--------------------------------------------------------------------*/ virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) { (void)method; SwigType *type = Getattr(parm, "type"); substituteClassname(type, tm); } /*---------------------------------------------------------------------- * decodeEnumFeature() * Decode the possible enum features, which are one of: * %csenum(simple) * %csenum(typeunsafe) - default * %csenum(typesafe) * %csenum(proper) *--------------------------------------------------------------------*/ EnumFeature decodeEnumFeature(Node *n) { EnumFeature enum_feature = TypeunsafeEnum; String *feature = Getattr(n, "feature:cs:enum"); if (feature) { if (Cmp(feature, "simple") == 0) enum_feature = SimpleEnum; else if (Cmp(feature, "typesafe") == 0) enum_feature = TypesafeEnum; else if (Cmp(feature, "proper") == 0) enum_feature = ProperEnum; } return enum_feature; } /* ----------------------------------------------------------------------- * enumValue() * This method will return a string with an enum value to use in C# generated * code. If the %csconst feature is not used, the string will contain the intermediary * class call to obtain the enum value. The intermediary class and PINVOKE methods to obtain * the enum value will be generated. Otherwise the C/C++ enum value will be used if there * is one and hopefully it will compile as C# code - e.g. 20 as in: enum E{e=20}; * The %csconstvalue feature overrides all other ways to generate the constant value. * The caller must delete memory allocated for the returned string. * ------------------------------------------------------------------------ */ String *enumValue(Node *n) { String *symname = Getattr(n, "sym:name"); // Check for the %csconstvalue feature String *value = Getattr(n, "feature:cs:constvalue"); if (!value) { // The %csconst feature determines how the constant value is obtained int const_feature_flag = GetFlag(n, "feature:cs:const"); if (const_feature_flag) { // Use the C syntax to make a true C# constant and hope that it compiles as C# code value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); } else { // Get the enumvalue from a PINVOKE call if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) { // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } else { memberconstantHandler(n); value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname))); } } } return value; } /* ----------------------------------------------------------------------------- * getEnumName() * ----------------------------------------------------------------------------- */ String *getEnumName(SwigType *t) { Node *enumname = NULL; Node *n = enumLookup(t); if (n) { enumname = Getattr(n, "enumname"); if (!enumname) { String *symname = Getattr(n, "sym:name"); if (symname) { // Add in class scope when referencing enum if not a global enum String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name")); String *proxyname = 0; if (scopename_prefix) { proxyname = getProxyName(scopename_prefix); } if (proxyname) { enumname = NewStringf("%s.%s", proxyname, symname); } else { // global enum or enum in a namespace String *nspace = Getattr(n, "sym:nspace"); if (nspace) { if (namespce) enumname = NewStringf("%s.%s.%s", namespce, nspace, symname); else enumname = NewStringf("%s.%s", nspace, symname); } else { enumname = Copy(symname); } } Setattr(n, "enumname", enumname); Delete(enumname); Delete(scopename_prefix); } } } return enumname; } /* ----------------------------------------------------------------------------- * substituteClassname() * * Substitute the special variable $csclassname with the proxy class name for classes/structs/unions * that SWIG knows about. Also substitutes enums with enum name. * Otherwise use the $descriptor name for the C# class name. Note that the $&csclassname substitution * is the same as a $&descriptor substitution, ie one pointer added to descriptor name. * Inputs: * pt - parameter type * tm - typemap contents that might contain the special variable to be replaced * Outputs: * tm - typemap contents complete with the special variable substitution * Return: * substitution_performed - flag indicating if a substitution was performed * ----------------------------------------------------------------------------- */ bool substituteClassname(SwigType *pt, String *tm) { bool substitution_performed = false; SwigType *type = Copy(SwigType_typedef_resolve_all(pt)); SwigType *strippedtype = SwigType_strip_qualifiers(type); if (Strstr(tm, "$csclassname")) { SwigType *classnametype = Copy(strippedtype); substituteClassnameSpecialVariable(classnametype, tm, "$csclassname"); substitution_performed = true; Delete(classnametype); } if (Strstr(tm, "$*csclassname")) { SwigType *classnametype = Copy(strippedtype); Delete(SwigType_pop(classnametype)); if (Len(classnametype) > 0) { substituteClassnameSpecialVariable(classnametype, tm, "$*csclassname"); substitution_performed = true; } Delete(classnametype); } if (Strstr(tm, "$&csclassname")) { SwigType *classnametype = Copy(strippedtype); SwigType_add_pointer(classnametype); substituteClassnameSpecialVariable(classnametype, tm, "$&csclassname"); substitution_performed = true; Delete(classnametype); } Delete(strippedtype); Delete(type); return substitution_performed; } /* ----------------------------------------------------------------------------- * substituteClassnameSpecialVariable() * ----------------------------------------------------------------------------- */ void substituteClassnameSpecialVariable(SwigType *classnametype, String *tm, const char *classnamespecialvariable) { String *replacementname; if (SwigType_isenum(classnametype)) { String *enumname = getEnumName(classnametype); if (enumname) { replacementname = Copy(enumname); } else { bool anonymous_enum = (Cmp(classnametype, "enum ") == 0); if (anonymous_enum) { replacementname = NewString("int"); } else { // An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) or an ignored enum replacementname = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype)); Replace(replacementname, "enum ", "", DOH_REPLACE_ANY); Setattr(swig_types_hash, replacementname, classnametype); } } } else { String *classname = getProxyName(classnametype); // getProxyName() works for pointers to classes too if (classname) { replacementname = Copy(classname); } else { // use $descriptor if SWIG does not know anything about this type. Note that any typedefs are resolved. replacementname = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype)); // Add to hash table so that the type wrapper classes can be created later Setattr(swig_types_hash, replacementname, classnametype); } } Replaceall(tm, classnamespecialvariable, replacementname); Delete(replacementname); } /* ----------------------------------------------------------------------------- * makeParameterName() * * Inputs: * n - Node * p - parameter node * arg_num - parameter argument number * setter - set this flag when wrapping variables * Return: * arg - a unique parameter name * ----------------------------------------------------------------------------- */ String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) { String *arg = 0; String *pn = Getattr(p, "name"); // Use C parameter name unless it is a duplicate or an empty parameter name int count = 0; ParmList *plist = Getattr(n, "parms"); while (plist) { if ((Cmp(pn, Getattr(plist, "name")) == 0)) count++; plist = nextSibling(plist); } String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); if (setter && Cmp(arg, "self") != 0) { // Note that in C# properties, the input variable name is always called 'value' Delete(arg); arg = NewString("value"); } return arg; } /* ----------------------------------------------------------------------------- * emitTypeWrapperClass() * ----------------------------------------------------------------------------- */ void emitTypeWrapperClass(String *classname, SwigType *type) { Node *n = NewHash(); Setfile(n, input_file); Setline(n, line_number); String *swigtype = NewString(""); String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname); File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); if (!f_swigtype) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the type wrapper class file emitBanner(f_swigtype); addOpenNamespace(0, f_swigtype); // Pure C# baseclass and interfaces const String *pure_baseclass = typemapLookup(n, "csbase", type, WARN_NONE); const String *pure_interfaces = typemapLookup(n, "csinterfaces", type, WARN_NONE); // Emit the class Printv(swigtype, typemapLookup(n, "csimports", type, WARN_NONE), // Import statements "\n", NIL); // Class attributes const String *csattributes = typemapLookup(n, "csattributes", type, WARN_NONE); if (csattributes && *Char(csattributes)) Printf(swigtype, "%s\n", csattributes); Printv(swigtype, typemapLookup(n, "csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $csclassname", // Class name and base class (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces ", " : "", pure_interfaces, " {", typemapLookup(n, "csbody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class typemapLookup(n, "cscode", type, WARN_NONE), // extra C# code "}\n", NIL); Replaceall(swigtype, "$csclassname", classname); Replaceall(swigtype, "$module", module_class_name); Replaceall(swigtype, "$imclassname", imclass_name); Replaceall(swigtype, "$dllimport", dllimport); // For unknown enums Replaceall(swigtype, "$enumvalues", ""); Printv(f_swigtype, swigtype, NIL); addCloseNamespace(0, f_swigtype); Delete(f_swigtype); Delete(swigtype); Delete(n); } /* ----------------------------------------------------------------------------- * typemapLookup() * n - for input only and must contain info for Getfile(n) and Getline(n) to work * tmap_method - typemap method name * type - typemap type to lookup * warning - warning number to issue if no typemaps found * typemap_attributes - the typemap attributes are attached to this node and will * also be used for temporary storage if non null * return is never NULL, unlike Swig_typemap_lookup() * ----------------------------------------------------------------------------- */ const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) { Node *node = !typemap_attributes ? NewHash() : typemap_attributes; Setattr(node, "type", type); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0); if (!tm) { tm = empty_string; if (warning != WARN_NONE) Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0)); } if (!typemap_attributes) Delete(node); return tm; } /* ----------------------------------------------------------------------------- * canThrow() * Determine whether the code in the typemap can throw a C# exception. * If so, note it for later when excodeSubstitute() is called. * ----------------------------------------------------------------------------- */ void canThrow(Node *n, const String *typemap, Node *parameter) { String *canthrow_attribute = NewStringf("tmap:%s:canthrow", typemap); String *canthrow = Getattr(parameter, canthrow_attribute); if (canthrow) Setattr(n, "csharp:canthrow", "1"); Delete(canthrow_attribute); } /* ----------------------------------------------------------------------------- * excodeSubstitute() * If a method can throw a C# exception, additional exception code is added to * check for the pending exception so that it can then throw the exception. The * $excode special variable is replaced by the exception code in the excode * typemap attribute. * ----------------------------------------------------------------------------- */ void excodeSubstitute(Node *n, String *code, const String *typemap, Node *parameter) { String *excode_attribute = NewStringf("tmap:%s:excode", typemap); String *excode = Getattr(parameter, excode_attribute); if (Getattr(n, "csharp:canthrow")) { int count = Replaceall(code, "$excode", excode); if (count < 1 || !excode) { Swig_warning(WARN_CSHARP_EXCODE, input_file, line_number, "C# exception may not be thrown - no $excode or excode attribute in '%s' typemap.\n", typemap); } } else { Replaceall(code, "$excode", empty_string); } Delete(excode_attribute); } /* ----------------------------------------------------------------------------- * addOpenNamespace() * ----------------------------------------------------------------------------- */ void addOpenNamespace(const String *nspace, File *file) { if (namespce || nspace) { Printf(file, "namespace "); if (namespce) Printv(file, namespce, nspace ? "." : "", NIL); if (nspace) Printv(file, nspace, NIL); Printf(file, " {\n"); } } /* ----------------------------------------------------------------------------- * addCloseNamespace() * ----------------------------------------------------------------------------- */ void addCloseNamespace(const String *nspace, File *file) { if (namespce || nspace) Printf(file, "\n}\n"); } /* ----------------------------------------------------------------------------- * outputDirectory() * * Return the directory to use for generating Java classes/enums and create the * subdirectory (does not create if language specific outdir does not exist). * ----------------------------------------------------------------------------- */ String *outputDirectory(String *nspace) { String *output_directory = Copy(SWIG_output_directory()); if (nspace) { String *nspace_subdirectory = Copy(nspace); Replaceall(nspace_subdirectory, ".", SWIG_FILE_DELIMITER); String *newdir_error = Swig_new_subdirectory(output_directory, nspace_subdirectory); if (newdir_error) { Printf(stderr, "%s\n", newdir_error); Delete(newdir_error); SWIG_exit(EXIT_FAILURE); } Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0); Delete(nspace_subdirectory); } return output_directory; } /*---------------------------------------------------------------------- * Start of director methods *--------------------------------------------------------------------*/ #if 0 /*---------------------------------------------------------------------- * emitDirectorUpcalls() *--------------------------------------------------------------------*/ void emitDirectorUpcalls() { if (n_dmethods) { Wrapper *w = NewWrapper(); String *dmethod_data = NewString(""); int n_methods = 0; Iterator udata_iter; udata_iter = First(dmethods_seq); while (udata_iter.item) { UpcallData *udata = udata_iter.item; Printf(dmethod_data, " { \"%s\", \"%s\" }", Getattr(udata, "imclass_method"), Getattr(udata, "imclass_fdesc")); ++n_methods; udata_iter = Next(udata_iter); if (udata_iter.item) Putc(',', dmethod_data); Putc('\n', dmethod_data); } Wrapper_print(w, f_wrappers); Delete(dmethod_data); Delete(swig_module_init); DelWrapper(w); } } #endif /*---------------------------------------------------------------------- * emitDirectorExtraMethods() * * This is where the director connect method is generated. *--------------------------------------------------------------------*/ void emitDirectorExtraMethods(Node *n) { if (!Swig_directorclass(n)) return; // Output the director connect method: String *norm_name = SwigType_namestr(Getattr(n, "name")); String *dirclassname = directorClassName(n); String *swig_director_connect = Swig_name_member(getNSpace(), getClassPrefix(), "director_connect"); String *wname = Swig_name_wrapper(swig_director_connect); String *sym_name = Getattr(n, "sym:name"); String *qualified_classname = Copy(sym_name); String *nspace = getNSpace(); String *dirClassName = directorClassName(n); String *smartptr = Getattr(n, "feature:smartptr"); if (!GetFlag(n, "feature:flatnested")) { for (Node *outer_class = Getattr(n, "nested:outer"); outer_class; outer_class = Getattr(outer_class, "nested:outer")) { Push(qualified_classname, "."); Push(qualified_classname, Getattr(outer_class, "sym:name")); } } if (nspace) Insert(qualified_classname, 0, NewStringf("%s.", nspace)); Printv(imclass_class_code, "\n [global::System.Runtime.InteropServices.DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); Printf(imclass_class_code, " public static extern void %s(global::System.Runtime.InteropServices.HandleRef jarg1", swig_director_connect); Wrapper *code_wrap = NewWrapper(); Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL %s(void *objarg", wname); if (Len(smartptr)) { Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", smartptr, smartptr); Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); } else { Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name); Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); } // TODO: if statement not needed?? - Java too Printf(code_wrap->code, " if (director) {\n"); Printf(code_wrap->code, " director->swig_connect_director("); for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *methid = Getattr(udata, "class_methodidx"); Printf(code_wrap->def, ", "); if (i != first_class_dmethod) Printf(code_wrap->code, ", "); Printf(code_wrap->def, "%s::SWIG_Callback%s_t callback%s", dirclassname, methid, methid); Printf(code_wrap->code, "callback%s", methid); Printf(imclass_class_code, ", %s.SwigDelegate%s_%s delegate%s", qualified_classname, sym_name, methid, methid); } Printf(code_wrap->def, ") {\n"); Printf(code_wrap->code, ");\n"); Printf(imclass_class_code, ");\n"); Printf(code_wrap->code, " }\n"); Printf(code_wrap->code, "}\n"); Wrapper_print(code_wrap, f_wrappers); DelWrapper(code_wrap); Delete(wname); Delete(swig_director_connect); Delete(qualified_classname); Delete(dirclassname); } /* --------------------------------------------------------------- * classDirectorMethod() * * Emit a virtual director method to pass a method call on to the * underlying Java object. * * --------------------------------------------------------------- */ int classDirectorMethod(Node *n, Node *parent, String *super) { String *classname = Getattr(parent, "sym:name"); String *c_classname = Getattr(parent, "name"); String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *returntype = Getattr(n, "type"); String *overloaded_name = getOverloadedName(n); String *storage = Getattr(n, "storage"); String *value = Getattr(n, "value"); String *decl = Getattr(n, "decl"); String *declaration = NewString(""); String *pre_code = NewString(""); String *post_code = NewString(""); String *terminator_code = NewString(""); String *tm; Parm *p; int i; Wrapper *w = NewWrapper(); ParmList *l = Getattr(n, "parms"); bool is_void = !(Cmp(returntype, "void")); String *qualified_return = 0; bool pure_virtual = (!(Cmp(storage, "virtual")) && !(Cmp(value, "0"))); int status = SWIG_OK; bool output_director = true; String *dirclassname = directorClassName(parent); String *qualified_name = NewStringf("%s::%s", dirclassname, name); SwigType *c_ret_type = NULL; String *jupcall_args = NewString(""); String *imclass_dmethod; String *callback_typedef_parms = NewString(""); String *delegate_parms = NewString(""); String *proxy_method_types = NewString(""); String *callback_def = NewString(""); String *callback_code = NewString(""); String *imcall_args = NewString(""); bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; // Kludge Alert: functionWrapper sets sym:overload properly, but it // isn't at this point, so we have to manufacture it ourselves. At least // we're consistent with the sym:overload name in functionWrapper. (?? when // does the overloaded method name get set?) imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), getClassPrefix(), overloaded_name)); qualified_return = SwigType_rcaststr(returntype, "c_result"); if (!is_void && !ignored_method) { if (!SwigType_isclass(returntype)) { if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); Delete(construct_result); } else { String *base_typename = SwigType_base(returntype); String *resolved_typename = SwigType_typedef_resolve_all(base_typename); Symtab *symtab = Getattr(n, "sym:symtab"); Node *typenode = Swig_symbol_clookup(resolved_typename, symtab); if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstracts"))) { /* initialize pointers to something sane. Same for abstract classes when a reference is returned. */ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); } else { /* If returning a reference, initialize the pointer to a sane default - if a C# exception occurs, then the pointer returns something other than a NULL-initialized reference. */ String *non_ref_type = Copy(returntype); /* Remove reference and const qualifiers */ Replaceall(non_ref_type, "r.", ""); Replaceall(non_ref_type, "q(const).", ""); Wrapper_add_localv(w, "result_default", "static", SwigType_str(non_ref_type, "result_default"), "=", SwigType_str(non_ref_type, "()"), NIL); Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= &result_default", NIL); Delete(non_ref_type); } Delete(base_typename); Delete(resolved_typename); } } else { SwigType *vt; vt = cplus_value_type(returntype); if (!vt) { Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL); } else { Wrapper_add_localv(w, "c_result", SwigType_lstr(vt, "c_result"), NIL); Delete(vt); } } } /* Create the intermediate class wrapper */ tm = Swig_typemap_lookup("imtype", n, "", 0); if (tm) { String *imtypeout = Getattr(n, "tmap:imtype:out"); // the type in the imtype typemap's out attribute overrides the type in the typemap if (imtypeout) tm = imtypeout; const String *im_directoroutattributes = Getattr(n, "tmap:imtype:directoroutattributes"); if (im_directoroutattributes) { Printf(callback_def, " %s\n", im_directoroutattributes); if (!ignored_method) Printf(director_delegate_definitions, " %s\n", im_directoroutattributes); } Printf(callback_def, " private %s SwigDirector%s(", tm, overloaded_name); if (!ignored_method) Printf(director_delegate_definitions, " public delegate %s", tm); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0)); } if ((c_ret_type = Swig_typemap_lookup("ctype", n, "", 0))) { if (!is_void && !ignored_method) { String *jretval_decl = NewStringf("%s jresult", c_ret_type); Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL); Delete(jretval_decl); } } else { Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } Swig_director_parms_fixup(l); /* Attach the standard typemaps */ Swig_typemap_attach_parms("out", l, 0); Swig_typemap_attach_parms("ctype", l, 0); Swig_typemap_attach_parms("imtype", l, 0); Swig_typemap_attach_parms("cstype", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("csdirectorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); /* Preamble code */ if (!ignored_method) Printf(w->code, "if (!swig_callback%s) {\n", overloaded_name); if (!pure_virtual) { String *super_call = Swig_method_call(super, l); if (is_void) { Printf(w->code, "%s;\n", super_call); if (!ignored_method) Printf(w->code, "return;\n"); } else { Printf(w->code, "return %s;\n", super_call); } Delete(super_call); } else { Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } if (!ignored_method) Printf(w->code, "} else {\n"); /* Go through argument list, convert from native to Java */ for (i = 0, p = l; p; ++i) { /* Is this superfluous? */ while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } SwigType *pt = Getattr(p, "type"); String *ln = makeParameterName(n, p, i, false); String *c_param_type = NULL; String *c_decl = NewString(""); String *arg = NewString(""); Printf(arg, "j%s", ln); /* And add to the upcall args */ if (i > 0) Printf(jupcall_args, ", "); Printf(jupcall_args, "%s", arg); /* Get parameter's intermediary C type */ if ((c_param_type = Getattr(p, "tmap:ctype"))) { String *ctypeout = Getattr(p, "tmap:ctype:out"); // the type in the ctype typemap's out attribute overrides the type in the typemap if (ctypeout) c_param_type = ctypeout; /* Add to local variables */ Printf(c_decl, "%s %s", c_param_type, arg); if (!ignored_method) Wrapper_add_localv(w, arg, c_decl, (!(SwigType_ispointer(pt) || SwigType_isreference(pt)) ? "" : "= 0"), NIL); /* Add input marshalling code */ if ((tm = Getattr(p, "tmap:directorin"))) { Setattr(p, "emit:directorinput", arg); Replaceall(tm, "$input", arg); Replaceall(tm, "$owner", "0"); if (Len(tm)) if (!ignored_method) Printf(w->code, "%s\n", tm); /* Add C type to callback typedef */ if (i > 0) Printf(callback_typedef_parms, ", "); Printf(callback_typedef_parms, "%s", c_param_type); /* Add parameter to the intermediate class code if generating the * intermediate's upcall code */ if ((tm = Getattr(p, "tmap:imtype"))) { String *imtypeout = Getattr(p, "tmap:imtype:out"); // the type in the imtype typemap's out attribute overrides the type in the typemap if (imtypeout) tm = imtypeout; const String *im_directorinattributes = Getattr(p, "tmap:imtype:directorinattributes"); String *din = Copy(Getattr(p, "tmap:csdirectorin")); if (din) { Replaceall(din, "$module", module_class_name); Replaceall(din, "$imclassname", imclass_name); substituteClassname(pt, din); Replaceall(din, "$iminput", ln); // pre and post attribute support String *pre = Getattr(p, "tmap:csdirectorin:pre"); if (pre) { substituteClassname(pt, pre); Replaceall(pre, "$iminput", ln); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:csdirectorin:post"); if (post) { substituteClassname(pt, post); Replaceall(post, "$iminput", ln); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } String *terminator = Getattr(p, "tmap:csdirectorin:terminator"); if (terminator) { substituteClassname(pt, terminator); Replaceall(terminator, "$iminput", ln); if (Len(terminator_code) > 0) Insert(terminator_code, 0, "\n"); Insert(terminator_code, 0, terminator); } if (i > 0) { Printf(delegate_parms, ", "); Printf(proxy_method_types, ", "); Printf(imcall_args, ", "); } Printf(delegate_parms, "%s%s %s", im_directorinattributes ? im_directorinattributes : empty_string, tm, ln); if (Cmp(din, ln)) { Printv(imcall_args, din, NIL); } else Printv(imcall_args, ln, NIL); /* Get the C# parameter type */ if ((tm = Getattr(p, "tmap:cstype"))) { substituteClassname(pt, tm); if (Strncmp(tm, "ref ", 4) == 0) { Replace(tm, "ref ", "", DOH_REPLACE_FIRST); Printf(proxy_method_types, "typeof(%s).MakeByRefType()", tm); } else if (Strncmp(tm, "out ", 4) == 0) { Replace(tm, "out ", "", DOH_REPLACE_FIRST); Printf(proxy_method_types, "typeof(%s).MakeByRefType()", tm); } else { Printf(proxy_method_types, "typeof(%s)", tm); } } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(pt, 0)); } } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number, "No csdirectorin typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } p = Getattr(p, "tmap:directorin:next"); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = nextSibling(p); output_director = false; } } else { Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; p = nextSibling(p); } Delete(ln); Delete(arg); Delete(c_decl); } /* header declaration, start wrapper definition */ String *target; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); target = Swig_method_decl(rtype, decl, name, l, 0, 1); Printf(declaration, " virtual %s", target); Delete(target); // Add any exception specifications to the methods in the director class ParmList *throw_parm_list = NULL; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { int gencomma = 0; Append(w->def, " throw("); Append(declaration, " throw("); if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); } Printf(w->def, "%s", SwigType_str(Getattr(p, "type"), 0)); Printf(declaration, "%s", SwigType_str(Getattr(p, "type"), 0)); } } Append(w->def, ")"); Append(declaration, ")"); } Append(w->def, " {"); Append(declaration, ";\n"); /* Finish off the inherited upcall's definition */ Printf(callback_def, "%s)", delegate_parms); Printf(callback_def, " {\n"); /* Emit the intermediate class's upcall to the actual class */ String *upcall = NewStringf("%s(%s)", symname, imcall_args); if ((tm = Swig_typemap_lookup("csdirectorout", n, "", 0))) { substituteClassname(returntype, tm); Replaceall(tm, "$cscall", upcall); if (!is_void) Insert(tm, 0, "return "); Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap // pre and post attribute support bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; bool is_terminator_code = Len(terminator_code) > 0; if (is_pre_code && is_post_code) Printf(callback_code, "%s\n try {\n %s;\n } finally {\n%s\n }\n", pre_code, tm, post_code); else if (is_pre_code) Printf(callback_code, "%s\n %s;\n", pre_code, tm); else if (is_post_code) Printf(callback_code, " try {\n %s;\n } finally {\n%s\n }\n", tm, post_code); else Printf(callback_code, " %s;\n", tm); if (is_terminator_code) Printv(callback_code, "\n", terminator_code, NIL); } Printf(callback_code, " }\n"); Delete(upcall); if (!ignored_method) { if (!is_void) Printf(w->code, "jresult = (%s) ", c_ret_type); Printf(w->code, "swig_callback%s(%s);\n", overloaded_name, jupcall_args); if (!is_void) { String *jresult_str = NewString("jresult"); String *result_str = NewString("c_result"); /* Copy jresult into c_result... */ if ((tm = Swig_typemap_lookup("directorout", n, result_str, w))) { Replaceall(tm, "$input", jresult_str); Replaceall(tm, "$result", result_str); Printf(w->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use return type %s used in %s::%s (skipping director method)\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } Delete(jresult_str); Delete(result_str); } /* Marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout"))) { canThrow(n, "directorargout", p); Replaceall(tm, "$result", "jresult"); Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } /* Terminate wrapper code */ Printf(w->code, "}\n"); if (!is_void) Printf(w->code, "return %s;", qualified_return); } Printf(w->code, "}"); // We expose virtual protected methods via an extra public inline method which makes a straight call to the wrapped class' method String *inline_extra_method = NewString(""); if (dirprot_mode() && !is_public(n) && !pure_virtual) { Printv(inline_extra_method, declaration, NIL); String *extra_method_name = NewStringf("%sSwigPublic", name); Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, ";\n", " {\n "); if (!is_void) Printf(inline_extra_method, "return "); String *methodcall = Swig_method_call(super, l); Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Delete(methodcall); Delete(extra_method_name); } /* emit the director method */ if (status == SWIG_OK && output_director) { if (!is_void) { Replaceall(w->code, "$null", qualified_return); } else { Replaceall(w->code, "$null", ""); } if (!ignored_method) Printv(director_delegate_callback, "\n", callback_def, callback_code, NIL); if (!Getattr(n, "defaultargs")) { Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); } } if (!ignored_method) { /* Emit the actual upcall through */ UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, decl, overloaded_name); String *methid = Getattr(udata, "class_methodidx"); Setattr(n, "upcalldata", udata); /* Printf(stdout, "setting upcalldata, nodeType: %s %s::%s %p\n", nodeType(n), classname, Getattr(n, "name"), n); */ Printf(director_callback_typedefs, " typedef %s (SWIGSTDCALL* SWIG_Callback%s_t)(", c_ret_type, methid); Printf(director_callback_typedefs, "%s);\n", callback_typedef_parms); Printf(director_callbacks, " SWIG_Callback%s_t swig_callback%s;\n", methid, overloaded_name); Printf(director_delegate_definitions, " SwigDelegate%s_%s(%s);\n", classname, methid, delegate_parms); Printf(director_delegate_instances, " private SwigDelegate%s_%s swigDelegate%s;\n", classname, methid, methid); Printf(director_method_types, " private static global::System.Type[] swigMethodTypes%s = new global::System.Type[] { %s };\n", methid, proxy_method_types); Printf(director_connect_parms, "SwigDirector%s%s delegate%s", classname, methid, methid); } Delete(pre_code); Delete(post_code); Delete(terminator_code); Delete(qualified_return); Delete(declaration); Delete(callback_typedef_parms); Delete(delegate_parms); Delete(proxy_method_types); Delete(callback_def); Delete(callback_code); Delete(dirclassname); DelWrapper(w); return status; } /* ------------------------------------------------------------ * classDirectorConstructor() * ------------------------------------------------------------ */ int classDirectorConstructor(Node *n) { Node *parent = parentNode(n); String *decl = Getattr(n, "decl"); String *supername = Swig_class_name(parent); String *dirclassname = directorClassName(parent); String *sub = NewString(""); Parm *p; ParmList *superparms = Getattr(n, "parms"); ParmList *parms; int argidx = 0; /* Assign arguments to superclass's parameters, if not already done */ for (p = superparms; p; p = nextSibling(p)) { String *pname = Getattr(p, "name"); if (!pname) { pname = NewStringf("arg%d", argidx++); Setattr(p, "name", pname); } } // TODO: Is this copy needed? parms = CopyParmList(superparms); if (!Getattr(n, "defaultargs")) { /* constructor */ { String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 0); String *call = Swig_csuperclass_call(0, basetype, superparms); Printf(f_directors, "%s::%s : %s, %s {\n", dirclassname, target, call, Getattr(parent, "director:ctor")); Printf(f_directors, " swig_init_callbacks();\n"); Printf(f_directors, "}\n\n"); Delete(target); Delete(call); } /* constructor header */ { String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } } Delete(sub); Delete(supername); Delete(parms); Delete(dirclassname); return Language::classDirectorConstructor(n); } /* ------------------------------------------------------------ * classDirectorDefaultConstructor() * ------------------------------------------------------------ */ int classDirectorDefaultConstructor(Node *n) { String *dirclassname = directorClassName(n); String *classtype = SwigType_namestr(Getattr(n, "name")); Wrapper *w = NewWrapper(); Printf(w->def, "%s::%s() : %s {", dirclassname, dirclassname, Getattr(n, "director:ctor")); Printf(w->code, "}\n"); Wrapper_print(w, f_directors); Printf(f_directors_h, " %s();\n", dirclassname); DelWrapper(w); Delete(classtype); Delete(dirclassname); return Language::classDirectorDefaultConstructor(n); } /* ------------------------------------------------------------ * classDirectorInit() * ------------------------------------------------------------ */ int classDirectorInit(Node *n) { Delete(none_comparison); none_comparison = NewString(""); // not used Delete(director_ctor_code); director_ctor_code = NewString("$director_new"); directorDeclaration(n); Printf(f_directors_h, "%s {\n", Getattr(n, "director:decl")); Printf(f_directors_h, "\npublic:\n"); /* Keep track of the director methods for this class */ first_class_dmethod = curr_class_dmethod = n_dmethods; director_callback_typedefs = NewString(""); director_callbacks = NewString(""); director_delegate_callback = NewString(""); director_delegate_definitions = NewString(""); director_delegate_instances = NewString(""); director_method_types = NewString(""); director_connect_parms = NewString(""); return Language::classDirectorInit(n); } int classDeclaration(Node *n) { String *old_director_callback_typedefs = director_callback_typedefs; String *old_director_callbacks = director_callbacks; String *old_director_delegate_callback = director_delegate_callback; String *old_director_delegate_definitions = director_delegate_definitions; String *old_director_delegate_instances = director_delegate_instances; String *old_director_method_types = director_method_types; String *old_director_connect_parms = director_connect_parms; int ret = Language::classDeclaration(n); // these variables are deleted in emitProxyClassDefAndCPPCasts, hence no Delete here director_callback_typedefs = old_director_callback_typedefs; director_callbacks = old_director_callbacks; director_delegate_callback = old_director_delegate_callback; director_delegate_definitions = old_director_delegate_definitions; director_delegate_instances = old_director_delegate_instances; director_method_types = old_director_method_types; director_connect_parms = old_director_connect_parms; return ret; } /* ---------------------------------------------------------------------- * classDirectorDestructor() * ---------------------------------------------------------------------- */ int classDirectorDestructor(Node *n) { Node *current_class = getCurrentClass(); String *dirclassname = directorClassName(current_class); Wrapper *w = NewWrapper(); if (Getattr(n, "throw")) { Printf(f_directors_h, " virtual ~%s() throw ();\n", dirclassname); Printf(w->def, "%s::~%s() throw () {\n", dirclassname, dirclassname); } else { Printf(f_directors_h, " virtual ~%s();\n", dirclassname); Printf(w->def, "%s::~%s() {\n", dirclassname, dirclassname); } Printv(w->code, "}\n", NIL); Wrapper_print(w, f_directors); DelWrapper(w); Delete(dirclassname); return SWIG_OK; } /* ------------------------------------------------------------ * classDirectorEnd() * ------------------------------------------------------------ */ int classDirectorEnd(Node *n) { int i; String *dirclassname = directorClassName(n); Wrapper *w = NewWrapper(); if (Len(director_callback_typedefs) > 0) { Printf(f_directors_h, "\n%s", director_callback_typedefs); } Printf(f_directors_h, " void swig_connect_director("); Printf(w->def, "void %s::swig_connect_director(", dirclassname); for (i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *methid = Getattr(udata, "class_methodidx"); String *overname = Getattr(udata, "overname"); Printf(f_directors_h, "SWIG_Callback%s_t callback%s", methid, overname); Printf(w->def, "SWIG_Callback%s_t callback%s", methid, overname); Printf(w->code, "swig_callback%s = callback%s;\n", overname, overname); if (i != curr_class_dmethod - 1) { Printf(f_directors_h, ", "); Printf(w->def, ", "); } } Printf(f_directors_h, ");\n"); Printf(w->def, ") {"); if (Len(director_callbacks) > 0) { Printf(f_directors_h, "\nprivate:\n%s", director_callbacks); } Printf(f_directors_h, " void swig_init_callbacks();\n"); Printf(f_directors_h, "};\n\n"); Printf(w->code, "}\n\n"); Printf(w->code, "void %s::swig_init_callbacks() {\n", dirclassname); for (i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *overname = Getattr(udata, "overname"); Printf(w->code, "swig_callback%s = 0;\n", overname); } Printf(w->code, "}"); Wrapper_print(w, f_directors); DelWrapper(w); Delete(dirclassname); return Language::classDirectorEnd(n); } /* -------------------------------------------------------------------- * classDirectorDisown() * ------------------------------------------------------------------*/ virtual int classDirectorDisown(Node *n) { (void) n; return SWIG_OK; } /*---------------------------------------------------------------------- * extraDirectorProtectedCPPMethodsRequired() *--------------------------------------------------------------------*/ bool extraDirectorProtectedCPPMethodsRequired() const { return false; } /*---------------------------------------------------------------------- * directorDeclaration() * * Generate the director class's declaration * e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {" *--------------------------------------------------------------------*/ void directorDeclaration(Node *n) { String *base = Getattr(n, "classtype"); String *class_ctor = NewString("Swig::Director()"); String *dirclassname = directorClassName(n); String *declaration = Swig_class_declaration(n, dirclassname); Printf(declaration, " : public %s, public Swig::Director", base); // Stash stuff for later. Setattr(n, "director:decl", declaration); Setattr(n, "director:ctor", class_ctor); Delete(dirclassname); } NestedClassSupport nestedClassesSupport() const { return NCS_Full; } }; /* class CSHARP */ /* ----------------------------------------------------------------------------- * swig_csharp() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_csharp() { return new CSHARP(); } extern "C" Language *swig_csharp(void) { return new_swig_csharp(); } /* ----------------------------------------------------------------------------- * Static member variables * ----------------------------------------------------------------------------- */ const char *CSHARP::usage = "\ C# Options (available with -csharp)\n\ -dllimport
- Override DllImport attribute name to
\n\ -namespace - Generate wrappers into C# namespace \n\ -noproxy - Generate the low-level functional interface instead\n\ of proxy classes\n\ -oldvarnames - Old intermediary method names for variable wrappers\n\ \n"; swig-3.0.2/Source/Modules/python.cxx0000664000175000017500000055754612343605122017306 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * python.cxx * * Python language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" static int treduce = SWIG_cparse_template_reduce(0); #include #define PYSHADOW_MEMBER 0x2 #define WARN_PYTHON_MULTIPLE_INH 405 static String *const_code = 0; static String *module = 0; static String *package = 0; static String *mainmodule = 0; static String *interface = 0; static String *global_name = 0; static int shadow = 1; static int use_kw = 0; static int director_method_index = 0; static int builtin = 0; static File *f_begin = 0; static File *f_runtime = 0; static File *f_runtime_h = 0; static File *f_header = 0; static File *f_wrappers = 0; static File *f_directors = 0; static File *f_directors_h = 0; static File *f_init = 0; static File *f_shadow_py = 0; static String *f_shadow = 0; static String *f_shadow_begin = 0; static Hash *f_shadow_imports = 0; static String *f_shadow_builtin_imports = 0; static String *f_shadow_stubs = 0; static Hash *builtin_getset = 0; static Hash *class_members = 0; static File *f_builtins = 0; static String *builtin_tp_init = 0; static String *builtin_methods = 0; static String *builtin_default_unref = 0; static String *methods; static String *class_name; static String *shadow_indent = 0; static int in_class = 0; static int classic = 0; static int modern = 0; static int new_repr = 1; static int no_header_file = 0; static int max_bases = 0; static int builtin_bases_needed = 0; static int py3 = 0; /* C++ Support + Shadow Classes */ static int have_constructor; static int have_repr; static String *real_classname; /* Thread Support */ static int threads = 0; static int nothreads = 0; static int classptr = 0; /* Other options */ static int shadowimport = 1; static int buildnone = 0; static int nobuildnone = 0; static int safecstrings = 0; static int dirvtable = 0; static int proxydel = 1; static int fastunpack = 0; static int fastproxy = 0; static int fastquery = 0; static int fastinit = 0; static int olddefs = 0; static int modernargs = 0; static int aliasobj0 = 0; static int castmode = 0; static int extranative = 0; static int outputtuple = 0; static int nortti = 0; static int relativeimport = 0; /* flags for the make_autodoc function */ enum autodoc_t { AUTODOC_CLASS, AUTODOC_CTOR, AUTODOC_DTOR, AUTODOC_STATICFUNC, AUTODOC_FUNC, AUTODOC_METHOD }; static const char *usage1 = "\ Python Options (available with -python)\n\ -aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\ -buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\ -builtin - Create new python built-in types, rather than proxy classes, for better performance\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ -classic - Use classic classes only\n\ -classptr - Generate shadow 'ClassPtr' as in older swig versions\n\ -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ -fastinit - Use fast init mechanism for classes (default)\n\ -fastunpack - Use fast unpack mechanism to parse the argument functions \n\ -fastproxy - Use fast proxy mechanism for member methods \n\ -fastquery - Use fast query mechanism for types \n\ -globals - Set used to access C global variable [default: 'cvar']\n\ -interface - Set the lib name to \n\ -keyword - Use keyword arguments\n\ -modern - Use modern python features only, without compatibility code\n\ -modernargs - Use \"modern\" args mechanism to pack/unpack the function arguments\n"; static const char *usage2 = "\ -newrepr - Use more informative version of __repr__ in proxy classes (default) \n\ -newvwm - New value wrapper mode, use only when everything else fails \n\ -noaliasobj0 - Don't generate an obj0 alias when using fastunpack (default) \n\ -nobuildnone - Access Py_None directly (default in non-Windows systems)\n\ -nocastmode - Disable the casting mode (default)\n\ -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ -noexcept - No automatic exception handling\n\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ -nofastinit - Use traditional init mechanism for classes \n\ -nofastunpack - Use traditional UnpackTuple method to parse the argument functions (default) \n\ -nofastproxy - Use traditional proxy mechanism for member methods (default) \n\ -nofastquery - Use traditional query mechanism for types (default) \n\ -noh - Don't generate the output header file\n\ -nomodern - Don't use modern python features which are not backwards compatible \n\ -nomodernargs - Use classic ParseTuple/CallFunction methods to pack/unpack the function arguments (default) \n"; static const char *usage3 = "\ -noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\ -nooutputtuple - Use a PyList for appending output values (default) \n\ -noproxy - Don't generate proxy classes \n\ -noproxydel - Don't generate the redundant __del__ method \n\ -noproxyimport - Don't insert proxy import statements derived from the %import directive \n\ -nortti - Disable the use of the native C++ RTTI with directors\n\ -nosafecstrings - Avoid extra strings copies when possible (default)\n\ -nothreads - Disable thread support for the entire interface\n\ -olddefs - Keep the old method definitions even when using fastproxy\n\ -oldrepr - Use shorter and old version of __repr__ in proxy classes\n\ -outputtuple - Use a PyTuple for outputs instead of a PyList (use carefully with legacy interfaces) \n\ -proxydel - Generate a __del__ method even though it is now redundant (default) \n\ -relativeimport - Use relative python imports \n\ -safecstrings - Use safer (but slower) C string mapping, generating copies from Python -> C/C++\n\ -threads - Add thread support for all the interface\n\ -O - Enable the following optimization options: \n\ -modern -fastdispatch -nosafecstrings -fvirtual -noproxydel \n\ -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\ -py3 - Generate code with Python 3 specific features:\n\ Function annotation \n\ \n"; static String *getSlot(Node *n = NULL, const char *key = NULL) { static String *slot_default = NewString("0"); String *val = key && *key ? Getattr(n, key) : NULL; return val ? val : slot_default; } static void printSlot(File *f, const String *slotval, const char *slotname, const char *functype = NULL) { String *slotval_override = functype ? NewStringf("(%s) %s", functype, slotval) : 0; if (slotval_override) slotval = slotval_override; int len = Len(slotval); int fieldwidth = len > 40 ? 0 : 40 - len; Printf(f, " %s, %*s/* %s */\n", slotval, fieldwidth, "", slotname); Delete(slotval_override); } static String *getClosure(String *functype, String *wrapper, int funpack = 0) { static const char *functypes[] = { "unaryfunc", "SWIGPY_UNARYFUNC_CLOSURE", "destructor", "SWIGPY_DESTRUCTOR_CLOSURE", "inquiry", "SWIGPY_INQUIRY_CLOSURE", "getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE", "binaryfunc", "SWIGPY_BINARYFUNC_CLOSURE", "ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE", "ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE", "lenfunc", "SWIGPY_LENFUNC_CLOSURE", "ssizeargfunc", "SWIGPY_SSIZEARGFUNC_CLOSURE", "ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE", "ssizeobjargproc", "SWIGPY_SSIZEOBJARGPROC_CLOSURE", "ssizessizeobjargproc", "SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE", "objobjargproc", "SWIGPY_OBJOBJARGPROC_CLOSURE", "reprfunc", "SWIGPY_REPRFUNC_CLOSURE", "hashfunc", "SWIGPY_HASHFUNC_CLOSURE", "iternextfunc", "SWIGPY_ITERNEXT_CLOSURE", NULL }; static const char *funpack_functypes[] = { "unaryfunc", "SWIGPY_UNARYFUNC_CLOSURE", "destructor", "SWIGPY_DESTRUCTOR_CLOSURE", "inquiry", "SWIGPY_INQUIRY_CLOSURE", "getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE", "ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE", "ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE", "lenfunc", "SWIGPY_LENFUNC_CLOSURE", "ssizeargfunc", "SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE", "ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE", "ssizeobjargproc", "SWIGPY_SSIZEOBJARGPROC_CLOSURE", "ssizessizeobjargproc", "SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE", "objobjargproc", "SWIGPY_OBJOBJARGPROC_CLOSURE", "reprfunc", "SWIGPY_REPRFUNC_CLOSURE", "hashfunc", "SWIGPY_HASHFUNC_CLOSURE", "iternextfunc", "SWIGPY_ITERNEXT_CLOSURE", NULL }; if (!functype) return NULL; char *c = Char(functype); int i; if (funpack) { for (i = 0; funpack_functypes[i] != NULL; i += 2) { if (!strcmp(c, funpack_functypes[i])) return NewStringf("%s(%s)", funpack_functypes[i + 1], wrapper); } } else { for (i = 0; functypes[i] != NULL; i += 2) { if (!strcmp(c, functypes[i])) return NewStringf("%s(%s)", functypes[i + 1], wrapper); } } return NULL; } class PYTHON:public Language { public: PYTHON() { /* Add code to manage protected constructors and directors */ director_prot_ctor_code = NewString(""); Printv(director_prot_ctor_code, "if ( $comparison ) { /* subclassed */\n", " $director_new \n", "} else {\n", " SWIG_SetErrorMsg(PyExc_RuntimeError,\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL); director_multiple_inheritance = 1; director_language = 1; } /* ------------------------------------------------------------ * Thread Implementation * ------------------------------------------------------------ */ int threads_enable(Node *n) const { return threads && !GetFlagAttr(n, "feature:nothread"); } int initialize_threads(String *f_init) { if (!threads) { return SWIG_OK; } Printf(f_init, "\n"); Printf(f_init, "/* Initialize threading */\n"); Printf(f_init, "SWIG_PYTHON_INITIALIZE_THREADS;\n"); return SWIG_OK; } virtual void thread_begin_block(Node *n, String *f) { if (!GetFlag(n, "feature:nothreadblock")) { String *bb = Getattr(n, "feature:threadbeginblock"); if (bb) { Append(f, bb); } else { Append(f, "SWIG_PYTHON_THREAD_BEGIN_BLOCK;\n"); } } } virtual void thread_end_block(Node *n, String *f) { if (!GetFlag(n, "feature:nothreadblock")) { String *eb = Getattr(n, "feature:threadendblock"); if (eb) { Append(f, eb); } else { Append(f, "SWIG_PYTHON_THREAD_END_BLOCK;\n"); } } } virtual void thread_begin_allow(Node *n, String *f) { if (!GetFlag(n, "feature:nothreadallow")) { String *bb = Getattr(n, "feature:threadbeginallow"); Append(f, "{\n"); if (bb) { Append(f, bb); } else { Append(f, "SWIG_PYTHON_THREAD_BEGIN_ALLOW;\n"); } } } virtual void thread_end_allow(Node *n, String *f) { if (!GetFlag(n, "feature:nothreadallow")) { String *eb = Getattr(n, "feature:threadendallow"); Append(f, "\n"); if (eb) { Append(f, eb); } else { Append(f, "SWIG_PYTHON_THREAD_END_ALLOW;"); } Append(f, "\n}"); } } /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { int cppcast = 1; SWIG_library_directory("python"); for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-interface") == 0) { if (argv[i + 1]) { interface = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } /* end added */ } else if (strcmp(argv[i], "-globals") == 0) { if (argv[i + 1]) { global_name = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if ((strcmp(argv[i], "-shadow") == 0) || ((strcmp(argv[i], "-proxy") == 0))) { shadow = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-new_repr") == 0) || (strcmp(argv[i], "-newrepr") == 0)) { new_repr = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-old_repr") == 0) || (strcmp(argv[i], "-oldrepr") == 0)) { new_repr = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-classptr") == 0) { classptr = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-noproxy") == 0)) { shadow = 0; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-noproxyimport") == 0)) { shadowimport = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-keyword") == 0) { use_kw = 1; SWIG_cparse_set_compact_default_args(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-classic") == 0) { classic = 1; modernargs = 0; modern = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-cppcast") == 0) { cppcast = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nocppcast") == 0) { cppcast = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-outputtuple") == 0) { outputtuple = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nooutputtuple") == 0) { outputtuple = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nortti") == 0) { nortti = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-threads") == 0) { threads = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nothreads") == 0) { /* Turn off thread suppor mode */ nothreads = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-safecstrings") == 0) { safecstrings = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nosafecstrings") == 0) { safecstrings = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-buildnone") == 0) { buildnone = 1; nobuildnone = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nobuildnone") == 0) { buildnone = 0; nobuildnone = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-dirvtable") == 0) { dirvtable = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nodirvtable") == 0) { dirvtable = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastunpack") == 0) { fastunpack = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nofastunpack") == 0) { fastunpack = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastproxy") == 0) { fastproxy = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nofastproxy") == 0) { fastproxy = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastquery") == 0) { fastquery = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nofastquery") == 0) { fastquery = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastinit") == 0) { fastinit = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nofastinit") == 0) { fastinit = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-olddefs") == 0) { olddefs = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-noolddefs") == 0) { olddefs = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-castmode") == 0) { castmode = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nocastmode") == 0) { castmode = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-extranative") == 0) { extranative = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-noextranative") == 0) { extranative = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-modernargs") == 0) { modernargs = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nomodernargs") == 0) { modernargs = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-aliasobj0") == 0) { aliasobj0 = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-noaliasobj0") == 0) { aliasobj0 = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-proxydel") == 0) { proxydel = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-noproxydel") == 0) { proxydel = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-modern") == 0) { classic = 0; modern = 1; modernargs = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nomodern") == 0) { modern = 0; modernargs = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-noh") == 0) { no_header_file = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-new_vwm") == 0) || (strcmp(argv[i], "-newvwm") == 0)) { /* Turn on new value wrapper mpde */ Swig_value_wrapper_mode(1); no_header_file = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { classic = 0; modern = 1; safecstrings = 0; buildnone = 0; nobuildnone = 1; classptr = 0; proxydel = 0; fastunpack = 1; fastproxy = 1; fastinit = 1; fastquery = 1; modernargs = 1; Wrapper_fast_dispatch_mode_set(1); Wrapper_virtual_elimination_mode_set(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage1, stdout); fputs(usage2, stdout); fputs(usage3, stdout); } else if (strcmp(argv[i], "-py3") == 0) { py3 = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-builtin") == 0) { builtin = 1; Preprocessor_define("SWIGPYTHON_BUILTIN", 0); Swig_mark_arg(i); } else if (strcmp(argv[i], "-relativeimport") == 0) { relativeimport = 1; Swig_mark_arg(i); } } } if (py3) { /* force disable features that not compatible with Python 3.x */ classic = 0; } if (cppcast) { Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); } if (!global_name) global_name = NewString("cvar"); Preprocessor_define("SWIGPYTHON 1", 0); SWIG_typemap_lang("python"); SWIG_config_file("python.swg"); allow_overloading(); } /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ virtual int top(Node *n) { /* check if directors are enabled for this module. note: this * is a "master" switch, without which no director code will be * emitted. %feature("director") statements are also required * to enable directors for individual classes or methods. * * use %module(directors="1") modulename at the start of the * interface file to enable director generation. */ String *mod_docstring = NULL; { Node *mod = Getattr(n, "module"); if (mod) { Node *options = Getattr(mod, "options"); if (options) { int dirprot = 0; if (Getattr(options, "dirprot")) { dirprot = 1; } if (Getattr(options, "nodirprot")) { dirprot = 0; } if (Getattr(options, "directors")) { allow_directors(); if (dirprot) allow_dirprot(); } if (Getattr(options, "threads")) { threads = 1; } if (Getattr(options, "castmode")) { castmode = 1; } if (Getattr(options, "nocastmode")) { castmode = 0; } if (Getattr(options, "extranative")) { extranative = 1; } if (Getattr(options, "noextranative")) { extranative = 0; } if (Getattr(options, "outputtuple")) { outputtuple = 1; } if (Getattr(options, "nooutputtuple")) { outputtuple = 0; } mod_docstring = Getattr(options, "docstring"); package = Getattr(options, "package"); } } } /* Set comparison with none for ConstructorToFunction */ setSubclassInstanceCheck(NewString("$arg != Py_None")); /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); String *outfile_h = !no_header_file ? Getattr(n, "outfile_h") : 0; f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); f_directors_h = NewString(""); f_directors = NewString(""); builtin_getset = NewHash(); class_members = NewHash(); builtin_methods = NewString(""); builtin_default_unref = NewString("delete $self;"); if (builtin) { f_builtins = NewString(""); } if (directorsEnabled()) { if (!no_header_file) { f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); } } else { f_runtime_h = f_runtime; } } /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); const_code = NewString(""); methods = NewString(""); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPYTHON\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } if (nothreads) { Printf(f_runtime, "#define SWIG_PYTHON_NO_THREADS\n"); } else if (threads) { Printf(f_runtime, "#define SWIG_PYTHON_THREADS\n"); } if (safecstrings) { Printf(f_runtime, "#define SWIG_PYTHON_SAFE_CSTRINGS\n"); } if (buildnone) { Printf(f_runtime, "#define SWIG_PYTHON_BUILD_NONE\n"); } if (nobuildnone) { Printf(f_runtime, "#define SWIG_PYTHON_NO_BUILD_NONE\n"); } if (!dirvtable) { Printf(f_runtime, "#define SWIG_PYTHON_DIRECTOR_NO_VTABLE\n"); } if (outputtuple) { Printf(f_runtime, "#define SWIG_PYTHON_OUTPUT_TUPLE\n"); } if (nortti) { Printf(f_runtime, "#ifndef SWIG_DIRECTOR_NORTTI\n"); Printf(f_runtime, "#define SWIG_DIRECTOR_NORTTI\n"); Printf(f_runtime, "#endif\n"); } if (castmode) { Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n"); Printf(f_runtime, "#define SWIG_PYTHON_CAST_MODE\n"); } if (extranative) { Printf(f_runtime, "#define SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS\n"); } if (classic) { Printf(f_runtime, "#define SWIG_PYTHON_CLASSIC\n"); } if (builtin) { Printf(f_runtime, "#define SWIGPYTHON_BUILTIN\n"); } Printf(f_runtime, "\n"); Printf(f_header, "#if (PY_VERSION_HEX <= 0x02000000)\n"); Printf(f_header, "# if !defined(SWIG_PYTHON_CLASSIC)\n"); Printf(f_header, "# error \"This python version requires swig to be run with the '-classic' option\"\n"); Printf(f_header, "# endif\n"); Printf(f_header, "#endif\n"); if (modern) { Printf(f_header, "#if (PY_VERSION_HEX <= 0x02020000)\n"); Printf(f_header, "# error \"This python version requires swig to be run with the '-nomodern' option\"\n"); Printf(f_header, "#endif\n"); } if (modernargs) { Printf(f_header, "#if (PY_VERSION_HEX <= 0x02020000)\n"); Printf(f_header, "# error \"This python version requires swig to be run with the '-nomodernargs' option\"\n"); Printf(f_header, "#endif\n"); } if (fastunpack) { Printf(f_header, "#ifndef METH_O\n"); Printf(f_header, "# error \"This python version requires swig to be run with the '-nofastunpack' option\"\n"); Printf(f_header, "#endif\n"); } if (fastquery) { Printf(f_header, "#ifdef SWIG_TypeQuery\n"); Printf(f_header, "# undef SWIG_TypeQuery\n"); Printf(f_header, "#endif\n"); Printf(f_header, "#define SWIG_TypeQuery SWIG_Python_TypeQuery\n"); } /* Set module name */ module = Copy(Getattr(n, "name")); mainmodule = Getattr(n, "name"); if (directorsEnabled()) { Swig_banner(f_directors_h); Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module); if (dirprot_mode()) { Printf(f_directors_h, "#include \n"); Printf(f_directors_h, "#include \n\n"); } Printf(f_directors, "\n\n"); Printf(f_directors, "/* ---------------------------------------------------\n"); Printf(f_directors, " * C++ director class methods\n"); Printf(f_directors, " * --------------------------------------------------- */\n\n"); if (outfile_h) { String *filename = Swig_file_filename(outfile_h); Printf(f_directors, "#include \"%s\"\n\n", filename); Delete(filename); } } /* If shadow classing is enabled, we're going to change the module name to "_module" */ if (shadow) { String *filen = NewStringf("%s%s.py", SWIG_output_directory(), Char(module)); // If we don't have an interface then change the module name X to _X if (interface) module = interface; else Insert(module, 0, "_"); if ((f_shadow_py = NewFile(filen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Delete(filen); filen = NULL; f_shadow = NewString(""); f_shadow_begin = NewString(""); f_shadow_imports = NewHash(); f_shadow_builtin_imports = NewString(""); f_shadow_stubs = NewString(""); Swig_register_filebyname("shadow", f_shadow); Swig_register_filebyname("python", f_shadow); if (mod_docstring && Len(mod_docstring)) { Printv(f_shadow, "\"\"\"\n", mod_docstring, "\n\"\"\"\n\n", NIL); Delete(mod_docstring); mod_docstring = NULL; } Printv(f_shadow, "\nfrom sys import version_info\n", NULL); if (!builtin && fastproxy) { Printv(f_shadow, "if version_info >= (3,0,0):\n", NULL); Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module); Printv(f_shadow, "else:\n", NULL); Printv(f_shadow, tab4, "from new import instancemethod as new_instancemethod\n", NULL); } /* Import the C-extension module. This should be a relative import, * since the shadow module may also have been imported by a relative * import, and there is thus no guarantee that the C-extension is on * sys.path. Relative imports must be explicitly specified from 2.6.0 * onwards (implicit relative imports will raise a DeprecationWarning * in 2.6, and fail in 2.7 onwards), but the relative import syntax * isn't available in python 2.4 or earlier, so we have to write some * code conditional on the python version. */ Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL); Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL); Printv(f_shadow, tab8, "from os.path import dirname\n", NULL); Printv(f_shadow, tab8, "import imp\n", NULL); Printv(f_shadow, tab8, "fp = None\n", NULL); Printv(f_shadow, tab8, "try:\n", NULL); Printf(f_shadow, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); Printf(f_shadow, tab8 "except ImportError:\n"); /* At here, the module may already loaded, so simply import it. */ Printf(f_shadow, tab4 tab8 "import %s\n", module); Printf(f_shadow, tab4 tab8 "return %s\n", module); Printv(f_shadow, tab8 "if fp is not None:\n", NULL); Printv(f_shadow, tab4 tab8 "try:\n", NULL); Printf(f_shadow, tab8 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module); Printv(f_shadow, tab4 tab8, "finally:\n", NULL); Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL); Printv(f_shadow, tab4 tab8, "return _mod\n", NULL); Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module); Printv(f_shadow, tab4, "del swig_import_helper\n", NULL); Printv(f_shadow, "else:\n", NULL); Printf(f_shadow, tab4 "import %s\n", module); /* Delete the version_info symbol since we don't use it elsewhere in the * module. */ Printv(f_shadow, "del version_info\n", NULL); if (builtin) { Printf(f_shadow, "from %s import *\n", module); } if (modern || !classic) { Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n", NULL); } /* if (!modern) */ /* always needed, a class can be forced to be no-modern, such as an exception */ { // Python-2.2 object hack Printv(f_shadow, "def _swig_setattr_nondynamic(self,class_type,name,value,static=1):\n", tab4, "if (name == \"thisown\"): return self.this.own(value)\n", tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n", #ifdef USE_THISOWN tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n", #endif tab4, tab8, "return\n", tab4, "method = class_type.__swig_setmethods__.get(name,None)\n", tab4, "if method: return method(self,value)\n", #ifdef USE_THISOWN tab4, "if (not static) or (name == \"thisown\"):\n", #else tab4, "if (not static):\n", #endif tab4, tab4, "self.__dict__[name] = value\n", tab4, "else:\n", tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\n", "def _swig_setattr(self,class_type,name,value):\n", tab4, "return _swig_setattr_nondynamic(self,class_type,name,value,0)\n\n", NIL); Printv(f_shadow, "def _swig_getattr(self,class_type,name):\n", tab4, "if (name == \"thisown\"): return self.this.own()\n", tab4, "method = class_type.__swig_getmethods__.get(name,None)\n", tab4, "if method: return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL); Printv(f_shadow, "def _swig_repr(self):\n", tab4, "try: strthis = \"proxy of \" + self.this.__repr__()\n", tab4, "except: strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL); if (!classic) { /* Usage of types.ObjectType is deprecated. * But don't sure wether this would broken old Python? */ Printv(f_shadow, // "import types\n", "try:\n", // " _object = types.ObjectType\n", " _object = object\n", " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n", // "del types\n", "\n\n", NIL); } } if (modern) { Printv(f_shadow, "def _swig_setattr_nondynamic_method(set):\n", tab4, "def set_attr(self,name,value):\n", #ifdef USE_THISOWN tab4, tab4, "if hasattr(self,name) or (name in (\"this\", \"thisown\")):\n", #else tab4, tab4, "if (name == \"thisown\"): return self.this.own(value)\n", tab4, tab4, "if hasattr(self,name) or (name == \"this\"):\n", #endif tab4, tab4, tab4, "set(self,name,value)\n", tab4, tab4, "else:\n", tab4, tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n", tab4, "return set_attr\n\n\n", NIL); } if (directorsEnabled()) { // Try loading weakref.proxy, which is only available in Python 2.1 and higher Printv(f_shadow, "try:\n", tab4, "import weakref\n", tab4, "weakref_proxy = weakref.proxy\n", "except:\n", tab4, "weakref_proxy = lambda x: x\n", "\n\n", NIL); } } // Include some information in the code Printf(f_header, "\n/*-----------------------------------------------\n @(target):= %s.so\n\ ------------------------------------------------*/\n", module); Printf(f_header, "#if PY_VERSION_HEX >= 0x03000000\n"); Printf(f_header, "# define SWIG_init PyInit_%s\n\n", module); Printf(f_header, "#else\n"); Printf(f_header, "# define SWIG_init init%s\n\n", module); Printf(f_header, "#endif\n"); Printf(f_header, "#define SWIG_name \"%s\"\n", module); Printf(f_wrappers, "#ifdef __cplusplus\n"); Printf(f_wrappers, "extern \"C\" {\n"); Printf(f_wrappers, "#endif\n"); Append(const_code, "static swig_const_info swig_const_table[] = {\n"); Append(methods, "static PyMethodDef SwigMethods[] = {\n"); /* the method exported for replacement of new.instancemethod in Python 3 */ add_pyinstancemethod_new(); if (builtin) { SwigType *s = NewString("SwigPyObject"); SwigType_add_pointer(s); SwigType_remember(s); Delete(s); } /* emit code */ Language::top(n); if (directorsEnabled()) { // Insert director runtime into the f_runtime file (make it occur before %header section) Swig_insert_file("director.swg", f_runtime); } /* Close language module */ Append(methods, "\t { NULL, NULL, 0, NULL }\n"); Append(methods, "};\n"); Printf(f_wrappers, "%s\n", methods); if (builtin) { Dump(f_builtins, f_wrappers); } SwigType_emit_type_table(f_runtime, f_wrappers); Append(const_code, "{0, 0, 0, 0.0, 0, 0}};\n"); Printf(f_wrappers, "%s\n", const_code); initialize_threads(f_init); Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n"); Printf(f_init, " return m;\n"); Printf(f_init, "#else\n"); Printf(f_init, " return;\n"); Printf(f_init, "#endif\n"); Printf(f_init, "}\n"); Printf(f_wrappers, "#ifdef __cplusplus\n"); Printf(f_wrappers, "}\n"); Printf(f_wrappers, "#endif\n"); if (shadow) { Swig_banner_target_lang(f_shadow_py, "#"); if (!modern) { Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL); } Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL); Printv(f_shadow_py, "\n", f_shadow_builtin_imports, "\n", NIL); Printv(f_shadow_py, f_shadow, "\n", NIL); Printv(f_shadow_py, f_shadow_stubs, "\n", NIL); Delete(f_shadow_py); } /* Close all of the files */ Dump(f_runtime, f_begin); Dump(f_header, f_begin); if (directorsEnabled()) { Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); if (f_runtime_h != f_begin) Delete(f_runtime_h); Dump(f_directors, f_begin); } Dump(f_wrappers, f_begin); if (builtin && builtin_bases_needed) Printf(f_begin, "static PyTypeObject *builtin_bases[%d];\n\n", max_bases + 2); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_builtins); Delete(f_init); Delete(f_directors); Delete(f_directors_h); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /* ------------------------------------------------------------ * Emit the wrapper for PyInstanceMethod_New to MethodDef array. * This wrapper is used to implement -fastproxy, * as a replacement of new.instancemethod in Python 3. * ------------------------------------------------------------ */ int add_pyinstancemethod_new() { String *name = NewString("SWIG_PyInstanceMethod_New"); Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},\n", name, name); Delete(name); return 0; } /* ------------------------------------------------------------ * subpkg_tail() * * Return the name of 'other' package relative to 'base'. * * 1. If 'other' is a sub-package of 'base', returns the 'other' relative to * 'base'. * 2. If 'other' and 'base' are equal, returns empty string "". * 3. In any other case, NULL pointer is returned. * * The 'base' and 'other' are expected to be fully qualified names. * * NOTE: none of 'base' nor 'other' can be null. * * Examples: * * # base other tail * -- ---- ----- ---- * 1 "Foo" "Foo.Bar" -> "Bar" * 2 "Foo" "Foo." -> "" * 3 "Foo" "FooB.ar" -> NULL * 4 "Foo.Bar" "Foo.Bar" -> "" * 5 "Foo.Bar" "Foo" -> NULL * 6 "Foo.Bar" "Foo.Gez" -> NULL * * NOTE: the example #2 is actually a syntax error (at input). I believe * swig parser prevents us from this case happening here. * ------------------------------------------------------------ */ static String *subpkg_tail(const String *base, const String *other) { int baselen = Len(base); int otherlen = Len(other); if (Strncmp(other, base, baselen) == 0) { if ((baselen < otherlen) && (Char(other))[baselen] == '.') { return NewString((Char(other)) + baselen + 1); } else if (baselen == otherlen) { return NewString(""); } else { return 0; } } else { return 0; } } /* ------------------------------------------------------------ * abs_import_directive_string() * * Return a string containing python code to import module. * * pkg package name or the module being imported * mod module name of the module being imported * pfx optional prefix to module name * * NOTE: keep this function consistent with abs_import_name_string(). * ------------------------------------------------------------ */ static String *abs_import_directive_string(const String *pkg, const String *mod, const char *pfx = "") { String *out = NewString(""); if (pkg && *Char(pkg)) { Printf(out, "import %s.%s%s\n", pkg, pfx, mod); } else { Printf(out, "import %s%s\n", pfx, mod); } return out; } /* ------------------------------------------------------------ * rel_import_directive_string() * * Return a string containing python code to import module that * is potentially within a package. * * mainpkg package name of the module which imports the other module * pkg package name or the module being imported * mod module name of the module being imported * pfx optional prefix to module name * * NOTE: keep this function consistent with rel_import_name_string(). * ------------------------------------------------------------ */ static String *rel_import_directive_string(const String *mainpkg, const String *pkg, const String *mod, const char *pfx = "") { /* NOTE: things are not so trivial. This is what we do here (by examples): * * 0. To import module 'foo', which is not in any package, we do absolute * import: * * import foo * * 1. To import 'pkg1.pkg2.foo', when mainpkg != "pkg1" and * mainpkg != "pkg1.pkg2" or when mainpkg is not given we do absolute * import: * * import pkg1.pkg2.foo * * 2. To import module pkg1.foo, when mainpkg == "pkg1", we do: * * - for py3 = 0: * * import foo * * - for py3 = 1: * * from . import foo * * 3. To import "pkg1.pkg2.pkg3.foo", when mainpkg = "pkg1", we do: * * - for py3 == 0: * * import pkg2.pkg3.foo * * - for py3 == 1: * * from . import pkg2 # [1] * import pkg1.pkg2.pkg3.foo * * NOTE: [1] is necessary for pkg2.foo to be present in the importing module */ String *apkg = 0; // absolute (FQDN) package name of pkg String *rpkg = 0; // relative package name int py3_rlen1 = 0; // length of 1st level sub-package name, used by py3 String *out = NewString(""); if (pkg && *Char(pkg)) { if (mainpkg) { String *tail = subpkg_tail(mainpkg, pkg); if (tail) { if (*Char(tail)) { rpkg = NewString(tail); const char *py3_end1 = Strchr(rpkg, '.'); if (!py3_end1) py3_end1 = (Char(rpkg)) + Len(rpkg); py3_rlen1 = py3_end1 - (Char(rpkg)); } else { rpkg = NewString(""); } Delete(tail); } else { apkg = NewString(pkg); } } else { apkg = NewString(pkg); } } else { apkg = NewString(""); } if (apkg) { Printf(out, "import %s%s%s%s\n", apkg, *Char(apkg) ? "." : "", pfx, mod); Delete(apkg); } else { if (py3) { if (py3_rlen1) Printf(out, "from . import %.*s\n", py3_rlen1, rpkg); Printf(out, "from .%s import %s%s\n", rpkg, pfx, mod); } else { Printf(out, "import %s%s%s%s\n", rpkg, *Char(rpkg) ? "." : "", pfx, mod); } Delete(rpkg); } return out; } /* ------------------------------------------------------------ * import_directive_string() * ------------------------------------------------------------ */ static String *import_directive_string(const String *mainpkg, const String *pkg, const String *mod, const char *pfx = "") { if (!relativeimport) { return abs_import_directive_string(pkg, mod, pfx); } else { return rel_import_directive_string(mainpkg, pkg, mod, pfx); } } /* ------------------------------------------------------------ * abs_import_name_string() * * Return a string with the name of a symbol (perhaps imported * from external module by absolute import directive). * * mainpkg package name of current module * mainmod module name of current module * pkg package name of (perhaps other) module * mod module name of (perhaps other) module * sym symbol name * * NOTE: mainmod, mod, and sym can't be NULL. * NOTE: keep this function consistent with abs_import_directive_string() * ------------------------------------------------------------ */ static String *abs_import_name_string(const String *mainpkg, const String *mainmod, const String *pkg, const String *mod, const String *sym) { String *out = NewString(""); if (pkg && *Char(pkg)) { if (mainpkg && *Char(mainpkg)) { if (Strcmp(mainpkg,pkg) != 0 || Strcmp(mainmod, mod) != 0) { Printf(out, "%s.%s.", pkg, mod); } } else { Printf(out, "%s.%s.", pkg, mod); } } else if ((mainpkg && *Char(mainpkg)) || Strcmp(mainmod, mod) != 0) { Printf(out, "%s.", mod); } Append(out, sym); return out; } /* ------------------------------------------------------------ * rel_import_name_string() * * Return a string with the name of a symbol (perhaps imported * from external module by relative import directive). * * mainpkg package name of current module * mainmod module name of current module * pkg package name of (perhaps other) module * mod module name of (perhaps other) module * sym symbol name * * NOTE: mainmod, mod, and sym can't be NULL. * NOTE: keep this function consistent with rel_import_directive_string() * ------------------------------------------------------------ */ static String *rel_import_name_string(const String *mainpkg, const String *mainmod, const String *pkg, const String *mod, const String *sym) { String *out = NewString(""); if (pkg && *Char(pkg)) { String *tail = 0; if (mainpkg) tail = subpkg_tail(mainpkg, pkg); if (!tail) tail = NewString(pkg); if (*Char(tail)) { Printf(out, "%s.%s.", tail, mod); } else if (Strcmp(mainmod, mod) != 0) { Printf(out, "%s.", mod); } Delete(tail); } else if ((mainpkg && *Char(mainpkg)) || Strcmp(mainmod, mod) != 0) { Printf(out, "%s.", mod); } Append(out, sym); return out; } /* ------------------------------------------------------------ * import_name_string() * ------------------------------------------------------------ */ static String *import_name_string(const String *mainpkg, const String *mainmod, const String *pkg, const String *mod, const String *sym) { if (!relativeimport) { return abs_import_name_string(mainpkg,mainmod,pkg,mod,sym); } else { return rel_import_name_string(mainpkg,mainmod,pkg,mod,sym); } } /* ------------------------------------------------------------ * importDirective() * ------------------------------------------------------------ */ virtual int importDirective(Node *n) { if (shadow) { String *modname = Getattr(n, "module"); if (modname) { // Find the module node for this imported module. It should be the // first child but search just in case. Node *mod = firstChild(n); while (mod && Strcmp(nodeType(mod), "module") != 0) mod = nextSibling(mod); Node *options = Getattr(mod, "options"); String *pkg = options ? Getattr(options, "package") : 0; if (shadowimport) { if (!options || (!Getattr(options, "noshadow") && !Getattr(options, "noproxy"))) { String *_import = import_directive_string(package, pkg, modname, "_"); if (!GetFlagAttr(f_shadow_imports, _import)) { String *import = import_directive_string(package, pkg, modname); Printf(builtin ? f_shadow_builtin_imports : f_shadow, "%s", import); Delete(import); SetFlag(f_shadow_imports, _import); } Delete(_import); } } } } return Language::importDirective(n); } /* ------------------------------------------------------------ * funcCall() * Emit shadow code to call a function in the extension * module. Using proper argument and calling style for * given node n. * ------------------------------------------------------------ */ String *funcCall(String *name, String *parms) { String *str = NewString(""); Printv(str, module, ".", name, "(", parms, ")", NIL); return str; } /* ------------------------------------------------------------ * pythoncode() - Output python code into the shadow file * ------------------------------------------------------------ */ String *pythoncode(String *code, const_String_or_char_ptr indent) { String *out = NewString(""); String *temp; char *t; if (!indent) indent = ""; temp = NewString(code); t = Char(temp); if (*t == '{') { Delitem(temp, 0); Delitem(temp, DOH_END); } /* Split the input text into lines */ List *clist = SplitLines(temp); Delete(temp); int initial = 0; String *s = 0; Iterator si; /* Get the initial indentation */ for (si = First(clist); si.item; si = Next(si)) { s = si.item; if (Len(s)) { char *c = Char(s); while (*c) { if (!isspace(*c)) break; initial++; c++; } if (*c && !isspace(*c)) { break; } else { initial = 0; } } } while (si.item) { s = si.item; if (Len(s) > initial) { char *c = Char(s); c += initial; Printv(out, indent, c, "\n", NIL); } else { Printv(out, "\n", NIL); } si = Next(si); } Delete(clist); return out; } /* ------------------------------------------------------------ * autodoc level declarations * ------------------------------------------------------------ */ enum autodoc_l { NO_AUTODOC = -2, // no autodoc STRING_AUTODOC = -1, // use provided string NAMES_AUTODOC = 0, // only parameter names TYPES_AUTODOC = 1, // parameter names and types EXTEND_AUTODOC = 2, // extended documentation and parameter names EXTEND_TYPES_AUTODOC = 3 // extended documentation and parameter types + names }; autodoc_l autodoc_level(String *autodoc) { autodoc_l dlevel = NO_AUTODOC; char *c = Char(autodoc); if (c) { if (isdigit(c[0])) { dlevel = (autodoc_l) atoi(c); } else { if (strcmp(c, "extended") == 0) { dlevel = EXTEND_AUTODOC; } else { dlevel = STRING_AUTODOC; } } } return dlevel; } /* ------------------------------------------------------------ * have_docstring() * Check if there is a docstring directive and it has text, * or there is an autodoc flag set * ------------------------------------------------------------ */ bool have_docstring(Node *n) { String *str = Getattr(n, "feature:docstring"); return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); } /* ------------------------------------------------------------ * docstring() * Get the docstring text, stripping off {} if neccessary, * and enclose in triple double quotes. If autodoc is also * set then it will build a combined docstring. * ------------------------------------------------------------ */ String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool use_triple = true) { String *str = Getattr(n, "feature:docstring"); bool have_ds = (str && Len(str) > 0); bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); const char *triple_double = use_triple ? "\"\"\"" : ""; String *autodoc = NULL; String *doc = NULL; if (have_ds) { char *t = Char(str); if (*t == '{') { Delitem(str, 0); Delitem(str, DOH_END); } } if (have_auto) { autodoc = make_autodoc(n, ad_type); have_auto = (autodoc && Len(autodoc) > 0); } // If there is more than one line then make docstrings like this: // // """ // This is line1 // And here is line2 followed by the rest of them // """ // // otherwise, put it all on a single line // if (have_auto && have_ds) { // Both autodoc and docstring are present doc = NewString(""); Printv(doc, triple_double, "\n", pythoncode(autodoc, indent), "\n", pythoncode(str, indent), indent, triple_double, NIL); } else if (!have_auto && have_ds) { // only docstring if (Strchr(str, '\n') == 0) { doc = NewStringf("%s%s%s", triple_double, str, triple_double); } else { doc = NewString(""); Printv(doc, triple_double, "\n", pythoncode(str, indent), indent, triple_double, NIL); } } else if (have_auto && !have_ds) { // only autodoc if (Strchr(autodoc, '\n') == 0) { doc = NewStringf("%s%s%s", triple_double, autodoc, triple_double); } else { doc = NewString(""); Printv(doc, triple_double, "\n", pythoncode(autodoc, indent), indent, triple_double, NIL); } } else doc = NewString(""); // Save the generated strings in the parse tree in case they are used later // by post processing tools Setattr(n, "python:docstring", doc); Setattr(n, "python:autodoc", autodoc); return doc; } /* ------------------------------------------------------------ * cdocstring() * Get the docstring text as it would appear in C-language * source code. * ------------------------------------------------------------ */ String *cdocstring(Node *n, autodoc_t ad_type) { String *ds = docstring(n, ad_type, "", false); Replaceall(ds, "\\", "\\\\"); Replaceall(ds, "\"", "\\\""); Replaceall(ds, "\n", "\\n\"\n\t\t\""); return ds; } /* ----------------------------------------------------------------------------- * addMissingParameterNames() * For functions that have not had nameless parameters set in the Language class. * * Inputs: * plist - entire parameter list * arg_offset - argument number for first parameter * Side effects: * The "lname" attribute in each parameter in plist will be contain a parameter name * ----------------------------------------------------------------------------- */ void addMissingParameterNames(ParmList *plist, int arg_offset) { Parm *p = plist; int i = arg_offset; while (p) { if (!Getattr(p, "lname")) { String *pname = Swig_cparm_name(p, i); Delete(pname); } i++; p = nextSibling(p); } } /* ------------------------------------------------------------ * make_autodocParmList() * Generate the documentation for the function parameters * Parameters: * func_annotation: Function annotation support * ------------------------------------------------------------ */ String *make_autodocParmList(Node *n, bool showTypes, bool calling = false, bool func_annotation = false) { String *doc = NewString(""); String *pdocs = 0; ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; int lines = 0; int start_arg_num = is_wrapping_class() ? 1 : 0; const int maxwidth = 80; if (calling) func_annotation = false; addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); if (Strcmp(ParmList_protostr(plist), "void") == 0) { //No parameters actually return doc; } for (p = plist; p; p = pnext) { String *tm = Getattr(p, "tmap:in"); if (tm) { pnext = Getattr(p, "tmap:in:next"); if (checkAttribute(p, "tmap:in:numinputs", "0")) { continue; } } else { pnext = nextSibling(p); } String *name = 0; String *type = 0; String *value = 0; String *pdoc = Getattr(p, "tmap:doc"); if (pdoc) { name = Getattr(p, "tmap:doc:name"); type = Getattr(p, "tmap:doc:type"); value = Getattr(p, "tmap:doc:value"); } // Note: the generated name should be consistent with that in kwnames[] name = name ? name : Getattr(p, "name"); name = name ? name : Getattr(p, "lname"); name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); if (SwigType_isvarargs(type)) break; if (Len(doc)) { // add a comma to the previous one if any Append(doc, ", "); // Do we need to wrap a long line? if ((Len(doc) - lines * maxwidth) > maxwidth) { Printf(doc, "\n%s", tab4); lines += 1; } } // Do the param type too? Node *nn = classLookup(Getattr(p, "type")); String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); if (showTypes) Printf(doc, "%s ", type_str); Append(doc, name); if (pdoc) { if (!pdocs) pdocs = NewString("\nParameters:\n"); Printf(pdocs, " %s\n", pdoc); } // Write the function annotation if (func_annotation) Printf(doc, " : '%s'", type_str); // Write default value if (value && !calling) { String *new_value = convertValue(value, Getattr(p, "type")); if (new_value) { value = new_value; } else { Node *lookup = Swig_symbol_clookup(value, 0); if (lookup) value = Getattr(lookup, "sym:name"); } Printf(doc, "=%s", value); } Delete(type_str); Delete(name); } if (pdocs) Setattr(n, "feature:pdocs", pdocs); Delete(plist); return doc; } /* ------------------------------------------------------------ * make_autodoc() * Build a docstring for the node, using parameter and other * info in the parse tree. If the value of the autodoc * attribute is "0" then do not include parameter types, if * it is "1" (the default) then do. If it has some other * value then assume it is supplied by the extension writer * and use it directly. * ------------------------------------------------------------ */ String *make_autodoc(Node *n, autodoc_t ad_type) { int extended = 0; // If the function is overloaded then this function is called // for the last one. Rewind to the first so the docstrings are // in order. while (Getattr(n, "sym:previousSibling")) n = Getattr(n, "sym:previousSibling"); String *doc = NewString(""); while (n) { bool showTypes = false; bool skipAuto = false; String *autodoc = Getattr(n, "feature:autodoc"); autodoc_l dlevel = autodoc_level(autodoc); switch (dlevel) { case NO_AUTODOC: break; case NAMES_AUTODOC: showTypes = false; break; case TYPES_AUTODOC: showTypes = true; break; case EXTEND_AUTODOC: extended = 1; showTypes = false; break; case EXTEND_TYPES_AUTODOC: extended = 1; showTypes = true; break; case STRING_AUTODOC: Append(doc, autodoc); skipAuto = true; break; } if (!skipAuto) { String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *type_str = NULL; if (type) { if (Strcmp(type, "void") == 0) { type_str = NULL; } else { Node *nn = classLookup(type); type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); } } switch (ad_type) { case AUTODOC_CLASS: { // Only do the autodoc if there isn't a docstring for the class String *str = Getattr(n, "feature:docstring"); if (!str || Len(str) == 0) { if (CPlusPlus) { Printf(doc, "Proxy of C++ %s class", real_classname); } else { Printf(doc, "Proxy of C %s struct", real_classname); } } } break; case AUTODOC_CTOR: if (Strcmp(class_name, symname) == 0) { String *paramList = make_autodocParmList(n, showTypes); Printf(doc, "__init__("); if (showTypes) Printf(doc, "%s ", getClassName()); if (Len(paramList)) Printf(doc, "self, %s) -> %s", paramList, class_name); else Printf(doc, "self) -> %s", class_name); } else Printf(doc, "%s(%s) -> %s", symname, make_autodocParmList(n, showTypes), class_name); break; case AUTODOC_DTOR: if (showTypes) Printf(doc, "__del__(%s self)", getClassName()); else Printf(doc, "__del__(self)"); break; case AUTODOC_STATICFUNC: Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes)); if (type_str) Printf(doc, " -> %s", type_str); break; case AUTODOC_FUNC: Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes)); if (type_str) Printf(doc, " -> %s", type_str); break; case AUTODOC_METHOD: String *paramList = make_autodocParmList(n, showTypes); Printf(doc, "%s(", symname); if (showTypes) Printf(doc, "%s ", class_name); if (Len(paramList)) Printf(doc, "self, %s)", paramList); else Printf(doc, "self)"); if (type_str) Printf(doc, " -> %s", type_str); break; } Delete(type_str); } if (extended) { String *pdocs = Getattr(n, "feature:pdocs"); if (pdocs) { Printv(doc, "\n", pdocs, NULL); } } // if it's overloaded then get the next decl and loop around again n = Getattr(n, "sym:nextSibling"); if (n) Append(doc, "\n"); } return doc; } /* ------------------------------------------------------------ * convertValue() * Check if string v can be a Python value literal, * (eg. number or string), or translate it to a Python literal. * ------------------------------------------------------------ */ String *convertValue(String *v, SwigType *t) { if (v && Len(v) > 0) { char fc = (Char(v))[0]; if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) { /* number or string (or maybe NULL pointer) */ if (SwigType_ispointer(t) && Strcmp(v, "0") == 0) return NewString("None"); else return v; } if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) return NewString("True"); if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("False"); if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) return SwigType_ispointer(t) ? NewString("None") : NewString("0"); } return 0; } /* ------------------------------------------------------------ * is_primitive_defaultargs() * Check if all the default args have primitive type. * (So we can generate proper parameter list with default * values..) * ------------------------------------------------------------ */ bool is_primitive_defaultargs(Node *n) { ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; Swig_typemap_attach_parms("in", plist, 0); for (p = plist; p; p = pnext) { String *tm = Getattr(p, "tmap:in"); if (tm) { pnext = Getattr(p, "tmap:in:next"); if (checkAttribute(p, "tmap:in:numinputs", "0")) { continue; } } else { pnext = nextSibling(p); } String *type = Getattr(p, "type"); String *value = Getattr(p, "value"); if (!convertValue(value, type)) return false; } return true; } /* ------------------------------------------------------------ * is_real_overloaded() * Check if the function is overloaded, but not just have some * siblings generated due to the original function have * default arguments. * ------------------------------------------------------------ */ bool is_real_overloaded(Node *n) { Node *h = Getattr(n, "sym:overloaded"); Node *i; if (!h) return false; i = Getattr(h, "sym:nextSibling"); while (i) { Node *nn = Getattr(i, "defaultargs"); if (nn != h) { /* Check if overloaded function has defaultargs and * pointed to the first overloaded. */ return true; } i = Getattr(i, "sym:nextSibling"); } return false; } /* ------------------------------------------------------------ * make_pyParmList() * Generate parameter list for Python functions or methods, * reuse make_autodocParmList() to do so. * ------------------------------------------------------------ */ String *make_pyParmList(Node *n, bool in_class, bool is_calling, int kw) { /* Get the original function for a defaultargs copy, * see default_arguments() in parser.y. */ Node *nn = Getattr(n, "defaultargs"); if (nn) n = nn; /* For overloaded function, just use *args */ if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || !is_primitive_defaultargs(n)) { String *parms = NewString(""); if (in_class) Printf(parms, "self, "); Printf(parms, "*args"); if (kw) Printf(parms, ", **kwargs"); return parms; } bool funcanno = py3 ? true : false; String *params = NewString(""); String *_params = make_autodocParmList(n, false, is_calling, funcanno); if (in_class) { Printf(params, "self"); if (Len(_params) > 0) Printf(params, ", "); } Printv(params, _params, NULL); return params; } /* ------------------------------------------------------------ * have_pythonprepend() * Check if there is a %pythonprepend directive and it has text * ------------------------------------------------------------ */ bool have_pythonprepend(Node *n) { String *str = Getattr(n, "feature:pythonprepend"); return (str && Len(str) > 0); } /* ------------------------------------------------------------ * pythonprepend() * Get the %pythonprepend code, stripping off {} if neccessary * ------------------------------------------------------------ */ String *pythonprepend(Node *n) { String *str = Getattr(n, "feature:pythonprepend"); char *t = Char(str); if (*t == '{') { Delitem(str, 0); Delitem(str, DOH_END); } return str; } /* ------------------------------------------------------------ * have_pythonappend() * Check if there is a %pythonappend directive and it has text * ------------------------------------------------------------ */ bool have_pythonappend(Node *n) { String *str = Getattr(n, "feature:pythonappend"); if (!str) str = Getattr(n, "feature:addtofunc"); return (str && Len(str) > 0); } /* ------------------------------------------------------------ * pythonappend() * Get the %pythonappend code, stripping off {} if neccessary * ------------------------------------------------------------ */ String *pythonappend(Node *n) { String *str = Getattr(n, "feature:pythonappend"); if (!str) str = Getattr(n, "feature:addtofunc"); char *t = Char(str); if (*t == '{') { Delitem(str, 0); Delitem(str, DOH_END); } return str; } /* ------------------------------------------------------------ * have_addtofunc() * Check if there is a %addtofunc directive and it has text * ------------------------------------------------------------ */ bool have_addtofunc(Node *n) { return have_pythonappend(n) || have_pythonprepend(n) || have_docstring(n); } /* ------------------------------------------------------------ * returnTypeAnnotation() * Helper function for constructing the function annotation * of the returning type, return a empty string for Python 2.x * ------------------------------------------------------------ */ String *returnTypeAnnotation(Node *n) { String *ret = 0; Parm *p = Getattr(n, "parms"); String *tm; /* Try to guess the returning type by argout typemap, * however the result may not accurate. */ while (p) { if ((tm = Getattr(p, "tmap:argout:match_type"))) { tm = SwigType_str(tm, 0); if (ret) Printv(ret, ", ", tm, NULL); else ret = tm; p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } /* If no argout typemap, then get the returning type from * the function prototype. */ if (!ret) { ret = Getattr(n, "type"); if (ret) ret = SwigType_str(ret, 0); } return (ret && py3) ? NewStringf(" -> \"%s\" ", ret) : NewString(""); } /* ------------------------------------------------------------ * emitFunctionShadowHelper() * Refactoring some common code out of functionWrapper and * dispatchFunction that writes the proxy code for non-member * functions. * ------------------------------------------------------------ */ void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) { String *parms = make_pyParmList(n, false, false, kw); String *callParms = make_pyParmList(n, false, true, kw); /* Make a wrapper function to insert the code into */ Printv(f_dest, "\ndef ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); if (have_pythonprepend(n)) Printv(f_dest, pythoncode(pythonprepend(n), " "), "\n", NIL); if (have_pythonappend(n)) { Printv(f_dest, " val = ", funcCall(name, callParms), "\n", NIL); Printv(f_dest, pythoncode(pythonappend(n), " "), "\n", NIL); Printv(f_dest, " return val\n", NIL); } else { Printv(f_dest, " return ", funcCall(name, callParms), "\n", NIL); } if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) { /* If there is no addtofunc directive then just assign from the extension module (for speed up) */ Printv(f_dest, name, " = ", module, ".", name, "\n", NIL); } } /* ------------------------------------------------------------ * check_kwargs() * check if using kwargs is allowed for this Node * ------------------------------------------------------------ */ int check_kwargs(Node *n) { return (use_kw || GetFlag(n, "feature:kwargs")) && !GetFlag(n, "memberset") && !GetFlag(n, "memberget"); } /* ------------------------------------------------------------ * add_method() * ------------------------------------------------------------ */ void add_method(String *name, String *function, int kw, Node *n = 0, int funpack= 0, int num_required= -1, int num_arguments = -1) { if (!kw) { if (n && funpack) { if (num_required == 0 && num_arguments == 0) { Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_NOARGS, ", name, function); } else if (num_required == 1 && num_arguments == 1) { Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, ", name, function); } else { Printf(methods, "\t { (char *)\"%s\", %s, METH_VARARGS, ", name, function); } } else { Printf(methods, "\t { (char *)\"%s\", %s, METH_VARARGS, ", name, function); } } else { Printf(methods, "\t { (char *)\"%s\", (PyCFunction) %s, METH_VARARGS | METH_KEYWORDS, ", name, function); } if (!n) { Append(methods, "NULL"); } else if (Getattr(n, "feature:callback")) { if (have_docstring(n)) { String *ds = cdocstring(n, AUTODOC_FUNC); Printf(methods, "(char *)\"%s\\nswig_ptr: %s\"", ds, Getattr(n, "feature:callback:name")); Delete(ds); } else { Printf(methods, "(char *)\"swig_ptr: %s\"", Getattr(n, "feature:callback:name")); } } else if (have_docstring(n)) { String *ds = cdocstring(n, AUTODOC_FUNC); Printf(methods, "(char *)\"%s\"", ds); Delete(ds); } else { Append(methods, "NULL"); } Append(methods, "},\n"); } /* ------------------------------------------------------------ * dispatchFunction() * ------------------------------------------------------------ */ void dispatchFunction(Node *n, String *linkage, int funpack = 0, bool builtin_self = false, bool builtin_ctor = false, bool director_class = false) { /* Last node in overloaded chain */ bool add_self = builtin_self && (!builtin_ctor || director_class); int maxargs; String *tmp = NewString(""); String *dispatch; const char *dispatch_code = funpack ? "return %s(self, argc, argv);" : "return %s(self, args);"; if (castmode) { dispatch = Swig_overload_dispatch_cast(n, dispatch_code, &maxargs); } else { dispatch = Swig_overload_dispatch(n, dispatch_code, &maxargs); } /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *f = NewWrapper(); String *symname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(symname); Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL); Wrapper_add_local(f, "argc", "int argc"); Printf(tmp, "PyObject *argv[%d]", maxargs + 1); Wrapper_add_local(f, "argv", tmp); if (!fastunpack) { Wrapper_add_local(f, "ii", "int ii"); if (maxargs - (add_self ? 1 : 0) > 0) Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n"); Append(f->code, "argc = args ? (int)PyObject_Length(args) : 0;\n"); if (add_self) Append(f->code, "argv[0] = self;\n"); Printf(f->code, "for (ii = 0; (ii < %d) && (ii < argc); ii++) {\n", add_self ? maxargs - 1 : maxargs); Printf(f->code, "argv[ii%s] = PyTuple_GET_ITEM(args,ii);\n", add_self ? " + 1" : ""); Append(f->code, "}\n"); if (add_self) Append(f->code, "argc++;\n"); } else { String *iname = Getattr(n, "sym:name"); Printf(f->code, "if (!(argc = SWIG_Python_UnpackTuple(args,\"%s\",0,%d,argv%s))) SWIG_fail;\n", iname, maxargs, add_self ? "+1" : ""); if (add_self) Append(f->code, "argv[0] = self;\n"); else Append(f->code, "--argc;\n"); } Replaceall(dispatch, "$args", "self,args"); Printv(f->code, dispatch, "\n", NIL); if (GetFlag(n, "feature:python:maybecall")) { Append(f->code, "fail:\n"); Append(f->code, "Py_INCREF(Py_NotImplemented);\n"); Append(f->code, "return Py_NotImplemented;\n"); } else { Node *sibl = n; while (Getattr(sibl, "sym:previousSibling")) sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up String *protoTypes = NewString(""); do { String *fulldecl = Swig_name_decl(sibl); Printf(protoTypes, "\n\" %s\\n\"", fulldecl); Delete(fulldecl); } while ((sibl = Getattr(sibl, "sym:nextSibling"))); Append(f->code, "fail:\n"); Printf(f->code, "SWIG_SetErrorMsg(PyExc_NotImplementedError," "\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes); Printf(f->code, "return %s;\n", builtin_ctor ? "-1" : "0"); Delete(protoTypes); } Printv(f->code, "}\n", NIL); Wrapper_print(f, f_wrappers); Node *p = Getattr(n, "sym:previousSibling"); if (!builtin_self) add_method(symname, wname, 0, p); /* Create a shadow for this function (if enabled and not in a member function) */ if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) { emitFunctionShadowHelper(n, in_class ? f_shadow_stubs : f_shadow, symname, 0); } DelWrapper(f); Delete(dispatch); Delete(tmp); Delete(wname); } /* ------------------------------------------------------------ * functionWrapper() * ------------------------------------------------------------ */ /* A note about argument marshalling with built-in types. There are three distinct cases for member (non-static) methods: 1) An ordinary member function. In this case, the first param in the param list is 'this'. For builtin types, 'this' is taken from the first argument to the wrapper (usually called 'self); it's not extracted from the second argument (which is usually a tuple). 2) A constructor for a non-director class. In this case, the param list doesn't contain an entry for 'this', but the first ('self') argument to the wrapper *does* contain the newly-allocated, uninitialized object. 3) A constructor for a director class. In this case, the param list contains a 'self' param, which comes from the first argument to the wrapper function. */ const char *get_implicitconv_flag(Node *klass) { int conv = 0; if (klass && GetFlag(klass, "feature:implicitconv")) { conv = 1; } return conv ? "SWIG_POINTER_IMPLICIT_CONV" : "0"; } virtual int functionWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); Node *parent = Swig_methodclass(n); int director_method = 0; Parm *p; int i; char source[64]; Wrapper *f; String *self_parse; String *parse_args; String *arglist; String *get_pointers; String *cleanup; String *outarg; String *kwargs; String *tm; String *overname = 0; int num_required; int num_arguments; int num_fixed_arguments; int tuple_required; int tuple_arguments; int varargs = 0; int allow_kwargs = check_kwargs(n); String *nodeType = Getattr(n, "nodeType"); int constructor = (!Cmp(nodeType, "constructor")); int destructor = (!Cmp(nodeType, "destructor")); String *storage = Getattr(n, "storage"); /* Only the first constructor is handled as init method. Others constructor can be emitted via %rename */ int handled_as_init = 0; if (!have_constructor && (constructor || Getattr(n, "handled_as_constructor")) && ((shadow & PYSHADOW_MEMBER))) { String *nname = Getattr(n, "sym:name"); String *sname = Getattr(getCurrentClass(), "sym:name"); String *cname = Swig_name_construct(NSPACE_TODO, sname); handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0); Delete(cname); } bool builtin_self = builtin && in_class && (constructor || (l && Getattr(l, "self"))); bool builtin_ctor = false; if (builtin_self && constructor) { String *class_mname = Getattr(getCurrentClass(), "sym:name"); String *mrename = Swig_name_construct(getNSpace(), class_mname); if (Cmp(iname, mrename)) builtin_self = false; else builtin_ctor = true; } bool director_class = (getCurrentClass() && Swig_directorclass(getCurrentClass())); bool add_self = builtin_self && (!builtin_ctor || director_class); bool builtin_getter = (builtin && GetFlag(n, "memberget")); bool builtin_setter = (builtin && GetFlag(n, "memberset") && !builtin_getter); bool over_varargs = false; char const *self_param = builtin ? "self" : "SWIGUNUSEDPARM(self)"; char const *wrap_return = builtin_ctor ? "int " : "PyObject *"; String *linkage = NewString("SWIGINTERN "); String *wrapper_name = Swig_name_wrapper(iname); if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) return SWIG_ERROR; } f = NewWrapper(); self_parse = NewString(""); parse_args = NewString(""); arglist = NewString(""); get_pointers = NewString(""); cleanup = NewString(""); outarg = NewString(""); kwargs = NewString(""); int allow_thread = threads_enable(n); Wrapper_add_local(f, "resultobj", "PyObject *resultobj = 0"); // Emit all of the local variables for holding arguments. emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); /* Get number of required and total arguments */ tuple_arguments = num_arguments = emit_num_arguments(l); tuple_required = num_required = emit_num_required(l); if (add_self) { --tuple_arguments; --tuple_required; } num_fixed_arguments = tuple_required; if (((num_arguments == 0) && (num_required == 0)) || ((num_arguments == 1) && (num_required == 1) && Getattr(l, "self"))) allow_kwargs = 0; varargs = emit_isvarargs(l); String *wname = Copy(wrapper_name); if (overname) { Append(wname, overname); } if (!allow_kwargs || overname) { if (!varargs) { Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL); } else { Printv(f->def, linkage, wrap_return, wname, "__varargs__", "(PyObject *", self_param, ", PyObject *args, PyObject *varargs) {", NIL); } if (allow_kwargs) { Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions (%s).\n", Swig_name_decl(n)); allow_kwargs = 0; } } else { if (varargs) { Swig_warning(WARN_LANG_VARARGS_KEYWORD, input_file, line_number, "Can't wrap varargs with keyword arguments enabled\n"); varargs = 0; } Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args, PyObject *kwargs) {", NIL); } if (!builtin || !in_class || tuple_arguments > 0) { if (!allow_kwargs) { Append(parse_args, " if (!PyArg_ParseTuple(args,(char *)\""); } else { Append(parse_args, " if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)\""); Append(arglist, ",kwnames"); } } if (overname) { String *over_varargs_attr = Getattr(n, "python:overvarargs"); if (!over_varargs_attr) { for (Node *sibling = n; sibling; sibling = Getattr(sibling, "sym:nextSibling")) { if (emit_isvarargs(Getattr(sibling, "parms"))) { over_varargs = true; break; } } over_varargs_attr = NewString(over_varargs ? "1" : "0"); for (Node *sibling = n; sibling; sibling = Getattr(sibling, "sym:nextSibling")) Setattr(sibling, "python:overvarargs", over_varargs_attr); } if (Strcmp(over_varargs_attr, "0") != 0) over_varargs = true; } int funpack = modernargs && fastunpack && !varargs && !over_varargs && !allow_kwargs; int noargs = funpack && (tuple_required == 0 && tuple_arguments == 0); int onearg = funpack && (tuple_required == 1 && tuple_arguments == 1); if (builtin && funpack && !overname && !builtin_ctor && !GetFlag(n, "feature:compactdefaultargs")) { String *argattr = NewStringf("%d", tuple_arguments); Setattr(n, "python:argcount", argattr); Delete(argattr); } /* Generate code for argument marshalling */ if (funpack) { if (overname) { if (aliasobj0) { Append(f->code, "#define obj0 (swig_obj[0])\n"); } } else if (num_arguments) { sprintf(source, "PyObject *swig_obj[%d]", num_arguments); Wrapper_add_localv(f, "swig_obj", source, NIL); if (aliasobj0) { Append(f->code, "#define obj0 (swig_obj[0])\n"); } } } if (constructor && num_arguments == 1 && num_required == 1) { if (Cmp(storage, "explicit") == 0) { if (GetFlag(parent, "feature:implicitconv")) { String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n, "type"))); Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc); Delete(desc); } } } if (builtin_ctor && checkAttribute(n, "access", "protected")) { String *tmp_none_comparison = Copy(none_comparison); Replaceall(tmp_none_comparison, "$arg", "self"); Printf(self_parse, "if (!(%s)) {\n", tmp_none_comparison); Printv(self_parse, " SWIG_SetErrorMsg(PyExc_RuntimeError, \"accessing abstract class or protected constructor\");\n SWIG_fail;\n}\n", NIL); Delete(tmp_none_comparison); } int use_parse = 0; Append(kwargs, "{"); for (i = 0, p = l; i < num_arguments; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *pn = Getattr(p, "name"); String *ln = Getattr(p, "lname"); bool parse_from_tuple = (i > 0 || !add_self); if (SwigType_type(pt) == T_VARARGS) { parse_from_tuple = false; num_fixed_arguments -= atoi(Char(Getattr(p, "tmap:in:numinputs"))); } if (!parse_from_tuple) sprintf(source, "self"); else if (funpack) sprintf(source, "swig_obj[%d]", add_self && !overname ? i - 1 : i); else sprintf(source, "obj%d", builtin_ctor ? i + 1 : i); if (parse_from_tuple) { Putc(',', arglist); if (i == num_required) Putc('|', parse_args); /* Optional argument separator */ } /* Keyword argument handling */ if (allow_kwargs && parse_from_tuple) { if (Len(pn)) { String *tmp = 0; String *name = pn; if (!Getattr(p, "hidden")) { name = tmp = Swig_name_make(p, 0, pn, 0, 0); // rename parameter if a keyword } Printf(kwargs, "(char *) \"%s\",", name); if (tmp) Delete(tmp); } else { Printf(kwargs, "(char *)\"arg%d\",", i + 1); } } /* Look for an input typemap */ if ((tm = Getattr(p, "tmap:in"))) { String *parse = Getattr(p, "tmap:in:parse"); if (!parse) { if (builtin_self) { Replaceall(tm, "$self", "self"); } else if (funpack) { Replaceall(tm, "$self", "swig_obj[0]"); } else { Replaceall(tm, "$self", "obj0"); } Replaceall(tm, "$source", source); Replaceall(tm, "$target", ln); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); /* Save the location of the object */ if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } if (Getattr(p, "tmap:in:implicitconv")) { const char *convflag = "0"; if (!Getattr(p, "hidden")) { SwigType *ptype = Getattr(p, "type"); convflag = get_implicitconv_flag(classLookup(ptype)); } Replaceall(tm, "$implicitconv", convflag); Setattr(p, "implicitconv", convflag); } if (parse_from_tuple) Putc('O', parse_args); if (!funpack && parse_from_tuple) { Wrapper_add_localv(f, source, "PyObject *", source, "= 0", NIL); Printf(arglist, "&%s", source); } if (i >= num_required) Printv(get_pointers, "if (", source, ") {\n", NIL); Printv(get_pointers, tm, "\n", NIL); if (i >= num_required) Printv(get_pointers, "}\n", NIL); } else { use_parse = 1; Append(parse_args, parse); if (parse_from_tuple) Printf(arglist, "&%s", ln); } p = Getattr(p, "tmap:in:next"); continue; } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } } /* finish argument marshalling */ Append(kwargs, " NULL }"); if (allow_kwargs) { Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL); } if (use_parse || allow_kwargs || !modernargs) { if (builtin && in_class && tuple_arguments == 0) { Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_fail;\n"); } else { Printf(parse_args, ":%s\"", iname); Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL); funpack = 0; } } else { Clear(parse_args); if (funpack) { Clear(f->def); if (overname) { if (noargs) { Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", int nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {", NIL); } else { Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", int nobjs, PyObject **swig_obj) {", NIL); } Printf(parse_args, "if ((nobjs < %d) || (nobjs > %d)) SWIG_fail;\n", num_required, num_arguments); } else { if (noargs) { Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL); } else { Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL); } if (onearg && !builtin_ctor) { Printf(parse_args, "if (!args) SWIG_fail;\n"); Append(parse_args, "swig_obj[0] = args;\n"); } else if (!noargs) { Printf(parse_args, "if (!SWIG_Python_UnpackTuple(args,\"%s\",%d,%d,swig_obj)) SWIG_fail;\n", iname, num_fixed_arguments, tuple_arguments); } else if (noargs) { Printf(parse_args, "if (!SWIG_Python_UnpackTuple(args,\"%s\",%d,%d,0)) SWIG_fail;\n", iname, num_fixed_arguments, tuple_arguments); } } } else { Printf(parse_args, "if(!PyArg_UnpackTuple(args,(char *)\"%s\",%d,%d", iname, num_fixed_arguments, tuple_arguments); Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL); } } /* Now piece together the first part of the wrapper function */ Printv(f->code, self_parse, parse_args, get_pointers, NIL); /* Check for trailing varargs */ if (varargs) { if (p && (tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$input", "varargs"); Printv(f->code, tm, "\n", NIL); } } /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ for (p = l; p;) { // if (!checkAttribute(p,"tmap:in:numinputs","0") && !Getattr(p,"tmap:in:parse")) { if (!Getattr(p, "tmap:in:parse") && (tm = Getattr(p, "tmap:freearg"))) { if (Getattr(p, "tmap:freearg:implicitconv")) { const char *convflag = "0"; if (!Getattr(p, "hidden")) { SwigType *ptype = Getattr(p, "type"); convflag = get_implicitconv_flag(classLookup(ptype)); } if (strcmp(convflag, "0") == 0) { tm = 0; } } if (tm && (Len(tm) != 0)) { Replaceall(tm, "$source", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); } p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } /* if the object is a director, and the method call originated from its * underlying python object, resolve the call by going up the c++ * inheritance chain. otherwise try to resolve the method in python. * without this check an infinite loop is set up between the director and * shadow class method calls. */ // NOTE: this code should only be inserted if this class is the // base class of a director class. however, in general we haven't // yet analyzed all classes derived from this one to see if they are // directors. furthermore, this class may be used as the base of // a director class defined in a completely different module at a // later time, so this test must be included whether or not directorbase // is true. we do skip this code if directors have not been enabled // at the command line to preserve source-level compatibility with // non-polymorphic swig. also, if this wrapper is for a smart-pointer // method, there is no need to perform the test since the calling object // (the smart-pointer) and the director object (the "pointee") are // distinct. director_method = is_member_director(n) && !is_smart_pointer() && !destructor; if (director_method) { Wrapper_add_local(f, "director", "Swig::Director *director = 0"); Append(f->code, "director = SWIG_DIRECTOR_CAST(arg1);\n"); if (dirprot_mode() && !is_public(n)) { Printf(f->code, "if (!director || !(director->swig_get_inner(\"%s\"))) {\n", name); Printf(f->code, "SWIG_SetErrorMsg(PyExc_RuntimeError,\"accessing protected member %s\");\n", name); Append(f->code, "SWIG_fail;\n"); Append(f->code, "}\n"); } Wrapper_add_local(f, "upcall", "bool upcall = false"); if (funpack) { const char *self_parm = builtin_self ? "self" : "swig_obj[0]"; Printf(f->code, "upcall = (director && (director->swig_get_self()==%s));\n", self_parm); } else { const char *self_parm = builtin_self ? "self" : "obj0"; Printf(f->code, "upcall = (director && (director->swig_get_self()==%s));\n", self_parm); } } /* Emit the function call */ if (director_method) { Append(f->code, "try {\n"); } else { if (allow_thread) { String *preaction = NewString(""); thread_begin_allow(n, preaction); Setattr(n, "wrap:preaction", preaction); String *postaction = NewString(""); thread_end_allow(n, postaction); Setattr(n, "wrap:postaction", postaction); } } Setattr(n, "wrap:name", wname); Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); if (director_method) { Append(actioncode, "} catch (Swig::DirectorException&) {\n"); Append(actioncode, " SWIG_fail;\n"); Append(actioncode, "}\n"); } /* This part below still needs cleanup */ /* Return the function value */ tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode); if (tm) { if (builtin_self) { Replaceall(tm, "$self", "self"); } else if (funpack) { Replaceall(tm, "$self", "swig_obj[0]"); } else { Replaceall(tm, "$self", "obj0"); } Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); if (builtin_ctor) { Replaceall(tm, "$owner", "SWIG_BUILTIN_INIT"); } else if (handled_as_init) { Replaceall(tm, "$owner", "SWIG_POINTER_NEW"); } else { if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "SWIG_POINTER_OWN"); } else { Replaceall(tm, "$owner", "0"); } } // FIXME: this will not try to unwrap directors returned as non-director // base class pointers! /* New addition to unwrap director return values so that the original * python object is returned instead. */ #if 1 int unwrap = 0; String *decl = Getattr(n, "decl"); int is_pointer = SwigType_ispointer_return(decl); int is_reference = SwigType_isreference_return(decl); if (is_pointer || is_reference) { String *type = Getattr(n, "type"); //Node *classNode = Swig_methodclass(n); //Node *module = Getattr(classNode, "module"); Node *module = Getattr(parent, "module"); Node *target = Swig_directormap(module, type); if (target) unwrap = 1; } if (unwrap) { Wrapper_add_local(f, "director", "Swig::Director *director = 0"); Printf(f->code, "director = SWIG_DIRECTOR_CAST(%s);\n", Swig_cresult_name()); Append(f->code, "if (director) {\n"); Append(f->code, " resultobj = director->swig_get_self();\n"); Append(f->code, " Py_INCREF(resultobj);\n"); Append(f->code, "} else {\n"); Printf(f->code, "%s\n", tm); Append(f->code, "}\n"); } else { Printf(f->code, "%s\n", tm); } #else Printf(f->code, "%s\n", tm); #endif Delete(tm); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); } emit_return_variable(n, d, f); /* Output argument output code */ Printv(f->code, outarg, NIL); /* Output cleanup code */ int need_cleanup = Len(cleanup) != 0; if (need_cleanup) { Printv(f->code, cleanup, NIL); } /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); Delete(tm); } } /* See if there is any return cleanup code */ if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); Delete(tm); } if (director_method) { if ((tm = Swig_typemap_lookup("directorfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$result", "resultobj"); Printf(f->code, "%s\n", tm); Delete(tm); } } if (builtin_ctor) Append(f->code, " return resultobj == Py_None ? -1 : 0;\n"); else Append(f->code, " return resultobj;\n"); /* Error handling code */ Append(f->code, "fail:\n"); if (need_cleanup) { Printv(f->code, cleanup, NIL); } if (builtin_ctor) Printv(f->code, " return -1;\n", NIL); else Printv(f->code, " return NULL;\n", NIL); if (funpack) { if (aliasobj0) { Append(f->code, "#if defined(obj0)\n"); Append(f->code, "#undef obj0\n"); Append(f->code, "#endif\n"); } } Append(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); /* Substitute the function name */ Replaceall(f->code, "$symname", iname); Replaceall(f->code, "$result", "resultobj"); if (builtin_self) { Replaceall(f->code, "$self", "self"); } else if (funpack) { Replaceall(f->code, "$self", "swig_obj[0]"); } else { Replaceall(f->code, "$self", "obj0"); } /* Dump the function out */ Wrapper_print(f, f_wrappers); /* If varargs. Need to emit a varargs stub */ if (varargs) { DelWrapper(f); f = NewWrapper(); if (funpack) { Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", int nobjs, PyObject **swig_obj) {", NIL); } else { Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL); } Wrapper_add_local(f, "resultobj", builtin_ctor ? "int resultobj" : "PyObject *resultobj"); Wrapper_add_local(f, "varargs", "PyObject *varargs"); Wrapper_add_local(f, "newargs", "PyObject *newargs"); if (funpack) { Wrapper_add_local(f, "i", "int i"); Printf(f->code, "newargs = PyTuple_New(%d);\n", num_fixed_arguments); Printf(f->code, "for (i = 0; i < %d; ++i) {\n", num_fixed_arguments); Printf(f->code, " PyTuple_SET_ITEM(newargs, i, swig_obj[i]);\n"); Printf(f->code, " Py_XINCREF(swig_obj[i]);\n"); Printf(f->code, "}\n"); Printf(f->code, "varargs = PyTuple_New(nobjs > %d ? nobjs - %d : 0);\n", num_fixed_arguments, num_fixed_arguments); Printf(f->code, "for (i = 0; i < nobjs - %d; ++i) {\n", num_fixed_arguments); Printf(f->code, " PyTuple_SET_ITEM(newargs, i, swig_obj[i + %d]);\n", num_fixed_arguments); Printf(f->code, " Py_XINCREF(swig_obj[i + %d]);\n", num_fixed_arguments); Printf(f->code, "}\n"); } else { Printf(f->code, "newargs = PyTuple_GetSlice(args,0,%d);\n", num_fixed_arguments); Printf(f->code, "varargs = PyTuple_GetSlice(args,%d,PyTuple_Size(args));\n", num_fixed_arguments); } Printf(f->code, "resultobj = %s__varargs__(%s,newargs,varargs);\n", wname, builtin ? "self" : "NULL"); Append(f->code, "Py_XDECREF(newargs);\n"); Append(f->code, "Py_XDECREF(varargs);\n"); Append(f->code, "return resultobj;\n"); Append(f->code, "}\n"); Wrapper_print(f, f_wrappers); } /* Now register the function with the interpreter. */ if (!Getattr(n, "sym:overloaded")) { if (!builtin_self) add_method(iname, wname, allow_kwargs, n, funpack, num_required, num_arguments); /* Create a shadow for this function (if enabled and not in a member function) */ if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) { emitFunctionShadowHelper(n, in_class ? f_shadow_stubs : f_shadow, iname, allow_kwargs); } } else { if (!Getattr(n, "sym:nextSibling")) { dispatchFunction(n, linkage, funpack, builtin_self, builtin_ctor, director_class); } } // Put this in tp_init of the PyTypeObject if (builtin_ctor) { if ((director_method || !is_private(n)) && !Getattr(class_members, iname)) { Setattr(class_members, iname, n); if (!builtin_tp_init) builtin_tp_init = Swig_name_wrapper(iname); } } /* If this is a builtin type, create a PyGetSetDef entry for this member variable. */ if (builtin_getter) { String *memname = Getattr(n, "membervariableHandler:sym:name"); if (!memname) memname = iname; Hash *h = Getattr(builtin_getset, memname); if (!h) { h = NewHash(); Setattr(builtin_getset, memname, h); Delete(h); } Setattr(h, "getter", wrapper_name); Delattr(n, "memberget"); } if (builtin_setter) { String *memname = Getattr(n, "membervariableHandler:sym:name"); if (!memname) memname = iname; Hash *h = Getattr(builtin_getset, memname); if (!h) { h = NewHash(); Setattr(builtin_getset, memname, h); Delete(h); } Setattr(h, "setter", wrapper_name); Delattr(n, "memberset"); } if (in_class && builtin) { /* Handle operator overloads overloads for builtin types */ String *slot = Getattr(n, "feature:python:slot"); if (slot) { String *func_type = Getattr(n, "feature:python:slot:functype"); String *closure_decl = getClosure(func_type, wrapper_name, overname ? 0 : funpack); String *feature_name = NewStringf("feature:python:%s", slot); String *closure_name = Copy(wrapper_name); if (closure_decl) { if (!Getattr(n, "sym:overloaded") || !Getattr(n, "sym:nextSibling")) Printv(f_wrappers, closure_decl, "\n\n", NIL); Append(closure_name, "_closure"); Delete(closure_decl); } if (func_type) { String *s = NewStringf("(%s) %s", func_type, closure_name); Delete(closure_name); closure_name = s; } Setattr(parent, feature_name, closure_name); Delete(feature_name); Delete(closure_name); } /* Handle comparison operators for builtin types */ String *compare = Getattr(n, "feature:python:compare"); if (compare) { Hash *richcompare = Getattr(parent, "python:richcompare"); assert(richcompare); Setattr(richcompare, compare, wrapper_name); } } Delete(self_parse); Delete(parse_args); Delete(linkage); Delete(arglist); Delete(get_pointers); Delete(cleanup); Delete(outarg); Delete(kwargs); Delete(wname); DelWrapper(f); Delete(wrapper_name); return SWIG_OK; } /* ------------------------------------------------------------ * variableWrapper() * ------------------------------------------------------------ */ virtual int variableWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *t = Getattr(n, "type"); static int have_globals = 0; String *tm; Wrapper *getf, *setf; if (!addSymbol(iname, n)) return SWIG_ERROR; getf = NewWrapper(); setf = NewWrapper(); /* If this is our first call, add the globals variable to the Python dictionary. */ if (!have_globals) { Printf(f_init, "\t PyDict_SetItemString(md,(char*)\"%s\", SWIG_globals());\n", global_name); if (builtin) Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", global_name); have_globals = 1; if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) { Printf(f_shadow_stubs, "%s = %s.%s\n", global_name, module, global_name); } } int assignable = is_assignable(n); if (!builtin && shadow && !assignable && !in_class) Printf(f_shadow_stubs, "%s = %s.%s\n", iname, global_name, iname); String *getname = Swig_name_get(NSPACE_TODO, iname); String *setname = Swig_name_set(NSPACE_TODO, iname); String *vargetname = NewStringf("Swig_var_%s", getname); String *varsetname = NewStringf("Swig_var_%s", setname); /* Create a function for setting the value of the variable */ if (assignable) { Setattr(n, "wrap:name", varsetname); if (builtin && in_class) { String *set_wrapper = Swig_name_wrapper(setname); Setattr(n, "pybuiltin:setter", set_wrapper); Delete(set_wrapper); } Printf(setf->def, "SWIGINTERN int %s(PyObject *_val) {", varsetname); if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { Replaceall(tm, "$source", "_val"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "_val"); if (Getattr(n, "tmap:varin:implicitconv")) { Replaceall(tm, "$implicitconv", get_implicitconv_flag(n)); } emit_action_code(n, setf->code, tm); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); } Printv(setf->code, " return 0;\n", NULL); Append(setf->code, "fail:\n"); Printv(setf->code, " return 1;\n", NULL); } else { /* Is a readonly variable. Issue an error */ if (CPlusPlus) { Printf(setf->def, "SWIGINTERN int %s(PyObject *) {", varsetname); } else { Printf(setf->def, "SWIGINTERN int %s(PyObject *_val SWIGUNUSED) {", varsetname); } Printv(setf->code, " SWIG_Error(SWIG_AttributeError,\"Variable ", iname, " is read-only.\");\n", " return 1;\n", NIL); } Append(setf->code, "}\n"); Wrapper_print(setf, f_wrappers); /* Create a function for getting the value of a variable */ Setattr(n, "wrap:name", vargetname); if (builtin && in_class) { String *get_wrapper = Swig_name_wrapper(getname); Setattr(n, "pybuiltin:getter", get_wrapper); Delete(get_wrapper); } int addfail = 0; Printf(getf->def, "SWIGINTERN PyObject *%s(void) {", vargetname); Wrapper_add_local(getf, "pyobj", "PyObject *pyobj = 0"); if (builtin) { Wrapper_add_local(getf, "self", "PyObject *self = 0"); Append(getf->code, " (void)self;\n"); } if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$source", name); Replaceall(tm, "$target", "pyobj"); Replaceall(tm, "$result", "pyobj"); addfail = emit_action_code(n, getf->code, tm); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0)); } Append(getf->code, " return pyobj;\n"); if (addfail) { Append(getf->code, "fail:\n"); Append(getf->code, " return NULL;\n"); } Append(getf->code, "}\n"); Wrapper_print(getf, f_wrappers); /* Now add this to the variable linking mechanism */ Printf(f_init, "\t SWIG_addvarlink(SWIG_globals(),(char*)\"%s\",%s, %s);\n", iname, vargetname, varsetname); if (builtin && shadow && !assignable && !in_class) { Printf(f_init, "\t PyDict_SetItemString(md, (char*)\"%s\", PyObject_GetAttrString(SWIG_globals(), \"%s\"));\n", iname, iname); Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", iname); } Delete(vargetname); Delete(varsetname); Delete(getname); Delete(setname); DelWrapper(setf); DelWrapper(getf); return SWIG_OK; } /* ------------------------------------------------------------ * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); String *tm; int have_tm = 0; int have_builtin_symname = 0; if (!addSymbol(iname, n)) return SWIG_ERROR; /* Special hook for member pointer */ if (SwigType_type(type) == T_MPOINTER) { String *wname = Swig_name_wrapper(iname); String *str = SwigType_str(type, wname); Printf(f_header, "static %s = %s;\n", str, value); Delete(str); value = wname; } if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); Replaceall(tm, "$value", value); Printf(const_code, "%s,\n", tm); Delete(tm); have_tm = 1; } if (builtin && in_class && Getattr(n, "pybuiltin:symname")) { have_builtin_symname = 1; Swig_require("builtin_constantWrapper", n, "*sym:name", "pybuiltin:symname", NIL); Setattr(n, "sym:name", Getattr(n, "pybuiltin:symname")); } if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); Replaceall(tm, "$value", value); Printf(f_init, "%s\n", tm); Delete(tm); have_tm = 1; } if (have_builtin_symname) Swig_restore(n); if (!have_tm) { Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); return SWIG_NOWRAP; } if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) { if (!in_class) { Printv(f_shadow, iname, " = ", module, ".", iname, "\n", NIL); } else { if (!(Getattr(n, "feature:python:callback"))) { Printv(f_shadow_stubs, iname, " = ", module, ".", iname, "\n", NIL); } } } return SWIG_OK; } /* ------------------------------------------------------------ * nativeWrapper() * ------------------------------------------------------------ */ virtual int nativeWrapper(Node *n) { String *name = Getattr(n, "sym:name"); String *wrapname = Getattr(n, "wrap:name"); if (!addSymbol(wrapname, n)) return SWIG_ERROR; add_method(name, wrapname, 0); if (!builtin && shadow) { Printv(f_shadow_stubs, name, " = ", module, ".", name, "\n", NIL); } return SWIG_OK; } /* ---------------------------------------------------------------------------- * BEGIN C++ Director Class modifications * ------------------------------------------------------------------------- */ /* C++/Python polymorphism demo code, copyright (C) 2002 Mark Rose * * TODO * * Move some boilerplate code generation to Swig_...() functions. * */ /* --------------------------------------------------------------- * classDirectorMethod() * * Emit a virtual director method to pass a method call on to the * underlying Python object. * ** Moved down due to gcc-2.96 internal error ** * --------------------------------------------------------------- */ int classDirectorMethods(Node *n); int classDirectorMethod(Node *n, Node *parent, String *super); /* ------------------------------------------------------------ * classDirectorConstructor() * ------------------------------------------------------------ */ int classDirectorConstructor(Node *n) { Node *parent = Getattr(n, "parentNode"); String *sub = NewString(""); String *decl = Getattr(n, "decl"); String *supername = Swig_class_name(parent); String *classname = NewString(""); Printf(classname, "SwigDirector_%s", supername); /* insert self parameter */ Parm *p; ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("PyObject"); SwigType_add_pointer(type); p = NewParm(type, NewString("self"), n); set_nextSibling(p, parms); parms = p; if (!Getattr(n, "defaultargs")) { /* constructor */ { Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self) { \n", classname, target, call); Printf(w->def, " SWIG_DIRECTOR_RGTR((%s *)this, this); \n", basetype); Append(w->def, "}\n"); Delete(target); Wrapper_print(w, f_directors); Delete(call); DelWrapper(w); } /* constructor header */ { String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } } Delete(sub); Delete(classname); Delete(supername); Delete(parms); return Language::classDirectorConstructor(n); } /* ------------------------------------------------------------ * classDirectorDefaultConstructor() * ------------------------------------------------------------ */ int classDirectorDefaultConstructor(Node *n) { String *classname = Swig_class_name(n); { Node *parent = Swig_methodclass(n); String *basetype = Getattr(parent, "classtype"); Wrapper *w = NewWrapper(); Printf(w->def, "SwigDirector_%s::SwigDirector_%s(PyObject* self) : Swig::Director(self) { \n", classname, classname); Printf(w->def, " SWIG_DIRECTOR_RGTR((%s *)this, this); \n", basetype); Append(w->def, "}\n"); Wrapper_print(w, f_directors); DelWrapper(w); } Printf(f_directors_h, " SwigDirector_%s(PyObject* self);\n", classname); Delete(classname); return Language::classDirectorDefaultConstructor(n); } /* ------------------------------------------------------------ * classDirectorInit() * ------------------------------------------------------------ */ int classDirectorInit(Node *n) { String *declaration = Swig_director_declaration(n); Printf(f_directors_h, "\n"); Printf(f_directors_h, "%s\n", declaration); Printf(f_directors_h, "public:\n"); Delete(declaration); return Language::classDirectorInit(n); } /* ------------------------------------------------------------ * classDirectorEnd() * ------------------------------------------------------------ */ int classDirectorEnd(Node *n) { String *classname = Swig_class_name(n); if (dirprot_mode()) { /* This implementation uses a std::map. It should be possible to rewrite it using a more elegant way, like copying the Java approach for the 'override' array. But for now, this seems to be the least intrusive way. */ Printf(f_directors_h, "\n"); Printf(f_directors_h, "/* Internal director utilities */\n"); Printf(f_directors_h, "public:\n"); Printf(f_directors_h, " bool swig_get_inner(const char *swig_protected_method_name) const {\n"); Printf(f_directors_h, " std::map::const_iterator iv = swig_inner.find(swig_protected_method_name);\n"); Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n"); Printf(f_directors_h, " }\n"); Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool val) const {\n"); Printf(f_directors_h, " swig_inner[swig_protected_method_name] = val;\n"); Printf(f_directors_h, " }\n"); Printf(f_directors_h, "private:\n"); Printf(f_directors_h, " mutable std::map swig_inner;\n"); } if (director_method_index) { Printf(f_directors_h, "\n"); Printf(f_directors_h, "#if defined(SWIG_PYTHON_DIRECTOR_VTABLE)\n"); Printf(f_directors_h, "/* VTable implementation */\n"); Printf(f_directors_h, " PyObject *swig_get_method(size_t method_index, const char *method_name) const {\n"); Printf(f_directors_h, " PyObject *method = vtable[method_index];\n"); Printf(f_directors_h, " if (!method) {\n"); Printf(f_directors_h, " swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);\n"); Printf(f_directors_h, " method = PyObject_GetAttr(swig_get_self(), name);\n"); Printf(f_directors_h, " if (!method) {\n"); Printf(f_directors_h, " std::string msg = \"Method in class %s doesn't exist, undefined \";\n", classname); Printf(f_directors_h, " msg += method_name;\n"); Printf(f_directors_h, " Swig::DirectorMethodException::raise(msg.c_str());\n"); Printf(f_directors_h, " }\n"); Printf(f_directors_h, " vtable[method_index] = method;\n"); Printf(f_directors_h, " }\n"); Printf(f_directors_h, " return method;\n"); Printf(f_directors_h, " }\n"); Printf(f_directors_h, "private:\n"); Printf(f_directors_h, " mutable swig::SwigVar_PyObject vtable[%d];\n", director_method_index); Printf(f_directors_h, "#endif\n\n"); } Printf(f_directors_h, "};\n\n"); return Language::classDirectorEnd(n); } /* ------------------------------------------------------------ * classDirectorDisown() * ------------------------------------------------------------ */ int classDirectorDisown(Node *n) { int result; int oldshadow = shadow; /* disable shadowing */ if (shadow) shadow = shadow | PYSHADOW_MEMBER; result = Language::classDirectorDisown(n); shadow = oldshadow; if (shadow) { if (builtin) { String *rname = SwigType_namestr(real_classname); Printf(builtin_methods, " { \"__disown__\", (PyCFunction) Swig::Director::swig_pyobj_disown< %s >, METH_NOARGS, \"\" },\n", rname); Delete(rname); } else { String *symname = Getattr(n, "sym:name"); String *mrename = Swig_name_disown(NSPACE_TODO, symname); //Getattr(n, "name")); Printv(f_shadow, tab4, "def __disown__(self):\n", NIL); #ifdef USE_THISOWN Printv(f_shadow, tab8, "self.thisown = 0\n", NIL); #else Printv(f_shadow, tab8, "self.this.disown()\n", NIL); #endif Printv(f_shadow, tab8, module, ".", mrename, "(self)\n", NIL); Printv(f_shadow, tab8, "return weakref_proxy(self)\n", NIL); Delete(mrename); } } return result; } /* ---------------------------------------------------------------------------- * END of C++ Director Class modifications * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * classDeclaration() * ------------------------------------------------------------ */ virtual int classDeclaration(Node *n) { if (shadow && !Getattr(n, "feature:onlychildren")) { Node *mod = Getattr(n, "module"); if (mod) { String *modname = Getattr(mod, "name"); Node *options = Getattr(mod, "options"); String *pkg = options ? Getattr(options, "package") : 0; String *sym = Getattr(n, "sym:name"); String *importname = import_name_string(package, mainmodule, pkg, modname, sym); Setattr(n, "python:proxy", importname); Delete(importname); } } int result = Language::classDeclaration(n); return result; } /* ------------------------------------------------------------ * classHandler() * ------------------------------------------------------------ */ String *add_explicit_scope(String *s) { if (!Strstr(s, "::")) { String *ss = NewStringf("::%s", s); Delete(s); s = ss; } return s; } void builtin_pre_decl(Node *n) { String *name = Getattr(n, "name"); String *rname = add_explicit_scope(SwigType_namestr(name)); String *mname = SwigType_manglestr(rname); Printf(f_init, "\n/* type '%s' */\n", rname); Printf(f_init, " builtin_pytype = (PyTypeObject *)&SwigPyBuiltin_%s_type;\n", mname); Printf(f_init, " builtin_pytype->tp_dict = d = PyDict_New();\n"); Delete(rname); Delete(mname); } void builtin_post_decl(File *f, Node *n) { String *name = Getattr(n, "name"); String *pname = Copy(name); SwigType_add_pointer(pname); String *symname = Getattr(n, "sym:name"); String *rname = add_explicit_scope(SwigType_namestr(name)); String *mname = SwigType_manglestr(rname); String *pmname = SwigType_manglestr(pname); String *templ = NewStringf("SwigPyBuiltin_%s", mname); int funpack = modernargs && fastunpack; Printv(f_init, " SwigPyBuiltin_SetMetaType(builtin_pytype, metatype);\n", NIL); Printf(f_init, " builtin_pytype->tp_new = PyType_GenericNew;\n"); Printv(f_init, " builtin_base_count = 0;\n", NIL); List *baselist = Getattr(n, "bases"); if (baselist) { int base_count = 0; for (Iterator b = First(baselist); b.item; b = Next(b)) { String *bname = Getattr(b.item, "name"); if (!bname || GetFlag(b.item, "feature:ignore")) continue; base_count++; String *base_name = Copy(bname); SwigType_add_pointer(base_name); String *base_mname = SwigType_manglestr(base_name); Printf(f_init, " builtin_basetype = SWIG_MangledTypeQuery(\"%s\");\n", base_mname); Printv(f_init, " if (builtin_basetype && builtin_basetype->clientdata && ((SwigPyClientData*) builtin_basetype->clientdata)->pytype) {\n", NIL); Printv(f_init, " builtin_bases[builtin_base_count++] = ((SwigPyClientData*) builtin_basetype->clientdata)->pytype;\n", NIL); Printv(f_init, " } else {\n", NIL); Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Could not create type '%s' as base '%s' has not been initialized.\\n\");\n", symname, bname); Printv(f_init, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); Printv(f_init, " return NULL;\n", NIL); Printv(f_init, "#else\n", NIL); Printv(f_init, " return;\n", NIL); Printv(f_init, "#endif\n", NIL); Printv(f_init, " }\n", NIL); Delete(base_name); Delete(base_mname); } if (base_count > max_bases) max_bases = base_count; } Printv(f_init, " builtin_bases[builtin_base_count] = NULL;\n", NIL); Printv(f_init, " SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases);\n", NIL); builtin_bases_needed = 1; // Check for non-public destructor, in which case tp_dealloc will issue // a warning and allow the memory to leak. Any class that doesn't explicitly // have a private/protected destructor has an implicit public destructor. String *tp_dealloc = Getattr(n, "feature:python:tp_dealloc"); if (tp_dealloc) { Printf(f, "SWIGPY_DESTRUCTOR_CLOSURE(%s)\n", tp_dealloc); tp_dealloc = NewStringf("%s_closure", tp_dealloc); } else { tp_dealloc = NewString("SwigPyBuiltin_BadDealloc"); } String *getset_name = NewStringf("%s_getset", templ); String *methods_name = NewStringf("%s_methods", templ); String *getset_def = NewString(""); Printf(getset_def, "SWIGINTERN PyGetSetDef %s[] = {\n", getset_name); // All objects have 'this' and 'thisown' attributes Printv(f_init, "PyDict_SetItemString(d, \"this\", this_descr);\n", NIL); Printv(f_init, "PyDict_SetItemString(d, \"thisown\", thisown_descr);\n", NIL); // Now, the rest of the attributes for (Iterator member_iter = First(builtin_getset); member_iter.item; member_iter = Next(member_iter)) { String *memname = member_iter.key; Hash *mgetset = member_iter.item; String *getter = Getattr(mgetset, "getter"); String *setter = Getattr(mgetset, "setter"); const char *getter_closure = getter ? funpack ? "SwigPyBuiltin_FunpackGetterClosure" : "SwigPyBuiltin_GetterClosure" : "0"; const char *setter_closure = setter ? funpack ? "SwigPyBuiltin_FunpackSetterClosure" : "SwigPyBuiltin_SetterClosure" : "0"; String *gspair = NewStringf("%s_%s_getset", symname, memname); Printf(f, "static SwigPyGetSet %s = { %s, %s };\n", gspair, getter ? getter : "0", setter ? setter : "0"); String *entry = NewStringf("{ (char*) \"%s\", (getter) %s, (setter) %s, (char*)\"%s.%s\", (void*) &%s }\n", memname, getter_closure, setter_closure, name, memname, gspair); if (GetFlag(mgetset, "static")) { Printf(f, "static PyGetSetDef %s_def = %s;\n", gspair, entry); Printf(f_init, "static_getset = SwigPyStaticVar_new_getset(metatype, &%s_def);\n", gspair); Printf(f_init, "PyDict_SetItemString(d, static_getset->d_getset->name, (PyObject*) static_getset);\n", memname); Printf(f_init, "Py_DECREF(static_getset);\n"); } else { Printf(getset_def, " %s,\n", entry); } Delete(gspair); Delete(entry); } Printv(f, getset_def, " {NULL, NULL, NULL, NULL, NULL} /* Sentinel */\n", "};\n\n", NIL); // Rich compare function Hash *richcompare = Getattr(n, "python:richcompare"); String *richcompare_func = NewStringf("%s_richcompare", templ); assert(richcompare); Printf(f, "SWIGINTERN PyObject *\n"); Printf(f, "%s(PyObject *self, PyObject *other, int op) {\n", richcompare_func); Printf(f, " PyObject *result = NULL;\n"); if (!funpack) { Printf(f, " PyObject *tuple = PyTuple_New(1);\n"); Printf(f, " assert(tuple);\n"); Printf(f, " PyTuple_SET_ITEM(tuple, 0, other);\n"); Printf(f, " Py_XINCREF(other);\n"); } Iterator rich_iter = First(richcompare); if (rich_iter.item) { Printf(f, " switch (op) {\n"); for (; rich_iter.item; rich_iter = Next(rich_iter)) Printf(f, " case %s : result = %s(self, %s); break;\n", rich_iter.key, rich_iter.item, funpack ? "other" : "tuple"); Printv(f, " default : break;\n", NIL); Printf(f, " }\n"); } Printv(f, " if (!result) {\n", NIL); Printv(f, " if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) {\n", NIL); Printv(f, " result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op);\n", NIL); Printv(f, " } else {\n", NIL); Printv(f, " result = Py_NotImplemented;\n", NIL); Printv(f, " Py_INCREF(result);\n", NIL); Printv(f, " }\n", NIL); Printv(f, " }\n", NIL); if (!funpack) Printf(f, " Py_DECREF(tuple);\n"); Printf(f, " return result;\n"); Printf(f, "}\n\n"); // Methods Printf(f, "SWIGINTERN PyMethodDef %s_methods[] = {\n", templ); Dump(builtin_methods, f); Printf(f, " { NULL, NULL, 0, NULL } /* Sentinel */\n};\n\n"); // No instance dict for nondynamic objects if (GetFlag(n, "feature:python:nondynamic")) Setattr(n, "feature:python:tp_setattro", "SWIG_Python_NonDynamicSetAttr"); Node *mod = Getattr(n, "module"); String *modname = mod ? Getattr(mod, "name") : 0; String *quoted_symname; if (package) { if (modname) quoted_symname = NewStringf("\"%s.%s.%s\"", package, modname, symname); else quoted_symname = NewStringf("\"%s.%s\"", package, symname); } else { if (modname) quoted_symname = NewStringf("\"%s.%s\"", modname, symname); else quoted_symname = NewStringf("\"%s\"", symname); } String *quoted_rname = NewStringf("\"%s\"", rname); char const *tp_init = builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "SwigPyBuiltin_BadInit"; String *tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES"); String *py3_tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE"); Printf(f, "static PyHeapTypeObject %s_type = {\n", templ); // PyTypeObject ht_type Printf(f, " {\n"); Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); Printv(f, " PyVarObject_HEAD_INIT(NULL, 0)\n", NIL); Printv(f, "#else\n", NIL); Printf(f, " PyObject_HEAD_INIT(NULL)\n"); printSlot(f, getSlot(), "ob_size"); Printv(f, "#endif\n", NIL); printSlot(f, quoted_symname, "tp_name"); printSlot(f, "sizeof(SwigPyObject)", "tp_basicsize"); printSlot(f, getSlot(n, "feature:python:tp_itemsize"), "tp_itemsize"); printSlot(f, tp_dealloc, "tp_dealloc", "destructor"); printSlot(f, getSlot(n, "feature:python:tp_print"), "tp_print", "printfunc"); printSlot(f, getSlot(n, "feature:python:tp_getattr"), "tp_getattr", "getattrfunc"); printSlot(f, getSlot(n, "feature:python:tp_setattr"), "tp_setattr", "setattrfunc"); Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_compare"), "tp_compare"); Printv(f, "#else\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_compare"), "tp_compare", "cmpfunc"); Printv(f, "#endif\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_repr"), "tp_repr", "reprfunc"); Printf(f, " &%s_type.as_number, /* tp_as_number */\n", templ); Printf(f, " &%s_type.as_sequence, /* tp_as_sequence */\n", templ); Printf(f, " &%s_type.as_mapping, /* tp_as_mapping */\n", templ); printSlot(f, getSlot(n, "feature:python:tp_hash"), "tp_hash", "hashfunc"); printSlot(f, getSlot(n, "feature:python:tp_call"), "tp_call", "ternaryfunc"); printSlot(f, getSlot(n, "feature:python:tp_str"), "tp_str", "reprfunc"); printSlot(f, getSlot(n, "feature:python:tp_getattro"), "tp_getattro", "getattrofunc"); printSlot(f, getSlot(n, "feature:python:tp_setattro"), "tp_setattro", "setattrofunc"); Printf(f, " &%s_type.as_buffer, /* tp_as_buffer */\n", templ); Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); printSlot(f, py3_tp_flags, "tp_flags"); Printv(f, "#else\n", NIL); printSlot(f, tp_flags, "tp_flags"); Printv(f, "#endif\n", NIL); printSlot(f, quoted_rname, "tp_doc"); printSlot(f, getSlot(n, "feature:python:tp_traverse"), "tp_traverse", "traverseproc"); printSlot(f, getSlot(n, "feature:python:tp_clear"), "tp_clear", "inquiry"); printSlot(f, richcompare_func, "feature:python:tp_richcompare", "richcmpfunc"); printSlot(f, getSlot(n, "feature:python:tp_weaklistoffset"), "tp_weaklistoffset"); printSlot(f, getSlot(n, "feature:python:tp_iter"), "tp_iter", "getiterfunc"); printSlot(f, getSlot(n, "feature:python:tp_iternext"), "tp_iternext", "iternextfunc"); printSlot(f, methods_name, "tp_methods"); printSlot(f, getSlot(n, "feature:python:tp_members"), "tp_members"); printSlot(f, getset_name, "tp_getset"); printSlot(f, getSlot(n, "feature:python:tp_base"), "tp_base"); printSlot(f, getSlot(n, "feature:python:tp_dict"), "tp_dict"); printSlot(f, getSlot(n, "feature:python:tp_descr_get"), "tp_descr_get", "descrgetfunc"); printSlot(f, getSlot(n, "feature:python:tp_descr_set"), "tp_descr_set", "descrsetfunc"); Printf(f, " (Py_ssize_t)offsetof(SwigPyObject, dict), /* tp_dictoffset */\n"); printSlot(f, tp_init, "tp_init", "initproc"); printSlot(f, getSlot(n, "feature:python:tp_alloc"), "tp_alloc", "allocfunc"); printSlot(f, "0", "tp_new", "newfunc"); printSlot(f, getSlot(n, "feature:python:tp_free"), "tp_free", "freefunc"); printSlot(f, getSlot(), "tp_is_gc", "inquiry"); printSlot(f, getSlot(), "tp_bases", "PyObject*"); printSlot(f, getSlot(), "tp_mro", "PyObject*"); printSlot(f, getSlot(), "tp_cache", "PyObject*"); printSlot(f, getSlot(), "tp_subclasses", "PyObject*"); printSlot(f, getSlot(), "tp_weaklist", "PyObject*"); printSlot(f, getSlot(), "tp_del", "destructor"); Printv(f, "#if PY_VERSION_HEX >= 0x02060000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_version_tag"), "tp_version_tag", "int"); Printv(f, "#endif\n", NIL); Printf(f, " },\n"); // PyNumberMethods as_number Printf(f, " {\n"); printSlot(f, getSlot(n, "feature:python:nb_add"), "nb_add", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_subtract"), "nb_subtract", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_multiply"), "nb_multiply", "binaryfunc"); Printv(f, "#if PY_VERSION_HEX < 0x03000000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_divide"), "nb_divide", "binaryfunc"); Printv(f, "#endif\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_remainder"), "nb_remainder", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_divmod"), "nb_divmod", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_power"), "nb_power", "ternaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_negative"), "nb_negative", "unaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_positive"), "nb_positive", "unaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_absolute"), "nb_absolute", "unaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_nonzero"), "nb_nonzero", "inquiry"); printSlot(f, getSlot(n, "feature:python:nb_invert"), "nb_invert", "unaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_lshift"), "nb_lshift", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_rshift"), "nb_rshift", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_and"), "nb_and", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_xor"), "nb_xor", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_or"), "nb_or", "binaryfunc"); Printv(f, "#if PY_VERSION_HEX < 0x03000000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_coerce"), "nb_coerce", "coercion"); Printv(f, "#endif\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_int"), "nb_int", "unaryfunc"); Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_reserved"), "nb_reserved", "void*"); Printv(f, "#else\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_long"), "nb_long", "unaryfunc"); Printv(f, "#endif\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_float"), "nb_float", "unaryfunc"); Printv(f, "#if PY_VERSION_HEX < 0x03000000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_oct"), "nb_oct", "unaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_hex"), "nb_hex", "unaryfunc"); Printv(f, "#endif\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_inplace_add"), "nb_inplace_add", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_subtract"), "nb_inplace_subtract", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_multiply"), "nb_inplace_multiply", "binaryfunc"); Printv(f, "#if PY_VERSION_HEX < 0x03000000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_inplace_divide"), "nb_inplace_divide", "binaryfunc"); Printv(f, "#endif\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_inplace_remainder"), "nb_inplace_remainder", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_power"), "nb_inplace_power", "ternaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_lshift"), "nb_inplace_lshift", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_rshift"), "nb_inplace_rshift", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_and"), "nb_inplace_and", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_xor"), "nb_inplace_xor", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_or"), "nb_inplace_or", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_floor_divide"), "nb_floor_divide", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_true_divide"), "nb_true_divide", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_floor_divide"), "nb_inplace_floor_divide", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_true_divide"), "nb_inplace_true_divide", "binaryfunc"); Printv(f, "#if PY_VERSION_HEX >= 0x02050000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_index"), "nb_index", "unaryfunc"); Printv(f, "#endif\n", NIL); Printf(f, " },\n"); // PyMappingMethods as_mapping; Printf(f, " {\n"); printSlot(f, getSlot(n, "feature:python:mp_length"), "mp_length", "lenfunc"); printSlot(f, getSlot(n, "feature:python:mp_subscript"), "mp_subscript", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:mp_ass_subscript"), "mp_ass_subscript", "objobjargproc"); Printf(f, " },\n"); // PySequenceMethods as_sequence; Printf(f, " {\n"); printSlot(f, getSlot(n, "feature:python:sq_length"), "sq_length", "lenfunc"); printSlot(f, getSlot(n, "feature:python:sq_concat"), "sq_concat", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:sq_repeat"), "sq_repeat", "ssizeargfunc"); printSlot(f, getSlot(n, "feature:python:sq_item"), "sq_item", "ssizeargfunc"); Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); printSlot(f, getSlot(n, "feature:was_sq_slice"), "was_sq_slice", "void*"); Printv(f, "#else\n", NIL); printSlot(f, getSlot(n, "feature:python:sq_slice"), "sq_slice", "ssizessizeargfunc"); Printv(f, "#endif\n", NIL); printSlot(f, getSlot(n, "feature:python:sq_ass_item"), "sq_ass_item", "ssizeobjargproc"); Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); printSlot(f, getSlot(n, "feature:was_sq_ass_slice"), "was_sq_ass_slice", "void*"); Printv(f, "#else\n", NIL); printSlot(f, getSlot(n, "feature:python:sq_ass_slice"), "sq_ass_slice", "ssizessizeobjargproc"); Printv(f, "#endif\n", NIL); printSlot(f, getSlot(n, "feature:python:sq_contains"), "sq_contains", "objobjproc"); printSlot(f, getSlot(n, "feature:python:sq_inplace_concat"), "sq_inplace_concat", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:sq_inplace_repeat"), "sq_inplace_repeat", "ssizeargfunc"); Printf(f, " },\n"); // PyBufferProcs as_buffer; Printf(f, " {\n"); Printv(f, "#if PY_VERSION_HEX < 0x03000000\n", NIL); printSlot(f, getSlot(n, "feature:python:bf_getreadbuffer"), "bf_getreadbuffer", "readbufferproc"); printSlot(f, getSlot(n, "feature:python:bf_getwritebuffer"), "bf_getwritebuffer", "writebufferproc"); printSlot(f, getSlot(n, "feature:python:bf_getsegcount"), "bf_getsegcount", "segcountproc"); printSlot(f, getSlot(n, "feature:python:bf_getcharbuffer"), "bf_getcharbuffer", "charbufferproc"); Printv(f, "#endif\n", NIL); Printv(f, "#if PY_VERSION_HEX >= 0x02060000\n", NIL); printSlot(f, getSlot(n, "feature:python:bf_getbuffer"), "bf_getbuffer", "getbufferproc"); printSlot(f, getSlot(n, "feature:python:bf_releasebuffer"), "bf_releasebuffer", "releasebufferproc"); Printv(f, "#endif\n", NIL); Printf(f, " },\n"); // PyObject *ht_name, *ht_slots printSlot(f, getSlot(n, "feature:python:ht_name"), "ht_name", "PyObject*"); printSlot(f, getSlot(n, "feature:python:ht_slots"), "ht_slots", "PyObject*"); Printf(f, "};\n\n"); String *clientdata = NewString(""); Printf(clientdata, "&%s_clientdata", templ); SwigType_remember_mangleddata(pmname, clientdata); String *smartptr = Getattr(n, "feature:smartptr"); if (smartptr) { SwigType *spt = Swig_cparse_type(smartptr); SwigType *smart = SwigType_typedef_resolve_all(spt); SwigType_add_pointer(smart); String *smart_pmname = SwigType_manglestr(smart); SwigType_remember_mangleddata(smart_pmname, clientdata); Delete(spt); Delete(smart); Delete(smart_pmname); } String *clientdata_klass = NewString("0"); if (GetFlag(n, "feature:implicitconv")) { Clear(clientdata_klass); Printf(clientdata_klass, "(PyObject*) &%s_type", templ); } Printf(f, "SWIGINTERN SwigPyClientData %s_clientdata = {%s, 0, 0, 0, 0, 0, (PyTypeObject *)&%s_type};\n\n", templ, clientdata_klass, templ); Printv(f_init, " if (PyType_Ready(builtin_pytype) < 0) {\n", NIL); Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Could not create type '%s'.\");\n", symname); Printv(f_init, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); Printv(f_init, " return NULL;\n", NIL); Printv(f_init, "#else\n", NIL); Printv(f_init, " return;\n", NIL); Printv(f_init, "#endif\n", NIL); Printv(f_init, " }\n", NIL); Printv(f_init, " Py_INCREF(builtin_pytype);\n", NIL); Printf(f_init, " PyModule_AddObject(m, \"%s\", (PyObject*) builtin_pytype);\n", symname); Printf(f_init, " SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", symname); Printv(f_init, " d = md;\n", NIL); Delete(clientdata); Delete(rname); Delete(pname); Delete(mname); Delete(pmname); Delete(templ); Delete(tp_dealloc); Delete(tp_flags); Delete(py3_tp_flags); Delete(quoted_symname); Delete(quoted_rname); Delete(clientdata_klass); Delete(richcompare_func); Delete(getset_name); Delete(methods_name); } virtual int classHandler(Node *n) { int oldclassic = classic; int oldmodern = modern; File *f_shadow_file = f_shadow; Node *base_node = NULL; if (shadow) { /* Create new strings for building up a wrapper function */ have_constructor = 0; have_repr = 0; if (GetFlag(n, "feature:classic")) { classic = 1; modern = 0; } if (GetFlag(n, "feature:modern")) { classic = 0; modern = 1; } if (GetFlag(n, "feature:exceptionclass")) { classic = 1; modern = 0; } class_name = Getattr(n, "sym:name"); real_classname = Getattr(n, "name"); if (!addSymbol(class_name, n)) return SWIG_ERROR; if (builtin) { List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist) > 0) { Iterator b = First(baselist); base_node = b.item; } } shadow_indent = (String *) tab4; /* Handle inheritance */ String *base_class = NewString(""); List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist)) { Iterator b; b = First(baselist); while (b.item) { String *bname = Getattr(b.item, "python:proxy"); bool ignore = GetFlag(b.item, "feature:ignore") ? true : false; if (!bname || ignore) { if (!bname && !ignore) { Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(n), Getline(n), "Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n", SwigType_namestr(Getattr(b.item, "name"))); } b = Next(b); continue; } Printv(base_class, bname, NIL); b = Next(b); if (b.item) { Putc(',', base_class); } } } if (builtin) { Hash *base_richcompare = NULL; Hash *richcompare = NULL; if (base_node) base_richcompare = Getattr(base_node, "python:richcompare"); if (base_richcompare) richcompare = Copy(base_richcompare); else richcompare = NewHash(); Setattr(n, "python:richcompare", richcompare); } /* dealing with abstract base class */ String *abcs = Getattr(n, "feature:python:abc"); if (py3 && abcs) { if (Len(base_class)) { Putc(',', base_class); } Printv(base_class, abcs, NIL); } if (builtin) { if (have_docstring(n)) { String *str = cdocstring(n, AUTODOC_CLASS); Setattr(n, "feature:python:tp_doc", str); Delete(str); } } else { Printv(f_shadow, "class ", class_name, NIL); if (Len(base_class)) { Printf(f_shadow, "(%s)", base_class); } else { if (!classic) { Printf(f_shadow, modern ? "(object)" : "(_object)"); } if (GetFlag(n, "feature:exceptionclass")) { Printf(f_shadow, "(Exception)"); } } Printf(f_shadow, ":\n"); if (have_docstring(n)) { String *str = docstring(n, AUTODOC_CLASS, tab4); if (str && Len(str)) Printv(f_shadow, tab4, str, "\n", NIL); } if (!modern) { Printv(f_shadow, tab4, "__swig_setmethods__ = {}\n", NIL); if (Len(base_class)) { Printf(f_shadow, "%sfor _s in [%s]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))\n", tab4, base_class); } if (!GetFlag(n, "feature:python:nondynamic")) { Printv(f_shadow, tab4, "__setattr__ = lambda self, name, value: _swig_setattr(self, ", class_name, ", name, value)\n", NIL); } else { Printv(f_shadow, tab4, "__setattr__ = lambda self, name, value: _swig_setattr_nondynamic(self, ", class_name, ", name, value)\n", NIL); } Printv(f_shadow, tab4, "__swig_getmethods__ = {}\n", NIL); if (Len(base_class)) { Printf(f_shadow, "%sfor _s in [%s]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))\n", tab4, base_class); } Printv(f_shadow, tab4, "__getattr__ = lambda self, name: _swig_getattr(self, ", class_name, ", name)\n", NIL); } else { Printv(f_shadow, tab4, "thisown = _swig_property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc='The membership flag')\n", NIL); /* Add static attribute */ if (GetFlag(n, "feature:python:nondynamic")) { Printv(f_shadow_file, tab4, "__setattr__ = _swig_setattr_nondynamic_method(object.__setattr__)\n", tab4, "class __metaclass__(type):\n", tab4, tab4, "__setattr__ = _swig_setattr_nondynamic_method(type.__setattr__)\n", NIL); } } } } /* Emit all of the members */ in_class = 1; if (builtin) builtin_pre_decl(n); /* Override the shadow file so we can capture its methods */ f_shadow = NewString(""); // Set up type check for director class constructor Clear(none_comparison); if (builtin && Swig_directorclass(n)) { String *p_real_classname = Copy(real_classname); SwigType_add_pointer(p_real_classname); String *mangle = SwigType_manglestr(p_real_classname); String *descriptor = NewStringf("SWIGTYPE%s", mangle); Printv(none_comparison, "self->ob_type != ((SwigPyClientData*) (", descriptor, ")->clientdata)->pytype", NIL); Delete(descriptor); Delete(mangle); Delete(p_real_classname); } else { Printv(none_comparison, "$arg != Py_None", NIL); } Language::classHandler(n); in_class = 0; /* Complete the class */ if (shadow) { /* Generate a class registration function */ String *smartptr = Getattr(n, "feature:smartptr"); // Replace storing a pointer to underlying class with a smart pointer (intended for use with non-intrusive smart pointers) SwigType *smart = 0; if (smartptr) { SwigType *cpt = Swig_cparse_type(smartptr); if (cpt) { smart = SwigType_typedef_resolve_all(cpt); Delete(cpt); } else { // TODO: report line number of where the feature comes from Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, real_classname); } } SwigType *ct = Copy(smart ? smart : real_classname); SwigType_add_pointer(ct); SwigType *realct = Copy(real_classname); SwigType_add_pointer(realct); SwigType_remember(realct); if (!builtin) { Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); Printv(f_wrappers, " PyObject *obj;\n", NIL); if (modernargs) { if (fastunpack) { Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); } else { Printv(f_wrappers, " if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); } } else { Printv(f_wrappers, " if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL); } Printv(f_wrappers, " SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n", " return SWIG_Py_Void();\n", "}\n\n", NIL); String *cname = NewStringf("%s_swigregister", class_name); add_method(cname, cname, 0); Delete(cname); } Delete(smart); Delete(ct); Delete(realct); if (!have_constructor) { if (!builtin) Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined", (Getattr(n, "abstracts") ? " - class is abstract" : ""), "\")\n", NIL); } else if (fastinit && !builtin) { Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); Printv(f_wrappers, " return SWIG_Python_InitShadowInstance(args);\n", "}\n\n", NIL); String *cname = NewStringf("%s_swiginit", class_name); add_method(cname, cname, 0); Delete(cname); } if (!have_repr && !builtin) { /* Supply a repr method for this class */ String *rname = SwigType_namestr(real_classname); if (new_repr) { Printv(f_shadow_file, tab4, "__repr__ = _swig_repr\n", NIL); } else { Printv(f_shadow_file, tab4, "def __repr__(self):\n", tab8, "return \"\" % (self.this,)\n", NIL); } Delete(rname); } if (builtin) builtin_post_decl(f_builtins, n); if (builtin_tp_init) { Delete(builtin_tp_init); builtin_tp_init = 0; } /* Now emit methods */ if (!builtin) Printv(f_shadow_file, f_shadow, NIL); /* Now the Ptr class */ if (classptr && !builtin) { Printv(f_shadow_file, "\nclass ", class_name, "Ptr(", class_name, "):\n", tab4, "def __init__(self, this):\n", NIL); if (!modern) { Printv(f_shadow_file, tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL); } else { Printv(f_shadow_file, tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL); } } if (!builtin) { if (fastproxy) { List *shadow_list = Getattr(n, "shadow_methods"); for (int i = 0; i < Len(shadow_list); ++i) { String *symname = Getitem(shadow_list, i); Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname), class_name); } } Printf(f_shadow_file, "%s_swigregister = %s.%s_swigregister\n", class_name, module, class_name); Printf(f_shadow_file, "%s_swigregister(%s)\n", class_name, class_name); } shadow_indent = 0; Printf(f_shadow_file, "%s\n", f_shadow_stubs); Clear(f_shadow_stubs); } if (builtin) { Clear(class_members); Clear(builtin_getset); Clear(builtin_methods); } classic = oldclassic; modern = oldmodern; /* Restore shadow file back to original version */ Delete(f_shadow); f_shadow = f_shadow_file; return SWIG_OK; } /* ------------------------------------------------------------ * functionHandler() - Mainly overloaded for callback handling * ------------------------------------------------------------ */ virtual int functionHandler(Node *n) { String *pcb = GetFlagAttr(n, "feature:python:callback"); if (pcb) { if (Strcmp(pcb, "1") == 0) { SetFlagAttr(n, "feature:callback", "%s_cb_ptr"); } else { SetFlagAttr(n, "feature:callback", pcb); } autodoc_l dlevel = autodoc_level(Getattr(n, "feature:autodoc")); if (dlevel != NO_AUTODOC && dlevel > TYPES_AUTODOC) { Setattr(n, "feature:autodoc", "1"); } } return Language::functionHandler(n); } /* ------------------------------------------------------------ * memberfunctionHandler() * ------------------------------------------------------------ */ virtual int memberfunctionHandler(Node *n) { String *symname = Getattr(n, "sym:name"); int oldshadow; if (builtin) Swig_save("builtin_memberfunc", n, "python:argcount", NIL); /* Create the default member function */ oldshadow = shadow; /* Disable shadowing when wrapping member functions */ if (shadow) shadow = shadow | PYSHADOW_MEMBER; Language::memberfunctionHandler(n); shadow = oldshadow; if (builtin && in_class) { // Can't use checkAttribute(n, "access", "public") because // "access" attr isn't set on %extend methods if (!checkAttribute(n, "access", "private") && strncmp(Char(symname), "operator ", 9) && !Getattr(class_members, symname)) { String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname); String *wname = Swig_name_wrapper(fullname); Setattr(class_members, symname, n); int argcount = Getattr(n, "python:argcount") ? atoi(Char(Getattr(n, "python:argcount"))) : 2; String *ds = have_docstring(n) ? cdocstring(n, AUTODOC_FUNC) : NewString(""); if (check_kwargs(n)) { Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS|METH_KEYWORDS, (char*) \"%s\" },\n", symname, wname, ds); } else if (argcount == 0) { Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_NOARGS, (char*) \"%s\" },\n", symname, wname, ds); } else if (argcount == 1) { Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_O, (char*) \"%s\" },\n", symname, wname, ds); } else { Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS, (char*) \"%s\" },\n", symname, wname, ds); } Delete(fullname); Delete(wname); Delete(ds); } } if (builtin) Swig_restore(n); if (!Getattr(n, "sym:nextSibling")) { if (shadow && !builtin) { int fproxy = fastproxy; String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname); if (Strcmp(symname, "__repr__") == 0) { have_repr = 1; } if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4); String *pyaction = NewStringf("%s.%s", module, fullname); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow, pycode, "\n", NIL); Delete(pycode); fproxy = 0; } else { int allow_kwargs = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0; String *parms = make_pyParmList(n, true, false, allow_kwargs); String *callParms = make_pyParmList(n, true, true, allow_kwargs); if (!have_addtofunc(n)) { if (!fastproxy || olddefs) { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, " return ", funcCall(fullname, callParms), "\n", NIL); } } else { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); if (have_pythonprepend(n)) { fproxy = 0; Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); } if (have_pythonappend(n)) { fproxy = 0; Printv(f_shadow, tab8, "val = ", funcCall(fullname, callParms), "\n", NIL); Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n\n", NIL); } } } if (fproxy) { List *shadow_list = Getattr(getCurrentClass(), "shadow_methods"); if (!shadow_list) { shadow_list = NewList(); Setattr(getCurrentClass(), "shadow_methods", shadow_list); Delete(shadow_list); } Append(shadow_list, symname); } Delete(fullname); } } return SWIG_OK; } /* ------------------------------------------------------------ * staticmemberfunctionHandler() * ------------------------------------------------------------ */ virtual int staticmemberfunctionHandler(Node *n) { String *symname = Getattr(n, "sym:name"); if (builtin && in_class) { Swig_save("builtin_memberconstantHandler", n, "pybuiltin:symname", NIL); Setattr(n, "pybuiltin:symname", symname); } Language::staticmemberfunctionHandler(n); if (builtin && in_class) { Swig_restore(n); } if (builtin && in_class) { if ((GetFlagAttr(n, "feature:extend") || checkAttribute(n, "access", "public")) && !Getattr(class_members, symname)) { String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname); String *wname = Swig_name_wrapper(fullname); Setattr(class_members, symname, n); int funpack = modernargs && fastunpack && !Getattr(n, "sym:overloaded"); String *pyflags = NewString("METH_STATIC|"); int argcount = Getattr(n, "python:argcount") ? atoi(Char(Getattr(n, "python:argcount"))) : 2; if (funpack && argcount == 0) Append(pyflags, "METH_NOARGS"); else if (funpack && argcount == 1) Append(pyflags, "METH_O"); else Append(pyflags, "METH_VARARGS"); if (have_docstring(n)) { String *ds = cdocstring(n, AUTODOC_STATICFUNC); Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, %s, (char*) \"%s\" },\n", symname, wname, pyflags, ds); Delete(ds); } else { Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, %s, \"\" },\n", symname, wname, pyflags); } Delete(fullname); Delete(wname); Delete(pyflags); } return SWIG_OK; } if (Getattr(n, "sym:nextSibling")) { return SWIG_OK; } if (shadow) { if (!classic && !Getattr(n, "feature:python:callback") && have_addtofunc(n)) { int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0; String *parms = make_pyParmList(n, false, false, kw); String *callParms = make_pyParmList(n, false, true, kw); Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); if (have_pythonprepend(n)) Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); if (have_pythonappend(n)) { Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL); } Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL); if (!modern) { Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", symname, "\n", NIL); } } else { if (!modern) { Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL); } if (!classic) { Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), ")\n", NIL); } } } return SWIG_OK; } /* ------------------------------------------------------------ * constructorDeclaration() * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { String *symname = Getattr(n, "sym:name"); int oldshadow = shadow; int use_director = Swig_directorclass(n); /* * If we're wrapping the constructor of a C++ director class, prepend a new parameter * to receive the scripting language object (e.g. 'self') * */ Swig_save("python:constructorHandler", n, "parms", NIL); if (use_director) { Parm *parms = Getattr(n, "parms"); Parm *self; String *name = NewString("self"); String *type = NewString("PyObject"); SwigType_add_pointer(type); self = NewParm(type, name, n); Delete(type); Delete(name); Setattr(self, "lname", "O"); if (parms) set_nextSibling(self, parms); Setattr(n, "parms", self); Setattr(n, "wrap:self", "1"); Setattr(n, "hidden", "1"); Delete(self); } if (shadow) shadow = shadow | PYSHADOW_MEMBER; Language::constructorHandler(n); shadow = oldshadow; Delattr(n, "wrap:self"); Swig_restore(n); if (!Getattr(n, "sym:nextSibling")) { if (shadow) { int allow_kwargs = (check_kwargs(n) && (!Getattr(n, "sym:overloaded"))) ? 1 : 0; int handled_as_init = 0; if (!have_constructor) { String *nname = Getattr(n, "sym:name"); String *sname = Getattr(getCurrentClass(), "sym:name"); String *cname = Swig_name_construct(NSPACE_TODO, sname); handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0); Delete(cname); } if (!have_constructor && handled_as_init) { if (!builtin) { if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4); String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow, pycode, "\n", NIL); Delete(pycode); } else { String *pass_self = NewString(""); Node *parent = Swig_methodclass(n); String *classname = Swig_class_name(parent); String *rclassname = Swig_class_name(getCurrentClass()); assert(rclassname); String *parms = make_pyParmList(n, true, false, allow_kwargs); /* Pass 'self' only if using director */ String *callParms = make_pyParmList(n, false, true, allow_kwargs); if (use_director) { Insert(callParms, 0, "_self, "); Printv(pass_self, tab8, NIL); Printf(pass_self, "if self.__class__ == %s:\n", classname); //Printv(pass_self, tab8, tab4, "args = (None,) + args\n", tab8, "else:\n", tab8, tab4, "args = (self,) + args\n", NIL); Printv(pass_self, tab8, tab4, "_self = None\n", tab8, "else:\n", tab8, tab4, "_self = self\n", NIL); } Printv(f_shadow, tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ": \n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); Printv(f_shadow, pass_self, NIL); if (fastinit) { Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL); } else { Printv(f_shadow, tab8, "this = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n", tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL); } if (have_pythonappend(n)) Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n\n", NIL); Delete(pass_self); } have_constructor = 1; } } else { /* Hmmm. We seem to be creating a different constructor. We're just going to create a function for it. */ if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), ""); String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow_stubs, pycode, "\n", NIL); Delete(pycode); } else { String *parms = make_pyParmList(n, false, false, allow_kwargs); String *callParms = make_pyParmList(n, false, true, allow_kwargs); Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); if (have_pythonprepend(n)) Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4), "\n", NIL); String *subfunc = NULL; /* if (builtin) subfunc = Copy(Getattr(getCurrentClass(), "sym:name")); else */ subfunc = Swig_name_construct(NSPACE_TODO, symname); Printv(f_shadow_stubs, tab4, "val = ", funcCall(subfunc, callParms), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); #endif if (have_pythonappend(n)) Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4), "\n", NIL); Printv(f_shadow_stubs, tab4, "return val\n", NIL); Delete(subfunc); } } } } return SWIG_OK; } /* ------------------------------------------------------------ * destructorHandler() * ------------------------------------------------------------ */ virtual int destructorHandler(Node *n) { String *symname = Getattr(n, "sym:name"); int oldshadow = shadow; if (builtin && in_class) { Node *cls = Swig_methodclass(n); if (!Getattr(cls, "feature:python:tp_dealloc")) { String *dealloc = Swig_name_destroy(NSPACE_TODO, symname); String *wdealloc = Swig_name_wrapper(dealloc); Setattr(cls, "feature:python:tp_dealloc", wdealloc); Delete(wdealloc); Delete(dealloc); } } if (shadow) shadow = shadow | PYSHADOW_MEMBER; //Setattr(n,"emit:dealloc","1"); Language::destructorHandler(n); shadow = oldshadow; if (shadow) { if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4); String *pyaction = NewStringf("%s.%s", module, Swig_name_destroy(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow, pycode, "\n", NIL); Delete(pycode); } else { Printv(f_shadow, tab4, "__swig_destroy__ = ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "\n", NIL); if (!have_pythonprepend(n) && !have_pythonappend(n)) { if (proxydel) { Printv(f_shadow, tab4, "__del__ = lambda self : None;\n", NIL); } return SWIG_OK; } Printv(f_shadow, tab4, "def __del__(self):\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow, tab8, "try:\n", NIL); Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL); Printv(f_shadow, tab8, "except: pass\n", NIL); #else #endif if (have_pythonappend(n)) Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); Printv(f_shadow, tab8, "pass\n", NIL); Printv(f_shadow, "\n", NIL); } } return SWIG_OK; } /* ------------------------------------------------------------ * membervariableHandler() * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { String *symname = Getattr(n, "sym:name"); int oldshadow = shadow; if (shadow) shadow = shadow | PYSHADOW_MEMBER; Language::membervariableHandler(n); shadow = oldshadow; if (shadow && !builtin) { String *mname = Swig_name_member(NSPACE_TODO, class_name, symname); String *setname = Swig_name_set(NSPACE_TODO, mname); String *getname = Swig_name_get(NSPACE_TODO, mname); int assignable = is_assignable(n); if (!modern) { if (assignable) { Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", setname, "\n", NIL); } Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL); } if (!classic) { if (!assignable) { Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ")\n", NIL); } else { Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL); } } Delete(mname); Delete(setname); Delete(getname); } return SWIG_OK; } /* ------------------------------------------------------------ * staticmembervariableHandler() * ------------------------------------------------------------ */ virtual int staticmembervariableHandler(Node *n) { Swig_save("builtin_staticmembervariableHandler", n, "builtin_symname", NIL); Language::staticmembervariableHandler(n); Swig_restore(n); if (GetFlag(n, "wrappedasconstant")) return SWIG_OK; String *symname = Getattr(n, "sym:name"); if (shadow) { if (!builtin && GetFlag(n, "hasconsttype")) { String *mname = Swig_name_member(NSPACE_TODO, class_name, symname); Printf(f_shadow_stubs, "%s.%s = %s.%s.%s\n", class_name, symname, module, global_name, mname); Delete(mname); } else { String *mname = Swig_name_member(NSPACE_TODO, class_name, symname); String *getname = Swig_name_get(NSPACE_TODO, mname); String *wrapgetname = Swig_name_wrapper(getname); String *vargetname = NewStringf("Swig_var_%s", getname); String *setname = Swig_name_set(NSPACE_TODO, mname); String *wrapsetname = Swig_name_wrapper(setname); String *varsetname = NewStringf("Swig_var_%s", setname); Wrapper *f = NewWrapper(); Printv(f->def, "SWIGINTERN PyObject *", wrapgetname, "(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(args)) {", NIL); Printv(f->code, " return ", vargetname, "();\n", NIL); Append(f->code, "}\n"); add_method(getname, wrapgetname, 0); Wrapper_print(f, f_wrappers); DelWrapper(f); int assignable = is_assignable(n); if (assignable) { int funpack = modernargs && fastunpack; Wrapper *f = NewWrapper(); Printv(f->def, "SWIGINTERN PyObject *", wrapsetname, "(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {", NIL); Wrapper_add_local(f, "res", "int res"); if (!funpack) { Wrapper_add_local(f, "value", "PyObject *value"); Append(f->code, "if (!PyArg_ParseTuple(args,(char *)\"O:set\",&value)) return NULL;\n"); } Printf(f->code, "res = %s(%s);\n", varsetname, funpack ? "args" : "value"); Append(f->code, "return !res ? SWIG_Py_Void() : NULL;\n"); Append(f->code, "}\n"); Wrapper_print(f, f_wrappers); add_method(setname, wrapsetname, 0, 0, funpack, 1, 1); DelWrapper(f); } if (!modern && !builtin) { if (assignable) { Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", setname, "\n", NIL); } Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL); } if (!classic && !builtin) { if (!assignable) { Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ")\n", NIL); } else { Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL); } } String *getter = Getattr(n, "pybuiltin:getter"); String *setter = Getattr(n, "pybuiltin:setter"); Hash *h = NULL; if (getter || setter) { h = Getattr(builtin_getset, symname); if (!h) { h = NewHash(); Setattr(h, "static", "1"); Setattr(builtin_getset, symname, h); } } if (getter) Setattr(h, "getter", getter); if (setter) Setattr(h, "setter", setter); if (h) Delete(h); Delete(mname); Delete(getname); Delete(wrapgetname); Delete(vargetname); Delete(setname); Delete(wrapsetname); Delete(varsetname); } } return SWIG_OK; } /* ------------------------------------------------------------ * memberconstantHandler() * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { String *symname = Getattr(n, "sym:name"); if (builtin && in_class) { Swig_save("builtin_memberconstantHandler", n, "pybuiltin:symname", NIL); Setattr(n, "pybuiltin:symname", symname); } int oldshadow = shadow; if (shadow) shadow = shadow | PYSHADOW_MEMBER; Language::memberconstantHandler(n); shadow = oldshadow; if (builtin && in_class) { Swig_restore(n); } else if (shadow) { Printv(f_shadow, tab4, symname, " = ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL); } return SWIG_OK; } /* ------------------------------------------------------------ * insertDirective() * * Hook for %insert directive. We're going to look for special %shadow inserts * as a special case so we can do indenting correctly * ------------------------------------------------------------ */ virtual int insertDirective(Node *n) { String *code = Getattr(n, "code"); String *section = Getattr(n, "section"); if (!ImportMode && (Cmp(section, "python") == 0 || Cmp(section, "shadow") == 0)) { if (shadow) { String *pycode = pythoncode(code, shadow_indent); Printv(f_shadow, pycode, NIL); Delete(pycode); } } else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) { String *pycode = pythoncode(code, ""); Printv(f_shadow_begin, pycode, NIL); Delete(pycode); } else { Language::insertDirective(n); } return SWIG_OK; } virtual String *runtimeCode() { String *s = NewString(""); String *shead = Swig_include_sys("pyhead.swg"); if (!shead) { Printf(stderr, "*** Unable to open 'pyhead.swg'\n"); } else { Append(s, shead); Delete(shead); } String *serrors = Swig_include_sys("pyerrors.swg"); if (!serrors) { Printf(stderr, "*** Unable to open 'pyerrors.swg'\n"); } else { Append(s, serrors); Delete(serrors); } String *sthread = Swig_include_sys("pythreads.swg"); if (!sthread) { Printf(stderr, "*** Unable to open 'pythreads.swg'\n"); } else { Append(s, sthread); Delete(sthread); } String *sapi = Swig_include_sys("pyapi.swg"); if (!sapi) { Printf(stderr, "*** Unable to open 'pyapi.swg'\n"); } else { Append(s, sapi); Delete(sapi); } String *srun = Swig_include_sys("pyrun.swg"); if (!srun) { Printf(stderr, "*** Unable to open 'pyrun.swg'\n"); } else { Append(s, srun); Delete(srun); } return s; } virtual String *defaultExternalRuntimeFilename() { return NewString("swigpyrun.h"); } }; /* --------------------------------------------------------------- * classDirectorMethod() * * Emit a virtual director method to pass a method call on to the * underlying Python object. * * ** Moved it here due to internal error on gcc-2.96 ** * --------------------------------------------------------------- */ int PYTHON::classDirectorMethods(Node *n) { director_method_index = 0; return Language::classDirectorMethods(n); } int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { int is_void = 0; int is_pointer = 0; String *decl = Getattr(n, "decl"); String *name = Getattr(n, "name"); String *classname = Getattr(parent, "sym:name"); String *c_classname = Getattr(parent, "name"); String *symname = Getattr(n, "sym:name"); String *declaration = NewString(""); ParmList *l = Getattr(n, "parms"); Wrapper *w = NewWrapper(); String *tm; String *wrap_args = NewString(""); String *returntype = Getattr(n, "type"); String *value = Getattr(n, "value"); String *storage = Getattr(n, "storage"); bool pure_virtual = false; int status = SWIG_OK; int idx; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; if (Cmp(storage, "virtual") == 0) { if (Cmp(value, "0") == 0) { pure_virtual = true; } } /* determine if the method returns a pointer */ is_pointer = SwigType_ispointer_return(decl); is_void = (!Cmp(returntype, "void") && !is_pointer); /* virtual method definition */ String *target; String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ target = Swig_method_decl(rtype, decl, name, l, 0, 1); Printf(declaration, " virtual %s", target); Delete(target); // Get any exception classes in the throws typemap ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { Parm *p; int gencomma = 0; Append(w->def, " throw("); Append(declaration, " throw("); if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); } String *str = SwigType_str(Getattr(p, "type"), 0); Append(w->def, str); Append(declaration, str); Delete(str); } } Append(w->def, ")"); Append(declaration, ")"); } Append(w->def, " {"); Append(declaration, ";\n"); /* declare method return value * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ if (!is_void) { if (!(ignored_method && !pure_virtual)) { String *cres = SwigType_lstr(returntype, "c_result"); Printf(w->code, "%s;\n", cres); Delete(cres); } } if (builtin) { Printv(w->code, "PyObject *self = NULL;\n", NIL); Printv(w->code, "(void)self;\n", NIL); } if (ignored_method) { if (!pure_virtual) { if (!is_void) Printf(w->code, "return "); String *super_call = Swig_method_call(super, l); Printf(w->code, "%s;\n", super_call); Delete(super_call); } else { Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } } else { /* attach typemaps to arguments (C/C++ -> Python) */ String *arglist = NewString(""); String *parse_args = NewString(""); Swig_director_parms_fixup(l); /* remove the wrapper 'w' since it was producing spurious temps */ Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); Parm *p; char source[256]; int outputs = 0; if (!is_void) outputs++; /* build argument list and type conversion string */ idx = 0; p = l; int use_parse = 0; while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } /* old style? caused segfaults without the p!=0 check in the for() condition, and seems dangerous in the while loop as well. while (Getattr(p, "tmap:ignore")) { p = Getattr(p, "tmap:ignore:next"); } */ if (Getattr(p, "tmap:directorargout") != 0) outputs++; String *pname = Getattr(p, "name"); String *ptype = Getattr(p, "type"); Putc(',', arglist); if ((tm = Getattr(p, "tmap:directorin")) != 0) { String *parse = Getattr(p, "tmap:directorin:parse"); if (!parse) { sprintf(source, "obj%d", idx++); String *input = NewString(source); Setattr(p, "emit:directorinput", input); Replaceall(tm, "$input", input); Delete(input); Replaceall(tm, "$owner", "0"); /* Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); */ Printv(wrap_args, "swig::SwigVar_PyObject ", source, ";\n", NIL); Printv(wrap_args, tm, "\n", NIL); Printv(arglist, "(PyObject *)", source, NIL); Putc('O', parse_args); } else { use_parse = 1; Append(parse_args, parse); Setattr(p, "emit:directorinput", pname); Replaceall(tm, "$input", pname); Replaceall(tm, "$owner", "0"); if (Len(tm) == 0) Append(tm, pname); Append(arglist, tm); } p = Getattr(p, "tmap:directorin:next"); continue; } else if (Cmp(ptype, "void")) { /* special handling for pointers to other C++ director classes. * ideally this would be left to a typemap, but there is currently no * way to selectively apply the dynamic_cast<> to classes that have * directors. in other words, the type "SwigDirector_$1_lname" only exists * for classes with directors. we avoid the problem here by checking * module.wrap::directormap, but it's not clear how to get a typemap to * do something similar. perhaps a new default typemap (in addition * to SWIGTYPE) called DIRECTORTYPE? */ if (SwigType_ispointer(ptype) || SwigType_isreference(ptype)) { Node *module = Getattr(parent, "module"); Node *target = Swig_directormap(module, ptype); sprintf(source, "obj%d", idx++); String *nonconst = 0; /* strip pointer/reference --- should move to Swig/stype.c */ String *nptype = NewString(Char(ptype) + 2); /* name as pointer */ String *ppname = Copy(pname); if (SwigType_isreference(ptype)) { Insert(ppname, 0, "&"); } /* if necessary, cast away const since Python doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", pname); String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, "Target language argument '%s' discards const in director method %s::%s.\n", SwigType_str(ptype, pname), SwigType_namestr(c_classname), SwigType_namestr(name)); } else { nonconst = Copy(ppname); } Delete(nptype); Delete(ppname); String *mangle = SwigType_manglestr(ptype); if (target) { String *director = NewStringf("director_%s", mangle); Wrapper_add_localv(w, director, "Swig::Director *", director, "= 0", NIL); Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); Printf(wrap_args, "%s = SWIG_DIRECTOR_CAST(%s);\n", director, nonconst); Printf(wrap_args, "if (!%s) {\n", director); Printf(wrap_args, "%s = SWIG_InternalNewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); Append(wrap_args, "} else {\n"); Printf(wrap_args, "%s = %s->swig_get_self();\n", source, director); Printf(wrap_args, "Py_INCREF((PyObject *)%s);\n", source); Append(wrap_args, "}\n"); Delete(director); Printv(arglist, source, NIL); } else { Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); Printf(wrap_args, "%s = SWIG_InternalNewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); //Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n", // source, nonconst, base); Printv(arglist, source, NIL); } Putc('O', parse_args); Delete(mangle); Delete(nonconst); } else { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_NOWRAP; break; } } p = nextSibling(p); } /* add the method name as a PyString */ String *pyname = Getattr(n, "sym:name"); int allow_thread = threads_enable(n); if (allow_thread) { thread_begin_block(n, w->code); Append(w->code, "{\n"); } /* wrap complex arguments to PyObjects */ Printv(w->code, wrap_args, NIL); /* pass the method call on to the Python object */ if (dirprot_mode() && !is_public(n)) { Printf(w->code, "swig_set_inner(\"%s\", true);\n", name); } Append(w->code, "if (!swig_get_self()) {\n"); Printf(w->code, " Swig::DirectorException::raise(\"'self' uninitialized, maybe you forgot to call %s.__init__.\");\n", classname); Append(w->code, "}\n"); Append(w->code, "#if defined(SWIG_PYTHON_DIRECTOR_VTABLE)\n"); Printf(w->code, "const size_t swig_method_index = %d;\n", director_method_index++); Printf(w->code, "const char * const swig_method_name = \"%s\";\n", pyname); Append(w->code, "PyObject* method = swig_get_method(swig_method_index, swig_method_name);\n"); if (Len(parse_args) > 0) { if (use_parse || !modernargs) { Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", Swig_cresult_name(), parse_args, arglist); } else { Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunctionObjArgs(method %s, NULL);\n", Swig_cresult_name(), arglist); } } else { if (modernargs) { Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n"); Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_Call(method, (PyObject*) args, NULL);\n", Swig_cresult_name()); } else { Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, NULL, NULL);\n", Swig_cresult_name()); } } Append(w->code, "#else\n"); if (Len(parse_args) > 0) { if (use_parse || !modernargs) { Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", Swig_cresult_name(), pyname, parse_args, arglist); } else { Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", Swig_cresult_name(), arglist); } } else { if (!modernargs) { Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", Swig_cresult_name(), pyname); } else { Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n", Swig_cresult_name()); } } Append(w->code, "#endif\n"); if (dirprot_mode() && !is_public(n)) Printf(w->code, "swig_set_inner(\"%s\", false);\n", name); /* exception handling */ tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { tm = Getattr(n, "feature:director:except"); if (tm) tm = Copy(tm); } Printf(w->code, "if (!%s) {\n", Swig_cresult_name()); Append(w->code, " PyObject *error = PyErr_Occurred();\n"); if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { Replaceall(tm, "$error", "error"); Printv(w->code, Str(tm), "\n", NIL); } else { Append(w->code, " if (error) {\n"); Printf(w->code, " Swig::DirectorMethodException::raise(\"Error detected when calling '%s.%s'\");\n", classname, pyname); Append(w->code, " }\n"); } Append(w->code, "}\n"); Delete(tm); /* * Python method may return a simple object, or a tuple. * for in/out aruments, we have to extract the appropriate PyObjects from the tuple, * then marshal everything back to C/C++ (return value and output arguments). * */ /* marshal return value and other outputs (if any) from PyObject to C/C++ type */ String *cleanup = NewString(""); String *outarg = NewString(""); if (outputs > 1) { Wrapper_add_local(w, "output", "PyObject *output"); Printf(w->code, "if (!PyTuple_Check(%s)) {\n", Swig_cresult_name()); Printf(w->code, " Swig::DirectorTypeMismatchException::raise(\"Python method %s.%sfailed to return a tuple.\");\n", classname, pyname); Append(w->code, "}\n"); } idx = 0; /* marshal return value */ if (!is_void) { tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); if (tm != 0) { if (outputs > 1) { Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++); Replaceall(tm, "$input", "output"); } else { Replaceall(tm, "$input", Swig_cresult_name()); } char temp[24]; sprintf(temp, "%d", idx); Replaceall(tm, "$argnum", temp); /* TODO check this */ if (Getattr(n, "wrap:disown")) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } if (Getattr(n, "tmap:directorout:implicitconv")) { Replaceall(tm, "$implicitconv", get_implicitconv_flag(n)); } Replaceall(tm, "$result", "c_result"); Printv(w->code, tm, "\n", NIL); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); status = SWIG_ERROR; } } /* marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { if (outputs > 1) { Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++); Replaceall(tm, "$result", "output"); } else { Replaceall(tm, "$result", Swig_cresult_name()); } Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } /* any existing helper functions to handle this? */ if (allow_thread) { Append(w->code, "}\n"); thread_end_block(n, w->code); } Delete(parse_args); Delete(arglist); Delete(cleanup); Delete(outarg); } if (!is_void) { if (!(ignored_method && !pure_virtual)) { String *rettype = SwigType_str(returntype, 0); if (!SwigType_isreference(returntype)) { Printf(w->code, "return (%s) c_result;\n", rettype); } else { Printf(w->code, "return (%s) *c_result;\n", rettype); } Delete(rettype); } } Append(w->code, "}\n"); // We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method String *inline_extra_method = NewString(""); if (dirprot_mode() && !is_public(n) && !pure_virtual) { Printv(inline_extra_method, declaration, NIL); String *extra_method_name = NewStringf("%sSwigPublic", name); Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, ";\n", " {\n "); if (!is_void) Printf(inline_extra_method, "return "); String *methodcall = Swig_method_call(super, l); Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Delete(methodcall); Delete(extra_method_name); } /* emit the director method */ if (status == SWIG_OK) { if (!Getattr(n, "defaultargs")) { Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); } } /* clean up */ Delete(wrap_args); Delete(pclassname); DelWrapper(w); return status; } /* ----------------------------------------------------------------------------- * swig_python() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_python() { return new PYTHON(); } extern "C" Language *swig_python(void) { return new_swig_python(); } swig-3.0.2/Source/Modules/java.cxx0000664000175000017500000052570012343605122016671 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * java.cxx * * Java language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include // for INT_MAX #include "cparse.h" #include /* Hash type used for upcalls from C/C++ */ typedef DOH UpcallData; class JAVA:public Language { static const char *usage; const String *empty_string; const String *public_string; const String *protected_string; Hash *swig_types_hash; File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; File *f_wrappers; File *f_init; File *f_directors; File *f_directors_h; List *filenames_list; bool proxy_flag; // Flag for generating proxy classes bool nopgcpp_flag; // Flag for suppressing the premature garbage collection prevention parameter bool native_function_flag; // Flag for when wrapping a native function bool enum_constant_flag; // Flag for when wrapping an enum or constant bool static_flag; // Flag for when wrapping a static functions or member variables bool variable_wrapper_flag; // Flag for when wrapping a nonstatic member variable bool wrapping_member_flag; // Flag for when wrapping a member variable/enum/const bool global_variable_flag; // Flag for when wrapping a global variable bool old_variable_names; // Flag for old style variable names in the intermediary class bool member_func_flag; // flag set when wrapping a member function String *imclass_name; // intermediary class name String *module_class_name; // module class name String *constants_interface_name; // constants interface name String *imclass_class_code; // intermediary class code String *proxy_class_def; String *proxy_class_code; String *module_class_code; String *proxy_class_name; // proxy class name String *full_proxy_class_name;// fully qualified proxy class name when using nspace feature, otherwise same as proxy_class_name String *full_imclass_name; // fully qualified intermediary class name when using nspace feature, otherwise same as imclass_name String *variable_name; //Name of a variable being wrapped String *proxy_class_constants_code; String *module_class_constants_code; String *enum_code; String *package; // Optional package name String *jnipackage; // Package name used in the JNI code String *package_path; // Package name used internally by JNI (slashes) String *imclass_imports; //intermediary class imports from %pragma String *module_imports; //module imports from %pragma String *imclass_baseclass; //inheritance for intermediary class class from %pragma String *imclass_package; //package in which to generate the intermediary class String *module_baseclass; //inheritance for module class from %pragma String *imclass_interfaces; //interfaces for intermediary class class from %pragma String *module_interfaces; //interfaces for module class from %pragma String *imclass_class_modifiers; //class modifiers for intermediary class overriden by %pragma String *module_class_modifiers; //class modifiers for module class overriden by %pragma String *upcasts_code; //C++ casts for inheritance hierarchies C++ code String *imclass_cppcasts_code; //C++ casts up inheritance hierarchies intermediary class code String *imclass_directors; // Intermediate class director code String *destructor_call; //C++ destructor call if any String *destructor_throws_clause; //C++ destructor throws clause if any // Director method stuff: List *dmethods_seq; Hash *dmethods_table; int n_dmethods; int n_directors; int first_class_dmethod; int curr_class_dmethod; int nesting_depth; enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum }; public: /* ----------------------------------------------------------------------------- * JAVA() * ----------------------------------------------------------------------------- */ JAVA():empty_string(NewString("")), public_string(NewString("public")), protected_string(NewString("protected")), swig_types_hash(NULL), f_begin(NULL), f_runtime(NULL), f_runtime_h(NULL), f_header(NULL), f_wrappers(NULL), f_init(NULL), f_directors(NULL), f_directors_h(NULL), filenames_list(NULL), proxy_flag(true), nopgcpp_flag(false), native_function_flag(false), enum_constant_flag(false), static_flag(false), variable_wrapper_flag(false), wrapping_member_flag(false), global_variable_flag(false), old_variable_names(false), member_func_flag(false), imclass_name(NULL), module_class_name(NULL), constants_interface_name(NULL), imclass_class_code(NULL), proxy_class_def(NULL), proxy_class_code(NULL), module_class_code(NULL), proxy_class_name(NULL), full_proxy_class_name(NULL), full_imclass_name(NULL), variable_name(NULL), proxy_class_constants_code(NULL), module_class_constants_code(NULL), enum_code(NULL), package(NULL), jnipackage(NULL), package_path(NULL), imclass_imports(NULL), module_imports(NULL), imclass_baseclass(NULL), imclass_package(NULL), module_baseclass(NULL), imclass_interfaces(NULL), module_interfaces(NULL), imclass_class_modifiers(NULL), module_class_modifiers(NULL), upcasts_code(NULL), imclass_cppcasts_code(NULL), imclass_directors(NULL), destructor_call(NULL), destructor_throws_clause(NULL), dmethods_seq(NULL), dmethods_table(NULL), n_dmethods(0), n_directors(0), first_class_dmethod(0), curr_class_dmethod(0), nesting_depth(0){ /* for now, multiple inheritance in directors is disabled, this should be easy to implement though */ director_multiple_inheritance = 0; director_language = 1; } /* ----------------------------------------------------------------------------- * constructIntermediateClassName() * * Construct the fully qualified name of the intermidiate class and set * the full_imclass_name attribute accordingly. * ----------------------------------------------------------------------------- */ void constructIntermediateClassName(Node *n) { String *nspace = Getattr(n, "sym:nspace"); if (imclass_package && package) full_imclass_name = NewStringf("%s.%s.%s", package, imclass_package, imclass_name); else if (package && nspace) full_imclass_name = NewStringf("%s.%s", package, imclass_name); else if (imclass_package) full_imclass_name = NewStringf("%s.%s", imclass_package, imclass_name); else full_imclass_name = NewStringf("%s", imclass_name); if (nspace && !package) { String *name = Getattr(n, "name") ? Getattr(n, "name") : NewString(""); Swig_warning(WARN_JAVA_NSPACE_WITHOUT_PACKAGE, Getfile(n), Getline(n), "The nspace feature is used on '%s' without -package. " "The generated code may not compile as Java does not support types declared in a named package accessing types declared in an unnamed package.\n", name); } } /* ----------------------------------------------------------------------------- * getProxyName() * * Test to see if a type corresponds to something wrapped with a proxy class. * Return NULL if not otherwise the proxy class name, fully qualified with * package name if the nspace feature is used, unless jnidescriptor is true as * the package name is handled differently (unfortunately for legacy reasons). * ----------------------------------------------------------------------------- */ String *getProxyName(SwigType *t, bool jnidescriptor = false) { String *proxyname = NULL; if (proxy_flag) { Node *n = classLookup(t); if (n) { proxyname = Getattr(n, "proxyname"); if (!proxyname || jnidescriptor) { String *nspace = Getattr(n, "sym:nspace"); String *symname = Copy(Getattr(n, "sym:name")); if (symname && !GetFlag(n, "feature:flatnested")) { for (Node *outer_class = Getattr(n, "nested:outer"); outer_class; outer_class = Getattr(outer_class, "nested:outer")) { Push(symname, "."); Push(symname, Getattr(outer_class, "sym:name")); } } if (nspace) { if (package && !jnidescriptor) proxyname = NewStringf("%s.%s.%s", package, nspace, symname); else proxyname = NewStringf("%s.%s", nspace, symname); } else { proxyname = Copy(symname); } if (!jnidescriptor) { Setattr(n, "proxyname", proxyname); // Cache it Delete(proxyname); } Delete(symname); } } } return proxyname; } /* ----------------------------------------------------------------------------- * makeValidJniName() * ----------------------------------------------------------------------------- */ String *makeValidJniName(const String *name) { String *valid_jni_name = NewString(name); Replaceall(valid_jni_name, "_", "_1"); return valid_jni_name; } /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { SWIG_library_directory("java"); // Look for certain command line options for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-package") == 0) { if (argv[i + 1]) { package = NewString(""); Printf(package, argv[i + 1]); if (Len(package) == 0) { Delete(package); package = 0; } Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if ((strcmp(argv[i], "-shadow") == 0) || ((strcmp(argv[i], "-proxy") == 0))) { Printf(stderr, "Deprecated command line option: %s. Proxy classes are now generated by default.\n", argv[i]); Swig_mark_arg(i); proxy_flag = true; } else if ((strcmp(argv[i], "-noproxy") == 0)) { Swig_mark_arg(i); proxy_flag = false; } else if (strcmp(argv[i], "-nopgcpp") == 0) { Swig_mark_arg(i); nopgcpp_flag = true; } else if (strcmp(argv[i], "-oldvarnames") == 0) { Swig_mark_arg(i); old_variable_names = true; } else if (strcmp(argv[i], "-jnic") == 0) { Swig_mark_arg(i); Printf(stderr, "Deprecated command line option: -jnic. C JNI calling convention now used when -c++ not specified.\n"); } else if (strcmp(argv[i], "-nofinalize") == 0) { Swig_mark_arg(i); Printf(stderr, "Deprecated command line option: -nofinalize. Use the new javafinalize typemap instead.\n"); } else if (strcmp(argv[i], "-jnicpp") == 0) { Swig_mark_arg(i); Printf(stderr, "Deprecated command line option: -jnicpp. C++ JNI calling convention now used when -c++ specified.\n"); } else if (strcmp(argv[i], "-help") == 0) { Printf(stdout, "%s\n", usage); } } } // Add a symbol to the parser for conditional compilation Preprocessor_define("SWIGJAVA 1", 0); // Add typemap definitions SWIG_typemap_lang("java"); SWIG_config_file("java.swg"); allow_overloading(); } /* --------------------------------------------------------------------- * top() * --------------------------------------------------------------------- */ virtual int top(Node *n) { // Get any options set in the module directive Node *optionsnode = Getattr(Getattr(n, "module"), "options"); if (optionsnode) { if (Getattr(optionsnode, "jniclassname")) imclass_name = Copy(Getattr(optionsnode, "jniclassname")); /* check if directors are enabled for this module. note: this * is a "master" switch, without which no director code will be * emitted. %feature("director") statements are also required * to enable directors for individual classes or methods. * * use %module(directors="1") modulename at the start of the * interface file to enable director generation. */ if (Getattr(optionsnode, "directors")) { allow_directors(); } if (Getattr(optionsnode, "dirprot")) { allow_dirprot(); } allow_allprotected(GetFlag(optionsnode, "allprotected")); } /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); String *outfile_h = Getattr(n, "outfile_h"); if (!outfile) { Printf(stderr, "Unable to determine outfile\n"); SWIG_exit(EXIT_FAILURE); } f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } if (directorsEnabled()) { if (!outfile_h) { Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); } } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); f_directors_h = NewString(""); f_directors = NewString(""); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); swig_types_hash = NewHash(); filenames_list = NewList(); // Make the intermediary class and module class names. The intermediary class name can be set in the module directive. if (!imclass_name) { imclass_name = NewStringf("%sJNI", Getattr(n, "name")); module_class_name = Copy(Getattr(n, "name")); } else { // Rename the module name if it is the same as intermediary class name - a backwards compatibility solution if (Cmp(imclass_name, Getattr(n, "name")) == 0) module_class_name = NewStringf("%sModule", Getattr(n, "name")); else module_class_name = Copy(Getattr(n, "name")); } constants_interface_name = NewStringf("%sConstants", module_class_name); // module class and intermediary classes are always created if (!addSymbol(imclass_name, n)) return SWIG_ERROR; if (!addSymbol(module_class_name, n)) return SWIG_ERROR; imclass_class_code = NewString(""); proxy_class_def = NewString(""); proxy_class_code = NewString(""); module_class_constants_code = NewString(""); imclass_baseclass = NewString(""); imclass_package = NULL; imclass_interfaces = NewString(""); imclass_class_modifiers = NewString(""); module_class_code = NewString(""); module_baseclass = NewString(""); module_interfaces = NewString(""); module_imports = NewString(""); module_class_modifiers = NewString(""); imclass_imports = NewString(""); imclass_cppcasts_code = NewString(""); imclass_directors = NewString(""); upcasts_code = NewString(""); dmethods_seq = NewList(); dmethods_table = NewHash(); n_dmethods = 0; n_directors = 0; jnipackage = NewString(""); package_path = NewString(""); Swig_banner(f_begin); Printf(f_runtime, "\n#define SWIGJAVA\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); /* Emit initial director header and director code: */ Swig_banner(f_directors_h); Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name); Printf(f_directors, "\n\n"); Printf(f_directors, "/* ---------------------------------------------------\n"); Printf(f_directors, " * C++ director class methods\n"); Printf(f_directors, " * --------------------------------------------------- */\n\n"); if (outfile_h) { String *filename = Swig_file_filename(outfile_h); Printf(f_directors, "#include \"%s\"\n\n", filename); Delete(filename); } } Printf(f_runtime, "\n"); String *wrapper_name = NewString(""); if (package) { String *jniname = makeValidJniName(package); Printv(jnipackage, jniname, NIL); Delete(jniname); Replaceall(jnipackage, ".", "_"); Append(jnipackage, "_"); Printv(package_path, package, NIL); Replaceall(package_path, ".", "/"); } String *jniname = makeValidJniName(imclass_name); Printf(wrapper_name, "Java_%s%s_%%f", jnipackage, jniname); Delete(jniname); Swig_name_register("wrapper", Char(wrapper_name)); if (old_variable_names) { Swig_name_register("set", "set_%n%v"); Swig_name_register("get", "get_%n%v"); } Delete(wrapper_name); Printf(f_wrappers, "\n#ifdef __cplusplus\n"); Printf(f_wrappers, "extern \"C\" {\n"); Printf(f_wrappers, "#endif\n\n"); /* Emit code */ Language::top(n); if (directorsEnabled()) { // Insert director runtime into the f_runtime file (make it occur before %header section) Swig_insert_file("director.swg", f_runtime); } // Generate the intermediary class { String *filen = NewStringf("%s%s.java", outputDirectory(imclass_package), imclass_name); File *f_im = NewFile(filen, "w", SWIG_output_files()); if (!f_im) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the intermediary class file emitBanner(f_im); if (imclass_package && package) Printf(f_im, "package %s.%s;", package, imclass_package); else if (imclass_package) Printf(f_im, "package %s;", imclass_package); else if (package) Printf(f_im, "package %s;\n", package); if (imclass_imports) Printf(f_im, "%s\n", imclass_imports); if (Len(imclass_class_modifiers) > 0) Printf(f_im, "%s ", imclass_class_modifiers); Printf(f_im, "%s ", imclass_name); if (imclass_baseclass && *Char(imclass_baseclass)) Printf(f_im, "extends %s ", imclass_baseclass); if (Len(imclass_interfaces) > 0) Printv(f_im, "implements ", imclass_interfaces, " ", NIL); Printf(f_im, "{\n"); // Add the intermediary class methods Replaceall(imclass_class_code, "$module", module_class_name); Replaceall(imclass_class_code, "$imclassname", imclass_name); Printv(f_im, imclass_class_code, NIL); Printv(f_im, imclass_cppcasts_code, NIL); if (Len(imclass_directors) > 0) Printv(f_im, "\n", imclass_directors, NIL); if (n_dmethods > 0) { Putc('\n', f_im); Printf(f_im, " private final static native void swig_module_init();\n"); Printf(f_im, " static {\n"); Printf(f_im, " swig_module_init();\n"); Printf(f_im, " }\n"); } // Finish off the class Printf(f_im, "}\n"); Delete(f_im); } // Generate the Java module class { String *filen = NewStringf("%s%s.java", SWIG_output_directory(), module_class_name); File *f_module = NewFile(filen, "w", SWIG_output_files()); if (!f_module) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the module class file emitBanner(f_module); if (package) Printf(f_module, "package %s;\n", package); if (module_imports) Printf(f_module, "%s\n", module_imports); if (Len(module_class_modifiers) > 0) Printf(f_module, "%s ", module_class_modifiers); Printf(f_module, "%s ", module_class_name); if (module_baseclass && *Char(module_baseclass)) Printf(f_module, "extends %s ", module_baseclass); if (Len(module_interfaces) > 0) { if (Len(module_class_constants_code) != 0) Printv(f_module, "implements ", constants_interface_name, ", ", module_interfaces, " ", NIL); else Printv(f_module, "implements ", module_interfaces, " ", NIL); } else { if (Len(module_class_constants_code) != 0) Printv(f_module, "implements ", constants_interface_name, " ", NIL); } Printf(f_module, "{\n"); Replaceall(module_class_code, "$module", module_class_name); Replaceall(module_class_constants_code, "$module", module_class_name); Replaceall(module_class_code, "$imclassname", imclass_name); Replaceall(module_class_constants_code, "$imclassname", imclass_name); // Add the wrapper methods Printv(f_module, module_class_code, NIL); // Finish off the class Printf(f_module, "}\n"); Delete(f_module); } // Generate the Java constants interface if (Len(module_class_constants_code) != 0) { String *filen = NewStringf("%s%s.java", SWIG_output_directory(), constants_interface_name); File *f_module = NewFile(filen, "w", SWIG_output_files()); if (!f_module) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the Java constants interface file emitBanner(f_module); if (package) Printf(f_module, "package %s;\n", package); if (module_imports) Printf(f_module, "%s\n", module_imports); Printf(f_module, "public interface %s {\n", constants_interface_name); // Write out all the global constants Printv(f_module, module_class_constants_code, NIL); // Finish off the Java interface Printf(f_module, "}\n"); Delete(f_module); } if (upcasts_code) Printv(f_wrappers, upcasts_code, NIL); emitDirectorUpcalls(); Printf(f_wrappers, "#ifdef __cplusplus\n"); Printf(f_wrappers, "}\n"); Printf(f_wrappers, "#endif\n"); // Output a Java type wrapper class for each SWIG type for (Iterator swig_type = First(swig_types_hash); swig_type.key; swig_type = Next(swig_type)) { emitTypeWrapperClass(swig_type.key, swig_type.item); } // Check for overwriting file problems on filesystems that are case insensitive Iterator it1; Iterator it2; for (it1 = First(filenames_list); it1.item; it1 = Next(it1)) { String *item1_lower = Swig_string_lower(it1.item); for (it2 = Next(it1); it2.item; it2 = Next(it2)) { String *item2_lower = Swig_string_lower(it2.item); if (it1.item && it2.item) { if (Strcmp(item1_lower, item2_lower) == 0) { Swig_warning(WARN_LANG_PORTABILITY_FILENAME, input_file, line_number, "Portability warning: File %s will be overwritten by %s on case insensitive filesystems such as " "Windows' FAT32 and NTFS unless the class/module name is renamed\n", it1.item, it2.item); } } Delete(item2_lower); } Delete(item1_lower); } Delete(swig_types_hash); swig_types_hash = NULL; Delete(filenames_list); filenames_list = NULL; Delete(imclass_name); imclass_name = NULL; Delete(imclass_class_code); imclass_class_code = NULL; Delete(proxy_class_def); proxy_class_def = NULL; Delete(proxy_class_code); proxy_class_code = NULL; Delete(module_class_constants_code); module_class_constants_code = NULL; Delete(imclass_baseclass); imclass_baseclass = NULL; Delete(imclass_package); imclass_package = NULL; Delete(imclass_interfaces); imclass_interfaces = NULL; Delete(imclass_class_modifiers); imclass_class_modifiers = NULL; Delete(module_class_name); module_class_name = NULL; Delete(constants_interface_name); constants_interface_name = NULL; Delete(module_class_code); module_class_code = NULL; Delete(module_baseclass); module_baseclass = NULL; Delete(module_interfaces); module_interfaces = NULL; Delete(module_imports); module_imports = NULL; Delete(module_class_modifiers); module_class_modifiers = NULL; Delete(imclass_imports); imclass_imports = NULL; Delete(imclass_cppcasts_code); imclass_cppcasts_code = NULL; Delete(imclass_directors); imclass_directors = NULL; Delete(upcasts_code); upcasts_code = NULL; Delete(package); package = NULL; Delete(jnipackage); jnipackage = NULL; Delete(package_path); package_path = NULL; Delete(dmethods_seq); dmethods_seq = NULL; Delete(dmethods_table); dmethods_table = NULL; n_dmethods = 0; /* Close all of the files */ Dump(f_header, f_runtime); if (directorsEnabled()) { Dump(f_directors, f_runtime); Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); Delete(f_runtime_h); f_runtime_h = NULL; Delete(f_directors); f_directors = NULL; Delete(f_directors_h); f_directors_h = NULL; } Dump(f_wrappers, f_runtime); Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); Dump(f_runtime, f_begin); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /* ----------------------------------------------------------------------------- * emitBanner() * ----------------------------------------------------------------------------- */ void emitBanner(File *f) { Printf(f, "/* ----------------------------------------------------------------------------\n"); Swig_banner_target_lang(f, " *"); Printf(f, " * ----------------------------------------------------------------------------- */\n\n"); } /*----------------------------------------------------------------------- * Add new director upcall signature *----------------------------------------------------------------------*/ UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *imclass_desc, String *class_desc, String *decl) { String *key = NewStringf("%s|%s", imclass_method, decl); ++curr_class_dmethod; String *imclass_methodidx = NewStringf("%d", n_dmethods); String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); n_dmethods++; Hash *new_udata = NewHash(); Append(dmethods_seq, new_udata); Setattr(dmethods_table, key, new_udata); Setattr(new_udata, "method", Copy(class_method)); Setattr(new_udata, "fdesc", Copy(class_desc)); Setattr(new_udata, "imclass_method", Copy(imclass_method)); Setattr(new_udata, "imclass_fdesc", Copy(imclass_desc)); Setattr(new_udata, "imclass_methodidx", imclass_methodidx); Setattr(new_udata, "class_methodidx", class_methodidx); Setattr(new_udata, "decl", Copy(decl)); Delete(key); return new_udata; } /*----------------------------------------------------------------------- * Get director upcall signature *----------------------------------------------------------------------*/ UpcallData *getUpcallMethodData(String *director_class, String *decl) { String *key = NewStringf("%s|%s", director_class, decl); UpcallData *udata = Getattr(dmethods_table, key); Delete(key); return udata; } /* ---------------------------------------------------------------------- * nativeWrapper() * ---------------------------------------------------------------------- */ virtual int nativeWrapper(Node *n) { String *wrapname = Getattr(n, "wrap:name"); if (!addSymbol(wrapname, n, imclass_name)) return SWIG_ERROR; if (Getattr(n, "type")) { Swig_save("nativeWrapper", n, "name", NIL); Setattr(n, "name", wrapname); native_function_flag = true; functionWrapper(n); Swig_restore(n); native_function_flag = false; } else { Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name")); } return SWIG_OK; } /* ---------------------------------------------------------------------- * functionWrapper() * ---------------------------------------------------------------------- */ virtual int functionWrapper(Node *n) { String *symname = Getattr(n, "sym:name"); SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *tm; Parm *p; int i; String *c_return_type = NewString(""); String *im_return_type = NewString(""); String *cleanup = NewString(""); String *outarg = NewString(""); String *body = NewString(""); int num_arguments = 0; int gencomma = 0; bool is_void_return; String *overloaded_name = getOverloadedName(n); String *nondir_args = NewString(""); bool is_destructor = (Cmp(Getattr(n, "nodeType"), "destructor") == 0); if (!Getattr(n, "sym:overloaded")) { if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name)) return SWIG_ERROR; } /* The rest of this function deals with generating the intermediary class wrapper function (that wraps a c/c++ function) and generating the JNI c code. Each Java wrapper function has a matching JNI c function call. */ // A new wrapper function object Wrapper *f = NewWrapper(); // Make a wrapper name for this function String *jniname = makeValidJniName(overloaded_name); String *wname = Swig_name_wrapper(jniname); Delete(jniname); /* Attach the non-standard typemaps to the parameter list. */ Swig_typemap_attach_parms("jni", l, f); Swig_typemap_attach_parms("jtype", l, f); Swig_typemap_attach_parms("jstype", l, f); /* Get return types */ if ((tm = Swig_typemap_lookup("jni", n, "", 0))) { Printf(c_return_type, "%s", tm); } else { Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s\n", SwigType_str(t, 0)); } if ((tm = Swig_typemap_lookup("jtype", n, "", 0))) { Printf(im_return_type, "%s", tm); } else { Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(t, 0)); } is_void_return = (Cmp(c_return_type, "void") == 0); if (!is_void_return) Wrapper_add_localv(f, "jresult", c_return_type, "jresult = 0", NIL); Printv(f->def, "SWIGEXPORT ", c_return_type, " JNICALL ", wname, "(JNIEnv *jenv, jclass jcls", NIL); // Usually these function parameters are unused - The code below ensures // that compilers do not issue such a warning if configured to do so. Printv(f->code, " (void)jenv;\n", NIL); Printv(f->code, " (void)jcls;\n", NIL); // Emit all of the local variables for holding arguments. emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); // Parameter overloading Setattr(n, "wrap:parms", l); Setattr(n, "wrap:name", wname); // Wrappers not wanted for some methods where the parameters cannot be overloaded in Java if (Getattr(n, "sym:overloaded")) { // Emit warnings for the few cases that can't be overloaded in Java and give up on generating wrapper Swig_overload_check(n); if (Getattr(n, "overload:ignore")) { DelWrapper(f); return SWIG_OK; } } Printf(imclass_class_code, " public final static native %s %s(", im_return_type, overloaded_name); num_arguments = emit_num_arguments(l); // Now walk the function parameter list and generate code to get arguments for (i = 0, p = l; i < num_arguments; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); String *im_param_type = NewString(""); String *c_param_type = NewString(""); String *arg = NewString(""); Printf(arg, "j%s", ln); /* Get the JNI C types of the parameter */ if ((tm = Getattr(p, "tmap:jni"))) { Printv(c_param_type, tm, NIL); } else { Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s\n", SwigType_str(pt, 0)); } /* Get the intermediary class parameter types of the parameter */ if ((tm = Getattr(p, "tmap:jtype"))) { Printv(im_param_type, tm, NIL); } else { Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to intermediary class method */ if (gencomma) Printf(imclass_class_code, ", "); Printf(imclass_class_code, "%s %s", im_param_type, arg); // Add parameter to C function Printv(f->def, ", ", c_param_type, " ", arg, NIL); ++gencomma; // Premature garbage collection prevention parameter if (!is_destructor) { String *pgc_parameter = prematureGarbageCollectionPreventionParameter(pt, p); if (pgc_parameter) { Printf(imclass_class_code, ", %s %s_", pgc_parameter, arg); Printf(f->def, ", jobject %s_", arg); Printf(f->code, " (void)%s_;\n", arg); } } // Get typemap for this argument if ((tm = Getattr(p, "tmap:in"))) { addThrows(n, "tmap:in", p); Replaceall(tm, "$source", arg); /* deprecated */ Replaceall(tm, "$target", ln); /* deprecated */ Replaceall(tm, "$arg", arg); /* deprecated? */ Replaceall(tm, "$input", arg); Setattr(p, "emit:input", arg); Printf(nondir_args, "%s\n", tm); p = Getattr(p, "tmap:in:next"); } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); p = nextSibling(p); } Delete(im_param_type); Delete(c_param_type); Delete(arg); } Printv(f->code, nondir_args, NIL); Delete(nondir_args); /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { addThrows(n, "tmap:check", p); Replaceall(tm, "$target", Getattr(p, "lname")); /* deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); /* deprecated? */ Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { addThrows(n, "tmap:freearg", p); Replaceall(tm, "$source", Getattr(p, "emit:input")); /* deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); /* deprecated? */ Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { addThrows(n, "tmap:argout", p); Replaceall(tm, "$source", Getattr(p, "emit:input")); /* deprecated */ Replaceall(tm, "$target", Getattr(p, "lname")); /* deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); /* deprecated? */ Replaceall(tm, "$result", "jresult"); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } // Get any Java exception classes in the throws typemap ParmList *throw_parm_list = NULL; if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { addThrows(n, "tmap:throws", p); } } } if (!native_function_flag) { if (Cmp(nodeType(n), "constant") == 0) { // Wrapping a constant hack Swig_save("functionWrapper", n, "wrap:action", NIL); // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value"))); } // Now write code to make the function call Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); // Handle exception classes specified in the "except" feature's "throws" attribute addThrows(n, "feature:except", n); if (Cmp(nodeType(n), "constant") == 0) Swig_restore(n); /* Return value if necessary */ if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { addThrows(n, "tmap:out", n); Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Replaceall(tm, "$target", "jresult"); /* deprecated */ Replaceall(tm, "$result", "jresult"); if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "1"); else Replaceall(tm, "$owner", "0"); Printf(f->code, "%s", tm); if (Len(tm)) Printf(f->code, "\n"); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), Getattr(n, "name")); } emit_return_variable(n, t, f); } /* Output argument output code */ Printv(f->code, outarg, NIL); /* Output cleanup code */ Printv(f->code, cleanup, NIL); /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { addThrows(n, "tmap:newfree", n); Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if (!native_function_flag) { if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { addThrows(n, "tmap:ret", n); Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } /* Finish C function and intermediary class function definitions */ Printf(imclass_class_code, ")"); generateThrowsClause(n, imclass_class_code); Printf(imclass_class_code, ";\n"); Printf(f->def, ") {"); if (!is_void_return) Printv(f->code, " return jresult;\n", NIL); Printf(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); /* Substitute the function name */ Replaceall(f->code, "$symname", symname); /* Contract macro modification */ Replaceall(f->code, "SWIG_contract_assert(", "SWIG_contract_assert($null, "); if (!is_void_return) Replaceall(f->code, "$null", "0"); else Replaceall(f->code, "$null", ""); /* Dump the function out */ if (!native_function_flag) Wrapper_print(f, f_wrappers); if (!(proxy_flag && is_wrapping_class()) && !enum_constant_flag) { moduleClassFunctionHandler(n); } /* * Generate the proxy class getters/setters for public member variables. * Not for enums and constants. */ if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { // Capitalize the first letter in the variable to create a JavaBean type getter/setter function name bool getter_flag = Cmp(symname, Swig_name_set(getNSpace(), Swig_name_member(0, getClassPrefix(), variable_name))) != 0; String *getter_setter_name = NewString(""); if (!getter_flag) Printf(getter_setter_name, "set"); else Printf(getter_setter_name, "get"); Putc(toupper((int) *Char(variable_name)), getter_setter_name); Printf(getter_setter_name, "%s", Char(variable_name) + 1); Setattr(n, "proxyfuncname", getter_setter_name); Setattr(n, "imfuncname", symname); proxyClassFunctionHandler(n); Delete(getter_setter_name); } Delete(c_return_type); Delete(im_return_type); Delete(cleanup); Delete(outarg); Delete(body); Delete(overloaded_name); DelWrapper(f); return SWIG_OK; } /* ----------------------------------------------------------------------- * variableWrapper() * ----------------------------------------------------------------------- */ virtual int variableWrapper(Node *n) { variable_wrapper_flag = true; Language::variableWrapper(n); /* Default to functions */ variable_wrapper_flag = false; return SWIG_OK; } /* ----------------------------------------------------------------------- * globalvariableHandler() * ------------------------------------------------------------------------ */ virtual int globalvariableHandler(Node *n) { variable_name = Getattr(n, "sym:name"); global_variable_flag = true; int ret = Language::globalvariableHandler(n); global_variable_flag = false; return ret; } String *getCurrentScopeName(String *nspace) { String *scope = 0; if (nspace || getCurrentClass()) { scope = NewString(""); if (nspace) Printf(scope, "%s", nspace); if (Node* cls = getCurrentClass()) { if (Node *outer = Getattr(cls, "nested:outer")) { String *outerClassesPrefix = Copy(Getattr(outer, "sym:name")); for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) { Push(outerClassesPrefix, "."); Push(outerClassesPrefix, Getattr(outer, "sym:name")); } Printv(scope, nspace ? "." : "", outerClassesPrefix, ".", proxy_class_name, NIL); Delete(outerClassesPrefix); } else Printv(scope, nspace ? "." : "", proxy_class_name, NIL); } } return scope; } /* ---------------------------------------------------------------------- * enumDeclaration() * * C/C++ enums can be mapped in one of 4 ways, depending on the java:enum feature specified: * 1) Simple enums - simple constant within the proxy class or module class * 2) Typeunsafe enums - simple constant in a Java class (class named after the c++ enum name) * 3) Typesafe enum - typesafe enum pattern (class named after the c++ enum name) * 4) Proper enums - proper Java enum * Anonymous enums always default to 1) * ---------------------------------------------------------------------- */ virtual int enumDeclaration(Node *n) { if (!ImportMode) { if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call if (proxy_flag && !is_wrapping_class()) { // Global enums / enums in a namespace assert(!full_imclass_name); constructIntermediateClassName(n); } enum_code = NewString(""); String *symname = Getattr(n, "sym:name"); String *constants_code = (proxy_flag && is_wrapping_class())? proxy_class_constants_code : module_class_constants_code; EnumFeature enum_feature = decodeEnumFeature(n); String *typemap_lookup_type = Getattr(n, "name"); if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum String *scope = getCurrentScopeName(nspace); if (!addSymbol(symname, n, scope)) return SWIG_ERROR; // Pure Java baseclass and interfaces const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE); const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); // Emit the enum Printv(enum_code, typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really) " ", symname, *Char(pure_baseclass) ? // Bases " extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces " implements " : "", pure_interfaces, " {\n", NIL); if (proxy_flag && is_wrapping_class()) Replaceall(enum_code, "$static ", "static "); else Replaceall(enum_code, "$static ", ""); Delete(scope); } else { // Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort if (symname && !Getattr(n, "unnamedinstance")) Printf(constants_code, " // %s \n", symname); } // Emit each enum item Language::enumDeclaration(n); if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum // Finish the enum declaration // Typemaps are used to generate the enum definition in a similar manner to proxy classes. Printv(enum_code, (enum_feature == ProperEnum) ? ";\n" : "", typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code "}", NIL); Replaceall(enum_code, "$javaclassname", symname); // Substitute $enumvalues - intended usage is for typesafe enums if (Getattr(n, "enumvalues")) Replaceall(enum_code, "$enumvalues", Getattr(n, "enumvalues")); else Replaceall(enum_code, "$enumvalues", ""); if (proxy_flag && is_wrapping_class()) { // Enums defined within the C++ class are defined within the proxy class // Add extra indentation Replaceall(enum_code, "\n", "\n "); Replaceall(enum_code, " \n", "\n"); Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { // Global enums are defined in their own file String *output_directory = outputDirectory(nspace); String *filen = NewStringf("%s%s.java", output_directory, symname); File *f_enum = NewFile(filen, "w", SWIG_output_files()); if (!f_enum) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the enum file emitBanner(f_enum); if (package || nspace) { Printf(f_enum, "package "); if (package) Printv(f_enum, package, nspace ? "." : "", NIL); if (nspace) Printv(f_enum, nspace, NIL); Printf(f_enum, ";\n"); } Printv(f_enum, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", enum_code, "\n", NIL); Printf(f_enum, "\n"); Delete(f_enum); Delete(output_directory); } } else { // Wrap C++ enum with simple constant Printf(enum_code, "\n"); if (proxy_flag && is_wrapping_class()) Printv(proxy_class_constants_code, enum_code, NIL); else Printv(module_class_constants_code, enum_code, NIL); } Delete(enum_code); enum_code = NULL; if (proxy_flag && !is_wrapping_class()) { Delete(full_imclass_name); full_imclass_name = 0; } } return SWIG_OK; } /* ---------------------------------------------------------------------- * enumvalueDeclaration() * ---------------------------------------------------------------------- */ virtual int enumvalueDeclaration(Node *n) { if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL); String *symname = Getattr(n, "sym:name"); String *value = Getattr(n, "value"); String *name = Getattr(n, "name"); Node *parent = parentNode(n); int unnamedinstance = GetFlag(parent, "unnamedinstance"); String *parent_name = Getattr(parent, "name"); String *nspace = getNSpace(); String *tmpValue; // Strange hack from parent method if (value) tmpValue = NewString(value); else tmpValue = NewString(name); // Note that this is used in enumValue() amongst other places Setattr(n, "value", tmpValue); // Deal with enum values that are not int int swigtype = SwigType_type(Getattr(n, "type")); if (swigtype == T_BOOL) { const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0"; Setattr(n, "enumvalue", val); } else if (swigtype == T_CHAR) { String *val = NewStringf("'%s'", Getattr(n, "enumvalue")); Setattr(n, "enumvalue", val); Delete(val); } { EnumFeature enum_feature = decodeEnumFeature(parent); // Add to language symbol table String *scope = 0; if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) { if (proxy_class_name) { scope = NewString(""); if (nspace) Printf(scope, "%s.", nspace); Printf(scope, "%s", proxy_class_name); } else { scope = Copy(constants_interface_name); } } else { scope = getCurrentScopeName(nspace); if (!scope) scope = Copy(Getattr(parent, "sym:name")); else Printf(scope, ".%s", Getattr(parent, "sym:name")); } if (!addSymbol(name, n, scope)) return SWIG_ERROR; if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) C/C++ enum with a proper Java enum // Emit the enum item. if (!GetFlag(n, "firstenumitem")) Printf(enum_code, ",\n"); Printf(enum_code, " %s", symname); if (Getattr(n, "enumvalue")) { String *value = enumValue(n); Printf(enum_code, "(%s)", value); Delete(value); } } else { // Wrap C/C++ enums with constant integers or use the typesafe enum pattern SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum "); Setattr(n, "type", typemap_lookup_type); const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF); String *return_type = Copy(tm); substituteClassname(typemap_lookup_type, return_type); const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) enum using the typesafe enum pattern if (Getattr(n, "enumvalue")) { String *value = enumValue(n); Printf(enum_code, " %s final static %s %s = new %s(\"%s\", %s);\n", methodmods, return_type, symname, return_type, symname, value); Delete(value); } else { Printf(enum_code, " %s final static %s %s = new %s(\"%s\");\n", methodmods, return_type, symname, return_type, symname); } } else { // Simple integer constants // Note these are always generated for anonymous enums, no matter what enum_feature is specified // Code generated is the same for SimpleEnum and TypeunsafeEnum -> the class it is generated into is determined later String *value = enumValue(n); Printf(enum_code, " %s final static %s %s = %s;\n", methodmods, return_type, symname, value); Delete(value); } Delete(return_type); } // Add the enum value to the comma separated list being constructed in the enum declaration. String *enumvalues = Getattr(parent, "enumvalues"); if (!enumvalues) Setattr(parent, "enumvalues", Copy(symname)); else Printv(enumvalues, ", ", symname, NIL); Delete(scope); } Delete(tmpValue); Swig_restore(n); return SWIG_OK; } /* ----------------------------------------------------------------------- * constantWrapper() * Used for wrapping constants - #define or %constant. * Also for inline initialised const static primitive type member variables (short, int, double, enums etc). * Java static final variables are generated for these. * If the %javaconst(1) feature is used then the C constant value is used to initialise the Java final variable. * If not, a JNI method is generated to get the C constant value for initialisation of the Java final variable. * However, if the %javaconstvalue feature is used, it overrides all other ways to generate the initialisation. * Also note that this method might be called for wrapping enum items (when the enum is using %javaconst(0)). * ------------------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { String *symname = Getattr(n, "sym:name"); SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *tm; String *return_type = NewString(""); String *constants_code = NewString(""); Swig_save("constantWrapper", n, "value", NIL); bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname; if (!is_enum_item) { String *scope = 0; if (proxy_class_name) { String *nspace = getNSpace(); scope = NewString(""); if (nspace) Printf(scope, "%s.", nspace); Printf(scope, "%s", proxy_class_name); } else { scope = Copy(constants_interface_name); } if (!addSymbol(itemname, n, scope)) return SWIG_ERROR; Delete(scope); } // The %javaconst feature determines how the constant value is obtained int const_feature_flag = GetFlag(n, "feature:java:const"); /* Adjust the enum type for the Swig_typemap_lookup. * We want the same jstype typemap for all the enum items so we use the enum type (parent node). */ if (is_enum_item) { t = Getattr(parentNode(n), "enumtype"); Setattr(n, "type", t); } /* Attach the non-standard typemaps to the parameter list. */ Swig_typemap_attach_parms("jstype", l, NULL); /* Get Java return types */ bool classname_substituted_flag = false; if ((tm = Swig_typemap_lookup("jstype", n, "", 0))) { classname_substituted_flag = substituteClassname(t, tm); Printf(return_type, "%s", tm); } else { Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined for %s\n", SwigType_str(t, 0)); } // Add the stripped quotes back in String *new_value = NewString(""); if (SwigType_type(t) == T_STRING) { Printf(new_value, "\"%s\"", Copy(Getattr(n, "value"))); Setattr(n, "value", new_value); } else if (SwigType_type(t) == T_CHAR) { Printf(new_value, "\'%s\'", Copy(Getattr(n, "value"))); Setattr(n, "value", new_value); } const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); Printf(constants_code, " %s final static %s %s = ", methodmods, return_type, itemname); // Check for the %javaconstvalue feature String *value = Getattr(n, "feature:java:constvalue"); if (value) { Printf(constants_code, "%s;\n", value); } else if (!const_feature_flag) { // Default enum and constant handling will work with any type of C constant and initialises the Java variable from C through a JNI call. if (classname_substituted_flag) { if (SwigType_isenum(t)) { // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on) Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } } else { Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } // Each constant and enum value is wrapped with a separate JNI function call SetFlag(n, "feature:immutable"); enum_constant_flag = true; variableWrapper(n); enum_constant_flag = false; } else { // Alternative constant handling will use the C syntax to make a true Java constant and hope that it compiles as Java code if (Getattr(n, "wrappedasconstant")) { if (SwigType_type(t) == T_CHAR) Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value")); else Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value")); } else { Printf(constants_code, "%s;\n", Getattr(n, "value")); } } // Emit the generated code to appropriate place // Enums only emit the intermediate and JNI methods, so no proxy or module class wrapper methods needed if (!is_enum_item) { if (proxy_flag && wrapping_member_flag) Printv(proxy_class_constants_code, constants_code, NIL); else Printv(module_class_constants_code, constants_code, NIL); } // Cleanup Swig_restore(n); Delete(new_value); Delete(return_type); Delete(constants_code); return SWIG_OK; } /* ----------------------------------------------------------------------------- * insertDirective() * ----------------------------------------------------------------------------- */ virtual int insertDirective(Node *n) { String *code = Getattr(n, "code"); Replaceall(code, "$module", module_class_name); Replaceall(code, "$imclassname", imclass_name); return Language::insertDirective(n); } /* ----------------------------------------------------------------------------- * pragmaDirective() * * Valid Pragmas: * jniclassbase - base (extends) for the intermediary class * jniclasspackage - package in which to generate the intermediary class * jniclassclassmodifiers - class modifiers for the intermediary class * jniclasscode - text (java code) is copied verbatim to the intermediary class * jniclassimports - import statements for the intermediary class * jniclassinterfaces - interface (implements) for the intermediary class * * modulebase - base (extends) for the module class * moduleclassmodifiers - class modifiers for the module class * modulecode - text (java code) is copied verbatim to the module class * moduleimports - import statements for the module class * moduleinterfaces - interface (implements) for the module class * * ----------------------------------------------------------------------------- */ virtual int pragmaDirective(Node *n) { if (!ImportMode) { String *lang = Getattr(n, "lang"); String *code = Getattr(n, "name"); String *value = Getattr(n, "value"); if (Strcmp(lang, "java") == 0) { String *strvalue = NewString(value); Replaceall(strvalue, "\\\"", "\""); if (Strcmp(code, "jniclassbase") == 0) { Delete(imclass_baseclass); imclass_baseclass = Copy(strvalue); } else if (Strcmp(code, "jniclasspackage") == 0) { Delete(imclass_package); imclass_package = Copy(strvalue); String *imclass_class_package_jniname = makeValidJniName(imclass_package); Printv(jnipackage, imclass_class_package_jniname, NIL); Delete(imclass_class_package_jniname); Replaceall(jnipackage, NSPACE_SEPARATOR, "_"); Append(jnipackage, "_"); String *wrapper_name = NewString(""); String *imclass_class_jniname = makeValidJniName(imclass_name); Printf(wrapper_name, "Java_%s%s_%%f", jnipackage, imclass_class_jniname); Delete(imclass_class_jniname); Swig_name_unregister("wrapper"); Swig_name_register("wrapper", Char(wrapper_name)); Delete(wrapper_name); } else if (Strcmp(code, "jniclassclassmodifiers") == 0) { Delete(imclass_class_modifiers); imclass_class_modifiers = Copy(strvalue); } else if (Strcmp(code, "jniclasscode") == 0) { Printf(imclass_class_code, "%s\n", strvalue); } else if (Strcmp(code, "jniclassimports") == 0) { Delete(imclass_imports); imclass_imports = Copy(strvalue); } else if (Strcmp(code, "jniclassinterfaces") == 0) { Delete(imclass_interfaces); imclass_interfaces = Copy(strvalue); } else if (Strcmp(code, "modulebase") == 0) { Delete(module_baseclass); module_baseclass = Copy(strvalue); } else if (Strcmp(code, "moduleclassmodifiers") == 0) { Delete(module_class_modifiers); module_class_modifiers = Copy(strvalue); } else if (Strcmp(code, "modulecode") == 0) { Printf(module_class_code, "%s\n", strvalue); } else if (Strcmp(code, "moduleimports") == 0) { Delete(module_imports); module_imports = Copy(strvalue); } else if (Strcmp(code, "moduleinterfaces") == 0) { Delete(module_interfaces); module_interfaces = Copy(strvalue); } else if (Strcmp(code, "moduleimport") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use the moduleimports pragma.\n"); } else if (Strcmp(code, "moduleinterface") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use the moduleinterfaces pragma.\n"); } else if (Strcmp(code, "modulemethodmodifiers") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%javamethodmodifiers.\n"); } else if (Strcmp(code, "allshadowimport") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaimports).\n"); } else if (Strcmp(code, "allshadowcode") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javacode).\n"); } else if (Strcmp(code, "allshadowbase") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javabase).\n"); } else if (Strcmp(code, "allshadowinterface") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javainterfaces).\n"); } else if (Strcmp(code, "allshadowclassmodifiers") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n"); } else if (proxy_flag) { if (Strcmp(code, "shadowcode") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javacode).\n"); } else if (Strcmp(code, "shadowimport") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaimports).\n"); } else if (Strcmp(code, "shadowbase") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javabase).\n"); } else if (Strcmp(code, "shadowinterface") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javainterfaces).\n"); } else if (Strcmp(code, "shadowclassmodifiers") == 0) { Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n"); } else { Swig_error(input_file, line_number, "Unrecognized pragma.\n"); } } else { Swig_error(input_file, line_number, "Unrecognized pragma.\n"); } Delete(strvalue); } } return Language::pragmaDirective(n); } /* ----------------------------------------------------------------------------- * emitProxyClassDefAndCPPCasts() * ----------------------------------------------------------------------------- */ void emitProxyClassDefAndCPPCasts(Node *n) { String *c_classname = SwigType_namestr(Getattr(n, "name")); String *c_baseclass = NULL; String *baseclass = NULL; String *c_baseclassname = NULL; SwigType *typemap_lookup_type = Getattr(n, "classtypeobj"); bool feature_director = Swig_directorclass(n) ? true : false; bool has_outerclass = Getattr(n, "nested:outer") != 0 && !GetFlag(n, "feature:flatnested"); // Inheritance from pure Java classes Node *attributes = NewHash(); const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE, attributes); bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false; bool purebase_notderived = GetFlag(attributes, "tmap:javabase:notderived") ? true : false; Delete(attributes); // C++ inheritance if (!purebase_replace) { List *baselist = Getattr(n, "bases"); if (baselist) { Iterator base = First(baselist); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } if (base.item) { c_baseclassname = Getattr(base.item, "name"); baseclass = Copy(getProxyName(c_baseclassname)); if (baseclass) c_baseclass = SwigType_namestr(Getattr(base.item, "name")); base = Next(base); /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { if (GetFlag(base.item, "feature:ignore")) { base = Next(base); continue; } String *proxyclassname = Getattr(n, "classtypeobj"); String *baseclassname = Getattr(base.item, "name"); Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname)); base = Next(base); } } } } bool derived = baseclass && getProxyName(c_baseclassname); if (derived && purebase_notderived) pure_baseclass = empty_string; const String *wanted_base = baseclass ? baseclass : pure_baseclass; if (purebase_replace) { wanted_base = pure_baseclass; derived = false; Delete(baseclass); baseclass = NULL; if (purebase_notderived) Swig_error(Getfile(n), Getline(n), "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); } else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) { Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. " "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass); } // Pure Java interfaces const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); // Start writing the proxy class if (!has_outerclass) // Import statements Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE),"\n", NIL); else Printv(proxy_class_def, "static ", NIL); // C++ nested classes correspond to static java classes Printv(proxy_class_def, typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $javaclassname", // Class name and bases (*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(pure_interfaces) ? // Pure Java interfaces " implements " : "", pure_interfaces, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class NIL); // C++ destructor is wrapped by the delete method // Note that the method name is specified in a typemap attribute called methodname String *destruct = NewString(""); const String *tm = NULL; attributes = NewHash(); String *destruct_methodname = NULL; String *destruct_methodmodifiers = NULL; if (derived) { tm = typemapLookup(n, "javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:javadestruct_derived:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct_derived:methodmodifiers"); } else { tm = typemapLookup(n, "javadestruct", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers"); } if (tm && *Char(tm)) { if (!destruct_methodname) { Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); } if (!destruct_methodmodifiers) { Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); } } // Emit the finalize and delete methods if (tm) { // Finalize method if (*Char(destructor_call)) { Printv(proxy_class_def, typemapLookup(n, "javafinalize", typemap_lookup_type, WARN_NONE), NIL); } // delete method Printv(destruct, tm, NIL); if (*Char(destructor_call)) Replaceall(destruct, "$jnicall", destructor_call); else Replaceall(destruct, "$jnicall", "throw new UnsupportedOperationException(\"C++ destructor does not have public access\")"); if (*Char(destruct)) Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL); } /* Insert directordisconnect typemap, if this class has directors enabled */ /* Also insert the swigTakeOwnership and swigReleaseOwnership methods */ if (feature_director) { String *destruct_jnicall, *release_jnicall, *take_jnicall; String *changeown_method_name = Swig_name_member(getNSpace(), getClassPrefix(), "change_ownership"); destruct_jnicall = NewStringf("%s()", destruct_methodname); release_jnicall = NewStringf("%s.%s(this, swigCPtr, false)", full_imclass_name, changeown_method_name); take_jnicall = NewStringf("%s.%s(this, swigCPtr, true)", full_imclass_name, changeown_method_name); emitCodeTypemap(n, false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall); emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall); emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall); Delete(destruct_jnicall); Delete(changeown_method_name); Delete(release_jnicall); Delete(take_jnicall); } Delete(attributes); Delete(destruct); // Emit extra user code Printv(proxy_class_def, typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code "\n", NIL); // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { String *smartptr = Getattr(n, "feature:smartptr"); String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smartptr != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast"); String *jniname = makeValidJniName(upcast_method); String *wname = Swig_name_wrapper(jniname); Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method); if (smartptr) { SwigType *spt = Swig_cparse_type(smartptr); if (spt) { SwigType *smart = SwigType_typedef_resolve_all(spt); Delete(spt); SwigType *bsmart = Copy(smart); SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); Replaceall(bsmart, rclassname, rbaseclass); Delete(rclassname); Delete(rbaseclass); String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(bsmart); Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", " jlong baseptr = 0;\n" " ", smartnamestr, " *argp1;\n" " (void)jenv;\n" " (void)jcls;\n" " argp1 = *(", smartnamestr, " **)&jarg1;\n" " *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n" " return baseptr;\n" "}\n", "\n", NIL); Delete(bsmartnamestr); Delete(smartnamestr); Delete(bsmart); } else { Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, c_classname); } } else { Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", " jlong baseptr = 0;\n" " (void)jenv;\n" " (void)jcls;\n" " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n" " return baseptr;\n" "}\n", "\n", NIL); } Delete(wname); Delete(jniname); Delete(upcast_method); } Delete(baseclass); } /* ---------------------------------------------------------------------- * classHandler() * ---------------------------------------------------------------------- */ virtual int classHandler(Node *n) { File *f_proxy = NULL; String *old_proxy_class_name = proxy_class_name; String *old_full_proxy_class_name = full_proxy_class_name; String *old_full_imclass_name = full_imclass_name; String *old_destructor_call = destructor_call; String *old_destructor_throws_clause = destructor_throws_clause; String *old_proxy_class_constants_code = proxy_class_constants_code; String *old_proxy_class_def = proxy_class_def; String *old_proxy_class_code = proxy_class_code; bool has_outerclass = Getattr(n, "nested:outer") && !GetFlag(n, "feature:flatnested"); if (proxy_flag) { proxy_class_name = NewString(Getattr(n, "sym:name")); String *nspace = getNSpace(); constructIntermediateClassName(n); String *outerClassesPrefix = 0; if (Node *outer = Getattr(n, "nested:outer")) { outerClassesPrefix = Copy(Getattr(outer, "sym:name")); for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) { Push(outerClassesPrefix, "."); Push(outerClassesPrefix, Getattr(outer, "sym:name")); } } if (!nspace) { full_proxy_class_name = outerClassesPrefix ? NewStringf("%s.%s", outerClassesPrefix, proxy_class_name) : NewStringf("%s", proxy_class_name); if (Cmp(proxy_class_name, imclass_name) == 0) { Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name); SWIG_exit(EXIT_FAILURE); } if (Cmp(proxy_class_name, module_class_name) == 0) { Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name); SWIG_exit(EXIT_FAILURE); } } else { if (outerClassesPrefix) { if (package) full_proxy_class_name = NewStringf("%s.%s.%s.%s", package, nspace, outerClassesPrefix, proxy_class_name); else full_proxy_class_name = NewStringf("%s.%s.%s", nspace, outerClassesPrefix, proxy_class_name); } else { if (package) full_proxy_class_name = NewStringf("%s.%s.%s", package, nspace, proxy_class_name); else full_proxy_class_name = NewStringf("%s.%s", nspace, proxy_class_name); } } if (outerClassesPrefix) { String *fnspace = nspace ? NewStringf("%s.%s", nspace, outerClassesPrefix) : outerClassesPrefix; if (!addSymbol(proxy_class_name, n, fnspace)) return SWIG_ERROR; if (nspace) Delete(fnspace); Delete(outerClassesPrefix); } else { if (!addSymbol(proxy_class_name, n, nspace)) return SWIG_ERROR; } // Each outer proxy class goes into a separate file if (!has_outerclass) { String *output_directory = outputDirectory(nspace); String *filen = NewStringf("%s%s.java", output_directory, proxy_class_name); f_proxy = NewFile(filen, "w", SWIG_output_files()); if (!f_proxy) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); Delete(output_directory); // Start writing out the proxy class file emitBanner(f_proxy); if (package || nspace) { Printf(f_proxy, "package "); if (package) Printv(f_proxy, package, nspace ? "." : "", NIL); if (nspace) Printv(f_proxy, nspace, NIL); Printf(f_proxy, ";\n"); } } else ++nesting_depth; proxy_class_def = NewString(""); proxy_class_code = NewString(""); destructor_call = NewString(""); destructor_throws_clause = NewString(""); proxy_class_constants_code = NewString(""); } Language::classHandler(n); if (proxy_flag) { emitProxyClassDefAndCPPCasts(n); String *javaclazzname = Swig_name_member(getNSpace(), getClassPrefix(), ""); // mangled full proxy class name Replaceall(proxy_class_def, "$javaclassname", proxy_class_name); Replaceall(proxy_class_code, "$javaclassname", proxy_class_name); Replaceall(proxy_class_constants_code, "$javaclassname", proxy_class_name); Replaceall(proxy_class_def, "$javaclazzname", javaclazzname); Replaceall(proxy_class_code, "$javaclazzname", javaclazzname); Replaceall(proxy_class_constants_code, "$javaclazzname", javaclazzname); Replaceall(proxy_class_def, "$module", module_class_name); Replaceall(proxy_class_code, "$module", module_class_name); Replaceall(proxy_class_constants_code, "$module", module_class_name); Replaceall(proxy_class_def, "$imclassname", full_imclass_name); Replaceall(proxy_class_code, "$imclassname", full_imclass_name); Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name); if (!has_outerclass) Printv(f_proxy, proxy_class_def, proxy_class_code, NIL); else { Swig_offset_string(proxy_class_def, nesting_depth); Append(old_proxy_class_code, proxy_class_def); Swig_offset_string(proxy_class_code, nesting_depth); Append(old_proxy_class_code, proxy_class_code); } // Write out all the constants if (Len(proxy_class_constants_code) != 0) { if (!has_outerclass) Printv(f_proxy, proxy_class_constants_code, NIL); else { Swig_offset_string(proxy_class_constants_code, nesting_depth); Append(old_proxy_class_code, proxy_class_constants_code); } } if (!has_outerclass) { Printf(f_proxy, "}\n"); Delete(f_proxy); f_proxy = NULL; } else { for (int i = 0; i < nesting_depth; ++i) Append(old_proxy_class_code, " "); Append(old_proxy_class_code, "}\n\n"); --nesting_depth; } /* Output the downcast method, if necessary. Note: There's no other really good place to put this code, since Abstract Base Classes (ABCs) can and should have downcasts, making the constructorHandler() a bad place (because ABCs don't get to have constructors emitted.) */ if (GetFlag(n, "feature:javadowncast")) { String *downcast_method = Swig_name_member(getNSpace(), getClassPrefix(), "SWIGDowncast"); String *jniname = makeValidJniName(downcast_method); String *wname = Swig_name_wrapper(jniname); String *norm_name = SwigType_namestr(Getattr(n, "name")); Printf(imclass_class_code, " public final static native %s %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method); Wrapper *dcast_wrap = NewWrapper(); Printf(dcast_wrap->def, "SWIGEXPORT jobject JNICALL %s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", wname); Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n"); Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n"); Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name); Printf(dcast_wrap->code, " if (obj) director = dynamic_cast(obj);\n"); Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n"); Printf(dcast_wrap->code, " return jresult;\n"); Printf(dcast_wrap->code, "}\n"); Wrapper_print(dcast_wrap, f_wrappers); DelWrapper(dcast_wrap); Delete(norm_name); Delete(wname); Delete(jniname); Delete(downcast_method); } emitDirectorExtraMethods(n); Delete(javaclazzname); Delete(proxy_class_name); proxy_class_name = old_proxy_class_name; Delete(full_proxy_class_name); full_proxy_class_name = old_full_proxy_class_name; Delete(full_imclass_name); full_imclass_name = old_full_imclass_name; Delete(destructor_call); destructor_call = old_destructor_call; Delete(destructor_throws_clause); destructor_throws_clause = old_destructor_throws_clause; Delete(proxy_class_constants_code); proxy_class_constants_code = old_proxy_class_constants_code; Delete(proxy_class_def); proxy_class_def = old_proxy_class_def; Delete(proxy_class_code); proxy_class_code = old_proxy_class_code; } return SWIG_OK; } /* ---------------------------------------------------------------------- * memberfunctionHandler() * ---------------------------------------------------------------------- */ virtual int memberfunctionHandler(Node *n) { member_func_flag = true; Language::memberfunctionHandler(n); if (proxy_flag) { String *overloaded_name = getOverloadedName(n); String *intermediary_function_name = Swig_name_member(getNSpace(), getClassPrefix(), overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); Delete(overloaded_name); } member_func_flag = false; return SWIG_OK; } /* ---------------------------------------------------------------------- * staticmemberfunctionHandler() * ---------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { static_flag = true; member_func_flag = true; Language::staticmemberfunctionHandler(n); if (proxy_flag) { String *overloaded_name = getOverloadedName(n); String *intermediary_function_name = Swig_name_member(getNSpace(), getClassPrefix(), overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); Delete(overloaded_name); } static_flag = false; member_func_flag = false; return SWIG_OK; } /* ----------------------------------------------------------------------------- * proxyClassFunctionHandler() * * Function called for creating a Java wrapper function around a c++ function in the * proxy class. Used for both static and non-static C++ class functions. * C++ class static functions map to Java static functions. * Two extra attributes in the Node must be available. These are "proxyfuncname" - * the name of the Java class proxy function, which in turn will call "imfuncname" - * the intermediary (JNI) function name in the intermediary class. * ----------------------------------------------------------------------------- */ void proxyClassFunctionHandler(Node *n) { SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *intermediary_function_name = Getattr(n, "imfuncname"); String *proxy_function_name = Getattr(n, "proxyfuncname"); String *tm; Parm *p; int i; String *imcall = NewString(""); String *return_type = NewString(""); String *function_code = NewString(""); bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); if (!proxy_flag) return; // Wrappers not wanted for some methods where the parameters cannot be overloaded in Java if (Getattr(n, "overload:ignore")) return; // Don't generate proxy method for additional explicitcall method used in directors if (GetFlag(n, "explicitcall")) return; if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { l = nextSibling(l); } } /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); Swig_typemap_attach_parms("jtype", l, NULL); Swig_typemap_attach_parms("jstype", l, NULL); Swig_typemap_attach_parms("javain", l, NULL); /* Get return types */ if ((tm = Swig_typemap_lookup("jstype", n, "", 0))) { // Note that in the case of polymorphic (covariant) return types, the method's return type is changed to be the base of the C++ return type SwigType *covariant = Getattr(n, "covariant"); substituteClassname(covariant ? covariant : t, tm); Printf(return_type, "%s", tm); if (covariant) Swig_warning(WARN_JAVA_COVARIANT_RET, input_file, line_number, "Covariant return types not supported in Java. Proxy method will return %s.\n", SwigType_str(covariant, 0)); } else { Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined for %s\n", SwigType_str(t, 0)); } if (wrapping_member_flag && !enum_constant_flag) { // For wrapping member variables (Javabean setter) setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), Swig_name_member(0, getClassPrefix(), variable_name))) == 0); } /* Start generating the proxy function */ const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); Printf(function_code, " %s ", methodmods); if (static_flag) Printf(function_code, "static "); Printf(function_code, "%s %s(", return_type, proxy_function_name); Printv(imcall, full_imclass_name, ".$imfuncname(", NIL); if (!static_flag) { Printf(imcall, "swigCPtr"); String *this_type = Copy(getClassType()); String *name = NewString("self"); String *qualifier = Getattr(n, "qualifier"); if (qualifier) SwigType_push(this_type, qualifier); SwigType_add_pointer(this_type); Parm *this_parm = NewParm(this_type, name, n); Swig_typemap_attach_parms("jtype", this_parm, NULL); Swig_typemap_attach_parms("jstype", this_parm, NULL); if (prematureGarbageCollectionPreventionParameter(this_type, this_parm)) Printf(imcall, ", this"); Delete(this_parm); Delete(name); Delete(this_type); } emit_mark_varargs(l); int gencomma = !static_flag; /* Output each parameter */ for (i = 0, p = l; p; i++) { /* Ignored varargs */ if (checkAttribute(p, "varargs:ignore", "1")) { p = nextSibling(p); continue; } /* Ignored parameters */ if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } /* Ignore the 'this' argument for variable wrappers */ if (!(variable_wrapper_flag && i == 0) || static_flag) { SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); /* Get the Java parameter type */ if ((tm = Getattr(p, "tmap:jstype"))) { substituteClassname(pt, tm); Printf(param_type, "%s", tm); } else { Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined for %s\n", SwigType_str(pt, 0)); } if (gencomma) Printf(imcall, ", "); String *arg = makeParameterName(n, p, i, setter_flag); // Use typemaps to transform type used in Java proxy wrapper (in proxy class) to type used in JNI function (in intermediary class) if ((tm = Getattr(p, "tmap:javain"))) { addThrows(n, "tmap:javain", p); substituteClassname(pt, tm); Replaceall(tm, "$javainput", arg); String *pre = Getattr(p, "tmap:javain:pre"); if (pre) { substituteClassname(pt, pre); Replaceall(pre, "$javainput", arg); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:javain:post"); if (post) { substituteClassname(pt, post); Replaceall(post, "$javainput", arg); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_JAVA_TYPEMAP_JAVAIN_UNDEF, input_file, line_number, "No javain typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to proxy function */ if (gencomma >= 2) Printf(function_code, ", "); gencomma = 2; Printf(function_code, "%s %s", param_type, arg); if (prematureGarbageCollectionPreventionParameter(pt, p)) { String *pgcppname = Getattr(p, "tmap:javain:pgcppname"); if (pgcppname) { String *argname = Copy(pgcppname); Replaceall(argname, "$javainput", arg); Printf(imcall, ", %s", argname); Delete(argname); } else { Printf(imcall, ", %s", arg); } } Delete(arg); Delete(param_type); } p = Getattr(p, "tmap:in:next"); } Printf(imcall, ")"); Printf(function_code, ")"); // Transform return type used in JNI function (in intermediary class) to type used in Java wrapper function (in proxy class) if ((tm = Swig_typemap_lookup("javaout", n, "", 0))) { addThrows(n, "tmap:javaout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; if (is_pre_code || is_post_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); Printv(tm, " finally {\n", post_code, "\n }", NIL); } else { Insert(tm, 0, "\n "); } if (is_pre_code) { Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } Insert(tm, 0, "{"); Printf(tm, "\n }"); } if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); // For director methods: generate code to selectively make a normal polymorphic call or // an explicit method call - needed to prevent infinite recursion calls in director methods. Node *explicit_n = Getattr(n, "explicitcallnode"); if (explicit_n) { String *ex_overloaded_name = getOverloadedName(explicit_n); String *ex_intermediary_function_name = Swig_name_member(getNSpace(), getClassPrefix(), ex_overloaded_name); String *ex_imcall = Copy(imcall); Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name); Replaceall(imcall, "$imfuncname", intermediary_function_name); String *excode = NewString(""); if (!Cmp(return_type, "void")) Printf(excode, "if (getClass() == %s.class) %s; else %s", proxy_class_name, imcall, ex_imcall); else Printf(excode, "(getClass() == %s.class) ? %s : %s", proxy_class_name, imcall, ex_imcall); Clear(imcall); Printv(imcall, excode, NIL); Delete(ex_overloaded_name); Delete(excode); } else { Replaceall(imcall, "$imfuncname", intermediary_function_name); } Replaceall(tm, "$jnicall", imcall); } else { Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number, "No javaout typemap defined for %s\n", SwigType_str(t, 0)); } generateThrowsClause(n, function_code); Printf(function_code, " %s\n\n", tm ? (const String *) tm : empty_string); Printv(proxy_class_code, function_code, NIL); Delete(pre_code); Delete(post_code); Delete(function_code); Delete(return_type); Delete(imcall); } /* ---------------------------------------------------------------------- * constructorHandler() * ---------------------------------------------------------------------- */ virtual int constructorHandler(Node *n) { ParmList *l = Getattr(n, "parms"); String *tm; Parm *p; int i; String *function_code = NewString(""); String *helper_code = NewString(""); // Holds code for the constructor helper method generated only when the javain typemap has code in the pre or post attributes String *helper_args = NewString(""); String *pre_code = NewString(""); String *post_code = NewString(""); String *im_return_type = NewString(""); bool feature_director = (parentNode(n) && Swig_directorclass(n)); Language::constructorHandler(n); // Wrappers not wanted for some methods where the parameters cannot be overloaded in Java if (Getattr(n, "overload:ignore")) return SWIG_OK; if (proxy_flag) { String *overloaded_name = getOverloadedName(n); String *mangled_overname = Swig_name_construct(getNSpace(), overloaded_name); String *imcall = NewString(""); const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); tm = Getattr(n, "tmap:jtype"); // typemaps were attached earlier to the node Printf(im_return_type, "%s", tm); Printf(function_code, " %s %s(", methodmods, proxy_class_name); Printf(helper_code, " static private %s SwigConstruct%s(", im_return_type, proxy_class_name); Printv(imcall, full_imclass_name, ".", mangled_overname, "(", NIL); /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); Swig_typemap_attach_parms("jtype", l, NULL); Swig_typemap_attach_parms("jstype", l, NULL); Swig_typemap_attach_parms("javain", l, NULL); emit_mark_varargs(l); int gencomma = 0; /* Output each parameter */ for (i = 0, p = l; p; i++) { /* Ignored varargs */ if (checkAttribute(p, "varargs:ignore", "1")) { p = nextSibling(p); continue; } /* Ignored parameters */ if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); /* Get the Java parameter type */ if ((tm = Getattr(p, "tmap:jstype"))) { substituteClassname(pt, tm); Printf(param_type, "%s", tm); } else { Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined for %s\n", SwigType_str(pt, 0)); } if (gencomma) Printf(imcall, ", "); String *arg = makeParameterName(n, p, i, false); // Use typemaps to transform type used in Java wrapper function (in proxy class) to type used in JNI function (in intermediary class) if ((tm = Getattr(p, "tmap:javain"))) { addThrows(n, "tmap:javain", p); substituteClassname(pt, tm); Replaceall(tm, "$javainput", arg); String *pre = Getattr(p, "tmap:javain:pre"); if (pre) { substituteClassname(pt, pre); Replaceall(pre, "$javainput", arg); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:javain:post"); if (post) { substituteClassname(pt, post); Replaceall(post, "$javainput", arg); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_JAVA_TYPEMAP_JAVAIN_UNDEF, input_file, line_number, "No javain typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to proxy function */ if (gencomma) { Printf(function_code, ", "); Printf(helper_code, ", "); Printf(helper_args, ", "); } Printf(function_code, "%s %s", param_type, arg); Printf(helper_code, "%s %s", param_type, arg); Printf(helper_args, "%s", arg); ++gencomma; if (prematureGarbageCollectionPreventionParameter(pt, p)) { String *pgcppname = Getattr(p, "tmap:javain:pgcppname"); if (pgcppname) { String *argname = Copy(pgcppname); Replaceall(argname, "$javainput", arg); Printf(imcall, ", %s", argname); Delete(argname); } else { Printf(imcall, ", %s", arg); } } Delete(arg); Delete(param_type); p = Getattr(p, "tmap:in:next"); } Printf(imcall, ")"); Printf(function_code, ")"); Printf(helper_code, ")"); generateThrowsClause(n, function_code); /* Insert the javaconstruct typemap, doing the replacement for $directorconnect, as needed */ Hash *attributes = NewHash(); String *construct_tm = Copy(typemapLookup(n, "javaconstruct", Getattr(n, "name"), WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF, attributes)); if (construct_tm) { if (!feature_director) { Replaceall(construct_tm, "$directorconnect", ""); } else { String *connect_attr = Getattr(attributes, "tmap:javaconstruct:directorconnect"); if (connect_attr) { Replaceall(construct_tm, "$directorconnect", connect_attr); } else { Swig_warning(WARN_JAVA_NO_DIRECTORCONNECT_ATTR, input_file, line_number, "\"directorconnect\" attribute missing in %s \"javaconstruct\" typemap.\n", Getattr(n, "name")); Replaceall(construct_tm, "$directorconnect", ""); } } Printv(function_code, " ", construct_tm, "\n", NIL); } bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; if (is_pre_code || is_post_code) { generateThrowsClause(n, helper_code); Printf(helper_code, " {\n"); if (is_pre_code) { Printv(helper_code, pre_code, "\n", NIL); } if (is_post_code) { Printf(helper_code, " try {\n"); Printv(helper_code, " return ", imcall, ";\n", NIL); Printv(helper_code, " } finally {\n", post_code, "\n }", NIL); } else { Printv(helper_code, " return ", imcall, ";", NIL); } Printf(helper_code, "\n }\n"); String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args); Printv(proxy_class_code, helper_code, "\n", NIL); Replaceall(function_code, "$imcall", helper_name); Delete(helper_name); } else { Replaceall(function_code, "$imcall", imcall); } Printv(proxy_class_code, function_code, "\n", NIL); Delete(helper_args); Delete(im_return_type); Delete(pre_code); Delete(post_code); Delete(construct_tm); Delete(attributes); Delete(overloaded_name); Delete(imcall); } return SWIG_OK; } /* ---------------------------------------------------------------------- * destructorHandler() * ---------------------------------------------------------------------- */ virtual int destructorHandler(Node *n) { Language::destructorHandler(n); String *symname = Getattr(n, "sym:name"); if (proxy_flag) { Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL); generateThrowsClause(n, destructor_throws_clause); } return SWIG_OK; } /* ---------------------------------------------------------------------- * membervariableHandler() * ---------------------------------------------------------------------- */ virtual int membervariableHandler(Node *n) { variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; variable_wrapper_flag = true; Language::membervariableHandler(n); wrapping_member_flag = false; variable_wrapper_flag = false; return SWIG_OK; } /* ---------------------------------------------------------------------- * staticmembervariableHandler() * ---------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; static_flag = true; Language::staticmembervariableHandler(n); wrapping_member_flag = false; static_flag = false; return SWIG_OK; } /* ---------------------------------------------------------------------- * memberconstantHandler() * ---------------------------------------------------------------------- */ virtual int memberconstantHandler(Node *n) { variable_name = Getattr(n, "sym:name"); wrapping_member_flag = true; Language::memberconstantHandler(n); wrapping_member_flag = false; return SWIG_OK; } /* ----------------------------------------------------------------------------- * getOverloadedName() * ----------------------------------------------------------------------------- */ String *getOverloadedName(Node *n) { /* Although JNI functions are designed to handle overloaded Java functions, * a Java long is used for all classes in the SWIG intermediary class. * The intermediary class methods are thus mangled when overloaded to give * a unique name. */ String *overloaded_name = NewStringf("%s", Getattr(n, "sym:name")); if (Getattr(n, "sym:overloaded")) { Printv(overloaded_name, Getattr(n, "sym:overname"), NIL); } return overloaded_name; } /* ----------------------------------------------------------------------------- * moduleClassFunctionHandler() * ----------------------------------------------------------------------------- */ void moduleClassFunctionHandler(Node *n) { SwigType *t = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); String *tm; Parm *p; int i; String *imcall = NewString(""); String *return_type = NewString(""); String *function_code = NewString(""); int num_arguments = 0; String *overloaded_name = getOverloadedName(n); String *func_name = NULL; bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { l = nextSibling(l); } } /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("jstype", l, NULL); Swig_typemap_attach_parms("javain", l, NULL); /* Get return types */ if ((tm = Swig_typemap_lookup("jstype", n, "", 0))) { substituteClassname(t, tm); Printf(return_type, "%s", tm); } else { Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined for %s\n", SwigType_str(t, 0)); } /* Change function name for global variables */ if (proxy_flag && global_variable_flag) { // Capitalize the first letter in the variable to create a JavaBean type getter/setter function name func_name = NewString(""); setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), variable_name)) == 0); if (setter_flag) Printf(func_name, "set"); else Printf(func_name, "get"); Putc(toupper((int) *Char(variable_name)), func_name); Printf(func_name, "%s", Char(variable_name) + 1); } else { func_name = Copy(Getattr(n, "sym:name")); } /* Start generating the function */ const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); Printf(function_code, " %s static %s %s(", methodmods, return_type, func_name); Printv(imcall, imclass_name, ".", overloaded_name, "(", NIL); /* Get number of required and total arguments */ num_arguments = emit_num_arguments(l); bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag); int gencomma = 0; /* Output each parameter */ for (i = 0, p = l; i < num_arguments; i++) { /* Ignored parameters */ while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); /* Get the Java parameter type */ if ((tm = Getattr(p, "tmap:jstype"))) { substituteClassname(pt, tm); Printf(param_type, "%s", tm); } else { Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined for %s\n", SwigType_str(pt, 0)); } if (gencomma) Printf(imcall, ", "); String *arg = makeParameterName(n, p, i, global_or_member_variable); // Use typemaps to transform type used in Java wrapper function (in proxy class) to type used in JNI function (in intermediary class) if ((tm = Getattr(p, "tmap:javain"))) { addThrows(n, "tmap:javain", p); substituteClassname(pt, tm); Replaceall(tm, "$javainput", arg); String *pre = Getattr(p, "tmap:javain:pre"); if (pre) { substituteClassname(pt, pre); Replaceall(pre, "$javainput", arg); if (Len(pre_code) > 0) Printf(pre_code, "\n"); Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:javain:post"); if (post) { substituteClassname(pt, post); Replaceall(post, "$javainput", arg); if (Len(post_code) > 0) Printf(post_code, "\n"); Printv(post_code, post, NIL); } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_JAVA_TYPEMAP_JAVAIN_UNDEF, input_file, line_number, "No javain typemap defined for %s\n", SwigType_str(pt, 0)); } /* Add parameter to module class function */ if (gencomma >= 2) Printf(function_code, ", "); gencomma = 2; Printf(function_code, "%s %s", param_type, arg); if (prematureGarbageCollectionPreventionParameter(pt, p)) { String *pgcppname = Getattr(p, "tmap:javain:pgcppname"); if (pgcppname) { String *argname = Copy(pgcppname); Replaceall(argname, "$javainput", arg); Printf(imcall, ", %s", argname); Delete(argname); } else { Printf(imcall, ", %s", arg); } } p = Getattr(p, "tmap:in:next"); Delete(arg); Delete(param_type); } Printf(imcall, ")"); Printf(function_code, ")"); // Transform return type used in JNI function (in intermediary class) to type used in Java wrapper function (in module class) if ((tm = Swig_typemap_lookup("javaout", n, "", 0))) { addThrows(n, "tmap:javaout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; if (is_pre_code || is_post_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); Printv(tm, " finally {\n", post_code, "\n }", NIL); } else { Insert(tm, 0, "\n "); } if (is_pre_code) { Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } Insert(tm, 0, "{"); Printf(tm, "\n }"); } if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "true"); else Replaceall(tm, "$owner", "false"); substituteClassname(t, tm); Replaceall(tm, "$jnicall", imcall); } else { Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number, "No javaout typemap defined for %s\n", SwigType_str(t, 0)); } generateThrowsClause(n, function_code); Printf(function_code, " %s\n\n", tm ? (const String *) tm : empty_string); Printv(module_class_code, function_code, NIL); Delete(pre_code); Delete(post_code); Delete(function_code); Delete(return_type); Delete(imcall); Delete(func_name); } /*---------------------------------------------------------------------- * replaceSpecialVariables() *--------------------------------------------------------------------*/ virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) { (void)method; SwigType *type = Getattr(parm, "type"); substituteClassname(type, tm); } /*---------------------------------------------------------------------- * decodeEnumFeature() * Decode the possible enum features, which are one of: * %javaenum(simple) * %javaenum(typeunsafe) - default * %javaenum(typesafe) * %javaenum(proper) *--------------------------------------------------------------------*/ EnumFeature decodeEnumFeature(Node *n) { EnumFeature enum_feature = TypeunsafeEnum; String *feature = Getattr(n, "feature:java:enum"); if (feature) { if (Cmp(feature, "simple") == 0) enum_feature = SimpleEnum; else if (Cmp(feature, "typesafe") == 0) enum_feature = TypesafeEnum; else if (Cmp(feature, "proper") == 0) enum_feature = ProperEnum; } return enum_feature; } /* ----------------------------------------------------------------------- * enumValue() * This method will return a string with an enum value to use in Java generated * code. If the %javaconst feature is not used, the string will contain the intermediary * class call to obtain the enum value. The intermediary class and JNI methods to obtain * the enum value will be generated. Otherwise the C/C++ enum value will be used if there * is one and hopefully it will compile as Java code - e.g. 20 as in: enum E{e=20}; * The %javaconstvalue feature overrides all other ways to generate the constant value. * The caller must delete memory allocated for the returned string. * ------------------------------------------------------------------------ */ String *enumValue(Node *n) { String *symname = Getattr(n, "sym:name"); // Check for the %javaconstvalue feature String *value = Getattr(n, "feature:java:constvalue"); if (!value) { // The %javaconst feature determines how the constant value is obtained int const_feature_flag = GetFlag(n, "feature:java:const"); if (const_feature_flag) { // Use the C syntax to make a true Java constant and hope that it compiles as Java code value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); } else { // Get the enumvalue from a JNI call if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) { // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } else { memberconstantHandler(n); value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname))); } } } return value; } /* ----------------------------------------------------------------------------- * getEnumName() * * If jnidescriptor is set, inner class names are separated with '$' otherwise a '.' * and the package is also not added to the name. * ----------------------------------------------------------------------------- */ String *getEnumName(SwigType *t, bool jnidescriptor) { Node *enumname = NULL; Node *n = enumLookup(t); if (n) { enumname = Getattr(n, "enumname"); if (!enumname || jnidescriptor) { String *symname = Getattr(n, "sym:name"); if (symname) { // Add in class scope when referencing enum if not a global enum String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name")); String *proxyname = 0; if (scopename_prefix) { proxyname = getProxyName(scopename_prefix, jnidescriptor); } if (proxyname) { const char *class_separator = jnidescriptor ? "$" : "."; enumname = NewStringf("%s%s%s", proxyname, class_separator, symname); } else { // global enum or enum in a namespace String *nspace = Getattr(n, "sym:nspace"); if (nspace) { if (package && !jnidescriptor) enumname = NewStringf("%s.%s.%s", package, nspace, symname); else enumname = NewStringf("%s.%s", nspace, symname); } else { enumname = Copy(symname); } } if (!jnidescriptor) { Setattr(n, "enumname", enumname); // Cache it Delete(enumname); } Delete(scopename_prefix); } } } return enumname; } /* ----------------------------------------------------------------------------- * substituteClassname() * * Substitute the special variable $javaclassname with the proxy class name for classes/structs/unions * that SWIG knows about. Also substitutes enums with enum name. * Otherwise use the $descriptor name for the Java class name. Note that the $&javaclassname substitution * is the same as a $&descriptor substitution, ie one pointer added to descriptor name. * Note that the path separator is a '.' unless jnidescriptor is set. * Inputs: * pt - parameter type * tm - typemap contents that might contain the special variable to be replaced * jnidescriptor - if set, inner class names are separated with '$' otherwise a '/' is used for the path separator * Outputs: * tm - typemap contents complete with the special variable substitution * Return: * substitution_performed - flag indicating if a substitution was performed * ----------------------------------------------------------------------------- */ bool substituteClassname(SwigType *pt, String *tm, bool jnidescriptor = false) { bool substitution_performed = false; SwigType *type = Copy(SwigType_typedef_resolve_all(pt)); SwigType *strippedtype = SwigType_strip_qualifiers(type); if (Strstr(tm, "$javaclassname")) { SwigType *classnametype = Copy(strippedtype); substituteClassnameSpecialVariable(classnametype, tm, "$javaclassname", jnidescriptor); substitution_performed = true; Delete(classnametype); } if (Strstr(tm, "$*javaclassname")) { SwigType *classnametype = Copy(strippedtype); Delete(SwigType_pop(classnametype)); if (Len(classnametype) > 0) { substituteClassnameSpecialVariable(classnametype, tm, "$*javaclassname", jnidescriptor); substitution_performed = true; } Delete(classnametype); } if (Strstr(tm, "$&javaclassname")) { SwigType *classnametype = Copy(strippedtype); SwigType_add_pointer(classnametype); substituteClassnameSpecialVariable(classnametype, tm, "$&javaclassname", jnidescriptor); substitution_performed = true; Delete(classnametype); } Delete(strippedtype); Delete(type); return substitution_performed; } /* ----------------------------------------------------------------------------- * substituteClassnameSpecialVariable() * ----------------------------------------------------------------------------- */ void substituteClassnameSpecialVariable(SwigType *classnametype, String *tm, const char *classnamespecialvariable, bool jnidescriptor) { String *replacementname; if (SwigType_isenum(classnametype)) { String *enumname = getEnumName(classnametype, jnidescriptor); if (enumname) { replacementname = Copy(enumname); } else { bool anonymous_enum = (Cmp(classnametype, "enum ") == 0); if (anonymous_enum) { replacementname = NewString("int"); } else { // An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) or an ignored enum replacementname = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype)); Replace(replacementname, "enum ", "", DOH_REPLACE_ANY); Setattr(swig_types_hash, replacementname, classnametype); } } } else { String *classname = getProxyName(classnametype, jnidescriptor); // getProxyName() works for pointers to classes too if (classname) { replacementname = Copy(classname); } else { // use $descriptor if SWIG does not know anything about this type. Note that any typedefs are resolved. replacementname = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype)); // Add to hash table so that the type wrapper classes can be created later Setattr(swig_types_hash, replacementname, classnametype); } } if (jnidescriptor) Replaceall(replacementname,".","/"); Replaceall(tm, classnamespecialvariable, replacementname); Delete(replacementname); } /* ----------------------------------------------------------------------------- * makeParameterName() * * Inputs: * n - Node * p - parameter node * arg_num - parameter argument number * setter - set this flag when wrapping variables * Return: * arg - a unique parameter name * ----------------------------------------------------------------------------- */ String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) { String *arg = 0; String *pn = Getattr(p, "name"); // Use C parameter name unless it is a duplicate or an empty parameter name int count = 0; ParmList *plist = Getattr(n, "parms"); while (plist) { if ((Cmp(pn, Getattr(plist, "name")) == 0)) count++; plist = nextSibling(plist); } String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); if (setter && Cmp(arg, "self") != 0) { // Note that for setters the parameter name is always set but sometimes includes C++ // scope resolution, so we need to strip off the scope resolution to make a valid name. Delete(arg); arg = NewString("value"); //Swig_scopename_last(pn); } return arg; } /* ----------------------------------------------------------------------------- * emitTypeWrapperClass() * ----------------------------------------------------------------------------- */ void emitTypeWrapperClass(String *classname, SwigType *type) { Node *n = NewHash(); Setfile(n, input_file); Setline(n, line_number); String *swigtype = NewString(""); String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname); File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); if (!f_swigtype) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); filen = NULL; // Start writing out the type wrapper class file emitBanner(f_swigtype); if (package) Printf(f_swigtype, "package %s;\n", package); // Pure Java baseclass and interfaces const String *pure_baseclass = typemapLookup(n, "javabase", type, WARN_NONE); const String *pure_interfaces = typemapLookup(n, "javainterfaces", type, WARN_NONE); // Emit the class Printv(swigtype, typemapLookup(n, "javaimports", type, WARN_NONE), // Import statements "\n", typemapLookup(n, "javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $javaclassname", // Class name and bases *Char(pure_baseclass) ? " extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces " implements " : "", pure_interfaces, " {", typemapLookup(n, "javabody", type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class typemapLookup(n, "javacode", type, WARN_NONE), // extra Java code "}\n", "\n", NIL); Replaceall(swigtype, "$javaclassname", classname); Replaceall(swigtype, "$module", module_class_name); Replaceall(swigtype, "$imclassname", imclass_name); // For unknown enums Replaceall(swigtype, "$static ", ""); Replaceall(swigtype, "$enumvalues", ""); Printv(f_swigtype, swigtype, NIL); Delete(f_swigtype); Delete(swigtype); Delete(n); } /* ----------------------------------------------------------------------------- * typemapLookup() * n - for input only and must contain info for Getfile(n) and Getline(n) to work * tmap_method - typemap method name * type - typemap type to lookup * warning - warning number to issue if no typemaps found * typemap_attributes - the typemap attributes are attached to this node and will * also be used for temporary storage if non null * return is never NULL, unlike Swig_typemap_lookup() * ----------------------------------------------------------------------------- */ const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) { Node *node = !typemap_attributes ? NewHash() : typemap_attributes; Setattr(node, "type", type); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0); if (!tm) { tm = empty_string; if (warning != WARN_NONE) Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0)); } if (!typemap_attributes) Delete(node); return tm; } /* ----------------------------------------------------------------------------- * addThrows() * * Adds exception classes to a throws list. The throws list is the list of classes * that will form the Java throws clause. Mainly for checked exceptions. * ----------------------------------------------------------------------------- */ void addThrows(Node *n, const String *attribute, Node *parameter) { // Get the comma separated exception classes for the throws clause - held in typemap/feature's "throws" attribute String *throws_attribute = NewStringf("%s:throws", attribute); String *throws = Getattr(parameter, throws_attribute); if (throws && Len(throws) > 0) { String *throws_list = Getattr(n, "java:throwslist"); if (!throws_list) { throws_list = NewList(); Setattr(n, "java:throwslist", throws_list); } // Put the exception classes in the throws clause into a temporary List List *temp_classes_list = Split(throws, ',', INT_MAX); // Add the exception classes to the node throws list, but don't duplicate if already in list if (temp_classes_list && Len(temp_classes_list) > 0) { for (Iterator cls = First(temp_classes_list); cls.item; cls = Next(cls)) { String *exception_class = NewString(cls.item); Replaceall(exception_class, " ", ""); // remove spaces Replaceall(exception_class, "\t", ""); // remove tabs if (Len(exception_class) > 0) { // $javaclassname substitution SwigType *pt = Getattr(parameter, "type"); substituteClassname(pt, exception_class); // Don't duplicate the Java exception class in the throws clause bool found_flag = false; for (Iterator item = First(throws_list); item.item; item = Next(item)) { if (Strcmp(item.item, exception_class) == 0) found_flag = true; } if (!found_flag) Append(throws_list, exception_class); } Delete(exception_class); } } Delete(temp_classes_list); } Delete(throws_attribute); } /* ----------------------------------------------------------------------------- * generateThrowsClause() * * Generates throws clause for checked exception * ----------------------------------------------------------------------------- */ void generateThrowsClause(Node *n, String *code) { // Add the throws clause into code List *throws_list = Getattr(n, "java:throwslist"); if (throws_list) { Iterator cls = First(throws_list); Printf(code, " throws %s", cls.item); while ((cls = Next(cls)).item) Printf(code, ", %s", cls.item); } } /* ----------------------------------------------------------------------------- * prematureGarbageCollectionPreventionParameter() * * Get the proxy class name for use in an additional generated parameter. The * additional parameter is added to a native method call purely to prevent * premature garbage collection of proxy classes which pass their C++ class pointer * in a Java long to the JNI layer. * ----------------------------------------------------------------------------- */ String *prematureGarbageCollectionPreventionParameter(SwigType *t, Parm *p) { String *proxyClassName = 0; String *jtype = NewString(Getattr(p, "tmap:jtype")); // Strip C comments String *stripped_jtype = Swig_strip_c_comments(jtype); if (stripped_jtype) { Delete(jtype); jtype = stripped_jtype; } // Remove whitespace Replaceall(jtype, " ", ""); Replaceall(jtype, "\t", ""); if (Cmp(jtype, "long") == 0) { if (proxy_flag) { if (!GetFlag(p, "tmap:jtype:nopgcpp") && !nopgcpp_flag) { String *proxyname = getProxyName(t); if (proxyname) { // Found a struct/class parameter passed by value, reference, pointer, or pointer reference proxyClassName = proxyname; } else { // Look for proxy class parameters passed to C++ layer using non-default typemaps, ie not one of above types String *jstype = NewString(Getattr(p, "tmap:jstype")); if (jstype) { Hash *classes = getClassHash(); if (classes) { // Strip C comments String *stripped_jstype = Swig_strip_c_comments(jstype); if (stripped_jstype) { Delete(jstype); jstype = stripped_jstype; } // Remove whitespace Replaceall(jstype, " ", ""); Replaceall(jstype, "\t", ""); Iterator ki; for (ki = First(classes); ki.key; ki = Next(ki)) { Node *cls = ki.item; if (cls && !Getattr(cls, "feature:ignore")) { String *symname = Getattr(cls, "sym:name"); if (symname && Strcmp(symname, jstype) == 0) { proxyClassName = symname; } } } } } Delete(jstype); } } } } Delete(jtype); return proxyClassName; } /* ----------------------------------------------------------------------------- * outputDirectory() * * Return the directory to use for generating Java classes/enums and create the * subdirectory (does not create if language specific outdir does not exist). * ----------------------------------------------------------------------------- */ String *outputDirectory(String *nspace) { String *output_directory = Copy(SWIG_output_directory()); if (nspace) { String *nspace_subdirectory = Copy(nspace); Replaceall(nspace_subdirectory, ".", SWIG_FILE_DELIMITER); String *newdir_error = Swig_new_subdirectory(output_directory, nspace_subdirectory); if (newdir_error) { Printf(stderr, "%s\n", newdir_error); Delete(newdir_error); SWIG_exit(EXIT_FAILURE); } Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0); Delete(nspace_subdirectory); } return output_directory; } /*---------------------------------------------------------------------- * Start of director methods *--------------------------------------------------------------------*/ /*---------------------------------------------------------------------- * getUpcallJNIMethod() *--------------------------------------------------------------------*/ String *getUpcallJNIMethod(String *descrip) { static struct { char code; const char *method; } upcall_methods[] = { { 'B', "CallStaticByteMethod"}, { 'C', "CallStaticCharMethod"}, { 'D', "CallStaticDoubleMethod"}, { 'F', "CallStaticFloatMethod"}, { 'I', "CallStaticIntMethod"}, { 'J', "CallStaticLongMethod"}, { 'L', "CallStaticObjectMethod"}, { 'S', "CallStaticShortMethod"}, { 'V', "CallStaticVoidMethod"}, { 'Z', "CallStaticBooleanMethod"}, { '[', "CallStaticObjectMethod"} }; char code; int i; code = *Char(descrip); for (i = 0; i < (int) (sizeof(upcall_methods) / sizeof(upcall_methods[0])); ++i) if (code == upcall_methods[i].code) return NewString(upcall_methods[i].method); return NULL; } /*---------------------------------------------------------------------- * emitDirectorUpcalls() *--------------------------------------------------------------------*/ void emitDirectorUpcalls() { if (n_dmethods) { Wrapper *w = NewWrapper(); String *jni_imclass_name = makeValidJniName(imclass_name); String *swig_module_init = NewString("swig_module_init"); String *swig_module_init_jni = makeValidJniName(swig_module_init); String *dmethod_data = NewString(""); int n_methods = 0; Iterator udata_iter; udata_iter = First(dmethods_seq); while (udata_iter.item) { UpcallData *udata = udata_iter.item; Printf(dmethod_data, " { \"%s\", \"%s\" }", Getattr(udata, "imclass_method"), Getattr(udata, "imclass_fdesc")); ++n_methods; udata_iter = Next(udata_iter); if (udata_iter.item) Putc(',', dmethod_data); Putc('\n', dmethod_data); } Printf(f_runtime, "namespace Swig {\n"); Printf(f_runtime, " namespace {\n"); Printf(f_runtime, " jclass jclass_%s = NULL;\n", imclass_name); Printf(f_runtime, " jmethodID director_methids[%d];\n", n_methods); Printf(f_runtime, " }\n"); Printf(f_runtime, "}\n"); Printf(w->def, "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls) {", jnipackage, jni_imclass_name, swig_module_init_jni); Printf(w->code, "static struct {\n"); Printf(w->code, " const char *method;\n"); Printf(w->code, " const char *signature;\n"); Printf(w->code, "} methods[%d] = {\n", n_methods); Printv(w->code, dmethod_data, NIL); Printf(w->code, "};\n"); Wrapper_add_local(w, "i", "int i"); Printf(w->code, "Swig::jclass_%s = (jclass) jenv->NewGlobalRef(jcls);\n", imclass_name); Printf(w->code, "if (!Swig::jclass_%s) return;\n", imclass_name); Printf(w->code, "for (i = 0; i < (int) (sizeof(methods)/sizeof(methods[0])); ++i) {\n"); Printf(w->code, " Swig::director_methids[i] = jenv->GetStaticMethodID(jcls, methods[i].method, methods[i].signature);\n"); Printf(w->code, " if (!Swig::director_methids[i]) return;\n"); Printf(w->code, "}\n"); Printf(w->code, "}\n"); Wrapper_print(w, f_wrappers); Delete(dmethod_data); Delete(swig_module_init_jni); Delete(swig_module_init); Delete(jni_imclass_name); DelWrapper(w); } } /*---------------------------------------------------------------------- * emitDirectorExtraMethods() * * This is where the director connect method is generated. *--------------------------------------------------------------------*/ void emitDirectorExtraMethods(Node *n) { if (!Swig_directorclass(n)) return; // Output the director connect method: String *jni_imclass_name = makeValidJniName(imclass_name); String *norm_name = SwigType_namestr(Getattr(n, "name")); String *swig_director_connect = Swig_name_member(getNSpace(), getClassPrefix(), "director_connect"); String *swig_director_connect_jni = makeValidJniName(swig_director_connect); String *smartptr = Getattr(n, "feature:smartptr"); String *dirClassName = directorClassName(n); Wrapper *code_wrap; Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean mem_own, boolean weak_global);\n", swig_director_connect, full_proxy_class_name); code_wrap = NewWrapper(); Printf(code_wrap->def, "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, " "jboolean jweak_global) {\n", jnipackage, jni_imclass_name, swig_director_connect_jni); if (Len(smartptr)) { Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr, smartptr); Printf(code_wrap->code, " (void)jcls;\n"); Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); } else { Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name); Printf(code_wrap->code, " (void)jcls;\n"); Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); } Printf(code_wrap->code, " if (director) {\n"); Printf(code_wrap->code, " director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), " "(jswig_mem_own == JNI_TRUE), (jweak_global == JNI_TRUE));\n"); Printf(code_wrap->code, " }\n"); Printf(code_wrap->code, "}\n"); Wrapper_print(code_wrap, f_wrappers); DelWrapper(code_wrap); Delete(swig_director_connect_jni); Delete(swig_director_connect); // Output the swigReleaseOwnership, swigTakeOwnership methods: String *changeown_method_name = Swig_name_member(getNSpace(), getClassPrefix(), "change_ownership"); String *changeown_jnimethod_name = makeValidJniName(changeown_method_name); Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean take_or_release);\n", changeown_method_name, full_proxy_class_name); code_wrap = NewWrapper(); Printf(code_wrap->def, "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jtake_or_release) {\n", jnipackage, jni_imclass_name, changeown_jnimethod_name); Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name); Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); Printf(code_wrap->code, " (void)jcls;\n"); Printf(code_wrap->code, " if (director) {\n"); Printf(code_wrap->code, " director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);\n"); Printf(code_wrap->code, " }\n"); Printf(code_wrap->code, "}\n"); Wrapper_print(code_wrap, f_wrappers); DelWrapper(code_wrap); Delete(changeown_method_name); Delete(changeown_jnimethod_name); Delete(norm_name); Delete(dirClassName); Delete(jni_imclass_name); } /*---------------------------------------------------------------------- * emitCodeTypemap() * * Output a code typemap that uses $methodname and $jnicall, as used * in the directordisconnect, director_release and director_take * typemaps. *--------------------------------------------------------------------*/ void emitCodeTypemap(Node *n, bool derived, SwigType *lookup_type, const String *typemap, const String *methodname, const String *jnicall) { const String *tm = NULL; Node *tmattrs = NewHash(); String *lookup_tmname = NewString(typemap); String *method_attr_name; String *method_attr; if (derived) { Append(lookup_tmname, "_derived"); } tm = typemapLookup(n, lookup_tmname, lookup_type, WARN_NONE, tmattrs); method_attr_name = NewStringf("tmap:%s:%s", lookup_tmname, methodname); method_attr = Getattr(tmattrs, method_attr_name); if (*Char(tm)) { if (method_attr) { String *codebody = Copy(tm); Replaceall(codebody, "$methodname", method_attr); Replaceall(codebody, "$jnicall", jnicall); Append(proxy_class_def, codebody); Delete(codebody); } else { Swig_error(input_file, line_number, "No %s method name attribute for %s\n", lookup_tmname, proxy_class_name); } } else { Swig_error(input_file, line_number, "No %s typemap for %s\n", lookup_tmname, proxy_class_name); } Delete(tmattrs); Delete(lookup_tmname); // Delete(method_attr); } /* ----------------------------------------------------------------------------- * substitutePackagePath() * * Replace $packagepath using the javapackage typemap associated with passed * parm or global package if p is 0. "$packagepath/" is replaced with "" if * no package is set. Note that the path separator is a '/'. * ----------------------------------------------------------------------------- */ void substitutePackagePath(String *text, Parm *p) { String *pkg_path= 0; if (p) pkg_path = Swig_typemap_lookup("javapackage", p, "", 0); if (!pkg_path || Len(pkg_path) == 0) pkg_path = Copy(package_path); if (Len(pkg_path) > 0) { Replaceall(pkg_path, ".", "/"); Replaceall(text, "$packagepath", pkg_path); } else { Replaceall(text, "$packagepath/", empty_string); Replaceall(text, "$packagepath", empty_string); } Delete(pkg_path); } /* --------------------------------------------------------------- * Canonicalize the JNI field descriptor * * Replace the $packagepath and $javaclassname family of special * variables with the desired package and Java proxy name as * required in the JNI field descriptors. * * !!SFM!! If $packagepath occurs in the field descriptor, but * package_path isn't set (length == 0), then strip it and the * optional trailing '/' from the resulting name. * * --------------------------------------------------------------- */ String *canonicalizeJNIDescriptor(String *descriptor_in, Parm *p) { SwigType *type = Getattr(p, "type"); String *descriptor_out = Copy(descriptor_in); substituteClassname(type, descriptor_out, true); substitutePackagePath(descriptor_out, p); return descriptor_out; } /* --------------------------------------------------------------- * classDirectorMethod() * * Emit a virtual director method to pass a method call on to the * underlying Java object. * * --------------------------------------------------------------- */ int classDirectorMethod(Node *n, Node *parent, String *super) { String *classname = Getattr(parent, "sym:name"); String *c_classname = Getattr(parent, "name"); String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *returntype = Getattr(n, "type"); String *overloaded_name = getOverloadedName(n); String *storage = Getattr(n, "storage"); String *value = Getattr(n, "value"); String *decl = Getattr(n, "decl"); String *declaration = NewString(""); String *tm; Parm *p; int i; Wrapper *w = NewWrapper(); ParmList *l = Getattr(n, "parms"); bool is_void = !(Cmp(returntype, "void")); String *qualified_return = 0; bool pure_virtual = (!(Cmp(storage, "virtual")) && !(Cmp(value, "0"))); int status = SWIG_OK; bool output_director = true; String *dirclassname = directorClassName(parent); String *qualified_name = NewStringf("%s::%s", dirclassname, name); String *jnidesc = NewString(""); String *classdesc = NewString(""); String *jniret_desc = NewString(""); String *classret_desc = NewString(""); SwigType *c_ret_type = NULL; String *jupcall_args = NewString("swigjobj"); String *imclass_dmethod; String *callback_def = NewString(""); String *callback_code = NewString(""); String *imcall_args = NewString(""); int classmeth_off = curr_class_dmethod - first_class_dmethod; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; String *qualified_classname = Copy(classname); String *nspace = getNSpace(); if (nspace && package) Insert(qualified_classname, 0, NewStringf("%s.%s.", package, nspace)); else if(nspace) Insert(qualified_classname, 0, NewStringf("%s.", nspace)); // Kludge Alert: functionWrapper sets sym:overload properly, but it // isn't at this point, so we have to manufacture it ourselves. At least // we're consistent with the sym:overload name in functionWrapper. (?? when // does the overloaded method name get set?) imclass_dmethod = NewStringf("%s", Swig_name_member(getNSpace(), dirclassname, overloaded_name)); qualified_return = SwigType_rcaststr(returntype, "c_result"); if (!is_void && (!ignored_method || pure_virtual)) { if (!SwigType_isclass(returntype)) { if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); Delete(construct_result); } else { String *base_typename = SwigType_base(returntype); String *resolved_typename = SwigType_typedef_resolve_all(base_typename); Symtab *symtab = Getattr(n, "sym:symtab"); Node *typenode = Swig_symbol_clookup(resolved_typename, symtab); if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstracts"))) { /* initialize pointers to something sane. Same for abstract classes when a reference is returned. */ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); } else { /* If returning a reference, initialize the pointer to a sane default - if a Java exception occurs, then the pointer returns something other than a NULL-initialized reference. */ String *non_ref_type = Copy(returntype); /* Remove reference and const qualifiers */ Replaceall(non_ref_type, "r.", ""); Replaceall(non_ref_type, "q(const).", ""); Wrapper_add_localv(w, "result_default", "static", SwigType_str(non_ref_type, "result_default"), "=", SwigType_str(non_ref_type, "()"), NIL); Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= &result_default", NIL); Delete(non_ref_type); } Delete(base_typename); Delete(resolved_typename); } } else { SwigType *vt; vt = cplus_value_type(returntype); if (!vt) { Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL); } else { Wrapper_add_localv(w, "c_result", SwigType_lstr(vt, "c_result"), NIL); Delete(vt); } } } /* Create the intermediate class wrapper */ tm = Swig_typemap_lookup("jtype", n, "", 0); if (tm) { Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, qualified_classname); } else { Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(returntype, 0)); } String *cdesc = NULL; SwigType *covariant = Getattr(n, "covariant"); SwigType *adjustedreturntype = covariant ? covariant : returntype; Parm *adjustedreturntypeparm = NewParmNode(adjustedreturntype, n); if (Swig_typemap_lookup("directorin", adjustedreturntypeparm, "", 0) && (cdesc = Getattr(adjustedreturntypeparm, "tmap:directorin:descriptor"))) { // Note that in the case of polymorphic (covariant) return types, the // method's return type is changed to be the base of the C++ return // type String *jnidesc_canon = canonicalizeJNIDescriptor(cdesc, adjustedreturntypeparm); Append(classret_desc, jnidesc_canon); Delete(jnidesc_canon); } else { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } /* Get the JNI field descriptor for this return type, add the JNI field descriptor to jniret_desc */ if ((c_ret_type = Swig_typemap_lookup("jni", n, "", 0))) { Parm *tp = NewParmNode(c_ret_type, n); if (!is_void && !ignored_method) { String *jretval_decl = NewStringf("%s jresult", c_ret_type); Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL); Delete(jretval_decl); } String *jdesc = NULL; if (Swig_typemap_lookup("directorin", tp, "", 0) && (jdesc = Getattr(tp, "tmap:directorin:descriptor"))) { // Objects marshalled passing a Java class across JNI boundary use jobject - the nouse flag indicates this // We need the specific Java class name instead of the generic 'Ljava/lang/Object;' if (GetFlag(tp, "tmap:directorin:nouse")) jdesc = cdesc; String *jnidesc_canon = canonicalizeJNIDescriptor(jdesc, tp); Append(jniret_desc, jnidesc_canon); Delete(jnidesc_canon); } else { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(c_ret_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } Delete(tp); } else { Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } Delete(adjustedreturntypeparm); Delete(qualified_classname); Swig_director_parms_fixup(l); /* Attach the standard typemaps */ Swig_typemap_attach_parms("out", l, 0); Swig_typemap_attach_parms("jni", l, 0); Swig_typemap_attach_parms("jtype", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("javadirectorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); if (!ignored_method) { /* Add Java environment pointer to wrapper */ String *jenvstr = NewString("jenv"); String *jobjstr = NewString("swigjobj"); Wrapper_add_localv(w, "swigjnienv", "JNIEnvWrapper", "swigjnienv(this)", NIL, NIL); Wrapper_add_localv(w, jenvstr, "JNIEnv *", jenvstr, "= swigjnienv.getJNIEnv()", NIL); Wrapper_add_localv(w, jobjstr, "jobject", jobjstr, "= (jobject) NULL", NIL); Delete(jenvstr); Delete(jobjstr); /* Preamble code */ Printf(w->code, "if (!swig_override[%d]) {\n", classmeth_off); } if (!pure_virtual) { String *super_call = Swig_method_call(super, l); if (is_void) { Printf(w->code, "%s;\n", super_call); if (!ignored_method) Printf(w->code, "return;\n"); } else { Printf(w->code, "return %s;\n", super_call); } Delete(super_call); } else { Printf(w->code, "SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "); Printf(w->code, "\"Attempted to invoke pure virtual method %s::%s.\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); /* Make sure that we return something in the case of a pure * virtual method call for syntactical reasons. */ if (!is_void) Printf(w->code, "return %s;", qualified_return); else if (!ignored_method) Printf(w->code, "return;\n"); } if (!ignored_method) { Printf(w->code, "}\n"); Printf(w->code, "swigjobj = swig_get_self(jenv);\n"); Printf(w->code, "if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {\n"); } /* Start the Java field descriptor for the intermediate class's upcall (insert self object) */ Parm *tp = NewParmNode(c_classname, n); String *jdesc; if ((tm = Swig_typemap_lookup("directorin", tp, "", 0)) && (jdesc = Getattr(tp, "tmap:directorin:descriptor"))) { String *jni_canon = canonicalizeJNIDescriptor(jdesc, tp); Append(jnidesc, jni_canon); Delete(jni_canon); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap for type %s for use in %s::%s (skipping director method)\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } Delete(tp); /* Go through argument list, convert from native to Java */ for (i = 0, p = l; p; ++i) { /* Is this superfluous? */ while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } SwigType *pt = Getattr(p, "type"); String *ln = makeParameterName(n, p, i, false); String *c_param_type = NULL; String *c_decl = NewString(""); String *arg = NewString(""); Printf(arg, "j%s", ln); /* Add various typemap's 'throws' clauses */ addThrows(n, "tmap:directorin", p); addThrows(n, "tmap:out", p); /* And add to the upcall args */ Printf(jupcall_args, ", %s", arg); /* Get parameter's intermediary C type */ if ((c_param_type = Getattr(p, "tmap:jni"))) { Parm *tp = NewParm(c_param_type, Getattr(p, "name"), n); String *desc_tm = NULL, *jdesc = NULL, *cdesc = NULL; /* Add to local variables */ Printf(c_decl, "%s %s", c_param_type, arg); if (!ignored_method) Wrapper_add_localv(w, arg, c_decl, (!(SwigType_ispointer(pt) || SwigType_isreference(pt)) ? "" : "= 0"), NIL); /* Add input marshalling code and update JNI field descriptor */ if ((desc_tm = Swig_typemap_lookup("directorin", tp, "", 0)) && (jdesc = Getattr(tp, "tmap:directorin:descriptor")) && (tm = Getattr(p, "tmap:directorin")) && (cdesc = Getattr(p, "tmap:directorin:descriptor"))) { // Objects marshalled by passing a Java class across the JNI boundary use jobject as the JNI type - // the nouse flag indicates this. We need the specific Java class name instead of the generic 'Ljava/lang/Object;' if (GetFlag(tp, "tmap:directorin:nouse")) jdesc = cdesc; String *jni_canon = canonicalizeJNIDescriptor(jdesc, tp); Append(jnidesc, jni_canon); Delete(jni_canon); Setattr(p, "emit:directorinput", arg); Replaceall(tm, "$input", arg); Replaceall(tm, "$owner", "0"); if (Len(tm)) if (!ignored_method) Printf(w->code, "%s\n", tm); /* Add parameter to the intermediate class code if generating the * intermediate's upcall code */ if ((tm = Getattr(p, "tmap:jtype"))) { String *din = Copy(Getattr(p, "tmap:javadirectorin")); addThrows(n, "tmap:javadirectorin", p); if (din) { Replaceall(din, "$module", module_class_name); Replaceall(din, "$imclassname", imclass_name); substituteClassname(pt, din); Replaceall(din, "$jniinput", ln); if (i > 0) Printf(imcall_args, ", "); Printf(callback_def, ", %s %s", tm, ln); if (Cmp(din, ln)) { Printv(imcall_args, din, NIL); } else Printv(imcall_args, ln, NIL); jni_canon = canonicalizeJNIDescriptor(cdesc, p); Append(classdesc, jni_canon); Delete(jni_canon); } else { Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number, "No javadirectorin typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } } else { Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } p = Getattr(p, "tmap:directorin:next"); Delete(desc_tm); } else { if (!desc_tm) { Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = nextSibling(p); } else if (!jdesc) { Swig_warning(WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC, input_file, line_number, "Missing JNI descriptor in directorin typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = Getattr(p, "tmap:directorin:next"); } else if (!tm) { Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = nextSibling(p); } else if (!cdesc) { Swig_warning(WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC, input_file, line_number, "Missing JNI descriptor in directorin typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = Getattr(p, "tmap:directorin:next"); } output_director = false; } } else { Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s for use in %s::%s (skipping director method)\n", SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; p = nextSibling(p); } Delete(arg); Delete(c_decl); Delete(ln); } /* header declaration, start wrapper definition */ String *target; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); target = Swig_method_decl(rtype, decl, name, l, 0, 1); Printf(declaration, " virtual %s", target); Delete(target); // Add any exception specifications to the methods in the director class // Get any Java exception classes in the throws typemap ParmList *throw_parm_list = NULL; // May need to add Java throws clause to director methods if %catches defined // Get any Java exception classes in the throws typemap ParmList *catches_list = Getattr(n, "catchlist"); if (catches_list) { Swig_typemap_attach_parms("throws", catches_list, 0); Swig_typemap_attach_parms("directorthrows", catches_list, 0); for (p = catches_list; p; p = nextSibling(p)) { addThrows(n, "tmap:throws", p); } } if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { int gencomma = 0; Append(w->def, " throw("); Append(declaration, " throw("); if (throw_parm_list) { Swig_typemap_attach_parms("throws", throw_parm_list, 0); Swig_typemap_attach_parms("directorthrows", throw_parm_list, 0); } for (p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { // %catches replaces the specified exception specification if (!catches_list) { addThrows(n, "tmap:throws", p); } if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); } Printf(w->def, "%s", SwigType_str(Getattr(p, "type"), 0)); Printf(declaration, "%s", SwigType_str(Getattr(p, "type"), 0)); } } Append(w->def, ")"); Append(declaration, ")"); } Append(w->def, " {"); Append(declaration, ";\n"); /* Emit the intermediate class's upcall to the actual class */ String *upcall = NewStringf("self.%s(%s)", symname, imcall_args); // Handle exception classes specified in the "except" feature's "throws" attribute addThrows(n, "feature:except", n); if (!is_void) { if ((tm = Swig_typemap_lookup("javadirectorout", n, "", 0))) { addThrows(n, "tmap:javadirectorout", n); substituteClassname(returntype, tm); Replaceall(tm, "$javacall", upcall); Printf(callback_code, " return %s;\n", tm); } if ((tm = Swig_typemap_lookup("out", n, "", 0))) addThrows(n, "tmap:out", n); Delete(tm); } else Printf(callback_code, " %s;\n", upcall); Printf(callback_code, " }\n"); Delete(upcall); /* Finish off the inherited upcall's definition */ Putc(')', callback_def); generateThrowsClause(n, callback_def); Printf(callback_def, " {\n"); if (!ignored_method) { /* Emit the actual upcall through */ String *imclass_desc = NewStringf("(%s)%s", jnidesc, jniret_desc); String *class_desc = NewStringf("(%s)%s", classdesc, classret_desc); UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, imclass_desc, class_desc, decl); String *methid = Getattr(udata, "imclass_methodidx"); String *methop = getUpcallJNIMethod(jniret_desc); if (!is_void) Printf(w->code, "jresult = (%s) ", c_ret_type); Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n", methop, imclass_name, methid, jupcall_args); // Generate code to handle any Java exception thrown by director delegation directorExceptHandler(n, catches_list ? catches_list : throw_parm_list, w); if (!is_void) { String *jresult_str = NewString("jresult"); String *result_str = NewString("c_result"); /* Copy jresult into c_result... */ if ((tm = Swig_typemap_lookup("directorout", n, result_str, w))) { addThrows(n, "tmap:directorout", n); Replaceall(tm, "$input", jresult_str); Replaceall(tm, "$result", result_str); Printf(w->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use return type %s used in %s::%s (skipping director method)\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } Delete(jresult_str); Delete(result_str); } /* Marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout"))) { addThrows(n, "tmap:directorargout", p); Replaceall(tm, "$result", "jresult"); Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } Delete(imclass_desc); Delete(class_desc); /* Terminate wrapper code */ Printf(w->code, "} else {\n"); Printf(w->code, "SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, \"null upcall object in %s::%s \");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); Printf(w->code, "}\n"); Printf(w->code, "if (swigjobj) jenv->DeleteLocalRef(swigjobj);\n"); if (!is_void) Printf(w->code, "return %s;", qualified_return); } Printf(w->code, "}"); // We expose virtual protected methods via an extra public inline method which makes a straight call to the wrapped class' method String *inline_extra_method = NewString(""); if (dirprot_mode() && !is_public(n) && !pure_virtual) { Printv(inline_extra_method, declaration, NIL); String *extra_method_name = NewStringf("%sSwigPublic", name); Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, ";\n", " {\n "); if (!is_void) Printf(inline_extra_method, "return "); String *methodcall = Swig_method_call(super, l); Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Delete(methodcall); Delete(extra_method_name); } /* emit the director method */ if (status == SWIG_OK && output_director) { if (!is_void) { Replaceall(w->code, "$null", qualified_return); } else { Replaceall(w->code, "$null", ""); } if (!GetFlag(n, "feature:ignore")) Printv(imclass_directors, callback_def, callback_code, NIL); if (!Getattr(n, "defaultargs")) { Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); } } Delete(inline_extra_method); Delete(qualified_return); Delete(jnidesc); Delete(c_ret_type); Delete(jniret_desc); Delete(declaration); Delete(callback_def); Delete(callback_code); DelWrapper(w); return status; } /* ------------------------------------------------------------ * directorExceptHandler() * * Emit code to map Java exceptions back to C++ exceptions when * feature("director:except") is applied to a method node. * This is generated after the Java method upcall. * ------------------------------------------------------------ */ void directorExceptHandler(Node *n, ParmList *throw_parm_list, Wrapper *w) { String *directorexcept = Getattr(n, "feature:director:except"); if (!directorexcept) { directorexcept = NewString(""); Printf(directorexcept, "jthrowable $error = jenv->ExceptionOccurred();\n"); Printf(directorexcept, "if ($error) {\n"); Printf(directorexcept, " jenv->ExceptionClear();$directorthrowshandlers\n"); Printf(directorexcept, " throw Swig::DirectorException(jenv, $error);\n"); Printf(directorexcept, "}\n"); } else { directorexcept = Copy(directorexcept); } // Can explicitly disable director:except by setting to "" or "0" if (Len(directorexcept) > 0 && Cmp(directorexcept, "0") != 0) { // Replace $packagepath substitutePackagePath(directorexcept, 0); // Replace $directorthrowshandlers with any defined typemap handlers (or nothing) if (Strstr(directorexcept, "$directorthrowshandlers")) { String *directorthrowshandlers_code = NewString(""); for (Parm *p = throw_parm_list; p; p = nextSibling(p)) { String *tm = Getattr(p, "tmap:directorthrows"); if (tm) { // replace $packagepath/$javaclassname String *directorthrows = canonicalizeJNIDescriptor(tm, p); Printv(directorthrowshandlers_code, directorthrows, NIL); Delete(directorthrows); } else { String *t = Getattr(p,"type"); Swig_warning(WARN_TYPEMAP_DIRECTORTHROWS_UNDEF, Getfile(n), Getline(n), "No directorthrows typemap defined for %s\n", SwigType_str(t, 0)); } } Replaceall(directorexcept, "$directorthrowshandlers", directorthrowshandlers_code); Delete(directorthrowshandlers_code); } Replaceall(directorexcept, "$error", "swigerror"); Printf(w->code, " %s\n", directorexcept); } Delete(directorexcept); } /* ------------------------------------------------------------ * directorPrefixArgs() * ------------------------------------------------------------ */ void directorPrefixArgs(Node *n) { Parm *p; /* Need to prepend 'jenv' to the director constructor's argument list */ String *jenv_type = NewString("JNIEnv"); SwigType_add_pointer(jenv_type); p = NewParm(jenv_type, NewString("jenv"), n); Setattr(p, "arg:byname", "1"); set_nextSibling(p, NULL); Setattr(n, "director:prefix_args", p); } /* ------------------------------------------------------------ * classDirectorConstructor() * ------------------------------------------------------------ */ int classDirectorConstructor(Node *n) { Node *parent = parentNode(n); String *decl = Getattr(n, "decl"); String *supername = Swig_class_name(parent); String *dirclassname = directorClassName(parent); String *sub = NewString(""); Parm *p; ParmList *superparms = Getattr(n, "parms"); ParmList *parms; int argidx = 0; /* Assign arguments to superclass's parameters, if not already done */ for (p = superparms; p; p = nextSibling(p)) { String *pname = Getattr(p, "name"); if (!pname) { pname = NewStringf("arg%d", argidx++); Setattr(p, "name", pname); } } /* insert jenv prefix argument */ parms = CopyParmList(superparms); String *jenv_type = NewString("JNIEnv"); SwigType_add_pointer(jenv_type); p = NewParm(jenv_type, NewString("jenv"), n); set_nextSibling(p, parms); parms = p; directorPrefixArgs(n); if (!Getattr(n, "defaultargs")) { /* constructor */ { String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 0); String *call = Swig_csuperclass_call(0, basetype, superparms); String *classtype = SwigType_namestr(Getattr(n, "name")); Printf(f_directors, "%s::%s : %s, %s {\n", dirclassname, target, call, Getattr(parent, "director:ctor")); Printf(f_directors, "}\n\n"); Delete(classtype); Delete(target); Delete(call); } /* constructor header */ { String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } } Delete(sub); Delete(supername); Delete(jenv_type); Delete(parms); Delete(dirclassname); return Language::classDirectorConstructor(n); } /* ------------------------------------------------------------ * classDirectorDefaultConstructor() * ------------------------------------------------------------ */ int classDirectorDefaultConstructor(Node *n) { String *classname = Swig_class_name(n); String *classtype = SwigType_namestr(Getattr(n, "name")); String *dirClassName = directorClassName(n); Wrapper *w = NewWrapper(); Printf(w->def, "%s::%s(JNIEnv *jenv) : %s {", dirClassName, dirClassName, Getattr(n, "director:ctor")); Printf(w->code, "}\n"); Wrapper_print(w, f_directors); Printf(f_directors_h, " %s(JNIEnv *jenv);\n", dirClassName); DelWrapper(w); Delete(classtype); Delete(classname); Delete(dirClassName); directorPrefixArgs(n); return Language::classDirectorDefaultConstructor(n); } /* ------------------------------------------------------------ * classDirectorInit() * ------------------------------------------------------------ */ int classDirectorInit(Node *n) { Delete(none_comparison); none_comparison = NewString(""); // not used Delete(director_ctor_code); director_ctor_code = NewString("$director_new"); directorDeclaration(n); Printf(f_directors_h, "%s {\n", Getattr(n, "director:decl")); Printf(f_directors_h, "\npublic:\n"); Printf(f_directors_h, " void swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global);\n"); /* Keep track of the director methods for this class */ first_class_dmethod = curr_class_dmethod = n_dmethods; return Language::classDirectorInit(n); } /* ---------------------------------------------------------------------- * classDirectorDestructor() * ---------------------------------------------------------------------- */ int classDirectorDestructor(Node *n) { Node *current_class = getCurrentClass(); String *full_classname = Getattr(current_class, "name"); String *classname = Swig_class_name(current_class); String *dirClassName = directorClassName(current_class); Wrapper *w = NewWrapper(); if (Getattr(n, "throw")) { Printf(f_directors_h, " virtual ~%s() throw ();\n", dirClassName); Printf(w->def, "%s::~%s() throw () {\n", dirClassName, dirClassName); } else { Printf(f_directors_h, " virtual ~%s();\n", dirClassName); Printf(w->def, "%s::~%s() {\n", dirClassName, dirClassName); } /* Ensure that correct directordisconnect typemap's method name is called * here: */ Node *disconn_attr = NewHash(); String *disconn_methodname = NULL; typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr); disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname"); Printv(w->code, " swig_disconnect_director_self(\"", disconn_methodname, "\");\n", "}\n", NIL); Wrapper_print(w, f_directors); DelWrapper(w); Delete(disconn_attr); Delete(classname); Delete(dirClassName); return SWIG_OK; } /* ------------------------------------------------------------ * classDirectorEnd() * ------------------------------------------------------------ */ int classDirectorEnd(Node *n) { String *classname = Getattr(n, "sym:name"); String *director_classname = directorClassName(n); String *internal_classname; Wrapper *w = NewWrapper(); if (Len(package_path) > 0 && Len(getNSpace()) > 0) internal_classname = NewStringf("%s/%s/%s", package_path, getNSpace(), classname); else if (Len(package_path) > 0) internal_classname = NewStringf("%s/%s", package_path, classname); else if (Len(getNSpace()) > 0) internal_classname = NewStringf("%s/%s", getNSpace(), classname); else internal_classname = NewStringf("%s", classname); // If the namespace is multiple levels, the result of getNSpace() will have inserted // .'s to delimit namespaces, so we need to replace those with /'s Replace(internal_classname, NSPACE_SEPARATOR, "/", DOH_REPLACE_ANY); Wrapper_add_localv(w, "baseclass", "static jclass baseclass", "= 0", NIL); Printf(w->def, "void %s::swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global) {", director_classname); if (first_class_dmethod != curr_class_dmethod) { Printf(w->def, "static struct {\n"); Printf(w->def, "const char *mname;\n"); Printf(w->def, "const char *mdesc;\n"); Printf(w->def, "jmethodID base_methid;\n"); Printf(w->def, "} methods[] = {\n"); for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); Printf(w->def, "{ \"%s\", \"%s\", NULL }", Getattr(udata, "method"), Getattr(udata, "fdesc")); if (i != curr_class_dmethod - 1) Putc(',', w->def); Putc('\n', w->def); } Printf(w->def, "};\n"); } Printf(w->code, "if (swig_set_self(jenv, jself, swig_mem_own, weak_global)) {\n"); Printf(w->code, "if (!baseclass) {\n"); Printf(w->code, "baseclass = jenv->FindClass(\"%s\");\n", internal_classname); Printf(w->code, "if (!baseclass) return;\n"); Printf(w->code, "baseclass = (jclass) jenv->NewGlobalRef(baseclass);\n"); Printf(w->code, "}\n"); int n_methods = curr_class_dmethod - first_class_dmethod; if (n_methods) { /* Emit the swig_overrides() method and the swig_override array */ Printf(f_directors_h, "public:\n"); Printf(f_directors_h, " bool swig_overrides(int n) {\n"); Printf(f_directors_h, " return (n < %d ? swig_override[n] : false);\n", n_methods); Printf(f_directors_h, " }\n"); Printf(f_directors_h, "protected:\n"); Printf(f_directors_h, " bool swig_override[%d];\n", n_methods); /* Emit the code to look up the class's methods, initialize the override array */ Printf(w->code, "bool derived = (jenv->IsSameObject(baseclass, jcls) ? false : true);\n"); Printf(w->code, "for (int i = 0; i < %d; ++i) {\n", n_methods); Printf(w->code, " if (!methods[i].base_methid) {\n"); Printf(w->code, " methods[i].base_methid = jenv->GetMethodID(baseclass, methods[i].mname, methods[i].mdesc);\n"); Printf(w->code, " if (!methods[i].base_methid) return;\n"); Printf(w->code, " }\n"); // Generally, derived classes have a mix of overridden and // non-overridden methods and it is worth making a GetMethodID // check during initialization to determine if each method is // overridden, thus avoiding unnecessary calls into Java. // // On the other hand, when derived classes are // expected to override all director methods then the // GetMethodID calls are inefficient, and it is better to let // the director unconditionally call up into Java. The resulting code // will still behave correctly (though less efficiently) when Java // code doesn't override a given method. // // The assumeoverride feature on a director controls whether or not // overrides are assumed. if (GetFlag(n, "feature:director:assumeoverride")) { Printf(w->code, " swig_override[i] = derived;\n"); } else { Printf(w->code, " swig_override[i] = false;\n"); Printf(w->code, " if (derived) {\n"); Printf(w->code, " jmethodID methid = jenv->GetMethodID(jcls, methods[i].mname, methods[i].mdesc);\n"); Printf(w->code, " swig_override[i] = (methid != methods[i].base_methid);\n"); Printf(w->code, " jenv->ExceptionClear();\n"); Printf(w->code, " }\n"); } Printf(w->code, "}\n"); } else { Printf(f_directors_h, "public:\n"); Printf(f_directors_h, " bool swig_overrides(int n) {\n"); Printf(f_directors_h, " return false;\n"); Printf(f_directors_h, " }\n"); } Printf(f_directors_h, "};\n\n"); Printf(w->code, "}\n"); Printf(w->code, "}\n"); Wrapper_print(w, f_directors); DelWrapper(w); Delete(internal_classname); return Language::classDirectorEnd(n); } /* -------------------------------------------------------------------- * classDirectorDisown() * ------------------------------------------------------------------*/ virtual int classDirectorDisown(Node *n) { (void) n; return SWIG_OK; } /*---------------------------------------------------------------------- * extraDirectorProtectedCPPMethodsRequired() *--------------------------------------------------------------------*/ bool extraDirectorProtectedCPPMethodsRequired() const { return false; } /*---------------------------------------------------------------------- * directorDeclaration() * * Generate the director class's declaration * e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {" *--------------------------------------------------------------------*/ void directorDeclaration(Node *n) { String *base = Getattr(n, "classtype"); String *class_ctor = NewString("Swig::Director(jenv)"); String *directorname = directorClassName(n); String *declaration = Swig_class_declaration(n, directorname); Printf(declaration, " : public %s, public Swig::Director", base); // Stash stuff for later. Setattr(n, "director:decl", declaration); Setattr(n, "director:ctor", class_ctor); } NestedClassSupport nestedClassesSupport() const { return NCS_Full; } }; /* class JAVA */ /* ----------------------------------------------------------------------------- * swig_java() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_java() { return new JAVA(); } extern "C" Language *swig_java(void) { return new_swig_java(); } /* ----------------------------------------------------------------------------- * Static member variables * ----------------------------------------------------------------------------- */ const char *JAVA::usage = "\ Java Options (available with -java)\n\ -nopgcpp - Suppress premature garbage collection prevention parameter\n\ -noproxy - Generate the low-level functional interface instead\n\ of proxy classes\n\ -oldvarnames - Old intermediary method names for variable wrappers\n\ -package - Set name of the Java package to \n\ \n"; swig-3.0.2/Source/Modules/uffi.cxx0000664000175000017500000002476012343605122016701 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * uffi.cxx * * Uffi language module for SWIG. * ----------------------------------------------------------------------------- */ // TODO: remove remnants of lisptype #include "swigmod.h" static const char *usage = "\ UFFI Options (available with -uffi)\n\ -identifier-converter - \n\ Specifies the type of conversion to do on C identifiers\n\ to convert them to symbols. There are two built-in\n\ converters: 'null' and 'lispify'. The default is\n\ 'null'. If you supply a name other than one of the\n\ built-ins, then a function by that name will be\n\ called to convert identifiers to symbols.\n\ "; class UFFI:public Language { public: virtual void main(int argc, char *argv[]); virtual int top(Node *n); virtual int functionWrapper(Node *n); virtual int constantWrapper(Node *n); virtual int classHandler(Node *n); virtual int membervariableHandler(Node *n); }; static File *f_cl = 0; static struct { int count; String **entries; } defined_foreign_types; static String *identifier_converter = NewString("identifier-convert-null"); static int any_varargs(ParmList *pl) { Parm *p; for (p = pl; p; p = nextSibling(p)) { if (SwigType_isvarargs(Getattr(p, "type"))) return 1; } return 0; } /* utilities */ /* returns new string w/ parens stripped */ static String *strip_parens(String *string) { char *s = Char(string), *p; int len = Len(string); String *res; if (len == 0 || s[0] != '(' || s[len - 1] != ')') { return NewString(string); } p = (char *) malloc(len - 2 + 1); if (!p) { Printf(stderr, "Malloc failed\n"); SWIG_exit(EXIT_FAILURE); } strncpy(p, s + 1, len - 1); p[len - 2] = 0; /* null terminate */ res = NewString(p); free(p); return res; } static String *convert_literal(String *num_param, String *type) { String *num = strip_parens(num_param), *res; char *s = Char(num); /* Make sure doubles use 'd' instead of 'e' */ if (!Strcmp(type, "double")) { String *updated = Copy(num); if (Replace(updated, "e", "d", DOH_REPLACE_ANY) > 1) { Printf(stderr, "Weird!! number %s looks invalid.\n", num); SWIG_exit(EXIT_FAILURE); } Delete(num); return updated; } if (SwigType_type(type) == T_CHAR) { /* Use CL syntax for character literals */ return NewStringf("#\\%s", num_param); } else if (SwigType_type(type) == T_STRING) { /* Use CL syntax for string literals */ return NewStringf("\"%s\"", num_param); } if (Len(num) < 2 || s[0] != '0') { return num; } /* octal or hex */ res = NewStringf("#%c%s", s[1] == 'x' ? 'x' : 'o', s + 2); Delete(num); return res; } static void add_defined_foreign_type(String *type) { if (!defined_foreign_types.count) { /* Make fresh */ defined_foreign_types.count = 1; defined_foreign_types.entries = (String **) malloc(sizeof(String *)); } else { /* make room */ defined_foreign_types.count++; defined_foreign_types.entries = (String **) realloc(defined_foreign_types.entries, defined_foreign_types.count * sizeof(String *)); } if (!defined_foreign_types.entries) { Printf(stderr, "Out of memory\n"); SWIG_exit(EXIT_FAILURE); } /* Fill in the new data */ defined_foreign_types.entries[defined_foreign_types.count - 1] = Copy(type); } static String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) { Node *node = NewHash(); Setattr(node, "type", ty); Setattr(node, "name", name); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup("ffitype", node, "", 0); Delete(node); if (tm) { return NewString(tm); } else { SwigType *tr = SwigType_typedef_resolve_all(ty); char *type_reduced = Char(tr); int i; //Printf(stdout,"convert_type %s\n", ty); if (SwigType_isconst(tr)) { SwigType_pop(tr); type_reduced = Char(tr); } if (SwigType_ispointer(type_reduced) || SwigType_isarray(ty) || !strncmp(type_reduced, "p.f", 3)) { return NewString(":pointer-void"); } for (i = 0; i < defined_foreign_types.count; i++) { if (!Strcmp(ty, defined_foreign_types.entries[i])) { return NewStringf("#.(%s \"%s\" :type :type)", identifier_converter, ty); } } if (!Strncmp(type_reduced, "enum ", 5)) { return NewString(":int"); } Printf(stderr, "Unsupported data type: %s (was: %s)\n", type_reduced, ty); SWIG_exit(EXIT_FAILURE); } return 0; } static String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) { Node *node = NewHash(); Setattr(node, "type", ty); Setattr(node, "name", name); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup("lisptype", node, "", 0); Delete(node); return tm ? NewString(tm) : NewString(""); } void UFFI::main(int argc, char *argv[]) { int i; Preprocessor_define("SWIGUFFI 1", 0); SWIG_library_directory("uffi"); SWIG_config_file("uffi.swg"); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-identifier-converter")) { char *conv = argv[i + 1]; if (!conv) Swig_arg_error(); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; /* check for built-ins */ if (!strcmp(conv, "lispify")) { Delete(identifier_converter); identifier_converter = NewString("identifier-convert-lispify"); } else if (!strcmp(conv, "null")) { Delete(identifier_converter); identifier_converter = NewString("identifier-convert-null"); } else { /* Must be user defined */ Delete(identifier_converter); identifier_converter = NewString(conv); } } if (!strcmp(argv[i], "-help")) { Printf(stdout, "%s\n", usage); } } } int UFFI::top(Node *n) { String *module = Getattr(n, "name"); String *output_filename = NewString(""); File *f_null = NewString(""); Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module); f_cl = NewFile(output_filename, "w", SWIG_output_files()); if (!f_cl) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); } Swig_register_filebyname("header", f_null); Swig_register_filebyname("begin", f_null); Swig_register_filebyname("runtime", f_null); Swig_register_filebyname("wrapper", f_cl); Swig_banner_target_lang(f_cl, ";;"); Printf(f_cl, "\n" ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n", module, module, module); Printf(f_cl, "(eval-when (compile load eval)\n (defparameter *swig-identifier-converter* '%s))\n", identifier_converter); Language::top(n); Delete(f_cl); // Delete the handle, not the file Delete(f_null); return SWIG_OK; } int UFFI::functionWrapper(Node *n) { String *funcname = Getattr(n, "sym:name"); ParmList *pl = Getattr(n, "parms"); Parm *p; int argnum = 0, first = 1; // int varargs = 0; //Language::functionWrapper(n); Printf(f_cl, "(swig-defun \"%s\"\n", funcname); Printf(f_cl, " ("); /* Special cases */ if (ParmList_len(pl) == 0) { Printf(f_cl, ":void"); } else if (any_varargs(pl)) { Printf(f_cl, "#| varargs |#"); // varargs = 1; } else { for (p = pl; p; p = nextSibling(p), argnum++) { String *argname = Getattr(p, "name"); SwigType *argtype = Getattr(p, "type"); String *ffitype = get_ffi_type(n, argtype, argname); String *lisptype = get_lisp_type(n, argtype, argname); int tempargname = 0; if (!argname) { argname = NewStringf("arg%d", argnum); tempargname = 1; } if (!first) { Printf(f_cl, "\n "); } Printf(f_cl, "(%s %s %s)", argname, ffitype, lisptype); first = 0; Delete(ffitype); Delete(lisptype); if (tempargname) Delete(argname); } } Printf(f_cl, ")\n"); /* finish arg list */ Printf(f_cl, " :returning %s\n" //" :strings-convert t\n" //" :call-direct %s\n" //" :optimize-for-space t" ")\n", get_ffi_type(n, Getattr(n, "type"), Swig_cresult_name()) //,varargs ? "nil" : "t" ); return SWIG_OK; } int UFFI::constantWrapper(Node *n) { String *type = Getattr(n, "type"); String *converted_value = convert_literal(Getattr(n, "value"), type); String *name = Getattr(n, "sym:name"); #if 0 Printf(stdout, "constant %s is of type %s. value: %s\n", name, type, converted_value); #endif Printf(f_cl, "(swig-defconstant \"%s\" %s)\n", name, converted_value); Delete(converted_value); return SWIG_OK; } // Includes structs int UFFI::classHandler(Node *n) { String *name = Getattr(n, "sym:name"); String *kind = Getattr(n, "kind"); Node *c; if (Strcmp(kind, "struct")) { Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind); Printf(stderr, " (name: %s)\n", name); SWIG_exit(EXIT_FAILURE); } Printf(f_cl, "(swig-def-struct \"%s\"\n \n", name); for (c = firstChild(n); c; c = nextSibling(c)) { SwigType *type = Getattr(c, "type"); SwigType *decl = Getattr(c, "decl"); type = Copy(type); SwigType_push(type, decl); String *lisp_type; if (Strcmp(nodeType(c), "cdecl")) { Printf(stderr, "Structure %s has a slot that we can't deal with.\n", name); Printf(stderr, "nodeType: %s, name: %s, type: %s\n", nodeType(c), Getattr(c, "name"), Getattr(c, "type")); SWIG_exit(EXIT_FAILURE); } /* Printf(stdout, "Converting %s in %s\n", type, name); */ lisp_type = get_ffi_type(n, type, Getattr(c, "sym:name")); Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type); Delete(lisp_type); } // Language::classHandler(n); Printf(f_cl, " )\n"); /* Add this structure to the known lisp types */ //Printf(stdout, "Adding %s foreign type\n", name); add_defined_foreign_type(name); return SWIG_OK; } int UFFI::membervariableHandler(Node *n) { Language::membervariableHandler(n); return SWIG_OK; } extern "C" Language *swig_uffi(void) { return new UFFI(); } swig-3.0.2/Source/Modules/overload.cxx0000664000175000017500000006527412343605122017570 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * overload.cxx * * This file is used to analyze overloaded functions and methods. * It looks at signatures and tries to gather information for * building a dispatch function. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #define MAX_OVERLOAD 4096 /* Overload "argc" and "argv" */ String *argv_template_string; String *argc_template_string; struct Overloaded { Node *n; /* Node */ int argc; /* Argument count */ ParmList *parms; /* Parameters used for overload check */ int error; /* Ambiguity error */ bool implicitconv_function; /* For ordering implicitconv functions*/ }; static int fast_dispatch_mode = 0; static int cast_dispatch_mode = 0; /* Set fast_dispatch_mode */ void Wrapper_fast_dispatch_mode_set(int flag) { fast_dispatch_mode = flag; } void Wrapper_cast_dispatch_mode_set(int flag) { cast_dispatch_mode = flag; } /* ----------------------------------------------------------------------------- * mark_implicitconv_function() * * Mark function if it contains an implicitconv type in the parameter list * ----------------------------------------------------------------------------- */ static void mark_implicitconv_function(Overloaded& onode) { Parm *parms = onode.parms; if (parms) { bool is_implicitconv_function = false; Parm *p = parms; while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; } if (GetFlag(p, "implicitconv")) { is_implicitconv_function = true; break; } p = nextSibling(p); } if (is_implicitconv_function) onode.implicitconv_function = true; } } /* ----------------------------------------------------------------------------- * Swig_overload_rank() * * This function takes an overloaded declaration and creates a list that ranks * all overloaded methods in an order that can be used to generate a dispatch * function. * Slight difference in the way this function is used by scripting languages and * statically typed languages. The script languages call this method via * Swig_overload_dispatch() - where wrappers for all overloaded methods are generated, * however sometimes the code can never be executed. The non-scripting languages * call this method via Swig_overload_check() for each overloaded method in order * to determine whether or not the method should be wrapped. Note the slight * difference when overloading methods that differ by const only. The * scripting languages will ignore the const method, whereas the non-scripting * languages ignore the first method parsed. * ----------------------------------------------------------------------------- */ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { Overloaded nodes[MAX_OVERLOAD]; int nnodes = 0; Node *o = Getattr(n, "sym:overloaded"); Node *c; if (!o) return 0; c = o; while (c) { if (Getattr(c, "error")) { c = Getattr(c, "sym:nextSibling"); continue; } /* if (SmartPointer && Getattr(c,"cplus:staticbase")) { c = Getattr(c,"sym:nextSibling"); continue; } */ /* Make a list of all the declarations (methods) that are overloaded with * this one particular method name */ if (Getattr(c, "wrap:name")) { assert(nnodes < MAX_OVERLOAD); nodes[nnodes].n = c; nodes[nnodes].parms = Getattr(c, "wrap:parms"); nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms); nodes[nnodes].error = 0; nodes[nnodes].implicitconv_function = false; mark_implicitconv_function(nodes[nnodes]); nnodes++; } c = Getattr(c, "sym:nextSibling"); } /* Sort the declarations by required argument count */ { int i, j; for (i = 0; i < nnodes; i++) { for (j = i + 1; j < nnodes; j++) { if (nodes[i].argc > nodes[j].argc) { Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; } } } } /* Sort the declarations by argument types */ { int i, j; for (i = 0; i < nnodes - 1; i++) { if (nodes[i].argc == nodes[i + 1].argc) { for (j = i + 1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) { Parm *p1 = nodes[i].parms; Parm *p2 = nodes[j].parms; int differ = 0; int num_checked = 0; while (p1 && p2 && (num_checked < nodes[i].argc)) { // Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type")); if (checkAttribute(p1, "tmap:in:numinputs", "0")) { p1 = Getattr(p1, "tmap:in:next"); continue; } if (checkAttribute(p2, "tmap:in:numinputs", "0")) { p2 = Getattr(p2, "tmap:in:next"); continue; } String *t1 = Getattr(p1, "tmap:typecheck:precedence"); String *t2 = Getattr(p2, "tmap:typecheck:precedence"); if ((!t1) && (!nodes[i].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), "Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); nodes[i].error = 1; } else if ((!t2) && (!nodes[j].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); nodes[j].error = 1; } if (t1 && t2) { int t1v, t2v; t1v = atoi(Char(t1)); t2v = atoi(Char(t2)); differ = t1v - t2v; } else if (!t1 && t2) differ = 1; else if (t1 && !t2) differ = -1; else if (!t1 && !t2) differ = -1; num_checked++; if (differ > 0) { Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; break; } else if ((differ == 0) && (Strcmp(t1, "0") == 0)) { t1 = Getattr(p1, "ltype"); if (!t1) { t1 = SwigType_ltype(Getattr(p1, "type")); if (Getattr(p1, "tmap:typecheck:SWIGTYPE")) { SwigType_add_pointer(t1); } Setattr(p1, "ltype", t1); } t2 = Getattr(p2, "ltype"); if (!t2) { t2 = SwigType_ltype(Getattr(p2, "type")); if (Getattr(p2, "tmap:typecheck:SWIGTYPE")) { SwigType_add_pointer(t2); } Setattr(p2, "ltype", t2); } /* Need subtype check here. If t2 is a subtype of t1, then we need to change the order */ if (SwigType_issubtype(t2, t1)) { Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; } if (Strcmp(t1, t2) != 0) { differ = 1; break; } } else if (differ) { break; } if (Getattr(p1, "tmap:in:next")) { p1 = Getattr(p1, "tmap:in:next"); } else { p1 = nextSibling(p1); } if (Getattr(p2, "tmap:in:next")) { p2 = Getattr(p2, "tmap:in:next"); } else { p2 = nextSibling(p2); } } if (!differ) { /* See if declarations differ by const only */ String *d1 = Getattr(nodes[i].n, "decl"); String *d2 = Getattr(nodes[j].n, "decl"); if (d1 && d2) { String *dq1 = Copy(d1); String *dq2 = Copy(d2); if (SwigType_isconst(d1)) { Delete(SwigType_pop(dq1)); } if (SwigType_isconst(d2)) { Delete(SwigType_pop(dq2)); } if (Strcmp(dq1, dq2) == 0) { if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { if (script_lang_wrapping) { // Swap nodes so that the const method gets ignored (shadowed by the non-const method) Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; } differ = 1; if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) { Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } } nodes[j].error = 1; } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { differ = 1; if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) { Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } } nodes[j].error = 1; } } Delete(dq1); Delete(dq2); } } if (!differ) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) { Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } nodes[j].error = 1; } } } } } } List *result = NewList(); { int i; int argc_changed_index = -1; for (i = 0; i < nnodes; i++) { if (nodes[i].error) Setattr(nodes[i].n, "overload:ignore", "1"); Append(result, nodes[i].n); // Printf(stdout,"[ %d ] %d %s\n", i, nodes[i].implicitconv_function, ParmList_errorstr(nodes[i].parms)); // Swig_print_node(nodes[i].n); if (i == nnodes-1 || nodes[i].argc != nodes[i+1].argc) { if (argc_changed_index+2 < nnodes && (nodes[argc_changed_index+1].argc == nodes[argc_changed_index+2].argc)) { // Add additional implicitconv functions in same order as already ranked. // Consider overloaded functions by argument count... only add additional implicitconv functions if // the number of functions with the same arg count > 1, ie, only if overloaded by same argument count. int j; for (j = argc_changed_index + 1; j <= i; j++) { if (nodes[j].implicitconv_function) { SetFlag(nodes[j].n, "implicitconvtypecheckoff"); Append(result, nodes[j].n); // Printf(stdout,"[ %d ] %d + %s\n", j, nodes[j].implicitconv_function, ParmList_errorstr(nodes[j].parms)); // Swig_print_node(nodes[j].n); } } } argc_changed_index = i; } } } return result; } // /* ----------------------------------------------------------------------------- // * print_typecheck() // * ----------------------------------------------------------------------------- */ static bool print_typecheck(String *f, int j, Parm *pj, bool implicitconvtypecheckoff) { char tmp[256]; sprintf(tmp, Char(argv_template_string), j); String *tm = Getattr(pj, "tmap:typecheck"); if (tm) { tm = Copy(tm); Replaceid(tm, Getattr(pj, "lname"), "_v"); String *conv = Getattr(pj, "implicitconv"); if (conv && !implicitconvtypecheckoff) { Replaceall(tm, "$implicitconv", conv); } else { Replaceall(tm, "$implicitconv", "0"); } Replaceall(tm, "$input", tmp); Printv(f, tm, "\n", NIL); Delete(tm); return true; } else return false; } /* ----------------------------------------------------------------------------- * ReplaceFormat() * ----------------------------------------------------------------------------- */ static String *ReplaceFormat(const_String_or_char_ptr fmt, int j) { String *lfmt = NewString(fmt); char buf[50]; sprintf(buf, "%d", j); Replaceall(lfmt, "$numargs", buf); int i; String *commaargs = NewString(""); for (i = 0; i < j; i++) { Printv(commaargs, ", ", NIL); Printf(commaargs, Char(argv_template_string), i); } Replaceall(lfmt, "$commaargs", commaargs); return lfmt; } /* ----------------------------------------------------------------------------- * Swig_overload_dispatch() * * Generate a dispatch function. argc is assumed to hold the argument count. * argv is the argument vector. * * Note that for C++ class member functions, Swig_overload_dispatch() assumes * that argc includes the "self" argument and that the first element of argv[] * is the "self" argument. So for a member function: * * Foo::bar(int x, int y, int z); * * the argc should be 4 (not 3!) and the first element of argv[] would be * the appropriate scripting language reference to "self". For regular * functions (and static class functions) the argc and argv only include * the regular function arguments. * ----------------------------------------------------------------------------- */ /* Cast dispatch mechanism. */ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *maxargs) { int i, j; *maxargs = 1; String *f = NewString(""); String *sw = NewString(""); Printf(f, "{\n"); Printf(f, "unsigned long _index = 0;\n"); Printf(f, "SWIG_TypeRank _rank = 0; \n"); /* Get a list of methods ranked by precedence values and argument count */ List *dispatch = Swig_overload_rank(n, true); int nfunc = Len(dispatch); /* Loop over the functions */ bool emitcheck = 1; for (i = 0; i < nfunc; i++) { int fn = 0; Node *ni = Getitem(dispatch, i); Parm *pi = Getattr(ni, "wrap:parms"); int num_required = emit_num_required(pi); int num_arguments = emit_num_arguments(pi); if (num_arguments > *maxargs) *maxargs = num_arguments; if (num_required == num_arguments) { Printf(f, "if (%s == %d) {\n", argc_template_string, num_required); } else { Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments); } Printf(f, "SWIG_TypeRank _ranki = 0;\n"); Printf(f, "SWIG_TypeRank _rankm = 0;\n"); if (num_arguments) Printf(f, "SWIG_TypeRank _pi = 1;\n"); /* create a list with the wrappers that collide with the current one based on argument number */ List *coll = NewList(); for (int k = i + 1; k < nfunc; k++) { Node *nk = Getitem(dispatch, k); Parm *pk = Getattr(nk, "wrap:parms"); int nrk = emit_num_required(pk); int nak = emit_num_arguments(pk); if ((nrk >= num_required && nrk <= num_arguments) || (nak >= num_required && nak <= num_arguments) || (nrk <= num_required && nak >= num_arguments)) Append(coll, nk); } // printf("overload: %s coll=%d\n", Char(Getattr(n, "sym:name")), Len(coll)); int num_braces = 0; bool test = (num_arguments > 0); if (test) { int need_v = 1; j = 0; Parm *pj = pi; while (pj) { if (checkAttribute(pj, "tmap:in:numinputs", "0")) { pj = Getattr(pj, "tmap:in:next"); continue; } String *tm = Getattr(pj, "tmap:typecheck"); if (tm) { /* normalise for comparison later */ Replaceid(tm, Getattr(pj, "lname"), "_v"); /* if all the wrappers have the same type check on this argument we can optimize it out */ for (int k = 0; k < Len(coll) && !emitcheck; k++) { Node *nk = Getitem(coll, k); Parm *pk = Getattr(nk, "wrap:parms"); int nak = emit_num_arguments(pk); if (nak <= j) continue; int l = 0; Parm *pl = pk; /* finds arg j on the collider wrapper */ while (pl && l <= j) { if (checkAttribute(pl, "tmap:in:numinputs", "0")) { pl = Getattr(pl, "tmap:in:next"); continue; } if (l == j) { /* we are at arg j, so we compare the tmaps now */ String *tml = Getattr(pl, "tmap:typecheck"); /* normalise it before comparing */ if (tml) Replaceid(tml, Getattr(pl, "lname"), "_v"); if (!tml || Cmp(tm, tml)) emitcheck = 1; //printf("tmap: %s[%d] (%d) => %s\n\n", // Char(Getattr(nk, "sym:name")), // l, emitcheck, tml?Char(tml):0); } Parm *pl1 = Getattr(pl, "tmap:in:next"); if (pl1) pl = pl1; else pl = nextSibling(pl); l++; } } if (emitcheck) { if (need_v) { Printf(f, "int _v = 0;\n"); need_v = 0; } if (j >= num_required) { Printf(f, "if (%s > %d) {\n", argc_template_string, j); num_braces++; } String *tmp = NewStringf(argv_template_string, j); String *conv = Getattr(pj, "implicitconv"); if (conv) { Replaceall(tm, "$implicitconv", conv); } else { Replaceall(tm, "$implicitconv", "0"); } Replaceall(tm, "$input", tmp); Printv(f, "{\n", tm, "}\n", NIL); fn = i + 1; Printf(f, "if (!_v) goto check_%d;\n", fn); Printf(f, "_ranki += _v*_pi;\n"); Printf(f, "_rankm += _pi;\n"); Printf(f, "_pi *= SWIG_MAXCASTRANK;\n"); } } if (!Getattr(pj, "tmap:in:SWIGTYPE") && Getattr(pj, "tmap:typecheck:SWIGTYPE")) { /* we emit a warning if the argument defines the 'in' typemap, but not the 'typecheck' one */ Swig_warning(WARN_TYPEMAP_TYPECHECK_UNDEF, Getfile(ni), Getline(ni), "Overloaded method %s with no explicit typecheck typemap for arg %d of type '%s'\n", Swig_name_decl(n), j, SwigType_str(Getattr(pj, "type"), 0)); } Parm *pj1 = Getattr(pj, "tmap:in:next"); if (pj1) pj = pj1; else pj = nextSibling(pj); j++; } } /* close braces */ for ( /* empty */ ; num_braces > 0; num_braces--) Printf(f, "}\n"); Printf(f, "if (!_index || (_ranki < _rank)) {\n"); Printf(f, " _rank = _ranki; _index = %d;\n", i + 1); Printf(f, " if (_rank == _rankm) goto dispatch;\n"); Printf(f, "}\n"); String *lfmt = ReplaceFormat(fmt, num_arguments); Printf(sw, "case %d:\n", i + 1); Printf(sw, Char(lfmt), Getattr(ni, "wrap:name")); Printf(sw, "\n"); Printf(f, "}\n"); /* braces closes "if" for this method */ if (fn) Printf(f, "check_%d:\n\n", fn); Delete(lfmt); Delete(coll); } Delete(dispatch); Printf(f, "dispatch:\n"); Printf(f, "switch(_index) {\n"); Printf(f, "%s", sw); Printf(f, "}\n"); Printf(f, "}\n"); return f; } /* Fast dispatch mechanism, provided by Salvador Fandi~no Garc'ia (#930586). */ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *maxargs) { int i, j; *maxargs = 1; String *f = NewString(""); /* Get a list of methods ranked by precedence values and argument count */ List *dispatch = Swig_overload_rank(n, true); int nfunc = Len(dispatch); /* Loop over the functions */ for (i = 0; i < nfunc; i++) { int fn = 0; Node *ni = Getitem(dispatch, i); Parm *pi = Getattr(ni, "wrap:parms"); int num_required = emit_num_required(pi); int num_arguments = emit_num_arguments(pi); if (num_arguments > *maxargs) *maxargs = num_arguments; if (num_required == num_arguments) { Printf(f, "if (%s == %d) {\n", argc_template_string, num_required); } else { Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments); } /* create a list with the wrappers that collide with the current one based on argument number */ List *coll = NewList(); for (int k = i + 1; k < nfunc; k++) { Node *nk = Getitem(dispatch, k); Parm *pk = Getattr(nk, "wrap:parms"); int nrk = emit_num_required(pk); int nak = emit_num_arguments(pk); if ((nrk >= num_required && nrk <= num_arguments) || (nak >= num_required && nak <= num_arguments) || (nrk <= num_required && nak >= num_arguments)) Append(coll, nk); } // printf("overload: %s coll=%d\n", Char(Getattr(n, "sym:name")), Len(coll)); int num_braces = 0; bool test = (Len(coll) > 0 && num_arguments); if (test) { int need_v = 1; j = 0; Parm *pj = pi; while (pj) { if (checkAttribute(pj, "tmap:in:numinputs", "0")) { pj = Getattr(pj, "tmap:in:next"); continue; } String *tm = Getattr(pj, "tmap:typecheck"); if (tm) { /* normalise for comparison later */ Replaceid(tm, Getattr(pj, "lname"), "_v"); /* if all the wrappers have the same type check on this argument we can optimize it out */ bool emitcheck = 0; for (int k = 0; k < Len(coll) && !emitcheck; k++) { Node *nk = Getitem(coll, k); Parm *pk = Getattr(nk, "wrap:parms"); int nak = emit_num_arguments(pk); if (nak <= j) continue; int l = 0; Parm *pl = pk; /* finds arg j on the collider wrapper */ while (pl && l <= j) { if (checkAttribute(pl, "tmap:in:numinputs", "0")) { pl = Getattr(pl, "tmap:in:next"); continue; } if (l == j) { /* we are at arg j, so we compare the tmaps now */ String *tml = Getattr(pl, "tmap:typecheck"); /* normalise it before comparing */ if (tml) Replaceid(tml, Getattr(pl, "lname"), "_v"); if (!tml || Cmp(tm, tml)) emitcheck = 1; //printf("tmap: %s[%d] (%d) => %s\n\n", // Char(Getattr(nk, "sym:name")), // l, emitcheck, tml?Char(tml):0); } Parm *pl1 = Getattr(pl, "tmap:in:next"); if (pl1) pl = pl1; else pl = nextSibling(pl); l++; } } if (emitcheck) { if (need_v) { Printf(f, "int _v = 0;\n"); need_v = 0; } if (j >= num_required) { Printf(f, "if (%s > %d) {\n", argc_template_string, j); num_braces++; } String *tmp = NewStringf(argv_template_string, j); String *conv = Getattr(pj, "implicitconv"); if (conv) { Replaceall(tm, "$implicitconv", conv); } else { Replaceall(tm, "$implicitconv", "0"); } Replaceall(tm, "$input", tmp); Printv(f, "{\n", tm, "}\n", NIL); fn = i + 1; Printf(f, "if (!_v) goto check_%d;\n", fn); } } if (!Getattr(pj, "tmap:in:SWIGTYPE") && Getattr(pj, "tmap:typecheck:SWIGTYPE")) { /* we emit a warning if the argument defines the 'in' typemap, but not the 'typecheck' one */ Swig_warning(WARN_TYPEMAP_TYPECHECK_UNDEF, Getfile(ni), Getline(ni), "Overloaded method %s with no explicit typecheck typemap for arg %d of type '%s'\n", Swig_name_decl(n), j, SwigType_str(Getattr(pj, "type"), 0)); } Parm *pj1 = Getattr(pj, "tmap:in:next"); if (pj1) pj = pj1; else pj = nextSibling(pj); j++; } } /* close braces */ for ( /* empty */ ; num_braces > 0; num_braces--) Printf(f, "}\n"); String *lfmt = ReplaceFormat(fmt, num_arguments); Printf(f, Char(lfmt), Getattr(ni, "wrap:name")); Printf(f, "}\n"); /* braces closes "if" for this method */ if (fn) Printf(f, "check_%d:\n\n", fn); Delete(lfmt); Delete(coll); } Delete(dispatch); return f; } String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxargs) { if (fast_dispatch_mode || GetFlag(n, "feature:fastdispatch")) { return Swig_overload_dispatch_fast(n, fmt, maxargs); } int i, j; *maxargs = 1; String *f = NewString(""); /* Get a list of methods ranked by precedence values and argument count */ List *dispatch = Swig_overload_rank(n, true); int nfunc = Len(dispatch); /* Loop over the functions */ for (i = 0; i < nfunc; i++) { Node *ni = Getitem(dispatch, i); Parm *pi = Getattr(ni, "wrap:parms"); bool implicitconvtypecheckoff = GetFlag(ni, "implicitconvtypecheckoff") != 0; int num_required = emit_num_required(pi); int num_arguments = emit_num_arguments(pi); if (GetFlag(n, "wrap:this")) { num_required++; num_arguments++; } if (num_arguments > *maxargs) *maxargs = num_arguments; if (num_required == num_arguments) { Printf(f, "if (%s == %d) {\n", argc_template_string, num_required); } else { Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments); } if (num_arguments) { Printf(f, "int _v;\n"); } int num_braces = 0; j = 0; Parm *pj = pi; while (pj) { if (checkAttribute(pj, "tmap:in:numinputs", "0")) { pj = Getattr(pj, "tmap:in:next"); continue; } if (j >= num_required) { String *lfmt = ReplaceFormat(fmt, num_arguments); Printf(f, "if (%s <= %d) {\n", argc_template_string, j); Printf(f, Char(lfmt), Getattr(ni, "wrap:name")); Printf(f, "}\n"); Delete(lfmt); } if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj, implicitconvtypecheckoff)) { Printf(f, "if (_v) {\n"); num_braces++; } if (!Getattr(pj, "tmap:in:SWIGTYPE") && Getattr(pj, "tmap:typecheck:SWIGTYPE")) { /* we emit a warning if the argument defines the 'in' typemap, but not the 'typecheck' one */ Swig_warning(WARN_TYPEMAP_TYPECHECK_UNDEF, Getfile(ni), Getline(ni), "Overloaded method %s with no explicit typecheck typemap for arg %d of type '%s'\n", Swig_name_decl(n), j, SwigType_str(Getattr(pj, "type"), 0)); } Parm *pk = Getattr(pj, "tmap:in:next"); if (pk) pj = pk; else pj = nextSibling(pj); j++; } String *lfmt = ReplaceFormat(fmt, num_arguments); Printf(f, Char(lfmt), Getattr(ni, "wrap:name")); Delete(lfmt); /* close braces */ for ( /* empty */ ; num_braces > 0; num_braces--) Printf(f, "}\n"); Printf(f, "}\n"); /* braces closes "if" for this method */ if (implicitconvtypecheckoff) Delattr(ni, "implicitconvtypecheckoff"); } Delete(dispatch); return f; } /* ----------------------------------------------------------------------------- * Swig_overload_check() * ----------------------------------------------------------------------------- */ void Swig_overload_check(Node *n) { Swig_overload_rank(n, false); } swig-3.0.2/Source/Modules/allocate.cxx0000664000175000017500000007367212343605122017542 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * allocate.cxx * * This module tries to figure out which classes and structures support * default constructors and destructors in C++. There are several rules that * define this behavior including pure abstract methods, private sections, * and non-default constructors in base classes. See the ARM or * Doc/Manual/SWIGPlus.html for details. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" static int virtual_elimination_mode = 0; /* set to 0 on default */ /* Set virtual_elimination_mode */ void Wrapper_virtual_elimination_mode_set(int flag) { virtual_elimination_mode = flag; } /* Helper function to assist with abstract class checking. This is a major hack. Sorry. */ extern "C" { static String *search_decl = 0; /* Declarator being searched */ static int check_implemented(Node *n) { String *decl; if (!n) return 0; while (n) { if (Strcmp(nodeType(n), "cdecl") == 0) { decl = Getattr(n, "decl"); if (SwigType_isfunction(decl)) { SwigType *decl1 = SwigType_typedef_resolve_all(decl); SwigType *decl2 = SwigType_pop_function(decl1); if (Strcmp(decl2, search_decl) == 0) { if (!GetFlag(n, "abstract")) { Delete(decl1); Delete(decl2); return 1; } } Delete(decl1); Delete(decl2); } } n = Getattr(n, "csym:nextSibling"); } return 0; } } class Allocate:public Dispatcher { Node *inclass; int extendmode; /* Checks if a function, n, is the same as any in the base class, ie if the method is polymorphic. * Also checks for methods which will be hidden (ie a base has an identical non-virtual method). * Both methods must have public access for a match to occur. */ int function_is_defined_in_bases(Node *n, Node *bases) { if (!bases) return 0; String *this_decl = Getattr(n, "decl"); if (!this_decl) return 0; String *name = Getattr(n, "name"); String *this_type = Getattr(n, "type"); String *resolved_decl = SwigType_typedef_resolve_all(this_decl); // Search all base classes for methods with same signature for (int i = 0; i < Len(bases); i++) { Node *b = Getitem(bases, i); Node *base = firstChild(b); while (base) { if (Strcmp(nodeType(base), "extend") == 0) { // Loop through all the %extend methods Node *extend = firstChild(base); while (extend) { if (function_is_defined_in_bases_seek(n, b, extend, this_decl, name, this_type, resolved_decl)) { Delete(resolved_decl); return 1; } extend = nextSibling(extend); } } else if (Strcmp(nodeType(base), "using") == 0) { // Loop through all the using declaration methods Node *usingdecl = firstChild(base); while (usingdecl) { if (function_is_defined_in_bases_seek(n, b, usingdecl, this_decl, name, this_type, resolved_decl)) { Delete(resolved_decl); return 1; } usingdecl = nextSibling(usingdecl); } } else { // normal methods if (function_is_defined_in_bases_seek(n, b, base, this_decl, name, this_type, resolved_decl)) { Delete(resolved_decl); return 1; } } base = nextSibling(base); } } Delete(resolved_decl); resolved_decl = 0; for (int j = 0; j < Len(bases); j++) { Node *b = Getitem(bases, j); if (function_is_defined_in_bases(n, Getattr(b, "allbases"))) return 1; } return 0; } /* Helper function for function_is_defined_in_bases */ int function_is_defined_in_bases_seek(Node *n, Node *b, Node *base, String *this_decl, String *name, String *this_type, String *resolved_decl) { String *base_decl = Getattr(base, "decl"); SwigType *base_type = Getattr(base, "type"); if (base_decl && base_type) { if (checkAttribute(base, "name", name) && !GetFlag(b, "feature:ignore") /* whole class is ignored */ ) { if (SwigType_isfunction(resolved_decl) && SwigType_isfunction(base_decl)) { // We have found a method that has the same name as one in a base class bool covariant_returntype = false; bool returntype_match = Strcmp(base_type, this_type) == 0 ? true : false; bool decl_match = Strcmp(base_decl, this_decl) == 0 ? true : false; if (returntype_match && decl_match) { // Exact match - we have found a method with identical signature // No typedef resolution was done, but skipping it speeds things up slightly } else { // Either we have: // 1) matching methods but are one of them uses a different typedef (return type or parameter) to the one in base class' method // 2) matching polymorphic methods with covariant return type // 3) a non-matching method (ie an overloaded method of some sort) // 4) a matching method which is not polymorphic, ie it hides the base class' method // Check if fully resolved return types match (including // covariant return types) if (!returntype_match) { String *this_returntype = function_return_type(n); String *base_returntype = function_return_type(base); returntype_match = Strcmp(this_returntype, base_returntype) == 0 ? true : false; if (!returntype_match) { covariant_returntype = SwigType_issubtype(this_returntype, base_returntype) ? true : false; returntype_match = covariant_returntype; } Delete(this_returntype); Delete(base_returntype); } // The return types must match at this point, for the whole method to match if (returntype_match && !decl_match) { // Now need to check the parameter list // First do an inexpensive parameter count ParmList *this_parms = Getattr(n, "parms"); ParmList *base_parms = Getattr(base, "parms"); if (ParmList_len(this_parms) == ParmList_len(base_parms)) { // Number of parameters are the same, now check that all the parameters match SwigType *base_fn = NewString(""); SwigType *this_fn = NewString(""); SwigType_add_function(base_fn, base_parms); SwigType_add_function(this_fn, this_parms); base_fn = SwigType_typedef_resolve_all(base_fn); this_fn = SwigType_typedef_resolve_all(this_fn); if (Strcmp(base_fn, this_fn) == 0) { // Finally check that the qualifiers match int base_qualifier = SwigType_isqualifier(resolved_decl); int this_qualifier = SwigType_isqualifier(base_decl); if (base_qualifier == this_qualifier) { decl_match = true; } } Delete(base_fn); Delete(this_fn); } } } //Printf(stderr,"look %s %s %d %d\n",base_decl, this_decl, returntype_match, decl_match); if (decl_match && returntype_match) { // Found an identical method in the base class bool this_wrapping_protected_members = is_member_director(n) ? true : false; // This should really check for dirprot rather than just being a director method bool base_wrapping_protected_members = is_member_director(base) ? true : false; // This should really check for dirprot rather than just being a director method bool both_have_public_access = is_public(n) && is_public(base); bool both_have_protected_access = (is_protected(n) && this_wrapping_protected_members) && (is_protected(base) && base_wrapping_protected_members); bool both_have_private_access = is_private(n) && is_private(base); if (checkAttribute(base, "storage", "virtual")) { // Found a polymorphic method. // Mark the polymorphic method, in case the virtual keyword was not used. Setattr(n, "storage", "virtual"); if (both_have_public_access || both_have_protected_access) { if (!is_non_public_base(inclass, b)) Setattr(n, "override", base); // Note C# definition of override, ie access must be the same } else if (!both_have_private_access) { // Different access if (this_wrapping_protected_members || base_wrapping_protected_members) if (!is_non_public_base(inclass, b)) Setattr(n, "hides", base); // Note C# definition of hiding, ie hidden if access is different } // Try and find the most base's covariant return type SwigType *most_base_covariant_type = Getattr(base, "covariant"); if (!most_base_covariant_type && covariant_returntype) most_base_covariant_type = function_return_type(base, false); if (!most_base_covariant_type) { // Eliminate the derived virtual method. if (virtual_elimination_mode && !is_member_director(n)) if (both_have_public_access) if (!is_non_public_base(inclass, b)) if (!Swig_symbol_isoverloaded(n)) { // Don't eliminate if an overloaded method as this hides the method // in the scripting languages: the dispatch function will hide the base method if ignored. SetFlag(n, "feature:ignore"); } } else { // Some languages need to know about covariant return types Setattr(n, "covariant", most_base_covariant_type); } } else { // Found an identical method in the base class, but it is not polymorphic. if (both_have_public_access || both_have_protected_access) if (!is_non_public_base(inclass, b)) Setattr(n, "hides", base); } if (both_have_public_access || both_have_protected_access) return 1; } } } } return 0; } /* Determines whether the base class, b, is in the list of private * or protected base classes for class n. */ bool is_non_public_base(Node *n, Node *b) { bool non_public_base = false; Node *bases = Getattr(n, "privatebases"); if (bases) { for (int i = 0; i < Len(bases); i++) { Node *base = Getitem(bases, i); if (base == b) non_public_base = true; } } bases = Getattr(n, "protectedbases"); if (bases) { for (int i = 0; i < Len(bases); i++) { Node *base = Getitem(bases, i); if (base == b) non_public_base = true; } } return non_public_base; } /* Returns the return type for a function. The node n should be a function. If resolve is true the fully returned type is fully resolved. Caller is responsible for deleting returned string. */ String *function_return_type(Node *n, bool resolve = true) { String *decl = Getattr(n, "decl"); SwigType *type = Getattr(n, "type"); String *ty = NewString(type); SwigType_push(ty, decl); if (SwigType_isqualifier(ty)) Delete(SwigType_pop(ty)); Delete(SwigType_pop_function(ty)); if (resolve) { String *unresolved = ty; ty = SwigType_typedef_resolve_all(unresolved); Delete(unresolved); } return ty; } /* Checks if a class member is the same as inherited from the class bases */ int class_member_is_defined_in_bases(Node *member, Node *classnode) { Node *bases; /* bases is the closest ancestors of classnode */ int defined = 0; bases = Getattr(classnode, "allbases"); if (!bases) return 0; { int old_mode = virtual_elimination_mode; if (is_member_director(classnode, member)) virtual_elimination_mode = 0; if (function_is_defined_in_bases(member, bases)) { defined = 1; } virtual_elimination_mode = old_mode; } if (defined) return 1; else return 0; } /* Checks to see if a class is abstract through inheritance, and saves the first node that seems to be abstract. */ int is_abstract_inherit(Node *n, Node *base = 0, int first = 0) { if (!first && (base == n)) return 0; if (!base) { /* Root node */ Symtab *stab = Getattr(n, "symtab"); /* Get symbol table for node */ Symtab *oldtab = Swig_symbol_setscope(stab); int ret = is_abstract_inherit(n, n, 1); Swig_symbol_setscope(oldtab); return ret; } List *abstracts = Getattr(base, "abstracts"); if (abstracts) { int dabstract = 0; int len = Len(abstracts); for (int i = 0; i < len; i++) { Node *nn = Getitem(abstracts, i); String *name = Getattr(nn, "name"); if (!name) continue; if (Strchr(name, '~')) continue; /* Don't care about destructors */ String *base_decl = Getattr(nn, "decl"); if (base_decl) base_decl = SwigType_typedef_resolve_all(base_decl); if (SwigType_isfunction(base_decl)) search_decl = SwigType_pop_function(base_decl); Node *dn = Swig_symbol_clookup_local_check(name, 0, check_implemented); Delete(search_decl); Delete(base_decl); if (!dn) { List *nabstracts = Getattr(n, "abstracts"); if (!nabstracts) { nabstracts = NewList(); Setattr(n, "abstracts", nabstracts); Delete(nabstracts); } Append(nabstracts, nn); if (!Getattr(n, "abstracts:firstnode")) { Setattr(n, "abstracts:firstnode", nn); } dabstract = base != n; } } if (dabstract) return 1; } List *bases = Getattr(base, "allbases"); if (!bases) return 0; for (int i = 0; i < Len(bases); i++) { if (is_abstract_inherit(n, Getitem(bases, i))) { return 1; } } return 0; } /* Grab methods used by smart pointers */ List *smart_pointer_methods(Node *cls, List *methods, int isconst, String *classname = 0) { if (!methods) { methods = NewList(); } Node *c = firstChild(cls); while (c) { if (Getattr(c, "error") || GetFlag(c, "feature:ignore")) { c = nextSibling(c); continue; } if (!isconst && (Strcmp(nodeType(c), "extend") == 0)) { methods = smart_pointer_methods(c, methods, isconst, Getattr(cls, "name")); } else if (Strcmp(nodeType(c), "cdecl") == 0) { if (!GetFlag(c, "feature:ignore")) { String *storage = Getattr(c, "storage"); if (!((Cmp(storage, "typedef") == 0)) && !((Cmp(storage, "friend") == 0))) { String *name = Getattr(c, "name"); String *symname = Getattr(c, "sym:name"); Node *e = Swig_symbol_clookup_local(name, 0); if (e && is_public(e) && !GetFlag(e, "feature:ignore") && (Cmp(symname, Getattr(e, "sym:name")) == 0)) { Swig_warning(WARN_LANG_DEREF_SHADOW, Getfile(e), Getline(e), "Declaration of '%s' shadows declaration accessible via operator->(),\n", name); Swig_warning(WARN_LANG_DEREF_SHADOW, Getfile(c), Getline(c), "previous declaration of '%s'.\n", name); } else { /* Make sure node with same name doesn't already exist */ int k; int match = 0; for (k = 0; k < Len(methods); k++) { e = Getitem(methods, k); if (Cmp(symname, Getattr(e, "sym:name")) == 0) { match = 1; break; } if (!Getattr(e, "sym:name") && (Cmp(name, Getattr(e, "name")) == 0)) { match = 1; break; } } if (!match) { Node *cc = c; while (cc) { Node *cp = cc; if (classname) { Setattr(cp, "extendsmartclassname", classname); } Setattr(cp, "allocate:smartpointeraccess", "1"); /* If constant, we have to be careful */ if (isconst) { SwigType *decl = Getattr(cp, "decl"); if (decl) { if (SwigType_isfunction(decl)) { /* If method, we only add if it's a const method */ if (SwigType_isconst(decl)) { Append(methods, cp); } } else { Append(methods, cp); } } else { Append(methods, cp); } } else { Append(methods, cp); } cc = Getattr(cc, "sym:nextSibling"); } } } } } } c = nextSibling(c); } /* Look for methods in base classes */ { Node *bases = Getattr(cls, "bases"); int k; for (k = 0; k < Len(bases); k++) { smart_pointer_methods(Getitem(bases, k), methods, isconst); } } /* Remove protected/private members */ { for (int i = 0; i < Len(methods);) { Node *n = Getitem(methods, i); if (!is_public(n)) { Delitem(methods, i); continue; } i++; } } return methods; } void mark_exception_classes(ParmList *p) { while (p) { SwigType *ty = Getattr(p, "type"); SwigType *t = SwigType_typedef_resolve_all(ty); if (SwigType_isreference(t) || SwigType_ispointer(t) || SwigType_isarray(t)) { Delete(SwigType_pop(t)); } Node *c = Swig_symbol_clookup(t, 0); if (c) { if (!GetFlag(c, "feature:exceptionclass")) { SetFlag(c, "feature:exceptionclass"); } } p = nextSibling(p); Delete(t); } } void process_exceptions(Node *n) { ParmList *catchlist = 0; /* the "catchlist" attribute is used to emit the block try {$action;} catch ; in emit.cxx and is either constructued from the "feature:catches" feature or copied from the node "throws" list. */ String *scatchlist = Getattr(n, "feature:catches"); if (scatchlist) { catchlist = Swig_cparse_parms(scatchlist, n); if (catchlist) { Setattr(n, "catchlist", catchlist); mark_exception_classes(catchlist); Delete(catchlist); } } ParmList *throws = Getattr(n, "throws"); if (throws) { /* if there is no explicit catchlist, we catch everything in the throws list */ if (!catchlist) { Setattr(n, "catchlist", throws); } mark_exception_classes(throws); } } public: Allocate(): inclass(NULL), extendmode(0) { } virtual int top(Node *n) { cplus_mode = PUBLIC; inclass = 0; extendmode = 0; emit_children(n); return SWIG_OK; } virtual int importDirective(Node *n) { return emit_children(n); } virtual int includeDirective(Node *n) { return emit_children(n); } virtual int externDeclaration(Node *n) { return emit_children(n); } virtual int namespaceDeclaration(Node *n) { return emit_children(n); } virtual int extendDirective(Node *n) { extendmode = 1; emit_children(n); extendmode = 0; return SWIG_OK; } virtual int classDeclaration(Node *n) { Symtab *symtab = Swig_symbol_current(); Swig_symbol_setscope(Getattr(n, "symtab")); save_value oldInclass(inclass); save_value oldAcessMode(cplus_mode); save_value oldExtendMode(extendmode); if (Getattr(n, "template")) extendmode = 0; if (!CPlusPlus) { /* Always have default constructors/destructors in C */ Setattr(n, "allocate:default_constructor", "1"); Setattr(n, "allocate:default_destructor", "1"); } if (Getattr(n, "allocate:visit")) return SWIG_OK; Setattr(n, "allocate:visit", "1"); /* Always visit base classes first */ { List *bases = Getattr(n, "bases"); if (bases) { for (int i = 0; i < Len(bases); i++) { Node *b = Getitem(bases, i); classDeclaration(b); } } } inclass = n; String *kind = Getattr(n, "kind"); if (Strcmp(kind, "class") == 0) { cplus_mode = PRIVATE; } else { cplus_mode = PUBLIC; } emit_children(n); /* Check if the class is abstract via inheritance. This might occur if a class didn't have any pure virtual methods of its own, but it didn't implement all of the pure methods in a base class */ if (!Getattr(n, "abstracts") && is_abstract_inherit(n)) { if (((Getattr(n, "allocate:public_constructor") || (!GetFlag(n, "feature:nodefault") && !Getattr(n, "allocate:has_constructor"))))) { if (!GetFlag(n, "feature:notabstract")) { Node *na = Getattr(n, "abstracts:firstnode"); if (na) { Swig_warning(WARN_TYPE_ABSTRACT, Getfile(n), Getline(n), "Class '%s' might be abstract, " "no constructors generated,\n", SwigType_namestr(Getattr(n, "name"))); Swig_warning(WARN_TYPE_ABSTRACT, Getfile(na), Getline(na), "Method %s might not be implemented.\n", Swig_name_decl(na)); if (!Getattr(n, "abstracts")) { List *abstracts = NewList(); Append(abstracts, na); Setattr(n, "abstracts", abstracts); Delete(abstracts); } } } } } if (!Getattr(n, "allocate:has_constructor")) { /* No constructor is defined. We need to check a few things */ /* If class is abstract. No default constructor. Sorry */ if (Getattr(n, "abstracts")) { Delattr(n, "allocate:default_constructor"); } if (!Getattr(n, "allocate:default_constructor")) { /* Check base classes */ List *bases = Getattr(n, "allbases"); int allows_default = 1; for (int i = 0; i < Len(bases); i++) { Node *n = Getitem(bases, i); /* If base class does not allow default constructor, we don't allow it either */ if (!Getattr(n, "allocate:default_constructor") && (!Getattr(n, "allocate:default_base_constructor"))) { allows_default = 0; } } if (allows_default) { Setattr(n, "allocate:default_constructor", "1"); } } } if (!Getattr(n, "allocate:has_copy_constructor")) { if (Getattr(n, "abstracts")) { Delattr(n, "allocate:copy_constructor"); } if (!Getattr(n, "allocate:copy_constructor")) { /* Check base classes */ List *bases = Getattr(n, "allbases"); int allows_copy = 1; for (int i = 0; i < Len(bases); i++) { Node *n = Getitem(bases, i); /* If base class does not allow copy constructor, we don't allow it either */ if (!Getattr(n, "allocate:copy_constructor") && (!Getattr(n, "allocate:copy_base_constructor"))) { allows_copy = 0; } } if (allows_copy) { Setattr(n, "allocate:copy_constructor", "1"); } } } if (!Getattr(n, "allocate:has_destructor")) { /* No destructor was defined */ List *bases = Getattr(n, "allbases"); int allows_destruct = 1; for (int i = 0; i < Len(bases); i++) { Node *n = Getitem(bases, i); /* If base class does not allow default destructor, we don't allow it either */ if (!Getattr(n, "allocate:default_destructor") && (!Getattr(n, "allocate:default_base_destructor"))) { allows_destruct = 0; } } if (allows_destruct) { Setattr(n, "allocate:default_destructor", "1"); } } if (!Getattr(n, "allocate:has_assign")) { /* No assignment operator was defined */ List *bases = Getattr(n, "allbases"); int allows_assign = 1; for (int i = 0; i < Len(bases); i++) { Node *n = Getitem(bases, i); /* If base class does not allow assignment, we don't allow it either */ if (Getattr(n, "allocate:has_assign")) { allows_assign = !Getattr(n, "allocate:noassign"); } } if (!allows_assign) { Setattr(n, "allocate:noassign", "1"); } } if (!Getattr(n, "allocate:has_new")) { /* No new operator was defined */ List *bases = Getattr(n, "allbases"); int allows_new = 1; for (int i = 0; i < Len(bases); i++) { Node *n = Getitem(bases, i); /* If base class does not allow new operator, we don't allow it either */ if (Getattr(n, "allocate:has_new")) { allows_new = !Getattr(n, "allocate:nonew"); } } if (!allows_new) { Setattr(n, "allocate:nonew", "1"); } } /* Check if base classes allow smart pointers, but might be hidden */ if (!Getattr(n, "allocate:smartpointer")) { Node *sp = Swig_symbol_clookup("operator ->", 0); if (sp) { /* Look for parent */ Node *p = parentNode(sp); if (Strcmp(nodeType(p), "extend") == 0) { p = parentNode(p); } if (Strcmp(nodeType(p), "class") == 0) { if (GetFlag(p, "feature:ignore")) { Setattr(n, "allocate:smartpointer", Getattr(p, "allocate:smartpointer")); } } } } /* Only care about default behavior. Remove temporary values */ Setattr(n, "allocate:visit", "1"); Swig_symbol_setscope(symtab); return SWIG_OK; } virtual int accessDeclaration(Node *n) { String *kind = Getattr(n, "kind"); if (Cmp(kind, "public") == 0) { cplus_mode = PUBLIC; } else if (Cmp(kind, "private") == 0) { cplus_mode = PRIVATE; } else if (Cmp(kind, "protected") == 0) { cplus_mode = PROTECTED; } return SWIG_OK; } virtual int usingDeclaration(Node *n) { Node *c = 0; for (c = firstChild(n); c; c = nextSibling(c)) { if (Strcmp(nodeType(c), "cdecl") == 0) { process_exceptions(c); if (inclass) class_member_is_defined_in_bases(c, inclass); } } return SWIG_OK; } virtual int cDeclaration(Node *n) { process_exceptions(n); if (inclass) { /* check whether the member node n is defined in class node in class's bases */ class_member_is_defined_in_bases(n, inclass); /* Check to see if this is a static member or not. If so, we add an attribute cplus:staticbase that saves the current class */ if (Swig_storage_isstatic(n)) { Setattr(n, "cplus:staticbase", inclass); } String *name = Getattr(n, "name"); if (cplus_mode != PUBLIC) { if (Strcmp(name, "operator =") == 0) { /* Look for a private assignment operator */ if (!GetFlag(n, "deleted")) Setattr(inclass, "allocate:has_assign", "1"); Setattr(inclass, "allocate:noassign", "1"); } else if (Strcmp(name, "operator new") == 0) { /* Look for a private new operator */ if (!GetFlag(n, "deleted")) Setattr(inclass, "allocate:has_new", "1"); Setattr(inclass, "allocate:nonew", "1"); } } else { if (Strcmp(name, "operator =") == 0) { if (!GetFlag(n, "deleted")) Setattr(inclass, "allocate:has_assign", "1"); else Setattr(inclass, "allocate:noassign", "1"); } else if (Strcmp(name, "operator new") == 0) { if (!GetFlag(n, "deleted")) Setattr(inclass, "allocate:has_new", "1"); else Setattr(inclass, "allocate:nonew", "1"); } /* Look for smart pointer operator */ if ((Strcmp(name, "operator ->") == 0) && (!GetFlag(n, "feature:ignore"))) { /* Look for version with no parameters */ Node *sn = n; while (sn) { if (!Getattr(sn, "parms")) { SwigType *type = SwigType_typedef_resolve_all(Getattr(sn, "type")); SwigType_push(type, Getattr(sn, "decl")); Delete(SwigType_pop_function(type)); SwigType *base = SwigType_base(type); Node *sc = Swig_symbol_clookup(base, 0); if ((sc) && (Strcmp(nodeType(sc), "class") == 0)) { if (SwigType_check_decl(type, "p.")) { /* Need to check if type is a const pointer */ int isconst = 0; Delete(SwigType_pop(type)); if (SwigType_isconst(type)) { isconst = !Getattr(inclass, "allocate:smartpointermutable"); Setattr(inclass, "allocate:smartpointerconst", "1"); } else { Setattr(inclass, "allocate:smartpointermutable", "1"); } List *methods = smart_pointer_methods(sc, 0, isconst); Setattr(inclass, "allocate:smartpointer", methods); Setattr(inclass, "allocate:smartpointerpointeeclassname", Getattr(sc, "name")); } else { /* Hmmm. The return value is not a pointer. If the type is a value or reference. We're going to chase it to see if another operator->() can be found */ if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) { Node *nn = Swig_symbol_clookup("operator ->", Getattr(sc, "symtab")); if (nn) { Delete(base); Delete(type); sn = nn; continue; } } } } Delete(base); Delete(type); break; } } } } } return SWIG_OK; } virtual int constructorDeclaration(Node *n) { if (!inclass) return SWIG_OK; Parm *parms = Getattr(n, "parms"); process_exceptions(n); if (!extendmode) { if (!ParmList_numrequired(parms)) { /* Class does define a default constructor */ /* However, we had better see where it is defined */ if (cplus_mode == PUBLIC) { Setattr(inclass, "allocate:default_constructor", "1"); } else if (cplus_mode == PROTECTED) { Setattr(inclass, "allocate:default_base_constructor", "1"); } } /* Class defines some kind of constructor. May or may not be public */ Setattr(inclass, "allocate:has_constructor", "1"); if (cplus_mode == PUBLIC) { Setattr(inclass, "allocate:public_constructor", "1"); } } else { Setattr(inclass, "allocate:has_constructor", "1"); Setattr(inclass, "allocate:public_constructor", "1"); } /* See if this is a copy constructor */ if (parms && (ParmList_numrequired(parms) == 1)) { /* Look for a few cases. X(const X &), X(X &), X(X *) */ int copy_constructor = 0; SwigType *type = Getattr(inclass, "name"); String *tn = NewStringf("r.q(const).%s", type); String *cc = SwigType_typedef_resolve_all(tn); SwigType *rt = SwigType_typedef_resolve_all(Getattr(parms, "type")); if (SwigType_istemplate(type)) { String *tmp = Swig_symbol_template_deftype(cc, 0); Delete(cc); cc = tmp; tmp = Swig_symbol_template_deftype(rt, 0); Delete(rt); rt = tmp; } if (Strcmp(cc, rt) == 0) { copy_constructor = 1; } else { Delete(cc); cc = NewStringf("r.%s", Getattr(inclass, "name")); if (Strcmp(cc, Getattr(parms, "type")) == 0) { copy_constructor = 1; } else { Delete(cc); cc = NewStringf("p.%s", Getattr(inclass, "name")); String *ty = SwigType_strip_qualifiers(Getattr(parms, "type")); if (Strcmp(cc, ty) == 0) { copy_constructor = 1; } Delete(ty); } } Delete(cc); Delete(rt); Delete(tn); if (copy_constructor) { Setattr(n, "copy_constructor", "1"); Setattr(inclass, "allocate:has_copy_constructor", "1"); if (cplus_mode == PUBLIC) { Setattr(inclass, "allocate:copy_constructor", "1"); } else if (cplus_mode == PROTECTED) { Setattr(inclass, "allocate:copy_base_constructor", "1"); } } } return SWIG_OK; } virtual int destructorDeclaration(Node *n) { (void) n; if (!inclass) return SWIG_OK; if (!extendmode) { Setattr(inclass, "allocate:has_destructor", "1"); if (cplus_mode == PUBLIC) { Setattr(inclass, "allocate:default_destructor", "1"); } else if (cplus_mode == PROTECTED) { Setattr(inclass, "allocate:default_base_destructor", "1"); } } else { Setattr(inclass, "allocate:has_destructor", "1"); Setattr(inclass, "allocate:default_destructor", "1"); } return SWIG_OK; } }; void Swig_default_allocators(Node *n) { if (!n) return; Allocate *a = new Allocate; a->top(n); delete a; } swig-3.0.2/Source/Modules/contract.cxx0000664000175000017500000002357312343605122017566 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * contract.cxx * * Support for Wrap by Contract in SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" /* Contract structure. This holds rules about the different kinds of contract sections and their combination rules */ struct contract { const char *section; const char *combiner; }; /* Contract rules. This table defines what contract sections are recognized as well as how contracts are to combined via inheritance */ static contract Rules[] = { {"require:", "&&"}, {"ensure:", "||"}, {NULL, NULL} }; /* ---------------------------------------------------------------------------- * class Contracts: * * This class defines the functions that need to be used in * "wrap by contract" module. * ------------------------------------------------------------------------- */ class Contracts:public Dispatcher { String *make_expression(String *s, Node *n); void substitute_parms(String *s, ParmList *p, int method); public: Hash *ContractSplit(Node *n); int emit_contract(Node *n, int method); int cDeclaration(Node *n); int constructorDeclaration(Node *n); int externDeclaration(Node *n); int extendDirective(Node *n); int importDirective(Node *n); int includeDirective(Node *n); int namespaceDeclaration(Node *n); int classDeclaration(Node *n); virtual int top(Node *n); }; static int Contract_Mode = 0; /* contract option */ static int InClass = 0; /* Parsing C++ or not */ static int InConstructor = 0; static Node *CurrentClass = 0; /* Set the contract mode, default is 0 (not open) */ /* Normally set in main.cxx, when get the "-contracts" option */ void Swig_contract_mode_set(int flag) { Contract_Mode = flag; } /* Get the contract mode */ int Swig_contract_mode_get() { return Contract_Mode; } /* Apply contracts */ void Swig_contracts(Node *n) { Contracts *a = new Contracts; a->top(n); delete a; } /* Split the whole contract into preassertion, postassertion and others */ Hash *Contracts::ContractSplit(Node *n) { String *contract = Getattr(n, "feature:contract"); Hash *result; if (!contract) return NULL; result = NewHash(); String *current_section = NewString(""); const char *current_section_name = Rules[0].section; List *l = SplitLines(contract); Iterator i; for (i = First(l); i.item; i = Next(i)) { int found = 0; if (Strchr(i.item, '{')) continue; if (Strchr(i.item, '}')) continue; for (int j = 0; Rules[j].section; j++) { if (Strstr(i.item, Rules[j].section)) { if (Len(current_section)) { Setattr(result, current_section_name, current_section); current_section = Getattr(result, Rules[j].section); if (!current_section) current_section = NewString(""); } current_section_name = Rules[j].section; found = 1; break; } } if (!found) Append(current_section, i.item); } if (Len(current_section)) Setattr(result, current_section_name, current_section); return result; } /* This function looks in base classes and collects contracts found */ void inherit_contracts(Node *c, Node *n, Hash *contracts, Hash *messages) { Node *b, *temp; String *name, *type, *local_decl, *base_decl; List *bases; int found = 0; bases = Getattr(c, "bases"); if (!bases) return; name = Getattr(n, "name"); type = Getattr(n, "type"); local_decl = Getattr(n, "decl"); if (local_decl) { local_decl = SwigType_typedef_resolve_all(local_decl); } else { return; } /* Width first search */ for (int i = 0; i < Len(bases); i++) { b = Getitem(bases, i); temp = firstChild(b); while (temp) { base_decl = Getattr(temp, "decl"); if (base_decl) { base_decl = SwigType_typedef_resolve_all(base_decl); if ((checkAttribute(temp, "storage", "virtual")) && (checkAttribute(temp, "name", name)) && (checkAttribute(temp, "type", type)) && (!Strcmp(local_decl, base_decl))) { /* Yes, match found. */ Hash *icontracts = Getattr(temp, "contract:rules"); Hash *imessages = Getattr(temp, "contract:messages"); found = 1; if (icontracts && imessages) { /* Add inherited contracts and messages to the contract rules above */ int j = 0; for (j = 0; Rules[j].section; j++) { String *t = Getattr(contracts, Rules[j].section); String *s = Getattr(icontracts, Rules[j].section); if (s) { if (t) { Insert(t, 0, "("); Printf(t, ") %s (%s)", Rules[j].combiner, s); String *m = Getattr(messages, Rules[j].section); Printf(m, " %s [%s from %s]", Rules[j].combiner, Getattr(imessages, Rules[j].section), Getattr(b, "name")); } else { Setattr(contracts, Rules[j].section, NewString(s)); Setattr(messages, Rules[j].section, NewStringf("[%s from %s]", Getattr(imessages, Rules[j].section), Getattr(b, "name"))); } } } } } Delete(base_decl); } temp = nextSibling(temp); } } Delete(local_decl); if (!found) { for (int j = 0; j < Len(bases); j++) { b = Getitem(bases, j); inherit_contracts(b, n, contracts, messages); } } } /* This function cleans up the assertion string by removing some extraneous characters. Splitting the assertion into pieces */ String *Contracts::make_expression(String *s, Node *n) { String *str_assert, *expr = 0; List *list_assert; str_assert = NewString(s); /* Omit all useless characters and split by ; */ Replaceall(str_assert, "\n", ""); Replaceall(str_assert, "{", ""); Replaceall(str_assert, "}", ""); Replace(str_assert, " ", "", DOH_REPLACE_ANY | DOH_REPLACE_NOQUOTE); Replace(str_assert, "\t", "", DOH_REPLACE_ANY | DOH_REPLACE_NOQUOTE); list_assert = Split(str_assert, ';', -1); Delete(str_assert); /* build up new assertion */ str_assert = NewString(""); Iterator ei; for (ei = First(list_assert); ei.item; ei = Next(ei)) { expr = ei.item; if (Len(expr)) { Replaceid(expr, Getattr(n, "name"), Swig_cresult_name()); if (Len(str_assert)) Append(str_assert, "&&"); Printf(str_assert, "(%s)", expr); } } Delete(list_assert); return str_assert; } /* This function substitutes parameter names for argument names in the contract specification. Note: it is assumed that the wrapper code uses arg1 for self and arg2..argn for arguments. */ void Contracts::substitute_parms(String *s, ParmList *p, int method) { int argnum = 1; char argname[32]; if (method) { Replaceid(s, "$self", "arg1"); argnum++; } while (p) { sprintf(argname, "arg%d", argnum); String *name = Getattr(p, "name"); if (name) { Replaceid(s, name, argname); } argnum++; p = nextSibling(p); } } int Contracts::emit_contract(Node *n, int method) { Hash *contracts; Hash *messages; String *c; ParmList *cparms; if (!Getattr(n, "feature:contract")) return SWIG_ERROR; /* Get contract parameters */ cparms = Getmeta(Getattr(n, "feature:contract"), "parms"); /* Split contract into preassert & postassert */ contracts = ContractSplit(n); if (!contracts) return SWIG_ERROR; /* This messages hash is used to hold the error messages that will be displayed on failed contract. */ messages = NewHash(); /* Take the different contract expressions and clean them up a bit */ Iterator i; for (i = First(contracts); i.item; i = Next(i)) { String *e = make_expression(i.item, n); substitute_parms(e, cparms, method); Setattr(contracts, i.key, e); /* Make a string containing error messages */ Setattr(messages, i.key, NewString(e)); } /* If we're in a class. We need to inherit other assertions. */ if (InClass) { inherit_contracts(CurrentClass, n, contracts, messages); } /* Save information */ Setattr(n, "contract:rules", contracts); Setattr(n, "contract:messages", messages); /* Okay. Generate the contract runtime code. */ if ((c = Getattr(contracts, "require:"))) { Setattr(n, "contract:preassert", NewStringf("SWIG_contract_assert(%s, \"Contract violation: require: %s\");\n", c, Getattr(messages, "require:"))); } if ((c = Getattr(contracts, "ensure:"))) { Setattr(n, "contract:postassert", NewStringf("SWIG_contract_assert(%s, \"Contract violation: ensure: %s\");\n", c, Getattr(messages, "ensure:"))); } return SWIG_OK; } int Contracts::cDeclaration(Node *n) { int ret = SWIG_OK; String *decl = Getattr(n, "decl"); /* Not a function. Don't even bother with it (for now) */ if (!SwigType_isfunction(decl)) return SWIG_OK; if (Getattr(n, "feature:contract")) ret = emit_contract(n, InClass && !Swig_storage_isstatic(n)); return ret; } int Contracts::constructorDeclaration(Node *n) { int ret = SWIG_OK; InConstructor = 1; if (Getattr(n, "feature:contract")) ret = emit_contract(n, 0); InConstructor = 0; return ret; } int Contracts::externDeclaration(Node *n) { return emit_children(n); } int Contracts::extendDirective(Node *n) { return emit_children(n); } int Contracts::importDirective(Node *n) { return emit_children(n); } int Contracts::includeDirective(Node *n) { return emit_children(n); } int Contracts::namespaceDeclaration(Node *n) { return emit_children(n); } int Contracts::classDeclaration(Node *n) { int ret = SWIG_OK; int oldInClass = InClass; Node *oldClass = CurrentClass; InClass = 1; CurrentClass = n; emit_children(n); InClass = oldInClass; CurrentClass = oldClass; return ret; } int Contracts::top(Node *n) { emit_children(n); return SWIG_OK; } swig-3.0.2/Source/Modules/swigmod.h0000664000175000017500000003560012343605122017041 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swigmod.h * * Main header file for SWIG modules. * ----------------------------------------------------------------------------- */ #ifndef SWIG_SWIGMOD_H_ #define SWIG_SWIGMOD_H_ #include "swig.h" #include "preprocessor.h" #include "swigwarn.h" #if !defined(HAVE_BOOL) typedef int bool; #define true ((bool)1) #define false ((bool)0) #endif #define NOT_VIRTUAL 0 #define PLAIN_VIRTUAL 1 #define PURE_VIRTUAL 2 extern String *input_file; extern int line_number; extern int start_line; extern int CPlusPlus; // C++ mode extern int Extend; // Extend mode extern int Verbose; extern int IsVirtual; extern int ImportMode; extern int NoExcept; // -no_except option extern int Abstract; // abstract base class extern int SmartPointer; // smart pointer methods being emitted extern int SwigRuntime; /* Overload "argc" and "argv" */ extern String *argv_template_string; extern String *argc_template_string; /* Miscellaneous stuff */ #define tab2 " " #define tab4 " " #define tab8 " " class Dispatcher { public: Dispatcher ():cplus_mode(PUBLIC) { } virtual ~ Dispatcher () { } virtual int emit_one(Node *n); virtual int emit_children(Node *n); virtual int defaultHandler(Node *n); /* Top of the parse tree */ virtual int top(Node *n) = 0; /* SWIG directives */ virtual int applyDirective(Node *n); virtual int clearDirective(Node *n); virtual int constantDirective(Node *n); virtual int extendDirective(Node *n); virtual int fragmentDirective(Node *n); virtual int importDirective(Node *n); virtual int includeDirective(Node *n); virtual int insertDirective(Node *n); virtual int moduleDirective(Node *n); virtual int nativeDirective(Node *n); virtual int pragmaDirective(Node *n); virtual int typemapDirective(Node *n); virtual int typemapitemDirective(Node *n); virtual int typemapcopyDirective(Node *n); virtual int typesDirective(Node *n); /* C/C++ parsing */ virtual int cDeclaration(Node *n); virtual int externDeclaration(Node *n); virtual int enumDeclaration(Node *n); virtual int enumvalueDeclaration(Node *n); virtual int enumforwardDeclaration(Node *n); virtual int classDeclaration(Node *n); virtual int classforwardDeclaration(Node *n); virtual int constructorDeclaration(Node *n); virtual int destructorDeclaration(Node *n); virtual int accessDeclaration(Node *n); virtual int usingDeclaration(Node *n); virtual int namespaceDeclaration(Node *n); virtual int templateDeclaration(Node *n); virtual int lambdaDeclaration(Node *n); enum AccessMode { PUBLIC, PRIVATE, PROTECTED }; protected: AccessMode cplus_mode; }; /* ---------------------------------------------------------------------------- * class language: * * This class defines the functions that need to be supported by the * scripting language being used. The translator calls these virtual * functions to output different types of code for different languages. * ------------------------------------------------------------------------- */ class Language:public Dispatcher { public: Language(); virtual ~Language(); virtual int emit_one(Node *n); String *directorClassName(Node *n); /* Parse command line options */ virtual void main(int argc, char *argv[]); /* Top of the parse tree */ virtual int top(Node *n); /* SWIG directives */ virtual int applyDirective(Node *n); virtual int clearDirective(Node *n); virtual int constantDirective(Node *n); virtual int extendDirective(Node *n); virtual int fragmentDirective(Node *n); virtual int importDirective(Node *n); virtual int includeDirective(Node *n); virtual int insertDirective(Node *n); virtual int moduleDirective(Node *n); virtual int nativeDirective(Node *n); virtual int pragmaDirective(Node *n); virtual int typemapDirective(Node *n); virtual int typemapcopyDirective(Node *n); virtual int typesDirective(Node *n); /* C/C++ parsing */ virtual int cDeclaration(Node *n); virtual int externDeclaration(Node *n); virtual int enumDeclaration(Node *n); virtual int enumvalueDeclaration(Node *n); virtual int enumforwardDeclaration(Node *n); virtual int classDeclaration(Node *n); virtual int classforwardDeclaration(Node *n); virtual int constructorDeclaration(Node *n); virtual int destructorDeclaration(Node *n); virtual int accessDeclaration(Node *n); virtual int namespaceDeclaration(Node *n); virtual int usingDeclaration(Node *n); /* Function handlers */ virtual int functionHandler(Node *n); virtual int globalfunctionHandler(Node *n); virtual int memberfunctionHandler(Node *n); virtual int staticmemberfunctionHandler(Node *n); virtual int callbackfunctionHandler(Node *n); /* Variable handlers */ virtual int variableHandler(Node *n); virtual int globalvariableHandler(Node *n); virtual int membervariableHandler(Node *n); virtual int staticmembervariableHandler(Node *n); /* C++ handlers */ virtual int memberconstantHandler(Node *n); virtual int constructorHandler(Node *n); virtual int copyconstructorHandler(Node *n); virtual int destructorHandler(Node *n); virtual int classHandler(Node *n); /* Miscellaneous */ virtual int typedefHandler(Node *n); /* Low-level code generation */ virtual int constantWrapper(Node *n); virtual int variableWrapper(Node *n); virtual int functionWrapper(Node *n); virtual int nativeWrapper(Node *n); /* C++ director class generation */ virtual int classDirector(Node *n); virtual int classDirectorInit(Node *n); virtual int classDirectorEnd(Node *n); virtual int unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_director, int &virtual_destructor, int protectedbase = 0); virtual int classDirectorConstructor(Node *n); virtual int classDirectorDefaultConstructor(Node *n); virtual int classDirectorMethod(Node *n, Node *parent, String *super); virtual int classDirectorConstructors(Node *n); virtual int classDirectorDestructor(Node *n); virtual int classDirectorMethods(Node *n); virtual int classDirectorDisown(Node *n); /* Miscellaneous */ virtual int validIdentifier(String *s); /* valid identifier? */ virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */ virtual void dumpSymbols(); virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */ virtual Hash* symbolAddScope(const_String_or_char_ptr scope); virtual Hash* symbolScopeLookup(const_String_or_char_ptr scope); virtual Hash* symbolScopePseudoSymbolLookup(const_String_or_char_ptr scope); virtual Node *classLookup(const SwigType *s) const; /* Class lookup */ virtual Node *enumLookup(SwigType *s); /* Enum lookup */ virtual int abstractClassTest(Node *n); /* Is class really abstract? */ virtual int is_assignable(Node *n); /* Is variable assignable? */ virtual String *runtimeCode(); /* returns the language specific runtime code */ virtual String *defaultExternalRuntimeFilename(); /* the default filename for the external runtime */ virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm); /* Language specific special variable substitutions for $typemap() */ /* Runtime is C++ based, so extern "C" header section */ void enable_cplus_runtime_mode(); /* Returns the cplus_runtime mode */ int cplus_runtime_mode(); /* Allow director related code generation */ void allow_directors(int val = 1); /* Return true if directors are enabled */ int directorsEnabled() const; /* Allow director protected members related code generation */ void allow_dirprot(int val = 1); /* Allow all protected members code generation (for directors) */ void allow_allprotected(int val = 0); /* Returns the dirprot mode */ int dirprot_mode() const; /* Check if the non public constructor is needed (for directors) */ int need_nonpublic_ctor(Node *n); /* Check if the non public member is needed (for directors) */ int need_nonpublic_member(Node *n); /* Set none comparison string */ void setSubclassInstanceCheck(String *s); /* Set overload variable templates argc and argv */ void setOverloadResolutionTemplates(String *argc, String *argv); /* Language instance is a singleton - get instance */ static Language* instance(); protected: /* Allow multiple-input typemaps */ void allow_multiple_input(int val = 1); /* Allow overloaded functions */ void allow_overloading(int val = 1); /* Wrapping class query */ int is_wrapping_class() const; /* Return the node for the current class */ Node *getCurrentClass() const; /* Return C++ mode */ int getCPlusMode() const; /* Return the namespace for the class/enum - the nspace feature */ String *getNSpace() const; /* Return the real name of the current class */ String *getClassName() const; /* Return the classes hash */ Hash *getClassHash() const; /* Return the current class prefix */ String *getClassPrefix() const; /* Fully qualified type name to use */ String *getClassType() const; /* Return true if the current method is part of a smart-pointer */ int is_smart_pointer() const; /* Some language modules require additional wrappers for virtual methods not declared in sub-classes */ virtual bool extraDirectorProtectedCPPMethodsRequired() const; public: enum NestedClassSupport { NCS_None, // Target language does not have an equivalent to nested classes NCS_Full, // Target language does have an equivalent to nested classes and is fully implemented NCS_Unknown // Target language may or may not have an equivalent to nested classes. If it does, it has not been implemented yet. }; /* Does target language support nested classes? Default is NCS_Unknown. If NCS_Unknown is returned, then the nested classes will be ignored unless %feature "flatnested" is applied to them, in which case they will appear in global space. If the target language does not support the notion of class nesting, the language module should return NCS_None from this function, and the nested classes will be moved to the global scope (like implicit global %feature "flatnested"). */ virtual NestedClassSupport nestedClassesSupport() const; protected: /* Identifies if a protected members that are generated when the allprotected option is used. This does not include protected virtual methods as they are turned on with the dirprot option. */ bool isNonVirtualProtectedAccess(Node *n) const; /* Identify if a wrapped global or member variable n should use the naturalvar feature */ int use_naturalvar_mode(Node *n) const; /* Director subclass comparison test */ String *none_comparison; /* Director constructor "template" code */ String *director_ctor_code; /* Director 'protected' constructor "template" code */ String *director_prot_ctor_code; /* Director allows multiple inheritance */ int director_multiple_inheritance; /* Director language module */ int director_language; private: Hash *symtabs; /* symbol tables */ Hash *classtypes; Hash *enumtypes; int overloading; int multiinput; int cplus_runtime; int directors; static Language *this_; }; int SWIG_main(int, char **, Language *); void emit_parameter_variables(ParmList *l, Wrapper *f); void emit_return_variable(Node *n, SwigType *rt, Wrapper *f); void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */ void SWIG_config_file(const_String_or_char_ptr ); const String *SWIG_output_directory(); void SWIG_config_cppext(const char *ext); void Swig_print_xml(Node *obj, String *filename); /* get the list of generated files */ List *SWIG_output_files(); void SWIG_library_directory(const char *); int emit_num_arguments(ParmList *); int emit_num_required(ParmList *); int emit_isvarargs(ParmList *); void emit_attach_parmmaps(ParmList *, Wrapper *f); void emit_mark_varargs(ParmList *l); String *emit_action(Node *n); int emit_action_code(Node *n, String *wrappercode, String *action); void Swig_overload_check(Node *n); String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *); String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *); String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *); List *Swig_overload_rank(Node *n, bool script_lang_wrapping); SwigType *cplus_value_type(SwigType *t); /* directors.cxx start */ String *Swig_csuperclass_call(String *base, String *method, ParmList *l); String *Swig_class_declaration(Node *n, String *name); String *Swig_class_name(Node *n); String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms); String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values); String *Swig_director_declaration(Node *n); void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f); void Swig_director_parms_fixup(ParmList *parms); /* directors.cxx end */ extern "C" { void SWIG_typemap_lang(const char *); typedef Language *(*ModuleFactory) (void); } void Swig_register_module(const char *name, ModuleFactory fac); ModuleFactory Swig_find_module(const char *name); /* Utilities */ int is_public(Node *n); int is_private(Node *n); int is_protected(Node *n); int is_member_director(Node *parentnode, Node *member); int is_member_director(Node *member); int is_non_virtual_protected_access(Node *n); /* Check if the non-virtual protected members are required (for directors) */ void Wrapper_virtual_elimination_mode_set(int); void Wrapper_fast_dispatch_mode_set(int); void Wrapper_cast_dispatch_mode_set(int); void Wrapper_naturalvar_mode_set(int); void clean_overloaded(Node *n); extern "C" { const char *Swig_to_string(DOH *object, int count = -1); const char *Swig_to_string_with_location(DOH *object, int count = -1); void Swig_print(DOH *object, int count = -1); void Swig_print_with_location(DOH *object, int count = -1); } /* Contracts */ void Swig_contracts(Node *n); void Swig_contract_mode_set(int flag); int Swig_contract_mode_get(); /* Browser */ void Swig_browser(Node *n, int); void Swig_default_allocators(Node *n); void Swig_process_types(Node *n); void Swig_nested_process_classes(Node *n); void Swig_nested_name_unnamed_c_structs(Node *n); template class save_value { T _value; T& _value_ptr; save_value(const save_value&); save_value& operator=(const save_value&); public: save_value(T& value) : _value(value), _value_ptr(value) {} save_value(T& value, T new_val) : _value(value), _value_ptr(value) { value = new_val; } ~save_value() { _value_ptr = _value; } }; #endif swig-3.0.2/Source/Modules/r.cxx0000664000175000017500000022742112343605122016210 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * r.cxx * * R language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" static const double DEFAULT_NUMBER = .0000123456712312312323; static String* replaceInitialDash(const String *name) { String *retval; if (!Strncmp(name, "_", 1)) { retval = Copy(name); Insert(retval, 0, "s"); } else { retval = Copy(name); } return retval; } static String * getRTypeName(SwigType *t, int *outCount = NULL) { String *b = SwigType_base(t); List *els = SwigType_split(t); int count = 0; int i; if(Strncmp(b, "struct ", 7) == 0) Replace(b, "struct ", "", DOH_REPLACE_FIRST); /* Printf(stdout, " %s,base = %s\n", t, b); for(i = 0; i < Len(els); i++) Printf(stdout, "%d) %s, ", i, Getitem(els,i)); Printf(stdout, "\n"); */ for(i = 0; i < Len(els); i++) { String *el = Getitem(els, i); if(Strcmp(el, "p.") == 0 || Strncmp(el, "a(", 2) == 0) { count++; Append(b, "Ref"); } } if(outCount) *outCount = count; String *tmp = NewString(""); char *retName = Char(SwigType_manglestr(t)); Insert(tmp, 0, retName); return tmp; /* if(count) return(b); Delete(b); return(NewString("")); */ } /********************* Tries to get the name of the R class corresponding to the given type e.g. struct A * is ARef, struct A** is ARefRef. Now handles arrays, i.e. struct A[2] ****************/ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { String *tmp = NewString(""); SwigType *resolved = SwigType_typedef_resolve_all(retType); char *retName = Char(SwigType_manglestr(resolved)); if (upRef) { Printf(tmp, "_p%s", retName); } else{ Insert(tmp, 0, retName); } return tmp; /* #if 1 List *l = SwigType_split(retType); int n = Len(l); if(!l || n == 0) { #ifdef R_SWIG_VERBOSE if (debugMode) Printf(stdout, "SwigType_split return an empty list for %s\n", retType); #endif return(tmp); } String *el = Getitem(l, n-1); char *ptr = Char(el); if(strncmp(ptr, "struct ", 7) == 0) ptr += 7; Printf(tmp, "%s", ptr); if(addRef) { for(int i = 0; i < n; i++) { if(Strcmp(Getitem(l, i), "p.") == 0 || Strncmp(Getitem(l, i), "a(", 2) == 0) Printf(tmp, "Ref"); } } #else char *retName = Char(SwigType_manglestr(retType)); if(!retName) return(tmp); if(addRef) { while(retName && strlen(retName) > 1 && strncmp(retName, "_p", 2) == 0) { retName += 2; Printf(tmp, "Ref"); } } if(retName[0] == '_') retName ++; Insert(tmp, 0, retName); #endif return tmp; */ } /********************* Tries to get the name of the R class corresponding to the given type e.g. struct A * is ARef, struct A** is ARefRef. Now handles arrays, i.e. struct A[2] ****************/ static String * getRClassNameCopyStruct(String *retType, int addRef) { String *tmp = NewString(""); #if 1 List *l = SwigType_split(retType); int n = Len(l); if(!l || n == 0) { #ifdef R_SWIG_VERBOSE Printf(stdout, "SwigType_split return an empty list for %s\n", retType); #endif return(tmp); } String *el = Getitem(l, n-1); char *ptr = Char(el); if(strncmp(ptr, "struct ", 7) == 0) ptr += 7; Printf(tmp, "%s", ptr); if(addRef) { for(int i = 0; i < n; i++) { if(Strcmp(Getitem(l, i), "p.") == 0 || Strncmp(Getitem(l, i), "a(", 2) == 0) Printf(tmp, "Ref"); } } #else char *retName = Char(SwigType_manglestr(retType)); if(!retName) return(tmp); if(addRef) { while(retName && strlen(retName) > 1 && strncmp(retName, "_p", 2) == 0) { retName += 2; Printf(tmp, "Ref"); } } if(retName[0] == '_') retName ++; Insert(tmp, 0, retName); #endif return tmp; } /********************************* Write the elements of a list to the File*, one element per line. If quote is true, surround the element with "element". This takes care of inserting a tab in front of each line and also a comma after each element, except the last one. **********************************/ static void writeListByLine(List *l, File *out, bool quote = 0) { int i, n = Len(l); for(i = 0; i < n; i++) Printf(out, "%s%s%s%s%s\n", tab8, quote ? "\"" :"", Getitem(l, i), quote ? "\"" :"", i < n-1 ? "," : ""); } static const char *usage = "\ R Options (available with -r)\n\ -copystruct - Emit R code to copy C structs (on by default)\n\ -cppcast - Enable C++ casting operators (default) \n\ -debug - Output debug\n\ -dll - Name of the DLL (without the .dll or .so suffix).\n\ Default is the module name.\n\ -gc - Aggressive garbage collection\n\ -memoryprof - Add memory profile\n\ -namespace - Output NAMESPACE file\n\ -no-init-code - Turn off the generation of the R_init_ code\n\ (registration information still generated)\n\ -package - Package name for the PACKAGE argument of the R .Call()\n\ invocations. Default is the module name.\n\ "; /************ Display the help for this module on the screen/console. *************/ static void showUsage() { fputs(usage, stdout); } static bool expandTypedef(SwigType *t) { if (SwigType_isenum(t)) return false; String *prefix = SwigType_prefix(t); if (Strncmp(prefix, "f", 1)) return false; if (Strncmp(prefix, "p.f", 3)) return false; return true; } /***** Determine whether we should add a .copy argument to the S function that wraps/interfaces to the routine that returns the given type. *****/ static int addCopyParameter(SwigType *type) { int ok = 0; ok = Strncmp(type, "struct ", 7) == 0 || Strncmp(type, "p.struct ", 9) == 0; if(!ok) { ok = Strncmp(type, "p.", 2); } return(ok); } static void replaceRClass(String *tm, SwigType *type) { String *tmp = getRClassName(type); String *tmp_base = getRClassName(type, 0); String *tmp_ref = getRClassName(type, 1, 1); Replaceall(tm, "$R_class", tmp); Replaceall(tm, "$*R_class", tmp_base); Replaceall(tm, "$&R_class", tmp_ref); Delete(tmp); Delete(tmp_base); Delete(tmp_ref); } static double getNumber(String *value) { double d = DEFAULT_NUMBER; if(Char(value)) { if(sscanf(Char(value), "%lf", &d) != 1) return(DEFAULT_NUMBER); } return(d); } class R : public Language { public: R(); void registerClass(Node *n); void main(int argc, char *argv[]); int top(Node *n); void dispatchFunction(Node *n); int functionWrapper(Node *n); int variableWrapper(Node *n); int classDeclaration(Node *n); int enumDeclaration(Node *n); int membervariableHandler(Node *n); int typedefHandler(Node *n); static List *Swig_overload_rank(Node *n, bool script_lang_wrapping); int memberfunctionHandler(Node *n) { if (debugMode) Printf(stdout, " %s %s\n", Getattr(n, "name"), Getattr(n, "type")); member_name = Getattr(n, "sym:name"); processing_class_member_function = 1; int status = Language::memberfunctionHandler(n); processing_class_member_function = 0; return status; } /* Grab the name of the current class being processed so that we can deal with members of that class. */ int classHandler(Node *n){ if(!ClassMemberTable) ClassMemberTable = NewHash(); class_name = Getattr(n, "name"); int status = Language::classHandler(n); class_name = NULL; return status; } // Not used: String *runtimeCode(); protected: int addRegistrationRoutine(String *rname, int nargs); int outputRegistrationRoutines(File *out); int outputCommandLineArguments(File *out); int generateCopyRoutines(Node *n); int DumpCode(Node *n); int OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out); int OutputArrayMethod(String *className, List *el, File *out); int OutputClassMemberTable(Hash *tb, File *out); int OutputClassMethodsTable(File *out); int OutputClassAccessInfo(Hash *tb, File *out); int defineArrayAccessors(SwigType *type); void addNamespaceFunction(String *name) { if(!namespaceFunctions) namespaceFunctions = NewList(); Append(namespaceFunctions, name); } void addNamespaceMethod(String *name) { if(!namespaceMethods) namespaceMethods = NewList(); Append(namespaceMethods, name); } String* processType(SwigType *t, Node *n, int *nargs = NULL); String *createFunctionPointerHandler(SwigType *t, Node *n, int *nargs); int addFunctionPointerProxy(String *name, Node *n, SwigType *t, String *s_paramTypes) { /*XXX Do we need to put the t in there to get the return type later. */ if(!functionPointerProxyTable) functionPointerProxyTable = NewHash(); Setattr(functionPointerProxyTable, name, n); Setattr(SClassDefs, name, name); Printv(s_classes, "setClass('", name, "',\n", tab8, "prototype = list(parameterTypes = c(", s_paramTypes, "),\n", tab8, tab8, tab8, "returnType = '", SwigType_manglestr(t), "'),\n", tab8, "contains = 'CRoutinePointer')\n\n##\n", NIL); return SWIG_OK; } void addSMethodInfo(String *name, String *argType, int nargs); // Simple initialization such as constant strings that can be reused. void init(); void addAccessor(String *memberName, Wrapper *f, String *name, int isSet = -1); static int getFunctionPointerNumArgs(Node *n, SwigType *tt); protected: bool copyStruct; bool memoryProfile; bool aggressiveGc; // Strings into which we cumulate the generated code that is to be written //vto the files. String *sfile; String *f_init; String *s_classes; String *f_begin; String *f_runtime; String *f_wrapper; String *s_header; String *f_wrappers; String *s_init; String *s_init_routine; String *s_namespace; // State variables that carry information across calls to functionWrapper() // from member accessors and class declarations. String *opaqueClassDeclaration; int processing_variable; int processing_member_access_function; String *member_name; String *class_name; int processing_class_member_function; List *class_member_functions; List *class_member_set_functions; /* */ Hash *ClassMemberTable; Hash *ClassMethodsTable; Hash *SClassDefs; Hash *SMethodInfo; // Information about routines that are generated and to be registered with // R for dynamic lookup. Hash *registrationTable; Hash *functionPointerProxyTable; List *namespaceFunctions; List *namespaceMethods; List *namespaceClasses; // Probably can do this from ClassMemberTable. // Store a copy of the command line. // Need only keep a string that has it formatted. char **Argv; int Argc; bool inCPlusMode; // State variables that we remember from the command line settings // potentially that govern the code we generate. String *DllName; String *Rpackage; bool noInitializationCode; bool outputNamespaceInfo; String *UnProtectWrapupCode; // Static members static bool debugMode; }; R::R() : copyStruct(false), memoryProfile(false), aggressiveGc(false), sfile(0), f_init(0), s_classes(0), f_begin(0), f_runtime(0), f_wrapper(0), s_header(0), f_wrappers(0), s_init(0), s_init_routine(0), s_namespace(0), opaqueClassDeclaration(0), processing_variable(0), processing_member_access_function(0), member_name(0), class_name(0), processing_class_member_function(0), class_member_functions(0), class_member_set_functions(0), ClassMemberTable(0), ClassMethodsTable(0), SClassDefs(0), SMethodInfo(0), registrationTable(0), functionPointerProxyTable(0), namespaceFunctions(0), namespaceMethods(0), namespaceClasses(0), Argv(0), Argc(0), inCPlusMode(false), DllName(0), Rpackage(0), noInitializationCode(false), outputNamespaceInfo(false), UnProtectWrapupCode(0) { } bool R::debugMode = false; int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) { (void) tt; n = Getattr(n, "type"); if (debugMode) Printf(stdout, "type: %s\n", n); ParmList *parms = Getattr(n, "parms"); if (debugMode) Printf(stdout, "parms = %p\n", parms); return ParmList_len(parms); } void R::addSMethodInfo(String *name, String *argType, int nargs) { (void) argType; if(!SMethodInfo) SMethodInfo = NewHash(); if (debugMode) Printf(stdout, "[addMethodInfo] %s\n", name); Hash *tb = Getattr(SMethodInfo, name); if(!tb) { tb = NewHash(); Setattr(SMethodInfo, name, tb); } String *str = Getattr(tb, "max"); int max = -1; if(str) max = atoi(Char(str)); if(max < nargs) { if(str) Delete(str); str = NewStringf("%d", max); Setattr(tb, "max", str); } } /* Returns the name of the new routine. */ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { String *funName = SwigType_manglestr(t); /* See if we have already processed this one. */ if(functionPointerProxyTable && Getattr(functionPointerProxyTable, funName)) return funName; if (debugMode) Printf(stdout, " Defining %s\n", t); SwigType *rettype = Copy(Getattr(n, "type")); SwigType *funcparams = SwigType_functionpointer_decompose(rettype); String *rtype = SwigType_str(rettype, 0); // ParmList *parms = Getattr(n, "parms"); // memory leak ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)), n); if (debugMode) { Printf(stdout, "Type: %s\n", t); Printf(stdout, "Return type: %s\n", SwigType_base(t)); } bool isVoidType = Strcmp(rettype, "void") == 0; if (debugMode) Printf(stdout, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype); Wrapper *f = NewWrapper(); /* Go through argument list, attach lnames for arguments */ int i = 0; Parm *p = parms; for (i = 0; p; p = nextSibling(p), ++i) { String *arg = Getattr(p, "name"); String *lname; if (!arg && Cmp(Getattr(p, "type"), "void")) { lname = NewStringf("s_arg%d", i+1); Setattr(p, "name", lname); } else lname = arg; Setattr(p, "lname", lname); } Swig_typemap_attach_parms("out", parms, f); Swig_typemap_attach_parms("scoerceout", parms, f); Swig_typemap_attach_parms("scheck", parms, f); Printf(f->def, "%s %s(", rtype, funName); emit_parameter_variables(parms, f); emit_return_variable(n, rettype, f); // emit_attach_parmmaps(parms,f); /* Using weird name and struct to avoid potential conflicts. */ Wrapper_add_local(f, "r_swig_cb_data", "RCallbackFunctionData *r_swig_cb_data = R_SWIG_getCallbackFunctionData()"); String *lvar = NewString("r_swig_cb_data"); Wrapper_add_local(f, "r_tmp", "SEXP r_tmp"); // for use in converting arguments to R objects for call. Wrapper_add_local(f, "r_nprotect", "int r_nprotect = 0"); // for use in converting arguments to R objects for call. Wrapper_add_local(f, "r_vmax", "char * r_vmax= 0"); // for use in converting arguments to R objects for call. // Add local for error code in return value. This is not in emit_return_variable because that assumes an out typemap // whereas the type makes are reverse Wrapper_add_local(f, "ecode", "int ecode = 0"); p = parms; int nargs = ParmList_len(parms); if(numArgs) { *numArgs = nargs; if (debugMode) Printf(stdout, "Setting number of parameters to %d\n", *numArgs); } String *setExprElements = NewString(""); String *s_paramTypes = NewString(""); for(i = 0; p; i++) { SwigType *tt = Getattr(p, "type"); SwigType *name = Getattr(p, "name"); String *tm = Getattr(p, "tmap:out"); Printf(f->def, "%s %s", SwigType_str(tt, 0), name); if(tm) { Replaceall(tm, "$1", name); if (SwigType_isreference(tt)) { String *tmp = NewString(""); Append(tmp, "*"); Append(tmp, name); Replaceall(tm, tmp, name); } Replaceall(tm, "$result", "r_tmp"); replaceRClass(tm, Getattr(p,"type")); Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); } Printf(setExprElements, "%s\n", tm); Printf(setExprElements, "SETCAR(r_swig_cb_data->el, %s);\n", "r_tmp"); Printf(setExprElements, "r_swig_cb_data->el = CDR(r_swig_cb_data->el);\n\n"); Printf(s_paramTypes, "'%s'", SwigType_manglestr(tt)); p = nextSibling(p); if(p) { Printf(f->def, ", "); Printf(s_paramTypes, ", "); } } Printf(f->def, ") {\n"); Printf(f->code, "Rf_protect(%s->expr = Rf_allocVector(LANGSXP, %d));\n", lvar, nargs + 1); Printf(f->code, "r_nprotect++;\n"); Printf(f->code, "r_swig_cb_data->el = r_swig_cb_data->expr;\n\n"); Printf(f->code, "SETCAR(r_swig_cb_data->el, r_swig_cb_data->fun);\n"); Printf(f->code, "r_swig_cb_data->el = CDR(r_swig_cb_data->el);\n\n"); Printf(f->code, "%s\n\n", setExprElements); Printv(f->code, "r_swig_cb_data->retValue = R_tryEval(", "r_swig_cb_data->expr,", " R_GlobalEnv,", " &r_swig_cb_data->errorOccurred", ");\n", NIL); Printv(f->code, "\n", "if(r_swig_cb_data->errorOccurred) {\n", "R_SWIG_popCallbackFunctionData(1);\n", "Rf_error(\"error in calling R function as a function pointer (", funName, ")\");\n", "}\n", NIL); if(!isVoidType) { /* Need to deal with the return type of the function pointer, not the function pointer itself. So build a new node that has the relevant pieces. XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost. Is this still true? If so, will a SwigType_push() solve things? */ Parm *bbase = NewParmNode(rettype, n); String *returnTM = Swig_typemap_lookup("in", bbase, Swig_cresult_name(), f); if(returnTM) { String *tm = returnTM; Replaceall(tm,"$input", "r_swig_cb_data->retValue"); Replaceall(tm,"$target", Swig_cresult_name()); replaceRClass(tm, rettype); Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); Replaceall(tm,"$disown","0"); Printf(f->code, "%s\n", tm); } Delete(bbase); } Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL); Printv(f->code, "\n", UnProtectWrapupCode, NIL); if (SwigType_isreference(rettype)) { Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL); } else if(!isVoidType) Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL); Printv(f->code, "\n}\n", NIL); Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn"); /* To coerce correctly in S, we really want to have an extra/intermediate function that handles the scoerceout. We need to check if any of the argument types have an entry in that map. If none do, the ignore and call the function straight. Otherwise, generate the a marshalling function. Need to be able to find it in S. Or use an entirely generic one that evaluates the expressions. Handle errors in the evaluation of the function by restoring the stack, if there is one in use for this function (i.e. no userData). */ Wrapper_print(f, f_wrapper); addFunctionPointerProxy(funName, n, t, s_paramTypes); Delete(s_paramTypes); Delete(rtype); Delete(rettype); Delete(funcparams); DelWrapper(f); return funName; } void R::init() { UnProtectWrapupCode = NewStringf("%s", "vmaxset(r_vmax);\nif(r_nprotect) Rf_unprotect(r_nprotect);\n\n"); SClassDefs = NewHash(); sfile = NewString(""); f_init = NewString(""); s_header = NewString(""); f_begin = NewString(""); f_runtime = NewString(""); f_wrapper = NewString(""); s_classes = NewString(""); s_init = NewString(""); s_init_routine = NewString(""); } #if 0 int R::cDeclaration(Node *n) { SwigType *t = Getattr(n, "type"); SwigType *name = Getattr(n, "name"); if (debugMode) Printf(stdout, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0)); return Language::cDeclaration(n); } #endif /** Method from Language that is called to start the entire processing off, i.e. the generation of the code. It is called after the input has been read and parsed. Here we open the output streams and generate the code. ***/ int R::top(Node *n) { String *module = Getattr(n, "name"); if(!Rpackage) Rpackage = Copy(module); if(!DllName) DllName = Copy(module); if(outputNamespaceInfo) { s_namespace = NewString(""); Swig_register_filebyname("snamespace", s_namespace); Printf(s_namespace, "useDynLib(%s)\n", DllName); } /* Associate the different streams with names so that they can be used in %insert directives by the typemap code. */ Swig_register_filebyname("sinit", s_init); Swig_register_filebyname("sinitroutine", s_init_routine); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("header", s_header); Swig_register_filebyname("wrapper", f_wrapper); Swig_register_filebyname("s", sfile); Swig_register_filebyname("sclasses", s_classes); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGR\n"); Printf(f_runtime, "\n"); Swig_banner_target_lang(s_init, "#"); outputCommandLineArguments(s_init); Printf(f_wrapper, "#ifdef __cplusplus\n"); Printf(f_wrapper, "extern \"C\" {\n"); Printf(f_wrapper, "#endif\n\n"); Language::top(n); Printf(f_wrapper, "#ifdef __cplusplus\n"); Printf(f_wrapper, "}\n"); Printf(f_wrapper, "#endif\n"); String *type_table = NewString(""); SwigType_emit_type_table(f_runtime,f_wrapper); Delete(type_table); if(ClassMemberTable) { //XXX OutputClassAccessInfo(ClassMemberTable, sfile); Delete(ClassMemberTable); ClassMemberTable = NULL; } Printf(f_init,"}\n"); if(registrationTable) outputRegistrationRoutines(f_init); /* Now arrange to write the 2 files - .S and .c. */ DumpCode(n); Delete(sfile); Delete(s_classes); Delete(s_init); Delete(f_wrapper); Delete(f_init); Delete(s_header); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /***************************************************** Write the generated code to the .S and the .c files. ****************************************************/ int R::DumpCode(Node *n) { String *output_filename = NewString(""); /* The name of the file in which we will generate the S code. */ Printf(output_filename, "%s%s.R", SWIG_output_directory(), Rpackage); #ifdef R_SWIG_VERBOSE Printf(stdout, "Writing S code to %s\n", output_filename); #endif File *scode = NewFile(output_filename, "w", SWIG_output_files()); if (!scode) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); } Delete(output_filename); Printf(scode, "%s\n\n", s_init); Printf(scode, "%s\n\n", s_classes); Printf(scode, "%s\n", sfile); Delete(scode); String *outfile = Getattr(n,"outfile"); File *runtime = NewFile(outfile,"w", SWIG_output_files()); if (!runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } Printf(runtime, "%s", f_begin); Printf(runtime, "%s\n", f_runtime); Printf(runtime, "%s\n", s_header); Printf(runtime, "%s\n", f_wrapper); Printf(runtime, "%s\n", f_init); Delete(runtime); if(outputNamespaceInfo) { output_filename = NewString(""); Printf(output_filename, "%sNAMESPACE", SWIG_output_directory()); File *ns = NewFile(output_filename, "w", SWIG_output_files()); if (!ns) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); } Delete(output_filename); Printf(ns, "%s\n", s_namespace); Printf(ns, "\nexport(\n"); writeListByLine(namespaceFunctions, ns); Printf(ns, ")\n"); Printf(ns, "\nexportMethods(\n"); writeListByLine(namespaceFunctions, ns, 1); Printf(ns, ")\n"); Delete(ns); Delete(s_namespace); } return SWIG_OK; } /* We may need to do more.... so this is left as a stub for the moment. */ int R::OutputClassAccessInfo(Hash *tb, File *out) { int n = OutputClassMemberTable(tb, out); OutputClassMethodsTable(out); return n; } /************************************************************************ Currently this just writes the information collected about the different methods of the C++ classes that have been processed to the console. This will be used later to define S4 generics and methods. **************************************************************************/ int R::OutputClassMethodsTable(File *) { Hash *tb = ClassMethodsTable; if(!tb) return SWIG_OK; List *keys = Keys(tb); String *key; int i, n = Len(keys); if (debugMode) { for(i = 0; i < n ; i++ ) { key = Getitem(keys, i); Printf(stdout, "%d) %s\n", i, key); List *els = Getattr(tb, key); int nels = Len(els); Printf(stdout, "\t"); for(int j = 0; j < nels; j+=2) { Printf(stdout, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : ""); Printf(stdout, "%s\n", Getitem(els, j+1)); } Printf(stdout, "\n"); } } return SWIG_OK; } /* Iterate over the _set and <>_get elements and generate the $ and $<- functions that provide constrained access to the member fields in these elements. tb - a hash table that is built up in functionWrapper as we process each membervalueHandler. The entries are indexed by _set and _get. Each entry is a List *. out - the stram where the code is to be written. This is the S code stream as we generate only S code here.. */ int R::OutputClassMemberTable(Hash *tb, File *out) { List *keys = Keys(tb), *el; String *key; int i, n = Len(keys); /* Loop over all the _set and _get entries in the table. */ if(n && outputNamespaceInfo) { Printf(s_namespace, "exportClasses("); } for(i = 0; i < n; i++) { key = Getitem(keys, i); el = Getattr(tb, key); String *className = Getitem(el, 0); char *ptr = Char(key); ptr = &ptr[Len(key) - 3]; int isSet = strcmp(ptr, "set") == 0; // OutputArrayMethod(className, el, out); OutputMemberReferenceMethod(className, isSet, el, out); if(outputNamespaceInfo) Printf(s_namespace, "\"%s\"%s", className, i < n-1 ? "," : ""); } if(n && outputNamespaceInfo) { Printf(s_namespace, ")\n"); } return n; } /******************************************************************* Write the methods for $ or $<- for accessing a member field in an struct or union (or class). className - the name of the struct or union (e.g. Bar for struct Bar) isSet - a logical value indicating whether the method is for modifying ($<-) or accessing ($) the member field. el - a list of length 2 * # accessible member elements + 1. The first element is the name of the class. The other pairs are member name and the name of the R function to access it. out - the stream where we write the code. ********************************************************************/ int R::OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out) { int numMems = Len(el), j; int varaccessor = 0; if (numMems == 0) return SWIG_OK; Wrapper *f = NewWrapper(), *attr = NewWrapper(); Printf(f->def, "function(x, name%s)", isSet ? ", value" : ""); Printf(attr->def, "function(x, i, j, ...%s)", isSet ? ", value" : ""); Printf(f->code, "{\n"); Printf(f->code, "%saccessorFuns = list(", tab8); Node *itemList = NewHash(); bool has_prev = false; for(j = 0; j < numMems; j+=3) { String *item = Getitem(el, j); if (Getattr(itemList, item)) continue; Setattr(itemList, item, "1"); String *dup = Getitem(el, j + 1); char *ptr = Char(dup); ptr = &ptr[Len(dup) - 3]; if (!strcmp(ptr, "get")) varaccessor++; String *pitem; if (!Strcmp(item, "operator ()")) { pitem = NewString("call"); } else if (!Strcmp(item, "operator ->")) { pitem = NewString("deref"); } else if (!Strcmp(item, "operator +")) { pitem = NewString("add"); } else if (!Strcmp(item, "operator -")) { pitem = NewString("sub"); } else { pitem = Copy(item); } if (has_prev) Printf(f->code, ", "); Printf(f->code, "'%s' = %s", pitem, dup); has_prev = true; Delete(pitem); } Delete(itemList); Printf(f->code, ");\n"); if (!isSet && varaccessor > 0) { Printf(f->code, "%svaccessors = c(", tab8); int vcount = 0; for(j = 0; j < numMems; j+=3) { String *item = Getitem(el, j); String *dup = Getitem(el, j + 1); char *ptr = Char(dup); ptr = &ptr[Len(dup) - 3]; if (!strcmp(ptr, "get")) { vcount++; Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : ""); } } Printf(f->code, ");\n"); } /* Printv(f->code, tab8, "idx = pmatch(name, names(accessorFuns))\n", tab8, "if(is.na(idx)) {\n", tab8, tab4, "stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className, ": fields are \", paste(names(accessorFuns), sep = \", \")", ")", "\n}\n", NIL); */ Printv(f->code, ";", tab8, "idx = pmatch(name, names(accessorFuns));\n", tab8, "if(is.na(idx)) \n", tab8, tab4, NIL); Printf(f->code, "return(callNextMethod(x, name%s));\n", isSet ? ", value" : ""); Printv(f->code, tab8, "f = accessorFuns[[idx]];\n", NIL); if(isSet) { Printv(f->code, tab8, "f(x, value);\n", NIL); Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value. } else { if (varaccessor) { Printv(f->code, tab8, "if (is.na(match(name, vaccessors))) function(...){f(x, ...)} else f(x);\n", NIL); } else { Printv(f->code, tab8, "function(...){f(x, ...)};\n", NIL); } } Printf(f->code, "}\n"); Printf(out, "# Start of accessor method for %s\n", className); Printf(out, "setMethod('$%s', '_p%s', ", isSet ? "<-" : "", getRClassName(className)); Wrapper_print(f, out); Printf(out, ");\n"); if(isSet) { Printf(out, "setMethod('[[<-', c('_p%s', 'character'),", getRClassName(className)); Insert(f->code, 2, "name = i;\n"); Printf(attr->code, "%s", f->code); Wrapper_print(attr, out); Printf(out, ");\n"); } DelWrapper(attr); DelWrapper(f); Printf(out, "# end of accessor method for %s\n", className); return SWIG_OK; } /******************************************************************* Write the methods for [ or [<- for accessing a member field in an struct or union (or class). className - the name of the struct or union (e.g. Bar for struct Bar) el - a list of length 2 * # accessible member elements + 1. The first element is the name of the class. The other pairs are member name and the name of the R function to access it. out - the stream where we write the code. ********************************************************************/ int R::OutputArrayMethod(String *className, List *el, File *out) { int numMems = Len(el), j; if(!el || numMems == 0) return(0); Printf(out, "# start of array methods for %s\n", className); for(j = 0; j < numMems; j+=3) { String *item = Getitem(el, j); String *dup = Getitem(el, j + 1); if (!Strcmp(item, "__getitem__")) { Printf(out, "setMethod('[', '_p%s', function(x, i, j, ..., drop =TRUE) ", getRClassName(className)); Printf(out, " sapply(i, function (n) %s(x, as.integer(n-1))))\n\n", dup); } if (!Strcmp(item, "__setitem__")) { Printf(out, "setMethod('[<-', '_p%s', function(x, i, j, ..., value)", getRClassName(className)); Printf(out, " sapply(1:length(i), function(n) %s(x, as.integer(i[n]-1), value[n])))\n\n", dup); } } Printf(out, "# end of array methods for %s\n", className); return SWIG_OK; } /************************************************************ Called when a enumeration is to be processed. We want to call the R function defineEnumeration(). tdname is the typedef of the enumeration, i.e. giving its name. *************************************************************/ int R::enumDeclaration(Node *n) { String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); /* Using name if tdname is empty. */ if(Len(tdname) == 0) tdname = name; if(!tdname || Strcmp(tdname, "") == 0) { Language::enumDeclaration(n); return SWIG_OK; } String *mangled_tdname = SwigType_manglestr(tdname); String *scode = NewString(""); Printv(scode, "defineEnumeration('", mangled_tdname, "'", ",\n", tab8, tab8, tab4, ".values = c(\n", NIL); Node *c; int value = -1; // First number is zero for (c = firstChild(n); c; c = nextSibling(c)) { // const char *tag = Char(nodeType(c)); // if (Strcmp(tag,"cdecl") == 0) { name = Getattr(c, "name"); String *val = Getattr(c, "enumvalue"); if(val && Char(val)) { int inval = (int) getNumber(val); if(inval == DEFAULT_NUMBER) value++; else value = inval; } else value++; Printf(scode, "%s%s%s'%s' = %d%s\n", tab8, tab8, tab8, name, value, nextSibling(c) ? ", " : ""); // } } Printv(scode, "))", NIL); Printf(sfile, "%s\n", scode); Delete(scode); Delete(mangled_tdname); return SWIG_OK; } /************************************************************* **************************************************************/ int R::variableWrapper(Node *n) { String *name = Getattr(n, "sym:name"); processing_variable = 1; Language::variableWrapper(n); // Force the emission of the _set and _get function wrappers. processing_variable = 0; SwigType *ty = Getattr(n, "type"); int addCopyParam = addCopyParameter(ty); //XXX processType(ty, n); if(!SwigType_isconst(ty)) { Wrapper *f = NewWrapper(); Printf(f->def, "%s = \nfunction(value%s)\n{\n", name, addCopyParam ? ", .copy = FALSE" : ""); Printv(f->code, "if(missing(value)) {\n", name, "_get(", addCopyParam ? ".copy" : "", ")\n}", NIL); Printv(f->code, " else {\n", name, "_set(value)\n}\n}", NIL); Wrapper_print(f, sfile); DelWrapper(f); } else { Printf(sfile, "%s = %s_get\n", name, name); } return SWIG_OK; } void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, int isSet) { if(isSet < 0) { int n = Len(name); char *ptr = Char(name); isSet = Strcmp(NewString(&ptr[n-3]), "set") == 0; } List *l = isSet ? class_member_set_functions : class_member_functions; if(!l) { l = NewList(); if(isSet) class_member_set_functions = l; else class_member_functions = l; } Append(l, memberName); Append(l, name); String *tmp = NewString(""); Wrapper_print(wrapper, tmp); Append(l, tmp); // if we could put the wrapper in directly: Append(l, Copy(sfun)); if (debugMode) Printf(stdout, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp); } #define MAX_OVERLOAD 256 struct Overloaded { Node *n; /* Node */ int argc; /* Argument count */ ParmList *parms; /* Parameters used for overload check */ int error; /* Ambiguity error */ }; List * R::Swig_overload_rank(Node *n, bool script_lang_wrapping) { Overloaded nodes[MAX_OVERLOAD]; int nnodes = 0; Node *o = Getattr(n,"sym:overloaded"); if (!o) return 0; Node *c = o; while (c) { if (Getattr(c,"error")) { c = Getattr(c,"sym:nextSibling"); continue; } /* if (SmartPointer && Getattr(c,"cplus:staticbase")) { c = Getattr(c,"sym:nextSibling"); continue; } */ /* Make a list of all the declarations (methods) that are overloaded with * this one particular method name */ if (Getattr(c,"wrap:name")) { nodes[nnodes].n = c; nodes[nnodes].parms = Getattr(c,"wrap:parms"); nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms); nodes[nnodes].error = 0; nnodes++; } c = Getattr(c,"sym:nextSibling"); } /* Sort the declarations by required argument count */ { int i,j; for (i = 0; i < nnodes; i++) { for (j = i+1; j < nnodes; j++) { if (nodes[i].argc > nodes[j].argc) { Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; } } } } /* Sort the declarations by argument types */ { int i,j; for (i = 0; i < nnodes-1; i++) { if (nodes[i].argc == nodes[i+1].argc) { for (j = i+1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) { Parm *p1 = nodes[i].parms; Parm *p2 = nodes[j].parms; int differ = 0; int num_checked = 0; while (p1 && p2 && (num_checked < nodes[i].argc)) { if (debugMode) { Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type")); } if (checkAttribute(p1,"tmap:in:numinputs","0")) { p1 = Getattr(p1,"tmap:in:next"); continue; } if (checkAttribute(p2,"tmap:in:numinputs","0")) { p2 = Getattr(p2,"tmap:in:next"); continue; } String *t1 = Getattr(p1,"tmap:typecheck:precedence"); String *t2 = Getattr(p2,"tmap:typecheck:precedence"); if (debugMode) { Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2); } if ((!t1) && (!nodes[i].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), "Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); nodes[i].error = 1; } else if ((!t2) && (!nodes[j].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), "xx Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); nodes[j].error = 1; } if (t1 && t2) { int t1v, t2v; t1v = atoi(Char(t1)); t2v = atoi(Char(t2)); differ = t1v-t2v; } else if (!t1 && t2) differ = 1; else if (t1 && !t2) differ = -1; else if (!t1 && !t2) differ = -1; num_checked++; if (differ > 0) { Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; break; } else if ((differ == 0) && (Strcmp(t1,"0") == 0)) { t1 = Getattr(p1,"ltype"); if (!t1) { t1 = SwigType_ltype(Getattr(p1,"type")); if (Getattr(p1,"tmap:typecheck:SWIGTYPE")) { SwigType_add_pointer(t1); } Setattr(p1,"ltype",t1); } t2 = Getattr(p2,"ltype"); if (!t2) { t2 = SwigType_ltype(Getattr(p2,"type")); if (Getattr(p2,"tmap:typecheck:SWIGTYPE")) { SwigType_add_pointer(t2); } Setattr(p2,"ltype",t2); } /* Need subtype check here. If t2 is a subtype of t1, then we need to change the order */ if (SwigType_issubtype(t2,t1)) { Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; } if (Strcmp(t1,t2) != 0) { differ = 1; break; } } else if (differ) { break; } if (Getattr(p1,"tmap:in:next")) { p1 = Getattr(p1,"tmap:in:next"); } else { p1 = nextSibling(p1); } if (Getattr(p2,"tmap:in:next")) { p2 = Getattr(p2,"tmap:in:next"); } else { p2 = nextSibling(p2); } } if (!differ) { /* See if declarations differ by const only */ String *d1 = Getattr(nodes[i].n, "decl"); String *d2 = Getattr(nodes[j].n, "decl"); if (d1 && d2) { String *dq1 = Copy(d1); String *dq2 = Copy(d2); if (SwigType_isconst(d1)) { Delete(SwigType_pop(dq1)); } if (SwigType_isconst(d2)) { Delete(SwigType_pop(dq2)); } if (Strcmp(dq1, dq2) == 0) { if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { if (script_lang_wrapping) { // Swap nodes so that the const method gets ignored (shadowed by the non-const method) Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; } differ = 1; if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } nodes[j].error = 1; } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { differ = 1; if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } nodes[j].error = 1; } } Delete(dq1); Delete(dq2); } } if (!differ) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); } nodes[j].error = 1; } } } } } } List *result = NewList(); { int i; for (i = 0; i < nnodes; i++) { if (nodes[i].error) Setattr(nodes[i].n, "overload:ignore", "1"); Append(result,nodes[i].n); // Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms)); // Swig_print_node(nodes[i].n); } } return result; } void R::dispatchFunction(Node *n) { Wrapper *f = NewWrapper(); String *symname = Getattr(n, "sym:name"); String *nodeType = Getattr(n, "nodeType"); bool constructor = (!Cmp(nodeType, "constructor")); String *sfname = NewString(symname); if (constructor) Replace(sfname, "new_", "", DOH_REPLACE_FIRST); Printf(f->def, "`%s` <- function(...) {", sfname); if (debugMode) { Swig_print_node(n); } List *dispatch = Swig_overload_rank(n, true); int nfunc = Len(dispatch); Printv(f->code, "argtypes <- mapply(class, list(...));\n", "argv <- list(...);\n", "argc <- length(argtypes);\n", NIL ); Printf(f->code, "# dispatch functions %d\n", nfunc); int cur_args = -1; bool first_compare = true; for (int i=0; i < nfunc; i++) { Node *ni = Getitem(dispatch,i); Parm *pi = Getattr(ni,"wrap:parms"); int num_arguments = emit_num_arguments(pi); String *overname = Getattr(ni,"sym:overname"); if (cur_args != num_arguments) { if (cur_args != -1) { Printv(f->code, "} else ", NIL); } Printf(f->code, "if (argc == %d) {", num_arguments); cur_args = num_arguments; first_compare = true; } Parm *p; int j; if (num_arguments > 0) { if (!first_compare) { Printv(f->code, " else ", NIL); } else { first_compare = false; } Printv(f->code, "if (", NIL); for (p =pi, j = 0 ; j < num_arguments ; j++) { if (debugMode) { Swig_print_node(p); } String *tm = Swig_typemap_lookup("rtype", p, "", 0); if(tm) { replaceRClass(tm, Getattr(p, "type")); } String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0); if (tmcheck) { String *tmp = NewString(""); Printf(tmp, "argv[[%d]]", j+1); Replaceall(tmcheck, "$arg", tmp); Printf(tmp, "argtype[%d]", j+1); Replaceall(tmcheck, "$argtype", tmp); if (tm) { Replaceall(tmcheck, "$rtype", tm); } if (debugMode) { Printf(stdout, "%s\n", tmcheck); } Printf(f->code, "%s(%s)", j == 0? "" : " && ", tmcheck); p = Getattr(p, "tmap:in:next"); continue; } if (tm) { if (Strcmp(tm,"numeric")==0) { Printf(f->code, "%sis.numeric(argv[[%d]])", j == 0 ? "" : " && ", j+1); } else if (Strcmp(tm,"integer")==0) { Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", j == 0 ? "" : " && ", j+1, j+1); } else if (Strcmp(tm,"character")==0) { Printf(f->code, "%sis.character(argv[[%d]])", j == 0 ? "" : " && ", j+1); } else { Printf(f->code, "%sextends(argtypes[%d], '%s')", j == 0 ? "" : " && ", j+1, tm); } } if (!SwigType_ispointer(Getattr(p, "type"))) { Printf(f->code, " && length(argv[[%d]]) == 1", j+1); } p = Getattr(p, "tmap:in:next"); } Printf(f->code, ") { f <- %s%s; }\n", sfname, overname); } else { Printf(f->code, "f <- %s%s; ", sfname, overname); } } if (cur_args != -1) { Printf(f->code, "} else {\n" "stop(\"cannot find overloaded function for %s with argtypes (\"," "toString(argtypes),\")\");\n" "}", sfname); } Printv(f->code, ";\nf(...)", NIL); Printv(f->code, ";\n}", NIL); Wrapper_print(f, sfile); Printv(sfile, "# Dispatch function\n", NIL); DelWrapper(f); } /****************************************************************** *******************************************************************/ int R::functionWrapper(Node *n) { String *fname = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); String *type = Getattr(n, "type"); if (debugMode) { Printf(stdout, " %s %s %s\n", fname, iname, type); } String *overname = 0; String *nodeType = Getattr(n, "nodeType"); bool constructor = (!Cmp(nodeType, "constructor")); bool destructor = (!Cmp(nodeType, "destructor")); String *sfname = NewString(iname); if (constructor) Replace(sfname, "new_", "", DOH_REPLACE_FIRST); if (Getattr(n,"sym:overloaded")) { overname = Getattr(n,"sym:overname"); Append(sfname, overname); } if (debugMode) Printf(stdout, " processing parameters\n"); ParmList *l = Getattr(n, "parms"); Parm *p; String *tm; p = l; while(p) { SwigType *resultType = Getattr(p, "type"); if (expandTypedef(resultType) && SwigType_istypedef(resultType)) { SwigType *resolved = SwigType_typedef_resolve_all(resultType); if (expandTypedef(resolved)) { Setattr(p, "type", Copy(resolved)); } } p = nextSibling(p); } String *unresolved_return_type = Copy(type); if (expandTypedef(type) && SwigType_istypedef(type)) { SwigType *resolved = SwigType_typedef_resolve_all(type); if (expandTypedef(resolved)) { type = Copy(resolved); Setattr(n, "type", type); } } if (debugMode) Printf(stdout, " unresolved_return_type %s\n", unresolved_return_type); if(processing_member_access_function) { if (debugMode) Printf(stdout, " '%s' '%s' '%s' '%s'\n", fname, iname, member_name, class_name); if(opaqueClassDeclaration) return SWIG_OK; /* Add the name of this member to a list for this class_name. We will dump all these at the end. */ int n = Len(iname); char *ptr = Char(iname); bool isSet(Strcmp(NewString(&ptr[n-3]), "set") == 0); String *tmp = NewString(""); Printf(tmp, "%s_%s", class_name, isSet ? "set" : "get"); List *memList = Getattr(ClassMemberTable, tmp); if(!memList) { memList = NewList(); Append(memList, class_name); Setattr(ClassMemberTable, tmp, memList); } Delete(tmp); Append(memList, member_name); Append(memList, iname); } int i; int nargs; String *wname = Swig_name_wrapper(iname); Replace(wname, "_wrap", "R_swig", DOH_REPLACE_FIRST); if(overname) Append(wname, overname); Setattr(n,"wrap:name", wname); Wrapper *f = NewWrapper(); Wrapper *sfun = NewWrapper(); int isVoidReturnType = (Strcmp(type, "void") == 0); // Need to use the unresolved return type since // typedef resolution removes the const which causes a // mismatch with the function action emit_return_variable(n, unresolved_return_type, f); SwigType *rtype = Getattr(n, "type"); int addCopyParam = 0; if(!isVoidReturnType) addCopyParam = addCopyParameter(rtype); // Can we get the nodeType() of the type node! and see if it is a struct. // int addCopyParam = SwigType_isclass(rtype); // if(addCopyParam) if (debugMode) Printf(stdout, "Adding a .copy argument to %s for %s = %s\n", iname, type, addCopyParam ? "yes" : "no"); Printv(f->def, "SWIGEXPORT SEXP\n", wname, " ( ", NIL); Printf(sfun->def, "# Start of %s\n", iname); Printv(sfun->def, "\n`", sfname, "` = function(", NIL); if(outputNamespaceInfo) //XXX Need to be a little more discriminating addNamespaceFunction(iname); Swig_typemap_attach_parms("scoercein", l, f); Swig_typemap_attach_parms("scoerceout", l, f); Swig_typemap_attach_parms("scheck", l, f); emit_parameter_variables(l, f); emit_attach_parmmaps(l,f); Setattr(n,"wrap:parms",l); nargs = emit_num_arguments(l); Wrapper_add_local(f, "r_nprotect", "unsigned int r_nprotect = 0"); Wrapper_add_localv(f, "r_ans", "SEXP", "r_ans = R_NilValue", NIL); Wrapper_add_localv(f, "r_vmax", "VMAXTYPE", "r_vmax = vmaxget()", NIL); String *sargs = NewString(""); String *s_inputTypes = NewString(""); String *s_inputMap = NewString(""); bool inFirstArg = true; bool inFirstType = true; Parm *curP; for (p =l, i = 0 ; i < nargs ; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *tt = Getattr(p, "type"); int nargs = -1; String *funcptr_name = processType(tt, p, &nargs); // SwigType *tp = Getattr(p, "type"); String *name = Getattr(p,"name"); String *lname = Getattr(p,"lname"); // R keyword renaming if (name) { if (Swig_name_warning(p, 0, name, 0)) { name = 0; } else { /* If we have a :: in the parameter name because we are accessing a static member of a class, say, then we need to remove that prefix. */ while (Strstr(name, "::")) { //XXX need to free. name = NewStringf("%s", Strchr(name, ':') + 2); if (debugMode) Printf(stdout, "+++ parameter name with :: in it %s\n", name); } } } if (!name || Len(name) == 0) name = NewStringf("s_arg%d", i+1); name = replaceInitialDash(name); if (!Strncmp(name, "arg", 3)) { name = Copy(name); Insert(name, 0, "s_"); } if(processing_variable) { name = Copy(name); Insert(name, 0, "s_"); } if(!Strcmp(name, fname)) { name = Copy(name); Insert(name, 0, "s_"); } Printf(sargs, "%s, ", name); String *tm; if((tm = Getattr(p, "tmap:scoercein"))) { Replaceall(tm, "$input", name); replaceRClass(tm, Getattr(p, "type")); if(funcptr_name) { //XXX need to get this to return non-zero if(nargs == -1) nargs = getFunctionPointerNumArgs(p, tt); String *snargs = NewStringf("%d", nargs); Printv(sfun->code, "if(is.function(", name, ")) {", "\n", "assert('...' %in% names(formals(", name, ")) || length(formals(", name, ")) >= ", snargs, ");\n} ", NIL); Delete(snargs); Printv(sfun->code, "else {\n", "if(is.character(", name, ")) {\n", name, " = getNativeSymbolInfo(", name, ");", "\n};\n", "if(is(", name, ", \"NativeSymbolInfo\")) {\n", name, " = ", name, "$address", ";\n}\n", "if(is(", name, ", \"ExternalReference\")) {\n", name, " = ", name, "@ref;\n}\n", "}; \n", NIL); } else { Printf(sfun->code, "%s\n", tm); } } Printv(sfun->def, inFirstArg ? "" : ", ", name, NIL); if ((tm = Getattr(p,"tmap:scheck"))) { Replaceall(tm,"$target", lname); Replaceall(tm,"$source", name); Replaceall(tm,"$input", name); replaceRClass(tm, Getattr(p, "type")); Printf(sfun->code,"%s\n",tm); } curP = p; if ((tm = Getattr(p,"tmap:in"))) { Replaceall(tm,"$target", lname); Replaceall(tm,"$source", name); Replaceall(tm,"$input", name); if (Getattr(p,"wrap:disown") || (Getattr(p,"tmap:in:disown"))) { Replaceall(tm,"$disown","SWIG_POINTER_DISOWN"); } else { Replaceall(tm,"$disown","0"); } if(funcptr_name) { /* have us a function pointer */ Printf(f->code, "if(TYPEOF(%s) != CLOSXP) {\n", name); Replaceall(tm,"$R_class", ""); } else { replaceRClass(tm, Getattr(p, "type")); } Printf(f->code,"%s\n",tm); if(funcptr_name) Printf(f->code, "} else {\n%s = %s;\nR_SWIG_pushCallbackFunctionData(%s, NULL);\n}\n", lname, funcptr_name, name); Printv(f->def, inFirstArg ? "" : ", ", "SEXP ", name, NIL); if (Len(name) != 0) inFirstArg = false; p = Getattr(p,"tmap:in:next"); } else { p = nextSibling(p); } tm = Swig_typemap_lookup("rtype", curP, "", 0); if(tm) { replaceRClass(tm, Getattr(curP, "type")); } Printf(s_inputTypes, "%s'%s'", inFirstType ? "" : ", ", tm); Printf(s_inputMap, "%s%s='%s'", inFirstType ? "" : ", ", name, tm); inFirstType = false; if(funcptr_name) Delete(funcptr_name); } /* end of looping over parameters. */ if(addCopyParam) { Printf(sfun->def, "%s.copy = FALSE", nargs > 0 ? ", " : ""); Printf(f->def, "%sSEXP s_swig_copy", nargs > 0 ? ", " : ""); Printf(sargs, "as.logical(.copy), "); } Printv(f->def, ")\n{\n", NIL); Printv(sfun->def, ")\n{\n", NIL); /* Insert cleanup code */ String *cleanup = NewString(""); for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } String *outargs = NewString(""); int numOutArgs = isVoidReturnType ? -1 : 0; for(p = l, i = 0; p; i++) { if((tm = Getattr(p, "tmap:argout"))) { // String *lname = Getattr(p, "lname"); numOutArgs++; String *pos = NewStringf("%d", numOutArgs); Replaceall(tm,"$source", Getattr(p, "lname")); Replaceall(tm,"$result", "r_ans"); Replaceall(tm,"$n", pos); // The position into which to store the answer. Replaceall(tm,"$arg", Getattr(p, "emit:input")); Replaceall(tm,"$input", Getattr(p, "emit:input")); Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); Printf(outargs, "%s\n", tm); p = Getattr(p,"tmap:argout:next"); } else p = nextSibling(p); } String *actioncode = emit_action(n); /* Deal with the explicit return value. */ if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { SwigType *retType = Getattr(n, "type"); //Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no"); /* if(SwigType_isarray(retType)) { defineArrayAccessors(retType); } */ Replaceall(tm,"$1", Swig_cresult_name()); Replaceall(tm,"$result", "r_ans"); replaceRClass(tm, retType); if (GetFlag(n,"feature:new")) { Replaceall(tm, "$owner", "R_SWIG_OWNER"); } else { Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); } #if 0 if(addCopyParam) { Printf(f->code, "if(LOGICAL(s_swig_copy)[0]) {\n"); Printf(f->code, "/* Deal with returning a reference. */\nr_ans = R_NilValue;\n"); Printf(f->code, "}\n else {\n"); } #endif Printf(f->code, "%s\n", tm); #if 0 if(addCopyParam) Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */ #endif } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), fname); } if(Len(outargs)) { Wrapper_add_local(f, "R_OutputValues", "SEXP R_OutputValues"); String *tmp = NewString(""); if(!isVoidReturnType) Printf(tmp, "Rf_protect(r_ans);\n"); Printf(tmp, "Rf_protect(R_OutputValues = Rf_allocVector(VECSXP,%d));\nr_nprotect += %d;\n", numOutArgs + !isVoidReturnType, isVoidReturnType ? 1 : 2); if(!isVoidReturnType) Printf(tmp, "SET_VECTOR_ELT(R_OutputValues, 0, r_ans);\n"); Printf(tmp, "r_ans = R_OutputValues;\n"); Insert(outargs, 0, tmp); Delete(tmp); Printv(f->code, outargs, NIL); Delete(outargs); } /* Output cleanup code */ Printv(f->code, cleanup, NIL); Delete(cleanup); /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } Printv(f->code, UnProtectWrapupCode, NIL); /*If the user gave us something to convert the result in */ if ((tm = Swig_typemap_lookup("scoerceout", n, Swig_cresult_name(), sfun))) { Replaceall(tm,"$source","ans"); Replaceall(tm,"$result","ans"); replaceRClass(tm, Getattr(n, "type")); Chop(tm); } Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname, "', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL); if(Len(tm)) { Printf(sfun->code, "%s\n\n", tm); if (constructor) { String *finalizer = NewString(iname); Replace(finalizer, "new_", "", DOH_REPLACE_FIRST); Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s)\n", finalizer); } Printf(sfun->code, "ans\n"); } if (destructor) Printv(f->code, "R_ClearExternalPtr(self);\n", NIL); Printv(f->code, "return r_ans;\n}\n", NIL); Printv(sfun->code, "\n}", NIL); /* Substitute the function name */ Replaceall(f->code,"$symname",iname); Wrapper_print(f, f_wrapper); Wrapper_print(sfun, sfile); Printf(sfun->code, "\n# End of %s\n", iname); tm = Swig_typemap_lookup("rtype", n, "", 0); if(tm) { SwigType *retType = Getattr(n, "type"); replaceRClass(tm, retType); } Printv(sfile, "attr(`", sfname, "`, 'returnType') = '", isVoidReturnType ? "void" : (tm ? tm : ""), "'\n", NIL); if(nargs > 0) Printv(sfile, "attr(`", sfname, "`, \"inputTypes\") = c(", s_inputTypes, ")\n", NIL); Printv(sfile, "class(`", sfname, "`) = c(\"SWIGFunction\", class('", sfname, "'))\n\n", NIL); if (memoryProfile) { Printv(sfile, "memory.profile()\n", NIL); } if (aggressiveGc) { Printv(sfile, "gc()\n", NIL); } // Printv(sfile, "setMethod('", name, "', '", name, "', ", iname, ")\n\n\n"); /* If we are dealing with a method in an C++ class, then add the name of the R function and its definition. XXX need to figure out how to store the Wrapper if possible in the hash/list. Would like to be able to do this so that we can potentially insert */ if(processing_member_access_function || processing_class_member_function) { addAccessor(member_name, sfun, iname); } if (Getattr(n, "sym:overloaded") && !Getattr(n, "sym:nextSibling")) { dispatchFunction(n); } addRegistrationRoutine(wname, addCopyParam ? nargs +1 : nargs); DelWrapper(f); DelWrapper(sfun); Delete(sargs); Delete(sfname); return SWIG_OK; } /***************************************************** Add the specified routine name to the collection of generated routines that are called from R functions. This is used to register the routines with R for resolving symbols. rname - the name of the routine nargs - the number of arguments it expects. ******************************************************/ int R::addRegistrationRoutine(String *rname, int nargs) { if(!registrationTable) registrationTable = NewHash(); String *el = NewStringf("{\"%s\", (DL_FUNC) &%s, %d}", rname, rname, nargs); Setattr(registrationTable, rname, el); return SWIG_OK; } /***************************************************** Write the registration information to an array and create the initialization routine for registering these. ******************************************************/ int R::outputRegistrationRoutines(File *out) { int i, n; if(!registrationTable) return(0); if(inCPlusMode) Printf(out, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n"); Printf(out, "#include \n\n"); if(inCPlusMode) Printf(out, "#ifdef __cplusplus\n}\n#endif\n\n"); Printf(out, "SWIGINTERN R_CallMethodDef CallEntries[] = {\n"); List *keys = Keys(registrationTable); n = Len(keys); for(i = 0; i < n; i++) Printf(out, " %s,\n", Getattr(registrationTable, Getitem(keys, i))); Printf(out, " {NULL, NULL, 0}\n};\n\n"); if(!noInitializationCode) { if (inCPlusMode) Printv(out, "extern \"C\" ", NIL); Printf(out, "SWIGEXPORT void R_init_%s(DllInfo *dll) {\n", Rpackage); Printf(out, "%sR_registerRoutines(dll, NULL, CallEntries, NULL, NULL);\n", tab4); if(Len(s_init_routine)) { Printf(out, "\n%s\n", s_init_routine); } Printf(out, "}\n"); } return n; } /**************************************************************************** Process a struct, union or class declaration in the source code, or an anonymous typedef struct *****************************************************************************/ //XXX What do we need to do here - // Define an S4 class to refer to this. void R::registerClass(Node *n) { String *name = Getattr(n, "name"); String *kind = Getattr(n, "kind"); if (debugMode) Swig_print_node(n); String *sname = NewStringf("_p%s", SwigType_manglestr(name)); if(!Getattr(SClassDefs, sname)) { Setattr(SClassDefs, sname, sname); String *base; if(Strcmp(kind, "class") == 0) { base = NewString(""); List *l = Getattr(n, "bases"); if(Len(l)) { Printf(base, "c("); for(int i = 0; i < Len(l); i++) { registerClass(Getitem(l, i)); Printf(base, "'_p%s'%s", SwigType_manglestr(Getattr(Getitem(l, i), "name")), i < Len(l)-1 ? ", " : ""); } Printf(base, ")"); } else { base = NewString("'C++Reference'"); } } else base = NewString("'ExternalReference'"); Printf(s_classes, "setClass('%s', contains = %s)\n", sname, base); Delete(base); } } int R::classDeclaration(Node *n) { String *name = Getattr(n, "name"); String *kind = Getattr(n, "kind"); if (debugMode) Swig_print_node(n); registerClass(n); /* If we have a typedef union { ... } U, then we never get to see the typedef via a regular call to typedefHandler. Instead, */ if(Getattr(n, "unnamed") && Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "typedef") == 0 && Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) { if (debugMode) Printf(stdout, "Typedef in the class declaration for %s\n", name); // typedefHandler(n); } bool opaque = GetFlag(n, "feature:opaque") ? true : false; if(opaque) opaqueClassDeclaration = name; int status = Language::classDeclaration(n); opaqueClassDeclaration = NULL; // OutputArrayMethod(name, class_member_functions, sfile); if (class_member_functions) OutputMemberReferenceMethod(name, 0, class_member_functions, sfile); if (class_member_set_functions) OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile); if(class_member_functions) { Delete(class_member_functions); class_member_functions = NULL; } if(class_member_set_functions) { Delete(class_member_set_functions); class_member_set_functions = NULL; } if (Getattr(n, "has_destructor")) { Printf(sfile, "setMethod('delete', '_p%s', function(obj) {delete%s(obj)})\n", getRClassName(Getattr(n, "name")), getRClassName(Getattr(n, "name"))); } if(!opaque && !Strcmp(kind, "struct") && copyStruct) { String *def = NewStringf("setClass(\"%s\",\n%srepresentation(\n", name, tab4); bool firstItem = true; for(Node *c = firstChild(n); c; ) { String *elName; String *tp; elName = Getattr(c, "name"); String *elKind = Getattr(c, "kind"); if (!Equal(elKind, "variable")) { c = nextSibling(c); continue; } if (!Len(elName)) { c = nextSibling(c); continue; } #if 0 tp = getRType(c); #else tp = Swig_typemap_lookup("rtype", c, "", 0); if(!tp) { c = nextSibling(c); continue; } if (Strstr(tp, "R_class")) { c = nextSibling(c); continue; } if (Strcmp(tp, "character") && Strstr(Getattr(c, "decl"), "p.")) { c = nextSibling(c); continue; } if (!firstItem) { Printf(def, ",\n"); } // else //XXX How can we tell if this is already done. // SwigType_push(elType, elDecl); // returns "" tp = processType(elType, c, NULL); // Printf(stdout, " elType %p\n", elType); // tp = getRClassNameCopyStruct(Getattr(c, "type"), 1); #endif String *elNameT = replaceInitialDash(elName); Printf(def, "%s%s = \"%s\"", tab8, elNameT, tp); firstItem = false; Delete(tp); Delete(elNameT); c = nextSibling(c); } Printf(def, "),\n%scontains = \"RSWIGStruct\")\n", tab8); Printf(s_classes, "%s\n\n# End class %s\n\n", def, name); generateCopyRoutines(n); Delete(def); } return status; } /*************************************************************** Create the C routines that copy an S object of the class given by the given struct definition in Node *n to the C value and also the routine that goes from the C routine to an object of this S class. ****************************************************************/ /*XXX Clean up the toCRef - make certain the names are correct for the types, etc. in all cases. */ int R::generateCopyRoutines(Node *n) { Wrapper *copyToR = NewWrapper(); Wrapper *copyToC = NewWrapper(); String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); String *kind = Getattr(n, "kind"); String *type; if(Len(tdname)) { type = Copy(tdname); } else { type = NewStringf("%s %s", kind, name); } String *mangledName = SwigType_manglestr(name); if (debugMode) Printf(stdout, "generateCopyRoutines: name = %s, %s\n", name, type); Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n", mangledName, name); Printf(copyToC->def, "CopyToC%s = function(value, obj)\n{\n", mangledName); Node *c = firstChild(n); for(; c; c = nextSibling(c)) { String *elName = Getattr(c, "name"); if (!Len(elName)) { continue; } String *elKind = Getattr(c, "kind"); if (!Equal(elKind, "variable")) { continue; } String *tp = Swig_typemap_lookup("rtype", c, "", 0); if(!tp) { continue; } if (Strstr(tp, "R_class")) { continue; } if (Strcmp(tp, "character") && Strstr(Getattr(c, "decl"), "p.")) { continue; } /* The S functions to get and set the member value. */ String *elNameT = replaceInitialDash(elName); Printf(copyToR->code, "obj@%s = value$%s;\n", elNameT, elNameT); Printf(copyToC->code, "obj$%s = value@%s;\n", elNameT, elNameT); Delete(elNameT); } Printf(copyToR->code, "obj;\n}\n\n"); String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref. Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName); Wrapper_print(copyToR, sfile); Printf(copyToC->code, "obj\n}\n\n"); Wrapper_print(copyToC, sfile); Printf(sfile, "# Start definition of copy methods for %s\n", rclassName); Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName, mangledName); Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName, mangledName); Printf(sfile, "# End definition of copy methods for %s\n", rclassName); Printf(sfile, "# End definition of copy functions & methods for %s\n", rclassName); String *m = NewStringf("%sCopyToR", name); addNamespaceMethod(m); char *tt = Char(m); tt[Len(m)-1] = 'C'; addNamespaceMethod(m); Delete(m); Delete(rclassName); Delete(mangledName); DelWrapper(copyToR); DelWrapper(copyToC); return SWIG_OK; } /***** Called when there is a typedef to be invoked. XXX Needs to be enhanced or split to handle the case where we have a typedef within a classDeclaration emission because the struct/union/etc. is anonymous. ******/ int R::typedefHandler(Node *n) { SwigType *tp = Getattr(n, "type"); String *type = Getattr(n, "type"); if (debugMode) Printf(stdout, " %s\n", Getattr(n, "name")); processType(tp, n); if(Strncmp(type, "struct ", 7) == 0) { String *name = Getattr(n, "name"); char *trueName = Char(type); trueName += 7; if (debugMode) Printf(stdout, " Defining S class %s\n", trueName); Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n", SwigType_manglestr(name)); } return Language::typedefHandler(n); } /********************* Called when processing a field in a "class", i.e. struct, union or actual class. We set a state variable so that we can correctly interpret the resulting functionWrapper() call and understand that it is for a field element. **********************/ int R::membervariableHandler(Node *n) { SwigType *t = Getattr(n, "type"); processType(t, n, NULL); processing_member_access_function = 1; member_name = Getattr(n,"sym:name"); if (debugMode) Printf(stdout, " name = %s, sym:name = %s\n", Getattr(n, "name"), member_name); int status(Language::membervariableHandler(n)); if(!opaqueClassDeclaration && debugMode) Printf(stdout, " %s %s\n", Getattr(n, "name"), Getattr(n, "type")); processing_member_access_function = 0; member_name = NULL; return status; } /* This doesn't seem to get used so leave it out for the moment. */ String * R::runtimeCode() { String *s = Swig_include_sys("rrun.swg"); if (!s) { Printf(stdout, "*** Unable to open 'rrun.swg'\n"); s = NewString(""); } return s; } /** Called when SWIG wants to initialize this We initialize anythin we want here. Most importantly, tell SWIG where to find the files (e.g. r.swg) for this module. Use Swig_mark_arg() to tell SWIG that it is understood and not to throw an error. **/ void R::main(int argc, char *argv[]) { bool cppcast = true; init(); Preprocessor_define("SWIGR 1", 0); SWIG_library_directory("r"); SWIG_config_file("r.swg"); debugMode = false; copyStruct = true; memoryProfile = false; aggressiveGc = false; inCPlusMode = false; outputNamespaceInfo = false; noInitializationCode = false; this->Argc = argc; this->Argv = argv; allow_overloading();// can we support this? for(int i = 0; i < argc; i++) { if(strcmp(argv[i], "-package") == 0) { Swig_mark_arg(i); i++; Swig_mark_arg(i); Rpackage = argv[i]; } else if(strcmp(argv[i], "-dll") == 0) { Swig_mark_arg(i); i++; Swig_mark_arg(i); DllName = argv[i]; } else if(strcmp(argv[i], "-help") == 0) { showUsage(); } else if(strcmp(argv[i], "-namespace") == 0) { outputNamespaceInfo = true; Swig_mark_arg(i); } else if(!strcmp(argv[i], "-no-init-code")) { noInitializationCode = true; Swig_mark_arg(i); } else if(!strcmp(argv[i], "-c++")) { inCPlusMode = true; Swig_mark_arg(i); Printf(s_classes, "setClass('C++Reference', contains = 'ExternalReference')\n"); } else if(!strcmp(argv[i], "-debug")) { debugMode = true; Swig_mark_arg(i); } else if (!strcmp(argv[i],"-cppcast")) { cppcast = true; Swig_mark_arg(i); } else if (!strcmp(argv[i],"-nocppcast")) { cppcast = false; Swig_mark_arg(i); } else if (!strcmp(argv[i],"-copystruct")) { copyStruct = true; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-nocopystruct")) { copyStruct = false; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-memoryprof")) { memoryProfile = true; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-nomemoryprof")) { memoryProfile = false; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-aggressivegc")) { aggressiveGc = true; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-noaggressivegc")) { aggressiveGc = false; Swig_mark_arg(i); } if (cppcast) { Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); } if (debugMode) { Swig_typemap_search_debug_set(); Swig_typemap_used_debug_set(); Swig_typemap_register_debug_set(); Swig_file_debug_set(); } /// copyToR copyToC functions. } } /* Could make this work for String or File and then just store the resulting string rather than the collection of arguments and argc. */ int R::outputCommandLineArguments(File *out) { if(Argc < 1 || !Argv || !Argv[0]) return(-1); Printf(out, "\n## Generated via the command line invocation:\n##\t"); for(int i = 0; i < Argc ; i++) { Printf(out, " %s", Argv[i]); } Printf(out, "\n\n\n"); return Argc; } /* How SWIG instantiates an object from this module. See swigmain.cxx */ extern "C" Language *swig_r(void) { return new R(); } /*************************************************************************************/ /* Needs to be reworked. */ String * R::processType(SwigType *t, Node *n, int *nargs) { //XXX Need to handle typedefs, e.g. // a type which is a typedef to a function pointer. SwigType *tmp = Getattr(n, "tdname"); if (debugMode) Printf(stdout, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp); SwigType *td = t; if (expandTypedef(t) && SwigType_istypedef(t)) { SwigType *resolved = SwigType_typedef_resolve_all(t); if (expandTypedef(resolved)) { td = Copy(resolved); } } if(!td) { int count = 0; String *b = getRTypeName(t, &count); if(count && b && !Getattr(SClassDefs, b)) { if (debugMode) Printf(stdout, " Defining class %s\n", b); Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b); Setattr(SClassDefs, b, b); } } if(td) t = td; if(SwigType_isfunctionpointer(t)) { if (debugMode) Printf(stdout, " Defining pointer handler %s\n", t); String *tmp = createFunctionPointerHandler(t, n, nargs); return tmp; } #if 0 SwigType_isfunction(t) && SwigType_ispointer(t) #endif return NULL; } /*************************************************************************************/ swig-3.0.2/Source/Modules/nested.cxx0000664000175000017500000003006112343605122017221 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * nested.cxx * * Nested structs support * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" // Nested classes processing section static Hash *classhash = 0; static String *make_name(Node *n, String *name, SwigType *decl) { int destructor = name && (*(Char(name)) == '~'); if (String *yyrename = Getattr(n, "class_rename")) { String *s = NewString(yyrename); Delattr(n, "class_rename"); if (destructor && (*(Char(s)) != '~')) { Insert(s, 0, "~"); } return s; } if (!name) return 0; return Swig_name_make(n, 0, name, decl, 0); } // C version of add_symbols() static void add_symbols_c(Node *n) { String *decl; String *wrn = 0; String *symname = 0; int iscdecl = Cmp(nodeType(n), "cdecl") == 0; Setattr(n, "ismember", "1"); Setattr(n, "access", "public"); if (Getattr(n, "sym:name")) return; decl = Getattr(n, "decl"); if (!SwigType_isfunction(decl)) { String *name = Getattr(n, "name"); String *makename = Getattr(n, "parser:makename"); if (iscdecl) { String *storage = Getattr(n, "storage"); if (Cmp(storage, "typedef") == 0) { Setattr(n, "kind", "typedef"); } else { SwigType *type = Getattr(n, "type"); String *value = Getattr(n, "value"); Setattr(n, "kind", "variable"); if (value && Len(value)) { Setattr(n, "hasvalue", "1"); } if (type) { SwigType *ty; SwigType *tmp = 0; if (decl) { ty = tmp = Copy(type); SwigType_push(ty, decl); } else { ty = type; } if (!SwigType_ismutable(ty)) { SetFlag(n, "hasconsttype"); SetFlag(n, "feature:immutable"); } if (tmp) Delete(tmp); } if (!type) { Printf(stderr, "notype name %s\n", name); } } } Swig_features_get(Swig_cparse_features(), 0, name, 0, n); if (makename) { symname = make_name(n, makename, 0); Delattr(n, "parser:makename"); /* temporary information, don't leave it hanging around */ } else { makename = name; symname = make_name(n, makename, 0); } if (!symname) { symname = Copy(Getattr(n, "unnamed")); } if (symname) { wrn = Swig_name_warning(n, 0, symname, 0); } } else { String *name = Getattr(n, "name"); SwigType *fdecl = Copy(decl); SwigType *fun = SwigType_pop_function(fdecl); if (iscdecl) { Setattr(n, "kind", "function"); } Swig_features_get(Swig_cparse_features(), 0, name, fun, n); symname = make_name(n, name, fun); wrn = Swig_name_warning(n, 0, symname, fun); Delete(fdecl); Delete(fun); } if (!symname) return; if (GetFlag(n, "feature:ignore")) { /* Only add to C symbol table and continue */ Swig_symbol_add(0, n); } else if (strncmp(Char(symname), "$ignore", 7) == 0) { char *c = Char(symname) + 7; SetFlag(n, "feature:ignore"); if (strlen(c)) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(0, Getfile(n), Getline(n), "%s\n", c + 1); SWIG_WARN_NODE_END(n); } Swig_symbol_add(0, n); } else { Node *c; if ((wrn) && (Len(wrn))) { String *metaname = symname; if (!Getmeta(metaname, "already_warned")) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(0, Getfile(n), Getline(n), "%s\n", wrn); SWIG_WARN_NODE_END(n); Setmeta(metaname, "already_warned", "1"); } } c = Swig_symbol_add(symname, n); if (c != n) { /* symbol conflict attempting to add in the new symbol */ if (Getattr(n, "sym:weak")) { Setattr(n, "sym:name", symname); } else { String *e = NewStringEmpty(); String *en = NewStringEmpty(); String *ec = NewStringEmpty(); int redefined = Swig_need_redefined_warn(n, c, true); if (redefined) { Printf(en, "Identifier '%s' redefined (ignored)", symname); Printf(ec, "previous definition of '%s'", symname); } else { Printf(en, "Redundant redeclaration of '%s'", symname); Printf(ec, "previous declaration of '%s'", symname); } if (Cmp(symname, Getattr(n, "name"))) { Printf(en, " (Renamed from '%s')", SwigType_namestr(Getattr(n, "name"))); } Printf(en, ","); if (Cmp(symname, Getattr(c, "name"))) { Printf(ec, " (Renamed from '%s')", SwigType_namestr(Getattr(c, "name"))); } Printf(ec, "."); SWIG_WARN_NODE_BEGIN(n); if (redefined) { Swig_warning(WARN_PARSE_REDEFINED, Getfile(n), Getline(n), "%s\n", en); Swig_warning(WARN_PARSE_REDEFINED, Getfile(c), Getline(c), "%s\n", ec); } else { Swig_warning(WARN_PARSE_REDUNDANT, Getfile(n), Getline(n), "%s\n", en); Swig_warning(WARN_PARSE_REDUNDANT, Getfile(c), Getline(c), "%s\n", ec); } SWIG_WARN_NODE_END(n); Printf(e, "%s:%d:%s\n%s:%d:%s\n", Getfile(n), Getline(n), en, Getfile(c), Getline(c), ec); Setattr(n, "error", e); Delete(e); Delete(en); Delete(ec); } } } Delete(symname); } /* Strips C-style and C++-style comments from string in-place. */ static void strip_comments(char *string) { int state = 0; /* * 0 - not in comment * 1 - in c-style comment * 2 - in c++-style comment * 3 - in string * 4 - after reading / not in comments * 5 - after reading * in c-style comments * 6 - after reading \ in strings */ char *c = string; while (*c) { switch (state) { case 0: if (*c == '\"') state = 3; else if (*c == '/') state = 4; break; case 1: if (*c == '*') state = 5; *c = ' '; break; case 2: if (*c == '\n') state = 0; else *c = ' '; break; case 3: if (*c == '\"') state = 0; else if (*c == '\\') state = 6; break; case 4: if (*c == '/') { *(c - 1) = ' '; *c = ' '; state = 2; } else if (*c == '*') { *(c - 1) = ' '; *c = ' '; state = 1; } else state = 0; break; case 5: if (*c == '/') state = 0; else state = 1; *c = ' '; break; case 6: state = 3; break; } ++c; } } // Create a %insert with a typedef to make a new name visible to C static Node *create_insert(Node *n, bool noTypedef = false) { // format a typedef String *ccode = Getattr(n, "code"); Push(ccode, " "); if (noTypedef) { Push(ccode, Getattr(n, "name")); Push(ccode, " "); Push(ccode, Getattr(n, "kind")); } else { Push(ccode, Getattr(n, "kind")); Push(ccode, "typedef "); Append(ccode, " "); Append(ccode, Getattr(n, "tdname")); } Append(ccode, ";"); /* Strip comments - further code may break in presence of comments. */ strip_comments(Char(ccode)); /* Make all SWIG created typedef structs/unions/classes unnamed else redefinition errors occur - nasty hack alert. */ if (!noTypedef) { const char *types_array[3] = { "struct", "union", "class" }; for (int i = 0; i < 3; i++) { char *code_ptr = Char(ccode); while (code_ptr) { /* Replace struct name (as in 'struct name {...}' ) with whitespace name will be between struct and opening brace */ code_ptr = strstr(code_ptr, types_array[i]); if (code_ptr) { char *open_bracket_pos; code_ptr += strlen(types_array[i]); open_bracket_pos = strchr(code_ptr, '{'); if (open_bracket_pos) { /* Make sure we don't have something like struct A a; */ char *semi_colon_pos = strchr(code_ptr, ';'); if (!(semi_colon_pos && (semi_colon_pos < open_bracket_pos))) while (code_ptr < open_bracket_pos) *code_ptr++ = ' '; } } } } } { /* Remove SWIG directive %constant which may be left in the SWIG created typedefs */ char *code_ptr = Char(ccode); while (code_ptr) { code_ptr = strstr(code_ptr, "%constant"); if (code_ptr) { char *directive_end_pos = strchr(code_ptr, ';'); if (directive_end_pos) { while (code_ptr <= directive_end_pos) *code_ptr++ = ' '; } } } } Node *newnode = NewHash(); set_nodeType(newnode, "insert"); Setfile(newnode, Getfile(n)); Setline(newnode, Getline(n)); String *code = NewStringEmpty(); Wrapper_pretty_print(ccode, code); Setattr(newnode, "code", code); Delete(code); Delattr(n, "code"); return newnode; } static void insertNodeAfter(Node *n, Node *c) { Node *g = parentNode(n); set_parentNode(c, g); Node *ns = nextSibling(n); if (Node *outer = Getattr(c, "nested:outer")) { while (ns && outer == Getattr(ns, "nested:outer")) { n = ns; ns = nextSibling(n); } } if (!ns) { set_lastChild(g, c); } else { set_nextSibling(c, ns); set_previousSibling(ns, c); } set_nextSibling(n, c); set_previousSibling(c, n); } void Swig_nested_name_unnamed_c_structs(Node *n) { if (!classhash) classhash = Getattr(n, "classes"); Node *c = firstChild(n); while (c) { Node *next = nextSibling(c); if (String *declName = Getattr(c, "nested:unnamed")) { if (Node *outer = Getattr(c, "nested:outer")) { // generate a name String *name = NewStringf("%s_%s", Getattr(outer, "name"), declName); Delattr(c, "nested:unnamed"); // set the name to the class and symbol table Setattr(c, "tdname", name); Setattr(c, "name", name); Swig_symbol_setscope(Getattr(c, "symtab")); Swig_symbol_setscopename(name); // now that we have a name - gather base symbols if (List *publicBases = Getattr(c, "baselist")) { List *bases = Swig_make_inherit_list(name, publicBases, 0); Swig_inherit_base_symbols(bases); Delete(bases); } Setattr(classhash, name, c); // Merge the extension into the symbol table if (Node *am = Getattr(Swig_extend_hash(), name)) { Swig_extend_merge(c, am); Swig_extend_append_previous(c, am); Delattr(Swig_extend_hash(), name); } Swig_symbol_popscope(); // process declarations following this type (assign correct new type) SwigType *ty = Copy(name); Node *decl = nextSibling(c); List *declList = NewList(); while (decl && Getattr(decl, "nested:unnamedtype") == c) { Setattr(decl, "type", ty); Append(declList, decl); Delattr(decl, "nested:unnamedtype"); SetFlag(decl, "feature:immutable"); add_symbols_c(decl); decl = nextSibling(decl); } Delete(ty); Swig_symbol_setscope(Swig_symbol_global_scope()); add_symbols_c(c); Node *ins = create_insert(c); insertNodeAfter(c, ins); removeNode(c); insertNodeAfter(n, c); Delete(ins); Delattr(c, "nested:outer"); } else { // global unnamed struct - ignore it and it's instances SetFlag(c, "feature:ignore"); while (next && Getattr(next, "nested:unnamedtype") == c) { SetFlag(next, "feature:ignore"); next = nextSibling(next); } c = next; continue; } } else if (cparse_cplusplusout) { if (Getattr(c, "nested:outer")) { Node *ins = create_insert(c, true); insertNodeAfter(c, ins); Delete(ins); Delattr(c, "nested:outer"); } } // process children Swig_nested_name_unnamed_c_structs(c); c = next; } } static void remove_outer_class_reference(Node *n) { for (Node *c = firstChild(n); c; c = nextSibling(c)) { if (GetFlag(c, "feature:flatnested") || Language::instance()->nestedClassesSupport() == Language::NCS_None) { Delattr(c, "nested:outer"); remove_outer_class_reference(c); } } } void Swig_nested_process_classes(Node *n) { Node *c = firstChild(n); while (c) { Node *next = nextSibling(c); if (!Getattr(c, "templatetype")) { if (GetFlag(c, "nested") && (GetFlag(c, "feature:flatnested") || Language::instance()->nestedClassesSupport() == Language::NCS_None)) { removeNode(c); if (!checkAttribute(c, "access", "public")) SetFlag(c, "feature:ignore"); else if (Strcmp(nodeType(n),"extend") == 0 && Strcmp(nodeType(parentNode(n)),"class") == 0) insertNodeAfter(parentNode(n), c); else insertNodeAfter(n, c); } Swig_nested_process_classes(c); } c = next; } remove_outer_class_reference(n); } swig-3.0.2/Source/Modules/javascript.cxx0000664000175000017500000022075112343605122020114 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * javascript.cxx * * Javascript language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" /** * Enables extra debugging information in typemaps. */ static bool js_template_enable_debug = false; #define ERR_MSG_ONLY_ONE_ENGINE_PLEASE "Only one engine can be specified at a time." // keywords used for state variables #define NAME "name" #define NAME_MANGLED "name_mangled" #define TYPE "type" #define TYPE_MANGLED "type_mangled" #define WRAPPER_NAME "wrapper" #define IS_IMMUTABLE "is_immutable" #define IS_STATIC "is_static" #define IS_ABSTRACT "is_abstract" #define GETTER "getter" #define SETTER "setter" #define PARENT "parent" #define CTOR "ctor" #define CTOR_WRAPPERS "ctor_wrappers" #define CTOR_DISPATCHERS "ctor_dispatchers" #define DTOR "dtor" #define ARGCOUNT "wrap:argc" #define HAS_TEMPLATES "has_templates" #define FORCE_CPP "force_cpp" #define RESET true // keys for global state variables #define CREATE_NAMESPACES "create_namespaces" #define REGISTER_NAMESPACES "register_namespaces" #define INITIALIZER "initializer" // keys for class scoped state variables #define MEMBER_VARIABLES "member_variables" #define MEMBER_FUNCTIONS "member_functions" #define STATIC_FUNCTIONS "static_functions" #define STATIC_VARIABLES "static_variables" /** * A convenience class to manage state variables for emitters. * The implementation delegates to SWIG Hash DOHs and provides * named sub-hashes for class, variable, and function states. */ class JSEmitterState { public: JSEmitterState(); ~JSEmitterState(); DOH *globals(); DOH *globals(const char *key, DOH *initial = 0); DOH *clazz(bool reset = false); DOH *clazz(const char *key, DOH *initial = 0); DOH *function(bool reset = false); DOH *function(const char *key, DOH *initial = 0); DOH *variable(bool reset = false); DOH *variable(const char *key, DOH *initial = 0); static int IsSet(DOH *val); private: DOH *getState(const char *key, bool reset = false); Hash *globalHash; }; /** * A convenience class that wraps a code snippet used as template * for code generation. */ class Template { public: Template(const String *code); Template(const String *code, const String *templateName); Template(const Template & other); ~Template(); String *str(); Template & replace(const String *pattern, const String *repl); Template & print(DOH *doh); Template & pretty_print(DOH *doh); void operator=(const Template & t); Template & trim(); private: String *code; String *templateName; }; /** * JSEmitter represents an abstraction of javascript code generators * for different javascript engines. **/ class JSEmitter { protected: typedef JSEmitterState State; enum MarshallingMode { Setter, Getter, Ctor, Function }; public: enum JSEngine { JavascriptCore, V8, NodeJS }; JSEmitter(JSEngine engine); virtual ~ JSEmitter(); /** * Opens output files and temporary output DOHs. */ virtual int initialize(Node *n); /** * Writes all collected code into the output file(s). */ virtual int dump(Node *n) = 0; /** * Cleans up all open output DOHs. */ virtual int close() = 0; /** * Switches the context for code generation. * * Classes, global variables and global functions may need to * be registered in certain static tables. * This method should be used to switch output DOHs correspondingly. */ virtual int switchNamespace(Node *); /** * Invoked at the beginning of the classHandler. */ virtual int enterClass(Node *); /** * Invoked at the end of the classHandler. */ virtual int exitClass(Node *) { return SWIG_OK; }; /** * Invoked at the beginning of the variableHandler. */ virtual int enterVariable(Node *); /** * Invoked at the end of the variableHandler. */ virtual int exitVariable(Node *) { return SWIG_OK; }; /** * Invoked at the beginning of the functionHandler. */ virtual int enterFunction(Node *); /** * Invoked at the end of the functionHandler. */ virtual int exitFunction(Node *) { return SWIG_OK; }; /** * Invoked by functionWrapper callback after call to Language::functionWrapper. */ virtual int emitWrapperFunction(Node *n); /** * Invoked from constantWrapper after call to Language::constantWrapper. **/ virtual int emitConstant(Node *n); /** * Registers a given code snippet for a given key name. * * This method is called by the fragmentDirective handler * of the JAVASCRIPT language module. **/ int registerTemplate(const String *name, const String *code); /** * Retrieve the code template registered for a given name. */ Template getTemplate(const String *name); State & getState(); protected: /** * Generates code for a constructor function. */ virtual int emitCtor(Node *n); /** * Generates code for a destructor function. */ virtual int emitDtor(Node *n); /** * Generates code for a function. */ virtual int emitFunction(Node *n, bool is_member, bool is_static); virtual int emitFunctionDispatcher(Node *n, bool /*is_member */ ); /** * Generates code for a getter function. */ virtual int emitGetter(Node *n, bool is_member, bool is_static); /** * Generates code for a setter function. */ virtual int emitSetter(Node *n, bool is_member, bool is_static); virtual void marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static) = 0; virtual String *emitInputTypemap(Node *n, Parm *params, Wrapper *wrapper, String *arg); virtual void marshalOutput(Node *n, ParmList *params, Wrapper *wrapper, String *actioncode, const String *cresult = 0, bool emitReturnVariable = true); virtual void emitCleanupCode(Node *n, Wrapper *wrapper, ParmList *params); /** * Helper function to retrieve the first parent class node. */ Node *getBaseClass(Node *n); Parm *skipIgnoredArgs(Parm *p); virtual int createNamespace(String *scope); virtual Hash *createNamespaceEntry(const char *name, const char *parent); virtual int emitNamespaces() = 0; protected: JSEngine engine; Hash *templates; State state; // contains context specific data (DOHs) // to allow generation of namespace related code // which are switched on namespace change Hash *namespaces; Hash *current_namespace; String *defaultResultName; File *f_wrappers; }; /* factory methods for concrete JSEmitters: */ JSEmitter *swig_javascript_create_JSCEmitter(); JSEmitter *swig_javascript_create_V8Emitter(); JSEmitter *swig_javascript_create_NodeJSEmitter(); /********************************************************************** * JAVASCRIPT: SWIG module implementation **********************************************************************/ class JAVASCRIPT:public Language { public: JAVASCRIPT():emitter(NULL) { } ~JAVASCRIPT() { delete emitter; } virtual int functionHandler(Node *n); virtual int globalfunctionHandler(Node *n); virtual int variableHandler(Node *n); virtual int globalvariableHandler(Node *n); virtual int staticmemberfunctionHandler(Node *n); virtual int classHandler(Node *n); virtual int functionWrapper(Node *n); virtual int constantWrapper(Node *n); virtual void main(int argc, char *argv[]); virtual int top(Node *n); /** * Registers all %fragments assigned to section "templates". **/ virtual int fragmentDirective(Node *n); public: virtual String *getNSpace() const; private: JSEmitter *emitter; }; /* --------------------------------------------------------------------- * functionWrapper() * * Low level code generator for functions * --------------------------------------------------------------------- */ int JAVASCRIPT::functionWrapper(Node *n) { // note: the default implementation only prints a message // Language::functionWrapper(n); emitter->emitWrapperFunction(n); return SWIG_OK; } /* --------------------------------------------------------------------- * functionHandler() * * Function handler for generating wrappers for functions * --------------------------------------------------------------------- */ int JAVASCRIPT::functionHandler(Node *n) { if (GetFlag(n, "isextension") == 1) { SetFlag(n, "ismember"); } emitter->enterFunction(n); Language::functionHandler(n); emitter->exitFunction(n); return SWIG_OK; } /* --------------------------------------------------------------------- * globalfunctionHandler() * * Function handler for generating wrappers for functions * --------------------------------------------------------------------- */ int JAVASCRIPT::globalfunctionHandler(Node *n) { emitter->switchNamespace(n); Language::globalfunctionHandler(n); return SWIG_OK; } /* --------------------------------------------------------------------- * staticmemberfunctionHandler() * * Function handler for generating wrappers for static member functions * --------------------------------------------------------------------- */ int JAVASCRIPT::staticmemberfunctionHandler(Node *n) { /* * Note: storage=static is removed by Language::staticmemberfunctionHandler. * So, don't rely on that after here. Instead use the state variable which is * set by JSEmitter::enterFunction(). */ Language::staticmemberfunctionHandler(n); return SWIG_OK; } /* --------------------------------------------------------------------- * variableHandler() * * Function handler for generating wrappers for variables * --------------------------------------------------------------------- */ int JAVASCRIPT::variableHandler(Node *n) { emitter->enterVariable(n); Language::variableHandler(n); emitter->exitVariable(n); return SWIG_OK; } /* --------------------------------------------------------------------- * globalvariableHandler() * * Function handler for generating wrappers for global variables * --------------------------------------------------------------------- */ int JAVASCRIPT::globalvariableHandler(Node *n) { emitter->switchNamespace(n); Language::globalvariableHandler(n); return SWIG_OK; } /* --------------------------------------------------------------------- * constantHandler() * * Function handler for generating wrappers for constants * --------------------------------------------------------------------- */ int JAVASCRIPT::constantWrapper(Node *n) { emitter->switchNamespace(n); // Note: callbacks trigger this wrapper handler // TODO: handle callback declarations if (Equal(Getattr(n, "kind"), "function")) { return SWIG_OK; } // TODO: the emitter for constants must be implemented in a cleaner way // currently we treat it like a read-only variable // however, there is a remaining bug with function pointer constants // which could be fixed with a cleaner approach emitter->emitConstant(n); return SWIG_OK; } /* --------------------------------------------------------------------- * classHandler() * * Function handler for generating wrappers for class * --------------------------------------------------------------------- */ int JAVASCRIPT::classHandler(Node *n) { emitter->switchNamespace(n); emitter->enterClass(n); Language::classHandler(n); emitter->exitClass(n); return SWIG_OK; } int JAVASCRIPT::fragmentDirective(Node *n) { // catch all fragment directives that have "templates" as location // and register them at the emitter. String *section = Getattr(n, "section"); if (Equal(section, "templates")) { emitter->registerTemplate(Getattr(n, "value"), Getattr(n, "code")); } else { Swig_fragment_register(n); } return SWIG_OK; } String *JAVASCRIPT::getNSpace() const { return Language::getNSpace(); } /* --------------------------------------------------------------------- * top() * * Function handler for processing top node of the parse tree * Wrapper code generation essentially starts from here * --------------------------------------------------------------------- */ int JAVASCRIPT::top(Node *n) { emitter->initialize(n); Language::top(n); emitter->dump(n); emitter->close(); return SWIG_OK; } static const char *usage = (char *) "\ Javascript Options (available with -javascript)\n\ -jsc - creates a JavascriptCore extension \n\ -v8 - creates a v8 extension \n\ -node - creates a node.js extension \n\ -debug-codetemplates - generates information about the origin of code templates\n"; /* --------------------------------------------------------------------- * main() * * Entry point for the JAVASCRIPT module * --------------------------------------------------------------------- */ void JAVASCRIPT::main(int argc, char *argv[]) { // Set javascript subdirectory in SWIG library SWIG_library_directory("javascript"); int engine = -1; for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-v8") == 0) { if (engine != -1) { Printf(stderr, ERR_MSG_ONLY_ONE_ENGINE_PLEASE); SWIG_exit(-1); } Swig_mark_arg(i); engine = JSEmitter::V8; } else if (strcmp(argv[i], "-jsc") == 0) { if (engine != -1) { Printf(stderr, ERR_MSG_ONLY_ONE_ENGINE_PLEASE); SWIG_exit(-1); } Swig_mark_arg(i); engine = JSEmitter::JavascriptCore; } else if (strcmp(argv[i], "-node") == 0) { if (engine != -1) { Printf(stderr, ERR_MSG_ONLY_ONE_ENGINE_PLEASE); SWIG_exit(-1); } Swig_mark_arg(i); engine = JSEmitter::NodeJS; } else if (strcmp(argv[i], "-debug-codetemplates") == 0) { Swig_mark_arg(i); js_template_enable_debug = true; } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); return; } } } switch (engine) { case JSEmitter::V8: { emitter = swig_javascript_create_V8Emitter(); Preprocessor_define("SWIG_JAVASCRIPT_V8 1", 0); SWIG_library_directory("javascript/v8"); // V8 API is C++, so output must be C++ compatibile even when wrapping C code if (!cparse_cplusplus) { Swig_cparse_cplusplusout(1); } break; } case JSEmitter::JavascriptCore: { emitter = swig_javascript_create_JSCEmitter(); Preprocessor_define("SWIG_JAVASCRIPT_JSC 1", 0); SWIG_library_directory("javascript/jsc"); break; } case JSEmitter::NodeJS: { emitter = swig_javascript_create_V8Emitter(); Preprocessor_define("SWIG_JAVASCRIPT_V8 1", 0); Preprocessor_define("BUILDING_NODE_EXTENSION 1", 0); SWIG_library_directory("javascript/v8"); break; } default: { Printf(stderr, "SWIG Javascript: Unknown engine. Please specify one of '-jsc', '-v8' or '-node'.\n"); SWIG_exit(-1); break; } } // Add a symbol to the parser for conditional compilation Preprocessor_define("SWIGJAVASCRIPT 1", 0); // Add typemap definitions SWIG_typemap_lang("javascript"); // Set configuration file SWIG_config_file("javascript.swg"); allow_overloading(); } /* ----------------------------------------------------------------------------- * swig_javascript() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_javascript() { return new JAVASCRIPT(); } extern "C" Language *swig_javascript(void) { return new_swig_javascript(); } /********************************************************************** * Emitter implementations **********************************************************************/ /* ----------------------------------------------------------------------------- * JSEmitter() * ----------------------------------------------------------------------------- */ JSEmitter::JSEmitter(JSEmitter::JSEngine engine) : engine(engine), templates(NewHash()), namespaces(NULL), current_namespace(NULL), defaultResultName(NewString("result")), f_wrappers(NULL) { } /* ----------------------------------------------------------------------------- * ~JSEmitter() * ----------------------------------------------------------------------------- */ JSEmitter::~JSEmitter() { Delete(templates); } /* ----------------------------------------------------------------------------- * JSEmitter::RegisterTemplate() : Registers a code template * * Note: this is used only by JAVASCRIPT::fragmentDirective(). * ----------------------------------------------------------------------------- */ int JSEmitter::registerTemplate(const String *name, const String *code) { if (!State::IsSet(state.globals(HAS_TEMPLATES))) { SetFlag(state.globals(), HAS_TEMPLATES); } return Setattr(templates, name, code); } /* ----------------------------------------------------------------------------- * JSEmitter::getTemplate() : Provides a registered code template * ----------------------------------------------------------------------------- */ Template JSEmitter::getTemplate(const String *name) { String *templ = Getattr(templates, name); if (!templ) { Printf(stderr, "Could not find template %s\n.", name); SWIG_exit(EXIT_FAILURE); } Template t(templ, name); return t; } JSEmitterState & JSEmitter::getState() { return state; } int JSEmitter::initialize(Node * /*n */ ) { if (namespaces != NULL) { Delete(namespaces); } namespaces = NewHash(); Hash *global_namespace = createNamespaceEntry("exports", 0); Setattr(namespaces, "::", global_namespace); current_namespace = global_namespace; f_wrappers = NewString(""); return SWIG_OK; } /* --------------------------------------------------------------------- * skipIgnoredArgs() * --------------------------------------------------------------------- */ Parm *JSEmitter::skipIgnoredArgs(Parm *p) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } return p; } /* ----------------------------------------------------------------------------- * JSEmitter::getBaseClass() : the node of the base class or NULL * * Note: the first base class is provided. Multiple inheritance is not * supported. * ----------------------------------------------------------------------------- */ Node *JSEmitter::getBaseClass(Node *n) { // retrieve the first base class that is not %ignored List *baselist = Getattr(n, "bases"); if (baselist) { Iterator base = First(baselist); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } return base.item; } return NULL; } /* ----------------------------------------------------------------------------- * JSEmitter::emitWrapperFunction() : dispatches emitter functions. * * This allows to have small sized, dedicated emitting functions. * All state dependent branching is done here. * ----------------------------------------------------------------------------- */ int JSEmitter::emitWrapperFunction(Node *n) { int ret = SWIG_OK; String *kind = Getattr(n, "kind"); if (kind) { if (Equal(kind, "function") // HACK: sneaky.ctest revealed that typedef'd (global) functions must be // detected via the 'view' attribute. || (Equal(kind, "variable") && Equal(Getattr(n, "view"), "globalfunctionHandler")) ) { bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0; bool is_static = GetFlag(state.function(), IS_STATIC) != 0; ret = emitFunction(n, is_member, is_static); } else if (Cmp(kind, "variable") == 0) { bool is_static = GetFlag(state.variable(), IS_STATIC) != 0; // HACK: smartpointeraccessed static variables are not treated as statics if (GetFlag(n, "allocate:smartpointeraccess")) { is_static = false; } bool is_member = GetFlag(n, "ismember") != 0; bool is_setter = GetFlag(n, "memberset") != 0 || GetFlag(n, "varset") != 0; bool is_getter = GetFlag(n, "memberget") != 0 || GetFlag(n, "varget") != 0; if (is_setter) { ret = emitSetter(n, is_member, is_static); } else if (is_getter) { ret = emitGetter(n, is_member, is_static); } else { Swig_print_node(n); } } else { Printf(stderr, "Warning: unsupported wrapper function type\n"); Swig_print_node(n); ret = SWIG_ERROR; } } else { String *view = Getattr(n, "view"); if (Cmp(view, "constructorHandler") == 0) { ret = emitCtor(n); } else if (Cmp(view, "destructorHandler") == 0) { ret = emitDtor(n); } else { Printf(stderr, "Warning: unsupported wrapper function type"); Swig_print_node(n); ret = SWIG_ERROR; } } return ret; } int JSEmitter::enterClass(Node *n) { state.clazz(RESET); state.clazz(NAME, Getattr(n, "sym:name")); state.clazz("nspace", current_namespace); // Creating a mangled name using the current namespace and the symbol name String *mangled_name = NewString(""); Printf(mangled_name, "%s_%s", Getattr(current_namespace, NAME_MANGLED), Getattr(n, "sym:name")); state.clazz(NAME_MANGLED, SwigType_manglestr(mangled_name)); Delete(mangled_name); state.clazz(TYPE, NewString(Getattr(n, "classtype"))); String *type = SwigType_manglestr(Getattr(n, "classtypeobj")); String *classtype_mangled = NewString(""); Printf(classtype_mangled, "p%s", type); state.clazz(TYPE_MANGLED, classtype_mangled); Delete(type); String *ctor_wrapper = NewString("_wrap_new_veto_"); Append(ctor_wrapper, state.clazz(NAME)); state.clazz(CTOR, ctor_wrapper); state.clazz(CTOR_DISPATCHERS, NewString("")); state.clazz(DTOR, NewString("0")); // HACK: assume that a class is abstract // this is resolved by emitCtor (which is only called for non abstract classes) SetFlag(state.clazz(), IS_ABSTRACT); return SWIG_OK; } int JSEmitter::enterFunction(Node *n) { state.function(RESET); state.function(NAME, Getattr(n, "sym:name")); if (Equal(Getattr(n, "storage"), "static")) { SetFlag(state.function(), IS_STATIC); } return SWIG_OK; } int JSEmitter::enterVariable(Node *n) { // reset the state information for variables. state.variable(RESET); // Retrieve a pure symbol name. Using 'sym:name' as a basis, as it considers %renamings. if (Equal(Getattr(n, "view"), "memberconstantHandler")) { // Note: this is kind of hacky/experimental // For constants/enums 'sym:name' contains e.g., 'Foo_Hello' instead of 'Hello' state.variable(NAME, Getattr(n, "memberconstantHandler:sym:name")); } else { state.variable(NAME, Swig_scopename_last(Getattr(n, "sym:name"))); } if (Equal(Getattr(n, "storage"), "static")) { SetFlag(state.variable(), IS_STATIC); } if (!Language::instance()->is_assignable(n)) { SetFlag(state.variable(), IS_IMMUTABLE); } // FIXME: test "arrays_global" does not compile with that as it is not allowed to assign to char[] if (Equal(Getattr(n, "type"), "a().char")) { SetFlag(state.variable(), IS_IMMUTABLE); } return SWIG_OK; } int JSEmitter::emitCtor(Node *n) { Wrapper *wrapper = NewWrapper(); bool is_overloaded = GetFlag(n, "sym:overloaded") != 0; Template t_ctor(getTemplate("js_ctor")); String *wrap_name = Swig_name_wrapper(Getattr(n, "sym:name")); if (is_overloaded) { t_ctor = getTemplate("js_overloaded_ctor"); Append(wrap_name, Getattr(n, "sym:overname")); } Setattr(n, "wrap:name", wrap_name); // note: we can remove the is_abstract flag now, as this // is called for non-abstract classes only. Setattr(state.clazz(), IS_ABSTRACT, 0); ParmList *params = Getattr(n, "parms"); emit_parameter_variables(params, wrapper); emit_attach_parmmaps(params, wrapper); // HACK: in test-case `ignore_parameter` emit_attach_parmmaps generated an extra line of applied typemaps. // Deleting wrapper->code here, to reset, and as it seemed to have no side effect elsewhere Delete(wrapper->code); wrapper->code = NewString(""); Printf(wrapper->locals, "%sresult;", SwigType_str(Getattr(n, "type"), 0)); marshalInputArgs(n, params, wrapper, Ctor, true, false); String *action = emit_action(n); Printv(wrapper->code, action, "\n", 0); emitCleanupCode(n, wrapper, params); t_ctor.replace("$jswrapper", wrap_name) .replace("$jsmangledtype", state.clazz(TYPE_MANGLED)) .replace("$jslocals", wrapper->locals) .replace("$jscode", wrapper->code) .replace("$jsargcount", Getattr(n, ARGCOUNT)) .pretty_print(f_wrappers); Template t_ctor_case(getTemplate("js_ctor_dispatch_case")); t_ctor_case.replace("$jswrapper", wrap_name) .replace("$jsargcount", Getattr(n, ARGCOUNT)); Append(state.clazz(CTOR_DISPATCHERS), t_ctor_case.str()); DelWrapper(wrapper); // create a dispatching ctor if (is_overloaded) { if (!Getattr(n, "sym:nextSibling")) { String *wrap_name = Swig_name_wrapper(Getattr(n, "sym:name")); Template t_mainctor(getTemplate("js_ctor_dispatcher")); t_mainctor.replace("$jswrapper", wrap_name) .replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsdispatchcases", state.clazz(CTOR_DISPATCHERS)) .pretty_print(f_wrappers); state.clazz(CTOR, wrap_name); } } else { state.clazz(CTOR, wrap_name); } return SWIG_OK; } int JSEmitter::emitDtor(Node *n) { String *wrap_name = Swig_name_wrapper(Getattr(n, "sym:name")); SwigType *type = state.clazz(TYPE); String *p_classtype = SwigType_add_pointer(state.clazz(TYPE)); String *ctype = SwigType_lstr(p_classtype, ""); String *free = NewString(""); // (Taken from JSCore implementation.) /* The if (Extend) block was taken from the Ruby implementation. * The problem is that in the case of an %extend to create a destructor for a struct to coordinate automatic memory cleanup with the Javascript collector, * the SWIG function was not being generated. More specifically: struct MyData { %extend { ~MyData() { FreeData($self); } } }; %newobject CreateData; struct MyData* CreateData(void); %delobject FreeData; void FreeData(struct MyData* the_data); where the use case is something like: var my_data = example.CreateData(); my_data = null; This function was not being generated: SWIGINTERN void delete_MyData(struct MyData *self){ FreeData(self); } I don't understand fully why it wasn't being generated. It just seems to happen in the Lua generator. There is a comment about staticmemberfunctionHandler having an inconsistency and I tracked down dome of the SWIGINTERN void delete_* code to that function in the Language base class. The Ruby implementation seems to have an explicit check for if(Extend) and explicitly generates the code, so that's what I'm doing here. The Ruby implementation does other stuff which I omit. */ if (Extend) { String *wrap = Getattr(n, "wrap:code"); if (wrap) { Printv(f_wrappers, wrap, NIL); } } // HACK: this is only for the v8 emitter. maybe set an attribute wrap:action of node // TODO: generate dtors more similar to other wrappers // EW: I think this is wrong. delete should only be used when new was used to create. If malloc was used, free needs to be used. if (SwigType_isarray(type)) { Printf(free, "delete [] (%s)", ctype); } else { Printf(free, "delete (%s)", ctype); } String *destructor_action = Getattr(n, "wrap:action"); // Adapted from the JSCore implementation. /* The next challenge is to generate the correct finalize function for JavaScriptCore to call. Originally, it would use this fragment from javascriptcode.swg %fragment ("JS_destructordefn", "templates") %{ void _wrap_${classname_mangled}_finalize(JSObjectRef thisObject) { SWIG_PRV_DATA* t = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject); if(t && t->swigCMemOwn) free ((${type}*)t->swigCObject); if(t) free(t); } %} But for the above example case of %extend to define a destructor on a struct, we need to override the system to not call free ((${type}*)t->swigCObject); and substitute it with what the user has provided. To solve this, I created a variation fragment called JS_destructoroverridedefn: SWIG_PRV_DATA* t = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject); if(t && t->swigCMemOwn) { ${type}* arg1 = (${type}*)t->swigCObject; ${destructor_action} } if(t) free(t); Based on what I saw in the Lua and Ruby modules, I use Getattr(n, "wrap:action") to decide if the user has a preferred destructor action. Based on that, I decide which fragment to use. And in the case of the custom action, I substitute that action in. I noticed that destructor_action has the form delete_MyData(arg1); The explicit arg1 is a little funny, so I structured the fragment to create a temporary variable called arg1 to make the generation easier. This might suggest this solution misunderstands a more complex case. Also, there is a problem where destructor_action is always true for me, even when not requesting %extend as above. So this code doesn't actually quite work as I expect. The end result is that the code still works because destructor_action calls free like the original template. The one caveat is the string in destructor_action casts to char* which is wierd. I think there is a deeper underlying SWIG issue because I don't think it should be char*. However, it doesn't really matter for free. Maybe the fix for the destructor_action always true problem is that this is supposed to be embedded in the if(Extend) block above. But I don't fully understand the conditions of any of these things, and since it works for the moment, I don't want to break more stuff. */ if (destructor_action) { Template t_dtor = getTemplate("js_dtoroverride"); state.clazz(DTOR, wrap_name); t_dtor.replace("${classname_mangled}", state.clazz(NAME_MANGLED)) .replace("$jswrapper", wrap_name) .replace("$jsfree", free) .replace("$jstype", ctype); t_dtor.replace("${destructor_action}", destructor_action); Wrapper_pretty_print(t_dtor.str(), f_wrappers); } else { Template t_dtor = getTemplate("js_dtor"); state.clazz(DTOR, wrap_name); t_dtor.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jswrapper", wrap_name) .replace("$jsfree", free) .replace("$jstype", ctype) .pretty_print(f_wrappers); } Delete(p_classtype); Delete(ctype); Delete(free); return SWIG_OK; } int JSEmitter::emitGetter(Node *n, bool is_member, bool is_static) { Wrapper *wrapper = NewWrapper(); Template t_getter(getTemplate("js_getter")); // prepare wrapper name String *wrap_name = Swig_name_wrapper(Getattr(n, "sym:name")); Setattr(n, "wrap:name", wrap_name); state.variable(GETTER, wrap_name); // prepare local variables ParmList *params = Getattr(n, "parms"); emit_parameter_variables(params, wrapper); emit_attach_parmmaps(params, wrapper); // prepare code part String *action = emit_action(n); marshalInputArgs(n, params, wrapper, Getter, is_member, is_static); marshalOutput(n, params, wrapper, action); emitCleanupCode(n, wrapper, params); t_getter.replace("$jswrapper", wrap_name) .replace("$jslocals", wrapper->locals) .replace("$jscode", wrapper->code) .pretty_print(f_wrappers); DelWrapper(wrapper); return SWIG_OK; } int JSEmitter::emitSetter(Node *n, bool is_member, bool is_static) { // skip variables that are immutable if (State::IsSet(state.variable(IS_IMMUTABLE))) { return SWIG_OK; } Wrapper *wrapper = NewWrapper(); Template t_setter(getTemplate("js_setter")); // prepare wrapper name String *wrap_name = Swig_name_wrapper(Getattr(n, "sym:name")); Setattr(n, "wrap:name", wrap_name); state.variable(SETTER, wrap_name); // prepare local variables ParmList *params = Getattr(n, "parms"); emit_parameter_variables(params, wrapper); emit_attach_parmmaps(params, wrapper); // prepare code part String *action = emit_action(n); marshalInputArgs(n, params, wrapper, Setter, is_member, is_static); Append(wrapper->code, action); emitCleanupCode(n, wrapper, params); t_setter.replace("$jswrapper", wrap_name) .replace("$jslocals", wrapper->locals) .replace("$jscode", wrapper->code) .pretty_print(f_wrappers); DelWrapper(wrapper); return SWIG_OK; } /* ----------------------------------------------------------------------------- * JSEmitter::emitConstant() : triggers code generation for constants * ----------------------------------------------------------------------------- */ int JSEmitter::emitConstant(Node *n) { // HACK: somehow it happened under OSX that before everything started // a lot of SWIG internal constants were emitted // This didn't happen on other platforms yet... // we ignore those premature definitions if (!State::IsSet(state.globals(HAS_TEMPLATES))) { return SWIG_ERROR; } Wrapper *wrapper = NewWrapper(); SwigType *type = Getattr(n, "type"); String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(name); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); // HACK: forcing usage of cppvalue for v8 (which turned out to fix typdef_struct.i, et. al) if (State::IsSet(state.globals(FORCE_CPP)) && Getattr(n, "cppvalue") != NULL) { value = Getattr(n, "cppvalue"); } Template t_getter(getTemplate("js_getter")); // call the variable methods as a constants are // registred in same way enterVariable(n); state.variable(GETTER, wname); // TODO: why do we need this? Setattr(n, "wrap:name", wname); // special treatment of member pointers if (SwigType_type(type) == T_MPOINTER) { // TODO: this could go into a code-template String *mpointer_wname = NewString(""); Printf(mpointer_wname, "_wrapConstant_%s", iname); Setattr(n, "memberpointer:constant:wrap:name", mpointer_wname); String *str = SwigType_str(type, mpointer_wname); Printf(f_wrappers, "static %s = %s;\n", str, value); Delete(str); value = mpointer_wname; } marshalOutput(n, 0, wrapper, NewString(""), value, false); t_getter.replace("$jswrapper", wname) .replace("$jslocals", wrapper->locals) .replace("$jscode", wrapper->code) .pretty_print(f_wrappers); exitVariable(n); DelWrapper(wrapper); return SWIG_OK; } int JSEmitter::emitFunction(Node *n, bool is_member, bool is_static) { Wrapper *wrapper = NewWrapper(); Template t_function(getTemplate("js_function")); bool is_overloaded = GetFlag(n, "sym:overloaded") != 0; // prepare the function wrapper name String *iname = Getattr(n, "sym:name"); String *wrap_name = Swig_name_wrapper(iname); if (is_overloaded) { t_function = getTemplate("js_overloaded_function"); Append(wrap_name, Getattr(n, "sym:overname")); } Setattr(n, "wrap:name", wrap_name); state.function(WRAPPER_NAME, wrap_name); // prepare local variables ParmList *params = Getattr(n, "parms"); emit_parameter_variables(params, wrapper); emit_attach_parmmaps(params, wrapper); // HACK: in test-case `ignore_parameter` emit_attach_parmmaps generates an extra line of applied typemap. // Deleting wrapper->code here fixes the problem, and seems to have no side effect elsewhere Delete(wrapper->code); wrapper->code = NewString(""); marshalInputArgs(n, params, wrapper, Function, is_member, is_static); String *action = emit_action(n); marshalOutput(n, params, wrapper, action); emitCleanupCode(n, wrapper, params); Replaceall(wrapper->code, "$symname", iname); t_function.replace("$jswrapper", wrap_name) .replace("$jslocals", wrapper->locals) .replace("$jscode", wrapper->code) .replace("$jsargcount", Getattr(n, ARGCOUNT)) .pretty_print(f_wrappers); DelWrapper(wrapper); return SWIG_OK; } int JSEmitter::emitFunctionDispatcher(Node *n, bool /*is_member */ ) { Wrapper *wrapper = NewWrapper(); // Generate call list, go to first node Node *sibl = n; while (Getattr(sibl, "sym:previousSibling")) sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up do { String *siblname = Getattr(sibl, "wrap:name"); if (siblname) { // handle function overloading Template t_dispatch_case = getTemplate("js_function_dispatch_case"); t_dispatch_case.replace("$jswrapper", siblname) .replace("$jsargcount", Getattr(sibl, ARGCOUNT)); Append(wrapper->code, t_dispatch_case.str()); } } while ((sibl = Getattr(sibl, "sym:nextSibling"))); Template t_function(getTemplate("js_function_dispatcher")); // Note: this dispatcher function gets called after the last overloaded function has been created. // At this time, n.wrap:name contains the name of the last wrapper function. // To get a valid function name for the dispatcher function we take the last wrapper name and // substract the extension "sym:overname", String *wrap_name = NewString(Getattr(n, "wrap:name")); String *overname = Getattr(n, "sym:overname"); int l1 = Len(wrap_name); int l2 = Len(overname); Delslice(wrap_name, l1 - l2, l1); Setattr(n, "wrap:name", wrap_name); state.function(WRAPPER_NAME, wrap_name); t_function.replace("$jslocals", wrapper->locals) .replace("$jscode", wrapper->code); // call this here, to replace all variables t_function.replace("$jswrapper", wrap_name) .replace("$jsname", state.function(NAME)) .pretty_print(f_wrappers); // Delete the state variable DelWrapper(wrapper); return SWIG_OK; } String *JSEmitter::emitInputTypemap(Node *n, Parm *p, Wrapper *wrapper, String *arg) { // Get input typemap for current param String *tm = Getattr(p, "tmap:in"); SwigType *type = Getattr(p, "type"); if (tm != NULL) { Replaceall(tm, "$input", arg); Setattr(p, "emit:input", arg); // do replacements for built-in variables if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } Replaceall(tm, "$symname", Getattr(n, "sym:name")); Printf(wrapper->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(type, 0)); } return tm; } void JSEmitter::marshalOutput(Node *n, ParmList *params, Wrapper *wrapper, String *actioncode, const String *cresult, bool emitReturnVariable) { SwigType *type = Getattr(n, "type"); String *tm; Parm *p; // adds a declaration for the result variable if (emitReturnVariable) emit_return_variable(n, type, wrapper); // if not given, use default result identifier ('result') for output typemap if (cresult == 0) cresult = defaultResultName; tm = Swig_typemap_lookup_out("out", n, cresult, wrapper, actioncode); bool should_own = GetFlag(n, "feature:new") != 0; if (tm) { Replaceall(tm, "$objecttype", Swig_scopename_last(SwigType_str(SwigType_strip_qualifiers(type), 0))); if (should_own) { Replaceall(tm, "$owner", "SWIG_POINTER_OWN"); } else { Replaceall(tm, "$owner", "0"); } Append(wrapper->code, tm); if (Len(tm) > 0) { Printf(wrapper->code, "\n"); } } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), Getattr(n, "name")); } if (params) { for (p = params; p;) { if ((tm = Getattr(p, "tmap:argout"))) { Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(wrapper->code, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } } Replaceall(wrapper->code, "$result", "jsresult"); } void JSEmitter::emitCleanupCode(Node *n, Wrapper *wrapper, ParmList *params) { Parm *p; String *tm; for (p = params; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { //addThrows(n, "tmap:freearg", p); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(wrapper->code, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } if (GetFlag(n, "feature:new")) { tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0); if (tm != NIL) { //addThrows(throws_hash, "newfree", n); Printv(wrapper->code, tm, "\n", NIL); } } } int JSEmitter::switchNamespace(Node *n) { // HACK: somehow this gets called for member functions. // We can safely ignore them, as members are not associated to a namespace (only their class) if (GetFlag(n, "ismember")) { return SWIG_OK; } // if nspace is deactivated, everything goes into the global scope if (!GetFlag(n, "feature:nspace")) { current_namespace = Getattr(namespaces, "::"); return SWIG_OK; } // EXPERIMENTAL: we want to use Language::getNSpace() here // However, it is not working yet. // For namespace functions Language::getNSpace() does not give a valid result #if 0 JAVASCRIPT *lang = static_cast(Language::instance()); String *_nspace = lang->getNSpace(); if (!Equal(nspace, _nspace)) { Printf(stdout, "##### Custom vs Language::getNSpace(): %s | %s\n", nspace, _nspace); Swig_print_node(n); } #endif String *nspace = Getattr(n, "sym:nspace"); if (nspace == NULL) { // It seems that only classes have 'sym:nspace' set. // We try to get the namespace from the qualified name (i.e., everything before the last '::') nspace = Swig_scopename_prefix(Getattr(n, "name")); } // If there is not even a scopename prefix then it must be global scope if (nspace == NULL) { current_namespace = Getattr(namespaces, "::"); return SWIG_OK; } String *scope = NewString(nspace); // replace "." with "::" that we can use Swig_scopename_last Replaceall(scope, ".", "::"); // if the scope is not yet registered // create (parent) namespaces recursively if (!Getattr(namespaces, scope)) { createNamespace(scope); } current_namespace = Getattr(namespaces, scope); return SWIG_OK; } int JSEmitter::createNamespace(String *scope) { String *parent_scope = Swig_scopename_prefix(scope); Hash *parent_namespace; if (parent_scope == 0) { parent_namespace = Getattr(namespaces, "::"); } else if (!Getattr(namespaces, parent_scope)) { createNamespace(parent_scope); parent_namespace = Getattr(namespaces, parent_scope); } else { parent_namespace = Getattr(namespaces, parent_scope); } assert(parent_namespace != 0); Hash *new_namespace = createNamespaceEntry(Char(scope), Char(Getattr(parent_namespace, "name"))); Setattr(namespaces, scope, new_namespace); Delete(parent_scope); return SWIG_OK; } Hash *JSEmitter::createNamespaceEntry(const char *_name, const char *parent) { Hash *entry = NewHash(); String *name = NewString(_name); Setattr(entry, NAME, Swig_scopename_last(name)); Setattr(entry, NAME_MANGLED, Swig_name_mangle(name)); Setattr(entry, PARENT, NewString(parent)); Delete(name); return entry; } /********************************************************************** * JavascriptCore: JSEmitter implementation for JavascriptCore engine **********************************************************************/ class JSCEmitter:public JSEmitter { public: JSCEmitter(); virtual ~ JSCEmitter(); virtual int initialize(Node *n); virtual int dump(Node *n); virtual int close(); protected: virtual int enterVariable(Node *n); virtual int exitVariable(Node *n); virtual int enterFunction(Node *n); virtual int exitFunction(Node *n); virtual int enterClass(Node *n); virtual int exitClass(Node *n); virtual void marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static); virtual Hash *createNamespaceEntry(const char *name, const char *parent); virtual int emitNamespaces(); private: String *NULL_STR; String *VETO_SET; // output file and major code parts File *f_wrap_cpp; File *f_runtime; File *f_header; File *f_init; }; JSCEmitter::JSCEmitter() : JSEmitter(JSEmitter::JavascriptCore), NULL_STR(NewString("NULL")), VETO_SET(NewString("JS_veto_set_variable")), f_wrap_cpp(NULL), f_runtime(NULL), f_header(NULL), f_init(NULL) { } JSCEmitter::~JSCEmitter() { Delete(NULL_STR); Delete(VETO_SET); } /* --------------------------------------------------------------------- * marshalInputArgs() * * Process all of the arguments passed into the argv array * and convert them into C/C++ function arguments using the * supplied typemaps. * --------------------------------------------------------------------- */ void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static) { Parm *p; String *tm; // determine an offset index, as members have an extra 'this' argument // except: static members and ctors. int startIdx = 0; if (is_member && !is_static && mode != Ctor) { startIdx = 1; } // store number of arguments for argument checks int num_args = emit_num_arguments(parms) - startIdx; String *argcount = NewString(""); Printf(argcount, "%d", num_args); Setattr(n, ARGCOUNT, argcount); // process arguments int i = 0; for (p = parms; p; i++) { String *arg = NewString(""); String *type = Getattr(p, "type"); // ignore varargs if (SwigType_isvarargs(type)) break; switch (mode) { case Getter: case Function: if (is_member && !is_static && i == 0) { Printv(arg, "thisObject", 0); } else { Printf(arg, "argv[%d]", i - startIdx); } break; case Setter: if (is_member && !is_static && i == 0) { Printv(arg, "thisObject", 0); } else { Printv(arg, "value", 0); } break; case Ctor: Printf(arg, "argv[%d]", i); break; default: throw "Illegal state."; } tm = emitInputTypemap(n, p, wrapper, arg); Delete(arg); if (tm) { p = Getattr(p, "tmap:in:next"); } else { p = nextSibling(p); } } } int JSCEmitter::initialize(Node *n) { JSEmitter::initialize(n); /* Get the output file name */ String *outfile = Getattr(n, "outfile"); /* Initialize I/O */ f_wrap_cpp = NewFile(outfile, "w", SWIG_output_files()); if (!f_wrap_cpp) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } /* Initialization of members */ f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); state.globals(CREATE_NAMESPACES, NewString("")); state.globals(REGISTER_NAMESPACES, NewString("")); state.globals(INITIALIZER, NewString("")); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("begin", f_wrap_cpp); Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_banner(f_wrap_cpp); return SWIG_OK; } int JSCEmitter::dump(Node *n) { /* Get the module name */ String *module = Getattr(n, "name"); Template initializer_define(getTemplate("js_initializer_define")); initializer_define.replace("$jsname", module).pretty_print(f_header); SwigType_emit_type_table(f_runtime, f_wrappers); Printv(f_wrap_cpp, f_runtime, "\n", 0); Printv(f_wrap_cpp, f_header, "\n", 0); Printv(f_wrap_cpp, f_wrappers, "\n", 0); emitNamespaces(); // compose the initializer function using a template Template initializer(getTemplate("js_initializer")); initializer.replace("$jsname", module) .replace("$jsregisterclasses", state.globals(INITIALIZER)) .replace("$jscreatenamespaces", state.globals(CREATE_NAMESPACES)) .replace("$jsregisternamespaces", state.globals(REGISTER_NAMESPACES)) .pretty_print(f_init); Printv(f_wrap_cpp, f_init, 0); return SWIG_OK; } int JSCEmitter::close() { Delete(f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(namespaces); Delete(f_wrap_cpp); return SWIG_OK; } int JSCEmitter::enterFunction(Node *n) { JSEmitter::enterFunction(n); return SWIG_OK; } int JSCEmitter::exitFunction(Node *n) { Template t_function = getTemplate("jsc_function_declaration"); bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0; bool is_overloaded = GetFlag(n, "sym:overloaded") != 0; // handle overloaded functions if (is_overloaded) { if (!Getattr(n, "sym:nextSibling")) { //state.function(WRAPPER_NAME, Swig_name_wrapper(Getattr(n, "name"))); // create dispatcher emitFunctionDispatcher(n, is_member); } else { //don't register wrappers of overloaded functions in function tables return SWIG_OK; } } t_function.replace("$jsname", state.function(NAME)) .replace("$jswrapper", state.function(WRAPPER_NAME)); if (is_member) { if (GetFlag(state.function(), IS_STATIC)) { t_function.pretty_print(state.clazz(STATIC_FUNCTIONS)); } else { t_function.pretty_print(state.clazz(MEMBER_FUNCTIONS)); } } else { t_function.pretty_print(Getattr(current_namespace, "functions")); } return SWIG_OK; } int JSCEmitter::enterVariable(Node *n) { JSEmitter::enterVariable(n); state.variable(GETTER, NULL_STR); state.variable(SETTER, VETO_SET); return SWIG_OK; } int JSCEmitter::exitVariable(Node *n) { Template t_variable(getTemplate("jsc_variable_declaration")); t_variable.replace("$jsname", state.variable(NAME)) .replace("$jsgetter", state.variable(GETTER)) .replace("$jssetter", state.variable(SETTER)); if (GetFlag(n, "ismember")) { if (GetFlag(state.variable(), IS_STATIC) || Equal(Getattr(n, "nodeType"), "enumitem")) { t_variable.pretty_print(state.clazz(STATIC_VARIABLES)); } else { t_variable.pretty_print(state.clazz(MEMBER_VARIABLES)); } } else { t_variable.pretty_print(Getattr(current_namespace, "values")); } return SWIG_OK; } int JSCEmitter::enterClass(Node *n) { JSEmitter::enterClass(n); state.clazz(MEMBER_VARIABLES, NewString("")); state.clazz(MEMBER_FUNCTIONS, NewString("")); state.clazz(STATIC_VARIABLES, NewString("")); state.clazz(STATIC_FUNCTIONS, NewString("")); Template t_class_decl = getTemplate("jsc_class_declaration"); t_class_decl.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .pretty_print(f_wrappers); return SWIG_OK; } int JSCEmitter::exitClass(Node *n) { Template t_class_tables(getTemplate("jsc_class_tables")); t_class_tables.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsclassvariables", state.clazz(MEMBER_VARIABLES)) .replace("$jsclassfunctions", state.clazz(MEMBER_FUNCTIONS)) .replace("$jsstaticclassfunctions", state.clazz(STATIC_FUNCTIONS)) .replace("$jsstaticclassvariables", state.clazz(STATIC_VARIABLES)) .pretty_print(f_wrappers); /* adds the ctor wrappers at this position */ // Note: this is necessary to avoid extra forward declarations. //Append(f_wrappers, state.clazz(CTOR_WRAPPERS)); // for abstract classes add a vetoing ctor if (GetFlag(state.clazz(), IS_ABSTRACT)) { Template t_veto_ctor(getTemplate("js_veto_ctor")); t_veto_ctor.replace("$jswrapper", state.clazz(CTOR)) .replace("$jsname", state.clazz(NAME)) .pretty_print(f_wrappers); } /* adds a class template statement to initializer function */ Template t_classtemplate(getTemplate("jsc_class_definition")); /* prepare registration of base class */ String *jsclass_inheritance = NewString(""); Node *base_class = getBaseClass(n); if (base_class != NULL) { Template t_inherit(getTemplate("jsc_class_inherit")); t_inherit.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsbaseclassmangled", SwigType_manglestr(Getattr(base_class, "name"))) .pretty_print(jsclass_inheritance); } else { Template t_inherit(getTemplate("jsc_class_noinherit")); t_inherit.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .pretty_print(jsclass_inheritance); } t_classtemplate.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsmangledtype", state.clazz(TYPE_MANGLED)) .replace("$jsclass_inheritance", jsclass_inheritance) .replace("$jsctor", state.clazz(CTOR)) .replace("$jsdtor", state.clazz(DTOR)) .pretty_print(state.globals(INITIALIZER)); Delete(jsclass_inheritance); /* Note: this makes sure that there is a swig_type added for this class */ SwigType_remember_clientdata(state.clazz(TYPE_MANGLED), NewString("0")); /* adds a class registration statement to initializer function */ Template t_registerclass(getTemplate("jsc_class_registration")); t_registerclass.replace("$jsname", state.clazz(NAME)) .replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsnspace", Getattr(state.clazz("nspace"), NAME_MANGLED)) .pretty_print(state.globals(INITIALIZER)); return SWIG_OK; } Hash *JSCEmitter::createNamespaceEntry(const char *name, const char *parent) { Hash *entry = JSEmitter::createNamespaceEntry(name, parent); Setattr(entry, "functions", NewString("")); Setattr(entry, "values", NewString("")); return entry; } int JSCEmitter::emitNamespaces() { Iterator it; for (it = First(namespaces); it.item; it = Next(it)) { Hash *entry = it.item; String *name = Getattr(entry, NAME); String *name_mangled = Getattr(entry, NAME_MANGLED); String *parent = Getattr(entry, PARENT); String *parent_mangled = Swig_name_mangle(parent); String *functions = Getattr(entry, "functions"); String *variables = Getattr(entry, "values"); // skip the global namespace which is given by the application Template namespace_definition(getTemplate("jsc_nspace_declaration")); namespace_definition.replace("$jsglobalvariables", variables) .replace("$jsglobalfunctions", functions) .replace("$jsnspace", name_mangled) .pretty_print(f_wrap_cpp); Template t_createNamespace(getTemplate("jsc_nspace_definition")); t_createNamespace.replace("$jsmangledname", name_mangled); Append(state.globals(CREATE_NAMESPACES), t_createNamespace.str()); // Don't register 'exports' as namespace. It is return to the application. if (!Equal("exports", name)) { Template t_registerNamespace(getTemplate("jsc_nspace_registration")); t_registerNamespace.replace("$jsmangledname", name_mangled) .replace("$jsname", name) .replace("$jsparent", parent_mangled); Append(state.globals(REGISTER_NAMESPACES), t_registerNamespace.str()); } } return SWIG_OK; } JSEmitter *swig_javascript_create_JSCEmitter() { return new JSCEmitter(); } /********************************************************************** * V8: JSEmitter implementation for V8 engine **********************************************************************/ class V8Emitter:public JSEmitter { public: V8Emitter(); virtual ~ V8Emitter(); virtual int initialize(Node *n); virtual int dump(Node *n); virtual int close(); virtual int enterClass(Node *n); virtual int exitClass(Node *n); virtual int enterVariable(Node *n); virtual int exitVariable(Node *n); virtual int exitFunction(Node *n); protected: virtual void marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static); virtual int emitNamespaces(); protected: /* built-in parts */ String *f_runtime; String *f_header; String *f_init; String *f_post_init; /* part for class templates */ String *f_class_templates; /* parts for initilizer */ String *f_init_namespaces; String *f_init_class_templates; String *f_init_wrappers; String *f_init_inheritance; String *f_init_class_instances; String *f_init_static_wrappers; String *f_init_register_classes; String *f_init_register_namespaces; // the output cpp file File *f_wrap_cpp; String *NULL_STR; String *VETO_SET; String *moduleName; }; V8Emitter::V8Emitter() : JSEmitter(JSEmitter::V8), NULL_STR(NewString("0")), VETO_SET(NewString("JS_veto_set_variable")) { } V8Emitter::~V8Emitter() { Delete(NULL_STR); Delete(VETO_SET); } int V8Emitter::initialize(Node *n) { JSEmitter::initialize(n); moduleName = Getattr(n, "name"); // Get the output file name String *outfile = Getattr(n, "outfile"); f_wrap_cpp = NewFile(outfile, "w", SWIG_output_files()); if (!f_wrap_cpp) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_header = NewString(""); f_class_templates = NewString(""); f_init = NewString(""); f_post_init = NewString(""); f_init_namespaces = NewString(""); f_init_class_templates = NewString(""); f_init_wrappers = NewString(""); f_init_inheritance = NewString(""); f_init_class_instances = NewString(""); f_init_static_wrappers = NewString(""); f_init_register_classes = NewString(""); f_init_register_namespaces = NewString(""); // note: this is necessary for built-in generation of SWIG runtime code Swig_register_filebyname("begin", f_wrap_cpp); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("init", f_init); Swig_register_filebyname("post-init", f_post_init); state.globals(FORCE_CPP, NewString("1")); Swig_banner(f_wrap_cpp); return SWIG_OK; } int V8Emitter::dump(Node *n) { /* Get the module name */ String *module = Getattr(n, "name"); Template initializer_define(getTemplate("js_initializer_define")); initializer_define.replace("$jsname", module).pretty_print(f_header); SwigType_emit_type_table(f_runtime, f_wrappers); Printv(f_wrap_cpp, f_runtime, "\n", 0); Printv(f_wrap_cpp, f_header, "\n", 0); Printv(f_wrap_cpp, f_class_templates, "\n", 0); Printv(f_wrap_cpp, f_wrappers, "\n", 0); emitNamespaces(); // compose the initializer function using a template // filled with sub-parts Template initializer(getTemplate("js_initializer")); initializer.replace("$jsname", moduleName) .replace("$jsv8nspaces", f_init_namespaces) .replace("$jsv8classtemplates", f_init_class_templates) .replace("$jsv8wrappers", f_init_wrappers) .replace("$jsv8inheritance", f_init_inheritance) .replace("$jsv8classinstances", f_init_class_instances) .replace("$jsv8staticwrappers", f_init_static_wrappers) .replace("$jsv8registerclasses", f_init_register_classes) .replace("$jsv8registernspaces", f_init_register_namespaces); Printv(f_init, initializer.str(), 0); Printv(f_wrap_cpp, f_init, 0); Printv(f_wrap_cpp, f_post_init, 0); return SWIG_OK; } int V8Emitter::close() { Delete(f_runtime); Delete(f_header); Delete(f_class_templates); Delete(f_init_namespaces); Delete(f_init_class_templates); Delete(f_init_wrappers); Delete(f_init_inheritance); Delete(f_init_class_instances); Delete(f_init_static_wrappers); Delete(f_init_register_classes); Delete(f_init_register_namespaces); Delete(f_init); Delete(f_post_init); Delete(f_wrap_cpp); return SWIG_OK; } int V8Emitter::enterClass(Node *n) { JSEmitter::enterClass(n); // emit declaration of a v8 class template Template t_decl_class(getTemplate("jsv8_declare_class_template")); t_decl_class.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .trim() .pretty_print(f_class_templates); return SWIG_OK; } int V8Emitter::exitClass(Node *n) { if (GetFlag(state.clazz(), IS_ABSTRACT)) { Template t_veto_ctor(getTemplate("js_veto_ctor")); t_veto_ctor.replace("$jswrapper", state.clazz(CTOR)) .replace("$jsname", state.clazz(NAME)) .pretty_print(f_wrappers); } /* Note: this makes sure that there is a swig_type added for this class */ String *clientData = NewString(""); Printf(clientData, "&%s_clientData", state.clazz(NAME_MANGLED)); /* Note: this makes sure that there is a swig_type added for this class */ SwigType_remember_clientdata(state.clazz(TYPE_MANGLED), NewString("0")); // emit definition of v8 class template Template t_def_class = getTemplate("jsv8_define_class_template"); t_def_class.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsname", state.clazz(NAME)) .replace("$jsmangledtype", state.clazz(TYPE_MANGLED)) .replace("$jsdtor", state.clazz(DTOR)) .trim() .pretty_print(f_init_class_templates); Template t_class_instance = getTemplate("jsv8_create_class_instance"); t_class_instance.replace("$jsname", state.clazz(NAME)) .replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsctor", state.clazz(CTOR)) .trim() .pretty_print(f_init_class_instances); // emit inheritance setup Node *baseClass = getBaseClass(n); if (baseClass) { String *base_name = Getattr(baseClass, "name"); Template t_inherit = getTemplate("jsv8_inherit"); String *base_name_mangled = SwigType_manglestr(base_name); t_inherit.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsbaseclass", base_name_mangled) .trim() .pretty_print(f_init_inheritance); Delete(base_name_mangled); } // emit registeration of class template Template t_register = getTemplate("jsv8_register_class"); t_register.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsname", state.clazz(NAME)) .replace("$jsparent", Getattr(state.clazz("nspace"), NAME_MANGLED)) .trim() .pretty_print(f_init_register_classes); return SWIG_OK; } int V8Emitter::enterVariable(Node *n) { JSEmitter::enterVariable(n); state.variable(GETTER, NULL_STR); state.variable(SETTER, VETO_SET); return SWIG_OK; } int V8Emitter::exitVariable(Node *n) { if (GetFlag(n, "ismember")) { if (GetFlag(state.variable(), IS_STATIC) || Equal(Getattr(n, "nodeType"), "enumitem")) { Template t_register = getTemplate("jsv8_register_static_variable"); t_register.replace("$jsparent", state.clazz(NAME_MANGLED)) .replace("$jsname", state.variable(NAME)) .replace("$jsgetter", state.variable(GETTER)) .replace("$jssetter", state.variable(SETTER)) .trim() .pretty_print(f_init_static_wrappers); } else { Template t_register = getTemplate("jsv8_register_member_variable"); t_register.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsname", state.variable(NAME)) .replace("$jsgetter", state.variable(GETTER)) .replace("$jssetter", state.variable(SETTER)) .trim() .pretty_print(f_init_wrappers); } } else { // Note: a global variable is treated like a static variable // with the parent being a nspace object (instead of class object) Template t_register = getTemplate("jsv8_register_static_variable"); t_register.replace("$jsparent", Getattr(current_namespace, NAME_MANGLED)) .replace("$jsname", state.variable(NAME)) .replace("$jsgetter", state.variable(GETTER)) .replace("$jssetter", state.variable(SETTER)) .trim() .pretty_print(f_init_wrappers); } return SWIG_OK; } int V8Emitter::exitFunction(Node *n) { bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0; // create a dispatcher for overloaded functions bool is_overloaded = GetFlag(n, "sym:overloaded") != 0; if (is_overloaded) { if (!Getattr(n, "sym:nextSibling")) { //state.function(WRAPPER_NAME, Swig_name_wrapper(Getattr(n, "name"))); emitFunctionDispatcher(n, is_member); } else { //don't register wrappers of overloaded functions in function tables return SWIG_OK; } } // register the function at the specific context if (is_member) { if (GetFlag(state.function(), IS_STATIC)) { Template t_register = getTemplate("jsv8_register_static_function"); t_register.replace("$jsparent", state.clazz(NAME_MANGLED)) .replace("$jsname", state.function(NAME)) .replace("$jswrapper", state.function(WRAPPER_NAME)) .trim() .pretty_print(f_init_static_wrappers); } else { Template t_register = getTemplate("jsv8_register_member_function"); t_register.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsname", state.function(NAME)) .replace("$jswrapper", state.function(WRAPPER_NAME)) .trim() .pretty_print(f_init_wrappers); } } else { // Note: a global function is treated like a static function // with the parent being a nspace object instead of class object Template t_register = getTemplate("jsv8_register_static_function"); t_register.replace("$jsparent", Getattr(current_namespace, NAME_MANGLED)) .replace("$jsname", state.function(NAME)) .replace("$jswrapper", state.function(WRAPPER_NAME)) .trim() .pretty_print(f_init_static_wrappers); } return SWIG_OK; } void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static) { Parm *p; String *tm; int startIdx = 0; if (is_member && !is_static && mode != Ctor) { startIdx = 1; } // store number of arguments for argument checks int num_args = emit_num_arguments(parms) - startIdx; String *argcount = NewString(""); Printf(argcount, "%d", num_args); Setattr(n, ARGCOUNT, argcount); int i = 0; for (p = parms; p; i++) { String *arg = NewString(""); String *type = Getattr(p, "type"); // ignore varargs if (SwigType_isvarargs(type)) break; switch (mode) { case Getter: if (is_member && !is_static && i == 0) { Printv(arg, "info.Holder()", 0); } else { Printf(arg, "args[%d]", i - startIdx); } break; case Function: if (is_member && !is_static && i == 0) { Printv(arg, "args.Holder()", 0); } else { Printf(arg, "args[%d]", i - startIdx); } break; case Setter: if (is_member && !is_static && i == 0) { Printv(arg, "info.Holder()", 0); } else { Printv(arg, "value", 0); } break; case Ctor: Printf(arg, "args[%d]", i); break; default: throw "Illegal state."; } tm = emitInputTypemap(n, p, wrapper, arg); Delete(arg); if (tm) { p = Getattr(p, "tmap:in:next"); } else { p = nextSibling(p); } } } int V8Emitter::emitNamespaces() { Iterator it; for (it = First(namespaces); it.item; it = Next(it)) { Hash *entry = it.item; String *name = Getattr(entry, NAME); String *name_mangled = Getattr(entry, NAME_MANGLED); String *parent = Getattr(entry, PARENT); String *parent_mangled = Swig_name_mangle(parent); bool do_create = true; bool do_register = true; if (Equal(parent, "")) { do_register = false; } // Note: 'exports' is by convention the name of the object where // globals are stored into if (Equal(name, "exports")) { do_create = false; } if (do_create) { // create namespace object and register it to the parent scope Template t_create_ns = getTemplate("jsv8_create_namespace"); t_create_ns.replace("$jsmangledname", name_mangled) .trim() .pretty_print(f_init_namespaces); } if (do_register) { Template t_register_ns = getTemplate("jsv8_register_namespace"); t_register_ns.replace("$jsmangledname", name_mangled) .replace("$jsname", name) .replace("$jsparent", parent_mangled) .trim(); // prepend in order to achieve reversed order of registration statements String *tmp_register_stmt = NewString(""); t_register_ns.pretty_print(tmp_register_stmt); Insert(f_init_register_namespaces, 0, tmp_register_stmt); Delete(tmp_register_stmt); } } return SWIG_OK; } JSEmitter *swig_javascript_create_V8Emitter() { return new V8Emitter(); } /********************************************************************** * Helper implementations **********************************************************************/ JSEmitterState::JSEmitterState() : globalHash(NewHash()) { // initialize sub-hashes Setattr(globalHash, "class", NewHash()); Setattr(globalHash, "function", NewHash()); Setattr(globalHash, "variable", NewHash()); } JSEmitterState::~JSEmitterState() { Delete(globalHash); } DOH *JSEmitterState::getState(const char *key, bool new_key) { if (new_key) { Hash *hash = NewHash(); Setattr(globalHash, key, hash); } return Getattr(globalHash, key); } DOH *JSEmitterState::globals() { return globalHash; } DOH *JSEmitterState::globals(const char *key, DOH *initial) { if (initial != 0) { Setattr(globalHash, key, initial); } return Getattr(globalHash, key); } DOH *JSEmitterState::clazz(bool new_key) { return getState("class", new_key); } DOH *JSEmitterState::clazz(const char *key, DOH *initial) { DOH *c = clazz(); if (initial != 0) { Setattr(c, key, initial); } return Getattr(c, key); } DOH *JSEmitterState::function(bool new_key) { return getState("function", new_key); } DOH *JSEmitterState::function(const char *key, DOH *initial) { DOH *f = function(); if (initial != 0) { Setattr(f, key, initial); } return Getattr(f, key); } DOH *JSEmitterState::variable(bool new_key) { return getState("variable", new_key); } DOH *JSEmitterState::variable(const char *key, DOH *initial) { DOH *v = variable(); if (initial != 0) { Setattr(v, key, initial); } return Getattr(v, key); } /*static*/ int JSEmitterState::IsSet(DOH *val) { if (!val) { return 0; } else { const char *cval = Char(val); if (!cval) return 0; return (strcmp(cval, "0") != 0) ? 1 : 0; } } /* ----------------------------------------------------------------------------- * Template::Template() : creates a Template class for given template code * ----------------------------------------------------------------------------- */ Template::Template(const String *code_) { if (!code_) { Printf(stdout, "Template code was null. Illegal input for template."); SWIG_exit(EXIT_FAILURE); } code = NewString(code_); templateName = NewString(""); } Template::Template(const String *code_, const String *templateName_) { if (!code_) { Printf(stdout, "Template code was null. Illegal input for template."); SWIG_exit(EXIT_FAILURE); } code = NewString(code_); templateName = NewString(templateName_); } /* ----------------------------------------------------------------------------- * Template::~Template() : cleans up of Template. * ----------------------------------------------------------------------------- */ Template::~Template() { Delete(code); Delete(templateName); } /* ----------------------------------------------------------------------------- * String* Template::str() : retrieves the current content of the template. * ----------------------------------------------------------------------------- */ String *Template::str() { if (js_template_enable_debug) { String *pre_code = NewString(""); String *post_code = NewString(""); String *debug_code = NewString(""); Printf(pre_code, "/* begin fragment(\"%s\") */", templateName); Printf(post_code, "/* end fragment(\"%s\") */", templateName); Printf(debug_code, "%s\n%s\n%s\n", pre_code, code, post_code); Delete(code); Delete(pre_code); Delete(post_code); code = debug_code; } return code; } Template & Template::trim() { const char *str = Char(code); if (str == 0) return *this; int length = Len(code); if (length == 0) return *this; int idx; for (idx = 0; idx < length; ++idx) { if (str[idx] != ' ' && str[idx] != '\t' && str[idx] != '\r' && str[idx] != '\n') break; } int start_pos = idx; for (idx = length - 1; idx >= start_pos; --idx) { if (str[idx] != ' ' && str[idx] != '\t' && str[idx] != '\r' && str[idx] != '\n') break; } int end_pos = idx; int new_length = end_pos - start_pos + 1; char *newstr = new char[new_length + 1]; memcpy(newstr, str + start_pos, new_length); newstr[new_length] = 0; Delete(code); code = NewString(newstr); delete[]newstr; return *this; } /* ----------------------------------------------------------------------------- * Template& Template::replace(const String* pattern, const String* repl) : * * replaces all occurences of a given pattern with a given replacement. * * - pattern: the pattern to be replaced * - repl: the replacement string * - returns a reference to the Template to allow chaining of methods. * ----------------------------------------------------------------------------- */ Template & Template::replace(const String *pattern, const String *repl) { Replaceall(code, pattern, repl); return *this; } Template & Template::print(DOH *doh) { Printv(doh, str(), 0); return *this; } Template & Template::pretty_print(DOH *doh) { Wrapper_pretty_print(str(), doh); return *this; } Template::Template(const Template & t) { code = NewString(t.code); templateName = NewString(t.templateName); } void Template::operator=(const Template & t) { Delete(code); Delete(templateName); code = NewString(t.code); templateName = NewString(t.templateName); } swig-3.0.2/Source/Modules/emit.cxx0000664000175000017500000003433512343605122016705 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * emit.cxx * * Useful functions for emitting various pieces of code. * ----------------------------------------------------------------------------- */ #include "swigmod.h" /* ----------------------------------------------------------------------------- * emit_return_variable() * * Emits a variable declaration for a function return value. * The variable name is always called result. * n => Node of the method being wrapped * rt => the return type * f => the wrapper to generate code into * ----------------------------------------------------------------------------- */ void emit_return_variable(Node *n, SwigType *rt, Wrapper *f) { if (!GetFlag(n, "tmap:out:optimal")) { if (rt && (SwigType_type(rt) != T_VOID)) { SwigType *vt = cplus_value_type(rt); SwigType *tt = vt ? vt : rt; SwigType *lt = SwigType_ltype(tt); String *lstr = SwigType_str(lt, Swig_cresult_name()); if (SwigType_ispointer(lt)) { Wrapper_add_localv(f, Swig_cresult_name(), lstr, "= 0", NULL); } else { Wrapper_add_local(f, Swig_cresult_name(), lstr); } if (vt) { Delete(vt); } Delete(lt); Delete(lstr); } } } /* ----------------------------------------------------------------------------- * emit_parameter_variables() * * Emits a list of variable declarations for function parameters. * The variable names are always called arg1, arg2, etc... * l => the parameter list * f => the wrapper to generate code into * ----------------------------------------------------------------------------- */ void emit_parameter_variables(ParmList *l, Wrapper *f) { Parm *p; String *tm; /* Emit function arguments */ Swig_cargs(f, l); /* Attach typemaps to parameters */ /* Swig_typemap_attach_parms("ignore",l,f); */ Swig_typemap_attach_parms("default", l, f); Swig_typemap_attach_parms("arginit", l, f); /* Apply the arginit and default */ p = l; while (p) { tm = Getattr(p, "tmap:arginit"); if (tm) { Replace(tm, "$target", Getattr(p, "lname"), DOH_REPLACE_ANY); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:arginit:next"); } else { p = nextSibling(p); } } /* Apply the default typemap */ p = l; while (p) { tm = Getattr(p, "tmap:default"); if (tm) { Replace(tm, "$target", Getattr(p, "lname"), DOH_REPLACE_ANY); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:default:next"); } else { p = nextSibling(p); } } } /* ----------------------------------------------------------------------------- * emit_attach_parmmaps() * * Attach the standard parameter related typemaps. * ----------------------------------------------------------------------------- */ void emit_attach_parmmaps(ParmList *l, Wrapper *f) { Swig_typemap_attach_parms("in", l, f); Swig_typemap_attach_parms("typecheck", l, 0); Swig_typemap_attach_parms("argout", l, f); Swig_typemap_attach_parms("check", l, f); Swig_typemap_attach_parms("freearg", l, f); { /* This is compatibility code to deal with the deprecated "ignore" typemap */ Parm *p = l; Parm *np; String *tm; while (p) { tm = Getattr(p, "tmap:in"); if (tm && checkAttribute(p, "tmap:in:numinputs", "0")) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); np = Getattr(p, "tmap:in:next"); while (p && (p != np)) { /* Setattr(p,"ignore","1"); Deprecate */ p = nextSibling(p); } } else if (tm) { p = Getattr(p, "tmap:in:next"); } else { p = nextSibling(p); } } } /* Perform a sanity check on "in" and "freearg" typemaps. These must exactly match to avoid chaos. If a mismatch occurs, we nuke the freearg typemap */ { Parm *p = l; Parm *npin, *npfreearg; while (p) { npin = Getattr(p, "tmap:in:next"); /* if (Getattr(p,"tmap:ignore")) { npin = Getattr(p,"tmap:ignore:next"); } else if (Getattr(p,"tmap:in")) { npin = Getattr(p,"tmap:in:next"); } */ if (Getattr(p, "tmap:freearg")) { npfreearg = Getattr(p, "tmap:freearg:next"); if (npin != npfreearg) { while (p != npin) { Delattr(p, "tmap:freearg"); Delattr(p, "tmap:freearg:next"); p = nextSibling(p); } } } p = npin; } } /* Check for variable length arguments with no input typemap. If no input is defined, we set this to ignore and print a message. */ { Parm *p = l; Parm *lp = 0; while (p) { if (!checkAttribute(p, "tmap:in:numinputs", "0")) { lp = p; p = Getattr(p, "tmap:in:next"); continue; } if (SwigType_isvarargs(Getattr(p, "type"))) { Swig_warning(WARN_LANG_VARARGS, input_file, line_number, "Variable length arguments discarded.\n"); Setattr(p, "tmap:in", ""); } lp = 0; p = nextSibling(p); } /* Check if last input argument is variable length argument */ if (lp) { p = lp; while (p) { if (SwigType_isvarargs(Getattr(p, "type"))) { Setattr(l, "emit:varargs", lp); break; } p = nextSibling(p); } } } } /* ----------------------------------------------------------------------------- * emit_num_arguments() * * Calculate the total number of arguments. This function is safe for use * with multi-argument typemaps which may change the number of arguments in * strange ways. * ----------------------------------------------------------------------------- */ int emit_num_arguments(ParmList *parms) { Parm *p = parms; int nargs = 0; while (p) { if (Getattr(p, "tmap:in")) { nargs += GetInt(p, "tmap:in:numinputs"); p = Getattr(p, "tmap:in:next"); } else { p = nextSibling(p); } } /* DB 04/02/2003: Not sure this is necessary with tmap:in:numinputs */ /* if (parms && (p = Getattr(parms,"emit:varargs"))) { if (!nextSibling(p)) { nargs--; } } */ return nargs; } /* ----------------------------------------------------------------------------- * emit_num_required() * * Computes the number of required arguments. This function is safe for * use with multi-argument typemaps and knows how to skip over everything * properly. Note that parameters with default values are counted unless * the compact default args option is on. * ----------------------------------------------------------------------------- */ int emit_num_required(ParmList *parms) { Parm *p = parms; int nargs = 0; Parm *first_default_arg = 0; int compactdefargs = ParmList_is_compactdefargs(p); while (p) { if (Getattr(p, "tmap:in") && checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } else { if (Getattr(p, "tmap:default")) break; if (Getattr(p, "value")) { if (!first_default_arg) first_default_arg = p; if (compactdefargs) break; } nargs += GetInt(p, "tmap:in:numinputs"); if (Getattr(p, "tmap:in")) { p = Getattr(p, "tmap:in:next"); } else { p = nextSibling(p); } } } /* Print error message for non-default arguments following default arguments */ /* The error message is printed more than once with most language modules, this ought to be fixed */ if (first_default_arg) { p = first_default_arg; while (p) { if (Getattr(p, "tmap:in") && checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } else { if (!Getattr(p, "value") && (!Getattr(p, "tmap:default"))) { Swig_error(Getfile(p), Getline(p), "Non-optional argument '%s' follows an optional argument.\n", Getattr(p, "name")); } if (Getattr(p, "tmap:in")) { p = Getattr(p, "tmap:in:next"); } else { p = nextSibling(p); } } } } /* DB 04/02/2003: Not sure this is necessary with tmap:in:numinputs */ /* if (parms && (p = Getattr(parms,"emit:varargs"))) { if (!nextSibling(p)) { nargs--; } } */ return nargs; } /* ----------------------------------------------------------------------------- * emit_isvarargs() * * Checks if a function is a varargs function * ----------------------------------------------------------------------------- */ int emit_isvarargs(ParmList *p) { if (!p) return 0; if (Getattr(p, "emit:varargs")) return 1; return 0; } /* ----------------------------------------------------------------------------- * void emit_mark_vararg_parms() * * Marks the vararg parameters which are to be ignored. * Vararg parameters are marked as ignored if there is no 'in' varargs (...) * typemap. * ----------------------------------------------------------------------------- */ void emit_mark_varargs(ParmList *l) { Parm *p = l; while (p) { if (SwigType_isvarargs(Getattr(p, "type"))) if (!Getattr(p, "tmap:in")) Setattr(p, "varargs:ignore", "1"); p = nextSibling(p); } } #if 0 /* replace_contract_args. This function replaces argument names in contract specifications. Used in conjunction with the %contract directive. */ static void replace_contract_args(Parm *cp, Parm *rp, String *s) { while (cp && rp) { String *n = Getattr(cp, "name"); if (n) { Replace(s, n, Getattr(rp, "lname"), DOH_REPLACE_ID); } cp = nextSibling(cp); rp = nextSibling(rp); } } #endif /* ----------------------------------------------------------------------------- * int emit_action_code() * * Emits action code for a wrapper. Adds in exception handling code (%exception). * eaction -> the action code to emit * wrappercode -> the emitted code (output) * ----------------------------------------------------------------------------- */ int emit_action_code(Node *n, String *wrappercode, String *eaction) { assert(Getattr(n, "wrap:name")); /* Look for except feature (%exception) */ String *tm = GetFlagAttr(n, "feature:except"); if (tm) tm = Copy(tm); if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { if (Strstr(tm, "$")) { Swig_replace_special_variables(n, parentNode(n), tm); Replaceall(tm, "$function", eaction); // deprecated Replaceall(tm, "$action", eaction); } Printv(wrappercode, tm, "\n", NIL); Delete(tm); return 1; } else { Printv(wrappercode, eaction, "\n", NIL); return 0; } } /* ----------------------------------------------------------------------------- * int emit_action() * * Emits the call to the wrapped function. * Adds in exception specification exception handling and %exception code. * ----------------------------------------------------------------------------- */ String *emit_action(Node *n) { String *actioncode = NewStringEmpty(); String *tm; String *action; String *wrap; ParmList *catchlist = Getattr(n, "catchlist"); /* Look for fragments */ { String *fragment = Getattr(n, "feature:fragment"); if (fragment) { char *c, *tok; String *t = Copy(fragment); c = Char(t); tok = strtok(c, ","); while (tok) { String *fname = NewString(tok); Setfile(fname, Getfile(n)); Setline(fname, Getline(n)); Swig_fragment_emit(fname); Delete(fname); tok = strtok(NULL, ","); } Delete(t); } } /* Emit wrapper code (if any) */ wrap = Getattr(n, "wrap:code"); if (wrap && Swig_filebyname("header") != Getattr(n, "wrap:code:done")) { File *f_code = Swig_filebyname("header"); if (f_code) { Printv(f_code, wrap, NIL); } Setattr(n, "wrap:code:done", f_code); } action = Getattr(n, "feature:action"); if (!action) action = Getattr(n, "wrap:action"); assert(action != 0); /* Emit contract code (if any) */ if (Swig_contract_mode_get()) { /* Preassertion */ tm = Getattr(n, "contract:preassert"); if (Len(tm)) { Printv(actioncode, tm, "\n", NIL); } } /* Exception handling code */ /* saves action -> eaction for postcatching exception */ String *eaction = NewString(""); /* If we are in C++ mode and there is an exception specification. We're going to enclose the block in a try block */ if (catchlist) { Printf(eaction, "try {\n"); } String *preaction = Getattr(n, "wrap:preaction"); if (preaction) Printv(eaction, preaction, NIL); Printv(eaction, action, NIL); String *postaction = Getattr(n, "wrap:postaction"); if (postaction) Printv(eaction, postaction, NIL); if (catchlist) { int unknown_catch = 0; int has_varargs = 0; Printf(eaction, "}\n"); for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) { String *em = Swig_typemap_lookup("throws", ep, "_e", 0); if (em) { SwigType *et = Getattr(ep, "type"); SwigType *etr = SwigType_typedef_resolve_all(et); if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) { Printf(eaction, "catch(%s) {", SwigType_str(et, "_e")); } else if (SwigType_isvarargs(etr)) { Printf(eaction, "catch(...) {"); has_varargs = 1; } else { Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e")); } Printv(eaction, em, "\n", NIL); Printf(eaction, "}\n"); } else { Swig_warning(WARN_TYPEMAP_THROW, Getfile(n), Getline(n), "No 'throws' typemap defined for exception type '%s'\n", SwigType_str(Getattr(ep, "type"), 0)); unknown_catch = 1; } } if (unknown_catch && !has_varargs) { Printf(eaction, "catch(...) { throw; }\n"); } } /* Look for except typemap (Deprecated) */ tm = Swig_typemap_lookup("except", n, Swig_cresult_name(), 0); if (tm) { Setattr(n, "feature:except", tm); tm = 0; } /* emit the except feature code */ emit_action_code(n, actioncode, eaction); Delete(eaction); /* Emit contract code (if any) */ if (Swig_contract_mode_get()) { /* Postassertion */ tm = Getattr(n, "contract:postassert"); if (Len(tm)) { Printv(actioncode, tm, "\n", NIL); } } return actioncode; } swig-3.0.2/Source/Modules/allegrocl.cxx0000664000175000017500000030601412343605122017707 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * allegrocl.cxx * * ALLEGROCL language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" #include // #define ALLEGROCL_DEBUG // #define ALLEGROCL_WRAP_DEBUG // #define ALLEGROCL_TYPE_DEBUG // #define ALLEGROCL_CLASS_DEBUG static const char *usage = "\ Allegro CL Options (available with -allegrocl)\n\ -identifier-converter - \n\ Specifies the type of conversion to do on C identifiers to convert\n\ them to symbols. There are two built-in converters: 'null' and\n\ 'lispify'. The default is 'null'. If you supply a name other\n\ than one of the built-ins, then a function by that name will be\n\ called to convert identifiers to symbols.\n\ -[no]cwrap - Turn on or turn off generation of an intermediate C file when\n\ creating a C interface. By default this is only done for C++ code.\n\ -isolate - Define all SWIG helper functions in a package unique to this\n\ module. Avoids redefinition warnings when loading multiple\n\ SWIGged modules into the same running Allegro CL image.\n\ "; static File *f_cl = 0; String *f_clhead = NewString(""); String *f_clwrap = NewString("(swig-in-package ())\n\n"); static File *f_begin; static File *f_runtime; static File *f_cxx_header = 0; static File *f_cxx_wrapper = 0; static String *module_name = 0; static String *swig_package = 0; static String *identifier_converter = NewString("identifier-convert-null"); static bool CWrap = true; // generate wrapper file for C code by default. most correct. static bool Generate_Wrapper = false; static bool unique_swig_package = false; static SwigType *fwdref_ffi_type = NewString("__SWIGACL_FwdReference"); static String *current_namespace = NewString(""); static String *current_package = NewString(""); static Hash *defined_namespace_packages = NewHash(); static Node *in_class = 0; static Node *first_linked_type = 0; static Hash *defined_foreign_types = NewHash(); static Hash *defined_foreign_ltypes = NewHash(); static String *anon_type_name = NewString("anontype"); static int anon_type_count = 0; // stub String *convert_literal(String *num_param, String *type, bool try_to_split = true); class ALLEGROCL:public Language { public: virtual void main(int argc, char *argv[]); virtual int top(Node *n); virtual int functionWrapper(Node *n); virtual int namespaceDeclaration(Node *n); virtual int constructorHandler(Node *n); virtual int destructorHandler(Node *n); virtual int globalvariableHandler(Node *n); virtual int variableWrapper(Node *n); virtual int constantWrapper(Node *n); virtual int memberfunctionHandler(Node *n); virtual int membervariableHandler(Node *n); virtual int classHandler(Node *n); virtual int emit_one(Node *n); virtual int enumDeclaration(Node *n); virtual int enumvalueDeclaration(Node *n); virtual int typedefHandler(Node *n); virtual int classforwardDeclaration(Node *n); virtual int templateDeclaration(Node *n); virtual int validIdentifier(String *s); private: int emit_defun(Node *n, File *f_cl); int emit_dispatch_defun(Node *n); int emit_buffered_defuns(Node *n); int cClassHandler(Node *n); int cppClassHandler(Node *n); }; static ALLEGROCL *allegrocl = 0; static String *trim(String *str) { char *c = Char(str); while (*c != '\0' && isspace((int) *c)) ++c; String *result = NewString(c); Chop(result); return result; } int is_integer(String *s) { char *c = Char(s); if (c[0] == '#' && (c[1] == 'x' || c[1] == 'o')) c += 2; while (*c) { if (!isdigit(*c)) return 0; c++; } return 1; } String *class_from_class_or_class_ref(String *type) { SwigType *stripped = SwigType_strip_qualifiers(type); if (SwigType_isclass(stripped)) return stripped; if (SwigType_ispointer(stripped) || SwigType_isreference(stripped)) { // Printf(stderr,"It is a pointer/reference. Is it a class?\n"); SwigType_pop(stripped); if (SwigType_isclass(stripped)) { return stripped; } } return 0; } String *lookup_defined_foreign_type(String *k) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "Looking up defined type '%s'.\n Found: '%s'\n", k, Getattr(defined_foreign_types, k)); #endif return Getattr(defined_foreign_types, k); } String *listify_namespace(String *namespaze) { if (Len(namespaze) == 0) return NewString("()"); String *result = NewStringf("(\"%s\")", namespaze); Replaceall(result, "::", "\" \""); return result; } String *namespaced_name(Node *n, String *ns = current_namespace) { return NewStringf("%s%s%s", ns, (Len(ns) != 0) ? "::" : "", Getattr(n, "sym:name")); } // "Namespace::Nested::Class2::Baz" -> "Baz" static String *strip_namespaces(String *str) { return Swig_scopename_last(str); } void add_linked_type(Node *n) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Adding linked node of type: %s(%s) %s(%p)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n); // Swig_print_node(n); #endif if (!first_linked_type) { first_linked_type = n; Setattr(n, "allegrocl:last_linked_type", n); } else { Node *t = Getattr(first_linked_type, "allegrocl:last_linked_type"); Setattr(t, "allegrocl:next_linked_type", n); Setattr(first_linked_type, "allegrocl:last_linked_type", n); } } void replace_linked_type(Node *old, Node *new_node) { Node *prev = Getattr(old, "allegrocl:prev_linked_type"); Setattr(new_node, "allegrocl:next_linked_type", Getattr(old, "allegrocl:next_linked_type")); if (prev) Setattr(prev, "allegrocl:next_linked_type", new_node); Delattr(old, "allegrocl:next_linked_type"); Delattr(old, "allegrocl:prev_linked_type"); // check if we're replacing the first link. if (first_linked_type == old) { first_linked_type = new_node; Setattr(first_linked_type, "allegrocl:last_linked_type", Getattr(old, "allegrocl:last_linked_type")); } // check if we're replacing the last link. if (Getattr(first_linked_type, "allegrocl:last_linked_type") == old) Setattr(first_linked_type, "allegrocl:last_linked_type", new_node); } void insert_linked_type_at(Node *old, Node *new_node, int before = 1) { Node *p = 0; if (!first_linked_type) { add_linked_type(new_node); return; } if (!before) { Setattr(new_node, "allegrocl:next_linked_type", Getattr(old, "allegrocl:next_linked_type")); Setattr(old, "allegrocl:next_linked_type", new_node); if (Getattr(first_linked_type, "allegrocl:last_linked_type") == old) Setattr(first_linked_type, "allegrocl:last_linked_type", new_node); } else { Node *c = first_linked_type; while (c) { if (c == old) { break; } else { p = c; c = Getattr(c, "allegrocl:next_linked_type"); } } if (c == old) { Setattr(new_node, "allegrocl:next_linked_type", c); if (first_linked_type == c) { first_linked_type = new_node; Setattr(first_linked_type, "allegrocl:last_linked_type", Getattr(c, "allegrocl:last_linked_type")); Delattr(c, "allegrocl:last_linked_type"); } if (p) Setattr(p, "allegrocl:next_linked_type", new_node); } } } Node *find_linked_type_by_name(String *name) { Node *p = 0; Node *c = first_linked_type; // Printf(stderr,"in find_linked_type_by_name '%s'...", name); while (c) { String *key = Getattr(c, "name"); if (!Strcmp(key, name)) { break; } else { p = c; c = Getattr(c, "allegrocl:next_linked_type"); } } // Printf(stderr,"exit find_linked_type_by_name.\n"); if (p && c) Setattr(c, "allegrocl:prev_linked_type", p); // Printf(stderr,"find_linked_type_by_name: DONE\n"); return c; } Node *get_primary_synonym_of(Node *n) { Node *p = Getattr(n, "allegrocl:synonym-of"); Node *prim = n; // Printf(stderr, "getting primary synonym of %p\n", n); while (p) { // Printf(stderr, " found one! %p\n", p); prim = p; p = Getattr(p, "allegrocl:synonym-of"); } // Printf(stderr,"get_primary_syn: DONE. returning %s(%p)\n", Getattr(prim,"name"),prim); return prim; } void add_forward_referenced_type(Node *n, int overwrite = 0) { String *k = Getattr(n, "name"); String *name = Getattr(n, "sym:name"); String *ns = listify_namespace(current_namespace); String *val = Getattr(defined_foreign_types, k); if (!val || overwrite) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "Adding forward reference for %s (overwrite=%d)\n", k, overwrite); #endif Setattr(defined_foreign_types, Copy(k), NewString("forward-reference")); String *mangled_lname_gen = NewStringf("#.(swig-insert-id \"%s\" %s :type :class)", name, ns); Setattr(defined_foreign_ltypes, Copy(k), mangled_lname_gen); // Printf(f_cl, ";; forward reference stub\n" // "(swig-def-foreign-class \"%s\" (ff:foreign-pointer) (:class ))\n\n" // , name); #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Linking forward reference type = %s(%p)\n", k, n); #endif add_linked_type(n); } } void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String *name = 0, String *ns = current_namespace) { String *val; String *ns_list = listify_namespace(ns); String *templated = n ? Getattr(n, "template") : 0; String *cDeclName = n ? Getattr(n, "name") : 0; #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "IN A-D-F-T. (n=%p, ow=%d, k=%s, name=%s, ns=%s\n", n, overwrite, k, name, ns); Printf(stderr, " templated = '%p', classDecl = '%p'\n", templated, cDeclName); #endif if (n) { if (!name) name = Getattr(n, "sym:name"); if (!name) name = strip_namespaces(Getattr(n, "name")); if (templated) { k = namespaced_name(n); } else { String *kind_of_type = Getattr(n, "kind"); /* For typedefs of the form: typedef struct __xxx { ... } xxx; behavior differs between C mode and C++ mode. C Mode: add_defined_foreign_type will be called once via classHandler to define the type for 'struct __xxx' and add the mapping from 'struct __xxx' -> 'xxx' It will also be called once via typedefHandler to add the mapping 'xxx' -> 'xxx' C++ Mode: add_defined_foreign_type will be called once via classHandler to define the type for 'xxx'. it also adds the mapping from 'xxx' -> 'xxx' and also for 'struct xxx' -> 'xxx' In typedefHandler, we again try to add the mapping from 'xxx' -> 'xxx', which already exists. This second mapping is ignored. Both modes: All references to this typedef'd struct will appear in generated lisp code as an objectd of type 'xxx'. For non-typedef'd structs, the classHand mapping will be struct __xxx -> (swig-insert-id "__xxx") */ // Swig_print_node(n); String *unnamed = Getattr(n, "unnamed"); if (kind_of_type && (!Strcmp(kind_of_type, "struct") || !Strcmp(kind_of_type, "union")) && cDeclName && !unnamed) { k = NewStringf("%s %s", kind_of_type, cDeclName); } else { if (!Strcmp(nodeType(n), "enum") && unnamed) { name = NewStringf("%s%d", anon_type_name, anon_type_count++); k = NewStringf("enum %s", name); Setattr(n, "allegrocl:name", name); } else { k = k ? k : Getattr(n, "name"); } } } // Swig_print_node(n); } String *tname = SwigType_istemplate_templateprefix(name); if (tname) { String *temp = strip_namespaces(tname); name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name)); Delete(temp); Delete(tname); } val = lookup_defined_foreign_type(k); int is_fwd_ref = 0; if (val) is_fwd_ref = !Strcmp(val, "forward-reference"); if (!val || overwrite || is_fwd_ref) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Adding defined type '%s' = '%s' '%s' (overwrite=%d, in-class=%d)\n", k, ns, name, overwrite, in_class); #endif String *mangled_name_gen = NewStringf("#.(swig-insert-id \"%s\" %s :type :type)", name, ns_list); String *mangled_lname_gen = NewStringf("#.(swig-insert-id \"%s\" %s :type :class)", name, ns_list); Setattr(defined_foreign_types, Copy(k), Copy(mangled_name_gen)); Setattr(defined_foreign_ltypes, Copy(k), Copy(mangled_lname_gen)); if (CPlusPlus) { bool cpp_struct = Strstr(k, "struct ") ? true : false; bool cpp_union = Strstr(k, "union ") ? true : false; String *cpp_type = 0; if (cpp_struct) { cpp_type = Copy(k); Replaceall(cpp_type, "struct ", ""); } else if (cpp_union) { cpp_type = Copy(k); Replaceall(cpp_type, "union ", ""); } if (cpp_struct || cpp_union) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, " Also adding defined type '%s' = '%s' '%s' (overwrite=%d)\n", cpp_type, ns, name, overwrite); #endif Setattr(defined_foreign_types, Copy(cpp_type), Copy(mangled_name_gen)); Setattr(defined_foreign_ltypes, Copy(cpp_type), Copy(mangled_lname_gen)); } } #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "looking to add %s/%s(%p) to linked_type_list...\n", k, name, n); #endif if (is_fwd_ref) { // Printf(stderr,"*** 1\n"); if (n) add_linked_type(n); } else { // Printf(stderr,"*** 1-a\n"); if (SwigType_istemplate(k)) { SwigType *resolved = SwigType_typedef_resolve_all(k); // Printf(stderr,"*** 1-b\n"); Node *match = find_linked_type_by_name(resolved); Node *new_node = 0; // Printf(stderr, "*** temp-1\n"); if (n) { new_node = n; } else { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Creating a new templateInst:\n"); Printf(stderr, " name = %s\n", resolved); Printf(stderr, " sym:name = %s\n", name); Printf(stderr, " real-name = %s\n", k); Printf(stderr, " type = %s\n", resolved); Printf(stderr, " ns = %s\n\n", ns); #endif new_node = NewHash(); Setattr(new_node, "nodeType", "templateInst"); Setattr(new_node, "name", Copy(resolved)); Setattr(new_node, "sym:name", Copy(name)); Setattr(new_node, "real-name", Copy(k)); Setattr(new_node, "type", Copy(resolved)); Setattr(new_node, "allegrocl:namespace", ns); Setattr(new_node, "allegrocl:package", ns); } if (!match) { if (!Strcmp(nodeType(new_node), "templateInst") && in_class) { /* this is an implicit template instantiation found while walking a class. need to insert this into the linked_type list before the current class definition */ #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "trying to insert a templateInst before a class\n"); #endif insert_linked_type_at(in_class, new_node); #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "DID IT!\n"); #endif } else { // Printf(stderr,"*** 3\n"); add_linked_type(new_node); } Setattr(new_node, "allegrocl:synonym:is-primary", "1"); } else { // a synonym type was found (held in variable 'match') // Printf(stderr, "setting primary synonym of %p to %p\n", new_node, match); if (new_node == match) Printf(stderr, "Hey-4 * - '%s' is a synonym of iteself!\n", Getattr(new_node, "name")); Setattr(new_node, "allegrocl:synonym-of", match); // Printf(stderr,"*** 4\n"); add_linked_type(new_node); } } else { Node *match; if (!Strcmp(nodeType(n), "cdecl") && !Strcmp(Getattr(n, "storage"), "typedef")) { SwigType *type = SwigType_strip_qualifiers(Getattr(n, "type")); #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Examining typedef '%s' for class references. (%d)\n", type, SwigType_isclass(type)); #endif if (SwigType_isclass(type)) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Found typedef of a class '%s'\n", type); #endif /* For the following parsed expression: typedef struct __xxx { ... } xxx; if n is of kind "class" (defining the class 'struct __xxx' then we add n to the linked type list. if n is "cdecl" node of storage "typedef" (to note that xxx is equivalent to 'struct __xxx' then we don't want to add this node to the linked type list. */ String *defined_type = lookup_defined_foreign_type(type); String *defined_key_type = lookup_defined_foreign_type(k); if ((Strstr(type, "struct ") || Strstr(type, "union ")) && defined_type && !Strcmp(defined_type, defined_key_type)) { // mark as a synonym but don't add to linked_type list // Printf(stderr,"*** 4.8\n"); Setattr(n, "allegrocl:synonym", "1"); } else { SwigType *lookup_type = SwigType_istemplate(type) ? SwigType_typedef_resolve_all(type) : Copy(type); match = find_linked_type_by_name(lookup_type); if (match) { Setattr(n, "allegrocl:synonym", "1"); Setattr(n, "allegrocl:synonym-of", match); Setattr(n, "real-name", Copy(lookup_type)); // Printf(stderr, "*** pre-5: found match of '%s'(%p)\n", Getattr(match,"name"),match); // if(n == match) Printf(stderr, "Hey-5 *** setting synonym of %p to %p\n", n, match); // Printf(stderr,"*** 5\n"); add_linked_type(n); } else { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Creating classfoward node for struct stub in typedef.\n"); #endif Node *new_node = NewHash(); String *symname = Copy(type); Replaceall(symname, "struct ", ""); Setattr(new_node, "nodeType", "classforward"); Setattr(new_node, "name", Copy(type)); Setattr(new_node, "sym:name", symname); Setattr(new_node, "allegrocl:namespace", ns); Setattr(new_node, "allegrocl:package", ns); String *mangled_new_name = NewStringf("#.(swig-insert-id \"%s\" %s)", symname, ns_list); String *mangled_new_lname = NewStringf("#.(swig-insert-id \"%s\" %s :type :class)", symname, ns_list); Setattr(defined_foreign_types, Copy(symname), Copy(mangled_new_name)); Setattr(defined_foreign_ltypes, Copy(symname), Copy(mangled_new_lname)); // Printf(stderr,"Weird! Can't find the type!\n"); add_forward_referenced_type(new_node); add_linked_type(new_node); Setattr(n, "allegrocl:synonym", "1"); Setattr(n, "allegrocl:synonym-of", new_node); add_linked_type(n); } Delete(lookup_type); } } else { // check if it's a pointer or reference to a class. // Printf(stderr,"Checking if '%s' is a p. or r. to a class\n", type); String *class_ref = class_from_class_or_class_ref(type); if (class_ref) { match = find_linked_type_by_name(class_ref); Setattr(n, "allegrocl:synonym", "1"); Setattr(n, "allegrocl:synonym-of", match); add_linked_type(n); } } Delete(type); // synonym types have already been added. // Printf(stderr,"*** 10\n"); if (!Getattr(n, "allegrocl:synonym")) add_linked_type(n); } else if (Getattr(n, "template")) { // Printf(stderr, "this is a class template node(%s)\n", nodeType(n)); String *resolved = SwigType_typedef_resolve_all(Getattr(n, "name")); #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, " looking up %s for linked type match with %s...\n", Getattr(n, "sym:name"), resolved); #endif match = find_linked_type_by_name(resolved); if (!match) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "found no implicit instantiation of %%template node %s(%p)\n", Getattr(n, "name"), n); #endif add_linked_type(n); } else { Node *primary = get_primary_synonym_of(match); Setattr(n, "allegrocl:synonym:is-primary", "1"); Delattr(primary, "allegrocl:synonym:is-primary"); if (n == match) Printf(stderr, "Hey-7 * setting synonym of %p to %p\n (match = %p)", primary, n, match); Setattr(primary, "allegrocl:synonym-of", n); // Printf(stderr,"*** 7\n"); add_linked_type(n); } } else { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "linking type '%s'(%p)\n", k, n); #endif // Printf(stderr,"*** 8\n"); add_linked_type(n); } } } Delete(mangled_name_gen); Delete(mangled_lname_gen); } else { if (!CPlusPlus || Strcmp(Getattr(n,"kind"),"typedef")) { Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n), "Attempting to store a foreign type that exists: %s (%s)\n", k, val); } } Delete(ns_list); #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "OUT A-D-F-T\n"); #endif } void note_implicit_template_instantiation(SwigType *t) { // the namespace of the implicit instantiation is not necessarily // current_namespace. Attempt to cull this from the type. #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "culling namespace of '%s' from '%s'\n", t, SwigType_templateprefix(t)); #endif SwigType *type = Copy(t); SwigType *tok = SwigType_pop(type); String *implicit_ns = SwigType_istemplate(tok) ? Swig_scopename_prefix(SwigType_templateprefix(tok)) : 0; add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace); Delete(type); } String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) { /* lookup defined foreign type. if it exists, it will return a form suitable for placing into lisp code to generate the def-foreign-type name */ #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "inside g_f_t: looking up '%s' '%s'\n", ty, name); #endif String *found_type = lookup_defined_foreign_type(ty); if (found_type) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "found_type '%s'\n", found_type); #endif return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : get_ffi_type(n, fwdref_ffi_type, "")); } else { Node *node = NewHash(); Setattr(node, "type", ty); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup("ffitype", node, name, 0); Delete(node); if (tm) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "g-f-t: found ffitype typemap '%s'\n", tm); #endif return NewString(tm); } if (SwigType_istemplate(ty)) { note_implicit_template_instantiation(ty); return Copy(lookup_defined_foreign_type(ty)); } } return 0; } String *lookup_defined_foreign_ltype(String *l) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "Looking up defined ltype '%s'.\n Found: '%s'\n", l, Getattr(defined_foreign_ltypes, l)); #endif return Getattr(defined_foreign_ltypes, l); } /* walk type and return string containing lisp version. recursive. */ String *internal_compose_foreign_type(Node *n, SwigType *ty) { SwigType *tok; String *ffiType = NewString(""); // for a function type, need to walk the parm list. while (Len(ty) != 0) { tok = SwigType_pop(ty); if (SwigType_isfunction(tok)) { // Generate Function wrapper Printf(ffiType, "(:function "); // walk parm list List *pl = SwigType_parmlist(tok); Printf(ffiType, "("); // start parm list for (Iterator i = First(pl); i.item; i = Next(i)) { SwigType *f_arg = SwigType_strip_qualifiers(i.item); Printf(ffiType, "%s ", internal_compose_foreign_type(n, f_arg)); Delete(f_arg); } Printf(ffiType, ")"); // end parm list. // do function return type. Printf(ffiType, " %s)", internal_compose_foreign_type(n, ty)); break; } else if (SwigType_ispointer(tok) || SwigType_isreference(tok)) { Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty)); } else if (SwigType_isarray(tok)) { Printf(ffiType, "(:array %s", internal_compose_foreign_type(n, ty)); String *atype = NewString("int"); String *dim = convert_literal(SwigType_array_getdim(tok, 0), atype); Delete(atype); if (is_integer(dim)) { Printf(ffiType, " %s)", dim); } else { Printf(ffiType, " #| %s |#)", SwigType_array_getdim(tok, 0)); } } else if (SwigType_ismemberpointer(tok)) { // temp Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty)); } else { String *res = get_ffi_type(n, tok, ""); if (res) { Printf(ffiType, "%s", res); } else { SwigType *resolved_type = SwigType_typedef_resolve_all(tok); if (Cmp(resolved_type, tok) != 0) { res = get_ffi_type(n, resolved_type, ""); if (res) { } else { res = internal_compose_foreign_type(n, resolved_type); } if (res) Printf(ffiType, "%s", res); } if (!res) { String *is_struct = 0; String *tok_remove_text = 0; String *tok_name = Copy(tok); String *tok_key = SwigType_str(tok,0); if ((is_struct = Strstr(tok_key, "struct ")) || Strstr(tok_key, "union ")) { tok_remove_text = NewString(is_struct ? "struct " : "union "); } /* be more permissive of opaque types. This is the swig way. compiles will notice if these types are ultimately not present. */ if(tok_remove_text) { Replaceall(tok_name,tok_remove_text,""); } tok_name = strip_namespaces(tok_name); Delete(tok_remove_text); // Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(tok), Getline(tok), "Unable to find definition of '%s', assuming forward reference.\n", tok); #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "i-c-f-t: adding forward reference for unknown type '%s'. mapping: %s -> %s\n", tok, tok_key, tok_name); #endif Node *nn = NewHash(); Setattr(nn,"nodeType","classforward"); Setattr(nn,"kind","class"); Setattr(nn,"sym:name",tok_name); Setattr(nn,"name",tok_key); Setattr(nn,"allegrocl:package",current_namespace); add_forward_referenced_type(nn, 0); // tok_name is dangling here, unused. ouch. why? Printf(ffiType, "%s", get_ffi_type(n, tok, ""), tok_name); } } } } return ffiType; } String *compose_foreign_type(Node *n, SwigType *ty, String * /*id*/ = 0) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty); // Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0)); /* String *id_ref = SwigType_str(ty, id); Printf(stderr, "looking up typemap for %s, found '%s'(%p)\n", id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res); if (lookup_res) Swig_print_node(lookup_res); */ #endif /* should we allow named lookups in the typemap here? YES! */ /* unnamed lookups should be found in get_ffi_type, called by internal_compose_foreign_type(), below. */ /* I'm reverting to 'no' for the question above. I can no longer remember why I needed it. If a user needed it, I'll find out as soon as they upgrade. Sigh. -mutandiz 9/16/2008. */ /* if(id && lookup_res) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "compose_foreign_type: EXIT-1 (%s)\n ", Getattr(lookup_res, "code")); #endif return NewString(Getattr(lookup_res, "code")); } */ SwigType *temp = SwigType_strip_qualifiers(ty); String *res = internal_compose_foreign_type(n, temp); Delete(temp); #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "compose_foreign_type: EXIT (%s)\n ", res); #endif return res; } void update_package_if_needed(Node *n, File *f = f_clwrap) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "update_package: ENTER... \n"); Printf(stderr, " current_package = '%s'\n", current_package); Printf(stderr, " node_package = '%s'\n", Getattr(n, "allegrocl:package")); Printf(stderr, " node(%p) = '%s'\n", n, Getattr(n, "name")); #endif String *node_package = Getattr(n, "allegrocl:package"); if (Strcmp(current_package, node_package)) { String *lispy_package = listify_namespace(node_package); Delete(current_package); current_package = Copy(node_package); Printf(f, "\n(swig-in-package %s)\n", lispy_package); Delete(lispy_package); } #ifdef ALLEGROCL_DEBUG Printf(stderr, "update_package: EXIT.\n"); #endif } static String *mangle_name(Node *n, char const *prefix = "ACL", String *ns = current_namespace) { String *suffix = Getattr(n, "sym:overname"); String *pre_mangled_name = NewStringf("%s_%s__%s%s", prefix, ns, Getattr(n, "sym:name"), suffix); String *mangled_name = Swig_name_mangle(pre_mangled_name); Delete(pre_mangled_name); return mangled_name; } /* utilities */ /* remove a pointer from ffitype. non-destructive. (* :char) ==> :char (* (:array :int 30)) ==> (:array :int 30) */ String *dereference_ffitype(String *ffitype) { char *start; char *temp = Char(ffitype); String *reduced_type = 0; if(temp && temp[0] == '(' && temp[1] == '*') { temp += 2; // walk past start of pointer references while(*temp == ' ') temp++; start = temp; // temp = Char(reduced_type); reduced_type = NewString(start); temp = Char(reduced_type); // walk to end of string. remove closing paren while(*temp != '\0') temp++; *(--temp) = '\0'; } return reduced_type ? reduced_type : Copy(ffitype); } /* returns new string w/ parens stripped */ String *strip_parens(String *string) { string = Copy(string); Replaceall(string, "(", ""); Replaceall(string, ")", ""); return string; } int ALLEGROCL::validIdentifier(String *s) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "validIdentifier %s\n", s); #endif char *c = Char(s); bool got_dot = false; bool only_dots = true; /* Check that s is a valid common lisp symbol. There's a lot of leeway here. A common lisp symbol is essentially any token that's not a number and does not consist of only dots. We are expressly not allowing spaces in identifiers here, but spaces could be added via the identifier converter. */ while (*c) { if (*c == '.') { got_dot = true; } else { only_dots = false; } if (!isgraph(*c)) return 0; c++; } return (got_dot && only_dots) ? 0 : 1; } String *infix_to_prefix(String *val, char split_op, const String *op, String *type) { List *ored = Split(val, split_op, -1); // some float hackery if (((split_op == '+') || (split_op == '-')) && Len(ored) == 2 && (SwigType_type(type) == T_FLOAT || SwigType_type(type) == T_DOUBLE || SwigType_type(type) == T_LONGDOUBLE)) { // check that we're not splitting a float String *possible_result = convert_literal(val, type, false); if (possible_result) return possible_result; } // try parsing the split results. if any part fails, kick out. bool part_failed = false; if (Len(ored) > 1) { String *result = NewStringf("(%s", op); for (Iterator i = First(ored); i.item; i = Next(i)) { String *converted = convert_literal(i.item, type); if (converted) { Printf(result, " %s", converted); Delete(converted); } else { part_failed = true; break; } } Printf(result, ")"); Delete(ored); return part_failed ? 0 : result; } Delete(ored); return 0; } /* To be called by code generating the lisp interface Will return a containing the literal based on type. Will return null if there are problems. try_to_split defaults to true (see stub above). */ String *convert_literal(String *literal, String *type, bool try_to_split) { String *num_param = Copy(literal); String *trimmed = trim(num_param); String *num = strip_parens(trimmed), *res = 0; char *s = Char(num); String *ns = listify_namespace(current_namespace); // very basic parsing of infix expressions. if (try_to_split && SwigType_type(type) != T_STRING) { if ((res = infix_to_prefix(num, '|', "logior", type))) return res; if ((res = infix_to_prefix(num, '&', "logand", type))) return res; if ((res = infix_to_prefix(num, '^', "logxor", type))) return res; if ((res = infix_to_prefix(num, '*', "*", type))) return res; if ((res = infix_to_prefix(num, '/', "/", type))) return res; if ((res = infix_to_prefix(num, '+', "+", type))) return res; if ((res = infix_to_prefix(num, '-', "-", type))) return res; // if ((res = infix_to_prefix(num, '~', "lognot", type))) return res; // if( (res = infix_to_prefix(num, '<<', "ash", type)) ) return res; } // unary complement... if (s[0] == '~' && Len(num) >= 2) { String *id = NewString(++s); String *id_conv = convert_literal(id, type, false); Delete(id); if (id_conv) return NewStringf("(lognot %s)", id_conv); s--; } if (SwigType_type(type) == T_FLOAT || SwigType_type(type) == T_DOUBLE || SwigType_type(type) == T_LONGDOUBLE) { // Use CL syntax for float literals String *oldnum = Copy(num); // careful. may be a float identifier or float constant. char *num_start = Char(num); char *num_end = num_start + strlen(num_start) - 1; bool is_literal = isdigit(*num_start) || (*num_start == '.'); String *lisp_exp = 0; if (is_literal) { if (*num_end == 'f' || *num_end == 'F') { lisp_exp = NewString("f"); } else { lisp_exp = NewString("d"); } if (*num_end == 'l' || *num_end == 'L' || *num_end == 'f' || *num_end == 'F') { *num_end = '\0'; num_end--; } int exponents = Replaceall(num, "e", lisp_exp) + Replaceall(num, "E", lisp_exp); if (!exponents) Printf(num, "%s0", lisp_exp); if (exponents > 1 || (exponents + Replaceall(num, ".", ".") == 0)) { // Printf(stderr, "Can't parse '%s' as type '%s'.\n", oldnum, type); Delete(num); num = 0; } Delete(lisp_exp); } else { String *id = NewStringf("#.(swig-insert-id \"%s\" %s :type :constant)", num, ns); Delete(num); num = id; } Delete(oldnum); Delete(trimmed); Delete(ns); return num; } else if (SwigType_type(type) == T_CHAR) { /* Use CL syntax for character literals */ Delete(num); Delete(trimmed); return NewStringf("#\\%s", num_param); } else if (SwigType_type(type) == T_STRING) { /* Use CL syntax for string literals */ Delete(num); Delete(trimmed); return NewStringf("\"%s\"", num_param); } else if (Len(num) >= 1 && (isdigit(s[0]) || s[0] == '+' || s[0] == '-')) { /* use CL syntax for numbers */ String *oldnum = Copy(num); int usuffixes = Replaceall(num, "u", "") + Replaceall(num, "U", ""); int lsuffixes = Replaceall(num, "l", "") + Replaceall(num, "L", ""); if (usuffixes > 1 || lsuffixes > 1) { Printf(stderr, "Weird!! number %s looks invalid.\n", oldnum); SWIG_exit(EXIT_FAILURE); } s = Char(num); if (s[0] == '0' && Len(num) >= 2) { /*octal or hex */ res = NewStringf("#%c%s", tolower(s[1]) == 'x' ? 'x' : 'o', s + 2); Delete(num); } else { res = num; } Delete(oldnum); Delete(trimmed); return res; } else if (allegrocl->validIdentifier(num)) { /* convert C/C++ identifiers to CL symbols */ res = NewStringf("#.(swig-insert-id \"%s\" %s :type :constant)", num, ns); Delete(num); Delete(trimmed); Delete(ns); return res; } else { Delete(trimmed); return num; } } void emit_stub_class(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_stub_class: ENTER... '%s'(%p)\n", Getattr(n, "sym:name"), n); Swig_print_node(n); #endif String *name = Getattr(n, "sym:name"); if (Getattr(n, "allegrocl:synonym:already-been-stubbed")) return; String *tname = SwigType_istemplate_templateprefix(name); if (tname) { String *temp = strip_namespaces(tname); name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name)); Delete(temp); Delete(tname); } else { name = strip_namespaces(name); } // Printf(f_clhead, ";; from emit-stub-class\n"); update_package_if_needed(n, f_clhead); Printf(f_clhead, ";; class template stub.\n"); Printf(f_clhead, "(swig-def-foreign-stub \"%s\")\n", name); Setattr(n, "allegrocl:synonym:already-been-stubbed", "1"); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_stub_class: EXIT\n"); #endif } void emit_synonym(Node *synonym) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_synonym: ENTER... \n"); #endif // Printf(stderr,"in emit_synonym for %s(%p)\n", Getattr(synonym,"name"),synonym); int is_tempInst = !Strcmp(nodeType(synonym), "templateInst"); String *synonym_type; Node *of = get_primary_synonym_of(synonym); if (is_tempInst) { // Printf(stderr, "*** using real-name '%s'\n", Getattr(synonym,"real-name")); synonym_type = Getattr(synonym, "real-name"); } else { // Printf(stderr, "*** using name '%s'\n", Getattr(synonym,"name")); synonym_type = Getattr(synonym, "name"); } String *synonym_ns = listify_namespace(Getattr(synonym, "allegrocl:namespace")); String *syn_ltype, *syn_type, *of_ltype; // String *of_cdeclname = Getattr(of,"allegrocl:classDeclarationName"); String *of_ns = Getattr(of, "allegrocl:namespace"); String *of_ns_list = listify_namespace(of_ns); // String *of_name = of_cdeclname ? NewStringf("struct %s", Getattr(of,"name")) : NewStringf("%s::%s", of_ns, Getattr(of,"sym:name")); // String *of_name = NewStringf("%s::%s", of_ns, Getattr(of,"sym:name")); String *of_name = namespaced_name(of, of_ns); if (CPlusPlus && !Strcmp(nodeType(synonym), "cdecl")) { String *real_name = Getattr(synonym, "real-name"); if (!real_name) real_name = NewString("Unknown"); // TODO: fix syn_ltype = NewStringf("#.(swig-insert-id \"%s\" %s :type :class)", strip_namespaces(real_name), synonym_ns); syn_type = NewStringf("#.(swig-insert-id \"%s\" %s :type :type)", strip_namespaces(real_name), synonym_ns); } else { syn_ltype = lookup_defined_foreign_ltype(synonym_type); syn_type = lookup_defined_foreign_type(synonym_type); } of_ltype = lookup_defined_foreign_ltype(of_name); // Printf(stderr,";; from emit-synonym syn='%s' of_ltype='%s'\n", syn_ltype, of_ltype); if( of_ltype ) Printf(f_clhead, "(swig-def-synonym-type %s\n %s\n %s)\n", syn_ltype, of_ltype, syn_type); Delete(synonym_ns); Delete(of_ns_list); Delete(of_name); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_synonym: EXIT\n"); #endif } void emit_full_class(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_full_class: ENTER... \n"); #endif String *name = Getattr(n, "sym:name"); String *kind = Getattr(n, "kind"); // Printf(stderr,"in emit_full_class: '%s'(%p).", Getattr(n,"name"),n); if (Getattr(n, "allegrocl:synonym-of")) { // Printf(stderr,"but it's a synonym of something.\n"); update_package_if_needed(n, f_clhead); emit_synonym(n); return; } // collect superclasses String *bases = Getattr(n, "bases"); String *supers = NewString("("); if (bases) { int first = 1; for (Iterator i = First(bases); i.item; i = Next(i)) { if (!first) Printf(supers, " "); String *s = lookup_defined_foreign_ltype(Getattr(i.item, "name")); // String *name = Getattr(i.item,"name"); if (s) { Printf(supers, "%s", s); } else { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "emit_templ_inst: did not find ltype for base class %s (%s)", Getattr(i.item, "name"), Getattr(n, "allegrocl:namespace")); #endif } } } else { Printf(supers, "ff:foreign-pointer"); } // check for "feature:aclmixins" and add those as well. Printf(supers, " %s)", Getattr(n,"feature:aclmixins")); // Walk children to generate type definition. String *slotdefs = NewString(" "); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, " walking children...\n"); #endif Node *c; for (c = firstChild(n); c; c = nextSibling(c)) { String *storage_type = Getattr(c, "storage"); if ((!Strcmp(nodeType(c), "cdecl") && (!storage_type || Strcmp(storage_type, "typedef")))) { String *access = Getattr(c, "access"); // hack. why would decl have a value of "variableHandler" and now "0"? String *childDecl = Getattr(c, "decl"); // Printf(stderr,"childDecl = '%s' (%s)\n", childDecl, Getattr(c,"view")); if (!childDecl || !Strcmp(childDecl, "0")) childDecl = NewString(""); SwigType *childType; String *cname; // don't include types for private slots (yet). spr33959. if(access && Strcmp(access,"public")) { childType = NewStringf("int"); cname = NewString("nil"); } else { childType = NewStringf("%s%s", childDecl, Getattr(c, "type")); cname = Copy(Getattr(c, "name")); } if (!SwigType_isfunction(childType)) { // Printf(slotdefs, ";;; member functions don't appear as slots.\n "); // Printf(slotdefs, ";; "); String *ns = listify_namespace(Getattr(n, "allegrocl:package")); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "slot name = '%s' ns = '%s' class-of '%s' and type = '%s'\n", cname, ns, name, childType); #endif Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, compose_foreign_type(n, childType)); Delete(ns); if (access && Strcmp(access, "public")) Printf(slotdefs, " ;; %s member", access); Printf(slotdefs, "\n "); } Delete(childType); Delete(cname); } } String *ns_list = listify_namespace(Getattr(n, "allegrocl:namespace")); update_package_if_needed(n, f_clhead); Printf(f_clhead, "(swig-def-foreign-class \"%s\"\n %s\n (:%s\n%s))\n\n", name, supers, kind, slotdefs); Delete(supers); Delete(ns_list); Setattr(n, "allegrocl:synonym:already-been-stubbed", "1"); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_full_class: EXIT\n"); #endif } void emit_class(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_class: ENTER... '%s'(%p)\n", Getattr(n, "sym:name"), n); #endif int is_tempInst = !Strcmp(nodeType(n), "templateInst"); String *ns_list = listify_namespace(Getattr(n, "allegrocl:namespace")); String *name = Getattr(n, is_tempInst ? "real-name" : "name"); String *tname = SwigType_istemplate_templateprefix(name); if (tname) { String *temp = strip_namespaces(tname); name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name)); Delete(temp); Delete(tname); } else { name = strip_namespaces(name); } if (Getattr(n, "allegrocl:synonym:is-primary")) { // Printf(stderr," is primary... "); if (is_tempInst) { emit_stub_class(n); } else { emit_full_class(n); } } else { // Node *primary = Getattr(n,"allegrocl:synonym-of"); Node *primary = get_primary_synonym_of(n); if (primary && (primary != n)) { // Printf(stderr," emitting synonym... "); emit_stub_class(primary); update_package_if_needed(n, f_clhead); emit_synonym(n); } else { emit_full_class(n); } } // Printf(stderr,"DONE\n"); Delete(name); Delete(ns_list); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_class: EXIT\n"); #endif } void emit_typedef(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_typedef: ENTER... \n"); #endif String *name; String *sym_name = Getattr(n, "sym:name"); String *type = NewStringf("%s%s", Getattr(n, "decl"), Getattr(n, "type")); String *lisp_type = compose_foreign_type(n, type); Delete(type); Node *in_class = Getattr(n, "allegrocl:typedef:in-class"); // Printf(stderr,"in emit_typedef: '%s'(%p).",Getattr(n,"name"),n); if (Getattr(n, "allegrocl:synonym-of")) { // Printf(stderr," but it's a synonym of something.\n"); emit_synonym(n); return; } if (in_class) { String *class_name = Getattr(in_class, "name"); String *tname = SwigType_istemplate_templateprefix(class_name); if (tname) { String *temp = strip_namespaces(tname); class_name = NewStringf("%s%s%s", temp, SwigType_templateargs(class_name), SwigType_templatesuffix(class_name)); Delete(temp); Delete(tname); } name = NewStringf("%s__%s", class_name, sym_name); Setattr(n, "allegrocl:in-class", in_class); } else { name = sym_name ? Copy(sym_name) : Copy(Getattr(n, "name")); } // leave these in for now. might want to change these to def-foreign-class at some point. // Printf(f_clhead, ";; %s\n", SwigType_typedef_resolve_all(lisp_type)); Printf(f_clhead, "(swig-def-foreign-type \"%s\"\n %s)\n", name, lisp_type); Delete(name); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_typedef: EXIT\n"); #endif } void emit_enum_type_no_wrap(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_enum_type_no_wrap: ENTER... \n"); #endif String *unnamed = Getattr(n, "unnamed"); String *name; // SwigType *enumtype; name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name"); SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name); Node *node = NewHash(); Setattr(node, "type", tmp); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0); Delete(node); Delete(tmp); if (name) { String *ns = listify_namespace(current_namespace); Printf(f_clhead, "(swig-def-foreign-type \"%s\" %s)\n", name, enumtype); Delete(ns); // walk children. Node *c; for (c = firstChild(n); c; c = nextSibling(c)) { if (!Getattr(c, "error")) { String *val = Getattr(c, "enumvalue"); if (!val) val = Getattr(c, "enumvalueex"); String *converted_val = convert_literal(val, Getattr(c, "type")); String *valname = Getattr(c, "sym:name"); if (converted_val) { Printf(f_clhead, "(swig-defconstant \"%s\" %s)\n", valname, converted_val); Delete(converted_val); } else { Swig_warning(WARN_LANG_DISCARD_CONST, Getfile(n), Getline(n), "Unable to parse enum value '%s'. Setting to NIL\n", val); Printf(f_clhead, "(swig-defconstant \"%s\" nil #| %s |#)\n", valname, val); } } } } Printf(f_clhead, "\n"); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_enum_type_no_wrap: EXIT\n"); #endif } void emit_enum_type(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_enum_type: ENTER... \n"); #endif if (!Generate_Wrapper) { emit_enum_type_no_wrap(n); return; } String *unnamed = Getattr(n, "unnamed"); String *name; // SwigType *enumtype; name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name"); SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name); Node *node = NewHash(); Setattr(node, "type", tmp); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0); Delete(node); Delete(tmp); if (name) { String *ns = listify_namespace(current_namespace); Printf(f_clhead, "(swig-def-foreign-type \"%s\" %s)\n", name, enumtype); Delete(ns); // walk children. Node *c; for(c = firstChild(n); c; c=nextSibling(c)) { String *mangled_name = mangle_name(c, "ACL_ENUM", Getattr(c,"allegrocl:package")); Printf(f_clhead, "(swig-defvar \"%s\" \"%s\" :type :constant :ftype :signed-long)\n", Getattr(c, "sym:name"), mangled_name); Delete(mangled_name); } } #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_enum_type: EXIT\n"); #endif } void emit_default_linked_type(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_default_linked_type: ENTER... \n"); #endif // catchall for non class types. if (!Strcmp(nodeType(n), "classforward")) { Printf(f_clhead, ";; forward referenced stub.\n"); Printf(f_clhead, "(swig-def-foreign-class \"%s\" (ff:foreign-pointer) (:class ))\n\n", Getattr(n, "sym:name")); } else if (!Strcmp(nodeType(n), "enum")) { emit_enum_type(n); } else { Printf(stderr, "Don't know how to emit node type '%s' named '%s'\n", nodeType(n), Getattr(n, "name")); } #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_default_linked_type: EXIT\n"); #endif } void dump_linked_types(File *f) { Node *n = first_linked_type; int i = 0; while (n) { Printf(f, "%d: (%p) node '%s' name '%s'\n", i++, n, nodeType(n), Getattr(n, "sym:name")); Node *t = Getattr(n, "allegrocl:synonym-of"); if (t) Printf(f, " synonym-of %s(%p)\n", Getattr(t, "name"), t); n = Getattr(n, "allegrocl:next_linked_type"); } } void emit_linked_types() { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_linked_types: ENTER... "); #endif Node *n = first_linked_type; while (n) { String *node_type = nodeType(n); // Printf(stderr,"emitting node %s(%p) of type %s.", Getattr(n,"name"),n, nodeType(n)); if (!Strcmp(node_type, "class") || !Strcmp(node_type, "templateInst")) { // may need to emit a stub, so it will update the package itself. // Printf(stderr," Passing to emit_class."); emit_class(n); } else if (!Strcmp(nodeType(n), "cdecl")) { // Printf(stderr," Passing to emit_typedef."); update_package_if_needed(n, f_clhead); emit_typedef(n); } else { // Printf(stderr," Passing to default_emitter."); update_package_if_needed(n, f_clhead); emit_default_linked_type(n); } n = Getattr(n, "allegrocl:next_linked_type"); // Printf(stderr,"returned.\n"); } #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_linked_types: EXIT\n"); #endif } extern "C" Language *swig_allegrocl(void) { return (allegrocl = new ALLEGROCL()); } void ALLEGROCL::main(int argc, char *argv[]) { int i; Preprocessor_define("SWIGALLEGROCL 1", 0); SWIG_library_directory("allegrocl"); SWIG_config_file("allegrocl.swg"); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-identifier-converter")) { char *conv = argv[i + 1]; if (!conv) Swig_arg_error(); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; /* check for built-ins */ if (!strcmp(conv, "lispify")) { Delete(identifier_converter); identifier_converter = NewString("identifier-convert-lispify"); } else if (!strcmp(conv, "null")) { Delete(identifier_converter); identifier_converter = NewString("identifier-convert-null"); } else { /* Must be user defined */ Delete(identifier_converter); identifier_converter = NewString(conv); } } else if (!strcmp(argv[i], "-cwrap")) { CWrap = true; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-nocwrap")) { CWrap = false; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-isolate")) { unique_swig_package = true; Swig_mark_arg(i); } if (!strcmp(argv[i], "-help")) { Printf(stdout, "%s\n", usage); } } allow_overloading(); } int ALLEGROCL::top(Node *n) { module_name = Getattr(n, "name"); String *cxx_filename = Getattr(n, "outfile"); String *cl_filename = NewString(""); swig_package = unique_swig_package ? NewStringf("swig.%s", module_name) : NewString("swig"); Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), module_name); f_cl = NewFile(cl_filename, "w", SWIG_output_files()); if (!f_cl) { Printf(stderr, "Unable to open %s for writing\n", cl_filename); SWIG_exit(EXIT_FAILURE); } Generate_Wrapper = CPlusPlus || CWrap; if (Generate_Wrapper) { f_begin = NewFile(cxx_filename, "w", SWIG_output_files()); if (!f_begin) { Delete(f_cl); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); SWIG_exit(EXIT_FAILURE); } } else f_begin = NewString(""); f_runtime = NewString(""); f_cxx_header = f_runtime; f_cxx_wrapper = NewString(""); Swig_register_filebyname("header", f_cxx_header); Swig_register_filebyname("wrapper", f_cxx_wrapper); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("lisp", f_clwrap); Swig_register_filebyname("lisphead", f_cl); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGALLEGROCL\n"); Printf(f_runtime, "\n"); Swig_banner_target_lang(f_cl, ";;"); Printf(f_cl, "\n" "(defpackage :%s\n" " (:use :common-lisp :ff :excl)\n" " (:export #:*swig-identifier-converter* #:*swig-module-name*\n" " #:*void* #:*swig-export-list*))\n" "(in-package :%s)\n\n" "(eval-when (:compile-toplevel :load-toplevel :execute)\n" " (defparameter *swig-identifier-converter* '%s)\n" " (defparameter *swig-module-name* :%s))\n\n", swig_package, swig_package, identifier_converter, module_name); Printf(f_cl, "(defpackage :%s\n" " (:use :common-lisp :%s :ff :excl))\n\n", module_name, swig_package); Printf(f_clhead, "(in-package :%s)\n", module_name); Language::top(n); #ifdef ALLEGROCL_TYPE_DEBUG dump_linked_types(stderr); #endif emit_linked_types(); Printf(f_clwrap, "\n(cl::in-package :%s)\n", swig_package); Printf(f_clwrap, "\n(macrolet ((swig-do-export ()\n"); Printf(f_clwrap, " `(dolist (s ',*swig-export-list*)\n"); Printf(f_clwrap, " (apply #'export s))))\n"); Printf(f_clwrap, " (swig-do-export))\n"); Printf(f_clwrap, "\n(setq *swig-export-list* nil)\n"); Printf(f_cl, "%s\n", f_clhead); Printf(f_cl, "%s\n", f_clwrap); Delete(f_cl); Delete(f_clhead); Delete(f_clwrap); Dump(f_runtime, f_begin); Printf(f_begin, "%s\n", f_cxx_wrapper); Delete(f_runtime); Delete(f_begin); Delete(f_cxx_wrapper); // Swig_print_tree(n); return SWIG_OK; } /* very shamelessly 'borrowed' from overload.cxx, which keeps the below Swig_overload_rank() code to itself. We don't need a dispatch function in the C++ wrapper code; we want it over on the lisp side. */ #define Swig_overload_rank Allegrocl_swig_overload_rank #define MAX_OVERLOAD 256 /* Overload "argc" and "argv" */ // String *argv_template_string; // String *argc_template_string; struct Overloaded { Node *n; /* Node */ int argc; /* Argument count */ ParmList *parms; /* Parameters used for overload check */ int error; /* Ambiguity error */ }; /* ----------------------------------------------------------------------------- * Swig_overload_rank() * * This function takes an overloaded declaration and creates a list that ranks * all overloaded methods in an order that can be used to generate a dispatch * function. * Slight difference in the way this function is used by scripting languages and * statically typed languages. The script languages call this method via * Swig_overload_dispatch() - where wrappers for all overloaded methods are generated, * however sometimes the code can never be executed. The non-scripting languages * call this method via Swig_overload_check() for each overloaded method in order * to determine whether or not the method should be wrapped. Note the slight * difference when overloading methods that differ by const only. The * scripting languages will ignore the const method, whereas the non-scripting * languages ignore the first method parsed. * ----------------------------------------------------------------------------- */ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { Overloaded nodes[MAX_OVERLOAD]; int nnodes = 0; Node *o = Getattr(n, "sym:overloaded"); Node *c; if (!o) return 0; c = o; while (c) { if (Getattr(c, "error")) { c = Getattr(c, "sym:nextSibling"); continue; } /* if (SmartPointer && Getattr(c,"cplus:staticbase")) { c = Getattr(c,"sym:nextSibling"); continue; } */ /* Make a list of all the declarations (methods) that are overloaded with * this one particular method name */ if (Getattr(c, "wrap:name")) { nodes[nnodes].n = c; nodes[nnodes].parms = Getattr(c, "wrap:parms"); nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms); nodes[nnodes].error = 0; nnodes++; } c = Getattr(c, "sym:nextSibling"); } /* Sort the declarations by required argument count */ { int i, j; for (i = 0; i < nnodes; i++) { for (j = i + 1; j < nnodes; j++) { if (nodes[i].argc > nodes[j].argc) { Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; } } } } /* Sort the declarations by argument types */ { int i, j; for (i = 0; i < nnodes - 1; i++) { if (nodes[i].argc == nodes[i + 1].argc) { for (j = i + 1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) { Parm *p1 = nodes[i].parms; Parm *p2 = nodes[j].parms; int differ = 0; int num_checked = 0; while (p1 && p2 && (num_checked < nodes[i].argc)) { // Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type")); if (checkAttribute(p1, "tmap:in:numinputs", "0")) { p1 = Getattr(p1, "tmap:in:next"); continue; } if (checkAttribute(p2, "tmap:in:numinputs", "0")) { p2 = Getattr(p2, "tmap:in:next"); continue; } String *t1 = Getattr(p1, "tmap:typecheck:precedence"); String *t2 = Getattr(p2, "tmap:typecheck:precedence"); if ((!t1) && (!nodes[i].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), "Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); nodes[i].error = 1; } else if ((!t2) && (!nodes[j].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); nodes[j].error = 1; } if (t1 && t2) { int t1v, t2v; t1v = atoi(Char(t1)); t2v = atoi(Char(t2)); differ = t1v - t2v; } else if (!t1 && t2) differ = 1; else if (t1 && !t2) differ = -1; else if (!t1 && !t2) differ = -1; num_checked++; if (differ > 0) { Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; break; } else if ((differ == 0) && (Strcmp(t1, "0") == 0)) { t1 = Getattr(p1, "ltype"); if (!t1) { t1 = SwigType_ltype(Getattr(p1, "type")); if (Getattr(p1, "tmap:typecheck:SWIGTYPE")) { SwigType_add_pointer(t1); } Setattr(p1, "ltype", t1); } t2 = Getattr(p2, "ltype"); if (!t2) { t2 = SwigType_ltype(Getattr(p2, "type")); if (Getattr(p2, "tmap:typecheck:SWIGTYPE")) { SwigType_add_pointer(t2); } Setattr(p2, "ltype", t2); } /* Need subtype check here. If t2 is a subtype of t1, then we need to change the order */ if (SwigType_issubtype(t2, t1)) { Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; } if (Strcmp(t1, t2) != 0) { differ = 1; break; } } else if (differ) { break; } if (Getattr(p1, "tmap:in:next")) { p1 = Getattr(p1, "tmap:in:next"); } else { p1 = nextSibling(p1); } if (Getattr(p2, "tmap:in:next")) { p2 = Getattr(p2, "tmap:in:next"); } else { p2 = nextSibling(p2); } } if (!differ) { /* See if declarations differ by const only */ String *d1 = Getattr(nodes[i].n, "decl"); String *d2 = Getattr(nodes[j].n, "decl"); if (d1 && d2) { String *dq1 = Copy(d1); String *dq2 = Copy(d2); if (SwigType_isconst(d1)) { Delete(SwigType_pop(dq1)); } if (SwigType_isconst(d2)) { Delete(SwigType_pop(dq2)); } if (Strcmp(dq1, dq2) == 0) { if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { if (script_lang_wrapping) { // Swap nodes so that the const method gets ignored (shadowed by the non-const method) Overloaded t = nodes[i]; nodes[i] = nodes[j]; nodes[j] = t; } differ = 1; if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } nodes[j].error = 1; } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { differ = 1; if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } nodes[j].error = 1; } } Delete(dq1); Delete(dq2); } } if (!differ) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); } nodes[j].error = 1; } } } } } } List *result = NewList(); { int i; for (i = 0; i < nnodes; i++) { if (nodes[i].error) Setattr(nodes[i].n, "overload:ignore", "1"); Append(result, nodes[i].n); // Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms)); // Swig_print_node(nodes[i].n); } } return result; } /* end shameless borrowing */ int any_varargs(ParmList *pl) { Parm *p; for (p = pl; p; p = nextSibling(p)) { if (SwigType_isvarargs(Getattr(p, "type"))) return 1; } return 0; } String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) { Node *node = NewHash(); Setattr(node, "type", ty); Setattr(node, "name", name); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup("lisptype", node, "", 0); Delete(node); return tm ? NewString(tm) : NewString(""); } Node *parent_node_skipping_extends(Node *n) { Node *result = n; do { result = parentNode(result); } while (Cmp("extend", nodeType(result)) == 0); return result; } /* ----------------------------------------------------------------------------- * emit_num_lin_arguments() * * Calculate the total number of arguments. This function is safe for use * with multi-argument typemaps which may change the number of arguments in * strange ways. * ----------------------------------------------------------------------------- */ int emit_num_lin_arguments(ParmList *parms) { Parm *p = parms; int nargs = 0; while (p) { // Printf(stderr,"enla: '%s' lin='%p' numinputs='%s'\n", Getattr(p,"name"), Getattr(p,"tmap:lin"), Getattr(p,"tmap:lin:numinputs")); if (Getattr(p, "tmap:lin")) { nargs += GetInt(p, "tmap:lin:numinputs"); p = Getattr(p, "tmap:lin:next"); } else { p = nextSibling(p); } } /* DB 04/02/2003: Not sure this is necessary with tmap:in:numinputs */ /* if (parms && (p = Getattr(parms,"emit:varargs"))) { if (!nextSibling(p)) { nargs--; } } */ return nargs; } String *id_converter_type(SwigType const *type) { SwigType *t = Copy(type); String *result = 0; if (SwigType_ispointer(t)) { SwigType_pop(t); String *pointee = id_converter_type(t); result = NewStringf("(:* %s)", pointee); Delete(pointee); } else if (SwigType_ismemberpointer(t)) { String *klass = SwigType_parm(t); SwigType_pop(t); String *member = id_converter_type(t); result = NewStringf("(:member \"%s\" %s)", klass, member); Delete(klass); Delete(member); } else if (SwigType_isreference(t)) { SwigType_pop(t); String *referencee = id_converter_type(t); result = NewStringf("(:& %s)", referencee); Delete(referencee); } else if (SwigType_isarray(t)) { String *size = SwigType_parm(t); SwigType_pop(t); String *element_type = id_converter_type(t); result = NewStringf("(:array %s \"%s\")", element_type, size); Delete(size); Delete(element_type); } else if (SwigType_isfunction(t)) { result = NewString("(:function ("); String *parmlist_str = SwigType_parm(t); List *parms = SwigType_parmlist(parmlist_str); for (Iterator i = First(parms); i.item;) { String *parm = id_converter_type((SwigType *) i.item); Printf(result, "%s", parm); i = Next(i); if (i.item) Printf(result, " "); Delete(parm); } SwigType_pop(t); String *ret = id_converter_type(t); Printf(result, ") %s)", ret); Delete(parmlist_str); Delete(parms); Delete(ret); } else if (SwigType_isqualifier(t)) { result = NewString("(:qualified ("); String *qualifiers_str = Copy(SwigType_parm(t)); // ?! // Replaceall below SEGVs if we don't put the Copy here... SwigType_pop(t); String *qualifiee = id_converter_type(t); Replaceall(qualifiers_str, " ", " :"); if (Len(qualifiers_str) > 0) Printf(result, ":"); Printf(result, "%s) %s)", qualifiers_str, qualifiee); Delete(qualifiers_str); Delete(qualifiee); } else if (SwigType_istemplate(t)) { result = NewStringf("(:template \"%s\")", t); } else { /* if (SwigType_issimple(t)) */ if (Strstr(Char(t), "::")) { result = listify_namespace(t); } else { result = NewStringf("\"%s\"", t); } } Delete(t); return result; } static ParmList *parmlist_with_names(ParmList *pl) { ParmList *pl2 = CopyParmList(pl); for (Parm *p = pl, *p2 = pl2; p2; p = nextSibling(p), p2 = nextSibling(p2)) { if (!Getattr(p2, "name")) Setattr(p2, "name", Getattr(p2, "lname")); Setattr(p2, "name", strip_namespaces(Getattr(p2, "name"))); Setattr(p2, "tmap:ctype", Getattr(p, "tmap:ctype")); String *temp = Getattr(p, "tmap:lin"); if (temp) { Setattr(p2, "tmap:lin", temp); Setattr(p2, "tmap:lin:next", Getattr(p, "tmap:lin:next")); } } return pl2; } static String *parmlist_str_id_converter(ParmList *pl) { String *result = NewString(""); for (Parm *p = pl; p;) { String *lispy_type = id_converter_type(Getattr(p, "type")); Printf(result, "(\"%s\" %s)", Getattr(p, "name"), lispy_type); Delete(lispy_type); if ((p = nextSibling(p))) Printf(result, " "); } return result; } String *collect_others_args(Node *overload) { String *overloaded_from = Getattr(overload, "sym:overloaded"); String *others_args = NewString(""); int first_overload = 1; for (Node *overload2 = overloaded_from; overload2; overload2 = Getattr(overload2, "sym:nextSibling")) { if (overload2 == overload || GetInt(overload2, "overload:ignore")) continue; ParmList *opl = parmlist_with_names(Getattr(overload2, "wrap:parms")); String *args = parmlist_str_id_converter(opl); if (!first_overload) Printf(others_args, "\n "); Printf(others_args, "(%s)", args); Delete(args); Delete(opl); first_overload = 0; } return others_args; } struct IDargs { String *name; String *type; String *klass; String *arity; IDargs():name(0), type(0), klass(0), arity(0) { } String *full_quoted_str() { String *result = no_others_quoted_str(); if (arity) Printf(result, " :arity %s", arity); return result; } String *no_others_quoted_str() { String *result = NewString(""); Printf(result, "\"%s\" :type :%s", name, type); if (klass) Printf(result, " :class \"%s\"", klass); return result; } String *noname_str(bool include_class = true) { String *result = NewString(""); Printf(result, " :type :%s", type); if (klass && include_class) Printf(result, " :class \"%s\"", klass); if (arity) Printf(result, " :arity %s", arity); return result; } String *noname_no_others_str(bool include_class = true) { String *result = NewString(""); Printf(result, " :type :%s", type); if (klass && include_class) Printf(result, " :class \"%s\"", klass); return result; } }; IDargs *id_converter_arguments(Node *n) { IDargs *result = (IDargs *) GetVoid(n, "allegrocl:id-converter-args"); if (!result) result = new IDargs; // Base name if (!result->name) { result->name = Getattr(n, "allegrocl:old-sym:name"); if (!result->name) result->name = Getattr(n, "sym:name"); result->name = Copy(result->name); } // :type if (result->type) Delete(result->type); if (!Getattr(n, "allegrocl:kind")) Setattr(n, "allegrocl:kind", "function"); if (Strstr(Getattr(n, "name"), "operator ")) Replaceall(Getattr(n, "allegrocl:kind"), "function", "operator"); if (Strstr(Getattr(n, "allegrocl:kind"), "variable")) { int name_end = Len(Getattr(n, "sym:name")) - 4; char *str = Char(Getattr(n, "sym:name")); String *get_set = NewString(str + name_end + 1); result->type = Copy(Getattr(n, "allegrocl:kind")); Replaceall(result->type, "variable", ""); Printf(result->type, "%ster", get_set); Delete(get_set); } else { result->type = Copy(Getattr(n, "allegrocl:kind")); } // :class if (Strstr(result->type, "member ")) { Replaceall(result->type, "member ", ""); if (!result->klass) { result->klass = Copy(Getattr(parent_node_skipping_extends(n), "sym:name")); } } // :arity if (Getattr(n, "sym:overloaded")) { if (result->arity) Delete(result->arity); result->arity = NewStringf("%d", // emit_num_arguments(Getattr(n, "wrap:parms"))); emit_num_lin_arguments(Getattr(n, "wrap:parms"))); // Printf(stderr, "got arity of '%s' node '%s' '%p'\n", result->arity, Getattr(n,"name"), Getattr(n,"wrap:parms")); } SetVoid(n, "allegrocl:id-converter-args", result); return result; } int ALLEGROCL::emit_buffered_defuns(Node *n) { Node *overloaded_from = Getattr(n, "sym:overloaded"); String *wrap; if (!overloaded_from) { wrap = Getattr(n, "allegrocl:lisp-wrap"); Printf(f_clwrap, "%s\n", wrap); Delattr(n, "allegrocl:lisp-wrap"); Delete(wrap); } else { for (Node *overload = overloaded_from; overload; overload = Getattr(overload, "sym:nextSibling")) { String *others_args = collect_others_args(overload); wrap = Getattr(overload, "allegrocl:lisp-wrap"); Replaceall(wrap, "@@OTHERS-ARGS-GO-HERE@@", others_args); // IDargs* id_args = id_converter_arguments(overload); // Replaceall(id_args->others_args, "@@OTHERS-ARGS-GO-HERE@@", others_args); if (!GetInt(overload, "overload:ignore")) Printf(f_clwrap, "%s", wrap); Delattr(overload, "allegrocl:lisp-wrap"); Delete(wrap); } } return SWIG_OK; } String *dispatching_type(Node *n, Parm *p) { String *result = 0; String *parsed = Getattr(p, "type"); //Swig_cparse_type(Getattr(p,"tmap:ctype")); String *cl_t = SwigType_typedef_resolve_all(parsed); Node *node = NewHash(); Setattr(node, "type", parsed); Setfile(node, Getfile(n)); Setline(node, Getline(n)); const String *tm = Swig_typemap_lookup("lispclass", node, Getattr(p, "name"), 0); Delete(node); if (tm) { result = Copy(tm); } else { String *lookup_type = class_from_class_or_class_ref(parsed); if (lookup_type) result = lookup_defined_foreign_ltype(lookup_type); } // if (!result && SwigType_ispointer(cl_t)) { // SwigType_pop(cl_t); // result = lookup_defined_foreign_ltype(cl_t); // } if (!result) result = NewStringf("ff:foreign-pointer"); // Delete(parsed); Delete(cl_t); return result; } int ALLEGROCL::emit_dispatch_defun(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_dispatch_defun: ENTER... "); #endif List *overloads = Swig_overload_rank(n, true); // Printf(stderr,"\ndispatch node=%p\n\n", n); // Swig_print_node(n); Node *overloaded_from = Getattr(n,"sym:overloaded"); bool include_class = Getattr(overloaded_from, "allegrocl:dispatcher:include-class") ? true : false; String *id_args = id_converter_arguments(n)->noname_no_others_str(include_class); Printf(f_clwrap, "(swig-dispatcher (\"%s\" %s :arities (", Getattr(overloaded_from, "allegrocl:dispatcher:name"), id_args); Delattr(overloaded_from, "allegrocl:dispatcher:include-class"); Delattr(overloaded_from, "allegrocl:dispatcher:name"); int last_arity = -1; for (Iterator i = First(overloads); i.item; i = Next(i)) { int arity = emit_num_lin_arguments(Getattr(i.item, "wrap:parms")); if (arity == last_arity) continue; Printf(f_clwrap, "%s%d", last_arity == -1 ? "" : " ", arity); last_arity = arity; } Printf(f_clwrap, ")))\n"); Delete(id_args); Delete(overloads); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_dispatch_defun: EXIT\n"); #endif return SWIG_OK; } int ALLEGROCL::emit_defun(Node *n, File *fcl) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_defun: ENTER... "); #endif // avoid name conflicts between smart pointer wrappers and the wrappers for the // actual class. bool smartmemberwrapper = (!Cmp(Getattr(n, "view"), "memberfunctionHandler") && Getattr(n,"allocate:smartpointeraccess")); #ifdef ALLEGROCL_DEBUG int auto_generated = Cmp(Getattr(n, "view"), "globalfunctionHandler"); Printf(stderr, "%s%sfunction %s%s%s\n", auto_generated ? "> " : "", Getattr(n, "sym:overloaded") ? "overloaded " : "", current_namespace, (current_namespace) > 0 ? "::" : "", Getattr(n, "sym:name")); Printf(stderr, " (view: %s)\n", Getattr(n, "view")); Swig_print_node(n); #endif String *funcname = Getattr(n, "allegrocl:old-sym:name"); if (smartmemberwrapper || !funcname) funcname = Getattr(n, "sym:name"); String *mangled_name = Getattr(n, "wrap:name"); ParmList *pl = parmlist_with_names(Getattr(n, "wrap:parms")); // attach typemap info. Wrapper *wrap = NewWrapper(); Swig_typemap_attach_parms("lin", pl, wrap); // Swig_typemap_attach_parms("ffitype", pl, wrap); Swig_typemap_lookup("lout", n, Swig_cresult_name(), 0); SwigType *result_type = Swig_cparse_type(Getattr(n, "tmap:ctype")); // prime the pump, with support for OUTPUT, INOUT typemaps. Printf(wrap->code, "(cl::let ((ACL_ffresult %s:*void*)\n ACL_result)\n $body\n (cl::if (cl::eq ACL_ffresult %s:*void*)\n (cl::values-list ACL_result)\n (cl::values-list (cl::cons ACL_ffresult ACL_result))))", swig_package, swig_package); Parm *p; int largnum = 0, argnum = 0, first = 1; // int varargs=0; if (Generate_Wrapper) { String *extra_parms = id_converter_arguments(n)->noname_str(smartmemberwrapper ? false : true); Node *overloaded_from = Getattr(n,"sym:overloaded"); if (overloaded_from) { if(!GetFlag(overloaded_from,"allegrocl:dispatcher:name")) { Setattr(overloaded_from,"allegrocl:dispatcher:name",funcname); Setattr(overloaded_from,"allegrocl:dispatcher:include-class", smartmemberwrapper ? 0 : "1"); // Printf(stderr, " set a:d:name='%s', a:d:i-c='%s'\n", Getattr(n,"allegrocl:dispatcher:name"), Getattr(n,"allegrocl:dispatcher:include-class")); } Printf(fcl, "(swig-defmethod (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); } else Printf(fcl, "(swig-defun (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); Delete(extra_parms); } // Just C else { Printf(fcl, "(swig-defun (\"%s\" \"%s\")\n", funcname, Generate_Wrapper ? mangled_name : funcname); } ////////////////////////////////////// // Lisp foreign call parameter list // ////////////////////////////////////// Printf(fcl, " ("); /* Special cases */ if (ParmList_len(pl) == 0) { Printf(fcl, ":void"); /* } else if (any_varargs(pl)) { Printf(fcl, "#| varargs |#"); varargs=1; */ } else { String *largs = NewString(""); for (p = pl; p; p = nextSibling(p), argnum++, largnum++) { // SwigType *argtype=Getattr(p, "type"); SwigType *argtype = Swig_cparse_type(Getattr(p, "tmap:ctype")); SwigType *parmtype = Getattr(p,"type"); if (!first) { Printf(fcl, "\n "); } /* by default, skip varargs */ if (!SwigType_isvarargs(parmtype)) { String *argname = NewStringf("PARM%d_%s", largnum, Getattr(p, "name")); // Printf(stderr,"%s\n", Getattr(p,"tmap:lin")); String *ffitype = compose_foreign_type(n, argtype, Getattr(p,"name")); String *deref_ffitype = dereference_ffitype(ffitype); String *lisptype = get_lisp_type(n, parmtype, Getattr(p, "name")); #ifdef ALLEGROCL_DEBUG Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", parmtype, Getattr(p, "name"), lisptype); #endif // while we're walking the parameters, generating LIN // wrapper code... Setattr(p, "lname", NewStringf("SWIG_arg%d", largnum)); String *parm_code = Getattr(p, "tmap:lin"); if (parm_code) { String *lname = Getattr(p, "lname"); Printf(largs, " %s", lname); Replaceall(parm_code, "$in_fftype", ffitype); // must come before $in Replaceall(parm_code, "$in", argname); Replaceall(parm_code, "$out", lname); Replaceall(parm_code, "$*in_fftype", deref_ffitype); Replaceall(wrap->code, "$body", parm_code); } String *dispatchtype = Getattr(n, "sym:overloaded") ? dispatching_type(n, p) : NewString(""); // if this parameter has been removed from the C/++ wrapper // it shouldn't be in the lisp wrapper either. if (!checkAttribute(p, "tmap:in:numinputs", "0")) { Printf(fcl, "(%s %s %s %s %s)", // parms in the ff wrapper, but not in the lisp wrapper. (checkAttribute(p, "tmap:lin:numinputs", "0") ? ":p-" : ":p+"), argname, dispatchtype, ffitype, lisptype); first = 0; } Delete(argname); Delete(ffitype); Delete(deref_ffitype); Delete(lisptype); } } Printf(wrap->locals, "%s", largs); } String *lout = Getattr(n, "tmap:lout"); Replaceall(lout, "$owner", GetFlag(n, "feature:new") ? "t" : "nil"); Replaceall(wrap->code, "$body", lout); // $lclass handling. String *lclass = (String *) 0; SwigType *parsed = Swig_cparse_type(Getattr(n, "tmap:ctype")); // SwigType *cl_t = SwigType_typedef_resolve_all(parsed); SwigType *cl_t = class_from_class_or_class_ref(parsed); String *out_ffitype = compose_foreign_type(n, parsed); String *deref_out_ffitype; String *out_temp = Copy(parsed); if (SwigType_ispointer(out_temp)) { SwigType_pop(out_temp); deref_out_ffitype = compose_foreign_type(n, out_temp); } else { deref_out_ffitype = Copy(out_ffitype); } Delete(out_temp); Delete(parsed); if (cl_t) { lclass = lookup_defined_foreign_ltype(cl_t); } int ff_foreign_ptr = 0; if (!lclass) { ff_foreign_ptr = 1; lclass = NewStringf("ff:foreign-pointer"); } #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "for output wrapping %s: type=%s, ctype=%s\n", Getattr(n, "name"), Getattr(n, "type"), Swig_cparse_type(Getattr(n, "tmap:ctype"))); #endif if (lclass) Replaceall(wrap->code, "$lclass", lclass); if (out_ffitype) Replaceall(wrap->code, "$out_fftype", out_ffitype); if (deref_out_ffitype) Replaceall(wrap->code, "$*out_fftype", deref_out_ffitype); Replaceall(wrap->code, "$body", NewStringf("(swig-ff-call%s)", wrap->locals)); String *ldestructor = Copy(lclass); if (ff_foreign_ptr) Replaceall(ldestructor, ldestructor, "cl::identity"); else Replaceall(ldestructor, ":type :class", ":type :destructor"); Replaceall(wrap->code, "$ldestructor", ldestructor); Delete(ldestructor); Printf(fcl, ")\n"); /* finish arg list */ ///////////////////////////////////////////////////// // Lisp foreign call return type and optimizations // ///////////////////////////////////////////////////// Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), Swig_cresult_name())); for (Iterator option = First(n); option.item; option = Next(option)) { if (Strncmp("feature:ffargs:", option.key, 15)) continue; String *option_val = option.item; String *option_name = NewString(Char(option.key) + 14); Replaceall(option_name, "_", "-"); // TODO: varargs vs call-direct ? Printf(fcl, "\n %s %s", option_name, option_val); Delete(option_name); } Printf(fcl, ")\n %s)\n\n", wrap->code); // Wrapper_print(wrap, stderr); Delete(result_type); Delete(mangled_name); Delete(pl); DelWrapper(wrap); #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_defun: EXIT\n"); #endif return SWIG_OK; } int ALLEGROCL::functionWrapper(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "functionWrapper %s\n", Getattr(n,"name")); #endif ParmList *parms = CopyParmList(Getattr(n, "parms")); Wrapper *f = NewWrapper(); SwigType *t = Getattr(n, "type"); String *name = Getattr(n, "name"); String *raw_return_type = Swig_typemap_lookup("ctype", n, "", 0); SwigType *return_type = Swig_cparse_type(raw_return_type); SwigType *resolved = SwigType_typedef_resolve_all(return_type); int is_void_return = (Cmp(resolved, "void") == 0); Delete(resolved); if (!is_void_return) { String *lresult_init = NewStringf("= (%s)0", SwigType_str(SwigType_strip_qualifiers(return_type),0)); Wrapper_add_localv(f, "lresult", SwigType_lstr(SwigType_ltype(return_type), "lresult"), lresult_init, NIL); Delete(lresult_init); } // Emit all of the local variables for holding arguments. emit_parameter_variables(parms, f); // Attach the standard typemaps Swig_typemap_attach_parms("ctype", parms, f); Swig_typemap_attach_parms("lin", parms, f); emit_attach_parmmaps(parms, f); String *mangled = mangle_name(n); Node *overloaded = Getattr(n, "sym:overloaded"); // Parameter overloading Setattr(n, "wrap:parms", parms); Setattr(n, "wrap:name", mangled); if (overloaded) { // emit warnings when overloading is impossible on the lisp side. // basically Swig_overload_check(n), but with script_lang_wrapping // set to true. Delete(Swig_overload_rank(n, true)); if (Getattr(n, "overload:ignore")) { // if we're the last overload, make sure to force the emit // of the rest of the overloads before we leave. // Printf(stderr, "ignored overload %s(%p)\n", name, Getattr(n, "sym:nextSibling")); if (!Getattr(n, "sym:nextSibling")) { update_package_if_needed(n); emit_buffered_defuns(n); emit_dispatch_defun(n); } DelWrapper(f); return SWIG_OK; } } // Get number of required and total arguments int num_arguments = emit_num_arguments(parms); int gencomma = 0; #ifdef ALLEGROCL_DEBUG Printf(stderr, "Walking parameters for %s '%s'\n", Getattr(n, "allegrocl:kind"), name); #endif // Now walk the function parameter list and generate code to get arguments String *name_and_parms = NewStringf("%s (", mangled); int i; Parm *p; for (i = 0, p = parms; i < num_arguments; i++) { #ifdef ALLEGROCL_DEBUG String *temp1 = Getattr(p,"tmap:in"); String *temp2 = Getattr(p,"tmap:in:numinputs"); Printf(stderr," parm %d: %s, tmap:in='%s', tmap:in:numinputs='%s'\n", i, Getattr(p,"name"), temp1 ? temp1 : "", temp2 ? temp2 : ""); #endif while (p && checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } if (!p) break; SwigType *c_parm_type = Swig_cparse_type(Getattr(p, "tmap:ctype")); String *arg = NewStringf("l%s", Getattr(p, "lname")); // Emit parameter declaration if (gencomma) Printf(name_and_parms, ", "); String *parm_decl = SwigType_str(c_parm_type, arg); Printf(name_and_parms, "%s", parm_decl); #ifdef ALLEGROCL_DEBUG Printf(stderr, " param: %s\n", parm_decl); #endif Delete(parm_decl); gencomma = 1; // Emit parameter conversion code String *parm_code = Getattr(p, "tmap:in"); //if (!parm_code) { // Swig_warning(...); // p = nextSibling(p); /*} else */ { // canThrow(n, "in", p); Replaceall(parm_code, "$input", arg); Setattr(p, "emit:input", arg); Printf(f->code, "%s\n", parm_code); p = Getattr(p, "tmap:in:next"); } Delete(arg); } Printf(name_and_parms, ")"); #ifdef ALLEGROCL_DEBUG Printf(stderr, " arity = %d(%d)\n", emit_num_lin_arguments(parms), emit_num_lin_arguments(Getattr(n,"wrap:parms"))); #endif // Emit the function definition String *signature = SwigType_str(return_type, name_and_parms); Printf(f->def, "EXPORT %s {", signature); if (CPlusPlus) Printf(f->code, " try {\n"); String *actioncode = emit_action(n); String *tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode); if (!is_void_return) { if (tm) { Replaceall(tm, "$result", "lresult"); Printf(f->code, "%s\n", tm); Printf(f->code, " return lresult;\n"); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), name); } } emit_return_variable(n, t, f); if (CPlusPlus) { Printf(f->code, " } catch (...) {\n"); if (!is_void_return) Printf(f->code, " return (%s)0;\n", SwigType_str(SwigType_strip_qualifiers(return_type),0)); Printf(f->code, " }\n"); } Printf(f->code, "}\n"); /* print this when in C mode? make this a command-line arg? */ if (Generate_Wrapper) Wrapper_print(f, f_cxx_wrapper); String *f_buffer = NewString(""); emit_defun(n, f_buffer); Setattr(n, "allegrocl:lisp-wrap", f_buffer); if (!overloaded || !Getattr(n, "sym:nextSibling")) { update_package_if_needed(n); emit_buffered_defuns(n); // this is the last overload. if (overloaded) { emit_dispatch_defun(n); } } DelWrapper(f); return SWIG_OK; } int ALLEGROCL::namespaceDeclaration(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "namespaceDecl: '%s'(%p) (fc=%p)\n", Getattr(n, "sym:name"), n, firstChild(n)); #endif /* don't wrap a namespace with no contents. package bloat. also, test-suite/namespace_class.i claims an unnamed namespace is 'private' and should not be wrapped. Complying... */ if (Getattr(n,"unnamed") || !firstChild(n)) return SWIG_OK; String *name = Getattr(n, "sym:name"); String *old_namespace = current_namespace; if (Cmp(current_namespace, "") == 0) current_namespace = NewStringf("%s", name); else current_namespace = NewStringf("%s::%s", current_namespace, name); if (!GetInt(defined_namespace_packages, current_namespace)) { SetInt(defined_namespace_packages, current_namespace, 1); String *lispy_namespace = listify_namespace(current_namespace); Printf(f_clhead, "(swig-defpackage %s)\n", lispy_namespace); Delete(lispy_namespace); } emit_children(n); Delete(current_namespace); current_namespace = old_namespace; return SWIG_OK; } int ALLEGROCL::constructorHandler(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "constructorHandler %s\n", Getattr(n, "name")); #endif // Swig_print_node(n); Setattr(n, "allegrocl:kind", "constructor"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); // Let SWIG generate a global forwarding function. return Language::constructorHandler(n); } int ALLEGROCL::destructorHandler(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "destructorHandler %s\n", Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "destructor"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); // Let SWIG generate a global forwarding function. return Language::destructorHandler(n); } int ALLEGROCL::constantWrapper(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "constantWrapper %s\n", Getattr(n, "name")); #endif if (Generate_Wrapper) { // Setattr(n,"wrap:name",mangle_name(n, "ACLPP")); String *const_type = Getattr(n, "type"); String *const_val = 0; String *raw_const = Getattr(n, "value"); if (SwigType_type(const_type) == T_STRING) { const_val = NewStringf("\"%s\"", raw_const); } else if (SwigType_type(const_type) == T_CHAR) { const_val = NewStringf("'%s'", raw_const); } else { const_val = Copy(raw_const); } SwigType_add_qualifier(const_type, "const"); String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "sym:name")); // Printf(f_runtime, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); Printf(f_runtime, "static %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); Setattr(n, "name", ppcname); SetFlag(n, "feature:immutable"); Delete(const_val); return variableWrapper(n); } String *type = Getattr(n, "type"); String *value = Getattr(n, "value"); String *converted_value = convert_literal(value, type); String *name = Getattr(n, "sym:name"); Setattr(n, "allegrocl:kind", "constant"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); #if 0 Printf(stdout, "constant %s is of type %s. value: %s\n", name, type, converted_value); #endif if (converted_value) { Printf(f_clwrap, "(swig-defconstant \"%s\" %s)\n", name, converted_value); } else { Swig_warning(WARN_LANG_DISCARD_CONST, Getfile(n), Getline(n), "Unable to parse constant value '%s'. Setting to NIL\n", value); Printf(f_clwrap, "(swig-defconstant \"%s\" nil #| %s |#)\n", name, value); } Delete(converted_value); return SWIG_OK; } int ALLEGROCL::globalvariableHandler(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "globalvariableHandler %s\n", Getattr(n, "name")); #endif if (Generate_Wrapper) return Language::globalvariableHandler(n); // String *name = Getattr(n, "name"); SwigType *type = Getattr(n, "type"); SwigType *rtype = SwigType_typedef_resolve_all(type); if (SwigType_isclass(rtype)) { SwigType_add_pointer(type); SwigType_add_pointer(rtype); } Printf(f_clwrap, "(swig-defvar \"%s\" \"%s\" :type %s)\n", Getattr(n, "sym:name"), Getattr(n, "sym:name"), ((SwigType_isconst(type)) ? ":constant" : ":variable")); return SWIG_OK; } int ALLEGROCL::variableWrapper(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "variableWrapper %s\n", Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "variable"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); // Let SWIG generate a get/set function pair. if (Generate_Wrapper) return Language::variableWrapper(n); String *name = Getattr(n, "name"); SwigType *type = Getattr(n, "type"); SwigType *ctype; SwigType *rtype = SwigType_typedef_resolve_all(type); String *mangled_name = mangle_name(n); int pointer_added = 0; if (SwigType_isclass(rtype)) { SwigType_add_pointer(type); SwigType_add_pointer(rtype); pointer_added = 1; } ctype = SwigType_str(type, 0); // EXPORT ; // = ; Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name); Printf(f_cl, "(swig-defvar \"%s\" :type %s)\n", mangled_name, ((SwigType_isconst(type)) ? ":constant" : ":variable")); Printf(stderr,"***\n"); Delete(mangled_name); #ifdef ALLEGROCL_DEBUG Printf(stderr, "DONE variable %s\n", Getattr(n, "name")); #endif return SWIG_OK; } int ALLEGROCL::memberfunctionHandler(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "memberfunctionHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); Swig_print_node(n); #endif Setattr(n, "allegrocl:kind", "member function"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); // Let SWIG generate a global forwarding function. return Language::memberfunctionHandler(n); } int ALLEGROCL::membervariableHandler(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "membervariableHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "member variable"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); // Let SWIG generate a get/set function pair. return Language::membervariableHandler(n); } int ALLEGROCL::typedefHandler(Node *n) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "In typedefHandler\n"); #endif SwigType *typedef_type = Getattr(n,"type"); // has the side-effect of noting any implicit // template instantiations in type. String *ff_type = compose_foreign_type(n, typedef_type); String *sym_name = Getattr(n, "sym:name"); String *name; String *type_ref; if (in_class) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, " typedef in class '%s'(%p)\n", Getattr(in_class, "sym:name"), in_class); #endif Setattr(n, "allegrocl:typedef:in-class", in_class); String *class_name = Getattr(in_class, "name"); name = NewStringf("%s__%s", class_name, sym_name); type_ref = NewStringf("%s::%s", class_name, sym_name); Setattr(n, "allegrocl:in-class", in_class); } else { name = Copy(sym_name); type_ref = Copy(Getattr(n, "name")); } Setattr(n, "allegrocl:namespace", current_namespace); String *lookup = lookup_defined_foreign_type(typedef_type); #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "** lookup='%s'(%p), typedef_type='%s', strcmp = '%d' strstr = '%d'\n", lookup, lookup, typedef_type, Strcmp(typedef_type,"void"), Strstr(ff_type,"__SWIGACL_FwdReference")); #endif if(lookup || (!lookup && Strcmp(typedef_type,"void")) || (!lookup && Strstr(ff_type,"__SWIGACL_FwdReference"))) { add_defined_foreign_type(n, 0, type_ref, name); } else { add_forward_referenced_type(n); } #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "Out typedefHandler\n"); #endif Delete(ff_type); return SWIG_OK; } // forward referenced classes are added specially to defined_foreign_types int ALLEGROCL::classforwardDeclaration(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "classforwardDeclaration %s\n", Getattr(n, "name")); #endif add_forward_referenced_type(n); return SWIG_OK; } int ALLEGROCL::classHandler(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "classHandler %s::%s\n", current_namespace, Getattr(n, "sym:name")); #endif int result; if (Generate_Wrapper) result = cppClassHandler(n); else result = cClassHandler(n); return result; } int ALLEGROCL::cClassHandler(Node *n) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "In cClassHandler\n"); #endif /* Add this structure to the known lisp types */ // Printf(stderr, "Adding %s foreign type\n", name); String *ns = listify_namespace(current_namespace); add_defined_foreign_type(n); Delete(ns); #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "Out cClassHandler\n"); #endif return SWIG_OK; } int ALLEGROCL::cppClassHandler(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "cppClassHandler %s\n", Getattr(n, "name")); #endif // String *name=Getattr(n, "sym:name"); // String *kind = Getattr(n,"kind"); /* Template instantiation. Careful. SWIG does not create instantiations of templated classes whenever it sees a templated class reference (say, as a return type, or in a parameter list). The %template directive results in a templated class instantiation that will actually be seen by :: classHandler(). In this case, we don't want to error if the type already exists; the point is to force the creation of wrappers for the templated class. */ String *templated = Getattr(n, "template"); String *t_name; // String *ns = listify_namespace(current_namespace); if (templated) { t_name = namespaced_name(n); } else { t_name = Getattr(n, "name"); } Setattr(n, "allegrocl:namespace", current_namespace); /* Add this structure to the known lisp types. Class may contain references to the type currently being defined */ if (!templated || !lookup_defined_foreign_type(t_name)) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Adding %s foreign type\n", Getattr(n, "sym:name")); #endif add_defined_foreign_type(n); } else { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "cppClassHand: type %s already exists. Assuming %%template instantiation for wrapping purposes.\n", Getattr(n, "sym:name")); #endif add_defined_foreign_type(n, 1); } // Generate slot accessors, constructor, and destructor. Node *prev_class = in_class; in_class = n; Node *c; // walk all member variables. #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, " MANUALLY walking class members... \n"); #endif for (c = firstChild(n); c; c = nextSibling(c)) { // ping the types of all children--even protected and private // so their types can be added to the linked_type_list. SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type")); #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "looking at child '%p' of type '%s' '%d'\n", c, childType, SwigType_isfunction(childType)); // Swig_print_node(c); #endif if (!SwigType_isfunction(childType)) Delete(compose_foreign_type(n, childType)); Delete(childType); } #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, " MANUAL walk DONE.\n"); #endif // this will walk all necessary methods. #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, " LANGUAGE walk of children...\n"); #endif Language::classHandler(n); #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, " LANGUAGE walk DONE\n"); #endif in_class = prev_class; return SWIG_OK; } int ALLEGROCL::emit_one(Node *n) { // When the current package does not correspond with the current // namespace we need to generate an IN-PACKAGE form, unless the // current node is another namespace node. if (Cmp(nodeType(n), "namespace") != 0 && Cmp(current_package, current_namespace) != 0) { String *lispy_namespace = listify_namespace(current_namespace); Printf(f_clwrap, "(swig-in-package %s)\n", lispy_namespace); Delete(lispy_namespace); Delete(current_package); current_package = NewStringf("%s", current_namespace); } Setattr(n, "allegrocl:package", current_package); return Language::emit_one(n); } int ALLEGROCL::enumDeclaration(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "enumDeclaration %s\n", Getattr(n, "name")); #endif if (Getattr(n, "sym:name")) { add_defined_foreign_type(n); } Node *c; for (c = firstChild(n); c; c = nextSibling(c)) { ALLEGROCL::enumvalueDeclaration(c); // since we walk our own children, we need to add // the current package ourselves. Setattr(c, "allegrocl:package", current_package); } return SWIG_OK; } int ALLEGROCL::enumvalueDeclaration(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "enumvalueDeclaration %s\n", Getattr(n, "name")); #endif /* print this when in C mode? make this a command-line arg? */ if (Generate_Wrapper) { SwigType *enum_type = Copy(Getattr(n,"type")); String *mangled_name = mangle_name(n, "ACL_ENUM", in_class ? Getattr(in_class,"name") : current_namespace); SwigType_add_qualifier(enum_type,"const"); String *enum_decl = SwigType_str(enum_type, mangled_name); Printf(f_cxx_wrapper, "EXPORT %s;\n", enum_decl); Printf(f_cxx_wrapper, "%s = %s;\n", enum_decl, Getattr(n, "value")); Delete(mangled_name); Delete(enum_type); Delete(enum_decl); } return SWIG_OK; } int ALLEGROCL::templateDeclaration(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "templateDeclaration %s\n", Getattr(n, "name")); #endif String *type = Getattr(n, "templatetype"); // Printf(stderr, "tempDecl: %s %s\n", Getattr(n,"name"), // type); // Swig_print_node(n); if (!Strcmp(type, "cdecl")) { SwigType *ty = NewStringf("%s%s", Getattr(n, "decl"), Getattr(n, "type")); Delete(ty); } Delete(type); return SWIG_OK; } swig-3.0.2/Source/Modules/utils.cxx0000664000175000017500000001766312343605122017114 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * utils.cxx * * Various utility functions. * ----------------------------------------------------------------------------- */ #include int is_public(Node *n) { String *access = Getattr(n, "access"); return !access || !Cmp(access, "public"); } int is_private(Node *n) { String *access = Getattr(n, "access"); return access && !Cmp(access, "private"); } int is_protected(Node *n) { String *access = Getattr(n, "access"); return access && !Cmp(access, "protected"); } static int is_member_director_helper(Node *parentnode, Node *member) { int parent_nodirector = GetFlag(parentnode, "feature:nodirector"); if (parent_nodirector) return 0; int parent_director = Swig_director_mode() && GetFlag(parentnode, "feature:director"); int cdecl_director = parent_director || GetFlag(member, "feature:director"); int cdecl_nodirector = GetFlag(member, "feature:nodirector"); return cdecl_director && !cdecl_nodirector && !GetFlag(member, "feature:extend"); } int is_member_director(Node *parentnode, Node *member) { if (parentnode && checkAttribute(member, "storage", "virtual")) { return is_member_director_helper(parentnode, member); } else { return 0; } } int is_member_director(Node *member) { return is_member_director(Getattr(member, "parentNode"), member); } // Identifies the additional protected members that are generated when the allprotected option is used. // This does not include protected virtual methods as they are turned on with the dirprot option. int is_non_virtual_protected_access(Node *n) { int result = 0; if (Swig_director_mode() && Swig_director_protected_mode() && Swig_all_protected_mode() && is_protected(n) && !checkAttribute(n, "storage", "virtual")) { Node *parentNode = Getattr(n, "parentNode"); // When vtable is empty, the director class does not get emitted, so a check for an empty vtable should be done. // However, vtable is set in Language and so is not yet set when methods in Typepass call clean_overloaded() // which calls is_non_virtual_protected_access. So commented out below. // Moving the director vtable creation into into Typepass should solve this problem. if (is_member_director_helper(parentNode, n) /* && Getattr(parentNode, "vtable")*/) result = 1; } return result; } /* Clean overloaded list. Removes templates, ignored, and errors */ void clean_overloaded(Node *n) { Node *nn = Getattr(n, "sym:overloaded"); Node *first = 0; while (nn) { String *ntype = nodeType(nn); if ((GetFlag(nn, "feature:ignore")) || (Getattr(nn, "error")) || (Strcmp(ntype, "template") == 0) || ((Strcmp(ntype, "cdecl") == 0) && is_protected(nn) && !is_member_director(nn) && !is_non_virtual_protected_access(n))) { /* Remove from overloaded list */ Node *ps = Getattr(nn, "sym:previousSibling"); Node *ns = Getattr(nn, "sym:nextSibling"); if (ps) { Setattr(ps, "sym:nextSibling", ns); } if (ns) { Setattr(ns, "sym:previousSibling", ps); } Delattr(nn, "sym:previousSibling"); Delattr(nn, "sym:nextSibling"); Delattr(nn, "sym:overloaded"); nn = ns; continue; } else { if (!first) first = nn; Setattr(nn, "sym:overloaded", first); } nn = Getattr(nn, "sym:nextSibling"); } if (!first || (first && !Getattr(first, "sym:nextSibling"))) { if (Getattr(n, "sym:overloaded")) Delattr(n, "sym:overloaded"); } } /* ----------------------------------------------------------------------------- * Swig_set_max_hash_expand() * * Controls how many Hash objects are displayed when displaying nested Hash objects. * Makes DohSetMaxHashExpand an externally callable function (for debugger). * ----------------------------------------------------------------------------- */ void Swig_set_max_hash_expand(int count) { SetMaxHashExpand(count); } extern "C" { /* ----------------------------------------------------------------------------- * Swig_get_max_hash_expand() * * Returns how many Hash objects are displayed when displaying nested Hash objects. * Makes DohGetMaxHashExpand an externally callable function (for debugger). * ----------------------------------------------------------------------------- */ int Swig_get_max_hash_expand() { return GetMaxHashExpand(); } /* ----------------------------------------------------------------------------- * Swig_to_doh_string() * * DOH version of Swig_to_string() * ----------------------------------------------------------------------------- */ static String *Swig_to_doh_string(DOH *object, int count) { int old_count = Swig_get_max_hash_expand(); if (count >= 0) Swig_set_max_hash_expand(count); String *debug_string = object ? NewStringf("%s", object) : NewString("NULL"); Swig_set_max_hash_expand(old_count); return debug_string; } /* ----------------------------------------------------------------------------- * Swig_to_doh_string_with_location() * * DOH version of Swig_to_string_with_location() * ----------------------------------------------------------------------------- */ static String *Swig_to_doh_string_with_location(DOH *object, int count) { int old_count = Swig_get_max_hash_expand(); if (count >= 0) Swig_set_max_hash_expand(count); String *debug_string = Swig_stringify_with_location(object); Swig_set_max_hash_expand(old_count); return debug_string; } /* ----------------------------------------------------------------------------- * Swig_to_string() * * Swig debug - return C string representation of any DOH type. * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0 * Note: leaks memory. * ----------------------------------------------------------------------------- */ const char *Swig_to_string(DOH *object, int count) { return Char(Swig_to_doh_string(object, count)); } /* ----------------------------------------------------------------------------- * Swig_to_string_with_location() * * Swig debug - return C string representation of any DOH type, within [] brackets * for Hash and List types, prefixed by line and file information. * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0 * Note: leaks memory. * ----------------------------------------------------------------------------- */ const char *Swig_to_string_with_location(DOH *object, int count) { return Char(Swig_to_doh_string_with_location(object, count)); } /* ----------------------------------------------------------------------------- * Swig_print() * * Swig debug - display string representation of any DOH type. * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0 * ----------------------------------------------------------------------------- */ void Swig_print(DOH *object, int count) { String *output = Swig_to_doh_string(object, count); Printf(stdout, "%s\n", output); Delete(output); } /* ----------------------------------------------------------------------------- * Swig_to_string_with_location() * * Swig debug - display string representation of any DOH type, within [] brackets * for Hash and List types, prefixed by line and file information. * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0 * ----------------------------------------------------------------------------- */ void Swig_print_with_location(DOH *object, int count) { String *output = Swig_to_doh_string_with_location(object, count); Printf(stdout, "%s\n", output); Delete(output); } } // extern "C" swig-3.0.2/Source/Modules/mzscheme.cxx0000664000175000017500000006351712343605122017566 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * mzscheme.cxx * * Mzscheme language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include static const char *usage = "\ Mzscheme Options (available with -mzscheme)\n\ -declaremodule - Create extension that declares a module\n\ -dynamic-load ,[library,...] - Do not link with these libraries, dynamic load\n\ them\n\ -noinit - Do not emit scheme_initialize, scheme_reload,\n\ scheme_module_name functions\n\ -prefix - Set a prefix to be prepended to all names\n\ "; static String *fieldnames_tab = 0; static String *convert_tab = 0; static String *convert_proto_tab = 0; static String *struct_name = 0; static String *mangled_struct_name = 0; static String *prefix = 0; static bool declaremodule = false; static bool noinit = false; static String *load_libraries = NULL; static String *module = 0; static const char *mzscheme_path = "mzscheme"; static String *init_func_def = 0; static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; static File *f_init = 0; // Used for garbage collection static int exporting_destructor = 0; static String *swigtype_ptr = 0; static String *cls_swigtype = 0; class MZSCHEME:public Language { public: /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { int i; SWIG_library_directory(mzscheme_path); // Look for certain command line options for (i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); SWIG_exit(0); } else if (strcmp(argv[i], "-prefix") == 0) { if (argv[i + 1]) { prefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-declaremodule") == 0) { declaremodule = true; Swig_mark_arg(i); } else if (strcmp(argv[i], "-noinit") == 0) { noinit = true; Swig_mark_arg(i); } else if (strcmp(argv[i], "-dynamic-load") == 0) { if (argv[i + 1]) { Delete(load_libraries); load_libraries = NewString(argv[i + 1]); Swig_mark_arg(i++); Swig_mark_arg(i); } else { Swig_arg_error(); } } } } // If a prefix has been specified make sure it ends in a '_' (not actually used!) if (prefix) { const char *px = Char(prefix); if (px[Len(prefix) - 1] != '_') Printf(prefix, "_"); } else prefix = NewString("swig_"); // Add a symbol for this module Preprocessor_define("SWIGMZSCHEME 1", 0); // Set name of typemaps SWIG_typemap_lang("mzscheme"); // Read in default typemaps */ SWIG_config_file("mzscheme.swg"); allow_overloading(); } /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ virtual int top(Node *n) { /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); init_func_def = NewString(""); Swig_register_filebyname("init", init_func_def); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGMZSCHEME\n"); Printf(f_runtime, "\n"); module = Getattr(n, "name"); Language::top(n); SwigType_emit_type_table(f_runtime, f_wrappers); if (!noinit) { if (declaremodule) { Printf(f_init, "#define SWIG_MZSCHEME_CREATE_MENV(env) scheme_primitive_module(scheme_intern_symbol(\"%s\"), env)\n", module); } else { Printf(f_init, "#define SWIG_MZSCHEME_CREATE_MENV(env) (env)\n"); } Printf(f_init, "%s\n", Char(init_func_def)); if (declaremodule) { Printf(f_init, "\tscheme_finish_primitive_module(menv);\n"); } Printf(f_init, "\treturn scheme_void;\n}\n"); Printf(f_init, "Scheme_Object *scheme_initialize(Scheme_Env *env) {\n"); if (load_libraries) { Printf(f_init, "mz_set_dlopen_libraries(\"%s\");\n", load_libraries); } Printf(f_init, "\treturn scheme_reload(env);\n"); Printf(f_init, "}\n"); Printf(f_init, "Scheme_Object *scheme_module_name(void) {\n"); if (declaremodule) { Printf(f_init, " return scheme_intern_symbol((char*)\"%s\");\n", module); } else { Printf(f_init, " return scheme_make_symbol((char*)\"%s\");\n", module); } Printf(f_init, "}\n"); } /* Close all of the files */ Dump(f_runtime, f_begin); Dump(f_header, f_begin); Dump(f_wrappers, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } /* ------------------------------------------------------------ * functionWrapper() * Create a function declaration and register it with the interpreter. * ------------------------------------------------------------ */ void throw_unhandled_mzscheme_type_error(SwigType *d) { Swig_warning(WARN_TYPEMAP_UNDEF, input_file, line_number, "Unable to handle type %s.\n", SwigType_str(d, 0)); } /* Return true iff T is a pointer type */ int is_a_pointer(SwigType *t) { return SwigType_ispointer(SwigType_typedef_resolve_all(t)); } virtual int functionWrapper(Node *n) { char *iname = GetChar(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); Parm *p; Wrapper *f = NewWrapper(); String *proc_name = NewString(""); String *source = NewString(""); String *target = NewString(""); String *arg = NewString(""); String *cleanup = NewString(""); String *outarg = NewString(""); String *build = NewString(""); String *tm; int i = 0; int numargs; int numreq; String *overname = 0; if (load_libraries) { ParmList *parms = Getattr(n, "parms"); SwigType *type = Getattr(n, "type"); String *name = NewString("caller"); Setattr(n, "wrap:action", Swig_cresult(type, Swig_cresult_name(), Swig_cfunction_call(name, parms))); } // Make a wrapper name for this String *wname = Swig_name_wrapper(iname); if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) { DelWrapper(f); return SWIG_ERROR; } } if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); // Build the name for Scheme. Printv(proc_name, iname, NIL); Replaceall(proc_name, "_", "-"); // writing the function wrapper function Printv(f->def, "static Scheme_Object *", wname, " (", NIL); Printv(f->def, "int argc, Scheme_Object **argv", NIL); Printv(f->def, ")\n{", NIL); /* Define the scheme name in C. This define is used by several macros. */ Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL); // Emit all of the local variables for holding arguments. emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); numargs = emit_num_arguments(l); numreq = emit_num_required(l); /* Add the holder for the pointer to the function to be opened */ if (load_libraries) { Wrapper_add_local(f, "_function_loaded", "static int _function_loaded=(1==0)"); Wrapper_add_local(f, "_the_function", "static void *_the_function=NULL"); { String *parms = ParmList_protostr(l); String *func = NewStringf("(*caller)(%s)", parms); Wrapper_add_local(f, "caller", SwigType_lstr(d, func)); /*"(*caller)()")); */ } } // adds local variables Wrapper_add_local(f, "lenv", "int lenv = 1"); Wrapper_add_local(f, "values", "Scheme_Object *values[MAXVALUES]"); if (load_libraries) { Printf(f->code, "if (!_function_loaded) { _the_function=mz_load_function(\"%s\");_function_loaded=(1==1); }\n", iname); Printf(f->code, "if (!_the_function) { scheme_signal_error(\"Cannot load C function '%s'\"); }\n", iname); Printf(f->code, "caller=_the_function;\n"); } // Now write code to extract the parameters (this is super ugly) for (i = 0, p = l; i < numargs; i++) { /* Skip ignored arguments */ while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); // Produce names of source and target Clear(source); Clear(target); Clear(arg); Printf(source, "argv[%d]", i); Printf(target, "%s", ln); Printv(arg, Getattr(p, "name"), NIL); if (i >= numreq) { Printf(f->code, "if (argc > %d) {\n", i); } // Handle parameter types. if ((tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$source", source); Replaceall(tm, "$target", target); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:in:next"); } else { // no typemap found // check if typedef and resolve throw_unhandled_mzscheme_type_error(pt); p = nextSibling(p); } if (i >= numreq) { Printf(f->code, "}\n"); } } /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } // Pass output arguments back to the caller. for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { Replaceall(tm, "$source", Getattr(p, "emit:input")); /* Deprecated */ Replaceall(tm, "$target", Getattr(p, "lname")); /* Deprecated */ Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } // Free up any memory allocated for the arguments. /* Insert cleanup code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } // Now write code to make the function call String *actioncode = emit_action(n); // Now have return value, figure out what to do with it. if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "values[0]"); Replaceall(tm, "$result", "values[0]"); if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "1"); else Replaceall(tm, "$owner", "0"); Printv(f->code, tm, "\n", NIL); } else { throw_unhandled_mzscheme_type_error(d); } emit_return_variable(n, d, f); // Dump the argument output code Printv(f->code, Char(outarg), NIL); // Dump the argument cleanup code Printv(f->code, Char(cleanup), NIL); // Look for any remaining cleanup if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } } // Free any memory allocated by the function being wrapped.. if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } // Wrap things up (in a manner of speaking) Printv(f->code, tab4, "return SWIG_MzScheme_PackageValues(lenv, values);\n", NIL); Printf(f->code, "#undef FUNC_NAME\n"); Printv(f->code, "}\n", NIL); /* Substitute the function name */ Replaceall(f->code, "$symname", iname); Wrapper_print(f, f_wrappers); if (!Getattr(n, "sym:overloaded")) { // Now register the function char temp[256]; sprintf(temp, "%d", numargs); if (exporting_destructor) { Printf(init_func_def, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname); } else { Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, wname, proc_name, numreq, numargs); } } else { if (!Getattr(n, "sym:nextSibling")) { /* Emit overloading dispatch function */ int maxargs; String *dispatch = Swig_overload_dispatch(n, "return %s(argc,argv);", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *df = NewWrapper(); String *dname = Swig_name_wrapper(iname); Printv(df->def, "static Scheme_Object *\n", dname, "(int argc, Scheme_Object **argv) {", NIL); Printv(df->code, dispatch, "\n", NIL); Printf(df->code, "scheme_signal_error(\"No matching function for overloaded '%s'\");\n", iname); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, dname, proc_name, 0, maxargs); DelWrapper(df); Delete(dispatch); Delete(dname); } } Delete(proc_name); Delete(source); Delete(target); Delete(arg); Delete(outarg); Delete(cleanup); Delete(build); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * variableWrapper() * * Create a link to a C variable. * This creates a single function _wrap_swig_var_varname(). * This function takes a single optional argument. If supplied, it means * we are setting this variable to some value. If omitted, it means we are * simply evaluating this variable. Either way, we return the variables * value. * ------------------------------------------------------------ */ virtual int variableWrapper(Node *n) { char *name = GetChar(n, "name"); char *iname = GetChar(n, "sym:name"); SwigType *t = Getattr(n, "type"); String *proc_name = NewString(""); String *tm; String *tm2 = NewString(""); String *argnum = NewString("0"); String *arg = NewString("argv[0]"); Wrapper *f; if (!addSymbol(iname, n)) return SWIG_ERROR; f = NewWrapper(); // evaluation function names String *var_name = Swig_name_wrapper(iname); // Build the name for scheme. Printv(proc_name, iname, NIL); Replaceall(proc_name, "_", "-"); Setattr(n, "wrap:name", proc_name); if ((SwigType_type(t) != T_USER) || (is_a_pointer(t))) { Printf(f->def, "static Scheme_Object *%s(int argc, Scheme_Object** argv) {\n", var_name); Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL); Wrapper_add_local(f, "swig_result", "Scheme_Object *swig_result"); if (!GetFlag(n, "feature:immutable")) { /* Check for a setting of the variable value */ Printf(f->code, "if (argc) {\n"); if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { Replaceall(tm, "$source", "argv[0]"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "argv[0]"); /* Printv(f->code, tm, "\n",NIL); */ emit_action_code(n, f->code, tm); } else { throw_unhandled_mzscheme_type_error(t); } Printf(f->code, "}\n"); } // Now return the value of the variable (regardless // of evaluating or setting) if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$source", name); Replaceall(tm, "$target", "swig_result"); Replaceall(tm, "$result", "swig_result"); /* Printf (f->code, "%s\n", tm); */ emit_action_code(n, f->code, tm); } else { throw_unhandled_mzscheme_type_error(t); } Printf(f->code, "\nreturn swig_result;\n"); Printf(f->code, "#undef FUNC_NAME\n"); Printf(f->code, "}\n"); Wrapper_print(f, f_wrappers); // Now add symbol to the MzScheme interpreter Printv(init_func_def, "scheme_add_global(\"", proc_name, "\", scheme_make_prim_w_arity(", var_name, ", \"", proc_name, "\", ", "0", ", ", "1", "), menv);\n", NIL); } else { Swig_warning(WARN_TYPEMAP_VAR_UNDEF, input_file, line_number, "Unsupported variable type %s (ignored).\n", SwigType_str(t, 0)); } Delete(var_name); Delete(proc_name); Delete(argnum); Delete(arg); Delete(tm2); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { char *name = GetChar(n, "name"); char *iname = GetChar(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *value = Getattr(n, "value"); String *var_name = NewString(""); String *proc_name = NewString(""); String *rvalue = NewString(""); String *temp = NewString(""); String *tm; // Make a static variable; Printf(var_name, "_wrap_const_%s", Swig_name_mangle(Getattr(n, "sym:name"))); // Build the name for scheme. Printv(proc_name, iname, NIL); Replaceall(proc_name, "_", "-"); if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) { Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); return SWIG_NOWRAP; } // See if there's a typemap Printv(rvalue, value, NIL); if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 1)) { temp = Copy(rvalue); Clear(rvalue); Printv(rvalue, "\"", temp, "\"", NIL); } if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 0)) { Delete(temp); temp = Copy(rvalue); Clear(rvalue); Printv(rvalue, "'", temp, "'", NIL); } if ((tm = Swig_typemap_lookup("constant", n, name, 0))) { Replaceall(tm, "$source", rvalue); Replaceall(tm, "$value", rvalue); Replaceall(tm, "$target", name); Printf(f_init, "%s\n", tm); } else { // Create variable and assign it a value Printf(f_header, "static %s = ", SwigType_lstr(type, var_name)); bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); if ((SwigType_type(type) == T_STRING)) { Printf(f_header, "\"%s\";\n", value); } else if (SwigType_type(type) == T_CHAR && !is_enum_item) { Printf(f_header, "\'%s\';\n", value); } else { Printf(f_header, "%s;\n", value); } // Now create a variable declaration { /* Hack alert: will cleanup later -- Dave */ Node *nn = NewHash(); Setfile(nn, Getfile(n)); Setline(nn, Getline(n)); Setattr(nn, "name", var_name); Setattr(nn, "sym:name", iname); Setattr(nn, "type", type); SetFlag(nn, "feature:immutable"); variableWrapper(nn); Delete(nn); } } Delete(proc_name); Delete(rvalue); Delete(temp); return SWIG_OK; } virtual int destructorHandler(Node *n) { exporting_destructor = true; Language::destructorHandler(n); exporting_destructor = false; return SWIG_OK; } /* ------------------------------------------------------------ * classHandler() * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { String *mangled_classname = 0; String *real_classname = 0; String *scm_structname = NewString(""); SwigType *ctype_ptr = NewStringf("p.%s", getClassType()); SwigType *t = NewStringf("p.%s", Getattr(n, "name")); swigtype_ptr = SwigType_manglestr(t); Delete(t); cls_swigtype = SwigType_manglestr(Getattr(n, "name")); fieldnames_tab = NewString(""); convert_tab = NewString(""); convert_proto_tab = NewString(""); struct_name = Getattr(n, "sym:name"); mangled_struct_name = Swig_name_mangle(Getattr(n, "sym:name")); Printv(scm_structname, struct_name, NIL); Replaceall(scm_structname, "_", "-"); real_classname = Getattr(n, "name"); mangled_classname = Swig_name_mangle(real_classname); Printv(fieldnames_tab, "static const char *_swig_struct_", cls_swigtype, "_field_names[] = { \n", NIL); Printv(convert_proto_tab, "static Scheme_Object *_swig_convert_struct_", cls_swigtype, "(", SwigType_str(ctype_ptr, "ptr"), ");\n", NIL); Printv(convert_tab, "static Scheme_Object *_swig_convert_struct_", cls_swigtype, "(", SwigType_str(ctype_ptr, "ptr"), ")\n {\n", NIL); Printv(convert_tab, tab4, "Scheme_Object *obj;\n", tab4, "Scheme_Object *fields[_swig_struct_", cls_swigtype, "_field_names_cnt];\n", tab4, "int i = 0;\n\n", NIL); /* Generate normal wrappers */ Language::classHandler(n); Printv(convert_tab, tab4, "obj = scheme_make_struct_instance(", "_swig_struct_type_", cls_swigtype, ", i, fields);\n", NIL); Printv(convert_tab, tab4, "return obj;\n}\n\n", NIL); Printv(fieldnames_tab, "};\n", NIL); Printv(f_header, "static Scheme_Object *_swig_struct_type_", cls_swigtype, ";\n", NIL); Printv(f_header, fieldnames_tab, NIL); Printv(f_header, "#define _swig_struct_", cls_swigtype, "_field_names_cnt (sizeof(_swig_struct_", cls_swigtype, "_field_names)/sizeof(char*))\n", NIL); Printv(f_header, convert_proto_tab, NIL); Printv(f_wrappers, convert_tab, NIL); Printv(init_func_def, "_swig_struct_type_", cls_swigtype, " = SWIG_MzScheme_new_scheme_struct(menv, \"", scm_structname, "\", ", "_swig_struct_", cls_swigtype, "_field_names_cnt,", "(char**) _swig_struct_", cls_swigtype, "_field_names);\n", NIL); Delete(mangled_classname); Delete(swigtype_ptr); swigtype_ptr = 0; Delete(fieldnames_tab); Delete(convert_tab); Delete(ctype_ptr); Delete(convert_proto_tab); struct_name = 0; mangled_struct_name = 0; Delete(cls_swigtype); cls_swigtype = 0; return SWIG_OK; } /* ------------------------------------------------------------ * membervariableHandler() * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { Language::membervariableHandler(n); if (!is_smart_pointer()) { String *symname = Getattr(n, "sym:name"); String *name = Getattr(n, "name"); SwigType *type = Getattr(n, "type"); String *swigtype = SwigType_manglestr(Getattr(n, "type")); String *tm = 0; String *access_mem = NewString(""); SwigType *ctype_ptr = NewStringf("p.%s", Getattr(n, "type")); Printv(fieldnames_tab, tab4, "\"", symname, "\",\n", NIL); Printv(access_mem, "(ptr)->", name, NIL); if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) { Printv(convert_tab, tab4, "fields[i++] = ", NIL); Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, 0), ")&((ptr)->", name, "));\n", NIL); } else if ((tm = Swig_typemap_lookup("varout", n, access_mem, 0))) { Replaceall(tm, "$result", "fields[i++]"); Printv(convert_tab, tm, "\n", NIL); } else Swig_warning(WARN_TYPEMAP_VAR_UNDEF, input_file, line_number, "Unsupported member variable type %s (ignored).\n", SwigType_str(type, 0)); Delete(access_mem); } return SWIG_OK; } /* ------------------------------------------------------------ * validIdentifer() * ------------------------------------------------------------ */ virtual int validIdentifier(String *s) { char *c = Char(s); /* Check whether we have an R5RS identifier. */ /* --> * | */ /* --> | */ if (!(isalpha(*c) || (*c == '!') || (*c == '$') || (*c == '%') || (*c == '&') || (*c == '*') || (*c == '/') || (*c == ':') || (*c == '<') || (*c == '=') || (*c == '>') || (*c == '?') || (*c == '^') || (*c == '_') || (*c == '~'))) { /* --> + | - | ... */ if ((strcmp(c, "+") == 0) || strcmp(c, "-") == 0 || strcmp(c, "...") == 0) return 1; else return 0; } /* --> | | */ while (*c) { if (!(isalnum(*c) || (*c == '!') || (*c == '$') || (*c == '%') || (*c == '&') || (*c == '*') || (*c == '/') || (*c == ':') || (*c == '<') || (*c == '=') || (*c == '>') || (*c == '?') || (*c == '^') || (*c == '_') || (*c == '~') || (*c == '+') || (*c == '-') || (*c == '.') || (*c == '@'))) return 0; c++; } return 1; } String *runtimeCode() { String *s = Swig_include_sys("mzrun.swg"); if (!s) { Printf(stderr, "*** Unable to open 'mzrun.swg'\n"); s = NewString(""); } return s; } String *defaultExternalRuntimeFilename() { return NewString("swigmzrun.h"); } }; /* ----------------------------------------------------------------------------- * swig_mzscheme() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_mzscheme() { return new MZSCHEME(); } extern "C" Language *swig_mzscheme(void) { return new_swig_mzscheme(); } swig-3.0.2/Source/Modules/guile.cxx0000664000175000017500000015432012343605122017051 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * guile.cxx * * Guile language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include // Note string broken in half for compilers that can't handle long strings static const char *usage = "\ Guile Options (available with -guile)\n\ -emitsetters - Emit procedures-with-setters for variables\n\ and structure slots.\n\ -emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\ -exportprimitive - Add the (export ...) code from scmstub into the\n\ GOOPS file.\n\ -goopsprefix - Prepend to all goops identifiers\n\ -Linkage - Use linkage protocol (default `simple')\n\ Use `module' for native Guile module linking\n\ (requires Guile >= 1.5.0). Use `passive' for\n\ passive linking (no C-level module-handling code),\n\ `ltdlmod' for Guile's old dynamic module\n\ convention (Guile <= 1.4), or `hobbit' for hobbit\n\ modules.\n\ -onlysetters - Don't emit traditional getter and setter\n\ procedures for structure slots,\n\ only emit procedures-with-setters.\n\ -package - Set the path of the module to \n\ (default NULL)\n\ -prefix - Use as prefix [default \"gswig_\"]\n\ -procdoc - Output procedure documentation to \n\ -procdocformat - Output procedure documentation in ;\n\ one of `guile-1.4', `plain', `texinfo'\n\ -proxy - Export GOOPS class definitions\n\ -primsuffix - Name appended to primitive module when exporting\n\ GOOPS classes. (default = \"primitive\")\n\ -scmstub - Output Scheme file with module declaration and\n\ exports; only with `passive' and `simple' linkage\n\ -useclassprefix - Prepend the class name to all goops identifiers\n\ \n"; static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; static File *f_init = 0; static String *prefix = NewString("gswig_"); static char *module = 0; static String *package = 0; static enum { GUILE_LSTYLE_SIMPLE, // call `SWIG_init()' GUILE_LSTYLE_PASSIVE, // passive linking (no module code) GUILE_LSTYLE_MODULE, // native guile module linking (Guile >= 1.4.1) GUILE_LSTYLE_LTDLMOD_1_4, // old (Guile <= 1.4) dynamic module convention GUILE_LSTYLE_HOBBIT // use (hobbit4d link) } linkage = GUILE_LSTYLE_SIMPLE; static File *procdoc = 0; static bool scmstub = false; static String *scmtext; static bool goops = false; static String *goopstext; static String *goopscode; static String *goopsexport; static enum { GUILE_1_4, PLAIN, TEXINFO } docformat = GUILE_1_4; static int emit_setters = 0; static int only_setters = 0; static int emit_slot_accessors = 0; static int struct_member = 0; static String *beforereturn = 0; static String *return_nothing_doc = 0; static String *return_one_doc = 0; static String *return_multi_doc = 0; static String *exported_symbols = 0; static int exporting_destructor = 0; static String *swigtype_ptr = 0; /* GOOPS stuff */ static String *primsuffix = 0; static String *class_name = 0; static String *short_class_name = 0; static String *goops_class_methods; static int in_class = 0; static int have_constructor = 0; static int useclassprefix = 0; // -useclassprefix argument static String *goopsprefix = 0; // -goopsprefix argument static int primRenamer = 0; // if (use-modules ((...) :renamer ...) is exported to GOOPS file static int exportprimitive = 0; // -exportprimitive argument static String *memberfunction_name = 0; extern "C" { static int has_classname(Node *class_node) { return Getattr(class_node, "guile:goopsclassname") ? 1 : 0; } } class GUILE:public Language { public: /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { int i; SWIG_library_directory("guile"); SWIG_typemap_lang("guile"); // Look for certain command line options for (i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); SWIG_exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-prefix") == 0) { if (argv[i + 1]) { prefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-package") == 0) { if (argv[i + 1]) { package = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-Linkage") == 0 || strcmp(argv[i], "-linkage") == 0) { if (argv[i + 1]) { if (0 == strcmp(argv[i + 1], "ltdlmod")) linkage = GUILE_LSTYLE_LTDLMOD_1_4; else if (0 == strcmp(argv[i + 1], "hobbit")) linkage = GUILE_LSTYLE_HOBBIT; else if (0 == strcmp(argv[i + 1], "simple")) linkage = GUILE_LSTYLE_SIMPLE; else if (0 == strcmp(argv[i + 1], "passive")) linkage = GUILE_LSTYLE_PASSIVE; else if (0 == strcmp(argv[i + 1], "module")) linkage = GUILE_LSTYLE_MODULE; else Swig_arg_error(); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-procdoc") == 0) { if (argv[i + 1]) { procdoc = NewFile(argv[i + 1], "w", SWIG_output_files()); if (!procdoc) { FileErrorDisplay(argv[i + 1]); SWIG_exit(EXIT_FAILURE); } Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-procdocformat") == 0) { if (strcmp(argv[i + 1], "guile-1.4") == 0) docformat = GUILE_1_4; else if (strcmp(argv[i + 1], "plain") == 0) docformat = PLAIN; else if (strcmp(argv[i + 1], "texinfo") == 0) docformat = TEXINFO; else Swig_arg_error(); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else if (strcmp(argv[i], "-emit-setters") == 0 || strcmp(argv[i], "-emitsetters") == 0) { emit_setters = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-only-setters") == 0 || strcmp(argv[i], "-onlysetters") == 0) { emit_setters = 1; only_setters = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-emit-slot-accessors") == 0 || strcmp(argv[i], "-emitslotaccessors") == 0) { emit_slot_accessors = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-scmstub") == 0) { scmstub = true; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-shadow") == 0) || ((strcmp(argv[i], "-proxy") == 0))) { goops = true; Swig_mark_arg(i); } else if (strcmp(argv[i], "-gh") == 0) { Printf(stderr, "Deprecated command line option: -gh. Wrappers are always generated for the SCM interface. See documentation for more information regarding the deprecated GH interface.\n"); Swig_mark_arg(i); } else if (strcmp(argv[i], "-scm") == 0) { Printf(stderr, "Deprecated command line option: -scm. Wrappers are always generated for the SCM interface. See documentation for more information regarding the deprecated GH interface.\n"); Swig_mark_arg(i); } else if (strcmp(argv[i], "-primsuffix") == 0) { if (argv[i + 1]) { primsuffix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-goopsprefix") == 0) { if (argv[i + 1]) { goopsprefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-useclassprefix") == 0) { useclassprefix = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-exportprimitive") == 0) { exportprimitive = 1; // should use Swig_warning() here? Swig_mark_arg(i); } } } // set default value for primsuffix if (!primsuffix) primsuffix = NewString("primitive"); //goops support can only be enabled if passive or module linkage is used if (goops) { if (linkage != GUILE_LSTYLE_PASSIVE && linkage != GUILE_LSTYLE_MODULE) { Printf(stderr, "guile: GOOPS support requires passive or module linkage\n"); exit(1); } } if (goops) { // -proxy implies -emit-setters emit_setters = 1; } if ((linkage == GUILE_LSTYLE_PASSIVE && scmstub) || linkage == GUILE_LSTYLE_MODULE) primRenamer = 1; if (exportprimitive && primRenamer) { // should use Swig_warning() ? Printf(stderr, "guile: Warning: -exportprimitive only makes sense with passive linkage without a scmstub.\n"); } // Make sure `prefix' ends in an underscore if (prefix) { const char *px = Char(prefix); if (px[Len(prefix) - 1] != '_') Printf(prefix, "_"); } /* Add a symbol for this module */ Preprocessor_define("SWIGGUILE 1", 0); /* Read in default typemaps */ SWIG_config_file("guile_scm.swg"); allow_overloading(); } /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ virtual int top(Node *n) { /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); scmtext = NewString(""); Swig_register_filebyname("scheme", scmtext); exported_symbols = NewString(""); goopstext = NewString(""); Swig_register_filebyname("goops", goopstext); goopscode = NewString(""); goopsexport = NewString(""); Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGGUILE\n"); /* Write out directives and declarations */ module = Swig_copy_string(Char(Getattr(n, "name"))); switch (linkage) { case GUILE_LSTYLE_SIMPLE: /* Simple linkage; we have to export the SWIG_init function. The user can rename the function by a #define. */ Printf(f_runtime, "#define SWIG_GUILE_INIT_STATIC extern\n"); break; default: /* Other linkage; we make the SWIG_init function static */ Printf(f_runtime, "#define SWIG_GUILE_INIT_STATIC static\n"); break; } if (CPlusPlus) { Printf(f_runtime, "extern \"C\" {\n\n"); } Printf(f_runtime, "SWIG_GUILE_INIT_STATIC void\nSWIG_init (void);\n"); if (CPlusPlus) { Printf(f_runtime, "\n}\n"); } Printf(f_runtime, "\n"); Language::top(n); /* Close module */ Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); SwigType_emit_type_table(f_runtime, f_wrappers); Printf(f_init, "}\n\n"); Printf(f_init, "#ifdef __cplusplus\n}\n#endif\n"); String *module_name = NewString(""); if (!module) Printv(module_name, "swig", NIL); else { if (package) Printf(module_name, "%s/%s", package, module); else Printv(module_name, module, NIL); } emit_linkage(module_name); Delete(module_name); if (procdoc) { Delete(procdoc); procdoc = NULL; } Delete(goopscode); Delete(goopsexport); Delete(goopstext); /* Close all of the files */ Dump(f_runtime, f_begin); Dump(f_header, f_begin); Dump(f_wrappers, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_runtime); Delete(f_begin); return SWIG_OK; } void emit_linkage(String *module_name) { String *module_func = NewString(""); if (CPlusPlus) { Printf(f_init, "extern \"C\" {\n\n"); } Printv(module_func, module_name, NIL); Replaceall(module_func, "-", "_"); switch (linkage) { case GUILE_LSTYLE_SIMPLE: Printf(f_init, "\n/* Linkage: simple */\n"); break; case GUILE_LSTYLE_PASSIVE: Printf(f_init, "\n/* Linkage: passive */\n"); Replaceall(module_func, "/", "_"); Insert(module_func, 0, "scm_init_"); Append(module_func, "_module"); Printf(f_init, "SCM\n%s (void)\n{\n", module_func); Printf(f_init, " SWIG_init();\n"); Printf(f_init, " return SCM_UNSPECIFIED;\n"); Printf(f_init, "}\n"); break; case GUILE_LSTYLE_LTDLMOD_1_4: Printf(f_init, "\n/* Linkage: ltdlmod */\n"); Replaceall(module_func, "/", "_"); Insert(module_func, 0, "scm_init_"); Append(module_func, "_module"); Printf(f_init, "SCM\n%s (void)\n{\n", module_func); { String *mod = NewString(module_name); Replaceall(mod, "/", " "); Printf(f_init, " scm_register_module_xxx (\"%s\", (void *) SWIG_init);\n", mod); Printf(f_init, " return SCM_UNSPECIFIED;\n"); Delete(mod); } Printf(f_init, "}\n"); break; case GUILE_LSTYLE_MODULE: Printf(f_init, "\n/* Linkage: module */\n"); Replaceall(module_func, "/", "_"); Insert(module_func, 0, "scm_init_"); Append(module_func, "_module"); Printf(f_init, "static void SWIG_init_helper(void *data)\n"); Printf(f_init, "{\n SWIG_init();\n"); if (Len(exported_symbols) > 0) Printf(f_init, " scm_c_export(%sNULL);", exported_symbols); Printf(f_init, "\n}\n\n"); Printf(f_init, "SCM\n%s (void)\n{\n", module_func); { String *mod = NewString(module_name); if (goops) Printv(mod, "-", primsuffix, NIL); Replaceall(mod, "/", " "); Printf(f_init, " scm_c_define_module(\"%s\",\n", mod); Printf(f_init, " SWIG_init_helper, NULL);\n"); Printf(f_init, " return SCM_UNSPECIFIED;\n"); Delete(mod); } Printf(f_init, "}\n"); break; case GUILE_LSTYLE_HOBBIT: Printf(f_init, "\n/* Linkage: hobbit */\n"); Replaceall(module_func, "/", "_slash_"); Insert(module_func, 0, "scm_init_"); Printf(f_init, "SCM\n%s (void)\n{\n", module_func); { String *mod = NewString(module_name); Replaceall(mod, "/", " "); Printf(f_init, " scm_register_module_xxx (\"%s\", (void *) SWIG_init);\n", mod); Printf(f_init, " return SCM_UNSPECIFIED;\n"); Delete(mod); } Printf(f_init, "}\n"); break; default: abort(); // for now } if (scmstub) { /* Emit Scheme stub if requested */ String *primitive_name = NewString(module_name); if (goops) Printv(primitive_name, "-", primsuffix, NIL); String *mod = NewString(primitive_name); Replaceall(mod, "/", " "); String *fname = NewStringf("%s%s.scm", SWIG_output_directory(), primitive_name); Delete(primitive_name); File *scmstubfile = NewFile(fname, "w", SWIG_output_files()); if (!scmstubfile) { FileErrorDisplay(fname); SWIG_exit(EXIT_FAILURE); } Delete(fname); Swig_banner_target_lang(scmstubfile, ";;;"); Printf(scmstubfile, "\n"); if (linkage == GUILE_LSTYLE_SIMPLE || linkage == GUILE_LSTYLE_PASSIVE) Printf(scmstubfile, "(define-module (%s))\n\n", mod); Delete(mod); Printf(scmstubfile, "%s", scmtext); if ((linkage == GUILE_LSTYLE_SIMPLE || linkage == GUILE_LSTYLE_PASSIVE) && Len(exported_symbols) > 0) { String *ex = NewString(exported_symbols); Replaceall(ex, ", ", "\n "); Replaceall(ex, "\"", ""); Chop(ex); Printf(scmstubfile, "\n(export %s)\n", ex); Delete(ex); } Delete(scmstubfile); } if (goops) { String *mod = NewString(module_name); Replaceall(mod, "/", " "); String *fname = NewStringf("%s%s.scm", SWIG_output_directory(), module_name); File *goopsfile = NewFile(fname, "w", SWIG_output_files()); if (!goopsfile) { FileErrorDisplay(fname); SWIG_exit(EXIT_FAILURE); } Delete(fname); Swig_banner_target_lang(goopsfile, ";;;"); Printf(goopsfile, "\n"); Printf(goopsfile, "(define-module (%s))\n", mod); Printf(goopsfile, "%s\n", goopstext); Printf(goopsfile, "(use-modules (oop goops) (Swig common))\n"); if (primRenamer) { Printf(goopsfile, "(use-modules ((%s-%s) :renamer (symbol-prefix-proc 'primitive:)))\n", mod, primsuffix); } Printf(goopsfile, "%s\n(export %s)", goopscode, goopsexport); if (exportprimitive) { String *ex = NewString(exported_symbols); Replaceall(ex, ", ", "\n "); Replaceall(ex, "\"", ""); Chop(ex); Printf(goopsfile, "\n(export %s)", ex); Delete(ex); } Delete(mod); Delete(goopsfile); } Delete(module_func); if (CPlusPlus) { Printf(f_init, "\n}\n"); } } /* Return true iff T is a pointer type */ int is_a_pointer(SwigType *t) { return SwigType_ispointer(SwigType_typedef_resolve_all(t)); } /* Report an error handling the given type. */ void throw_unhandled_guile_type_error(SwigType *d) { Swig_warning(WARN_TYPEMAP_UNDEF, input_file, line_number, "Unable to handle type %s.\n", SwigType_str(d, 0)); } /* Write out procedure documentation */ void write_doc(const String *proc_name, const String *signature, const String *doc, const String *signature2 = NULL) { switch (docformat) { case GUILE_1_4: Printv(procdoc, "\f\n", NIL); Printv(procdoc, "(", signature, ")\n", NIL); if (signature2) Printv(procdoc, "(", signature2, ")\n", NIL); Printv(procdoc, doc, "\n", NIL); break; case PLAIN: Printv(procdoc, "\f", proc_name, "\n\n", NIL); Printv(procdoc, "(", signature, ")\n", NIL); if (signature2) Printv(procdoc, "(", signature2, ")\n", NIL); Printv(procdoc, doc, "\n\n", NIL); break; case TEXINFO: Printv(procdoc, "\f", proc_name, "\n", NIL); Printv(procdoc, "@deffn primitive ", signature, "\n", NIL); if (signature2) Printv(procdoc, "@deffnx primitive ", signature2, "\n", NIL); Printv(procdoc, doc, "\n", NIL); Printv(procdoc, "@end deffn\n\n", NIL); break; } } /* returns false if the typemap is an empty string */ bool handle_documentation_typemap(String *output, const String *maybe_delimiter, Parm *p, const String *typemap, const String *default_doc, const String *name = NULL) { String *tmp = NewString(""); String *tm; if (!(tm = Getattr(p, typemap))) { Printf(tmp, "%s", default_doc); tm = tmp; } bool result = (Len(tm) > 0); if (maybe_delimiter && Len(output) > 0 && Len(tm) > 0) { Printv(output, maybe_delimiter, NIL); } const String *pn = !name ? (const String *) Getattr(p, "name") : name; String *pt = Getattr(p, "type"); Replaceall(tm, "$name", pn); // legacy for $parmname Replaceall(tm, "$type", SwigType_str(pt, 0)); /* $NAME is like $name, but marked-up as a variable. */ String *ARGNAME = NewString(""); if (docformat == TEXINFO) Printf(ARGNAME, "@var{%s}", pn); else Printf(ARGNAME, "%(upper)s", pn); Replaceall(tm, "$NAME", ARGNAME); Replaceall(tm, "$PARMNAME", ARGNAME); Printv(output, tm, NIL); Delete(tmp); return result; } /* ------------------------------------------------------------ * functionWrapper() * Create a function declaration and register it with the interpreter. * ------------------------------------------------------------ */ virtual int functionWrapper(Node *n) { String *iname = Getattr(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); Parm *p; String *proc_name = 0; char source[256]; Wrapper *f = NewWrapper(); String *cleanup = NewString(""); String *outarg = NewString(""); String *signature = NewString(""); String *doc_body = NewString(""); String *returns = NewString(""); String *method_signature = NewString(""); String *primitive_args = NewString(""); Hash *scheme_arg_names = NewHash(); int num_results = 1; String *tmp = NewString(""); String *tm; int i; int numargs = 0; int numreq = 0; String *overname = 0; int args_passed_as_array = 0; int scheme_argnum = 0; bool any_specialized_arg = false; // Make a wrapper name for this String *wname = Swig_name_wrapper(iname); if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); args_passed_as_array = 1; } else { if (!addSymbol(iname, n)) { DelWrapper(f); return SWIG_ERROR; } } if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); // Build the name for scheme. proc_name = NewString(iname); Replaceall(proc_name, "_", "-"); /* Emit locals etc. into f->code; figure out which args to ignore */ emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); /* Get number of required and total arguments */ numargs = emit_num_arguments(l); numreq = emit_num_required(l); /* Declare return variable */ Wrapper_add_local(f, "gswig_result", "SCM gswig_result"); Wrapper_add_local(f, "gswig_list_p", "SWIGUNUSED int gswig_list_p = 0"); /* Open prototype and signature */ Printv(f->def, "static SCM\n", wname, " (", NIL); if (args_passed_as_array) { Printv(f->def, "int argc, SCM *argv", NIL); } Printv(signature, proc_name, NIL); /* Now write code to extract the parameters */ for (i = 0, p = l; i < numargs; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); int opt_p = (i >= numreq); // Produce names of source and target if (args_passed_as_array) sprintf(source, "argv[%d]", i); else sprintf(source, "s_%d", i); String *target = Getattr(p, "lname"); if (!args_passed_as_array) { if (i != 0) Printf(f->def, ", "); Printf(f->def, "SCM s_%d", i); } if (opt_p) { Printf(f->code, " if (%s != SCM_UNDEFINED) {\n", source); } if ((tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$source", source); Replaceall(tm, "$target", target); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); Printv(f->code, tm, "\n", NIL); SwigType *pb = SwigType_typedef_resolve_all(SwigType_base(pt)); SwigType *pn = Getattr(p, "name"); String *argname; scheme_argnum++; if (pn && !Getattr(scheme_arg_names, pn)) argname = pn; else { /* Anonymous arg or re-used argument name -- choose a name that cannot clash */ argname = NewStringf("%%arg%d", scheme_argnum); } if (procdoc) { if (i == numreq) { /* First optional argument */ Printf(signature, " #:optional"); } /* Add to signature (arglist) */ handle_documentation_typemap(signature, " ", p, "tmap:in:arglist", "$name", argname); /* Document the type of the arg in the documentation body */ handle_documentation_typemap(doc_body, ", ", p, "tmap:in:doc", "$NAME is of type <$type>", argname); } if (goops) { if (i < numreq) { if (strcmp("void", Char(pt)) != 0) { Node *class_node = Swig_symbol_clookup_check(pb, Getattr(n, "sym:symtab"), has_classname); String *goopsclassname = !class_node ? NULL : Getattr(class_node, "guile:goopsclassname"); /* do input conversion */ if (goopsclassname) { Printv(method_signature, " (", argname, " ", goopsclassname, ")", NIL); any_specialized_arg = true; } else { Printv(method_signature, " ", argname, NIL); } Printv(primitive_args, " ", argname, NIL); Setattr(scheme_arg_names, argname, p); } } } if (!pn) { Delete(argname); } p = Getattr(p, "tmap:in:next"); } else { throw_unhandled_guile_type_error(pt); p = nextSibling(p); } if (opt_p) Printf(f->code, " }\n"); } if (Len(doc_body) > 0) Printf(doc_body, ".\n"); /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Pass output arguments back to the caller. */ /* Insert argument output code */ String *returns_argout = NewString(""); for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$target", Getattr(p, "lname")); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); if (procdoc) { if (handle_documentation_typemap(returns_argout, ", ", p, "tmap:argout:doc", "$NAME (of type $type)")) { /* A documentation typemap that is not the empty string indicates that a value is returned to Scheme. */ num_results++; } } p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } if (exporting_destructor) { /* Mark the destructor's argument as destroyed. */ String *tm = NewString("SWIG_Guile_MarkPointerDestroyed($input);"); Replaceall(tm, "$input", Getattr(l, "emit:input")); Printv(cleanup, tm, "\n", NIL); Delete(tm); } /* Close prototype */ Printf(f->def, ")\n{\n"); /* Define the scheme name in C. This define is used by several Guile macros. */ Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL); // Now write code to make the function call String *actioncode = emit_action(n); // Now have return value, figure out what to do with it. if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$result", "gswig_result"); Replaceall(tm, "$target", "gswig_result"); Replaceall(tm, "$source", Swig_cresult_name()); if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "1"); else Replaceall(tm, "$owner", "0"); Printv(f->code, tm, "\n", NIL); } else { throw_unhandled_guile_type_error(d); } emit_return_variable(n, d, f); // Documentation if ((tm = Getattr(n, "tmap:out:doc"))) { Printv(returns, tm, NIL); if (Len(tm) > 0) num_results = 1; else num_results = 0; } else { String *s = SwigType_str(d, 0); Chop(s); Printf(returns, "<%s>", s); Delete(s); num_results = 1; } Append(returns, returns_argout); // Dump the argument output code Printv(f->code, outarg, NIL); // Dump the argument cleanup code Printv(f->code, cleanup, NIL); // Look for any remaining cleanup if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } } // Free any memory allocated by the function being wrapped.. if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } // Wrap things up (in a manner of speaking) if (beforereturn) Printv(f->code, beforereturn, "\n", NIL); Printv(f->code, "return gswig_result;\n", NIL); /* Substitute the function name */ Replaceall(f->code, "$symname", iname); // Undefine the scheme name Printf(f->code, "#undef FUNC_NAME\n"); Printf(f->code, "}\n"); Wrapper_print(f, f_wrappers); if (!Getattr(n, "sym:overloaded")) { if (numargs > 10) { int i; /* gh_new_procedure would complain: too many args */ /* Build a wrapper wrapper */ Printv(f_wrappers, "static SCM\n", wname, "_rest (SCM rest)\n", NIL); Printv(f_wrappers, "{\n", NIL); Printf(f_wrappers, "SCM arg[%d];\n", numargs); Printf(f_wrappers, "SWIG_Guile_GetArgs (arg, rest, %d, %d, \"%s\");\n", numreq, numargs - numreq, proc_name); Printv(f_wrappers, "return ", wname, "(", NIL); Printv(f_wrappers, "arg[0]", NIL); for (i = 1; i < numargs; i++) Printf(f_wrappers, ", arg[%d]", i); Printv(f_wrappers, ");\n", NIL); Printv(f_wrappers, "}\n", NIL); /* Register it */ Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s_rest);\n", proc_name, wname); } else if (emit_setters && struct_member && strlen(Char(proc_name)) > 3) { int len = Len(proc_name); const char *pc = Char(proc_name); /* MEMBER-set and MEMBER-get functions. */ int is_setter = (pc[len - 3] == 's'); if (is_setter) { Printf(f_init, "SCM setter = "); struct_member = 2; /* have a setter */ } else Printf(f_init, "SCM getter = "); /* GOOPS support uses the MEMBER-set and MEMBER-get functions, so ignore only_setters in this case. */ if (only_setters && !goops) Printf(f_init, "scm_c_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); else Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); if (!is_setter) { /* Strip off "-get" */ char *pws_name = (char *) malloc(sizeof(char) * (len - 3)); strncpy(pws_name, pc, len - 3); pws_name[len - 4] = 0; if (struct_member == 2) { /* There was a setter, so create a procedure with setter */ Printf(f_init, "scm_c_define"); Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(getter, setter));\n", pws_name); } else { /* There was no setter, so make an alias to the getter */ Printf(f_init, "scm_c_define"); Printf(f_init, "(\"%s\", getter);\n", pws_name); } Printf(exported_symbols, "\"%s\", ", pws_name); free(pws_name); } } else { /* Register the function */ if (exporting_destructor) { Printf(f_init, "((swig_guile_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (guile_destructor) %s;\n", swigtype_ptr, wname); //Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname); } Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); } } else { /* overloaded function; don't export the single methods */ if (!Getattr(n, "sym:nextSibling")) { /* Emit overloading dispatch function */ int maxargs; String *dispatch = Swig_overload_dispatch(n, "return %s(argc,argv);", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *df = NewWrapper(); String *dname = Swig_name_wrapper(iname); Printv(df->def, "static SCM\n", dname, "(SCM rest)\n{\n", NIL); Printf(df->code, "#define FUNC_NAME \"%s\"\n", proc_name); Printf(df->code, "SCM argv[%d];\n", maxargs); Printf(df->code, "int argc = SWIG_Guile_GetArgs (argv, rest, %d, %d, \"%s\");\n", 0, maxargs, proc_name); Printv(df->code, dispatch, "\n", NIL); Printf(df->code, "scm_misc_error(\"%s\", \"No matching method for generic function `%s'\", SCM_EOL);\n", proc_name, iname); Printf(df->code, "#undef FUNC_NAME\n"); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s);\n", proc_name, dname); DelWrapper(df); Delete(dispatch); Delete(dname); } } Printf(exported_symbols, "\"%s\", ", proc_name); if (!in_class || memberfunction_name) { // export wrapper into goops file String *method_def = NewString(""); String *goops_name; if (in_class) goops_name = NewString(memberfunction_name); else goops_name = goopsNameMapping(proc_name, ""); String *primitive_name = NewString(""); if (primRenamer) Printv(primitive_name, "primitive:", proc_name, NIL); else Printv(primitive_name, proc_name, NIL); Replaceall(method_signature, "_", "-"); Replaceall(primitive_args, "_", "-"); if (!any_specialized_arg) { /* If there would not be any specialized argument in the method declaration, we simply re-export the function. This is a performance optimization. */ Printv(method_def, "(define ", goops_name, " ", primitive_name, ")\n", NIL); } else if (numreq == numargs) { Printv(method_def, "(define-method (", goops_name, method_signature, ")\n", NIL); Printv(method_def, " (", primitive_name, primitive_args, "))\n", NIL); } else { /* Handle optional args. For the rest argument, use a name that cannot clash. */ Printv(method_def, "(define-method (", goops_name, method_signature, " . %args)\n", NIL); Printv(method_def, " (apply ", primitive_name, primitive_args, " %args))\n", NIL); } if (in_class) { /* Defer method definition till end of class definition. */ Printv(goops_class_methods, method_def, NIL); } else { Printv(goopscode, method_def, NIL); } Printf(goopsexport, "%s ", goops_name); Delete(primitive_name); Delete(goops_name); Delete(method_def); } if (procdoc) { String *returns_text = NewString(""); if (num_results == 0) Printv(returns_text, return_nothing_doc, NIL); else if (num_results == 1) Printv(returns_text, return_one_doc, NIL); else Printv(returns_text, return_multi_doc, NIL); /* Substitute documentation variables */ static const char *numbers[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve" }; if (num_results <= 12) Replaceall(returns_text, "$num_values", numbers[num_results]); else { String *num_results_str = NewStringf("%d", num_results); Replaceall(returns_text, "$num_values", num_results_str); Delete(num_results_str); } Replaceall(returns_text, "$values", returns); Printf(doc_body, "\n%s", returns_text); write_doc(proc_name, signature, doc_body); Delete(returns_text); } Delete(proc_name); Delete(outarg); Delete(cleanup); Delete(signature); Delete(method_signature); Delete(primitive_args); Delete(doc_body); Delete(returns_argout); Delete(returns); Delete(tmp); Delete(scheme_arg_names); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * variableWrapper() * * Create a link to a C variable. * This creates a single function PREFIX_var_VARNAME(). * This function takes a single optional argument. If supplied, it means * we are setting this variable to some value. If omitted, it means we are * simply evaluating this variable. Either way, we return the variables * value. * ------------------------------------------------------------ */ virtual int variableWrapper(Node *n) { char *name = GetChar(n, "name"); char *iname = GetChar(n, "sym:name"); SwigType *t = Getattr(n, "type"); String *proc_name; Wrapper *f; String *tm; if (!addSymbol(iname, n)) return SWIG_ERROR; f = NewWrapper(); // evaluation function names String *var_name = Swig_name_wrapper(iname); // Build the name for scheme. proc_name = NewString(iname); Replaceall(proc_name, "_", "-"); Setattr(n, "wrap:name", proc_name); if (1 || (SwigType_type(t) != T_USER) || (is_a_pointer(t))) { Printf(f->def, "static SCM\n%s(SCM s_0)\n{\n", var_name); /* Define the scheme name in C. This define is used by several Guile macros. */ Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL); Wrapper_add_local(f, "gswig_result", "SCM gswig_result"); if (!GetFlag(n, "feature:immutable")) { /* Check for a setting of the variable value */ Printf(f->code, "if (s_0 != SCM_UNDEFINED) {\n"); if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { Replaceall(tm, "$source", "s_0"); Replaceall(tm, "$input", "s_0"); Replaceall(tm, "$target", name); /* Printv(f->code,tm,"\n",NIL); */ emit_action_code(n, f->code, tm); } else { throw_unhandled_guile_type_error(t); } Printf(f->code, "}\n"); } // Now return the value of the variable (regardless // of evaluating or setting) if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$source", name); Replaceall(tm, "$target", "gswig_result"); Replaceall(tm, "$result", "gswig_result"); /* Printv(f->code,tm,"\n",NIL); */ emit_action_code(n, f->code, tm); } else { throw_unhandled_guile_type_error(t); } Printf(f->code, "\nreturn gswig_result;\n"); Printf(f->code, "#undef FUNC_NAME\n"); Printf(f->code, "}\n"); Wrapper_print(f, f_wrappers); // Now add symbol to the Guile interpreter if (!emit_setters || GetFlag(n, "feature:immutable")) { /* Read-only variables become a simple procedure returning the value; read-write variables become a simple procedure with an optional argument. */ if (!goops && GetFlag(n, "feature:constasvar")) { /* need to export this function as a variable instead of a procedure */ if (scmstub) { /* export the function in the wrapper, and (set!) it in scmstub */ Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name); Printf(scmtext, "(set! %s (%s))\n", proc_name, proc_name); } else { /* export the variable directly */ Printf(f_init, "scm_c_define(\"%s\", %s(SCM_UNDEFINED));\n", proc_name, var_name); } } else { /* Export the function as normal */ Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name); } } else { /* Read/write variables become a procedure with setter. */ Printf(f_init, "{ SCM p = scm_c_define_gsubr(\"%s\", 0, 1, 0, (swig_guile_proc) %s);\n", proc_name, var_name); Printf(f_init, "scm_c_define"); Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(p, p)); }\n", proc_name); } Printf(exported_symbols, "\"%s\", ", proc_name); // export wrapper into goops file if (!in_class) { // only if the variable is not part of a class String *class_name = SwigType_typedef_resolve_all(SwigType_base(t)); String *goops_name = goopsNameMapping(proc_name, ""); String *primitive_name = NewString(""); if (primRenamer) Printv(primitive_name, "primitive:", NIL); Printv(primitive_name, proc_name, NIL); /* Simply re-export the procedure */ if ((!emit_setters || GetFlag(n, "feature:immutable")) && GetFlag(n, "feature:constasvar")) { Printv(goopscode, "(define ", goops_name, " (", primitive_name, "))\n", NIL); } else { Printv(goopscode, "(define ", goops_name, " ", primitive_name, ")\n", NIL); } Printf(goopsexport, "%s ", goops_name); Delete(primitive_name); Delete(class_name); Delete(goops_name); } if (procdoc) { /* Compute documentation */ String *signature = NewString(""); String *signature2 = NULL; String *doc = NewString(""); if (GetFlag(n, "feature:immutable")) { Printv(signature, proc_name, NIL); if (GetFlag(n, "feature:constasvar")) { Printv(doc, "Is constant ", NIL); } else { Printv(doc, "Returns constant ", NIL); } if ((tm = Getattr(n, "tmap:varout:doc"))) { Printv(doc, tm, NIL); } else { String *s = SwigType_str(t, 0); Chop(s); Printf(doc, "<%s>", s); Delete(s); } } else if (emit_setters) { Printv(signature, proc_name, NIL); signature2 = NewString(""); Printv(signature2, "set! (", proc_name, ") ", NIL); handle_documentation_typemap(signature2, NIL, n, "tmap:varin:arglist", "new-value"); Printv(doc, "Get or set the value of the C variable, \n", NIL); Printv(doc, "which is of type ", NIL); handle_documentation_typemap(doc, NIL, n, "tmap:varout:doc", "$1_type"); Printv(doc, "."); } else { Printv(signature, proc_name, " #:optional ", NIL); if ((tm = Getattr(n, "tmap:varin:doc"))) { Printv(signature, tm, NIL); } else { String *s = SwigType_str(t, 0); Chop(s); Printf(signature, "new-value <%s>", s); Delete(s); } Printv(doc, "If NEW-VALUE is provided, " "set C variable to this value.\n", NIL); Printv(doc, "Returns variable value ", NIL); if ((tm = Getattr(n, "tmap:varout:doc"))) { Printv(doc, tm, NIL); } else { String *s = SwigType_str(t, 0); Chop(s); Printf(doc, "<%s>", s); Delete(s); } } write_doc(proc_name, signature, doc, signature2); Delete(signature); if (signature2) Delete(signature2); Delete(doc); } } else { Swig_warning(WARN_TYPEMAP_VAR_UNDEF, input_file, line_number, "Unsupported variable type %s (ignored).\n", SwigType_str(t, 0)); } Delete(var_name); Delete(proc_name); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * constantWrapper() * * We create a read-only variable. * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { char *name = GetChar(n, "name"); char *iname = GetChar(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *value = Getattr(n, "value"); int constasvar = GetFlag(n, "feature:constasvar"); String *proc_name; String *var_name; String *rvalue; Wrapper *f; SwigType *nctype; String *tm; f = NewWrapper(); // Make a static variable; var_name = NewStringf("%sconst_%s", prefix, iname); // Strip const qualifier from type if present nctype = NewString(type); if (SwigType_isconst(nctype)) { Delete(SwigType_pop(nctype)); } // Build the name for scheme. proc_name = NewString(iname); Replaceall(proc_name, "_", "-"); if ((SwigType_type(nctype) == T_USER) && (!is_a_pointer(nctype))) { Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); Delete(var_name); DelWrapper(f); return SWIG_NOWRAP; } // See if there's a typemap bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); if (SwigType_type(nctype) == T_STRING) { rvalue = NewStringf("\"%s\"", value); } else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) { rvalue = NewStringf("\'%s\'", value); } else { rvalue = NewString(value); } if ((tm = Swig_typemap_lookup("constant", n, name, 0))) { Replaceall(tm, "$source", rvalue); Replaceall(tm, "$value", rvalue); Replaceall(tm, "$target", name); Printv(f_header, tm, "\n", NIL); } else { // Create variable and assign it a value Printf(f_header, "static %s = %s;\n", SwigType_str(type, var_name), rvalue); } { /* Hack alert: will cleanup later -- Dave */ Node *nn = NewHash(); Setfile(nn, Getfile(n)); Setline(nn, Getline(n)); Setattr(nn, "name", var_name); Setattr(nn, "sym:name", iname); Setattr(nn, "type", nctype); SetFlag(nn, "feature:immutable"); if (constasvar) { SetFlag(nn, "feature:constasvar"); } variableWrapper(nn); Delete(nn); } Delete(var_name); Delete(nctype); Delete(proc_name); Delete(rvalue); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * classDeclaration() * ------------------------------------------------------------ */ virtual int classDeclaration(Node *n) { String *class_name = NewStringf("<%s>", Getattr(n, "sym:name")); Setattr(n, "guile:goopsclassname", class_name); return Language::classDeclaration(n); } /* ------------------------------------------------------------ * classHandler() * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { /* Create new strings for building up a wrapper function */ have_constructor = 0; class_name = NewString(""); short_class_name = NewString(""); Printv(class_name, "<", Getattr(n, "sym:name"), ">", NIL); Printv(short_class_name, Getattr(n, "sym:name"), NIL); Replaceall(class_name, "_", "-"); Replaceall(short_class_name, "_", "-"); if (!addSymbol(class_name, n)) return SWIG_ERROR; /* Handle inheritance */ String *base_class = NewString("<"); List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist)) { Iterator i = First(baselist); while (i.item) { Printv(base_class, Getattr(i.item, "sym:name"), NIL); i = Next(i); if (i.item) { Printf(base_class, "> <"); } } } Printf(base_class, ">"); Replaceall(base_class, "_", "-"); Printv(goopscode, "(define-class ", class_name, " ", NIL); Printf(goopsexport, "%s ", class_name); if (Len(base_class) > 2) { Printv(goopscode, "(", base_class, ")\n", NIL); } else { Printv(goopscode, "()\n", NIL); } SwigType *ct = NewStringf("p.%s", Getattr(n, "name")); swigtype_ptr = SwigType_manglestr(ct); String *mangled_classname = Swig_name_mangle(Getattr(n, "sym:name")); /* Export clientdata structure */ Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname); Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_guile_clientdata", mangled_classname, ");\n", NIL); SwigType_remember(ct); Delete(ct); /* Emit all of the members */ goops_class_methods = NewString(""); in_class = 1; Language::classHandler(n); in_class = 0; Printv(goopscode, " #:metaclass \n", NIL); if (have_constructor) Printv(goopscode, " #:new-function ", primRenamer ? "primitive:" : "", "new-", short_class_name, "\n", NIL); Printf(goopscode, ")\n%s\n", goops_class_methods); Delete(goops_class_methods); goops_class_methods = 0; /* export class initialization function */ if (goops) { /* export the wrapper function */ String *funcName = NewString(mangled_classname); Printf(funcName, "_swig_guile_setgoopsclass"); String *guileFuncName = NewString(funcName); Replaceall(guileFuncName, "_", "-"); Printv(f_wrappers, "static SCM ", funcName, "(SCM cl) \n", NIL); Printf(f_wrappers, "#define FUNC_NAME %s\n{\n", guileFuncName); Printv(f_wrappers, " ((swig_guile_clientdata *)(SWIGTYPE", swigtype_ptr, "->clientdata))->goops_class = cl;\n", NIL); Printf(f_wrappers, " return SCM_UNSPECIFIED;\n"); Printf(f_wrappers, "}\n#undef FUNC_NAME\n\n"); Printf(f_init, "scm_c_define_gsubr(\"%s\", 1, 0, 0, (swig_guile_proc) %s);\n", guileFuncName, funcName); Printf(exported_symbols, "\"%s\", ", guileFuncName); /* export the call to the wrapper function */ Printf(goopscode, "(%s%s %s)\n\n", primRenamer ? "primitive:" : "", guileFuncName, class_name); Delete(guileFuncName); Delete(funcName); } Delete(mangled_classname); Delete(swigtype_ptr); swigtype_ptr = 0; Delete(class_name); Delete(short_class_name); class_name = 0; short_class_name = 0; return SWIG_OK; } /* ------------------------------------------------------------ * memberfunctionHandler() * ------------------------------------------------------------ */ int memberfunctionHandler(Node *n) { String *iname = Getattr(n, "sym:name"); String *proc = NewString(iname); Replaceall(proc, "_", "-"); memberfunction_name = goopsNameMapping(proc, short_class_name); Language::memberfunctionHandler(n); Delete(memberfunction_name); memberfunction_name = NULL; Delete(proc); return SWIG_OK; } /* ------------------------------------------------------------ * membervariableHandler() * ------------------------------------------------------------ */ int membervariableHandler(Node *n) { String *iname = Getattr(n, "sym:name"); if (emit_setters) { struct_member = 1; Printf(f_init, "{\n"); } Language::membervariableHandler(n); if (emit_setters) { Printf(f_init, "}\n"); struct_member = 0; } String *proc = NewString(iname); Replaceall(proc, "_", "-"); String *goops_name = goopsNameMapping(proc, short_class_name); /* The slot name is never qualified with the class, even if useclassprefix is true. */ Printv(goopscode, " (", proc, " #:allocation #:virtual", NIL); /* GOOPS (at least in Guile 1.6.3) only accepts closures, not primitive procedures for slot-ref and slot-set. */ Printv(goopscode, "\n #:slot-ref (lambda (obj) (", primRenamer ? "primitive:" : "", short_class_name, "-", proc, "-get", " obj))", NIL); if (!GetFlag(n, "feature:immutable")) { Printv(goopscode, "\n #:slot-set! (lambda (obj value) (", primRenamer ? "primitive:" : "", short_class_name, "-", proc, "-set", " obj value))", NIL); } else { Printf(goopscode, "\n #:slot-set! (lambda (obj value) (error \"Immutable slot\"))"); } if (emit_slot_accessors) { if (GetFlag(n, "feature:immutable")) { Printv(goopscode, "\n #:getter ", goops_name, NIL); } else { Printv(goopscode, "\n #:accessor ", goops_name, NIL); } Printf(goopsexport, "%s ", goops_name); } Printv(goopscode, ")\n", NIL); Delete(proc); Delete(goops_name); return SWIG_OK; } /* ------------------------------------------------------------ * constructorHandler() * ------------------------------------------------------------ */ int constructorHandler(Node *n) { Language::constructorHandler(n); have_constructor = 1; return SWIG_OK; } /* ------------------------------------------------------------ * destructorHandler() * ------------------------------------------------------------ */ virtual int destructorHandler(Node *n) { exporting_destructor = true; Language::destructorHandler(n); exporting_destructor = false; return SWIG_OK; } /* ------------------------------------------------------------ * pragmaDirective() * ------------------------------------------------------------ */ virtual int pragmaDirective(Node *n) { if (!ImportMode) { String *lang = Getattr(n, "lang"); String *cmd = Getattr(n, "name"); String *value = Getattr(n, "value"); # define store_pragma(PRAGMANAME) \ if (Strcmp(cmd, #PRAGMANAME) == 0) { \ if (PRAGMANAME) Delete(PRAGMANAME); \ PRAGMANAME = value ? NewString(value) : NULL; \ } if (Strcmp(lang, "guile") == 0) { store_pragma(beforereturn) store_pragma(return_nothing_doc) store_pragma(return_one_doc) store_pragma(return_multi_doc); # undef store_pragma } } return Language::pragmaDirective(n); } /* ------------------------------------------------------------ * goopsNameMapping() * Maps the identifier from C++ to the GOOPS based * on command * line parameters and such. * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ String *goopsNameMapping(String *name, const_String_or_char_ptr class_name) { String *n = NewString(""); if (Strcmp(class_name, "") == 0) { // not part of a class, so no class name to prefix if (goopsprefix) { Printf(n, "%s%s", goopsprefix, name); } else { Printf(n, "%s", name); } } else { if (useclassprefix) { Printf(n, "%s-%s", class_name, name); } else { if (goopsprefix) { Printf(n, "%s%s", goopsprefix, name); } else { Printf(n, "%s", name); } } } return n; } /* ------------------------------------------------------------ * validIdentifier() * ------------------------------------------------------------ */ virtual int validIdentifier(String *s) { char *c = Char(s); /* Check whether we have an R5RS identifier. Guile supports a superset of R5RS identifiers, but it's probably a bad idea to use those. */ /* --> * | */ /* --> | */ if (!(isalpha(*c) || (*c == '!') || (*c == '$') || (*c == '%') || (*c == '&') || (*c == '*') || (*c == '/') || (*c == ':') || (*c == '<') || (*c == '=') || (*c == '>') || (*c == '?') || (*c == '^') || (*c == '_') || (*c == '~'))) { /* --> + | - | ... */ if ((strcmp(c, "+") == 0) || strcmp(c, "-") == 0 || strcmp(c, "...") == 0) return 1; else return 0; } /* --> | | */ while (*c) { if (!(isalnum(*c) || (*c == '!') || (*c == '$') || (*c == '%') || (*c == '&') || (*c == '*') || (*c == '/') || (*c == ':') || (*c == '<') || (*c == '=') || (*c == '>') || (*c == '?') || (*c == '^') || (*c == '_') || (*c == '~') || (*c == '+') || (*c == '-') || (*c == '.') || (*c == '@'))) return 0; c++; } return 1; } String *runtimeCode() { String *s; s = Swig_include_sys("guile_scm_run.swg"); if (!s) { Printf(stderr, "*** Unable to open 'guile_scm_run.swg"); s = NewString(""); } return s; } String *defaultExternalRuntimeFilename() { return NewString("swigguilerun.h"); } }; /* ----------------------------------------------------------------------------- * swig_guile() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_guile() { return new GUILE(); } extern "C" Language *swig_guile(void) { return new_swig_guile(); } swig-3.0.2/Source/Modules/typepass.cxx0000664000175000017500000012165712343605122017623 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * typepass.cxx * * This module builds all of the internal type information by collecting * typedef declarations as well as registering classes, structures, and unions. * This information is needed to correctly handle shadow classes and other * advanced features. This phase of compilation is also used to perform * type-expansion. All types are fully qualified with namespace prefixes * and other information needed for compilation. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" struct normal_node { Symtab *symtab; Hash *typescope; List *normallist; normal_node *next; }; static normal_node *patch_list = 0; /* Singleton class - all non-static methods in this class are private */ class TypePass:private Dispatcher { Node *inclass; Node *module; int importmode; String *nsname; String *nssymname; Hash *classhash; List *normalize; TypePass() : inclass(0), module(0), importmode(0), nsname(0), nssymname(0), classhash(0), normalize(0) { } /* Normalize a type. Replaces type with fully qualified version */ void normalize_type(SwigType *ty) { SwigType *qty; if (CPlusPlus) { Replaceall(ty, "struct ", ""); Replaceall(ty, "union ", ""); Replaceall(ty, "class ", ""); } qty = SwigType_typedef_qualified(ty); /* Printf(stdout,"%s --> %s\n", ty, qty); */ Clear(ty); Append(ty, qty); Delete(qty); } /* Normalize a parameter list */ void normalize_parms(ParmList *p) { while (p) { SwigType *ty = Getattr(p, "type"); normalize_type(ty); /* This is a check for a function type */ { SwigType *qty = SwigType_typedef_resolve_all(ty); if (SwigType_isfunction(qty)) { SwigType_add_pointer(ty); } Delete(qty); } String *value = Getattr(p, "value"); if (value) { Node *n = Swig_symbol_clookup(value, 0); if (n) { String *q = Swig_symbol_qualified(n); if (q && Len(q)) { String *vb = Swig_scopename_last(value); Clear(value); Printf(value, "%s::%s", SwigType_namestr(q), vb); Delete(q); } } } if (value && SwigType_istemplate(value)) { String *nv = SwigType_namestr(value); Setattr(p, "value", nv); } p = nextSibling(p); } } void normalize_later(ParmList *p) { while (p) { SwigType *ty = Getattr(p, "type"); Append(normalize, ty); p = nextSibling(p); } } /* Walk through entries in normalize list and patch them up */ void normalize_list() { Hash *currentsym = Swig_symbol_current(); normal_node *nn = patch_list; normal_node *np; while (nn) { Swig_symbol_setscope(nn->symtab); SwigType_set_scope(nn->typescope); Iterator t; for (t = First(nn->normallist); t.item; t = Next(t)) { normalize_type(t.item); } Delete(nn->normallist); np = nn->next; delete(nn); nn = np; } Swig_symbol_setscope(currentsym); } /* generate C++ inheritance type-relationships */ void cplus_inherit_types_impl(Node *first, Node *cls, String *clsname, const char *bases, const char *baselist, int ispublic, String *cast = 0) { if (first == cls) return; /* The Marcelo check */ if (!cls) cls = first; List *alist = 0; List *ilist = Getattr(cls, bases); if (!ilist) { List *nlist = Getattr(cls, baselist); if (nlist) { int len = Len(nlist); int i; for (i = 0; i < len; i++) { Node *bcls = 0; int clsforward = 0; String *bname = Getitem(nlist, i); String *sname = bname; String *tname = 0; /* Try to locate the base class. We look in the symbol table and we chase typedef declarations to get to the base class if necessary */ Symtab *st = Getattr(cls, "sym:symtab"); if (SwigType_istemplate(bname)) { tname = SwigType_typedef_resolve_all(bname); sname = tname; } while (1) { String *qsname = SwigType_typedef_qualified(sname); bcls = Swig_symbol_clookup(qsname, st); Delete(qsname); if (bcls) { if (Strcmp(nodeType(bcls), "class") != 0) { /* Not a class. The symbol could be a typedef. */ if (checkAttribute(bcls, "storage", "typedef")) { SwigType *decl = Getattr(bcls, "decl"); if (!decl || !(Len(decl))) { sname = Getattr(bcls, "type"); st = Getattr(bcls, "sym:symtab"); if (SwigType_istemplate(sname)) { if (tname) Delete(tname); tname = SwigType_typedef_resolve_all(sname); sname = tname; } continue; } // A case when both outer and nested classes inherit from the same parent. Constructor may be found instead of the class itself. } else if (GetFlag(cls, "nested") && checkAttribute(bcls, "nodeType", "constructor")) { bcls = Getattr(bcls, "parentNode"); if (Getattr(bcls, "typepass:visit")) { if (!Getattr(bcls, "feature:onlychildren")) { if (!ilist) ilist = alist = NewList(); Append(ilist, bcls); } else { Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname)); Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname)); } } break; } if (Strcmp(nodeType(bcls), "classforward") != 0) { Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname)); Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname)); } else { Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname)); Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname)); clsforward = 1; } bcls = 0; } else { if (Getattr(bcls, "typepass:visit")) { if (!Getattr(bcls, "feature:onlychildren")) { if (!ilist) ilist = alist = NewList(); Append(ilist, bcls); } else { Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname)); Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname)); } } else { Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname)); Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname)); } } } break; } if (tname) Delete(tname); if (!bcls) { if (!clsforward) { if (ispublic && !Getmeta(bname, "already_warned")) { Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname)); if (Strchr(bname, '<')) { Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname)); } Setmeta(bname, "already_warned", "1"); } } SwigType_inherit(clsname, bname, cast, 0); } } } if (ilist) { Setattr(cls, bases, ilist); } } if (alist) Delete(alist); if (!ilist) return; int len = Len(ilist); int i; for (i = 0; i < len; i++) { Node *n = Getitem(ilist, i); String *bname = Getattr(n, "name"); Node *bclass = n; /* Getattr(n,"class"); */ Hash *scopes = Getattr(bclass, "typescope"); SwigType_inherit(clsname, bname, cast, 0); String *smartptr = Getattr(first, "feature:smartptr"); if (smartptr) { SwigType *smart = 0; SwigType *spt = Swig_cparse_type(smartptr); if (spt) { smart = SwigType_typedef_resolve_all(spt); Delete(spt); /* Record a (fake) inheritance relationship between smart pointer and smart pointer to base class, so that smart pointer upcasts are automatically generated. */ SwigType *bsmart = Copy(smart); SwigType *rclsname = SwigType_typedef_resolve_all(clsname); SwigType *rbname = SwigType_typedef_resolve_all(bname); Replaceall(bsmart, rclsname, rbname); Delete(rclsname); Delete(rbname); String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(bsmart); /* construct casting code */ String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr); Delete(bsmartnamestr); Delete(smartnamestr); /* setup inheritance relationship between smart pointer templates */ SwigType_inherit(smart, bsmart, 0, convcode); if (!GetFlag(bclass, "feature:smartptr")) Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name"))); Delete(convcode); Delete(bsmart); Delete(smart); } else { Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname)); } } else { if (GetFlag(bclass, "feature:smartptr")) Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name"))); } if (!importmode) { String *btype = Copy(bname); SwigType_add_pointer(btype); SwigType_remember(btype); Delete(btype); } if (scopes) { SwigType_inherit_scope(scopes); } /* Set up inheritance in the symbol table */ Symtab *st = Getattr(cls, "symtab"); Symtab *bst = Getattr(bclass, "symtab"); if (st == bst) { Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name"))); continue; } Symtab *s = Swig_symbol_current(); Swig_symbol_setscope(st); Swig_symbol_inherit(bst); Swig_symbol_setscope(s); /* Recursively hit base classes */ String *namestr = SwigType_namestr(Getattr(bclass, "name")); String *newcast = NewStringf("(%s *)%s", namestr, cast); Delete(namestr); cplus_inherit_types_impl(first, bclass, clsname, bases, baselist, ispublic, newcast); Delete(newcast); } } void append_list(List *lb, List *la) { if (la && lb) { for (Iterator bi = First(la); bi.item; bi = Next(bi)) { Append(lb, bi.item); } } } void cplus_inherit_types(Node *first, Node *cls, String *clsname, String *cast = 0) { cplus_inherit_types_impl(first, cls, clsname, "bases", "baselist", 1, cast); cplus_inherit_types_impl(first, cls, clsname, "protectedbases", "protectedbaselist", 0, cast); cplus_inherit_types_impl(first, cls, clsname, "privatebases", "privatebaselist", 0, cast); if (!cls) cls = first; List *allbases = NewList(); append_list(allbases, Getattr(cls, "bases")); append_list(allbases, Getattr(cls, "protectedbases")); append_list(allbases, Getattr(cls, "privatebases")); if (Len(allbases)) { Setattr(cls, "allbases", allbases); } Delete(allbases); } /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ virtual int top(Node *n) { importmode = 0; module = Getattr(n, "module"); inclass = 0; normalize = 0; nsname = 0; nssymname = 0; classhash = Getattr(n, "classes"); emit_children(n); normalize_list(); SwigType_set_scope(0); return SWIG_OK; } /* ------------------------------------------------------------ * moduleDirective() * ------------------------------------------------------------ */ virtual int moduleDirective(Node *n) { if (!module) { module = n; } return SWIG_OK; } /* ------------------------------------------------------------ * importDirective() * ------------------------------------------------------------ */ virtual int importDirective(Node *n) { String *oldmodule = module; int oldimport = importmode; importmode = 1; module = 0; emit_children(n); importmode = oldimport; module = oldmodule; return SWIG_OK; } /* ------------------------------------------------------------ * includeDirective() * externDirective() * extendDirective() * ------------------------------------------------------------ */ virtual int includeDirective(Node *n) { return emit_children(n); } virtual int externDeclaration(Node *n) { return emit_children(n); } virtual int extendDirective(Node *n) { return emit_children(n); } /* ------------------------------------------------------------ * classDeclaration() * ------------------------------------------------------------ */ virtual int classDeclaration(Node *n) { String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); String *unnamed = Getattr(n, "unnamed"); String *storage = Getattr(n, "storage"); String *kind = Getattr(n, "kind"); save_value oldinclass(inclass); List *olist = normalize; Symtab *symtab; String *nname = 0; String *fname = 0; String *scopename = 0; String *template_default_expanded = 0; normalize = NewList(); if (name) { if (SwigType_istemplate(name)) { // We need to fully resolve the name and expand default template parameters to make templates work correctly */ Node *cn; SwigType *resolved_name = SwigType_typedef_resolve_all(name); SwigType *deftype_name = Swig_symbol_template_deftype(resolved_name, 0); fname = Copy(resolved_name); if (!Equal(resolved_name, deftype_name)) template_default_expanded = Copy(deftype_name); if (!Equal(fname, name) && (cn = Swig_symbol_clookup_local(fname, 0))) { if ((n == cn) || (Strcmp(nodeType(cn), "template") == 0) || (Getattr(cn, "feature:onlychildren") != 0) || (Getattr(n, "feature:onlychildren") != 0)) { Swig_symbol_cadd(fname, n); if (template_default_expanded) Swig_symbol_cadd(template_default_expanded, n); SwigType_typedef_class(fname); scopename = Copy(fname); } else { Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n), "Template '%s' was already wrapped,\n", SwigType_namestr(name)); Swig_warning(WARN_TYPE_REDEFINED, Getfile(cn), Getline(cn), "previous wrap of '%s'.\n", SwigType_namestr(Getattr(cn, "name"))); scopename = 0; } } else { Swig_symbol_cadd(fname, n); SwigType_typedef_class(fname); scopename = Copy(fname); } Delete(deftype_name); Delete(resolved_name); } else { if ((CPlusPlus) || (unnamed)) { SwigType_typedef_class(name); } else { SwigType_typedef_class(NewStringf("%s %s", kind, name)); } scopename = Copy(name); } } else { scopename = 0; } Setattr(n, "typepass:visit", "1"); /* Need to set up a typedef if unnamed */ if (unnamed && tdname && (Cmp(storage, "typedef") == 0)) { SwigType_typedef(unnamed, tdname); } // name of the outer class should already be patched to contain its outer classes names, but not to contain namespaces // namespace name (if present) is added after processing child nodes if (Getattr(n, "nested:outer") && name) { String *outerName = Getattr(Getattr(n, "nested:outer"), "name"); name = NewStringf("%s::%s", outerName, name); Setattr(n, "name", name); if (tdname) { tdname = NewStringf("%s::%s", outerName, tdname); Setattr(n, "tdname", tdname); } } if (nsname && name) { nname = NewStringf("%s::%s", nsname, name); String *tdname = Getattr(n, "tdname"); if (tdname) { tdname = NewStringf("%s::%s", nsname, tdname); Setattr(n, "tdname", tdname); } } if (nssymname) { if (GetFlag(n, "feature:nspace")) Setattr(n, "sym:nspace", nssymname); } SwigType_new_scope(scopename); SwigType_attach_symtab(Getattr(n, "symtab")); /* Inherit type definitions into the class */ if (name && !(GetFlag(n, "nested") && !checkAttribute(n, "access", "public") && (GetFlag(n, "feature:flatnested") || Language::instance()->nestedClassesSupport() == Language::NCS_None))) { cplus_inherit_types(n, 0, nname ? nname : (fname ? fname : name)); } inclass = n; symtab = Swig_symbol_setscope(Getattr(n, "symtab")); emit_children(n); Swig_symbol_setscope(symtab); Hash *ts = SwigType_pop_scope(); Setattr(n, "typescope", ts); Delete(ts); Setattr(n, "module", module); // When a fully qualified templated type with default parameters is used in the parsed code, // the following additional symbols and scopes are needed for successful lookups if (template_default_expanded) { Swig_symbol_alias(template_default_expanded, Getattr(n, "symtab")); SwigType_scope_alias(template_default_expanded, Getattr(n, "typescope")); } /* Normalize deferred types */ { normal_node *nn = new normal_node(); nn->normallist = normalize; nn->symtab = Getattr(n, "symtab"); nn->next = patch_list; nn->typescope = Getattr(n, "typescope"); patch_list = nn; } normalize = olist; /* If in a namespace, patch the class name */ if (nname) { Setattr(n, "name", nname); Delete(nname); } Delete(fname); return SWIG_OK; } /* ------------------------------------------------------------ * templateDeclaration() * ------------------------------------------------------------ */ virtual int templateDeclaration(Node *n) { String *name = Getattr(n, "name"); String *ttype = Getattr(n, "templatetype"); if (Strcmp(ttype, "class") == 0) { String *rname = SwigType_typedef_resolve_all(name); SwigType_typedef_class(rname); Delete(rname); } else if (Strcmp(ttype, "classforward") == 0) { String *rname = SwigType_typedef_resolve_all(name); SwigType_typedef_class(rname); Delete(rname); /* SwigType_typedef_class(name); */ } return SWIG_OK; } /* ------------------------------------------------------------ * lambdaDeclaration() * ------------------------------------------------------------ */ virtual int lambdaDeclaration(Node *) { return SWIG_OK; } /* ------------------------------------------------------------ * classforwardDeclaration() * ------------------------------------------------------------ */ virtual int classforwardDeclaration(Node *n) { /* Can't do inside a C struct because it breaks C nested structure wrapping */ if ((!inclass) || (CPlusPlus)) { String *name = Getattr(n, "name"); SwigType_typedef_class(name); } return SWIG_OK; } /* ------------------------------------------------------------ * namespaceDeclaration() * ------------------------------------------------------------ */ virtual int namespaceDeclaration(Node *n) { Symtab *symtab; String *name = Getattr(n, "name"); String *alias = Getattr(n, "alias"); List *olist = normalize; normalize = NewList(); if (alias) { Typetab *ts = Getattr(n, "typescope"); if (!ts) { /* Create an empty scope for the alias */ Node *ns = Getattr(n, "namespace"); SwigType_scope_alias(name, Getattr(ns, "typescope")); ts = Getattr(ns, "typescope"); Setattr(n, "typescope", ts); } /* Namespace alias */ return SWIG_OK; } else { if (name) { Node *nn = Swig_symbol_clookup(name, n); Hash *ts = 0; if (nn) ts = Getattr(nn, "typescope"); if (!ts) { SwigType_new_scope(name); SwigType_attach_symtab(Getattr(n, "symtab")); } else { SwigType_set_scope(ts); } } String *oldnsname = nsname; String *oldnssymname = nssymname; nsname = Swig_symbol_qualified(Getattr(n, "symtab")); nssymname = Swig_symbol_qualified_language_scopename(Getattr(n, "symtab")); symtab = Swig_symbol_setscope(Getattr(n, "symtab")); emit_children(n); Swig_symbol_setscope(symtab); if (name) { Hash *ts = SwigType_pop_scope(); Setattr(n, "typescope", ts); Delete(ts); } /* Normalize deferred types */ { normal_node *nn = new normal_node(); nn->normallist = normalize; nn->symtab = Getattr(n, "symtab"); nn->next = patch_list; nn->typescope = Getattr(n, "typescope"); patch_list = nn; } normalize = olist; Delete(nssymname); nssymname = oldnssymname; Delete(nsname); nsname = oldnsname; return SWIG_OK; } } /* ------------------------------------------------------------ * cDeclaration() * ------------------------------------------------------------ */ virtual int cDeclaration(Node *n) { if (NoExcept) { Delattr(n, "throws"); } /* Normalize types. */ SwigType *ty = Getattr(n, "type"); if (!ty) { return SWIG_OK; } normalize_type(ty); SwigType *decl = Getattr(n, "decl"); if (decl) { normalize_type(decl); } normalize_parms(Getattr(n, "parms")); normalize_parms(Getattr(n, "throws")); if (GetFlag(n, "conversion_operator")) { /* The call to the operator in the generated wrapper must be fully qualified in order to compile */ SwigType *name = Getattr(n, "name"); SwigType *qualifiedname = Swig_symbol_string_qualify(name, 0); Clear(name); Append(name, qualifiedname); Delete(qualifiedname); } if (checkAttribute(n, "storage", "typedef")) { String *name = Getattr(n, "name"); ty = Getattr(n, "type"); decl = Getattr(n, "decl"); SwigType *t = Copy(ty); { /* If the typename is qualified, make sure the scopename is fully qualified when making a typedef */ if (Swig_scopename_check(t) && strncmp(Char(t), "::", 2)) { String *base, *prefix, *qprefix; base = Swig_scopename_last(t); prefix = Swig_scopename_prefix(t); qprefix = SwigType_typedef_qualified(prefix); Delete(t); t = NewStringf("%s::%s", qprefix, base); Delete(base); Delete(prefix); Delete(qprefix); } } SwigType_push(t, decl); if (CPlusPlus) { Replaceall(t, "struct ", ""); Replaceall(t, "union ", ""); Replaceall(t, "class ", ""); } SwigType_typedef(t, name); } /* If namespaces are active. We need to patch the name with a namespace prefix */ if (nsname && !inclass) { String *name = Getattr(n, "name"); if (name) { String *nname = NewStringf("%s::%s", nsname, name); Setattr(n, "name", nname); Delete(nname); } } clean_overloaded(n); return SWIG_OK; } /* ------------------------------------------------------------ * constructorDeclaration() * ------------------------------------------------------------ */ virtual int constructorDeclaration(Node *n) { if (NoExcept) { Delattr(n, "throws"); } normalize_parms(Getattr(n, "parms")); normalize_parms(Getattr(n, "throws")); clean_overloaded(n); return SWIG_OK; } /* ------------------------------------------------------------ * destructorDeclaration() * ------------------------------------------------------------ */ virtual int destructorDeclaration(Node *) { return SWIG_OK; } /* ------------------------------------------------------------ * constantDirective() * ------------------------------------------------------------ */ virtual int constantDirective(Node *n) { SwigType *ty = Getattr(n, "type"); if (ty) { Setattr(n, "type", SwigType_typedef_qualified(ty)); } return SWIG_OK; } /* ------------------------------------------------------------ * enumDeclaration() * ------------------------------------------------------------ */ virtual int enumDeclaration(Node *n) { String *name = Getattr(n, "name"); if (name) { String *scope = 0; // Add a typedef to the type table so that we can use 'enum Name' as well as just 'Name' if (nsname || inclass) { // But first correct the name and tdname to contain the fully qualified scopename if (nsname && inclass) { scope = NewStringf("%s::%s", nsname, Getattr(inclass, "name")); } else if (nsname) { scope = NewStringf("%s", nsname); } else if (inclass) { scope = NewStringf("%s", Getattr(inclass, "name")); } String *nname = NewStringf("%s::%s", scope, name); Setattr(n, "name", nname); String *tdname = Getattr(n, "tdname"); if (tdname) { tdname = NewStringf("%s::%s", scope, tdname); Setattr(n, "tdname", tdname); } SwigType *t = NewStringf("enum %s", nname); SwigType_typedef(t, name); } else { SwigType *t = NewStringf("enum %s", name); SwigType_typedef(t, name); } Delete(scope); } String *tdname = Getattr(n, "tdname"); String *unnamed = Getattr(n, "unnamed"); String *storage = Getattr(n, "storage"); // Construct enumtype - for declaring an enum of this type with SwigType_ltype() etc String *enumtype = 0; if (unnamed && tdname && (Cmp(storage, "typedef") == 0)) { enumtype = Copy(Getattr(n, "tdname")); } else if (name) { enumtype = NewStringf("%s%s", CPlusPlus ? "" : "enum ", Getattr(n, "name")); } else { // anonymous enums enumtype = Copy(Getattr(n, "type")); } Setattr(n, "enumtype", enumtype); if (nssymname) { if (GetFlag(n, "feature:nspace")) Setattr(n, "sym:nspace", nssymname); } // This block of code is for dealing with %ignore on an enum item where the target language // attempts to use the C enum value in the target language itself and expects the previous enum value // to be one more than the previous value... the previous enum item might not exist if it is ignored! // - It sets the first non-ignored enum item with the "firstenumitem" attribute. // - It adds an enumvalue attribute if the previous enum item is ignored { Node *c; int count = 0; String *previous = 0; bool previous_ignored = false; bool firstenumitem = false; for (c = firstChild(n); c; c = nextSibling(c)) { assert(strcmp(Char(nodeType(c)), "enumitem") == 0); bool reset; String *enumvalue = Getattr(c, "enumvalue"); if (GetFlag(c, "feature:ignore") || !Getattr(c, "sym:name")) { reset = enumvalue ? true : false; previous_ignored = true; } else { if (!enumvalue && previous_ignored) { if (previous) Setattr(c, "enumvalue", NewStringf("(%s) + %d", previous, count+1)); else Setattr(c, "enumvalue", NewStringf("%d", count)); SetFlag(c, "virtenumvalue"); // identify enumvalue as virtual, ie not from the parsed source } if (!firstenumitem) { SetFlag(c, "firstenumitem"); firstenumitem = true; } reset = true; previous_ignored = false; } if (reset) { previous = enumvalue ? enumvalue : Getattr(c, "name"); count = 0; } else { count++; } } } emit_children(n); return SWIG_OK; } /* ------------------------------------------------------------ * enumvalueDeclaration() * ------------------------------------------------------------ */ virtual int enumvalueDeclaration(Node *n) { String *name = Getattr(n, "name"); String *value = Getattr(n, "value"); String *scopedenum = Getattr(parentNode(n), "scopedenum"); if (!value) value = name; if (Strcmp(value, name) == 0) { String *new_value; if ((nsname || inclass || scopedenum) && cparse_cplusplus) { new_value = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value); } else { new_value = NewString(value); } if ((nsname || inclass || scopedenum) && !cparse_cplusplus) { String *cppvalue = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value); Setattr(n, "cppvalue", cppvalue); /* for target languages that always generate C++ code even when wrapping C code */ } Setattr(n, "value", new_value); Delete(new_value); } Node *next = nextSibling(n); // Make up an enumvalue if one was not specified in the parsed code (not designed to be used on enum items and %ignore - enumvalue will be set instead) if (!GetFlag(n, "feature:ignore")) { if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set (Note: first non-ignored enum item has firstenumitem set) Setattr(n, "enumvalueex", "0"); } if (next && !Getattr(next, "enumvalue")) { Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name"))); } } return SWIG_OK; } /* ------------------------------------------------------------ * enumforwardDeclaration() * ------------------------------------------------------------ */ virtual int enumforwardDeclaration(Node *n) { // Use enumDeclaration() to do all the hard work. // Note that no children can be emitted in a forward declaration as there aren't any. int result = enumDeclaration(n); if (result == SWIG_OK) { // Detect when the real enum matching the forward enum declaration has not been parsed/declared SwigType *ty = SwigType_typedef_resolve_all(Getattr(n, "type")); Replaceall(ty, "enum ", ""); Node *nn = Swig_symbol_clookup(ty, 0); String *nodetype = nn ? nodeType(nn) : 0; if (nodetype) { if (Equal(nodetype, "enumforward")) { SetFlag(nn, "enumMissing"); } // if a real enum was declared this would be an "enum" node type } Delete(ty); } return result; } #ifdef DEBUG_OVERLOADED static void show_overloaded(Node *n) { Node *c = Getattr(n, "sym:overloaded"); Node *checkoverloaded = c; Printf(stdout, "-------------------- overloaded start %s sym:overloaded():%p -------------------------------\n", Getattr(n, "name"), c); while (c) { if (Getattr(c, "error")) { c = Getattr(c, "sym:nextSibling"); continue; } if (Getattr(c, "sym:overloaded") != checkoverloaded) { Printf(stdout, "sym:overloaded error c:%p checkoverloaded:%p\n", c, checkoverloaded); Swig_print_node(c); exit (1); } String *decl = Strcmp(nodeType(c), "using") == 0 ? NewString("------") : Getattr(c, "decl"); Printf(stdout, " show_overloaded %s::%s(%s) [%s] nodeType:%s\n", parentNode(c) ? Getattr(parentNode(c), "name") : "NOPARENT", Getattr(c, "name"), decl, Getattr(c, "sym:overname"), nodeType(c)); if (!Getattr(c, "sym:overloaded")) { Printf(stdout, "sym:overloaded error.....%p\n", c); Swig_print_node(c); exit (1); } c = Getattr(c, "sym:nextSibling"); } Printf(stdout, "-------------------- overloaded end %s -------------------------------\n", Getattr(n, "name")); } #endif /* ------------------------------------------------------------ * usingDeclaration() * ------------------------------------------------------------ */ virtual int usingDeclaration(Node *n) { if (Getattr(n, "namespace")) { /* using namespace id */ /* For a namespace import. We set up inheritance in the type system */ Node *ns = Getattr(n, "node"); if (ns) { Typetab *ts = Getattr(ns, "typescope"); if (ts) { SwigType_using_scope(ts); } } return SWIG_OK; } else { Node *ns; /* using id */ Symtab *stab = Getattr(n, "sym:symtab"); if (stab) { String *uname = Getattr(n, "uname"); ns = Swig_symbol_clookup(uname, stab); if (!ns && SwigType_istemplate(uname)) { String *tmp = Swig_symbol_template_deftype(uname, 0); if (!Equal(tmp, uname)) { ns = Swig_symbol_clookup(tmp, stab); } Delete(tmp); } } else { ns = 0; } if (!ns) { if (is_public(n)) { Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(n), Getline(n), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(n, "uname"))); } } else { /* Only a single symbol is being used. There are only a few symbols that we actually care about. These are typedef, class declarations, and enum */ String *ntype = nodeType(ns); if (Strcmp(ntype, "cdecl") == 0) { if (checkAttribute(ns, "storage", "typedef")) { /* A typedef declaration */ String *uname = Getattr(n, "uname"); SwigType_typedef_using(uname); } else { /* A normal C declaration. */ if ((inclass) && (!GetFlag(n, "feature:ignore")) && (Getattr(n, "sym:name"))) { Node *c = ns; Node *unodes = 0, *last_unodes = 0; int ccount = 0; String *symname = Getattr(n, "sym:name"); while (c) { if (Strcmp(nodeType(c), "cdecl") == 0) { if (!(Swig_storage_isstatic(c) || checkAttribute(c, "storage", "typedef") || checkAttribute(c, "storage", "friend") || (Getattr(c, "feature:extend") && !Getattr(c, "code")) || GetFlag(c, "feature:ignore"))) { /* Don't generate a method if the method is overridden in this class, * for example don't generate another m(bool) should there be a Base::m(bool) : * struct Derived : Base { * void m(bool); * using Base::m; * }; */ String *csymname = Getattr(c, "sym:name"); if (!csymname || (Strcmp(csymname, symname) == 0)) { { String *decl = Getattr(c, "decl"); Node *over = Getattr(n, "sym:overloaded"); int match = 0; while (over) { String *odecl = Getattr(over, "decl"); if (Cmp(decl, odecl) == 0) { match = 1; break; } over = Getattr(over, "sym:nextSibling"); } if (match) { c = Getattr(c, "csym:nextSibling"); continue; } } Node *nn = copyNode(c); Delattr(nn, "access"); // access might be different from the method in the base class Setattr(nn, "access", Getattr(n, "access")); if (!Getattr(nn, "sym:name")) Setattr(nn, "sym:name", symname); if (!GetFlag(nn, "feature:ignore")) { ParmList *parms = CopyParmList(Getattr(c, "parms")); int is_pointer = SwigType_ispointer_return(Getattr(nn, "decl")); int is_void = checkAttribute(nn, "type", "void") && !is_pointer; Setattr(nn, "parms", parms); Delete(parms); if (Getattr(n, "feature:extend")) { String *ucode = is_void ? NewStringf("{ self->%s(", Getattr(n, "uname")) : NewStringf("{ return self->%s(", Getattr(n, "uname")); for (ParmList *p = parms; p;) { Append(ucode, Getattr(p, "name")); p = nextSibling(p); if (p) Append(ucode, ","); } Append(ucode, "); }"); Setattr(nn, "code", ucode); Delete(ucode); } ParmList *throw_parm_list = Getattr(c, "throws"); if (throw_parm_list) Setattr(nn, "throws", CopyParmList(throw_parm_list)); ccount++; if (!last_unodes) { last_unodes = nn; unodes = nn; } else { Setattr(nn, "previousSibling", last_unodes); Setattr(last_unodes, "nextSibling", nn); Setattr(nn, "sym:previousSibling", last_unodes); Setattr(last_unodes, "sym:nextSibling", nn); Setattr(nn, "sym:overloaded", unodes); Setattr(unodes, "sym:overloaded", unodes); last_unodes = nn; } } else { Delete(nn); } } } } c = Getattr(c, "csym:nextSibling"); } if (unodes) { set_firstChild(n, unodes); if (ccount > 1) { if (!Getattr(n, "sym:overloaded")) { Setattr(n, "sym:overloaded", n); Setattr(n, "sym:overname", "_SWIG_0"); } } } /* Hack the parse tree symbol table for overloaded methods. Replace the "using" node with the * list of overloaded methods we have just added in as child nodes to the "using" node. * The node will still exist, it is just the symbol table linked list of overloaded methods * which is hacked. */ if (Getattr(n, "sym:overloaded")) { int cnt = 0; #ifdef DEBUG_OVERLOADED Node *debugnode = n; show_overloaded(n); #endif if (!firstChild(n)) { // Remove from overloaded list ('using' node does not actually end up adding in any methods) Node *ps = Getattr(n, "sym:previousSibling"); Node *ns = Getattr(n, "sym:nextSibling"); if (ps) { Setattr(ps, "sym:nextSibling", ns); } if (ns) { Setattr(ns, "sym:previousSibling", ps); } } else { // The 'using' node results in methods being added in - slot in the these methods here Node *ps = Getattr(n, "sym:previousSibling"); Node *ns = Getattr(n, "sym:nextSibling"); Node *fc = firstChild(n); Node *pp = fc; Node *firstoverloaded = Getattr(n, "sym:overloaded"); if (firstoverloaded == n) { // This 'using' node we are cutting out was the first node in the overloaded list. // Change the first node in the list to its first sibling Delattr(firstoverloaded, "sym:overloaded"); Node *nnn = Getattr(firstoverloaded, "sym:nextSibling"); firstoverloaded = fc; while (nnn) { Setattr(nnn, "sym:overloaded", firstoverloaded); nnn = Getattr(nnn, "sym:nextSibling"); } } while (pp) { Node *ppn = Getattr(pp, "sym:nextSibling"); Setattr(pp, "sym:overloaded", firstoverloaded); Setattr(pp, "sym:overname", NewStringf("%s_%d", Getattr(n, "sym:overname"), cnt++)); if (ppn) pp = ppn; else break; } if (ps) { Setattr(ps, "sym:nextSibling", fc); Setattr(fc, "sym:previousSibling", ps); } if (ns) { Setattr(ns, "sym:previousSibling", pp); Setattr(pp, "sym:nextSibling", ns); } #ifdef DEBUG_OVERLOADED debugnode = firstoverloaded; #endif } Delattr(n, "sym:previousSibling"); Delattr(n, "sym:nextSibling"); Delattr(n, "sym:overloaded"); Delattr(n, "sym:overname"); #ifdef DEBUG_OVERLOADED show_overloaded(debugnode); #endif clean_overloaded(n); // Needed? } } } } else if ((Strcmp(ntype, "class") == 0) || ((Strcmp(ntype, "classforward") == 0))) { /* We install the using class name as kind of a typedef back to the original class */ String *uname = Getattr(n, "uname"); /* Import into current type scope */ SwigType_typedef_using(uname); } else if (Strcmp(ntype, "enum") == 0) { SwigType_typedef_using(Getattr(n, "uname")); } else if (Strcmp(ntype, "template") == 0) { /* Printf(stdout, "usingDeclaration template %s --- %s\n", Getattr(n, "name"), Getattr(n, "uname")); SwigType_typedef_using(Getattr(n, "uname")); */ } } } return SWIG_OK; } /* ------------------------------------------------------------ * typemapDirective() * ------------------------------------------------------------ */ virtual int typemapDirective(Node *n) { if (inclass || nsname) { Node *items = firstChild(n); while (items) { Parm *pattern = Getattr(items, "pattern"); Parm *parms = Getattr(items, "parms"); normalize_later(pattern); normalize_later(parms); items = nextSibling(items); } } return SWIG_OK; } /* ------------------------------------------------------------ * typemapcopyDirective() * ------------------------------------------------------------ */ virtual int typemapcopyDirective(Node *n) { if (inclass || nsname) { Node *items = firstChild(n); ParmList *pattern = Getattr(n, "pattern"); normalize_later(pattern); while (items) { ParmList *npattern = Getattr(items, "pattern"); normalize_later(npattern); items = nextSibling(items); } } return SWIG_OK; } /* ------------------------------------------------------------ * applyDirective() * ------------------------------------------------------------ */ virtual int applyDirective(Node *n) { if (inclass || nsname) { ParmList *pattern = Getattr(n, "pattern"); normalize_later(pattern); Node *items = firstChild(n); while (items) { Parm *apattern = Getattr(items, "pattern"); normalize_later(apattern); items = nextSibling(items); } } return SWIG_OK; } /* ------------------------------------------------------------ * clearDirective() * ------------------------------------------------------------ */ virtual int clearDirective(Node *n) { if (inclass || nsname) { Node *p; for (p = firstChild(n); p; p = nextSibling(p)) { ParmList *pattern = Getattr(p, "pattern"); normalize_later(pattern); } } return SWIG_OK; } public: static void pass(Node *n) { TypePass t; t.top(n); } }; void Swig_process_types(Node *n) { if (!n) return; TypePass::pass(n); } swig-3.0.2/Source/Modules/main.cxx0000664000175000017500000012712212343605122016670 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * main.cxx * * Main entry point to the SWIG core. * ----------------------------------------------------------------------------- */ #include "swigconfig.h" #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include #endif #include "swigmod.h" #include "swigwarn.h" #include "cparse.h" #include #include // for INT_MAX // Global variables static Language *lang = 0; // Language method int CPlusPlus = 0; int Extend = 0; // Extend flag int ForceExtern = 0; // Force extern mode int GenerateDefault = 1; // Generate default constructors int Verbose = 0; int AddExtern = 0; int NoExcept = 0; int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime /* Suppress warning messages for private inheritance, preprocessor evaluation etc... WARN_PP_EVALUATION 202 WARN_PARSE_PRIVATE_INHERIT 309 WARN_TYPE_ABSTRACT 403 WARN_LANG_OVERLOAD_CONST 512 WARN_PARSE_BUILTIN_NAME 321 WARN_PARSE_REDUNDANT 322 */ #define EXTRA_WARNINGS "202,309,403,512,321,322" extern "C" { extern String *ModuleName; extern int ignore_nested_classes; } /* usage string split into multiple parts otherwise string is too big for some compilers */ /* naming conventions for commandline options - no underscores, no capital letters, join words together * except when using a common prefix, then use '-' to separate, eg the debug-xxx options */ static const char *usage1 = (const char *) "\ \nGeneral Options\n\ -addextern - Add extra extern declarations\n\ -c++ - Enable C++ processing\n\ -co - Check out of the SWIG library\n\ -copyctor - Automatically generate copy constructors wherever possible\n\ -cpperraswarn - Treat the preprocessor #error statement as #warning (default)\n\ -copyright - Display copyright notices\n\ -debug-classes - Display information about the classes found in the interface\n\ -debug-module - Display module parse tree at stages 1-4, is a csv list of stages\n\ -debug-symtabs - Display symbol tables information\n\ -debug-symbols - Display target language symbols in the symbol tables\n\ -debug-csymbols - Display C symbols in the symbol tables\n\ -debug-lsymbols - Display target language layer symbols\n\ -debug-tags - Display information about the tags found in the interface\n\ -debug-template - Display information for debugging templates\n\ -debug-top - Display entire parse tree at stages 1-4, is a csv list of stages\n\ -debug-typedef - Display information about the types and typedefs in the interface\n\ -debug-typemap - Display typemap debugging information\n\ -debug-tmsearch - Display typemap search debugging information\n\ -debug-tmused - Display typemaps used debugging information\n\ -directors - Turn on director mode for all the classes, mainly for testing\n\ -dirprot - Turn on wrapping of protected members for director classes (default)\n\ -D - Define a symbol (for conditional compilation)\n\ -E - Preprocess only, does not generate wrapper code\n\ -external-runtime [file] - Export the SWIG runtime stack\n\ -fakeversion - Make SWIG fake the program version number to \n\ -fcompact - Compile in compact mode\n\ -features - Set global features, where is a comma separated list of\n\ features, eg -features directors,autodoc=1\n\ If no explicit value is given to the feature, a default of 1 is used\n\ "; static const char *usage2 = (const char *) "\ -fastdispatch - Enable fast dispatch mode to produce faster overload dispatcher code\n\ -Fmicrosoft - Display error/warning messages in Microsoft format\n\ -Fstandard - Display error/warning messages in commonly used format\n\ -fvirtual - Compile in virtual elimination mode\n\ -help - This output\n\ -I- - Don't search the current directory\n\ -I - Look for SWIG files in directory \n\ -ignoremissing - Ignore missing include files\n\ -importall - Follow all #include statements as imports\n\ -includeall - Follow all #include statements\n\ -l - Include SWIG library file \n\ -macroerrors - Report errors inside macros\n\ -makedefault - Create default constructors/destructors (the default)\n\ -M - List all dependencies\n\ -MD - Is equivalent to `-M -MF ', except `-E' is not implied\n\ -MF - Generate dependencies into and continue generating wrappers\n\ -MM - List dependencies, but omit files in SWIG library\n\ -MMD - Like `-MD', but omit files in SWIG library\n\ -module - Set module name to \n\ -MP - Generate phony targets for all dependencies\n\ -MT - Set the target of the rule emitted by dependency generation\n\ -nocontract - Turn off contract checking\n\ -nocpperraswarn - Do not treat the preprocessor #error statement as #warning\n\ -nodefault - Do not generate default constructors nor default destructors\n\ -nodefaultctor - Do not generate implicit default constructors\n\ -nodefaultdtor - Do not generate implicit default destructors\n\ -nodirprot - Do not wrap director protected members\n\ -noexcept - Do not wrap exception specifiers\n\ -nofastdispatch - Disable fast dispatch mode (default)\n\ -nopreprocess - Skip the preprocessor step\n\ "; static const char *usage3 = (const char *) "\ -notemplatereduce - Disable reduction of the typedefs in templates\n\ -O - Enable the optimization options: \n\ -fastdispatch -fvirtual \n\ -o - Set name of the output file to \n\ -oh - Set name of the output header file to \n\ -outcurrentdir - Set default output dir to current dir instead of input file's path\n\ -outdir - Set language specific files output directory to \n\ -pcreversion - Display PCRE version information\n\ -small - Compile in virtual elimination & compact mode\n\ -swiglib - Report location of SWIG library and exit\n\ -templatereduce - Reduce all the typedefs in templates\n\ -v - Run in verbose mode\n\ -version - Display SWIG version number\n\ -Wall - Remove all warning suppression, also implies -Wextra\n\ -Wallkw - Enable keyword warnings for all the supported languages\n\ -Werror - Treat warnings as errors\n\ -Wextra - Adds the following additional warnings: " EXTRA_WARNINGS "\n\ -w - Suppress/add warning messages, eg -w401,+321 - see Warnings.html\n\ -xmlout - Write XML version of the parse tree to after normal processing\n\ \n\ Options can also be defined using the SWIG_FEATURES environment variable, for example:\n\ \n\ $ SWIG_FEATURES=\"-Wall\"\n\ $ export SWIG_FEATURES\n\ $ swig -python interface.i\n\ \n\ is equivalent to: \n\ \n\ $ swig -Wall -python interface.i \n\ \n\ \n"; // Local variables static String *LangSubDir = 0; // Target language library subdirectory static String *SwigLib = 0; // Library directory static String *SwigLibWinUnix = 0; // Extra library directory on Windows static int freeze = 0; static String *lang_config = 0; static const char *hpp_extension = "h"; static const char *cpp_extension = "cxx"; static const char *depends_extension = "d"; static String *outdir = 0; static String *xmlout = 0; static int outcurrentdir = 0; static int help = 0; static int checkout = 0; static int cpp_only = 0; static int no_cpp = 0; static String *outfile_name = 0; static String *outfile_name_h = 0; static int tm_debug = 0; static int dump_symtabs = 0; static int dump_symbols = 0; static int dump_csymbols = 0; static int dump_lang_symbols = 0; static int dump_tags = 0; static int dump_module = 0; static int dump_top = 0; static int dump_xml = 0; static int browse = 0; static int dump_typedef = 0; static int dump_classes = 0; static int werror = 0; static int depend = 0; static int depend_only = 0; static int depend_phony = 0; static int memory_debug = 0; static int allkw = 0; static DOH *cpps = 0; static String *dependencies_file = 0; static String *dependencies_target = 0; static int external_runtime = 0; static String *external_runtime_name = 0; enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 }; static List *libfiles = 0; static List *all_output_files = 0; /* ----------------------------------------------------------------------------- * check_extension() * * Checks the extension of a file to see if we should emit extern declarations. * ----------------------------------------------------------------------------- */ static bool check_extension(String *filename) { bool wanted = false; const char *name = Char(filename); if (!name) return 0; String *extension = Swig_file_extension(name); const char *c = Char(extension); if ((strcmp(c, ".c") == 0) || (strcmp(c, ".C") == 0) || (strcmp(c, ".cc") == 0) || (strcmp(c, ".cxx") == 0) || (strcmp(c, ".c++") == 0) || (strcmp(c, ".cpp") == 0)) { wanted = true; } Delete(extension); return wanted; } /* ----------------------------------------------------------------------------- * install_opts() * * Install all command line options as preprocessor symbols * ----------------------------------------------------------------------------- */ static void install_opts(int argc, char *argv[]) { int i; int noopt = 0; char *c; for (i = 1; i < (argc - 1); i++) { if (argv[i]) { if ((*argv[i] == '-') && (!isupper(*(argv[i] + 1)))) { String *opt = NewStringf("SWIGOPT%(upper)s", argv[i]); Replaceall(opt, "-", "_"); c = Char(opt); noopt = 0; while (*c) { if (!(isalnum(*c) || (*c == '_'))) { noopt = 1; break; } c++; } if (((i + 1) < (argc - 1)) && (argv[i + 1]) && (*argv[i + 1] != '-')) { Printf(opt, " %s", argv[i + 1]); i++; } else { Printf(opt, " 1"); } if (!noopt) { /* Printf(stdout,"%s\n", opt); */ Preprocessor_define(opt, 0); } Delete(opt); } } } } /* ----------------------------------------------------------------------------- * decode_numbers_list() * * Decode comma separated list into a binary number of the inputs or'd together * eg list="1,4" will return (2^0 || 2^3) = 0x1001 * ----------------------------------------------------------------------------- */ static unsigned int decode_numbers_list(String *numlist) { unsigned int decoded_number = 0; if (numlist) { List *numbers = Split(numlist, ',', INT_MAX); if (numbers && Len(numbers) > 0) { for (Iterator it = First(numbers); it.item; it = Next(it)) { String *numstring = it.item; // TODO: check that it is a number int number = atoi(Char(numstring)); if (number > 0 && number <= 16) { decoded_number |= (1 << (number-1)); } } } } return decoded_number; } /* ----------------------------------------------------------------------------- * Sets the output directory for language specific (proxy) files from the * C wrapper file if not set and corrects the directory name and adds a trailing * file separator if necessary. * ----------------------------------------------------------------------------- */ static void configure_outdir(const String *c_wrapper_outfile) { // Use the C wrapper file's directory if the output directory has not been set by user if (!outdir || Len(outdir) == 0) outdir = Swig_file_dirname(c_wrapper_outfile); Swig_filename_correct(outdir); // Add trailing file delimiter if not present in output directory name if (Len(outdir) > 0) { const char *outd = Char(outdir); if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0) Printv(outdir, SWIG_FILE_DELIMITER, NIL); } } /* This function sets the name of the configuration file */ void SWIG_config_file(const_String_or_char_ptr filename) { lang_config = NewString(filename); } /* Sets the target language subdirectory name */ void SWIG_library_directory(const char *subdirectory) { LangSubDir = NewString(subdirectory); } // Returns the directory for generating language specific files (non C/C++ files) const String *SWIG_output_directory() { assert(outdir); return outdir; } void SWIG_config_cppext(const char *ext) { cpp_extension = ext; } List *SWIG_output_files() { assert(all_output_files); return all_output_files; } void SWIG_setfeature(const char *cfeature, const char *cvalue) { Hash *features_hash = Swig_cparse_features(); String *name = NewString(""); String *fname = NewString(cfeature); String *fvalue = NewString(cvalue); Swig_feature_set(features_hash, name, 0, fname, fvalue, 0); Delete(name); Delete(fname); Delete(fvalue); } void SWIG_setfeatures(const char *c) { char feature[64]; char *fb = feature; char *fe = fb + 63; Hash *features_hash = Swig_cparse_features(); String *name = NewString(""); /* Printf(stderr,"all features %s\n", c); */ while (*c) { char *f = fb; String *fname = NewString("feature:"); String *fvalue = NewString(""); while ((f != fe) && *c != '=' && *c != ',' && *c) { *(f++) = *(c++); } *f = 0; Printf(fname, "%s", feature); if (*c && *(c++) == '=') { char value[64]; char *v = value; char *ve = v + 63; while ((v != ve) && *c != ',' && *c && !isspace(*c)) { *(v++) = *(c++); } *v = 0; Printf(fvalue, "%s", value); } else { Printf(fvalue, "1"); } /* Printf(stderr,"%s %s\n", fname, fvalue); */ Swig_feature_set(features_hash, name, 0, fname, fvalue, 0); Delete(fname); Delete(fvalue); } Delete(name); } /* This function handles the -external-runtime command option */ static void SWIG_dump_runtime() { String *outfile; File *runtime; String *s; outfile = external_runtime_name; if (!outfile) { outfile = lang->defaultExternalRuntimeFilename(); if (!outfile) { Printf(stderr, "*** Please provide a filename for the external runtime\n"); SWIG_exit(EXIT_FAILURE); } } runtime = NewFile(outfile, "w", SWIG_output_files()); if (!runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } Swig_banner(runtime); Printf(runtime, "\n"); s = Swig_include_sys("swiglabels.swg"); if (!s) { Printf(stderr, "*** Unable to open 'swiglabels.swg'\n"); Delete(runtime); SWIG_exit(EXIT_FAILURE); } Printf(runtime, "%s", s); Delete(s); s = Swig_include_sys("swigerrors.swg"); if (!s) { Printf(stderr, "*** Unable to open 'swigerrors.swg'\n"); Delete(runtime); SWIG_exit(EXIT_FAILURE); } Printf(runtime, "%s", s); Delete(s); s = Swig_include_sys("swigrun.swg"); if (!s) { Printf(stderr, "*** Unable to open 'swigrun.swg'\n"); Delete(runtime); SWIG_exit(EXIT_FAILURE); } Printf(runtime, "%s", s); Delete(s); s = lang->runtimeCode(); Printf(runtime, "%s", s); Delete(s); s = Swig_include_sys("runtime.swg"); if (!s) { Printf(stderr, "*** Unable to open 'runtime.swg'\n"); Delete(runtime); SWIG_exit(EXIT_FAILURE); } Printf(runtime, "%s", s); Delete(s); Delete(runtime); SWIG_exit(EXIT_SUCCESS); } void SWIG_getoptions(int argc, char *argv[]) { int i; // Get options for (i = 1; i < argc; i++) { if (argv[i] && !Swig_check_marked(i)) { if (strncmp(argv[i], "-I-", 3) == 0) { // Don't push/pop directories Swig_set_push_dir(0); Swig_mark_arg(i); } else if (strncmp(argv[i], "-I", 2) == 0) { // Add a new directory search path char *a = Swig_copy_string(argv[i] + 2); Swig_add_directory((DOH *) a); free(a); Swig_mark_arg(i); } else if (strncmp(argv[i], "-D", 2) == 0) { String *d = NewString(argv[i] + 2); Replace(d, "=", " ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST); Preprocessor_define((DOH *) d, 0); Delete(d); // Create a symbol Swig_mark_arg(i); } else if (strcmp(argv[i], "-E") == 0) { cpp_only = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nopreprocess") == 0) { no_cpp = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-verbose") == 0) || (strcmp(argv[i], "-v") == 0)) { Verbose = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-c++") == 0) { CPlusPlus = 1; Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); Swig_cparse_cplusplus(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-c++out") == 0) { // Undocumented Swig_cparse_cplusplusout(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-fcompact") == 0) { Wrapper_compact_print_mode_set(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-fvirtual") == 0) { Wrapper_virtual_elimination_mode_set(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastdispatch") == 0) { Wrapper_fast_dispatch_mode_set(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-nofastdispatch") == 0) { Wrapper_fast_dispatch_mode_set(0); Swig_mark_arg(i); } else if (strcmp(argv[i], "-naturalvar") == 0) { Wrapper_naturalvar_mode_set(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-directors") == 0) { SWIG_setfeature("feature:director", "1"); Wrapper_director_mode_set(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-dirprot") == 0) { Wrapper_director_protected_mode_set(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-nodirprot") == 0) { Wrapper_director_protected_mode_set(0); Swig_mark_arg(i); } else if (strcmp(argv[i], "-pcreversion") == 0) { String *version = Swig_pcre_version(); Printf(stdout, "%s\n", version); Delete(version); Swig_mark_arg(i); SWIG_exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-small") == 0) { Wrapper_compact_print_mode_set(1); Wrapper_virtual_elimination_mode_set(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-runtime") == 0) { // Used to also accept -c. removed in swig-1.3.36 Swig_mark_arg(i); Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n"); SwigRuntime = 1; } else if (strcmp(argv[i], "-noruntime") == 0) { Swig_mark_arg(i); Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n"); SwigRuntime = 2; } else if (strcmp(argv[i], "-external-runtime") == 0) { external_runtime = 1; Swig_mark_arg(i); if (argv[i + 1]) { external_runtime_name = NewString(argv[i + 1]); Swig_mark_arg(i + 1); i++; } } else if ((strcmp(argv[i], "-make_default") == 0) || (strcmp(argv[i], "-makedefault") == 0)) { GenerateDefault = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-no_default") == 0) || (strcmp(argv[i], "-nodefault") == 0)) { GenerateDefault = 0; Swig_warning(WARN_DEPRECATED_NODEFAULT, "SWIG", 1, "dangerous, use -nodefaultctor, -nodefaultdtor instead.\n"); Swig_mark_arg(i); } else if ((strcmp(argv[i], "-nodefaultctor") == 0)) { SWIG_setfeature("feature:nodefaultctor", "1"); Swig_mark_arg(i); } else if ((strcmp(argv[i], "-nodefaultdtor") == 0)) { SWIG_setfeature("feature:nodefaultdtor", "1"); Swig_mark_arg(i); } else if ((strcmp(argv[i], "-copyctor") == 0)) { SWIG_setfeature("feature:copyctor", "1"); Swig_mark_arg(i); } else if (strcmp(argv[i], "-noexcept") == 0) { NoExcept = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-noextern") == 0) { Swig_warning(WARN_DEPRECATED_NOEXTERN, "SWIG", 1, "-noextern command line option is deprecated; extern is no longer generated by default.\n"); AddExtern = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-addextern") == 0) { AddExtern = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-debug-template") == 0) || (strcmp(argv[i], "-debug_template") == 0) || (strcmp(argv[i], "-show_templates") == 0)) { Swig_cparse_debug_templates(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-templatereduce") == 0) { SWIG_cparse_template_reduce(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-notemplatereduce") == 0) { SWIG_cparse_template_reduce(0); Swig_mark_arg(i); } else if (strcmp(argv[i], "-macroerrors") == 0) { Swig_cparse_follow_locators(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-swiglib") == 0) { Printf(stdout, "%s\n", SwigLib); if (SwigLibWinUnix) Printf(stdout, "%s\n", SwigLibWinUnix); SWIG_exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-o") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { outfile_name = NewString(argv[i + 1]); Swig_filename_correct(outfile_name); if (!outfile_name_h || !dependencies_file) { char *ext = strrchr(Char(outfile_name), '.'); String *basename = ext ? NewStringWithSize(Char(outfile_name), Char(ext) - Char(outfile_name)) : NewString(outfile_name); if (!dependencies_file) { dependencies_file = NewStringf("%s.%s", basename, depends_extension); } if (!outfile_name_h) { Printf(basename, ".%s", hpp_extension); outfile_name_h = NewString(basename); } Delete(basename); } Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-oh") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { outfile_name_h = NewString(argv[i + 1]); Swig_filename_correct(outfile_name_h); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-fakeversion") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { Swig_set_fakeversion(argv[i + 1]); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-version") == 0) { fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); fprintf(stdout, "\nConfigured options: %cpcre\n", #ifdef HAVE_PCRE '+' #else '-' #endif ); fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT); SWIG_exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-copyright") == 0) { fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); fprintf(stdout, "Copyright (c) 1995-1998\n"); fprintf(stdout, "University of Utah and the Regents of the University of California\n"); fprintf(stdout, "Copyright (c) 1998-2005\n"); fprintf(stdout, "University of Chicago\n"); fprintf(stdout, "Copyright (c) 2005-2006\n"); fprintf(stdout, "Arizona Board of Regents (University of Arizona)\n"); SWIG_exit(EXIT_SUCCESS); } else if (strncmp(argv[i], "-l", 2) == 0) { // Add a new directory search path Append(libfiles, argv[i] + 2); Swig_mark_arg(i); } else if (strcmp(argv[i], "-co") == 0) { checkout = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-features") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { SWIG_setfeatures(argv[i + 1]); Swig_mark_arg(i + 1); } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-freeze") == 0) { freeze = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-includeall") == 0) { Preprocessor_include_all(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-importall") == 0) { Preprocessor_import_all(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-ignoremissing") == 0) { Preprocessor_ignore_missing(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-cpperraswarn") == 0) { Preprocessor_error_as_warning(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-nocpperraswarn") == 0) { Preprocessor_error_as_warning(0); Swig_mark_arg(i); } else if ((strcmp(argv[i], "-debug-typemap") == 0) || (strcmp(argv[i], "-debug_typemap") == 0) || (strcmp(argv[i], "-tm_debug") == 0)) { tm_debug = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-debug-tmsearch") == 0) { Swig_typemap_search_debug_set(); Swig_mark_arg(i); } else if (strcmp(argv[i], "-debug-tmused") == 0) { Swig_typemap_used_debug_set(); Swig_mark_arg(i); } else if (strcmp(argv[i], "-module") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { ModuleName = NewString(argv[i + 1]); Swig_mark_arg(i + 1); } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-M") == 0) { depend = 1; depend_only = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-MM") == 0) { depend = 2; depend_only = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-MF") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { dependencies_file = NewString(argv[i + 1]); Swig_mark_arg(i + 1); } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-MD") == 0) { depend = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-MMD") == 0) { depend = 2; Swig_mark_arg(i); } else if (strcmp(argv[i], "-MP") == 0) { depend_phony = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-MT") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { if (!dependencies_target) dependencies_target = NewString(argv[i + 1]); else Printf(dependencies_target, " %s", argv[i + 1]); Swig_mark_arg(i + 1); } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-outdir") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { outdir = NewString(argv[i + 1]); Swig_mark_arg(i + 1); } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-outcurrentdir") == 0) { Swig_mark_arg(i); outcurrentdir = 1; } else if (strcmp(argv[i], "-Wall") == 0) { Swig_mark_arg(i); Swig_warnall(); } else if (strcmp(argv[i], "-Wallkw") == 0) { allkw = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-Werror") == 0) { werror = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-Wextra") == 0) { Swig_mark_arg(i); Swig_warnfilter(EXTRA_WARNINGS, 0); } else if (strncmp(argv[i], "-w", 2) == 0) { Swig_mark_arg(i); Swig_warnfilter(argv[i] + 2, 1); } else if (strcmp(argv[i], "-debug-symtabs") == 0) { dump_symtabs = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-debug-symbols") == 0) { dump_symbols = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-debug-csymbols") == 0) { dump_csymbols = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-debug-lsymbols") == 0) { dump_lang_symbols = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) { dump_tags = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-debug-top") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { String *dump_list = NewString(argv[i + 1]); dump_top = decode_numbers_list(dump_list); if (dump_top < STAGE1 || dump_top >= STAGEOVERFLOW) Swig_arg_error(); else Swig_mark_arg(i + 1); Delete(dump_list); } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-debug-module") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { String *dump_list = NewString(argv[i + 1]); dump_module = decode_numbers_list(dump_list); if (dump_module < STAGE1 || dump_module >= STAGEOVERFLOW) Swig_arg_error(); else Swig_mark_arg(i + 1); Delete(dump_list); } else { Swig_arg_error(); } } else if ((strcmp(argv[i], "-dump_tree") == 0) || (strcmp(argv[i], "-dump_top") == 0)) { dump_top |= STAGE4; Swig_mark_arg(i); } else if (strcmp(argv[i], "-dump_module") == 0) { dump_module |= STAGE4; Swig_mark_arg(i); } else if (strcmp(argv[i], "-dump_parse_module") == 0) { dump_module |= STAGE1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-dump_parse_top") == 0) { dump_top |= STAGE1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-dump_xml") == 0) { dump_xml = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-xmlout") == 0) { dump_xml = 1; Swig_mark_arg(i); if (argv[i + 1]) { xmlout = NewString(argv[i + 1]); Swig_mark_arg(i + 1); } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-nocontract") == 0) { Swig_mark_arg(i); Swig_contract_mode_set(0); } else if (strcmp(argv[i], "-browse") == 0) { browse = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-debug-typedef") == 0) || (strcmp(argv[i], "-dump_typedef") == 0)) { dump_typedef = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-debug-classes") == 0) || (strcmp(argv[i], "-dump_classes") == 0)) { dump_classes = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-debug-memory") == 0) || (strcmp(argv[i], "-dump_memory") == 0)) { memory_debug = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-Fstandard") == 0) { Swig_error_msg_format(EMF_STANDARD); Swig_mark_arg(i); } else if (strcmp(argv[i], "-Fmicrosoft") == 0) { Swig_error_msg_format(EMF_MICROSOFT); Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { Wrapper_virtual_elimination_mode_set(1); Wrapper_fast_dispatch_mode_set(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage1, stdout); fputs(usage2, stdout); fputs(usage3, stdout); Swig_mark_arg(i); help = 1; } } } } int SWIG_main(int argc, char *argv[], Language *l) { char *c; /* Initialize the SWIG core */ Swig_init(); // Default warning suppression Swig_warnfilter(EXTRA_WARNINGS, 1); // Initialize the preprocessor Preprocessor_init(); lang = l; // Set up some default symbols (available in both SWIG interface files // and C files) Preprocessor_define((DOH *) "SWIG 1", 0); Preprocessor_define((DOH *) "__STDC__", 0); // Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C String *package_version = NewString(PACKAGE_VERSION); /* Note that the fakeversion has not been set at this point */ char *token = strtok(Char(package_version), "."); String *vers = NewString("SWIG_VERSION 0x"); int count = 0; while (token) { int len = strlen(token); assert(len == 1 || len == 2); Printf(vers, "%s%s", (len == 1) ? "0" : "", token); token = strtok(NULL, "."); count++; } Delete(package_version); assert(count == 3); // Check version format is correct /* Turn on contracts */ Swig_contract_mode_set(1); Preprocessor_define(vers, 0); /* Turn off directors mode */ Wrapper_director_mode_set(0); Wrapper_director_protected_mode_set(1); // Inform the parser if the nested classes should be ignored unless explicitly told otherwise via feature:flatnested ignore_nested_classes = l->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0; // Create Library search directories // Check for SWIG_LIB environment variable if ((c = getenv("SWIG_LIB")) == (char *) 0) { #if defined(_WIN32) char buf[MAX_PATH]; char *p; if (!(GetModuleFileName(0, buf, MAX_PATH) == 0 || (p = strrchr(buf, '\\')) == 0)) { *(p + 1) = '\0'; SwigLib = NewStringf("%sLib", buf); // Native windows installation path } else { SwigLib = NewStringf(""); // Unexpected error } if (Len(SWIG_LIB_WIN_UNIX) > 0) SwigLibWinUnix = NewString(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw) #else SwigLib = NewString(SWIG_LIB); #endif } else { SwigLib = NewString(c); } libfiles = NewList(); all_output_files = NewList(); /* Check for SWIG_FEATURES environment variable */ SWIG_getoptions(argc, argv); // Define the __cplusplus symbol if (CPlusPlus) Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); // Parse language dependent options lang->main(argc, argv); if (help) { Printf(stdout, "\nNote: 'swig - -help' displays options for a specific target language.\n\n"); SWIG_exit(EXIT_SUCCESS); // Exit if we're in help mode } // Check all of the options to make sure we're cool. // Don't check for an input file if -external-runtime is passed Swig_check_options(external_runtime ? 0 : 1); if (CPlusPlus && cparse_cplusplusout) { Printf(stderr, "The -c++out option is for C input but C++ input has been requested via -c++\n"); SWIG_exit(EXIT_FAILURE); } install_opts(argc, argv); // Add language dependent directory to the search path { String *rl = NewString(""); Printf(rl, ".%sswig_lib%s%s", SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER, LangSubDir); Swig_add_directory(rl); if (SwigLibWinUnix) { rl = NewString(""); Printf(rl, "%s%s%s", SwigLibWinUnix, SWIG_FILE_DELIMITER, LangSubDir); Swig_add_directory(rl); } rl = NewString(""); Printf(rl, "%s%s%s", SwigLib, SWIG_FILE_DELIMITER, LangSubDir); Swig_add_directory(rl); } Swig_add_directory((String *) "." SWIG_FILE_DELIMITER "swig_lib"); if (SwigLibWinUnix) Swig_add_directory((String *) SwigLibWinUnix); Swig_add_directory(SwigLib); if (Verbose) { Printf(stdout, "Language subdirectory: %s\n", LangSubDir); Printf(stdout, "Search paths:\n"); List *sp = Swig_search_path(); Iterator s; for (s = First(sp); s.item; s = Next(s)) { Printf(stdout, " %s\n", s.item); } } // handle the -external-runtime argument if (external_runtime) SWIG_dump_runtime(); // If we made it this far, looks good. go for it.... input_file = NewString(argv[argc - 1]); Swig_filename_correct(input_file); // If the user has requested to check out a file, handle that if (checkout) { DOH *s; String *outfile = input_file; if (outfile_name) outfile = outfile_name; if (Verbose) Printf(stdout, "Handling checkout...\n"); s = Swig_include(input_file); if (!s) { Printf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file); } else { FILE *f = Swig_open(outfile); if (f) { fclose(f); Printf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile); } else { File *f_outfile = NewFile(outfile, "w", SWIG_output_files()); if (!f_outfile) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } else { if (Verbose) Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile); Printv(f_outfile, s, NIL); Delete(f_outfile); } } } } else { // Run the preprocessor if (Verbose) Printf(stdout, "Preprocessing...\n"); { int i; String *fs = NewString(""); FILE *df = Swig_open(input_file); if (!df) { df = Swig_include_open(input_file); if (!df) { char *cfile = Char(input_file); if (cfile && cfile[0] == '-') { Printf(stderr, "Unable to find option or file '%s', ", input_file); Printf(stderr, "use 'swig -help' for more information.\n"); } else { Printf(stderr, "Unable to find file '%s'.\n", input_file); } SWIG_exit(EXIT_FAILURE); } else { Swig_warning(WARN_DEPRECATED_INPUT_FILE, "SWIG", 1, "Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file.\n"); // so that behaviour is like c/c++ compilers } } if (!no_cpp) { fclose(df); Printf(fs, "%%include \n"); if (allkw) { Printf(fs, "%%include \n"); } if (lang_config) { Printf(fs, "\n%%include <%s>\n", lang_config); } Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_filename_escape(Swig_last_file())); for (i = 0; i < Len(libfiles); i++) { Printf(fs, "\n%%include \"%s\"\n", Swig_filename_escape(Getitem(libfiles, i))); } Seek(fs, 0, SEEK_SET); cpps = Preprocessor_parse(fs); Delete(fs); } else { cpps = Swig_read_file(df); fclose(df); } if (Swig_error_count()) { SWIG_exit(EXIT_FAILURE); } if (cpp_only) { Printf(stdout, "%s", cpps); SWIG_exit(EXIT_SUCCESS); } if (depend) { if (!no_cpp) { String *outfile; File *f_dependencies_file = 0; String *inputfile_filename = outcurrentdir ? Swig_file_filename(input_file): Copy(input_file); String *basename = Swig_file_basename(inputfile_filename); if (!outfile_name) { if (CPlusPlus || lang->cplus_runtime_mode()) { outfile = NewStringf("%s_wrap.%s", basename, cpp_extension); } else { outfile = NewStringf("%s_wrap.c", basename); } } else { outfile = NewString(outfile_name); } if (dependencies_file && Len(dependencies_file) != 0) { f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files()); if (!f_dependencies_file) { FileErrorDisplay(dependencies_file); SWIG_exit(EXIT_FAILURE); } } else if (!depend_only) { String *filename = NewStringf("%s_wrap.%s", basename, depends_extension); f_dependencies_file = NewFile(filename, "w", SWIG_output_files()); if (!f_dependencies_file) { FileErrorDisplay(filename); SWIG_exit(EXIT_FAILURE); } } else f_dependencies_file = stdout; if (dependencies_target) { Printf(f_dependencies_file, "%s: ", dependencies_target); } else { Printf(f_dependencies_file, "%s: ", outfile); } List *files = Preprocessor_depend(); List *phony_targets = NewList(); for (int i = 0; i < Len(files); i++) { int use_file = 1; if (depend == 2) { if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0))) use_file = 0; } if (use_file) { Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); if (depend_phony) Append(phony_targets, Getitem(files, i)); } } Printf(f_dependencies_file, "\n"); if (depend_phony) { for (int i = 0; i < Len(phony_targets); i++) { Printf(f_dependencies_file, "\n%s:\n", Getitem(phony_targets, i)); } } if (f_dependencies_file != stdout) Delete(f_dependencies_file); if (depend_only) SWIG_exit(EXIT_SUCCESS); Delete(inputfile_filename); Delete(basename); Delete(phony_targets); } else { Printf(stderr, "Cannot generate dependencies with -nopreprocess\n"); // Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse SWIG_exit(EXIT_FAILURE); } } Seek(cpps, 0, SEEK_SET); } /* Register a null file with the file handler */ Swig_register_filebyname("null", NewString("")); // Pass control over to the specific language interpreter if (Verbose) { fprintf(stdout, "Starting language-specific parse...\n"); fflush(stdout); } Node *top = Swig_cparse(cpps); if (dump_top & STAGE1) { Printf(stdout, "debug-top stage 1\n"); Swig_print_tree(top); } if (dump_module & STAGE1) { Printf(stdout, "debug-module stage 1\n"); Swig_print_tree(Getattr(top, "module")); } if (!CPlusPlus) { if (Verbose) Printf(stdout, "Processing unnamed structs...\n"); Swig_nested_name_unnamed_c_structs(top); } Swig_extend_unused_check(); if (Verbose) { Printf(stdout, "Processing types...\n"); } Swig_process_types(top); if (dump_top & STAGE2) { Printf(stdout, "debug-top stage 2\n"); Swig_print_tree(top); } if (dump_module & STAGE2) { Printf(stdout, "debug-module stage 2\n"); Swig_print_tree(Getattr(top, "module")); } if (Verbose) { Printf(stdout, "C++ analysis...\n"); } Swig_default_allocators(top); if (CPlusPlus) { if (Verbose) Printf(stdout, "Processing nested classes...\n"); Swig_nested_process_classes(top); } if (dump_top & STAGE3) { Printf(stdout, "debug-top stage 3\n"); Swig_print_tree(top); } if (dump_module & STAGE3) { Printf(stdout, "debug-module stage 3\n"); Swig_print_tree(Getattr(top, "module")); } if (Verbose) { Printf(stdout, "Generating wrappers...\n"); } if (dump_classes) { Hash *classes = Getattr(top, "classes"); if (classes) { Printf(stdout, "Classes\n"); Printf(stdout, "------------\n"); Iterator ki; for (ki = First(classes); ki.key; ki = Next(ki)) { Printf(stdout, "%s\n", ki.key); } } } if (dump_typedef) { SwigType_print_scope(); } if (dump_symtabs) { Swig_symbol_print_tables(Swig_symbol_global_scope()); Swig_symbol_print_tables_summary(); } if (dump_symbols) { Swig_symbol_print_symbols(); } if (dump_csymbols) { Swig_symbol_print_csymbols(); } if (dump_tags) { Swig_print_tags(top, 0); } if (top) { if (!Getattr(top, "name")) { Printf(stderr, "No module name specified using %%module or -module.\n"); SWIG_exit(EXIT_FAILURE); } else { /* Set some filename information on the object */ String *infile = scanner_get_main_input_file(); if (!infile) { Printf(stderr, "Missing input file in preprocessed output.\n"); SWIG_exit(EXIT_FAILURE); } Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file Setattr(top, "inputfile", input_file); String *infile_filename = outcurrentdir ? Swig_file_filename(infile): Copy(infile); String *basename = Swig_file_basename(infile_filename); if (!outfile_name) { if (CPlusPlus || lang->cplus_runtime_mode()) { Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension)); } else { Setattr(top, "outfile", NewStringf("%s_wrap.c", basename)); } } else { Setattr(top, "outfile", outfile_name); } if (!outfile_name_h) { Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", basename, hpp_extension)); } else { Setattr(top, "outfile_h", outfile_name_h); } configure_outdir(Getattr(top, "outfile")); if (Swig_contract_mode_get()) { Swig_contracts(top); } // Check the extension for a c/c++ file. If so, we're going to declare everything we see as "extern" ForceExtern = check_extension(input_file); lang->top(top); if (browse) { Swig_browser(top, 0); } Delete(infile_filename); Delete(basename); } } if (dump_lang_symbols) { lang->dumpSymbols(); } if (dump_top & STAGE4) { Printf(stdout, "debug-top stage 4\n"); Swig_print_tree(top); } if (dump_module & STAGE4) { Printf(stdout, "debug-module stage 4\n"); Swig_print_tree(Getattr(top, "module")); } if (dump_xml && top) { delete lang; lang = 0; Swig_print_xml(top, xmlout); } Delete(top); } if (tm_debug) Swig_typemap_debug(); if (memory_debug) DohMemoryDebug(); char *outfiles = getenv("CCACHE_OUTFILES"); if (outfiles) { File *f_outfiles = NewFile(outfiles, "w", 0); if (!f_outfiles) { Printf(stderr, "Failed to write list of output files to the filename '%s' specified in CCACHE_OUTFILES environment variable - ", outfiles); FileErrorDisplay(outfiles); SWIG_exit(EXIT_FAILURE); } else { int i; for (i = 0; i < Len(all_output_files); i++) Printf(f_outfiles, "%s\n", Getitem(all_output_files, i)); Delete(f_outfiles); } } // Deletes Delete(libfiles); Preprocessor_delete(); while (freeze) { } if ((werror) && (Swig_warn_count())) { return Swig_warn_count(); } delete lang; return Swig_error_count(); } /* ----------------------------------------------------------------------------- * SWIG_exit() * * Cleanup and either freeze or exit * ----------------------------------------------------------------------------- */ void SWIG_exit(int exit_code) { while (freeze) { } exit(exit_code); } swig-3.0.2/Source/Modules/pike.cxx0000664000175000017500000006476412343605122016710 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * pike.cxx * * Pike language module for SWIG. * ----------------------------------------------------------------------------- */ /* * Notes: * * - The current approach used for "out" typemaps is inconsistent with * how "out" typemaps are handled by other language modules. Instead * of converting the C/C++ type ($1) to a Pike object type (e.g. a * struct svalue), we're just calling the appropriate push_XXX * (e.g. push_int) to push the return value onto the stack. * * - Pike classes can't have static member functions or data, so we need * to find some other appropriate mapping for C++ static member functions * and data. * * - Pike doesn't seem to provide any default way to print the memory * address, etc. for extension objects. Should we do something here? * */ #include "swigmod.h" #include // for isalnum() static const char *usage = "\ Pike Options (available with -pike)\n\ [no additional options]\n\ \n"; class PIKE:public Language { private: File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; File *f_init; File *f_classInit; String *PrefixPlusUnderscore; int current; // Wrap modes enum { NO_CPP, MEMBER_FUNC, CONSTRUCTOR, DESTRUCTOR, MEMBER_VAR, CLASS_CONST, STATIC_FUNC, STATIC_VAR }; public: /* --------------------------------------------------------------------- * PIKE() * * Initialize member data * --------------------------------------------------------------------- */ PIKE() { f_begin = 0; f_runtime = 0; f_header = 0; f_wrappers = 0; f_init = 0; f_classInit = 0; PrefixPlusUnderscore = 0; current = NO_CPP; } /* --------------------------------------------------------------------- * main() * * Parse command line options and initializes variables. * --------------------------------------------------------------------- */ virtual void main(int argc, char *argv[]) { /* Set location of SWIG library */ SWIG_library_directory("pike"); /* Look for certain command line options */ for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); } } } /* Add a symbol to the parser for conditional compilation */ Preprocessor_define("SWIGPIKE 1", 0); /* Set language-specific configuration file */ SWIG_config_file("pike.swg"); /* Set typemap language */ SWIG_typemap_lang("pike"); /* Enable overloaded methods support */ allow_overloading(); } /* --------------------------------------------------------------------- * top() * --------------------------------------------------------------------- */ virtual int top(Node *n) { /* Get the module name */ String *module = Getattr(n, "name"); /* Get the output file name */ String *outfile = Getattr(n, "outfile"); /* Open the output file */ f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_classInit = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("classInit", f_classInit); /* Standard stuff for the SWIG runtime section */ Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPIKE\n"); Printf(f_runtime, "\n"); Printf(f_header, "#define SWIG_init pike_module_init\n"); Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); /* Change naming scheme for constructors and destructors */ Swig_name_register("construct", "%n%c_create"); Swig_name_register("destroy", "%n%c_destroy"); /* Current wrap type */ current = NO_CPP; /* Emit code for children */ Language::top(n); /* Close the initialization function */ Printf(f_init, "}\n"); SwigType_emit_type_table(f_runtime, f_wrappers); /* Close all of the files */ Dump(f_runtime, f_begin); Dump(f_header, f_begin); Dump(f_wrappers, f_begin); Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_classInit); Delete(f_runtime); Delete(f_begin); /* Done */ return SWIG_OK; } /* ------------------------------------------------------------ * validIdentifier() * ------------------------------------------------------------ */ virtual int validIdentifier(String *s) { char *c = Char(s); const char *c0 = c; const char *c1 = c0 + 1; while (*c) { if (*c == '`' && c == c0) { c++; continue; } if ((*c == '+' || *c == '-' || *c == '*' || *c == '/') && c == c1) { c++; continue; } if (!(isalnum(*c) || (*c == '_'))) return 0; c++; } return 1; } /* ------------------------------------------------------------ * importDirective() * ------------------------------------------------------------ */ virtual int importDirective(Node *n) { String *modname = Getattr(n, "module"); if (modname) { Printf(f_init, "pike_require(\"%s\");\n", modname); } return Language::importDirective(n); } /* ------------------------------------------------------------ * strip() * * For names that begin with the current class prefix plus an * underscore (e.g. "Foo_enum_test"), return the base function * name (i.e. "enum_test"). * ------------------------------------------------------------ */ String *strip(const DOHconst_String_or_char_ptr name) { String *s = Copy(name); if (Strncmp(name, PrefixPlusUnderscore, Len(PrefixPlusUnderscore)) != 0) { return s; } Replaceall(s, PrefixPlusUnderscore, ""); return s; } /* ------------------------------------------------------------ * add_method() * ------------------------------------------------------------ */ void add_method(const DOHconst_String_or_char_ptr name, const DOHconst_String_or_char_ptr function, const DOHconst_String_or_char_ptr description) { String *rename = NULL; switch (current) { case NO_CPP: rename = NewString(name); Printf(f_init, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description); break; case STATIC_FUNC: case STATIC_VAR: rename = NewString(name); Printf(f_init, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description); break; case CONSTRUCTOR: case DESTRUCTOR: case MEMBER_FUNC: case MEMBER_VAR: rename = strip(name); Printf(f_classInit, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description); break; case CLASS_CONST: assert(false); // shouldn't have gotten here for CLASS_CONST nodes default: assert(false); // what is this? } Delete(rename); } /* --------------------------------------------------------------------- * functionWrapper() * * Create a function declaration and register it with the interpreter. * --------------------------------------------------------------------- */ virtual int functionWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); Parm *p; String *tm; int i; String *overname = 0; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) return SWIG_ERROR; } Wrapper *f = NewWrapper(); // Emit all of the local variables for holding arguments. emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); /* Get number of required and total arguments */ int num_arguments = emit_num_arguments(l); int varargs = emit_isvarargs(l); /* Which input argument to start with? */ int start = (current == MEMBER_FUNC || current == MEMBER_VAR || current == DESTRUCTOR) ? 1 : 0; /* Offset to skip over the attribute name */ // int offset = (current == MEMBER_VAR) ? 1 : 0; int offset = 0; String *wname = Swig_name_wrapper(iname); if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); Printv(f->def, "static void ", wname, "(INT32 args) {", NIL); /* Generate code for argument marshalling */ String *description = NewString(""); char source[64]; for (i = 0, p = l; i < num_arguments; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); if (i < start) { String *lstr = SwigType_lstr(pt, 0); Printf(f->code, "%s = (%s) THIS;\n", ln, lstr); Delete(lstr); } else { /* Look for an input typemap */ sprintf(source, "Pike_sp[%d-args]", i - start + offset); if ((tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$source", source); Replaceall(tm, "$target", ln); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); Printf(f->code, "%s\n", tm); String *pikedesc = Getattr(p, "tmap:in:pikedesc"); if (pikedesc) { Printv(description, pikedesc, " ", NIL); } p = Getattr(p, "tmap:in:next"); continue; } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } } p = nextSibling(p); } /* Check for trailing varargs */ if (varargs) { if (p && (tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$input", "varargs"); Printv(f->code, tm, "\n", NIL); } } /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ String *cleanup = NewString(""); for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ String *outarg = NewString(""); for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } /* Emit the function call */ String *actioncode = emit_action(n); /* Clear the return stack */ Printf(actioncode, "pop_n_elems(args);\n"); /* Return the function value */ if (current == CONSTRUCTOR) { Printv(actioncode, "THIS = (void *) ", Swig_cresult_name(), ";\n", NIL); Printv(description, ", tVoid", NIL); } else if (current == DESTRUCTOR) { Printv(description, ", tVoid", NIL); } else { Printv(description, ", ", NIL); if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { actioncode = 0; Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "1"); } else { Replaceall(tm, "$owner", "0"); } String *pikedesc = Getattr(n, "tmap:out:pikedesc"); if (pikedesc) { Printv(description, pikedesc, NIL); } Printf(f->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); } } if (actioncode) { Append(f->code, actioncode); Delete(actioncode); } emit_return_variable(n, d, f); /* Output argument output code */ Printv(f->code, outarg, NIL); /* Output cleanup code */ Printv(f->code, cleanup, NIL); /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } /* Close the function */ Printf(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); /* Substitute the function name */ Replaceall(f->code, "$symname", iname); Replaceall(f->code, "$result", "resultobj"); /* Dump the function out */ Wrapper_print(f, f_wrappers); /* Now register the function with the interpreter. */ if (!Getattr(n, "sym:overloaded")) { add_method(iname, wname, description); } else { if (!Getattr(n, "sym:nextSibling")) { dispatchFunction(n); } } Delete(cleanup); Delete(outarg); Delete(description); Delete(wname); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * dispatchFunction() * * Emit overloading dispatch function * ------------------------------------------------------------ */ void dispatchFunction(Node *n) { /* Last node in overloaded chain */ int maxargs; String *tmp = NewString(""); String *dispatch = Swig_overload_dispatch(n, "%s(args); return;", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *f = NewWrapper(); String *symname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(symname); Printf(f->def, "static void %s(INT32 args) {", wname); Wrapper_add_local(f, "argc", "INT32 argc"); Printf(tmp, "struct svalue argv[%d]", maxargs); Wrapper_add_local(f, "argv", tmp); Wrapper_add_local(f, "ii", "INT32 ii"); Printf(f->code, "argc = args;\n"); Printf(f->code, "for (ii = 0; (ii < argc) && (ii < %d); ii++) {\n", maxargs); Printf(f->code, "argv[ii] = Pike_sp[ii-args];\n"); Printf(f->code, "}\n"); Replaceall(dispatch, "$args", "self, args"); Printv(f->code, dispatch, "\n", NIL); Printf(f->code, "Pike_error(\"No matching function for overloaded '%s'.\");\n", symname); Printv(f->code, "}\n", NIL); Wrapper_print(f, f_wrappers); String *description = NewString(""); Printf(description, "tAny,"); if (current == CONSTRUCTOR || current == DESTRUCTOR) { Printf(description, " tVoid"); } else { String *pd = Getattr(n, "tmap:out:pikedesc"); if (pd) Printf(description, " %s", pd); } add_method(symname, wname, description); Delete(description); DelWrapper(f); Delete(dispatch); Delete(tmp); Delete(wname); } /* ------------------------------------------------------------ * variableWrapper() * ------------------------------------------------------------ */ virtual int variableWrapper(Node *n) { return Language::variableWrapper(n); } /* ------------------------------------------------------------ * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { Swig_require("constantWrapper", n, "*sym:name", "type", "value", NIL); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *value = Getattr(n, "value"); bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); if (SwigType_type(type) == T_MPOINTER) { /* Special hook for member pointer */ String *wname = Swig_name_wrapper(symname); Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value); value = wname; } else if (SwigType_type(type) == T_CHAR && is_enum_item) { type = NewSwigType(T_INT); Setattr(n, "type", type); } /* Perform constant typemap substitution */ String *tm = Swig_typemap_lookup("constant", n, value, 0); if (tm) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", symname); Replaceall(tm, "$symname", symname); Replaceall(tm, "$value", value); Printf(f_init, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value %s = %s\n", SwigType_str(type, 0), value); } Swig_restore(n); return SWIG_OK; } /* ------------------------------------------------------------ * nativeWrapper() * ------------------------------------------------------------ */ virtual int nativeWrapper(Node *n) { // return Language::nativeWrapper(n); String *name = Getattr(n, "sym:name"); String *wrapname = Getattr(n, "wrap:name"); if (!addSymbol(wrapname, n)) return SWIG_ERROR; add_method(name, wrapname, 0); return SWIG_OK; } /* ------------------------------------------------------------ * enumDeclaration() * ------------------------------------------------------------ */ virtual int enumDeclaration(Node *n) { return Language::enumDeclaration(n); } /* ------------------------------------------------------------ * enumvalueDeclaration() * ------------------------------------------------------------ */ virtual int enumvalueDeclaration(Node *n) { return Language::enumvalueDeclaration(n); } /* ------------------------------------------------------------ * classDeclaration() * ------------------------------------------------------------ */ virtual int classDeclaration(Node *n) { return Language::classDeclaration(n); } /* ------------------------------------------------------------ * classHandler() * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { String *symname = Getattr(n, "sym:name"); if (!addSymbol(symname, n)) return SWIG_ERROR; PrefixPlusUnderscore = NewStringf("%s_", getClassPrefix()); Printf(f_classInit, "start_new_program();\n"); /* Handle inheritance */ List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist) > 0) { Iterator base = First(baselist); while (base.item) { String *basename = Getattr(base.item, "name"); SwigType *basetype = NewString(basename); SwigType_add_pointer(basetype); SwigType_remember(basetype); String *basemangle = SwigType_manglestr(basetype); Printf(f_classInit, "low_inherit((struct program *) SWIGTYPE%s->clientdata, 0, 0, 0, 0, 0);\n", basemangle); Delete(basemangle); Delete(basetype); base = Next(base); } } else { Printf(f_classInit, "ADD_STORAGE(swig_object_wrapper);\n"); } Language::classHandler(n); /* Accessors for member variables */ /* List *membervariables = Getattr(n,"membervariables"); if (membervariables && Len(membervariables) > 0) { membervariableAccessors(membervariables); } */ /* Done, close the class and dump its definition to the init function */ Printf(f_classInit, "add_program_constant(\"%s\", pr = end_program(), 0);\n", symname); Dump(f_classInit, f_init); Clear(f_classInit); SwigType *tt = NewString(symname); SwigType_add_pointer(tt); SwigType_remember(tt); String *tm = SwigType_manglestr(tt); Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) pr);\n", tm); Delete(tm); Delete(tt); Delete(PrefixPlusUnderscore); PrefixPlusUnderscore = 0; return SWIG_OK; } /* ------------------------------------------------------------ * memberfunctionHandler() * * Method for adding C++ member function * ------------------------------------------------------------ */ virtual int memberfunctionHandler(Node *n) { current = MEMBER_FUNC; Language::memberfunctionHandler(n); current = NO_CPP; return SWIG_OK; } /* ------------------------------------------------------------ * constructorHandler() * * Method for adding C++ member constructor * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { current = CONSTRUCTOR; Language::constructorHandler(n); current = NO_CPP; return SWIG_OK; } /* ------------------------------------------------------------ * destructorHandler() * ------------------------------------------------------------ */ virtual int destructorHandler(Node *n) { current = DESTRUCTOR; Language::destructorHandler(n); current = NO_CPP; return SWIG_OK; } /* ------------------------------------------------------------ * membervariableAccessors() * ------------------------------------------------------------ */ void membervariableAccessors(List *membervariables) { String *name; Iterator i; bool need_setter; String *funcname; /* If at least one of them is mutable, we need a setter */ need_setter = false; i = First(membervariables); while (i.item) { if (!GetFlag(i.item, "feature:immutable")) { need_setter = true; break; } i = Next(i); } /* Create a function to set the values of the (mutable) variables */ if (need_setter) { Wrapper *wrapper = NewWrapper(); String *setter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->="); String *wname = Swig_name_wrapper(setter); Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); i = First(membervariables); while (i.item) { if (!GetFlag(i.item, "feature:immutable")) { name = Getattr(i.item, "name"); funcname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name))); Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name); Printf(wrapper->code, "%s(args);\n", funcname); Printf(wrapper->code, "return;\n"); Printf(wrapper->code, "}\n"); Delete(funcname); } i = Next(i); } /* Close the function */ Printf(wrapper->code, "pop_n_elems(args);\n"); Printf(wrapper->code, "}\n"); /* Dump wrapper code to the output file */ Wrapper_print(wrapper, f_wrappers); /* Register it with Pike */ String *description = NewString("tStr tFloat, tVoid"); add_method("`->=", wname, description); Delete(description); /* Clean up */ Delete(wname); Delete(setter); DelWrapper(wrapper); } /* Create a function to get the values of the (mutable) variables */ Wrapper *wrapper = NewWrapper(); String *getter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->"); String *wname = Swig_name_wrapper(getter); Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); i = First(membervariables); while (i.item) { name = Getattr(i.item, "name"); funcname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name))); Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name); Printf(wrapper->code, "%s(args);\n", funcname); Printf(wrapper->code, "return;\n"); Printf(wrapper->code, "}\n"); Delete(funcname); i = Next(i); } /* Close the function */ Printf(wrapper->code, "pop_n_elems(args);\n"); Printf(wrapper->code, "}\n"); /* Dump wrapper code to the output file */ Wrapper_print(wrapper, f_wrappers); /* Register it with Pike */ String *description = NewString("tStr, tMix"); add_method("`->", wname, description); Delete(description); /* Clean up */ Delete(wname); Delete(getter); DelWrapper(wrapper); } /* ------------------------------------------------------------ * membervariableHandler() * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { List *membervariables = Getattr(getCurrentClass(), "membervariables"); if (!membervariables) { membervariables = NewList(); Setattr(getCurrentClass(), "membervariables", membervariables); } Append(membervariables, n); current = MEMBER_VAR; Language::membervariableHandler(n); current = NO_CPP; return SWIG_OK; } /* ----------------------------------------------------------------------- * staticmemberfunctionHandler() * * Wrap a static C++ function * ---------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { current = STATIC_FUNC; Language::staticmemberfunctionHandler(n); current = NO_CPP; return SWIG_OK; } /* ------------------------------------------------------------ * memberconstantHandler() * * Create a C++ constant * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { current = CLASS_CONST; constantWrapper(n); current = NO_CPP; return SWIG_OK; } /* --------------------------------------------------------------------- * staticmembervariableHandler() * --------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { current = STATIC_VAR; Language::staticmembervariableHandler(n); current = NO_CPP; return SWIG_OK; } }; /* ----------------------------------------------------------------------------- * swig_pike() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_pike() { return new PIKE(); } extern "C" Language *swig_pike(void) { return new_swig_pike(); } swig-3.0.2/Source/Modules/go.cxx0000664000175000017500000044300212343605122016347 0ustar williamwilliam/* ----------------------------------------------------------------------------- * See the LICENSE file for information on copyright, usage and redistribution * of SWIG, and the README file for authors - http://www.swig.org/release.html. * * go.cxx * * Go language module for SWIG. * ----------------------------------------------------------------------------- */ #include "swigmod.h" #include "cparse.h" #include class GO:public Language { static const char *const usage; // Go package name. String *package; // SWIG module name. String *module; // Flag for generating gccgo output. bool gccgo_flag; // Prefix to use with gccgo. String *go_prefix; // -fgo-prefix option. String *prefix_option; // -fgo-pkgpath option. String *pkgpath_option; // Whether to use a shared library. bool use_shlib; // Name of shared library to import. String *soname; // Size in bits of the Go type "int". 0 if not specified. int intgo_type_size; /* Output files */ File *f_c_begin; File *f_go_begin; File *f_gc_begin; /* Output fragments */ File *f_c_runtime; File *f_c_header; File *f_c_wrappers; File *f_c_init; File *f_c_directors; File *f_c_directors_h; File *f_go_imports; File *f_go_runtime; File *f_go_header; File *f_go_wrappers; File *f_gc_runtime; File *f_gc_header; File *f_gc_wrappers; // True if we imported a module. bool saw_import; // If not NULL, name of import package being processed. String *imported_package; // Build interface methods while handling a class. This is only // non-NULL when we are handling methods. String *interfaces; // The class node while handling a class. This is only non-NULL // when we are handling methods. Node *class_node; // The class name while handling a class. This is only non-NULL // when we are handling methods. This is the name of the class as // SWIG sees it. String *class_name; // The receiver name while handling a class. This is only non-NULL // when we are handling methods. This is the name of the class // as run through goCPointerType. String *class_receiver; // A hash table of method names that we have seen when processing a // class. This lets us detect base class methods that we don't want // to use. Hash *class_methods; // True when we are generating the wrapper functions for a variable. bool making_variable_wrappers; // True when working with a static member function. bool is_static_member_function; // A hash table of enum types that we have seen but which may not have // been defined. The index is a SwigType. Hash *undefined_enum_types; // A hash table of types that we have seen but which may not have // been defined. The index is a SwigType. Hash *undefined_types; // A hash table of classes which were defined. The index is a Go // type name. Hash *defined_types; // A hash table of all the go_imports already imported. The index is a full // import name e.g. '"runtime"' or '_ "runtime/cgo"' or 'sc "syscall"'. Hash *go_imports; public: GO():package(NULL), module(NULL), gccgo_flag(false), go_prefix(NULL), prefix_option(NULL), pkgpath_option(NULL), use_shlib(false), soname(NULL), intgo_type_size(0), f_c_begin(NULL), f_go_begin(NULL), f_gc_begin(NULL), f_c_runtime(NULL), f_c_header(NULL), f_c_wrappers(NULL), f_c_init(NULL), f_c_directors(NULL), f_c_directors_h(NULL), f_go_imports(NULL), f_go_runtime(NULL), f_go_header(NULL), f_go_wrappers(NULL), f_gc_runtime(NULL), f_gc_header(NULL), f_gc_wrappers(NULL), saw_import(false), imported_package(NULL), interfaces(NULL), class_node(NULL), class_name(NULL), class_receiver(NULL), class_methods(NULL), making_variable_wrappers(false), is_static_member_function(false), undefined_enum_types(NULL), undefined_types(NULL), defined_types(NULL), go_imports(NULL) { director_multiple_inheritance = 1; director_language = 1; director_prot_ctor_code = NewString("_swig_gopanic(\"accessing abstract class or protected constructor\");"); } private: /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { SWIG_library_directory("go"); bool display_help = false; // Process command line options. for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-package") == 0) { if (argv[i + 1]) { package = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-gccgo") == 0) { Swig_mark_arg(i); gccgo_flag = true; } else if (strcmp(argv[i], "-go-prefix") == 0) { if (argv[i + 1]) { prefix_option = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-go-pkgpath") == 0) { if (argv[i + 1]) { pkgpath_option = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-use-shlib") == 0) { Swig_mark_arg(i); use_shlib = true; } else if (strcmp(argv[i], "-soname") == 0) { if (argv[i + 1]) { soname = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-longsize") == 0) { // Ignore for backward compatibility. if (argv[i + 1]) { Swig_mark_arg(i); Swig_mark_arg(i + 1); ++i; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-intgosize") == 0) { if (argv[i + 1]) { intgo_type_size = atoi(argv[i + 1]); if (intgo_type_size != 32 && intgo_type_size != 64) { Printf(stderr, "-intgosize not 32 or 64\n"); Swig_arg_error(); } Swig_mark_arg(i); Swig_mark_arg(i + 1); ++i; } else { Swig_arg_error(); } } else if (strcmp(argv[i], "-help") == 0) { display_help = true; Printf(stdout, "%s\n", usage); } } } if (gccgo_flag && !pkgpath_option && !prefix_option) { prefix_option = NewString("go"); } // Add preprocessor symbol to parser. Preprocessor_define("SWIGGO 1", 0); if (gccgo_flag) { Preprocessor_define("SWIGGO_GCCGO 1", 0); } // This test may be removed in the future, when we can assume that // everybody has upgraded to Go 1.1. The code below is prepared // for this test to simply be taken out. if (intgo_type_size == 0 && !display_help) { Printf(stderr, "SWIG -go: -intgosize option required but not specified\n"); SWIG_exit(EXIT_FAILURE); } if (intgo_type_size == 32) { Preprocessor_define("SWIGGO_INTGO_SIZE 32", 0); } else if (intgo_type_size == 64) { Preprocessor_define("SWIGGO_INTGO_SIZE 64", 0); } else { Preprocessor_define("SWIGGO_INTGO_SIZE 0", 0); } // Add typemap definitions. SWIG_typemap_lang("go"); SWIG_config_file("go.swg"); allow_overloading(); } /* --------------------------------------------------------------------- * top() * * For 6g/8g, we are going to create the following files: * * 1) A .c or .cxx file compiled with gcc. This file will contain * function wrappers. Each wrapper will take a pointer to a * struct holding the arguments, unpack them, and call the real * function. * * 2) A .go file which defines the Go form of all types, and which * defines Go function wrappers. Each wrapper will call the C * function wrapper in the second file. * * 3) A .c file compiled with 6c/8c. This file will define * Go-callable C function wrappers. Each wrapper will use * cgocall to call the function wrappers in the first file. * * When generating code for gccgo, we don't need the third file, and * the function wrappers in the first file have a different form. * * --------------------------------------------------------------------- */ virtual int top(Node *n) { Node *optionsnode = Getattr(Getattr(n, "module"), "options"); if (optionsnode) { if (Getattr(optionsnode, "directors")) { allow_directors(); } if (Getattr(optionsnode, "dirprot")) { allow_dirprot(); } allow_allprotected(GetFlag(optionsnode, "allprotected")); } module = Getattr(n, "name"); if (!package) { package = Copy(module); } if (!soname && use_shlib) { soname = Copy(package); Append(soname, ".so"); } if (gccgo_flag) { String *pref; if (pkgpath_option) { pref = pkgpath_option; } else { pref = prefix_option; } go_prefix = NewString(""); for (char *p = Char(pref); *p != '\0'; p++) { if ((*p >= 'A' && *p <= 'Z') || (*p >= 'a' && *p <= 'z') || (*p >= '0' && *p <= '9') || *p == '.' || *p == '$') { Putc(*p, go_prefix); } else { Putc('_', go_prefix); } } if (!pkgpath_option) { Append(go_prefix, "."); Append(go_prefix, package); } } // Get filenames. String *swig_filename = Getattr(n, "infile"); String *c_filename = Getattr(n, "outfile"); String *c_filename_h = Getattr(n, "outfile_h"); String *go_filename = NewString(""); Printf(go_filename, "%s%s.go", SWIG_output_directory(), module); String *gc_filename = NULL; if (!gccgo_flag) { gc_filename = NewString(""); Printf(gc_filename, "%s%s_gc.c", SWIG_output_directory(), module); } // Open files. f_c_begin = NewFile(c_filename, "w", SWIG_output_files()); if (!f_c_begin) { FileErrorDisplay(c_filename); SWIG_exit(EXIT_FAILURE); } if (directorsEnabled()) { if (!c_filename_h) { Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } f_c_directors_h = NewFile(c_filename_h, "w", SWIG_output_files()); if (!f_c_directors_h) { FileErrorDisplay(c_filename_h); SWIG_exit(EXIT_FAILURE); } } f_go_begin = NewFile(go_filename, "w", SWIG_output_files()); if (!f_go_begin) { FileErrorDisplay(go_filename); SWIG_exit(EXIT_FAILURE); } if (!gccgo_flag) { f_gc_begin = NewFile(gc_filename, "w", SWIG_output_files()); if (!f_gc_begin) { FileErrorDisplay(gc_filename); SWIG_exit(EXIT_FAILURE); } } f_c_runtime = NewString(""); f_c_header = NewString(""); f_c_wrappers = NewString(""); f_c_init = NewString(""); f_c_directors = NewString(""); f_go_imports = NewString(""); f_go_runtime = NewString(""); f_go_header = NewString(""); f_go_wrappers = NewString(""); if (!gccgo_flag) { f_gc_runtime = NewString(""); f_gc_header = NewString(""); f_gc_wrappers = NewString(""); } Swig_register_filebyname("begin", f_c_begin); Swig_register_filebyname("runtime", f_c_runtime); Swig_register_filebyname("header", f_c_header); Swig_register_filebyname("wrapper", f_c_wrappers); Swig_register_filebyname("init", f_c_init); Swig_register_filebyname("director", f_c_directors); Swig_register_filebyname("director_h", f_c_directors_h); Swig_register_filebyname("go_begin", f_go_begin); Swig_register_filebyname("go_imports", f_go_imports); Swig_register_filebyname("go_runtime", f_go_runtime); Swig_register_filebyname("go_header", f_go_header); Swig_register_filebyname("go_wrapper", f_go_wrappers); if (!gccgo_flag) { Swig_register_filebyname("gc_begin", f_gc_begin); Swig_register_filebyname("gc_runtime", f_gc_runtime); Swig_register_filebyname("gc_header", f_gc_header); Swig_register_filebyname("gc_wrapper", f_gc_wrappers); } Swig_banner(f_c_begin); if (CPlusPlus) { Printf(f_c_begin, "\n// source: %s\n\n", swig_filename); } else { Printf(f_c_begin, "\n/* source: %s */\n\n", swig_filename); } Printf(f_c_runtime, "#define SWIGMODULE %s\n", module); if (gccgo_flag) { Printf(f_c_runtime, "#define SWIGGO_PREFIX %s\n", go_prefix); } if (directorsEnabled()) { Printf(f_c_runtime, "#define SWIG_DIRECTORS\n"); Swig_banner(f_c_directors_h); Printf(f_c_directors_h, "\n// source: %s\n\n", swig_filename); Printf(f_c_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module); Printf(f_c_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module); Printf(f_c_directors, "\n// C++ director class methods.\n"); String *filename = Swig_file_filename(c_filename_h); Printf(f_c_directors, "#include \"%s\"\n\n", filename); Delete(filename); } Swig_banner(f_go_begin); Printf(f_go_begin, "\n// source: %s\n", swig_filename); if (!gccgo_flag && soname) { Swig_banner(f_gc_begin); Printf(f_gc_begin, "\n/* source: %s */\n\n", swig_filename); Printf(f_gc_begin, "\n/* This file should be compiled with 6c/8c. */\n"); Printf(f_gc_begin, "#pragma dynimport _ _ \"%s\"\n", soname); } // Output module initialization code. Printf(f_go_begin, "\npackage %s\n\n", package); if (gccgo_flag) { Printf(f_go_runtime, "func SwigCgocall()\n"); Printf(f_go_runtime, "func SwigCgocallDone()\n"); Printf(f_go_runtime, "func SwigCgocallBack()\n"); Printf(f_go_runtime, "func SwigCgocallBackDone()\n\n"); } // All the C++ wrappers should be extern "C". Printv(f_c_wrappers, "#ifdef __cplusplus\n", "extern \"C\" {\n", "#endif\n\n", NULL); // Set up the hash table for types not defined by SWIG. undefined_enum_types = NewHash(); undefined_types = NewHash(); defined_types = NewHash(); go_imports = NewHash(); // Emit code. Language::top(n); Delete(go_imports); // Write out definitions for the types not defined by SWIG. if (Len(undefined_enum_types) > 0) Printv(f_go_wrappers, "\n", NULL); for (Iterator p = First(undefined_enum_types); p.key; p = Next(p)) { String *name = p.item; Printv(f_go_wrappers, "type ", name, " int\n", NULL); } Printv(f_go_wrappers, "\n", NULL); for (Iterator p = First(undefined_types); p.key; p = Next(p)) { String *ty = goType(NULL, p.key); if (!Getattr(defined_types, ty)) { String *cp = goCPointerType(p.key, false); if (!Getattr(defined_types, cp)) { Printv(f_go_wrappers, "type ", cp, " uintptr\n", NULL); Printv(f_go_wrappers, "type ", ty, " interface {\n", NULL); Printv(f_go_wrappers, "\tSwigcptr() uintptr;\n", NULL); Printv(f_go_wrappers, "}\n", NULL); Printv(f_go_wrappers, "func (p ", cp, ") Swigcptr() uintptr {\n", NULL); Printv(f_go_wrappers, "\treturn uintptr(p)\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); } Delete(cp); } Delete(ty); } Delete(undefined_enum_types); Delete(undefined_types); Delete(defined_types); /* Write and cleanup */ Dump(f_c_header, f_c_runtime); if (directorsEnabled()) { Printf(f_c_directors_h, "#endif\n"); Delete(f_c_directors_h); f_c_directors_h = NULL; Dump(f_c_directors, f_c_runtime); Delete(f_c_directors); f_c_directors = NULL; } // End the extern "C". Printv(f_c_wrappers, "#ifdef __cplusplus\n", "}\n", "#endif\n\n", NULL); Dump(f_c_runtime, f_c_begin); Dump(f_c_wrappers, f_c_begin); Dump(f_c_init, f_c_begin); Dump(f_go_imports, f_go_begin); Dump(f_go_header, f_go_begin); Dump(f_go_runtime, f_go_begin); Dump(f_go_wrappers, f_go_begin); if (!gccgo_flag) { Dump(f_gc_header, f_gc_begin); Dump(f_gc_runtime, f_gc_begin); Dump(f_gc_wrappers, f_gc_begin); } Delete(f_c_runtime); Delete(f_c_header); Delete(f_c_wrappers); Delete(f_c_init); Delete(f_go_imports); Delete(f_go_runtime); Delete(f_go_header); Delete(f_go_wrappers); if (!gccgo_flag) { Delete(f_gc_runtime); Delete(f_gc_header); Delete(f_gc_wrappers); } Delete(f_c_begin); Delete(f_go_begin); if (!gccgo_flag) { Delete(f_gc_begin); } return SWIG_OK; } /* ------------------------------------------------------------ * importDirective() * * Handle a SWIG import statement by generating a Go import * statement. * ------------------------------------------------------------ */ virtual int importDirective(Node *n) { String *hold_import = imported_package; String *modname = Getattr(n, "module"); if (modname) { if (!Getattr(go_imports, modname)) { Setattr(go_imports, modname, modname); Printv(f_go_imports, "import \"", modname, "\"\n", NULL); } imported_package = modname; saw_import = true; } int r = Language::importDirective(n); imported_package = hold_import; return r; } /* ---------------------------------------------------------------------- * Language::insertDirective() * * If the section is go_imports, store them for later. * ---------------------------------------------------------------------- */ virtual int insertDirective(Node *n) { char *section = Char(Getattr(n, "section")); if ((ImportMode && !Getattr(n, "generated")) || !section || (strcmp(section, "go_imports") != 0)) { return Language::insertDirective(n); } char *code = Char(Getattr(n, "code")); char *pch = strtok(code, ","); while (pch != NULL) { // Do not import same thing more than once. if (!Getattr(go_imports, pch)) { Setattr(go_imports, pch, pch); Printv(f_go_imports, "import ", pch, "\n", NULL); } pch = strtok(NULL, ","); } return SWIG_OK; } /* ---------------------------------------------------------------------- * functionWrapper() * * Implement a function. * ---------------------------------------------------------------------- */ virtual int functionWrapper(Node *n) { if (GetFlag(n, "feature:ignore")) { return SWIG_OK; } // We don't need explicit calls. if (GetFlag(n, "explicitcall")) { return SWIG_OK; } String *name = Getattr(n, "sym:name"); String *nodetype = Getattr(n, "nodeType"); bool is_static = is_static_member_function || isStatic(n); bool is_friend = isFriend(n); bool is_ctor_dtor = false; SwigType *result = Getattr(n, "type"); // For some reason SWIG changs the "type" value during the call to // functionWrapper. We need to remember the type for possible // overload processing. Setattr(n, "go:type", Copy(result)); String *go_name; String *r1 = NULL; if (making_variable_wrappers) { // Change the name of the variable setter and getter functions // to be more Go like. bool is_set = Strcmp(Char(name) + Len(name) - 4, "_set") == 0; assert(is_set || Strcmp(Char(name) + Len(name) - 4, "_get") == 0); // Start with Set or Get. go_name = NewString(is_set ? "Set" : "Get"); // If this is a static variable, put in the class name, // capitalized. if (is_static && class_name) { String *ccn = exportedName(class_name); Append(go_name, ccn); Delete(ccn); } // Add the rest of the name, capitalized, dropping the _set or // _get. String *c1 = removeClassname(name); String *c2 = exportedName(c1); char *p = Char(c2); int len = Len(p); for (int i = 0; i < len - 4; ++i) { Putc(p[i], go_name); } Delete(c2); Delete(c1); if (!checkIgnoredParameters(n, go_name)) { Delete(go_name); return SWIG_NOWRAP; } } else if (Cmp(nodetype, "constructor") == 0) { is_ctor_dtor = true; // Change the name of a constructor to be more Go like. Change // new_ to New, and capitalize the class name. assert(Strncmp(name, "new_", 4) == 0); String *c1 = NewString(Char(name) + 4); String *c2 = exportedName(c1); go_name = NewString("New"); Append(go_name, c2); Delete(c2); Delete(c1); if (Swig_methodclass(n) && Swig_directorclass(n) && Strcmp(Char(Getattr(n, "wrap:action")), director_prot_ctor_code) != 0) { // The core SWIG code skips the first parameter when // generating the $nondirector_new string. Recreate the // action in this case. But don't it if we are using the // special code for an abstract class. String *call = Swig_cppconstructor_call(getClassType(), Getattr(n, "parms")); SwigType *type = Copy(getClassType()); SwigType_add_pointer(type); String *cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); } } else if (Cmp(nodetype, "destructor") == 0) { // No need to emit protected destructors. if (!is_public(n)) { return SWIG_OK; } is_ctor_dtor = true; // Change the name of a destructor to be more Go like. Change // delete_ to Delete and capitalize the class name. assert(Strncmp(name, "delete_", 7) == 0); String *c1 = NewString(Char(name) + 7); String *c2 = exportedName(c1); go_name = NewString("Delete"); Append(go_name, c2); Delete(c2); Delete(c1); result = NewString("void"); r1 = result; } else { if (!checkFunctionVisibility(n, NULL)) { return SWIG_OK; } go_name = buildGoName(name, is_static, is_friend); if (!checkIgnoredParameters(n, go_name)) { Delete(go_name); return SWIG_NOWRAP; } } String *overname = NULL; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { String *scope; if (!class_name || is_static || is_ctor_dtor) { scope = NULL; } else { scope = NewString("swiggoscope."); Append(scope, class_name); } if (!checkNameConflict(go_name, n, scope)) { Delete(go_name); return SWIG_NOWRAP; } } String *wname = Swig_name_wrapper(name); if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); ParmList *parms = Getattr(n, "parms"); Setattr(n, "wrap:parms", parms); int r = makeWrappers(n, name, go_name, overname, wname, NULL, parms, result, is_static); if (r != SWIG_OK) { return r; } if (Getattr(n, "sym:overloaded") && !Getattr(n, "sym:nextSibling")) { String *scope ; if (!class_name || is_static || is_ctor_dtor) { scope = NULL; } else { scope = NewString("swiggoscope."); Append(scope, class_name); } if (!checkNameConflict(go_name, n, scope)) { Delete(go_name); return SWIG_NOWRAP; } String *receiver = class_receiver; if (is_static || is_ctor_dtor) { receiver = NULL; } r = makeDispatchFunction(n, go_name, receiver, is_static, NULL, false); if (r != SWIG_OK) { return r; } } Delete(wname); Delete(go_name); Delete(r1); return SWIG_OK; } /* ---------------------------------------------------------------------- * staticmemberfunctionHandler() * * For some reason the language code removes the "storage" attribute * for a static function before calling functionWrapper, which means * that we have no way of knowing whether a function is static or * not. That makes no sense in the Go context. Here we note that a * function is static. * ---------------------------------------------------------------------- */ int staticmemberfunctionHandler(Node *n) { assert(!is_static_member_function); is_static_member_function = true; int r = Language::staticmemberfunctionHandler(n); is_static_member_function = false; return r; } /* ---------------------------------------------------------------------- * makeWrappers() * * Write out the various function wrappers. * n: The function we are emitting. * name: The function name. * go_name: The name of the function in Go. * overname: The overload string for overloaded function. * wname: The SWIG wrapped name--the name of the C function. * base: A list of the names of base classes, in the case where this * is is a vritual method not defined in the current class. * parms: The parameters. * result: The result type. * is_static: Whether this is a static method or member. * ---------------------------------------------------------------------- */ int makeWrappers(Node *n, String *name, String *go_name, String *overname, String *wname, List *base, ParmList *parms, SwigType *result, bool is_static) { assert(result); bool needs_wrapper; int r = goFunctionWrapper(n, name, go_name, overname, wname, base, parms, result, is_static, &needs_wrapper); if (r != SWIG_OK) { return r; } if (!gccgo_flag) { r = gcFunctionWrapper(n, name, go_name, overname, wname, parms, result, is_static, needs_wrapper); if (r != SWIG_OK) { return r; } r = gccFunctionWrapper(n, base, wname, parms, result); if (r != SWIG_OK) { return r; } } else { r = gccgoFunctionWrapper(n, base, wname, parms, result); if (r != SWIG_OK) { return r; } } if (class_methods) { Setattr(class_methods, Getattr(n, "name"), NewString("")); } return SWIG_OK; } /* ---------------------------------------------------------------------- * goFunctionWrapper() * * Write out a function wrapper in Go. When not implementing a * method, the actual code is all in C; here we just declare the C * function. When implementing a method, we have to call the C * function, because it will have a different name. If base is not * NULL, then we are being called to forward a virtual method to a * base class. * ---------------------------------------------------------------------- */ int goFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, List *base, ParmList *parms, SwigType *result, bool is_static, bool *p_needs_wrapper) { Wrapper *dummy = NewWrapper(); emit_attach_parmmaps(parms, dummy); Swig_typemap_attach_parms("default", parms, dummy); Swig_typemap_attach_parms("gotype", parms, dummy); int parm_count = emit_num_arguments(parms); int required_count = emit_num_required(parms); String *receiver = class_receiver; if (receiver && is_static) { receiver = NULL; } String *nodetype = Getattr(n, "nodeType"); bool is_constructor = Cmp(nodetype, "constructor") == 0; bool is_destructor = Cmp(nodetype, "destructor") == 0; if (is_constructor || is_destructor) { assert(class_receiver); assert(!base); receiver = NULL; } bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !overname && checkFunctionVisibility(n, NULL)); bool needs_wrapper = (gccgo_flag || receiver || is_constructor || is_destructor || parm_count > required_count); // See whether any of the function parameters are represented by // interface values When calling the C++ code, we need to convert // back to a uintptr. if (!needs_wrapper) { Parm *p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); String *ty = Getattr(p, "type"); if (goTypeIsInterface(p, ty)) { needs_wrapper = true; break; } p = nextParm(p); } } if (goTypeIsInterface(n, result)) { needs_wrapper = true; } *p_needs_wrapper = needs_wrapper; // If this is a method, first declare the C function we will call. // If we do not need a wrapper, then we will only be writing a // declaration. String *wrapper_name = NULL; if (needs_wrapper) { wrapper_name = buildGoWrapperName(name, overname); if (gccgo_flag) { Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL); } Printv(f_go_wrappers, "func ", wrapper_name, "(", NULL); if (parm_count > required_count) { Printv(f_go_wrappers, "int", NULL); } Parm *p = getParm(parms); Swig_cparm_name(p, 0); int i = 0; if (is_destructor) { if (parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } Printv(f_go_wrappers, "uintptr", NULL); ++i; p = nextParm(p); } else if (receiver && (base || !is_constructor)) { if (parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } Printv(f_go_wrappers, receiver, NULL); if (!base) { ++i; p = nextParm(p); } } for (; i < parm_count; ++i) { p = getParm(p); // Give the parameter a name we will use below. Swig_cparm_name(p, i); if (i > 0 || (base && receiver) || parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } String *tm = goWrapperType(p, Getattr(p, "type"), false); Printv(f_go_wrappers, tm, NULL); Delete(tm); p = nextParm(p); } Printv(f_go_wrappers, ")", NULL); if (is_constructor) { Printv(f_go_wrappers, " ", class_receiver, NULL); } else { if (SwigType_type(result) != T_VOID) { String *tm = goWrapperType(n, result, true); Printv(f_go_wrappers, " ", tm, NULL); Delete(tm); } } Printv(f_go_wrappers, "\n\n", NULL); } // Start defining the Go function. if (!needs_wrapper && gccgo_flag) { Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL); } Printv(f_go_wrappers, "func ", NULL); Parm *p = parms; int pi = 0; // Add the receiver if this is a method. if (receiver) { Printv(f_go_wrappers, "(", NULL); if (base && receiver) { Printv(f_go_wrappers, "_swig_base", NULL); } else { Printv(f_go_wrappers, Getattr(p, "lname"), NULL); p = nextParm(p); ++pi; } Printv(f_go_wrappers, " ", receiver, ") ", NULL); } Printv(f_go_wrappers, go_name, NULL); if (overname) { Printv(f_go_wrappers, overname, NULL); } Printv(f_go_wrappers, "(", NULL); // If we are doing methods, add this function to the interface. if (add_to_interface) { Printv(interfaces, "\t", go_name, "(", NULL); } // Write out the parameters to both the function definition and // the interface. String *parm_print = NewString(""); for (; pi < parm_count; ++pi) { p = getParm(p); if (pi == 0 && is_destructor) { String *cl = exportedName(class_name); Printv(parm_print, Getattr(p, "lname"), " ", cl, NULL); Delete(cl); } else { if (pi > (receiver && !base ? 1 : 0)) { Printv(parm_print, ", ", NULL); } if (pi >= required_count) { Printv(parm_print, "_swig_args ...interface{}", NULL); break; } if (needs_wrapper) { Printv(parm_print, Getattr(p, "lname"), " ", NULL); } String *tm = goType(p, Getattr(p, "type")); Printv(parm_print, tm, NULL); Delete(tm); } p = nextParm(p); } Printv(parm_print, ")", NULL); // Write out the result type. if (is_constructor) { String *cl = exportedName(class_name); Printv(parm_print, " ", cl, NULL); Delete(cl); } else { if (SwigType_type(result) != T_VOID) { String *tm = goType(n, result); Printv(parm_print, " ", tm, NULL); Delete(tm); } } Printv(f_go_wrappers, parm_print, NULL); if (add_to_interface) { Printv(interfaces, parm_print, "\n", NULL); } // If this is a wrapper, we need to actually call the C function. if (needs_wrapper) { Printv(f_go_wrappers, " {\n", NULL); if (parm_count > required_count) { Parm *p = parms; int i; for (i = 0; i < required_count; ++i) { p = getParm(p); p = nextParm(p); } for (; i < parm_count; ++i) { p = getParm(p); String *tm = goType(p, Getattr(p, "type")); Printv(f_go_wrappers, "\tvar ", Getattr(p, "lname"), " ", tm, "\n", NULL); Printf(f_go_wrappers, "\tif len(_swig_args) > %d {\n", i - required_count); Printf(f_go_wrappers, "\t\t%s = _swig_args[%d].(%s)\n", Getattr(p, "lname"), i - required_count, tm); Printv(f_go_wrappers, "\t}\n", NULL); Delete(tm); p = nextParm(p); } } if (gccgo_flag) { if (!is_constructor) { Printv(f_go_wrappers, "\tdefer SwigCgocallDone()\n", NULL); Printv(f_go_wrappers, "\tSwigCgocall()\n", NULL); } else { // For a constructor the wrapper function will return a // uintptr but we will return an interface. We want to // convert the uintptr to the interface after calling // SwigCgocallDone, so that we don't try to allocate memory // while the Go scheduler can't see us. Printv(f_go_wrappers, "\tvar done bool\n", NULL); Printv(f_go_wrappers, "\tdefer func() {\n", NULL); Printv(f_go_wrappers, "\t\tif !done {\n", NULL); Printv(f_go_wrappers, "\t\t\tSwigCgocallDone()\n", NULL); Printv(f_go_wrappers, "\t\t}\n", NULL); Printv(f_go_wrappers, "\t}()\n", NULL); Printv(f_go_wrappers, "\tSwigCgocall()\n", NULL); } } Printv(f_go_wrappers, "\t", NULL); if (SwigType_type(result) != T_VOID) { if (gccgo_flag && is_constructor) { Printv(f_go_wrappers, "swig_r := ", NULL); } else { Printv(f_go_wrappers, "return ", NULL); } } Printv(f_go_wrappers, wrapper_name, "(", NULL); if (parm_count > required_count) { Printv(f_go_wrappers, "len(_swig_args)", NULL); } if (base && receiver) { if (parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } Printv(f_go_wrappers, "_swig_base", NULL); } Parm *p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); if (i > 0 || (base && receiver) || parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } Printv(f_go_wrappers, Getattr(p, "lname"), NULL); // If this is a destructor, then the C function expects the // C++ value, and we have the interface. We need to get the // C++ value. The same is true for a type represented as an // interface. if ((i == 0 && is_destructor) || ((i > 0 || !receiver || base || is_constructor) && goTypeIsInterface(p, Getattr(p, "type")))) { Printv(f_go_wrappers, ".Swigcptr()", NULL); } p = nextParm(p); } Printv(f_go_wrappers, ")\n", NULL); if (gccgo_flag && is_constructor) { Printv(f_go_wrappers, "\tSwigCgocallDone()\n", NULL); Printv(f_go_wrappers, "\tdone = true\n", NULL); Printv(f_go_wrappers, "\treturn swig_r\n", NULL); } Printv(f_go_wrappers, "}\n", NULL); } Printv(f_go_wrappers, "\n", NULL); Delete(wrapper_name); DelWrapper(dummy); return SWIG_OK; } /* ---------------------------------------------------------------------- * gcFunctionWrapper() * * This is used for 6g/8g, not for gccgo. Write out the function * wrapper which will be compiled with 6c/8c. * ---------------------------------------------------------------------- */ int gcFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, ParmList *parms, SwigType *result, bool is_static, bool needs_wrapper) { Wrapper *f = NewWrapper(); Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"\"\n", NULL); Printv(f->def, "#pragma cgo_import_static ", wname, "\n", NULL); Printv(f->def, "extern void (*", wname, ")(void*);\n", NULL); Printv(f->def, "static void (*x", wname, ")(void*) = ", wname, ";\n", NULL); Printv(f->def, "\n", NULL); Printv(f->def, "void\n", NULL); Wrapper *dummy = NewWrapper(); emit_attach_parmmaps(parms, dummy); Swig_typemap_attach_parms("default", parms, dummy); Swig_typemap_attach_parms("gosize", parms, dummy); int parm_count = emit_num_arguments(parms); int required_count = emit_num_required(parms); String *parm_size = NewString(""); if (parm_count > required_count) { Append(parm_size, "SWIG_PARM_SIZE"); } if (class_receiver && !is_static) { if (Len(parm_size) > 0) { Append(parm_size, " + "); } Append(parm_size, "SWIG_PARM_SIZE"); } Parm *p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); addGcTypeSize(p, Getattr(p, "type"), parm_size); p = nextParm(p); } if (SwigType_type(result) != T_VOID) { addGcTypeSize(n, result, parm_size); } if (Len(parm_size) == 0) { Append(parm_size, "1"); } String *fn_name; if (!needs_wrapper) { fn_name = Copy(go_name); if (overname) { Append(fn_name, overname); } } else { fn_name = buildGoWrapperName(name, overname); } // \xc2\xb7 is UTF-8 for U+00B7 which is Unicode 'Middle Dot' Printv(f->def, "\xc2\xb7", fn_name, "(struct { uint8 x[", parm_size, "];} p)", NULL); Delete(fn_name); Delete(parm_size); Printv(f->code, "{\n", NULL); Printv(f->code, "\truntime\xc2\xb7" "cgocall(x", wname, ", &p);\n", NULL); Printv(f->code, "}\n", NULL); Printv(f->code, "\n", NULL); Wrapper_print(f, f_gc_wrappers); DelWrapper(f); DelWrapper(dummy); return SWIG_OK; } /* ---------------------------------------------------------------------- * getGcTypeSize() * * Return the size to use when passing a type from 6g/8g to 6c/8c. * ---------------------------------------------------------------------- */ String *addGcTypeSize(Node *n, SwigType *type, String *orig) { if (Len(orig) > 0) { Append(orig, " + "); } String *go = goType(n, type); if (Cmp(go, "string") == 0) { // A string has a pointer and a length. Append(orig, "(2 * SWIG_PARM_SIZE)"); } else if (Strncmp(go, "[]", 2) == 0) { // A slice has a pointer, a length, and a capacity. Append(orig, "(3 * SWIG_PARM_SIZE)"); } else if (Strcmp(go, "float64") == 0) { Append(orig, "8"); } else if (Strcmp(go, "complex64") == 0) { Append(orig, "8"); } else if (Strcmp(go, "complex128") == 0) { Append(orig, "16"); } else { Append(orig, "SWIG_PARM_SIZE"); } return orig; } /* ---------------------------------------------------------------------- * gccFunctionWrapper() * * This is used for 6g/8g, not for gccgo. Write out the function * wrapper which will be compiled with gcc. If the base parameter * is not NULL, this is calls the base class method rather than * executing the SWIG wrapper code. * ---------------------------------------------------------------------- */ int gccFunctionWrapper(Node *n, List *base, String *wname, ParmList *parms, SwigType *result) { Wrapper *f = NewWrapper(); Swig_save("gccFunctionWrapper", n, "parms", NULL); Parm *base_parm = NULL; if (base && !isStatic(n)) { SwigType *base_type = Copy(getClassType()); SwigType_add_pointer(base_type); base_parm = NewParm(base_type, NewString("arg1"), n); set_nextSibling(base_parm, parms); parms = base_parm; } emit_parameter_variables(parms, f); emit_attach_parmmaps(parms, f); int parm_count = emit_num_arguments(parms); int required_count = emit_num_required(parms); emit_return_variable(n, result, f); // Start the function definition. Printv(f->def, "void\n", wname, "(void *swig_v)\n", "{\n", NULL); // The single function parameter is a pointer to the real argument // values. Define the structure that it points to. Printv(f->code, "\tstruct swigargs {\n", NULL); if (parm_count > required_count) { Printv(f->code, "\t\tintgo _swig_optargc;\n", NULL); } Parm *p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); String *ln = Getattr(p, "lname"); SwigType *pt = Getattr(p, "type"); String *ct = gcCTypeForGoValue(p, pt, ln); Printv(f->code, "\t\t\t", ct, ";\n", NULL); Delete(ct); p = nextParm(p); } if (SwigType_type(result) != T_VOID) { Printv(f->code, "\t\tlong : 0;\n", NULL); String *ln = NewString(Swig_cresult_name()); String *ct = gcCTypeForGoValue(n, result, ln); Delete(ln); Printv(f->code, "\t\t", ct, ";\n", NULL); Delete(ct); } Printv(f->code, "\t} *swig_a = (struct swigargs *) swig_v;\n", NULL); Printv(f->code, "\n", NULL); // Copy the input arguments out of the structure into the // parameter variables. p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); String *tm = Getattr(p, "tmap:in"); if (!tm) { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { String *ln = Getattr(p, "lname"); String *input = NewString(""); Printv(input, "swig_a->", ln, NULL); Replaceall(tm, "$input", input); Setattr(p, "emit:input", input); if (i < required_count) { Printv(f->code, "\t", tm, "\n", NULL); } else { Printf(f->code, "\tif (swig_a->_swig_optargc > %d) {\n", i - required_count); Printv(f->code, "\t\t", tm, "\n", NULL); Printv(f->code, "\t}\n", NULL); } } p = nextParm(p); } Printv(f->code, "\n", NULL); // Do the real work of the function. checkConstraints(parms, f); emitGoAction(n, base, parms, result, f); argout(parms, f); cleanupFunction(n, f, parms); Printv(f->code, "}\n", NULL); Wrapper_print(f, f_c_wrappers); Swig_restore(n); DelWrapper(f); Delete(base_parm); return SWIG_OK; } /* ---------------------------------------------------------------------- * gccgoFunctionWrapper() * * This is used for gccgo, not 6g/8g. Write out the function * wrapper which will be compiled with gcc. If the base parameter * is not NULL, this is calls the base class method rather than * executing the SWIG wrapper code. * ---------------------------------------------------------------------- */ int gccgoFunctionWrapper(Node *n, List *base, String *wname, ParmList *parms, SwigType *result) { Wrapper *f = NewWrapper(); Swig_save("gccgoFunctionWrapper", n, "parms", NULL); Parm *base_parm = NULL; if (base && !isStatic(n)) { SwigType *base_type = Copy(getClassType()); SwigType_add_pointer(base_type); base_parm = NewParm(base_type, NewString("arg1"), n); set_nextSibling(base_parm, parms); parms = base_parm; } emit_parameter_variables(parms, f); emit_attach_parmmaps(parms, f); int parm_count = emit_num_arguments(parms); int required_count = emit_num_required(parms); emit_return_variable(n, result, f); // Start the function definition. String *fnname = NewString(""); Printv(fnname, "go_", wname, "(", NULL); if (parm_count > required_count) { Printv(fnname, "intgo _swig_optargc", NULL); } Parm *p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); SwigType *pt = Copy(Getattr(p, "type")); if (SwigType_isarray(pt)) { SwigType_del_array(pt); SwigType_add_pointer(pt); } String *pn = NewString("g"); Append(pn, Getattr(p, "lname")); String *ct = gccgoCTypeForGoValue(p, pt, pn); if (i > 0 || parm_count > required_count) { Printv(fnname, ", ", NULL); } Printv(fnname, ct, NULL); Delete(ct); Delete(pn); Delete(pt); p = nextParm(p); } Printv(fnname, ")", NULL); String *fndef = NewString(""); if (SwigType_type(result) == T_VOID) { Printv(fndef, "void ", fnname, NULL); } else { String *ct = gccgoCTypeForGoValue(n, result, fnname); Printv(fndef, ct, NULL); Delete(ct); } Printv(f->def, fndef, " __asm__(\"", go_prefix, "_", wname, "\");\n", NULL); Printv(f->def, fndef, " {\n", NULL); Delete(fnname); Delete(fndef); if (SwigType_type(result) != T_VOID) { String *ln = NewString("go_result"); String *ct = gccgoCTypeForGoValue(n, result, ln); Wrapper_add_local(f, "go_result", ct); Delete(ct); Delete(ln); } // Copy the parameters into the variables which hold their values, // applying appropriate transformations. p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); String *tm = Getattr(p, "tmap:in"); if (!tm) { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { String *ln = Getattr(p, "lname"); String *pn = NewString("g"); Append(pn, ln); Replaceall(tm, "$input", pn); Setattr(p, "emit:input", pn); if (i < required_count) { Printv(f->code, " ", tm, "\n", NULL); } else { Printf(f->code, " if (_swig_optargc > %d) {\n", i - required_count); Printv(f->code, " ", tm, "\n", NULL); Printv(f->code, " }\n", NULL); } } p = nextParm(p); } Printv(f->code, "\n", NULL); // Do the real work of the function. checkConstraints(parms, f); emitGoAction(n, base, parms, result, f); argout(parms, f); cleanupFunction(n, f, parms); if (SwigType_type(result) != T_VOID) { Printv(f->code, " return go_result;\n", NULL); } Printv(f->code, "}\n", NULL); Wrapper_print(f, f_c_wrappers); Swig_restore(n); DelWrapper(f); Delete(base_parm); return SWIG_OK; } /* ----------------------------------------------------------------------- * checkConstraints() * * Check parameter constraints if any. This is used for the C/C++ * function. This assumes that each parameter has an "emit:input" * property with the name to use to refer to that parameter. * ----------------------------------------------------------------------- */ void checkConstraints(ParmList *parms, Wrapper *f) { Parm *p = parms; while (p) { String *tm = Getattr(p, "tmap:check"); if (!tm) { p = nextSibling(p); } else { Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(f->code, tm, "\n\n", NULL); p = Getattr(p, "tmap:check:next"); } } } /* ----------------------------------------------------------------------- * getGoAction() * * Get the action of the function. This is used for C/C++ function. * ----------------------------------------------------------------------- */ void emitGoAction(Node *n, List *base, ParmList *parms, SwigType *result, Wrapper *f) { String *actioncode; if (!base || isStatic(n)) { Swig_director_emit_dynamic_cast(n, f); actioncode = emit_action(n); } else { // Call the base class method. actioncode = NewString(""); String *current = NewString(""); if (!gccgo_flag) { Printv(current, "swig_a->", NULL); } Printv(current, Getattr(parms, "lname"), NULL); int vc = 0; for (Iterator bi = First(base); bi.item; bi = Next(bi)) { Printf(actioncode, " %s *swig_b%d = (%s *)%s;\n", bi.item, vc, bi.item, current); Delete(current); current = NewString(""); Printf(current, "swig_b%d", vc); ++vc; } String *code = Copy(Getattr(n, "wrap:action")); Replaceall(code, Getattr(parms, "lname"), current); Printv(actioncode, code, "\n", NULL); } Swig_save("emitGoAction", n, "type", "tmap:out", NULL); Setattr(n, "type", result); String *tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode); if (!tm) { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s\n", SwigType_str(result, 0)); } else { if (!gccgo_flag) { static const String *swig_a_result = NewStringf("swig_a->%s", Swig_cresult_name()); Replaceall(tm, "$result", swig_a_result); } else { Replaceall(tm, "$result", "go_result"); } if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "1"); } else { Replaceall(tm, "$owner", "0"); } Printv(f->code, tm, "\n", NULL); Delete(tm); } Swig_restore(n); } /* ----------------------------------------------------------------------- * argout() * * Handle argument output code if any. This is used for the C/C++ * function. This assumes that each parameter has an "emit:input" * property with the name to use to refer to that parameter. * ----------------------------------------------------------------------- */ void argout(ParmList *parms, Wrapper *f) { Parm *p = parms; while (p) { String *tm = Getattr(p, "tmap:argout"); if (!tm) { p = nextSibling(p); } else { Replaceall(tm, "$result", Swig_cresult_name()); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(f->code, tm, "\n", NULL); p = Getattr(p, "tmap:argout:next"); } } } /* ----------------------------------------------------------------------- * freearg() * * Handle argument cleanup code if any. This is used for the C/C++ * function. This assumes that each parameter has an "emit:input" * property with the name to use to refer to that parameter. * ----------------------------------------------------------------------- */ String *freearg(ParmList *parms) { String *ret = NewString(""); Parm *p = parms; while (p) { String *tm = Getattr(p, "tmap:freearg"); if (!tm) { p = nextSibling(p); } else { Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(ret, tm, "\n", NULL); p = Getattr(p, "tmap:freearg:next"); } } return ret; } /* ----------------------------------------------------------------------- * cleanupFunction() * * Final function cleanup code. * ----------------------------------------------------------------------- */ void cleanupFunction(Node *n, Wrapper *f, ParmList *parms) { String *cleanup = freearg(parms); Printv(f->code, cleanup, NULL); if (GetFlag(n, "feature:new")) { String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0); if (tm) { Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NULL); Delete(tm); } } Replaceall(f->code, "$cleanup", cleanup); Delete(cleanup); Replaceall(f->code, "$symname", Getattr(n, "sym:name")); } /* ----------------------------------------------------------------------- * variableHandler() * * This exists just to set the making_variable_wrappers flag. * ----------------------------------------------------------------------- */ virtual int variableHandler(Node *n) { assert(!making_variable_wrappers); making_variable_wrappers = true; int r = Language::variableHandler(n); making_variable_wrappers = false; return r; } /* ----------------------------------------------------------------------- * constantWrapper() * * Product a const declaration. * ------------------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { SwigType *type = Getattr(n, "type"); if (!SwigType_issimple(type) && SwigType_type(type) != T_STRING) { return goComplexConstant(n, type); } if (Swig_storage_isstatic(n)) { return goComplexConstant(n, type); } String *go_name = buildGoName(Getattr(n, "sym:name"), false, false); String *tm = goType(n, type); String *value = Getattr(n, "value"); String *copy = NULL; if (SwigType_type(type) == T_BOOL) { if (Cmp(value, "true") != 0 && Cmp(value, "false") != 0) { return goComplexConstant(n, type); } } else if (SwigType_type(type) == T_STRING || SwigType_type(type) == T_CHAR) { // Backslash sequences are somewhat different in Go and C/C++. if (Strchr(value, '\\') != 0) { return goComplexConstant(n, type); } } else { // Accept a 0x prefix, and strip combinations of u and l // suffixes. Otherwise accept digits, decimal point, and // exponentiation. Treat anything else as too complicated to // handle as a Go constant. char *p = Char(value); int len = strlen(p); bool need_copy = false; while (len > 0) { char c = p[len - 1]; if (c != 'l' && c != 'L' && c != 'u' && c != 'U') { break; } --len; need_copy = true; } bool is_hex = false; int i = 0; if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) { i = 2; is_hex = true; } for (; i < len; ++i) { switch (p[i]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': break; case 'a': case 'b': case 'c': case 'd': case 'f': case 'A': case 'B': case 'C': case 'D': case 'F': if (!is_hex) { return goComplexConstant(n, type); } break; case '.': case 'e': case 'E': case '+': case '-': break; default: return goComplexConstant(n, type); } } if (need_copy) { copy = Copy(value); Replaceall(copy, p + len, ""); value = copy; } } if (!checkNameConflict(go_name, n, NULL)) { Delete(tm); Delete(go_name); Delete(copy); return SWIG_NOWRAP; } Printv(f_go_wrappers, "const ", go_name, " ", tm, " = ", NULL); if (SwigType_type(type) == T_STRING) { Printv(f_go_wrappers, "\"", value, "\"", NULL); } else if (SwigType_type(type) == T_CHAR) { Printv(f_go_wrappers, "'", value, "'", NULL); } else { Printv(f_go_wrappers, value, NULL); } Printv(f_go_wrappers, "\n", NULL); Delete(tm); Delete(go_name); Delete(copy); return SWIG_OK; } /* ---------------------------------------------------------------------- * enumDeclaration() * * A C++ enum type turns into a Named go int type. * ---------------------------------------------------------------------- */ virtual int enumDeclaration(Node *n) { String *name = goEnumName(n); if (Strcmp(name, "int") != 0) { if (!ImportMode || !imported_package) { if (!checkNameConflict(name, n, NULL)) { Delete(name); return SWIG_NOWRAP; } Printv(f_go_wrappers, "type ", name, " int\n", NULL); } else { String *nw = NewString(""); Printv(nw, imported_package, ".", name, NULL); Setattr(n, "go:enumname", nw); } } Delete(name); return Language::enumDeclaration(n); } /* ----------------------------------------------------------------------- * enumvalueDeclaration() * * Declare a single value of an enum type. We fetch the value by * calling a C/C++ function. * ------------------------------------------------------------------------ */ virtual int enumvalueDeclaration(Node *n) { if (!is_public(n)) { return SWIG_OK; } if (Getattr(parentNode(n), "unnamed")) { Setattr(n, "type", NewString("int")); } else { Setattr(n, "type", Getattr(parentNode(n), "enumtype")); } return goComplexConstant(n, Getattr(n, "type")); } /* ----------------------------------------------------------------------- * goComplexConstant() * * Handle a const declaration for something which is not a Go constant. * ------------------------------------------------------------------------ */ int goComplexConstant(Node *n, SwigType *type) { String *symname = Getattr(n, "sym:name"); if (!symname) { symname = Getattr(n, "name"); } String *varname = buildGoName(symname, true, false); if (!checkNameConflict(varname, n, NULL)) { Delete(varname); return SWIG_NOWRAP; } String *get = NewString(""); Printv(get, Swig_cresult_name(), " = ", NULL); char quote; if (Getattr(n, "wrappedasconstant")) { quote = '\0'; } else if (SwigType_type(type) == T_CHAR) { quote = '\''; } else if (SwigType_type(type) == T_STRING) { quote = '"'; } else { quote = '\0'; } if (quote != '\0') { Printf(get, "%c", quote); } Printv(get, Getattr(n, "value"), NULL); if (quote != '\0') { Printf(get, "%c", quote); } Printv(get, ";\n", NULL); Setattr(n, "wrap:action", get); String *sname = Copy(symname); if (class_name) { Append(sname, "_"); Append(sname, class_name); } String *go_name = NewString("_swig_get"); if (class_name) { Append(go_name, class_name); Append(go_name, "_"); } Append(go_name, sname); String *wname = Swig_name_wrapper(sname); Setattr(n, "wrap:name", wname); int r = makeWrappers(n, sname, go_name, NULL, wname, NULL, NULL, type, true); if (r != SWIG_OK) { return r; } String *t = goType(n, type); Printv(f_go_wrappers, "var ", varname, " ", t, " = ", go_name, "()\n", NULL); Delete(varname); Delete(t); Delete(go_name); Delete(sname); return SWIG_OK; } /* ------------------------------------------------------------ * classHandler() * * For a C++ class, in Go we generate both a struct and an * interface. The interface will declare all the class public * methods. We will define all the methods on the struct, so that * the struct meets the interface. We then expect users of the * class to use the interface. * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { class_node = n; List *baselist = Getattr(n, "bases"); bool has_base_classes = baselist && Len(baselist) > 0; String *name = Getattr(n, "sym:name"); String *go_name = exportedName(name); if (!checkNameConflict(go_name, n, NULL)) { Delete(go_name); SetFlag(n, "go:conflict"); return SWIG_NOWRAP; } String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); class_name = name; class_receiver = go_type_name; class_methods = NewHash(); int isdir = GetFlag(n, "feature:director"); int isnodir = GetFlag(n, "feature:nodirector"); bool is_director = isdir && !isnodir; Printv(f_go_wrappers, "type ", go_type_name, " uintptr\n\n", NULL); // A method to return the pointer to the C++ class. This is used // by generated code to convert between the interface and the C++ // value. Printv(f_go_wrappers, "func (p ", go_type_name, ") Swigcptr() uintptr {\n", NULL); Printv(f_go_wrappers, "\treturn (uintptr)(p)\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); // A method used as a marker for the class, to avoid invalid // interface conversions when using multiple inheritance. Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigIs", go_name, "() {\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); if (is_director) { // Return the interface passed to the NewDirector function. Printv(f_go_wrappers, "func (p ", go_type_name, ") DirectorInterface() interface{} {\n", NULL); Printv(f_go_wrappers, "\treturn nil\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); } // We have seen a definition for this type. Setattr(defined_types, go_name, go_name); Setattr(defined_types, go_type_name, go_type_name); interfaces = NewString(""); int r = Language::classHandler(n); if (r != SWIG_OK) { return r; } if (has_base_classes) { // For each method defined in a base class but not defined in // this class, we need to define the method in this class. We // can't use anonymous field inheritance because it works // differently in Go and in C++. Hash *local = NewHash(); for (Node *ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { if (!is_public(ni)) { continue; } String *type = Getattr(ni, "nodeType"); if (Cmp(type, "constructor") == 0 || Cmp(type, "destructor") == 0) { continue; } String *cname = Getattr(ni, "sym:name"); if (!cname) { cname = Getattr(ni, "name"); } if (cname) { Setattr(local, cname, NewString("")); } } for (Iterator b = First(baselist); b.item; b = Next(b)) { List *bases = NewList(); Append(bases, Getattr(b.item, "classtype")); int r = addBase(n, b.item, bases, local); if (r != SWIG_OK) { return r; } Delete(bases); } Delete(local); Hash *parents = NewHash(); addFirstBaseInterface(n, parents, baselist); int r = addExtraBaseInterfaces(n, parents, baselist); Delete(parents); if (r != SWIG_OK) { return r; } } Printv(f_go_wrappers, "type ", go_name, " interface {\n", NULL); Printv(f_go_wrappers, "\tSwigcptr() uintptr\n", NULL); Printv(f_go_wrappers, "\tSwigIs", go_name, "()\n", NULL); if (is_director) { Printv(f_go_wrappers, "\tDirectorInterface() interface{}\n", NULL); } Append(f_go_wrappers, interfaces); Printf(f_go_wrappers, "}\n\n", NULL); Delete(interfaces); interfaces = NULL; class_name = NULL; class_receiver = NULL; class_node = NULL; Delete(class_methods); class_methods = NULL; Delete(go_type_name); return SWIG_OK; } /* ------------------------------------------------------------ * addBase() * * Implement methods and members defined in a parent class for a * child class. * ------------------------------------------------------------ */ int addBase(Node *n, Node *base, List *bases, Hash *local) { if (GetFlag(base, "feature:ignore")) { return SWIG_OK; } for (Node *ni = Getattr(base, "firstChild"); ni; ni = nextSibling(ni)) { if (GetFlag(ni, "feature:ignore")) { continue; } if (!is_public(ni)) { continue; } String *type = Getattr(ni, "nodeType"); if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0 || Strcmp(type, "classforward") == 0 || Strcmp(type, "template") == 0) { continue; } String *storage = Getattr(ni, "storage"); if (storage && (Strcmp(storage, "typedef") == 0 || Strcmp(storage, "friend") == 0)) { continue; } String *mname = Getattr(ni, "sym:name"); if (!mname) { continue; } String *lname = Getattr(ni, "name"); if (Getattr(class_methods, lname)) { continue; } if (Getattr(local, lname)) { continue; } Setattr(local, lname, NewString("")); String *ty = NewString(Getattr(ni, "type")); SwigType_push(ty, Getattr(ni, "decl")); String *fullty = SwigType_typedef_resolve_all(ty); bool is_function = SwigType_isfunction(fullty) ? true : false; Delete(ty); Delete(fullty); if (is_function) { int r = goBaseMethod(n, bases, ni); if (r != SWIG_OK) { return r; } if (Getattr(ni, "sym:overloaded")) { for (Node *on = Getattr(ni, "sym:nextSibling"); on; on = Getattr(on, "sym:nextSibling")) { r = goBaseMethod(n, bases, on); if (r != SWIG_OK) { return r; } } String *receiver = class_receiver; bool is_static = isStatic(ni); if (is_static) { receiver = NULL; } String *go_name = buildGoName(Getattr(ni, "sym:name"), is_static, false); r = makeDispatchFunction(ni, go_name, receiver, is_static, NULL, false); Delete(go_name); if (r != SWIG_OK) { return r; } } } else { int r = goBaseVariable(n, bases, ni); if (r != SWIG_OK) { return r; } } } List *baselist = Getattr(base, "bases"); if (baselist && Len(baselist) > 0) { for (Iterator b = First(baselist); b.item; b = Next(b)) { List *nb = Copy(bases); Append(nb, Getattr(b.item, "classtype")); int r = addBase(n, b.item, nb, local); Delete(nb); if (r != SWIG_OK) { return r; } } } return SWIG_OK; } /* ------------------------------------------------------------ * goBaseMethod() * * Implement a method defined in a parent class for a child class. * ------------------------------------------------------------ */ int goBaseMethod(Node *method_class, List *bases, Node *method) { String *symname = Getattr(method, "sym:name"); if (!validIdentifier(symname)) { return SWIG_OK; } String *name = NewString(""); Printv(name, Getattr(method_class, "sym:name"), "_", symname, NULL); bool is_static = isStatic(method); String *go_name = buildGoName(name, is_static, false); String *overname = NULL; if (Getattr(method, "sym:overloaded")) { overname = Getattr(method, "sym:overname"); } String *wname = Swig_name_wrapper(name); if (overname) { Append(wname, overname); } String *result = NewString(Getattr(method, "type")); SwigType_push(result, Getattr(method, "decl")); if (SwigType_isqualifier(result)) { Delete(SwigType_pop(result)); } Delete(SwigType_pop_function(result)); // If the base method is imported, wrap:action may not be set. Swig_save("goBaseMethod", method, "wrap:name", "wrap:action", "parms", NULL); Setattr(method, "wrap:name", wname); if (!Getattr(method, "wrap:action")) { if (!is_static) { Swig_MethodToFunction(method, getNSpace(), getClassType(), (Getattr(method, "template") ? SmartPointer : Extend | SmartPointer), NULL, false); // Remove any self parameter that was just added. ParmList *parms = Getattr(method, "parms"); if (parms && Getattr(parms, "self")) { parms = CopyParmList(nextSibling(parms)); Setattr(method, "parms", parms); } } else { String *call = Swig_cfunction_call(Getattr(method, "name"), Getattr(method, "parms")); Setattr(method, "wrap:action", Swig_cresult(Getattr(method, "type"), Swig_cresult_name(), call)); } } int r = makeWrappers(method, name, go_name, overname, wname, bases, Getattr(method, "parms"), result, is_static); Swig_restore(method); Delete(result); Delete(go_name); Delete(name); return r; } /* ------------------------------------------------------------ * goBaseVariable() * * Add accessors for a member variable defined in a parent class for * a child class. * ------------------------------------------------------------ */ int goBaseVariable(Node *var_class, List *bases, Node *var) { if (isStatic(var)) { return SWIG_OK; } String *var_name = buildGoName(Getattr(var, "sym:name"), false, false); Swig_save("goBaseVariable", var, "type", "wrap:action", NULL); // For a pointer type we apparently have to wrap in the decl. SwigType *var_type = NewString(Getattr(var, "type")); SwigType_push(var_type, Getattr(var, "decl")); Setattr(var, "type", var_type); SwigType *vt = Copy(var_type); if (SwigType_isclass(vt)) { SwigType_add_pointer(vt); } int flags = Extend | SmartPointer | use_naturalvar_mode(var); if (isNonVirtualProtectedAccess(var)) { flags |= CWRAP_ALL_PROTECTED_ACCESS; } String *mname = Swig_name_member(getNSpace(), Getattr(var_class, "sym:name"), var_name); if (is_assignable(var)) { for (Iterator ki = First(var); ki.key; ki = Next(ki)) { if (Strncmp(ki.key, "tmap:", 5) == 0) { Delattr(var, ki.key); } } Swig_save("goBaseVariableSet", var, "name", "sym:name", "type", NULL); String *mname_set = NewString("Set"); Append(mname_set, mname); String *go_name = NewString("Set"); Append(go_name, var_name); Swig_MembersetToFunction(var, class_name, flags); String *wname = Swig_name_wrapper(mname_set); ParmList *parms = NewParm(vt, var_name, var); String *result = NewString("void"); int r = makeWrappers(var, mname_set, go_name, NULL, wname, bases, parms, result, false); if (r != SWIG_OK) { return r; } Delete(wname); Delete(parms); Delete(result); Delete(go_name); Delete(mname_set); Swig_restore(var); for (Iterator ki = First(var); ki.key; ki = Next(ki)) { if (Strncmp(ki.key, "tmap:", 5) == 0) { Delattr(var, ki.key); } } } Swig_MembergetToFunction(var, class_name, flags); String *mname_get = NewString("Get"); Append(mname_get, mname); String *go_name = NewString("Get"); Append(go_name, var_name); String *wname = Swig_name_wrapper(mname_get); int r = makeWrappers(var, mname_get, go_name, NULL, wname, bases, NULL, vt, false); if (r != SWIG_OK) { return r; } Delete(wname); Delete(mname_get); Delete(go_name); Delete(mname); Delete(var_name); Delete(var_type); Delete(vt); Swig_restore(var); return SWIG_OK; } /* ------------------------------------------------------------ * addFirstBaseInterface() * * When a C++ class uses multiple inheritance, we can use the C++ * pointer for the first base class but not for any subsequent base * classes. However, the Go interface will match the interface for * all the base classes. To avoid accidentally treating a class as * a pointer to a base class other than the first one, we use an * isClassname method. This function adds those methods as * required. * * For convenience when using multiple inheritance, we also add * functions to retrieve the base class pointers. * ------------------------------------------------------------ */ void addFirstBaseInterface(Node *n, Hash *parents, List *bases) { if (!bases || Len(bases) == 0) { return; } Iterator b = First(bases); if (!GetFlag(b.item, "feature:ignore")) { String *go_name = buildGoName(Getattr(n, "sym:name"), false, false); String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); String *go_base_name = exportedName(Getattr(b.item, "sym:name")); String *go_base_type = goType(n, Getattr(b.item, "classtypeobj")); String *go_base_type_name = goCPointerType(Getattr(b.item, "classtypeobj"), true); Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigIs", go_base_name, "() {\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); Printv(interfaces, "\tSwigIs", go_base_name, "()\n", NULL); Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", go_base_name, "() ", go_base_type, " {\n", NULL); Printv(f_go_wrappers, "\treturn ", go_base_type_name, "(p.Swigcptr())\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); Printv(interfaces, "\tSwigGet", go_base_name, "() ", go_base_type, "\n", NULL); Setattr(parents, go_base_name, NewString("")); Delete(go_name); Delete(go_type_name); Delete(go_base_type); Delete(go_base_type_name); } addFirstBaseInterface(n, parents, Getattr(b.item, "bases")); } /* ------------------------------------------------------------ * addExtraBaseInterfaces() * * Add functions to retrieve the base class pointers for all base * classes other than the first. * ------------------------------------------------------------ */ int addExtraBaseInterfaces(Node *n, Hash *parents, List *bases) { Iterator b = First(bases); Node *fb = b.item; for (b = Next(b); b.item; b = Next(b)) { if (GetFlag(b.item, "feature:ignore")) { continue; } String *go_base_name = exportedName(Getattr(b.item, "sym:name")); Swig_save("addExtraBaseInterface", n, "wrap:action", "wrap:name", "wrap:parms", NULL); SwigType *type = Copy(Getattr(n, "classtypeobj")); SwigType_add_pointer(type); Parm *parm = NewParm(type, "self", n); Setattr(n, "wrap:parms", parm); String *pn = Swig_cparm_name(parm, 0); String *action = NewString(""); Printv(action, Swig_cresult_name(), " = (", Getattr(b.item, "classtype"), "*)", pn, ";", NULL); Delete(pn); Setattr(n, "wrap:action", action); String *name = Copy(class_name); Append(name, "_SwigGet"); Append(name, go_base_name); String *go_name = NewString("SwigGet"); String *c1 = exportedName(go_base_name); Append(go_name, c1); Delete(c1); String *wname = Swig_name_wrapper(name); Setattr(n, "wrap:name", wname); SwigType *result = Copy(Getattr(b.item, "classtypeobj")); SwigType_add_pointer(result); int r = makeWrappers(n, name, go_name, NULL, wname, NULL, parm, result, false); if (r != SWIG_OK) { return r; } Swig_restore(n); Setattr(parents, go_base_name, NewString("")); Delete(go_name); Delete(type); Delete(parm); Delete(action); Delete(result); String *ns = NewString(""); addParentExtraBaseInterfaces(n, parents, b.item, false, ns); Delete(ns); } if (!GetFlag(fb, "feature:ignore")) { String *ns = NewString(""); addParentExtraBaseInterfaces(n, parents, fb, true, ns); Delete(ns); } return SWIG_OK; } /* ------------------------------------------------------------ * addParentExtraBaseInterfaces() * * Add functions to retrieve the base class pointers for all base * classes of parents other than the first base class at each level. * ------------------------------------------------------------ */ void addParentExtraBaseInterfaces(Node *n, Hash *parents, Node *base, bool is_base_first, String *sofar) { List *baselist = Getattr(base, "bases"); if (!baselist || Len(baselist) == 0) { return; } String *go_this_base_name = exportedName(Getattr(base, "sym:name")); String *sf = NewString(""); Printv(sf, sofar, ".SwigGet", go_this_base_name, "()", NULL); Iterator b = First(baselist); if (is_base_first) { if (!b.item) { return; } if (!GetFlag(b.item, "feature:ignore")) { addParentExtraBaseInterfaces(n, parents, b.item, true, sf); } b = Next(b); } String *go_name = buildGoName(Getattr(n, "sym:name"), false, false); String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); for (; b.item; b = Next(b)) { if (GetFlag(b.item, "feature:ignore")) { continue; } String *go_base_name = exportedName(Getattr(b.item, "sym:name")); if (!Getattr(parents, go_base_name)) { Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", go_base_name, "() ", go_base_name, " {\n", NULL); Printv(f_go_wrappers, "\treturn p", sf, ".SwigGet", go_base_name, "()\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); Printv(interfaces, "\tSwigGet", go_base_name, "() ", go_base_name, "\n", NULL); addParentExtraBaseInterfaces(n, parents, b.item, false, sf); Setattr(parents, go_base_name, NewString("")); } } Delete(go_name); Delete(go_type_name); Delete(go_this_base_name); Delete(sf); } /* ------------------------------------------------------------ * classDirectorInit * * Add support for a director class. * * Virtual inheritance is different in Go and C++. We implement * director classes by defining a new function in Go, * NewDirectorClassname, which takes a empty interface value and * creates an instance of a new child class. The new child class * refers all methods back to Go. The Go code checks whether the * value passed to NewDirectorClassname implements that method; if * it does, it calls it, otherwise it calls back into C++. * ------------------------------------------------------------ */ int classDirectorInit(Node *n) { // Because we use a different function to handle inheritance in // Go, ordinary creations of the object should not create a // director object. Delete(director_ctor_code); director_ctor_code = NewString("$nondirector_new"); class_node = n; String *name = Getattr(n, "sym:name"); assert(!class_name); class_name = name; String *go_name = exportedName(name); String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); assert(!class_receiver); class_receiver = go_type_name; String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, go_name); String *cxx_director_name = NewString("SwigDirector_"); Append(cxx_director_name, name); // The Go type of the director class. Printv(f_go_wrappers, "type ", director_struct_name, " struct {\n", NULL); Printv(f_go_wrappers, "\t", go_type_name, "\n", NULL); Printv(f_go_wrappers, "\tv interface{}\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); Printv(f_go_wrappers, "func (p *", director_struct_name, ") Swigcptr() uintptr {\n", NULL); Printv(f_go_wrappers, "\treturn p.", go_type_name, ".Swigcptr()\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); Printv(f_go_wrappers, "func (p *", director_struct_name, ") SwigIs", go_name, "() {\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); Printv(f_go_wrappers, "func (p *", director_struct_name, ") DirectorInterface() interface{} {\n", NULL); Printv(f_go_wrappers, "\treturn p.v\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); // Start defining the director class. Printv(f_c_directors_h, "class ", cxx_director_name, " : public ", Getattr(n, "classtype"), "\n", NULL); Printv(f_c_directors_h, "{\n", NULL); Printv(f_c_directors_h, " public:\n", NULL); Delete(director_struct_name); Delete(cxx_director_name); class_methods = NewHash(); return SWIG_OK; } /* ------------------------------------------------------------ * classDirectorConstructor * * Emit a constructor for a director class. * ------------------------------------------------------------ */ int classDirectorConstructor(Node *n) { bool is_ignored = GetFlag(n, "feature:ignore") ? true : false; String *name = Getattr(n, "sym:name"); if (!name) { assert(is_ignored); name = Getattr(n, "name"); } String *overname = NULL; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } String *go_name = exportedName(name); ParmList *parms = Getattr(n, "parms"); Setattr(n, "wrap:parms", parms); String *cn = exportedName(Getattr(parentNode(n), "sym:name")); String *go_type_name = goCPointerType(Getattr(parentNode(n), "classtypeobj"), true); String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, cn); String *fn_name = NewString("_swig_NewDirector"); Append(fn_name, cn); Append(fn_name, go_name); if (!overname && !is_ignored) { if (!checkNameConflict(fn_name, n, NULL)) { return SWIG_NOWRAP; } } String *wname = Swig_name_wrapper(fn_name); if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); bool is_static = isStatic(n); Wrapper *dummy = NewWrapper(); emit_attach_parmmaps(parms, dummy); DelWrapper(dummy); Swig_typemap_attach_parms("gotype", parms, NULL); int parm_count = emit_num_arguments(parms); String *func_name = NewString("NewDirector"); Append(func_name, go_name); String *func_with_over_name = Copy(func_name); if (overname) { Append(func_with_over_name, overname); } SwigType *first_type = NewString("void"); SwigType_add_pointer(first_type); Parm *first_parm = NewParm(first_type, "swig_p", n); set_nextSibling(first_parm, parms); Setattr(first_parm, "lname", "p"); Parm *p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); Swig_cparm_name(p, i); p = nextParm(p); } if (!is_ignored) { // Declare the C++ wrapper. if (gccgo_flag) { Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL); } Printv(f_go_wrappers, "func ", fn_name, NULL); if (overname) { Printv(f_go_wrappers, overname, NULL); } Printv(f_go_wrappers, "(*", director_struct_name, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); String *tm = goType(p, Getattr(p, "type")); Printv(f_go_wrappers, ", ", tm, NULL); Delete(tm); p = nextParm(p); } Printv(f_go_wrappers, ") ", go_type_name, "\n\n", NULL); Printv(f_go_wrappers, "func ", func_with_over_name, "(v interface{}", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); // Set the lname parameter. Printv(f_go_wrappers, ", ", Getattr(p, "lname"), " ", NULL); String *tm = goType(p, Getattr(p, "type")); Printv(f_go_wrappers, tm, NULL); Delete(tm); p = nextParm(p); } Printv(f_go_wrappers, ") ", cn, " {\n", NULL); Printv(f_go_wrappers, "\tp := &", director_struct_name, "{0, v}\n", NULL); if (gccgo_flag) { Printv(f_go_wrappers, "\tdefer SwigCgocallDone()\n", NULL); Printv(f_go_wrappers, "\tSwigCgocall()\n", NULL); } Printv(f_go_wrappers, "\tp.", class_receiver, " = ", fn_name, NULL); if (overname) { Printv(f_go_wrappers, overname, NULL); } Printv(f_go_wrappers, "(p", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); Printv(f_go_wrappers, ", ", Getattr(p, "lname"), NULL); p = nextParm(p); } Printv(f_go_wrappers, ")\n", NULL); Printv(f_go_wrappers, "\treturn p\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); SwigType *result = Copy(Getattr(parentNode(n), "classtypeobj")); SwigType_add_pointer(result); Swig_save("classDirectorConstructor", n, "wrap:name", "wrap:action", NULL); Setattr(n, "wrap:name", Swig_name_wrapper(name)); String *action = NewString(""); Printv(action, Swig_cresult_name(), " = new SwigDirector_", class_name, "(", NULL); String *pname = Swig_cparm_name(NULL, 0); Printv(action, pname, NULL); Delete(pname); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); String *pname = Swig_cparm_name(NULL, i + 1); Printv(action, ", ", NULL); if (SwigType_isreference(Getattr(p, "type"))) { Printv(action, "*", NULL); } Printv(action, pname, NULL); Delete(pname); p = nextParm(p); } Printv(action, ");", NULL); Setattr(n, "wrap:action", action); if (!gccgo_flag) { int r = gcFunctionWrapper(n, fn_name, fn_name, overname, wname, first_parm, result, is_static, false); if (r != SWIG_OK) { return r; } r = gccFunctionWrapper(n, NULL, wname, first_parm, result); if (r != SWIG_OK) { return r; } } else { int r = gccgoFunctionWrapper(n, NULL, wname, first_parm, result); if (r != SWIG_OK) { return r; } } Swig_restore(n); Delete(result); } String *cxx_director_name = NewString("SwigDirector_"); Append(cxx_director_name, class_name); String *decl = Swig_method_decl(NULL, Getattr(n, "decl"), cxx_director_name, first_parm, 0, 0); Printv(f_c_directors_h, " ", decl, ";\n", NULL); Delete(decl); decl = Swig_method_decl(NULL, Getattr(n, "decl"), cxx_director_name, first_parm, 0, 0); Printv(f_c_directors, cxx_director_name, "::", decl, "\n", NULL); Delete(decl); Printv(f_c_directors, " : ", Getattr(parentNode(n), "classtype"), "(", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); if (i > 0) { Printv(f_c_directors, ", ", NULL); } String *pn = Getattr(p, "name"); assert(pn); Printv(f_c_directors, pn, NULL); p = nextParm(p); } Printv(f_c_directors, "),\n", NULL); Printv(f_c_directors, " go_val(swig_p)\n", NULL); Printv(f_c_directors, "{ }\n\n", NULL); if (Getattr(n, "sym:overloaded") && !Getattr(n, "sym:nextSibling")) { int r = makeDispatchFunction(n, func_name, cn, is_static, Getattr(parentNode(n), "classtypeobj"), false); if (r != SWIG_OK) { return r; } } Delete(cxx_director_name); Delete(go_name); Delete(cn); Delete(go_type_name); Delete(director_struct_name); Delete(fn_name); Delete(func_name); Delete(func_with_over_name); Delete(wname); Delete(first_type); Delete(first_parm); return SWIG_OK; } /* ------------------------------------------------------------ * classDirectorDestructor * * Emit a destructor for a director class. * ------------------------------------------------------------ */ int classDirectorDestructor(Node *n) { if (!is_public(n)) { return SWIG_OK; } bool is_ignored = GetFlag(n, "feature:ignore") ? true : false; if (!is_ignored) { String *fnname = NewString("DeleteDirector"); String *c1 = exportedName(class_name); Append(fnname, c1); Delete(c1); String *wname = Swig_name_wrapper(fnname); Setattr(n, "wrap:name", fnname); Swig_DestructorToFunction(n, getNSpace(), getClassType(), CPlusPlus, Extend); ParmList *parms = Getattr(n, "parms"); Setattr(n, "wrap:parms", parms); String *result = NewString("void"); int r = makeWrappers(n, fnname, fnname, NULL, wname, NULL, parms, result, isStatic(n)); if (r != SWIG_OK) { return r; } Delete(result); Delete(fnname); Delete(wname); } // Generate the destructor for the C++ director class. Since the // Go code is keeping a pointer to the C++ object, we need to call // back to the Go code to let it know that the C++ object is gone. String *wname = NewString("_swiggo_wrap_DeleteDirector_"); Append(wname, class_name); String *go_name = NewString("Swiggo_DeleteDirector_"); Append(go_name, class_name); String *cn = exportedName(class_name); String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, cn); Printv(f_c_directors_h, " virtual ~SwigDirector_", class_name, "()", NULL); String *throws = buildThrow(n); if (throws) { Printv(f_c_directors_h, " ", throws, NULL); } Printv(f_c_directors_h, ";\n", NULL); if (!is_ignored) { if (!gccgo_flag) { Printv(f_c_directors, "extern \"C\" void ", wname, "(void*, int);\n", NULL); } else { Printv(f_c_directors, "extern \"C\" void ", wname, "(void*) __asm__(\"", go_prefix, ".", go_name, "\");\n", NULL); } } Printv(f_c_directors, "SwigDirector_", class_name, "::~SwigDirector_", class_name, "()", NULL); if (throws) { Printv(f_c_directors, " ", throws, NULL); Delete(throws); } Printv(f_c_directors, "\n", NULL); Printv(f_c_directors, "{\n", NULL); if (!is_ignored) { if (!gccgo_flag) { Printv(f_c_directors, " struct { void *p; } a;\n", NULL); Printv(f_c_directors, " a.p = go_val;\n", NULL); Printv(f_c_directors, " crosscall2(", wname, ", &a, (int) sizeof a);\n", NULL); Printv(f_gc_wrappers, "#pragma dynexport ", wname, " ", wname, "\n", NULL); Printv(f_gc_wrappers, "#pragma cgo_export_static ", wname, " ", wname, "\n", NULL); Printv(f_gc_wrappers, "#pragma textflag 7\n", NULL); Printv(f_gc_wrappers, "extern void \xc2\xb7", go_name, "();\n", NULL); Printv(f_gc_wrappers, "void\n", NULL); Printv(f_gc_wrappers, wname, "(void *a, int32 n)\n", NULL); Printv(f_gc_wrappers, "{\n", NULL); Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL); Printv(f_gc_wrappers, "}\n\n", NULL); } else { Printv(f_c_directors, " ", wname, "(go_val);\n", NULL); } } Printv(f_c_directors, "}\n\n", NULL); if (!is_ignored) { Printv(f_go_wrappers, "func ", go_name, "(p *", director_struct_name, ") {\n", NULL); Printv(f_go_wrappers, "\tp.", class_receiver, " = 0\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); } Delete(wname); Delete(go_name); Delete(cn); Delete(director_struct_name); return SWIG_OK; } /* ------------------------------------------------------------ * classDirectorMethod * * Emit a method for a director class, plus its overloads. * ------------------------------------------------------------ */ int classDirectorMethod(Node *n, Node *parent, String *super) { bool is_ignored = GetFlag(n, "feature:ignore") ? true : false; // We don't need explicit calls. if (GetFlag(n, "explicitcall")) { return SWIG_OK; } String *name = Getattr(n, "sym:name"); if (!name) { assert(is_ignored); name = Getattr(n, "name"); } bool overloaded = Getattr(n, "sym:overloaded") && !Getattr(n, "explicitcallnode"); if (!overloaded) { int r = oneClassDirectorMethod(n, parent, super); if (r != SWIG_OK) { return r; } } else { // Handle overloaded methods here, because otherwise we will // reject them in the class_methods hash table. We need to use // class_methods so that we correctly handle cases where a // function in one class hides a function of the same name in a // parent class. if (!Getattr(class_methods, name)) { for (Node *on = Getattr(n, "sym:overloaded"); on; on = Getattr(on, "sym:nextSibling")) { // Swig_overload_rank expects wrap:name and wrap:parms to be // set. String *wn = Swig_name_wrapper(Getattr(on, "sym:name")); Append(wn, Getattr(on, "sym:overname")); Setattr(on, "wrap:name", wn); Delete(wn); Setattr(on, "wrap:parms", Getattr(on, "parms")); } } int r = oneClassDirectorMethod(n, parent, super); if (r != SWIG_OK) { return r; } if (!Getattr(n, "sym:nextSibling")) { // Last overloaded function Node *on = Getattr(n, "sym:overloaded"); bool is_static = isStatic(on); String *cn = exportedName(Getattr(parent, "sym:name")); String *go_name = buildGoName(name, is_static, false); String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, cn); int r = makeDispatchFunction(on, go_name, director_struct_name, is_static, director_struct_name, false); if (r != SWIG_OK) { return r; } if (!GetFlag(n, "abstract")) { String *go_upcall = NewString("Director"); Append(go_upcall, cn); Append(go_upcall, go_name); r = makeDispatchFunction(on, go_upcall, director_struct_name, is_static, director_struct_name, true); if (r != SWIG_OK) { return r; } Delete(go_upcall); } Delete(director_struct_name); Delete(go_name); Delete(cn); } } Setattr(class_methods, name, NewString("")); return SWIG_OK; } /* ------------------------------------------------------------ * oneClassDirectorMethod * * Emit a method for a director class. * ------------------------------------------------------------ */ int oneClassDirectorMethod(Node *n, Node *parent, String *super) { String *symname = Getattr(n, "sym:name"); if (!checkFunctionVisibility(n, parent)) { return SWIG_OK; } bool is_ignored = GetFlag(n, "feature:ignore") ? true : false; bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0); String *name = Getattr(n, "sym:name"); if (!name) { assert(is_ignored); name = Getattr(n, "name"); } String *overname = NULL; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } String *cn = exportedName(Getattr(parent, "sym:name")); String *go_type_name = goCPointerType(Getattr(parent, "classtypeobj"), true); String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, cn); bool is_static = isStatic(n); String *go_name = buildGoName(name, is_static, false); ParmList *parms = Getattr(n, "parms"); Setattr(n, "wrap:parms", parms); Wrapper *dummy = NewWrapper(); emit_attach_parmmaps(parms, dummy); DelWrapper(dummy); Swig_typemap_attach_parms("gotype", parms, NULL); int parm_count = emit_num_arguments(parms); SwigType *result = Getattr(n, "type"); // Save the type for overload processing. Setattr(n, "go:type", result); String *interface_name = NewString("_swig_DirectorInterface"); Append(interface_name, cn); Append(interface_name, go_name); if (overname) { Append(interface_name, overname); } String *callback_name = Copy(director_struct_name); Append(callback_name, "_callback_"); Append(callback_name, name); Replace(callback_name, "_swig", "Swig", DOH_REPLACE_FIRST); if (overname) { Append(callback_name, overname); } String *callback_wname = Swig_name_wrapper(callback_name); String *upcall_name = Copy(director_struct_name); Append(upcall_name, "_upcall_"); Append(upcall_name, go_name); String *upcall_wname = Swig_name_wrapper(upcall_name); if (overname) { Append(upcall_wname, overname); } String *upcall_gc_name = buildGoWrapperName(upcall_name, overname); String *go_with_over_name = Copy(go_name); if (overname) { Append(go_with_over_name, overname); } Parm *p = 0; Wrapper *w = NewWrapper(); Swig_director_parms_fixup(parms); Swig_typemap_attach_parms("directorin", parms, w); Swig_typemap_attach_parms("directorargout", parms, w); if (!is_ignored) { // We use an interface to see if this method is defined in Go. Printv(f_go_wrappers, "type ", interface_name, " interface {\n", NULL); Printv(f_go_wrappers, "\t", go_with_over_name, "(", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); if (i > 0) { Printv(f_go_wrappers, ", ", NULL); } String *tm = goType(p, Getattr(p, "type")); Printv(f_go_wrappers, tm, NULL); Delete(tm); p = nextParm(p); } Printv(f_go_wrappers, ")", NULL); if (SwigType_type(result) != T_VOID) { String *tm = goType(n, result); Printv(f_go_wrappers, " ", tm, NULL); Delete(tm); } Printv(f_go_wrappers, "\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); if (!GetFlag(n, "abstract")) { // Declare the upcall function, which calls the method on the // parent class. if (gccgo_flag) { Printv(f_go_wrappers, "//extern ", go_prefix, "_", upcall_wname, "\n", NULL); } Printv(f_go_wrappers, "func ", upcall_gc_name, "(", go_type_name, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); String *tm = goWrapperType(p, Getattr(p, "type"), false); Printv(f_go_wrappers, ", ", tm, NULL); Delete(tm); p = nextParm(p); } Printv(f_go_wrappers, ")", NULL); if (SwigType_type(result) != T_VOID) { String *tm = goWrapperType(n, result, true); Printv(f_go_wrappers, " ", tm, NULL); Delete(tm); } Printv(f_go_wrappers, "\n", NULL); } // Define the method on the director class in Go. Printv(f_go_wrappers, "func (swig_p *", director_struct_name, ") ", go_with_over_name, "(", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); if (i > 0) { Printv(f_go_wrappers, ", ", NULL); } Printv(f_go_wrappers, Getattr(p, "lname"), " ", NULL); String *tm = goType(p, Getattr(p, "type")); Printv(f_go_wrappers, tm, NULL); Delete(tm); p = nextParm(p); } Printv(f_go_wrappers, ")", NULL); if (SwigType_type(result) != T_VOID) { String *tm = goType(n, result); Printv(f_go_wrappers, " ", tm, NULL); Delete(tm); } Printv(f_go_wrappers, " {\n", NULL); Printv(f_go_wrappers, "\tif swig_g, swig_ok := swig_p.v.(", interface_name, "); swig_ok {\n", NULL); Printv(f_go_wrappers, "\t\t", NULL); if (SwigType_type(result) != T_VOID) { Printv(f_go_wrappers, "return ", NULL); } Printv(f_go_wrappers, "swig_g.", go_with_over_name, "(", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); if (i > 0) { Printv(f_go_wrappers, ", ", NULL); } Printv(f_go_wrappers, Getattr(p, "lname"), NULL); p = nextParm(p); } Printv(f_go_wrappers, ")\n", NULL); if (SwigType_type(result) == T_VOID) { Printv(f_go_wrappers, "\t\treturn\n", NULL); } Printv(f_go_wrappers, "\t}\n", NULL); if (GetFlag(n, "abstract")) { Printv(f_go_wrappers, "\tpanic(\"call to pure virtual method\")\n", NULL); } else { if (gccgo_flag) { Printv(f_go_wrappers, "\tdefer SwigCgocallDone()\n", NULL); Printv(f_go_wrappers, "\tSwigCgocall()\n", NULL); } Printv(f_go_wrappers, "\t", NULL); if (SwigType_type(result) != T_VOID) { Printv(f_go_wrappers, "return ", NULL); } Printv(f_go_wrappers, upcall_gc_name, "(swig_p.", go_type_name, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); SwigType *pt = Getattr(p, "type"); Printv(f_go_wrappers, ", ", Getattr(p, "lname"), NULL); if (goTypeIsInterface(p, pt)) { Printv(f_go_wrappers, ".Swigcptr()", NULL); } p = nextParm(p); } Printv(f_go_wrappers, ")\n", NULL); } Printv(f_go_wrappers, "}\n\n", NULL); // Define a method in the C++ director class that the C++ upcall // function can call. This permits an upcall to a protected // method. if (!GetFlag(n, "abstract")) { String *upcall_method_name = NewString("_swig_upcall_"); Append(upcall_method_name, name); if (overname) { Append(upcall_method_name, overname); } SwigType *rtype = Getattr(n, "classDirectorMethods:type"); String *upcall_decl = Swig_method_decl(rtype, Getattr(n, "decl"), upcall_method_name, parms, 0, 0); Printv(f_c_directors_h, " ", upcall_decl, " {\n", NULL); Delete(upcall_decl); Printv(f_c_directors_h, " ", NULL); if (SwigType_type(result) != T_VOID) { Printv(f_c_directors_h, "return ", NULL); } String *super_call = Swig_method_call(super, parms); Printv(f_c_directors_h, super_call, ";\n", NULL); Delete(super_call); Printv(f_c_directors_h, " }\n", NULL); // Define the C++ function that the Go function calls. SwigType *first_type = NULL; Parm *first_parm = parms; if (!is_static) { first_type = NewString("SwigDirector_"); Append(first_type, class_name); SwigType_add_pointer(first_type); first_parm = NewParm(first_type, "p", n); set_nextSibling(first_parm, parms); } Swig_save("classDirectorMethod", n, "wrap:name", "wrap:action", NULL); Setattr(n, "wrap:name", upcall_wname); String *action = NewString(""); if (SwigType_type(result) != T_VOID) { Printv(action, Swig_cresult_name(), " = (", SwigType_lstr(result, 0), ")", NULL); if (SwigType_isreference(result)) { Printv(action, "&", NULL); } } Printv(action, Swig_cparm_name(NULL, 0), "->", upcall_method_name, "(", NULL); p = parms; int i = 0; while (p != NULL) { if (SwigType_type(Getattr(p, "type")) != T_VOID) { String *pname = Swig_cparm_name(NULL, i + 1); if (i > 0) { Printv(action, ", ", NULL); } // A parameter whose type is a reference is converted into a // pointer type by gcCTypeForGoValue. We are calling a // function which expects a reference so we need to convert // back. if (SwigType_isreference(Getattr(p, "type"))) { Printv(action, "*", NULL); } Printv(action, pname, NULL); Delete(pname); i++; } p = nextSibling(p); } Printv(action, ");", NULL); Setattr(n, "wrap:action", action); if (!gccgo_flag) { // Write the upcall wrapper function. This is compiled by gc // and calls the C++ function. int r = gcFunctionWrapper(n, upcall_name, upcall_name, overname, upcall_wname, first_parm, result, is_static, true); if (r != SWIG_OK) { return r; } r = gccFunctionWrapper(n, NULL, upcall_wname, first_parm, result); if (r != SWIG_OK) { return r; } } else { int r = gccgoFunctionWrapper(n, NULL, upcall_wname, first_parm, result); if (r != SWIG_OK) { return r; } } Delete(first_type); if (first_parm != parms) { Delete(first_parm); } Swig_restore(n); Delete(upcall_method_name); // Define a function that uses the Go director type that other // methods in the Go type can call to get parent methods. Printv(f_go_wrappers, "func Director", cn, go_with_over_name, "(p ", cn, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); Printv(f_go_wrappers, ", ", Getattr(p, "lname"), " ", NULL); String *tm = goType(p, Getattr(p, "type")); Printv(f_go_wrappers, tm, NULL); Delete(tm); p = nextParm(p); } Printv(f_go_wrappers, ")", NULL); if (SwigType_type(result) != T_VOID) { String *tm = goType(n, result); Printv(f_go_wrappers, " ", tm, NULL); Delete(tm); } Printv(f_go_wrappers, " {\n", NULL); if (gccgo_flag) { Printv(f_go_wrappers, "\tdefer SwigCgocallDone()\n", NULL); Printv(f_go_wrappers, "\tSwigCgocall()\n", NULL); } Printv(f_go_wrappers, "\t", NULL); if (SwigType_type(result) != T_VOID) { Printv(f_go_wrappers, "return ", NULL); } Printv(f_go_wrappers, upcall_gc_name, "(p.(*", director_struct_name, ").", go_type_name, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); SwigType *pt = Getattr(p, "type"); Printv(f_go_wrappers, ", ", Getattr(p, "lname"), NULL); if (goTypeIsInterface(p, pt)) { Printv(f_go_wrappers, ".Swigcptr()", NULL); } p = nextParm(p); } Printv(f_go_wrappers, ")\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); } // The Go function which invokes the method. This is called // from by the C++ method on the director class. Printv(f_go_wrappers, "func ", callback_name, "(p *", director_struct_name, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); String *tm = goWrapperType(p, Getattr(p, "type"), false); Printv(f_go_wrappers, ", ", Getattr(p, "lname"), " ", tm, NULL); Delete(tm); p = nextParm(p); } Printv(f_go_wrappers, ") ", NULL); String *result_wrapper = NULL; if (SwigType_type(result) != T_VOID) { result_wrapper = goWrapperType(n, result, true); Printv(f_go_wrappers, "(swig_result ", result_wrapper, ") ", NULL); } Printv(f_go_wrappers, "{\n", NULL); if (gccgo_flag) { Printv(f_go_wrappers, "\tSwigCgocallBack()\n", NULL); Printv(f_go_wrappers, "\tdefer SwigCgocallBackDone()\n", NULL); } Printv(f_go_wrappers, "\t", NULL); if (is_ignored) { Printv(f_go_wrappers, "return\n", NULL); } else { bool result_is_interface = false; if (SwigType_type(result) != T_VOID) { Printv(f_go_wrappers, "return ", NULL); result_is_interface = goTypeIsInterface(NULL, result); if (result_is_interface) { Printv(f_go_wrappers, result_wrapper, "(", NULL); } } Printv(f_go_wrappers, "p.", go_with_over_name, "(", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); if (i > 0) { Printv(f_go_wrappers, ", ", NULL); } SwigType *pt = Getattr(p, "type"); // If the Go representation is an interface type class, then // we are receiving a uintptr, and must convert to the // interface. bool is_interface = goTypeIsInterface(p, pt); if (is_interface) { // Passing is_result as true to goWrapperType gives us the // name of the Go type we need to convert to an interface. String *wt = goWrapperType(p, pt, true); Printv(f_go_wrappers, wt, "(", NULL); Delete(wt); } Printv(f_go_wrappers, Getattr(p, "lname"), NULL); if (is_interface) { Printv(f_go_wrappers, ")", NULL); } p = nextParm(p); } Printv(f_go_wrappers, ")", NULL); if (result_is_interface) { Printv(f_go_wrappers, ".Swigcptr())", NULL); } Printv(f_go_wrappers, "\n", NULL); } Printv(f_go_wrappers, "}\n\n", NULL); Delete(result_wrapper); Delete(upcall_wname); Delete(upcall_gc_name); // Build the C++ functions. if (!gccgo_flag) { Printv(f_c_directors, "extern \"C\" void ", callback_wname, "(void*, int);\n", NULL); } else { Printv(f_c_directors, "extern \"C\" ", NULL); String *fnname = NewString(""); Printv(fnname, callback_wname, "(void*", NULL); p = parms; while (p) { while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } String *cg = gccgoCTypeForGoValue(p, Getattr(p, "type"), Getattr(p, "lname")); Printv(fnname, ", ", cg, NULL); Delete(cg); p = Getattr(p, "tmap:directorin:next"); } Printv(fnname, ")", NULL); if (SwigType_type(result) == T_VOID) { Printv(f_c_directors, "void ", fnname, NULL); } else { String *tm = gccgoCTypeForGoValue(n, result, fnname); Printv(f_c_directors, tm, NULL); Delete(tm); } Delete(fnname); Printv(f_c_directors, " __asm__(\"", go_prefix, ".", callback_name, "\");\n", NULL); } Delete(go_with_over_name); } if (!is_ignored || is_pure_virtual) { // Declare the method for the director class. SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); String *decl = Swig_method_decl(rtype, Getattr(n, "decl"), Getattr(n, "name"), parms, 0, 0); Printv(f_c_directors_h, " virtual ", decl, NULL); Delete(decl); String *qname = NewString(""); Printv(qname, "SwigDirector_", class_name, "::", Getattr(n, "name"), NULL); decl = Swig_method_decl(rtype, Getattr(n, "decl"), qname, parms, 0, 0); Printv(w->def, decl, NULL); Delete(decl); Delete(qname); String *throws = buildThrow(n); if (throws) { Printv(f_c_directors_h, " ", throws, NULL); Printv(w->def, " ", throws, NULL); Delete(throws); } Printv(f_c_directors_h, ";\n", NULL); Printv(w->def, " {\n", NULL); if (SwigType_type(result) != T_VOID) { Wrapper_add_local(w, "c_result", SwigType_lstr(result, "c_result")); } if (!is_ignored) { if (!gccgo_flag) { Printv(w->code, " struct {\n", NULL); Printv(w->code, " void *go_val;\n", NULL); p = parms; while (p) { while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } String *ln = Getattr(p, "lname"); String *cg = gcCTypeForGoValue(p, Getattr(p, "type"), ln); Printv(w->code, " ", cg, ";\n", NULL); Delete(cg); p = Getattr(p, "tmap:directorin:next"); } if (SwigType_type(result) != T_VOID) { Printv(w->code, " long : 0;\n", NULL); String *rname = NewString(Swig_cresult_name()); String *cg = gcCTypeForGoValue(n, result, rname); Printv(w->code, " ", cg, ";\n", NULL); Delete(cg); Delete(rname); } Printv(w->code, " } swig_a;\n", NULL); Printv(w->code, " swig_a.go_val = go_val;\n", NULL); p = parms; while (p) { while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } String *tm = Getattr(p, "tmap:directorin"); if (!tm) { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { String *ln = Getattr(p, "lname"); String *input = NewString(""); Printv(input, "swig_a.", ln, NULL); Setattr(p, "emit:directorinput", input); Replaceall(tm, "$input", input); Replaceall(tm, "$owner", "0"); Delete(input); Printv(w->code, "\t", tm, "\n", NULL); } p = Getattr(p, "tmap:directorin:next"); } Printv(w->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL); if (SwigType_type(result) != T_VOID) { String *result_str = NewString("c_result"); String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL); if (!tm) { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use type %s as director method result\n", SwigType_str(result, 0)); } else { static const String *swig_a_result = NewStringf("swig_a.%s", Swig_cresult_name()); Replaceall(tm, "$input", swig_a_result); Replaceall(tm, "$result", "c_result"); Printv(w->code, " ", tm, "\n", NULL); String *retstr = SwigType_rcaststr(result, "c_result"); Printv(w->code, " return ", retstr, ";\n", NULL); Delete(retstr); Delete(tm); } Delete(result_str); } // The C wrapper code which calls the Go function. Printv(f_gc_wrappers, "#pragma dynexport ", callback_wname, " ", callback_wname, "\n", NULL); Printv(f_gc_wrappers, "#pragma cgo_export_static ", callback_wname, " ", callback_wname, "\n", NULL); Printv(f_gc_wrappers, "#pragma textflag 7\n", NULL); Printv(f_gc_wrappers, "extern void \xc2\xb7", callback_name, "();\n", NULL); Printv(f_gc_wrappers, "void\n", NULL); Printv(f_gc_wrappers, callback_wname, "(void *a, int32 n)\n", NULL); Printv(f_gc_wrappers, "{\n", NULL); Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL); Printv(f_gc_wrappers, "}\n\n", NULL); } else { if (SwigType_type(result) != T_VOID) { String *r = NewString(Swig_cresult_name()); String *tm = gccgoCTypeForGoValue(n, result, r); Wrapper_add_local(w, r, tm); Delete(tm); Delete(r); } String *args = NewString(""); p = parms; while (p) { while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } String *pn = NewString("g"); Append(pn, Getattr(p, "lname")); Setattr(p, "emit:input", pn); String *tm = gccgoCTypeForGoValue(n, Getattr(p, "type"), pn); Wrapper_add_local(w, pn, tm); Delete(tm); tm = Getattr(p, "tmap:directorin"); if (!tm) { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { Replaceall(tm, "$input", pn); Replaceall(tm, "$owner", 0); Printv(w->code, " ", tm, "\n", NULL); Printv(args, ", ", pn, NULL); } p = Getattr(p, "tmap:directorin:next"); } Printv(w->code, " ", NULL); if (SwigType_type(result) != T_VOID) { Printv(w->code, Swig_cresult_name(), " = ", NULL); } Printv(w->code, callback_wname, "(go_val", args, ");\n", NULL); if (SwigType_type(result) != T_VOID) { String *result_str = NewString("c_result"); String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL); if (!tm) { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use type %s as director method result\n", SwigType_str(result, 0)); } else { Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$result", "c_result"); Printv(w->code, " ", tm, "\n", NULL); String *retstr = SwigType_rcaststr(result, "c_result"); Printv(w->code, " return ", retstr, ";\n", NULL); Delete(retstr); Delete(tm); } Delete(result_str); } } /* Marshal outputs */ for (p = parms; p;) { String *tm; if ((tm = Getattr(p, "tmap:directorargout"))) { Replaceall(tm, "$result", "jresult"); Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); } } } else { assert(is_pure_virtual); Printv(w->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL); if (SwigType_type(result) != T_VOID) { String *retstr = SwigType_rcaststr(result, "c_result"); Printv(w->code, " return ", retstr, ";\n", NULL); Delete(retstr); } } Printv(w->code, "}", NULL); Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_c_directors); } Delete(cn); Delete(go_type_name); Delete(director_struct_name); Delete(interface_name); Delete(upcall_name); Delete(callback_wname); Delete(go_name); DelWrapper(w); return SWIG_OK; } /* ------------------------------------------------------------ * classDirectorEnd * * Complete support for a director class. * ------------------------------------------------------------ */ int classDirectorEnd(Node *n) { (void) n; Printv(f_c_directors_h, " private:\n", NULL); Printv(f_c_directors_h, " void *go_val;\n", NULL); Printv(f_c_directors_h, "};\n\n", NULL); class_name = NULL; class_node = NULL; Delete(class_receiver); class_receiver = NULL; Delete(class_methods); class_methods = NULL; return SWIG_OK; } /* ------------------------------------------------------------ * classDirectorDisown * * I think Go does not require a disown method. * ------------------------------------------------------------ */ int classDirectorDisown(Node *n) { (void) n; return SWIG_OK; } /*---------------------------------------------------------------------- * buildThrow() * * Build and return a throw clause if needed. *--------------------------------------------------------------------*/ String *buildThrow(Node *n) { ParmList *throw_parm_list = Getattr(n, "throws"); if (!throw_parm_list && !Getattr(n, "throw")) return NULL; String *ret = NewString("throw("); if (throw_parm_list) { Swig_typemap_attach_parms("throws", throw_parm_list, NULL); } bool first = true; for (Parm *p = throw_parm_list; p; p = nextSibling(p)) { if (Getattr(p, "tmap:throws")) { if (first) { first = false; } else { Printv(ret, ", ", NULL); } String *s = SwigType_str(Getattr(p, "type"), 0); Printv(ret, s, NULL); Delete(s); } } Printv(ret, ")", NULL); return ret; } /*---------------------------------------------------------------------- * extraDirectorProtectedCPPMethodsRequired() * * We don't need to check upcall when calling methods. *--------------------------------------------------------------------*/ bool extraDirectorProtectedCPPMethodsRequired() const { return false; } /*---------------------------------------------------------------------- * makeDispatchFunction * * Make a dispatch function for an overloaded C++ function. The * receiver parameter is the receiver for a method, unless is_upcall * is true. If is_upcall is true, then the receiver parameter is * the type of the first argument to the function. *--------------------------------------------------------------------*/ int makeDispatchFunction(Node *n, String *go_name, String *receiver, bool is_static, SwigType *director_struct, bool is_upcall) { bool is_director = director_struct ? true : false; String *nodetype = Getattr(n, "nodeType"); bool is_constructor = Cmp(nodetype, "constructor") == 0; bool is_destructor = Cmp(nodetype, "destructor") == 0; bool can_use_receiver = (!is_constructor && !is_destructor && !is_upcall); bool use_receiver = (!is_static && can_use_receiver); bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !is_upcall); List *dispatch = Swig_overload_rank(n, false); int nfunc = Len(dispatch); SwigType *all_result; bool mismatch; if (is_constructor) { assert(!is_upcall); if (!is_director) { all_result = Copy(Getattr(class_node, "classtypeobj")); } else { all_result = Copy(director_struct); } mismatch = false; } else { all_result = NULL; mismatch = false; bool any_void = false; for (int i = 0; i < nfunc; ++i) { Node *nn = Getitem(dispatch, i); Node *ni = Getattr(nn, "directorNode") ? Getattr(nn, "directorNode") : nn; SwigType *result = Getattr(ni, "go:type"); assert(result); if (SwigType_type(result) == T_VOID) { if (all_result) { mismatch = true; } any_void = true; } else { if (any_void) { mismatch = true; } else if (!all_result) { all_result = Copy(result); } else if (Cmp(result, all_result) != 0) { mismatch = true; } } } if (mismatch) { Delete(all_result); all_result = NULL; } else if (all_result) { ; } else { all_result = NewString("void"); } } Printv(f_go_wrappers, "func ", NULL); if (receiver && use_receiver) { Printv(f_go_wrappers, "(p ", receiver, ") ", NULL); } Printv(f_go_wrappers, go_name, "(", NULL); if (is_director && is_constructor) { Printv(f_go_wrappers, "abi interface{}, ", NULL); assert(!add_to_interface); } if (is_upcall) { Printv(f_go_wrappers, "p *", receiver, ", ", NULL); assert(!add_to_interface); } Printv(f_go_wrappers, "a ...interface{})", NULL); if (add_to_interface) { Printv(interfaces, "\t", go_name, "(a ...interface{})", NULL); } if (mismatch) { Printv(f_go_wrappers, " interface{}", NULL); if (add_to_interface) { Printv(interfaces, " interface{}", NULL); } } else if (all_result && SwigType_type(all_result) != T_VOID) { if (is_director && is_constructor) { Printv(f_go_wrappers, " ", receiver, NULL); if (add_to_interface) { Printv(interfaces, " ", receiver, NULL); } } else { String *tm = goType(n, all_result); Printv(f_go_wrappers, " ", tm, NULL); if (add_to_interface) { Printv(interfaces, " ", tm, NULL); } Delete(tm); } } Printv(f_go_wrappers, " {\n", NULL); if (add_to_interface) { Printv(interfaces, "\n", NULL); } Printv(f_go_wrappers, "\targc := len(a)\n", NULL); for (int i = 0; i < nfunc; ++i) { int fn = 0; Node *nn = Getitem(dispatch, i); Node *ni = Getattr(nn, "directorNode") ? Getattr(nn, "directorNode") : nn; Parm *pi = Getattr(ni, "wrap:parms"); // If we are using a receiver, we want to ignore a leading self // parameter. Because of the way this is called, there may or // may not be a self parameter at this point. if (use_receiver && pi && Getattr(pi, "self")) { pi = getParm(pi); if (pi) { pi = nextParm(pi); } } int num_required = emit_num_required(pi); int num_arguments = emit_num_arguments(pi); bool varargs = emit_isvarargs(pi) ? true : false; if (varargs) { Printf(f_go_wrappers, "\tif argc >= %d {\n", num_required); } else { if (num_required == num_arguments) { Printf(f_go_wrappers, "\tif argc == %d {\n", num_required); } else { Printf(f_go_wrappers, "\tif argc >= %d && argc <= %d {\n", num_required, num_arguments); } } // Build list of collisions with the same number of arguments. List *coll = NewList(); for (int k = i + 1; k < nfunc; ++k) { Node *nnk = Getitem(dispatch, k); Node *nk = Getattr(nnk, "directorNode") ? Getattr(nnk, "directorNode") : nnk; Parm *pk = Getattr(nk, "wrap:parms"); if (use_receiver && pk && Getattr(pk, "self")) { pk = getParm(pk); if (pk) { pk = nextParm(pk); } } int nrk = emit_num_required(pk); int nak = emit_num_arguments(pk); if ((nrk >= num_required && nrk <= num_arguments) || (nak >= num_required && nak <= num_arguments) || (nrk <= num_required && nak >= num_arguments) || (varargs && nrk >= num_required)) { Append(coll, nk); } } int num_braces = 0; if (Len(coll) > 0 && num_arguments > 0) { int j = 0; Parm *pj = pi; while (pj) { pj = getParm(pj); if (!pj) { break; } // If all the wrappers have the same type in this position, // we can omit the check. SwigType *tm = goWrapperType(pj, Getattr(pj, "type"), true); bool emitcheck = false; for (int k = 0; k < Len(coll) && !emitcheck; ++k) { Node *nk = Getitem(coll, k); Parm *pk = Getattr(nk, "wrap:parms"); if (use_receiver && pk && Getattr(pk, "self")) { pk = getParm(pk); if (pk) { pk = nextParm(pk); } } int nak = emit_num_arguments(pk); if (nak <= j) continue; int l = 0; Parm *pl = pk; while (pl && l <= j) { pl = getParm(pl); if (!pl) { break; } if (l == j) { SwigType *tml = goWrapperType(pl, Getattr(pl, "type"), true); if (Cmp(tm, tml) != 0) { emitcheck = true; } Delete(tml); } pl = nextParm(pl); ++l; } } if (emitcheck) { if (j >= num_required) { Printf(f_go_wrappers, "\t\tif argc > %d {\n", j); ++num_braces; } fn = i + 1; Printf(f_go_wrappers, "\t\tif _, ok := a[%d].(%s); !ok {\n", j, tm); Printf(f_go_wrappers, "\t\t\tgoto check_%d\n", fn); Printv(f_go_wrappers, "\t\t}\n", NULL); } Delete(tm); pj = nextParm(pj); ++j; } } for (; num_braces > 0; --num_braces) { Printv(f_go_wrappers, "\t\t}\n", NULL); } // We may need to generate multiple calls if there are variable // argument lists involved. Build the start of the call. String *start = NewString(""); SwigType *result = Getattr(ni, "go:type"); if (is_constructor) { result = all_result; } else if (is_destructor) { result = NULL; } if (result && SwigType_type(result) != T_VOID && (!all_result || SwigType_type(all_result) != T_VOID)) { Printv(start, "return ", NULL); } bool advance_parm = false; if (receiver && use_receiver) { Printv(start, "p.", go_name, NULL); } else if (can_use_receiver && !isStatic(ni) && pi && Getattr(pi, "self")) { // This is an overload of a static function and a non-static // function. assert(num_required > 0); SwigType *tm = goWrapperType(pi, Getattr(pi, "type"), true); String *nm = buildGoName(Getattr(ni, "sym:name"), false, isFriend(ni)); Printv(start, "a[0].(", tm, ").", nm, NULL); Delete(nm); Delete(tm); advance_parm = true; } else { Printv(start, go_name, NULL); } Printv(start, Getattr(ni, "sym:overname"), "(", NULL); bool need_comma = false; if (is_director && is_constructor) { Printv(start, "abi", NULL); need_comma = true; } if (is_upcall) { Printv(start, "p", NULL); need_comma = true; } Parm *p = pi; int pn = 0; if (advance_parm) { p = getParm(p); if (p) { p = nextParm(p); } ++pn; } while (pn < num_required) { p = getParm(p); if (need_comma) { Printv(start, ", ", NULL); } SwigType *tm = goType(p, Getattr(p, "type")); Printf(start, "a[%d].(%s)", pn, tm); Delete(tm); need_comma = true; ++pn; p = nextParm(p); } String *end = NULL; if (!result || SwigType_type(result) == T_VOID || (all_result && SwigType_type(all_result) == T_VOID)) { end = NewString(""); Printv(end, "return", NULL); if (!all_result || SwigType_type(all_result) != T_VOID) { Printv(end, " 0", NULL); } } if (num_required == num_arguments) { Printv(f_go_wrappers, "\t\t", start, ")\n", NULL); if (end) { Printv(f_go_wrappers, "\t\t", end, "\n", NULL); } } else { Printv(f_go_wrappers, "\t\tswitch argc {\n", NULL); for (int j = num_required; j <= num_arguments; ++j) { Printf(f_go_wrappers, "\t\tcase %d:\n", j); Printv(f_go_wrappers, "\t\t\t", start, NULL); bool nc = need_comma; for (int k = num_required; k < j; ++k) { if (nc) { Printv(f_go_wrappers, ", ", NULL); } Printf(f_go_wrappers, "a[%d]", k); nc = true; } Printv(f_go_wrappers, ")\n", NULL); if (end) { Printv(f_go_wrappers, "\t\t\t", end, "\n", NULL); } } Printv(f_go_wrappers, "\t\t}\n", NULL); } Printv(f_go_wrappers, "\t}\n", NULL); if (fn != 0) { Printf(f_go_wrappers, "check_%d:\n", fn); } Delete(coll); } Printv(f_go_wrappers, "\tpanic(\"No match for overloaded function call\")\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); Delete(all_result); Delete(dispatch); return SWIG_OK; } /* ---------------------------------------------------------------------- * checkFunctionVisibility() * * Return true if we should write out a function based on its * visibility, false otherwise. * ---------------------------------------------------------------------- */ bool checkFunctionVisibility(Node *n, Node *parent) { // Write out a public function. if (is_public(n)) return true; // Don't write out a private function. if (is_private(n)) return false; // Write a protected function for a director class in // dirprot_mode. if (parent == NULL) { return false; } if (dirprot_mode() && Swig_directorclass(parent)) return true; // Otherwise don't write out a protected function. return false; } /* ---------------------------------------------------------------------- * exportedName() * * Given a C/C++ name, return a name in Go which will be exported. * If the first character is an upper case letter, this returns a * copy of its argment. If the first character is a lower case * letter, this forces it to upper case. Otherwise, this prepends * 'X'. * ---------------------------------------------------------------------- */ String *exportedName(String *name) { String *copy = Copy(name); char c = *Char(copy); if (islower(c)) { char l[2]; char u[2]; l[0] = c; l[1] = '\0'; u[0] = toupper(c); u[1] = '\0'; Replace(copy, l, u, DOH_REPLACE_FIRST); } else if (!isalpha(c)) { char l[2]; char u[3]; l[0] = c; l[1] = '\0'; u[0] = 'X'; u[1] = c; u[2] = '\0'; Replace(copy, l, u, DOH_REPLACE_FIRST); } String *ret = Swig_name_mangle(copy); Delete(copy); return ret; } /* ---------------------------------------------------------------------- * removeClassname() * * If the name starts with the current class name, followed by an * underscore, remove it. If there is no current class name, this * simply returns a copy of the name. This undoes Swig's way of * recording the class name in a member name. * ---------------------------------------------------------------------- */ String *removeClassname(String *name) { String *copy = Copy(name); if (class_name) { char *p = Char(name); if (Strncmp(name, class_name, Len(class_name)) == 0 && p[Len(class_name)] == '_') { Replace(copy, class_name, "", DOH_REPLACE_FIRST); Replace(copy, "_", "", DOH_REPLACE_FIRST); } } return copy; } /* ---------------------------------------------------------------------- * buildGoName() * * Build the name to use for an ordinary function, variable, or * whatever in Go. The name argument is something like the sym:name * attribute of the node. If is_static is false, this could be a * method, and the returned name will be the name of the * method--i.e., it will not include the class name. * ---------------------------------------------------------------------- */ String *buildGoName(String *name, bool is_static, bool is_friend) { String *nw = NewString(""); if (is_static && !is_friend && class_name) { String *c1 = exportedName(class_name); Append(nw, c1); Delete(c1); } String *c2 = removeClassname(name); String *c3 = exportedName(c2); Append(nw, c3); Delete(c2); Delete(c3); String *ret = Swig_name_mangle(nw); Delete(nw); return ret; } /* ---------------------------------------------------------------------- * buildGoWrapperName() * * Build the name to use for a Go wrapper function. This is a * function called by the real Go function in order to convert C++ * classes from interfaces to pointers, and other such conversions * between the Go type and the C++ type. * ---------------------------------------------------------------------- */ String *buildGoWrapperName(String *name, String *overname) { String *s1 = NewString("_swig_wrap_"); Append(s1, name); String *s2 = Swig_name_mangle(s1); Delete(s1); if (overname) { Append(s2, overname); } return s2; } /* ---------------------------------------------------------------------- * checkNameConflict() * * Check for a name conflict on the name we are going to use in Go. * These conflicts are likely because of the enforced * capitalization. When we find one, issue a warning and return * false. If the name is OK, return true. * ---------------------------------------------------------------------- */ bool checkNameConflict(String* name, Node* n, const_String_or_char_ptr scope) { Node *lk = symbolLookup(name, scope); if (lk) { String *n1 = Getattr(n, "sym:name"); if (!n1) { n1 = Getattr(n, "name"); } String *n2 = Getattr(lk, "sym:name"); if (!n2) { n2 = Getattr(lk, "name"); } Swig_warning(WARN_GO_NAME_CONFLICT, input_file, line_number, "Ignoring '%s' due to Go name ('%s') conflict with '%s'\n", n1, name, n2); return false; } bool r = addSymbol(name, n, scope) ? true : false; assert(r); return true; } /* ---------------------------------------------------------------------- * checkIgnoredParameters() * * If any of the parameters of this function, or the return type, * are ignored due to a name conflict, give a warning and return * false. * ---------------------------------------------------------------------- */ bool checkIgnoredParameters(Node *n, String *go_name) { ParmList *parms = Getattr(n, "parms"); if (parms) { Wrapper *dummy = NewWrapper(); emit_attach_parmmaps(parms, dummy); int parm_count = emit_num_arguments(parms); Parm *p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); if (!checkIgnoredType(n, go_name, Getattr(p, "type"))) { DelWrapper(dummy); return false; } p = nextParm(p); } DelWrapper(dummy); } if (!checkIgnoredType(n, go_name, Getattr(n, "type"))) { return false; } return true; } /* ---------------------------------------------------------------------- * checkIgnoredType() * * If this type is being ignored due to a name conflict, give a * warning and return false. * ---------------------------------------------------------------------- */ bool checkIgnoredType(Node *n, String *go_name, SwigType *type) { if (hasGoTypemap(n, type)) { return true; } SwigType *t = SwigType_typedef_resolve_all(type); bool ret = true; bool is_conflict = false; Node *e = Language::enumLookup(t); if (e) { if (GetFlag(e, "go:conflict")) { is_conflict = true; } } else if (SwigType_issimple(t)) { Node *cn = classLookup(t); if (cn) { if (GetFlag(cn, "go:conflict")) { is_conflict = true; } } } else if (SwigType_ispointer(t) || SwigType_isarray(t) || SwigType_isqualifier(t) || SwigType_isreference(t)) { SwigType *r = Copy(t); if (SwigType_ispointer(r)) { SwigType_del_pointer(r); } else if (SwigType_isarray(r)) { SwigType_del_array(r); } else if (SwigType_isqualifier(r)) { SwigType_del_qualifier(r); } else { SwigType_del_reference(r); } if (!checkIgnoredType(n, go_name, r)) { ret = false; } Delete(r); } if (is_conflict) { String *s = SwigType_str(t, NULL); Swig_warning(WARN_GO_NAME_CONFLICT, input_file, line_number, "Ignoring '%s' (Go name '%s') due to Go name conflict for parameter or result type '%s'\n", Getattr(n, "name"), go_name, s); Delete(s); ret = false; } Delete(t); return ret; } /* ---------------------------------------------------------------------- * goType() * * Given a SWIG type, return a string for the type in Go. * ---------------------------------------------------------------------- */ String *goType(Node *n, SwigType *type) { return goTypeWithInfo(n, type, NULL); } /* ---------------------------------------------------------------------- * goTypeWithInfo() * * Like goType, but return some more information. * * If the p_is_interface parameter is not NULL, this sets * *p_is_interface to indicate whether this type is going to be * represented by a Go interface type. These are cases where the Go * code needs to make some adjustments when passing values back and * forth with C/C++. * ---------------------------------------------------------------------- */ String *goTypeWithInfo(Node *n, SwigType *type, bool *p_is_interface) { if (p_is_interface) { *p_is_interface = false; } String *ret; if (n && Cmp(type, Getattr(n, "type")) == 0) { ret = NULL; if (Strcmp(Getattr(n, "nodeType"), "parm") == 0) { ret = Getattr(n, "tmap:gotype"); } if (!ret) { ret = Swig_typemap_lookup("gotype", n, "", NULL); } } else { Parm *p = NewParm(type, "goType", n); ret = Swig_typemap_lookup("gotype", p, "", NULL); Delete(p); } if (ret && Strstr(ret, "$gotypename") != 0) { ret = NULL; } if (ret) { return Copy(ret); } SwigType *t = SwigType_typedef_resolve_all(type); if (SwigType_isenum(t)) { Node *e = Language::enumLookup(t); if (e) { ret = goEnumName(e); } else if (Strcmp(t, "enum ") == 0) { ret = NewString("int"); } else { // An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) or an ignored enum String *tt = Copy(t); Replace(tt, "enum ", "", DOH_REPLACE_ANY); ret = exportedName(tt); Setattr(undefined_enum_types, t, ret); Delete(tt); } } else if (SwigType_isfunctionpointer(type) || SwigType_isfunction(type)) { ret = NewString("_swig_fnptr"); } else if (SwigType_ismemberpointer(type)) { ret = NewString("_swig_memberptr"); } else if (SwigType_issimple(t)) { Node *cn = classLookup(t); if (cn) { ret = Getattr(cn, "sym:name"); if (!ret) { ret = Getattr(cn, "name"); } ret = exportedName(ret); Node *cnmod = Getattr(cn, "module"); if (!cnmod || Strcmp(Getattr(cnmod, "name"), module) == 0) { Setattr(undefined_types, t, t); } else { String *nw = NewString(""); Printv(nw, Getattr(cnmod, "name"), ".", ret, NULL); Delete(ret); ret = nw; } } else { // SWIG does not know about this type. ret = exportedName(t); Setattr(undefined_types, t, t); } if (p_is_interface) { *p_is_interface = true; } } else if (SwigType_ispointer(t) || SwigType_isarray(t)) { SwigType *r = Copy(t); if (SwigType_ispointer(r)) { SwigType_del_pointer(r); } else { SwigType_del_array(r); } if (SwigType_type(r) == T_VOID) { ret = NewString("uintptr"); } else { bool is_interface; String *base = goTypeWithInfo(n, r, &is_interface); // At the Go level, an unknown or class type is handled as an // interface wrapping a pointer. This means that if a // function returns the C type X, we will be wrapping the C // type X*. In Go we will call that type X. That means that // if a C function expects X*, we can pass the Go type X. And // that means that when we see the C type X*, we should use // the Go type X. // The is_interface variable tells us this. However, it will // be true both for the case of X and for the case of X*. If // r is a pointer here, then we are looking at X**. There is // really no good way for us to handle that. bool is_pointer_to_pointer = false; if (is_interface) { SwigType *c = Copy(r); if (SwigType_isqualifier(c)) { SwigType_del_qualifier(c); if (SwigType_ispointer(c) || SwigType_isarray(c)) { is_pointer_to_pointer = true; } } Delete(c); } if (is_interface) { if (!is_pointer_to_pointer) { ret = base; if (p_is_interface) { *p_is_interface = true; } } else { ret = NewString("uintptr"); } } else { ret = NewString("*"); Append(ret, base); Delete(base); } } Delete(r); } else if (SwigType_isreference(t)) { SwigType *r = Copy(t); SwigType_del_reference(r); // If this is a const reference, and we are looking at a pointer // to it, then we just use the pointer we already have. bool add_pointer = true; if (SwigType_isqualifier(r)) { String *q = SwigType_parm(r); if (Strcmp(q, "const") == 0) { SwigType *c = Copy(r); SwigType_del_qualifier(c); if (SwigType_ispointer(c)) { add_pointer = false; } Delete(c); } } if (add_pointer) { SwigType_add_pointer(r); } ret = goTypeWithInfo(n, r, p_is_interface); Delete(r); } else if (SwigType_isqualifier(t)) { SwigType *r = Copy(t); SwigType_del_qualifier(r); ret = goTypeWithInfo(n, r, p_is_interface); Delete(r); } else if (SwigType_isvarargs(t)) { ret = NewString("[]interface{}"); } Delete(t); if (!ret) { Swig_warning(WARN_LANG_NATIVE_UNIMPL, input_file, line_number, "No Go typemap defined for %s\n", SwigType_str(type, 0)); ret = NewString("uintptr"); } return ret; } /* ---------------------------------------------------------------------- * goWrapperType() * * Given a type, return a string for the type to use for the wrapped * Go function. This function exists because for a C++ class we * need to convert interface and reference types. * ---------------------------------------------------------------------- */ String *goWrapperType(Node *n, SwigType *type, bool is_result) { bool is_interface; String *ret = goTypeWithInfo(n, type, &is_interface); // If this is an interface, we want to pass the real type. if (is_interface) { Delete(ret); if (!is_result) { ret = NewString("uintptr"); } else { SwigType *ty = SwigType_typedef_resolve_all(type); while (true) { if (SwigType_ispointer(ty)) { SwigType_del_pointer(ty); } else if (SwigType_isarray(ty)) { SwigType_del_array(ty); } else if (SwigType_isreference(ty)) { SwigType_del_reference(ty); } else if (SwigType_isqualifier(ty)) { SwigType_del_qualifier(ty); } else { break; } } assert(SwigType_issimple(ty)); String *p = goCPointerType(ty, true); Delete(ty); ret = p; } } return ret; } /* ---------------------------------------------------------------------- * goCPointerType() * * Return the name of the Go type to use for the C pointer value. * The regular C type is the name of an interface type which wraps a * pointer whose name is returned by this function. * ---------------------------------------------------------------------- */ String *goCPointerType(SwigType *type, bool add_to_hash) { SwigType *ty = SwigType_typedef_resolve_all(type); Node *cn = classLookup(ty); String *ex; String *ret; if (!cn) { if (add_to_hash) { Setattr(undefined_types, ty, ty); } ret = NewString("Swigcptr"); ex = exportedName(ty); Append(ret, ex); } else { String *cname = Getattr(cn, "sym:name"); if (!cname) { cname = Getattr(cn, "name"); } ex = exportedName(cname); Node *cnmod = Getattr(cn, "module"); if (!cnmod || Strcmp(Getattr(cnmod, "name"), module) == 0) { if (add_to_hash) { Setattr(undefined_types, ty, ty); } ret = NewString("Swigcptr"); Append(ret, ex); } else { ret = NewString(""); Printv(ret, Getattr(cnmod, "name"), ".Swigcptr", ex, NULL); } } Delete(ty); Delete(ex); return ret; } /* ---------------------------------------------------------------------- * gcCTypeForGoValue() * * Given a type, return the C/C++ type which will be used to catch * the value in Go. This is the 6g/8g version. * ---------------------------------------------------------------------- */ String *gcCTypeForGoValue(Node *n, SwigType *type, String *name) { bool is_interface; String *gt = goTypeWithInfo(n, type, &is_interface); bool is_string = Strcmp(gt, "string") == 0; bool is_slice = Strncmp(gt, "[]", 2) == 0; bool is_function = Strcmp(gt, "_swig_fnptr") == 0; bool is_member = Strcmp(gt, "_swig_memberptr") == 0; bool is_complex64 = Strcmp(gt, "complex64") == 0; bool is_complex128 = Strcmp(gt, "complex128") == 0; bool is_int8 = false; bool is_int16 = false; bool is_int = Strcmp(gt, "int") == 0 || Strcmp(gt, "uint") == 0; bool is_int32 = false; bool is_int64 = false; bool is_float32 = false; bool is_float64 = false; if ((n != NULL && Getattr(n, "tmap:gotype") != NULL) || hasGoTypemap(n, type)) { is_int8 = Strcmp(gt, "int8") == 0 || Strcmp(gt, "uint8") == 0 || Strcmp(gt, "byte") == 0; is_int16 = Strcmp(gt, "int16") == 0 || Strcmp(gt, "uint16") == 0; is_int32 = Strcmp(gt, "int32") == 0 || Strcmp(gt, "uint32") == 0; is_int64 = Strcmp(gt, "int64") == 0 || Strcmp(gt, "uint64") == 0; is_float32 = Strcmp(gt, "float32") == 0; is_float64 = Strcmp(gt, "float64") == 0; } Delete(gt); String *ret; if (is_string) { // Note that we don't turn a reference to a string into a // pointer to a string. Strings are immutable anyhow. ret = NewString("_gostring_ "); Append(ret, name); return ret; } else if (is_slice) { // Slices are always passed as a _goslice_, whether or not references // are involved. ret = NewString("_goslice_ "); Append(ret, name); return ret; } else if (is_function || is_member) { ret = NewString("void *"); Append(ret, name); return ret; } else if (is_complex64) { ret = NewString("_Complex float "); } else if (is_complex128) { ret = NewString("_Complex double "); } else if (is_interface) { SwigType *t = SwigType_typedef_resolve_all(type); if (SwigType_ispointer(t)) { SwigType_del_pointer(t); } if (SwigType_isreference(t)) { SwigType_del_reference(t); } SwigType_add_pointer(t); ret = SwigType_lstr(t, name); Delete(t); return ret; } else { SwigType *t = SwigType_typedef_resolve_all(type); if (SwigType_isreference(t)) { // A const reference to a known type, or to a pointer, is not // mapped to a pointer. SwigType_del_reference(t); if (SwigType_isqualifier(t)) { String *q = SwigType_parm(t); if (Strcmp(q, "const") == 0) { SwigType_del_qualifier(t); if (hasGoTypemap(n, t) || SwigType_ispointer(t)) { if (is_int) { ret = NewString("intgo "); Append(ret, name); } else if (is_int64) { ret = NewString("long long "); Append(ret, name); } else { ret = SwigType_lstr(t, name); } Delete(q); Delete(t); return ret; } } Delete(q); } } if (Language::enumLookup(t) != NULL) { is_int = true; } else { SwigType *tstripped = SwigType_strip_qualifiers(t); if (SwigType_isenum(tstripped)) is_int = true; Delete(tstripped); } Delete(t); if (is_int8) { ret = NewString("char "); } else if (is_int16) { ret = NewString("short "); } else if (is_int) { ret = NewString("intgo "); } else if (is_int32) { ret = NewString("int "); } else if (is_int64) { ret = NewString("long long "); } else if (is_float32) { ret = NewString("float "); } else if (is_float64) { ret = NewString("double "); } else { return SwigType_lstr(type, name); } } if (SwigType_isreference(type)) { Append(ret, "* "); } Append(ret, name); return ret; } /* ---------------------------------------------------------------------- * gccgoCTypeForGoValue() * * Given a type, return the C/C++ type which will be used to catch * the value in Go. This is the gccgo version. * ---------------------------------------------------------------------- */ String *gccgoCTypeForGoValue(Node *n, SwigType *type, String *name) { return gcCTypeForGoValue(n, type, name); } /* ---------------------------------------------------------------------- * goTypeIsInterface * * Return whether this C++ type is represented as an interface type * in Go. These types require adjustments in the Go code when * passing them back and forth between Go and C++. * ---------------------------------------------------------------------- */ bool goTypeIsInterface(Node *n, SwigType *type) { bool is_interface; Delete(goTypeWithInfo(n, type, &is_interface)); return is_interface; } /* ---------------------------------------------------------------------- * hasGoTypemap * * Return whether a type has a "gotype" typemap entry. * ---------------------------------------------------------------------- */ bool hasGoTypemap(Node *n, SwigType *type) { Parm *p = NewParm(type, "test", n); SwigType *tm = Swig_typemap_lookup("gotype", p, "", NULL); Delete(p); if (tm && Strstr(tm, "$gotypename") == 0) { Delete(tm); return true; } Delete(tm); return false; } /* ---------------------------------------------------------------------- * goEnumName() * * Given an enum node, return a string to use for the enum type in Go. * ---------------------------------------------------------------------- */ String *goEnumName(Node *n) { String *ret = Getattr(n, "go:enumname"); if (ret) { return Copy(ret); } if (Equal(Getattr(n, "type"), "enum ")) { return NewString("int"); } String *type = Getattr(n, "enumtype"); assert(type); char *p = Char(type); int len = Len(type); String *s = NewString(""); bool capitalize = true; for (int i = 0; i < len; ++i, ++p) { if (*p == ':') { ++i; ++p; assert(*p == ':'); capitalize = true; } else if (capitalize) { Putc(toupper(*p), s); capitalize = false; } else { Putc(*p, s); } } ret = Swig_name_mangle(s); Delete(s); return ret; } /* ---------------------------------------------------------------------- * getParm() * * Get the real parameter to use. * ---------------------------------------------------------------------- */ Parm *getParm(Parm *p) { while (p && checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } return p; } /* ---------------------------------------------------------------------- * nextParm() * * Return the next parameter. * ---------------------------------------------------------------------- */ Parm *nextParm(Parm *p) { if (!p) { return NULL; } else if (Getattr(p, "tmap:in")) { return Getattr(p, "tmap:in:next"); } else { return nextSibling(p); } } /* ---------------------------------------------------------------------- * isStatic * * Return whether a node should be considered as static rather than * as a member. * ---------------------------------------------------------------------- */ bool isStatic(Node *n) { String *storage = Getattr(n, "storage"); return (storage && (Swig_storage_isstatic(n) || Strcmp(storage, "friend") == 0) && (!SmartPointer || !Getattr(n, "allocate:smartpointeraccess"))); } /* ---------------------------------------------------------------------- * isFriend * * Return whether a node is a friend. * ---------------------------------------------------------------------- */ bool isFriend(Node *n) { String *storage = Getattr(n, "storage"); return storage && Strcmp(storage, "friend") == 0; } }; /* class GO */ /* ----------------------------------------------------------------------------- * swig_go() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_go() { return new GO(); } extern "C" Language *swig_go(void) { return new_swig_go(); } /* ----------------------------------------------------------------------------- * Static member variables * ----------------------------------------------------------------------------- */ // Usage message. const char * const GO::usage = "\ Go Options (available with -go)\n\ -gccgo - Generate code for gccgo rather than 6g/8g\n\ -go-pkgpath

- Like gccgo -fgo-pkgpath option\n\ -go-prefix

- Like gccgo -fgo-prefix option\n\ -intgosize - Set size of Go int type--32 or 64 bits\n\ -package - Set name of the Go package to \n\ -use-shlib - Force use of a shared library\n\ -soname - Set shared library holding C/C++ code to \n\ \n"; swig-3.0.2/Source/Modules/lua.cxx0000664000175000017500000025270412343605122016532 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * lua.cxx * * Lua language module for SWIG. * ----------------------------------------------------------------------------- */ /* NEW LANGUAGE NOTE: * ver001 this is simply a copy of tcl8.cxx, which has been renamed * ver002 all non essential code commented out, program now does virtually nothing it prints to stderr the list of functions to wrap, but does not create the XXX_wrap.c file * ver003 added back top(), still prints the list of fns to stderr but now creates a rather empty XXX_wrap.c with some basic boilerplate code * ver004 very basic version of functionWrapper() also uncommented usage_string() to keep compiler happy this will start producing proper looking code soon (I hope) produced the wrapper code, but without any type conversion (in or out) generates a few warning because of no wrappering does not generate SWIG_init() reason for this is that lua.swg is empty we will need to add code into this to make it work * ver005/6 massive rework, basing work on the pike module instead of tcl (pike module it only 1/3 of the size)(though not as complete) * ver007 added simple type checking * ver008 INPUT, OUTPUT, INOUT typemaps handled (though not all types yet) * ver009 class support: ok for basic types, but methods still TDB (code is VERY messed up & needs to be cleaned) * ver010 Added support for embedded Lua. Try swig -lua -help for more information */ #include "swigmod.h" #include "cparse.h" /**** Diagnostics: With the #define REPORT(), you can change the amount of diagnostics given This helps me search the parse tree & figure out what is going on inside SWIG (because its not clear or documented) */ #define REPORT(T,D) // no info: //#define REPORT(T,D) {Printf(stdout,T"\n");} // only title //#define REPORT(T,D) {Printf(stdout,T" %p\n",n);} // title & pointer //#define REPORT(T,D) {Printf(stdout,T"\n");display_mapping(D);} // the works //#define REPORT(T,D) {Printf(stdout,T"\n");if(D)Swig_print_node(D);} // the works void display_mapping(DOH *d) { if (d == 0 || !DohIsMapping(d)) return; for (Iterator it = First(d); it.item; it = Next(it)) { if (DohIsString(it.item)) Printf(stdout, " %s = %s\n", it.key, it.item); else if (DohIsMapping(it.item)) Printf(stdout, " %s = \n", it.key); else if (DohIsSequence(it.item)) Printf(stdout, " %s = \n", it.key); else Printf(stdout, " %s = \n", it.key); } } extern "C" { static int compareByLen(const DOH *f, const DOH *s) { return Len(s) - Len(f); } } /* NEW LANGUAGE NOTE:*********************************************** most of the default options are handled by SWIG you can add new ones here (though for now I have not bothered) NEW LANGUAGE NOTE:END ************************************************/ static const char *usage = "\ Lua Options (available with -lua)\n\ -elua - Generates LTR compatible wrappers for smaller devices running elua\n\ -eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\ -elua-emulate - Emulates behaviour of eLua. Useful only for testing.\n\ Incompatible with -elua/-eluac options.\n\ -nomoduleglobal - Do not register the module name as a global variable \n\ but return the module table from calls to require.\n\ -no-old-metatable-bindings\n\ - Disable support for old-style bindings name generation, some\n\ old-style members scheme etc.\n\ -squash-bases - Squashes symbols from all inheritance tree of a given class\n\ into itself. Emulates pre-SWIG3.0 inheritance. Insignificantly\n\ speeds things up, but increases memory consumption.\n\ \n"; static int nomoduleglobal = 0; static int elua_ltr = 0; static int eluac_ltr = 0; static int elua_emulate = 0; static int squash_bases = 0; /* The new metatable bindings were introduced in SWIG 3.0.0. * old_metatable_bindings in v2: * 1. static methods will be put into the scope their respective class * belongs to as well as into the class scope itself. (only for classes without %nspace given) * 2. The layout in elua mode is somewhat different */ static int old_metatable_bindings = 1; static int old_compatible_names = 1; // This flag can temporarily disable backward compatible names generation if old_metatable_bindings is enabled /* NEW LANGUAGE NOTE:*********************************************** To add a new language, you need to derive your class from Language and the overload various virtual functions (more on this as I figure it out) NEW LANGUAGE NOTE:END ************************************************/ class LUA:public Language { private: File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; File *f_init; File *f_initbeforefunc; String *s_luacode; // luacode to be called during init String *module; //name of the module // Parameters for current class. NIL if not parsing class int have_constructor; int have_destructor; String *destructor_action; // This variable holds the name of the current class in Lua. Usually it is // the same as C++ class name, but rename directives can change it. String *proxy_class_name; // This is a so calld fully qualified symname - the above proxy class name // prepended with class namespace. If class Lua name is the same as class C++ name, // then it is basically C++ fully qualified name with colons replaced with dots. String *full_proxy_class_name; // All static methods and/or variables are treated as if they were in the // special C++ namespace $(classname).SwigStatic. This is internal mechanism only // and is not visible to user in any manner. This variable holds the name // of such pseudo-namespace a.k.a the result of above expression evaluation String *class_static_nspace; // This variable holds the name of generated C function that acts as a constructor // for the currently parsed class. String *constructor_name; // Many wrappers forward calls to each other, for example staticmembervariableHandler // forwards calls to variableHandler, which, in turn, makes to call to functionWrapper. // In order to access information about whether it is a static member of class or just // a plain old variable, the current array is kept and used as a 'log' of the call stack. enum TState { NO_CPP, VARIABLE, GLOBAL_FUNC, GLOBAL_VAR, MEMBER_FUNC, CONSTRUCTOR, DESTRUCTOR, MEMBER_VAR, STATIC_FUNC, STATIC_VAR, STATIC_CONST, // enums and things like static const int x = 5; ENUM_CONST, // This is only needed for backward compatibility in C mode STATES_COUNT }; bool current[STATES_COUNT]; public: /* --------------------------------------------------------------------- * LUA() * * Initialize member data * --------------------------------------------------------------------- */ LUA(): f_begin(0), f_runtime(0), f_header(0), f_wrappers(0), f_init(0), f_initbeforefunc(0), s_luacode(0), module(0), have_constructor(0), have_destructor(0), destructor_action(0), proxy_class_name(0), full_proxy_class_name(0), class_static_nspace(0), constructor_name(0) { for (int i = 0; i < STATES_COUNT; i++) current[i] = false; } /* NEW LANGUAGE NOTE:*********************************************** This is called to initialise the system & read any command line args most of this is boilerplate code, except the command line args which depends upon what args your code supports NEW LANGUAGE NOTE:END *********************************************** */ /* --------------------------------------------------------------------- * main() * * Parse command line options and initializes variables. * --------------------------------------------------------------------- */ virtual void main(int argc, char *argv[]) { /* Set location of SWIG library */ SWIG_library_directory("lua"); /* Look for certain command line options */ for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { // usage flags fputs(usage, stdout); } else if (strcmp(argv[i], "-nomoduleglobal") == 0) { nomoduleglobal = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-elua") == 0) { elua_ltr = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-eluac") == 0) { eluac_ltr = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-no-old-metatable-bindings") == 0) { Swig_mark_arg(i); old_metatable_bindings = 0; } else if (strcmp(argv[i], "-squash-bases") == 0) { Swig_mark_arg(i); squash_bases = 1; } else if (strcmp(argv[i], "-elua-emulate") == 0) { Swig_mark_arg(i); elua_emulate = 1; } } } if (elua_emulate && (eluac_ltr || elua_ltr )) { Printf(stderr, "Cannot have -elua-emulate with either -eluac or -elua\n"); Swig_arg_error(); } // Set elua_ltr if elua_emulate is requested if(elua_emulate) elua_ltr = 1; /* NEW LANGUAGE NOTE:*********************************************** This is the boilerplate code, setting a few #defines and which lib directory to use the SWIG_library_directory() is also boilerplate code but it always seems to be the first line of code NEW LANGUAGE NOTE:END *********************************************** */ /* Add a symbol to the parser for conditional compilation */ Preprocessor_define("SWIGLUA 1", 0); /* Set language-specific configuration file */ SWIG_config_file("lua.swg"); /* Set typemap language */ SWIG_typemap_lang("lua"); /* Enable overloaded methods support */ allow_overloading(); } /* NEW LANGUAGE NOTE:*********************************************** After calling main, SWIG parses the code to wrap (I believe) then calls top() in this is more boilerplate code to set everything up and a call to Language::top() which begins the code generations by calling the member fns after all that is more boilerplate code to close all down (overall there is virtually nothing here that needs to be edited just use as is) NEW LANGUAGE NOTE:END *********************************************** */ /* --------------------------------------------------------------------- * top() * --------------------------------------------------------------------- */ virtual int top(Node *n) { /* Get the module name */ module = Getattr(n, "name"); /* Get the output file name */ String *outfile = Getattr(n, "outfile"); /* Open the output file */ f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); f_initbeforefunc = NewString(""); /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("initbeforefunc", f_initbeforefunc); s_luacode = NewString(""); Swig_register_filebyname("luacode", s_luacode); current[NO_CPP] = true; /* Standard stuff for the SWIG runtime section */ Swig_banner(f_begin); Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGLUA\n"); emitLuaFlavor(f_runtime); if (nomoduleglobal) { Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n"); } else { Printf(f_runtime, "#define SWIG_LUA_MODULE_GLOBAL\n"); } if (squash_bases) Printf(f_runtime, "#define SWIG_LUA_SQUASH_BASES\n"); // if (NoInclude) { // Printf(f_runtime, "#define SWIG_NOINCLUDE\n"); // } Printf(f_runtime, "\n"); //String *init_name = NewStringf("%(title)s_Init", module); //Printf(f_header, "#define SWIG_init %s\n", init_name); //Printf(f_header, "#define SWIG_name \"%s\"\n", module); /* SWIG_import is a special function name for importing within Lua5.1 */ //Printf(f_header, "#define SWIG_import luaopen_%s\n\n", module); Printf(f_header, "#define SWIG_name \"%s\"\n", module); Printf(f_header, "#define SWIG_init luaopen_%s\n", module); Printf(f_header, "#define SWIG_init_user luaopen_%s_user\n\n", module); Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n", module); Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); /* %init code inclusion, effectively in the SWIG_init function */ Printf(f_init, "void SWIG_init_user(lua_State* L)\n{\n"); Language::top(n); Printf(f_init, "/* exec Lua code if applicable */\nSWIG_Lua_dostring(L,SWIG_LUACODE);\n"); Printf(f_init, "}\n"); // Done. Close up the module & write to the wrappers closeNamespaces(f_wrappers); Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n"); SwigType_emit_type_table(f_runtime, f_wrappers); /* NEW LANGUAGE NOTE:*********************************************** this basically combines several of the strings together and then writes it all to a file NEW LANGUAGE NOTE:END *********************************************** */ Dump(f_runtime, f_begin); Dump(f_header, f_begin); Dump(f_wrappers, f_begin); Dump(f_initbeforefunc, f_begin); /* for the Lua code it needs to be properly escaped to be added into the C/C++ code */ escapeCode(s_luacode); Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n", s_luacode); Wrapper_pretty_print(f_init, f_begin); /* Close all of the files */ Delete(s_luacode); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_initbeforefunc); Delete(f_runtime); Delete(f_begin); /* Done */ return SWIG_OK; } /* ------------------------------------------------------------ * importDirective() * ------------------------------------------------------------ */ virtual int importDirective(Node *n) { return Language::importDirective(n); } /* ------------------------------------------------------------ * cDeclaration() * It copies sym:name to lua:name to preserve its original value * ------------------------------------------------------------ */ virtual int cDeclaration(Node *n) { // class 'Language' is messing with symname in a really heavy way. // Although documentation states that sym:name is a name in // the target language space, it is not true. sym:name and // its derivatives are used in various places, including // behind-the-scene C code generation. The best way is not to // touch it at all. // But we need to know what was the name of function/variable // etc that user desired, that's why we store correct symname // as lua:name String *symname = Getattr(n, "sym:name"); if (symname) Setattr(n, "lua:name", symname); return Language::cDeclaration(n); } virtual int constructorDeclaration(Node *n) { Setattr(n, "lua:name", Getattr(n, "sym:name")); return Language::constructorDeclaration(n); } virtual int destructorDeclaration(Node *n) { Setattr(n, "lua:name", Getattr(n, "sym:name")); return Language::destructorDeclaration(n); } /* NEW LANGUAGE NOTE:*********************************************** This is it! you get this one right, and most of your work is done but its going to take some file to get it working right quite a bit of this is generally boilerplate code (or stuff I don't understand) that which matters will have extra added comments NEW LANGUAGE NOTE:END *********************************************** */ /* --------------------------------------------------------------------- * functionWrapper() * * Create a function declaration and register it with the interpreter. * --------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- * registerMethod() * * Determines wrap name of a method, its scope etc and calls * registerMethod overload with correct arguments * Overloaded variant adds method to the "methods" array of specified lua scope/class * ---------------------------------------------------------------------- */ void registerMethod(Node *n, bool overwrite = false, String *overwriteLuaScope = 0) { String *symname = Getattr(n, "sym:name"); assert(symname); if (Getattr(n, "sym:nextSibling")) return; // Lua scope. It is not symbol NSpace, it is the actual key to retrieve getCArraysHash. String *luaScope = luaCurrentSymbolNSpace(); if (overwrite) luaScope = overwriteLuaScope; String *wrapname = 0; String *mrename; if (current[NO_CPP] || !getCurrentClass()) { mrename = symname; } else { assert(!current[NO_CPP]); if (current[STATIC_FUNC] || current[MEMBER_FUNC]) { mrename = Swig_name_member(getNSpace(), getClassPrefix(), symname); } else { mrename = symname; } } wrapname = Swig_name_wrapper(mrename); registerMethod(n, wrapname, luaScope); } /* ----------------------------------------------------------------------- * registerMethod() * * Add method to the "methods" C array of given namespace/class * ---------------------------------------------------------------------- */ void registerMethod(Node *n, String* wname, String *luaScope) { assert(n); Hash *nspaceHash = getCArraysHash(luaScope); String *s_ns_methods_tab = Getattr(nspaceHash, "methods"); String *lua_name = Getattr(n, "lua:name"); if (elua_ltr || eluac_ltr) Printv(s_ns_methods_tab, tab4, "{LSTRKEY(\"", lua_name, "\")", ", LFUNCVAL(", wname, ")", "},\n", NIL); else Printv(s_ns_methods_tab, tab4, "{ \"", lua_name, "\", ", wname, "},\n", NIL); // Add to the metatable if method starts with '__' const char * tn = Char(lua_name); if (tn[0]=='_' && tn[1] == '_' && !eluac_ltr) { String *metatable_tab = Getattr(nspaceHash, "metatable"); assert(metatable_tab); if (elua_ltr) Printv(metatable_tab, tab4, "{LSTRKEY(\"", lua_name, "\")", ", LFUNCVAL(", wname, ")", "},\n", NIL); else Printv(metatable_tab, tab4, "{ \"", lua_name, "\", ", wname, "},\n", NIL); } } virtual int functionWrapper(Node *n) { REPORT("functionWrapper", n); String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); String *lua_name = Getattr(n, "lua:name"); assert(lua_name); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); Parm *p; String *tm; int i; //Printf(stdout,"functionWrapper %s %s %d\n",name,iname,current); String *overname = 0; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!luaAddSymbol(lua_name, n)) { return SWIG_ERROR; } } /* NEW LANGUAGE NOTE:*********************************************** the wrapper object holds all the wrapper code we need to add a couple of local variables NEW LANGUAGE NOTE:END *********************************************** */ Wrapper *f = NewWrapper(); Wrapper_add_local(f, "SWIG_arg", "int SWIG_arg = 0"); String *wname = Swig_name_wrapper(iname); if (overname) { Append(wname, overname); } if (current[CONSTRUCTOR]) { if (constructor_name != 0) Delete(constructor_name); constructor_name = Copy(wname); } /* NEW LANGUAGE NOTE:*********************************************** the format of a lua fn is: static int wrap_XXX(lua_State* L){...} this line adds this into the wrapper code NEW LANGUAGE NOTE:END *********************************************** */ Printv(f->def, "static int ", wname, "(lua_State* L) {", NIL); /* NEW LANGUAGE NOTE:*********************************************** this prints the list of args, eg for a C fn int gcd(int x,int y); it will print int arg1; int arg2; NEW LANGUAGE NOTE:END *********************************************** */ /* Write code to extract function parameters. */ emit_parameter_variables(l, f); /* Attach the standard typemaps */ emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); /* Get number of required and total arguments */ int num_arguments = emit_num_arguments(l); int num_required = emit_num_required(l); int varargs = emit_isvarargs(l); // Check if we have to ignore arguments that are passed by LUA. // Needed for unary minus, where lua passes two arguments and // we have to ignore the second. int args_to_ignore = 0; if (Getattr(n, "lua:ignore_args")) { args_to_ignore = GetInt(n, "lua:ignore_args"); } /* NEW LANGUAGE NOTE:*********************************************** from here on in, it gets rather hairy this is the code to convert from the scripting language to C/C++ some of the stuff will refer to the typemaps code written in your swig file (lua.swg), and some is done in the code here I suppose you could do all the conversion in C, but it would be a nightmare to do NEW LANGUAGE NOTE:END *********************************************** */ /* Generate code for argument marshalling */ // String *description = NewString(""); /* NEW LANGUAGE NOTE:*********************************************** argument_check is a new feature I added to check types of arguments: eg for int gcd(int,int) I want to check that arg1 & arg2 really are integers NEW LANGUAGE NOTE:END *********************************************** */ String *argument_check = NewString(""); String *argument_parse = NewString(""); String *checkfn = NULL; char source[64]; Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n", Swig_name_str(n), num_required + args_to_ignore, num_arguments + args_to_ignore); for (i = 0, p = l; i < num_arguments; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); /* Look for an input typemap */ sprintf(source, "%d", i + 1); if ((tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$source", source); Replaceall(tm, "$target", ln); Replaceall(tm, "$input", source); Setattr(p, "emit:input", source); if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { Replaceall(tm, "$disown", "0"); } /* NEW LANGUAGE NOTE:*********************************************** look for a 'checkfn' typemap this an additional parameter added to the in typemap if found the type will be tested for this will result in code either in the argument_check or argument_parse string NEW LANGUAGE NOTE:END *********************************************** */ if ((checkfn = Getattr(p, "tmap:in:checkfn"))) { if (i < num_required) { Printf(argument_check, "if(!%s(L,%s))", checkfn, source); } else { Printf(argument_check, "if(lua_gettop(L)>=%s && !%s(L,%s))", source, checkfn, source); } Printf(argument_check, " SWIG_fail_arg(\"%s\",%s,\"%s\");\n", Swig_name_str(n), source, SwigType_str(pt, 0)); } /* NEW LANGUAGE NOTE:*********************************************** lua states the number of arguments passed to a function using the fn lua_gettop() we can use this to deal with default arguments NEW LANGUAGE NOTE:END *********************************************** */ if (i < num_required) { Printf(argument_parse, "%s\n", tm); } else { Printf(argument_parse, "if(lua_gettop(L)>=%s){%s}\n", source, tm); } p = Getattr(p, "tmap:in:next"); continue; } else { /* NEW LANGUAGE NOTE:*********************************************** // why is this code not called when I don't have a typemap? // instead of giving a warning, no code is generated NEW LANGUAGE NOTE:END *********************************************** */ Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } } // add all argcheck code Printv(f->code, argument_check, argument_parse, NIL); /* Check for trailing varargs */ if (varargs) { if (p && (tm = Getattr(p, "tmap:in"))) { Replaceall(tm, "$input", "varargs"); Printv(f->code, tm, "\n", NIL); } } /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { Replaceall(tm, "$target", Getattr(p, "lname")); Printv(f->code, tm, "\n", NIL); p = Getattr(p, "tmap:check:next"); } else { p = nextSibling(p); } } /* Insert cleanup code */ String *cleanup = NewString(""); for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$source", Getattr(p, "lname")); Printv(cleanup, tm, "\n", NIL); p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); } } /* Insert argument output code */ String *outarg = NewString(""); for (p = l; p;) { if ((tm = Getattr(p, "tmap:argout"))) { // // managing the number of returning variables // if (numoutputs=Getattr(p,"tmap:argout:numoutputs")){ // int i=GetInt(p,"tmap:argout:numoutputs"); // printf("got argout:numoutputs of %d\n",i); // returnval+=GetInt(p,"tmap:argout:numoutputs"); // } // else returnval++; Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$target", Swig_cresult_name()); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); p = Getattr(p, "tmap:argout:next"); } else { p = nextSibling(p); } } // Remember C name of the wrapping function Setattr(n, "wrap:name", wname); /* Emit the function call */ String *actioncode = emit_action(n); /* NEW LANGUAGE NOTE:*********************************************** FIXME: returns 1 if there is a void return type this is because there is a typemap for void NEW LANGUAGE NOTE:END *********************************************** */ // Return value if necessary if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { // managing the number of returning variables // if (numoutputs=Getattr(tm,"numoutputs")){ // int i=GetInt(tm,"numoutputs"); // printf("return numoutputs %d\n",i); // returnval+=GetInt(tm,"numoutputs"); // } // else returnval++; Replaceall(tm, "$source", Swig_cresult_name()); if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "1"); } else { Replaceall(tm, "$owner", "0"); } Printf(f->code, "%s\n", tm); // returnval++; } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); } emit_return_variable(n, d, f); /* Output argument output code */ Printv(f->code, outarg, NIL); /* Output cleanup code */ Printv(f->code, cleanup, NIL); /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } /* Close the function */ Printv(f->code, "return SWIG_arg;\n", NIL); // add the failure cleanup code: Printv(f->code, "\nif(0) SWIG_fail;\n", NIL); Printv(f->code, "\nfail:\n", NIL); Printv(f->code, "$cleanup", "lua_error(L);\n", NIL); Printv(f->code, "return SWIG_arg;\n", NIL); Printf(f->code, "}\n"); /* Substitute the cleanup code */ Replaceall(f->code, "$cleanup", cleanup); /* Substitute the function name */ Replaceall(f->code, "$symname", iname); Replaceall(f->code, "$result", Swig_cresult_name()); /* Dump the function out */ /* in Lua we will not emit the destructor as a wrapper function, Lua will automatically call the destructor when the object is free'd However: you cannot just skip this function as it will not emit any custom destructor (using %extend), as you need to call emit_action() Therefore we go though the whole function, but do not write the code into the wrapper */ if (!current[DESTRUCTOR]) { Wrapper_print(f, f_wrappers); } /* NEW LANGUAGE NOTE:*********************************************** register the function in SWIG different language mappings seem to use different ideas NEW LANGUAGE NOTE:END *********************************************** */ /* Now register the function with the interpreter. */ int result = SWIG_OK; if (Getattr(n, "sym:overloaded")) { if (!Getattr(n, "sym:nextSibling")) { result = dispatchFunction(n); } } Delete(argument_check); Delete(argument_parse); Delete(cleanup); Delete(outarg); // Delete(description); DelWrapper(f); return result; } /* ------------------------------------------------------------ * dispatchFunction() * * Emit overloading dispatch function * ------------------------------------------------------------ */ /* NEW LANGUAGE NOTE:*********************************************** This is an extra function used for overloading of functions it checks the args & then calls the relevant fn most of the real work in again typemaps: look for %typecheck(SWIG_TYPECHECK_*) in the .swg file NEW LANGUAGE NOTE:END *********************************************** */ int dispatchFunction(Node *n) { //REPORT("dispatchFunction", n); /* Last node in overloaded chain */ int maxargs; String *tmp = NewString(""); String *dispatch = Swig_overload_dispatch(n, "return %s(L);", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *f = NewWrapper(); String *symname = Getattr(n, "sym:name"); String *lua_name = Getattr(n, "lua:name"); assert(lua_name); String *wname = Swig_name_wrapper(symname); //Printf(stdout,"Swig_overload_dispatch %s %s '%s' %d\n",symname,wname,dispatch,maxargs); if (!luaAddSymbol(lua_name, n)) { return SWIG_ERROR; } Printv(f->def, "static int ", wname, "(lua_State* L) {", NIL); Wrapper_add_local(f, "argc", "int argc"); Printf(tmp, "int argv[%d]={1", maxargs + 1); for (int i = 1; i <= maxargs; i++) { Printf(tmp, ",%d", i + 1); } Printf(tmp, "}"); Wrapper_add_local(f, "argv", tmp); Printf(f->code, "argc = lua_gettop(L);\n"); Replaceall(dispatch, "$args", "self,args"); Printv(f->code, dispatch, "\n", NIL); Node *sibl = n; while (Getattr(sibl, "sym:previousSibling")) sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up String *protoTypes = NewString(""); do { String *fulldecl = Swig_name_decl(sibl); Printf(protoTypes, "\n\" %s\\n\"", fulldecl); Delete(fulldecl); } while ((sibl = Getattr(sibl, "sym:nextSibling"))); Printf(f->code, "SWIG_Lua_pusherrstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n" "\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes); Delete(protoTypes); Printf(f->code, "lua_error(L);return 0;\n"); Printv(f->code, "}\n", NIL); Wrapper_print(f, f_wrappers); // Remember C name of the wrapping function Setattr(n, "wrap:name", wname); if (current[CONSTRUCTOR]) { if (constructor_name != 0) Delete(constructor_name); constructor_name = Copy(wname); } DelWrapper(f); Delete(dispatch); Delete(tmp); return SWIG_OK; } /* ------------------------------------------------------------ * Add variable to "attributes" C arrays of given namespace or class. * Input is node. Based on the state of "current" array it determines * the name of the getter function, setter function etc and calls * registerVariable overload with necessary params. * Lua scope could be overwritten. (Used only for backward compatibility) * ------------------------------------------------------------ */ void registerVariable(Node *n, bool overwrite = false, String *overwriteLuaScope = 0) { int assignable = is_assignable(n); String *symname = Getattr(n, "sym:name"); assert(symname); // Lua scope. It is not symbol NSpace, it is the actual key to retrieve getCArraysHash. String *luaScope = luaCurrentSymbolNSpace(); if (overwrite) luaScope = overwriteLuaScope; // Getter and setter String *getName = 0; String *setName = 0; String *mrename = 0; if (current[NO_CPP] || !getCurrentClass()) { // Global variable getName = Swig_name_get(getNSpace(), symname); if (assignable) setName = Swig_name_set(getNSpace(), symname); } else { assert(!current[NO_CPP]); if (current[STATIC_VAR] ) { mrename = Swig_name_member(getNSpace(), getClassPrefix(), symname); getName = Swig_name_get(0, mrename); if (assignable) setName = Swig_name_set(0, mrename); } else if (current[MEMBER_VAR]) { mrename = Swig_name_member(0, getClassPrefix(), symname); getName = Swig_name_get(getNSpace(), mrename); if (assignable) setName = Swig_name_set(getNSpace(), mrename); } else { assert(false); } } getName = Swig_name_wrapper(getName); if (setName) setName = Swig_name_wrapper(setName); registerVariable(luaScope, n, getName, setName); } /* ------------------------------------------------------------ * registerVariable() * * Add variable to the "attributes" (or "get"/"set" in * case of elua_ltr) C arrays of given namespace or class * ------------------------------------------------------------ */ void registerVariable(String *lua_nspace_or_class_name, Node *n, String *getName, String *setName) { String *unassignable = NewString("SWIG_Lua_set_immutable"); if (setName == 0 || GetFlag(n, "feature:immutable")) { setName = unassignable; } Hash *nspaceHash = getCArraysHash(lua_nspace_or_class_name); String *s_ns_methods_tab = Getattr(nspaceHash, "methods"); String *s_ns_var_tab = Getattr(nspaceHash, "attributes"); String *lua_name = Getattr(n, "lua:name"); if (elua_ltr) { String *s_ns_dot_get = Getattr(nspaceHash, "get"); String *s_ns_dot_set = Getattr(nspaceHash, "set"); Printf(s_ns_dot_get, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, lua_name, getName); Printf(s_ns_dot_set, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, lua_name, setName); } else if (eluac_ltr) { Printv(s_ns_methods_tab, tab4, "{LSTRKEY(\"", lua_name, "_get", "\")", ", LFUNCVAL(", getName, ")", "},\n", NIL); Printv(s_ns_methods_tab, tab4, "{LSTRKEY(\"", lua_name, "_set", "\")", ", LFUNCVAL(", setName, ")", "},\n", NIL); } else { Printf(s_ns_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, lua_name, getName, setName); } } /* ------------------------------------------------------------ * variableWrapper() * ------------------------------------------------------------ */ virtual int variableWrapper(Node *n) { /* NEW LANGUAGE NOTE:*********************************************** Language::variableWrapper(n) will generate two wrapper fns Foo_get & Foo_set by calling functionWrapper() so we will just add these into the variable lists ideally we should not have registered these as functions, only WRT this variable will look into this later. NEW LANGUAGE NOTE:END *********************************************** */ // REPORT("variableWrapper", n); String *lua_name = Getattr(n, "lua:name"); assert(lua_name); current[VARIABLE] = true; // let SWIG generate the wrappers int result = Language::variableWrapper(n); // It is impossible to use registerVariable, because sym:name of the Node is currently // in an undefined state - the callees of this function may have modified it. // registerVariable should be used from respective callees.* current[VARIABLE] = false; return result; } /* ------------------------------------------------------------ * Add constant to appropriate C array. constantRecord is an array record. * Actually, in current implementation it is resolved consttab typemap * ------------------------------------------------------------ */ void registerConstant(String *nspace, String *constantRecord) { Hash *nspaceHash = getCArraysHash(nspace); String *s_const_tab = 0; if (eluac_ltr || elua_ltr) // In elua everything goes to "methods" tab s_const_tab = Getattr(nspaceHash, "methods"); else s_const_tab = Getattr(nspaceHash, "constants"); assert(s_const_tab); Printf(s_const_tab, " %s,\n", constantRecord); if ((eluac_ltr || elua_ltr) && old_metatable_bindings) { s_const_tab = Getattr(nspaceHash, "constants"); assert(s_const_tab); Printf(s_const_tab, " %s,\n", constantRecord); } } /* ------------------------------------------------------------ * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { REPORT("constantWrapper", n); String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); String *lua_name = Getattr(n, "lua:name"); if (lua_name == 0) lua_name = iname; String *nsname = Copy(iname); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); String *tm; String *lua_name_v2 = 0; String *tm_v2 = 0; String *iname_v2 = 0; Node *n_v2 = 0; if (!luaAddSymbol(lua_name, n)) return SWIG_ERROR; Swig_save("lua_constantMember", n, "sym:name", NIL); Setattr(n, "sym:name", lua_name); /* Special hook for member pointer */ if (SwigType_type(type) == T_MPOINTER) { String *wname = Swig_name_wrapper(iname); Printf(f_wrappers, "static %s = %s;\n", SwigType_str(type, wname), value); value = Char(wname); } if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", lua_name); Replaceall(tm, "$value", value); Replaceall(tm, "$nsname", nsname); registerConstant(luaCurrentSymbolNSpace(), tm); } else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", lua_name); Replaceall(tm, "$value", value); Replaceall(tm, "$nsname", nsname); Printf(f_init, "%s\n", tm); } else { Delete(nsname); nsname = 0; Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); Swig_restore(n); return SWIG_NOWRAP; } bool make_v2_compatible = old_metatable_bindings && getCurrentClass() && old_compatible_names; if (make_v2_compatible) { // Don't do anything for enums in C mode - they are already // wrapped correctly if (CPlusPlus || !current[ENUM_CONST]) { lua_name_v2 = Swig_name_member(0, proxy_class_name, lua_name); iname_v2 = Swig_name_member(0, proxy_class_name, iname); n_v2 = Copy(n); if (!luaAddSymbol(iname_v2, n, getNSpace())) { Swig_restore(n); return SWIG_ERROR; } Setattr(n_v2, "sym:name", lua_name_v2); tm_v2 = Swig_typemap_lookup("consttab", n_v2, name, 0); if (tm_v2) { Replaceall(tm_v2, "$source", value); Replaceall(tm_v2, "$target", lua_name_v2); Replaceall(tm_v2, "$value", value); Replaceall(tm_v2, "$nsname", nsname); registerConstant(getNSpace(), tm_v2); } else { tm_v2 = Swig_typemap_lookup("constcode", n_v2, name, 0); if (!tm_v2) { // This can't be. assert(false); Swig_restore(n); return SWIG_ERROR; } Replaceall(tm_v2, "$source", value); Replaceall(tm_v2, "$target", lua_name_v2); Replaceall(tm_v2, "$value", value); Replaceall(tm_v2, "$nsname", nsname); Printf(f_init, "%s\n", tm_v2); } Delete(n_v2); } } Swig_restore(n); Delete(nsname); return SWIG_OK; } /* ------------------------------------------------------------ * nativeWrapper() * ------------------------------------------------------------ */ virtual int nativeWrapper(Node *n) { // REPORT("nativeWrapper", n); String *symname = Getattr(n, "sym:name"); String *wrapname = Getattr(n, "wrap:name"); if (!luaAddSymbol(wrapname, n)) return SWIG_ERROR; Hash *nspaceHash = getCArraysHash(getNSpace()); String *s_ns_methods_tab = Getattr(nspaceHash, "methods"); Printv(s_ns_methods_tab, tab4, "{ \"", symname, "\",", wrapname, "},\n", NIL); // return Language::nativeWrapper(n); // this does nothing... return SWIG_OK; } /* ------------------------------------------------------------ * enumDeclaration() * ------------------------------------------------------------ */ virtual int enumDeclaration(Node *n) { current[STATIC_CONST] = true; current[ENUM_CONST] = true; // There is some slightly specific behaviour with enums. Basically, // their NSpace may be tracked separately. The code below tries to work around // this issue to some degree. // The idea is the same as in classHandler - to drop old names generation if // enum is in class in namespace. const int old_compatible_names_saved = old_compatible_names; if (getNSpace() || ( Getattr(n, "sym:nspace") != 0 && Len(Getattr(n, "sym:nspace")) > 0 ) ) { old_compatible_names = 0; } int result = Language::enumDeclaration(n); current[STATIC_CONST] = false; current[ENUM_CONST] = false; old_compatible_names = old_compatible_names_saved; return result; } /* ------------------------------------------------------------ * enumvalueDeclaration() * ------------------------------------------------------------ */ virtual int enumvalueDeclaration(Node *n) { if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL); String *value = Getattr(n, "value"); String *name = Getattr(n, "name"); String *tmpValue; if (value) tmpValue = NewString(value); else tmpValue = NewString(name); Setattr(n, "value", tmpValue); Setattr(n, "name", tmpValue); /* for wrapping of enums in a namespace when emit_action is used */ int result = constantWrapper(n); Delete(tmpValue); Swig_restore(n); return result; } /* ------------------------------------------------------------ * classDeclaration() * ------------------------------------------------------------ */ virtual int classDeclaration(Node *n) { return Language::classDeclaration(n); } /* ------------------------------------------------------------ * Helper function that adds record to appropriate C arrays * ------------------------------------------------------------ */ void registerClass(String *scope, String *wrap_class) { assert(wrap_class); Hash *nspaceHash = getCArraysHash(scope); String *ns_classes = Getattr(nspaceHash, "classes"); Printv(ns_classes, "&", wrap_class, ",\n", NIL); if (elua_ltr || eluac_ltr) { String *ns_methods = Getattr(nspaceHash, "methods"); Hash *class_hash = getCArraysHash(class_static_nspace); assert(class_hash); String *cls_methods = Getattr(class_hash, "methods:name"); assert(cls_methods); Printv(ns_methods, tab4, "{LSTRKEY(\"", proxy_class_name, "\")", ", LROVAL(", cls_methods, ")", "},\n", NIL); } } /* ------------------------------------------------------------ * classHandler() * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { //REPORT("classHandler", n); String *mangled_full_proxy_class_name = 0; String *destructor_name = 0; String *nspace = getNSpace(); constructor_name = 0; have_constructor = 0; have_destructor = 0; destructor_action = 0; assert(class_static_nspace == 0); assert(full_proxy_class_name == 0); assert(proxy_class_name == 0); current[NO_CPP] = false; proxy_class_name = Getattr(n, "sym:name"); // We have to enforce nspace here, because technically we are already // inside class parsing (getCurrentClass != 0), but we should register // class in its parent namespace if (!luaAddSymbol(proxy_class_name, n, nspace)) return SWIG_ERROR; if (nspace == 0) full_proxy_class_name = NewStringf("%s", proxy_class_name); else full_proxy_class_name = NewStringf("%s.%s", nspace, proxy_class_name); assert(full_proxy_class_name); mangled_full_proxy_class_name = Swig_name_mangle(full_proxy_class_name); SwigType *t = Copy(Getattr(n, "name")); SwigType *fr_t = SwigType_typedef_resolve_all(t); /* Create fully resolved type */ SwigType *t_tmp = 0; t_tmp = SwigType_typedef_qualified(fr_t); // Temporal variable Delete(fr_t); fr_t = SwigType_strip_qualifiers(t_tmp); String *mangled_fr_t = 0; mangled_fr_t = SwigType_manglestr(fr_t); // not sure exactly how this works, // but tcl has a static hashtable of all classes emitted and then only emits code for them once. // this fixes issues in test suites: template_default2 & template_specialization // * if i understand correctly, this is a bug. // * consider effect on template_specialization_defarg static Hash *emitted = NewHash(); if (GetFlag(emitted, mangled_fr_t)) { full_proxy_class_name = 0; proxy_class_name = 0; return SWIG_NOWRAP; } SetFlag(emitted, mangled_fr_t); // We treat class T as both 'class' and 'namespace'. All static members, attributes // and constants are considered part of namespace T, all members - part of the 'class' // Now, here is a trick. Static methods, attributes and non-static methods and attributes // are described with same structures - swig_lua_attribute/swig_lua_method. Instead of calling // getCArraysHash(class name) to initialize things for static methods/attributes and then // manually doing same initialization for non-static methods, we call getCArraysHash 2 times: // 1) With name "class name" + "." + "SwigStatic" to initialize static things // 2) With "class name" to initialize non-static things Hash *instance_cls = getCArraysHash(full_proxy_class_name, false); assert(instance_cls); String *s_attr_tab_name = Getattr(instance_cls, "attributes:name"); String *s_methods_tab_name = Getattr(instance_cls, "methods:name"); SetFlag(instance_cls, "lua:no_namespaces"); SetFlag(instance_cls, "lua:no_classes"); SetFlag(instance_cls, "lua:class_instance"); /* There is no use for "constants", "classes" and "namespaces" arrays. * All constants are considered part of static part of class. */ class_static_nspace = NewStringf("%s%sSwigStatic", full_proxy_class_name, NSPACE_SEPARATOR); Hash *static_cls = getCArraysHash(class_static_nspace, false); assert(static_cls); SetFlag(static_cls, "lua:no_namespaces"); SetFlag(static_cls, "lua:class_static"); // Notifying instance_cls and static_cls hashes about each other Setattr(instance_cls, "lua:class_instance:static_hash", static_cls); Setattr(static_cls, "lua:class_static:instance_hash", instance_cls); const int old_compatible_names_saved = old_compatible_names; // If class has %nspace enabled, then generation of backward compatible names // should be disabled if (getNSpace()) { old_compatible_names = 0; } /* There is no use for "classes" and "namespaces" arrays. Subclasses are not supported * by SWIG and namespaces couldn't be nested inside classes (C++ Standard) */ // Generate normal wrappers Language::classHandler(n); old_compatible_names = old_compatible_names_saved; SwigType_add_pointer(t); // Catch all: eg. a class with only static functions and/or variables will not have 'remembered' String *wrap_class_name = Swig_name_wrapper(NewStringf("class_%s", mangled_full_proxy_class_name)); String *wrap_class = NewStringf("&%s", wrap_class_name); SwigType_remember_clientdata(t, wrap_class); String *rt = Copy(getClassType()); SwigType_add_pointer(rt); // Adding class to apropriate namespace registerClass(nspace, wrap_class_name); Hash *nspaceHash = getCArraysHash(nspace); // Register the class structure with the type checker // Printf(f_init,"SWIG_TypeClientData(SWIGTYPE%s, (void *) &_wrap_class_%s);\n", SwigType_manglestr(t), mangled_full_proxy_class_name); // emit a function to be called to delete the object if (have_destructor) { destructor_name = NewStringf("swig_delete_%s", mangled_full_proxy_class_name); Printv(f_wrappers, "static void ", destructor_name, "(void *obj) {\n", NIL); if (destructor_action) { Printv(f_wrappers, SwigType_str(rt, "arg1"), " = (", SwigType_str(rt, 0), ") obj;\n", NIL); Printv(f_wrappers, destructor_action, "\n", NIL); } else { if (CPlusPlus) { Printv(f_wrappers, " delete (", SwigType_str(rt, 0), ") obj;\n", NIL); } else { Printv(f_wrappers, " free((char *) obj);\n", NIL); } } Printf(f_wrappers, "}\n"); } // Wrap constructor wrapper into one more proxy function. It will be used as class namespace __call method, thus // allowing both // Module.ClassName.StaticMethod to access static method/variable/constant // Module.ClassName() to create new object if (have_constructor) { assert(constructor_name); String *constructor_proxy_name = NewStringf("_proxy_%s", constructor_name); Printv(f_wrappers, "static int ", constructor_proxy_name, "(lua_State *L) {\n", NIL); Printv(f_wrappers, tab4, "assert(lua_istable(L,1));\n", tab4, "lua_pushcfunction(L,", constructor_name, ");\n", tab4, "assert(!lua_isnil(L,-1));\n", tab4, "lua_replace(L,1); /* replace our table with real constructor */\n", tab4, "lua_call(L,lua_gettop(L)-1,1);\n", tab4, "return 1;\n}\n", NIL); Delete(constructor_name); constructor_name = constructor_proxy_name; if (elua_ltr) { String *static_cls_metatable_tab = Getattr(static_cls, "metatable"); assert(static_cls_metatable_tab); Printf(static_cls_metatable_tab, " {LSTRKEY(\"__call\"), LFUNCVAL(%s)},\n", constructor_name); } else if (eluac_ltr) { String *ns_methods_tab = Getattr(nspaceHash, "methods"); assert(ns_methods_tab); Printv(ns_methods_tab, tab4, "{LSTRKEY(\"", "new_", proxy_class_name, "\")", ", LFUNCVAL(", constructor_name, ")", "},\n", NIL); } } if (have_destructor) { if (eluac_ltr) { String *ns_methods_tab = Getattr(nspaceHash, "methods"); assert(ns_methods_tab); Printv(ns_methods_tab, tab4, "{LSTRKEY(\"", "free_", mangled_full_proxy_class_name, "\")", ", LFUNCVAL(", destructor_name, ")", "},\n", NIL); } } closeCArraysHash(full_proxy_class_name, f_wrappers); closeCArraysHash(class_static_nspace, f_wrappers); // Handle inheritance // note: with the idea of class hierarchies spread over multiple modules // cf test-suite: imports.i // it is not possible to just add the pointers to the base classes to the code // (as sometimes these classes are not present) // therefore we instead hold the name of the base class and a null pointer // at runtime: we can query the swig type manager & see if the class exists // if so, we can get the pointer to the base class & replace the null pointer // if the type does not exist, then we cannot... String *base_class = NewString(""); String *base_class_names = NewString(""); List *baselist = Getattr(n, "bases"); if (baselist && Len(baselist)) { Iterator b; int index = 0; b = First(baselist); while (b.item) { String *bname = Getattr(b.item, "name"); if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) { b = Next(b); continue; } // stores a null pointer & the name Printf(base_class, "0,"); Printf(base_class_names, "\"%s *\",", SwigType_namestr(bname)); b = Next(b); index++; } } // First, print class static part printCArraysDefinition(class_static_nspace, proxy_class_name, f_wrappers); assert(mangled_full_proxy_class_name); assert(base_class); assert(base_class_names); assert(proxy_class_name); assert(full_proxy_class_name); // Then print class isntance part Printv(f_wrappers, "static swig_lua_class *swig_", mangled_full_proxy_class_name, "_bases[] = {", base_class, "0};\n", NIL); Delete(base_class); Printv(f_wrappers, "static const char *swig_", mangled_full_proxy_class_name, "_base_names[] = {", base_class_names, "0};\n", NIL); Delete(base_class_names); Printv(f_wrappers, "static swig_lua_class _wrap_class_", mangled_full_proxy_class_name, " = { \"", proxy_class_name, "\", \"", full_proxy_class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL); if (have_constructor) { Printv(f_wrappers, constructor_name, NIL); Delete(constructor_name); constructor_name = 0; } else { Printf(f_wrappers, "0"); } if (have_destructor) { Printv(f_wrappers, ", ", destructor_name, NIL); } else { Printf(f_wrappers, ",0"); } Printf(f_wrappers, ", %s, %s, &%s", s_methods_tab_name, s_attr_tab_name, Getattr(static_cls, "cname")); if (!eluac_ltr) { Printf(f_wrappers, ", %s", Getattr(instance_cls,"metatable:name")); } else Printf(f_wrappers, ", 0"); Printf(f_wrappers, ", swig_%s_bases, swig_%s_base_names };\n\n", mangled_full_proxy_class_name, mangled_full_proxy_class_name); current[NO_CPP] = true; Delete(class_static_nspace); class_static_nspace = 0; Delete(mangled_full_proxy_class_name); mangled_full_proxy_class_name = 0; Delete(destructor_name); destructor_name = 0; Delete(full_proxy_class_name); full_proxy_class_name = 0; proxy_class_name = 0; return SWIG_OK; } /* ------------------------------------------------------------ * memberfunctionHandler() * ------------------------------------------------------------ */ virtual int memberfunctionHandler(Node *n) { String *symname = GetChar(n, "sym:name"); //Printf(stdout,"memberfunctionHandler %s %s\n",name,iname); // Special case unary minus: LUA passes two parameters for the // wrapper function while we want only one. Tell our // functionWrapper to ignore a parameter. if (Cmp(symname, "__unm") == 0) { //Printf(stdout, "unary minus: ignore one argument\n"); SetInt(n, "lua:ignore_args", 1); } current[MEMBER_FUNC] = true; Language::memberfunctionHandler(n); registerMethod(n); current[MEMBER_FUNC] = false; return SWIG_OK; } /* ------------------------------------------------------------ * membervariableHandler() * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { // REPORT("membervariableHandler",n); current[MEMBER_VAR] = true; Language::membervariableHandler(n); registerVariable(n); current[MEMBER_VAR] = false; return SWIG_OK; } /* ------------------------------------------------------------ * constructorHandler() * * Method for adding C++ member constructor * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { // REPORT("constructorHandler", n); current[CONSTRUCTOR] = true; Language::constructorHandler(n); current[CONSTRUCTOR] = false; //constructor_name = NewString(Getattr(n, "sym:name")); have_constructor = 1; return SWIG_OK; } /* ------------------------------------------------------------ * destructorHandler() * ------------------------------------------------------------ */ virtual int destructorHandler(Node *n) { REPORT("destructorHandler", n); current[DESTRUCTOR] = true; Language::destructorHandler(n); current[DESTRUCTOR] = false; have_destructor = 1; destructor_action = Getattr(n, "wrap:action"); return SWIG_OK; } /* ---------------------------------------------------------------------- * globalfunctionHandler() * * It can be called: * 1. Usual C/C++ global function. * 2. During class parsing for functions declared/defined as friend * 3. During class parsing from staticmemberfunctionHandler * ---------------------------------------------------------------------- */ virtual int globalfunctionHandler(Node *n) { bool oldVal = current[NO_CPP]; if (!current[STATIC_FUNC]) // If static function, don't switch to NO_CPP current[NO_CPP] = true; const int result = Language::globalfunctionHandler(n); if (!current[STATIC_FUNC]) // Register only if not called from static function handler registerMethod(n); current[NO_CPP] = oldVal; return result; } /* ---------------------------------------------------------------------- * globalvariableHandler() * * Sets "current" array correctly * ---------------------------------------------------------------------- */ virtual int globalvariableHandler(Node *n) { bool oldVal = current[NO_CPP]; current[GLOBAL_VAR] = true; current[NO_CPP] = true; const int result = Language::globalvariableHandler(n); registerVariable(n); current[GLOBAL_VAR] = false; current[NO_CPP] = oldVal; return result; } /* ----------------------------------------------------------------------- * staticmemberfunctionHandler() * * Wrap a static C++ function * ---------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { REPORT("staticmemberfunctionHandler", n); current[STATIC_FUNC] = true; const int result = Language::staticmemberfunctionHandler(n); registerMethod(n); if (old_metatable_bindings && result == SWIG_OK && old_compatible_names) { Swig_require("lua_staticmemberfunctionHandler", n, "*lua:name", NIL); String *lua_name = Getattr(n, "lua:name"); // Although this function uses Swig_name_member, it actually generates the Lua name, // not the C++ name. This is because an earlier version used such a scheme for static function // name generation and we have to maintain backward compatibility. String *compat_name = Swig_name_member(0, proxy_class_name, lua_name); Setattr(n, "lua:name", compat_name); registerMethod(n, true, getNSpace()); Delete(compat_name); Swig_restore(n); } current[STATIC_FUNC] = false;; return result; } /* ------------------------------------------------------------ * memberconstantHandler() * * Create a C++ constant * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { REPORT("memberconstantHandler", n); int result = Language::memberconstantHandler(n); return result; } /* --------------------------------------------------------------------- * staticmembervariableHandler() * --------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { REPORT("staticmembervariableHandler", n); current[STATIC_VAR] = true; //String *symname = Getattr(n, "sym:name"); int result = Language::staticmembervariableHandler(n); if (!GetFlag(n, "wrappedasconstant")) { registerVariable(n); } if (result == SWIG_OK) { // This will add static member variable to the class namespace with name ClassName_VarName if (old_metatable_bindings && old_compatible_names) { Swig_save("lua_staticmembervariableHandler", n, "lua:name", NIL); String *lua_name = Getattr(n, "lua:name"); // Although this function uses Swig_name_member, it actually generates the Lua name, // not the C++ name. This is because an earlier version used such a scheme for static function // name generation and we have to maintain backward compatibility. String *v2_name = Swig_name_member(NIL, proxy_class_name, lua_name); if (!GetFlag(n, "wrappedasconstant")) { Setattr(n, "lua:name", v2_name); // Registering static var in the class parent nspace registerVariable(n, true, getNSpace()); } // If static member variable was wrapped as a constant, then // constant wrapper has already performed all actions necessary for old_metatable_bindings Delete(v2_name); Swig_restore(n); } } current[STATIC_VAR] = false; return result; } /* --------------------------------------------------------------------- * external runtime generation * --------------------------------------------------------------------- */ /* This is to support the usage SWIG -external-runtime The code consists of two functions: String *runtimeCode() // returns a large string with all the runtimes in String *defaultExternalRuntimeFilename() // returns the default filename I am writing a generic solution, even though SWIG-Lua only has one file right now... */ String *runtimeCode() { String *s = NewString(""); const char *filenames[] = { "luarun.swg", 0 }; // must be 0 terminated emitLuaFlavor(s); String *sfile = 0; for (int i = 0; filenames[i] != 0; i++) { sfile = Swig_include_sys(filenames[i]); if (!sfile) { Printf(stderr, "*** Unable to open '%s'\n", filenames[i]); } else { Append(s, sfile); Delete(sfile); } } return s; } String *defaultExternalRuntimeFilename() { return NewString("swigluarun.h"); } /* --------------------------------------------------------------------- * helpers * --------------------------------------------------------------------- */ void emitLuaFlavor(String *s) { if (elua_emulate) { Printf(s, "/*This is only emulation!*/\n"); Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n"); Printf(s, "#define SWIG_LUA_ELUA_EMULATE\n"); } else if (elua_ltr) Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n"); else if (eluac_ltr) Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUAC\n"); else Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA\n"); } /* ----------------------------------------------------------------------------- * escapeCode() * * This is to convert the string of Lua code into a proper string, which can then be * emitted into the C/C++ code. * Basically is is a lot of search & replacing of odd sequences * ---------------------------------------------------------------------------- */ void escapeCode(String *str) { //Printf(f_runtime,"/* original luacode:[[[\n%s\n]]]\n*/\n",str); Chop(str); // trim Replace(str, "\\", "\\\\", DOH_REPLACE_ANY); // \ to \\ (this must be done first) Replace(str, "\"", "\\\"", DOH_REPLACE_ANY); // " to \" Replace(str, "\n", "\\n\"\n \"", DOH_REPLACE_ANY); // \n to \n"\n" (ie quoting every line) //Printf(f_runtime,"/* hacked luacode:[[[\n%s\n]]]\n*/\n",str); } /* ----------------------------------------------------------------------------- * rawGetCArraysHash(String *name) * * A small helper to hide impelementation of how CArrays hashes are stored * ---------------------------------------------------------------------------- */ Hash *rawGetCArraysHash(const_String_or_char_ptr name) { Hash *scope = symbolScopeLookup( name ? name : "" ); if(!scope) return 0; Hash *carrays_hash = Getattr(scope, "lua:cdata"); return carrays_hash; } /* ----------------------------------------------------------------------------- * getCArraysHash() * * Each namespace can be described with a hash that stores C arrays * where members of the namespace should be added. All these hashes are stored * inside the symbols table, in pseudo-symbol for every namespace. * nspace could be NULL (NSPACE_TODO), that means functions and variables and classes * that are not in any namespace (this is default for SWIG unless %nspace feature is used). * You can later set some attributes that will affect behaviour of functions that use this hash: * "lua:no_namespaces" will disable "namespaces" array. * "lua:no_classes" will disable "classes" array. * For every component ("attributes", "methods", etc) there are subcomponents: * XXX:name - name of the C array that stores data for component * XXX:decl - statement with forward declaration of this array; * Namespace could be automatically registered to its parent if 'reg' == true. This can only be * done during the first call (a.k.a when nspace is created). * ---------------------------------------------------------------------------- */ Hash *getCArraysHash(String *nspace, bool reg = true) { Hash *scope = symbolScopeLookup(nspace ? nspace : ""); if(!scope) { symbolAddScope( nspace ? nspace : "" ); scope = symbolScopeLookup(nspace ? nspace : ""); assert(scope); } Hash *carrays_hash = Getattr(scope, "lua:cdata"); if (carrays_hash != 0) return carrays_hash; carrays_hash = NewHash(); String *mangled_name = 0; if (nspace == 0 || Len(nspace) == 0) mangled_name = NewString("SwigModule"); else mangled_name = Swig_name_mangle(nspace); String *cname = NewStringf("swig_%s", mangled_name); Setattr(carrays_hash, "cname", cname); String *attr_tab = NewString(""); String *attr_tab_name = NewStringf("swig_%s_attributes", mangled_name); String *attr_tab_decl = NewString(""); Printv(attr_tab, "static swig_lua_attribute ", NIL); Printv(attr_tab, attr_tab_name, "[]", NIL); Printv(attr_tab_decl, attr_tab, ";\n", NIL); Printv(attr_tab, " = {\n", NIL); Setattr(carrays_hash, "attributes", attr_tab); Setattr(carrays_hash, "attributes:name", attr_tab_name); Setattr(carrays_hash, "attributes:decl", attr_tab_decl); String *methods_tab = NewString(""); String *methods_tab_name = NewStringf("swig_%s_methods", mangled_name); String *methods_tab_decl = NewString(""); if (elua_ltr || eluac_ltr) // In this case methods array also acts as namespace rotable Printf(methods_tab, "const LUA_REG_TYPE "); else Printf(methods_tab, "static swig_lua_method "); Printv(methods_tab, methods_tab_name, "[]", NIL); Printv(methods_tab_decl, methods_tab, ";\n", NIL); Printv(methods_tab, "= {\n", NIL); Setattr(carrays_hash, "methods", methods_tab); Setattr(carrays_hash, "methods:name", methods_tab_name); Setattr(carrays_hash, "methods:decl", methods_tab_decl); String *const_tab = NewString(""); String *const_tab_name = NewStringf("swig_%s_constants", mangled_name); String *const_tab_decl = NewString(""); if (elua_ltr || eluac_ltr) // In this case const array holds rotable with namespace constants Printf(const_tab, "const LUA_REG_TYPE "); else Printf(const_tab, "static swig_lua_const_info "); Printv(const_tab, const_tab_name, "[]", NIL); Printv(const_tab_decl, const_tab, ";", NIL); Printv(const_tab, "= {\n", NIL); Setattr(carrays_hash, "constants", const_tab); Setattr(carrays_hash, "constants:name", const_tab_name); Setattr(carrays_hash, "constants:decl", const_tab_decl); String *classes_tab = NewString(""); String *classes_tab_name = NewStringf("swig_%s_classes", mangled_name); String *classes_tab_decl = NewString(""); Printf(classes_tab, "static swig_lua_class* "); Printv(classes_tab, classes_tab_name, "[]", NIL); Printv(classes_tab_decl, classes_tab, ";", NIL); Printv(classes_tab, "= {\n", NIL); Setattr(carrays_hash, "classes", classes_tab); Setattr(carrays_hash, "classes:name", classes_tab_name); Setattr(carrays_hash, "classes:decl", classes_tab_decl); String *namespaces_tab = NewString(""); String *namespaces_tab_name = NewStringf("swig_%s_namespaces", mangled_name); String *namespaces_tab_decl = NewString(""); Printf(namespaces_tab, "static swig_lua_namespace* "); Printv(namespaces_tab, namespaces_tab_name, "[]", NIL); Printv(namespaces_tab_decl, namespaces_tab, ";", NIL); Printv(namespaces_tab, " = {\n", NIL); Setattr(carrays_hash, "namespaces", namespaces_tab); Setattr(carrays_hash, "namespaces:name", namespaces_tab_name); Setattr(carrays_hash, "namespaces:decl", namespaces_tab_decl); if (elua_ltr) { String *get_tab = NewString(""); String *get_tab_name = NewStringf("swig_%s_get", mangled_name); String *get_tab_decl = NewString(""); Printv(get_tab, "const LUA_REG_TYPE ", get_tab_name, "[]", NIL); Printv(get_tab_decl, get_tab, ";", NIL); Printv(get_tab, " = {\n", NIL); Setattr(carrays_hash, "get", get_tab); Setattr(carrays_hash, "get:name", get_tab_name); Setattr(carrays_hash, "get:decl", get_tab_decl); String *set_tab = NewString(""); String *set_tab_name = NewStringf("swig_%s_set", mangled_name); String *set_tab_decl = NewString(""); Printv(set_tab, "const LUA_REG_TYPE ", set_tab_name, "[]", NIL); Printv(set_tab_decl, set_tab, ";", NIL); Printv(set_tab, " = {\n", NIL); Setattr(carrays_hash, "set", set_tab); Setattr(carrays_hash, "set:name", set_tab_name); Setattr(carrays_hash, "set:decl", set_tab_decl); } if (!eluac_ltr) { String *metatable_tab = NewString(""); String *metatable_tab_name = NewStringf("swig_%s_meta", mangled_name); String *metatable_tab_decl = NewString(""); if (elua_ltr) // In this case const array holds rotable with namespace constants Printf(metatable_tab, "const LUA_REG_TYPE "); else Printf(metatable_tab, "static swig_lua_method "); Printv(metatable_tab, metatable_tab_name, "[]", NIL); Printv(metatable_tab_decl, metatable_tab, ";", NIL); Printv(metatable_tab, " = {\n", NIL); Setattr(carrays_hash, "metatable", metatable_tab); Setattr(carrays_hash, "metatable:name", metatable_tab_name); Setattr(carrays_hash, "metatable:decl", metatable_tab_decl); } Setattr(scope, "lua:cdata", carrays_hash); assert(rawGetCArraysHash(nspace)); if (reg && nspace != 0 && Len(nspace) != 0 && GetFlag(carrays_hash, "lua:no_reg") == 0) { // Split names into components List *components = Split(nspace, '.', -1); String *parent_path = NewString(""); int len = Len(components); String *name = Copy(Getitem(components, len - 1)); for (int i = 0; i < len - 1; i++) { if (i > 0) Printv(parent_path, NSPACE_SEPARATOR, NIL); String *item = Getitem(components, i); Printv(parent_path, item, NIL); } Hash *parent = getCArraysHash(parent_path, true); String *namespaces_tab = Getattr(parent, "namespaces"); Printv(namespaces_tab, "&", cname, ",\n", NIL); if (elua_ltr || eluac_ltr) { String *methods_tab = Getattr(parent, "methods"); Printv(methods_tab, tab4, "{LSTRKEY(\"", name, "\")", ", LROVAL(", methods_tab_name, ")", "},\n", NIL); } Setattr(carrays_hash, "name", name); Delete(components); Delete(parent_path); } else if (!reg) // This namespace shouldn't be registered. Lets remember it. SetFlag(carrays_hash, "lua:no_reg"); Delete(mangled_name); mangled_name = 0; return carrays_hash; } /* ----------------------------------------------------------------------------- * closeCArraysHash() * * Functions add end markers {0,0,...,0} to all arrays, prints them to * output and marks hash as closed (lua:closed). Consequent attempts to * close the same hash will result in an error. * closeCArraysHash DOES NOT print structure that describes namespace, it only * prints array. You can use printCArraysDefinition to print structure. * if "lua:no_namespaces" is set, then array for "namespaces" won't be printed * if "lua:no_classes" is set, then array for "classes" won't be printed * ----------------------------------------------------------------------------- */ void closeCArraysHash(String *nspace, File *output) { Hash *carrays_hash = rawGetCArraysHash(nspace); assert(carrays_hash); assert(GetFlag(carrays_hash, "lua:closed") == 0); SetFlag(carrays_hash, "lua:closed"); // Do arrays describe class instance part or class static part const int is_instance = GetFlag(carrays_hash, "lua:class_instance"); String *attr_tab = Getattr(carrays_hash, "attributes"); Printf(attr_tab, " {0,0,0}\n};\n"); Printv(output, attr_tab, NIL); String *const_tab = Getattr(carrays_hash, "constants"); String *const_tab_name = Getattr(carrays_hash, "constants:name"); if (elua_ltr || eluac_ltr) Printv(const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL); else Printf(const_tab, " {0,0,0,0,0,0}\n};\n"); // For the sake of compiling with -Wall -Werror we print constants // only when necessary int need_constants = 0; if ( (elua_ltr || eluac_ltr) && (old_metatable_bindings) ) need_constants = 1; else if (!is_instance) // static part need constants tab need_constants = 1; if (need_constants) Printv(output, const_tab, NIL); if (elua_ltr) { // Put forward declaration of metatable array Printv(output, "extern ", Getattr(carrays_hash, "metatable:decl"), "\n", NIL); } String *methods_tab = Getattr(carrays_hash, "methods"); String *metatable_tab_name = Getattr(carrays_hash, "metatable:name"); if (elua_ltr || eluac_ltr) { if (old_metatable_bindings) Printv(methods_tab, tab4, "{LSTRKEY(\"const\"), LROVAL(", const_tab_name, ")},\n", NIL); if (elua_ltr) { Printv(methods_tab, tab4, "{LSTRKEY(\"__metatable\"), LROVAL(", metatable_tab_name, ")},\n", NIL); } Printv(methods_tab, tab4, "{LSTRKEY(\"__disown\"), LFUNCVAL(SWIG_Lua_class_disown)},\n", NIL); Printv(methods_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); } else Printf(methods_tab, " {0,0}\n};\n"); Printv(output, methods_tab, NIL); if (!GetFlag(carrays_hash, "lua:no_classes")) { String *classes_tab = Getattr(carrays_hash, "classes"); Printf(classes_tab, " 0\n};\n"); Printv(output, classes_tab, NIL); } if (!GetFlag(carrays_hash, "lua:no_namespaces")) { String *namespaces_tab = Getattr(carrays_hash, "namespaces"); Printf(namespaces_tab, " 0\n};\n"); Printv(output, namespaces_tab, NIL); } if (elua_ltr) { String *get_tab = Getattr(carrays_hash, "get"); String *set_tab = Getattr(carrays_hash, "set"); Printv(get_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); Printv(set_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); Printv(output, get_tab, NIL); Printv(output, set_tab, NIL); } // Heuristic whether we need to print metatable or not. // For the sake of compiling with -Wall -Werror we don't print // metatable for static part. int need_metatable = 0; if (eluac_ltr) need_metatable = 0; else if(!is_instance) need_metatable = 0; else need_metatable = 1; if (need_metatable) { String *metatable_tab = Getattr(carrays_hash, "metatable"); assert(metatable_tab); if (elua_ltr) { String *get_tab_name = Getattr(carrays_hash, "get:name"); String *set_tab_name = Getattr(carrays_hash, "set:name"); if (GetFlag(carrays_hash, "lua:class_instance")) { Printv(metatable_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_class_get)},\n", NIL); Printv(metatable_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_class_set)},\n", NIL); } else { Printv(metatable_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_namespace_get)},\n", NIL); Printv(metatable_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_namespace_set)},\n", NIL); } Printv(metatable_tab, tab4, "{LSTRKEY(\"__gc\"), LFUNCVAL(SWIG_Lua_class_destruct)},\n", NIL); Printv(metatable_tab, tab4, "{LSTRKEY(\".get\"), LROVAL(", get_tab_name, ")},\n", NIL); Printv(metatable_tab, tab4, "{LSTRKEY(\".set\"), LROVAL(", set_tab_name, ")},\n", NIL); Printv(metatable_tab, tab4, "{LSTRKEY(\".fn\"), LROVAL(", Getattr(carrays_hash, "methods:name"), ")},\n", NIL); if (GetFlag(carrays_hash, "lua:class_instance")) { String *static_cls = Getattr(carrays_hash, "lua:class_instance:static_hash"); assert(static_cls); // static_cls is swig_lua_namespace. This structure can't be use with eLua(LTR) // Instead structure describing its methods isused String *static_cls_cname = Getattr(static_cls, "methods:name"); assert(static_cls_cname); Printv(metatable_tab, tab4, "{LSTRKEY(\".static\"), LROVAL(", static_cls_cname, ")},\n", NIL); // Put forward declaration of this array Printv(output, "extern ", Getattr(static_cls, "methods:decl"), "\n", NIL); } else if (GetFlag(carrays_hash, "lua:class_static")) { Hash *instance_cls = Getattr(carrays_hash, "lua:class_static:instance_hash"); assert(instance_cls); String *instance_cls_metatable_name = Getattr(instance_cls, "metatable:name"); assert(instance_cls_metatable_name); Printv(metatable_tab, tab4, "{LSTRKEY(\".instance\"), LROVAL(", instance_cls_metatable_name, ")},\n", NIL); } Printv(metatable_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); } else { Printf(metatable_tab, " {0,0}\n};\n"); } Printv(output, metatable_tab, NIL); } Printv(output, "\n", NIL); } /* ----------------------------------------------------------------------------- * closeNamespaces() * * Recursively close all non-closed namespaces. Prints data to dataOutput. * ----------------------------------------------------------------------------- */ void closeNamespaces(File *dataOutput) { // Special handling for empty module. if (symbolScopeLookup("") == 0 || rawGetCArraysHash("") == 0) { // Module is empty. Create hash for global scope in order to have swig_SwigModule // variable in resulting file getCArraysHash(0); } // Because we cant access directly 'symtabs', instead we access // top-level scope and look on all scope pseudo-symbols in it. Hash *top_scope = symbolScopeLookup(""); assert(top_scope); Iterator ki = First(top_scope); List *to_close = NewList(); while (ki.key) { assert(ki.item); if (Getattr(ki.item, "sym:scope")) { // We have a pseudo symbol. Lets get actual scope for this pseudo symbol Hash *carrays_hash = rawGetCArraysHash(ki.key); assert(carrays_hash); if (GetFlag(carrays_hash, "lua:closed") == 0) Append(to_close, ki.key); } ki = Next(ki); } SortList(to_close, &compareByLen); int len = Len(to_close); for (int i = 0; i < len; i++) { String *key = Getitem(to_close, i); closeCArraysHash(key, dataOutput); Hash *carrays_hash = rawGetCArraysHash(key); String *name = 0; // name - name of the namespace as it should be visible in Lua if (DohLen(key) == 0) // This is global module name = module; else name = Getattr(carrays_hash, "name"); assert(name); printCArraysDefinition(key, name, dataOutput); } Delete(to_close); } /* ----------------------------------------------------------------------------- * printCArraysDefinition() * * This function prints to output a definition of namespace in form * swig_lua_namespace $cname = { attr_array, methods_array, ... , namespaces_array }; * You can call this function as many times as is necessary. * 'name' is a user-visible name that this namespace will have in Lua. It shouldn't * be a fully qualified name, just its own name. * ----------------------------------------------------------------------------- */ void printCArraysDefinition(String *nspace, String *name, File *output) { Hash *carrays_hash = getCArraysHash(nspace, false); String *cname = Getattr(carrays_hash, "cname"); // cname - name of the C structure that describes namespace assert(cname); Printv(output, "static swig_lua_namespace ", cname, " = ", NIL); String *null_string = NewString("0"); String *attr_tab_name = Getattr(carrays_hash, "attributes:name"); String *methods_tab_name = Getattr(carrays_hash, "methods:name"); String *const_tab_name = Getattr(carrays_hash, "constants:name"); String *classes_tab_name = Getattr(carrays_hash, "classes:name"); String *namespaces_tab_name = Getattr(carrays_hash, "namespaces:name"); bool has_classes = GetFlag(carrays_hash, "lua:no_classes") == 0; bool has_namespaces = GetFlag(carrays_hash, "lua:no_namespaces") == 0; Printv(output, "{\n", tab4, "\"", name, "\",\n", tab4, methods_tab_name, ",\n", tab4, attr_tab_name, ",\n", tab4, const_tab_name, ",\n", tab4, (has_classes) ? classes_tab_name : null_string, ",\n", tab4, (has_namespaces) ? namespaces_tab_name : null_string, "\n};\n", NIL); Delete(null_string); } /* ----------------------------------------------------------------------------- * luaCurrentSymbolNSpace() * * This function determines actual namespace/scope where any symbol at the * current moment should be placed. It looks at the 'current' array * and depending on where are we - static class member/function, * instance class member/function or just global functions decides * where symbol should be put. * The namespace/scope doesn't depend from symbol, only from 'current' * ----------------------------------------------------------------------------- */ String *luaCurrentSymbolNSpace() { String *scope = 0; // If ouside class, than NSpace is used. // If inside class, but current[NO_CPP], then this is friend function. It belongs to NSpace if (!getCurrentClass() || current[NO_CPP]) { scope = getNSpace(); } else if (current[ENUM_CONST] && !CPlusPlus ) { // Enums in C mode go to NSpace scope = getNSpace(); } else { // If inside class, then either class static namespace or class fully qualified name is used assert(!current[NO_CPP]); if (current[STATIC_FUNC] || current[STATIC_VAR] || current[STATIC_CONST]) { scope = class_static_nspace; } else if (current[MEMBER_VAR] || current[CONSTRUCTOR] || current[DESTRUCTOR] || current[MEMBER_FUNC]) { scope = full_proxy_class_name; } else { // Friend functions are handled this way scope = class_static_nspace; } assert(scope); } return scope; } /* ----------------------------------------------------------------------------- * luaAddSymbol() * * Our implementation of addSymbol. Determines scope correctly, then * forwards to Language::addSymbol * ----------------------------------------------------------------------------- */ int luaAddSymbol(const String *s, const Node *n) { String *scope = luaCurrentSymbolNSpace(); return luaAddSymbol(s, n, scope); } /* ----------------------------------------------------------------------------- * luaAddSymbol() * * Overload. Enforces given scope. Actually, it simply forwards call to Language::addSymbol * ----------------------------------------------------------------------------- */ int luaAddSymbol(const String *s, const Node *n, const_String_or_char_ptr scope) { int result = Language::addSymbol(s, n, scope); if (!result) Printf(stderr, "addSymbol(%s to scope %s) failed\n", s, scope); return result; } }; /* NEW LANGUAGE NOTE:*********************************************** in order to add you language into swig, you need to make the following changes: - write this file (obviously) - add into the makefile (not 100% clear on how to do this) - edit swigmain.cxx to add your module near the top of swigmain.cxx, look for this code & add you own codes ======= begin change ========== extern "C" { Language *swig_tcl(void); Language *swig_python(void); //etc,etc,etc... Language *swig_lua(void); // this is my code } //etc,etc,etc... swig_module modules[] = { {"-guile", swig_guile, "Guile"}, {"-java", swig_java, "Java"}, //etc,etc,etc... {"-lua", swig_lua, "Lua"}, // this is my code {NULL, NULL, NULL} // this must come at the end of the list }; ======= end change ========== This is all that is needed NEW LANGUAGE NOTE:END ************************************************/ /* ----------------------------------------------------------------------------- * swig_lua() - Instantiate module * ----------------------------------------------------------------------------- */ extern "C" Language *swig_lua(void) { return new LUA(); } swig-3.0.2/Source/Modules/module.cxx0000664000175000017500000000333512343605122017230 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * module.cxx * * This file is responsible for the module system. * ----------------------------------------------------------------------------- */ #include "swigmod.h" struct Module { ModuleFactory fac; char *name; Module *next; Module(const char *n, ModuleFactory f) { fac = f; name = new char[strlen(n) + 1]; strcpy(name, n); next = 0; } ~Module() { delete[]name; } }; static Module *modules = 0; /* ----------------------------------------------------------------------------- * void Swig_register_module() * * Register a module. * ----------------------------------------------------------------------------- */ void Swig_register_module(const char *n, ModuleFactory f) { Module *m = new Module(n, f); m->next = modules; modules = m; } /* ----------------------------------------------------------------------------- * Language *Swig_find_module() * * Given a command line option, locates the factory function. * ----------------------------------------------------------------------------- */ ModuleFactory Swig_find_module(const char *name) { Module *m = modules; while (m) { if (strcmp(m->name, name) == 0) { return m->fac; } m = m->next; } return 0; } swig-3.0.2/Source/DOH/0000775000175000017500000000000012343605122014215 5ustar williamwilliamswig-3.0.2/Source/DOH/README0000664000175000017500000001112512343605122015075 0ustar williamwilliamDOH (Dave's Object Hack) Overview: --------- DOH is a small C library that provides a number of simple yet powerful data structures. The data structures are built around a dynamic typing model in which any given object is allowed to support one or more classes of operations. Furthermore, a simple garbage collection scheme and a variety of interesting library methods are available. All and all, the operation of DOH makes massive abuse of the C type system and would probably make the language purists scream and performance addicts run away in horror. However, I really don't care--so there! However, for the rest of us, DOH is actually kind of fun to use. This is only a short description of the methods and is no way meant to be exhaustive. Common Operations (for all types) --------------------------------- Delete(obj) Decrease the reference count and destroy if zero Copy(obj) Make a copy of an object. Clear(obj) Clear an object. Setscope(obj) Set scope of an object (guru's only) Str(obj) Create a string representation of obj. Data(obj) Return pointer to raw data in an object Char(obj) Convert to a char * Len(obj) Length of an object Hash(obj) Hash value (used for mapping) Cmp(obj1,obj2) Compare two objects. Name(obj) Return the object name First(obj) Return first object (iterator) Next(obj) Return next object Dump(obj,out) Serialize on out Load(in) Unserialize from in First(obj) Iterator Next(iter) Next iterator Mapping Operations (for hash table behavior) -------------------------------------------- Getattr(hash,key) Get an attribute Setattr(hash,key,value) Set an attribute Delattr(hash,key) Delete an attribute First(hash) Get first object (iterator) Next(hash) Get next object GetInt(hash,key) Get attribute as an 'int' SetInt(hash,key,ivalue) Set attribute as an 'int' GetDouble(hash,key) Get attribute as a 'double' SetDouble(hash,key,dvalue) Set Attribute as a 'double' GetChar(hash,key) Get attribute as a 'char *' Sequence Operations ------------------- Getitem(list,index) Get an item Setitem(list,index,val) Set an item Delitem(list,index) Delete an item Insert(list,index,val) Insert an item Append(list,val) Append to end Push(list,val) Insert at beginning File Operations --------------- Read(obj,buffer,len) Read data Write(obj,buffer,len) Write data Getc(obj) Get a character Putc(ch,obj) Put a character Ungetc(ch,obj) Put character back on input stream Seek(obj,offset,whence) Seek Tell(obj) Return file pointer Delete(obj) Decrease the reference count, close file if zero String Operations ----------------- Replace(obj, orig, rep, flags) Replace occurrences of orig with rep. Chop(obj) Remove trailing whitespace flags is one of the following: DOH_REPLACE_ANY DOH_REPLACE_NOQUOTE DOH_REPLACE_ID DOH_REPLACE_FIRST Callable Operations ------------------- Call(obj, args) Perform a function call with arguments args. Miscellaneous library functions ------------------------------- NewScope() Create a new scope DelScope(s) Delete scope s Readline(in) Read a line of input from in Printf(out,fmt,...) Formatted output DohEncoding(name, fn) Register a format encoding for Printf Currently Available datatypes ------------------------------ NewString(char *initial) Strings NewHash() Hash NewList() List NewVoid(void *ptr, void (*del)(void *)) Void NewFile(char *filename, char *mode, List *newfiles) File NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object Odds and ends: 1. All objects are of type 'DOH *' 2. When in doubt, see rule (1) 3. In certain cases, DOH performs implicit conversions of 'char *' to an appropriate DOH string representation. For operations involving files, DOH works with many kinds of objects including FILE *, DOH File objects, and DOH strings. Don't even ask how this works. 4. More complete documentation is forthcoming. swig-3.0.2/Source/DOH/memory.c0000664000175000017500000001434212343605122015675 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * memory.c * * This file implements all of DOH's memory management including allocation * of objects and checking of objects. * ----------------------------------------------------------------------------- */ #include "dohint.h" #ifndef DOH_POOL_SIZE #define DOH_POOL_SIZE 16384 #endif /* Checks stale DOH object use - will use a lot more memory as pool memory is not re-used. */ /* #define DOH_DEBUG_MEMORY_POOLS */ static int PoolSize = DOH_POOL_SIZE; DOH *DohNone = 0; /* The DOH None object */ typedef struct pool { DohBase *ptr; /* Start of pool */ int len; /* Length of pool */ int blen; /* Byte length of pool */ int current; /* Current position for next allocation */ char *pbeg; /* Beg of pool */ char *pend; /* End of pool */ struct pool *next; /* Next pool */ } Pool; static DohBase *FreeList = 0; /* List of free objects */ static Pool *Pools = 0; static int pools_initialized = 0; /* ---------------------------------------------------------------------- * CreatePool() - Create a new memory pool * ---------------------------------------------------------------------- */ static void CreatePool() { Pool *p = 0; p = (Pool *) DohMalloc(sizeof(Pool)); assert(p); p->ptr = (DohBase *) DohMalloc(sizeof(DohBase) * PoolSize); assert(p->ptr); memset(p->ptr, 0, sizeof(DohBase) * PoolSize); p->len = PoolSize; p->blen = PoolSize * sizeof(DohBase); p->current = 0; p->pbeg = ((char *) p->ptr); p->pend = p->pbeg + p->blen; p->next = Pools; Pools = p; } /* ---------------------------------------------------------------------- * InitPools() - Initialize the memory allocator * ---------------------------------------------------------------------- */ static void InitPools() { if (pools_initialized) return; CreatePool(); /* Create initial pool */ pools_initialized = 1; DohNone = NewVoid(0, 0); /* Create the None object */ DohIntern(DohNone); } /* ---------------------------------------------------------------------- * DohCheck() * * Returns 1 if an arbitrary pointer is a DOH object. * ---------------------------------------------------------------------- */ int DohCheck(const DOH *ptr) { register Pool *p = Pools; register char *cptr = (char *) ptr; while (p) { if ((cptr >= p->pbeg) && (cptr < p->pend)) { #ifdef DOH_DEBUG_MEMORY_POOLS DohBase *b = (DohBase *) ptr; int DOH_object_already_deleted = b->type == 0; assert(!DOH_object_already_deleted); #endif return 1; } /* pptr = (char *) p->ptr; if ((cptr >= pptr) && (cptr < (pptr+(p->current*sizeof(DohBase))))) return 1; */ p = p->next; } return 0; } /* ----------------------------------------------------------------------------- * DohIntern() * ----------------------------------------------------------------------------- */ void DohIntern(DOH *obj) { DohBase *b = (DohBase *) obj; b->flag_intern = 1; } /* ---------------------------------------------------------------------- * DohObjMalloc() * * Allocate memory for a new object. * ---------------------------------------------------------------------- */ DOH *DohObjMalloc(DohObjInfo *type, void *data) { DohBase *obj; if (!pools_initialized) InitPools(); #ifndef DOH_DEBUG_MEMORY_POOLS if (FreeList) { obj = FreeList; FreeList = (DohBase *) obj->data; } else { #endif while (Pools->current == Pools->len) { CreatePool(); } obj = Pools->ptr + Pools->current; ++Pools->current; #ifndef DOH_DEBUG_MEMORY_POOLS } #endif obj->type = type; obj->data = data; obj->meta = 0; obj->refcount = 1; obj->flag_intern = 0; obj->flag_marked = 0; obj->flag_user = 0; obj->flag_usermark = 0; return (DOH *) obj; } /* ---------------------------------------------------------------------- * DohObjFree() - Free a DOH object * ---------------------------------------------------------------------- */ void DohObjFree(DOH *ptr) { DohBase *b, *meta; b = (DohBase *) ptr; if (b->flag_intern) return; meta = (DohBase *) b->meta; b->data = (void *) FreeList; b->meta = 0; b->type = 0; b->refcount = 0; FreeList = b; if (meta) { Delete(meta); } } /* ---------------------------------------------------------------------- * DohMemoryDebug() * * Display memory usage statistics * ---------------------------------------------------------------------- */ void DohMemoryDebug(void) { extern DohObjInfo DohStringType; extern DohObjInfo DohListType; extern DohObjInfo DohHashType; Pool *p; int totsize = 0; int totused = 0; int totfree = 0; int numstring = 0; int numlist = 0; int numhash = 0; printf("Memory statistics:\n\n"); printf("Pools:\n"); p = Pools; while (p) { /* Calculate number of used, free items */ int i; int nused = 0, nfree = 0; for (i = 0; i < p->len; i++) { if (p->ptr[i].refcount <= 0) nfree++; else { nused++; if (p->ptr[i].type == &DohStringType) numstring++; else if (p->ptr[i].type == &DohListType) numlist++; else if (p->ptr[i].type == &DohHashType) numhash++; } } printf(" Pool %8p: size = %10d. used = %10d. free = %10d\n", (void *) p, p->len, nused, nfree); totsize += p->len; totused += nused; totfree += nfree; p = p->next; } printf("\n Total: size = %10d, used = %10d, free = %10d\n", totsize, totused, totfree); printf("\nObject types\n"); printf(" Strings : %d\n", numstring); printf(" Lists : %d\n", numlist); printf(" Hashes : %d\n", numhash); #if 0 p = Pools; while (p) { int i; for (i = 0; i < p->len; i++) { if (p->ptr[i].refcount > 0) { if (p->ptr[i].type == &DohStringType) { Printf(stdout, "%s\n", p->ptr + i); } } } p = p->next; } #endif } swig-3.0.2/Source/DOH/file.c0000664000175000017500000001724512343605122015311 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * file.c * * This file implements a file-like object that can be built around an * ordinary FILE * or integer file descriptor. * ----------------------------------------------------------------------------- */ #include "dohint.h" #ifdef DOH_INTFILE #include #endif #include typedef struct { FILE *filep; int fd; int closeondel; } DohFile; /* ----------------------------------------------------------------------------- * DelFile() * ----------------------------------------------------------------------------- */ static void DelFile(DOH *fo) { DohFile *f = (DohFile *) ObjData(fo); if (f->closeondel) { if (f->filep) { fclose(f->filep); } #ifdef DOH_INTFILE if (f->fd) { close(f->fd); } #endif } DohFree(f); } /* ----------------------------------------------------------------------------- * File_read() * ----------------------------------------------------------------------------- */ static int File_read(DOH *fo, void *buffer, int len) { DohFile *f = (DohFile *) ObjData(fo); if (f->filep) { return fread(buffer, 1, len, f->filep); } else if (f->fd) { #ifdef DOH_INTFILE return read(f->fd, buffer, len); #endif } return -1; } /* ----------------------------------------------------------------------------- * File_write() * ----------------------------------------------------------------------------- */ static int File_write(DOH *fo, const void *buffer, int len) { DohFile *f = (DohFile *) ObjData(fo); if (f->filep) { int ret = (int) fwrite(buffer, 1, len, f->filep); int err = (ret != len) ? ferror(f->filep) : 0; return err ? -1 : ret; } else if (f->fd) { #ifdef DOH_INTFILE return write(f->fd, buffer, len); #endif } return -1; } /* ----------------------------------------------------------------------------- * File_seek() * ----------------------------------------------------------------------------- */ static int File_seek(DOH *fo, long offset, int whence) { DohFile *f = (DohFile *) ObjData(fo); if (f->filep) { return fseek(f->filep, offset, whence); } else if (f->fd) { #ifdef DOH_INTFILE return lseek(f->fd, offset, whence); #endif } return -1; } /* ----------------------------------------------------------------------------- * File_tell() * ----------------------------------------------------------------------------- */ static long File_tell(DOH *fo) { DohFile *f = (DohFile *) ObjData(fo); if (f->filep) { return ftell(f->filep); } else if (f->fd) { #ifdef DOH_INTFILE return lseek(f->fd, 0, SEEK_CUR); #endif } return -1; } /* ----------------------------------------------------------------------------- * File_putc() * ----------------------------------------------------------------------------- */ static int File_putc(DOH *fo, int ch) { DohFile *f = (DohFile *) ObjData(fo); if (f->filep) { return fputc(ch, f->filep); } else if (f->fd) { #ifdef DOH_INTFILE char c; c = (char) ch; return write(f->fd, &c, 1); #endif } return -1; } /* ----------------------------------------------------------------------------- * File_getc() * ----------------------------------------------------------------------------- */ static int File_getc(DOH *fo) { DohFile *f = (DohFile *) ObjData(fo); if (f->filep) { return fgetc(f->filep); } else if (f->fd) { #ifdef DOH_INTFILE unsigned char c; if (read(f->fd, &c, 1) < 0) return EOF; return c; #endif } return EOF; } /* ----------------------------------------------------------------------------- * File_ungetc() * * Put a character back onto the input * ----------------------------------------------------------------------------- */ static int File_ungetc(DOH *fo, int ch) { DohFile *f = (DohFile *) ObjData(fo); if (f->filep) { return ungetc(ch, f->filep); } else if (f->fd) { #ifdef DOH_INTFILE /* Not implemented yet */ #endif } return -1; } /* ----------------------------------------------------------------------------- * File_close() * * Close the file * ----------------------------------------------------------------------------- */ static int File_close(DOH *fo) { int ret = 0; DohFile *f = (DohFile *) ObjData(fo); if (f->filep) { ret = fclose(f->filep); f->filep = 0; } else if (f->fd) { #ifdef DOH_INTFILE ret = close(f->fd); f->fd = 0; #endif } return ret; } static DohFileMethods FileFileMethods = { File_read, File_write, File_putc, File_getc, File_ungetc, File_seek, File_tell, File_close, /* close */ }; static DohObjInfo DohFileType = { "DohFile", /* objname */ DelFile, /* doh_del */ 0, /* doh_copy */ 0, /* doh_clear */ 0, /* doh_str */ 0, /* doh_data */ 0, /* doh_dump */ 0, /* doh_len */ 0, /* doh_hash */ 0, /* doh_cmp */ 0, /* doh_equal */ 0, /* doh_first */ 0, /* doh_next */ 0, /* doh_setfile */ 0, /* doh_getfile */ 0, /* doh_setline */ 0, /* doh_getline */ 0, /* doh_mapping */ 0, /* doh_sequence */ &FileFileMethods, /* doh_file */ 0, /* doh_string */ 0, /* doh_callable */ 0, /* doh_position */ }; /* ----------------------------------------------------------------------------- * NewFile() * * Create a new file from a given filename and mode. * If newfiles is non-zero, the filename is added to the list of new files. * ----------------------------------------------------------------------------- */ DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) { DohFile *f; FILE *file; char *filen; filen = Char(filename); file = fopen(filen, mode); if (!file) return 0; f = (DohFile *) DohMalloc(sizeof(DohFile)); if (!f) { fclose(file); return 0; } if (newfiles) Append(newfiles, filename); f->filep = file; f->fd = 0; f->closeondel = 1; return DohObjMalloc(&DohFileType, f); } /* ----------------------------------------------------------------------------- * NewFileFromFile() * * Create a file object from an already open FILE *. * ----------------------------------------------------------------------------- */ DOH *DohNewFileFromFile(FILE *file) { DohFile *f; f = (DohFile *) DohMalloc(sizeof(DohFile)); if (!f) return 0; f->filep = file; f->fd = 0; f->closeondel = 0; return DohObjMalloc(&DohFileType, f); } /* ----------------------------------------------------------------------------- * NewFileFromFd() * * Create a file object from an already open FILE *. * ----------------------------------------------------------------------------- */ DOH *DohNewFileFromFd(int fd) { DohFile *f; f = (DohFile *) DohMalloc(sizeof(DohFile)); if (!f) return 0; f->filep = 0; f->fd = fd; f->closeondel = 0; return DohObjMalloc(&DohFileType, f); } /* ----------------------------------------------------------------------------- * FileErrorDisplay() * * Display cause of one of the NewFile functions failing. * ----------------------------------------------------------------------------- */ void DohFileErrorDisplay(DOHString * filename) { Printf(stderr, "Unable to open file %s: %s\n", filename, strerror(errno)); } swig-3.0.2/Source/DOH/doh.h0000664000175000017500000004166412343605122015153 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * doh.h * * This file describes of the externally visible functions in DOH. * ----------------------------------------------------------------------------- */ #ifndef _DOH_H #define _DOH_H #ifndef MACSWIG #include "swigconfig.h" #endif #include #include /* Set the namespace prefix for DOH API functions. This can be used to control visibility of the functions in libraries */ /* Set this macro if you want to change DOH linkage. You would do this if you wanted to hide DOH in a library using a different set of names. Note: simply change "Doh" to a new name. */ /* #define DOH_NAMESPACE(x) Doh ## x */ #ifdef DOH_NAMESPACE /* Namespace control. These macros define all of the public API names in DOH */ #define DohCheck DOH_NAMESPACE(Check) #define DohIntern DOH_NAMESPACE(Intern) #define DohDelete DOH_NAMESPACE(Delete) #define DohCopy DOH_NAMESPACE(Copy) #define DohClear DOH_NAMESPACE(Clear) #define DohStr DOH_NAMESPACE(Str) #define DohData DOH_NAMESPACE(Data) #define DohDump DOH_NAMESPACE(Dump) #define DohLen DOH_NAMESPACE(Len) #define DohHashval DOH_NAMESPACE(Hashval) #define DohCmp DOH_NAMESPACE(Cmp) #define DohEqual DOH_NAMESPACE(Equal) #define DohIncref DOH_NAMESPACE(Incref) #define DohCheckattr DOH_NAMESPACE(Checkattr) #define DohSetattr DOH_NAMESPACE(Setattr) #define DohDelattr DOH_NAMESPACE(Delattr) #define DohKeys DOH_NAMESPACE(Keys) #define DohGetInt DOH_NAMESPACE(GetInt) #define DohGetDouble DOH_NAMESPACE(GetDouble) #define DohGetChar DOH_NAMESPACE(GetChar) #define DohSetChar DOH_NAMESPACE(SetChar) #define DohSetInt DOH_NAMESPACE(SetInt) #define DohSetDouble DOH_NAMESPACE(SetDouble) #define DohSetVoid DOH_NAMESPACE(SetVoid) #define DohGetVoid DOH_NAMESPACE(GetVoid) #define DohGetitem DOH_NAMESPACE(Getitem) #define DohSetitem DOH_NAMESPACE(Setitem) #define DohDelitem DOH_NAMESPACE(Delitem) #define DohInsertitem DOH_NAMESPACE(Insertitem) #define DohDelslice DOH_NAMESPACE(Delslice) #define DohWrite DOH_NAMESPACE(Write) #define DohRead DOH_NAMESPACE(Read) #define DohSeek DOH_NAMESPACE(Seek) #define DohTell DOH_NAMESPACE(Tell) #define DohGetc DOH_NAMESPACE(Getc) #define DohPutc DOH_NAMESPACE(Putc) #define DohUngetc DOH_NAMESPACE(Ungetc) #define DohGetline DOH_NAMESPACE(Getline) #define DohSetline DOH_NAMESPACE(Setline) #define DohGetfile DOH_NAMESPACE(Getfile) #define DohSetfile DOH_NAMESPACE(Setfile) #define DohReplace DOH_NAMESPACE(Replace) #define DohChop DOH_NAMESPACE(Chop) #define DohGetmeta DOH_NAMESPACE(Getmeta) #define DohSetmeta DOH_NAMESPACE(Setmeta) #define DohDelmeta DOH_NAMESPACE(Delmeta) #define DohEncoding DOH_NAMESPACE(Encoding) #define DohPrintf DOH_NAMESPACE(Printf) #define DohvPrintf DOH_NAMESPACE(vPrintf) #define DohPrintv DOH_NAMESPACE(Printv) #define DohReadline DOH_NAMESPACE(Readline) #define DohIsMapping DOH_NAMESPACE(IsMapping) #define DohIsSequence DOH_NAMESPACE(IsSequence) #define DohIsString DOH_NAMESPACE(IsString) #define DohIsFile DOH_NAMESPACE(IsFile) #define DohNewString DOH_NAMESPACE(NewString) #define DohNewStringEmpty DOH_NAMESPACE(NewStringEmpty) #define DohNewStringWithSize DOH_NAMESPACE(NewStringWithSize) #define DohNewStringf DOH_NAMESPACE(NewStringf) #define DohStrcmp DOH_NAMESPACE(Strcmp) #define DohStrncmp DOH_NAMESPACE(Strncmp) #define DohStrstr DOH_NAMESPACE(Strstr) #define DohStrchr DOH_NAMESPACE(Strchr) #define DohNewFile DOH_NAMESPACE(NewFile) #define DohNewFileFromFile DOH_NAMESPACE(NewFileFromFile) #define DohNewFileFromFd DOH_NAMESPACE(NewFileFromFd) #define DohFileErrorDisplay DOH_NAMESPACE(FileErrorDisplay) #define DohClose DOH_NAMESPACE(Close) #define DohCopyto DOH_NAMESPACE(Copyto) #define DohNewList DOH_NAMESPACE(NewList) #define DohNewHash DOH_NAMESPACE(NewHash) #define DohNewVoid DOH_NAMESPACE(NewVoid) #define DohSplit DOH_NAMESPACE(Split) #define DohSplitLines DOH_NAMESPACE(SplitLines) #define DohNone DOH_NAMESPACE(None) #define DohCall DOH_NAMESPACE(Call) #define DohObjMalloc DOH_NAMESPACE(ObjMalloc) #define DohObjFree DOH_NAMESPACE(ObjFree) #define DohMemoryDebug DOH_NAMESPACE(MemoryDebug) #define DohStringType DOH_NAMESPACE(StringType) #define DohListType DOH_NAMESPACE(ListType) #define DohHashType DOH_NAMESPACE(HashType) #define DohFileType DOH_NAMESPACE(FileType) #define DohVoidType DOH_NAMESPACE(VoidType) #define DohIterator DOH_NAMESPACE(Iterator) #define DohFirst DOH_NAMESPACE(First) #define DohNext DOH_NAMESPACE(Next) #endif #define DOH_MAJOR_VERSION 0 #define DOH_MINOR_VERSION 1 typedef void DOH; /* * With dynamic typing, all DOH objects are technically of type 'void *'. * However, to clarify the reading of source code, the following symbolic * names are used. */ #define DOHString DOH #define DOHList DOH #define DOHHash DOH #define DOHFile DOH #define DOHVoid DOH #define DOHString_or_char DOH #define DOHObj_or_char DOH typedef const DOHString_or_char * const_String_or_char_ptr; typedef const DOHString_or_char * DOHconst_String_or_char_ptr; #define DOH_BEGIN -1 #define DOH_END -2 #define DOH_CUR -3 #define DOH_CURRENT -3 /* Iterator objects */ typedef struct { void *key; /* Current key (if any) */ void *item; /* Current item */ void *object; /* Object being iterated over */ void *_current; /* Internal use */ int _index; /* Internal use */ } DohIterator; /* Memory management */ #ifndef DohMalloc #define DohMalloc malloc #endif #ifndef DohRealloc #define DohRealloc realloc #endif #ifndef DohFree #define DohFree free #endif extern int DohCheck(const DOH *ptr); /* Check if a DOH object */ extern void DohIntern(DOH *); /* Intern an object */ /* Basic object methods. Common to most objects */ extern void DohDelete(DOH *obj); /* Delete an object */ extern DOH *DohCopy(const DOH *obj); extern void DohClear(DOH *obj); extern DOHString *DohStr(const DOH *obj); extern void *DohData(const DOH *obj); extern int DohDump(const DOH *obj, DOHFile * out); extern int DohLen(const DOH *obj); extern int DohHashval(const DOH *obj); extern int DohCmp(const DOH *obj1, const DOH *obj2); extern int DohEqual(const DOH *obj1, const DOH *obj2); extern void DohIncref(DOH *obj); /* Mapping methods */ extern DOH *DohGetattr(DOH *obj, const DOHString_or_char *name); extern int DohSetattr(DOH *obj, const DOHString_or_char *name, const DOHObj_or_char * value); extern int DohDelattr(DOH *obj, const DOHString_or_char *name); extern int DohCheckattr(DOH *obj, const DOHString_or_char *name, const DOHString_or_char *value); extern DOH *DohKeys(DOH *obj); extern int DohGetInt(DOH *obj, const DOHString_or_char *name); extern void DohSetInt(DOH *obj, const DOHString_or_char *name, int); extern double DohGetDouble(DOH *obj, const DOHString_or_char *name); extern void DohSetDouble(DOH *obj, const DOHString_or_char *name, double); extern char *DohGetChar(DOH *obj, const DOHString_or_char *name); extern void DohSetChar(DOH *obj, const DOH *name, char *value); extern void *DohGetFlagAttr(DOH *obj, const DOHString_or_char *name); extern int DohGetFlag(DOH *obj, const DOHString_or_char *name); extern void DohSetFlagAttr(DOH *obj, const DOHString_or_char *name, const DOHString_or_char *attr); extern void DohSetFlag(DOH *obj, const DOHString_or_char *name); extern void *DohGetVoid(DOH *obj, const DOHString_or_char *name); extern void DohSetVoid(DOH *obj, const DOHString_or_char *name, void *value); /* Sequence methods */ extern DOH *DohGetitem(DOH *obj, int index); extern int DohSetitem(DOH *obj, int index, const DOHObj_or_char * value); extern int DohDelitem(DOH *obj, int index); extern int DohInsertitem(DOH *obj, int index, const DOHObj_or_char * value); extern int DohDelslice(DOH *obj, int sindex, int eindex); /* File methods */ extern int DohWrite(DOHFile * obj, const void *buffer, int length); extern int DohRead(DOHFile * obj, void *buffer, int length); extern int DohSeek(DOHFile * obj, long offset, int whence); extern long DohTell(DOHFile * obj); extern int DohGetc(DOHFile * obj); extern int DohPutc(int ch, DOHFile * obj); extern int DohUngetc(int ch, DOHFile * obj); /* Iterators */ extern DohIterator DohFirst(DOH *obj); extern DohIterator DohNext(DohIterator x); /* Positional */ extern int DohGetline(const DOH *obj); extern void DohSetline(DOH *obj, int line); extern DOH *DohGetfile(const DOH *obj); extern void DohSetfile(DOH *obj, DOH *file); /* String Methods */ extern int DohReplace(DOHString * src, const DOHString_or_char *token, const DOHString_or_char *rep, int flags); extern void DohChop(DOHString * src); /* Meta-variables */ extern DOH *DohGetmeta(DOH *, const DOH *); extern int DohSetmeta(DOH *, const DOH *, const DOH *value); extern int DohDelmeta(DOH *, const DOH *); /* Utility functions */ extern void DohEncoding(const char *name, DOH *(*fn) (DOH *s)); extern int DohPrintf(DOHFile * obj, const char *format, ...); extern int DohvPrintf(DOHFile * obj, const char *format, va_list ap); extern int DohPrintv(DOHFile * obj, ...); extern DOH *DohReadline(DOHFile * in); /* Miscellaneous */ extern int DohIsMapping(const DOH *obj); extern int DohIsSequence(const DOH *obj); extern int DohIsString(const DOH *obj); extern int DohIsFile(const DOH *obj); extern void DohSetMaxHashExpand(int count); extern int DohGetMaxHashExpand(void); extern void DohSetmark(DOH *obj, int x); extern int DohGetmark(DOH *obj); /* ----------------------------------------------------------------------------- * Strings. * ----------------------------------------------------------------------------- */ extern DOHString *DohNewStringEmpty(void); extern DOHString *DohNewString(const DOHString_or_char *c); extern DOHString *DohNewStringWithSize(const DOHString_or_char *c, int len); extern DOHString *DohNewStringf(const DOHString_or_char *fmt, ...); extern int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2); extern int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n); extern char *DohStrstr(const DOHString_or_char *s1, const DOHString_or_char *s2); extern char *DohStrchr(const DOHString_or_char *s1, int ch); /* String replacement flags */ #define DOH_REPLACE_ANY 0x01 #define DOH_REPLACE_NOQUOTE 0x02 #define DOH_REPLACE_ID 0x04 #define DOH_REPLACE_FIRST 0x08 #define DOH_REPLACE_ID_BEGIN 0x10 #define DOH_REPLACE_ID_END 0x20 #define DOH_REPLACE_NUMBER_END 0x40 #define Replaceall(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ANY) #define Replaceid(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ID) /* ----------------------------------------------------------------------------- * Files * ----------------------------------------------------------------------------- */ extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles); extern DOHFile *DohNewFileFromFile(FILE *f); extern DOHFile *DohNewFileFromFd(int fd); extern void DohFileErrorDisplay(DOHString * filename); /* Deprecated, just use DohDelete extern int DohClose(DOH *file); */ extern int DohCopyto(DOHFile * input, DOHFile * output); /* ----------------------------------------------------------------------------- * List * ----------------------------------------------------------------------------- */ extern DOHList *DohNewList(void); extern void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *)); /* ----------------------------------------------------------------------------- * Hash * ----------------------------------------------------------------------------- */ extern DOHHash *DohNewHash(void); /* ----------------------------------------------------------------------------- * Void * ----------------------------------------------------------------------------- */ extern DOHVoid *DohNewVoid(void *ptr, void (*del) (void *)); extern DOHList *DohSplit(DOHFile * input, char ch, int nsplits); extern DOHList *DohSplitLines(DOHFile * input); extern DOH *DohNone; /* Helper union for converting between function and object pointers. */ typedef union DohFuncPtr { void* p; DOH *(*func)(DOH *); } DohFuncPtr_t; extern void DohMemoryDebug(void); #ifndef DOH_LONG_NAMES /* Macros to invoke the above functions. Includes the location of the caller to simplify debugging if something goes wrong */ #define Delete DohDelete #define Copy DohCopy #define Clear DohClear #define Str DohStr #define Dump DohDump #define Getattr DohGetattr #define Setattr DohSetattr #define Delattr DohDelattr #define Checkattr DohCheckattr #define Hashval DohHashval #define Getitem DohGetitem #define Setitem DohSetitem #define Delitem DohDelitem #define Insert DohInsertitem #define Delslice DohDelslice #define Append(s,x) DohInsertitem(s,DOH_END,x) #define Push(s,x) DohInsertitem(s,DOH_BEGIN,x) #define Len DohLen #define Data DohData #define Char (char *) Data #define Cmp DohCmp #define Equal DohEqual #define Setline DohSetline #define Getline DohGetline #define Setfile DohSetfile #define Getfile DohGetfile #define Write DohWrite #define Read DohRead #define Seek DohSeek #define Tell DohTell #define Printf DohPrintf #define Printv DohPrintv #define Getc DohGetc #define Putc DohPutc #define Ungetc DohUngetc /* #define StringPutc DohStringPutc */ /* #define StringGetc DohStringGetc */ /* #define StringUngetc DohStringUngetc */ /* #define StringAppend Append */ /* #define StringLen DohStringLen */ /* #define StringChar DohStringChar */ /* #define StringEqual DohStringEqual */ #define Close DohClose #define vPrintf DohvPrintf #define GetInt DohGetInt #define GetDouble DohGetDouble #define GetChar DohGetChar #define GetVoid DohGetVoid #define GetFlagAttr DohGetFlagAttr #define GetFlag DohGetFlag #define SetInt DohSetInt #define SetDouble DohSetDouble #define SetChar DohSetattr #define SetVoid DohSetVoid #define SetFlagAttr DohSetFlagAttr #define SetFlag DohSetFlag #define UnsetFlag(o,n) DohSetFlagAttr(o,n,NULL) #define ClearFlag(o,n) DohSetFlagAttr(o,n,"") #define Readline DohReadline #define Replace DohReplace #define Chop DohChop #define Getmeta DohGetmeta #define Setmeta DohSetmeta #define Delmeta DohDelmeta #define NewString DohNewString #define NewStringEmpty DohNewStringEmpty #define NewStringWithSize DohNewStringWithSize #define NewStringf DohNewStringf #define NewHash DohNewHash #define NewList DohNewList #define NewFile DohNewFile #define NewFileFromFile DohNewFileFromFile #define NewFileFromFd DohNewFileFromFd #define FileErrorDisplay DohFileErrorDisplay #define Close DohClose #define NewVoid DohNewVoid #define Keys DohKeys #define Strcmp DohStrcmp #define Strncmp DohStrncmp #define Strstr DohStrstr #define Strchr DohStrchr #define Copyto DohCopyto #define Split DohSplit #define SplitLines DohSplitLines #define Setmark DohSetmark #define Getmark DohGetmark #define SetMaxHashExpand DohSetMaxHashExpand #define GetMaxHashExpand DohGetMaxHashExpand #define None DohNone #define Call DohCall #define First DohFirst #define Next DohNext #define Iterator DohIterator #define SortList DohSortList #endif #ifdef NIL #undef NIL #endif #define NIL (char *) NULL #endif /* DOH_H */ swig-3.0.2/Source/DOH/fio.c0000664000175000017500000003217012343605122015141 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * fio.c * * This file implements a number of standard I/O operations included * formatted output, readline, and splitting. * ----------------------------------------------------------------------------- */ #include "dohint.h" #define OBUFLEN 512 static DOH *encodings = 0; /* Encoding hash */ /* ----------------------------------------------------------------------------- * Writen() * * Writes N characters of output and retries until all characters are * written. This is useful should a write operation encounter a spurious signal. * ----------------------------------------------------------------------------- */ static int Writen(DOH *out, void *buffer, int len) { int nw = len, ret; char *cb = (char *) buffer; while (nw) { ret = Write(out, cb, nw); if (ret < 0) return -1; nw = nw - ret; cb += ret; } return len; } /* ----------------------------------------------------------------------------- * DohEncoding() * * Registers a new printf encoding method. An encoder function should accept * two file-like objects and operate as a filter. * ----------------------------------------------------------------------------- */ void DohEncoding(const char *name, DOH *(*fn) (DOH *s)) { DohFuncPtr_t fp; if (!encodings) encodings = NewHash(); fp.func = fn; Setattr(encodings, (void *) name, NewVoid(fp.p, 0)); } /* internal function for processing an encoding */ static DOH *encode(char *name, DOH *s) { DOH *handle, *ns; DohFuncPtr_t fp; long pos; char *cfmt = strchr(name, ':'); DOH *tmp = 0; if (cfmt) { tmp = NewString(cfmt + 1); Append(tmp, s); Setfile(tmp, Getfile((DOH *) s)); Setline(tmp, Getline((DOH *) s)); *cfmt = '\0'; } if (!encodings || !(handle = Getattr(encodings, name))) { return Copy(s); } if (tmp) s = tmp; pos = Tell(s); Seek(s, 0, SEEK_SET); fp.p = Data(handle); ns = (*fp.func) (s); assert(pos != -1); (void)Seek(s, pos, SEEK_SET); if (tmp) Delete(tmp); return ns; } /* ----------------------------------------------------------------------------- * DohvPrintf() * * DOH implementation of printf. Output can be directed to any file-like object * including bare FILE * objects. The same formatting codes as printf are * recognized with two extensions: * * %s - Prints a "char *" or the string representation of any * DOH object. This will implicitly result in a call to * Str(obj). * * %(encoder)* - Filters the output through an encoding function registered * with DohEncoder(). * * Note: This function is not particularly memory efficient with large strings. * It's better to use Dump() or some other method instead. * ----------------------------------------------------------------------------- */ int DohvPrintf(DOH *so, const char *format, va_list ap) { static const char *fmt_codes = "dioxXucsSfeEgGpn"; int state = 0; const char *p = format; char newformat[256]; char obuffer[OBUFLEN]; char *fmt = 0; char temp[64]; int widthval = 0; int precval = 0; int maxwidth; char *w = 0; int ivalue; double dvalue; void *pvalue; char *stemp; int nbytes = 0; char encoder[128], *ec = 0; int plevel = 0; memset(newformat, 0, sizeof(newformat)); while (*p) { switch (state) { case 0: /* Ordinary text */ if (*p != '%') { Putc(*p, so); nbytes++; } else { fmt = newformat; widthval = 0; precval = 0; *(fmt++) = *p; encoder[0] = 0; state = 10; } break; case 10: /* Look for a width and precision */ if (isdigit((int) *p) && (*p != '0')) { w = temp; *(w++) = *p; *(fmt++) = *p; state = 20; } else if (strchr(fmt_codes, *p)) { /* Got one of the formatting codes */ p--; state = 100; } else if (*p == '*') { /* Width field is specified in the format list */ widthval = va_arg(ap, int); sprintf(temp, "%d", widthval); for (w = temp; *w; w++) { *(fmt++) = *w; } state = 30; } else if (*p == '%') { Putc(*p, so); fmt = newformat; nbytes++; state = 0; } else if (*p == '(') { ++plevel; ec = encoder; state = 60; } else { *(fmt++) = *p; } break; case 20: /* Hmmm. At the start of a width field */ if (isdigit((int) *p)) { *(w++) = *p; *(fmt++) = *p; } else if (strchr(fmt_codes, *p)) { /* Got one of the formatting codes */ /* Figure out width */ *w = 0; widthval = atoi(temp); p--; state = 100; } else if (*p == '.') { *w = 0; widthval = atoi(temp); w = temp; *(fmt++) = *p; state = 40; } else { /* ??? */ *w = 0; widthval = atoi(temp); state = 50; } break; case 30: /* Parsed a width from an argument. Look for a . */ if (*p == '.') { w = temp; *(fmt++) = *p; state = 40; } else if (strchr(fmt_codes, *p)) { /* Got one of the formatting codes */ /* Figure out width */ p--; state = 100; } else { /* hmmm. Something else. */ state = 50; } break; case 40: /* Start of precision expected */ if (isdigit((int) *p) && (*p != '0')) { *(fmt++) = *p; *(w++) = *p; state = 41; } else if (*p == '*') { /* Precision field is specified in the format list */ precval = va_arg(ap, int); sprintf(temp, "%d", precval); for (w = temp; *w; w++) { *(fmt++) = *w; } state = 50; } else if (strchr(fmt_codes, *p)) { p--; state = 100; } else { *(fmt++) = *p; state = 50; } break; case 41: if (isdigit((int) *p)) { *(fmt++) = *p; *(w++) = *p; } else if (strchr(fmt_codes, *p)) { /* Got one of the formatting codes */ /* Figure out width */ *w = 0; precval = atoi(temp); p--; state = 100; } else { *w = 0; precval = atoi(temp); *(fmt++) = *p; state = 50; } break; /* Hang out, wait for format specifier */ case 50: if (strchr(fmt_codes, *p)) { p--; state = 100; } else { *(fmt++) = *p; } break; /* Got an encoding header */ case 60: if (*p == '(') { ++plevel; *ec = *p; ec++; } else if (*p == ')') { --plevel; if (plevel <= 0) { *ec = 0; state = 10; } else { *ec = *p; ec++; } } else { *ec = *p; ec++; } break; case 100: /* Got a formatting code */ if (widthval < precval) maxwidth = precval; else maxwidth = widthval; if ((*p == 's') || (*p == 'S')) { /* Null-Terminated string */ DOH *doh; DOH *Sval; DOH *enc = 0; doh = va_arg(ap, DOH *); if (DohCheck(doh)) { /* Is a DOH object. */ if (DohIsString(doh)) { Sval = doh; } else { Sval = Str(doh); } if (strlen(encoder)) { enc = encode(encoder, Sval); maxwidth = maxwidth + strlen(newformat) + Len(enc); } else { maxwidth = maxwidth + strlen(newformat) + Len(Sval); } *(fmt++) = 's'; *fmt = 0; if ((maxwidth + 1) < OBUFLEN) { stemp = obuffer; } else { stemp = (char *) DohMalloc(maxwidth + 1); } if (enc) { nbytes += sprintf(stemp, newformat, Data(enc)); } else { nbytes += sprintf(stemp, newformat, Data(Sval)); } if (Writen(so, stemp, strlen(stemp)) < 0) return -1; if ((DOH *) Sval != doh) { Delete(Sval); } if (enc) Delete(enc); if (*p == 'S') { Delete(doh); } if (stemp != obuffer) { DohFree(stemp); } } else { if (!doh) doh = (char *) ""; if (strlen(encoder)) { DOH *s = NewString(doh); Seek(s, 0, SEEK_SET); enc = encode(encoder, s); Delete(s); doh = Char(enc); } else { enc = 0; } maxwidth = maxwidth + strlen(newformat) + strlen((char *) doh); *(fmt++) = 's'; *fmt = 0; if ((maxwidth + 1) < OBUFLEN) { stemp = obuffer; } else { stemp = (char *) DohMalloc(maxwidth + 1); } nbytes += sprintf(stemp, newformat, doh); if (Writen(so, stemp, strlen(stemp)) < 0) return -1; if (stemp != obuffer) { DohFree(stemp); } if (enc) Delete(enc); } } else { *(fmt++) = *p; *fmt = 0; maxwidth = maxwidth + strlen(newformat) + 64; /* Only allocate a buffer if it is too big to fit. Shouldn't have to do this very often */ if (maxwidth < OBUFLEN) stemp = obuffer; else stemp = (char *) DohMalloc(maxwidth + 1); switch (*p) { case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': case 'c': ivalue = va_arg(ap, int); nbytes += sprintf(stemp, newformat, ivalue); break; case 'f': case 'g': case 'e': case 'E': case 'G': dvalue = va_arg(ap, double); nbytes += sprintf(stemp, newformat, dvalue); break; case 'p': pvalue = va_arg(ap, void *); nbytes += sprintf(stemp, newformat, pvalue); break; default: break; } if (Writen(so, stemp, strlen(stemp)) < 0) return -1; if (stemp != obuffer) DohFree(stemp); } state = 0; break; } p++; } if (state) { int r; *fmt = 0; r = Writen(so, fmt, strlen(fmt)); if (r < 0) return -1; nbytes += r; } return nbytes; } /* ----------------------------------------------------------------------------- * DohPrintf() * * Variable length argument entry point to Printf * ----------------------------------------------------------------------------- */ int DohPrintf(DOH *obj, const char *format, ...) { va_list ap; int ret; va_start(ap, format); ret = DohvPrintf(obj, format, ap); va_end(ap); return ret; } /* ----------------------------------------------------------------------------- * DohPrintv() * * Print a null-terminated variable length list of DOH objects * ----------------------------------------------------------------------------- */ int DohPrintv(DOHFile * f, ...) { va_list ap; int ret = 0; DOH *obj; va_start(ap, f); while (1) { obj = va_arg(ap, void *); if ((!obj) || (obj == DohNone)) break; if (DohCheck(obj)) { ret += DohDump(obj, f); } else { ret += DohWrite(f, obj, strlen((char *) obj)); } } va_end(ap); return ret; } /* ----------------------------------------------------------------------------- * DohCopyto() * * Copies all of the input from an input stream to an output stream. Returns the * number of bytes copied. * ----------------------------------------------------------------------------- */ int DohCopyto(DOH *in, DOH *out) { int nbytes = 0, ret; int nwrite = 0, wret; char *cw; char buffer[16384]; if ((!in) || (!out)) return 0; while (1) { ret = Read(in, buffer, 16384); if (ret > 0) { nwrite = ret; cw = buffer; while (nwrite) { wret = Write(out, cw, nwrite); if (wret < 0) { nbytes = -1; break; } nwrite = nwrite - wret; cw += wret; } nbytes += ret; } else { break; } } return nbytes; } /* ----------------------------------------------------------------------------- * DohSplit() * * Split an input stream into a list of strings delimited by the specified * character. Optionally accepts a maximum number of splits to perform. * ----------------------------------------------------------------------------- */ DOH *DohSplit(DOH *in, char ch, int nsplits) { DOH *list; DOH *str; int c; list = NewList(); if (DohIsString(in)) { Seek(in, 0, SEEK_SET); } while (1) { str = NewStringEmpty(); do { c = Getc(in); } while ((c != EOF) && (c == ch)); if (c != EOF) { Putc(c, str); while (1) { c = Getc(in); if ((c == EOF) || ((c == ch) && (nsplits != 0))) break; Putc(c, str); } nsplits--; } Append(list, str); Delete(str); if (c == EOF) break; } return list; } /* ----------------------------------------------------------------------------- * DohSplitLines() * * Split an input stream into a list of strings delimited by newline characters. * ----------------------------------------------------------------------------- */ DOH *DohSplitLines(DOH *in) { DOH *list; DOH *str; int c = 0; list = NewList(); if (DohIsString(in)) { Seek(in, 0, SEEK_SET); } while (c != EOF) { str = NewStringEmpty(); while ((c = Getc(in)) != '\n' && c != EOF) { Putc(c, str); } Append(list, str); Delete(str); } return list; } /* ----------------------------------------------------------------------------- * DohReadline() * * Read a single input line and return it as a string. * ----------------------------------------------------------------------------- */ DOH *DohReadline(DOH *in) { char c; int n = 0; DOH *s = NewStringEmpty(); while (1) { if (Read(in, &c, 1) < 0) { if (n == 0) { Delete(s); s = 0; } break; } if (c == '\n') break; if (c == '\r') continue; Putc(c, s); n++; } return s; } swig-3.0.2/Source/DOH/void.c0000664000175000017500000000577712343605122015342 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * void.c * * Implements a "void" object that is really just a DOH container around * an arbitrary C object represented as a void *. * ----------------------------------------------------------------------------- */ #include "dohint.h" typedef struct { void *ptr; void (*del) (void *); } VoidObj; /* ----------------------------------------------------------------------------- * Void_delete() * * Delete a void object. Invokes the destructor supplied at the time of creation. * ----------------------------------------------------------------------------- */ static void Void_delete(DOH *vo) { VoidObj *v = (VoidObj *) ObjData(vo); if (v->del) (*v->del) (v->ptr); DohFree(v); } /* ----------------------------------------------------------------------------- * Void_copy() * * Copies a void object. This is only a shallow copy. The object destruction * function is not copied in order to avoid potential double-free problems. * ----------------------------------------------------------------------------- */ static DOH *Void_copy(DOH *vo) { VoidObj *v = (VoidObj *) ObjData(vo); return NewVoid(v->ptr, 0); } /* ----------------------------------------------------------------------------- * Void_data() * * Returns the void * stored in the object. * ----------------------------------------------------------------------------- */ static void *Void_data(DOH *vo) { VoidObj *v = (VoidObj *) ObjData(vo); return v->ptr; } static DohObjInfo DohVoidType = { "VoidObj", /* objname */ Void_delete, /* doh_del */ Void_copy, /* doh_copy */ 0, /* doh_clear */ 0, /* doh_str */ Void_data, /* doh_data */ 0, /* doh_dump */ 0, /* doh_len */ 0, /* doh_hash */ 0, /* doh_cmp */ 0, /* doh_equal */ 0, /* doh_first */ 0, /* doh_next */ 0, /* doh_setfile */ 0, /* doh_getfile */ 0, /* doh_setline */ 0, /* doh_getline */ 0, /* doh_mapping */ 0, /* doh_sequence */ 0, /* doh_file */ 0, /* doh_string */ 0, /* doh_reserved */ 0, /* clientdata */ }; /* ----------------------------------------------------------------------------- * NewVoid() * * Creates a new Void object given a void * and an optional destructor function. * ----------------------------------------------------------------------------- */ DOH *DohNewVoid(void *obj, void (*del) (void *)) { VoidObj *v; v = (VoidObj *) DohMalloc(sizeof(VoidObj)); v->ptr = obj; v->del = del; return DohObjMalloc(&DohVoidType, v); } swig-3.0.2/Source/DOH/hash.c0000664000175000017500000003343512343605122015314 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * hash.c * * Implements a simple hash table object. * ----------------------------------------------------------------------------- */ #include "dohint.h" extern DohObjInfo DohHashType; /* Hash node */ typedef struct HashNode { DOH *key; DOH *object; struct HashNode *next; } HashNode; /* Hash object */ typedef struct Hash { DOH *file; int line; HashNode **hashtable; int hashsize; int nitems; } Hash; /* Key interning structure */ typedef struct KeyValue { char *cstr; DOH *sstr; struct KeyValue *left; struct KeyValue *right; } KeyValue; static KeyValue *root = 0; static int max_expand = 1; /* Find or create a key in the interned key table */ static DOH *find_key(DOH *doh_c) { char *c = (char *) doh_c; KeyValue *r, *s; int d = 0; /* OK, sure, we use a binary tree for maintaining interned symbols. Then we use their hash values for accessing secondary hash tables. */ r = root; s = 0; while (r) { s = r; d = strcmp(r->cstr, c); if (d == 0) return r->sstr; if (d < 0) r = r->left; else r = r->right; } /* fprintf(stderr,"Interning '%s'\n", c); */ r = (KeyValue *) DohMalloc(sizeof(KeyValue)); r->cstr = (char *) DohMalloc(strlen(c) + 1); strcpy(r->cstr, c); r->sstr = NewString(c); DohIntern(r->sstr); r->left = 0; r->right = 0; if (!s) { root = r; } else { if (d < 0) s->left = r; else s->right = r; } return r->sstr; } #define HASH_INIT_SIZE 7 /* Create a new hash node */ static HashNode *NewNode(DOH *k, void *obj) { HashNode *hn = (HashNode *) DohMalloc(sizeof(HashNode)); hn->key = k; Incref(hn->key); hn->object = obj; Incref(obj); hn->next = 0; return hn; } /* Delete a hash node */ static void DelNode(HashNode *hn) { Delete(hn->key); Delete(hn->object); DohFree(hn); } /* ----------------------------------------------------------------------------- * DelHash() * * Delete a hash table. * ----------------------------------------------------------------------------- */ static void DelHash(DOH *ho) { Hash *h = (Hash *) ObjData(ho); HashNode *n, *next; int i; for (i = 0; i < h->hashsize; i++) { n = h->hashtable[i]; while (n) { next = n->next; DelNode(n); n = next; } } DohFree(h->hashtable); h->hashtable = 0; h->hashsize = 0; DohFree(h); } /* ----------------------------------------------------------------------------- * Hash_clear() * * Clear all of the entries in the hash table. * ----------------------------------------------------------------------------- */ static void Hash_clear(DOH *ho) { Hash *h = (Hash *) ObjData(ho); HashNode *n, *next; int i; for (i = 0; i < h->hashsize; i++) { n = h->hashtable[i]; while (n) { next = n->next; DelNode(n); n = next; } h->hashtable[i] = 0; } h->nitems = 0; } /* resize the hash table */ static void resize(Hash *h) { HashNode *n, *next, **table; int oldsize, newsize; int i, p, hv; if (h->nitems < 2 * h->hashsize) return; /* Too big. We have to rescale everything now */ oldsize = h->hashsize; /* Calculate a new size */ newsize = 2 * oldsize + 1; p = 3; while (p < (newsize >> 1)) { if (((newsize / p) * p) == newsize) { newsize += 2; p = 3; continue; } p = p + 2; } table = (HashNode **) DohMalloc(newsize * sizeof(HashNode *)); for (i = 0; i < newsize; i++) { table[i] = 0; } /* Walk down the old set of nodes and re-place */ h->hashsize = newsize; for (i = 0; i < oldsize; i++) { n = h->hashtable[i]; while (n) { hv = Hashval(n->key) % newsize; next = n->next; n->next = table[hv]; table[hv] = n; n = next; } } DohFree(h->hashtable); h->hashtable = table; } /* ----------------------------------------------------------------------------- * Hash_setattr() * * Set an attribute in the hash table. Deletes the existing entry if it already * exists. * ----------------------------------------------------------------------------- */ static int Hash_setattr(DOH *ho, DOH *k, DOH *obj) { int hv; HashNode *n, *prev; Hash *h = (Hash *) ObjData(ho); if (!obj) { return DohDelattr(ho, k); } if (!DohCheck(k)) k = find_key(k); if (!DohCheck(obj)) { obj = NewString((char *) obj); Decref(obj); } hv = (Hashval(k)) % h->hashsize; n = h->hashtable[hv]; prev = 0; while (n) { if (Cmp(n->key, k) == 0) { /* Node already exists. Just replace its contents */ if (n->object == obj) { /* Whoa. Same object. Do nothing */ return 1; } Delete(n->object); n->object = obj; Incref(obj); return 1; /* Return 1 to indicate a replacement */ } else { prev = n; n = n->next; } } /* Add this to the table */ n = NewNode(k, obj); if (prev) prev->next = n; else h->hashtable[hv] = n; h->nitems++; resize(h); return 0; } /* ----------------------------------------------------------------------------- * Hash_getattr() * * Get an attribute from the hash table. Returns 0 if it doesn't exist. * ----------------------------------------------------------------------------- */ typedef int (*binop) (DOH *obj1, DOH *obj2); static DOH *Hash_getattr(DOH *h, DOH *k) { DOH *obj = 0; Hash *ho = (Hash *) ObjData(h); DOH *ko = DohCheck(k) ? k : find_key(k); int hv = Hashval(ko) % ho->hashsize; DohObjInfo *k_type = ((DohBase*)ko)->type; HashNode *n = ho->hashtable[hv]; if (k_type->doh_equal) { binop equal = k_type->doh_equal; while (n) { DohBase *nk = (DohBase *)n->key; if ((k_type == nk->type) && equal(ko, nk)) obj = n->object; n = n->next; } } else { binop cmp = k_type->doh_cmp; while (n) { DohBase *nk = (DohBase *)n->key; if ((k_type == nk->type) && (cmp(ko, nk) == 0)) obj = n->object; n = n->next; } } return obj; } /* ----------------------------------------------------------------------------- * Hash_delattr() * * Delete an object from the hash table. * ----------------------------------------------------------------------------- */ static int Hash_delattr(DOH *ho, DOH *k) { HashNode *n, *prev; int hv; Hash *h = (Hash *) ObjData(ho); if (!DohCheck(k)) k = find_key(k); hv = Hashval(k) % h->hashsize; n = h->hashtable[hv]; prev = 0; while (n) { if (Cmp(n->key, k) == 0) { /* Found it, kill it */ if (prev) { prev->next = n->next; } else { h->hashtable[hv] = n->next; } DelNode(n); h->nitems--; return 1; } prev = n; n = n->next; } return 0; } static DohIterator Hash_firstiter(DOH *ho) { DohIterator iter; Hash *h = (Hash *) ObjData(ho); iter.object = ho; iter._current = 0; iter.item = 0; iter.key = 0; iter._index = 0; /* Index in hash table */ while ((iter._index < h->hashsize) && !h->hashtable[iter._index]) iter._index++; if (iter._index >= h->hashsize) { return iter; } iter._current = h->hashtable[iter._index]; iter.item = ((HashNode *) iter._current)->object; iter.key = ((HashNode *) iter._current)->key; /* Actually save the next slot in the hash. This makes it possible to delete the item being iterated over without trashing the universe */ iter._current = ((HashNode *) iter._current)->next; return iter; } static DohIterator Hash_nextiter(DohIterator iter) { Hash *h = (Hash *) ObjData(iter.object); if (!iter._current) { iter._index++; while ((iter._index < h->hashsize) && !h->hashtable[iter._index]) { iter._index++; } if (iter._index >= h->hashsize) { iter.item = 0; iter.key = 0; iter._current = 0; return iter; } iter._current = h->hashtable[iter._index]; } iter.key = ((HashNode *) iter._current)->key; iter.item = ((HashNode *) iter._current)->object; /* Store the next node to iterator on */ iter._current = ((HashNode *) iter._current)->next; return iter; } /* ----------------------------------------------------------------------------- * Hash_keys() * * Return a list of keys * ----------------------------------------------------------------------------- */ static DOH *Hash_keys(DOH *so) { DOH *keys; Iterator i; keys = NewList(); for (i = First(so); i.key; i = Next(i)) { Append(keys, i.key); } return keys; } /* ----------------------------------------------------------------------------- * DohSetMaxHashExpand() * * Controls how many Hash objects are displayed in full in Hash_str * ----------------------------------------------------------------------------- */ void DohSetMaxHashExpand(int count) { max_expand = count; } /* ----------------------------------------------------------------------------- * DohGetMaxHashExpand() * * Returns how many Hash objects are displayed in full in Hash_str * ----------------------------------------------------------------------------- */ int DohGetMaxHashExpand(void) { return max_expand; } /* ----------------------------------------------------------------------------- * Hash_str() * * Create a string representation of a hash table (mainly for debugging). * ----------------------------------------------------------------------------- */ static DOH *Hash_str(DOH *ho) { int i, j; HashNode *n; DOH *s; static int expanded = 0; static const char *tab = " "; Hash *h = (Hash *) ObjData(ho); s = NewStringEmpty(); if (ObjGetMark(ho)) { Printf(s, "Hash(%p)", ho); return s; } if (expanded >= max_expand) { /* replace each hash attribute with a '.' */ Printf(s, "Hash(%p) {", ho); for (i = 0; i < h->hashsize; i++) { n = h->hashtable[i]; while (n) { Putc('.', s); n = n->next; } } Putc('}', s); return s; } ObjSetMark(ho, 1); Printf(s, "Hash(%p) {\n", ho); for (i = 0; i < h->hashsize; i++) { n = h->hashtable[i]; while (n) { for (j = 0; j < expanded + 1; j++) Printf(s, tab); expanded += 1; Printf(s, "'%s' : %s, \n", n->key, n->object); expanded -= 1; n = n->next; } } for (j = 0; j < expanded; j++) Printf(s, tab); Printf(s, "}"); ObjSetMark(ho, 0); return s; } /* ----------------------------------------------------------------------------- * Hash_len() * * Return number of entries in the hash table. * ----------------------------------------------------------------------------- */ static int Hash_len(DOH *ho) { Hash *h = (Hash *) ObjData(ho); return h->nitems; } /* ----------------------------------------------------------------------------- * CopyHash() * * Make a copy of a hash table. Note: this is a shallow copy. * ----------------------------------------------------------------------------- */ static DOH *CopyHash(DOH *ho) { Hash *h, *nh; HashNode *n; DOH *nho; int i; h = (Hash *) ObjData(ho); nh = (Hash *) DohMalloc(sizeof(Hash)); nh->hashsize = h->hashsize; nh->hashtable = (HashNode **) DohMalloc(nh->hashsize * sizeof(HashNode *)); for (i = 0; i < nh->hashsize; i++) { nh->hashtable[i] = 0; } nh->nitems = 0; nh->line = h->line; nh->file = h->file; if (nh->file) Incref(nh->file); nho = DohObjMalloc(&DohHashType, nh); for (i = 0; i < h->hashsize; i++) { n = h->hashtable[i]; while (n) { Hash_setattr(nho, n->key, n->object); n = n->next; } } return nho; } static void Hash_setfile(DOH *ho, DOH *file) { DOH *fo; Hash *h = (Hash *) ObjData(ho); if (!DohCheck(file)) { fo = NewString(file); Decref(fo); } else fo = file; Incref(fo); Delete(h->file); h->file = fo; } static DOH *Hash_getfile(DOH *ho) { Hash *h = (Hash *) ObjData(ho); return h->file; } static void Hash_setline(DOH *ho, int line) { Hash *h = (Hash *) ObjData(ho); h->line = line; } static int Hash_getline(DOH *ho) { Hash *h = (Hash *) ObjData(ho); return h->line; } /* ----------------------------------------------------------------------------- * type information * ----------------------------------------------------------------------------- */ static DohHashMethods HashHashMethods = { Hash_getattr, Hash_setattr, Hash_delattr, Hash_keys, }; DohObjInfo DohHashType = { "Hash", /* objname */ DelHash, /* doh_del */ CopyHash, /* doh_copy */ Hash_clear, /* doh_clear */ Hash_str, /* doh_str */ 0, /* doh_data */ 0, /* doh_dump */ Hash_len, /* doh_len */ 0, /* doh_hash */ 0, /* doh_cmp */ 0, /* doh_equal */ Hash_firstiter, /* doh_first */ Hash_nextiter, /* doh_next */ Hash_setfile, /* doh_setfile */ Hash_getfile, /* doh_getfile */ Hash_setline, /* doh_setline */ Hash_getline, /* doh_getline */ &HashHashMethods, /* doh_mapping */ 0, /* doh_sequence */ 0, /* doh_file */ 0, /* doh_string */ 0, /* doh_positional */ 0, }; /* ----------------------------------------------------------------------------- * NewHash() * * Create a new hash table. * ----------------------------------------------------------------------------- */ DOH *DohNewHash(void) { Hash *h; int i; h = (Hash *) DohMalloc(sizeof(Hash)); h->hashsize = HASH_INIT_SIZE; h->hashtable = (HashNode **) DohMalloc(h->hashsize * sizeof(HashNode *)); for (i = 0; i < h->hashsize; i++) { h->hashtable[i] = 0; } h->nitems = 0; h->file = 0; h->line = 0; return DohObjMalloc(&DohHashType, h); } swig-3.0.2/Source/DOH/dohint.h0000664000175000017500000001137412343605122015661 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * dohint.h * * This file describes internally managed objects. * ----------------------------------------------------------------------------- */ #ifndef _DOHINT_H #define _DOHINT_H #include "doh.h" #include #include #include #include #include #include /* Hash objects */ typedef struct { DOH *(*doh_getattr) (DOH *obj, DOH *name); /* Get attribute */ int (*doh_setattr) (DOH *obj, DOH *name, DOH *value); /* Set attribute */ int (*doh_delattr) (DOH *obj, DOH *name); /* Del attribute */ DOH *(*doh_keys) (DOH *obj); /* All keys as a list */ } DohHashMethods; /* List objects */ typedef struct { DOH *(*doh_getitem) (DOH *obj, int index); /* Get item */ int (*doh_setitem) (DOH *obj, int index, DOH *value); /* Set item */ int (*doh_delitem) (DOH *obj, int index); /* Delete item */ int (*doh_insitem) (DOH *obj, int index, DOH *value); /* Insert item */ int (*doh_delslice) (DOH *obj, int sindex, int eindex); /* Delete slice */ } DohListMethods; /* File methods */ typedef struct { int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */ int (*doh_write) (DOH *obj, const void *buffer, int nbytes); /* Write bytes */ int (*doh_putc) (DOH *obj, int ch); /* Put character */ int (*doh_getc) (DOH *obj); /* Get character */ int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */ int (*doh_seek) (DOH *obj, long offset, int whence); /* Seek */ long (*doh_tell) (DOH *obj); /* Tell */ int (*doh_close) (DOH *obj); /* Close */ } DohFileMethods; /* String methods */ typedef struct { int (*doh_replace) (DOH *obj, const DOHString_or_char *old, const DOHString_or_char *rep, int flags); void (*doh_chop) (DOH *obj); } DohStringMethods; /* ----------------------------------------------------------------------------- * DohObjInfo * ----------------------------------------------------------------------------- */ typedef struct DohObjInfo { const char *objname; /* Object name */ /* Basic object methods */ void (*doh_del) (DOH *obj); /* Delete object */ DOH *(*doh_copy) (DOH *obj); /* Copy and object */ void (*doh_clear) (DOH *obj); /* Clear an object */ /* I/O methods */ DOH *(*doh_str) (DOH *obj); /* Make a full string */ void *(*doh_data) (DOH *obj); /* Return raw data */ int (*doh_dump) (DOH *obj, DOH *out); /* Serialize on out */ /* Length and hash values */ int (*doh_len) (DOH *obj); int (*doh_hashval) (DOH *obj); /* Compare */ int (*doh_cmp) (DOH *obj1, DOH *obj2); /* Equal */ int (*doh_equal) (DOH *obj1, DOH *obj2); /* Iterators */ DohIterator (*doh_first) (DOH *obj); DohIterator (*doh_next) (DohIterator); /* Positional */ void (*doh_setfile) (DOH *obj, DOHString_or_char *file); DOH *(*doh_getfile) (DOH *obj); void (*doh_setline) (DOH *obj, int line); int (*doh_getline) (DOH *obj); DohHashMethods *doh_hash; /* Hash methods */ DohListMethods *doh_list; /* List methods */ DohFileMethods *doh_file; /* File methods */ DohStringMethods *doh_string; /* String methods */ void *doh_reserved; /* Reserved */ void *clientdata; /* User data */ } DohObjInfo; typedef struct { void *data; /* Data pointer */ DohObjInfo *type; void *meta; /* Meta data */ unsigned int flag_intern:1; /* Interned object */ unsigned int flag_marked:1; /* Mark flag. Used to avoid recursive loops in places */ unsigned int flag_user:1; /* User flag */ unsigned int flag_usermark:1; /* User marked */ unsigned int refcount:28; /* Reference count (max 16 million) */ } DohBase; /* Macros for decrefing and increfing (safe for null objects). */ #define Decref(a) if (a) ((DohBase *) a)->refcount-- #define Incref(a) if (a) ((DohBase *) a)->refcount++ #define Refcount(a) ((DohBase *) a)->refcount /* Macros for manipulating objects in a safe manner */ #define ObjData(a) ((DohBase *)a)->data #define ObjSetMark(a,x) ((DohBase *)a)->flag_marked = x #define ObjGetMark(a) ((DohBase *)a)->flag_marked #define ObjType(a) ((DohBase *)a)->type extern DOH *DohObjMalloc(DohObjInfo *type, void *data); /* Allocate a DOH object */ extern void DohObjFree(DOH *ptr); /* Free a DOH object */ #endif /* DOHINT_H */ swig-3.0.2/Source/DOH/list.c0000664000175000017500000002275712343605122015351 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * list.c * * Implements a simple list object. * ----------------------------------------------------------------------------- */ #include "dohint.h" typedef struct List { int maxitems; /* Max size */ int nitems; /* Num items */ DOH *file; int line; DOH **items; } List; extern DohObjInfo DohListType; /* Doubles amount of memory in a list */ static void more(List *l) { l->items = (void **) DohRealloc(l->items, l->maxitems * 2 * sizeof(void *)); assert(l->items); l->maxitems *= 2; } /* ----------------------------------------------------------------------------- * CopyList() * * Make a shallow copy of a list. * ----------------------------------------------------------------------------- */ static DOH *CopyList(DOH *lo) { List *l, *nl; int i; l = (List *) ObjData(lo); nl = (List *) DohMalloc(sizeof(List)); nl->nitems = l->nitems; nl->maxitems = l->maxitems; nl->items = (void **) DohMalloc(l->maxitems * sizeof(void *)); for (i = 0; i < l->nitems; i++) { nl->items[i] = l->items[i]; Incref(nl->items[i]); } nl->file = l->file; if (nl->file) Incref(nl->file); nl->line = l->line; return DohObjMalloc(&DohListType, nl); } /* ----------------------------------------------------------------------------- * DelList() * * Delete a list. * ----------------------------------------------------------------------------- */ static void DelList(DOH *lo) { List *l = (List *) ObjData(lo); int i; for (i = 0; i < l->nitems; i++) Delete(l->items[i]); DohFree(l->items); DohFree(l); } /* ----------------------------------------------------------------------------- * List_clear() * * Remove all of the list entries, but keep the list object intact. * ----------------------------------------------------------------------------- */ static void List_clear(DOH *lo) { List *l = (List *) ObjData(lo); int i; for (i = 0; i < l->nitems; i++) { Delete(l->items[i]); } l->nitems = 0; } /* ----------------------------------------------------------------------------- * List_insert() * * Insert an item into the list. If the item is not a DOH object, it is assumed * to be a 'char *' and is used to construct an equivalent string object. * ----------------------------------------------------------------------------- */ static int List_insert(DOH *lo, int pos, DOH *item) { List *l = (List *) ObjData(lo); int i; if (!item) return -1; if (!DohCheck(item)) { item = NewString(item); Decref(item); } if (pos == DOH_END) pos = l->nitems; if (pos < 0) pos = 0; if (pos > l->nitems) pos = l->nitems; if (l->nitems == l->maxitems) more(l); for (i = l->nitems; i > pos; i--) { l->items[i] = l->items[i - 1]; } l->items[pos] = item; Incref(item); l->nitems++; return 0; } /* ----------------------------------------------------------------------------- * List_remove() * * Remove an item from a list. * ----------------------------------------------------------------------------- */ static int List_remove(DOH *lo, int pos) { List *l = (List *) ObjData(lo); int i; if (pos == DOH_END) pos = l->nitems - 1; if (pos == DOH_BEGIN) pos = 0; assert(!((pos < 0) || (pos >= l->nitems))); Delete(l->items[pos]); for (i = pos; i < l->nitems - 1; i++) { l->items[i] = l->items[i + 1]; } l->nitems--; return 0; } /* ----------------------------------------------------------------------------- * List_len() * * Return the number of elements in the list * ----------------------------------------------------------------------------- */ static int List_len(DOH *lo) { List *l = (List *) ObjData(lo); return l->nitems; } /* ----------------------------------------------------------------------------- * List_get() * * Get the nth item from the list. * ----------------------------------------------------------------------------- */ static DOH *List_get(DOH *lo, int n) { List *l = (List *) ObjData(lo); if (n == DOH_END) n = l->nitems - 1; if (n == DOH_BEGIN) n = 0; assert(!((n < 0) || (n >= l->nitems))); return l->items[n]; } /* ----------------------------------------------------------------------------- * List_set() * * Set the nth item in the list replacing any previous item. * ----------------------------------------------------------------------------- */ static int List_set(DOH *lo, int n, DOH *val) { List *l = (List *) ObjData(lo); if (!val) return -1; assert(!((n < 0) || (n >= l->nitems))); if (!DohCheck(val)) { val = NewString(val); Decref(val); } Delete(l->items[n]); l->items[n] = val; Incref(val); Delete(val); return 0; } /* ----------------------------------------------------------------------------- * List_first() * * Return the first item in the list. * ----------------------------------------------------------------------------- */ static DohIterator List_first(DOH *lo) { DohIterator iter; List *l = (List *) ObjData(lo); iter.object = lo; iter._index = 0; iter._current = 0; iter.key = 0; if (l->nitems > 0) { iter.item = l->items[0]; } else { iter.item = 0; } return iter; } /* ----------------------------------------------------------------------------- * List_next() * * Return the next item in the list. * ----------------------------------------------------------------------------- */ static DohIterator List_next(DohIterator iter) { List *l = (List *) ObjData(iter.object); iter._index = iter._index + 1; if (iter._index >= l->nitems) { iter.item = 0; iter.key = 0; } else { iter.item = l->items[iter._index]; } return iter; } /* ----------------------------------------------------------------------------- * List_str() * * Create a string representation of the list. * ----------------------------------------------------------------------------- */ static DOH *List_str(DOH *lo) { DOH *s; int i; List *l = (List *) ObjData(lo); s = NewStringEmpty(); if (ObjGetMark(lo)) { Printf(s, "List(%p)", lo); return s; } ObjSetMark(lo, 1); Printf(s, "List[ "); for (i = 0; i < l->nitems; i++) { Printf(s, "%s", l->items[i]); if ((i + 1) < l->nitems) Printf(s, ", "); } Printf(s, " ]"); ObjSetMark(lo, 0); return s; } /* ----------------------------------------------------------------------------- * List_dump() * * Dump the items to an output stream. * ----------------------------------------------------------------------------- */ static int List_dump(DOH *lo, DOH *out) { int nsent = 0; int i, ret; List *l = (List *) ObjData(lo); for (i = 0; i < l->nitems; i++) { ret = Dump(l->items[i], out); if (ret < 0) return -1; nsent += ret; } return nsent; } static void List_setfile(DOH *lo, DOH *file) { DOH *fo; List *l = (List *) ObjData(lo); if (!DohCheck(file)) { fo = NewString(file); Decref(fo); } else fo = file; Incref(fo); Delete(l->file); l->file = fo; } static DOH *List_getfile(DOH *lo) { List *l = (List *) ObjData(lo); return l->file; } static void List_setline(DOH *lo, int line) { List *l = (List *) ObjData(lo); l->line = line; } static int List_getline(DOH *lo) { List *l = (List *) ObjData(lo); return l->line; } static DohListMethods ListListMethods = { List_get, List_set, List_remove, List_insert, 0, /* delslice */ }; DohObjInfo DohListType = { "List", /* objname */ DelList, /* doh_del */ CopyList, /* doh_copy */ List_clear, /* doh_clear */ List_str, /* doh_str */ 0, /* doh_data */ List_dump, /* doh_dump */ List_len, /* doh_len */ 0, /* doh_hash */ 0, /* doh_cmp */ 0, /* doh_equal */ List_first, /* doh_first */ List_next, /* doh_next */ List_setfile, /* doh_setfile */ List_getfile, /* doh_getfile */ List_setline, /* doh_setline */ List_getline, /* doh_getline */ 0, /* doh_mapping */ &ListListMethods, /* doh_sequence */ 0, /* doh_file */ 0, /* doh_string */ 0, /* doh_callable */ 0, /* doh_position */ }; /* ----------------------------------------------------------------------------- * NewList() * * Create a new list. * ----------------------------------------------------------------------------- */ #define MAXLISTITEMS 8 DOH *DohNewList(void) { List *l; int i; l = (List *) DohMalloc(sizeof(List)); l->nitems = 0; l->maxitems = MAXLISTITEMS; l->items = (void **) DohMalloc(l->maxitems * sizeof(void *)); for (i = 0; i < MAXLISTITEMS; i++) { l->items[i] = 0; } l->file = 0; l->line = 0; return DohObjMalloc(&DohListType, l); } static int (*List_sort_compare_func) (const DOH *, const DOH *); static int List_qsort_compare(const void *a, const void *b) { return List_sort_compare_func(*((DOH **) a), *((DOH **) b)); } /* Sort a list */ void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *)) { List *l = (List *) ObjData(lo); if (cmp) { List_sort_compare_func = cmp; } else { List_sort_compare_func = DohCmp; } qsort(l->items, l->nitems, sizeof(DOH *), List_qsort_compare); } swig-3.0.2/Source/DOH/string.c0000664000175000017500000007052112343605122015674 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * string.c * * Implements a string object that supports both sequence operations and * file semantics. * ----------------------------------------------------------------------------- */ #include "dohint.h" extern DohObjInfo DohStringType; typedef struct String { DOH *file; int line; int maxsize; /* Max size allocated */ int len; /* Current length */ int hashkey; /* Hash key value */ int sp; /* Current position */ char *str; /* String data */ } String; /* ----------------------------------------------------------------------------- * String_data() - Return as a 'void *' * ----------------------------------------------------------------------------- */ static void *String_data(DOH *so) { String *s = (String *) ObjData(so); s->str[s->len] = 0; return (void *) s->str; } /* static char *String_char(DOH *so) { return (char *) String_data(so); } */ /* ----------------------------------------------------------------------------- * String_dump() - Serialize a string onto out * ----------------------------------------------------------------------------- */ static int String_dump(DOH *so, DOH *out) { int nsent; int ret; String *s = (String *) ObjData(so); nsent = 0; while (nsent < s->len) { ret = Write(out, s->str + nsent, (s->len - nsent)); if (ret < 0) return ret; nsent += ret; } return nsent; } /* ----------------------------------------------------------------------------- * CopyString() - Copy a string * ----------------------------------------------------------------------------- */ static DOH *CopyString(DOH *so) { String *str; String *s = (String *) ObjData(so); str = (String *) DohMalloc(sizeof(String)); str->hashkey = s->hashkey; str->sp = s->sp; str->line = s->line; str->file = s->file; if (str->file) Incref(str->file); str->str = (char *) DohMalloc(s->len + 1); memcpy(str->str, s->str, s->len); str->maxsize = s->len; str->len = s->len; str->str[str->len] = 0; return DohObjMalloc(&DohStringType, str); } /* ----------------------------------------------------------------------------- * DelString() - Delete a string * ----------------------------------------------------------------------------- */ static void DelString(DOH *so) { String *s = (String *) ObjData(so); DohFree(s->str); DohFree(s); } /* ----------------------------------------------------------------------------- * DohString_len() - Length of a string * ----------------------------------------------------------------------------- */ static int String_len(DOH *so) { String *s = (String *) ObjData(so); return s->len; } /* ----------------------------------------------------------------------------- * String_cmp() - Compare two strings * ----------------------------------------------------------------------------- */ static int String_cmp(DOH *so1, DOH *so2) { String *s1, *s2; char *c1, *c2; int maxlen, i; s1 = (String *) ObjData(so1); s2 = (String *) ObjData(so2); maxlen = s1->len; if (s2->len < maxlen) maxlen = s2->len; c1 = s1->str; c2 = s2->str; for (i = maxlen; i; --i, c1++, c2++) { if (*c1 != *c2) break; } if (i != 0) { if (*c1 < *c2) return -1; else return 1; } if (s1->len == s2->len) return 0; if (s1->len > s2->len) return 1; return -1; } /* ----------------------------------------------------------------------------- * String_equal() - Say if two string are equal * ----------------------------------------------------------------------------- */ static int String_equal(DOH *so1, DOH *so2) { String *s1 = (String *) ObjData(so1); String *s2 = (String *) ObjData(so2); register int len = s1->len; if (len != s2->len) { return 0; } else { register char *c1 = s1->str; register char *c2 = s2->str; #if 0 register int mlen = len >> 2; register int i = mlen; for (; i; --i) { if (*(c1++) != *(c2++)) return 0; if (*(c1++) != *(c2++)) return 0; if (*(c1++) != *(c2++)) return 0; if (*(c1++) != *(c2++)) return 0; } for (i = len - (mlen << 2); i; --i) { if (*(c1++) != *(c2++)) return 0; } return 1; #else return memcmp(c1, c2, len) == 0; #endif } } /* ----------------------------------------------------------------------------- * String_hash() - Compute string hash value * ----------------------------------------------------------------------------- */ static int String_hash(DOH *so) { String *s = (String *) ObjData(so); if (s->hashkey >= 0) { return s->hashkey; } else { register char *c = s->str; register int len = s->len > 50 ? 50 : s->len; register int h = 0; register int mlen = len >> 2; register int i = mlen; for (; i; --i) { h = (h << 5) + *(c++); h = (h << 5) + *(c++); h = (h << 5) + *(c++); h = (h << 5) + *(c++); } for (i = len - (mlen << 2); i; --i) { h = (h << 5) + *(c++); } h &= 0x7fffffff; s->hashkey = h; return h; } } /* ----------------------------------------------------------------------------- * DohString_append() - Append to s * ----------------------------------------------------------------------------- */ static void DohString_append(DOH *so, const DOHString_or_char *str) { int oldlen, newlen, newmaxsize, l, sp; char *tc; String *s = (String *) ObjData(so); char *newstr = 0; if (DohCheck(str)) { String *ss = (String *) ObjData(str); newstr = (char *) String_data((DOH *) str); l = ss->len; } else { newstr = (char *) (str); l = (int) strlen(newstr); } if (!newstr) return; s->hashkey = -1; oldlen = s->len; newlen = oldlen + l + 1; if (newlen >= s->maxsize - 1) { newmaxsize = 2 * s->maxsize; if (newlen >= newmaxsize - 1) newmaxsize = newlen + 1; s->str = (char *) DohRealloc(s->str, newmaxsize); assert(s->str); s->maxsize = newmaxsize; } tc = s->str; memcpy(tc + oldlen, newstr, l + 1); sp = s->sp; if (sp >= oldlen) { int i = oldlen + l - sp; tc += sp; for (; i; --i) { if (*(tc++) == '\n') s->line++; } s->sp = oldlen + l; } s->len += l; } /* ----------------------------------------------------------------------------- * String_clear() - Clear a string * ----------------------------------------------------------------------------- */ static void String_clear(DOH *so) { String *s = (String *) ObjData(so); s->hashkey = -1; s->len = 0; *(s->str) = 0; s->sp = 0; s->line = 1; } /* ----------------------------------------------------------------------------- * String_insert() - Insert a string * ----------------------------------------------------------------------------- */ static int String_insert(DOH *so, int pos, DOH *str) { String *s; int len; char *data; if (pos == DOH_END) { DohString_append(so, str); return 0; } s = (String *) ObjData(so); s->hashkey = -1; if (DohCheck(str)) { String *ss = (String *) ObjData(str); data = (char *) String_data(str); len = ss->len; } else { data = (char *) (str); len = (int) strlen(data); } if (pos < 0) pos = 0; else if (pos > s->len) pos = s->len; /* See if there is room to insert the new data */ while (s->maxsize <= s->len + len) { int newsize = 2 * s->maxsize; s->str = (char *) DohRealloc(s->str, newsize); assert(s->str); s->maxsize = newsize; } memmove(s->str + pos + len, s->str + pos, (s->len - pos)); memcpy(s->str + pos, data, len); if (s->sp >= pos) { int i; for (i = 0; i < len; i++) { if (data[i] == '\n') s->line++; } s->sp += len; } s->len += len; s->str[s->len] = 0; return 0; } /* ----------------------------------------------------------------------------- * String_delitem() - Delete a character * ----------------------------------------------------------------------------- */ static int String_delitem(DOH *so, int pos) { String *s = (String *) ObjData(so); s->hashkey = -1; if (pos == DOH_END) pos = s->len - 1; if (pos == DOH_BEGIN) pos = 0; if (s->len == 0) return 0; if (s->sp > pos) { s->sp--; assert(s->sp >= 0); if (s->str[pos] == '\n') s->line--; } memmove(s->str + pos, s->str + pos + 1, ((s->len - 1) - pos)); s->len--; s->str[s->len] = 0; return 0; } /* ----------------------------------------------------------------------------- * String_delslice() - Delete a range * ----------------------------------------------------------------------------- */ static int String_delslice(DOH *so, int sindex, int eindex) { String *s = (String *) ObjData(so); int size; if (s->len == 0) return 0; s->hashkey = -1; if (eindex == DOH_END) eindex = s->len; if (sindex == DOH_BEGIN) sindex = 0; size = eindex - sindex; if (s->sp > sindex) { /* Adjust the file pointer and line count */ int i, end; if (s->sp > eindex) { end = eindex; s->sp -= size; } else { end = s->sp; s->sp = sindex; } for (i = sindex; i < end; i++) { if (s->str[i] == '\n') s->line--; } assert(s->sp >= 0); } memmove(s->str + sindex, s->str + eindex, s->len - eindex); s->len -= size; s->str[s->len] = 0; return 0; } /* ----------------------------------------------------------------------------- * String_str() - Returns a string (used by printing commands) * ----------------------------------------------------------------------------- */ static DOH *String_str(DOH *so) { String *s = (String *) ObjData(so); s->str[s->len] = 0; return NewString(s->str); } /* ----------------------------------------------------------------------------- * String_read() - Read data from a string * ----------------------------------------------------------------------------- */ static int String_read(DOH *so, void *buffer, int len) { int reallen, retlen; char *cb; String *s = (String *) ObjData(so); if ((s->sp + len) > s->len) reallen = (s->len - s->sp); else reallen = len; cb = (char *) buffer; retlen = reallen; if (reallen > 0) { memmove(cb, s->str + s->sp, reallen); s->sp += reallen; } return retlen; } /* ----------------------------------------------------------------------------- * String_write() - Write data to a string * ----------------------------------------------------------------------------- */ static int String_write(DOH *so, const void *buffer, int len) { int newlen; String *s = (String *) ObjData(so); s->hashkey = -1; if (s->sp > s->len) s->sp = s->len; newlen = s->sp + len + 1; if (newlen > s->maxsize) { s->str = (char *) DohRealloc(s->str, newlen); assert(s->str); s->maxsize = newlen; s->len = s->sp + len; } if ((s->sp + len) > s->len) s->len = s->sp + len; memmove(s->str + s->sp, buffer, len); s->sp += len; s->str[s->len] = 0; return len; } /* ----------------------------------------------------------------------------- * String_seek() - Seek to a new position * ----------------------------------------------------------------------------- */ static int String_seek(DOH *so, long offset, int whence) { int pos, nsp, inc; String *s = (String *) ObjData(so); if (whence == SEEK_SET) pos = 0; else if (whence == SEEK_CUR) pos = s->sp; else if (whence == SEEK_END) { pos = s->len; offset = -offset; } else pos = s->sp; nsp = pos + offset; if (nsp < 0) nsp = 0; if (s->len > 0 && nsp > s->len) nsp = s->len; inc = (nsp > s->sp) ? 1 : -1; { #if 0 register int sp = s->sp; register char *tc = s->str; register int len = s->len; while (sp != nsp) { int prev = sp + inc; if (prev >= 0 && prev <= len && tc[prev] == '\n') s->line += inc; sp += inc; } #else register int sp = s->sp; register char *tc = s->str; if (inc > 0) { while (sp != nsp) { if (tc[++sp] == '\n') ++s->line; } } else { while (sp != nsp) { if (tc[--sp] == '\n') --s->line; } } #endif s->sp = sp; } assert(s->sp >= 0); return 0; } /* ----------------------------------------------------------------------------- * String_tell() - Return current position * ----------------------------------------------------------------------------- */ static long String_tell(DOH *so) { String *s = (String *) ObjData(so); return (long) (s->sp); } /* ----------------------------------------------------------------------------- * String_putc() * ----------------------------------------------------------------------------- */ static int String_putc(DOH *so, int ch) { String *s = (String *) ObjData(so); register int len = s->len; register int sp = s->sp; s->hashkey = -1; if (sp >= len) { register int maxsize = s->maxsize; register char *tc = s->str; if (len > (maxsize - 2)) { maxsize *= 2; tc = (char *) DohRealloc(tc, maxsize); assert(tc); s->maxsize = (int) maxsize; s->str = tc; } tc += sp; *tc = (char) ch; *(++tc) = 0; s->len = s->sp = sp + 1; } else { s->str[s->sp++] = (char) ch; } if (ch == '\n') s->line++; return ch; } /* ----------------------------------------------------------------------------- * String_getc() * ----------------------------------------------------------------------------- */ static int String_getc(DOH *so) { int c; String *s = (String *) ObjData(so); if (s->sp >= s->len) c = EOF; else c = (int)(unsigned char) s->str[s->sp++]; if (c == '\n') s->line++; return c; } /* ----------------------------------------------------------------------------- * String_ungetc() * ----------------------------------------------------------------------------- */ static int String_ungetc(DOH *so, int ch) { String *s = (String *) ObjData(so); if (ch == EOF) return ch; if (s->sp <= 0) return EOF; s->sp--; if (ch == '\n') s->line--; return ch; } static char *end_quote(char *s) { char *qs; char qc; char *q; char *nl; qc = *s; qs = s; while (1) { q = strpbrk(s + 1, "\"\'"); nl = strchr(s + 1, '\n'); if (nl && (nl < q)) { /* A new line appears before the end of the string */ if (*(nl - 1) == '\\') { s = nl + 1; continue; } /* String was terminated by a newline. Wing it */ return qs; } if (!q && nl) { return qs; } if (!q) return 0; if ((*q == qc) && (*(q - 1) != '\\')) return q; s = q; } } static char *match_simple(char *base, char *s, char *token, int tokenlen) { (void) base; (void) tokenlen; return strstr(s, token); } static char *match_identifier(char *base, char *s, char *token, int tokenlen) { while (s) { s = strstr(s, token); if (!s) return 0; if ((s > base) && (isalnum((int) *(s - 1)) || (*(s - 1) == '_'))) { s += tokenlen; continue; } if (isalnum((int) *(s + tokenlen)) || (*(s + tokenlen) == '_')) { s += tokenlen; continue; } return s; } return 0; } static char *match_identifier_begin(char *base, char *s, char *token, int tokenlen) { while (s) { s = strstr(s, token); if (!s) return 0; if ((s > base) && (isalnum((int) *(s - 1)) || (*(s - 1) == '_'))) { s += tokenlen; continue; } return s; } return 0; } static char *match_identifier_end(char *base, char *s, char *token, int tokenlen) { (void) base; while (s) { s = strstr(s, token); if (!s) return 0; if (isalnum((int) *(s + tokenlen)) || (*(s + tokenlen) == '_')) { s += tokenlen; continue; } return s; } return 0; } static char *match_number_end(char *base, char *s, char *token, int tokenlen) { (void) base; while (s) { s = strstr(s, token); if (!s) return 0; if (isdigit((int) *(s + tokenlen))) { s += tokenlen; continue; } return s; } return 0; } /* ----------------------------------------------------------------------------- * replace_simple() * * Replaces count non-overlapping occurrences of token with rep in a string. * ----------------------------------------------------------------------------- */ static int replace_simple(String *str, char *token, char *rep, int flags, int count, char *(*match) (char *, char *, char *, int)) { int tokenlen; /* Length of the token */ int replen; /* Length of the replacement */ int delta, expand = 0; int ic; int rcount = 0; int noquote = 0; char *c, *s, *t, *first; char *q, *q2; register char *base; int i; /* Figure out if anything gets replaced */ if (!strlen(token)) return 0; base = str->str; tokenlen = strlen(token); s = (*match) (base, base, token, tokenlen); if (!s) return 0; /* No matches. Who cares */ str->hashkey = -1; if (flags & DOH_REPLACE_NOQUOTE) noquote = 1; /* If we are not replacing inside quotes, we need to do a little extra work */ if (noquote) { q = strpbrk(base, "\"\'"); if (!q) { noquote = 0; /* Well, no quotes to worry about. Oh well */ } else { while (q && (q < s)) { /* First match was found inside a quote. Try to find another match */ q2 = end_quote(q); if (!q2) { return 0; } if (q2 > s) { /* Find next match */ s = (*match) (base, q2 + 1, token, tokenlen); } if (!s) return 0; /* Oh well, no matches */ q = strpbrk(q2 + 1, "\"\'"); if (!q) noquote = 0; /* No more quotes */ } } } first = s; replen = strlen(rep); delta = (replen - tokenlen); if (delta <= 0) { /* String is either shrinking or staying the same size */ /* In this case, we do the replacement in place without memory reallocation */ ic = count; t = s; /* Target of memory copies */ while (ic && s) { if (replen) { memcpy(t, rep, replen); t += replen; } rcount++; expand += delta; /* Find the next location */ s += tokenlen; if (ic == 1) break; c = (*match) (base, s, token, tokenlen); if (noquote) { q = strpbrk(s, "\"\'"); if (!q) { noquote = 0; } else { while (q && (q < c)) { /* First match was found inside a quote. Try to find another match */ q2 = end_quote(q); if (!q2) { c = 0; break; } if (q2 > c) c = (*match) (base, q2 + 1, token, tokenlen); if (!c) break; q = strpbrk(q2 + 1, "\"\'"); if (!q) noquote = 0; /* No more quotes */ } } } if (delta) { if (c) { memmove(t, s, c - s); t += (c - s); } else { memmove(t, s, (str->str + str->len) - s + 1); } } else { t += (c - s); } s = c; ic--; } if (s && delta) { memmove(t, s, (str->str + str->len) - s + 1); } str->len += expand; str->str[str->len] = 0; if (str->sp >= str->len) str->sp += expand; /* Fix the end of file pointer */ return rcount; } /* The string is expanding as a result of the replacement */ /* Figure out how much expansion is going to occur and allocate a new string */ { char *ns; int newsize; rcount++; ic = count - 1; s += tokenlen; while (ic && (c = (*match) (base, s, token, tokenlen))) { if (noquote) { q = strpbrk(s, "\"\'"); if (!q) { break; } else { while (q && (q < c)) { /* First match was found inside a quote. Try to find another match */ q2 = end_quote(q); if (!q2) { c = 0; break; } if (q2 > c) { c = (*match) (base, q2 + 1, token, tokenlen); if (!c) break; } q = strpbrk(q2 + 1, "\"\'"); if (!q) noquote = 0; } } } if (c) { rcount++; ic--; s = c + tokenlen; } else { break; } } expand = delta * rcount; /* Total amount of expansion for the replacement */ newsize = str->maxsize; while ((str->len + expand) >= newsize) newsize *= 2; ns = (char *) DohMalloc(newsize); assert(ns); t = ns; s = first; /* Copy the first part of the string */ if (first > str->str) { memcpy(t, str->str, (first - str->str)); t += (first - str->str); } for (i = 0; i < rcount; i++) { memcpy(t, rep, replen); t += replen; s += tokenlen; c = (*match) (base, s, token, tokenlen); if (noquote) { q = strpbrk(s, "\"\'"); if (!q) { noquote = 0; } else { while (q && (q < c)) { /* First match was found inside a quote. Try to find another match */ q2 = end_quote(q); if (!q2) { c = 0; break; } if (q2 > c) { c = (*match) (base, q2 + 1, token, tokenlen); if (!c) break; } q = strpbrk(q2 + 1, "\"\'"); if (!q) noquote = 0; /* No more quotes */ } } } if (i < (rcount - 1)) { memcpy(t, s, c - s); t += (c - s); } else { memcpy(t, s, (str->str + str->len) - s + 1); } s = c; } c = str->str; str->str = ns; if (str->sp >= str->len) str->sp += expand; str->len += expand; str->str[str->len] = 0; str->maxsize = newsize; DohFree(c); return rcount; } } /* ----------------------------------------------------------------------------- * String_replace() * ----------------------------------------------------------------------------- */ static int String_replace(DOH *stro, const DOHString_or_char *token, const DOHString_or_char *rep, int flags) { int count = -1; String *str = (String *) ObjData(stro); if (flags & DOH_REPLACE_FIRST) count = 1; if (flags & DOH_REPLACE_ID_END) { return replace_simple(str, Char(token), Char(rep), flags, count, match_identifier_end); } else if (flags & DOH_REPLACE_ID_BEGIN) { return replace_simple(str, Char(token), Char(rep), flags, count, match_identifier_begin); } else if (flags & DOH_REPLACE_ID) { return replace_simple(str, Char(token), Char(rep), flags, count, match_identifier); } else if (flags & DOH_REPLACE_NUMBER_END) { return replace_simple(str, Char(token), Char(rep), flags, count, match_number_end); } else { return replace_simple(str, Char(token), Char(rep), flags, count, match_simple); } } /* ----------------------------------------------------------------------------- * String_chop() * ----------------------------------------------------------------------------- */ static void String_chop(DOH *so) { char *c; String *str = (String *) ObjData(so); /* Replace trailing whitespace */ c = str->str + str->len - 1; while ((str->len > 0) && (isspace((int) *c))) { if (str->sp >= str->len) { str->sp--; if (*c == '\n') str->line--; } str->len--; c--; } str->str[str->len] = 0; assert(str->sp >= 0); str->hashkey = -1; } static void String_setfile(DOH *so, DOH *file) { DOH *fo; String *str = (String *) ObjData(so); if (!DohCheck(file)) { fo = NewString(file); Decref(fo); } else fo = file; Incref(fo); Delete(str->file); str->file = fo; } static DOH *String_getfile(DOH *so) { String *str = (String *) ObjData(so); return str->file; } static void String_setline(DOH *so, int line) { String *str = (String *) ObjData(so); str->line = line; } static int String_getline(DOH *so) { String *str = (String *) ObjData(so); return str->line; } static DohListMethods StringListMethods = { 0, /* doh_getitem */ 0, /* doh_setitem */ String_delitem, /* doh_delitem */ String_insert, /* doh_insitem */ String_delslice, /* doh_delslice */ }; static DohFileMethods StringFileMethods = { String_read, String_write, String_putc, String_getc, String_ungetc, String_seek, String_tell, 0, /* close */ }; static DohStringMethods StringStringMethods = { String_replace, String_chop, }; DohObjInfo DohStringType = { "String", /* objname */ DelString, /* doh_del */ CopyString, /* doh_copy */ String_clear, /* doh_clear */ String_str, /* doh_str */ String_data, /* doh_data */ String_dump, /* doh_dump */ String_len, /* doh_len */ String_hash, /* doh_hash */ String_cmp, /* doh_cmp */ String_equal, /* doh_equal */ 0, /* doh_first */ 0, /* doh_next */ String_setfile, /* doh_setfile */ String_getfile, /* doh_getfile */ String_setline, /* doh_setline */ String_getline, /* doh_getline */ 0, /* doh_mapping */ &StringListMethods, /* doh_sequence */ &StringFileMethods, /* doh_file */ &StringStringMethods, /* doh_string */ 0, /* doh_position */ 0 }; #define INIT_MAXSIZE 16 /* ----------------------------------------------------------------------------- * NewString() - Create a new string * ----------------------------------------------------------------------------- */ DOHString *DohNewString(const DOHString_or_char *so) { int l = 0, max; String *str; char *s; int hashkey = -1; if (DohCheck(so)) { str = (String *) ObjData(so); s = (char *) String_data((String *) so); l = s ? str->len : 0; hashkey = str->hashkey; } else { s = (char *) so; l = s ? (int) strlen(s) : 0; } str = (String *) DohMalloc(sizeof(String)); str->hashkey = hashkey; str->sp = 0; str->line = 1; str->file = 0; max = INIT_MAXSIZE; if (s) { if ((l + 1) > max) max = l + 1; } str->str = (char *) DohMalloc(max); str->maxsize = max; if (s) { strcpy(str->str, s); str->len = l; str->sp = l; } else { str->str[0] = 0; str->len = 0; } return DohObjMalloc(&DohStringType, str); } /* ----------------------------------------------------------------------------- * NewStringEmpty() - Create a new string * ----------------------------------------------------------------------------- */ DOHString *DohNewStringEmpty(void) { int max = INIT_MAXSIZE; String *str = (String *) DohMalloc(sizeof(String)); str->hashkey = 0; str->sp = 0; str->line = 1; str->file = 0; str->str = (char *) DohMalloc(max); str->maxsize = max; str->str[0] = 0; str->len = 0; return DohObjMalloc(&DohStringType, str); } /* ----------------------------------------------------------------------------- * NewStringWithSize() - Create a new string * ----------------------------------------------------------------------------- */ DOHString *DohNewStringWithSize(const DOHString_or_char *so, int len) { int l = 0, max; String *str; char *s; if (DohCheck(so)) { s = (char *) String_data((String *) so); } else { s = (char *) so; } str = (String *) DohMalloc(sizeof(String)); str->hashkey = -1; str->sp = 0; str->line = 1; str->file = 0; max = INIT_MAXSIZE; if (s) { l = (int) len; if ((l + 1) > max) max = l + 1; } str->str = (char *) DohMalloc(max); str->maxsize = max; if (s) { strncpy(str->str, s, len); str->str[l] = 0; str->len = l; str->sp = l; } else { str->str[0] = 0; str->len = 0; } return DohObjMalloc(&DohStringType, str); } /* ----------------------------------------------------------------------------- * NewStringf() * * Create a new string from a list of objects. * ----------------------------------------------------------------------------- */ DOHString *DohNewStringf(const DOHString_or_char *fmt, ...) { va_list ap; DOH *r; va_start(ap, fmt); r = NewStringEmpty(); DohvPrintf(r, Char(fmt), ap); va_end(ap); return (DOHString *) r; } /* ----------------------------------------------------------------------------- * Strcmp() * Strncmp() * Strstr() * Strchr() * * Some utility functions. * ----------------------------------------------------------------------------- */ int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2) { const char *c1 = Char(s1); const char *c2 = Char(s2); return strcmp(c1, c2); } int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n) { return strncmp(Char(s1), Char(s2), n); } char *DohStrstr(const DOHString_or_char *s1, const DOHString_or_char *s2) { char *p1 = Char(s1); char *p2 = Char(s2); return p1 == 0 || p2 == 0 || *p2 == '\0' ? p1 : strstr(p1, p2); } char *DohStrchr(const DOHString_or_char *s1, int ch) { return strchr(Char(s1), ch); } swig-3.0.2/Source/DOH/base.c0000664000175000017500000006506712343605122015311 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * base.c * * This file contains the function entry points for dispatching methods on * DOH objects. A number of small utility functions are also included. * ----------------------------------------------------------------------------- */ #include "dohint.h" /* ----------------------------------------------------------------------------- * DohDelete() * ----------------------------------------------------------------------------- */ #ifndef SWIG_DEBUG_DELETE #define SWIG_DEBUG_DELETE 0 #endif void DohDelete(DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (!obj) return; if (!DohCheck(b)) { #if SWIG_DEBUG_DELETE fputs("DOH: Fatal error. Attempt to delete a non-doh object.\n", stderr); abort(); #else assert(0); #endif return; } if (b->flag_intern) return; assert(b->refcount > 0); b->refcount--; if (b->refcount <= 0) { objinfo = b->type; if (objinfo->doh_del) { (objinfo->doh_del) (b); } else { if (b->data) DohFree(b->data); } DohObjFree(b); } } /* ----------------------------------------------------------------------------- * DohCopy() * ----------------------------------------------------------------------------- */ DOH *DohCopy(const DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (!obj) return 0; if (!DohCheck(b)) { #if SWIG_DEBUG_DELETE fputs("DOH: Fatal error. Attempt to copy a non-doh object.\n", stderr); abort(); #else assert(0); #endif return 0; } objinfo = b->type; if (objinfo->doh_copy) { DohBase *bc = (DohBase *) (objinfo->doh_copy) (b); if ((bc) && b->meta) { bc->meta = Copy(b->meta); } return (DOH *) bc; } return 0; } void DohIncref(DOH *obj) { Incref(obj); } /* ----------------------------------------------------------------------------- * DohClear() * ----------------------------------------------------------------------------- */ void DohClear(DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_clear) (objinfo->doh_clear) (b); } /* ----------------------------------------------------------------------------- * DohStr() * ----------------------------------------------------------------------------- */ DOH *DohStr(const DOH *obj) { char buffer[512]; DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (DohCheck(b)) { objinfo = b->type; if (objinfo->doh_str) { return (objinfo->doh_str) (b); } sprintf(buffer, "", objinfo->objname, (void *) b); return NewString(buffer); } else { return NewString(obj); } } /* ----------------------------------------------------------------------------- * DohDump() * ----------------------------------------------------------------------------- */ int DohDump(const DOH *obj, DOH *out) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_dump) { return (objinfo->doh_dump) (b, out); } return 0; } /* ----------------------------------------------------------------------------- * DohLen() - Defaults to strlen() if not a DOH object * ----------------------------------------------------------------------------- */ int DohLen(const DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (!b) return 0; if (DohCheck(b)) { objinfo = b->type; if (objinfo->doh_len) { return (objinfo->doh_len) (b); } return 0; } else { return strlen((char *) obj); } } /* ----------------------------------------------------------------------------- * DohHashVal() * ----------------------------------------------------------------------------- */ int DohHashval(const DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; /* obj is already checked and/or converted into DohBase* */ /* if (DohCheck(b)) */ { objinfo = b->type; if (objinfo->doh_hashval) { return (objinfo->doh_hashval) (b); } } return 0; } /* ----------------------------------------------------------------------------- * DohData() * ----------------------------------------------------------------------------- */ void *DohData(const DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (DohCheck(obj)) { objinfo = b->type; if (objinfo->doh_data) { return (objinfo->doh_data) (b); } return 0; } return (void *) obj; } /* ----------------------------------------------------------------------------- * RawData() * ----------------------------------------------------------------------------- */ static void *RawData(DohBase *b) { DohObjInfo *objinfo = b->type; return (objinfo->doh_data) ? (objinfo->doh_data) (b) : 0; } /* ----------------------------------------------------------------------------- * DohCmp() * ----------------------------------------------------------------------------- */ int DohCmp(const DOH *obj1, const DOH *obj2) { DohBase *b1, *b2; DohObjInfo *b1info, *b2info; int c1, c2; b1 = (DohBase *) obj1; b2 = (DohBase *) obj2; c1 = DohCheck(b1); c2 = DohCheck(b2); /* most of the times, obj2 is a plain c string */ if (!c1 || !c2) { if ((b1 == 0) && (b2 == 0)) return 0; if (b1 && !b2) return 1; if (!b1 && b2) return -1; return strcmp((char *) (c1 ? RawData(b1) : (void *) obj1), (char *) (c2 ? RawData(b2) : (void *) obj2)); } b1info = b1->type; b2info = b2->type; if ((b1info == b2info) && (b1info->doh_cmp)) return (b1info->doh_cmp) (b1, b2); return 1; } /* ----------------------------------------------------------------------------- * DohEqual() * ----------------------------------------------------------------------------- */ int DohEqual(const DOH *obj1, const DOH *obj2) { DohBase *b1 = (DohBase *) obj1; DohBase *b2 = (DohBase *) obj2; if (!b1) { return !b2; } else if (!b2) { return 0; } else { DohObjInfo *b1info = 0; DohObjInfo *b2info = 0; if (DohCheck(b1)) { b1info = b1->type; if (DohCheck(b2)) { b2info = b2->type; } else { int len = (b1info->doh_len) (b1); char *cobj = (char *) obj2; return len == (int) strlen(cobj) ? (memcmp(RawData(b1), cobj, len) == 0) : 0; } } else if (DohCheck(b2)) { int len = (b2->type->doh_len) (b2); char *cobj = (char *) obj1; return len == (int) strlen(cobj) ? (memcmp(RawData(b2), cobj, len) == 0) : 0; } else { return strcmp((char *) obj1, (char *) obj2) == 0; } if (!b1info) { return obj1 == obj2; } else if (b1info == b2info) { return b1info->doh_equal ? (b1info->doh_equal) (b1, b2) : (b1info->doh_cmp ? (b1info->doh_cmp) (b1, b2) == 0 : (b1 == b2)); } else { return 0; } } } /* ----------------------------------------------------------------------------- * DohFirst() * ----------------------------------------------------------------------------- */ DohIterator DohFirst(DOH *obj) { DohIterator iter; DohBase *b; DohObjInfo *binfo; b = (DohBase *) obj; if (DohCheck(b)) { binfo = b->type; if (binfo->doh_first) { return (binfo->doh_first) (b); } } iter.object = 0; iter.item = 0; iter.key = 0; iter._current = 0; iter._index = 0; return iter; } /* ----------------------------------------------------------------------------- * DohNext() * ----------------------------------------------------------------------------- */ DohIterator DohNext(DohIterator iter) { DohIterator niter; if (iter.object) { DohBase *b; DohObjInfo *binfo; b = (DohBase *) iter.object; binfo = b->type; if (binfo->doh_next) { return (binfo->doh_next) (iter); } } niter = iter; return niter; } /* ----------------------------------------------------------------------------- * DohIsMapping() * ----------------------------------------------------------------------------- */ int DohIsMapping(const DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (!DohCheck(b)) return 0; objinfo = b->type; if (objinfo->doh_hash) return 1; else return 0; } /* ----------------------------------------------------------------------------- * DohGetattr() * ----------------------------------------------------------------------------- */ DOH *DohGetattr(DOH *obj, const DOH *name) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_hash && objinfo->doh_hash->doh_getattr) { DOH *r = (objinfo->doh_hash->doh_getattr) (b, (DOH *) name); return (r == DohNone) ? 0 : r; } return 0; } /* ----------------------------------------------------------------------------- * DohSetattr() * ----------------------------------------------------------------------------- */ int DohSetattr(DOH *obj, const DOH *name, const DOH *value) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_hash && objinfo->doh_hash->doh_setattr) { return (objinfo->doh_hash->doh_setattr) (b, (DOH *) name, (DOH *) value); } return 0; } /* ----------------------------------------------------------------------------- * DohDelattr() * ----------------------------------------------------------------------------- */ int DohDelattr(DOH *obj, const DOH *name) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_hash && objinfo->doh_hash->doh_delattr) { return (objinfo->doh_hash->doh_delattr) (b, (DOH *) name); } return 0; } /* ----------------------------------------------------------------------------- * DohCheckattr() * ----------------------------------------------------------------------------- */ int DohCheckattr(DOH *obj, const DOH *name, const DOH *value) { DOH *attr = Getattr(obj,name); if (!attr) return 0; return DohEqual(attr,value); } /* ----------------------------------------------------------------------------- * DohKeys() * ----------------------------------------------------------------------------- */ DOH *DohKeys(DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo && objinfo->doh_hash->doh_keys) { return (objinfo->doh_hash->doh_keys) (b); } return 0; } /* ----------------------------------------------------------------------------- * DohGetInt() * ----------------------------------------------------------------------------- */ int DohGetInt(DOH *obj, const DOH *name) { DOH *val; val = Getattr(obj, (DOH *) name); if (!val) return 0; if (DohIsString(val)) { return atoi((char *) Data(val)); } return 0; } /* ----------------------------------------------------------------------------- * DohGetDouble() * ----------------------------------------------------------------------------- */ double DohGetDouble(DOH *obj, const DOH *name) { DOH *val; val = Getattr(obj, (DOH *) name); if (!val) return 0; if (DohIsString(val)) { return atof((char *) Data(val)); } return 0; } /* ----------------------------------------------------------------------------- * DohGetChar() * ----------------------------------------------------------------------------- */ char *DohGetChar(DOH *obj, const DOH *name) { DOH *val; val = Getattr(obj, (DOH *) name); if (!val) return 0; if (DohIsString(val)) { return (char *) Data(val); } return 0; } /* ----------------------------------------------------------------------------- * DohGetFlagAttr() / DohGetFlag() * A flag is unset if the attribute (name) does not exist on the node (obj), * or it is set to "0". If the attribute is set to any other value, * the flag is set. * * DohGetFlag() returns if the flag is set or not * DohGetFlagAttr() returns the flag value if is set, NULL otherwise * ----------------------------------------------------------------------------- */ DOH *DohGetFlagAttr(DOH *obj, const DOH *name) { DOH *val = Getattr(obj, (DOH *) name); if (!val) { return NULL; } else { const char *cval = Char(val); if (!cval) return val; return (strcmp(cval, "0") != 0) ? val : NULL; } } int DohGetFlag(DOH *obj, const DOH *name) { return DohGetFlagAttr(obj, name) ? 1 : 0; } /* ----------------------------------------------------------------------------- * DohGetVoid() * ----------------------------------------------------------------------------- */ void *DohGetVoid(DOH *obj, const DOH *name) { DOH *val; val = Getattr(obj, (DOH *) name); if (!val) return 0; return (void *) Data(val); } /* ----------------------------------------------------------------------------- * DohSetInt() * ----------------------------------------------------------------------------- */ void DohSetInt(DOH *obj, const DOH *name, int value) { DOH *temp; temp = NewStringEmpty(); Printf(temp, "%d", value); Setattr(obj, (DOH *) name, temp); } /* ----------------------------------------------------------------------------- * DohSetDouble() * ----------------------------------------------------------------------------- */ void DohSetDouble(DOH *obj, const DOH *name, double value) { DOH *temp; temp = NewStringEmpty(); Printf(temp, "%0.17f", value); Setattr(obj, (DOH *) name, temp); } /* ----------------------------------------------------------------------------- * DohSetChar() * ----------------------------------------------------------------------------- */ void DohSetChar(DOH *obj, const DOH *name, char *value) { Setattr(obj, (DOH *) name, NewString(value)); } /* ----------------------------------------------------------------------------- * DohSetFlag() * ----------------------------------------------------------------------------- */ void DohSetFlagAttr(DOH *obj, const DOH *name, const DOH *attr) { Setattr(obj, (DOH *) name, attr ? attr : NewString("0")); } void DohSetFlag(DOH *obj, const DOH *name) { Setattr(obj, (DOH *) name, NewString("1")); } /* ----------------------------------------------------------------------------- * DohSetVoid() * ----------------------------------------------------------------------------- */ void DohSetVoid(DOH *obj, const DOH *name, void *value) { Setattr(obj, (DOH *) name, NewVoid(value, 0)); } /* ----------------------------------------------------------------------------- * DohIsSequence() * ----------------------------------------------------------------------------- */ int DohIsSequence(const DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (!DohCheck(b)) return 0; objinfo = b->type; if (objinfo->doh_list) return 1; else return 0; } /* ----------------------------------------------------------------------------- * DohGetitem() * ----------------------------------------------------------------------------- */ DOH *DohGetitem(DOH *obj, int index) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_list && objinfo->doh_list->doh_getitem) { return (objinfo->doh_list->doh_getitem) (b, index); } return 0; } /* ----------------------------------------------------------------------------- * DohSetitem() * ----------------------------------------------------------------------------- */ int DohSetitem(DOH *obj, int index, const DOH *value) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_list && objinfo->doh_list->doh_setitem) { return (objinfo->doh_list->doh_setitem) (b, index, (DOH *) value); } return -1; } /* ----------------------------------------------------------------------------- * DohDelitem() * ----------------------------------------------------------------------------- */ int DohDelitem(DOH *obj, int index) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_list && objinfo->doh_list->doh_delitem) { return (objinfo->doh_list->doh_delitem) (b, index); } return -1; } /* ----------------------------------------------------------------------------- * DohInsertitem() * ----------------------------------------------------------------------------- */ int DohInsertitem(DOH *obj, int index, const DOH *value) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_list && objinfo->doh_list->doh_insitem) { return (objinfo->doh_list->doh_insitem) (b, index, (DOH *) value); } return -1; } /* ----------------------------------------------------------------------------- * DohDelslice() * ----------------------------------------------------------------------------- */ int DohDelslice(DOH *obj, int sindex, int eindex) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo = b->type; if (objinfo->doh_list && objinfo->doh_list->doh_delslice) { return (objinfo->doh_list->doh_delslice) (b, sindex, eindex); } return -1; } /* ----------------------------------------------------------------------------- * DohIsFile() * ----------------------------------------------------------------------------- */ int DohIsFile(const DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (!DohCheck(b)) return 0; objinfo = b->type; if (objinfo->doh_file) return 1; else return 0; } /* ----------------------------------------------------------------------------- * DohRead() * ----------------------------------------------------------------------------- */ int DohRead(DOH *obj, void *buffer, int length) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (DohCheck(obj)) { objinfo = b->type; if ((objinfo->doh_file) && (objinfo->doh_file->doh_read)) { return (objinfo->doh_file->doh_read) (b, buffer, length); } return -1; } /* Hmmm. Not a file. Maybe it's a real FILE */ return fread(buffer, 1, length, (FILE *) b); } /* ----------------------------------------------------------------------------- * DohWrite() * ----------------------------------------------------------------------------- */ int DohWrite(DOH *obj, const void *buffer, int length) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (DohCheck(obj)) { objinfo = b->type; if ((objinfo->doh_file) && (objinfo->doh_file->doh_write)) { return (objinfo->doh_file->doh_write) (b, buffer, length); } return -1; } /* Hmmm. Not a file. Maybe it's a real FILE */ return fwrite(buffer, 1, length, (FILE *) b); } /* ----------------------------------------------------------------------------- * DohSeek() * ----------------------------------------------------------------------------- */ int DohSeek(DOH *obj, long offset, int whence) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (DohCheck(obj)) { objinfo = b->type; if ((objinfo->doh_file) && (objinfo->doh_file->doh_seek)) { return (objinfo->doh_file->doh_seek) (b, offset, whence); } return -1; } return fseek((FILE *) b, offset, whence); } /* ----------------------------------------------------------------------------- * DohTell() * ----------------------------------------------------------------------------- */ long DohTell(DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (DohCheck(obj)) { objinfo = b->type; if ((objinfo->doh_file) && (objinfo->doh_file->doh_tell)) { return (objinfo->doh_file->doh_tell) (b); } return -1; } return ftell((FILE *) b); } /* ----------------------------------------------------------------------------- * DohGetc() * ----------------------------------------------------------------------------- */ int DohGetc(DOH *obj) { static DOH *lastdoh = 0; DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (obj == lastdoh) { objinfo = b->type; return (objinfo->doh_file->doh_getc) (b); } if (DohCheck(obj)) { objinfo = b->type; if (objinfo->doh_file->doh_getc) { lastdoh = obj; return (objinfo->doh_file->doh_getc) (b); } return EOF; } return fgetc((FILE *) b); } /* ----------------------------------------------------------------------------- * DohPutc() * ----------------------------------------------------------------------------- */ int DohPutc(int ch, DOH *obj) { static DOH *lastdoh = 0; DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (obj == lastdoh) { objinfo = b->type; return (objinfo->doh_file->doh_putc) (b, ch); } if (DohCheck(obj)) { objinfo = b->type; if (objinfo->doh_file->doh_putc) { lastdoh = obj; return (objinfo->doh_file->doh_putc) (b, ch); } return EOF; } return fputc(ch, (FILE *) b); } /* ----------------------------------------------------------------------------- * DohUngetc() * ----------------------------------------------------------------------------- */ int DohUngetc(int ch, DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (DohCheck(obj)) { objinfo = b->type; if (objinfo->doh_file->doh_ungetc) { return (objinfo->doh_file->doh_ungetc) (b, ch); } return EOF; } return ungetc(ch, (FILE *) b); } /* ----------------------------------------------------------------------------- * DohClose() * ----------------------------------------------------------------------------- */ /* int DohClose(DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (DohCheck(obj)) { objinfo = b->type; if (objinfo->doh_file->doh_close) { return (objinfo->doh_file->doh_close) (b); } return 0; } return fclose((FILE *) obj); } */ /* ----------------------------------------------------------------------------- * DohIsString() * ----------------------------------------------------------------------------- */ int DohIsString(const DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (!DohCheck(b)) return 0; objinfo = b->type; if (objinfo->doh_string) return 1; else return 0; } /* ----------------------------------------------------------------------------- * DohReplace() * ----------------------------------------------------------------------------- */ int DohReplace(DOH *src, const DOH *token, const DOH *rep, int flags) { DohBase *b = (DohBase *) src; DohObjInfo *objinfo; if (!token) return 0; if (!rep) rep = ""; if (DohIsString(src)) { objinfo = b->type; if (objinfo->doh_string->doh_replace) { return (objinfo->doh_string->doh_replace) (b, (DOH *) token, (DOH *) rep, flags); } } return 0; } /* ----------------------------------------------------------------------------- * DohChop() * ----------------------------------------------------------------------------- */ void DohChop(DOH *src) { DohBase *b = (DohBase *) src; DohObjInfo *objinfo; if (DohIsString(src)) { objinfo = b->type; if (objinfo->doh_string->doh_chop) { (objinfo->doh_string->doh_chop) (b); } } } /* ----------------------------------------------------------------------------- * DohSetFile() * ----------------------------------------------------------------------------- */ void DohSetfile(DOH *ho, DOH *file) { DohBase *h = (DohBase *) ho; DohObjInfo *objinfo; if (!h) return; objinfo = h->type; if (objinfo->doh_setfile) (objinfo->doh_setfile) (h, file); } /* ----------------------------------------------------------------------------- * DohGetFile() * ----------------------------------------------------------------------------- */ DOH *DohGetfile(const DOH *ho) { DohBase *h = (DohBase *) ho; DohObjInfo *objinfo; if (!h) return 0; objinfo = h->type; if (objinfo->doh_getfile) return (objinfo->doh_getfile) (h); return 0; } /* ----------------------------------------------------------------------------- * DohSetLine() * ----------------------------------------------------------------------------- */ void DohSetline(DOH *ho, int l) { DohBase *h = (DohBase *) ho; DohObjInfo *objinfo; if (!h) return; objinfo = h->type; if (objinfo->doh_setline) (objinfo->doh_setline) (h, l); } /* ----------------------------------------------------------------------------- * DohGetLine() * ----------------------------------------------------------------------------- */ int DohGetline(const DOH *ho) { DohBase *h = (DohBase *) ho; DohObjInfo *objinfo; if (!h) return 0; objinfo = h->type; if (objinfo->doh_getline) return (objinfo->doh_getline) (h); return 0; } /* ----------------------------------------------------------------------------- * DohGetmeta() * ----------------------------------------------------------------------------- */ DOH *DohGetmeta(DOH *ho, const DOH *name) { DohBase *h = (DohBase *) ho; if (!DohCheck(ho)) return 0; if (!h->meta) return 0; return DohGetattr(h->meta, name); } /* ----------------------------------------------------------------------------- * DohGetmeta() * ----------------------------------------------------------------------------- */ int DohSetmeta(DOH *ho, const DOH *name, const DOH *value) { DohBase *h = (DohBase *) ho; if (!DohCheck(ho)) return 0; if (!h->meta) h->meta = NewHash(); return DohSetattr(h->meta, name, value); } /* ----------------------------------------------------------------------------- * DohDelmeta() * ----------------------------------------------------------------------------- */ int DohDelmeta(DOH *ho, const DOH *name) { DohBase *h = (DohBase *) ho; if (!DohCheck(ho)) return 0; if (!h->meta) return 0; return DohDelattr(h->meta, name); } /* ----------------------------------------------------------------------------- * DohSetmark() * ----------------------------------------------------------------------------- */ void DohSetmark(DOH *ho, int x) { DohBase *h = (DohBase *) ho; h->flag_usermark = x; } int DohGetmark(DOH *ho) { DohBase *h = (DohBase *) ho; return h->flag_usermark; } /* ----------------------------------------------------------------------------- * DohCall() * * Invokes a function via DOH. A Function is represented by a hash table with * the following attributes: * * "builtin" - Pointer to built-in function (if any) * * (Additional attributes may be added later) * * Returns a DOH object with result on success. Returns NULL on error * ----------------------------------------------------------------------------- */ DOH *DohCall(DOH *func, DOH *args) { DOH *result; DohFuncPtr_t builtin; builtin.p = GetVoid(func, "builtin"); if (!builtin.p) return 0; result = (*builtin.func) (args); return result; } swig-3.0.2/Source/Makefile.in0000664000175000017500000012303712343706574015673 0ustar williamwilliam# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = eswig$(EXEEXT) subdir = Source DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ CParse/parser.c CParse/parser.h ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/Tools/config/ac_compare_version.m4 \ $(top_srcdir)/Tools/config/ac_compile_warnings.m4 \ $(top_srcdir)/Tools/config/ac_define_dir.m4 \ $(top_srcdir)/Tools/config/ax_boost_base.m4 \ $(top_srcdir)/Tools/config/ax_compare_version.m4 \ $(top_srcdir)/Tools/config/ax_cxx_compile_stdcxx_11.m4 \ $(top_srcdir)/Tools/config/ax_path_generic.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/Source/Include/swigconfig.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__dirstamp = $(am__leading_dot)dirstamp am_eswig_OBJECTS = CParse/cscanner.$(OBJEXT) CParse/parser.$(OBJEXT) \ CParse/templ.$(OBJEXT) CParse/util.$(OBJEXT) \ DOH/base.$(OBJEXT) DOH/file.$(OBJEXT) DOH/fio.$(OBJEXT) \ DOH/hash.$(OBJEXT) DOH/list.$(OBJEXT) DOH/memory.$(OBJEXT) \ DOH/string.$(OBJEXT) DOH/void.$(OBJEXT) \ Modules/allegrocl.$(OBJEXT) Modules/allocate.$(OBJEXT) \ Modules/browser.$(OBJEXT) Modules/cffi.$(OBJEXT) \ Modules/chicken.$(OBJEXT) Modules/clisp.$(OBJEXT) \ Modules/contract.$(OBJEXT) Modules/csharp.$(OBJEXT) \ Modules/d.$(OBJEXT) Modules/directors.$(OBJEXT) \ Modules/emit.$(OBJEXT) Modules/go.$(OBJEXT) \ Modules/guile.$(OBJEXT) Modules/java.$(OBJEXT) \ Modules/javascript.$(OBJEXT) Modules/lang.$(OBJEXT) \ Modules/lua.$(OBJEXT) Modules/main.$(OBJEXT) \ Modules/modula3.$(OBJEXT) Modules/module.$(OBJEXT) \ Modules/mzscheme.$(OBJEXT) Modules/nested.$(OBJEXT) \ Modules/ocaml.$(OBJEXT) Modules/octave.$(OBJEXT) \ Modules/overload.$(OBJEXT) Modules/perl5.$(OBJEXT) \ Modules/php.$(OBJEXT) Modules/pike.$(OBJEXT) \ Modules/python.$(OBJEXT) Modules/r.$(OBJEXT) \ Modules/ruby.$(OBJEXT) Modules/s-exp.$(OBJEXT) \ Modules/swigmain.$(OBJEXT) Modules/tcl8.$(OBJEXT) \ Modules/typepass.$(OBJEXT) Modules/uffi.$(OBJEXT) \ Modules/utils.$(OBJEXT) Modules/xml.$(OBJEXT) \ Preprocessor/cpp.$(OBJEXT) Preprocessor/expr.$(OBJEXT) \ Swig/cwrap.$(OBJEXT) Swig/deprecate.$(OBJEXT) \ Swig/error.$(OBJEXT) Swig/extend.$(OBJEXT) \ Swig/fragment.$(OBJEXT) Swig/getopt.$(OBJEXT) \ Swig/include.$(OBJEXT) Swig/misc.$(OBJEXT) \ Swig/naming.$(OBJEXT) Swig/parms.$(OBJEXT) \ Swig/scanner.$(OBJEXT) Swig/stype.$(OBJEXT) \ Swig/symbol.$(OBJEXT) Swig/tree.$(OBJEXT) \ Swig/typeobj.$(OBJEXT) Swig/typemap.$(OBJEXT) \ Swig/typesys.$(OBJEXT) Swig/wrapfunc.$(OBJEXT) eswig_OBJECTS = $(am_eswig_OBJECTS) eswig_DEPENDENCIES = DEFAULT_INCLUDES = depcomp = $(SHELL) $(top_srcdir)/Tools/config/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS) YLWRAP = $(top_srcdir)/Tools/config/ylwrap SOURCES = $(eswig_SOURCES) DIST_SOURCES = $(eswig_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ADB = @ADB@ ALLEGROCLBIN = @ALLEGROCLBIN@ AMTAR = @AMTAR@ ANDROID = @ANDROID@ ANT = @ANT@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDFLAGS = @BOOST_LDFLAGS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CCSHARED = @CCSHARED@ CFLAGS = @CFLAGS@ CHICKEN = @CHICKEN@ CHICKENLIB = @CHICKENLIB@ CHICKENOPTS = @CHICKENOPTS@ CHICKENSHAREDLIB = @CHICKENSHAREDLIB@ CHICKEN_CSC = @CHICKEN_CSC@ CHICKEN_CSI = @CHICKEN_CSI@ CLISPBIN = @CLISPBIN@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSHARPCFLAGS = @CSHARPCFLAGS@ CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@ CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@ CSHARPCOMPILER = @CSHARPCOMPILER@ CSHARPCYGPATH_W = @CSHARPCYGPATH_W@ CSHARPDYNAMICLINKING = @CSHARPDYNAMICLINKING@ CSHARPLIBRARYPREFIX = @CSHARPLIBRARYPREFIX@ CSHARPPATHSEPARATOR = @CSHARPPATHSEPARATOR@ CSHARPSO = @CSHARPSO@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXXSHARED = @CXXSHARED@ CYGPATH_W = @CYGPATH_W@ D1COMPILER = @D1COMPILER@ D2COMPILER = @D2COMPILER@ DDEFAULTVERSION = @DDEFAULTVERSION@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLIBPREFIX = @DLIBPREFIX@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_CCACHE = @ENABLE_CCACHE@ EXEEXT = @EXEEXT@ EXTRA_CLEAN = @EXTRA_CLEAN@ GCJ = @GCJ@ GCJH = @GCJH@ GO = @GO@ GO1 = @GO1@ GO12 = @GO12@ GO13 = @GO13@ GOC = @GOC@ GOGCC = @GOGCC@ GOOPT = @GOOPT@ GOVERSIONOPTION = @GOVERSIONOPTION@ GREP = @GREP@ GUILE = @GUILE@ GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_CONFIG = @GUILE_CONFIG@ GUILE_LIBS = @GUILE_LIBS@ GUILE_SO = @GUILE_SO@ HAVE_CXX11_COMPILER = @HAVE_CXX11_COMPILER@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ JAVA = @JAVA@ JAVAC = @JAVAC@ JAVACFLAGS = @JAVACFLAGS@ JAVACXXSHARED = @JAVACXXSHARED@ JAVADYNAMICLINKING = @JAVADYNAMICLINKING@ JAVAINC = @JAVAINC@ JAVALDSHARED = @JAVALDSHARED@ JAVALIBRARYPREFIX = @JAVALIBRARYPREFIX@ JAVASO = @JAVASO@ JSCENABLED = @JSCENABLED@ JSCOREDYNAMICLINKING = @JSCOREDYNAMICLINKING@ JSCOREINC = @JSCOREINC@ JSCOREVERSION = @JSCOREVERSION@ JSCXXSHARED = @JSCXXSHARED@ JSINTERPRETERCXX = @JSINTERPRETERCXX@ JSINTERPRETERLINKFLAGS = @JSINTERPRETERLINKFLAGS@ JSLDSHARED = @JSLDSHARED@ JSLIBRARYPREFIX = @JSLIBRARYPREFIX@ JSSO = @JSSO@ JSV8DYNAMICLINKING = @JSV8DYNAMICLINKING@ JSV8ENABLED = @JSV8ENABLED@ JSV8INC = @JSV8INC@ LDFLAGS = @LDFLAGS@ LDSHARED = @LDSHARED@ LIBC = @LIBC@ LIBCRYPT = @LIBCRYPT@ LIBM = @LIBM@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LINKFORSHARED = @LINKFORSHARED@ LTLIBOBJS = @LTLIBOBJS@ LUABIN = @LUABIN@ LUADYNAMICLINKING = @LUADYNAMICLINKING@ LUAFLAGS = @LUAFLAGS@ LUALINK = @LUALINK@ LUA_SO = @LUA_SO@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MZC = @MZC@ MZDYNOBJ = @MZDYNOBJ@ MZSCHEME = @MZSCHEME@ MZSCHEME_SO = @MZSCHEME_SO@ NDKBUILD = @NDKBUILD@ NODEGYP = @NODEGYP@ NODEJS = @NODEJS@ OBJEXT = @OBJEXT@ OCAMLBIN = @OCAMLBIN@ OCAMLC = @OCAMLC@ OCAMLDLGEN = @OCAMLDLGEN@ OCAMLFIND = @OCAMLFIND@ OCAMLINC = @OCAMLINC@ OCAMLLOC = @OCAMLLOC@ OCAMLMKTOP = @OCAMLMKTOP@ OCAMLVER = @OCAMLVER@ OCTAVE = @OCTAVE@ OCTAVE_CPPFLAGS = @OCTAVE_CPPFLAGS@ OCTAVE_CXXFLAGS = @OCTAVE_CXXFLAGS@ OCTAVE_LDFLAGS = @OCTAVE_LDFLAGS@ OCTAVE_SO = @OCTAVE_SO@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PCRE_CFLAGS = @PCRE_CFLAGS@ PCRE_CONFIG = @PCRE_CONFIG@ PCRE_LIBS = @PCRE_LIBS@ PERL = @PERL@ PERL5CCCDLFLAGS = @PERL5CCCDLFLAGS@ PERL5CCDLFLAGS = @PERL5CCDLFLAGS@ PERL5CCFLAGS = @PERL5CCFLAGS@ PERL5DYNAMICLINKING = @PERL5DYNAMICLINKING@ PERL5EXT = @PERL5EXT@ PERL5LDFLAGS = @PERL5LDFLAGS@ PERL5LIB = @PERL5LIB@ PHP = @PHP@ PHPINC = @PHPINC@ PHP_SO = @PHP_SO@ PIKE = @PIKE@ PIKECCDLFLAGS = @PIKECCDLFLAGS@ PIKECONFIG = @PIKECONFIG@ PIKEDYNAMICLINKING = @PIKEDYNAMICLINKING@ PIKEINCLUDE = @PIKEINCLUDE@ PLATCFLAGS = @PLATCFLAGS@ PLATCXXFLAGS = @PLATCXXFLAGS@ PY3CONFIG = @PY3CONFIG@ PY3INCLUDE = @PY3INCLUDE@ PY3LIB = @PY3LIB@ PY3LINK = @PY3LINK@ PYINCLUDE = @PYINCLUDE@ PYLIB = @PYLIB@ PYLINK = @PYLINK@ PYTHON = @PYTHON@ PYTHON3 = @PYTHON3@ PYTHON3DYNAMICLINKING = @PYTHON3DYNAMICLINKING@ PYTHONDYNAMICLINKING = @PYTHONDYNAMICLINKING@ PYTHON_SO = @PYTHON_SO@ RANLIB = @RANLIB@ RBIN = @RBIN@ ROOT_DIR = @ROOT_DIR@ RPATH = @RPATH@ RUBY = @RUBY@ RUBYCCDLFLAGS = @RUBYCCDLFLAGS@ RUBYDYNAMICLINKING = @RUBYDYNAMICLINKING@ RUBYINCLUDE = @RUBYINCLUDE@ RUBYLIB = @RUBYLIB@ RUBYLINK = @RUBYLINK@ RUBYSO = @RUBYSO@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SKIP_ALLEGROCL = @SKIP_ALLEGROCL@ SKIP_ANDROID = @SKIP_ANDROID@ SKIP_CFFI = @SKIP_CFFI@ SKIP_CHICKEN = @SKIP_CHICKEN@ SKIP_CLISP = @SKIP_CLISP@ SKIP_CSHARP = @SKIP_CSHARP@ SKIP_D = @SKIP_D@ SKIP_GCJ = @SKIP_GCJ@ SKIP_GO = @SKIP_GO@ SKIP_GUILE = @SKIP_GUILE@ SKIP_JAVA = @SKIP_JAVA@ SKIP_JAVASCRIPT = @SKIP_JAVASCRIPT@ SKIP_LUA = @SKIP_LUA@ SKIP_MODULA3 = @SKIP_MODULA3@ SKIP_MZSCHEME = @SKIP_MZSCHEME@ SKIP_OCAML = @SKIP_OCAML@ SKIP_OCTAVE = @SKIP_OCTAVE@ SKIP_PERL5 = @SKIP_PERL5@ SKIP_PHP = @SKIP_PHP@ SKIP_PIKE = @SKIP_PIKE@ SKIP_PYTHON = @SKIP_PYTHON@ SKIP_PYTHON3 = @SKIP_PYTHON3@ SKIP_R = @SKIP_R@ SKIP_RUBY = @SKIP_RUBY@ SKIP_TCL = @SKIP_TCL@ SKIP_UFFI = @SKIP_UFFI@ SO = @SO@ STRIP = @STRIP@ SWIGLIBS = @SWIGLIBS@ SWIG_LIB = @SWIG_LIB@ SWILL = @SWILL@ TCLCXXSHARED = @TCLCXXSHARED@ TCLDYNAMICLINKING = @TCLDYNAMICLINKING@ TCLINCLUDE = @TCLINCLUDE@ TCLLDSHARED = @TCLLDSHARED@ TCLLIB = @TCLLIB@ TCL_SO = @TCL_SO@ TRYLINKINGWITHCXX = @TRYLINKINGWITHCXX@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ YODL2HTML = @YODL2HTML@ YODL2MAN = @YODL2MAN@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_aux_dir = @ac_aux_dir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ subdirs = @subdirs@ swig_lib = @swig_lib@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # subdir-objects generates object files using the directory structure of the source files. AUTOMAKE_OPTIONS = foreign nostdinc subdir-objects 1.7.2 SOURCE_DIR = $(top_srcdir)/Source BUILD_SOURCE_DIR = $(top_builddir)/Source SWIG_CXX_DEFS = @SWILL@ AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ -I$(BUILD_SOURCE_DIR)/CParse \ -I$(SOURCE_DIR)/Include \ -I$(SOURCE_DIR)/DOH \ -I$(SOURCE_DIR)/CParse \ -I$(SOURCE_DIR)/Preprocessor \ -I$(SOURCE_DIR)/Swig \ -I$(SOURCE_DIR)/Modules AM_CXXFLAGS = $(SWIG_CXX_DEFS) AM_YFLAGS = -d BUILT_SOURCES = CParse/parser.h eswig_SOURCES = CParse/cscanner.c \ CParse/parser.y \ CParse/templ.c \ CParse/util.c \ DOH/base.c \ DOH/file.c \ DOH/fio.c \ DOH/hash.c \ DOH/list.c \ DOH/memory.c \ DOH/string.c \ DOH/void.c \ Modules/allegrocl.cxx \ Modules/allocate.cxx \ Modules/browser.cxx \ Modules/cffi.cxx \ Modules/chicken.cxx \ Modules/clisp.cxx \ Modules/contract.cxx \ Modules/csharp.cxx \ Modules/d.cxx \ Modules/directors.cxx \ Modules/emit.cxx \ Modules/go.cxx \ Modules/guile.cxx \ Modules/java.cxx \ Modules/javascript.cxx \ Modules/lang.cxx \ Modules/lua.cxx \ Modules/main.cxx \ Modules/modula3.cxx \ Modules/module.cxx \ Modules/mzscheme.cxx \ Modules/nested.cxx \ Modules/ocaml.cxx \ Modules/octave.cxx \ Modules/overload.cxx \ Modules/perl5.cxx \ Modules/php.cxx \ Modules/pike.cxx \ Modules/python.cxx \ Modules/r.cxx \ Modules/ruby.cxx \ Modules/s-exp.cxx \ Modules/swigmain.cxx \ Modules/tcl8.cxx \ Modules/typepass.cxx \ Modules/uffi.cxx \ Modules/utils.cxx \ Modules/xml.cxx \ Preprocessor/cpp.c \ Preprocessor/expr.c \ Swig/cwrap.c \ Swig/deprecate.c \ Swig/error.c \ Swig/extend.c \ Swig/fragment.c \ Swig/getopt.c \ Swig/include.c \ Swig/misc.c \ Swig/naming.c \ Swig/parms.c \ Swig/scanner.c \ Swig/stype.c \ Swig/symbol.c \ Swig/tree.c \ Swig/typeobj.c \ Swig/typemap.c \ Swig/typesys.c \ Swig/wrapfunc.c eswig_LDADD = @SWIGLIBS@ # Override the link stage to avoid using Libtool CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ # Beautify the code. # Note that this works well on C code, but does some odd joining of lines for C++ code. # Compiling with -DNDEBUG and no optimisations will allow one to do a binary diff of the # swig executable as a way of checking before and after the 'beautifying'. # Single files can be beautified with the beautify-file target, eg: 'make beautify-file INDENTFILE=chosenfile.c' SWIGTYPEDEFS = -T bool -T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T Scanner -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHObj_or_char -T DOHFile -T DOHString -T DOHString_or_char -T UpcallData INDENTBAKSDIR = ../IndentBaks all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .cxx .o .obj .y $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Source/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Source/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) CParse/$(am__dirstamp): @$(MKDIR_P) CParse @: > CParse/$(am__dirstamp) CParse/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) CParse/$(DEPDIR) @: > CParse/$(DEPDIR)/$(am__dirstamp) CParse/cscanner.$(OBJEXT): CParse/$(am__dirstamp) \ CParse/$(DEPDIR)/$(am__dirstamp) CParse/parser.h: CParse/parser.c @if test ! -f $@; then rm -f CParse/parser.c; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) CParse/parser.c; else :; fi CParse/parser.$(OBJEXT): CParse/$(am__dirstamp) \ CParse/$(DEPDIR)/$(am__dirstamp) CParse/templ.$(OBJEXT): CParse/$(am__dirstamp) \ CParse/$(DEPDIR)/$(am__dirstamp) CParse/util.$(OBJEXT): CParse/$(am__dirstamp) \ CParse/$(DEPDIR)/$(am__dirstamp) DOH/$(am__dirstamp): @$(MKDIR_P) DOH @: > DOH/$(am__dirstamp) DOH/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) DOH/$(DEPDIR) @: > DOH/$(DEPDIR)/$(am__dirstamp) DOH/base.$(OBJEXT): DOH/$(am__dirstamp) DOH/$(DEPDIR)/$(am__dirstamp) DOH/file.$(OBJEXT): DOH/$(am__dirstamp) DOH/$(DEPDIR)/$(am__dirstamp) DOH/fio.$(OBJEXT): DOH/$(am__dirstamp) DOH/$(DEPDIR)/$(am__dirstamp) DOH/hash.$(OBJEXT): DOH/$(am__dirstamp) DOH/$(DEPDIR)/$(am__dirstamp) DOH/list.$(OBJEXT): DOH/$(am__dirstamp) DOH/$(DEPDIR)/$(am__dirstamp) DOH/memory.$(OBJEXT): DOH/$(am__dirstamp) \ DOH/$(DEPDIR)/$(am__dirstamp) DOH/string.$(OBJEXT): DOH/$(am__dirstamp) \ DOH/$(DEPDIR)/$(am__dirstamp) DOH/void.$(OBJEXT): DOH/$(am__dirstamp) DOH/$(DEPDIR)/$(am__dirstamp) Modules/$(am__dirstamp): @$(MKDIR_P) Modules @: > Modules/$(am__dirstamp) Modules/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) Modules/$(DEPDIR) @: > Modules/$(DEPDIR)/$(am__dirstamp) Modules/allegrocl.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/allocate.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/browser.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/cffi.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/chicken.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/clisp.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/contract.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/csharp.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/d.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/directors.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/emit.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/go.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/guile.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/java.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/javascript.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/lang.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/lua.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/main.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/modula3.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/module.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/mzscheme.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/nested.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/ocaml.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/octave.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/overload.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/perl5.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/php.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/pike.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/python.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/r.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/ruby.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/s-exp.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/swigmain.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/tcl8.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/typepass.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/uffi.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/utils.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Modules/xml.$(OBJEXT): Modules/$(am__dirstamp) \ Modules/$(DEPDIR)/$(am__dirstamp) Preprocessor/$(am__dirstamp): @$(MKDIR_P) Preprocessor @: > Preprocessor/$(am__dirstamp) Preprocessor/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) Preprocessor/$(DEPDIR) @: > Preprocessor/$(DEPDIR)/$(am__dirstamp) Preprocessor/cpp.$(OBJEXT): Preprocessor/$(am__dirstamp) \ Preprocessor/$(DEPDIR)/$(am__dirstamp) Preprocessor/expr.$(OBJEXT): Preprocessor/$(am__dirstamp) \ Preprocessor/$(DEPDIR)/$(am__dirstamp) Swig/$(am__dirstamp): @$(MKDIR_P) Swig @: > Swig/$(am__dirstamp) Swig/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) Swig/$(DEPDIR) @: > Swig/$(DEPDIR)/$(am__dirstamp) Swig/cwrap.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/deprecate.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/error.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/extend.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/fragment.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/getopt.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/include.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/misc.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/naming.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/parms.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/scanner.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/stype.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/symbol.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/tree.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/typeobj.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/typemap.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/typesys.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) Swig/wrapfunc.$(OBJEXT): Swig/$(am__dirstamp) \ Swig/$(DEPDIR)/$(am__dirstamp) eswig$(EXEEXT): $(eswig_OBJECTS) $(eswig_DEPENDENCIES) $(EXTRA_eswig_DEPENDENCIES) @rm -f eswig$(EXEEXT) $(CXXLINK) $(eswig_OBJECTS) $(eswig_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f CParse/cscanner.$(OBJEXT) -rm -f CParse/parser.$(OBJEXT) -rm -f CParse/templ.$(OBJEXT) -rm -f CParse/util.$(OBJEXT) -rm -f DOH/base.$(OBJEXT) -rm -f DOH/file.$(OBJEXT) -rm -f DOH/fio.$(OBJEXT) -rm -f DOH/hash.$(OBJEXT) -rm -f DOH/list.$(OBJEXT) -rm -f DOH/memory.$(OBJEXT) -rm -f DOH/string.$(OBJEXT) -rm -f DOH/void.$(OBJEXT) -rm -f Modules/allegrocl.$(OBJEXT) -rm -f Modules/allocate.$(OBJEXT) -rm -f Modules/browser.$(OBJEXT) -rm -f Modules/cffi.$(OBJEXT) -rm -f Modules/chicken.$(OBJEXT) -rm -f Modules/clisp.$(OBJEXT) -rm -f Modules/contract.$(OBJEXT) -rm -f Modules/csharp.$(OBJEXT) -rm -f Modules/d.$(OBJEXT) -rm -f Modules/directors.$(OBJEXT) -rm -f Modules/emit.$(OBJEXT) -rm -f Modules/go.$(OBJEXT) -rm -f Modules/guile.$(OBJEXT) -rm -f Modules/java.$(OBJEXT) -rm -f Modules/javascript.$(OBJEXT) -rm -f Modules/lang.$(OBJEXT) -rm -f Modules/lua.$(OBJEXT) -rm -f Modules/main.$(OBJEXT) -rm -f Modules/modula3.$(OBJEXT) -rm -f Modules/module.$(OBJEXT) -rm -f Modules/mzscheme.$(OBJEXT) -rm -f Modules/nested.$(OBJEXT) -rm -f Modules/ocaml.$(OBJEXT) -rm -f Modules/octave.$(OBJEXT) -rm -f Modules/overload.$(OBJEXT) -rm -f Modules/perl5.$(OBJEXT) -rm -f Modules/php.$(OBJEXT) -rm -f Modules/pike.$(OBJEXT) -rm -f Modules/python.$(OBJEXT) -rm -f Modules/r.$(OBJEXT) -rm -f Modules/ruby.$(OBJEXT) -rm -f Modules/s-exp.$(OBJEXT) -rm -f Modules/swigmain.$(OBJEXT) -rm -f Modules/tcl8.$(OBJEXT) -rm -f Modules/typepass.$(OBJEXT) -rm -f Modules/uffi.$(OBJEXT) -rm -f Modules/utils.$(OBJEXT) -rm -f Modules/xml.$(OBJEXT) -rm -f Preprocessor/cpp.$(OBJEXT) -rm -f Preprocessor/expr.$(OBJEXT) -rm -f Swig/cwrap.$(OBJEXT) -rm -f Swig/deprecate.$(OBJEXT) -rm -f Swig/error.$(OBJEXT) -rm -f Swig/extend.$(OBJEXT) -rm -f Swig/fragment.$(OBJEXT) -rm -f Swig/getopt.$(OBJEXT) -rm -f Swig/include.$(OBJEXT) -rm -f Swig/misc.$(OBJEXT) -rm -f Swig/naming.$(OBJEXT) -rm -f Swig/parms.$(OBJEXT) -rm -f Swig/scanner.$(OBJEXT) -rm -f Swig/stype.$(OBJEXT) -rm -f Swig/symbol.$(OBJEXT) -rm -f Swig/tree.$(OBJEXT) -rm -f Swig/typemap.$(OBJEXT) -rm -f Swig/typeobj.$(OBJEXT) -rm -f Swig/typesys.$(OBJEXT) -rm -f Swig/wrapfunc.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@CParse/$(DEPDIR)/cscanner.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@CParse/$(DEPDIR)/parser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@CParse/$(DEPDIR)/templ.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@CParse/$(DEPDIR)/util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@DOH/$(DEPDIR)/base.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@DOH/$(DEPDIR)/file.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@DOH/$(DEPDIR)/fio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@DOH/$(DEPDIR)/hash.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@DOH/$(DEPDIR)/list.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@DOH/$(DEPDIR)/memory.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@DOH/$(DEPDIR)/string.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@DOH/$(DEPDIR)/void.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/allegrocl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/allocate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/browser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/cffi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/chicken.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/clisp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/contract.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/csharp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/d.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/directors.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/emit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/go.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/guile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/java.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/javascript.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/lang.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/lua.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/modula3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/module.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/mzscheme.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/nested.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/ocaml.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/octave.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/overload.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/perl5.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/php.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/pike.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/python.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/ruby.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/s-exp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/swigmain.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/tcl8.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/typepass.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/uffi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/utils.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Modules/$(DEPDIR)/xml.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Preprocessor/$(DEPDIR)/cpp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Preprocessor/$(DEPDIR)/expr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/cwrap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/deprecate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/extend.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/fragment.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/getopt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/include.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/misc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/naming.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/parms.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/scanner.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/stype.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/symbol.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/tree.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/typemap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/typeobj.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/typesys.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Swig/$(DEPDIR)/wrapfunc.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cxx.o: @am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cxx.obj: @am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .y.c: $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(PROGRAMS) all-local installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f CParse/$(DEPDIR)/$(am__dirstamp) -rm -f CParse/$(am__dirstamp) -rm -f DOH/$(DEPDIR)/$(am__dirstamp) -rm -f DOH/$(am__dirstamp) -rm -f Modules/$(DEPDIR)/$(am__dirstamp) -rm -f Modules/$(am__dirstamp) -rm -f Preprocessor/$(DEPDIR)/$(am__dirstamp) -rm -f Preprocessor/$(am__dirstamp) -rm -f Swig/$(DEPDIR)/$(am__dirstamp) -rm -f Swig/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -rm -f CParse/parser.c -rm -f CParse/parser.h -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-local mostlyclean-am distclean: distclean-am -rm -rf CParse/$(DEPDIR) DOH/$(DEPDIR) Modules/$(DEPDIR) Preprocessor/$(DEPDIR) Swig/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-local distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf CParse/$(DEPDIR) DOH/$(DEPDIR) Modules/$(DEPDIR) Preprocessor/$(DEPDIR) Swig/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS all all-am all-local check check-am clean \ clean-binPROGRAMS clean-generic clean-local ctags distclean \ distclean-compile distclean-generic distclean-local \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-binPROGRAMS install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # The executable is copied to the root directory for installation and running the test-suite. # This occurs on each invocation of make and is a step towards providing support for multiple # build directories. all-local: eswig@EXEEXT@ cp -f $(top_builddir)/Source/eswig@EXEEXT@ $(top_builddir)/swig@EXEEXT@ clean-local: rm -f $(top_builddir)/swig@EXEEXT@ rm -f core @EXTRA_CLEAN@ distclean-local: rm -f $(top_builddir)/Source/Include/swigconfig.h rm -f $(top_builddir)/Source/Include/stamp-h1 beautify: rm -rf $(INDENTBAKSDIR) mkdir $(INDENTBAKSDIR) mkdir $(INDENTBAKSDIR)/CParse mkdir $(INDENTBAKSDIR)/DOH mkdir $(INDENTBAKSDIR)/Modules mkdir $(INDENTBAKSDIR)/Preprocessor mkdir $(INDENTBAKSDIR)/Swig mkdir $(INDENTBAKSDIR)/Include (csources=`find . -name "*.c"` && \ hsources=`find . -name "*.h"` && \ cxxsources=`find . -name "*.cxx"` && \ for file in $$csources $$hsources $$cxxsources; do \ $(MAKE) beautify-file INDENTFILE=$$file; \ done; ) beautify-file: test -e $(INDENTBAKSDIR) || (echo $(INDENTBAKSDIR) directory does not exist && exit 1;) test -n "$(INDENTFILE)" || (echo INDENTFILE not defined && exit 1;) test -e $(INDENTFILE) || (echo File does not exist: $(INDENTFILE) && exit 1;) cp $(INDENTFILE) $(INDENTBAKSDIR)/$(INDENTFILE); indent -kr --honour-newlines --line-length160 --indent-level2 --braces-on-func-def-line --leave-optional-blank-lines $(SWIGTYPEDEFS) $(INDENTFILE) -o $(INDENTFILE).tmp; cat $(INDENTFILE).tmp | sed -e 's/const const /const /' > $(INDENTFILE); rm $(INDENTFILE).tmp; # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: swig-3.0.2/Source/Makefile.am0000664000175000017500000001121412343605122015636 0ustar williamwilliam## Process this file with automake to produce Makefile.in # subdir-objects generates object files using the directory structure of the source files. AUTOMAKE_OPTIONS = foreign nostdinc subdir-objects 1.7.2 SOURCE_DIR=$(top_srcdir)/Source BUILD_SOURCE_DIR=$(top_builddir)/Source SWIG_CXX_DEFS = @SWILL@ AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ -I$(BUILD_SOURCE_DIR)/CParse \ -I$(SOURCE_DIR)/Include \ -I$(SOURCE_DIR)/DOH \ -I$(SOURCE_DIR)/CParse \ -I$(SOURCE_DIR)/Preprocessor \ -I$(SOURCE_DIR)/Swig \ -I$(SOURCE_DIR)/Modules AM_CXXFLAGS = $(SWIG_CXX_DEFS) AM_YFLAGS = -d BUILT_SOURCES = CParse/parser.h eswig_SOURCES = CParse/cscanner.c \ CParse/parser.y \ CParse/templ.c \ CParse/util.c \ DOH/base.c \ DOH/file.c \ DOH/fio.c \ DOH/hash.c \ DOH/list.c \ DOH/memory.c \ DOH/string.c \ DOH/void.c \ Modules/allegrocl.cxx \ Modules/allocate.cxx \ Modules/browser.cxx \ Modules/cffi.cxx \ Modules/chicken.cxx \ Modules/clisp.cxx \ Modules/contract.cxx \ Modules/csharp.cxx \ Modules/d.cxx \ Modules/directors.cxx \ Modules/emit.cxx \ Modules/go.cxx \ Modules/guile.cxx \ Modules/java.cxx \ Modules/javascript.cxx \ Modules/lang.cxx \ Modules/lua.cxx \ Modules/main.cxx \ Modules/modula3.cxx \ Modules/module.cxx \ Modules/mzscheme.cxx \ Modules/nested.cxx \ Modules/ocaml.cxx \ Modules/octave.cxx \ Modules/overload.cxx \ Modules/perl5.cxx \ Modules/php.cxx \ Modules/pike.cxx \ Modules/python.cxx \ Modules/r.cxx \ Modules/ruby.cxx \ Modules/s-exp.cxx \ Modules/swigmain.cxx \ Modules/tcl8.cxx \ Modules/typepass.cxx \ Modules/uffi.cxx \ Modules/utils.cxx \ Modules/xml.cxx \ Preprocessor/cpp.c \ Preprocessor/expr.c \ Swig/cwrap.c \ Swig/deprecate.c \ Swig/error.c \ Swig/extend.c \ Swig/fragment.c \ Swig/getopt.c \ Swig/include.c \ Swig/misc.c \ Swig/naming.c \ Swig/parms.c \ Swig/scanner.c \ Swig/stype.c \ Swig/symbol.c \ Swig/tree.c \ Swig/typeobj.c \ Swig/typemap.c \ Swig/typesys.c \ Swig/wrapfunc.c bin_PROGRAMS = eswig eswig_LDADD = @SWIGLIBS@ # Override the link stage to avoid using Libtool CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ # The executable is copied to the root directory for installation and running the test-suite. # This occurs on each invocation of make and is a step towards providing support for multiple # build directories. all-local: eswig@EXEEXT@ cp -f $(top_builddir)/Source/eswig@EXEEXT@ $(top_builddir)/swig@EXEEXT@ clean-local: rm -f $(top_builddir)/swig@EXEEXT@ rm -f core @EXTRA_CLEAN@ distclean-local: rm -f $(top_builddir)/Source/Include/swigconfig.h rm -f $(top_builddir)/Source/Include/stamp-h1 # Beautify the code. # Note that this works well on C code, but does some odd joining of lines for C++ code. # Compiling with -DNDEBUG and no optimisations will allow one to do a binary diff of the # swig executable as a way of checking before and after the 'beautifying'. # Single files can be beautified with the beautify-file target, eg: 'make beautify-file INDENTFILE=chosenfile.c' SWIGTYPEDEFS=-T bool -T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T Scanner -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHObj_or_char -T DOHFile -T DOHString -T DOHString_or_char -T UpcallData INDENTBAKSDIR=../IndentBaks beautify: rm -rf $(INDENTBAKSDIR) mkdir $(INDENTBAKSDIR) mkdir $(INDENTBAKSDIR)/CParse mkdir $(INDENTBAKSDIR)/DOH mkdir $(INDENTBAKSDIR)/Modules mkdir $(INDENTBAKSDIR)/Preprocessor mkdir $(INDENTBAKSDIR)/Swig mkdir $(INDENTBAKSDIR)/Include (csources=`find . -name "*.c"` && \ hsources=`find . -name "*.h"` && \ cxxsources=`find . -name "*.cxx"` && \ for file in $$csources $$hsources $$cxxsources; do \ $(MAKE) beautify-file INDENTFILE=$$file; \ done; ) beautify-file: test -e $(INDENTBAKSDIR) || (echo $(INDENTBAKSDIR) directory does not exist && exit 1;) test -n "$(INDENTFILE)" || (echo INDENTFILE not defined && exit 1;) test -e $(INDENTFILE) || (echo File does not exist: $(INDENTFILE) && exit 1;) cp $(INDENTFILE) $(INDENTBAKSDIR)/$(INDENTFILE); indent -kr --honour-newlines --line-length160 --indent-level2 --braces-on-func-def-line --leave-optional-blank-lines $(SWIGTYPEDEFS) $(INDENTFILE) -o $(INDENTFILE).tmp; cat $(INDENTFILE).tmp | sed -e 's/const const /const /' > $(INDENTFILE); rm $(INDENTFILE).tmp; swig-3.0.2/Source/Swig/0000775000175000017500000000000012343605122014514 5ustar williamwilliamswig-3.0.2/Source/Swig/misc.c0000664000175000017500000011103312343605122015612 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * misc.c * * Miscellaneous functions that don't really fit anywhere else. * ----------------------------------------------------------------------------- */ #include "swig.h" #include #include #include #include #include #ifdef _WIN32 #include #ifndef S_ISDIR #define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR) #endif #endif static char *fake_version = 0; /* ----------------------------------------------------------------------------- * Swig_copy_string() * * Duplicate a NULL-terminate string given as a char *. * ----------------------------------------------------------------------------- */ char *Swig_copy_string(const char *s) { char *c = 0; if (s) { c = (char *) malloc(strlen(s) + 1); strcpy(c, s); } return c; } /* ----------------------------------------------------------------------------- * Swig_set_fakeversion() * * Version string override * ----------------------------------------------------------------------------- */ void Swig_set_fakeversion(const char *version) { fake_version = Swig_copy_string(version); } /* ----------------------------------------------------------------------------- * Swig_package_version() * * Return the package string containing the version number * ----------------------------------------------------------------------------- */ const char *Swig_package_version(void) { return fake_version ? fake_version : PACKAGE_VERSION; } /* ----------------------------------------------------------------------------- * Swig_banner() * * Emits the SWIG identifying banner for the C/C++ wrapper file. * ----------------------------------------------------------------------------- */ void Swig_banner(File *f) { Printf(f, "/* ----------------------------------------------------------------------------\n\ * This file was automatically generated by SWIG (http://www.swig.org).\n\ * Version %s\n\ *\n\ * This file is not intended to be easily readable and contains a number of\n\ * coding conventions designed to improve portability and efficiency. Do not make\n\ * changes to this file unless you know what you are doing--modify the SWIG\n\ * interface file instead.\n", Swig_package_version()); /* String too long for ISO compliance */ Printf(f, " * ----------------------------------------------------------------------------- */\n"); } /* ----------------------------------------------------------------------------- * Swig_banner_target_lang() * * Emits a SWIG identifying banner in the target language * ----------------------------------------------------------------------------- */ void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar) { Printf(f, "%s This file was automatically generated by SWIG (http://www.swig.org).\n", commentchar); Printf(f, "%s Version %s\n", commentchar, Swig_package_version()); Printf(f, "%s\n", commentchar); Printf(f, "%s Do not make changes to this file unless you know what you are doing--modify\n", commentchar); Printf(f, "%s the SWIG interface file instead.\n", commentchar); } /* ----------------------------------------------------------------------------- * Swig_strip_c_comments() * * Return a new string with C comments stripped from the input string. NULL is * returned if there aren't any comments. * ----------------------------------------------------------------------------- */ String *Swig_strip_c_comments(const String *s) { const char *c = Char(s); const char *comment_begin = 0; const char *comment_end = 0; String *stripped = 0; while (*c) { if (!comment_begin && *c == '/') { ++c; if (!*c) break; if (*c == '*') comment_begin = c-1; } else if (comment_begin && !comment_end && *c == '*') { ++c; if (*c == '/') { comment_end = c; break; } } ++c; } if (comment_begin && comment_end) { int size = comment_begin - Char(s); String *stripmore = 0; stripped = NewStringWithSize(s, size); Printv(stripped, comment_end + 1, NIL); do { stripmore = Swig_strip_c_comments(stripped); if (stripmore) { Delete(stripped); stripped = stripmore; } } while (stripmore); } return stripped; } /* ----------------------------------------------------------------------------- * is_directory() * ----------------------------------------------------------------------------- */ static int is_directory(String *directory) { int last = Len(directory) - 1; int statres; struct stat st; char *dir = Char(directory); if (dir[last] == SWIG_FILE_DELIMITER[0]) { /* remove trailing slash - can cause S_ISDIR to fail on Windows, at least */ dir[last] = 0; statres = stat(dir, &st); dir[last] = SWIG_FILE_DELIMITER[0]; } else { statres = stat(dir, &st); } return (statres == 0 && S_ISDIR(st.st_mode)); } /* ----------------------------------------------------------------------------- * Swig_new_subdirectory() * * Create the subdirectory only if the basedirectory already exists as a directory. * basedirectory can be empty to indicate current directory but not NULL. * ----------------------------------------------------------------------------- */ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) { String *error = 0; int current_directory = Len(basedirectory) == 0; if (current_directory || is_directory(basedirectory)) { Iterator it; String *dir = NewString(basedirectory); List *subdirs = Split(subdirectory, SWIG_FILE_DELIMITER[0], INT_MAX); for (it = First(subdirs); it.item; it = Next(it)) { int result; String *subdirectory = it.item; Printf(dir, "%s", subdirectory); #ifdef _WIN32 result = _mkdir(Char(dir)); #else result = mkdir(Char(dir), 0777); #endif if (result != 0 && errno != EEXIST) { error = NewStringf("Cannot create directory %s: %s", dir, strerror(errno)); break; } if (!is_directory(dir)) { error = NewStringf("Cannot create directory %s: it may already exist but not be a directory", dir); break; } Printf(dir, SWIG_FILE_DELIMITER); } } else { error = NewStringf("Cannot create subdirectory %s under the base directory %s. Either the base does not exist as a directory or it is not readable.", subdirectory, basedirectory); } return error; } /* ----------------------------------------------------------------------------- * Swig_filename_correct() * * Corrects filename paths by removing duplicate delimiters and on non-unix * systems use the correct delimiter across the whole name. * ----------------------------------------------------------------------------- */ void Swig_filename_correct(String *filename) { int network_path = 0; if (Len(filename) >= 2) { const char *fname = Char(filename); if (fname[0] == '\\' && fname[1] == '\\') network_path = 1; if (fname[0] == '/' && fname[1] == '/') network_path = 1; } #if defined(_WIN32) || defined(MACSWIG) /* accept Unix path separator on non-Unix systems */ Replaceall(filename, "/", SWIG_FILE_DELIMITER); #endif #if defined(__CYGWIN__) /* accept Windows path separator in addition to Unix path separator */ Replaceall(filename, "\\", SWIG_FILE_DELIMITER); #endif /* remove all duplicate file name delimiters */ while (Replaceall(filename, SWIG_FILE_DELIMITER SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER)) { } /* Network paths can start with a double slash on Windows - unremove the duplicate slash we just removed */ if (network_path) Insert(filename, 0, SWIG_FILE_DELIMITER); } /* ----------------------------------------------------------------------------- * Swig_filename_escape() * * Escapes backslashes in filename - for Windows * ----------------------------------------------------------------------------- */ String *Swig_filename_escape(String *filename) { String *adjusted_filename = Copy(filename); Swig_filename_correct(adjusted_filename); #if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */ Replaceall(adjusted_filename, "\\", "\\\\"); #endif return adjusted_filename; } /* ----------------------------------------------------------------------------- * Swig_filename_unescape() * * Remove double backslash escaping in filename - for Windows * ----------------------------------------------------------------------------- */ void Swig_filename_unescape(String *filename) { (void)filename; #if defined(_WIN32) Replaceall(filename, "\\\\", "\\"); #endif } /* ----------------------------------------------------------------------------- * Swig_storage_isextern() * * Determine if the storage class specifier is extern (but not externc) * ----------------------------------------------------------------------------- */ int Swig_storage_isextern(Node *n) { const String *storage = Getattr(n, "storage"); return storage ? Strcmp(storage, "extern") == 0 || Strncmp(storage, "extern ", 7) == 0 : 0; } /* ----------------------------------------------------------------------------- * Swig_storage_isexternc() * * Determine if the storage class specifier is externc (but not plain extern) * ----------------------------------------------------------------------------- */ int Swig_storage_isexternc(Node *n) { const String *storage = Getattr(n, "storage"); return storage ? Strcmp(storage, "externc") == 0 || Strncmp(storage, "externc ", 8) == 0 : 0; } /* ----------------------------------------------------------------------------- * Swig_storage_isstatic_custom() * * Determine if the storage class specifier is static * ----------------------------------------------------------------------------- */ int Swig_storage_isstatic_custom(Node *n, const_String_or_char_ptr storage_name) { const String *storage = Getattr(n, storage_name); return storage ? Strncmp(storage, "static", 6) == 0 : 0; } /* ----------------------------------------------------------------------------- * Swig_storage_isstatic() * * Determine if the storage class specifier is static * ----------------------------------------------------------------------------- */ int Swig_storage_isstatic(Node *n) { return Swig_storage_isstatic_custom(n, "storage"); } /* ----------------------------------------------------------------------------- * Swig_string_escape() * * Takes a string object and produces a string with escape codes added to it. * ----------------------------------------------------------------------------- */ String *Swig_string_escape(String *s) { String *ns; int c; ns = NewStringEmpty(); while ((c = Getc(s)) != EOF) { if (c == '\n') { Printf(ns, "\\n"); } else if (c == '\r') { Printf(ns, "\\r"); } else if (c == '\t') { Printf(ns, "\\t"); } else if (c == '\\') { Printf(ns, "\\\\"); } else if (c == '\'') { Printf(ns, "\\'"); } else if (c == '\"') { Printf(ns, "\\\""); } else if (c == ' ') { Putc(c, ns); } else if (!isgraph(c)) { if (c < 0) c += UCHAR_MAX + 1; Printf(ns, "\\%o", c); } else { Putc(c, ns); } } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_upper() * * Takes a string object and returns a copy that is uppercase * ----------------------------------------------------------------------------- */ String *Swig_string_upper(String *s) { String *ns; int c; ns = NewStringEmpty(); Seek(s, 0, SEEK_SET); while ((c = Getc(s)) != EOF) { Putc(toupper(c), ns); } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_lower() * * Takes a string object and returns a copy that is lowercase * ----------------------------------------------------------------------------- */ String *Swig_string_lower(String *s) { String *ns; int c; ns = NewStringEmpty(); Seek(s, 0, SEEK_SET); while ((c = Getc(s)) != EOF) { Putc(tolower(c), ns); } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_title() * * Takes a string object and returns a copy that is lowercase with first letter * capitalized * ----------------------------------------------------------------------------- */ String *Swig_string_title(String *s) { String *ns; int first = 1; int c; ns = NewStringEmpty(); Seek(s, 0, SEEK_SET); while ((c = Getc(s)) != EOF) { Putc(first ? toupper(c) : tolower(c), ns); first = 0; } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_ccase() * * Takes a string object and returns a copy that is lowercase with the first * letter capitalized and the one following '_', which are removed. * * camel_case -> CamelCase * camelCase -> CamelCase * ----------------------------------------------------------------------------- */ String *Swig_string_ccase(String *s) { String *ns; int first = 1; int c; ns = NewStringEmpty(); Seek(s, 0, SEEK_SET); while ((c = Getc(s)) != EOF) { if (c == '_') { first = 1; continue; } Putc(first ? toupper(c) : c, ns); first = 0; } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_lccase() * * Takes a string object and returns a copy with the character after * each '_' capitalised, and the '_' removed. The first character is * also forced to lowercase. * * camel_case -> camelCase * CamelCase -> camelCase * ----------------------------------------------------------------------------- */ String *Swig_string_lccase(String *s) { String *ns; int first = 1; int after_underscore = 0; int c; ns = NewStringEmpty(); Seek(s, 0, SEEK_SET); while ((c = Getc(s)) != EOF) { if (c == '_') { after_underscore = 1; continue; } if (first) { Putc(tolower(c), ns); first = 0; } else { Putc(after_underscore ? toupper(c) : c, ns); } after_underscore = 0; } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_ucase() * * This is the reverse case of ccase, ie * * CamelCase -> camel_case * get2D -> get_2d * asFloat2 -> as_float2 * ----------------------------------------------------------------------------- */ String *Swig_string_ucase(String *s) { String *ns; int c; int lastC = 0; int nextC = 0; int underscore = 0; ns = NewStringEmpty(); /* We insert a underscore when: 1. Lower case char followed by upper case char getFoo > get_foo; getFOo > get_foo; GETFOO > getfoo 2. Number proceded by char and not end of string get2D > get_2d; get22D > get_22d; GET2D > get_2d but: asFloat2 > as_float2 */ Seek(s, 0, SEEK_SET); while ((c = Getc(s)) != EOF) { nextC = Getc(s); Ungetc(nextC, s); if (isdigit(c) && isalpha(lastC) && nextC != EOF) underscore = 1; else if (isupper(c) && isalpha(lastC) && !isupper(lastC)) underscore = 1; lastC = c; if (underscore) { Putc('_', ns); underscore = 0; } Putc(tolower(c), ns); } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_first_upper() * * Make the first character in the string uppercase, leave all the * rest the same. This is used by the Ruby module to provide backwards * compatibility with the old way of naming classes and constants. For * more info see the Ruby documentation. * * firstUpper -> FirstUpper * ----------------------------------------------------------------------------- */ String *Swig_string_first_upper(String *s) { String *ns = NewStringEmpty(); char *cs = Char(s); if (cs && cs[0] != 0) { Putc(toupper((int)cs[0]), ns); Append(ns, cs + 1); } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_first_lower() * * Make the first character in the string lowercase, leave all the * rest the same. This is used by the Ruby module to provide backwards * compatibility with the old way of naming classes and constants. For * more info see the Ruby documentation. * * firstLower -> FirstLower * ----------------------------------------------------------------------------- */ String *Swig_string_first_lower(String *s) { String *ns = NewStringEmpty(); char *cs = Char(s); if (cs && cs[0] != 0) { Putc(tolower((int)cs[0]), ns); Append(ns, cs + 1); } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_schemify() * * Replace underscores with dashes, to make identifiers look nice to Schemers. * * under_scores -> under-scores * ----------------------------------------------------------------------------- */ String *Swig_string_schemify(String *s) { String *ns = NewString(s); Replaceall(ns, "_", "-"); return ns; } /* ----------------------------------------------------------------------------- * Swig_string_typecode() * * Takes a string with possible type-escapes in it and replaces them with * real C datatypes. * ----------------------------------------------------------------------------- */ String *Swig_string_typecode(String *s) { String *ns; int c; String *tc; ns = NewStringEmpty(); while ((c = Getc(s)) != EOF) { if (c == '`') { String *str = 0; tc = NewStringEmpty(); while ((c = Getc(s)) != EOF) { if (c == '`') break; Putc(c, tc); } str = SwigType_str(tc, 0); Append(ns, str); Delete(str); } else { Putc(c, ns); if (c == '\'') { while ((c = Getc(s)) != EOF) { Putc(c, ns); if (c == '\'') break; if (c == '\\') { c = Getc(s); Putc(c, ns); } } } else if (c == '\"') { while ((c = Getc(s)) != EOF) { Putc(c, ns); if (c == '\"') break; if (c == '\\') { c = Getc(s); Putc(c, ns); } } } } } return ns; } /* ----------------------------------------------------------------------------- * Swig_string_mangle() * * Take a string and mangle it by stripping all non-valid C identifier * characters. * * This routine skips unnecessary blank spaces, therefore mangling * 'char *' and 'char*', 'std::pair' and * 'std::pair', produce the same result. * * However, note that 'long long' and 'long_long' produce different * mangled strings. * * The mangling method still is not 'perfect', for example std::pair and * std_pair return the same mangling. This is just a little better * than before, but it seems to be enough for most of the purposes. * * Having a perfect mangling will break some examples and code which * assume, for example, that A::get_value will be mangled as * A_get_value. * ----------------------------------------------------------------------------- */ String *Swig_string_mangle(const String *s) { #if 0 /* old mangling, not suitable for using in macros */ String *t = Copy(s); char *c = Char(t); while (*c) { if (!isalnum(*c)) *c = '_'; c++; } return t; #else String *result = NewStringEmpty(); int space = 0; int state = 0; char *pc, *cb; String *b = Copy(s); if (SwigType_istemplate(b)) { String *st = Swig_symbol_template_deftype(b, 0); String *sq = Swig_symbol_type_qualify(st, 0); String *t = SwigType_namestr(sq); Delete(st); Delete(sq); Delete(b); b = t; } pc = cb = Char(b); while (*pc) { char c = *pc; if (isalnum((int) c) || (c == '_')) { state = 1; if (space && (space == state)) { Append(result, "_SS_"); } space = 0; Printf(result, "%c", (int) c); } else { if (isspace((int) c)) { space = state; ++pc; continue; } else { state = 3; space = 0; } switch (c) { case '.': if ((cb != pc) && (*(pc - 1) == 'p')) { Append(result, "_"); ++pc; continue; } else { c = 'f'; } break; case ':': if (*(pc + 1) == ':') { Append(result, "_"); ++pc; ++pc; continue; } break; case '*': c = 'm'; break; case '&': c = 'A'; break; case '<': c = 'l'; break; case '>': c = 'g'; break; case '=': c = 'e'; break; case ',': c = 'c'; break; case '(': c = 'p'; break; case ')': c = 'P'; break; case '[': c = 'b'; break; case ']': c = 'B'; break; case '^': c = 'x'; break; case '|': c = 'o'; break; case '~': c = 'n'; break; case '!': c = 'N'; break; case '%': c = 'M'; break; case '?': c = 'q'; break; case '+': c = 'a'; break; case '-': c = 's'; break; case '/': c = 'd'; break; default: break; } if (isalpha((int) c)) { Printf(result, "_S%c_", (int) c); } else { Printf(result, "_S%02X_", (int) c); } } ++pc; } Delete(b); return result; #endif } String *Swig_string_emangle(String *s) { return Swig_string_mangle(s); } /* ----------------------------------------------------------------------------- * Swig_scopename_prefix() * * Take a qualified name like "A::B::C" and return the scope name. * In this case, "A::B". Returns NULL if there is no base. * ----------------------------------------------------------------------------- */ void Swig_scopename_split(const String *s, String **rprefix, String **rlast) { char *tmp = Char(s); char *c = tmp; char *cc = c; char *co = 0; if (!strstr(c, "::")) { *rprefix = 0; *rlast = Copy(s); } co = strstr(cc, "operator "); if (co) { if (co == cc) { *rprefix = 0; *rlast = Copy(s); return; } else { *rprefix = NewStringWithSize(cc, co - cc - 2); *rlast = NewString(co); return; } } while (*c) { if ((*c == ':') && (*(c + 1) == ':')) { cc = c; c += 2; } else { if (*c == '<') { int level = 1; c++; while (*c && level) { if (*c == '<') level++; if (*c == '>') level--; c++; } } else { c++; } } } if (cc != tmp) { *rprefix = NewStringWithSize(tmp, cc - tmp); *rlast = NewString(cc + 2); return; } else { *rprefix = 0; *rlast = Copy(s); } } String *Swig_scopename_prefix(const String *s) { char *tmp = Char(s); char *c = tmp; char *cc = c; char *co = 0; if (!strstr(c, "::")) return 0; co = strstr(cc, "operator "); if (co) { if (co == cc) { return 0; } else { String *prefix = NewStringWithSize(cc, co - cc - 2); return prefix; } } while (*c) { if ((*c == ':') && (*(c + 1) == ':')) { cc = c; c += 2; } else { if (*c == '<') { int level = 1; c++; while (*c && level) { if (*c == '<') level++; if (*c == '>') level--; c++; } } else { c++; } } } if (cc != tmp) { return NewStringWithSize(tmp, cc - tmp); } else { return 0; } } /* ----------------------------------------------------------------------------- * Swig_scopename_last() * * Take a qualified name like "A::B::C" and returns the last. In this * case, "C". * ----------------------------------------------------------------------------- */ String *Swig_scopename_last(const String *s) { char *tmp = Char(s); char *c = tmp; char *cc = c; char *co = 0; if (!strstr(c, "::")) return NewString(s); co = strstr(cc, "operator "); if (co) { return NewString(co); } while (*c) { if ((*c == ':') && (*(c + 1) == ':')) { c += 2; cc = c; } else { if (*c == '<') { int level = 1; c++; while (*c && level) { if (*c == '<') level++; if (*c == '>') level--; c++; } } else { c++; } } } return NewString(cc); } /* ----------------------------------------------------------------------------- * Swig_scopename_first() * * Take a qualified name like "A::B::C" and returns the first scope name. * In this case, "A". Returns NULL if there is no base. * ----------------------------------------------------------------------------- */ String *Swig_scopename_first(const String *s) { char *tmp = Char(s); char *c = tmp; char *co = 0; if (!strstr(c, "::")) return 0; co = strstr(c, "operator "); if (co) { if (co == c) { return 0; } } else { co = c + Len(s); } while (*c && (c != co)) { if ((*c == ':') && (*(c + 1) == ':')) { break; } else { if (*c == '<') { int level = 1; c++; while (*c && level) { if (*c == '<') level++; if (*c == '>') level--; c++; } } else { c++; } } } if (*c && (c != tmp)) { return NewStringWithSize(tmp, c - tmp); } else { return 0; } } /* ----------------------------------------------------------------------------- * Swig_scopename_suffix() * * Take a qualified name like "A::B::C" and returns the suffix. * In this case, "B::C". Returns NULL if there is no suffix. * ----------------------------------------------------------------------------- */ String *Swig_scopename_suffix(const String *s) { char *tmp = Char(s); char *c = tmp; char *co = 0; if (!strstr(c, "::")) return 0; co = strstr(c, "operator "); if (co) { if (co == c) return 0; } while (*c) { if ((*c == ':') && (*(c + 1) == ':')) { break; } else { if (*c == '<') { int level = 1; c++; while (*c && level) { if (*c == '<') level++; if (*c == '>') level--; c++; } } else { c++; } } } if (*c && (c != tmp)) { return NewString(c + 2); } else { return 0; } } /* ----------------------------------------------------------------------------- * Swig_scopename_check() * * Checks to see if a name is qualified with a scope name, examples: * foo -> 0 * ::foo -> 1 * foo::bar -> 1 * foo< ::bar > -> 0 * ----------------------------------------------------------------------------- */ int Swig_scopename_check(const String *s) { char *c = Char(s); char *co = strstr(c, "operator "); if (co) { if (co == c) return 0; } if (!strstr(c, "::")) return 0; while (*c) { if ((*c == ':') && (*(c + 1) == ':')) { return 1; } else { if (*c == '<') { int level = 1; c++; while (*c && level) { if (*c == '<') level++; if (*c == '>') level--; c++; } } else { c++; } } } return 0; } /* ----------------------------------------------------------------------------- * Swig_string_command() * * Executes a external command via popen with the string as a command * line parameter. For example: * * Printf(stderr,"%(command:sed 's/[a-z]/\U\\1/' <<<)s","hello") -> Hello * ----------------------------------------------------------------------------- */ #if defined(HAVE_POPEN) # if defined(_MSC_VER) # define popen _popen # define pclose _pclose # else extern FILE *popen(const char *command, const char *type); extern int pclose(FILE *stream); # endif #else # if defined(_MSC_VER) # define HAVE_POPEN 1 # define popen _popen # define pclose _pclose # endif #endif String *Swig_string_command(String *s) { String *res = NewStringEmpty(); #if defined(HAVE_POPEN) if (Len(s)) { char *command = Char(s); FILE *fp = popen(command, "r"); if (fp) { char buffer[1025]; while (fscanf(fp, "%1024s", buffer) != EOF) { Append(res, buffer); } pclose(fp); } else { Swig_error("SWIG", Getline(s), "Command encoder fails attempting '%s'.\n", s); exit(1); } } #endif return res; } /* ----------------------------------------------------------------------------- * Swig_string_strip() * * Strip given prefix from identifiers * * Printf(stderr,"%(strip:[wx])s","wxHello") -> Hello * ----------------------------------------------------------------------------- */ String *Swig_string_strip(String *s) { String *ns; if (!Len(s)) { ns = NewString(s); } else { const char *cs = Char(s); const char *ce = Strchr(cs, ']'); if (*cs != '[' || !ce) { ns = NewString(s); } else { String *fmt = NewStringf("%%.%ds", ce-cs-1); String *prefix = NewStringf(fmt, cs+1); if (0 == Strncmp(ce+1, prefix, Len(prefix))) { ns = NewString(ce+1+Len(prefix)); } else { ns = NewString(ce+1); } } } return ns; } /* ----------------------------------------------------------------------------- * Swig_offset_string() * * Insert number tabs before each new line in s * ----------------------------------------------------------------------------- */ void Swig_offset_string(String *s, int number) { char *res, *p, *end, *start; /* count a number of lines in s */ int lines = 1; int len = Len(s); if (len == 0) return; start = strchr(Char(s), '\n'); while (start) { ++lines; start = strchr(start + 1, '\n'); } /* do not count pending new line */ if ((Char(s))[len-1] == '\n') --lines; /* allocate a temporary storage for a padded string */ res = (char*)malloc(len + lines * number * 2 + 1); res[len + lines * number * 2] = 0; /* copy lines to res, prepending tabs to each line */ p = res; /* output pointer */ start = Char(s); /* start of a current line */ end = strchr(start, '\n'); /* end of a current line */ while (end) { memset(p, ' ', number*2); p += number*2; memcpy(p, start, end - start + 1); p += end - start + 1; start = end + 1; end = strchr(start, '\n'); } /* process the last line */ if (*start) { memset(p, ' ', number*2); p += number*2; strcpy(p, start); } /* replace 's' contents with 'res' */ Clear(s); Append(s, res); free(res); } #ifdef HAVE_PCRE #include static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input) { const char *pats, *pate; const char *subs, *sube; /* Locate the search pattern */ const char *p = Char(s); if (*p++ != '/') goto err_out; pats = p; p = strchr(p, '/'); if (!p) goto err_out; pate = p; /* Locate the substitution string */ subs = ++p; p = strchr(p, '/'); if (!p) goto err_out; sube = p; *pattern = NewStringWithSize(pats, pate - pats); *subst = NewStringWithSize(subs, sube - subs); *input = p + 1; return 1; err_out: Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s); exit(1); } /* This function copies len characters from src to dst, possibly applying case conversions to them: if convertCase is 1, to upper case and if it is -1, to lower * case. If convertNextOnly is 1, only a single character is converted (and convertCase is reset), otherwise all of them are. */ static void copy_with_maybe_case_conversion(String *dst, const char *src, int len, int *convertCase, int convertNextOnly) { /* Deal with the trivial cases first. */ if (!len) return; if (!*convertCase) { Write(dst, src, len); return; } /* If we must convert only the first character, do it and write the rest at once. */ if (convertNextOnly) { int src_char = *src; Putc(*convertCase == 1 ? toupper(src_char) : tolower(src_char), dst); *convertCase = 0; if (len > 1) { Write(dst, src + 1, len - 1); } } else { /* We need to convert all characters. */ int i; for (i = 0; i < len; i++, src++) { int src_char = *src; Putc(*convertCase == 1 ? toupper(src_char) : tolower(src_char), dst); } } } String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s) { int convertCase = 0, convertNextOnly = 0; String *result = NewStringEmpty(); const char *p = Char(subst); while (*p) { /* Copy part without substitutions */ const char *q = strchr(p, '\\'); if (!q) { copy_with_maybe_case_conversion(result, p, strlen(p), &convertCase, convertNextOnly); break; } copy_with_maybe_case_conversion(result, p, q - p, &convertCase, convertNextOnly); p = q + 1; /* Handle substitution */ if (*p == '\0') { Putc('\\', result); } else if (isdigit((unsigned char)*p)) { int group = *p++ - '0'; if (group < num_captures) { int l = captures[group*2], r = captures[group*2 + 1]; if (l != -1) { copy_with_maybe_case_conversion(result, input + l, r - l, &convertCase, convertNextOnly); } } else { Swig_error("SWIG", Getline(s), "PCRE capture replacement failed while matching \"%s\" using \"%s\" - request for group %d is greater than the number of captures %d.\n", Char(pattern), input, group, num_captures-1); } } else { /* Handle Perl-like case conversion escapes. */ switch (*p) { case 'u': convertCase = 1; convertNextOnly = 1; break; case 'U': convertCase = 1; convertNextOnly = 0; break; case 'l': convertCase = -1; convertNextOnly = 1; break; case 'L': convertCase = -1; convertNextOnly = 0; break; case 'E': convertCase = 0; break; default: Swig_error("SWIG", Getline(s), "Unrecognized escape character '%c' in the replacement string \"%s\".\n", *p, Char(subst)); } p++; } } return result; } /* ----------------------------------------------------------------------------- * Swig_string_regex() * * Executes a regular expression substitution. For example: * * Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello * ----------------------------------------------------------------------------- */ String *Swig_string_regex(String *s) { const int pcre_options = 0; String *res = 0; pcre *compiled_pat = 0; const char *pcre_error, *input; int pcre_errorpos; String *pattern = 0, *subst = 0; int captures[30]; if (split_regex_pattern_subst(s, &pattern, &subst, &input)) { int rc; compiled_pat = pcre_compile( Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL); if (!compiled_pat) { Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n", pcre_error, Char(pattern), pcre_errorpos); exit(1); } rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30); if (rc >= 0) { res = replace_captures(rc, input, subst, captures, pattern, s); } else if (rc != PCRE_ERROR_NOMATCH) { Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n", rc, Char(pattern), input); exit(1); } } DohDelete(pattern); DohDelete(subst); pcre_free(compiled_pat); return res ? res : NewStringEmpty(); } String *Swig_pcre_version(void) { return NewStringf("PCRE Version: %s", pcre_version()); } #else String *Swig_string_regex(String *s) { Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n"); exit(1); } String *Swig_pcre_version(void) { return NewStringf("PCRE not used"); } #endif /* ----------------------------------------------------------------------------- * Swig_init() * * Initialize the SWIG core * ----------------------------------------------------------------------------- */ void Swig_init() { /* Set some useful string encoding methods */ DohEncoding("escape", Swig_string_escape); DohEncoding("upper", Swig_string_upper); DohEncoding("lower", Swig_string_lower); DohEncoding("title", Swig_string_title); DohEncoding("ctitle", Swig_string_ccase); DohEncoding("lctitle", Swig_string_lccase); DohEncoding("utitle", Swig_string_ucase); DohEncoding("typecode", Swig_string_typecode); DohEncoding("mangle", Swig_string_emangle); DohEncoding("command", Swig_string_command); DohEncoding("schemify", Swig_string_schemify); DohEncoding("strip", Swig_string_strip); DohEncoding("regex", Swig_string_regex); /* aliases for the case encoders */ DohEncoding("uppercase", Swig_string_upper); DohEncoding("lowercase", Swig_string_lower); DohEncoding("camelcase", Swig_string_ccase); DohEncoding("lowercamelcase", Swig_string_lccase); DohEncoding("undercase", Swig_string_ucase); DohEncoding("firstuppercase", Swig_string_first_upper); DohEncoding("firstlowercase", Swig_string_first_lower); /* Initialize typemaps */ Swig_typemap_init(); /* Initialize symbol table */ Swig_symbol_init(); /* Initialize type system */ SwigType_typesystem_init(); /* Initialize template system */ SwigType_template_init(); } swig-3.0.2/Source/Swig/fragment.c0000664000175000017500000001273012343605122016466 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * fragment.c * * This file manages named code fragments. Code fragments are typically * used to hold helper-code that may or may not be included in the wrapper * file (depending on what features are actually used in the interface). * * By using fragments, it's possible to greatly reduce the amount of * wrapper code and to generate cleaner wrapper files. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "swigwarn.h" #include "cparse.h" static Hash *fragments = 0; static Hash *looking_fragments = 0; static int debug = 0; /* ----------------------------------------------------------------------------- * Swig_fragment_register() * * Add a fragment. Use the original Node*, so, if something needs to be * changed, lang.cxx doesn't nedd to be touched again. * ----------------------------------------------------------------------------- */ void Swig_fragment_register(Node *fragment) { if (Getattr(fragment, "emitonly")) { Swig_fragment_emit(fragment); return; } else { String *name = Copy(Getattr(fragment, "value")); String *type = Getattr(fragment, "type"); if (type) { SwigType *rtype = SwigType_typedef_resolve_all(type); String *mangle = Swig_string_mangle(type); Append(name, mangle); Delete(mangle); Delete(rtype); if (debug) Printf(stdout, "register fragment %s %s\n", name, type); } if (!fragments) { fragments = NewHash(); } if (!Getattr(fragments, name)) { String *section = Copy(Getattr(fragment, "section")); String *ccode = Copy(Getattr(fragment, "code")); Hash *kwargs = Getattr(fragment, "kwargs"); Setmeta(ccode, "section", section); if (kwargs) { Setmeta(ccode, "kwargs", kwargs); } Setfile(ccode, Getfile(fragment)); Setline(ccode, Getline(fragment)); /* Replace $descriptor() macros */ Swig_cparse_replace_descriptor(ccode); Setattr(fragments, name, ccode); if (debug) Printf(stdout, "registering fragment %s %s\n", name, section); Delete(section); Delete(ccode); } Delete(name); } } /* ----------------------------------------------------------------------------- * Swig_fragment_emit() * * Emit a fragment * ----------------------------------------------------------------------------- */ static char *char_index(char *str, char c) { while (*str && (c != *str)) ++str; return (c == *str) ? str : 0; } void Swig_fragment_emit(Node *n) { String *code; char *pc, *tok; String *t; String *mangle = 0; String *name = 0; String *type = 0; name = Getattr(n, "value"); if (!name) { name = n; } if (!fragments) { Swig_warning(WARN_FRAGMENT_NOT_FOUND, Getfile(n), Getline(n), "Fragment '%s' not found.\n", name); return; } type = Getattr(n, "type"); if (type) { mangle = Swig_string_mangle(type); } if (debug) Printf(stdout, "looking fragment %s %s\n", name, type); t = Copy(name); tok = Char(t); pc = char_index(tok, ','); if (pc) *pc = 0; while (tok) { String *name = NewString(tok); if (mangle) Append(name, mangle); if (looking_fragments && Getattr(looking_fragments, name)) { return; } code = Getattr(fragments, name); if (debug) Printf(stdout, "looking subfragment %s\n", name); if (code && (Strcmp(code, "ignore") != 0)) { String *section = Getmeta(code, "section"); Hash *nn = Getmeta(code, "kwargs"); if (!looking_fragments) looking_fragments = NewHash(); Setattr(looking_fragments, name, "1"); while (nn) { if (Equal(Getattr(nn, "name"), "fragment")) { if (debug) Printf(stdout, "emitting fragment %s %s\n", nn, type); Setfile(nn, Getfile(n)); Setline(nn, Getline(n)); Swig_fragment_emit(nn); } nn = nextSibling(nn); } if (section) { File *f = Swig_filebyname(section); if (!f) { Swig_error(Getfile(code), Getline(code), "Bad section '%s' in %%fragment declaration for code fragment '%s'\n", section, name); } else { if (debug) Printf(stdout, "emitting subfragment %s %s\n", name, section); if (debug) Printf(f, "/* begin fragment %s */\n", name); Printf(f, "%s\n", code); if (debug) Printf(f, "/* end fragment %s */\n\n", name); Setattr(fragments, name, "ignore"); Delattr(looking_fragments, name); } } } else if (!code && type) { SwigType *rtype = SwigType_typedef_resolve_all(type); if (!Equal(type, rtype)) { String *name = Copy(Getattr(n, "value")); String *mangle = Swig_string_mangle(type); Append(name, mangle); Setfile(name, Getfile(n)); Setline(name, Getline(n)); Swig_fragment_emit(name); Delete(mangle); Delete(name); } Delete(rtype); } if (!code) { Swig_warning(WARN_FRAGMENT_NOT_FOUND, Getfile(n), Getline(n), "Fragment '%s' not found.\n", name); } tok = pc ? pc + 1 : 0; if (tok) { pc = char_index(tok, ','); if (pc) *pc = 0; } Delete(name); } Delete(t); } swig-3.0.2/Source/Swig/scanner.c0000664000175000017500000012500012343605122016307 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * scanner.c * * This file implements a general purpose C/C++ compatible lexical scanner. * This scanner isn't intended to be plugged directly into a parser built * with yacc. Rather, it contains a lot of generic code that could be used * to easily construct yacc-compatible scanners. * ----------------------------------------------------------------------------- */ #include "swig.h" #include extern String *cparse_file; extern int cparse_line; extern int cparse_cplusplus; extern int cparse_start_line; struct Scanner { String *text; /* Current token value */ List *scanobjs; /* Objects being scanned */ String *str; /* Current object being scanned */ char *idstart; /* Optional identifier start characters */ int nexttoken; /* Next token to be returned */ int start_line; /* Starting line of certain declarations */ int line; int yylen; /* Length of text pushed into text */ String *file; String *error; /* Last error message (if any) */ int error_line; /* Error line number */ int freeze_line; /* Suspend line number updates */ List *brackets; /* Current level of < > brackets on each level */ }; typedef struct Locator { String *filename; int line_number; struct Locator *next; } Locator; static int follow_locators = 0; static void brackets_push(Scanner *); static void brackets_clear(Scanner *); /* ----------------------------------------------------------------------------- * NewScanner() * * Create a new scanner object * ----------------------------------------------------------------------------- */ Scanner *NewScanner(void) { Scanner *s; s = (Scanner *) malloc(sizeof(Scanner)); s->line = 1; s->file = 0; s->nexttoken = -1; s->start_line = 1; s->yylen = 0; s->idstart = NULL; s->scanobjs = NewList(); s->text = NewStringEmpty(); s->str = 0; s->error = 0; s->error_line = 0; s->freeze_line = 0; s->brackets = NewList(); brackets_push(s); return s; } /* ----------------------------------------------------------------------------- * DelScanner() * * Delete a scanner object. * ----------------------------------------------------------------------------- */ void DelScanner(Scanner *s) { assert(s); Delete(s->scanobjs); Delete(s->brackets); Delete(s->text); Delete(s->file); Delete(s->error); Delete(s->str); free(s->idstart); free(s); } /* ----------------------------------------------------------------------------- * Scanner_clear() * * Clear the contents of a scanner object. * ----------------------------------------------------------------------------- */ void Scanner_clear(Scanner *s) { assert(s); Delete(s->str); Clear(s->text); Clear(s->scanobjs); brackets_clear(s); Delete(s->error); s->str = 0; s->error = 0; s->line = 1; s->nexttoken = -1; s->start_line = 0; s->yylen = 0; /* Should these be cleared too? s->idstart; s->file; s->error_line; s->freeze_line; */ } /* ----------------------------------------------------------------------------- * Scanner_push() * * Push some new text into the scanner. The scanner will start parsing this text * immediately before returning to the old text. * ----------------------------------------------------------------------------- */ void Scanner_push(Scanner *s, String *txt) { assert(s && txt); Push(s->scanobjs, txt); if (s->str) { Setline(s->str,s->line); Delete(s->str); } s->str = txt; DohIncref(s->str); s->line = Getline(txt); } /* ----------------------------------------------------------------------------- * Scanner_pushtoken() * * Push a token into the scanner. This token will be returned on the next * call to Scanner_token(). * ----------------------------------------------------------------------------- */ void Scanner_pushtoken(Scanner *s, int nt, const_String_or_char_ptr val) { assert(s); assert((nt >= 0) && (nt < SWIG_MAXTOKENS)); s->nexttoken = nt; if ( Char(val) != Char(s->text) ) { Clear(s->text); Append(s->text,val); } } /* ----------------------------------------------------------------------------- * Scanner_set_location() * * Set the file and line number location of the scanner. * ----------------------------------------------------------------------------- */ void Scanner_set_location(Scanner *s, String *file, int line) { Setline(s->str, line); Setfile(s->str, file); s->line = line; } /* ----------------------------------------------------------------------------- * Scanner_file() * * Get the current file. * ----------------------------------------------------------------------------- */ String *Scanner_file(Scanner *s) { return Getfile(s->str); } /* ----------------------------------------------------------------------------- * Scanner_line() * * Get the current line number * ----------------------------------------------------------------------------- */ int Scanner_line(Scanner *s) { return s->line; } /* ----------------------------------------------------------------------------- * Scanner_start_line() * * Get the line number on which the current token starts * ----------------------------------------------------------------------------- */ int Scanner_start_line(Scanner *s) { return s->start_line; } /* ----------------------------------------------------------------------------- * Scanner_idstart() * * Change the set of additional characters that can be used to start an identifier. * ----------------------------------------------------------------------------- */ void Scanner_idstart(Scanner *s, const char *id) { free(s->idstart); s->idstart = Swig_copy_string(id); } /* ----------------------------------------------------------------------------- * nextchar() * * Returns the next character from the scanner or 0 if end of the string. * ----------------------------------------------------------------------------- */ static char nextchar(Scanner *s) { int nc; if (!s->str) return 0; while ((nc = Getc(s->str)) == EOF) { Delete(s->str); s->str = 0; Delitem(s->scanobjs, 0); if (Len(s->scanobjs) == 0) return 0; s->str = Getitem(s->scanobjs, 0); s->line = Getline(s->str); DohIncref(s->str); } if ((nc == '\n') && (!s->freeze_line)) s->line++; Putc(nc,s->text); return (char)nc; } /* ----------------------------------------------------------------------------- * set_error() * * Sets error information on the scanner. * ----------------------------------------------------------------------------- */ static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) { s->error_line = line; s->error = NewString(msg); } /* ----------------------------------------------------------------------------- * Scanner_errmsg() * Scanner_errline() * * Returns error information (if any) * ----------------------------------------------------------------------------- */ String *Scanner_errmsg(Scanner *s) { return s->error; } int Scanner_errline(Scanner *s) { return s->error_line; } /* ----------------------------------------------------------------------------- * freeze_line() * * Freezes the current line number. * ----------------------------------------------------------------------------- */ static void freeze_line(Scanner *s, int val) { s->freeze_line = val; } /* ----------------------------------------------------------------------------- * brackets_count() * * Returns the number of brackets at the current depth. * A syntax error with unbalanced ) brackets will result in a NULL pointer return. * ----------------------------------------------------------------------------- */ static int *brackets_count(Scanner *s) { int *count; if (Len(s->brackets) > 0) count = (int *)Data(Getitem(s->brackets, 0)); else count = 0; return count; } /* ----------------------------------------------------------------------------- * brackets_clear() * * Resets the current depth and clears all brackets. * Usually called at the end of statements; * ----------------------------------------------------------------------------- */ static void brackets_clear(Scanner *s) { Clear(s->brackets); brackets_push(s); /* base bracket count should always be created */ } /* ----------------------------------------------------------------------------- * brackets_increment() * * Increases the number of brackets at the current depth. * Usually called when a single '<' is found. * ----------------------------------------------------------------------------- */ static void brackets_increment(Scanner *s) { int *count = brackets_count(s); if (count) (*count)++; } /* ----------------------------------------------------------------------------- * brackets_decrement() * * Decreases the number of brackets at the current depth. * Usually called when a single '>' is found. * ----------------------------------------------------------------------------- */ static void brackets_decrement(Scanner *s) { int *count = brackets_count(s); if (count) (*count)--; } /* ----------------------------------------------------------------------------- * brackets_reset() * * Sets the number of '<' brackets back to zero. Called at the point where * it is no longer possible to have a matching closing >> pair for a template. * ----------------------------------------------------------------------------- */ static void brackets_reset(Scanner *s) { int *count = brackets_count(s); if (count) *count = 0; } /* ----------------------------------------------------------------------------- * brackets_push() * * Increases the depth of brackets. * Usually called when '(' is found. * ----------------------------------------------------------------------------- */ static void brackets_push(Scanner *s) { int *newInt = malloc(sizeof(int)); *newInt = 0; Push(s->brackets, NewVoid(newInt, free)); } /* ----------------------------------------------------------------------------- * brackets_pop() * * Decreases the depth of brackets. * Usually called when ')' is found. * ----------------------------------------------------------------------------- */ static void brackets_pop(Scanner *s) { if (Len(s->brackets) > 0) /* protect against unbalanced ')' brackets */ Delitem(s->brackets, 0); } /* ----------------------------------------------------------------------------- * brackets_allow_shift() * * Return 1 to allow shift (>>), or 0 if (>>) should be split into (> >). * This is for C++11 template syntax for closing templates. * ----------------------------------------------------------------------------- */ static int brackets_allow_shift(Scanner *s) { int *count = brackets_count(s); return !count || (*count <= 0); } /* ----------------------------------------------------------------------------- * retract() * * Retract n characters * ----------------------------------------------------------------------------- */ static void retract(Scanner *s, int n) { int i, l; char *str; str = Char(s->text); l = Len(s->text); assert(n <= l); for (i = 0; i < n; i++) { if (str[l - 1] == '\n') { if (!s->freeze_line) s->line--; } (void)Seek(s->str, -1, SEEK_CUR); Delitem(s->text, DOH_END); } } /* ----------------------------------------------------------------------------- * get_escape() * * Get escape sequence. Called when a backslash is found in a string * ----------------------------------------------------------------------------- */ static void get_escape(Scanner *s) { int result = 0; int state = 0; int c; while (1) { c = nextchar(s); if (c == 0) break; switch (state) { case 0: if (c == 'n') { Delitem(s->text, DOH_END); Append(s->text,"\n"); return; } if (c == 'r') { Delitem(s->text, DOH_END); Append(s->text,"\r"); return; } if (c == 't') { Delitem(s->text, DOH_END); Append(s->text,"\t"); return; } if (c == 'a') { Delitem(s->text, DOH_END); Append(s->text,"\a"); return; } if (c == 'b') { Delitem(s->text, DOH_END); Append(s->text,"\b"); return; } if (c == 'f') { Delitem(s->text, DOH_END); Append(s->text,"\f"); return; } if (c == '\\') { Delitem(s->text, DOH_END); Append(s->text,"\\"); return; } if (c == 'v') { Delitem(s->text, DOH_END); Append(s->text,"\v"); return; } if (c == 'e') { Delitem(s->text, DOH_END); Append(s->text,"\033"); return; } if (c == '\'') { Delitem(s->text, DOH_END); Append(s->text,"\'"); return; } if (c == '\"') { Delitem(s->text, DOH_END); Append(s->text,"\""); return; } if (c == '\n') { Delitem(s->text, DOH_END); return; } if (isdigit(c)) { state = 10; result = (c - '0'); Delitem(s->text, DOH_END); } else if (c == 'x') { state = 20; Delitem(s->text, DOH_END); } else { char tmp[3]; tmp[0] = '\\'; tmp[1] = (char)c; tmp[2] = 0; Delitem(s->text, DOH_END); Append(s->text, tmp); return; } break; case 10: if (!isdigit(c)) { retract(s,1); Putc((char)result,s->text); return; } result = (result << 3) + (c - '0'); Delitem(s->text, DOH_END); break; case 20: if (!isxdigit(c)) { retract(s,1); Putc((char)result, s->text); return; } if (isdigit(c)) result = (result << 4) + (c - '0'); else result = (result << 4) + (10 + tolower(c) - 'a'); Delitem(s->text, DOH_END); break; } } return; } /* ----------------------------------------------------------------------------- * look() * * Return the raw value of the next token. * ----------------------------------------------------------------------------- */ static int look(Scanner *s) { int state = 0; int c = 0; String *str_delimiter = 0; Clear(s->text); s->start_line = s->line; Setfile(s->text, Getfile(s->str)); while (1) { switch (state) { case 0: if ((c = nextchar(s)) == 0) return (0); /* Process delimiters */ if (c == '\n') { return SWIG_TOKEN_ENDLINE; } else if (!isspace(c)) { retract(s, 1); state = 1000; Clear(s->text); Setline(s->text, s->line); Setfile(s->text, Getfile(s->str)); } break; case 1000: if ((c = nextchar(s)) == 0) return (0); if (c == '%') state = 4; /* Possibly a SWIG directive */ /* Look for possible identifiers or unicode/delimiter strings */ else if ((isalpha(c)) || (c == '_') || (s->idstart && strchr(s->idstart, c))) { state = 7; } /* Look for single character symbols */ else if (c == '(') { brackets_push(s); return SWIG_TOKEN_LPAREN; } else if (c == ')') { brackets_pop(s); return SWIG_TOKEN_RPAREN; } else if (c == ';') { brackets_clear(s); return SWIG_TOKEN_SEMI; } else if (c == ',') return SWIG_TOKEN_COMMA; else if (c == '*') state = 220; else if (c == '}') return SWIG_TOKEN_RBRACE; else if (c == '{') { brackets_reset(s); return SWIG_TOKEN_LBRACE; } else if (c == '=') state = 33; else if (c == '+') state = 200; else if (c == '-') state = 210; else if (c == '&') state = 31; else if (c == '|') state = 32; else if (c == '^') state = 230; else if (c == '<') state = 60; else if (c == '>') state = 61; else if (c == '~') return SWIG_TOKEN_NOT; else if (c == '!') state = 3; else if (c == '\\') return SWIG_TOKEN_BACKSLASH; else if (c == '[') return SWIG_TOKEN_LBRACKET; else if (c == ']') return SWIG_TOKEN_RBRACKET; else if (c == '@') return SWIG_TOKEN_AT; else if (c == '$') state = 75; else if (c == '#') return SWIG_TOKEN_POUND; else if (c == '?') return SWIG_TOKEN_QUESTION; /* Look for multi-character sequences */ else if (c == '/') { state = 1; /* Comment (maybe) */ s->start_line = s->line; } else if (c == ':') state = 5; /* maybe double colon */ else if (c == '0') state = 83; /* An octal or hex value */ else if (c == '\"') { state = 2; /* A string constant */ s->start_line = s->line; Clear(s->text); } else if (c == '\'') { s->start_line = s->line; Clear(s->text); state = 9; /* A character constant */ } else if (c == '`') { s->start_line = s->line; Clear(s->text); state = 900; } else if (c == '.') state = 100; /* Maybe a number, maybe just a period */ else if (isdigit(c)) state = 8; /* A numerical value */ else state = 99; /* An error */ break; case 1: /* Comment block */ if ((c = nextchar(s)) == 0) return (0); if (c == '/') { state = 10; /* C++ style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "//"); } else if (c == '*') { state = 11; /* C style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "/*"); } else if (c == '=') { return SWIG_TOKEN_DIVEQUAL; } else { retract(s, 1); return SWIG_TOKEN_SLASH; } break; case 10: /* C++ style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '\n') { retract(s,1); return SWIG_TOKEN_COMMENT; } else { state = 10; } break; case 11: /* C style comment block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else { state = 11; } break; case 12: /* Still in C style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else if (c == '/') { return SWIG_TOKEN_COMMENT; } else { state = 11; } break; case 2: /* Processing a string */ if (!str_delimiter) { state=20; break; } if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } else if (c == '(') { state = 20; } else { char temp[2] = { 0, 0 }; temp[0] = c; Append( str_delimiter, temp ); } break; case 20: /* Inside the string */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } if (!str_delimiter) { /* Ordinary string: "value" */ if (c == '\"') { Delitem(s->text, DOH_END); return SWIG_TOKEN_STRING; } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } } else { /* Custom delimiter string: R"XXXX(value)XXXX" */ if (c==')') { int i=0; String *end_delimiter = NewStringEmpty(); while ((c = nextchar(s)) != 0 && c!='\"') { char temp[2] = { 0, 0 }; temp[0] = c; Append( end_delimiter, temp ); i++; } if (Strcmp( str_delimiter, end_delimiter )==0) { Delete( end_delimiter ); /* Correct end delimiter )XXXX" occured */ Delete( str_delimiter ); str_delimiter = 0; return SWIG_TOKEN_STRING; } else { /* Incorrect end delimiter occured */ retract( s, i ); Delete( end_delimiter ); } } } break; case 3: /* Maybe a not equals */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LNOT; else if (c == '=') return SWIG_TOKEN_NOTEQUAL; else { retract(s, 1); return SWIG_TOKEN_LNOT; } break; case 31: /* AND or Logical AND or ANDEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_AND; else if (c == '&') return SWIG_TOKEN_LAND; else if (c == '=') return SWIG_TOKEN_ANDEQUAL; else { retract(s, 1); return SWIG_TOKEN_AND; } break; case 32: /* OR or Logical OR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_OR; else if (c == '|') return SWIG_TOKEN_LOR; else if (c == '=') return SWIG_TOKEN_OREQUAL; else { retract(s, 1); return SWIG_TOKEN_OR; } break; case 33: /* EQUAL or EQUALTO */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_EQUAL; else if (c == '=') return SWIG_TOKEN_EQUALTO; else { retract(s, 1); return SWIG_TOKEN_EQUAL; } break; case 4: /* A wrapper generator directive (maybe) */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PERCENT; if (c == '{') { state = 40; /* Include block */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); s->start_line = s->line; } else if (s->idstart && strchr(s->idstart, '%') && ((isalpha(c)) || (c == '_'))) { state = 7; } else if (c == '=') { return SWIG_TOKEN_MODEQUAL; } else { retract(s, 1); return SWIG_TOKEN_PERCENT; } break; case 40: /* Process an include block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated block\n"); return SWIG_TOKEN_ERROR; } if (c == '%') state = 41; break; case 41: /* Still processing include block */ if ((c = nextchar(s)) == 0) { set_error(s,s->start_line,"Unterminated code block"); return 0; } if (c == '}') { Delitem(s->text, DOH_END); Delitem(s->text, DOH_END); Seek(s->text,0,SEEK_SET); return SWIG_TOKEN_CODEBLOCK; } else { state = 40; } break; case 5: /* Maybe a double colon */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_COLON; if (c == ':') state = 50; else { retract(s, 1); return SWIG_TOKEN_COLON; } break; case 50: /* DCOLON, DCOLONSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DCOLON; else if (c == '*') return SWIG_TOKEN_DCOLONSTAR; else { retract(s, 1); return SWIG_TOKEN_DCOLON; } break; case 60: /* shift operators */ if ((c = nextchar(s)) == 0) { brackets_increment(s); return SWIG_TOKEN_LESSTHAN; } if (c == '<') state = 240; else if (c == '=') return SWIG_TOKEN_LTEQUAL; else { retract(s, 1); brackets_increment(s); return SWIG_TOKEN_LESSTHAN; } break; case 61: if ((c = nextchar(s)) == 0) { brackets_decrement(s); return SWIG_TOKEN_GREATERTHAN; } if (c == '>' && brackets_allow_shift(s)) state = 250; else if (c == '=') return SWIG_TOKEN_GTEQUAL; else { retract(s, 1); brackets_decrement(s); return SWIG_TOKEN_GREATERTHAN; } break; case 7: /* Identifier or true/false or unicode/custom delimiter string */ if (c == 'R') { /* Possibly CUSTOM DELIMITER string */ state = 72; break; } else if (c == 'L') { /* Probably identifier but may be a wide string literal */ state = 77; break; } else if (c != 'u' && c != 'U') { /* Definitely an identifier */ state = 70; break; } if ((c = nextchar(s)) == 0) { state = 76; } else if (c == '\"') { /* Definitely u, U or L string */ retract(s, 1); state = 1000; } else if (c == 'R') { /* Possibly CUSTOM DELIMITER u, U, L string */ state = 73; } else if (c == '8') { /* Possibly u8 string */ state = 71; } else { retract(s, 1); /* Definitely an identifier */ state = 70; } break; case 70: /* Identifier */ if ((c = nextchar(s)) == 0) state = 76; else if (isalnum(c) || (c == '_') || (c == '$')) { state = 70; } else { retract(s, 1); state = 76; } break; case 71: /* Possibly u8 string */ if ((c = nextchar(s)) == 0) { state = 76; } else if (c=='\"') { retract(s, 1); /* Definitely u8 string */ state = 1000; } else if (c=='R') { state = 74; /* Possibly CUSTOM DELIMITER u8 string */ } else { retract(s, 2); /* Definitely an identifier. Retract 8" */ state = 70; } break; case 72: /* Possibly CUSTOM DELIMITER string */ case 73: case 74: if ((c = nextchar(s)) == 0) { state = 76; } else if (c=='\"') { retract(s, 1); /* Definitely custom delimiter u, U or L string */ str_delimiter = NewStringEmpty(); state = 1000; } else { if (state==72) { retract(s, 1); /* Definitely an identifier. Retract ? */ } else if (state==73) { retract(s, 2); /* Definitely an identifier. Retract R? */ } else if (state==74) { retract(s, 3); /* Definitely an identifier. Retract 8R? */ } state = 70; } break; case 75: /* Special identifier $ */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOLLAR; if (isalnum(c) || (c == '_') || (c == '*') || (c == '&')) { state = 70; } else { retract(s,1); if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR; state = 76; } break; case 76: /* Identifier or true/false */ if (cparse_cplusplus) { if (Strcmp(s->text, "true") == 0) return SWIG_TOKEN_BOOL; else if (Strcmp(s->text, "false") == 0) return SWIG_TOKEN_BOOL; } return SWIG_TOKEN_ID; break; case 77: /*identifier or wide string literal*/ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ID; else if (c == '\"') { s->start_line = s->line; Clear(s->text); state = 78; } else if (c == '\'') { s->start_line = s->line; Clear(s->text); state = 79; } else if (isalnum(c) || (c == '_') || (c == '$')) state = 7; else { retract(s, 1); return SWIG_TOKEN_ID; } break; case 78: /* Processing a wide string literal*/ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide string\n"); return SWIG_TOKEN_ERROR; } if (c == '\"') { Delitem(s->text, DOH_END); return SWIG_TOKEN_WSTRING; } else if (c == '\\') { if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide string\n"); return SWIG_TOKEN_ERROR; } } break; case 79: /* Processing a wide char literal */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '\'') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_WCHAR); } else if (c == '\\') { if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide character literal\n"); return SWIG_TOKEN_ERROR; } } break; case 8: /* A numerical digit */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (c == '.') { state = 81; } else if ((c == 'e') || (c == 'E')) { state = 82; } else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if (isdigit(c)) { state = 8; } else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 81: /* A floating pointer number of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 81; else if ((c == 'e') || (c == 'E')) state = 820; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return (SWIG_TOKEN_DOUBLE); } break; case 82: if ((c = nextchar(s)) == 0) { retract(s, 1); return SWIG_TOKEN_INT; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); return (SWIG_TOKEN_INT); } break; case 820: /* Like case 82, but we've seen a decimal point. */ if ((c = nextchar(s)) == 0) { retract(s, 1); return SWIG_TOKEN_DOUBLE; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); return (SWIG_TOKEN_DOUBLE); } break; case 83: /* Might be a hexadecimal or octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'x') || (c == 'X')) state = 85; else if (c == '.') state = 81; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 84: /* This is an octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 85: /* This is an hex number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isxdigit(c)) state = 85; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 86: /* Rest of floating point number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 86; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return SWIG_TOKEN_DOUBLE; } break; case 87: /* A long integer of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONG; } else if ((c == 'l') || (c == 'L')) { state = 870; } else { retract(s, 1); return SWIG_TOKEN_LONG; } break; /* A long long integer */ case 870: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONGLONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONGLONG; } else { retract(s, 1); return SWIG_TOKEN_LONGLONG; } /* An unsigned number */ case 88: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_UINT; if ((c == 'l') || (c == 'L')) { state = 880; } else { retract(s, 1); return SWIG_TOKEN_UINT; } break; /* Possibly an unsigned long long or unsigned long */ case 880: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ULONG; if ((c == 'l') || (c == 'L')) return SWIG_TOKEN_ULONGLONG; else { retract(s, 1); return SWIG_TOKEN_ULONG; } /* A character constant */ case 9: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '\'') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_CHAR); } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } break; /* A period or maybe a floating point number */ case 100: if ((c = nextchar(s)) == 0) return (0); if (isdigit(c)) state = 81; else { retract(s, 1); return SWIG_TOKEN_PERIOD; } break; case 200: /* PLUS, PLUSPLUS, PLUSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PLUS; else if (c == '+') return SWIG_TOKEN_PLUSPLUS; else if (c == '=') return SWIG_TOKEN_PLUSEQUAL; else { retract(s, 1); return SWIG_TOKEN_PLUS; } break; case 210: /* MINUS, MINUSMINUS, MINUSEQUAL, ARROW */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_MINUS; else if (c == '-') return SWIG_TOKEN_MINUSMINUS; else if (c == '=') return SWIG_TOKEN_MINUSEQUAL; else if (c == '>') state = 211; else { retract(s, 1); return SWIG_TOKEN_MINUS; } break; case 211: /* ARROW, ARROWSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ARROW; else if (c == '*') return SWIG_TOKEN_ARROWSTAR; else { retract(s, 1); return SWIG_TOKEN_ARROW; } break; case 220: /* STAR, TIMESEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_STAR; else if (c == '=') return SWIG_TOKEN_TIMESEQUAL; else { retract(s, 1); return SWIG_TOKEN_STAR; } break; case 230: /* XOR, XOREQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_XOR; else if (c == '=') return SWIG_TOKEN_XOREQUAL; else { retract(s, 1); return SWIG_TOKEN_XOR; } break; case 240: /* LSHIFT, LSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LSHIFT; else if (c == '=') return SWIG_TOKEN_LSEQUAL; else { retract(s, 1); return SWIG_TOKEN_LSHIFT; } break; case 250: /* RSHIFT, RSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_RSHIFT; else if (c == '=') return SWIG_TOKEN_RSEQUAL; else { retract(s, 1); return SWIG_TOKEN_RSHIFT; } break; /* An illegal character */ /* Reverse string */ case 900: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '`') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_RSTRING); } break; default: return SWIG_TOKEN_ILLEGAL; } } } /* ----------------------------------------------------------------------------- * Scanner_token() * * Real entry point to return the next token. Returns 0 if at end of input. * ----------------------------------------------------------------------------- */ int Scanner_token(Scanner *s) { int t; Delete(s->error); if (s->nexttoken >= 0) { t = s->nexttoken; s->nexttoken = -1; return t; } s->start_line = 0; t = look(s); if (!s->start_line) { Setline(s->text,s->line); } else { Setline(s->text,s->start_line); } return t; } /* ----------------------------------------------------------------------------- * Scanner_text() * * Return the lexene associated with the last returned token. * ----------------------------------------------------------------------------- */ String *Scanner_text(Scanner *s) { return s->text; } /* ----------------------------------------------------------------------------- * Scanner_skip_line() * * Skips to the end of a line * ----------------------------------------------------------------------------- */ void Scanner_skip_line(Scanner *s) { char c; int done = 0; Clear(s->text); Setfile(s->text, Getfile(s->str)); Setline(s->text, s->line); while (!done) { if ((c = nextchar(s)) == 0) return; if (c == '\\') { nextchar(s); } else if (c == '\n') { done = 1; } } return; } /* ----------------------------------------------------------------------------- * Scanner_skip_balanced() * * Skips a piece of code enclosed in begin/end symbols such as '{...}' or * (...). Ignores symbols inside comments or strings. * ----------------------------------------------------------------------------- */ int Scanner_skip_balanced(Scanner *s, int startchar, int endchar) { char c; int num_levels = 1; int state = 0; char temp[2] = { 0, 0 }; String *locator = 0; temp[0] = (char) startchar; Clear(s->text); Setfile(s->text, Getfile(s->str)); Setline(s->text, s->line); Append(s->text, temp); while (num_levels > 0) { if ((c = nextchar(s)) == 0) { Delete(locator); return -1; } switch (state) { case 0: if (c == startchar) num_levels++; else if (c == endchar) num_levels--; else if (c == '/') state = 10; else if (c == '\"') state = 20; else if (c == '\'') state = 30; break; case 10: if (c == '/') state = 11; else if (c == '*') state = 12; else if (c == startchar) { state = 0; num_levels++; } else state = 0; break; case 11: if (c == '\n') state = 0; else state = 11; break; case 12: /* first character inside C comment */ if (c == '*') state = 14; else if (c == '@') state = 40; else state = 13; break; case 13: if (c == '*') state = 14; break; case 14: /* possible end of C comment */ if (c == '*') state = 14; else if (c == '/') state = 0; else state = 13; break; case 20: if (c == '\"') state = 0; else if (c == '\\') state = 21; break; case 21: state = 20; break; case 30: if (c == '\'') state = 0; else if (c == '\\') state = 31; break; case 31: state = 30; break; /* 40-45 SWIG locator checks - a C comment with contents starting: @SWIG */ case 40: state = (c == 'S') ? 41 : (c == '*') ? 14 : 13; break; case 41: state = (c == 'W') ? 42 : (c == '*') ? 14 : 13; break; case 42: state = (c == 'I') ? 43 : (c == '*') ? 14 : 13; break; case 43: state = (c == 'G') ? 44 : (c == '*') ? 14 : 13; if (c == 'G') { Delete(locator); locator = NewString("/*@SWIG"); } break; case 44: if (c == '*') state = 45; Putc(c, locator); break; case 45: /* end of SWIG locator in C comment */ if (c == '/') { state = 0; Putc(c, locator); Scanner_locator(s, locator); } else { /* malformed locator */ state = (c == '*') ? 14 : 13; } break; default: break; } } Delete(locator); return 0; } /* ----------------------------------------------------------------------------- * Scanner_get_raw_text_balanced() * * Returns raw text between 2 braces, does not change scanner state in any way * ----------------------------------------------------------------------------- */ String *Scanner_get_raw_text_balanced(Scanner *s, int startchar, int endchar) { String *result = 0; char c; int old_line = s->line; String *old_text = Copy(s->text); long position = Tell(s->str); int num_levels = 1; int state = 0; char temp[2] = { 0, 0 }; temp[0] = (char) startchar; Clear(s->text); Setfile(s->text, Getfile(s->str)); Setline(s->text, s->line); Append(s->text, temp); while (num_levels > 0) { if ((c = nextchar(s)) == 0) { Clear(s->text); Append(s->text, old_text); Delete(old_text); s->line = old_line; return 0; } switch (state) { case 0: if (c == startchar) num_levels++; else if (c == endchar) num_levels--; else if (c == '/') state = 10; else if (c == '\"') state = 20; else if (c == '\'') state = 30; break; case 10: if (c == '/') state = 11; else if (c == '*') state = 12; else if (c == startchar) { state = 0; num_levels++; } else state = 0; break; case 11: if (c == '\n') state = 0; else state = 11; break; case 12: /* first character inside C comment */ if (c == '*') state = 14; else state = 13; break; case 13: if (c == '*') state = 14; break; case 14: /* possible end of C comment */ if (c == '*') state = 14; else if (c == '/') state = 0; else state = 13; break; case 20: if (c == '\"') state = 0; else if (c == '\\') state = 21; break; case 21: state = 20; break; case 30: if (c == '\'') state = 0; else if (c == '\\') state = 31; break; case 31: state = 30; break; default: break; } } Seek(s->str, position, SEEK_SET); result = Copy(s->text); Clear(s->text); Append(s->text, old_text); Delete(old_text); s->line = old_line; return result; } /* ----------------------------------------------------------------------------- * Scanner_isoperator() * * Returns 0 or 1 depending on whether or not a token corresponds to a C/C++ * operator. * ----------------------------------------------------------------------------- */ int Scanner_isoperator(int tokval) { if (tokval >= 100) return 1; return 0; } /* ---------------------------------------------------------------------- * locator() * * Support for locator strings. These are strings of the form * @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They * are primarily used for macro line number reporting. * We just use the locator to mark when to activate/deactivate linecounting. * ---------------------------------------------------------------------- */ void Scanner_locator(Scanner *s, String *loc) { static Locator *locs = 0; static int expanding_macro = 0; if (!follow_locators) { if (Equal(loc, "/*@SWIG@*/")) { /* End locator. */ if (expanding_macro) --expanding_macro; } else { /* Begin locator. */ ++expanding_macro; } /* Freeze line number processing in Scanner */ freeze_line(s,expanding_macro); } else { int c; Locator *l; (void)Seek(loc, 7, SEEK_SET); c = Getc(loc); if (c == '@') { /* Empty locator. We pop the last location off */ if (locs) { Scanner_set_location(s, locs->filename, locs->line_number); cparse_file = locs->filename; cparse_line = locs->line_number; l = locs->next; free(locs); locs = l; } return; } /* We're going to push a new location */ l = (Locator *) malloc(sizeof(Locator)); l->filename = cparse_file; l->line_number = cparse_line; l->next = locs; locs = l; /* Now, parse the new location out of the locator string */ { String *fn = NewStringEmpty(); /* Putc(c, fn); */ while ((c = Getc(loc)) != EOF) { if ((c == '@') || (c == ',')) break; Putc(c, fn); } cparse_file = Swig_copy_string(Char(fn)); Clear(fn); cparse_line = 1; /* Get the line number */ while ((c = Getc(loc)) != EOF) { if ((c == '@') || (c == ',')) break; Putc(c, fn); } cparse_line = atoi(Char(fn)); Clear(fn); /* Get the rest of it */ while ((c = Getc(loc)) != EOF) { if (c == '@') break; Putc(c, fn); } /* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */ Scanner_set_location(s, cparse_file, cparse_line); Delete(fn); } } } void Swig_cparse_follow_locators(int v) { follow_locators = v; } swig-3.0.2/Source/Swig/typeobj.c0000664000175000017500000007702512343605122016347 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * typeobj.c * * This file provides functions for constructing, manipulating, and testing * type objects. Type objects are merely the raw low-level representation * of C++ types. They do not incorporate high-level type system features * like typedef, namespaces, etc. * ----------------------------------------------------------------------------- */ #include "swig.h" #include #include /* ----------------------------------------------------------------------------- * Synopsis * * This file provides a collection of low-level functions for constructing and * manipulating C++ data types. In SWIG, C++ datatypes are encoded as simple * text strings. This representation is compact, easy to debug, and easy to read. * * General idea: * * Types are represented by a base type (e.g., "int") and a collection of * type operators applied to the base (e.g., pointers, arrays, etc...). * * Encoding: * * Types are encoded as strings of type constructors such as follows: * * String Encoding C Example * --------------- --------- * p.p.int int ** * a(300).a(400).int int [300][400] * p.q(const).char char const * * * All type constructors are denoted by a trailing '.': * * 'p.' = Pointer (*) * 'r.' = Reference (&) * 'z.' = Rvalue reference (&&) * 'a(n).' = Array of size n [n] * 'f(..,..).' = Function with arguments (args) * 'q(str).' = Qualifier (such as const or volatile) (const, volatile) * 'm(qual).' = Pointer to member (qual::*) * * The complete type representation for varargs is: * 'v(...)' * * The encoding follows the order that you might describe a type in words. * For example "p.a(200).int" is "A pointer to array of int's" and * "p.q(const).char" is "a pointer to a const char". * * This representation of types is fairly convenient because ordinary string * operations can be used for type manipulation. For example, a type could be * formed by combining two strings such as the following: * * "p.p." + "a(400).int" = "p.p.a(400).int" * * For C++, typenames may be parameterized using <(...)>. Here are some * examples: * * String Encoding C++ Example * --------------- ------------ * p.vector<(int)> vector * * r.foo<(int,p.double)> foo & * * Contents of this file: * * Most of this functions in this file pertain to the low-level manipulation * of type objects. There are constructor functions like this: * * SwigType_add_pointer() * SwigType_add_reference() * SwigType_add_rvalue_reference() * SwigType_add_array() * * These are used to build new types. There are also functions to undo these * operations. For example: * * SwigType_del_pointer() * SwigType_del_reference() * SwigType_del_rvalue_reference() * SwigType_del_array() * * In addition, there are query functions * * SwigType_ispointer() * SwigType_isreference() * SwigType_isrvalue_reference() * SwigType_isarray() * * Finally, there are some data extraction functions that can be used to * extract array dimensions, template arguments, and so forth. * * It is very important for developers to realize that the functions in this * module do *NOT* incorporate higher-level type system features like typedef. * For example, you could have C code like this: * * typedef int *intptr; * * In this case, a SwigType of type 'intptr' will be treated as a simple type and * functions like SwigType_ispointer() will evaluate as false. It is strongly * advised that developers use the TypeSys_* interface to check types in a more * reliable manner. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * NewSwigType() * * Constructs a new type object. Eventually, it would be nice for this function * to accept an initial value in the form a C/C++ abstract type (currently unimplemented). * ----------------------------------------------------------------------------- */ #ifdef NEW SwigType *NewSwigType(const_String_or_char_ptr initial) { return NewString(initial); } #endif /* The next few functions are utility functions used in the construction and management of types */ /* ----------------------------------------------------------------------------- * static element_size() * * This utility function finds the size of a single type element in a type string. * Type elements are always delimited by periods, but may be nested with * parentheses. A nested element is always handled as a single item. * * Returns the integer size of the element (which can be used to extract a * substring, to chop the element off, or for other purposes). * ----------------------------------------------------------------------------- */ static int element_size(char *c) { int nparen; char *s = c; while (*c) { if (*c == '.') { c++; return (int) (c - s); } else if (*c == '(') { nparen = 1; c++; while (*c) { if (*c == '(') nparen++; if (*c == ')') { nparen--; if (nparen == 0) break; } c++; } } if (*c) c++; } return (int) (c - s); } /* ----------------------------------------------------------------------------- * SwigType_del_element() * * Deletes one type element from the type. * ----------------------------------------------------------------------------- */ SwigType *SwigType_del_element(SwigType *t) { int sz = element_size(Char(t)); Delslice(t, 0, sz); return t; } /* ----------------------------------------------------------------------------- * SwigType_pop() * * Pop one type element off the type. * Example: t in: q(const).p.Integer * t out: p.Integer * result: q(const). * ----------------------------------------------------------------------------- */ SwigType *SwigType_pop(SwigType *t) { SwigType *result; char *c; int sz; c = Char(t); if (!*c) return 0; sz = element_size(c); result = NewStringWithSize(c, sz); Delslice(t, 0, sz); c = Char(t); if (*c == '.') { Delitem(t, 0); } return result; } /* ----------------------------------------------------------------------------- * SwigType_parm() * * Returns the parameter of an operator as a string * ----------------------------------------------------------------------------- */ String *SwigType_parm(const SwigType *t) { char *start, *c; int nparens = 0; c = Char(t); while (*c && (*c != '(') && (*c != '.')) c++; if (!*c || (*c == '.')) return 0; c++; start = c; while (*c) { if (*c == ')') { if (nparens == 0) break; nparens--; } else if (*c == '(') { nparens++; } c++; } return NewStringWithSize(start, (int) (c - start)); } /* ----------------------------------------------------------------------------- * SwigType_split() * * Splits a type into its component parts and returns a list of string. * ----------------------------------------------------------------------------- */ List *SwigType_split(const SwigType *t) { String *item; List *list; char *c; int len; c = Char(t); list = NewList(); while (*c) { len = element_size(c); item = NewStringWithSize(c, len); Append(list, item); Delete(item); c = c + len; if (*c == '.') c++; } return list; } /* ----------------------------------------------------------------------------- * SwigType_parmlist() * * Splits a comma separated list of parameters into its component parts * The input is expected to contain the parameter list within () brackets * Returns 0 if no argument list in the input, ie there are no round brackets () * Returns an empty List if there are no parameters in the () brackets * For example: * * Foo(std::string,p.f().Bar<(int,double)>) * * returns 2 elements in the list: * std::string * p.f().Bar<(int,double)> * ----------------------------------------------------------------------------- */ List *SwigType_parmlist(const String *p) { String *item = 0; List *list; char *c; char *itemstart; int size; assert(p); c = Char(p); while (*c && (*c != '(') && (*c != '.')) c++; if (!*c) return 0; assert(*c != '.'); /* p is expected to contain sub elements of a type */ c++; list = NewList(); itemstart = c; while (*c) { if (*c == ',') { size = (int) (c - itemstart); item = NewStringWithSize(itemstart, size); Append(list, item); Delete(item); itemstart = c + 1; } else if (*c == '(') { int nparens = 1; c++; while (*c) { if (*c == '(') nparens++; if (*c == ')') { nparens--; if (nparens == 0) break; } c++; } } else if (*c == ')') { break; } if (*c) c++; } size = (int) (c - itemstart); if (size > 0) { item = NewStringWithSize(itemstart, size); Append(list, item); } Delete(item); return list; } /* ----------------------------------------------------------------------------- * Pointers * * SwigType_add_pointer() * SwigType_del_pointer() * SwigType_ispointer() * * Add, remove, and test if a type is a pointer. The deletion and query * functions take into account qualifiers (if any). * ----------------------------------------------------------------------------- */ SwigType *SwigType_add_pointer(SwigType *t) { Insert(t, 0, "p."); return t; } SwigType *SwigType_del_pointer(SwigType *t) { char *c, *s; c = Char(t); s = c; /* Skip qualifiers, if any */ if (strncmp(c, "q(", 2) == 0) { c = strchr(c, '.'); assert(c); c++; } if (strncmp(c, "p.", 2)) { printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n"); abort(); } Delslice(t, 0, (c - s) + 2); return t; } int SwigType_ispointer(const SwigType *t) { char *c; if (!t) return 0; c = Char(t); /* Skip qualifiers, if any */ if (strncmp(c, "q(", 2) == 0) { c = strchr(c, '.'); if (!c) return 0; c++; } if (strncmp(c, "p.", 2) == 0) { return 1; } return 0; } /* ----------------------------------------------------------------------------- * References * * SwigType_add_reference() * SwigType_del_reference() * SwigType_isreference() * * Add, remove, and test if a type is a reference. The deletion and query * functions take into account qualifiers (if any). * ----------------------------------------------------------------------------- */ SwigType *SwigType_add_reference(SwigType *t) { Insert(t, 0, "r."); return t; } SwigType *SwigType_del_reference(SwigType *t) { char *c = Char(t); int check = strncmp(c, "r.", 2); assert(check == 0); Delslice(t, 0, 2); return t; } int SwigType_isreference(const SwigType *t) { char *c; if (!t) return 0; c = Char(t); if (strncmp(c, "r.", 2) == 0) { return 1; } return 0; } /* ----------------------------------------------------------------------------- * Rvalue References * * SwigType_add_rvalue_reference() * SwigType_del_rvalue_reference() * SwigType_isrvalue_reference() * * Add, remove, and test if a type is a rvalue reference. The deletion and query * functions take into account qualifiers (if any). * ----------------------------------------------------------------------------- */ SwigType *SwigType_add_rvalue_reference(SwigType *t) { Insert(t, 0, "z."); return t; } SwigType *SwigType_del_rvalue_reference(SwigType *t) { char *c = Char(t); int check = strncmp(c, "z.", 2); assert(check == 0); Delslice(t, 0, 2); return t; } int SwigType_isrvalue_reference(const SwigType *t) { char *c; if (!t) return 0; c = Char(t); if (strncmp(c, "z.", 2) == 0) { return 1; } return 0; } /* ----------------------------------------------------------------------------- * Qualifiers * * SwigType_add_qualifier() * SwigType_del_qualifier() * SwigType_is_qualifier() * * Adds type qualifiers like "const" and "volatile". When multiple qualifiers * are added to a type, they are combined together into a single qualifier. * Repeated qualifications have no effect. Moreover, the order of qualifications * is alphabetical---meaning that "const volatile" and "volatile const" are * stored in exactly the same way as "q(const volatile)". * 'qual' can be a list of multiple qualifiers in any order, separated by spaces. * ----------------------------------------------------------------------------- */ SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) { List *qlist; String *allq, *newq; int i, sz; const char *cqprev = 0; const char *c = Char(t); const char *cqual = Char(qual); /* if 't' has no qualifiers and 'qual' is a single qualifier, simply add it */ if ((strncmp(c, "q(", 2) != 0) && (strstr(cqual, " ") == 0)) { String *temp = NewStringf("q(%s).", cqual); Insert(t, 0, temp); Delete(temp); return t; } /* create string of all qualifiers */ if (strncmp(c, "q(", 2) == 0) { allq = SwigType_parm(t); Append(allq, " "); SwigType_del_element(t); /* delete old qualifier list from 't' */ } else { allq = NewStringEmpty(); } Append(allq, qual); /* create list of all qualifiers from string */ qlist = Split(allq, ' ', INT_MAX); Delete(allq); /* sort in alphabetical order */ SortList(qlist, Strcmp); /* create new qualifier string from unique elements of list */ sz = Len(qlist); newq = NewString("q("); for (i = 0; i < sz; ++i) { String *q = Getitem(qlist, i); const char *cq = Char(q); if (cqprev == 0 || strcmp(cqprev, cq) != 0) { if (i > 0) { Append(newq, " "); } Append(newq, q); cqprev = cq; } } Append(newq, ")."); Delete(qlist); /* replace qualifier string with new one */ Insert(t, 0, newq); Delete(newq); return t; } SwigType *SwigType_del_qualifier(SwigType *t) { char *c = Char(t); int check = strncmp(c, "q(", 2); assert(check == 0); Delslice(t, 0, element_size(c)); return t; } int SwigType_isqualifier(const SwigType *t) { char *c; if (!t) return 0; c = Char(t); if (strncmp(c, "q(", 2) == 0) { return 1; } return 0; } /* ----------------------------------------------------------------------------- * Function Pointers * ----------------------------------------------------------------------------- */ int SwigType_isfunctionpointer(const SwigType *t) { char *c; if (!t) return 0; c = Char(t); if (strncmp(c, "p.f(", 4) == 0) { return 1; } return 0; } /* ----------------------------------------------------------------------------- * SwigType_functionpointer_decompose * * Decompose the function pointer into the parameter list and the return type * t - input and on completion contains the return type * returns the function's parameters * ----------------------------------------------------------------------------- */ SwigType *SwigType_functionpointer_decompose(SwigType *t) { String *p; assert(SwigType_isfunctionpointer(t)); p = SwigType_pop(t); Delete(p); p = SwigType_pop(t); return p; } /* ----------------------------------------------------------------------------- * Member Pointers * * SwigType_add_memberpointer() * SwigType_del_memberpointer() * SwigType_ismemberpointer() * * Add, remove, and test for C++ pointer to members. * ----------------------------------------------------------------------------- */ SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr name) { String *temp = NewStringf("m(%s).", name); Insert(t, 0, temp); Delete(temp); return t; } SwigType *SwigType_del_memberpointer(SwigType *t) { char *c = Char(t); int check = strncmp(c, "m(", 2); assert(check == 0); Delslice(t, 0, element_size(c)); return t; } int SwigType_ismemberpointer(const SwigType *t) { char *c; if (!t) return 0; c = Char(t); if (strncmp(c, "m(", 2) == 0) { return 1; } return 0; } /* ----------------------------------------------------------------------------- * Arrays * * SwigType_add_array() * SwigType_del_array() * SwigType_isarray() * * Utility functions: * * SwigType_array_ndim() - Calculate number of array dimensions. * SwigType_array_getdim() - Get array dimension * SwigType_array_setdim() - Set array dimension * SwigType_array_type() - Return array type * SwigType_pop_arrays() - Remove all arrays * ----------------------------------------------------------------------------- */ SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) { String *temp = NewString("a("); Append(temp, size); Append(temp, ")."); Insert(t, 0, temp); Delete(temp); return t; } SwigType *SwigType_del_array(SwigType *t) { char *c = Char(t); int check = strncmp(c, "a(", 2); assert(check == 0); Delslice(t, 0, element_size(c)); return t; } int SwigType_isarray(const SwigType *t) { char *c; if (!t) return 0; c = Char(t); if (strncmp(c, "a(", 2) == 0) { return 1; } return 0; } /* * SwigType_prefix_is_simple_1D_array * * Determine if the type is a 1D array type that is treated as a pointer within SWIG * eg Foo[], Foo[3] return true, but Foo[3][3], Foo*[], Foo*[3], Foo**[] return false */ int SwigType_prefix_is_simple_1D_array(const SwigType *t) { char *c = Char(t); if (c && (strncmp(c, "a(", 2) == 0)) { c = strchr(c, '.'); if (c) return (*(++c) == 0); } return 0; } /* Remove all arrays */ SwigType *SwigType_pop_arrays(SwigType *t) { String *ta; assert(SwigType_isarray(t)); ta = NewStringEmpty(); while (SwigType_isarray(t)) { SwigType *td = SwigType_pop(t); Append(ta, td); Delete(td); } return ta; } /* Return number of array dimensions */ int SwigType_array_ndim(const SwigType *t) { int ndim = 0; char *c = Char(t); while (c && (strncmp(c, "a(", 2) == 0)) { c = strchr(c, '.'); if (c) { c++; ndim++; } } return ndim; } /* Get nth array dimension */ String *SwigType_array_getdim(const SwigType *t, int n) { char *c = Char(t); while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) { c = strchr(c, '.'); if (c) { c++; n--; } } if (n == 0) { String *dim = SwigType_parm(c); if (SwigType_istemplate(dim)) { String *ndim = SwigType_namestr(dim); Delete(dim); dim = ndim; } return dim; } return 0; } /* Replace nth array dimension */ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) { String *result = 0; char temp; char *start; char *c = Char(t); start = c; if (strncmp(c, "a(", 2)) abort(); while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) { c = strchr(c, '.'); if (c) { c++; n--; } } if (n == 0) { temp = *c; *c = 0; result = NewString(start); Printf(result, "a(%s)", rep); *c = temp; c = strchr(c, '.'); Append(result, c); } Clear(t); Append(t, result); Delete(result); } /* Return base type of an array */ SwigType *SwigType_array_type(const SwigType *ty) { SwigType *t; t = Copy(ty); while (SwigType_isarray(t)) { Delete(SwigType_pop(t)); } return t; } /* ----------------------------------------------------------------------------- * Functions * * SwigType_add_function() * SwigType_del_function() * SwigType_isfunction() * SwigType_pop_function() * * Add, remove, and test for function types. * ----------------------------------------------------------------------------- */ /* Returns the function type, t, constructed from the parameters, parms */ SwigType *SwigType_add_function(SwigType *t, ParmList *parms) { String *pstr; Parm *p; Insert(t, 0, ")."); pstr = NewString("f("); for (p = parms; p; p = nextSibling(p)) { if (p != parms) Putc(',', pstr); Append(pstr, Getattr(p, "type")); } Insert(t, 0, pstr); Delete(pstr); return t; } SwigType *SwigType_pop_function(SwigType *t) { SwigType *f = 0; SwigType *g = 0; char *c = Char(t); if (strncmp(c, "q(", 2) == 0) { f = SwigType_pop(t); c = Char(t); } if (strncmp(c, "f(", 2)) { printf("Fatal error. SwigType_pop_function applied to non-function.\n"); abort(); } g = SwigType_pop(t); if (f) SwigType_push(g, f); Delete(f); return g; } int SwigType_isfunction(const SwigType *t) { char *c; if (!t) { return 0; } c = Char(t); if (strncmp(c, "q(", 2) == 0) { /* Might be a 'const' function. Try to skip over the 'const' */ c = strchr(c, '.'); if (c) c++; else return 0; } if (strncmp(c, "f(", 2) == 0) { return 1; } return 0; } /* Create a list of parameters from the type t, using the file_line_node Node for * file and line numbering for the parameters */ ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node) { List *l = SwigType_parmlist(t); Hash *p, *pp = 0, *firstp = 0; Iterator o; for (o = First(l); o.item; o = Next(o)) { p = file_line_node ? NewParm(o.item, 0, file_line_node) : NewParmWithoutFileLineInfo(o.item, 0); if (!firstp) firstp = p; if (pp) { set_nextSibling(pp, p); Delete(p); } pp = p; } Delete(l); return firstp; } int SwigType_isvarargs(const SwigType *t) { if (Strcmp(t, "v(...)") == 0) return 1; return 0; } /* ----------------------------------------------------------------------------- * Templates * * SwigType_add_template() * * Template handling. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * SwigType_add_template() * * Adds a template to a type. This template is encoded in the SWIG type * mechanism and produces a string like this: * * vector ----> "vector<(p.int)>" * ----------------------------------------------------------------------------- */ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) { Parm *p; Append(t, "<("); for (p = parms; p; p = nextSibling(p)) { String *v; if (Getattr(p, "default")) continue; if (p != parms) Append(t, ","); v = Getattr(p, "value"); if (v) { Append(t, v); } else { Append(t, Getattr(p, "type")); } } Append(t, ")>"); return t; } /* ----------------------------------------------------------------------------- * SwigType_templateprefix() * * Returns the prefix before the first template definition. * Returns the type unmodified if not a template. * For example: * * Foo<(p.int)>::bar => Foo * r.q(const).Foo<(p.int)>::bar => r.q(const).Foo * Foo => Foo * ----------------------------------------------------------------------------- */ String *SwigType_templateprefix(const SwigType *t) { const char *s = Char(t); const char *c = strstr(s, "<("); return c ? NewStringWithSize(s, c - s) : NewString(s); } /* ----------------------------------------------------------------------------- * SwigType_templatesuffix() * * Returns text after a template substitution. Used to handle scope names * for example: * * Foo<(p.int)>::bar * * returns "::bar" * ----------------------------------------------------------------------------- */ String *SwigType_templatesuffix(const SwigType *t) { const char *c; c = Char(t); while (*c) { if ((*c == '<') && (*(c + 1) == '(')) { int nest = 1; c++; while (*c && nest) { if (*c == '<') nest++; if (*c == '>') nest--; c++; } return NewString(c); } c++; } return NewStringEmpty(); } /* ----------------------------------------------------------------------------- * SwigType_istemplate_templateprefix() * * Combines SwigType_istemplate and SwigType_templateprefix efficiently into one function. * Returns the prefix before the first template definition. * Returns NULL if not a template. * For example: * * Foo<(p.int)>::bar => Foo * r.q(const).Foo<(p.int)>::bar => r.q(const).Foo * Foo => NULL * ----------------------------------------------------------------------------- */ String *SwigType_istemplate_templateprefix(const SwigType *t) { const char *s = Char(t); const char *c = strstr(s, "<("); return c ? NewStringWithSize(s, c - s) : 0; } /* ----------------------------------------------------------------------------- * SwigType_istemplate_only_templateprefix() * * Similar to SwigType_istemplate_templateprefix() but only returns the template * prefix if the type is just the template and not a subtype/symbol within the template. * Returns NULL if not a template or is a template with a symbol within the template. * For example: * * Foo<(p.int)> => Foo * Foo<(p.int)>::bar => NULL * r.q(const).Foo<(p.int)> => r.q(const).Foo * r.q(const).Foo<(p.int)>::bar => NULL * Foo => NULL * ----------------------------------------------------------------------------- */ String *SwigType_istemplate_only_templateprefix(const SwigType *t) { int len = Len(t); const char *s = Char(t); if (len >= 4 && strcmp(s + len - 2, ")>") == 0) { const char *c = strstr(s, "<("); return c ? NewStringWithSize(s, c - s) : 0; } else { return 0; } } /* ----------------------------------------------------------------------------- * SwigType_templateargs() * * Returns the template arguments * For example: * * Foo<(p.int)>::bar * * returns "<(p.int)>" * ----------------------------------------------------------------------------- */ String *SwigType_templateargs(const SwigType *t) { const char *c; const char *start; c = Char(t); while (*c) { if ((*c == '<') && (*(c + 1) == '(')) { int nest = 1; start = c; c++; while (*c && nest) { if (*c == '<') nest++; if (*c == '>') nest--; c++; } return NewStringWithSize(start, c - start); } c++; } return 0; } /* ----------------------------------------------------------------------------- * SwigType_istemplate() * * Tests a type to see if it includes template parameters * ----------------------------------------------------------------------------- */ int SwigType_istemplate(const SwigType *t) { char *ct = Char(t); ct = strstr(ct, "<("); if (ct && (strstr(ct + 2, ")>"))) return 1; return 0; } /* ----------------------------------------------------------------------------- * SwigType_base() * * This function returns the base of a type. For example, if you have a * type "p.p.int", the function would return "int". * ----------------------------------------------------------------------------- */ SwigType *SwigType_base(const SwigType *t) { char *c; char *lastop = 0; c = Char(t); lastop = c; /* Search for the last type constructor separator '.' */ while (*c) { if (*c == '.') { if (*(c + 1)) { lastop = c + 1; } c++; continue; } if (*c == '<') { /* Skip over template---it's part of the base name */ int ntemp = 1; c++; while ((*c) && (ntemp > 0)) { if (*c == '>') ntemp--; else if (*c == '<') ntemp++; c++; } if (ntemp) break; continue; } if (*c == '(') { /* Skip over params */ int nparen = 1; c++; while ((*c) && (nparen > 0)) { if (*c == '(') nparen++; else if (*c == ')') nparen--; c++; } if (nparen) break; continue; } c++; } return NewString(lastop); } /* ----------------------------------------------------------------------------- * SwigType_prefix() * * Returns the prefix of a datatype. For example, the prefix of the * type "p.p.int" is "p.p.". * ----------------------------------------------------------------------------- */ String *SwigType_prefix(const SwigType *t) { char *c, *d; String *r = 0; c = Char(t); d = c + strlen(c); /* Check for a type constructor */ if ((d > c) && (*(d - 1) == '.')) d--; while (d > c) { d--; if (*d == '>') { int nest = 1; d--; while ((d > c) && (nest)) { if (*d == '>') nest++; if (*d == '<') nest--; d--; } } if (*d == ')') { /* Skip over params */ int nparen = 1; d--; while ((d > c) && (nparen)) { if (*d == ')') nparen++; if (*d == '(') nparen--; d--; } } if (*d == '.') { char t = *(d + 1); *(d + 1) = 0; r = NewString(c); *(d + 1) = t; return r; } } return NewStringEmpty(); } /* ----------------------------------------------------------------------------- * SwigType_strip_qualifiers() * * Strip all qualifiers from a type and return a new type * ----------------------------------------------------------------------------- */ SwigType *SwigType_strip_qualifiers(const SwigType *t) { static Hash *memoize_stripped = 0; SwigType *r; List *l; Iterator ei; if (!memoize_stripped) memoize_stripped = NewHash(); r = Getattr(memoize_stripped, t); if (r) return Copy(r); l = SwigType_split(t); r = NewStringEmpty(); for (ei = First(l); ei.item; ei = Next(ei)) { if (SwigType_isqualifier(ei.item)) continue; Append(r, ei.item); } Delete(l); { String *key, *value; key = Copy(t); value = Copy(r); Setattr(memoize_stripped, key, value); Delete(key); Delete(value); } return r; } /* ----------------------------------------------------------------------------- * SwigType_strip_single_qualifier() * * If the type contains a qualifier, strip one qualifier and return a new type. * The left most qualifier is stripped first (when viewed as C source code) but * this is the equivalent to the right most qualifier using SwigType notation. * Example: * r.q(const).p.q(const).int => r.q(const).p.int * r.q(const).p.int => r.p.int * r.p.int => r.p.int * ----------------------------------------------------------------------------- */ SwigType *SwigType_strip_single_qualifier(const SwigType *t) { static Hash *memoize_stripped = 0; SwigType *r = 0; List *l; int numitems; if (!memoize_stripped) memoize_stripped = NewHash(); r = Getattr(memoize_stripped, t); if (r) return Copy(r); l = SwigType_split(t); numitems = Len(l); if (numitems >= 2) { int item; /* iterate backwards from last but one item */ for (item = numitems - 2; item >= 0; --item) { String *subtype = Getitem(l, item); if (SwigType_isqualifier(subtype)) { Iterator it; Delitem(l, item); r = NewStringEmpty(); for (it = First(l); it.item; it = Next(it)) { Append(r, it.item); } break; } } } if (!r) r = Copy(t); Delete(l); { String *key, *value; key = Copy(t); value = Copy(r); Setattr(memoize_stripped, key, value); Delete(key); Delete(value); } return r; } swig-3.0.2/Source/Swig/swigopt.h0000664000175000017500000000156712343605122016372 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swigopt.h * * Header file for the SWIG command line processing functions * ----------------------------------------------------------------------------- */ extern void Swig_init_args(int argc, char **argv); extern void Swig_mark_arg(int n); extern int Swig_check_marked(int n); extern void Swig_check_options(int check_input); extern void Swig_arg_error(void); swig-3.0.2/Source/Swig/swigfile.h0000664000175000017500000000400612343605122016476 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swigfile.h * * File handling functions in the SWIG core * ----------------------------------------------------------------------------- */ extern List *Swig_add_directory(const_String_or_char_ptr dirname); extern void Swig_push_directory(const_String_or_char_ptr dirname); extern void Swig_pop_directory(void); extern String *Swig_last_file(void); extern List *Swig_search_path(void); extern FILE *Swig_include_open(const_String_or_char_ptr name); extern FILE *Swig_open(const_String_or_char_ptr name); extern String *Swig_read_file(FILE *f); extern String *Swig_include(const_String_or_char_ptr name); extern String *Swig_include_sys(const_String_or_char_ptr name); extern int Swig_insert_file(const_String_or_char_ptr name, File *outfile); extern void Swig_set_push_dir(int dopush); extern int Swig_get_push_dir(void); extern void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile); extern File *Swig_filebyname(const_String_or_char_ptr filename); extern String *Swig_file_extension(const_String_or_char_ptr filename); extern String *Swig_file_basename(const_String_or_char_ptr filename); extern String *Swig_file_filename(const_String_or_char_ptr filename); extern String *Swig_file_dirname(const_String_or_char_ptr filename); extern void Swig_file_debug_set(); /* Delimiter used in accessing files and directories */ #if defined(MACSWIG) # define SWIG_FILE_DELIMITER ":" #elif defined(_WIN32) # define SWIG_FILE_DELIMITER "\\" #else # define SWIG_FILE_DELIMITER "/" #endif swig-3.0.2/Source/Swig/typesys.c0000664000175000017500000017004412343605122016406 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * typesys.c * * SWIG type system management. These functions are used to manage * the C++ type system including typenames, typedef, type scopes, * inheritance, and namespaces. Generation of support code for the * run-time type checker is also handled here. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "cparse.h" /* ----------------------------------------------------------------------------- * Synopsis * * The purpose of this module is to manage type names and scoping issues related * to the C++ type system. The primary use is tracking typenames through typedef * and inheritance. * * New typenames are introduced by typedef, class, and enum declarations. * Each type is declared in a scope. This is either the global scope, a * class, or a namespace. For example: * * typedef int A; // Typename A, in global scope * namespace Foo { * typedef int A; // Typename A, in scope Foo:: * } * class Bar { // Typename Bar, in global scope * typedef int A; // Typename A, in scope Bar:: * } * * To manage scopes, the type system is constructed as a tree of hash tables. Each * hash table contains the following attributes: * * "name" - Scope name * "qname" - Fully qualified typename * "typetab" - Type table containing typenames and typedef information * "symtab" - Hash table of symbols defined in a scope * "inherit" - List of inherited scopes * "parent" - Parent scope * * Typedef information is stored in the "typetab" hash table. For example, * if you have these declarations: * * typedef int A; * typedef A B; * typedef B *C; * * typetab is built as follows: * * "A" : "int" * "B" : "A" * "C" : "p.B" * * To resolve a type back to its root type, one repeatedly expands on the type base. * For example: * * C *[40] ---> a(40).p.C (string type representation, see stype.c) * ---> a(40).p.p.B (C --> p.B) * ---> a(40).p.p.A (B --> A) * ---> a(40).p.p.int (A --> int) * * For inheritance, SWIG tries to resolve types back to the base class. For instance, if * you have this: * * class Foo { * public: * typedef int Integer; * }; * * class Bar : public Foo { * void blah(Integer x); * }; * * The argument type of Bar::blah will be set to Foo::Integer. * * The scope-inheritance mechanism is used to manage C++ namespace aliases. * For example, if you have this: * * namespace Foo { * typedef int Integer; * } * * namespace F = Foo; * * In this case, "F::" is defined as a scope that "inherits" from Foo. Internally, * "F::" will merely be an empty scope that refers to Foo. SWIG will never * place new type information into a namespace alias---attempts to do so * will generate a warning message (in the parser) and will place information into * Foo instead. * *----------------------------------------------------------------------------- */ static Typetab *current_scope = 0; /* Current type scope */ static Hash *current_typetab = 0; /* Current type table */ static Hash *current_symtab = 0; /* Current symbol table */ static Typetab *global_scope = 0; /* The global scope */ static Hash *scopes = 0; /* Hash table containing fully qualified scopes */ /* Performance optimization */ #define SWIG_TYPEDEF_RESOLVE_CACHE static Hash *typedef_resolve_cache = 0; static Hash *typedef_all_cache = 0; static Hash *typedef_qualified_cache = 0; static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix); /* common attribute keys, to avoid calling find_key all the times */ /* Enable this one if your language fully support SwigValueWrapper. Leaving at '0' keeps the old swig behavior, which is not always safe, but is well known. Setting at '1' activates the new scheme, which is always safe but it requires all the typemaps to be ready for that. */ static int value_wrapper_mode = 0; int Swig_value_wrapper_mode(int mode) { value_wrapper_mode = mode; return mode; } static void flush_cache() { typedef_resolve_cache = 0; typedef_all_cache = 0; typedef_qualified_cache = 0; } /* Initialize the scoping system */ void SwigType_typesystem_init() { if (global_scope) Delete(global_scope); if (scopes) Delete(scopes); current_scope = NewHash(); global_scope = current_scope; Setattr(current_scope, "name", ""); /* No name for global scope */ current_typetab = NewHash(); Setattr(current_scope, "typetab", current_typetab); current_symtab = 0; scopes = NewHash(); Setattr(scopes, "", current_scope); } /* ----------------------------------------------------------------------------- * SwigType_typedef() * * Defines a new typedef in the current scope. Returns -1 if the type name is * already defined. * ----------------------------------------------------------------------------- */ int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name) { if (Getattr(current_typetab, name)) return -1; /* Already defined */ if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */ return 0; } /* Check if 'type' is already a scope. If so, we create an alias in the type system for it. This is needed to make strange nested scoping problems work correctly. */ { Typetab *t = SwigType_find_scope(current_scope, type); if (t) { SwigType_new_scope(name); SwigType_inherit_scope(t); SwigType_pop_scope(); } } Setattr(current_typetab, name, type); flush_cache(); return 0; } /* ----------------------------------------------------------------------------- * SwigType_typedef_class() * * Defines a class in the current scope. * ----------------------------------------------------------------------------- */ int SwigType_typedef_class(const_String_or_char_ptr name) { String *cname; /* Printf(stdout,"class : '%s'\n", name); */ if (Getattr(current_typetab, name)) return -1; /* Already defined */ cname = NewString(name); Setmeta(cname, "class", "1"); Setattr(current_typetab, cname, cname); Delete(cname); flush_cache(); return 0; } /* ----------------------------------------------------------------------------- * SwigType_scope_name() * * Returns the qualified scope name of a type table * ----------------------------------------------------------------------------- */ String *SwigType_scope_name(Typetab *ttab) { String *qname = NewString(Getattr(ttab, "name")); ttab = Getattr(ttab, "parent"); while (ttab) { String *pname = Getattr(ttab, "name"); if (Len(pname)) { Insert(qname, 0, "::"); Insert(qname, 0, pname); } ttab = Getattr(ttab, "parent"); } return qname; } /* ----------------------------------------------------------------------------- * SwigType_new_scope() * * Creates a new scope * ----------------------------------------------------------------------------- */ void SwigType_new_scope(const_String_or_char_ptr name) { Typetab *s; Hash *ttab; String *qname; if (!name) { name = ""; } s = NewHash(); Setattr(s, "name", name); Setattr(s, "parent", current_scope); ttab = NewHash(); Setattr(s, "typetab", ttab); /* Build fully qualified name and */ qname = SwigType_scope_name(s); Setattr(scopes, qname, s); Setattr(s, "qname", qname); Delete(qname); current_scope = s; current_typetab = ttab; current_symtab = 0; flush_cache(); } /* ----------------------------------------------------------------------------- * SwigType_inherit_scope() * * Makes the current scope inherit from another scope. This is used for both * C++ class inheritance, namespaces, and namespace aliases. * ----------------------------------------------------------------------------- */ void SwigType_inherit_scope(Typetab *scope) { List *inherits; int i, len; inherits = Getattr(current_scope, "inherit"); if (!inherits) { inherits = NewList(); Setattr(current_scope, "inherit", inherits); Delete(inherits); } assert(scope != current_scope); len = Len(inherits); for (i = 0; i < len; i++) { Node *n = Getitem(inherits, i); if (n == scope) return; } Append(inherits, scope); } /* ----------------------------------------------------------------------------- * SwigType_scope_alias() * * Creates a scope-alias. * ----------------------------------------------------------------------------- */ void SwigType_scope_alias(String *aliasname, Typetab *ttab) { String *q; /* Printf(stdout,"alias: '%s' '%p'\n", aliasname, ttab); */ q = SwigType_scope_name(current_scope); if (Len(q)) { Append(q, "::"); } Append(q, aliasname); Setattr(scopes, q, ttab); flush_cache(); } /* ----------------------------------------------------------------------------- * SwigType_using_scope() * * Import another scope into this scope. * ----------------------------------------------------------------------------- */ void SwigType_using_scope(Typetab *scope) { SwigType_inherit_scope(scope); { List *ulist; int i, len; ulist = Getattr(current_scope, "using"); if (!ulist) { ulist = NewList(); Setattr(current_scope, "using", ulist); Delete(ulist); } assert(scope != current_scope); len = Len(ulist); for (i = 0; i < len; i++) { Typetab *n = Getitem(ulist, i); if (n == scope) return; } Append(ulist, scope); } flush_cache(); } /* ----------------------------------------------------------------------------- * SwigType_pop_scope() * * Pop off the last scope and perform a merge operation. Returns the hash * table for the scope that was popped off. * ----------------------------------------------------------------------------- */ Typetab *SwigType_pop_scope() { Typetab *t, *old = current_scope; t = Getattr(current_scope, "parent"); if (!t) t = global_scope; current_scope = t; current_typetab = Getattr(t, "typetab"); current_symtab = Getattr(t, "symtab"); flush_cache(); return old; } /* ----------------------------------------------------------------------------- * SwigType_set_scope() * * Set the scope. Returns the old scope. * ----------------------------------------------------------------------------- */ Typetab *SwigType_set_scope(Typetab *t) { Typetab *old = current_scope; if (!t) t = global_scope; current_scope = t; current_typetab = Getattr(t, "typetab"); current_symtab = Getattr(t, "symtab"); flush_cache(); return old; } /* ----------------------------------------------------------------------------- * SwigType_attach_symtab() * * Attaches a symbol table to a type scope * ----------------------------------------------------------------------------- */ void SwigType_attach_symtab(Symtab *sym) { Setattr(current_scope, "symtab", sym); current_symtab = sym; } /* ----------------------------------------------------------------------------- * SwigType_print_scope() * * Debugging function for printing out current scope * ----------------------------------------------------------------------------- */ void SwigType_print_scope(void) { Hash *ttab; Iterator i, j; Printf(stdout, "SCOPES start =======================================\n"); for (i = First(scopes); i.key; i = Next(i)) { Printf(stdout, "-------------------------------------------------------------\n"); ttab = Getattr(i.item, "typetab"); Printf(stdout, "Type scope '%s' (%p)\n", i.key, i.item); { List *inherit = Getattr(i.item, "inherit"); if (inherit) { Iterator j; for (j = First(inherit); j.item; j = Next(j)) { Printf(stdout, " Inherits from '%s' (%p)\n", Getattr(j.item, "qname"), j.item); } } } for (j = First(ttab); j.key; j = Next(j)) { Printf(stdout, "%40s -> %s\n", j.key, j.item); } } Printf(stdout, "SCOPES finish =======================================\n"); } static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) { Typetab *ss; Typetab *s_orig = s; String *nnameprefix = 0; static int check_parent = 1; if (Getmark(s)) return 0; Setmark(s, 1); if (SwigType_istemplate(nameprefix)) { nnameprefix = SwigType_typedef_resolve_all(nameprefix); nameprefix = nnameprefix; } ss = s; while (ss) { String *full; String *qname = Getattr(ss, "qname"); if (qname) { full = NewStringf("%s::%s", qname, nameprefix); } else { full = NewString(nameprefix); } if (Getattr(scopes, full)) { s = Getattr(scopes, full); } else { s = 0; } Delete(full); if (s) { if (nnameprefix) Delete(nnameprefix); Setmark(s_orig, 0); return s; } if (!s) { /* Check inheritance */ List *inherit; inherit = Getattr(ss, "using"); if (inherit) { Typetab *ttab; int i, len; len = Len(inherit); for (i = 0; i < len; i++) { int oldcp = check_parent; ttab = Getitem(inherit, i); check_parent = 0; s = SwigType_find_scope(ttab, nameprefix); check_parent = oldcp; if (s) { if (nnameprefix) Delete(nnameprefix); Setmark(s_orig, 0); return s; } } } } if (!check_parent) break; ss = Getattr(ss, "parent"); } if (nnameprefix) Delete(nnameprefix); Setmark(s_orig, 0); return 0; } /* ----------------------------------------------------------------------------- * typedef_resolve() * * Resolves a typedef and returns a new type string. Returns 0 if there is no * typedef mapping. base is a name without qualification. * Internal function. * ----------------------------------------------------------------------------- */ static Typetab *resolved_scope = 0; /* Internal function */ static SwigType *_typedef_resolve(Typetab *s, String *base, int look_parent) { Hash *ttab; SwigType *type = 0; List *inherit; Typetab *parent; /* if (!s) return 0; *//* now is checked bellow */ /* Printf(stdout,"Typetab %s : %s\n", Getattr(s,"name"), base); */ if (!Getmark(s)) { Setmark(s, 1); ttab = Getattr(s, "typetab"); type = Getattr(ttab, base); if (type) { resolved_scope = s; Setmark(s, 0); } else { /* Hmmm. Not found in my scope. It could be in an inherited scope */ inherit = Getattr(s, "inherit"); if (inherit) { int i, len; len = Len(inherit); for (i = 0; i < len; i++) { type = _typedef_resolve(Getitem(inherit, i), base, 0); if (type) { Setmark(s, 0); break; } } } if (!type) { /* Hmmm. Not found in my scope. check parent */ if (look_parent) { parent = Getattr(s, "parent"); type = parent ? _typedef_resolve(parent, base, 1) : 0; } } Setmark(s, 0); } } return type; } /* ----------------------------------------------------------------------------- * template_parameters_resolve() * * For use with templates only. The template parameters are resolved. If none * of the parameters can be resolved, zero is returned. * ----------------------------------------------------------------------------- */ static String *template_parameters_resolve(const String *base) { List *tparms; String *suffix; String *type; int i, sz; int rep = 0; type = SwigType_templateprefix(base); suffix = SwigType_templatesuffix(base); Append(type, "<("); tparms = SwigType_parmlist(base); sz = Len(tparms); for (i = 0; i < sz; i++) { SwigType *tpr; SwigType *tp = Getitem(tparms, i); if (!rep) { tpr = SwigType_typedef_resolve(tp); } else { tpr = 0; } if (tpr) { Append(type, tpr); Delete(tpr); rep = 1; } else { Append(type, tp); } if ((i + 1) < sz) Append(type, ","); } Append(type, ")>"); Append(type, suffix); Delete(suffix); Delete(tparms); if (!rep) { Delete(type); type = 0; } return type; } static SwigType *typedef_resolve(Typetab *s, String *base) { return _typedef_resolve(s, base, 1); } /* ----------------------------------------------------------------------------- * SwigType_typedef_resolve() * ----------------------------------------------------------------------------- */ /* #define SWIG_DEBUG */ SwigType *SwigType_typedef_resolve(const SwigType *t) { String *base; String *type = 0; String *r = 0; Typetab *s; Hash *ttab; String *namebase = 0; String *nameprefix = 0, *rnameprefix = 0; int newtype = 0; resolved_scope = 0; #ifdef SWIG_TYPEDEF_RESOLVE_CACHE if (!typedef_resolve_cache) { typedef_resolve_cache = NewHash(); } r = Getattr(typedef_resolve_cache, t); if (r) { resolved_scope = Getmeta(r, "scope"); return Copy(r); } #endif base = SwigType_base(t); #ifdef SWIG_DEBUG Printf(stdout, "base = '%s' t='%s'\n", base, t); #endif if (SwigType_issimple(base)) { s = current_scope; ttab = current_typetab; if (strncmp(Char(base), "::", 2) == 0) { s = global_scope; ttab = Getattr(s, "typetab"); Delitem(base, 0); Delitem(base, 0); } /* Do a quick check in the local scope */ type = Getattr(ttab, base); if (type) { resolved_scope = s; } if (!type) { /* Didn't find in this scope. We need to do a little more searching */ if (Swig_scopename_check(base)) { /* A qualified name. */ Swig_scopename_split(base, &nameprefix, &namebase); #ifdef SWIG_DEBUG Printf(stdout, "nameprefix = '%s'\n", nameprefix); #endif if (nameprefix) { rnameprefix = SwigType_typedef_resolve(nameprefix); if(rnameprefix != NULL) { #ifdef SWIG_DEBUG Printf(stdout, "nameprefix '%s' is a typedef to '%s'\n", nameprefix, rnameprefix); #endif type = Copy(namebase); Insert(type, 0, "::"); Insert(type, 0, rnameprefix); if (strncmp(Char(type), "::", 2) == 0) { Delitem(type, 0); Delitem(type, 0); } newtype = 1; } else { /* Name had a prefix on it. See if we can locate the proper scope for it */ String *rnameprefix = template_parameters_resolve(nameprefix); nameprefix = rnameprefix ? Copy(rnameprefix) : nameprefix; Delete(rnameprefix); s = SwigType_find_scope(s, nameprefix); /* Couldn't locate a scope for the type. */ if (!s) { Delete(base); Delete(namebase); Delete(nameprefix); r = 0; goto return_result; } /* Try to locate the name starting in the scope */ #ifdef SWIG_DEBUG Printf(stdout, "namebase = '%s'\n", namebase); #endif type = typedef_resolve(s, namebase); if (type && resolved_scope) { /* we need to look for the resolved type, this will also fix the resolved_scope if 'type' and 'namebase' are declared in different scopes */ String *rtype = 0; rtype = typedef_resolve(resolved_scope, type); if (rtype) type = rtype; } #ifdef SWIG_DEBUG Printf(stdout, "%s type = '%s'\n", Getattr(s, "name"), type); #endif if ((type) && (!Swig_scopename_check(type)) && resolved_scope) { Typetab *rtab = resolved_scope; String *qname = Getattr(resolved_scope, "qname"); /* If qualified *and* the typename is defined from the resolved scope, we qualify */ if ((qname) && typedef_resolve(resolved_scope, type)) { type = Copy(type); Insert(type, 0, "::"); Insert(type, 0, qname); #ifdef SWIG_DEBUG Printf(stdout, "qual %s \n", type); #endif newtype = 1; } resolved_scope = rtab; } } } else { /* Name is unqualified. */ type = typedef_resolve(s, base); } } else { /* Name is unqualified. */ type = typedef_resolve(s, base); } } if (type && (Equal(base, type))) { if (newtype) Delete(type); Delete(base); Delete(namebase); Delete(nameprefix); r = 0; goto return_result; } /* If the type is a template, and no typedef was found, we need to check the template arguments one by one to see if they can be resolved. */ if (!type && SwigType_istemplate(base)) { newtype = 1; type = template_parameters_resolve(base); } if (namebase) Delete(namebase); if (nameprefix) Delete(nameprefix); } else { if (SwigType_isfunction(base)) { List *parms; int i, sz; int rep = 0; type = NewString("f("); newtype = 1; parms = SwigType_parmlist(base); sz = Len(parms); for (i = 0; i < sz; i++) { SwigType *tpr; SwigType *tp = Getitem(parms, i); if (!rep) { tpr = SwigType_typedef_resolve(tp); } else { tpr = 0; } if (tpr) { Append(type, tpr); Delete(tpr); rep = 1; } else { Append(type, tp); } if ((i + 1) < sz) Append(type, ","); } Append(type, ")."); Delete(parms); if (!rep) { Delete(type); type = 0; } } else if (SwigType_ismemberpointer(base)) { String *rt; String *mtype = SwigType_parm(base); rt = SwigType_typedef_resolve(mtype); if (rt) { type = NewStringf("m(%s).", rt); newtype = 1; Delete(rt); } Delete(mtype); } else { type = 0; } } r = SwigType_prefix(t); if (!type) { if (r && Len(r)) { char *cr = Char(r); if ((strstr(cr, "f(") || (strstr(cr, "m(")))) { SwigType *rt = SwigType_typedef_resolve(r); if (rt) { Delete(r); Append(rt, base); Delete(base); r = rt; goto return_result; } } } Delete(r); Delete(base); r = 0; goto return_result; } Delete(base); /* If 'type' is an array, then the right-most qualifier in 'r' should be added to 'type' after the array qualifier, so that given a(7).q(volatile).double myarray // typedef volatile double[7] myarray; the type q(const).myarray // const myarray becomes a(7).q(const volatile).double // const volatile double[7] and NOT q(const).a(7).q(volatile).double // non-sensical type */ if (r && Len(r) && SwigType_isarray(type)) { List *r_elem; String *r_qual; int r_sz; r_elem = SwigType_split(r); r_sz = Len(r_elem); r_qual = Getitem(r_elem, r_sz-1); if (SwigType_isqualifier(r_qual)) { String *new_r; String *new_type; List *type_elem; String *type_qual; String *r_qual_arg; int i, type_sz; type_elem = SwigType_split(type); type_sz = Len(type_elem); for (i = 0; i < type_sz; ++i) { String *e = Getitem(type_elem, i); if (!SwigType_isarray(e)) break; } type_qual = Copy(Getitem(type_elem, i)); r_qual_arg = SwigType_parm(r_qual); SwigType_add_qualifier(type_qual, r_qual_arg); Delete(r_qual_arg); Setitem(type_elem, i, type_qual); new_r = NewStringEmpty(); for (i = 0; i < r_sz-1; ++i) { Append(new_r, Getitem(r_elem, i)); } new_type = NewStringEmpty(); for (i = 0; i < type_sz; ++i) { Append(new_type, Getitem(type_elem, i)); } #ifdef SWIG_DEBUG Printf(stdout, "r+type='%s%s' new_r+new_type='%s%s'\n", r, type, new_r, new_type); #endif Delete(r); r = new_r; newtype = 1; type = new_type; Delete(type_elem); } Delete(r_elem); } Append(r, type); if (newtype) { Delete(type); } return_result: #ifdef SWIG_TYPEDEF_RESOLVE_CACHE { String *key = NewString(t); if (r) { SwigType *r1; Setattr(typedef_resolve_cache, key, r); Setmeta(r, "scope", resolved_scope); r1 = Copy(r); Delete(r); r = r1; } Delete(key); } #endif return r; } /* ----------------------------------------------------------------------------- * SwigType_typedef_resolve_all() * * Fully resolve a type down to its most basic datatype * ----------------------------------------------------------------------------- */ SwigType *SwigType_typedef_resolve_all(const SwigType *t) { SwigType *n; SwigType *r; int count = 0; /* Check to see if the typedef resolve has been done before by checking the cache */ if (!typedef_all_cache) { typedef_all_cache = NewHash(); } r = Getattr(typedef_all_cache, t); if (r) { return Copy(r); } /* Recursively resolve the typedef */ r = NewString(t); while ((n = SwigType_typedef_resolve(r))) { Delete(r); r = n; if (++count >= 512) { Swig_error(Getfile(t), Getline(t), "Recursive typedef detected resolving '%s' to '%s' to '%s' and so on...\n", SwigType_str(t, 0), SwigType_str(SwigType_typedef_resolve(t), 0), SwigType_str(SwigType_typedef_resolve(SwigType_typedef_resolve(t)), 0)); break; } } /* Add the typedef to the cache for next time it is looked up */ { String *key; SwigType *rr = Copy(r); key = NewString(t); Setattr(typedef_all_cache, key, rr); Delete(key); Delete(rr); } return r; } /* ----------------------------------------------------------------------------- * SwigType_typedef_qualified() * * Given a type declaration, this function tries to fully qualify it according to * typedef scope rules. * If the unary scope operator (::) is used as a prefix to the type to denote global * scope, it is left in place. * ----------------------------------------------------------------------------- */ SwigType *SwigType_typedef_qualified(const SwigType *t) { List *elements; String *result; int i, len; if (!typedef_qualified_cache) typedef_qualified_cache = NewHash(); result = Getattr(typedef_qualified_cache, t); if (result) { String *rc = Copy(result); return rc; } result = NewStringEmpty(); elements = SwigType_split(t); len = Len(elements); for (i = 0; i < len; i++) { String *ty = 0; String *e = Getitem(elements, i); if (SwigType_issimple(e)) { if (!SwigType_istemplate(e)) { String *isenum = 0; if (SwigType_isenum(e)) { isenum = NewString("enum "); ty = NewString(Char(e) + 5); e = ty; } resolved_scope = 0; if (typedef_resolve(current_scope, e) && resolved_scope) { /* resolved_scope contains the scope that actually resolved the symbol */ String *qname = Getattr(resolved_scope, "qname"); if (qname) { Insert(e, 0, "::"); Insert(e, 0, qname); } } else { if (Swig_scopename_check(e)) { String *qlast; String *qname; Swig_scopename_split(e, &qname, &qlast); if (qname) { String *tqname = SwigType_typedef_qualified(qname); Clear(e); Printf(e, "%s::%s", tqname, qlast); Delete(qname); Delete(tqname); } Delete(qlast); /* Automatic template instantiation might go here??? */ } else { /* It's a bare name. It's entirely possible, that the name is part of a namespace. We'll check this by unrolling out of the current scope */ Typetab *cs = current_scope; while (cs) { String *qs = SwigType_scope_name(cs); if (Len(qs)) { Append(qs, "::"); } Append(qs, e); if (Getattr(scopes, qs)) { Clear(e); Append(e, qs); Delete(qs); break; } Delete(qs); cs = Getattr(cs, "parent"); } } } if (isenum) { Insert(e, 0, isenum); Delete(isenum); } } else { /* Template. We need to qualify template parameters as well as the template itself */ String *tprefix, *qprefix; String *tsuffix; Iterator pi; Parm *p; List *parms; ty = Swig_symbol_template_deftype(e, current_symtab); /* String *dt = Swig_symbol_template_deftype(e, current_symtab); ty = Swig_symbol_type_qualify(dt, 0); */ e = ty; parms = SwigType_parmlist(e); tprefix = SwigType_templateprefix(e); tsuffix = SwigType_templatesuffix(e); qprefix = SwigType_typedef_qualified(tprefix); Append(qprefix, "<("); pi = First(parms); while ((p = pi.item)) { String *qt = SwigType_typedef_qualified(p); if (Equal(qt, p)) { /* && (!Swig_scopename_check(qt))) */ /* No change in value. It is entirely possible that the parameter is an integer value. If there is a symbol table associated with this scope, we're going to check for this */ if (current_symtab) { Node *lastnode = 0; String *value = Copy(p); while (1) { Node *n = Swig_symbol_clookup(value, current_symtab); if (n == lastnode) break; lastnode = n; if (n) { char *ntype = Char(nodeType(n)); if (strcmp(ntype, "enumitem") == 0) { /* An enum item. Generate a fully qualified name */ String *qn = Swig_symbol_qualified(n); if (Len(qn)) { Append(qn, "::"); Append(qn, Getattr(n, "name")); Delete(value); value = qn; continue; } else { Delete(qn); break; } } else if ((strcmp(ntype, "cdecl") == 0) && (Getattr(n, "value"))) { Delete(value); value = Copy(Getattr(n, "value")); continue; } } break; } Append(qprefix, value); Delete(value); } else { Append(qprefix, p); } } else { Append(qprefix, qt); } Delete(qt); pi = Next(pi); if (pi.item) { Append(qprefix, ","); } } Append(qprefix, ")>"); Append(qprefix, tsuffix); Delete(tsuffix); Clear(e); Append(e, qprefix); Delete(tprefix); Delete(qprefix); Delete(parms); /* Delete(dt); */ } Append(result, e); Delete(ty); } else if (SwigType_isfunction(e)) { List *parms = SwigType_parmlist(e); String *s = NewString("f("); Iterator pi; pi = First(parms); while (pi.item) { String *pq = SwigType_typedef_qualified(pi.item); Append(s, pq); Delete(pq); pi = Next(pi); if (pi.item) { Append(s, ","); } } Append(s, ")."); Append(result, s); Delete(s); Delete(parms); } else if (SwigType_isarray(e)) { String *ndim; String *dim = SwigType_parm(e); ndim = Swig_symbol_string_qualify(dim, 0); Printf(result, "a(%s).", ndim); Delete(dim); Delete(ndim); } else { Append(result, e); } } Delete(elements); { String *key, *cresult; key = NewString(t); cresult = NewString(result); Setattr(typedef_qualified_cache, key, cresult); Delete(key); Delete(cresult); } return result; } /* ----------------------------------------------------------------------------- * SwigType_istypedef() * * Checks a typename to see if it is a typedef. * ----------------------------------------------------------------------------- */ int SwigType_istypedef(const SwigType *t) { String *type; type = SwigType_typedef_resolve(t); if (type) { Delete(type); return 1; } else { return 0; } } /* ----------------------------------------------------------------------------- * SwigType_typedef_using() * * Processes a 'using' declaration to import types from one scope into another. * Name is a qualified name like A::B. * ----------------------------------------------------------------------------- */ int SwigType_typedef_using(const_String_or_char_ptr name) { String *base; String *td; String *prefix; Typetab *s; Typetab *tt = 0; String *defined_name = 0; /* Printf(stdout,"using %s\n", name); */ if (!Swig_scopename_check(name)) return -1; /* Not properly qualified */ base = Swig_scopename_last(name); /* See if the base is already defined in this scope */ if (Getattr(current_typetab, base)) { Delete(base); return -1; } /* See if the using name is a scope */ /* tt = SwigType_find_scope(current_scope,name); Printf(stdout,"tt = %p, name = '%s'\n", tt, name); */ /* We set up a typedef B --> A::B */ Setattr(current_typetab, base, name); /* Find the scope name where the symbol is defined */ td = SwigType_typedef_resolve(name); /* Printf(stdout,"td = '%s' %p\n", td, resolved_scope); */ if (resolved_scope) { defined_name = Getattr(resolved_scope, "qname"); if (defined_name) { defined_name = Copy(defined_name); Append(defined_name, "::"); Append(defined_name, base); /* Printf(stdout,"defined_name = '%s'\n", defined_name); */ tt = SwigType_find_scope(current_scope, defined_name); } } if (td) Delete(td); /* Figure out the scope the using directive refers to */ { prefix = Swig_scopename_prefix(name); if (prefix) { s = SwigType_find_scope(current_scope, prefix); if (s) { Hash *ttab = Getattr(s, "typetab"); if (!Getattr(ttab, base) && defined_name) { Setattr(ttab, base, defined_name); } } } } if (tt) { /* Using directive had its own scope. We need to create a new scope for it */ SwigType_new_scope(base); SwigType_inherit_scope(tt); SwigType_pop_scope(); } if (defined_name) Delete(defined_name); Delete(prefix); Delete(base); return 0; } /* ----------------------------------------------------------------------------- * SwigType_isclass() * * Determines if a type defines a class or not. A class is defined by * its type-table entry maps to itself. Note: a pointer to a class is not * a class. * ----------------------------------------------------------------------------- */ int SwigType_isclass(const SwigType *t) { SwigType *qty, *qtys; int isclass = 0; qty = SwigType_typedef_resolve_all(t); qtys = SwigType_strip_qualifiers(qty); if (SwigType_issimple(qtys)) { String *td = SwigType_typedef_resolve(qtys); if (td) { Delete(td); } if (resolved_scope) { isclass = 1; } /* Hmmm. Not a class. If a template, it might be uninstantiated */ if (!isclass) { String *tp = SwigType_istemplate_templateprefix(qtys); if (tp && Strcmp(tp, t) != 0) { isclass = SwigType_isclass(tp); } Delete(tp); } } Delete(qty); Delete(qtys); return isclass; } /* ----------------------------------------------------------------------------- * SwigType_type() * * Returns an integer code describing the datatype. This is only used for * compatibility with SWIG1.1 language modules and is likely to go away once * everything is based on typemaps. * ----------------------------------------------------------------------------- */ int SwigType_type(const SwigType *t) { char *c; /* Check for the obvious stuff */ c = Char(t); if (strncmp(c, "p.", 2) == 0) { if (SwigType_type(c + 2) == T_CHAR) return T_STRING; else if (SwigType_type(c + 2) == T_WCHAR) return T_WSTRING; else return T_POINTER; } if (strncmp(c, "a(", 2) == 0) return T_ARRAY; if (strncmp(c, "r.", 2) == 0) return T_REFERENCE; if (strncmp(c, "z.", 2) == 0) return T_RVALUE_REFERENCE; if (strncmp(c, "m(", 2) == 0) return T_MPOINTER; if (strncmp(c, "q(", 2) == 0) { while (*c && (*c != '.')) c++; if (*c) return SwigType_type(c + 1); return T_ERROR; } if (strncmp(c, "f(", 2) == 0) return T_FUNCTION; /* Look for basic types */ if (strcmp(c, "int") == 0) return T_INT; if (strcmp(c, "long") == 0) return T_LONG; if (strcmp(c, "short") == 0) return T_SHORT; if (strcmp(c, "unsigned") == 0) return T_UINT; if (strcmp(c, "unsigned short") == 0) return T_USHORT; if (strcmp(c, "unsigned long") == 0) return T_ULONG; if (strcmp(c, "unsigned int") == 0) return T_UINT; if (strcmp(c, "char") == 0) return T_CHAR; if (strcmp(c, "signed char") == 0) return T_SCHAR; if (strcmp(c, "unsigned char") == 0) return T_UCHAR; if (strcmp(c, "wchar_t") == 0) return T_WCHAR; if (strcmp(c, "float") == 0) return T_FLOAT; if (strcmp(c, "double") == 0) return T_DOUBLE; if (strcmp(c, "long double") == 0) return T_LONGDOUBLE; if (!cparse_cplusplus && (strcmp(c, "float complex") == 0)) return T_FLTCPLX; if (!cparse_cplusplus && (strcmp(c, "double complex") == 0)) return T_DBLCPLX; if (!cparse_cplusplus && (strcmp(c, "complex") == 0)) return T_COMPLEX; if (strcmp(c, "void") == 0) return T_VOID; if (strcmp(c, "bool") == 0) return T_BOOL; if (strcmp(c, "long long") == 0) return T_LONGLONG; if (strcmp(c, "unsigned long long") == 0) return T_ULONGLONG; if (strncmp(c, "enum ", 5) == 0) return T_INT; if (strcmp(c, "auto") == 0) return T_AUTO; if (strcmp(c, "v(...)") == 0) return T_VARARGS; /* Hmmm. Unknown type */ if (SwigType_istypedef(t)) { int r; SwigType *nt = SwigType_typedef_resolve(t); r = SwigType_type(nt); Delete(nt); return r; } return T_USER; } /* ----------------------------------------------------------------------------- * SwigType_alttype() * * Returns the alternative value type needed in C++ for class value * types. When swig is not sure about using a plain $ltype value, * since the class doesn't have a default constructor, or it can't be * assigned, you will get back 'SwigValueWrapper'. * * This is the default behavior unless: * * 1.- swig detects a default_constructor and 'setallocate:default_constructor' * attribute. * * 2.- swig doesn't mark 'type' as non-assignable. * * 3.- the user specifies that the value wrapper is not needed by using * %feature("novaluewrapper") like so: * * %feature("novaluewrapper") MyOpaqueClass; * class MyOpaqueClass; * * The user can also force the use of the value wrapper with * %feature("valuewrapper"). * ----------------------------------------------------------------------------- */ SwigType *SwigType_alttype(const SwigType *t, int local_tmap) { Node *n; SwigType *w = 0; int use_wrapper = 0; SwigType *td = 0; if (!cparse_cplusplus) return 0; if (value_wrapper_mode == 0) { /* old partial use of SwigValueTypes, it can fail for opaque types */ if (local_tmap) return 0; if (SwigType_isclass(t)) { SwigType *ftd = SwigType_typedef_resolve_all(t); td = SwigType_strip_qualifiers(ftd); Delete(ftd); n = Swig_symbol_clookup(td, 0); if (n) { if (GetFlag(n, "feature:valuewrapper")) { use_wrapper = 1; } else { if (Checkattr(n, "nodeType", "class") && (!Getattr(n, "allocate:default_constructor") || (Getattr(n, "allocate:noassign")))) { use_wrapper = !GetFlag(n, "feature:novaluewrapper") || GetFlag(n, "feature:nodefault"); } } } else { if (SwigType_issimple(td) && SwigType_istemplate(td)) { use_wrapper = !n || !GetFlag(n, "feature:novaluewrapper"); } } } } else { /* safe use of SwigValueTypes, it can fail with some typemaps */ SwigType *ftd = SwigType_typedef_resolve_all(t); td = SwigType_strip_qualifiers(ftd); Delete(ftd); if (SwigType_type(td) == T_USER) { use_wrapper = 1; n = Swig_symbol_clookup(td, 0); if (n) { if ((Checkattr(n, "nodeType", "class") && !Getattr(n, "allocate:noassign") && (Getattr(n, "allocate:default_constructor"))) || (GetFlag(n, "feature:novaluewrapper"))) { use_wrapper = GetFlag(n, "feature:valuewrapper"); } } } } if (use_wrapper) { /* Need a space before the type in case it starts "::" (since the <: * token is a digraph for [ in C++. Also need a space after the * type in case it ends with ">" since then we form the token ">>". */ w = NewStringf("SwigValueWrapper< %s >", td); } Delete(td); return w; } /* ---------------------------------------------------------------------------- * * * * WARNING * * * *** * *** * Don't even think about modifying anything below this line unless you *** * are completely on top of *EVERY* subtle aspect of the C++ type system *** * and you are prepared to suffer endless hours of agony trying to *** * debug the SWIG run-time type checker after you break it. *** * ------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * SwigType_remember() * * This function "remembers" a datatype that was used during wrapper code generation * so that a type-checking table can be generated later on. It is up to the language * modules to actually call this function--it is not done automatically. * * Type tracking is managed through two separate hash tables. The hash 'r_mangled' * is mapping between mangled type names (used in the target language) and * fully-resolved C datatypes used in the source input. The second hash 'r_resolved' * is the inverse mapping that maps fully-resolved C datatypes to all of the mangled * names in the scripting languages. For example, consider the following set of * typedef declarations: * * typedef double Real; * typedef double Float; * typedef double Point[3]; * * Now, suppose that the types 'double *', 'Real *', 'Float *', 'double[3]', and * 'Point' were used in an interface file and "remembered" using this function. * The hash tables would look like this: * * r_mangled { * _p_double : [ p.double, a(3).double ] * _p_Real : [ p.double ] * _p_Float : [ p.double ] * _Point : [ a(3).double ] * * r_resolved { * p.double : [ _p_double, _p_Real, _p_Float ] * a(3).double : [ _p_double, _Point ] * } * * Together these two hash tables can be used to determine type-equivalency between * mangled typenames. To do this, we view the two hash tables as a large graph and * compute the transitive closure. * ----------------------------------------------------------------------------- */ static Hash *r_mangled = 0; /* Hash mapping mangled types to fully resolved types */ static Hash *r_resolved = 0; /* Hash mapping resolved types to mangled types */ static Hash *r_ltype = 0; /* Hash mapping mangled names to their local c type */ static Hash *r_clientdata = 0; /* Hash mapping resolved types to client data */ static Hash *r_mangleddata = 0; /* Hash mapping mangled types to client data */ static Hash *r_remembered = 0; /* Hash of types we remembered already */ static void (*r_tracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0; void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata) { if (!r_mangleddata) { r_mangleddata = NewHash(); } Setattr(r_mangleddata, mangled, clientdata); } void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata) { String *mt; SwigType *lt; Hash *h; SwigType *fr; SwigType *qr; String *tkey; String *cd; Hash *lthash; if (!r_mangled) { r_mangled = NewHash(); r_resolved = NewHash(); r_ltype = NewHash(); r_clientdata = NewHash(); r_remembered = NewHash(); } { String *last; last = Getattr(r_remembered, t); if (last && (Cmp(last, clientdata) == 0)) return; } tkey = Copy(t); cd = clientdata ? NewString(clientdata) : NewStringEmpty(); Setattr(r_remembered, tkey, cd); Delete(tkey); Delete(cd); mt = SwigType_manglestr(t); /* Create mangled string */ if (r_tracefunc) { (*r_tracefunc) (t, mt, (String *) clientdata); } if (SwigType_istypedef(t)) { lt = Copy(t); } else { lt = SwigType_ltype(t); } lthash = Getattr(r_ltype, mt); if (!lthash) { lthash = NewHash(); Setattr(r_ltype, mt, lthash); } Setattr(lthash, lt, "1"); Delete(lt); fr = SwigType_typedef_resolve_all(t); /* Create fully resolved type */ qr = SwigType_typedef_qualified(fr); Delete(fr); /* Added to deal with possible table bug */ fr = SwigType_strip_qualifiers(qr); Delete(qr); /*Printf(stdout,"t = '%s'\n", t); Printf(stdout,"fr= '%s'\n\n", fr); */ if (t) { char *ct = Char(t); if (strchr(ct, '<') && !(strstr(ct, "<("))) { Printf(stdout, "Bad template type passed to SwigType_remember: %s\n", t); assert(0); } } h = Getattr(r_mangled, mt); if (!h) { h = NewHash(); Setattr(r_mangled, mt, h); Delete(h); } Setattr(h, fr, mt); h = Getattr(r_resolved, fr); if (!h) { h = NewHash(); Setattr(r_resolved, fr, h); Delete(h); } Setattr(h, mt, fr); if (clientdata) { String *cd = Getattr(r_clientdata, fr); if (cd) { if (Strcmp(clientdata, cd) != 0) { Printf(stderr, "*** Internal error. Inconsistent clientdata for type '%s'\n", SwigType_str(fr, 0)); Printf(stderr, "*** '%s' != '%s'\n", clientdata, cd); assert(0); } } else { String *cstr = NewString(clientdata); Setattr(r_clientdata, fr, cstr); Delete(cstr); } } /* If the remembered type is a reference, we also remember the pointer version. This is to prevent odd problems with mixing pointers and references--especially when different functions are using different typenames (via typedef). */ if (SwigType_isreference(t)) { SwigType *tt = Copy(t); SwigType_del_reference(tt); SwigType_add_pointer(tt); SwigType_remember_clientdata(tt, clientdata); } else if (SwigType_isrvalue_reference(t)) { SwigType *tt = Copy(t); SwigType_del_rvalue_reference(tt); SwigType_add_pointer(tt); SwigType_remember_clientdata(tt, clientdata); } } void SwigType_remember(const SwigType *ty) { SwigType_remember_clientdata(ty, 0); } void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *) { void (*o) (const SwigType *, String *, String *) = r_tracefunc; r_tracefunc = tf; return o; } /* ----------------------------------------------------------------------------- * SwigType_equivalent_mangle() * * Return a list of all of the mangled typenames that are equivalent to another * mangled name. This works as follows: For each fully qualified C datatype * in the r_mangled hash entry, we collect all of the mangled names from the * r_resolved hash and combine them together in a list (removing duplicate entries). * ----------------------------------------------------------------------------- */ List *SwigType_equivalent_mangle(String *ms, Hash *checked, Hash *found) { List *l; Hash *h; Hash *ch; Hash *mh; if (found) { h = found; } else { h = NewHash(); } if (checked) { ch = checked; } else { ch = NewHash(); } if (Getattr(ch, ms)) goto check_exit; /* Already checked this type */ Setattr(h, ms, "1"); Setattr(ch, ms, "1"); mh = Getattr(r_mangled, ms); if (mh) { Iterator ki; ki = First(mh); while (ki.key) { Hash *rh; if (Getattr(ch, ki.key)) { ki = Next(ki); continue; } Setattr(ch, ki.key, "1"); rh = Getattr(r_resolved, ki.key); if (rh) { Iterator rk; rk = First(rh); while (rk.key) { Setattr(h, rk.key, "1"); SwigType_equivalent_mangle(rk.key, ch, h); rk = Next(rk); } } ki = Next(ki); } } check_exit: if (!found) { l = Keys(h); Delete(h); Delete(ch); return l; } else { return 0; } } /* ----------------------------------------------------------------------------- * SwigType_clientdata_collect() * * Returns the clientdata field for a mangled type-string. * ----------------------------------------------------------------------------- */ static String *SwigType_clientdata_collect(String *ms) { Hash *mh; String *clientdata = 0; if (r_mangleddata) { clientdata = Getattr(r_mangleddata, ms); if (clientdata) return clientdata; } mh = Getattr(r_mangled, ms); if (mh) { Iterator ki; ki = First(mh); while (ki.key) { clientdata = Getattr(r_clientdata, ki.key); if (clientdata) break; ki = Next(ki); } } return clientdata; } /* ----------------------------------------------------------------------------- * SwigType_inherit() * * Record information about inheritance. We keep a hash table that keeps * a mapping between base classes and all of the classes that are derived * from them. * * subclass is a hash that maps base-classes to all of the classes derived from them. * * derived - name of derived class * base - name of base class * cast - additional casting code when casting from derived to base * conversioncode - if set, overrides the default code in the function when casting * from derived to base * ----------------------------------------------------------------------------- */ static Hash *subclass = 0; static Hash *conversions = 0; void SwigType_inherit(String *derived, String *base, String *cast, String *conversioncode) { Hash *h; String *dd = 0; String *bb = 0; if (!subclass) subclass = NewHash(); /* Printf(stdout,"'%s' --> '%s' '%s'\n", derived, base, cast); */ if (SwigType_istemplate(derived)) { String *ty = SwigType_typedef_resolve_all(derived); dd = SwigType_typedef_qualified(ty); derived = dd; Delete(ty); } if (SwigType_istemplate(base)) { String *ty = SwigType_typedef_resolve_all(base); bb = SwigType_typedef_qualified(ty); base = bb; Delete(ty); } /* Printf(stdout,"'%s' --> '%s' '%s'\n", derived, base, cast); */ h = Getattr(subclass, base); if (!h) { h = NewHash(); Setattr(subclass, base, h); Delete(h); } if (!Getattr(h, derived)) { Hash *c = NewHash(); if (cast) Setattr(c, "cast", cast); if (conversioncode) Setattr(c, "convcode", conversioncode); Setattr(h, derived, c); Delete(c); } Delete(dd); Delete(bb); } /* ----------------------------------------------------------------------------- * SwigType_issubtype() * * Determines if a t1 is a subtype of t2, ie, is t1 derived from t2 * ----------------------------------------------------------------------------- */ int SwigType_issubtype(const SwigType *t1, const SwigType *t2) { SwigType *ft1, *ft2; String *b1, *b2; Hash *h; int r = 0; if (!subclass) return 0; ft1 = SwigType_typedef_resolve_all(t1); ft2 = SwigType_typedef_resolve_all(t2); b1 = SwigType_base(ft1); b2 = SwigType_base(ft2); h = Getattr(subclass, b2); if (h) { if (Getattr(h, b1)) { r = 1; } } Delete(ft1); Delete(ft2); Delete(b1); Delete(b2); /* Printf(stdout, "issubtype(%s,%s) --> %d\n", t1, t2, r); */ return r; } /* ----------------------------------------------------------------------------- * SwigType_inherit_equiv() * * Modify the type table to handle C++ inheritance * ----------------------------------------------------------------------------- */ void SwigType_inherit_equiv(File *out) { String *ckey; String *prefix, *base; String *mprefix, *mkey; Hash *sub; Hash *rh; List *rlist; Iterator rk, bk, ck; if (!conversions) conversions = NewHash(); if (!subclass) subclass = NewHash(); rk = First(r_resolved); while (rk.key) { /* rkey is a fully qualified type. We strip all of the type constructors off of it just to get the base */ base = SwigType_base(rk.key); /* Check to see whether the base is recorded in the subclass table */ sub = Getattr(subclass, base); Delete(base); if (!sub) { rk = Next(rk); continue; } /* This type has subclasses. We now need to walk through these subtypes and generate pointer conversion functions */ rh = Getattr(r_resolved, rk.key); rlist = NewList(); for (ck = First(rh); ck.key; ck = Next(ck)) { Append(rlist, ck.key); } /* Printf(stdout,"rk.key = '%s'\n", rk.key); Printf(stdout,"rh = %p '%s'\n", rh,rh); */ bk = First(sub); while (bk.key) { prefix = SwigType_prefix(rk.key); Append(prefix, bk.key); /* Printf(stdout,"set %p = '%s' : '%s'\n", rh, SwigType_manglestr(prefix),prefix); */ mprefix = SwigType_manglestr(prefix); Setattr(rh, mprefix, prefix); mkey = SwigType_manglestr(rk.key); ckey = NewStringf("%s+%s", mprefix, mkey); if (!Getattr(conversions, ckey)) { String *convname = NewStringf("%sTo%s", mprefix, mkey); String *lkey = SwigType_lstr(rk.key, 0); String *lprefix = SwigType_lstr(prefix, 0); Hash *subhash = Getattr(sub, bk.key); String *convcode = Getattr(subhash, "convcode"); if (convcode) { char *newmemoryused = Strstr(convcode, "newmemory"); /* see if newmemory parameter is used in order to avoid unused parameter warnings */ String *fn = Copy(convcode); Replaceall(fn, "$from", "x"); Printf(out, "static void *%s(void *x, int *%s) {", convname, newmemoryused ? "newmemory" : "SWIGUNUSEDPARM(newmemory)"); Printf(out, "%s", fn); } else { String *cast = Getattr(subhash, "cast"); Printf(out, "static void *%s(void *x, int *SWIGUNUSEDPARM(newmemory)) {", convname); Printf(out, "\n return (void *)((%s) ", lkey); if (cast) Printf(out, "%s", cast); Printf(out, " ((%s) x));\n", lprefix); } Printf(out, "}\n"); Setattr(conversions, ckey, convname); Delete(ckey); Delete(lkey); Delete(lprefix); /* This inserts conversions for typedefs */ { Hash *r = Getattr(r_resolved, prefix); if (r) { Iterator rrk; rrk = First(r); while (rrk.key) { Iterator rlk; String *rkeymangle; /* Make sure this name equivalence is not due to inheritance */ if (Cmp(prefix, Getattr(r, rrk.key)) == 0) { rkeymangle = Copy(mkey); ckey = NewStringf("%s+%s", rrk.key, rkeymangle); if (!Getattr(conversions, ckey)) { Setattr(conversions, ckey, convname); } Delete(ckey); for (rlk = First(rlist); rlk.item; rlk = Next(rlk)) { ckey = NewStringf("%s+%s", rrk.key, rlk.item); Setattr(conversions, ckey, convname); Delete(ckey); } Delete(rkeymangle); /* This is needed to pick up other alternative names for the same type. Needed to make templates work */ Setattr(rh, rrk.key, rrk.item); } rrk = Next(rrk); } } } Delete(convname); } Delete(prefix); Delete(mprefix); Delete(mkey); bk = Next(bk); } rk = Next(rk); Delete(rlist); } } /* Helper function to sort the mangled list */ static int SwigType_compare_mangled(const DOH *a, const DOH *b) { return strcmp((char *) Data(a), (char *) Data(b)); } /* ----------------------------------------------------------------------------- * SwigType_get_sorted_mangled_list() * * Returns the sorted list of mangled type names that should be exported into the * wrapper file. * ----------------------------------------------------------------------------- */ List *SwigType_get_sorted_mangled_list() { List *l = Keys(r_mangled); SortList(l, SwigType_compare_mangled); return l; } /* ----------------------------------------------------------------------------- * SwigType_type_table() * * Generate the type-table for the type-checker. * ----------------------------------------------------------------------------- */ void SwigType_emit_type_table(File *f_forward, File *f_table) { Iterator ki; String *types, *table, *cast, *cast_init, *cast_temp; Hash *imported_types; List *mangled_list; List *table_list = NewList(); int i = 0; if (!r_mangled) { r_mangled = NewHash(); r_resolved = NewHash(); } Printf(f_table, "\n/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */\n\n"); SwigType_inherit_equiv(f_table); /*#define DEBUG 1*/ #ifdef DEBUG Printf(stdout, "---r_mangled---\n"); Printf(stdout, "%s\n", r_mangled); Printf(stdout, "---r_resolved---\n"); Printf(stdout, "%s\n", r_resolved); Printf(stdout, "---r_ltype---\n"); Printf(stdout, "%s\n", r_ltype); Printf(stdout, "---subclass---\n"); Printf(stdout, "%s\n", subclass); Printf(stdout, "---conversions---\n"); Printf(stdout, "%s\n", conversions); Printf(stdout, "---r_clientdata---\n"); Printf(stdout, "%s\n", r_clientdata); #endif table = NewStringEmpty(); types = NewStringEmpty(); cast = NewStringEmpty(); cast_init = NewStringEmpty(); imported_types = NewHash(); Printf(table, "static swig_type_info *swig_type_initial[] = {\n"); Printf(cast_init, "static swig_cast_info *swig_cast_initial[] = {\n"); Printf(f_forward, "\n/* -------- TYPES TABLE (BEGIN) -------- */\n\n"); mangled_list = SwigType_get_sorted_mangled_list(); for (ki = First(mangled_list); ki.item; ki = Next(ki)) { List *el; Iterator ei; SwigType *lt; SwigType *rt = 0; String *nt; String *ln; String *rn; const String *cd; Hash *lthash; Iterator ltiter; Hash *nthash; cast_temp = NewStringEmpty(); Printv(types, "static swig_type_info _swigt_", ki.item, " = {", NIL); Append(table_list, ki.item); Printf(cast_temp, "static swig_cast_info _swigc_%s[] = {", ki.item); i++; cd = SwigType_clientdata_collect(ki.item); if (!cd) cd = "0"; lthash = Getattr(r_ltype, ki.item); nt = 0; nthash = NewHash(); ltiter = First(lthash); while (ltiter.key) { lt = ltiter.key; rt = SwigType_typedef_resolve_all(lt); /* we save the original type and the fully resolved version */ ln = SwigType_lstr(lt, 0); rn = SwigType_lstr(rt, 0); if (Equal(ln, rn)) { Setattr(nthash, ln, "1"); } else { Setattr(nthash, rn, "1"); Setattr(nthash, ln, "1"); } if (SwigType_istemplate(rt)) { String *dt = Swig_symbol_template_deftype(rt, 0); String *dn = SwigType_lstr(dt, 0); if (!Equal(dn, rn) && !Equal(dn, ln)) { Setattr(nthash, dn, "1"); } Delete(dt); Delete(dn); } ltiter = Next(ltiter); } /* now build nt */ ltiter = First(nthash); nt = 0; while (ltiter.key) { if (nt) { Printf(nt, "|%s", ltiter.key); } else { nt = NewString(ltiter.key); } ltiter = Next(ltiter); } Delete(nthash); Printf(types, "\"%s\", \"%s\", 0, 0, (void*)%s, 0};\n", ki.item, nt, cd); el = SwigType_equivalent_mangle(ki.item, 0, 0); for (ei = First(el); ei.item; ei = Next(ei)) { String *ckey; String *conv; ckey = NewStringf("%s+%s", ei.item, ki.item); conv = Getattr(conversions, ckey); if (conv) { Printf(cast_temp, " {&_swigt_%s, %s, 0, 0},", ei.item, conv); } else { Printf(cast_temp, " {&_swigt_%s, 0, 0, 0},", ei.item); } Delete(ckey); if (!Getattr(r_mangled, ei.item) && !Getattr(imported_types, ei.item)) { Printf(types, "static swig_type_info _swigt_%s = {\"%s\", 0, 0, 0, 0, 0};\n", ei.item, ei.item); Append(table_list, ei.item); Printf(cast, "static swig_cast_info _swigc_%s[] = {{&_swigt_%s, 0, 0, 0},{0, 0, 0, 0}};\n", ei.item, ei.item); i++; Setattr(imported_types, ei.item, "1"); } } Delete(el); Printf(cast, "%s{0, 0, 0, 0}};\n", cast_temp); Delete(cast_temp); Delete(nt); Delete(rt); } /* print the tables in the proper order */ SortList(table_list, SwigType_compare_mangled); i = 0; for (ki = First(table_list); ki.item; ki = Next(ki)) { Printf(f_forward, "#define SWIGTYPE%s swig_types[%d]\n", ki.item, i++); Printf(table, " &_swigt_%s,\n", ki.item); Printf(cast_init, " _swigc_%s,\n", ki.item); } if (i == 0) { /* empty arrays are not allowed by ISO C */ Printf(table, " NULL\n"); Printf(cast_init, " NULL\n"); } Delete(table_list); Delete(mangled_list); Printf(table, "};\n"); Printf(cast_init, "};\n"); Printf(f_table, "%s\n", types); Printf(f_table, "%s\n", table); Printf(f_table, "%s\n", cast); Printf(f_table, "%s\n", cast_init); Printf(f_table, "\n/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */\n\n"); Printf(f_forward, "static swig_type_info *swig_types[%d];\n", i + 1); Printf(f_forward, "static swig_module_info swig_module = {swig_types, %d, 0, 0, 0, 0};\n", i); Printf(f_forward, "#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)\n"); Printf(f_forward, "#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)\n"); Printf(f_forward, "\n/* -------- TYPES TABLE (END) -------- */\n\n"); Delete(types); Delete(table); Delete(cast); Delete(cast_init); Delete(imported_types); } swig-3.0.2/Source/Swig/include.c0000664000175000017500000002613512343605122016312 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * include.c * * The functions in this file are used to manage files in the SWIG library. * General purpose functions for opening, including, and retrieving pathnames * are provided. * ----------------------------------------------------------------------------- */ #include "swig.h" static List *directories = 0; /* List of include directories */ static String *lastpath = 0; /* Last file that was included */ static List *pdirectories = 0; /* List of pushed directories */ static int dopush = 1; /* Whether to push directories */ static int file_debug = 0; /* This functions determine whether to push/pop dirs in the preprocessor */ void Swig_set_push_dir(int push) { dopush = push; } int Swig_get_push_dir(void) { return dopush; } /* ----------------------------------------------------------------------------- * Swig_add_directory() * * Adds a directory to the SWIG search path. * ----------------------------------------------------------------------------- */ List *Swig_add_directory(const_String_or_char_ptr dirname) { String *adirname; if (!directories) directories = NewList(); assert(directories); if (dirname) { adirname = NewString(dirname); Append(directories,adirname); Delete(adirname); } return directories; } /* ----------------------------------------------------------------------------- * Swig_push_directory() * * Inserts a directory at the front of the SWIG search path. This is used by * the preprocessor to grab files in the same directory as other included files. * ----------------------------------------------------------------------------- */ void Swig_push_directory(const_String_or_char_ptr dirname) { String *pdirname; if (!Swig_get_push_dir()) return; if (!pdirectories) pdirectories = NewList(); assert(pdirectories); pdirname = NewString(dirname); assert(pdirname); Insert(pdirectories,0,pdirname); Delete(pdirname); } /* ----------------------------------------------------------------------------- * Swig_pop_directory() * * Pops a directory off the front of the SWIG search path. This is used by * the preprocessor. * ----------------------------------------------------------------------------- */ void Swig_pop_directory(void) { if (!Swig_get_push_dir()) return; if (!pdirectories) return; Delitem(pdirectories, 0); } /* ----------------------------------------------------------------------------- * Swig_last_file() * * Returns the full pathname of the last file opened. * ----------------------------------------------------------------------------- */ String *Swig_last_file(void) { assert(lastpath); return lastpath; } /* ----------------------------------------------------------------------------- * Swig_search_path_any() * * Returns a list of the current search paths. * ----------------------------------------------------------------------------- */ static List *Swig_search_path_any(int syspath) { String *filename; List *slist; int i, ilen; slist = NewList(); assert(slist); filename = NewStringEmpty(); assert(filename); #ifdef MACSWIG Printf(filename, "%s", SWIG_FILE_DELIMITER); #else Printf(filename, ".%s", SWIG_FILE_DELIMITER); #endif Append(slist, filename); Delete(filename); /* If there are any pushed directories. Add them first */ if (pdirectories) { ilen = Len(pdirectories); for (i = 0; i < ilen; i++) { filename = NewString(Getitem(pdirectories,i)); Append(filename,SWIG_FILE_DELIMITER); Append(slist,filename); Delete(filename); } } /* Add system directories next */ ilen = Len(directories); for (i = 0; i < ilen; i++) { filename = NewString(Getitem(directories,i)); Append(filename,SWIG_FILE_DELIMITER); if (syspath) { /* If doing a system include, put the system directories first */ Insert(slist,i,filename); } else { /* Otherwise, just put the system directories after the pushed directories (if any) */ Append(slist,filename); } Delete(filename); } return slist; } List *Swig_search_path() { return Swig_search_path_any(0); } /* ----------------------------------------------------------------------------- * Swig_open() * * open a file, optionally looking for it in the include path. Returns an open * FILE * on success. * ----------------------------------------------------------------------------- */ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_include_path) { FILE *f; String *filename; List *spath = 0; char *cname; int i, ilen, nbytes; char bom[3]; if (!directories) directories = NewList(); assert(directories); cname = Char(name); filename = NewString(cname); assert(filename); if (file_debug) { Printf(stdout, " Open: %s\n", filename); } f = fopen(Char(filename), "r"); if (!f && use_include_path) { spath = Swig_search_path_any(sysfile); ilen = Len(spath); for (i = 0; i < ilen; i++) { Clear(filename); Printf(filename, "%s%s", Getitem(spath, i), cname); f = fopen(Char(filename), "r"); if (f) break; } Delete(spath); } if (f) { Delete(lastpath); lastpath = filename; /* Skip the UTF-8 BOM if it's present */ nbytes = fread(bom, 1, 3, f); if (nbytes == 3 && bom[0] == (char)0xEF && bom[1] == (char)0xBB && bom[2] == (char)0xBF) { /* skip */ } else { fseek(f, 0, SEEK_SET); } } return f; } /* Open a file - searching the include paths to find it */ FILE *Swig_include_open(const_String_or_char_ptr name) { return Swig_open_file(name, 0, 1); } /* Open a file - does not use include paths to find it */ FILE *Swig_open(const_String_or_char_ptr name) { return Swig_open_file(name, 0, 0); } /* ----------------------------------------------------------------------------- * Swig_read_file() * * Reads data from an open FILE * and returns it as a string. * ----------------------------------------------------------------------------- */ String *Swig_read_file(FILE *f) { int len; char buffer[4096]; String *str = NewStringEmpty(); assert(str); while (fgets(buffer, 4095, f)) { Append(str, buffer); } len = Len(str); /* Add a newline if not present on last line -- the preprocessor seems to * rely on \n and not EOF terminating lines */ if (len) { char *cstr = Char(str); if (cstr[len - 1] != '\n') { Append(str, "\n"); } } return str; } /* ----------------------------------------------------------------------------- * Swig_include() * * Opens a file and returns it as a string. * ----------------------------------------------------------------------------- */ static String *Swig_include_any(const_String_or_char_ptr name, int sysfile) { FILE *f; String *str; String *file; f = Swig_open_file(name, sysfile, 1); if (!f) return 0; str = Swig_read_file(f); fclose(f); Seek(str, 0, SEEK_SET); file = Copy(Swig_last_file()); Setfile(str, file); Delete(file); Setline(str, 1); return str; } String *Swig_include(const_String_or_char_ptr name) { return Swig_include_any(name, 0); } String *Swig_include_sys(const_String_or_char_ptr name) { return Swig_include_any(name, 1); } /* ----------------------------------------------------------------------------- * Swig_insert_file() * * Copies the contents of a file into another file * ----------------------------------------------------------------------------- */ int Swig_insert_file(const_String_or_char_ptr filename, File *outfile) { char buffer[4096]; int nbytes; FILE *f = Swig_include_open(filename); if (!f) return -1; while ((nbytes = Read(f, buffer, 4096)) > 0) { Write(outfile, buffer, nbytes); } return 0; } /* ----------------------------------------------------------------------------- * Swig_register_filebyname() * * Register a "named" file with the core. Named files can become targets * for %insert directives and other SWIG operations. This function takes * the place of the f_header, f_wrapper, f_init, and other global variables * in SWIG1.1 * ----------------------------------------------------------------------------- */ static Hash *named_files = 0; void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile) { if (!named_files) named_files = NewHash(); Setattr(named_files, filename, outfile); } /* ----------------------------------------------------------------------------- * Swig_filebyname() * * Get a named file * ----------------------------------------------------------------------------- */ File *Swig_filebyname(const_String_or_char_ptr filename) { if (!named_files) return 0; return Getattr(named_files, filename); } /* ----------------------------------------------------------------------------- * Swig_file_extension() * * Returns the extension of a file * ----------------------------------------------------------------------------- */ String *Swig_file_extension(const_String_or_char_ptr filename) { String *name = Swig_file_filename(filename); const char *c = strrchr(Char(name), '.'); String *extension = c ? NewString(c) : NewString(""); Delete(name); return extension; } /* ----------------------------------------------------------------------------- * Swig_file_basename() * * Returns the filename with the extension removed. * ----------------------------------------------------------------------------- */ String *Swig_file_basename(const_String_or_char_ptr filename) { String *extension = Swig_file_extension(filename); String *basename = NewStringWithSize(filename, Len(filename) - Len(extension)); Delete(extension); return basename; } /* ----------------------------------------------------------------------------- * Swig_file_filename() * * Return the file name with any leading path stripped off * ----------------------------------------------------------------------------- */ String *Swig_file_filename(const_String_or_char_ptr filename) { const char *delim = SWIG_FILE_DELIMITER; const char *c = strrchr(Char(filename), *delim); return c ? NewString(c + 1) : NewString(filename); } /* ----------------------------------------------------------------------------- * Swig_file_dirname() * * Return the name of the directory associated with a file * ----------------------------------------------------------------------------- */ String *Swig_file_dirname(const_String_or_char_ptr filename) { const char *delim = SWIG_FILE_DELIMITER; const char *c = strrchr(Char(filename), *delim); return c ? NewStringWithSize(filename, c - Char(filename) + 1) : NewString(""); } /* * Swig_file_debug() */ void Swig_file_debug_set() { file_debug = 1; } swig-3.0.2/Source/Swig/symbol.c0000664000175000017500000017221112343605122016171 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * symbol.c * * This file implements the SWIG symbol table. See details below. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "swigwarn.h" #include /* #define SWIG_DEBUG*/ /* ----------------------------------------------------------------------------- * Synopsis * * This module provides symbol table management for all of SWIG. In previous * releases, the management of symbols was rather haphazard. This module tries * to correct that. * * All symbols are associated with simple identifiers. For example, here are some * declarations that generate symbol table entries: * * decl symbol * -------------- ------------ * void foo(int); foo * int x; x * typedef int *blah; blah * * Associated with each symbol is a Hash table that can contain any set of * attributes that make sense for that object. For example: * * typedef int *blah; ----> "name" : 'blah' * "type" : 'int' * "decl" : 'p.' * "storage" : 'typedef' * * In some cases, the symbol table needs to manage overloaded entries. For instance, * overloaded functions. In this case, a linked list is built. The "sym:nextSibling" * attribute is reserved to hold a link to the next entry. For example: * * int foo(int); --> "name" : "foo" "name" : "foo" * int foo(int,double); "type" : "int" "type" : "int" * "decl" : "f(int)." "decl" : "f(int,double)." * ... ... * "sym:nextSibling" : --------> "sym:nextSibling": --------> ... * * When more than one symbol has the same name, the symbol declarator is * used to detect duplicates. For example, in the above case, foo(int) and * foo(int,double) are different because their "decl" attribute is different. * However, if a third declaration "foo(int)" was made, it would generate a * conflict (due to having a declarator that matches a previous entry). * * Structures and classes: * * C/C++ symbol tables are normally managed in a few different spaces. The * most visible namespace is reserved for functions, variables, typedef, enum values * and such. In C, a separate tag-space is reserved for 'struct name', 'class name', * and 'union name' declarations. In SWIG, a single namespace is used for everything * this means that certain incompatibilities will arise with some C programs. For instance: * * struct Foo { * ... * } * * int Foo(); // Error. Name clash. Works in C though * * Due to the unified namespace for structures, special handling is performed for * the following: * * typedef struct Foo { * * } Foo; * * In this case, the symbol table contains an entry for the structure itself. The * typedef is left out of the symbol table. * * Target language vs C: * * The symbol tables are normally managed *in the namespace of the target language*. * This means that name-collisions can be resolved using %rename and related * directives. A quirk of this is that sometimes the symbol tables need to * be used for C type resolution as well. To handle this, each symbol table * also has a C-symbol table lurking behind the scenes. This is used to locate * symbols in the C namespace. However, this symbol table is not used for error * reporting nor is it used for anything else during code generation. * * Symbol table structure: * * Symbol tables themselves are a special kind of node that is organized just like * a normal parse tree node. Symbol tables are organized in a tree that can be * traversed using the SWIG-DOM API. The following attributes names are reserved. * * name -- Name of the scope defined by the symbol table (if any) * This name is the C-scope name and is not affected by * %renaming operations * symtab -- Hash table mapping identifiers to nodes. * csymtab -- Hash table mapping C identifiers to nodes. * * Reserved attributes on symbol objects: * * When a symbol is placed in the symbol table, the following attributes * are set: * * sym:name -- Symbol name * sym:nextSibling -- Next symbol (if overloaded) * sym:previousSibling -- Previous symbol (if overloaded) * sym:symtab -- Symbol table object holding the symbol * sym:overloaded -- Set to the first symbol if overloaded * * These names are modeled after XML namespaces. In particular, every attribute * pertaining to symbol table management is prefaced by the "sym:" prefix. * * An example dump of the parse tree showing symbol table entries for the * following code should clarify this: * * namespace OuterNamespace { * namespace InnerNamespace { * class Class { * }; * struct Struct { * int Var; * }; * } * } * * +++ namespace ---------------------------------------- * | sym:name - "OuterNamespace" * | symtab - 0xa064bf0 * | sym:symtab - 0xa041690 * | sym:overname - "__SWIG_0" * * +++ namespace ---------------------------------------- * | sym:name - "InnerNamespace" * | symtab - 0xa064cc0 * | sym:symtab - 0xa064bf0 * | sym:overname - "__SWIG_0" * * +++ class ---------------------------------------- * | sym:name - "Class" * | symtab - 0xa064d80 * | sym:symtab - 0xa064cc0 * | sym:overname - "__SWIG_0" * | * +++ class ---------------------------------------- * | sym:name - "Struct" * | symtab - 0xa064f00 * | sym:symtab - 0xa064cc0 * | sym:overname - "__SWIG_0" * * +++ cdecl ---------------------------------------- * | sym:name - "Var" * | sym:symtab - 0xa064f00 * | sym:overname - "__SWIG_0" * | * * * Each class and namespace has its own scope and thus a new symbol table (sym) * is created. The sym attribute is only set for the first entry in the symbol * table. The sym:symtab entry points to the symbol table in which the symbol * exists, so for example, Struct is in the scope OuterNamespace::InnerNamespace * so sym:symtab points to this symbol table (0xa064cc0). * * ----------------------------------------------------------------------------- */ static Hash *current = 0; /* The current symbol table hash */ static Hash *ccurrent = 0; /* The current c symbol table hash */ static Hash *current_symtab = 0; /* Current symbol table node */ static Hash *symtabs = 0; /* Hash of all symbol tables by fully-qualified name */ static Hash *global_scope = 0; /* Global scope */ static int use_inherit = 1; /* common attribute keys, to avoid calling find_key all the times */ /* ----------------------------------------------------------------------------- * Swig_symbol_print_tables() * * Debug display of symbol tables * ----------------------------------------------------------------------------- */ void Swig_symbol_print_tables(Symtab *symtab) { if (!symtab) symtab = current_symtab; Printf(stdout, "SYMBOL TABLES start =======================================\n"); Swig_print_tree(symtab); Printf(stdout, "SYMBOL TABLES finish =======================================\n"); } /* ----------------------------------------------------------------------------- * Swig_symbol_print_tables_summary() * * Debug summary display of all symbol tables by fully-qualified name * ----------------------------------------------------------------------------- */ void Swig_symbol_print_tables_summary(void) { Printf(stdout, "SYMBOL TABLES SUMMARY start =======================================\n"); Swig_print_node(symtabs); Printf(stdout, "SYMBOL TABLES SUMMARY finish =======================================\n"); } /* ----------------------------------------------------------------------------- * symbol_print_symbols() * ----------------------------------------------------------------------------- */ static void symbol_print_symbols(const char *symboltabletype) { Node *table = symtabs; Iterator ki = First(table); while (ki.key) { String *k = ki.key; Printf(stdout, "===================================================\n"); Printf(stdout, "%s -\n", k); { Symtab *symtab = Getattr(Getattr(table, k), symboltabletype); Iterator it = First(symtab); while (it.key) { String *symname = it.key; Printf(stdout, " %s (%s)\n", symname, nodeType(it.item)); /* Printf(stdout, " %s - %p (%s)\n", symname, it.item, Getattr(it.item, "name")); */ it = Next(it); } } ki = Next(ki); } } /* ----------------------------------------------------------------------------- * Swig_symbol_print_symbols() * * Debug display of all the target language symbols * ----------------------------------------------------------------------------- */ void Swig_symbol_print_symbols(void) { Printf(stdout, "SYMBOLS start =======================================\n"); symbol_print_symbols("symtab"); Printf(stdout, "SYMBOLS finish =======================================\n"); } /* ----------------------------------------------------------------------------- * Swig_symbol_print_csymbols() * * Debug display of all the C symbols * ----------------------------------------------------------------------------- */ void Swig_symbol_print_csymbols(void) { Printf(stdout, "CSYMBOLS start =======================================\n"); symbol_print_symbols("csymtab"); Printf(stdout, "CSYMBOLS finish =======================================\n"); } /* ----------------------------------------------------------------------------- * Swig_symbol_init() * * Create a new symbol table object * ----------------------------------------------------------------------------- */ void Swig_symbol_init(void) { current = NewHash(); current_symtab = NewHash(); ccurrent = NewHash(); set_nodeType(current_symtab, "symboltable"); Setattr(current_symtab, "symtab", current); Delete(current); Setattr(current_symtab, "csymtab", ccurrent); Delete(ccurrent); /* Set the global scope */ symtabs = NewHash(); Setattr(symtabs, "", current_symtab); Delete(current_symtab); global_scope = current_symtab; } /* ----------------------------------------------------------------------------- * Swig_symbol_setscopename() * * Set the C scopename of the current symbol table. * ----------------------------------------------------------------------------- */ void Swig_symbol_setscopename(const_String_or_char_ptr name) { String *qname; /* assert(!Getattr(current_symtab,"name")); */ Setattr(current_symtab, "name", name); /* Set nested scope in parent */ qname = Swig_symbol_qualifiedscopename(current_symtab); /* Save a reference to this scope */ Setattr(symtabs, qname, current_symtab); Delete(qname); } /* ----------------------------------------------------------------------------- * Swig_symbol_getscopename() * * Get the C scopename of the current symbol table * ----------------------------------------------------------------------------- */ String *Swig_symbol_getscopename(void) { return Getattr(current_symtab, "name"); } /* ----------------------------------------------------------------------------- * Swig_symbol_getscope() * * Given a fully qualified C scopename, this function returns a symbol table * ----------------------------------------------------------------------------- */ Symtab *Swig_symbol_getscope(const_String_or_char_ptr name) { if (!symtabs) return 0; if (Equal("::", (const_String_or_char_ptr ) name)) name = ""; return Getattr(symtabs, name); } /* ----------------------------------------------------------------------------- * Swig_symbol_qualifiedscopename() * * Get the fully qualified C scopename of a symbol table. Note, this only pertains * to the C/C++ scope name. It is not affected by renaming. * ----------------------------------------------------------------------------- */ String *Swig_symbol_qualifiedscopename(Symtab *symtab) { String *result = 0; Hash *parent; String *name; if (!symtab) symtab = current_symtab; parent = Getattr(symtab, "parentNode"); if (parent) { result = Swig_symbol_qualifiedscopename(parent); } name = Getattr(symtab, "name"); if (name) { if (!result) { result = NewStringEmpty(); } if (Len(result)) { Printv(result, "::", name, NIL); } else { Append(result, name); } } return result; } /* ----------------------------------------------------------------------------- * Swig_symbol_qualified_language_scopename() * * Get the fully qualified C scopename of a symbol table but using a language * specific separator for the scopenames. Basically the same as * Swig_symbol_qualifiedscopename() but using the different separator. * ----------------------------------------------------------------------------- */ String *Swig_symbol_qualified_language_scopename(Symtab *n) { /* TODO: fix for %rename to work */ String *result = Swig_symbol_qualifiedscopename(n); Replaceall(result, "::", NSPACE_SEPARATOR); return result; } /* ----------------------------------------------------------------------------- * Swig_symbol_newscope() * * Create a new scope. Returns the newly created scope. * ----------------------------------------------------------------------------- */ Symtab *Swig_symbol_newscope(void) { Hash *n; Hash *hsyms, *h; hsyms = NewHash(); h = NewHash(); set_nodeType(h, "symboltable"); Setattr(h, "symtab", hsyms); Delete(hsyms); set_parentNode(h, current_symtab); n = lastChild(current_symtab); if (!n) { set_firstChild(current_symtab, h); } else { set_nextSibling(n, h); Delete(h); } set_lastChild(current_symtab, h); current = hsyms; ccurrent = NewHash(); Setattr(h, "csymtab", ccurrent); Delete(ccurrent); current_symtab = h; return h; } /* ----------------------------------------------------------------------------- * Swig_symbol_setscope() * * Set the current scope. Returns the previous current scope. * ----------------------------------------------------------------------------- */ Symtab *Swig_symbol_setscope(Symtab *sym) { Symtab *ret = current_symtab; current_symtab = sym; current = Getattr(sym, "symtab"); assert(current); ccurrent = Getattr(sym, "csymtab"); assert(ccurrent); return ret; } /* ----------------------------------------------------------------------------- * Swig_symbol_popscope() * * Pop out of the current scope. Returns the popped scope and sets the * scope to the parent scope. * ----------------------------------------------------------------------------- */ Symtab *Swig_symbol_popscope(void) { Hash *h = current_symtab; current_symtab = Getattr(current_symtab, "parentNode"); assert(current_symtab); current = Getattr(current_symtab, "symtab"); assert(current); ccurrent = Getattr(current_symtab, "csymtab"); assert(ccurrent); return h; } /* ----------------------------------------------------------------------------- * Swig_symbol_global_scope() * * Return the symbol table for the global scope. * ----------------------------------------------------------------------------- */ Symtab *Swig_symbol_global_scope(void) { return global_scope; } /* ----------------------------------------------------------------------------- * Swig_symbol_current() * * Return the current symbol table. * ----------------------------------------------------------------------------- */ Symtab *Swig_symbol_current(void) { return current_symtab; } /* ----------------------------------------------------------------------------- * Swig_symbol_alias() * * Makes an alias for a symbol in the global symbol table. * Primarily for namespace aliases such as 'namespace X = Y;'. * ----------------------------------------------------------------------------- */ void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *s) { String *qname = Swig_symbol_qualifiedscopename(current_symtab); if (qname) { Printf(qname, "::%s", aliasname); } else { qname = NewString(aliasname); } if (!Getattr(symtabs, qname)) { Setattr(symtabs, qname, s); } Delete(qname); } /* ----------------------------------------------------------------------------- * Swig_symbol_inherit() * * Inherit symbols from another scope. Primarily for C++ inheritance and * for using directives, such as 'using namespace X;' * but not for using declarations, such as 'using A;'. * ----------------------------------------------------------------------------- */ void Swig_symbol_inherit(Symtab *s) { int i, ilen; List *inherit = Getattr(current_symtab, "inherit"); if (!inherit) { inherit = NewList(); Setattr(current_symtab, "inherit", inherit); Delete(inherit); } if (s == current_symtab) { Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(s), Getline(s), "Recursive scope inheritance of '%s'.\n", Getattr(s, "name")); return; } assert(s != current_symtab); ilen = Len(inherit); for (i = 0; i < ilen; i++) { Node *n = Getitem(inherit, i); if (n == s) return; /* Already inherited */ } Append(inherit, s); } /* ----------------------------------------------------------------------------- * Swig_symbol_cadd() * * Adds a node to the C symbol table only. * ----------------------------------------------------------------------------- */ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) { Node *append = 0; Node *cn; /* There are a few options for weak symbols. A "weak" symbol is any symbol that can be replaced by another symbol in the C symbol table. An example would be a forward class declaration. A forward class sits in the symbol table until a real class declaration comes along. Certain symbols are marked as "sym:typename". These are important symbols related to the C++ type-system and take precedence in the C symbol table. An example might be code like this: template T foo(T x); int foo(int); In this case, the template is marked with "sym:typename" so that it stays in the C symbol table (so that it can be expanded using %template). */ if (!name) return; if (SwigType_istemplate(name)) { String *cname = NewString(name); String *dname = Swig_symbol_template_deftype(cname, 0); if (!Equal(dname, name)) { Swig_symbol_cadd(dname, n); } Delete(dname); Delete(cname); } #ifdef SWIG_DEBUG Printf(stderr, "symbol_cadd %s %p\n", name, n); #endif cn = Getattr(ccurrent, name); if (cn && (Getattr(cn, "sym:typename"))) { /* The node in the C symbol table is a typename. Do nothing */ /* We might append the symbol at the end */ append = n; } else if (cn && (Getattr(cn, "sym:weak"))) { /* The node in the symbol table is weak. Replace it */ if (checkAttribute(cn, "nodeType", "template") && checkAttribute(cn, "templatetype", "classforward")) { /* The node is a template classforward declaration, and the default template parameters here take precedence. */ ParmList *pc = Getattr(cn, "templateparms"); ParmList *pn = Getattr(n, "templateparms"); #ifdef SWIG_DEBUG Printf(stderr, "found template classforward %s\n", Getattr(cn, "name")); #endif while (pc && pn) { String *value = Getattr(pc, "value"); if (value) { #ifdef SWIG_DEBUG Printf(stderr, "add default template value %s %s\n", Getattr(pc, "name"), value); #endif Setattr(pn, "value", value); } pc = nextSibling(pc); pn = nextSibling(pn); } Setattr(n, "templateparms", Getattr(cn, "templateparms")); } Setattr(ccurrent, name, n); } else if (cn && (Getattr(n, "sym:weak"))) { /* The node being added is weak. Don't worry about it */ } else if (cn && (Getattr(n, "sym:typename"))) { /* The node being added is a typename. We definitely add it */ Setattr(ccurrent, name, n); append = cn; } else if (cn && (Checkattr(cn, "nodeType", "templateparm"))) { Swig_error(Getfile(n), Getline(n), "Declaration of '%s' shadows template parameter,\n", name); Swig_error(Getfile(cn), Getline(cn), "previous template parameter declaration '%s'.\n", name); return; } else if (cn) { append = n; } else if (!cn) { /* No conflict. Add the symbol */ Setattr(ccurrent, name, n); } /* Multiple entries in the C symbol table. We append to to the symbol table */ if (append) { Node *fn, *pn = 0; cn = Getattr(ccurrent, name); fn = cn; while (fn) { pn = fn; if (fn == append) { /* already added. Bail */ return; } fn = Getattr(fn, "csym:nextSibling"); } if (pn) { Setattr(pn, "csym:nextSibling", append); } } /* Special typedef handling. When a typedef node is added to the symbol table, we might have to add a type alias. This would occur if the typedef mapped to another scope in the system. For example: class Foo { }; typedef Foo OtherFoo; In this case, OtherFoo becomes an alias for Foo. */ { Node *td = n; while (td && Checkattr(td, "nodeType", "cdecl") && Checkattr(td, "storage", "typedef")) { SwigType *type; Node *td1; type = Copy(Getattr(td, "type")); SwigType_push(type, Getattr(td, "decl")); td1 = Swig_symbol_clookup(type, 0); /* Fix pathetic case #1214313: class Foo { }; typedef Foo FooBar; class CBaz { public: typedef FooBar Foo; }; ie, when Foo -> FooBar -> Foo, jump one scope up when possible. */ if (td1 && Checkattr(td1, "storage", "typedef")) { String *st = Getattr(td1, "type"); String *sn = Getattr(td, "name"); if (st && sn && Equal(st, sn)) { Symtab *sc = Getattr(current_symtab, "parentNode"); if (sc) td1 = Swig_symbol_clookup(type, sc); } } Delete(type); if (td1 == td) break; td = td1; if (td) { Symtab *st = Getattr(td, "symtab"); if (st) { Swig_symbol_alias(Getattr(n, "name"), st); break; } } } } } /* ----------------------------------------------------------------------------- * Swig_symbol_add() * * Adds a node to the symbol table. Returns the node itself if successfully * added. Otherwise, it returns the symbol table entry of the conflicting node. * * Also places the symbol in a behind-the-scenes C symbol table. This is needed * for namespace support, type resolution, and other issues. * ----------------------------------------------------------------------------- */ Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) { Hash *c, *cn, *cl = 0; SwigType *decl, *ndecl; String *cstorage, *nstorage; int nt = 0, ct = 0; int pn = 0; int u1 = 0, u2 = 0; String *name, *overname; /* See if the node has a name. If so, we place in the C symbol table for this scope. We don't worry about overloading here---the primary purpose of this is to record information for type/name resolution for later. Conflicts in C namespaces are errors, but these will be caught by the C++ compiler when compiling the wrapper code */ /* There are a few options for weak symbols. A "weak" symbol is any symbol that can be replaced by another symbol in the C symbol table. An example would be a forward class declaration. A forward class sits in the symbol table until a real class declaration comes along. Certain symbols are marked as "sym:typename". These are important symbols related to the C++ type-system and take precedence in the C symbol table. An example might be code like this: template T foo(T x); int foo(int); In this case, the template is marked with "sym:typename" so that it stays in the C symbol table (so that it can be expanded using %template). */ name = Getattr(n, "name"); if (name && Len(name)) { Swig_symbol_cadd(name, n); } /* No symbol name defined. We return. */ if (!symname) { Setattr(n, "sym:symtab", current_symtab); return n; } /* If node is ignored. We don't proceed any further */ if (GetFlag(n, "feature:ignore")) return n; /* See if the symbol already exists in the table */ c = Getattr(current, symname); /* Check for a weak symbol. A weak symbol is allowed to be in the symbol table, but is silently overwritten by other symbols. An example would be a forward class declaration. For instance: class Foo; In this case, "Foo" sits in the symbol table. However, the definition of Foo would replace the entry if it appeared later. */ if (c && Getattr(c, "sym:weak")) { c = 0; } if (c) { /* There is a symbol table conflict. There are a few cases to consider here: (1) A conflict between a class/enum and a typedef declaration is okay. In this case, the symbol table entry is set to the class/enum declaration itself, not the typedef. (2) A conflict between namespaces is okay--namespaces are open (3) Otherwise, overloading is only allowed for functions */ /* Check for namespaces */ String *ntype = Getattr(n, "nodeType"); if ((Equal(ntype, Getattr(c, "nodeType"))) && ((Equal(ntype, "namespace")))) { Node *cl, *pcl = 0; cl = c; while (cl) { pcl = cl; cl = Getattr(cl, "sym:nextSibling"); } Setattr(pcl, "sym:nextSibling", n); Setattr(n, "sym:symtab", current_symtab); Setattr(n, "sym:name", symname); Setattr(n, "sym:previousSibling", pcl); return n; } if (Getattr(n, "allows_typedef")) nt = 1; if (Getattr(c, "allows_typedef")) ct = 1; if (nt || ct) { Node *td, *other; String *s; /* At least one of the nodes allows typedef overloading. Make sure that both don't--this would be a conflict */ if (nt && ct) return c; /* Figure out which node allows the typedef */ if (nt) { td = n; other = c; } else { td = c; other = n; } /* Make sure the other node is a typedef */ s = Getattr(other, "storage"); if (!s || (!Equal(s, "typedef"))) return c; /* No. This is a conflict */ /* Hmmm. This appears to be okay. Make sure the symbol table refers to the allow_type node */ if (td != c) { Setattr(current, symname, td); Setattr(td, "sym:symtab", current_symtab); Setattr(td, "sym:name", symname); } return n; } decl = Getattr(c, "decl"); ndecl = Getattr(n, "decl"); { String *nt1, *nt2; nt1 = Getattr(n, "nodeType"); if (Equal(nt1, "template")) nt1 = Getattr(n, "templatetype"); nt2 = Getattr(c, "nodeType"); if (Equal(nt2, "template")) nt2 = Getattr(c, "templatetype"); if (Equal(nt1, "using")) u1 = 1; if (Equal(nt2, "using")) u2 = 1; if ((!Equal(nt1, nt2)) && !(u1 || u2)) return c; } if (!(u1 || u2)) { if ((!SwigType_isfunction(decl)) || (!SwigType_isfunction(ndecl))) { /* Symbol table conflict */ return c; } } /* Hmmm. Declarator seems to indicate that this is a function */ /* Look at storage class to see if compatible */ cstorage = Getattr(c, "storage"); nstorage = Getattr(n, "storage"); /* If either one is declared as typedef, forget it. We're hosed */ if (Cmp(cstorage, "typedef") == 0) { return c; } if (Cmp(nstorage, "typedef") == 0) { return c; } /* Okay. Walk down the list of symbols and see if we get a declarator match */ { String *nt = Getattr(n, "nodeType"); int n_template = Equal(nt, "template") && Checkattr(n, "templatetype", "cdecl"); int n_plain_cdecl = Equal(nt, "cdecl"); cn = c; pn = 0; while (cn) { decl = Getattr(cn, "decl"); if (!(u1 || u2)) { if (Cmp(ndecl, decl) == 0) { /* Declarator conflict */ /* Now check we don't have a non-templated function overloaded by a templated function with same params, * eg void foo(); template void foo(); */ String *cnt = Getattr(cn, "nodeType"); int cn_template = Equal(cnt, "template") && Checkattr(cn, "templatetype", "cdecl"); int cn_plain_cdecl = Equal(cnt, "cdecl"); if (!((n_template && cn_plain_cdecl) || (cn_template && n_plain_cdecl))) { /* found a conflict */ return cn; } } } cl = cn; cn = Getattr(cn, "sym:nextSibling"); pn++; } } /* Well, we made it this far. Guess we can drop the symbol in place */ Setattr(n, "sym:symtab", current_symtab); Setattr(n, "sym:name", symname); /* Printf(stdout,"%s %p\n", Getattr(n,"sym:overname"), current_symtab); */ assert(!Getattr(n, "sym:overname")); overname = NewStringf("__SWIG_%d", pn); Setattr(n, "sym:overname", overname); /*Printf(stdout,"%s %s %s\n", symname, Getattr(n,"decl"), Getattr(n,"sym:overname")); */ Setattr(cl, "sym:nextSibling", n); Setattr(n, "sym:previousSibling", cl); Setattr(cl, "sym:overloaded", c); Setattr(n, "sym:overloaded", c); Delete(overname); return n; } /* No conflict. Just add it */ Setattr(n, "sym:symtab", current_symtab); Setattr(n, "sym:name", symname); /* Printf(stdout,"%s\n", Getattr(n,"sym:overname")); */ overname = NewStringf("__SWIG_%d", pn); Setattr(n, "sym:overname", overname); Delete(overname); /* Printf(stdout,"%s %s %s\n", symname, Getattr(n,"decl"), Getattr(n,"sym:overname")); */ Setattr(current, symname, n); return n; } /* ----------------------------------------------------------------------------- * symbol_lookup() * * Internal function to handle fully qualified symbol table lookups. This * works from the symbol table supplied in symtab and unwinds its way out * towards the global scope. * * This function operates in the C namespace, not the target namespace. * * The check function is an optional callback that can be used to verify a particular * symbol match. This is only used in some of the more exotic parts of SWIG. For instance, * verifying that a class hierarchy implements all pure virtual methods. * ----------------------------------------------------------------------------- */ static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (Node *n)) { Node *n; List *inherit; Hash *sym = Getattr(symtab, "csymtab"); if (Getmark(symtab)) return 0; Setmark(symtab, 1); n = Getattr(sym, name); #ifdef SWIG_DEBUG Printf(stderr, "symbol_look %s %p %p %s\n", name, n, symtab, Getattr(symtab, "name")); #endif if (n) { /* if a check-function is defined. Call it to determine a match */ if (check) { int c = check(n); if (c == 1) { Setmark(symtab, 0); return n; } if (c < 0) { /* Terminate the search right away */ Setmark(symtab, 0); return 0; } } else { Setmark(symtab, 0); return n; } } if (!n && SwigType_istemplate(name)) { String *dname = 0; Setmark(symtab, 0); dname = Swig_symbol_template_deftype(name, symtab); if (!Equal(dname, name)) { n = _symbol_lookup(dname, symtab, check); } Delete(dname); if (n) return n; Setmark(symtab, 1); } inherit = Getattr(symtab, "inherit"); if (inherit && use_inherit) { int i, len; len = Len(inherit); for (i = 0; i < len; i++) { n = _symbol_lookup(name, Getitem(inherit, i), check); if (n) { Setmark(symtab, 0); return n; } } } Setmark(symtab, 0); return 0; } static Node *symbol_lookup(const_String_or_char_ptr name, Symtab *symtab, int (*check) (Node *n)) { Node *n = 0; if (DohCheck(name)) { n = _symbol_lookup(name, symtab, check); } else { String *sname = NewString(name); n = _symbol_lookup(sname, symtab, check); Delete(sname); } return n; } /* ----------------------------------------------------------------------------- * symbol_lookup_qualified() * ----------------------------------------------------------------------------- */ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symtab, const String *prefix, int local, int (*checkfunc) (Node *n)) { /* This is a little funky, we search by fully qualified names */ if (!symtab) return 0; if (!prefix) { Node *n; String *bname; String *prefix; Swig_scopename_split(name, &prefix, &bname); n = symbol_lookup_qualified(bname, symtab, prefix, local, checkfunc); Delete(bname); Delete(prefix); return n; } else { Symtab *st; Node *n = 0; /* Make qualified name of current scope */ String *qalloc = 0; String *qname = Swig_symbol_qualifiedscopename(symtab); const String *cqname; if (qname) { if (Len(qname)) { if (prefix && Len(prefix)) { Printv(qname, "::", prefix, NIL); } } else { Append(qname, prefix); } qalloc = qname; cqname = qname; } else { cqname = prefix; } st = Getattr(symtabs, cqname); /* Found a scope match */ if (st) { if (!name) { if (qalloc) Delete(qalloc); return st; } n = symbol_lookup(name, st, checkfunc); } if (qalloc) Delete(qalloc); if (!n) { if (!local) { Node *pn = Getattr(symtab, "parentNode"); if (pn) n = symbol_lookup_qualified(name, pn, prefix, local, checkfunc); /* Check inherited scopes */ if (!n) { List *inherit = Getattr(symtab, "inherit"); if (inherit && use_inherit) { int i, len; len = Len(inherit); for (i = 0; i < len; i++) { Node *prefix_node = symbol_lookup(prefix, Getitem(inherit, i), checkfunc); if (prefix_node) { Node *prefix_symtab = Getattr(prefix_node, "symtab"); if (prefix_symtab) { n = symbol_lookup(name, prefix_symtab, checkfunc); break; } } } } } } else { n = 0; } } return n; } } /* ----------------------------------------------------------------------------- * Swig_symbol_clookup() * * Look up a symbol in the symbol table. This uses the C name, not scripting * names. Note: If we come across a using declaration, we follow it to * to get the real node. Any using directives are also followed (but this is * implemented in symbol_lookup()). * ----------------------------------------------------------------------------- */ Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) { Hash *hsym = 0; Node *s = 0; if (!n) { hsym = current_symtab; } else { if (!Checkattr(n, "nodeType", "symboltable")) { n = Getattr(n, "sym:symtab"); } assert(n); if (n) { hsym = n; } } if (Swig_scopename_check(name)) { char *cname = Char(name); if (strncmp(cname, "::", 2) == 0) { String *nname = NewString(cname + 2); if (Swig_scopename_check(nname)) { s = symbol_lookup_qualified(nname, global_scope, 0, 0, 0); } else { s = symbol_lookup(nname, global_scope, 0); } Delete(nname); } else { String *prefix = Swig_scopename_prefix(name); if (prefix) { s = symbol_lookup_qualified(name, hsym, 0, 0, 0); Delete(prefix); if (!s) { return 0; } } } } if (!s) { while (hsym) { s = symbol_lookup(name, hsym, 0); if (s) break; hsym = Getattr(hsym, "parentNode"); if (!hsym) break; } } if (!s) { return 0; } /* Check if s is a 'using' node */ while (s && Checkattr(s, "nodeType", "using")) { String *uname = Getattr(s, "uname"); Symtab *un = Getattr(s, "sym:symtab"); Node *ss = (!Equal(name, uname) || (un != n)) ? Swig_symbol_clookup(uname, un) : 0; /* avoid infinity loop */ if (!ss) { Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", Getattr(s, "uname")); } s = ss; } return s; } /* ----------------------------------------------------------------------------- * Swig_symbol_clookup_check() * * This function is identical to Swig_symbol_clookup() except that it * accepts a callback function that is invoked to determine a symbol match. * The purpose of this function is to support complicated algorithms that need * to examine multiple definitions of the same symbol that might appear in an * inheritance hierarchy. * ----------------------------------------------------------------------------- */ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *n)) { Hash *hsym = 0; Node *s = 0; if (!n) { hsym = current_symtab; } else { if (!Checkattr(n, "nodeType", "symboltable")) { n = Getattr(n, "sym:symtab"); } assert(n); if (n) { hsym = n; } } if (Swig_scopename_check(name)) { char *cname = Char(name); if (strncmp(cname, "::", 2) == 0) { String *nname = NewString(cname + 2); if (Swig_scopename_check(nname)) { s = symbol_lookup_qualified(nname, global_scope, 0, 0, checkfunc); } else { s = symbol_lookup(nname, global_scope, checkfunc); } Delete(nname); } else { String *prefix = Swig_scopename_prefix(name); if (prefix) { s = symbol_lookup_qualified(name, hsym, 0, 0, checkfunc); Delete(prefix); if (!s) { return 0; } } } } if (!s) { while (hsym) { s = symbol_lookup(name, hsym, checkfunc); if (s) break; hsym = Getattr(hsym, "parentNode"); if (!hsym) break; } } if (!s) { return 0; } /* Check if s is a 'using' node */ while (s && Checkattr(s, "nodeType", "using")) { Node *ss; ss = Swig_symbol_clookup(Getattr(s, "uname"), Getattr(s, "sym:symtab")); if (!ss && !checkfunc) { Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", Getattr(s, "uname")); } s = ss; } return s; } /* ----------------------------------------------------------------------------- * Swig_symbol_clookup_local() * * Same as Swig_symbol_clookup but parent nodes are not searched, that is, just * this symbol table is searched. * ----------------------------------------------------------------------------- */ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) { Hash *hsym; Node *s = 0; if (!n) { hsym = current_symtab; } else { if (!Checkattr(n, "nodeType", "symboltable")) { n = Getattr(n, "sym:symtab"); } assert(n); hsym = n; } if (Swig_scopename_check(name)) { char *cname = Char(name); if (strncmp(cname, "::", 2) == 0) { String *nname = NewString(cname + 2); if (Swig_scopename_check(nname)) { s = symbol_lookup_qualified(nname, global_scope, 0, 0, 0); } else { s = symbol_lookup(nname, global_scope, 0); } Delete(nname); } else { s = symbol_lookup_qualified(name, hsym, 0, 0, 0); } } if (!s) { s = symbol_lookup(name, hsym, 0); } if (!s) return 0; /* Check if s is a 'using' node */ while (s && Checkattr(s, "nodeType", "using")) { Node *ss = Swig_symbol_clookup_local(Getattr(s, "uname"), Getattr(s, "sym:symtab")); if (!ss) { Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", Getattr(s, "uname")); } s = ss; } return s; } /* ----------------------------------------------------------------------------- * Swig_symbol_clookup_local_check() * ----------------------------------------------------------------------------- */ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *)) { Hash *hsym; Node *s = 0; if (!n) { hsym = current_symtab; } else { if (!Checkattr(n, "nodeType", "symboltable")) { n = Getattr(n, "sym:symtab"); } assert(n); hsym = n; } if (Swig_scopename_check(name)) { char *cname = Char(name); if (strncmp(cname, "::", 2) == 0) { String *nname = NewString(cname + 2); if (Swig_scopename_check(nname)) { s = symbol_lookup_qualified(nname, global_scope, 0, 0, checkfunc); } else { s = symbol_lookup(nname, global_scope, checkfunc); } Delete(nname); } else { s = symbol_lookup_qualified(name, hsym, 0, 0, checkfunc); } } if (!s) { s = symbol_lookup(name, hsym, checkfunc); } if (!s) return 0; /* Check if s is a 'using' node */ while (s && Checkattr(s, "nodeType", "using")) { Node *ss = Swig_symbol_clookup_local_check(Getattr(s, "uname"), Getattr(s, "sym:symtab"), checkfunc); if (!ss && !checkfunc) { Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", Getattr(s, "uname")); } s = ss; } return s; } /* ----------------------------------------------------------------------------- * Swig_symbol_clookup_no_inherit() * * Symbol lookup like Swig_symbol_clookup but does not follow using declarations. * ----------------------------------------------------------------------------- */ Node *Swig_symbol_clookup_no_inherit(const_String_or_char_ptr name, Symtab *n) { Node *s = 0; assert(use_inherit==1); use_inherit = 0; s = Swig_symbol_clookup(name, n); use_inherit = 1; return s; } /* ----------------------------------------------------------------------------- * Swig_symbol_cscope() * * Look up a scope name. * ----------------------------------------------------------------------------- */ Symtab *Swig_symbol_cscope(const_String_or_char_ptr name, Symtab *symtab) { char *cname = Char(name); if (strncmp(cname, "::", 2) == 0) return symbol_lookup_qualified(0, global_scope, name, 0, 0); return symbol_lookup_qualified(0, symtab, name, 0, 0); } /* ----------------------------------------------------------------------------- * Swig_symbol_remove() * * Remove a symbol. If the symbol is an overloaded function and the symbol removed * is not the last in the list of overloaded functions, then the overloaded * names (sym:overname attribute) are changed to start from zero, eg __SWIG_0. * ----------------------------------------------------------------------------- */ void Swig_symbol_remove(Node *n) { Symtab *symtab; String *symname; String *overname; Node *symprev; Node *symnext; Node *fixovername = 0; symtab = Getattr(n, "sym:symtab"); /* Get symbol table object */ symtab = Getattr(symtab, "symtab"); /* Get actual hash table of symbols */ symname = Getattr(n, "sym:name"); symprev = Getattr(n, "sym:previousSibling"); symnext = Getattr(n, "sym:nextSibling"); /* If previous symbol, just fix the links */ if (symprev) { if (symnext) { Setattr(symprev, "sym:nextSibling", symnext); fixovername = symprev; /* fix as symbol to remove is somewhere in the middle of the linked list */ } else { Delattr(symprev, "sym:nextSibling"); } } else { /* If no previous symbol, see if there is a next symbol */ if (symnext) { Setattr(symtab, symname, symnext); fixovername = symnext; /* fix as symbol to remove is at head of linked list */ } else { if (symname) Delattr(symtab, symname); } } if (symnext) { if (symprev) { Setattr(symnext, "sym:previousSibling", symprev); } else { Delattr(symnext, "sym:previousSibling"); } } Delattr(n, "sym:symtab"); Delattr(n, "sym:previousSibling"); Delattr(n, "sym:nextSibling"); Delattr(n, "csym:nextSibling"); Delattr(n, "sym:overname"); Delattr(n, "csym:previousSibling"); Delattr(n, "sym:overloaded"); n = 0; if (fixovername) { Node *nn = fixovername; Node *head = fixovername; int pn = 0; /* find head of linked list */ while (nn) { head = nn; nn = Getattr(nn, "sym:previousSibling"); } /* adjust all the sym:overname strings to start from 0 and increment by one */ nn = head; while (nn) { assert(Getattr(nn, "sym:overname")); Delattr(nn, "sym:overname"); overname = NewStringf("__SWIG_%d", pn); Setattr(nn, "sym:overname", overname); Delete(overname); pn++; nn = Getattr(nn, "sym:nextSibling"); } } } /* ----------------------------------------------------------------------------- * Swig_symbol_qualified() * * Return the qualified name of a symbol * ----------------------------------------------------------------------------- */ String *Swig_symbol_qualified(Node *n) { Hash *symtab; if (Checkattr(n, "nodeType", "symboltable")) { symtab = n; } else { symtab = Getattr(n, "sym:symtab"); } if (!symtab) return NewStringEmpty(); #ifdef SWIG_DEBUG Printf(stderr, "symbol_qscope %s %p %s\n", Getattr(n, "name"), symtab, Getattr(symtab, "name")); #endif return Swig_symbol_qualifiedscopename(symtab); } /* ----------------------------------------------------------------------------- * Swig_symbol_isoverloaded() * * Check if a symbol is overloaded. Returns the first symbol if so. * ----------------------------------------------------------------------------- */ Node *Swig_symbol_isoverloaded(Node *n) { return Getattr(n, "sym:overloaded"); } /* ----------------------------------------------------------------------------- * symbol_template_qualify() * * Internal function to create a fully qualified type name for templates * ----------------------------------------------------------------------------- */ /* This cache produces problems with OSS, don't active it */ /* #define SWIG_TEMPLATE_QUALIFY_CACHE */ static SwigType *symbol_template_qualify(const SwigType *e, Symtab *st) { String *tprefix, *tsuffix; SwigType *qprefix; List *targs; Node *tempn; Symtab *tscope; Iterator ti; #ifdef SWIG_TEMPLATE_QUALIFY_CACHE static Hash *qualify_cache = 0; String *scopetype = st ? NewStringf("%s::%s", Getattr(st, "name"), e) : NewStringf("%s::%s", Swig_symbol_getscopename(), e); if (!qualify_cache) { qualify_cache = NewHash(); } if (scopetype) { String *cres = Getattr(qualify_cache, scopetype); if (cres) { Delete(scopetype); return Copy(cres); } } #endif tprefix = SwigType_templateprefix(e); tsuffix = SwigType_templatesuffix(e); qprefix = Swig_symbol_type_qualify(tprefix, st); targs = SwigType_parmlist(e); tempn = Swig_symbol_clookup_local(tprefix, st); tscope = tempn ? Getattr(tempn, "sym:symtab") : 0; Append(qprefix, "<("); for (ti = First(targs); ti.item;) { String *vparm; String *qparm = Swig_symbol_type_qualify(ti.item, st); if (tscope && (tscope != st)) { String *ty = Swig_symbol_type_qualify(qparm, tscope); Delete(qparm); qparm = ty; } vparm = Swig_symbol_template_param_eval(qparm, st); Append(qprefix, vparm); ti = Next(ti); if (ti.item) { Putc(',', qprefix); } Delete(qparm); Delete(vparm); } Append(qprefix, ")>"); Append(qprefix, tsuffix); Delete(tprefix); Delete(tsuffix); Delete(targs); #ifdef SWIG_DEBUG Printf(stderr, "symbol_temp_qual %s %s\n", e, qprefix); #endif #ifdef SWIG_TEMPLATE_QUALIFY_CACHE Setattr(qualify_cache, scopetype, qprefix); Delete(scopetype); #endif return qprefix; } static int symbol_no_constructor(Node *n) { return !Checkattr(n, "nodeType", "constructor"); } /* ----------------------------------------------------------------------------- * Swig_symbol_type_qualify() * * Create a fully qualified type name * Note: Does not resolve a constructor if passed in as the 'type'. * ----------------------------------------------------------------------------- */ SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) { List *elements; String *result = NewStringEmpty(); int i, len; char *c = Char(t); if (strncmp(c, "::", 2) == 0) { Append(result, t); return result; } elements = SwigType_split(t); len = Len(elements); for (i = 0; i < len; i++) { String *e = Getitem(elements, i); if (SwigType_issimple(e)) { /* Note: the unary scope operator (::) is being removed from the template parameters here. */ Node *n = Swig_symbol_clookup_check(e, st, symbol_no_constructor); if (n) { String *name = Getattr(n, "name"); Clear(e); Append(e, name); #ifdef SWIG_DEBUG Printf(stderr, "symbol_qual_ei %d %s %s %p\n", i, name, e, st); #endif if (!Swig_scopename_check(name)) { String *qname = Swig_symbol_qualified(n); if (qname && Len(qname)) { Insert(e, 0, "::"); Insert(e, 0, qname); } #ifdef SWIG_DEBUG Printf(stderr, "symbol_qual_sc %d %s %s %p\n", i, qname, e, st); #endif Delete(qname); } } else if (SwigType_istemplate(e)) { SwigType *ty = symbol_template_qualify(e, st); Clear(e); Append(e, ty); Delete(ty); } if (strncmp(Char(e), "::", 2) == 0) { Delitem(e, 0); Delitem(e, 0); } Append(result, e); } else if (SwigType_isfunction(e)) { List *parms = SwigType_parmlist(e); String *s = NewString("f("); Iterator pi = First(parms); while (pi.item) { String *pf = Swig_symbol_type_qualify(pi.item, st); Append(s, pf); pi = Next(pi); if (pi.item) { Append(s, ","); } Delete(pf); } Append(s, ")."); Append(result, s); Delete(parms); Delete(s); } else { Append(result, e); } } Delete(elements); #ifdef SWIG_DEBUG Printf(stderr, "symbol_qualify %s %s %p %s\n", t, result, st, st ? Getattr(st, "name") : 0); #endif return result; } /* ----------------------------------------------------------------------------- * Swig_symbol_template_reduce() * Resolves template parameter types * For example: * typedef int Int; * typedef Int Integer; * with input: * Foo<(Int,Integer)> * returns: * Foo<(int,int)> * ----------------------------------------------------------------------------- */ static SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab) { Parm *p; String *templateargs = SwigType_templateargs(qt); List *parms = SwigType_parmlist(templateargs); Iterator pi = First(parms); String *tprefix = SwigType_templateprefix(qt); String *tsuffix = SwigType_templatesuffix(qt); String *qprefix = SwigType_typedef_qualified(tprefix); Append(qprefix, "<("); while ((p = pi.item)) { String *np; String *tp = Swig_symbol_typedef_reduce(p, ntab); String *qp = Swig_symbol_type_qualify(tp, ntab); Node *n = Swig_symbol_clookup(qp, ntab); if (n) { String *qual = Swig_symbol_qualified(n); np = Copy(Getattr(n, "name")); Delete(tp); tp = np; if (qual && Len(qual)) { Insert(np, 0, "::"); Insert(np, 0, qual); } Delete(qual); } else { np = qp; } Append(qprefix, np); pi = Next(pi); if (pi.item) { Append(qprefix, ","); } Delete(qp); Delete(tp); } Append(qprefix, ")>"); Append(qprefix, tsuffix); Delete(parms); Delete(tprefix); Delete(tsuffix); Delete(templateargs); return qprefix; } /* ----------------------------------------------------------------------------- * Swig_symbol_typedef_reduce() * * Chase a typedef through symbol tables looking for a match. * ----------------------------------------------------------------------------- */ SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab) { SwigType *prefix, *base; Node *n; String *nt; base = SwigType_base(ty); prefix = SwigType_prefix(ty); n = Swig_symbol_clookup(base, tab); if (!n) { if (SwigType_istemplate(ty)) { SwigType *qt = Swig_symbol_template_reduce(base, tab); Append(prefix, qt); Delete(qt); #ifdef SWIG_DEBUG Printf(stderr, "symbol_reduce (a) %s %s\n", ty, prefix); #endif Delete(base); return prefix; } else { Delete(prefix); #ifdef SWIG_DEBUG Printf(stderr, "symbol_reduce (b) %s %s\n", ty, ty); #endif return Copy(ty); } } nt = Getattr(n, "nodeType"); if (Equal(nt, "using")) { String *uname = Getattr(n, "uname"); if (uname) { n = Swig_symbol_clookup(base, Getattr(n, "sym:symtab")); if (!n) { Delete(base); Delete(prefix); #ifdef SWIG_DEBUG Printf(stderr, "symbol_reduce (c) %s %s\n", ty, ty); #endif return Copy(ty); } } } if (Equal(nt, "cdecl")) { String *storage = Getattr(n, "storage"); if (storage && (Equal(storage, "typedef"))) { SwigType *decl; SwigType *rt; SwigType *qt; Symtab *ntab; SwigType *nt = Copy(Getattr(n, "type")); /* Fix for case 'typedef struct Hello hello;' */ { const char *dclass[3] = { "struct ", "union ", "class " }; int i; char *c = Char(nt); for (i = 0; i < 3; i++) { if (strstr(c, dclass[i]) == c) { Replace(nt, dclass[i], "", DOH_REPLACE_FIRST); } } } decl = Getattr(n, "decl"); if (decl) { SwigType_push(nt, decl); } SwigType_push(nt, prefix); Delete(base); Delete(prefix); ntab = Getattr(n, "sym:symtab"); rt = Swig_symbol_typedef_reduce(nt, ntab); qt = Swig_symbol_type_qualify(rt, ntab); if (SwigType_istemplate(qt)) { SwigType *qtr = Swig_symbol_template_reduce(qt, ntab); Delete(qt); qt = qtr; } Delete(nt); Delete(rt); #ifdef SWIG_DEBUG Printf(stderr, "symbol_reduce (d) %s %s\n", qt, ty); #endif return qt; } } Delete(base); Delete(prefix); #ifdef SWIG_DEBUG Printf(stderr, "symbol_reduce (e) %s %s\n", ty, ty); #endif return Copy(ty); } /* ----------------------------------------------------------------------------- * Swig_symbol_string_qualify() * * This function takes a string and looks for identifiers. Identifiers are * then qualified according to scope rules. This function is used in a number * of settings including expression evaluation, scoping of conversion operators, * and so forth. * ----------------------------------------------------------------------------- */ String *Swig_symbol_string_qualify(String *s, Symtab *st) { int have_id = 0; String *id = NewStringEmpty(); String *r = NewStringEmpty(); char *c = Char(s); int first_char = 1; while (*c) { if (isalpha((int) *c) || (*c == '_') || (*c == ':') || (*c == '~' && first_char) || (isdigit((int) *c) && !first_char)) { Putc(*c, id); have_id = 1; } else { if (have_id) { String *qid = Swig_symbol_type_qualify(id, st); Append(r, qid); Clear(id); Delete(qid); have_id = 0; } Putc(*c, r); } first_char = (*c == ':'); c++; } if (have_id) { String *qid = Swig_symbol_type_qualify(id, st); Append(r, qid); Delete(qid); } Delete(id); return r; } /* ----------------------------------------------------------------------------- * Swig_symbol_template_defargs() * * Apply default arg from generic template default args * Returns a parameter list which contains missing default arguments (if any) * Note side effects: parms will also contain the extra parameters in its list * (but only if non-zero). * ----------------------------------------------------------------------------- */ ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl) { ParmList *expandedparms = parms; if (Len(parms) < Len(targs)) { Parm *lp = parms; Parm *p = lp; Parm *tp = targs; while (p && tp) { p = nextSibling(p); tp = nextSibling(tp); if (p) lp = p; } while (tp) { String *value = Getattr(tp, "value"); if (value) { Parm *cp; Parm *ta = targs; Parm *p = parms; SwigType *nt = Swig_symbol_string_qualify(value, tsdecl); SwigType *ntq = 0; #ifdef SWIG_DEBUG Printf(stderr, "value %s %s %s\n", value, nt, tsdecl ? Getattr(tsdecl, "name") : tsdecl); #endif while (p && ta) { String *name = Getattr(ta, "name"); String *pvalue = Getattr(p, "value"); String *value = pvalue ? pvalue : Getattr(p, "type"); String *ttq = Swig_symbol_type_qualify(value, tscope); /* value = SwigType_typedef_resolve_all(value); */ Replaceid(nt, name, ttq); p = nextSibling(p); ta = nextSibling(ta); Delete(ttq); } ntq = Swig_symbol_type_qualify(nt, tsdecl); if (SwigType_istemplate(ntq)) { String *ty = Swig_symbol_template_deftype(ntq, tscope); Delete(ntq); ntq = ty; } /* Printf(stderr,"value %s %s %s\n",value,ntr,ntq); */ cp = NewParmWithoutFileLineInfo(ntq, 0); if (lp) set_nextSibling(lp, cp); else expandedparms = CopyParm(cp); lp = cp; tp = nextSibling(tp); Delete(cp); Delete(nt); Delete(ntq); } else { tp = 0; } } } return expandedparms; } /* ----------------------------------------------------------------------------- * Swig_symbol_template_deftype() * * Apply default args to generic template type * ----------------------------------------------------------------------------- */ #define SWIG_TEMPLATE_DEFTYPE_CACHE SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) { String *result = NewStringEmpty(); List *elements = SwigType_split(type); int len = Len(elements); int i; #ifdef SWIG_TEMPLATE_DEFTYPE_CACHE static Hash *deftype_cache = 0; String *scopetype = tscope ? NewStringf("%s::%s", Getattr(tscope, "name"), type) : NewStringf("%s::%s", Swig_symbol_getscopename(), type); if (!deftype_cache) { deftype_cache = NewHash(); } if (scopetype) { String *cres = Getattr(deftype_cache, scopetype); if (cres) { Append(result, cres); Delete(scopetype); return result; } } #endif #ifdef SWIG_DEBUG Printf(stderr, "finding deftype %s\n", type); #endif for (i = 0; i < len; i++) { String *e = Getitem(elements, i); if (SwigType_isfunction(e)) { String *s = NewString("f("); List *parms = SwigType_parmlist(e); Iterator pi = First(parms); while (pi.item) { String *pf = SwigType_istemplate(e) ? Swig_symbol_template_deftype(pi.item, tscope) : Swig_symbol_type_qualify(pi.item, tscope); Append(s, pf); pi = Next(pi); if (pi.item) { Append(s, ","); } Delete(pf); } Append(s, ")."); Append(result, s); Delete(s); Delete(parms); } else if (SwigType_istemplate(e)) { String *prefix = SwigType_prefix(e); String *base = SwigType_base(e); String *tprefix = SwigType_templateprefix(base); String *targs = SwigType_templateargs(base); String *tsuffix = SwigType_templatesuffix(base); ParmList *tparms = SwigType_function_parms(targs, 0); Node *tempn = Swig_symbol_clookup_local(tprefix, tscope); if (!tempn && tsuffix && Len(tsuffix)) { tempn = Swig_symbol_clookup(tprefix, 0); } #ifdef SWIG_DEBUG Printf(stderr, "deftype type %s %s %d\n", e, tprefix, (long) tempn); #endif if (tempn) { ParmList *tnargs = Getattr(tempn, "templateparms"); ParmList *expandedparms; Parm *p; Symtab *tsdecl = Getattr(tempn, "sym:symtab"); #ifdef SWIG_DEBUG Printf(stderr, "deftype type %s %s %s\n", tprefix, targs, tsuffix); #endif Append(tprefix, "<("); expandedparms = Swig_symbol_template_defargs(tparms, tnargs, tscope, tsdecl); p = expandedparms; tscope = tsdecl; while (p) { SwigType *ptype = Getattr(p, "type"); SwigType *ttr = ptype ? ptype : Getattr(p, "value"); SwigType *ttf = Swig_symbol_type_qualify(ttr, tscope); SwigType *ttq = Swig_symbol_template_param_eval(ttf, tscope); #ifdef SWIG_DEBUG Printf(stderr, "arg type %s\n", ttq); #endif if (SwigType_istemplate(ttq)) { SwigType *ttd = Swig_symbol_template_deftype(ttq, tscope); Delete(ttq); ttq = ttd; #ifdef SWIG_DEBUG Printf(stderr, "arg deftype %s\n", ttq); #endif } Append(tprefix, ttq); p = nextSibling(p); if (p) Putc(',', tprefix); Delete(ttf); Delete(ttq); } Append(tprefix, ")>"); Append(tprefix, tsuffix); Append(prefix, tprefix); #ifdef SWIG_DEBUG Printf(stderr, "deftype %s %s \n", type, tprefix); #endif Append(result, prefix); } else { Append(result, e); } Delete(prefix); Delete(base); Delete(tprefix); Delete(tsuffix); Delete(targs); Delete(tparms); } else { Append(result, e); } } Delete(elements); #ifdef SWIG_TEMPLATE_DEFTYPE_CACHE Setattr(deftype_cache, scopetype, result); Delete(scopetype); #endif return result; } SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab) { String *value = Copy(p); Node *lastnode = 0; while (1) { Node *n = Swig_symbol_clookup(value, symtab); if (n == lastnode) break; lastnode = n; if (n) { String *nt = Getattr(n, "nodeType"); if (Equal(nt, "enumitem")) { /* An enum item. Generate a fully qualified name */ String *qn = Swig_symbol_qualified(n); if (qn && Len(qn)) { Append(qn, "::"); Append(qn, Getattr(n, "name")); Delete(value); value = qn; continue; } else { Delete(qn); break; } } else if ((Equal(nt, "cdecl"))) { String *nv = Getattr(n, "value"); if (nv) { Delete(value); value = Copy(nv); continue; } } } break; } return value; } swig-3.0.2/Source/Swig/swigtree.h0000664000175000017500000000450212343605122016517 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swigtree.h * * These functions are used to access and manipulate the SWIG parse tree. * The structure of this tree is modeled directly after XML-DOM. The attribute * and function names are meant to be similar. * ----------------------------------------------------------------------------- */ /* Macros to traverse the DOM tree */ #define nodeType(x) Getattr(x,"nodeType") #define parentNode(x) Getattr(x,"parentNode") #define previousSibling(x) Getattr(x,"previousSibling") #define nextSibling(x) Getattr(x,"nextSibling") #define firstChild(x) Getattr(x,"firstChild") #define lastChild(x) Getattr(x,"lastChild") /* Macros to set up the DOM tree (mostly used by the parser) */ #define set_nodeType(x,v) Setattr(x,"nodeType",v) #define set_parentNode(x,v) Setattr(x,"parentNode",v) #define set_previousSibling(x,v) Setattr(x,"previousSibling",v) #define set_nextSibling(x,v) Setattr(x,"nextSibling",v) #define set_firstChild(x,v) Setattr(x,"firstChild",v) #define set_lastChild(x,v) Setattr(x,"lastChild",v) /* Utility functions */ extern int checkAttribute(Node *obj, const_String_or_char_ptr name, const_String_or_char_ptr value); extern void appendChild(Node *node, Node *child); extern void prependChild(Node *node, Node *child); extern void removeNode(Node *node); extern Node *copyNode(Node *node); extern void appendSibling(Node *node, Node *child); /* Node restoration/restore functions */ extern void Swig_require(const char *ns, Node *node, ...); extern void Swig_save(const char *ns, Node *node, ...); extern void Swig_restore(Node *node); /* Debugging of parse trees */ extern void Swig_print_tags(File *obj, Node *root); extern void Swig_print_tree(Node *obj); extern void Swig_print_node(Node *obj); swig-3.0.2/Source/Swig/swig.h0000664000175000017500000005212112343605122015637 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swig.h * * Header file for the SWIG core. * ----------------------------------------------------------------------------- */ #ifndef SWIGCORE_H_ #define SWIGCORE_H_ #ifndef MACSWIG #include "swigconfig.h" #endif #include #include #include #include #ifdef __cplusplus extern "C" { #endif #include "doh.h" /* Status codes */ #define SWIG_OK 1 #define SWIG_ERROR 0 #define SWIG_NOWRAP 0 /* Global macros */ #define NSPACE_SEPARATOR "." /* Namespace separator for the nspace feature - this should be changed to a target language configurable variable */ #define NSPACE_TODO 0 /* Languages that still need to implement and test the nspace feature use this */ /* Short names for common data types */ typedef DOH String; typedef DOH Hash; typedef DOH List; typedef DOH String_or_char; typedef DOH File; typedef DOH Parm; typedef DOH ParmList; typedef DOH Node; typedef DOH Symtab; typedef DOH Typetab; typedef DOH SwigType; /* --- Legacy DataType interface. These type codes are provided solely for backwards compatibility with older modules --- */ /* --- The ordering of type values is used to determine type-promotion in the parser. Do not change */ /* Numeric types */ #define T_BOOL 1 #define T_SCHAR 2 #define T_UCHAR 3 #define T_SHORT 4 #define T_USHORT 5 #define T_ENUM 6 #define T_INT 7 #define T_UINT 8 #define T_LONG 9 #define T_ULONG 10 #define T_LONGLONG 11 #define T_ULONGLONG 12 #define T_FLOAT 20 #define T_DOUBLE 21 #define T_LONGDOUBLE 22 #define T_FLTCPLX 23 #define T_DBLCPLX 24 #define T_NUMERIC 25 #define T_AUTO 26 #define T_COMPLEX T_DBLCPLX /* non-numeric */ #define T_CHAR 29 #define T_WCHAR 30 #define T_USER 31 #define T_VOID 32 #define T_STRING 33 #define T_POINTER 34 #define T_REFERENCE 35 #define T_ARRAY 36 #define T_FUNCTION 37 #define T_MPOINTER 38 #define T_VARARGS 39 #define T_RVALUE_REFERENCE 40 #define T_WSTRING 41 #define T_SYMBOL 98 #define T_ERROR 99 /* --- File interface --- */ #include "swigfile.h" /* --- Command line parsing --- */ #include "swigopt.h" /* --- Scanner Interface --- */ #include "swigscan.h" /* --- Functions for manipulating the string-based type encoding --- */ extern SwigType *NewSwigType(int typecode); extern SwigType *SwigType_del_element(SwigType *t); extern SwigType *SwigType_add_pointer(SwigType *t); extern SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr qual); extern SwigType *SwigType_del_memberpointer(SwigType *t); extern SwigType *SwigType_del_pointer(SwigType *t); extern SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size); extern SwigType *SwigType_del_array(SwigType *t); extern SwigType *SwigType_pop_arrays(SwigType *t); extern SwigType *SwigType_add_reference(SwigType *t); extern SwigType *SwigType_del_reference(SwigType *t); extern SwigType *SwigType_add_rvalue_reference(SwigType *t); extern SwigType *SwigType_del_rvalue_reference(SwigType *t); extern SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual); extern SwigType *SwigType_del_qualifier(SwigType *t); extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms); extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms); extern SwigType *SwigType_pop_function(SwigType *t); extern ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node); extern List *SwigType_split(const SwigType *t); extern String *SwigType_pop(SwigType *t); extern void SwigType_push(SwigType *t, String *s); extern List *SwigType_parmlist(const SwigType *p); extern String *SwigType_parm(const SwigType *p); extern String *SwigType_str(const SwigType *s, const_String_or_char_ptr id); extern String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id); extern String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr id); extern String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr id); extern String *SwigType_manglestr(const SwigType *t); extern SwigType *SwigType_ltype(const SwigType *t); extern int SwigType_ispointer(const SwigType *t); extern int SwigType_ispointer_return(const SwigType *t); extern int SwigType_isfunctionpointer(const SwigType *t); extern int SwigType_ismemberpointer(const SwigType *t); extern int SwigType_isreference(const SwigType *t); extern int SwigType_isreference_return(const SwigType *t); extern int SwigType_isrvalue_reference(const SwigType *t); extern int SwigType_isarray(const SwigType *t); extern int SwigType_prefix_is_simple_1D_array(const SwigType *t); extern int SwigType_isfunction(const SwigType *t); extern int SwigType_isqualifier(const SwigType *t); extern int SwigType_isconst(const SwigType *t); extern int SwigType_issimple(const SwigType *t); extern int SwigType_ismutable(const SwigType *t); extern int SwigType_isvarargs(const SwigType *t); extern int SwigType_istemplate(const SwigType *t); extern int SwigType_isenum(const SwigType *t); extern int SwigType_check_decl(const SwigType *t, const_String_or_char_ptr decl); extern SwigType *SwigType_strip_qualifiers(const SwigType *t); extern SwigType *SwigType_strip_single_qualifier(const SwigType *t); extern SwigType *SwigType_functionpointer_decompose(SwigType *t); extern String *SwigType_base(const SwigType *t); extern String *SwigType_namestr(const SwigType *t); extern String *SwigType_templateprefix(const SwigType *t); extern String *SwigType_templatesuffix(const SwigType *t); extern String *SwigType_istemplate_templateprefix(const SwigType *t); extern String *SwigType_istemplate_only_templateprefix(const SwigType *t); extern String *SwigType_templateargs(const SwigType *t); extern String *SwigType_prefix(const SwigType *t); extern int SwigType_array_ndim(const SwigType *t); extern String *SwigType_array_getdim(const SwigType *t, int n); extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep); extern SwigType *SwigType_array_type(const SwigType *t); extern SwigType *SwigType_default_create(const SwigType *ty); extern SwigType *SwigType_default_deduce(const SwigType *t); extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep); extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t); extern SwigType *SwigType_alttype(const SwigType *t, int ltmap); /* --- Type-system managment --- */ extern void SwigType_typesystem_init(void); extern int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name); extern int SwigType_typedef_class(const_String_or_char_ptr name); extern int SwigType_typedef_using(const_String_or_char_ptr qname); extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode); extern int SwigType_issubtype(const SwigType *subtype, const SwigType *basetype); extern void SwigType_scope_alias(String *aliasname, Typetab *t); extern void SwigType_using_scope(Typetab *t); extern void SwigType_new_scope(const_String_or_char_ptr name); extern void SwigType_inherit_scope(Typetab *scope); extern Typetab *SwigType_pop_scope(void); extern Typetab *SwigType_set_scope(Typetab *h); extern void SwigType_print_scope(void); extern SwigType *SwigType_typedef_resolve(const SwigType *t); extern SwigType *SwigType_typedef_resolve_all(const SwigType *t); extern SwigType *SwigType_typedef_qualified(const SwigType *t); extern int SwigType_istypedef(const SwigType *t); extern int SwigType_isclass(const SwigType *t); extern void SwigType_attach_symtab(Symtab *syms); extern void SwigType_remember(const SwigType *t); extern void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata); extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata); extern void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *); extern void SwigType_emit_type_table(File *f_headers, File *f_table); extern int SwigType_type(const SwigType *t); /* --- Symbol table module --- */ extern void Swig_symbol_print_tables(Symtab *symtab); extern void Swig_symbol_print_tables_summary(void); extern void Swig_symbol_print_symbols(void); extern void Swig_symbol_print_csymbols(void); extern void Swig_symbol_init(void); extern void Swig_symbol_setscopename(const_String_or_char_ptr name); extern String *Swig_symbol_getscopename(void); extern String *Swig_symbol_qualifiedscopename(Symtab *symtab); extern String *Swig_symbol_qualified_language_scopename(Symtab *symtab); extern Symtab *Swig_symbol_newscope(void); extern Symtab *Swig_symbol_setscope(Symtab *); extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname); extern Symtab *Swig_symbol_global_scope(void); extern Symtab *Swig_symbol_current(void); extern Symtab *Swig_symbol_popscope(void); extern Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *node); extern void Swig_symbol_cadd(const_String_or_char_ptr symname, Node *node); extern Node *Swig_symbol_clookup(const_String_or_char_ptr symname, Symtab *tab); extern Node *Swig_symbol_clookup_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *)); extern Node *Swig_symbol_clookup_no_inherit(const_String_or_char_ptr name, Symtab *n); extern Symtab *Swig_symbol_cscope(const_String_or_char_ptr symname, Symtab *tab); extern Node *Swig_symbol_clookup_local(const_String_or_char_ptr symname, Symtab *tab); extern Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *)); extern String *Swig_symbol_qualified(Node *node); extern Node *Swig_symbol_isoverloaded(Node *node); extern void Swig_symbol_remove(Node *node); extern void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *tab); extern void Swig_symbol_inherit(Symtab *tab); extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab); extern String *Swig_symbol_string_qualify(String *s, Symtab *tab); extern SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab); extern ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl); extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope); extern SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab); /* --- Parameters and Parameter Lists --- */ #include "swigparm.h" extern String *ParmList_errorstr(ParmList *); extern int ParmList_is_compactdefargs(ParmList *p); /* --- Parse tree support --- */ #include "swigtree.h" /* -- Wrapper function Object */ #include "swigwrap.h" /* --- Naming functions --- */ extern void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format); extern void Swig_name_unregister(const_String_or_char_ptr method); extern String *Swig_name_mangle(const_String_or_char_ptr s); extern String *Swig_name_wrapper(const_String_or_char_ptr fname); extern String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername); extern String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname); extern String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname); extern String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname); extern String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname); extern String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname); extern String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname); extern void Swig_naming_init(void); extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn); extern Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl); extern void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *namewrn, ParmList *declaratorparms); extern void Swig_name_inherit(String *base, String *derived); extern List *Swig_make_inherit_list(String *clsname, List *names, String *Namespaceprefix); extern void Swig_inherit_base_symbols(List *bases); extern int Swig_need_protected(Node *n); extern int Swig_need_name_warning(Node *n); extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass); extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname); extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl); extern String *Swig_name_str(Node *n); extern String *Swig_name_decl(Node *n); extern String *Swig_name_fulldecl(Node *n); /* --- parameterized rename functions --- */ extern void Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object); extern DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *decl); extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived); extern void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl, Node *n); extern void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, const_String_or_char_ptr value, Hash *featureattribs); /* --- Misc --- */ extern char *Swig_copy_string(const char *c); extern void Swig_set_fakeversion(const char *version); extern const char *Swig_package_version(void); extern void Swig_banner(File *f); extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar); extern String *Swig_strip_c_comments(const String *s); extern String *Swig_new_subdirectory(String *basedirectory, String *subdirectory); extern void Swig_filename_correct(String *filename); extern String *Swig_filename_escape(String *filename); extern void Swig_filename_unescape(String *filename); extern int Swig_storage_isextern(Node *n); extern int Swig_storage_isexternc(Node *n); extern int Swig_storage_isstatic_custom(Node *n, const_String_or_char_ptr storage); extern int Swig_storage_isstatic(Node *n); extern String *Swig_string_escape(String *s); extern String *Swig_string_mangle(const String *s); extern void Swig_scopename_split(const String *s, String **prefix, String **last); extern String *Swig_scopename_prefix(const String *s); extern String *Swig_scopename_last(const String *s); extern String *Swig_scopename_first(const String *s); extern String *Swig_scopename_suffix(const String *s); extern int Swig_scopename_check(const String *s); extern String *Swig_string_lower(String *s); extern String *Swig_string_upper(String *s); extern String *Swig_string_title(String *s); extern void Swig_offset_string(String *s, int number); extern String *Swig_pcre_version(void); extern void Swig_init(void); extern int Swig_value_wrapper_mode(int mode); typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat; extern void Swig_warning(int num, const_String_or_char_ptr filename, int line, const char *fmt, ...); extern void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...); extern int Swig_error_count(void); extern void Swig_error_silent(int s); extern void Swig_warnfilter(const_String_or_char_ptr wlist, int val); extern void Swig_warnall(void); extern int Swig_warn_count(void); extern void Swig_error_msg_format(ErrorMessageFormat format); extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...); extern String *Swig_stringify_with_location(DOH *object); /* --- C Wrappers --- */ extern void Swig_cresult_name_set(const char *new_name); extern const char *Swig_cresult_name(void); extern String *Swig_cparm_name(Parm *p, int i); extern String *Swig_wrapped_var_type(SwigType *t, int varcref); extern int Swig_cargs(Wrapper *w, ParmList *l); extern String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl); extern String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms); extern String *Swig_cconstructor_call(const_String_or_char_ptr name); extern String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms); extern String *Swig_unref_call(Node *n); extern String *Swig_ref_call(Node *n, const String *lname); extern String *Swig_cdestructor_call(Node *n); extern String *Swig_cppdestructor_call(Node *n); extern String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref); extern String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref); extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self); extern void Swig_replace_special_variables(Node *n, Node *parentnode, String *code); /* --- Transformations --- */ extern int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director); extern int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags, String *directorname); extern int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags); extern int Swig_MembersetToFunction(Node *n, String *classname, int flags); extern int Swig_MembergetToFunction(Node *n, String *classname, int flags); extern int Swig_VargetToFunction(Node *n, int flags); extern int Swig_VarsetToFunction(Node *n, int flags); #define CWRAP_EXTEND 0x01 #define CWRAP_SMART_POINTER 0x02 #define CWRAP_NATURAL_VAR 0x04 #define CWRAP_DIRECTOR_ONE_CALL 0x08 #define CWRAP_DIRECTOR_TWO_CALLS 0x10 #define CWRAP_ALL_PROTECTED_ACCESS 0x20 #define CWRAP_SMART_POINTER_OVERLOAD 0x40 /* --- Director Helpers --- */ extern Node *Swig_methodclass(Node *n); extern int Swig_directorclass(Node *n); extern Node *Swig_directormap(Node *n, String *type); /* --- Legacy Typemap API (somewhat simplified, ha!) --- */ extern void Swig_typemap_init(void); extern void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs); extern int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcpattern, ParmList *pattern); extern void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *pattern); extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat); extern void Swig_typemap_clear_apply(ParmList *pattern); extern void Swig_typemap_debug(void); extern void Swig_typemap_search_debug_set(void); extern void Swig_typemap_used_debug_set(void); extern void Swig_typemap_register_debug_set(void); extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f); extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode); extern void Swig_typemap_new_scope(void); extern Hash *Swig_typemap_pop_scope(void); extern void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f); /* --- Code fragment support --- */ extern void Swig_fragment_register(Node *fragment); extern void Swig_fragment_emit(String *name); extern void Swig_fragment_clear(String *section); /* --- Extension support --- */ extern Hash *Swig_extend_hash(void); extern void Swig_extend_merge(Node *cls, Node *am); extern void Swig_extend_append_previous(Node *cls, Node *am); extern void Swig_extend_unused_check(void); /* hacks defined in C++ ! */ extern int Swig_director_mode(void); extern int Swig_director_protected_mode(void); extern int Swig_all_protected_mode(void); extern void Wrapper_director_mode_set(int); extern void Wrapper_director_protected_mode_set(int); extern void Wrapper_all_protected_mode_set(int); extern void Language_replace_special_variables(String *method, String *tm, Parm *parm); extern void Swig_print(DOH *object, int count); extern void Swig_print_with_location(DOH *object, int count); /* -- template init -- */ extern void SwigType_template_init(void); #ifdef __cplusplus } #endif #endif swig-3.0.2/Source/Swig/wrapfunc.c0000664000175000017500000003100212343605122016501 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * wrapfunc.c * * This file defines a object for creating wrapper functions. Primarily * this is used for convenience since it allows pieces of a wrapper function * to be created in a piecemeal manner. * ----------------------------------------------------------------------------- */ #include "swig.h" #include static int Compact_mode = 0; /* set to 0 on default */ static int Max_line_size = 128; /* ----------------------------------------------------------------------------- * NewWrapper() * * Create a new wrapper function object. * ----------------------------------------------------------------------------- */ Wrapper *NewWrapper(void) { Wrapper *w; w = (Wrapper *) malloc(sizeof(Wrapper)); w->localh = NewHash(); w->locals = NewStringEmpty(); w->code = NewStringEmpty(); w->def = NewStringEmpty(); return w; } /* ----------------------------------------------------------------------------- * DelWrapper() * * Delete a wrapper function object. * ----------------------------------------------------------------------------- */ void DelWrapper(Wrapper *w) { Delete(w->localh); Delete(w->locals); Delete(w->code); Delete(w->def); free(w); } /* ----------------------------------------------------------------------------- * Wrapper_compact_print_mode_set() * * Set compact_mode. * ----------------------------------------------------------------------------- */ void Wrapper_compact_print_mode_set(int flag) { Compact_mode = flag; } /* ----------------------------------------------------------------------------- * Wrapper_pretty_print() * * Formats a wrapper function and fixes up the indentation. * ----------------------------------------------------------------------------- */ void Wrapper_pretty_print(String *str, File *f) { String *ts; int level = 0; int c, i; int empty = 1; int indent = 2; int plevel = 0; int label = 0; ts = NewStringEmpty(); Seek(str, 0, SEEK_SET); while ((c = Getc(str)) != EOF) { if (c == '\"') { Putc(c, ts); while ((c = Getc(str)) != EOF) { if (c == '\\') { Putc(c, ts); c = Getc(str); } Putc(c, ts); if (c == '\"') break; } empty = 0; } else if (c == '\'') { Putc(c, ts); while ((c = Getc(str)) != EOF) { if (c == '\\') { Putc(c, ts); c = Getc(str); } Putc(c, ts); if (c == '\'') break; } empty = 0; } else if (c == ':') { Putc(c, ts); if ((c = Getc(str)) == '\n') { if (!empty && !strchr(Char(ts), '?')) label = 1; } Ungetc(c, str); } else if (c == '(') { Putc(c, ts); plevel += indent; empty = 0; } else if (c == ')') { Putc(c, ts); plevel -= indent; empty = 0; } else if (c == '{') { Putc(c, ts); Putc('\n', ts); for (i = 0; i < level; i++) Putc(' ', f); Printf(f, "%s", ts); Clear(ts); level += indent; while ((c = Getc(str)) != EOF) { if (!isspace(c)) { Ungetc(c, str); break; } } empty = 0; } else if (c == '}') { if (!empty) { Putc('\n', ts); for (i = 0; i < level; i++) Putc(' ', f); Printf(f, "%s", ts); Clear(ts); } level -= indent; Putc(c, ts); empty = 0; } else if (c == '\n') { Putc(c, ts); empty = 0; if (!empty) { int slevel = level; if (label && (slevel >= indent)) slevel -= indent; if ((Char(ts))[0] != '#') { for (i = 0; i < slevel; i++) Putc(' ', f); } Printf(f, "%s", ts); for (i = 0; i < plevel; i++) Putc(' ', f); } Clear(ts); label = 0; empty = 1; } else if (c == '/') { empty = 0; Putc(c, ts); c = Getc(str); if (c != EOF) { Putc(c, ts); if (c == '/') { /* C++ comment */ while ((c = Getc(str)) != EOF) { if (c == '\n') { Ungetc(c, str); break; } Putc(c, ts); } } else if (c == '*') { /* C comment */ int endstar = 0; while ((c = Getc(str)) != EOF) { if (endstar && c == '/') { /* end of C comment */ Putc(c, ts); break; } endstar = (c == '*'); Putc(c, ts); if (c == '\n') { /* multi-line C comment. Could be improved slightly. */ for (i = 0; i < level; i++) Putc(' ', ts); } } } } } else { if (!empty || !isspace(c)) { Putc(c, ts); empty = 0; } } } if (!empty) Printf(f, "%s", ts); Delete(ts); Printf(f, "\n"); } /* ----------------------------------------------------------------------------- * Wrapper_compact_print() * * Formats a wrapper function and fixes up the indentation. * Print out in compact format, with Compact enabled. * ----------------------------------------------------------------------------- */ void Wrapper_compact_print(String *str, File *f) { String *ts, *tf; /*temp string & temp file */ int level = 0; int c, i; int empty = 1; int indent = 2; ts = NewStringEmpty(); tf = NewStringEmpty(); Seek(str, 0, SEEK_SET); while ((c = Getc(str)) != EOF) { if (c == '\"') { /* string 1 */ empty = 0; Putc(c, ts); while ((c = Getc(str)) != EOF) { if (c == '\\') { Putc(c, ts); c = Getc(str); } Putc(c, ts); if (c == '\"') break; } } else if (c == '\'') { /* string 2 */ empty = 0; Putc(c, ts); while ((c = Getc(str)) != EOF) { if (c == '\\') { Putc(c, ts); c = Getc(str); } Putc(c, ts); if (c == '\'') break; } } else if (c == '{') { /* start of {...} */ empty = 0; Putc(c, ts); if (Len(tf) == 0) { for (i = 0; i < level; i++) Putc(' ', tf); } else if ((Len(tf) + Len(ts)) < Max_line_size) { Putc(' ', tf); } else { Putc('\n', tf); Printf(f, "%s", tf); Clear(tf); for (i = 0; i < level; i++) Putc(' ', tf); } Append(tf, ts); Clear(ts); level += indent; while ((c = Getc(str)) != EOF) { if (!isspace(c)) { Ungetc(c, str); break; } } } else if (c == '}') { /* end of {...} */ empty = 0; if (Len(tf) == 0) { for (i = 0; i < level; i++) Putc(' ', tf); } else if ((Len(tf) + Len(ts)) < Max_line_size) { Putc(' ', tf); } else { Putc('\n', tf); Printf(f, "%s", tf); Clear(tf); for (i = 0; i < level; i++) Putc(' ', tf); } Append(tf, ts); Putc(c, tf); Clear(ts); level -= indent; } else if (c == '\n') { /* line end */ while ((c = Getc(str)) != EOF) { if (!isspace(c)) break; } if (c == '#') { Putc('\n', ts); } else if (c == '}') { Putc(' ', ts); } else if ((c != EOF) || (Len(ts) != 0)) { if (Len(tf) == 0) { for (i = 0; i < level; i++) Putc(' ', tf); } else if ((Len(tf) + Len(ts)) < Max_line_size) { Putc(' ', tf); } else { Putc('\n', tf); Printf(f, "%s", tf); Clear(tf); for (i = 0; i < level; i++) Putc(' ', tf); } Append(tf, ts); Clear(ts); } Ungetc(c, str); empty = 1; } else if (c == '/') { /* comment */ empty = 0; c = Getc(str); if (c != EOF) { if (c == '/') { /* C++ comment */ while ((c = Getc(str)) != EOF) { if (c == '\n') { Ungetc(c, str); break; } } } else if (c == '*') { /* C comment */ int endstar = 0; while ((c = Getc(str)) != EOF) { if (endstar && c == '/') { /* end of C comment */ break; } endstar = (c == '*'); } } else { Putc('/', ts); Putc(c, ts); } } } else if (c == '#') { /* Preprocessor line */ Putc('#', ts); while ((c = Getc(str)) != EOF) { Putc(c, ts); if (c == '\\') { /* Continued line of the same PP */ c = Getc(str); if (c == '\n') Putc(c, ts); else Ungetc(c, str); } else if (c == '\n') break; } if (!empty) { Append(tf, "\n"); } Append(tf, ts); Printf(f, "%s", tf); Clear(tf); Clear(ts); for (i = 0; i < level; i++) Putc(' ', tf); empty = 1; } else { if (!empty || !isspace(c)) { Putc(c, ts); empty = 0; } } } if (!empty) { Append(tf, ts); } if (Len(tf) != 0) Printf(f, "%s", tf); Delete(ts); Delete(tf); Printf(f, "\n"); } /* ----------------------------------------------------------------------------- * Wrapper_print() * * Print out a wrapper function. Does pretty or compact printing as well. * ----------------------------------------------------------------------------- */ void Wrapper_print(Wrapper *w, File *f) { String *str; str = NewStringEmpty(); Printf(str, "%s\n", w->def); Printf(str, "%s\n", w->locals); Printf(str, "%s\n", w->code); if (Compact_mode == 1) Wrapper_compact_print(str, f); else Wrapper_pretty_print(str, f); Delete(str); } /* ----------------------------------------------------------------------------- * Wrapper_add_local() * * Adds a new local variable declaration to a function. Returns -1 if already * present (which may or may not be okay to the caller). * ----------------------------------------------------------------------------- */ int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) { /* See if the local has already been declared */ if (Getattr(w->localh, name)) { return -1; } Setattr(w->localh, name, decl); Printf(w->locals, "%s;\n", decl); return 0; } /* ----------------------------------------------------------------------------- * Wrapper_add_localv() * * Same as add_local(), but allows a NULL terminated list of strings to be * used as a replacement for decl. This saves the caller the trouble of having * to manually construct the 'decl' string before calling. * ----------------------------------------------------------------------------- */ int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...) { va_list ap; int ret; String *decl; DOH *obj; decl = NewStringEmpty(); va_start(ap, name); obj = va_arg(ap, void *); while (obj) { Append(decl, obj); Putc(' ', decl); obj = va_arg(ap, void *); } va_end(ap); ret = Wrapper_add_local(w, name, decl); Delete(decl); return ret; } /* ----------------------------------------------------------------------------- * Wrapper_check_local() * * Check to see if a local name has already been declared * ----------------------------------------------------------------------------- */ int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name) { if (Getattr(w->localh, name)) { return 1; } return 0; } /* ----------------------------------------------------------------------------- * Wrapper_new_local() * * Adds a new local variable with a guarantee that a unique local name will be * used. Returns the name that was actually selected. * ----------------------------------------------------------------------------- */ char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) { int i; String *nname = NewString(name); String *ndecl = NewString(decl); char *ret; i = 0; while (Wrapper_check_local(w, nname)) { Clear(nname); Printf(nname, "%s%d", name, i); i++; } Replace(ndecl, name, nname, DOH_REPLACE_ID); Setattr(w->localh, nname, ndecl); Printf(w->locals, "%s;\n", ndecl); ret = Char(nname); Delete(nname); Delete(ndecl); return ret; /* Note: nname should still exists in the w->localh hash */ } /* ----------------------------------------------------------------------------- * Wrapper_new_localv() * * Same as add_local(), but allows a NULL terminated list of strings to be * used as a replacement for decl. This saves the caller the trouble of having * to manually construct the 'decl' string before calling. * ----------------------------------------------------------------------------- */ char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...) { va_list ap; char *ret; String *decl; DOH *obj; decl = NewStringEmpty(); va_start(ap, name); obj = va_arg(ap, void *); while (obj) { Append(decl, obj); Putc(' ', decl); obj = va_arg(ap, void *); } va_end(ap); ret = Wrapper_new_local(w, name, decl); Delete(decl); return ret; } swig-3.0.2/Source/Swig/swigscan.h0000664000175000017500000001321612343605122016506 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swigscan.h * * C/C++ scanner. * ----------------------------------------------------------------------------- */ typedef struct Scanner Scanner; extern Scanner *NewScanner(void); extern void DelScanner(Scanner *); extern void Scanner_clear(Scanner *); extern void Scanner_push(Scanner *, String *); extern void Scanner_pushtoken(Scanner *, int, const_String_or_char_ptr value); extern int Scanner_token(Scanner *); extern String *Scanner_text(Scanner *); extern void Scanner_skip_line(Scanner *); extern int Scanner_skip_balanced(Scanner *, int startchar, int endchar); extern String *Scanner_get_raw_text_balanced(Scanner *, int startchar, int endchar); extern void Scanner_set_location(Scanner *, String *file, int line); extern String *Scanner_file(Scanner *); extern int Scanner_line(Scanner *); extern int Scanner_start_line(Scanner *); extern void Scanner_idstart(Scanner *, const char *idchar); extern String *Scanner_errmsg(Scanner *); extern int Scanner_errline(Scanner *); extern int Scanner_isoperator(int tokval); extern void Scanner_locator(Scanner *, String *loc); /* Note: Tokens in range 100+ are for C/C++ operators */ #define SWIG_MAXTOKENS 200 #define SWIG_TOKEN_LPAREN 1 /* ( */ #define SWIG_TOKEN_RPAREN 2 /* ) */ #define SWIG_TOKEN_SEMI 3 /* ; */ #define SWIG_TOKEN_LBRACE 4 /* { */ #define SWIG_TOKEN_RBRACE 5 /* } */ #define SWIG_TOKEN_LBRACKET 6 /* [ */ #define SWIG_TOKEN_RBRACKET 7 /* ] */ #define SWIG_TOKEN_BACKSLASH 8 /* \ */ #define SWIG_TOKEN_ENDLINE 9 /* \n */ #define SWIG_TOKEN_STRING 10 /* "str" */ #define SWIG_TOKEN_POUND 11 /* # */ #define SWIG_TOKEN_COLON 12 /* : */ #define SWIG_TOKEN_DCOLON 13 /* :: */ #define SWIG_TOKEN_DCOLONSTAR 14 /* ::* */ #define SWIG_TOKEN_ID 15 /* identifer */ #define SWIG_TOKEN_FLOAT 16 /* 3.1415F */ #define SWIG_TOKEN_DOUBLE 17 /* 3.1415 */ #define SWIG_TOKEN_INT 18 /* 314 */ #define SWIG_TOKEN_UINT 19 /* 314U */ #define SWIG_TOKEN_LONG 20 /* 314L */ #define SWIG_TOKEN_ULONG 21 /* 314UL */ #define SWIG_TOKEN_CHAR 22 /* 'charconst' */ #define SWIG_TOKEN_PERIOD 23 /* . */ #define SWIG_TOKEN_AT 24 /* @ */ #define SWIG_TOKEN_DOLLAR 25 /* $ */ #define SWIG_TOKEN_CODEBLOCK 26 /* %{ ... %} ... */ #define SWIG_TOKEN_RSTRING 27 /* `charconst` */ #define SWIG_TOKEN_LONGLONG 28 /* 314LL */ #define SWIG_TOKEN_ULONGLONG 29 /* 314ULL */ #define SWIG_TOKEN_QUESTION 30 /* ? */ #define SWIG_TOKEN_COMMENT 31 /* C or C++ comment */ #define SWIG_TOKEN_BOOL 32 /* true or false */ #define SWIG_TOKEN_WSTRING 33 /* L"str" */ #define SWIG_TOKEN_WCHAR 34 /* L'c' */ #define SWIG_TOKEN_ILLEGAL 99 #define SWIG_TOKEN_ERROR -1 #define SWIG_TOKEN_COMMA 101 /* , */ #define SWIG_TOKEN_STAR 102 /* * */ #define SWIG_TOKEN_TIMES 102 /* * */ #define SWIG_TOKEN_EQUAL 103 /* = */ #define SWIG_TOKEN_EQUALTO 104 /* == */ #define SWIG_TOKEN_NOTEQUAL 105 /* != */ #define SWIG_TOKEN_PLUS 106 /* + */ #define SWIG_TOKEN_MINUS 107 /* - */ #define SWIG_TOKEN_AND 108 /* & */ #define SWIG_TOKEN_LAND 109 /* && */ #define SWIG_TOKEN_OR 110 /* | */ #define SWIG_TOKEN_LOR 111 /* || */ #define SWIG_TOKEN_XOR 112 /* ^ */ #define SWIG_TOKEN_LESSTHAN 113 /* < */ #define SWIG_TOKEN_GREATERTHAN 114 /* > */ #define SWIG_TOKEN_LTEQUAL 115 /* <= */ #define SWIG_TOKEN_GTEQUAL 116 /* >= */ #define SWIG_TOKEN_NOT 117 /* ~ */ #define SWIG_TOKEN_LNOT 118 /* ! */ #define SWIG_TOKEN_SLASH 119 /* / */ #define SWIG_TOKEN_DIVIDE 119 /* / */ #define SWIG_TOKEN_PERCENT 120 /* % */ #define SWIG_TOKEN_MODULO 120 /* % */ #define SWIG_TOKEN_LSHIFT 121 /* << */ #define SWIG_TOKEN_RSHIFT 122 /* >> */ #define SWIG_TOKEN_PLUSPLUS 123 /* ++ */ #define SWIG_TOKEN_MINUSMINUS 124 /* -- */ #define SWIG_TOKEN_PLUSEQUAL 125 /* += */ #define SWIG_TOKEN_MINUSEQUAL 126 /* -= */ #define SWIG_TOKEN_TIMESEQUAL 127 /* *= */ #define SWIG_TOKEN_DIVEQUAL 128 /* /= */ #define SWIG_TOKEN_ANDEQUAL 129 /* &= */ #define SWIG_TOKEN_OREQUAL 130 /* |= */ #define SWIG_TOKEN_XOREQUAL 131 /* ^= */ #define SWIG_TOKEN_LSEQUAL 132 /* <<= */ #define SWIG_TOKEN_RSEQUAL 133 /* >>= */ #define SWIG_TOKEN_MODEQUAL 134 /* %= */ #define SWIG_TOKEN_ARROW 135 /* -> */ #define SWIG_TOKEN_ARROWSTAR 136 /* ->* */ swig-3.0.2/Source/Swig/swigwrap.h0000664000175000017500000000277412343605122016542 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swigwrap.h * * Functions related to wrapper objects. * ----------------------------------------------------------------------------- */ typedef struct Wrapper { Hash *localh; String *def; String *locals; String *code; } Wrapper; extern Wrapper *NewWrapper(void); extern void DelWrapper(Wrapper *w); extern void Wrapper_compact_print_mode_set(int flag); extern void Wrapper_pretty_print(String *str, File *f); extern void Wrapper_compact_print(String *str, File *f); extern void Wrapper_print(Wrapper *w, File *f); extern int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl); extern int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...); extern int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name); extern char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl); extern char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...); swig-3.0.2/Source/Swig/getopt.c0000664000175000017500000000701012343605122016160 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * getopt.c * * Handles the parsing of command line options. This is particularly nasty * compared to other utilities given that command line options can potentially * be read by many different modules within SWIG. Thus, in order to make sure * there are no unrecognized options, each module is required to "mark" * the options that it uses. Afterwards, we can make a quick scan to make * sure there are no unmarked options. * * TODO: * - This module needs to be modified so that it doesn't call exit(). * Should have cleaner error handling in general. * ----------------------------------------------------------------------------- */ #include "swig.h" static char **args; static int numargs; static int *marked; /* ----------------------------------------------------------------------------- * Swig_init_args() * * Initialize the argument list handler. * ----------------------------------------------------------------------------- */ void Swig_init_args(int argc, char **argv) { int i; assert(argc > 0); assert(argv); numargs = argc; args = argv; marked = (int *) malloc(numargs * sizeof(int)); for (i = 0; i < argc; i++) { marked[i] = 0; } marked[0] = 1; } /* ----------------------------------------------------------------------------- * Swig_mark_arg() * * Marks an argument as being parsed. * ----------------------------------------------------------------------------- */ void Swig_mark_arg(int n) { assert(marked); assert((n >= 0) && (n < numargs)); marked[n] = 1; } /* ----------------------------------------------------------------------------- * Swig_check_marked() * * Checks to see if argument has been picked up. * ----------------------------------------------------------------------------- */ int Swig_check_marked(int n) { assert((n >= 0) && (n < numargs)); return marked[n]; } /* ----------------------------------------------------------------------------- * Swig_check_options() * * Checkers for unprocessed command line options and errors. * ----------------------------------------------------------------------------- */ void Swig_check_options(int check_input) { int error = 0; int i; int max = check_input ? numargs - 1 : numargs; assert(marked); for (i = 1; i < max; i++) { if (!marked[i]) { Printf(stderr, "swig error : Unrecognized option %s\n", args[i]); error = 1; } } if (error) { Printf(stderr, "Use 'swig -help' for available options.\n"); exit(1); } if (check_input && marked[numargs - 1]) { Printf(stderr, "Must specify an input file. Use -help for available options.\n"); exit(1); } } /* ----------------------------------------------------------------------------- * Swig_arg_error() * * Generates a generic error message and exits. * ----------------------------------------------------------------------------- */ void Swig_arg_error(void) { Printf(stderr, "SWIG : Unable to parse command line options.\n"); Printf(stderr, "Use 'swig -help' for available options.\n"); exit(1); } swig-3.0.2/Source/Swig/extend.c0000664000175000017500000001124612343605122016153 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * extend.c * * Extensions support (%extend) * ----------------------------------------------------------------------------- */ #include "swig.h" #include "cparse.h" static Hash *extendhash = 0; /* Hash table of added methods */ /* ----------------------------------------------------------------------------- * Swig_extend_hash() * * Access the extend hash * ----------------------------------------------------------------------------- */ Hash *Swig_extend_hash(void) { if (!extendhash) extendhash = NewHash(); return extendhash; } /* ----------------------------------------------------------------------------- * Swig_extend_merge() * * Extension merge. This function is used to handle the %extend directive * when it appears before a class definition. To handle this, the %extend * actually needs to take precedence. Therefore, we will selectively nuke symbols * from the current symbol table, replacing them with the added methods. * ----------------------------------------------------------------------------- */ void Swig_extend_merge(Node *cls, Node *am) { Node *n; Node *csym; n = firstChild(am); while (n) { String *symname; if (Strcmp(nodeType(n),"constructor") == 0) { symname = Getattr(n,"sym:name"); if (symname) { if (Strcmp(symname,Getattr(n,"name")) == 0) { /* If the name and the sym:name of a constructor are the same, then it hasn't been renamed. However---the name of the class itself might have been renamed so we need to do a consistency check here */ if (Getattr(cls,"sym:name")) { Setattr(n,"sym:name", Getattr(cls,"sym:name")); } } } } symname = Getattr(n,"sym:name"); DohIncref(symname); if ((symname) && (!Getattr(n,"error"))) { /* Remove node from its symbol table */ Swig_symbol_remove(n); csym = Swig_symbol_add(symname,n); if (csym != n) { /* Conflict with previous definition. Nuke previous definition */ String *e = NewStringEmpty(); String *en = NewStringEmpty(); String *ec = NewStringEmpty(); Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname); Printf(en,"%%extend definition of '%s'.",symname); SWIG_WARN_NODE_BEGIN(n); Swig_warning(WARN_PARSE_REDEFINED,Getfile(csym),Getline(csym),"%s\n",ec); Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en); SWIG_WARN_NODE_END(n); Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec, Getfile(n),Getline(n),en); Setattr(csym,"error",e); Delete(e); Delete(en); Delete(ec); Swig_symbol_remove(csym); /* Remove class definition */ Swig_symbol_add(symname,n); /* Insert extend definition */ } } n = nextSibling(n); } } /* ----------------------------------------------------------------------------- * Swig_extend_append_previous() * ----------------------------------------------------------------------------- */ void Swig_extend_append_previous(Node *cls, Node *am) { Node *n, *ne; Node *pe = 0; Node *ae = 0; if (!am) return; n = firstChild(am); while (n) { ne = nextSibling(n); set_nextSibling(n,0); /* typemaps and fragments need to be prepended */ if (((Cmp(nodeType(n),"typemap") == 0) || (Cmp(nodeType(n),"fragment") == 0))) { if (!pe) pe = new_node("extend"); appendChild(pe, n); } else { if (!ae) ae = new_node("extend"); appendChild(ae, n); } n = ne; } if (pe) prependChild(cls,pe); if (ae) appendChild(cls,ae); } /* ----------------------------------------------------------------------------- * Swig_extend_unused_check() * * Check for unused %extend. Special case, don't report unused * extensions for templates * ----------------------------------------------------------------------------- */ void Swig_extend_unused_check(void) { Iterator ki; if (!extendhash) return; for (ki = First(extendhash); ki.key; ki = Next(ki)) { if (!Strchr(ki.key,'<')) { SWIG_WARN_NODE_BEGIN(ki.item); Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", SwigType_namestr(ki.key)); SWIG_WARN_NODE_END(ki.item); } } } swig-3.0.2/Source/Swig/cwrap.c0000664000175000017500000014232512343605122016003 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * cwrap.c * * This file defines a variety of wrapping rules for C/C++ handling including * the naming of local variables, calling conventions, and so forth. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "cparse.h" static const char *cresult_variable_name = "result"; static Parm *nonvoid_parms(Parm *p) { if (p) { SwigType *t = Getattr(p, "type"); if (SwigType_type(t) == T_VOID) return 0; } return p; } /* ----------------------------------------------------------------------------- * Swig_cresult_name_set() * * Change the name of the variable used to hold the return value from C/C++ wrapper functions * from the default "result". * ----------------------------------------------------------------------------- */ void Swig_cresult_name_set(const char *new_name) { cresult_variable_name = new_name; } /* ----------------------------------------------------------------------------- * Swig_cresult_name() * * Get the name of the variable used to hold the return value from C/C++ wrapper functions * ----------------------------------------------------------------------------- */ const char *Swig_cresult_name(void) { return cresult_variable_name; } /* ----------------------------------------------------------------------------- * Swig_cparm_name() * * Generates a name for the ith argument in an argument list * ----------------------------------------------------------------------------- */ String *Swig_cparm_name(Parm *p, int i) { String *name = NewStringf("arg%d", i + 1); if (p) { Setattr(p, "lname", name); } return name; } /* ----------------------------------------------------------------------------- * Swig_clocal() * * Creates a string that declares a C local variable type. Converts references * and user defined types to pointers. * ----------------------------------------------------------------------------- */ static String *Swig_clocal(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr value) { String *decl; decl = NewStringEmpty(); switch (SwigType_type(t)) { case T_REFERENCE: if (value) { String *lstrname = SwigType_lstr(t, name); String *lstr = SwigType_lstr(t, 0); Printf(decl, "%s = (%s) &%s_defvalue", lstrname, lstr, name); Delete(lstrname); Delete(lstr); } else { String *lstrname = SwigType_lstr(t, name); Printf(decl, "%s = 0", lstrname); Delete(lstrname); } break; case T_RVALUE_REFERENCE: if (value) { String *lstrname = SwigType_lstr(t, name); String *lstr = SwigType_lstr(t, 0); Printf(decl, "%s = (%s) &%s_defrvalue", lstrname, lstr, name); Delete(lstrname); Delete(lstr); } else { String *lstrname = SwigType_lstr(t, name); Printf(decl, "%s = 0", lstrname); Delete(lstrname); } break; case T_VOID: break; case T_VARARGS: Printf(decl, "void *%s = 0", name); break; default: if (value) { String *lcaststr = SwigType_lcaststr(t, value); String *lstr = SwigType_lstr(t, 0); String *lstrn = SwigType_lstr(t, name); Printf(decl, "%s = (%s) %s", lstrn, lstr, lcaststr); Delete(lcaststr); Delete(lstr); Delete(lstrn); } else { String *lstrname = SwigType_lstr(t, name); Append(decl, lstrname); Delete(lstrname); } } return decl; } /* ----------------------------------------------------------------------------- * Swig_wrapped_var_convert() * * Converts a member variable for use in the get and set wrapper methods. * This function only converts user defined types to pointers. * ----------------------------------------------------------------------------- */ String *Swig_wrapped_var_type(SwigType *t, int varcref) { SwigType *ty; if (!Strstr(t, "enum $unnamed")) { ty = Copy(t); } else { /* Change the type for unnamed enum instance variables */ ty = NewString("int"); } if (SwigType_isclass(t)) { if (varcref) { if (cparse_cplusplus) { if (!SwigType_isconst(ty)) SwigType_add_qualifier(ty, "const"); SwigType_add_reference(ty); } else { return Copy(ty); } } else { SwigType_add_pointer(ty); } } return ty; } String *Swig_wrapped_member_var_type(SwigType *t, int varcref) { SwigType *ty; if (!Strstr(t, "enum $unnamed")) { ty = Copy(t); } else { /* Change the type for unnamed enum instance variables */ ty = NewString("int"); } if (SwigType_isclass(t)) { if (varcref) { if (cparse_cplusplus) { if (!SwigType_isconst(ty)) SwigType_add_qualifier(ty, "const"); SwigType_add_reference(ty); } else { return Copy(ty); } } else { SwigType_add_pointer(ty); } } return ty; } static String *Swig_wrapped_var_deref(SwigType *t, const_String_or_char_ptr name, int varcref) { if (SwigType_isclass(t)) { if (varcref) { if (cparse_cplusplus) { return NewStringf("*%s", name); } else { return NewStringf("%s", name); } } else { return NewStringf("*%s", name); } } else { return SwigType_rcaststr(t, name); } } static String *Swig_wrapped_var_assign(SwigType *t, const_String_or_char_ptr name, int varcref) { if (SwigType_isclass(t)) { if (varcref) { return NewStringf("%s", name); } else { return NewStringf("&%s", name); } } else { return SwigType_lcaststr(t, name); } } /* ----------------------------------------------------------------------------- * Swig_cargs() * * Emit all of the local variables for a list of parameters. Returns the * number of parameters. * Default values for the local variables are only emitted if the compact default * argument behaviour is required. * ----------------------------------------------------------------------------- */ int Swig_cargs(Wrapper *w, ParmList *p) { int i = 0; int compactdefargs = ParmList_is_compactdefargs(p); while (p != 0) { String *lname = Swig_cparm_name(p, i); SwigType *pt = Getattr(p, "type"); if ((SwigType_type(pt) != T_VOID)) { String *local = 0; String *type = Getattr(p, "type"); /* default values only emitted if in compact default args mode */ String *pvalue = (compactdefargs) ? Getattr(p, "value") : 0; /* When using compactdefaultargs, the code generated initialises a variable via a constructor call that accepts the * default value as a parameter. The default constructor is not called and therefore SwigValueWrapper is not needed. */ SwigType *altty = pvalue ? 0 : SwigType_alttype(type, 0); int tycode = SwigType_type(type); if (tycode == T_REFERENCE) { if (pvalue) { SwigType *tvalue; String *defname, *defvalue, *rvalue, *qvalue; rvalue = SwigType_typedef_resolve_all(pvalue); qvalue = SwigType_typedef_qualified(rvalue); defname = NewStringf("%s_defvalue", lname); tvalue = Copy(type); SwigType_del_reference(tvalue); tycode = SwigType_type(tvalue); if (tycode != T_USER) { /* plain primitive type, we copy the def value */ String *lstr = SwigType_lstr(tvalue, defname); defvalue = NewStringf("%s = %s", lstr, qvalue); Delete(lstr); } else { /* user type, we copy the reference value */ String *str = SwigType_str(type, defname); defvalue = NewStringf("%s = %s", str, qvalue); Delete(str); } Wrapper_add_localv(w, defname, defvalue, NIL); Delete(tvalue); Delete(rvalue); Delete(qvalue); Delete(defname); Delete(defvalue); } } else if (tycode == T_RVALUE_REFERENCE) { if (pvalue) { SwigType *tvalue; String *defname, *defvalue, *rvalue, *qvalue; rvalue = SwigType_typedef_resolve_all(pvalue); qvalue = SwigType_typedef_qualified(rvalue); defname = NewStringf("%s_defrvalue", lname); tvalue = Copy(type); SwigType_del_rvalue_reference(tvalue); tycode = SwigType_type(tvalue); if (tycode != T_USER) { /* plain primitive type, we copy the the def value */ String *lstr = SwigType_lstr(tvalue, defname); defvalue = NewStringf("%s = %s", lstr, qvalue); Delete(lstr); } else { /* user type, we copy the reference value */ String *str = SwigType_str(type, defname); defvalue = NewStringf("%s = %s", str, qvalue); Delete(str); } Wrapper_add_localv(w, defname, defvalue, NIL); Delete(tvalue); Delete(rvalue); Delete(qvalue); Delete(defname); Delete(defvalue); } } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING) || (tycode == T_WSTRING))) { pvalue = (String *) "0"; } if (!altty) { local = Swig_clocal(pt, lname, pvalue); } else { local = Swig_clocal(altty, lname, pvalue); Delete(altty); } Wrapper_add_localv(w, lname, local, NIL); Delete(local); i++; } Delete(lname); p = nextSibling(p); } return (i); } /* ----------------------------------------------------------------------------- * Swig_cresult() * * This function generates the C code needed to set the result of a C * function call. * ----------------------------------------------------------------------------- */ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl) { String *fcall; fcall = NewStringEmpty(); switch (SwigType_type(t)) { case T_VOID: break; case T_REFERENCE: { String *lstr = SwigType_lstr(t, 0); Printf(fcall, "%s = (%s) &", name, lstr); Delete(lstr); } break; case T_RVALUE_REFERENCE: { String *const_lvalue_str; String *lstr = SwigType_lstr(t, 0); SwigType *tt = Copy(t); SwigType_del_rvalue_reference(tt); SwigType_add_qualifier(tt, "const"); SwigType_add_reference(tt); const_lvalue_str = SwigType_rcaststr(tt, 0); Printf(fcall, "%s = (%s) &%s", name, lstr, const_lvalue_str); Delete(const_lvalue_str); Delete(tt); Delete(lstr); } break; case T_USER: Printf(fcall, "%s = ", name); break; default: /* Normal return value */ { String *lstr = SwigType_lstr(t, 0); Printf(fcall, "%s = (%s)", name, lstr); Delete(lstr); } break; } /* Now print out function call */ Append(fcall, decl); /* A sick hack */ { char *c = Char(decl) + Len(decl) - 1; if (!((*c == ';') || (*c == '}'))) Append(fcall, ";"); } return fcall; } /* ----------------------------------------------------------------------------- * Swig_cfunction_call() * * Creates a string that calls a C function using the local variable rules * defined above. * * name(arg0, arg1, arg2, ... argn) * * ----------------------------------------------------------------------------- */ String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms) { String *func; int i = 0; int comma = 0; Parm *p = parms; String *nname; func = NewStringEmpty(); nname = SwigType_namestr(name); /* SWIGTEMPLATEDISAMBIGUATOR is compiler dependent (swiglabels.swg), - SUN Studio 9 requires 'template', - gcc-3.4 forbids the use of 'template'. the rest seems not caring very much, */ if (SwigType_istemplate(name)) { String *prefix = Swig_scopename_prefix(nname); if (!prefix || Len(prefix) == 0) { Printf(func, "%s(", nname); } else { String *last = Swig_scopename_last(nname); Printf(func, "%s::SWIGTEMPLATEDISAMBIGUATOR %s(", prefix, last); Delete(last); } Delete(prefix); } else { Printf(func, "%s(", nname); } Delete(nname); while (p) { SwigType *pt = Getattr(p, "type"); if ((SwigType_type(pt) != T_VOID)) { SwigType *rpt = SwigType_typedef_resolve_all(pt); String *pname = Swig_cparm_name(p, i); String *rcaststr = SwigType_rcaststr(rpt, pname); if (comma) { Printv(func, ",", rcaststr, NIL); } else { Append(func, rcaststr); } Delete(rpt); Delete(pname); Delete(rcaststr); comma = 1; i++; } p = nextSibling(p); } Append(func, ")"); return func; } /* ----------------------------------------------------------------------------- * Swig_cmethod_call() * * Generates a string that calls a C++ method from a list of parameters. * * arg0->name(arg1, arg2, arg3, ..., argn) * * self is an argument that defines how to handle the first argument. Normally, * it should be set to "this->". With C++ proxy classes enabled, it could be * set to "(*this)->" or some similar sequence. * ----------------------------------------------------------------------------- */ static String *Swig_cmethod_call(const_String_or_char_ptr name, ParmList *parms, const_String_or_char_ptr self, String *explicit_qualifier, SwigType *director_type) { String *func, *nname; int i = 0; Parm *p = parms; SwigType *pt; int comma = 0; func = NewStringEmpty(); if (!p) return func; if (!self) self = "(this)->"; Append(func, self); if (SwigType_istemplate(name) && (strncmp(Char(name), "operator ", 9) == 0)) { /* fix for template + operators and compilers like gcc 3.3.5 */ String *tprefix = SwigType_templateprefix(name); nname = tprefix; } else { nname = SwigType_namestr(name); } if (director_type) { const char *pname = "darg"; String *rcaststr = SwigType_rcaststr(director_type, pname); Replaceall(func, "this", rcaststr); Delete(rcaststr); } else { pt = Getattr(p, "type"); /* If the method is invoked through a dereferenced pointer, we don't add any casts (needed for smart pointers). Otherwise, we cast to the appropriate type */ if (Strstr(func, "*this")) { String *pname = Swig_cparm_name(p, 0); Replaceall(func, "this", pname); Delete(pname); } else { String *pname = Swig_cparm_name(p, 0); String *rcaststr = SwigType_rcaststr(pt, pname); Replaceall(func, "this", rcaststr); Delete(rcaststr); Delete(pname); } /* SWIGTEMPLATEDESIMBUAGATOR is compiler dependent (swiglabels.swg), - SUN Studio 9 requires 'template', - gcc-3.4 forbids the use of 'template' (correctly implementing the ISO C++ standard) the others don't seem to care, */ if (SwigType_istemplate(name)) Printf(func, "SWIGTEMPLATEDISAMBIGUATOR "); if (explicit_qualifier) { Printv(func, explicit_qualifier, "::", NIL); } } Printf(func, "%s(", nname); i++; p = nextSibling(p); while (p) { pt = Getattr(p, "type"); if ((SwigType_type(pt) != T_VOID)) { String *pname = Swig_cparm_name(p, i); String *rcaststr = SwigType_rcaststr(pt, pname); if (comma) Append(func, ","); Append(func, rcaststr); Delete(rcaststr); Delete(pname); comma = 1; i++; } p = nextSibling(p); } Append(func, ")"); Delete(nname); return func; } /* ----------------------------------------------------------------------------- * Swig_cconstructor_call() * * Creates a string that calls a C constructor function. * * calloc(1,sizeof(name)); * ----------------------------------------------------------------------------- */ String *Swig_cconstructor_call(const_String_or_char_ptr name) { DOH *func; func = NewStringEmpty(); Printf(func, "calloc(1, sizeof(%s))", name); return func; } /* ----------------------------------------------------------------------------- * Swig_cppconstructor_call() * * Creates a string that calls a C function using the local variable rules * defined above. * * name(arg0, arg1, arg2, ... argn) * * ----------------------------------------------------------------------------- */ String *Swig_cppconstructor_base_call(const_String_or_char_ptr name, ParmList *parms, int skip_self) { String *func; String *nname; int i = 0; int comma = 0; Parm *p = parms; SwigType *pt; if (skip_self) { if (p) p = nextSibling(p); i++; } nname = SwigType_namestr(name); func = NewStringEmpty(); Printf(func, "new %s(", nname); while (p) { pt = Getattr(p, "type"); if ((SwigType_type(pt) != T_VOID)) { String *rcaststr = 0; String *pname = 0; if (comma) Append(func, ","); if (!Getattr(p, "arg:byname")) { pname = Swig_cparm_name(p, i); i++; } else { pname = Getattr(p, "value"); if (pname) pname = Copy(pname); else pname = Copy(Getattr(p, "name")); } rcaststr = SwigType_rcaststr(pt, pname); Append(func, rcaststr); Delete(rcaststr); comma = 1; Delete(pname); } p = nextSibling(p); } Append(func, ")"); Delete(nname); return func; } String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms) { return Swig_cppconstructor_base_call(name, parms, 0); } String *Swig_cppconstructor_nodirector_call(const_String_or_char_ptr name, ParmList *parms) { return Swig_cppconstructor_base_call(name, parms, 1); } String *Swig_cppconstructor_director_call(const_String_or_char_ptr name, ParmList *parms) { return Swig_cppconstructor_base_call(name, parms, 0); } /* ----------------------------------------------------------------------------- * recursive_flag_search() * * This function searches for the class attribute 'attr' in the class * 'n' or recursively in its bases. * * If you define SWIG_FAST_REC_SEARCH, the method will set the found * 'attr' in the target class 'n'. If not, the method will set the * 'noattr' one. This prevents of having to navigate the entire * hierarchy tree everytime, so, it is an O(1) method... or something * like that. However, it populates all the parsed classes with the * 'attr' and/or 'noattr' attributes. * * If you undefine the SWIG_FAST_REC_SEARCH no attribute will be set * while searching. This could be slower for large projects with very * large hierarchy trees... or maybe not. But it will be cleaner. * * Maybe later a swig option can be added to switch at runtime. * * ----------------------------------------------------------------------------- */ /* #define SWIG_FAST_REC_SEARCH 1 */ static String *recursive_flag_search(Node *n, const String *attr, const String *noattr) { String *f = 0; n = Swig_methodclass(n); if (GetFlag(n, noattr)) { return 0; } f = GetFlagAttr(n, attr); if (f) { return f; } else { List *bl = Getattr(n, "bases"); if (bl) { Iterator bi; for (bi = First(bl); bi.item; bi = Next(bi)) { f = recursive_flag_search(bi.item, attr, noattr); if (f) { #ifdef SWIG_FAST_REC_SEARCH SetFlagAttr(n, attr, f); #endif return f; } } } } #ifdef SWIG_FAST_REC_SEARCH SetFlag(n, noattr); #endif return 0; } /* ----------------------------------------------------------------------------- * Swig_unref_call() * * Find the "feature:unref" call, if any. * ----------------------------------------------------------------------------- */ String *Swig_unref_call(Node *n) { String *unref = recursive_flag_search(n, "feature:unref", "feature:nounref"); if (unref) { String *pname = Swig_cparm_name(0, 0); unref = NewString(unref); Replaceall(unref, "$this", pname); Replaceall(unref, "$self", pname); Delete(pname); } return unref; } /* ----------------------------------------------------------------------------- * Swig_ref_call() * * Find the "feature:ref" call, if any. * ----------------------------------------------------------------------------- */ String *Swig_ref_call(Node *n, const String *lname) { String *ref = recursive_flag_search(n, "feature:ref", "feature:noref"); if (ref) { ref = NewString(ref); Replaceall(ref, "$this", lname); Replaceall(ref, "$self", lname); } return ref; } /* ----------------------------------------------------------------------------- * Swig_cdestructor_call() * * Creates a string that calls a C destructor function. * * free((char *) arg0); * ----------------------------------------------------------------------------- */ String *Swig_cdestructor_call(Node *n) { Node *cn = Swig_methodclass(n); String *unref = Swig_unref_call(cn); if (unref) { return unref; } else { String *pname = Swig_cparm_name(0, 0); String *call = NewStringf("free((char *) %s);", pname); Delete(pname); return call; } } /* ----------------------------------------------------------------------------- * Swig_cppdestructor_call() * * Creates a string that calls a C destructor function. * * delete arg1; * ----------------------------------------------------------------------------- */ String *Swig_cppdestructor_call(Node *n) { Node *cn = Swig_methodclass(n); String *unref = Swig_unref_call(cn); if (unref) { return unref; } else { String *pname = Swig_cparm_name(0, 0); String *call = NewStringf("delete %s;", pname); Delete(pname); return call; } } /* ----------------------------------------------------------------------------- * Swig_cmemberset_call() * * Generates a string that sets the name of a member in a C++ class or C struct. * * arg0->name = arg1 * * ----------------------------------------------------------------------------- */ String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref) { String *func; String *pname0 = Swig_cparm_name(0, 0); String *pname1 = Swig_cparm_name(0, 1); func = NewStringEmpty(); if (!self) self = NewString("(this)->"); else self = NewString(self); Replaceall(self, "this", pname0); if (SwigType_type(type) != T_ARRAY) { if (!Strstr(type, "enum $unnamed")) { String *dref = Swig_wrapped_var_deref(type, pname1, varcref); int extra_cast = 0; if (cparse_cplusplusout) { /* Required for C nested structs compiled as C++ as a duplicate of the nested struct is put into the global namespace. * We could improve this by adding the extra casts just for nested structs rather than all structs. */ String *base = SwigType_base(type); extra_cast = SwigType_isclass(base); Delete(base); } if (extra_cast) { String *lstr; SwigType *ptype = Copy(type); SwigType_add_pointer(ptype); lstr = SwigType_lstr(ptype, 0); Printf(func, "if (%s) *(%s)&%s%s = %s", pname0, lstr, self, name, dref); Delete(lstr); Delete(ptype); } else { Printf(func, "if (%s) %s%s = %s", pname0, self, name, dref); } Delete(dref); } else { Printf(func, "if (%s && sizeof(int) == sizeof(%s%s)) *(int*)(void*)&(%s%s) = %s", pname0, self, name, self, name, pname1); } } Delete(self); Delete(pname0); Delete(pname1); return (func); } /* ----------------------------------------------------------------------------- * Swig_cmemberget_call() * * Generates a string that sets the name of a member in a C++ class or C struct. * * arg0->name * * ----------------------------------------------------------------------------- */ String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref) { String *func; String *call; String *pname0 = Swig_cparm_name(0, 0); if (!self) self = NewString("(this)->"); else self = NewString(self); Replaceall(self, "this", pname0); func = NewStringEmpty(); call = Swig_wrapped_var_assign(t, "", varcref); Printf(func, "%s (%s%s)", call, self, name); Delete(self); Delete(call); Delete(pname0); return func; } /* ----------------------------------------------------------------------------- * Swig_replace_special_variables() * * Replaces special variables with a value from the supplied node * ----------------------------------------------------------------------------- */ void Swig_replace_special_variables(Node *n, Node *parentnode, String *code) { Node *parentclass = parentnode; String *overloaded = Getattr(n, "sym:overloaded"); Replaceall(code, "$name", Getattr(n, "name")); Replaceall(code, "$symname", Getattr(n, "sym:name")); Replaceall(code, "$wrapname", Getattr(n, "wrap:name")); Replaceall(code, "$overname", overloaded ? Char(Getattr(n, "sym:overname")) : ""); if (Strstr(code, "$decl")) { String *decl = Swig_name_decl(n); Replaceall(code, "$decl", decl); Delete(decl); } if (Strstr(code, "$fulldecl")) { String *fulldecl = Swig_name_fulldecl(n); Replaceall(code, "$fulldecl", fulldecl); Delete(fulldecl); } if (parentclass && !Equal(nodeType(parentclass), "class")) parentclass = 0; if (Strstr(code, "$parentclasssymname")) { String *parentclasssymname = 0; if (parentclass) parentclasssymname = Getattr(parentclass, "sym:name"); Replaceall(code, "$parentclasssymname", parentclasssymname ? parentclasssymname : ""); } if (Strstr(code, "$parentclassname")) { String *parentclassname = 0; if (parentclass) parentclassname = Getattr(parentclass, "name"); Replaceall(code, "$parentclassname", parentclassname ? parentclassname : ""); } } /* ----------------------------------------------------------------------------- * extension_code() * * Generates an extension function (a function defined in %extend) * * return_type function_name(parms) code * * ----------------------------------------------------------------------------- */ static String *extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) { String *parms_str = cplusplus ? ParmList_str_defaultargs(parms) : ParmList_str(parms); String *sig = NewStringf("%s(%s)", function_name, (cplusplus || Len(parms_str)) ? parms_str : "void"); String *rt_sig = SwigType_str(return_type, sig); String *body = NewStringf("SWIGINTERN %s", rt_sig); Printv(body, code, "\n", NIL); if (Strstr(body, "$")) { Swig_replace_special_variables(n, parentNode(parentNode(n)), body); if (self) Replaceall(body, "$self", self); } Delete(parms_str); Delete(sig); Delete(rt_sig); return body; } /* ----------------------------------------------------------------------------- * Swig_add_extension_code() * * Generates an extension function (a function defined in %extend) and * adds it to the "wrap:code" attribute of a node * * See also extension_code() * * ----------------------------------------------------------------------------- */ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) { String *body = extension_code(n, function_name, parms, return_type, code, cplusplus, self); Setattr(n, "wrap:code", body); Delete(body); return SWIG_OK; } /* ----------------------------------------------------------------------------- * Swig_MethodToFunction(Node *n) * * Converts a C++ method node to a function accessor function. * ----------------------------------------------------------------------------- */ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) { String *name; ParmList *parms; SwigType *type; Parm *p; String *self = 0; int is_smart_pointer_overload = 0; String *qualifier = Getattr(n, "qualifier"); String *directorScope = NewString(nspace); Replace(directorScope, NSPACE_SEPARATOR, "_", DOH_REPLACE_ANY); /* If smart pointer without const overload or mutable method, change self dereferencing */ if (flags & CWRAP_SMART_POINTER) { if (flags & CWRAP_SMART_POINTER_OVERLOAD) { if (qualifier && strncmp(Char(qualifier), "q(const)", 8) == 0) { self = NewString("(*(this))->"); is_smart_pointer_overload = 1; } else if (Swig_storage_isstatic(n)) { String *cname = Getattr(n, "extendsmartclassname") ? Getattr(n, "extendsmartclassname") : classname; String *ctname = SwigType_namestr(cname); self = NewStringf("(*(%s const *)this)->", ctname); is_smart_pointer_overload = 1; Delete(ctname); } else { self = NewString("(*this)->"); } } else { self = NewString("(*this)->"); } } /* If node is a member template expansion, we don't allow added code */ if (Getattr(n, "templatetype")) flags &= ~(CWRAP_EXTEND); name = Getattr(n, "name"); parms = CopyParmList(nonvoid_parms(Getattr(n, "parms"))); type = NewString(classname); if (qualifier) { SwigType_push(type, qualifier); } SwigType_add_pointer(type); p = NewParm(type, "self", n); Setattr(p, "self", "1"); Setattr(p, "hidden","1"); /* Disable the 'this' ownership in 'self' to manage inplace operations like: A& A::operator+=(int i) { ...; return *this;} Here the 'self' parameter ownership needs to be disabled since there could be two objects sharing the same 'this' pointer: the input and the result one. And worse, the pointer could be deleted in one of the objects (input), leaving the other (output) with just a seg. fault to happen. To avoid the previous problem, use %feature("self:disown") *::operator+=; %feature("new") *::operator+=; These two lines just transfer the ownership of the 'this' pointer from the input to the output wrapping object. This happens in python, but may also happen in other target languages. */ if (GetFlag(n, "feature:self:disown")) { Setattr(p, "wrap:disown", "1"); } set_nextSibling(p, parms); Delete(type); /* Generate action code for the access */ if (!(flags & CWRAP_EXTEND)) { String *explicit_qualifier = 0; String *call = 0; String *cres = 0; String *explicitcall_name = 0; int pure_virtual = !(Cmp(Getattr(n, "storage"), "virtual")) && !(Cmp(Getattr(n, "value"), "0")); /* Call the explicit method rather than allow for a polymorphic call */ if ((flags & CWRAP_DIRECTOR_TWO_CALLS) || (flags & CWRAP_DIRECTOR_ONE_CALL)) { String *access = Getattr(n, "access"); if (access && (Cmp(access, "protected") == 0)) { /* If protected access (can only be if a director method) then call the extra public accessor method (language module must provide this) */ String *explicit_qualifier_tmp = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname")); explicitcall_name = NewStringf("%sSwigPublic", name); if (Len(directorScope) > 0) explicit_qualifier = NewStringf("SwigDirector_%s_%s", directorScope, explicit_qualifier_tmp); else explicit_qualifier = NewStringf("SwigDirector_%s", explicit_qualifier_tmp); Delete(explicit_qualifier_tmp); } else { explicit_qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname")); } } call = Swig_cmethod_call(explicitcall_name ? explicitcall_name : name, p, self, explicit_qualifier, director_type); cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call); if (pure_virtual && is_director && (flags & CWRAP_DIRECTOR_TWO_CALLS)) { String *qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname")); Delete(cres); cres = NewStringf("Swig::DirectorPureVirtualException::raise(\"%s::%s\");", qualifier, name); Delete(qualifier); } if (flags & CWRAP_DIRECTOR_TWO_CALLS) { /* Create two method calls, one to call the explicit method, the other a normal polymorphic function call */ String *cres_both_calls = NewStringf(""); String *call_extra = Swig_cmethod_call(name, p, self, 0, director_type); String *cres_extra = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call_extra); Printv(cres_both_calls, "if (upcall) {\n", cres, "\n", "} else {", cres_extra, "\n}", NIL); Setattr(n, "wrap:action", cres_both_calls); Delete(cres_extra); Delete(call_extra); Delete(cres_both_calls); } else { Setattr(n, "wrap:action", cres); } Delete(explicitcall_name); Delete(call); Delete(cres); Delete(explicit_qualifier); } else { /* Methods with default arguments are wrapped with additional methods for each default argument, * however, only one extra %extend method is generated. */ String *defaultargs = Getattr(n, "defaultargs"); String *code = Getattr(n, "code"); String *cname = Getattr(n, "extendsmartclassname") ? Getattr(n, "extendsmartclassname") : classname; String *membername = Swig_name_member(nspace, cname, name); String *mangled = Swig_name_mangle(membername); int is_smart_pointer = flags & CWRAP_SMART_POINTER; type = Getattr(n, "type"); /* Check if the method is overloaded. If so, and it has code attached, we append an extra suffix to avoid a name-clash in the generated wrappers. This allows overloaded methods to be defined in C. */ if (Getattr(n, "sym:overloaded") && code) { Append(mangled, Getattr(defaultargs ? defaultargs : n, "sym:overname")); } /* See if there is any code that we need to emit */ if (!defaultargs && code && !is_smart_pointer) { Swig_add_extension_code(n, mangled, p, type, code, cparse_cplusplus, "self"); } if (is_smart_pointer) { int i = 0; Parm *pp = p; String *func = NewStringf("%s(", mangled); String *cres; if (!Swig_storage_isstatic(n)) { String *pname = Swig_cparm_name(pp, i); String *ctname = SwigType_namestr(cname); String *fadd = 0; if (is_smart_pointer_overload) { String *nclassname = SwigType_namestr(classname); fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, nclassname, pname); Delete(nclassname); } else { fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname); } Append(func, fadd); Delete(ctname); Delete(fadd); Delete(pname); pp = nextSibling(pp); if (pp) Append(func, ","); } else { pp = nextSibling(pp); } ++i; while (pp) { SwigType *pt = Getattr(pp, "type"); if ((SwigType_type(pt) != T_VOID)) { String *pname = Swig_cparm_name(pp, i++); String *rcaststr = SwigType_rcaststr(pt, pname); Append(func, rcaststr); Delete(rcaststr); Delete(pname); pp = nextSibling(pp); if (pp) Append(func, ","); } } Append(func, ")"); cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), func); Setattr(n, "wrap:action", cres); Delete(cres); } else { String *call = Swig_cfunction_call(mangled, p); String *cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); } Delete(membername); Delete(mangled); } Setattr(n, "parms", p); Delete(p); Delete(self); Delete(parms); Delete(directorScope); return SWIG_OK; } /* ----------------------------------------------------------------------------- * Swig_methodclass() * * This function returns the class node for a given method or class. * ----------------------------------------------------------------------------- */ Node *Swig_methodclass(Node *n) { Node *nodetype = nodeType(n); if (Cmp(nodetype, "class") == 0) return n; return GetFlag(n, "feature:extend") ? parentNode(parentNode(n)) : parentNode(n); } int Swig_directorclass(Node *n) { Node *classNode = Swig_methodclass(n); assert(classNode != 0); return (Getattr(classNode, "vtable") != 0); } Node *Swig_directormap(Node *module, String *type) { int is_void = !Cmp(type, "void"); if (!is_void && module) { /* ?? follow the inheritance hierarchy? */ String *base = SwigType_base(type); Node *directormap = Getattr(module, "wrap:directormap"); if (directormap) return Getattr(directormap, base); } return 0; } /* ----------------------------------------------------------------------------- * Swig_ConstructorToFunction() * * This function creates a C wrapper for a C constructor function. * ----------------------------------------------------------------------------- */ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags, String *directorname) { Parm *p; ParmList *directorparms; SwigType *type; int use_director = Swig_directorclass(n); ParmList *parms = CopyParmList(nonvoid_parms(Getattr(n, "parms"))); /* Prepend the list of prefix_args (if any) */ Parm *prefix_args = Getattr(n, "director:prefix_args"); if (prefix_args != NIL) { Parm *p2, *p3; directorparms = CopyParmList(prefix_args); for (p = directorparms; nextSibling(p); p = nextSibling(p)); for (p2 = parms; p2; p2 = nextSibling(p2)) { p3 = CopyParm(p2); set_nextSibling(p, p3); Delete(p3); p = p3; } } else directorparms = parms; type = NewString(classname); SwigType_add_pointer(type); if (flags & CWRAP_EXTEND) { /* Constructors with default arguments are wrapped with additional constructor methods for each default argument, * however, only one extra %extend method is generated. */ String *call; String *cres; String *defaultargs = Getattr(n, "defaultargs"); String *code = Getattr(n, "code"); String *membername = Swig_name_construct(nspace, classname); String *mangled = Swig_name_mangle(membername); /* Check if the constructor is overloaded. If so, and it has code attached, we append an extra suffix to avoid a name-clash in the generated wrappers. This allows overloaded constructors to be defined in C. */ if (Getattr(n, "sym:overloaded") && code) { Append(mangled, Getattr(defaultargs ? defaultargs : n, "sym:overname")); } /* See if there is any code that we need to emit */ if (!defaultargs && code) { Swig_add_extension_code(n, mangled, parms, type, code, cparse_cplusplus, "self"); } call = Swig_cfunction_call(mangled, parms); cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); Delete(membername); Delete(mangled); } else { if (cplus) { /* if a C++ director class exists, create it rather than the original class */ if (use_director) { Node *parent = Swig_methodclass(n); int abstract = Getattr(parent, "abstracts") != 0; String *action = NewStringEmpty(); String *tmp_none_comparison = Copy(none_comparison); String *director_call; String *nodirector_call; Replaceall(tmp_none_comparison, "$arg", "arg1"); director_call = Swig_cppconstructor_director_call(directorname, directorparms); nodirector_call = Swig_cppconstructor_nodirector_call(classname, parms); if (abstract) { /* whether or not the abstract class has been subclassed in python, * create a director instance (there's no way to create a normal * instance). if any of the pure virtual methods haven't been * implemented in the target language, calls to those methods will * generate Swig::DirectorPureVirtualException exceptions. */ String *cres = Swig_cresult(type, Swig_cresult_name(), director_call); Append(action, cres); Delete(cres); } else { /* (scottm): The code for creating a new director is now a string template that gets passed in via the director_ctor argument. $comparison : an 'if' comparison from none_comparison $director_new: Call new for director class $nondirector_new: Call new for non-director class */ String *cres; Append(action, director_ctor); Replaceall(action, "$comparison", tmp_none_comparison); cres = Swig_cresult(type, Swig_cresult_name(), director_call); Replaceall(action, "$director_new", cres); Delete(cres); cres = Swig_cresult(type, Swig_cresult_name(), nodirector_call); Replaceall(action, "$nondirector_new", cres); Delete(cres); } Setattr(n, "wrap:action", action); Delete(tmp_none_comparison); Delete(action); } else { String *call = Swig_cppconstructor_call(classname, parms); String *cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); } } else { String *call = Swig_cconstructor_call(classname); String *cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); } } Setattr(n, "type", type); Setattr(n, "parms", parms); Delete(type); if (directorparms != parms) Delete(directorparms); Delete(parms); return SWIG_OK; } /* ----------------------------------------------------------------------------- * Swig_DestructorToFunction() * * This function creates a C wrapper for a destructor function. * ----------------------------------------------------------------------------- */ int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags) { SwigType *type; Parm *p; type = NewString(classname); SwigType_add_pointer(type); p = NewParm(type, "self", n); Setattr(p, "self", "1"); Setattr(p, "hidden", "1"); Setattr(p, "wrap:disown", "1"); Delete(type); type = NewString("void"); if (flags & CWRAP_EXTEND) { String *cres; String *call; String *membername, *mangled, *code; membername = Swig_name_destroy(nspace, classname); mangled = Swig_name_mangle(membername); code = Getattr(n, "code"); if (code) { Swig_add_extension_code(n, mangled, p, type, code, cparse_cplusplus, "self"); } call = Swig_cfunction_call(mangled, p); cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); Delete(membername); Delete(mangled); Delete(call); Delete(cres); } else { if (cplus) { String *call = Swig_cppdestructor_call(n); String *cres = NewStringf("%s", call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); } else { String *call = Swig_cdestructor_call(n); String *cres = NewStringf("%s", call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); } } Setattr(n, "type", type); Setattr(n, "parms", p); Delete(type); Delete(p); return SWIG_OK; } /* ----------------------------------------------------------------------------- * Swig_MembersetToFunction() * * This function creates a C wrapper for setting a structure member. * ----------------------------------------------------------------------------- */ int Swig_MembersetToFunction(Node *n, String *classname, int flags) { String *name; ParmList *parms; Parm *p; SwigType *t; SwigType *ty; SwigType *type; SwigType *void_type = NewString("void"); String *self = 0; int varcref = flags & CWRAP_NATURAL_VAR; if (flags & CWRAP_SMART_POINTER) { self = NewString("(*this)->"); } if (flags & CWRAP_ALL_PROTECTED_ACCESS) { self = NewStringf("darg->"); } name = Getattr(n, "name"); type = Getattr(n, "type"); t = NewString(classname); SwigType_add_pointer(t); parms = NewParm(t, "self", n); Setattr(parms, "self", "1"); Setattr(parms, "hidden","1"); Delete(t); ty = Swig_wrapped_member_var_type(type, varcref); p = NewParm(ty, name, n); Setattr(parms, "hidden", "1"); set_nextSibling(parms, p); /* If the type is a pointer or reference. We mark it with a special wrap:disown attribute */ if (SwigType_check_decl(type, "p.")) { Setattr(p, "wrap:disown", "1"); } Delete(p); if (flags & CWRAP_EXTEND) { String *call; String *cres; String *code = Getattr(n, "code"); String *sname = Swig_name_set(0, name); String *membername = Swig_name_member(0, classname, sname); String *mangled = Swig_name_mangle(membername); if (code) { /* I don't think this ever gets run - WSF */ Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self"); } call = Swig_cfunction_call(mangled, parms); cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); Delete(mangled); Delete(membername); Delete(sname); } else { String *call = Swig_cmemberset_call(name, type, self, varcref); String *cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); } Setattr(n, "type", void_type); Setattr(n, "parms", parms); Delete(parms); Delete(ty); Delete(void_type); Delete(self); return SWIG_OK; } /* ----------------------------------------------------------------------------- * Swig_MembergetToFunction() * * This function creates a C wrapper for getting a structure member. * ----------------------------------------------------------------------------- */ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { String *name; ParmList *parms; SwigType *t; SwigType *ty; SwigType *type; String *self = 0; int varcref = flags & CWRAP_NATURAL_VAR; if (flags & CWRAP_SMART_POINTER) { if (Swig_storage_isstatic(n)) { Node *sn = Getattr(n, "cplus:staticbase"); String *base = Getattr(sn, "name"); self = NewStringf("%s::", base); } else if (flags & CWRAP_SMART_POINTER_OVERLOAD) { String *nclassname = SwigType_namestr(classname); self = NewStringf("(*(%s const *)this)->", nclassname); Delete(nclassname); } else { self = NewString("(*this)->"); } } if (flags & CWRAP_ALL_PROTECTED_ACCESS) { self = NewStringf("darg->"); } name = Getattr(n, "name"); type = Getattr(n, "type"); t = NewString(classname); SwigType_add_pointer(t); parms = NewParm(t, "self", n); Setattr(parms, "self", "1"); Setattr(parms, "hidden","1"); Delete(t); ty = Swig_wrapped_member_var_type(type, varcref); if (flags & CWRAP_EXTEND) { String *call; String *cres; String *code = Getattr(n, "code"); String *gname = Swig_name_get(0, name); String *membername = Swig_name_member(0, classname, gname); String *mangled = Swig_name_mangle(membername); if (code) { /* I don't think this ever gets run - WSF */ Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, "self"); } call = Swig_cfunction_call(mangled, parms); cres = Swig_cresult(ty, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); Delete(mangled); Delete(membername); Delete(gname); } else { String *call = Swig_cmemberget_call(name, type, self, varcref); String *cres = Swig_cresult(ty, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); } Setattr(n, "type", ty); Setattr(n, "parms", parms); Delete(parms); Delete(ty); return SWIG_OK; } /* ----------------------------------------------------------------------------- * Swig_VarsetToFunction() * * This function creates a C wrapper for setting a global variable or static member * variable. * ----------------------------------------------------------------------------- */ int Swig_VarsetToFunction(Node *n, int flags) { String *name, *nname; ParmList *parms; SwigType *type, *ty; int varcref = flags & CWRAP_NATURAL_VAR; name = Getattr(n, "name"); type = Getattr(n, "type"); nname = SwigType_namestr(name); ty = Swig_wrapped_var_type(type, varcref); parms = NewParm(ty, name, n); if (flags & CWRAP_EXTEND) { String *sname = Swig_name_set(0, name); String *mangled = Swig_name_mangle(sname); String *call = Swig_cfunction_call(mangled, parms); String *cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); Delete(mangled); Delete(sname); } else { if (!Strstr(type, "enum $unnamed")) { String *pname = Swig_cparm_name(0, 0); String *dref = Swig_wrapped_var_deref(type, pname, varcref); String *call = NewStringf("%s = %s;", nname, dref); Setattr(n, "wrap:action", call); Delete(call); Delete(dref); Delete(pname); } else { String *pname = Swig_cparm_name(0, 0); String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;", nname, nname, pname); Setattr(n, "wrap:action", call); Delete(pname); Delete(call); } } Setattr(n, "type", "void"); Setattr(n, "parms", parms); Delete(parms); Delete(ty); Delete(nname); return SWIG_OK; } /* ----------------------------------------------------------------------------- * Swig_VargetToFunction() * * This function creates a C wrapper for getting a global variable or static member * variable. * ----------------------------------------------------------------------------- */ int Swig_VargetToFunction(Node *n, int flags) { String *cres, *call; String *name; SwigType *type; SwigType *ty = 0; int varcref = flags & CWRAP_NATURAL_VAR; name = Getattr(n, "name"); type = Getattr(n, "type"); ty = Swig_wrapped_var_type(type, varcref); if (flags & CWRAP_EXTEND) { String *sname = Swig_name_get(0, name); String *mangled = Swig_name_mangle(sname); call = Swig_cfunction_call(mangled, 0); cres = Swig_cresult(ty, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(mangled); Delete(sname); } else { String *nname = SwigType_namestr(name); call = Swig_wrapped_var_assign(type, nname, varcref); cres = Swig_cresult(ty, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(nname); } Setattr(n, "type", ty); Delattr(n, "parms"); Delete(cres); Delete(call); Delete(ty); return SWIG_OK; } swig-3.0.2/Source/Swig/deprecate.c0000664000175000017500000000753212343605122016623 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * deprecate.c * * The functions in this file are SWIG core functions that are deprecated * or which do not fit in nicely with everything else. Generally this means * that the function and/or API needs to be changed in some future release. * ----------------------------------------------------------------------------- */ #include "swig.h" /* --------------------------------------------------------------------- * ParmList_is_compactdefargs() * * Returns 1 if the parameter list passed in is marked for compact argument * handling (by the "compactdefargs" attribute). Otherwise returns 0. * ---------------------------------------------------------------------- */ /* Discussion: "compactdefargs" is a property set by the Parser to indicate special handling of default arguments. This property seems to be something that is associated with functions and methods rather than low-level ParmList objects. Therefore, I don't like the fact that this special purpose feature is bolted onto the side of ParmList objects. Proposed solution: 1. "compactdefargs" should be a feature set on function/method nodes instead of ParmList objects. For example, if you have a function, you would check the function node to see if the parameters are to be handled in this way. Difficulties: 1. This is used by functions in cwrap.c and emit.cxx, none of which are passed information about the function/method node. We might have to change the API of those functions to make this work correctly. For example: int emit_num_required(ParmList *parms) might become int emit_num_required(ParmList *parms, int compactargs) */ int ParmList_is_compactdefargs(ParmList *p) { int compactdefargs = 0; if (p) { compactdefargs = Getattr(p, "compactdefargs") ? 1 : 0; /* The "compactdefargs" attribute should only be set on the first parameter in the list. * However, sometimes an extra parameter is inserted at the beginning of the parameter list, * so we check the 2nd parameter too. */ if (!compactdefargs) { Parm *nextparm = nextSibling(p); compactdefargs = (nextparm && Getattr(nextparm, "compactdefargs")) ? 1 : 0; } } return compactdefargs; } /* --------------------------------------------------------------------- * ParmList_errorstr() * * Generate a prototype string suitable for use in error/warning messages. * Similar to ParmList_protostr() but is also aware of hidden parameters. * ---------------------------------------------------------------------- */ /* Discussion. This function is used to generate error messages, but take into account that there might be a hidden parameter. Although this involves parameter lists, it really isn't a core feature of swigparm.h or parms.c. This is because the "hidden" attribute of parameters is added elsewhere (cwrap.c). For now, this function is placed here because it doesn't really seem to fit in with the parms.c interface. */ String *ParmList_errorstr(ParmList *p) { String *out = NewStringEmpty(); while (p) { if (Getattr(p,"hidden")) { p = nextSibling(p); } else { String *pstr = SwigType_str(Getattr(p, "type"), 0); Append(out, pstr); p = nextSibling(p); if (p) { Append(out, ","); } Delete(pstr); } } return out; } swig-3.0.2/Source/Swig/stype.c0000664000175000017500000010505612343605122016033 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * stype.c * * This file provides general support for datatypes that are encoded in * the form of simple strings. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "cparse.h" #include /* ----------------------------------------------------------------------------- * Synopsis * * The purpose of this module is to provide a general purpose type representation * based on simple text strings. * * General idea: * * Types are represented by a base type (e.g., "int") and a collection of * type operators applied to the base (e.g., pointers, arrays, etc...). * * Encoding: * * Types are encoded as strings of type constructors such as follows: * * String Encoding C Example * --------------- --------- * p.p.int int ** * a(300).a(400).int int [300][400] * p.q(const).char char const * * * All type constructors are denoted by a trailing '.': * * 'p.' = Pointer (*) * 'r.' = Reference (&) * 'z.' = Rvalue reference (&&) * 'a(n).' = Array of size n [n] * 'f(..,..).' = Function with arguments (args) * 'q(str).' = Qualifier (such as const or volatile) (const, volatile) * 'm(qual).' = Pointer to member (qual::*) * * The encoding follows the order that you might describe a type in words. * For example "p.a(200).int" is "A pointer to array of int's" and * "p.q(const).char" is "a pointer to a const char". * * This representation of types is fairly convenient because ordinary string * operations can be used for type manipulation. For example, a type could be * formed by combining two strings such as the following: * * "p.p." + "a(400).int" = "p.p.a(400).int" * * Similarly, one could strip a 'const' declaration from a type doing something * like this: * * Replace(t,"q(const).","",DOH_REPLACE_ANY) * * For the most part, this module tries to minimize the use of special * characters (*, [, <, etc...) in its type encoding. One reason for this * is that SWIG might be extended to encode data in formats such as XML * where you might want to do this: * * * p.p.int * ... * * * Or alternatively, * * blah * * In either case, it's probably best to avoid characters such as '&', '*', or '<'. * * Why not use C syntax? Well, C syntax is fairly complicated to parse * and not particularly easy to manipulate---especially for adding, deleting and * composing type constructors. The string representation presented here makes * this pretty easy. * * Why not use a bunch of nested data structures? Are you kidding? How * would that be easier to use than a few simple string operations? * ----------------------------------------------------------------------------- */ SwigType *NewSwigType(int t) { switch (t) { case T_BOOL: return NewString("bool"); break; case T_INT: return NewString("int"); break; case T_UINT: return NewString("unsigned int"); break; case T_SHORT: return NewString("short"); break; case T_USHORT: return NewString("unsigned short"); break; case T_LONG: return NewString("long"); break; case T_ULONG: return NewString("unsigned long"); break; case T_FLOAT: return NewString("float"); break; case T_DOUBLE: return NewString("double"); break; case T_COMPLEX: return NewString("complex"); break; case T_CHAR: return NewString("char"); break; case T_SCHAR: return NewString("signed char"); break; case T_UCHAR: return NewString("unsigned char"); break; case T_STRING: { SwigType *t = NewString("char"); SwigType_add_qualifier(t, "const"); SwigType_add_pointer(t); return t; break; } case T_WCHAR: return NewString("wchar_t"); break; case T_WSTRING: { SwigType *t = NewString("wchar_t"); SwigType_add_pointer(t); return t; break; } case T_LONGLONG: return NewString("long long"); break; case T_ULONGLONG: return NewString("unsigned long long"); break; case T_VOID: return NewString("void"); break; case T_AUTO: return NewString("auto"); break; default: break; } return NewStringEmpty(); } /* ----------------------------------------------------------------------------- * SwigType_push() * * Push a type constructor onto the type * ----------------------------------------------------------------------------- */ void SwigType_push(SwigType *t, String *cons) { if (!cons) return; if (!Len(cons)) return; if (Len(t)) { char *c = Char(cons); if (c[strlen(c) - 1] != '.') Insert(t, 0, "."); } Insert(t, 0, cons); } /* ----------------------------------------------------------------------------- * SwigType_ispointer_return() * * Testing functions for querying a raw datatype * ----------------------------------------------------------------------------- */ int SwigType_ispointer_return(const SwigType *t) { char *c; int idx; if (!t) return 0; c = Char(t); idx = strlen(c) - 4; if (idx >= 0) { return (strcmp(c + idx, ").p.") == 0); } return 0; } int SwigType_isreference_return(const SwigType *t) { char *c; int idx; if (!t) return 0; c = Char(t); idx = strlen(c) - 4; if (idx >= 0) { return (strcmp(c + idx, ").r.") == 0); } return 0; } int SwigType_isconst(const SwigType *t) { char *c; if (!t) return 0; c = Char(t); if (strncmp(c, "q(", 2) == 0) { String *q = SwigType_parm(t); if (strstr(Char(q), "const")) { Delete(q); return 1; } Delete(q); } /* Hmmm. Might be const through a typedef */ if (SwigType_issimple(t)) { int ret; SwigType *td = SwigType_typedef_resolve(t); if (td) { ret = SwigType_isconst(td); Delete(td); return ret; } } return 0; } int SwigType_ismutable(const SwigType *t) { int r; SwigType *qt = SwigType_typedef_resolve_all(t); if (SwigType_isreference(qt) || SwigType_isrvalue_reference(qt) || SwigType_isarray(qt)) { Delete(SwigType_pop(qt)); } r = SwigType_isconst(qt); Delete(qt); return r ? 0 : 1; } int SwigType_isenum(const SwigType *t) { char *c = Char(t); if (!t) return 0; if (strncmp(c, "enum ", 5) == 0) { return 1; } return 0; } int SwigType_issimple(const SwigType *t) { char *c = Char(t); if (!t) return 0; while (*c) { if (*c == '<') { int nest = 1; c++; while (*c && nest) { if (*c == '<') nest++; if (*c == '>') nest--; c++; } c--; } if (*c == '.') return 0; c++; } return 1; } /* ----------------------------------------------------------------------------- * SwigType_default_create() * * Create the default type for this datatype. This takes a type and strips it * down to a generic form first by resolving all typedefs. * * Rules: * Pointers: p.SWIGTYPE * References: r.SWIGTYPE * Arrays no dimension: a().SWIGTYPE * Arrays with dimension: a(ANY).SWIGTYPE * Member pointer: m(CLASS).SWIGTYPE * Function pointer: f(ANY).SWIGTYPE * Enums: enum SWIGTYPE * Types: SWIGTYPE * * Examples (also see SwigType_default_deduce): * * int [2][4] * a(2).a(4).int * a(ANY).a(ANY).SWIGTYPE * * struct A {}; * typedef A *Aptr; * Aptr const & * r.q(const).Aptr * r.q(const).p.SWIGTYPE * * enum E {e1, e2}; * enum E const & * r.q(const).enum E * r.q(const).enum SWIGTYPE * ----------------------------------------------------------------------------- */ SwigType *SwigType_default_create(const SwigType *ty) { SwigType *r = 0; List *l; Iterator it; int numitems; if (!SwigType_isvarargs(ty)) { SwigType *t = SwigType_typedef_resolve_all(ty); r = NewStringEmpty(); l = SwigType_split(t); numitems = Len(l); if (numitems >= 1) { String *last_subtype = Getitem(l, numitems-1); if (SwigType_isenum(last_subtype)) Setitem(l, numitems-1, NewString("enum SWIGTYPE")); else Setitem(l, numitems-1, NewString("SWIGTYPE")); } for (it = First(l); it.item; it = Next(it)) { String *subtype = it.item; if (SwigType_isarray(subtype)) { if (Equal(subtype, "a().")) Append(r, NewString("a().")); else Append(r, NewString("a(ANY).")); } else if (SwigType_isfunction(subtype)) { Append(r, NewString("f(ANY).SWIGTYPE")); break; } else if (SwigType_ismemberpointer(subtype)) { Append(r, NewString("m(CLASS).SWIGTYPE")); break; } else { Append(r, subtype); } } Delete(l); Delete(t); } return r; } /* ----------------------------------------------------------------------------- * SwigType_default_deduce() * * This function implements type deduction used in the typemap matching rules * and is very close to the type deduction used in partial template class * specialization matching in that the most specialized type is always chosen. * SWIGTYPE is used as the generic type. The basic idea is to repeatedly call * this function to find a deduced type unless until nothing matches. * * The type t must have already been converted to the default type via a call to * SwigType_default_create() before calling this function. * * Example deductions (matching the examples described in SwigType_default_create), * where the most specialized matches are highest in the list: * * a(ANY).a(ANY).SWIGTYPE * a(ANY).a().SWIGTYPE * a(ANY).p.SWIGTYPE * a(ANY).SWIGTYPE * a().SWIGTYPE * p.SWIGTYPE * SWIGTYPE * * r.q(const).p.SWIGTYPE * r.q(const).SWIGTYPE * r.SWIGTYPE * SWIGTYPE * * r.q(const).enum SWIGTYPE * r.enum SWIGTYPE * r.SWIGTYPE * SWIGTYPE * ----------------------------------------------------------------------------- */ SwigType *SwigType_default_deduce(const SwigType *t) { SwigType *r = NewStringEmpty(); List *l; Iterator it; int numitems; l = SwigType_split(t); numitems = Len(l); if (numitems >= 1) { String *last_subtype = Getitem(l, numitems-1); int is_enum = SwigType_isenum(last_subtype); if (numitems >=2 ) { String *subtype = Getitem(l, numitems-2); /* last but one */ if (SwigType_isarray(subtype)) { if (is_enum) { /* enum deduction, enum SWIGTYPE => SWIGTYPE */ Setitem(l, numitems-1, NewString("SWIGTYPE")); } else { /* array deduction, a(ANY). => a(). => p. */ String *deduced_subtype = 0; if (Strcmp(subtype, "a().") == 0) { deduced_subtype = NewString("p."); } else if (Strcmp(subtype, "a(ANY).") == 0) { deduced_subtype = NewString("a()."); } else { assert(0); } Setitem(l, numitems-2, deduced_subtype); } } else if (SwigType_ismemberpointer(subtype)) { /* member pointer deduction, m(CLASS). => p. */ Setitem(l, numitems-2, NewString("p.")); } else if (is_enum && !SwigType_isqualifier(subtype)) { /* enum deduction, enum SWIGTYPE => SWIGTYPE */ Setitem(l, numitems-1, NewString("SWIGTYPE")); } else { /* simple type deduction, eg, r.p.p. => r.p. */ /* also function pointers eg, p.f(ANY). => p. */ Delitem(l, numitems-2); } } else { if (is_enum) { /* enum deduction, enum SWIGTYPE => SWIGTYPE */ Setitem(l, numitems-1, NewString("SWIGTYPE")); } else { /* delete the only item, we are done with deduction */ Delitem(l, 0); } } } else { assert(0); } for (it = First(l); it.item; it = Next(it)) { Append(r, it.item); } if (Len(r) == 0) { Delete(r); r = 0; } Delete(l); return r; } /* ----------------------------------------------------------------------------- * SwigType_namestr() * * Returns a string of the base type. Takes care of template expansions * ----------------------------------------------------------------------------- */ String *SwigType_namestr(const SwigType *t) { String *r; String *suffix; List *p; int i, sz; char *d = Char(t); char *c = strstr(d, "<("); if (!c || !strstr(c + 2, ")>")) return NewString(t); r = NewStringWithSize(d, c - d); if (*(c - 1) == '<') Putc(' ', r); Putc('<', r); p = SwigType_parmlist(c + 1); sz = Len(p); for (i = 0; i < sz; i++) { String *str = SwigType_str(Getitem(p, i), 0); /* Avoid creating a <: token, which is the same as [ in C++ - put a space after '<'. */ if (i == 0 && Len(str)) Putc(' ', r); Append(r, str); if ((i + 1) < sz) Putc(',', r); Delete(str); } Putc(' ', r); Putc('>', r); suffix = SwigType_templatesuffix(t); if (Len(suffix) > 0) { String *suffix_namestr = SwigType_namestr(suffix); Append(r, suffix_namestr); Delete(suffix_namestr); } else { Append(r, suffix); } Delete(suffix); Delete(p); return r; } /* ----------------------------------------------------------------------------- * SwigType_str() * * Create a C string representation of a datatype. * ----------------------------------------------------------------------------- */ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) { String *result; String *element = 0; String *nextelement; String *forwardelement; List *elements; int nelements, i; if (id) { /* stringify the id expanding templates, for example when the id is a fully qualified templated class name */ String *id_str = NewString(id); /* unfortunate copy due to current const limitations */ result = SwigType_str(id_str, 0); Delete(id_str); } else { result = NewStringEmpty(); } elements = SwigType_split(s); nelements = Len(elements); if (nelements > 0) { element = Getitem(elements, 0); } /* Now, walk the type list and start emitting */ for (i = 0; i < nelements; i++) { if (i < (nelements - 1)) { nextelement = Getitem(elements, i + 1); forwardelement = nextelement; if (SwigType_isqualifier(nextelement)) { if (i < (nelements - 2)) forwardelement = Getitem(elements, i + 2); } } else { nextelement = 0; forwardelement = 0; } if (SwigType_isqualifier(element)) { DOH *q = 0; q = SwigType_parm(element); Insert(result, 0, " "); Insert(result, 0, q); Delete(q); } else if (SwigType_ispointer(element)) { Insert(result, 0, "*"); if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) { Insert(result, 0, "("); Append(result, ")"); } } else if (SwigType_ismemberpointer(element)) { String *q; q = SwigType_parm(element); Insert(result, 0, "::*"); Insert(result, 0, q); if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) { Insert(result, 0, "("); Append(result, ")"); } Delete(q); } else if (SwigType_isreference(element)) { Insert(result, 0, "&"); if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) { Insert(result, 0, "("); Append(result, ")"); } } else if (SwigType_isrvalue_reference(element)) { Insert(result, 0, "&&"); if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) { Insert(result, 0, "("); Append(result, ")"); } } else if (SwigType_isarray(element)) { DOH *size; Append(result, "["); size = SwigType_parm(element); Append(result, size); Append(result, "]"); Delete(size); } else if (SwigType_isfunction(element)) { DOH *parms, *p; int j, plen; Append(result, "("); parms = SwigType_parmlist(element); plen = Len(parms); for (j = 0; j < plen; j++) { p = SwigType_str(Getitem(parms, j), 0); Append(result, p); if (j < (plen - 1)) Append(result, ","); } Append(result, ")"); Delete(parms); } else { if (strcmp(Char(element), "v(...)") == 0) { Insert(result, 0, "..."); } else { String *bs = SwigType_namestr(element); Insert(result, 0, " "); Insert(result, 0, bs); Delete(bs); } } element = nextelement; } Delete(elements); Chop(result); return result; } /* ----------------------------------------------------------------------------- * SwigType_ltype(const SwigType *ty) * * Create a locally assignable type * ----------------------------------------------------------------------------- */ SwigType *SwigType_ltype(const SwigType *s) { String *result; String *element; SwigType *td, *tc = 0; List *elements; int nelements, i; int firstarray = 1; int notypeconv = 0; result = NewStringEmpty(); tc = Copy(s); /* Nuke all leading qualifiers */ while (SwigType_isqualifier(tc)) { Delete(SwigType_pop(tc)); } if (SwigType_issimple(tc)) { /* Resolve any typedef definitions */ SwigType *tt = Copy(tc); td = 0; while ((td = SwigType_typedef_resolve(tt))) { if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td) || SwigType_isrvalue_reference(td))) { /* We need to use the typedef type */ Delete(tt); break; } else if (td) { Delete(tt); tt = td; } } if (td) { Delete(tc); tc = td; } } elements = SwigType_split(tc); nelements = Len(elements); /* Now, walk the type list and start emitting */ for (i = 0; i < nelements; i++) { element = Getitem(elements, i); /* when we see a function, we need to preserve the following types */ if (SwigType_isfunction(element)) { notypeconv = 1; } if (SwigType_isqualifier(element)) { /* Do nothing. Ignore */ } else if (SwigType_ispointer(element)) { Append(result, element); firstarray = 0; } else if (SwigType_ismemberpointer(element)) { Append(result, element); firstarray = 0; } else if (SwigType_isreference(element)) { if (notypeconv) { Append(result, element); } else { Append(result, "p."); } firstarray = 0; } else if (SwigType_isrvalue_reference(element)) { if (notypeconv) { Append(result, element); } else { Append(result, "p."); } firstarray = 0; } else if (SwigType_isarray(element) && firstarray) { if (notypeconv) { Append(result, element); } else { Append(result, "p."); } firstarray = 0; } else if (SwigType_isenum(element)) { int anonymous_enum = (Cmp(element, "enum ") == 0); if (notypeconv || !anonymous_enum) { Append(result, element); } else { Append(result, "int"); } } else { Append(result, element); } } Delete(elements); Delete(tc); return result; } /* ----------------------------------------------------------------------------- * SwigType_lstr(DOH *s, DOH *id) * * Produces a type-string that is suitable as a lvalue in an expression. * That is, a type that can be freely assigned a value without violating * any C assignment rules. * * - Qualifiers such as 'const' and 'volatile' are stripped. * - Arrays are converted into a *single* pointer (i.e., * double [][] becomes double *). * - References are converted into a pointer. * - Typedef names that refer to read-only types will be replaced * with an equivalent assignable version. * -------------------------------------------------------------------- */ String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id) { String *result; SwigType *tc; tc = SwigType_ltype(s); result = SwigType_str(tc, id); Delete(tc); return result; } /* ----------------------------------------------------------------------------- * SwigType_rcaststr() * * Produces a casting string that maps the type returned by lstr() to the real * datatype printed by str(). * ----------------------------------------------------------------------------- */ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) { String *result, *cast; String *element = 0; String *nextelement; String *forwardelement; SwigType *td, *tc = 0; const SwigType *rs; List *elements; int nelements, i; int clear = 1; int firstarray = 1; int isreference = 0; int isfunction = 0; result = NewStringEmpty(); if (SwigType_isconst(s)) { tc = Copy(s); Delete(SwigType_pop(tc)); rs = tc; } else { rs = s; } if ((SwigType_isconst(rs) || SwigType_isarray(rs) || SwigType_isreference(rs) || SwigType_isrvalue_reference(rs))) { td = 0; } else { td = SwigType_typedef_resolve(rs); } if (td) { if ((SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td) || SwigType_isrvalue_reference(td))) { elements = SwigType_split(td); } else { elements = SwigType_split(rs); } Delete(td); } else { elements = SwigType_split(rs); } nelements = Len(elements); if (nelements > 0) { element = Getitem(elements, 0); } /* Now, walk the type list and start emitting */ for (i = 0; i < nelements; i++) { if (i < (nelements - 1)) { nextelement = Getitem(elements, i + 1); forwardelement = nextelement; if (SwigType_isqualifier(nextelement)) { if (i < (nelements - 2)) forwardelement = Getitem(elements, i + 2); } } else { nextelement = 0; forwardelement = 0; } if (SwigType_isqualifier(element)) { DOH *q = 0; q = SwigType_parm(element); Insert(result, 0, " "); Insert(result, 0, q); Delete(q); clear = 0; } else if (SwigType_ispointer(element)) { Insert(result, 0, "*"); if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) { Insert(result, 0, "("); Append(result, ")"); } firstarray = 0; } else if (SwigType_ismemberpointer(element)) { String *q; Insert(result, 0, "::*"); q = SwigType_parm(element); Insert(result, 0, q); Delete(q); if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) { Insert(result, 0, "("); Append(result, ")"); } firstarray = 0; } else if (SwigType_isreference(element)) { Insert(result, 0, "&"); if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) { Insert(result, 0, "("); Append(result, ")"); } if (!isfunction) isreference = 1; } else if (SwigType_isrvalue_reference(element)) { Insert(result, 0, "&&"); if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) { Insert(result, 0, "("); Append(result, ")"); } if (!isfunction) isreference = 1; clear = 0; } else if (SwigType_isarray(element)) { DOH *size; if (firstarray && !isreference) { Append(result, "(*)"); firstarray = 0; } else { Append(result, "["); size = SwigType_parm(element); Append(result, size); Append(result, "]"); Delete(size); clear = 0; } } else if (SwigType_isfunction(element)) { DOH *parms, *p; int j, plen; Append(result, "("); parms = SwigType_parmlist(element); plen = Len(parms); for (j = 0; j < plen; j++) { p = SwigType_str(Getitem(parms, j), 0); Append(result, p); Delete(p); if (j < (plen - 1)) Append(result, ","); } Append(result, ")"); Delete(parms); isfunction = 1; } else { String *bs = SwigType_namestr(element); Insert(result, 0, " "); Insert(result, 0, bs); Delete(bs); } element = nextelement; } Delete(elements); if (clear) { cast = NewStringEmpty(); } else { cast = NewStringf("(%s)", result); } if (name) { if (isreference) { Append(cast, "*"); } Append(cast, name); } Delete(result); Delete(tc); return cast; } /* ----------------------------------------------------------------------------- * SwigType_lcaststr() * * Casts a variable from the real type to the local datatype. * ----------------------------------------------------------------------------- */ String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr name) { String *result; result = NewStringEmpty(); if (SwigType_isarray(s)) { String *lstr = SwigType_lstr(s, 0); Printf(result, "(%s)%s", lstr, name); Delete(lstr); } else if (SwigType_isreference(s)) { String *str = SwigType_str(s, 0); Printf(result, "(%s)", str); Delete(str); if (name) Append(result, name); } else if (SwigType_isrvalue_reference(s)) { String *str = SwigType_str(s, 0); Printf(result, "(%s)", str); Delete(str); if (name) Append(result, name); } else if (SwigType_isqualifier(s)) { String *lstr = SwigType_lstr(s, 0); Printf(result, "(%s)%s", lstr, name); Delete(lstr); } else { if (name) Append(result, name); } return result; } #if 0 /* Alternative implementation for manglestr_default. Mangling is similar to the original except for a few subtle differences for example in templates: namespace foo { template class bar {}; typedef int Integer; void test2(bar *x); } Mangling is more consistent and changes from _p_foo__barT_int_p_t to _p_foo__barT_p_int_t. */ static void mangle_stringcopy(String *destination, const char *source, int count) { while (count-- > 0) { char newc = '_'; if (!(*source == '.' || *source == ':' || *source == ' ')) newc = *source; /* TODO: occasionally '*' or numerics need converting to '_', eg in array dimensions and template expressions */ Putc(newc, destination); source++; } } static void mangle_subtype(String *mangled, SwigType *s); /* ----------------------------------------------------------------------------- * mangle_namestr() * * Mangles a type taking care of template expansions. Similar to SwigType_namestr(). * The type may include a trailing '.', for example "p." * ----------------------------------------------------------------------------- */ static void mangle_namestr(String *mangled, SwigType *t) { int length = Len(t); if (SwigType_isqualifier(t)) { Append(mangled, "q_"); mangle_stringcopy(mangled, Char(t)+2, length-4); Append(mangled, "__"); } else if (SwigType_ismemberpointer(t)) { Append(mangled, "m_"); mangle_stringcopy(mangled, Char(t)+2, length-4); Append(mangled, "__"); } else if (SwigType_isarray(t)) { Append(mangled, "a_"); mangle_stringcopy(mangled, Char(t)+2, length-4); Append(mangled, "__"); } else if (SwigType_isfunction(t)) { List *p = SwigType_parmlist(t); int sz = Len(p); int i; Append(mangled, "f_"); for (i = 0; i < sz; i++) { mangle_subtype(mangled, Getitem(p, i)); Putc('_', mangled); } Append(mangled, (sz > 0) ? "_" : "__"); } else if (SwigType_isvarargs(t)) { Append(mangled, "___"); } else { char *d = Char(t); char *c = strstr(d, "<("); if (!c || !strstr(c + 2, ")>")) { /* not a template type */ mangle_stringcopy(mangled, Char(t), Len(t)); } else { /* a template type */ String *suffix; List *p; int i, sz; mangle_stringcopy(mangled, d, c-d); Putc('T', mangled); Putc('_', mangled); p = SwigType_parmlist(c + 1); sz = Len(p); for (i = 0; i < sz; i++) { mangle_subtype(mangled, Getitem(p, i)); Putc('_', mangled); } Putc('t', mangled); suffix = SwigType_templatesuffix(t); if (Len(suffix) > 0) { mangle_namestr(mangled, suffix); } else { Append(mangled, suffix); } Delete(suffix); Delete(p); } } } static void mangle_subtype(String *mangled, SwigType *s) { List *elements; int nelements, i; assert(s); elements = SwigType_split(s); nelements = Len(elements); for (i = 0; i < nelements; i++) { SwigType *element = Getitem(elements, i); mangle_namestr(mangled, element); } Delete(elements); } static String *manglestr_default(const SwigType *s) { String *mangled = NewString("_"); SwigType *sr = SwigType_typedef_resolve_all(s); SwigType *sq = SwigType_typedef_qualified(sr); SwigType *ss = SwigType_remove_global_scope_prefix(sq); SwigType *type = ss; SwigType *lt; if (SwigType_istemplate(ss)) { SwigType *ty = Swig_symbol_template_deftype(ss, 0); Delete(ss); ss = ty; type = ss; } lt = SwigType_ltype(type); Replace(lt, "struct ", "", DOH_REPLACE_ANY); Replace(lt, "class ", "", DOH_REPLACE_ANY); Replace(lt, "union ", "", DOH_REPLACE_ANY); Replace(lt, "enum ", "", DOH_REPLACE_ANY); mangle_subtype(mangled, lt); Delete(ss); Delete(sq); Delete(sr); return mangled; } #else static String *manglestr_default(const SwigType *s) { char *c; String *result = 0; String *base = 0; SwigType *lt; SwigType *sr = SwigType_typedef_resolve_all(s); SwigType *sq = SwigType_typedef_qualified(sr); SwigType *ss = SwigType_remove_global_scope_prefix(sq); SwigType *type = ss; if (SwigType_istemplate(ss)) { SwigType *ty = Swig_symbol_template_deftype(ss, 0); Delete(ss); ss = ty; type = ss; } lt = SwigType_ltype(type); result = SwigType_prefix(lt); base = SwigType_base(lt); c = Char(result); while (*c) { if (!isalnum((int) *c)) *c = '_'; c++; } if (SwigType_istemplate(base)) { String *b = SwigType_namestr(base); Delete(base); base = b; } Replace(base, "struct ", "", DOH_REPLACE_ANY); /* This might be problematic */ Replace(base, "class ", "", DOH_REPLACE_ANY); Replace(base, "union ", "", DOH_REPLACE_ANY); Replace(base, "enum ", "", DOH_REPLACE_ANY); c = Char(base); while (*c) { if (*c == '<') *c = 'T'; else if (*c == '>') *c = 't'; else if (*c == '*') *c = 'p'; else if (*c == '[') *c = 'a'; else if (*c == ']') *c = 'A'; else if (*c == '&') *c = 'R'; else if (*c == '(') *c = 'f'; else if (*c == ')') *c = 'F'; else if (!isalnum((int) *c)) *c = '_'; c++; } Append(result, base); Insert(result, 0, "_"); Delete(lt); Delete(base); Delete(ss); Delete(sq); Delete(sr); return result; } #endif String *SwigType_manglestr(const SwigType *s) { #if 0 /* Debugging checks to ensure a proper SwigType is passed in and not a stringified type */ String *angle = Strstr(s, "<"); if (angle && Strncmp(angle, "<(", 2) != 0) Printf(stderr, "SwigType_manglestr error: %s\n", s); else if (Strstr(s, "*") || Strstr(s, "&") || Strstr(s, "[")) Printf(stderr, "SwigType_manglestr error: %s\n", s); #endif return manglestr_default(s); } /* ----------------------------------------------------------------------------- * SwigType_typename_replace() * * Replaces a typename in a type with something else. Needed for templates. * ----------------------------------------------------------------------------- */ void SwigType_typename_replace(SwigType *t, String *pat, String *rep) { String *nt; int i, ilen; List *elem; if (!Strstr(t, pat)) return; if (Equal(t, pat)) { Replace(t, pat, rep, DOH_REPLACE_ANY); return; } nt = NewStringEmpty(); elem = SwigType_split(t); ilen = Len(elem); for (i = 0; i < ilen; i++) { String *e = Getitem(elem, i); if (SwigType_issimple(e)) { if (Equal(e, pat)) { /* Replaces a type of the form 'pat' with 'rep' */ Replace(e, pat, rep, DOH_REPLACE_ANY); } else if (SwigType_istemplate(e)) { /* Replaces a type of the form 'pat' with 'rep' */ if (Equal(e, pat)) { String *repbase = SwigType_templateprefix(rep); Replace(e, pat, repbase, DOH_REPLACE_ID | DOH_REPLACE_FIRST); Delete(repbase); } { String *tsuffix; List *tparms = SwigType_parmlist(e); int j, jlen; String *nt = SwigType_templateprefix(e); Append(nt, "<("); jlen = Len(tparms); for (j = 0; j < jlen; j++) { SwigType_typename_replace(Getitem(tparms, j), pat, rep); Append(nt, Getitem(tparms, j)); if (j < (jlen - 1)) Putc(',', nt); } tsuffix = SwigType_templatesuffix(e); Printf(nt, ")>%s", tsuffix); Delete(tsuffix); Clear(e); Append(e, nt); Delete(nt); Delete(tparms); } } else if (Swig_scopename_check(e)) { String *first, *rest; first = Swig_scopename_first(e); rest = Swig_scopename_suffix(e); SwigType_typename_replace(rest, pat, rep); SwigType_typename_replace(first, pat, rep); Clear(e); Printv(e, first, "::", rest, NIL); Delete(first); Delete(rest); } } else if (SwigType_isfunction(e)) { int j, jlen; List *fparms = SwigType_parmlist(e); Clear(e); Append(e, "f("); jlen = Len(fparms); for (j = 0; j < jlen; j++) { SwigType_typename_replace(Getitem(fparms, j), pat, rep); Append(e, Getitem(fparms, j)); if (j < (jlen - 1)) Putc(',', e); } Append(e, ")."); Delete(fparms); } else if (SwigType_isarray(e)) { Replace(e, pat, rep, DOH_REPLACE_ID); } Append(nt, e); } Clear(t); Append(t, nt); Delete(nt); Delete(elem); } /* ----------------------------------------------------------------------------- * SwigType_remove_global_scope_prefix() * * Removes the unary scope operator (::) prefix indicating global scope in all * components of the type * ----------------------------------------------------------------------------- */ SwigType *SwigType_remove_global_scope_prefix(const SwigType *t) { SwigType *result; const char *type = Char(t); if (strncmp(type, "::", 2) == 0) type += 2; result = NewString(type); Replaceall(result, ".::", "."); Replaceall(result, "(::", "("); Replaceall(result, "enum ::", "enum "); return result; } /* ----------------------------------------------------------------------------- * SwigType_check_decl() * * Checks type declarators for a match * ----------------------------------------------------------------------------- */ int SwigType_check_decl(const SwigType *ty, const SwigType *decl) { SwigType *t, *t1, *t2; int r; t = SwigType_typedef_resolve_all(ty); t1 = SwigType_strip_qualifiers(t); t2 = SwigType_prefix(t1); r = Equal(t2, decl); Delete(t); Delete(t1); Delete(t2); return r == 1; } swig-3.0.2/Source/Swig/parms.c0000664000175000017500000001612112343605122016003 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * parms.c * * Parameter list class. * ----------------------------------------------------------------------------- */ #include "swig.h" /* ------------------------------------------------------------------------ * NewParm() * * Create a new parameter from datatype 'type' and name 'name' copying * the file and line number from the Node from_node. * ------------------------------------------------------------------------ */ Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *from_node) { Parm *p = NewParmWithoutFileLineInfo(type, name); Setfile(p, Getfile(from_node)); Setline(p, Getline(from_node)); return p; } /* ------------------------------------------------------------------------ * NewParmWithoutFileLineInfo() * * Create a new parameter from datatype 'type' and name 'name' without any * file / line numbering information. * ------------------------------------------------------------------------ */ Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name) { Parm *p = NewHash(); set_nodeType(p, "parm"); if (type) { SwigType *ntype = Copy(type); Setattr(p, "type", ntype); Delete(ntype); } Setattr(p, "name", name); return p; } /* ------------------------------------------------------------------------ * NewParmNode() * * Create a new parameter from datatype 'type' and name and symbol table as * well as file and line number from the 'from_node'. * The resulting Parm will be similar to a Node used for typemap lookups. * ------------------------------------------------------------------------ */ Parm *NewParmNode(SwigType *type, Node *from_node) { Parm *p = NewParm(type, Getattr(from_node, "name"), from_node); Setattr(p, "sym:symtab", Getattr(from_node, "sym:symtab")); return p; } /* ------------------------------------------------------------------------ * CopyParm() * ------------------------------------------------------------------------ */ Parm *CopyParm(Parm *p) { Parm *np = NewHash(); Iterator ki; for (ki = First(p); ki.key; ki = Next(ki)) { if (DohIsString(ki.item)) { DOH *c = Copy(ki.item); Setattr(np,ki.key,c); Delete(c); } } Setfile(np, Getfile(p)); Setline(np, Getline(p)); return np; } /* ------------------------------------------------------------------ * CopyParmListMax() * CopyParmList() * ------------------------------------------------------------------ */ ParmList *CopyParmListMax(ParmList *p, int count) { Parm *np; Parm *pp = 0; Parm *fp = 0; if (!p) return 0; while (p) { if (count == 0) break; np = CopyParm(p); if (pp) { set_nextSibling(pp, np); Delete(np); } else { fp = np; } pp = np; p = nextSibling(p); count--; } return fp; } ParmList *CopyParmList(ParmList *p) { return CopyParmListMax(p,-1); } /* ----------------------------------------------------------------------------- * int ParmList_numrequired(). Return number of required arguments * ----------------------------------------------------------------------------- */ int ParmList_numrequired(ParmList *p) { int i = 0; while (p) { SwigType *t = Getattr(p, "type"); String *value = Getattr(p, "value"); if (value) return i; if (!(SwigType_type(t) == T_VOID)) i++; else break; p = nextSibling(p); } return i; } /* ----------------------------------------------------------------------------- * int ParmList_len() * ----------------------------------------------------------------------------- */ int ParmList_len(ParmList *p) { int i = 0; while (p) { i++; p = nextSibling(p); } return i; } /* --------------------------------------------------------------------- * get_empty_type() * ---------------------------------------------------------------------- */ static SwigType *get_empty_type() { return NewStringEmpty(); } /* --------------------------------------------------------------------- * ParmList_str() * * Generates a string of parameters * ---------------------------------------------------------------------- */ String *ParmList_str(ParmList *p) { String *out = NewStringEmpty(); while (p) { String *type = Getattr(p, "type"); String *pstr = SwigType_str(type ? type : get_empty_type(), Getattr(p, "name")); Append(out, pstr); p = nextSibling(p); if (p) { Append(out, ","); } Delete(pstr); } return out; } /* --------------------------------------------------------------------- * ParmList_str_defaultargs() * * Generates a string of parameters including default arguments * ---------------------------------------------------------------------- */ String *ParmList_str_defaultargs(ParmList *p) { String *out = NewStringEmpty(); while (p) { String *value = Getattr(p, "value"); String *type = Getattr(p, "type"); String *pstr = SwigType_str(type ? type : get_empty_type(), Getattr(p, "name")); Append(out, pstr); if (value) { Printf(out, "=%s", value); } p = nextSibling(p); if (p) { Append(out, ","); } Delete(pstr); } return out; } /* ----------------------------------------------------------------------------- * ParmList_str_multibrackets() * * Generates a string of parameters including default arguments adding brackets * if more than one parameter * ----------------------------------------------------------------------------- */ String *ParmList_str_multibrackets(ParmList *p) { String *out; String *parm_str = ParmList_str_defaultargs(p); if (ParmList_len(p) > 1) out = NewStringf("(%s)", parm_str); else out = NewStringf("%s", parm_str); Delete(parm_str); return out; } /* --------------------------------------------------------------------- * ParmList_protostr() * * Generate a prototype string. * ---------------------------------------------------------------------- */ String *ParmList_protostr(ParmList *p) { String *out = NewStringEmpty(); while (p) { String *type = Getattr(p, "type"); String *pstr = SwigType_str(type ? type : get_empty_type(), 0); Append(out, pstr); p = nextSibling(p); if (p) { Append(out, ","); } Delete(pstr); } return out; } /* --------------------------------------------------------------------- * ParmList_has_defaultargs() * * Returns 1 if the parameter list passed in is has one or more default * arguments. Otherwise returns 0. * ---------------------------------------------------------------------- */ int ParmList_has_defaultargs(ParmList *p) { while (p) { if (Getattr(p, "value")) { return 1; } p = nextSibling(p); } return 0; } swig-3.0.2/Source/Swig/naming.c0000664000175000017500000014546312343605122016146 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * naming.c * * Functions for generating various kinds of names during code generation. * * Swig_name_register is used to register a format string for generating names. * The format string makes use of the following format specifiers: * * %c - class name is substituted * %f - function name is substituted * %m - member name is substituted * %n - namespace is substituted * %v - variable name is substituted * ----------------------------------------------------------------------------- */ #include "swig.h" #include "cparse.h" #include /* Hash table containing naming data */ static Hash *naming_hash = 0; #if 0 #define SWIG_DEBUG #endif /* ----------------------------------------------------------------------------- * Swig_name_register() * * Register a new naming format. * ----------------------------------------------------------------------------- */ void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format) { if (!naming_hash) naming_hash = NewHash(); Setattr(naming_hash, method, format); } void Swig_name_unregister(const_String_or_char_ptr method) { if (naming_hash) { Delattr(naming_hash, method); } } static int name_mangle(String *r) { char *c; int special; special = 0; Replaceall(r, "::", "_"); c = Char(r); while (*c) { if (!isalnum((int) *c) && (*c != '_')) { special = 1; switch (*c) { case '+': *c = 'a'; break; case '-': *c = 's'; break; case '*': *c = 'm'; break; case '/': *c = 'd'; break; case '<': *c = 'l'; break; case '>': *c = 'g'; break; case '=': *c = 'e'; break; case ',': *c = 'c'; break; case '(': *c = 'p'; break; case ')': *c = 'P'; break; case '[': *c = 'b'; break; case ']': *c = 'B'; break; case '^': *c = 'x'; break; case '&': *c = 'A'; break; case '|': *c = 'o'; break; case '~': *c = 'n'; break; case '!': *c = 'N'; break; case '%': *c = 'M'; break; case '.': *c = 'f'; break; case '?': *c = 'q'; break; default: *c = '_'; break; } } c++; } if (special) Append(r, "___"); return special; } /* ----------------------------------------------------------------------------- * replace_nspace() * * Mangles in the namespace from nspace by replacing %n in name if nspace feature required. * ----------------------------------------------------------------------------- */ static void replace_nspace(String *name, const_String_or_char_ptr nspace) { if (nspace) { String *namspace = NewStringf("%s_", nspace); Replaceall(namspace, NSPACE_SEPARATOR, "_"); Replace(name, "%n", namspace, DOH_REPLACE_ANY); Delete(namspace); } else { Replace(name, "%n", "", DOH_REPLACE_ANY); } } /* ----------------------------------------------------------------------------- * Swig_name_mangle() * * Converts all of the non-identifier characters of a string to underscores. * ----------------------------------------------------------------------------- */ String *Swig_name_mangle(const_String_or_char_ptr s) { #if 0 String *r = NewString(s); name_mangle(r); return r; #else return Swig_string_mangle(s); #endif } /* ----------------------------------------------------------------------------- * Swig_name_wrapper() * * Returns the name of a wrapper function. * ----------------------------------------------------------------------------- */ String *Swig_name_wrapper(const_String_or_char_ptr fname) { String *r; String *f; r = NewStringEmpty(); if (!naming_hash) naming_hash = NewHash(); f = Getattr(naming_hash, "wrapper"); if (!f) { Append(r, "_wrap_%f"); } else { Append(r, f); } Replace(r, "%f", fname, DOH_REPLACE_ANY); name_mangle(r); return r; } /* ----------------------------------------------------------------------------- * Swig_name_member() * * Returns the name of a class method. * ----------------------------------------------------------------------------- */ String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername) { String *r; String *f; String *rclassname; char *cname; rclassname = SwigType_namestr(classname); r = NewStringEmpty(); if (!naming_hash) naming_hash = NewHash(); f = Getattr(naming_hash, "member"); if (!f) { Append(r, "%n%c_%m"); } else { Append(r, f); } cname = Char(rclassname); if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) { cname = strchr(cname, ' ') + 1; } replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); Replace(r, "%m", membername, DOH_REPLACE_ANY); /* name_mangle(r); */ Delete(rclassname); return r; } /* ----------------------------------------------------------------------------- * Swig_name_get() * * Returns the name of the accessor function used to get a variable. * ----------------------------------------------------------------------------- */ String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) { String *r; String *f; #ifdef SWIG_DEBUG Printf(stdout, "Swig_name_get: '%s'\n", vname); #endif r = NewStringEmpty(); if (!naming_hash) naming_hash = NewHash(); f = Getattr(naming_hash, "get"); if (!f) { Append(r, "%n%v_get"); } else { Append(r, f); } replace_nspace(r, nspace); Replace(r, "%v", vname, DOH_REPLACE_ANY); /* name_mangle(r); */ return r; } /* ----------------------------------------------------------------------------- * Swig_name_set() * * Returns the name of the accessor function used to set a variable. * ----------------------------------------------------------------------------- */ String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) { String *r; String *f; r = NewStringEmpty(); if (!naming_hash) naming_hash = NewHash(); f = Getattr(naming_hash, "set"); if (!f) { Append(r, "%n%v_set"); } else { Append(r, f); } replace_nspace(r, nspace); Replace(r, "%v", vname, DOH_REPLACE_ANY); /* name_mangle(r); */ return r; } /* ----------------------------------------------------------------------------- * Swig_name_construct() * * Returns the name of the accessor function used to create an object. * ----------------------------------------------------------------------------- */ String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; char *cname; rclassname = SwigType_namestr(classname); r = NewStringEmpty(); if (!naming_hash) naming_hash = NewHash(); f = Getattr(naming_hash, "construct"); if (!f) { Append(r, "new_%n%c"); } else { Append(r, f); } cname = Char(rclassname); if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) { cname = strchr(cname, ' ') + 1; } replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); Delete(rclassname); return r; } /* ----------------------------------------------------------------------------- * Swig_name_copyconstructor() * * Returns the name of the accessor function used to copy an object. * ----------------------------------------------------------------------------- */ String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; char *cname; rclassname = SwigType_namestr(classname); r = NewStringEmpty(); if (!naming_hash) naming_hash = NewHash(); f = Getattr(naming_hash, "copy"); if (!f) { Append(r, "copy_%n%c"); } else { Append(r, f); } cname = Char(rclassname); if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) { cname = strchr(cname, ' ') + 1; } replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); Delete(rclassname); return r; } /* ----------------------------------------------------------------------------- * Swig_name_destroy() * * Returns the name of the accessor function used to destroy an object. * ----------------------------------------------------------------------------- */ String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; char *cname; rclassname = SwigType_namestr(classname); r = NewStringEmpty(); if (!naming_hash) naming_hash = NewHash(); f = Getattr(naming_hash, "destroy"); if (!f) { Append(r, "delete_%n%c"); } else { Append(r, f); } cname = Char(rclassname); if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) { cname = strchr(cname, ' ') + 1; } replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); Delete(rclassname); return r; } /* ----------------------------------------------------------------------------- * Swig_name_disown() * * Returns the name of the accessor function used to disown an object. * ----------------------------------------------------------------------------- */ String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; char *cname; rclassname = SwigType_namestr(classname); r = NewStringEmpty(); if (!naming_hash) naming_hash = NewHash(); f = Getattr(naming_hash, "disown"); if (!f) { Append(r, "disown_%n%c"); } else { Append(r, f); } cname = Char(rclassname); if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) { cname = strchr(cname, ' ') + 1; } replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); Delete(rclassname); return r; } /* ----------------------------------------------------------------------------- * Swig_name_object_set() * * Sets an object associated with a name and optional declarators. * ----------------------------------------------------------------------------- */ void Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object) { DOH *n; #ifdef SWIG_DEBUG Printf(stdout, "Swig_name_object_set: '%s', '%s'\n", name, decl); #endif n = Getattr(namehash, name); if (!n) { n = NewHash(); Setattr(namehash, name, n); Delete(n); } /* Add an object based on the declarator value */ if (!decl) { Setattr(n, "start", object); } else { SwigType *cd = Copy(decl); Setattr(n, cd, object); Delete(cd); } } /* ----------------------------------------------------------------------------- * Swig_name_object_get() * * Return an object associated with an optional class prefix, name, and * declarator. This function operates according to name matching rules * described for the %rename directive in the SWIG manual. * ----------------------------------------------------------------------------- */ static DOH *get_object(Hash *n, String *decl) { DOH *rn = 0; if (!n) return 0; if (decl) { rn = Getattr(n, decl); } else { rn = Getattr(n, "start"); } return rn; } static DOH *name_object_get(Hash *namehash, String *tname, SwigType *decl, SwigType *ncdecl) { DOH *rn = 0; Hash *n = Getattr(namehash, tname); if (n) { rn = get_object(n, decl); if ((!rn) && ncdecl) rn = get_object(n, ncdecl); if (!rn) rn = get_object(n, 0); } return rn; } DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *decl) { String *tname = NewStringEmpty(); DOH *rn = 0; char *ncdecl = 0; if (!namehash) return 0; /* DB: This removed to more tightly control feature/name matching */ /* if ((decl) && (SwigType_isqualifier(decl))) { ncdecl = strchr(Char(decl),'.'); ncdecl++; } */ #ifdef SWIG_DEBUG Printf(stdout, "Swig_name_object_get: '%s' '%s', '%s'\n", prefix, name, decl); #endif /* Perform a class-based lookup (if class prefix supplied) */ if (prefix) { if (Len(prefix)) { Printf(tname, "%s::%s", prefix, name); rn = name_object_get(namehash, tname, decl, ncdecl); if (!rn) { String *cls = Swig_scopename_last(prefix); if (!Equal(cls, prefix)) { Clear(tname); Printf(tname, "*::%s::%s", cls, name); rn = name_object_get(namehash, tname, decl, ncdecl); } Delete(cls); } /* A template-based class lookup, check name first */ if (!rn) { String *t_name = SwigType_istemplate_templateprefix(name); if (t_name) rn = Swig_name_object_get(namehash, prefix, t_name, decl); Delete(t_name); } } /* A wildcard-based class lookup */ if (!rn) { Clear(tname); Printf(tname, "*::%s", name); rn = name_object_get(namehash, tname, decl, ncdecl); } } else { /* Lookup in the global namespace only */ Clear(tname); Printf(tname, "::%s", name); rn = name_object_get(namehash, tname, decl, ncdecl); } /* Catch-all */ if (!rn) { rn = name_object_get(namehash, name, decl, ncdecl); } if (!rn && Swig_scopename_check(name)) { String *nprefix = NewStringEmpty(); String *nlast = NewStringEmpty(); Swig_scopename_split(name, &nprefix, &nlast); rn = name_object_get(namehash, nlast, decl, ncdecl); Delete(nlast); Delete(nprefix); } Delete(tname); #ifdef SWIG_DEBUG Printf(stdout, "Swig_name_object_get: found %d\n", rn ? 1 : 0); #endif return rn; } /* ----------------------------------------------------------------------------- * Swig_name_object_inherit() * * Implements name-based inheritance scheme. * ----------------------------------------------------------------------------- */ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) { Iterator ki; Hash *derh; String *bprefix; String *dprefix; char *cbprefix; int plen; if (!namehash) return; /* Temporary hash holding all the entries we add while we iterate over namehash itself as we can't modify the latter while iterating over it. */ derh = NULL; bprefix = NewStringf("%s::", base); dprefix = NewStringf("%s::", derived); cbprefix = Char(bprefix); plen = strlen(cbprefix); for (ki = First(namehash); ki.key; ki = Next(ki)) { char *k = Char(ki.key); if (strncmp(k, cbprefix, plen) == 0) { /* Copy, adjusting name, this element to the derived hash. */ Iterator oi; String *nkey = NewStringf("%s%s", dprefix, k + plen); Hash *n = ki.item; Hash *newh; /* Don't overwrite an existing value for the derived class, if any. */ newh = Getattr(namehash, nkey); if (!newh) { if (!derh) derh = NewHash(); newh = NewHash(); Setattr(derh, nkey, newh); Delete(newh); } for (oi = First(n); oi.key; oi = Next(oi)) { if (!Getattr(newh, oi.key)) { String *ci = Copy(oi.item); Setattr(newh, oi.key, ci); Delete(ci); } } Delete(nkey); } } /* Merge the contents of derived hash into the main hash. */ if (derh) { for (ki = First(derh); ki.key; ki = Next(ki)) { Setattr(namehash, ki.key, ki.item); } } Delete(bprefix); Delete(dprefix); Delete(derh); } /* ----------------------------------------------------------------------------- * merge_features() * * Given a hash, this function merges the features in the hash into the node. * ----------------------------------------------------------------------------- */ static void merge_features(Hash *features, Node *n) { Iterator ki; if (!features) return; for (ki = First(features); ki.key; ki = Next(ki)) { String *ci = Copy(ki.item); Setattr(n, ki.key, ci); Delete(ci); } } /* ----------------------------------------------------------------------------- * Swig_features_get() * * Attaches any features in the features hash to the node that matches * the declaration, decl. * ----------------------------------------------------------------------------- */ static void features_get(Hash *features, const String *tname, SwigType *decl, SwigType *ncdecl, Node *node) { Node *n = Getattr(features, tname); #ifdef SWIG_DEBUG Printf(stdout, " features_get: %s\n", tname); #endif if (n) { merge_features(get_object(n, 0), node); if (ncdecl) merge_features(get_object(n, ncdecl), node); merge_features(get_object(n, decl), node); } } void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl, Node *node) { char *ncdecl = 0; String *rdecl = 0; String *rname = 0; if (!features) return; /* MM: This removed to more tightly control feature/name matching */ /* if ((decl) && (SwigType_isqualifier(decl))) { ncdecl = strchr(Char(decl),'.'); ncdecl++; } */ /* very specific hack for template constructors/destructors */ if (name && SwigType_istemplate(name)) { String *nodetype = nodeType(node); if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) { String *nprefix = NewStringEmpty(); String *nlast = NewStringEmpty(); String *tprefix; Swig_scopename_split(name, &nprefix, &nlast); tprefix = SwigType_templateprefix(nlast); Delete(nlast); if (Len(nprefix)) { Append(nprefix, "::"); Append(nprefix, tprefix); Delete(tprefix); rname = nprefix; } else { rname = tprefix; Delete(nprefix); } rdecl = Copy(decl); Replaceall(rdecl, name, rname); decl = rdecl; name = rname; } } #ifdef SWIG_DEBUG Printf(stdout, "Swig_features_get: '%s' '%s' '%s'\n", prefix, name, decl); #endif /* Global features */ features_get(features, "", 0, 0, node); if (name) { String *tname = NewStringEmpty(); /* add features for 'root' template */ String *dname = SwigType_istemplate_templateprefix(name); if (dname) { features_get(features, dname, decl, ncdecl, node); } /* Catch-all */ features_get(features, name, decl, ncdecl, node); /* Perform a class-based lookup (if class prefix supplied) */ if (prefix) { /* A class-generic feature */ if (Len(prefix)) { Printf(tname, "%s::", prefix); features_get(features, tname, decl, ncdecl, node); } /* A wildcard-based class lookup */ Clear(tname); Printf(tname, "*::%s", name); features_get(features, tname, decl, ncdecl, node); /* A specific class lookup */ if (Len(prefix)) { /* A template-based class lookup */ String *tprefix = SwigType_istemplate_templateprefix(prefix); if (tprefix) { Clear(tname); Printf(tname, "%s::%s", tprefix, name); features_get(features, tname, decl, ncdecl, node); } Clear(tname); Printf(tname, "%s::%s", prefix, name); features_get(features, tname, decl, ncdecl, node); Delete(tprefix); } } else { /* Lookup in the global namespace only */ Clear(tname); Printf(tname, "::%s", name); features_get(features, tname, decl, ncdecl, node); } Delete(tname); Delete(dname); } if (name && SwigType_istemplate(name)) { /* add features for complete template type */ String *dname = Swig_symbol_template_deftype(name, 0); if (!Equal(dname, name)) { Swig_features_get(features, prefix, dname, decl, node); } Delete(dname); } if (rname) Delete(rname); if (rdecl) Delete(rdecl); } /* ----------------------------------------------------------------------------- * Swig_feature_set() * * Sets a feature name and value. Also sets optional feature attributes as * passed in by featureattribs. Optional feature attributes are given a full name * concatenating the feature name plus ':' plus the attribute name. * ----------------------------------------------------------------------------- */ void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, const_String_or_char_ptr value, Hash *featureattribs) { Hash *n; Hash *fhash; #ifdef SWIG_DEBUG Printf(stdout, "Swig_feature_set: '%s' '%s' '%s' '%s'\n", name, decl, featurename, value); #endif n = Getattr(features, name); if (!n) { n = NewHash(); Setattr(features, name, n); Delete(n); } if (!decl) { fhash = Getattr(n, "start"); if (!fhash) { fhash = NewHash(); Setattr(n, "start", fhash); Delete(fhash); } } else { fhash = Getattr(n, decl); if (!fhash) { String *cdecl_ = Copy(decl); fhash = NewHash(); Setattr(n, cdecl_, fhash); Delete(cdecl_); Delete(fhash); } } if (value) { Setattr(fhash, featurename, value); } else { Delattr(fhash, featurename); } { /* Add in the optional feature attributes */ Hash *attribs = featureattribs; while (attribs) { String *attribname = Getattr(attribs, "name"); String *featureattribname = NewStringf("%s:%s", featurename, attribname); if (value) { String *attribvalue = Getattr(attribs, "value"); Setattr(fhash, featureattribname, attribvalue); } else { Delattr(fhash, featureattribname); } attribs = nextSibling(attribs); Delete(featureattribname); } } if (name && SwigType_istemplate(name)) { String *dname = Swig_symbol_template_deftype(name, 0); if (Strcmp(dname, name)) { Swig_feature_set(features, dname, decl, featurename, value, featureattribs); } Delete(dname); } } /* ----------------------------------------------------------------------------- * The rename/namewarn engine * * Code below was in parser.y for a while * ----------------------------------------------------------------------------- */ static Hash *namewarn_hash = 0; Hash *Swig_name_namewarn_hash() { if (!namewarn_hash) namewarn_hash = NewHash(); return namewarn_hash; } static Hash *rename_hash = 0; Hash *Swig_name_rename_hash() { if (!rename_hash) rename_hash = NewHash(); return rename_hash; } static List *namewarn_list = 0; List *Swig_name_namewarn_list() { if (!namewarn_list) namewarn_list = NewList(); return namewarn_list; } static List *rename_list = 0; List *Swig_name_rename_list() { if (!rename_list) rename_list = NewList(); return rename_list; } /* ----------------------------------------------------------------------------- * int Swig_need_name_warning(Node *n) * * Detects if a node needs name warnings * * ----------------------------------------------------------------------------- */ int Swig_need_name_warning(Node *n) { int need = 1; /* We don't use name warnings for: - class forwards, no symbol is generated at the target language. - template declarations, only for real instances using %template(name). - typedefs, have no effect at the target language. - using declarations and using directives, have no effect at the target language. */ if (checkAttribute(n, "nodeType", "classforward")) { need = 0; } else if (checkAttribute(n, "nodeType", "using")) { need = 0; } else if (checkAttribute(n, "storage", "typedef")) { need = 0; } else if (Getattr(n, "hidden")) { need = 0; } else if (Getattr(n, "ignore")) { need = 0; } else if (Getattr(n, "templatetype")) { need = 0; } return need; } /* ----------------------------------------------------------------------------- * int Swig_need_redefined_warn() * * Detects when a redefined object needs a warning * * ----------------------------------------------------------------------------- */ static int nodes_are_equivalent(Node *a, Node *b, int a_inclass) { /* they must have the same type */ String *ta = nodeType(a); String *tb = nodeType(b); if (!Equal(ta, tb)) { if (!(Equal(ta, "using") && Equal(tb, "cdecl"))) { return 0; } } if (Cmp(ta, "cdecl") == 0) { /* both cdecl case */ /* typedef */ String *a_storage = Getattr(a, "storage"); String *b_storage = Getattr(b, "storage"); if ((Cmp(a_storage, "typedef") == 0) || (Cmp(b_storage, "typedef") == 0)) { if (Cmp(a_storage, b_storage) == 0) { String *a_type = (Getattr(a, "type")); String *b_type = (Getattr(b, "type")); if (Cmp(a_type, b_type) == 0) return 1; } return 0; } /* static functions */ if (Swig_storage_isstatic(a) || Swig_storage_isstatic(b)) { if (Cmp(a_storage, b_storage) != 0) return 0; } /* friend methods */ if (!a_inclass || (Cmp(a_storage, "friend") == 0)) { /* check declaration */ String *a_decl = (Getattr(a, "decl")); String *b_decl = (Getattr(b, "decl")); if (Cmp(a_decl, b_decl) == 0) { /* check return type */ String *a_type = (Getattr(a, "type")); String *b_type = (Getattr(b, "type")); if (Cmp(a_type, b_type) == 0) { /* check parameters */ Parm *ap = (Getattr(a, "parms")); Parm *bp = (Getattr(b, "parms")); while (ap && bp) { SwigType *at = Getattr(ap, "type"); SwigType *bt = Getattr(bp, "type"); if (Cmp(at, bt) != 0) return 0; ap = nextSibling(ap); bp = nextSibling(bp); } if (ap || bp) { return 0; } else { Node *a_template = Getattr(a, "template"); Node *b_template = Getattr(b, "template"); /* Not equivalent if one is a template instantiation (via %template) and the other is a non-templated function */ if ((a_template && !b_template) || (!a_template && b_template)) return 0; } return 1; } } } } else if (Equal(ta, "using")) { /* using and cdecl case */ String *b_storage = Getattr(b, "storage"); if (Equal(b_storage, "typedef")) { String *a_name = Getattr(a, "name"); String *b_name = Getattr(b, "name"); if (Equal(a_name, b_name)) return 1; } } else { /* both %constant case */ String *a_storage = Getattr(a, "storage"); String *b_storage = Getattr(b, "storage"); if ((Cmp(a_storage, "%constant") == 0) || (Cmp(b_storage, "%constant") == 0)) { if (Cmp(a_storage, b_storage) == 0) { String *a_type = (Getattr(a, "type")); String *b_type = (Getattr(b, "type")); if ((Cmp(a_type, b_type) == 0) && (Cmp(Getattr(a, "value"), Getattr(b, "value")) == 0)) return 1; } return 0; } } return 0; } int Swig_need_redefined_warn(Node *a, Node *b, int InClass) { String *a_name = Getattr(a, "name"); String *b_name = Getattr(b, "name"); String *a_symname = Getattr(a, "sym:name"); String *b_symname = Getattr(b, "sym:name"); /* always send a warning if a 'rename' is involved */ if ((a_symname && !Equal(a_symname, a_name)) || (b_symname && !Equal(b_symname, b_name))) { if (!Equal(a_name, b_name)) { return 1; } } return !nodes_are_equivalent(a, b, InClass); } /* ----------------------------------------------------------------------------- * int Swig_need_protected(Node* n) * * Detects when we need to fully register the protected member. * This is basically any protected members when the allprotected mode is set. * Otherwise we take just the protected virtual methods and non-static methods * (potentially virtual methods) as well as constructors/destructors. * Also any "using" statements in a class may potentially be virtual. * ----------------------------------------------------------------------------- */ int Swig_need_protected(Node *n) { String *nodetype = nodeType(n); if (checkAttribute(n, "access", "protected")) { if ((Equal(nodetype, "cdecl"))) { if (Swig_director_mode() && Swig_director_protected_mode() && Swig_all_protected_mode()) { return 1; } if (SwigType_isfunction(Getattr(n, "decl"))) { String *storage = Getattr(n, "storage"); /* The function is declared virtual, or it has no storage. This eliminates typedef, static etc. */ return !storage || Equal(storage, "virtual"); } } else if (Equal(nodetype, "constructor") || Equal(nodetype, "destructor")) { return 1; } else if (Equal(nodetype, "using") && !Getattr(n, "namespace")) { return 1; } } return 0; } /* ----------------------------------------------------------------------------- * void Swig_name_nameobj_add() * * Add nameobj (rename/namewarn) * * ----------------------------------------------------------------------------- */ static List *Swig_make_attrlist(const char *ckey) { List *list = NewList(); const char *cattr = strchr(ckey, '$'); if (cattr) { String *nattr; const char *rattr = strchr(++cattr, '$'); while (rattr) { nattr = NewStringWithSize(cattr, rattr - cattr); Append(list, nattr); Delete(nattr); cattr = rattr + 1; rattr = strchr(cattr, '$'); } nattr = NewString(cattr); Append(list, nattr); Delete(nattr); } else { Append(list, "nodeType"); } return list; } static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) { Node *kw = nextSibling(nameobj); List *matchlist = 0; while (kw) { Node *next = nextSibling(kw); String *kname = Getattr(kw, "name"); char *ckey = kname ? Char(kname) : 0; if (ckey) { const char **rkey; int isnotmatch = 0; int isregexmatch = 0; if ((strncmp(ckey, "match", 5) == 0) || (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0)) || (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0)) || (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) { Hash *mi = NewHash(); List *attrlist = Swig_make_attrlist(ckey); if (!matchlist) matchlist = NewList(); Setattr(mi, "value", Getattr(kw, "value")); Setattr(mi, "attrlist", attrlist); if (isnotmatch) SetFlag(mi, "notmatch"); if (isregexmatch) SetFlag(mi, "regexmatch"); Delete(attrlist); Append(matchlist, mi); Delete(mi); removeNode(kw); } else { for (rkey = keys; *rkey != 0; ++rkey) { if (strcmp(ckey, *rkey) == 0) { Setattr(nameobj, *rkey, Getattr(kw, "value")); removeNode(kw); } } } } kw = next; } if (matchlist) { Setattr(nameobj, "matchlist", matchlist); Delete(matchlist); } } void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, String *name, SwigType *decl, Hash *nameobj) { String *nname = 0; if (name && Len(name)) { String *target_fmt = Getattr(nameobj, "targetfmt"); nname = prefix ? NewStringf("%s::%s", prefix, name) : NewString(name); if (target_fmt) { String *tmp = NewStringf(target_fmt, nname); Delete(nname); nname = tmp; } } if (!nname || !Len(nname) || Getattr(nameobj, "fullname") || /* any of these options trigger a 'list' nameobj */ Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist") || Getattr(nameobj, "regextarget")) { if (decl) Setattr(nameobj, "decl", decl); if (nname && Len(nname)) Setattr(nameobj, "targetname", nname); /* put the new nameobj at the beginnig of the list, such that the last inserted rule take precedence */ Insert(name_list, 0, nameobj); } else { /* here we add an old 'hash' nameobj, simple and fast */ Swig_name_object_set(name_hash, nname, decl, nameobj); } Delete(nname); } /* ----------------------------------------------------------------------------- * int Swig_name_match_nameobj() * * Apply and check the nameobj's math list to the node * * ----------------------------------------------------------------------------- */ static DOH *Swig_get_lattr(Node *n, List *lattr) { DOH *res = 0; int ilen = Len(lattr); int i; for (i = 0; n && (i < ilen); ++i) { String *nattr = Getitem(lattr, i); res = Getattr(n, nattr); #ifdef SWIG_DEBUG if (!res) { Printf(stdout, "missing %s %s %s\n", nattr, Getattr(n, "name"), Getattr(n, "member")); } else { Printf(stdout, "lattr %d %s %s\n", i, nattr, DohIsString(res) ? res : Getattr(res, "name")); } #endif n = res; } return res; } #ifdef HAVE_PCRE #include int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) { pcre *compiled_pat; const char *err; int errpos; int rc; compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL); if (!compiled_pat) { Swig_error("SWIG", Getline(n), "Invalid regex \"%s\": compilation failed at %d: %s\n", Char(pattern), errpos, err); exit(1); } rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0); pcre_free(compiled_pat); if (rc == PCRE_ERROR_NOMATCH) return 0; if (rc < 0 ) { Swig_error("SWIG", Getline(n), "Matching \"%s\" against regex \"%s\" failed: %d\n", Char(s), Char(pattern), rc); exit(1); } return 1; } #else /* !HAVE_PCRE */ int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) { (void)pattern; (void)s; Swig_error("SWIG", Getline(n), "PCRE regex matching is not available in this SWIG build.\n"); exit(1); } #endif /* HAVE_PCRE/!HAVE_PCRE */ int Swig_name_match_value(String *mvalue, String *value) { #if defined(SWIG_USE_SIMPLE_MATCHOR) int match = 0; char *cvalue = Char(value); char *cmvalue = Char(mvalue); char *sep = strchr(cmvalue, '|'); while (sep && !match) { match = strncmp(cvalue, cmvalue, sep - cmvalue) == 0; #ifdef SWIG_DEBUG Printf(stdout, "match_value: %s %s %d\n", cvalue, cmvalue, match); #endif cmvalue = sep + 1; sep = strchr(cmvalue, '|'); } if (!match) { match = strcmp(cvalue, cmvalue) == 0; #ifdef SWIG_DEBUG Printf(stdout, "match_value: %s %s %d\n", cvalue, cmvalue, match); #endif } return match; #else return Equal(mvalue, value); #endif } int Swig_name_match_nameobj(Hash *rn, Node *n) { int match = 1; List *matchlist = Getattr(rn, "matchlist"); #ifdef SWIG_DEBUG Printf(stdout, "Swig_name_match_nameobj: %s\n", Getattr(n, "name")); #endif if (matchlist) { int ilen = Len(matchlist); int i; for (i = 0; match && (i < ilen); ++i) { Node *mi = Getitem(matchlist, i); List *lattr = Getattr(mi, "attrlist"); String *nval = Swig_get_lattr(n, lattr); int notmatch = GetFlag(mi, "notmatch"); int regexmatch = GetFlag(mi, "regexmatch"); match = 0; if (nval) { String *kwval = Getattr(mi, "value"); match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval) : Swig_name_match_value(kwval, nval); #ifdef SWIG_DEBUG Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen); #endif } if (notmatch) match = !match; } } #ifdef SWIG_DEBUG Printf(stdout, "Swig_name_match_nameobj: %d\n", match); #endif return match; } /* ----------------------------------------------------------------------------- * Hash *Swig_name_nameobj_lget() * * Get a nameobj (rename/namewarn) from the list of filters * * ----------------------------------------------------------------------------- */ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *name, String *decl) { Hash *res = 0; if (namelist) { int len = Len(namelist); int i; int match = 0; for (i = 0; !match && (i < len); i++) { Hash *rn = Getitem(namelist, i); String *rdecl = Getattr(rn, "decl"); if (rdecl && (!decl || !Equal(rdecl, decl))) { continue; } else if (Swig_name_match_nameobj(rn, n)) { String *tname = Getattr(rn, "targetname"); if (tname) { String *sfmt = Getattr(rn, "sourcefmt"); String *sname = 0; int fullname = GetFlag(rn, "fullname"); int regextarget = GetFlag(rn, "regextarget"); if (sfmt) { if (fullname && prefix) { String *pname = NewStringf("%s::%s", prefix, name); sname = NewStringf(sfmt, pname); Delete(pname); } else { sname = NewStringf(sfmt, name); } } else { if (fullname && prefix) { sname = NewStringf("%s::%s", prefix, name); } else { sname = name; DohIncref(name); } } match = regextarget ? Swig_name_regexmatch_value(n, tname, sname) : Swig_name_match_value(tname, sname); Delete(sname); } else { /* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */ String *sname = NewStringf(Getattr(rn, "name"), name); if (sname) { if (Len(sname)) match = 1; Delete(sname); } } } if (match) { res = rn; break; } } } return res; } /* ----------------------------------------------------------------------------- * Swig_name_namewarn_add * * Add a namewarn objects * * ----------------------------------------------------------------------------- */ void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn) { const char *namewrn_keys[] = { "rename", "error", "fullname", "sourcefmt", "targetfmt", 0 }; Swig_name_object_attach_keys(namewrn_keys, namewrn); Swig_name_nameobj_add(Swig_name_namewarn_hash(), Swig_name_namewarn_list(), prefix, name, decl, namewrn); } /* ----------------------------------------------------------------------------- * Hash *Swig_name_namewarn_get() * * Return the namewarn object, if there is one. * * ----------------------------------------------------------------------------- */ Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl) { if (!namewarn_hash && !namewarn_list) return 0; if (n) { /* Return in the obvious cases */ if (!name || !Swig_need_name_warning(n)) { return 0; } else { String *access = Getattr(n, "access"); int is_public = !access || Equal(access, "public"); if (!is_public && !Swig_need_protected(n)) { return 0; } } } if (name) { /* Check to see if the name is in the hash */ Hash *wrn = Swig_name_object_get(Swig_name_namewarn_hash(), prefix, name, decl); if (wrn && !Swig_name_match_nameobj(wrn, n)) wrn = 0; if (!wrn) { wrn = Swig_name_nameobj_lget(Swig_name_namewarn_list(), n, prefix, name, decl); } if (wrn && Getattr(wrn, "error")) { if (n) { Swig_error(Getfile(n), Getline(n), "%s\n", Getattr(wrn, "name")); } else { Swig_error(cparse_file, cparse_line, "%s\n", Getattr(wrn, "name")); } } return wrn; } else { return 0; } } /* ----------------------------------------------------------------------------- * String *Swig_name_warning() * * Return the name warning, if there is one. * * ----------------------------------------------------------------------------- */ String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl) { Hash *wrn = Swig_name_namewarn_get(n, prefix, name, decl); return (name && wrn) ? Getattr(wrn, "name") : 0; } /* ----------------------------------------------------------------------------- * Swig_name_rename_add() * * Manage the rename objects * * ----------------------------------------------------------------------------- */ static void single_rename_add(String *prefix, String *name, SwigType *decl, Hash *newname) { Swig_name_nameobj_add(Swig_name_rename_hash(), Swig_name_rename_list(), prefix, name, decl, newname); } /* Add a new rename. Works much like new_feature including default argument handling. */ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *newname, ParmList *declaratorparms) { ParmList *declparms = declaratorparms; const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 }; Swig_name_object_attach_keys(rename_keys, newname); /* Add the name */ single_rename_add(prefix, name, decl, newname); /* Add extra names if there are default parameters in the parameter list */ if (decl) { int constqualifier = SwigType_isconst(decl); while (declparms) { if (ParmList_has_defaultargs(declparms)) { /* Create a parameter list for the new rename by copying all but the last (defaulted) parameter */ ParmList *newparms = CopyParmListMax(declparms,ParmList_len(declparms)-1); /* Create new declaration - with the last parameter removed */ SwigType *newdecl = Copy(decl); Delete(SwigType_pop_function(newdecl)); /* remove the old parameter list from newdecl */ SwigType_add_function(newdecl, newparms); if (constqualifier) SwigType_add_qualifier(newdecl, "const"); single_rename_add(prefix, name, newdecl, newname); declparms = newparms; Delete(newdecl); } else { declparms = 0; } } } } /* Create a name applying rename/namewarn if needed */ static String *apply_rename(String *newname, int fullname, String *prefix, String *name) { String *result = 0; if (newname && Len(newname)) { if (Strcmp(newname, "$ignore") == 0) { result = Copy(newname); } else { char *cnewname = Char(newname); if (cnewname) { int destructor = name && (*(Char(name)) == '~'); String *fmt = newname; /* use name as a fmt, but avoid C++ "%" and "%=" operators */ if (Len(newname) > 1 && strchr(cnewname, '%') && !(strcmp(cnewname, "%=") == 0)) { if (fullname && prefix) { result = NewStringf(fmt, prefix, name); } else { result = NewStringf(fmt, name); } } else { result = Copy(newname); } if (destructor && result && (*(Char(result)) != '~')) { Insert(result, 0, "~"); } } } } return result; } /* ----------------------------------------------------------------------------- * String *Swig_name_make() * * Make a name after applying all the rename/namewarn objects * * ----------------------------------------------------------------------------- */ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname) { String *nname = 0; String *result = 0; String *name = NewString(cname); Hash *wrn = 0; String *rdecl = 0; String *rname = 0; /* very specific hack for template constructors/destructors */ #ifdef SWIG_DEBUG Printf(stdout, "Swig_name_make: looking for %s %s %s %s\n", prefix, name, decl, oldname); #endif if (name && n && SwigType_istemplate(name)) { String *nodetype = nodeType(n); if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) { String *nprefix = NewStringEmpty(); String *nlast = NewStringEmpty(); String *tprefix; Swig_scopename_split(name, &nprefix, &nlast); tprefix = SwigType_templateprefix(nlast); Delete(nlast); if (Len(nprefix)) { Append(nprefix, "::"); Append(nprefix, tprefix); Delete(tprefix); rname = nprefix; } else { rname = tprefix; Delete(nprefix); } rdecl = Copy(decl); Replaceall(rdecl, name, rname); #ifdef SWIG_DEBUG Printf(stdout, "SWIG_name_make: use new name %s %s : %s %s\n", name, decl, rname, rdecl); #endif decl = rdecl; Delete(name); name = rname; } } if (rename_hash || rename_list || namewarn_hash || namewarn_list) { Hash *rn = Swig_name_object_get(Swig_name_rename_hash(), prefix, name, decl); if (!rn || !Swig_name_match_nameobj(rn, n)) { rn = Swig_name_nameobj_lget(Swig_name_rename_list(), n, prefix, name, decl); if (rn) { String *sfmt = Getattr(rn, "sourcefmt"); int fullname = GetFlag(rn, "fullname"); if (fullname && prefix) { String *sname = NewStringf("%s::%s", prefix, name); Delete(name); name = sname; prefix = 0; } if (sfmt) { String *sname = NewStringf(sfmt, name); Delete(name); name = sname; } } } if (rn) { String *newname = Getattr(rn, "name"); int fullname = GetFlag(rn, "fullname"); result = apply_rename(newname, fullname, prefix, name); } if (result && !Equal(result, name)) { /* operators in C++ allow aliases, we look for them */ char *cresult = Char(result); if (cresult && (strncmp(cresult, "operator ", 9) == 0)) { String *nresult = Swig_name_make(n, prefix, result, decl, oldname); if (!Equal(nresult, result)) { Delete(result); result = nresult; } else { Delete(nresult); } } } nname = result ? result : name; wrn = Swig_name_namewarn_get(n, prefix, nname, decl); if (wrn) { String *rename = Getattr(wrn, "rename"); if (rename) { String *msg = Getattr(wrn, "name"); int fullname = GetFlag(wrn, "fullname"); if (result) Delete(result); result = apply_rename(rename, fullname, prefix, name); if ((msg) && (Len(msg))) { if (!Getmeta(nname, "already_warned")) { if (n) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(0, Getfile(n), Getline(n), "%s\n", msg); SWIG_WARN_NODE_END(n); } else { Swig_warning(0, Getfile(name), Getline(name), "%s\n", msg); } Setmeta(nname, "already_warned", "1"); } } } } } if (!result || !Len(result)) { if (result) Delete(result); if (oldname) { result = NewString(oldname); } else { result = NewString(cname); } } Delete(name); #ifdef SWIG_DEBUG Printf(stdout, "Swig_name_make: result '%s' '%s'\n", cname, result); #endif return result; } /* ----------------------------------------------------------------------------- * void Swig_name_inherit() * * Inherit namewarn,rename, and feature objects * * ----------------------------------------------------------------------------- */ void Swig_name_inherit(String *base, String *derived) { /* Printf(stdout,"base = '%s', derived = '%s'\n", base, derived); */ Swig_name_object_inherit(Swig_name_rename_hash(), base, derived); Swig_name_object_inherit(Swig_name_namewarn_hash(), base, derived); Swig_name_object_inherit(Swig_cparse_features(), base, derived); } /* ----------------------------------------------------------------------------- * Swig_inherit_base_symbols() * ----------------------------------------------------------------------------- */ void Swig_inherit_base_symbols(List *bases) { if (bases) { Iterator s; for (s = First(bases); s.item; s = Next(s)) { Symtab *st = Getattr(s.item, "symtab"); if (st) { Setfile(st, Getfile(s.item)); Setline(st, Getline(s.item)); Swig_symbol_inherit(st); } } Delete(bases); } } /* ----------------------------------------------------------------------------- * Swig_make_inherit_list() * ----------------------------------------------------------------------------- */ List *Swig_make_inherit_list(String *clsname, List *names, String *Namespaceprefix) { int i, ilen; String *derived; List *bases = NewList(); if (Namespaceprefix) derived = NewStringf("%s::%s", Namespaceprefix, clsname); else derived = NewString(clsname); ilen = Len(names); for (i = 0; i < ilen; i++) { String *base; String *n = Getitem(names, i); /* Try to figure out where this symbol is */ Node *s = Swig_symbol_clookup(n, 0); if (s) { while (s && (Strcmp(nodeType(s), "class") != 0)) { /* Not a class. Could be a typedef though. */ String *storage = Getattr(s, "storage"); if (storage && (Strcmp(storage, "typedef") == 0)) { String *nn = Getattr(s, "type"); s = Swig_symbol_clookup(nn, Getattr(s, "sym:symtab")); } else { break; } } if (s && ((Strcmp(nodeType(s), "class") == 0) || (Strcmp(nodeType(s), "template") == 0))) { String *q = Swig_symbol_qualified(s); Append(bases, s); if (q) { base = NewStringf("%s::%s", q, Getattr(s, "name")); Delete(q); } else { base = NewString(Getattr(s, "name")); } } else { base = NewString(n); } } else { base = NewString(n); } if (base) { Swig_name_inherit(base, derived); Delete(base); } } return bases; } /* ----------------------------------------------------------------------------- * void Swig_name_str() * * Return a stringified version of a C/C++ symbol from a node. * The node passed in is expected to be a function, constructor, destructor or * variable. Some example return values: * "MyNameSpace::MyTemplate::~MyTemplate" * "MyNameSpace::ABC::ABC" * "MyNameSpace::ABC::constmethod" * "MyNameSpace::ABC::variablename" * * ----------------------------------------------------------------------------- */ String *Swig_name_str(Node *n) { String *qname; String *qualifier = Swig_symbol_qualified(n); String *name = Swig_scopename_last(Getattr(n, "name")); if (qualifier) qualifier = SwigType_namestr(qualifier); /* Very specific hack for template constructors/destructors */ if (SwigType_istemplate(name)) { String *nodetype = nodeType(n); if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) { String *nprefix = NewStringEmpty(); String *nlast = NewStringEmpty(); String *tprefix; Swig_scopename_split(name, &nprefix, &nlast); tprefix = SwigType_templateprefix(nlast); Delete(nlast); Delete(name); name = tprefix; } } qname = NewString(""); if (qualifier && Len(qualifier) > 0) Printf(qname, "%s::", qualifier); Printf(qname, "%s", SwigType_str(name, 0)); Delete(name); Delete(qualifier); return qname; } /* ----------------------------------------------------------------------------- * void Swig_name_decl() * * Return a stringified version of a C/C++ declaration without the return type. * The node passed in is expected to be a function, constructor, destructor or * variable. Some example return values: * "MyNameSpace::MyTemplate::~MyTemplate()" * "MyNameSpace::ABC::ABC(int,double)" * "MyNameSpace::ABC::constmethod(int) const" * "MyNameSpace::ABC::variablename" * * ----------------------------------------------------------------------------- */ String *Swig_name_decl(Node *n) { String *qname; String *decl; qname = Swig_name_str(n); if (checkAttribute(n, "kind", "variable")) decl = NewStringf("%s", qname); else decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : ""); Delete(qname); return decl; } /* ----------------------------------------------------------------------------- * void Swig_name_fulldecl() * * Return a stringified version of a C/C++ declaration including the return type. * The node passed in is expected to be a function, constructor or destructor. * Some example return values: * "MyNameSpace::MyTemplate::~MyTemplate()" * "MyNameSpace::ABC::ABC(int,double)" * "int * MyNameSpace::ABC::constmethod(int) const" * * ----------------------------------------------------------------------------- */ String *Swig_name_fulldecl(Node *n) { String *decl = Swig_name_decl(n); String *type = Getattr(n, "type"); String *nodetype = nodeType(n); String *fulldecl; /* add on the return type */ if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) { fulldecl = decl; } else { String *t = SwigType_str(type, 0); fulldecl = NewStringf("%s %s", t, decl); Delete(decl); Delete(t); } return fulldecl; } swig-3.0.2/Source/Swig/error.c0000664000175000017500000002346712343605122016025 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * error.c * * Error handling functions. These are used to issue warnings and * error messages. * ----------------------------------------------------------------------------- */ #include "swig.h" #include #include /* ----------------------------------------------------------------------------- * Commentary on the warning filter. * * The warning filter is a string of numbers prefaced by (-) or (+) to * indicate whether or not a warning message is displayed. For example: * * "-304-201-140+210+201" * * The filter string is scanned left to right and the first occurrence * of a warning number is used to determine printing behavior. * * The same number may appear more than once in the string. For example, in the * above string, "201" appears twice. This simply means that warning 201 * was disabled after it was previously enabled. This may only be temporary * setting--the first number may be removed later in which case the warning * is reenabled. * ----------------------------------------------------------------------------- */ #if defined(_WIN32) # define DEFAULT_ERROR_MSG_FORMAT EMF_MICROSOFT #else # define DEFAULT_ERROR_MSG_FORMAT EMF_STANDARD #endif static ErrorMessageFormat msg_format = DEFAULT_ERROR_MSG_FORMAT; static int silence = 0; /* Silent operation */ static String *filter = 0; /* Warning filter */ static int warnall = 0; static int nwarning = 0; static int nerrors = 0; static int init_fmt = 0; static char wrn_wnum_fmt[64]; static char wrn_nnum_fmt[64]; static char err_line_fmt[64]; static char err_eof_fmt[64]; static char diag_line_fmt[64]; static char diag_eof_fmt[64]; static String *format_filename(const_String_or_char_ptr filename); /* ----------------------------------------------------------------------------- * Swig_warning() * * Issue a warning message on stderr. * ----------------------------------------------------------------------------- */ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const char *fmt, ...) { String *out; char *msg; int wrn = 1; va_list ap; if (silence) return; if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT); va_start(ap, fmt); out = NewStringEmpty(); vPrintf(out, fmt, ap); msg = Char(out); if (isdigit((unsigned char) *msg)) { unsigned long result = strtoul(msg, &msg, 10); if (msg != Char(out)) { msg++; wnum = result; } } /* Check in the warning filter */ if (filter) { char temp[32]; char *c; char *f = Char(filter); sprintf(temp, "%d", wnum); while (*f != '\0' && (c = strstr(f, temp))) { if (*(c - 1) == '-') { wrn = 0; /* Warning disabled */ break; } if (*(c - 1) == '+') { wrn = 1; /* Warning enabled */ break; } f += strlen(temp); } } if (warnall || wrn) { String *formatted_filename = format_filename(filename); if (wnum) { Printf(stderr, wrn_wnum_fmt, formatted_filename, line, wnum); } else { Printf(stderr, wrn_nnum_fmt, formatted_filename, line); } Printf(stderr, "%s", msg); nwarning++; Delete(formatted_filename); } Delete(out); va_end(ap); } /* ----------------------------------------------------------------------------- * Swig_error() * * Issue an error message on stderr. * ----------------------------------------------------------------------------- */ void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...) { va_list ap; String *formatted_filename = NULL; if (silence) return; if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT); va_start(ap, fmt); formatted_filename = format_filename(filename); if (line > 0) { Printf(stderr, err_line_fmt, formatted_filename, line); } else { Printf(stderr, err_eof_fmt, formatted_filename); } vPrintf(stderr, fmt, ap); va_end(ap); nerrors++; Delete(formatted_filename); } /* ----------------------------------------------------------------------------- * Swig_error_count() * * Returns number of errors received. * ----------------------------------------------------------------------------- */ int Swig_error_count(void) { return nerrors; } /* ----------------------------------------------------------------------------- * Swig_error_silent() * * Set silent flag * ----------------------------------------------------------------------------- */ void Swig_error_silent(int s) { silence = s; } /* ----------------------------------------------------------------------------- * Swig_warnfilter() * * Takes a comma separate list of warning numbers and puts in the filter. * ----------------------------------------------------------------------------- */ void Swig_warnfilter(const_String_or_char_ptr wlist, int add) { char *c; char *cw; String *s; if (!filter) filter = NewStringEmpty(); s = NewString(""); Clear(s); cw = Char(wlist); while (*cw != '\0') { if (*cw != ' ') { Putc(*cw, s); } ++cw; } c = Char(s); c = strtok(c, ", "); while (c) { if (isdigit((int) *c) || (*c == '+') || (*c == '-')) { /* Even if c is a digit, the rest of the string might not be, eg in the case of typemap * warnings (a bit odd really), eg: %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) */ if (add) { Insert(filter, 0, c); if (isdigit((int) *c)) { Insert(filter, 0, "-"); } } else { char *temp = (char *)malloc(sizeof(char)*strlen(c) + 2); if (isdigit((int) *c)) { sprintf(temp, "-%s", c); } else { strcpy(temp, c); } Replace(filter, temp, "", DOH_REPLACE_FIRST); free(temp); } } c = strtok(NULL, ", "); } Delete(s); } void Swig_warnall(void) { warnall = 1; } /* ----------------------------------------------------------------------------- * Swig_warn_count() * * Return the number of warnings * ----------------------------------------------------------------------------- */ int Swig_warn_count(void) { return nwarning; } /* ----------------------------------------------------------------------------- * Swig_error_msg_format() * * Set the type of error/warning message display * ----------------------------------------------------------------------------- */ void Swig_error_msg_format(ErrorMessageFormat format) { const char *error = "Error"; const char *warning = "Warning"; const char *fmt_eof = 0; const char *fmt_line = 0; /* here 'format' could be directly a string instead of an enum, but by now a switch is used to translated into one. */ switch (format) { case EMF_MICROSOFT: fmt_line = "%s(%d) "; fmt_eof = "%s(999999) "; /* Is there a special character for EOF? Just use a large number. */ break; case EMF_STANDARD: default: fmt_line = "%s:%d"; fmt_eof = "%s:EOF"; } sprintf(wrn_wnum_fmt, "%s: %s %%d: ", fmt_line, warning); sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning); sprintf(err_line_fmt, "%s: %s: ", fmt_line, error); sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error); sprintf(diag_line_fmt, "%s: ", fmt_line); sprintf(diag_eof_fmt, "%s: ", fmt_eof); msg_format = format; init_fmt = 1; } /* ----------------------------------------------------------------------------- * format_filename() * * Remove double backslashes in Windows filename paths for display * ----------------------------------------------------------------------------- */ static String *format_filename(const_String_or_char_ptr filename) { String *formatted_filename = NewString(filename); #if defined(_WIN32) Replaceall(formatted_filename, "\\\\", "\\"); #endif return formatted_filename; } /* ----------------------------------------------------------------------------- * Swig_stringify_with_location() * * Return a string representation of any DOH object with line and file location * information in the appropriate error message format. The string representation * is enclosed within [] brackets after the line and file information. * ----------------------------------------------------------------------------- */ String *Swig_stringify_with_location(DOH *object) { String *str = NewStringEmpty(); if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT); if (object) { int line = Getline(object); String *formatted_filename = format_filename(Getfile(object)); if (line > 0) { Printf(str, diag_line_fmt, formatted_filename, line); } else { Printf(str, diag_eof_fmt, formatted_filename); } if (Len(object) == 0) { Printf(str, "[EMPTY]"); } else { Printf(str, "[%s]", object); } Delete(formatted_filename); } else { Printf(str, "[NULL]"); } return str; } /* ----------------------------------------------------------------------------- * Swig_diagnostic() * * Issue a diagnostic message on stdout. * ----------------------------------------------------------------------------- */ void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...) { va_list ap; String *formatted_filename = NULL; if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT); va_start(ap, fmt); formatted_filename = format_filename(filename); if (line > 0) { Printf(stdout, diag_line_fmt, formatted_filename, line); } else { Printf(stdout, diag_eof_fmt, formatted_filename); } vPrintf(stdout, fmt, ap); va_end(ap); Delete(formatted_filename); } swig-3.0.2/Source/Swig/tree.c0000664000175000017500000002434112343605122015623 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * tree.c * * This file provides some general purpose functions for manipulating * parse trees. * ----------------------------------------------------------------------------- */ #include "swig.h" #include #include /* ----------------------------------------------------------------------------- * Swig_print_tags() * * Dump the tag structure of a parse tree to standard output * ----------------------------------------------------------------------------- */ void Swig_print_tags(DOH *obj, DOH *root) { DOH *croot, *newroot; DOH *cobj; if (!root) croot = NewStringEmpty(); else croot = root; while (obj) { Swig_diagnostic(Getfile(obj), Getline(obj), "%s . %s\n", croot, nodeType(obj)); cobj = firstChild(obj); if (cobj) { newroot = NewStringf("%s . %s", croot, nodeType(obj)); Swig_print_tags(cobj, newroot); Delete(newroot); } obj = nextSibling(obj); } if (!root) Delete(croot); } static int indent_level = 0; static void print_indent(int l) { int i; for (i = 0; i < indent_level; i++) { fputc(' ', stdout); } if (l) { fputc('|', stdout); fputc(' ', stdout); } } /* ----------------------------------------------------------------------------- * Swig_print_node(Node *n) * ----------------------------------------------------------------------------- */ void Swig_print_node(Node *obj) { Iterator ki; Node *cobj; print_indent(0); Printf(stdout, "+++ %s ----------------------------------------\n", nodeType(obj)); ki = First(obj); while (ki.key) { String *k = ki.key; if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) || (Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) { /* Do nothing */ } else if (Cmp(k, "parms") == 0 || Cmp(k, "wrap:parms") == 0) { print_indent(2); Printf(stdout, "%-12s - %s\n", k, ParmList_str_defaultargs(Getattr(obj, k))); } else { DOH *o; const char *trunc = ""; print_indent(2); if (DohIsString(Getattr(obj, k))) { o = Str(Getattr(obj, k)); if (Len(o) > 80) { trunc = "..."; } Printf(stdout, "%-12s - \"%(escape)-0.80s%s\"\n", k, o, trunc); Delete(o); } else { Printf(stdout, "%-12s - %p\n", k, Getattr(obj, k)); } } ki = Next(ki); } cobj = firstChild(obj); if (cobj) { indent_level += 6; Printf(stdout, "\n"); Swig_print_tree(cobj); indent_level -= 6; } else { print_indent(1); Printf(stdout, "\n"); } } /* ----------------------------------------------------------------------------- * Swig_print_tree() * * Dump the tree structure of a parse tree to standard output * ----------------------------------------------------------------------------- */ void Swig_print_tree(DOH *obj) { while (obj) { Swig_print_node(obj); obj = nextSibling(obj); } } /* ----------------------------------------------------------------------------- * appendChild() * * Appends a new child to a node * ----------------------------------------------------------------------------- */ void appendChild(Node *node, Node *chd) { Node *lc; if (!chd) return; lc = lastChild(node); if (!lc) { set_firstChild(node, chd); } else { set_nextSibling(lc, chd); set_previousSibling(chd, lc); } while (chd) { lc = chd; set_parentNode(chd, node); chd = nextSibling(chd); } set_lastChild(node, lc); } /* ----------------------------------------------------------------------------- * prependChild() * * Prepends a new child to a node * ----------------------------------------------------------------------------- */ void prependChild(Node *node, Node *chd) { Node *fc; if (!chd) return; fc = firstChild(node); if (fc) { set_nextSibling(chd, fc); set_previousSibling(fc, chd); } set_firstChild(node, chd); while (chd) { set_parentNode(chd, node); chd = nextSibling(chd); } } void appendSibling(Node *node, Node *chd) { Node *parent; Node *lc = node; while (nextSibling(lc)) lc = nextSibling(lc); set_nextSibling(lc, chd); set_previousSibling(chd, lc); parent = parentNode(node); if (parent) { while (chd) { lc = chd; set_parentNode(chd, parent); chd = nextSibling(chd); } set_lastChild(parent, lc); } } /* ----------------------------------------------------------------------------- * removeNode() * * Removes a node from the parse tree. Detaches it from its parent's child list. * ----------------------------------------------------------------------------- */ void removeNode(Node *n) { Node *parent; Node *prev; Node *next; parent = parentNode(n); if (!parent) return; prev = previousSibling(n); next = nextSibling(n); if (prev) { set_nextSibling(prev, next); } else { if (parent) { set_firstChild(parent, next); } } if (next) { set_previousSibling(next, prev); } else { if (parent) { set_lastChild(parent, prev); } } /* Delete attributes */ Delattr(n,"parentNode"); Delattr(n,"nextSibling"); Delattr(n,"prevSibling"); } /* ----------------------------------------------------------------------------- * copyNode() * * Copies a node, but only copies simple attributes (no lists, hashes). * ----------------------------------------------------------------------------- */ Node *copyNode(Node *n) { Iterator ki; Node *c = NewHash(); for (ki = First(n); ki.key; ki = Next(ki)) { if (DohIsString(ki.item)) { Setattr(c, ki.key, Copy(ki.item)); } } Setfile(c, Getfile(n)); Setline(c, Getline(n)); return c; } /* ----------------------------------------------------------------------------- * checkAttribute() * ----------------------------------------------------------------------------- */ int checkAttribute(Node *n, const_String_or_char_ptr name, const_String_or_char_ptr value) { String *v = Getattr(n, name); return v ? Equal(v, value) : 0; } /* ----------------------------------------------------------------------------- * Swig_require() * ns - namespace for the view name for saving any attributes under * n - node * ... - list of attribute names of type char* * This method checks that the attribute names exist in the node n and asserts if * not. Assert will only occur unless the attribute is optional. An attribute is * optional if it is prefixed by ?, eg "?value". If the attribute name is prefixed * by * or ?, eg "*value" then a copy of the attribute is saved. The saved * attributes will be restored on a subsequent call to Swig_restore(). All the * saved attributes are saved in the view namespace (prefixed by ns). * This function can be called more than once with different namespaces. * ----------------------------------------------------------------------------- */ void Swig_require(const char *ns, Node *n, ...) { va_list ap; char *name; DOH *obj; va_start(ap, n); name = va_arg(ap, char *); while (name) { int newref = 0; int opt = 0; if (*name == '*') { newref = 1; name++; } else if (*name == '?') { newref = 1; opt = 1; name++; } obj = Getattr(n, name); if (!opt && !obj) { Swig_error(Getfile(n), Getline(n), "Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n", name, nodeType(n)); assert(obj); } if (!obj) obj = DohNone; if (newref) { /* Save a copy of the attribute */ Setattr(n, NewStringf("%s:%s", ns, name), obj); } name = va_arg(ap, char *); } va_end(ap); /* Save the view */ { String *view = Getattr(n, "view"); if (view) { if (Strcmp(view, ns) != 0) { Setattr(n, NewStringf("%s:view", ns), view); Setattr(n, "view", NewString(ns)); } } else { Setattr(n, "view", NewString(ns)); } } } /* ----------------------------------------------------------------------------- * Swig_save() * Same as Swig_require(), but all attribute names are optional and all attributes * are saved, ie behaves as if all the attribute names were prefixed by ?. * ----------------------------------------------------------------------------- */ void Swig_save(const char *ns, Node *n, ...) { va_list ap; char *name; DOH *obj; va_start(ap, n); name = va_arg(ap, char *); while (name) { if (*name == '*') { name++; } else if (*name == '?') { name++; } obj = Getattr(n, name); if (!obj) obj = DohNone; /* Save a copy of the attribute */ if (Setattr(n, NewStringf("%s:%s", ns, name), obj)) { Printf(stderr, "Swig_save('%s','%s'): Warning, attribute '%s' was already saved.\n", ns, nodeType(n), name); } name = va_arg(ap, char *); } va_end(ap); /* Save the view */ { String *view = Getattr(n, "view"); if (view) { if (Strcmp(view, ns) != 0) { Setattr(n, NewStringf("%s:view", ns), view); Setattr(n, "view", NewString(ns)); } } else { Setattr(n, "view", NewString(ns)); } } } /* ----------------------------------------------------------------------------- * Swig_restore() * Restores attributes saved by a previous call to Swig_require() or Swig_save(). * ----------------------------------------------------------------------------- */ void Swig_restore(Node *n) { String *temp; int len; List *l; String *ns; Iterator ki; ns = Getattr(n, "view"); assert(ns); l = NewList(); temp = NewStringf("%s:", ns); len = Len(temp); for (ki = First(n); ki.key; ki = Next(ki)) { if (Strncmp(temp, ki.key, len) == 0) { Append(l, ki.key); } } for (ki = First(l); ki.item; ki = Next(ki)) { DOH *obj = Getattr(n, ki.item); Setattr(n, Char(ki.item) + len, obj); Delattr(n, ki.item); } Delete(l); Delete(temp); } swig-3.0.2/Source/Swig/typemap.c0000664000175000017500000017476112343605122016357 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * typemap.c * * A somewhat generalized implementation of SWIG1.1 typemaps. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "cparse.h" #include #if 0 #define SWIG_DEBUG #endif static int typemap_search_debug = 0; static int typemaps_used_debug = 0; static int typemap_register_debug = 0; static int in_typemap_search_multi = 0; static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f, Node *file_line_node); /* ----------------------------------------------------------------------------- * Typemaps are stored in a collection of nested hash tables. Something like * this: * * [ type ] * +-------- [ name ] * +-------- [ name ] * * Each hash table [ type ] or [ name ] then contains references to the * different typemap methods. These are referenced by names such as * "tmap:in", "tmap:out", "tmap:argout", and so forth. * * The object corresponding to a specific typemap method has the following attributes: * * "type" - Typemap type * "pname" - Parameter name * "code" - Typemap code * "source" - Source directive (%apply or %typemap) for the typemap * "locals" - Local variables (if any) * "kwargs" - Typemap attributes * * Example for a typemap method named "in": * %typemap(in, warning="987:my warning", noblock=1) int &my_int (int tmp) "$1 = $input;" * * "type" - r.int * "pname" - my_int * "code" - $1 = $input; * "source" - typemap(in) int &my_int * "locals" - int tmp * "kwargs" - warning="987:my typemap warning", foo=123 * * ----------------------------------------------------------------------------- */ #define MAX_SCOPE 32 static Hash *typemaps[MAX_SCOPE]; static int tm_scope = 0; static Hash *get_typemap(int tm_scope, const SwigType *type) { Hash *tm = 0; SwigType *dtype = 0; SwigType *hashtype; if (SwigType_istemplate(type)) { String *ty = Swig_symbol_template_deftype(type, 0); dtype = Swig_symbol_type_qualify(ty, 0); type = dtype; Delete(ty); } /* remove unary scope operator (::) prefix indicating global scope for looking up in the hashmap */ hashtype = SwigType_remove_global_scope_prefix(type); tm = Getattr(typemaps[tm_scope], hashtype); Delete(dtype); Delete(hashtype); return tm; } static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) { SwigType *hashtype = 0; Hash *new_tm = 0; assert(*tmhash == 0); if (SwigType_istemplate(type)) { SwigType *rty = SwigType_typedef_resolve_all(type); String *ty = Swig_symbol_template_deftype(rty, 0); String *tyq = Swig_symbol_type_qualify(ty, 0); hashtype = SwigType_remove_global_scope_prefix(tyq); *tmhash = Getattr(typemaps[tm_scope], hashtype); Delete(rty); Delete(tyq); Delete(ty); } else { hashtype = SwigType_remove_global_scope_prefix(type); } if (!*tmhash) { /* this type has not been seen before even after resolving template parameter types */ new_tm = NewHash(); *tmhash = new_tm; } /* note that the unary scope operator (::) prefix indicating global scope has been removed from the type */ Setattr(typemaps[tm_scope], hashtype, *tmhash); Delete(hashtype); Delete(new_tm); } /* ----------------------------------------------------------------------------- * Swig_typemap_init() * * Initialize the typemap system * ----------------------------------------------------------------------------- */ void Swig_typemap_init() { int i; for (i = 0; i < MAX_SCOPE; i++) { typemaps[i] = 0; } typemaps[0] = NewHash(); tm_scope = 0; } static String *typemap_method_name(const_String_or_char_ptr tmap_method) { static Hash *names = 0; String *s; /* Due to "interesting" object-identity semantics of DOH, we have to make sure that we only intern strings without object identity into the hash table. (typemap_attach_kwargs calls typemap_method_name several times with the "same" String *tmap_method (i.e., same object identity) but differing string values.) Most other callers work around this by using char* rather than String *. -- mkoeppe, Jun 17, 2003 */ const char *method_without_object_identity = Char(tmap_method); if (!names) names = NewHash(); s = Getattr(names, method_without_object_identity); if (s) return s; s = NewStringf("tmap:%s", tmap_method); Setattr(names, method_without_object_identity, s); Delete(s); return s; } #if 0 /* ----------------------------------------------------------------------------- * Swig_typemap_new_scope() * * Create a new typemap scope * ----------------------------------------------------------------------------- */ void Swig_typemap_new_scope() { tm_scope++; typemaps[tm_scope] = NewHash(); } /* ----------------------------------------------------------------------------- * Swig_typemap_pop_scope() * * Pop the last typemap scope off * ----------------------------------------------------------------------------- */ Hash *Swig_typemap_pop_scope() { if (tm_scope > 0) { return typemaps[tm_scope--]; } return 0; } #endif /* ----------------------------------------------------------------------------- * typemap_register() * * Internal implementation for Swig_typemap_register() * ----------------------------------------------------------------------------- */ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs, String *source_directive) { Hash *tm; Hash *tm1; Hash *tm2; Parm *np; String *tm_method; SwigType *type; String *pname; if (!parms) return; if (typemap_register_debug) { Printf(stdout, "Registering - %s\n", tmap_method); Swig_print_node(parms); } tm_method = typemap_method_name(tmap_method); /* Register the first type in the parameter list */ type = Getattr(parms, "type"); pname = Getattr(parms, "name"); /* See if this type has been seen before */ tm = get_typemap(tm_scope, type); if (!tm) { set_typemap(tm_scope, type, &tm); } if (pname) { /* See if parameter has been seen before */ tm1 = Getattr(tm, pname); if (!tm1) { tm1 = NewHash(); Setattr(tm, pname, tm1); Delete(tm1); } tm = tm1; } /* Now see if this typemap method has been seen before */ tm2 = Getattr(tm, tm_method); if (!tm2) { tm2 = NewHash(); Setattr(tm, tm_method, tm2); Delete(tm2); } /* For a multi-argument typemap, the typemap code and information is really only stored in the last argument. However, to make this work, we perform a really neat trick using the typemap method name. For example, consider this typemap %typemap(in) (int foo, int *bar, char *blah[]) { ... } To store it, we look at typemaps for the following: typemap method type-name ---------------------------------------------- "in" int foo "in-int+foo:" int *bar "in-int+foo:-p.int+bar: char *blah[] Notice how the typemap method name expands to encode information about previous arguments. */ np = nextSibling(parms); if (np) { /* Make an entirely new typemap method key */ String *multi_tmap_method = NewStringf("%s-%s+%s:", tmap_method, type, pname); /* Now reregister on the remaining arguments */ typemap_register(multi_tmap_method, np, code, locals, kwargs, source_directive); Delete(multi_tmap_method); } else { ParmList *clocals = CopyParmList(locals); ParmList *ckwargs = CopyParmList(kwargs); Setfile(tm2, Getfile(code)); Setline(tm2, Getline(code)); Setattr(tm2, "code", code); Setattr(tm2, "type", type); Setattr(tm2, "source", source_directive); if (pname) { Setattr(tm2, "pname", pname); } Setattr(tm2, "locals", clocals); Setattr(tm2, "kwargs", ckwargs); Delete(clocals); Delete(ckwargs); } } /* ----------------------------------------------------------------------------- * Swig_typemap_register() * * Add a new, possibly multi-argument, typemap * ----------------------------------------------------------------------------- */ void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) { String *parms_str = ParmList_str_multibrackets(parms); String *source_directive = NewStringf("typemap(%s) %s", tmap_method, parms_str); typemap_register(tmap_method, parms, code, locals, kwargs, source_directive); Delete(source_directive); Delete(parms_str); } /* ----------------------------------------------------------------------------- * typemap_get() * * Retrieve typemap information from current scope. * ----------------------------------------------------------------------------- */ static Hash *typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) { Hash *tm, *tm1; /* See if this type has been seen before */ if ((scope < 0) || (scope > tm_scope)) return 0; tm = get_typemap(scope, type); if (!tm) { return 0; } if ((name) && Len(name)) { tm1 = Getattr(tm, name); return tm1; } return tm; } /* ----------------------------------------------------------------------------- * Swig_typemap_copy() * * Copy a typemap * ----------------------------------------------------------------------------- */ int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcparms, ParmList *parms) { Hash *tm = 0; String *tm_method; Parm *p; String *pname; SwigType *ptype; int ts = tm_scope; String *tm_methods, *multi_tmap_method; if (ParmList_len(parms) != ParmList_len(srcparms)) return -1; tm_method = typemap_method_name(tmap_method); while (ts >= 0) { p = srcparms; tm_methods = NewString(tm_method); while (p) { ptype = Getattr(p, "type"); pname = Getattr(p, "name"); /* Lookup the type */ tm = typemap_get(ptype, pname, ts); if (!tm) break; tm = Getattr(tm, tm_methods); if (!tm) break; /* Got a match. Look for next typemap */ multi_tmap_method = NewStringf("%s-%s+%s:", tm_methods, ptype, pname); Delete(tm_methods); tm_methods = multi_tmap_method; p = nextSibling(p); } Delete(tm_methods); if (!p && tm) { /* Got some kind of match */ String *parms_str = ParmList_str_multibrackets(parms); String *srcparms_str = ParmList_str_multibrackets(srcparms); String *source_directive = NewStringf("typemap(%s) %s = %s", tmap_method, parms_str, srcparms_str); typemap_register(tmap_method, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs"), source_directive); Delete(source_directive); Delete(srcparms_str); Delete(parms_str); return 0; } ts--; } /* Not found */ return -1; } /* ----------------------------------------------------------------------------- * Swig_typemap_clear() * * Delete a multi-argument typemap * ----------------------------------------------------------------------------- */ void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *parms) { SwigType *type; String *name; Parm *p; String *multi_tmap_method; Hash *tm = 0; /* This might not work */ multi_tmap_method = NewString(tmap_method); p = parms; while (p) { type = Getattr(p, "type"); name = Getattr(p, "name"); tm = typemap_get(type, name, tm_scope); if (!tm) return; p = nextSibling(p); if (p) Printf(multi_tmap_method, "-%s+%s:", type, name); } if (tm) { tm = Getattr(tm, typemap_method_name(multi_tmap_method)); if (tm) { Delattr(tm, "code"); Delattr(tm, "locals"); Delattr(tm, "kwargs"); } } Delete(multi_tmap_method); } /* ----------------------------------------------------------------------------- * Swig_typemap_apply() * * Multi-argument %apply directive. This is pretty horrible so I sure hope * it works. * ----------------------------------------------------------------------------- */ static int count_args(String *s) { /* Count up number of arguments */ int na = 0; char *c = Char(s); while (*c) { if (*c == '+') na++; c++; } return na; } int Swig_typemap_apply(ParmList *src, ParmList *dest) { String *ssig, *dsig; Parm *p, *np, *lastp, *dp, *lastdp = 0; int narg = 0; int ts = tm_scope; SwigType *type = 0, *name; Hash *tm, *sm; int match = 0; /* Printf(stdout,"apply : %s --> %s\n", ParmList_str(src), ParmList_str(dest)); */ /* Create type signature of source */ ssig = NewStringEmpty(); dsig = NewStringEmpty(); p = src; dp = dest; lastp = 0; while (p) { lastp = p; lastdp = dp; np = nextSibling(p); if (np) { Printf(ssig, "-%s+%s:", Getattr(p, "type"), Getattr(p, "name")); Printf(dsig, "-%s+%s:", Getattr(dp, "type"), Getattr(dp, "name")); narg++; } p = np; dp = nextSibling(dp); } /* make sure a typemap node exists for the last destination node */ type = Getattr(lastdp, "type"); tm = get_typemap(tm_scope, type); if (!tm) { set_typemap(tm_scope, type, &tm); } name = Getattr(lastdp, "name"); if (name) { Hash *tm1 = Getattr(tm, name); if (!tm1) { tm1 = NewHash(); Setattr(tm, NewString(name), tm1); Delete(tm1); } tm = tm1; } /* This is a little nasty. We need to go searching for all possible typemaps in the source and apply them to the target */ type = Getattr(lastp, "type"); name = Getattr(lastp, "name"); while (ts >= 0) { /* See if there is a matching typemap in this scope */ sm = typemap_get(type, name, ts); /* if there is not matching, look for a typemap in the original typedef, if any, like in: typedef unsigned long size_t; ... %apply(size_t) {my_size}; ==> %apply(unsigned long) {my_size}; */ if (!sm) { SwigType *ntype = SwigType_typedef_resolve(type); if (ntype && (Cmp(ntype, type) != 0)) { sm = typemap_get(ntype, name, ts); } Delete(ntype); } if (sm) { /* Got a typemap. Need to only merge attributes for methods that match our signature */ Iterator ki; match = 1; for (ki = First(sm); ki.key; ki = Next(ki)) { /* Check for a signature match with the source signature */ if ((count_args(ki.key) == narg) && (Strstr(ki.key, ssig))) { String *oldm; /* A typemap we have to copy */ String *nkey = Copy(ki.key); Replace(nkey, ssig, dsig, DOH_REPLACE_ANY); /* Make sure the typemap doesn't already exist in the target map */ oldm = Getattr(tm, nkey); if (!oldm || (!Getattr(tm, "code"))) { String *code; ParmList *locals; ParmList *kwargs; Hash *sm1 = ki.item; code = Getattr(sm1, "code"); locals = Getattr(sm1, "locals"); kwargs = Getattr(sm1, "kwargs"); if (code) { String *src_str = ParmList_str_multibrackets(src); String *dest_str = ParmList_str_multibrackets(dest); String *source_directive = NewStringf("apply %s { %s }", src_str, dest_str); Replace(nkey, dsig, "", DOH_REPLACE_ANY); Replace(nkey, "tmap:", "", DOH_REPLACE_ANY); typemap_register(nkey, dest, code, locals, kwargs, source_directive); Delete(source_directive); Delete(dest_str); Delete(src_str); } } Delete(nkey); } } } ts--; } Delete(ssig); Delete(dsig); return match; } /* ----------------------------------------------------------------------------- * Swig_typemap_clear_apply() * * %clear directive. Clears all typemaps for a type (in the current scope only). * ----------------------------------------------------------------------------- */ /* Multi-argument %clear directive */ void Swig_typemap_clear_apply(Parm *parms) { String *tsig; Parm *p, *np, *lastp; int narg = 0; Hash *tm; String *name; /* Create a type signature of the parameters */ tsig = NewStringEmpty(); p = parms; lastp = 0; while (p) { lastp = p; np = nextSibling(p); if (np) { Printf(tsig, "-%s+%s:", Getattr(p, "type"), Getattr(p, "name")); narg++; } p = np; } tm = get_typemap(tm_scope, Getattr(lastp, "type")); if (!tm) { Delete(tsig); return; } name = Getattr(lastp, "name"); if (name) { tm = Getattr(tm, name); } if (tm) { /* Clear typemaps that match our signature */ Iterator ki, ki2; char *ctsig = Char(tsig); for (ki = First(tm); ki.key; ki = Next(ki)) { char *ckey = Char(ki.key); if (strncmp(ckey, "tmap:", 5) == 0) { int na = count_args(ki.key); if ((na == narg) && strstr(ckey, ctsig)) { Hash *h = ki.item; for (ki2 = First(h); ki2.key; ki2 = Next(ki2)) { Delattr(h, ki2.key); } } } } } Delete(tsig); } /* Internal function to strip array dimensions. */ static SwigType *strip_arrays(SwigType *type) { SwigType *t; int ndim; int i; t = Copy(type); ndim = SwigType_array_ndim(t); for (i = 0; i < ndim; i++) { SwigType_array_setdim(t, i, "ANY"); } return t; } static void debug_search_result_display(Node *tm) { if (tm) Printf(stdout, " Using: %%%s\n", Getattr(tm, "source")); else Printf(stdout, " None found\n"); } /* ----------------------------------------------------------------------------- * typemap_search_helper() * * Helper function for typemap_search to see if there is a type match in the typemap * tm. A match is sought in this order: * %typemap(tm_method) ctype cqualifiedname * %typemap(tm_method) ctype cname * %typemap(tm_method) ctype * ----------------------------------------------------------------------------- */ static Hash *typemap_search_helper(int debug_display, Hash *tm, const String *tm_method, SwigType *ctype, const String *cqualifiedname, const String *cname, Hash **backup) { Hash *result = 0; Hash *tm1; if (debug_display && cqualifiedname) Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cqualifiedname)); if (tm && cqualifiedname) { tm1 = Getattr(tm, cqualifiedname); if (tm1) { result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ if (result && Getattr(result, "code")) goto ret_result; if (result) *backup = result; } } if (debug_display && cname) Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cname)); if (tm && cname) { tm1 = Getattr(tm, cname); if (tm1) { result = Getattr(tm1, tm_method); /* See if there is a type - name match */ if (result && Getattr(result, "code")) goto ret_result; if (result) *backup = result; } } if (debug_display) Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, 0)); if (tm) { result = Getattr(tm, tm_method); /* See if there is simply a type without name match */ if (result && Getattr(result, "code")) goto ret_result; if (result) *backup = result; } ret_result: return result; } /* ----------------------------------------------------------------------------- * typemap_search() * * Search for a typemap match. This is where the typemap pattern matching rules * are implemented... tries to find the most specific typemap that includes a * 'code' attribute. * ----------------------------------------------------------------------------- */ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, const_String_or_char_ptr qualifiedname, SwigType **matchtype, Node *node) { Hash *result = 0; Hash *tm; Hash *backup = 0; SwigType *primitive = 0; SwigType *ctype = 0; SwigType *ctype_unstripped = 0; int ts; int isarray; const String *cname = 0; const String *cqualifiedname = 0; String *tm_method = typemap_method_name(tmap_method); int debug_display = (in_typemap_search_multi == 0) && typemap_search_debug; if ((name) && Len(name)) cname = name; if ((qualifiedname) && Len(qualifiedname)) cqualifiedname = qualifiedname; ts = tm_scope; if (debug_display) { String *typestr = SwigType_str(type, cqualifiedname ? cqualifiedname : cname); Swig_diagnostic(Getfile(node), Getline(node), "Searching for a suitable '%s' typemap for: %s\n", tmap_method, typestr); Delete(typestr); } while (ts >= 0) { ctype = Copy(type); ctype_unstripped = Copy(ctype); while (ctype) { /* Try to get an exact type-match */ tm = get_typemap(ts, ctype); result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup); if (result && Getattr(result, "code")) goto ret_result; { /* Look for the type reduced to just the template prefix - for templated types without the template parameter list being specified */ SwigType *template_prefix = SwigType_istemplate_only_templateprefix(ctype); if (template_prefix) { tm = get_typemap(ts, template_prefix); result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup); Delete(template_prefix); if (result && Getattr(result, "code")) goto ret_result; } } /* look for [ANY] arrays */ isarray = SwigType_isarray(ctype); if (isarray) { /* If working with arrays, strip away all of the dimensions and replace with "ANY". See if that generates a match */ SwigType *noarrays = strip_arrays(ctype); tm = get_typemap(ts, noarrays); result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup); Delete(noarrays); if (result && Getattr(result, "code")) goto ret_result; } /* No match so far - try with a qualifier stripped (strip one qualifier at a time until none remain) * The order of stripping in SwigType_strip_single_qualifier is used to provide some sort of consistency * with the default (SWIGTYPE) typemap matching rules for the first qualifier to be stripped. */ { SwigType *oldctype = ctype; ctype = SwigType_strip_single_qualifier(oldctype); if (!Equal(ctype, oldctype)) { Delete(oldctype); continue; } Delete(oldctype); } /* Once all qualifiers are stripped try resolve a typedef */ { SwigType *oldctype = ctype; ctype = SwigType_typedef_resolve(ctype_unstripped); Delete(oldctype); ctype_unstripped = Copy(ctype); } } /* Hmmm. Well, no match seems to be found at all. See if there is some kind of default (SWIGTYPE) mapping */ primitive = SwigType_default_create(type); while (primitive) { tm = get_typemap(ts, primitive); result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup); if (result && Getattr(result, "code")) goto ret_result; { SwigType *nprim = SwigType_default_deduce(primitive); Delete(primitive); primitive = nprim; } } if (ctype != type) { Delete(ctype); ctype = 0; } ts--; /* Hmmm. Nothing found in this scope. Guess we'll go try another scope */ } result = backup; ret_result: Delete(primitive); if (matchtype) *matchtype = Copy(ctype); Delete(ctype); Delete(ctype_unstripped); return result; } /* ----------------------------------------------------------------------------- * typemap_search_multi() * * Search for a multi-argument typemap. * ----------------------------------------------------------------------------- */ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList *parms, int *nmatch) { SwigType *type; SwigType *mtype = 0; String *name; String *multi_tmap_method; Hash *tm; Hash *tm1 = 0; if (!parms) { *nmatch = 0; return 0; } type = Getattr(parms, "type"); name = Getattr(parms, "name"); /* Try to find a match on the first type */ tm = typemap_search(tmap_method, type, name, 0, &mtype, parms); if (tm) { if (mtype && SwigType_isarray(mtype)) { Setattr(parms, "tmap:match", mtype); } Delete(mtype); multi_tmap_method = NewStringf("%s-%s+%s:", tmap_method, type, name); in_typemap_search_multi++; tm1 = typemap_search_multi(multi_tmap_method, nextSibling(parms), nmatch); in_typemap_search_multi--; if (tm1) tm = tm1; if (Getattr(tm, "code")) { *(nmatch) = *nmatch + 1; if (typemap_search_debug && tm1 && (in_typemap_search_multi == 0)) { Printf(stdout, " Multi-argument typemap found...\n"); } } else { tm = 0; } Delete(multi_tmap_method); } if (typemap_search_debug && (in_typemap_search_multi == 0)) debug_search_result_display(tm); if (typemaps_used_debug && (in_typemap_search_multi == 0) && tm) { String *typestr = SwigType_str(type, name); Swig_diagnostic(Getfile(parms), Getline(parms), "Typemap for %s (%s) : %%%s\n", typestr, tmap_method, Getattr(tm, "source")); assert(Getfile(parms) && Len(Getfile(parms)) > 0); /* Missing file and line numbering information */ Delete(typestr); } return tm; } /* ----------------------------------------------------------------------------- * typemap_replace_vars() * * Replaces typemap variables on a string. index is the $n variable. * type and pname are the type and parameter name. * ----------------------------------------------------------------------------- */ static void replace_local_types(ParmList *p, const String *name, const String *rep) { SwigType *t; while (p) { t = Getattr(p, "type"); Replace(t, name, rep, DOH_REPLACE_ANY); p = nextSibling(p); } } static int check_locals(ParmList *p, const char *s) { while (p) { char *c = GetChar(p, "type"); if (strstr(c, s)) return 1; p = nextSibling(p); } return 0; } static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, SwigType *rtype, String *pname, String *lname, int index) { char var[512]; char *varname; SwigType *ftype; int bare_substitution_count = 0; Replaceall(s, "$typemap", "$TYPEMAP"); /* workaround for $type substitution below */ ftype = SwigType_typedef_resolve_all(type); if (!pname) pname = lname; { Parm *p; int rep = 0; p = locals; while (p) { if (Strchr(Getattr(p, "type"), '$')) rep = 1; p = nextSibling(p); } if (!rep) locals = 0; } sprintf(var, "$%d_", index); varname = &var[strlen(var)]; /* If the original datatype was an array. We're going to go through and substitute its array dimensions */ if (SwigType_isarray(type) || SwigType_isarray(ftype)) { String *size; int ndim; int i; if (SwigType_array_ndim(type) != SwigType_array_ndim(ftype)) type = ftype; ndim = SwigType_array_ndim(type); size = NewStringEmpty(); for (i = 0; i < ndim; i++) { String *dim = SwigType_array_getdim(type, i); if (index == 1) { char t[32]; sprintf(t, "$dim%d", i); Replace(s, t, dim, DOH_REPLACE_ANY); replace_local_types(locals, t, dim); } sprintf(varname, "dim%d", i); Replace(s, var, dim, DOH_REPLACE_ANY); replace_local_types(locals, var, dim); if (Len(size)) Putc('*', size); Append(size, dim); Delete(dim); } sprintf(varname, "size"); Replace(s, var, size, DOH_REPLACE_ANY); replace_local_types(locals, var, size); Delete(size); } /* Parameter name substitution */ if (index == 1) { Replace(s, "$parmname", pname, DOH_REPLACE_ANY); } strcpy(varname, "name"); Replace(s, var, pname, DOH_REPLACE_ANY); /* Type-related stuff */ { SwigType *star_type, *amp_type, *base_type, *lex_type; SwigType *ltype, *star_ltype, *amp_ltype; String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name, *base_type_str; String *descriptor, *star_descriptor, *amp_descriptor; String *ts; char *sc; sc = Char(s); if (strstr(sc, "type") || check_locals(locals, "type")) { /* Given type : $type */ ts = SwigType_str(type, 0); if (index == 1) { Replace(s, "$type", ts, DOH_REPLACE_ANY); replace_local_types(locals, "$type", type); } strcpy(varname, "type"); Replace(s, var, ts, DOH_REPLACE_ANY); replace_local_types(locals, var, type); Delete(ts); sc = Char(s); } if (strstr(sc, "ltype") || check_locals(locals, "ltype")) { /* Local type: $ltype */ ltype = SwigType_ltype(type); ts = SwigType_str(ltype, 0); if (index == 1) { Replace(s, "$ltype", ts, DOH_REPLACE_ANY); replace_local_types(locals, "$ltype", ltype); } strcpy(varname, "ltype"); Replace(s, var, ts, DOH_REPLACE_ANY); replace_local_types(locals, var, ltype); Delete(ts); Delete(ltype); sc = Char(s); } if (strstr(sc, "mangle") || strstr(sc, "descriptor")) { /* Mangled type */ mangle = SwigType_manglestr(type); if (index == 1) Replace(s, "$mangle", mangle, DOH_REPLACE_ANY); strcpy(varname, "mangle"); Replace(s, var, mangle, DOH_REPLACE_ANY); descriptor = NewStringf("SWIGTYPE%s", mangle); if (index == 1) if (Replace(s, "$descriptor", descriptor, DOH_REPLACE_ANY)) SwigType_remember(type); strcpy(varname, "descriptor"); if (Replace(s, var, descriptor, DOH_REPLACE_ANY)) SwigType_remember(type); Delete(descriptor); Delete(mangle); } /* One pointer level removed */ /* This creates variables of the form $*n_type $*n_ltype */ if (SwigType_ispointer(ftype) || (SwigType_isarray(ftype)) || (SwigType_isreference(ftype)) || (SwigType_isrvalue_reference(ftype))) { if (!(SwigType_isarray(type) || SwigType_ispointer(type) || SwigType_isreference(type) || SwigType_isrvalue_reference(type))) { star_type = Copy(ftype); } else { star_type = Copy(type); } if (!(SwigType_isreference(star_type) || SwigType_isrvalue_reference(star_type))) { if (SwigType_isarray(star_type)) { SwigType_del_element(star_type); } else { SwigType_del_pointer(star_type); } ts = SwigType_str(star_type, 0); if (index == 1) { Replace(s, "$*type", ts, DOH_REPLACE_ANY); replace_local_types(locals, "$*type", star_type); } sprintf(varname, "$*%d_type", index); Replace(s, varname, ts, DOH_REPLACE_ANY); replace_local_types(locals, varname, star_type); Delete(ts); } else { SwigType_del_element(star_type); } star_ltype = SwigType_ltype(star_type); ts = SwigType_str(star_ltype, 0); if (index == 1) { Replace(s, "$*ltype", ts, DOH_REPLACE_ANY); replace_local_types(locals, "$*ltype", star_ltype); } sprintf(varname, "$*%d_ltype", index); Replace(s, varname, ts, DOH_REPLACE_ANY); replace_local_types(locals, varname, star_ltype); Delete(ts); Delete(star_ltype); star_mangle = SwigType_manglestr(star_type); if (index == 1) Replace(s, "$*mangle", star_mangle, DOH_REPLACE_ANY); sprintf(varname, "$*%d_mangle", index); Replace(s, varname, star_mangle, DOH_REPLACE_ANY); star_descriptor = NewStringf("SWIGTYPE%s", star_mangle); if (index == 1) if (Replace(s, "$*descriptor", star_descriptor, DOH_REPLACE_ANY)) SwigType_remember(star_type); sprintf(varname, "$*%d_descriptor", index); if (Replace(s, varname, star_descriptor, DOH_REPLACE_ANY)) SwigType_remember(star_type); Delete(star_descriptor); Delete(star_mangle); Delete(star_type); } else { /* TODO: Signal error if one of the $* substitutions is requested */ } /* One pointer level added */ amp_type = Copy(type); SwigType_add_pointer(amp_type); ts = SwigType_str(amp_type, 0); if (index == 1) { Replace(s, "$&type", ts, DOH_REPLACE_ANY); replace_local_types(locals, "$&type", amp_type); } sprintf(varname, "$&%d_type", index); Replace(s, varname, ts, DOH_REPLACE_ANY); replace_local_types(locals, varname, amp_type); Delete(ts); amp_ltype = SwigType_ltype(type); SwigType_add_pointer(amp_ltype); ts = SwigType_str(amp_ltype, 0); if (index == 1) { Replace(s, "$<ype", ts, DOH_REPLACE_ANY); replace_local_types(locals, "$<ype", amp_ltype); } sprintf(varname, "$&%d_ltype", index); Replace(s, varname, ts, DOH_REPLACE_ANY); replace_local_types(locals, varname, amp_ltype); Delete(ts); Delete(amp_ltype); amp_mangle = SwigType_manglestr(amp_type); if (index == 1) Replace(s, "$&mangle", amp_mangle, DOH_REPLACE_ANY); sprintf(varname, "$&%d_mangle", index); Replace(s, varname, amp_mangle, DOH_REPLACE_ANY); amp_descriptor = NewStringf("SWIGTYPE%s", amp_mangle); if (index == 1) if (Replace(s, "$&descriptor", amp_descriptor, DOH_REPLACE_ANY)) SwigType_remember(amp_type); sprintf(varname, "$&%d_descriptor", index); if (Replace(s, varname, amp_descriptor, DOH_REPLACE_ANY)) SwigType_remember(amp_type); Delete(amp_descriptor); Delete(amp_mangle); Delete(amp_type); /* Base type */ if (SwigType_isarray(type)) { base_type = Copy(type); Delete(SwigType_pop_arrays(base_type)); } else { base_type = SwigType_base(type); } base_type_str = SwigType_str(base_type, 0); base_name = SwigType_namestr(base_type_str); if (index == 1) { Replace(s, "$basetype", base_name, DOH_REPLACE_ANY); replace_local_types(locals, "$basetype", base_name); } strcpy(varname, "basetype"); Replace(s, var, base_type_str, DOH_REPLACE_ANY); replace_local_types(locals, var, base_name); base_mangle = SwigType_manglestr(base_type); if (index == 1) Replace(s, "$basemangle", base_mangle, DOH_REPLACE_ANY); strcpy(varname, "basemangle"); Replace(s, var, base_mangle, DOH_REPLACE_ANY); Delete(base_mangle); Delete(base_name); Delete(base_type_str); Delete(base_type); lex_type = SwigType_base(rtype); if (index == 1) Replace(s, "$lextype", lex_type, DOH_REPLACE_ANY); strcpy(varname, "lextype"); Replace(s, var, lex_type, DOH_REPLACE_ANY); Delete(lex_type); } /* Replace any $n. with (&n)-> */ { char temp[64]; sprintf(var, "$%d.", index); sprintf(temp, "(&$%d)->", index); Replace(s, var, temp, DOH_REPLACE_ANY); } /* Replace the bare $n variable */ sprintf(var, "$%d", index); bare_substitution_count = Replace(s, var, lname, DOH_REPLACE_NUMBER_END); Delete(ftype); return bare_substitution_count; } /* ------------------------------------------------------------------------ * static typemap_locals() * * Takes a string, a parameter list and a wrapper function argument and * creates the local variables. * ------------------------------------------------------------------------ */ static void typemap_locals(String *s, ParmList *l, Wrapper *f, int argnum) { Parm *p; char *new_name; p = l; while (p) { SwigType *pt = Getattr(p, "type"); SwigType *at = SwigType_alttype(pt, 1); String *pn = Getattr(p, "name"); String *value = Getattr(p, "value"); if (at) pt = at; if (pn) { if (Len(pn) > 0) { String *str; int isglobal = 0; str = NewStringEmpty(); if (strncmp(Char(pn), "_global_", 8) == 0) { isglobal = 1; } /* If the user gave us $type as the name of the local variable, we'll use the passed datatype instead */ if ((argnum >= 0) && (!isglobal)) { Printf(str, "%s%d", pn, argnum); } else { Append(str, pn); } if (isglobal && Wrapper_check_local(f, str)) { p = nextSibling(p); Delete(str); if (at) Delete(at); continue; } if (value) { String *pstr = SwigType_str(pt, str); new_name = Wrapper_new_localv(f, str, pstr, "=", value, NIL); Delete(pstr); } else { String *pstr = SwigType_str(pt, str); new_name = Wrapper_new_localv(f, str, pstr, NIL); Delete(pstr); } if (!isglobal) { /* Substitute */ Replace(s, pn, new_name, DOH_REPLACE_ID | DOH_REPLACE_NOQUOTE); } Delete(str); } } p = nextSibling(p); if (at) Delete(at); } } /* ----------------------------------------------------------------------------- * typemap_warn() * * If any warning message is attached to this parameter's "tmap::warning" * attribute, return the warning message (special variables will need expanding * before displaying the warning). * ----------------------------------------------------------------------------- */ static String *typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) { String *temp = NewStringf("%s:warning", tmap_method); String *w = Getattr(p, typemap_method_name(temp)); Delete(temp); return w ? Copy(w) : 0; } /* ----------------------------------------------------------------------------- * Swig_typemap_lookup() * * Attach one or more typemaps to a node and optionally generate the typemap contents * into the wrapper. * * Looks for a typemap matching the given type and name and attaches the typemap code * and any typemap attributes to the provided node. * * The node should contain the "type" and "name" attributes for the typemap match on. * input. The typemap code and typemap attribute values are attached onto the node * prefixed with "tmap:". For example with tmap_method="in", the typemap code can be retrieved * with a call to Getattr(node, "tmap:in") (this is also the string returned) and the * "noblock" attribute can be retrieved with a call to Getattr(node, "tmap:in:noblock"). * * tmap_method - typemap method, eg "in", "out", "newfree" * node - the node to attach the typemap and typemap attributes to * lname - name of variable to substitute $1, $2 etc for * f - wrapper code to generate into if non null * actioncode - code to generate into f before the out typemap code, unless * the optimal attribute is set in the out typemap in which case * $1 in the out typemap will be replaced by the code in actioncode. * ----------------------------------------------------------------------------- */ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) { SwigType *type; SwigType *mtype = 0; String *pname; String *qpname = 0; String *noscope_pname = 0; Hash *tm = 0; String *s = 0; String *sdef = 0; String *warning = 0; ParmList *locals; ParmList *kw; char temp[256]; String *symname; String *cname = 0; String *clname = 0; char *cmethod = Char(tmap_method); int optimal_attribute = 0; int optimal_substitution = 0; int num_substitutions = 0; SwigType *matchtype = 0; type = Getattr(node, "type"); if (!type) return sdef; /* Special hook (hack!). Check for the 'ref' feature and add code it contains to any 'newfree' typemap code. * We could choose to put this hook into a number of different typemaps, not necessarily 'newfree'... * Rather confusingly 'newfree' is used to release memory and the 'ref' feature is used to add in memory references - yuck! */ if (Cmp(tmap_method, "newfree") == 0) { String *base = SwigType_base(type); Node *typenode = Swig_symbol_clookup(base, 0); if (typenode) sdef = Swig_ref_call(typenode, lname); Delete(base); } pname = Getattr(node, "name"); noscope_pname = Copy(pname); if (pname && Getattr(node, "sym:symtab")) { /* Add on a qualified name search for any symbol in the symbol table, for example: * struct Foo { * int *foo(int bar) -> Foo::foo * }; * Note that if node is a parameter (Parm *) then there will be no symbol table attached to the Parm *. */ String *qsn; if (Swig_scopename_check(pname)) { /* sometimes pname is qualified, so we remove all the scope for the lookup */ Delete(noscope_pname); noscope_pname = Swig_scopename_last(pname); /* Printf(stdout, "Removed scope: %s => %s\n", pname, noscope_pname); */ } qsn = Swig_symbol_qualified(node); if (qsn && Len(qsn)) { qpname = NewStringf("%s::%s", qsn, noscope_pname); Delete(qsn); } } tm = typemap_search(tmap_method, type, noscope_pname, qpname, &mtype, node); if (typemap_search_debug) debug_search_result_display(tm); if (typemaps_used_debug && tm) { String *typestr = SwigType_str(type, qpname ? qpname : pname); Swig_diagnostic(Getfile(node), Getline(node), "Typemap for %s (%s) : %%%s\n", typestr, tmap_method, Getattr(tm, "source")); assert(Getfile(node) && Len(Getfile(node)) > 0); /* Missing file and line numbering information */ Delete(typestr); } Delete(qpname); qpname = 0; Delete(noscope_pname); noscope_pname = 0; if (!tm) return sdef; s = Getattr(tm, "code"); if (!s) return sdef; /* Empty typemap. No match */ if (Cmp(s, "pass") == 0) return sdef; s = Copy(s); /* Make a local copy of the typemap code */ /* Attach kwargs - ie the typemap attributes */ kw = Getattr(tm, "kwargs"); while (kw) { String *value = Copy(Getattr(kw, "value")); String *kwtype = Getattr(kw, "type"); char *ckwname = Char(Getattr(kw, "name")); if (kwtype) { String *mangle = Swig_string_mangle(kwtype); Append(value, mangle); Delete(mangle); } sprintf(temp, "%s:%s", cmethod, ckwname); Setattr(node, typemap_method_name(temp), value); if (Cmp(temp, "out:optimal") == 0) optimal_attribute = (Cmp(value, "0") != 0) ? 1 : 0; Delete(value); kw = nextSibling(kw); } if (optimal_attribute) { /* Note: "out" typemap is the only typemap that will have the "optimal" attribute set. * If f and actioncode are NULL, then the caller is just looking to attach the "out" attributes * ie, not use the typemap code, otherwise both f and actioncode must be non null. */ if (actioncode) { const String *result_equals = NewStringf("%s = ", Swig_cresult_name()); clname = Copy(actioncode); /* check that the code in the typemap can be used in this optimal way. * The code should be in the form "result = ...;\n". We need to extract * the "..." part. This may not be possible for various reasons, eg * code added by %exception. This optimal code generation is bit of a * hack and circumvents the normal requirement for a temporary variable * to hold the result returned from a wrapped function call. */ if (Strncmp(clname, result_equals, 9) == 0) { int numreplacements = Replace(clname, result_equals, "", DOH_REPLACE_ID_BEGIN); if (numreplacements == 1) { numreplacements = Replace(clname, ";\n", "", DOH_REPLACE_ID_END); if (numreplacements == 1) { if (Strchr(clname, ';') == 0) { lname = clname; actioncode = 0; optimal_substitution = 1; } } } } if (!optimal_substitution) { Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute ignored\n", Swig_name_decl(node)); Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", clname); Delattr(node, "tmap:out:optimal"); } } else { assert(!f); } } if (actioncode) { assert(f); Append(f->code, actioncode); } /* emit local variables declared in typemap, eg emit declarations for aa and bb in: * %typemap(in) foo (int aa, int bb) "..." */ locals = Getattr(tm, "locals"); if (locals) locals = CopyParmList(locals); if (pname) { if (SwigType_istemplate(pname)) { cname = SwigType_namestr(pname); pname = cname; } } if (SwigType_istemplate((char *) lname)) { clname = SwigType_namestr((char *) lname); lname = clname; } matchtype = mtype && SwigType_isarray(mtype) ? mtype : type; num_substitutions = typemap_replace_vars(s, locals, matchtype, type, pname, (char *) lname, 1); if (optimal_substitution && num_substitutions > 1) { Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node)); Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "optimal attribute usage in the out typemap.\n"); } if (locals && f) { typemap_locals(s, locals, f, -1); } { ParmList *parm_sublist = NewParmWithoutFileLineInfo(type, pname); Setattr(parm_sublist, "lname", lname); replace_embedded_typemap(s, parm_sublist, f, tm); Delete(parm_sublist); } Replace(s, "$name", pname, DOH_REPLACE_ANY); symname = Getattr(node, "sym:name"); if (symname) Replace(s, "$symname", symname, DOH_REPLACE_ANY); Setattr(node, typemap_method_name(tmap_method), s); if (locals) { sprintf(temp, "%s:locals", cmethod); Setattr(node, typemap_method_name(temp), locals); Delete(locals); } if (Checkattr(tm, "type", "SWIGTYPE")) { sprintf(temp, "%s:SWIGTYPE", cmethod); Setattr(node, typemap_method_name(temp), "1"); } /* Print warnings, if any */ warning = typemap_warn(cmethod, node); if (warning) { typemap_replace_vars(warning, 0, matchtype, type, pname, (char *) lname, 1); Replace(warning, "$name", pname, DOH_REPLACE_ANY); if (symname) Replace(warning, "$symname", symname, DOH_REPLACE_ANY); Swig_warning(0, Getfile(node), Getline(node), "%s\n", warning); Delete(warning); } /* Look for code fragments */ { String *fragment; sprintf(temp, "%s:fragment", cmethod); fragment = Getattr(node, typemap_method_name(temp)); if (fragment) { String *fname = Copy(fragment); Setfile(fname, Getfile(node)); Setline(fname, Getline(node)); Swig_fragment_emit(fname); Delete(fname); } } Delete(cname); Delete(clname); Delete(mtype); if (sdef) { /* put 'ref' and 'newfree' codes together */ String *p = NewStringf("%s\n%s", sdef, s); Delete(s); Delete(sdef); s = p; } Delete(actioncode); return s; } String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) { assert(actioncode); assert(Cmp(tmap_method, "out") == 0); return Swig_typemap_lookup_impl(tmap_method, node, lname, f, actioncode); } String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *node, const_String_or_char_ptr lname, Wrapper *f) { return Swig_typemap_lookup_impl(tmap_method, node, lname, f, 0); } /* ----------------------------------------------------------------------------- * typemap_attach_kwargs() * * If this hash (tm) contains a linked list of parameters under its "kwargs" * attribute, add keys for each of those named keyword arguments to this * parameter for later use. * For example, attach the typemap attributes to p: * %typemap(in, foo="xyz") ... * A new attribute called "tmap:in:foo" with value "xyz" is attached to p. * ----------------------------------------------------------------------------- */ static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method, Parm *p) { String *temp = NewStringEmpty(); Parm *kw = Getattr(tm, "kwargs"); while (kw) { String *value = Copy(Getattr(kw, "value")); String *type = Getattr(kw, "type"); if (type) { Hash *v = NewHash(); Setattr(v, "type", type); Setattr(v, "value", value); Delete(value); value = v; } Clear(temp); Printf(temp, "%s:%s", tmap_method, Getattr(kw, "name")); Setattr(p, typemap_method_name(temp), value); Delete(value); kw = nextSibling(kw); } Clear(temp); Printf(temp, "%s:match_type", tmap_method); Setattr(p, typemap_method_name(temp), Getattr(tm, "type")); Delete(temp); } static void typemap_emit_code_fragments(const_String_or_char_ptr tmap_method, Parm *p) { String *temp = NewStringf("%s:fragment", tmap_method); String *f = Getattr(p, typemap_method_name(temp)); if (f) { String *fname = Copy(f); Setfile(fname, Getfile(p)); Setline(fname, Getline(p)); Swig_fragment_emit(fname); Delete(fname); } Delete(temp); } static String *typemap_get_option(Hash *tm, const_String_or_char_ptr name) { Parm *kw = Getattr(tm, "kwargs"); while (kw) { String *kname = Getattr(kw, "name"); if (Equal(kname, name)) { return Getattr(kw, "value"); } kw = nextSibling(kw); } return 0; } /* ----------------------------------------------------------------------------- * Swig_typemap_attach_parms() * * Given a parameter list, this function attaches all of the typemaps and typemap * attributes to the parameter for each type in the parameter list. * * This function basically provides the typemap code and typemap attribute values as * attributes on each parameter prefixed with "tmap:". For example with tmap_method="in", the typemap * code can be retrieved for the first parameter with a call to Getattr(parm, "tmap:in") * and the "numinputs" attribute can be retrieved with a call to Getattr(parm, "tmap:in:numinputs"). * * tmap_method - typemap method, eg "in", "out", "newfree" * parms - parameter list to attach each typemap and all typemap attributes * f - wrapper code to generate into if non null * ----------------------------------------------------------------------------- */ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f) { Parm *p, *firstp; Hash *tm; int nmatch = 0; int i; String *s; String *warning = 0; ParmList *locals; int argnum = 0; char temp[256]; char *cmethod = Char(tmap_method); String *kwmatch = 0; p = parms; #ifdef SWIG_DEBUG Printf(stdout, "Swig_typemap_attach_parms: %s\n", tmap_method); #endif while (p) { argnum++; nmatch = 0; #ifdef SWIG_DEBUG Printf(stdout, "parms: %s %s %s\n", tmap_method, Getattr(p, "name"), Getattr(p, "type")); #endif tm = typemap_search_multi(tmap_method, p, &nmatch); #ifdef SWIG_DEBUG if (tm) Printf(stdout, "found: %s\n", tm); #endif if (!tm) { p = nextSibling(p); continue; } /* Check if the typemap requires to match the type of another typemap, for example: %typemap(in) SWIGTYPE * (int var) {...} %typemap(freearg,match="in") SWIGTYPE * {if (var$argnum) ...} here, the freearg typemap requires the "in" typemap to match, or the 'var$argnum' variable will not exist. */ kwmatch = typemap_get_option(tm, "match"); if (kwmatch) { String *tmname = NewStringf("tmap:%s", kwmatch); String *tmin = Getattr(p, tmname); Delete(tmname); #ifdef SWIG_DEBUG if (tm) Printf(stdout, "matching: %s\n", kwmatch); #endif if (tmin) { String *tmninp = NewStringf("tmap:%s:numinputs", kwmatch); String *ninp = Getattr(p, tmninp); Delete(tmninp); if (ninp && Equal(ninp, "0")) { p = nextSibling(p); continue; } else { SwigType *typetm = Getattr(tm, "type"); String *temp = NewStringf("tmap:%s:match_type", kwmatch); SwigType *typein = Getattr(p, temp); Delete(temp); if (!Equal(typein, typetm)) { p = nextSibling(p); continue; } else { int nnmatch; Hash *tmapin = typemap_search_multi(kwmatch, p, &nnmatch); String *tmname = Getattr(tm, "pname"); String *tnname = Getattr(tmapin, "pname"); if (!(tmname && tnname && Equal(tmname, tnname)) && !(!tmname && !tnname)) { p = nextSibling(p); continue; } } } } else { p = nextSibling(p); continue; } } s = Getattr(tm, "code"); if (!s) { p = nextSibling(p); continue; } #ifdef SWIG_DEBUG if (s) Printf(stdout, "code: %s\n", s); #endif /* Empty typemap. No match */ if (Cmp(s, "pass") == 0) { p = nextSibling(p); continue; } s = Copy(s); locals = Getattr(tm, "locals"); if (locals) locals = CopyParmList(locals); firstp = p; #ifdef SWIG_DEBUG Printf(stdout, "nmatch: %d\n", nmatch); #endif for (i = 0; i < nmatch; i++) { SwigType *type = Getattr(p, "type"); String *pname = Getattr(p, "name"); String *lname = Getattr(p, "lname"); SwigType *mtype = Getattr(p, "tmap:match"); SwigType *matchtype = mtype ? mtype : type; typemap_replace_vars(s, locals, matchtype, type, pname, lname, i + 1); if (mtype) Delattr(p, "tmap:match"); if (Checkattr(tm, "type", "SWIGTYPE")) { sprintf(temp, "%s:SWIGTYPE", cmethod); Setattr(p, typemap_method_name(temp), "1"); } p = nextSibling(p); } if (locals && f) { typemap_locals(s, locals, f, argnum); } replace_embedded_typemap(s, firstp, f, tm); /* Attach attributes to object */ #ifdef SWIG_DEBUG Printf(stdout, "attach: %s %s %s\n", Getattr(firstp, "name"), typemap_method_name(tmap_method), s); #endif Setattr(firstp, typemap_method_name(tmap_method), s); /* Code object */ if (locals) { sprintf(temp, "%s:locals", cmethod); Setattr(firstp, typemap_method_name(temp), locals); Delete(locals); } /* Attach a link to the next parameter. Needed for multimaps */ sprintf(temp, "%s:next", cmethod); Setattr(firstp, typemap_method_name(temp), p); /* Attach kwargs */ typemap_attach_kwargs(tm, tmap_method, firstp); /* Replace the argument number */ sprintf(temp, "%d", argnum); Replace(s, "$argnum", temp, DOH_REPLACE_ANY); /* Print warnings, if any */ warning = typemap_warn(tmap_method, firstp); if (warning) { SwigType *type = Getattr(firstp, "type"); String *pname = Getattr(firstp, "name"); String *lname = Getattr(firstp, "lname"); SwigType *mtype = Getattr(firstp, "tmap:match"); SwigType *matchtype = mtype ? mtype : type; typemap_replace_vars(warning, 0, matchtype, type, pname, lname, 1); Replace(warning, "$argnum", temp, DOH_REPLACE_ANY); Swig_warning(0, Getfile(firstp), Getline(firstp), "%s\n", warning); Delete(warning); } /* Look for code fragments */ typemap_emit_code_fragments(tmap_method, firstp); /* increase argnum to consider numinputs */ argnum += nmatch - 1; Delete(s); #ifdef SWIG_DEBUG Printf(stdout, "res: %s %s %s\n", Getattr(firstp, "name"), typemap_method_name(tmap_method), Getattr(firstp, typemap_method_name(tmap_method))); #endif } #ifdef SWIG_DEBUG Printf(stdout, "Swig_typemap_attach_parms: end\n"); #endif } /* Splits the arguments of an embedded typemap */ static List *split_embedded_typemap(String *s) { List *args = 0; char *c, *start; int level = 0; int angle_level = 0; int leading = 1; args = NewList(); c = strchr(Char(s), '('); assert(c); c++; start = c; while (*c) { if (*c == '\"') { c++; while (*c) { if (*c == '\\') { c++; } else { if (*c == '\"') break; } c++; } } if ((level == 0) && angle_level == 0 && ((*c == ',') || (*c == ')'))) { String *tmp = NewStringWithSize(start, c - start); Append(args, tmp); Delete(tmp); start = c + 1; leading = 1; if (*c == ')') break; c++; continue; } if (*c == '(') level++; if (*c == ')') level--; if (*c == '<') angle_level++; if (*c == '>') angle_level--; if (isspace((int) *c) && leading) start++; if (!isspace((int) *c)) leading = 0; c++; } return args; } /* ----------------------------------------------------------------------------- * replace_embedded_typemap() * * This function replaces the special variable macro $typemap(...) with typemap * code. The general form of $typemap is as follows: * * $typemap(method, typelist, var1=value, var2=value, ...) * * where varx parameters are optional and undocumented; they were used in an earlier version of $typemap. * A search is made using the typemap matching rules of form: * * %typemap(method) typelist {...} * * and if found will substitute in the typemap contents, making appropriate variable replacements. * * For example: * $typemap(in, int) # simple usage matching %typemap(in) int { ... } * $typemap(in, int b) # simple usage matching %typemap(in) int b { ... } or above %typemap * $typemap(in, (Foo a, int b)) # multi-argument typemap matching %typemap(in) (Foo a, int b) {...} * ----------------------------------------------------------------------------- */ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f, Node *file_line_node) { char *start = 0; while ((start = strstr(Char(s), "$TYPEMAP("))) { /* note $typemap capitalisation to $TYPEMAP hack */ /* Gather the parameters */ char *end = 0, *c; int level = 0; String *dollar_typemap; int syntax_error = 1; c = start; while (*c) { if (*c == '(') level++; if (*c == ')') { level--; if (level == 0) { end = c + 1; break; } } c++; } if (end) { dollar_typemap = NewStringWithSize(start, (end - start)); syntax_error = 0; } else { dollar_typemap = NewStringWithSize(start, (c - start)); } if (!syntax_error) { List *l; String *tmap_method; Hash *vars; syntax_error = 1; /* Split apart each parameter in $typemap(...) */ l = split_embedded_typemap(dollar_typemap); if (Len(l) >= 2) { ParmList *to_match_parms; tmap_method = Getitem(l, 0); /* the second parameter might contain multiple sub-parameters for multi-argument * typemap matching, so split these parameters apart */ to_match_parms = Swig_cparse_parms(Getitem(l, 1), file_line_node); if (to_match_parms) { Parm *p = to_match_parms; Parm *sub_p = parm_sublist; String *empty_string = NewStringEmpty(); String *lname = empty_string; while (p) { if (sub_p) { lname = Getattr(sub_p, "lname"); sub_p = nextSibling(sub_p); } Setattr(p, "lname", lname); p = nextSibling(p); } Delete(empty_string); } /* process optional extra parameters - the variable replacements (undocumented) */ vars = NewHash(); { int i, ilen; ilen = Len(l); for (i = 2; i < ilen; i++) { String *parm = Getitem(l, i); char *eq = strchr(Char(parm), '='); char *c = Char(parm); if (eq && (eq - c > 0)) { String *name = NewStringWithSize(c, eq - c); String *value = NewString(eq + 1); Insert(name, 0, "$"); Setattr(vars, name, value); } else { to_match_parms = 0; /* error - variable replacement parameters must be of form varname=value */ } } } /* Perform a typemap search */ if (to_match_parms) { static int already_substituting = 0; String *tm; String *attr; int match = 0; #ifdef SWIG_DEBUG Printf(stdout, "Swig_typemap_attach_parms: embedded\n"); #endif if (already_substituting < 10) { already_substituting++; if ((in_typemap_search_multi == 0) && typemap_search_debug) { String *dtypemap = NewString(dollar_typemap); Replaceall(dtypemap, "$TYPEMAP", "$typemap"); Printf(stdout, " Containing: %s\n", dtypemap); Delete(dtypemap); } Swig_typemap_attach_parms(tmap_method, to_match_parms, f); already_substituting--; /* Look for the typemap code */ attr = NewStringf("tmap:%s", tmap_method); tm = Getattr(to_match_parms, attr); if (tm) { Printf(attr, "%s", ":next"); /* fail if multi-argument lookup requested in $typemap(...) and the lookup failed */ if (!Getattr(to_match_parms, attr)) { /* Replace parameter variables */ Iterator ki; for (ki = First(vars); ki.key; ki = Next(ki)) { Replace(tm, ki.key, ki.item, DOH_REPLACE_ANY); } /* offer the target language module the chance to make special variable substitutions */ Language_replace_special_variables(tmap_method, tm, to_match_parms); /* finish up - do the substitution */ Replace(s, dollar_typemap, tm, DOH_REPLACE_ANY); Delete(tm); match = 1; } } if (!match) { String *dtypemap = NewString(dollar_typemap); Replaceall(dtypemap, "$TYPEMAP", "$typemap"); Swig_error(Getfile(s), Getline(s), "No typemap found for %s\n", dtypemap); Delete(dtypemap); } Delete(attr); } else { /* Simple recursive call check to prevent infinite recursion - this strategy only allows a limited * number of calls by a embedded typemaps to other embedded typemaps though */ String *dtypemap = NewString(dollar_typemap); Replaceall(dtypemap, "$TYPEMAP", "$typemap"); Swig_error(Getfile(s), Getline(s), "Likely recursive $typemap calls containing %s. Use -debug-tmsearch to debug.\n", dtypemap); Delete(dtypemap); } syntax_error = 0; } Delete(vars); } Delete(l); } if (syntax_error) { String *dtypemap = NewString(dollar_typemap); Replaceall(dtypemap, "$TYPEMAP", "$typemap"); Swig_error(Getfile(s), Getline(s), "Syntax error in: %s\n", dtypemap); Delete(dtypemap); } Replace(s, dollar_typemap, "", DOH_REPLACE_ANY); Delete(dollar_typemap); } } /* ----------------------------------------------------------------------------- * Swig_typemap_debug() * * Display all typemaps * ----------------------------------------------------------------------------- */ void Swig_typemap_debug() { int ts; int nesting_level = 2; Printf(stdout, "---[ typemaps ]--------------------------------------------------------------\n"); ts = tm_scope; while (ts >= 0) { Printf(stdout, "::: scope %d\n\n", ts); Swig_print(typemaps[ts], nesting_level); ts--; } Printf(stdout, "-----------------------------------------------------------------------------\n"); } /* ----------------------------------------------------------------------------- * Swig_typemap_search_debug_set() * * Turn on typemap searching debug display * ----------------------------------------------------------------------------- */ void Swig_typemap_search_debug_set(void) { typemap_search_debug = 1; } /* ----------------------------------------------------------------------------- * Swig_typemap_used_debug_set() * * Turn on typemaps used debug display * ----------------------------------------------------------------------------- */ void Swig_typemap_used_debug_set(void) { typemaps_used_debug = 1; } /* ----------------------------------------------------------------------------- * Swig_typemap_register_debug_set() * * Turn on typemaps used debug display * ----------------------------------------------------------------------------- */ void Swig_typemap_register_debug_set(void) { typemap_register_debug = 1; } swig-3.0.2/Source/Swig/swigparm.h0000664000175000017500000000276712343605122016532 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * swigparm.h * * Functions related to the handling of function/method parameters and * parameter lists. * ----------------------------------------------------------------------------- */ /* Individual parameters */ extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *from_node); extern Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name); extern Parm *NewParmNode(SwigType *type, Node *from_node); extern Parm *CopyParm(Parm *p); /* Parameter lists */ extern ParmList *CopyParmList(ParmList *); extern ParmList *CopyParmListMax(ParmList *, int count); extern int ParmList_len(ParmList *); extern int ParmList_numrequired(ParmList *); extern int ParmList_has_defaultargs(ParmList *p); /* Output functions */ extern String *ParmList_str(ParmList *); extern String *ParmList_str_defaultargs(ParmList *); extern String *ParmList_str_multibrackets(ParmList *); extern String *ParmList_protostr(ParmList *); swig-3.0.2/Source/Preprocessor/0000775000175000017500000000000012343605122016271 5ustar williamwilliamswig-3.0.2/Source/Preprocessor/expr.c0000664000175000017500000003032712343605122017420 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * expr.c * * Integer arithmetic expression evaluator used to handle expressions * encountered during preprocessing. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "preprocessor.h" static Scanner *scan = 0; typedef struct { int op; long value; String *svalue; } exprval; #define EXPR_TOP 1 #define EXPR_VALUE 2 #define EXPR_OP 3 #define EXPR_GROUP 4 #define EXPR_UMINUS 100 static exprval stack[256]; /* Parsing stack */ static int sp = 0; /* Stack pointer */ static int prec[256]; /* Precedence rules */ static int expr_init = 0; /* Initialization flag */ static const char *errmsg = 0; /* Parsing error */ /* Initialize the precedence table for various operators. Low values have higher precedence */ static void init_precedence() { prec[SWIG_TOKEN_NOT] = 10; prec[EXPR_UMINUS] = 10; prec[SWIG_TOKEN_STAR] = 20; prec[SWIG_TOKEN_SLASH] = 20; prec[SWIG_TOKEN_PERCENT] = 20; prec[SWIG_TOKEN_PLUS] = 30; prec[SWIG_TOKEN_MINUS] = 30; prec[SWIG_TOKEN_LSHIFT] = 40; prec[SWIG_TOKEN_RSHIFT] = 40; prec[SWIG_TOKEN_AND] = 50; prec[SWIG_TOKEN_XOR] = 60; prec[SWIG_TOKEN_OR] = 70; prec[SWIG_TOKEN_EQUALTO] = 80; prec[SWIG_TOKEN_NOTEQUAL] = 80; prec[SWIG_TOKEN_LESSTHAN] = 80; prec[SWIG_TOKEN_GREATERTHAN] = 80; prec[SWIG_TOKEN_LTEQUAL] = 80; prec[SWIG_TOKEN_GTEQUAL] = 80; prec[SWIG_TOKEN_LNOT] = 90; prec[SWIG_TOKEN_LAND] = 100; prec[SWIG_TOKEN_LOR] = 110; expr_init = 1; } #define UNARY_OP(token) (((token) == SWIG_TOKEN_NOT) || \ ((token) == SWIG_TOKEN_LNOT) || \ ((token) == EXPR_UMINUS)) /* Reduce a single operator on the stack */ /* return 0 on failure, 1 on success */ static int reduce_op() { long op_token = stack[sp - 1].value; assert(sp > 0); assert(stack[sp - 1].op == EXPR_OP); /* do some basic checking first: */ if (stack[sp].op != EXPR_VALUE) { errmsg = "Right-hand side is not value"; return 0; } if (UNARY_OP(op_token)) { if (stack[sp].svalue) { errmsg = "Syntax error: attempt to apply unary operator to string"; return 0; } } else { /* binary operator: */ if (sp == 1) { /* top of stack: don't attempt to use sp-2! */ errmsg = "Missing left-hand side for binary operator"; return 0; } if (stack[sp].op != EXPR_VALUE) { errmsg = "Left-hand side of binary operator is not a value"; return 0; } if ((!stack[sp - 2].svalue) != (!stack[sp].svalue)) { errmsg = "Can't mix strings and integers in expression"; return 0; } } if (stack[sp].svalue) { /* A binary string expression */ switch (stack[sp - 1].value) { case SWIG_TOKEN_EQUALTO: stack[sp - 2].value = (Strcmp(stack[sp - 2].svalue, stack[sp].svalue) == 0); Delete(stack[sp - 2].svalue); Delete(stack[sp].svalue); sp -= 2; break; case SWIG_TOKEN_NOTEQUAL: stack[sp - 2].value = (Strcmp(stack[sp - 2].svalue, stack[sp].svalue) != 0); Delete(stack[sp - 2].svalue); Delete(stack[sp].svalue); sp -= 2; break; default: errmsg = "Syntax error: bad binary operator for strings"; return 0; break; } } else { switch (op_token) { case SWIG_TOKEN_STAR: stack[sp - 2].value = stack[sp - 2].value * stack[sp].value; sp -= 2; break; case SWIG_TOKEN_EQUALTO: stack[sp - 2].value = stack[sp - 2].value == stack[sp].value; sp -= 2; break; case SWIG_TOKEN_NOTEQUAL: stack[sp - 2].value = stack[sp - 2].value != stack[sp].value; sp -= 2; break; case SWIG_TOKEN_PLUS: stack[sp - 2].value = stack[sp - 2].value + stack[sp].value; sp -= 2; break; case SWIG_TOKEN_MINUS: stack[sp - 2].value = stack[sp - 2].value - stack[sp].value; sp -= 2; break; case SWIG_TOKEN_AND: stack[sp - 2].value = stack[sp - 2].value & stack[sp].value; sp -= 2; break; case SWIG_TOKEN_LAND: stack[sp - 2].value = stack[sp - 2].value && stack[sp].value; sp -= 2; break; case SWIG_TOKEN_OR: stack[sp - 2].value = stack[sp - 2].value | stack[sp].value; sp -= 2; break; case SWIG_TOKEN_LOR: stack[sp - 2].value = stack[sp - 2].value || stack[sp].value; sp -= 2; break; case SWIG_TOKEN_XOR: stack[sp - 2].value = stack[sp - 2].value ^ stack[sp].value; sp -= 2; break; case SWIG_TOKEN_LESSTHAN: stack[sp - 2].value = stack[sp - 2].value < stack[sp].value; sp -= 2; break; case SWIG_TOKEN_GREATERTHAN: stack[sp - 2].value = stack[sp - 2].value > stack[sp].value; sp -= 2; break; case SWIG_TOKEN_LTEQUAL: stack[sp - 2].value = stack[sp - 2].value <= stack[sp].value; sp -= 2; break; case SWIG_TOKEN_GTEQUAL: stack[sp - 2].value = stack[sp - 2].value >= stack[sp].value; sp -= 2; break; case SWIG_TOKEN_NOT: stack[sp - 1].value = ~stack[sp].value; sp--; break; case SWIG_TOKEN_LNOT: stack[sp - 1].value = !stack[sp].value; sp--; break; case EXPR_UMINUS: stack[sp - 1].value = -stack[sp].value; sp--; break; case SWIG_TOKEN_SLASH: stack[sp - 2].value = stack[sp - 2].value / stack[sp].value; sp -= 2; break; case SWIG_TOKEN_PERCENT: stack[sp - 2].value = stack[sp - 2].value % stack[sp].value; sp -= 2; break; case SWIG_TOKEN_LSHIFT: stack[sp - 2].value = stack[sp - 2].value << stack[sp].value; sp -= 2; break; case SWIG_TOKEN_RSHIFT: stack[sp - 2].value = stack[sp - 2].value >> stack[sp].value; sp -= 2; break; default: errmsg = "Syntax error: bad operator"; return 0; break; } } stack[sp].op = EXPR_VALUE; stack[sp].svalue = 0; /* ensure it's not a string! */ return 1; } /* ----------------------------------------------------------------------------- * Preprocessor_expr_init() * * Initialize the expression evaluator * ----------------------------------------------------------------------------- */ void Preprocessor_expr_init(void) { if (!expr_init) init_precedence(); if (!scan) scan = NewScanner(); } void Preprocessor_expr_delete(void) { DelScanner(scan); } /* ----------------------------------------------------------------------------- * Tokenizer * ----------------------------------------------------------------------------- */ static int expr_token(Scanner * s) { int t; while (1) { t = Scanner_token(s); if (!((t == SWIG_TOKEN_BACKSLASH) || (t == SWIG_TOKEN_ENDLINE) || (t == SWIG_TOKEN_COMMENT))) break; } return t; } /* ----------------------------------------------------------------------------- * Preprocessor_expr() * * Evaluates an arithmetic expression. Returns the result and sets an error code. * ----------------------------------------------------------------------------- */ int Preprocessor_expr(DOH *s, int *error) { int token = 0; int op = 0; sp = 0; assert(s); assert(scan); Seek(s, 0, SEEK_SET); /* Printf(stdout,"evaluating : '%s'\n", s); */ *error = 0; Scanner_clear(scan); Scanner_push(scan, s); /* Put initial state onto the stack */ stack[sp].op = EXPR_TOP; stack[sp].value = 0; while (1) { /* Look at the top of the stack */ switch (stack[sp].op) { case EXPR_TOP: /* An expression. Can be a number or another expression enclosed in parens */ token = expr_token(scan); if (!token) { errmsg = "Expected an expression"; *error = 1; return 0; } if ((token == SWIG_TOKEN_INT) || (token == SWIG_TOKEN_UINT) || (token == SWIG_TOKEN_LONG) || (token == SWIG_TOKEN_ULONG)) { /* A number. Reduce EXPR_TOP to an EXPR_VALUE */ char *c = Char(Scanner_text(scan)); stack[sp].value = (long) strtol(c, 0, 0); stack[sp].svalue = 0; /* stack[sp].value = (long) atol(Char(Scanner_text(scan))); */ stack[sp].op = EXPR_VALUE; } else if (token == SWIG_TOKEN_PLUS) { } else if ((token == SWIG_TOKEN_MINUS) || (token == SWIG_TOKEN_LNOT) || (token == SWIG_TOKEN_NOT)) { if (token == SWIG_TOKEN_MINUS) token = EXPR_UMINUS; stack[sp].value = token; stack[sp++].op = EXPR_OP; stack[sp].op = EXPR_TOP; stack[sp].svalue = 0; } else if (token == SWIG_TOKEN_LPAREN) { stack[sp++].op = EXPR_GROUP; stack[sp].op = EXPR_TOP; stack[sp].value = 0; stack[sp].svalue = 0; } else if (token == SWIG_TOKEN_ENDLINE) { } else if (token == SWIG_TOKEN_STRING) { stack[sp].svalue = NewString(Scanner_text(scan)); stack[sp].op = EXPR_VALUE; } else if (token == SWIG_TOKEN_ID) { stack[sp].value = 0; stack[sp].svalue = 0; stack[sp].op = EXPR_VALUE; } else goto syntax_error; break; case EXPR_VALUE: /* A value is on the stack. We may reduce or evaluate depending on what the next token is */ token = expr_token(scan); if (!token) { /* End of input. Might have to reduce if an operator is on stack */ while (sp > 0) { if (stack[sp - 1].op == EXPR_OP) { if (!reduce_op()) goto reduce_error; } else if (stack[sp - 1].op == EXPR_GROUP) { errmsg = "Missing \')\'"; *error = 1; return 0; } else goto syntax_error; } return stack[sp].value; } /* Token must be an operator */ switch (token) { case SWIG_TOKEN_STAR: case SWIG_TOKEN_EQUALTO: case SWIG_TOKEN_NOTEQUAL: case SWIG_TOKEN_PLUS: case SWIG_TOKEN_MINUS: case SWIG_TOKEN_AND: case SWIG_TOKEN_LAND: case SWIG_TOKEN_OR: case SWIG_TOKEN_LOR: case SWIG_TOKEN_XOR: case SWIG_TOKEN_LESSTHAN: case SWIG_TOKEN_GREATERTHAN: case SWIG_TOKEN_LTEQUAL: case SWIG_TOKEN_GTEQUAL: case SWIG_TOKEN_SLASH: case SWIG_TOKEN_PERCENT: case SWIG_TOKEN_LSHIFT: case SWIG_TOKEN_RSHIFT: if ((sp == 0) || (stack[sp - 1].op == EXPR_GROUP)) { /* No possibility of reduce. Push operator and expression */ sp++; stack[sp].op = EXPR_OP; stack[sp].value = token; sp++; stack[sp].op = EXPR_TOP; stack[sp].value = 0; } else { if (stack[sp - 1].op != EXPR_OP) goto syntax_error_expected_operator; op = stack[sp - 1].value; /* Previous operator */ /* Now, depending on the precedence relationship between the last operator and the current we will reduce or push */ if (prec[op] <= prec[token]) { /* Reduce the previous operator */ if (!reduce_op()) goto reduce_error; } sp++; stack[sp].op = EXPR_OP; stack[sp].value = token; sp++; stack[sp].op = EXPR_TOP; stack[sp].value = 0; } break; case SWIG_TOKEN_RPAREN: if (sp == 0) goto extra_rparen; /* Might have to reduce operators first */ while ((sp > 0) && (stack[sp - 1].op == EXPR_OP)) { if (!reduce_op()) goto reduce_error; } if ((sp == 0) || (stack[sp - 1].op != EXPR_GROUP)) goto extra_rparen; stack[sp - 1].op = EXPR_VALUE; stack[sp - 1].value = stack[sp].value; sp--; break; default: goto syntax_error_expected_operator; break; } break; default: fprintf(stderr, "Internal error in expression evaluator.\n"); abort(); } } syntax_error: errmsg = "Syntax error"; *error = 1; return 0; syntax_error_expected_operator: errmsg = "Syntax error: expected operator"; *error = 1; return 0; reduce_error: /* errmsg has been set by reduce_op */ *error = 1; return 0; extra_rparen: errmsg = "Extra \')\'"; *error = 1; return 0; } /* ----------------------------------------------------------------------------- * Preprocessor_expr_error() * * Return error message set by the evaluator (if any) * ----------------------------------------------------------------------------- */ const char *Preprocessor_expr_error() { return errmsg; } swig-3.0.2/Source/Preprocessor/cpp.c0000664000175000017500000014526512343605122017234 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * cpp.c * * An implementation of a C preprocessor plus some support for additional * SWIG directives. * * - SWIG directives such as %include, %extern, and %import are handled * - A new macro %define ... %enddef can be used for multiline macros * - No preprocessing is performed in %{ ... %} blocks * - Lines beginning with %# are stripped down to #... and passed through. * ----------------------------------------------------------------------------- */ #include "swig.h" #include "preprocessor.h" #include static Hash *cpp = 0; /* C preprocessor data */ static int include_all = 0; /* Follow all includes */ static int ignore_missing = 0; static int import_all = 0; /* Follow all includes, but as %import statements */ static int imported_depth = 0; /* Depth of %imported files */ static int single_include = 1; /* Only include each file once */ static Hash *included_files = 0; static List *dependencies = 0; static Scanner *id_scan = 0; static int error_as_warning = 0; /* Understand the cpp #error directive as a special #warning */ static int expand_defined_operator = 0; static int macro_level = 0; static int macro_start_line = 0; static const String * macro_start_file = 0; /* Test a character to see if it starts an identifier */ #define isidentifier(c) ((isalpha(c)) || (c == '_') || (c == '$')) /* Test a character to see if it valid in an identifier (after the first letter) */ #define isidchar(c) ((isalnum(c)) || (c == '_') || (c == '$')) static DOH *Preprocessor_replace(DOH *); /* Skip whitespace */ static void skip_whitespace(String *s, String *out) { int c; while ((c = Getc(s)) != EOF) { if (!isspace(c)) { Ungetc(c, s); break; } else if (out) Putc(c, out); } } /* Skip to a specified character taking line breaks into account */ static int skip_tochar(String *s, int ch, String *out) { int c; while ((c = Getc(s)) != EOF) { if (out) Putc(c, out); if (c == ch) break; if (c == '\\') { c = Getc(s); if ((c != EOF) && (out)) Putc(c, out); } } if (c == EOF) return -1; return 0; } static void copy_location(const DOH *s1, DOH *s2) { Setfile(s2, Getfile((DOH *) s1)); Setline(s2, Getline((DOH *) s1)); } static String *cpp_include(const_String_or_char_ptr fn, int sysfile) { String *s = sysfile ? Swig_include_sys(fn) : Swig_include(fn); if (s && single_include) { String *file = Getfile(s); if (Getattr(included_files, file)) { Delete(s); return 0; } Setattr(included_files, file, file); } if (!s) { if (ignore_missing) { Swig_warning(WARN_PP_MISSING_FILE, Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn); } else { Swig_error(Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn); } } else { String *lf; Seek(s, 0, SEEK_SET); if (!dependencies) { dependencies = NewList(); } lf = Copy(Swig_last_file()); Append(dependencies, lf); Delete(lf); } return s; } List *Preprocessor_depend(void) { return dependencies; } /* ----------------------------------------------------------------------------- * void Preprocessor_cpp_init() - Initialize the preprocessor * ----------------------------------------------------------------------------- */ static String *kpp_args = 0; static String *kpp_define = 0; static String *kpp_defined = 0; static String *kpp_elif = 0; static String *kpp_else = 0; static String *kpp_endif = 0; static String *kpp_expanded = 0; static String *kpp_if = 0; static String *kpp_ifdef = 0; static String *kpp_ifndef = 0; static String *kpp_name = 0; static String *kpp_swigmacro = 0; static String *kpp_symbols = 0; static String *kpp_undef = 0; static String *kpp_value = 0; static String *kpp_varargs = 0; static String *kpp_error = 0; static String *kpp_warning = 0; static String *kpp_line = 0; static String *kpp_include = 0; static String *kpp_pragma = 0; static String *kpp_level = 0; static String *kpp_dline = 0; static String *kpp_ddefine = 0; static String *kpp_dinclude = 0; static String *kpp_dimport = 0; static String *kpp_dbeginfile = 0; static String *kpp_dextern = 0; static String *kpp_LINE = 0; static String *kpp_FILE = 0; static String *kpp_hash_if = 0; static String *kpp_hash_elif = 0; void Preprocessor_init(void) { Hash *s; kpp_args = NewString("args"); kpp_define = NewString("define"); kpp_defined = NewString("defined"); kpp_else = NewString("else"); kpp_elif = NewString("elif"); kpp_endif = NewString("endif"); kpp_expanded = NewString("*expanded*"); kpp_if = NewString("if"); kpp_ifdef = NewString("ifdef"); kpp_ifndef = NewString("ifndef"); kpp_name = NewString("name"); kpp_swigmacro = NewString("swigmacro"); kpp_symbols = NewString("symbols"); kpp_undef = NewString("undef"); kpp_value = NewString("value"); kpp_error = NewString("error"); kpp_warning = NewString("warning"); kpp_pragma = NewString("pragma"); kpp_level = NewString("level"); kpp_line = NewString("line"); kpp_include = NewString("include"); kpp_varargs = NewString("varargs"); kpp_dinclude = NewString("%include"); kpp_dimport = NewString("%import"); kpp_dbeginfile = NewString("%beginfile"); kpp_dextern = NewString("%extern"); kpp_ddefine = NewString("%define"); kpp_dline = NewString("%line"); kpp_LINE = NewString("__LINE__"); kpp_FILE = NewString("__FILE__"); kpp_hash_if = NewString("#if"); kpp_hash_elif = NewString("#elif"); cpp = NewHash(); s = NewHash(); Setattr(cpp, kpp_symbols, s); Delete(s); Preprocessor_expr_init(); /* Initialize the expression evaluator */ included_files = NewHash(); id_scan = NewScanner(); } void Preprocessor_delete(void) { Delete(kpp_args); Delete(kpp_define); Delete(kpp_defined); Delete(kpp_else); Delete(kpp_elif); Delete(kpp_endif); Delete(kpp_expanded); Delete(kpp_if); Delete(kpp_ifdef); Delete(kpp_ifndef); Delete(kpp_name); Delete(kpp_swigmacro); Delete(kpp_symbols); Delete(kpp_undef); Delete(kpp_value); Delete(kpp_error); Delete(kpp_warning); Delete(kpp_pragma); Delete(kpp_level); Delete(kpp_line); Delete(kpp_include); Delete(kpp_varargs); Delete(kpp_dinclude); Delete(kpp_dimport); Delete(kpp_dbeginfile); Delete(kpp_dextern); Delete(kpp_ddefine); Delete(kpp_dline); Delete(kpp_LINE); Delete(kpp_FILE); Delete(kpp_hash_if); Delete(kpp_hash_elif); Delete(cpp); Delete(included_files); Preprocessor_expr_delete(); DelScanner(id_scan); Delete(dependencies); Delete(Swig_add_directory(0)); } /* ----------------------------------------------------------------------------- * void Preprocessor_include_all() - Instruct preprocessor to include all files * ----------------------------------------------------------------------------- */ void Preprocessor_include_all(int a) { include_all = a; } void Preprocessor_import_all(int a) { import_all = a; } void Preprocessor_ignore_missing(int a) { ignore_missing = a; } void Preprocessor_error_as_warning(int a) { error_as_warning = a; } /* ----------------------------------------------------------------------------- * Preprocessor_define() * * Defines a new C preprocessor symbol. swigmacro specifies whether or not the macro has * SWIG macro semantics. * ----------------------------------------------------------------------------- */ String *Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr line) { String *argname; String *varargname; char *s, *dots; argname = Copy(str); s = Char(argname); dots = strchr(s, '.'); if (!dots) { Delete(argname); return NULL; } if (strcmp(dots, "...") != 0) { Swig_error(Getfile(line), Getline(line), "Illegal macro argument name '%s'\n", str); Delete(argname); return NULL; } if (dots == s) { varargname = NewString("__VA_ARGS__"); } else { *dots = '\0'; varargname = NewString(s); } Delete(argname); return varargname; } Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { String *macroname = 0, *argstr = 0, *macrovalue = 0, *file = 0, *s = 0; Hash *macro = 0, *symbols = 0, *m1; List *arglist = 0; int c, line; int varargs = 0; String *str; assert(cpp); assert(_str); /* First make sure that string is actually a string */ if (DohCheck(_str)) { s = Copy(_str); copy_location(_str, s); str = s; } else { str = NewString((char *) _str); } Seek(str, 0, SEEK_SET); line = Getline(str); file = Getfile(str); /* Skip over any leading whitespace */ skip_whitespace(str, 0); /* Now look for a macro name */ macroname = NewStringEmpty(); copy_location(str, macroname); while ((c = Getc(str)) != EOF) { if (c == '(') { argstr = NewStringEmpty(); copy_location(str, argstr); /* It is a macro. Go extract its argument string */ while ((c = Getc(str)) != EOF) { if (c == ')') break; else Putc(c, argstr); } if (c != ')') { Swig_error(Getfile(argstr), Getline(argstr), "Missing \')\' in macro parameters\n"); goto macro_error; } break; } else if (isidchar(c) || (c == '%')) { Putc(c, macroname); } else if (isspace(c)) { break; } else if (c == '\\') { c = Getc(str); if (c != '\n') { Ungetc(c, str); Ungetc('\\', str); break; } } else { Ungetc(c, str); break; } } if (!swigmacro) skip_whitespace(str, 0); macrovalue = NewStringEmpty(); copy_location(str, macrovalue); while ((c = Getc(str)) != EOF) { Putc(c, macrovalue); } /* If there are any macro arguments, convert into a list */ if (argstr) { String *argname, *varargname; arglist = NewList(); Seek(argstr, 0, SEEK_SET); argname = NewStringEmpty(); while ((c = Getc(argstr)) != EOF) { if (c == ',') { varargname = Macro_vararg_name(argname, argstr); if (varargname) { Delete(varargname); Swig_error(Getfile(argstr), Getline(argstr), "Variable length macro argument must be last parameter\n"); } else { Append(arglist, argname); } Delete(argname); argname = NewStringEmpty(); } else if (isidchar(c) || (c == '.')) { Putc(c, argname); } else if (!(isspace(c) || (c == '\\'))) { Delete(argname); Swig_error(Getfile(argstr), Getline(argstr), "Illegal character in macro argument name\n"); goto macro_error; } } if (Len(argname)) { /* Check for varargs */ varargname = Macro_vararg_name(argname, argstr); if (varargname) { Append(arglist, varargname); Delete(varargname); varargs = 1; } else { Append(arglist, argname); } } Delete(argname); } if (!swigmacro) { Replace(macrovalue, "\\\n", " ", DOH_REPLACE_NOQUOTE); } /* Look for special # substitutions. We only consider # that appears outside of quotes and comments */ { int state = 0; char *cc = Char(macrovalue); while (*cc) { switch (state) { case 0: if (*cc == '#') *cc = '\001'; else if (*cc == '/') state = 10; else if (*cc == '\'') state = 20; else if (*cc == '\"') state = 30; break; case 10: if (*cc == '*') state = 11; else if (*cc == '/') state = 15; else { state = 0; cc--; } break; case 11: if (*cc == '*') state = 12; break; case 12: if (*cc == '/') state = 0; else if (*cc != '*') state = 11; break; case 15: if (*cc == '\n') state = 0; break; case 20: if (*cc == '\'') state = 0; if (*cc == '\\') state = 21; break; case 21: state = 20; break; case 30: if (*cc == '\"') state = 0; if (*cc == '\\') state = 31; break; case 31: state = 30; break; default: break; } cc++; } } /* Get rid of whitespace surrounding # */ /* Replace(macrovalue,"#","\001",DOH_REPLACE_NOQUOTE); */ while (strstr(Char(macrovalue), "\001 ")) { Replace(macrovalue, "\001 ", "\001", DOH_REPLACE_ANY); } while (strstr(Char(macrovalue), " \001")) { Replace(macrovalue, " \001", "\001", DOH_REPLACE_ANY); } /* Replace '##' with a special token */ Replace(macrovalue, "\001\001", "\002", DOH_REPLACE_ANY); /* Replace '#@' with a special token */ Replace(macrovalue, "\001@", "\004", DOH_REPLACE_ANY); /* Replace '##@' with a special token */ Replace(macrovalue, "\002@", "\005", DOH_REPLACE_ANY); /* Go create the macro */ macro = NewHash(); Setattr(macro, kpp_name, macroname); if (arglist) { Setattr(macro, kpp_args, arglist); Delete(arglist); if (varargs) { Setattr(macro, kpp_varargs, "1"); } } Setattr(macro, kpp_value, macrovalue); Setline(macro, line); Setfile(macro, file); if (swigmacro) { Setattr(macro, kpp_swigmacro, "1"); } symbols = Getattr(cpp, kpp_symbols); if ((m1 = Getattr(symbols, macroname))) { if (!Checkattr(m1, kpp_value, macrovalue)) { Swig_error(Getfile(macroname), Getline(macroname), "Macro '%s' redefined,\n", macroname); Swig_error(Getfile(m1), Getline(m1), "previous definition of '%s'.\n", macroname); goto macro_error; } } else { Setattr(symbols, macroname, macro); Delete(macro); } Delete(macroname); Delete(macrovalue); Delete(str); Delete(argstr); return macro; macro_error: Delete(str); Delete(argstr); Delete(arglist); Delete(macroname); Delete(macrovalue); return 0; } /* ----------------------------------------------------------------------------- * Preprocessor_undef() * * Undefines a macro. * ----------------------------------------------------------------------------- */ void Preprocessor_undef(const_String_or_char_ptr str) { Hash *symbols; assert(cpp); symbols = Getattr(cpp, kpp_symbols); Delattr(symbols, str); } /* ----------------------------------------------------------------------------- * find_args() * * Isolates macro arguments and returns them in a list. For each argument, * leading and trailing whitespace is stripped (ala K&R, pg. 230). * ----------------------------------------------------------------------------- */ static List *find_args(String *s, int ismacro, String *macro_name) { List *args; String *str; int c, level; long pos; /* Create a new list */ args = NewList(); copy_location(s, args); /* First look for a '(' */ pos = Tell(s); skip_whitespace(s, 0); /* Now see if the next character is a '(' */ c = Getc(s); if (c != '(') { /* Not a macro, bail out now! */ assert(pos != -1); (void)Seek(s, pos, SEEK_SET); Delete(args); return 0; } c = Getc(s); /* Okay. This appears to be a macro so we will start isolating arguments */ while (c != EOF) { if (isspace(c)) { skip_whitespace(s, 0); /* Skip leading whitespace */ c = Getc(s); } str = NewStringEmpty(); copy_location(s, str); level = 0; while (c != EOF) { if (c == '\"') { Putc(c, str); skip_tochar(s, '\"', str); c = Getc(s); continue; } else if (c == '\'') { Putc(c, str); skip_tochar(s, '\'', str); c = Getc(s); continue; } if ((c == ',') && (level == 0)) break; if ((c == ')') && (level == 0)) break; Putc(c, str); if (c == '(') level++; if (c == ')') level--; c = Getc(s); } if (level > 0) { goto unterm; } Chop(str); if (Len(args) || Len(str)) Append(args, str); Delete(str); /* if (Len(str) && (c != ')')) Append(args,str); */ if (c == ')') return args; c = Getc(s); } unterm: if (ismacro) Swig_error(Getfile(args), Getline(args), "Unterminated call invoking macro '%s'\n", macro_name); else Swig_error(Getfile(args), Getline(args), "Unterminated call to '%s'\n", macro_name); return args; } /* ----------------------------------------------------------------------------- * DOH *get_filename() * * Read a filename from str. A filename can be enclosed in quotes, angle brackets, * or bare. * ----------------------------------------------------------------------------- */ static String *get_filename(String *str, int *sysfile) { String *fn; int c; fn = NewStringEmpty(); copy_location(str, fn); c = Getc(str); *sysfile = 0; if (c == '\"') { while (((c = Getc(str)) != EOF) && (c != '\"')) Putc(c, fn); } else if (c == '<') { *sysfile = 1; while (((c = Getc(str)) != EOF) && (c != '>')) Putc(c, fn); } else { String *preprocessed_str; Putc(c, fn); while (((c = Getc(str)) != EOF) && (!isspace(c))) Putc(c, fn); if (isspace(c)) Ungetc(c, str); preprocessed_str = Preprocessor_replace(fn); Seek(preprocessed_str, 0, SEEK_SET); Delete(fn); fn = NewStringEmpty(); copy_location(preprocessed_str, fn); c = Getc(preprocessed_str); if (c == '\"') { while (((c = Getc(preprocessed_str)) != EOF) && (c != '\"')) Putc(c, fn); } else if (c == '<') { *sysfile = 1; while (((c = Getc(preprocessed_str)) != EOF) && (c != '>')) Putc(c, fn); } else { fn = Copy(preprocessed_str); } Delete(preprocessed_str); } Swig_filename_unescape(fn); Swig_filename_correct(fn); Seek(fn, 0, SEEK_SET); return fn; } static String *get_options(String *str) { int c; c = Getc(str); if (c == '(') { String *opt; int level = 1; opt = NewString("("); while (((c = Getc(str)) != EOF)) { Putc(c, opt); if (c == ')') { level--; if (!level) return opt; } if (c == '(') level++; } Delete(opt); return 0; } else { Ungetc(c, str); return 0; } } /* ----------------------------------------------------------------------------- * expand_macro() * * Perform macro expansion and return a new string. Returns NULL if some sort * of error occurred. * name - name of the macro * args - arguments passed to the macro * line_file - only used for line/file name when reporting errors * ----------------------------------------------------------------------------- */ static String *expand_macro(String *name, List *args, String *line_file) { String *ns; DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e; int i, l; int isvarargs = 0; symbols = Getattr(cpp, kpp_symbols); if (!symbols) return 0; /* See if the name is actually defined */ macro = Getattr(symbols, name); if (!macro) return 0; if (macro_level == 0) { /* Store the start of the macro should the macro contain __LINE__ and __FILE__ for expansion */ macro_start_line = Getline(args ? args : line_file); macro_start_file = Getfile(args ? args : line_file); } macro_level++; if (Getattr(macro, kpp_expanded)) { ns = NewStringEmpty(); Append(ns, name); if (args) { int lenargs = Len(args); if (lenargs) Putc('(', ns); for (i = 0; i < lenargs; i++) { Append(ns, Getitem(args, i)); if (i < (lenargs - 1)) Putc(',', ns); } if (i) Putc(')', ns); } macro_level--; return ns; } /* Get macro arguments and value */ mvalue = Getattr(macro, kpp_value); assert(mvalue); margs = Getattr(macro, kpp_args); if (args && Getattr(macro, kpp_varargs)) { isvarargs = 1; /* Variable length argument macro. We need to collect all of the extra arguments into a single argument */ if (Len(args) >= (Len(margs) - 1)) { int i; int vi, na; String *vararg = NewStringEmpty(); vi = Len(margs) - 1; na = Len(args); for (i = vi; i < na; i++) { Append(vararg, Getitem(args, i)); if ((i + 1) < na) { Append(vararg, ","); } } /* Remove arguments */ for (i = vi; i < na; i++) { Delitem(args, vi); } Append(args, vararg); Delete(vararg); } } /* If there are arguments, see if they match what we were given */ if (args && (margs) && (Len(margs) != Len(args))) { if (Len(margs) > (1 + isvarargs)) Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs); else if (Len(margs) == (1 + isvarargs)) Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects 1 argument\n", name); else Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects no arguments\n", name); macro_level--; return 0; } /* If the macro expects arguments, but none were supplied, we leave it in place */ if (!args && (margs) && Len(margs) > 0) { macro_level--; return NewString(name); } /* Copy the macro value */ ns = Copy(mvalue); copy_location(mvalue, ns); /* Tag the macro as being expanded. This is to avoid recursion in macro expansion */ temp = NewStringEmpty(); tempa = NewStringEmpty(); if (args && margs) { l = Len(margs); for (i = 0; i < l; i++) { DOH *arg, *aname; String *reparg; arg = Getitem(args, i); /* Get an argument value */ reparg = Preprocessor_replace(arg); aname = Getitem(margs, i); /* Get macro argument name */ if (strstr(Char(ns), "\001")) { /* Try to replace a quoted version of the argument */ Clear(temp); Clear(tempa); Printf(temp, "\001%s", aname); Printf(tempa, "\"%s\"", arg); Replace(ns, temp, tempa, DOH_REPLACE_ID_END); } if (strstr(Char(ns), "\002")) { /* Look for concatenation tokens */ Clear(temp); Clear(tempa); Printf(temp, "\002%s", aname); Append(tempa, "\002\003"); Replace(ns, temp, tempa, DOH_REPLACE_ID_END); Clear(temp); Clear(tempa); Printf(temp, "%s\002", aname); Append(tempa, "\003\002"); Replace(ns, temp, tempa, DOH_REPLACE_ID_BEGIN); } /* Non-standard macro expansion. The value `x` is replaced by a quoted version of the argument except that if the argument is already quoted nothing happens */ if (strchr(Char(ns), '`')) { String *rep; char *c; Clear(temp); Printf(temp, "`%s`", aname); c = Char(arg); if (*c == '\"') { rep = arg; } else { Clear(tempa); Printf(tempa, "\"%s\"", arg); rep = tempa; } Replace(ns, temp, rep, DOH_REPLACE_ANY); } /* Non-standard mangle expansions. The #@Name is replaced by mangle_arg(Name). */ if (strstr(Char(ns), "\004")) { String *marg = Swig_string_mangle(arg); Clear(temp); Printf(temp, "\004%s", aname); Replace(ns, temp, marg, DOH_REPLACE_ID_END); Delete(marg); } if (strstr(Char(ns), "\005")) { String *marg = Swig_string_mangle(arg); Clear(temp); Clear(tempa); Printf(temp, "\005%s", aname); Printf(tempa, "\"%s\"", marg); Replace(ns, temp, tempa, DOH_REPLACE_ID_END); Delete(marg); } if (isvarargs && i == l - 1 && Len(arg) == 0) { /* Zero length varargs macro argument. We search for commas that might appear before and nuke them */ char *a, *s, *t, *name; int namelen; s = Char(ns); name = Char(aname); namelen = Len(aname); a = strstr(s, name); while (a) { char ca = a[namelen + 1]; if (!isidchar((int) ca)) { /* Matched the entire vararg name, not just a prefix */ t = a - 1; if (*t == '\002') { t--; while (t >= s) { if (isspace((int) *t)) t--; else if (*t == ',') { *t = ' '; } else break; } } } a = strstr(a + namelen, name); } } /* Replace(ns, aname, arg, DOH_REPLACE_ID); */ Replace(ns, aname, reparg, DOH_REPLACE_ID); /* Replace expanded args */ Replace(ns, "\003", arg, DOH_REPLACE_ANY); /* Replace unexpanded arg */ Delete(reparg); } } Replace(ns, "\002", "", DOH_REPLACE_ANY); /* Get rid of concatenation tokens */ Replace(ns, "\001", "#", DOH_REPLACE_ANY); /* Put # back (non-standard C) */ Replace(ns, "\004", "#@", DOH_REPLACE_ANY); /* Put # back (non-standard C) */ /* Expand this macro even further */ Setattr(macro, kpp_expanded, "1"); e = Preprocessor_replace(ns); Delattr(macro, kpp_expanded); Delete(ns); if (Getattr(macro, kpp_swigmacro)) { String *g; String *f = NewStringEmpty(); Seek(e, 0, SEEK_SET); copy_location(macro, e); g = Preprocessor_parse(e); #if 0 /* Drop the macro in place, but with a marker around it */ Printf(f, "/*@%s,%d,%s@*/%s/*@@*/", Getfile(macro), Getline(macro), name, g); #else /* Use simplified around markers to properly count lines in cscanner.c */ if (strchr(Char(g), '\n')) { Printf(f, "/*@SWIG:%s,%d,%s@*/%s/*@SWIG@*/", Getfile(macro), Getline(macro), name, g); #if 0 Printf(f, "/*@SWIG:%s@*/%s/*@SWIG@*/", name, g); #endif } else { Append(f, g); } #endif Delete(g); Delete(e); e = f; } macro_level--; Delete(temp); Delete(tempa); return e; } /* ----------------------------------------------------------------------------- * DOH *Preprocessor_replace(DOH *s) * * Performs a macro substitution on a string s. Returns a new string with * substitutions applied. This function works by walking down s and looking * for identifiers. When found, a check is made to see if they are macros * which are then expanded. * ----------------------------------------------------------------------------- */ /* #define SWIG_PUT_BUFF */ static DOH *Preprocessor_replace(DOH *s) { DOH *ns, *symbols, *m; int c, i, state = 0; String *id = NewStringEmpty(); assert(cpp); symbols = Getattr(cpp, kpp_symbols); ns = NewStringEmpty(); copy_location(s, ns); Seek(s, 0, SEEK_SET); /* Try to locate identifiers in s and replace them with macro replacements */ while ((c = Getc(s)) != EOF) { switch (state) { case 0: if (isidentifier(c)) { Clear(id); Putc(c, id); state = 4; } else if (c == '%') { Clear(id); Putc(c, id); state = 2; } else if (c == '#') { Clear(id); Putc(c, id); state = 4; } else if (c == '\"') { Putc(c, ns); skip_tochar(s, '\"', ns); } else if (c == '\'') { Putc(c, ns); skip_tochar(s, '\'', ns); } else if (c == '/') { Putc(c, ns); state = 10; } else if (c == '\\') { Putc(c, ns); c = Getc(s); if (c == '\n') { Putc(c, ns); } else { Ungetc(c, s); } } else if (c == '\n') { Putc(c, ns); expand_defined_operator = 0; } else { Putc(c, ns); } break; case 2: /* Found '%#' */ if (c == '#') { Putc(c, id); state = 4; } else { Ungetc(c, s); state = 4; } break; case 4: /* An identifier */ if (isidchar(c)) { Putc(c, id); state = 4; } else { /* We found the end of a valid identifier */ Ungetc(c, s); /* See if this is the special "defined" operator */ if (Equal(kpp_defined, id)) { if (expand_defined_operator) { int lenargs = 0; DOH *args = 0; /* See whether or not a parenthesis has been used */ skip_whitespace(s, 0); c = Getc(s); if (c == '(') { Ungetc(c, s); args = find_args(s, 0, kpp_defined); } else if (isidchar(c)) { DOH *arg = NewStringEmpty(); args = NewList(); Putc(c, arg); while (((c = Getc(s)) != EOF)) { if (!isidchar(c)) { Ungetc(c, s); break; } Putc(c, arg); } if (Len(arg)) Append(args, arg); Delete(arg); } else { Seek(s, -1, SEEK_CUR); } lenargs = Len(args); if ((!args) || (!lenargs)) { /* This is not a defined() operator. */ Append(ns, id); state = 0; break; } for (i = 0; i < lenargs; i++) { DOH *o = Getitem(args, i); if (!Getattr(symbols, o)) { break; } } if (i < lenargs) Putc('0', ns); else Putc('1', ns); Delete(args); } else { Append(ns, id); } state = 0; break; } else if (Equal(kpp_LINE, id)) { Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s)); state = 0; break; } else if (Equal(kpp_FILE, id)) { String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s)); Replaceall(fn, "\\", "\\\\"); Printf(ns, "\"%s\"", fn); Delete(fn); state = 0; break; } else if (Equal(kpp_hash_if, id) || Equal(kpp_hash_elif, id)) { expand_defined_operator = 1; Append(ns, id); /* } else if (Equal("%#if", id) || Equal("%#ifdef", id)) { Swig_warning(998, Getfile(s), Getline(s), "Found: %s preprocessor directive.\n", id); Append(ns, id); } else if (Equal("#ifdef", id) || Equal("#ifndef", id)) { Swig_warning(998, Getfile(s), Getline(s), "The %s preprocessor directive does not work in macros, try #if instead.\n", id); Append(ns, id); */ } else if ((m = Getattr(symbols, id))) { /* See if the macro is defined in the preprocessor symbol table */ DOH *args = 0; DOH *e; int macro_additional_lines = 0; /* See if the macro expects arguments */ if (Getattr(m, kpp_args)) { /* Yep. We need to go find the arguments and do a substitution */ int line = Getline(s); args = find_args(s, 1, id); macro_additional_lines = Getline(s) - line; assert(macro_additional_lines >= 0); if (!Len(args)) { Delete(args); args = 0; } } else { args = 0; } e = expand_macro(id, args, s); if (e) { Append(ns, e); } while (macro_additional_lines--) { Putc('\n', ns); } Delete(e); Delete(args); } else { Append(ns, id); } state = 0; } break; case 10: if (c == '/') state = 11; else if (c == '*') state = 12; else { Ungetc(c, s); state = 0; break; } Putc(c, ns); break; case 11: /* in C++ comment */ Putc(c, ns); if (c == '\n') { expand_defined_operator = 0; state = 0; } break; case 12: /* in C comment */ Putc(c, ns); if (c == '*') state = 13; break; case 13: Putc(c, ns); if (c == '/') state = 0; else if (c != '*') state = 12; break; default: state = 0; break; } } /* Identifier at the end */ if (state == 2 || state == 4) { /* See if this is the special "defined" operator */ if (Equal(kpp_defined, id)) { Swig_error(Getfile(s), Getline(s), "No arguments given to defined()\n"); } else if (Equal(kpp_LINE, id)) { Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s)); } else if (Equal(kpp_FILE, id)) { String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s)); Replaceall(fn, "\\", "\\\\"); Printf(ns, "\"%s\"", fn); Delete(fn); } else if (Getattr(symbols, id)) { DOH *e; /* Yes. There is a macro here */ /* See if the macro expects arguments */ e = expand_macro(id, 0, s); if (e) Append(ns, e); Delete(e); } else { Append(ns, id); } } Delete(id); return ns; } /* ----------------------------------------------------------------------------- * int checkpp_id(DOH *s) * * Checks the string s to see if it contains any unresolved identifiers. This * function contains the heuristic that determines whether or not a macro * definition passes through the preprocessor as a constant declaration. * ----------------------------------------------------------------------------- */ static int checkpp_id(DOH *s) { int c; int hastok = 0; Scanner *scan = id_scan; Seek(s, 0, SEEK_SET); Scanner_clear(scan); s = Copy(s); Seek(s, SEEK_SET, 0); Scanner_push(scan, s); while ((c = Scanner_token(scan))) { hastok = 1; if ((c == SWIG_TOKEN_ID) || (c == SWIG_TOKEN_LBRACE) || (c == SWIG_TOKEN_RBRACE)) return 1; } if (!hastok) return 1; return 0; } /* addline(). Utility function for adding lines to a chunk */ static void addline(DOH *s1, DOH *s2, int allow) { if (allow) { Append(s1, s2); } else { char *c = Char(s2); while (*c) { if (*c == '\n') Putc('\n', s1); c++; } } } static void add_chunk(DOH *ns, DOH *chunk, int allow) { DOH *echunk; Seek(chunk, 0, SEEK_SET); if (allow) { echunk = Preprocessor_replace(chunk); addline(ns, echunk, allow); Delete(echunk); } else { addline(ns, chunk, 0); } Clear(chunk); } /* push/pop_imported(): helper functions for defining and undefining SWIGIMPORTED (when %importing a file). */ static void push_imported() { if (imported_depth == 0) { Preprocessor_define("SWIGIMPORTED 1", 0); } ++imported_depth; } static void pop_imported() { --imported_depth; if (imported_depth == 0) { Preprocessor_undef("SWIGIMPORTED"); } } /* ----------------------------------------------------------------------------- * Preprocessor_parse() * * Parses the string s. Returns a new string containing the preprocessed version. * * Parsing rules : * 1. Lines starting with # are C preprocessor directives * 2. Macro expansion inside strings is not allowed * 3. All code inside false conditionals is changed to blank lines * 4. Code in %{, %} is not parsed because it may need to be * included inline (with all preprocessor directives included). * ----------------------------------------------------------------------------- */ String *Preprocessor_parse(String *s) { String *ns; /* New string containing the preprocessed text */ String *chunk, *decl; Hash *symbols; String *id = 0, *value = 0, *comment = 0; int i, state, e, c; int start_line = 0; int allow = 1; int level = 0; int dlevel = 0; int filelevel = 0; int mask = 0; int start_level = 0; int cpp_lines = 0; int cond_lines[256]; /* Blow away all carriage returns */ Replace(s, "\015", "", DOH_REPLACE_ANY); ns = NewStringEmpty(); /* Return result */ decl = NewStringEmpty(); id = NewStringEmpty(); value = NewStringEmpty(); comment = NewStringEmpty(); chunk = NewStringEmpty(); copy_location(s, chunk); copy_location(s, ns); symbols = Getattr(cpp, kpp_symbols); state = 0; while ((c = Getc(s)) != EOF) { switch (state) { case 0: /* Initial state - in first column */ /* Look for C preprocessor directives. Otherwise, go directly to state 1 */ if (c == '#') { copy_location(s, chunk); add_chunk(ns, chunk, allow); cpp_lines = 1; state = 40; } else if (isspace(c)) { Putc(c, chunk); skip_whitespace(s, chunk); } else { state = 1; Ungetc(c, s); } break; case 1: /* Non-preprocessor directive */ /* Look for SWIG directives */ if (c == '%') { state = 100; break; } Putc(c, chunk); if (c == '\n') state = 0; else if (c == '\"') { start_line = Getline(s); if (skip_tochar(s, '\"', chunk) < 0) { Swig_error(Getfile(s), -1, "Unterminated string constant starting at line %d\n", start_line); } } else if (c == '\'') { start_line = Getline(s); if (skip_tochar(s, '\'', chunk) < 0) { Swig_error(Getfile(s), -1, "Unterminated character constant starting at line %d\n", start_line); } } else if (c == '/') state = 30; /* Comment */ break; case 30: /* Possibly a comment string of some sort */ start_line = Getline(s); Putc(c, chunk); if (c == '/') state = 31; else if (c == '*') state = 32; else state = 1; break; case 31: Putc(c, chunk); if (c == '\n') state = 0; break; case 32: Putc(c, chunk); if (c == '*') state = 33; break; case 33: Putc(c, chunk); if (c == '/') state = 1; else if (c != '*') state = 32; break; case 40: /* Start of a C preprocessor directive */ if (c == '\n') { Putc('\n', chunk); state = 0; } else if (isspace(c)) { state = 40; } else { /* Got the start of a preprocessor directive */ Ungetc(c, s); Clear(id); copy_location(s, id); state = 41; } break; case 41: /* Build up the name of the preprocessor directive */ if ((isspace(c) || (!isalpha(c)))) { Clear(value); Clear(comment); if (c == '\n') { Ungetc(c, s); state = 50; } else { state = 42; if (!isspace(c)) { Ungetc(c, s); } } copy_location(s, value); break; } Putc(c, id); break; case 42: /* Strip any leading space before preprocessor value */ if (isspace(c)) { if (c == '\n') { Ungetc(c, s); state = 50; } break; } state = 43; /* no break intended here */ case 43: /* Get preprocessor value */ if (c == '\n') { Ungetc(c, s); state = 50; } else if (c == '/') { state = 45; } else if (c == '\"') { Putc(c, value); skip_tochar(s, '\"', value); } else if (c == '\'') { Putc(c, value); skip_tochar(s, '\'', value); } else { Putc(c, value); if (c == '\\') state = 44; } break; case 44: if (c == '\n') { Putc(c, value); cpp_lines++; } else { Ungetc(c, s); } state = 43; break; /* States 45-48 are used to remove, but retain comments from macro values. The comments will be placed in the output in an alternative form */ case 45: if (c == '/') state = 46; else if (c == '*') state = 47; else if (c == '\n') { Putc('/', value); Ungetc(c, s); state = 50; } else { Putc('/', value); Putc(c, value); state = 43; } break; case 46: /* in C++ comment */ if (c == '\n') { Ungetc(c, s); state = 50; } else Putc(c, comment); break; case 47: /* in C comment */ if (c == '*') state = 48; else Putc(c, comment); break; case 48: if (c == '/') state = 43; else if (c == '*') Putc(c, comment); else { Putc('*', comment); Putc(c, comment); state = 47; } break; case 50: /* Check for various preprocessor directives */ Chop(value); if (Equal(id, kpp_define)) { if (allow) { DOH *m, *v, *v1; Seek(value, 0, SEEK_SET); m = Preprocessor_define(value, 0); if ((m) && !(Getattr(m, kpp_args))) { v = Copy(Getattr(m, kpp_value)); copy_location(m, v); if (Len(v)) { Swig_error_silent(1); v1 = Preprocessor_replace(v); Swig_error_silent(0); /* Printf(stdout,"checking '%s'\n", v1); */ if (!checkpp_id(v1)) { if (Len(comment) == 0) Printf(ns, "%%constant %s = %s;\n", Getattr(m, kpp_name), v1); else Printf(ns, "%%constant %s = %s; /*%s*/\n", Getattr(m, kpp_name), v1, comment); cpp_lines--; } Delete(v1); } Delete(v); } } } else if (Equal(id, kpp_undef)) { if (allow) Preprocessor_undef(value); } else if (Equal(id, kpp_ifdef)) { cond_lines[level] = Getline(id); level++; if (allow) { start_level = level; if (Len(value) > 0) { /* See if the identifier is in the hash table */ if (!Getattr(symbols, value)) allow = 0; } else { Swig_error(Getfile(s), Getline(id), "Missing identifier for #ifdef.\n"); allow = 0; } mask = 1; } } else if (Equal(id, kpp_ifndef)) { cond_lines[level] = Getline(id); level++; if (allow) { start_level = level; if (Len(value) > 0) { /* See if the identifier is in the hash table */ if (Getattr(symbols, value)) allow = 0; } else { Swig_error(Getfile(s), Getline(id), "Missing identifier for #ifndef.\n"); allow = 0; } mask = 1; } } else if (Equal(id, kpp_else)) { if (level <= 0) { Swig_error(Getfile(s), Getline(id), "Misplaced #else.\n"); } else { cond_lines[level - 1] = Getline(id); if (Len(value) != 0) Swig_warning(WARN_PP_UNEXPECTED_TOKENS, Getfile(s), Getline(id), "Unexpected tokens after #else directive.\n"); if (allow) { allow = 0; mask = 0; } else if (level == start_level) { allow = 1 * mask; } } } else if (Equal(id, kpp_endif)) { level--; if (level < 0) { Swig_error(Getfile(id), Getline(id), "Extraneous #endif.\n"); level = 0; } else { if (level < start_level) { if (Len(value) != 0) Swig_warning(WARN_PP_UNEXPECTED_TOKENS, Getfile(s), Getline(id), "Unexpected tokens after #endif directive.\n"); allow = 1; start_level--; } } } else if (Equal(id, kpp_if)) { cond_lines[level] = Getline(id); level++; if (allow) { int val; String *sval; expand_defined_operator = 1; sval = Preprocessor_replace(value); start_level = level; Seek(sval, 0, SEEK_SET); /* Printf(stdout,"Evaluating '%s'\n", sval); */ if (Len(sval) > 0) { val = Preprocessor_expr(sval, &e); if (e) { const char *msg = Preprocessor_expr_error(); Seek(value, 0, SEEK_SET); Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value); if (msg) Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg); allow = 0; } else { if (val == 0) allow = 0; } } else { Swig_error(Getfile(s), Getline(id), "Missing expression for #if.\n"); allow = 0; } expand_defined_operator = 0; mask = 1; } } else if (Equal(id, kpp_elif)) { if (level == 0) { Swig_error(Getfile(s), Getline(id), "Misplaced #elif.\n"); } else { cond_lines[level - 1] = Getline(id); if (allow) { allow = 0; mask = 0; } else if (level == start_level) { int val; String *sval; expand_defined_operator = 1; sval = Preprocessor_replace(value); Seek(sval, 0, SEEK_SET); if (Len(sval) > 0) { val = Preprocessor_expr(sval, &e); if (e) { const char *msg = Preprocessor_expr_error(); Seek(value, 0, SEEK_SET); Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value); if (msg) Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg); allow = 0; } else { if (val) allow = 1 * mask; else allow = 0; } } else { Swig_error(Getfile(s), Getline(id), "Missing expression for #elif.\n"); allow = 0; } expand_defined_operator = 0; } } } else if (Equal(id, kpp_warning)) { if (allow) { Swig_warning(WARN_PP_CPP_WARNING, Getfile(s), Getline(id), "CPP #warning, \"%s\".\n", value); } } else if (Equal(id, kpp_error)) { if (allow) { if (error_as_warning) { Swig_warning(WARN_PP_CPP_ERROR, Getfile(s), Getline(id), "CPP #error \"%s\".\n", value); } else { Swig_error(Getfile(s), Getline(id), "CPP #error \"%s\". Use the -cpperraswarn option to continue swig processing.\n", value); } } } else if (Equal(id, kpp_line)) { } else if (Equal(id, kpp_include)) { if (((include_all) || (import_all)) && (allow)) { String *s1, *s2, *fn; String *dirname; int sysfile = 0; if (include_all && import_all) { Swig_warning(WARN_PP_INCLUDEALL_IMPORTALL, Getfile(s), Getline(id), "Both includeall and importall are defined: using includeall.\n"); import_all = 0; } Seek(value, 0, SEEK_SET); fn = get_filename(value, &sysfile); s1 = cpp_include(fn, sysfile); if (s1) { if (include_all) Printf(ns, "%%includefile \"%s\" %%beginfile\n", Swig_filename_escape(Swig_last_file())); else if (import_all) { Printf(ns, "%%importfile \"%s\" %%beginfile\n", Swig_filename_escape(Swig_last_file())); push_imported(); } /* See if the filename has a directory component */ dirname = Swig_file_dirname(Swig_last_file()); if (sysfile || !Len(dirname)) { Delete(dirname); dirname = 0; } if (dirname) { int len = Len(dirname); Delslice(dirname, len - 1, len); /* Kill trailing directory delimiter */ Swig_push_directory(dirname); } s2 = Preprocessor_parse(s1); addline(ns, s2, allow); Append(ns, "%endoffile"); if (dirname) { Swig_pop_directory(); } if (import_all) { pop_imported(); } Delete(s2); Delete(dirname); Delete(s1); } Delete(fn); } } else if (Equal(id, kpp_pragma)) { if (Strncmp(value, "SWIG ", 5) == 0) { char *c = Char(value) + 5; while (*c && (isspace((int) *c))) c++; if (*c) { if (strncmp(c, "nowarn=", 7) == 0) { String *val = NewString(c + 7); String *nowarn = Preprocessor_replace(val); Swig_warnfilter(nowarn, 1); Delete(nowarn); Delete(val); } else if (strncmp(c, "cpperraswarn=", 13) == 0) { error_as_warning = atoi(c + 13); } else { Swig_error(Getfile(s), Getline(id), "Unknown SWIG pragma: %s\n", c); } } } } else if (Equal(id, kpp_level)) { Swig_error(Getfile(s), Getline(id), "cpp debug: level = %d, startlevel = %d\n", level, start_level); } for (i = 0; i < cpp_lines; i++) Putc('\n', ns); state = 0; break; /* SWIG directives */ case 100: /* %{,%} block */ if (c == '{') { start_line = Getline(s); copy_location(s, chunk); add_chunk(ns, chunk, allow); Putc('%', chunk); Putc(c, chunk); state = 105; } /* %#cpp - an embedded C preprocessor directive (we strip off the %) */ else if (c == '#') { add_chunk(ns, chunk, allow); Putc(c, chunk); state = 107; } else if (isidentifier(c)) { Clear(decl); Putc('%', decl); Putc(c, decl); state = 110; } else { Putc('%', chunk); Putc(c, chunk); state = 1; } break; case 105: Putc(c, chunk); if (c == '%') state = 106; break; case 106: Putc(c, chunk); if (c == '}') { state = 1; addline(ns, chunk, allow); Clear(chunk); copy_location(s, chunk); } else { state = 105; } break; case 107: Putc(c, chunk); if (c == '\n') { addline(ns, chunk, allow); Clear(chunk); state = 0; } else if (c == '\\') { state = 108; } break; case 108: Putc(c, chunk); state = 107; break; case 110: if (!isidchar(c)) { Ungetc(c, s); /* Look for common SWIG directives */ if (Equal(decl, kpp_dinclude) || Equal(decl, kpp_dimport) || Equal(decl, kpp_dextern)) { /* Got some kind of file inclusion directive, eg: %import(option1="value1") "filename" */ if (allow) { DOH *s1, *s2, *fn, *opt; String *options_whitespace = NewStringEmpty(); String *filename_whitespace = NewStringEmpty(); int sysfile = 0; if (Equal(decl, kpp_dextern)) { Swig_warning(WARN_DEPRECATED_EXTERN, Getfile(s), Getline(s), "%%extern is deprecated. Use %%import instead.\n"); Clear(decl); Append(decl, "%%import"); } skip_whitespace(s, options_whitespace); opt = get_options(s); skip_whitespace(s, filename_whitespace); fn = get_filename(s, &sysfile); s1 = cpp_include(fn, sysfile); if (s1) { String *dirname; copy_location(s, chunk); add_chunk(ns, chunk, allow); Printf(ns, "%sfile%s%s%s\"%s\" %%beginfile\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file())); if (Equal(decl, kpp_dimport)) { push_imported(); } dirname = Swig_file_dirname(Swig_last_file()); if (sysfile || !Len(dirname)) { Delete(dirname); dirname = 0; } if (dirname) { int len = Len(dirname); Delslice(dirname, len - 1, len); /* Kill trailing directory delimiter */ Swig_push_directory(dirname); } s2 = Preprocessor_parse(s1); if (dirname) { Swig_pop_directory(); } if (Equal(decl, kpp_dimport)) { pop_imported(); } addline(ns, s2, allow); Append(ns, "%endoffile"); Delete(s2); Delete(dirname); Delete(s1); } Delete(fn); Delete(filename_whitespace); Delete(options_whitespace); } state = 1; } else if (Equal(decl, kpp_dbeginfile)) { /* Got an internal directive marking the beginning of an included file: %beginfile ... %endoffile */ filelevel++; start_line = Getline(s); copy_location(s, chunk); add_chunk(ns, chunk, allow); Append(chunk, decl); state = 120; } else if (Equal(decl, kpp_dline)) { /* Got a line directive */ state = 1; } else if (Equal(decl, kpp_ddefine)) { /* Got a define directive */ dlevel++; copy_location(s, chunk); add_chunk(ns, chunk, allow); Clear(value); copy_location(s, value); state = 150; } else { Append(chunk, decl); state = 1; } } else { Putc(c, decl); } break; /* Searching for the end of a %beginfile block */ case 120: Putc(c, chunk); if (c == '%') { const char *bf = "beginfile"; const char *ef = "endoffile"; char statement[10]; int i = 0; for (i = 0; i < 9;) { c = Getc(s); Putc(c, chunk); statement[i++] = (char)c; if (strncmp(statement, bf, i) && strncmp(statement, ef, i)) break; } c = Getc(s); Ungetc(c, s); if ((i == 9) && (isspace(c))) { if (strncmp(statement, bf, i) == 0) { ++filelevel; } else if (strncmp(statement, ef, i) == 0) { --filelevel; if (!filelevel) { /* Reached end of included file */ addline(ns, chunk, allow); Clear(chunk); copy_location(s, chunk); state = 1; } } } } break; /* Searching for the end of a %define statement */ case 150: Putc(c, value); if (c == '%') { const char *ed = "enddef"; const char *df = "define"; char statement[7]; int i = 0; for (i = 0; i < 6;) { c = Getc(s); Putc(c, value); statement[i++] = (char)c; if (strncmp(statement, ed, i) && strncmp(statement, df, i)) break; } c = Getc(s); Ungetc(c, s); if ((i == 6) && (isspace(c))) { if (strncmp(statement, df, i) == 0) { ++dlevel; } else { if (strncmp(statement, ed, i) == 0) { --dlevel; if (!dlevel) { /* Got the macro */ for (i = 0; i < 7; i++) { Delitem(value, DOH_END); } if (allow) { Seek(value, 0, SEEK_SET); Preprocessor_define(value, 1); } addline(ns, value, 0); state = 0; } } } } } break; default: Printf(stderr, "cpp: Invalid parser state %d\n", state); abort(); break; } } while (level > 0) { Swig_error(Getfile(s), -1, "Missing #endif for conditional starting on line %d\n", cond_lines[level - 1]); level--; } if (state == 120) { Swig_error(Getfile(s), -1, "Missing %%endoffile for file inclusion block starting on line %d\n", start_line); } if (state == 150) { Seek(value, 0, SEEK_SET); Swig_error(Getfile(s), -1, "Missing %%enddef for macro starting on line %d\n", Getline(value)); } if ((state >= 105) && (state < 107)) { Swig_error(Getfile(s), -1, "Unterminated %%{ ... %%} block starting on line %d\n", start_line); } if ((state >= 30) && (state < 40)) { Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line); } copy_location(s, chunk); add_chunk(ns, chunk, allow); /* DelScope(scp); */ Delete(decl); Delete(id); Delete(value); Delete(comment); Delete(chunk); return ns; } swig-3.0.2/Source/Preprocessor/preprocessor.h0000664000175000017500000000273312343605122021175 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * * preprocessor.h * * SWIG preprocessor module. * ----------------------------------------------------------------------------- */ #ifndef SWIG_PREPROCESSOR_H_ #define SWIG_PREPROCESSOR_H_ #include "swigwarn.h" #ifdef __cplusplus extern "C" { #endif extern int Preprocessor_expr(String *s, int *error); extern const char *Preprocessor_expr_error(void); extern Hash *Preprocessor_define(const_String_or_char_ptr str, int swigmacro); extern void Preprocessor_undef(const_String_or_char_ptr name); extern void Preprocessor_init(void); extern void Preprocessor_delete(void); extern String *Preprocessor_parse(String *s); extern void Preprocessor_include_all(int); extern void Preprocessor_import_all(int); extern void Preprocessor_ignore_missing(int); extern void Preprocessor_error_as_warning(int); extern List *Preprocessor_depend(void); extern void Preprocessor_expr_init(void); extern void Preprocessor_expr_delete(void); #ifdef __cplusplus } #endif #endif swig-3.0.2/Tools/0000775000175000017500000000000012343605122013443 5ustar williamwilliamswig-3.0.2/Tools/config/0000775000175000017500000000000012343706574014725 5ustar williamwilliamswig-3.0.2/Tools/config/ax_cxx_compile_stdcxx_11.m40000664000175000017500000001002412343605122022047 0ustar williamwilliam# ============================================================================ # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html # ============================================================================ # # SYNOPSIS # # AX_CXX_COMPILE_STDCXX_11([ext|noext], [nostop]) # # DESCRIPTION # # Check for baseline language coverage in the compiler for the C++11 # standard; if necessary, add switches to CXXFLAGS to enable support. # CXX11FLAGS will also contain any necessary switches to enable support. # HAVE_CXX11_COMPILER will additionally be set to yes if there is support. # If the second argument is not specified, errors out if no mode that # supports C++11 baseline syntax can be found. The first argument, if # specified, indicates whether you insist on an extended mode # (e.g. -std=gnu++11) or a strict conformance mode (e.g. -std=c++11). # If neither is specified, you get whatever works, with preference for an # extended mode. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik # Copyright (c) 2012 Zack Weinberg # Copyright (c) 2012 William Fulton # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 1 m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [ template struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; typedef check> right_angle_brackets; int a; decltype(a) b; typedef check check_type; check_type c; check_type&& cr = static_cast(c); ]) AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl m4_if([$1], [], [], [$1], [ext], [], [$1], [noext], [], [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl m4_if([$2], [], [], [$2], [nostop], [], [m4_fatal([invalid argument `$2' to AX_CXX_COMPILE_STDCXX_11])])dnl AC_LANG_ASSERT([C++])dnl ac_success=no CXX11FLAGS= AC_CACHE_CHECK(whether $CXX supports C++11 features by default, ax_cv_cxx_compile_cxx11, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], [ax_cv_cxx_compile_cxx11=yes], [ax_cv_cxx_compile_cxx11=no])]) if test x$ax_cv_cxx_compile_cxx11 = xyes; then ac_success=yes fi m4_if([$1], [noext], [], [dnl if test x$ac_success = xno; then for switch in -std=gnu++11 -std=gnu++0x; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, $cachevar, [ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], [eval $cachevar=yes], [eval $cachevar=no]) CXXFLAGS="$ac_save_CXXFLAGS"]) if eval test x\$$cachevar = xyes; then CXXFLAGS="$CXXFLAGS $switch" CXX11FLAGS=$switch ac_success=yes break fi done fi]) m4_if([$1], [ext], [], [dnl if test x$ac_success = xno; then for switch in -std=c++11 -std=c++0x; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, $cachevar, [ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], [eval $cachevar=yes], [eval $cachevar=no]) CXXFLAGS="$ac_save_CXXFLAGS"]) if eval test x\$$cachevar = xyes; then CXXFLAGS="$CXXFLAGS $switch" CXX11FLAGS=$switch ac_success=yes break fi done fi]) if test x$ac_success = xno; then if test x$2 != xnostop; then AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) fi else HAVE_CXX11_COMPILER=yes fi ]) swig-3.0.2/Tools/config/ax_path_generic.m40000664000175000017500000001262212343605122020275 0ustar williamwilliam# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_path_generic.html # =========================================================================== # # SYNOPSIS # # AX_PATH_GENERIC(LIBRARY,[MINIMUM-VERSION,[SED-EXPR-EXTRACTOR]],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],[CONFIG-SCRIPTS],[CFLAGS-ARG],[LIBS-ARG]) # # DESCRIPTION # # Runs the LIBRARY-config script and defines LIBRARY_CFLAGS and # LIBRARY_LIBS unless the user had predefined them in the environment. # # The script must support `--cflags' and `--libs' args. If MINIMUM-VERSION # is specified, the script must also support the `--version' arg. If the # `--with-library-[exec-]prefix' arguments to ./configure are given, it # must also support `--prefix' and `--exec-prefix'. Prefereable use # CONFIG-SCRIPTS as config script, CFLAGS-ARG instead of `--cflags` and # LIBS-ARG instead of `--libs`, if given. # # The SED-EXPR-EXTRACTOR parameter representes the expression used in sed # to extract the version number. Use it if your 'foo-config --version' # dumps something like 'Foo library v1.0.0 (alfa)' instead of '1.0.0'. # # The macro respects LIBRARY_CONFIG, LIBRARY_CFLAGS and LIBRARY_LIBS # variables. If the first one is defined, it specifies the name of the # config script to use. If the latter two are defined, the script is not # ran at all and their values are used instead (if only one of them is # defined, the empty value of the remaining one is still used). # # Example: # # AX_PATH_GENERIC(Foo, 1.0.0) # # would run `foo-config --version' and check that it is at least 1.0.0, if # successful the following variables would be defined and substituted: # # FOO_CFLAGS to `foo-config --cflags` # FOO_LIBS to `foo-config --libs` # # Example: # # AX_PATH_GENERIC([Bar],,,[ # AC_MSG_ERROR([Cannot find Bar library]) # ]) # # would check for bar-config program, defining and substituting the # following variables: # # BAR_CFLAGS to `bar-config --cflags` # BAR_LIBS to `bar-config --libs` # # Example: # # ./configure BAZ_LIBS=/usr/lib/libbaz.a # # would link with a static version of baz library even if `baz-config # --libs` returns just "-lbaz" that would normally result in using the # shared library. # # This macro is a rearranged version of AC_PATH_GENERIC from Angus Lees. # # LICENSE # # Copyright (c) 2009 Francesco Salvestrini # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 11 AU_ALIAS([AC_PATH_GENERIC], [AX_PATH_GENERIC]) AC_DEFUN([AX_PATH_GENERIC],[ AC_REQUIRE([AC_PROG_SED]) dnl we're going to need uppercase and lowercase versions of the dnl string `LIBRARY' pushdef([UP], translit([$1], [a-z], [A-Z]))dnl pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl AC_ARG_WITH(DOWN-prefix,[AS_HELP_STRING([--with-]DOWN[-prefix=PREFIX], [Prefix where $1 is installed (optional)])], DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="") AC_ARG_WITH(DOWN-exec-prefix,[AS_HELP_STRING([--with-]DOWN[-exec-prefix=EPREFIX], [Exec prefix where $1 is installed (optional)])], DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="") AC_ARG_VAR(UP[]_CONFIG, [config script used for $1]) AC_ARG_VAR(UP[]_CFLAGS, [CFLAGS used for $1]) AC_ARG_VAR(UP[]_LIBS, [LIBS used for $1]) AS_IF([test x$UP[]_CFLAGS != x -o x$UP[]_LIBS != x],[ dnl Don't run config script at all, use user-provided values instead. AC_SUBST(UP[]_CFLAGS) AC_SUBST(UP[]_LIBS) : $4 ],[ AS_IF([test x$DOWN[]_config_exec_prefix != x],[ DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix" AS_IF([test x${UP[]_CONFIG+set} != xset],[ UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config ]) ]) AS_IF([test x$DOWN[]_config_prefix != x],[ DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix" AS_IF([test x${UP[]_CONFIG+set} != xset],[ UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config ]) ]) AC_PATH_PROGS(UP[]_CONFIG,[$6 DOWN-config],[no]) AS_IF([test "$UP[]_CONFIG" = "no"],[ : $5 ],[ dnl Get the CFLAGS from LIBRARY-config script AS_IF([test x"$7" = x],[ UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`" ],[ UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args $7`" ]) dnl Get the LIBS from LIBRARY-config script AS_IF([test x"$8" = x],[ UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`" ],[ UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args $8`" ]) AS_IF([test x"$2" != x],[ dnl Check for provided library version AS_IF([test x"$3" != x],[ dnl Use provided sed expression DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e $3`" ],[ DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e 's/^\ *\(.*\)\ *$/\1/'`" ]) AC_MSG_CHECKING([for $1 ($DOWN[]_version) >= $2]) AX_COMPARE_VERSION($DOWN[]_version,[ge],[$2],[ AC_MSG_RESULT([yes]) AC_SUBST(UP[]_CFLAGS) AC_SUBST(UP[]_LIBS) : $4 ],[ AC_MSG_RESULT([no]) : $5 ]) ],[ AC_SUBST(UP[]_CFLAGS) AC_SUBST(UP[]_LIBS) : $4 ]) ]) ]) popdef([UP]) popdef([DOWN]) ]) swig-3.0.2/Tools/config/depcomp0000755000175000017500000004755612343706574016321 0ustar williamwilliam#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2011-12-04.11; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, # 2011 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test "$stat" = 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/ \1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/ / G p }' >> "$depfile" rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: swig-3.0.2/Tools/config/install-sh0000755000175000017500000003325612343706574016740 0ustar williamwilliam#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for `test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: swig-3.0.2/Tools/config/ac_compare_version.m40000664000175000017500000000241512343605122021012 0ustar williamwilliamdnl @synopsis AC_COMPARE_VERSION\ dnl (version-a, version-b, action-if-greater, action-if-equal, action-if-less) dnl dnl This macro compares two version numbers and executes the indicated action dnl based on whether they're equal or one is greater than the other. dnl It's needed to determine whether ocaml is new enough that the incompatible dnl change 'loc' -> '_loc' is present in this version of camlp4. dnl dnl It's implemented from scratch just for SWIG by arty. dnl dnl @category Misc dnl @author arty dnl @version 2006-11-02 dnl @license GPLWithACException AC_DEFUN([AC_COMPARE_VERSION], [ # Split the version into units. ver_a="[$1]" ver_b="[$2]" nodots_a=`echo $ver_a | sed -e 's/\./ /g'` condition="equal" isolate_b_regex='\([[0-9]]\+\).*' for ver_part in $nodots_a ; do b_ver_part=`echo "$ver_b" | sed -e 's/'"$isolate_b_regex"'/\1/'` if test \( "$ver_part" -lt "$b_ver_part" \) -a \( "x$condition" = "xequal" \) ; then condition=less elif test \( "$ver_part" -gt "$b_ver_part" \) -a \( "x$condition" = "xequal" \) ; then condition=greater fi isolate_b_regex='[[0-9]]\+\.'"$isolate_b_regex" done if test "x$condition" = "xequal" ; then [$4] elif test "x$condition" = "xless" ; then [$3] elif test "x$condition" = "xgreater" ; then [$5] fi ]) swig-3.0.2/Tools/config/ax_compare_version.m40000664000175000017500000001465212343605122021045 0ustar williamwilliam# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_compare_version.html # =========================================================================== # # SYNOPSIS # # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # # DESCRIPTION # # This macro compares two version strings. Due to the various number of # minor-version numbers that can exist, and the fact that string # comparisons are not compatible with numeric comparisons, this is not # necessarily trivial to do in a autoconf script. This macro makes doing # these comparisons easy. # # The six basic comparisons are available, as well as checking equality # limited to a certain number of minor-version levels. # # The operator OP determines what type of comparison to do, and can be one # of: # # eq - equal (test A == B) # ne - not equal (test A != B) # le - less than or equal (test A <= B) # ge - greater than or equal (test A >= B) # lt - less than (test A < B) # gt - greater than (test A > B) # # Additionally, the eq and ne operator can have a number after it to limit # the test to that number of minor versions. # # eq0 - equal up to the length of the shorter version # ne0 - not equal up to the length of the shorter version # eqN - equal up to N sub-version levels # neN - not equal up to N sub-version levels # # When the condition is true, shell commands ACTION-IF-TRUE are run, # otherwise shell commands ACTION-IF-FALSE are run. The environment # variable 'ax_compare_version' is always set to either 'true' or 'false' # as well. # # Examples: # # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) # AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) # # would both be true. # # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) # AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) # # would both be false. # # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) # # would be true because it is only comparing two minor versions. # # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) # # would be true because it is only comparing the lesser number of minor # versions of the two values. # # Note: The characters that separate the version numbers do not matter. An # empty string is the same as version 0. OP is evaluated by autoconf, not # configure, so must be a string, not a variable. # # The author would like to acknowledge Guido Draheim whose advice about # the m4_case and m4_ifvaln functions make this macro only include the # portions necessary to perform the specific comparison specified by the # OP argument in the final configure script. # # LICENSE # # Copyright (c) 2008 Tim Toolan # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 11 dnl ######################################################################### AC_DEFUN([AX_COMPARE_VERSION], [ AC_REQUIRE([AC_PROG_AWK]) # Used to indicate true or false condition ax_compare_version=false # Convert the two version strings to be compared into a format that # allows a simple string comparison. The end result is that a version # string of the form 1.12.5-r617 will be converted to the form # 0001001200050617. In other words, each number is zero padded to four # digits, and non digits are removed. AS_VAR_PUSHDEF([A],[ax_compare_version_A]) A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` AS_VAR_PUSHDEF([B],[ax_compare_version_B]) B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary dnl # then the first line is used to determine if the condition is true. dnl # The sed right after the echo is to remove any indented white space. m4_case(m4_tolower($2), [lt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [gt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [le],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` ], [ge],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` ],[ dnl Split the operator from the subversion count if present. m4_bmatch(m4_substr($2,2), [0],[ # A count of zero means use the length of the shorter version. # Determine the number of characters in A and B. ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` # Set A to no more than B's length and B to no more than A's length. A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` ], [[0-9]+],[ # A count greater than zero means use only that many subversions A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` ], [.+],[ AC_WARNING( [illegal OP numeric parameter: $2]) ],[]) # Pad zeros at end of numbers to make same length. ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" B="$B`echo $A | sed 's/./0/g'`" A="$ax_compare_version_tmp_A" # Check for equality or inequality as necessary. m4_case(m4_tolower(m4_substr($2,0,2)), [eq],[ test "x$A" = "x$B" && ax_compare_version=true ], [ne],[ test "x$A" != "x$B" && ax_compare_version=true ],[ AC_WARNING([illegal OP parameter: $2]) ]) ]) AS_VAR_POPDEF([A])dnl AS_VAR_POPDEF([B])dnl dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. if test "$ax_compare_version" = "true" ; then m4_ifvaln([$4],[$4],[:])dnl m4_ifvaln([$5],[else $5])dnl fi ]) dnl AX_COMPARE_VERSION swig-3.0.2/Tools/config/ax_boost_base.m40000664000175000017500000002475512343605122017777 0ustar williamwilliam# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_boost_base.html # =========================================================================== # # SYNOPSIS # # AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # DESCRIPTION # # Test for the Boost C++ libraries of a particular version (or newer) # # If no path to the installed boost library is given the macro searchs # under /usr, /usr/local, /opt and /opt/local and evaluates the # $BOOST_ROOT environment variable. Further documentation is available at # . # # This macro calls: # # AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) # # And sets: # # HAVE_BOOST # # LICENSE # # Copyright (c) 2008 Thomas Porschberg # Copyright (c) 2009 Peter Adolphs # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 23 AC_DEFUN([AX_BOOST_BASE], [ AC_ARG_WITH([boost], [AS_HELP_STRING([--with-boost@<:@=ARG@:>@], [use Boost library from a standard location (ARG=yes), from the specified location (ARG=), or disable it (ARG=no) @<:@ARG=yes@:>@ ])], [ if test "$withval" = "no"; then want_boost="no" elif test "$withval" = "yes"; then want_boost="yes" ac_boost_path="" else want_boost="yes" ac_boost_path="$withval" fi ], [want_boost="yes"]) AC_ARG_WITH([boost-libdir], AS_HELP_STRING([--with-boost-libdir=LIB_DIR], [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]), [ if test -d "$withval" then ac_boost_lib_path="$withval" else AC_MSG_ERROR(--with-boost-libdir expected directory name) fi ], [ac_boost_lib_path=""] ) if test "x$want_boost" = "xyes"; then boost_lib_version_req=ifelse([$1], ,1.20.0,$1) boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` if test "x$boost_lib_version_req_sub_minor" = "x" ; then boost_lib_version_req_sub_minor="0" fi WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) succeeded=no dnl On 64-bit systems check for system libraries in both lib64 and lib. dnl The former is specified by FHS, but e.g. Debian does not adhere to dnl this (as it rises problems for generic multi-arch support). dnl The last entry in the list is chosen by default when no libraries dnl are found, e.g. when only header-only libraries are installed! libsubdirs="lib" ax_arch=`uname -m` case $ax_arch in x86_64|ppc64|s390x|sparc64|aarch64) libsubdirs="lib64 lib lib64" ;; esac dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give dnl them priority over the other paths since, if libs are found there, they dnl are almost assuredly the ones desired. AC_REQUIRE([AC_CANONICAL_HOST]) libsubdirs="lib/${host_cpu}-${host_os} $libsubdirs" case ${host_cpu} in i?86) libsubdirs="lib/i386-${host_os} $libsubdirs" ;; esac dnl first we check the system location for boost libraries dnl this location ist chosen if boost libraries are installed with the --layout=system option dnl or if you install boost with RPM if test "$ac_boost_path" != ""; then BOOST_CPPFLAGS="-I$ac_boost_path/include" for ac_boost_path_tmp in $libsubdirs; do if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" break fi done elif test "$cross_compiling" != yes; then for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then for libsubdir in $libsubdirs ; do if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" break; fi done fi dnl overwrite ld flags if we have required special directory with dnl --with-boost-libdir parameter if test "$ac_boost_lib_path" != ""; then BOOST_LDFLAGS="-L$ac_boost_lib_path" fi CPPFLAGS_SAVED="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" export CPPFLAGS LDFLAGS_SAVED="$LDFLAGS" LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" export LDFLAGS AC_REQUIRE([AC_PROG_CXX]) AC_LANG_PUSH(C++) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ @%:@include ]], [[ #if BOOST_VERSION >= $WANT_BOOST_VERSION // Everything is okay #else # error Boost version is too old #endif ]])],[ AC_MSG_RESULT(yes) succeeded=yes found_system=yes ],[ ]) AC_LANG_POP([C++]) dnl if we found no boost with system layout we search for boost libraries dnl built and installed without the --layout=system option or for a staged(not installed) version if test "x$succeeded" != "xyes"; then _version=0 if test "$ac_boost_path" != ""; then if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` V_CHECK=`expr $_version_tmp \> $_version` if test "$V_CHECK" = "1" ; then _version=$_version_tmp fi VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" done fi else if test "$cross_compiling" != yes; then for ac_boost_path in /usr /usr/local /opt /opt/local ; do if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` V_CHECK=`expr $_version_tmp \> $_version` if test "$V_CHECK" = "1" ; then _version=$_version_tmp best_path=$ac_boost_path fi done fi done VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" if test "$ac_boost_lib_path" = ""; then for libsubdir in $libsubdirs ; do if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done BOOST_LDFLAGS="-L$best_path/$libsubdir" fi fi if test "x$BOOST_ROOT" != "x"; then for libsubdir in $libsubdirs ; do if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` V_CHECK=`expr $stage_version_shorten \>\= $_version` if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) BOOST_CPPFLAGS="-I$BOOST_ROOT" BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir" fi fi fi fi CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" export CPPFLAGS LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" export LDFLAGS AC_LANG_PUSH(C++) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ @%:@include ]], [[ #if BOOST_VERSION >= $WANT_BOOST_VERSION // Everything is okay #else # error Boost version is too old #endif ]])],[ AC_MSG_RESULT(yes) succeeded=yes found_system=yes ],[ ]) AC_LANG_POP([C++]) fi if test "$succeeded" != "yes" ; then if test "$_version" = "0" ; then AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) else AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) fi # execute ACTION-IF-NOT-FOUND (if present): ifelse([$3], , :, [$3]) else AC_SUBST(BOOST_CPPFLAGS) AC_SUBST(BOOST_LDFLAGS) AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) # execute ACTION-IF-FOUND (if present): ifelse([$2], , :, [$2]) fi CPPFLAGS="$CPPFLAGS_SAVED" LDFLAGS="$LDFLAGS_SAVED" fi ]) swig-3.0.2/Tools/config/ylwrap0000755000175000017500000001435712343706574016201 0ustar williamwilliam#! /bin/sh # ylwrap - wrapper for lex/yacc invocations. scriptversion=2011-08-25.18; # UTC # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, # 2007, 2009, 2010, 2011 Free Software Foundation, Inc. # # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . case "$1" in '') echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 exit 1 ;; --basedir) basedir=$2 shift 2 ;; -h|--h*) cat <<\EOF Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... Wrapper for lex/yacc invocations, renaming files as desired. INPUT is the input file OUTPUT is one file PROG generates DESIRED is the file we actually want instead of OUTPUT PROGRAM is program to run ARGS are passed to PROG Any number of OUTPUT,DESIRED pairs may be used. Report bugs to . EOF exit $? ;; -v|--v*) echo "ylwrap $scriptversion" exit $? ;; esac # The input. input="$1" shift case "$input" in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input="`pwd`/$input" ;; esac pairlist= while test "$#" -ne 0; do if test "$1" = "--"; then shift break fi pairlist="$pairlist $1" shift done # The program to run. prog="$1" shift # Make any relative path in $prog absolute. case "$prog" in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog="`pwd`/$prog" ;; esac # FIXME: add hostname here for parallel makes that run commands on # other machines. But that might take us over the 14-char limit. dirname=ylwrap$$ do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 mkdir $dirname || exit 1 cd $dirname case $# in 0) "$prog" "$input" ;; *) "$prog" "$@" "$input" ;; esac ret=$? if test $ret -eq 0; then set X $pairlist shift first=yes # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot="no" if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot="yes" fi # The directory holding the input. input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` # Quote $INPUT_DIR so we can use it in a regexp. # FIXME: really we should care about more than `.' and `\'. input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` while test "$#" -ne 0; do from="$1" # Handle y_tab.c and y_tab.h output by DOS if test $y_tab_nodot = "yes"; then if test $from = "y.tab.c"; then from="y_tab.c" else if test $from = "y.tab.h"; then from="y_tab.h" fi fi fi if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend `../'. case "$2" in [\\/]* | ?:[\\/]*) target="$2";; *) target="../$2";; esac # We do not want to overwrite a header file if it hasn't # changed. This avoid useless recompilations. However the # parser itself (the first file) should always be updated, # because it is the destination of the .y.c rule in the # Makefile. Divert the output of all other files to a temporary # file so we can compare them to existing versions. if test $first = no; then realtarget="$target" target="tmp-`echo $target | sed s/.*[\\/]//g`" fi # Edit out `#line' or `#' directives. # # We don't want the resulting debug information to point at # an absolute srcdir; it is better for it to just mention the # .y file with no path. # # We want to use the real output file name, not yy.lex.c for # instance. # # We want the include guards to be adjusted too. FROM=`echo "$from" | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` TARGET=`echo "$2" | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$? # Check whether header files must be updated. if test $first = no; then if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then echo "$2" is unchanged rm -f "$target" else echo updating "$2" mv -f "$target" "$realtarget" fi fi else # A missing file is only an error for the first file. This # is a blatant hack to let us support using "yacc -d". If -d # is not specified, we don't want an error when the header # file is "missing". if test $first = yes; then ret=1 fi fi shift shift first=no done else ret=$? fi # Remove the directory. cd .. rm -rf $dirname exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: swig-3.0.2/Tools/config/ac_define_dir.m40000664000175000017500000000224012343605122017703 0ustar williamwilliamdnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) dnl dnl This macro sets VARNAME to the expansion of the DIR variable, dnl taking care of fixing up ${prefix} and such. dnl dnl VARNAME is then offered as both an output variable and a C dnl preprocessor symbol. dnl dnl Example: dnl dnl AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.]) dnl dnl @category Misc dnl @author Stepan Kasal dnl @author Andreas Schwab dnl @author Guido Draheim dnl @author Alexandre Oliva dnl @version 2005-07-29 dnl @license AllPermissive AC_DEFUN([AC_DEFINE_DIR], [ prefix_NONE= exec_prefix_NONE= test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn dnl refers to ${prefix}. Thus we have to use `eval' twice. eval ac_define_dir="\"[$]$2\"" eval ac_define_dir="\"$ac_define_dir\"" AC_SUBST($1, "$ac_define_dir") AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) test "$prefix_NONE" && prefix=NONE test "$exec_prefix_NONE" && exec_prefix=NONE ]) swig-3.0.2/Tools/config/compile0000755000175000017500000001533712343706574016312 0ustar williamwilliam#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-01-04.17; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free # Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l*) lib=${1#-l} found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes set x "$@" "$dir/$lib.dll.lib" break fi if test -f "$dir/$lib.lib"; then found=yes set x "$@" "$dir/$lib.lib" break fi done IFS=$save_IFS test "$found" != yes && set x "$@" "$lib.lib" shift ;; -L*) func_file_conv "${1#-L}" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: swig-3.0.2/Tools/config/missing0000755000175000017500000002415212343706574016326 0ustar williamwilliam#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: swig-3.0.2/Tools/config/config.guess0000755000175000017500000012743212343706574017254 0ustar williamwilliam#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: swig-3.0.2/Tools/config/ac_compile_warnings.m40000664000175000017500000000335312343605122021161 0ustar williamwilliamdnl @synopsis AC_COMPILE_WARNINGS dnl dnl Set the maximum warning verbosity according to C and C++ compiler used. dnl Currently supports g++ and gcc. dnl dnl The compiler options are always added CFLAGS and CXXFLAGS even if dnl these are overridden at configure time. Removing the maximum warning dnl flags can be removed with --without-maximum-compile-warnings. For example: dnl dnl ./configure --without-maximum-compile-warnings CFLAGS= CXXFLAGS= dnl dnl @category Misc dnl @author Loic Dachary dnl @author William Fulton dnl @version 2005-04-29 dnl @license GPLWithACException AC_DEFUN([AC_COMPILE_WARNINGS], [ AC_MSG_CHECKING([maximum warning verbosity option]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PROG_CXX]) AC_ARG_WITH([maximum-compile-warnings], AS_HELP_STRING([--without-maximum-compile-warnings], [Disable maximum warning verbosity]), [ac_compile_warnings_on="$withval"], [ac_compile_warnings_on=""]) if test x"$ac_compile_warnings_on" = xno then ac_compile_warnings_msg=no else if test -n "$CXX" then if test "$GXX" = "yes" then ac_compile_warnings_opt='-Wall -W -ansi -pedantic' fi CXXFLAGS="$CXXFLAGS $ac_compile_warnings_opt" ac_compile_warnings_msg="$ac_compile_warnings_opt for C++" fi if test -n "$CC" then if test "$GCC" = "yes" then ac_compile_warnings_opt='-Wall -W -ansi -pedantic' fi CFLAGS="$CFLAGS $ac_compile_warnings_opt" ac_compile_warnings_msg="$ac_compile_warnings_msg $ac_compile_warnings_opt for C" fi fi AC_MSG_RESULT([$ac_compile_warnings_msg]) unset ac_compile_warnings_msg unset ac_compile_warnings_opt ]) swig-3.0.2/Tools/config/config.sub0000755000175000017500000010517612343706574016720 0ustar williamwilliam#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: swig-3.0.2/Tools/mkwindows.sh0000775000175000017500000000775312343605122016040 0ustar williamwilliam#!/bin/sh # Build Windows distribution (swigwin-2.0.x.zip) from source tarball (swig-2.0.x.tar.gz) # Requires running in either: # - MinGW environment # - Linux using MinGW cross compiler # - Cygwin using MinGW compiler # path to zip program zip= # options for configure extraconfigureoptions= compileflags="-O2" extracompileflags= if test x$1 != x; then version=$1 if test x$2 != x; then zip=$2; echo zip: $zip; fi else echo "Usage: mkwindows.sh version [zip]" echo " Build SWIG Windows distribution from source tarball. Works on Cygwin, MinGW or Linux" echo " version should be 2.0.x" echo " zip is full path to zip program - default is /c/cygwin/bin/zip on MinGW, zip on Linux and Cygwin" exit 1 fi uname=`uname -a` mingw=`echo "$uname" | grep -i mingw` linux=`echo "$uname" | grep -i linux` cygwin=`echo "$uname" | grep -i cygwin` if test "$mingw"; then echo "Building native Windows executable on MinGW"; if test x$zip = x; then zip=/c/cygwin/bin/zip fi else if test "$linux"; then echo "Building native Windows executable on Linux" if test x$zip = x; then zip=zip fi extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux" else if test "$cygwin"; then echo "Building native Windows executable on Cygwin" if test x$zip = x; then zip=zip fi compileflags="-O2 -mno-cygwin" else echo "Unknown platform. Requires either Linux or MinGW." exit 1; fi fi fi swigbasename=swig-$version swigwinbasename=swigwin-$version tarball=$swigbasename.tar.gz pcre_tarball=`ls pcre-*.tar.*` if ! test -f "$pcre_tarball"; then echo "Could not find PCRE tarball. Please download a PCRE source tarball from http://www.pcre.org" echo "and place in the same directory as the SWIG tarball." exit 1 fi if test -f "$tarball"; then builddir=build-$version if test -e $builddir; then echo "Deleting directory $builddir..." rm -rf $builddir fi echo "Creating directory $builddir..." mkdir $builddir cd $builddir echo "Unzipping tarball..." tar -zxf ../$tarball sleep 2 # fix strange not finding newly created directory if test -d $swigbasename; then mv $swigbasename $swigwinbasename tar -zxf ../$tarball cd $swigbasename (cd ../.. && cp $pcre_tarball $builddir/$swigbasename) echo Running: Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" ./Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1 echo Running: ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1 echo "Compiling (quietly)..." make > build.log echo "Simple check to see if swig.exe runs..." env LD_LIBRARY_PATH= PATH= ./swig.exe -version || exit 1 echo "Simple check to see if ccache-swig.exe runs..." env LD_LIBRARY_PATH= PATH= ./CCache/ccache-swig.exe -V || exit 1 echo "Creating $swigwinbasename.zip..." cd .. cp $swigbasename/swig.exe $swigwinbasename cp $swigbasename/CCache/ccache-swig.exe $swigwinbasename/CCache cp $swigbasename/Lib/swigwarn.swg $swigwinbasename/Lib sleep 2 # fix strange not finding swig.exe echo "Unzip into a directory of your choice. Please read the README file as well as Doc\Manual\Windows.html for installation instructions." > swig_windows_zip_comments.txt rm -f ../$swigwinbasename.zip $zip -q -r -9 -z < swig_windows_zip_comments.txt ../$swigwinbasename.zip $swigwinbasename rm -f swig_windows_zip_comments.txt echo "Cleaning up..." cd .. rm -rf $builddir echo "Finished building $swigwinbasename.zip" else echo "Expecting tarball to create directory: $swigbasename but it does not exist" exit 1 fi else echo tarball missing: $tarball exit 1 fi exit 0 swig-3.0.2/Tools/brew-install0000775000175000017500000000120712343605122015774 0ustar williamwilliam#!/bin/bash # Wrapper around 'brew install' emitting a message every minute if the command is still running. # This is used on Travis to ensure the install isn't killed when there is no output over a long period (10 minutes). # Usage: brew-install package, where package is the name of the package for brew to install. seconds=0 minutes=0 brew install $1 & while true; do ps -p$! 2>& 1>/dev/null if [ $? = 0 ]; then if [ $seconds = 60 ]; then let seconds=0 let minutes=minutes+1 echo "brew install $1 still running ($minutes min)" fi sleep 1 let seconds=seconds+1 else break fi done wait $! exit $? swig-3.0.2/Tools/capitalize0000775000175000017500000000034712343605122015522 0ustar williamwilliam#!/bin/sh # usage: capitalize word # write word to stdout w/ first character upcased first_char=`echo $1 | sed 's/^\(.\).*/\1/' | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` echo ${first_char}`echo $1 | sed 's/^.//'` swig-3.0.2/Tools/swig.gdb0000664000175000017500000000244012343605122015072 0ustar williamwilliam# User-defined commands for easier debugging of SWIG in gdb # # This file can be "included" into your main .gdbinit file using: # source swig.gdb # or otherwise paste the contents into .gdbinit # # Note all user defined commands can be seen using: # (gdb) show user # The documentation for each command can be easily viewed, for example: # (gdb) help swigprint define swigprint if ($argc == 2) set $expand_count = $arg1 else set $expand_count = -1 end Printf "%s\n", Swig_to_string($arg0, $expand_count) end document swigprint Displays any SWIG DOH object Usage: swigprint swigobject [hashexpandcount] swigobject - The object to display. hashexpandcount - Number of nested Hash types to expand (default is 1). See Swig_set_max_hash_expand() to change default. end define locswigprint if ($argc == 2) set $expand_count = $arg1 else set $expand_count = -1 end Printf "%s\n", Swig_to_string_with_location($arg0, $expand_count) end document locswigprint Displays any SWIG DOH object prefixed with file and line location Usage: locswigprint swigobject [hashexpandcount] swigobject - The object to display. hashexpandcount - Number of nested Hash types to expand (default is 1). See Swig_set_max_hash_expand() to change default. end swig-3.0.2/Tools/pyname_patch.py0000664000175000017500000001166412343605122016475 0ustar williamwilliam#!/usr/bin/env python """ From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, since they are inappropriate and discouraged in Python documentation (from http://www.python.org/doc/2.5.2/api/includes.html): "All user visible names defined by Python.h (except those defined by the included standard headers) have one of the prefixes "Py" or "_Py". Names beginning with "_Py" are for internal use by the Python implementation and should not be used by extension writers. Structure member names do not have a reserved prefix. Important: user code should never define names that begin with "Py" or "_Py". This confuses the reader, and jeopardizes the portability of the user code to future Python versions, which may define additional names beginning with one of these prefixes." This file is a simple script used for change all of these symbols, for user code or SWIG itself. """ import re from shutil import copyfile import sys symbols = [ #(old name, new name) ("PySequence_Base", "SwigPySequence_Base"), ("PySequence_Cont", "SwigPySequence_Cont"), ("PySwigIterator_T", "SwigPyIterator_T"), ("PyPairBoolOutputIterator", "SwigPyPairBoolOutputIterator"), ("PySwigIterator", "SwigPyIterator"), ("PySwigIterator_T", "SwigPyIterator_T"), ("PyMapIterator_T", "SwigPyMapIterator_T"), ("PyMapKeyIterator_T", "SwigPyMapKeyIterator_T"), ("PyMapValueIterator_T", "SwigPyMapValueITerator_T"), ("PyObject_ptr", "SwigPtr_PyObject"), ("PyObject_var", "SwigVar_PyObject"), ("PyOper", "SwigPyOper"), ("PySeq", "SwigPySeq"), ("PySequence_ArrowProxy", "SwigPySequence_ArrowProxy"), ("PySequence_Cont", "SwigPySequence_Cont"), ("PySequence_InputIterator", "SwigPySequence_InputIterator"), ("PySequence_Ref", "SwigPySequence_Ref"), ("PySwigClientData", "SwigPyClientData"), ("PySwigClientData_Del", "SwigPyClientData_Del"), ("PySwigClientData_New", "SwigPyClientData_New"), ("PySwigIterator", "SwigPyIterator"), ("PySwigIteratorClosed_T", "SwigPyIteratorClosed_T"), ("PySwigIteratorOpen_T", "SwigPyIteratorOpen_T"), ("PySwigIterator_T", "SwigPyIterator_T"), ("PySwigObject", "SwigPyObject"), ("PySwigObject_Check", "SwigPyObject_Check"), ("PySwigObject_GetDesc", "SwigPyObject_GetDesc"), ("PySwigObject_New", "SwigPyObject_New"), ("PySwigObject_acquire", "SwigPyObject_acquire"), ("PySwigObject_append", "SwigPyObject_append"), ("PySwigObject_as_number", "SwigPyObject_as_number"), ("PySwigObject_compare", "SwigPyObject_compare"), ("PySwigObject_dealloc", "SwigPyObject_dealloc"), ("PySwigObject_disown", "SwigPyObject_disown"), ("PySwigObject_format", "SwigPyObject_format"), ("PySwigObject_getattr", "SwigPyObject_getattr"), ("PySwigObject_hex", "SwigPyObject_hex"), ("PySwigObject_long", "SwigPyObject_long"), ("PySwigObject_next", "SwigPyObject_next"), ("PySwigObject_oct", "SwigPyObject_oct"), ("PySwigObject_own", "SwigPyObject_own"), ("PySwigObject_print", "SwigPyObject_print"), ("PySwigObject_repr", "SwigPyObject_repr"), ("PySwigObject_richcompare", "SwigPyObject_richcompare"), ("PySwigObject_str", "SwigPyObject_str"), ("PySwigObject_type", "SwigPyObject_type"), ("PySwigPacked", "SwigPyPacked"), ("PySwigPacked_Check", "SwigPyPacked_Check"), ("PySwigPacked_New", "SwigPyPacked_New"), ("PySwigPacked_UnpackData", "SwigPyPacked_UnpackData"), ("PySwigPacked_compare", "SwigPyPacked_compare"), ("PySwigPacked_dealloc", "SwigPyPacked_dealloc"), ("PySwigPacked_print", "SwigPyPacked_print"), ("PySwigPacked_repr", "SwigPyPacked_repr"), ("PySwigPacked_str", "SwigPyPacked_str"), ("PySwigPacked_type", "SwigPyPacked_type"), ("pyseq", "swigpyseq"), ("pyswigobject_type", "swigpyobject_type"), ("pyswigpacked_type", "swigpypacked_type"), ] res = [(re.compile("\\b(%s)\\b"%oldname), newname) for oldname, newname in symbols] def patch_file(fn): newf = [] changed = False for line in open(fn): for r, newname in res: line, n = r.subn(newname, line) if n>0: changed = True newf.append(line) if changed: copyfile(fn, fn+".bak") f = open(fn, "w") f.write("".join(newf)) f.close() return changed def main(fns): for fn in fns: try: if patch_file(fn): print "Patched file", fn except IOError: print "Error occurred during patching", fn return if __name__=="__main__": if len(sys.argv) > 1: main(sys.argv[1:]) else: print "Patch your interface file for SWIG's Py* symbol name deprecation." print "Usage:" print " %s files..."%sys.argv[0] swig-3.0.2/Tools/vcfilter0000775000175000017500000000067112343605122015213 0ustar williamwilliam#!/bin/sh # This is a simple utility for Cygwin/Mingw which is useful when running the SWIG # test-suite through Visual Studio. If the output from the test-suite is piped # through this utility, it will filter the junk that the compiler generates. # Typical usage: make check | vcfilter # dos2unix needed for ^ and $ to work. 2>&1 dos2unix | grep -v "\.cxx$" | grep -v "\.c$" | grep -v "^ Creating library" | grep -v "^Generating Code" swig-3.0.2/Tools/setup.py.tmpl0000664000175000017500000001125712343605122016136 0ustar williamwilliam#!@PYTHON@ '''A setup.py script with better SWIG support. To use it, either rename it to setup.py.in and have it pe processed by your configure script (you will need to define @PYTHON@), or replace the @*@ strings by hand. Copyright 2001, Anthony Joseph Seward''' from distutils.core import setup, Extension ############################################################################### ## Start of better Swig support ############################################################################### from distutils.command.build_ext import build_ext import os import string class build_swig_ext(build_ext): '''Better swig support for Distutils''' ## __ Tell Distutils about the options user_options = build_ext.user_options boolean_options = build_ext.boolean_options user_options.append( ('swig-doc=', None, 'what type of documentation should SWIG produce (default: none)') ) user_options.append( ('swig-inc=', None, 'a list of directories to add to the SWIG include path' + "(separated by ':')(default: SWIG)") ) user_options.append( ('swig-shadow', None, 'have SWIG create shadow classes' + ' (also adds docstrings to the shadow classes') ) boolean_options.append('swig-shadow') def initialize_options(self): '''Initialize the new options after the inherited ones''' build_ext.initialize_options(self) self.swig_doc = 'none' self.swig_inc = 'SWIG' self.swig_shadow = None def swig_sources(self, sources): """Override the definition of 'swig_sources' in build_ext. This is essentially the same function but with better swig support. I will now quote the original docstring: Walk the list of source files in 'sources', looking for SWIG interface (.i) files. Run SWIG on all that are found, and return a modified 'sources' list with SWIG source files replaced by the generated C (or C++) files. """ new_sources = [] swig_sources = [] swig_targets = {} # XXX this drops generated C/C++ files into the source tree, which # is fine for developers who want to distribute the generated # source -- but there should be an option to put SWIG output in # the temp dir. if self.swig_cpp: target_ext = '.cpp' else: target_ext = '.c' for source in sources: (base, ext) = os.path.splitext(source) if ext == ".i": # SWIG interface file new_sources.append(base + target_ext) swig_sources.append(source) swig_targets[source] = new_sources[-1] else: new_sources.append(source) if not swig_sources: return new_sources includes = self.swig_inc if type(includes) is type(''): includes = string.split(includes, ':') includes = map(lambda x: '-I'+x, includes) includes = string.join(includes) swig = self.find_swig() ## swig_cmd = [swig, "-python", "-d%s" % self.swig_doc, includes] swig_cmd = [swig, '-v', '-python', '-d%s' % self.swig_doc, includes] if self.swig_cpp: swig_cmd.append('-c++') if self.swig_shadow: swig_cmd.append('-shadow') ## swig1.1 swig_cmd.append('-docstring') for source in swig_sources: target = swig_targets[source] self.announce('swigging %s to %s' % (source, target)) self.spawn(swig_cmd + ['-o', target, source]) return new_sources # swig_sources () ############################################################################### ## End of improved swig support ############################################################################### package = '@PACKAGE@' version = '@VERSION@' include_dirs = ['@top_srcdir@'] lib_dirs = ['@top_srcdir@/@PACKAGE@'] libraries = ['@PACKAGE@', 'stdc++'] setup(name = package, version = version, description = '', author = '', author_email = '', url = 'http://', cmdclass = {'build_ext': build_swig_ext}, ext_modules = [Extension(package+'cmodule', [package+'.i'], include_dirs=include_dirs, library_dirs=lib_dirs, libraries=libraries, )], options = {'build_ext': {'swig_doc': 'html', 'swig_cpp': not None, 'swig_shadow': not None} } ) swig-3.0.2/Tools/mkdist.py0000775000175000017500000000643412343605122015322 0ustar williamwilliam#!/usr/bin/env python # This script builds a swig-x.y.z distribution. # Usage: mkdist.py version branch, where version should be x.y.z and branch is normally 'master' import sys import string import os import subprocess def failed(): print "mkdist.py failed to complete" sys.exit(2) try: version = sys.argv[1] dirname = "swig-" + version branch = sys.argv[2] except: print "Usage: mkdist.py version branch, where version should be x.y.z and branch is normally 'master'" sys.exit(1) if sys.version_info[0:2] < (2, 7): print "Error: Python 2.7 is required" sys.exit(3) # Check name matches normal unix conventions if string.lower(dirname) != dirname: print "directory name ("+dirname+") should be in lowercase" sys.exit(3) # If directory and tarball exist, remove it print "Removing ", dirname os.system("rm -rf "+dirname) print "Removing "+dirname+".tar if exists" os.system("rm -f "+dirname+".tar.gz") print "Removing "+dirname+".tar.gz if exists" os.system("rm -f "+dirname+".tar") # Grab the code from git print "Checking git repository is in sync with remote repository" os.system("git remote update origin") == 0 or failed() command = ["git", "status", "--porcelain", "-uno"] out = subprocess.check_output(command) if out.strip() != "": print "Local git repository has modifications" print " ".join(command) print out sys.exit(3) command = ["git", "log", "--oneline", branch + "..origin/" + branch] out = subprocess.check_output(command) if out.strip() != "": print "Remote repository has additional modifications to local repository" print " ".join(command) print out sys.exit(3) command = ["git", "log", "--oneline", "origin/" + branch + ".." + branch] out = subprocess.check_output(command) if out.strip() != "": print "Local repository has modifications not pushed to the remote repository" print "These should be pushed and checked that they pass Continuous Integration testing before continuing" print " ".join(command) print out sys.exit(3) print "Tagging release" tag = "'rel-" + version + "'" os.system("git tag -a -m " + tag + " " + tag) == 0 or failed() outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/" print "Grabbing tagged release git repository using 'git archive' into " + outdir os.system("(cd .. && git archive --prefix=" + outdir + " " + tag + " . | tar -xf -)") == 0 or failed() # Remove the debian directory -- it's not official os.system("rm -Rf "+dirname+"/debian") == 0 or failed() # Go build the system print "Building system" os.system("cd "+dirname+" && ./autogen.sh") == 0 or failed() os.system("cd "+dirname+"/Source/CParse && bison -y -d parser.y && mv y.tab.c parser.c && mv y.tab.h parser.h") == 0 or failed() os.system("cd "+dirname+" && make -f Makefile.in libfiles srcdir=./") == 0 or failed() # Remove autoconf files os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;") # Build documentation print "Building html documentation" os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed() print "Building man pages" os.system("cd "+dirname+"/CCache && yodl2man -o ccache-swig.1 ccache.yo") == 0 or failed() # Build the tar-ball os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed() os.system("gzip "+dirname+".tar") == 0 or failed() print "Finished building "+dirname+".tar.gz" swig-3.0.2/Tools/pcre-build.sh0000775000175000017500000000427112343605122016034 0ustar williamwilliam#!/bin/sh pcre_subdir=pcre/pcre-swig-install pcre_install_dir=`pwd`/$pcre_subdir usage() { echo "Helper script to build PCRE as a static library from a tarball just for use during the" echo "SWIG build. It does not install PCRE for global use on your system." echo "Usage: pcre-build.sh [--help] [args]" echo " args - optional additional arguments passed on to the PCRE configure script (leave out" echo " unless you are an expert at configure)" echo " --help - Display this help information." echo "Instructions:" echo " - Download the latest PCRE source tarball from http://www.pcre.org and place in the" echo " directory that you will configure and build SWIG." echo " - Run this script in the same directory that you intend to configure and build SWIG in." echo " This will configure and build PCRE as a static library." echo " - Afterwards run the SWIG configure script which will then find and use the PCRE static" echo " libraries in the $pcre_subdir subdirectory." exit 0 } bail() { echo $1 >&2 exit 1 } if test "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ; then usage fi if test -f "pcre-build.sh" ; then echo "Error: this script should not be run in the Tools directory" >&2 echo "" usage fi echo "Looking for PCRE tarball..." rm -rf pcre pcre_tarball=`ls pcre-*.tar*` test -n "$pcre_tarball" || bail "Could not find tarball matching pattern: pcre-*.tar*" test -f "$pcre_tarball" || bail "Could not find a single PCRE tarball. Found: $pcre_tarball" echo "Extracting tarball: $pcre_tarball" tar -xf $pcre_tarball || bail "Could not untar $pcre_tarball" pcre_dir=`echo $pcre_tarball | sed -e "s/\.tar.*//"` echo "Configuring PCRE in directory: pcre" mv $pcre_dir pcre || bail "Could not create pcre directory" cd pcre && ./configure --prefix=$pcre_install_dir --disable-shared $* || bail "PCRE configure failed" echo "Building PCRE..." ${MAKE:-make} -s || bail "Could not build PCRE" echo "Installing PCRE locally to $pcre_install_dir..." ${MAKE:-make} -s install || bail "Could not install PCRE" echo "" echo "The SWIG configure script can now be run, whereupon PCRE will automatically be detected and used from $pcre_install_dir/bin/pcre-config." swig-3.0.2/Tools/check-include-path.pike0000664000175000017500000000110712343605122017744 0ustar williamwilliam/** * This is a helper script to identify the proper include path * for Pike header files. It should be run with the full path * to the Pike executable as its single argument, e.g. * * pike check-include-path.pike /usr/local/bin/pike * * and its output should be the correct path to the header * files, e.g. * * /usr/local/pike/7.2.239/include/pike * */ int main(int argc, array(string) argv) { string prefix = replace(argv[1], "/bin/pike", ""); write(prefix + "/pike/" + __MAJOR__ + "." + __MINOR__ + "." + __BUILD__ + "/include/pike"); return 0; } swig-3.0.2/Tools/mkrelease.py0000775000175000017500000000375612343605122016003 0ustar williamwilliam#!/usr/bin/env python # This script builds the SWIG source tarball, creates the Windows executable and the Windows zip package # and uploads them both to SF ready for release. Also uploaded are the release notes. import sys import string import os def failed(message): if message == "": print "mkrelease.py failed to complete" else: print message sys.exit(2) try: version = sys.argv[1] branch = sys.argv[2] username = sys.argv[3] except: print "Usage: python mkrelease.py version branch username" print "where version should be x.y.z and username is your SF username" sys.exit(1) print "Looking for rsync" os.system("which rsync") and failed("rsync not installed/found. Please install.") print "Making source tarball" os.system("python ./mkdist.py " + version + " " + branch) and failed("") print "Build Windows package" os.system("./mkwindows.sh " + version) and failed("") print "Uploading to SourceForge" swig_dir_sf = username + ",swig@frs.sourceforge.net:/home/frs/project/s/sw/swig/swig/swig-" + version + "/" swigwin_dir_sf = username + ",swig@frs.sourceforge.net:/home/frs/project/s/sw/swig/swigwin/swigwin-" + version + "/" # If a file with 'readme' in the name exists in the same folder as the zip/tarball, it gets automatically displayed as the release notes by SF full_readme_file = "readme-" + version + ".txt" os.system("rm -f " + full_readme_file) os.system("cat swig-" + version + "/README " + "swig-" + version + "/CHANGES.current " + "swig-" + version + "/RELEASENOTES " + "> " + full_readme_file) os.system("rsync --archive --verbose -P --times -e ssh " + "swig-" + version + ".tar.gz " + full_readme_file + " " + swig_dir_sf) and failed("") os.system("rsync --archive --verbose -P --times -e ssh " + "swigwin-" + version + ".zip " + full_readme_file + " " + swigwin_dir_sf) and failed("") print "Finished" print "Now log in to SourceForge and set the operating systems applicable to the newly uploaded tarball and zip file. Also remember to do a 'git push --tags'." swig-3.0.2/Tools/javascript/0000775000175000017500000000000012343605122015611 5ustar williamwilliamswig-3.0.2/Tools/javascript/javascript.cxx0000664000175000017500000000255212343605122020507 0ustar williamwilliam#include #include #include #include #include #include #include "js_shell.h" void print_usage() { std::cout << "javascript [-i] [-jsc|-v8] [-l module] " << std::endl; } int main(int argc, char* argv[]) { #if defined(JAVASCRIPT_INTERPRETER_STOP) std::cout << "Attach your Debugger and press any key to continue" << std::endl; std::cin.get(); #endif std::string scriptPath = ""; bool interactive = false; JSShell* shell = 0; std::vector modulePath; modulePath.push_back("."); for (int idx = 1; idx < argc; ++idx) { if(strcmp(argv[idx], "-v8") == 0) { shell = JSShell::Create(JSShell::V8); } else if(strcmp(argv[idx], "-jsc") == 0) { shell = JSShell::Create(JSShell::JSC); } else if(strcmp(argv[idx], "-i") == 0) { interactive = true; } else if(strcmp(argv[idx], "-L") == 0) { modulePath.push_back(argv[++idx]); } else { scriptPath = argv[idx]; } } if (shell == 0) { shell = JSShell::Create(); } shell->setModulePath(modulePath); bool failed = false; if(interactive) { failed = !(shell->RunShell()); } else { failed = !(shell->RunScript(scriptPath)); } if (failed) { delete shell; printf("FAIL: Error during execution of script.\n"); return 1; } delete shell; return 0; } swig-3.0.2/Tools/javascript/js_shell.cxx0000664000175000017500000000653312343605122020147 0ustar williamwilliam#include "js_shell.h" #include #include #include #include #include #ifdef __GNUC__ #ifdef __APPLE__ #define LIBRARY_EXT ".bundle" #else #define LIBRARY_EXT ".so" #endif #include #define LOAD_LIBRARY(name) dlopen(name, RTLD_LAZY) #define CLOSE_LIBRARY(handle) dlclose(handle) #define LIBRARY_ERROR dlerror #define LIBRARYFILE(name) std::string("lib").append(name).append(LIBRARY_EXT) #else #error "implement dll loading" #endif JSShell::~JSShell() { for(std::vector::iterator it = loaded_modules.begin(); it != loaded_modules.end(); ++it) { HANDLE handle = *it; CLOSE_LIBRARY(handle); } } // TODO: this could be done more intelligent... // - can we achieve source file relative loading? // - better path resolution std::string JSShell::LoadModule(const std::string& name, HANDLE* library) { // works only for posix like OSs size_t pathIdx = name.find_last_of("/"); std::string lib_name; std::string module_name; if (pathIdx == std::string::npos) { module_name = name; lib_name = std::string(name).append(LIBRARY_EXT); } else { std::string path = name.substr(0, pathIdx+1); module_name = name.substr(pathIdx+1); lib_name = path.append(module_name).append(LIBRARY_EXT); } std::string lib_path; HANDLE handle = 0; for (int i = 0; i < module_path.size(); ++i) { lib_path = module_path[i] + "/" + lib_name; if (access( lib_path.c_str(), F_OK ) != -1) { handle = LOAD_LIBRARY(lib_path.c_str()); } } if(handle == 0) { std::cerr << "Could not find module " << lib_path << ":" << std::endl << LIBRARY_ERROR() << std::endl; return 0; } loaded_modules.push_back(handle); *library = handle; return module_name; } bool JSShell::RunScript(const std::string& scriptPath) { std::string source = ReadFile(scriptPath); if(!InitializeEngine()) return false; // Node.js compatibility: make `print` available as `console.log()` ExecuteScript("var console = {}; console.log = print;", ""); if(!ExecuteScript(source, scriptPath)) { return false; } return DisposeEngine(); } bool JSShell::RunShell() { if(!InitializeEngine()) return false; static const int kBufferSize = 1024; while (true) { char buffer[kBufferSize]; printf("> "); char* str = fgets(buffer, kBufferSize, stdin); if (str == NULL) break; std::string source(str); ExecuteScript(source, "(shell)"); } printf("\n"); return true; } std::string JSShell::ReadFile(const std::string& fileName) { std::string script; std::ifstream file(fileName.c_str()); if (file.is_open()) { while ( file.good() ) { std::string line; getline(file, line); script.append(line); script.append("\n"); } file.close(); } else { std::cout << "Unable to open file " << fileName << "." << std::endl; } return script; } #ifdef ENABLE_JSC extern JSShell* JSCShell_Create(); #endif #ifdef ENABLE_V8 extern JSShell* V8Shell_Create(); #endif typedef JSShell*(*ShellFactory)(); static ShellFactory js_shell_factories[2] = { #ifdef ENABLE_JSC JSCShell_Create, #else 0, #endif #ifdef ENABLE_V8 V8Shell_Create, #else 0, #endif }; JSShell *JSShell::Create(Engine engine) { if(js_shell_factories[engine] == 0) { throw "Engine not available."; } return js_shell_factories[engine](); } swig-3.0.2/Tools/javascript/js_shell.h0000664000175000017500000000161012343605122017563 0ustar williamwilliam#ifndef JS_SHELL_H #define JS_SHELL_H #include #include typedef void* HANDLE; typedef void* MODULE; class JSShell { public: enum Engine { JSC = 0, V8 }; public: JSShell() {} virtual ~JSShell() = 0; static JSShell* Create(Engine engine = JSC); std::string LoadModule(const std::string& name, HANDLE* library); virtual bool RunScript(const std::string& scriptPath); virtual bool RunShell(); void setModulePath(const std::vector& modulePath) { module_path = modulePath; } protected: virtual bool InitializeEngine() = 0; virtual bool ExecuteScript(const std::string& source, const std::string& scriptPath) = 0; virtual bool DisposeEngine() = 0; static std::string ReadFile(const std::string& fileName); protected: std::vector loaded_modules; std::vector module_path; }; #endif // JS_SHELL_H swig-3.0.2/Tools/javascript/v8_shell.cxx0000664000175000017500000002056612343605122020072 0ustar williamwilliam#include #include #include #include #include #include #include #include "js_shell.h" typedef int (*V8ExtensionInitializer) (v8::Handle module); class V8Shell: public JSShell { public: V8Shell(); virtual ~V8Shell(); virtual bool RunScript(const std::string& scriptPath); virtual bool RunShell(); protected: virtual bool InitializeEngine(); virtual bool ExecuteScript(const std::string& source, const std::string& scriptPath); virtual bool DisposeEngine(); private: v8::Handle Import(const std::string& moduleName); v8::Persistent CreateShellContext(); void ReportException(v8::TryCatch* handler); static v8::Handle Print(const v8::Arguments& args); static v8::Handle Require(const v8::Arguments& args); static v8::Handle Quit(const v8::Arguments& args); static v8::Handle Version(const v8::Arguments& args); static const char* ToCString(const v8::String::Utf8Value& value); virtual bool _ExecuteScript(const std::string& source, const std::string& scriptPath); protected: v8::Persistent context; }; #ifdef __GNUC__ #include #define LOAD_SYMBOL(handle, name) dlsym(handle, name) #else #error "implement dll loading" #endif V8Shell::V8Shell(){} V8Shell::~V8Shell() {} bool V8Shell::RunScript(const std::string& scriptPath) { if (!context.IsEmpty()) { context.Dispose(); } std::string source = ReadFile(scriptPath); context = CreateShellContext(); if (context.IsEmpty()) { printf("Could not create context.\n"); return false; } context->Enter(); bool success = _ExecuteScript(source, scriptPath); context->Exit(); context.Dispose(); v8::V8::Dispose(); return true; } bool V8Shell::_ExecuteScript(const std::string& source, const std::string& scriptPath) { v8::HandleScope scope; // Store a pointer to this shell for later use v8::Handle global = context->Global(); v8::Local __shell__ = v8::External::New((void*) (long) this); global->SetHiddenValue(v8::String::New("__shell__"), __shell__); // Node.js compatibility: make `print` available as `console.log()` ExecuteScript("var console = {}; console.log = print;", ""); if(!ExecuteScript(source, scriptPath)) { return false; } return true; } bool V8Shell::RunShell() { if (!context.IsEmpty()) { context.Dispose(); } context = CreateShellContext(); if (context.IsEmpty()) { printf("Could not create context.\n"); return false; } context->Enter(); v8::Context::Scope context_scope(context); ExecuteScript("var console = {}; console.log = print;", ""); static const int kBufferSize = 1024; while (true) { char buffer[kBufferSize]; printf("> "); char* str = fgets(buffer, kBufferSize, stdin); if (str == NULL) break; std::string source(str); ExecuteScript(source, "(shell)"); } printf("\n"); context->Exit(); context.Dispose(); v8::V8::Dispose(); return true; } bool V8Shell::InitializeEngine() { return true; } bool V8Shell::ExecuteScript(const std::string& source, const std::string& name) { v8::HandleScope handle_scope; v8::TryCatch try_catch; v8::Handle script = v8::Script::Compile(v8::String::New(source.c_str()), v8::String::New(name.c_str())); // Stop if script is empty if (script.IsEmpty()) { // Print errors that happened during compilation. ReportException(&try_catch); return false; } v8::Handle result = script->Run(); // Print errors that happened during execution. if (try_catch.HasCaught()) { ReportException(&try_catch); return false; } else { return true; } } bool V8Shell::DisposeEngine() { return true; } v8::Persistent V8Shell::CreateShellContext() { v8::HandleScope scope; // Create a template for the global object. v8::Handle global = v8::ObjectTemplate::New(); // Bind global functions global->Set(v8::String::New("print"), v8::FunctionTemplate::New(V8Shell::Print)); global->Set(v8::String::New("quit"), v8::FunctionTemplate::New(V8Shell::Quit)); global->Set(v8::String::New("require"), v8::FunctionTemplate::New(V8Shell::Require)); global->Set(v8::String::New("version"), v8::FunctionTemplate::New(V8Shell::Version)); v8::Persistent _context = v8::Context::New(NULL, global); return _context; } v8::Handle V8Shell::Import(const std::string& module_path) { v8::HandleScope scope; HANDLE library; std::string module_name = LoadModule(module_path, &library); std::string symname = std::string(module_name).append("_initialize"); V8ExtensionInitializer init_function = reinterpret_cast((long) LOAD_SYMBOL(library, symname.c_str())); if(init_function == 0) { printf("Could not find initializer function."); return v8::Undefined(); } v8::Local module = v8::Object::New(); init_function(module); return scope.Close(module); } v8::Handle V8Shell::Print(const v8::Arguments& args) { bool first = true; for (int i = 0; i < args.Length(); i++) { v8::HandleScope handle_scope; if (first) { first = false; } else { printf(" "); } v8::String::Utf8Value str(args[i]); const char* cstr = V8Shell::ToCString(str); printf("%s", cstr); } printf("\n"); fflush(stdout); return v8::Undefined(); } v8::Handle V8Shell::Require(const v8::Arguments& args) { v8::HandleScope scope; if (args.Length() != 1) { printf("Illegal arguments for `require`"); }; v8::String::Utf8Value str(args[0]); const char* cstr = V8Shell::ToCString(str); std::string moduleName(cstr); v8::Local global = v8::Context::GetCurrent()->Global(); v8::Local hidden = global->GetHiddenValue(v8::String::New("__shell__")); v8::Local __shell__ = v8::Local::Cast(hidden); V8Shell* _this = (V8Shell*) (long) __shell__->Value(); v8::Handle module = _this->Import(moduleName); return scope.Close(module); } v8::Handle V8Shell::Quit(const v8::Arguments& args) { int exit_code = args[0]->Int32Value(); fflush(stdout); fflush(stderr); exit(exit_code); return v8::Undefined(); } v8::Handle V8Shell::Version(const v8::Arguments& args) { return v8::String::New(v8::V8::GetVersion()); } void V8Shell::ReportException(v8::TryCatch* try_catch) { v8::HandleScope handle_scope; v8::String::Utf8Value exception(try_catch->Exception()); const char* exception_string = V8Shell::ToCString(exception); v8::Handle message = try_catch->Message(); if (message.IsEmpty()) { // V8 didn't provide any extra information about this error; just // print the exception. printf("%s\n", exception_string); } else { // Print (filename):(line number): (message). v8::String::Utf8Value filename(message->GetScriptResourceName()); const char* filename_string = V8Shell::ToCString(filename); int linenum = message->GetLineNumber(); printf("%s:%i: %s\n", filename_string, linenum, exception_string); // Print line of source code. v8::String::Utf8Value sourceline(message->GetSourceLine()); const char* sourceline_string = V8Shell::ToCString(sourceline); printf("%s\n", sourceline_string); // Print wavy underline (GetUnderline is deprecated). int start = message->GetStartColumn(); for (int i = 0; i < start; i++) { printf(" "); } int end = message->GetEndColumn(); for (int i = start; i < end; i++) { printf("^"); } printf("\n"); v8::String::Utf8Value stack_trace(try_catch->StackTrace()); if (stack_trace.length() > 0) { const char* stack_trace_string = V8Shell::ToCString(stack_trace); printf("%s\n", stack_trace_string); } } } // Extracts a C string from a V8 Utf8Value. const char* V8Shell::ToCString(const v8::String::Utf8Value& value) { return *value ? *value : ""; } JSShell* V8Shell_Create() { return new V8Shell(); } swig-3.0.2/Tools/javascript/Makefile.in0000664000175000017500000000423212343605122017657 0ustar williamwilliam# ---------------------------------------------------------------- # Compile a custom javascript interpreter # ---------------------------------------------------------------- # # Note: # There is no common CLI Javascript interpreter. # V8 comes with one 'd8' which however does not provide a means # to load extensions. Therefore, by default we use nodejs as # environment. # For testing native v8 and jsc extensions we provide our own # interpreter (see 'Tools/javascript'). # # ---------------------------------------------------------------- all: javascript CC = @CC@ # HACK: under OSX a g++ compiled interpreter is seg-faulting when loading module libraries # with 'c++' it works... probably some missing flags? JSCXX = @JSINTERPRETERCXX@ CPPFLAGS = @BOOST_CPPFLAGS@ CFLAGS = @PLATCFLAGS@ CXXFLAGS = @PLATCXXFLAGS@ LDFLAGS = LINKFLAGS = @JSINTERPRETERLINKFLAGS@ ROOT_DIR = @ROOT_DIR@ JSINCLUDES = @JSCOREINC@ @JSV8INC@ JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@ JSLIBRARYPREFIX = @JSLIBRARYPREFIX@ JSSO =@JSSO@ JSLDSHARED = @JSLDSHARED@ JSCXXSHARED = @JSCXXSHARED@ JSV8ENABLED = @JSV8ENABLED@ JSCENABLED = @JSCENABLED@ srcdir = @srcdir@ # Regenerate Makefile if Makefile.in or config.status have changed. Makefile: $(srcdir)/Makefile.in ../../config.status cd ../.. && $(SHELL) ./config.status Tools/javascript/Makefile # These settings are provided by 'configure' (see '/configure.in') ifeq (1, $(JSV8ENABLED)) JS_INTERPRETER_SRC_V8 = v8_shell.cxx JS_INTERPRETER_ENABLE_V8 = -DENABLE_V8 endif ifeq (1, $(JSCENABLED)) JS_INTERPRETER_SRC_JSC = jsc_shell.cxx JS_INTERPRETER_ENABLE_JSC = -DENABLE_JSC endif JS_INTERPRETER_DEFINES = $(JS_INTERPRETER_ENABLE_JSC) $(JS_INTERPRETER_ENABLE_V8) JS_INTERPRETER_SRC = javascript.cxx js_shell.cxx $(JS_INTERPRETER_SRC_JSC) $(JS_INTERPRETER_SRC_V8) JS_INTERPRETER_OBJS = $(JS_INTERPRETER_SRC:.cxx=.o) %.o: $(srcdir)/%.cxx $(JSCXX) $(JS_INTERPRETER_DEFINES) $(CPPFLAGS) $(CXXFLAGS) $(JSINCLUDES) -o $@ -c $< javascript: $(JS_INTERPRETER_OBJS) $(JSCXX) $^ $(CXXFLAGS) $(LDFLAGS) -o javascript $(JSDYNAMICLINKING) $(LINKFLAGS) clean: rm -f *.o rm -f javascript distclean: clean rm -f Makefile swig-3.0.2/Tools/javascript/jsc_shell.cxx0000664000175000017500000001576312343605122020317 0ustar williamwilliam#include #include "js_shell.h" #include #include #ifdef __GNUC__ #include #define LOAD_SYMBOL(handle, name) dlsym(handle, name) #else #error "implement dll loading" #endif class JSCShell: public JSShell { typedef int (*JSCIntializer)(JSGlobalContextRef context, JSObjectRef *module); public: JSCShell() {}; virtual ~JSCShell(); protected: virtual bool InitializeEngine(); virtual bool ExecuteScript(const std::string& source, const std::string& scriptPath); virtual bool DisposeEngine(); private: JSObjectRef Import(const std::string &moduleName); static JSValueRef Print(JSContextRef context, JSObjectRef object, JSObjectRef globalobj, size_t argc, const JSValueRef args[], JSValueRef* ex); static JSValueRef Require(JSContextRef context, JSObjectRef object, JSObjectRef globalobj, size_t argc, const JSValueRef args[], JSValueRef* ex); static bool RegisterFunction(JSGlobalContextRef context, JSObjectRef object, const char* functionName, JSObjectCallAsFunctionCallback cbFunction); static void PrintError(JSContextRef, JSValueRef); private: JSGlobalContextRef context; }; JSCShell::~JSCShell() { if(context != 0) { JSGlobalContextRelease(context); context = 0; } } bool JSCShell::InitializeEngine() { if(context != 0) { JSGlobalContextRelease(context); context = 0; } // TODO: check for initialization errors context = JSGlobalContextCreate(NULL); if(context == 0) return false; JSObjectRef globalObject = JSContextGetGlobalObject(context); // store this for later use JSClassDefinition __shell_classdef__ = JSClassDefinition(); JSClassRef __shell_class__ = JSClassCreate(&__shell_classdef__); JSObjectRef __shell__ = JSObjectMake(context, __shell_class__, 0); bool success = JSObjectSetPrivate(__shell__, (void*) (long) this); if (!success) { std::cerr << "Could not register the shell in the Javascript context" << std::endl; return false; } JSStringRef shellKey = JSStringCreateWithUTF8CString("__shell__"); JSObjectSetProperty(context, globalObject, shellKey, __shell__, kJSPropertyAttributeReadOnly, NULL); JSStringRelease(shellKey); JSCShell::RegisterFunction(context, globalObject, "print", JSCShell::Print); JSCShell::RegisterFunction(context, globalObject, "require", JSCShell::Require); return true; } bool JSCShell::ExecuteScript(const std::string& source, const std::string& scriptPath) { JSStringRef jsScript; JSStringRef sourceURL; JSValueRef ex; jsScript = JSStringCreateWithUTF8CString(source.c_str()); sourceURL = JSStringCreateWithUTF8CString(scriptPath.c_str()); JSValueRef jsResult = JSEvaluateScript(context, jsScript, 0, sourceURL, 0, &ex); JSStringRelease(jsScript); if (jsResult == NULL && ex != NULL) { JSCShell::PrintError(context, ex); return false; } return true; } bool JSCShell::DisposeEngine() { JSGlobalContextRelease(context); context = 0; return true; } JSValueRef JSCShell::Print(JSContextRef context, JSObjectRef object, JSObjectRef globalobj, size_t argc, const JSValueRef args[], JSValueRef* ex) { if (argc > 0) { JSStringRef string = JSValueToStringCopy(context, args[0], NULL); size_t numChars = JSStringGetMaximumUTF8CStringSize(string); char *stringUTF8 = new char[numChars]; JSStringGetUTF8CString(string, stringUTF8, numChars); printf("%s\n", stringUTF8); delete[] stringUTF8; } return JSValueMakeUndefined(context); } // Attention: this feature should not create too high expectations. // It is only capable of loading things relative to the execution directory // and not relative to the parent script. JSValueRef JSCShell::Require(JSContextRef context, JSObjectRef object, JSObjectRef globalObj, size_t argc, const JSValueRef args[], JSValueRef* ex) { JSObjectRef module; JSStringRef shellKey = JSStringCreateWithUTF8CString("__shell__"); JSValueRef shellAsVal = JSObjectGetProperty(context, globalObj, shellKey, NULL); JSStringRelease(shellKey); JSObjectRef shell = JSValueToObject(context, shellAsVal, 0); JSCShell *_this = (JSCShell*) (long) JSObjectGetPrivate(shell); if (argc > 0) { JSStringRef string = JSValueToStringCopy(context, args[0], NULL); size_t numChars = JSStringGetMaximumUTF8CStringSize(string); char *stringUTF8 = new char[numChars]; JSStringGetUTF8CString(string, stringUTF8, numChars); std::string modulePath(stringUTF8); module = _this->Import(modulePath); delete[] stringUTF8; } if (module) { return module; } else { printf("Ooops.\n"); return JSValueMakeUndefined(context); } } JSObjectRef JSCShell::Import(const std::string& module_path) { HANDLE library; std::string module_name = LoadModule(module_path, &library); if (library == 0) { printf("Could not load module."); return 0; } std::string symname = std::string(module_name).append("_initialize"); JSCIntializer init_function = reinterpret_cast((long) LOAD_SYMBOL(library, symname.c_str())); if(init_function == 0) { printf("Could not find module's initializer function."); return 0; } JSObjectRef module; init_function(context, &module); return module; } bool JSCShell::RegisterFunction(JSGlobalContextRef context, JSObjectRef object, const char* functionName, JSObjectCallAsFunctionCallback callback) { JSStringRef js_functionName = JSStringCreateWithUTF8CString(functionName); JSObjectSetProperty(context, object, js_functionName, JSObjectMakeFunctionWithCallback(context, js_functionName, callback), kJSPropertyAttributeNone, NULL); JSStringRelease(js_functionName); return true; } void JSCShell::PrintError(JSContextRef ctx, JSValueRef err) { char *buffer; size_t length; JSStringRef string = JSValueToStringCopy(ctx, err, 0); length = JSStringGetLength(string); buffer = new char[length+1]; JSStringGetUTF8CString(string, buffer, length+1); std::string errMsg(buffer); JSStringRelease(string); delete[] buffer; JSObjectRef errObj = JSValueToObject(ctx, err, 0); if(errObj == 0) { std::cerr << errMsg << std::endl; return; } JSStringRef sourceURLKey = JSStringCreateWithUTF8CString("sourceURL"); JSStringRef sourceURLStr = JSValueToStringCopy(ctx, JSObjectGetProperty(ctx, errObj, sourceURLKey, 0), 0); length = JSStringGetLength(sourceURLStr); buffer = new char[length+1]; JSStringGetUTF8CString(sourceURLStr, buffer, length+1); std::string sourceURL(buffer); delete[] buffer; JSStringRelease(sourceURLStr); JSStringRelease(sourceURLKey); JSStringRef lineKey = JSStringCreateWithUTF8CString("line"); JSValueRef jsLine = JSObjectGetProperty(ctx, errObj, lineKey, 0); int line = (int) JSValueToNumber(ctx, jsLine, 0); JSStringRelease(lineKey); std::cerr << sourceURL << ":" << line << ":" << errMsg << std::endl; } JSShell* JSCShell_Create() { return new JSCShell(); } swig-3.0.2/Tools/obs-update0000775000175000017500000000136212343605122015436 0ustar williamwilliam#!/bin/bash # Update SWIG tarball on openSUSE Build Service to contain the latest from master # Requires the openSUSE Build Service command-line tool (osc) # See http://openbuildservice.org/download/ # And these packages: obs-service-tar_scm obs-service-recompress obs-service-set_version # Results appear at https://build.opensuse.org/package/show/home:kwk:swig/swig-raw set -e set -x rm -rf home-kwk-swig/swig-raw mkdir -p home-kwk-swig cd home-kwk-swig # check out 'swig-raw' osc co -o swig-raw home:kwk:swig swig-raw cd swig-raw # remove existing tarball osc rm swig*tar.bz2 # fetch latest master branch from git and create tarball osc service disabledrun # add new tarball osc addremove # check changes into build service, triggers build osc ci swig-3.0.2/configure0000775000175000017500000140417112343706575014300 0ustar williamwilliam#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for swig 3.0.2. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: http://www.swig.org about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='swig' PACKAGE_TARNAME='swig' PACKAGE_VERSION='3.0.2' PACKAGE_STRING='swig 3.0.2' PACKAGE_BUGREPORT='http://www.swig.org' PACKAGE_URL='' ac_unique_file="Source/Swig/swig.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" enable_option_checking=no ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS SWIG_LIB swig_lib ac_aux_dir EXTRA_CLEAN ROOT_DIR SKIP_ANDROID SKIP_GCJ SKIP_D SKIP_GO SKIP_UFFI SKIP_CFFI SKIP_R SKIP_CLISP SKIP_ALLEGROCL SKIP_LUA SKIP_MODULA3 SKIP_CSHARP SKIP_CHICKEN SKIP_PIKE SKIP_OCAML SKIP_PHP SKIP_RUBY SKIP_MZSCHEME SKIP_GUILE SKIP_JAVASCRIPT SKIP_JAVA SKIP_PYTHON3 SKIP_PYTHON SKIP_OCTAVE SKIP_PERL5 SKIP_TCL DLIBPREFIX DDEFAULTVERSION D2COMPILER D1COMPILER GOVERSIONOPTION GOOPT GO13 GO12 GO1 GOC GOGCC GO RBIN CLISPBIN ALLEGROCLBIN LUALINK LUAFLAGS LUADYNAMICLINKING LUABIN CSHARPSO CSHARPCFLAGS CSHARPLIBRARYPREFIX CSHARPDYNAMICLINKING CSHARPCYGPATH_W CSHARPPATHSEPARATOR CSHARPCILINTERPRETER_FLAGS CSHARPCILINTERPRETER CSHARPCOMPILER CHICKENSHAREDLIB CHICKENLIB CHICKENOPTS CHICKEN_CSI CHICKEN_CSC CHICKEN PIKEDYNAMICLINKING PIKECCDLFLAGS PIKEINCLUDE PIKECONFIG PIKE OCAMLINC OCAMLVER OCAMLLOC OCAMLMKTOP OCAMLBIN OCAMLC OCAMLFIND OCAMLDLGEN PHPINC PHP RUBYDYNAMICLINKING RUBYSO RUBYCCDLFLAGS RUBYLINK RUBYLIB RUBYINCLUDE RUBY MZDYNOBJ MZC MZSCHEME GUILE_LIBS GUILE_CFLAGS GUILE GUILE_CONFIG NDKBUILD ANT ADB ANDROID GCJH GCJ JSV8ENABLED JSCENABLED JSV8DYNAMICLINKING JSV8INC JSCOREVERSION JSCOREDYNAMICLINKING JSCOREINC JSINTERPRETERLINKFLAGS JSINTERPRETERCXX JSCXXSHARED JSLDSHARED JSSO JSLIBRARYPREFIX NODEGYP NODEJS JAVACFLAGS JAVACXXSHARED JAVALDSHARED JAVASO JAVALIBRARYPREFIX JAVADYNAMICLINKING JAVAINC JAVAC JAVA OCTAVE_LDFLAGS OCTAVE_CXXFLAGS OCTAVE_CPPFLAGS OCTAVE_SO OCTAVE PERL5LDFLAGS PERL5CCCDLFLAGS PERL5CCDLFLAGS PERL5CCFLAGS PERL5LIB PERL5DYNAMICLINKING PERL5EXT PERL PYTHON3DYNAMICLINKING PY3LINK PY3LIB PY3INCLUDE PY3CONFIG PYTHON3 PYTHONDYNAMICLINKING PYLINK PYLIB PYINCLUDE PYTHON TCLCXXSHARED TCLLDSHARED TCLDYNAMICLINKING TCLLIB TCLINCLUDE LIBC LIBCRYPT LIBM SWILL SWIGLIBS LUA_SO MZSCHEME_SO PHP_SO GUILE_SO TCL_SO PYTHON_SO LINKFORSHARED HAVE_CXX11_COMPILER PLATCXXFLAGS PLATCFLAGS RPATH TRYLINKINGWITHCXX CXXSHARED CCSHARED LDSHARED SO BOOST_LDFLAGS BOOST_CPPFLAGS YODL2HTML YODL2MAN AR RANLIB YFLAGS YACC ENABLE_CCACHE subdirs PCRE_LIBS PCRE_CFLAGS PCRE_CONFIG SED EGREP GREP CPP am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_dependency_tracking with_maximum_compile_warnings with_popen with_pcre with_pcre_prefix with_pcre_exec_prefix enable_ccache with_boost with_boost_libdir enable_cpp11_testing with_libm with_libc with_alllang with_tclconfig with_tcl with_tclincl with_tcllib with_python with_python3 with_perl5 with_octave with_java with_javac with_javaincl with_javascript with_jscoreinc with_jscorelib with_jsv8inc with_jsv8lib with_gcj with_gcjh with_android with_adb with_ant with_ndk_build with_guile_config with_guile with_guile_cflags with_guile_libs with_mzscheme with_mzc with_ruby with_php with_ocaml with_ocamlc with_ocamldlgen with_ocamlfind with_ocamlmktop with_pike with_pike_config with_pikeincl with_chicken with_chickencsc with_chickencsi with_chickenopts with_chickensharedlib with_chickenlib with_csharp with_cil_interpreter with_csharp_compiler with_lua with_luaincl with_lualib with_allegrocl with_clisp with_r with_go with_d with_d1_compiler with_d2_compiler with_swiglibdir ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CXX CXXFLAGS CCC CPP PCRE_CONFIG PCRE_CFLAGS PCRE_LIBS YACC YFLAGS' ac_subdirs_all='CCache' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures swig 3.0.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/swig] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of swig 3.0.2:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --disable-ccache disable building and installation of ccache-swig executable (default enabled) --enable-cpp11-testing enable C++11 testing if supported by compiler (default disabled) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-maximum-compile-warnings Disable maximum warning verbosity --without-popen Disable popen --without-pcre Disable support for regular expressions using PCRE --with-pcre-prefix=PREFIX Prefix where pcre is installed (optional) --with-pcre-exec-prefix=EPREFIX Exec prefix where pcre is installed (optional) --with-boost[=ARG] use Boost library from a standard location (ARG=yes), from the specified location (ARG=), or disable it (ARG=no) [ARG=yes] --with-boost-libdir=LIB_DIR Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located. --with-libm=STRING math library --with-libc=STRING C library --without-alllang Disable all languages --without-tcl Disable Tcl --with-tclconfig=path Set location of tclConfig.sh --with-tcl=path Set location of Tcl package --with-tclincl=path Set location of Tcl include directory --with-tcllib=path Set location of Tcl library directory --without-python Disable Python --with-python=path Set location of Python executable --without-python3 Disable Python 3.x support --with-python3=path Set location of Python 3.x executable --without-perl5 Disable Perl5 --with-perl5=path Set location of Perl5 executable --without-octave Disable Octave --with-octave=path Set location of Octave executable --without-java Disable Java --with-java=path Set location of java executable --with-javac=path Set location of javac executable --with-javaincl=path Set location of Java include directory --without-javascript Disable Javascript --with-jscinc=path Set location of Javascript include directory --with-jsclib =path Set location of the JavaScriptCore/Webkit library directory --with-v8inc=path Set location of Javascript v8 include directory --with-v8lib=path Set location of V8 Javascript library directory --without-gcj Disable GCJ --with-gcj=path Set location of gcj executable --with-gcjh=path Set location of gcjh executable --without-android Disable Android --with-android=path Set location of android executable --with-adb=path Set location of adb executable - Android Debug Bridge --with-ant=path Set location of ant executable for Android --with-ndk-build=path Set location of Android ndk-build executable --without-guile Disable Guile --with-guile-config=path Set location of guile-config --with-guile=path Set location of Guile executable --with-guile-cflags=cflags Set cflags required to compile against Guile --with-guile-libs=ldflags Set ldflags needed to link with Guile --without-mzscheme Disable MzScheme --with-mzscheme=path Set location of MzScheme executable --with-mzc=path Set location of MzScheme's mzc --without-ruby Disable Ruby --with-ruby=path Set location of Ruby executable --without-php Disable PHP --with-php=path Set location of PHP executable --without-ocaml Disable OCaml --with-ocaml=path Set location of ocaml executable --with-ocamlc=path Set location of ocamlc executable --with-ocamldlgen=path Set location of ocamldlgen --with-ocamlfind=path Set location of ocamlfind --with-ocamlmktop=path Set location of ocamlmktop executable --without-pike Disable Pike --with-pike=path Set location of Pike executable --with-pike-config=path Set location of pike-config script --with-pikeincl=path Set location of Pike include directory --without-chicken Disable CHICKEN --with-chicken=path Set location of CHICKEN executable --with-chickencsc=path Set location of csc executable --with-chickencsi=path Set location of csi executable --with-chickenopts=args Set compiler options for static CHICKEN generated code --with-chickensharedlib=args Set linker options for shared CHICKEN generated code --with-chickenlib=args Set linker options for static CHICKEN generated code --without-csharp Disable CSharp --with-cil-interpreter=path Set location of CIL interpreter for CSharp --with-csharp-compiler=path Set location of CSharp compiler --without-lua Disable Lua --with-lua=path Set location of Lua executable --with-luaincl=path Set location of Lua include directory --with-lualib=path Set location of Lua library directory --without-allegrocl Disable Allegro CL --with-allegrocl=path Set location of Allegro CL executable (alisp) --without-clisp Disable CLISP --with-clisp=path Set location of CLISP executable (clisp) --without-r Disable R --with-r=path Set location of R executable (r) --without-go Disable Go --with-go=path Set location of Go compiler --without-d Disable D --with-d1-compiler=path Set location of D1/Tango compiler (DMD compatible) --with-d2-compiler=path Set location of D2 compiler (DMD compatible) --with-swiglibdir=DIR Put SWIG system-independent libraries into DIR. Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags CPP C preprocessor PCRE_CONFIG config script used for pcre PCRE_CFLAGS CFLAGS used for pcre PCRE_LIBS LIBS used for pcre YACC The `Yet Another Compiler Compiler' implementation to use. Defaults to the first program found out of: `bison -y', `byacc', `yacc'. YFLAGS The list of arguments that will be passed by default to $YACC. This script will default YFLAGS to the empty string to avoid a default value of `-d' given by some make applications. Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF swig configure 3.0.2 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_cxx_check_type LINENO TYPE VAR INCLUDES # --------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_cxx_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_type # ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_cxx_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ---------------------------------- ## ## Report this to http://www.swig.org ## ## ---------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by swig $as_me 3.0.2, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in Tools/config "$srcdir"/Tools/config; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in Tools/config \"$srcdir\"/Tools/config" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. ac_config_headers="$ac_config_headers Source/Include/swigconfig.h" # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='swig' VERSION='3.0.2' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&5' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi # Needed for subdir-objects in AUTOMAKE_OPTIONS { $as_echo "$as_me:${as_lineno-$LINENO}: checking maximum warning verbosity option" >&5 $as_echo_n "checking maximum warning verbosity option... " >&6; } # Check whether --with-maximum-compile-warnings was given. if test "${with_maximum_compile_warnings+set}" = set; then : withval=$with_maximum_compile_warnings; ac_compile_warnings_on="$withval" else ac_compile_warnings_on="" fi if test x"$ac_compile_warnings_on" = xno then ac_compile_warnings_msg=no else if test -n "$CXX" then if test "$GXX" = "yes" then ac_compile_warnings_opt='-Wall -W -ansi -pedantic' fi CXXFLAGS="$CXXFLAGS $ac_compile_warnings_opt" ac_compile_warnings_msg="$ac_compile_warnings_opt for C++" fi if test -n "$CC" then if test "$GCC" = "yes" then ac_compile_warnings_opt='-Wall -W -ansi -pedantic' fi CFLAGS="$CFLAGS $ac_compile_warnings_opt" ac_compile_warnings_msg="$ac_compile_warnings_msg $ac_compile_warnings_opt for C" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_compile_warnings_msg" >&5 $as_echo "$ac_compile_warnings_msg" >&6; } unset ac_compile_warnings_msg unset ac_compile_warnings_opt # Increase warning levels cat >>confdefs.h <<_ACEOF #define SWIG_CXX "$CXX" _ACEOF cat >>confdefs.h <<_ACEOF #define SWIG_PLATFORM "$host" _ACEOF ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_cxx_check_type "$LINENO" "bool" "ac_cv_type_bool" "$ac_includes_default" if test "x$ac_cv_type_bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_BOOL 1 _ACEOF fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Check whether --with-popen was given. if test "${with_popen+set}" = set; then : withval=$with_popen; with_popen="$withval" fi if test x"${with_popen}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling popen" >&5 $as_echo "$as_me: Disabling popen" >&6;} else ac_fn_c_check_func "$LINENO" "popen" "ac_cv_func_popen" if test "x$ac_cv_func_popen" = xyes; then : $as_echo "#define HAVE_POPEN 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling popen" >&5 $as_echo "$as_me: Disabling popen" >&6;} fi fi # Check whether --with-pcre was given. if test "${with_pcre+set}" = set; then : withval=$with_pcre; else with_pcre=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable PCRE support" >&5 $as_echo_n "checking whether to enable PCRE support... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_pcre" >&5 $as_echo "$with_pcre" >&6; } if test x"${with_pcre}" = xyes ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use local PCRE" >&5 $as_echo_n "checking whether to use local PCRE... " >&6; } local_pcre_config=no if test -z $PCRE_CONFIG; then if test -f `pwd`/pcre/pcre-swig-install/bin/pcre-config; then PCRE_CONFIG=`pwd`/pcre/pcre-swig-install/bin/pcre-config local_pcre_config=$PCRE_CONFIG fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $local_pcre_config" >&5 $as_echo "$local_pcre_config" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed if test "x$with_pcre" != xno; then : # Check whether --with-pcre-prefix was given. if test "${with_pcre_prefix+set}" = set; then : withval=$with_pcre_prefix; pcre_config_prefix="$withval" else pcre_config_prefix="" fi # Check whether --with-pcre-exec-prefix was given. if test "${with_pcre_exec_prefix+set}" = set; then : withval=$with_pcre_exec_prefix; pcre_config_exec_prefix="$withval" else pcre_config_exec_prefix="" fi if test x$PCRE_CFLAGS != x -o x$PCRE_LIBS != x; then : : $as_echo "#define HAVE_PCRE 1" >>confdefs.h LIBS="$LIBS $PCRE_LIBS" CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS" else if test x$pcre_config_exec_prefix != x; then : pcre_config_args="$pcre_config_args --exec-prefix=$pcre_config_exec_prefix" if test x${PCRE_CONFIG+set} != xset; then : PCRE_CONFIG=$pcre_config_exec_prefix/bin/pcre-config fi fi if test x$pcre_config_prefix != x; then : pcre_config_args="$pcre_config_args --prefix=$pcre_config_prefix" if test x${PCRE_CONFIG+set} != xset; then : PCRE_CONFIG=$pcre_config_prefix/bin/pcre-config fi fi for ac_prog in pcre-config do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PCRE_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PCRE_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PCRE_CONFIG="$PCRE_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PCRE_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PCRE_CONFIG=$ac_cv_path_PCRE_CONFIG if test -n "$PCRE_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PCRE_CONFIG" >&5 $as_echo "$PCRE_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PCRE_CONFIG" && break done test -n "$PCRE_CONFIG" || PCRE_CONFIG="no" if test "$PCRE_CONFIG" = "no"; then : : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? " Cannot find pcre-config script from PCRE (Perl Compatible Regular Expressions) library package. This dependency is needed for configure to complete, Either: - Install the PCRE developer package on your system (preferred approach). - Download the PCRE source tarball, build and install on your system as you would for any package built from source distribution. - Use the Tools/pcre-build.sh script to build PCRE just for SWIG to statically link against. Run 'Tools/pcre-build.sh --help' for instructions. (quite easy and does not require privileges to install PCRE on your system) - Use configure --without-pcre to disable regular expressions support in SWIG (not recommended). See \`config.log' for more details" "$LINENO" 5; } else if test x"" = x; then : PCRE_CFLAGS="`$PCRE_CONFIG $pcre_config_args --cflags`" else PCRE_CFLAGS="`$PCRE_CONFIG $pcre_config_args `" fi if test x"" = x; then : PCRE_LIBS="`$PCRE_CONFIG $pcre_config_args --libs`" else PCRE_LIBS="`$PCRE_CONFIG $pcre_config_args `" fi if test x"" != x; then : if test x" " != x; then : pcre_version="`$PCRE_CONFIG $pcre_config_args --version | $SED -e `" else pcre_version="`$PCRE_CONFIG $pcre_config_args --version | $SED -e 's/^\ *\(.*\)\ *$/\1/'`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre ($pcre_version) >= " >&5 $as_echo_n "checking for pcre ($pcre_version) >= ... " >&6; } # Used to indicate true or false condition ax_compare_version=false # Convert the two version strings to be compared into a format that # allows a simple string comparison. The end result is that a version # string of the form 1.12.5-r617 will be converted to the form # 0001001200050617. In other words, each number is zero padded to four # digits, and non digits are removed. ax_compare_version_A=`echo "$pcre_version" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/[^0-9]//g'` ax_compare_version_B=`echo "" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/[^0-9]//g'` ax_compare_version=`echo "x$ax_compare_version_A x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` if test "$ax_compare_version" = "true" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } : $as_echo "#define HAVE_PCRE 1" >>confdefs.h LIBS="$LIBS $PCRE_LIBS" CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? " Cannot find pcre-config script from PCRE (Perl Compatible Regular Expressions) library package. This dependency is needed for configure to complete, Either: - Install the PCRE developer package on your system (preferred approach). - Download the PCRE source tarball, build and install on your system as you would for any package built from source distribution. - Use the Tools/pcre-build.sh script to build PCRE just for SWIG to statically link against. Run 'Tools/pcre-build.sh --help' for instructions. (quite easy and does not require privileges to install PCRE on your system) - Use configure --without-pcre to disable regular expressions support in SWIG (not recommended). See \`config.log' for more details" "$LINENO" 5; } fi else : $as_echo "#define HAVE_PCRE 1" >>confdefs.h LIBS="$LIBS $PCRE_LIBS" CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS" fi fi fi fi # Check whether --enable-ccache was given. if test "${enable_ccache+set}" = set; then : enableval=$enable_ccache; enable_ccache=$enableval else enable_ccache=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable ccache-swig" >&5 $as_echo_n "checking whether to enable ccache-swig... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_ccache" >&5 $as_echo "$enable_ccache" >&6; } if test "$enable_ccache" = yes; then subdirs="$subdirs CCache" ENABLE_CCACHE=1 fi echo "" echo "Checking packages required for SWIG developers." echo "Note : None of the following packages are required for users to compile and install SWIG from the distributed tarball" echo "" for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_YACC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_YACC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi YACC=$ac_cv_prog_YACC if test -n "$YACC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 $as_echo "$YACC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$YACC" && break done test -n "$YACC" || YACC="yacc" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi for ac_prog in ar aal do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done test -n "$AR" || AR="ar" for ac_prog in yodl2man do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_YODL2MAN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$YODL2MAN"; then ac_cv_prog_YODL2MAN="$YODL2MAN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_YODL2MAN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi YODL2MAN=$ac_cv_prog_YODL2MAN if test -n "$YODL2MAN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YODL2MAN" >&5 $as_echo "$YODL2MAN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$YODL2MAN" && break done for ac_prog in yodl2html do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_YODL2HTML+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$YODL2HTML"; then ac_cv_prog_YODL2HTML="$YODL2HTML" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_YODL2HTML="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi YODL2HTML=$ac_cv_prog_YODL2HTML if test -n "$YODL2HTML"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YODL2HTML" >&5 $as_echo "$YODL2HTML" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$YODL2HTML" && break done if test -n "$YODL2MAN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking yodl2man version >= 2.02" >&5 $as_echo_n "checking yodl2man version >= 2.02... " >&6; } yodl_version=`$YODL2MAN --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.*[0-9]*\).*/\1/g'` # Used to indicate true or false condition ax_compare_version=false # Convert the two version strings to be compared into a format that # allows a simple string comparison. The end result is that a version # string of the form 1.12.5-r617 will be converted to the form # 0001001200050617. In other words, each number is zero padded to four # digits, and non digits are removed. ax_compare_version_A=`echo "$yodl_version" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/[^0-9]//g'` ax_compare_version_B=`echo "2.02" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/[^0-9]//g'` ax_compare_version=`echo "x$ax_compare_version_A x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` if test "$ax_compare_version" = "true" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - $yodl_version found" >&5 $as_echo "no - $yodl_version found" >&6; } fi fi if test -n "$YODL2HTML"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking yodl2html version >= 2.02" >&5 $as_echo_n "checking yodl2html version >= 2.02... " >&6; } yodl_version=`$YODL2HTML --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'` # Used to indicate true or false condition ax_compare_version=false # Convert the two version strings to be compared into a format that # allows a simple string comparison. The end result is that a version # string of the form 1.12.5-r617 will be converted to the form # 0001001200050617. In other words, each number is zero padded to four # digits, and non digits are removed. ax_compare_version_A=`echo "$yodl_version" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/[^0-9]//g'` ax_compare_version_B=`echo "2.02" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/[^0-9]//g'` ax_compare_version=`echo "x$ax_compare_version_A x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` if test "$ax_compare_version" = "true" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - $yodl_version found" >&5 $as_echo "no - $yodl_version found" >&6; } fi fi echo "" echo "Checking for installed target languages and other information in order to compile and run" echo "the examples and test-suite invoked by 'make check'." echo "Note : None of the following packages are required for users to compile and install SWIG from the distributed tarball" echo "" # Check whether --with-boost was given. if test "${with_boost+set}" = set; then : withval=$with_boost; if test "$withval" = "no"; then want_boost="no" elif test "$withval" = "yes"; then want_boost="yes" ac_boost_path="" else want_boost="yes" ac_boost_path="$withval" fi else want_boost="yes" fi # Check whether --with-boost-libdir was given. if test "${with_boost_libdir+set}" = set; then : withval=$with_boost_libdir; if test -d "$withval" then ac_boost_lib_path="$withval" else as_fn_error $? "--with-boost-libdir expected directory name" "$LINENO" 5 fi else ac_boost_lib_path="" fi if test "x$want_boost" = "xyes"; then boost_lib_version_req=1.20.0 boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([0-9]*\.[0-9]*\)'` boost_lib_version_req_major=`expr $boost_lib_version_req : '\([0-9]*\)'` boost_lib_version_req_minor=`expr $boost_lib_version_req : '[0-9]*\.\([0-9]*\)'` boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[0-9]*\.[0-9]*\.\([0-9]*\)'` if test "x$boost_lib_version_req_sub_minor" = "x" ; then boost_lib_version_req_sub_minor="0" fi WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for boostlib >= $boost_lib_version_req" >&5 $as_echo_n "checking for boostlib >= $boost_lib_version_req... " >&6; } succeeded=no libsubdirs="lib" ax_arch=`uname -m` case $ax_arch in x86_64|ppc64|s390x|sparc64|aarch64) libsubdirs="lib64 lib lib64" ;; esac libsubdirs="lib/${host_cpu}-${host_os} $libsubdirs" case ${host_cpu} in i?86) libsubdirs="lib/i386-${host_os} $libsubdirs" ;; esac if test "$ac_boost_path" != ""; then BOOST_CPPFLAGS="-I$ac_boost_path/include" for ac_boost_path_tmp in $libsubdirs; do if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" break fi done elif test "$cross_compiling" != yes; then for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then for libsubdir in $libsubdirs ; do if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" break; fi done fi if test "$ac_boost_lib_path" != ""; then BOOST_LDFLAGS="-L$ac_boost_lib_path" fi CPPFLAGS_SAVED="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" export CPPFLAGS LDFLAGS_SAVED="$LDFLAGS" LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" export LDFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if BOOST_VERSION >= $WANT_BOOST_VERSION // Everything is okay #else # error Boost version is too old #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } succeeded=yes found_system=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "x$succeeded" != "xyes"; then _version=0 if test "$ac_boost_path" != ""; then if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` V_CHECK=`expr $_version_tmp \> $_version` if test "$V_CHECK" = "1" ; then _version=$_version_tmp fi VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" done fi else if test "$cross_compiling" != yes; then for ac_boost_path in /usr /usr/local /opt /opt/local ; do if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` V_CHECK=`expr $_version_tmp \> $_version` if test "$V_CHECK" = "1" ; then _version=$_version_tmp best_path=$ac_boost_path fi done fi done VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" if test "$ac_boost_lib_path" = ""; then for libsubdir in $libsubdirs ; do if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done BOOST_LDFLAGS="-L$best_path/$libsubdir" fi fi if test "x$BOOST_ROOT" != "x"; then for libsubdir in $libsubdirs ; do if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` stage_version_shorten=`expr $stage_version : '\([0-9]*\.[0-9]*\)'` V_CHECK=`expr $stage_version_shorten \>\= $_version` if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: We will use a staged boost library from $BOOST_ROOT" >&5 $as_echo "$as_me: We will use a staged boost library from $BOOST_ROOT" >&6;} BOOST_CPPFLAGS="-I$BOOST_ROOT" BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir" fi fi fi fi CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" export CPPFLAGS LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" export LDFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if BOOST_VERSION >= $WANT_BOOST_VERSION // Everything is okay #else # error Boost version is too old #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } succeeded=yes found_system=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi if test "$succeeded" != "yes" ; then if test "$_version" = "0" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation." >&5 $as_echo "$as_me: We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation." >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: Your boost libraries seems to old (version $_version)." >&5 $as_echo "$as_me: Your boost libraries seems to old (version $_version)." >&6;} fi # execute ACTION-IF-NOT-FOUND (if present): : else $as_echo "#define HAVE_BOOST /**/" >>confdefs.h # execute ACTION-IF-FOUND (if present): : fi CPPFLAGS="$CPPFLAGS_SAVED" LDFLAGS="$LDFLAGS_SAVED" fi # -I should not be used on system directories (GCC) if test "$GCC" = yes; then ISYSTEM="-isystem " else ISYSTEM="-I" fi { $as_echo "$as_me:${as_lineno-$LINENO}: ISYSTEM: $ISYSTEM" >&5 $as_echo "$as_me: ISYSTEM: $ISYSTEM" >&6;} # SO is the extension of shared libraries (including the dot!) { $as_echo "$as_me:${as_lineno-$LINENO}: checking SO" >&5 $as_echo_n "checking SO... " >&6; } if test -z "$SO" then case $host in *-*-hp*) SO=.sl;; *-*-darwin*) SO=.bundle;; *-*-cygwin* | *-*-mingw*) SO=.dll;; *) SO=.so;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SO" >&5 $as_echo "$SO" >&6; } # LDSHARED is the ld *command* used to create shared library # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into # Python, as opposed to building Python itself as a shared library.) { $as_echo "$as_me:${as_lineno-$LINENO}: checking LDSHARED" >&5 $as_echo_n "checking LDSHARED... " >&6; } if test -z "$LDSHARED" then case $host in *-*-aix*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";; *-*-cygwin* | *-*-mingw*) if test "$GCC" = yes; then LDSHARED="$CC -shared" else if test "cl" = $CC ; then # Microsoft Visual C++ (MSVC) LDSHARED="$CC -nologo -LD" else # Unknown compiler try gcc approach LDSHARED="$CC -shared" fi fi ;; *-*-irix5*) LDSHARED="ld -shared";; *-*-irix6*) LDSHARED="ld ${SGI_ABI} -shared -all";; *-*-sunos4*) LDSHARED="ld";; *-*-solaris*) LDSHARED="ld -G";; *-*-hp*) LDSHARED="ld -b";; *-*-osf*) LDSHARED="ld -shared -expect_unresolved \"*\"";; *-sequent-sysv4) LDSHARED="ld -G";; *-*-next*) if test "$ns_dyld" then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind' else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r' fi if test "$with_next_framework" ; then LDSHARED="$LDSHARED \$(LDLIBRARY)" fi ;; *-*-linux*) LDSHARED="gcc -shared";; *-*-dgux*) LDSHARED="ld -G";; *-*-freebsd3*) LDSHARED="gcc -shared";; *-*-freebsd* | *-*-openbsd*) LDSHARED="ld -Bshareable";; *-*-netbsd*) if [ "`$CC -dM -E - &5 $as_echo "$LDSHARED" >&6; } # CXXSHARED is the ld *command* used to create C++ shared library # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into # Python, as opposed to building Python itself as a shared library.) { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXSHARED" >&5 $as_echo_n "checking CXXSHARED... " >&6; } if test -z "$CXXSHARED" then CXXSHARED="$LDSHARED" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXSHARED" >&5 $as_echo "$CXXSHARED" >&6; } # { $as_echo "$as_me:${as_lineno-$LINENO}: checking TRYLINKINGWITHCXX" >&5 $as_echo_n "checking TRYLINKINGWITHCXX... " >&6; } if test -z "$TRYLINKINGWITHCXX" then case $host in *-*-solaris*) if test "$GCC" = yes then TRYLINKINGWITHCXX="CXXSHARED= $CXX -Wl,-G" else TRYLINKINGWITHCXX="CXXSHARED= $CXX -G -L/opt/SUNWspro/lib -lCrun -lCstd" fi;; *-*-hp*) TRYLINKINGWITHCXX="CXXSHARED= $CXX +z ";; *-*-darwin*) TRYLINKINGWITHCXX="CXXSHARED= $CXX -bundle -undefined suppress -flat_namespace";; *-*-cygwin* | *-*-mingw*) if test "$GCC" = yes; then TRYLINKINGWITHCXX="CXXSHARED= $CXX -shared " else if test "cl" = $CXX ; then # Microsoft Visual C++ (MSVC) TRYLINKINGWITHCXX="CXXSHARED= $CXX -nologo -LD" else TRYLINKINGWITHCXX="#unknown Windows compiler" fi fi ;; *) TRYLINKINGWITHCXX="CXXSHARED= $CXX -shared ";; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TRYLINKINGWITHCXX" >&5 $as_echo "$TRYLINKINGWITHCXX" >&6; } # CCSHARED are the C *flags* used to create objects to go into a shared # library (module) -- this is only needed for a few systems { $as_echo "$as_me:${as_lineno-$LINENO}: checking CCSHARED" >&5 $as_echo_n "checking CCSHARED... " >&6; } if test -z "$CCSHARED" then case $host in *-*-hp*) if test "$GCC" = yes then CCSHARED="-fpic" else CCSHARED="+z" fi;; *-*-linux*) CCSHARED="-fpic";; *-*-freebsd* | *-*-openbsd*) CCSHARED="-fpic";; *-*-netbsd*) CCSHARED="-fPIC";; *-sco-sysv*) CCSHARED="-KPIC -dy -Bdynamic";; *-*-irix6*) case $CC in *gcc*) CCSHARED="-shared";; *) CCSHARED="";; esac;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CCSHARED" >&5 $as_echo "$CCSHARED" >&6; } # RPATH is the path used to look for shared library files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking RPATH" >&5 $as_echo_n "checking RPATH... " >&6; } if test -z "$RPATH" then case $host in *-*-solaris*) RPATH='-R. -R$(exec_prefix)/lib';; *-*-irix*) RPATH='-rpath .:$(exec_prefix)/lib';; *-*-linux*) RPATH='-Xlinker -rpath $(exec_prefix)/lib -Xlinker -rpath .';; *) RPATH='';; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RPATH" >&5 $as_echo "$RPATH" >&6; } # LINKFORSHARED are the flags passed to the $(CC) command that links # the a few executables -- this is only needed for a few systems { $as_echo "$as_me:${as_lineno-$LINENO}: checking LINKFORSHARED" >&5 $as_echo_n "checking LINKFORSHARED... " >&6; } if test -z "$LINKFORSHARED" then case $host in *-*-aix*) LINKFORSHARED='-Wl,-bE:$(srcdir)/python.exp -lld';; *-*-hp*) LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; *-*-linux*) LINKFORSHARED="-Xlinker -export-dynamic";; *-*-next*) LINKFORSHARED="-u libsys_s";; *-sco-sysv*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";; *-*-irix6*) LINKFORSHARED="-all";; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LINKFORSHARED" >&5 $as_echo "$LINKFORSHARED" >&6; } # Optional CFLAGS used to silence/enhance compiler warnings on some platforms. { $as_echo "$as_me:${as_lineno-$LINENO}: checking PLATCFLAGS" >&5 $as_echo_n "checking PLATCFLAGS... " >&6; } case $host in *-*-solaris*) if test "$GCC" = yes then PLATCFLAGS= else PLATCFLAGS= # else PLATCFLAGS="-errtags=yes" # Need more work as C examples use ld for linking fi;; *) PLATCFLAGS= esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PLATCFLAGS" >&5 $as_echo "$PLATCFLAGS" >&6; } # Add switch if necessary to enable C++11 support - just for tests # Check whether --enable-cpp11-testing was given. if test "${enable_cpp11_testing+set}" = set; then : enableval=$enable_cpp11_testing; enable_cpp11_testing=$enableval else enable_cpp11_testing=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable C++11 testing" >&5 $as_echo_n "checking whether to enable C++11 testing... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_cpp11_testing" >&5 $as_echo "$enable_cpp11_testing" >&6; } PLATCXXFLAGS="$PLATCFLAGS" if test x"$enable_cpp11_testing" = xyes; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXXFLAGS_SAVED=$CXXFLAGS ac_success=no CXX11FLAGS= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 $as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } if ${ax_cv_cxx_compile_cxx11+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ template struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; typedef check> right_angle_brackets; int a; decltype(a) b; typedef check check_type; check_type c; check_type&& cr = static_cast(c); _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ax_cv_cxx_compile_cxx11=yes else ax_cv_cxx_compile_cxx11=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 $as_echo "$ax_cv_cxx_compile_cxx11" >&6; } if test x$ax_cv_cxx_compile_cxx11 = xyes; then ac_success=yes fi if test x$ac_success = xno; then for switch in -std=c++11 -std=c++0x; do cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $switch" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ template struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; typedef check> right_angle_brackets; int a; decltype(a) b; typedef check check_type; check_type c; check_type&& cr = static_cast(c); _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval $cachevar=yes else eval $cachevar=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="$ac_save_CXXFLAGS" fi eval ac_res=\$$cachevar { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXXFLAGS="$CXXFLAGS $switch" CXX11FLAGS=$switch ac_success=yes break fi done fi if test x$ac_success = xno; then if test xnostop != xnostop; then as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 fi else HAVE_CXX11_COMPILER=yes fi CXXFLAGS=$CXXFLAGS_SAVED ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test x"$CXX11FLAGS" != x; then PLATCXXFLAGS="$CXX11FLAGS $PLATCXXFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++11 enabled compiler" >&5 $as_echo_n "checking for C++11 enabled compiler... " >&6; } if test x"$HAVE_CXX11_COMPILER" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_CXX11_COMPILER" >&5 $as_echo "$HAVE_CXX11_COMPILER" >&6; } fi fi # On darwin 10.7,10.8,10.9 using clang++, need to ensure using # libc++ for tests and examples to run under mono. May affect # other language targets as well - problem is an OSX incompatibility # between libraries depending on libstdc++ and libc++. CLANGXX= $CXX -v 2>&1 | grep -i clang >/dev/null && CLANGXX=yes case $host in *-*-darwin11* | *-*-darwin12* |*-*-darwin13* ) if test "$CLANGXX" = "yes"; then PLATCXXFLAGS="$PLATCXXFLAGS -stdlib=libc++" fi;; *) ;; esac # Set info about shared libraries. # This variation is needed on OS-X because there is no (apparent) consistency in shared library naming. # Sometimes .bundle works, but sometimes .so is needed. It depends on the target language case $host in *-*-mingw*) PYTHON_SO=.pyd;; *-*-darwin*) PYTHON_SO=.so;; *) PYTHON_SO=$SO;; esac case $host in *-*-darwin*) TCL_SO=.dylib;; *) TCL_SO=$SO;; esac case $host in *-*-darwin*) GUILE_SO=.so;; *) GUILE_SO=$SO;; esac case $host in *-*-darwin*) PHP_SO=.so;; *) PHP_SO=$SO;; esac case $host in *) MZSCHEME_SO=.so;; esac case $host in *-*-darwin*) LUA_SO=.so;; *) LUA_SO=$SO;; esac # Check for specific libraries. Used for SWIG examples { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF LIBS="-ldl $LIBS" fi # Dynamic linking for SunOS/Solaris and SYSV { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDLD 1 _ACEOF LIBS="-ldld $LIBS" fi # Dynamic linking for HP-UX { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing t_open" >&5 $as_echo_n "checking for library containing t_open... " >&6; } if ${ac_cv_search_t_open+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char t_open (); int main () { return t_open (); ; return 0; } _ACEOF for ac_lib in '' nsl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_t_open=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_t_open+:} false; then : break fi done if ${ac_cv_search_t_open+:} false; then : else ac_cv_search_t_open=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_t_open" >&5 $as_echo "$ac_cv_search_t_open" >&6; } ac_res=$ac_cv_search_t_open if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi # SVR4 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } if ${ac_cv_search_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF for ac_lib in '' inet; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gethostbyname=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_gethostbyname+:} false; then : break fi done if ${ac_cv_search_gethostbyname+:} false; then : else ac_cv_search_gethostbyname=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 $as_echo "$ac_cv_search_gethostbyname" >&6; } ac_res=$ac_cv_search_gethostbyname if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi # Sequent { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 $as_echo_n "checking for library containing socket... " >&6; } if ${ac_cv_search_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char socket (); int main () { return socket (); ; return 0; } _ACEOF for ac_lib in '' socket; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_socket=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_socket+:} false; then : break fi done if ${ac_cv_search_socket+:} false; then : else ac_cv_search_socket=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 $as_echo "$ac_cv_search_socket" >&6; } ac_res=$ac_cv_search_socket if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi # SVR4 sockets { $as_echo "$as_me:${as_lineno-$LINENO}: checking for swill_init in -lswill" >&5 $as_echo_n "checking for swill_init in -lswill... " >&6; } if ${ac_cv_lib_swill_swill_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lswill $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char swill_init (); int main () { return swill_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_swill_swill_init=yes else ac_cv_lib_swill_swill_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_swill_swill_init" >&5 $as_echo "$ac_cv_lib_swill_swill_init" >&6; } if test "x$ac_cv_lib_swill_swill_init" = xyes; then : SWIGLIBS="-lswill $LIBS" SWILL="-DSWIG_SWILL" fi # check for --with-libm=... LIBM=-lm # Check whether --with-libm was given. if test "${with_libm+set}" = set; then : withval=$with_libm; if test "$withval" != yes then LIBM=$withval else as_fn_error $? "proper usage is --with-libm=STRING" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lieee" >&5 $as_echo_n "checking for main in -lieee... " >&6; } if ${ac_cv_lib_ieee_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lieee $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ieee_main=yes else ac_cv_lib_ieee_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ieee_main" >&5 $as_echo "$ac_cv_lib_ieee_main" >&6; } if test "x$ac_cv_lib_ieee_main" = xyes; then : LIBM="-lieee $LIBM" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5 $as_echo_n "checking for crypt in -lcrypt... " >&6; } if ${ac_cv_lib_crypt_crypt+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char crypt (); int main () { return crypt (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_crypt_crypt=yes else ac_cv_lib_crypt_crypt=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt" >&5 $as_echo "$ac_cv_lib_crypt_crypt" >&6; } if test "x$ac_cv_lib_crypt_crypt" = xyes; then : LIBCRYPT="-lcrypt" fi # check for --with-libc=... # Check whether --with-libc was given. if test "${with_libc+set}" = set; then : withval=$with_libc; if test "$withval" != yes then LIBC=$withval else as_fn_error $? "proper usage is --with-libc=STRING" "$LINENO" 5 fi fi #-------------------------------------------------------------------- # Target languages #-------------------------------------------------------------------- # Check whether --with-alllang was given. if test "${with_alllang+set}" = set; then : withval=$with_alllang; with_alllang="$withval" fi #-------------------------------------------------------------------- # Look for Tcl #-------------------------------------------------------------------- TCLINCLUDE= TCLLIB= TCLPACKAGE= # Check whether --with-tclconfig was given. if test "${with_tclconfig+set}" = set; then : withval=$with_tclconfig; with_tclconfig="$withval" else with_tclconfig= fi # Check whether --with-tcl was given. if test "${with_tcl+set}" = set; then : withval=$with_tcl; TCLPACKAGE="$withval" else TCLPACKAGE=yes fi # Check whether --with-tclincl was given. if test "${with_tclincl+set}" = set; then : withval=$with_tclincl; TCLINCLUDE="$ISYSTEM$withval" else TCLINCLUDE= fi # Check whether --with-tcllib was given. if test "${with_tcllib+set}" = set; then : withval=$with_tcllib; TCLLIB="-L$withval" else TCLLIB= fi # First, check for "--without-tcl" or "--with-tcl=no". if test x"${TCLPACKAGE}" = xno -o x"${with_alllang}" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Tcl" >&5 $as_echo "$as_me: Disabling Tcl" >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl configuration" >&5 $as_echo_n "checking for Tcl configuration... " >&6; } # First check to see if --with-tclconfig was specified. if test x"${with_tclconfig}" != x ; then if test -f "${with_tclconfig}/tclConfig.sh" ; then TCLCONFIG=`(cd ${with_tclconfig}; pwd)` else as_fn_error $? "${with_tcl} directory does not contain tclConfig.sh" "$LINENO" 5 fi fi # check in a few common install locations if test x"${TCLCONFIG}" = x ; then for i in `ls -d -r /usr/lib*/ 2>/dev/null` \ `ls -d -r /usr/lib*/tcl*/ 2>/dev/null` \ `ls -d -r /usr/local/lib*/ 2>/dev/null` \ `ls -d -r /usr/local/lib*/tcl*/ 2>/dev/null` ; do if test -f $i"tclConfig.sh" ; then TCLCONFIG=`(cd $i; pwd)` break fi done fi if test x"${TCLCONFIG}" = x ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: found $TCLCONFIG/tclConfig.sh" >&5 $as_echo "found $TCLCONFIG/tclConfig.sh" >&6; } . $TCLCONFIG/tclConfig.sh if test -z "$TCLINCLUDE"; then TCLINCLUDE=`echo $TCL_INCLUDE_SPEC | sed "s/-I/$ISYSTEM/"` fi if test -z "$TCLLIB"; then TCLLIB=$TCL_LIB_SPEC fi fi if test -z "$TCLINCLUDE"; then if test "x$TCLPACKAGE" != xyes; then TCLINCLUDE="$ISYSTEM$TCLPACKAGE/include" fi fi if test -z "$TCLLIB"; then if test "x$TCLPACKAGE" != xyes; then TCLLIB="-L$TCLPACKAGE/lib -ltcl" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl header files" >&5 $as_echo_n "checking for Tcl header files... " >&6; } if test -z "$TCLINCLUDE"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else TCLINCLUDE="" fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$TCLINCLUDE"; then dirs="/usr/local/include /usr/include /opt/local/include" for i in $dirs ; do if test -r $i/tcl.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5 $as_echo "$i" >&6; } TCLINCLUDE="$ISYSTEM$i" break fi done fi if test -z "$TCLINCLUDE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLINCLUDE" >&5 $as_echo "$TCLINCLUDE" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl library" >&5 $as_echo_n "checking for Tcl library... " >&6; } if test -z "$TCLLIB"; then dirs="/usr/local/lib /usr/lib /opt/local/lib" for i in $dirs ; do if test -r $i/libtcl.a; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5 $as_echo "$i" >&6; } TCLLIB="-L$i -ltcl" break fi done if test -z "$TCLLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLLIB" >&5 $as_echo "$TCLLIB" >&6; } fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) TCLDYNAMICLINKING="$TCLLIB";; *)TCLDYNAMICLINKING="";; esac case $host in *-*-darwin*) TCLLDSHARED='$(CC) -dynamiclib -undefined suppress -flat_namespace' TCLCXXSHARED='$(CXX) -dynamiclib -undefined suppress -flat_namespace' ;; *) TCLLDSHARED='$(LDSHARED)' TCLCXXSHARED='$(CXXSHARED)' ;; esac fi #---------------------------------------------------------------- # Look for Python #---------------------------------------------------------------- PYINCLUDE= PYLIB= PYPACKAGE= # Check whether --with-python was given. if test "${with_python+set}" = set; then : withval=$with_python; PYBIN="$withval" else PYBIN=yes fi # First, check for "--without-python" or "--with-python=no". if test x"${PYBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Python" >&5 $as_echo "$as_me: Disabling Python" >&6;} else # First figure out the name of the Python executable if test "x$PYBIN" = xyes; then for ac_prog in python python2.8 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PYTHON+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PYTHON"; then ac_cv_prog_PYTHON="$PYTHON" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PYTHON="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PYTHON=$ac_cv_prog_PYTHON if test -n "$PYTHON"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 $as_echo "$PYTHON" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PYTHON" && break done else PYTHON="$PYBIN" fi if test -n "$PYTHON"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python prefix" >&5 $as_echo_n "checking for Python prefix... " >&6; } PYPREFIX=`($PYTHON -c "import sys; print sys.prefix") 2>/dev/null` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYPREFIX" >&5 $as_echo "$PYPREFIX" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python exec-prefix" >&5 $as_echo_n "checking for Python exec-prefix... " >&6; } PYEPREFIX=`($PYTHON -c "import sys; print sys.exec_prefix") 2>/dev/null` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYEPREFIX" >&5 $as_echo "$PYEPREFIX" >&6; } # Note: I could not think of a standard way to get the version string from different versions. # This trick pulls it out of the file location for a standard library file. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python version" >&5 $as_echo_n "checking for Python version... " >&6; } # Need to do this hack since autoconf replaces __file__ with the name of the configure file filehack="file__" PYVERSION=`($PYTHON -c "import string,operator,os.path; print operator.getitem(os.path.split(operator.getitem(os.path.split(string.__$filehack),0)),1)")` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYVERSION" >&5 $as_echo "$PYVERSION" >&6; } # Find the directory for libraries this is necessary to deal with # platforms that can have apps built for multiple archs: e.g. x86_64 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python lib dir" >&5 $as_echo_n "checking for Python lib dir... " >&6; } PYLIBDIR=`($PYTHON -c "import sys; print sys.lib") 2>/dev/null` if test -z "$PYLIBDIR"; then # Fedora patch Python to add sys.lib, for other distros we assume "lib". PYLIBDIR="lib" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYLIBDIR" >&5 $as_echo "$PYLIBDIR" >&6; } # Set the include directory { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python header files" >&5 $as_echo_n "checking for Python header files... " >&6; } if test -r $PYPREFIX/include/$PYVERSION/Python.h; then PYINCLUDE="-I$PYPREFIX/include/$PYVERSION -I$PYEPREFIX/$PYLIBDIR/$PYVERSION/config" fi if test -z "$PYINCLUDE"; then if test -r $PYPREFIX/include/Py/Python.h; then PYINCLUDE="-I$PYPREFIX/include/Py -I$PYEPREFIX/$PYLIBDIR/python/lib" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYINCLUDE" >&5 $as_echo "$PYINCLUDE" >&6; } # Set the library directory blindly. This probably won't work with older versions { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python library" >&5 $as_echo_n "checking for Python library... " >&6; } dirs="$PYVERSION/config $PYVERSION/$PYLIBDIR python/$PYLIBDIR" for i in $dirs; do if test -d $PYEPREFIX/$PYLIBDIR/$i; then PYLIB="$PYEPREFIX/$PYLIBDIR/$i" break fi done if test -z "$PYLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Not found" >&5 $as_echo "Not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYLIB" >&5 $as_echo "$PYLIB" >&6; } fi PYLINK="-l$PYVERSION" fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) PYTHONDYNAMICLINKING="-L$PYLIB $PYLINK" DEFS="-DUSE_DL_IMPORT $DEFS" ;; *)PYTHONDYNAMICLINKING="";; esac fi #---------------------------------------------------------------- # Look for Python 3.x #---------------------------------------------------------------- # mostly copy & pasted from "Look for Python" section, # did some trim, fix and rename PY3INCLUDE= PY3LIB= PY3PACKAGE= # Check whether --with-python3 was given. if test "${with_python3+set}" = set; then : withval=$with_python3; PY3BIN="$withval" else PY3BIN=yes fi # First, check for "--without-python3" or "--with-python3=no". if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Python 3.x support" >&5 $as_echo "$as_me: Disabling Python 3.x support" >&6;} else if test "x$PY3BIN" = xyes; then for py_ver in 3 3.6 3.5 3.4 3.3 3.2 3.1 3.0; do for ac_prog in python$py_ver do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PYTHON3+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PYTHON3"; then ac_cv_prog_PYTHON3="$PYTHON3" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PYTHON3="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PYTHON3=$ac_cv_prog_PYTHON3 if test -n "$PYTHON3"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON3" >&5 $as_echo "$PYTHON3" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PYTHON3" && break done if test -n "$PYTHON3"; then for ac_prog in $PYTHON3-config do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PY3CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PY3CONFIG"; then ac_cv_prog_PY3CONFIG="$PY3CONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PY3CONFIG="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PY3CONFIG=$ac_cv_prog_PY3CONFIG if test -n "$PY3CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PY3CONFIG" >&5 $as_echo "$PY3CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PY3CONFIG" && break done if test -n "$PY3CONFIG"; then break fi fi done else PYTHON3="$PY3BIN" for ac_prog in $PYTHON3-config do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PY3CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PY3CONFIG"; then ac_cv_prog_PY3CONFIG="$PY3CONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PY3CONFIG="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PY3CONFIG=$ac_cv_prog_PY3CONFIG if test -n "$PY3CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PY3CONFIG" >&5 $as_echo "$PY3CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PY3CONFIG" && break done fi if test -n "$PYTHON3" -a -n "$PY3CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python 3.x prefix" >&5 $as_echo_n "checking for Python 3.x prefix... " >&6; } PY3PREFIX=`($PY3CONFIG --prefix) 2>/dev/null` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PY3PREFIX" >&5 $as_echo "$PY3PREFIX" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python 3.x exec-prefix" >&5 $as_echo_n "checking for Python 3.x exec-prefix... " >&6; } PY3EPREFIX=`($PY3CONFIG --exec-prefix) 2>/dev/null` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PY3EPREFIX" >&5 $as_echo "$PY3EPREFIX" >&6; } # Note: I could not think of a standard way to get the version string from different versions. # This trick pulls it out of the file location for a standard library file. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python 3.x version" >&5 $as_echo_n "checking for Python 3.x version... " >&6; } # Need to do this hack since autoconf replaces __file__ with the name of the configure file filehack="file__" PY3VERSION=`($PYTHON3 -c "import string,operator,os.path; print(operator.getitem(os.path.split(operator.getitem(os.path.split(string.__$filehack),0)),1))")` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PY3VERSION" >&5 $as_echo "$PY3VERSION" >&6; } # Find the directory for libraries this is necessary to deal with # platforms that can have apps built for multiple archs: e.g. x86_64 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python 3.x lib dir" >&5 $as_echo_n "checking for Python 3.x lib dir... " >&6; } PY3LIBDIR=`($PYTHON3 -c "import sys; print(sys.lib)") 2>/dev/null` if test -z "$PY3LIBDIR"; then # some dists don't have sys.lib so the best we can do is assume lib PY3LIBDIR="lib" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PY3LIBDIR" >&5 $as_echo "$PY3LIBDIR" >&6; } # Set the include directory { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python 3.x header files" >&5 $as_echo_n "checking for Python 3.x header files... " >&6; } PY3INCLUDE=`($PY3CONFIG --includes) 2>/dev/null` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PY3INCLUDE" >&5 $as_echo "$PY3INCLUDE" >&6; } # Set the library directory blindly. This probably won't work with older versions { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python 3.x library" >&5 $as_echo_n "checking for Python 3.x library... " >&6; } dirs="$PY3VERSION/config $PY3VERSION/$PY3LIBDIR python/$PY3LIBDIR" for i in $dirs; do if test -d $PY3EPREFIX/$PY3LIBDIR/$i; then PY3LIB="$PY3EPREFIX/$PY3LIBDIR/$i" break fi done if test -z "$PY3LIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Not found" >&5 $as_echo "Not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PY3LIB" >&5 $as_echo "$PY3LIB" >&6; } fi PY3LINK="-l$PY3VERSION" fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK" DEFS="-DUSE_DL_IMPORT $DEFS" ;; *)PYTHON3DYNAMICLINKING="";; esac fi #---------------------------------------------------------------- # Look for Perl5 #---------------------------------------------------------------- PERLBIN= # Check whether --with-perl5 was given. if test "${with_perl5+set}" = set; then : withval=$with_perl5; PERLBIN="$withval" else PERLBIN=yes fi # First, check for "--without-perl5" or "--with-perl5=no". if test x"${PERLBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Perl5" >&5 $as_echo "$as_me: Disabling Perl5" >&6;} PERL= else # First figure out what the name of Perl5 is if test "x$PERLBIN" = xyes; then for ac_prog in perl perl5.6.1 perl5.6.0 perl5.004 perl5.003 perl5.002 perl5.001 perl5 perl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then ac_cv_prog_PERL="$PERL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PERL="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PERL=$ac_cv_prog_PERL if test -n "$PERL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 $as_echo "$PERL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PERL" && break done else PERL="$PERLBIN" fi # This could probably be simplified as for all platforms and all versions of Perl the following apparently should be run to get the compilation options: # perl -MExtUtils::Embed -e ccopts { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Perl5 header files" >&5 $as_echo_n "checking for Perl5 header files... " >&6; } if test -n "$PERL"; then PERL5DIR=`($PERL -e 'use Config; print $Config{archlib}, "\n";') 2>/dev/null` if test -n "$PERL5DIR" ; then dirs="$PERL5DIR $PERL5DIR/CORE" PERL5EXT=none for i in $dirs; do if test -r $i/perl.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5 $as_echo "$i" >&6; } PERL5EXT="$i" break fi done if test "$PERL5EXT" = none; then PERL5EXT="$PERL5DIR/CORE" { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not locate perl.h...using $PERL5EXT" >&5 $as_echo "could not locate perl.h...using $PERL5EXT" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Perl5 library" >&5 $as_echo_n "checking for Perl5 library... " >&6; } PERL5LIB=`($PERL -e 'use Config; $_=$Config{libperl}; s/^lib//; s/$Config{_a}$//; s/\.$Config{so}.*//; print $_, "\n"') 2>/dev/null` if test -z "$PERL5LIB" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL5LIB" >&5 $as_echo "$PERL5LIB" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Perl5 ccflags" >&5 $as_echo_n "checking for Perl5 ccflags... " >&6; } PERL5CCFLAGS=`($PERL -e 'use Config; print $Config{ccflags}, "\n"' | sed "s/-Wdeclaration-after-statement//" | sed "s/-I/$ISYSTEM/") 2>/dev/null` if test -z "$PERL5CCFLAGS" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL5CCFLAGS" >&5 $as_echo "$PERL5CCFLAGS" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Perl5 ccdlflags" >&5 $as_echo_n "checking for Perl5 ccdlflags... " >&6; } PERL5CCDLFLAGS=`($PERL -e 'use Config; print $Config{ccdlflags}, "\n"') 2>/dev/null` if test -z "$PERL5CCDLFLAGS" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL5CCDLFLAGS" >&5 $as_echo "$PERL5CCDLFLAGS" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Perl5 cccdlflags" >&5 $as_echo_n "checking for Perl5 cccdlflags... " >&6; } PERL5CCCDLFLAGS=`($PERL -e 'use Config; print $Config{cccdlflags}, "\n"') 2>/dev/null` if test -z "$PERL5CCCDLFLAGS" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL5CCCDLFLAGS" >&5 $as_echo "$PERL5CCCDLFLAGS" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Perl5 ldflags" >&5 $as_echo_n "checking for Perl5 ldflags... " >&6; } PERL5LDFLAGS=`($PERL -e 'use Config; print $Config{ldflags}, "\n"') 2>/dev/null` if test -z "$PERL5LDFLAGS" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL5LDFLAGS" >&5 $as_echo "$PERL5LDFLAGS" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Perl5 Test::More module" >&5 $as_echo_n "checking for Perl5 Test::More module... " >&6; } # For test-suite PERL5TESTMORE=`($PERL -e 'use Test::More; print "good";') 2>/dev/null` if test -z "$PERL5TESTMORE" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 $as_echo "found" >&6; } fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: unable to determine perl5 configuration" >&5 $as_echo "unable to determine perl5 configuration" >&6; } PERL5EXT=$PERL5DIR fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not figure out how to run perl5" >&5 $as_echo "could not figure out how to run perl5" >&6; } fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) PERL5DYNAMICLINKING="-L$PERL5EXT -l$PERL5LIB";; *)PERL5DYNAMICLINKING="";; esac fi #---------------------------------------------------------------- # Look for Octave #---------------------------------------------------------------- OCTAVEBIN= OCTAVE_SO=.oct # Check whether --with-octave was given. if test "${with_octave+set}" = set; then : withval=$with_octave; OCTAVEBIN="$withval" else OCTAVEBIN=yes fi # First, check for "--without-octave" or "--with-octave=no". if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Octave" >&5 $as_echo "$as_me: Disabling Octave" >&6;} OCTAVE= # First figure out what the name of Octave is elif test "x$OCTAVEBIN" = xyes; then # Extract the first word of "octave", so it can be a program name with args. set dummy octave; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_OCTAVE+:} false; then : $as_echo_n "(cached) " >&6 else case $OCTAVE in [\\/]* | ?:[\\/]*) ac_cv_path_OCTAVE="$OCTAVE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_OCTAVE="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi OCTAVE=$ac_cv_path_OCTAVE if test -n "$OCTAVE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCTAVE" >&5 $as_echo "$OCTAVE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else OCTAVE="$OCTAVEBIN" fi if test -n "$OCTAVE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mkoctfile" >&5 $as_echo_n "checking for mkoctfile... " >&6; } mkoctfile="`dirname ${OCTAVE}`/mkoctfile" if test -x "${mkoctfile}"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${mkoctfile}" >&5 $as_echo "${mkoctfile}" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found, disabling Octave" >&5 $as_echo "not found, disabling Octave" >&6; } OCTAVE= fi fi if test -n "$OCTAVE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Octave preprocessor flags" >&5 $as_echo_n "checking for Octave preprocessor flags... " >&6; } OCTAVE_CPPFLAGS= for n in CPPFLAGS INCFLAGS; do OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} "`unset CPPFLAGS; ${mkoctfile} -p $n` done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCTAVE_CPPFLAGS" >&5 $as_echo "$OCTAVE_CPPFLAGS" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Octave compiler flags" >&5 $as_echo_n "checking for Octave compiler flags... " >&6; } OCTAVE_CXXFLAGS= for n in ALL_CXXFLAGS; do OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} "`unset CXXFLAGS; ${mkoctfile} -p $n` done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCTAVE_CXXFLAGS" >&5 $as_echo "$OCTAVE_CXXFLAGS" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Octave linker flags" >&5 $as_echo_n "checking for Octave linker flags... " >&6; } OCTAVE_LDFLAGS= for n in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`${mkoctfile} -p $n` done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCTAVE_LDFLAGS" >&5 $as_echo "$OCTAVE_LDFLAGS" >&6; } for octave_opt in --silent --norc --no-history --no-window-system; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Octave option '${octave_opt}' is supported" >&5 $as_echo_n "checking if Octave option '${octave_opt}' is supported... " >&6; } octave_out=`${OCTAVE} ${octave_opt} /dev/null 2>&1 | sed -n '1{/unrecognized/p}'` if test "x${octave_out}" = x; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } OCTAVE="${OCTAVE} ${octave_opt}" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi done fi #---------------------------------------------------------------- # Look for java #---------------------------------------------------------------- # Check whether --with-java was given. if test "${with_java+set}" = set; then : withval=$with_java; JAVABIN="$withval" else JAVABIN=yes fi # Check whether --with-javac was given. if test "${with_javac+set}" = set; then : withval=$with_javac; JAVACBIN="$withval" else JAVACBIN= fi # First, check for "--without-java" or "--with-java=no". if test x"${JAVABIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Java" >&5 $as_echo "$as_me: Disabling Java" >&6;} JAVA= else if test "x$JAVABIN" = xyes; then for ac_prog in java kaffe guavac do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_JAVA+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$JAVA"; then ac_cv_prog_JAVA="$JAVA" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_JAVA="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi JAVA=$ac_cv_prog_JAVA if test -n "$JAVA"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVA" >&5 $as_echo "$JAVA" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$JAVA" && break done else JAVA="$JAVABIN" fi if test -z "$JAVACBIN"; then for ac_prog in javac do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_JAVAC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$JAVAC"; then ac_cv_prog_JAVAC="$JAVAC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_JAVAC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi JAVAC=$ac_cv_prog_JAVAC if test -n "$JAVAC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVAC" >&5 $as_echo "$JAVAC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$JAVAC" && break done else JAVAC="$JAVACBIN" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for java include file jni.h" >&5 $as_echo_n "checking for java include file jni.h... " >&6; } # Check whether --with-javaincl was given. if test "${with_javaincl+set}" = set; then : withval=$with_javaincl; JAVAINCDIR="$withval" else JAVAINCDIR= fi if test -z "$JAVAINCDIR" ; then JAVAINCDIR="/usr/j2sdk*/include /usr/local/j2sdk*/include /usr/jdk*/include /usr/local/jdk*/include /opt/j2sdk*/include /opt/jdk*/include /usr/java/include /usr/java/j2sdk*/include /usr/java/jdk*/include /usr/local/java/include /opt/java/include /usr/include/java /usr/local/include/java /usr/lib/java/include /usr/lib/jvm/java*/include /usr/lib64/jvm/java*/include /usr/include/kaffe /usr/local/include/kaffe /usr/include" # Add in default installation directory on Windows for Cygwin case $host in *-*-cygwin* | *-*-mingw*) JAVAINCDIR="c:/Program*Files/Java/jdk*/include d:/Program*Files/Java/jdk*/include c:/j2sdk*/include d:/j2sdk*/include c:/jdk*/include d:/jdk*/include $JAVAINCDIR";; *-*-darwin*) JAVAINCDIR="/System/Library/Frameworks/JavaVM.framework/Headers $JAVAINCDIR";; *);; esac fi JAVAINC="" for d in $JAVAINCDIR ; do if test -r "$d/jni.h" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $d" >&5 $as_echo "$d" >&6; } JAVAINCDIR=$d JAVAINC=-I\"$d\" break fi done if test "$JAVAINC" = "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else # now look for /jni_md.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for java include file jni_md.h" >&5 $as_echo_n "checking for java include file jni_md.h... " >&6; } JAVAMDDIR=`find "$JAVAINCDIR" -follow -name jni_md.h -print` if test "$JAVAMDDIR" = "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else JAVAMDDIR=`dirname "$JAVAMDDIR" | tail -1` JAVAINC="${JAVAINC} -I\"$JAVAMDDIR\"" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVAMDDIR" >&5 $as_echo "$JAVAMDDIR" >&6; } fi fi # java.exe on Cygwin requires the Windows standard (Pascal) calling convention as it is a normal Windows executable and not a Cygwin built executable case $host in *-*-cygwin* | *-*-mingw*) if test "$GCC" = yes; then JAVADYNAMICLINKING=" -mno-cygwin -mthreads -Wl,--add-stdcall-alias" JAVACFLAGS="-mno-cygwin -mthreads" else JAVADYNAMICLINKING="" JAVACFLAGS="" fi ;; *-*-darwin*) JAVADYNAMICLINKING="-dynamiclib -framework JavaVM" JAVACFLAGS="" ;; *) JAVADYNAMICLINKING="" JAVACFLAGS="" ;; esac # Java on Windows platforms including Cygwin doesn't use libname.dll, rather name.dll when loading dlls case $host in *-*-cygwin* | *-*-mingw*) JAVALIBRARYPREFIX="";; *)JAVALIBRARYPREFIX="lib";; esac # Java on Mac OS X tweaks case $host in *-*-darwin*) JAVASO=".jnilib" JAVALDSHARED='$(CC)' JAVACXXSHARED='$(CXX)' ;; *) JAVASO=$SO JAVALDSHARED='$(LDSHARED)' JAVACXXSHARED='$(CXXSHARED)' ;; esac fi #---------------------------------------------------------------- # Look for Javascript #---------------------------------------------------------------- # Check whether --with-javascript was given. if test "${with_javascript+set}" = set; then : withval=$with_javascript; with_javascript="$withval" else with_javascript=yes fi # First, check for "--without-javascript" or "--with-javascript=no". if test x"${with_javascript}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Javascript" >&5 $as_echo "$as_me: Disabling Javascript" >&6;} JAVASCRIPT= else JAVASCRIPT=1 #---------------------------------------------------------------- # General Javascript settings shared by JSC and V8 #---------------------------------------------------------------- case $host in *-*-cygwin* | *-*-mingw*) JSLIBRARYPREFIX="" ;; *) JSLIBRARYPREFIX="lib" ;; esac case $host in *-*-darwin*) JSSO=".dylib" JSLDSHARED='$(CC) -dynamiclib' JSCXXSHARED='$(CXX) -dynamiclib' # HACK: didn't manage to get dynamic module loading working with a g++ compiled interpreter JSINTERPRETERCXX='c++' JSINTERPRETERLINKFLAGS='-g -Wl,-search_paths_first -Wl,-headerpad_max_install_names' ;; *) JSSO=$SO JSLDSHARED='$(LDSHARED)' JSCXXSHARED='$(CXXSHARED)' JSINTERPRETERCXX='$(CXX)' JSINTERPRETERLINKFLAGS='-ldl' ;; esac #---------------------------------------------------------------- # Look for Node.js which is the default Javascript engine #---------------------------------------------------------------- for ac_prog in node do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NODEJS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NODEJS"; then ac_cv_prog_NODEJS="$NODEJS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NODEJS="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NODEJS=$ac_cv_prog_NODEJS if test -n "$NODEJS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NODEJS" >&5 $as_echo "$NODEJS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$NODEJS" && break done if test -n "$NODEJS"; then # node-gyp is needed to run the test-suite/examples for ac_prog in node-gyp do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NODEGYP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NODEGYP"; then ac_cv_prog_NODEGYP="$NODEGYP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NODEGYP="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NODEGYP=$ac_cv_prog_NODEGYP if test -n "$NODEGYP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NODEGYP" >&5 $as_echo "$NODEGYP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$NODEGYP" && break done if test -z "$NODEGYP"; then NODEJS= fi fi #---------------------------------------------------------------- # Look for JavascriptCore (Webkit) settings (JSCOREINCDIR, JSCOREDYNAMICLINKING) #---------------------------------------------------------------- # check for include files { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JavaScriptCore/JavaScript.h" >&5 $as_echo_n "checking for JavaScriptCore/JavaScript.h... " >&6; } # Check whether --with-jscoreinc was given. if test "${with_jscoreinc+set}" = set; then : withval=$with_jscoreinc; JSCOREINCDIR="$withval" else JSCOREINCDIR= fi JSCOREVERSION= if test -z "$JSCOREINCDIR"; then JSCOREINCDIR="/usr/include/ /usr/local/include/" # Add in default directory for JavaScriptCore headers for Linux and MacOSX case $host in *-*-linux*) JSCOREINCDIR="/usr/include/webkit-1.0/ /usr/include/webkitgtk-1.0/ /usr/local/include/webkit-1.0/JavaScriptCore/ $JSCOREINCDIR" ;; *-*-darwin*) JSCOREINCDIR="/System/Library/Frameworks/JavaScriptCore.framework/Headers/ $JSCOREINCDIR" ;; *) ;; esac fi for d in $JSCOREINCDIR ; do if test -r "$d/JavaScriptCore/JavaScript.h" || test -r "$d/JavaScript.h" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $d" >&5 $as_echo "$d" >&6; } JSCOREINCDIR=$d JSCOREINC=-I\"$d\" break fi done if test "$JSCOREINC" = "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } fi # check for JavaScriptCore/Webkit libraries # Check whether --with-jscorelib was given. if test "${with_jscorelib+set}" = set; then : withval=$with_jscorelib; JSCORELIB="-L$withval" else JSCORELIB= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JavaScriptCore/Webkit library" >&5 $as_echo_n "checking for JavaScriptCore/Webkit library... " >&6; } # look for the library when not provided if test -z "$JSCORELIB"; then case $host in *-*-linux*) dirs="/usr/lib64/ /usr/local/lib64/ /usr/lib/ /usr/local/lib/" for i in $dirs ; do if test -r $i/libjavascriptcoregtk-1.0.so; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5 $as_echo "$i" >&6; } JSCORELIB="-L$i -ljavascriptcoregtk-1.0" JSCOREVERSION=`pkg-config --modversion javascriptcoregtk-1.0` break fi done if test -z "$JSCORELIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } JSCENABLED= else JSCOREDYNAMICLINKING="$JSCORELIB" JSCENABLED=1 fi ;; *-*-darwin*) JSCOREDYNAMICLINKING="-framework JavaScriptCore" JSCENABLED=1 ;; *) ;; esac fi #---------------------------------------------------------------- # Look for V8 settings (JSV8INCDIR, JSV8DYNAMICLINKING) #---------------------------------------------------------------- # check for include files { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V8 Javascript v8.h" >&5 $as_echo_n "checking for V8 Javascript v8.h... " >&6; } # Check whether --with-jsv8inc was given. if test "${with_jsv8inc+set}" = set; then : withval=$with_jsv8inc; JSV8INCDIR="$withval" fi # if not include dir is specified we try to find if test -z "$JSV8INCDIR"; then # Add in default directory for JavaScriptCore headers for Linux and MacOSX case $host in *-*-linux*) JSV8INCDIR="/usr/include /usr/local/include/ $JSV8INCDIR" ;; *-*-darwin*) JSV8INCDIR="$JSV8INCDIR" ;; *) ;; esac fi for d in $JSV8INCDIR ; do if test -r "$d/v8.h" ; then JSV8INCDIR=$d JSV8INC=-I\"$d\" break fi done if test "$JSV8INC" = "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JSV8INCDIR" >&5 $as_echo "$JSV8INCDIR" >&6; } fi # check for V8 library { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V8 Javascript library" >&5 $as_echo_n "checking for V8 Javascript library... " >&6; } # Check whether --with-jsv8lib was given. if test "${with_jsv8lib+set}" = set; then : withval=$with_jsv8lib; JSV8LIBDIR="$withval" else JSV8LIB= fi v8libdirs="$JSV8LIBDIR /usr/lib64/ /usr/local/lib64/ /usr/lib/ /usr/local/lib/" for d in $v8libdirs ; do if test -r $d/libv8.so; then JSV8LIBDIR=$d JSV8LIB="-L$d -lv8" break fi done if test "$JSV8LIB" = "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } JSV8ENABLED= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JSV8LIBDIR" >&5 $as_echo "$JSV8LIBDIR" >&6; } JSV8ENABLED=1 fi # linking options case $host in *-*-darwin*) JSV8DYNAMICLINKING="" # TODO: add osx configuration ;; *-*-linux*) JSV8DYNAMICLINKING="$JSV8LIB" ;; *) JSV8DYNAMICLINKING="" ;; esac fi #---------------------------------------------------------------- # Look for gcj #---------------------------------------------------------------- # Check whether --with-gcj was given. if test "${with_gcj+set}" = set; then : withval=$with_gcj; GCJBIN="$withval" else GCJBIN=yes fi # Check whether --with-gcjh was given. if test "${with_gcjh+set}" = set; then : withval=$with_gcjh; GCJHBIN="$withval" else GCJHBIN= fi # First, check for "--without-gcj" or "--with-gcj=no". if test x"${GCJBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling GCJ" >&5 $as_echo "$as_me: Disabling GCJ" >&6;} else if test "x$GCJBIN" = xyes; then for ac_prog in gcj do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_GCJ+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$GCJ"; then ac_cv_prog_GCJ="$GCJ" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_GCJ="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi GCJ=$ac_cv_prog_GCJ if test -n "$GCJ"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GCJ" >&5 $as_echo "$GCJ" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$GCJ" && break done else GCJ="$GCJBIN" fi if test -z "$GCJCBIN"; then for ac_prog in gcjh do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_GCJH+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$GCJH"; then ac_cv_prog_GCJH="$GCJH" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_GCJH="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi GCJH=$ac_cv_prog_GCJH if test -n "$GCJH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GCJH" >&5 $as_echo "$GCJH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$GCJH" && break done else GCJH="$GCJHBIN" fi fi #---------------------------------------------------------------- # Look for Android #---------------------------------------------------------------- # Check whether --with-android was given. if test "${with_android+set}" = set; then : withval=$with_android; ANDROIDBIN="$withval" else ANDROIDBIN=yes fi # Check whether --with-adb was given. if test "${with_adb+set}" = set; then : withval=$with_adb; ADBBIN="$withval" else ADBBIN= fi # Check whether --with-ant was given. if test "${with_ant+set}" = set; then : withval=$with_ant; ANTBIN="$withval" else ANTBIN= fi # Check whether --with-ndk-build was given. if test "${with_ndk_build+set}" = set; then : withval=$with_ndk_build; NDKBUILDBIN="$withval" else NDKBUILDBIN= fi # First, check for "--without-android" or "--with-android=no". if test x"${ANDROIDBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Android" >&5 $as_echo "$as_me: Disabling Android" >&6;} ANDROID= else if test "x$ANDROIDBIN" = xyes; then for ac_prog in android do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ANDROID+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ANDROID"; then ac_cv_prog_ANDROID="$ANDROID" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ANDROID="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ANDROID=$ac_cv_prog_ANDROID if test -n "$ANDROID"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ANDROID" >&5 $as_echo "$ANDROID" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ANDROID" && break done else ANDROID="$ANDROIDBIN" fi if test -z "$ADBBIN"; then for ac_prog in adb do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ADB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ADB"; then ac_cv_prog_ADB="$ADB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ADB="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ADB=$ac_cv_prog_ADB if test -n "$ADB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ADB" >&5 $as_echo "$ADB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ADB" && break done else ADB="$ADBBIN" fi if test -z "$ANTBIN"; then for ac_prog in ant do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ANT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ANT"; then ac_cv_prog_ANT="$ANT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ANT="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ANT=$ac_cv_prog_ANT if test -n "$ANT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ANT" >&5 $as_echo "$ANT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ANT" && break done else ANT="$ANTBIN" fi if test -z "$NDKBUILDBIN"; then for ac_prog in ndk-build do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NDKBUILD+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NDKBUILD"; then ac_cv_prog_NDKBUILD="$NDKBUILD" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NDKBUILD="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NDKBUILD=$ac_cv_prog_NDKBUILD if test -n "$NDKBUILD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NDKBUILD" >&5 $as_echo "$NDKBUILD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$NDKBUILD" && break done else NDKBUILD="$NDKBUILDBIN" fi fi #---------------------------------------------------------------- # Look for Guile #---------------------------------------------------------------- GUILE= GUILE_CFLAGS= GUILE_LIBS= # Check whether --with-guile-config was given. if test "${with_guile_config+set}" = set; then : withval=$with_guile_config; GUILE_CONFIG="$withval" else GUILE_CONFIG= fi # Check whether --with-guile was given. if test "${with_guile+set}" = set; then : withval=$with_guile; GUILE="$withval" else GUILE=yes fi # Check whether --with-guile-cflags was given. if test "${with_guile_cflags+set}" = set; then : withval=$with_guile_cflags; GUILE_CFLAGS="$withval" fi # Check whether --with-guile-libs was given. if test "${with_guile_libs+set}" = set; then : withval=$with_guile_libs; GUILE_LIBS="$withval" fi # First, check for "--without-guile" or "--with-guile=no". if test x"${GUILE}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Guile" >&5 $as_echo "$as_me: Disabling Guile" >&6;} else if test -z "$GUILE_CONFIG" ; then # Extract the first word of "guile-config", so it can be a program name with args. set dummy guile-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GUILE_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $GUILE_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_GUILE_CONFIG="$GUILE_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_GUILE_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi GUILE_CONFIG=$ac_cv_path_GUILE_CONFIG if test -n "$GUILE_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE_CONFIG" >&5 $as_echo "$GUILE_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -n "$GUILE_CONFIG" ; then if test x"$GUILE" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for guile bindir" >&5 $as_echo_n "checking for guile bindir... " >&6; } guile_bindir="`$GUILE_CONFIG info bindir`" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $guile_bindir" >&5 $as_echo "$guile_bindir" >&6; } GUILE=$guile_bindir/guile if ! test -f "$GUILE" ; then GUILE= # Extract the first word of "guile", so it can be a program name with args. set dummy guile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GUILE+:} false; then : $as_echo_n "(cached) " >&6 else case $GUILE in [\\/]* | ?:[\\/]*) ac_cv_path_GUILE="$GUILE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_GUILE="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi GUILE=$ac_cv_path_GUILE if test -n "$GUILE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE" >&5 $as_echo "$GUILE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -f "$GUILE" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for guile version" >&5 $as_echo_n "checking for guile version... " >&6; } guile_version=`$GUILE -c '(display (effective-version))'` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $guile_version" >&5 $as_echo "$guile_version" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for guile version >= 1.8" >&5 $as_echo_n "checking for guile version >= 1.8... " >&6; } guile_good_version=`$GUILE -c '(if (>= (string->number (effective-version)) 1.8) (display "yes") (display "no"))'` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $guile_good_version" >&5 $as_echo "$guile_good_version" >&6; } if test x"$guile_good_version" != xyes ; then GUILE= fi fi if test -z "$GUILE_CFLAGS" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for guile compile flags" >&5 $as_echo_n "checking for guile compile flags... " >&6; } GUILE_CFLAGS="`$GUILE_CONFIG compile`" # Note that this can sometimes be empty { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE_CFLAGS" >&5 $as_echo "$GUILE_CFLAGS" >&6; } fi if test -z "$GUILE_LIBS" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for guile link flags" >&5 $as_echo_n "checking for guile link flags... " >&6; } GUILE_LIBS="`$GUILE_CONFIG link`" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUILE_LIBS" >&5 $as_echo "$GUILE_LIBS" >&6; } fi fi fi #---------------------------------------------------------------- # Look for MzScheme #---------------------------------------------------------------- # Check whether --with-mzscheme was given. if test "${with_mzscheme+set}" = set; then : withval=$with_mzscheme; MZSCHEMEBIN="$withval" else MZSCHEMEBIN=yes fi # Check whether --with-mzc was given. if test "${with_mzc+set}" = set; then : withval=$with_mzc; MZCBIN="$withval" else MZCBIN= fi # First, check for "--without-mzscheme" or "--with-mzscheme=no". if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling MzScheme" >&5 $as_echo "$as_me: Disabling MzScheme" >&6;} MZC= else if test "x$MZSCHEMEBIN" = xyes; then # Extract the first word of "mzscheme", so it can be a program name with args. set dummy mzscheme; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MZSCHEME+:} false; then : $as_echo_n "(cached) " >&6 else case $MZSCHEME in [\\/]* | ?:[\\/]*) ac_cv_path_MZSCHEME="$MZSCHEME" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MZSCHEME="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi MZSCHEME=$ac_cv_path_MZSCHEME if test -n "$MZSCHEME"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MZSCHEME" >&5 $as_echo "$MZSCHEME" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MZSCHEME="$MZSCHEMEBIN" fi if test -z "$MZCBIN"; then # Extract the first word of "mzc", so it can be a program name with args. set dummy mzc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MZC+:} false; then : $as_echo_n "(cached) " >&6 else case $MZC in [\\/]* | ?:[\\/]*) ac_cv_path_MZC="$MZC" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MZC="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi MZC=$ac_cv_path_MZC if test -n "$MZC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MZC" >&5 $as_echo "$MZC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -n "$MZSCHEME"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MzScheme dynext object" >&5 $as_echo_n "checking for MzScheme dynext object... " >&6; } MZDYNOBJ=`$MZSCHEME --eval '(begin (require dynext/link) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (printf "~a" x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` if test -f "$MZDYNOBJ"; then : else # older versions (3.72 approx and earlier) MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` fi if test -f "$MZDYNOBJ"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MZDYNOBJ" >&5 $as_echo "$MZDYNOBJ" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } MZDYNOBJ="" fi fi fi #---------------------------------------------------------------- # Look for Ruby #---------------------------------------------------------------- RUBYBIN= # Check whether --with-ruby was given. if test "${with_ruby+set}" = set; then : withval=$with_ruby; RUBYBIN="$withval" else RUBYBIN=yes fi # First, check for "--without-ruby" or "--with-ruby=no". if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Ruby" >&5 $as_echo "$as_me: Disabling Ruby" >&6;} RUBY= else # First figure out what the name of Ruby is if test "x$RUBYBIN" = xyes; then for ac_prog in ruby do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RUBY+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RUBY"; then ac_cv_prog_RUBY="$RUBY" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RUBY="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RUBY=$ac_cv_prog_RUBY if test -n "$RUBY"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY" >&5 $as_echo "$RUBY" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$RUBY" && break done else RUBY="$RUBYBIN" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ruby header files" >&5 $as_echo_n "checking for Ruby header files... " >&6; } if test -n "$RUBY"; then # Try Ruby1.9+ first RUBYDIR=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyhdrdir"] || $rubyhdrdir') 2>/dev/null` if test x"$RUBYDIR" = x"" || test x"$RUBYDIR" = x"nil"; then RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG["archdir"] || $archdir') 2>/dev/null` else RUBYARCH=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG["arch"] || $arch') 2>/dev/null` fi if test x"$RUBYDIR" != x""; then dirs="$RUBYDIR" RUBYINCLUDE= for i in $dirs; do if test -r $i/ruby.h; then if test x"$RUBYARCH" = x""; then RUBYINCLUDE="-I$i" else RUBYINCLUDE="-I$i -I$i/$RUBYARCH" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBYINCLUDE" >&5 $as_echo "$RUBYINCLUDE" >&6; } break fi done if test x"$RUBYINCLUDE" = x""; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not locate ruby.h" >&5 $as_echo "could not locate ruby.h" >&6; } fi # Find library and path for linking. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ruby library" >&5 $as_echo_n "checking for Ruby library... " >&6; } RUBYLIB="" rb_libdir=`($RUBY -rrbconfig -e 'print Config::CONFIG["libdir"]') 2>/dev/null` rb_bindir=`($RUBY -rrbconfig -e 'print Config::CONFIG["bindir"]') 2>/dev/null` dirs="$dirs $rb_libdir $rb_bindir" rb_libruby=`($RUBY -rrbconfig -e 'print Config::CONFIG["LIBRUBY_A"]') 2>/dev/null` RUBYLINK=`($RUBY -rrbconfig -e ' c = Config::CONFIG if c.has_key? "LIBRUBYARG_STATIC" # 1.8.x if c["LIBRUBY"] == c["LIBRUBY_A"] link = c["LIBRUBYARG_STATIC"] else link = c["LIBRUBYARG_SHARED"] end else # 1.6.x link = "-l" + c["RUBY_INSTALL_NAME"] end # Get the target Ruby was built for target = c["target"] if target == "i386-pc-mswin32" # Need to change msvcrt-ruby*.lib to -lmsvcrt-ruby* ext = File.extname(link) # Get index that counts backwards from end of string index = -1 - ext.size # Strip off the extension link = link.slice(0..index) puts "-l#{link}" else puts link end') 2>/dev/null` if test "$rb_libruby" != ""; then for i in $dirs; do if (test -r $i/$rb_libruby;) then RUBYLIB="$i" break fi done fi if test "$RUBYLIB" = ""; then RUBYLIB="$RUBYDIR" { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found... using $RUBYDIR" >&5 $as_echo "not found... using $RUBYDIR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBYLINK in $RUBYLIB" >&5 $as_echo "$RUBYLINK in $RUBYLIB" >&6; } fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: unable to determine ruby configuration" >&5 $as_echo "unable to determine ruby configuration" >&6; } fi case $host in *-*-mingw*) ;; # do nothing, the default windows libraries are already included *) RUBYLINK="$RUBYLINK `($RUBY -rrbconfig -e 'print Config::CONFIG["LIBS"]') 2>/dev/null`";; esac RUBYCCDLFLAGS=`($RUBY -rrbconfig -e 'print Config::CONFIG["CCDLFLAGS"]') 2>/dev/null` RUBYSO=.`($RUBY -rrbconfig -e 'print Config::CONFIG["DLEXT"]') 2>/dev/null` else { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not figure out how to run ruby" >&5 $as_echo "could not figure out how to run ruby" >&6; } fi case $host in *-*-cygwin* | *-*-mingw*) RUBYDYNAMICLINKING="-L$RUBYLIB $RUBYLINK";; *) RUBYDYNAMICLINKING="";; esac fi #------------------------------------------------------------------------- # Look for PHP #------------------------------------------------------------------------- PHPBIN= # Check whether --with-php was given. if test "${with_php+set}" = set; then : withval=$with_php; PHPBIN="$withval" else PHPBIN=yes fi # First, check for "--without-php" or "--with-php=no". if test x"${PHPBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling PHP" >&5 $as_echo "$as_me: Disabling PHP" >&6;} PHP= else if test "x$PHPBIN" = xyes; then for ac_prog in php5 php do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PHP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PHP"; then ac_cv_prog_PHP="$PHP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PHP="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PHP=$ac_cv_prog_PHP if test -n "$PHP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PHP" >&5 $as_echo "$PHP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PHP" && break done else PHP=$PHPBIN fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PHP header files" >&5 $as_echo_n "checking for PHP header files... " >&6; } case $PHP in *5) PHPCONFIG=`echo "$PHP"|sed 's/5$/-config5/'` ;; *) PHPCONFIG=$PHP-config ;; esac php_version=`$PHPCONFIG --version 2>/dev/null` case $php_version in 5*) PHPINC=`$PHPCONFIG --includes 2>/dev/null` if test -n "$PHPINC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PHPINC" >&5 $as_echo "$PHPINC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: found PHP $version, but only PHP 5 is supported" >&5 $as_echo "found PHP $version, but only PHP 5 is supported" >&6; } ;; esac fi #---------------------------------------------------------------- # Look for ocaml #---------------------------------------------------------------- # Check whether --with-ocaml was given. if test "${with_ocaml+set}" = set; then : withval=$with_ocaml; OCAMLBIN="$withval" else OCAMLBIN=yes fi # Check whether --with-ocamlc was given. if test "${with_ocamlc+set}" = set; then : withval=$with_ocamlc; OCAMLC="$withval" else OCAMLC= fi # Check whether --with-ocamldlgen was given. if test "${with_ocamldlgen+set}" = set; then : withval=$with_ocamldlgen; OCAMLDLGEN="$withval" else OCAMLDLGEN= fi # Check whether --with-ocamlfind was given. if test "${with_ocamlfind+set}" = set; then : withval=$with_ocamlfind; OCAMLFIND="$withval" else OCAMLFIND= fi # Check whether --with-ocamlmktop was given. if test "${with_ocamlmktop+set}" = set; then : withval=$with_ocamlmktop; OCAMLMKTOP="$withval" else OCAMLMKTOP= fi # First, check for "--without-ocaml" or "--with-ocaml=no". if test x"${OCAMLBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling OCaml" >&5 $as_echo "$as_me: Disabling OCaml" >&6;} OCAMLBIN= else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ocaml DL load generator" >&5 $as_echo_n "checking for Ocaml DL load generator... " >&6; } if test -z "$OCAMLDLGEN"; then for ac_prog in ocamldlgen do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLDLGEN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLDLGEN"; then ac_cv_prog_OCAMLDLGEN="$OCAMLDLGEN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OCAMLDLGEN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLDLGEN=$ac_cv_prog_OCAMLDLGEN if test -n "$OCAMLDLGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDLGEN" >&5 $as_echo "$OCAMLDLGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$OCAMLDLGEN" && break done test -n "$OCAMLDLGEN" || OCAMLDLGEN=":" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ocaml package tool" >&5 $as_echo_n "checking for Ocaml package tool... " >&6; } if test -z "$OCAMLFIND"; then for ac_prog in ocamlfind do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLFIND+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLFIND"; then ac_cv_prog_OCAMLFIND="$OCAMLFIND" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OCAMLFIND="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLFIND=$ac_cv_prog_OCAMLFIND if test -n "$OCAMLFIND"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLFIND" >&5 $as_echo "$OCAMLFIND" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$OCAMLFIND" && break done test -n "$OCAMLFIND" || OCAMLFIND=":" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ocaml compiler" >&5 $as_echo_n "checking for Ocaml compiler... " >&6; } if test -z "$OCAMLC"; then for ac_prog in ocamlc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLC"; then ac_cv_prog_OCAMLC="$OCAMLC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OCAMLC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLC=$ac_cv_prog_OCAMLC if test -n "$OCAMLC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLC" >&5 $as_echo "$OCAMLC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$OCAMLC" && break done test -n "$OCAMLC" || OCAMLC=":" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ocaml interpreter" >&5 $as_echo_n "checking for Ocaml interpreter... " >&6; } if test "x$OCAMLBIN" = xyes; then for ac_prog in ocaml do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLBIN"; then ac_cv_prog_OCAMLBIN="$OCAMLBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OCAMLBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLBIN=$ac_cv_prog_OCAMLBIN if test -n "$OCAMLBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLBIN" >&5 $as_echo "$OCAMLBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$OCAMLBIN" && break done test -n "$OCAMLBIN" || OCAMLBIN=":" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ocaml toplevel creator" >&5 $as_echo_n "checking for Ocaml toplevel creator... " >&6; } if test -z "$OCAMLMKTOP"; then for ac_prog in ocamlmktop do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLMKTOP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLMKTOP"; then ac_cv_prog_OCAMLMKTOP="$OCAMLMKTOP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OCAMLMKTOP="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLMKTOP=$ac_cv_prog_OCAMLMKTOP if test -n "$OCAMLMKTOP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKTOP" >&5 $as_echo "$OCAMLMKTOP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$OCAMLMKTOP" && break done test -n "$OCAMLMKTOP" || OCAMLMKTOP=":" fi OCAMLLOC=loc if test "$OCAMLC" != ":" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ocaml header files" >&5 $as_echo_n "checking for Ocaml header files... " >&6; } dirs="/usr/lib/ocaml/caml /usr/local/lib/ocaml/caml" dir="`$OCAMLC -where 2>/dev/null`" if test "$dir"; then dirs="$dir/caml $dirs" fi for i in $dirs; do if test -r $i/mlvalues.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5 $as_echo "$i" >&6; } OCAMLEXT="$i" OCAMLINC="-I$OCAMLEXT" break fi done if test -z "$OCAMLINC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ocaml version 3.08.2 or higher" >&5 $as_echo_n "checking for Ocaml version 3.08.2 or higher... " >&6; } OCAMLVER=`$OCAMLC -version | sed -e 's/.*version //g'` # Split the version into units. ver_a="$OCAMLVER" ver_b="3.08.2" nodots_a=`echo $ver_a | sed -e 's/\./ /g'` condition="equal" isolate_b_regex='\([0-9]\+\).*' for ver_part in $nodots_a ; do b_ver_part=`echo "$ver_b" | sed -e 's/'"$isolate_b_regex"'/\1/'` if test \( "$ver_part" -lt "$b_ver_part" \) -a \( "x$condition" = "xequal" \) ; then condition=less elif test \( "$ver_part" -gt "$b_ver_part" \) -a \( "x$condition" = "xequal" \) ; then condition=greater fi isolate_b_regex='[0-9]\+\.'"$isolate_b_regex" done if test "x$condition" = "xequal" ; then : elif test "x$condition" = "xless" ; then : elif test "x$condition" = "xgreater" ; then OCAMLLOC=_loc fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLVER" >&5 $as_echo "$OCAMLVER" >&6; } fi fi # Disabling ocaml export OCAMLLOC export OCAMLVER export OCAMLINC export OCAMLBIN export OCAMLC export OCAMLDLGEN export OCAMLFIND export OCAMLMKTOP #---------------------------------------------------------------- # Look for Pike #---------------------------------------------------------------- # Identify the name of the Pike executable # Priority: configure option, automatic search PIKEBIN= # Check whether --with-pike was given. if test "${with_pike+set}" = set; then : withval=$with_pike; PIKEBIN="$withval" else PIKEBIN=yes fi # First, check for "--without-pike" or "--with-pike=no". if test x"${PIKEBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Pike" >&5 $as_echo "$as_me: Disabling Pike" >&6;} PIKEBIN= else if test "x$PIKEBIN" = xyes; then for ac_prog in pike pike7.8 pike7.6 pike7.4 pike7.2 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PIKE+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PIKE"; then ac_cv_prog_PIKE="$PIKE" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PIKE="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PIKE=$ac_cv_prog_PIKE if test -n "$PIKE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PIKE" >&5 $as_echo "$PIKE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PIKE" && break done else PIKE="$PIKEBIN" fi # Check for pike-config # Priority: configure option, guessed from $PIKE, search from list # Check whether --with-pike-config was given. if test "${with_pike_config+set}" = set; then : withval=$with_pike_config; PIKECONFIG="$withval" else PIKECONFIG="" fi if test -z "$PIKECONFIG" -a -n "$PIKE"; then for ac_prog in $PIKE-config pike-config \ pike7.6-config pike7.4-config pike7.2-config do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PIKECONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PIKECONFIG"; then ac_cv_prog_PIKECONFIG="$PIKECONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PIKECONFIG="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PIKECONFIG=$ac_cv_prog_PIKECONFIG if test -n "$PIKECONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PIKECONFIG" >&5 $as_echo "$PIKECONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PIKECONFIG" && break done fi # Check for a --with-pikeincl option to configure # Priority: configure option, info from $PIKECONFIG, guessed by pike script # Check whether --with-pikeincl was given. if test "${with_pikeincl+set}" = set; then : withval=$with_pikeincl; PIKEINCLUDE="-I$withval" else PIKEINCLUDE= fi if test -n "$PIKE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Pike header files" >&5 $as_echo_n "checking for Pike header files... " >&6; } if test -z "$PIKEINCLUDE" -a -n "$PIKECONFIG"; then PIKEINCLUDE=`$PIKECONFIG --cflags` fi if test -z "$PIKEINCLUDE" -a -n "$PIKE"; then PIKEINCLUDE=`$PIKE -x cflags` if test -z "$PIKEINCLUDE"; then PIKEPATH=`which $PIKE` PIKEINCLUDE=`$PIKE Tools/check-include-path.pike $PIKEPATH` PIKEINCLUDE="-I$PIKEINCLUDE" fi fi if test -z "$PIKEINCLUDE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PIKEINCLUDE" >&5 $as_echo "$PIKEINCLUDE" >&6; } fi fi fi #---------------------------------------------------------------- # Look for CHICKEN #---------------------------------------------------------------- CHICKEN= CHICKEN_CONFIG= CHICKENHOME= CHICKENOPTS= CHICKENLIB= # Check whether --with-chicken was given. if test "${with_chicken+set}" = set; then : withval=$with_chicken; CHICKENBIN="$withval" else CHICKENBIN=yes fi # First, check for "--without-chicken" or "--with-chicken=no". if test x"${CHICKENBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling CHICKEN" >&5 $as_echo "$as_me: Disabling CHICKEN" >&6;} else if test "x$CHICKENBIN" = xyes; then for ac_prog in chicken do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CHICKEN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CHICKEN"; then ac_cv_prog_CHICKEN="$CHICKEN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CHICKEN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CHICKEN=$ac_cv_prog_CHICKEN if test -n "$CHICKEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHICKEN" >&5 $as_echo "$CHICKEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CHICKEN" && break done else CHICKEN="$CHICKENBIN" fi # Check whether --with-chickencsc was given. if test "${with_chickencsc+set}" = set; then : withval=$with_chickencsc; CHICKEN_CSC="$withval" else CHICKEN_CSC= fi if test -z "$CHICKEN_CSC"; then for ac_prog in csc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CHICKEN_CSC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CHICKEN_CSC"; then ac_cv_prog_CHICKEN_CSC="$CHICKEN_CSC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CHICKEN_CSC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CHICKEN_CSC=$ac_cv_prog_CHICKEN_CSC if test -n "$CHICKEN_CSC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHICKEN_CSC" >&5 $as_echo "$CHICKEN_CSC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CHICKEN_CSC" && break done # Both the Microsoft C# compiler and chicken have an executable called csc, so check that this csc is really the chicken one if test -n "$CHICKEN_CSC" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether csc is the chicken compiler" >&5 $as_echo_n "checking whether csc is the chicken compiler... " >&6; } $CHICKEN_CSC -version 2>/dev/null | grep "chicken" > /dev/null || CHICKEN_CSC="" if test -z "$CHICKEN_CSC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi fi # Check whether --with-chickencsi was given. if test "${with_chickencsi+set}" = set; then : withval=$with_chickencsi; CHICKEN_CSI="$withval" else CHICKEN_CSI= fi if test -z "$CHICKEN_CSI"; then for ac_prog in csi do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CHICKEN_CSI+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CHICKEN_CSI"; then ac_cv_prog_CHICKEN_CSI="$CHICKEN_CSI" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CHICKEN_CSI="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CHICKEN_CSI=$ac_cv_prog_CHICKEN_CSI if test -n "$CHICKEN_CSI"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHICKEN_CSI" >&5 $as_echo "$CHICKEN_CSI" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CHICKEN_CSI" && break done fi if test -n "$CHICKEN_CSC" ; then # Check whether --with-chickenopts was given. if test "${with_chickenopts+set}" = set; then : withval=$with_chickenopts; CHICKENOPTS="$withval" else CHICKENOPTS= fi # Check whether --with-chickensharedlib was given. if test "${with_chickensharedlib+set}" = set; then : withval=$with_chickensharedlib; CHICKENSHAREDLIB="$withval" else CHICKENSHAREDLIB= fi # Check whether --with-chickenlib was given. if test "${with_chickenlib+set}" = set; then : withval=$with_chickenlib; CHICKENLIB="$withval" else CHICKENLIB= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler options for static CHICKEN generated code" >&5 $as_echo_n "checking for compiler options for static CHICKEN generated code... " >&6; } if test -z "$CHICKENOPTS"; then CHICKENOPTS="`$CHICKEN_CSC -cflags`" else CHICKENOPTS="`$CHICKEN_CSC -cflags` $CHICKENOPTS" fi if test -z "$CHICKENOPTS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHICKENOPTS" >&5 $as_echo "$CHICKENOPTS" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker options for shared CHICKEN generated code" >&5 $as_echo_n "checking for linker options for shared CHICKEN generated code... " >&6; } if test -z "$CHICKENSHAREDLIB"; then CHICKENSHAREDLIB="`$CHICKEN_CSC -shared -libs`" else CHICKENSHAREDLIB="`$CHICKEN_CSC -shared -libs` $CHICKENSHAREDLIB" fi if test -z "$CHICKENSHAREDLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHICKENSHAREDLIB" >&5 $as_echo "$CHICKENSHAREDLIB" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker options for static CHICKEN generated code" >&5 $as_echo_n "checking for linker options for static CHICKEN generated code... " >&6; } if test -z "$CHICKENLIB"; then CHICKENLIB="`$CHICKEN_CSC -libs`" else CHICKENLIB="`$CHICKEN_CSC -libs` $CHICKENLIB" fi if test -z "$CHICKENLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHICKENLIB" >&5 $as_echo "$CHICKENLIB" >&6; } fi fi # have CHICKEN_CONFIG fi # Check for --without-chicken #---------------------------------------------------------------- # Look for C# #---------------------------------------------------------------- # Check whether --with-csharp was given. if test "${with_csharp+set}" = set; then : withval=$with_csharp; with_csharp="$withval" else with_csharp=yes fi # Check whether --with-cil-interpreter was given. if test "${with_cil_interpreter+set}" = set; then : withval=$with_cil_interpreter; CSHARPBIN="$withval" else CSHARPBIN= fi # Check whether --with-csharp-compiler was given. if test "${with_csharp_compiler+set}" = set; then : withval=$with_csharp_compiler; CSHARPCOMPILERBIN="$withval" else CSHARPCOMPILERBIN= fi # First, check for "--without-csharp" or "--with-csharp=no". if test x"${with_csharp}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling CSharp" >&5 $as_echo "$as_me: Disabling CSharp" >&6;} CSHARPCOMPILER= else if test -z "$CSHARPCOMPILERBIN" ; then case $host in *-*-cygwin* | *-*-mingw*) # prefer Mono gmcs (.NET 2.0) over mcs (.NET 1.1) - note mcs-1.2.3 has major pinvoke bug for ac_prog in csc mono-csc gmcs mcs cscc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CSHARPCOMPILER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CSHARPCOMPILER"; then ac_cv_prog_CSHARPCOMPILER="$CSHARPCOMPILER" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CSHARPCOMPILER="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CSHARPCOMPILER=$ac_cv_prog_CSHARPCOMPILER if test -n "$CSHARPCOMPILER"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CSHARPCOMPILER" >&5 $as_echo "$CSHARPCOMPILER" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CSHARPCOMPILER" && break done if test -n "$CSHARPCOMPILER" && test "$CSHARPCOMPILER" = "csc" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether csc is the Microsoft CSharp compiler" >&5 $as_echo_n "checking whether csc is the Microsoft CSharp compiler... " >&6; } csc 2>/dev/null | grep "C#" > /dev/null || CSHARPCOMPILER="" if test -z "$CSHARPCOMPILER" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } for ac_prog in mono-csc gmcs mcs cscc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CSHARPCOMPILER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CSHARPCOMPILER"; then ac_cv_prog_CSHARPCOMPILER="$CSHARPCOMPILER" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CSHARPCOMPILER="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CSHARPCOMPILER=$ac_cv_prog_CSHARPCOMPILER if test -n "$CSHARPCOMPILER"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CSHARPCOMPILER" >&5 $as_echo "$CSHARPCOMPILER" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CSHARPCOMPILER" && break done else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi ;; *)for ac_prog in mono-csc gmcs mcs cscc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CSHARPCOMPILER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CSHARPCOMPILER"; then ac_cv_prog_CSHARPCOMPILER="$CSHARPCOMPILER" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CSHARPCOMPILER="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CSHARPCOMPILER=$ac_cv_prog_CSHARPCOMPILER if test -n "$CSHARPCOMPILER"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CSHARPCOMPILER" >&5 $as_echo "$CSHARPCOMPILER" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CSHARPCOMPILER" && break done ;; esac else CSHARPCOMPILER="$CSHARPCOMPILERBIN" fi CSHARPPATHSEPARATOR="/" CSHARPCYGPATH_W=echo if test -z "$CSHARPBIN" ; then CSHARPCILINTERPRETER="" CSHARPCILINTERPRETER_FLAGS="" if test "cscc" = "$CSHARPCOMPILER" ; then for ac_prog in ilrun do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CSHARPCILINTERPRETER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CSHARPCILINTERPRETER"; then ac_cv_prog_CSHARPCILINTERPRETER="$CSHARPCILINTERPRETER" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CSHARPCILINTERPRETER="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CSHARPCILINTERPRETER=$ac_cv_prog_CSHARPCILINTERPRETER if test -n "$CSHARPCILINTERPRETER"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CSHARPCILINTERPRETER" >&5 $as_echo "$CSHARPCILINTERPRETER" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CSHARPCILINTERPRETER" && break done else if test "mcs" = "$CSHARPCOMPILER"; then # Check that mcs is the C# compiler and not the Unix mcs utility by examining the output of 'mcs --version' # The Mono compiler should emit: Mono C# compiler version a.b.c.d csharp_version_raw=`(mcs --version) 2>/dev/null` csharp_version_searched=`(mcs --version | sed -e "/C#/b" -e "/Mono/b" -e d) 2>/dev/null` # return string if contains 'Mono' or 'C#' CSHARPCOMPILER="" if test -n "$csharp_version_raw" ; then if test "$csharp_version_raw" = "$csharp_version_searched" ; then CSHARPCOMPILER="mcs" fi fi if test "mcs" != "$CSHARPCOMPILER" ; then echo "mcs is not a working Mono C# compiler" fi fi if test "mcs" = "$CSHARPCOMPILER" || test "gmcs" = "$CSHARPCOMPILER" || test "mono-csc" = "$CSHARPCOMPILER"; then for ac_prog in mono do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CSHARPCILINTERPRETER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CSHARPCILINTERPRETER"; then ac_cv_prog_CSHARPCILINTERPRETER="$CSHARPCILINTERPRETER" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CSHARPCILINTERPRETER="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CSHARPCILINTERPRETER=$ac_cv_prog_CSHARPCILINTERPRETER if test -n "$CSHARPCILINTERPRETER"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CSHARPCILINTERPRETER" >&5 $as_echo "$CSHARPCILINTERPRETER" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CSHARPCILINTERPRETER" && break done # Mono JIT CSHARPCILINTERPRETER_FLAGS="--debug" else if test "csc" = "$CSHARPCOMPILER"; then CSHARPPATHSEPARATOR="\\\\" CSHARPCYGPATH_W='cygpath -w' fi fi fi else CSHARPCILINTERPRETER="$CSHARPBIN" fi # Cygwin requires the Windows standard (Pascal) calling convention as it is a Windows executable and not a Cygwin built executable case $host in *-*-cygwin* | *-*-mingw*) if test "$GCC" = yes; then CSHARPDYNAMICLINKING=" -mno-cygwin -mthreads -Wl,--add-stdcall-alias" CSHARPCFLAGS="-mno-cygwin -mthreads" else CSHARPDYNAMICLINKING="" CSHARPCFLAGS="" fi ;; *) CSHARPDYNAMICLINKING="" CSHARPCFLAGS="" ;; esac # CSharp on Windows platforms including Cygwin doesn't use libname.dll, rather name.dll when loading dlls case $host in *-*-cygwin* | *-*-mingw*) CSHARPLIBRARYPREFIX="";; *)CSHARPLIBRARYPREFIX="lib";; esac # C#/Mono on Mac OS X tweaks case $host in *-*-darwin*) CSHARPSO=".so" ;; *) CSHARPSO=$SO ;; esac fi # Is this going to be used? #---------------------------------------------------------------- # Look for Lua #---------------------------------------------------------------- LUABIN= LUAINCLUDE= LUALIB= LUADYNAMICLOADLIB= LUAFLAGS= LUALINK= # note: if LUABIN is empty then lua tests will not be done # LUABIN will be cleared if certain dependencies cannot be found # Check whether --with-lua was given. if test "${with_lua+set}" = set; then : withval=$with_lua; LUABIN="$withval" else LUABIN=yes fi # Check whether --with-luaincl was given. if test "${with_luaincl+set}" = set; then : withval=$with_luaincl; LUAINCLUDE="$withval" else LUAINCLUDE= fi # Check whether --with-lualib was given. if test "${with_lualib+set}" = set; then : withval=$with_lualib; LUALIB="$withval" else LUALIB= fi # First, check for "--without-lua" or "--with-lua=no". if test x"${LUABIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Lua" >&5 $as_echo "$as_me: Disabling Lua" >&6;} else # can we find lua? if test "x$LUABIN" = xyes; then # We look for a versioned Lua binary first, as there can be # multiple versions of Lua installed on some systems (like Debian). # The search order should match the include-file and library search # orders below (a Lua shared library built for one version may not # work with a Lua binary of a different version). for ac_prog in lua5.2 lua5.1 lua do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_LUABIN+:} false; then : $as_echo_n "(cached) " >&6 else case $LUABIN in [\\/]* | ?:[\\/]*) ac_cv_path_LUABIN="$LUABIN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_LUABIN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi LUABIN=$ac_cv_path_LUABIN if test -n "$LUABIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LUABIN" >&5 $as_echo "$LUABIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$LUABIN" && break done fi # check version: we need Lua 5.x if test "$LUABIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking Lua version" >&5 $as_echo_n "checking Lua version... " >&6; } # if version 5.x LUAV5=`$LUABIN -e 'if string.sub(_VERSION,5,5)=="5" then print "1" end'` # if not version 5.0 LUAV51=`$LUABIN -e 'if string.sub(_VERSION,5,7)~="5.0" then print "1" end'` if test -z "$LUAV5"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Not Lua 5.x" >&5 $as_echo "$as_me: WARNING: Not Lua 5.x" >&2;} LUABIN="" elif test -z "$LUAV51"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Lua 5.0.x" >&5 $as_echo "Lua 5.0.x" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: Lua 5.1 or later" >&5 $as_echo "Lua 5.1 or later" >&6; } fi fi if test "$LUABIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Lua dynamic loading is enabled" >&5 $as_echo_n "checking whether Lua dynamic loading is enabled... " >&6; } # using Lua to check Lua # lua 5.0 & 5.1 have different fn names if test -z "$LUAV51"; then LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=loadlib("no_such_lib","") if c~="absent" then print "1" end'` else LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=package.loadlib("no_such_lib","") if c~="absent" then print "1" end'` fi if test -z "$LUADYNAMICLOADLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi # look for the header files & set LUAFLAGS accordingly # will clear LUABIN if not present if test -n "$LUAINCLUDE"; then as_ac_File=`$as_echo "ac_cv_file_$LUAINCLUDE/lua.h" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LUAINCLUDE/lua.h" >&5 $as_echo_n "checking for $LUAINCLUDE/lua.h... " >&6; } if eval \${$as_ac_File+:} false; then : $as_echo_n "(cached) " >&6 else test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r "$LUAINCLUDE/lua.h"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : LUAFLAGS="$ISYSTEM$LUAINCLUDE" else LUABIN= fi else LUA_OK="1" ac_fn_c_check_header_mongrel "$LINENO" "lua.h" "ac_cv_header_lua_h" "$ac_includes_default" if test "x$ac_cv_header_lua_h" = xyes; then : LUAFLAGS="" else LUA_OK="" fi # if we didn't get it, going to have to look elsewhere (the hard way) if test -z "$LUA_OK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua.h in other locations" >&5 $as_echo_n "checking for lua.h in other locations... " >&6; } # note: Debian/Ubuntu seem to like /usr/include/lua5.1/lua.h # The ordering of the include directories to search should match # the ordering of libraries to search in the library test below. inc=/usr/include dirs="$inc/lua5.2 $inc/lua5.1 $inc/lua51 $inc/lua5.0 $inc/lua50 /usr/local/include" for i in $dirs; do #echo "$i" if test -r $i/lua.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i/lua.h" >&5 $as_echo "$i/lua.h" >&6; } LUAFLAGS="$ISYSTEM$i" break fi done if test -z "$LUAFLAGS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } LUABIN="" # clear the bin fi fi fi # look for the library files & set LUALINK accordingly # will clear LUABIN if not present lua_save_LIBS=$LIBS # the code seems to disrupt LIBS, so saving if test -n "$LUALIB"; then as_ac_File=`$as_echo "ac_cv_file_$LUALIB/liblua.a" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LUALIB/liblua.a" >&5 $as_echo_n "checking for $LUALIB/liblua.a... " >&6; } if eval \${$as_ac_File+:} false; then : $as_echo_n "(cached) " >&6 else test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r "$LUALIB/liblua.a"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : LUALINK="-L$LUALIB -llua" else LUABIN= fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing lua_close" >&5 $as_echo_n "checking for library containing lua_close... " >&6; } if ${ac_cv_search_lua_close+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char lua_close (); int main () { return lua_close (); ; return 0; } _ACEOF for ac_lib in '' lua lua5.2 lua5.1 lua51 lua5.0 lua50; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_lua_close=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_lua_close+:} false; then : break fi done if ${ac_cv_search_lua_close+:} false; then : else ac_cv_search_lua_close=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_lua_close" >&5 $as_echo "$ac_cv_search_lua_close" >&6; } ac_res=$ac_cv_search_lua_close if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" LUALINK="-l$ac_lib" else LUABIN= fi fi # adding lualib for lua 5.0 if test -z "$LUAV51"; then # extra for lua 5.0 LUALINK="$LUALINK -llualib" fi LIBS=$lua_save_LIBS # restore LIBS fi # if not disabled #---------------------------------------------------------------- # Look for Allegro Common Lisp #---------------------------------------------------------------- ALLEGROCLBIN= # Check whether --with-allegrocl was given. if test "${with_allegrocl+set}" = set; then : withval=$with_allegrocl; ALLEGROCLBIN="$withval" else ALLEGROCLBIN=yes fi # First, check for "--without-allegrocl" or "--with-allegrocl=no". if test x"${ALLEGROCLBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Allegro CL" >&5 $as_echo "$as_me: Disabling Allegro CL" >&6;} ALLEGROCLBIN= else # can we find allegrocl? if test "x$ALLEGROCLBIN" = xyes; then # Extract the first word of "alisp", so it can be a program name with args. set dummy alisp; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ALLEGROCLBIN+:} false; then : $as_echo_n "(cached) " >&6 else case $ALLEGROCLBIN in [\\/]* | ?:[\\/]*) ac_cv_path_ALLEGROCLBIN="$ALLEGROCLBIN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ALLEGROCLBIN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ALLEGROCLBIN=$ac_cv_path_ALLEGROCLBIN if test -n "$ALLEGROCLBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ALLEGROCLBIN" >&5 $as_echo "$ALLEGROCLBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi #---------------------------------------------------------------- # Look for GNU CLISP #---------------------------------------------------------------- CLISPBIN= # Check whether --with-clisp was given. if test "${with_clisp+set}" = set; then : withval=$with_clisp; CLISPBIN="$withval" else CLISPBIN=yes fi # First, check for "--without-clisp" or "--with-clisp=no". if test x"${CLISPBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling CLISP" >&5 $as_echo "$as_me: Disabling CLISP" >&6;} CLISPBIN= else # can we find clisp? if test "x$CLISPBIN" = xyes; then # Extract the first word of "clisp", so it can be a program name with args. set dummy clisp; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_CLISPBIN+:} false; then : $as_echo_n "(cached) " >&6 else case $CLISPBIN in [\\/]* | ?:[\\/]*) ac_cv_path_CLISPBIN="$CLISPBIN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CLISPBIN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi CLISPBIN=$ac_cv_path_CLISPBIN if test -n "$CLISPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLISPBIN" >&5 $as_echo "$CLISPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi #---------------------------------------------------------------- # Look for GNU R #---------------------------------------------------------------- RBIN= # Check whether --with-r was given. if test "${with_r+set}" = set; then : withval=$with_r; RBIN="$withval" else RBIN=yes fi # First, check for "--without-r" or "--with-r=no". if test x"${RBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling R" >&5 $as_echo "$as_me: Disabling R" >&6;} RBIN= else # can we find R? if test "x$RBIN" = xyes; then # Extract the first word of "R", so it can be a program name with args. set dummy R; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_RBIN+:} false; then : $as_echo_n "(cached) " >&6 else case $RBIN in [\\/]* | ?:[\\/]*) ac_cv_path_RBIN="$RBIN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_RBIN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi RBIN=$ac_cv_path_RBIN if test -n "$RBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RBIN" >&5 $as_echo "$RBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi #---------------------------------------------------------------- # Look for Go compilers #---------------------------------------------------------------- # Check whether --with-go was given. if test "${with_go+set}" = set; then : withval=$with_go; GOBIN="$withval" else GOBIN=yes fi if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling Go" >&5 $as_echo "$as_me: Disabling Go" >&6;} GO= GOC= GO1=false GO12=false GO13=false GOGCC=false GOOPT= GOVERSIONOPTION= else if test "x$GOBIN" = xyes; then for ac_prog in go 6g 8g gccgo do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_GO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$GO"; then ac_cv_prog_GO="$GO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_GO="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi GO=$ac_cv_prog_GO if test -n "$GO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GO" >&5 $as_echo "$GO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$GO" && break done else GO="$GOBIN" fi GOGCC=false GO1=false GO12=false GO13=false GOOPT= GOVERSIONOPTION= if test -n "$GO" ; then if $GO --help 2>/dev/null | grep gccgo >/dev/null 2>&1 ; then GOGCC=true GOVERSIONOPTION=--version { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gccgo version is too old" >&5 $as_echo_n "checking whether gccgo version is too old... " >&6; } go_version=`$GO $GOVERSIONOPTION | sed -n '1p' | sed -e 's/^.* \([0-9.]*\) *$/\1/' -e 's/[.]//g'` if test "x$go_version" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not determine gccgo version - disabling Go" >&5 $as_echo "could not determine gccgo version - disabling Go" >&6; } GO= elif test "$go_version" -lt 470; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - minimum version is 4.7.0" >&5 $as_echo "yes - minimum version is 4.7.0" >&6; } GO= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if test "$go_version" -lt 480; then GOOPT="-intgosize 32" else # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 $as_echo_n "checking size of void *... " >&6; } if ${ac_cv_sizeof_void_p+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : else if test "$ac_cv_type_void_p" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (void *) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_void_p=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 $as_echo "$ac_cv_sizeof_void_p" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_VOID_P $ac_cv_sizeof_void_p _ACEOF if test "$ac_cv_sizeof_void_p" = "8"; then GOOPT="-intgosize 64" else GOOPT="-intgosize 32" fi fi fi elif test "`echo $GO | sed -e 's|.*/||'`" = "go"; then GO1=true GOVERSIONOPTION=version GOC=$(sh -c "$(go env) && echo \$GOCHAR")c go_version=$($GO $GOVERSIONOPTION | sed -e 's/go version //') case $go_version in go1.0*) GOOPT="-intgosize 32" ;; *) if test "$GOC" = "6c"; then GOOPT="-intgosize 64" else GOOPT="-intgosize 32" fi ;; esac case $go_version in go1.0* | go1.1*) GOOPT="$GOOPT -use-shlib" ;; go1.2*) GO12=true ;; *) GO13=true ;; esac else GOC=`echo $GO | sed -e 's/g/c/'` GOVERSIONOPTION=-V { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Go ($GO) version is too old" >&5 $as_echo_n "checking whether Go ($GO) version is too old... " >&6; } go_version=`$GO $GOVERSIONOPTION 2>/dev/null | sed -e 's/.*version.* \([0-9]*\).*/\1/'` go_min_version=7077 if test "$go_version" != "" -a "$go_version" -lt $go_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - minimum version is $go_min_version" >&5 $as_echo "yes - minimum version is $go_min_version" >&6; } GO= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi GOOPT="-intgosize 32" GO12=false GO13=false fi fi fi #---------------------------------------------------------------- # Look for D #---------------------------------------------------------------- # Check whether --with-d was given. if test "${with_d+set}" = set; then : withval=$with_d; with_d="$withval" else with_d=yes fi # Check whether --with-d1-compiler was given. if test "${with_d1_compiler+set}" = set; then : withval=$with_d1_compiler; D1COMPILERBIN="$withval" else D1COMPILERBIN= fi # Check whether --with-d2-compiler was given. if test "${with_d2_compiler+set}" = set; then : withval=$with_d2_compiler; D2COMPILERBIN="$withval" else D2COMPILERBIN= fi # First, check for "--without-d" or "--with-d=no". if test x"${with_d}" = xno -o x"${with_alllang}" = xno ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling D" >&5 $as_echo "$as_me: Disabling D" >&6;} D1COMPILER= D2COMPILER= else old_ac_ext=$ac_ext ac_ext=d if test -z "$D1COMPILERBIN" ; then for ac_prog in dmd ldmd gdmd do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_D1COMPILER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$D1COMPILER"; then ac_cv_prog_D1COMPILER="$D1COMPILER" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_D1COMPILER="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi D1COMPILER=$ac_cv_prog_D1COMPILER if test -n "$D1COMPILER"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $D1COMPILER" >&5 $as_echo "$D1COMPILER" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$D1COMPILER" && break done if test -n "$D1COMPILER" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D1/Tango compiler works" >&5 $as_echo_n "checking whether the D1/Tango compiler works... " >&6; } cat > conftest.$ac_ext <<_ACEOF import tango.io.Stdout; void main() { } _ACEOF rm -f conftest.$ac_objext if { { ac_try="$D1COMPILER conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$D1COMPILER conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test ! -s conftest.err && test -s conftest.$ac_objext; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } D1COMPILER= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi else D1COMPILER="$D1COMPILERBIN" fi if test -z "$D2COMPILERBIN" ; then for ac_prog in dmd gdmd do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_D2COMPILER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$D2COMPILER"; then ac_cv_prog_D2COMPILER="$D2COMPILER" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_D2COMPILER="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi D2COMPILER=$ac_cv_prog_D2COMPILER if test -n "$D2COMPILER"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $D2COMPILER" >&5 $as_echo "$D2COMPILER" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$D2COMPILER" && break done if test -n "$D2COMPILER" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D2 compiler works" >&5 $as_echo_n "checking whether the D2 compiler works... " >&6; } cat > conftest.$ac_ext <<_ACEOF import std.algorithm; void main() { } _ACEOF rm -f conftest.$ac_objext if { { ac_try="$D2COMPILER conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$D2COMPILER conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test ! -s conftest.err && test -s conftest.$ac_objext; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } D2COMPILER= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi else D2COMPILER="$D2COMPILERBIN" fi ac_ext=$old_ac_ext fi if test -n "$D1COMPILER"; then DDEFAULTVERSION=1 elif test -n "$D2COMPILER"; then DDEFAULTVERSION=2 fi # Do not prefix library file names with "lib" on Windows. case $host in *-*-cygwin* | *-*-mingw*) DLIBPREFIX="";; *)DLIBPREFIX="lib";; esac #---------------------------------------------------------------- # Determine which languages to use for examples/test-suite #---------------------------------------------------------------- SKIP_TCL= if test -z "$TCLINCLUDE" || test -z "$TCLLIB" ; then SKIP_TCL="1" fi SKIP_PERL5= if test -z "$PERL" || test -z "$PERL5EXT" || test -z "$PERL5TESTMORE"; then SKIP_PERL5="1" fi SKIP_OCTAVE= if test -z "$OCTAVE" ; then SKIP_OCTAVE="1" fi SKIP_PYTHON= if (test -z "$PYINCLUDE") && (test -z "$PY3INCLUDE") ; then SKIP_PYTHON="1" fi SKIP_PYTHON3= if test -z "$PY3INCLUDE" ; then SKIP_PYTHON3="1" fi SKIP_JAVA= if test -z "$JAVA" || test -z "$JAVAC" || test -z "$JAVAINC" ; then SKIP_JAVA="1" fi SKIP_JAVASCRIPT= if test -z "$JAVASCRIPT" || ( test -z "$NODEJS" && test -z "$JSCENABLED" && test -z "$JSV8ENABLED" ) ; then SKIP_JAVASCRIPT="1" fi SKIP_GUILE= if test -z "$GUILE" || test -z "$GUILE_LIBS" ; then SKIP_GUILE="1" fi SKIP_MZSCHEME= if test -z "$MZC" || test -z "$MZDYNOBJ" ; then SKIP_MZSCHEME="1" fi SKIP_RUBY= if test -z "$RUBY" || test -z "$RUBYINCLUDE" || test -z "$RUBYLIB" ; then SKIP_RUBY="1" fi SKIP_PHP= if test -z "$PHP" || test -z "$PHPINC" ; then SKIP_PHP="1" fi SKIP_OCAML= if test -z "$OCAMLBIN" || test -z "$OCAMLINC" ; then SKIP_OCAML="1" fi SKIP_PIKE= if test -z "$PIKE" || test -z "$PIKEINCLUDE" ; then SKIP_PIKE="1" fi SKIP_CHICKEN= if test -z "$CHICKEN_CSC" || test -z "$CHICKEN"; then SKIP_CHICKEN="1" fi SKIP_CSHARP= if test -z "$CSHARPCOMPILER" ; then SKIP_CSHARP="1" else if test "cscc" = "$CSHARPCOMPILER" && test -z "$CSHARPCILINTERPRETER" ; then SKIP_CSHARP="1" fi fi SKIP_MODULA3="1" # Always skipped! SKIP_LUA= # we need LUABIN & dynamic loading if test -z "$LUABIN" || test -z "$LUADYNAMICLOADLIB"; then SKIP_LUA="1" fi SKIP_ALLEGROCL= if test -z "$ALLEGROCLBIN" ; then SKIP_ALLEGROCL="1" fi SKIP_CLISP= if test -z "$CLISPBIN" ; then SKIP_CLISP="1" fi SKIP_R= if test -z "$RBIN" ; then SKIP_R="1" fi SKIP_CFFI= #if test -z "$CFFIBIN" ; then SKIP_CFFI="1" #fi SKIP_UFFI= #if test -z "$UFFIBIN" ; then SKIP_UFFI="1" #fi SKIP_GO= if test -z "$GO" ; then SKIP_GO="1" fi SKIP_D= if test -z "$DDEFAULTVERSION" ; then SKIP_D="1" fi #---------------------------------------------------------------- # Additional language dependencies #---------------------------------------------------------------- SKIP_GCJ= if test -z "$GCJ" || test -z "$GCJH" ; then SKIP_GCJ="1" else if test "$GCC" != yes; then SKIP_GCJ="1" fi fi SKIP_ANDROID= if test -z "$ANDROID" || test -z "$ADB" || test -z "$ANT" || test -z "$NDKBUILD" ; then SKIP_ANDROID="1" fi #---------------------------------------------------------------- # Miscellaneous #---------------------------------------------------------------- # Root directory # Translate path for native Windows compilers for use with 'make check' ROOT_DIR=`pwd` case $host in *-*-cygwin* | *-*-mingw*) if (cygpath --mixed $ROOT_DIR) >/dev/null 2>/dev/null; then ROOT_DIR=`cygpath --mixed $ROOT_DIR` fi # Extra files generated by some Windows compilers EXTRA_CLEAN="*.stackdump *.exp *.lib *.pdb *.ilk" ;; esac # Configure SWIG_LIB path # Check whether --with-swiglibdir was given. if test "${with_swiglibdir+set}" = set; then : withval=$with_swiglibdir; swig_lib="$withval" else swig_lib="${datadir}/swig/${PACKAGE_VERSION}" fi prefix_NONE= exec_prefix_NONE= test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix eval ac_define_dir="\"$swig_lib\"" eval ac_define_dir="\"$ac_define_dir\"" SWIG_LIB="$ac_define_dir" cat >>confdefs.h <<_ACEOF #define SWIG_LIB "$ac_define_dir" _ACEOF test "$prefix_NONE" && prefix=NONE test "$exec_prefix_NONE" && exec_prefix=NONE case $build in # Windows does not understand unix directories. Convert into a windows directory with drive letter. *-*-mingw*) SWIG_LIB_WIN_UNIX=`cmd //c echo $SWIG_LIB | sed -e "s/ *$//"`;; # This echo converts unix to mixed paths. Then zap unexpected trailing space. *-*-cygwin*) SWIG_LIB_WIN_UNIX=`cygpath --mixed "$SWIG_LIB"`;; *) SWIG_LIB_WIN_UNIX="";; esac cat >>confdefs.h <<_ACEOF #define SWIG_LIB_WIN_UNIX "$SWIG_LIB_WIN_UNIX" _ACEOF ac_config_files="$ac_config_files Makefile swig.spec Examples/Makefile Examples/xml/Makefile Examples/test-suite/errors/Makefile Examples/test-suite/chicken/Makefile Examples/test-suite/csharp/Makefile Examples/test-suite/d/Makefile Examples/test-suite/guile/Makefile Examples/test-suite/java/Makefile Examples/test-suite/javascript/Makefile Examples/test-suite/mzscheme/Makefile Examples/test-suite/ocaml/Makefile Examples/test-suite/octave/Makefile Examples/test-suite/perl5/Makefile Examples/test-suite/php/Makefile Examples/test-suite/pike/Makefile Examples/test-suite/python/Makefile Examples/test-suite/ruby/Makefile Examples/test-suite/tcl/Makefile Examples/test-suite/lua/Makefile Examples/test-suite/allegrocl/Makefile Examples/test-suite/clisp/Makefile Examples/test-suite/cffi/Makefile Examples/test-suite/uffi/Makefile Examples/test-suite/r/Makefile Examples/test-suite/go/Makefile Source/Makefile Tools/javascript/Makefile" ac_config_files="$ac_config_files preinst-swig" ac_config_files="$ac_config_files CCache/ccache_swig_config.h" #-------------------------------------------------------------------- # Building Examples/ out of source directory #-------------------------------------------------------------------- # If building out of source tree, replicate Examples/ source tree in # build directory, and copy over Makefiles from source directory. # Prefix each Makefile with a header which sets SRCDIR to the relative # source directory, and provides a rule for updating the Makefile from # its original source. ac_config_commands="$ac_config_commands Examples" #-------------------------------------------------------------------- cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by swig $as_me 3.0.2, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ swig config.status 3.0.2 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "Source/Include/swigconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS Source/Include/swigconfig.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "swig.spec") CONFIG_FILES="$CONFIG_FILES swig.spec" ;; "Examples/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/Makefile" ;; "Examples/xml/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/xml/Makefile" ;; "Examples/test-suite/errors/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/errors/Makefile" ;; "Examples/test-suite/chicken/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/chicken/Makefile" ;; "Examples/test-suite/csharp/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/csharp/Makefile" ;; "Examples/test-suite/d/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/d/Makefile" ;; "Examples/test-suite/guile/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/guile/Makefile" ;; "Examples/test-suite/java/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/java/Makefile" ;; "Examples/test-suite/javascript/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/javascript/Makefile" ;; "Examples/test-suite/mzscheme/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/mzscheme/Makefile" ;; "Examples/test-suite/ocaml/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/ocaml/Makefile" ;; "Examples/test-suite/octave/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/octave/Makefile" ;; "Examples/test-suite/perl5/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/perl5/Makefile" ;; "Examples/test-suite/php/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/php/Makefile" ;; "Examples/test-suite/pike/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/pike/Makefile" ;; "Examples/test-suite/python/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/python/Makefile" ;; "Examples/test-suite/ruby/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/ruby/Makefile" ;; "Examples/test-suite/tcl/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/tcl/Makefile" ;; "Examples/test-suite/lua/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/lua/Makefile" ;; "Examples/test-suite/allegrocl/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/allegrocl/Makefile" ;; "Examples/test-suite/clisp/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/clisp/Makefile" ;; "Examples/test-suite/cffi/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/cffi/Makefile" ;; "Examples/test-suite/uffi/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/uffi/Makefile" ;; "Examples/test-suite/r/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/r/Makefile" ;; "Examples/test-suite/go/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/test-suite/go/Makefile" ;; "Source/Makefile") CONFIG_FILES="$CONFIG_FILES Source/Makefile" ;; "Tools/javascript/Makefile") CONFIG_FILES="$CONFIG_FILES Tools/javascript/Makefile" ;; "preinst-swig") CONFIG_FILES="$CONFIG_FILES preinst-swig" ;; "CCache/ccache_swig_config.h") CONFIG_FILES="$CONFIG_FILES CCache/ccache_swig_config.h" ;; "Examples") CONFIG_COMMANDS="$CONFIG_COMMANDS Examples" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "preinst-swig":F) chmod +x preinst-swig ;; "Examples":C) if test "x${srcdir}" != "x." ; then { $as_echo "$as_me:${as_lineno-$LINENO}: generating Examples build tree" >&5 $as_echo "$as_me: generating Examples build tree" >&6;} for mkfile in `cd ${srcdir} && find Examples/ -type f -name Makefile`; do dir=`dirname ${mkfile}` d=${dir} reldir=""; while test "x$d" != "x." ; do d=`dirname $d` reldir="${reldir}../" done relsrcdir=${reldir}${srcdir}/ as_dir=${dir}; as_fn_mkdir_p cat <${mkfile} # DO NOT EDIT: instead edit ${relsrcdir}${mkfile} # and run (cd ${reldir} && ./config.status) to regenerate SRCDIR = ${relsrcdir}${dir}/ EOF cat ${srcdir}/${mkfile} >>${mkfile} done fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi # # CONFIG_SUBDIRS section. # if test "$no_recursion" != yes; then # Remove --cache-file, --srcdir, and --disable-option-checking arguments # so they do not pile up. ac_sub_configure_args= ac_prev= eval "set x $ac_configure_args" shift for ac_arg do if test -n "$ac_prev"; then ac_prev= continue fi case $ac_arg in -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \ | --c=*) ;; --config-cache | -C) ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) ;; --disable-option-checking) ;; *) case $ac_arg in *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_sub_configure_args " '$ac_arg'" ;; esac done # Always prepend --prefix to ensure using the same prefix # in subdir configurations. ac_arg="--prefix=$prefix" case $ac_arg in *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args" # Pass --silent if test "$silent" = yes; then ac_sub_configure_args="--silent $ac_sub_configure_args" fi # Always prepend --disable-option-checking to silence warnings, since # different subdirs can have different --enable and --with options. ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args" ac_popdir=`pwd` for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue # Do not complain, so a configure script can configure whichever # parts of a large source tree are present. test -d "$srcdir/$ac_dir" || continue ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)" $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5 $as_echo "$ac_msg" >&6 as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" # Check for guested configure; otherwise get Cygnus style configure. if test -f "$ac_srcdir/configure.gnu"; then ac_sub_configure=$ac_srcdir/configure.gnu elif test -f "$ac_srcdir/configure"; then ac_sub_configure=$ac_srcdir/configure elif test -f "$ac_srcdir/configure.in"; then # This should be Cygnus configure. ac_sub_configure=$ac_aux_dir/configure else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no configuration information is in $ac_dir" >&5 $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} ac_sub_configure= fi # The recursion is here. if test -n "$ac_sub_configure"; then # Make the cache file name correct relative to the subdirectory. case $cache_file in [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;; *) # Relative name. ac_sub_cache_file=$ac_top_build_prefix$cache_file ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5 $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;} # The eval makes quoting arguments work. eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \ --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" || as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5 fi cd "$ac_popdir" done fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi langs="" test -n "$SKIP_ALLEGROCL" || langs="${langs}allegrocl " test -n "$SKIP_CFFI" || langs="${langs}cffi " test -n "$SKIP_CHICKEN" || langs="${langs}chicken " test -n "$SKIP_CLISP" || langs="${langs}clisp " test -n "$SKIP_CSHARP" || langs="${langs}csharp " test -n "$SKIP_D" || langs="${langs}d " test -n "$SKIP_GO" || langs="${langs}go " test -n "$SKIP_GUILE" || langs="${langs}guile " test -n "$SKIP_JAVA" || langs="${langs}java " test -n "$SKIP_JAVASCRIPT" || langs="${langs}javascript " test -n "$SKIP_LUA" || langs="${langs}lua " test -n "$SKIP_MODULA3" || langs="${langs}modula3 " test -n "$SKIP_MZSCHEME" || langs="${langs}mzscheme " test -n "$SKIP_OCAML" || langs="${langs}ocaml " test -n "$SKIP_OCTAVE" || langs="${langs}octave " test -n "$SKIP_PERL5" || langs="${langs}perl5 " test -n "$SKIP_PHP" || langs="${langs}php " test -n "$SKIP_PIKE" || langs="${langs}pike " test -n "$SKIP_PYTHON" || langs="${langs}python " test -n "$SKIP_R" || langs="${langs}r " test -n "$SKIP_RUBY" || langs="${langs}ruby " test -n "$SKIP_TCL" || langs="${langs}tcl " test -n "$SKIP_UFFI" || langs="${langs}uffi " echo " The SWIG test-suite and examples are configured for the following languages: $langs " swig-3.0.2/swig.spec.in0000664000175000017500000000473712343605122014610 0ustar williamwilliam# You can build the package from Git using something like: # tar -czf swig-@PACKAGE_VERSION@.tar.gz swig-@PACKAGE_VERSION@ && rpmbuild -tb swig-@PACKAGE_VERSION@.tar.gz # @configure_input@ %define ver @PACKAGE_VERSION@ %define rel 1 %define prefix /usr %define home_page http://www.swig.org %define docprefix %{prefix}/share ###################################################################### # Usually, nothing needs to be changed below here between releases ###################################################################### Summary: Simplified Wrapper and Interface Generator Name: swig Version: %{ver} Release: %{rel} URL: %{home_page} Source0: %{name}-%{version}.tar.gz License: BSD Group: Development/Tools BuildRoot: %{_tmppath}/%{name}-root %description SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is primarily used with common scripting languages such as Perl, Python, Tcl/Tk, and Ruby, however the list of supported languages also includes non-scripting languages such as Java, OCAML and C#. Also several interpreted and compiled Scheme implementations (Guile, MzScheme, Chicken) are supported. SWIG is most commonly used to create high-level interpreted or compiled programming environments, user interfaces, and as a tool for testing and prototyping C/C++ software. SWIG can also export its parse tree in the form of XML and Lisp s-expressions. %prep %setup -q -n %{name}-%{version} %build # so we can build package from Git source too [ ! -r configure ] && ./autogen.sh %configure make %install rm -rf ${RPM_BUILD_ROOT} make DESTDIR=$RPM_BUILD_ROOT install %clean rm -rf ${RPM_BUILD_ROOT} %files %defattr(-,root,root) %doc ANNOUNCE CHANGES INSTALL LICENSE LICENSE-GPL LICENSE-UNIVERSITIES README RELEASENOTES %doc Doc/* %{_bindir}/* %{prefix}/share/* %changelog * Thu Sep 16 2004 Marcelo Matus - Small fixes needed after removing the runtime package * Tue Jul 20 2004 William Fulton - Update for SWIG-1.3.22 - Removed runtime package * Wed Mar 03 2004 Robert H De Vries - Update to work with Fedora Core 1 rpm 4.2.1 * Wed Jul 24 2002 Sam Liddicott - Added runtime package of runtime libs * Mon Sep 10 2001 Tony Seward - Merge Red Hat's and Dustin Mitchell's .spec files. - Install all of the examples in the documentation directory. - Auto create the list of installed files. swig-3.0.2/Examples/0000775000175000017500000000000012343605122014121 5ustar williamwilliamswig-3.0.2/Examples/xml/0000775000175000017500000000000012343605122014721 5ustar williamwilliamswig-3.0.2/Examples/xml/example_p5.i0000664000175000017500000000021712343605122017132 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/xml/example_const.i0000664000175000017500000000113112343605122017730 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following statements also produce constants */ const int iconst = 37; const double fconst = 3.14; swig-3.0.2/Examples/xml/example_title_add.expected-xml0000664000175000017500000001024412343605122022707 0ustar williamwilliam #include "example.h" Vector addv(Vector &a, Vector &b) { return a+b; } { return a+b; } { return (*self)[index]; } { (*self)[index] = a; } swig-3.0.2/Examples/xml/example.h0000664000175000017500000000022712343605122016526 0ustar williamwilliam// i add this file because it's referenced by other files. // someone should replace these comments w/ proper content. // --ttn, 2001/01/16 17:44:19 swig-3.0.2/Examples/xml/example_inl.h0000664000175000017500000000011012343605122017357 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; swig-3.0.2/Examples/xml/error.i0000664000175000017500000000005312343605122016222 0ustar williamwilliam%module error enum { RED=10, GREEN, BLUE };swig-3.0.2/Examples/xml/gnarly.expected-xml0000664000175000017500000001730312343605122020542 0ustar williamwilliam { } { WHATEVER MAKES YOU HAPPY AS RESULT } { WHATEVER MAKES YOU HAPPY AS PARAMETER } swig-3.0.2/Examples/xml/example_inl.expected-xml0000664000175000017500000000636512343605122021551 0ustar williamwilliam #include "example.h" Vector *new_Vector(double x, double y, double z) { Vector *v = (Vector *) malloc(sizeof(Vector)); v->x = x; v->y = y; v->z = z; return v; } void vector_print(Vector *v) { printf("Vector %x = (%g, %g, %g)\n", v, v->x, v->y, v->z); } { Vector *v = (Vector *) malloc(sizeof(Vector)); v->x = x; v->y = y; v->z = z; return v; } { printf("Vector %x = (%g, %g, %g)\n", v, v->x, v->y, v->z); } swig-3.0.2/Examples/xml/example.i0000664000175000017500000000011312343605122016521 0ustar williamwilliam/* File : example.i */ %module example %apply int *OUTPUT { int *r }; swig-3.0.2/Examples/xml/example_gif.expected-xml0000664000175000017500000026313712343605122021536 0ustar williamwilliam swig-3.0.2/Examples/xml/example_ro.i0000664000175000017500000000011712343605122017225 0ustar williamwilliam/* File : example.i */ %readonly extern int status; extern char path[256]; swig-3.0.2/Examples/xml/example_xml.h0000664000175000017500000000111312343605122017401 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { }; virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/xml/example_title_add.i0000664000175000017500000000136112343605122020540 0ustar williamwilliam/* File : example.i */ %title "Matrix and vector package" /* This file has a few "typical" uses of C++ references. */ %module example %{ #include "example.h" %} class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %addmethods { Vector &get(int index) { return (*self)[index]; } void set(int index, Vector &a) { (*self)[index] = a; } } }; swig-3.0.2/Examples/xml/example_p5.expected-xml0000664000175000017500000000141412343605122021301 0ustar williamwilliam #include "example.h" swig-3.0.2/Examples/xml/example_apply.expected-xml0000664000175000017500000015005712343605122022112 0ustar williamwilliam %include pointer.i The pointer.i library provides run-time support for managing and manipulating a variety of C/C++ pointer values. In particular, you can create various kinds of objects and dereference common pointer types. This is done through a common set of functions: ptrvalue - Dereferences a pointer ptrset - Set the value of an object referenced by a pointer. ptrcreate - Create a new object and return a pointer. ptrfree - Free the memory allocated by ptrcreate. ptradd - Increment/decrement a pointer value. When creating, dereferencing, or setting the value of pointer variable, only the common C datatypes of int, short, long, float, double, char, and char * are currently supported. Other datatypes may generate an error. One of the more interesting aspects of this library is that it operates with a wide range of datatypes. For example, the "ptrvalue" function can dereference "double *", "int *", "long *", "char *", and other datatypes. Since SWIG encodes pointers with type information, this can be done transparently and in most cases, you can dereference a pointer without ever knowing what type it actually is. This library is primarily designed for utility, not high performance (the dynamic determination of pointer types takes more work than most normal wrapper functions). As a result, you may achieve better performance by writing customized "helper" functions if you're making lots of calls to these functions in inner loops or other intensive operations. #include &lt;ctype.h> /* Types used by the library */ static swig_type_info *SWIG_POINTER_int_p = 0; static swig_type_info *SWIG_POINTER_short_p =0; static swig_type_info *SWIG_POINTER_long_p = 0; static swig_type_info *SWIG_POINTER_float_p = 0; static swig_type_info *SWIG_POINTER_double_p = 0; static swig_type_info *SWIG_POINTER_char_p = 0; static swig_type_info *SWIG_POINTER_char_pp = 0; static swig_type_info *SWIG_POINTER_void_p = 0; SWIG_POINTER_int_p = SWIG_TypeQuery("int *"); SWIG_POINTER_short_p = SWIG_TypeQuery("short *"); SWIG_POINTER_long_p = SWIG_TypeQuery("long *"); SWIG_POINTER_float_p = SWIG_TypeQuery("float *"); SWIG_POINTER_double_p = SWIG_TypeQuery("double *"); SWIG_POINTER_char_p = SWIG_TypeQuery("char *"); SWIG_POINTER_char_pp = SWIG_TypeQuery("char **"); SWIG_POINTER_void_p = SWIG_TypeQuery("void *"); /* #ifdef WIN32 #undef isspace #define isspace(c) (c == ' ') #endif */ /*------------------------------------------------------------------ ptrvalue(ptr,type = 0) Attempts to dereference a pointer value. If type is given, it will try to use that type. Otherwise, this function will attempt to "guess" the proper datatype by checking against all of the builtin C datatypes. ------------------------------------------------------------------ */ #ifdef PERL_OBJECT static SV *_ptrvalue(CPerlObj *pPerl,SV *_PTRVALUE, int index, char *type) { #define ptrvalue(a,b,c) _ptrvalue(pPerl,a,b,c) #else static SV *_ptrvalue(SV *_PTRVALUE, int index, char *type) { #define ptrvalue(a,b,c) _ptrvalue(a,b,c) #endif void *ptr; SV *obj = 0; if (SWIG_ConvertPtr(_PTRVALUE, &ptr, 0) &lt; 0) { croak("Type error it ptrvalue. Argument is not a valid pointer value."); } else { /* If no datatype was passed, try a few common datatypes first */ if (!type) { /* No datatype was passed. Type to figure out if it's a common one */ if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_int_p) >= 0) { type = "int"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_double_p) >= 0) { type = "double"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_short_p) >= 0) { type = "short"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_long_p) >= 0) { type = "long"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_float_p) >= 0) { type = "float"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_p) >= 0) { type = "char"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_pp) >= 0) { type = "char *"; } else { type = "unknown"; } } if (!ptr) { croak("Unable to dereference NULL pointer."); return 0; } /* Now we have a datatype. Try to figure out what to do about it */ if (strcmp(type,"int") == 0) { obj = sv_newmortal(); sv_setiv(obj,(IV) *(((int *) ptr) + index)); } else if (strcmp(type,"double") == 0) { obj = sv_newmortal(); sv_setnv(obj,(double) *(((double *) ptr)+index)); } else if (strcmp(type,"short") == 0) { obj = sv_newmortal(); sv_setiv(obj,(IV) *(((short *) ptr) + index)); } else if (strcmp(type,"long") == 0) { obj = sv_newmortal(); sv_setiv(obj,(IV) *(((long *) ptr) + index)); } else if (strcmp(type,"float") == 0) { obj = sv_newmortal(); sv_setnv(obj,(double) *(((float *) ptr)+index)); } else if (strcmp(type,"char") == 0) { obj = sv_newmortal(); sv_setpv(obj,((char *) ptr)+index); } else if (strcmp(type,"char *") == 0) { char *c = *(((char **) ptr)+index); obj = sv_newmortal(); if (c) sv_setpv(obj,c); else sv_setpv(obj,"NULL"); } else { croak("Unable to dereference unsupported datatype."); obj = 0; } } return obj; } /*------------------------------------------------------------------ ptrcreate(type,value = 0,numelements = 1) Attempts to create a new object of given type. Type must be a basic C datatype. Will not create complex objects. ------------------------------------------------------------------ */ #ifdef PERL_OBJECT static SV *_ptrcreate(CPerlObj *pPerl, char *type, SV *value, int numelements) { #define ptrcreate(a,b,c) _ptrcreate(pPerl,a,b,c) #else static SV *_ptrcreate(char *type, SV *value, int numelements) { #define ptrcreate(a,b,c) _ptrcreate(a,b,c) #endif void *ptr; SV *obj; int sz; swig_type_info *cast = 0; /* Check the type string against a variety of possibilities */ if (strcmp(type,"int") == 0) { sz = sizeof(int)*numelements; cast = SWIG_POINTER_int_p; } else if (strcmp(type,"short") == 0) { sz = sizeof(short)*numelements; cast = SWIG_POINTER_short_p; } else if (strcmp(type,"long") == 0) { sz = sizeof(long)*numelements; cast = SWIG_POINTER_long_p; } else if (strcmp(type,"double") == 0) { sz = sizeof(double)*numelements; cast = SWIG_POINTER_double_p; } else if (strcmp(type,"float") == 0) { sz = sizeof(float)*numelements; cast = SWIG_POINTER_float_p; } else if (strcmp(type,"char") == 0) { sz = sizeof(char)*numelements; cast = SWIG_POINTER_char_p; } else if (strcmp(type,"char *") == 0) { sz = sizeof(char *)*(numelements+1); cast = SWIG_POINTER_char_pp; } else if (strcmp(type,"void") == 0) { sz = numelements; cast = SWIG_POINTER_void_p; } else { croak("Unable to create unknown datatype."); return 0; } /* Create the new object */ ptr = (void *) malloc(sz); if (!ptr) { croak("Out of memory in ptrcreate."); return 0; } /* Now try to set its default value */ if (value) { if (strcmp(type,"int") == 0) { int *ip,i,ivalue; ivalue = (int) SvIV(value); ip = (int *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"short") == 0) { short *ip,ivalue; int i; ivalue = (short) SvIV(value); ip = (short *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"long") == 0) { long *ip,ivalue; int i; ivalue = (long) SvIV(value); ip = (long *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"double") == 0) { double *ip,ivalue; int i; ivalue = (double) SvNV(value); ip = (double *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"float") == 0) { float *ip,ivalue; int i; ivalue = (float) SvNV(value); ip = (float *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"char") == 0) { char *ip,*ivalue; ivalue = (char *) SvPV(value,PL_na); ip = (char *) ptr; strncpy(ip,ivalue,numelements-1); } else if (strcmp(type,"char *") == 0) { char **ip, *ivalue; int i; ivalue = (char *) SvPV(value,PL_na); ip = (char **) ptr; for (i = 0; i &lt; numelements; i++) { if (ivalue) { ip[i] = (char *) malloc(strlen(ivalue)+1); strcpy(ip[i],ivalue); } else { ip[i] = 0; } } ip[numelements] = 0; } } /* Create the pointer value */ obj = sv_newmortal(); SWIG_MakePtr(obj,ptr,cast); return obj; } /*------------------------------------------------------------------ ptrset(ptr,value,index = 0,type = 0) Attempts to set the value of a pointer variable. If type is given, we will use that type. Otherwise, we'll guess the datatype. ------------------------------------------------------------------ */ #ifdef PERL_OBJECT static void _ptrset(CPerlObj *pPerl,SV *_PTRVALUE, SV *value, int index, char *type) { #define ptrset(a,b,c,d) _ptrset(pPerl,a,b,c,d) #else static void _ptrset(SV *_PTRVALUE, SV *value, int index, char *type) { #define ptrset(a,b,c,d) _ptrset(a,b,c,d) #endif void *ptr; SV *obj; if (SWIG_ConvertPtr(_PTRVALUE, &ptr, 0) &lt; 0) { croak("Type error it ptrvalue. Argument is not a valid pointer value."); } else { /* If no datatype was passed, try a few common datatypes first */ if (!type) { /* No datatype was passed. Type to figure out if it's a common one */ if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_int_p) >= 0) { type = "int"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_double_p) >= 0) { type = "double"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_short_p) >= 0) { type = "short"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_long_p) >= 0) { type = "long"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_float_p) >= 0) { type = "float"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_p) >= 0) { type = "char"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_pp) >= 0) { type = "char *"; } else { type = "unknown"; } } } if (!ptr) { croak("Unable to set NULL pointer."); return; } /* Now we have a datatype. Try to figure out what to do about it */ if (strcmp(type,"int") == 0) { *(((int *) ptr)+index) = (int) SvIV(value); } else if (strcmp(type,"double") == 0) { *(((double *) ptr)+index) = (double) SvNV(value); } else if (strcmp(type,"short") == 0) { *(((short *) ptr)+index) = (short) SvIV(value); } else if (strcmp(type,"long") == 0) { *(((long *) ptr)+index) = (long) SvIV(value); } else if (strcmp(type,"float") == 0) { *(((float *) ptr)+index) = (float) SvNV(value); } else if (strcmp(type,"char") == 0) { char *c = SvPV(value,PL_na); strcpy(((char *) ptr)+index, c); } else if (strcmp(type,"char *") == 0) { char *c = SvPV(value,PL_na); char **ca = (char **) ptr; if (ca[index]) free(ca[index]); if (strcmp(c,"NULL") == 0) { ca[index] = 0; } else { ca[index] = (char *) malloc(strlen(c)+1); strcpy(ca[index],c); } } else { croak("Unable to set unsupported datatype."); return; } } /*------------------------------------------------------------------ ptradd(ptr,offset) Adds a value to an existing pointer value. Will do a type-dependent add for basic datatypes. For other datatypes, will do a byte-add. ------------------------------------------------------------------ */ #ifdef PERL_OBJECT static SV *_ptradd(CPerlObj *pPerl, SV *_PTRVALUE, int offset) { #define ptradd(a,b) _ptradd(pPerl,a,b) #else static SV *_ptradd(SV *_PTRVALUE, int offset) { #define ptradd(a,b) _ptradd(a,b) #endif void *ptr,*junk; SV *obj; swig_type_info *type; char *tname; /* Try to handle a few common datatypes first */ if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_int_p) >= 0) { ptr = (void *) (((int *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_double_p) >= 0) { ptr = (void *) (((double *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_short_p) >= 0) { ptr = (void *) (((short *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_long_p) >= 0) { ptr = (void *) (((long *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_float_p) >= 0) { ptr = (void *) (((float *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_p) >= 0) { ptr = (void *) (((char *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,0) >= 0) { ptr = (void *) (((char *) ptr) + offset); } else { croak("Type error in ptradd. Argument is not a valid pointer value."); return 0; } printf("ptradd = %x\n", ptr); tname = HvNAME(SvSTASH(SvRV(_PTRVALUE))); obj = sv_newmortal(); sv_setref_pv(obj,tname,ptr); return obj; } /*------------------------------------------------------------------ ptrfree(ptr) Destroys a pointer value ------------------------------------------------------------------ */ #ifdef PERL_OBJECT void _ptrfree(CPerlObj *pPerl, SV *_PTRVALUE) { #define ptrfree(a) _ptrfree(pPerl, a) #else void _ptrfree(SV *_PTRVALUE) { #define ptrfree(a) _ptrfree(a) #endif void *ptr, *junk; if (SWIG_ConvertPtr(_PTRVALUE,&ptr,0) &lt; 0) { croak("Type error in ptrfree. Argument is not a valid pointer value."); return; } /* Check to see if this pointer is a char ** */ if (SWIG_ConvertPtr(_PTRVALUE,&junk,SWIG_POINTER_char_pp) >= 0) { char **c = (char **) ptr; if (c) { int i = 0; while (c[i]) { free(c[i]); i++; } } } if (ptr) free((char *) ptr); } { $target = $source; } { $target = $source; } { $target = $source; argvi++; } { $target = $source; argvi++; } { $target = $source; argvi++; } { $target = $source; argvi++; } { if ($source == -1) return NULL; } { temp = (double) SvNV($source); $target = &temp; } { temp = (float) SvNV($source); $target = &temp; } { temp = (int) SvIV($source); $target = &temp; } { temp = (short) SvIV($source); $target = &temp; } { temp = (long) SvIV($source); $target = &temp; } { temp = (unsigned int) SvIV($source); $target = &temp; } { temp = (unsigned short) SvIV($source); $target = &temp; } { temp = (unsigned long) SvIV($source); $target = &temp; } { temp = (unsigned char) SvIV($source); $target = &temp; } { $target = &temp; } { $target = &amp;temp; } { $target = &amp;amp;temp; } { $target = &amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;amp;amp;amp;amp;temp; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setnv($target,(double) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setnv($target,(double) *($source)); argvi++; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { printf("Received %d\n", SvTYPE(tempsv)); croak("Expected a double reference."); } dvalue = SvNV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { croak("expected a double reference"); } dvalue = (float) SvNV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (short) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (long) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (unsigned int) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (unsigned short) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (unsigned long) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; tempsv = SvRV($arg); sv_setnv(tempsv, (double) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setnv(tempsv, (double) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } swig-3.0.2/Examples/xml/example_apply.i0000664000175000017500000000074712343605122017743 0ustar williamwilliam/* File : example.i */ %module example /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include pointer.i /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); swig-3.0.2/Examples/xml/example_inl.i0000664000175000017500000000122512343605122017370 0ustar williamwilliam// Tests SWIG's handling of pass-by-value for complex datatypes %module example %{ #include "example.h" %} /* Some functions that manipulate Vectors by value */ extern double dot_product(Vector a, Vector b); extern Vector vector_add(Vector a, Vector b); /* Include this because the vector_add() function will leak memory */ void free(void *); /* Some helper functions for our interface */ %inline %{ Vector *new_Vector(double x, double y, double z) { Vector *v = (Vector *) malloc(sizeof(Vector)); v->x = x; v->y = y; v->z = z; return v; } void vector_print(Vector *v) { printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z); } %} swig-3.0.2/Examples/xml/example_ro.expected-xml0000664000175000017500000000153112343605122021375 0ustar williamwilliam swig-3.0.2/Examples/xml/example_const.expected-xml0000664000175000017500000000372212343605122022107 0ustar williamwilliam swig-3.0.2/Examples/xml/gnarly.i0000664000175000017500000000202212343605122016363 0ustar williamwilliam/* File : check.i */ %module my_check enum color { RED=10, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE, WARP, LUDICROUS }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); %typemap(out) int * { WHATEVER MAKES YOU HAPPY AS RESULT } %typemap(in) int * { WHATEVER MAKES YOU HAPPY AS PARAMETER } %pragma(xml) DEBUG="false"; extern int * my_gcd(const char * x, int * y[], int * r, int (*op)(int,int)) const; extern double my_foo; void my_void(); my_empty(); const double my_dutch = 1.0; union my_union { int my_iii; char my_ccc; }; struct my_struct { public: virtual ~my_struct(); int my_foo(); protected: int my_bar; double x, y; virtual double area() = 0; static int nshapes; }; class my_class : public my_struct, public my_union { public: my_class( char c ); private: ~my_class(); virtual const int * my_func( my_class , char * * x, int y[], const int & r) const; double my_foo[128]; const my_int i; }; typedef int my_int; swig-3.0.2/Examples/xml/Makefile.in0000664000175000017500000000207412343605122016771 0ustar williamwilliam# Examples/xml/Makefile top_srcdir = @top_srcdir@ cleanup = tail +2 \ | sed -e 's/ident="ID[0-9A-F]*"//g' \ -e 's,name="/[^"]*/\([^/]*\.swg\)",name="\1",g' all-dot-i-files = \ error.i \ example.i \ example_apply.i \ example_const.i \ example_gif.i \ example_inl.i \ example_p5.i \ example_ro.i \ example_title_add.i \ example_xml.i \ gnarly.i chk-swiglib = $(top_srcdir)/Lib check: for f in $(all-dot-i-files) ; do \ base=`basename $$f .i` ; \ xml=$$base.xml ; \ SWIG_LIB=$(chk-swiglib) $(top_srcdir)/swig -xml $$xml $$f ; \ cat $$xml | $(cleanup) | diff -c $$base.expected-xml - ; \ done clean: rm -f *.xml distclean: clean rm -f Makefile # from here on, non-developers beware! %.expected-xml : %.i SWIG_LIB=$(top_srcdir)/Lib $(top_srcdir)/swig -xml tmp-file $^ cat tmp-file | $(cleanup) > $@ rm -f tmp-file all-expected-xml: for f in $(all-dot-i-files) ; do \ make `basename $$f .i`.expected-xml ; done all-expected-xml-clean: rm -f *.expected-xml # Examples/xml/Makefile ends here swig-3.0.2/Examples/xml/example.expected-xml0000664000175000017500000000146612343605122020704 0ustar williamwilliam swig-3.0.2/Examples/xml/error.expected-xml0000664000175000017500000000150512343605122020374 0ustar williamwilliam swig-3.0.2/Examples/xml/example_xml.expected-xml0000664000175000017500000016242112343605122021563 0ustar williamwilliam { } %include pointer.i The pointer.i library provides run-time support for managing and manipulating a variety of C/C++ pointer values. In particular, you can create various kinds of objects and dereference common pointer types. This is done through a common set of functions: ptrvalue - Dereferences a pointer ptrset - Set the value of an object referenced by a pointer. ptrcreate - Create a new object and return a pointer. ptrfree - Free the memory allocated by ptrcreate. ptradd - Increment/decrement a pointer value. When creating, dereferencing, or setting the value of pointer variable, only the common C datatypes of int, short, long, float, double, char, and char * are currently supported. Other datatypes may generate an error. One of the more interesting aspects of this library is that it operates with a wide range of datatypes. For example, the "ptrvalue" function can dereference "double *", "int *", "long *", "char *", and other datatypes. Since SWIG encodes pointers with type information, this can be done transparently and in most cases, you can dereference a pointer without ever knowing what type it actually is. This library is primarily designed for utility, not high performance (the dynamic determination of pointer types takes more work than most normal wrapper functions). As a result, you may achieve better performance by writing customized "helper" functions if you're making lots of calls to these functions in inner loops or other intensive operations. #include &lt;ctype.h> /* Types used by the library */ static swig_type_info *SWIG_POINTER_int_p = 0; static swig_type_info *SWIG_POINTER_short_p =0; static swig_type_info *SWIG_POINTER_long_p = 0; static swig_type_info *SWIG_POINTER_float_p = 0; static swig_type_info *SWIG_POINTER_double_p = 0; static swig_type_info *SWIG_POINTER_char_p = 0; static swig_type_info *SWIG_POINTER_char_pp = 0; static swig_type_info *SWIG_POINTER_void_p = 0; SWIG_POINTER_int_p = SWIG_TypeQuery("int *"); SWIG_POINTER_short_p = SWIG_TypeQuery("short *"); SWIG_POINTER_long_p = SWIG_TypeQuery("long *"); SWIG_POINTER_float_p = SWIG_TypeQuery("float *"); SWIG_POINTER_double_p = SWIG_TypeQuery("double *"); SWIG_POINTER_char_p = SWIG_TypeQuery("char *"); SWIG_POINTER_char_pp = SWIG_TypeQuery("char **"); SWIG_POINTER_void_p = SWIG_TypeQuery("void *"); /* #ifdef WIN32 #undef isspace #define isspace(c) (c == ' ') #endif */ /*------------------------------------------------------------------ ptrvalue(ptr,type = 0) Attempts to dereference a pointer value. If type is given, it will try to use that type. Otherwise, this function will attempt to "guess" the proper datatype by checking against all of the builtin C datatypes. ------------------------------------------------------------------ */ #ifdef PERL_OBJECT static SV *_ptrvalue(CPerlObj *pPerl,SV *_PTRVALUE, int index, char *type) { #define ptrvalue(a,b,c) _ptrvalue(pPerl,a,b,c) #else static SV *_ptrvalue(SV *_PTRVALUE, int index, char *type) { #define ptrvalue(a,b,c) _ptrvalue(a,b,c) #endif void *ptr; SV *obj = 0; if (SWIG_ConvertPtr(_PTRVALUE, &ptr, 0) &lt; 0) { croak("Type error it ptrvalue. Argument is not a valid pointer value."); } else { /* If no datatype was passed, try a few common datatypes first */ if (!type) { /* No datatype was passed. Type to figure out if it's a common one */ if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_int_p) >= 0) { type = "int"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_double_p) >= 0) { type = "double"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_short_p) >= 0) { type = "short"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_long_p) >= 0) { type = "long"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_float_p) >= 0) { type = "float"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_p) >= 0) { type = "char"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_pp) >= 0) { type = "char *"; } else { type = "unknown"; } } if (!ptr) { croak("Unable to dereference NULL pointer."); return 0; } /* Now we have a datatype. Try to figure out what to do about it */ if (strcmp(type,"int") == 0) { obj = sv_newmortal(); sv_setiv(obj,(IV) *(((int *) ptr) + index)); } else if (strcmp(type,"double") == 0) { obj = sv_newmortal(); sv_setnv(obj,(double) *(((double *) ptr)+index)); } else if (strcmp(type,"short") == 0) { obj = sv_newmortal(); sv_setiv(obj,(IV) *(((short *) ptr) + index)); } else if (strcmp(type,"long") == 0) { obj = sv_newmortal(); sv_setiv(obj,(IV) *(((long *) ptr) + index)); } else if (strcmp(type,"float") == 0) { obj = sv_newmortal(); sv_setnv(obj,(double) *(((float *) ptr)+index)); } else if (strcmp(type,"char") == 0) { obj = sv_newmortal(); sv_setpv(obj,((char *) ptr)+index); } else if (strcmp(type,"char *") == 0) { char *c = *(((char **) ptr)+index); obj = sv_newmortal(); if (c) sv_setpv(obj,c); else sv_setpv(obj,"NULL"); } else { croak("Unable to dereference unsupported datatype."); obj = 0; } } return obj; } /*------------------------------------------------------------------ ptrcreate(type,value = 0,numelements = 1) Attempts to create a new object of given type. Type must be a basic C datatype. Will not create complex objects. ------------------------------------------------------------------ */ #ifdef PERL_OBJECT static SV *_ptrcreate(CPerlObj *pPerl, char *type, SV *value, int numelements) { #define ptrcreate(a,b,c) _ptrcreate(pPerl,a,b,c) #else static SV *_ptrcreate(char *type, SV *value, int numelements) { #define ptrcreate(a,b,c) _ptrcreate(a,b,c) #endif void *ptr; SV *obj; int sz; swig_type_info *cast = 0; /* Check the type string against a variety of possibilities */ if (strcmp(type,"int") == 0) { sz = sizeof(int)*numelements; cast = SWIG_POINTER_int_p; } else if (strcmp(type,"short") == 0) { sz = sizeof(short)*numelements; cast = SWIG_POINTER_short_p; } else if (strcmp(type,"long") == 0) { sz = sizeof(long)*numelements; cast = SWIG_POINTER_long_p; } else if (strcmp(type,"double") == 0) { sz = sizeof(double)*numelements; cast = SWIG_POINTER_double_p; } else if (strcmp(type,"float") == 0) { sz = sizeof(float)*numelements; cast = SWIG_POINTER_float_p; } else if (strcmp(type,"char") == 0) { sz = sizeof(char)*numelements; cast = SWIG_POINTER_char_p; } else if (strcmp(type,"char *") == 0) { sz = sizeof(char *)*(numelements+1); cast = SWIG_POINTER_char_pp; } else if (strcmp(type,"void") == 0) { sz = numelements; cast = SWIG_POINTER_void_p; } else { croak("Unable to create unknown datatype."); return 0; } /* Create the new object */ ptr = (void *) malloc(sz); if (!ptr) { croak("Out of memory in ptrcreate."); return 0; } /* Now try to set its default value */ if (value) { if (strcmp(type,"int") == 0) { int *ip,i,ivalue; ivalue = (int) SvIV(value); ip = (int *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"short") == 0) { short *ip,ivalue; int i; ivalue = (short) SvIV(value); ip = (short *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"long") == 0) { long *ip,ivalue; int i; ivalue = (long) SvIV(value); ip = (long *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"double") == 0) { double *ip,ivalue; int i; ivalue = (double) SvNV(value); ip = (double *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"float") == 0) { float *ip,ivalue; int i; ivalue = (float) SvNV(value); ip = (float *) ptr; for (i = 0; i &lt; numelements; i++) ip[i] = ivalue; } else if (strcmp(type,"char") == 0) { char *ip,*ivalue; ivalue = (char *) SvPV(value,PL_na); ip = (char *) ptr; strncpy(ip,ivalue,numelements-1); } else if (strcmp(type,"char *") == 0) { char **ip, *ivalue; int i; ivalue = (char *) SvPV(value,PL_na); ip = (char **) ptr; for (i = 0; i &lt; numelements; i++) { if (ivalue) { ip[i] = (char *) malloc(strlen(ivalue)+1); strcpy(ip[i],ivalue); } else { ip[i] = 0; } } ip[numelements] = 0; } } /* Create the pointer value */ obj = sv_newmortal(); SWIG_MakePtr(obj,ptr,cast); return obj; } /*------------------------------------------------------------------ ptrset(ptr,value,index = 0,type = 0) Attempts to set the value of a pointer variable. If type is given, we will use that type. Otherwise, we'll guess the datatype. ------------------------------------------------------------------ */ #ifdef PERL_OBJECT static void _ptrset(CPerlObj *pPerl,SV *_PTRVALUE, SV *value, int index, char *type) { #define ptrset(a,b,c,d) _ptrset(pPerl,a,b,c,d) #else static void _ptrset(SV *_PTRVALUE, SV *value, int index, char *type) { #define ptrset(a,b,c,d) _ptrset(a,b,c,d) #endif void *ptr; SV *obj; if (SWIG_ConvertPtr(_PTRVALUE, &ptr, 0) &lt; 0) { croak("Type error it ptrvalue. Argument is not a valid pointer value."); } else { /* If no datatype was passed, try a few common datatypes first */ if (!type) { /* No datatype was passed. Type to figure out if it's a common one */ if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_int_p) >= 0) { type = "int"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_double_p) >= 0) { type = "double"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_short_p) >= 0) { type = "short"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_long_p) >= 0) { type = "long"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_float_p) >= 0) { type = "float"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_p) >= 0) { type = "char"; } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_pp) >= 0) { type = "char *"; } else { type = "unknown"; } } } if (!ptr) { croak("Unable to set NULL pointer."); return; } /* Now we have a datatype. Try to figure out what to do about it */ if (strcmp(type,"int") == 0) { *(((int *) ptr)+index) = (int) SvIV(value); } else if (strcmp(type,"double") == 0) { *(((double *) ptr)+index) = (double) SvNV(value); } else if (strcmp(type,"short") == 0) { *(((short *) ptr)+index) = (short) SvIV(value); } else if (strcmp(type,"long") == 0) { *(((long *) ptr)+index) = (long) SvIV(value); } else if (strcmp(type,"float") == 0) { *(((float *) ptr)+index) = (float) SvNV(value); } else if (strcmp(type,"char") == 0) { char *c = SvPV(value,PL_na); strcpy(((char *) ptr)+index, c); } else if (strcmp(type,"char *") == 0) { char *c = SvPV(value,PL_na); char **ca = (char **) ptr; if (ca[index]) free(ca[index]); if (strcmp(c,"NULL") == 0) { ca[index] = 0; } else { ca[index] = (char *) malloc(strlen(c)+1); strcpy(ca[index],c); } } else { croak("Unable to set unsupported datatype."); return; } } /*------------------------------------------------------------------ ptradd(ptr,offset) Adds a value to an existing pointer value. Will do a type-dependent add for basic datatypes. For other datatypes, will do a byte-add. ------------------------------------------------------------------ */ #ifdef PERL_OBJECT static SV *_ptradd(CPerlObj *pPerl, SV *_PTRVALUE, int offset) { #define ptradd(a,b) _ptradd(pPerl,a,b) #else static SV *_ptradd(SV *_PTRVALUE, int offset) { #define ptradd(a,b) _ptradd(a,b) #endif void *ptr,*junk; SV *obj; swig_type_info *type; char *tname; /* Try to handle a few common datatypes first */ if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_int_p) >= 0) { ptr = (void *) (((int *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_double_p) >= 0) { ptr = (void *) (((double *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_short_p) >= 0) { ptr = (void *) (((short *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_long_p) >= 0) { ptr = (void *) (((long *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_float_p) >= 0) { ptr = (void *) (((float *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_p) >= 0) { ptr = (void *) (((char *) ptr) + offset); } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,0) >= 0) { ptr = (void *) (((char *) ptr) + offset); } else { croak("Type error in ptradd. Argument is not a valid pointer value."); return 0; } printf("ptradd = %x\n", ptr); tname = HvNAME(SvSTASH(SvRV(_PTRVALUE))); obj = sv_newmortal(); sv_setref_pv(obj,tname,ptr); return obj; } /*------------------------------------------------------------------ ptrfree(ptr) Destroys a pointer value ------------------------------------------------------------------ */ #ifdef PERL_OBJECT void _ptrfree(CPerlObj *pPerl, SV *_PTRVALUE) { #define ptrfree(a) _ptrfree(pPerl, a) #else void _ptrfree(SV *_PTRVALUE) { #define ptrfree(a) _ptrfree(a) #endif void *ptr, *junk; if (SWIG_ConvertPtr(_PTRVALUE,&ptr,0) &lt; 0) { croak("Type error in ptrfree. Argument is not a valid pointer value."); return; } /* Check to see if this pointer is a char ** */ if (SWIG_ConvertPtr(_PTRVALUE,&junk,SWIG_POINTER_char_pp) >= 0) { char **c = (char **) ptr; if (c) { int i = 0; while (c[i]) { free(c[i]); i++; } } } if (ptr) free((char *) ptr); } { $target = $source; } { $target = $source; } { $target = $source; argvi++; } { $target = $source; argvi++; } { $target = $source; argvi++; } { $target = $source; argvi++; } { if ($source == -1) return NULL; } { temp = (double) SvNV($source); $target = &temp; } { temp = (float) SvNV($source); $target = &temp; } { temp = (int) SvIV($source); $target = &temp; } { temp = (short) SvIV($source); $target = &temp; } { temp = (long) SvIV($source); $target = &temp; } { temp = (unsigned int) SvIV($source); $target = &temp; } { temp = (unsigned short) SvIV($source); $target = &temp; } { temp = (unsigned long) SvIV($source); $target = &temp; } { temp = (unsigned char) SvIV($source); $target = &temp; } { $target = &temp; } { $target = &amp;temp; } { $target = &amp;amp;temp; } { $target = &amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;amp;amp;amp;temp; } { $target = &amp;amp;amp;amp;amp;amp;amp;amp;temp; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setiv($target,(IV) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setnv($target,(double) *($source)); argvi++; } { if (argvi >= items) { EXTEND(sp,1); } $target = sv_newmortal(); sv_setnv($target,(double) *($source)); argvi++; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { printf("Received %d\n", SvTYPE(tempsv)); croak("Expected a double reference."); } dvalue = SvNV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { croak("expected a double reference"); } dvalue = (float) SvNV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (short) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (long) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (unsigned int) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (unsigned short) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; if (!SvROK($source)) { croak("expected a reference"); } tempsv = SvRV($source); if (!SvIOK(tempsv)) { croak("expected an integer reference"); } dvalue = (unsigned long) SvIV(tempsv); $target = &dvalue; } { SV *tempsv; tempsv = SvRV($arg); sv_setnv(tempsv, (double) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setnv(tempsv, (double) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { SV *tempsv; tempsv = SvRV($arg); sv_setiv(tempsv, (int) *$source); } { WHATEVER MAKES YOU HAPPY AS RESULT } { WHATEVER MAKES YOU HAPPY AS PARAMETER } swig-3.0.2/Examples/xml/example_xml.i0000664000175000017500000000214312343605122017406 0ustar williamwilliam/* File : example.i */ %module my_example enum color { RED=10, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE, WARP, LUDICROUS }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); %include pointer.i /* Next we'll use some typemaps */ %include typemaps.i %typemap(out) int * { WHATEVER MAKES YOU HAPPY AS RESULT } %typemap(in) int * { WHATEVER MAKES YOU HAPPY AS PARAMETER } %pragma(xml) DEBUG="false"; extern int * my_gcd(const char * x, int * y[], int * r, int (*op)(int,int)) const; extern double my_foo; void my_void(); my_empty(); const double my_dutch = 1.0; union my_union { int my_iii; char my_ccc; }; struct my_struct { public: virtual ~my_struct(); int my_foo(); protected: int my_bar; double x, y; virtual double area() = 0; static int nshapes; }; class my_class : public my_struct, public my_union { public: my_class( char c ); private: ~my_class(); virtual const int * my_func( my_class , char * * x, int y[], const int & r) const; double my_foo[128]; const my_int i; }; typedef int my_int; swig-3.0.2/Examples/r/0000775000175000017500000000000012343605122014362 5ustar williamwilliamswig-3.0.2/Examples/r/class/0000775000175000017500000000000012343605122015467 5ustar williamwilliamswig-3.0.2/Examples/r/class/example.h0000664000175000017500000000107612343605122017277 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/r/class/example.i0000664000175000017500000000021512343605122017272 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/r/class/example.cxx0000664000175000017500000000065012343605122017647 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/r/class/runme.R0000664000175000017500000000202212343605122016734 0ustar williamwilliam# This file illustrates the proxy class C++ interface generated # by SWIG. dyn.load(paste("example", .Platform$dynlib.ext, sep="")) source("example.R") cacheMetaData(1) # ----- Object creation ----- print("Creating some objects:") circle <- Circle(10) print (" Created circle") square <- Square(10) print (" Created square") # ----- Access a static member ----- sprintf("A total of %d shapes were created", Shape_nshapes()) # ----- Member data access ----- # Set the location of the object circle$x <- 20 circle$y <- 30 square$x <- -10 square$y <- 5 print("Here is their current position:") sprintf(" Circle = (%f, %f)", circle$x,circle$y) sprintf(" Square = (%f, %f)", square$x,square$y) # ----- Call some methods ----- print ("Here are some properties of the shapes:") sapply(c(circle, square), function(o) { sprintf(" area = %f perimeter = %f", o$area(), o$perimeter()) }) print("Guess I'll clean up now") delete(circle) delete(square) sprintf("%d shapes remain", Shape_nshapes()) print ("Goodbye"); swig-3.0.2/Examples/r/class/example.dsp0000664000175000017500000001211312343605122017630 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(R_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(R_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(R_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(R_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on ..\..\..\swig.exe -c++ -r -o example_wrap.cpp "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on ..\..\..\swig.exe -c++ -r -o example_wrap.cpp "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/r/class/Makefile0000664000175000017500000000064712343605122017136 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' r_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' r_clean swig-3.0.2/Examples/r/simple/0000775000175000017500000000000012343605122015653 5ustar williamwilliamswig-3.0.2/Examples/r/simple/example.c0000664000175000017500000000036712343605122017460 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/r/simple/example.i0000664000175000017500000000015212343605122017456 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/r/simple/runme.R0000664000175000017500000000055412343605122017130 0ustar williamwilliam# file: runme.R dyn.load(paste("example", .Platform$dynlib.ext, sep="")) source("example.R") cacheMetaData(1) # Call our gcd() function x <- 42 y <- 105 g <- gcd(x,y) sprintf("The gcd of %d and %d is %d", x, y, g) # Manipulate the Foo global variable # Output its current value Foo() # Change its value Foo(3.1415926) # See if the change took effect Foo() swig-3.0.2/Examples/r/simple/example.dsp0000664000175000017500000001172312343605122020022 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(R_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(R_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(R_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(R_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on ..\..\..\swig.exe -r "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on ..\..\..\swig.exe -r "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/r/simple/Makefile0000664000175000017500000000063312343605122017315 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' r_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' r_clean swig-3.0.2/Examples/r/check.list0000664000175000017500000000005112343605122016330 0ustar williamwilliam# see top-level Makefile.in class simple swig-3.0.2/Examples/pike/0000775000175000017500000000000012343605122015051 5ustar williamwilliamswig-3.0.2/Examples/pike/template/0000775000175000017500000000000012343605122016664 5ustar williamwilliamswig-3.0.2/Examples/pike/template/example.h0000664000175000017500000000077712343605122020503 0ustar williamwilliam/* File : example.h */ // Some template definitions template T max(T a, T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } #ifdef SWIG %extend { T getitem(int index) { return $self->get(index); } void setitem(int index, T val) { $self->set(index,val); } } #endif }; swig-3.0.2/Examples/pike/template/example.i0000664000175000017500000000051412343605122020471 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; swig-3.0.2/Examples/pike/template/runme.pike0000664000175000017500000000134612343605122020670 0ustar williamwilliamint main() { // Call some templated functions write(sprintf("%d\n", .example.maxint(3, 7))); write(sprintf("%f\n", .example.maxdouble(3.14, 2.18))); // Create some objects .example.vecint iv = .example.vecint(100); .example.vecdouble dv = .example.vecdouble(1000); for (int i = 0; i < 100; i++) { iv->setitem(i, 2*i); } for (int i = 0; i < 1000; i++) { dv->setitem(i, 1.0/(i+1)); } int isum = 0; for (int i = 0; i < 100; i++) { isum += iv->getitem(i); } write(sprintf("%d\n", isum)); float fsum = 0.0; for (int i = 0; i < 1000; i++) { fsum += dv->getitem(i); } write(sprintf("%f\n", fsum)); return 0; } swig-3.0.2/Examples/pike/template/Makefile0000664000175000017500000000115312343605122020324 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean swig-3.0.2/Examples/pike/class/0000775000175000017500000000000012343605122016156 5ustar williamwilliamswig-3.0.2/Examples/pike/class/example.h0000664000175000017500000000107612343605122017766 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/pike/class/example.i0000664000175000017500000000021512343605122017761 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/pike/class/example.cxx0000664000175000017500000000065012343605122020336 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/pike/class/runme.pike0000664000175000017500000000250612343605122020161 0ustar williamwilliamimport .example; int main() { // ----- Object creation ----- write("Creating some objects:\n"); Circle c = Circle(10.0); write(" Created circle.\n"); Square s = Square(10.0); write(" Created square.\n"); // ----- Access a static member ----- write("\nA total of " + Shape_nshapes_get() + " shapes were created\n"); // ----- Member data access ----- // Set the location of the object c->x_set(20.0); c->y_set(30.0); s->x_set(-10.0); s->y_set(5.0); write("\nHere is their current position:\n"); write(" Circle = (%f, %f)\n", c->x_get(), c->y_get()); write(" Square = (%f, %f)\n", s->x_get(), s->y_get()); // ----- Call some methods ----- write("\nHere are some properties of the shapes:\n"); write(" The circle:\n"); write(" area = %f.\n", c->area()); write(" perimeter = %f.\n", c->perimeter()); write(" The square:\n"); write(" area = %f.\n", s->area()); write(" perimeter = %f.\n", s->perimeter()); write("\nGuess I'll clean up now\n"); /* See if we can force 's' to be garbage-collected */ s = 0; /* Now we should be down to only 1 shape */ write("%d shapes remain\n", Shape_nshapes_get()); /* Done */ write("Goodbye\n"); return 0; } swig-3.0.2/Examples/pike/class/Makefile0000664000175000017500000000110012343605122017606 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean swig-3.0.2/Examples/pike/enum/0000775000175000017500000000000012343605122016015 5ustar williamwilliamswig-3.0.2/Examples/pike/enum/README0000664000175000017500000000056112343605122016677 0ustar williamwilliamThis example will not compile with Pike versions 7.4.20 unless you first patch the Pike sources. The problem is for line 91 of Pike's "stralloc.h" (usually installed as /usr/local/pike/7.4.10/include/pike/stralloc.h). That line reads: tmp.ptr=ptr; but should be patched to read: tmp.ptr=(p_wchar0 *) ptr; This bug has been reported to the Pike developers. swig-3.0.2/Examples/pike/enum/example.h0000664000175000017500000000031512343605122017620 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE, WARP, LUDICROUS }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/pike/enum/example.i0000664000175000017500000000021712343605122017622 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/pike/enum/example.cxx0000664000175000017500000000150712343605122020177 0ustar williamwilliam/* File : example.c */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/pike/enum/runme.pike0000664000175000017500000000165612343605122020025 0ustar williamwilliamint main() { write("*** color ***\n"); write(" RED = " + .example.RED + "\n"); write(" BLUE = " + .example.BLUE + "\n"); write(" GREEN = " + .example.GREEN + "\n"); write("\n*** Foo::speed ***\n"); write(" Foo_IMPULSE = " + .example.Foo.IMPULSE + "\n"); write(" Foo_WARP = " + .example.Foo.WARP + "\n"); write(" Foo_LUDICROUS = " + .example.Foo.LUDICROUS + "\n"); write("\nTesting use of enums with functions\n\n"); .example.enum_test(.example.RED, .example.Foo.IMPULSE); .example.enum_test(.example.BLUE, .example.Foo.WARP); .example.enum_test(.example.GREEN, .example.Foo.LUDICROUS); .example.enum_test(1234, 5678); write("\nTesting use of enum with class method\n"); .example.Foo f = .example.Foo(); f->enum_test(.example.Foo.IMPULSE); f->enum_test(.example.Foo.WARP); f->enum_test(.example.Foo.LUDICROUS); return 0; } swig-3.0.2/Examples/pike/enum/Makefile0000664000175000017500000000110012343605122017445 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean swig-3.0.2/Examples/pike/simple/0000775000175000017500000000000012343605122016342 5ustar williamwilliamswig-3.0.2/Examples/pike/simple/example.c0000664000175000017500000000036712343605122020147 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/pike/simple/example.i0000664000175000017500000000015212343605122020145 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/pike/simple/runme.pike0000664000175000017500000000071512343605122020345 0ustar williamwilliamint main() { /* Call our gcd() function */ int x = 42; int y = 105; int g = .example.gcd(x, y); write("The gcd of %d and %d is %d\n", x, y, g); /* Manipulate the Foo global variable */ /* Output its current value */ write("Foo = %f\n", .example->Foo_get()); /* Change its value */ .example->Foo_set(3.1415926); /* See if the change took effect */ write("Foo = %f\n", .example->Foo_get()); return 0; } swig-3.0.2/Examples/pike/simple/Makefile0000664000175000017500000000103112343605122017775 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean swig-3.0.2/Examples/pike/constants/0000775000175000017500000000000012343605122017065 5ustar williamwilliamswig-3.0.2/Examples/pike/constants/example.i0000664000175000017500000000113512343605122020672 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/pike/constants/runme.pike0000664000175000017500000000156612343605122021075 0ustar williamwilliamint main() { write("ICONST = %d (should be 42)\n", .example.ICONST); write("FCONST = %f (should be 2.1828)\n", .example.FCONST); write("CCONST = %c (should be 'x')\n", .example.CCONST); write("CCONST2 = %c (this should be on a new line)\n", .example.CCONST2); write("SCONST = %s (should be 'Hello World')\n", .example.SCONST); write("SCONST2 = %s (should be '\"Hello World\"')\n", .example.SCONST2); write("EXPR = %f (should be 48.5484)\n", .example.EXPR); write("iconst = %d (should be 37)\n", .example.iconst); write("fconst = %f (should be 3.14)\n", .example.fconst); if (search(indices(.example), "EXTERN") == -1) write("EXTERN isn't defined (good)\n"); else write("EXTERN is defined (bad)\n"); if (search(indices(.example), "FOO") == -1) write("FOO isn't defined (good)\n"); else write("FOO is defined (bad)\n"); return 0; } swig-3.0.2/Examples/pike/constants/Makefile0000664000175000017500000000101712343605122020524 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean swig-3.0.2/Examples/pike/overload/0000775000175000017500000000000012343605122016664 5ustar williamwilliamswig-3.0.2/Examples/pike/overload/example.h0000664000175000017500000000132512343605122020471 0ustar williamwilliam#ifndef EXAMPLE_H #define EXAMPLE_H class Bar { public: Bar(); Bar(const Bar&); Bar(double); Bar(double, char *); Bar(int, int); Bar(char *); Bar(long); Bar(int); Bar(Bar *); void foo(const Bar&); void foo(double); void foo(double, char *); void foo(int, int); void foo(char *); void foo(long); void foo(int); void foo(Bar *); void spam(int x, int y=2, int z=3); void spam(double x, int y=2, int z=3); }; void foo(const Bar&); void foo(double); void foo(double, char *); void foo(int, int); void foo(char *); void foo(int); void foo(long); void foo(Bar *); void spam(int x, int y=2, int z=3); void spam(double x, int y=2, int z=3); #endif swig-3.0.2/Examples/pike/overload/example.i0000664000175000017500000000120612343605122020470 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /** * These overloaded declarations conflict with other overloads (as far as * SWIG's Ruby module's implementation for overloaded methods is concerned). * One option is use the %rename directive to rename the conflicting methods; * here, we're just using %ignore to avoid wrapping some of the overloaded * functions altogether. */ %ignore Bar; %ignore Bar::Bar(Bar *); %ignore Bar::Bar(long); %ignore Bar::foo(const Bar&); %ignore Bar::foo(long); %ignore ::foo(const Bar&); %ignore ::foo(int); /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/pike/overload/example.cxx0000664000175000017500000000571712343605122021055 0ustar williamwilliam#include #include "example.h" // Overloaded constructors for class Bar Bar::Bar() { std::cout << "Called Bar::Bar()" << std::endl; } Bar::Bar(const Bar&) { std::cout << "Called Bar::Bar(const Bar&)" << std::endl; } Bar::Bar(double x) { std::cout << "Called Bar::Bar(double) with x = " << x << std::endl; } Bar::Bar(double x, char *y) { std::cout << "Called Bar::Bar(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; } Bar::Bar(int x, int y) { std::cout << "Called Bar::Bar(int, int) with x, y = " << x << ", " << y << std::endl; } Bar::Bar(char *x) { std::cout << "Called Bar::Bar(char *) with x = \"" << x << "\"" << std::endl; } Bar::Bar(int x) { std::cout << "Called Bar::Bar(int) with x = " << x << std::endl; } Bar::Bar(long x) { std::cout << "Called Bar::Bar(long) with x = " << x << std::endl; } Bar::Bar(Bar *x) { std::cout << "Called Bar::Bar(Bar *) with x = " << x << std::endl; } // Overloaded member functions void Bar::foo(const Bar& x) { std::cout << "Called Bar::foo(const Bar&) with &x = " << &x << std::endl; } void Bar::foo(double x) { std::cout << "Called Bar::foo(double) with x = " << x << std::endl; } void Bar::foo(double x, char *y) { std::cout << "Called Bar::foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; } void Bar::foo(int x, int y) { std::cout << "Called Bar::foo(int, int) with x, y = " << x << ", " << y << std::endl; } void Bar::foo(char *x) { std::cout << "Called Bar::foo(char *) with x = \"" << x << "\"" << std::endl; } void Bar::foo(int x) { std::cout << "Called Bar::foo(int) with x = " << x << std::endl; } void Bar::foo(long x) { std::cout << "Called Bar::foo(long) with x = " << x << std::endl; } void Bar::foo(Bar *x) { std::cout << "Called Bar::foo(Bar *) with x = " << x << std::endl; } void Bar::spam(int x, int y, int z) { std::cout << "Called Bar::spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; } void Bar::spam(double x, int y, int z) { std::cout << "Called Bar::spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; } // Overloaded global methods void foo(const Bar& x) { std::cout << "Called foo(const Bar& x) with &x = " << &x << std::endl; } void foo(double x) { std::cout << "Called foo(double) with x = " << x << std::endl; } void foo(double x, char *y) { std::cout << "Called foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; } void foo(int x, int y) { std::cout << "Called foo(int, int) with x, y = " << x << ", " << y << std::endl; } void foo(char *x) { std::cout << "Called foo(char *) with x = \"" << x << "\"" << std::endl; } void foo(int x) { std::cout << "Called foo(int) with x = " << x << std::endl; } void foo(long x) { std::cout << "Called foo(long) with x = " << x << std::endl; } void foo(Bar *x) { std::cout << "Called foo(Bar *) with x = " << x << std::endl; } swig-3.0.2/Examples/pike/overload/runme.pike0000664000175000017500000000314512343605122020667 0ustar williamwilliam// import .example; int main() { // This should invoke foo(double) .example.foo(3.14159); // This should invoke foo(double, char *) .example.foo(3.14159, "Pi"); // This should invoke foo(int, int) .example.foo(3, 4); // This should invoke foo(char *) .example.foo("This is a test"); // This should invoke foo(long) .example.foo(42); /* // This should invoke Bar::Bar() followed by foo(Bar *) foo(Bar.new); // Skip a line write("\n"); // This should invoke Bar::Bar(double) Bar.new(3.14159); // This should invoke Bar::Bar(double, char *) Bar.new(3.14159, "Pi"); // This should invoke Bar::Bar(int, int) Bar.new(3, 4); // This should invoke Bar::Bar(char *) Bar.new("This is a test"); // This should invoke Bar::Bar(int) Bar.new(42); // This should invoke Bar::Bar() for the input argument, // followed by Bar::Bar(const Bar&). Bar.new(Bar.new); // Skip a line write("\n"); */ // Construct a new Bar instance (invokes Bar::Bar()) /* bar = Bar.new; // This should invoke Bar::foo(double) bar.foo(3.14159); // This should invoke Bar::foo(double, char *) bar.foo(3.14159, "Pi"); // This should invoke Bar::foo(int, int) bar.foo(3, 4); // This should invoke Bar::foo(char *) bar.foo("This is a test"); // This should invoke Bar::foo(int) bar.foo(42); // This should invoke Bar::Bar() to construct the input // argument, followed by Bar::foo(Bar *). bar.foo(Example::Bar.new); // This should invoke Bar::spam(int x, int y, int z) bar.spam(1); // This should invoke Bar::spam(double x, int y, int z) bar.spam(3.14159); */ write("Goodbye\n"); return 0; } swig-3.0.2/Examples/pike/overload/Makefile0000664000175000017500000000111112343605122020316 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lstdc++ -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean swig-3.0.2/Examples/pike/check.list0000664000175000017500000000011212343605122017015 0ustar williamwilliam# see top-level Makefile.in class constants enum overload simple template swig-3.0.2/Examples/test-suite/0000775000175000017500000000000012343605122016227 5ustar williamwilliamswig-3.0.2/Examples/test-suite/li_std_wstring.i0000664000175000017500000000277312343605122021445 0ustar williamwilliam%module li_std_wstring %include %include %inline %{ struct A : std::wstring { A(const std::wstring& s) : std::wstring(s) { } }; struct B { B(const std::wstring& s) : cname(0), name(s), a(s) { } char *cname; std::wstring name; A a; }; wchar_t test_wcvalue(wchar_t x) { return x; } const wchar_t* test_ccvalue(const wchar_t* x) { return x; } wchar_t* test_cvalue(wchar_t* x) { return x; } wchar_t* test_wchar_overload() { return 0; } wchar_t* test_wchar_overload(wchar_t *x) { return x; } std::wstring test_value(std::wstring x) { return x; } const std::wstring& test_const_reference(const std::wstring &x) { return x; } void test_pointer(std::wstring *x) { } std::wstring *test_pointer_out() { static std::wstring x = L"x"; return &x; } void test_const_pointer(const std::wstring *x) { } const std::wstring *test_const_pointer_out() { static std::wstring x = L"x"; return &x; } void test_reference(std::wstring &x) { } std::wstring& test_reference_out() { static std::wstring x = L"x"; return x; } #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif void test_throw() throw(std::wstring){ static std::wstring x = L"x"; throw x; } #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} swig-3.0.2/Examples/test-suite/smart_pointer_template_const_overload.i0000664000175000017500000000200612343605122026261 0ustar williamwilliam%module smart_pointer_template_const_overload %warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) SmartPointer::operator->; // Overloaded method SmartPointer< FooImplementation >::operator ->() ignored %inline %{ template class SmartPointer { T *ptr; public: SmartPointer(T *t = 0) : ptr(t) {} inline const T * operator->() const { return ptr; } inline T * operator->() { return ptr; } }; class FooImplementation { public: int mingy() { return 0; } int constmingy() const { return 0; } static int thingy() { return 0; } static int svariable; static const int constsvariable; int normalvariable; }; int FooImplementation::svariable = 0; const int FooImplementation::constsvariable = 2; void tester() { SmartPointer p; p->mingy(); p->constmingy(); p->thingy(); int a = p->svariable; a = p->constsvariable; a = p->normalvariable; } %} %template(FooSmartPointer) SmartPointer; swig-3.0.2/Examples/test-suite/anonymous_bitfield.i0000664000175000017500000000035012343605122022271 0ustar williamwilliam%module anonymous_bitfield %inline %{ struct Foo { int x : 4; int y : 4; int : 2; unsigned int f : 1; unsigned int : 5; int z : 15; unsigned int : 8+6; unsigned seq : (sizeof(unsigned)*8 - 6); }; %} swig-3.0.2/Examples/test-suite/redefined_not.i0000664000175000017500000000036112343605122021206 0ustar williamwilliam%module redefined_not // These should not emit an Identifer redefined warning %inline %{ typedef unsigned int my_size_t; namespace Std { using ::my_size_t; } using Std::my_size_t; typedef unsigned int my_size_t; using Std::my_size_t; %} swig-3.0.2/Examples/test-suite/director_stl.i0000664000175000017500000000351412343605122021101 0ustar williamwilliam%module(directors="1") director_stl #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR %include "std_string.i" %include "std_pair.i" %include "std_vector.i" #ifndef SWIG_STD_DEFAULT_INSTANTIATION %template() std::vector; %template() std::vector; %template() std::vector; %template() std::pair; %template() std::pair; %template() std::pair; #endif %feature("director") Foo; %feature("director:except") { #ifndef SWIGPHP if ($error != NULL) { #else if ($error == FAILURE) { #endif throw Swig::DirectorMethodException(); } } %exception { try { $action } catch (...) { SWIG_fail; } } %inline { class Foo { public: virtual ~Foo() {} virtual std::string& bar(std::string& s) { return s; } virtual std::string ping(std::string s) = 0; virtual std::string pong(const std::string& s) { return std::string("Foo::pong:") + s + ":" + ping(s); } std::string tping(std::string s) { return ping(s); } std::string tpong(const std::string& s) { return pong(s); } virtual std::pair pident(const std::pair& p) { return p; } virtual std::vector vident(const std::vector& p) { return p; } virtual std::vector vsecond(const std::vector& p, const std::vector& s) { return s; } std::pair tpident(const std::pair& p) { return pident(p); } std::vector tvident(const std::vector& p) { return vident(p); } virtual std::vector tvsecond(const std::vector& p, const std::vector& s) { return vsecond(p,s); } virtual std::vector vidents(const std::vector& p) { return p; } std::vector tvidents(const std::vector& p) { return vidents(p); } }; } swig-3.0.2/Examples/test-suite/evil_diamond_ns.i0000664000175000017500000000133612343605122021536 0ustar williamwilliam%module(ruby_minherit="1") evil_diamond_ns %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Blah::foo; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Blah::bar; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Blah::baz; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C#, D & Java, PHP multiple inheritance %inline %{ namespace Blah { class foo { }; class bar : public foo { }; class baz : public foo { }; class spam : public bar, public baz { }; foo *test(foo *f) { return f; } } %} swig-3.0.2/Examples/test-suite/funcptr_cpp.i0000664000175000017500000000245212343605122020727 0ustar williamwilliam%module funcptr_cpp %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */ #endif %} %inline %{ int addByValue(const int &a, int b) { return a+b; } int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; } int & addByReference(const int &a, int b) { static int val; val = a+b; return val; } int call1(int (*d)(const int &, int), int a, int b) { return d(a, b); } int call2(int * (*d)(const int &, int), int a, int b) { return *d(a, b); } int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); } %} %constant int (*ADD_BY_VALUE)(const int &, int) = addByValue; %constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer; %constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference; %inline %{ typedef int AddByValueTypedef(const int &a, int b); typedef int * AddByPointerTypedef(const int &a, int b); typedef int & AddByReferenceTypedef(const int &a, int b); void *typedef_call1(AddByValueTypedef *& precallback, AddByValueTypedef * postcallback) { return 0; } void *typedef_call2(AddByPointerTypedef *& precallback, AddByPointerTypedef * postcallback) { return 0; } void *typedef_call3(AddByReferenceTypedef *& precallback, AddByReferenceTypedef * postcallback) { return 0; } %} swig-3.0.2/Examples/test-suite/cpp11_constexpr.i0000664000175000017500000000147712343605122021443 0ustar williamwilliam/* This interface tests whether SWIG supports the new "constexpr" keyword introduced by C++11. */ %module cpp11_constexpr %inline %{ constexpr int AAA = 10; constexpr const int BBB = 20; constexpr int CCC() { return 30; } constexpr const int DDD() { return 40; } constexpr int XXX() { return 10; } constexpr int YYY = XXX() + 100; struct ConstExpressions { static constexpr const int JJJ = 100; static constexpr int KKK = 200; static const int LLL = 300; constexpr int MMM() { return 400; } constexpr const int NNN() { return 500; } }; %} %{ int Array10[AAA]; int Array20[BBB]; int Array30[CCC()]; int Array40[DDD()]; int Array100[ConstExpressions::JJJ]; int Array200[ConstExpressions::KKK]; int Array300[ConstExpressions::LLL]; //int Array400[ConstExpressions::MMM()]; //int Array500[ConstExpressions::NNN()]; %} swig-3.0.2/Examples/test-suite/equality.i0000664000175000017500000000275612343605122020250 0ustar williamwilliam/* File : equality.i */ /* Specific test for operator== overload. Partially overlaps with operator_overload.i */ %module equality %warnfilter(SWIGWARN_LANG_IDENTIFIER) operator==; %inline %{ /* Point has no equality operator */ typedef struct Point { double x; double y; } Point; static const Point s_zeroPoint = { 0.0, 0.0 }; /* stack version */ Point MakePoint(double x, double y) { Point new_point = {x, y}; return new_point; } const Point* GetZeroPointPtr() { return &s_zeroPoint; } Point GetZeroPointCopy() { return s_zeroPoint; } /* EqualOpDefined has correct equality operator */ class EqualOpDefined { public: EqualOpDefined(): x(5) {} EqualOpDefined(int val): x(val) {} int x; }; /* EqualOpWrong has logically incorrect equality operator */ class EqualOpWrong { public: inline static const EqualOpWrong* GetStaticObject(); }; static EqualOpWrong s_wrongEqOp; const EqualOpWrong* EqualOpWrong::GetStaticObject() { return &s_wrongEqOp; } inline bool operator==( const EqualOpDefined& first, const EqualOpDefined& second ) { return first.x == second.x; } inline bool operator==( const EqualOpWrong& first, const EqualOpWrong& second ) { return false; } %} /* in order to wrapper this correctly we need to extend the class to make the friends & non members part of the class */ %extend EqualOpDefined { bool operator==(const EqualOpDefined& b){return (*$self) == b;} } %extend EqualOpWrong { bool operator==(const EqualOpWrong& b){return (*$self) == b;} } swig-3.0.2/Examples/test-suite/cpp_basic.i0000664000175000017500000000377012343605122020333 0ustar williamwilliam/* This is a basic test of proxy classes, used by chicken */ %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) global_cint; /* Ruby, wrong constant name */ %module cpp_basic %newobject Bar::testFoo; %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */ #endif %} %inline %{ class Foo { public: Foo(int a) : num(a) {} int num; int func1(int a) { return 2*a*num; } int func2(int a) { return -a*num; } int (Foo::*func_ptr)(int); const char* __str__() const { return "Foo"; } }; class FooSub : public Foo { public: FooSub() :Foo(42) {} }; class FooSubSub : public FooSub { public: FooSubSub() : FooSub() {} const char* __str__() const { return "FooSubSub"; } }; %} %{ static Foo init_ref = Foo(-4); %} %inline %{ class Bar { public: Bar() : fptr(0), fref(init_ref), fval(15) , cint(3) {} Foo *fptr; Foo &fref; Foo fval; const int cint; static const int global_cint = -4; static Foo *global_fptr; static Foo &global_fref; static Foo global_fval; int test(int a, Foo *f) { return a + (f ? f->num : 0) + fval.num; } Foo *testFoo(int a, Foo *f) { return new Foo(2 * a + (f ? f->num : 0) + fval.num); } private: Bar& operator=(const Bar&); }; %} %{ Foo *Bar::global_fptr = NULL; Foo &Bar::global_fref = init_ref; Foo Bar::global_fval = Foo(3); %} /* member function tests */ %inline %{ int (Foo::*get_func1_ptr())(int) { return &Foo::func1; } int (Foo::*get_func2_ptr())(int) { return &Foo::func2; } int test_func_ptr(Foo *f, int a) { return (f->*(f->func_ptr))(a); } %} #ifdef __cplusplus %define MACRO_WINDOW_SHOW void show(void *count = 0, void *data = 0) { return; } %enddef %inline %{ class Fl_Window { public: Fl_Window() {}; ~Fl_Window() {}; }; %} %extend Fl_Window { MACRO_WINDOW_SHOW } #endif swig-3.0.2/Examples/test-suite/director_overload.i0000664000175000017500000000176212343605122022115 0ustar williamwilliam%module(directors="1") director_overload %feature("director"); #ifdef SWIGPYTHON %feature("director:except") { if ($error != NULL) { throw Swig::DirectorMethodException(); } } #endif #ifdef SWIGRUBY // Catch ruby exceptions in directors %feature("director:except") { throw Swig::DirectorMethodException($error); } #endif %inline %{ class OverloadedClass { public: virtual ~OverloadedClass() {} virtual void method1() const {} virtual void method2() const {} virtual void method3() const {} // test overloaded method, but not directly after the first method virtual void method2(bool b) const {} }; class OverloadedPointers { public: virtual ~OverloadedPointers() {} virtual void method(int *p) const {} virtual void method(double *p) const {} virtual void method(bool &r) const {} virtual void method(short &r) const {} virtual void method(OverloadedClass *p) const {} virtual void method(OverloadedPointers *p) const {} virtual void notover(int *p) const {} }; %} swig-3.0.2/Examples/test-suite/preproc_line_file.i0000664000175000017500000000344712343605122022071 0ustar williamwilliam%module preproc_line_file // Test __LINE__ and __FILE__ (don't change line numbering in here else runtime tests will need modifying) #define MYLINE __LINE__ #define MYLINE_ADJUSTED __LINE__ + 100 #define MYFILE __FILE__ #define MYFILE_ADJUSTED __FILE__ ".bak" #define STRINGNUM_HELP(a,b) #a#b #define STRINGNUM(a,b) STRINGNUM_HELP(a,b) #define STRINGNUM_UNIQUE(a) STRINGNUM(a,__LINE__) #define MY_STRINGNUM_A STRINGNUM_UNIQUE(my) #define MY_STRINGNUM_B STRINGNUM_UNIQUE(my) #define NUMBER_HELP(a,b) a##b #define NUMBER(a,b) NUMBER_HELP(a,b) #define NUMBER_UNIQUE(a) NUMBER(a,__LINE__) %{ const int thing27 = -1; const int thing28 = -2; %} const int NUMBER_UNIQUE(thing) = -1; /* resolves to thing27 */ const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */ #define MYLINE2 __LINE__ #if defined (SWIGJAVA) %javaconst(1); #elif defined(SWIGCSHARP) %csconst(1); #elif defined(SWIGD) %dmanifestconst; #else %ignore LINE_NUMBER; %ignore LINE_NUM; /* spare space */ #endif %{ struct SillyStruct { int num; /* static const int line_num = __LINE__; */ }; %} struct SillyStruct { int num; static const int LINE_NUMBER = __LINE__; /* This is a C test case, but we can still use a C++ feature to wrap a constant to test __LINE__ here */ }; #define SILLY_CLASS struct SillyMacroClass { int num; static const int LINE_NUM = __LINE__; }; SILLY_CLASS %{ #define SILLY_CLASS struct SillyMacroClass { int num; }; SILLY_CLASS %} %inline %{ #ifdef SWIG %define BODY int num; static const int LINE_NUM = __LINE__; %enddef %define KLASS(NAME) struct NAME { BODY }; %enddef #else #define KLASS(NAME) \ struct NAME { \ int num; \ }; #endif KLASS(SillyMultipleMacroStruct) %} %inline %{ #define INLINE_FILE __FILE__ #define INLINE_LINE __LINE__ %} #define MACRO_END_WITH_SLASH ABCD/ %inline %{ KLASS(Slash) %} swig-3.0.2/Examples/test-suite/clientdata_prop_a.i0000664000175000017500000000045412343605122022054 0ustar williamwilliam/* This file tests the clientdata propagation at swig wrapper generation. It tests a bug in the TCL module where the clientdata was not propagated correctly to all classes */ %module clientdata_prop_a %{ #include "clientdata_prop_a.h" %} %include "clientdata_prop_a.h" %newobject new_tA; swig-3.0.2/Examples/test-suite/dynamic_cast.i0000664000175000017500000000313312343605122021037 0ustar williamwilliam/* File : example.i */ %module dynamic_cast #if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD) %apply SWIGTYPE *DYNAMIC { Foo * }; #endif %inline %{ class Foo { public: virtual ~Foo() { } virtual Foo *blah() { return this; } }; %} #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO) || defined(SWIGD) %typemap(out) Foo *blah { Bar *downcast = dynamic_cast($1); *(Bar **)&$result = downcast; } #endif #if defined(SWIGJAVA) %typemap(javaout) Foo * { return new Bar($jnicall, $owner); } #endif #if defined(SWIGCSHARP) %typemap(csout, excode=SWIGEXCODE) Foo * { Bar ret = new Bar($imcall, $owner);$excode return ret; } #endif #if defined(SWIGD) %typemap(dout, excode=SWIGEXCODE) Foo * { Bar ret = new Bar($imcall, $owner);$excode return ret; } #endif #if defined(SWIGGO) %insert(go_runtime) %{ func FooToBar(f Foo) Bar { return SwigcptrBar(f.Swigcptr()) } %} #endif %inline %{ class Bar : public Foo { public: virtual Foo *blah() { return (Foo *) this; } virtual char * test() { return (char *) "Bar::test"; } }; char *do_test(Bar *b) { return b->test(); } %} #if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD) // A general purpose function for dynamic casting of a Foo * %{ static swig_type_info * Foo_dynamic(void **ptr) { Bar *b; b = dynamic_cast((Foo *) *ptr); if (b) { *ptr = (void *) b; return SWIGTYPE_p_Bar; } return 0; } %} // Register the above casting function DYNAMIC_CAST(SWIGTYPE_p_Foo, Foo_dynamic); #endif swig-3.0.2/Examples/test-suite/r/0000775000175000017500000000000012343605122016470 5ustar williamwilliamswig-3.0.2/Examples/test-suite/r/rename_simple_runme.R0000664000175000017500000000110612343605122022637 0ustar williamwilliamsource("unittest.R") dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep="")) source("rename_simple.R") cacheMetaData(1) s <- NewStruct(); unittest(111, s$NewInstanceVariable) unittest(222, s$NewInstanceMethod()) unittest(333, NewStruct_NewStaticMethod()) unittest(444, NewStruct_NewStaticVariable()) unittest(555, NewFunction()) unittest(666, NewGlobalVariable()) s$NewInstanceVariable <- 1111 NewStruct_NewStaticVariable(4444) NewGlobalVariable(6666) unittest(1111, s$NewInstanceVariable) unittest(4444, NewStruct_NewStaticVariable()) unittest(6666, NewGlobalVariable()) swig-3.0.2/Examples/test-suite/r/arrays_dimensionless_runme.R0000664000175000017500000000074612343605122024265 0ustar williamwilliamsource("unittest.R") dyn.load(paste("arrays_dimensionless", .Platform$dynlib.ext, sep="")) source("arrays_dimensionless.R") cacheMetaData(1) unittest(arr_short(1:4, 3), 6) unittest(arr_ushort(1:4, 3), 6) unittest(arr_int(1:4, 3), 6) unittest(arr_uint(1:4, 3), 6) unittest(arr_long(1:4, 3), 6) unittest(arr_ulong(1:4, 3), 6) unittest(arr_ll(1:4, 3), 6) unittest(arr_ull(1:4, 3), 6) unittest(arr_float(as.numeric(1:4), 3), 6) unittest(arr_double(as.numeric(1:4), 3), 6) q(save="no") swig-3.0.2/Examples/test-suite/r/integers_runme.R0000664000175000017500000000101512343605122021636 0ustar williamwilliamsource("unittest.R") dyn.load(paste("integers", .Platform$dynlib.ext, sep="")) source("integers.R") cacheMetaData(1) unittest(signed_char_identity(1), 1) unittest(unsigned_char_identity(1), 1) unittest(signed_short_identity(1), 1) unittest(unsigned_short_identity(1), 1) unittest(signed_int_identity(1), 1) unittest(unsigned_int_identity(1), 1) unittest(signed_long_identity(1), 1) unittest(unsigned_long_identity(1), 1) unittest(signed_long_long_identity(1), 1) unittest(unsigned_long_long_identity(1), 1) q(save="no") swig-3.0.2/Examples/test-suite/r/ignore_parameter_runme.R0000664000175000017500000000027012343605122023343 0ustar williamwilliamsource("unittest.R") dyn.load(paste("ignore_parameter", .Platform$dynlib.ext, sep="")) source("ignore_parameter.R") cacheMetaData(1) unittest(jaguar(1, 1.0), "hello") q(save="no") swig-3.0.2/Examples/test-suite/r/unions_runme.R0000664000175000017500000000025612343605122021337 0ustar williamwilliamsource("unittest.R") dyn.load(paste("unions", .Platform$dynlib.ext, sep="")) source("unions.R") cacheMetaData(1) ss <- SmallStruct() bstruct <- BigStruct() q(save="no") swig-3.0.2/Examples/test-suite/r/r_double_delete_runme.R0000664000175000017500000000026212343605122023136 0ustar williamwilliamdyn.load(paste("r_double_delete", .Platform$dynlib.ext, sep="")) source("r_double_delete.R") cacheMetaData(1) # ----- Object creation ----- f <- Foo(2.0) delete(f); delete(f); swig-3.0.2/Examples/test-suite/r/unittest.R0000664000175000017500000000037712343605122020501 0ustar williamwilliamunittest <- function (x,y) { if (x==y) { print("PASS") } else { print("FAIL") stop("Test failed") } } unittesttol <- function(x,y,z) { if (abs(x-y) < z) { print("PASS") } else { print("FAIL") stop("Test failed") } } swig-3.0.2/Examples/test-suite/r/funcptr_runme.R0000664000175000017500000000033012343605122021476 0ustar williamwilliamsource("unittest.R") dyn.load(paste("funcptr", .Platform$dynlib.ext, sep="")) source("funcptr.R") cacheMetaData(1) unittest(do_op(1, 3, add), 4) unittest(do_op(2, 3, multiply), 6) unittest(do_op(2, 3, funcvar()), 5) swig-3.0.2/Examples/test-suite/r/r_copy_struct_runme.R0000664000175000017500000000154012343605122022720 0ustar williamwilliamsource("unittest.R") dyn.load(paste("r_copy_struct", .Platform$dynlib.ext, sep="")) source("r_copy_struct.R") cacheMetaData(1) a <- getA() r = getARef() unittest(A_d_get(r), 42) unittest(r$d, 42) unittest(r$i, 20) # An error in trying to access a field that doesn't exist. try(r$foo) r$d <- pi unittesttol(r$d, 3.141593, 0.0001) r$i <- -100 r$ui r$ui <- 10 # An error since i is unsigned and so must be positive. try(r$ui <- -10) a = A() unittest(a$i,0) unittest(a$d,0) unittest(a$ui,0) a$ui <- 100 unittest(a$ui,100) a$d = 1 unittest(a$d,1) d <- bar() unittest(class(d), "_p_D") unittest(d$x, 1) unittest(d$u, 0) la <- new("A"); la@ui <- as.integer(5) # Removing the next line makes this fail in R 2.4 la@str <- "" other = A() foo <- copyToC(la, other) aa = A() aa$i = as.integer(201) aa$d = pi aa$str = "foo" aa$ui = as.integer(0) copyToR(aa) swig-3.0.2/Examples/test-suite/r/r_sexp_runme.R0000664000175000017500000000023212343605122021316 0ustar williamwilliamsource("unittest.R") dyn.load(paste("r_sexp", .Platform$dynlib.ext, sep="")) source("r_sexp.R") cacheMetaData(1) obj <- return_sexp(1); unittest(obj, 1) swig-3.0.2/Examples/test-suite/r/overload_method_runme.R0000664000175000017500000000042312343605122023173 0ustar williamwilliamsource("unittest.R") dyn.load(paste("overload_method", .Platform$dynlib.ext, sep="")) source("overload_method.R") cacheMetaData(1) b <- Base() Base_method(b) Base_overloaded_method(b) Base_overloaded_method(b, 43) Base_overloaded_method(b) b$method() b$overloaded_method() swig-3.0.2/Examples/test-suite/r/simple_array_runme.R0000664000175000017500000000023112343605122022504 0ustar williamwilliamsource("unittest.R") dyn.load(paste("simple_array", .Platform$dynlib.ext, sep="")) source("simple_array.R") cacheMetaData(1) initArray() q(save="no") swig-3.0.2/Examples/test-suite/r/Makefile.in0000664000175000017500000000373612343605122020546 0ustar williamwilliam####################################################################### # Makefile for r test-suite ####################################################################### LANGUAGE = r SCRIPTSUFFIX = _runme.R WRAPSUFFIX = .R RUNR = R CMD BATCH --no-save --no-restore srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ C_TEST_CASES += \ r_copy_struct \ r_legacy CPP_TEST_CASES += \ r_double_delete \ r_overload_array \ r_sexp include $(srcdir)/../common.mk # Overridden variables here # none! # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_multitestcase) # Runs the testcase. # # Run the runme if it exists. If not just load the R wrapper to # check for syntactic correctness run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ else \ $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX); \ fi run_multitestcase = \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \ $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \ else \ $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \ fi; \ done # Clean clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" r_clean %.clean: @rm -f $*.R $*_wrap.so $*_wrap.cpp $*_wrap.c $*_wrap.o $*_runme.Rout $*.Rout @if [ -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ rm -f $${f}.R $${f}.Rout ; \ done \ fi swig-3.0.2/Examples/test-suite/r/r_legacy_runme.R0000664000175000017500000000113112343605122021602 0ustar williamwilliamsource("unittest.R") dyn.load(paste("r_legacy", .Platform$dynlib.ext, sep="")) source("r_legacy.R") cacheMetaData(1) obj <- getObject(1,3) unittest(class(obj), "_p_Obj") unittest(obj$i, 1) unittesttol(obj$d, 3, 0.001) unittest(obj$str, "a test string") obj$i <- 2 unittest(obj$i, 2) obj$d <- 4 unittesttol(obj$d, 4, 0.001) obj$str <- "a new string" unittest(obj$str, "a new string") unittest(getInt(), 42) unittesttol(getDouble(),3.14159, 0.001) unittesttol(getFloat(),3.14159/2.0, 0.001) unittest(getLong(), -321313) unittest(getUnsignedLong(), 23123) unittest(getChar(), "A") q(save="no") swig-3.0.2/Examples/test-suite/li_std_pair_using.i0000664000175000017500000000056412343605122022104 0ustar williamwilliam%module li_std_pair_using %include using std::pair; %template(StringStringPair) pair; %inline %{ typedef int Integer; using std::string; %} %template(StringIntPair) pair; %inline %{ typedef std::string String; typedef string Streeng; std::pair bounce(std::pair p) { return p; } %} swig-3.0.2/Examples/test-suite/cpp11_template_explicit.i0000664000175000017500000000117612343605122023126 0ustar williamwilliam/* This unit tests whether SWIG correctly parses the code and makes wrappers for the new C++11 extern templates (explicit template instantiation without using the translation unit). */ %module cpp11_template_explicit #pragma SWIG nowarn=SWIGWARN_PARSE_EXPLICIT_TEMPLATE %inline %{ template struct Temper { T val; }; class A { public: int member; int memberFunction() { return 100; } }; template class Temper; extern template class Temper; template class Temper; extern template class Temper; template class Temper; extern template class Temper; %} %template(TemperInt) Temper; swig-3.0.2/Examples/test-suite/unicode_strings.i0000664000175000017500000000035712343605122021605 0ustar williamwilliam%module unicode_strings %include %inline %{ const char* non_utf8_c_str(void) { return "h\xe9llo w\xc3\xb6rld"; } std::string non_utf8_std_string(void) { return std::string("h\xe9llo w\xc3\xb6rld"); } %} swig-3.0.2/Examples/test-suite/smart_pointer_const.i0000664000175000017500000000032212343605122022472 0ustar williamwilliam%module smart_pointer_const %inline %{ struct Foo { int x; int getx() const { return x; } }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } Foo *operator->() { return f; } }; %} swig-3.0.2/Examples/test-suite/voidtest.i0000664000175000017500000000051212343605122020240 0ustar williamwilliam%module voidtest %inline %{ void globalfunc(void) { } class Foo { public: Foo(void) { } void memberfunc(void) { } static void staticmemberfunc(void) { } }; void *vfunc1(void *f) { return f; } void *vfunc2(Foo *f) { return f; } Foo *vfunc3(void *f) { return (Foo *) f; } Foo *vfunc4(Foo *f) { return f; } %} swig-3.0.2/Examples/test-suite/smart_pointer_const2.i0000664000175000017500000000036512343605122022563 0ustar williamwilliam%module smart_pointer_const2 %inline %{ struct Foo { int x; int getx() const { return x; } int test() { return x; } }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } const Foo *operator->() { return f; } }; %} swig-3.0.2/Examples/test-suite/enum_forward.i0000664000175000017500000000145512343605122021076 0ustar williamwilliam%module enum_forward /* This contains C code that is not valid C++03 and Octave, and Javascript(v8) wrappers are always compiled as C++ */ #if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) %{ enum ForwardEnum1 { AAA, BBB }; enum ForwardEnum2 { CCC, DDD }; %} %inline %{ enum ForwardEnum1; enum ForwardEnum1 get_enum1() { return AAA; } enum ForwardEnum1 test_function1(enum ForwardEnum1 e) { return e; } %} %inline %{ enum ForwardEnum2; enum ForwardEnum2; enum ForwardEnum2 get_enum2() { return CCC; } enum ForwardEnum2 test_function2(enum ForwardEnum2 e) { return e; } enum ForwardEnum2; %} %inline %{ enum ForwardEnum3; enum ForwardEnum3 { EEE, FFF }; enum ForwardEnum3 get_enum3() { return EEE; } enum ForwardEnum3 test_function3(enum ForwardEnum3 e) { return e; } enum ForwardEnum3; %} #endif swig-3.0.2/Examples/test-suite/director_frob.i0000664000175000017500000000415112343605122021225 0ustar williamwilliam%module(directors="1") director_frob; #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR %header %{ #include %} %feature("director"); %feature("nodirector") Bravo::abs_method(); // ok %feature("director") Charlie::abs_method(); // ok %feature("nodirector") Delta::abs_method(); // ok %inline %{ struct Alpha { virtual ~Alpha() { }; virtual const char* abs_method() = 0; }; struct Bravo : Alpha { const char* abs_method() { return "Bravo::abs_method()"; } }; struct Charlie : Bravo { const char* abs_method() { return "Charlie::abs_method()"; } }; struct Delta : Charlie { }; %} %rename(OpInt) operator int(); %rename(OpIntStarStarConst) operator int **() const; %rename(OpIntAmp) operator int &(); %rename(OpIntStar) operator void *(); %rename(OpConstIntIntStar) operator const int *(); %inline %{ class Ops { public: Ops() : num(0) {} virtual ~Ops() {} virtual operator int() { return 0; } virtual operator int **() const { return (int **) 0; } virtual operator int &() { return num; } virtual operator void *() { return (void *) this; } virtual operator const int *() { return # } private: int num; }; struct Prims { virtual ~Prims() {} virtual unsigned long long ull(unsigned long long i, unsigned long long j) { return i + j; } unsigned long long callull(int i, int j) { return ull(i, j); } }; %} // The similarity of the director class name and other symbol names were causing a problem in the code generation %feature("director") coreCallbacks; %inline %{ class corePoint3d {}; struct coreCallbacks_On3dEngineRedrawnData { corePoint3d _eye; corePoint3d _at; }; struct coreCallbacksOn3dEngineRedrawnData { corePoint3d _eye; corePoint3d _at; }; class coreCallbacks { public: coreCallbacks(void) {} virtual ~coreCallbacks(void) {} virtual void On3dEngineRedrawn(const coreCallbacks_On3dEngineRedrawnData& data){} virtual void On3dEngineRedrawn2(const coreCallbacksOn3dEngineRedrawnData& data){} }; %} swig-3.0.2/Examples/test-suite/csharp_features.i0000664000175000017500000000133412343605122021560 0ustar williamwilliam%module csharp_features %include "wchar.i" // SWIG gets the method modifiers wrong occasionally, like with private inheritance, %csmethodmodifiers can fix this %csmethodmodifiers Derived::VirtualMethod() "public virtual" %csmethodmodifiers MoreDerived::variable "public new" %inline %{ class Base { public: virtual ~Base() {} virtual void VirtualMethod() {} }; class Derived : private Base { public: virtual ~Derived() {} virtual void VirtualMethod() {} int variable; }; class MoreDerived : public Derived { public: int variable; // test wide char literals support for C# module void methodWithDefault1(const wchar_t* s = L"literal with escapes \x1234"){} void methodWithDefault2(wchar_t c = L'\x1234'){} }; %} swig-3.0.2/Examples/test-suite/pike/0000775000175000017500000000000012343605122017157 5ustar williamwilliamswig-3.0.2/Examples/test-suite/pike/Makefile.in0000664000175000017500000000223412343605122021225 0ustar williamwilliam####################################################################### # Makefile for Pike test-suite ####################################################################### LANGUAGE = pike PIKE = pike SCRIPTSUFFIX = _runme.pike srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ include $(srcdir)/../common.mk # Overridden variables here # none! # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.pike appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PIKE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: remove the generated .pike file %.clean: @rm -f $*.pike; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" pike_clean swig-3.0.2/Examples/test-suite/cpp11_rvalue_reference2.i0000664000175000017500000000535612343605122023014 0ustar williamwilliam%module cpp11_rvalue_reference2 %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) globalrrval; // This testcase tests lots of different places that rvalue reference syntax can be used %typemap(in) Something && "/*in Something && typemap*/" %rename(OperatorRValue) Thingy::operator int&&; %rename(memberFnRenamed) memberFn(short &&i); %feature("compactdefaultargs") Thingy::compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef); %feature("exception") Thingy::privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue); %ignore Thingy::operator=; %inline %{ #include struct UserDef { int a; }; static const bool PublicGlobalTrue = true; static const UserDef PublicUserDef = UserDef(); struct Thingy { typedef int Integer; int val; int &lvalref; int &&rvalref; Thingy(int v) : val(v), lvalref(val), rvalref(22) {} void refIn(long &i) {} void rvalueIn(long &&i) {} short && rvalueInOut(short &&i) { return std::move(i); } static short && staticRvalueInOut(short &&i) { return std::move(i); } // 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 &&() {} Thingy& operator=(const Thingy& rhs) { val = rhs.val; lvalref = rhs.lvalref; rvalref = rhs.rvalref; } private: static const bool PrivateTrue; Thingy(); }; const bool Thingy::PrivateTrue = true; short && globalRvalueInOut(short &&i) { return std::move(i); } Thingy &&globalrrval = Thingy(55); short && func(short &&i) { return std::move(i); } Thingy getit() { return Thingy(22); } void rvalrefFunction1(int &&v = (int &&)5) {} void rvalrefFunctionBYVAL(short (Thingy::*memFunc)(short)) {} void rvalrefFunctionLVALUE(short &(Thingy::*memFunc)(short &)) {} void rvalrefFunction2(short && (Thingy::*memFunc)(short &&)) {} void rvalrefFunction3(short && (*memFunc)(short &&)) {} template struct RemoveReference { typedef T type; }; template struct RemoveReference { typedef T type; }; template struct RemoveReference { typedef T type; }; template <> struct RemoveReference { typedef short type; }; // like std::move template typename RemoveReference::type&& Move(T&& t) { return static_cast::type&&>(t); } %} %template(RemoveReferenceDouble) RemoveReference; %template(RemoveReferenceFloat) RemoveReference; %template(RemoveReferenceShort) RemoveReference; %template(MoveFloat) Move; swig-3.0.2/Examples/test-suite/varargs_overload.i0000664000175000017500000000175012343605122021744 0ustar williamwilliam// Tests SWIG's *default* handling of overloading varargs (function varargs, not preprocessor varargs). // The default behavior is to simply ignore the varargs. %module varargs_overload %inline %{ const char *vararg_over1(const char *fmt, ...) { return fmt; } const char *vararg_over1(int i) { static char buffer[256]; sprintf(buffer, "%d", i); return buffer; } const char *vararg_over2(const char *fmt, ...) { return fmt; } const char *vararg_over2(int i, double j) { static char buffer[256]; sprintf(buffer, "%d %g", i, j); return buffer; } const char *vararg_over3(const char *fmt, ...) { return fmt; } const char *vararg_over3(int i, double j, const char *s) { static char buffer[256]; sprintf(buffer, "%d %g %s", i, j, s); return buffer; } %} %varargs(int mode = 0) vararg_over4; %inline %{ const char *vararg_over4(const char *fmt, ...) { return fmt; } const char *vararg_over4(int i) { static char buffer[256]; sprintf(buffer, "%d", i); return buffer; } %} swig-3.0.2/Examples/test-suite/using_extend.i0000664000175000017500000000177012343605122021102 0ustar williamwilliam%module(ruby_minherit="1") using_extend %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, D, Java, PHP multiple inheritance #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah; #endif %extend Foo { int blah(int x, int y) { return x+y; } }; %extend Bar { double blah(double x, double y) { return x+y; } }; %inline %{ class Foo { public: int blah(int x) { return x; } char *blah(char *x) { return x; } }; class Bar { public: int duh1() { return 1; } int duh(int x) { return x; } double blah(double x) { return x; } }; class FooBar : public Foo, public Bar { public: using Foo::blah; using Bar::blah; char *blah(char *x) { return x; } }; %} %extend FooBar { using Bar::duh1; using Bar::duh; } swig-3.0.2/Examples/test-suite/swig_examples_lock.h0000664000175000017500000000255312343605122022264 0ustar williamwilliam # if defined(_WIN32) || defined(__WIN32__) #include namespace SwigExamples { class CriticalSection { public: CriticalSection() { InitializeCriticalSection(&mutex_); } ~CriticalSection() { DeleteCriticalSection(&mutex_); } CRITICAL_SECTION mutex_; }; struct Lock { Lock(CriticalSection &cs) : critical_section(cs) { EnterCriticalSection(&critical_section.mutex_); } ~Lock() { LeaveCriticalSection(&critical_section.mutex_); } private: CriticalSection &critical_section; }; } #else #include #ifndef PTHREAD_MUTEX_RECURSIVE_NP // For Cygwin and possibly other OSs: _NP is "non-portable" #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE #endif namespace SwigExamples { class CriticalSection { public: CriticalSection() { pthread_mutexattr_t mutexattr; pthread_mutexattr_init(&mutexattr); pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE_NP); pthread_mutex_init(&mutex_, &mutexattr); pthread_mutexattr_destroy(&mutexattr); } ~CriticalSection() { pthread_mutex_destroy (&mutex_); } pthread_mutex_t mutex_; }; struct Lock { Lock(CriticalSection &cs) : critical_section(cs) { pthread_mutex_lock (&critical_section.mutex_); } ~Lock() { pthread_mutex_unlock (&critical_section.mutex_); } private: CriticalSection &critical_section; }; } #endif swig-3.0.2/Examples/test-suite/samename.i0000664000175000017500000000035512343605122020172 0ustar williamwilliam%module samename #if !(defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGD)) class samename { public: void do_something() { // ... } }; #endif %{ class samename { public: void do_something() { // ... } }; %} swig-3.0.2/Examples/test-suite/director_primitives.i0000664000175000017500000001064312343605122022473 0ustar williamwilliam// Tests primitives // Note: C# module has a large runtime test #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR %module(directors="1") director_primitives %feature("director") Base; %feature("director") Derived; %include "std_string.i" %inline %{ #include #include // Use for debugging bool PrintDebug = false; enum HShadowMode { HShadowNone = 1, HShadowSoft = 2, HShadowHard = 3 }; class Base { protected: double m_dd; public: Base(double dd) : m_dd(dd) {} virtual ~Base() {} virtual void NoParmsMethod() { if (PrintDebug) std::cout << "Base - NoParmsMethod()" << std::endl; } virtual bool BoolMethod(bool x) { if (PrintDebug) std::cout << "Base - BoolMethod(" << x << ")" << std::endl; return x; } virtual int IntMethod(int x) { if (PrintDebug) std::cout << "Base - IntMethod(" << x << ")" << std::endl; return x; } virtual unsigned int UIntMethod(unsigned int x) { if (PrintDebug) std::cout << "Base - UIntMethod(" << x << ")" << std::endl; return x; } virtual float FloatMethod(float x) { if (PrintDebug) std::cout << "Base - FloatMethod(" << x << ")" << std::endl; return x; } virtual char * CharPtrMethod(char * x) { if (PrintDebug) std::cout << "Base - CharPtrMethod(" << x << ")" << std::endl; return x; } virtual const char * ConstCharPtrMethod(const char * x) { if (PrintDebug) std::cout << "Base - ConstCharPtrMethod(" << x << ")" << std::endl; return x; } virtual HShadowMode EnumMethod(HShadowMode x) { if (PrintDebug) std::cout << "Base - EnumMethod(" << x << ")" << std::endl; return x; } virtual void ManyParmsMethod(bool b, int i, unsigned int u, float f, char * c, const char * cc, HShadowMode h) { if (PrintDebug) std::cout << "Base - ManyParmsMethod(" << b << ", " << i << ", " << u << ", " << f << ", " << c << ", " << cc << ", " << h << ")" << std::endl; } virtual void NotOverriddenMethod() { if (PrintDebug) std::cout << "Base - NotOverriddenMethod()" << std::endl; } }; class Derived : public Base { public: Derived(double dd) : Base(dd) {} virtual ~Derived() {} virtual void NoParmsMethod() { if (PrintDebug) std::cout << "Derived - NoParmsMethod()" << std::endl; } virtual bool BoolMethod(bool x) { if (PrintDebug) std::cout << "Derived - BoolMethod(" << x << ")" << std::endl; return x; } virtual int IntMethod(int x) { if (PrintDebug) std::cout << "Derived - IntMethod(" << x << ")" << std::endl; return x; } virtual unsigned int UIntMethod(unsigned int x) { if (PrintDebug) std::cout << "Derived - UIntMethod(" << x << ")" << std::endl; return x; } virtual float FloatMethod(float x) { if (PrintDebug) std::cout << "Derived - FloatMethod(" << x << ")" << std::endl; return x; } virtual char * CharPtrMethod(char * x) { if (PrintDebug) std::cout << "Derived - CharPtrMethod(" << x << ")" << std::endl; return x; } virtual const char * ConstCharPtrMethod(const char * x) { if (PrintDebug) std::cout << "Derived - ConstCharPtrMethod(" << x << ")" << std::endl; return x; } virtual HShadowMode EnumMethod(HShadowMode x) { if (PrintDebug) std::cout << "Derived - EnumMethod(" << x << ")" << std::endl; return x; } virtual void ManyParmsMethod(bool b, int i, unsigned int u, float f, char * c, const char * cc, HShadowMode h) { if (PrintDebug) std::cout << "Derived - ManyParmsMethod(" << b << ", " << i << ", " << u << ", " << f << ", " << c << ", " << cc << ", " << h << ")" << std::endl; } }; class Caller { private: Base *m_base; void delBase() { delete m_base; m_base = 0; } public: Caller(): m_base(0) {} virtual ~Caller() { delBase(); } void set(Base *b) { delBase(); m_base = b; } void reset() { m_base = 0; } void NoParmsMethodCall() { m_base->NoParmsMethod(); } bool BoolMethodCall(bool x) { return m_base->BoolMethod(x); } int IntMethodCall(int x) { return m_base->IntMethod(x); } unsigned int UIntMethodCall(unsigned int x) { return m_base->UIntMethod(x); } float FloatMethodCall(float x) { return m_base->FloatMethod(x); } char * CharPtrMethodCall(char * x) { return m_base->CharPtrMethod(x); } const char * ConstCharPtrMethodCall(const char * x) { return m_base->ConstCharPtrMethod(x); } HShadowMode EnumMethodCall(HShadowMode x) { return m_base->EnumMethod(x); } virtual void ManyParmsMethodCall(bool b, int i, unsigned int u, float f, char * c, const char * cc, HShadowMode h) { return m_base->ManyParmsMethod(b, i, u, f, c, cc, h); } virtual void NotOverriddenMethodCall() { m_base->NotOverriddenMethod(); } }; %} swig-3.0.2/Examples/test-suite/extern_c.i0000664000175000017500000000037112343605122020211 0ustar williamwilliam%module extern_c %inline %{ extern "C" { void RealFunction(int value); typedef void Function1(int value); // Fails typedef int Integer1; } typedef void Function2(int value); // Works typedef int Integer2; %} %{ void RealFunction(int value) {} %} swig-3.0.2/Examples/test-suite/ruby_naming.i0000664000175000017500000000303512343605122020714 0ustar williamwilliam%module ruby_naming %predicate predicateMethod(); %bang bangMethod(); /* This gets mapped to a constant */ %constant int constant1 = 1; /* This gets mapped to a constant */ #define constant2 2 %immutable TestConstants::constant8; %inline %{ /* ============ Test Constants Names ============== */ /* This gets mapped to a constant */ #define constant3 3 /* These are all singleton methods */ const int constant4[2] = {10, 20}; const int constant5 = 5; static const int constant6 = 6; class TestConstants { public: TestConstants() : constant7(7) {} /* This gets mapped to a method */ const int constant7; /* This gets mapped to a singleton method, but this is not legal C++ */ static const int constant8; /* This gets mapped to a method, but this it not legal C++ */ /*const int constant9 = 9;*/ /* This gets mapped to a constant */ static const int constant10 = 10; }; const int TestConstants::constant8 = 8; const TestConstants * constant11[5]; /* ============ Test Enum ============== */ typedef enum {Red, Green, Blue} Colors; /* ============ Test Method Names ============== */ class my_class { public: int methodOne() { return 1; } int MethodTwo() { return 2; } int Method_THREE() { return 3; } int Method44_4() { return 4; } bool predicateMethod() { return true; } bool bangMethod() { return true; } int begin() { return 1; } int end() { return 1; } }; %} %inline { template struct A { }; } %template(A_i) A; swig-3.0.2/Examples/test-suite/types_directive.i0000664000175000017500000000233112343605122021602 0ustar williamwilliam%module types_directive #if defined(SWIGR) // Avoid conflict with Date class in R #define Date DateSwig %inline %{ #define Date DateSwig %} #endif %ignore Time2::operator Date *; %inline %{ struct Date { Date(unsigned int year, unsigned int month, unsigned int day) : year(year), month(month), day(day) {} unsigned int year; unsigned int month; unsigned int day; }; struct Time1 { Time1(unsigned int year, unsigned int month, unsigned int day, unsigned int seconds) : date(year, month, day), seconds(seconds) {} Date &dateFromTime() { return date; } Date date; unsigned int seconds; }; struct Time2 { Time2(unsigned int year, unsigned int month, unsigned int day, unsigned int seconds) : date(year, month, day), seconds(seconds) {} operator Date *() { return &date; } Date date; unsigned int seconds; }; Date add(const Date &date, unsigned int days) { Date newDate = date; newDate.day += days; return newDate; } %} // allow conversion from Date -> Time1 using the following code %types(Time1 = Date) %{ Time1 *t = (Time1 *)$from; Date &d = t->dateFromTime(); return (void *) &d; %} // allow conversion from Date -> Time2 using conversion operator (cast) in Time2 %types(Time2 = Date); swig-3.0.2/Examples/test-suite/refcount.h0000664000175000017500000000557312343605122020237 0ustar williamwilliam#ifndef TEST_SUITE_REFCOUNT_H__ #define TEST_SUITE_REFCOUNT_H__ struct RCObjBase { /*! Return the numbers of active references. \return The internal \c refCount value. */ int ref_count() const { return refCount; } /*! Add one reference. \return The reference counter value. */ int addref() const { return add_ref(); } /*! Delete one reference. If the refCount is zero, the object is deleted. \return The reference counter value, which can be zero after deletion. */ int delref() const { if (ref_count() == 0 || del_ref() == 0 ) { delete this; return 0; } return ref_count(); } protected: RCObjBase(); RCObjBase(const RCObjBase& ); virtual ~RCObjBase() = 0; private: RCObjBase& operator=(const RCObjBase& ); friend struct RCObj; int add_ref() const { return ++refCount; } int del_ref() const { return --refCount; } mutable int refCount; }; struct RCObj : virtual RCObjBase { protected: RCObj() { } }; /*! Reference an RCObj object \return The input pointer \a r */ template inline T* addref(T* r) { return (r && r->addref() ) ? r : 0; } /*! Unreference an RCObj object. \return The input pointer \a r or nil if the object was deleted. */ template inline T* delref(T* r) { return ( r && r->delref() ) ? r : 0; } RCObjBase::RCObjBase() : refCount(0) { } RCObjBase::~RCObjBase() { } RCObjBase::RCObjBase(const RCObjBase&) : refCount(0) { } RCObjBase& RCObjBase::operator=(const RCObjBase&) { return *this; } template struct RCPtr { typedef T* pointer_type; typedef T& refernce_type; typedef T value_type; RCPtr(); RCPtr(T* realPtr); RCPtr(const RCPtr& rhs); ~RCPtr(); RCPtr& operator=(const RCPtr& rhs); RCPtr& operator=(T* realPtr); T* operator->() { return pointee; } T& operator*() { return *pointee; } const T* operator->() const { return pointee; } const T& operator*() const { return *pointee; } operator T*() { return pointee; } operator T&() { return *pointee; } operator const T*() const { return pointee; } operator const T&() const { return *pointee; } T* get() { return pointee; } T* get() const { return pointee; } private: T* pointee; }; template inline RCPtr::RCPtr() : pointee(0) { } template inline RCPtr::RCPtr(T* realPtr) : pointee(realPtr) { addref(pointee); } template inline RCPtr::RCPtr(const RCPtr& rhs) : pointee(rhs.pointee) { addref(pointee); } template inline RCPtr::~RCPtr() { delref(pointee); } template inline RCPtr& RCPtr::operator=(const RCPtr& rhs) { if (pointee != rhs.pointee) { delref(pointee); pointee = rhs.pointee; addref(pointee); } return *this; } #endif //TEST_SUITE_REFCOUNT_H__ swig-3.0.2/Examples/test-suite/name_cxx.i0000664000175000017500000000065212343605122020206 0ustar williamwilliam/* This interface files tests whether SWIG handles overloaded renamed functions. */ %module name_cxx #pragma SWIG nowarn=SWIGWARN_DEPRECATED_NAME // %name is deprecated. Use %rename instead. %name("bar_int") %inline %{ void bar(int i) {} %} %name("bar_double") %inline %{ void bar(double i) {} %} // %name inheritance test %{ class A { }; class B : public A { }; %} %name(AA) class A { }; class B : public A { }; swig-3.0.2/Examples/test-suite/preproc.i0000664000175000017500000001620012343605122020052 0ustar williamwilliam%module preproc %warnfilter(SWIGWARN_RUBY_WRONG_NAME) one; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) two; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) three; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_CONST; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_PROTOTYPES; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */ #pragma SWIG nowarn=890 /* lots of Go name conflicts */ #pragma SWIG nowarn=206 /* Unexpected tokens after #endif directive. */ /* check __cplusplus case */ %header %{ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* C code */ #ifdef __cplusplus } #endif /* __cplusplus */ %} /* This interface file tests whether SWIG's extended C preprocessor is working right. In this example, SWIG 1.3.6 chokes on "//" in a #define with a syntax error. */ #define SLASHSLASH "//" /* This SWIG -*- c -*- interface is to test for some strange preprocessor bug. I get syntax errors unless I remove the apostrophe in the comment or the sharp-sign substitution. (The apostrophe seems to disable sharp-sign substitution.) */ %define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(SCM_TYPE) /* Don't check for NULL pointers (override checks). */ %typemap(argout, doc="($arg >)") int *VECTORLENOUTPUT { } %enddef TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(boolean) // preproc_3 #define Sum( A, B, \ C) \ A + B + C // preproc_4 %{ int hello0() { return 0; } int hello1() { return 1; } int hello2() { return 2; } int f(int min) { return min; } %} #define ARITH_RTYPE(A1, A2) A2 #define HELLO_TYPE(A, B) ARITH_RTYPE(A, ARITH_RTYPE(A,B)) // // These two work fine // int hello0(); ARITH_RTYPE(double,int) hello1(); // // This doesn't work with 1.3.17+ ( but it was ok in 1.3.16 ) // it gets expanded as (using -E) // // ARITH_RTYPE(double,int) hello2(); // HELLO_TYPE(double,int) hello2(); #define min(x,y) ((x) < (y)) ? (x) : (y) int f(int min); // preproc_5 %warnfilter(SWIGWARN_PARSE_REDEFINED) A5; // Ruby, wrong constant name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) a5; // Ruby, wrong constant name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) b5; // Ruby, wrong constant name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) c5; // Ruby, wrong constant name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) d5; // Ruby, wrong constant name // Various preprocessor bits of nastiness. /* Test argument name substitution */ #define foo(x,xx) #x #xx #define bar(x,xx) x + xx %constant char *a5 = foo(hello,world); %constant int b5 = bar(3,4); // Wrap your brain around this one ;-) %{ #define cat(x,y) x ## y %} #define cat(x,y) x ## y /* This should expand to cat(1,2); See K&R, p. 231 */ %constant int c5 = cat(cat(1,2),;) #define xcat(x,y) cat(x,y) /* This expands to 123. See K&R, p. 231 */ %constant int d5 = xcat(xcat(1,2),3); #define C1\ "hello" #define C2 #define C3 C2 #define ALONG_\ NAME 42 #define C4"Hello" // preproc_6 %warnfilter(SWIGWARN_PARSE_REDEFINED) A6; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) a6; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) b6; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) c6; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) d6; /* Ruby, wrong constant name */ #define add(a, b) (a + b) #define times(a, b) (a * b) #define op(x) x(1, 5) /* expand to (1 + 5) */ %constant int a6 = op(add); /* expand to (1 * 5) */ %constant int b6 = op(times); /* expand to ((1 + 5) * 5) */ %constant int c6 = times(add(1, 5), 5); /* expand to ((1 + 5) * 5) */ %constant int d6 = times(op(add), 5); /* This interface file tests whether SWIG's extended C preprocessor is working right. In this example, SWIG 1.3a5 reports missing macro arguments, which is bogus. */ %define MACRO1(C_TYPE, GETLENGTH) /* nothing */ %enddef %define MACRO2(XYZZY) MACRO1(XYZZY, 1) %enddef MACRO2(int) // cpp_macro_noarg. Tests to make sure macros with no arguments work right. #define MACROWITHARG(x) something(x) typedef int MACROWITHARG; /* This testcase tests for embedded defines and embedded %constants */ %inline %{ typedef struct EmbeddedDefines { int dummy; #define EMBEDDED_DEFINE 44 #ifdef SWIG %constant EMBEDDED_SWIG_CONSTANT = 55; #endif } EmbeddedDefines; %} /* This testcase tests operators for defines */ #define A1 1 + 2 #define A2 3 - 4 #define A3 5 * 6 #define A4 7 / 8 #define A5 9 >> 10 #define A6 11 << 12 #define A7 13 & 14 #define A8 15 | 16 #define A9 17 ^ 18 #define A10 19 && 20 #define A11 21 || 21 #define A12 ~22 #define A13 !23 #ifdef __cplusplus #define %mangle_macro(...) #@__VA_ARGS__ #define %mangle_macro_str(...) ##@__VA_ARGS__ %define my_func(...) inline const char* mangle_macro ## #@__VA_ARGS__ () { return %mangle_macro_str(__VA_ARGS__); } %enddef %inline { my_func(class Int) ; my_func(std::pair >*) ; } #endif #if defined (__cplusplus) \ || defined (_AIX) \ || defined (__DECC) \ || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ || defined (_MSC_VER) \ || defined (_WIN32) #define __GMP_HAVE_CONST 1 #define __GMP_HAVE_PROTOTYPES 1 #define __GMP_HAVE_TOKEN_PASTE 1 #else #define __GMP_HAVE_CONST 0 #define __GMP_HAVE_PROTOTYPES 0 #define __GMP_HAVE_TOKEN_PASTE 0 #endif /* empty TWO() macro is broken */ #define ONE 1 #define TWO() 2 #define THREE(FOO) 3 #define one ONE #define two TWO() #define three THREE(42) #if defined(one) /* hello */ #else /* chiao */ #endif; #ifdef SWIGCHICKEN /* define is a scheme keyword (and thus an invalid variable name), so SWIG warns about it */ %warnfilter(SWIGWARN_PARSE_KEYWORD) define; #endif #ifdef SWIGRUBY %rename(ddefined) defined; #endif #ifdef SWIGPHP %rename(endif_) endif; #endif %inline %{ const int endif = 1; const int define = 1; const int defined = 1; int test(int defined) { return defined; } %} #pragma SWIG nowarn=SWIGWARN_PP_CPP_WARNING #warning "Some warning" /* check that #error can be turned into a warning, but suppress the warning message for the test-suite! */ #pragma SWIG nowarn=SWIGWARN_PP_CPP_ERROR #pragma SWIG cpperraswarn=1 #error "Some error" #define MASK(shift, size) (((1 << (size)) - 1) <<(shift)) #define SOME_MASK_DEF (80*MASK(8, 10)) /* some constants */ #define BOLTZMANN (1.380658e-23) #define AVOGADRO (6.0221367e23) #define RGAS (BOLTZMANN*AVOGADRO) #define RGASX (BOLTZMANN*AVOGADRO*BOLTZMANN) %{ #define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \ struct TypeNameTraits { \ int val; \ } \ %} #define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \ struct TypeNameTraits { \ int val; \ } \ %inline %{ TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(int); %} %inline %{ int method(struct TypeNameTraits tnt) { return tnt.val; } %} swig-3.0.2/Examples/test-suite/d/0000775000175000017500000000000012343605122016452 5ustar williamwilliamswig-3.0.2/Examples/test-suite/d/nspace_extend_runme.2.d0000664000175000017500000000150612343605122023007 0ustar williamwilliammodule nspace_extend_runme; static import oi1c = nspace_extend.Outer.Inner1.Color; static import oi2c = nspace_extend.Outer.Inner2.Color; void main() { { // constructors and destructors scope color1 = new oi1c.Color(); scope color = new oi1c.Color(color1); // class methods color.colorInstanceMethod(20.0); oi1c.Color.colorStaticMethod(20.0); auto created = oi1c.Color.create(); } { // constructors and destructors scope color2 = new oi2c.Color(); scope color = new oi2c.Color(color2); // class methods color.colorInstanceMethod(20.0); oi2c.Color.colorStaticMethod(20.0); auto created = oi2c.Color.create(); // Same class different namespaces auto col1 = new oi1c.Color(); auto col2 = oi2c.Color.create(); col2.colors(col1, col1, col2, col2, col2); } } swig-3.0.2/Examples/test-suite/d/typemap_namespace_runme.2.d0000664000175000017500000000034012343605122023655 0ustar williamwilliammodule typemap_namespace_runme; import std.exception; import typemap_namespace.typemap_namespace; void main() { enforce(test1("hello") == "hello", "test1 failed"); enforce(test2("hello") == "hello", "test2 failed"); } swig-3.0.2/Examples/test-suite/d/varargs_runme.2.d0000664000175000017500000000045412343605122021635 0ustar williamwilliammodule varargs_runme; import std.exception; import varargs.varargs; import varargs.Foo; void main() { enforce(test("Hello") == "Hello", "Test 1 failed"); auto f = new Foo("Greetings"); enforce(f.str == "Greetings", "Test 2 failed"); enforce(f.test("Hello") == "Hello", "Test 3 failed"); } swig-3.0.2/Examples/test-suite/d/director_basic_runme.2.d0000664000175000017500000000236012343605122023142 0ustar williamwilliammodule director_basic_runme; import std.exception; import director_basic.A1; import director_basic.Bar; import director_basic.Foo; import director_basic.MyClass; void main() { auto a = new director_basic_MyFoo(); enforce(a.ping() == "director_basic_MyFoo::ping()", "a.ping()"); enforce(a.pong() == "Foo::pong();director_basic_MyFoo::ping()", "a.pong()"); auto b = new Foo(); enforce(b.ping() == "Foo::ping()", "b.ping()"); enforce(b.pong() == "Foo::pong();Foo::ping()", "b.pong()"); { scope a1 = new A1(1, false); } auto my = new MyOverriddenClass(); my.expectNull = true; enforce(MyClass.call_pmethod(my, null) is null, "null pointer conversion problem"); auto myBar = new Bar(); my.expectNull = false; auto myNewBar = MyClass.call_pmethod(my, myBar); enforce(myNewBar !is null, "non-null pointer conversion problem"); myNewBar.x = 10; } class director_basic_MyFoo : Foo { public override string ping() { return "director_basic_MyFoo::ping()"; } } class MyOverriddenClass : MyClass { public bool expectNull = false; public bool nonNullReceived = false; public override Bar pmethod(Bar b) { if (expectNull && (b !is null)) throw new Exception("null not received as expected"); return b; } } swig-3.0.2/Examples/test-suite/d/constover_runme.2.d0000664000175000017500000000110012343605122022177 0ustar williamwilliammodule constover_runme; import std.exception; import constover.constover; import constover.Foo; void main() { enforce(test("test") == "test", "test failed!"); enforce(test_pconst("test") == "test_pconst", "test_pconst failed!"); auto f = new Foo(); enforce(f.test("test") == "test", "member-test failed!"); enforce(f.test_pconst("test") == "test_pconst", "member-test_pconst failed!"); enforce(f.test_constm("test") == "test_constmethod", "member-test_constm failed!"); enforce(f.test_pconstm("test") == "test_pconstmethod", "member-test_pconstm failed!"); } swig-3.0.2/Examples/test-suite/d/typemap_namespace_runme.1.d0000664000175000017500000000037712343605122023666 0ustar williamwilliammodule typemap_namespace_runme; import typemap_namespace.typemap_namespace; void main() { if (test1("hello") != "hello") { throw new Exception("test1 failed"); } if (test2("hello") != "hello") { throw new Exception("test2 failed"); } } swig-3.0.2/Examples/test-suite/d/virtual_poly_runme.1.d0000664000175000017500000000113412343605122022714 0ustar williamwilliammodule virtual_poly_runme; import virtual_poly.NDouble; import virtual_poly.NInt; import virtual_poly.NNumber; void main() { // D supports covariant (polymorphic) return types, so this should work like // in C++. auto d = new NDouble(3.5); NDouble dc = d.copy(); if (d.get() != dc.get()) { throw new Exception("Test 1 failed."); } auto i = new NInt(2); NInt ic = i.copy(); if (i.get() != ic.get()) { throw new Exception("Test 2 failed."); } NNumber n = d; auto nd = cast(NDouble) n.copy(); if (nd.get() != d.get()) { throw new Exception("Test 3 failed."); } } swig-3.0.2/Examples/test-suite/d/nspace_runme.1.d0000664000175000017500000000544612343605122021446 0ustar williamwilliammodule nspace_runme; import nspace.nspace; static import nspace.NoNSpacePlease; static import nspace.Outer.namespce; static import nspace.Outer.Inner1.Channel; static import oi1c = nspace.Outer.Inner1.Color; static import nspace.Outer.Inner2.Channel; static import nspace.Outer.Inner2.Color; static import nspace.Outer.Inner3.Blue; static import nspace.Outer.Inner4.Blue; static import nspace.Outer.SomeClass; void main() { // constructors and destructors auto color1 = new oi1c.Color(); auto color = new oi1c.Color(color1); // class methods color.colorInstanceMethod(20.0); oi1c.Color.colorStaticMethod(20.0); auto created = oi1c.Color.create(); // class enums auto someClass = new nspace.Outer.SomeClass.SomeClass(); auto channel = someClass.GetInner1ColorChannel(); if (channel != oi1c.Color.Channel.Transmission) { throw new Exception("Transmission wrong"); } // class anonymous enums int val1 = oi1c.Color.ColorEnumVal1; int val2 = oi1c.Color.ColorEnumVal2; if (val1 != 0 || val2 != 0x22) { throw new Exception("ColorEnumVal wrong"); } // instance member variables color.instanceMemberVariable = 123; if (color.instanceMemberVariable != 123) { throw new Exception("instance member variable failed"); } // static member variables oi1c.Color.staticMemberVariable = 789; if (oi1c.Color.staticMemberVariable != 789) { throw new Exception("static member variable failed"); } if (oi1c.Color.staticConstMemberVariable != 222) { throw new Exception("static const member variable failed"); } if (oi1c.Color.staticConstEnumMemberVariable != oi1c.Color.Channel.Transmission) { throw new Exception("static const enum member variable failed"); } // check globals in a namespace don't get mangled with the nspace option nspace.nspace.namespaceFunction(color); nspace.nspace.namespaceVar = 111; if (nspace.nspace.namespaceVar != 111) { throw new Exception("global var failed"); } // Same class different namespaces auto col1 = new oi1c.Color(); auto col2 = nspace.Outer.Inner2.Color.Color.create(); col2.colors(col1, col1, col2, col2, col2); // global enums auto outerChannel1 = someClass.GetInner1Channel(); if (outerChannel1 != nspace.Outer.Inner1.Channel.Channel.Transmission1) { throw new Exception("Transmission1 wrong"); } auto outerChannel2 = someClass.GetInner2Channel(); if (outerChannel2 != nspace.Outer.Inner2.Channel.Channel.Transmission2) { throw new Exception("Transmission2 wrong"); } // turn feature off / ignoring auto ns = new nspace.Outer.namespce.namespce(); auto nons = new nspace.NoNSpacePlease.NoNSpacePlease(); // Derived class auto blue3 = new nspace.Outer.Inner3.Blue.Blue(); blue3.blueInstanceMethod(); auto blue4 = new nspace.Outer.Inner4.Blue.Blue(); blue4.blueInstanceMethod(); } swig-3.0.2/Examples/test-suite/d/li_std_string_runme.2.d0000664000175000017500000000555412343605122023042 0ustar williamwilliammodule li_std_string_runme; import std.exception; import li_std_string.li_std_string; import li_std_string.Structure; import li_std_string.SWIGTYPE_p_std__string; void main() { // Checking expected use of %typemap(in) std::string {} test_value("Fee"); // Checking expected result of %typemap(out) std::string {} enforce(test_value("Fi") == "Fi", "Test 1 failed"); // Verify type-checking for %typemap(in) std::string {} enforceThrows( (){ test_value(null); }, "Test 2 failed."); // Checking expected use of %typemap(in) const std::string & {} test_const_reference("Fo"); // Checking expected result of %typemap(out) const std::string& {} enforce(test_const_reference("Fum") == "Fum", "Test 3 failed"); // Verify type-checking for %typemap(in) const std::string & {} enforceThrows( (){ test_const_reference(null); }, "Test 4 failed."); // Input and output typemaps for pointers and non-const references to // std::string are *not* supported; the following tests confirm // that none of these cases are slipping through. SWIGTYPE_p_std__string stringPtr = null; stringPtr = test_pointer_out(); test_pointer(stringPtr); stringPtr = test_const_pointer_out(); test_const_pointer(stringPtr); stringPtr = test_reference_out(); test_reference(stringPtr); // Check throw exception specification try { test_throw(); throw new Exception("test 5 failed!"); } catch (Exception e) { enforce(e.msg == "test_throw message", "Test 5 string check: " ~ e.msg); } try { test_const_reference_throw(); throw new Exception("test 6 failed!"); } catch (Exception e) { enforce(e.msg == "test_const_reference_throw message", "Test 6 string check: " ~ e.msg); } // Global variables. const string s = "initial string"; enforce(GlobalString2 == "global string 2", "GlobalString2 test 1"); GlobalString2 = s; enforce(GlobalString2 == s, "GlobalString2 test 2"); enforce(ConstGlobalString == "const global string", "ConstGlobalString test"); // Member variables. auto myStructure = new Structure(); enforce(myStructure.MemberString2 == "member string 2", "MemberString2 test 1"); myStructure.MemberString2 = s; enforce(myStructure.MemberString2 == s, "MemberString2 test 2"); enforce(myStructure.ConstMemberString == "const member string", "ConstMemberString test"); // Static member variables. enforce(Structure.StaticMemberString2 == "static member string 2", "StaticMemberString2 test 1"); Structure.StaticMemberString2 = s; enforce(Structure.StaticMemberString2 == s, "StaticMemberString2 test 2"); enforce(Structure.ConstStaticMemberString == "const static member string", "ConstStaticMemberString test"); } private void enforceThrows(void delegate() dg, string errorMessage) { bool hasThrown; try { dg(); } catch (Exception) { hasThrown = true; } finally { enforce(hasThrown, errorMessage); } } swig-3.0.2/Examples/test-suite/d/catches_runme.1.d0000664000175000017500000000176512343605122021607 0ustar williamwilliammodule catches_runme; import catches.catches; void main() { test({ test_catches(1); }, "C++ int exception thrown, value: 1"); test({ test_catches(2); }, "two"); test({ test_catches(3); }, "C++ ThreeException const & exception thrown"); test({ test_exception_specification(1); }, "C++ int exception thrown, value: 1"); test({ test_exception_specification(2); }, "unknown exception"); test({ test_exception_specification(3); }, "unknown exception"); test({ test_catches_all(1); }, "unknown exception"); } void test(void delegate() command, char[] expectedMessage) { bool didntThrow; try { command(); didntThrow = true; } catch (Exception e) { if (e.msg != expectedMessage) { throw new Exception("Failed to propagate C++ exception. Expected '" ~ expectedMessage ~ "', but received '" ~ e.msg ~ "'."); } } if (didntThrow) { throw new Exception("Failed to propagate C++ exception. Expected '" ~ expectedMessage ~ "', but no exception was thrown."); } } swig-3.0.2/Examples/test-suite/d/director_string_runme.2.d0000664000175000017500000000170412343605122023370 0ustar williamwilliammodule director_string_runme; import std.conv; import std.exception; import director_string.A; void main() { auto c = new director_string_A("hi"); for (int i=0; i<3; ++i) { auto s = c.call_get(i); auto expected = to!string(i); enforce(s == expected, "director_string_A.get(" ~ expected ~ ") failed. Got:" ~ s); } auto b = new director_string_B("hello"); enforce(b.call_get_first() == "director_string_B.get_first", "call_get_first() failed"); enforce(b.call_get(0) == "director_string_B.get: hello", "get(0) failed"); } class director_string_B : A { public: this(string first) { super(first); } override string get_first() const { return "director_string_B.get_first"; } override string get(int n) const { return "director_string_B.get: " ~ super.get(n); } } class director_string_A : A { public: this(string first) { super(first); } override string get(int n) const { return to!string(n); } } swig-3.0.2/Examples/test-suite/d/README0000664000175000017500000000035212343605122017332 0ustar williamwilliamD language module testsuite --------------------------- Please see ../README for the common readme file. By default the D1 version is built, set D_VERSION=2 (in the environment or at the make command line) to run it for D2 instead. swig-3.0.2/Examples/test-suite/d/overload_complicated_runme.1.d0000664000175000017500000000226712343605122024352 0ustar williamwilliammodule overload_complicated_runme; import overload_complicated; void main() { SWIGTYPE_p_int pInt = null; // Check the correct constructors are available Pop p = new Pop(pInt); p = new Pop(pInt, false); // Check overloaded in const only and pointers/references which target languages cannot disambiguate if (p.hip(false) != 701) throw new Exception("Test 1 failed"); if (p.hip(pInt) != 702) throw new Exception("Test 2 failed"); // Reverse the order for the above if (p.hop(pInt) != 805) throw new Exception("Test 3 failed"); if (p.hop(false) != 801) throw new Exception("Test 4 failed"); // Few more variations and order shuffled if (p.pop(false) != 901) throw new Exception("Test 5 failed"); if (p.pop(pInt) != 902) throw new Exception("Test 6 failed"); if (p.pop() != 905) throw new Exception("Test 7 failed"); // Overload on const only if (p.bop(pInt) != 1001) throw new Exception("Test 8 failed"); if (p.bip(pInt) != 2001) throw new Exception("Test 9 failed"); // Globals if (muzak(false) != 3001) throw new Exception("Test 10 failed"); if (muzak(pInt) != 3002) throw new Exception("Test 11 failed"); } swig-3.0.2/Examples/test-suite/d/li_std_except_runme.1.d0000664000175000017500000000216412343605122023015 0ustar williamwilliammodule li_std_except_runme; import tango.core.Exception; import tango.io.Console; import li_std_except.Test; void main() { with (new Test()) { mixin(test("Exception", "throw_bad_exception")); mixin(test("Exception", "throw_domain_error")); mixin(test("Exception", "throw_exception")); mixin(test("IllegalArgumentException", "throw_invalid_argument")); mixin(test("NoSuchElementException", "throw_length_error")); mixin(test("Exception", "throw_logic_error")); mixin(test("NoSuchElementException", "throw_out_of_range")); mixin(test("Exception", "throw_overflow_error")); mixin(test("Exception", "throw_range_error")); mixin(test("Exception", "throw_runtime_error")); mixin(test("Exception", "throw_underflow_error")); } } char[] test(char[] e, char[] f) { return "if (!works!(" ~ e ~ ")(&" ~ f ~ ")) {\n" ~ "throw new Exception(\"" ~ f ~ " failed\");\n" ~ "}"; } bool works(alias E, F)(F f) { try { try { f(); } catch(E) { return true; } } catch(Exception e) { Cerr( "Received wrong exception: " ~ e.classinfo.name ).newline; } return false; } swig-3.0.2/Examples/test-suite/d/aggregate_runme.1.d0000664000175000017500000000117212343605122022113 0ustar williamwilliammodule aggregate_runme; import aggregate.aggregate; void main() { // Confirm that move() returns correct results under normal use. int result = move(UP); if (result != UP) throw new Exception("UP failed"); result = move(DOWN); if (result != DOWN) throw new Exception("DOWN failed"); result = move(LEFT); if (result != LEFT) throw new Exception("LEFT failed"); result = move(RIGHT); if (result != RIGHT) throw new Exception("RIGHT failed"); // Confirm that move() raises an exception when the contract is violated. try { move(0); throw new Exception("0 test failed"); } catch (Exception e) {} } swig-3.0.2/Examples/test-suite/d/preproc_constants_c_runme.2.d0000664000175000017500000000575412343605122024250 0ustar williamwilliammodule preproc_constants_c_runme; import core.stdc.config; import preproc_constants_c.preproc_constants_c; // Same as preproc_constants.i testcase, but bool types are int instead. void main() { static assert(is(int == typeof(CONST_INT1()))); static assert(is(int == typeof(CONST_INT2()))); static assert(is(uint == typeof(CONST_UINT1()))); static assert(is(uint == typeof(CONST_UINT2()))); static assert(is(uint == typeof(CONST_UINT3()))); static assert(is(uint == typeof(CONST_UINT4()))); static assert(is(c_long == typeof(CONST_LONG1()))); static assert(is(c_long == typeof(CONST_LONG2()))); static assert(is(c_long == typeof(CONST_LONG3()))); static assert(is(c_long == typeof(CONST_LONG4()))); static assert(is(long == typeof(CONST_LLONG1()))); static assert(is(long == typeof(CONST_LLONG2()))); static assert(is(long == typeof(CONST_LLONG3()))); static assert(is(long == typeof(CONST_LLONG4()))); static assert(is(ulong == typeof(CONST_ULLONG1()))); static assert(is(ulong == typeof(CONST_ULLONG2()))); static assert(is(ulong == typeof(CONST_ULLONG3()))); static assert(is(ulong == typeof(CONST_ULLONG4()))); static assert(is(double == typeof(CONST_DOUBLE1()))); static assert(is(double == typeof(CONST_DOUBLE2()))); static assert(is(double == typeof(CONST_DOUBLE3()))); static assert(is(double == typeof(CONST_DOUBLE4()))); static assert(is(double == typeof(CONST_DOUBLE5()))); static assert(is(double == typeof(CONST_DOUBLE6()))); static assert(is(int == typeof(CONST_BOOL1()))); static assert(is(int == typeof(CONST_BOOL2()))); static assert(is(char == typeof(CONST_CHAR()))); static assert(is(string == typeof(CONST_STRING1()))); static assert(is(string == typeof(CONST_STRING2()))); static assert(is(int == typeof(INT_AND_BOOL()))); // static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); static assert(is(c_long == typeof(INT_AND_LONG()))); static assert(is(c_ulong == typeof(INT_AND_ULONG()))); static assert(is(long == typeof(INT_AND_LLONG()))); static assert(is(ulong == typeof(INT_AND_ULLONG()))); static assert(is(int == typeof(BOOL_AND_BOOL()))); static assert(is(int == typeof(EXPR_MULTIPLY()))); static assert(is(int == typeof(EXPR_DIVIDE()))); static assert(is(int == typeof(EXPR_PLUS()))); static assert(is(int == typeof(EXPR_MINUS()))); static assert(is(int == typeof(EXPR_LSHIFT()))); static assert(is(int == typeof(EXPR_RSHIFT()))); static assert(is(int == typeof(EXPR_LTE()))); static assert(is(int == typeof(EXPR_GTE()))); static assert(is(int == typeof(EXPR_INEQUALITY()))); static assert(is(int == typeof(EXPR_EQUALITY()))); static assert(is(int == typeof(EXPR_AND()))); static assert(is(int == typeof(EXPR_XOR()))); static assert(is(int == typeof(EXPR_OR()))); static assert(is(int == typeof(EXPR_LAND()))); static assert(is(int == typeof(EXPR_LOR()))); static assert(is(double == typeof(EXPR_CONDITIONAL()))); } swig-3.0.2/Examples/test-suite/d/special_variable_macros_runme.1.d0000664000175000017500000000200312343605122025010 0ustar williamwilliammodule special_variable_macros_runme; import special_variable_macros.special_variable_macros; import special_variable_macros.Name; import special_variable_macros.NewName; import special_variable_macros.PairIntBool; void main() { auto name = new Name(); if (testFred(name) != "none") { throw new Exception("test failed"); } if (testJack(name) != "$specialname") { throw new Exception("test failed"); } if (testJill(name) != "jilly") { throw new Exception("test failed"); } if (testMary(name) != "SWIGTYPE_p_NameWrap") { throw new Exception("test failed"); } if (testJames(name) != "SWIGTYPE_Name") { throw new Exception("test failed"); } if (testJim(name) != "multiname num") { throw new Exception("test failed"); } if (testJohn(new PairIntBool(10, false)) != 123) { throw new Exception("test failed"); } auto newName = NewName.factory("factoryname"); if (newName.getStoredName().getName() != "factoryname") { throw new Exception("test failed"); } } swig-3.0.2/Examples/test-suite/d/director_ignore_runme.1.d0000664000175000017500000000256012343605122023345 0ustar williamwilliammodule director_ignore_runme; import director_ignore.DIgnores; import director_ignore.DAbstractIgnores; void main() { // Just check the classes can be instantiated and other methods work as expected auto a = new DIgnoresDerived(); if (a.Triple(5) != 15) throw new Exception("Triple failed"); auto b = new DAbstractIgnoresDerived(); if (b.Quadruple(5) != 20) throw new Exception("Quadruple failed"); } class DIgnoresDerived : DIgnores { public: // These will give a warning if the %ignore is not working int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedMethod(int n, int xoffset) { return 0; } int OverloadedMethod(int n) { return 0; } int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedProtectedMethod(int n, int xoffset) { return 0; } int OverloadedProtectedMethod(int n) { return 0; } } class DAbstractIgnoresDerived : DAbstractIgnores { public: // These will give a warning if the %ignore is not working int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedMethod(int n, int xoffset) { return 0; } int OverloadedMethod(int n) { return 0; } int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedProtectedMethod(int n, int xoffset) { return 0; } int OverloadedProtectedMethod(int n) { return 0; } } swig-3.0.2/Examples/test-suite/d/overload_complicated_runme.2.d0000664000175000017500000000203212343605122024341 0ustar williamwilliammodule overload_complicated_runme; import std.exception; import overload_complicated.overload_complicated; import overload_complicated.Pop; void main() { int* pInt = new int; // Check the correct constructors are available auto p = new Pop(pInt); p = new Pop(pInt, false); // Check overloaded in const only and pointers/references which target languages cannot disambiguate enforce(p.hip(false) == 701, "Test 1 failed"); enforce(p.hip(pInt) == 702, "Test 2 failed"); // Reverse the order for the above enforce(p.hop(pInt) == 805, "Test 3 failed"); enforce(p.hop(false) == 801, "Test 4 failed"); // Few more variations and order shuffled enforce(p.pop(false) == 901, "Test 5 failed"); enforce(p.pop(pInt) == 902, "Test 6 failed"); enforce(p.pop() == 905, "Test 7 failed"); // Overload on const only enforce(p.bop(pInt) == 1001, "Test 8 failed"); enforce(p.bip(pInt) == 2001, "Test 9 failed"); // Globals enforce(muzak(false) == 3001, "Test 10 failed"); enforce(muzak(pInt) == 3002, "Test 11 failed"); } swig-3.0.2/Examples/test-suite/d/sneaky1_runme.1.d0000664000175000017500000000057012343605122021541 0ustar williamwilliammodule sneaky1_runme; import sneaky1.sneaky1; void main() { if (add(30, 2) != 32) { throw new Exception("add test failed"); } if (subtract(20, 2) != 18) { throw new Exception("subtract test failed"); } if (mul(20, 2) != 40) { throw new Exception("mul test failed"); } if (divide(20, 2) != 10) { throw new Exception("div test failed"); } } swig-3.0.2/Examples/test-suite/d/director_string_runme.1.d0000664000175000017500000000177712343605122023401 0ustar williamwilliammodule director_string_runme; import Integer = tango.text.convert.Integer; import director_string.A; void main() { char[] s; auto c = new director_string_A("hi"); for (int i=0; i<3; ++i) { s = c.call_get(i); if (s != Integer.toString(i)) throw new Exception("director_string_A.get(" ~ Integer.toString(i) ~ ") failed. Got:" ~ s); } auto b = new director_string_B("hello"); s = b.call_get_first(); if (s != "director_string_B.get_first") throw new Exception("call_get_first() failed"); s = b.call_get(0); if (s != "director_string_B.get: hello") throw new Exception("get(0) failed"); } class director_string_B : A { public: this(char[] first) { super(first); } override char[] get_first() { return "director_string_B.get_first"; } override char[] get(int n) { return "director_string_B.get: " ~ super.get(n); } } class director_string_A : A { public: this(char[] first) { super(first); } override char[] get(int n) { return Integer.toString(n); } } swig-3.0.2/Examples/test-suite/d/director_primitives_runme.1.d0000664000175000017500000000752612343605122024264 0ustar williamwilliam/** * This test program shows a D class DDerived inheriting from Base. * * Three types of classes are created and the virtual methods called to * demonstrate: * - Wide variety of primitive types * - Calling methods with zero, one or more parameters * - Director methods that are not overridden in D * - Director classes that are not overridden at all in D, i.e. non-director * behaviour is as expected for director classes * - Inheritance hierarchy using director methods * - Return types working as well as parameters * * The Caller class is a tester class which calls the virtual functions from C++. */ module director_primitives_runme; import tango.io.Stdout; import director_primitives.director_primitives; import director_primitives.Base; import director_primitives.Caller; import director_primitives.Derived; import director_primitives.HShadowMode; void main() { PrintDebug = false; if (PrintDebug) Stdout("------------ Start ------------ ").newline; Caller myCaller = new Caller(); // Test C++ base class. { scope myBase = new Base(100.0); makeCalls(myCaller, myBase); } if (PrintDebug) Stdout("--------------------------------").newline; // Test vanilla C++ wrapped derived class. { scope Base myBase = new Derived(100.0); makeCalls(myCaller, myBase); } if (PrintDebug) Stdout("--------------------------------").newline; // Test director/D derived class. { scope Base myBase = new DDerived(300.0); makeCalls(myCaller, myBase); } if (PrintDebug) Stdout("------------ Finish ------------ ").newline; } void makeCalls(Caller myCaller, Base myBase) { myCaller.set(myBase); myCaller.NoParmsMethodCall(); if (myCaller.BoolMethodCall(true) != true) throw new Exception("failed"); if (myCaller.BoolMethodCall(false) != false) throw new Exception("failed"); if (myCaller.IntMethodCall(-123) != -123) throw new Exception("failed"); if (myCaller.UIntMethodCall(123) != 123) throw new Exception("failed"); if (myCaller.FloatMethodCall(-123.456f) != -123.456f) throw new Exception("failed"); if (myCaller.CharPtrMethodCall("test string") != "test string") throw new Exception("failed"); if (myCaller.ConstCharPtrMethodCall("another string") != "another string") throw new Exception("failed"); if (myCaller.EnumMethodCall(HShadowMode.HShadowHard) != HShadowMode.HShadowHard) throw new Exception("failed"); myCaller.ManyParmsMethodCall(true, -123, 123, 123.456f, "test string", "another string", HShadowMode.HShadowHard); myCaller.NotOverriddenMethodCall(); myCaller.reset(); } class DDerived : Base { public: this(double dd) { super(dd); } override void NoParmsMethod() { if (PrintDebug) Stdout("DDerived - NoParmsMethod()").newline; } override bool BoolMethod(bool x) { if (PrintDebug) Stdout.formatln("DDerived - BoolMethod({0})", x); return x; } override int IntMethod(int x) { if (PrintDebug) Stdout.formatln("DDerived - IntMethod({0})", x); return x; } override uint UIntMethod(uint x) { if (PrintDebug) Stdout.formatln("DDerived - UIntMethod({0})", x); return x; } override float FloatMethod(float x) { if (PrintDebug) Stdout.formatln("DDerived - FloatMethod({0})", x); return x; } override char[] CharPtrMethod(char[] x) { if (PrintDebug) Stdout.formatln("DDerived - CharPtrMethod({0})", x); return x; } override char[] ConstCharPtrMethod(char[] x) { if (PrintDebug) Stdout.formatln("DDerived - ConstCharPtrMethod({0})", x); return x; } override HShadowMode EnumMethod(HShadowMode x) { if (PrintDebug) Stdout.formatln("DDerived - EnumMethod({0})", x); return x; } override void ManyParmsMethod(bool b, int i, uint u, float f, char[] c, char[] cc, HShadowMode h) { if (PrintDebug) Stdout.formatln("DDerived - ManyParmsMethod({0}, {1}, {2}, {3:d3}, {4}, {5}, {6})", b, i, u, f, c, cc, h); } } swig-3.0.2/Examples/test-suite/d/allprotected_runme.1.d0000664000175000017500000000310112343605122022641 0ustar williamwilliammodule allprotected_runme; import allprotected.Klass; import allprotected.ProtectedBase; void main() { auto mpb = new MyProtectedBase("MyProtectedBase"); mpb.accessProtected(); } class MyProtectedBase : ProtectedBase { public: this(char[] name) { super(name); } void accessProtected() { char[] s = virtualMethod(); if (s != "ProtectedBase") throw new Exception("Failed"); Klass k = instanceMethod(new Klass("xyz")); if (k.getName() != "xyz") throw new Exception("Failed"); k = instanceOverloaded(new Klass("xyz")); if (k.getName() != "xyz") throw new Exception("Failed"); k = instanceOverloaded(new Klass("xyz"), "abc"); if (k.getName() != "abc") throw new Exception("Failed"); k = staticMethod(new Klass("abc")); if (k.getName() != "abc") throw new Exception("Failed"); k = staticOverloaded(new Klass("xyz")); if (k.getName() != "xyz") throw new Exception("Failed"); k = staticOverloaded(new Klass("xyz"), "abc"); if (k.getName() != "abc") throw new Exception("Failed"); instanceMemberVariable = 30; int i = instanceMemberVariable; if (i != 30) throw new Exception("Failed"); staticMemberVariable = 40; i = staticMemberVariable; if (i != 40) throw new Exception("Failed"); i = staticConstMemberVariable; if (i != 20) throw new Exception("Failed"); anEnum = ProtectedBase.AnEnum.EnumVal1; ProtectedBase.AnEnum ae = anEnum; if (ae != ProtectedBase.AnEnum.EnumVal1) throw new Exception("Failed"); } } swig-3.0.2/Examples/test-suite/d/sizet_runme.1.d0000664000175000017500000000032012343605122021315 0ustar williamwilliammodule sizet_runme; import sizet.sizet; void main() { size_t s = 2000; s = test1(s+1); s = test2(s+1); s = test3(s+1); s = test4(s+1); if (s != 2004) { throw new Exception("failed"); } } swig-3.0.2/Examples/test-suite/d/director_primitives_runme.2.d0000664000175000017500000000717012343605122024260 0ustar williamwilliam/** * This test program shows a D class DDerived inheriting from Base. * * Three types of classes are created and the virtual methods called to * demonstrate: * - Wide variety of primitive types * - Calling methods with zero, one or more parameters * - Director methods that are not overridden in D * - Director classes that are not overridden at all in D, i.e. non-director * behaviour is as expected for director classes * - Inheritance hierarchy using director methods * - Return types working as well as parameters * * The Caller class is a tester class which calls the virtual functions from C++. */ module director_primitives_runme; import std.exception; import std.stdio; import director_primitives.director_primitives; import director_primitives.Base; import director_primitives.Caller; import director_primitives.Derived; import director_primitives.HShadowMode; void main() { PrintDebug = false; if (PrintDebug) writeln("------------ Start ------------ "); auto myCaller = new Caller(); // Test C++ base class. { scope myBase = new Base(100.0); makeCalls(myCaller, myBase); } if (PrintDebug) writeln("--------------------------------"); // Test vanilla C++ wrapped derived class. { scope Base myBase = new Derived(100.0); makeCalls(myCaller, myBase); } if (PrintDebug) writeln("--------------------------------"); // Test director/D derived class. { scope Base myBase = new DDerived(300.0); makeCalls(myCaller, myBase); } if (PrintDebug) writeln("------------ Finish ------------ "); } void makeCalls(Caller myCaller, Base myBase) { myCaller.set(myBase); myCaller.NoParmsMethodCall(); enforce(myCaller.BoolMethodCall(true) == true, "failed"); enforce(myCaller.BoolMethodCall(false) == false, "failed"); enforce(myCaller.IntMethodCall(-123) == -123, "failed"); enforce(myCaller.UIntMethodCall(123) == 123, "failed"); enforce(myCaller.FloatMethodCall(-123.456f) == -123.456f, "failed"); enforce(myCaller.CharPtrMethodCall("test string") == "test string", "failed"); enforce(myCaller.ConstCharPtrMethodCall("another string") == "another string", "failed"); enforce(myCaller.EnumMethodCall(HShadowMode.HShadowHard) == HShadowMode.HShadowHard, "failed"); myCaller.ManyParmsMethodCall(true, -123, 123, 123.456f, "test string", "another string", HShadowMode.HShadowHard); myCaller.NotOverriddenMethodCall(); myCaller.reset(); } class DDerived : Base { public: this(double dd) { super(dd); } override void NoParmsMethod() { if (PrintDebug) writeln("DDerived - NoParmsMethod()"); } override bool BoolMethod(bool x) { if (PrintDebug) writefln("DDerived - BoolMethod(%s)", x); return x; } override int IntMethod(int x) { if (PrintDebug) writefln("DDerived - IntMethod(%s)", x); return x; } override uint UIntMethod(uint x) { if (PrintDebug) writefln("DDerived - UIntMethod(%s)", x); return x; } override float FloatMethod(float x) { if (PrintDebug) writefln("DDerived - FloatMethod(%s)", x); return x; } override string CharPtrMethod(string x) { if (PrintDebug) writefln("DDerived - CharPtrMethod(%s)", x); return x; } override string ConstCharPtrMethod(string x) { if (PrintDebug) writefln("DDerived - ConstCharPtrMethod(%s)", x); return x; } override HShadowMode EnumMethod(HShadowMode x) { if (PrintDebug) writefln("DDerived - EnumMethod(%s)", x); return x; } override void ManyParmsMethod(bool b, int i, uint u, float f, string c, string cc, HShadowMode h) { if (PrintDebug) writefln("DDerived - ManyParmsMethod(%s, %s, %s, %s, %s, %s, %s)", b, i, u, f, c, cc, h); } } swig-3.0.2/Examples/test-suite/d/default_constructor_runme.1.d0000664000175000017500000000123112343605122024252 0ustar williamwilliammodule default_constructor_runme; import default_constructor.FFF; import default_constructor.G; void main() { // Protected destructor test. try { { scope g = new G(); } throw new Exception("Protected destructor exception should have been thrown"); } catch (Exception e) { if (e.msg != "C++ destructor does not have public access") { throw e; } } // Private destructor test. try { { scope f = new FFF(); } throw new Exception("Private destructor exception should have been thrown"); } catch (Exception e) { if (e.msg != "C++ destructor does not have public access") { throw e; } } } swig-3.0.2/Examples/test-suite/d/director_protected_runme.2.d0000664000175000017500000000170312343605122024052 0ustar williamwilliammodule director_protected_runme; import std.exception; import director_protected.Foo; import director_protected.Bar; void main() { Bar b = new Bar(); Foo f = b.create(); auto fb = new FooBar(); scope fb2 = new FooBar2(); enforce(fb.used() == "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used" ~ " - " ~ fb.used()); enforce(fb2.used() == "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used"); enforce(b.pong() == "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong"); enforce(f.pong() == "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong"); enforce(fb.pong() == "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong"); } class FooBar : Bar { protected: override string ping() { return "FooBar::ping();"; } } class FooBar2 : Bar { protected: override string ping() { return "FooBar2::ping();"; } override string pang() { return "FooBar2::pang();"; } } swig-3.0.2/Examples/test-suite/d/constover_runme.1.d0000664000175000017500000000134312343605122022207 0ustar williamwilliammodule constover_runme; import constover.constover; import constover.Foo; void main() { char[] p = test("test"); if (p != "test") throw new Exception("test failed!"); p = test_pconst("test"); if (p != "test_pconst") throw new Exception("test_pconst failed!"); auto f = new Foo(); p = f.test("test"); if (p != "test") throw new Exception("member-test failed!"); p = f.test_pconst("test"); if (p != "test_pconst") throw new Exception("member-test_pconst failed!"); p = f.test_constm("test"); if (p != "test_constmethod") throw new Exception("member-test_constm failed!"); p = f.test_pconstm("test"); if (p != "test_pconstmethod") throw new Exception("member-test_pconstm failed!"); } swig-3.0.2/Examples/test-suite/d/typemap_out_optimal_runme.2.d0000664000175000017500000000020212343605122024252 0ustar williamwilliammodule typemap_out_optimal_runme; import typemap_out_optimal.XX; void main() { XX x; XX.trace = false; x = XX.create(); } swig-3.0.2/Examples/test-suite/d/allprotected_runme.2.d0000664000175000017500000000302312343605122022645 0ustar williamwilliammodule allprotected_runme; import allprotected.Klass; import allprotected.ProtectedBase; import std.conv : text; import std.exception : enforce; void main() { auto mpb = new MyProtectedBase("MyProtectedBase"); mpb.accessProtected(); } class MyProtectedBase : ProtectedBase { public: this(string name) { super(name); } void accessProtected() { string s = virtualMethod(); enforce(s == "ProtectedBase", "Failed, got '" ~ s ~ "'"); Klass k; void expect(string name) { auto kName = k.getName(); enforce(kName == name, "Failed, expected '" ~ name ~ "' instead of '" ~ kName ~ "'."); } k = instanceMethod(new Klass("xyz")); expect("xyz"); k = instanceOverloaded(new Klass("xyz")); expect("xyz"); k = instanceOverloaded(new Klass("xyz"), "abc"); expect("abc"); k = staticMethod(new Klass("abc")); expect("abc"); k = staticOverloaded(new Klass("xyz")); expect("xyz"); k = staticOverloaded(new Klass("xyz"), "abc"); expect("abc"); instanceMemberVariable = 30; int i = instanceMemberVariable; enforce(i == 30, text("Failed, expected ", 30, "instead of ", i)); staticMemberVariable = 40; i = staticMemberVariable; enforce(i == 40, text("Failed, expected ", 40, "instead of ", i)); i = staticConstMemberVariable; enforce(i == 20, text("Failed, expected ", 20, "instead of ", i)); anEnum = ProtectedBase.AnEnum.EnumVal1; ProtectedBase.AnEnum ae = anEnum; enforce(ae == ProtectedBase.AnEnum.EnumVal1); } } swig-3.0.2/Examples/test-suite/d/member_pointer_runme.2.d0000664000175000017500000000217312343605122023177 0ustar williamwilliammodule member_pointer_runme; import std.conv; import std.exception; import member_pointer.member_pointer; import member_pointer.Square; import member_pointer.SWIGTYPE_m_Shape__f_void__double; void main() { auto s = new Square(10); // Do some calculations auto area_pt = areapt(); auto perim_pt = perimeterpt(); check("Square area", 100.0, do_op(s, area_pt)); check("Square perim", 40.0, do_op(s, perim_pt)); SWIGTYPE_m_Shape__f_void__double memberPtr = null; memberPtr = areavar; memberPtr = perimetervar; // Try the variables check("Square area", 100.0, do_op(s, areavar)); check("Square perim", 40.0, do_op(s, perimetervar)); // Modify one of the variables areavar = perim_pt; check("Square perimeter", 40.0, do_op(s,areavar)); // Try the constants memberPtr = AREAPT; memberPtr = PERIMPT; memberPtr = NULLPT; check("Square area", 100.0, do_op(s, AREAPT)); check("Square perim", 40.0, do_op(s, PERIMPT)); } void check(string what, double expected, double actual) { enforce(expected == actual, "Failed: " ~ what ~ ": expected " ~ to!string(expected) ~ ", but got " ~ to!string(actual)); } swig-3.0.2/Examples/test-suite/d/sizet_runme.2.d0000664000175000017500000000031412343605122021321 0ustar williamwilliammodule sizet_runme; import std.exception; import sizet.sizet; void main() { size_t s = 2000; s = test1(s+1); s = test2(s+1); s = test3(s+1); s = test4(s+1); enforce(s == 2004, "failed"); } swig-3.0.2/Examples/test-suite/d/default_args_runme.1.d0000664000175000017500000000727612343605122022640 0ustar williamwilliammodule default_args_runme; import default_args.default_args; import default_args.ConstMethods; import default_args.EnumClass; import default_args.Except; import default_args.Foo; import default_args.Klass; import default_args.Statics; import default_args.Tricky; void main() { if (anonymous() != 7771) throw new Exception("anonymous (1) failed"); if (anonymous(1234) != 1234) throw new Exception("anonymous (2) failed"); if (booltest() != true) throw new Exception("booltest (1) failed"); if (booltest(true) != true) throw new Exception("booltest (2) failed"); if (booltest(false) != false) throw new Exception("booltest (3) failed"); auto ec = new EnumClass(); if (ec.blah() != true) throw new Exception("EnumClass failed"); if (casts1() != null) throw new Exception("casts1 failed"); if (casts2() != "Hello") throw new Exception("casts2 failed"); if (casts1("Ciao") != "Ciao") throw new Exception("casts1 not default failed"); if (chartest1() != 'x') throw new Exception("chartest1 failed"); if (chartest2() != '\0') throw new Exception("chartest2 failed"); if (chartest1('y') != 'y') throw new Exception("chartest1 not default failed"); if (chartest1('y') != 'y') throw new Exception("chartest1 not default failed"); if (reftest1() != 42) throw new Exception("reftest1 failed"); if (reftest1(400) != 400) throw new Exception("reftest1 not default failed"); if (reftest2() != "hello") throw new Exception("reftest2 failed"); // rename auto foo = new Foo(); foo.newname(); foo.newname(10); foo.renamed3arg(10, 10.0); foo.renamed2arg(10); foo.renamed1arg(); // exception specifications testException( { exceptionspec(); }, "exceptionspec 1" ); testException( { exceptionspec(-1); }, "exceptionspec 2" ); testException( { exceptionspec(100); }, "exceptionspec 3" ); auto ex = new Except(false); testException( { ex.exspec(); }, "exspec 1" ); testException( { ex.exspec(-1); }, "exspec 2" ); testException( { ex.exspec(100); }, "exspec 3" ); testException( { ex = new Except(true); }, "Except constructor 1" ); testException( { ex = new Except(true, -2); }, "Except constructor 2" ); // Default parameters in static class methods if (Statics.staticmethod() != 10+20+30) throw new Exception("staticmethod 1 failed"); if (Statics.staticmethod(100) != 100+20+30) throw new Exception("staticmethod 2 failed"); if (Statics.staticmethod(100,200,300) != 100+200+300) throw new Exception("staticmethod 3 failed"); auto tricky = new Tricky(); if (tricky.privatedefault() != 200) throw new Exception("privatedefault failed"); if (tricky.protectedint() != 2000) throw new Exception("protectedint failed"); if (tricky.protecteddouble() != 987.654) throw new Exception("protecteddouble failed"); if (tricky.functiondefault() != 500) throw new Exception("functiondefault failed"); if (tricky.contrived() != 'X') throw new Exception("contrived failed"); if (constructorcall().val != -1) throw new Exception("constructorcall test 1 failed"); if (constructorcall(new Klass(2222)).val != 2222) throw new Exception("constructorcall test 2 failed"); if (constructorcall(new Klass()).val != -1) throw new Exception("constructorcall test 3 failed"); // const methods auto cm = new ConstMethods(); if (cm.coo() != 20) throw new Exception("coo test 1 failed"); if (cm.coo(1.0) != 20) throw new Exception("coo test 2 failed"); } void testException(void delegate() command, char[] testName) { bool didntThrow; try { command(); didntThrow = true; } catch (Exception e) {} if (didntThrow) { throw new Exception(testName ~ " failed"); } } swig-3.0.2/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.1.d0000664000175000017500000000075412343605122025240 0ustar williamwilliammodule li_boost_shared_ptr_runme_bits; import li_boost_shared_ptr_bits.li_boost_shared_ptr_bits; import li_boost_shared_ptr_bits.HiddenDestructor; import li_boost_shared_ptr_bits.IntHolder; import li_boost_shared_ptr_bits.VectorIntHolder; void main() { auto v = new VectorIntHolder(); v ~= new IntHolder(11); v ~= new IntHolder(22); v ~= new IntHolder(33); if (sum(v) != 66) { throw new Exception("sum is wrong"); } { scope hidden = HiddenDestructor.create(); } } swig-3.0.2/Examples/test-suite/d/overload_template_runme.1.d0000664000175000017500000000740212343605122023675 0ustar williamwilliammodule overload_template_runme; import overload_template.overload_template; import overload_template.Klass; void main() { int f = foo(); f += maximum(3,4); double b = maximum(3.4,5.2); b++; // warning suppression // mix 1 if (mix1("hi") != 101) throw new Exception ("mix1(const char*)"); if (mix1(1.0, 1.0) != 102) throw new Exception ("mix1(double, const double &)"); if (mix1(1.0) != 103) throw new Exception ("mix1(double)"); // mix 2 if (mix2("hi") != 101) throw new Exception ("mix2(const char*)"); if (mix2(1.0, 1.0) != 102) throw new Exception ("mix2(double, const double &)"); if (mix2(1.0) != 103) throw new Exception ("mix2(double)"); // mix 3 if (mix3("hi") != 101) throw new Exception ("mix3(const char*)"); if (mix3(1.0, 1.0) != 102) throw new Exception ("mix3(double, const double &)"); if (mix3(1.0) != 103) throw new Exception ("mix3(double)"); // Combination 1 if (overtparams1(100) != 10) throw new Exception ("overtparams1(int)"); if (overtparams1(100.0, 100) != 20) throw new Exception ("overtparams1(double, int)"); // Combination 2 if (overtparams2(100.0, 100) != 40) throw new Exception ("overtparams2(double, int)"); // Combination 3 if (overloaded() != 60) throw new Exception ("overloaded()"); if (overloaded(100.0, 100) != 70) throw new Exception ("overloaded(double, int)"); // Combination 4 if (overloadedagain("hello") != 80) throw new Exception ("overloadedagain(const char *)"); if (overloadedagain() != 90) throw new Exception ("overloadedagain(double)"); // specializations if (specialization(10) != 202) throw new Exception ("specialization(int)"); if (specialization(10.0) != 203) throw new Exception ("specialization(double)"); if (specialization(10, 10) != 204) throw new Exception ("specialization(int, int)"); if (specialization(10.0, 10.0) != 205) throw new Exception ("specialization(double, double)"); if (specialization("hi", "hi") != 201) throw new Exception ("specialization(const char *, const char *)"); // simple specialization xyz(); xyz_int(); xyz_double(); // a bit of everything if (overload("hi") != 0) throw new Exception ("overload()"); if (overload(1) != 10) throw new Exception ("overload(int t)"); if (overload(1, 1) != 20) throw new Exception ("overload(int t, const int &)"); if (overload(1, "hello") != 30) throw new Exception ("overload(int t, const char *)"); auto k = new Klass(); if (overload(k) != 10) throw new Exception ("overload(Klass t)"); if (overload(k, k) != 20) throw new Exception ("overload(Klass t, const Klass &)"); if (overload(k, "hello") != 30) throw new Exception ("overload(Klass t, const char *)"); if (overload(10.0, "hi") != 40) throw new Exception ("overload(double t, const char *)"); if (overload() != 50) throw new Exception ("overload(const char *)"); // everything put in a namespace if (nsoverload("hi") != 1000) throw new Exception ("nsoverload()"); if (nsoverload(1) != 1010) throw new Exception ("nsoverload(int t)"); if (nsoverload(1, 1) != 1020) throw new Exception ("nsoverload(int t, const int &)"); if (nsoverload(1, "hello") != 1030) throw new Exception ("nsoverload(int t, const char *)"); if (nsoverload(k) != 1010) throw new Exception ("nsoverload(Klass t)"); if (nsoverload(k, k) != 1020) throw new Exception ("nsoverload(Klass t, const Klass &)"); if (nsoverload(k, "hello") != 1030) throw new Exception ("nsoverload(Klass t, const char *)"); if (nsoverload(10.0, "hi") != 1040) throw new Exception ("nsoverload(double t, const char *)"); if (nsoverload() != 1050) throw new Exception ("nsoverload(const char *)"); } swig-3.0.2/Examples/test-suite/d/pointer_reference_runme.1.d0000664000175000017500000000050612343605122023663 0ustar williamwilliammodule pointer_reference_runme; import pointer_reference.pointer_reference; import pointer_reference.Struct; void main() { Struct s = get(); if (s.value != 10) throw new Exception("get test failed"); Struct ss = new Struct(20); set(ss); if (Struct.instance.value != 20) throw new Exception("set test failed"); } swig-3.0.2/Examples/test-suite/d/enum_thorough_runme.1.d0000664000175000017500000007657712343605122023075 0ustar williamwilliammodule enum_thorough_runme; import enum_thorough.enum_thorough; import enum_thorough.AnonStruct; import enum_thorough.colour; import enum_thorough.DifferentTypes; import enum_thorough.FirStruct; import enum_thorough.HairStruct; import enum_thorough.IgnoreTest; import enum_thorough.Instances; import enum_thorough.namedanon; import enum_thorough.namedanonspace; import enum_thorough.newname; import enum_thorough.NewNameStruct; import enum_thorough.repeat; import enum_thorough.SpeedClass; import enum_thorough.TClassInt; import enum_thorough.TemplateClassInt; import enum_thorough.TreesClass; import enum_thorough.twonames; import enum_thorough.TwoNamesStruct; void main() { { // Anonymous enums int i = AnonEnum1; if (ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed"); i += AnonSpaceEnum1; i += AnonStruct.AnonStructEnum1; } { auto red = colour.red; colourTest1(red); colourTest2(red); colourTest3(red); colourTest4(red); myColour = red; } { auto s = new SpeedClass(); auto speed = SpeedClass.speed.slow; if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed"); if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed"); if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed"); if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed"); if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed"); if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed"); if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed"); if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed"); if (speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed"); if (speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed"); if (speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed"); if (speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed"); if (speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed"); } { auto s = new SpeedClass(); auto slow = SpeedClass.speed.slow; auto lightning = SpeedClass.speed.lightning; if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed"); if (cast(int)s.mySpeedtd1 != 10) throw new Exception("mySpeedtd1 2 failed"); s.mySpeedtd1 = lightning; if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed"); if (cast(int)s.mySpeedtd1 != 31) throw new Exception("mySpeedtd1 4 failed"); } { if (namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest 1 failed"); } { auto val = twonames.TwoNames2; if (twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed"); if (twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed"); if (twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed"); } { auto t = new TwoNamesStruct(); auto val = TwoNamesStruct.twonames.TwoNamesStruct1; if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed"); if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed"); if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed"); } { auto val = namedanonspace.NamedAnonSpace2; if (namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed"); if (namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed"); if (namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed"); if (namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed"); } { auto t = new TemplateClassInt(); auto galileo = TemplateClassInt.scientists.galileo; if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed"); if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed"); if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed"); if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed"); if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed"); if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed"); if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed"); if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed"); if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed"); // if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed"); if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed"); // if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed"); if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed"); if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed"); if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed"); if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed"); if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed"); if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed"); if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed"); if (scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed"); if (scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed"); if (scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed"); if (scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed"); if (scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed"); if (scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed"); if (scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed"); if (scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed"); } { auto t = new TClassInt(); auto bell = TClassInt.scientists.bell; auto galileo = TemplateClassInt.scientists.galileo; if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed"); if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed"); if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed"); if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed"); if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed"); if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed"); if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed"); if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed"); if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed"); // if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed"); if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed"); // if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed"); if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed"); if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed"); if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed"); if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed"); if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed"); if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed"); if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed"); if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed"); if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed"); if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed"); if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed"); if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed"); if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed"); if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed"); if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed"); if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed"); if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed"); if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed"); if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed"); if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed"); if (scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed"); if (scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed"); if (scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed"); if (scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed"); if (scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed"); if (scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed"); if (scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed"); if (scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed"); if (scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed"); if (scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed"); if (scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed"); if (scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed"); if (scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed"); if (scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed"); if (scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed"); if (scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed"); if (scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed"); if (scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed"); if (scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed"); if (scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed"); if (scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed"); if (scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed"); if (scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed"); if (scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed"); if (scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed"); if (scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed"); if (scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed"); if (scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed"); } { auto val = newname.argh; if (renameTest1(val) != val) throw new Exception("renameTest Global 1 failed"); if (renameTest2(val) != val) throw new Exception("renameTest Global 2 failed"); } { auto n = new NewNameStruct(); if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 1 failed"); if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 2 failed"); if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest 3 failed"); if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 4 failed"); if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 5 failed"); if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest 6 failed"); } { if (renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest Global 3 failed"); if (renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest Global 4 failed"); if (renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 5 failed"); if (renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 6 failed"); if (renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest Global 7 failed"); } { auto t = new TreesClass(); auto pine = TreesClass.trees.pine; if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed"); if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed"); if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed"); if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed"); if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed"); if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed"); if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed"); if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed"); if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed"); if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed"); if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed"); if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed"); if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed"); if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed"); if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed"); if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed"); if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed"); if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed"); if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed"); if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed"); if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed"); if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed"); if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed"); if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed"); if (treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed"); if (treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed"); if (treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed"); if (treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed"); if (treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed"); if (treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed"); if (treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed"); if (treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed"); if (treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed"); if (treesTestA(pine) != pine) throw new Exception("treesTest Global A failed"); if (treesTestB(pine) != pine) throw new Exception("treesTest Global B failed"); if (treesTestC(pine) != pine) throw new Exception("treesTest Global C failed"); if (treesTestD(pine) != pine) throw new Exception("treesTest Global D failed"); if (treesTestE(pine) != pine) throw new Exception("treesTest Global E failed"); if (treesTestF(pine) != pine) throw new Exception("treesTest Global F failed"); if (treesTestG(pine) != pine) throw new Exception("treesTest Global G failed"); if (treesTestH(pine) != pine) throw new Exception("treesTest Global H failed"); if (treesTestI(pine) != pine) throw new Exception("treesTest Global I failed"); if (treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed"); if (treesTestK(pine) != pine) throw new Exception("treesTest Global K failed"); if (treesTestL(pine) != pine) throw new Exception("treesTest Global L failed"); if (treesTestM(pine) != pine) throw new Exception("treesTest Global M failed"); // if (treesTestN(pine) != pine) throw new Exception("treesTest Global N failed"); if (treesTestO(pine) != pine) throw new Exception("treesTest Global O failed"); if (treesTestP(pine) != pine) throw new Exception("treesTest Global P failed"); if (treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed"); if (treesTestR(pine) != pine) throw new Exception("treesTest Global R failed"); } { auto h = new HairStruct(); auto ginger = HairStruct.hair.ginger; if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed"); if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed"); if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed"); if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed"); if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed"); if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed"); if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed"); if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed"); if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed"); if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed"); if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed"); auto red = colour.red; if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed"); if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed"); if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed"); if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed"); auto fir = TreesClass.trees.fir; if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed"); if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed"); if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed"); if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed"); } { auto blonde = HairStruct.hair.blonde; if (hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed"); if (hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed"); if (hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed"); if (hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed"); if (hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed"); if (hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed"); if (hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed"); if (hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed"); if (hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed"); if (hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed"); if (hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed"); if (hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed"); if (hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed"); if (hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed"); if (hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed"); if (hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed"); if (hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed"); if (hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed"); if (hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed"); if (hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed"); if (hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed"); if (hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed"); if (hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed"); if (hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed"); if (hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed"); if (hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed"); if (hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed"); if (hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed"); if (hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed"); if (hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed"); if (hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed"); if (hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed"); if (hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed"); if (hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed"); if (hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed"); if (hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed"); if (hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed"); if (hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed"); if (hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed"); if (hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed"); if (hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed"); if (hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed"); if (hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed"); if (hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed"); if (hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed"); if (hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed"); if (hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed"); if (hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed"); } { auto f = new FirStruct(); auto blonde = HairStruct.hair.blonde; if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed"); if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed"); if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed"); if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed"); if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed"); if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed"); if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed"); if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed"); if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed"); if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed"); } { GlobalInstance = globalinstance2; if (GlobalInstance != globalinstance2) throw new Exception("GlobalInstance 1 failed"); auto i = new Instances(); i.MemberInstance = Instances.memberinstance3; if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed"); } // ignore enum item tests start { if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed"); if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed"); if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed"); if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed"); if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed"); if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed"); if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed"); if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed"); if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed"); if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed"); } { if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed"); if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed"); if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed"); if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed"); if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed"); if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed"); } { if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed"); if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed"); if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed"); if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed"); if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed"); if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed"); } { if (cast(int)ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed"); if (cast(int)ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed"); } { if (cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed"); if (cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed"); if (cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed"); } // ignore enum item tests end { if (cast(int)repeatTest(repeat.one) != 1) throw new Exception("repeatTest 1 failed"); if (cast(int)repeatTest(repeat.initial) != 1) throw new Exception("repeatTest 2 failed"); if (cast(int)repeatTest(repeat.two) != 2) throw new Exception("repeatTest 3 failed"); if (cast(int)repeatTest(repeat.three) != 3) throw new Exception("repeatTest 4 failed"); if (cast(int)repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed"); if (cast(int)repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed"); } // different types { if (cast(int)differentTypesTest(DifferentTypes.typeint) != 10) throw new Exception("differentTypes 1 failed"); if (cast(int)differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed"); if (cast(int)differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new Exception("differentTypes 3 failed"); if (cast(int)differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new Exception("differentTypes 4 failed"); if (cast(int)differentTypesTest(DifferentTypes.typechar) != 'C') throw new Exception("differentTypes 5 failed"); if (cast(int)differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed"); int global_enum = global_typeint; if (cast(int)globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed"); global_enum = global_typeboolfalse; if (cast(int)globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed"); global_enum = global_typebooltrue; if (cast(int)globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed"); global_enum = global_typebooltwo; if (cast(int)globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed"); global_enum = global_typechar; if (cast(int)globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed"); global_enum = global_typedefaultint; if (cast(int)globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed"); } } swig-3.0.2/Examples/test-suite/d/li_typemaps_runme.2.d0000664000175000017500000000373412343605122022522 0ustar williamwilliam/// Tests correct handling of a few INPUT/OUTPUT/INOUT-typemapped functions. module li_typemaps_runme; import std.exception; import li_typemaps.li_typemaps; void main() { // Check double INPUT typemaps enforce(in_double(22.22) == 22.22, "in_double"); enforce(inr_double(22.22) == 22.22, "inr_double"); // Check double OUTPUT typemaps { double var = 44.44; out_double(22.22, var); enforce(var == 22.22, "out_double"); } { double var = 44.44; outr_double(22.22, var); enforce(var == 22.22, "outr_double"); } // Check double INOUT typemaps { double var = 44.44; inout_double(var); enforce(var == 44.44, "inout_double"); } { double var = 44.44; inoutr_double(var); enforce(var == 44.44, "inoutr_double"); } // Check unsigned long long INPUT typemaps enforce(in_ulonglong(20) == 20, "in_ulonglong"); enforce(inr_ulonglong(20) == 20, "inr_ulonglong"); // Check unsigned long long OUTPUT typemaps { ulong var = 40; out_ulonglong(20, var); enforce(var == 20, "out_ulonglong"); } { ulong var = 40; outr_ulonglong(20, var); enforce(var == 20, "outr_ulonglong"); } // Check unsigned long long INOUT typemaps { ulong var = 40; inout_ulonglong(var); enforce(var == 40, "inout_ulonglong"); } { ulong var = 40; inoutr_ulonglong(var); enforce(var == 40, "inoutr_ulonglong"); } // Check unsigned bool INPUT typemaps enforce(in_bool(false) == false, "in_bool"); enforce(inr_bool(false) == false, "inr_bool"); // Check unsigned bool OUTPUT typemaps { bool var = false; out_bool(true, var); enforce(var == true, "out_bool"); } { bool var = false; outr_bool(true, var); enforce(var == true, "outr_bool"); } // Check unsigned bool INOUT typemaps { bool var = false; inout_bool(var); enforce(var == false, "inout_bool"); } { bool var = false; inoutr_bool(var); enforce(var == false, "inoutr_bool"); } } swig-3.0.2/Examples/test-suite/d/threads_runme.1.d0000664000175000017500000000340512343605122021620 0ustar williamwilliammodule threads_runme; import tango.core.Thread; import tango.io.Console; import Integer = tango.text.convert.Integer; import threads.Kerfuffle; // Spawn 8 threads. const uint NUM_THREADS = 8; // Run test for a few seconds on a 1GHz machine. const uint WORKER_LOOP_PASSES = 30000; void main() { auto kerf = new Kerfuffle(); TestThread[] threads; // Invoke the threads. for (uint i = 0; i < NUM_THREADS; i++) { auto thread = new TestThread(kerf); threads ~= thread; thread.name = Integer.toString(i); thread.start(); } // Wait for the threads to finish. foreach(thread; threads) { thread.join(); } // Check if any thread has failed. foreach(thread; threads) { if (thread.failed) throw new Exception("Test failed."); } } class TestThread : Thread { public: this(Kerfuffle kerf) { super(&run); m_kerf = kerf; } void run() { failed = false; try { for (uint i = 0; i < WORKER_LOOP_PASSES; i++) { char[] given = "This is the test char[] that should come back. A number: " ~ Integer.toString(i); char[] received = m_kerf.StdString(given); if (received != given) { throw new Exception("StdString char[] does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'."); } } for (uint i = 0; i < WORKER_LOOP_PASSES; i++) { char[] given = "This is the test char[] that should come back. A number: " ~ Integer.toString(i); char[] received = m_kerf.CharString(given); if (received != given) { throw new Exception("StdString char[] does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'."); } } } catch (Exception e) { Cerr("Test failed (thread " ~ name() ~ "): " ~ e.msg).newline; failed = true; } } bool failed; private: Kerfuffle m_kerf; } swig-3.0.2/Examples/test-suite/d/typemap_out_optimal_runme.1.d0000664000175000017500000000020212343605122024251 0ustar williamwilliammodule typemap_out_optimal_runme; import typemap_out_optimal.XX; void main() { XX x; XX.trace = false; x = XX.create(); } swig-3.0.2/Examples/test-suite/d/director_ignore_runme.2.d0000664000175000017500000000272612343605122023352 0ustar williamwilliammodule director_ignore_runme; import std.exception; import director_ignore.DIgnores; import director_ignore.DAbstractIgnores; void main() { // Just check the classes can be instantiated and other methods work as expected auto a = new DIgnoresDerived(); enforce(a.Triple(5) == 15, "Triple failed"); auto b = new DAbstractIgnoresDerived(); enforce(b.Quadruple(5) == 20, "Quadruple failed"); } class DIgnoresDerived : DIgnores { public: // These will give a warning if the %ignore is not working int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedMethod(int n, int xoffset) { return 0; } int OverloadedMethod(int n) { return 0; } alias super.OverloadedMethod OverloadedMethod; protected: int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedProtectedMethod(int n, int xoffset) { return 0; } int OverloadedProtectedMethod(int n) { return 0; } } class DAbstractIgnoresDerived : DAbstractIgnores { public: // These will give a warning if the %ignore is not working int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedMethod(int n, int xoffset) { return 0; } int OverloadedMethod(int n) { return 0; } alias super.OverloadedMethod OverloadedMethod; protected: int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedProtectedMethod(int n, int xoffset) { return 0; } int OverloadedProtectedMethod(int n) { return 0; } } swig-3.0.2/Examples/test-suite/d/threads_runme.2.d0000664000175000017500000000254012343605122021620 0ustar williamwilliammodule threads_runme; import core.thread; import std.conv; import std.exception; import std.range; import std.stdio; import threads.Kerfuffle; // Spawn 8 threads. enum THREADS = iota(0, 9); // Run test for a few seconds on a 1GHz machine. enum WORK_RANGE = iota(0, 30000); void main() { auto kerf = new Kerfuffle(); TestThread[] threads; // Invoke the threads. foreach (i; THREADS) { auto thread = new TestThread(kerf); threads ~= thread; thread.name = to!string(i); thread.start(); } // Wait for the threads to finish. foreach (i, thread; threads) { thread.join(true); } } class TestThread : Thread { this(Kerfuffle kerf) { super(&run); m_kerf = kerf; } void run() { foreach (i; WORK_RANGE) { string given = "This is the test string that should come back. A number: " ~ to!string(i); string received = m_kerf.StdString(given); enforce(received == given, "StdString string does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'."); } foreach (i; WORK_RANGE) { string given = "This is the test string that should come back. A number: " ~ to!string(i); string received = m_kerf.CharString(given); enforce(received == given, "CharString string does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'."); } } private: Kerfuffle m_kerf; } swig-3.0.2/Examples/test-suite/d/li_std_string_runme.1.d0000664000175000017500000000605112343605122023032 0ustar williamwilliammodule li_std_string_runme; import tango.core.Exception; import li_std_string.li_std_string; import li_std_string.Structure; import li_std_string.SWIGTYPE_p_std__string; void main() { // Checking expected use of %typemap(in) std::string {} test_value("Fee"); // Checking expected result of %typemap(out) std::string {} if (test_value("Fi") != "Fi") throw new Exception("Test 1 failed"); // Verify type-checking for %typemap(in) std::string {} try { test_value(null); throw new Exception("Test 2 failed"); } catch (IllegalArgumentException) { } // Checking expected use of %typemap(in) const std::string & {} test_const_reference("Fo"); // Checking expected result of %typemap(out) const std::string& {} if (test_const_reference("Fum") != "Fum") throw new Exception("Test 3 failed"); // Verify type-checking for %typemap(in) const std::string & {} try { test_const_reference(null); throw new Exception("Test 4 failed"); } catch (IllegalArgumentException) { } // Input and output typemaps for pointers and non-const references to // std::string are *not* supported; the following tests confirm // that none of these cases are slipping through. SWIGTYPE_p_std__string stringPtr = null; stringPtr = test_pointer_out(); test_pointer(stringPtr); stringPtr = test_const_pointer_out(); test_const_pointer(stringPtr); stringPtr = test_reference_out(); test_reference(stringPtr); // Check throw exception specification try { test_throw(); throw new Exception("test 5 failed!"); } catch (Exception e) { if (e.msg != "test_throw message") throw new Exception("Test 5 string check: " ~ e.msg); } try { test_const_reference_throw(); throw new Exception("test 6 failed!"); } catch (Exception e) { if (e.msg != "test_const_reference_throw message") throw new Exception("Test 6 string check: " ~ e.msg); } // Global variables. const char[] s = "initial string"; if (GlobalString2 != "global string 2") throw new Exception("GlobalString2 test 1"); GlobalString2 = s; if (GlobalString2 != s) throw new Exception("GlobalString2 test 2"); if (ConstGlobalString != "const global string") throw new Exception("ConstGlobalString test"); // Member variables. auto myStructure = new Structure(); if (myStructure.MemberString2 != "member string 2") throw new Exception("MemberString2 test 1"); myStructure.MemberString2 = s; if (myStructure.MemberString2 != s) throw new Exception("MemberString2 test 2"); if (myStructure.ConstMemberString != "const member string") throw new Exception("ConstMemberString test"); // Static member variables. if (Structure.StaticMemberString2 != "static member string 2") throw new Exception("StaticMemberString2 test 1"); Structure.StaticMemberString2 = s; if (Structure.StaticMemberString2 != s) throw new Exception("StaticMemberString2 test 2"); if (Structure.ConstStaticMemberString != "const static member string") throw new Exception("ConstStaticMemberString test"); } swig-3.0.2/Examples/test-suite/d/default_constructor_runme.2.d0000664000175000017500000000123312343605122024255 0ustar williamwilliammodule default_constructor_runme; import default_constructor.FFF; import default_constructor.G; void main() { // D2 does not support something akin to D1/Tango dispose() for deterministic // destruction yet. // enforceThrows((){ scope g = new G(); }, "Protected destructor exception should have been thrown"); // enforceThrows((){ scope f = new FFF(); }, "Private destructor exception should have been thrown"); } private void enforceThrows(void delegate() dg, string errorMessage) { bool hasThrown; try { dg(); } catch (Exception) { hasThrown = true; } finally { if (!hasThrown) { throw new Exception(errorMessage); } } } swig-3.0.2/Examples/test-suite/d/apply_strings_runme.2.d0000664000175000017500000000072612343605122023070 0ustar williamwilliammodule apply_strings_runme; import apply_strings.apply_strings; enum string TEST_MESSAGE = "A message from target language to the C++ world and back again."; void main() { if (UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed"); if (SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed"); auto pChar = CharFunction(null); if (pChar !is null) throw new Exception("CharFunction failed"); } swig-3.0.2/Examples/test-suite/d/member_pointer_runme.1.d0000664000175000017500000000224512343605122023176 0ustar williamwilliammodule member_pointer_runme; import Float = tango.text.convert.Float; import member_pointer.member_pointer; import member_pointer.Square; import member_pointer.SWIGTYPE_m_Shape__f_void__double; void main() { auto s = new Square(10); // Do some calculations auto area_pt = areapt(); auto perim_pt = perimeterpt(); check("Square area ", 100.0, do_op(s, area_pt)); check("Square perim", 40.0, do_op(s, perim_pt)); SWIGTYPE_m_Shape__f_void__double memberPtr = null; memberPtr = areavar; memberPtr = perimetervar; // Try the variables check("Square area ", 100.0, do_op(s, areavar)); check("Square perim", 40.0, do_op(s, perimetervar)); // Modify one of the variables areavar = perim_pt; check("Square perimeter", 40.0, do_op(s,areavar)); // Try the constants memberPtr = AREAPT; memberPtr = PERIMPT; memberPtr = NULLPT; check("Square area", 100.0, do_op(s, AREAPT)); check("Square perim", 40.0, do_op(s, PERIMPT)); } void check(char[] what, double expected, double actual) { if (expected != actual) { throw new Exception("Failed: " ~ what ~ ": expected " ~ Float.toString(expected) ~ ", but got " ~ Float.toString(actual)); } } swig-3.0.2/Examples/test-suite/d/default_args_runme.2.d0000664000175000017500000000621712343605122022633 0ustar williamwilliammodule default_args_runme; import std.exception; import default_args.default_args; import default_args.ConstMethods; import default_args.EnumClass; import default_args.Except; import default_args.Foo; import default_args.Klass; import default_args.Statics; import default_args.Tricky; void main() { enforce(anonymous() == 7771, "anonymous (1) failed"); enforce(anonymous(1234) == 1234,"anonymous (2) failed"); enforce(booltest() == true, "booltest (1) failed"); enforce(booltest(true) == true, "booltest (2) failed"); enforce(booltest(false) == false, "booltest (3) failed"); enforce((new EnumClass()).blah() == true, "EnumClass failed"); enforce(casts1() == null, "casts1 failed"); enforce(casts2() == "Hello", "casts2 failed"); enforce(casts1("Ciao") == "Ciao", "casts1 not default failed"); enforce(chartest1() == 'x', "chartest1 failed"); enforce(chartest2() == '\0', "chartest2 failed"); enforce(chartest1('y') == 'y', "chartest1 not default failed"); enforce(chartest1('y') == 'y', "chartest1 not default failed"); enforce(reftest1() == 42, "reftest1 failed"); enforce(reftest1(400) == 400, "reftest1 not default failed"); enforce(reftest2() == "hello", "reftest2 failed"); // rename auto foo = new Foo(); foo.newname(); foo.newname(10); foo.renamed3arg(10, 10.0); foo.renamed2arg(10); foo.renamed1arg(); // exception specifications enforceThrows( (){ exceptionspec(); }, "exceptionspec 1" ); enforceThrows( (){ exceptionspec(-1); }, "exceptionspec 2" ); enforceThrows( (){ exceptionspec(100); }, "exceptionspec 3" ); auto ex = new Except(false); enforceThrows( (){ ex.exspec(); }, "exspec 1" ); enforceThrows( (){ ex.exspec(-1); }, "exspec 2" ); enforceThrows( (){ ex.exspec(100); }, "exspec 3" ); enforceThrows( (){ ex = new Except(true); }, "Except constructor 1" ); enforceThrows( (){ ex = new Except(true, -2); }, "Except constructor 2" ); // Default parameters in static class methods enforce(Statics.staticmethod() == 10+20+30, "staticmethod 1 failed"); enforce(Statics.staticmethod(100) == 100+20+30, "staticmethod 2 failed"); enforce(Statics.staticmethod(100,200,300) == 100+200+300, "staticmethod 3 failed"); auto tricky = new Tricky(); enforce(tricky.privatedefault() == 200, "privatedefault failed"); enforce(tricky.protectedint() == 2000, "protectedint failed"); enforce(tricky.protecteddouble() == 987.654, "protecteddouble failed"); enforce(tricky.functiondefault() == 500, "functiondefault failed"); enforce(tricky.contrived() == 'X', "contrived failed"); enforce(constructorcall().val == -1, "constructorcall test 1 failed"); enforce(constructorcall(new Klass(2222)).val == 2222, "constructorcall test 2 failed"); enforce(constructorcall(new Klass()).val == -1, "constructorcall test 3 failed"); // const methods const cm = new ConstMethods(); enforce(cm.coo() == 20, "coo test 1 failed"); enforce(cm.coo(1.0) == 20, "coo test 2 failed"); } private void enforceThrows(void delegate() dg, string errorMessage) { bool hasThrown; try { dg(); } catch (Exception) { hasThrown = true; } finally { if (!hasThrown) { throw new Exception(errorMessage); } } } swig-3.0.2/Examples/test-suite/d/li_attribute_runme.2.d0000664000175000017500000000302712343605122022656 0ustar williamwilliammodule li_attribute_runme; import std.exception; import li_attribute.A; import li_attribute.B; import li_attribute.MyClass; import li_attribute.MyClassVal; import li_attribute.MyStringyClass; import li_attribute.MyFoo; import li_attribute.Param_i; void main() { auto aa = new A(1,2,3); enforce(aa.a == 1); aa.a = 3; enforce(aa.a == 3); enforce(aa.b == 2); aa.b = 5; enforce(aa.b == 5); enforce(aa.d == aa.b); enforce(aa.c == 3); auto pi = new Param_i(7); enforce(pi.value == 7); pi.value=3; enforce(pi.value == 3); auto b = new B(aa); enforce(b.a.c == 3); // class/struct attribute with get/set methods using return/pass by reference auto myFoo = new MyFoo(); myFoo.x = 8; auto myClass = new MyClass(); myClass.Foo = myFoo; enforce(myClass.Foo.x == 8); // class/struct attribute with get/set methods using return/pass by value auto myClassVal = new MyClassVal(); enforce(myClassVal.ReadWriteFoo.x == -1); enforce(myClassVal.ReadOnlyFoo.x == -1); myClassVal.ReadWriteFoo = myFoo; enforce(myClassVal.ReadWriteFoo.x == 8); enforce(myClassVal.ReadOnlyFoo.x == 8); // string attribute with get/set methods using return/pass by value auto myStringClass = new MyStringyClass("initial string"); enforce(myStringClass.ReadWriteString == "initial string"); enforce(myStringClass.ReadOnlyString == "initial string"); myStringClass.ReadWriteString = "changed string"; enforce(myStringClass.ReadWriteString == "changed string"); enforce(myStringClass.ReadOnlyString == "changed string"); } swig-3.0.2/Examples/test-suite/d/director_classes_runme.1.d0000664000175000017500000001336212343605122023521 0ustar williamwilliam/** * This test demonstrates director classes when the types are classes. Shown are * virtual function calls which use classes passed by * - Value * - Reference * - Pointer * as both parameters and return values * * The test also demonstrates directors used with: * - method overloading * - default parameters * * Note: Methods with default parameters that call up from C++ cannot call the * overloaded D methods, see DefaultParms method. * Expected output if PrintDebug enabled: * ------------ Start ------------ * Base - Val(444.555) * Base - Ref(444.555) * Base - Ptr(444.555) * Base - FullyOverloaded(int 10) * Base - FullyOverloaded(bool 1) * Base - SemiOverloaded(int -678) * Base - SemiOverloaded(bool 1) * Base - DefaultParms(10, 2.2) * Base - DefaultParms(10, 1.1) * -------------------------------- * Derived - Val(444.555) * Derived - Ref(444.555) * Derived - Ptr(444.555) * Derived - FullyOverloaded(int 10) * Derived - FullyOverloaded(bool 1) * Derived - SemiOverloaded(int -678) * Base - SemiOverloaded(bool 1) * Derived - DefaultParms(10, 2.2) * Derived - DefaultParms(10, 1.1) * -------------------------------- * DDerived - Val(444.555) * DDerived - Ref(444.555) * DDerived - Ptr(444.555) * DDerived - FullyOverloaded(int 10) * DDerived - FullyOverloaded(bool True) * DDerived - SemiOverloaded(-678) * Base - SemiOverloaded(bool 1) * DDerived - DefaultParms(10, 2.2) * DDerived - DefaultParms(10, 1.1) * ------------ Finish ------------ */ module director_classes_runme; import tango.io.Stdout; import tango.text.Util; import director_classes.director_classes; import director_classes.Caller; import director_classes.Base; import director_classes.Derived; import director_classes.DoubleHolder; void main() { if (PrintDebug) Stdout.formatln("------------ Start ------------ "); auto myCaller = new Caller(); // Test C++ base class. { scope myBase = new Base(100.0); makeCalls(myCaller, myBase); } if (PrintDebug) Stdout.formatln("--------------------------------"); // Test vanilla C++ wrapped derived class. { scope myBase = new Derived(200.0); makeCalls(myCaller, myBase); } if (PrintDebug) Stdout.formatln("--------------------------------"); // Test director / D derived class. { scope myBase = new DDerived(300.0); makeCalls(myCaller, myBase); } if (PrintDebug) Stdout.formatln("------------ Finish ------------ "); } void makeCalls(Caller myCaller, Base myBase) { char[] myBaseType = myBase.classinfo.name.split(".")[$-1]; myCaller.set(myBase); DoubleHolder dh = new DoubleHolder(444.555); // Class pointer, reference and pass by value tests if (myCaller.ValCall(dh).val != dh.val) throw new Exception("[1] failed"); if (myCaller.RefCall(dh).val != dh.val) throw new Exception("[2] failed"); if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("[3] failed"); // Fully overloaded method test (all methods in base class are overloaded) if (myCaller.FullyOverloadedCall(10) != myBaseType ~ "::FullyOverloaded(int)") throw new Exception("[4] failed"); if (myCaller.FullyOverloadedCall(true) != myBaseType ~ "::FullyOverloaded(bool)") throw new Exception("[5] failed"); // Semi overloaded method test (some methods in base class are overloaded) if (myCaller.SemiOverloadedCall(-678) != myBaseType ~ "::SemiOverloaded(int)") throw new Exception("[6] failed"); if (myCaller.SemiOverloadedCall(true) != "Base" ~ "::SemiOverloaded(bool)") throw new Exception("[7] failed"); // Default parameters methods test if (myCaller.DefaultParmsCall(10, 2.2) != myBaseType ~ "::DefaultParms(int, double)") throw new Exception("[8] failed"); if (myBase.classinfo == DDerived.classinfo) { // special handling for D derived classes, there is no way to do this any other way if (myCaller.DefaultParmsCall(10) != myBaseType ~ "::DefaultParms(int, double)") throw new Exception("[9] failed"); } else { if (myCaller.DefaultParmsCall(10) != myBaseType ~ "::DefaultParms(int)") throw new Exception("[10] failed"); } myCaller.reset(); } public class DDerived : Base { public this(double dd) { super(dd); } public override DoubleHolder Val(DoubleHolder x) { if (PrintDebug) Stdout.formatln("DDerived - Val({0:d3})", x.val); return x; } public override DoubleHolder Ref(DoubleHolder x) { if (PrintDebug) Stdout.formatln("DDerived - Ref({0:d3})", x.val); return x; } public override DoubleHolder Ptr(DoubleHolder x) { if (PrintDebug) Stdout.formatln("DDerived - Ptr({0:d3})", x.val); return x; } public override char[] FullyOverloaded(int x) { if (PrintDebug) Stdout.formatln("DDerived - FullyOverloaded(int {0})", x); return "DDerived::FullyOverloaded(int)"; } public override char[] FullyOverloaded(bool x) { if (PrintDebug) Stdout.formatln("DDerived - FullyOverloaded(bool {0})", x); return "DDerived::FullyOverloaded(bool)"; } public override char[] SemiOverloaded(int x) { char[] ret = "DDerived::SemiOverloaded(int)"; if (PrintDebug) Stdout.formatln("DDerived - SemiOverloaded({0})", x); return ret; } alias Base.SemiOverloaded SemiOverloaded; // Alias in SemiOverloaded(bool x). public override char[] DefaultParms(int x, double y) { char[] ret = "DDerived::DefaultParms(int, double)"; if (PrintDebug) Stdout.formatln("DDerived - DefaultParms({0}, {1:d1})", x, y); return ret; } // This method will never be called from C++ code because the two-parameter // DefaultParams() has a default value for the second parameter there. It is // only here to ensure consistent behavior for calls from C++ and D code. public override char[] DefaultParms(int x) { if (PrintDebug) Stdout.formatln("DDerived - DefaultParms({0})", x); return DefaultParms(x, 1.1/*use C++ default here*/); } } swig-3.0.2/Examples/test-suite/d/director_alternating_runme.2.d0000664000175000017500000000022312343605122024365 0ustar williamwilliammodule director_alternating_runme; import director_alternating.director_alternating; void main() { assert(getBar().id() == idFromGetBar()); } swig-3.0.2/Examples/test-suite/d/aggregate_runme.2.d0000664000175000017500000000117212343605122022114 0ustar williamwilliammodule aggregate_runme; import aggregate.aggregate; void main() { // Confirm that move() returns correct results under normal use. int result = move(UP); if (result != UP) throw new Exception("UP failed"); result = move(DOWN); if (result != DOWN) throw new Exception("DOWN failed"); result = move(LEFT); if (result != LEFT) throw new Exception("LEFT failed"); result = move(RIGHT); if (result != RIGHT) throw new Exception("RIGHT failed"); // Confirm that move() raises an exception when the contract is violated. try { move(0); throw new Exception("0 test failed"); } catch (Exception e) {} } swig-3.0.2/Examples/test-suite/d/operator_overload_runme.2.d0000664000175000017500000000351212343605122023714 0ustar williamwilliammodule operator_overload_runme; import operator_overload.Op; void main() { // Invoke the C++ sanity check first. Op.sanity_check(); auto a = new Op(); auto b = new Op(5); auto c = b; auto d = new Op(2); auto dd = d; // test equality assert(a != b); assert(b == c); assert(a != d); assert(d == dd); // test < assert(a < b); assert(a <= b); assert(b <= c); assert(b >= c); assert(b > d); assert(b >= d); // test += auto e = new Op(3); e += d; assert(e == b); e -= c; assert(e == a); e = new Op(1); e *= b; assert(e == c); e /= d; assert(e == d); e %= c; assert(e == d); // test + auto f = new Op(1); auto g = new Op(1); assert(f + g == new Op(2)); assert(f - g == new Op(0)); assert(f * g == new Op(1)); assert(f / g == new Op(1)); assert(f % g == new Op(0)); // test unary operators assert(-a == a); assert(-b == new Op(-5)); // Unfortunately, there is no way to override conversion to boolean for // classes in D, opCast!("bool") is only used for structs. // test [] auto h = new Op(3); assert(h[0]==3); assert(h[1]==0); // Generation of opIndexAssign is not supported yet. // test () auto i = new Op(3); assert(i()==3); assert(i(1)==4); assert(i(1,2)==6); // test ++ and -- auto j = new Op(100); int original = j.i; // The prefix increment/decrement operators are not directly overloadable in // D2, and because the proxy classes are reference types, the lowering // yields the same value as the postfix operators. { Op newOp = ++j; int newInt = ++original; assert(j.i == original); assert(newOp.i == newInt); } { Op newOp = --j; int newInt = --original; assert(j.i == original); assert(newOp.i == newInt); } // Implicit casting via alias this is not supported yet. }swig-3.0.2/Examples/test-suite/d/director_classic_runme.2.d0000664000175000017500000001077712343605122023515 0ustar williamwilliammodule director_classic_runme; import std.exception; import std.stdio; import director_classic.Caller; import director_classic.Person; import director_classic.Child; import director_classic.GrandChild; import director_classic.OrphanPerson; import director_classic.OrphanChild; enum TRACE = false; void main() { { scope person = new Person(); check(person, "Person"); } { scope person = new Child(); check(person, "Child"); } { scope person = new GrandChild(); check(person, "GrandChild"); } { scope person = new TargetLangPerson(); check(person, "TargetLangPerson"); } { scope person = new TargetLangChild(); check(person, "TargetLangChild"); } { scope person = new TargetLangGrandChild(); check(person, "TargetLangGrandChild"); } // Semis - don't override id() in target language { scope person = new TargetLangSemiPerson(); check(person, "Person"); } { scope person = new TargetLangSemiChild(); check(person, "Child"); } { scope person = new TargetLangSemiGrandChild(); check(person, "GrandChild"); } // Orphans - don't override id() in C++ { scope person = new OrphanPerson(); check(person, "Person"); } { scope person = new OrphanChild(); check(person, "Child"); } { scope person = new TargetLangOrphanPerson(); check(person, "TargetLangOrphanPerson"); } { scope person = new TargetLangOrphanChild(); check(person, "TargetLangOrphanChild"); } // Duals - id() makes an upcall to the base id() { scope person = new TargetLangDualPerson(); check(person, "TargetLangDualPerson + Person"); } { scope person = new TargetLangDualChild(); check(person, "TargetLangDualChild + Child"); } { scope person = new TargetLangDualGrandChild(); check(person, "TargetLangDualGrandChild + GrandChild"); } // Mix Orphans and Duals { scope person = new TargetLangDualOrphanPerson(); check(person, "TargetLangDualOrphanPerson + Person"); } { scope person = new TargetLangDualOrphanChild(); check(person, "TargetLangDualOrphanChild + Child"); } } void check(Person person, string expected) { string ret; // Normal D polymorphic call. ret = person.id(); if (TRACE) writeln(ret); enforce(ret == expected, "Failed. Received: " ~ ret ~ " Expected: " ~ expected); // Polymorphic call from C++. auto caller = new Caller(); caller.setCallback(person); ret = caller.call(); if (TRACE) writeln(ret); enforce(ret == expected, "Failed. Received: " ~ ret ~ " Expected: " ~ expected); // Polymorphic call of object created in D and passed to C++ and back again. Person baseclass = caller.baseClass(); ret = baseclass.id(); if (TRACE) writeln(ret); enforce(ret == expected, "Failed. Received: " ~ ret ~ " Expected: " ~ expected); caller.resetCallback(); if (TRACE) writeln("----------------------------------------"); } // »Full« target language persons. class TargetLangPerson : Person { public override string id() { return "TargetLangPerson"; } } class TargetLangChild : Child { public override string id() { return "TargetLangChild"; } } class TargetLangGrandChild : GrandChild { public override string id() { return "TargetLangGrandChild"; } } // Semis - don't override id() in target language class TargetLangSemiPerson : Person { // No id() override } class TargetLangSemiChild : Child { // No id() override } class TargetLangSemiGrandChild : GrandChild { // No id() override } // Orphans - don't override id() in C++ class TargetLangOrphanPerson : OrphanPerson { public override string id() { return "TargetLangOrphanPerson"; } } class TargetLangOrphanChild : OrphanChild { public override string id() { return "TargetLangOrphanChild"; } } // Duals - id() makes an upcall to the base id() class TargetLangDualPerson : Person { public override string id() { return "TargetLangDualPerson + " ~ super.id(); } } class TargetLangDualChild : Child { public override string id() { return "TargetLangDualChild + " ~ super.id(); } } class TargetLangDualGrandChild : GrandChild { public override string id() { return "TargetLangDualGrandChild + " ~ super.id(); } } // Mix Orphans and Duals class TargetLangDualOrphanPerson : OrphanPerson { public override string id() { return "TargetLangDualOrphanPerson + " ~ super.id(); } } class TargetLangDualOrphanChild : OrphanChild { public override string id() { return "TargetLangDualOrphanChild + " ~ super.id(); } } swig-3.0.2/Examples/test-suite/d/enum_thorough_runme.2.d0000664000175000017500000006521712343605122023063 0ustar williamwilliammodule enum_thorough_runme; import std.exception; import enum_thorough.enum_thorough; import enum_thorough.AnonStruct; import enum_thorough.colour; import enum_thorough.DifferentTypes; import enum_thorough.FirStruct; import enum_thorough.HairStruct; import enum_thorough.IgnoreTest; import enum_thorough.Instances; import enum_thorough.namedanon; import enum_thorough.namedanonspace; import enum_thorough.newname; import enum_thorough.NewNameStruct; import enum_thorough.repeat; import enum_thorough.SpeedClass; import enum_thorough.TClassInt; import enum_thorough.TemplateClassInt; import enum_thorough.TreesClass; import enum_thorough.twonames; import enum_thorough.TwoNamesStruct; void main() { { // Anonymous enums int i = AnonEnum1; enforce(ReallyAnInteger == 200, "Test Anon 1 failed"); i += AnonSpaceEnum1; i += AnonStruct.AnonStructEnum1; } { auto red = colour.red; colourTest1(red); colourTest2(red); colourTest3(red); colourTest4(red); myColour = red; } { auto s = new SpeedClass(); auto speed = SpeedClass.speed.slow; enforce(s.speedTest1(speed) == speed, "speedTest 1 failed"); enforce(s.speedTest2(speed) == speed, "speedTest 2 failed"); enforce(s.speedTest3(speed) == speed, "speedTest 3 failed"); enforce(s.speedTest4(speed) == speed, "speedTest 4 failed"); enforce(s.speedTest5(speed) == speed, "speedTest 5 failed"); enforce(s.speedTest6(speed) == speed, "speedTest 6 failed"); enforce(s.speedTest7(speed) == speed, "speedTest 7 failed"); enforce(s.speedTest8(speed) == speed, "speedTest 8 failed"); enforce(speedTest1(speed) == speed, "speedTest Global 1 failed"); enforce(speedTest2(speed) == speed, "speedTest Global 2 failed"); enforce(speedTest3(speed) == speed, "speedTest Global 3 failed"); enforce(speedTest4(speed) == speed, "speedTest Global 4 failed"); enforce(speedTest5(speed) == speed, "speedTest Global 5 failed"); } { auto s = new SpeedClass(); auto slow = SpeedClass.speed.slow; auto lightning = SpeedClass.speed.lightning; enforce(s.mySpeedtd1 == slow, "mySpeedtd1 1 failed"); enforce(cast(int)s.mySpeedtd1 == 10, "mySpeedtd1 2 failed"); s.mySpeedtd1 = lightning; enforce(s.mySpeedtd1 == lightning, "mySpeedtd1 3 failed"); enforce(cast(int)s.mySpeedtd1 == 31, "mySpeedtd1 4 failed"); } { enforce(namedanonTest1(namedanon.NamedAnon2) == namedanon.NamedAnon2, "namedanonTest 1 failed"); } { auto val = twonames.TwoNames2; enforce(twonamesTest1(val) == val, "twonamesTest 1 failed"); enforce(twonamesTest2(val) == val, "twonamesTest 2 failed"); enforce(twonamesTest3(val) == val, "twonamesTest 3 failed"); } { auto t = new TwoNamesStruct(); auto val = TwoNamesStruct.twonames.TwoNamesStruct1; enforce(t.twonamesTest1(val) == val, "twonamesTest 1 failed"); enforce(t.twonamesTest2(val) == val, "twonamesTest 2 failed"); enforce(t.twonamesTest3(val) == val, "twonamesTest 3 failed"); } { auto val = namedanonspace.NamedAnonSpace2; enforce(namedanonspaceTest1(val) == val, "namedanonspaceTest 1 failed"); enforce(namedanonspaceTest2(val) == val, "namedanonspaceTest 2 failed"); enforce(namedanonspaceTest3(val) == val, "namedanonspaceTest 3 failed"); enforce(namedanonspaceTest4(val) == val, "namedanonspaceTest 4 failed"); } { auto t = new TemplateClassInt(); auto galileo = TemplateClassInt.scientists.galileo; enforce(t.scientistsTest1(galileo) == galileo, "scientistsTest 1 failed"); enforce(t.scientistsTest2(galileo) == galileo, "scientistsTest 2 failed"); enforce(t.scientistsTest3(galileo) == galileo, "scientistsTest 3 failed"); enforce(t.scientistsTest4(galileo) == galileo, "scientistsTest 4 failed"); enforce(t.scientistsTest5(galileo) == galileo, "scientistsTest 5 failed"); enforce(t.scientistsTest6(galileo) == galileo, "scientistsTest 6 failed"); enforce(t.scientistsTest7(galileo) == galileo, "scientistsTest 7 failed"); enforce(t.scientistsTest8(galileo) == galileo, "scientistsTest 8 failed"); enforce(t.scientistsTest9(galileo) == galileo, "scientistsTest 9 failed"); // enforce(t.scientistsTestA(galileo) == galileo, "scientistsTest A failed"); enforce(t.scientistsTestB(galileo) == galileo, "scientistsTest B failed"); // enforce(t.scientistsTestC(galileo) == galileo, "scientistsTest C failed"); enforce(t.scientistsTestD(galileo) == galileo, "scientistsTest D failed"); enforce(t.scientistsTestE(galileo) == galileo, "scientistsTest E failed"); enforce(t.scientistsTestF(galileo) == galileo, "scientistsTest F failed"); enforce(t.scientistsTestG(galileo) == galileo, "scientistsTest G failed"); enforce(t.scientistsTestH(galileo) == galileo, "scientistsTest H failed"); enforce(t.scientistsTestI(galileo) == galileo, "scientistsTest I failed"); enforce(t.scientistsTestJ(galileo) == galileo, "scientistsTest J failed"); enforce(scientistsTest1(galileo) == galileo, "scientistsTest Global 1 failed"); enforce(scientistsTest2(galileo) == galileo, "scientistsTest Global 2 failed"); enforce(scientistsTest3(galileo) == galileo, "scientistsTest Global 3 failed"); enforce(scientistsTest4(galileo) == galileo, "scientistsTest Global 4 failed"); enforce(scientistsTest5(galileo) == galileo, "scientistsTest Global 5 failed"); enforce(scientistsTest6(galileo) == galileo, "scientistsTest Global 6 failed"); enforce(scientistsTest7(galileo) == galileo, "scientistsTest Global 7 failed"); enforce(scientistsTest8(galileo) == galileo, "scientistsTest Global 8 failed"); } { auto t = new TClassInt(); auto bell = TClassInt.scientists.bell; auto galileo = TemplateClassInt.scientists.galileo; enforce(t.scientistsNameTest1(bell) == bell, "scientistsNameTest 1 failed"); enforce(t.scientistsNameTest2(bell) == bell, "scientistsNameTest 2 failed"); enforce(t.scientistsNameTest3(bell) == bell, "scientistsNameTest 3 failed"); enforce(t.scientistsNameTest4(bell) == bell, "scientistsNameTest 4 failed"); enforce(t.scientistsNameTest5(bell) == bell, "scientistsNameTest 5 failed"); enforce(t.scientistsNameTest6(bell) == bell, "scientistsNameTest 6 failed"); enforce(t.scientistsNameTest7(bell) == bell, "scientistsNameTest 7 failed"); enforce(t.scientistsNameTest8(bell) == bell, "scientistsNameTest 8 failed"); enforce(t.scientistsNameTest9(bell) == bell, "scientistsNameTest 9 failed"); // enforce(t.scientistsNameTestA(bell) == bell, "scientistsNameTest A failed"); enforce(t.scientistsNameTestB(bell) == bell, "scientistsNameTest B failed"); // enforce(t.scientistsNameTestC(bell) == bell, "scientistsNameTest C failed"); enforce(t.scientistsNameTestD(bell) == bell, "scientistsNameTest D failed"); enforce(t.scientistsNameTestE(bell) == bell, "scientistsNameTest E failed"); enforce(t.scientistsNameTestF(bell) == bell, "scientistsNameTest F failed"); enforce(t.scientistsNameTestG(bell) == bell, "scientistsNameTest G failed"); enforce(t.scientistsNameTestH(bell) == bell, "scientistsNameTest H failed"); enforce(t.scientistsNameTestI(bell) == bell, "scientistsNameTest I failed"); enforce(t.scientistsNameSpaceTest1(bell) == bell, "scientistsNameSpaceTest 1 failed"); enforce(t.scientistsNameSpaceTest2(bell) == bell, "scientistsNameSpaceTest 2 failed"); enforce(t.scientistsNameSpaceTest3(bell) == bell, "scientistsNameSpaceTest 3 failed"); enforce(t.scientistsNameSpaceTest4(bell) == bell, "scientistsNameSpaceTest 4 failed"); enforce(t.scientistsNameSpaceTest5(bell) == bell, "scientistsNameSpaceTest 5 failed"); enforce(t.scientistsNameSpaceTest6(bell) == bell, "scientistsNameSpaceTest 6 failed"); enforce(t.scientistsNameSpaceTest7(bell) == bell, "scientistsNameSpaceTest 7 failed"); enforce(t.scientistsOtherTest1(galileo) == galileo, "scientistsOtherTest 1 failed"); enforce(t.scientistsOtherTest2(galileo) == galileo, "scientistsOtherTest 2 failed"); enforce(t.scientistsOtherTest3(galileo) == galileo, "scientistsOtherTest 3 failed"); enforce(t.scientistsOtherTest4(galileo) == galileo, "scientistsOtherTest 4 failed"); enforce(t.scientistsOtherTest5(galileo) == galileo, "scientistsOtherTest 5 failed"); enforce(t.scientistsOtherTest6(galileo) == galileo, "scientistsOtherTest 6 failed"); enforce(t.scientistsOtherTest7(galileo) == galileo, "scientistsOtherTest 7 failed"); enforce(scientistsNameTest1(bell) == bell, "scientistsNameTest Global 1 failed"); enforce(scientistsNameTest2(bell) == bell, "scientistsNameTest Global 2 failed"); enforce(scientistsNameTest3(bell) == bell, "scientistsNameTest Global 3 failed"); enforce(scientistsNameTest4(bell) == bell, "scientistsNameTest Global 4 failed"); enforce(scientistsNameTest5(bell) == bell, "scientistsNameTest Global 5 failed"); enforce(scientistsNameTest6(bell) == bell, "scientistsNameTest Global 6 failed"); enforce(scientistsNameTest7(bell) == bell, "scientistsNameTest Global 7 failed"); enforce(scientistsNameSpaceTest1(bell) == bell, "scientistsNameSpaceTest Global 1 failed"); enforce(scientistsNameSpaceTest2(bell) == bell, "scientistsNameSpaceTest Global 2 failed"); enforce(scientistsNameSpaceTest3(bell) == bell, "scientistsNameSpaceTest Global 3 failed"); enforce(scientistsNameSpaceTest4(bell) == bell, "scientistsNameSpaceTest Global 4 failed"); enforce(scientistsNameSpaceTest5(bell) == bell, "scientistsNameSpaceTest Global 5 failed"); enforce(scientistsNameSpaceTest6(bell) == bell, "scientistsNameSpaceTest Global 6 failed"); enforce(scientistsNameSpaceTest7(bell) == bell, "scientistsNameSpaceTest Global 7 failed"); enforce(scientistsNameSpaceTest8(bell) == bell, "scientistsNameSpaceTest Global 8 failed"); enforce(scientistsNameSpaceTest9(bell) == bell, "scientistsNameSpaceTest Global 9 failed"); enforce(scientistsNameSpaceTestA(bell) == bell, "scientistsNameSpaceTest Global A failed"); enforce(scientistsNameSpaceTestB(bell) == bell, "scientistsNameSpaceTest Global B failed"); enforce(scientistsNameSpaceTestC(bell) == bell, "scientistsNameSpaceTest Global C failed"); enforce(scientistsNameSpaceTestD(bell) == bell, "scientistsNameSpaceTest Global D failed"); enforce(scientistsNameSpaceTestE(bell) == bell, "scientistsNameSpaceTest Global E failed"); enforce(scientistsNameSpaceTestF(bell) == bell, "scientistsNameSpaceTest Global F failed"); enforce(scientistsNameSpaceTestG(bell) == bell, "scientistsNameSpaceTest Global G failed"); enforce(scientistsNameSpaceTestH(bell) == bell, "scientistsNameSpaceTest Global H failed"); enforce(scientistsNameSpaceTestI(bell) == bell, "scientistsNameSpaceTest Global I failed"); enforce(scientistsNameSpaceTestJ(bell) == bell, "scientistsNameSpaceTest Global J failed"); enforce(scientistsNameSpaceTestK(bell) == bell, "scientistsNameSpaceTest Global K failed"); enforce(scientistsNameSpaceTestL(bell) == bell, "scientistsNameSpaceTest Global L failed"); } { auto val = newname.argh; enforce(renameTest1(val) == val, "renameTest Global 1 failed"); enforce(renameTest2(val) == val, "renameTest Global 2 failed"); } { auto n = new NewNameStruct(); enforce(n.renameTest1(NewNameStruct.enumeration.bang) == NewNameStruct.enumeration.bang, "renameTest 1 failed"); enforce(n.renameTest2(NewNameStruct.enumeration.bang) == NewNameStruct.enumeration.bang, "renameTest 2 failed"); enforce(n.renameTest3(NewNameStruct.simplerenamed.simple1) == NewNameStruct.simplerenamed.simple1, "renameTest 3 failed"); enforce(n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) == NewNameStruct.doublenamerenamed.doublename1, "renameTest 4 failed"); enforce(n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) == NewNameStruct.doublenamerenamed.doublename1, "renameTest 5 failed"); enforce(n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) == NewNameStruct.singlenamerenamed.singlename1, "renameTest 6 failed"); } { enforce(renameTest3(NewNameStruct.enumeration.bang) == NewNameStruct.enumeration.bang, "renameTest Global 3 failed"); enforce(renameTest4(NewNameStruct.simplerenamed.simple1) == NewNameStruct.simplerenamed.simple1, "renameTest Global 4 failed"); enforce(renameTest5(NewNameStruct.doublenamerenamed.doublename1) == NewNameStruct.doublenamerenamed.doublename1, "renameTest Global 5 failed"); enforce(renameTest6(NewNameStruct.doublenamerenamed.doublename1) == NewNameStruct.doublenamerenamed.doublename1, "renameTest Global 6 failed"); enforce(renameTest7(NewNameStruct.singlenamerenamed.singlename1) == NewNameStruct.singlenamerenamed.singlename1, "renameTest Global 7 failed"); } { auto t = new TreesClass(); auto pine = TreesClass.trees.pine; enforce(t.treesTest1(pine) == pine, "treesTest 1 failed"); enforce(t.treesTest2(pine) == pine, "treesTest 2 failed"); enforce(t.treesTest3(pine) == pine, "treesTest 3 failed"); enforce(t.treesTest4(pine) == pine, "treesTest 4 failed"); enforce(t.treesTest5(pine) == pine, "treesTest 5 failed"); enforce(t.treesTest6(pine) == pine, "treesTest 6 failed"); enforce(t.treesTest7(pine) == pine, "treesTest 7 failed"); enforce(t.treesTest8(pine) == pine, "treesTest 8 failed"); enforce(t.treesTest9(pine) == pine, "treesTest 9 failed"); enforce(t.treesTestA(pine) == pine, "treesTest A failed"); enforce(t.treesTestB(pine) == pine, "treesTest B failed"); enforce(t.treesTestC(pine) == pine, "treesTest C failed"); enforce(t.treesTestD(pine) == pine, "treesTest D failed"); enforce(t.treesTestE(pine) == pine, "treesTest E failed"); enforce(t.treesTestF(pine) == pine, "treesTest F failed"); enforce(t.treesTestG(pine) == pine, "treesTest G failed"); enforce(t.treesTestH(pine) == pine, "treesTest H failed"); enforce(t.treesTestI(pine) == pine, "treesTest I failed"); enforce(t.treesTestJ(pine) == pine, "treesTest J failed"); enforce(t.treesTestK(pine) == pine, "treesTest K failed"); enforce(t.treesTestL(pine) == pine, "treesTest L failed"); enforce(t.treesTestM(pine) == pine, "treesTest M failed"); enforce(t.treesTestN(pine) == pine, "treesTest N failed"); enforce(t.treesTestO(pine) == pine, "treesTest O failed"); enforce(treesTest1(pine) == pine, "treesTest Global 1 failed"); enforce(treesTest2(pine) == pine, "treesTest Global 2 failed"); enforce(treesTest3(pine) == pine, "treesTest Global 3 failed"); enforce(treesTest4(pine) == pine, "treesTest Global 4 failed"); enforce(treesTest5(pine) == pine, "treesTest Global 5 failed"); enforce(treesTest6(pine) == pine, "treesTest Global 6 failed"); enforce(treesTest7(pine) == pine, "treesTest Global 7 failed"); enforce(treesTest8(pine) == pine, "treesTest Global 8 failed"); enforce(treesTest9(pine) == pine, "treesTest Global 9 failed"); enforce(treesTestA(pine) == pine, "treesTest Global A failed"); enforce(treesTestB(pine) == pine, "treesTest Global B failed"); enforce(treesTestC(pine) == pine, "treesTest Global C failed"); enforce(treesTestD(pine) == pine, "treesTest Global D failed"); enforce(treesTestE(pine) == pine, "treesTest Global E failed"); enforce(treesTestF(pine) == pine, "treesTest Global F failed"); enforce(treesTestG(pine) == pine, "treesTest Global G failed"); enforce(treesTestH(pine) == pine, "treesTest Global H failed"); enforce(treesTestI(pine) == pine, "treesTest Global I failed"); enforce(treesTestJ(pine) == pine, "treesTest Global J failed"); enforce(treesTestK(pine) == pine, "treesTest Global K failed"); enforce(treesTestL(pine) == pine, "treesTest Global L failed"); enforce(treesTestM(pine) == pine, "treesTest Global M failed"); // enforce(treesTestN(pine) == pine, "treesTest Global N failed"); enforce(treesTestO(pine) == pine, "treesTest Global O failed"); enforce(treesTestP(pine) == pine, "treesTest Global P failed"); enforce(treesTestQ(pine) == pine, "treesTest Global Q failed"); enforce(treesTestR(pine) == pine, "treesTest Global R failed"); } { auto h = new HairStruct(); auto ginger = HairStruct.hair.ginger; enforce(h.hairTest1(ginger) == ginger, "hairTest 1 failed"); enforce(h.hairTest2(ginger) == ginger, "hairTest 2 failed"); enforce(h.hairTest3(ginger) == ginger, "hairTest 3 failed"); enforce(h.hairTest4(ginger) == ginger, "hairTest 4 failed"); enforce(h.hairTest5(ginger) == ginger, "hairTest 5 failed"); enforce(h.hairTest6(ginger) == ginger, "hairTest 6 failed"); enforce(h.hairTest7(ginger) == ginger, "hairTest 7 failed"); enforce(h.hairTest8(ginger) == ginger, "hairTest 8 failed"); enforce(h.hairTest9(ginger) == ginger, "hairTest 9 failed"); enforce(h.hairTestA(ginger) == ginger, "hairTest A failed"); enforce(h.hairTestB(ginger) == ginger, "hairTest B failed"); auto red = colour.red; enforce(h.colourTest1(red) == red, "colourTest HairStruct 1 failed"); enforce(h.colourTest2(red) == red, "colourTest HairStruct 2 failed"); enforce(h.namedanonTest1(namedanon.NamedAnon2) == namedanon.NamedAnon2, "namedanonTest HairStruct 1 failed"); enforce(h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) == namedanonspace.NamedAnonSpace2, "namedanonspaceTest HairStruct 1 failed"); auto fir = TreesClass.trees.fir; enforce(h.treesGlobalTest1(fir) == fir, "treesGlobalTest1 HairStruct 1 failed"); enforce(h.treesGlobalTest2(fir) == fir, "treesGlobalTest1 HairStruct 2 failed"); enforce(h.treesGlobalTest3(fir) == fir, "treesGlobalTest1 HairStruct 3 failed"); enforce(h.treesGlobalTest4(fir) == fir, "treesGlobalTest1 HairStruct 4 failed"); } { auto blonde = HairStruct.hair.blonde; enforce(hairTest1(blonde) == blonde, "hairTest Global 1 failed"); enforce(hairTest2(blonde) == blonde, "hairTest Global 2 failed"); enforce(hairTest3(blonde) == blonde, "hairTest Global 3 failed"); enforce(hairTest4(blonde) == blonde, "hairTest Global 4 failed"); enforce(hairTest5(blonde) == blonde, "hairTest Global 5 failed"); enforce(hairTest6(blonde) == blonde, "hairTest Global 6 failed"); enforce(hairTest7(blonde) == blonde, "hairTest Global 7 failed"); enforce(hairTest8(blonde) == blonde, "hairTest Global 8 failed"); enforce(hairTest9(blonde) == blonde, "hairTest Global 9 failed"); enforce(hairTestA(blonde) == blonde, "hairTest Global A failed"); enforce(hairTestB(blonde) == blonde, "hairTest Global B failed"); enforce(hairTestC(blonde) == blonde, "hairTest Global C failed"); enforce(hairTestA1(blonde) == blonde, "hairTest Global A1 failed"); enforce(hairTestA2(blonde) == blonde, "hairTest Global A2 failed"); enforce(hairTestA3(blonde) == blonde, "hairTest Global A3 failed"); enforce(hairTestA4(blonde) == blonde, "hairTest Global A4 failed"); enforce(hairTestA5(blonde) == blonde, "hairTest Global A5 failed"); enforce(hairTestA6(blonde) == blonde, "hairTest Global A6 failed"); enforce(hairTestA7(blonde) == blonde, "hairTest Global A7 failed"); enforce(hairTestA8(blonde) == blonde, "hairTest Global A8 failed"); enforce(hairTestA9(blonde) == blonde, "hairTest Global A9 failed"); enforce(hairTestAA(blonde) == blonde, "hairTest Global AA failed"); enforce(hairTestAB(blonde) == blonde, "hairTest Global AB failed"); enforce(hairTestAC(blonde) == blonde, "hairTest Global AC failed"); enforce(hairTestB1(blonde) == blonde, "hairTest Global B1 failed"); enforce(hairTestB2(blonde) == blonde, "hairTest Global B2 failed"); enforce(hairTestB3(blonde) == blonde, "hairTest Global B3 failed"); enforce(hairTestB4(blonde) == blonde, "hairTest Global B4 failed"); enforce(hairTestB5(blonde) == blonde, "hairTest Global B5 failed"); enforce(hairTestB6(blonde) == blonde, "hairTest Global B6 failed"); enforce(hairTestB7(blonde) == blonde, "hairTest Global B7 failed"); enforce(hairTestB8(blonde) == blonde, "hairTest Global B8 failed"); enforce(hairTestB9(blonde) == blonde, "hairTest Global B9 failed"); enforce(hairTestBA(blonde) == blonde, "hairTest Global BA failed"); enforce(hairTestBB(blonde) == blonde, "hairTest Global BB failed"); enforce(hairTestBC(blonde) == blonde, "hairTest Global BC failed"); enforce(hairTestC1(blonde) == blonde, "hairTest Global C1 failed"); enforce(hairTestC2(blonde) == blonde, "hairTest Global C2 failed"); enforce(hairTestC3(blonde) == blonde, "hairTest Global C3 failed"); enforce(hairTestC4(blonde) == blonde, "hairTest Global C4 failed"); enforce(hairTestC5(blonde) == blonde, "hairTest Global C5 failed"); enforce(hairTestC6(blonde) == blonde, "hairTest Global C6 failed"); enforce(hairTestC7(blonde) == blonde, "hairTest Global C7 failed"); enforce(hairTestC8(blonde) == blonde, "hairTest Global C8 failed"); enforce(hairTestC9(blonde) == blonde, "hairTest Global C9 failed"); enforce(hairTestCA(blonde) == blonde, "hairTest Global CA failed"); enforce(hairTestCB(blonde) == blonde, "hairTest Global CB failed"); enforce(hairTestCC(blonde) == blonde, "hairTest Global CC failed"); } { auto f = new FirStruct(); auto blonde = HairStruct.hair.blonde; enforce(f.hairTestFir1(blonde) == blonde, "hairTestFir 1 failed"); enforce(f.hairTestFir2(blonde) == blonde, "hairTestFir 2 failed"); enforce(f.hairTestFir3(blonde) == blonde, "hairTestFir 3 failed"); enforce(f.hairTestFir4(blonde) == blonde, "hairTestFir 4 failed"); enforce(f.hairTestFir5(blonde) == blonde, "hairTestFir 5 failed"); enforce(f.hairTestFir6(blonde) == blonde, "hairTestFir 6 failed"); enforce(f.hairTestFir7(blonde) == blonde, "hairTestFir 7 failed"); enforce(f.hairTestFir8(blonde) == blonde, "hairTestFir 8 failed"); enforce(f.hairTestFir9(blonde) == blonde, "hairTestFir 9 failed"); enforce(f.hairTestFirA(blonde) == blonde, "hairTestFir A failed"); } { GlobalInstance = globalinstance2; enforce(GlobalInstance == globalinstance2, "GlobalInstance 1 failed"); auto i = new Instances(); i.MemberInstance = Instances.memberinstance3; enforce(i.MemberInstance == Instances.memberinstance3, "MemberInstance 1 failed"); } // ignore enum item tests start { enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) == 0, "ignoreATest 0 failed"); enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) == 3, "ignoreATest 3 failed"); enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) == 10, "ignoreATest 10 failed"); enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) == 11, "ignoreATest 11 failed"); enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) == 13, "ignoreATest 13 failed"); enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) == 14, "ignoreATest 14 failed"); enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) == 20, "ignoreATest 20 failed"); enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) == 30, "ignoreATest 30 failed"); enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) == 32, "ignoreATest 32 failed"); enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) == 33, "ignoreATest 33 failed"); } { enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) == 11, "ignoreBTest 11 failed"); enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) == 12, "ignoreBTest 12 failed"); enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) == 31, "ignoreBTest 31 failed"); enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) == 32, "ignoreBTest 32 failed"); enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) == 41, "ignoreBTest 41 failed"); enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) == 42, "ignoreBTest 42 failed"); } { enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten), "ignoreCTest 10 failed"); enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) == 12, "ignoreCTest 12 failed"); enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) == 30, "ignoreCTest 30 failed"); enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) == 32, "ignoreCTest 32 failed"); enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) == 40, "ignoreCTest 40 failed"); enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) == 42, "ignoreCTest 42 failed"); } { enforce(cast(int)ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) == 21, "ignoreDTest 21 failed"); enforce(cast(int)ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) == 22, "ignoreDTest 22 failed"); } { enforce(cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) == 0, "ignoreETest 0 failed"); enforce(cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) == 21, "ignoreETest 21 failed"); enforce(cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) == 22, "ignoreETest 22 failed"); } // ignore enum item tests end { enforce(cast(int)repeatTest(repeat.one) == 1, "repeatTest 1 failed"); enforce(cast(int)repeatTest(repeat.initial) == 1, "repeatTest 2 failed"); enforce(cast(int)repeatTest(repeat.two) == 2, "repeatTest 3 failed"); enforce(cast(int)repeatTest(repeat.three) == 3, "repeatTest 4 failed"); enforce(cast(int)repeatTest(repeat.llast) == 3, "repeatTest 5 failed"); enforce(cast(int)repeatTest(repeat.end) == 3, "repeatTest 6 failed"); } // different types { enforce(cast(int)differentTypesTest(DifferentTypes.typeint) == 10, "differentTypes 1 failed"); enforce(cast(int)differentTypesTest(DifferentTypes.typeboolfalse) == 0, "differentTypes 2 failed"); enforce(cast(int)differentTypesTest(DifferentTypes.typebooltrue) == 1, "differentTypes 3 failed"); enforce(cast(int)differentTypesTest(DifferentTypes.typebooltwo) == 2, "differentTypes 4 failed"); enforce(cast(int)differentTypesTest(DifferentTypes.typechar) == 'C', "differentTypes 5 failed"); enforce(cast(int)differentTypesTest(DifferentTypes.typedefaultint) == 'D', "differentTypes 6 failed"); int global_enum = global_typeint; enforce(cast(int)globalDifferentTypesTest(global_enum) == 10, "global differentTypes 1 failed"); global_enum = global_typeboolfalse; enforce(cast(int)globalDifferentTypesTest(global_enum) == 0, "global differentTypes 2 failed"); global_enum = global_typebooltrue; enforce(cast(int)globalDifferentTypesTest(global_enum) == 1, "global differentTypes 3 failed"); global_enum = global_typebooltwo; enforce(cast(int)globalDifferentTypesTest(global_enum) == 2, "global differentTypes 4 failed"); global_enum = global_typechar; enforce(cast(int)globalDifferentTypesTest(global_enum) == 'C', "global differentTypes 5 failed"); global_enum = global_typedefaultint; enforce(cast(int)globalDifferentTypesTest(global_enum) == 'D', "global differentTypes 6 failed"); } } swig-3.0.2/Examples/test-suite/d/nspace_extend_runme.1.d0000664000175000017500000000150612343605122023006 0ustar williamwilliammodule nspace_extend_runme; static import oi1c = nspace_extend.Outer.Inner1.Color; static import oi2c = nspace_extend.Outer.Inner2.Color; void main() { { // constructors and destructors scope color1 = new oi1c.Color(); scope color = new oi1c.Color(color1); // class methods color.colorInstanceMethod(20.0); oi1c.Color.colorStaticMethod(20.0); auto created = oi1c.Color.create(); } { // constructors and destructors scope color2 = new oi2c.Color(); scope color = new oi2c.Color(color2); // class methods color.colorInstanceMethod(20.0); oi2c.Color.colorStaticMethod(20.0); auto created = oi2c.Color.create(); // Same class different namespaces auto col1 = new oi1c.Color(); auto col2 = oi2c.Color.create(); col2.colors(col1, col1, col2, col2, col2); } } swig-3.0.2/Examples/test-suite/d/li_std_vector_runme.1.d0000664000175000017500000001225612343605122023032 0ustar williamwilliammodule li_std_vector_runme; import tango.core.Exception; import tango.io.Stdout; import Integer = tango.text.convert.Integer; import li_std_vector.li_std_vector; import li_std_vector.DoubleVector; import li_std_vector.IntVector; import li_std_vector.IntPtrVector; import li_std_vector.IntConstPtrVector; import li_std_vector.RealVector; import li_std_vector.Struct; import li_std_vector.StructVector; import li_std_vector.StructPtrVector; import li_std_vector.StructConstPtrVector; const size_t SIZE = 20; void main() { // Basic functionality tests. { auto vector = new IntVector(); for (size_t i = 0; i < SIZE; ++i) { vector ~= i * 10; } if (vector.length != SIZE) { throw new Exception("length test failed."); } vector[0] = 200; if (vector[0] != 200) { throw new Exception("indexing test failed"); } vector[0] = 0 * 10; try { vector[vector.length] = 777; throw new Exception("out of range test failed"); } catch (NoSuchElementException) { } foreach (i, value; vector) { if (value != (i * 10)) { throw new Exception("foreach test failed, i: " ~ Integer.toString(i)); } } vector.clear(); if (vector.size != 0) { throw new Exception("clear test failed"); } } // Slice tests. { auto dVector = new DoubleVector(); for (size_t i = 0; i < SIZE; ++i) { dVector ~= i * 10.1f; } double[] dArray = dVector[]; foreach (i, value; dArray) { if (dVector[i] != value) { throw new Exception("slice test 1 failed, i: " ~ Integer.toString(i)); } } auto sVector = new StructVector(); for (size_t i = 0; i < SIZE; i++) { sVector ~= new Struct(i / 10.0); } Struct[] array = sVector[]; for (size_t i = 0; i < SIZE; i++) { // Make sure that a shallow copy has been made. void* aPtr = Struct.swigGetCPtr(array[i]); void* vPtr = Struct.swigGetCPtr(sVector[i]); if (aPtr != vPtr) { throw new Exception("slice test 2 failed, i: " ~ Integer.toString(i)); } } } // remove() tests. { auto iVector = new IntVector(); for (int i = 0; i < SIZE; i++) { iVector ~= i; } iVector.remove(iVector.length - 1); iVector.remove(SIZE / 2); iVector.remove(0); try { iVector.remove(iVector.size); throw new Exception("remove test failed"); } catch (NoSuchElementException) { } } // Capacity tests. { auto dv = new DoubleVector(10); if ((dv.capacity != 10) || (dv.length != 0)) { throw new Exception("constructor setting capacity test failed"); } // TODO: Is this really required (and spec'ed) behavior? dv.capacity = 20; if (dv.capacity != 20) { throw new Exception("capacity test 1 failed"); } dv ~= 1.11; try { dv.capacity = dv.length - 1; throw new Exception("capacity test 2 failed"); } catch (IllegalArgumentException) { } } // Test the methods being wrapped. { auto iv = new IntVector(); for (int i=0; i<4; i++) { iv ~= i; } double x = average(iv); x += average(new IntVector([1, 2, 3, 4])); RealVector rv = half(new RealVector([10.0f, 10.5f, 11.0f, 11.5f])); auto dv = new DoubleVector(); for (size_t i = 0; i < SIZE; i++) { dv ~= i / 2.0; } halve_in_place(dv); RealVector v0 = vecreal(new RealVector()); float flo = 123.456f; v0 ~= flo; flo = v0[0]; IntVector v1 = vecintptr(new IntVector()); IntPtrVector v2 = vecintptr(new IntPtrVector()); IntConstPtrVector v3 = vecintconstptr(new IntConstPtrVector()); v1 ~= 123; v2.clear(); v3.clear(); StructVector v4 = vecstruct(new StructVector()); StructPtrVector v5 = vecstructptr(new StructPtrVector()); StructConstPtrVector v6 = vecstructconstptr(new StructConstPtrVector()); v4 ~= new Struct(123); v5 ~= new Struct(123); v6 ~= new Struct(123); } // Test vectors of pointers. { auto vector = new StructPtrVector(); for (size_t i = 0; i < SIZE; i++) { vector ~= new Struct(i / 10.0); } Struct[] array = vector[]; for (size_t i = 0; i < SIZE; i++) { // Make sure that a shallow copy has been made. void* aPtr = Struct.swigGetCPtr(array[i]); void* vPtr = Struct.swigGetCPtr(vector[i]); if (aPtr != vPtr) { throw new Exception("StructPtrVector test 1 failed, i: " ~ Integer.toString(i)); } } } // Test vectors of const pointers. { auto vector = new StructConstPtrVector(); for (size_t i = 0; i < SIZE; i++) { vector ~= new Struct(i / 10.0); } Struct[] array = vector[]; for (size_t i = 0; i < SIZE; i++) { // Make sure that a shallow copy has been made. void* aPtr = Struct.swigGetCPtr(array[i]); void* vPtr = Struct.swigGetCPtr(vector[i]); if (aPtr != vPtr) { throw new Exception("StructConstPtrVector test 1 failed, i: " ~ Integer.toString(i)); } } } // Test vectors destroyed via dispose(). { { scope vector = new StructVector(); vector ~= new Struct(0.0); vector ~= new Struct(11.1); } { scope vector = new DoubleVector(); vector ~= 0.0; vector ~= 11.1; } } } swig-3.0.2/Examples/test-suite/d/throw_exception_runme.1.d0000664000175000017500000000106412343605122023406 0ustar williamwilliammodule throw_exception_runme; import throw_exception.Foo; void main() { test!("test_int"); test!("test_msg"); test!("test_cls"); test!("test_cls_ptr"); test!("test_cls_ref"); test!("test_cls_td"); test!("test_cls_ptr_td"); test!("test_cls_ref_td"); test!("test_array"); test!("test_enum"); } void test(char[] methodName)() { auto foo = new Foo(); bool didntThrow; try { mixin("foo." ~ methodName ~ "();"); didntThrow = true; } catch (Exception) {} if (didntThrow) { throw new Exception(methodName ~ " failed"); } } swig-3.0.2/Examples/test-suite/d/long_long_runme.2.d0000664000175000017500000000153112343605122022143 0ustar williamwilliam// Checks if the long long and unsigned long long types work. module long_long_runme; import std.conv; import std.exception; import long_long.long_long; void main() { check_ll(0L); check_ll(0x7FFFFFFFFFFFFFFFL); check_ll(-10L); check_ull(0u); check_ull(127u); check_ull(128u); check_ull(9223372036854775807u); //0x7FFFFFFFFFFFFFFFL check_ull(18446744073709551615u); //0xFFFFFFFFFFFFFFFFL } void check_ll(long value) { ll = value; long value_check = ll; enforce(value == value_check, "Runtime test using long long failed: expected: " ~ to!string(value) ~ ", got: " ~ to!string(value_check)); } void check_ull(ulong value) { ull = value; ulong value_check = ull; enforce(value == value_check, "Runtime test using unsigned long long failed: expected: " ~ to!string(value) ~ ", ll_check=" ~ to!string(value_check)); } swig-3.0.2/Examples/test-suite/d/li_std_vector_runme.2.d0000664000175000017500000001237212343605122023032 0ustar williamwilliammodule li_std_vector_runme; import std.algorithm; import std.array; import std.conv; import std.exception; import std.stdio; import li_std_vector.li_std_vector; import li_std_vector.DoubleVector; import li_std_vector.IntVector; import li_std_vector.IntPtrVector; import li_std_vector.IntConstPtrVector; import li_std_vector.RealVector; import li_std_vector.Struct; import li_std_vector.StructVector; import li_std_vector.StructPtrVector; import li_std_vector.StructConstPtrVector; const size_t SIZE = 20; void main() { // Basic functionality tests. { auto vector = new IntVector(); foreach (int i; 0 .. SIZE) { vector ~= i * 10; } enforce(vector.length == SIZE, "length test failed."); vector[0] = 200; enforce(vector[0] == 200, "indexing test failed"); vector[0] = 0 * 10; enforceThrows((){ vector[vector.length] = 777; }, "out of range test failed" ); foreach (i, value; vector) { enforce(value == (i * 10), "foreach test failed, i: " ~ to!string(i)); } enforce(canFind!`a == 0 * 10`(vector[]), "canFind test 1 failed"); enforce(canFind!`a == 10 * 10`(vector[]), "canFind test 2 failed"); enforce(canFind!`a == 19 * 10`(vector[]), "canFind test 3 failed"); enforce(!canFind!`a == 20 * 10`(vector[]), "canFind test 4 failed"); foreach (i, _; vector) { enforce(countUntil(vector[], i * 10) == i, "indexOf test failed, i: " ~ to!string(i)); } enforce(countUntil(vector[], 42) == -1, "non-existant item indexOf test failed"); vector.clear(); enforce(vector.length == 0, "clear test failed"); } // To array conversion tests. { auto dVector = new DoubleVector(); foreach (i; 0 .. SIZE) { dVector ~= i * 10.1f; } double[] dArray = array(dVector[]); foreach (i, value; dArray) { enforce(dVector[i] == value, "slice test 1 failed, i: " ~ to!string(i)); } auto sVector = new StructVector(); foreach (i; 0 .. SIZE) { sVector ~= new Struct(i / 10.0); } Struct[] sArray = array(sVector[]); foreach (i; 0 .. SIZE) { // Make sure that a shallow copy has been made. void* aPtr = Struct.swigGetCPtr(sArray[i]); void* vPtr = Struct.swigGetCPtr(sVector[i]); enforce(aPtr == vPtr, "slice test 2 failed, i: " ~ to!string(i)); } } // remove() tests. { auto iVector = new IntVector(); foreach (int i; 0 .. SIZE) { iVector ~= i; } iVector.remove(iVector.length - 1); iVector.remove(SIZE / 2); iVector.remove(0); enforceThrows((){ iVector.remove(iVector.length); }, "remove test failed"); } // Capacity tests. { auto dv = new DoubleVector(10); enforce(dv.capacity == 10, "constructor setting capacity test failed (1)"); enforce(dv.length == 0, "constructor setting capacity test failed (1)"); dv.reserve(20); enforce(dv.capacity == 20, "capacity test failed"); } // Test the methods being wrapped. { auto iv = new IntVector(); foreach (int i; 0 .. 4) { iv ~= i; } double x = average(iv); x += average(new IntVector([1, 2, 3, 4])); RealVector rv = half(new RealVector([10.0f, 10.5f, 11.0f, 11.5f])); auto dv = new DoubleVector(); foreach (i; 0 .. SIZE) { dv ~= i / 2.0; } halve_in_place(dv); RealVector v0 = vecreal(new RealVector()); float flo = 123.456f; v0 ~= flo; flo = v0[0]; IntVector v1 = vecintptr(new IntVector()); IntPtrVector v2 = vecintptr(new IntPtrVector()); IntConstPtrVector v3 = vecintconstptr(new IntConstPtrVector()); v1 ~= 123; v2.clear(); v3.clear(); StructVector v4 = vecstruct(new StructVector()); StructPtrVector v5 = vecstructptr(new StructPtrVector()); StructConstPtrVector v6 = vecstructconstptr(new StructConstPtrVector()); v4 ~= new Struct(123); v5 ~= new Struct(123); v6 ~= new Struct(123); } // Test vectors of pointers. { auto vector = new StructPtrVector(); foreach (i; 0 .. SIZE) { vector ~= new Struct(i / 10.0); } Struct[] array = array(vector[]); foreach (i; 0 .. SIZE) { // Make sure that a shallow copy has been made. void* aPtr = Struct.swigGetCPtr(array[i]); void* vPtr = Struct.swigGetCPtr(vector[i]); enforce(aPtr == vPtr, "StructConstPtrVector test 1 failed, i: " ~ to!string(i)); } } // Test vectors of const pointers. { auto vector = new StructConstPtrVector(); foreach (i; 0 .. SIZE) { vector ~= new Struct(i / 10.0); } Struct[] array = array(vector[]); foreach (i; 0 .. SIZE) { // Make sure that a shallow copy has been made. void* aPtr = Struct.swigGetCPtr(array[i]); void* vPtr = Struct.swigGetCPtr(vector[i]); enforce(aPtr == vPtr, "StructConstPtrVector test 1 failed, i: " ~ to!string(i)); } } // Test vectors destroyed via scope. { { scope vector = new StructVector(); vector ~= new Struct(0.0); vector ~= new Struct(11.1); } { scope vector = new DoubleVector(); vector ~= 0.0; vector ~= 11.1; } } } private void enforceThrows(void delegate() dg, string errorMessage) { bool hasThrown; try { dg(); } catch (Exception) { hasThrown = true; } finally { if (!hasThrown) { throw new Exception(errorMessage); } } } swig-3.0.2/Examples/test-suite/d/li_boost_shared_ptr_runme.1.d0000664000175000017500000004143612343605122024221 0ustar williamwilliammodule li_boost_shared_ptr_runme; import tango.io.Stdout; import tango.core.Exception; import tango.core.Memory; import tango.core.Thread; import tango.text.convert.Integer; import li_boost_shared_ptr.li_boost_shared_ptr; import li_boost_shared_ptr.Klass; import li_boost_shared_ptr.KlassDerived; import li_boost_shared_ptr.Klass3rdDerived; import li_boost_shared_ptr.MemberVariables; import li_boost_shared_ptr.PairIntDouble; // Debugging flag const bool TRACE = false; void main() { if (TRACE) Stdout("---> STARTED <---").newline; debug_shared=TRACE; // Change loop count to run for a long time to monitor memory const int LOOP_COUNT = 1; // 50000; for (int i = 0; i < LOOP_COUNT; ++i) { runTest(); GC.collect(); } if (TRACE) Stdout("---> NEARLY FINISHED <---").newline; // Try to get the GC to collect everything not referenced anymore. int countdown = 100; while (--countdown) { GC.collect(); if (Klass.getTotal_count() == 1) break; Thread.sleep(0.01); } // A single remaining instance expected: the global variable (GlobalValue). if (Klass.getTotal_count() != 1) throw new Exception("Klass.total_count=" ~ toString(Klass.getTotal_count())); // A single remaining instance expected: the global variable (GlobalSmartValue). int wrapper_count = shared_ptr_wrapper_count(); if (wrapper_count != NOT_COUNTING) if (wrapper_count != 1) throw new Exception("shared_ptr wrapper count=" ~ toString(wrapper_count)); if (TRACE) Stdout("---> FINISHED <---").newline; } void runTest() { // simple shared_ptr usage - created in C++ { auto k = new Klass("me oh my"); char[] val = k.getValue(); verifyValue("me oh my", val); verifyCount(1, k); } // simple shared_ptr usage - not created in C++ { auto k = factorycreate(); char[] val = k.getValue(); verifyValue("factorycreate", val); verifyCount(1, k); } // pass by shared_ptr { auto k = new Klass("me oh my"); auto kret = smartpointertest(k); char[] val = kret.getValue(); verifyValue("me oh my smartpointertest", val); verifyCount(2, k); verifyCount(2, kret); } // pass by shared_ptr pointer { auto k = new Klass("me oh my"); auto kret = smartpointerpointertest(k); char[] val = kret.getValue(); verifyValue("me oh my smartpointerpointertest", val); verifyCount(2, k); verifyCount(2, kret); } // pass by shared_ptr reference { auto k = new Klass("me oh my"); auto kret = smartpointerreftest(k); char[] val = kret.getValue(); verifyValue("me oh my smartpointerreftest", val); verifyCount(2, k); verifyCount(2, kret); } // pass by shared_ptr pointer reference { auto k = new Klass("me oh my"); auto kret = smartpointerpointerreftest(k); char[] val = kret.getValue(); verifyValue("me oh my smartpointerpointerreftest", val); verifyCount(2, k); verifyCount(2, kret); } // const pass by shared_ptr { auto k = new Klass("me oh my"); auto kret = constsmartpointertest(k); char[] val = kret.getValue(); verifyValue("me oh my", val); verifyCount(2, k); verifyCount(2, kret); } // const pass by shared_ptr pointer { auto k = new Klass("me oh my"); auto kret = constsmartpointerpointertest(k); char[] val = kret.getValue(); verifyValue("me oh my", val); verifyCount(2, k); verifyCount(2, kret); } // const pass by shared_ptr reference { auto k = new Klass("me oh my"); auto kret = constsmartpointerreftest(k); char[] val = kret.getValue(); verifyValue("me oh my", val); verifyCount(2, k); verifyCount(2, kret); } // pass by value { auto k = new Klass("me oh my"); auto kret = valuetest(k); char[] val = kret.getValue(); verifyValue("me oh my valuetest", val); verifyCount(1, k); verifyCount(1, kret); } // pass by pointer { auto k = new Klass("me oh my"); auto kret = pointertest(k); char[] val = kret.getValue(); verifyValue("me oh my pointertest", val); verifyCount(1, k); verifyCount(1, kret); } // pass by reference { auto k = new Klass("me oh my"); auto kret = reftest(k); char[] val = kret.getValue(); verifyValue("me oh my reftest", val); verifyCount(1, k); verifyCount(1, kret); } // pass by pointer reference { auto k = new Klass("me oh my"); auto kret = pointerreftest(k); char[] val = kret.getValue(); verifyValue("me oh my pointerreftest", val); verifyCount(1, k); verifyCount(1, kret); } // null tests { Klass k = null; // TODO: add in const versions too if (smartpointertest(k) !is null) throw new Exception("return was not null"); if (smartpointerpointertest(k) !is null) throw new Exception("return was not null"); if (smartpointerreftest(k) !is null) throw new Exception("return was not null"); if (smartpointerpointerreftest(k) !is null) throw new Exception("return was not null"); if (nullsmartpointerpointertest(null) != "null pointer") throw new Exception("not null smartpointer pointer"); try { valuetest(k); throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {} if (pointertest(k) !is null) throw new Exception("return was not null"); try { reftest(k); throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {} } // $owner { auto k = pointerownertest(); char[] val = k.getValue(); verifyValue("pointerownertest", val); verifyCount(1, k); } { auto k = smartpointerpointerownertest(); char[] val = k.getValue(); verifyValue("smartpointerpointerownertest", val); verifyCount(1, k); } ////////////////////////////////// Derived classes //////////////////////////////////////// // derived pass by shared_ptr { auto k = new KlassDerived("me oh my"); auto kret = derivedsmartptrtest(k); char[] val = kret.getValue(); verifyValue("me oh my derivedsmartptrtest-Derived", val); verifyCount(4, k); // includes two extra references for upcasts in the proxy classes verifyCount(4, kret); } // derived pass by shared_ptr pointer { auto k = new KlassDerived("me oh my"); auto kret = derivedsmartptrpointertest(k); char[] val = kret.getValue(); verifyValue("me oh my derivedsmartptrpointertest-Derived", val); verifyCount(4, k); // includes two extra references for upcasts in the proxy classes verifyCount(4, kret); } // derived pass by shared_ptr ref { auto k = new KlassDerived("me oh my"); auto kret = derivedsmartptrreftest(k); char[] val = kret.getValue(); verifyValue("me oh my derivedsmartptrreftest-Derived", val); verifyCount(4, k); // includes two extra references for upcasts in the proxy classes verifyCount(4, kret); } // derived pass by shared_ptr pointer ref { auto k = new KlassDerived("me oh my"); auto kret = derivedsmartptrpointerreftest(k); char[] val = kret.getValue(); verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val); verifyCount(4, k); // includes two extra references for upcasts in the proxy classes verifyCount(4, kret); } // derived pass by pointer { auto k = new KlassDerived("me oh my"); auto kret = derivedpointertest(k); char[] val = kret.getValue(); verifyValue("me oh my derivedpointertest-Derived", val); verifyCount(2, k); // includes an extra reference for the upcast in the proxy class verifyCount(2, kret); } // derived pass by ref { auto k = new KlassDerived("me oh my"); auto kret = derivedreftest(k); char[] val = kret.getValue(); verifyValue("me oh my derivedreftest-Derived", val); verifyCount(2, k); // includes an extra reference for the upcast in the proxy class verifyCount(2, kret); } ////////////////////////////////// Derived and base class mixed //////////////////////////////////////// // pass by shared_ptr (mixed) { auto k = new KlassDerived("me oh my"); auto kret = smartpointertest(k); char[] val = kret.getValue(); verifyValue("me oh my smartpointertest-Derived", val); verifyCount(3, k); // an extra reference for the upcast in the proxy class verifyCount(3, kret); } // pass by shared_ptr pointer (mixed) { auto k = new KlassDerived("me oh my"); auto kret = smartpointerpointertest(k); char[] val = kret.getValue(); verifyValue("me oh my smartpointerpointertest-Derived", val); verifyCount(3, k); // an extra reference for the upcast in the proxy class verifyCount(3, kret); } // pass by shared_ptr reference (mixed) { auto k = new KlassDerived("me oh my"); auto kret = smartpointerreftest(k); char[] val = kret.getValue(); verifyValue("me oh my smartpointerreftest-Derived", val); verifyCount(3, k); // an extra reference for the upcast in the proxy class verifyCount(3, kret); } // pass by shared_ptr pointer reference (mixed) { auto k = new KlassDerived("me oh my"); auto kret = smartpointerpointerreftest(k); char[] val = kret.getValue(); verifyValue("me oh my smartpointerpointerreftest-Derived", val); verifyCount(3, k); // an extra reference for the upcast in the proxy class verifyCount(3, kret); } // pass by value (mixed) { auto k = new KlassDerived("me oh my"); auto kret = valuetest(k); char[] val = kret.getValue(); verifyValue("me oh my valuetest", val); // note slicing verifyCount(2, k); // an extra reference for the upcast in the proxy class verifyCount(1, kret); } // pass by pointer (mixed) { auto k = new KlassDerived("me oh my"); auto kret = pointertest(k); char[] val = kret.getValue(); verifyValue("me oh my pointertest-Derived", val); verifyCount(2, k); // an extra reference for the upcast in the proxy class verifyCount(1, kret); } // pass by ref (mixed) { auto k = new KlassDerived("me oh my"); auto kret = reftest(k); char[] val = kret.getValue(); verifyValue("me oh my reftest-Derived", val); verifyCount(2, k); // an extra reference for the upcast in the proxy class verifyCount(1, kret); } // 3rd derived class { auto k = new Klass3rdDerived("me oh my"); char[] val = k.getValue(); verifyValue("me oh my-3rdDerived", val); verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values val = test3rdupcast(k); verifyValue("me oh my-3rdDerived", val); verifyCount(3, k); } ////////////////////////////////// Member variables //////////////////////////////////////// // smart pointer by value { auto m = new MemberVariables(); auto k = new Klass("smart member value"); m.SmartMemberValue = k; char[] val = k.getValue(); verifyValue("smart member value", val); verifyCount(2, k); auto kmember = m.SmartMemberValue; val = kmember.getValue(); verifyValue("smart member value", val); verifyCount(3, kmember); verifyCount(3, k); delete m; verifyCount(2, kmember); verifyCount(2, k); } // smart pointer by pointer { auto m = new MemberVariables(); auto k = new Klass("smart member pointer"); m.SmartMemberPointer = k; char[] val = k.getValue(); verifyValue("smart member pointer", val); verifyCount(1, k); auto kmember = m.SmartMemberPointer; val = kmember.getValue(); verifyValue("smart member pointer", val); verifyCount(2, kmember); verifyCount(2, k); delete m; verifyCount(2, kmember); verifyCount(2, k); } // smart pointer by reference { auto m = new MemberVariables(); auto k = new Klass("smart member reference"); m.SmartMemberReference = k; char[] val = k.getValue(); verifyValue("smart member reference", val); verifyCount(2, k); auto kmember = m.SmartMemberReference; val = kmember.getValue(); verifyValue("smart member reference", val); verifyCount(3, kmember); verifyCount(3, k); // The C++ reference refers to SmartMemberValue... auto kmemberVal = m.SmartMemberValue; val = kmember.getValue(); verifyValue("smart member reference", val); verifyCount(4, kmemberVal); verifyCount(4, kmember); verifyCount(4, k); delete m; verifyCount(3, kmember); verifyCount(3, k); } // plain by value { auto m = new MemberVariables(); auto k = new Klass("plain member value"); m.MemberValue = k; char[] val = k.getValue(); verifyValue("plain member value", val); verifyCount(1, k); auto kmember = m.MemberValue; val = kmember.getValue(); verifyValue("plain member value", val); verifyCount(1, kmember); verifyCount(1, k); delete m; verifyCount(1, kmember); verifyCount(1, k); } // plain by pointer { auto m = new MemberVariables(); auto k = new Klass("plain member pointer"); m.MemberPointer = k; char[] val = k.getValue(); verifyValue("plain member pointer", val); verifyCount(1, k); auto kmember = m.MemberPointer; val = kmember.getValue(); verifyValue("plain member pointer", val); verifyCount(1, kmember); verifyCount(1, k); delete m; verifyCount(1, kmember); verifyCount(1, k); } // plain by reference { auto m = new MemberVariables(); auto k = new Klass("plain member reference"); m.MemberReference = k; char[] val = k.getValue(); verifyValue("plain member reference", val); verifyCount(1, k); auto kmember = m.MemberReference; val = kmember.getValue(); verifyValue("plain member reference", val); verifyCount(1, kmember); verifyCount(1, k); delete m; verifyCount(1, kmember); verifyCount(1, k); } // null member variables { auto m = new MemberVariables(); // shared_ptr by value auto k = m.SmartMemberValue; if (k !is null) throw new Exception("expected null"); m.SmartMemberValue = null; k = m.SmartMemberValue; if (k !is null) throw new Exception("expected null"); verifyCount(0, k); // plain by value try { m.MemberValue = null; throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {} } ////////////////////////////////// Global variables //////////////////////////////////////// // smart pointer { auto kglobal = GlobalSmartValue; if (kglobal !is null) throw new Exception("expected null"); auto k = new Klass("smart global value"); GlobalSmartValue = k; verifyCount(2, k); kglobal = GlobalSmartValue; char[] val = kglobal.getValue(); verifyValue("smart global value", val); verifyCount(3, kglobal); verifyCount(3, k); verifyValue("smart global value", GlobalSmartValue.getValue()); GlobalSmartValue = null; } // plain value { Klass kglobal; auto k = new Klass("global value"); GlobalValue = k; verifyCount(1, k); kglobal = GlobalValue; char[] val = kglobal.getValue(); verifyValue("global value", val); verifyCount(1, kglobal); verifyCount(1, k); verifyValue("global value", GlobalValue.getValue()); try { GlobalValue = null; throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {} } // plain pointer { auto kglobal = GlobalPointer; if (kglobal !is null) throw new Exception("expected null"); auto k = new Klass("global pointer"); GlobalPointer = k; verifyCount(1, k); kglobal = GlobalPointer; char[] val = kglobal.getValue(); verifyValue("global pointer", val); verifyCount(1, kglobal); verifyCount(1, k); GlobalPointer = null; } // plain reference { Klass kglobal; auto k = new Klass("global reference"); GlobalReference = k; verifyCount(1, k); kglobal = GlobalReference; char[] val = kglobal.getValue(); verifyValue("global reference", val); verifyCount(1, kglobal); verifyCount(1, k); try { GlobalReference = null; throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {} } ////////////////////////////////// Templates //////////////////////////////////////// { PairIntDouble pid = new PairIntDouble(10, 20.2); if (pid.baseVal1 != 20 || pid.baseVal2 != 40.4) throw new Exception("Base values wrong"); if (pid.val1 != 10 || pid.val2 != 20.2) throw new Exception("Derived Values wrong"); } } private void verifyValue(char[] expected, char[] got) { if (expected != got) throw new Exception("verify value failed. Expected: " ~ expected ~ " Got: " ~ got); } private void verifyCount(int expected, Klass k) { // We deliberately call the use_count(Klass) overload also for objects which // are instances of a subclass of Klass (due to static dispatch); things still // have to work. int got = use_count(k); if (expected != got) throw new Exception("verify use_count failed. Expected: " ~ toString(expected) ~ " Got: " ~ toString(got)); } swig-3.0.2/Examples/test-suite/d/sneaky1_runme.2.d0000664000175000017500000000044312343605122021541 0ustar williamwilliammodule sneaky1_runme; import std.exception; import sneaky1.sneaky1; void main() { enforce(add(30, 2) == 32, "add test failed"); enforce(subtract(20, 2) == 18, "subtract test failed"); enforce(mul(20, 2) == 40, "mul test failed"); enforce(divide(20, 2) == 10, "div test failed"); } swig-3.0.2/Examples/test-suite/d/director_alternating_runme.1.d0000664000175000017500000000022312343605122024364 0ustar williamwilliammodule director_alternating_runme; import director_alternating.director_alternating; void main() { assert(getBar().id() == idFromGetBar()); } swig-3.0.2/Examples/test-suite/d/nspace_runme.2.d0000664000175000017500000000516212343605122021442 0ustar williamwilliammodule nspace_runme; import std.exception; import nspace.nspace; static import nspace.NoNSpacePlease; static import nspace.Outer.namespce; static import nspace.Outer.Inner1.Channel; static import oi1c = nspace.Outer.Inner1.Color; static import nspace.Outer.Inner2.Channel; static import nspace.Outer.Inner2.Color; static import nspace.Outer.Inner3.Blue; static import nspace.Outer.Inner4.Blue; static import nspace.Outer.SomeClass; void main() { // constructors and destructors auto color1 = new oi1c.Color(); auto color = new oi1c.Color(color1); // class methods color.colorInstanceMethod(20.0); oi1c.Color.colorStaticMethod(20.0); auto created = oi1c.Color.create(); // class enums auto someClass = new nspace.Outer.SomeClass.SomeClass(); auto channel = someClass.GetInner1ColorChannel(); enforce(channel == oi1c.Color.Channel.Transmission, "Transmission wrong"); // class anonymous enums int val1 = oi1c.Color.ColorEnumVal1; int val2 = oi1c.Color.ColorEnumVal2; enforce(val1 == 0 && val2 == 0x22, "ColorEnumVal wrong"); // instance member variables color.instanceMemberVariable = 123; enforce(color.instanceMemberVariable == 123, "instance member variable failed"); // static member variables oi1c.Color.staticMemberVariable = 789; enforce(oi1c.Color.staticMemberVariable == 789, "static member variable failed"); enforce(oi1c.Color.staticConstMemberVariable == 222, "static const member variable failed"); enforce(oi1c.Color.staticConstEnumMemberVariable == oi1c.Color.Channel.Transmission, "static const enum member variable failed"); // check globals in a namespace don't get mangled with the nspace option nspace.nspace.namespaceFunction(color); nspace.nspace.namespaceVar = 111; enforce(nspace.nspace.namespaceVar == 111, "global var failed"); // Same class different namespaces auto col1 = new oi1c.Color(); auto col2 = nspace.Outer.Inner2.Color.Color.create(); col2.colors(col1, col1, col2, col2, col2); // global enums auto outerChannel1 = someClass.GetInner1Channel(); enforce(outerChannel1 == nspace.Outer.Inner1.Channel.Channel.Transmission1, "Transmission1 wrong"); auto outerChannel2 = someClass.GetInner2Channel(); enforce(outerChannel2 == nspace.Outer.Inner2.Channel.Channel.Transmission2, "Transmission2 wrong"); // turn feature off / ignoring auto ns = new nspace.Outer.namespce.namespce(); auto nons = new nspace.NoNSpacePlease.NoNSpacePlease(); // Derived class auto blue3 = new nspace.Outer.Inner3.Blue.Blue(); blue3.blueInstanceMethod(); auto blue4 = new nspace.Outer.Inner4.Blue.Blue(); blue4.blueInstanceMethod(); } swig-3.0.2/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.2.d0000664000175000017500000000074712343605122025243 0ustar williamwilliammodule li_boost_shared_ptr_runme_bits; import std.exception; import li_boost_shared_ptr_bits.li_boost_shared_ptr_bits; import li_boost_shared_ptr_bits.HiddenDestructor; import li_boost_shared_ptr_bits.IntHolder; import li_boost_shared_ptr_bits.VectorIntHolder; void main() { auto v = new VectorIntHolder(); v ~= new IntHolder(11); v ~= new IntHolder(22); v ~= new IntHolder(33); enforce(sum(v) == 66, "sum is wrong"); { scope hidden = HiddenDestructor.create(); } } swig-3.0.2/Examples/test-suite/d/li_attribute_runme.1.d0000664000175000017500000000401312343605122022651 0ustar williamwilliammodule li_attribute_runme; import li_attribute.A; import li_attribute.B; import li_attribute.MyClass; import li_attribute.MyClassVal; import li_attribute.MyStringyClass; import li_attribute.MyFoo; import li_attribute.Param_i; void main() { auto aa = new A(1,2,3); if (aa.a != 1) throw new Exception("error"); aa.a = 3; if (aa.a != 3) throw new Exception("error"); if (aa.b != 2) throw new Exception("error"); aa.b = 5; if (aa.b != 5) throw new Exception("error"); if (aa.d != aa.b) throw new Exception("error"); if (aa.c != 3) throw new Exception("error"); auto pi = new Param_i(7); if (pi.value != 7) throw new Exception("error"); pi.value=3; if (pi.value != 3) throw new Exception("error"); auto b = new B(aa); if (b.a.c != 3) throw new Exception("error"); // class/struct attribute with get/set methods using return/pass by reference auto myFoo = new MyFoo(); myFoo.x = 8; auto myClass = new MyClass(); myClass.Foo = myFoo; if (myClass.Foo.x != 8) throw new Exception("error"); // class/struct attribute with get/set methods using return/pass by value auto myClassVal = new MyClassVal(); if (myClassVal.ReadWriteFoo.x != -1) throw new Exception("error"); if (myClassVal.ReadOnlyFoo.x != -1) throw new Exception("error"); myClassVal.ReadWriteFoo = myFoo; if (myClassVal.ReadWriteFoo.x != 8) throw new Exception("error"); if (myClassVal.ReadOnlyFoo.x != 8) throw new Exception("error"); // string attribute with get/set methods using return/pass by value auto myStringClass = new MyStringyClass("initial string"); if (myStringClass.ReadWriteString != "initial string") throw new Exception("error"); if (myStringClass.ReadOnlyString != "initial string") throw new Exception("error"); myStringClass.ReadWriteString = "changed string"; if (myStringClass.ReadWriteString != "changed string") throw new Exception("error"); if (myStringClass.ReadOnlyString != "changed string") throw new Exception("error"); } swig-3.0.2/Examples/test-suite/d/throw_exception_runme.2.d0000664000175000017500000000106412343605122023407 0ustar williamwilliammodule throw_exception_runme; import throw_exception.Foo; void main() { test!("test_int"); test!("test_msg"); test!("test_cls"); test!("test_cls_ptr"); test!("test_cls_ref"); test!("test_cls_td"); test!("test_cls_ptr_td"); test!("test_cls_ref_td"); test!("test_array"); test!("test_enum"); } void test(string methodName)() { auto foo = new Foo(); bool didntThrow; try { mixin("foo." ~ methodName ~ "();"); didntThrow = true; } catch (Exception) {} if (didntThrow) { throw new Exception(methodName ~ " failed"); } } swig-3.0.2/Examples/test-suite/d/varargs_runme.1.d0000664000175000017500000000054612343605122021636 0ustar williamwilliammodule varargs_runme; import varargs.varargs; import varargs.Foo; void main() { if (test("Hello") != "Hello") { throw new Exception("Test 1 failed"); } auto f = new Foo("Greetings"); if (f.str != "Greetings") { throw new Exception("Test 2 failed"); } if (f.test("Hello") != "Hello") { throw new Exception("Test 3 failed"); } } swig-3.0.2/Examples/test-suite/d/preproc_constants_runme.1.d0000664000175000017500000000564612343605122023745 0ustar williamwilliammodule preproc_constants_runme; import tango.stdc.config; import preproc_constants.preproc_constants; void main() { static assert(is(int == typeof(CONST_INT1()))); static assert(is(int == typeof(CONST_INT2()))); static assert(is(uint == typeof(CONST_UINT1()))); static assert(is(uint == typeof(CONST_UINT2()))); static assert(is(uint == typeof(CONST_UINT3()))); static assert(is(uint == typeof(CONST_UINT4()))); static assert(is(c_long == typeof(CONST_LONG1()))); static assert(is(c_long == typeof(CONST_LONG2()))); static assert(is(c_long == typeof(CONST_LONG3()))); static assert(is(c_long == typeof(CONST_LONG4()))); static assert(is(long == typeof(CONST_LLONG1()))); static assert(is(long == typeof(CONST_LLONG2()))); static assert(is(long == typeof(CONST_LLONG3()))); static assert(is(long == typeof(CONST_LLONG4()))); static assert(is(ulong == typeof(CONST_ULLONG1()))); static assert(is(ulong == typeof(CONST_ULLONG2()))); static assert(is(ulong == typeof(CONST_ULLONG3()))); static assert(is(ulong == typeof(CONST_ULLONG4()))); static assert(is(double == typeof(CONST_DOUBLE1()))); static assert(is(double == typeof(CONST_DOUBLE2()))); static assert(is(double == typeof(CONST_DOUBLE3()))); static assert(is(double == typeof(CONST_DOUBLE4()))); static assert(is(double == typeof(CONST_DOUBLE5()))); static assert(is(double == typeof(CONST_DOUBLE6()))); static assert(is(bool == typeof(CONST_BOOL1()))); static assert(is(bool == typeof(CONST_BOOL2()))); static assert(is(char == typeof(CONST_CHAR()))); static assert(is(char[] == typeof(CONST_STRING1()))); static assert(is(char[] == typeof(CONST_STRING2()))); static assert(is(int == typeof(INT_AND_BOOL()))); // static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); static assert(is(c_long == typeof(INT_AND_LONG()))); static assert(is(c_ulong == typeof(INT_AND_ULONG()))); static assert(is(long == typeof(INT_AND_LLONG()))); static assert(is(ulong == typeof(INT_AND_ULLONG()))); static assert(is(int == typeof(BOOL_AND_BOOL()))); static assert(is(int == typeof(EXPR_MULTIPLY()))); static assert(is(int == typeof(EXPR_DIVIDE()))); static assert(is(int == typeof(EXPR_PLUS()))); static assert(is(int == typeof(EXPR_MINUS()))); static assert(is(int == typeof(EXPR_LSHIFT()))); static assert(is(int == typeof(EXPR_RSHIFT()))); static assert(is(bool == typeof(EXPR_LTE()))); static assert(is(bool == typeof(EXPR_GTE()))); static assert(is(bool == typeof(EXPR_INEQUALITY()))); static assert(is(bool == typeof(EXPR_EQUALITY()))); static assert(is(int == typeof(EXPR_AND()))); static assert(is(int == typeof(EXPR_XOR()))); static assert(is(int == typeof(EXPR_OR()))); static assert(is(bool == typeof(EXPR_LAND()))); static assert(is(bool == typeof(EXPR_LOR()))); static assert(is(double == typeof(EXPR_CONDITIONAL()))); } swig-3.0.2/Examples/test-suite/d/director_classes_runme.2.d0000664000175000017500000001275012343605122023522 0ustar williamwilliam/** * This test demonstrates director classes when the types are classes. Shown are * virtual function calls which use classes passed by * - Value * - Reference * - Pointer * as both parameters and return values * * The test also demonstrates directors used with: * - method overloading * - default parameters * * Note: Methods with default parameters that call up from C++ cannot call the * overloaded D methods, see DefaultParms method. * Expected output if PrintDebug enabled: * ------------ Start ------------ * Base - Val(444.555) * Base - Ref(444.555) * Base - Ptr(444.555) * Base - FullyOverloaded(int 10) * Base - FullyOverloaded(bool 1) * Base - SemiOverloaded(int -678) * Base - SemiOverloaded(bool 1) * Base - DefaultParms(10, 2.2) * Base - DefaultParms(10, 1.1) * -------------------------------- * Derived - Val(444.555) * Derived - Ref(444.555) * Derived - Ptr(444.555) * Derived - FullyOverloaded(int 10) * Derived - FullyOverloaded(bool 1) * Derived - SemiOverloaded(int -678) * Base - SemiOverloaded(bool 1) * Derived - DefaultParms(10, 2.2) * Derived - DefaultParms(10, 1.1) * -------------------------------- * DDerived - Val(444.555) * DDerived - Ref(444.555) * DDerived - Ptr(444.555) * DDerived - FullyOverloaded(int 10) * DDerived - FullyOverloaded(bool true) * DDerived - SemiOverloaded(-678) * Base - SemiOverloaded(bool 1) * DDerived - DefaultParms(10, 2.2) * DDerived - DefaultParms(10, 1.1) * ------------ Finish ------------ */ module director_classes_runme; import std.exception; import std.stdio; import std.string; import director_classes.director_classes; import director_classes.Caller; import director_classes.Base; import director_classes.Derived; import director_classes.DoubleHolder; void main() { if (PrintDebug) writeln("------------ Start ------------ "); auto myCaller = new Caller(); // Test C++ base class. { scope myBase = new Base(100.0); makeCalls(myCaller, myBase); } if (PrintDebug) writeln("--------------------------------"); // Test vanilla C++ wrapped derived class. { scope myBase = new Derived(200.0); makeCalls(myCaller, myBase); } if (PrintDebug) writeln("--------------------------------"); // Test director / D derived class. { scope myBase = new DDerived(300.0); makeCalls(myCaller, myBase); } if (PrintDebug) writeln("------------ Finish ------------ "); } void makeCalls(Caller myCaller, Base myBase) { string myBaseType = myBase.classinfo.name.split(".")[$-1]; myCaller.set(myBase); DoubleHolder dh = new DoubleHolder(444.555); // Class pointer, reference and pass by value tests enforce(myCaller.ValCall(dh).val == dh.val, "[1] failed"); enforce(myCaller.RefCall(dh).val == dh.val, "[2] failed"); enforce(myCaller.PtrCall(dh).val == dh.val, "[3] failed"); // Fully overloaded method test (all methods in base class are overloaded) enforce(myCaller.FullyOverloadedCall(10) == myBaseType ~ "::FullyOverloaded(int)", "[4] failed"); enforce(myCaller.FullyOverloadedCall(true) == myBaseType ~ "::FullyOverloaded(bool)", "[5] failed"); // Semi overloaded method test (some methods in base class are overloaded) enforce(myCaller.SemiOverloadedCall(-678) == myBaseType ~ "::SemiOverloaded(int)", "[6] failed"); enforce(myCaller.SemiOverloadedCall(true) == "Base" ~ "::SemiOverloaded(bool)", "[7] failed"); // Default parameters methods test enforce(myCaller.DefaultParmsCall(10, 2.2) == myBaseType ~ "::DefaultParms(int, double)", "[8] failed"); if (myBase.classinfo == DDerived.classinfo) { // special handling for D derived classes, there is no other way to do this enforce(myCaller.DefaultParmsCall(10) == myBaseType ~ "::DefaultParms(int, double)", "[9] failed"); } else { enforce(myCaller.DefaultParmsCall(10) == myBaseType ~ "::DefaultParms(int)", "[10] failed"); } myCaller.reset(); } public class DDerived : Base { public this(double dd) { super(dd); } public override DoubleHolder Val(DoubleHolder x) { if (PrintDebug) writefln("DDerived - Val(%s)", x.val); return x; } public override DoubleHolder Ref(DoubleHolder x) { if (PrintDebug) writefln("DDerived - Ref(%s)", x.val); return x; } public override DoubleHolder Ptr(DoubleHolder x) { if (PrintDebug) writefln("DDerived - Ptr(%s)", x.val); return x; } public override string FullyOverloaded(int x) { if (PrintDebug) writefln("DDerived - FullyOverloaded(int %s)", x); return "DDerived::FullyOverloaded(int)"; } public override string FullyOverloaded(bool x) { if (PrintDebug) writefln("DDerived - FullyOverloaded(bool %s)", x); return "DDerived::FullyOverloaded(bool)"; } public override string SemiOverloaded(int x) { string ret = "DDerived::SemiOverloaded(int)"; if (PrintDebug) writefln("DDerived - SemiOverloaded(%s)", x); return ret; } alias Base.SemiOverloaded SemiOverloaded; // Alias in SemiOverloaded(bool x). public override string DefaultParms(int x, double y) { string ret = "DDerived::DefaultParms(int, double)"; if (PrintDebug) writefln("DDerived - DefaultParms(%s, %s)", x, y); return ret; } // This method will never be called from C++ code because the two-parameter // DefaultParams() has a default value for the second parameter there. It is // only here to ensure consistent behavior for calls from C++ and D code. public override string DefaultParms(int x) { if (PrintDebug) writefln("DDerived - DefaultParms(%s)", x); return DefaultParms(x, 1.1/*use C++ default here*/); } } swig-3.0.2/Examples/test-suite/d/bools_runme.2.d0000664000175000017500000000056112343605122021305 0ustar williamwilliam/// This is the bool runtime testcase. It checks that the C++ bool type works. module bools_runme; import bools.bools; void main() { bool t = true; bool f = false; check_bo(f); check_bo(t); } void check_bo(bool input) { for (int i = 0; i < 1000; ++i) { if (bo(input) != input) { throw new Exception("Runtime test check_bo failed."); } } } swig-3.0.2/Examples/test-suite/d/preproc_constants_runme.2.d0000664000175000017500000000564512343605122023745 0ustar williamwilliammodule preproc_constants_runme; import core.stdc.config; import preproc_constants.preproc_constants; void main() { static assert(is(int == typeof(CONST_INT1()))); static assert(is(int == typeof(CONST_INT2()))); static assert(is(uint == typeof(CONST_UINT1()))); static assert(is(uint == typeof(CONST_UINT2()))); static assert(is(uint == typeof(CONST_UINT3()))); static assert(is(uint == typeof(CONST_UINT4()))); static assert(is(c_long == typeof(CONST_LONG1()))); static assert(is(c_long == typeof(CONST_LONG2()))); static assert(is(c_long == typeof(CONST_LONG3()))); static assert(is(c_long == typeof(CONST_LONG4()))); static assert(is(long == typeof(CONST_LLONG1()))); static assert(is(long == typeof(CONST_LLONG2()))); static assert(is(long == typeof(CONST_LLONG3()))); static assert(is(long == typeof(CONST_LLONG4()))); static assert(is(ulong == typeof(CONST_ULLONG1()))); static assert(is(ulong == typeof(CONST_ULLONG2()))); static assert(is(ulong == typeof(CONST_ULLONG3()))); static assert(is(ulong == typeof(CONST_ULLONG4()))); static assert(is(double == typeof(CONST_DOUBLE1()))); static assert(is(double == typeof(CONST_DOUBLE2()))); static assert(is(double == typeof(CONST_DOUBLE3()))); static assert(is(double == typeof(CONST_DOUBLE4()))); static assert(is(double == typeof(CONST_DOUBLE5()))); static assert(is(double == typeof(CONST_DOUBLE6()))); static assert(is(bool == typeof(CONST_BOOL1()))); static assert(is(bool == typeof(CONST_BOOL2()))); static assert(is(char == typeof(CONST_CHAR()))); static assert(is(string == typeof(CONST_STRING1()))); static assert(is(string == typeof(CONST_STRING2()))); static assert(is(int == typeof(INT_AND_BOOL()))); // static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); static assert(is(c_long == typeof(INT_AND_LONG()))); static assert(is(c_ulong == typeof(INT_AND_ULONG()))); static assert(is(long == typeof(INT_AND_LLONG()))); static assert(is(ulong == typeof(INT_AND_ULLONG()))); static assert(is(int == typeof(BOOL_AND_BOOL()))); static assert(is(int == typeof(EXPR_MULTIPLY()))); static assert(is(int == typeof(EXPR_DIVIDE()))); static assert(is(int == typeof(EXPR_PLUS()))); static assert(is(int == typeof(EXPR_MINUS()))); static assert(is(int == typeof(EXPR_LSHIFT()))); static assert(is(int == typeof(EXPR_RSHIFT()))); static assert(is(bool == typeof(EXPR_LTE()))); static assert(is(bool == typeof(EXPR_GTE()))); static assert(is(bool == typeof(EXPR_INEQUALITY()))); static assert(is(bool == typeof(EXPR_EQUALITY()))); static assert(is(int == typeof(EXPR_AND()))); static assert(is(int == typeof(EXPR_XOR()))); static assert(is(int == typeof(EXPR_OR()))); static assert(is(bool == typeof(EXPR_LAND()))); static assert(is(bool == typeof(EXPR_LOR()))); static assert(is(double == typeof(EXPR_CONDITIONAL()))); } swig-3.0.2/Examples/test-suite/d/long_long_runme.1.d0000664000175000017500000000166212343605122022147 0ustar williamwilliam// Checks if the long long and unsigned long long types work. module long_long_runme; import Integer = tango.text.convert.Integer; import long_long.long_long; void main() { check_ll(0L); check_ll(0x7FFFFFFFFFFFFFFFL); check_ll(-10L); check_ull(0u); check_ull(127u); check_ull(128u); check_ull(9223372036854775807u); //0x7FFFFFFFFFFFFFFFL check_ull(18446744073709551615u); //0xFFFFFFFFFFFFFFFFL } void check_ll(long value) { ll = value; long value_check = ll; if (value != value_check) { throw new Exception("Runtime test using long long failed: expected: " ~ Integer.toString(value) ~ ", got: " ~ Integer.toString(value_check)); } } void check_ull(ulong value) { ull = value; ulong value_check = ull; if (value != value_check) { throw new Exception( "Runtime test using unsigned long long failed: expected: " ~ Integer.toString(value) ~ ", ll_check=" ~ Integer.toString(value_check)); } } swig-3.0.2/Examples/test-suite/d/d_nativepointers_runme.2.d0000664000175000017500000000166012343605122023545 0ustar williamwilliammodule d_nativepointers_runnme; import d_nativepointers.d_nativepointers; import d_nativepointers.SomeClass; import d_nativepointers.SWIGTYPE_p_OpaqueClass; import d_nativepointers.SWIGTYPE_p_p_SomeClass; import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void; extern(C) alias void function(int**, char***) GType; void main() { check!(a, int*); check!(b, float**); check!(c, char***); check!(d, SomeClass); check!(e, SWIGTYPE_p_p_SomeClass); check!(f, SWIGTYPE_p_OpaqueClass); check!(g, GType); check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void); { static assert(is(int* function(int*) == typeof(&refA))); int v = 2; assert(*refA(&v) == 2); } { static assert(is(float** function(float**) == typeof(&refB))); float v = 1.0; float* p = &v; assert(**refB(&p) == 1.0); } } void check(alias F, T)() { static assert(is(T function(T) == typeof(&F))); assert(F(null) is null); } swig-3.0.2/Examples/test-suite/d/d_nativepointers_runme.1.d0000664000175000017500000000166012343605122023544 0ustar williamwilliammodule d_nativepointers_runnme; import d_nativepointers.d_nativepointers; import d_nativepointers.SomeClass; import d_nativepointers.SWIGTYPE_p_OpaqueClass; import d_nativepointers.SWIGTYPE_p_p_SomeClass; import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void; extern(C) alias void function(int**, char***) GType; void main() { check!(a, int*); check!(b, float**); check!(c, char***); check!(d, SomeClass); check!(e, SWIGTYPE_p_p_SomeClass); check!(f, SWIGTYPE_p_OpaqueClass); check!(g, GType); check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void); { static assert(is(int* function(int*) == typeof(&refA))); int v = 2; assert(*refA(&v) == 2); } { static assert(is(float** function(float**) == typeof(&refB))); float v = 1.0; float* p = &v; assert(**refB(&p) == 1.0); } } void check(alias F, T)() { static assert(is(T function(T) == typeof(&F))); assert(F(null) is null); } swig-3.0.2/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d0000664000175000017500000004101212343605122024210 0ustar williamwilliammodule li_boost_shared_ptr_runme; import core.memory; import core.thread; import std.conv; import std.exception; import std.stdio; import li_boost_shared_ptr.li_boost_shared_ptr; import li_boost_shared_ptr.Klass; import li_boost_shared_ptr.KlassDerived; import li_boost_shared_ptr.Klass3rdDerived; import li_boost_shared_ptr.MemberVariables; import li_boost_shared_ptr.PairIntDouble; // Debugging flag enum TRACE = false; void main() { if (TRACE) writeln("---> STARTED <---"); debug_shared = TRACE; // Change loop count to run for a long time to monitor memory enum LOOP_COUNT = 1; // 50000; for (int i = 0; i < LOOP_COUNT; ++i) { runTest(); GC.collect(); } if (TRACE) writeln("---> NEARLY FINISHED <---"); // Try to get the GC to collect everything not referenced anymore. int countdown = 100; while (--countdown) { GC.collect(); if (Klass.getTotal_count() == 1) break; Thread.sleep(100); } // A single remaining instance expected: the global variable (GlobalValue). if (Klass.getTotal_count() != 1) throw new Exception("Klass.total_count=" ~ to!string(Klass.getTotal_count())); // A single remaining instance expected: the global variable (GlobalSmartValue). int wrapper_count = shared_ptr_wrapper_count(); if (wrapper_count != NOT_COUNTING) if (wrapper_count != 1) throw new Exception("shared_ptr wrapper count=" ~ to!string(wrapper_count)); if (TRACE) writeln("---> FINISHED <---"); } void runTest() { // simple shared_ptr usage - created in C++ { auto k = new Klass("me oh my"); string val = k.getValue(); verifyValue("me oh my", val); verifyCount(1, k); } // simple shared_ptr usage - not created in C++ { auto k = factorycreate(); string val = k.getValue(); verifyValue("factorycreate", val); verifyCount(1, k); } // pass by shared_ptr { auto k = new Klass("me oh my"); auto kret = smartpointertest(k); string val = kret.getValue(); verifyValue("me oh my smartpointertest", val); verifyCount(2, k); verifyCount(2, kret); } // pass by shared_ptr pointer { auto k = new Klass("me oh my"); auto kret = smartpointerpointertest(k); string val = kret.getValue(); verifyValue("me oh my smartpointerpointertest", val); verifyCount(2, k); verifyCount(2, kret); } // pass by shared_ptr reference { auto k = new Klass("me oh my"); auto kret = smartpointerreftest(k); string val = kret.getValue(); verifyValue("me oh my smartpointerreftest", val); verifyCount(2, k); verifyCount(2, kret); } // pass by shared_ptr pointer reference { auto k = new Klass("me oh my"); auto kret = smartpointerpointerreftest(k); string val = kret.getValue(); verifyValue("me oh my smartpointerpointerreftest", val); verifyCount(2, k); verifyCount(2, kret); } // const pass by shared_ptr { auto k = new Klass("me oh my"); auto kret = constsmartpointertest(k); string val = kret.getValue(); verifyValue("me oh my", val); verifyCount(2, k); verifyCount(2, kret); } // const pass by shared_ptr pointer { auto k = new Klass("me oh my"); auto kret = constsmartpointerpointertest(k); string val = kret.getValue(); verifyValue("me oh my", val); verifyCount(2, k); verifyCount(2, kret); } // const pass by shared_ptr reference { auto k = new Klass("me oh my"); auto kret = constsmartpointerreftest(k); string val = kret.getValue(); verifyValue("me oh my", val); verifyCount(2, k); verifyCount(2, kret); } // pass by value { auto k = new Klass("me oh my"); auto kret = valuetest(k); string val = kret.getValue(); verifyValue("me oh my valuetest", val); verifyCount(1, k); verifyCount(1, kret); } // pass by pointer { auto k = new Klass("me oh my"); auto kret = pointertest(k); string val = kret.getValue(); verifyValue("me oh my pointertest", val); verifyCount(1, k); verifyCount(1, kret); } // pass by reference { auto k = new Klass("me oh my"); auto kret = reftest(k); string val = kret.getValue(); verifyValue("me oh my reftest", val); verifyCount(1, k); verifyCount(1, kret); } // pass by pointer reference { auto k = new Klass("me oh my"); auto kret = pointerreftest(k); string val = kret.getValue(); verifyValue("me oh my pointerreftest", val); verifyCount(1, k); verifyCount(1, kret); } // null tests { Klass k = null; // TODO: add in const versions too enforce(smartpointertest(k) is null, "return was not null"); enforce(smartpointerpointertest(k) is null, "return was not null"); enforce(smartpointerreftest(k) is null, "return was not null"); enforce(smartpointerpointerreftest(k) is null, "return was not null"); enforce(nullsmartpointerpointertest(null) == "null pointer", "not null smartpointer pointer"); enforceThrows( (){ valuetest(k); }, "Failed to catch null pointer"); enforce(pointertest(k) is null, "return was not null"); enforceThrows( (){ reftest(k); }, "Failed to catch null pointer"); } // $owner { auto k = pointerownertest(); string val = k.getValue(); verifyValue("pointerownertest", val); verifyCount(1, k); } { auto k = smartpointerpointerownertest(); string val = k.getValue(); verifyValue("smartpointerpointerownertest", val); verifyCount(1, k); } ////////////////////////////////// Derived classes //////////////////////////////////////// // derived pass by shared_ptr { auto k = new KlassDerived("me oh my"); auto kret = derivedsmartptrtest(k); string val = kret.getValue(); verifyValue("me oh my derivedsmartptrtest-Derived", val); verifyCount(4, k); // includes two extra references for upcasts in the proxy classes verifyCount(4, kret); } // derived pass by shared_ptr pointer { auto k = new KlassDerived("me oh my"); auto kret = derivedsmartptrpointertest(k); string val = kret.getValue(); verifyValue("me oh my derivedsmartptrpointertest-Derived", val); verifyCount(4, k); // includes two extra references for upcasts in the proxy classes verifyCount(4, kret); } // derived pass by shared_ptr ref { auto k = new KlassDerived("me oh my"); auto kret = derivedsmartptrreftest(k); string val = kret.getValue(); verifyValue("me oh my derivedsmartptrreftest-Derived", val); verifyCount(4, k); // includes two extra references for upcasts in the proxy classes verifyCount(4, kret); } // derived pass by shared_ptr pointer ref { auto k = new KlassDerived("me oh my"); auto kret = derivedsmartptrpointerreftest(k); string val = kret.getValue(); verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val); verifyCount(4, k); // includes two extra references for upcasts in the proxy classes verifyCount(4, kret); } // derived pass by pointer { auto k = new KlassDerived("me oh my"); auto kret = derivedpointertest(k); string val = kret.getValue(); verifyValue("me oh my derivedpointertest-Derived", val); verifyCount(2, k); // includes an extra reference for the upcast in the proxy class verifyCount(2, kret); } // derived pass by ref { auto k = new KlassDerived("me oh my"); auto kret = derivedreftest(k); string val = kret.getValue(); verifyValue("me oh my derivedreftest-Derived", val); verifyCount(2, k); // includes an extra reference for the upcast in the proxy class verifyCount(2, kret); } ////////////////////////////////// Derived and base class mixed //////////////////////////////////////// // pass by shared_ptr (mixed) { auto k = new KlassDerived("me oh my"); auto kret = smartpointertest(k); string val = kret.getValue(); verifyValue("me oh my smartpointertest-Derived", val); verifyCount(3, k); // an extra reference for the upcast in the proxy class verifyCount(3, kret); } // pass by shared_ptr pointer (mixed) { auto k = new KlassDerived("me oh my"); auto kret = smartpointerpointertest(k); string val = kret.getValue(); verifyValue("me oh my smartpointerpointertest-Derived", val); verifyCount(3, k); // an extra reference for the upcast in the proxy class verifyCount(3, kret); } // pass by shared_ptr reference (mixed) { auto k = new KlassDerived("me oh my"); auto kret = smartpointerreftest(k); string val = kret.getValue(); verifyValue("me oh my smartpointerreftest-Derived", val); verifyCount(3, k); // an extra reference for the upcast in the proxy class verifyCount(3, kret); } // pass by shared_ptr pointer reference (mixed) { auto k = new KlassDerived("me oh my"); auto kret = smartpointerpointerreftest(k); string val = kret.getValue(); verifyValue("me oh my smartpointerpointerreftest-Derived", val); verifyCount(3, k); // an extra reference for the upcast in the proxy class verifyCount(3, kret); } // pass by value (mixed) { auto k = new KlassDerived("me oh my"); auto kret = valuetest(k); string val = kret.getValue(); verifyValue("me oh my valuetest", val); // note slicing verifyCount(2, k); // an extra reference for the upcast in the proxy class verifyCount(1, kret); } // pass by pointer (mixed) { auto k = new KlassDerived("me oh my"); auto kret = pointertest(k); string val = kret.getValue(); verifyValue("me oh my pointertest-Derived", val); verifyCount(2, k); // an extra reference for the upcast in the proxy class verifyCount(1, kret); } // pass by ref (mixed) { auto k = new KlassDerived("me oh my"); auto kret = reftest(k); string val = kret.getValue(); verifyValue("me oh my reftest-Derived", val); verifyCount(2, k); // an extra reference for the upcast in the proxy class verifyCount(1, kret); } // 3rd derived class { auto k = new Klass3rdDerived("me oh my"); string val = k.getValue(); verifyValue("me oh my-3rdDerived", val); verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values val = test3rdupcast(k); verifyValue("me oh my-3rdDerived", val); verifyCount(3, k); } ////////////////////////////////// Member variables //////////////////////////////////////// // smart pointer by value { auto m = new MemberVariables(); auto k = new Klass("smart member value"); m.SmartMemberValue = k; string val = k.getValue(); verifyValue("smart member value", val); verifyCount(2, k); auto kmember = m.SmartMemberValue; val = kmember.getValue(); verifyValue("smart member value", val); verifyCount(3, kmember); verifyCount(3, k); delete m; verifyCount(2, kmember); verifyCount(2, k); } // smart pointer by pointer { auto m = new MemberVariables(); auto k = new Klass("smart member pointer"); m.SmartMemberPointer = k; string val = k.getValue(); verifyValue("smart member pointer", val); verifyCount(1, k); auto kmember = m.SmartMemberPointer; val = kmember.getValue(); verifyValue("smart member pointer", val); verifyCount(2, kmember); verifyCount(2, k); delete m; verifyCount(2, kmember); verifyCount(2, k); } // smart pointer by reference { auto m = new MemberVariables(); auto k = new Klass("smart member reference"); m.SmartMemberReference = k; string val = k.getValue(); verifyValue("smart member reference", val); verifyCount(2, k); auto kmember = m.SmartMemberReference; val = kmember.getValue(); verifyValue("smart member reference", val); verifyCount(3, kmember); verifyCount(3, k); // The C++ reference refers to SmartMemberValue... auto kmemberVal = m.SmartMemberValue; val = kmember.getValue(); verifyValue("smart member reference", val); verifyCount(4, kmemberVal); verifyCount(4, kmember); verifyCount(4, k); delete m; verifyCount(3, kmember); verifyCount(3, k); } // plain by value { auto m = new MemberVariables(); auto k = new Klass("plain member value"); m.MemberValue = k; string val = k.getValue(); verifyValue("plain member value", val); verifyCount(1, k); auto kmember = m.MemberValue; val = kmember.getValue(); verifyValue("plain member value", val); verifyCount(1, kmember); verifyCount(1, k); delete m; verifyCount(1, kmember); verifyCount(1, k); } // plain by pointer { auto m = new MemberVariables(); auto k = new Klass("plain member pointer"); m.MemberPointer = k; string val = k.getValue(); verifyValue("plain member pointer", val); verifyCount(1, k); auto kmember = m.MemberPointer; val = kmember.getValue(); verifyValue("plain member pointer", val); verifyCount(1, kmember); verifyCount(1, k); delete m; verifyCount(1, kmember); verifyCount(1, k); } // plain by reference { auto m = new MemberVariables(); auto k = new Klass("plain member reference"); m.MemberReference = k; string val = k.getValue(); verifyValue("plain member reference", val); verifyCount(1, k); auto kmember = m.MemberReference; val = kmember.getValue(); verifyValue("plain member reference", val); verifyCount(1, kmember); verifyCount(1, k); delete m; verifyCount(1, kmember); verifyCount(1, k); } // null member variables { auto m = new MemberVariables(); // shared_ptr by value auto k = m.SmartMemberValue; if (k !is null) throw new Exception("expected null"); m.SmartMemberValue = null; k = m.SmartMemberValue; if (k !is null) throw new Exception("expected null"); verifyCount(0, k); // plain by value enforceThrows( (){ m.MemberValue = null; }, "Failed to catch null pointer"); } ////////////////////////////////// Global variables //////////////////////////////////////// // smart pointer { auto kglobal = GlobalSmartValue; enforce(kglobal is null, "expected null"); auto k = new Klass("smart global value"); GlobalSmartValue = k; verifyCount(2, k); kglobal = GlobalSmartValue; string val = kglobal.getValue(); verifyValue("smart global value", val); verifyCount(3, kglobal); verifyCount(3, k); verifyValue("smart global value", GlobalSmartValue.getValue()); GlobalSmartValue = null; } // plain value { Klass kglobal; auto k = new Klass("global value"); GlobalValue = k; verifyCount(1, k); kglobal = GlobalValue; string val = kglobal.getValue(); verifyValue("global value", val); verifyCount(1, kglobal); verifyCount(1, k); verifyValue("global value", GlobalValue.getValue()); enforceThrows((){ GlobalValue = null; }, "Failed to catch null pointer"); } // plain pointer { auto kglobal = GlobalPointer; enforce(kglobal is null, "expected null"); auto k = new Klass("global pointer"); GlobalPointer = k; verifyCount(1, k); kglobal = GlobalPointer; string val = kglobal.getValue(); verifyValue("global pointer", val); verifyCount(1, kglobal); verifyCount(1, k); GlobalPointer = null; } // plain reference { Klass kglobal; auto k = new Klass("global reference"); GlobalReference = k; verifyCount(1, k); kglobal = GlobalReference; string val = kglobal.getValue(); verifyValue("global reference", val); verifyCount(1, kglobal); verifyCount(1, k); enforceThrows((){ GlobalReference = null; }, "Failed to catch null pointer"); } ////////////////////////////////// Templates //////////////////////////////////////// { auto pid = new PairIntDouble(10, 20.2); enforce(pid.baseVal1 == 20 && pid.baseVal2== 40.4, "Base values wrong"); enforce(pid.val1 == 10 && pid.val2 == 20.2, "Derived Values wrong"); } } private void verifyValue(string expected, string got) { if (expected != got) throw new Exception("verify value failed. Expected: " ~ expected ~ " Got: " ~ got); } private void verifyCount(int expected, Klass k) { // We deliberately call the use_count(Klass) overload also for objects which // are instances of a subclass of Klass (due to static dispatch); things still // have to work. auto got = use_count(k); if (expected != got) throw new Exception("verify use_count failed. Expected: " ~ to!string(expected) ~ " Got: " ~ to!string(got)); } private void enforceThrows(void delegate() dg, string errorMessage) { bool hasThrown; try { dg(); } catch (Exception) { hasThrown = true; } finally { if (!hasThrown) { throw new Exception(errorMessage); } } } swig-3.0.2/Examples/test-suite/d/pointer_reference_runme.2.d0000664000175000017500000000047112343605122023665 0ustar williamwilliammodule pointer_reference_runme; import std.exception; import pointer_reference.pointer_reference; import pointer_reference.Struct; void main() { Struct s = get(); enforce(s.value == 10, "get test failed"); auto ss = new Struct(20); set(ss); enforce(Struct.instance.value == 20, "set test failed"); } swig-3.0.2/Examples/test-suite/d/apply_strings_runme.1.d0000664000175000017500000000072712343605122023070 0ustar williamwilliammodule apply_strings_runme; import apply_strings.apply_strings; const char[] TEST_MESSAGE = "A message from target language to the C++ world and back again."; void main() { if (UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed"); if (SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed"); auto pChar = CharFunction(null); if (pChar !is null) throw new Exception("CharFunction failed"); } swig-3.0.2/Examples/test-suite/d/char_strings_runme.2.d0000664000175000017500000001034212343605122022653 0ustar williamwilliammodule char_strings_runme; import std.conv; import std.exception; import std.range; import char_strings.char_strings; enum CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; enum OTHERLAND_MSG = "Little message from the safe world."; enum TEST_RANGE = iota(0, 10000); void main() { // get functions foreach (i; TEST_RANGE) { enforce(GetCharHeapString() == CPLUSPLUS_MSG, "Test char get 1 failed, iteration " ~ to!string(i)); DeleteCharHeapString(); } foreach (i; TEST_RANGE) { enforce(GetConstCharProgramCodeString() == CPLUSPLUS_MSG, "Test char get 2 failed, iteration " ~ to!string(i)); DeleteCharHeapString(); } foreach (i; TEST_RANGE) { enforce(GetCharStaticString() == CPLUSPLUS_MSG, "Test char get 3 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(GetCharStaticStringFixed() == CPLUSPLUS_MSG, "Test char get 4 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(GetConstCharStaticStringFixed() == CPLUSPLUS_MSG, "Test char get 5 failed, iteration " ~ to!string(i)); } // set functions foreach (i; TEST_RANGE) { enforce(SetCharHeapString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 1 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(SetCharStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 2 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(SetCharArrayStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 3 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(SetConstCharHeapString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 4 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(SetConstCharStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 5 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(SetConstCharArrayStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 6 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(SetCharConstStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 7 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(SetConstCharConstStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 8 failed, iteration " ~ to!string(i)); } // get set function foreach (i; TEST_RANGE) { string ping = OTHERLAND_MSG ~ to!string(i); string pong = CharPingPong(ping); enforce(ping == pong, "Test PingPong 1 failed.\nExpected:" ~ ping ~ "\nReceived:" ~ pong); } // variables foreach (i; TEST_RANGE) { const msg = OTHERLAND_MSG ~ to!string(i); global_char = msg; enforce(global_char == msg, "Test variables 1 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { const msg = OTHERLAND_MSG ~ to!string(i); global_char_array1 = msg; enforce(global_char_array1 == msg, "Test variables 2 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { const msg = OTHERLAND_MSG ~ to!string(i); global_char_array2 = msg; enforce(global_char_array2 == msg, "Test variables 2 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(global_const_char == CPLUSPLUS_MSG, "Test variables 4 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(global_const_char_array1 == CPLUSPLUS_MSG, "Test variables 5 failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(global_const_char_array2 == CPLUSPLUS_MSG, "Test variables 6 failed, iteration " ~ to!string(i)); } // char *& tests foreach (i; TEST_RANGE) { enforce(GetCharPointerRef() == CPLUSPLUS_MSG, "Test char pointer ref get failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(SetCharPointerRef(OTHERLAND_MSG ~ to!string(i), i), "Test char pointer ref set failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(GetConstCharPointerRef() == CPLUSPLUS_MSG, "Test const char pointer ref get failed, iteration " ~ to!string(i)); } foreach (i; TEST_RANGE) { enforce(SetConstCharPointerRef(OTHERLAND_MSG ~ to!string(i), i), "Test const char pointer ref set failed, iteration " ~ to!string(i)); } } swig-3.0.2/Examples/test-suite/d/Makefile.in0000664000175000017500000000417112343605122020522 0ustar williamwilliam####################################################################### # Makefile for D test-suite ####################################################################### LANGUAGE = d srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ ifeq (2,$(D_VERSION)) VERSIONSUFFIX = .2 else VERSIONSUFFIX = .1 endif SCRIPTSUFFIX = _runme$(VERSIONSUFFIX).d CPP_TEST_CASES = \ d_nativepointers \ exception_partial_info include $(srcdir)/../common.mk # Override some variables from common.mk: TARGETSUFFIX = _wrap SWIGOPT+=-splitproxy -package $* # Rules for the different types of tests %.cpptest: $(setup) +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_cpp)) +$(run_testcase) %.ctest: $(setup) +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_c)) +$(run_testcase) %.multicpptest: $(setup) +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_multi_cpp)) +$(run_testcase) # Makes a directory for the testcase if it does not exist setup = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \ else \ echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \ fi; \ if [ ! -d $*$(VERSIONSUFFIX) ]; then \ mkdir $*$(VERSIONSUFFIX); \ fi; \ if [ ! -d $*$(VERSIONSUFFIX)/$* ]; then \ mkdir $*$(VERSIONSUFFIX)/$*; \ fi # Compiles D files then runs the testcase. A testcase is only run if # a file is found which has _runme.d appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ cd $*$(VERSIONSUFFIX) && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ DFLAGS='-of$*_runme' \ DSRCS='../$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) `find $* -name *.d`' d_compile && \ env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme; \ else \ cd $*$(VERSIONSUFFIX) && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ DFLAGS='-c' \ DSRCS='`find $* -name *.d`' d_compile && cd .. ; \ fi # Clean: remove testcase directories %.clean: @if [ -d $*$(VERSIONSUFFIX) ]; then \ rm -rf $*$(VERSIONSUFFIX); \ fi swig-3.0.2/Examples/test-suite/d/director_protected_runme.1.d0000664000175000017500000000212312343605122024046 0ustar williamwilliammodule director_protected_runme; import director_protected.Foo; import director_protected.Bar; void main() { Bar b = new Bar(); Foo f = b.create(); auto fb = new FooBar(); auto fb2 = new FooBar2(); char[] s; s = fb.used(); if ( s != ("Foo::pang();Bar::pong();Foo::pong();FooBar::ping();")) throw new Exception("bad FooBar::used" ~ " - " ~ s); s = fb2.used(); if ( s != ("FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();")) throw new Exception("bad FooBar2::used"); s = b.pong(); if ( s != ("Bar::pong();Foo::pong();Bar::ping();")) throw new Exception("bad Bar::pong"); s = f.pong(); if ( s != ("Bar::pong();Foo::pong();Bar::ping();")) throw new Exception("bad Foo::pong"); s = fb.pong(); if ( s != ("Bar::pong();Foo::pong();FooBar::ping();")) throw new Exception("bad FooBar::pong"); } class FooBar : Bar { protected: override char[] ping() { return "FooBar::ping();"; } } class FooBar2 : Bar{ protected: override char[] ping() { return "FooBar2::ping();"; } override char[] pang() { return "FooBar2::pang();"; } } swig-3.0.2/Examples/test-suite/d/preproc_constants_c_runme.1.d0000664000175000017500000000575512343605122024250 0ustar williamwilliammodule preproc_constants_c_runme; import tango.stdc.config; import preproc_constants_c.preproc_constants_c; // Same as preproc_constants.i testcase, but bool types are int instead. void main() { static assert(is(int == typeof(CONST_INT1()))); static assert(is(int == typeof(CONST_INT2()))); static assert(is(uint == typeof(CONST_UINT1()))); static assert(is(uint == typeof(CONST_UINT2()))); static assert(is(uint == typeof(CONST_UINT3()))); static assert(is(uint == typeof(CONST_UINT4()))); static assert(is(c_long == typeof(CONST_LONG1()))); static assert(is(c_long == typeof(CONST_LONG2()))); static assert(is(c_long == typeof(CONST_LONG3()))); static assert(is(c_long == typeof(CONST_LONG4()))); static assert(is(long == typeof(CONST_LLONG1()))); static assert(is(long == typeof(CONST_LLONG2()))); static assert(is(long == typeof(CONST_LLONG3()))); static assert(is(long == typeof(CONST_LLONG4()))); static assert(is(ulong == typeof(CONST_ULLONG1()))); static assert(is(ulong == typeof(CONST_ULLONG2()))); static assert(is(ulong == typeof(CONST_ULLONG3()))); static assert(is(ulong == typeof(CONST_ULLONG4()))); static assert(is(double == typeof(CONST_DOUBLE1()))); static assert(is(double == typeof(CONST_DOUBLE2()))); static assert(is(double == typeof(CONST_DOUBLE3()))); static assert(is(double == typeof(CONST_DOUBLE4()))); static assert(is(double == typeof(CONST_DOUBLE5()))); static assert(is(double == typeof(CONST_DOUBLE6()))); static assert(is(int == typeof(CONST_BOOL1()))); static assert(is(int == typeof(CONST_BOOL2()))); static assert(is(char == typeof(CONST_CHAR()))); static assert(is(char[] == typeof(CONST_STRING1()))); static assert(is(char[] == typeof(CONST_STRING2()))); static assert(is(int == typeof(INT_AND_BOOL()))); // static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); static assert(is(c_long == typeof(INT_AND_LONG()))); static assert(is(c_ulong == typeof(INT_AND_ULONG()))); static assert(is(long == typeof(INT_AND_LLONG()))); static assert(is(ulong == typeof(INT_AND_ULLONG()))); static assert(is(int == typeof(BOOL_AND_BOOL()))); static assert(is(int == typeof(EXPR_MULTIPLY()))); static assert(is(int == typeof(EXPR_DIVIDE()))); static assert(is(int == typeof(EXPR_PLUS()))); static assert(is(int == typeof(EXPR_MINUS()))); static assert(is(int == typeof(EXPR_LSHIFT()))); static assert(is(int == typeof(EXPR_RSHIFT()))); static assert(is(int == typeof(EXPR_LTE()))); static assert(is(int == typeof(EXPR_GTE()))); static assert(is(int == typeof(EXPR_INEQUALITY()))); static assert(is(int == typeof(EXPR_EQUALITY()))); static assert(is(int == typeof(EXPR_AND()))); static assert(is(int == typeof(EXPR_XOR()))); static assert(is(int == typeof(EXPR_OR()))); static assert(is(int == typeof(EXPR_LAND()))); static assert(is(int == typeof(EXPR_LOR()))); static assert(is(double == typeof(EXPR_CONDITIONAL()))); } swig-3.0.2/Examples/test-suite/d/special_variable_macros_runme.2.d0000664000175000017500000000131312343605122025014 0ustar williamwilliammodule special_variable_macros_runme; import std.exception; import special_variable_macros.special_variable_macros; import special_variable_macros.Name; import special_variable_macros.NewName; import special_variable_macros.PairIntBool; void main() { auto name = new Name(); enforce(testFred(name) == "none"); enforce(testJack(name) == "$specialname"); enforce(testJill(name) == "jilly"); enforce(testMary(name) == "SWIGTYPE_p_NameWrap"); enforce(testJames(name) == "SWIGTYPE_Name"); enforce(testJim(name) == "multiname num"); enforce(testJohn(new PairIntBool(10, false)) == 123); auto newName = NewName.factory("factoryname"); enforce(newName.getStoredName().getName() == "factoryname"); } swig-3.0.2/Examples/test-suite/d/li_typemaps_runme.1.d0000664000175000017500000000425112343605122022514 0ustar williamwilliam/// Tests correct handling of a few INPUT/OUTPUT/INOUT-typemapped functions. module li_typemaps_runme; import li_typemaps.li_typemaps; void main() { // Check double INPUT typemaps if (in_double(22.22) != 22.22) raiseError("in_double"); if (inr_double(22.22) != 22.22) raiseError("inr_double"); // Check double OUTPUT typemaps { double var = 44.44; out_double(22.22, var); if (var != 22.22) raiseError("out_double"); } { double var = 44.44; outr_double(22.22, var); if (var != 22.22) raiseError("outr_double"); } // Check double INOUT typemaps { double var = 44.44; inout_double(var); if (var != 44.44) raiseError("inout_double"); } { double var = 44.44; inoutr_double(var); if (var != 44.44) raiseError("inoutr_double"); } // Check unsigned long long INPUT typemaps if (in_ulonglong(20) != 20) raiseError("in_ulonglong"); if (inr_ulonglong(20) != 20) raiseError("inr_ulonglong"); // Check unsigned long long OUTPUT typemaps { ulong var = 40; out_ulonglong(20, var); if (var != 20) raiseError("out_ulonglong"); } { ulong var = 40; outr_ulonglong(20, var); if (var != 20) raiseError("outr_ulonglong"); } // Check unsigned long long INOUT typemaps { ulong var = 40; inout_ulonglong(var); if (var != 40) raiseError("inout_ulonglong"); } { ulong var = 40; inoutr_ulonglong(var); if (var != 40) raiseError("inoutr_ulonglong"); } // Check unsigned bool INPUT typemaps if (in_bool(false) != false) raiseError("in_bool"); if (inr_bool(false) != false) raiseError("inr_bool"); // Check unsigned bool OUTPUT typemaps { bool var = false; out_bool(true, var); if (var != true) raiseError("out_bool"); } { bool var = false; outr_bool(true, var); if (var != true) raiseError("outr_bool"); } // Check unsigned bool INOUT typemaps { bool var = false; inout_bool(var); if (var != false) raiseError("inout_bool"); } { bool var = false; inoutr_bool(var); if (var != false) raiseError("inoutr_bool"); } } void raiseError(char[] funcName) { throw new Exception("Test FAILED for function " ~ funcName); } swig-3.0.2/Examples/test-suite/d/inherit_target_language_runme.1.d0000664000175000017500000000156312343605122025044 0ustar williamwilliammodule inherit_target_language_runme; import inherit_target_language.BaseX; import inherit_target_language.Derived1; import inherit_target_language.Derived2; import inherit_target_language.DerivedX; import inherit_target_language.MultipleDerived1; import inherit_target_language.MultipleDerived2; import inherit_target_language.MultipleDerived3; import inherit_target_language.MultipleDerived4; void main() { (new Derived1()).targetLanguageBaseMethod(); (new Derived2()).targetLanguageBaseMethod(); (new MultipleDerived1()).targetLanguageBaseMethod(); (new MultipleDerived2()).targetLanguageBaseMethod(); (new MultipleDerived3()).f(); (new MultipleDerived4()).g(); auto baseX = new BaseX(); baseX.basex(); baseX.targetLanguageBase2Method(); auto derivedX = new DerivedX(); derivedX.basex(); derivedX.derivedx(); derivedX.targetLanguageBase2Method(); } swig-3.0.2/Examples/test-suite/d/overload_template_runme.2.d0000664000175000017500000000571112343605122023677 0ustar williamwilliammodule overload_template_runme; import std.exception; import overload_template.overload_template; import overload_template.Klass; void main() { int f = foo(); f += maximum(3,4); double b = maximum(3.4,5.2); b++; // warning suppression // mix 1 enforce(mix1("hi") == 101, "mix1(const char*)"); enforce(mix1(1.0, 1.0) == 102, "mix1(double, const double &)"); enforce(mix1(1.0) == 103, "mix1(double)"); // mix 2 enforce(mix2("hi") == 101, "mix2(const char*)"); enforce(mix2(1.0, 1.0) == 102, "mix2(double, const double &)"); enforce(mix2(1.0) == 103, "mix2(double)"); // mix 3 enforce(mix3("hi") == 101, "mix3(const char*)"); enforce(mix3(1.0, 1.0) == 102, "mix3(double, const double &)"); enforce(mix3(1.0) == 103, "mix3(double)"); // Combination 1 enforce(overtparams1(100) == 10, "overtparams1(int)"); enforce(overtparams1(100.0, 100) == 20, "overtparams1(double, int)"); // Combination 2 enforce(overtparams2(100.0, 100) == 40, "overtparams2(double, int)"); // Combination 3 enforce(overloaded() == 60, "overloaded()"); enforce(overloaded(100.0, 100) == 70, "overloaded(double, int)"); // Combination 4 enforce(overloadedagain("hello") == 80, "overloadedagain(const char *)"); enforce(overloadedagain() == 90, "overloadedagain(double)"); // specializations enforce(specialization(10) == 202, "specialization(int)"); enforce(specialization(10.0) == 203, "specialization(double)"); enforce(specialization(10, 10) == 204, "specialization(int, int)"); enforce(specialization(10.0, 10.0) == 205, "specialization(double, double)"); enforce(specialization("hi", "hi") == 201, "specialization(const char *, const char *)"); // simple specialization xyz(); xyz_int(); xyz_double(); // a bit of everything enforce(overload("hi") == 0, "overload()"); enforce(overload(1) == 10, "overload(int t)"); enforce(overload(1, 1) == 20, "overload(int t, const int &)"); enforce(overload(1, "hello") == 30, "overload(int t, const char *)"); auto k = new Klass(); enforce(overload(k) == 10, "overload(Klass t)"); enforce(overload(k, k) == 20, "overload(Klass t, const Klass &)"); enforce(overload(k, "hello") == 30, "overload(Klass t, const char *)"); enforce(overload(10.0, "hi") == 40, "overload(double t, const char *)"); enforce(overload() == 50, "overload(const char *)"); // everything put in a namespace enforce(nsoverload("hi") == 1000, "nsoverload()"); enforce(nsoverload(1) == 1010, "nsoverload(int t)"); enforce(nsoverload(1, 1) == 1020, "nsoverload(int t, const int &)"); enforce(nsoverload(1, "hello") == 1030, "nsoverload(int t, const char *)"); enforce(nsoverload(k) == 1010, "nsoverload(Klass t)"); enforce(nsoverload(k, k) == 1020, "nsoverload(Klass t, const Klass &)"); enforce(nsoverload(k, "hello") == 1030, "nsoverload(Klass t, const char *)"); enforce(nsoverload(10.0, "hi") == 1040, "nsoverload(double t, const char *)"); enforce(nsoverload() == 1050, "nsoverload(const char *)"); } swig-3.0.2/Examples/test-suite/d/director_classic_runme.1.d0000664000175000017500000001113312343605122023477 0ustar williamwilliammodule director_classic_runme; import tango.io.Stdout; import director_classic.Caller; import director_classic.Person; import director_classic.Child; import director_classic.GrandChild; import director_classic.OrphanPerson; import director_classic.OrphanChild; const bool TRACE = false; void main() { { scope person = new Person(); check(person, "Person"); } { scope person = new Child(); check(person, "Child"); } { scope person = new GrandChild(); check(person, "GrandChild"); } { scope person = new TargetLangPerson(); check(person, "TargetLangPerson"); } { scope person = new TargetLangChild(); check(person, "TargetLangChild"); } { scope person = new TargetLangGrandChild(); check(person, "TargetLangGrandChild"); } // Semis - don't override id() in target language { scope person = new TargetLangSemiPerson(); check(person, "Person"); } { scope person = new TargetLangSemiChild(); check(person, "Child"); } { scope person = new TargetLangSemiGrandChild(); check(person, "GrandChild"); } // Orphans - don't override id() in C++ { scope person = new OrphanPerson(); check(person, "Person"); } { scope person = new OrphanChild(); check(person, "Child"); } { scope person = new TargetLangOrphanPerson(); check(person, "TargetLangOrphanPerson"); } { scope person = new TargetLangOrphanChild(); check(person, "TargetLangOrphanChild"); } // Duals - id() makes an upcall to the base id() { scope person = new TargetLangDualPerson(); check(person, "TargetLangDualPerson + Person"); } { scope person = new TargetLangDualChild(); check(person, "TargetLangDualChild + Child"); } { scope person = new TargetLangDualGrandChild(); check(person, "TargetLangDualGrandChild + GrandChild"); } // Mix Orphans and Duals { scope person = new TargetLangDualOrphanPerson(); check(person, "TargetLangDualOrphanPerson + Person"); } { scope person = new TargetLangDualOrphanChild(); check(person, "TargetLangDualOrphanChild + Child"); } } void check(Person person, char[] expected) { char[] ret; // Normal D polymorphic call. ret = person.id(); if (TRACE) Stdout(ret).newline; if (ret != expected) throw new Exception("Failed. Received: " ~ ret ~ " Expected: " ~ expected); // Polymorphic call from C++. Caller caller = new Caller(); caller.setCallback(person); ret = caller.call(); if (TRACE) Stdout(ret).newline; if (ret != expected) throw new Exception("Failed. Received: " ~ ret ~ " Expected: " ~ expected); // Polymorphic call of object created in D and passed to C++ and back again. Person baseclass = caller.baseClass(); ret = baseclass.id(); if (TRACE) Stdout(ret).newline; if (ret != expected) throw new Exception("Failed. Received: " ~ ret ~ " Expected: " ~ expected); caller.resetCallback(); if (TRACE) Stdout("----------------------------------------").newline; } // »Full« target language persons. class TargetLangPerson : Person { public override char[] id() { return "TargetLangPerson"; } } class TargetLangChild : Child { public override char[] id() { return "TargetLangChild"; } } class TargetLangGrandChild : GrandChild { public override char[] id() { return "TargetLangGrandChild"; } } // Semis - don't override id() in target language class TargetLangSemiPerson : Person { // No id() override } class TargetLangSemiChild : Child { // No id() override } class TargetLangSemiGrandChild : GrandChild { // No id() override } // Orphans - don't override id() in C++ class TargetLangOrphanPerson : OrphanPerson { public override char[] id() { return "TargetLangOrphanPerson"; } } class TargetLangOrphanChild : OrphanChild { public override char[] id() { return "TargetLangOrphanChild"; } } // Duals - id() makes an upcall to the base id() class TargetLangDualPerson : Person { public override char[] id() { return "TargetLangDualPerson + " ~ super.id(); } } class TargetLangDualChild : Child { public override char[] id() { return "TargetLangDualChild + " ~ super.id(); } } class TargetLangDualGrandChild : GrandChild { public override char[] id() { return "TargetLangDualGrandChild + " ~ super.id(); } } // Mix Orphans and Duals class TargetLangDualOrphanPerson : OrphanPerson { public override char[] id() { return "TargetLangDualOrphanPerson + " ~ super.id(); } } class TargetLangDualOrphanChild : OrphanChild { public override char[] id() { return "TargetLangDualOrphanChild + " ~ super.id(); } } swig-3.0.2/Examples/test-suite/d/li_std_except_runme.2.d0000664000175000017500000000165712343605122023024 0ustar williamwilliammodule li_std_except_runme; import std.exception; import std.stdio; import li_std_except.Test; void main() { with (new Test()) { enforce(works!(Exception)(&throw_bad_exception)); enforce(works!(Exception)(&throw_domain_error)); enforce(works!(Exception)(&throw_exception)); enforce(works!(Exception)(&throw_invalid_argument)); enforce(works!(Exception)(&throw_length_error)); enforce(works!(Exception)(&throw_logic_error)); enforce(works!(Exception)(&throw_out_of_range)); enforce(works!(Exception)(&throw_overflow_error)); enforce(works!(Exception)(&throw_range_error)); enforce(works!(Exception)(&throw_runtime_error)); enforce(works!(Exception)(&throw_underflow_error)); } } bool works(alias E, F)(F f) { try { try { f(); } catch(E) { return true; } } catch(Exception e) { writefln( "Received wrong exception: %s", e.classinfo.name ); } return false; } swig-3.0.2/Examples/test-suite/d/director_basic_runme.1.d0000664000175000017500000000261012343605122023137 0ustar williamwilliammodule director_basic_runme; import director_basic.A1; import director_basic.Bar; import director_basic.Foo; import director_basic.MyClass; void main() { auto a = new director_basic_MyFoo(); if (a.ping() != "director_basic_MyFoo::ping()") { throw new Exception("a.ping()"); } if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") { throw new Exception("a.pong()"); } auto b = new Foo(); if (b.ping() != "Foo::ping()") { throw new Exception("b.ping()"); } if (b.pong() != "Foo::pong();Foo::ping()") { throw new Exception("b.pong()"); } { scope a1 = new A1(1, false); } { auto my = new MyOverriddenClass(); my.expectNull = true; if (MyClass.call_pmethod(my, null) !is null) throw new Exception("null pointer conversion problem"); auto myBar = new Bar(); my.expectNull = false; auto myNewBar = MyClass.call_pmethod(my, myBar); if (myNewBar is null) throw new Exception("non-null pointer conversion problem"); myNewBar.x = 10; } } class director_basic_MyFoo : Foo { public override char[] ping() { return "director_basic_MyFoo::ping()"; } } class MyOverriddenClass : MyClass { public bool expectNull = false; public bool nonNullReceived = false; public override Bar pmethod(Bar b) { if (expectNull && (b !is null)) throw new Exception("null not received as expected"); return b; } } swig-3.0.2/Examples/test-suite/d/virtual_poly_runme.2.d0000664000175000017500000000104412343605122022715 0ustar williamwilliammodule virtual_poly_runme; import std.exception; import virtual_poly.NDouble; import virtual_poly.NInt; import virtual_poly.NNumber; void main() { // D supports covariant (polymorphic) return types, so this should work like // in C++. auto d = new NDouble(3.5); NDouble dc = d.copy(); enforce(d.get() == dc.get(), "Test 1 failed."); auto i = new NInt(2); NInt ic = i.copy(); enforce(i.get() == ic.get(), "Test 2 failed."); NNumber n = d; auto nd = cast(NDouble) n.copy(); enforce(nd.get() == d.get(), "Test 3 failed."); } swig-3.0.2/Examples/test-suite/d/catches_runme.2.d0000664000175000017500000000176512343605122021610 0ustar williamwilliammodule catches_runme; import catches.catches; void main() { test({ test_catches(1); }, "C++ int exception thrown, value: 1"); test({ test_catches(2); }, "two"); test({ test_catches(3); }, "C++ ThreeException const & exception thrown"); test({ test_exception_specification(1); }, "C++ int exception thrown, value: 1"); test({ test_exception_specification(2); }, "unknown exception"); test({ test_exception_specification(3); }, "unknown exception"); test({ test_catches_all(1); }, "unknown exception"); } void test(void delegate() command, string expectedMessage) { bool didntThrow; try { command(); didntThrow = true; } catch (Exception e) { if (e.msg != expectedMessage) { throw new Exception("Failed to propagate C++ exception. Expected '" ~ expectedMessage ~ "', but received '" ~ e.msg ~ "'."); } } if (didntThrow) { throw new Exception("Failed to propagate C++ exception. Expected '" ~ expectedMessage ~ "', but no exception was thrown."); } } swig-3.0.2/Examples/test-suite/d/inherit_target_language_runme.2.d0000664000175000017500000000156312343605122025045 0ustar williamwilliammodule inherit_target_language_runme; import inherit_target_language.BaseX; import inherit_target_language.Derived1; import inherit_target_language.Derived2; import inherit_target_language.DerivedX; import inherit_target_language.MultipleDerived1; import inherit_target_language.MultipleDerived2; import inherit_target_language.MultipleDerived3; import inherit_target_language.MultipleDerived4; void main() { (new Derived1()).targetLanguageBaseMethod(); (new Derived2()).targetLanguageBaseMethod(); (new MultipleDerived1()).targetLanguageBaseMethod(); (new MultipleDerived2()).targetLanguageBaseMethod(); (new MultipleDerived3()).f(); (new MultipleDerived4()).g(); auto baseX = new BaseX(); baseX.basex(); baseX.targetLanguageBase2Method(); auto derivedX = new DerivedX(); derivedX.basex(); derivedX.derivedx(); derivedX.targetLanguageBase2Method(); } swig-3.0.2/Examples/test-suite/d/char_strings_runme.1.d0000664000175000017500000001160012343605122022650 0ustar williamwilliammodule char_strings_runme; import tango.text.convert.Integer; import char_strings.char_strings; const char[] CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; const char[] OTHERLAND_MSG = "Little message from the safe world."; void main() { const uint count = 10000; uint i = 0; // get functions for (i=0; i= c); assert(b > d); assert(b >= d); // test += auto e = new Op(3); e += d; assert(e == b); e -= c; assert(e == a); e = new Op(1); e *= b; assert(e == c); e /= d; assert(e == d); e %= c; assert(e == d); // test + auto f = new Op(1); auto g = new Op(1); assert(f + g == new Op(2)); assert(f - g == new Op(0)); assert(f * g == new Op(1)); assert(f / g == new Op(1)); assert(f % g == new Op(0)); // test unary operators assert(-a == a); assert(-b == new Op(-5)); // The unary ! operator is not overloadable in D1. // test [] auto h = new Op(3); assert(h[0]==3); assert(h[1]==0); // Generation of opIndexAssign is not supported yet. // test () auto i = new Op(3); assert(i()==3); assert(i(1)==4); assert(i(1,2)==6); // test ++ and -- auto j = new Op(100); int original = j.i; { Op newOp = j++; int newInt = original++; assert(j.i == original); assert(newOp.i == newInt); } { Op newOp = j--; int newInt = original--; assert(j.i == original); assert(newOp.i == newInt); } // Prefix increment/decrement operators are lowered to (foo +=/-= 1) in D1, // but the test case does not define an integer overload for operator += // respectively -=. // Implicit casting is not overloadable in D1. }swig-3.0.2/Examples/test-suite/char_constant.i0000664000175000017500000000057412343605122021235 0ustar williamwilliam/* This interface file tests whether character constants are correctly wrapped as procedures returning Scheme characters (rather than Scheme strings). */ %module char_constant #define CHAR_CONSTANT 'x' #define STRING_CONSTANT "xyzzy" #define ESC_CONST '\1' #define NULL_CONST '\0' #define SPECIALCHAR 'á' %inline { const int ia = (int)'a'; const int ib = 'b'; } swig-3.0.2/Examples/test-suite/callback.i0000664000175000017500000000202312343605122020132 0ustar williamwilliam%module callback %callback(1) foo; %callback(1) foof; %callback(1) A::bar; %callback(1) A::foom; %callback("%s_Cb_Ptr") foo_T; // old style, still works. %inline %{ int foo(int a) { return a; } int foof(int a) { return 3*a; } struct A { static int bar(int a) { return 2*a; } int foom(int a) { return -a; } //friend int foof(int a); }; extern "C" int foobar(int a, int (*pf)(int a)) { return pf(a); } extern "C" int foobarm(int a, A ap, int (A::*pf)(int a)) { return (ap.*pf)(a); } template T foo_T(T a) { return a; } template T foo_T(T a, T b) { return a + b; } template T foobar_T(T a, T (*pf)(T a)) { return pf(a); } template const T& ident(const T& x) { return x; } %} %template(foo_i) foo_T; %template(foobar_i) foobar_T; %template(foo_d) foo_T; %template(foobar_d) foobar_T; %template(ident_d) ident; swig-3.0.2/Examples/test-suite/director_basic.i0000664000175000017500000000367212343605122021365 0ustar williamwilliam%module(directors="1") director_basic %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod; %{ #include class Foo { public: virtual ~Foo() {} virtual std::string ping() { return "Foo::ping()"; } virtual std::string pong() { return "Foo::pong();" + ping(); } static Foo* get_self(Foo *slf) {return slf;} }; %} %include %feature("director") Foo; class Foo { public: virtual ~Foo(); virtual std::string ping(); virtual std::string pong(); static Foo* get_self(Foo *slf); }; %{ #include %} %feature("director") A; // basic renaming %rename(rg) A::gg; %feature("nodirector") hi::A1::gg; %inline %{ struct A{ A(std::complex i, double d=0.0) {} A(int i, bool j=false) {} virtual ~A() {} virtual int f(int i=0) {return i;} virtual int gg(int i=0) {return i;} }; namespace hi { struct A1 : public A { A1(std::complex i, double d=0.0) : A(i, d) {} A1(int i, bool j=false) : A(i, j) {} virtual int ff(int i = 0) {return i;} }; } %} %feature("director") MyClass; %inline %{ typedef void VoidType; struct Bar { int x; Bar(int _x = 0) : x(_x) { } }; class MyClass { public: MyClass(int a = 0) { } virtual void method(VoidType *) { } virtual ~MyClass() { } virtual Bar vmethod(Bar b) { b.x += 13; return b; } virtual Bar* pmethod(Bar *b) { b->x += 12; return b; } Bar cmethod(const Bar &b) { return vmethod(b); } static MyClass *get_self(MyClass *c) { return c; } static Bar * call_pmethod(MyClass *myclass, Bar *b) { return myclass->pmethod(b); } }; template class MyClassT { public: MyClassT(int a = 0) { } virtual void method(VoidType *) { } virtual ~MyClassT() { } }; %} %template(MyClassT_i) MyClassT; swig-3.0.2/Examples/test-suite/nested_scope.i0000664000175000017500000000070012343605122021051 0ustar williamwilliam%module nested_scope #if !defined(SWIGCSHARP) && !defined(SWIGJAVA) %feature ("flatnested"); #endif %inline %{ namespace ns { // "global" is a case-insensitive keyword in PHP. struct Global_ { #ifdef __clang__ struct Outer { struct Nested; struct Nested { int data; }; }; struct Outer::Nested instance; #else struct Outer { struct Nested; }; struct Outer::Nested { int data; } instance; #endif }; } %} swig-3.0.2/Examples/test-suite/li_std_except_as_class.i0000664000175000017500000000133212343605122023076 0ustar williamwilliam/* File : li_std_except_as_class.i */ %module li_std_except_as_class /* NOTE: SF bug 1295: * if there were also functions throwing 'std::logic_error' and * 'std::exception' then the bug would not be fully replicated */ %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %{ #include #include void test_domain_error() throw(std::domain_error) { throw std::domain_error("std::domain_error"); } %} %include #define SWIG_STD_EXCEPTIONS_AS_CLASSES %include void test_domain_error() throw(std::domain_error) { throw std::domain_error("std::domain_error"); } swig-3.0.2/Examples/test-suite/li_cpointer.i0000664000175000017500000000034712343605122020714 0ustar williamwilliam%module li_cpointer %warnfilter(SWIGWARN_RUBY_WRONG_NAME) doublep; /* Ruby, wrong class name */ %include "cpointer.i" %pointer_functions(int,intp); %pointer_class(double,doublep); %pointer_cast(int, unsigned int, int_to_uint); swig-3.0.2/Examples/test-suite/li_boost_shared_ptr.i0000664000175000017500000003205512343605122022433 0ustar williamwilliam// This tests shared_ptr is working okay. It also checks that there are no memory leaks in the // class that shared_ptr is pointing via a counting mechanism in the constructors and destructor of Klass. // In order to test that there are no leaks of the shared_ptr class itself (as it is created on the heap) // the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools // like 'top'. There is a wrapper for shared_ptr in shared_ptr_wrapper.h which enables one to // count the instances of shared_ptr. Uncomment the SHARED_PTR_WRAPPER macro to turn this on. // // Also note the debug_shared flag which can be set from the target language. %module li_boost_shared_ptr %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); %inline %{ #include "boost/shared_ptr.hpp" #include "swig_examples_lock.h" // Uncomment macro below to turn on shared_ptr memory leak checking as described above //#define SHARED_PTR_WRAPPER #ifdef SHARED_PTR_WRAPPER # include "shared_ptr_wrapper.h" #endif %} %{ #ifndef SHARED_PTR_WRAPPER # define SwigBoost boost #endif %} %include "std_string.i" #ifndef SHARED_PTR_WRAPPER # define SWIG_SHARED_PTR_NAMESPACE SwigBoost #endif #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) %include %shared_ptr(Space::Klass) %shared_ptr(Space::KlassDerived) %shared_ptr(Space::Klass2ndDerived) %shared_ptr(Space::Klass3rdDerived) %shared_ptr(IgnoredMultipleInheritBase) // IgnoredMultipleInheritBase not actually used in any wrapped functions, so this isn't entirely necessary and warning 520 could instead have been suppressed. #endif // TODO: // const shared_ptr // std::vector // Add in generic %extend for the Upcast function for derived classes // Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method %exception { if (debug_shared) { cout << "++++++" << endl; cout << "calling $name" << endl; } $action if (debug_shared) { cout << "------" << endl; } } %ignore IgnoredMultipleInheritBase; %ignore Space::Klass::operator=; %newobject pointerownertest(); %newobject smartpointerpointerownertest(); %inline %{ #include using namespace std; static bool debug_shared = false; namespace Space { struct Klass { Klass() : value("EMPTY") { if (debug_shared) cout << "Klass() [" << value << "]" << endl; increment(); } Klass(const std::string &val) : value(val) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl; increment(); } virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl; decrement(); } virtual std::string getValue() const { return value; } void append(const std::string &s) { value += s; } Klass(const Klass &other) : value(other.value) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl; increment(); } Klass &operator=(const Klass &other) { value = other.value; return *this; } static int getTotal_count() { return total_count; } private: // lock increment and decrement as a destructor could be called at the same time as a // new object is being created - C# / Java, at least, have finalizers run in a separate thread static SwigExamples::CriticalSection critical_section; static void increment() { SwigExamples::Lock lock(critical_section); total_count++; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;} static void decrement() { SwigExamples::Lock lock(critical_section); total_count--; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;} static int total_count; std::string value; int array[1024]; }; SwigExamples::CriticalSection Space::Klass::critical_section; struct IgnoredMultipleInheritBase { IgnoredMultipleInheritBase() : d(0.0), e(0.0) {} virtual ~IgnoredMultipleInheritBase() {} double d; double e; virtual void AVirtualMethod() {} }; // For most compilers, this use of multiple inheritance results in different derived and base class // pointer values ... for some more challenging tests :) struct KlassDerived : IgnoredMultipleInheritBase, Klass { KlassDerived() : Klass() {} KlassDerived(const std::string &val) : Klass(val) {} KlassDerived(const KlassDerived &other) : Klass(other) {} virtual ~KlassDerived() {} virtual std::string getValue() const { return Klass::getValue() + "-Derived"; } }; KlassDerived* derivedpointertest(KlassDerived* kd) { if (kd) kd->append(" derivedpointertest"); return kd; } KlassDerived& derivedreftest(KlassDerived& kd) { kd.append(" derivedreftest"); return kd; } SwigBoost::shared_ptr derivedsmartptrtest(SwigBoost::shared_ptr kd) { if (kd) kd->append(" derivedsmartptrtest"); return kd; } SwigBoost::shared_ptr* derivedsmartptrpointertest(SwigBoost::shared_ptr* kd) { if (kd && *kd) (*kd)->append(" derivedsmartptrpointertest"); return kd; } SwigBoost::shared_ptr* derivedsmartptrreftest(SwigBoost::shared_ptr* kd) { if (kd && *kd) (*kd)->append(" derivedsmartptrreftest"); return kd; } SwigBoost::shared_ptr*& derivedsmartptrpointerreftest(SwigBoost::shared_ptr*& kd) { if (kd && *kd) (*kd)->append(" derivedsmartptrpointerreftest"); return kd; } // 3 classes in inheritance chain test struct Klass2ndDerived : Klass { Klass2ndDerived() : Klass() {} Klass2ndDerived(const std::string &val) : Klass(val) {} }; struct Klass3rdDerived : IgnoredMultipleInheritBase, Klass2ndDerived { Klass3rdDerived() : Klass2ndDerived() {} Klass3rdDerived(const std::string &val) : Klass2ndDerived(val) {} virtual ~Klass3rdDerived() {} virtual std::string getValue() const { return Klass2ndDerived::getValue() + "-3rdDerived"; } }; std::string test3rdupcast( SwigBoost::shared_ptr< Klass > k) { return k->getValue(); } SwigBoost::shared_ptr factorycreate() { return SwigBoost::shared_ptr(new Klass("factorycreate")); } // smart pointer SwigBoost::shared_ptr smartpointertest(SwigBoost::shared_ptr k) { if (k) k->append(" smartpointertest"); return SwigBoost::shared_ptr(k); } SwigBoost::shared_ptr* smartpointerpointertest(SwigBoost::shared_ptr* k) { if (k && *k) (*k)->append(" smartpointerpointertest"); return k; } SwigBoost::shared_ptr& smartpointerreftest(SwigBoost::shared_ptr& k) { if (k) k->append(" smartpointerreftest"); return k; } SwigBoost::shared_ptr*& smartpointerpointerreftest(SwigBoost::shared_ptr*& k) { if (k && *k) (*k)->append(" smartpointerpointerreftest"); return k; } // const SwigBoost::shared_ptr constsmartpointertest(SwigBoost::shared_ptr k) { return SwigBoost::shared_ptr(k); } SwigBoost::shared_ptr* constsmartpointerpointertest(SwigBoost::shared_ptr* k) { return k; } SwigBoost::shared_ptr& constsmartpointerreftest(SwigBoost::shared_ptr& k) { return k; } // plain pointer Klass valuetest(Klass k) { k.append(" valuetest"); return k; } Klass *pointertest(Klass *k) { if (k) k->append(" pointertest"); return k; } Klass& reftest(Klass& k) { k.append(" reftest"); return k; } Klass *const& pointerreftest(Klass *const& k) { k->append(" pointerreftest"); return k; } // null std::string nullsmartpointerpointertest(SwigBoost::shared_ptr* k) { if (k && *k) return "not null"; else if (!k) return "null smartpointer pointer"; else if (!*k) return "null pointer"; else return "also not null"; } // $owner Klass *pointerownertest() { return new Klass("pointerownertest"); } SwigBoost::shared_ptr* smartpointerpointerownertest() { return new SwigBoost::shared_ptr(new Klass("smartpointerpointerownertest")); } // Provide overloads for Klass and derived classes as some language modules, eg Python, create an extra reference in // the marshalling if an upcast to a base class is required. long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } const SwigBoost::shared_ptr& ref_1() { static SwigBoost::shared_ptr sptr; return sptr; } // overloading tests std::string overload_rawbyval(int i) { return "int"; } std::string overload_rawbyval(Klass k) { return "rawbyval"; } std::string overload_rawbyref(int i) { return "int"; } std::string overload_rawbyref(Klass &k) { return "rawbyref"; } std::string overload_rawbyptr(int i) { return "int"; } std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; } std::string overload_rawbyptrref(int i) { return "int"; } std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; } std::string overload_smartbyval(int i) { return "int"; } std::string overload_smartbyval(SwigBoost::shared_ptr k) { return "smartbyval"; } std::string overload_smartbyref(int i) { return "int"; } std::string overload_smartbyref(SwigBoost::shared_ptr &k) { return "smartbyref"; } std::string overload_smartbyptr(int i) { return "int"; } std::string overload_smartbyptr(SwigBoost::shared_ptr *k) { return "smartbyptr"; } std::string overload_smartbyptrref(int i) { return "int"; } std::string overload_smartbyptrref(SwigBoost::shared_ptr *&k) { return "smartbyptrref"; } } // namespace Space %} %{ int Space::Klass::total_count = 0; %} // Member variables %inline %{ struct MemberVariables { MemberVariables() : SmartMemberPointer(&SmartMemberValue), SmartMemberReference(SmartMemberValue), MemberPointer(0), MemberReference(MemberValue) {} SwigBoost::shared_ptr SmartMemberValue; SwigBoost::shared_ptr * SmartMemberPointer; SwigBoost::shared_ptr & SmartMemberReference; Space::Klass MemberValue; Space::Klass * MemberPointer; Space::Klass & MemberReference; }; // Global variables SwigBoost::shared_ptr GlobalSmartValue; Space::Klass GlobalValue; Space::Klass * GlobalPointer = 0; Space::Klass & GlobalReference = GlobalValue; %} #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) // Note: %template after the shared_ptr typemaps %shared_ptr(Base) %shared_ptr(Pair) #endif // Templates %inline %{ template struct Base { Space::Klass klassBase; T1 baseVal1; T2 baseVal2; Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {} virtual std::string getValue() const { return "Base<>"; }; }; %} %template(BaseIntDouble) Base; %inline %{ template struct Pair : Base { Space::Klass klassPair; T1 val1; T2 val2; Pair(T1 t1, T2 t2) : Base(t1, t2), val1(t1), val2(t2) {} virtual std::string getValue() const { return "Pair<>"; }; }; Pair pair_id2(Pair p) { return p; } SwigBoost::shared_ptr< Pair > pair_id1(SwigBoost::shared_ptr< Pair > p) { return p; } %} %template(PairIntDouble) Pair; // For counting the instances of shared_ptr (all of which are created on the heap) // shared_ptr_wrapper_count() gives overall count %inline %{ namespace SwigBoost { const int NOT_COUNTING = -123456; int shared_ptr_wrapper_count() { #ifdef SHARED_PTR_WRAPPER return SwigBoost::SharedPtrWrapper::getTotalCount(); #else return NOT_COUNTING; #endif } #ifdef SHARED_PTR_WRAPPER template<> std::string show_message(boost::shared_ptr*t) { if (!t) return "null shared_ptr!!!"; if (boost::get_deleter(*t)) return "Klass NULL DELETER"; // pointer may be dangling so cannot use it if (*t) return "Klass: " + (*t)->getValue(); else return "Klass: NULL"; } template<> std::string show_message(boost::shared_ptr*t) { if (!t) return "null shared_ptr!!!"; if (boost::get_deleter(*t)) return "Klass NULL DELETER"; // pointer may be dangling so cannot use it if (*t) return "Klass: " + (*t)->getValue(); else return "Klass: NULL"; } template<> std::string show_message(boost::shared_ptr*t) { if (!t) return "null shared_ptr!!!"; if (boost::get_deleter(*t)) return "KlassDerived NULL DELETER"; // pointer may be dangling so cannot use it if (*t) return "KlassDerived: " + (*t)->getValue(); else return "KlassDerived: NULL"; } template<> std::string show_message(boost::shared_ptr*t) { if (!t) return "null shared_ptr!!!"; if (boost::get_deleter(*t)) return "KlassDerived NULL DELETER"; // pointer may be dangling so cannot use it if (*t) return "KlassDerived: " + (*t)->getValue(); else return "KlassDerived: NULL"; } #endif } %} swig-3.0.2/Examples/test-suite/clientdata_prop.list0000664000175000017500000000004412343605122022272 0ustar williamwilliamclientdata_prop_a clientdata_prop_b swig-3.0.2/Examples/test-suite/li_std_vector_ptr.i0000664000175000017500000000075612343605122022136 0ustar williamwilliam// Bug 2359417 %module li_std_vector_ptr %include "std_vector.i" %template(IntPtrVector) std::vector; %inline %{ #include using namespace std; int* makeIntPtr(int v) { return new int(v); } double* makeDoublePtr(double v) { return new double(v); } #if 1 int** makeIntPtrPtr(int* v) { return new int*(v); } #endif void displayVector(std::vector vpi) { cout << "displayVector..." << endl; for (int i=0; i %inline %{ #include // Anonymous arguments int anonymous(int = 7771); int anonymous(int x) { return x; } // Bug [548272] Default arguments bool booltest(bool x = true) { return x; } // scoped enums enum flavor { BITTER, SWEET }; class EnumClass { public: enum speed { FAST, SLOW }; // Note: default values should be EnumClass::FAST and SWEET bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); }; }; // casts const char * casts1(const char *m = (const char *) NULL) { char *ret = NULL; if (m) { ret = new char[strlen(m)+1]; strcpy(ret, m); } return ret; } const char * casts2(const char *m = (const char *) "Hello") { char *ret = NULL; if (m) { ret = new char[strlen(m)+1]; strcpy(ret, m); } return ret; } // char char chartest1(char c = 'x') { return c; } char chartest2(char c = '\0') { return c; } // namespaces namespace AType { enum AType { NoType }; } void dummy(AType::AType aType = AType::NoType) {} namespace A { namespace B { int CONST_NUM = 10; } int afunction(int i = B::CONST_NUM) { return i; } } // references int reftest1(const int &x = 42) { return x; } std::string reftest2(const std::string &x = "hello") { return x; } // enum scope class Tree { public: enum types {Oak, Fir, Cedar}; void chops(enum types type) {} void test(int x = Oak + Fir + Cedar) {} }; enum Tree::types chops(enum Tree::types type) { return type; } %} // Rename a class member %rename(bar2) Foo::bar; %rename(newname) Foo::oldname(int x = 1234); %ignore Foo::Foo(int x, int y = 0, int z = 0); %ignore Foo::meth(int x, int y = 0, int z = 0); %rename(renamed3arg) Foo::renameme(int x, double d) const; %rename(renamed2arg) Foo::renameme(int x) const; %rename(renamed1arg) Foo::renameme() const; %inline %{ // Define a class class Foo { public: static int bar; static int spam; Foo(){} Foo(int x, int y = 0, int z = 0){} void meth(int x, int y = 0, int z = 0){} // Use a renamed member as a default argument. SWIG has to resolve // bar to Foo::bar and not Foo::spam. SWIG-1.3.11 got this wrong. // (Different default parameter wrapping in SWIG-1.3.23 ensures SWIG doesn't have to resolve these symbols). void method1(int x = bar) {} // Use unrenamed member as default void method2(int x = spam) {} // test the method itself being renamed void oldname(int x = 1234) {} void renameme(int x = 1234, double d=123.4) const {} }; int Foo::bar = 1; int Foo::spam = 2; %} // tests valuewrapper %feature("compactdefaultargs") MyClass2::set; %inline %{ enum MyType { Val1, Val2 }; class MyClass1 { public: MyClass1(MyType myType) {} }; class MyClass2 { public : void set(MyClass1 cl1 = Val1) {} // This could have been written : set(MyClass1 cl1 = MyClass1(Val1)) // But it works in C++ since there is a "conversion" constructor in MyClass1. void set2(MyClass1 cl1 = Val1) {} }; %} // Default parameters with exception specifications %inline %{ void exceptionspec(int a = -1) throw (int, const char*) { if (a == -1) throw "ciao"; else throw a; } struct Except { Except(bool throwException, int a = -1) throw (int) { if (throwException) throw a; } void exspec(int a = 0) throw (int, const char*) { ::exceptionspec(a); } }; %} // Default parameters in static class methods #ifdef SWIGPYTHON %rename(staticMethod) staticmethod; #endif %inline %{ namespace SpaceName { struct Statics { static int staticmethod(int a=10, int b=20, int c=30) { return a+b+c; } }; } %} // Tests which could never be wrapped prior to changes in default argument wrapping implemented in SWIG-1.3.23: %inline %{ class Tricky { static int getDefault() { return 500; } enum { privatevalue = 200 }; static const char charvalue; public: int privatedefault(int val = privatevalue) { return val; } int protectedint(int val = intvalue) { return val; } double protecteddouble(double val = doublevalue) { return val; } int functiondefault(int val = Tricky::getDefault()) { return val; } char contrived(const char *c = &charvalue) { return *c; } protected: static const int intvalue = 2000; static const double doublevalue; }; const char Tricky::charvalue = 'X'; const double Tricky::doublevalue = 987.654; // tests default argument which is a constructor call within namespace // also tests default constructor (from defaulted parameter) namespace Space { struct Klass { int val; Klass(int val = -1) : val(val) {} }; Klass constructorcall(const Klass& k = Klass()) { return k; } } %} %{ struct ConstMethods { int coo(double d = 0.0) { return 10; } int coo(double d = 0.0) const { return 20; } }; %} // const methods // runtime test needed to check that the const method is called struct ConstMethods { int coo(double d = 0.0) const; }; // Default args with C linkage %inline %{ extern "C" double cfunc1(double x,double p = 1) { return(x+p); } extern "C" { double cfunc2(double x,double p = 2) { return(x+p); } double cfunc3(double x,double p = 3) { return(x+p); } typedef struct Pointf { double x,y; } Pointf; } %} swig-3.0.2/Examples/test-suite/lextype.i0000664000175000017500000000275412343605122020103 0ustar williamwilliam/* This module tests whether SWIG sets the '$lextype' variable correctly. This variable maintains the literal base name of the type in the wrapper code - it's therefore usually the same as '$basetype', but NOT ALWAYS. In the example below, the typemap definitions are written for any type of 'Animal', but are parameterized through preprocessor definitions. So when wrapping functions which explicitly reference Giraffes, the wrapper code can behave appropriately for that particular species. For this to work correctly however, it is critical that there is a variable which strictly preserves the name of the type. '$basetype' doesn't currently do this - it sometimes contains 'Giraffe' and sometimes (specifically the case of arrays) contains 'Animal'. Since existing code may rely on that behaviour, we create a new variable '$lextype' which does what we need. There is no need for any runtime test here, since if the code is not functioning properly it will fail to compile. */ %module lextype %{ #include %} %typemap(in) Animal () { void *space_needed = malloc(HEIGHT_$1_lextype * WIDTH_$1_lextype); $1 = ($1_ltype)space_needed; } %typemap(in) Animal[2] () { void *space_needed = malloc(2 * HEIGHT_$1_lextype * WIDTH_$1_lextype); $1 = ($1_ltype)space_needed; } %inline %{ #define HEIGHT_Giraffe 100 #define WIDTH_Giraffe 5 typedef void * Animal; typedef Animal Giraffe; void eat(Giraffe g) {} void drink(Giraffe *g) {} Giraffe mate(Giraffe g[2]) { return g[0]; } %} swig-3.0.2/Examples/test-suite/nested_extend_c.i0000664000175000017500000000325712343605122021543 0ustar williamwilliam%module nested_extend_c #if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) %extend hiA { hiA() { union hiA *self = (union hiA *)malloc(sizeof(union hiA)); self->c = 'h'; return self; } char hi_extend() { return $self->c; } static const long swig_size = sizeof(union hiA); } %extend lowA { lowA() { struct lowA *self = (struct lowA *)malloc(sizeof(struct lowA)); self->name = 0; self->num = 99; return self; } int low_extend() { return $self->num; } static const long swig_size = sizeof(struct lowA); } %extend hiB { hiB() { union hiB *self = (union hiB *)malloc(sizeof(union hiB)); self->c = 'h'; return self; } char hi_extend() { return $self->c; } static const long swig_size = sizeof(union hiB); } %extend lowB { lowB() { struct lowB *self = (struct lowB *)malloc(sizeof(struct lowB)); self->name = 0; self->num = 99; return self; } int low_extend() { return $self->num; } static const long swig_size = sizeof(struct lowB); } %extend FOO_bar { void bar_extend() { $self->d = 1; } }; %extend NestedA { static const long swig_size = sizeof(struct NestedA); } #endif %inline %{ typedef struct NestedA { int a; union hiA { char c; int d; } hiA_instance; struct lowA { char *name; int num; } lowA_instance; } NestedA; typedef struct { int a; union hiB { char c; int d; } hiB_instance; struct lowB { char *name; int num; } lowB_instance; } NestedB; typedef struct { int a; union { char c; int d; } bar; } FOO; struct { int i; } THING; %} swig-3.0.2/Examples/test-suite/director_keywords.i0000664000175000017500000000052412343605122022144 0ustar williamwilliam// Checks if collisions of argument names with target language keywords are // resolved properly when directors are used (currently only »abstract« for // C#, D and Java is checked). %module(directors="1") director_keywords %feature("director") Foo; %inline %{ struct Foo { virtual ~Foo() {} virtual void bar(int abstract) {} }; %} swig-3.0.2/Examples/test-suite/README0000664000175000017500000000412512343605122017111 0ustar williamwilliamSWIG testsuite README file -------------------------- This testsuite is here to ensure SWIG can handle a wide range of c/c++ syntax. The testsuite comprises many testcases in this directory. Each test case is tested under each of the language modules thereby thoroughly testing all of SWIG. It ensures that each of the language modules are at a similar standard. Those modules that support shadow classes run the tests producing shadow classes to test the full language module functionality. Some test cases need a runtime test. These need implementing in each of the language modules. The language modules look for a file in the language specific test-suite directory which has _runme appended after the testcase name. If one is found it will be run as part of the test. Some language modules add to this common set of test cases for language specific tests. These can be found in the appropriate language test-suite directory. There is also a README in each of the language module directories. For each testcase a message showing which testcase is being tested is displayed. Nothing else is printed unless the test fails. Some Developer Guidelines ------------------------- Note that the whole test suite need not be run each time a testcase is modified. An individual testcase may be run by going to the language module test-suite directory and using make testcasename.xxx where xxx is the type of test (eg cpptest). See common.mk. make -s doesn't print any junk on the screen and is useful for emulating the way make check works from the SWIG root directory. If there are runtime tests needed, don't print anything unless there is an error in which case stderr is suggested. Please set the name of the module to the same name as the testcase, otherwise modules will not be found. There is a special directory called testdir for testcases requiring inputs from subdirectories or multiple directories. See the testdir/README file. Further Documentation --------------------- There is documentation about the test-suite and how to use use it in the SWIG documentation - Doc/Manual/Extending.html#Extending_test_suite. swig-3.0.2/Examples/test-suite/rename_simple.i0000664000175000017500000000136012343605122021221 0ustar williamwilliam%module rename_simple %rename(NewStruct) OldStruct; %rename(NewVariable) OldVariable; %rename(NewInstanceMethod) OldInstanceMethod; %rename(NewInstanceVariable) OldInstanceVariable; %rename(NewStaticMethod) OldStaticMethod; %rename(NewStaticVariable) OldStaticVariable; %rename(NewFunction) OldFunction; %rename(NewGlobalVariable) OldGlobalVariable; %inline %{ struct OldStruct { enum { ONE = 1, TWO, THREE }; OldStruct() : OldInstanceVariable(111) {} int OldInstanceVariable; int OldInstanceMethod() { return 222; } static int OldStaticVariable; static int OldStaticMethod() { return 333; } }; int OldStruct::OldStaticVariable = 444; int OldFunction() { return 555; } int OldGlobalVariable = 666; %} swig-3.0.2/Examples/test-suite/preproc_constants.i0000664000175000017500000000501212343605122022145 0ustar williamwilliam%module preproc_constants // Note: C types are slightly different to C++ types as (a && b) is int in C and bool in C++ // Simple constants #define CONST_INT1 10 #define CONST_INT2 0xFF #define CONST_UINT1 10u #define CONST_UINT2 10U #define CONST_UINT3 0xFFu #define CONST_UINT4 0xFFU #define CONST_LONG1 10l #define CONST_LONG2 10L #define CONST_LONG3 0xFFl #define CONST_LONG4 0xFFL #define CONST_LLONG1 10LL #define CONST_LLONG2 10ll #define CONST_LLONG3 0xFFll #define CONST_LLONG4 0xFFLL #define CONST_ULLONG1 10ull #define CONST_ULLONG2 10ULL #define CONST_ULLONG3 0xFFull #define CONST_ULLONG4 0xFFULL #define CONST_DOUBLE1 10e1 #define CONST_DOUBLE2 10E1 #define CONST_DOUBLE3 12.3 #define CONST_DOUBLE4 12. #define CONST_DOUBLE5 12.3f #define CONST_DOUBLE6 12.3F #define CONST_BOOL1 true #define CONST_BOOL2 false #define CONST_CHAR 'x' #define CONST_STRING1 "const string" #define CONST_STRING2 "const" " string" #define CONST_STRING3 "log-revprops" // Expressions - runtime tests check the type for any necessary type promotions of the expressions #define INT_AND_BOOL 0xFF & true //#define INT_AND_CHAR 0xFF & 'A' /* FIXME compile error */ #define INT_AND_INT 0xFF & 2 #define INT_AND_UINT 0xFF & 2u #define INT_AND_LONG 0xFF & 2l #define INT_AND_ULONG 0xFF & 2ul #define INT_AND_LLONG 0xFF & 2ll #define INT_AND_ULLONG 0xFF & 2ull #define BOOL_AND_BOOL true & true // Note integral promotion to type int //#define CHAR_AND_CHAR 'A' & 'B' // Note integral promotion to type int /* FIXME ABOVE */ #define EXPR_MULTIPLY 0xFF * 2 #define EXPR_DIVIDE 0xFF / 2 //FIXME #define EXPR_MOD 0xFF % 2 #define EXPR_PLUS 0xFF + 2 #define EXPR_MINUS 0xFF + 2 #define EXPR_LSHIFT 0xFF << 2 #define EXPR_RSHIFT 0xFF >> 2 /* FIXME #define EXPR_LT 0xFF < 255 #define EXPR_GT 0xFF > 255 */ #define EXPR_LTE 0xFF <= 255 #define EXPR_GTE 0xFF >= 255 #define EXPR_INEQUALITY 0xFF != 255 #define EXPR_EQUALITY 0xFF == 255 #define EXPR_AND 0xFF & 1 #define EXPR_XOR 0xFF ^ 1 #define EXPR_OR 0xFF | 1 #define EXPR_LAND 0xFF && 1 #define EXPR_LOR 0xFF || 1 #define EXPR_CONDITIONAL true ? 2 : 2.2 /// constant assignment in enum #if defined(SWIGCSHARP) %csconstvalue("1<<2") kValue; #endif %{ #define BIT(n) (1ULL << (n)) enum MyEnum { kValue = BIT(2) }; %} #define BIT(n) (1ULL << (n)) enum MyEnum { kValue = BIT(2) }; swig-3.0.2/Examples/test-suite/smart_pointer_protected.i0000664000175000017500000000061312343605122023340 0ustar williamwilliam%module smart_pointer_protected %inline %{ namespace hi { struct A { virtual ~A() { } virtual int value(A*) = 0; int index; }; struct B : A { protected: int value(A*) { return 1; } }; struct C { hi::B* operator->() const { return new hi::B(); } private: int index; }; } %} swig-3.0.2/Examples/test-suite/python/0000775000175000017500000000000012343605122017550 5ustar williamwilliamswig-3.0.2/Examples/test-suite/python/naturalvar_runme.py0000664000175000017500000000020112343605122023500 0ustar williamwilliamfrom naturalvar import * f = Foo() b = Bar() b.f = f cvar.s = "hello" b.s = "hello" if b.s != cvar.s: raise RuntimeError swig-3.0.2/Examples/test-suite/python/static_const_member_2_runme.py0000664000175000017500000000046212343605122025577 0ustar williamwilliamfrom static_const_member_2 import * c = Test_int() try: a = c.forward_field a = c.current_profile a = c.RightIndex a = Test_int.backward_field a = Test_int.LeftIndex a = Test_int.cavity_flags except: raise RuntimeError if Foo.BAZ.val != 2*Foo.BAR.val: raise RuntimeError swig-3.0.2/Examples/test-suite/python/director_profile_runme.py0000664000175000017500000000102412343605122024660 0ustar williamwilliamimport director_profile class MyB(director_profile.B): def vfi(self, a): return a+3 a = director_profile.A() myb = MyB() b = director_profile.B.get_self(myb) fi = b.fi i = 50000 a = 1 while i: a = fi(a) #1 a = fi(a) #2 a = fi(a) #3 a = fi(a) #4 a = fi(a) #5 a = fi(a) #6 a = fi(a) #7 a = fi(a) #8 a = fi(a) #9 a = fi(a) #10 a = fi(a) #1 a = fi(a) #2 a = fi(a) #3 a = fi(a) #4 a = fi(a) #5 a = fi(a) #6 a = fi(a) #7 a = fi(a) #8 a = fi(a) #9 a = fi(a) #20 i -= 1 print a swig-3.0.2/Examples/test-suite/python/special_variable_macros_runme.py0000664000175000017500000000124512343605122026163 0ustar williamwilliamimport special_variable_macros name = special_variable_macros.Name() if special_variable_macros.testFred(name) != "none": raise "test failed" if special_variable_macros.testJack(name) != "$specialname": raise "test failed" if special_variable_macros.testJill(name) != "jilly": raise "test failed" if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap": raise "test failed" if special_variable_macros.testJames(name) != "SWIGTYPE_Name": raise "test failed" if special_variable_macros.testJim(name) != "multiname num": raise "test failed" if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123: raise "test failed" swig-3.0.2/Examples/test-suite/python/input_runme.py0000664000175000017500000000045512343605122022473 0ustar williamwilliamfrom input import * f = Foo() if f.foo(2) != 4: raise RuntimeError if f.foo(None)!= None: raise RuntimeError if f.foo()!= None: raise RuntimeError if sfoo("Hello") != "Hello world": raise RuntimeError if sfoo(None) != None: raise RuntimeError if sfoo() != None: raise RuntimeError swig-3.0.2/Examples/test-suite/python/smart_pointer_rename_runme.py0000664000175000017500000000027712343605122025553 0ustar williamwilliamfrom smart_pointer_rename import * f = Foo() b = Bar(f) if b.test() != 3: raise RuntimeError if b.ftest1(1) != 1: raise RuntimeError if b.ftest2(2,3) != 2: raise RuntimeError swig-3.0.2/Examples/test-suite/python/python_nondynamic_runme.py0000664000175000017500000000116412343605122025072 0ustar williamwilliamimport python_nondynamic aa = python_nondynamic.A() aa.a = 1 aa.b = 2 try: aa.c = 2 err = 0 except: err = 1 if not err: raise RuntimeError, "A is not static" class B(python_nondynamic.A): c = 4 def __init__(self): python_nondynamic.A.__init__(self) pass pass bb = B() try: bb.c = 3 err = 0 except: err = 1 if not err: print "bb.c = %d" % bb.c print "B.c = %d" % B.c raise RuntimeError, "B.c class variable messes up nondynamic-ness of B" try: bb.d = 2 err = 0 except: err = 1 if not err: raise RuntimeError, "B is not static" cc = python_nondynamic.C() cc.d = 3 swig-3.0.2/Examples/test-suite/python/minherit_runme.py0000664000175000017500000000434112343605122023151 0ustar williamwilliam import minherit a = minherit.Foo() b = minherit.Bar() c = minherit.FooBar() d = minherit.Spam() if a.xget() != 1: raise RuntimeError, "Bad attribute value" if b.yget() != 2: raise RuntimeError, "Bad attribute value" if c.xget() != 1 or c.yget() != 2 or c.zget() != 3: raise RuntimeError, "Bad attribute value" if d.xget() != 1 or d.yget() != 2 or d.zget() != 3 or d.wget() != 4: raise RuntimeError, "Bad attribute value" if minherit.xget(a) != 1: raise RuntimeError, "Bad attribute value %d" % (minherit.xget(a)) if minherit.yget(b) != 2: raise RuntimeError, "Bad attribute value %d" % (minherit.yget(b)) if minherit.xget(c) != 1 or minherit.yget(c) != 2 or minherit.zget(c) != 3: raise RuntimeError, "Bad attribute value %d %d %d" % (minherit.xget(c), minherit.yget(c), minherit.zget(c)) if minherit.xget(d) != 1 or minherit.yget(d) != 2 or minherit.zget(d) != 3 or minherit.wget(d) != 4: raise RuntimeError, "Bad attribute value %d %d %d %d" % (minherit.xget(d), minherit.yget(d), minherit.zget(d), minherit.wget(d)) # Cleanse all of the pointers and see what happens aa = minherit.toFooPtr(a) bb = minherit.toBarPtr(b) cc = minherit.toFooBarPtr(c) dd = minherit.toSpamPtr(d) if aa.xget() != 1: raise RuntimeError, "Bad attribute value" if bb.yget() != 2: raise RuntimeError, "Bad attribute value" if cc.xget() != 1 or cc.yget() != 2 or cc.zget() != 3: raise RuntimeError, "Bad attribute value" if dd.xget() != 1 or dd.yget() != 2 or dd.zget() != 3 or dd.wget() != 4: raise RuntimeError, "Bad attribute value" if minherit.xget(aa) != 1: raise RuntimeError, "Bad attribute value %d" % (minherit.xget(aa)) if minherit.yget(bb) != 2: raise RuntimeError, "Bad attribute value %d" % (minherit.yget(bb)) if minherit.xget(cc) != 1 or minherit.yget(cc) != 2 or minherit.zget(cc) != 3: raise RuntimeError, "Bad attribute value %d %d %d" % (minherit.xget(cc), minherit.yget(cc), minherit.zget(cc)) if minherit.xget(dd) != 1 or minherit.yget(dd) != 2 or minherit.zget(dd) != 3 or minherit.wget(dd) != 4: raise RuntimeError, "Bad attribute value %d %d %d %d" % (minherit.xget(dd), minherit.yget(dd), minherit.zget(dd), minherit.wget(dd)) swig-3.0.2/Examples/test-suite/python/primitive_types_runme.py0000664000175000017500000002177412343605122024577 0ustar williamwilliamfrom primitive_types import * var_init() # assigning globals calls cvar.var_bool = sct_bool cvar.var_schar = sct_schar cvar.var_uchar = sct_uchar cvar.var_int = sct_int cvar.var_uint = sct_uint cvar.var_short = sct_short cvar.var_ushort = sct_ushort cvar.var_long = sct_long cvar.var_ulong = sct_ulong cvar.var_llong = sct_llong cvar.var_ullong = sct_ullong cvar.var_char = sct_char cvar.var_pchar = sct_pchar cvar.var_pcharc = sct_pcharc cvar.var_pint = sct_pint cvar.var_sizet = sct_sizet cvar.var_hello = sct_hello cvar.var_myint = sct_myint cvar.var_namet = def_namet cvar.var_parami = sct_parami cvar.var_paramd = sct_paramd cvar.var_paramc = sct_paramc v_check() def pyerror(name, val, cte): print "bad val/cte", name, val, cte raise RuntimeError pass if cvar.var_bool != cct_bool: pyerror("bool", cvar.var_bool, cct_bool) if cvar.var_schar != cct_schar: pyerror("schar", cvar.var_schar, cct_schar) if cvar.var_uchar != cct_uchar: pyerror("uchar", cvar.var_uchar, cct_uchar) if cvar.var_int != cct_int: pyerror("int", cvar.var_int, cct_int) if cvar.var_uint != cct_uint: pyerror("uint", cvar.var_uint, cct_uint) if cvar.var_short != cct_short: pyerror("short", cvar.var_short, cct_short) if cvar.var_ushort != cct_ushort: pyerror("ushort", cvar.var_ushort, cct_ushort) if cvar.var_long != cct_long: pyerror("long", cvar.var_long, cct_long) if cvar.var_ulong != cct_ulong: pyerror("ulong", cvar.var_ulong, cct_ulong) if cvar.var_llong != cct_llong: pyerror("llong", cvar.var_llong, cct_llong) if cvar.var_ullong != cct_ullong: pyerror("ullong", cvar.var_ullong, cct_ullong) if cvar.var_char != cct_char: pyerror("char", cvar.var_char, cct_char) if cvar.var_pchar != cct_pchar: pyerror("pchar", cvar.var_pchar, cct_pchar) if cvar.var_pcharc != cct_pcharc: pyerror("pchar", cvar.var_pcharc, cct_pcharc) if cvar.var_pint != cct_pint: pyerror("pint", cvar.var_pint, cct_pint) if cvar.var_sizet != cct_sizet: pyerror("sizet", cvar.var_sizet, cct_sizet) if cvar.var_hello != cct_hello: pyerror("hello", cvar.var_hello, cct_hello) if cvar.var_myint != cct_myint: pyerror("myint", cvar.var_myint, cct_myint) if cvar.var_namet != def_namet: pyerror("name", cvar.var_namet, def_namet) class PyTest (TestDirector): def __init__(self): TestDirector.__init__(self) pass def ident(self, x): return x def vval_bool(self, x): return self.ident(x) def vval_schar(self, x): return self.ident(x) def vval_uchar(self, x): return self.ident(x) def vval_int(self, x): return self.ident(x) def vval_uint(self, x): return self.ident(x) def vval_short(self, x): return self.ident(x) def vval_ushort(self, x): return self.ident(x) def vval_long(self, x): return self.ident(x) def vval_ulong(self, x): return self.ident(x) def vval_llong(self, x): return self.ident(x) def vval_ullong(self, x): return self.ident(x) def vval_float(self, x): return self.ident(x) def vval_double(self, x): return self.ident(x) def vval_char(self, x): return self.ident(x) def vval_pchar(self, x): return self.ident(x) def vval_pcharc(self, x): return self.ident(x) def vval_pint(self, x): return self.ident(x) def vval_sizet(self, x): return self.ident(x) def vval_hello(self, x): return self.ident(x) def vval_myint(self, x): return self.ident(x) def vref_bool(self, x): return self.ident(x) def vref_schar(self, x): return self.ident(x) def vref_uchar(self, x): return self.ident(x) def vref_int(self, x): return self.ident(x) def vref_uint(self, x): return self.ident(x) def vref_short(self, x): return self.ident(x) def vref_ushort(self, x): return self.ident(x) def vref_long(self, x): return self.ident(x) def vref_ulong(self, x): return self.ident(x) def vref_llong(self, x): return self.ident(x) def vref_ullong(self, x): return self.ident(x) def vref_float(self, x): return self.ident(x) def vref_double(self, x): return self.ident(x) def vref_char(self, x): return self.ident(x) def vref_pchar(self, x): return self.ident(x) def vref_pcharc(self, x): return self.ident(x) def vref_pint(self, x): return self.ident(x) def vref_sizet(self, x): return self.ident(x) def vref_hello(self, x): return self.ident(x) def vref_myint(self, x): return self.ident(x) pass t = Test() p = PyTest() # internal call check if t.c_check() != p.c_check(): raise RuntimeError, "bad director" p.var_bool = p.stc_bool p.var_schar = p.stc_schar p.var_uchar = p.stc_uchar p.var_int = p.stc_int p.var_uint = p.stc_uint p.var_short = p.stc_short p.var_ushort = p.stc_ushort p.var_long = p.stc_long p.var_ulong = p.stc_ulong p.var_llong = p.stc_llong p.var_ullong = p.stc_ullong p.var_char = p.stc_char p.var_pchar = sct_pchar p.var_pcharc = sct_pcharc p.var_pint = sct_pint p.var_sizet = sct_sizet p.var_hello = sct_hello p.var_myint = sct_myint p.var_namet = def_namet p.var_parami = sct_parami p.var_paramd = sct_paramd p.var_paramc = sct_paramc p.v_check() t.var_bool = t.stc_bool t.var_schar = t.stc_schar t.var_uchar = t.stc_uchar t.var_int = t.stc_int t.var_uint = t.stc_uint t.var_short = t.stc_short t.var_ushort = t.stc_ushort t.var_long = t.stc_long t.var_ulong = t.stc_ulong t.var_llong = t.stc_llong t.var_ullong = t.stc_ullong t.var_char = t.stc_char t.var_pchar = sct_pchar t.var_pcharc = sct_pcharc t.var_pint = sct_pint t.var_sizet = sct_sizet t.var_hello = sct_hello t.var_myint = sct_myint t.var_namet = def_namet t.var_parami = sct_parami t.var_paramd = sct_paramd t.var_paramc = sct_paramc t.v_check() # this value contains a '0' char! if def_namet != 'hola': print "bad namet", def_namet raise RuntimeError t.var_namet = def_namet if t.var_namet != def_namet: print "bad namet", t.var_namet, def_namet raise RuntimeError t.var_namet = 'hola' if t.var_namet != 'hola': print "bad namet", t.var_namet raise RuntimeError t.var_namet = 'hol' if t.var_namet != 'hol': #if t.var_namet != 'hol\0\0': print "bad namet", t.var_namet raise RuntimeError cvar.var_char = '\0' if cvar.var_char != '\0': raise RuntimeError, "bad char '0' case" cvar.var_char = 0 if cvar.var_char != '\0': raise RuntimeError, "bad char '0' case" cvar.var_namet = '\0' #if cvar.var_namet != '\0\0\0\0\0': if cvar.var_namet != '': print 'hola', '', cvar.var_namet raise RuntimeError, "bad char '\0' case" cvar.var_namet = '' #if cvar.var_namet != '\0\0\0\0\0': if cvar.var_namet != '': raise RuntimeError, "bad char empty case" cvar.var_pchar = None if cvar.var_pchar != None: raise RuntimeError, "bad None case" cvar.var_pchar = '' if cvar.var_pchar != '': print '%c' % (cvar.var_pchar[0],) raise RuntimeError, "bad char empty case" cvar.var_pcharc = None if cvar.var_pcharc != None: raise RuntimeError, "bad None case" cvar.var_pcharc = '' if cvar.var_pcharc != '': raise RuntimeError, "bad char empty case" # # creating a raw char* # pc = new_pchar(5) pchar_setitem(pc, 0, 'h') pchar_setitem(pc, 1, 'o') pchar_setitem(pc, 2, 'l') pchar_setitem(pc, 3, 'a') pchar_setitem(pc, 4, 0) cvar.var_pchar = pc if cvar.var_pchar != "hola": print cvar.var_pchar raise RuntimeError, "bad pointer case" cvar.var_namet = pc #if cvar.var_namet != "hola\0": if cvar.var_namet != "hola": raise RuntimeError, "bad pointer case" delete_pchar(pc) # # Now when things should fail # try: error = 0 a = t.var_uchar t.var_uchar = 10000 error = 1 except OverflowError: if a != t.var_uchar: error = 1 pass if error: raise RuntimeError, "bad uchar typemap" try: error = 0 a = t.var_char t.var_char = '23' error = 1 except TypeError: if a != t.var_char: error = 1 pass if error: raise RuntimeError, "bad char typemap" try: error = 0 a = t.var_ushort t.var_ushort = -1 error = 1 except OverflowError: if a != t.var_ushort: error = 1 pass if error: raise RuntimeError, "bad ushort typemap" try: error = 0 a = t.var_uint t.var_uint = -1 error = 1 except OverflowError: if a != t.var_uint: error = 1 pass if error: raise RuntimeError, "bad uint typemap" try: error = 0 a = t.var_sizet t.var_sizet = -1 error = 1 except OverflowError: if a != t.var_sizet: error = 1 pass if error: raise RuntimeError, "bad sizet typemap" try: error = 0 a = t.var_ulong t.var_ulong = -1 error = 1 except OverflowError: if a != t.var_ulong: error = 1 pass if error: raise RuntimeError, "bad ulong typemap" # # try: error = 0 a = t.var_namet t.var_namet = '123456' error = 1 except TypeError: if a != t.var_namet: error = 1 pass if error: raise RuntimeError, "bad namet typemap" # # # t2 = p.vtest(t) if t.var_namet != t2.var_namet: raise RuntimeError, "bad SWIGTYPE* typemap" if cvar.fixsize != 'ho\0la\0\0\0': raise RuntimeError, "bad FIXSIZE typemap" cvar.fixsize = 'ho' if cvar.fixsize != 'ho\0\0\0\0\0\0': raise RuntimeError, "bad FIXSIZE typemap" f = Foo(3) f1 = fptr_val(f) f2 = fptr_ref(f) if f1._a != f2._a: raise RuntimeError, "bad const ptr& typemap" v = char_foo(1,3) if v !=3: raise RuntimeError, "bad int typemap" s = char_foo(1,"hello") if s !="hello": raise RuntimeError, "bad char* typemap" v = SetPos(1,3) if v !=4: raise RuntimeError, "bad int typemap" swig-3.0.2/Examples/test-suite/python/rename_predicates_runme.py0000664000175000017500000000205112343605122025000 0ustar williamwilliamfrom rename_predicates import * r = RenamePredicates(123) r.MF_member_function() r.MF_static_member_function() r.MF_extend_function_before() r.MF_extend_function_after() GF_global_function() if r.MV_member_variable != 123: raise RuntimeError("variable wrong") r.MV_member_variable = 1234; if r.MV_member_variable != 1234: raise RuntimeError("variable wrong") if cvar.RenamePredicates_MV_static_member_variable != 456: raise RuntimeError("variable wrong") cvar.RenamePredicates_MV_static_member_variable = 4567; if cvar.RenamePredicates_MV_static_member_variable != 4567: raise RuntimeError("variable wrong") if cvar.GV_global_variable != 789: raise RuntimeError("variable wrong") cvar.GV_global_variable = 7890; if cvar.GV_global_variable != 7890: raise RuntimeError("variable wrong") UC_UPPERCASE() LC_lowercase() TI_Title() FU_FirstUpperCase() FL_firstLowerCase() CA_CamelCase() LC_lowerCamelCase() UC_under_case_it() ex = ExtendCheck() ex.MF_real_member1() ex.MF_real_member2() ex.EX_EXTENDMETHOD1() ex.EX_EXTENDMETHOD2() ex.EX_EXTENDMETHOD3() swig-3.0.2/Examples/test-suite/python/typemap_delete_runme.py0000664000175000017500000000013412343605122024327 0ustar williamwilliamimport typemap_delete r = typemap_delete.Rect(123) if r.val != 123: raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_ns_runme.py0000664000175000017500000000041612343605122023644 0ustar williamwilliamfrom template_ns import * p1 = pairii(2,3) p2 = pairii(p1) if p2.first != 2: raise RuntimeError if p2.second != 3: raise RuntimeError p3 = pairdd(3.5,2.5) p4 = pairdd(p3) if p4.first != 3.5: raise RuntimeError if p4.second != 2.5: raise RuntimeError swig-3.0.2/Examples/test-suite/python/varargs_runme.py0000664000175000017500000000140612343605122022776 0ustar williamwilliamimport varargs if varargs.test("Hello") != "Hello": raise RuntimeError, "Failed" f = varargs.Foo("Greetings") if f.str != "Greetings": raise RuntimeError, "Failed" if f.test("Hello") != "Hello": raise RuntimeError, "Failed" if varargs.test_def("Hello",1) != "Hello": raise RuntimeError, "Failed" if varargs.test_def("Hello") != "Hello": raise RuntimeError, "Failed" ### if varargs.test_plenty("Hello") != "Hello": raise RuntimeError, "Failed" if varargs.test_plenty("Hello", 1) != "Hello": raise RuntimeError, "Failed" if varargs.test_plenty("Hello", 1, 2) != "Hello": raise RuntimeError, "Failed" try: varargs.test_plenty("Hello", 1, 2, 3) raise RuntimeError except NotImplementedError: pass except TypeError: pass swig-3.0.2/Examples/test-suite/python/template_static_runme.py0000664000175000017500000000006212343605122024510 0ustar williamwilliamfrom template_static import * Foo_bar_double(1) swig-3.0.2/Examples/test-suite/python/li_std_pair_using_runme.py0000664000175000017500000000031712343605122025027 0ustar williamwilliamfrom li_std_pair_using import * one_tuple = ("one", "numero uno") one = StringStringPair(one_tuple) two_tuple = ("two", 2) two = StringIntPair(two_tuple) if bounce(one) != one_tuple: raise RuntimeError swig-3.0.2/Examples/test-suite/python/README0000664000175000017500000000075512343605122020437 0ustar williamwilliamSee ../README for common README file. Any testcases which have _runme.py (or _runme3.py for Python 3) appended after the testcase name will be detected and run. If you intend to write a testcase for both Python 2.x and 3.x, do *not* directly put the _runme3.py in this directory. Just write Python 2.x's _runme.py testcase and it will be automatically converted to Python 3 code during test. You can run make with PY3=y to run test case with Python 3.x, eg. $ make voidtest.cpptest PY3=y swig-3.0.2/Examples/test-suite/python/director_thread_runme.py0000664000175000017500000000037112343605122024473 0ustar williamwilliamfrom director_thread import Foo class Derived(Foo) : def __init__(self): Foo.__init__(self) def do_foo(self): self.val = self.val - 1 d = Derived() d.run() if d.val >= 0: print d.val raise RuntimeError d.stop() swig-3.0.2/Examples/test-suite/python/typedef_inherit_runme.py0000664000175000017500000000073312343605122024515 0ustar williamwilliamimport typedef_inherit a = typedef_inherit.Foo() b = typedef_inherit.Bar() x = typedef_inherit.do_blah(a) if x != "Foo::blah": print "Whoa! Bad return", x x = typedef_inherit.do_blah(b) if x != "Bar::blah": print "Whoa! Bad return", x c = typedef_inherit.Spam() d = typedef_inherit.Grok() x = typedef_inherit.do_blah2(c) if x != "Spam::blah": print "Whoa! Bad return", x x = typedef_inherit.do_blah2(d) if x != "Grok::blah": print "Whoa! Bad return", x swig-3.0.2/Examples/test-suite/python/compactdefaultargs_runme.py0000664000175000017500000000053412343605122025202 0ustar williamwilliamfrom compactdefaultargs import * defaults1 = Defaults1(1000) defaults1 = Defaults1() if defaults1.ret(10.0) != 10.0: raise RuntimeError if defaults1.ret() != -1.0: raise RuntimeError defaults2 = Defaults2(1000) defaults2 = Defaults2() if defaults2.ret(10.0) != 10.0: raise RuntimeError if defaults2.ret() != -1.0: raise RuntimeError swig-3.0.2/Examples/test-suite/python/preproc_defined_runme.py0000664000175000017500000000032312343605122024456 0ustar williamwilliamimport preproc_defined if preproc_defined.call_checking() != 1: raise RuntimeError d = preproc_defined.Defined() d.defined = 10 preproc_defined.thing(10) preproc_defined.stuff(10) preproc_defined.bumpf(10) swig-3.0.2/Examples/test-suite/python/friends_runme.py0000664000175000017500000000124512343605122022764 0ustar williamwilliamimport friends a = friends.A(2) if friends.get_val1(a) != 2: raise RuntimeError if friends.get_val2(a) != 4: raise RuntimeError if friends.get_val3(a) != 6: raise RuntimeError # nice overload working fine if friends.get_val1(1,2,3) != 1: raise RuntimeError b = friends.B(3) # David's case if friends.mix(a,b) != 5: raise RuntimeError di = friends.D_d(2) dd = friends.D_d(3.3) # incredible template overloading working just fine if friends.get_val1(di) != 2: raise RuntimeError if friends.get_val1(dd) != 3.3: raise RuntimeError friends.set(di, 4) friends.set(dd, 1.3) if friends.get_val1(di) != 4: raise RuntimeError if friends.get_val1(dd) != 1.3: raise RuntimeError swig-3.0.2/Examples/test-suite/python/multi_import_runme.py0000664000175000017500000000047512343605122024062 0ustar williamwilliamimport multi_import_a import multi_import_b x = multi_import_b.XXX() if x.testx() != 0: raise RuntimeError y = multi_import_b.YYY() if y.testx() != 0: raise RuntimeError if y.testy() != 1: raise RuntimeError z = multi_import_a.ZZZ() if z.testx() != 0: raise RuntimeError if z.testz() != 2: raise RuntimeError swig-3.0.2/Examples/test-suite/python/extend_placement_runme.py0000664000175000017500000000161512343605122024652 0ustar williamwilliamimport extend_placement foo = extend_placement.Foo() foo = extend_placement.Foo(1) foo = extend_placement.Foo(1,1) foo.spam() foo.spam("hello") foo.spam(1) foo.spam(1,1) foo.spam(1,1,1) foo.spam(extend_placement.Foo()) foo.spam(extend_placement.Foo(), 1.0) bar = extend_placement.Bar() bar = extend_placement.Bar(1) bar.spam() bar.spam("hello") bar.spam(1) bar.spam(1,1) bar.spam(1,1,1) bar.spam(extend_placement.Bar()) bar.spam(extend_placement.Bar(), 1.0) foo = extend_placement.FooTi() foo = extend_placement.FooTi(1) foo = extend_placement.FooTi(1,1) foo.spam() foo.spam("hello") foo.spam(1) foo.spam(1,1) foo.spam(1,1,1) foo.spam(extend_placement.Foo()) foo.spam(extend_placement.Foo(), 1.0) bar = extend_placement.BarTi() bar = extend_placement.BarTi(1) bar.spam() bar.spam("hello") bar.spam(1) bar.spam(1,1) bar.spam(1,1,1) bar.spam(extend_placement.Bar()) bar.spam(extend_placement.Bar(), 1.0) swig-3.0.2/Examples/test-suite/python/profiletest_runme.py0000664000175000017500000000071012343605122023666 0ustar williamwilliamimport _profiletest import profiletest a = profiletest.A() print a print a.this b = profiletest.B() fn = b.fn i = 50000 while i: a = fn(a) #1 a = fn(a) #2 a = fn(a) #3 a = fn(a) #4 a = fn(a) #5 a = fn(a) #6 a = fn(a) #7 a = fn(a) #8 a = fn(a) #9 a = fn(a) #10 a = fn(a) #1 a = fn(a) #2 a = fn(a) #3 a = fn(a) #4 a = fn(a) #5 a = fn(a) #6 a = fn(a) #7 a = fn(a) #8 a = fn(a) #9 a = fn(a) #20 i -= 1 swig-3.0.2/Examples/test-suite/python/inctest_runme.py0000664000175000017500000000106312343605122023001 0ustar williamwilliamimport inctest error = 0 try: a = inctest.A() except: print "didn't find A" print "therefore, I didn't include 'testdir/subdir1/hello.i'" error = 1 pass try: b = inctest.B() except: print "didn't find B" print "therefore, I didn't include 'testdir/subdir2/hello.i'" error = 1 pass if error == 1: raise RuntimeError # Check the import in subdirectory worked if inctest.importtest1(5) != 15: print "import test 1 failed" raise RuntimeError if inctest.importtest2("black") != "white": print "import test 2 failed" raise RuntimeError swig-3.0.2/Examples/test-suite/python/disown_runme.py0000664000175000017500000000043612343605122022636 0ustar williamwilliamfrom disown import * a = A() tmp = a.thisown a.thisown = 0 if a.thisown: raise RuntimeError a.thisown = 1 if (not a.thisown): raise RuntimeError a.thisown = tmp if (a.thisown != tmp): raise RuntimeError b = B() b.acquire(a) if a.thisown: raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_typedef_runme.py0000664000175000017500000000170312343605122024664 0ustar williamwilliamfrom template_typedef import * d = make_Identity_float() c = make_Identity_reald() try: a = d.this a = c.this except: raise RuntimeError try: e = make_Multiplies_float_float_float_float(d, d) a = e.this except: print e, "is not an instance" raise RuntimeError try: f = make_Multiplies_reald_reald_reald_reald(c, c) a = f.this except: print f, "is not an instance" raise RuntimeError try: g = make_Multiplies_float_float_reald_reald(d, c) a = g.this except: print g, "is not an instance" raise RuntimeError # the old large format if not SWIG_TypeQuery("vfncs::ArithUnaryFunction::argument_type,vfncs::arith_traits::result_type > *"): raise RuntimeError # the reduced format if not SWIG_TypeQuery("vfncs::ArithUnaryFunction *"): raise RuntimeError # this is a bad name if SWIG_TypeQuery("vfncs::ArithUnaryFunction *"): raise RuntimeError swig-3.0.2/Examples/test-suite/python/overload_simple_runme.py0000664000175000017500000000366112343605122024522 0ustar williamwilliamfrom overload_simple import * if foo(3) != "foo:int": raise RuntimeError, "foo(int)" if foo(3.0) != "foo:double": raise RuntimeError, "foo(double)" if foo("hello") != "foo:char *": raise RuntimeError, "foo(char *)" f = Foo() b = Bar() if foo(f) != "foo:Foo *": raise RuntimeError, "foo(Foo *)" if foo(b) != "foo:Bar *": raise RuntimeError, "foo(Bar *)" v = malloc_void(32) if foo(v) != "foo:void *": raise RuntimeError, "foo(void *)" s = Spam() if s.foo(3) != "foo:int": raise RuntimeError, "Spam::foo(int)" if s.foo(3.0) != "foo:double": raise RuntimeError, "Spam::foo(double)" if s.foo("hello") != "foo:char *": raise RuntimeError, "Spam::foo(char *)" if s.foo(f) != "foo:Foo *": raise RuntimeError, "Spam::foo(Foo *)" if s.foo(b) != "foo:Bar *": raise RuntimeError, "Spam::foo(Bar *)" if s.foo(v) != "foo:void *": raise RuntimeError, "Spam::foo(void *)" if Spam_bar(3) != "bar:int": raise RuntimeError, "Spam::bar(int)" if Spam_bar(3.0) != "bar:double": raise RuntimeError, "Spam::bar(double)" if Spam_bar("hello") != "bar:char *": raise RuntimeError, "Spam::bar(char *)" if Spam_bar(f) != "bar:Foo *": raise RuntimeError, "Spam::bar(Foo *)" if Spam_bar(b) != "bar:Bar *": raise RuntimeError, "Spam::bar(Bar *)" if Spam_bar(v) != "bar:void *": raise RuntimeError, "Spam::bar(void *)" # Test constructors s = Spam() if s.type != "none": raise RuntimeError, "Spam()" s = Spam(3) if s.type != "int": raise RuntimeError, "Spam(int)" s = Spam(3.4) if s.type != "double": raise RuntimeError, "Spam(double)" s = Spam("hello") if s.type != "char *": raise RuntimeError, "Spam(char *)" s = Spam(f) if s.type != "Foo *": raise RuntimeError, "Spam(Foo *)" s = Spam(b) if s.type != "Bar *": raise RuntimeError, "Spam(Bar *)" s = Spam(v) if s.type != "void *": raise RuntimeError, "Spam(void *)" free_void(v) a = ClassA() b = a.method1(1) swig-3.0.2/Examples/test-suite/python/global_namespace_runme.py0000664000175000017500000000165312343605122024611 0ustar williamwilliamfrom global_namespace import * k1 = Klass1() k2 = Klass2() k3 = Klass3() k4 = Klass4() k5 = Klass5() k6 = Klass6() k7 = Klass7() KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7) KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7) k1 = getKlass1A() k2 = getKlass2A() k3 = getKlass3A() k4 = getKlass4A() k5 = getKlass5A() k6 = getKlass6A() k7 = getKlass7A() KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7) KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7) k1 = getKlass1B() k2 = getKlass2B() k3 = getKlass3B() k4 = getKlass4B() k5 = getKlass5B() k6 = getKlass6B() k7 = getKlass7B() KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7) KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7) XYZMethods.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) XYZMethods.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) TheEnumMethods.methodA(theenum1, theenum2, theenum3) TheEnumMethods.methodA(theenum1, theenum2, theenum3) swig-3.0.2/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py0000664000175000017500000000076112343605122026402 0ustar williamwilliamfrom li_boost_shared_ptr_bits import * def check(nd): nd.i = 200 i = nd.i try: nd.notexist = 100 passed = 0 except: passed = 1 if not passed: raise "Test failed" nd = NonDynamic() check(nd) b = boing(nd) check(b) ################################ v = VectorIntHolder() v.push_back(IntHolder(11)) v.push_back(IntHolder(22)) v.push_back(IntHolder(33)) sum = sum(v) if sum != 66: raise "sum is wrong" ################################ p = HiddenDestructor.create() swig-3.0.2/Examples/test-suite/python/implicittest_runme.py0000664000175000017500000000521112343605122024041 0ustar williamwilliamfrom implicittest import * def check(a, b): if a != b: raise RuntimeError(str(a) + " does not equal " + str(b)) #### Class #### # No implicit conversion check(1, A(1).get()) check(2, A(1.0).get()) check(3, A(B()).get()) check(4, A("hello").get()) try: check(3, A(None).get()) raise RuntimeError except ValueError: # ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &' # Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value, # references and pointers to different types, where pointers ought to be given a slightly higher precedence. pass check(1, get(1)) check(2, get(1.0)) check(3, get(B())) # Explicit constructor: try: check(4, get("hello")) raise RuntimeError except TypeError: pass #### Template Class #### # No implicit conversion check(1, A_int(1).get()) check(2, A_int(1.0).get()) check(3, A_int(B()).get()) check(4, A_int("hello").get()) check(1, A_int.sget(1)) check(2, A_int.sget(1.0)) check(3, A_int.sget(B())) # explicit constructor: try: check(4, A_int.sget("hello")) raise RuntimeError except TypeError: pass #### Global variable assignment #### cvar.foo = Foo(1); check(cvar.foo.ii, 1) cvar.foo = 1; check(cvar.foo.ii, 1) cvar.foo = 1.0; check(cvar.foo.ii, 2) cvar.foo = Foo("hello"); check(cvar.foo.ii, 3) # explicit constructor: try: cvar.foo = "hello" raise RuntimeError except TypeError: pass #### Member variable assignment #### # Note: also needs naturalvar b = Bar(); check(b.f.ii, 0) b.f = Foo("hello"); check(b.f.ii, 3) b.f = 1; check(b.f.ii, 1) b.f = 1.0; check(b.f.ii, 2) # explicit constructor: try: b.f = "hello" raise RuntimeError except TypeError: pass #### Class testing None #### # No implicit conversion check(1, AA(1).get()) check(2, AA(1.0).get()) check(3, AA(B()).get()) check(3, AA(None).get()) check(4, AA("hello").get()) check(5, AA(BB()).get()) check(1, get_AA_val(1)) check(2, get_AA_val(1.0)) check(3, get_AA_val(B())) check(3, get_AA_val(None)) check(5, get_AA_val(BB())) # Explicit constructor: try: check(4, get_AA_val("hello")) raise RuntimeError except TypeError: pass check(1, get_AA_ref(1)) check(2, get_AA_ref(1.0)) check(3, get_AA_ref(B())) check(3, get_AA_ref(None)) check(5, get_AA_ref(BB())) # Explicit constructor: try: check(4, get_AA_ref("hello")) raise RuntimeError except TypeError: pass ### overloading priority test ### ccc = CCC(B()) check(ccc.checkvalue, 10) check(ccc.xx(123), 11) check(ccc.yy(123, 123), 111) swig-3.0.2/Examples/test-suite/python/using1_runme.py0000664000175000017500000000010012343605122022525 0ustar williamwilliamimport using1 if using1.spam(37) != 37: raise RuntimeError swig-3.0.2/Examples/test-suite/python/cpp11_initializer_list_runme.py0000664000175000017500000000014212343605122025707 0ustar williamwilliamimport cpp11_initializer_list a = cpp11_initializer_list.A() a = cpp11_initializer_list.A(11.1) swig-3.0.2/Examples/test-suite/python/abstract_access_runme.py0000664000175000017500000000013112343605122024447 0ustar williamwilliamimport abstract_access d = abstract_access.D() if d.do_x() != 1: raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_std_stream_runme.py0000664000175000017500000000027512343605122024165 0ustar williamwilliamfrom li_std_stream import * a = A() o = ostringstream() o << a << " " << 2345 << " " << 1.435 if o.str() != "A class 2345 1.435": print "\"%s\"" % (o.str(),) raise RuntimeError swig-3.0.2/Examples/test-suite/python/default_constructor_runme.py0000664000175000017500000000305512343605122025424 0ustar williamwilliam# This test is expected to fail with -builtin option. # It uses the old static syntax (e.g., dc.new_A() rather than dc.A()), # which is not provided with the -builtin option. import _default_constructor dc = _default_constructor a = dc.new_A() dc.delete_A(a) aa = dc.new_AA() dc.delete_AA(aa) try: b = dc.new_B() print "Whoa. new_BB created." except: pass del_b = dc.delete_B try: bb = dc.new_BB(); print "Whoa. new_BB created." except: pass del_bb = dc.delete_BB try: c = dc.new_C() print "Whoa. new_C created." except: pass del_c = dc.delete_C cc = dc.new_CC() dc.delete_CC(cc) try: d = dc.new_D(); print "Whoa. new_D created" except: pass del_d = dc.delete_D try: dd = dc.new_DD() print "Whoa. new_DD created" except: pass dd = dc.delete_DD try: ad = dc.new_AD() print "Whoa. new_AD created" except: pass del_ad = dc.delete_AD e = dc.new_E() dc.delete_E(e) ee = dc.new_EE() dc.delete_EE(ee) try: eb = dc.new_EB() print "Whoa. new_EB created" except: pass del_eb = dc.delete_EB f = dc.new_F() try: del_f = dc.delete_F print "Whoa. delete_F created" except AttributeError: pass dc.F_destroy(f) ff = dc.new_FFF() try: del_ff = dc.delete_FFF print "Whoa. delete_FFF created" except AttributeError: pass dc.F_destroy(ff) g = dc.new_G() try: del_g = dc.delete_G print "Whoa. delete_G created" except AttributeError: pass dc.G_destroy(g) gg = dc.new_GG() dc.delete_GG(gg) import default_constructor hh = default_constructor.HH(1,1) swig-3.0.2/Examples/test-suite/python/kwargs_feature_runme.py0000664000175000017500000000166212343605122024346 0ustar williamwilliamfrom kwargs_feature import * class MyFoo(Foo): def __init__(self, a , b = 0): Foo.__init__(self, a, b) # Simple class f1 = MyFoo(2) f = Foo(b=2,a=1) if f.foo(b=1,a=2) != 3: raise RuntimeError if Foo_statfoo(b=2) != 3: raise RuntimeError if f.efoo(b=2) != 3: raise RuntimeError if Foo_sfoo(b=2) != 3: raise RuntimeError # Templated class b = BarInt(b=2,a=1) if b.bar(b=1,a=2) != 3: raise RuntimeError if BarInt_statbar(b=2) != 3: raise RuntimeError if b.ebar(b=2) != 3: raise RuntimeError if BarInt_sbar(b=2) != 3: raise RuntimeError # Functions if templatedfunction(b=2) != 3: raise RuntimeError if foo(a=1,b=2) != 3: raise RuntimeError if foo(b=2) != 3: raise RuntimeError #Funtions with keywords if foo_kw(_from=2) != 4: raise RuntimeError if foo_nu(_from=2, arg2=3) != 2: raise RuntimeError if foo_mm(min=2) != 4: raise RuntimeError if foo_mm(max=3) != 4: raise RuntimeError swig-3.0.2/Examples/test-suite/python/constructor_copy_runme.py0000664000175000017500000000062012343605122024745 0ustar williamwilliamfrom constructor_copy import * f1 = Foo1(3); f11 = Foo1(f1); if f1.x != f11.x: raise RuntimeError f8 = Foo8() try: f81 = Foo8(f8) good = 0 except: good = 1 if not good: raise RuntimeError bi = Bari(5) bc = Bari(bi) if (bi.x != bc.x): raise RuntimeError bd = Bard(5) try: bc = Bard(bd) good = 0 except: good = 1 if not good: raise RuntimeError swig-3.0.2/Examples/test-suite/python/char_binary_runme.py0000664000175000017500000000130512343605122023610 0ustar williamwilliamfrom char_binary import * t = Test() if t.strlen('hile') != 4: print t.strlen('hile') raise RuntimeError, "bad multi-arg typemap" if t.strlen('hil\0') != 4: raise RuntimeError, "bad multi-arg typemap" # # creating a raw char* # pc = new_pchar(5) pchar_setitem(pc, 0, 'h') pchar_setitem(pc, 1, 'o') pchar_setitem(pc, 2, 'l') pchar_setitem(pc, 3, 'a') pchar_setitem(pc, 4, 0) if t.strlen(pc) != 4: raise RuntimeError, "bad multi-arg typemap" cvar.var_pchar = pc if cvar.var_pchar != "hola": print cvar.var_pchar raise RuntimeError, "bad pointer case" cvar.var_namet = pc #if cvar.var_namet != "hola\0": if cvar.var_namet != "hola": raise RuntimeError, "bad pointer case" delete_pchar(pc) swig-3.0.2/Examples/test-suite/python/overload_complicated_runme.py0000664000175000017500000000175012343605122025512 0ustar williamwilliamfrom overload_complicated import * pInt = None # Check the correct constructors are available p = Pop(pInt) p = Pop(pInt, 0) # Check overloaded in const only and pointers/references which target languages cannot disambiguate if p.hip(0) != 701: raise RuntimeError,"Test 1 failed" if p.hip(pInt) != 702: raise RuntimeError,"Test 2 failed" # Reverse the order for the above if p.hop(pInt) != 805: raise RuntimeError,"Test 3 failed" if p.hop(0) != 801: raise RuntimeError,"Test 4 failed" # Few more variations and order shuffled if p.pop(0) != 901: raise RuntimeError,"Test 5 failed" if p.pop(pInt) != 902: raise RuntimeError,"Test 6 failed" if p.pop() != 905: raise RuntimeError,"Test 7 failed" # Overload on const only if p.bop(pInt) != 1001: raise RuntimeError,"Test 8 failed" if p.bip(pInt) != 2001: raise RuntimeError,"Test 9 failed" # Globals if muzak(0) != 3001: raise RuntimeError,"Test 10 failed" if muzak(pInt) != 3002: raise RuntimeError,"Test 11 failed" swig-3.0.2/Examples/test-suite/python/cpp11_type_traits_runme.py0000664000175000017500000000031012343605122024675 0ustar williamwilliamfrom cpp11_type_traits import * if Elaborate(0, 0) != 1: raise RuntimeError("Elaborate should have returned 1") if Elaborate(0, 0.0) != 2: raise RuntimeError("Elaborate should have returned 2") swig-3.0.2/Examples/test-suite/python/director_exception_runme.py0000664000175000017500000000316112343605122025222 0ustar williamwilliamfrom director_exception import * class MyException(Exception): def __init__(self, a, b): self.msg = a + b class MyFoo(Foo): def ping(self): raise NotImplementedError, "MyFoo::ping() EXCEPTION" class MyFoo2(Foo): def ping(self): return True pass # error: should return a string class MyFoo3(Foo): def ping(self): raise MyException("foo", "bar") # Check that the NotImplementedError raised by MyFoo.ping() is returned by # MyFoo.pong(). ok = 0 a = MyFoo() b = launder(a) try: b.pong() except NotImplementedError, e: if str(e) == "MyFoo::ping() EXCEPTION": ok = 1 else: print "Unexpected error message: %s" % str(e) except: pass if not ok: raise RuntimeError # Check that the director returns the appropriate TypeError if the return type # is wrong. ok = 0 a = MyFoo2() b = launder(a) try: b.pong() except TypeError, e: if str(e) == "SWIG director type mismatch in output value of type 'std::string'": ok = 1 else: print "Unexpected error message: %s" % str(e) if not ok: raise RuntimeError # Check that the director can return an exception which requires two arguments # to the constructor, without mangling it. ok = 0 a = MyFoo3() b = launder(a) try: b.pong() except MyException, e: if e.msg == 'foobar': ok = 1 else: print "Unexpected error message: %s" % str(e) if not ok: raise RuntimeError # This is expected to fail with -builtin option # Throwing builtin classes as exceptions not supported try: raise Exception2() except Exception2: pass # This is expected to fail with -builtin option # Throwing builtin classes as exceptions not supported try: raise Exception1() except Exception1: pass swig-3.0.2/Examples/test-suite/python/li_std_vector_runme.py0000664000175000017500000000012112343605122024162 0ustar williamwilliamfrom li_std_vector import * if typedef_test(101) != 101: raise RuntimeError swig-3.0.2/Examples/test-suite/python/cpp11_decltype_runme.py0000664000175000017500000000052012343605122024142 0ustar williamwilliamimport cpp11_decltype a = cpp11_decltype.A() a.i = 5 if a.i != 5: raise RuntimeError, "Assignment to a.i failed." a.j = 10 if a.j != 10: raise RuntimeError, "Assignment to a.j failed." b = a.foo(5) if b != 10: raise RuntimeError, "foo(5) should return 10." b = a.foo(6) if b != 0: raise RuntimeError, "foo(6) should return 0." swig-3.0.2/Examples/test-suite/python/virtual_poly_runme.py0000664000175000017500000000114312343605122024060 0ustar williamwilliamimport virtual_poly d = virtual_poly.NDouble(3.5) i = virtual_poly.NInt(2) # # the copy methods return the right polymorphic types # dc = d.copy() ic = i.copy() if d.get() != dc.get(): raise RuntimeError if i.get() != ic.get(): raise RuntimeError virtual_poly.incr(ic) if (i.get() + 1) != ic.get(): raise RuntimeError dr = d.ref_this() if d.get() != dr.get(): raise RuntimeError # # 'narrowing' also works # ddc = virtual_poly.NDouble_narrow(d.nnumber()) if d.get() != ddc.get(): raise RuntimeError dic = virtual_poly.NInt_narrow(i.nnumber()) if i.get() != dic.get(): raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_typedef_cplx_runme.py0000664000175000017500000000306612343605122025716 0ustar williamwilliamfrom template_typedef_cplx import * # # double case # try: d = make_Identity_double() a = d.this except: print d, "is not an instance" raise RuntimeError s = '%s' % d if str.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError try: e = make_Multiplies_double_double_double_double(d, d) a = e.this except: print e, "is not an instance" raise RuntimeError s = '%s' % e if str.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError # # complex case # try: c = make_Identity_complex() a = c.this except: print c, "is not an instance" raise RuntimeError s = '%s' % c if str.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError try: f = make_Multiplies_complex_complex_complex_complex(c, c) a = f.this except: print f, "is not an instance" raise RuntimeError s = '%s' % f if str.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError # # Mix case # try: g = make_Multiplies_double_double_complex_complex(d, c) a = g.this except: print g, "is not an instance" raise RuntimeError s = '%s' % g if str.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError try: h = make_Multiplies_complex_complex_double_double(c, d) a = h.this except: print h, "is not an instance" raise RuntimeError s = '%s' % h if str.find(s, 'ArithUnaryFunction') == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_std_set_runme.py0000664000175000017500000000235412343605122023465 0ustar williamwilliamfrom li_std_set import * s = set_string() s.append("a") s.append("b") s.append("c") sum = "" for i in s: sum = sum + i if sum != "abc": raise RuntimeError i = s.__iter__() if i.next() != "a": raise RuntimeError if i.next() != "b": raise RuntimeError if i.next() != "c": raise RuntimeError b = s.begin() e = s.end() sum = "" while (b != e): sum = sum + b.next() if sum != "abc": raise RuntimeError b = s.rbegin() e = s.rend() sum = "" while (b != e): sum = sum + b.next() if sum != "cba": raise RuntimeError si = set_int() si.append(1) si.append(2) si.append(3) i = si.__iter__() if i.next() != 1: raise RuntimeError if i.next() != 2: raise RuntimeError if i.next() != 3: raise RuntimeError i = s.begin() i.next() s.erase(i) b = s.begin() e = s.end() sum = "" while (b != e): sum = sum + b.next() if sum != "ac": raise RuntimeError b = s.begin() e = s.end() if e - b != 2: raise RuntimeError m = b + 1 if m.value() != "c": raise RuntimeError s = pyset() s.insert((1,2)) s.insert(1) s.insert("hello") sum = () for i in s: sum = sum + (i,) if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)) : raise RuntimeError swig-3.0.2/Examples/test-suite/python/mod_runme.py0000664000175000017500000000011012343605122022077 0ustar williamwilliamimport mod_a import mod_b c = mod_b.C() d = mod_b.D() d.DoSomething(c) swig-3.0.2/Examples/test-suite/python/python_richcompare_runme.py0000664000175000017500000000565212343605122025235 0ustar williamwilliamimport python_richcompare base1 = python_richcompare.BaseClass(1) base2 = python_richcompare.BaseClass(2) base3 = python_richcompare.BaseClass(3) a1 = python_richcompare.SubClassA(1) a2 = python_richcompare.SubClassA(2) a3 = python_richcompare.SubClassA(3) b1 = python_richcompare.SubClassB(1) b2 = python_richcompare.SubClassB(2) b3 = python_richcompare.SubClassB(3) # Check == and != within a single type #------------------------------------------------------------------------------- if not (base1 == base1) : raise RuntimeError("Object not == to itself") if not (base1 == python_richcompare.BaseClass(1)) : raise RuntimeError("Object not == to an equivalent object") if (base1 == base2) : raise RuntimeError("Comparing non-equivalent objects of the same type, == returned True") if (base1 != base1) : raise RuntimeError("Object is != itself") if (base1 != python_richcompare.BaseClass(1)) : raise RuntimeError("Object is != an equivalent object") if not (base1 != base2) : raise RuntimeError("Comparing non-equivalent objects of the same type, != returned False") # Check redefined operator== in SubClassA #------------------------------------------------------------------------------- if (a2 == base2) : raise RuntimeError("Redefined operator== in SubClassA failed") if (a2 == b2) : raise RuntimeError("Redefined operator== in SubClassA failed") if not (a1 == a2) : raise RuntimeError("Redefined operator== in SubClassA failed") # Check up-casting of subclasses #------------------------------------------------------------------------------- if (base2 != a2) : raise RuntimeError("Comparing equivalent base and subclass instances, != returned True") if (a2 == base2) : raise RuntimeError("Comparing non-equivalent base and subclass instances, == returned True") if (a1 == b1) : raise RuntimeError("Comparing equivalent instances of different subclasses, == returned True") if (b1 == a1) : raise RuntimeError("Comparing equivalent instances of different subclasses, == returned True") # Check inequalities #------------------------------------------------------------------------------- if (a2 > b2) : raise RuntimeError("operator> failed") if (a2 < b2) : raise RuntimeError("operator< failed") if not (a2 >= b2) : raise RuntimeError("operator>= failed") if not (a2 <= b2) : raise RuntimeError("operator<= failed") # Check inequalities used for ordering #------------------------------------------------------------------------------- x = sorted([a2, a3, a1]) if not (x[0] is a1) : raise RuntimeError("Ordering failed") if not (x[1] is a2) : raise RuntimeError("Ordering failed") if not (x[2] is a3) : raise RuntimeError("Ordering failed") x = sorted([base2, a3, b1]) if not (x[0] is b1) : raise RuntimeError("Ordering failed") if not (x[1] is base2) : raise RuntimeError("Ordering failed") if not (x[2] is a3) : raise RuntimeError("Ordering failed") swig-3.0.2/Examples/test-suite/python/li_std_containers_int_runme.py0000664000175000017500000002071112343605122025706 0ustar williamwilliam# Check std::vector and std::list behaves the same as Python iterable types (list) from li_std_containers_int import * import sys def failed(a, b, msg): raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b)) def compare_sequences(a, b): if len(a) != len(b): failed(a, b, "different sizes") for i in range(len(a)): if a[i] != b[i]: failed(a, b, "elements are different") def compare_containers(pythonlist, swigvector, swiglist): compare_sequences(pythonlist, swigvector) compare_sequences(pythonlist, swiglist) # Check std::vector and std::list assignment behaves same as Python list assignment including exceptions def container_insert_step(i, j, step, newval): ps = range(6) iv = vector_int(ps) il = list_int(ps) # Python slice try: if step == None: if j == None: ps[i] = newval else: ps[i:j] = newval else: if j == None: ps[i::step] = newval else: ps[i:j:step] = newval ps_error = None except ValueError, e: ps_error = e except IndexError, e: ps_error = e # std::vector try: if step == None: if j == None: iv[i] = newval else: iv[i:j] = newval else: if j == None: iv[i::step] = newval else: iv[i:j:step] = newval iv_error = None except ValueError, e: iv_error = e except IndexError, e: iv_error = e # std::list try: if step == None: if j == None: il[i] = newval else: il[i:j] = newval else: if j == None: il[i::step] = newval else: il[i:j:step] = newval il_error = None except ValueError, e: il_error = e except IndexError, e: il_error = e # Python 2.6 contains bug fixes in extended slicing syntax: http://docs.python.org/2/whatsnew/2.6.html skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6)) if not(skip_check): if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error) compare_containers(ps, iv, il) # Check std::vector and std::list delete behaves same as Python list delete including exceptions def container_delete_step(i, j, step): ps = range(6) iv = vector_int(ps) il = list_int(ps) # Python slice try: if step == None: if j == None: del ps[i] else: del ps[i:j] else: if j == None: del ps[i::step] else: del ps[i:j:step] ps_error = None except ValueError, e: ps_error = e except IndexError, e: ps_error = e # std::vector try: if step == None: if j == None: del iv[i] else: del iv[i:j] else: if j == None: del iv[i::step] else: del iv[i:j:step] iv_error = None except ValueError, e: iv_error = e except IndexError, e: iv_error = e # std::list try: if step == None: if j == None: del il[i] else: del il[i:j] else: if j == None: del il[i::step] else: del il[i:j:step] il_error = None except ValueError, e: il_error = e except IndexError, e: il_error = e if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error) compare_containers(ps, iv, il) ps = [0,1,2,3,4,5] iv = vector_int(ps) il = list_int(ps) # slices compare_containers(ps[0:0], iv[0:0], il[0:0]) compare_containers(ps[1:1], iv[1:1], il[1:1]) compare_containers(ps[1:3], iv[1:3], il[1:3]) compare_containers(ps[2:4], iv[2:4], il[2:4]) compare_containers(ps[0:3], iv[0:3], il[0:3]) compare_containers(ps[3:6], iv[3:6], il[3:6]) compare_containers(ps[3:10], iv[3:10], il[3:10]) # beyond end of range # before beginning of range (negative indexing) compare_containers(ps[-1:7], iv[-1:7], il[-1:7]) compare_containers(ps[-2:7], iv[-2:7], il[-2:7]) compare_containers(ps[-5:7], iv[-5:7], il[-5:7]) compare_containers(ps[-6:7], iv[-6:7], il[-6:7]) # before beginning of range (negative indexing, negative index is > container size) compare_containers(ps[-7:7], iv[-7:7], il[-7:7]) compare_containers(ps[-100:7], iv[-100:7], il[-100:7]) compare_containers(ps[3:], iv[3:], il[3:]) compare_containers(ps[:3], iv[:3], il[:3]) compare_containers(ps[:], iv[:], il[:]) compare_containers(ps[-3:], iv[-3:], il[-3:]) compare_containers(ps[-7:], iv[-7:], il[-7:]) compare_containers(ps[:-1], iv[:-1], il[:-1]) compare_containers(ps[:-7], iv[:-7], il[:-7]) # step slicing compare_containers(ps[1:5:1], iv[1:5:1], il[1:5:1]) compare_containers(ps[1:5:2], iv[1:5:2], il[1:5:2]) compare_containers(ps[1:5:3], iv[1:5:3], il[1:5:3]) compare_containers(ps[1:5:4], iv[1:5:4], il[1:5:4]) compare_containers(ps[1:6:5], iv[1:6:5], il[1:6:5]) compare_containers(ps[1:7:5], iv[1:7:5], il[1:7:5]) compare_containers(ps[-1:7:1], iv[-1:7:1], il[-1:7:1]) compare_containers(ps[-1:7:2], iv[-1:7:2], il[-1:7:2]) compare_containers(ps[-6:7:2], iv[-6:7:2], il[-6:7:2]) compare_containers(ps[-100:7:2], iv[-100:7:2], il[-100:7:2]) compare_containers(ps[::1], iv[::1], il[::1]) compare_containers(ps[::2], iv[::2], il[::2]) compare_containers(ps[::-1], iv[::-1], il[::-1]) compare_containers(ps[6::-1], iv[6::-1], il[6::-1]) compare_containers(ps[:-3:-1], iv[:-3:-1], il[:-3:-1]) compare_containers(ps[:-6:-1], iv[:-6:-1], il[:-6:-1]) compare_containers(ps[:-7:-1], iv[:-7:-1], il[:-7:-1]) compare_containers(ps[:-8:-1], iv[:-8:-1], il[:-8:-1]) compare_containers(ps[:-100:-1], iv[:-100:-1], il[:-100:-1]) compare_containers(ps[4:6:-1], iv[4:6:-1], il[4:6:-1]) compare_containers(ps[4:5:-1], iv[4:5:-1], il[4:5:-1]) compare_containers(ps[4:4:-1], iv[4:4:-1], il[4:4:-1]) compare_containers(ps[4:3:-1], iv[4:3:-1], il[4:3:-1]) compare_containers(ps[4:2:-1], iv[4:2:-1], il[4:2:-1]) compare_containers(ps[100:104:-1], iv[100:104:-1], il[100:104:-1]) compare_containers(ps[104:100:-1], iv[104:100:-1], il[104:100:-1]) compare_containers(ps[-100:-104:-1], iv[-100:-104:-1], il[-100:-104:-1]) compare_containers(ps[-104:-100:-1], iv[-104:-100:-1], il[-104:-100:-1]) compare_containers(ps[::-2], iv[::-2], il[::-2]) compare_containers(ps[::-3], iv[::-3], il[::-3]) compare_containers(ps[::-4], iv[::-4], il[::-4]) compare_containers(ps[::-5], iv[::-5], il[::-5]) # insert sequences (growing, shrinking and staying same size) for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: # single element set/replace container_insert_step(start, None, None, 111) for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666, 777]) container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666]) container_insert_step(start, end, None, [111, 222, 333, 444, 555]) container_insert_step(start, end, None, [111, 222, 333, 444]) container_insert_step(start, end, None, [111, 222, 333]) container_insert_step(start, end, None, [111, 222]) container_insert_step(start, end, None, [111]) container_insert_step(start, end, None, []) # delete sequences (growing, shrinking and staying same size) for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: # single element delete container_delete_step(start, None, None) for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: container_delete_step(start, end, None) for step in range(-7,7): container_delete_step(start, end, step) ps = range(6) iv = vector_int(ps) il = list_int(ps) del ps[:]; del iv[:]; del il[:] compare_containers(ps, iv, il) for end in range(7): for step in range(-7,7): for start in range(7): container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666, 777]) container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666]) container_insert_step(start, end, step, [111, 222, 333, 444, 555]) container_insert_step(start, end, step, [111, 222, 333, 444]) container_insert_step(start, end, step, [111, 222, 333]) container_insert_step(start, end, step, [111, 222]) container_insert_step(start, end, step, [111]) container_insert_step(start, end, step, []) try: x = iv[::0] raise RuntimeError("Zero step not caught") except ValueError: pass swig-3.0.2/Examples/test-suite/python/director_frob_runme.py0000664000175000017500000000017212343605122024153 0ustar williamwilliamfrom director_frob import * foo = Bravo(); s = foo.abs_method(); if s != "Bravo::abs_method()": raise RuntimeError, s swig-3.0.2/Examples/test-suite/python/li_implicit_runme.py0000664000175000017500000000045012343605122023625 0ustar williamwilliamfrom li_implicit import * b = B() ai = A(1) ad = A(2.0) ab = A(b) ai, get(ai) ad, get(ad) ab, get(ab) if get(ai) != get(1): raise RuntimeError,"bad implicit type" if get(ad) != get(2.0): raise RuntimeError,"bad implicit type" if get(ab) != get(b): raise RuntimeError,"bad implicit type" swig-3.0.2/Examples/test-suite/python/typedef_scope_runme.py0000664000175000017500000000026012343605122024157 0ustar williamwilliamimport typedef_scope b = typedef_scope.Bar() x = b.test1(42,"hello") if x != 42: print "Failed!!" x = b.test2(42,"hello") if x != "hello": print "Failed!!" swig-3.0.2/Examples/test-suite/python/cpp_namespace_runme.py0000664000175000017500000000223312343605122024126 0ustar williamwilliam# Note: This example assumes that namespaces are flattened import cpp_namespace n = cpp_namespace.fact(4) if n != 24: raise RuntimeError("Bad return value!") if cpp_namespace.cvar.Foo != 42: raise RuntimeError("Bad variable value!") t = cpp_namespace.Test() if t.method() != "Test::method": raise RuntimeError("Bad method return value!") if cpp_namespace.do_method(t) != "Test::method": raise RuntimeError("Bad return value!") if cpp_namespace.do_method2(t) != "Test::method": raise RuntimeError("Bad return value!") cpp_namespace.weird("hello", 4) del t t2 = cpp_namespace.Test2() t3 = cpp_namespace.Test3() t4 = cpp_namespace.Test4() t5 = cpp_namespace.Test5() if cpp_namespace.foo3(42) != 42: raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t2,40) != "Test2::method": raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t3,40) != "Test3::method": raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t4,40) != "Test4::method": raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t5,40) != "Test5::method": raise RuntimeError("Bad return value!") swig-3.0.2/Examples/test-suite/python/overload_extendc_runme.py0000664000175000017500000000071712343605122024662 0ustar williamwilliamimport overload_extendc f = overload_extendc.Foo() if f.test(3) != 1: raise RuntimeError if f.test("hello") != 2: raise RuntimeError if f.test(3.5,2.5) != 3: raise RuntimeError if f.test("hello",20) != 1020: raise RuntimeError if f.test("hello",20,100) != 120: raise RuntimeError # C default args if f.test(f) != 30: raise RuntimeError if f.test(f,100) != 120: raise RuntimeError if f.test(f,100,200) != 300: raise RuntimeError swig-3.0.2/Examples/test-suite/python/default_args_runme.py0000664000175000017500000000203612343605122023771 0ustar williamwilliamimport default_args if default_args.Statics_staticMethod() != 60: raise RuntimeError if default_args.cfunc1(1) != 2: raise RuntimeError if default_args.cfunc2(1) != 3: raise RuntimeError if default_args.cfunc3(1) != 4: raise RuntimeError f = default_args.Foo() f.newname() f.newname(1) try: f = default_args.Foo(1) error = 1 except: error = 0 if error: raise RuntimeError,"Foo::Foo ignore is not working" try: f = default_args.Foo(1,2) error = 1 except: error = 0 if error: raise RuntimeError,"Foo::Foo ignore is not working" try: f = default_args.Foo(1,2,3) error = 1 except: error = 0 if error: raise RuntimeError,"Foo::Foo ignore is not working" try: m = f.meth(1) error = 1 except: error = 0 if error: raise RuntimeError,"Foo::meth ignore is not working" try: m = f.meth(1,2) error = 1 except: error = 0 if error: raise RuntimeError,"Foo::meth ignore is not working" try: m = f.meth(1,2,3) error = 1 except: error = 0 if error: raise RuntimeError,"Foo::meth ignore is not working" swig-3.0.2/Examples/test-suite/python/overload_subtype_runme.py0000664000175000017500000000022512343605122024715 0ustar williamwilliamfrom overload_subtype import * f = Foo() b = Bar() if spam(f) != 1: raise RuntimeError, "foo" if spam(b) != 2: raise RuntimeError, "bar" swig-3.0.2/Examples/test-suite/python/li_cmalloc_runme.py0000664000175000017500000000024212343605122023424 0ustar williamwilliamfrom li_cmalloc import * p = malloc_int() free_int(p) ok = 0 try: p = calloc_int(-1) free_int(p) except: ok = 1 if ok != 1: raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_extend2_runme.py0000664000175000017500000000026712343605122024601 0ustar williamwilliamimport template_extend2 a = template_extend2.lBaz() b = template_extend2.dBaz() if a.foo() != "lBaz::foo": raise RuntimeError if b.foo() != "dBaz::foo": raise RuntimeError swig-3.0.2/Examples/test-suite/python/iadd_runme.py0000664000175000017500000000014212343605122022226 0ustar williamwilliamimport iadd f = iadd.Foo() f.AsA.x = 3 f.AsA += f.AsA if f.AsA.x != 6: raise RuntimeError swig-3.0.2/Examples/test-suite/python/memberin_extend_c_runme.py0000664000175000017500000000021712343605122024777 0ustar williamwilliamimport memberin_extend_c t = memberin_extend_c.Person() t.name = "Fred Bloggs" if t.name != "FRED BLOGGS": raise RuntimeError("name wrong") swig-3.0.2/Examples/test-suite/python/li_std_map_runme.py0000664000175000017500000000117712343605122023451 0ustar williamwilliamimport li_std_map a1 = li_std_map.A(3) a2 = li_std_map.A(7) p0 = li_std_map.pairii(1,2) p1 = li_std_map.pairA(1,a1.this) m = {} m[1] = a1 m[2] = a2 pp1 = li_std_map.p_identa(p1) mm = li_std_map.m_identa(m) m = li_std_map.mapA() m[1] = a1 m[2] = a2 pm ={} for k in m: pm[k] = m[k] for k in m: if pm[k].this != m[k].this: print pm[k], m[k] raise RuntimeError m = {} m[1] = (1,2) m["foo"] = "hello" pm = li_std_map.pymap() for k in m: pm[k] = m[k] for k in pm: if (pm[k] != m[k]): raise RuntimeError mii = li_std_map.IntIntMap() mii[1] = 1 mii[1] = 2 if mii[1] != 2: raise RuntimeError swig-3.0.2/Examples/test-suite/python/director_basic_runme.py0000664000175000017500000000263112343605122024306 0ustar williamwilliamimport director_basic class PyFoo(director_basic.Foo): def ping(self): return "PyFoo::ping()" a = PyFoo() if a.ping() != "PyFoo::ping()": raise RuntimeError, a.ping() if a.pong() != "Foo::pong();PyFoo::ping()": raise RuntimeError, a.pong() b = director_basic.Foo() if b.ping() != "Foo::ping()": raise RuntimeError, b.ping() if b.pong() != "Foo::pong();Foo::ping()": raise RuntimeError, b.pong() a = director_basic.A1(1) if a.rg(2) != 2: raise RuntimeError class PyClass(director_basic.MyClass): def method(self, vptr): self.cmethod = 7 pass def vmethod(self, b): b.x = b.x + 31 return b b = director_basic.Bar(3) d = director_basic.MyClass() c = PyClass() cc = director_basic.MyClass_get_self(c) dd = director_basic.MyClass_get_self(d) bc = cc.cmethod(b) bd = dd.cmethod(b) cc.method(b) if c.cmethod != 7: raise RuntimeError if bc.x != 34: raise RuntimeError if bd.x != 16: raise RuntimeError class PyMulti(director_basic.Foo, director_basic.MyClass): def __init__(self): director_basic.Foo.__init__(self) director_basic.MyClass.__init__(self) pass def vmethod(self, b): b.x = b.x + 31 return b def ping(self): return "PyFoo::ping()" a = 0 for i in range(0,100): pymult = PyMulti() pymult.pong() del pymult pymult = PyMulti() p1 = director_basic.Foo_get_self(pymult) p2 = director_basic.MyClass_get_self(pymult) p1.ping() p2.vmethod(bc) swig-3.0.2/Examples/test-suite/python/constover_runme.py0000664000175000017500000000124412343605122023353 0ustar williamwilliamimport constover import sys error = 0 p = constover.test("test") if p != "test": print "test failed!" error = 1 p = constover.test_pconst("test") if p != "test_pconst": print "test_pconst failed!" error = 1 f = constover.Foo() p = f.test("test") if p != "test": print "member-test failed!" error = 1 p = f.test_pconst("test") if p != "test_pconst": print "member-test_pconst failed!" error = 1 p = f.test_constm("test") if p != "test_constmethod": print "member-test_constm failed!" error = 1 p = f.test_pconstm("test") if p != "test_pconstmethod": print "member-test_pconstm failed!" error = 1 sys.exit(error) swig-3.0.2/Examples/test-suite/python/director_extend_runme.py0000664000175000017500000000107712343605122024517 0ustar williamwilliam# Test case from bug #1506850 #"When threading is enabled, the interpreter will infinitely wait on a mutex the second #time this type of extended method is called. Attached is an example #program that waits on the mutex to be unlocked." from director_extend import * class MyObject(SpObject): def __init__(self): SpObject.__init__(self) return def getFoo(self): return 123 m = MyObject() if m.dummy() != 666: raise RuntimeError, "1st call" if m.dummy() != 666: # Locked system raise RuntimeError, "2nd call" swig-3.0.2/Examples/test-suite/python/abstract_typedef2_runme.py0000664000175000017500000000006412343605122024735 0ustar williamwilliamfrom abstract_typedef2 import * a = A_UF() swig-3.0.2/Examples/test-suite/python/director_enum_runme.py0000664000175000017500000000033512343605122024170 0ustar williamwilliamimport director_enum class MyFoo(director_enum.Foo): def say_hi(self, val): return val b = director_enum.Foo() a = MyFoo() if a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi): raise RuntimeError swig-3.0.2/Examples/test-suite/python/overload_template_fast_runme.py0000664000175000017500000000670112343605122026057 0ustar williamwilliamfrom overload_template_fast import * f = foo() a = maximum(3,4) b = maximum(3.4,5.2) # mix 1 if (mix1("hi") != 101): raise RuntimeError, ("mix1(const char*)") if (mix1(1.0, 1.0) != 102): raise RuntimeError, ("mix1(double, const double &)") if (mix1(1.0) != 103): raise RuntimeError, ("mix1(double)") # mix 2 if (mix2("hi") != 101): raise RuntimeError, ("mix2(const char*)") if (mix2(1.0, 1.0) != 102): raise RuntimeError, ("mix2(double, const double &)") if (mix2(1.0) != 103): raise RuntimeError, ("mix2(double)") # mix 3 if (mix3("hi") != 101): raise RuntimeError, ("mix3(const char*)") if (mix3(1.0, 1.0) != 102): raise RuntimeError, ("mix3(double, const double &)") if (mix3(1.0) != 103): raise RuntimeError, ("mix3(double)") # Combination 1 if (overtparams1(100) != 10): raise RuntimeError, ("overtparams1(int)") if (overtparams1(100.0, 100) != 20): raise RuntimeError, ("overtparams1(double, int)") # Combination 2 if (overtparams2(100.0, 100) != 40): raise RuntimeError, ("overtparams2(double, int)") # Combination 3 if (overloaded() != 60): raise RuntimeError, ("overloaded()") if (overloaded(100.0, 100) != 70): raise RuntimeError, ("overloaded(double, int)") # Combination 4 if (overloadedagain("hello") != 80): raise RuntimeError, ("overloadedagain(const char *)") if (overloadedagain() != 90): raise RuntimeError, ("overloadedagain(double)") # specializations if (specialization(10) != 202): raise RuntimeError, ("specialization(int)") if (specialization(10.0) != 203): raise RuntimeError, ("specialization(double)") if (specialization(10, 10) != 204): raise RuntimeError, ("specialization(int, int)") if (specialization(10.0, 10.0) != 205): raise RuntimeError, ("specialization(double, double)") if (specialization("hi", "hi") != 201): raise RuntimeError, ("specialization(const char *, const char *)") # simple specialization xyz() xyz_int() xyz_double() # a bit of everything if (overload("hi") != 0): raise RuntimeError, ("overload()") if (overload(1) != 10): raise RuntimeError, ("overload(int t)") if (overload(1, 1) != 20): raise RuntimeError, ("overload(int t, const int &)") if (overload(1, "hello") != 30): raise RuntimeError, ("overload(int t, const char *)") k = Klass() if (overload(k) != 10): raise RuntimeError, ("overload(Klass t)") if (overload(k, k) != 20): raise RuntimeError, ("overload(Klass t, const Klass &)") if (overload(k, "hello") != 30): raise RuntimeError, ("overload(Klass t, const char *)") if (overload(10.0, "hi") != 40): raise RuntimeError, ("overload(double t, const char *)") if (overload() != 50): raise RuntimeError, ("overload(const char *)") # everything put in a namespace if (nsoverload("hi") != 1000): raise RuntimeError, ("nsoverload()") if (nsoverload(1) != 1010): raise RuntimeError, ("nsoverload(int t)") if (nsoverload(1, 1) != 1020): raise RuntimeError, ("nsoverload(int t, const int &)") if (nsoverload(1, "hello") != 1030): raise RuntimeError, ("nsoverload(int t, const char *)") if (nsoverload(k) != 1010): raise RuntimeError, ("nsoverload(Klass t)") if (nsoverload(k, k) != 1020): raise RuntimeError, ("nsoverload(Klass t, const Klass &)") if (nsoverload(k, "hello") != 1030): raise RuntimeError, ("nsoverload(Klass t, const char *)") if (nsoverload(10.0, "hi") != 1040): raise RuntimeError, ("nsoverload(double t, const char *)") if (nsoverload() != 1050): raise RuntimeError, ("nsoverload(const char *)") A.foo(1) b = B() b.foo(1) swig-3.0.2/Examples/test-suite/python/class_scope_weird_runme.py0000664000175000017500000000017412343605122025022 0ustar williamwilliamimport class_scope_weird f = class_scope_weird.Foo() g = class_scope_weird.Foo(3) if f.bar(3) != 3: raise RuntimeError swig-3.0.2/Examples/test-suite/python/abstract_typedef_runme.py0000664000175000017500000000014612343605122024654 0ustar williamwilliamfrom abstract_typedef import * e = Engine() a = A() if a.write(e) != 1: raise RuntimeError swig-3.0.2/Examples/test-suite/python/return_const_value_runme.py0000664000175000017500000000046012343605122025251 0ustar williamwilliamimport return_const_value import sys p = return_const_value.Foo_ptr.getPtr() if (p.getVal() != 17): print "Runtime test1 faild. p.getVal()=", p.getVal() sys.exit(1) p = return_const_value.Foo_ptr.getConstPtr() if (p.getVal() != 17): print "Runtime test2 faild. p.getVal()=", p.getVal() sys.exit(1) swig-3.0.2/Examples/test-suite/python/using_composition_runme.py0000664000175000017500000000127112343605122025101 0ustar williamwilliamfrom using_composition import * f = FooBar() if f.blah(3) != 3: raise RuntimeError,"FooBar::blah(int)" if f.blah(3.5) != 3.5: raise RuntimeError,"FooBar::blah(double)" if f.blah("hello") != "hello": raise RuntimeError,"FooBar::blah(char *)" f = FooBar2() if f.blah(3) != 3: raise RuntimeError,"FooBar2::blah(int)" if f.blah(3.5) != 3.5: raise RuntimeError,"FooBar2::blah(double)" if f.blah("hello") != "hello": raise RuntimeError,"FooBar2::blah(char *)" f = FooBar3() if f.blah(3) != 3: raise RuntimeError,"FooBar3::blah(int)" if f.blah(3.5) != 3.5: raise RuntimeError,"FooBar3::blah(double)" if f.blah("hello") != "hello": raise RuntimeError,"FooBar3::blah(char *)" swig-3.0.2/Examples/test-suite/python/director_nested_runme.py0000664000175000017500000000203412343605122024504 0ustar williamwilliamfrom director_nested import * class A(FooBar_int): def do_step(self): return "A::do_step;" def get_value(self): return "A::get_value" pass a = A() if a.step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;": raise RuntimeError,"Bad A virtual resolution" class B(FooBar_int): def do_advance(self): return "B::do_advance;" + self.do_step() def do_step(self): return "B::do_step;" def get_value(self): return 1 pass b = B() if b.step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;": raise RuntimeError,"Bad B virtual resolution" class C(FooBar_int): def do_advance(self): return "C::do_advance;" + FooBar_int.do_advance(self) def do_step(self): return "C::do_step;" def get_value(self): return 2 def get_name(self): return FooBar_int.get_name(self) + " hello" pass cc = C() c = FooBar_int_get_self(cc) c.advance() if c.get_name() != "FooBar::get_name hello": raise RuntimeError if c.name() != "FooBar::get_name hello": raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_std_vector_extra_runme.py0000664000175000017500000000602712343605122025400 0ustar williamwilliamfrom li_std_vector_extra import * iv = IntVector(4) for i in range(0,4): iv[i] = i x = average(iv) y = average([1,2,3,4]) a = half([10,10.5,11,11.5]) dv = DoubleVector(10) for i in range(0,10): dv[i] = i/2.0 halve_in_place(dv) bv = BoolVector(4) bv[0]= bool(1) bv[1]= bool(0) bv[2]= bool(4) bv[3]= bool(0) if bv[0] != bv[2]: raise RuntimeError,"bad std::vector mapping" b = B(5) va = VecA([b,None,b,b]) if va[0].f(1) != 6: raise RuntimeError,"bad std::vector mapping" if vecAptr(va) != 6: raise RuntimeError,"bad std::vector mapping" b.val = 7 if va[3].f(1) != 8: raise RuntimeError,"bad std::vector mapping" ip = PtrInt() ap = new_ArrInt(10) ArrInt_setitem(ip,0,123) ArrInt_setitem(ap,2,123) vi = IntPtrVector((ip,ap,None)) if ArrInt_getitem(vi[0],0) != ArrInt_getitem(vi[1],2): raise RuntimeError,"bad std::vector mapping" delete_ArrInt(ap) a = halfs([10,8,4,3]) v = IntVector() v[0:2] = [1,2] if v[0] != 1 or v[1] != 2: raise RuntimeError,"bad setslice" if v[0:-1][0] != 1: raise RuntimeError,"bad getslice" if v[0:-2].size() != 0: raise RuntimeError,"bad getslice" v[0:1] = [2] if v[0] != 2: raise RuntimeError,"bad setslice" v[1:] = [3] if v[1] != 3: raise RuntimeError,"bad setslice" v[2:] = [3] if v[2] != 3: raise RuntimeError,"bad setslice" if v[0:][0] != v[0]: raise RuntimeError,"bad getslice" del v[:] if v.size() != 0: raise RuntimeError,"bad getslice" del v[:] if v.size() != 0: raise RuntimeError,"bad getslice" v = vecStr(["hello ", "world"]) if v[0] != 'hello world': raise RuntimeError,"bad std::string+std::vector" pv = pyvector([1, "hello", (1,2)]) if pv[1] != "hello": raise RuntimeError iv = IntVector(5) for i in range(0,5): iv[i] = i iv[1:3] = [] if iv[1] != 3: raise RuntimeError # Overloading checks if overloaded1(iv) != "vector": raise RuntimeError if overloaded1(dv) != "vector": raise RuntimeError if overloaded2(iv) != "vector": raise RuntimeError if overloaded2(dv) != "vector": raise RuntimeError if overloaded3(iv) != "vector *": raise RuntimeError if overloaded3(None) != "vector *": raise RuntimeError if overloaded3(100) != "int": raise RuntimeError # vector pointer checks ip = makeIntPtr(11) dp = makeDoublePtr(33.3) error = 0 try: vi = IntPtrVector((ip, dp)) # check vector does not accept double * element error = 1 except: pass if error: raise RuntimeError vi = IntPtrVector((ip, makeIntPtr(22))) if extractInt(vi[0]) != 11: raise RuntimeError if extractInt(vi[1]) != 22: raise RuntimeError # vector const pointer checks csp = makeConstShortPtr(111) error = 0 try: vcs = ConstShortPtrVector((csp, dp)) # check vector does not accept double * element error = 1 except: pass if error: raise RuntimeError vcs = ConstShortPtrVector((csp, makeConstShortPtr(222))) if extractConstShort(vcs[0]) != 111: raise RuntimeError if extractConstShort(vcs[1]) != 222: raise RuntimeError swig-3.0.2/Examples/test-suite/python/using_inherit_runme.py0000664000175000017500000000153312343605122024201 0ustar williamwilliamfrom using_inherit import * b = Bar() if b.test(3) != 3: raise RuntimeError,"Bar::test(int)" if b.test(3.5) != 3.5: raise RuntimeError, "Bar::test(double)" b = Bar2() if b.test(3) != 6: raise RuntimeError,"Bar2::test(int)" if b.test(3.5) != 7.0: raise RuntimeError, "Bar2::test(double)" b = Bar3() if b.test(3) != 6: raise RuntimeError,"Bar3::test(int)" if b.test(3.5) != 7.0: raise RuntimeError, "Bar3::test(double)" b = Bar4() if b.test(3) != 6: raise RuntimeError,"Bar4::test(int)" if b.test(3.5) != 7.0: raise RuntimeError, "Bar4::test(double)" b = Fred1() if b.test(3) != 3: raise RuntimeError,"Fred1::test(int)" if b.test(3.5) != 7.0: raise RuntimeError, "Fred1::test(double)" b = Fred2() if b.test(3) != 3: raise RuntimeError,"Fred2::test(int)" if b.test(3.5) != 7.0: raise RuntimeError, "Fred2::test(double)" swig-3.0.2/Examples/test-suite/python/director_classic_runme.py0000664000175000017500000000630212343605122024645 0ustar williamwilliamfrom director_classic import * class TargetLangPerson(Person): def __init__(self): Person.__init__(self) def id(self): identifier = "TargetLangPerson" return identifier class TargetLangChild(Child): def __init__(self): Child.__init__(self) def id(self): identifier = "TargetLangChild" return identifier class TargetLangGrandChild(GrandChild): def __init__(self): GrandChild.__init__(self) def id(self): identifier = "TargetLangGrandChild" return identifier # Semis - don't override id() in target language class TargetLangSemiPerson(Person): def __init__(self): Person.__init__(self) # No id() override class TargetLangSemiChild(Child): def __init__(self): Child.__init__(self) # No id() override class TargetLangSemiGrandChild(GrandChild): def __init__(self): GrandChild.__init__(self) # No id() override # Orphans - don't override id() in C++ class TargetLangOrphanPerson(OrphanPerson): def __init__(self): OrphanPerson.__init__(self) def id(self): identifier = "TargetLangOrphanPerson" return identifier class TargetLangOrphanChild(OrphanChild): def __init__(self): Child.__init__(self) def id(self): identifier = "TargetLangOrphanChild" return identifier def check(person, expected): debug = 0 # Normal target language polymorphic call ret = person.id() if (debug): print(ret) if (ret != expected): raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) # Polymorphic call from C++ caller = Caller() caller.setCallback(person) ret = caller.call() if (debug): print(ret) if (ret != expected): raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) # Polymorphic call of object created in target language and passed to C++ and back again baseclass = caller.baseClass() ret = baseclass.id() if (debug): print(ret) if (ret != expected): raise RuntimeError("Failed. Received: " + str(ret)+ " Expected: " + expected) caller.resetCallback() if (debug): print("----------------------------------------") person = Person(); check(person, "Person"); del person person = Child(); check(person, "Child"); del person person = GrandChild(); check(person, "GrandChild"); del person person = TargetLangPerson(); check(person, "TargetLangPerson"); del person person = TargetLangChild(); check(person, "TargetLangChild"); del person person = TargetLangGrandChild(); check(person, "TargetLangGrandChild"); del person # Semis - don't override id() in target language person = TargetLangSemiPerson(); check(person, "Person"); del person person = TargetLangSemiChild(); check(person, "Child"); del person person = TargetLangSemiGrandChild(); check(person, "GrandChild"); del person # Orphans - don't override id() in C++ person = OrphanPerson(); check(person, "Person"); del person person = OrphanChild(); check(person, "Child"); del person person = TargetLangOrphanPerson(); check(person, "TargetLangOrphanPerson"); del person person = TargetLangOrphanChild(); check(person, "TargetLangOrphanChild"); del person swig-3.0.2/Examples/test-suite/python/extern_c_runme.py0000664000175000017500000000005312343605122023135 0ustar williamwilliamimport extern_c extern_c.RealFunction(2) swig-3.0.2/Examples/test-suite/python/li_boost_shared_ptr_runme.py0000664000175000017500000004360212343605122025362 0ustar williamwilliamimport li_boost_shared_ptr import gc debug = False # simple shared_ptr usage - created in C++ class li_boost_shared_ptr_runme: def main(self): if (debug): print "Started" li_boost_shared_ptr.cvar.debug_shared = debug # Change loop count to run for a long time to monitor memory loopCount = 1 #5000 for i in range (0,loopCount): self.runtest() # Expect 1 instance - the one global variable (GlobalValue) if (li_boost_shared_ptr.Klass.getTotal_count() != 1): raise RuntimeError("Klass.total_count=%s" % li_boost_shared_ptr.Klass.getTotal_count()) wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count() if (wrapper_count != li_boost_shared_ptr.NOT_COUNTING): # Expect 1 instance - the one global variable (GlobalSmartValue) if (wrapper_count != 1): raise RuntimeError("shared_ptr wrapper count=%s" % wrapper_count) if (debug): print "Finished" def runtest(self): # simple shared_ptr usage - created in C++ k = li_boost_shared_ptr.Klass("me oh my") val = k.getValue() self.verifyValue("me oh my", val) self.verifyCount(1, k) # simple shared_ptr usage - not created in C++ k = li_boost_shared_ptr.factorycreate() val = k.getValue() self.verifyValue("factorycreate", val) self.verifyCount(1, k) # pass by shared_ptr k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.smartpointertest(k) val = kret.getValue() self.verifyValue("me oh my smartpointertest", val) self.verifyCount(2, k) self.verifyCount(2, kret) # pass by shared_ptr pointer k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.smartpointerpointertest(k) val = kret.getValue() self.verifyValue("me oh my smartpointerpointertest", val) self.verifyCount(2, k) self.verifyCount(2, kret) # pass by shared_ptr reference k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.smartpointerreftest(k) val = kret.getValue() self.verifyValue("me oh my smartpointerreftest", val) self.verifyCount(2, k) self.verifyCount(2, kret) # pass by shared_ptr pointer reference k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.smartpointerpointerreftest(k) val = kret.getValue() self.verifyValue("me oh my smartpointerpointerreftest", val) self.verifyCount(2, k) self.verifyCount(2, kret) # const pass by shared_ptr k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.constsmartpointertest(k) val = kret.getValue() self.verifyValue("me oh my", val) self.verifyCount(2, k) self.verifyCount(2, kret) # const pass by shared_ptr pointer k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.constsmartpointerpointertest(k) val = kret.getValue() self.verifyValue("me oh my", val) self.verifyCount(2, k) self.verifyCount(2, kret) # const pass by shared_ptr reference k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.constsmartpointerreftest(k) val = kret.getValue() self.verifyValue("me oh my", val) self.verifyCount(2, k) self.verifyCount(2, kret) # pass by value k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.valuetest(k) val = kret.getValue() self.verifyValue("me oh my valuetest", val) self.verifyCount(1, k) self.verifyCount(1, kret) # pass by pointer k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.pointertest(k) val = kret.getValue() self.verifyValue("me oh my pointertest", val) self.verifyCount(1, k) self.verifyCount(1, kret) # pass by reference k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.reftest(k) val = kret.getValue() self.verifyValue("me oh my reftest", val) self.verifyCount(1, k) self.verifyCount(1, kret) # pass by pointer reference k = li_boost_shared_ptr.Klass("me oh my") kret = li_boost_shared_ptr.pointerreftest(k) val = kret.getValue() self.verifyValue("me oh my pointerreftest", val) self.verifyCount(1, k) self.verifyCount(1, kret) # null tests k = None if (li_boost_shared_ptr.smartpointertest(k) != None): raise RuntimeError("return was not null") if (li_boost_shared_ptr.smartpointerpointertest(k) != None): raise RuntimeError("return was not null") if (li_boost_shared_ptr.smartpointerreftest(k) != None): raise RuntimeError("return was not null") if (li_boost_shared_ptr.smartpointerpointerreftest(k) != None): raise RuntimeError("return was not null") if (li_boost_shared_ptr.nullsmartpointerpointertest(None) != "null pointer"): raise RuntimeError("not null smartpointer pointer") try: li_boost_shared_ptr.valuetest(k) raise RuntimeError("Failed to catch null pointer") except ValueError: pass if (li_boost_shared_ptr.pointertest(k) != None): raise RuntimeError("return was not null") try: li_boost_shared_ptr.reftest(k) raise RuntimeError("Failed to catch null pointer") except ValueError: pass # $owner k = li_boost_shared_ptr.pointerownertest() val = k.getValue() self.verifyValue("pointerownertest", val) self.verifyCount(1, k) k = li_boost_shared_ptr.smartpointerpointerownertest() val = k.getValue() self.verifyValue("smartpointerpointerownertest", val) self.verifyCount(1, k) # //////////////////////////////// Derived class //////////////////////////////////////// # derived pass by shared_ptr k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.derivedsmartptrtest(k) val = kret.getValue() self.verifyValue("me oh my derivedsmartptrtest-Derived", val) self.verifyCount(2, k) self.verifyCount(2, kret) # derived pass by shared_ptr pointer k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.derivedsmartptrpointertest(k) val = kret.getValue() self.verifyValue("me oh my derivedsmartptrpointertest-Derived", val) self.verifyCount(2, k) self.verifyCount(2, kret) # derived pass by shared_ptr ref k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.derivedsmartptrreftest(k) val = kret.getValue() self.verifyValue("me oh my derivedsmartptrreftest-Derived", val) self.verifyCount(2, k) self.verifyCount(2, kret) # derived pass by shared_ptr pointer ref k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.derivedsmartptrpointerreftest(k) val = kret.getValue() self.verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val) self.verifyCount(2, k) self.verifyCount(2, kret) # derived pass by pointer k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.derivedpointertest(k) val = kret.getValue() self.verifyValue("me oh my derivedpointertest-Derived", val) self.verifyCount(1, k) self.verifyCount(1, kret) # derived pass by ref k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.derivedreftest(k) val = kret.getValue() self.verifyValue("me oh my derivedreftest-Derived", val) self.verifyCount(1, k) self.verifyCount(1, kret) # //////////////////////////////// Derived and base class mixed //////////////////////////////////////// # pass by shared_ptr (mixed) k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.smartpointertest(k) val = kret.getValue() self.verifyValue("me oh my smartpointertest-Derived", val) self.verifyCount(2, k) self.verifyCount(2, kret) # pass by shared_ptr pointer (mixed) k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.smartpointerpointertest(k) val = kret.getValue() self.verifyValue("me oh my smartpointerpointertest-Derived", val) self.verifyCount(2, k) self.verifyCount(2, kret) # pass by shared_ptr reference (mixed) k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.smartpointerreftest(k) val = kret.getValue() self.verifyValue("me oh my smartpointerreftest-Derived", val) self.verifyCount(2, k) self.verifyCount(2, kret) # pass by shared_ptr pointer reference (mixed) k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.smartpointerpointerreftest(k) val = kret.getValue() self.verifyValue("me oh my smartpointerpointerreftest-Derived", val) self.verifyCount(2, k) self.verifyCount(2, kret) # pass by value (mixed) k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.valuetest(k) val = kret.getValue() self.verifyValue("me oh my valuetest", val) # note slicing self.verifyCount(1, k) self.verifyCount(1, kret) # pass by pointer (mixed) k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.pointertest(k) val = kret.getValue() self.verifyValue("me oh my pointertest-Derived", val) self.verifyCount(1, k) self.verifyCount(1, kret) # pass by ref (mixed) k = li_boost_shared_ptr.KlassDerived("me oh my") kret = li_boost_shared_ptr.reftest(k) val = kret.getValue() self.verifyValue("me oh my reftest-Derived", val) self.verifyCount(1, k) self.verifyCount(1, kret) # //////////////////////////////// Overloading tests //////////////////////////////////////// # Base class k = li_boost_shared_ptr.Klass("me oh my") self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval") self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref") self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr") self.verifyValue(li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref") self.verifyValue(li_boost_shared_ptr.overload_smartbyval(k), "smartbyval") self.verifyValue(li_boost_shared_ptr.overload_smartbyref(k), "smartbyref") self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr") self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref") # Derived class k = li_boost_shared_ptr.KlassDerived("me oh my") self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval") self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref") self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr") self.verifyValue(li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref") self.verifyValue(li_boost_shared_ptr.overload_smartbyval(k), "smartbyval") self.verifyValue(li_boost_shared_ptr.overload_smartbyref(k), "smartbyref") self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr") self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref") # 3rd derived class k = li_boost_shared_ptr.Klass3rdDerived("me oh my") val = k.getValue() self.verifyValue("me oh my-3rdDerived", val) self.verifyCount(1, k) val = li_boost_shared_ptr.test3rdupcast(k) self.verifyValue("me oh my-3rdDerived", val) self.verifyCount(1, k) # //////////////////////////////// Member variables //////////////////////////////////////// # smart pointer by value m = li_boost_shared_ptr.MemberVariables() k = li_boost_shared_ptr.Klass("smart member value") m.SmartMemberValue = k val = k.getValue() self.verifyValue("smart member value", val) self.verifyCount(2, k) kmember = m.SmartMemberValue val = kmember.getValue() self.verifyValue("smart member value", val) self.verifyCount(3, kmember) self.verifyCount(3, k) del m self.verifyCount(2, kmember) self.verifyCount(2, k) # smart pointer by pointer m = li_boost_shared_ptr.MemberVariables() k = li_boost_shared_ptr.Klass("smart member pointer") m.SmartMemberPointer = k val = k.getValue() self.verifyValue("smart member pointer", val) self.verifyCount(1, k) kmember = m.SmartMemberPointer val = kmember.getValue() self.verifyValue("smart member pointer", val) self.verifyCount(2, kmember) self.verifyCount(2, k) del m self.verifyCount(2, kmember) self.verifyCount(2, k) # smart pointer by reference m = li_boost_shared_ptr.MemberVariables() k = li_boost_shared_ptr.Klass("smart member reference") m.SmartMemberReference = k val = k.getValue() self.verifyValue("smart member reference", val) self.verifyCount(2, k) kmember = m.SmartMemberReference val = kmember.getValue() self.verifyValue("smart member reference", val) self.verifyCount(3, kmember) self.verifyCount(3, k) # The C++ reference refers to SmartMemberValue... kmemberVal = m.SmartMemberValue val = kmember.getValue() self.verifyValue("smart member reference", val) self.verifyCount(4, kmemberVal) self.verifyCount(4, kmember) self.verifyCount(4, k) del m self.verifyCount(3, kmemberVal) self.verifyCount(3, kmember) self.verifyCount(3, k) # plain by value m = li_boost_shared_ptr.MemberVariables() k = li_boost_shared_ptr.Klass("plain member value") m.MemberValue = k val = k.getValue() self.verifyValue("plain member value", val) self.verifyCount(1, k) kmember = m.MemberValue val = kmember.getValue() self.verifyValue("plain member value", val) self.verifyCount(1, kmember) self.verifyCount(1, k) del m self.verifyCount(1, kmember) self.verifyCount(1, k) # plain by pointer m = li_boost_shared_ptr.MemberVariables() k = li_boost_shared_ptr.Klass("plain member pointer") m.MemberPointer = k val = k.getValue() self.verifyValue("plain member pointer", val) self.verifyCount(1, k) kmember = m.MemberPointer val = kmember.getValue() self.verifyValue("plain member pointer", val) self.verifyCount(1, kmember) self.verifyCount(1, k) del m self.verifyCount(1, kmember) self.verifyCount(1, k) # plain by reference m = li_boost_shared_ptr.MemberVariables() k = li_boost_shared_ptr.Klass("plain member reference") m.MemberReference = k val = k.getValue() self.verifyValue("plain member reference", val) self.verifyCount(1, k) kmember = m.MemberReference val = kmember.getValue() self.verifyValue("plain member reference", val) self.verifyCount(1, kmember) self.verifyCount(1, k) del m self.verifyCount(1, kmember) self.verifyCount(1, k) # null member variables m = li_boost_shared_ptr.MemberVariables() # shared_ptr by value k = m.SmartMemberValue if (k != None): raise RuntimeError("expected null") m.SmartMemberValue = None k = m.SmartMemberValue if (k != None): raise RuntimeError("expected null") self.verifyCount(0, k) # plain by value try: m.MemberValue = None raise RuntimeError("Failed to catch null pointer") except ValueError: pass # ////////////////////////////////// Global variables //////////////////////////////////////// # smart pointer kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue if (kglobal != None): raise RuntimeError("expected null") k = li_boost_shared_ptr.Klass("smart global value") li_boost_shared_ptr.cvar.GlobalSmartValue = k self.verifyCount(2, k) kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue val = kglobal.getValue() self.verifyValue("smart global value", val) self.verifyCount(3, kglobal) self.verifyCount(3, k) self.verifyValue("smart global value", li_boost_shared_ptr.cvar.GlobalSmartValue.getValue()) li_boost_shared_ptr.cvar.GlobalSmartValue = None # plain value k = li_boost_shared_ptr.Klass("global value") li_boost_shared_ptr.cvar.GlobalValue = k self.verifyCount(1, k) kglobal = li_boost_shared_ptr.cvar.GlobalValue val = kglobal.getValue() self.verifyValue("global value", val) self.verifyCount(1, kglobal) self.verifyCount(1, k) self.verifyValue("global value", li_boost_shared_ptr.cvar.GlobalValue.getValue()) try: li_boost_shared_ptr.cvar.GlobalValue = None raise RuntimeError("Failed to catch null pointer") except ValueError: pass # plain pointer kglobal = li_boost_shared_ptr.cvar.GlobalPointer if (kglobal != None): raise RuntimeError("expected null") k = li_boost_shared_ptr.Klass("global pointer") li_boost_shared_ptr.cvar.GlobalPointer = k self.verifyCount(1, k) kglobal = li_boost_shared_ptr.cvar.GlobalPointer val = kglobal.getValue() self.verifyValue("global pointer", val) self.verifyCount(1, kglobal) self.verifyCount(1, k) li_boost_shared_ptr.cvar.GlobalPointer = None # plain reference kglobal k = li_boost_shared_ptr.Klass("global reference") li_boost_shared_ptr.cvar.GlobalReference = k self.verifyCount(1, k) kglobal = li_boost_shared_ptr.cvar.GlobalReference val = kglobal.getValue() self.verifyValue("global reference", val) self.verifyCount(1, kglobal) self.verifyCount(1, k) try: li_boost_shared_ptr.cvar.GlobalReference = None raise RuntimeError("Failed to catch null pointer") except ValueError: pass # ////////////////////////////////// Templates //////////////////////////////////////// pid = li_boost_shared_ptr.PairIntDouble(10, 20.2) if (pid.baseVal1 != 20 or pid.baseVal2 != 40.4): raise RuntimeError("Base values wrong") if (pid.val1 != 10 or pid.val2 != 20.2): raise RuntimeError("Derived Values wrong") def verifyValue(self, expected, got): if (expected != got): raise RuntimeError("verify value failed. Expected: ", expected, " Got: ", got) def verifyCount(self, expected, k): got = li_boost_shared_ptr.use_count(k) if (expected != got): raise RuntimeError("verify use_count failed. Expected: ", expected, " Got: ", got) runme = li_boost_shared_ptr_runme() runme.main() swig-3.0.2/Examples/test-suite/python/rename_pcre_encoder_runme.py0000664000175000017500000000062612343605122025313 0ustar williamwilliamfrom rename_pcre_encoder import * s = SomeWidget() s.put_borderWidth(3) if s.get_borderWidth() != 3: raise RuntimeError("Border should be 3, not %d" % (s.get_borderWidth(),)) s.put_size(4, 5) a = AnotherWidget() a.DoSomething() evt = wxEVTSomeEvent() t = xUnchangedName() if StartINSAneAndUNSAvoryTraNSAtlanticRaNSAck() != 42: raise RuntimeError("Unexpected result of renamed function call") swig-3.0.2/Examples/test-suite/python/li_std_vector_ptr_runme.py0000664000175000017500000000017512343605122025060 0ustar williamwilliamfrom li_std_vector_ptr import * ip1 = makeIntPtr(11) ip2 = makeIntPtr(22) vi = IntPtrVector((ip1, ip2)) displayVector(vi) swig-3.0.2/Examples/test-suite/python/struct_rename_runme.py0000664000175000017500000000005612343605122024204 0ustar williamwilliamimport struct_rename b = struct_rename.Bar() swig-3.0.2/Examples/test-suite/python/li_std_carray_runme.py0000664000175000017500000000115012343605122024144 0ustar williamwilliamfrom li_std_carray import * v3 = Vector3() for i in range(0,len(v3)): v3[i] = i i = 0 for d in v3: if d != i: raise RuntimeError i = i + 1 m3 = Matrix3() for i in range(0,len(m3)): v3 = m3[i] for j in range(0,len(v3)): v3[j] = i + j i = 0 for v3 in m3: j = 0 for d in v3: if d != i + j: raise RuntimeError j = j + 1 pass i = i + 1 pass for i in range(0,len(m3)): for j in range(0,len(m3)): if m3[i][j] != i + j: raise RuntimeError da = Vector3((1,2,3)) ma = Matrix3(((1,2,3),(4,5,6),(7,8,9))) swig-3.0.2/Examples/test-suite/python/member_pointer_runme.py0000664000175000017500000000211512343605122024336 0ustar williamwilliam# Example using pointers to member functions from member_pointer import * def check(what, expected, actual): if expected != actual: raise RuntimeError ("Failed: " , what , " Expected: " , expected , " Actual: " , actual) # Get the pointers area_pt = areapt() perim_pt = perimeterpt() # Create some objects s = Square(10) # Do some calculations check ("Square area ", 100.0, do_op(s,area_pt)) check ("Square perim", 40.0, do_op(s,perim_pt)) memberPtr = cvar.areavar memberPtr = cvar.perimetervar # Try the variables check ("Square area ", 100.0, do_op(s,cvar.areavar)) check ("Square perim", 40.0, do_op(s,cvar.perimetervar)) # Modify one of the variables cvar.areavar = perim_pt check ("Square perimeter", 40.0, do_op(s,cvar.areavar)) # Try the constants memberPtr = AREAPT memberPtr = PERIMPT memberPtr = NULLPT check ("Square area ", 100.0, do_op(s,AREAPT)) check ("Square perim", 40.0, do_op(s,PERIMPT)) check ("Add by value", 3, call1(ADD_BY_VALUE, 1, 2)) check ("Add by pointer", 7, call2(ADD_BY_POINTER, 3, 4)) check ("Add by reference", 11, call3(ADD_BY_REFERENCE, 5, 6)) swig-3.0.2/Examples/test-suite/python/smart_pointer_member_runme.py0000664000175000017500000000044112343605122025544 0ustar williamwilliamfrom smart_pointer_member import * f = Foo() f.y = 1 if f.y != 1: raise RuntimeError b = Bar(f) b.y = 2 if f.y != 2: print f.y print b.y raise RuntimeError if b.x != f.x: raise RuntimeError if b.z != f.z: raise RuntimeError if Foo.z == Bar.z: raise RuntimeError swig-3.0.2/Examples/test-suite/python/director_detect_runme.py0000664000175000017500000000115312343605122024473 0ustar williamwilliamimport director_detect class MyBar(director_detect.Bar): def __init__(self, val = 2): director_detect.Bar.__init__(self) self.val = val def get_value(self): self.val = self.val + 1 return self.val def get_class(self): self.val = self.val + 1 return director_detect.A() def just_do_it(self): self.val = self.val + 1 def clone(self): return MyBar(self.val) pass b = MyBar() f = b.baseclass() v = f.get_value() a = f.get_class() f.just_do_it() c = b.clone() vc = c.get_value() if (v != 3) or (b.val != 5) or (vc != 6): raise RuntimeError,"Bad virtual detection" swig-3.0.2/Examples/test-suite/python/inplaceadd_runme.py0000664000175000017500000000035012343605122023412 0ustar williamwilliamimport inplaceadd a = inplaceadd.A(7) a += 5 if a.val != 12: print a.val raise RuntimeError a -= 5 if a.val != 7: raise RuntimeError a *= 2 if a.val != 14: raise RuntimeError a += a if a.val != 28: raise RuntimeError swig-3.0.2/Examples/test-suite/python/cpp11_thread_local_runme.py0000664000175000017500000000114112343605122024752 0ustar williamwilliamfrom cpp11_thread_local import * t = ThreadLocals() if t.stval != 11: raise RuntimeError if t.tsval != 22: raise RuntimeError if t.tscval99 != 99: raise RuntimeError cvar.etval = -11 if cvar.etval != -11: raise RuntimeError cvar.stval = -22 if cvar.stval != -22: raise RuntimeError cvar.tsval = -33 if cvar.tsval != -33: raise RuntimeError cvar.etval = -44 if cvar.etval != -44: raise RuntimeError cvar.teval = -55 if cvar.teval != -55: raise RuntimeError cvar.ectval = -66 if cvar.ectval != -66: raise RuntimeError cvar.ecpptval = -66 if cvar.ecpptval != -66: raise RuntimeError swig-3.0.2/Examples/test-suite/python/cpp11_raw_string_literals_runme.py0000664000175000017500000000151212343605122026411 0ustar williamwilliamfrom cpp11_raw_string_literals import * if cvar.L != 100: raise RuntimeError if cvar.u8 != 100: raise RuntimeError if cvar.u != 100: raise RuntimeError if UStruct.U != 100: raise RuntimeError if cvar.R != 100: raise RuntimeError if cvar.LR != 100: raise RuntimeError if cvar.u8R != 100: raise RuntimeError if cvar.uR != 100: raise RuntimeError if URStruct.UR != 100: raise RuntimeError if cvar.aa != "Wide string": raise RuntimeError if cvar.bb != "UTF-8 string": raise RuntimeError, cvar.wide if cvar.xx != ")I'm an \"ascii\" \\ string.": raise RuntimeError, cvar.xx if cvar.ee != ")I'm an \"ascii\" \\ string.": raise RuntimeError, cvar.ee if cvar.ff != "I'm a \"raw wide\" \\ string.": raise RuntimeError, cvar.ff if cvar.gg != "I'm a \"raw UTF-8\" \\ string.": raise RuntimeError, cvar.gg swig-3.0.2/Examples/test-suite/python/template_type_namespace_runme.py0000664000175000017500000000020112343605122026211 0ustar williamwilliamfrom template_type_namespace import * if type(foo()[0]) != type(""): raise RuntimeError swig-3.0.2/Examples/test-suite/python/director_string_runme.py0000664000175000017500000000070512343605122024533 0ustar williamwilliamfrom director_string import * class B(A): def __init__(self,string): A.__init__(self,string) def get_first(self): return A.get_first(self) + " world!" def process_text(self, string): A.process_text(self, string) self.smem = "hello" b = B("hello") b.get(0) if b.get_first() != "hello world!": print b.get_first() raise RuntimeError b.call_process_func() if b.smem != "hello": print smem raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_carrays_runme.py0000664000175000017500000000016612343605122023463 0ustar williamwilliamfrom li_carrays import * d = doubleArray(10) d[0] = 7 d[5] = d[0] + 3 if d[5] + d[0] != 17: raise RuntimeError swig-3.0.2/Examples/test-suite/python/preproc_include_runme.py0000664000175000017500000000073012343605122024505 0ustar williamwilliamimport preproc_include if preproc_include.multiply10(10) != 100: raise RuntimeError if preproc_include.multiply20(10) != 200: raise RuntimeError if preproc_include.multiply30(10) != 300: raise RuntimeError if preproc_include.multiply40(10) != 400: raise RuntimeError if preproc_include.multiply50(10) != 500: raise RuntimeError if preproc_include.multiply60(10) != 600: raise RuntimeError if preproc_include.multiply70(10) != 700: raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_std_wstring_runme.py0000664000175000017500000000373512343605122024373 0ustar williamwilliamimport li_std_wstring x=u"h" if li_std_wstring.test_wcvalue(x) != x: print li_std_wstring.test_wcvalue(x) raise RuntimeError("bad string mapping") x=u"hello" if li_std_wstring.test_ccvalue(x) != x: raise RuntimeError("bad string mapping") if li_std_wstring.test_cvalue(x) != x: raise RuntimeError("bad string mapping") if li_std_wstring.test_wchar_overload(x) != x: raise RuntimeError("bad string mapping") if li_std_wstring.test_wchar_overload("not unicode") != "not unicode": raise RuntimeError("bad string mapping") if li_std_wstring.test_value(x) != x: print x, li_std_wstring.test_value(x) raise RuntimeError("bad string mapping") if li_std_wstring.test_const_reference(x) != x: raise RuntimeError("bad string mapping") s = li_std_wstring.wstring(u"he") s = s + u"llo" if s != x: print s, x raise RuntimeError("bad string mapping") if s[1:4] != x[1:4]: raise RuntimeError("bad string mapping") if li_std_wstring.test_value(s) != x: raise RuntimeError("bad string mapping") if li_std_wstring.test_const_reference(s) != x: raise RuntimeError("bad string mapping") a = li_std_wstring.A(s) if li_std_wstring.test_value(a) != x: raise RuntimeError("bad string mapping") if li_std_wstring.test_const_reference(a) != x: raise RuntimeError("bad string mapping") b = li_std_wstring.wstring(" world") if a + b != "hello world": raise RuntimeError("bad string mapping") if a + " world" != "hello world": raise RuntimeError("bad string mapping") # This is expected to fail if -builtin is used if "hello" + b != "hello world": raise RuntimeError("bad string mapping") # This is expected to fail if -builtin is used c = "hello" + b if c.find_last_of("l") != 9: raise RuntimeError("bad string mapping") s = "hello world" b = li_std_wstring.B("hi") b.name = li_std_wstring.wstring(u"hello") if b.name != "hello": raise RuntimeError("bad string mapping") b.a = li_std_wstring.A("hello") if b.a != u"hello": raise RuntimeError("bad string mapping") swig-3.0.2/Examples/test-suite/python/threads_exception_runme.py0000664000175000017500000000135012343605122025037 0ustar williamwilliamimport threads_exception t = threads_exception.Test() try: t.unknown() except RuntimeError,e: pass try: t.simple() except RuntimeError,e: if e.args[0] != 37: raise RuntimeError try: t.message() except RuntimeError,e: if e.args[0] != "I died.": raise RuntimeError # This is expected fail with -builtin option # Throwing builtin classes as exceptions not supported try: t.hosed() except threads_exception.Exc,e: code = e.code if code != 42: raise RuntimeError, "bad... code: %d" % code msg = e.msg if msg != "Hosed": raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg)) for i in range(1,4): try: t.multi(i) except RuntimeError,e: pass except threads_exception.Exc,e: pass swig-3.0.2/Examples/test-suite/python/li_attribute_template_runme.py0000664000175000017500000000243412343605122025715 0ustar williamwilliam# Check usage of template attributes import li_attribute_template chell = li_attribute_template.Cintint(1,2,3) def rassert( what, master ): if what != master: print what raise RuntimeError ## Testing primitive by value attribute rassert( chell.a, 1 ) chell.a = 3 rassert( chell.a, 3 ) ## Testing primitive by ref attribute rassert( chell.b, 2 ) chell.b = 5 rassert( chell.b,5 ) ## Testing string chell.str = "abc" rassert( chell.str, "abc" ) # Testing class by value rassert( chell.d.value, 1 ) chell.d = li_attribute_template.Foo(2) rassert( chell.d.value, 2 ) # Testing class by reference rassert( chell.e.value, 2 ) chell.e= li_attribute_template.Foo(3) rassert( chell.e.value, 3 ) chell.e.value = 4 rassert( chell.e.value, 4 ) # Testing moderately complex template by value rassert( chell.f.first, 1 ) rassert( chell.f.second, 2 ) pair = li_attribute_template.pair_intint(3,4) chell.f = pair rassert( chell.f.first, 3 ) rassert( chell.f.second, 4 ) # Testing moderately complex template by ref rassert( chell.g.first, 2 ) rassert( chell.g.second, 3 ) pair = li_attribute_template.pair_intint(4,5) chell.g = pair rassert( chell.g.first, 4 ) rassert( chell.g.second, 5 ) chell.g.first = 6 chell.g.second = 7 rassert( chell.g.first, 6 ) rassert( chell.g.second, 7 ) swig-3.0.2/Examples/test-suite/python/namespace_class_runme.py0000664000175000017500000000076612343605122024462 0ustar williamwilliamfrom namespace_class import * try: p = Private1() error = 1 except: error = 0 if (error): raise RuntimeError, "Private1 is private" try: p = Private2() error = 1 except: error = 0 if (error): raise RuntimeError, "Private2 is private" EulerT3D.toFrame(1,1,1) b = BooT_i() b = BooT_H() f = FooT_i() f.quack(1) f = FooT_d() f.moo(1) f = FooT_H() f.foo(Hi) f_type = str(type(f)) if f_type.find("'namespace_class.FooT_H'") == -1: raise RuntimeError("Incorrect type: " + f_type) swig-3.0.2/Examples/test-suite/python/enum_template_runme.py0000664000175000017500000000021512343605122024165 0ustar williamwilliamimport enum_template if enum_template.MakeETest() != 1: raise RuntimeError if enum_template.TakeETest(0) != None: raise RuntimeError swig-3.0.2/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py0000664000175000017500000000052112343605122027624 0ustar williamwilliamimport cpp11_alternate_function_syntax a = cpp11_alternate_function_syntax.SomeStruct() res = a.addNormal(4,5) if res != 9: raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ", res, " should be 9.") res = a.addAlternate(4,5) if res != 9: raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.") swig-3.0.2/Examples/test-suite/python/constructor_rename_runme.py0000664000175000017500000000007312343605122025244 0ustar williamwilliamfrom constructor_rename import * x = RenamedConstructor() swig-3.0.2/Examples/test-suite/python/typemap_arrays_runme.py0000664000175000017500000000013312343605122024365 0ustar williamwilliamfrom typemap_arrays import * if sumA(None) != 60: raise RuntimeError, "Sum is wrong" swig-3.0.2/Examples/test-suite/python/smart_pointer_extend_runme.py0000664000175000017500000000065112343605122025567 0ustar williamwilliamfrom smart_pointer_extend import * f = Foo() b = Bar(f) if b.extension() != f.extension(): raise RuntimeError b = CBase() d = CDerived() p = CPtr() if b.bar() != p.bar(): raise RuntimeError if d.foo() != p.foo(): raise RuntimeError if b.hello() != p.hello(): raise RuntimeError d = DFoo() dp = DPtrFoo(d) if d.SExt(1) != dp.SExt(1): raise RuntimeError if d.Ext(1) != dp.Ext(1): raise RuntimeError swig-3.0.2/Examples/test-suite/python/empty_runme.py0000664000175000017500000000001512343605122022462 0ustar williamwilliamimport empty swig-3.0.2/Examples/test-suite/python/cpp11_uniform_initialization_runme.py0000664000175000017500000000103412343605122027120 0ustar williamwilliamimport cpp11_uniform_initialization var1 = cpp11_uniform_initialization.cvar.var1 if var1.x != 5: raise RuntimeError var2 = cpp11_uniform_initialization.cvar.var2 if var2.getX() != 2: raise RuntimeError m = cpp11_uniform_initialization.MoreInit() if m.charptr != None: raise RuntimeError, m.charptr m.charptr = "hello sir" if m.charptr != "hello sir": raise RuntimeError, m.charptr if m.more1(m.vi) != 15: raise RuntimeError, m.vi if m.more1( [-1,1,2] ) != 2: raise RuntimeError, m.vi if m.more1() != 10: raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_cstring_runme.py0000664000175000017500000000125512343605122023470 0ustar williamwilliamfrom li_cstring import * if count("ab\0ab\0ab\0", 0) != 3: raise RuntimeError if test1() != "Hello World": raise RuntimeError if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": raise RuntimeError if test3("hello") != "hello-suffix": print test3("hello") raise RuntimeError if test4("hello") != "hello-suffix": print test4("hello") raise RuntimeError if test5(4) != 'xxxx': raise RuntimeError if test6(10) != 'xxxxx': raise RuntimeError if test7() !="Hello world!": raise RuntimeError if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": raise RuntimeError swig-3.0.2/Examples/test-suite/python/langobj_runme.py0000664000175000017500000000027112343605122022744 0ustar williamwilliamimport sys from langobj import * x ="hello" rx = sys.getrefcount(x) v = identity(x) rv = sys.getrefcount(v) if v != x: raise RuntimeError if rv - rx != 1: raise RuntimeError swig-3.0.2/Examples/test-suite/python/python_pybuf_runme3.py0000664000175000017500000000175312343605122024147 0ustar williamwilliam#run: # python python_pybuf_runme3.py benchmark #for the benchmark, other wise the test case will be run import python_pybuf import sys if len(sys.argv)>=2 and sys.argv[1]=="benchmark": #run the benchmark import time k=1000000 #number of times to excute the functions t=time.time() a = bytearray(b'hello world') for i in range(k): pybuf.title1(a) print("Time used by bytearray:",time.time()-t) t=time.time() b = 'hello world' for i in range(k): pybuf.title2(b) print("Time used by string:",time.time()-t) else: #run the test case buf1 = bytearray(10) buf2 = bytearray(50) pybuf.func1(buf1) assert buf1 == b'a'*10 pybuf.func2(buf2) assert buf2.startswith(b"Hello world!\x00") count = pybuf.func3(buf2) assert count==10 #number of alpha and number in 'Hello world!' length = pybuf.func4(buf2) assert length==12 buf3 = bytearray(b"hello") pybuf.title1(buf3) assert buf3==b'Hello' swig-3.0.2/Examples/test-suite/python/unions_runme.py0000664000175000017500000000240712343605122022646 0ustar williamwilliam # This is the union runtime testcase. It ensures that values within a # union embedded within a struct can be set and read correctly. import unions import sys import string # Create new instances of SmallStruct and BigStruct for later use small = unions.SmallStruct() small.jill = 200 big = unions.BigStruct() big.smallstruct = small big.jack = 300 # Use SmallStruct then BigStruct to setup EmbeddedUnionTest. # Ensure values in EmbeddedUnionTest are set correctly for each. eut = unions.EmbeddedUnionTest() # First check the SmallStruct in EmbeddedUnionTest eut.number = 1 eut.uni.small = small Jill1 = eut.uni.small.jill if (Jill1 != 200): print "Runtime test1 failed. eut.uni.small.jill=" , Jill1 sys.exit(1) Num1 = eut.number if (Num1 != 1): print "Runtime test2 failed. eut.number=" , Num1 sys.exit(1) # Secondly check the BigStruct in EmbeddedUnionTest eut.number = 2 eut.uni.big = big Jack1 = eut.uni.big.jack if (Jack1 != 300): print "Runtime test3 failed. eut.uni.big.jack=" , Jack1 sys.exit(1) Jill2 = eut.uni.big.smallstruct.jill if (Jill2 != 200): print "Runtime test4 failed. eut.uni.big.smallstruct.jill=" , Jill2 sys.exit(1) Num2 = eut.number if (Num2 != 2): print "Runtime test5 failed. eut.number=" , Num2 sys.exit(1) swig-3.0.2/Examples/test-suite/python/typename_runme.py0000664000175000017500000000046012343605122023152 0ustar williamwilliamimport typename import types f = typename.Foo() b = typename.Bar() x = typename.twoFoo(f) if not isinstance(x,types.FloatType): raise RuntimeError,"Wrong return type (FloatType) !" y = typename.twoBar(b) if not isinstance(y,types.IntType): raise RuntimeError,"Wrong return type (IntType)!" swig-3.0.2/Examples/test-suite/python/voidtest_runme.py0000664000175000017500000000064312343605122023174 0ustar williamwilliamimport voidtest voidtest.globalfunc() f = voidtest.Foo() f.memberfunc() voidtest.Foo_staticmemberfunc() def fvoid(): pass if f.memberfunc() != fvoid(): raise RuntimeError v1 = voidtest.vfunc1(f) v2 = voidtest.vfunc2(f) if v1 != v2: raise RuntimeError v3 = voidtest.vfunc3(v1) if v3.this != f.this: raise RuntimeError v4 = voidtest.vfunc1(f) if v4 != v1: raise RuntimeError v3.memberfunc() swig-3.0.2/Examples/test-suite/python/overload_rename_runme.py0000664000175000017500000000022612343605122024472 0ustar williamwilliamimport overload_rename f = overload_rename.Foo(1) f = overload_rename.Foo(1,1) f = overload_rename.Foo_int(1,1) f = overload_rename.Foo_int(1,1,1) swig-3.0.2/Examples/test-suite/python/overload_copy_runme.py0000664000175000017500000000006112343605122024172 0ustar williamwilliamfrom overload_copy import * f = Foo() g = Foo(f) swig-3.0.2/Examples/test-suite/python/callback_runme.py0000664000175000017500000000103112343605122023057 0ustar williamwilliamimport _callback from callback import * if foo(2) != 2: raise RuntimeError if A_bar(2) != 4: raise RuntimeError if foobar(3, _callback.foo) != foo(3): raise RuntimeError if foobar(3, foo) != foo(3): raise RuntimeError if foobar(3, A_bar) != A_bar(3): raise RuntimeError if foobar(3, foof) != foof(3): raise RuntimeError if foobar_i(3, foo_i) != foo_i(3): raise RuntimeError if foobar_d(3.5, foo_d) != foo_d(3.5): raise RuntimeError a = A() if foobarm(3, a, A.foom_cb_ptr) != a.foom(3): raise RuntimeError swig-3.0.2/Examples/test-suite/python/refcount_runme.py0000664000175000017500000000156012343605122023157 0ustar williamwilliamfrom refcount import * # # very innocent example # a = A3() b1 = B(a) b2 = B.create(a) if a.ref_count() != 3: raise RuntimeError("Count = %d" % a.ref_count()) rca = b2.get_rca() b3 = B.create(rca) if a.ref_count() != 5: raise RuntimeError("Count = %d" % a.ref_count()) v = vector_A(2) v[0] = a v[1] = a x = v[0] del v if a.ref_count() != 6: raise RuntimeError("Count = %d" % a.ref_count()) # Check %newobject b4 = b2.cloner() if b4.ref_count() != 1: raise RuntimeError b5 = global_create(a) if b5.ref_count() != 1: raise RuntimeError b6 = Factory.create(a) if b6.ref_count() != 1: raise RuntimeError b7 = Factory().create2(a) if b7.ref_count() != 1: raise RuntimeError if a.ref_count() != 10: raise RuntimeError("Count = %d" % a.ref_count()) del b4 del b5 del b6 del b7 if a.ref_count() != 6: raise RuntimeError("Count = %d" % a.ref_count()) swig-3.0.2/Examples/test-suite/python/python_overload_simple_cast_runme.py0000664000175000017500000001001312343605122027122 0ustar williamwilliamfrom python_overload_simple_cast import * class Ai: def __init__(self,x): self.x = x def __int__(self): return self.x class Ad: def __init__(self,x): self.x = x def __float__(self): return self.x ai = Ai(4) ad = Ad(5.0) add = Ad(5.5) try: fint(add) good = 0 except: good = 1 if not good: raise RuntimeError, "fint(int)" if fint(ad) != "fint:int": raise RuntimeError, "fint(int)" if fdouble(ad) != "fdouble:double": raise RuntimeError, "fdouble(double)" if fint(ai) != "fint:int": raise RuntimeError, "fint(int)" if fint(5.0) != "fint:int": raise RuntimeError, "fint(int)" if fint(3) != "fint:int": raise RuntimeError, "fint(int)" if fint(3.0) != "fint:int": raise RuntimeError, "fint(int)" if fdouble(ad) != "fdouble:double": raise RuntimeError, "fdouble(double)" if fdouble(3) != "fdouble:double": raise RuntimeError, "fdouble(double)" if fdouble(3.0) != "fdouble:double": raise RuntimeError, "fdouble(double)" if fid(3,3.0) != "fid:intdouble": raise RuntimeError, "fid:intdouble" if fid(3.0,3) != "fid:doubleint": raise RuntimeError, "fid:doubleint" if fid(ad,ai) != "fid:doubleint": raise RuntimeError, "fid:doubleint" if fid(ai,ad) != "fid:intdouble": raise RuntimeError, "fid:intdouble" if foo(3) != "foo:int": raise RuntimeError, "foo(int)" if foo(3.0) != "foo:double": raise RuntimeError, "foo(double)" if foo("hello") != "foo:char *": raise RuntimeError, "foo(char *)" f = Foo() b = Bar() if foo(f) != "foo:Foo *": raise RuntimeError, "foo(Foo *)" if foo(b) != "foo:Bar *": raise RuntimeError, "foo(Bar *)" v = malloc_void(32) if foo(v) != "foo:void *": raise RuntimeError, "foo(void *)" s = Spam() if s.foo(3) != "foo:int": raise RuntimeError, "Spam::foo(int)" if s.foo(3.0) != "foo:double": raise RuntimeError, "Spam::foo(double)" if s.foo("hello") != "foo:char *": raise RuntimeError, "Spam::foo(char *)" if s.foo(f) != "foo:Foo *": raise RuntimeError, "Spam::foo(Foo *)" if s.foo(b) != "foo:Bar *": raise RuntimeError, "Spam::foo(Bar *)" if s.foo(v) != "foo:void *": raise RuntimeError, "Spam::foo(void *)" if Spam_bar(3) != "bar:int": raise RuntimeError, "Spam::bar(int)" if Spam_bar(3.0) != "bar:double": raise RuntimeError, "Spam::bar(double)" if Spam_bar("hello") != "bar:char *": raise RuntimeError, "Spam::bar(char *)" if Spam_bar(f) != "bar:Foo *": raise RuntimeError, "Spam::bar(Foo *)" if Spam_bar(b) != "bar:Bar *": raise RuntimeError, "Spam::bar(Bar *)" if Spam_bar(v) != "bar:void *": raise RuntimeError, "Spam::bar(void *)" # Test constructors s = Spam() if s.type != "none": raise RuntimeError, "Spam()" s = Spam(3) if s.type != "int": raise RuntimeError, "Spam(int)" s = Spam(3.4) if s.type != "double": raise RuntimeError, "Spam(double)" s = Spam("hello") if s.type != "char *": raise RuntimeError, "Spam(char *)" s = Spam(f) if s.type != "Foo *": raise RuntimeError, "Spam(Foo *)" s = Spam(b) if s.type != "Bar *": raise RuntimeError, "Spam(Bar *)" s = Spam(v) if s.type != "void *": raise RuntimeError, "Spam(void *)" # unsigned long long ullmax = 9223372036854775807 #0xffffffffffffffff ullmaxd = 9007199254740992.0 ullmin = 0 ullmind = 0.0 if ull(ullmin) != ullmin: raise runtimeerror, "ull(ullmin)" if ull(ullmax) != ullmax: raise runtimeerror, "ull(ullmax)" if ull(ullmind) != ullmind: raise RuntimeError, "ull(ullmind)" if ull(ullmaxd) != ullmaxd: raise RuntimeError, "ull(ullmaxd)" # long long llmax = 9223372036854775807 #0x7fffffffffffffff llmin = -9223372036854775808 # these are near the largest floats we can still convert into long long llmaxd = 9007199254740992.0 llmind = -9007199254740992.0 if ll(llmin) != llmin: raise runtimeerror, "ll(llmin)" if ll(llmax) != llmax: raise runtimeerror, "ll(llmax)" if ll(llmind) != llmind: raise RuntimeError, "ll(llmind)" if ll(llmaxd) != llmaxd: raise RuntimeError, "ll(llmaxd)" free_void(v) swig-3.0.2/Examples/test-suite/python/li_std_wstream_runme.py0000664000175000017500000000031312343605122024345 0ustar williamwilliamfrom li_std_wstream import * a = A() o = wostringstream() o << a << u" " << 2345 << u" " << 1.435 << wends if o.str() != "A class 2345 1.435\0": print "\"%s\"" % (o.str(),) raise RuntimeError swig-3.0.2/Examples/test-suite/python/preproc_runme.py0000664000175000017500000000032112343605122022776 0ustar williamwilliamimport preproc if preproc.endif != 1: raise RuntimeError if preproc.define != 1: raise RuntimeError if preproc.defined != 1: raise RuntimeError if 2*preproc.one != preproc.two: raise RuntimeError swig-3.0.2/Examples/test-suite/python/swigobject_runme.py0000664000175000017500000000117612343605122023475 0ustar williamwilliam from swigobject import * a = A() a1 = a_ptr(a) a2 = a_ptr(a) if a1.this != a2.this: raise RuntimeError lthis = long(a.this) # match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p xstr1 = "%016X" % (lthis,) xstr1 = str.lstrip(xstr1, '0') xstr2 = pointer_str(a) xstr2 = str.replace(xstr2, "0x", "") xstr2 = str.replace(xstr2, "0X", "") xstr2 = str.lstrip(xstr2, '0') xstr2 = str.upper(xstr2) if xstr1 != xstr2: print xstr1, xstr2 raise RuntimeError s = str(a.this) r = repr(a.this) v1 = v_ptr(a) v2 = v_ptr(a) if long(v1) != long(v2): raise RuntimeError swig-3.0.2/Examples/test-suite/python/hugemod.pl0000664000175000017500000000237712343605122021546 0ustar williamwilliam#!/usr/bin/perl use strict; my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod my $runme = shift @ARGV; open HEADER, ">hugemod.h" or die "error"; open TEST, ">$runme" or die "error"; open I1, ">hugemod_a.i" or die "error"; open I2, ">hugemod_b.i" or die "error"; print TEST "import hugemod_a\n"; print TEST "import hugemod_b\n"; print I1 "\%module hugemod_a;\n"; print I1 "\%include \"hugemod.h\";\n"; print I1 "\%{ #include \"hugemod.h\" \%}\n"; print I2 "\%module hugemod_b;\n"; print I2 "\%import \"hugemod.h\";\n"; print I2 "\%{ #include \"hugemod.h\" \%}\n"; print I2 "\%inline \%{\n"; my $i; for ($i = 0; $i < $modsize; $i++) { my $t = $i * 4; print HEADER "class type$i { public: int a; };\n"; print I2 "class dtype$i : public type$i { public: int b; };\n"; print TEST "c = hugemod_a.type$i()\n"; print TEST "c.a = $t\n"; print TEST "if c.a != $t:\n"; print TEST " raise RuntimeError\n"; print TEST "c = hugemod_b.dtype$i()\n"; print TEST "c.a = $t\n"; print TEST "if c.a != $t:\n"; print TEST " raise RuntimeError\n"; $t = -$t; print TEST "c.b = $t\n"; print TEST "if c.b != $t:\n"; print TEST " raise RuntimeError\n\n"; } print I2 "\%}\n"; close HEADER; close TEST; close I1; close I2; swig-3.0.2/Examples/test-suite/python/typemap_ns_using_runme.py0000664000175000017500000000012412343605122024711 0ustar williamwilliamimport typemap_ns_using if typemap_ns_using.spam(37) != 37: raise RuntimeError swig-3.0.2/Examples/test-suite/python/struct_initialization_runme.py0000664000175000017500000000051712343605122025766 0ustar williamwilliamfrom struct_initialization import * if cvar.instanceC1.x != 10: raise RuntimeError if cvar.instanceD1.x != 10: raise RuntimeError if cvar.instanceD2.x != 20: raise RuntimeError if cvar.instanceD3.x != 30: raise RuntimeError if cvar.instanceE1.x != 1: raise RuntimeError if cvar.instanceF1.x != 1: raise RuntimeError swig-3.0.2/Examples/test-suite/python/python_append_runme.py0000664000175000017500000000030612343605122024177 0ustar williamwilliamfrom python_append import * t=Test() t.func() t.static_func() if grabpath() != os.path.dirname(mypath): raise RuntimeError if grabstaticpath() != os.path.basename(mypath): raise RuntimeError swig-3.0.2/Examples/test-suite/python/pointer_reference_runme.py0000664000175000017500000000070512343605122025030 0ustar williamwilliamimport pointer_reference s = pointer_reference.get() if s.value != 10: raise RuntimeError, "get test failed" ss = pointer_reference.Struct(20) pointer_reference.set(ss) if pointer_reference.cvar.Struct_instance.value != 20: raise RuntimeError, "set test failed" if pointer_reference.overloading(1) != 111: raise RuntimeError, "overload test 1 failed" if pointer_reference.overloading(ss) != 222: raise RuntimeError, "overload test 2 failed" swig-3.0.2/Examples/test-suite/python/namespace_typemap_runme.py0000664000175000017500000000244412343605122025027 0ustar williamwilliamfrom namespace_typemap import * if stest1("hello") != "hello": raise RuntimeError if stest2("hello") != "hello": raise RuntimeError if stest3("hello") != "hello": raise RuntimeError if stest4("hello") != "hello": raise RuntimeError if stest5("hello") != "hello": raise RuntimeError if stest6("hello") != "hello": raise RuntimeError if stest7("hello") != "hello": raise RuntimeError if stest8("hello") != "hello": raise RuntimeError if stest9("hello") != "hello": raise RuntimeError if stest10("hello") != "hello": raise RuntimeError if stest11("hello") != "hello": raise RuntimeError if stest12("hello") != "hello": raise RuntimeError c = complex(2,3) r = c.real if ctest1(c) != r: raise RuntimeError if ctest2(c) != r: raise RuntimeError if ctest3(c) != r: raise RuntimeError if ctest4(c) != r: raise RuntimeError if ctest5(c) != r: raise RuntimeError if ctest6(c) != r: raise RuntimeError if ctest7(c) != r: raise RuntimeError if ctest8(c) != r: raise RuntimeError if ctest9(c) != r: raise RuntimeError if ctest10(c) != r: raise RuntimeError if ctest11(c) != r: raise RuntimeError if ctest12(c) != r: raise RuntimeError try: ttest1(-14) raise RuntimeError except ValueError: pass swig-3.0.2/Examples/test-suite/python/complextest_runme.py0000664000175000017500000000046412343605122023703 0ustar williamwilliamimport complextest a = complex(-1,2) if complextest.Conj(a) != a.conjugate(): raise RuntimeError, "bad complex mapping" if complextest.Conjf(a) != a.conjugate(): raise RuntimeError, "bad complex mapping" v = (complex(1,2), complex(2,3), complex(4,3), 1) try: complextest.Copy_h(v) except: pass swig-3.0.2/Examples/test-suite/python/enums_runme.py0000664000175000017500000000041212343605122022454 0ustar williamwilliam import _enums _enums.bar2(1) _enums.bar3(1) _enums.bar1(1) if _enums.cvar.enumInstance != 2: raise RuntimeError if _enums.cvar.Slap != 10: raise RuntimeError if _enums.cvar.Mine != 11: raise RuntimeError if _enums.cvar.Thigh != 12: raise RuntimeError swig-3.0.2/Examples/test-suite/python/std_containers_runme.py0000664000175000017500000000400112343605122024342 0ustar williamwilliamimport sys import std_containers cube = (((1, 2), (3, 4)), ((5, 6), (7, 8))) icube = std_containers.cident(cube) for i in range(0,len(cube)): if cube[i] != icube[i]: raise RuntimeError, "bad cident" p = (1,2) if p != std_containers.pident(p): raise RuntimeError, "bad pident" v = (1,2,3,4,5,6) iv = std_containers.vident(v) for i in range(0,len(v)): if v[i] != iv[i]: raise RuntimeError, "bad vident" iv = std_containers.videntu(v) for i in range(0,len(v)): if v[i] != iv[i]: raise RuntimeError, "bad videntu" vu = std_containers.vector_ui(v) if vu[2] != std_containers.videntu(vu)[2]: raise RuntimeError, "bad videntu" if v[0:3][1] != vu[0:3][1]: print v[0:3][1], vu[0:3][1] raise RuntimeError, "bad getslice" m = ((1,2,3),(2,3),(3,4)) im = std_containers.midenti(m) for i in range(0,len(m)): for j in range(0,len(m[i])): if m[i][j] != im[i][j]: raise RuntimeError, "bad getslice" m = ((True,False,True),(True,True),(True,True)) im = std_containers.midentb(m) for i in range(0,len(m)): for j in range(0,len(m[i])): if m[i][j] != im[i][j]: raise RuntimeError, "bad getslice" mi = std_containers.imatrix(m) mc = std_containers.cmatrix(m) if mi[0][1] != mc[0][1]: raise RuntimeError, "bad matrix" map ={} map['hello'] = 1 map['hi'] = 2 map['3'] = 2 imap = std_containers.mapident(map) for k in map: if map[k] != imap[k]: raise RuntimeError, "bad map" mapc ={} c1 = std_containers.C() c2 = std_containers.C() mapc[1] = c1.this mapc[2] = c2 std_containers.mapidentc(mapc) vi = std_containers.vector_i((2,2,3,4)) v = (1,2) v1 = std_containers.v_inout(vi) vi[1], v1[1] v1,v2 = ((1,2),(3,4)) v1,v2 = std_containers.v_inout2(v1,v2) a1 = std_containers.A(1) a2 = std_containers.A(2) p1 = (1,a1) p2 = (2,a2) v = (p1,p2) v2= std_containers.pia_vident(v) v2[0][1].a v2[1][1].a v3 = std_containers.vector_piA(v2) v3[0][1].a v3[1][1].a s = std_containers.set_i() s.append(1) s.append(2) s.append(3) j=1 for i in s: if i != j: raise RuntimeError j = j + 1 swig-3.0.2/Examples/test-suite/python/li_attribute_runme.py0000664000175000017500000000315312343605122024021 0ustar williamwilliam# Ported to C# li_attribute_runme.cs import li_attribute aa = li_attribute.A(1,2,3) if aa.a != 1: raise RuntimeError aa.a = 3 if aa.a != 3: print aa.a raise RuntimeError if aa.b != 2: print aa.b raise RuntimeError aa.b = 5 if aa.b != 5: raise RuntimeError if aa.d != aa.b: raise RuntimeError if aa.c != 3: raise RuntimeError #aa.c = 5 #if aa.c != 3: # raise RuntimeError pi = li_attribute.Param_i(7) if pi.value != 7: raise RuntimeError pi.value=3 if pi.value != 3: raise RuntimeError b = li_attribute.B(aa) if b.a.c != 3: raise RuntimeError # class/struct attribute with get/set methods using return/pass by reference myFoo = li_attribute.MyFoo() myFoo.x = 8 myClass = li_attribute.MyClass() myClass.Foo = myFoo if myClass.Foo.x != 8: raise RuntimeError # class/struct attribute with get/set methods using return/pass by value myClassVal = li_attribute.MyClassVal() if myClassVal.ReadWriteFoo.x != -1: raise RuntimeError if myClassVal.ReadOnlyFoo.x != -1: raise RuntimeError myClassVal.ReadWriteFoo = myFoo if myClassVal.ReadWriteFoo.x != 8: raise RuntimeError if myClassVal.ReadOnlyFoo.x != 8: raise RuntimeError # string attribute with get/set methods using return/pass by value myStringyClass = li_attribute.MyStringyClass("initial string") if myStringyClass.ReadWriteString != "initial string": raise RuntimeError if myStringyClass.ReadOnlyString != "initial string": raise RuntimeError myStringyClass.ReadWriteString = "changed string" if myStringyClass.ReadWriteString != "changed string": raise RuntimeError if myStringyClass.ReadOnlyString != "changed string": raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_typemaps_typedef2_runme.py0000664000175000017500000000206412343605122026671 0ustar williamwilliamfrom template_typemaps_typedef2 import * m1 = MultimapIntA() dummy_pair = m1.make_dummy_pair() val = m1.typemap_test(dummy_pair).val if val != 1234: raise RuntimeError, "typemaps not working" m2 = MultimapAInt() # TODO: typemaps and specializations not quite working as expected. T needs expanding, but at least the right typemap is being picked up. #dummy_pair = m2.make_dummy_pair() #val = m2.typemap_test(dummy_pair) #print val #if val != 4321: # raise RuntimeError, "typemaps not working" if typedef_test1(dummy_pair).val != 1234: raise RuntimeError, "typedef_test1 not working" if typedef_test2(dummy_pair).val != 1234: raise RuntimeError, "typedef_test2 not working" if typedef_test3(dummy_pair).val != 1234: raise RuntimeError, "typedef_test3 not working" if typedef_test4(dummy_pair).val != 1234: raise RuntimeError, "typedef_test4 not working" if typedef_test5(dummy_pair).val != 1234: raise RuntimeError, "typedef_test5 not working" if typedef_test6(dummy_pair).val != 1234: raise RuntimeError, "typedef_test6 not working" swig-3.0.2/Examples/test-suite/python/director_protected_runme.py0000664000175000017500000000430512343605122025216 0ustar williamwilliamfrom director_protected import * class FooBar(Bar): def ping(self): return "FooBar::ping();" class FooBar2(Bar): def ping(self): return "FooBar2::ping();" def pang(self): return "FooBar2::pang();" class FooBar3(Bar): def cheer(self): return "FooBar3::cheer();" b = Bar() f = b.create() fb = FooBar() fb2 = FooBar2() fb3 = FooBar3() try: s = fb.used() if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();": raise RuntimeError pass except: raise RuntimeError, "bad FooBar::used" try: s = fb2.used() if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();": raise RuntimeError pass except: raise RuntimeError, "bad FooBar2::used" try: s = b.pong() if s != "Bar::pong();Foo::pong();Bar::ping();": raise RuntimeError pass except: raise RuntimeError, "bad Bar::pong" try: s = f.pong() if s != "Bar::pong();Foo::pong();Bar::ping();": raise RuntimeError pass except: raise RuntimeError," bad Foo::pong" try: s = fb.pong() if s != "Bar::pong();Foo::pong();FooBar::ping();": raise RuntimeError pass except: raise RuntimeError," bad FooBar::pong" protected=1 try: b.ping() protected=0 except: pass if not protected: raise RuntimeError,"Foo::ping is protected" protected=1 try: f.ping() protected=0 except: pass if not protected: raise RuntimeError,"Foo::ping is protected" protected=1 try: f.pang() protected=0 except: pass if not protected: raise RuntimeError,"FooBar::pang is protected" protected=1 try: b.cheer() protected=0 except: pass if not protected: raise RuntimeError,"Bar::cheer is protected" protected=1 try: f.cheer() protected=0 except: pass if not protected: raise RuntimeError,"Foo::cheer is protected" if fb3.cheer() != "FooBar3::cheer();": raise RuntimeError, "bad fb3::cheer" if fb2.callping() != "FooBar2::ping();": raise RuntimeError, "bad fb2.callping" if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();": raise RuntimeError, "bad fb2.callcheer" if fb3.callping() != "Bar::ping();": raise RuntimeError, "bad fb3.callping" if fb3.callcheer() != "FooBar3::cheer();": raise RuntimeError, "bad fb3.callcheer" swig-3.0.2/Examples/test-suite/python/director_abstract_runme.py0000664000175000017500000000227112343605122025030 0ustar williamwilliamimport director_abstract class MyFoo(director_abstract.Foo): def __init__(self): director_abstract.Foo.__init__(self) def ping(self): return "MyFoo::ping()" a = MyFoo() if a.ping() != "MyFoo::ping()": raise RuntimeError, a.ping() if a.pong() != "Foo::pong();MyFoo::ping()": raise RuntimeError, a.pong() class MyExample1(director_abstract.Example1): def Color(self, r, g, b): return r class MyExample2(director_abstract.Example2): def Color(self, r, g, b): return g class MyExample3(director_abstract.Example3_i): def Color(self, r, g, b): return b me1 = MyExample1() if director_abstract.Example1_get_color(me1, 1,2,3) != 1: raise RuntimeError me2 = MyExample2(1,2) if MyExample2.get_color(me2, 1,2,3) != 2: raise RuntimeError me3 = MyExample3() if MyExample3.get_color(me3, 1,2,3) != 3: raise RuntimeError error = 1 try: me1 = director_abstract.Example1() except: error = 0 if (error): raise RuntimeError error = 1 try: me2 = director_abstract.Example2() except: error = 0 if (error): raise RuntimeError error = 1 try: me3 = director_abstract.Example3_i() except: error = 0 if (error): raise RuntimeError try: f = director_abstract.A.f except: raise RuntimeError swig-3.0.2/Examples/test-suite/python/smart_pointer_overload_runme.py0000664000175000017500000000051412343605122026111 0ustar williamwilliamfrom smart_pointer_overload import * f = Foo() b = Bar(f) if f.test(3) != 1: raise RuntimeError if f.test(3.5) != 2: raise RuntimeError if f.test("hello") != 3: raise RuntimeError if b.test(3) != 1: raise RuntimeError if b.test(3.5) != 2: raise RuntimeError if b.test("hello") != 3: raise RuntimeError swig-3.0.2/Examples/test-suite/python/default_arg_values_runme.py0000664000175000017500000000035712343605122025171 0ustar williamwilliamfrom default_arg_values import * d = Display() if d.draw1() != 0: raise RuntimeError if d.draw1(12) != 12: raise RuntimeError p = createPtr(123); if d.draw2() != 0: raise RuntimeError if d.draw2(p) != 123: raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_factory_runme.py0000664000175000017500000000033712343605122023466 0ustar williamwilliamfrom li_factory import * circle = Geometry_create(Geometry.CIRCLE) r = circle.radius() if (r != 1.5): raise RuntimeError point = Geometry_create(Geometry.POINT) w = point.width() if (w != 1.0): raise RuntimeError swig-3.0.2/Examples/test-suite/python/ret_by_value_runme.py0000664000175000017500000000021012343605122024001 0ustar williamwilliamimport ret_by_value a = ret_by_value.get_test() if a.myInt != 100: raise RuntimeError if a.myShort != 200: raise RuntimeError swig-3.0.2/Examples/test-suite/python/funcptr_cpp_runme.py0000664000175000017500000000032312343605122023651 0ustar williamwilliamfrom funcptr_cpp import * if call1(ADD_BY_VALUE, 10, 11) != 21: raise RuntimeError if call2(ADD_BY_POINTER, 12, 13) != 25: raise RuntimeError if call3(ADD_BY_REFERENCE, 14, 15) != 29: raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_inherit_runme.py0000664000175000017500000000155712343605122024675 0ustar williamwilliamfrom template_inherit import * a = FooInt() b = FooDouble() c = BarInt() d = BarDouble() e = FooUInt() f = BarUInt() if a.blah() != "Foo": raise ValueError if b.blah() != "Foo": raise ValueError if e.blah() != "Foo": raise ValueError if c.blah() != "Bar": raise ValueError if d.blah() != "Bar": raise ValueError if f.blah() != "Bar": raise ValueError if c.foomethod() != "foomethod": raise ValueError if d.foomethod() != "foomethod": raise ValueError if f.foomethod() != "foomethod": raise ValueError if invoke_blah_int(a) != "Foo": raise ValueError if invoke_blah_int(c) != "Bar": raise ValueError if invoke_blah_double(b) != "Foo": raise ValueError if invoke_blah_double(d) != "Bar": raise ValueError if invoke_blah_uint(e) != "Foo": raise ValueError if invoke_blah_uint(f) != "Bar": raise ValueError swig-3.0.2/Examples/test-suite/python/using_protected_runme.py0000664000175000017500000000015412343605122024526 0ustar williamwilliamfrom using_protected import * f = FooBar() f.x = 3 if f.blah(4) != 4: raise RuntimeError, "blah(int)" swig-3.0.2/Examples/test-suite/python/director_wstring_runme.py0000664000175000017500000000065212343605122024723 0ustar williamwilliamfrom director_wstring import * class B(A): def __init__(self,string): A.__init__(self,string) def get_first(self): return A.get_first(self) + u" world!" def process_text(self, string): self.smem = u"hello" b = B(u"hello") b.get(0) if b.get_first() != u"hello world!": print b.get_first() raise RuntimeError b.call_process_func() if b.smem != u"hello": print smem raise RuntimeError swig-3.0.2/Examples/test-suite/python/fvirtual_runme.py0000664000175000017500000000016712343605122023170 0ustar williamwilliamfrom fvirtual import * sw = NodeSwitch() n = Node() i = sw.addChild(n); if i != 2: raise RuntimeError, "addChild" swig-3.0.2/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py0000664000175000017500000000027512343605122027154 0ustar williamwilliamfrom smart_pointer_multi_typedef import * f = Foo() b = Bar(f) s = Spam(b) g = Grok(b) s.x = 3 if s.getx() != 3: raise RuntimeError g.x = 4 if g.getx() != 4: raise RuntimeError swig-3.0.2/Examples/test-suite/python/overload_template_runme.py0000664000175000017500000000667412343605122025053 0ustar williamwilliamfrom overload_template import * f = foo() a = maximum(3,4) b = maximum(3.4,5.2) # mix 1 if (mix1("hi") != 101): raise RuntimeError, ("mix1(const char*)") if (mix1(1.0, 1.0) != 102): raise RuntimeError, ("mix1(double, const double &)") if (mix1(1.0) != 103): raise RuntimeError, ("mix1(double)") # mix 2 if (mix2("hi") != 101): raise RuntimeError, ("mix2(const char*)") if (mix2(1.0, 1.0) != 102): raise RuntimeError, ("mix2(double, const double &)") if (mix2(1.0) != 103): raise RuntimeError, ("mix2(double)") # mix 3 if (mix3("hi") != 101): raise RuntimeError, ("mix3(const char*)") if (mix3(1.0, 1.0) != 102): raise RuntimeError, ("mix3(double, const double &)") if (mix3(1.0) != 103): raise RuntimeError, ("mix3(double)") # Combination 1 if (overtparams1(100) != 10): raise RuntimeError, ("overtparams1(int)") if (overtparams1(100.0, 100) != 20): raise RuntimeError, ("overtparams1(double, int)") # Combination 2 if (overtparams2(100.0, 100) != 40): raise RuntimeError, ("overtparams2(double, int)") # Combination 3 if (overloaded() != 60): raise RuntimeError, ("overloaded()") if (overloaded(100.0, 100) != 70): raise RuntimeError, ("overloaded(double, int)") # Combination 4 if (overloadedagain("hello") != 80): raise RuntimeError, ("overloadedagain(const char *)") if (overloadedagain() != 90): raise RuntimeError, ("overloadedagain(double)") # specializations if (specialization(10) != 202): raise RuntimeError, ("specialization(int)") if (specialization(10.0) != 203): raise RuntimeError, ("specialization(double)") if (specialization(10, 10) != 204): raise RuntimeError, ("specialization(int, int)") if (specialization(10.0, 10.0) != 205): raise RuntimeError, ("specialization(double, double)") if (specialization("hi", "hi") != 201): raise RuntimeError, ("specialization(const char *, const char *)") # simple specialization xyz() xyz_int() xyz_double() # a bit of everything if (overload("hi") != 0): raise RuntimeError, ("overload()") if (overload(1) != 10): raise RuntimeError, ("overload(int t)") if (overload(1, 1) != 20): raise RuntimeError, ("overload(int t, const int &)") if (overload(1, "hello") != 30): raise RuntimeError, ("overload(int t, const char *)") k = Klass() if (overload(k) != 10): raise RuntimeError, ("overload(Klass t)") if (overload(k, k) != 20): raise RuntimeError, ("overload(Klass t, const Klass &)") if (overload(k, "hello") != 30): raise RuntimeError, ("overload(Klass t, const char *)") if (overload(10.0, "hi") != 40): raise RuntimeError, ("overload(double t, const char *)") if (overload() != 50): raise RuntimeError, ("overload(const char *)") # everything put in a namespace if (nsoverload("hi") != 1000): raise RuntimeError, ("nsoverload()") if (nsoverload(1) != 1010): raise RuntimeError, ("nsoverload(int t)") if (nsoverload(1, 1) != 1020): raise RuntimeError, ("nsoverload(int t, const int &)") if (nsoverload(1, "hello") != 1030): raise RuntimeError, ("nsoverload(int t, const char *)") if (nsoverload(k) != 1010): raise RuntimeError, ("nsoverload(Klass t)") if (nsoverload(k, k) != 1020): raise RuntimeError, ("nsoverload(Klass t, const Klass &)") if (nsoverload(k, "hello") != 1030): raise RuntimeError, ("nsoverload(Klass t, const char *)") if (nsoverload(10.0, "hi") != 1040): raise RuntimeError, ("nsoverload(double t, const char *)") if (nsoverload() != 1050): raise RuntimeError, ("nsoverload(const char *)") A_foo(1) b = B() b.foo(1) swig-3.0.2/Examples/test-suite/python/struct_value_runme.py0000664000175000017500000000020612343605122024046 0ustar williamwilliamimport struct_value b = struct_value.Bar() b.a.x = 3 if b.a.x != 3: raise RuntimeError b.b.x = 3 if b.b.x != 3: raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_std_string_extra_runme.py0000664000175000017500000000734712343605122025412 0ustar williamwilliamimport li_std_string_extra x="hello" if li_std_string_extra.test_ccvalue(x) != x: raise RuntimeError, "bad string mapping" if li_std_string_extra.test_cvalue(x) != x: raise RuntimeError, "bad string mapping" if li_std_string_extra.test_value(x) != x: print x, li_std_string_extra.test_value(x) raise RuntimeError, "bad string mapping" if li_std_string_extra.test_const_reference(x) != x: raise RuntimeError, "bad string mapping" s = li_std_string_extra.string("he") #s += "ll" #s.append('o') s = s + "llo" if s != x: print s, x raise RuntimeError, "bad string mapping" if s[1:4] != x[1:4]: raise RuntimeError, "bad string mapping" if li_std_string_extra.test_value(s) != x: raise RuntimeError, "bad string mapping" if li_std_string_extra.test_const_reference(s) != x: raise RuntimeError, "bad string mapping" a = li_std_string_extra.A(s) if li_std_string_extra.test_value(a) != x: raise RuntimeError, "bad string mapping" if li_std_string_extra.test_const_reference(a) != x: raise RuntimeError, "bad string mapping" b = li_std_string_extra.string(" world") s = a + b if a + b != "hello world": print a + b raise RuntimeError, "bad string mapping" if a + " world" != "hello world": raise RuntimeError, "bad string mapping" # This is expected to fail with -builtin option # Reverse operators not supported in builtin types if "hello" + b != "hello world": raise RuntimeError, "bad string mapping" # This is expected to fail with -builtin option # Reverse operators not supported in builtin types c = "hello" + b if c.find_last_of("l") != 9: raise RuntimeError, "bad string mapping" s = "hello world" b = li_std_string_extra.B("hi") b.name = li_std_string_extra.string("hello") if b.name != "hello": raise RuntimeError, "bad string mapping" b.a = li_std_string_extra.A("hello") if b.a != "hello": raise RuntimeError, "bad string mapping" if li_std_string_extra.test_value_basic1(x) != x: raise RuntimeError, "bad string mapping" if li_std_string_extra.test_value_basic2(x) != x: raise RuntimeError, "bad string mapping" if li_std_string_extra.test_value_basic3(x) != x: raise RuntimeError, "bad string mapping" # Global variables s = "initial string" if li_std_string_extra.cvar.GlobalString2 != "global string 2": raise RuntimeError, "GlobalString2 test 1" li_std_string_extra.cvar.GlobalString2 = s if li_std_string_extra.cvar.GlobalString2 != s: raise RuntimeError, "GlobalString2 test 2" if li_std_string_extra.cvar.ConstGlobalString != "const global string": raise RuntimeError, "ConstGlobalString test" # Member variables myStructure = li_std_string_extra.Structure() if myStructure.MemberString2 != "member string 2": raise RuntimeError, "MemberString2 test 1" myStructure.MemberString2 = s if myStructure.MemberString2 != s: raise RuntimeError, "MemberString2 test 2" if myStructure.ConstMemberString != "const member string": raise RuntimeError, "ConstMemberString test" if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2": raise RuntimeError, "StaticMemberString2 test 1" li_std_string_extra.cvar.Structure_StaticMemberString2 = s if li_std_string_extra.cvar.Structure_StaticMemberString2 != s: raise RuntimeError, "StaticMemberString2 test 2" if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string": raise RuntimeError, "ConstStaticMemberString test" if li_std_string_extra.test_reference_input("hello") != "hello": raise RuntimeError s = li_std_string_extra.test_reference_inout("hello") if s != "hellohello": raise RuntimeError if li_std_string_extra.stdstring_empty() != "": raise RuntimeError if li_std_string_extra.c_empty() != "": raise RuntimeError if li_std_string_extra.c_null() != None: raise RuntimeError swig-3.0.2/Examples/test-suite/python/typemap_out_optimal_runme.py0000664000175000017500000000011212343605122025415 0ustar williamwilliamfrom typemap_out_optimal import * cvar.XX_debug = False x = XX.create() swig-3.0.2/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py0000664000175000017500000000077612343605122026771 0ustar williamwilliamimport cpp11_null_pointer_constant a = cpp11_null_pointer_constant.A() if a._myA != None: raise RuntimeError, ("cpp11_null_pointer_constant: _myA should be None, but is ", a._myA) b = cpp11_null_pointer_constant.A() if a._myA != b._myA: raise RuntimeError, ("cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA) a._myA = cpp11_null_pointer_constant.A() if a._myA == None: raise RuntimeError, ("cpp11_null_pointer_constant: _myA should be object, but is None") swig-3.0.2/Examples/test-suite/python/cpp11_rvalue_reference_runme.py0000664000175000017500000000122312343605122025646 0ustar williamwilliamimport cpp11_rvalue_reference a = cpp11_rvalue_reference.A() a.setAcopy(5) if a.getAcopy() != 5: raise RunTimeError, ("int A::getAcopy() value is ", a.getAcopy(), " should be 5") ptr = a.getAptr() a.setAptr(ptr) if a.getAcopy() != 5: raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(), " should be 5") a.setAref(ptr) if a.getAcopy() != 5: raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(), " should be 5") rvalueref = a.getAmove() a.setAmove(rvalueref) if a.getAcopy() != 5: raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(), " should be 5") swig-3.0.2/Examples/test-suite/python/global_functions_runme.py0000664000175000017500000000153112343605122024660 0ustar williamwilliamfrom global_functions import * def check(a, b): if a != b: raise RuntimeError("Failed: " + str(a) + " != " + str(b)) global_void() check(global_one(1), 1) check(global_two(2, 2), 4) fail = True try: global_void(1) except TypeError, e: fail = False if fail: raise RuntimeError("argument count check failed") fail = True try: global_one() except TypeError, e: fail = False if fail: raise RuntimeError("argument count check failed") fail = True try: global_one(2, 2) except TypeError, e: fail = False if fail: raise RuntimeError("argument count check failed") fail = True try: global_two(1) except TypeError, e: fail = False if fail: raise RuntimeError("argument count check failed") fail = True try: global_two(3, 3, 3) except TypeError, e: fail = False if fail: raise RuntimeError("argument count check failed") swig-3.0.2/Examples/test-suite/python/rename_scope_runme.py0000664000175000017500000000024012343605122023764 0ustar williamwilliamfrom rename_scope import * a = Natural_UP() b = Natural_BP() if a.rtest() != 1: raise RuntimeError if b.rtest() != 1: raise RuntimeError f = equals swig-3.0.2/Examples/test-suite/python/overload_numeric_runme.py0000664000175000017500000000242212343605122024665 0ustar williamwilliam from overload_numeric import * import math nums = Nums() limits = Limits() def check(got, expected): if got != expected: raise RuntimeError("got: " + got + " expected: " + expected) check(nums.over(0), "signed char") check(nums.over(0.0), "float") check(nums.over(limits.schar_min()), "signed char") check(nums.over(limits.schar_max()), "signed char") check(nums.over(limits.schar_min()-1), "short") check(nums.over(limits.schar_max()+1), "short") check(nums.over(limits.shrt_min()), "short") check(nums.over(limits.shrt_max()), "short") check(nums.over(limits.shrt_min()-1), "int") check(nums.over(limits.shrt_max()+1), "int") check(nums.over(limits.int_min()), "int") check(nums.over(limits.int_max()), "int") check(nums.over(limits.flt_min()), "float") check(nums.over(limits.flt_max()), "float") check(nums.over(limits.flt_max()*10), "double") check(nums.over(-limits.flt_max()*10), "double") check(nums.over(limits.dbl_max()), "double") check(nums.over(-limits.dbl_max()), "double") check(nums.over(float("inf")), "float") check(nums.over(float("-inf")), "float") check(nums.over(float("nan")), "float") # Just check if the following are accepted without exceptions being thrown nums.doublebounce(float("inf")) nums.doublebounce(float("-inf")) nums.doublebounce(float("nan")) swig-3.0.2/Examples/test-suite/python/template_typedef_cplx3_runme.py0000664000175000017500000000066312343605122026001 0ustar williamwilliamimport string from template_typedef_cplx3 import * # # this is OK # s = Sin() s.get_base_value() s.get_value() s.get_arith_value() my_func_r(s) make_Multiplies_double_double_double_double(s,s) z = CSin() z.get_base_value() z.get_value() z.get_arith_value() my_func_c(z) make_Multiplies_complex_complex_complex_complex(z,z) # # Here we fail # d = make_Identity_double() my_func_r(d) c = make_Identity_complex() my_func_c(c) swig-3.0.2/Examples/test-suite/python/template_typedef_cplx4_runme.py0000664000175000017500000000066312343605122026002 0ustar williamwilliamimport string from template_typedef_cplx4 import * # # this is OK # s = Sin() s.get_base_value() s.get_value() s.get_arith_value() my_func_r(s) make_Multiplies_double_double_double_double(s,s) z = CSin() z.get_base_value() z.get_value() z.get_arith_value() my_func_c(z) make_Multiplies_complex_complex_complex_complex(z,z) # # Here we fail # d = make_Identity_double() my_func_r(d) c = make_Identity_complex() my_func_c(c) swig-3.0.2/Examples/test-suite/python/sneaky1_runme.py0000664000175000017500000000015312343605122022702 0ustar williamwilliamimport sneaky1 x = sneaky1.add(3,4) y = sneaky1.subtract(3,4) z = sneaky1.mul(3,4) w = sneaky1.divide(3,4) swig-3.0.2/Examples/test-suite/python/typemap_namespace_runme.py0000664000175000017500000000021512343605122025021 0ustar williamwilliamfrom typemap_namespace import * if test1("hello") != "hello": raise RuntimeError if test2("hello") != "hello": raise RuntimeError swig-3.0.2/Examples/test-suite/python/inherit_missing_runme.py0000664000175000017500000000061212343605122024522 0ustar williamwilliamimport inherit_missing a = inherit_missing.new_Foo() b = inherit_missing.Bar() c = inherit_missing.Spam() x = inherit_missing.do_blah(a) if x != "Foo::blah": print "Whoa! Bad return", x x = inherit_missing.do_blah(b) if x != "Bar::blah": print "Whoa! Bad return", x x = inherit_missing.do_blah(c) if x != "Spam::blah": print "Whoa! Bad return", x inherit_missing.delete_Foo(a) swig-3.0.2/Examples/test-suite/python/li_cdata_runme.py0000664000175000017500000000017412343605122023072 0ustar williamwilliam from li_cdata import * s = "ABC abc" m = malloc(256) memmove(m, s) ss = cdata(m, 7) if ss != "ABC abc": raise "failed" swig-3.0.2/Examples/test-suite/python/wrapmacro_runme.py0000664000175000017500000000020012343605122023313 0ustar williamwilliamimport wrapmacro a = 2 b = -1 wrapmacro.maximum(a,b) wrapmacro.maximum(a/7.0, -b*256) wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1) swig-3.0.2/Examples/test-suite/python/template_typedef_import_runme.py0000664000175000017500000000071312343605122026256 0ustar williamwilliamfrom template_typedef_cplx2 import * from template_typedef_import import * # # this is OK # s = Sin() s.get_base_value() s.get_value() s.get_arith_value() my_func_r(s) make_Multiplies_double_double_double_double(s,s) z = CSin() z.get_base_value() z.get_value() z.get_arith_value() my_func_c(z) make_Multiplies_complex_complex_complex_complex(z,z) # # Here we fail # d = make_Identity_double() my_func_r(d) c = make_Identity_complex() my_func_c(c) swig-3.0.2/Examples/test-suite/python/extend_variable_runme.py0000664000175000017500000000011012343605122024454 0ustar williamwilliamfrom extend_variable import * if Foo.Bar != 42: raise RuntimeError swig-3.0.2/Examples/test-suite/python/smart_pointer_const_overload_runme.py0000664000175000017500000000405712343605122027325 0ustar williamwilliamfrom smart_pointer_const_overload import * CONST_ACCESS = 1 MUTABLE_ACCESS = 2 def test(b, f): if f.x != 0: raise RuntimeError # Test member variable get if b.x != 0: raise RuntimeError if f.access != CONST_ACCESS: raise RuntimeError # Test member variable set b.x = 1 if f.x != 1: raise RuntimeError if f.access != MUTABLE_ACCESS: raise RuntimeError # Test const method if b.getx() != 1: raise RuntimeError if f.access != CONST_ACCESS: raise RuntimeError # Test mutable method b.setx(2) if f.x != 2: raise RuntimeError if f.access != MUTABLE_ACCESS: raise RuntimeError # Test extended const method if b.getx2() != 2: raise RuntimeError if f.access != CONST_ACCESS: raise RuntimeError # Test extended mutable method b.setx2(3) if f.x != 3: raise RuntimeError if f.access != MUTABLE_ACCESS: raise RuntimeError # Test static method b.stat() if f.access != CONST_ACCESS: raise RuntimeError # Test const member f.access = MUTABLE_ACCESS if b.y != 0: raise RuntimeError if f.access != CONST_ACCESS: raise RuntimeError # Test get through mutable pointer to const member f.access = MUTABLE_ACCESS if get_int(b.yp) != 0: raise RuntimeError if f.access != CONST_ACCESS: raise RuntimeError # Test get through const pointer to mutable member f.x = 4 f.access = MUTABLE_ACCESS if get_int(b.xp) != 4: raise RuntimeError if f.access != CONST_ACCESS: raise RuntimeError # Test set through const pointer to mutable member f.access = MUTABLE_ACCESS set_int(b.xp, 5) if f.x != 5: raise RuntimeError if f.access != CONST_ACCESS: raise RuntimeError # Test set pointer to const member b.yp = new_int(6) if f.y != 0: raise RuntimeError if get_int(f.yp) != 6: raise RuntimeError if f.access != MUTABLE_ACCESS: raise RuntimeError delete_int(f.yp); f = Foo() b = Bar(f) f2 = Foo() b2 = Bar2(f2) test(b, f) test(b2, f2) swig-3.0.2/Examples/test-suite/python/typemap_qualifier_strip_runme.py0000664000175000017500000000231012343605122026265 0ustar williamwilliamimport typemap_qualifier_strip val = typemap_qualifier_strip.create_int(111) if typemap_qualifier_strip.testA1(val) != 1234: raise RuntimeError if typemap_qualifier_strip.testA2(val) != 1234: raise RuntimeError if typemap_qualifier_strip.testA3(val) != 1234: raise RuntimeError if typemap_qualifier_strip.testA4(val) != 1234: raise RuntimeError if typemap_qualifier_strip.testB1(val) != 111: raise RuntimeError if typemap_qualifier_strip.testB2(val) != 111: raise RuntimeError if typemap_qualifier_strip.testB3(val) != 111: raise RuntimeError if typemap_qualifier_strip.testB4(val) != 111: raise RuntimeError if typemap_qualifier_strip.testC1(val) != 5678: raise RuntimeError if typemap_qualifier_strip.testC2(val) != 111: raise RuntimeError if typemap_qualifier_strip.testC3(val) != 5678: raise RuntimeError if typemap_qualifier_strip.testC4(val) != 111: raise RuntimeError if typemap_qualifier_strip.testD1(val) != 111: raise RuntimeError if typemap_qualifier_strip.testD2(val) != 3456: raise RuntimeError if typemap_qualifier_strip.testD3(val) != 111: raise RuntimeError if typemap_qualifier_strip.testD4(val) != 111: raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_std_auto_ptr_runme.py0000664000175000017500000000057612343605122024533 0ustar williamwilliamfrom li_std_auto_ptr import * k1 = makeKlassAutoPtr("first") k2 = makeKlassAutoPtr("second") if Klass.getTotal_count() != 2: raise "number of objects should be 2" del k1 if Klass.getTotal_count() != 1: raise "number of objects should be 1" if k2.getLabel() != "second": raise "wrong object label" del k2 if Klass.getTotal_count() != 0: raise "no objects should be left" swig-3.0.2/Examples/test-suite/python/cpp_enum_runme.py0000664000175000017500000000055212343605122023140 0ustar williamwilliamimport cpp_enum f = cpp_enum.Foo() if f.hola != f.Hello: print f.hola raise RuntimeError f.hola = f.Hi if f.hola != f.Hi: print f.hola raise RuntimeError f.hola = f.Hello if f.hola != f.Hello: print f.hola raise RuntimeError cpp_enum.cvar.hi = cpp_enum.Hello if cpp_enum.cvar.hi != cpp_enum.Hello: print cpp_enum.cvar.hi raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_default_arg_runme.py0000664000175000017500000000544212343605122025505 0ustar williamwilliamimport template_default_arg helloInt = template_default_arg.Hello_int() helloInt.foo(template_default_arg.Hello_int.hi) x = template_default_arg.X_int() if (x.meth(20.0, 200) != 200): raise RuntimeError, ("X_int test 1 failed") if (x.meth(20) != 20): raise RuntimeError, ("X_int test 2 failed") if (x.meth() != 0): raise RuntimeError, ("X_int test 3 failed") y = template_default_arg.Y_unsigned() if (y.meth(20.0, 200) != 200): raise RuntimeError, ("Y_unsigned test 1 failed") if (y.meth(20) != 20): raise RuntimeError, ("Y_unsigned test 2 failed") if (y.meth() != 0): raise RuntimeError, ("Y_unsigned test 3 failed") x = template_default_arg.X_longlong() x = template_default_arg.X_longlong(20.0) x = template_default_arg.X_longlong(20.0, 200L) x = template_default_arg.X_int() x = template_default_arg.X_int(20.0) x = template_default_arg.X_int(20.0, 200) x = template_default_arg.X_hello_unsigned() x = template_default_arg.X_hello_unsigned(20.0) x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int()) y = template_default_arg.Y_hello_unsigned() y.meth(20.0, template_default_arg.Hello_int()) y.meth(template_default_arg.Hello_int()) y.meth() fz = template_default_arg.Foo_Z_8() x = template_default_arg.X_Foo_Z_8() fzc = x.meth(fz) # Templated functions # plain function: int ott(Foo) if (template_default_arg.ott(template_default_arg.Foo_int()) != 30): raise RuntimeError, ("ott test 1 failed") # %template(ott) ott if (template_default_arg.ott() != 10): raise RuntimeError, ("ott test 2 failed") if (template_default_arg.ott(1) != 10): raise RuntimeError, ("ott test 3 failed") if (template_default_arg.ott(1, 1) != 10): raise RuntimeError, ("ott test 4 failed") if (template_default_arg.ott("hi") != 20): raise RuntimeError, ("ott test 5 failed") if (template_default_arg.ott("hi", 1) != 20): raise RuntimeError, ("ott test 6 failed") if (template_default_arg.ott("hi", 1, 1) != 20): raise RuntimeError, ("ott test 7 failed") # %template(ott) ott if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40): raise RuntimeError, ("ott test 8 failed") if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40): raise RuntimeError, ("ott test 9 failed") # %template(ott) ott if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50): raise RuntimeError, ("ott test 10 failed") if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50): raise RuntimeError, ("ott test 11 failed") # %template(ott) ott if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60): raise RuntimeError, ("ott test 12 failed") if (template_default_arg.ott(template_default_arg.Hello_int()) != 60): raise RuntimeError, ("ott test 13 failed") swig-3.0.2/Examples/test-suite/python/using_private_runme.py0000664000175000017500000000035712343605122024214 0ustar williamwilliamfrom using_private import * f = FooBar() f.x = 3 if f.blah(4) != 4: raise RuntimeError, "blah(int)" if f.defaulted() != -1: raise RuntimeError, "defaulted()" if f.defaulted(222) != 222: raise RuntimeError, "defaulted(222)" swig-3.0.2/Examples/test-suite/python/import_nomodule_runme.py0000664000175000017500000000014112343605122024540 0ustar williamwilliamfrom import_nomodule import * f = create_Foo() test1(f,42) delete_Foo(f) b = Bar() test1(b,37) swig-3.0.2/Examples/test-suite/python/template_ref_type_runme.py0000664000175000017500000000013412343605122025036 0ustar williamwilliamimport template_ref_type xr = template_ref_type.XC() y = template_ref_type.Y() y.find(xr) swig-3.0.2/Examples/test-suite/python/smart_pointer_templatevariables_runme.py0000664000175000017500000000044012343605122030000 0ustar williamwilliamfrom smart_pointer_templatevariables import * d = DiffImContainerPtr_D(create(1234, 5678)) if (d.id != 1234): raise RuntimeError #if (d.xyz != 5678): # raise RuntimeError d.id = 4321 #d.xyz = 8765 if (d.id != 4321): raise RuntimeError #if (d.xyz != 8765): # raise RuntimeError swig-3.0.2/Examples/test-suite/python/cpp11_result_of_runme.py0000664000175000017500000000057512343605122024345 0ustar williamwilliamimport cpp11_result_of result = cpp11_result_of.test_result(cpp11_result_of.SQUARE, 3.0) if result != 9.0: raise RuntimeError, "test_result(square, 3.0) is not 9.0. Got: " + str(result) result = cpp11_result_of.test_result_alternative1(cpp11_result_of.SQUARE, 3.0) if result != 9.0: raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(result) swig-3.0.2/Examples/test-suite/python/overload_bool_runme.py0000664000175000017500000000300212343605122024151 0ustar williamwilliamimport overload_bool # Overloading bool, int, string if overload_bool.overloaded(True) != "bool": raise RuntimeError("wrong!") if overload_bool.overloaded(False) != "bool": raise RuntimeError("wrong!") if overload_bool.overloaded(0) != "int": raise RuntimeError("wrong!") if overload_bool.overloaded(1) != "int": raise RuntimeError("wrong!") if overload_bool.overloaded(2) != "int": raise RuntimeError("wrong!") if overload_bool.overloaded("1234") != "string": raise RuntimeError("wrong!") # Test bool masquerading as int if overload_bool.intfunction(True) != "int": raise RuntimeError("wrong!") if overload_bool.intfunction(False) != "int": raise RuntimeError("wrong!") # Test int masquerading as bool # Not possible ############################################# # Overloading bool, int, string if overload_bool.overloaded_ref(True) != "bool": raise RuntimeError("wrong!") if overload_bool.overloaded_ref(False) != "bool": raise RuntimeError("wrong!") if overload_bool.overloaded_ref(0) != "int": raise RuntimeError("wrong!") if overload_bool.overloaded_ref(1) != "int": raise RuntimeError("wrong!") if overload_bool.overloaded_ref(2) != "int": raise RuntimeError("wrong!") if overload_bool.overloaded_ref("1234") != "string": raise RuntimeError("wrong!") # Test bool masquerading as int if overload_bool.intfunction_ref(True) != "int": raise RuntimeError("wrong!") if overload_bool.intfunction_ref(False) != "int": raise RuntimeError("wrong!") # Test int masquerading as bool # Not possible swig-3.0.2/Examples/test-suite/python/enum_forward_runme.py0000664000175000017500000000035012343605122024016 0ustar williamwilliamimport enum_forward f1 = enum_forward.get_enum1(); f1 = enum_forward.test_function1(f1); f2 = enum_forward.get_enum2(); f2 = enum_forward.test_function2(f2); f3 = enum_forward.get_enum3(); f3 = enum_forward.test_function3(f3); swig-3.0.2/Examples/test-suite/python/primitive_ref_runme.py0000664000175000017500000000117712343605122024202 0ustar williamwilliamfrom primitive_ref import * if ref_int(3) != 3: raise RuntimeError if ref_uint(3) != 3: raise RuntimeError if ref_short(3) != 3: raise RuntimeError if ref_ushort(3) != 3: raise RuntimeError if ref_long(3) != 3: raise RuntimeError if ref_ulong(3) != 3: raise RuntimeError if ref_schar(3) != 3: raise RuntimeError if ref_uchar(3) != 3: raise RuntimeError if ref_float(3.5) != 3.5: raise RuntimeError if ref_double(3.5) != 3.5: raise RuntimeError if ref_bool(True) != True: raise RuntimeError if ref_char('x') != 'x': raise RuntimeError if ref_over(0) != 0: raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_std_except_as_class_runme.py0000664000175000017500000000033112343605122026023 0ustar williamwilliamfrom li_std_except_as_class import * # std::domain_error hierarchy try: test_domain_error() except domain_error: pass try: test_domain_error() except logic_error: pass try: test_domain_error() except exception: pass swig-3.0.2/Examples/test-suite/python/argcargvtest_runme.py0000664000175000017500000000073312343605122024027 0ustar williamwilliamfrom argcargvtest import * largs=['hi','hola','hello'] if mainc(largs) != 3: raise RuntimeError("bad main typemap") targs=('hi','hola') if mainv(targs,1) != 'hola': print(mainv(targs,1)) raise RuntimeError("bad main typemap") targs=('hi', 'hola') if mainv(targs,1) != 'hola': raise RuntimeError("bad main typemap") try: error = 0 mainv('hello',1) error = 1 except TypeError: pass if error: raise RuntimeError("bad main typemap") initializeApp(largs) swig-3.0.2/Examples/test-suite/python/li_cpointer_runme.py0000664000175000017500000000017312343605122023640 0ustar williamwilliamfrom li_cpointer import * p = new_intp() intp_assign(p,3) if intp_value(p) != 3: raise RuntimeError delete_intp(p) swig-3.0.2/Examples/test-suite/python/virtual_derivation_runme.py0000664000175000017500000000022412343605122025240 0ustar williamwilliamfrom virtual_derivation import * # # very innocent example # b = B(3) if b.get_a() != b.get_b(): raise RuntimeError, "something is really wrong" swig-3.0.2/Examples/test-suite/python/smart_pointer_simple_runme.py0000664000175000017500000000026212343605122025567 0ustar williamwilliamfrom smart_pointer_simple import * f = Foo() b = Bar(f) b.x = 3 if b.getx() != 3: raise RuntimeError fp = b.__deref__() fp.x = 4 if fp.getx() != 4: raise RuntimeError swig-3.0.2/Examples/test-suite/python/typedef_class_runme.py0000664000175000017500000000013712343605122024156 0ustar williamwilliamimport typedef_class a = typedef_class.RealA() a.a = 3 b = typedef_class.B() b.testA(a) swig-3.0.2/Examples/test-suite/python/director_stl_runme.py0000664000175000017500000000072112343605122024025 0ustar williamwilliamimport director_stl class MyFoo(director_stl.Foo): def ping(self, s): return "MyFoo::ping():" + s def pident(self, arg): return arg def vident(self,v): return v def vidents(self,v): return v def vsecond(self,v1,v2): return v2 a = MyFoo() a.tping("hello") a.tpong("hello") p = (1,2) a.pident(p) v = (3,4) a.vident(v) a.tpident(p) a.tvident(v) v1 = (3,4) v2 = (5,6) a.tvsecond(v1,v2) vs=("hi", "hello") vs a.tvidents(vs) swig-3.0.2/Examples/test-suite/python/template_extend1_runme.py0000664000175000017500000000026712343605122024600 0ustar williamwilliamimport template_extend1 a = template_extend1.lBaz() b = template_extend1.dBaz() if a.foo() != "lBaz::foo": raise RuntimeError if b.foo() != "dBaz::foo": raise RuntimeError swig-3.0.2/Examples/test-suite/python/li_std_pair_extra_runme.py0000664000175000017500000000207512343605122025030 0ustar williamwilliamimport li_std_pair_extra p = (1,2) p1 = li_std_pair_extra.p_inout(p) p2 = li_std_pair_extra.p_inoutd(p1) d1 = li_std_pair_extra.d_inout(2) i,d2 = li_std_pair_extra.d_inout2(2) i,p = li_std_pair_extra.p_inout2(p) p3,p4 = li_std_pair_extra.p_inout3(p1,p1) psi = li_std_pair_extra.SIPair("hello",1) pci = li_std_pair_extra.CIPair(1,1) #psi.first = "hi" psi = li_std_pair_extra.SIPair("hi",1) if psi != ("hi",1): raise RuntimeError psii = li_std_pair_extra.SIIPair(psi,1) a = li_std_pair_extra.A() b = li_std_pair_extra.B() pab = li_std_pair_extra.ABPair(a,b); pab.first = a pab.first.val = 2 if pab.first.val != 2: raise RuntimeError pci = li_std_pair_extra.CIntPair(1,0) a = li_std_pair_extra.A(5) p1 = li_std_pair_extra.pairP1(1,a.this) p2 = li_std_pair_extra.pairP2(a,1) p3 = li_std_pair_extra.pairP3(a,a) if a.val != li_std_pair_extra.p_identa(p1.this)[1].val: raise RuntimeError p = li_std_pair_extra.IntPair(1,10) p.first = 1 p = li_std_pair_extra.paircA1(1,a) p.first p.second p = li_std_pair_extra.paircA2(1,a) pp = li_std_pair_extra.pairiiA(1,p) swig-3.0.2/Examples/test-suite/python/arrays_global_runme.py0000664000175000017500000000063712343605122024157 0ustar williamwilliamimport arrays_global arrays_global.cvar.array_i = arrays_global.cvar.array_const_i from arrays_global import * BeginString_FIX44a cvar.BeginString_FIX44b BeginString_FIX44c cvar.BeginString_FIX44d cvar.BeginString_FIX44d cvar.BeginString_FIX44b ="12"'\0'"45" cvar.BeginString_FIX44b cvar.BeginString_FIX44d cvar.BeginString_FIX44e BeginString_FIX44f test_a("hello","hi","chello","chi") test_b("1234567","hi") swig-3.0.2/Examples/test-suite/python/smart_pointer_not_runme.py0000664000175000017500000000073012343605122025076 0ustar williamwilliamfrom smart_pointer_not import * f = Foo() b = Bar(f) s = Spam(f) g = Grok(f) try: x = b.x print "Error! b.x" except: pass try: x = s.x print "Error! s.x" except: pass try: x = g.x print "Error! g.x" except: pass try: x = b.getx() print "Error! b.getx()" except: pass try: x = s.getx() print "Error! s.getx()" except: pass try: x = g.getx() print "Error! g.getx()" except: pass swig-3.0.2/Examples/test-suite/python/pythonswig.supp0000664000175000017500000002344212343605122022701 0ustar williamwilliam{ Memcheck:Leak fun:_Znam fun:_Z21SWIG_AsCharPtrAndSizeP7_objectPPcPmPi fun:var_pcharc_set fun:swig_varlink_setattr fun:PyObject_SetAttr fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znam fun:var_pchar_set fun:swig_varlink_setattr fun:PyObject_SetAttr fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znam fun:_wrap_Test_var_pcharc_set fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalFrame fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:function_call fun:PyObject_Call fun:PyEval_CallObjectWithKeywords fun:instance_setattr fun:PyObject_SetAttr } { Memcheck:Leak fun:_Znam fun:_wrap_TestDirector_var_pcharc_set fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalFrame fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:function_call fun:PyObject_Call fun:instancemethod_call fun:PyObject_Call fun:call_method } { Memcheck:Leak fun:_Znam fun:_Z21SWIG_AsCharPtrAndSizeP7_objectPPcPmPi fun:var_pcharc_set fun:swig_varlink_setattr fun:PyObject_SetAttr fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znam fun:_wrap_Test_var_pchar_set fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalFrame fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:function_call fun:PyObject_Call fun:PyEval_CallObjectWithKeywords fun:instance_setattr fun:PyObject_SetAttr } { Memcheck:Leak fun:_Znam fun:_wrap_TestDirector_var_pchar_set fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalFrame fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:function_call fun:PyObject_Call fun:instancemethod_call fun:PyObject_Call fun:call_method } { Memcheck:Leak fun:malloc fun:SWIG_Python_newvarlink fun:SWIG_globals fun:init_primitive_types fun:_PyImport_LoadDynamicModule fun:load_module fun:import_submodule fun:load_next fun:import_module_ex fun:PyImport_ImportModuleEx fun:builtin___import__ fun:PyObject_Call } { Memcheck:Leak fun:malloc fun:SWIG_Python_addvarlink fun:init_primitive_types fun:_PyImport_LoadDynamicModule fun:load_module fun:import_submodule fun:load_next fun:import_module_ex fun:PyImport_ImportModuleEx fun:builtin___import__ fun:PyObject_Call fun:PyEval_CallObjectWithKeywords } { Memcheck:Leak fun:malloc fun:PyFloat_FromDouble fun:init_primitive_types fun:_PyImport_LoadDynamicModule fun:load_module fun:import_submodule fun:load_next fun:import_module_ex fun:PyImport_ImportModuleEx fun:builtin___import__ fun:PyObject_Call fun:PyEval_CallObjectWithKeywords } { Memcheck:Leak fun:malloc fun:SWIG_Python_addvarlink fun:init_primitive_types fun:_PyImport_LoadDynamicModule fun:load_module fun:import_submodule fun:load_next fun:import_module_ex fun:PyImport_ImportModuleEx fun:builtin___import__ fun:PyObject_Call fun:PyEval_CallObjectWithKeywords } { Memcheck:Leak fun:realloc fun:_PyString_Resize fun:jcompile fun:com_funcdef fun:com_node fun:com_node fun:compile_node fun:jcompile fun:com_classdef fun:com_node fun:compile_node fun:jcompile } { Memcheck:Leak fun:malloc fun:_PyObject_GC_New fun:PyDict_New fun:PyModule_New fun:PyImport_AddModule fun:Py_InitModule4 fun:_PyExc_Init fun:Py_InitializeEx fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z21createref_signed_chara fun:_wrap_createref_signed_char fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z23createref_unsigned_charh fun:_wrap_createref_unsigned_char fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z14createref_charc fun:_wrap_createref_char fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z24createref_unsigned_shortt fun:_wrap_createref_unsigned_short fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z15createref_shorts fun:_wrap_createref_short fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z14createref_boolb fun:_wrap_createref_bool fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z19createref_TestClass9TestClass fun:_wrap_createref_TestClass fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z15createref_floatf fun:_wrap_createref_float fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z22createref_unsigned_intj fun:_wrap_createref_unsigned_int fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z13createref_inti fun:_wrap_createref_int fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z16createref_doubled fun:_wrap_createref_double fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z28createref_unsigned_long_longy fun:_wrap_createref_unsigned_long_long fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z19createref_long_longx fun:_wrap_createref_long_long fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z23createref_unsigned_longm fun:_wrap_createref_unsigned_long fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:_Znwm fun:_Z14createref_longl fun:_wrap_createref_long fun:PyEval_EvalFrame fun:PyEval_EvalCodeEx fun:PyEval_EvalCode fun:PyRun_FileExFlags fun:PyRun_SimpleFileExFlags fun:Py_Main fun:__libc_start_main } { Memcheck:Leak fun:malloc fun:SWIG_Python_newvarlink fun:SWIG_globals fun:init_reference_global_vars fun:_PyImport_LoadDynamicModule fun:load_module fun:import_submodule fun:load_next fun:import_module_ex fun:PyImport_ImportModuleEx fun:builtin___import__ fun:PyObject_Call } { Memcheck:Leak fun:malloc fun:SWIG_Python_addvarlink fun:init_reference_global_vars fun:_PyImport_LoadDynamicModule fun:load_module fun:import_submodule fun:load_next fun:import_module_ex fun:PyImport_ImportModuleEx fun:builtin___import__ fun:PyObject_Call fun:PyEval_CallObjectWithKeywords } { Memcheck:Leak fun:malloc fun:SWIG_Python_addvarlink fun:init_reference_global_vars fun:_PyImport_LoadDynamicModule fun:load_module fun:import_submodule fun:load_next fun:import_module_ex fun:PyImport_ImportModuleEx fun:builtin___import__ fun:PyObject_Call fun:PyEval_CallObjectWithKeywords } swig-3.0.2/Examples/test-suite/python/li_std_map_member_runme.py0000664000175000017500000000032512343605122024772 0ustar williamwilliamimport li_std_map_member a = li_std_map_member.mapita() a[1] = li_std_map_member.TestA() if (a[1].i != 1) : raise RuntimeError("a[1] != 1") a[1].i = 2 if (a[1].i != 2) : raise RuntimeError("a[1] != 2") swig-3.0.2/Examples/test-suite/python/using_extend_runme.py0000664000175000017500000000064512343605122024031 0ustar williamwilliamfrom using_extend import * f = FooBar() if f.blah(3) != 3: raise RuntimeError,"blah(int)" if f.blah(3.5) != 3.5: raise RuntimeError,"blah(double)" if f.blah("hello") != "hello": raise RuntimeError,"blah(char *)" if f.blah(3,4) != 7: raise RuntimeError,"blah(int,int)" if f.blah(3.5,7.5) != (3.5+7.5): raise RuntimeError,"blah(double,double)" if f.duh(3) != 3: raise RuntimeError,"duh(int)" swig-3.0.2/Examples/test-suite/python/types_directive_runme.py0000664000175000017500000000053112343605122024531 0ustar williamwilliamfrom types_directive import * d1 = Time1(2001, 2, 3, 60) newDate = add(d1, 7) # check that a Time1 instance is accepted where Date is expected if newDate.day != 10: raise RuntimeError d2 = Time2(1999, 8, 7, 60) newDate = add(d2, 7) # check that a Time2 instance is accepted where Date is expected if newDate.day != 14: raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_rename_runme.py0000664000175000017500000000027612343605122024477 0ustar williamwilliamimport template_rename i = template_rename.iFoo() d = template_rename.dFoo() a = i.blah_test(4) b = i.spam_test(5) c = i.groki_test(6) x = d.blah_test(7) y = d.spam(8) z = d.grok_test(9) swig-3.0.2/Examples/test-suite/python/rename_strip_encoder_runme.py0000664000175000017500000000013212343605122025513 0ustar williamwilliamfrom rename_strip_encoder import * s = SomeWidget() a = AnotherWidget() a.DoSomething() swig-3.0.2/Examples/test-suite/python/python_abstractbase_runme3.py0000664000175000017500000000106412343605122025453 0ustar williamwilliamfrom python_abstractbase import * from collections import * # This is expected to fail with -builtin option # Builtin types can't inherit from pure-python abstract bases assert issubclass(Mapii, MutableMapping) assert issubclass(Multimapii, MutableMapping) assert issubclass(IntSet, MutableSet) assert issubclass(IntMultiset, MutableSet) assert issubclass(IntVector, MutableSequence) assert issubclass(IntList, MutableSequence) mapii = Mapii() multimapii = Multimapii() intset = IntSet() intmultiset = IntMultiset() intvector = IntVector() intlist = IntList() swig-3.0.2/Examples/test-suite/python/reference_global_vars_runme.py0000664000175000017500000000406212343605122025643 0ustar williamwilliamfrom reference_global_vars import * # const class reference variable if getconstTC().num != 33: raise RuntimeError # primitive reference variables cvar.var_bool = createref_bool(False) if value_bool(cvar.var_bool) != False: raise RuntimeError cvar.var_bool = createref_bool(True) if value_bool(cvar.var_bool) != True: raise RuntimeError cvar.var_char = createref_char('w') if value_char(cvar.var_char) != 'w': raise RuntimeError cvar.var_unsigned_char = createref_unsigned_char(10) if value_unsigned_char(cvar.var_unsigned_char) != 10: raise RuntimeError cvar.var_signed_char = createref_signed_char(10) if value_signed_char(cvar.var_signed_char) != 10: raise RuntimeError cvar.var_short = createref_short(10) if value_short(cvar.var_short) != 10: raise RuntimeError cvar.var_unsigned_short = createref_unsigned_short(10) if value_unsigned_short(cvar.var_unsigned_short) != 10: raise RuntimeError cvar.var_int = createref_int(10) if value_int(cvar.var_int) != 10: raise RuntimeError cvar.var_unsigned_int = createref_unsigned_int(10) if value_unsigned_int(cvar.var_unsigned_int) != 10: raise RuntimeError cvar.var_long = createref_long(10) if value_long(cvar.var_long) != 10: raise RuntimeError cvar.var_unsigned_long = createref_unsigned_long(10) if value_unsigned_long(cvar.var_unsigned_long) != 10: raise RuntimeError cvar.var_long_long = createref_long_long(0x6FFFFFFFFFFFFFF8) if value_long_long(cvar.var_long_long) != 0x6FFFFFFFFFFFFFF8: raise RuntimeError #ull = abs(0xFFFFFFF2FFFFFFF0) ull = 55834574864 cvar.var_unsigned_long_long = createref_unsigned_long_long(ull) if value_unsigned_long_long(cvar.var_unsigned_long_long) != ull: raise RuntimeError cvar.var_float = createref_float(10.5) if value_float(cvar.var_float) != 10.5: raise RuntimeError cvar.var_double = createref_double(10.5) if value_double(cvar.var_double) != 10.5: raise RuntimeError # class reference variable cvar.var_TestClass = createref_TestClass(TestClass(20)) if value_TestClass(cvar.var_TestClass).num != 20: raise RuntimeError swig-3.0.2/Examples/test-suite/python/dynamic_cast_runme.py0000664000175000017500000000025212343605122023765 0ustar williamwilliamimport dynamic_cast f = dynamic_cast.Foo() b = dynamic_cast.Bar() x = f.blah() y = b.blah() a = dynamic_cast.do_test(y) if a != "Bar::test": print "Failed!!" swig-3.0.2/Examples/test-suite/python/li_cwstring_runme.py0000664000175000017500000000120512343605122023652 0ustar williamwilliamfrom li_cwstring import * if count(u"ab\0ab\0ab\0", 0) != 3: raise RuntimeError if test1() != u"Hello World": raise RuntimeError if test2() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": raise RuntimeError if test3("hello") != u"hello-suffix": raise RuntimeError if test4("hello") != u"hello-suffix": raise RuntimeError if test5(4) != u'xxxx': raise RuntimeError if test6(10) != u'xxxxx': raise RuntimeError if test7() != u"Hello world!": raise RuntimeError if test8() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": raise RuntimeError swig-3.0.2/Examples/test-suite/python/Makefile.in0000664000175000017500000001134612343605122021622 0ustar williamwilliam####################################################################### # Makefile for python test-suite ####################################################################### ifeq (,$(PY3)) PYBIN = @PYTHON@ else PYBIN = @PYTHON3@ endif LANGUAGE = python PYTHON = $(PYBIN) #*_runme.py for Python 2.x, *_runme3.py for Python 3.x PY2SCRIPTSUFFIX = _runme.py PY3SCRIPTSUFFIX = _runme3.py PY2TO3 = 2to3 -x import ifeq (,$(PY3)) SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX) else SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX) endif srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ argcargvtest \ callback \ complextest \ director_stl \ director_wstring \ file_test \ iadd \ implicittest \ inout \ inplaceadd \ input \ kwargs_feature \ li_cstring \ li_cwstring \ li_factory \ li_implicit \ li_std_containers_int \ li_std_map_member \ li_std_multimap \ li_std_pair_extra \ li_std_set \ li_std_stream \ li_std_string_extra \ li_std_vectora \ li_std_vector_extra \ li_std_wstream \ li_std_wstring \ primitive_types \ python_abstractbase \ python_append \ python_director \ python_nondynamic \ python_overload_simple_cast \ python_richcompare \ simutry \ std_containers \ swigobject \ template_matrix # li_std_carray # director_profile # python_pybuf C_TEST_CASES += \ file_test \ li_cstring \ li_cwstring \ python_nondynamic \ python_varargs_typemap # # This test only works with modern C compilers # #C_TEST_CASES += \ # complextest include $(srcdir)/../common.mk BUILTIN_BROKEN = \ default_constructor.cpptest \ director_exception.cpptest \ exception_order.cpptest \ li_std_string_extra.cpptest \ li_std_wstring.cpptest \ python_abstractbase.cpptest \ threads_exception.cpptest BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES)) builtin-check : $(BUILTIN_NOT_BROKEN) # Overridden variables here SCRIPTDIR = . LIBS = -L. VALGRIND_OPT += --suppressions=pythonswig.supp # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: +$(convert_testcase) $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: +$(convert_testcase) $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: +$(convert_testcase) $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name. py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme) run_testcase = \ if [ -f $(SCRIPTDIR)/$(py_runme) ]; then \ $(run_python);\ fi # No copying/conversion needed for in-source-tree Python 2 scripts ifeq ($(SCRIPTDIR)|$(SCRIPTSUFFIX),$(srcdir)|$(PY2SCRIPTSUFFIX)) convert_testcase = else convert_testcase = \ if [ -f $(srcdir)/$(py2_runme) ]; then \ $(MAKE) $(SCRIPTDIR)/$(py_runme); \ fi $(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) test x$< = x$@ || cp $< $@ || exit 1 test x$(PY3) = x || $(PY2TO3) -w $@ >/dev/null 2>&1 || exit 1 endif # Clean: remove the generated .py file # We only remove the _runme3.py if it is generated by 2to3 from a _runme.py. %.clean: @rm -f $*.py @if test -f $(srcdir)/$(py2_runme); then rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; fi @if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py2_runme); fi clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py rm -f multi_import_b.py packageoption_a.py packageoption_b.py packageoption_c.py cvsignore: @echo '*wrap* *.pyc *.so *.dll *.exp *.lib' @echo Makefile @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done @echo clientdata_prop_a.py @echo clientdata_prop_b.py @echo imports_a.py @echo imports_b.py @echo mod_a.py mod_b.py @echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py @echo template_typedef_import.py hugemod_runme = hugemod$(SCRIPTPREFIX) hugemod: perl hugemod.pl $(hugemod_runme) $(MAKE) hugemod_a.cpptest $(MAKE) hugemod_b.cpptest sh -c "time $(PYTHON) $(hugemod_runme)" sh -c "time $(PYTHON) $(hugemod_runme)" swig-3.0.2/Examples/test-suite/python/director_finalizer_runme.py0000664000175000017500000000105512343605122025207 0ustar williamwilliamfrom director_finalizer import * class MyFoo(Foo): def __del__(self): self.orStatus(2) try: Foo.__del__(self) except: pass resetStatus() a = MyFoo() del a if getStatus() != 3: raise RuntimeError resetStatus() a = MyFoo() launder(a) if getStatus() != 0: raise RuntimeError del a if getStatus() != 3: raise RuntimeError resetStatus() a = MyFoo().__disown__() deleteFoo(a) if getStatus() != 3: raise RuntimeError resetStatus() a = MyFoo().__disown__() deleteFoo(launder(a)) if getStatus() != 3: raise RuntimeError resetStatus() swig-3.0.2/Examples/test-suite/python/grouping_runme.py0000664000175000017500000000033512343605122023163 0ustar williamwilliamimport grouping x = grouping.test1(42) if x != 42: raise RuntimeError grouping.test2(42) x = grouping.do_unary(37, grouping.NEGATE) if x != -37: raise RuntimeError grouping.cvar.test3 = 42 grouping.test3 = 42 swig-3.0.2/Examples/test-suite/python/cpp_static_runme.py0000664000175000017500000000034412343605122023462 0ustar williamwilliam#!/usr/bin/evn python from cpp_static import * StaticFunctionTest.static_func() StaticFunctionTest.static_func_2(1) StaticFunctionTest.static_func_3(1,2) StaticMemberTest.static_int = 10 assert StaticMemberTest.static_int == 10 swig-3.0.2/Examples/test-suite/python/operbool_runme.py0000664000175000017500000000010212343605122023142 0ustar williamwilliam#!/usr/bin/env python import operbool assert not operbool.Test() swig-3.0.2/Examples/test-suite/python/file_test_runme.py0000664000175000017500000000027212343605122023307 0ustar williamwilliamimport sys import file_test if sys.version_info[0:2] < (3, 0): file_test.nfile(sys.stdout) cstdout = file_test.GetStdOut() file_test.nfile(cstdout) file_test.nfile_name("test.dat") swig-3.0.2/Examples/test-suite/python/director_alternating_runme.py0000664000175000017500000000020112343605122025524 0ustar williamwilliamfrom director_alternating import * id = getBar().id() if id != idFromGetBar(): raise RuntimeError, "Got wrong id: " + str(id) swig-3.0.2/Examples/test-suite/python/namespace_virtual_method_runme.py0000664000175000017500000000010512343605122026366 0ustar williamwilliamimport namespace_virtual_method x = namespace_virtual_method.Spam() swig-3.0.2/Examples/test-suite/python/template_construct_runme.py0000664000175000017500000000003212343605122025242 0ustar williamwilliamimport template_construct swig-3.0.2/Examples/test-suite/python/cpp11_function_objects_runme.py0000664000175000017500000000057112343605122025675 0ustar williamwilliamimport cpp11_function_objects import sys t = cpp11_function_objects.Test() if t.value != 0: raise RuntimeError("Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value)) t(1,2) # adds numbers and sets value if t.value != 3: raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value)) swig-3.0.2/Examples/test-suite/python/contract_runme.py0000664000175000017500000000427312343605122023153 0ustar williamwilliamimport contract contract.test_preassert(1,2) try: contract.test_preassert(-1) print "Failed! Preassertions are broken" except: pass contract.test_postassert(3) try: contract.test_postassert(-3) print "Failed! Postassertions are broken" except: pass contract.test_prepost(2,3) contract.test_prepost(5,-4) try: contract.test_prepost(-3,4) print "Failed! Preassertions are broken" except: pass try: contract.test_prepost(4,-10) print "Failed! Postassertions are broken" except: pass f = contract.Foo() f.test_preassert(4,5) try: f.test_preassert(-2,3) print "Failed! Method preassertion." except: pass f.test_postassert(4) try: f.test_postassert(-4) print "Failed! Method postassertion" except: pass f.test_prepost(3,4) f.test_prepost(4,-3) try: f.test_prepost(-4,2) print "Failed! Method preassertion." except: pass try: f.test_prepost(4,-10) print "Failed! Method postassertion." except: pass contract.Foo_stest_prepost(4,0) try: contract.Foo_stest_prepost(-4,2) print "Failed! Static method preassertion" except: pass try: contract.Foo_stest_prepost(4,-10) print "Failed! Static method posteassertion" except: pass b = contract.Bar() try: b.test_prepost(2,-4) print "Failed! Inherited preassertion." except: pass d = contract.D() try: d.foo(-1,1,1,1,1) print "Failed! Inherited preassertion (D)." except: pass try: d.foo(1,-1,1,1,1) print "Failed! Inherited preassertion (D)." except: pass try: d.foo(1,1,-1,1,1) print "Failed! Inherited preassertion (D)." except: pass try: d.foo(1,1,1,-1,1) print "Failed! Inherited preassertion (D)." except: pass try: d.foo(1,1,1,1,-1) print "Failed! Inherited preassertion (D)." except: pass try: d.bar(-1,1,1,1,1) print "Failed! Inherited preassertion (D)." except: pass try: d.bar(1,-1,1,1,1) print "Failed! Inherited preassertion (D)." except: pass try: d.bar(1,1,-1,1,1) print "Failed! Inherited preassertion (D)." except: pass try: d.bar(1,1,1,-1,1) print "Failed! Inherited preassertion (D)." except: pass try: d.bar(1,1,1,1,-1) print "Failed! Inherited preassertion (D)." except: pass #Namespace my = contract.myClass(1) try: my = contract.myClass(0) print "Failed! constructor preassertion" except: pass swig-3.0.2/Examples/test-suite/python/import_stl_runme.py0000664000175000017500000000021212343605122023517 0ustar williamwilliamimport import_stl_b import import_stl_a v_new = import_stl_b.process_vector([1,2,3]) if v_new != (1,2,3,4): raise RuntimeError, v_new swig-3.0.2/Examples/test-suite/python/template_tbase_template_runme.py0000664000175000017500000000014612343605122026215 0ustar williamwilliamfrom template_tbase_template import * a = make_Class_dd() if a.test() != "test": raise RuntimeError swig-3.0.2/Examples/test-suite/python/director_unroll_runme.py0000664000175000017500000000034112343605122024534 0ustar williamwilliamimport director_unroll class MyFoo(director_unroll.Foo): def ping(self): return "MyFoo::ping()" a = MyFoo() b = director_unroll.Bar() b.set(a) c = b.get() if not (a.this == c.this): print a, c raise RuntimeError swig-3.0.2/Examples/test-suite/python/using2_runme.py0000664000175000017500000000010012343605122022526 0ustar williamwilliamimport using2 if using2.spam(37) != 37: raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_opaque_runme.py0000664000175000017500000000014112343605122024511 0ustar williamwilliamimport template_opaque v = template_opaque.OpaqueVectorType(10) template_opaque.FillVector(v) swig-3.0.2/Examples/test-suite/python/imports_runme.py0000664000175000017500000000037312343605122023030 0ustar williamwilliam# This is the import runtime testcase. import imports_b import imports_a import sys x = imports_b.B() imports_a.A.hello(x) a = imports_a.A() c = imports_b.C() a1 = c.get_a(c) a2 = c.get_a_type(c) if a1.hello() != a2.hello(): raise RuntimeError swig-3.0.2/Examples/test-suite/python/python_varargs_typemap_runme.py0000664000175000017500000000042712343605122026140 0ustar williamwilliamimport python_varargs_typemap if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") : raise RuntimeError("testfunc failed!") if (python_varargs_typemap.testfunc(1, 2.0, "three", "four", "five") != "threefourfive") : raise RuntimeError("testfunc failed! {}") swig-3.0.2/Examples/test-suite/python/li_std_vector_enum_runme.py0000664000175000017500000000057012343605122025216 0ustar williamwilliamimport li_std_vector_enum def check(a, b): if (a != b): raise RuntimeError("Not equal: ", a, b) ev = li_std_vector_enum.EnumVector() check(ev.nums[0], 10) check(ev.nums[1], 20) check(ev.nums[2], 30) it = ev.nums.iterator() v = it.value() check(v, 10) it.next() v = it.value() check(v, 20) expected = 10 for val in ev.nums: check(val, expected) expected += 10 swig-3.0.2/Examples/test-suite/python/template_matrix_runme.py0000664000175000017500000000017512343605122024532 0ustar williamwilliamfrom template_matrix import * passVector([1,2,3]) passMatrix([[1,2],[1,2,3]]) passCube([[[1,2],[1,2,3]],[[1,2],[1,2,3]]]) swig-3.0.2/Examples/test-suite/python/unicode_strings_runme.py0000664000175000017500000000104412343605122024526 0ustar williamwilliamimport sys import unicode_strings # The 'u' string prefix isn't valid in Python 3.0 - 3.2 and is redundant # in 3.3+. Since this file is run through 2to3 before testing, though, # mark this as a unicode string in 2.x so it'll become a str in 3.x. test_string = u'h\udce9llo w\u00f6rld' if sys.version_info[0:2] >= (3, 1): if unicode_strings.non_utf8_c_str() != test_string: raise ValueError('Test comparison mismatch') if unicode_strings.non_utf8_std_string() != test_string: raise ValueError('Test comparison mismatch') swig-3.0.2/Examples/test-suite/python/extend_template_runme.py0000664000175000017500000000021712343605122024512 0ustar williamwilliamimport extend_template f = extend_template.Foo_0() if f.test1(37) != 37: raise RuntimeError if f.test2(42) != 42: raise RuntimeError swig-3.0.2/Examples/test-suite/python/array_member_runme.py0000664000175000017500000000064012343605122023775 0ustar williamwilliamfrom array_member import * f = Foo() f.data = cvar.global_data for i in range(0,8): if get_value(f.data,i) != get_value(cvar.global_data,i): raise RuntimeError, "Bad array assignment" for i in range(0,8): set_value(f.data,i,-i) cvar.global_data = f.data for i in range(0,8): if get_value(f.data,i) != get_value(cvar.global_data,i): raise RuntimeError, "Bad array assignment" swig-3.0.2/Examples/test-suite/python/nested_workaround_runme.py0000664000175000017500000000046112343605122025066 0ustar williamwilliamfrom nested_workaround import * inner = Inner(5) outer = Outer() newInner = outer.doubleInnerValue(inner) if newInner.getValue() != 10: raise RuntimeError outer = Outer() inner = outer.createInner(3) newInner = outer.doubleInnerValue(inner) if outer.getInnerValue(newInner) != 6: raise RuntimeError swig-3.0.2/Examples/test-suite/python/smart_pointer_multi_runme.py0000664000175000017500000000026512343605122025433 0ustar williamwilliamfrom smart_pointer_multi import * f = Foo() b = Bar(f) s = Spam(b) g = Grok(b) s.x = 3 if s.getx() != 3: raise RuntimeError g.x = 4 if g.getx() != 4: raise RuntimeError swig-3.0.2/Examples/test-suite/python/exception_order_runme.py0000664000175000017500000000122112343605122024515 0ustar williamwilliamfrom exception_order import * # This test is expected to fail with -builtin option. # Throwing builtin classes as exceptions not supported a = A() try: a.foo() except E1,e: pass except: raise RuntimeError, "bad exception order" try: a.bar() except E2,e: pass except: raise RuntimeError, "bad exception order" try: a.foobar() except RuntimeError,e: if e.args[0] != "postcatch unknown": print "bad exception order", raise RuntimeError, e.args try: a.barfoo(1) except E1,e: pass except: raise RuntimeError, "bad exception order" try: a.barfoo(2) except E2,e: pass except: raise RuntimeError, "bad exception order" swig-3.0.2/Examples/test-suite/python/extend_template_ns_runme.py0000664000175000017500000000021212343605122025205 0ustar williamwilliamfrom extend_template_ns import * f = Foo_One() if f.test1(37) != 37: raise RuntimeError if f.test2(42) != 42: raise RuntimeError swig-3.0.2/Examples/test-suite/python/abstract_virtual_runme.py0000664000175000017500000000006212343605122024677 0ustar williamwilliamfrom abstract_virtual import * d = D() e = E() swig-3.0.2/Examples/test-suite/python/inout_runme.py0000664000175000017500000000052112343605122022464 0ustar williamwilliamimport inout a = inout.AddOne1(1) if a != 2: raise RuntimeError a = inout.AddOne3(1,1,1) if a != [2,2,2]: raise RuntimeError a = inout.AddOne1p((1,1)) if a != (2,2): raise RuntimeError a = inout.AddOne2p((1,1),1) if a != [(2,2),2]: raise RuntimeError a = inout.AddOne3p(1,(1,1),1) if a != [2,(2,2),2]: raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_typemaps_typedef_runme.py0000664000175000017500000000206312343605122026606 0ustar williamwilliamfrom template_typemaps_typedef import * m1 = MultimapIntA() dummy_pair = m1.make_dummy_pair() val = m1.typemap_test(dummy_pair).val if val != 1234: raise RuntimeError, "typemaps not working" m2 = MultimapAInt() # TODO: typemaps and specializations not quite working as expected. T needs expanding, but at least the right typemap is being picked up. #dummy_pair = m2.make_dummy_pair() #val = m2.typemap_test(dummy_pair) #print val #if val != 4321: # raise RuntimeError, "typemaps not working" if typedef_test1(dummy_pair).val != 1234: raise RuntimeError, "typedef_test1 not working" if typedef_test2(dummy_pair).val != 1234: raise RuntimeError, "typedef_test2 not working" if typedef_test3(dummy_pair).val != 1234: raise RuntimeError, "typedef_test3 not working" if typedef_test4(dummy_pair).val != 1234: raise RuntimeError, "typedef_test4 not working" if typedef_test5(dummy_pair).val != 1234: raise RuntimeError, "typedef_test5 not working" if typedef_test6(dummy_pair).val != 1234: raise RuntimeError, "typedef_test6 not working" swig-3.0.2/Examples/test-suite/python/cpp11_initializer_list_extend_runme.py0000664000175000017500000000014712343605122027263 0ustar williamwilliamimport cpp11_initializer_list_extend c = cpp11_initializer_list_extend.Container( [10, 20, 30, 40] ) swig-3.0.2/Examples/test-suite/python/director_default_runme.py0000664000175000017500000000011512343605122024644 0ustar williamwilliamfrom director_default import * f = Foo() f = Foo(1) f = Bar() f = Bar(1) swig-3.0.2/Examples/test-suite/python/typedef_typedef_runme.py0000664000175000017500000000015012343605122024504 0ustar williamwilliamimport typedef_typedef b = typedef_typedef.B() if b.getValue(123) != 1234: raise Exception("Failed") swig-3.0.2/Examples/test-suite/python/keyword_rename_runme.py0000664000175000017500000000013412343605122024341 0ustar williamwilliam#!/usr/bin/env python import keyword_rename keyword_rename._in(1) keyword_rename._except(1) swig-3.0.2/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py0000664000175000017500000000117312343605122027252 0ustar williamwilliamfrom li_boost_shared_ptr_template import * b = BaseINTEGER() d = DerivedINTEGER() if b.bar() != 1: raise RuntimeError if d.bar() != 2: raise RuntimeError if bar_getter(b) != 1: raise RuntimeError # Fix reverted in rev 12953 #if bar_getter(d) != 2: # raise RuntimeError b = BaseDefaultInt() d = DerivedDefaultInt() d2 = DerivedDefaultInt2() if b.bar2() != 3: raise RuntimeError if d.bar2() != 4: raise RuntimeError if d2.bar2() != 4: raise RuntimeError if bar2_getter(b) != 3: raise RuntimeError # Fix reverted in rev 12953 #if bar2_getter(d) != 4: # raise RuntimeError #if bar2_getter(d2) != 4: # raise RuntimeError swig-3.0.2/Examples/test-suite/python/smart_pointer_typedef_runme.py0000664000175000017500000000026312343605122025737 0ustar williamwilliamfrom smart_pointer_typedef import * f = Foo() b = Bar(f) b.x = 3 if b.getx() != 3: raise RuntimeError fp = b.__deref__() fp.x = 4 if fp.getx() != 4: raise RuntimeError swig-3.0.2/Examples/test-suite/python/class_ignore_runme.py0000664000175000017500000000015712343605122024003 0ustar williamwilliamimport class_ignore a = class_ignore.Bar() if class_ignore.do_blah(a) != "Bar::blah": raise RuntimeError swig-3.0.2/Examples/test-suite/python/overload_extend_runme.py0000664000175000017500000000042112343605122024507 0ustar williamwilliamimport overload_extend f = overload_extend.Foo() if f.test() != 0: raise RuntimeError if f.test(3) != 1: raise RuntimeError if f.test("hello") != 2: raise RuntimeError if f.test(3,2) != 5: raise RuntimeError if f.test(3.0) != 1003: raise RuntimeError swig-3.0.2/Examples/test-suite/python/template_typedef_cplx2_runme.py0000664000175000017500000000322712343605122025777 0ustar williamwilliamfrom template_typedef_cplx2 import * # # double case # try: d = make_Identity_double() a = d.this except: print d, "is not an instance" raise RuntimeError s = '%s' % d if str.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError try: e = make_Multiplies_double_double_double_double(d, d) a = e.this except: print e, "is not an instance" raise RuntimeError s = '%s' % e if str.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError # # complex case # try: c = make_Identity_complex() a = c.this except: print c, "is not an instance" raise RuntimeError s = '%s' % c if str.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError try: f = make_Multiplies_complex_complex_complex_complex(c, c) a = f.this except: print f, "is not an instance" raise RuntimeError s = '%s' % f if str.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError # # Mix case # try: g = make_Multiplies_double_double_complex_complex(d, c) a = g.this except: print g, "is not an instance" raise RuntimeError s = '%s' % g if str.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError try: h = make_Multiplies_complex_complex_double_double(c, d) a = h.this except: print h, "is not an instance" raise RuntimeError s = '%s' % h if str.find(s, 'ArithUnaryFunction') == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError try: a = g.get_value() except: print g, "has not get_value() method" raise RuntimeError swig-3.0.2/Examples/test-suite/python/autodoc_runme.py0000664000175000017500000001147212343605122022773 0ustar williamwilliamfrom autodoc import * import sys def check(got, expected): if expected != got: raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]") check(A.__doc__, "Proxy of C++ A class") check(A.funk.__doc__, "just a string") check(A.func0.__doc__, "func0(self, arg2, hello) -> int") check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int") check(A.func2.__doc__, "\n" " func2(self, arg2, hello) -> int\n" "\n" " Parameters:\n" " arg2: short\n" " hello: int tuple[2]\n" "\n" " " ) check(A.func3.__doc__, "\n" " func3(A self, short arg2, Tuple hello) -> int\n" "\n" " Parameters:\n" " arg2: short\n" " hello: int tuple[2]\n" "\n" " " ) check(A.func0default.__doc__, "\n" " func0default(self, e, arg3, hello, f=2) -> int\n" " func0default(self, e, arg3, hello) -> int\n" " " ) check(A.func1default.__doc__, "\n" " func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" " func1default(A self, A e, short arg3, Tuple hello) -> int\n" " " ) check(A.func2default.__doc__, "\n" " func2default(self, e, arg3, hello, f=2) -> int\n" "\n" " Parameters:\n" " e: A *\n" " arg3: short\n" " hello: int tuple[2]\n" " f: double\n" "\n" " func2default(self, e, arg3, hello) -> int\n" "\n" " Parameters:\n" " e: A *\n" " arg3: short\n" " hello: int tuple[2]\n" "\n" " " ) check(A.func3default.__doc__, "\n" " func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" "\n" " Parameters:\n" " e: A *\n" " arg3: short\n" " hello: int tuple[2]\n" " f: double\n" "\n" " func3default(A self, A e, short arg3, Tuple hello) -> int\n" "\n" " Parameters:\n" " e: A *\n" " arg3: short\n" " hello: int tuple[2]\n" "\n" " " ) check(A.func0static.__doc__, "\n" " func0static(e, arg2, hello, f=2) -> int\n" " func0static(e, arg2, hello) -> int\n" " " ) check(A.func1static.__doc__, "\n" " func1static(A e, short arg2, Tuple hello, double f=2) -> int\n" " func1static(A e, short arg2, Tuple hello) -> int\n" " " ) check(A.func2static.__doc__, "\n" " func2static(e, arg2, hello, f=2) -> int\n" "\n" " Parameters:\n" " e: A *\n" " arg2: short\n" " hello: int tuple[2]\n" " f: double\n" "\n" " func2static(e, arg2, hello) -> int\n" "\n" " Parameters:\n" " e: A *\n" " arg2: short\n" " hello: int tuple[2]\n" "\n" " " ) check(A.func3static.__doc__, "\n" " func3static(A e, short arg2, Tuple hello, double f=2) -> int\n" "\n" " Parameters:\n" " e: A *\n" " arg2: short\n" " hello: int tuple[2]\n" " f: double\n" "\n" " func3static(A e, short arg2, Tuple hello) -> int\n" "\n" " Parameters:\n" " e: A *\n" " arg2: short\n" " hello: int tuple[2]\n" "\n" " " ) if sys.version_info[0:2] > (2, 4): # Python 2.4 does not seem to work check(A.variable_a.__doc__, "A_variable_a_get(self) -> int") check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int") check(A.variable_c.__doc__, "\n" "A_variable_c_get(self) -> int\n" "\n" "Parameters:\n" " self: A *\n" "\n" ) check(A.variable_d.__doc__, "\n" "A_variable_d_get(A self) -> int\n" "\n" "Parameters:\n" " self: A *\n" "\n" ) check(B.__doc__, "Proxy of C++ B class") check(C.__init__.__doc__, "__init__(self, a, b, h) -> C") check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D") check(E.__init__.__doc__, "\n" " __init__(self, a, b, h) -> E\n" "\n" " Parameters:\n" " a: special comment for parameter a\n" " b: another special comment for parameter b\n" " h: enum Hola\n" "\n" " " ) check(F.__init__.__doc__, "\n" " __init__(F self, int a, int b, Hola h) -> F\n" "\n" " Parameters:\n" " a: special comment for parameter a\n" " b: another special comment for parameter b\n" " h: enum Hola\n" "\n" " " ) check(B.funk.__doc__, "funk(B self, int c, int d) -> int") check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int") check(funkdefaults.__doc__, "\n" " funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n" " funkdefaults(A e, short arg2, int c, int d) -> int\n" " " ) check(func_input.__doc__, "func_input(int * INPUT) -> int") check(func_output.__doc__, "func_output() -> int") check(func_inout.__doc__, "func_inout(int * INOUT) -> int") check(banana.__doc__, "banana(S a, S b, int c, Integer d)") swig-3.0.2/Examples/test-suite/python/varargs_overload_runme.py0000664000175000017500000000146112343605122024672 0ustar williamwilliamimport varargs_overload if varargs_overload.vararg_over1("Hello") != "Hello": raise RuntimeError, "Failed" if varargs_overload.vararg_over1(2) != "2": raise RuntimeError, "Failed" if varargs_overload.vararg_over2("Hello") != "Hello": raise RuntimeError, "Failed" if varargs_overload.vararg_over2(2, 2.2) != "2 2.2": raise RuntimeError, "Failed" if varargs_overload.vararg_over3("Hello") != "Hello": raise RuntimeError, "Failed" if varargs_overload.vararg_over3(2, 2.2, "hey") != "2 2.2 hey": raise RuntimeError, "Failed" if varargs_overload.vararg_over4("Hello") != "Hello": raise RuntimeError, "Failed" if varargs_overload.vararg_over4(123) != "123": raise RuntimeError, "Failed" if varargs_overload.vararg_over4("Hello", 123) != "Hello": raise RuntimeError, "Failed" swig-3.0.2/Examples/test-suite/python/global_vars_runme.py0000664000175000017500000000144412343605122023626 0ustar williamwilliamimport global_vars global_vars.init() b = global_vars.cvar.b if b != "string b": raise RuntimeError("Unexpected string: " + b) global_vars.cvar.b = "a string value" b = global_vars.cvar.b if b != "a string value": raise RuntimeError("Unexpected string: " + b) x = global_vars.cvar.x if x != 1234: raise RuntimeError("Unexpected x: " + str(x)) global_vars.cvar.x = 9876 x = global_vars.cvar.x if x != 9876: raise RuntimeError("Unexpected string: " + str(x)) fail = True try: global_vars.cvar.notexist = "something" except AttributeError, e: fail = False if fail: raise RuntimeError("AttributeError should have been thrown") fail = True try: g = global_vars.cvar.notexist except AttributeError, e: fail = False if fail: raise RuntimeError("AttributeError should have been thrown") swig-3.0.2/Examples/test-suite/python/template_ns4_runme.py0000664000175000017500000000013412343605122023725 0ustar williamwilliamfrom template_ns4 import * d = make_Class_DD(); if d.test() != "test": raise RuntimeError swig-3.0.2/Examples/test-suite/python/profiletestc_runme.py0000664000175000017500000000155112343605122024035 0ustar williamwilliamimport _profiletest #import profiletest pa = _profiletest.new_A() pb = _profiletest.new_B() fn = _profiletest.B_fn destroy = _profiletest.delete_A i = 50000 a = pa while i: a = fn(pb,a) #1 destroy(a) a = fn(pb,a) #2 destroy(a) a = fn(pb,a) #3 destroy(a) a = fn(pb,a) #4 destroy(a) a = fn(pb,a) #5 destroy(a) a = fn(pb,a) #6 destroy(a) a = fn(pb,a) #7 destroy(a) a = fn(pb,a) #8 destroy(a) a = fn(pb,a) #9 destroy(a) a = fn(pb,a) #10 destroy(a) a = fn(pb,a) #1 destroy(a) a = fn(pb,a) #2 destroy(a) a = fn(pb,a) #3 destroy(a) a = fn(pb,a) #4 destroy(a) a = fn(pb,a) #5 destroy(a) a = fn(pb,a) #6 destroy(a) a = fn(pb,a) #7 destroy(a) a = fn(pb,a) #8 destroy(a) a = fn(pb,a) #9 destroy(a) a = fn(pb,a) #20 destroy(a) i -= 1 _profiletest.delete_A(pa) _profiletest.delete_B(pb) swig-3.0.2/Examples/test-suite/python/global_ns_arg_runme.py0000664000175000017500000000006612343605122024123 0ustar williamwilliamfrom global_ns_arg import * a = foo(1) b = bar_fn() swig-3.0.2/Examples/test-suite/octave/0000775000175000017500000000000012343605122017510 5ustar williamwilliamswig-3.0.2/Examples/test-suite/octave/struct_rename_runme.m0000664000175000017500000000005112343605122023743 0ustar williamwilliamstruct_rename b = struct_rename.Bar(); swig-3.0.2/Examples/test-suite/octave/minherit_runme.m0000664000175000017500000000405012343605122022712 0ustar williamwilliamminherit a = minherit.Foo(); b = minherit.Bar(); c = minherit.FooBar(); d = minherit.Spam(); if (a.xget() != 1) error("Bad attribute value") endif if (b.yget() != 2) error("Bad attribute value") endif if (c.xget() != 1 || c.yget() != 2 || c.zget() != 3) error("Bad attribute value") endif if (d.xget() != 1 || d.yget() != 2 || d.zget() != 3 || d.wget() != 4) error("Bad attribute value") endif if (minherit.xget(a) != 1) error("Bad attribute value %d",minherit.xget(a)) endif if (minherit.yget(b) != 2) error("Bad attribute value %d",minherit.yget(b)) endif if (minherit.xget(c) != 1 || minherit.yget(c) != 2 || minherit.zget(c) != 3) error("Bad attribute value %d %d %d",minherit.xget(c),minherit.yget(c),minherit.zget(c)) endif if (minherit.xget(d) != 1 || minherit.yget(d) != 2 || minherit.zget(d) != 3 || minherit.wget(d) != 4) error("Bad attribute value %d %d %d %d",minherit.xget(d),minherit.yget(d),minherit.zget(d),minherit.wget(d)) endif # Cleanse all of the pointers and see what happens aa = minherit.toFooPtr(a); bb = minherit.toBarPtr(b); cc = minherit.toFooBarPtr(c); dd = minherit.toSpamPtr(d); if (aa.xget() != 1) error("Bad attribute value"); endif if (bb.yget() != 2) error("Bad attribute value"); endif if (cc.xget() != 1 || cc.yget() != 2 || cc.zget() != 3) error("Bad attribute value") endif if (dd.xget() != 1 || dd.yget() != 2 || dd.zget() != 3 || dd.wget() != 4) error("Bad attribute value") endif if (minherit.xget(aa) != 1) error("Bad attribute value %d",minherit.xget(aa)); endif if (minherit.yget(bb) != 2) error("Bad attribute value %d",minherit.yget(bb)); endif if (minherit.xget(cc) != 1 || minherit.yget(cc) != 2 || minherit.zget(cc) != 3) error("Bad attribute value %d %d %d",minherit.xget(cc),minherit.yget(cc),minherit.zget(cc)); endif if (minherit.xget(dd) != 1 || minherit.yget(dd) != 2 || minherit.zget(dd) != 3 || minherit.wget(dd) != 4) error("Bad attribute value %d %d %d %d",minherit.xget(dd),minherit.yget(dd),minherit.zget(dd),minherit.wget(dd)) endif swig-3.0.2/Examples/test-suite/octave/smart_pointer_member_runme.m0000664000175000017500000000050112343605122025305 0ustar williamwilliamsmart_pointer_member f = Foo(); f.y = 1; if (f.y != 1) error endif b = Bar(f); b.y = 2; if (f.y != 2) error("f.y = %i, b.y = %i",f.y,b.y) endif if (swig_this(b.x) != swig_this(f.x)) error endif if (b.z != f.z) error endif try if (Foo.z == Bar.z) error endif error catch end_try_catch swig-3.0.2/Examples/test-suite/octave/file_test_runme.m0000664000175000017500000000020612343605122023050 0ustar williamwilliamfile_test file_test.nfile("stdout"); cstdout = file_test.GetStdOut(); file_test.nfile(cstdout); file_test.nfile_name("test.dat"); swig-3.0.2/Examples/test-suite/octave/template_typedef_cplx2_runme.m0000664000175000017500000000306412343605122025542 0ustar williamwilliamtemplate_typedef_cplx2 # # double case # try d = make_Identity_double(); a = swig_this(d); catch d error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(d)) != 1) d error("is not an ArithUnaryFunction") error endif try e = make_Multiplies_double_double_double_double(d, d); a = swig_this(e); catch e error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(e)) != 1) e error("is not an ArithUnaryFunction") endif # # complex case # try c = make_Identity_complex(); a = swig_this(c); catch c error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(c)) != 1) c error("is not an ArithUnaryFunction") endif try f = make_Multiplies_complex_complex_complex_complex(c, c); a = swig_this(f); catch f error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(f)) != 1) f error("is not an ArithUnaryFunction") endif # # Mix case # try g = make_Multiplies_double_double_complex_complex(d, c); a = swig_this(g); catch g error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(g)) != 1) g error("is not an ArithUnaryFunction") error endif try h = make_Multiplies_complex_complex_double_double(c, d); a = swig_this(h); catch h error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(h)) == -1) h error("is not an ArithUnaryFunction") endif try a = g.get_value(); catch error(g, "has not get_value() method") error end_try_catch swig-3.0.2/Examples/test-suite/octave/primitive_ref_runme.m0000664000175000017500000000105112343605122023735 0ustar williamwilliamprimitive_ref if (ref_int(3) != 3) error endif if (ref_uint(3) != 3) error endif if (ref_short(3) != 3) error endif if (ref_ushort(3) != 3) error endif if (ref_long(3) != 3) error endif if (ref_ulong(3) != 3) error endif if (ref_schar(3) != 3) error endif if (ref_uchar(3) != 3) error endif if (ref_float(3.5) != 3.5) error endif if (ref_double(3.5) != 3.5) error endif if (ref_bool(true) != true) error endif if (!strcmp(ref_char('x'),'x')) error endif if (ref_over(0) != 0) error endif swig-3.0.2/Examples/test-suite/octave/typemap_namespace_runme.m0000664000175000017500000000017712343605122024574 0ustar williamwilliamtypemap_namespace if (!strcmp(test1("hello"),"hello")) error endif if (!strcmp(test2("hello"),"hello")) error endif swig-3.0.2/Examples/test-suite/octave/argcargvtest_runme.m0000664000175000017500000000065712343605122023600 0ustar williamwilliamargcargvtest largs={'hi','hola','hello'}; if (mainc(largs) != 3) error("bad main typemap"); endif targs={'hi','hola'}; if (mainv(targs,1) != 'hola') error("bad main typemap"); endif targs={'hi', 'hola'}; if (mainv(targs,1) != 'hola') error("bad main typemap"); endif try error_flag = 0; mainv('hello',1); error_flag = 1; catch end_try_catch if (error_flag) error("bad main typemap") endif initializeApp(largs); swig-3.0.2/Examples/test-suite/octave/overload_extend_runme.m0000664000175000017500000000036512343605122024262 0ustar williamwilliamoverload_extend f = overload_extend.Foo(); if (f.test() != 0) error endif if (f.test(3) != 1) error endif if (f.test("hello") != 2) error endif if (f.test(3,2) != 5) error endif if (f.test(3.1)-.1 != 1003) # :) error endif swig-3.0.2/Examples/test-suite/octave/class_scope_weird_runme.m0000664000175000017500000000016112343605122024562 0ustar williamwilliamclass_scope_weird f = class_scope_weird.Foo(); g = class_scope_weird.Foo(3); if (f.bar(3) != 3) error endif swig-3.0.2/Examples/test-suite/octave/using2_runme.m0000664000175000017500000000006312343605122022302 0ustar williamwilliamusing2 if (using2.spam(37) != 37) error endif swig-3.0.2/Examples/test-suite/octave/extend_template_runme.m0000664000175000017500000000017512343605122024261 0ustar williamwilliamextend_template f = extend_template.Foo_0(); if (f.test1(37) != 37) error endif if (f.test2(42) != 42) error endif swig-3.0.2/Examples/test-suite/octave/constructor_copy_runme.m0000664000175000017500000000060212343605122024511 0ustar williamwilliamconstructor_copy f1 = Foo1(3); f11 = Foo1(f1); if (f1.x != f11.x) error endif f8 = Foo8(); try f81 = Foo8(f8); good = 0; catch good = 1; end_try_catch if (!good) error endif bi = Bari(5); bc = Bari(bi); if (bi.x != bc.x) error endif bd = Bard(5); try bc = Bard(bd); good = 0; catch good = 1; end_try_catch if (!good) error endif swig-3.0.2/Examples/test-suite/octave/template_opaque_runme.m0000664000175000017500000000013512343605122024260 0ustar williamwilliamtemplate_opaque v = template_opaque.OpaqueVectorType(10); template_opaque.FillVector(v); swig-3.0.2/Examples/test-suite/octave/template_typedef_cplx_runme.m0000664000175000017500000000270212343605122025456 0ustar williamwilliamtemplate_typedef_cplx # # double case # try d = make_Identity_double(); a = swig_this(d); catch d error("is not an instance") end_try_catch if (findstr("ArithUnaryFunction",swig_type(d)) != 1) d error("is not an ArithUnaryFunction") endif try e = make_Multiplies_double_double_double_double(d, d); a = swig_this(e); catch error(e, "is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(e)) != 1); c error("is not an ArithUnaryFunction") endif # # complex case # try c = make_Identity_complex(); a = swig_this(c); catch c error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(c)) != 1) c error("is not an ArithUnaryFunction") endif try f = make_Multiplies_complex_complex_complex_complex(c, c); a = swig_this(f); catch f error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(f)) != 1) f error("is not an ArithUnaryFunction") endif # # Mix case # try g = make_Multiplies_double_double_complex_complex(d, c); a = swig_this(g); catch g error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(g)) != 1) g error("is not an ArithUnaryFunction") endif try h = make_Multiplies_complex_complex_double_double(c, d); a = swig_this(h); catch h error("is not an instance") end_try_catch if (findstr('ArithUnaryFunction',swig_type(h)) != 1) h error("is not an ArithUnaryFunction") endif swig-3.0.2/Examples/test-suite/octave/li_attribute_runme.m0000664000175000017500000000265512343605122023573 0ustar williamwilliamli_attribute aa = li_attribute.A(1,2,3); if (aa.a != 1) error endif aa.a = 3; if (aa.a != 3) error("aa.a = %i",aa.a) endif if (aa.b != 2) error(aa.b) endif aa.b = 5; if (aa.b != 5) error endif if (aa.d != aa.b) error endif if (aa.c != 3) error endif pi = li_attribute.Param_i(7); if (pi.value != 7) error endif pi.value=3; if (pi.value != 3) error endif b = li_attribute.B(aa); if (b.a.c != 3) error endif # class/struct attribute with get/set methods using return/pass by reference myFoo = li_attribute.MyFoo(); myFoo.x = 8; myClass = li_attribute.MyClass(); myClass.Foo = myFoo; if (myClass.Foo.x != 8) error endif # class/struct attribute with get/set methods using return/pass by value myClassVal = li_attribute.MyClassVal(); if (myClassVal.ReadWriteFoo.x != -1) error endif if (myClassVal.ReadOnlyFoo.x != -1) error endif myClassVal.ReadWriteFoo = myFoo; if (myClassVal.ReadWriteFoo.x != 8) error endif if (myClassVal.ReadOnlyFoo.x != 8) error endif # string attribute with get/set methods using return/pass by value myStringyClass = li_attribute.MyStringyClass("initial string"); if (myStringyClass.ReadWriteString != "initial string") error endif if (myStringyClass.ReadOnlyString != "initial string") error endif myStringyClass.ReadWriteString = "changed string"; if (myStringyClass.ReadWriteString != "changed string") error endif if (myStringyClass.ReadOnlyString != "changed string") error endif swig-3.0.2/Examples/test-suite/octave/extend_placement_runme.m0000664000175000017500000000165412343605122024421 0ustar williamwilliamextend_placement foo = extend_placement.Foo(); foo = extend_placement.Foo(1); foo = extend_placement.Foo(1,1); foo.spam(); foo.spam("hello"); foo.spam(1); foo.spam(1,1); foo.spam(1,1,1); foo.spam(extend_placement.Foo()); foo.spam(extend_placement.Foo(), 1.0); bar = extend_placement.Bar(); bar = extend_placement.Bar(1); bar.spam(); bar.spam("hello"); bar.spam(1); bar.spam(1,1); bar.spam(1,1,1); bar.spam(extend_placement.Bar()); bar.spam(extend_placement.Bar(), 1.0); foo = extend_placement.FooTi(); foo = extend_placement.FooTi(1); foo = extend_placement.FooTi(1,1); foo.spam(); foo.spam("hello"); foo.spam(1); foo.spam(1,1); foo.spam(1,1,1); foo.spam(extend_placement.Foo()); foo.spam(extend_placement.Foo(), 1.0); bar = extend_placement.BarTi(); bar = extend_placement.BarTi(1); bar.spam(); bar.spam("hello"); bar.spam(1); bar.spam(1,1); bar.spam(1,1,1); bar.spam(extend_placement.Bar()); bar.spam(extend_placement.Bar(), 1.0); swig-3.0.2/Examples/test-suite/octave/preproc_runme.m0000664000175000017500000000030112343605122022540 0ustar williamwilliampreproc if (preproc.cvar.endif != 1) error endif if (preproc.cvar.define != 1) error endif if (preproc.cvar.defined != 1) error endif if (2*preproc.one != preproc.two) error endif swig-3.0.2/Examples/test-suite/octave/li_cstring_runme.m0000664000175000017500000000121012343605122023223 0ustar williamwilliamli_cstring if (count("ab\0ab\0ab\0", 0) != 3) error endif if (!strcmp(test1(),"Hello World")) error endif if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_")) error endif if (!strcmp(test3("hello"),"hello-suffix")) error(test3("hello")) endif if (!strcmp(test4("hello"),"hello-suffix")) error(test4("hello")) endif if (!strcmp(test5(4),'xxxx')) error endif if (!strcmp(test6(10),'xxxxx')) error endif if (!strcmp(test7(),"Hello world!")) error endif if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_")) error endif swig-3.0.2/Examples/test-suite/octave/nondynamic_runme.m0000664000175000017500000000054112343605122023233 0ustar williamwilliamnondynamic aa = nondynamic.A(); aa.a = 1; aa.b = 2; try aa.c = 2; err = 0; catch err = 1; end_try_catch if (!err) error("A is not static") endif B=@() subclass(nondynamic.A(),'c',4); bb = B(); bb.c = 3; try bb.d = 2 err = 0 catch err = 1 end_try_catch if (!err) error("B is not static") endif cc = nondynamic.C(); cc.d = 3; swig-3.0.2/Examples/test-suite/octave/typedef_class_runme.m0000664000175000017500000000013012343605122023713 0ustar williamwilliamtypedef_class a = typedef_class.RealA(); a.a = 3; b = typedef_class.B(); b.testA(a); swig-3.0.2/Examples/test-suite/octave/extend_variable_runme.m0000664000175000017500000000006512343605122024231 0ustar williamwilliamextend_variable if (Foo.Bar != 42) error endif swig-3.0.2/Examples/test-suite/octave/cpp_enum_runme.m0000664000175000017500000000063312343605122022704 0ustar williamwilliamcpp_enum f = cpp_enum.Foo(); if (f.hola != cpp_enum.Foo_Hello) error(f.hola); error; endif f.hola = cpp_enum.Foo_Hi; if (f.hola != cpp_enum.Foo_Hi) error(f.hola); error; endif f.hola = cpp_enum.Foo_Hello; if (f.hola != cpp_enum.Foo_Hello) error(f.hola); error; endif cpp_enum.hi = cpp_enum.Hello; if (cpp_enum.hi != cpp_enum.Hello) error(cpp_enum.hi); error; endif swig-3.0.2/Examples/test-suite/octave/li_std_wstring_runme.m0000664000175000017500000000275512343605122024140 0ustar williamwilliamli_std_wstring x="h"; if (li_std_wstring.test_wcvalue(x) != x) error("bad string mapping") endif x="hello"; if (li_std_wstring.test_ccvalue(x) != x) error("bad string mapping") endif if (li_std_wstring.test_cvalue(x) != x) error("bad string mapping") endif if (li_std_wstring.test_value(x) != x) error("bad string mapping") endif if (li_std_wstring.test_const_reference(x) != x) error("bad string mapping") endif s = li_std_wstring.wstring("he"); s = s + "llo"; if (s != x) error("bad string mapping") endif if (s(1:4) != x(1:4)) error("bad string mapping") endif if (li_std_wstring.test_value(s) != x) error("bad string mapping") endif if (li_std_wstring.test_const_reference(s) != x) error("bad string mapping") endif a = li_std_wstring.A(s); if (li_std_wstring.test_value(a) != x) error("bad string mapping") endif if (li_std_wstring.test_const_reference(a) != x) error("bad string mapping") endif b = li_std_wstring.wstring(" world"); if (a + b != "hello world") error("bad string mapping") endif if (a + " world" != "hello world") error("bad string mapping") endif if ("hello" + b != "hello world") error("bad string mapping") endif c = "hello" + b; if (c.find_last_of("l") != 9) error("bad string mapping") endif s = "hello world"; b = li_std_wstring.B("hi"); b.name = li_std_wstring.wstring("hello"); if (b.name != "hello") error("bad string mapping") endif b.a = li_std_wstring.A("hello"); if (b.a != "hello") error("bad string mapping") endif swig-3.0.2/Examples/test-suite/octave/template_default_arg_runme.m0000664000175000017500000000516012343605122025246 0ustar williamwilliamtemplate_default_arg helloInt = template_default_arg.Hello_int(); helloInt.foo(template_default_arg.Hello_int_hi); x = template_default_arg.X_int(); if (x.meth(20.0, 200) != 200) error("X_int test 1 failed") endif if (x.meth(20) != 20) error("X_int test 2 failed") endif if (x.meth() != 0) error("X_int test 3 failed") endif y = template_default_arg.Y_unsigned(); if (y.meth(20.0, 200) != 200) error("Y_unsigned test 1 failed") endif if (y.meth(20) != 20) error("Y_unsigned test 2 failed") endif if (y.meth() != 0) error("Y_unsigned test 3 failed") endif x = template_default_arg.X_longlong(); x = template_default_arg.X_longlong(20.0); x = template_default_arg.X_longlong(20.0, 200); x = template_default_arg.X_int(); x = template_default_arg.X_int(20.0); x = template_default_arg.X_int(20.0, 200); x = template_default_arg.X_hello_unsigned(); x = template_default_arg.X_hello_unsigned(20.0); x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int()); y = template_default_arg.Y_hello_unsigned(); y.meth(20.0, template_default_arg.Hello_int()); y.meth(template_default_arg.Hello_int()); y.meth(); fz = template_default_arg.Foo_Z_8(); x = template_default_arg.X_Foo_Z_8(); fzc = x.meth(fz); # Templated functions # plain function: int ott(Foo) if (template_default_arg.ott(template_default_arg.Foo_int()) != 30) error("ott test 1 failed") endif # %template(ott) ott if (template_default_arg.ott() != 10) error("ott test 2 failed") endif if (template_default_arg.ott(1) != 10) error("ott test 3 failed") endif if (template_default_arg.ott(1, 1) != 10) error("ott test 4 failed") endif if (template_default_arg.ott("hi") != 20) error("ott test 5 failed") endif if (template_default_arg.ott("hi", 1) != 20) error("ott test 6 failed") endif if (template_default_arg.ott("hi", 1, 1) != 20) error("ott test 7 failed") endif # %template(ott) ott if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40) error("ott test 8 failed") endif if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40) error("ott test 9 failed") endif # %template(ott) ott if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50) error("ott test 10 failed") endif if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50) error("ott test 11 failed") endif # %template(ott) ott if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60) error("ott test 12 failed") endif if (template_default_arg.ott(template_default_arg.Hello_int()) != 60) error("ott test 13 failed") endif swig-3.0.2/Examples/test-suite/octave/nested_structs_runme.m0000664000175000017500000000053012343605122024143 0ustar williamwilliamnested_structs named = nested_structs.Named(); named.val = 999; assert(nested_structs.nestedByVal(named), 999); assert(nested_structs.nestedByPtr(named), 999); outer = nested_structs.Outer(); outer.inside1.val = 456; assert(nested_structs.getInside1Val(outer), 456); outer.inside1 = named; assert(nested_structs.getInside1Val(outer), 999); swig-3.0.2/Examples/test-suite/octave/return_const_value_runme.m0000664000175000017500000000042412343605122025015 0ustar williamwilliamreturn_const_value p = return_const_value.Foo_ptr.getPtr(); if (p.getVal() != 17) error("Runtime test1 faild. p.getVal()=", p.getVal()) endif p = return_const_value.Foo_ptr.getConstPtr(); if (p.getVal() != 17) error("Runtime test2 faild. p.getVal()=", p.getVal()) endif swig-3.0.2/Examples/test-suite/octave/member_pointer_runme.m0000664000175000017500000000163212343605122024105 0ustar williamwilliam# Example using pointers to member functions member_pointer function check(what,expected,actual) if (expected != actual) error ("Failed: %s, Expected: %f, Actual: %f",what,expected,actual); endif end # Get the pointers area_pt = areapt; perim_pt = perimeterpt; # Create some objects s = Square(10); # Do some calculations check ("Square area ", 100.0, do_op(s,area_pt)); check ("Square perim", 40.0, do_op(s,perim_pt)); memberPtr = cvar.areavar; memberPtr = cvar.perimetervar; # Try the variables check ("Square area ", 100.0, do_op(s,cvar.areavar)); check ("Square perim", 40.0, do_op(s,cvar.perimetervar)); # Modify one of the variables cvar.areavar = perim_pt; check ("Square perimeter", 40.0, do_op(s,cvar.areavar)); # Try the constants memberPtr = AREAPT; memberPtr = PERIMPT; memberPtr = NULLPT; check ("Square area ", 100.0, do_op(s,AREAPT)); check ("Square perim", 40.0, do_op(s,PERIMPT)); swig-3.0.2/Examples/test-suite/octave/imports_runme.m0000664000175000017500000000072012343605122022570 0ustar williamwilliam# This is the import runtime testcase. # Workaround seg fault occurring during interpreter cleanup/exit in version 3.1 and 3.2, seems okay in 3.6 if (compare_versions(version(), "3.3", ">=")) imports_b; imports_a; x = imports_b.B(); x.hello(); a = imports_a.A(); c = imports_b.C(); a1 = c.get_a(c); a2 = c.get_a_type(c); a1.hello(); a2.hello(); assert(swig_this(a1)==swig_this(a2)); assert(strcmp(swig_type(a1),swig_type(a2))); endif swig-3.0.2/Examples/test-suite/octave/template_tbase_template_runme.m0000664000175000017500000000013212343605122025754 0ustar williamwilliamtemplate_tbase_template a = make_Class_dd(); if (!strcmp(a.test(),"test")) error endif swig-3.0.2/Examples/test-suite/octave/overload_complicated_runme.m0000664000175000017500000000164612343605122025262 0ustar williamwilliamoverload_complicated pInt = None; # Check the correct constructors are available p = Pop(pInt); p = Pop(pInt, 0); # Check overloaded in const only and pointers/references which target languages cannot disambiguate if (p.hip(0) != 701) error("Test 1 failed") endif if (p.hip(pInt) != 702) error("Test 2 failed") endif # Reverse the order for the above if (p.hop(pInt) != 805) error("Test 3 failed") endif if (p.hop(0) != 801) error("Test 4 failed") endif # Few more variations and order shuffled if (p.pop(0) != 901) error("Test 5 failed") endif if (p.pop(pInt) != 902) error("Test 6 failed") endif if (p.pop() != 905) error("Test 7 failed") endif # Overload on const only if (p.bop(pInt) != 1001) error("Test 8 failed") endif if (p.bip(pInt) != 2001) error("Test 9 failed") endif # Globals if (muzak(0) != 3001) error("Test 10 failed") endif if (muzak(pInt) != 3002) error("Test 11 failed") endif swig-3.0.2/Examples/test-suite/octave/arrays_global_runme.m0000664000175000017500000000064212343605122023717 0ustar williamwilliamarrays_global arrays_global.cvar.array_i = arrays_global.cvar.array_const_i; cvar.BeginString_FIX44a; cvar.BeginString_FIX44b; cvar.BeginString_FIX44c; cvar.BeginString_FIX44d; cvar.BeginString_FIX44d; cvar.BeginString_FIX44b = strcat("12","\0","45"); cvar.BeginString_FIX44b; cvar.BeginString_FIX44d; cvar.BeginString_FIX44e; cvar.BeginString_FIX44f; test_a("hello","hi","chello","chi"); test_b("1234567","hi"); swig-3.0.2/Examples/test-suite/octave/enum_template_runme.m0000664000175000017500000000024112343605122023730 0ustar williamwilliamenum_template if (enum_template.MakeETest() != 1) error endif enum_template.TakeETest(0); try a=enum_template.TakeETest(0); error catch end_try_catch swig-3.0.2/Examples/test-suite/octave/compactdefaultargs_runme.m0000664000175000017500000000047212343605122024747 0ustar williamwilliamcompactdefaultargs defaults1 = Defaults1(1000); defaults1 = Defaults1(); if (defaults1.ret(10.0) != 10.0) error endif if (defaults1.ret() != -1.0) error endif defaults2 = Defaults2(1000); defaults2 = Defaults2(); if (defaults2.ret(10.0) != 10.0) error endif if (defaults2.ret() != -1.0) error endif swig-3.0.2/Examples/test-suite/octave/typedef_inherit_runme.m0000664000175000017500000000102412343605122024253 0ustar williamwilliamtypedef_inherit a = typedef_inherit.Foo(); b = typedef_inherit.Bar(); x = typedef_inherit.do_blah(a); if (!strcmp(x,"Foo::blah")) error("Whoa! Bad return", x) endif x = typedef_inherit.do_blah(b); if (!strcmp(x,"Bar::blah")) error("Whoa! Bad return", x) endif c = typedef_inherit.Spam(); d = typedef_inherit.Grok(); x = typedef_inherit.do_blah2(c); if (!strcmp(x,"Spam::blah")) error("Whoa! Bad return", x) endif x = typedef_inherit.do_blah2(d); if (!strcmp(x,"Grok::blah")) error("Whoa! Bad return", x) endif swig-3.0.2/Examples/test-suite/octave/inctest_runme.m0000664000175000017500000000072612343605122022552 0ustar williamwilliaminctest try a = inctest.A(); catch error("didn't find A\ntherefore, I didn't include \ 'testdir/subdir1/hello.i'") end_try_catch try b = inctest.B(); catch error("didn't find B\ntherefore, I didn't include 'testdir/subdir2/hello.i'") end_try_catch # Check the import in subdirectory worked if (inctest.importtest1(5) != 15) error("import test 1 failed") endif if (!strcmp(inctest.importtest2("black"),"white")) error("import test 2 failed") endif swig-3.0.2/Examples/test-suite/octave/template_static_runme.m0000664000175000017500000000004412343605122024254 0ustar williamwilliamtemplate_static Foo_bar_double(1); swig-3.0.2/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m0000664000175000017500000000025212343605122026713 0ustar williamwilliamsmart_pointer_multi_typedef f = Foo(); b = Bar(f); s = Spam(b); g = Grok(b); s.x = 3; if (s.getx() != 3) error endif g.x = 4; if (g.getx() != 4) error endif swig-3.0.2/Examples/test-suite/octave/template_extend2_runme.m0000664000175000017500000000026212343605122024340 0ustar williamwilliamtemplate_extend2 a = template_extend2.lBaz(); b = template_extend2.dBaz(); if (!strcmp(a.foo(),"lBaz::foo")) error endif if (!strcmp(b.foo(),"dBaz::foo")) error endif swig-3.0.2/Examples/test-suite/octave/swigobject_runme.m0000664000175000017500000000052612343605122023237 0ustar williamwilliamswigobject a = A(); a1 = a_ptr(a); a2 = a_ptr(a); if (swig_this(a1) != swig_this(a2)) error endif lthis = uint64(swig_this(a.this)); xstr1 = printf("0x%x",lthis); xstr2 = pointer_str(a); if (xstr1 != xstr2) error endif s = str(a.this); r = repr(a.this); v1 = v_ptr(a); v2 = v_ptr(a); if (uint64(v1) != uint64(v2)) error endif swig-3.0.2/Examples/test-suite/octave/abstract_typedef2_runme.m0000664000175000017500000000004612343605122024501 0ustar williamwilliamabstract_typedef2 a = A_UF(); swig-3.0.2/Examples/test-suite/octave/wrapmacro_runme.m0000664000175000017500000000017712343605122023074 0ustar williamwilliamwrapmacro a = 2; b = -1; wrapmacro.maximum(a,b); wrapmacro.maximum(a/7.0, -b*256); wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1); swig-3.0.2/Examples/test-suite/octave/li_std_set_runme.m0000664000175000017500000000200012343605122023215 0ustar williamwilliamli_std_set s = set_string() s.append("a") s.append("b") s.append("c") sum = "" for i in s: sum = sum + i if (sum != "abc") error i = s.__iter__() if i.next() != "a": error if i.next() != "b": error if i.next() != "c": error b = s.begin() e = s.end() sum = "" while (b != e): sum = sum + b.next() if sum != "abc": error b = s.rbegin() e = s.rend() sum = "" while (b != e): sum = sum + b.next() if sum != "cba": error si = set_int() si.append(1) si.append(2) si.append(3) i = si.__iter__() if i.next() != 1: error if i.next() != 2: error if i.next() != 3: error i = s.begin() i.next() s.erase(i) b = s.begin() e = s.end() sum = "" while (b != e): sum = sum + b.next() if sum != "ac": error b = s.begin() e = s.end() if e - b != 2: error m = b + 1 if m.value() != "c": error s = pyset() s.insert((1,2)) s.insert(1) s.insert("hello") sum = () for i in s: sum = sum + (i,) if sum != (1, 'hello', (1, 2)): error swig-3.0.2/Examples/test-suite/octave/li_std_string_extra_runme.m0000664000175000017500000000661312343605122025151 0ustar williamwilliamli_std_string_extra x="hello"; if (li_std_string_extra.test_ccvalue(x) != x) error("bad string mapping") endif if (li_std_string_extra.test_cvalue(x) != x) error("bad string mapping") endif if (li_std_string_extra.test_value(x) != x) error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x)) endif if (li_std_string_extra.test_const_reference(x) != x) error("bad string mapping") endif s = li_std_string_extra.string("he"); #s += "ll" #s.append("ll") s = s + "llo"; if (s != x) error("bad string mapping: %s, %s", s, x); endif #if (s(1:4) != x(1:4)) # error("bad string mapping") #endif if (li_std_string_extra.test_value(s) != x) error("bad string mapping") endif if (li_std_string_extra.test_const_reference(s) != x) error("bad string mapping") endif a = li_std_string_extra.A(s); if (li_std_string_extra.test_value(a) != x) error("bad string mapping") endif if (li_std_string_extra.test_const_reference(a) != x) error("bad string mapping") endif b = li_std_string_extra.string(" world"); s = a + b; if (a + b != "hello world") error("bad string mapping: %s", a + b) endif if (a + " world" != "hello world") error("bad string mapping") endif #if ("hello" + b != "hello world") # error("bad string mapping") #endif c = (li_std_string_extra.string("hello") + b); if (c.find_last_of("l") != 9) error("bad string mapping") endif s = "hello world"; b = li_std_string_extra.B("hi"); b.name = li_std_string_extra.string("hello"); if (b.name != "hello") error("bad string mapping") endif b.a = li_std_string_extra.A("hello"); if (b.a != "hello") error("bad string mapping") endif if (li_std_string_extra.test_value_basic1(x) != x) error("bad string mapping") endif if (li_std_string_extra.test_value_basic2(x) != x) error("bad string mapping") endif if (li_std_string_extra.test_value_basic3(x) != x) error("bad string mapping") endif # Global variables s = "initial string"; if (li_std_string_extra.cvar.GlobalString2 != "global string 2") error("GlobalString2 test 1") endif li_std_string_extra.cvar.GlobalString2 = s; if (li_std_string_extra.cvar.GlobalString2 != s) error("GlobalString2 test 2") endif if (li_std_string_extra.cvar.ConstGlobalString != "const global string") error("ConstGlobalString test") endif # Member variables myStructure = li_std_string_extra.Structure(); if (myStructure.MemberString2 != "member string 2") error("MemberString2 test 1") endif myStructure.MemberString2 = s; if (myStructure.MemberString2 != s) error("MemberString2 test 2") endif if (myStructure.ConstMemberString != "const member string") error("ConstMemberString test") endif if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2") error("StaticMemberString2 test 1") endif li_std_string_extra.cvar.Structure_StaticMemberString2 = s; if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s) error("StaticMemberString2 test 2") endif if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string") error("ConstStaticMemberString test") endif if (li_std_string_extra.test_reference_input("hello") != "hello") error endif s = li_std_string_extra.test_reference_inout("hello"); if (s != "hellohello") error endif if (li_std_string_extra.stdstring_empty() != "") error endif if (li_std_string_extra.c_empty() != "") error endif #if (li_std_string_extra.c_null() != None) # error #endif swig-3.0.2/Examples/test-suite/octave/template_typedef_cplx4_runme.m0000664000175000017500000000064712343605122025550 0ustar williamwilliamtemplate_typedef_cplx4 # # this is OK # s = Sin(); s.get_base_value(); s.get_value(); s.get_arith_value(); my_func_r(s); make_Multiplies_double_double_double_double(s,s); z = CSin(); z.get_base_value(); z.get_value(); z.get_arith_value(); my_func_c(z); make_Multiplies_complex_complex_complex_complex(z,z); # # Here we fail # d = make_Identity_double(); my_func_r(d); c = make_Identity_complex(); my_func_c(c); swig-3.0.2/Examples/test-suite/octave/li_std_vector_enum_runme.m0000664000175000017500000000057012343605122024762 0ustar williamwilliamli_std_vector_enum function check(a, b) if (a != b) error("incorrect match"); endif end ev = EnumVector(); check(ev.nums(0), 10); check(ev.nums(1), 20); check(ev.nums(2), 30); it = ev.nums.begin(); v = it.value(); check(v, 10); it.next(); v = it.value(); check(v, 20); #expected = 10 #ev.nums.each do|val| # swig_assert(val == expected) # expected += 10 #end swig-3.0.2/Examples/test-suite/octave/template_typedef_cplx3_runme.m0000664000175000017500000000065012343605122025541 0ustar williamwilliamtemplate_typedef_cplx3 # # this is OK # s = Sin(); s.get_base_value(); s.get_value(); s.get_arith_value(); my_func_r(s); make_Multiplies_double_double_double_double(s,s); z = CSin(); z.get_base_value(); z.get_value(); z.get_arith_value(); my_func_c(z); make_Multiplies_complex_complex_complex_complex(z,z); # # Here we fail # d = make_Identity_double(); my_func_r(d); c = make_Identity_complex(); my_func_c(c); swig-3.0.2/Examples/test-suite/octave/varargs_runme.m0000664000175000017500000000060212343605122022537 0ustar williamwilliamvarargs if (!strcmp(varargs.test("Hello"),"Hello")) error("Failed") endif f = varargs.Foo("Greetings"); if (!strcmp(f.str,"Greetings")) error("Failed") endif if (!strcmp(f.test("Hello"),"Hello")) error("Failed") endif if (!strcmp(varargs.test_def("Hello",1),"Hello")) error("Failed") endif if (!strcmp(varargs.test_def("Hello"),"Hello")) error("Failed") endif swig-3.0.2/Examples/test-suite/octave/voidtest_runme.m0000664000175000017500000000075112343605122022740 0ustar williamwilliamvoidtest voidtest.globalfunc(); f = voidtest.Foo(); f.memberfunc(); voidtest.Foo_staticmemberfunc(); function fvoid() end try a = f.memberfunc(); catch end_try_catch try a = fvoid(); catch end_try_catch v1 = voidtest.vfunc1(f); v2 = voidtest.vfunc2(f); if (swig_this(v1) != swig_this(v2)) error endif v3 = voidtest.vfunc3(v1); if (swig_this(v3) != swig_this(f)) error endif v4 = voidtest.vfunc1(f); if (swig_this(v4) != swig_this(v1)) error endif v3.memberfunc(); swig-3.0.2/Examples/test-suite/octave/smart_pointer_overload_runme.m0000664000175000017500000000043412343605122025656 0ustar williamwilliamsmart_pointer_overload f = Foo(); b = Bar(f); if (f.test(3) != 1) error endif if (f.test(3.5) != 2) error endif if (f.test("hello") != 3) error endif if (b.test(3) != 1) error endif if (b.test(3.5) != 2) error endif if (b.test("hello") != 3) error endif swig-3.0.2/Examples/test-suite/octave/types_directive_runme.m0000664000175000017500000000050412343605122024275 0ustar williamwilliamtypes_directive d1 = Time1(2001, 2, 3, 60); newDate = add(d1, 7); # check that a Time1 instance is accepted where Date is expected if (newDate.day != 10) error endif d2 = Time2(1999, 8, 7, 60); newDate = add(d2, 7); # check that a Time2 instance is accepted where Date is expected if (newDate.day != 14) error endif swig-3.0.2/Examples/test-suite/octave/virtual_derivation_runme.m0000664000175000017500000000020112343605122024777 0ustar williamwilliamvirtual_derivation # # very innocent example # b = B(3); if (b.get_a() != b.get_b()) error("something is really wrong") endif swig-3.0.2/Examples/test-suite/octave/octave_empty.c0000664000175000017500000000021112343605122022345 0ustar williamwilliam/* empty C file for the Octave test-suite C tests is needed - build system workaround as the generated files for Octave are C++ files */ swig-3.0.2/Examples/test-suite/octave/director_abstract_runme.m0000664000175000017500000000174112343605122024575 0ustar williamwilliamdirector_abstract MyFoo=@() subclass(director_abstract.Foo(),@ping); function out=ping(self) out="MyFoo::ping()"; end a = MyFoo(); if (!strcmp(a.ping(),"MyFoo::ping()")) error(a.ping()) endif if (!strcmp(a.pong(),"Foo::pong();MyFoo::ping()")) error(a.pong()) endif MyExample1=@() subclass(director_abstract.Example1(),'Color',@(self,r,g,b) r); MyExample2=@(a,b) subclass(director_abstract.Example2(a,b),'Color',@(self,r,g,b) g); MyExample3=@() subclass(director_abstract.Example3_i(),'Color',@(self,r,g,b) b); me1 = MyExample1(); if (director_abstract.Example1.get_color(me1, 1,2,3) != 1) error endif me2 = MyExample2(1,2); if (me2.get_color(me2, 1,2,3) != 2) error endif me3 = MyExample3(); if (me3.get_color(me3, 1,2,3) != 3) error endif # don't check that we cannot construct abstract bases, since we have no # way of disambiguating that with the normal construction case using # subclass. furthermore, calling a pure virtual method will still generate # an error. swig-3.0.2/Examples/test-suite/octave/struct_value_runme.m0000664000175000017500000000017212343605122023614 0ustar williamwilliamstruct_value b = struct_value.Bar(); b.a.x = 3; if (b.a.x != 3) error endif b.b.x = 3; if (b.b.x != 3) error endif swig-3.0.2/Examples/test-suite/octave/li_cwstring_runme.m0000664000175000017500000000115012343605122023415 0ustar williamwilliamli_cwstring if (count("ab\0ab\0ab\0", 0) != 3) error endif if (!strcmp(test1(),"Hello World")) error endif if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_")) error endif if (!strcmp(test3("hello"),"hello-suffix")) error endif if (!strcmp(test4("hello"),"hello-suffix")) error endif if (!strcmp(test5(4),'xxxx')) error endif if (!strcmp(test6(10),'xxxxx')) error endif if (!strcmp(test7(),"Hello world!")) error endif if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_")) error endif swig-3.0.2/Examples/test-suite/octave/director_frob_runme.m0000664000175000017500000000015512343605122023720 0ustar williamwilliamdirector_frob foo = Bravo(); s = foo.abs_method(); if (!strcmp(s,"Bravo::abs_method()")) error(s) endif swig-3.0.2/Examples/test-suite/octave/smart_pointer_typedef_runme.m0000664000175000017500000000023612343605122025503 0ustar williamwilliamsmart_pointer_typedef f = Foo(); b = Bar(f); b.x = 3; if (b.getx() != 3) error endif fp = b.__deref__(); fp.x = 4; if (fp.getx() != 4) error endif swig-3.0.2/Examples/test-suite/octave/typename_runme.m0000664000175000017500000000033112343605122022713 0ustar williamwilliamtypename f = typename.Foo(); b = typename.Bar(); x = typename.twoFoo(f); if (x == floor(x)) error("Wrong return type!") endif y = typename.twoBar(b); if (y != floor(y)) error("Wrong return type!") endif swig-3.0.2/Examples/test-suite/octave/template_typedef_import_runme.m0000664000175000017500000000067512343605122026031 0ustar williamwilliamtemplate_typedef_cplx2 template_typedef_import # # this is OK # s = Sin(); s.get_base_value(); s.get_value(); s.get_arith_value(); my_func_r(s); make_Multiplies_double_double_double_double(s,s); z = CSin(); z.get_base_value(); z.get_value(); z.get_arith_value(); my_func_c(z); make_Multiplies_complex_complex_complex_complex(z,z); # # Here we fail # d = make_Identity_double(); my_func_r(d); c = make_Identity_complex(); my_func_c(c); swig-3.0.2/Examples/test-suite/octave/multi_import_runme.m0000664000175000017500000000043412343605122023621 0ustar williamwilliammulti_import_a; multi_import_b; x = multi_import_b.XXX(); if (x.testx() != 0) error endif y = multi_import_b.YYY(); if (y.testx() != 0) error endif if (y.testy() != 1) error endif z = multi_import_a.ZZZ(); if (z.testx() != 0) error endif if (z.testz() != 2) error endif swig-3.0.2/Examples/test-suite/octave/grouping_runme.m0000664000175000017500000000027412343605122022731 0ustar williamwilliamgrouping x = grouping.test1(42); if (x != 42) error endif grouping.test2(42); x = (grouping.do_unary(37, grouping.NEGATE)); if (x != -37) error endif grouping.cvar.test3 = 42; swig-3.0.2/Examples/test-suite/octave/director_enum_runme.m0000664000175000017500000000031312343605122023730 0ustar williamwilliamdirector_enum MyFoo=@() subclass(director_enum.Foo(),'say_hi',@(self,val) val); b = director_enum.Foo(); a = MyFoo(); if (a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi)) error endif swig-3.0.2/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m0000664000175000017500000000035212343605122027546 0ustar williamwilliamsmart_pointer_templatevariables d = DiffImContainerPtr_D(create(1234, 5678)); if (d.id != 1234) error endif #if (d.xyz != 5678): # error d.id = 4321; #d.xyz = 8765 if (d.id != 4321) error endif #if (d.xyz != 8765): # error swig-3.0.2/Examples/test-suite/octave/director_detect_runme.m0000664000175000017500000000122312343605122024235 0ustar williamwilliamdirector_detect global MyBar=@(val=2) \ subclass(director_detect.Bar(),'val',val,@get_value,@get_class,@just_do_it,@clone); function val=get_value(self) self.val = self.val + 1; val = self.val; end function ptr=get_class(self) global director_detect; self.val = self.val + 1; ptr=director_detect.A(); end function just_do_it(self) self.val = self.val + 1; end function ptr=clone(self) global MyBar; ptr=MyBar(self.val); end b = MyBar(); f = b.baseclass(); v = f.get_value(); a = f.get_class(); f.just_do_it(); c = b.clone(); vc = c.get_value(); if ((v != 3) || (b.val != 5) || (vc != 6)) error("Bad virtual detection") endif swig-3.0.2/Examples/test-suite/octave/null_pointer_runme.m0000664000175000017500000000004112343605122023601 0ustar williamwilliamnull_pointer; assert(func([])); swig-3.0.2/Examples/test-suite/octave/li_factory_runme.m0000664000175000017500000000030112343605122023221 0ustar williamwilliamli_factory circle = Geometry_create(Geometry.CIRCLE); r = circle.radius(); if (r != 1.5) error endif point = Geometry_create(Geometry.POINT); w = point.width(); if (w != 1.0) error endif swig-3.0.2/Examples/test-suite/octave/default_constructor_runme.m0000664000175000017500000000255612343605122025175 0ustar williamwilliamdefault_constructor dc = default_constructor; a = dc.new_A(); dc.delete_A(a); aa = dc.new_AA(); dc.delete_AA(aa); try b = dc.new_B(); error("Whoa. new_BB created.") catch end_try_catch del_b = dc.delete_B; try bb = dc.new_BB(); error("Whoa. new_BB created.") catch end_try_catch del_bb = dc.delete_BB; try c = dc.new_C(); error("Whoa. new_C created.") catch end_try_catch del_c = dc.delete_C; cc = dc.new_CC(); dc.delete_CC(cc); try d = dc.new_D(); error("Whoa. new_D created") catch end_try_catch del_d = dc.delete_D; try dd = dc.new_DD(); error("Whoa. new_DD created") catch end_try_catch dd = dc.delete_DD; try ad = dc.new_AD(); error("Whoa. new_AD created") catch end_try_catch del_ad = dc.delete_AD; e = dc.new_E(); dc.delete_E(e); ee = dc.new_EE(); dc.delete_EE(ee); try eb = dc.new_EB(); error("Whoa. new_EB created") catch end_try_catch del_eb = dc.delete_EB; f = dc.new_F(); try del_f = dc.delete_F; error("Whoa. delete_F created") catch end_try_catch dc.F_destroy(f); ff = dc.new_FFF(); try del_ff = dc.delete_FFF; error("Whoa. delete_FFF created") catch end_try_catch dc.F_destroy(ff); g = dc.new_G(); try del_g = dc.delete_G; error("Whoa. delete_G created") catch end_try_catch dc.G_destroy(g); gg = dc.new_GG(); dc.delete_GG(gg); hh = default_constructor.HH(1,1); swig-3.0.2/Examples/test-suite/octave/li_cmalloc_runme.m0000664000175000017500000000024012343605122023166 0ustar williamwilliamli_cmalloc p = malloc_int(); free_int(p); ok = 0; try p = calloc_int(-1); free_int(p); catch ok = 1; end_try_catch if (ok != 1) error endif swig-3.0.2/Examples/test-suite/octave/sneaky1_runme.m0000664000175000017500000000015012343605122022443 0ustar williamwilliamsneaky1 x = sneaky1.add(3,4); y = sneaky1.subtract(3,4); z = sneaky1.mul(3,4); w = sneaky1.divide(3,4); swig-3.0.2/Examples/test-suite/octave/refcount_runme.m0000664000175000017500000000023112343605122022715 0ustar williamwilliamrefcount # # very innocent example # a = A3(); b1 = B(a); b2 = B.create(a); if (a.ref_count() != 3) error("This program will crash... now") endif swig-3.0.2/Examples/test-suite/octave/smart_pointer_rename_runme.m0000664000175000017500000000024212343605122025307 0ustar williamwilliamsmart_pointer_rename f = Foo(); b = Bar(f); if (b.test() != 3) error endif if (b.ftest1(1) != 1) error endif if (b.ftest2(2,3) != 2) error endif swig-3.0.2/Examples/test-suite/octave/director_basic_runme.m0000664000175000017500000000330612343605122024052 0ustar williamwilliamdirector_basic function self=OctFoo() global director_basic; self=subclass(director_basic.Foo()); self.ping=@OctFoo_ping; end function string=OctFoo_ping(self) string="OctFoo::ping()"; end a = OctFoo(); if (!strcmp(a.ping(),"OctFoo::ping()")) error(a.ping()) endif if (!strcmp(a.pong(),"Foo::pong();OctFoo::ping()")) error(a.pong()) endif b = director_basic.Foo(); if (!strcmp(b.ping(),"Foo::ping()")) error(b.ping()) endif if (!strcmp(b.pong(),"Foo::pong();Foo::ping()")) error(b.pong()) endif a = director_basic.A1(1); if (a.rg(2) != 2) error endif function self=OctClass() global director_basic; self=subclass(director_basic.MyClass()); self.method=@OctClass_method; self.vmethod=@OctClass_vmethod; end function OctClass_method(self,vptr) self.cmethod = 7; end function out=OctClass_vmethod(self,b) b.x = b.x + 31; out=b; end b = director_basic.Bar(3); d = director_basic.MyClass(); c = OctClass(); cc = director_basic.MyClass_get_self(c); dd = director_basic.MyClass_get_self(d); bc = cc.cmethod(b); bd = dd.cmethod(b); cc.method(b); if (c.cmethod != 7) error endif if (bc.x != 34) error endif if (bd.x != 16) error endif function self=OctMulti() global director_basic; self=subclass(director_basic.Foo(),director_basic.MyClass()); self.vmethod=@OctMulti_vmethod; self.ping=@OctMulti_ping; end function out=OctMulti_vmethod(self,b) b.x = b.x + 31; out=b; end function out=OctMulti_ping(self) out="OctFoo::ping()"; end a = 0; for i=0:100, octmult = OctMulti(); octmult.pong(); clear octmult endfor octmult = OctMulti(); p1 = director_basic.Foo_get_self(octmult); p2 = director_basic.MyClass_get_self(octmult); p1.ping(); p2.vmethod(bc); swig-3.0.2/Examples/test-suite/octave/naturalvar_runme.m0000664000175000017500000000016312343605122023253 0ustar williamwilliamnaturalvar f = Foo(); b = Bar(); b.f = f; cvar.s = "hello"; b.s = "hello"; if (b.s != cvar.s) error endif swig-3.0.2/Examples/test-suite/octave/director_wstring_runme.m0000664000175000017500000000052612343605122024467 0ustar williamwilliamdirector_wstring B=@(string) subclass(A(string),\ 'get_first',A.get_first(self) + " world!",\ 'process_text',@(self) self.smem = u"hello"\ ); b = B("hello"); b.get(0); if (!strcmp(b.get_first(),"hello world!")) error(b.get_first()) endif b.call_process_func(); if (!strcmp(b.smem,"hello")) error(smem) endif swig-3.0.2/Examples/test-suite/octave/std_containers_runme.m0000664000175000017500000000365712343605122024126 0ustar williamwilliamstd_containers cube = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}; icube = std_containers.cident(cube); for i=len(cube), if (cube{i} != icube{i}) error("bad cident") endif endfor p = {1,2}; if (p != std_containers.pident(p)) error("bad pident") endif v = {1,2,3,4,5,6}; iv = std_containers.vident(v); for i=0:len(v), if (v{i} != iv{i}) error("bad vident") endif endfor iv = std_containers.videntu(v); for i=0:len(v), if (v{i} != iv{i}) error("bad videntu") endif endfor vu = std_containers.vector_ui(v); if (vu{2} != std_containers.videntu(vu){2}) error("bad videntu") endif if (v(0:3)(1) != vu(0:3)(1)) error("bad getslice") endif m = {[1,2,3],[2,3],[3,4]}; im = std_containers.midenti(m); for i=0:len(m), for j=0:len(m(i)), if (m(i)(j) != im(i)(j)) error("bad getslice") endif endfor endfor m = {[1,0,1],[1,1],[1,1]}; im = std_containers.midentb(m); for i=0:len(m), for j in range(0,len(m[i])): if (m(i)(j) != im(i)(j)) error("bad getslice") endif endfor endfor mi = std_containers.imatrix(m); mc = std_containers.cmatrix(m); if (mi(0)(1) != mc(0)(1)) error("bad matrix") endif map ={}; map{'hello'} = 1; map{'hi'} = 2; map{'3'} = 2; imap = std_containers.mapident(map); for k in map, if (map(k) != imap(k)) error("bad map") endif endfor mapc ={}; c1 = std_containers.C(); c2 = std_containers.C(); mapc(1) = swig_this(c1); mapc(2) = c2; std_containers.mapidentc(mapc); vi = std_containers.vector_i([2,2,3,4]); v = [1,2]; v1 = std_containers.v_inout(vi); vi(1), v1(1); [v1,v2] = std_containers.v_inout2(v1,v2); a1 = std_containers.A(1); a2 = std_containers.A(2); p1 = {1,a1}; p2 = {2,a2}; v = (p1,p2); v2= std_containers.pia_vident(v); v2(0)(1).a; v2(1)(1).a; v3 = std_containers.vector_piA(v2); v3(0)(1).a; v3(1)(1).a; s = std_containers.set_i(); s.append(1); s.append(2); s.append(3); j=1; for i in s, if (i != j) error endif j = j + 1; endfor swig-3.0.2/Examples/test-suite/octave/global_ns_arg_runme.m0000664000175000017500000000005212343605122023662 0ustar williamwilliamglobal_ns_arg a = foo(1); b = bar_fn(); swig-3.0.2/Examples/test-suite/octave/director_stl_runme.m0000664000175000017500000000064712343605122023600 0ustar williamwilliamdirector_stl MyFoo=@() subclass(director_stl.Foo(),\ 'ping',@(self,s) "MyFoo::ping():" + s,\ 'pident',@(self,arg) arg,\ 'vident',@(self,v) v,\ 'vidents',@(self,v) v,\ 'vsecond',@(self,v1,v2) v2,\ ); a = MyFoo(); a.tping("hello"); a.tpong("hello"); p = {1,2} a.pident(p); v = {3,4} a.vident(v); a.tpident(p); a.tvident(v); v1 = {3,4}; v2 = {5,6}; a.tvsecond(v1,v2); vs=("hi", "hello"); vs; a.tvidents(vs); swig-3.0.2/Examples/test-suite/octave/samename_runme.m0000664000175000017500000000001112343605122022652 0ustar williamwilliamsamename swig-3.0.2/Examples/test-suite/octave/iadd_runme.m0000664000175000017500000000012712343605122021775 0ustar williamwilliamiadd f = iadd.Foo(); f.AsA.x = 3; f.AsA += f.AsA; if (f.AsA.x != 6) error endif swig-3.0.2/Examples/test-suite/octave/namespace_class_runme.m0000664000175000017500000000056112343605122024217 0ustar williamwilliamnamespace_class try p = Private1(); ok = 1; catch ok = 0; end_try_catch if (ok) error("Private1 is private") endif try p = Private2(); ok = 1; catch ok = 0; end_try_catch if (ok) error("Private2 is private") endif EulerT3D.toFrame(1,1,1); b = BooT_i(); b = BooT_H(); f = FooT_i(); f.quack(1); f = FooT_d(); f.moo(1); f = FooT_H(); f.foo(Hi); swig-3.0.2/Examples/test-suite/octave/array_member_runme.m0000664000175000017500000000057312343605122023546 0ustar williamwilliamarray_member f = Foo(); f.data = cvar.global_data; for i=0:7, if (get_value(f.data,i) != get_value(cvar.global_data,i)) error("Bad array assignment"); endif endfor for i=0:7, set_value(f.data,i,-i); endfor cvar.global_data = f.data; for i=0:7, if (get_value(f.data,i) != get_value(cvar.global_data,i)) error("Bad array assignment") endif endfor swig-3.0.2/Examples/test-suite/octave/director_default_runme.m0000664000175000017500000000010412343605122024406 0ustar williamwilliamdirector_default f = Foo(); f = Foo(1); f = Bar(); f = Bar(1); swig-3.0.2/Examples/test-suite/octave/director_nested_runme.m0000664000175000017500000000175212343605122024256 0ustar williamwilliamdirector_nested A=@() subclass(FooBar_int(), 'do_step',@(self) "A::do_step;", 'get_value',@(self) "A::get_value"); a = A(); if (!strcmp(a.step(),"Bar::step;Foo::advance;Bar::do_advance;A::do_step;")) error("Bad A virtual resolution") endif B=@() subclass(FooBar_int(), 'do_advance',@(self) strcat("B::do_advance;",self.do_step()), 'do_step',@(self) "B::do_step;", 'get_value',@(self) 1); b = B(); if (!strcmp(b.step(),"Bar::step;Foo::advance;B::do_advance;B::do_step;")) error("Bad B virtual resolution") endif C=@() subclass(FooBar_int(), 'do_advance',@(self) strcat("C::do_advance;",self.FooBar_int.do_advance()), 'do_step',@(self) "C::do_step;", 'get_value',@(self) 2, 'get_name',@(self) strcat(self.FooBar_int.get_name()," hello")); cc = C(); c = FooBar_int_get_self(cc); c.advance(); if (!strcmp(c.get_name(),"FooBar::get_name hello")) error endif if (!strcmp(c.name(),"FooBar::get_name hello")) error endif swig-3.0.2/Examples/test-suite/octave/inout_runme.m0000664000175000017500000000046112343605122022233 0ustar williamwilliaminout a = inout.AddOne1(1); if (a != 2) error endif a = inout.AddOne3(1,1,1); if (a != [2,2,2]) error endif a = inout.AddOne1p((1,1)); if (a != (2,2)) error endif a = inout.AddOne2p((1,1),1); if (a != [(2,2),2]) error endif a = inout.AddOne3p(1,(1,1),1); if (a != [2,(2,2),2]) error endif swig-3.0.2/Examples/test-suite/octave/li_cpointer_runme.m0000664000175000017500000000015312343605122023402 0ustar williamwilliamli_cpointer p = new_intp(); intp_assign(p,3); if (intp_value(p) != 3) error endif delete_intp(p); swig-3.0.2/Examples/test-suite/octave/template_type_namespace_runme.m0000664000175000017500000000013512343605122025763 0ustar williamwilliamtemplate_type_namespace assert(strcmp(foo()(1),"foo")); swig-3.0.2/Examples/test-suite/octave/template_matrix_runme.m0000664000175000017500000000016112343605122024271 0ustar williamwilliamtemplate_matrix passVector([1,2,3]); passMatrix({[1,2],[1,2,3]}); passCube({{[1,2],[1,2,3]},{[1,2],[1,2,3]}}); swig-3.0.2/Examples/test-suite/octave/overload_extendc_runme.m0000664000175000017500000000063112343605122024421 0ustar williamwilliamoverload_extendc f = overload_extendc.Foo(); if (f.test(3) != 1) error endif if (f.test("hello") != 2) error endif if (f.test(3.5,2.5) != 3) error endif if (f.test("hello",20) != 1020) error endif if (f.test("hello",20,100) != 120) error endif # C default args if (f.test(f) != 30) error endif if (f.test(f,100) != 120) error endif if (f.test(f,100,200) != 300) error endif swig-3.0.2/Examples/test-suite/octave/director_string_runme.m0000664000175000017500000000071012343605122024273 0ustar williamwilliamdirector_string function out=get_first(self) out = strcat(self.A.get_first()," world!"); end function process_text(self,string) self.A.process_text(string); self.smem = "hello"; end B=@(string) subclass(A(string),'get_first',@get_first,'process_text',@process_text); b = B("hello"); b.get(0); if (!strcmp(b.get_first(),"hello world!")) error(b.get_first()) endif b.call_process_func(); if (!strcmp(b.smem,"hello")) error(b.smem) endif swig-3.0.2/Examples/test-suite/octave/template_ref_type_runme.m0000664000175000017500000000013012343605122024576 0ustar williamwilliamtemplate_ref_type xr = template_ref_type.XC(); y = template_ref_type.Y(); y.find(xr); swig-3.0.2/Examples/test-suite/octave/inplaceadd_runme.m0000664000175000017500000000030012343605122023151 0ustar williamwilliaminplaceadd a = inplaceadd.A(7); a += 5; if (a.val != 12) error endif a -= 5; if a.val != 7: error endif a *= 2; if (a.val != 14) error endif a += a; if (a.val != 28) error endif swig-3.0.2/Examples/test-suite/octave/li_carrays_runme.m0000664000175000017500000000014512343605122023224 0ustar williamwilliamli_carrays d = doubleArray(10); d(0) = 7; d(5) = d(0) + 3; if (d(5) + d(0) != 17) error endif swig-3.0.2/Examples/test-suite/octave/unions_runme.m0000664000175000017500000000231612343605122022411 0ustar williamwilliam # This is the union runtime testcase. It ensures that values within a # union embedded within a struct can be set and read correctly. unions # Create new instances of SmallStruct and BigStruct for later use small = unions.SmallStruct(); small.jill = 200; big = unions.BigStruct(); big.smallstruct = small; big.jack = 300; # Use SmallStruct then BigStruct to setup EmbeddedUnionTest. # Ensure values in EmbeddedUnionTest are set correctly for each. eut = unions.EmbeddedUnionTest(); # First check the SmallStruct in EmbeddedUnionTest eut.number = 1; eut.uni.small = small; Jill1 = eut.uni.small.jill; if (Jill1 != 200) error("Runtime test1 failed. eut.uni.small.jill=%i" , Jill1) endif Num1 = eut.number; if (Num1 != 1) error("Runtime test2 failed. eut.number=%i" , Num1) endif # Secondly check the BigStruct in EmbeddedUnionTest eut.number = 2; eut.uni.big = big; Jack1 = eut.uni.big.jack; if (Jack1 != 300) error("Runtime test3 failed. eut.uni.big.jack=%i" , Jack1) endif Jill2 = eut.uni.big.smallstruct.jill; if (Jill2 != 200) error("Runtime test4 failed. eut.uni.big.smallstruct.jill=%i" , Jill2) endif Num2 = eut.number; if (Num2 != 2) error("Runtime test5 failed. eut.number=%i" , Num2) endif swig-3.0.2/Examples/test-suite/octave/using_extend_runme.m0000664000175000017500000000060012343605122023564 0ustar williamwilliamusing_extend f = FooBar(); if (f.blah(3) != 3) error("blah(int)") endif if (f.blah(3.5) != 3.5) error("blah(double)") endif if (!strcmp(f.blah("hello"),"hello")) error("blah(char *)") endif if (f.blah(3,4) != 7) error("blah(int,int)") endif if (f.blah(3.5,7.5) != (3.5+7.5)) error("blah(double,double)") endif if (f.duh(3) != 3) error("duh(int)") endif swig-3.0.2/Examples/test-suite/octave/friends_runme.m0000664000175000017500000000121412343605122022524 0ustar williamwilliamfriends a = friends.A(2); if (friends.get_val1(a) != 2) error endif if (friends.get_val2(a) != 4) error endif if (friends.get_val3(a) != 6) error endif # nice overload working fine if (friends.get_val1(1,2,3) != 1) error endif b = friends.B(3); # David's case if (friends.mix(a,b) != 5) error endif di = friends.D_d(2); dd = friends.D_d(3.3); # incredible template overloading working just fine if (friends.get_val1(di) != 2) error endif if (friends.get_val1(dd) != 3.3) error endif friends.set(di, 4); friends.set(dd, 1.3); if (friends.get_val1(di) != 4) error endif if (friends.get_val1(dd) != 1.3) error endif swig-3.0.2/Examples/test-suite/octave/complextest_runme.m0000664000175000017500000000045012343605122023442 0ustar williamwilliamcomplextest a = complex(-1,2); if (complextest.Conj(a) != a.conjugate()) error("bad complex mapping") endif if (complextest.Conjf(a) != a.conjugate()) error("bad complex mapping") endif v = (complex(1,2), complex(2,3), complex(4,3), 1); try complextest.Copy_h(v); catch end_try_catch swig-3.0.2/Examples/test-suite/octave/using1_runme.m0000664000175000017500000000006312343605122022301 0ustar williamwilliamusing1 if (using1.spam(37) != 37) error endif swig-3.0.2/Examples/test-suite/octave/typemap_ns_using_runme.m0000664000175000017500000000010712343605122024456 0ustar williamwilliamtypemap_ns_using if (typemap_ns_using.spam(37) != 37) error endif swig-3.0.2/Examples/test-suite/octave/cpp_namespace_runme.m0000664000175000017500000000221412343605122023671 0ustar williamwilliam# Note: This example assumes that namespaces are flattened cpp_namespace n = cpp_namespace.fact(4); if (n != 24) error("Bad return value!") endif if (cpp_namespace.cvar.Foo != 42) error("Bad variable value!") endif t = cpp_namespace.Test(); if (!strcmp(t.method(),"Test::method")) error("Bad method return value!") endif if (!strcmp(cpp_namespace.do_method(t),"Test::method")) error("Bad return value!") endif if (!strcmp(cpp_namespace.do_method2(t),"Test::method")) error("Bad return value!") endif cpp_namespace.weird("hello", 4); clear t; t2 = cpp_namespace.Test2(); t3 = cpp_namespace.Test3(); t4 = cpp_namespace.Test4(); t5 = cpp_namespace.Test5(); if (cpp_namespace.foo3(42) != 42) error("Bad return value!") endif if (!strcmp(cpp_namespace.do_method3(t2,40),"Test2::method")) error("Bad return value!") endif if (!strcmp(cpp_namespace.do_method3(t3,40),"Test3::method")) error("Bad return value!") endif if (!strcmp(cpp_namespace.do_method3(t4,40),"Test4::method")) error("Bad return value!") endif if (!strcmp(cpp_namespace.do_method3(t5,40),"Test5::method")) error("Bad return value!") endif swig-3.0.2/Examples/test-suite/octave/overload_template_fast_runme.m0000664000175000017500000000625412343605122025626 0ustar williamwilliamoverload_template_fast # unless explicitly casted via {{u}int{8,16,32,64},double,single}, # octave will take numeric literals as doubles. f = foo(); a = maximum(3,4); b = maximum(3.4,5.2); # mix 1 if (mix1("hi") != 101) error("mix1(const char*)") endif if (mix1(1.1, 1.1) != 102) error("mix1(double, const double &)") endif if (mix1(1.1) != 103) error("mix1(double)") endif # mix 2 if (mix2("hi") != 101) error("mix2(const char*)") endif if (mix2(1.1, 1.1) != 102) error("mix2(double, const double &)") endif if (mix2(1.1) != 103) error("mix2(double)") endif # mix 3 if (mix3("hi") != 101) error("mix3(const char*)") endif if (mix3(1.1, 1.1) != 102) error("mix3(double, const double &)") endif if (mix3(1.1) != 103) error("mix3(double)") endif # Combination 1 if (overtparams1(100) != 10) error("overtparams1(int)") endif if (overtparams1(100.1, 100) != 20) error("overtparams1(double, int)") endif # Combination 2 if (overtparams2(100.1, 100) != 40) error("overtparams2(double, int)") endif # Combination 3 if (overloaded() != 60) error("overloaded()") endif if (overloaded(100.1, 100) != 70) error("overloaded(double, int)") endif # Combination 4 if (overloadedagain("hello") != 80) error("overloadedagain(const char *)") endif if (overloadedagain() != 90) error("overloadedagain(double)") endif # specializations if (specialization(10) != 202) error("specialization(int)") endif if (specialization(10.1) != 203) error("specialization(double)") endif if (specialization(10, 10) != 204) error("specialization(int, int)") endif if (specialization(10.1, 10.1) != 205) error("specialization(double, double)") endif if (specialization("hi", "hi") != 201) error("specialization(const char *, const char *)") endif # simple specialization xyz(); xyz_int(); xyz_double(); # a bit of everything if (overload("hi") != 0) error("overload()") endif if (overload(1) != 10) error("overload(int t)") endif if (overload(1, 1) != 20) error("overload(int t, const int &)") endif if (overload(1, "hello") != 30) error("overload(int t, const char *)") endif k = Klass(); if (overload(k) != 10) error("overload(Klass t)") endif if (overload(k, k) != 20) error("overload(Klass t, const Klass &)") endif if (overload(k, "hello") != 30) error("overload(Klass t, const char *)") endif if (overload(10.1, "hi") != 40) error("overload(double t, const char *)") endif if (overload() != 50) error("overload(const char *)") endif # everything put in a namespace if (nsoverload("hi") != 1000) error("nsoverload()") endif if (nsoverload(1) != 1010) error("nsoverload(int t)") endif if (nsoverload(1, 1) != 1020) error("nsoverload(int t, const int &)") endif if (nsoverload(1, "hello") != 1030) error("nsoverload(int t, const char *)") endif if (nsoverload(k) != 1010) error("nsoverload(Klass t)") endif if (nsoverload(k, k) != 1020) error("nsoverload(Klass t, const Klass &)") endif if (nsoverload(k, "hello") != 1030) error("nsoverload(Klass t, const char *)") endif if (nsoverload(10.1, "hi") != 1040) error("nsoverload(double t, const char *)") endif if (nsoverload() != 1050) error("nsoverload(const char *)") endif A.foo(1); b = B(); b.foo(1); swig-3.0.2/Examples/test-suite/octave/octave_cell_deref_runme.m0000664000175000017500000000020412343605122024515 0ustar williamwilliamoctave_cell_deref; assert(func("hello")); assert(func({"hello"})); c = func2(); assert(strcmp(c{1}, "hello")); assert(c{2} == 4); swig-3.0.2/Examples/test-suite/octave/smart_pointer_simple_runme.m0000664000175000017500000000023512343605122025333 0ustar williamwilliamsmart_pointer_simple f = Foo(); b = Bar(f); b.x = 3; if (b.getx() != 3) error endif fp = b.__deref__(); fp.x = 4; if (fp.getx() != 4) error endif swig-3.0.2/Examples/test-suite/octave/li_std_pair_extra_runme.m0000664000175000017500000000326312343605122024574 0ustar williamwilliamli_std_pair_extra p = {1,2}; p1 = li_std_pair_extra.p_inout(p); assert(all(cell2mat(p1)==[2,1])); p2 = li_std_pair_extra.p_inoutd(p1); assert(all(cell2mat(p2)==[1,2])); d1 = li_std_pair_extra.d_inout(2); assert(d1==4); [i,d2] = li_std_pair_extra.d_inout2(2); assert(all([i,d2]==[1,4])); [i,p] = li_std_pair_extra.p_inout2(p); assert(i==1&&all([cell2mat(p)]==[2,1])); [p3,p4] = li_std_pair_extra.p_inout3(p1,p1); assert(all(cell2mat(p3)==[2,1])); assert(all(cell2mat(p4)==[2,1])); psi = li_std_pair_extra.SIPair("hello",1); assert(psi=={"hello",1}); pci = li_std_pair_extra.CIPair(complex(1,2),1); assert(pci.first==complex(1,2)&&pci.second==1); psi = li_std_pair_extra.SIPair("hi",1); assert(psi.first=="hi"&&psi.second==1); psii = li_std_pair_extra.SIIPair(psi,1); assert(psii.first.first=="hi"); assert(psii.first.second==1); assert(psii.second==1); a = li_std_pair_extra.A(); b = li_std_pair_extra.B(); pab = li_std_pair_extra.ABPair(a,b); pab.first = a; pab.first.val = 2; assert(pab.first.val == 2); pci = li_std_pair_extra.CIntPair(1,0); assert(pci.first==1&&pci.second==0); a = li_std_pair_extra.A(5); p1 = li_std_pair_extra.pairP1(1,a); p2 = li_std_pair_extra.pairP2(a,1); p3 = li_std_pair_extra.pairP3(a,a); assert(a.val == li_std_pair_extra.p_identa(p1){2}.val); p = li_std_pair_extra.IntPair(1,10); assert(p.first==1&&p.second==10); p.first = 1; assert(p.first==1); p = li_std_pair_extra.paircA1(1,a); assert(p.first==1); assert(swig_this(p.second)==swig_this(a)); p = li_std_pair_extra.paircA2(1,a); assert(p.first==1); assert(swig_this(p.second)==swig_this(a)); #pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2 pp = li_std_pair_extra.pairiiA(1,{1,A()}); swig-3.0.2/Examples/test-suite/octave/template_rename_runme.m0000664000175000017500000000027712343605122024244 0ustar williamwilliamtemplate_rename i = template_rename.iFoo(); d = template_rename.dFoo(); a = i.blah_test(4); b = i.spam_test(5); c = i.groki_test(6); x = d.blah_test(7); y = d.spam(8); z = d.grok_test(9); swig-3.0.2/Examples/test-suite/octave/template_extend1_runme.m0000664000175000017500000000026212343605122024337 0ustar williamwilliamtemplate_extend1 a = template_extend1.lBaz(); b = template_extend1.dBaz(); if (!strcmp(a.foo(),"lBaz::foo")) error endif if (!strcmp(b.foo(),"dBaz::foo")) error endif swig-3.0.2/Examples/test-suite/octave/template_ns_runme.m0000664000175000017500000000035412343605122023411 0ustar williamwilliamtemplate_ns p1 = pairii(2,3); p2 = pairii(p1); if (p2.first != 2) error endif if (p2.second != 3) error endif p3 = pairdd(3.5,2.5); p4 = pairdd(p3); if (p4.first != 3.5) error endif if (p4.second != 2.5) error endif swig-3.0.2/Examples/test-suite/octave/ret_by_value_runme.m0000664000175000017500000000016612343605122023557 0ustar williamwilliamret_by_value a = ret_by_value.get_test(); if (a.myInt != 100) error endif if (a.myShort != 200) error endif swig-3.0.2/Examples/test-suite/octave/director_extend_runme.m0000664000175000017500000000027712343605122024264 0ustar williamwilliamdirector_extend MyObject=@() subclass(SpObject(),'getFoo',@(self) 123); m = MyObject(); if (m.dummy() != 666) error("1st call") endif if (m.dummy() != 666) error("2nd call") endif swig-3.0.2/Examples/test-suite/octave/profiletest_runme.m0000664000175000017500000000071012343605122023432 0ustar williamwilliamimport _profiletest import profiletest a = profiletest.A() print a print a.this b = profiletest.B() fn = b.fn i = 50000 while i: a = fn(a) #1 a = fn(a) #2 a = fn(a) #3 a = fn(a) #4 a = fn(a) #5 a = fn(a) #6 a = fn(a) #7 a = fn(a) #8 a = fn(a) #9 a = fn(a) #10 a = fn(a) #1 a = fn(a) #2 a = fn(a) #3 a = fn(a) #4 a = fn(a) #5 a = fn(a) #6 a = fn(a) #7 a = fn(a) #8 a = fn(a) #9 a = fn(a) #20 i -= 1 swig-3.0.2/Examples/test-suite/octave/contract_runme.m0000664000175000017500000000433012343605122022711 0ustar williamwilliamcontract contract.test_preassert(1,2); try contract.test_preassert(-1,0) error("Failed! Preassertions are broken") catch end_try_catch contract.test_postassert(3); try contract.test_postassert(-3); error("Failed! Postassertions are broken") catch end_try_catch contract.test_prepost(2,3); contract.test_prepost(5,-4); try contract.test_prepost(-3,4); error("Failed! Preassertions are broken") catch end_try_catch try contract.test_prepost(4,-10); error("Failed! Postassertions are broken") catch end_try_catch f = contract.Foo(); f.test_preassert(4,5); try f.test_preassert(-2,3); error("Failed! Method preassertion.") catch end_try_catch f.test_postassert(4); try f.test_postassert(-4); error("Failed! Method postassertion") catch end_try_catch f.test_prepost(3,4); f.test_prepost(4,-3); try f.test_prepost(-4,2); error("Failed! Method preassertion.") catch end_try_catch try f.test_prepost(4,-10); error("Failed! Method postassertion.") catch end_try_catch contract.Foo_stest_prepost(4,0); try contract.Foo_stest_prepost(-4,2); error("Failed! Static method preassertion") catch end_try_catch try contract.Foo_stest_prepost(4,-10); error("Failed! Static method posteassertion") catch end_try_catch b = contract.Bar(); try b.test_prepost(2,-4); error("Failed! Inherited preassertion.") catch end_try_catch d = contract.D(); try d.foo(-1,1,1,1,1); error("Failed! Inherited preassertion (D).") catch end_try_catch try d.foo(1,-1,1,1,1); error("Failed! Inherited preassertion (D).") catch end_try_catch try d.foo(1,1,-1,1,1); error("Failed! Inherited preassertion (D).") catch end_try_catch try d.foo(1,1,1,-1,1); error("Failed! Inherited preassertion (D).") catch end_try_catch try d.foo(1,1,1,1,-1); error("Failed! Inherited preassertion (D).") catch end_try_catch try d.bar(-1,1,1,1,1); error("Failed! Inherited preassertion (D).") catch end_try_catch try d.bar(1,-1,1,1,1); error("Failed! Inherited preassertion (D).") catch end_try_catch try d.bar(1,1,-1,1,1); error("Failed! Inherited preassertion (D).") catch end_try_catch try d.bar(1,1,1,-1,1); error("Failed! Inherited preassertion (D).") catch end_try_catch try d.bar(1,1,1,1,-1); error("Failed! Inherited preassertion (D).") catch end_try_catch swig-3.0.2/Examples/test-suite/octave/octave_dim_runme.m0000664000175000017500000000105712343605122023211 0ustar williamwilliamoctave_dim assert(all(size(Foo45a())==[4 5])); assert(all(size(Foo456a())==[4 5 6])); assert(all(size(Foo4a())==[4 1])); assert(all(size(Foo4b())==[4 1])); assert(all(size(Foo())==[1 1])); assert(all(size(Bar1())==[1 1])); assert(all(size(Bar2())==[1 1])); assert(all(size(Baz1())==[3 4])); assert(all(size(Baz2())==[3 4])); assert(all(size(Baz3())==[3 4])); assert(all(size(Baz4())==[3 4])); % Assertions will not work, but kept for future reference. %assert(all(size(Baz5())==[3 4])); %assert(all(size(Baz6())==[3 4])); %assert(all(size(Baz7())==[3 4])); swig-3.0.2/Examples/test-suite/octave/preproc_constants_runme.m0000664000175000017500000000102512343605122024640 0ustar williamwilliampreproc_constants assert(CONST_INT1, 10) assert(CONST_DOUBLE3, 12.3) assert(CONST_BOOL1, true) assert(CONST_CHAR, 'x') assert(CONST_STRING1, "const string") # Test global constants can be seen within functions function test_global() global CONST_INT1 global CONST_DOUBLE3 global CONST_BOOL1 global CONST_CHAR global CONST_STRING1 assert(CONST_INT1, 10) assert(CONST_DOUBLE3, 12.3) assert(CONST_BOOL1, true) assert(CONST_CHAR, 'x') assert(CONST_STRING1, "const string") endfunction test_global swig-3.0.2/Examples/test-suite/octave/template_ns4_runme.m0000664000175000017500000000011712343605122023472 0ustar williamwilliamtemplate_ns4 d = make_Class_DD(); if (!strcmp(d.test(),"test")) error endif swig-3.0.2/Examples/test-suite/octave/reference_global_vars_runme.m0000664000175000017500000000374412343605122025415 0ustar williamwilliamreference_global_vars # const class reference variable if (getconstTC().num != 33) error endif # primitive reference variables cvar.var_bool = createref_bool(false); if (value_bool(cvar.var_bool) != 0) error endif cvar.var_bool = createref_bool(true); if (value_bool(cvar.var_bool) != 1) error endif cvar.var_char = createref_char('w'); if (!strcmp(value_char(cvar.var_char),'w')) error endif cvar.var_unsigned_char = createref_unsigned_char(10); if (value_unsigned_char(cvar.var_unsigned_char) != 10) error endif cvar.var_signed_char = createref_signed_char(10); if (value_signed_char(cvar.var_signed_char) != 10) error endif cvar.var_short = createref_short(10); if (value_short(cvar.var_short) != 10) error endif cvar.var_unsigned_short = createref_unsigned_short(10); if (value_unsigned_short(cvar.var_unsigned_short) != 10) error endif cvar.var_int = createref_int(10); if (value_int(cvar.var_int) != 10) error endif cvar.var_unsigned_int = createref_unsigned_int(10); if (value_unsigned_int(cvar.var_unsigned_int) != 10) error endif cvar.var_long = createref_long(10); if (value_long(cvar.var_long) != 10) error endif cvar.var_unsigned_long = createref_unsigned_long(10); if (value_unsigned_long(cvar.var_unsigned_long) != 10) error endif cvar.var_long_long = createref_long_long(int64(0x6FFFFFFFFFFFFFF8)); if (value_long_long(cvar.var_long_long) != int64(0x6FFFFFFFFFFFFFF8)) error endif #ull = abs(0xFFFFFFF2FFFFFFF0) ull = uint64(55834574864); cvar.var_unsigned_long_long = createref_unsigned_long_long(ull); if (value_unsigned_long_long(cvar.var_unsigned_long_long) != ull) error endif cvar.var_float = createref_float(10.5); if (value_float(cvar.var_float) != 10.5) error endif cvar.var_double = createref_double(10.5); if (value_double(cvar.var_double) != 10.5) error endif # class reference variable cvar.var_TestClass = createref_TestClass(TestClass(20)); if (value_TestClass(cvar.var_TestClass).num != 20) error endif swig-3.0.2/Examples/test-suite/octave/li_std_vector_runme.m0000664000175000017500000000020412343605122023730 0ustar williamwilliamli_std_vector iv = IntVector(4); for i=0:3, iv(i) = i; endfor x = average(iv); if (x != 1.5) error("average failed"); endif swig-3.0.2/Examples/test-suite/octave/director_classic_runme.m0000664000175000017500000000455312343605122024417 0ustar williamwilliamdirector_classic TargetLangPerson=@() subclass(Person(),'id',@(self) "TargetLangPerson"); TargetLangChild=@() subclass(Child(),'id',@(self) "TargetLangChild"); TargetLangGrandChild=@() subclass(GrandChild(),'id',@(self) "TargetLangGrandChild"); # Semis - don't override id() in target language TargetLangSemiPerson=@() subclass(Person()); TargetLangSemiChild=@() subclass(Child()); TargetLangSemiGrandChild=@() subclass(GrandChild()); # Orphans - don't override id() in C++ TargetLangOrphanPerson=@() subclass(OrphanPerson(),'id',@(self) "TargetLangOrphanPerson"); TargetLangOrphanChild=@() subclass(OrphanChild(),'id',@(self) "TargetLangOrphanChild"); function check(person,expected) global Caller; # Normal target language polymorphic call ret = person.id(); if (ret != expected) raise ("Failed. Received: " + ret + " Expected: " + expected); endif # Polymorphic call from C++ caller = Caller(); caller.setCallback(person); ret = caller.call(); if (ret != expected) error ("Failed. Received: " + ret + " Expected: " + expected); endif # Polymorphic call of object created in target language and passed to C++ and back again baseclass = caller.baseClass(); ret = baseclass.id(); if (ret != expected) error ("Failed. Received: " + ret + " Expected: " + expected); endif caller.resetCallback(); end person = Person(); check(person, "Person"); clear person; person = Child(); check(person, "Child"); clear person; person = GrandChild(); check(person, "GrandChild"); clear person; person = TargetLangPerson(); check(person, "TargetLangPerson"); clear person; person = TargetLangChild(); check(person, "TargetLangChild"); clear person; person = TargetLangGrandChild(); check(person, "TargetLangGrandChild"); clear person; # Semis - don't override id() in target language person = TargetLangSemiPerson(); check(person, "Person"); clear person; person = TargetLangSemiChild(); check(person, "Child"); clear person; person = TargetLangSemiGrandChild(); check(person, "GrandChild"); clear person; # Orphans - don't override id() in C++ person = OrphanPerson(); check(person, "Person"); clear person; person = OrphanChild(); check(person, "Child"); clear person; person = TargetLangOrphanPerson(); check(person, "TargetLangOrphanPerson"); clear person; person = TargetLangOrphanChild(); check(person, "TargetLangOrphanChild"); clear person; swig-3.0.2/Examples/test-suite/octave/smart_pointer_not_runme.m0000664000175000017500000000072612343605122024647 0ustar williamwilliamsmart_pointer_not f = Foo(); b = Bar(f); s = Spam(f); g = Grok(f); try x = b.x; error("Error! b.x") catch end_try_catch try x = s.x; error("Error! s.x") catch end_try_catch try x = g.x; error("Error! g.x") catch end_try_catch try x = b.getx(); error("Error! b.getx()") catch end_try_catch try x = s.getx(); error("Error! s.getx()") catch end_try_catch try x = g.getx(); error("Error! g.getx()") catch end_try_catch swig-3.0.2/Examples/test-suite/octave/using_protected_runme.m0000664000175000017500000000013212343605122024266 0ustar williamwilliamusing_protected f = FooBar(); f.x = 3; if (f.blah(4) != 4) error("blah(int)") endif swig-3.0.2/Examples/test-suite/octave/abstract_virtual_runme.m0000664000175000017500000000004712343605122024446 0ustar williamwilliamabstract_virtual d = D(); e = E(); swig-3.0.2/Examples/test-suite/octave/constover_runme.m0000664000175000017500000000117212343605122023117 0ustar williamwilliamconstover p = constover.test("test"); if (!strcmp(p,"test")) error("test failed!") endif p = constover.test_pconst("test"); if (!strcmp(p,"test_pconst")) error("test_pconst failed!") endif f = constover.Foo(); p = f.test("test"); if (!strcmp(p,"test")) error("member-test failed!") endif p = f.test_pconst("test"); if (!strcmp(p,"test_pconst")) error("member-test_pconst failed!") endif p = f.test_constm("test"); if (!strcmp(p,"test_constmethod")) error("member-test_constm failed!") endif p = f.test_pconstm("test"); if (!strcmp(p,"test_pconstmethod")) error("member-test_pconstm failed!") endif swig-3.0.2/Examples/test-suite/octave/using_inherit_runme.m0000664000175000017500000000142112343605122023741 0ustar williamwilliamusing_inherit b = Bar(); if (b.test(3) != 3) error("Bar::test(int)") endif if (b.test(3.5) != 3.5) error("Bar::test(double)") endif b = Bar2(); if (b.test(3) != 6) error("Bar2::test(int)") endif if (b.test(3.5) != 7.0) error("Bar2::test(double)") endif b = Bar3(); if (b.test(3) != 6) error("Bar3::test(int)") endif if (b.test(3.5) != 7.0) error("Bar3::test(double)") endif b = Bar4(); if (b.test(3) != 6) error("Bar4::test(int)") endif if (b.test(3.5) != 7.0) error("Bar4::test(double)") endif b = Fred1(); if (b.test(3) != 3) error("Fred1::test(int)") endif if (b.test(3.5) != 7.0) error("Fred1::test(double)") endif b = Fred2(); if (b.test(3) != 3) error("Fred2::test(int)") endif if (b.test(3.5) != 7.0) error("Fred2::test(double)") endif swig-3.0.2/Examples/test-suite/octave/fvirtual_runme.m0000664000175000017500000000014512343605122022730 0ustar williamwilliamfvirtual sw = NodeSwitch(); n = Node(); i = sw.addChild(n); if (i != 2) error("addChild") endif swig-3.0.2/Examples/test-suite/octave/overload_subtype_runme.m0000664000175000017500000000017512343605122024465 0ustar williamwilliamoverload_subtype f = Foo(); b = Bar(); if (spam(f) != 1) error("foo") endif if (spam(b) != 2) error("bar") endif swig-3.0.2/Examples/test-suite/octave/input_runme.m0000664000175000017500000000030712343605122022233 0ustar williamwilliaminput f = Foo(); if (f.foo(2) != 4) error endif try a=f.foo(); error catch end_try_catch if (!strcmp(sfoo("Hello"),"Hello world")) error endif try a=sfoo(); error catch end_try_catch swig-3.0.2/Examples/test-suite/octave/li_std_carray_runme.m0000664000175000017500000000104512343605122023713 0ustar williamwilliamli_std_carray v3 = Vector3(); for i=0:len(v3), v3(i) = i; endfor i = 0; for d in v3, if (d != i) error endif i = i + 1; endfor m3 = Matrix3(); for i=0:len(m3), v3 = m3(i); for j=0:len(v3), v3(j) = i + j; endfor endfor i = 0; for v3 in m3, j = 0; for d in v3, if (d != i + j) error endif j = j + 1; endfor i = i + 1 endfor for i=0:len(m3), for j=0:len(m3), if (m3(i,j) != i + j) error endif endfor endfor da = Vector3([1,2,3]); ma = Matrix3({[1,2,3],[4,5,6],[7,8,9]}); swig-3.0.2/Examples/test-suite/octave/exception_order_runme.m0000664000175000017500000000160212343605122024264 0ustar williamwilliamexception_order function check_lasterror(expected) if (!strcmp(lasterror.message, expected)) # Take account of older versions prefixing with "error: " and adding a newline at the end if (!strcmp(regexprep(lasterror.message, 'error: (.*)\n$', '$1'), expected)) error(["Bad exception order. Expected: \"", expected, "\" Got: \"", lasterror.message, "\""]) endif endif endfunction a = A(); try a.foo() catch check_lasterror("C++ side threw an exception of type E1") end_try_catch try a.bar() catch check_lasterror("C++ side threw an exception of type E2") end_try_catch try a.foobar() catch check_lasterror("postcatch unknown (SWIG_RuntimeError)") end_try_catch try a.barfoo(1) catch check_lasterror("C++ side threw an exception of type E1") end_try_catch try a.barfoo(2) catch check_lasterror("C++ side threw an exception of type E2 *") end_try_catch swig-3.0.2/Examples/test-suite/octave/virtual_poly_runme.m0000664000175000017500000000110012343605122023615 0ustar williamwilliamvirtual_poly d = virtual_poly.NDouble(3.5); i = virtual_poly.NInt(2); # # the copy methods return the right polymorphic types # dc = d.copy(); ic = i.copy(); if (d.get() != dc.get()) error endif if (i.get() != ic.get()) error endif virtual_poly.incr(ic); if ((i.get() + 1) != ic.get()) error endif dr = d.ref_this(); if (d.get() != dr.get()) error endif # # 'narrowing' also works # ddc = virtual_poly.NDouble_narrow(d.nnumber()); if (d.get() != ddc.get()) error endif dic = virtual_poly.NInt_narrow(i.nnumber()); if (i.get() != dic.get()) error endif swig-3.0.2/Examples/test-suite/octave/li_std_stream_runme.m0000664000175000017500000000021512343605122023723 0ustar williamwilliamli_std_stream a = A(); o = ostringstream(); o << a << " " << 2345 << " " << 1.435; if (o.str() != "A class 2345 1.435") error endif swig-3.0.2/Examples/test-suite/octave/smart_pointer_multi_runme.m0000664000175000017500000000024112343605122025171 0ustar williamwilliamsmart_pointer_multi f = Foo(); b = Bar(f); s = Spam(b); g = Grok(b); s.x = 3; if (s.getx() != 3) error endif g.x = 4; if (g.getx() != 4) error endif swig-3.0.2/Examples/test-suite/octave/using_private_runme.m0000664000175000017500000000032112343605122023747 0ustar williamwilliamusing_private f = FooBar(); f.x = 3; if (f.blah(4) != 4) error, "blah(int)" endif if (f.defaulted() != -1) error, "defaulted()" endif if (f.defaulted(222) != 222) error, "defaulted(222)" endif swig-3.0.2/Examples/test-suite/octave/class_ignore_runme.m0000664000175000017500000000015112343605122023541 0ustar williamwilliamclass_ignore a = class_ignore.Bar(); if (!strcmp(class_ignore.do_blah(a),"Bar::blah")) error endif swig-3.0.2/Examples/test-suite/octave/template_typedef_runme.m0000664000175000017500000000174512343605122024436 0ustar williamwilliamtemplate_typedef d = make_Identity_float(); c = make_Identity_reald(); try a = swig_this(d); a = swig_this(c); catch error end_try_catch try e = make_Multiplies_float_float_float_float(d, d); a = swig_this(e); catch e error("is not an instance") end_try_catch try f = make_Multiplies_reald_reald_reald_reald(c, c); a = swig_this(f); catch f error("is not an instance"); end_try_catch try g = make_Multiplies_float_float_reald_reald(d, c); a = swig_this(g); catch error(g, "is not an instance") end_try_catch # the old large format if (strcmp("",swig_typequery("vfncs::ArithUnaryFunction::argument_type,vfncs::arith_traits::result_type > *"))) error endif # the reduced format if (strcmp("",swig_typequery("vfncs::ArithUnaryFunction *"))) error endif # this is a bad name if (!strcmp("",swig_typequery("vfncs::ArithUnaryFunction *"))) error endif swig-3.0.2/Examples/test-suite/octave/dynamic_cast_runme.m0000664000175000017500000000026512343605122023535 0ustar williamwilliamdynamic_cast f = dynamic_cast.Foo(); b = dynamic_cast.Bar(); x = f.blah(); y = b.blah(); a = dynamic_cast.do_test(y); if (!strcmp(a,"Bar::test")) error("Failed!!") endif swig-3.0.2/Examples/test-suite/octave/callback_runme.m0000664000175000017500000000071712343605122022635 0ustar williamwilliam_callback callback if (foo(2) != 2) error endif if (A_bar(2) != 4) error endif if (foobar(3, _callback.foo) != foo(3)) error endif if (foobar(3, foo) != foo(3)) error endif if (foobar(3, A_bar) != A_bar(3)) error endif if (foobar(3, foof) != foof(3)) error endif if (foobar_i(3, foo_i) != foo_i(3)) error endif if (foobar_d(3.5, foo_d) != foo_d(3.5)) error endif a = A(); if (foobarm(3, a, A.foom_cb_ptr) != a.foom(3)) error endif swig-3.0.2/Examples/test-suite/octave/Makefile.in0000664000175000017500000000431412343605122021557 0ustar williamwilliam####################################################################### # Makefile for octave test-suite ####################################################################### LANGUAGE = octave OCTAVE = @OCTAVE@ SCRIPTSUFFIX = _runme.m srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ li_std_pair_extra \ li_std_string_extra \ octave_cell_deref\ octave_dim CPP_TEST_BROKEN += \ implicittest \ li_implicit \ li_std_set \ li_std_stream #C_TEST_CASES += # # This test only works with modern C compilers # #C_TEST_CASES += \ # complextest include $(srcdir)/../common.mk # Overridden variables here LIBS = -L. CSRCS = octave_empty.c # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.m appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(RUNTOOL) $(OCTAVE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: remove the generated .m file %.clean: @rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.m hugemod_b.m hugemod_runme.m @rm -f $*.m; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" octave_clean cvsignore: @echo '*wrap* *.mc *.so *.dll *.exp *.lib' @echo Makefile @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.m; done @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.m CVS/Entries ; then echo $${i}_runme.m; fi; done @echo clientdata_prop_a.m @echo clientdata_prop_b.m @echo imports_a.m @echo imports_b.m @echo mod_a.m mod_b.m @echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.m hugemod_b.m hugemod_runme.m @echo template_typedef_import.m hugemod: perl hugemod.pl $(MAKE) hugemod_a.cpptest $(MAKE) hugemod_b.cpptest time $(OCTAVE) hugemod_runme.m time $(OCTAVE) hugemod_runme.m swig-3.0.2/Examples/test-suite/octave/default_args_runme.m0000664000175000017500000000200512343605122023531 0ustar williamwilliamdefault_args if (default_args.Statics.staticmethod() != 60) error endif if (default_args.cfunc1(1) != 2) error endif if (default_args.cfunc2(1) != 3) error endif if (default_args.cfunc3(1) != 4) error endif f = default_args.Foo(); f.newname(); f.newname(1); try f = default_args.Foo(1); ok = 1; catch ok = 0; end_try_catch if (ok) error("Foo::Foo ignore is not working") endif try f = default_args.Foo(1,2); ok = 1; catch ok = 0; end_try_catch if (ok) error("Foo::Foo ignore is not working") endif try f = default_args.Foo(1,2,3); ok = 1; catch ok = 0; end_try_catch if (ok) error("Foo::Foo ignore is not working") endif try m = f.meth(1); ok = 1; catch ok = 0; end_try_catch if (ok) error("Foo::meth ignore is not working") endif try m = f.meth(1,2); ok = 1; catch ok = 0; end_try_catch if (ok) error("Foo::meth ignore is not working") endif try m = f.meth(1,2,3); ok = 1; catch ok = 0; end_try_catch if (ok) error("Foo::meth ignore is not working") endif swig-3.0.2/Examples/test-suite/octave/template_inherit_runme.m0000664000175000017500000000160512343605122024433 0ustar williamwilliamtemplate_inherit a = FooInt(); b = FooDouble(); c = BarInt(); d = BarDouble(); e = FooUInt(); f = BarUInt(); if (!strcmp(a.blah(),"Foo")) error endif if (!strcmp(b.blah(),"Foo")) error endif if (!strcmp(e.blah(),"Foo")) error endif if (!strcmp(c.blah(),"Bar")) error endif if (!strcmp(d.blah(),"Bar")) error endif if (!strcmp(f.blah(),"Bar")) error endif if (!strcmp(c.foomethod(),"foomethod")) error endif if (!strcmp(d.foomethod(),"foomethod")) error endif if (!strcmp(f.foomethod(),"foomethod")) error endif if (!strcmp(invoke_blah_int(a),"Foo")) error endif if (!strcmp(invoke_blah_int(c),"Bar")) error endif if (!strcmp(invoke_blah_double(b),"Foo")) error endif if (!strcmp(invoke_blah_double(d),"Bar")) error endif if (!strcmp(invoke_blah_uint(e),"Foo")) error endif if (!strcmp(invoke_blah_uint(f),"Bar")) error endif swig-3.0.2/Examples/test-suite/octave/abstract_typedef_runme.m0000664000175000017500000000012312343605122024413 0ustar williamwilliamabstract_typedef e = Engine(); a = A(); if (a.write(e) != 1) error endif swig-3.0.2/Examples/test-suite/octave/empty_runme.m0000664000175000017500000000000712343605122022227 0ustar williamwilliamempty swig-3.0.2/Examples/test-suite/octave/static_const_member_2_runme.m0000664000175000017500000000043212343605122025340 0ustar williamwilliamstatic_const_member_2 c = Test_int(); try a = c.forward_field; a = c.current_profile; a = c.RightIndex; a = Test_int.backward_field; a = Test_int.LeftIndex; a = Test_int.cavity_flags; catch end_try_catch if (Foo.BAZ.val != 2*Foo.BAR.val) error endif swig-3.0.2/Examples/test-suite/octave/abstract_access_runme.m0000664000175000017500000000011512343605122024215 0ustar williamwilliamabstract_access d = abstract_access.D(); if (d.do_x() != 1) error endif swig-3.0.2/Examples/test-suite/octave/typedef_scope_runme.m0000664000175000017500000000030212343605122023720 0ustar williamwilliamtypedef_scope b = typedef_scope.Bar(); x = b.test1(42,"hello"); if (x != 42) error("Failed!!") endif x = b.test2(42,"hello"); if (!strcmp(x,"hello")) error("Failed!!") endif swig-3.0.2/Examples/test-suite/octave/director_unroll_runme.m0000664000175000017500000000032512343605122024302 0ustar williamwilliamdirector_unroll MyFoo=@() subclass(director_unroll.Foo(),'ping',@(self) "MyFoo::ping()"); a = MyFoo(); b = director_unroll.Bar(); b.set(a); c = b.get(); if (swig_this(a) != swig_this(c)) a,c error endif swig-3.0.2/Examples/test-suite/octave/li_std_wstream_runme.m0000664000175000017500000000023512343605122024114 0ustar williamwilliamli_std_wstream a = A(); o = wostringstream(); o << a << u" " << 2345 << u" " << 1.435 << wends; if (o.str() != "A class 2345 1.435\0") error endif swig-3.0.2/Examples/test-suite/octave/import_nomodule_runme.m0000664000175000017500000000013012343605122024302 0ustar williamwilliamimport_nomodule f = create_Foo(); test1(f,42); delete_Foo(f); b = Bar(); test1(b,37); swig-3.0.2/Examples/test-suite/octave/rename_scope_runme.m0000664000175000017500000000021312343605122023530 0ustar williamwilliamrename_scope a = Natural_UP(); b = Natural_BP(); if (a.rtest() != 1) error endif if (b.rtest() != 1) error endif f = @equals; swig-3.0.2/Examples/test-suite/octave/namespace_typemap_runme.m0000664000175000017500000000227312343605122024573 0ustar williamwilliamnamespace_typemap if (!strcmp(stest1("hello"),"hello")) error endif if (!strcmp(stest2("hello"),"hello")) error endif if (!strcmp(stest3("hello"),"hello")) error endif if (!strcmp(stest4("hello"),"hello")) error endif if (!strcmp(stest5("hello"),"hello")) error endif if (!strcmp(stest6("hello"),"hello")) error endif if (!strcmp(stest7("hello"),"hello")) error endif if (!strcmp(stest8("hello"),"hello")) error endif if (!strcmp(stest9("hello"),"hello")) error endif if (!strcmp(stest10("hello"),"hello")) error endif if (!strcmp(stest11("hello"),"hello")) error endif if (!strcmp(stest12("hello"),"hello")) error endif c = complex(2,3); r = real(c); if (ctest1(c) != r) error endif if (ctest2(c) != r) error endif if (ctest3(c) != r) error endif if (ctest4(c) != r) error endif if (ctest5(c) != r) error endif if (ctest6(c) != r) error endif if (ctest7(c) != r) error endif if (ctest8(c) != r) error endif if (ctest9(c) != r) error endif if (ctest10(c) != r) error endif if (ctest11(c) != r) error endif if (ctest12(c) != r) error endif try ttest1(-14) error catch end_try_catch swig-3.0.2/Examples/test-suite/octave/overload_simple_cast_runme.m0000664000175000017500000000754412343605122025304 0ustar williamwilliamoverload_simple_cast Ai=@(x) subclass('x',x,'__int',@(self) self.x); Ad=@(x) subclass('x',x,'__float',@(self) self.x); ai = Ai(4); ad = Ad(5.0); add = Ad(5.5); try fint(add); good = 0; catch good = 1; end_try_catch if (!good) error("fint(int)") endif if (!strcmp(fint(ad),"fint:int")) error("fint(int)") endif if (!strcmp(fdouble(ad),"fdouble:double")) error("fdouble(double)") endif if (!strcmp(fint(ai),"fint:int")) error("fint(int)") endif if (!strcmp(fint(5.0),"fint:int")) error("fint(int)") endif if (!strcmp(fint(3),"fint:int")) error("fint(int)") endif if (!strcmp(fint(3.0),"fint:int")) error("fint(int)") endif if (!strcmp(fdouble(ad),"fdouble:double")) error("fdouble(double)") endif if (!strcmp(fdouble(3),f"fdouble:double")) error("fdouble(double)") endif if (!strcmp(fdouble(3.0),"fdouble:double")) error("fdouble(double)") endif if (!strcmp(fid(3,3.0),"fid:intdouble")) error("fid:intdouble") endif if (!strcmp(fid(3.0,3),"fid:doubleint")) error("fid:doubleint") endif if (!strcmp(fid(ad,ai),"fid:doubleint")) error("fid:doubleint") endif if (!strcmp(fid(ai,ad),"fid:intdouble")) error("fid:intdouble") endif if (!strcmp(foo(3),"foo:int")) error("foo(int)") endif if (!strcmp(foo(3.0),"foo:double")) error("foo(double)") endif if (!strcmp(foo("hello"),"foo:char *")) error("foo(char *)") endif f = Foo(); b = Bar(); if (!strcmp(foo(f),"foo:Foo *")) error("foo(Foo *)") endif if (!strcmp(foo(b),"foo:Bar *")) error("foo(Bar *)") endif v = malloc_void(32); if (!strcmp(foo(v),"foo:void *")) error("foo(void *)") endif s = Spam(); if (!strcmp(s.foo(3),"foo:int")) error("Spam::foo(int)") endif if (!strcmp(s.foo(3.0),"foo:double")) error("Spam::foo(double)") endif if (!strcmp(s.foo("hello"),"foo:char *")) error("Spam::foo(char *)") endif if (!strcmp(s.foo(f),"foo:Foo *")) error("Spam::foo(Foo *)") endif if (!strcmp(s.foo(b),"foo:Bar *")) error("Spam::foo(Bar *)") endif if (!strcmp(s.foo(v),"foo:void *")) error("Spam::foo(void *)") endif if (!strcmp(Spam_bar(3),"bar:int")) error("Spam::bar(int)") endif if (!strcmp(Spam_bar(3.0),"bar:double")) error("Spam::bar(double)") endif if (!strcmp(Spam_bar("hello"),"bar:char *")) error("Spam::bar(char *)") endif if (!strcmp(Spam_bar(f),"bar:Foo *")) error("Spam::bar(Foo *)") endif if (!strcmp(Spam_bar(b),"bar:Bar *")) error("Spam::bar(Bar *)") endif if (!strcmp(Spam_bar(v),"bar:void *")) error("Spam::bar(void *)") endif # Test constructors s = Spam(); if (!strcmp(s.type,"none")) error("Spam()") endif s = Spam(3); if (!strcmp(s.type,"int")) error("Spam(int)") endif s = Spam(3.4); if (!strcmp(s.type,"double")) error("Spam(double)") endif s = Spam("hello"); if (!strcmp(s.type,"char *")) error("Spam(char *)") endif s = Spam(f); if (!strcmp(s.type,"Foo *")) error("Spam(Foo *)") endif s = Spam(b); if (!strcmp(s.type,"Bar *")) error("Spam(Bar *)") endif s = Spam(v); if (!strcmp(s.type,"void *")) error("Spam(void *)") endif # unsigned long long ullmax = 9223372036854775807; #0xffffffffffffffff ullmaxd = 9007199254740992.0; ullmin = 0; ullmind = 0.0; if (ull(ullmin) != ullmin) error("ull(ullmin)") endif if (ull(ullmax) != ullmax) error("ull(ullmax)") endif if (ull(ullmind) != ullmind) error("ull(ullmind)") endif if (ull(ullmaxd) != ullmaxd) error("ull(ullmaxd)") endif # long long llmax = 9223372036854775807; #0x7fffffffffffffff llmin = -9223372036854775808; # these are near the largest floats we can still convert into long long llmaxd = 9007199254740992.0; llmind = -9007199254740992.0; if (ll(llmin) != llmin) error("ll(llmin)") endif if (ll(llmax) != llmax) error("ll(llmax)") endif if (ll(llmind) != llmind) error("ll(llmind)") endif if (ll(llmaxd) != llmaxd) error("ll(llmaxd)") endif free_void(v); swig-3.0.2/Examples/test-suite/octave/template_construct_runme.m0000664000175000017500000000002312343605122025006 0ustar williamwilliamtemplate_construct swig-3.0.2/Examples/test-suite/octave/li_implicit_runme.m0000664000175000017500000000042212343605122023370 0ustar williamwilliamli_implicit b = B(); ai = A(1); ad = A(2.0); ab = A(b); ai, get(ai); ad, get(ad); ab, get(ab); if (get(ai) != get(1)) error("bad implicit type") endif if (get(ad) != get(2.0)) error("bad implicit type") endif if (get(ab) != get(b)) error("bad implicit type") endif swig-3.0.2/Examples/test-suite/octave/enums_runme.m0000664000175000017500000000034312343605122022223 0ustar williamwilliam enums enums.bar2(1) enums.bar3(1) enums.bar1(1) if (enums.cvar.enumInstance != 2) error endif if (enums.cvar.Slap != 10) error endif if (enums.cvar.Mine != 11) error endif if (enums.cvar.Thigh != 12) error endif swig-3.0.2/Examples/test-suite/octave/mod_runme.m0000664000175000017500000000007612343605122021656 0ustar williamwilliammod_a mod_b c = mod_b.C(); d = mod_b.D(); d.DoSomething(c); swig-3.0.2/Examples/test-suite/octave/overload_simple_runme.m0000664000175000017500000000404012343605122024256 0ustar williamwilliamoverload_simple # unless explicitly casted via {{u}int{8,16,32,64},double,single}, # octave will take numeric literals as doubles. if (!strcmp(foo(3),"foo:int")) error("foo(int)") endif if (!strcmp(foo(3.1),"foo:double")) error("foo(double)") endif if (!strcmp(foo("hello"),"foo:char *")) error("foo(char *)") endif f = Foo(); b = Bar(); if (!strcmp(foo(f),"foo:Foo *")) error("foo(Foo *)") endif if (!strcmp(foo(b),"foo:Bar *")) error("foo(Bar *)") endif v = malloc_void(32); if (!strcmp(foo(v),"foo:void *")) error("foo(void *)") endif s = Spam(); if (!strcmp(s.foo(3),"foo:int")) error("Spam::foo(int)") endif if (!strcmp(s.foo(3.1),"foo:double")) error("Spam::foo(double)") endif if (!strcmp(s.foo("hello"),"foo:char *")) error("Spam::foo(char *)") endif if (!strcmp(s.foo(f),"foo:Foo *")) error("Spam::foo(Foo *)") endif if (!strcmp(s.foo(b),"foo:Bar *")) error("Spam::foo(Bar *)") endif if (!strcmp(s.foo(v),"foo:void *")) error("Spam::foo(void *)") endif if (!strcmp(Spam_bar(3),"bar:int")) error("Spam::bar(int)") endif if (!strcmp(Spam_bar(3.1),"bar:double")) error("Spam::bar(double)") endif if (!strcmp(Spam_bar("hello"),"bar:char *")) error("Spam::bar(char *)") endif if (!strcmp(Spam_bar(f),"bar:Foo *")) error("Spam::bar(Foo *)") endif if (!strcmp(Spam_bar(b),"bar:Bar *")) error("Spam::bar(Bar *)") endif if (!strcmp(Spam_bar(v),"bar:void *")) error("Spam::bar(void *)") endif # Test constructors s = Spam(); if (!strcmp(s.type,"none")) error("Spam()") endif s = Spam(3); if (!strcmp(s.type,"int")) error("Spam(int)") endif s = Spam(3.4); if (!strcmp(s.type,"double")) error("Spam(double)") endif s = Spam("hello"); if (!strcmp(s.type,"char *")) error("Spam(char *)") endif s = Spam(f); if (!strcmp(s.type,"Foo *")) error("Spam(Foo *)") endif s = Spam(b); if (!strcmp(s.type,"Bar *")) error("Spam(Bar *)") endif s = Spam(v); if (!strcmp(s.type,"void *")) error("Spam(void *)") endif free_void(v); a = ClassA(); b = a.method1(1); swig-3.0.2/Examples/test-suite/octave/inherit_missing_runme.m0000664000175000017500000000070012343605122024264 0ustar williamwilliaminherit_missing a = inherit_missing.new_Foo(); b = inherit_missing.Bar(); c = inherit_missing.Spam(); x = inherit_missing.do_blah(a); if (!strcmp(x, "Foo::blah")) error("Whoa! Bad return %s", x) endif x = inherit_missing.do_blah(b); if (!strcmp(x, "Bar::blah")) error("Whoa! Bad return %s", x) endif x = inherit_missing.do_blah(c); if (!strcmp(x, "Spam::blah")) error("Whoa! Bad return %s", x) endif inherit_missing.delete_Foo(a); swig-3.0.2/Examples/test-suite/octave/overload_copy_runme.m0000664000175000017500000000004512343605122023740 0ustar williamwilliamoverload_copy f = Foo(); g = Foo(f); swig-3.0.2/Examples/test-suite/octave/extend_template_ns_runme.m0000664000175000017500000000016212343605122024755 0ustar williamwilliamextend_template_ns f = Foo_One(); if (f.test1(37) != 37) error endif if (f.test2(42) != 42) error endif swig-3.0.2/Examples/test-suite/octave/overload_rename_runme.m0000664000175000017500000000023312343605122024234 0ustar williamwilliamoverload_rename f = overload_rename.Foo(1); f = overload_rename.Foo(1,1); f = overload_rename.new_Foo_int(1,1); f = overload_rename.new_Foo_int(1,1,1); swig-3.0.2/Examples/test-suite/octave/smart_pointer_extend_runme.m0000664000175000017500000000057712343605122025342 0ustar williamwilliamsmart_pointer_extend f = Foo(); b = Bar(f); if (b.extension() != f.extension()) error endif b = CBase(); d = CDerived(); p = CPtr(); if (b.bar() != p.bar()) error endif if (d.foo() != p.foo()) error endif if (b.hello() != p.hello()) error endif d = DFoo(); dp = DPtrFoo(d); if (d.SExt(1) != dp.SExt(1)) error endif if (d.Ext(1) != dp.Ext(1)) error endif swig-3.0.2/Examples/test-suite/octave/overload_template_runme.m0000664000175000017500000000606212343605122024606 0ustar williamwilliamoverload_template f = foo(); a = maximum(3,4); b = maximum(3.4,5.2); # mix 1 if (mix1("hi") != 101) error("mix1(const char*)") endif if (mix1(1.0, 1.0) != 102) error("mix1(double, const double &)") endif if (mix1(1.0) != 103) error("mix1(double)") endif # mix 2 if (mix2("hi") != 101) error("mix2(const char*)") endif if (mix2(1.0, 1.0) != 102) error("mix2(double, const double &)") endif if (mix2(1.0) != 103) error("mix2(double)") endif # mix 3 if (mix3("hi") != 101) error("mix3(const char*)") endif if (mix3(1.0, 1.0) != 102) error("mix3(double, const double &)") endif if (mix3(1.0) != 103) error("mix3(double)") endif # Combination 1 if (overtparams1(100) != 10) error("overtparams1(int)") endif if (overtparams1(100.0, 100) != 20) error("overtparams1(double, int)") endif # Combination 2 if (overtparams2(100.0, 100) != 40) error("overtparams2(double, int)") endif # Combination 3 if (overloaded() != 60) error("overloaded()") endif if (overloaded(100.0, 100) != 70) error("overloaded(double, int)") endif # Combination 4 if (overloadedagain("hello") != 80) error("overloadedagain(const char *)") endif if (overloadedagain() != 90) error("overloadedagain(double)") endif # specializations if (specialization(10) != 202) error("specialization(int)") endif if (specialization(10.1) != 203) error("specialization(double)") endif if (specialization(10, 10) != 204) error("specialization(int, int)") endif if (specialization(10.0, 10.1) != 205) error("specialization(double, double)") endif if (specialization("hi", "hi") != 201) error("specialization(const char *, const char *)") endif # simple specialization xyz(); xyz_int(); xyz_double(); # a bit of everything if (overload("hi") != 0) error("overload()") endif if (overload(1) != 10) error("overload(int t)") endif if (overload(1, 1) != 20) error("overload(int t, const int &)") endif if (overload(1, "hello") != 30) error("overload(int t, const char *)") endif k = Klass(); if (overload(k) != 10) error("overload(Klass t)") endif if (overload(k, k) != 20) error("overload(Klass t, const Klass &)") endif if (overload(k, "hello") != 30) error("overload(Klass t, const char *)") endif if (overload(10.1, "hi") != 40) error("overload(double t, const char *)") endif if (overload() != 50) error("overload(const char *)") endif # everything put in a namespace if (nsoverload("hi") != 1000) error("nsoverload()") endif if (nsoverload(1) != 1010) error("nsoverload(int t)") endif if (nsoverload(1, 1) != 1020) error("nsoverload(int t, const int &)") endif if (nsoverload(1, "hello") != 1030) error("nsoverload(int t, const char *)") endif if (nsoverload(k) != 1010) error("nsoverload(Klass t)") endif if (nsoverload(k, k) != 1020) error("nsoverload(Klass t, const Klass &)") endif if (nsoverload(k, "hello") != 1030) error("nsoverload(Klass t, const char *)") endif if (nsoverload(10.1, "hi") != 1040) error("nsoverload(double t, const char *)") endif if (nsoverload() != 1050) error("nsoverload(const char *)") endif A_foo(1); b = B(); b.foo(1); swig-3.0.2/Examples/test-suite/octave/using_composition_runme.m0000664000175000017500000000122312343605122024642 0ustar williamwilliamusing_composition f = FooBar(); if (f.blah(3) != 3) error("FooBar::blah(int)") endif if (f.blah(3.5) != 3.5) error("FooBar::blah(double)") endif if (!strcmp(f.blah("hello"),"hello")) error("FooBar::blah(char *)") endif f = FooBar2(); if (f.blah(3) != 3) error("FooBar2::blah(int)") endif if (f.blah(3.5) != 3.5) error("FooBar2::blah(double)") endif if (!strcmp(f.blah("hello"),"hello")) error("FooBar2::blah(char *)") endif f = FooBar3(); if (f.blah(3) != 3) error("FooBar3::blah(int)") endif if (f.blah(3.5) != 3.5) error("FooBar3::blah(double)") endif if (!strcmp(f.blah("hello"),"hello")) error("FooBar3::blah(char *)") endif swig-3.0.2/Examples/test-suite/octave/namespace_virtual_method_runme.m0000664000175000017500000000010012343605122026125 0ustar williamwilliamnamespace_virtual_method x = namespace_virtual_method.Spam(); swig-3.0.2/Examples/test-suite/template_int_const.i0000664000175000017500000000205612343605122022277 0ustar williamwilliam%module template_int_const %warnfilter(SWIGWARN_RUBY_WRONG_NAME) interface_traits; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) module_traits; /* Ruby, wrong class name */ %inline %{ enum Polarization { UnaryPolarization, BinaryPolarization }; struct interface_traits { static const Polarization polarization = UnaryPolarization; }; template struct Interface_ { }; typedef unsigned int Category; struct module_traits { static const Category category = 1; }; template struct Module { }; %} %template(Interface_UP) Interface_; %template(Module_1) Module<1>; %inline %{ struct ExtInterface1 : Interface_ // works { }; struct ExtInterface2 : Interface_ // doesn't work { }; struct ExtModule1 : Module<1> // works { }; struct ExtModule2 : Module // doesn't work { }; %} swig-3.0.2/Examples/test-suite/conversion_ns_template.i0000664000175000017500000000240712343605122023164 0ustar williamwilliam%module conversion_ns_template %{ namespace oss { struct Hi { Hi(){} Hi(int){} }; enum Test {One, Two}; template struct Foo { Foo(){} }; template struct Bar { Bar(){ } Bar(int){ } operator int() { return 0; } operator int&() { static int num = 0; return num; } operator Foo() { return Foo(); } operator Foo&() { return *(new Foo()); } }; } %} namespace oss { enum Test {One, Two}; // these works %ignore Hi::Hi(); %rename(create) Hi::Hi(int); struct Hi { Hi(); Hi(int); }; template struct Foo { Foo(); }; // these works %rename(hello1) Bar::operator int&(); %ignore Bar::operator int(); %rename(hello2) Bar::operator Foo&(); %ignore Bar::operator Foo(); // these don't %ignore Bar::Bar(); %rename(Bar_create) Bar::Bar(int); template struct Bar { Bar(); Bar(int); operator int(); operator int&(); operator Foo(); operator Foo&(); }; } namespace oss { %template(Foo_One) Foo; %template(Bar_One) Bar; } swig-3.0.2/Examples/test-suite/typemap_template.i0000664000175000017500000000230312343605122021751 0ustar williamwilliam%module typemap_template /* Test bug in 1.3.40 where the presence of a generic/unspecialized typemap caused the incorrect specialized typemap to be used */ %typemap(in) SWIGTYPE "_this_will_not_compile_SWIGTYPE_ \"$type\" " %typemap(in) const SWIGTYPE & "_this_will_not_compile_const_SWIGTYPE_REF_\"$type\" " %typemap(in) const TemplateTest1 & {$1 = (TemplateTest1 *)0; /* in typemap generic for $type */} %typemap(in) const TemplateTest1< ZZ > & {$1 = (TemplateTest1 *)0; /* in typemap ZZ for $type */} %typemap(in) const TemplateTest1< int > & {$1 = (TemplateTest1 *)0; /* in typemap int for $type */} %inline %{ template struct TemplateTest1 { void setT(const TemplateTest1& t) {} typedef double Double; }; %} %inline %{ struct YY {}; struct ZZ {}; %} %template(TTYY) TemplateTest1< YY >; %template(TTZZ) TemplateTest1< ZZ >; %template(TTint) TemplateTest1< int >; %inline %{ void extratest(const TemplateTest1< YY > &t, const TemplateTest1< ZZ > &tt, const TemplateTest1< int > &ttt) {} %} %typemap(in) TemplateTest1 "_this_will_not_compile_TemplateTest_ \"$type\" " %inline %{ void wasbug(TemplateTest1< int >::Double wbug) {} %} swig-3.0.2/Examples/test-suite/char_binary.i0000664000175000017500000000077512343605122020673 0ustar williamwilliam/* A test case for testing non null terminated char pointers. */ %module char_binary %apply (char *STRING, size_t LENGTH) { (const char *str, size_t len) } %inline %{ struct Test { size_t strlen(const char *str, size_t len) { return len; } }; typedef char namet[5]; namet var_namet; typedef char* pchar; pchar var_pchar; %} // Remove string handling typemaps and treat as pointer %typemap(freearg) SWIGTYPE * "" %apply SWIGTYPE * { char * } %include "carrays.i" %array_functions(char, pchar); swig-3.0.2/Examples/test-suite/typename.i0000664000175000017500000000072212343605122020224 0ustar williamwilliam%module "typename" // Tests the typename handling in templates. %inline %{ class Foo { public: typedef double Number; Number blah() { return 2.1828; } }; class Bar { public: typedef int Number; Number blah() { return 42; } }; template typename T::Number twoblah(T &obj) { return 2*(obj.blah()); } Bar::Number spam() { return 3; } %} %template(twoFoo) twoblah; %template(twoBar) twoblah; swig-3.0.2/Examples/test-suite/java_lib_arrays_dimensionless.i0000664000175000017500000000202012343605122024457 0ustar williamwilliam%module java_lib_arrays_dimensionless %include "arrays_java.i" // Can't wrap dimensionless arrays, so we use the old pointer approach %apply SWIGTYPE* { int globalints[], int constglobalints[], int Bar::ints[] } // Test %apply for arrays in arrays_java.i library file %apply bool [] { bool *array } %apply char [] { char *array } %apply signed char [] { signed char *array } %apply unsigned char [] { unsigned char *array } %apply short [] { short *array } %apply unsigned short [] { unsigned short *array } %apply int [] { int *array } %apply unsigned int [] { unsigned int *array } %apply long [] { long *array } %apply unsigned long [] { unsigned long *array } %apply long [] { long *array } %apply unsigned long long [] { unsigned long long *array } %apply float [] { float *array } %apply double [] { double *array } %include "arrays_dimensionless.i" swig-3.0.2/Examples/test-suite/csharp_typemaps.i0000664000175000017500000000567612343605122021621 0ustar williamwilliam%module csharp_typemaps // Test the C# types customisation by modifying the default char * typemaps to return a single char %typemap(ctype, out="char /*ctype out override*/") char * "char *" %typemap(imtype, out="char /*imtype out override*/") char * "string" %typemap(cstype, out="char /*cstype out override*/") char * "string" %typemap(out) char * %{ // return the 0th element rather than the whole string $result = SWIG_csharp_string_callback($1)[0]; %} %typemap(csout, excode=SWIGEXCODE) char * { char ret = $imcall;$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) char * %{ get { char ret = $imcall;$excode return ret; } %} %inline %{ namespace Space { class Things { public: char* start(char *val) { return val; } static char* stop(char *val) { return val; } }; char* partyon(char *val) { return val; } } %} // Test variables when ref is used in the cstype typemap - the variable name should come from the out attribute if specified %typemap(cstype) MKVector, const MKVector& "MKVector" %typemap(cstype, out="MKVector") MKVector &, MKVector * "ref MKVector" %inline %{ struct MKVector { }; struct MKRenderGameVector { MKVector memberValue; static MKVector staticValue; }; MKVector MKRenderGameVector::staticValue; MKVector globalValue; %} // Number and Obj are for the eager garbage collector runtime test %inline %{ struct Number { Number(double value) : Value(value) {} double Value; }; class Obj { public: Number triple(Number n) { n.Value *= 3; return n; } Number times6(const Number& num) { Number n(num); n.Value *= 6; return n; } Number times9(const Number* num) { Number n(*num); n.Value *= 9; return n; } }; Number quadruple(Number n) { n.Value *= 4; return n; }; Number times8(const Number& num) { Number n(num); n.Value *= 8; return n; }; Number times12(const Number* num) { Number n(*num); n.Value *= 12; return n; }; %} // Test $csinput expansion %typemap(csvarin, excode=SWIGEXCODE2) int %{ set { if ($csinput < 0) throw new global::System.ApplicationException("number too small!"); $imcall;$excode } %} %inline %{ int myInt = 0; %} // Illegal special variable crash %typemap(cstype) WasCrashing "$csclassname /*cstype $*csclassname*/" // $*csclassname was causing crash %inline %{ struct WasCrashing {}; void hoop(WasCrashing was) {} %} // Enum underlying type %typemap(csbase) BigNumbers "uint" %inline %{ enum BigNumbers { big=0x80000000, bigger }; %} // Member variable qualification %typemap(cstype) bool "badtype1" %typemap(cstype) bool mvar "badtype2" %typemap(cstype) bool svar "badtype4" %typemap(cstype) bool gvar "badtype5" %typemap(cstype) bool MVar::mvar "bool" %typemap(cstype) bool MVar::svar "bool" %typemap(cstype) bool Glob::gvar "bool" %inline %{ struct MVar { bool mvar; static bool svar; }; namespace Glob { bool gvar; } bool MVar::svar = false; %} swig-3.0.2/Examples/test-suite/template_explicit.i0000664000175000017500000000255712343605122022126 0ustar williamwilliam/* File : example.i */ %module "template_explicit" %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ // #pragma is used for warnings that are not associated to // specific nodes. #pragma SWIG nowarn=-SWIGWARN_PARSE_EXPLICIT_TEMPLATE /* Let's just grab the original header file here */ %{ #ifdef max #undef max #endif %} %inline %{ template T max(const T a, const T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } // This really doesn't do anything except test const handling void testconst(const T x) { } }; /* Explicit instantiation. SWIG should ignore */ template class vector; template class vector; template class vector; %} /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; /* Now try to break constness */ %template(maxintp) max; %template(vecintp) vector; swig-3.0.2/Examples/test-suite/iadd.i0000664000175000017500000000133412343605122017303 0ustar williamwilliam%module iadd %include attribute.i class Foo; %attribute_ref(test::Foo, test::A& , AsA); %attribute_ref(test::Foo, long, AsLong); %inline %{ struct B { int x; B(const int x) : x(x) {} B& get_me() { return *this; } B& operator+=(const B& a) { x += a.x; return *this; } }; namespace test { struct A { int x; A(const int x) : x(x) {} A& get_me() { return *this; } A operator+=(const A& a) { x += a.x; return *this; } }; class Foo { public: Foo(): _a(new A(5)), _n(new long) {} ~Foo() { delete _a; delete _n; _a = NULL; _n = NULL; } A & AsA() const { return *_a; } long& AsLong() const { return *_n; } private: A *_a; long *_n; }; } %} swig-3.0.2/Examples/test-suite/using_private.i0000664000175000017500000000071312343605122021261 0ustar williamwilliam%module using_private %inline %{ class Foo { public: virtual ~Foo() { } int x; int blah(int xx) { return xx; } int defaulted(int i = -1) { return i; } virtual void virtualmethod() {} virtual void anothervirtual() {} }; class FooBar : private Foo { public: using Foo::blah; using Foo::x; using Foo::defaulted; using Foo::virtualmethod; virtual void anothervirtual() {} virtual ~FooBar() {} }; %} swig-3.0.2/Examples/test-suite/csharp_lib_arrays.i0000664000175000017500000000263512343605122022076 0ustar williamwilliam%module csharp_lib_arrays %include "arrays_csharp.i" %apply int INPUT[] { int* sourceArray } %apply int OUTPUT[] { int* targetArray } %apply int INOUT[] { int* array1 } %apply int INOUT[] { int* array2 } %inline %{ /* copy the contents of the first array to the second */ void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) { int i; for ( i = 0; i < nitems; i++ ) { targetArray[ i ] = sourceArray[ i ]; } } /* swap the contents of the two arrays */ void myArraySwap( int* array1, int* array2, int nitems ) { int i, temp; for ( i = 0; i < nitems; i++ ) { temp = array1[ i ]; array1[ i ] = array2[ i ]; array2[ i ] = temp; } } %} %clear int* sourceArray; %clear int* targetArray; %clear int* array1; %clear int* array2; // Below replicates the above array handling but this time using the pinned (fixed) array typemaps %csmethodmodifiers myArrayCopyUsingFixedArrays "public unsafe"; %csmethodmodifiers myArraySwapUsingFixedArrays "public unsafe"; %apply int FIXED[] { int* sourceArray } %apply int FIXED[] { int* targetArray } %inline %{ void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) { myArrayCopy(sourceArray, targetArray, nitems); } %} %apply int FIXED[] { int* array1 } %apply int FIXED[] { int* array2 } %inline %{ void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) { myArraySwap(array1, array2, nitems); } %} swig-3.0.2/Examples/test-suite/abstract_access.i0000664000175000017500000000071112343605122021524 0ustar williamwilliam%module abstract_access %warnfilter(SWIGWARN_LANG_DIRECTOR_ABSTRACT) A; %inline %{ class A { public: virtual ~A() { } private: virtual int x() = 0; protected: virtual int y() = 0; public: virtual int z() = 0; int do_x() { return x(); } }; class B : public A { private: virtual int x() { return y(); } }; class C : public B { protected: virtual int y() { return z(); } }; class D : public C { private: virtual int z() { return 1; } }; %} swig-3.0.2/Examples/test-suite/li_reference.i0000664000175000017500000000471612343605122021033 0ustar williamwilliam%module li_reference %include "reference.i" %inline %{ double FrVal; double ToVal; void PDouble(double *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } void RDouble(double &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = FrVal + t; } void PFloat(float *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (float)(FrVal + t); } void RFloat(float &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (float)(FrVal + t); } void PInt(int *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (int)(FrVal + t); } void RInt(int &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (int)(FrVal + t); } void PShort(short *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (short)(FrVal + t); } void RShort(short &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (short)(FrVal + t); } void PLong(long *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (long)(FrVal + t); } void RLong(long &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (long)(FrVal + t); } void PUInt(unsigned int *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (unsigned int)(FrVal + t); } void RUInt(unsigned int &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (unsigned int)(FrVal + t); } void PUShort(unsigned short *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (unsigned short)(FrVal + t); } void RUShort(unsigned short &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (unsigned short)(FrVal + t); } void PULong(unsigned long *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (unsigned long)(FrVal + t); } void RULong(unsigned long &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (unsigned long)(FrVal + t); } void PUChar(unsigned char *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (unsigned char)(FrVal + t); } void RUChar(unsigned char &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (unsigned char)(FrVal + t); } void PChar(signed char *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (signed char)(FrVal + t); } void RChar(signed char &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (signed char)(FrVal + t); } void PBool(bool *REFERENCE, int t = 0) { ToVal = *REFERENCE; *REFERENCE = (FrVal + t) ? true : false; } void RBool(bool &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = (FrVal + t) ? true : false; } %} swig-3.0.2/Examples/test-suite/template_default_arg_virtual_destructor.i0000664000175000017500000000115312343605122026575 0ustar williamwilliam%module template_default_arg_virtual_destructor // SF bug #1296: // virtual destructor in template class (template specification having // default parameter(s)) triggers the warning "illegal destructor name" %inline %{ struct A {}; template struct B { B(T const&) {} virtual ~B() {} }; template struct B { B(int,int) {} // constructor specific to this partial specialization virtual ~B() {} // "illegal destructor name" when ~B() is virtual }; %} %template(B_AF) B; %template(B_A) B; // this instantiation triggers the warning swig-3.0.2/Examples/test-suite/const_const_2.i0000664000175000017500000000053512343605122021161 0ustar williamwilliam/* This interface file tests whether SWIG handles doubly constant methods right. SF Bug #216057 against Swig 1.3a5, reported by Mike Romberg */ %module const_const_2 %inline %{ class Spam { public: Spam() {} }; class Eggs { public: Eggs() {} const Spam *spam(void) const { return new Spam(); } }; %} swig-3.0.2/Examples/test-suite/overload_subtype.i0000664000175000017500000000023512343605122021767 0ustar williamwilliam%module overload_subtype %inline %{ class Foo {}; class Bar : public Foo {}; int spam(Foo *f) { return 1; } int spam(Bar *b) { return 2; } %} swig-3.0.2/Examples/test-suite/virtual_destructor.i0000664000175000017500000000066712343605122022356 0ustar williamwilliam/* This testcase checks that a virtual destructor with void as a parameter is correctly handled. Also tests a class with protected destructor derived from a class with a public destructor. */ %module virtual_destructor %inline %{ class VirtualVoidDestructor { public: VirtualVoidDestructor() {}; virtual ~VirtualVoidDestructor(void) { }; }; class Derived : public VirtualVoidDestructor { protected: virtual ~Derived() {}; }; %} swig-3.0.2/Examples/test-suite/catches.i0000664000175000017500000000146212343605122020016 0ustar williamwilliam%module catches %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %include // for throws(...) typemap %catches(int, const char *, const ThreeException&) test_catches(int i); %catches(int, ...) test_exception_specification(int i); // override the exception specification %catches(...) test_catches_all(int i); %inline %{ struct ThreeException {}; void test_catches(int i) { if (i == 1) { throw int(1); } else if (i == 2) { throw (const char *)"two"; } else if (i == 3) { throw ThreeException(); } } void test_exception_specification(int i) throw(int, const char *, const ThreeException&) { test_catches(i); } void test_catches_all(int i) { test_catches(i); } %} swig-3.0.2/Examples/test-suite/template_qualifier.i0000664000175000017500000000030712343605122022255 0ustar williamwilliam%module template_qualifier /* Stroustruo, 3rd Ed, C.13.6 */ %inline %{ class X { public: template X *xalloc() { return new X(); } }; %} %extend X { %template(xalloc_int) xalloc<200>; }; swig-3.0.2/Examples/test-suite/typedef_inherit.i0000664000175000017500000000125612343605122021567 0ustar williamwilliam// Inheritance through a typedef name %module typedef_inherit %inline %{ class Foo { public: virtual ~Foo () { } virtual char *blah() { return (char *) "Foo::blah"; } }; typedef Foo FooObj; class Bar : public FooObj { public: virtual char *blah() { return (char *) "Bar::blah"; }; }; char *do_blah(FooObj *f) { return f->blah(); } typedef struct spam { virtual ~spam() { } virtual char *blah() { return (char *) "Spam::blah"; } } Spam; struct Grok : public Spam { virtual ~Grok() { } virtual char *blah() { return (char *) "Grok::blah"; } }; static char * do_blah2(Spam *s) { return s->blah(); } %} swig-3.0.2/Examples/test-suite/template_typemaps_typedef.i0000664000175000017500000000770012343605122023662 0ustar williamwilliam%module template_typemaps_typedef // Similar to template_typedef_class_template // Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters %inline %{ namespace Standard { template struct Pair { T first; U second; }; } %} %{ namespace Standard { template class Multimap { public: typedef Key key_type; typedef T mapped_type; class iterator { public: mapped_type mm; iterator(mapped_type m = mapped_type()) : mm(m) {} }; mapped_type typemap_test(Standard::Pair pp) { return pp.second.mm; } Standard::Pair* make_dummy_pair() { return new Standard::Pair(); } }; } %} namespace Standard { template class Multimap { public: typedef Key key_type; typedef T mapped_type; class iterator; %typemap(in) Standard::Pair "$1 = default_general< Key, T >();" mapped_type typemap_test(Standard::Pair pii1); Standard::Pair* make_dummy_pair(); }; } // specialization namespace Standard { template<> class Multimap { public: typedef A key_type; typedef int mapped_type; class iterator; // Note uses a different function to the non-specialized version %typemap(in) Standard::Pair "$1 = default_A_int< A, int >();" mapped_type typemap_test(Standard::Pair pii2); Standard::Pair* make_dummy_pair(); }; } %inline %{ struct A { int val; A(int v = 0): val(v) {} }; %} %{ // For < int, A > template Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_general() { Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value; default_value.second.mm = A(1234); return default_value; } // For < A, int > template Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_A_int() { Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value; default_value.second.mm = 4321; return default_value; } %} %inline %{ typedef A AA; namespace Space { typedef AA AB; } %} %template(PairIntA) Standard::Pair; %template(MultimapIntA) Standard::Multimap; %template(PairAInt) Standard::Pair; %template(MultimapAInt) Standard::Multimap; %inline %{ // Extend the test with some typedefs in the template parameters Standard::Multimap< int, AA >::mapped_type typedef_test1(Standard::Pair< Standard::Multimap< int, AA >::iterator, Standard::Multimap< int, AA >::iterator > pp) { return pp.second.mm; } Standard::Multimap< int, A >::mapped_type typedef_test2(Standard::Pair< Standard::Multimap< int, A >::iterator, Standard::Multimap< int, A >::iterator > pp) { return pp.second.mm; } Standard::Multimap< int, AA, int >::mapped_type typedef_test3(Standard::Pair< Standard::Multimap< int, AA, int >::iterator, Standard::Multimap< int, AA, int >::iterator > pp) { return pp.second.mm; } Standard::Multimap< int, A , int >::mapped_type typedef_test4(Standard::Pair< Standard::Multimap< int, A , int >::iterator, Standard::Multimap< int, A , int >::iterator > pp) { return pp.second.mm; } using namespace Space; Standard::Multimap< int, AB >::mapped_type typedef_test5(Standard::Pair< Standard::Multimap< int, AB >::iterator, Standard::Multimap< int, AB >::iterator > pp) { return pp.second.mm; } Standard::Multimap< int, AB, int >::mapped_type typedef_test6(Standard::Pair< Standard::Multimap< int, AB, int >::iterator, Standard::Multimap< int, AB, int >::iterator > pp) { return pp.second.mm; } %} swig-3.0.2/Examples/test-suite/multi_import_a.i0000664000175000017500000000026012343605122021423 0ustar williamwilliam/* This was reported in Bug #1735931 */ %module multi_import_a %import multi_import_b.i %{ #include "multi_import.h" %} class ZZZ : public XXX { public: int testz(); }; swig-3.0.2/Examples/test-suite/director_unroll.i0000664000175000017500000000120512343605122021605 0ustar williamwilliam%module(directors="1") director_unroll %{ #include class Foo { public: virtual ~Foo() {} virtual std::string ping() { return "Foo::ping()"; } virtual std::string pong() { return "Foo::pong();" + ping(); } }; class Bar { private: Foo *foo; public: void set(Foo *x) { foo = x; } Foo *get() { return foo; } }; %} %include "std_string.i" %feature("director") Foo; class Foo { public: virtual ~Foo() {} virtual std::string ping() { return "Foo::ping()"; } virtual std::string pong() { return "Foo::pong();" + ping(); } }; class Bar { private: Foo *foo; public: void set(Foo *x) { foo = x; } Foo *get() { return foo; } }; swig-3.0.2/Examples/test-suite/nested_workaround.i0000664000175000017500000000112412343605122022134 0ustar williamwilliam%module nested_workaround // "flatnested" emulates deprecated feature "nested_workaround" for the languages not supporting nested classes %feature ("flatnested"); %inline %{ class Outer { public: class Inner { int val; public: Inner(int v = 0) : val(v) {} void setValue(int v) { val = v; } int getValue() const { return val; } }; Inner createInner(int v) const { return Inner(v); } int getInnerValue(const Inner& i) const { return i.getValue(); } Inner doubleInnerValue(Inner inner) { inner.setValue(inner.getValue() * 2); return inner; } }; %} swig-3.0.2/Examples/test-suite/director_alternating.i0000664000175000017500000000144512343605122022610 0ustar williamwilliam// Checks if calls to a method being defined in the base class, not // overridden in the subclass, but again overridden in a class derived from // the first subclass are dispatched correctly. %module(directors="1") director_alternating; %feature("director") Foo; %inline %{ struct Foo { virtual ~Foo() {} virtual int id() { return 0; } }; struct Bar : Foo {}; struct Baz : Bar { virtual int id() { return 2; } }; // Note that even though the return value is of type Bar*, it really points to // an instance of Baz (in which id() has been overridden). Bar *getBar() { static Baz baz; return &baz; } // idFromGetBar() obviously is equivalent to getBar()->id() in C++ – this // should be true from the target language as well. int idFromGetBar() { return getBar()->id(); } %} swig-3.0.2/Examples/test-suite/cpp11_initializer_list.i0000664000175000017500000000124312343605122022763 0ustar williamwilliam/* This testcase shows a few simple ways to deal with the new initializer_list introduced in C++11. */ %module cpp11_initializer_list %warnfilter(SWIGWARN_TYPEMAP_INITIALIZER_LIST) B::B; %ignore A::A(std::initializer_list); %ignore B::method; %typemap(in) std::initializer_list { $1 = {"Ab", "Fab"}; } %inline %{ #include class A { public: A(std::initializer_list) {} A() {} A(double d) {} }; class B { public: B(std::initializer_list, std::initializer_list) {} B() {} void method(std::initializer_list init) {} }; class C { public: C(std::initializer_list) {} C() {} }; %} swig-3.0.2/Examples/test-suite/name.i0000664000175000017500000000073112343605122017322 0ustar williamwilliam/* This interface file tests whether SWIG/Guile handle the %rename and %name directives, which was not the case in 1.3a5. */ %module name #pragma SWIG nowarn=SWIGWARN_DEPRECATED_NAME // %name is deprecated. Use %rename instead. #ifdef SWIGGUILE %rename foo_1 "foo-2"; #else %rename foo_1 "foo_2"; #endif %inline %{ void foo_1() {} %} #ifdef SWIGGUILE %name("bar-2") #else %name("bar_2") #endif %inline %{ int bar_1 = 17; %} %name("Baz_2") %constant int Baz_1 = 47; swig-3.0.2/Examples/test-suite/derived_nested.i0000664000175000017500000000123512343605122021366 0ustar williamwilliam/* This testcase tests nested derived classes. This was reported in bug #909389 */ %module derived_nested %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::CC; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::DD; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::EE; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::FF; %inline %{ class A { public: int x; }; class B { class C { int y; }; //generates a warning class D : public A { int z; }; //ok }; struct BB { class CC { int y; }; class DD : public A { int z; }; struct EE : public A { int z; }; struct FF : public A { int z; } ff_instance; // Bug 1960977 void useEE(const EE& e) {} }; %} swig-3.0.2/Examples/test-suite/li_boost_shared_ptr_attribute.i0000664000175000017500000000215512343605122024514 0ustar williamwilliam%module li_boost_shared_ptr_attribute #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) %include "attribute.i" %include "boost_shared_ptr.i" %inline %{ #include using namespace boost; %} %shared_ptr(GetMe); %shared_ptr(GetSetMe); %attributestring(GetterOnly, shared_ptr, AddedAttrib, GetIt) %attributestring(GetterSetter, shared_ptr, AddedAttrib, GetIt, SetIt) %inline %{ struct GetMe { explicit GetMe(int n) : n(n) {} ~GetMe() {} int n; }; struct GetSetMe { explicit GetSetMe(int n) : n(n) {} ~GetSetMe() {} int n; }; struct GetterOnly { explicit GetterOnly(int n) : myval(new GetMe(n*n)) {} shared_ptr GetIt() const { return myval; } shared_ptr myval; }; struct GetterSetter { explicit GetterSetter(int n) : myval(new GetSetMe(n*n)) {} shared_ptr GetIt() const { return myval; } void SetIt(shared_ptr newval) { myval = newval; } shared_ptr myval; }; %} #endif swig-3.0.2/Examples/test-suite/template_tbase_template.i0000664000175000017500000000210612343605122023264 0ustar williamwilliam%module template_tbase_template %warnfilter(SWIGWARN_RUBY_WRONG_NAME) traits; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_PARSE_EXPLICIT_TEMPLATE); %inline %{ typedef double Double; template struct Funktion { char *test() { return (char *) "test"; } }; template struct traits { typedef ArgType arg_type; typedef ResType res_type; typedef Funktion base; }; // Egad! template struct Class_ : Funktion::arg_type, typename traits::res_type> { }; template typename traits::base make_Class() { return Class_(); } %} %{ template struct Funktion ; template struct Class_ ; %} %template(traits_dd) traits ; %template(Funktion_dd) Funktion ; %template(Class_dd) Class_ ; %template(make_Class_dd) make_Class; swig-3.0.2/Examples/test-suite/wallkw.i0000664000175000017500000000135412343605122017705 0ustar williamwilliam%module wallkw // test the -Wallkw option %warnfilter(SWIGWARN_PARSE_KEYWORD) clone; // 'clone' is a PHP keyword, renaming to 'c_clone' %warnfilter(SWIGWARN_PARSE_KEYWORD) delegate; // 'delegate' is a C# keyword, renaming to '_delegate' %warnfilter(SWIGWARN_PARSE_KEYWORD) pass; // 'pass' is a python keyword, renaming to '_pass' %warnfilter(SWIGWARN_PARSE_KEYWORD) alias; // 'alias' is a D keyword, renaming to '_alias' %warnfilter(SWIGWARN_PARSE_KEYWORD) rescue; // 'rescue' is a ruby keyword, renaming to 'C_rescue' %inline %{ const char * clone() { return "clone"; } const char * delegate() { return "delegate"; } const char * pass() { return "pass"; } const char * alias() { return "alias"; } const char * rescue() { return "rescue"; } %} swig-3.0.2/Examples/test-suite/template_typedef_import.list0000664000175000017500000000005712343605122024053 0ustar williamwilliamtemplate_typedef_cplx2 template_typedef_import swig-3.0.2/Examples/test-suite/cpp11_reference_wrapper.i0000664000175000017500000000120512343605122023101 0ustar williamwilliam%module cpp11_reference_wrapper // SWIG could provide some sort of typemaps for reference_wrapper which is acts like a C++ reference, // but is copy-constructible and copy-assignable %inline %{ #include #include using namespace std; struct B { B(int &val) : val(val) {} std::reference_wrapper val; // int &val; }; %} %inline %{ void go() { int val(999); B b1(val); int const& aa1 = b1.val; cout << aa1 << endl; // copy constructible B b2(b1); int const& aa2 = b2.val; cout << aa2 << endl; // copy assignable B b3(val); b3 = b1; int const& aa3 = b3.val; cout << aa3 << endl; } %} swig-3.0.2/Examples/test-suite/guile/0000775000175000017500000000000012343605122017334 5ustar williamwilliamswig-3.0.2/Examples/test-suite/guile/cpp_enum_runme.scm0000664000175000017500000000046512343605122023061 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum")) (load "../schemerunme/cpp_enum.scm") swig-3.0.2/Examples/test-suite/guile/README0000664000175000017500000000020712343605122020213 0ustar williamwilliamSee ../README for common README file. Any testcases which have _runme.scm appended after the testcase name will be detected and run. swig-3.0.2/Examples/test-suite/guile/char_constant_runme.scm0000664000175000017500000000050412343605122024073 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant")) (load "../schemerunme/char_constant.scm") swig-3.0.2/Examples/test-suite/guile/contract_runme.scm0000664000175000017500000000051412343605122023063 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract")) (load "testsuite.scm") (load "../schemerunme/contract.scm") swig-3.0.2/Examples/test-suite/guile/unions_runme.scm0000664000175000017500000000067212343605122022566 0ustar williamwilliam;;; This is the union runtime testcase. It ensures that values within a ;;; union embedded within a struct can be set and read correctly. ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_unions_module" (dynamic-link "./libunions")) (load "../schemerunme/unions.scm") swig-3.0.2/Examples/test-suite/guile/li_std_string_runme.scm0000664000175000017500000000215012343605122024110 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string")) ; Note: when working with non-ascii strings in guile 2 ; Guile doesn't handle non-ascii characters in the default C locale ; The locale must be set explicitly ; The setlocale call below takes care of that ; The locale needs to be a UTF-8 locale to handle the non-ASCII characters ; But they are named differently on different systems so we try a few until one works (define (try-set-locale name) ; (display "testing ") ; (display name) ; (display "\n") (catch #t (lambda () (setlocale LC_ALL name) #t ) (lambda (key . parameters) #f )) ) (if (not (try-set-locale "C.UTF-8")) ; Linux (if (not (try-set-locale "en_US.utf8")) ; Linux (if (not (try-set-locale "en_US.UTF-8")) ; Mac OSX (error "Failed to set any UTF-8 locale") ))) (load "../schemerunme/li_std_string.scm") swig-3.0.2/Examples/test-suite/guile/testsuite.scm0000664000175000017500000000210712343605122022071 0ustar williamwilliam;; Little helper functions and macros for the run tests (use-modules (ice-9 format)) (define (test-error error-format . args) (display "Runtime check failed. ") (apply format #t error-format args) (newline) (exit 1)) (define-macro (expect-true form) `(if (not ,form) (test-error "Expected true value of ~A" ',form))) (define-macro (expect-false form) `(if ,form (test-error "Expected false value of ~A" ',form))) (define-macro (expect-result expected-result-form equal? form) `(let ((expected-result ,expected-result-form) (result ,form)) (if (not (,equal? result expected-result)) (test-error "The result of ~A was ~A, expected ~A, which is not ~A" ',form result expected-result ',equal?)))) (define-macro (expect-throw tag-form form) `(let ((tag ,tag-form)) (if (catch #t (lambda () ,form #t) (lambda (key . args) (if (eq? key ,tag-form) #f (test-error "The form ~A threw to ~A (expected a throw to ~A)" ',form key tag)))) (test-error "The form ~A returned normally (expected a throw to ~A)")))) swig-3.0.2/Examples/test-suite/guile/imports_runme.scm0000664000175000017500000000115112343605122022741 0ustar williamwilliam;;; This file is part of a test for SF bug #231619. ;;; It shows that the %import directive does not work properly in SWIG ;;; 1.3a5: Type information is not properly generated if a base class ;;; comes from an %import-ed file. ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a")) (dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b")) (load "../schemerunme/imports.scm") swig-3.0.2/Examples/test-suite/guile/cpp_namespace_runme.scm0000664000175000017500000000017512343605122024047 0ustar williamwilliam(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace")) (load "../schemerunme/cpp_namespace.scm") swig-3.0.2/Examples/test-suite/guile/name_runme.scm0000664000175000017500000000045112343605122022166 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_name_module" (dynamic-link "./libname")) (load "../schemerunme/name.scm") swig-3.0.2/Examples/test-suite/guile/import_nomodule_runme.scm0000664000175000017500000000020312343605122024455 0ustar williamwilliam(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule")) (load "../schemerunme/import_nomodule.scm") swig-3.0.2/Examples/test-suite/guile/overload_copy_runme.scm0000664000175000017500000000017512343605122024116 0ustar williamwilliam(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy")) (load "../schemerunme/overload_copy.scm") swig-3.0.2/Examples/test-suite/guile/list_vector_runme.scm0000664000175000017500000000047612343605122023612 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector")) (load "../schemerunme/list_vector.scm") swig-3.0.2/Examples/test-suite/guile/constover_runme.scm0000664000175000017500000000016112343605122023266 0ustar williamwilliam(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover")) (load "../schemerunme/constover.scm") swig-3.0.2/Examples/test-suite/guile/overload_extend_runme.scm0000664000175000017500000000020312343605122024423 0ustar williamwilliam(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend")) (load "../schemerunme/overload_extend.scm") swig-3.0.2/Examples/test-suite/guile/overload_simple_runme.scm0000664000175000017500000000051212343605122024430 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple")) (load "../schemerunme/overload_simple.scm") swig-3.0.2/Examples/test-suite/guile/inherit_missing_runme.scm0000664000175000017500000000020312343605122024434 0ustar williamwilliam(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing")) (load "../schemerunme/inherit_missing.scm") swig-3.0.2/Examples/test-suite/guile/casts_runme.scm0000664000175000017500000000045412343605122022366 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts")) (load "../schemerunme/casts.scm") swig-3.0.2/Examples/test-suite/guile/overload_complicated_runme.scm0000664000175000017500000000115512343605122025427 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated")) (define-macro (check form) `(if (not ,form) (error "Check failed: " ',form))) (define (=~ a b) (< (abs (- a b)) 1e-8)) ;; Check first method (check (=~ (foo 1 2 "bar" 4) 15)) ;; Check second method (check (=~ (foo 1 2) 4811.4)) (check (=~ (foo 1 2 3.2) 4797.2)) (check (=~ (foo 1 2 3.2 #\Q) 4798.2)) (exit 0) swig-3.0.2/Examples/test-suite/guile/guile_ext_test_runme.scm0000664000175000017500000000103312343605122024267 0ustar williamwilliam(dynamic-call "scm_init_guile_ext_test_module" (dynamic-link "./libguile_ext_test")) ; This is a test for SF Bug 1573892 ; If IsPointer is called before TypeQuery, the test-is-pointer will fail ; (i.e if the bottom two lines were moved to the top, the old code would succeed) ; only a problem when is-pointer is called first (define a (new-A)) (if (not (test-is-pointer a)) (error "test-is-pointer failed!")) (if (test-is-pointer 5) (error "test-is-pointer thinks 5 is a pointer!")) (define b (test-create)) (A-hello b) (exit 0) swig-3.0.2/Examples/test-suite/guile/throw_exception_runme.scm0000664000175000017500000000330012343605122024463 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception")) (define-macro (check-throw form) `(catch 'swig-exception (lambda () ,form (error "Check failed (returned normally): " ',form)) (lambda (key result) result))) (define-macro (check-throw-error form) `(let ((result (check-throw ,form))) (test-is-Error result))) (let ((foo (new-Foo))) (let ((result (check-throw (Foo-test-int foo)))) (if (not (eqv? result 37)) (error "Foo-test-int failed, returned " result))) (let ((result (check-throw (Foo-test-multi foo 1)))) (if (not (eqv? result 37)) (error "Foo-test-multi 1 failed, returned " result))) (let ((result (check-throw (Foo-test-msg foo)))) (if (not (and (string? result) (string=? result "Dead"))) (error "Foo-test-msg failed, returned " result))) (let ((result (check-throw (Foo-test-multi foo 2)))) (if (not (and (string? result) (string=? result "Dead"))) (error "Foo-test-multi 2 failed, returned " result))) (check-throw-error (Foo-test-cls foo)) (check-throw-error (Foo-test-multi foo 3)) (check-throw-error (Foo-test-cls-ptr foo)) (check-throw-error (Foo-test-cls-ref foo)) ;; Namespace stuff (let ((result (check-throw (Foo-test-enum foo)))) (if (not (eqv? result (enum2))) (error "Foo-test-enum failed, returned " result))) (check-throw-error (Foo-test-cls-td foo)) (check-throw-error (Foo-test-cls-ptr-td foo)) (check-throw-error (Foo-test-cls-ref-td foo))) (exit 0) swig-3.0.2/Examples/test-suite/guile/overload_subtype_runme.scm0000664000175000017500000000051512343605122024635 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype")) (load "../schemerunme/overload_subtype.scm") swig-3.0.2/Examples/test-suite/guile/dynamic_cast_runme.scm0000664000175000017500000000017212343605122023704 0ustar williamwilliam(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast")) (load "../schemerunme/dynamic_cast.scm") swig-3.0.2/Examples/test-suite/guile/guile_ext_test_external.cxx0000664000175000017500000000066112343605122025011 0ustar williamwilliam#include #include SCM test_create() { #define FUNC_NAME "test-create" SCM result; A *newobj; swig_type_info *type; newobj = new A(); type = SWIG_TypeQuery("A *"); result = SWIG_NewPointerObj(newobj, type, 1); return result; #undef FUNC_NAME } SCM test_is_pointer(SCM val) { #define FUNC_NAME "test-is-pointer" return SCM_BOOL(SWIG_IsPointer(val)); #undef FUNC_NAME } swig-3.0.2/Examples/test-suite/guile/integers_runme.scm0000664000175000017500000000063512343605122023072 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers")) (define-macro (throws-exception? form) `(catch #t (lambda () ,form #f) (lambda args #t))) (load "../schemerunme/integers.scm") swig-3.0.2/Examples/test-suite/guile/Makefile.in0000664000175000017500000000275512343605122021412 0ustar williamwilliam####################################################################### # Makefile for guile test-suite ####################################################################### EXTRA_TEST_CASES += guile_ext_test.externaltest LANGUAGE = guile VARIANT = SCRIPTSUFFIX = _runme.scm srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ GUILE = @GUILE@ GUILE_RUNTIME= C_TEST_CASES = long_long \ list_vector \ multivalue \ pointer_in_out include $(srcdir)/../common.mk # Overridden variables here INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile # Custom tests - tests with additional commandline options %.multicpptest: SWIGOPT += $(GUILE_RUNTIME) # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) %.externaltest: $(setup) +$(swig_and_compile_external) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.scm appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean %.clean: @rm -f $*-guile clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" guile_clean swig-3.0.2/Examples/test-suite/guile/li_typemaps_runme.scm0000664000175000017500000000130712343605122023575 0ustar williamwilliam;;; This is the union runtime testcase. It ensures that values within a ;;; union embedded within a struct can be set and read correctly. ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps")) (load "../schemerunme/li_typemaps.scm") (let ((lst (inoutr-int2 3 -2))) (if (not (and (= (car lst) 3) (= (cadr lst) -2))) (error "Error in inoutr-int2"))) (let ((lst (out-foo 4))) (if (not (and (= (Foo-a-get (car lst)) 4) (= (cadr lst) 8))) (error "Error in out-foo"))) (exit 0) swig-3.0.2/Examples/test-suite/guile/multivalue_runme.scm0000664000175000017500000000055212343605122023437 0ustar williamwilliam;;;; Automatic test of multiple return values ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue")) (load "../schemerunme/multivalue.scm") swig-3.0.2/Examples/test-suite/guile/typedef_inherit_runme.scm0000664000175000017500000000020312343605122024423 0ustar williamwilliam(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit")) (load "../schemerunme/typedef_inherit.scm") swig-3.0.2/Examples/test-suite/guile/reference_global_vars_runme.scm0000664000175000017500000000026412343605122025561 0ustar williamwilliam; copied from python runme_.py (dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars")) (load "../schemerunme/reference_global_vars.scm") swig-3.0.2/Examples/test-suite/guile/typename_runme.scm0000664000175000017500000000026312343605122023071 0ustar williamwilliam(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename")) ;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes")) (load "../schemerunme/typename.scm") swig-3.0.2/Examples/test-suite/guile/pointer_in_out_runme.scm0000664000175000017500000000050712343605122024305 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out")) (load "../schemerunme/pointer_in_out.scm") swig-3.0.2/Examples/test-suite/guile/class_ignore_runme.scm0000664000175000017500000000017212343605122023716 0ustar williamwilliam(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore")) (load "../schemerunme/class_ignore.scm") swig-3.0.2/Examples/test-suite/c_delete.i0000664000175000017500000000054312343605122020147 0ustar williamwilliam%module c_delete /* check C++ delete keyword is okay in C wrappers */ %warnfilter(SWIGWARN_PARSE_KEYWORD) delete; #if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) /* Octave and Javascript/v8 compiles wrappers as C++ */ %inline %{ struct delete { int delete; }; %} %rename(DeleteGlobalVariable) delete; %inline %{ int delete = 0; %} #endif swig-3.0.2/Examples/test-suite/director_thread.i0000664000175000017500000000324212343605122021544 0ustar williamwilliam// This testcase was in the python subdirectory #if defined(SWIGPYTHON) // Is "threads" really needed for Python? It seems to work without it. %module(directors="1",threads="1") director_thread #else %module(directors="1") director_thread #endif %{ #ifdef _WIN32 #include #include #else #include #include #include #endif #include class Foo; extern "C" { #ifdef _WIN32 unsigned int __stdcall working(void* t); unsigned int thread_id(0); #else void* working(void* t); pthread_t thread; #endif static int thread_terminate = 0; } %} %director Foo; %inline { static void MilliSecondSleep(int milliseconds) { %#ifdef _WIN32 Sleep(milliseconds); %#else usleep(milliseconds*1000); %#endif } class Foo { public: int val; Foo() : val(0) { } virtual ~Foo() { } void stop() { thread_terminate = 1; %#ifdef _WIN32 /*TODO(bhy) what to do for win32? */ %#else pthread_join(thread, NULL); %#endif } void run() { %#ifdef _WIN32 _beginthreadex(NULL,0,working,this,0,&thread_id); %#else pthread_create(&thread,NULL,working,this); %#endif MilliSecondSleep(500); } virtual void do_foo() { val += 1; } }; } %{ extern "C" { #ifdef _WIN32 unsigned int __stdcall working(void* t) #else void* working(void* t) #endif { Foo* f = static_cast(t); while ( ! thread_terminate ) { MilliSecondSleep(50); f->do_foo(); } #ifdef _WIN32 /* TODO(bhy) what's the corresponding of pthread_exit in win32? */ #else pthread_exit(0); #endif return 0; } } %} swig-3.0.2/Examples/test-suite/cpp11_hash_tables.i0000664000175000017500000000236112343605122021664 0ustar williamwilliam/* This testcase checks the new wrappers for the new unordered_ STL types introduced in C++11. */ %module cpp11_hash_tables %inline %{ #include //#include #include //#include %} %include "std_set.i" //%include "std_map.i" %include "std_unordered_set.i" //%include "std_unordered_map.i" %template (SetInt) std::set; //%template (MapIntInt) std::map; %template (UnorderedSetInt) std::unordered_set; //%template (UnorderedMapIntInt) std::unordered_map; %inline %{ using namespace std; class MyClass { public: set getSet() { return _set; } void addSet(int elt) { _set.insert(_set.begin(), elt); } // map getMap() { return _map; } // void addMap(int elt1, int elt2) { _map.insert(make_pair(elt1, elt2)); } unordered_set getUnorderedSet() { return _unordered_set; } void addUnorderedSet(int elt) { _unordered_set.insert(_unordered_set.begin(), elt); } // unordered_map getUnorderedMap() { return _unordered_map; } // void addUnorderedMap(int elt1, int elt2) { _unordered_map.insert(make_pair(elt1, elt2)); } private: set _set; // map _map; unordered_set _unordered_set; // unordered_map _unordered_map; }; %} swig-3.0.2/Examples/test-suite/import_stl.list0000664000175000017500000000003212343605122021313 0ustar williamwilliamimport_stl_a import_stl_b swig-3.0.2/Examples/test-suite/constants.i0000664000175000017500000000014612343605122020416 0ustar williamwilliam%module constants %inline %{ struct A { A(double) { } }; const A b123(3.0); %} swig-3.0.2/Examples/test-suite/director_enum.i0000664000175000017500000000414612343605122021245 0ustar williamwilliam%module(directors="1") director_enum %warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::hi; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::hello; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::yo; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::awright; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::Foo::ciao; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::Foo::aufwiedersehen; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::Foo::adios; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE, SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) EnumDirector::Foo; /* Thread/reentrant unsafe wrapping, consider returning by value instead. */ %feature("director") Foo; %rename(Hallo) EnumDirector::Hello; %inline %{ namespace EnumDirector { struct A; enum Hello { hi, hello, yo, awright = 10 }; class Foo { public: enum Bye { ciao, aufwiedersehen = 100, adios }; virtual ~Foo() {} virtual Hello say_hi(Hello h){ return h;} virtual Hello say_hello(Hello){ return hello;} virtual Hello say_hi(A *a){ return hi;} virtual Bye say_bye(Bye b){ return b;} virtual const Hello & say_hi_ref(const Hello & h){ return h;} Hello ping(Hello h){ return say_hi(h);} const Hello & ping_ref(const Hello &h){ return say_hi_ref(h);} Bye ping_member_enum(Bye b){ return say_bye(b);} }; } %} %feature("director"); %inline %{ namespace EnumDirector { enum FType{ SA = -1, NA_=0, EA=1}; struct A{ A(const double a, const double b, const FType c) {} virtual ~A() {} virtual int f(int i=0) {return i;} }; struct B : public A{ B(const double a, const double b, const FType c) : A(a, b, c) {} }; } %} %inline %{ namespace EnumDirector { struct A2{ A2(const FType c = NA_) {} virtual ~A2() {} virtual int f(int i=0) {return i;} }; struct B2 : public A2{ B2(const FType c) : A2(c) {} }; } %} swig-3.0.2/Examples/test-suite/conversion.i0000664000175000017500000000023512343605122020566 0ustar williamwilliam%module conversion %rename(toFoo) Bar::operator Foo(); %inline %{ struct Foo { }; struct Bar { operator Foo () { return Foo(); } }; %} swig-3.0.2/Examples/test-suite/using_pointers.i0000664000175000017500000000134212343605122021451 0ustar williamwilliam%module using_pointers #ifdef SWIGCSHARP %csmethodmodifiers x "public new" #endif %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %inline %{ class Foo { public: int x; virtual ~Foo() { } virtual Foo* blah() { return this; } virtual Foo* exception_spec(int what_to_throw) throw (int, const char *) { int num = 10; const char *str = "exception message"; if (what_to_throw == 1) throw num; else if (what_to_throw == 2) throw str; return 0; } }; class FooBar : public Foo { public: using Foo::blah; using Foo::x; using Foo::exception_spec; }; %} swig-3.0.2/Examples/test-suite/mod.h0000664000175000017500000000036212343605122017160 0ustar williamwilliam class C; class A { public: A() {} C* GetC() { return NULL; } void DoSomething(A* a) {} }; class B : public A { public: B() {} }; class C : public B { public: C() {} }; class D : public C { public: D() {} }; swig-3.0.2/Examples/test-suite/intermediary_classname.i0000664000175000017500000000501112343605122023120 0ustar williamwilliam // This test is to check the intermediary class name can be changed (C# and Java only use intermediary classes at time of writing) %module(directors="1", jniclassname="intermediary_classname", imclassname="intermediary_classname") "intermediary_classname" %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR); // change the access to the intermediary class for testing purposes %pragma(java) jniclassclassmodifiers="public class"; %pragma(csharp) imclassclassmodifiers="public class"; %feature("director") Base; %feature("director") Derived; // Test the throws attribute in these typemaps %typemap(javadirectorout, throws="InstantiationException/*javadirectorout Base&*/") Base& "$javaclassname.getCPtr($javacall)/* XYZ& typemap directorout*/" %typemap(javadirectorin, throws="ClassNotFoundException/*javadirectorin Base&*/") Base& "new $javaclassname($jniinput, false)/*javadirectorin*/" %typemap(out, throws="IllegalAccessException/*out Base&*/") Base& { // XYZ& typemap out $result = 0; // remove unused variable warning } %inline %{ template T maximum(const T a, const T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } void testconst(const T x) { } }; #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif class Base { public: Base() : mVectInt(0) {} Base(Base *b) : mVectInt(0) {} virtual ~Base() {} virtual Base& m1(Base &b) { return b; } virtual Base& m1out() { static Base b; return b; } virtual Base* m2(Base *b) { return b; } // virtual Base m3(Base b) { return b; } vector mVectInt; int mInt; enum en { en1, en2 }; en enummethod(en e) { return e; } }; class Derived : public Base { public: Derived(Base *b) : Base(b) {} virtual Base& m1(Base &b) { return b; } virtual Base* m2(Base *b) { return b; } // virtual Base m3(Base b) { return b; } void throwspec() throw (int, Base) {} }; #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %template(maxint) maximum; %template(maxdouble) maximum; %template(vecint) vector; %template(vecdouble) vector; %template(maxintp) maximum; %template(vecintp) vector; swig-3.0.2/Examples/test-suite/template_ns2.i0000664000175000017500000000044112343605122020775 0ustar williamwilliam// Tests compilation of uninstantiated templates in a namespace %module template_ns2 %inline %{ namespace foo { template class bar { }; bar *test1(bar *x) { return x; } typedef int Integer; bar *test2(bar *x) { return x; } } %} swig-3.0.2/Examples/test-suite/member_pointer.i0000664000175000017500000000614612343605122021417 0ustar williamwilliam%module member_pointer %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */ #pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */ #pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */ #endif %} %inline %{ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; double *z; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; virtual double area(void); virtual double perimeter(void); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { }; virtual double area(void); virtual double perimeter(void); }; extern double do_op(Shape *s, double (Shape::*m)(void)); /* Functions that return member pointers */ extern double (Shape::*areapt())(void); extern double (Shape::*perimeterpt())(void); /* Global variables that are member pointers */ extern double (Shape::*areavar)(void); extern double (Shape::*perimetervar)(void); %} %{ # define SWIG_M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area(void) { return SWIG_M_PI*radius*radius; } double Circle::perimeter(void) { return 2*SWIG_M_PI*radius; } double Square::area(void) { return width*width; } double Square::perimeter(void) { return 4*width; } double do_op(Shape *s, double (Shape::*m)(void)) { return (s->*m)(); } double (Shape::*areapt())(void) { return &Shape::area; } double (Shape::*perimeterpt())(void) { return &Shape::perimeter; } /* Member pointer variables */ double (Shape::*areavar)(void) = &Shape::area; double (Shape::*perimetervar)(void) = &Shape::perimeter; %} /* Some constants */ %constant double (Shape::*AREAPT)(void) = &Shape::area; %constant double (Shape::*PERIMPT)(void) = &Shape::perimeter; %constant double (Shape::*NULLPT)(void) = 0; /* %inline %{ struct Funktions { void retByRef(int & (*d)(double)) {} }; void byRef(int & (Funktions::*d)(double)) {} %} */ %inline %{ struct Funktions { int addByValue(const int &a, int b) { return a+b; } int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; } int & addByReference(const int &a, int b) { static int val; val = a+b; return val; } }; int call1(int (Funktions::*d)(const int &, int), int a, int b) { Funktions f; return (f.*d)(a, b); } int call2(int * (Funktions::*d)(const int &, int), int a, int b) { Funktions f; return *(f.*d)(a, b); } int call3(int & (Funktions::*d)(const int &, int), int a, int b) { Funktions f; return (f.*d)(a, b); } %} %constant int (Funktions::*ADD_BY_VALUE)(const int &, int) = &Funktions::addByValue; %constant int * (Funktions::*ADD_BY_POINTER)(const int &, int) = &Funktions::addByPointer; %constant int & (Funktions::*ADD_BY_REFERENCE)(const int &, int) = &Funktions::addByReference; swig-3.0.2/Examples/test-suite/virtual_vs_nonvirtual_base.i0000664000175000017500000000151312343605122024052 0ustar williamwilliam%module virtual_vs_nonvirtual_base; // Regression test for SF#3124665. %inline { class SimpleVirtual { public: virtual int implementMe() = 0; virtual ~SimpleVirtual() {} }; class SimpleNonVirtual { public: int dummy() { return 0; } }; class SimpleReturnClass { public: SimpleReturnClass(int i) : value(i) {}; int get() const { return value; } private: int value; }; class SimpleClassFail : public SimpleVirtual { public: SimpleClassFail() : inner(10) {} SimpleReturnClass getInner() { return inner; } virtual int implementMe() { return 0; } private: SimpleReturnClass inner; }; class SimpleClassWork : public SimpleNonVirtual { public: SimpleClassWork() : inner(10) {} SimpleReturnClass getInner() { return inner; } virtual int implementMe() { return 0; } private: SimpleReturnClass inner; }; } swig-3.0.2/Examples/test-suite/preproc_include_h2.i0000664000175000017500000000002112343605122022140 0ustar williamwilliam#define const2 2 swig-3.0.2/Examples/test-suite/grouping.i0000664000175000017500000000054312343605122020235 0ustar williamwilliam%module grouping %inline %{ typedef int Integer; int (test1)(int x) { return x; } int *(test2)(int x) { static int y; y = x; return &y; } int (test3) = 37; typedef Integer (UnaryOp)(Integer); Integer do_unary(Integer x, UnaryOp *f) { return (*f)(x); } int negate(int x) { return -x; } %} %constant UnaryOp *NEGATE = negate; swig-3.0.2/Examples/test-suite/java_director_exception_feature_nspace.i0000664000175000017500000001546612343605122026353 0ustar williamwilliam%module(directors="1") java_director_exception_feature_nspace %include %nspace; // turn namespace feature on for everything. #define PACKAGEDOT "java_director_exception_feature_nspacePackage." #define PACKAGESLASH "java_director_exception_feature_nspacePackage/" %{ #define PACKAGEDOT "java_director_exception_feature_nspacePackage." #define PACKAGESLASH "java_director_exception_feature_nspacePackage/" %} %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif #include %} %include // DEFINE exceptions in header section using std::runtime_error %{ #include #include namespace MyNS { struct Exception1 : public std::runtime_error { Exception1(const std::string& what):runtime_error(what) {} }; struct Exception2 : public std::runtime_error { Exception2(const std::string& what):runtime_error(what) {} }; struct Unexpected : public std::runtime_error { Unexpected(const std::string& what):runtime_error(what) {} }; } %} // Add an explicit handler for Foo::ping, mapping one java exception back to an 'int' %feature("director:except") MyNS::Foo::ping { jthrowable $error = jenv->ExceptionOccurred(); if ($error) { jenv->ExceptionClear(); // clear java exception since mapping to c++ exception if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyNS/MyJavaException1")) { throw 1; } else if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyNS/MyJavaException2")) { std::string msg(Swig::JavaExceptionMessage(jenv,$error).message()); throw MyNS::Exception2(msg); } else { std::cerr << "Test failed, unexpected exception thrown: " << Swig::JavaExceptionMessage(jenv,$error).message() << std::endl; throw std::runtime_error("unexpected exception in Foo::ping"); } } } // Use default handler on Foo::pong, with directorthrows typemaps // directorthrows typemaps for java->c++ conversions %typemap(directorthrows) MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected %{ if (Swig::ExceptionMatches(jenv, $error, "$packagepath/$javaclassname")) { std::string msg(Swig::JavaExceptionMessage(jenv,$error).message()); throw $1_type(msg); } %} // Override the director:except feature so exception specification is not violated // (Cannot use built-in default of throw DirectorException) %feature("director:except") MyNS::Foo::pong %{ jthrowable $error = jenv->ExceptionOccurred(); if ($error) { jenv->ExceptionClear(); $directorthrowshandlers throw ::MyNS::Unexpected(Swig::JavaExceptionMessage(jenv,$error).message()); } %} // TODO 'throws' typemap emitted by emit_action (emit.cxx) has no way // to get access to language specific special variables like // $javaclassname or $packagepath ("java_director_exception_feature" here) // throws typemaps for c++->java exception conversions %typemap(throws,throws=PACKAGEDOT"MyNS.MyJavaException1") MyNS::Exception1 %{ jclass excpcls = jenv->FindClass(PACKAGESLASH"MyNS/MyJavaException1"); if (excpcls) { jenv->ThrowNew(excpcls, $1.what()); } return $null; %} %typemap(throws,throws=PACKAGEDOT"MyNS.MyJavaException1") int %{ (void)$1; jclass excpcls = jenv->FindClass(PACKAGESLASH"MyNS/MyJavaException1"); if (excpcls) { jenv->ThrowNew(excpcls, "Threw some integer"); } return $null; %} %typemap(throws,throws=PACKAGEDOT"MyNS.MyJavaException2") MyNS::Exception2 %{ jclass excpcls = jenv->FindClass(PACKAGESLASH"MyNS/MyJavaException2"); if (excpcls) { jenv->ThrowNew(excpcls, $1.what()); } return $null; %} %typemap(throws,throws=PACKAGEDOT"MyNS.MyJavaUnexpected") MyNS::Unexpected %{ jclass excpcls = jenv->FindClass(PACKAGESLASH"MyNS/MyJavaUnexpected"); if (excpcls) { jenv->ThrowNew(excpcls, $1.what()); } return $null; %} // Use generic exception translation approach like python, ruby %feature("director:except") MyNS::Foo::genericpong { jthrowable $error = jenv->ExceptionOccurred(); if ($error) { jenv->ExceptionClear(); throw Swig::DirectorException(jenv,$error); } } // %exception with throws attribute. Need throws attribute for checked exceptions %feature ("except",throws="Exception") MyNS::Foo::genericpong %{ %} %feature ("except",throws="Exception") MyNS::Bar::genericpong %{ try { $action } catch (Swig::DirectorException & direxcp) { direxcp.raiseJavaException(jenv); // jenv always available in JNI code return $null; } %} %feature("director") Foo; // Rename exceptions on java side to make translation of exceptions more clear %rename(MyJavaException1) MyNS::Exception1; %rename(MyJavaException2) MyNS::Exception2; %rename(MyJavaUnexpected) MyNS::Unexpected; %typemap(javabase) ::MyNS::Exception1,::MyNS::Exception2,::MyNS::Unexpected "java.lang.Exception"; %rename(getMessage) what() const; // Rename all what() methods namespace MyNS { struct Exception1 { Exception1(const std::string& what); const char * what() const; }; struct Exception2 { Exception2(const std::string& what); const char * what() const; }; struct Unexpected { Unexpected(const std::string& what); const char * what() const; }; } // In general it is better to use %catches instead of an exception specification on the method // since violating an exception specification calls terminate() preventing catch-all behavior // like throwing std::runtime_error. But an exception specification must be used if the // actual interface being wrapped does use them. %catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Foo::pong; %catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Bar::pong; %inline %{ namespace MyNS { class Foo { public: virtual ~Foo() {} // ping java implementation throws a java Exception1 or an Exception2 if excp is 1 or 2. // pong java implementation throws Exception1,Exception2,Unexpected,NullPointerException for 1,2,3,4 virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0; virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0; virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0; }; // Make a bar from a foo, so a call to Java Bar // goes Java Bar -> C++ Bar -> C++ Foo -> Java Foo Director class Bar { public: Bar(Foo* d) { delegate=d; } virtual std::string ping(int excp) throw(int,MyNS::Exception2) { return delegate->ping(excp); } virtual std::string pong(int excp) /* throws MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected */ { return delegate->pong(excp); } virtual std::string genericpong(int excp) { return delegate->genericpong(excp); } private: Foo * delegate; }; } %} swig-3.0.2/Examples/test-suite/using_namespace_loop.i0000664000175000017500000000023712343605122022575 0ustar williamwilliam%module using_namespace_loop %inline { namespace A { struct Foo; } namespace B { using namespace A; } namespace A { using namespace B; typedef Foo Bar; } } swig-3.0.2/Examples/test-suite/li_cdata_carrays.i0000664000175000017500000000015612343605122021667 0ustar williamwilliam%module li_cdata_carrays %include %array_class(int, intArray); %include %cdata(int); swig-3.0.2/Examples/test-suite/template_typedef_cplx2.h0000664000175000017500000001102412343605122023041 0ustar williamwilliam#ifndef ___typedef_import_h__ #define ___typedef_import_h__ #ifdef SWIG %module template_typedef_cplx2; #endif #include typedef std::complex Complex; namespace vfncs { struct UnaryFunctionBase { int get_base_value() { return 0; } }; template struct UnaryFunction; template struct ArithUnaryFunction; template struct UnaryFunction : UnaryFunctionBase { int get_value() { return 1; } }; template struct ArithUnaryFunction : UnaryFunction { int get_arith_value() { return 2; } }; template struct unary_func_traits { typedef ArithUnaryFunction base; }; template inline typename unary_func_traits< ArgType, ArgType >::base make_Identity() { return typename unary_func_traits< ArgType, ArgType >::base(); } template struct arith_traits { }; template<> struct arith_traits< double, double > { typedef double argument_type; typedef double result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< Complex, Complex > { typedef Complex argument_type; typedef Complex result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< Complex, double > { typedef double argument_type; typedef Complex result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< double, Complex > { typedef double argument_type; typedef Complex result_type; static const char* const arg_type; static const char* const res_type; }; template inline ArithUnaryFunction::argument_type, typename arith_traits< RF, RG >::result_type > make_Multiplies(const ArithUnaryFunction& f, const ArithUnaryFunction& g) { return ArithUnaryFunction::argument_type, typename arith_traits< RF, RG >::result_type>(); } #ifndef SWIG // Initialize these static class members const char* const arith_traits< double, double >::arg_type = "double"; const char* const arith_traits< double, double >::res_type = "double"; const char* const arith_traits< Complex, Complex >::arg_type = "complex"; const char* const arith_traits< Complex, Complex >::res_type = "complex"; const char* const arith_traits< Complex, double >::arg_type = "double"; const char* const arith_traits< Complex, double >::res_type = "complex"; const char* const arith_traits< double, Complex >::arg_type = "double"; const char* const arith_traits< double, Complex >::res_type = "complex"; #endif } // end namespace vfncs #ifdef SWIG namespace vfncs { %template(UnaryFunction_double_double) UnaryFunction; %template(ArithUnaryFunction_double_double) ArithUnaryFunction; %template() unary_func_traits; %template() arith_traits; %template(make_Identity_double) make_Identity; %template(UnaryFunction_complex_complex) UnaryFunction; %template(ArithUnaryFunction_complex_complex) ArithUnaryFunction; %template() unary_func_traits; %template() arith_traits; %template(make_Identity_complex) make_Identity; /* [beazley] Added this part */ %template() unary_func_traits; %template(UnaryFunction_double_complex) UnaryFunction; %template(ArithUnaryFunction_double_complex) ArithUnaryFunction; /* */ %template() arith_traits; %template() arith_traits; %template(make_Multiplies_double_double_complex_complex) make_Multiplies; %template(make_Multiplies_double_double_double_double) make_Multiplies; %template(make_Multiplies_complex_complex_complex_complex) make_Multiplies; %template(make_Multiplies_complex_complex_double_double) make_Multiplies; } #endif #endif //___template_typedef_h__ swig-3.0.2/Examples/test-suite/csharp_exceptions.i0000664000175000017500000002000312343605122022115 0ustar williamwilliam%module csharp_exceptions %include %inline %{ class Ex { const char *message; public: Ex(const char *msg) : message(msg) {} const char *what() { return message; } }; %} %exception ThrowByValue() { try { $action } catch(Ex e) { SWIG_exception(SWIG_DivisionByZero, e.what()); } } %exception ThrowByReference() { try { $action } catch(Ex &e) { SWIG_exception(SWIG_DivisionByZero, e.what()); } } %csnothrowexception NoThrowException() { try { $action } catch(Ex) { // swallowed } } %inline %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif // %exception tests void ThrowByValue() { throw Ex("ThrowByValue"); } void ThrowByReference() { throw Ex("ThrowByReference"); } // %csnothrowexception void NoThrowException() { throw Ex("NoThrowException"); } // exception specifications void ExceptionSpecificationValue() throw(Ex) { throw Ex("ExceptionSpecificationValue"); } void ExceptionSpecificationReference() throw(Ex&) { throw Ex("ExceptionSpecificationReference"); } void ExceptionSpecificationString() throw(const char *) { throw "ExceptionSpecificationString"; } void ExceptionSpecificationInteger() throw(int) { throw 20; } %} // test exceptions in the default typemaps // null reference exceptions %inline %{ void NullReference(Ex& e) {} void NullValue(Ex e) {} %} // enums %inline %{ enum TestEnum {TestEnumItem}; void ExceptionSpecificationEnumValue() throw(TestEnum) { throw TestEnumItem; } void ExceptionSpecificationEnumReference() throw(TestEnum&) { throw TestEnumItem; } %} // std::string %include %inline %{ void ExceptionSpecificationStdStringValue() throw(std::string) { throw std::string("ExceptionSpecificationStdStringValue"); } void ExceptionSpecificationStdStringReference() throw(const std::string&) { throw std::string("ExceptionSpecificationStdStringReference"); } void NullStdStringValue(std::string s) {} void NullStdStringReference(std::string &s) {} %} // Memory leak check (The C++ exception stack was never unwound in the original approach to throwing exceptions from unmanaged code) %exception MemoryLeakCheck() { Counter destructor_should_be_called; try { $action } catch(Ex e) { SWIG_exception(SWIG_DivisionByZero, e.what()); } } %inline %{ struct Counter { static int count; Counter() { count++; } ~Counter() { count--; } }; int Counter::count = 0; void MemoryLeakCheck() { throw Ex("testing memory leaks when throwing exceptions"); } %} // test exception pending in the csconstruct typemap %inline %{ struct constructor { constructor(std::string s) {} constructor() throw(int) { throw 10; } }; #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} // test exception pending in the csout typemaps %typemap(out, canthrow=1) unsigned short ushorttest %{ $result = $1; if ($result == 100) { SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, "don't like 100"); return $null; } %} %inline %{ unsigned short ushorttest() { return 100; } %} // test exception pending in the csvarout/csvarin typemaps and canthrow attribute in unmanaged code typemaps %typemap(check, canthrow=1) int numberin, int InOutStruct::staticnumberin %{ if ($1 < 0) { SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, "too small"); return $null; } %} %typemap(out, canthrow=1) int numberout, int InOutStruct::staticnumberout %{ $result = $1; if ($result > 10) { SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, "too big"); return $null; } %} %inline %{ int numberin; int numberout; struct InOutStruct { int numberin; int numberout; static int staticnumberin; static int staticnumberout; }; int InOutStruct::staticnumberin; int InOutStruct::staticnumberout; %} // test SWIG_exception macro - it must return from unmanaged code without executing any further unmanaged code %typemap(check, canthrow=1) int macrotest { if ($1 < 0) { SWIG_exception(SWIG_IndexError, "testing SWIG_exception macro"); } } %inline %{ bool exception_macro_run_flag = false; void exceptionmacrotest(int macrotest) { exception_macro_run_flag = true; } %} // test all the types of exceptions %typemap(check, canthrow=1) UnmanagedExceptions { switch($1) { case UnmanagedApplicationException: SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "msg"); return $null; break; case UnmanagedArithmeticException: SWIG_CSharpSetPendingException(SWIG_CSharpArithmeticException, "msg"); return $null; break; case UnmanagedDivideByZeroException: SWIG_CSharpSetPendingException(SWIG_CSharpDivideByZeroException, "msg"); return $null; break; case UnmanagedIndexOutOfRangeException: SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, "msg"); return $null; break; case UnmanagedInvalidCastException: SWIG_CSharpSetPendingException(SWIG_CSharpInvalidCastException, "msg"); return $null; break; case UnmanagedInvalidOperationException: SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, "msg"); return $null; break; case UnmanagedIOException: SWIG_CSharpSetPendingException(SWIG_CSharpIOException, "msg"); return $null; break; case UnmanagedNullReferenceException: SWIG_CSharpSetPendingException(SWIG_CSharpNullReferenceException, "msg"); return $null; break; case UnmanagedOutOfMemoryException: SWIG_CSharpSetPendingException(SWIG_CSharpOutOfMemoryException, "msg"); return $null; break; case UnmanagedOverflowException: SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, "msg"); return $null; break; case UnmanagedSystemException: SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, "msg"); return $null; break; case UnmanagedArgumentException: SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentException, "msg", "parm"); return $null; break; case UnmanagedArgumentNullException: SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "msg", "parm"); return $null; break; case UnmanagedArgumentOutOfRangeException: SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, "msg", "parm"); return $null; break; } } %inline %{ enum UnmanagedExceptions { UnmanagedApplicationException, UnmanagedArithmeticException, UnmanagedDivideByZeroException, UnmanagedIndexOutOfRangeException, UnmanagedInvalidCastException, UnmanagedInvalidOperationException, UnmanagedIOException, UnmanagedNullReferenceException, UnmanagedOutOfMemoryException, UnmanagedOverflowException, UnmanagedSystemException, UnmanagedArgumentException, UnmanagedArgumentNullException, UnmanagedArgumentOutOfRangeException, }; void check_exception(UnmanagedExceptions e) { } %} // exceptions in multiple threads test %exception ThrowsClass::ThrowException(long long input) { try { $action } catch (long long d) { char message[64]; sprintf(message, "caught:%lld", d); SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, message, "input"); } } %inline %{ struct ThrowsClass { double dub; ThrowsClass(double d) : dub(d) {} long long ThrowException(long long input) { throw input; return input; } }; %} // test inner exceptions %exception InnerExceptionTest() { try { $action } catch(Ex &e) { SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, e.what()); SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, "My OuterException message"); } } %inline %{ void InnerExceptionTest() { throw Ex("My InnerException message"); } %} swig-3.0.2/Examples/test-suite/enum_thorough.i0000664000175000017500000010145212343605122021267 0ustar williamwilliam%module "enum_thorough" // Suppress warning messages from the Ruby module for all of the // following... #pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD %warnfilter(SWIGWARN_RUBY_WRONG_NAME); %warnfilter(SWIGWARN_RUBY_WRONG_NAME) red; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) blue; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) green; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) SpeedClass::slow; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) SpeedClass::medium; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) SpeedClass::fast; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) SpeedClass::lightning; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) TemplateClass::einstein; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) TemplateClass::galileo; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Name::TClass::faraday; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Name::TClass::bell; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) argh; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) eek; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::whizz; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::kerboom; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::pop; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::simple1; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::singlename1; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::doublename1; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) TreesClass::oak; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) TreesClass::fir; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) TreesClass::pine; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) curly::greasy::HairStruct::blonde; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) curly::greasy::HairStruct::ginger; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::one; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::onetrail; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::two; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::twoagain; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::twotrail; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::twotrailagain; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance1; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance2; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance3; %warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'one' due to Go name ('ObscureOne') conflict with 'Obscure::One' */ %inline %{ enum { AnonEnum1, AnonEnum2 = 100 }; enum { ReallyAnInteger = 200 }; //enum { AnonEnum3, AnonEnum4 } instance; namespace AnonSpace { enum { AnonSpaceEnum1, AnonSpaceEnum2 = 300 }; struct AnonStruct { enum { AnonStructEnum1, AnonStructEnum2 = 400 }; }; } enum colour { red=-1, blue, green = 10 }; colour colourTest1(colour e) { return e; } enum colour colourTest2(enum colour e) { return e; } const colour colourTest3(const colour e) { return e; } const enum colour colourTest4(const enum colour e) { return e; } colour myColour; struct SpeedClass { enum speed { slow=10, medium=20, fast=30, lightning }; typedef enum speed speedtd1; int speedTest0(int s) { return s; } speed speedTest1(speed s) { return s; } enum speed speedTest2(enum speed s) { return s; } const speed speedTest3(const speed s) { return s; } const enum speed speedTest4(const enum speed s) { return s; } speedtd1 speedTest5(speedtd1 s) { return s; } const speedtd1 speedTest6(const speedtd1 s) { return s; } const speed & speedTest7(const speed &s) { return s; } const enum speed & speedTest8(const enum speed &s) { return s; } const colour myColour2; speedtd1 mySpeedtd1; SpeedClass() : myColour2(red), mySpeedtd1(slow) { } private: SpeedClass& operator=(const SpeedClass&); }; int speedTest0(int s) { return s; } SpeedClass::speed speedTest1(SpeedClass::speed s) { return s; } enum SpeedClass::speed speedTest2(enum SpeedClass::speed s) { return s; } const SpeedClass::speed speedTest3(const SpeedClass::speed s) { return s; } const enum SpeedClass::speed speedTest4(const enum SpeedClass::speed s) { return s; } const SpeedClass::speed & speedTest5(const SpeedClass::speed &s) { return s; } typedef enum { NamedAnon1, NamedAnon2 } namedanon; namedanon namedanonTest1(namedanon e) { return e; } typedef enum twonamestag { TwoNames1, TwoNames2, TwoNames3 = 33 } twonames; twonames twonamesTest1(twonames e) { return e; } twonamestag twonamesTest2(twonamestag e) { return e; } enum twonamestag twonamesTest3(enum twonamestag e) { return e; } struct TwoNamesStruct { typedef enum twonamestag { TwoNamesStruct1, TwoNamesStruct2 } twonames; twonames twonamesTest1(twonames e) { return e; } twonamestag twonamesTest2(twonamestag e) { return e; } enum twonamestag twonamesTest3(enum twonamestag e) { return e; } }; namespace AnonSpace{ typedef enum { NamedAnonSpace1, NamedAnonSpace2 } namedanonspace; namedanonspace namedanonspaceTest1(namedanonspace e) { return e; } AnonSpace::namedanonspace namedanonspaceTest2(AnonSpace::namedanonspace e) { return e; } } AnonSpace::namedanonspace namedanonspaceTest3(AnonSpace::namedanonspace e) { return e; } using namespace AnonSpace; namedanonspace namedanonspaceTest4(namedanonspace e) { return e; } template struct TemplateClass { enum scientists { einstein, galileo = 10 }; typedef enum scientists scientiststd1; typedef scientists scientiststd2; typedef scientiststd1 scientiststd3; scientists scientistsTest1(scientists e) { return e; } enum scientists scientistsTest2(enum scientists e) { return e; } const scientists scientistsTest3(const scientists e) { return e; } const enum scientists scientistsTest4(const enum scientists e) { return e; } typename TemplateClass::scientists scientistsTest5(typename TemplateClass::scientists e) { return e; } const typename TemplateClass::scientists scientistsTest6(const typename TemplateClass::scientists e) { return e; } enum TemplateClass::scientists scientistsTest7(enum TemplateClass::scientists e) { return e; } const enum TemplateClass::scientists scientistsTest8(const enum TemplateClass::scientists e) { return e; } typename TemplateClass::scientists scientistsTest9(typename TemplateClass::scientists e) { return e; } // enum TemplateClass::scientists scientistsTestA(enum TemplateClass::scientists e) { return e; } const typename TemplateClass::scientists scientistsTestB(const typename TemplateClass::scientists e) { return e; } // const enum TemplateClass::scientists scientistsTestC(const enum TemplateClass::scientists e) { return e; } scientiststd1 scientistsTestD(scientiststd1 e) { return e; } scientiststd2 scientistsTestE(scientiststd2 e) { return e; } scientiststd3 scientistsTestF(scientiststd3 e) { return e; } typename TemplateClass::scientiststd1 scientistsTestG(typename TemplateClass::scientiststd1 e) { return e; } typename TemplateClass::scientiststd2 scientistsTestH(typename TemplateClass::scientiststd2 e) { return e; } typename TemplateClass::scientiststd3 scientistsTestI(typename TemplateClass::scientiststd3 e) { return e; } const scientists & scientistsTestJ(const scientists &e) { return e; } }; TemplateClass::scientists scientistsTest1(TemplateClass::scientists e) { return e; } const TemplateClass::scientists scientistsTest2(const TemplateClass::scientists e) { return e; } enum TemplateClass::scientists scientistsTest3(enum TemplateClass::scientists e) { return e; } const enum TemplateClass::scientists scientistsTest4(const enum TemplateClass::scientists e) { return e; } TemplateClass::scientiststd1 scientistsTest5(TemplateClass::scientiststd1 e) { return e; } TemplateClass::scientiststd2 scientistsTest6(TemplateClass::scientiststd2 e) { return e; } TemplateClass::scientiststd3 scientistsTest7(TemplateClass::scientiststd3 e) { return e; } const TemplateClass::scientiststd3 & scientistsTest8(const TemplateClass::scientiststd3 &e) { return e; } namespace Name { template struct TClass { enum scientists { faraday, bell = 20 }; typedef enum scientists scientiststd1; typedef scientists scientiststd2; typedef scientiststd1 scientiststd3; scientists scientistsNameTest1(scientists e) { return e; } enum scientists scientistsNameTest2(enum scientists e) { return e; } const scientists scientistsNameTest3(const scientists e) { return e; } const enum scientists scientistsNameTest4(const enum scientists e) { return e; } typename TClass::scientists scientistsNameTest5(typename TClass::scientists e) { return e; } const typename TClass::scientists scientistsNameTest6(const typename TClass::scientists e) { return e; } enum TClass::scientists scientistsNameTest7(enum TClass::scientists e) { return e; } const enum TClass::scientists scientistsNameTest8(const enum TClass::scientists e) { return e; } typename TClass::scientists scientistsNameTest9(typename TClass::scientists e) { return e; } // enum TClass::scientists scientistsNameTestA(enum TClass::scientists e) { return e; } const typename TClass::scientists scientistsNameTestB(const typename TClass::scientists e) { return e; } // const enum TClass::scientists scientistsNameTestC(const enum TClass::scientists e) { return e; } scientiststd1 scientistsNameTestD(scientiststd1 e) { return e; } scientiststd2 scientistsNameTestE(scientiststd2 e) { return e; } scientiststd3 scientistsNameTestF(scientiststd3 e) { return e; } typename TClass::scientiststd1 scientistsNameTestG(typename TClass::scientiststd1 e) { return e; } typename TClass::scientiststd2 scientistsNameTestH(typename TClass::scientiststd2 e) { return e; } typename TClass::scientiststd3 scientistsNameTestI(typename TClass::scientiststd3 e) { return e; } typename Name::TClass::scientists scientistsNameSpaceTest1(typename Name::TClass::scientists e) { return e; } const typename Name::TClass::scientists scientistsNameSpaceTest2(const typename Name::TClass::scientists e) { return e; } enum Name::TClass::scientists scientistsNameSpaceTest3(enum Name::TClass::scientists e) { return e; } const enum Name::TClass::scientists scientistsNameSpaceTest4(const enum Name::TClass::scientists e) { return e; } typename Name::TClass::scientiststd1 scientistsNameSpaceTest5(typename Name::TClass::scientiststd1 e) { return e; } typename Name::TClass::scientiststd2 scientistsNameSpaceTest6(typename Name::TClass::scientiststd2 e) { return e; } typename Name::TClass::scientiststd3 scientistsNameSpaceTest7(typename Name::TClass::scientiststd3 e) { return e; } // Test TemplateClass::scientists rather then TClass::scientists ::TemplateClass::scientists scientistsOtherTest1(::TemplateClass::scientists e) { return e; } const ::TemplateClass::scientists scientistsOtherTest2(const ::TemplateClass::scientists e) { return e; } enum ::TemplateClass::scientists scientistsOtherTest3(enum ::TemplateClass::scientists e) { return e; } const enum ::TemplateClass::scientists scientistsOtherTest4(const enum ::TemplateClass::scientists e) { return e; } ::TemplateClass::scientiststd1 scientistsOtherTest5(::TemplateClass::scientiststd1 e) { return e; } ::TemplateClass::scientiststd2 scientistsOtherTest6(::TemplateClass::scientiststd2 e) { return e; } ::TemplateClass::scientiststd3 scientistsOtherTest7(::TemplateClass::scientiststd3 e) { return e; } }; TClass::scientists scientistsNameTest1(TClass::scientists e) { return e; } const TClass::scientists scientistsNameTest2(const TClass::scientists e) { return e; } enum TClass::scientists scientistsNameTest3(enum TClass::scientists e) { return e; } const enum TClass::scientists scientistsNameTest4(const enum TClass::scientists e) { return e; } TClass::scientiststd1 scientistsNameTest5(TClass::scientiststd1 e) { return e; } TClass::scientiststd2 scientistsNameTest6(TClass::scientiststd2 e) { return e; } TClass::scientiststd3 scientistsNameTest7(TClass::scientiststd3 e) { return e; } Name::TClass::scientists scientistsNameSpaceTest1(Name::TClass::scientists e) { return e; } const Name::TClass::scientists scientistsNameSpaceTest2(const Name::TClass::scientists e) { return e; } enum Name::TClass::scientists scientistsNameSpaceTest3(enum Name::TClass::scientists e) { return e; } const enum Name::TClass::scientists scientistsNameSpaceTest4(const enum Name::TClass::scientists e) { return e; } Name::TClass::scientiststd1 scientistsNameSpaceTest5(Name::TClass::scientiststd1 e) { return e; } Name::TClass::scientiststd2 scientistsNameSpaceTest6(Name::TClass::scientiststd2 e) { return e; } Name::TClass::scientiststd3 scientistsNameSpaceTest7(Name::TClass::scientiststd3 e) { return e; } } Name::TClass::scientists scientistsNameSpaceTest8(Name::TClass::scientists e) { return e; } const Name::TClass::scientists scientistsNameSpaceTest9(const Name::TClass::scientists e) { return e; } enum Name::TClass::scientists scientistsNameSpaceTestA(enum Name::TClass::scientists e) { return e; } const enum Name::TClass::scientists scientistsNameSpaceTestB(const enum Name::TClass::scientists e) { return e; } Name::TClass::scientiststd1 scientistsNameSpaceTestC(Name::TClass::scientiststd1 e) { return e; } Name::TClass::scientiststd2 scientistsNameSpaceTestD(Name::TClass::scientiststd2 e) { return e; } Name::TClass::scientiststd3 scientistsNameSpaceTestE(Name::TClass::scientiststd3 e) { return e; } using namespace Name; TClass::scientists scientistsNameSpaceTestF(TClass::scientists e) { return e; } const TClass::scientists scientistsNameSpaceTestG(const TClass::scientists e) { return e; } enum TClass::scientists scientistsNameSpaceTestH(enum TClass::scientists e) { return e; } const enum TClass::scientists scientistsNameSpaceTestI(const enum TClass::scientists e) { return e; } TClass::scientiststd1 scientistsNameSpaceTestJ(TClass::scientiststd1 e) { return e; } TClass::scientiststd2 scientistsNameSpaceTestK(TClass::scientiststd2 e) { return e; } TClass::scientiststd3 scientistsNameSpaceTestL(TClass::scientiststd3 e) { return e; } %} %template(TemplateClassInt) TemplateClass; %template(TClassInt) Name::TClass; // %rename tests %rename(NewNameStruct) OldNameStruct; %rename(newname) old_name; %rename(doublenamerenamed) doublename; %rename(simplerenamed) simple; %rename(singlenamerenamed) singlename; %rename(bang) OldNameStruct::kerboom; %inline %{ enum old_name { argh, eek = -1 }; typedef old_name old_nametd; old_name renameTest1(old_name e) { return e; } old_nametd renameTest2(old_nametd e) { return e; } struct OldNameStruct { enum enumeration {whizz, kerboom, pop}; enumeration renameTest1(enumeration e) { return e; } OldNameStruct::enumeration renameTest2(OldNameStruct::enumeration e) { return e; } enum simple {simple1}; typedef enum doublenametag {doublename1} doublename; typedef enum {singlename1} singlename; simple renameTest3(simple e) { return e; } doublename renameTest4(doublename e) { return e; } doublenametag renameTest5(doublenametag e) { return e; } singlename renameTest6(singlename e) { return e; } }; OldNameStruct::enumeration renameTest3(OldNameStruct::enumeration e) { return e; } OldNameStruct::simple renameTest4(OldNameStruct::simple e) { return e; } OldNameStruct::doublename renameTest5(OldNameStruct::doublename e) { return e; } OldNameStruct::doublenametag renameTest6(OldNameStruct::doublenametag e) { return e; } OldNameStruct::singlename renameTest7(OldNameStruct::singlename e) { return e; } %} %inline %{ struct TreesClass { enum trees {oak, fir, pine }; typedef enum trees treestd1; typedef trees treestd2; typedef treestd1 treestd3; typedef TreesClass::trees treestd4; typedef treestd1 treestd5; trees treesTest1(trees e) { return e; } treestd1 treesTest2(treestd1 e) { return e; } treestd2 treesTest3(treestd2 e) { return e; } treestd3 treesTest4(treestd3 e) { return e; } treestd4 treesTest5(treestd4 e) { return e; } treestd5 treesTest6(treestd5 e) { return e; } const trees treesTest7(const trees e) { return e; } const treestd1 treesTest8(const treestd1 e) { return e; } const treestd2 treesTest9(const treestd2 e) { return e; } const treestd3 treesTestA(const treestd3 e) { return e; } const treestd4 treesTestB(const treestd4 e) { return e; } const treestd5 treesTestC(const treestd5 e) { return e; } TreesClass::trees treesTestD(TreesClass::trees e) { return e; } TreesClass::treestd1 treesTestE(TreesClass::treestd1 e) { return e; } TreesClass::treestd2 treesTestF(TreesClass::treestd2 e) { return e; } TreesClass::treestd3 treesTestG(TreesClass::treestd3 e) { return e; } TreesClass::treestd4 treesTestH(TreesClass::treestd4 e) { return e; } TreesClass::treestd5 treesTestI(TreesClass::treestd5 e) { return e; } const TreesClass::trees treesTestJ(const TreesClass::trees e) { return e; } const TreesClass::treestd1 treesTestK(const TreesClass::treestd1 e) { return e; } const TreesClass::treestd2 treesTestL(const TreesClass::treestd2 e) { return e; } const TreesClass::treestd3 treesTestM(const TreesClass::treestd3 e) { return e; } const TreesClass::treestd4 treesTestN(const TreesClass::treestd4 e) { return e; } const TreesClass::treestd5 treesTestO(const TreesClass::treestd5 e) { return e; } }; TreesClass::trees treesTest1(TreesClass::trees e) { return e; } TreesClass::treestd1 treesTest2(TreesClass::treestd1 e) { return e; } TreesClass::treestd2 treesTest3(TreesClass::treestd2 e) { return e; } TreesClass::treestd3 treesTest4(TreesClass::treestd3 e) { return e; } TreesClass::treestd4 treesTest5(TreesClass::treestd4 e) { return e; } TreesClass::treestd5 treesTest6(TreesClass::treestd5 e) { return e; } const TreesClass::trees treesTest7(const TreesClass::trees e) { return e; } const TreesClass::treestd1 treesTest8(const TreesClass::treestd1 e) { return e; } const TreesClass::treestd2 treesTest9(const TreesClass::treestd2 e) { return e; } const TreesClass::treestd3 treesTestA(const TreesClass::treestd3 e) { return e; } const TreesClass::treestd4 treesTestB(const TreesClass::treestd4 e) { return e; } const TreesClass::treestd5 treesTestC(const TreesClass::treestd5 e) { return e; } typedef enum TreesClass::trees treesglobaltd1; typedef TreesClass::trees treesglobaltd2; typedef TreesClass::treestd1 treesglobaltd3; typedef TreesClass::treestd2 treesglobaltd4; typedef treesglobaltd4 treesglobaltd5; treesglobaltd1 treesTestD(treesglobaltd1 e) { return e; } treesglobaltd2 treesTestE(treesglobaltd2 e) { return e; } treesglobaltd3 treesTestF(treesglobaltd3 e) { return e; } treesglobaltd4 treesTestG(treesglobaltd4 e) { return e; } treesglobaltd5 treesTestH(treesglobaltd5 e) { return e; } const treesglobaltd1 treesTestI(const treesglobaltd1 e) { return e; } const treesglobaltd2 treesTestJ(const treesglobaltd2 e) { return e; } const treesglobaltd3 treesTestK(const treesglobaltd3 e) { return e; } const treesglobaltd4 treesTestL(const treesglobaltd4 e) { return e; } const treesglobaltd5 treesTestM(const treesglobaltd5 e) { return e; } typedef const enum TreesClass::trees treesglobaltd6; typedef const TreesClass::trees treesglobaltd7; typedef const TreesClass::treestd1 treesglobaltd8; typedef const TreesClass::treestd2 treesglobaltd9; typedef const treesglobaltd4 treesglobaltdA; //treesglobaltd6 treesTestN(treesglobaltd6 e) { return e; } // casting using an int instead of treesglobaltd6 treesglobaltd7 treesTestO(treesglobaltd7 e) { return e; } treesglobaltd8 treesTestP(treesglobaltd8 e) { return e; } treesglobaltd9 treesTestQ(treesglobaltd9 e) { return e; } treesglobaltdA treesTestR(treesglobaltdA e) { return e; } namespace curly { namespace greasy { struct HairStruct { enum hair { blonde=0xFF0, ginger }; typedef hair hairtd1; typedef HairStruct::hair hairtd2; typedef greasy::HairStruct::hair hairtd3; typedef curly::greasy::HairStruct::hair hairtd4; typedef ::curly::greasy::HairStruct::hair hairtd5; typedef hairtd1 hairtd6; typedef HairStruct::hairtd1 hairtd7; typedef greasy::HairStruct::hairtd1 hairtd8; typedef curly::greasy::HairStruct::hairtd1 hairtd9; typedef ::curly::greasy::HairStruct::hairtd1 hairtdA; hair hairTest1(hair e) { return e; } hairtd1 hairTest2(hairtd1 e) { return e; } hairtd2 hairTest3(hairtd2 e) { return e; } hairtd3 hairTest4(hairtd3 e) { return e; } hairtd4 hairTest5(hairtd4 e) { return e; } hairtd5 hairTest6(hairtd5 e) { return e; } hairtd6 hairTest7(hairtd6 e) { return e; } hairtd7 hairTest8(hairtd7 e) { return e; } hairtd8 hairTest9(hairtd8 e) { return e; } hairtd9 hairTestA(hairtd9 e) { return e; } hairtdA hairTestB(hairtdA e) { return e; } ::colour colourTest1(::colour e) { return e; } enum colour colourTest2(enum colour e) { return e; } namedanon namedanonTest1(namedanon e) { return e; } AnonSpace::namedanonspace namedanonspaceTest1(AnonSpace::namedanonspace e) { return e; } treesglobaltd1 treesGlobalTest1(treesglobaltd1 e) { return e; } treesglobaltd2 treesGlobalTest2(treesglobaltd2 e) { return e; } treesglobaltd3 treesGlobalTest3(treesglobaltd3 e) { return e; } treesglobaltd4 treesGlobalTest4(treesglobaltd4 e) { return e; } treesglobaltd5 treesGlobalTest5(treesglobaltd5 e) { return e; } }; HairStruct::hair hairTest1(HairStruct::hair e) { return e; } HairStruct::hairtd1 hairTest2(HairStruct::hairtd1 e) { return e; } HairStruct::hairtd2 hairTest3(HairStruct::hairtd2 e) { return e; } HairStruct::hairtd3 hairTest4(HairStruct::hairtd3 e) { return e; } HairStruct::hairtd4 hairTest5(HairStruct::hairtd4 e) { return e; } HairStruct::hairtd5 hairTest6(HairStruct::hairtd5 e) { return e; } HairStruct::hairtd6 hairTest7(HairStruct::hairtd6 e) { return e; } HairStruct::hairtd7 hairTest8(HairStruct::hairtd7 e) { return e; } HairStruct::hairtd8 hairTest9(HairStruct::hairtd8 e) { return e; } HairStruct::hairtd9 hairTestA(HairStruct::hairtd9 e) { return e; } HairStruct::hairtdA hairTestB(HairStruct::hairtdA e) { return e; } const HairStruct::hair & hairTestC(const HairStruct::hair &e) { return e; } } greasy::HairStruct::hair hairTestA1(greasy::HairStruct::hair e) { return e; } greasy::HairStruct::hairtd1 hairTestA2(greasy::HairStruct::hairtd1 e) { return e; } greasy::HairStruct::hairtd2 hairTestA3(greasy::HairStruct::hairtd2 e) { return e; } greasy::HairStruct::hairtd3 hairTestA4(greasy::HairStruct::hairtd3 e) { return e; } greasy::HairStruct::hairtd4 hairTestA5(greasy::HairStruct::hairtd4 e) { return e; } greasy::HairStruct::hairtd5 hairTestA6(greasy::HairStruct::hairtd5 e) { return e; } greasy::HairStruct::hairtd6 hairTestA7(greasy::HairStruct::hairtd6 e) { return e; } greasy::HairStruct::hairtd7 hairTestA8(greasy::HairStruct::hairtd7 e) { return e; } greasy::HairStruct::hairtd8 hairTestA9(greasy::HairStruct::hairtd8 e) { return e; } greasy::HairStruct::hairtd9 hairTestAA(greasy::HairStruct::hairtd9 e) { return e; } greasy::HairStruct::hairtdA hairTestAB(greasy::HairStruct::hairtdA e) { return e; } const greasy::HairStruct::hairtdA & hairTestAC(const greasy::HairStruct::hairtdA &e) { return e; } } curly::greasy::HairStruct::hair hairTestB1(curly::greasy::HairStruct::hair e) { return e; } curly::greasy::HairStruct::hairtd1 hairTestB2(curly::greasy::HairStruct::hairtd1 e) { return e; } curly::greasy::HairStruct::hairtd2 hairTestB3(curly::greasy::HairStruct::hairtd2 e) { return e; } curly::greasy::HairStruct::hairtd3 hairTestB4(curly::greasy::HairStruct::hairtd3 e) { return e; } curly::greasy::HairStruct::hairtd4 hairTestB5(curly::greasy::HairStruct::hairtd4 e) { return e; } curly::greasy::HairStruct::hairtd5 hairTestB6(curly::greasy::HairStruct::hairtd5 e) { return e; } curly::greasy::HairStruct::hairtd6 hairTestB7(curly::greasy::HairStruct::hairtd6 e) { return e; } curly::greasy::HairStruct::hairtd7 hairTestB8(curly::greasy::HairStruct::hairtd7 e) { return e; } curly::greasy::HairStruct::hairtd8 hairTestB9(curly::greasy::HairStruct::hairtd8 e) { return e; } curly::greasy::HairStruct::hairtd9 hairTestBA(curly::greasy::HairStruct::hairtd9 e) { return e; } curly::greasy::HairStruct::hairtdA hairTestBB(curly::greasy::HairStruct::hairtdA e) { return e; } const curly::greasy::HairStruct::hairtdA & hairTestBC(const curly::greasy::HairStruct::hairtdA &e) { return e; } using curly::greasy::HairStruct; HairStruct::hair hairTestC1(HairStruct::hair e) { return e; } HairStruct::hairtd1 hairTestC2(HairStruct::hairtd1 e) { return e; } HairStruct::hairtd2 hairTestC3(HairStruct::hairtd2 e) { return e; } HairStruct::hairtd3 hairTestC4(HairStruct::hairtd3 e) { return e; } HairStruct::hairtd4 hairTestC5(HairStruct::hairtd4 e) { return e; } HairStruct::hairtd5 hairTestC6(HairStruct::hairtd5 e) { return e; } HairStruct::hairtd6 hairTestC7(HairStruct::hairtd6 e) { return e; } HairStruct::hairtd7 hairTestC8(HairStruct::hairtd7 e) { return e; } HairStruct::hairtd8 hairTestC9(HairStruct::hairtd8 e) { return e; } HairStruct::hairtd9 hairTestCA(HairStruct::hairtd9 e) { return e; } HairStruct::hairtdA hairTestCB(HairStruct::hairtdA e) { return e; } const HairStruct::hairtdA & hairTestCC(const HairStruct::hairtdA &e) { return e; } namespace curly { namespace greasy { struct FirStruct : HairStruct { hair hairTestFir1(hair e) { return e; } hairtd1 hairTestFir2(hairtd1 e) { return e; } hairtd2 hairTestFir3(hairtd2 e) { return e; } hairtd3 hairTestFir4(hairtd3 e) { return e; } hairtd4 hairTestFir5(hairtd4 e) { return e; } hairtd5 hairTestFir6(hairtd5 e) { return e; } hairtd6 hairTestFir7(hairtd6 e) { return e; } hairtd7 hairTestFir8(hairtd7 e) { return e; } hairtd8 hairTestFir9(hairtd8 e) { return e; } hairtd9 hairTestFirA(hairtd9 e) { return e; } hairtdA hairTestFirB(hairtdA e) { return e; } }; } } struct Obscure { enum Zero {}; enum One {one}; enum Two {two, twoagain}; #if defined(SWIG) // g++-4.3 warns about this typedef enum Empty {}; #endif typedef enum {} AlsoEmpty; }; // Unnamed enum instance extern "C" { enum { globalinstance1, globalinstance2, globalinstance3 = 30 } GlobalInstance; } struct Instances { enum { memberinstance1, memberinstance2, memberinstance3 = 300 } MemberInstance; Instances() : MemberInstance(memberinstance3) {} }; %} // Repeated values #if defined(SWIGJAVA) %javaconst(1); // needed for typesafe and proper enums only %javaconst(0) ignoreA_three; %javaconst(0) ignoreA_thirteen; #elif defined(SWIGCSHARP) // needed for typesafe enums only #ifdef SWIG_TEST_NOCSCONST %csconst(0) ignoreA_three; %csconst(0) ignoreA_thirteen; #endif %csconst(1); #endif %ignore ignoreA_one; %ignore ignoreA_two; %ignore ignoreA_twelve; %ignore ignoreA_thirty_one; %ignore ignoreB_ten; %ignore ignoreB_twenty; %ignore ignoreB_thirty; %ignore ignoreB_forty; %ignore ignoreC_eleven; %ignore ignoreC_thirty_one; %ignore ignoreC_forty_one; %ignore ignoreD_ten; %ignore ignoreD_twenty; %ignore ignoreE_twenty; %inline %{ struct IgnoreTest { enum IgnoreA { ignoreA_zero, ignoreA_one, ignoreA_two, ignoreA_three, ignoreA_ten=10, ignoreA_eleven, ignoreA_twelve, ignoreA_thirteen, ignoreA_fourteen, ignoreA_twenty=20, ignoreA_thirty=30, ignoreA_thirty_one, ignoreA_thirty_two, ignoreA_thirty_three }; enum IgnoreB { ignoreB_ten=10, ignoreB_eleven, ignoreB_twelve, ignoreB_twenty=20, ignoreB_thirty=30, ignoreB_thirty_one, ignoreB_thirty_two, ignoreB_forty=40, ignoreB_forty_one, ignoreB_forty_two }; enum IgnoreC { ignoreC_ten=10, ignoreC_eleven, ignoreC_twelve, ignoreC_twenty=20, ignoreC_thirty=30, ignoreC_thirty_one, ignoreC_thirty_two, ignoreC_forty=40, ignoreC_forty_one, ignoreC_forty_two }; enum IgnoreD { ignoreD_ten=10, ignoreD_twenty=20, ignoreD_twenty_one, ignoreD_twenty_two }; enum IgnoreE { ignoreE_zero, ignoreE_twenty=20, ignoreE_twenty_one, ignoreE_twenty_two }; }; IgnoreTest::IgnoreA ignoreATest(IgnoreTest::IgnoreA n) { return n; } IgnoreTest::IgnoreB ignoreBTest(IgnoreTest::IgnoreB n) { return n; } IgnoreTest::IgnoreC ignoreCTest(IgnoreTest::IgnoreC n) { return n; } IgnoreTest::IgnoreD ignoreDTest(IgnoreTest::IgnoreD n) { return n; } IgnoreTest::IgnoreE ignoreETest(IgnoreTest::IgnoreE n) { return n; } %} %inline %{ namespace RepeatSpace { typedef enum { one = 1, initial = one, two, three, llast = three, end = llast } repeat; repeat repeatTest(repeat e) { return e; } } %} %inline %{ namespace DifferentSpace { enum DifferentTypes { typeint = 10, typeboolfalse = false, typebooltrue = true, typebooltwo, typechar = 'C', typedefaultint }; DifferentTypes differentTypesTest(DifferentTypes n) { return n; } enum { global_typeint = 10, global_typeboolfalse = false, global_typebooltrue = true, global_typebooltwo, global_typechar = 'C', global_typedefaultint }; int globalDifferentTypesTest(int n) { return n; } } %} #if defined(SWIGJAVA) %javaconst(0); #elif defined(SWIGCSHARP) %csconst(0); #endif %inline %{ namespace DifferentSpace { enum DifferentTypesNoConst { typeint_noconst = 10, typeboolfalse_noconst = false, typebooltrue_noconst = true, typebooltwo_noconst, typechar_noconst = 'C', typedefaultint_noconst }; enum { global_typeint_noconst = 10, global_typeboolfalse_noconst = false, global_typebooltrue_noconst = true, global_typebooltwo_noconst, global_typechar_noconst = 'C', global_typedefaultint_noconst }; } %} swig-3.0.2/Examples/test-suite/schemerunme/0000775000175000017500000000000012343605122020542 5ustar williamwilliamswig-3.0.2/Examples/test-suite/schemerunme/typedef_inherit.scm0000664000175000017500000000060512343605122024431 0ustar williamwilliam(define a (new-Foo)) (define b (new-Bar)) (if (not (string=? (do-blah a) "Foo::blah")) (error "bad return")) (if (not (string=? (do-blah b) "Bar::blah")) (error "bad return")) (define c (new-Spam)) (define d (new-Grok)) (if (not (string=? (do-blah2 c) "Spam::blah")) (error "bad return")) (if (not (string=? (do-blah2 d) "Grok::blah")) (error "bad return")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/overload_simple.scm0000664000175000017500000000341512343605122024435 0ustar williamwilliam(if (not (string=? (foo 3) "foo:int")) (error "foo(int)")) (if (not (string=? (foo 3.01) "foo:double")) (error "foo(double)")) (if (not (string=? (foo "hello") "foo:char *")) (error "foo(char *)")) (let ((f (new-Foo)) (b (new-Bar)) (s (new-Spam))) (if (not (string=? (foo f) "foo:Foo *")) (error "foo(Foo *)")) (if (not (string=? (foo b) "foo:Bar *")) (error "foo(Bar *)")) ;; Test member functions (if (not (string=? (Spam-foo s 3) "foo:int")) (error "Spam::foo(int)")) (if (not (string=? (Spam-foo s 3.01) "foo:double")) (error "Spam::foo(double)")) (if (not (string=? (Spam-foo s "hello") "foo:char *")) (error "Spam::foo(char *)")) (if (not (string=? (Spam-foo s f) "foo:Foo *")) (error "Spam::foo(Foo *)")) (if (not (string=? (Spam-foo s b) "foo:Bar *")) (error "Spam::foo(Bar *)")) ;; Test static member functions (if (not (string=? (Spam-bar 3) "bar:int")) (error "Spam::bar(int)")) (if (not (string=? (Spam-bar 3.01) "bar:double")) (error "Spam::bar(double)")) (if (not (string=? (Spam-bar "hello") "bar:char *")) (error "Spam::bar(char *)")) (if (not (string=? (Spam-bar f) "bar:Foo *")) (error "Spam::bar(Foo *)")) (if (not (string=? (Spam-bar b) "bar:Bar *")) (error "Spam::bar(Bar *)")) ;; Test constructors (if (not (string=? (Spam-type-get (new-Spam)) "none")) (error "Spam()")) (if (not (string=? (Spam-type-get (new-Spam 3)) "int")) (error "Spam(int)")) (if (not (string=? (Spam-type-get (new-Spam 3.4)) "double")) (error "Spam(double)")) (if (not (string=? (Spam-type-get (new-Spam "hello")) "char *")) (error "Spam(char *)")) (if (not (string=? (Spam-type-get (new-Spam b)) "Bar *")) (error "Spam(Bar *)"))) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/class_ignore.scm0000664000175000017500000000015212343605122023714 0ustar williamwilliam(define a (new-Bar)) (if (not (string=? (Bar-blah a) "Bar::blah")) (error "Wrong string")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/dynamic_cast.scm0000664000175000017500000000026712343605122023711 0ustar williamwilliam(define f (new-Foo)) (define b (new-Bar)) (define x (Foo-blah f)) (define y (Bar-blah b)) (define a (do-test y)) (if (not (string=? a "Bar::test")) (error "Failed!")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/li_typemaps.scm0000664000175000017500000000262312343605122023577 0ustar williamwilliam(define-macro (check func val test) (cons 'begin (map (lambda (x) `(if (not (,test (,(string->symbol (string-append x func)) ,val) ,val)) (error ,(string-append "Error in test " x func)))) (list "in-" "inr-" "out-" "outr-" "inout-" "inoutr-")))) (define (=~ a b) (< (abs (- a b)) 1e-5)) (check "bool" #t and) (check "int" -2 =) (check "long" -32 =) (check "short" -15 =) (check "uint" 75 =) (check "ushort" 123 =) (check "ulong" 462 =) ;(check "uchar" 16 =) ;(check "schar" -53 =) (check "float" 4.3 =~) (check "double" -175.42 =~) ;(check "longlong" 1634 =) ;(check "ulonglong" 6432 =) ;; The checking of inoutr-int2 and out-foo is done in the individual ;; language runme scripts, since chicken returns multiple values ;; and must be checked with call-with-values, while guile just returns a list ;(call-with-values (lambda () (inoutr-int2 3 -2)) ; (lambda (a b) ; (if (not (and (= a 3) (= b -2))) ; (error "Error in inoutr-int2")))) ;(call-with-values (lambda () (out-foo 4)) ; (lambda (a b) ; (if (not (and (= (Foo-a-get a) 4) (= b 8))) ; (error "Error in out-foo")))) ;(let ((lst (inoutr-int2 3 -2))) ; (if (not (and (= (car lst) 3) (= (cadr lst) -2))) ; (error "Error in inoutr-int2"))) ;(let ((lst (out-foo 4))) ; (if (not (and (= (Foo-a-get (car lst)) 4) (= (cadr lst) 8))) ; (error "Error in out-foo"))) swig-3.0.2/Examples/test-suite/schemerunme/unions.scm0000664000175000017500000000206112343605122022560 0ustar williamwilliam;;; This is the union runtime testcase. It ensures that values within a ;;; union embedded within a struct can be set and read correctly. ;; Create new instances of SmallStruct and BigStruct for later use (define small (new-SmallStruct)) (SmallStruct-jill-set small 200) (define big (new-BigStruct)) (BigStruct-smallstruct-set big small) (BigStruct-jack-set big 300) ;; Use SmallStruct then BigStruct to setup EmbeddedUnionTest. ;; Ensure values in EmbeddedUnionTest are set correctly for each. (define eut (new-EmbeddedUnionTest)) ;; First check the SmallStruct in EmbeddedUnionTest (EmbeddedUnionTest-number-set eut 1) (EmbeddedUnionTest-uni-small-set (EmbeddedUnionTest-uni-get eut) small) (let ((Jill1 (SmallStruct-jill-get (EmbeddedUnionTest-uni-small-get (EmbeddedUnionTest-uni-get eut))))) (if (not (= Jill1 200)) (begin (display "Runtime test 1 failed.") (exit 1)))) (let ((Num1 (EmbeddedUnionTest-number-get eut))) (if (not (= Num1 1)) (begin (display "Runtime test 2 failed.") (exit 1)))) ;; that should do (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/cpp_enum.scm0000664000175000017500000000052712343605122023060 0ustar williamwilliam(define f (new-Foo)) (if (not (= (Foo-hola-get f) (Foo-Hello))) (error "Error 1")) (Foo-hola-set f (Foo-Hi)) (if (not (= (Foo-hola-get f) (Foo-Hi))) (error "Error 2")) (Foo-hola-set f (Foo-Hello)) (if (not (= (Foo-hola-get f) (Foo-Hello))) (error "Error 3")) (hi (Hello)) (if (not (= (hi) (Hello))) (error "Error 4")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/constover.scm0000664000175000017500000000124112343605122023266 0ustar williamwilliam(define p (test "test")) (if (not (string=? p "test")) (error "test failed!")) (set! p (test-pconst "test")) (if (not (string=? p "test_pconst")) (error "test_pconst failed!")) (define f (new-Foo)) (set! p (Foo-test f "test")) (if (not (string=? p "test")) (error "member-test failed!")) (set! p (Foo-test-pconst f "test")) (if (not (string=? p "test_pconst")) (error "member-test_pconst failed!")) (set! p (Foo-test-constm f "test")) (if (not (string=? p "test_constmethod")) (error "member-test_constm failed!")) (set! p (Foo-test-pconstm f "test")) (if (not (string=? p "test_pconstmethod")) (error "member-test_pconstm failed!")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/multivalue.scm0000664000175000017500000000071312343605122023436 0ustar williamwilliam;;;; Automatic test of multiple return values (let ((quotient/remainder (divide-l 37 5))) (if (not (equal? quotient/remainder '(7 2))) (exit 1))) (let ((quotient-remainder-vector (divide-v 41 7))) (if (not (equal? quotient-remainder-vector #(5 6))) (exit 1))) (call-with-values (lambda () (divide-mv 91 13)) (lambda (quotient remainder) (if (not (and (= quotient 7) (= remainder 0))) (exit 1)))) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/typename.scm0000664000175000017500000000040012343605122023062 0ustar williamwilliam(define f (new-Foo)) (define b (new-Bar)) (define x (twoFoo f)) ;;(if (not (isinstance x (types-FloatType))) ;; (error "wrong return type")) (define y (twoBar b)) ;;(if (not (isinstance y (types-IntType))) ;; (error "wrong return type")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/li_typemaps_proxy.scm0000664000175000017500000000261512343605122025041 0ustar williamwilliam(define-macro (check func val test) (cons 'begin (map (lambda (x) `(if (not (,test (,(string->symbol (string-append x func)) ,val) ,val)) (error ,(string-append "Error in test " x func)))) (list "in-" "inr-" "out-" "outr-" "inout-" "inoutr-")))) (define (=~ a b) (< (abs (- a b)) 1e-5)) (check "bool" #t and) (check "int" -2 =) (check "long" -32 =) (check "short" -15 =) (check "uint" 75 =) (check "ushort" 123 =) (check "ulong" 462 =) ;(check "uchar" 16 =) ;(check "schar" -53 =) (check "float" 4.3 =~) (check "double" -175.42 =~) (check "longlong" 1634 =) (check "ulonglong" 6432 =) ;; The checking of inoutr-int2 and out-foo is done in the individual ;; language runme scripts, since chicken returns multiple values ;; and must be checked with call-with-values, while guile just returns a list ;(call-with-values (lambda () (inoutr-int2 3 -2)) ; (lambda (a b) ; (if (not (and (= a 3) (= b -2))) ; (error "Error in inoutr-int2")))) ;(call-with-values (lambda () (out-foo 4)) ; (lambda (a b) ; (if (not (and (= (slot-ref a 'a) 4) (= b 8))) ; (error "Error in out-foo")))) ;(let ((lst (inoutr-int2 3 -2))) ; (if (not (and (= (car lst) 3) (= (cadr lst) -2))) ; (error "Error in inoutr-int2"))) ;(let ((lst (out-foo 4))) ; (if (not (and (= (slot-ref (car lst) 'a) 4) (= (cadr lst) 8))) ; (error "Error in out-foo"))) swig-3.0.2/Examples/test-suite/schemerunme/contract.scm0000664000175000017500000000060612343605122023065 0ustar williamwilliam(test-preassert 1 2) (expect-throw 'swig-contract-assertion-failed (test-preassert -1 2)) (test-postassert 3) (expect-throw 'swig-contract-assertion-failed (test-postassert -3)) (test-prepost 2 3) (test-prepost 5 -4) (expect-throw 'swig-contract-assertion-failed (test-prepost -3 4)) (expect-throw 'swig-contract-assertion-failed (test-prepost 4 -10)) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/list_vector.scm0000664000175000017500000000155712343605122023613 0ustar williamwilliam(define-macro (check-equality form1 form2) `(let ((result1 ,form1) (result2 ,form2)) (if (not (equal? result1 result2)) (error "Check failed:" (list 'equal? ',form1 ',form2) result1 result2)))) (check-equality (sum-list '(1 3 4 6 7)) 21.0) (check-equality (sum-vector #(2 4 6 7 9)) 28.0) (check-equality (one-to-seven-list) '(1 2 3 4 5 6 7)) (check-equality (one-to-seven-vector) #(1 2 3 4 5 6 7)) (check-equality (sum-list2 '(1 3 4 6 7)) 21.0) (check-equality (sum-vector2 #(2 4 6 7 9)) 28.0) (check-equality (one-to-seven-list2) '(1 2 3 4 5 6 7)) (check-equality (one-to-seven-vector2) #(1 2 3 4 5 6 7)) (check-equality (sum-lists '(1 2 3) '(4 5 6) '(7 8 9)) 45.0) (check-equality (sum-lists2 '(1 2 3) '(4 5 6) '(7 8 9)) 45.0) (check-equality (call-with-values produce-lists list) '(#(0 1 2 3 4) #(0 1 4 9 16) #(0.0 1.5 3.0 4.5 6.0))) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/pointer_in_out.scm0000664000175000017500000000040012343605122024275 0ustar williamwilliam(define-macro (check form) `(if (not ,form) (error "Check failed: " ',form))) (define p (produce-int-pointer 47 11)) (check (= (consume-int-pointer p) 47)) (define q (frobnicate-int-pointer p)) (check (= (consume-int-pointer q) 11)) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/li_std_string.scm0000664000175000017500000000274212343605122024117 0ustar williamwilliam; The test string has some non-ascii characters added ; because our guile wrappers had bugs in that area (define x "hello - æææ") (if (not (string=? (test-value x) x)) (begin (error "Error 1") (exit 1))) (if (not (string=? (test-const-reference x) x)) (begin (error "Error 2") (exit 1))) (define y (test-pointer-out)) (test-pointer y) (define z (test-const-pointer-out)) (test-const-pointer z) (define a (test-reference-out)) (test-reference a) ;; test global variables (GlobalString "whee") (if (not (string=? (GlobalString) "whee")) (error "Error 3")) (if (not (string=? (GlobalString2) "global string 2")) (error "Error 4")) (define struct (new-Structure)) ;; MemberString should be a wrapped class (define scl (Structure-MemberString-get struct)) (if (not (string=? scl "")) (error "Error 4.5")) (Structure-MemberString-set struct "and how") (if (not (string=? (Structure-MemberString-get struct) "and how")) (error "Error 5")) (if (not (string=? (Structure-MemberString2-get struct) "member string 2")) (error "Error 6")) (Structure-StaticMemberString "static str") (if (not (string=? (Structure-StaticMemberString) "static str")) (error "Error 7")) (if (not (string=? (Structure-StaticMemberString2) "static member string 2")) (error "Error 8")) ;(if (not (string=? (Structure-ConstMemberString-get struct) "const member string")) ; (error "Error 9")) (if (not (string=? (Structure-ConstStaticMemberString) "const static member string")) (error "Error 10")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/cpp_namespace.scm0000664000175000017500000000172312343605122024047 0ustar williamwilliam(define n (fact 4)) (if (not (= n 24)) (error "Bad return value!")) (if (not (= (Foo) 42)) (error "bad variable value!")) (define t (new-Test)) (if (not (string=? (Test-method t) "Test::method")) (error "Bad method return value!")) (if (not (string=? (do-method t) "Test::method")) (error "Bad return value!")) (if (not (string=? (do-method2 t) "Test::method")) (error "Bad return value!")) (weird "hello" 4) ;; (delete-Test t) (define t2 (new-Test2)) (define t3 (new-Test3)) (define t4 (new-Test4)) (define t5 (new-Test5)) (if (not (= (foo3 42) 42)) (error "Bad return value!")) (if (not (string=? (do-method3 t2 40) "Test2::method")) (error "bad return value!")) (if (not (string=? (do-method3 t3 40) "Test3::method")) (error "bad return value")) (if (not (string=? (do-method3 t4 40) "Test4::method")) (error "bad return value")) (if (not (string=? (do-method3 t5 40) "Test5::method")) (error "bad return value")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/char_constant.scm0000664000175000017500000000013312343605122024071 0ustar williamwilliam(if (and (char? (CHAR-CONSTANT)) (string? (STRING-CONSTANT))) (exit 0) (exit 1)) swig-3.0.2/Examples/test-suite/schemerunme/imports.scm0000664000175000017500000000064312343605122022746 0ustar williamwilliam;;; This file is part of a test for SF bug #231619. ;;; It shows that the %import directive does not work properly in SWIG ;;; 1.3a5: Type information is not properly generated if a base class ;;; comes from an %import-ed file. (define x (new-B)) ;; This fails in 1.3a5 because the SWIG runtime code does not know ;; that x (an instance of class B) can be passed to methods of class A. (A-hello x) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/overload_complicated.scm0000664000175000017500000000050412343605122025424 0ustar williamwilliam(define-macro (check form) `(if (not ,form) (error "Check failed: " ',form))) (define (=~ a b) (< (abs (- a b)) 1e-8)) ;; Check first method (check (=~ (foo 1 2 "bar" 4) 15)) ;; Check second method (check (=~ (foo 1 2) 4811.4)) (check (=~ (foo 1 2 3.2) 4797.2)) (check (=~ (foo 1 2 3.2 #\Q) 4798.2)) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/overload_extend.scm0000664000175000017500000000035212343605122024430 0ustar williamwilliam(define f (new-Foo)) (if (not (= (Foo-test f 3) 1)) (error "test integer bad")) (if (not (= (Foo-test f "hello") 2)) (error "test string bad")) (if (not (= (Foo-test f 3.5 2.5) 6.0)) (error "test reals bad")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/overload_subtype.scm0000664000175000017500000000016312343605122024634 0ustar williamwilliam(if (not (= (spam (new-Foo)) 1)) (error "foo")) (if (not (= (spam (new-Bar)) 2)) (error "bar")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/import_nomodule.scm0000664000175000017500000000012212343605122024455 0ustar williamwilliam(define f (create-Foo)) (test1 f 42) (define b (new-Bar)) (test1 b 37) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/integers.scm0000664000175000017500000000453512343605122023075 0ustar williamwilliam(define-macro (check-equality form1 form2) `(let ((result1 ,form1) (result2 ,form2)) (if (not (equal? result1 result2)) (error "Check failed:" (list 'equal? ',form1 ',form2) result1 result2)))) (define-macro (check-range function from to) `(begin (check-equality (,function ,from) ,from) (check-equality (,function ,to) ,to) (check-equality (throws-exception? (,function (- ,from 1))) #t) (check-equality (throws-exception? (,function (+ ,to 1))) #t))) (let ((signed-short-min (- (expt 2 (- (* (signed-short-size) 8) 1)))) (signed-short-max (- (expt 2 (- (* (signed-short-size) 8) 1)) 1)) (unsigned-short-max (- (expt 2 (* (unsigned-short-size) 8)) 1)) (signed-int-min (- (expt 2 (- (* (signed-int-size) 8) 1)))) (signed-int-max (- (expt 2 (- (* (signed-int-size) 8) 1)) 1)) (unsigned-int-max (- (expt 2 (* (unsigned-int-size) 8)) 1)) (signed-long-min (- (expt 2 (- (* (signed-long-size) 8) 1)))) (signed-long-max (- (expt 2 (- (* (signed-long-size) 8) 1)) 1)) (unsigned-long-max (- (expt 2 (* (unsigned-long-size) 8)) 1)) (signed-long-long-min (- (expt 2 (- (* (signed-long-long-size) 8) 1)))) (signed-long-long-max (- (expt 2 (- (* (signed-long-long-size) 8) 1)) 1)) (unsigned-long-long-max (- (expt 2 (* (unsigned-long-long-size) 8)) 1)) ) ;;; signed char, unsigned char typemaps deal with characters, not integers. ;; (check-range signed-char-identity (- (expt 2 7)) (- (expt 2 7) 1)) ;; (check-range unsigned-char-identity 0 (- (expt 2 8) 1)) (check-range signed-short-identity signed-short-min signed-short-max) (check-range unsigned-short-identity 0 unsigned-short-max) (check-range signed-int-identity signed-int-min signed-int-max) (check-range unsigned-int-identity 0 unsigned-int-max) (check-range signed-long-identity signed-long-min signed-long-max) (check-range signed-long-long-identity signed-long-long-min signed-long-long-max) ;;; unsigned (long) long is broken in guile 1.8 on Mac OS X, skip test (if (or (>= (string->number (major-version)) 2) (not (equal? (utsname:sysname (uname)) "Darwin"))) (begin (check-range unsigned-long-identity 0 unsigned-long-max) (check-range unsigned-long-long-identity 0 unsigned-long-long-max)) ) ) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/casts.scm0000664000175000017500000000025412343605122022364 0ustar williamwilliam(define x (new-B)) ;; This fails in 1.3a5 because the SWIG/Guile runtime code gets the ;; source and the target of a cast the wrong way around. (A-hello x) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/name.scm0000664000175000017500000000003612343605122022165 0ustar williamwilliam(foo-2) bar-2 Baz-2 (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/multiple_inheritance_proxy.scm0000664000175000017500000000124112343605122026711 0ustar williamwilliam(define-macro (check test) `(if (not ,test) (error "Error in test" ',test))) (define b (make )) (check (= (bar b) 1)) (define f (make )) (check (= (foo f) 2)) (define fb (make )) (check (= (bar fb) 1)) (check (= (foo fb) 2)) (check (= (fooBar fb) 3)) (define id1 (make )) (check (= (bar id1) 1)) (check (= (ignorederived1 id1) 7)) (define id2 (make )) (check (= (bar id2) 1)) (check (= (ignorederived2 id2) 8)) (define id3 (make )) (check (= (bar id3) 1)) (check (= (ignorederived3 id3) 9)) (define id4 (make )) (check (= (bar id4) 1)) (check (= (ignorederived4 id4) 10)) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/unions_proxy.scm0000664000175000017500000000174112343605122024025 0ustar williamwilliam;;; This is the union runtime testcase. It ensures that values within a ;;; union embedded within a struct can be set and read correctly. ;; Create new instances of SmallStruct and BigStruct for later use (define small (make )) (slot-set! small 'jill 200) (define big (make )) (slot-set! big 'smallstruct small) (slot-set! big 'jack 300) ;; Use SmallStruct then BigStruct to setup EmbeddedUnionTest. ;; Ensure values in EmbeddedUnionTest are set correctly for each. (define eut (make )) ;; First check the SmallStruct in EmbeddedUnionTest (slot-set! eut 'number 1) (slot-set! (slot-ref eut 'uni) 'small small) (let ((Jill1 (slot-ref (slot-ref (slot-ref eut 'uni) 'small) 'jill))) (if (not (= Jill1 200)) (begin (display "Runtime test 1 failed.") (exit 1)))) (let ((Num1 (slot-ref eut 'number))) (if (not (= Num1 1)) (begin (display "Runtime test 2 failed.") (exit 1)))) ;; that should do (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/global_vars.scm0000664000175000017500000000077612343605122023553 0ustar williamwilliam(define-macro (check test) `(if (not ,test) (error "Error in test" ',test))) (b "hello") (check (string=? (b) "hello")) (define sa (new-A)) (A-x-set sa 5) (a sa) (check (= (A-x-get (a)) 5)) (ap sa) (check (= (A-x-get (ap)) 5)) (A-x-set sa 10) (check (= (A-x-get (ap)) 10)) (define sa2 (new-A)) (A-x-set sa2 -4) (cap sa2) (check (= (A-x-get (cap)) -4)) (A-x-set sa2 -7) (check (= (A-x-get (cap)) -7)) (check (= (A-x-get (ar)) 5)) (ar sa2) (check (= (A-x-get (ar)) -7)) (x 4) (check (= (x) 4)) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/inherit_missing.scm0000664000175000017500000000044312343605122024442 0ustar williamwilliam(define a (new-Foo)) (define b (new-Bar)) (define c (new-Spam)) (if (not (string=? (do-blah a) "Foo::blah")) (error "Bad return")) (if (not (string=? (do-blah b) "Bar::blah")) (error "Bad return")) (if (not (string=? (do-blah c) "Spam::blah")) (error "bad return")) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/reference_global_vars.scm0000664000175000017500000000402512343605122025560 0ustar williamwilliam(define (!= a b) (not (= a b))) ; const class reference variable (if (!= (TestClass-num-get (getconstTC)) 33) (begin (display "Runtime test 1 failed.\n") (exit 1))) ; primitive reference variables (var-bool (createref-bool #f)) (if (value-bool (var-bool)) (begin (display "Runtime test 2 failed.\n") (exit 1))) (var-char (createref-char #\w)) (if (not (char=? (value-char (var-char)) #\w)) (begin (display "Runtime test 3 failed.\n") (exit 1))) (var-unsigned-char (createref-unsigned-char #\newline)) (if (not (char=? (value-unsigned-char (var-unsigned-char)) #\newline)) (begin (display "Runtime test 4 failed.\n") (exit 1))) (var-signed-char (createref-signed-char #\newline)) (if (not (char=? (value-signed-char (var-signed-char)) #\newline)) (begin (display "Runtime test 5 failed.\n") (exit 1))) (var-unsigned-short (createref-unsigned-short 10)) (if (!= (value-unsigned-short (var-unsigned-short)) 10) (begin (display "Runtime test 6 failed.\n") (exit 1))) (var-int (createref-int 10)) (if (!= (value-int (var-int)) 10) (begin (display "Runtime test 7 failed.\n") (exit 1))) (var-unsigned-int (createref-unsigned-int 10)) (if (!= (value-unsigned-int (var-unsigned-int)) 10) (begin (display "Runtime test 8 failed.\n") (exit 1))) (var-long (createref-long 10)) (if (!= (value-long (var-long)) 10) (begin (display "Runtime test 9 failed.\n") (exit 1))) (var-unsigned-long (createref-unsigned-long 10)) (if (!= (value-unsigned-long (var-unsigned-long)) 10) (begin (display "Runtime test 10 failed.\n") (exit 1))) ;skip long long and unsigned long long (var-float (createref-float 10.5)) (if (!= (value-float (var-float)) 10.5) (begin (display "Runtime test 11 failed.\n") (exit 1))) (var-double (createref-double 10.55)) (if (!= (value-double (var-double)) 10.55) (begin (display "Runtime test 12 failed.\n") (exit 1))) ;class reference (var-TestClass (createref-TestClass (new-TestClass 20))) (if (!= (TestClass-num-get (value-TestClass (var-TestClass))) 20) (begin (display "Runtime test 13 failed.\n") (exit 1))) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/overload_copy.scm0000664000175000017500000000006612343605122024115 0ustar williamwilliam(define f (new-Foo)) (define g (new-Foo f)) (exit 0) swig-3.0.2/Examples/test-suite/schemerunme/global_vars_proxy.scm0000664000175000017500000000106412343605122025003 0ustar williamwilliam(define-macro (check test) `(if (not ,test) (error "Error in test" ',test))) (b "hello") (check (string=? (b) "hello")) (define sa (make )) (slot-set! sa 'x 5) (a sa) (check (= (slot-ref (a) 'x) 5)) (ap sa) (check (= (slot-ref (ap) 'x) 5)) (slot-set! sa 'x 10) (check (= (slot-ref (ap) 'x) 10)) (define sa2 (make )) (slot-set! sa2 'x -4) (cap sa2) (check (= (slot-ref (cap) 'x) -4)) (slot-set! sa2 'x -7) (check (= (slot-ref (cap) 'x) -7)) (check (= (slot-ref (ar) 'x) 5)) (ar sa2) (check (= (slot-ref (ar) 'x) -7)) (x 4) (check (= (x) 4)) (exit 0) swig-3.0.2/Examples/test-suite/disown.i0000664000175000017500000000127712343605122017713 0ustar williamwilliam%module disown %{ #include %} #pragma SWIG nowarn=SWIGWARN_TYPEMAP_APPLY_UNDEF %apply SWIGTYPE *DISOWN { A *disown }; %inline { struct A { ~A() { // std::cout <<"delete A" << std::endl; } }; class B { A *_a; public: B() : _a(0) { } ~B() { if (_a) { // std::cout <<"delete A from B" << std::endl; delete _a; } // std::cout <<"delete B" << std::endl; } int acquire(A *disown) { // std::cout <<"acquire A" << std::endl; _a = disown; return 5; } int remove(A *remove) { delete remove; return 5; } }; } swig-3.0.2/Examples/test-suite/immutable_values.i0000664000175000017500000000040412343605122021735 0ustar williamwilliam// test to make sure setters are not generated for constants %module immutable_values %immutable; %mutable; %inline %{ #define ABC -11 enum count {Zero, One, Two}; %} %clearimmutable; %inline %{ #define XYZ -22 enum backwards {Tre=3, Duo=2, Uno=1}; %} swig-3.0.2/Examples/test-suite/go/0000775000175000017500000000000012343605122016634 5ustar williamwilliamswig-3.0.2/Examples/test-suite/go/keyword_rename_runme.go0000664000175000017500000000015112343605122023401 0ustar williamwilliampackage main import "./keyword_rename" func main() { keyword_rename.Xgo(1) keyword_rename.Xchan(1) } swig-3.0.2/Examples/test-suite/go/smart_pointer_member_runme.go0000664000175000017500000000051712343605122024611 0ustar williamwilliampackage main import "fmt" import . "./smart_pointer_member" func main() { f := NewFoo() f.SetY(1) if f.GetY() != 1 { panic(0) } b := NewBar(f) b.SetY(2) if f.GetY() != 2 { fmt.Println(f.GetY()) fmt.Println(b.GetY()) panic(0) } if b.GetX() != f.GetX() { panic(0) } if b.GetZ() != GetFooZ() { panic(0) } } swig-3.0.2/Examples/test-suite/go/director_exception_runme.go0000664000175000017500000000322312343605122024262 0ustar williamwilliampackage main import . "./director_exception" type Exception struct { msg string } func NewException(a, b string) *Exception { return &Exception{a + b} } type MyFoo struct{} // From Foo func (p *MyFoo) Ping() string { panic("MyFoo::ping() EXCEPTION") } type MyFoo2 struct{} // From Foo func (p *MyFoo2) Ping() bool { return true // should return a string } type MyFoo3 struct{} // From Foo func (p *MyFoo3) Ping() string { panic(NewException("foo", "bar")) } func main() { // Check that the NotImplementedError raised by MyFoo.ping() // is returned by MyFoo.pong(). ok := false a := NewDirectorFoo(&MyFoo{}) b := Launder(a) func() { defer func() { e := recover() if e.(string) == "MyFoo::ping() EXCEPTION" { ok = true } else { panic("Unexpected error message: " + e.(string)) } }() b.Pong() }() if !ok { panic(0) } // Check that if the method has the wrong return type it is // not called. ok = false a = NewDirectorFoo(&MyFoo2{}) b = Launder(a) e := b.Pong() if e != "Foo::pong();"+"Foo::ping()" { panic(e) } // Check that the director can return an exception which // requires two arguments to the constructor, without mangling // it. ok = false a = NewDirectorFoo(&MyFoo3{}) b = Launder(a) func() { defer func() { e := recover() if e.(*Exception).msg == "foobar" { ok = true } else { panic("Unexpected error message: " + e.(string)) } }() b.Pong() }() if !ok { panic(0) } func() { defer func() { e := recover() _ = e.(Exception2) }() panic(NewException2()) }() func() { defer func() { e := recover() _ = e.(Exception1) }() panic(NewException1()) }() } swig-3.0.2/Examples/test-suite/go/class_ignore_runme.go0000664000175000017500000000024412343605122023041 0ustar williamwilliampackage main import "./class_ignore" func main() { a := class_ignore.NewBar() if class_ignore.Do_blah(a) != "Bar::blah" { panic(class_ignore.Do_blah(a)) } } swig-3.0.2/Examples/test-suite/go/typemap_ns_using_runme.go0000664000175000017500000000015712343605122023760 0ustar williamwilliampackage main import "./typemap_ns_using" func main() { if typemap_ns_using.Spam(37) != 37 { panic(0) } } swig-3.0.2/Examples/test-suite/go/director_unroll_runme.go0000664000175000017500000000050512343605122023577 0ustar williamwilliampackage main import "./director_unroll" type MyFoo struct{} // From director_unroll.Foo func (p *MyFoo) Ping() string { return "MyFoo::ping()" } func main() { a := director_unroll.NewDirectorFoo(&MyFoo{}) b := director_unroll.NewBar() b.Set(a) c := b.Get() if c.Ping() != "MyFoo::ping()" { panic(c.Ping()) } } swig-3.0.2/Examples/test-suite/go/abstract_access_runme.go0000664000175000017500000000020012343605122023505 0ustar williamwilliampackage main import "./abstract_access" func main() { d := abstract_access.NewD() if d.Do_x() != 1 { panic(d.Do_x()) } } swig-3.0.2/Examples/test-suite/go/struct_rename_runme.go0000664000175000017500000000012412343605122023241 0ustar williamwilliampackage main import "./struct_rename" func main() { _ = struct_rename.NewBar() } swig-3.0.2/Examples/test-suite/go/varargs_runme.go0000664000175000017500000000060212343605122022034 0ustar williamwilliampackage main import "./varargs" func main() { if varargs.Test("Hello") != "Hello" { panic("Failed") } f := varargs.NewFoo("Greetings") if f.GetStr() != "Greetings" { panic("Failed") } if f.Test("Hello") != "Hello" { panic("Failed") } if varargs.Test_def("Hello", 1) != "Hello" { panic("Failed") } if varargs.Test_def("Hello") != "Hello" { panic("Failed") } } swig-3.0.2/Examples/test-suite/go/unions_runme.go0000664000175000017500000000230012343605122021677 0ustar williamwilliam// This is the union runtime testcase. It ensures that values within a // union embedded within a struct can be set and read correctly. package main import "./unions" func main() { // Create new instances of SmallStruct and BigStruct for later use small := unions.NewSmallStruct() small.SetJill(200) big := unions.NewBigStruct() big.SetSmallstruct(small) big.SetJack(300) // Use SmallStruct then BigStruct to setup EmbeddedUnionTest. // Ensure values in EmbeddedUnionTest are set correctly for each. eut := unions.NewEmbeddedUnionTest() // First check the SmallStruct in EmbeddedUnionTest eut.SetNumber(1) eut.GetUni().SetSmall(small) Jill1 := eut.GetUni().GetSmall().GetJill() if Jill1 != 200 { panic("Runtime test1 failed") } Num1 := eut.GetNumber() if Num1 != 1 { panic("Runtime test2 failed") } // Secondly check the BigStruct in EmbeddedUnionTest eut.SetNumber(2) eut.GetUni().SetBig(big) Jack1 := eut.GetUni().GetBig().GetJack() if Jack1 != 300 { panic("Runtime test3 failed") } Jill2 := eut.GetUni().GetBig().GetSmallstruct().GetJill() if Jill2 != 200 { panic("Runtime test4 failed") } Num2 := eut.GetNumber() if Num2 != 2 { panic("Runtime test5 failed") } } swig-3.0.2/Examples/test-suite/go/virtual_derivation_runme.go0000664000175000017500000000025412343605122024304 0ustar williamwilliampackage main import . "./virtual_derivation" // very innocent example func main() { b := NewB(3) if b.Get_a() != b.Get_b() { panic("something is really wrong") } } swig-3.0.2/Examples/test-suite/go/director_basic_runme.go0000664000175000017500000000352512343605122023352 0ustar williamwilliampackage main import "./director_basic" type GoFoo struct{} func (p *GoFoo) Ping() string { return "GoFoo::ping()" } func f1() { a := director_basic.NewDirectorFoo(&GoFoo{}) if a.Ping() != "GoFoo::ping()" { panic(a.Ping()) } if a.Pong() != "Foo::pong();GoFoo::ping()" { panic(a.Pong()) } b := director_basic.NewFoo() if b.Ping() != "Foo::ping()" { panic(b.Ping()) } if b.Pong() != "Foo::pong();Foo::ping()" { panic(b.Pong()) } a1 := director_basic.NewA1(1) if a1.Rg(2) != 2 { panic(0) } } type GoClass struct { cmethod int } func (p *GoClass) Method(uintptr) { p.cmethod = 7 } func (p *GoClass) Vmethod(b director_basic.Bar) director_basic.Bar { b.SetX(b.GetX() + 31) return b } var bc director_basic.Bar func f2() { b := director_basic.NewBar(3) d := director_basic.NewMyClass() pc := &GoClass{0} c := director_basic.NewDirectorMyClass(pc) cc := director_basic.MyClassGet_self(c) dd := director_basic.MyClassGet_self(d) bc = cc.Cmethod(b) bd := dd.Cmethod(b) cc.Method(b.Swigcptr()) if pc.cmethod != 7 { panic(pc.cmethod) } if bc.GetX() != 34 { panic(bc.GetX()) } if bd.GetX() != 16 { panic(bd.GetX()) } } type GoMulti struct { GoClass } func (p *GoMulti) Vmethod(b director_basic.Bar) director_basic.Bar { b.SetX(b.GetX() + 31) return b } func (p *GoMulti) Ping() string { return "GoFoo::ping()" } func f3() { for i := 0; i < 100; i++ { p := &GoMulti{GoClass{0}} gomult := director_basic.NewDirectorFoo(p) gomult.Pong() director_basic.DeleteDirectorFoo(gomult) } p := &GoMulti{GoClass{0}} gomult := director_basic.NewDirectorMyClass(p) fgomult := director_basic.NewDirectorFoo(gomult) p1 := director_basic.FooGet_self(fgomult.(director_basic.Foo)) p2 := director_basic.MyClassGet_self(gomult.(director_basic.MyClass)) p1.Ping() p2.Vmethod(bc) } func main() { f1() f2() f3() } swig-3.0.2/Examples/test-suite/go/li_attribute_runme.go0000664000175000017500000000323612343605122023064 0ustar williamwilliampackage main import "./li_attribute" func main() { aa := li_attribute.NewA(1, 2, 3) if aa.GetA() != 1 { panic(0) } aa.SetA(3) if aa.GetA() != 3 { panic(aa.GetA()) } if aa.GetB() != 2 { panic(aa.GetB()) } aa.SetB(5) if aa.GetB() != 5 { panic(0) } if aa.GetD() != aa.GetB() { panic(0) } if aa.GetC() != 3 { panic(0) } pi := li_attribute.NewParam_i(7) if pi.GetValue() != 7 { panic(0) } pi.SetValue(3) if pi.GetValue() != 3 { panic(0) } b := li_attribute.NewB(aa) if b.GetA().GetC() != 3 { panic(0) } // class/struct attribute with get/set methods using // return/pass by reference myFoo := li_attribute.NewMyFoo() myFoo.SetX(8) myClass := li_attribute.NewMyClass() myClass.SetFoo(myFoo) if myClass.GetFoo().GetX() != 8 { panic(0) } // class/struct attribute with get/set methods using // return/pass by value myClassVal := li_attribute.NewMyClassVal() if myClassVal.GetReadWriteFoo().GetX() != -1 { panic(0) } if myClassVal.GetReadOnlyFoo().GetX() != -1 { panic(0) } myClassVal.SetReadWriteFoo(myFoo) if myClassVal.GetReadWriteFoo().GetX() != 8 { panic(0) } if myClassVal.GetReadOnlyFoo().GetX() != 8 { panic(0) } // string attribute with get/set methods using return/pass by // value myStringyClass := li_attribute.NewMyStringyClass("initial string") if myStringyClass.GetReadWriteString() != "initial string" { panic(0) } if myStringyClass.GetReadOnlyString() != "initial string" { panic(0) } myStringyClass.SetReadWriteString("changed string") if myStringyClass.GetReadWriteString() != "changed string" { panic(0) } if myStringyClass.GetReadOnlyString() != "changed string" { panic(0) } } swig-3.0.2/Examples/test-suite/go/director_extend_runme.go0000664000175000017500000000064212343605122023555 0ustar williamwilliam// Test case from bug #1506850 "When threading is enabled, the // interpreter will infinitely wait on a mutex the second time this // type of extended method is called. Attached is an example program // that waits on the mutex to be unlocked." package main import . "./director_extend" func main() { m := NewSpObject() if m.Dummy() != 666 { panic("1st call") } if m.Dummy() != 666 { panic("2nd call") } } swig-3.0.2/Examples/test-suite/go/extend_template_ns_runme.go0000664000175000017500000000023712343605122024255 0ustar williamwilliampackage main import . "./extend_template_ns" func main() { f := NewFoo_One() if f.Test1(37) != 37 { panic(0) } if f.Test2(42) != 42 { panic(0) } } swig-3.0.2/Examples/test-suite/go/profiletest_runme.go0000664000175000017500000000107412343605122022733 0ustar williamwilliampackage main import "fmt" import "./profiletest" func main() { a := profiletest.NewA() if false { fmt.Println(a) } b := profiletest.NewB() fn := func(a profiletest.A) profiletest.A { return b.Fn(a) } i := 50000 for i != 0 { a = fn(a) //1 a = fn(a) //2 a = fn(a) //3 a = fn(a) //4 a = fn(a) //5 a = fn(a) //6 a = fn(a) //7 a = fn(a) //8 a = fn(a) //9 a = fn(a) //10 a = fn(a) //1 a = fn(a) //2 a = fn(a) //3 a = fn(a) //4 a = fn(a) //5 a = fn(a) //6 a = fn(a) //7 a = fn(a) //8 a = fn(a) //9 a = fn(a) //20 i -= 1 } } swig-3.0.2/Examples/test-suite/go/abstract_typedef2_runme.go0000664000175000017500000000013112343605122023771 0ustar williamwilliampackage main import "./abstract_typedef2" func main() { abstract_typedef2.NewA_UF() } swig-3.0.2/Examples/test-suite/go/template_type_namespace_runme.go0000664000175000017500000000014012343605122025254 0ustar williamwilliampackage main import . "./template_type_namespace" func main() { if Foo().Get(0) == "" { } } swig-3.0.2/Examples/test-suite/go/empty_runme.go0000664000175000017500000000006212343605122021525 0ustar williamwilliampackage main import _ "./empty" func main() { } swig-3.0.2/Examples/test-suite/go/cpp_enum_runme.go0000664000175000017500000000064412343605122022203 0ustar williamwilliampackage main import "./cpp_enum" func main() { f := cpp_enum.NewFoo() if f.GetHola() != cpp_enum.FooHello { panic(f.GetHola()) } f.SetHola(cpp_enum.FooHi) if f.GetHola() != cpp_enum.FooHi { panic(f.GetHola()) } f.SetHola(cpp_enum.FooHello) if f.GetHola() != cpp_enum.FooHello { panic(f.GetHola()) } cpp_enum.SetHi(cpp_enum.Hello) if cpp_enum.GetHi() != cpp_enum.Hello { panic(cpp_enum.Hi) } } swig-3.0.2/Examples/test-suite/go/li_std_vector_ptr_runme.go0000664000175000017500000000026212343605122024116 0ustar williamwilliampackage main import . "./li_std_vector_ptr" func main() { ip1 := MakeIntPtr(11) ip2 := MakeIntPtr(22) vi := NewIntPtrVector() vi.Add(ip1) vi.Add(ip2) DisplayVector(vi) } swig-3.0.2/Examples/test-suite/go/array_member_runme.go0000664000175000017500000000071512343605122023041 0ustar williamwilliampackage main import . "./array_member" func main() { f := NewFoo() f.SetData(GetGlobal_data()) for i := 0; i < 8; i++ { if Get_value(f.GetData(), i) != Get_value(GetGlobal_data(), i) { panic("Bad array assignment") } } for i := 0; i < 8; i++ { Set_value(f.GetData(), i, -i) } SetGlobal_data(f.GetData()) for i := 0; i < 8; i++ { if Get_value(f.GetData(), i) != Get_value(GetGlobal_data(), i) { panic("Bad array assignment") } } } swig-3.0.2/Examples/test-suite/go/rename_simple_runme.go0000664000175000017500000000161012343605122023207 0ustar williamwilliampackage main import "fmt" import . "./rename_simple" func main() { s := NewNewStruct() check(111, s.GetNewInstanceVariable(), "NewInstanceVariable") check(222, s.NewInstanceMethod(), "NewInstanceMethod") check(333, NewStructNewStaticMethod(), "NewStaticMethod") check(444, GetNewStructNewStaticVariable(), "NewStaticVariable") check(555, NewFunction(), "NewFunction") check(666, GetNewGlobalVariable(), "NewGlobalVariable") s.SetNewInstanceVariable(1111) SetNewStructNewStaticVariable(4444) SetNewGlobalVariable(6666) check(1111, s.GetNewInstanceVariable(), "NewInstanceVariable") check(4444, GetNewStructNewStaticVariable(), "NewStaticVariable") check(6666, GetNewGlobalVariable(), "NewGlobalVariable") } func check(expected, actual int, msg string) { if expected != actual { panic("Failed: Expected: " + fmt.Sprint(expected) + " actual: " + fmt.Sprint(actual) + " " + msg) } } swig-3.0.2/Examples/test-suite/go/compactdefaultargs_runme.go0000664000175000017500000000076612343605122024252 0ustar williamwilliampackage main import . "./compactdefaultargs" func main() { defaults1 := NewDefaults1(1000) defaults1 = NewDefaults1() if defaults1.Ret(10.0) != 10.0 { println(1, defaults1.Ret(10.0)) panic(defaults1.Ret(10.0)) } if defaults1.Ret() != -1.0 { println(2, defaults1.Ret()) panic(defaults1.Ret()) } defaults2 := NewDefaults2(1000) defaults2 = NewDefaults2() if defaults2.Ret(10.0) != 10.0 { panic(defaults2.Ret(10.0)) } if defaults2.Ret() != -1.0 { panic(defaults2.Ret()) } } swig-3.0.2/Examples/test-suite/go/enum_template_runme.go0000664000175000017500000000021012343605122023221 0ustar williamwilliampackage main import "./enum_template" func main() { if enum_template.MakeETest() != 1 { panic(0) } enum_template.TakeETest(0) } swig-3.0.2/Examples/test-suite/go/template_static_runme.go0000664000175000017500000000011612343605122023551 0ustar williamwilliampackage main import . "./template_static" func main() { FooBar_double(1) } swig-3.0.2/Examples/test-suite/go/struct_initialization_runme.go0000664000175000017500000000055312343605122025027 0ustar williamwilliampackage main import . "./struct_initialization" func main() { if GetInstanceC1().GetX() != 10 { panic(0) } if GetInstanceD1().GetX() != 10 { panic(0) } if GetInstanceD2().GetX() != 20 { panic(0) } if GetInstanceD3().GetX() != 30 { panic(0) } if GetInstanceE1().GetX() != 1 { panic(0) } if GetInstanceF1().GetX() != 1 { panic(0) } } swig-3.0.2/Examples/test-suite/go/constover_runme.go0000664000175000017500000000140212343605122022410 0ustar williamwilliampackage main import ( "./constover" "fmt" "os" ) func main() { error := 0 p := constover.Test("test") if p != "test" { fmt.Println("test failed!") error = 1 } p = constover.Test_pconst("test") if p != "test_pconst" { fmt.Println("test_pconst failed!") error = 1 } f := constover.NewFoo() p = f.Test("test") if p != "test" { fmt.Println("member-test failed!") error = 1 } p = f.Test_pconst("test") if p != "test_pconst" { fmt.Println("member-test_pconst failed!") error = 1 } p = f.Test_constm("test") if p != "test_constmethod" { fmt.Println("member-test_constm failed!") error = 1 } p = f.Test_pconstm("test") if p != "test_pconstmethod" { fmt.Println("member-test_pconstm failed!") error = 1 } os.Exit(error) } swig-3.0.2/Examples/test-suite/go/using_private_runme.go0000664000175000017500000000036612343605122023255 0ustar williamwilliampackage main import . "./using_private" func main() { f := NewFooBar() f.SetX(3) if f.Blah(4) != 4 { panic("blah(int)") } if f.Defaulted() != -1 { panic("defaulted()") } if f.Defaulted(222) != 222 { panic("defaulted(222)") } } swig-3.0.2/Examples/test-suite/go/director_classic_runme.go0000664000175000017500000000643012343605122023710 0ustar williamwilliampackage main import "fmt" import . "./director_classic" type TargetLangPerson struct{} // From Person func (p *TargetLangPerson) Id() string { return "TargetLangPerson" } type TargetLangChild struct{} // Form Child func (p *TargetLangChild) Id() string { return "TargetLangChild" } type TargetLangGrandChild struct{} // From Grandchild func (p *TargetLangGrandChild) Id() string { return "TargetLangGrandChild" } // Semis - don't override id() in target language type TargetLangSemiPerson struct{} // From Person type TargetLangSemiChild struct{} // From Child type TargetLangSemiGrandChild struct{} // From GrandChild // Orphans - don't override id() in C++ type TargetLangOrphanPerson struct{} // From OrphanPerson func (p *TargetLangOrphanPerson) Id() string { return "TargetLangOrphanPerson" } type TargetLangOrphanChild struct{} // From OrphanChild func (p *TargetLangOrphanChild) Id() string { return "TargetLangOrphanChild" } func check(person Person, expected string) { debug := false // Normal target language polymorphic call ret := person.Id() if debug { fmt.Println(ret) } if ret != expected { panic("Failed. Received: " + ret + " Expected: " + expected) } // Polymorphic call from C++ caller := NewCaller() caller.SetCallback(person) ret = caller.Call() if debug { fmt.Println(ret) } if ret != expected { panic("Failed. Received: " + ret + " Expected: " + expected) } // Polymorphic call of object created in target language and // passed to C++ and back again baseclass := caller.BaseClass() ret = baseclass.Id() if debug { fmt.Println(ret) } if ret != expected { panic("Failed. Received: " + ret + " Expected: " + expected) } caller.ResetCallback() if debug { fmt.Println("----------------------------------------") } } func main() { person := NewPerson() check(person, "Person") DeletePerson(person) person = NewChild() check(person, "Child") DeletePerson(person) person = NewGrandChild() check(person, "GrandChild") DeletePerson(person) person = NewDirectorPerson(&TargetLangPerson{}) check(person, "TargetLangPerson") DeleteDirectorPerson(person) person = NewDirectorChild(&TargetLangChild{}) check(person, "TargetLangChild") DeleteDirectorChild(person.(Child)) person = NewDirectorGrandChild(&TargetLangGrandChild{}) check(person, "TargetLangGrandChild") DeleteDirectorGrandChild(person.(GrandChild)) // Semis - don't override id() in target language person = NewDirectorPerson(&TargetLangSemiPerson{}) check(person, "Person") DeleteDirectorPerson(person) person = NewDirectorChild(&TargetLangSemiChild{}) check(person, "Child") DeleteDirectorChild(person.(Child)) person = NewDirectorGrandChild(&TargetLangSemiGrandChild{}) check(person, "GrandChild") DeleteDirectorGrandChild(person.(GrandChild)) // Orphans - don't override id() in C++ person = NewOrphanPerson() check(person, "Person") DeleteOrphanPerson(person.(OrphanPerson)) person = NewOrphanChild() check(person, "Child") DeleteOrphanChild(person.(OrphanChild)) person = NewDirectorOrphanPerson(&TargetLangOrphanPerson{}) check(person, "TargetLangOrphanPerson") DeleteDirectorOrphanPerson(person.(OrphanPerson)) person = NewDirectorOrphanChild(&TargetLangOrphanChild{}) check(person, "TargetLangOrphanChild") DeleteDirectorOrphanChild(person.(OrphanChild)) } swig-3.0.2/Examples/test-suite/go/multi_import_runme.go0000664000175000017500000000064512343605122023122 0ustar williamwilliampackage main import "multi_import_a" import "multi_import_b" func main() { x := multi_import_b.NewXXX() if x.Testx() != 0 { panic(0) } y := multi_import_b.NewYYY() if y.Testx() != 0 { panic(0) } if y.Testy() != 1 { panic(0) } z := multi_import_a.NewZZZ() if z.Testx() != 0 { println("z.Testx", z.Testx(), z.Testz()) panic(0) } if z.Testz() != 2 { println("z.Testz", z.Testz()) panic(0) } } swig-3.0.2/Examples/test-suite/go/default_args_runme.go0000664000175000017500000000050012343605122023024 0ustar williamwilliampackage main import "./default_args" func main() { if default_args.StaticsStaticmethod() != 60 { panic(0) } if default_args.Cfunc1(1) != 2 { panic(0) } if default_args.Cfunc2(1) != 3 { panic(0) } if default_args.Cfunc3(1) != 4 { panic(0) } f := default_args.NewFoo() f.Newname() f.Newname(1) } swig-3.0.2/Examples/test-suite/go/template_typedef_cplx3_runme.go0000664000175000017500000000072312343605122025037 0ustar williamwilliampackage main import . "./template_typedef_cplx3" func main() { // this is OK s := NewSin() s.Get_base_value() s.Get_value() s.Get_arith_value() My_func_r(s) Make_Multiplies_double_double_double_double(s, s) z := NewCSin() z.Get_base_value() z.Get_value() z.Get_arith_value() My_func_c(z) Make_Multiplies_complex_complex_complex_complex(z, z) // Here we fail d := Make_Identity_double() My_func_r(d) c := Make_Identity_complex() My_func_c(c) } swig-3.0.2/Examples/test-suite/go/using_extend_runme.go0000664000175000017500000000065112343605122023067 0ustar williamwilliampackage main import . "./using_extend" func main() { f := NewFooBar() if f.Blah(3).(int) != 3 { panic("blah(int)") } if f.Blah(3.5) != 3.5 { panic("blah(double)") } if f.Blah("hello").(string) != "hello" { panic("blah(char *)") } if f.Blah(3, 4).(int) != 7 { panic("blah(int,int)") } if f.Blah(3.5, 7.5) != (3.5 + 7.5) { panic("blah(double,double)") } if f.Duh(3) != 3 { panic("duh(int)") } } swig-3.0.2/Examples/test-suite/go/minherit_runme.go0000664000175000017500000000445712343605122022222 0ustar williamwilliampackage main import "fmt" import "./minherit" func main() { a := minherit.NewFoo() b := minherit.NewBar() c := minherit.NewFooBar() d := minherit.NewSpam() if a.Xget() != 1 { panic("1 Bad attribute value") } if b.Yget() != 2 { panic("2 Bad attribute value") } if c.Xget() != 1 || c.Yget() != 2 || c.Zget() != 3 { panic("3 Bad attribute value") } if d.Xget() != 1 || d.Yget() != 2 || d.Zget() != 3 || d.Wget() != 4 { panic("4 Bad attribute value") } if minherit.Xget(a) != 1 { panic(fmt.Sprintf("5 Bad attribute value %d", minherit.Xget(a))) } if minherit.Yget(b) != 2 { panic(fmt.Sprintf("6 Bad attribute value %d", minherit.Yget(b))) } if minherit.Xget(c) != 1 || minherit.Yget(c.SwigGetBar()) != 2 || minherit.Zget(c) != 3 { panic(fmt.Sprintf("7 Bad attribute value %d %d %d", minherit.Xget(c), minherit.Yget(c.SwigGetBar()), minherit.Zget(c))) } if minherit.Xget(d) != 1 || minherit.Yget(d.SwigGetBar()) != 2 || minherit.Zget(d) != 3 || minherit.Wget(d) != 4 { panic(fmt.Sprintf("8 Bad attribute value %d %d %d %d", minherit.Xget(d), minherit.Yget(d.SwigGetBar()), minherit.Zget(d), minherit.Wget(d))) } // Cleanse all of the pointers and see what happens aa := minherit.ToFooPtr(a) bb := minherit.ToBarPtr(b) cc := minherit.ToFooBarPtr(c) dd := minherit.ToSpamPtr(d) if aa.Xget() != 1 { panic("9 Bad attribute value") } if bb.Yget() != 2 { panic("10 Bad attribute value") } if cc.Xget() != 1 || cc.Yget() != 2 || cc.Zget() != 3 { panic("11 Bad attribute value") } if dd.Xget() != 1 || dd.Yget() != 2 || dd.Zget() != 3 || dd.Wget() != 4 { panic("12 Bad attribute value") } if minherit.Xget(aa) != 1 { panic(fmt.Sprintf("13 Bad attribute value %d", minherit.Xget(aa))) } if minherit.Yget(bb) != 2 { panic(fmt.Sprintf("14 Bad attribute value %d", minherit.Yget(bb))) } if minherit.Xget(cc) != 1 || minherit.Yget(cc.SwigGetBar()) != 2 || minherit.Zget(cc) != 3 { panic(fmt.Sprintf("15 Bad attribute value %d %d %d", minherit.Xget(cc), minherit.Yget(cc.SwigGetBar()), minherit.Zget(cc))) } if minherit.Xget(dd) != 1 || minherit.Yget(dd.SwigGetBar()) != 2 || minherit.Zget(dd) != 3 || minherit.Wget(dd) != 4 { panic(fmt.Sprintf("16 Bad attribute value %d %d %d %d", minherit.Xget(dd), minherit.Yget(dd.SwigGetBar()), minherit.Zget(dd), minherit.Wget(dd))) } } swig-3.0.2/Examples/test-suite/go/extend_placement_runme.go0000664000175000017500000000210012343605122023701 0ustar williamwilliampackage main import "./extend_placement" func main() { foo := extend_placement.NewFoo() foo = extend_placement.NewFoo(1) foo = extend_placement.NewFoo(1, 1) foo.Spam() foo.Spam("hello") foo.Spam(1) foo.Spam(1, 1) foo.Spam(1, 1, 1) foo.Spam(extend_placement.NewFoo()) foo.Spam(extend_placement.NewFoo(), 1.0) bar := extend_placement.NewBar() bar = extend_placement.NewBar(1) bar.Spam() bar.Spam("hello") bar.Spam(1) bar.Spam(1, 1) bar.Spam(1, 1, 1) bar.Spam(extend_placement.NewBar()) bar.Spam(extend_placement.NewBar(), 1.0) footi := extend_placement.NewFooTi() footi = extend_placement.NewFooTi(1) footi = extend_placement.NewFooTi(1, 1) footi.Spam() footi.Spam("hello") footi.Spam(1) footi.Spam(1, 1) footi.Spam(1, 1, 1) footi.Spam(extend_placement.NewFoo()) footi.Spam(extend_placement.NewFoo(), 1.0) barti := extend_placement.NewBarTi() barti = extend_placement.NewBarTi(1) barti.Spam() barti.Spam("hello") barti.Spam(1) barti.Spam(1, 1) barti.Spam(1, 1, 1) barti.Spam(extend_placement.NewBar()) barti.Spam(extend_placement.NewBar(), 1.0) } swig-3.0.2/Examples/test-suite/go/smart_pointer_multi_runme.go0000664000175000017500000000033512343605122024472 0ustar williamwilliampackage main import . "./smart_pointer_multi" func main() { f := NewFoo() b := NewBar(f) s := NewSpam(b) g := NewGrok(b) s.SetX(3) if s.Getx() != 3 { panic(0) } g.SetX(4) if g.Getx() != 4 { panic(0) } } swig-3.0.2/Examples/test-suite/go/wrapmacro_runme.go0000664000175000017500000000031212343605122022360 0ustar williamwilliampackage main import "./wrapmacro" func main() { a := 2 b := -1 wrapmacro.Maximum(int64(a), int64(b)) wrapmacro.Maximum(float64(a/7.0), float64(-b*256)) wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1) } swig-3.0.2/Examples/test-suite/go/friends_runme.go0000664000175000017500000000140112343605122022017 0ustar williamwilliampackage main import "./friends" func main() { a := friends.NewA(2) if friends.Get_val1(a).(int) != 2 { panic(0) } if friends.Get_val2(a) != 4 { panic(0) } if friends.Get_val3(a) != 6 { panic(0) } // nice overload working fine if friends.Get_val1(1, 2, 3).(int) != 1 { panic(0) } b := friends.NewB(3) // David's case if friends.Mix(a, b) != 5 { panic(0) } di := friends.NewD_d(2) dd := friends.NewD_d(3.3) // incredible template overloading working just fine if friends.Get_val1(di).(float64) != 2 { panic(0) } if friends.Get_val1(dd).(float64) != 3.3 { panic(0) } friends.Set(di, 4.0) friends.Set(dd, 1.3) if friends.Get_val1(di).(float64) != 4 { panic(0) } if friends.Get_val1(dd).(float64) != 1.3 { panic(0) } } swig-3.0.2/Examples/test-suite/go/using_protected_runme.go0000664000175000017500000000020712343605122023566 0ustar williamwilliampackage main import . "./using_protected" func main() { f := NewFooBar() f.SetX(3) if f.Blah(4) != 4 { panic("blah(int)") } } swig-3.0.2/Examples/test-suite/go/overload_copy_runme.go0000664000175000017500000000013012343605122023230 0ustar williamwilliampackage main import . "./overload_copy" func main() { f := NewFoo() _ = NewFoo(f) } swig-3.0.2/Examples/test-suite/go/member_pointer_runme.go0000664000175000017500000000172612343605122023406 0ustar williamwilliam// Example using pointers to member functions package main import "fmt" import . "./member_pointer" func check(what string, expected float64, actual float64) { if expected != actual { panic(fmt.Sprintf("Failed: %s Expected: %f Actual; %f", what, expected, actual)) } } func main() { // Get the pointers area_pt := Areapt() perim_pt := Perimeterpt() // Create some objects s := NewSquare(10) // Do some calculations check("Square area ", 100.0, Do_op(s, area_pt)) check("Square perim", 40.0, Do_op(s, perim_pt)) _ = GetAreavar() _ = GetPerimetervar() // Try the variables check("Square area ", 100.0, Do_op(s, GetAreavar())) check("Square perim", 40.0, Do_op(s, GetPerimetervar())) // Modify one of the variables SetAreavar(perim_pt) check("Square perimeter", 40.0, Do_op(s, GetAreavar())) // Try the constants _ = AREAPT _ = PERIMPT _ = NULLPT check("Square area ", 100.0, Do_op(s, AREAPT)) check("Square perim", 40.0, Do_op(s, PERIMPT)) } swig-3.0.2/Examples/test-suite/go/overload_template_fast_runme.go0000664000175000017500000000606112343605122025117 0ustar williamwilliampackage main import . "./overload_template_fast" func main() { _ = Foo() _ = Maximum(3, 4) _ = Maximum(3.4, 5.2) // mix 1 if Mix1("hi") != 101 { panic("mix1(const char*)") } if Mix1(1.0, 1.0) != 102 { panic("mix1(double, const double &)") } if Mix1(1.0) != 103 { panic("mix1(double)") } // mix 2 if Mix2("hi") != 101 { panic("mix2(const char*)") } if Mix2(1.0, 1.0) != 102 { panic("mix2(double, const double &)") } if Mix2(1.0) != 103 { panic("mix2(double)") } // mix 3 if Mix3("hi") != 101 { panic("mix3(const char*)") } if Mix3(1.0, 1.0) != 102 { panic("mix3(double, const double &)") } if Mix3(1.0) != 103 { panic("mix3(double)") } // Combination 1 if Overtparams1(100) != 10 { panic("overtparams1(int)") } if Overtparams1(100.0, 100) != 20 { panic("overtparams1(double, int)") } // Combination 2 if Overtparams2(100.0, 100) != 40 { panic("overtparams2(double, int)") } // Combination 3 if Overloaded() != 60 { panic("overloaded()") } if Overloaded(100.0, 100) != 70 { panic("overloaded(double, int)") } // Combination 4 if Overloadedagain("hello") != 80 { panic("overloadedagain(const char *)") } if Overloadedagain() != 90 { panic("overloadedagain(double)") } // specializations if Specialization(10) != 202 { panic("specialization(int)") } if Specialization(10.0) != 203 { panic("specialization(double)") } if Specialization(10, 10) != 204 { panic("specialization(int, int)") } if Specialization(10.0, 10.0) != 205 { panic("specialization(double, double)") } if Specialization("hi", "hi") != 201 { panic("specialization(const char *, const char *)") } // simple specialization Xyz() Xyz_int() Xyz_double() // a bit of everything if Overload("hi") != 0 { panic("overload()") } if Overload(1) != 10 { panic("overload(int t)") } if Overload(1, 1) != 20 { panic("overload(int t, const int &)") } if Overload(1, "hello") != 30 { panic("overload(int t, const char *)") } k := NewKlass() if Overload(k) != 10 { panic("overload(Klass t)") } if Overload(k, k) != 20 { panic("overload(Klass t, const Klass &)") } if Overload(k, "hello") != 30 { panic("overload(Klass t, const char *)") } if Overload(10.0, "hi") != 40 { panic("overload(double t, const char *)") } if Overload() != 50 { panic("overload(const char *)") } // everything put in a namespace if Nsoverload("hi") != 1000 { panic("nsoverload()") } if Nsoverload(1) != 1010 { panic("nsoverload(int t)") } if Nsoverload(1, 1) != 1020 { panic("nsoverload(int t, const int &)") } if Nsoverload(1, "hello") != 1030 { panic("nsoverload(int t, const char *)") } if Nsoverload(k) != 1010 { panic("nsoverload(Klass t)") } if Nsoverload(k, k) != 1020 { panic("nsoverload(Klass t, const Klass &)") } if Nsoverload(k, "hello") != 1030 { panic("nsoverload(Klass t, const char *)") } if Nsoverload(10.0, "hi") != 1040 { panic("nsoverload(double t, const char *)") } if Nsoverload() != 1050 { panic("nsoverload(const char *)") } AFoo(1) b := NewB() b.Foo(1) } swig-3.0.2/Examples/test-suite/go/varargs_overload_runme.go0000664000175000017500000000126412343605122023734 0ustar williamwilliampackage main import "./varargs_overload" func main() { if varargs_overload.Vararg_over1("Hello") != "Hello" { panic(0) } if varargs_overload.Vararg_over1(2) != "2" { panic(1) } if varargs_overload.Vararg_over2("Hello") != "Hello" { panic(2) } if varargs_overload.Vararg_over2(2, 2.2) != "2 2.2" { panic(3) } if varargs_overload.Vararg_over3("Hello") != "Hello" { panic(4) } if varargs_overload.Vararg_over3(2, 2.2, "hey") != "2 2.2 hey" { panic(5) } if varargs_overload.Vararg_over4("Hello") != "Hello" { panic(6) } if varargs_overload.Vararg_over4(123) != "123" { panic(7) } if varargs_overload.Vararg_over4("Hello", 123) != "Hello" { panic(8) } } swig-3.0.2/Examples/test-suite/go/template_default_arg_runme.go0000664000175000017500000000537612343605122024554 0ustar williamwilliampackage main import "./template_default_arg" func main() { helloInt := template_default_arg.NewHello_int() helloInt.Foo(template_default_arg.Hello_intHi) x := template_default_arg.NewX_int() if x.Meth(20.0, 200).(int) != 200 { panic("X_int test 1 failed") } if x.Meth(20).(int) != 20 { panic("X_int test 2 failed") } if x.Meth().(int) != 0 { panic("X_int test 3 failed") } y := template_default_arg.NewY_unsigned() if y.Meth(20.0, uint(200)).(uint) != 200 { panic("Y_unsigned test 1 failed") } if y.Meth(uint(20)).(uint) != 20 { panic("Y_unsigned test 2 failed") } if y.Meth().(uint) != 0 { panic("Y_unsigned test 3 failed") } _ = template_default_arg.NewX_longlong() _ = template_default_arg.NewX_longlong(20.0) _ = template_default_arg.NewX_longlong(20.0, int64(200)) _ = template_default_arg.NewX_int() _ = template_default_arg.NewX_int(20.0) _ = template_default_arg.NewX_int(20.0, 200) _ = template_default_arg.NewX_hello_unsigned() _ = template_default_arg.NewX_hello_unsigned(20.0) _ = template_default_arg.NewX_hello_unsigned(20.0, template_default_arg.NewHello_int()) yy := template_default_arg.NewY_hello_unsigned() yy.Meth(20.0, template_default_arg.NewHello_int()) yy.Meth(template_default_arg.NewHello_int()) yy.Meth() fz := template_default_arg.NewFoo_Z_8() xz := template_default_arg.NewX_Foo_Z_8() _ = xz.Meth(fz) // Templated functions // plain function: int ott(Foo) if template_default_arg.Ott(template_default_arg.NewFoo_int()) != 30 { panic("ott test 1 failed") } // %template(ott) ott if template_default_arg.Ott() != 10 { panic("ott test 2 failed") } if template_default_arg.Ott(1) != 10 { panic("ott test 3 failed") } if template_default_arg.Ott(1, 1) != 10 { panic("ott test 4 failed") } if template_default_arg.Ott("hi") != 20 { panic("ott test 5 failed") } if template_default_arg.Ott("hi", 1) != 20 { panic("ott test 6 failed") } if template_default_arg.Ott("hi", 1, 1) != 20 { panic("ott test 7 failed") } // %template(ott) ott if template_default_arg.Ottstring(template_default_arg.NewHello_int(), "hi") != 40 { panic("ott test 8 failed") } if template_default_arg.Ottstring(template_default_arg.NewHello_int()) != 40 { panic("ott test 9 failed") } // %template(ott) ott if template_default_arg.Ottint(template_default_arg.NewHello_int(), 1) != 50 { panic("ott test 10 failed") } if template_default_arg.Ottint(template_default_arg.NewHello_int()) != 50 { panic("ott test 11 failed") } // %template(ott) ott if template_default_arg.Ott(template_default_arg.NewHello_int(), 1.0) != 60 { panic("ott test 12 failed") } if template_default_arg.Ott(template_default_arg.NewHello_int()) != 60 { panic("ott test 13 failed") } } swig-3.0.2/Examples/test-suite/go/namespace_typemap_runme.go0000664000175000017500000000234612343605122024071 0ustar williamwilliampackage main import . "./namespace_typemap" func main() { if Stest1("hello") != "hello" { panic(0) } if Stest2("hello") != "hello" { panic(0) } if Stest3("hello") != "hello" { panic(0) } if Stest4("hello") != "hello" { panic(0) } if Stest5("hello") != "hello" { panic(0) } if Stest6("hello") != "hello" { panic(0) } if Stest7("hello") != "hello" { panic(0) } if Stest8("hello") != "hello" { panic(0) } if Stest9("hello") != "hello" { panic(0) } if Stest10("hello") != "hello" { panic(0) } if Stest11("hello") != "hello" { panic(0) } if Stest12("hello") != "hello" { panic(0) } c := complex(2, 3) r := real(c) if Ctest1(c) != r { println(Ctest1(c)) panic(Ctest1(c)) } if Ctest2(c) != r { panic(0) } if Ctest3(c) != r { panic(0) } if Ctest4(c) != r { panic(0) } if Ctest5(c) != r { panic(0) } if Ctest6(c) != r { panic(0) } if Ctest7(c) != r { panic(0) } if Ctest8(c) != r { panic(0) } if Ctest9(c) != r { panic(0) } if Ctest10(c) != r { panic(0) } if Ctest11(c) != r { panic(0) } if Ctest12(c) != r { panic(0) } ok := false func() { defer func() { ok = recover() != nil }() Ttest1(-14) }() if !ok { panic(0) } } swig-3.0.2/Examples/test-suite/go/smart_pointer_rename_runme.go0000664000175000017500000000032212343605122024603 0ustar williamwilliampackage main import . "./smart_pointer_rename" func main() { f := NewFoo() b := NewBar(f) if b.Test() != 3 { panic(0) } if b.Ftest1(1) != 1 { panic(0) } if b.Ftest2(2, 3) != 2 { panic(0) } } swig-3.0.2/Examples/test-suite/go/inherit_missing_runme.go0000664000175000017500000000061512343605122023566 0ustar williamwilliampackage main import "./inherit_missing" func main() { a := inherit_missing.New_Foo() b := inherit_missing.NewBar() c := inherit_missing.NewSpam() x := inherit_missing.Do_blah(a) if x != "Foo::blah" { panic(x) } x = inherit_missing.Do_blah(b) if x != "Bar::blah" { panic(x) } x = inherit_missing.Do_blah(c) if x != "Spam::blah" { panic(x) } inherit_missing.Delete_Foo(a) } swig-3.0.2/Examples/test-suite/go/smart_pointer_extend_runme.go0000664000175000017500000000071712343605122024633 0ustar williamwilliampackage main import . "./smart_pointer_extend" func main() { f := NewFoo() b := NewBar(f) if b.Extension() != f.Extension() { panic(0) } b2 := NewCBase() d := NewCDerived() p := NewCPtr() if b2.Bar() != p.Bar() { panic(0) } if d.Foo() != p.Foo() { panic(0) } if CBaseHello() != p.Hello() { panic(0) } d2 := NewDFoo() dp := NewDPtrFoo(d2) if DFooSExt(1) != dp.SExt(1) { panic(0) } if d2.Ext(1) != dp.Ext(1) { panic(0) } } swig-3.0.2/Examples/test-suite/go/overload_complicated_runme.go0000664000175000017500000000174712343605122024561 0ustar williamwilliampackage main import . "./overload_complicated" func main() { var pInt *int // Check the correct constructors are available p := NewPop(pInt) p = NewPop(pInt, false) // Check overloaded in const only and pointers/references // which target languages cannot disambiguate if p.Hip(false) != 701 { panic("Test 1 failed") } if p.Hip(pInt) != 702 { panic("Test 2 failed") } // Reverse the order for the above if p.Hop(pInt) != 805 { panic("Test 3 failed") } if p.Hop(false) != 801 { panic("Test 4 failed") } // Few more variations and order shuffled if p.Pop(false) != 901 { panic("Test 5 failed") } if p.Pop(pInt) != 902 { panic("Test 6 failed") } if p.Pop() != 905 { panic("Test 7 failed") } // Overload on const only if p.Bop(pInt) != 1001 { panic("Test 8 failed") } if p.Bip(pInt) != 2001 { panic("Test 9 failed") } // Globals if Muzak(false) != 3001 { panic("Test 10 failed") } if Muzak(pInt) != 3002 { panic("Test 11 failed") } } swig-3.0.2/Examples/test-suite/go/refcount_runme.go0000664000175000017500000000067012343605122022221 0ustar williamwilliampackage main import . "./refcount" // very innocent example func main() { a := NewA3() _ = NewB(a) b2 := BCreate(a) if a.Ref_count() != 3 { panic("This program will crash... now") } rca := b2.Get_rca() // _ = BCreate(rca) _ = rca if a.Ref_count() != 4 { panic("This program will crash... now") } /* Requires smart pointer support. v := NewVector_A(2) v.Set(0, a) v.Set(1, a) _ = v.Get(0) DeleteVector_A(v) */ } swig-3.0.2/Examples/test-suite/go/return_const_value_runme.go0000664000175000017500000000041012343605122024305 0ustar williamwilliampackage main import "./return_const_value" func main() { p := return_const_value.Foo_ptrGetPtr() if p.GetVal() != 17 { panic("Runtime test1 failed") } p = return_const_value.Foo_ptrGetConstPtr() if p.GetVal() != 17 { panic("Runtime test2 failed") } } swig-3.0.2/Examples/test-suite/go/li_carrays_runme.go0000664000175000017500000000026512343605122022524 0ustar williamwilliampackage main import . "./li_carrays" func main() { d := NewDoubleArray(10) d.Setitem(0, 7) d.Setitem(5, d.Getitem(0)+3) if d.Getitem(5)+d.Getitem(0) != 17 { panic(0) } } swig-3.0.2/Examples/test-suite/go/director_frob_runme.go0000664000175000017500000000022412343605122023212 0ustar williamwilliampackage main import . "./director_frob" func main() { foo := NewBravo() s := foo.Abs_method() if s != "Bravo::abs_method()" { panic(s) } } swig-3.0.2/Examples/test-suite/go/director_alternating_runme.go0000664000175000017500000000020012343605122024564 0ustar williamwilliampackage main import . "./director_alternating" func main() { id := GetBar().Id() if id != IdFromGetBar() { panic(id) } } swig-3.0.2/Examples/test-suite/go/abstract_virtual_runme.go0000664000175000017500000000015512343605122023743 0ustar williamwilliampackage main import "./abstract_virtual" func main() { abstract_virtual.NewD() abstract_virtual.NewE() } swig-3.0.2/Examples/test-suite/go/using2_runme.go0000664000175000017500000000013312343605122021575 0ustar williamwilliampackage main import "./using2" func main() { if using2.Spam(37) != 37 { panic(0) } } swig-3.0.2/Examples/test-suite/go/using_composition_runme.go0000664000175000017500000000133012343605122024136 0ustar williamwilliampackage main import . "./using_composition" func main() { f := NewFooBar() if f.Blah(3).(int) != 3 { panic("FooBar::blah(int)") } if f.Blah(3.5) != 3.5 { panic("FooBar::blah(double)") } if f.Blah("hello").(string) != "hello" { panic("FooBar::blah(char *)") } f2 := NewFooBar2() if f2.Blah(3).(int) != 3 { panic("FooBar2::blah(int)") } if f2.Blah(3.5) != 3.5 { panic("FooBar2::blah(double)") } if f2.Blah("hello").(string) != "hello" { panic("FooBar2::blah(char *)") } f3 := NewFooBar3() if f3.Blah(3).(int) != 3 { panic("FooBar3::blah(int)") } if f3.Blah(3.5) != 3.5 { panic("FooBar3::blah(double)") } if f3.Blah("hello").(string) != "hello" { panic("FooBar3::blah(char *)") } } swig-3.0.2/Examples/test-suite/go/rename_strip_encoder_runme.go0000664000175000017500000000020012343605122024550 0ustar williamwilliampackage main import . "./rename_strip_encoder" func main() { _ = NewSomeWidget() a := NewAnotherWidget() a.DoSomething() } swig-3.0.2/Examples/test-suite/go/extern_c_runme.go0000664000175000017500000000011512343605122022175 0ustar williamwilliampackage main import "./extern_c" func main() { extern_c.RealFunction(2) } swig-3.0.2/Examples/test-suite/go/typedef_scope_runme.go0000664000175000017500000000033512343605122023223 0ustar williamwilliampackage main import "./typedef_scope" func main() { b := typedef_scope.NewBar() x := b.Test1(42, "hello") if x != 42 { panic("Failed!!") } xb := b.Test2(42, "hello") if xb != "hello" { panic("Failed!!") } } swig-3.0.2/Examples/test-suite/go/special_variable_macros_runme.go0000664000175000017500000000137012343605122025223 0ustar williamwilliampackage main import "./special_variable_macros" func main() { name := special_variable_macros.NewName() if special_variable_macros.TestFred(name) != "none" { panic("test failed") } if special_variable_macros.TestJack(name) != "$specialname" { panic("test failed") } if special_variable_macros.TestJill(name) != "jilly" { panic("test failed") } if special_variable_macros.TestMary(name) != "SWIGTYPE_p_NameWrap" { panic("test failed") } if special_variable_macros.TestJames(name) != "SWIGTYPE_Name" { panic("test failed") } if special_variable_macros.TestJim(name) != "multiname num" { panic("test failed") } if special_variable_macros.TestJohn(special_variable_macros.NewPairIntBool(10, false)) != 123 { panic("test failed") } } swig-3.0.2/Examples/test-suite/go/mod_runme.go0000664000175000017500000000022112343605122021143 0ustar williamwilliampackage main import "mod_a" import "mod_b" func main() { c := mod_b.NewC() d := mod_b.NewD() d.DoSomething(mod_a.SwigcptrA(c.Swigcptr())) } swig-3.0.2/Examples/test-suite/go/global_ns_arg_runme.go0000664000175000017500000000011412343605122023156 0ustar williamwilliampackage main import . "./global_ns_arg" func main() { Foo(1) Bar_fn() } swig-3.0.2/Examples/test-suite/go/static_const_member_2_runme.go0000664000175000017500000000051612343605122024640 0ustar williamwilliampackage main import . "./static_const_member_2" func main() { _ = NewTest_int() _ = CavityPackFlagsForward_field _ = Test_intCurrent_profile _ = Test_intRightIndex _ = CavityPackFlagsBackward_field _ = Test_intLeftIndex // _ = GetTest_int_Cavity_flags() if GetFooBAZ().GetVal() != 2*GetFooBAR().GetVal() { panic(0) } } swig-3.0.2/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go0000664000175000017500000000034512343605122026213 0ustar williamwilliampackage main import . "./smart_pointer_multi_typedef" func main() { f := NewFoo() b := NewBar(f) s := NewSpam(b) g := NewGrok(b) s.SetX(3) if s.Getx() != 3 { panic(0) } g.SetX(4) if g.Getx() != 4 { panic(0) } } swig-3.0.2/Examples/test-suite/go/typemap_namespace_runme.go0000664000175000017500000000023312343605122024062 0ustar williamwilliampackage main import . "./typemap_namespace" func main() { if Test1("hello") != "hello" { panic(0) } if Test2("hello") != "hello" { panic(0) } } swig-3.0.2/Examples/test-suite/go/typemap_out_optimal_runme.go0000664000175000017500000000014312343605122024462 0ustar williamwilliampackage main import . "./typemap_out_optimal" func main() { SetXXDebug(false) _ = XXCreate() } swig-3.0.2/Examples/test-suite/go/namespace_class_runme.go0000664000175000017500000000033112343605122023507 0ustar williamwilliampackage main import . "./namespace_class" func main() { EulerT3DToFrame(1, 1, 1) _ = NewBooT_i() _ = NewBooT_H() f1 := NewFooT_i() f1.Quack(1) f2 := NewFooT_d() f2.Moo(1) f3 := NewFooT_H() f3.Foo(Hi) } swig-3.0.2/Examples/test-suite/go/overload_subtype_runme.go0000664000175000017500000000024712343605122023762 0ustar williamwilliampackage main import . "./overload_subtype" func main() { f := NewFoo() b := NewBar() if Spam(f) != 1 { panic("foo") } if Spam(b) != 2 { panic("bar") } } swig-3.0.2/Examples/test-suite/go/director_default_runme.go0000664000175000017500000000015012343605122023704 0ustar williamwilliampackage main import . "./director_default" func main() { NewFoo() NewFoo(1) NewBar() NewBar(1) } swig-3.0.2/Examples/test-suite/go/constructor_copy_runme.go0000664000175000017500000000065512343605122024016 0ustar williamwilliampackage main import . "./constructor_copy" func main() { f1 := NewFoo1(3) f11 := NewFoo1(f1) if f1.GetX() != f11.GetX() { panic("f1/f11 x mismatch") } bi := NewBari(5) bc := NewBari(bi) if bi.GetX() != bc.GetX() { panic("bi/bc x mismatch") } bd := NewBard(5) good := false func() { defer func() { if recover() != nil { good = true } }() NewBard(bd) }() if !good { panic("bd !good") } } swig-3.0.2/Examples/test-suite/go/reference_global_vars_runme.go0000664000175000017500000000431512343605122024705 0ustar williamwilliampackage main import . "./reference_global_vars" func main() { // const class reference variable if GetconstTC().GetNum() != 33 { panic(0) } // primitive reference variables SetVar_bool(Createref_bool(false)) if Value_bool(GetVar_bool()) != false { println(1, GetVar_bool(), Value_bool(GetVar_bool())) panic(0) } SetVar_bool(Createref_bool(true)) if Value_bool(GetVar_bool()) != true { println(2, GetVar_bool(), Value_bool(GetVar_bool())) panic(0) } SetVar_char(Createref_char('w')) if Value_char(GetVar_char()) != 'w' { println(3, GetVar_char(), Value_char(GetVar_char())) panic(0) } SetVar_unsigned_char(Createref_unsigned_char(10)) if Value_unsigned_char(GetVar_unsigned_char()) != 10 { println(4, GetVar_unsigned_char(), Value_unsigned_char(GetVar_unsigned_char())) panic(0) } SetVar_signed_char(Createref_signed_char(10)) if Value_signed_char(GetVar_signed_char()) != 10 { panic(0) } SetVar_short(Createref_short(10)) if Value_short(GetVar_short()) != 10 { panic(0) } SetVar_unsigned_short(Createref_unsigned_short(10)) if Value_unsigned_short(GetVar_unsigned_short()) != 10 { panic(0) } SetVar_int(Createref_int(10)) if Value_int(GetVar_int()) != 10 { panic(0) } SetVar_unsigned_int(Createref_unsigned_int(10)) if Value_unsigned_int(GetVar_unsigned_int()) != 10 { panic(0) } SetVar_long(Createref_long(10)) if Value_long(GetVar_long()) != 10 { panic(0) } SetVar_unsigned_long(Createref_unsigned_long(10)) if Value_unsigned_long(GetVar_unsigned_long()) != 10 { panic(0) } SetVar_long_long(Createref_long_long(0x6FFFFFFFFFFFFFF8)) if Value_long_long(GetVar_long_long()) != 0x6FFFFFFFFFFFFFF8 { panic(0) } //ull = abs(0xFFFFFFF2FFFFFFF0) ull := uint64(55834574864) SetVar_unsigned_long_long(Createref_unsigned_long_long(ull)) if Value_unsigned_long_long(GetVar_unsigned_long_long()) != ull { panic(0) } SetVar_float(Createref_float(10.5)) if Value_float(GetVar_float()) != 10.5 { panic(0) } SetVar_double(Createref_double(10.5)) if Value_double(GetVar_double()) != 10.5 { panic(0) } // class reference variable SetVar_TestClass(Createref_TestClass(NewTestClass(20))) if Value_TestClass(GetVar_TestClass()).GetNum() != 20 { panic(0) } } swig-3.0.2/Examples/test-suite/go/extend_template_runme.go0000664000175000017500000000025012343605122023550 0ustar williamwilliampackage main import "./extend_template" func main() { f := extend_template.NewFoo_0() if f.Test1(37) != 37 { panic(0) } if f.Test2(42) != 42 { panic(0) } } swig-3.0.2/Examples/test-suite/go/memberin_extend_c_runme.go0000664000175000017500000000026612343605122024044 0ustar williamwilliampackage main import "./memberin_extend_c" func main() { t := memberin_extend_c.NewPerson() t.SetName("Fred Bloggs") if t.GetName() != "FRED BLOGGS" { panic("name wrong") } } swig-3.0.2/Examples/test-suite/go/input_runme.go0000664000175000017500000000022712343605122021531 0ustar williamwilliampackage main import . "./input" func main() { f := NewFoo() if f.Foo(2) != 4 { panic(0) } if Sfoo("Hello") != "Hello world" { panic(0) } } swig-3.0.2/Examples/test-suite/go/template_opaque_runme.go0000664000175000017500000000021712343605122023556 0ustar williamwilliampackage main import "./template_opaque" func main() { v := template_opaque.NewOpaqueVectorType(int64(10)) template_opaque.FillVector(v) } swig-3.0.2/Examples/test-suite/go/overload_rename_runme.go0000664000175000017500000000040012343605122023525 0ustar williamwilliampackage main import "./overload_rename" func main() { _ = overload_rename.NewFoo(float32(1)) _ = overload_rename.NewFoo(float32(1), float32(1)) _ = overload_rename.NewFoo_int(float32(1), 1) _ = overload_rename.NewFoo_int(float32(1), 1, float32(1)) } swig-3.0.2/Examples/test-suite/go/preproc_runme.go0000664000175000017500000000035512343605122022046 0ustar williamwilliampackage main import "./preproc" func main() { if preproc.GetEndif() != 1 { panic(0) } if preproc.GetDefine() != 1 { panic(0) } if preproc.GetDefined() != 1 { panic(0) } if 2*preproc.One != preproc.Two { panic(0) } } swig-3.0.2/Examples/test-suite/go/director_nested_runme.go0000664000175000017500000000246012343605122023550 0ustar williamwilliampackage main import . "./director_nested" type A struct{} // From FooBar_int func (p *A) Do_step() string { return "A::do_step;" } func (p *A) Get_value() string { return "A::get_value" } func f1() { a := NewDirectorFooBar_int(&A{}) if a.Step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;" { panic("Bad A virtual resolution") } } type B struct{} // From FooBar_int func (p *B) Do_advance() string { return "B::do_advance;" + p.Do_step() } func (p *B) Do_step() string { return "B::do_step;" } func (p *B) Get_value() int { return 1 } func f2() { b := NewDirectorFooBar_int(&B{}) if b.Step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;" { panic("Bad B virtual resolution") } } type C struct { fbi FooBar_int } // From FooBar_int func (p *C) Do_advance() string { return "C::do_advance;" + DirectorFooBar_intDo_advance(p.fbi) } func (p *C) Do_step() string { return "C::do_step;" } func (p *C) Get_value() int { return 2 } func (p *C) Get_name() string { return DirectorFooBar_intGet_name(p.fbi) + " hello" } func f3() { m := &C{nil} cc := NewDirectorFooBar_int(m) m.fbi = cc c := FooBar_intGet_self(cc) c.Advance() if c.Get_name() != "FooBar::get_name hello" { panic(0) } if c.Name() != "FooBar::get_name hello" { panic(0) } } func main() { f1() f2() f3() } swig-3.0.2/Examples/test-suite/go/disown_runme.go0000664000175000017500000000013412343605122021672 0ustar williamwilliampackage main import . "./disown" func main() { a := NewA() b := NewB() b.Acquire(a) } swig-3.0.2/Examples/test-suite/go/char_binary_runme.go0000664000175000017500000000065412343605122022657 0ustar williamwilliampackage main import . "./char_binary" func main() { t := NewTest() if t.Strlen("hile") != 4 { print(t.Strlen("hile")) panic("bad multi-arg typemap") } if t.Strlen("hil\000") != 4 { panic("bad multi-arg typemap") } // creating a raw char* pc := New_pchar(5) Pchar_setitem(pc, 0, 'h') Pchar_setitem(pc, 1, 'o') Pchar_setitem(pc, 2, 'l') Pchar_setitem(pc, 3, 'a') Pchar_setitem(pc, 4, 0) Delete_pchar(pc) } swig-3.0.2/Examples/test-suite/go/extend_variable_runme.go0000664000175000017500000000013512343605122023524 0ustar williamwilliampackage main import . "./extend_variable" func main() { if FooBar != 42 { panic(0) } } swig-3.0.2/Examples/test-suite/go/template_ns_runme.go0000664000175000017500000000047212343605122022707 0ustar williamwilliampackage main import . "./template_ns" func main() { p1 := NewPairii(2, 3) p2 := NewPairii(p1) if p2.GetFirst() != 2 { panic(0) } if p2.GetSecond() != 3 { panic(0) } p3 := NewPairdd(3.5, 2.5) p4 := NewPairdd(p3) if p4.GetFirst() != 3.5 { panic(0) } if p4.GetSecond() != 2.5 { panic(0) } } swig-3.0.2/Examples/test-suite/go/grouping_runme.go0000664000175000017500000000033712343605122022226 0ustar williamwilliampackage main import "./grouping" func main() { x := grouping.Test1(42) if x != 42 { panic(0) } grouping.Test2(42) x = grouping.Do_unary(37, grouping.NEGATE) if x != -37 { panic(0) } grouping.SetTest3(42) } swig-3.0.2/Examples/test-suite/go/exception_order_runme.go0000664000175000017500000000145012343605122023562 0ustar williamwilliampackage main import "strings" import . "./exception_order" func main() { a := NewA() func() { defer func() { e := recover() if strings.Index(e.(string), "E1") == -1 { panic(e.(string)) } }() a.Foo() }() func() { defer func() { e := recover() if strings.Index(e.(string), "E2") == -1 { panic(e.(string)) } }() a.Bar() }() func() { defer func() { e := recover() if e.(string) != "postcatch unknown" { panic("bad exception order") } }() a.Foobar() }() func() { defer func() { e := recover() if strings.Index(e.(string), "E1") == -1 { panic(e.(string)) } }() a.Barfoo(1) }() func() { defer func() { e := recover() if strings.Index(e.(string), "E2") == -1 { panic(e.(string)) } }() a.Barfoo(2) }() } swig-3.0.2/Examples/test-suite/go/director_detect_runme.go0000664000175000017500000000141112343605122023531 0ustar williamwilliampackage main import "./director_detect" type MyBar struct { val int } // From director_detect.Bar func NewMyBar() director_detect.Bar { return director_detect.NewDirectorBar(&MyBar{2}) } func (p *MyBar) Get_value() int { p.val++ return p.val } func (p *MyBar) Get_class() director_detect.A { p.val++ return director_detect.NewA() } func (p *MyBar) Just_do_it() { p.val++ } func (p *MyBar) Clone() director_detect.Bar { return director_detect.NewDirectorBar(&MyBar{p.val}) } func main() { b := NewMyBar() f := b.Baseclass() v := f.Get_value() _ = f.Get_class() f.Just_do_it() c := b.DirectorInterface().(*MyBar).Clone() vc := c.Get_value() if (v != 3) || (b.DirectorInterface().(*MyBar).val != 5) || (vc != 6) { panic("Bad virtual detection") } } swig-3.0.2/Examples/test-suite/go/rename_scope_runme.go0000664000175000017500000000027212343605122023032 0ustar williamwilliampackage main import . "./rename_scope" func main() { a := NewNatural_UP() b := NewNatural_BP() if a.Rtest() != 1 { panic(0) } if b.Rtest() != 1 { panic(0) } _ = Equals } swig-3.0.2/Examples/test-suite/go/ret_by_value_runme.go0000664000175000017500000000025012343605122023046 0ustar williamwilliampackage main import "./ret_by_value" func main() { a := ret_by_value.Get_test() if a.GetMyInt() != 100 { panic(0) } if a.GetMyShort() != 200 { panic(0) } } swig-3.0.2/Examples/test-suite/go/arrays_global_runme.go0000664000175000017500000000064212343605122023214 0ustar williamwilliampackage main import . "./arrays_global" func main() { SetArray_i(GetArray_const_i()) GetBeginString_FIX44a() GetBeginString_FIX44b() GetBeginString_FIX44c() GetBeginString_FIX44d() GetBeginString_FIX44d() SetBeginString_FIX44b("12\00045") GetBeginString_FIX44b() GetBeginString_FIX44d() GetBeginString_FIX44e() GetBeginString_FIX44f() Test_a("hello", "hi", "chello", "chi") Test_b("1234567", "hi") } swig-3.0.2/Examples/test-suite/go/template_inherit_runme.go0000664000175000017500000000153712343605122023734 0ustar williamwilliampackage main import . "./template_inherit" func main() { a := NewFooInt() b := NewFooDouble() c := NewBarInt() d := NewBarDouble() e := NewFooUInt() f := NewBarUInt() if a.Blah() != "Foo" { panic(0) } if b.Blah() != "Foo" { panic(0) } if e.Blah() != "Foo" { panic(0) } if c.Blah() != "Bar" { panic(0) } if d.Blah() != "Bar" { panic(0) } if f.Blah() != "Bar" { panic(0) } if c.Foomethod() != "foomethod" { panic(0) } if d.Foomethod() != "foomethod" { panic(0) } if f.Foomethod() != "foomethod" { panic(0) } if Invoke_blah_int(a) != "Foo" { panic(0) } if Invoke_blah_int(c) != "Bar" { panic(0) } if Invoke_blah_double(b) != "Foo" { panic(0) } if Invoke_blah_double(d) != "Bar" { panic(0) } if Invoke_blah_uint(e) != "Foo" { panic(0) } if Invoke_blah_uint(f) != "Bar" { panic(0) } } swig-3.0.2/Examples/test-suite/go/dynamic_cast_runme.go0000664000175000017500000000036112343605122023027 0ustar williamwilliampackage main import "./dynamic_cast" func main() { f := dynamic_cast.NewFoo() b := dynamic_cast.NewBar() _ = f.Blah() y := b.Blah() a := dynamic_cast.Do_test(dynamic_cast.FooToBar(y)) if a != "Bar::test" { panic("Failed!!") } } swig-3.0.2/Examples/test-suite/go/virtual_poly_runme.go0000664000175000017500000000116312343605122023123 0ustar williamwilliampackage main import "./virtual_poly" func main() { d := virtual_poly.NewNDouble(3.5) i := virtual_poly.NewNInt(2) // the copy methods return the right polymorphic types dc := d.Copy() ic := i.Copy() if d.Get() != dc.Get() { panic(0) } if i.Get() != ic.Get() { panic(0) } virtual_poly.Incr(ic) if (i.Get() + 1) != ic.Get() { panic(0) } dr := d.Ref_this() if d.Get() != dr.Get() { panic(0) } // 'narrowing' also works ddc := virtual_poly.NDoubleNarrow(d.Nnumber()) if d.Get() != ddc.Get() { panic(0) } dic := virtual_poly.NIntNarrow(i.Nnumber()) if i.Get() != dic.Get() { panic(0) } } swig-3.0.2/Examples/test-suite/go/inctest_runme.go0000664000175000017500000000045712343605122022050 0ustar williamwilliampackage main import "./inctest" func main() { inctest.NewA() inctest.NewB() // Check the import in subdirectory worked if inctest.Importtest1(5) != 15 { panic("import test 1 failed") } a := []byte("black") if inctest.Importtest2(string(a)) != "white" { panic("import test 2 failed") } } swig-3.0.2/Examples/test-suite/go/cpp_namespace_runme.go0000664000175000017500000000220712343605122023170 0ustar williamwilliam// Note: This example assumes that namespaces are flattened package main import "./cpp_namespace" func main() { n := cpp_namespace.Fact(4) if n != 24 { panic("Bad return value!") } if cpp_namespace.GetFoo() != 42 { panic("Bad variable value!") } t := cpp_namespace.NewTest() if t.Method() != "Test::method" { panic("Bad method return value!") } if cpp_namespace.Do_method(t) != "Test::method" { panic("Bad return value!") } if cpp_namespace.Do_method2(t) != "Test::method" { panic("Bad return value!") } cpp_namespace.Weird("hello", 4) cpp_namespace.DeleteTest(t) t2 := cpp_namespace.NewTest2() t3 := cpp_namespace.NewTest3() t4 := cpp_namespace.NewTest4() t5 := cpp_namespace.NewTest5() if cpp_namespace.Foo3(42) != 42 { panic("Bad return value!") } if cpp_namespace.Do_method3(t2, 40) != "Test2::method" { panic("Bad return value!") } if cpp_namespace.Do_method3(t3, 40) != "Test3::method" { panic("Bad return value!") } if cpp_namespace.Do_method3(t4, 40) != "Test4::method" { panic("Bad return value!") } if cpp_namespace.Do_method3(t5, 40) != "Test5::method" { panic("Bad return value!") } } swig-3.0.2/Examples/test-suite/go/nested_workaround_runme.go0000664000175000017500000000052612343605122024131 0ustar williamwilliampackage main import . "./nested_workaround" func main() { inner := NewInner(5) outer := NewOuter() newInner := outer.DoubleInnerValue(inner) if newInner.GetValue() != 10 { panic(0) } outer = NewOuter() inner = outer.CreateInner(3) newInner = outer.DoubleInnerValue(inner) if outer.GetInnerValue(newInner) != 6 { panic(0) } } swig-3.0.2/Examples/test-suite/go/template_tbase_template_runme.go0000664000175000017500000000020112343605122025246 0ustar williamwilliampackage main import . "./template_tbase_template" func main() { a := Make_Class_dd() if a.Test() != "test" { panic(0) } } swig-3.0.2/Examples/test-suite/go/sneaky1_runme.go0000664000175000017500000000022612343605122021744 0ustar williamwilliampackage main import "./sneaky1" func main() { _ = sneaky1.Add(3, 4) _ = sneaky1.Subtract(3, 4) _ = sneaky1.Mul(3, 4) _ = sneaky1.Divide(3, 4) } swig-3.0.2/Examples/test-suite/go/overload_simple_runme.go0000664000175000017500000000344512343605122023563 0ustar williamwilliampackage main import . "./overload_simple" func main() { if Foo(3) != "foo:int" { panic("foo(int)") } if Foo(3.0) != "foo:double" { panic("foo(double)") } if Foo("hello") != "foo:char *" { panic("foo(char *)") } f := NewFoos() b := NewBar() if Foo(f) != "foo:Foo *" { panic("foo(Foo *)") } if Foo(b) != "foo:Bar *" { panic("foo(Bar *)") } v := Malloc_void(32) if Foo(v) != "foo:void *" { panic("foo(void *)") } s := NewSpam() if s.Foo(3) != "foo:int" { panic("Spam::foo(int)") } if s.Foo(3.0) != "foo:double" { panic("Spam::foo(double)") } if s.Foo("hello") != "foo:char *" { panic("Spam::foo(char *)") } if s.Foo(f) != "foo:Foo *" { panic("Spam::foo(Foo *)") } if s.Foo(b) != "foo:Bar *" { panic("Spam::foo(Bar *)") } if s.Foo(v) != "foo:void *" { panic("Spam::foo(void *)") } if SpamBar(3) != "bar:int" { panic("Spam::bar(int)") } if SpamBar(3.0) != "bar:double" { panic("Spam::bar(double)") } if SpamBar("hello") != "bar:char *" { panic("Spam::bar(char *)") } if SpamBar(f) != "bar:Foo *" { panic("Spam::bar(Foo *)") } if SpamBar(b) != "bar:Bar *" { panic("Spam::bar(Bar *)") } if SpamBar(v) != "bar:void *" { panic("Spam::bar(void *)") } // Test constructors s = NewSpam() if s.GetXtype() != "none" { panic("Spam()") } s = NewSpam(3) if s.GetXtype() != "int" { panic("Spam(int)") } s = NewSpam(3.4) if s.GetXtype() != "double" { panic("Spam(double)") } s = NewSpam("hello") if s.GetXtype() != "char *" { panic("Spam(char *)") } s = NewSpam(f) if s.GetXtype() != "Foo *" { panic("Spam(Foo *)") } s = NewSpam(b) if s.GetXtype() != "Bar *" { panic("Spam(Bar *)") } s = NewSpam(v) if s.GetXtype() != "void *" { panic("Spam(void *)") } Free_void(v) a := NewClassA() _ = a.Method1(1) } swig-3.0.2/Examples/test-suite/go/smart_pointer_typedef_runme.go0000664000175000017500000000032512343605122024777 0ustar williamwilliampackage main import . "./smart_pointer_typedef" func main() { f := NewFoo() b := NewBar(f) b.SetX(3) if b.Getx() != 3 { panic(0) } fp := b.X__deref__() fp.SetX(4) if fp.Getx() != 4 { panic(0) } } swig-3.0.2/Examples/test-suite/go/class_scope_weird_runme.go0000664000175000017500000000024312343605122024060 0ustar williamwilliampackage main import "./class_scope_weird" func main() { f := class_scope_weird.NewFoo() class_scope_weird.NewFoo(3) if f.Bar(3) != 3 { panic(f.Bar(3)) } } swig-3.0.2/Examples/test-suite/go/template_typedef_cplx4_runme.go0000664000175000017500000000072312343605122025040 0ustar williamwilliampackage main import . "./template_typedef_cplx4" func main() { // this is OK s := NewSin() s.Get_base_value() s.Get_value() s.Get_arith_value() My_func_r(s) Make_Multiplies_double_double_double_double(s, s) z := NewCSin() z.Get_base_value() z.Get_value() z.Get_arith_value() My_func_c(z) Make_Multiplies_complex_complex_complex_complex(z, z) // Here we fail d := Make_Identity_double() My_func_r(d) c := Make_Identity_complex() My_func_c(c) } swig-3.0.2/Examples/test-suite/go/fvirtual_runme.go0000664000175000017500000000022612343605122022225 0ustar williamwilliampackage main import . "./fvirtual" func main() { sw := NewNodeSwitch() n := NewNode() i := sw.AddChild(n) if i != 2 { panic("addChild") } } swig-3.0.2/Examples/test-suite/go/using1_runme.go0000664000175000017500000000013312343605122021574 0ustar williamwilliampackage main import "./using1" func main() { if using1.Spam(37) != 37 { panic(0) } } swig-3.0.2/Examples/test-suite/go/director_finalizer_runme.go0000664000175000017500000000064612343605122024255 0ustar williamwilliampackage main import . "./director_finalizer" type MyFoo struct{} // From Foo func DeleteMyFoo(p Foo) { p.OrStatus(2) DeleteFoo(p) } func main() { ResetStatus() a := NewDirectorFoo(&MyFoo{}) DeleteMyFoo(a) if GetStatus() != 3 { panic(0) } ResetStatus() a = NewDirectorFoo(&MyFoo{}) Launder(a) if GetStatus() != 0 { panic(0) } DeleteMyFoo(a) if GetStatus() != 3 { panic(0) } ResetStatus() } swig-3.0.2/Examples/test-suite/go/abstract_typedef_runme.go0000664000175000017500000000024312343605122023713 0ustar williamwilliampackage main import "./abstract_typedef" func main() { e := abstract_typedef.NewEngine() a := abstract_typedef.NewA() if !a.Write(e) { panic("failed") } } swig-3.0.2/Examples/test-suite/go/template_ns4_runme.go0000664000175000017500000000016612343605122022773 0ustar williamwilliampackage main import . "./template_ns4" func main() { d := Make_Class_DD() if d.Test() != "test" { panic(0) } } swig-3.0.2/Examples/test-suite/go/smart_pointer_templatevariables_runme.go0000664000175000017500000000046612343605122027051 0ustar williamwilliampackage main import . "./smart_pointer_templatevariables" func main() { d := NewDiffImContainerPtr_D(Create(1234, 5678)) if d.GetId() != 1234 { panic(0) } //if (d.xyz != 5678): // panic(0) d.SetId(4321) //d.xyz = 8765 if d.GetId() != 4321 { panic(0) } //if (d.xyz != 8765): // panic(0) } swig-3.0.2/Examples/test-suite/go/typename_runme.go0000664000175000017500000000026612343605122022217 0ustar williamwilliampackage main import "./typename" func main() { f := typename.NewFoo() b := typename.NewBar() var x float64 = typename.TwoFoo(f) var y int = typename.TwoBar(b) _ = x _ = y } swig-3.0.2/Examples/test-suite/go/imports_runme.go0000664000175000017500000000034412343605122022067 0ustar williamwilliam// This is the import runtime testcase. package main import "imports_b" import "imports_a" func main() { x := imports_b.NewB() x.Hello() _ = imports_a.NewA() c := imports_b.NewC() _ = c.Get_a(c) _ = c.Get_a_type(c) } swig-3.0.2/Examples/test-suite/go/using_inherit_runme.go0000664000175000017500000000165312343605122023245 0ustar williamwilliampackage main import . "./using_inherit" func main() { b := NewBar() if b.Test(3).(int) != 3 { panic("Bar::test(int)") } if b.Test(3.5).(float64) != 3.5 { panic("Bar::test(double)") } b2 := NewBar2() if b2.Test(3).(int) != 6 { panic("Bar2::test(int)") } if b2.Test(3.5).(float64) != 7.0 { panic("Bar2::test(double)") } b3 := NewBar3() if b3.Test(3).(int) != 6 { panic("Bar3::test(int)") } if b3.Test(3.5).(float64) != 7.0 { panic("Bar3::test(double)") } b4 := NewBar4() if b4.Test(3).(int) != 6 { panic("Bar4::test(int)") } if b4.Test(3.5).(float64) != 7.0 { panic("Bar4::test(double)") } bf1 := NewFred1() if bf1.Test(3).(int) != 3 { panic("Fred1::test(int)") } if bf1.Test(3.5).(float64) != 7.0 { panic("Fred1::test(double)") } bf2 := NewFred2() if bf2.Test(3).(int) != 3 { panic("Fred2::test(int)") } if bf2.Test(3.5).(float64) != 7.0 { panic("Fred2::test(double)") } } swig-3.0.2/Examples/test-suite/go/template_ref_type_runme.go0000664000175000017500000000021012343605122024072 0ustar williamwilliampackage main import "./template_ref_type" func main() { xr := template_ref_type.NewXC() y := template_ref_type.NewY() y.Find(xr) } swig-3.0.2/Examples/test-suite/go/voidtest_runme.go0000664000175000017500000000054112343605122022232 0ustar williamwilliampackage main import "./voidtest" func main() { voidtest.Globalfunc() f := voidtest.NewFoo() f.Memberfunc() voidtest.FooStaticmemberfunc() v1 := voidtest.Vfunc1(f.Swigcptr()) v2 := voidtest.Vfunc2(f) if v1 != v2 { panic(0) } v3 := voidtest.Vfunc3(v1) v4 := voidtest.Vfunc1(f.Swigcptr()) if v4 != v1 { panic(0) } v3.Memberfunc() } swig-3.0.2/Examples/test-suite/go/template_rename_runme.go0000664000175000017500000000036012343605122023532 0ustar williamwilliampackage main import "./template_rename" func main() { i := template_rename.NewIFoo() d := template_rename.NewDFoo() _ = i.Blah_test(4) _ = i.Spam_test(5) _ = i.Groki_test(6) _ = d.Blah_test(7) _ = d.Spam(8) _ = d.Grok_test(9) } swig-3.0.2/Examples/test-suite/go/default_constructor_runme.go0000664000175000017500000000060312343605122024461 0ustar williamwilliampackage main import dc "./default_constructor" func main() { a := dc.NewA() dc.DeleteA(a) aa := dc.NewAA() dc.DeleteAA(aa) cc := dc.NewCC() dc.DeleteCC(cc) e := dc.NewE() dc.DeleteE(e) ee := dc.NewEE() dc.DeleteEE(ee) f := dc.NewF() f.Destroy() ff := dc.NewFFF() ff.Destroy() g := dc.NewG() dc.GDestroy(g) gg := dc.NewGG() dc.DeleteGG(gg) dc.NewHH(1, 1) } swig-3.0.2/Examples/test-suite/go/director_string_runme.go0000664000175000017500000000112112343605122023565 0ustar williamwilliampackage main import . "./director_string" type B struct { // From A abi A smem string } func NewB(s string) A { p := &B{nil, ""} ret := NewDirectorA(p, s) p.abi = ret return ret } func (p *B) Get_first() string { return DirectorAGet_first(p.abi) + " world!" } func (p *B) Process_text(s string) { DirectorAProcess_text(p.abi, s) p.smem = "hello" } func main() { b := NewB("hello") b.Get(0) if b.Get_first() != "hello world!" { panic(b.Get_first()) } b.Call_process_func() if b.DirectorInterface().(*B).smem != "hello" { panic(b.DirectorInterface().(*B).smem) } } swig-3.0.2/Examples/test-suite/go/smart_pointer_overload_runme.go0000664000175000017500000000050612343605122025153 0ustar williamwilliampackage main import . "./smart_pointer_overload" func main() { f := NewFoo() b := NewBar(f) if f.Test(3) != 1 { panic(0) } if f.Test(3.5) != 2 { panic(0) } if f.Test("hello") != 3 { panic(0) } if b.Test(3) != 1 { panic(0) } if b.Test(3.5) != 2 { panic(0) } if b.Test("hello") != 3 { panic(0) } } swig-3.0.2/Examples/test-suite/go/smart_pointer_simple_runme.go0000664000175000017500000000032412343605122024627 0ustar williamwilliampackage main import . "./smart_pointer_simple" func main() { f := NewFoo() b := NewBar(f) b.SetX(3) if b.Getx() != 3 { panic(0) } fp := b.X__deref__() fp.SetX(4) if fp.Getx() != 4 { panic(0) } } swig-3.0.2/Examples/test-suite/go/director_protected_runme.go0000664000175000017500000000262112343605122024256 0ustar williamwilliampackage main import . "./director_protected" type FooBar struct{} // From Bar func (p *FooBar) Ping() string { return "FooBar::ping();" } type FooBar2 struct{} // From Bar func (p *FooBar2) Ping() string { return "FooBar2::ping();" } func (p *FooBar2) Pang() string { return "FooBar2::pang();" } type FooBar3 struct{} // From Bar func (p *FooBar3) Cheer() string { return "FooBar3::cheer();" } func main() { b := NewBar() f := b.Create() fb := NewDirectorBar(&FooBar{}) fb2 := NewDirectorBar(&FooBar2{}) fb3 := NewDirectorBar(&FooBar3{}) s := fb.Used() if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();" { panic(0) } s = fb2.Used() if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();" { panic(0) } s = b.Pong() if s != "Bar::pong();Foo::pong();Bar::ping();" { panic(0) } s = f.Pong() if s != "Bar::pong();Foo::pong();Bar::ping();" { panic(0) } s = fb.Pong() if s != "Bar::pong();Foo::pong();FooBar::ping();" { panic(0) } s = fb3.DirectorInterface().(*FooBar3).Cheer() if s != "FooBar3::cheer();" { panic(s) } if fb2.Callping() != "FooBar2::ping();" { panic("bad fb2.callping") } if fb2.Callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();" { panic("bad fb2.callcheer") } if fb3.Callping() != "Bar::ping();" { panic("bad fb3.callping") } if fb3.Callcheer() != "FooBar3::cheer();" { panic("bad fb3.callcheer") } } swig-3.0.2/Examples/test-suite/go/Makefile.in0000664000175000017500000001100012343605122020671 0ustar williamwilliam####################################################################### # Makefile for Go test-suite ####################################################################### LANGUAGE = go GO = @GO@ GOGCC = @GOGCC@ GO1 = @GO1@ GO12 = @GO12@ GO13 = @GO13@ GOC = @GOC@ SCRIPTSUFFIX = _runme.go GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` GOLD = $(GOC:c=l) GOTOOL = `if $(GO1) ; then echo go tool; fi` GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi` GOOBJEXT = $(GOC:c=) SO = @SO@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ include $(srcdir)/../common.mk .SUFFIXES: .cpptest .ctest .multicpptest # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase_cpp) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_multi_testcase) multi_import.multicpptest: $(setup) for f in multi_import_b multi_import_a; do \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done $(run_multi_testcase) # Runs the testcase. run_testcase = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ if $(GOGCC) ; then \ $(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*_wrap.@OBJEXT@; \ elif $(GO12) || $(GO13); then \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CC) -extldflags "$(CFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ fi && \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ fi run_testcase_cpp = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ if $(GOGCC) ; then \ $(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*_wrap.@OBJEXT@ -lstdc++; \ elif $(GO12) || $(GO13); then \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ fi && \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ fi run_multi_testcase = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ if $(GOGCC) ; then \ files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \ $(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $${f}_wrap.@OBJEXT@; done` -lstdc++; \ elif $(GO12) || $(GO13); then \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ fi && \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ fi %.clean: @rm -f $*.go $*_gc.c $*_wrap.* $*_runme clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" go_clean rm -f mod_a.go mod_b.go imports_a.go imports_b.go rm -f clientdata_prop_a.go clientdata_prop_b.go rm -f multi_import_a.go multi_import_b.go rm -f packageoption_a.go packageoption_b.go packageoption_c.go rm -f import_stl_a.go import_stl_b.go cvsignore: @echo '*_gc.c *_wrap.* *.so *.dll *.exp *.lib' @echo Makefile @echo mod_a.go mod_b.go imports_a.go imports_b.go @echo clientdata_prop_a.go clientdata_prop_b.go @echo multi_import_a.go multi_import_b.go @echo packageoption_a.go packageoption_b.go packageoption_c.go @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.go; done swig-3.0.2/Examples/test-suite/go/li_std_map_runme.go0000664000175000017500000000067312343605122022512 0ustar williamwilliampackage main import "./li_std_map" func main() { a1 := li_std_map.NewA(3) a2 := li_std_map.NewA(7) _ = li_std_map.NewPairii(1, 2) p1 := li_std_map.NewPairA(1, a1) m := li_std_map.NewMapA() m.Set(1, a1) m.Set(2, a2) _ = li_std_map.P_identa(p1) _ = li_std_map.M_identa(m) m = li_std_map.NewMapA() m.Set(1, a1) m.Set(2, a2) mii := li_std_map.NewIntIntMap() mii.Set(1, 1) mii.Set(1, 2) if mii.Get(1) != 2 { panic(0) } } swig-3.0.2/Examples/test-suite/go/naturalvar_runme.go0000664000175000017500000000025212343605122022547 0ustar williamwilliampackage main import . "./naturalvar" func main() { f := NewFoo() b := NewBar() b.SetF(f) SetS("hello") b.SetS("hello") if b.GetS() != GetS() { panic(0) } } swig-3.0.2/Examples/test-suite/go/namespace_virtual_method_runme.go0000664000175000017500000000015312343605122025432 0ustar williamwilliampackage main import "./namespace_virtual_method" func main() { _ = namespace_virtual_method.NewSpam() } swig-3.0.2/Examples/test-suite/go/contract_runme.go0000664000175000017500000000651112343605122022211 0ustar williamwilliampackage main import "./contract" func main() { contract.Test_preassert(1, 2) contract.Test_postassert(3) func() { defer func() { if recover() == nil { panic("Failed! Postassertions are broken") } }() contract.Test_postassert(-3) }() contract.Test_prepost(2, 3) contract.Test_prepost(5, -4) func() { defer func() { if recover() == nil { panic("Failed! Preassertions are broken") } }() contract.Test_prepost(-3, 4) }() func() { defer func() { if recover() == nil { panic("Failed! Postassertions are broken") } }() contract.Test_prepost(4, -10) }() f := contract.NewFoo() f.Test_preassert(4, 5) func() { defer func() { if recover() == nil { panic("Failed! Method preassertion.") } }() f.Test_preassert(-2, 3) }() f.Test_postassert(4) func() { defer func() { if recover() == nil { panic("Failed! Method postassertion") } }() f.Test_postassert(-4) }() f.Test_prepost(3, 4) f.Test_prepost(4, -3) func() { defer func() { if recover() == nil { panic("Failed! Method preassertion.") } }() f.Test_prepost(-4, 2) }() func() { defer func() { if recover() == nil { panic("Failed! Method postassertion.") } }() f.Test_prepost(4, -10) }() contract.FooStest_prepost(4, 0) func() { defer func() { if recover() == nil { panic("Failed! Static method preassertion") } }() contract.FooStest_prepost(-4, 2) }() func() { defer func() { if recover() == nil { panic("Failed! Static method posteassertion") } }() contract.FooStest_prepost(4, -10) }() b := contract.NewBar() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion.") } }() b.Test_prepost(2, -4) }() d := contract.NewD() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Foo(-1, 1, 1, 1, 1) }() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Foo(1, -1, 1, 1, 1) }() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Foo(1, 1, -1, 1, 1) }() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Foo(1, 1, 1, -1, 1) }() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Foo(1, 1, 1, 1, -1) }() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Bar(-1, 1, 1, 1, 1) }() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Bar(1, -1, 1, 1, 1) }() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Bar(1, 1, -1, 1, 1) }() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Bar(1, 1, 1, -1, 1) }() func() { defer func() { if recover() == nil { panic("Failed! Inherited preassertion (D).") } }() d.Bar(1, 1, 1, 1, -1) }() //Namespace my := contract.NewMyClass(1) func() { defer func() { if recover() == nil { panic("Failed! constructor preassertion") } }() my = contract.NewMyClass(0) }() } swig-3.0.2/Examples/test-suite/go/primitive_ref_runme.go0000664000175000017500000000110112343605122023226 0ustar williamwilliampackage main import . "./primitive_ref" func main() { if Ref_int(3) != 3 { panic(0) } if Ref_uint(3) != 3 { panic(0) } if Ref_short(3) != 3 { panic(0) } if Ref_ushort(3) != 3 { panic(0) } if Ref_long(3) != 3 { panic(0) } if Ref_ulong(3) != 3 { panic(0) } if Ref_schar(3) != 3 { panic(0) } if Ref_uchar(3) != 3 { panic(0) } if Ref_float(3.5) != 3.5 { panic(0) } if Ref_double(3.5) != 3.5 { panic(0) } if Ref_bool(true) != true { panic(0) } if Ref_char('x') != 'x' { panic(0) } if Ref_over(0) != 0 { panic(0) } } swig-3.0.2/Examples/test-suite/go/li_cdata_runme.go0000664000175000017500000000026412343605122022133 0ustar williamwilliampackage main import . "./li_cdata" func main() { s := "ABC abc" m := Malloc(256) Memmove(m, s, len(s)) ss := Cdata(m, 7) if string(ss) != "ABC abc" { panic("failed") } } swig-3.0.2/Examples/test-suite/go/director_profile_runme.go0000664000175000017500000000135212343605122023725 0ustar williamwilliampackage main import "fmt" import "./director_profile" type MyB struct{} // From director_profile.B func (p *MyB) Vfi(a int) int { return a + 3 } func main() { _ = director_profile.NewA() myb := director_profile.NewDirectorB(&MyB{}) b := director_profile.BGet_self(myb) fi := func(a int) int { return b.Fi(a) } i := 50000 a := 1 for i != 0 { a = fi(a) // 1 a = fi(a) // 2 a = fi(a) // 3 a = fi(a) // 4 a = fi(a) // 5 a = fi(a) // 6 a = fi(a) // 7 a = fi(a) // 8 a = fi(a) // 9 a = fi(a) // 10 a = fi(a) // 1 a = fi(a) // 2 a = fi(a) // 3 a = fi(a) // 4 a = fi(a) // 5 a = fi(a) // 6 a = fi(a) // 7 a = fi(a) // 8 a = fi(a) // 9 a = fi(a) // 20 i -= 1 } if false { fmt.Println(a) } } swig-3.0.2/Examples/test-suite/go/overload_template_runme.go0000664000175000017500000000605412343605122024104 0ustar williamwilliampackage main import . "./overload_template" func main() { _ = Foo() _ = Maximum(3, 4) _ = Maximum(3.4, 5.2) // mix 1 if Mix1("hi") != 101 { panic("mix1(const char*)") } if Mix1(1.0, 1.0) != 102 { panic("mix1(double, const double &)") } if Mix1(1.0) != 103 { panic("mix1(double)") } // mix 2 if Mix2("hi") != 101 { panic("mix2(const char*)") } if Mix2(1.0, 1.0) != 102 { panic("mix2(double, const double &)") } if Mix2(1.0) != 103 { panic("mix2(double)") } // mix 3 if Mix3("hi") != 101 { panic("mix3(const char*)") } if Mix3(1.0, 1.0) != 102 { panic("mix3(double, const double &)") } if Mix3(1.0) != 103 { panic("mix3(double)") } // Combination 1 if Overtparams1(100) != 10 { panic("overtparams1(int)") } if Overtparams1(100.0, 100) != 20 { panic("overtparams1(double, int)") } // Combination 2 if Overtparams2(100.0, 100) != 40 { panic("overtparams2(double, int)") } // Combination 3 if Overloaded() != 60 { panic("overloaded()") } if Overloaded(100.0, 100) != 70 { panic("overloaded(double, int)") } // Combination 4 if Overloadedagain("hello") != 80 { panic("overloadedagain(const char *)") } if Overloadedagain() != 90 { panic("overloadedagain(double)") } // specializations if Specialization(10) != 202 { panic("specialization(int)") } if Specialization(10.0) != 203 { panic("specialization(double)") } if Specialization(10, 10) != 204 { panic("specialization(int, int)") } if Specialization(10.0, 10.0) != 205 { panic("specialization(double, double)") } if Specialization("hi", "hi") != 201 { panic("specialization(const char *, const char *)") } // simple specialization Xyz() Xyz_int() Xyz_double() // a bit of everything if Overload("hi") != 0 { panic("overload()") } if Overload(1) != 10 { panic("overload(int t)") } if Overload(1, 1) != 20 { panic("overload(int t, const int &)") } if Overload(1, "hello") != 30 { panic("overload(int t, const char *)") } k := NewKlass() if Overload(k) != 10 { panic("overload(Klass t)") } if Overload(k, k) != 20 { panic("overload(Klass t, const Klass &)") } if Overload(k, "hello") != 30 { panic("overload(Klass t, const char *)") } if Overload(10.0, "hi") != 40 { panic("overload(double t, const char *)") } if Overload() != 50 { panic("overload(const char *)") } // everything put in a namespace if Nsoverload("hi") != 1000 { panic("nsoverload()") } if Nsoverload(1) != 1010 { panic("nsoverload(int t)") } if Nsoverload(1, 1) != 1020 { panic("nsoverload(int t, const int &)") } if Nsoverload(1, "hello") != 1030 { panic("nsoverload(int t, const char *)") } if Nsoverload(k) != 1010 { panic("nsoverload(Klass t)") } if Nsoverload(k, k) != 1020 { panic("nsoverload(Klass t, const Klass &)") } if Nsoverload(k, "hello") != 1030 { panic("nsoverload(Klass t, const char *)") } if Nsoverload(10.0, "hi") != 1040 { panic("nsoverload(double t, const char *)") } if Nsoverload() != 1050 { panic("nsoverload(const char *)") } AFoo(1) b := NewB() b.Foo(1) } swig-3.0.2/Examples/test-suite/go/template_extend1_runme.go0000664000175000017500000000032512343605122023634 0ustar williamwilliampackage main import "./template_extend1" func main() { a := template_extend1.NewLBaz() b := template_extend1.NewDBaz() if a.Foo() != "lBaz::foo" { panic(0) } if b.Foo() != "dBaz::foo" { panic(0) } } swig-3.0.2/Examples/test-suite/go/enums_runme.go0000664000175000017500000000042112343605122021515 0ustar williamwilliampackage main import "./enums" func main() { enums.Bar2(1) enums.Bar3(1) enums.Bar1(1) if enums.GetEnumInstance() != 2 { panic(0) } if enums.GetSlap() != 10 { panic(0) } if enums.GetMine() != 11 { panic(0) } if enums.GetThigh() != 12 { panic(0) } } swig-3.0.2/Examples/test-suite/go/template_extend2_runme.go0000664000175000017500000000032512343605122023635 0ustar williamwilliampackage main import "./template_extend2" func main() { a := template_extend2.NewLBaz() b := template_extend2.NewDBaz() if a.Foo() != "lBaz::foo" { panic(0) } if b.Foo() != "dBaz::foo" { panic(0) } } swig-3.0.2/Examples/test-suite/go/li_cpointer_runme.go0000664000175000017500000000022512343605122022677 0ustar williamwilliampackage main import . "./li_cpointer" func main() { p := New_intp() Intp_assign(p, 3) if Intp_value(p) != 3 { panic(0) } Delete_intp(p) } swig-3.0.2/Examples/test-suite/go/typedef_inherit_runme.go0000664000175000017500000000072612343605122023560 0ustar williamwilliampackage main import "./typedef_inherit" func main() { a := typedef_inherit.NewFoo() b := typedef_inherit.NewBar() x := typedef_inherit.Do_blah(a) if x != "Foo::blah" { panic(x) } x = typedef_inherit.Do_blah(b) if x != "Bar::blah" { panic(x) } c := typedef_inherit.NewSpam() d := typedef_inherit.NewGrok() x = typedef_inherit.Do_blah2(c) if x != "Spam::blah" { panic(x) } x = typedef_inherit.Do_blah2(d) if x != "Grok::blah" { panic(x) } } swig-3.0.2/Examples/test-suite/go/overload_extendc_runme.go0000664000175000017500000000070612343605122023721 0ustar williamwilliampackage main import "./overload_extendc" func main() { f := overload_extendc.NewFoo() if f.Test(3) != 1 { panic(0) } if f.Test("hello") != 2 { panic(0) } if f.Test(3.5, 2.5) != 3 { panic(0) } if f.Test("hello", 20) != 1020 { panic(0) } if f.Test("hello", 20, 100) != 120 { panic(0) } // C default args if f.Test(f) != 30 { panic(0) } if f.Test(f, 100) != 120 { panic(0) } if f.Test(f, 100, 200) != 300 { panic(0) } } swig-3.0.2/Examples/test-suite/go/cpp_static_runme.go0000664000175000017500000000043612343605122022525 0ustar williamwilliampackage main import . "./cpp_static" func main() { StaticFunctionTestStatic_func() StaticFunctionTestStatic_func_2(1) StaticFunctionTestStatic_func_3(1, 2) SetStaticMemberTestStatic_int(10) if GetStaticMemberTestStatic_int() != 10 { panic(GetStaticMemberTestStatic_int()) } } swig-3.0.2/Examples/test-suite/go/director_enum_runme.go0000664000175000017500000000056112343605122023232 0ustar williamwilliampackage main import "./director_enum" type MyFoo struct{} // From director_enum.Foo func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHello) director_enum.EnumDirectorHello { return val } func main() { b := director_enum.NewFoo() a := director_enum.NewDirectorFoo(&MyFoo{}) if a.Say_hi(director_enum.Hello) != b.Say_hello(director_enum.Hi) { panic(0) } } swig-3.0.2/Examples/test-suite/go/typedef_class_runme.go0000664000175000017500000000021212343605122023211 0ustar williamwilliampackage main import "./typedef_class" func main() { a := typedef_class.NewRealA() a.SetA(3) b := typedef_class.NewB() b.TestA(a) } swig-3.0.2/Examples/test-suite/go/import_nomodule_runme.go0000664000175000017500000000021212343605122023600 0ustar williamwilliampackage main import . "./import_nomodule" func main() { f := Create_Foo() Test1(f, 42) Delete_Foo(f) b := NewBar() Test1(b, 37) } swig-3.0.2/Examples/test-suite/go/threads_exception_runme.go0000664000175000017500000000153112343605122024101 0ustar williamwilliampackage main import "strings" import "./threads_exception" func main() { t := threads_exception.NewTest() error := true func() { defer func() { error = recover() == nil }() t.Unknown() }() if error { panic(0) } error = true func() { defer func() { error = strings.Index(recover().(string), "int exception") == -1 }() t.Simple() }() if error { panic(0) } error = true func() { defer func() { error = recover().(string) != "I died." }() t.Message() }() if error { panic(0) } error = true func() { defer func() { e := recover().(string) error = strings.Index(e, "Exc exception") == -1 }() t.Hosed() }() if error { panic(0) } for i := 1; i < 4; i++ { error = true func() { defer func() { error = recover() == nil }() t.Multi(i) }() if error { panic(0) } } } swig-3.0.2/Examples/test-suite/go/li_cmalloc_runme.go0000664000175000017500000000042312343605122022466 0ustar williamwilliampackage main import . "./li_cmalloc" func main() { p := Malloc_int() Free_int(p) ok := false func() { defer func() { if recover() != nil { ok = true } }() p = Calloc_int(-1) if p == nil { ok = true } Free_int(p) }() if !ok { panic(0) } } swig-3.0.2/Examples/test-suite/go/overload_extend_runme.go0000664000175000017500000000051512343605122023554 0ustar williamwilliampackage main import "./overload_extend" func main() { f := overload_extend.NewFoo() if f.Test().(int) != 0 { panic(0) } if f.Test(3).(int) != 1 { panic(0) } if f.Test("hello").(int) != 2 { panic(0) } if f.Test(float64(3), float64(2)).(float64) != 5 { panic(0) } if f.Test(3.0).(float64) != 1003 { panic(0) } } swig-3.0.2/Examples/test-suite/go/struct_value_runme.go0000664000175000017500000000031312343605122023106 0ustar williamwilliampackage main import "./struct_value" func main() { b := struct_value.NewBar() b.GetA().SetX(3) if b.GetA().GetX() != 3 { panic(0) } b.GetB().SetX(3) if b.GetB().GetX() != 3 { panic(0) } } swig-3.0.2/Examples/test-suite/class_forward.i0000664000175000017500000000013112343605122021225 0ustar williamwilliam%module class_forward %inline %{ struct A { class B; }; class C : public A { }; %} swig-3.0.2/Examples/test-suite/template_ns.i0000664000175000017500000000164512343605122020722 0ustar williamwilliam// Tests the use of the %template directive with fully // qualified scope names %module template_ns %warnfilter(SWIGWARN_RUBY_WRONG_NAME) std::my_pair; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) std::my_pair; /* Ruby, wrong class name */ %ignore std::my_pair::my_pair(); %inline %{ namespace std { template struct my_pair { typedef _T1 first_type; typedef _T2 second_type; _T1 first; _T2 second; my_pair() : first(_T1()), second(_T2()) {} my_pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} template my_pair(const my_pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} }; } %} // Add copy constructor %extend std::my_pair { %template(pair) my_pair<_T1,_T2>; }; %template(pairii) std::my_pair; %template(pairdd) std::my_pair; swig-3.0.2/Examples/test-suite/register_par.i0000664000175000017500000000016712343605122021073 0ustar williamwilliam%module register_par // bug # 924413 %inline { void clear_tree_flags(register struct tree *tp, register int i) {} } swig-3.0.2/Examples/test-suite/allprotected.i0000664000175000017500000000513112343605122021063 0ustar williamwilliam// Tests for the allprotected option %module(directors="1", allprotected="1") allprotected %{ #include %} %include "std_string.i" %feature("director") PublicBase; %feature("director") ProtectedBase; // protected types not supported (ProtectedEnum, IntegerType). Make sure they can be ignored. %ignore ProtectedBase::protectedenum; %ignore ProtectedBase::typedefs; %inline %{ class Klass { std::string name; public: Klass(const std::string& n) : name(n) {} std::string getName() { return name; } }; class PublicBase { std::string str; public: enum AnEnum { EnumVal1, EnumVal2 }; public: PublicBase(const char* s): str(s), instanceMemberVariable(0), anEnum(EnumVal1), stringMember(0) {} virtual ~PublicBase() { } virtual std::string virtualMethod() const { return "PublicBase"; } Klass instanceMethod(Klass k) const { return k; } Klass *instanceOverloaded(Klass *k) const { return k; } Klass *instanceOverloaded(Klass *k, std::string name) const { return new Klass(name); } static Klass staticMethod(Klass k) { return k; } static Klass *staticOverloaded(Klass *k) { return k; } static Klass *staticOverloaded(Klass *k, std::string name) { return new Klass(name); } int instanceMemberVariable; static int staticMemberVariable; static const int staticConstMemberVariable = 20; AnEnum anEnum; char *stringMember; }; int PublicBase::staticMemberVariable = 10; class ProtectedBase { std::string str; public: enum AnEnum { EnumVal1, EnumVal2 }; std::string getName() { return str; } protected: ProtectedBase(const char* s): str(s), instanceMemberVariable(0), anEnum(EnumVal1), stringMember(0), protectedenum(ProtEnumVal1) {} virtual ~ProtectedBase() { } virtual std::string virtualMethod() const { return "ProtectedBase"; } Klass instanceMethod(Klass k) const { return k; } Klass *instanceOverloaded(Klass *k) const { return k; } Klass *instanceOverloaded(Klass *k, std::string name) const { return new Klass(name); } static Klass staticMethod(Klass k) { return k; } static Klass *staticOverloaded(Klass *k) { return k; } static Klass *staticOverloaded(Klass *k, std::string name) { return new Klass(name); } int instanceMemberVariable; static int staticMemberVariable; static const int staticConstMemberVariable = 20; AnEnum anEnum; char *stringMember; // unsupported: types defined with protected access and thus methods/variables which use them enum ProtectedEnum { ProtEnumVal1, ProtEnumVal2 }; typedef int IntegerType; ProtectedEnum protectedenum; IntegerType typedefs(IntegerType it) { return it; } }; int ProtectedBase::staticMemberVariable = 10; %} swig-3.0.2/Examples/test-suite/integers.i0000664000175000017500000000305312343605122020222 0ustar williamwilliam/* This test case is meant to be used with run tests that check that -- the whole range of the integer types is supported; -- errors are signalled when out-of-range values are passed. */ %module integers; %inline %{ signed char signed_char_identity(signed char x) { return x; } unsigned char unsigned_char_identity(unsigned char x) { return x; } signed short signed_short_identity(signed short x) { return x; } unsigned short unsigned_short_identity(unsigned short x) { return x; } signed int signed_int_identity(signed int x) { return x; } unsigned int unsigned_int_identity(unsigned int x) { return x; } signed long signed_long_identity(signed long x) { return x; } unsigned long unsigned_long_identity(unsigned long x) { return x; } signed long long signed_long_long_identity(signed long long x) { return x; } unsigned long long unsigned_long_long_identity(unsigned long long x) { return x; } size_t signed_char_size() { return sizeof (signed char); } size_t unsigned_char_size() { return sizeof (unsigned char); } size_t signed_short_size() { return sizeof (signed short); } size_t unsigned_short_size() { return sizeof (unsigned short); } size_t signed_int_size() { return sizeof (signed int); } size_t unsigned_int_size() { return sizeof (unsigned int); } size_t signed_long_size() { return sizeof (signed long); } size_t unsigned_long_size() { return sizeof (unsigned long); } size_t signed_long_long_size() { return sizeof (signed long long); } size_t unsigned_long_long_size() { return sizeof (unsigned long long); } %} swig-3.0.2/Examples/test-suite/threads.i0000664000175000017500000000105212343605122020031 0ustar williamwilliam// This test is designed for testing wrappers in the target language in a multi-threaded environment. // The most common cause for this test failing is incorrect compiler settings for a multi-threaded environment. %module threads %include "std_string.i" %newobject Kerfuffle::CharString; %inline %{ #include struct Kerfuffle { std::string StdString(std::string str) { return str; } char * CharString(const char *str) { char * retstr = new char[256]; strcpy(retstr, str); return retstr; } }; %} swig-3.0.2/Examples/test-suite/template_template_parameters.i0000664000175000017500000000227212343605122024335 0ustar williamwilliam%module template_template_parameters %inline %{ namespace pfc { template class t_alloc> class array_t {}; template class alloc_fast { public: typedef t_item alloc_type; }; } template class list_impl_t {}; template class t_alloc = pfc::alloc_fast > class list_t : public list_impl_t > { public: t_item item; // typename t_alloc::alloc_type allotype; // SWIG can't handle this yet void xx() { typename t_alloc::alloc_type atype; // this type is the same as t_item type atype = true; } }; void TestInstantiations() { pfc::array_t myArrayInt; list_impl_t > myListImplInt; (void) myArrayInt; (void) myListImplInt; } %} %template(ListImplFastBool) list_impl_t >; %template(ListFastBool) list_t; %template(ListImplFastDouble) list_impl_t >; %template(ListDefaultDouble) list_t; swig-3.0.2/Examples/test-suite/extend_special_variables.i0000664000175000017500000000124412343605122023421 0ustar williamwilliam%module extend_special_variables %rename(ForExtensionNewName) ForExtension; %rename(extended_renamed) ForExtension::extended; %extend ForExtension { ForExtension() { return new ForExtension(); } const char* extended() { return "name:$name symname:$symname wrapname:$wrapname overname:$overname decl:$decl fulldecl:$fulldecl parentclasssymname:$parentclasssymname parentclassname:$parentclassname"; } const char* extended(int) { return "name:$name symname:$symname wrapname:$wrapname overname:$overname decl:$decl fulldecl:$fulldecl parentclasssymname:$parentclasssymname parentclassname:$parentclassname"; } } %inline %{ struct ForExtension { }; %} swig-3.0.2/Examples/test-suite/infinity.i0000664000175000017500000000300312343605122020226 0ustar williamwilliam%module infinity /* C99 defines INFINITY Because INFINITY may be defined by compiler built-ins, we can't use #define. Instead, expose the variable MYINFINITY and then use %rename to make it INFINITY in the scripting language. */ %rename(INFINITY) MYINFINITY; %{ #include /* C99 math.h defines INFINITY. If not available, this is the fallback. */ #if !defined(INFINITY) #if defined(_MSC_VER) union MSVC_EVIL_FLOAT_HACK { unsigned __int8 Bytes[4]; float Value; }; const union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}}; #define INFINITY (INFINITY_HACK.Value) #define INFINITY_NO_CONST #endif #ifdef __GNUC__ #define INFINITY (__builtin_inf()) #elif defined(__clang__) #if __has_builtin(__builtin_inf) #define INFINITY (__builtin_inf()) #endif #endif #ifndef INFINITY #define INFINITY (1e1000) #endif #endif #ifdef INFINITY_NO_CONST /* To void: error C2099: initializer is not a constant */ double MYINFINITY = 0.0; void initialise_MYINFINITY(void) { MYINFINITY = INFINITY; } #else const double MYINFINITY = INFINITY; void initialise_MYINFINITY(void) { } #endif float use_infinity(float inf_val) { return inf_val; } %} /* This will allow us to bind the real INFINITY value through SWIG via MYINFINITY. Use %rename to fix the name. */ const double MYINFINITY = INFINITY; void initialise_MYINFINITY(void); /* Use of float is intentional because the original bug was in the float conversion due to overflow checking. */ float use_infinity(float inf_val); swig-3.0.2/Examples/test-suite/struct_value.i0000664000175000017500000000015612343605122021123 0ustar williamwilliam%module struct_value %inline %{ struct Foo { int x; }; struct Bar { Foo a; struct Foo b; }; %} swig-3.0.2/Examples/test-suite/evil_diamond_prop.i0000664000175000017500000000156312343605122022100 0ustar williamwilliam%module(ruby_minherit="1") evil_diamond_prop %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) bar; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) baz; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance %inline %{ class foo { public: int _foo; foo() : _foo(1) {} }; class bar : public foo { public: int _bar; bar() : _bar(2) {} }; class baz : public foo { public: int _baz; baz() : _baz(3) {} }; class spam : public bar, public baz { public: int _spam; spam() : _spam(4) {} }; foo *test(foo *f) { return f; } %} swig-3.0.2/Examples/test-suite/pointer_reference.i0000664000175000017500000000201512343605122022075 0ustar williamwilliam/* This interface file tests whether SWIG handles pointer-reference (*&) arguments. SWIG 1.3a5 signals a syntax error. */ %module pointer_reference %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */ #ifdef SWIGGUILE /* A silly testing typemap for feeding a doubly indirect integer */ %typemap(in) int *&XYZZY (int temp1, int *temp2) { temp1 = scm_to_int($input); temp2 = &temp1; $1 = &temp2; }; #endif %inline %{ void foo(int *&XYZZY) {} %} // Test pointer reference typemaps shipped with SWIG (add in SWIG 1.3.28 for many languages) %inline %{ struct Struct { int value; Struct(int v) : value(v) {} static Struct instance; static Struct *pInstance; }; void set(Struct *const& s) { Struct::instance = *s; } Struct *const& get() { return Struct::pInstance; } int overloading(int i) { return 111; } int overloading(Struct *const& s) { return 222; } %} %{ Struct Struct::instance = Struct(10); Struct *Struct::pInstance = &Struct::instance; %} swig-3.0.2/Examples/test-suite/template_enum_typedef.i0000664000175000017500000000143212343605122022760 0ustar williamwilliam%module template_enum_typedef %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::etraits; /* Ruby, wrong class name */ %inline %{ namespace oss { enum Polarization { UnaryPolarization, BinaryPolarization }; template struct Interface_ { }; struct etraits { static const Polarization pmode = UnaryPolarization; }; template struct Module { typedef Traits traits; static const Polarization P = traits::pmode; void get(Interface_

arg) { }; // Here P is only replace by traits::pmode }; } %} namespace oss { %template(Interface_UP) Interface_; %template(Module_UP) Module; } swig-3.0.2/Examples/test-suite/default_constructor.i0000664000175000017500000000562312343605122022500 0ustar williamwilliam// This module tests default constructor generation under a // number of different conditions %module(ruby_minherit="1") default_constructor %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, D, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */ %delobject F::destroy; %delobject G::destroy; %inline %{ /* A class with a public default constructor */ class A { public: A() { }; }; /* This class should get default constructor/destructors */ class AA : public A { }; /* A class with a public constructor, but not default */ class B { private: B() { } public: B(int x, int y) { } }; /* This class should get no default constructor, but a destructor */ class BB : public B { }; /* A class with a protected constructor */ class C { protected: C() { }; public: }; /* This class does get a default constructor/destructor */ class CC : public C { }; /* A class with a private constructor */ class D { private: D() { }; public: void foo() { }; }; /* This class does not get a default constructor */ class DD: public D { }; /* No default constructor. A is okay, but D is not */ class AD: public A, public D { }; /* This class has a default constructor because of optional arguments */ class E { public: E(int x = 0, int y = 0) { } }; /* This should get a default constructor */ class EE : public E { }; /* This class should not get a default constructor. B doesn't have one */ class EB : public E, public B { }; /* A class with a private destructor */ class F { private: ~F() { } public: void foo(int, int) { } friend void bar(F *); void destroy() { delete this; } }; void bar(F *) { } #if defined(_MSC_VER) #pragma warning(disable: 4624) // : destructor could not be generated because a base class destructor is inaccessible #endif class FFF : public F { }; #if defined(_MSC_VER) #pragma warning(default: 4624) // : destructor could not be generated because a base class destructor is inaccessible #endif /* A class with a protected destructor */ class G { protected: ~G() { } public: static void destroy(G *g) { delete g; } }; class GG : public G { }; template class HH_T { public: HH_T(int i,int j) { } protected: HH_T(); }; %} %template(HH) HH_T; %{ class OSRSpatialReferenceShadow { private: OSRSpatialReferenceShadow(); public: }; %} typedef void OSRSpatialReferenceShadow; class OSRSpatialReferenceShadow { private: public: %extend { OSRSpatialReferenceShadow( char const * wkt = "" ) { return 0; } } }; swig-3.0.2/Examples/test-suite/li_std_vector_member_var.i0000664000175000017500000000067712343605122023452 0ustar williamwilliam%module li_std_vector_member_var %include "std_vector.i" %template(vectorDbl) std::vector; %inline %{ #include typedef std::vector DblVector; struct Test { DblVector v; int x; Test() : x(0) { } void f(int n) { x += n; v.push_back(1.0 / n); } }; // Regression test for SF#3528035: struct S { int x; S() : x(4) { } }; struct T { S start_t; unsigned length; }; %} swig-3.0.2/Examples/test-suite/rename_pcre_enum.i0000664000175000017500000000253612343605122021713 0ustar williamwilliam%module rename_pcre_enum // This file is needed for proper enum support in C#/Java backends #if defined(SWIGCSHARP) || defined(SWIGJAVA) %include "enums.swg" #endif // Apply a rule for renaming the enum elements to avoid the common prefixes // redundant in C#/Java %rename("%(regex:/([A-Z][a-z]+)+_(.*)/\\2/)s",%$isenumitem) ""; // Also don't export special end of enum markers which are often used in C++ // code to just have a symbolic name for the number of enum elements but are // not needed in target language. %rename("$ignore", regexmatch$name="([A-Z][a-z]+)+_Max$",%$isenumitem) ""; // Test another way of doing the same thing with regextarget: %rename("$ignore", %$isenumitem, regextarget=1) "([A-Z][a-z]+)+_Internal$"; // Apply this renaming rule to all enum elements that don't contain more than // one capital letter. %rename("%(lower)s", notregexmatch$name="[A-Z]\\w*[A-Z]", %$isenumitem) ""; %inline %{ // Foo_Internal and Foo_Max won't be exported. enum Foo { Foo_Internal = -1, Foo_First, Foo_Second, Foo_Max }; // All elements of this enum will be exported because they do not match the // excluding regex. enum BoundaryCondition { BoundaryCondition_MinMax, BoundaryCondition_MaxMin, BoundaryCondition_MaxMax }; // The elements of this enum will have lower-case names. enum Colour { Red, Blue, Green }; %} swig-3.0.2/Examples/test-suite/template_typedef_import.i0000664000175000017500000000073012343605122023326 0ustar williamwilliam%module template_typedef_import %{ #include "template_typedef_cplx2.h" %} %import "template_typedef_cplx2.h" %inline %{ typedef vfncs::ArithUnaryFunction RFunction; typedef vfncs::ArithUnaryFunction CFunction; int my_func_r(RFunction* hello) { return 0; } int my_func_c(CFunction* hello) { return 1; } struct Sin : RFunction { }; struct CSin : CFunction { }; %} swig-3.0.2/Examples/test-suite/template_typedef_cplx2.i0000664000175000017500000000015712343605122023047 0ustar williamwilliam%module template_typedef_cplx2 %{ #include "template_typedef_cplx2.h" %} %include "template_typedef_cplx2.h" swig-3.0.2/Examples/test-suite/overload_rename.i0000664000175000017500000000044212343605122021543 0ustar williamwilliam%module overload_rename %{ class Foo { public: Foo(float a, float b=1.0) { } Foo(float a, int c, float b=1.0) { } }; %} %rename(Foo_int) Foo::Foo(float a, int c, float b=1.0); class Foo { public: Foo(float a, float b=1.0); Foo(float a, int c, float b=1.0); }; swig-3.0.2/Examples/test-suite/li_stdint.i0000664000175000017500000000443012343605122020373 0ustar williamwilliam%module li_stdint %include %inline %{ struct StdInts { int8_t int8_member; int16_t int16_member; int32_t int32_member; int64_t int64_member; uint8_t uint8_member; uint16_t uint16_member; uint32_t uint32_member; uint64_t uint64_member; }; int8_t int8_td (int8_t i) { return i; } int16_t int16_td(int16_t i) { return i; } int32_t int32_td(int32_t i) { return i; } int64_t int64_td(int64_t i) { return i; } uint8_t uint8_td (int8_t i) { return i; } uint16_t uint16_td(int16_t i) { return i; } uint32_t uint32_td(int32_t i) { return i; } uint64_t uint64_td(int64_t i) { return i; } struct StdIntFasts { int_fast8_t int_fast8_member; int_fast16_t int_fast16_member; int_fast32_t int_fast32_member; int_fast64_t int_fast64_member; uint_fast8_t uint_fast8_member; uint_fast16_t uint_fast16_member; uint_fast32_t uint_fast32_member; uint_fast64_t uint_fast64_member; }; int_fast8_t int_fast8_td (int_fast8_t i) { return i; } int_fast16_t int_fast16_td(int_fast16_t i) { return i; } int_fast32_t int_fast32_td(int_fast32_t i) { return i; } int_fast64_t int_fast64_td(int_fast64_t i) { return i; } uint_fast8_t uint_fast8_td (int_fast8_t i) { return i; } uint_fast16_t uint_fast16_td(int_fast16_t i) { return i; } uint_fast32_t uint_fast32_td(int_fast32_t i) { return i; } uint_fast64_t uint_fast64_td(int_fast64_t i) { return i; } struct StdIntLeasts { int_least8_t int_least8_member; int_least16_t int_least16_member; int_least32_t int_least32_member; int_least64_t int_least64_member; uint_least8_t uint_least8_member; uint_least16_t uint_least16_member; uint_least32_t uint_least32_member; uint_least64_t uint_least64_member; }; int_least8_t int_least8_td (int_least8_t i) { return i; } int_least16_t int_least16_td(int_least16_t i) { return i; } int_least32_t int_least32_td(int_least32_t i) { return i; } int_least64_t int_least64_td(int_least64_t i) { return i; } uint_least8_t uint_least8_td (int_least8_t i) { return i; } uint_least16_t uint_least16_td(int_least16_t i) { return i; } uint_least32_t uint_least32_td(int_least32_t i) { return i; } uint_least64_t uint_least64_td(int_least64_t i) { return i; } %} swig-3.0.2/Examples/test-suite/namespace_typemap.i0000664000175000017500000001215212343605122022075 0ustar williamwilliam// This tests SWIG's handling of typemaps and namespaces %module namespace_typemap %{ namespace test { /* A minimalistic string class */ class string_class { char *data; public: string_class() { data = 0; } string_class(const char *s) { data = new char[strlen(s)+1]; strcpy(data,s); } ~string_class() { if (data) delete [] data; } char *c_str() { return data; } }; /* A minimalistic test_complex class */ class test_complex { double re; double im; public: test_complex(double r = 0, double i = 0) { re = r; im = i; } double real() { return re; } double imag() { return im; } }; } %} /* SWIG interface tests */ #ifdef SWIGPYTHON %typemap(in) test::test_complex * { if (PyComplex_Check($input)) { $1 = new test_complex(PyComplex_RealAsDouble($input), PyComplex_ImagAsDouble($input)); } else { PyErr_SetString(PyExc_TypeError,"Expected test_complex.\n"); return NULL; } } %typemap(freearg) test::test_complex * { delete $1; } #endif #ifdef SWIGOCTAVE %typemap(in) test::test_complex * { if ($input.is_complex_scalar()) { $1 = new test_complex($input.complex_value().real(), $input.complex_value().imag()); } else { error("Expected test_complex."); } } %typemap(freearg) test::test_complex * { delete $1; } #endif #ifdef SWIGGO %typemap(gotype) test::test_complex * "complex128" %typemap(in) test::test_complex * { $1 = new test_complex(__real__ $input, __imag__ $input); } %typemap(freearg) test::test_complex * { delete $1; } #endif namespace test { class string_class; #ifdef SWIGPYTHON %typemap(in) string_class * { $1 = new string_class(SWIG_Python_str_AsChar($input)); } %typemap(freearg) string_class * { delete $1; } #endif #ifdef SWIGOCTAVE %typemap(in) string_class * { $1 = new string_class($input.string_value().c_str()); } %typemap(freearg) string_class * { delete $1; } #endif #ifdef SWIGRUBY %typemap(in) string_class * { $1 = new string_class(StringValuePtr($input)); } %typemap(freearg) string_class * { delete $1; } #endif #ifdef SWIGGO %typemap(gotype) string_class * "string" %typemap(in) string_class * { $1 = new string_class($input.p); } %typemap(freearg) string_class * { delete $1; } #endif } %inline %{ namespace test { class string_class; class test_complex; /* Functions in the namespace itself */ char *stest1(string_class *s) { return s->c_str(); } double ctest1(test_complex *c) { return c->real(); } } namespace test2 { using test::string_class; using test::test_complex; /* Functions in another namespace */ char *stest2(string_class *s) { return s->c_str(); } double ctest2(test_complex *c) { return c->real(); } } namespace test3 { using namespace test; char *stest3(string_class *s) { return s->c_str(); } double ctest3(test_complex *c) { return c->real(); } } namespace test4 { using namespace test2; char *stest4(string_class *s) { return s->c_str(); } double ctest4(test_complex *c) { return c->real(); } } namespace test5 { using namespace test3; char *stest5(string_class *s) { return s->c_str(); } double ctest5(test_complex *c) { return c->real(); } } char *stest6(test::string_class *s) { return s->c_str(); } double ctest6(test::test_complex *c) { return c->real(); } char *stest7(test2::string_class *s) { return s->c_str(); } double ctest7(test2::test_complex *c) { return c->real(); } char *stest8(test3::string_class *s) { return s->c_str(); } double ctest8(test3::test_complex *c) { return c->real(); } char *stest9(test4::string_class *s) { return s->c_str(); } double ctest9(test4::test_complex *c) { return c->real(); } char *stest10(test5::string_class *s) { return s->c_str(); } double ctest10(test5::test_complex *c) { return c->real(); } namespace test11 = test; char *stest11(test11::string_class *s) { return s->c_str(); } double ctest11(test11::test_complex *c) { return c->real(); } using namespace test2; using test::test_complex; char *stest12(string_class *s) { return s->c_str(); } double ctest12(test_complex *c) { return c->real(); } %} namespace Split { #ifdef SWIGPYTHON %typemap(in) PosInteger { $1 = PyInt_AsLong($input); if ($1 < 0) { PyErr_SetString(PyExc_ValueError,"domain error\n"); return NULL; } } #endif #ifdef SWIGOCTAVE %typemap(in) PosInteger { $1 = $input.long_value(); if ($1 < 0) { error("domain error"); } } #endif #ifdef SWIGRUBY %typemap(in) PosInteger { $1 = NUM2INT($input); if ($1 < 0) { rb_raise(rb_eRangeError, "domain error"); } } #endif #ifdef SWIGGO %typemap(in) PosInteger { $1 = $input; if ($1 < 0) { _swig_gopanic("domain error"); } } #endif } %inline %{ namespace Split { typedef int PosInteger; PosInteger ttest1(PosInteger x) { return x; } } %} swig-3.0.2/Examples/test-suite/python_director.i0000664000175000017500000000047412343605122021622 0ustar williamwilliam%module(directors="1") python_director %feature("director"); %inline %{ class IFactoryFuncs { public: IFactoryFuncs() {} virtual ~IFactoryFuncs() {} virtual PyObject * process(PyObject *pyobj) { return pyobj; } void process_again(const PyObject *& pyobj) { } }; %} swig-3.0.2/Examples/test-suite/sizet.i0000664000175000017500000000120112343605122017531 0ustar williamwilliam%module sizet %{ #include %} #ifndef SWIGCHICKEN %include "std_common.i" #endif %inline { size_t test1(size_t s) { return s; } std::size_t test2(std::size_t s) { return s; } const std::size_t& test3(const std::size_t& s) { return s; } const size_t& test4(const size_t& s) { return s; } } #ifdef SWIGPYTHON %include "std_vector.i" %template(vectors) std::vector; %inline { std::vector testv1(std::vector s) { return s; } const std::vector& testv2(const std::vector& s) { return s; } } #endif swig-3.0.2/Examples/test-suite/namespace_typedef_class.i0000664000175000017500000000021612343605122023241 0ustar williamwilliam%module namespace_typedef_class %inline %{ namespace ns { struct S1 { int n; }; typedef struct { int n; } S2; } %} swig-3.0.2/Examples/test-suite/preproc_include_d withspace.h0000664000175000017500000000003112343605122024022 0ustar williamwilliam int multiply40(int a); swig-3.0.2/Examples/test-suite/cpp11_inheriting_constructors.i0000664000175000017500000000114712343605122024400 0ustar williamwilliam/* This test checks whether SWIG correctly parses the new constructor inheritance. */ %module cpp11_inheriting_constructors %inline %{ // Delegating constructors class BaseClass { private: int _val; public: BaseClass(int iValue) { _val = iValue; } }; // Constructor inheritance via using declaration class DerivedClass: public BaseClass { public: using BaseClass::BaseClass; // Adds DerivedClass(int) constructor }; // Member initialization at the site of the declaration class SomeClass { public: SomeClass() {} explicit SomeClass(int new_value) : value(new_value) {} int value = 5; }; %} swig-3.0.2/Examples/test-suite/typedef_reference.i0000664000175000017500000000030212343605122022052 0ustar williamwilliam%module typedef_reference %include cpointer.i %pointer_functions(int, intp); %inline %{ typedef int & IntRef; int somefunc(IntRef i) { return i; } int otherfunc(int &i) { return i; } %} swig-3.0.2/Examples/test-suite/template_typedef.i0000664000175000017500000001073012343605122021735 0ustar williamwilliam#ifdef SWIGPYTHON %module("templatereduce") template_typedef #else %module template_typedef #endif // // Change this to #if 1 to test the 'test' // #if 0 #define reald double %{ #define reald double %} #else %inline %{ typedef double reald; %} #endif %inline %{ // typedef double reald; namespace vfncs { struct UnaryFunctionBase { }; template struct UnaryFunction; template struct ArithUnaryFunction; template struct UnaryFunction : UnaryFunctionBase { }; template struct ArithUnaryFunction : UnaryFunction { }; template struct unary_func_traits { typedef ArithUnaryFunction base; }; template inline typename unary_func_traits< ArgType, ArgType >::base make_Identity() { return typename unary_func_traits< ArgType, ArgType >::base(); } template struct arith_traits { }; template<> struct arith_traits< float, float > { typedef float argument_type; typedef float result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< reald, reald > { typedef reald argument_type; typedef reald result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< reald, float > { typedef float argument_type; typedef reald result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< float, reald > { typedef float argument_type; typedef reald result_type; static const char* const arg_type; static const char* const res_type; }; template inline ArithUnaryFunction::argument_type, typename arith_traits< RF, RG >::result_type > make_Multiplies(const ArithUnaryFunction& f, const ArithUnaryFunction& g) { return ArithUnaryFunction::argument_type, typename arith_traits< RF, RG >::result_type>(); } #ifndef SWIG // Initialize these static class members const char* const arith_traits< float, float >::arg_type = "float"; const char* const arith_traits< float, float >::res_type = "float"; const char* const arith_traits< reald, reald >::arg_type = "reald"; const char* const arith_traits< reald, reald >::res_type = "reald"; const char* const arith_traits< reald, float >::arg_type = "float"; const char* const arith_traits< reald, float >::res_type = "reald"; const char* const arith_traits< float, reald >::arg_type = "float"; const char* const arith_traits< float, reald >::res_type = "reald"; #endif } %} namespace vfncs { %template(UnaryFunction_float_float) UnaryFunction; %template(ArithUnaryFunction_float_float) ArithUnaryFunction; %template() unary_func_traits; %template() arith_traits; %template(make_Identity_float) make_Identity; %template(UnaryFunction_reald_reald) UnaryFunction; %template(ArithUnaryFunction_reald_reald) ArithUnaryFunction; %template() unary_func_traits; %template() arith_traits; %template(make_Identity_reald) make_Identity; /* [beazley] Added this part */ %template() unary_func_traits; %template(UnaryFunction_float_reald) UnaryFunction; %template(ArithUnaryFunction_float_reald) ArithUnaryFunction; /* */ %template() arith_traits; %template() arith_traits; %template() arith_traits; %template(make_Multiplies_float_float_reald_reald) make_Multiplies; %template(make_Multiplies_float_float_float_float) make_Multiplies; %template(make_Multiplies_reald_reald_reald_reald) make_Multiplies; } #ifdef SWIGPYTHON swig_type_info *SWIG_TypeQuery(const char* name); #endif swig-3.0.2/Examples/test-suite/typemap_arrays.i0000664000175000017500000000123012343605122021435 0ustar williamwilliam%module typemap_arrays // Test that previously non-working array typemaps special variables are working %typemap(in) SWIGTYPE[ANY] { _should_not_be_used_and_will_not_compile_ } // Check $basemangle expands to _p_int and $basetype expands to int * %typemap(in) int *nums[3] (int *temp[3]) { $basetype var1$basemangle = new int(10); $basetype var2$basemangle = new int(20); $basetype var3$basemangle = new int(30); temp[0] = var1_p_int; temp[1] = var2_p_int; temp[2] = var3_p_int; $1 = temp; } %inline %{ int sumA(int *nums[3]) { int sum = 0; for (int i=0; i<3; ++i) { int *p = nums[i]; if (p) sum += *p; } return sum; } %} swig-3.0.2/Examples/test-suite/preproc_constants_c.i0000664000175000017500000000015412343605122022451 0ustar williamwilliam%module preproc_constants_c %define true 1 %enddef %define false 0 %enddef %include "preproc_constants.i" swig-3.0.2/Examples/test-suite/ruby_track_objects_directors.i0000664000175000017500000000072412343605122024340 0ustar williamwilliam%module(directors="1") ruby_track_objects_directors %{ #include %} %include "std_string.i"; %feature("director") Foo; %trackobjects; %inline %{ class Foo { public: Foo() {} virtual ~Foo() {} virtual std::string ping() { return "Foo::ping()"; } virtual std::string pong() { return "Foo::pong();" + ping(); } }; class Container { Foo* foo_; public: Foo* get_foo() { return foo_; } void set_foo(Foo *foo) { foo_ = foo; } }; %} swig-3.0.2/Examples/test-suite/cplusplus_throw.i0000664000175000017500000000102612343605122021655 0ustar williamwilliam/* This interface file checks whether the SWIG parses the throw directive in combination with the const directive. Bug reported by Scott B. Drummonds, 08 June 2001. */ %module cplusplus_throw %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %nodefaultctor; %inline %{ class Foo { }; class Bar { public: void baz() const { }; void foo() throw (Foo) { }; void bazfoo() const throw (int) { }; }; %} swig-3.0.2/Examples/test-suite/li_cwstring.i0000664000175000017500000000351512343605122020731 0ustar williamwilliam%module li_cwstring %include "cwstring.i" #ifndef SWIG_CWSTRING_UNIMPL %cwstring_input_binary(wchar_t *str_in, int n); %cwstring_bounded_output(wchar_t *out1, 512); %cwstring_chunk_output(wchar_t *out2, 64); %cwstring_bounded_mutable(wchar_t *out3, 512); %cwstring_mutable(wchar_t *out4, 32); %cwstring_output_maxsize(wchar_t *out5, int max); %cwstring_output_withsize(wchar_t *out6, int *size); #ifdef __cplusplus %cwstring_output_allocate(wchar_t **out7, delete [] *$1); %cwstring_output_allocate_size(wchar_t **out8, int *size, delete [] *$1); #else %cwstring_output_allocate(wchar_t **out7, free(*$1)); %cwstring_output_allocate_size(wchar_t **out8, int *size, free(*$1)); #endif %inline %{ int count(wchar_t *str_in, int n, wchar_t c) { int r = 0; while (n > 0) { if (*str_in == c) { r++; } str_in++; --n; } return r; } void test1(wchar_t *out1) { wcscpy(out1,L"Hello World"); } void test2(wchar_t *out2) { int i; for (i = 0; i < 64; i++) { *out2 = (wchar_t) i + 32; out2++; } } void test3(wchar_t *out3) { wcscat(out3,L"-suffix"); } void test4(wchar_t *out4) { wcscat(out4,L"-suffix"); } void test5(wchar_t *out5, int max) { int i; for (i = 0; i < max; i++) { out5[i] = 'x'; } out5[max]='\0'; } void test6(wchar_t *out6, int *size) { int i; for (i = 0; i < (*size/2); i++) { out6[i] = 'x'; } *size = (*size/2); } void test7(wchar_t **out7) { #ifdef __cplusplus *out7 = new wchar_t[64]; #else *out7 = malloc(64*sizeof(wchar_t)); #endif (*out7)[0] = 0; wcscat(*out7,L"Hello world!"); } void test8(wchar_t **out8, int *size) { int i; #ifdef __cplusplus *out8 = new wchar_t[64]; #else *out8 = malloc(64*sizeof(wchar_t)); #endif for (i = 0; i < 64; i++) { (*out8)[i] = (wchar_t) i + 32; } *size = 64; } %} #endif swig-3.0.2/Examples/test-suite/kwargs_feature.i0000664000175000017500000000332612343605122021416 0ustar williamwilliam%module kwargs_feature %nocopyctor; %kwargs; %rename(myDel) del; %inline { struct s { int del; }; } // Simple class %extend Foo { int efoo(int a = 1, int b = 0) {return a + b; } static int sfoo(int a = 1, int b = 0) { return a + b; } } %newobject Foo::create; %inline %{ struct Foo { Foo(int a, int b = 0) {} virtual int foo(int a = 1, int b = 0) {return a + b; } static int statfoo(int a = 1, int b = 0) {return a + b; } static Foo *create(int a = 1, int b = 0) { return new Foo(a, b); } virtual ~Foo() { } }; %} // Templated class %extend Bar { T ebar(T a = 1, T b = 0) {return a + b; } static T sbar(T a = 1, T b = 0) { return a + b; } } %inline %{ template struct Bar { Bar(T a, T b = 0){} T bar(T a = 1, T b = 0) {return a + b; } static T statbar(T a = 1, T b = 0) {return a + b; } }; %} %template(BarInt) Bar; // Functions %inline %{ int foo(int a = 1, int b = 0) {return a + b; } template T templatedfunction(T a = 1, T b = 0) { return a + b; } %} %template(templatedfunction) templatedfunction; // Deafult args with references %inline %{ typedef int size_type; struct Hello { static const size_type hello = 3; }; int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() ) { return x; } %} %{ const int Hello::hello; %} // Functions with keywords %warnfilter(SWIGWARN_PARSE_KEYWORD); %inline %{ /* silently rename the parameter names in python */ int foo_kw(int from = 1, int except = 2) {return from + except; } int foo_nu(int from = 1, int = 0) {return from; } int foo_mm(int min = 1, int max = 2) {return min + max; } %} swig-3.0.2/Examples/test-suite/cpp11_decltype.i0000664000175000017500000000047312343605122021222 0ustar williamwilliam/* This testcase checks whether SWIG correctly uses the new 'decltype()' introduced in C++11. */ %module cpp11_decltype %inline %{ class A { public: int i; decltype(i) j; auto foo( decltype(i) a ) -> decltype(i) { if (a==5) return 10; else return 0; } }; %} swig-3.0.2/Examples/test-suite/packageoption.h0000664000175000017500000000015612343605122021226 0ustar williamwilliamstruct Base { virtual int vmethod() { return 1; } int basemethod() { return 1; } virtual ~Base() {} }; swig-3.0.2/Examples/test-suite/template_extend1.i0000664000175000017500000000104412343605122021643 0ustar williamwilliam// One of Luigi's evil tests %module template_extend1 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Baz; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Baz; // Ruby, wrong class name %{ namespace Quux { template class Baz {}; } %} namespace Quux { template class Baz {}; %template (lBaz) Baz; %extend Baz { char *foo(void) { return (char *) "lBaz::foo"; } } %template (dBaz) Baz; %extend Baz { char *foo(void) { return (char *) "dBaz::foo"; } } } swig-3.0.2/Examples/test-suite/global_scope_types.i0000664000175000017500000000217712343605122022265 0ustar williamwilliam%module global_scope_types // no constructor/destructor wrappers as they do not use global scope operator which we are trying to test here %nodefaultctor Dingaling; %nodefaultdtor Dingaling; %inline %{ struct Dingaling {}; typedef Dingaling DINGALING; template struct MyTemplate { T tt(T t) { return t; } T& ttr(T& t) { return t; } }; #ifndef SWIG // This is added so that the code will not compile, if the global scope operator on Dingaling is omitted in the generated code namespace Spac { class Dingaling { Dingaling(); Dingaling(const Dingaling& t); Dingaling& operator=(const Dingaling t); }; } using namespace Spac; #endif namespace Spac { struct Ting {}; typedef Ting TING; class Test { public: void something(::Dingaling t, ::Dingaling* pt, ::Dingaling& rt, const ::Dingaling& crt) {} void tsomething(MyTemplate< ::Dingaling > t1, MyTemplate< const ::Dingaling* > t2) {} // void usomething(::MyTemplate< ::DINGALING > t3, ::MyTemplate< ::DINGALING *> t4) {} // needs fixing void nothing(::Spac::Ting*, ::Spac::TING&) {} }; } extern "C" void funcptrtest( void (*)(::Dingaling) ) {} %} swig-3.0.2/Examples/test-suite/multi_import_b.i0000664000175000017500000000021512343605122021424 0ustar williamwilliam%module multi_import_b %include multi_import_c.i %{ #include "multi_import.h" %} class YYY : public XXX { public: int testy(); }; swig-3.0.2/Examples/test-suite/member_template.i0000664000175000017500000000062212343605122021543 0ustar williamwilliam%module member_template %{ #ifdef max #undef max #endif %} %inline %{ template T max(T x, T y, T z) { return (x > y) ? x : y; } template class Foo { public: template S max(S x, S y) { return (x > y) ? x : y; } }; %} %extend Foo { %template(maxi) max; %template(maxd) max; }; %template(Fooint) Foo; %template(Foodouble) Foo; swig-3.0.2/Examples/test-suite/template_ns_inherit.i0000664000175000017500000000110012343605122022426 0ustar williamwilliam// Submitted by Marcelo Matus %module template_ns_inherit %inline %{ namespace hello { typedef double Double; } namespace hello { template class VUnaryFunction {}; template class UnaryFunction : public VUnaryFunction {}; } %} namespace hello { %template(VUnaryFunction_id) VUnaryFunction; %template(UnaryFunction_id) UnaryFunction; } swig-3.0.2/Examples/test-suite/private_assign.i0000664000175000017500000000167612343605122021431 0ustar williamwilliam// A class with a private assignment operator. // This is rare, but sometimes used with singletons and // objects that have complicated state. %module private_assign %{ #include %} %inline %{ class Foo { private: Foo &operator=(const Foo &f) { return *this; } public: void bar() { } }; Foo blah() { return Foo(); } class Bar : protected Foo { }; %} #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_NEW // operator new %inline %{ class TROOT { protected: void *operator new(size_t l) { return malloc(sizeof(TROOT)); } int prot_meth() { return 1; } public: TROOT() { } TROOT(const char *name, const char *title, void *initfunc = 0) { } }; class A : protected TROOT { }; %} #ifdef SWIGPYTHON // This case only works in python %inline %{ struct FooBar : Foo { }; FooBar bar; %} #endif swig-3.0.2/Examples/test-suite/li_carrays.i0000664000175000017500000000100012343605122020520 0ustar williamwilliam%module li_carrays %warnfilter(SWIGWARN_RUBY_WRONG_NAME) doubleArray; /* Ruby, wrong class name */ %include %array_functions(int,intArray); %array_class(double, doubleArray); %inline %{ typedef struct { int x; int y; } XY; XY globalXYArray[3]; typedef struct { int a; int b; } AB; AB globalABArray[3]; %} // Note that struct XY { ... }; gives compiler error for C when using %array_class or %array_functions, but is okay in C++ %array_class(XY, XYArray) %array_functions(AB, ABArray) swig-3.0.2/Examples/test-suite/import_nomodule.i0000664000175000017500000000200612343605122021613 0ustar williamwilliam%module import_nomodule %{ #include "import_nomodule.h" %} // For Python %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Bar; // Base class 'Foo' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %import directive. %import "import_nomodule.h" #if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD) /** * The proxy class does not have Bar derived from Foo, yet an instance of Bar * can successfully be passed to a proxy function taking a Foo pointer (for some * language modules). * * This violation of the type system is not possible in Java, C# and D due to * static type checking. It's also not (currently) possible in Ruby, but this may * be fixable (needs more investigation). */ %newobject create_Foo; %delobject delete_Foo; %inline %{ Foo *create_Foo() { return new Foo(); } void delete_Foo(Foo *f) { delete f; } void test1(Foo *f, Integer x) { } class Bar : public Foo { }; %} #endif swig-3.0.2/Examples/test-suite/director_nspace.i0000664000175000017500000000327212343605122021551 0ustar williamwilliam%module(directors="1") director_nspace #ifdef SWIGJAVA SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) #endif %{ #include namespace TopLevel { namespace Bar { class FooBar { public: FooBar() {} FooBar(const FooBar&) {} virtual ~FooBar() {} std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; } }; class Foo { public: virtual ~Foo() {} virtual std::string ping() { return "Bar::Foo::ping()"; } virtual std::string pong() { return "Bar::Foo::pong();" + ping(); } virtual std::string fooBar(FooBar* fb) { return fb->FooBarDo(); } virtual Foo makeFoo() { return Foo(); } virtual FooBar makeFooBar() { return FooBar(); } static Foo* get_self(Foo *self_) {return self_;} }; } } %} %include // nspace feature only supported by these languages #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT) %nspace TopLevel::Bar::Foo; %nspace TopLevel::Bar::FooBar; #else //#warning nspace feature not yet supported in this target language #endif %feature("director") TopLevel::Bar::Foo; namespace TopLevel { namespace Bar { class FooBar { public: FooBar(); FooBar(const FooBar&); virtual ~FooBar(); std::string FooBarDo(); }; class Foo { public: virtual ~Foo(); virtual std::string ping(); virtual std::string pong(); virtual std::string fooBar(FooBar* fb); virtual Foo makeFoo(); virtual FooBar makeFooBar(); static Foo* get_self(Foo *self_); }; } } swig-3.0.2/Examples/test-suite/director_profile.i0000664000175000017500000000136012343605122021734 0ustar williamwilliam%module(directors="1") director_profile %include std_string.i %feature("director") B; %inline %{ class A { public: A() {} }; class B { A aa; public: B() {} virtual A fn(const A* a) { return *a; } virtual int vfi(int a) { return a + 1; } int fi(int a) { return vfi(a); } int fj(const A* a) { return 10; } B* fk(int i) { return this; } const char* fl(int i) { return "hello"; } virtual ~B() { } static B* get_self(B *b) { return b; } virtual std::string vfs(const std::string& a) { return a; } std::string fs(const std::string& a) { return vfs(a); } }; %} swig-3.0.2/Examples/test-suite/li_constraints.i0000664000175000017500000000076012343605122021437 0ustar williamwilliam%module li_constraints %include %inline %{ void test_nonnegative(double NONNEGATIVE) { } void test_nonpositive(double NONPOSITIVE) { } void test_positive(double POSITIVE) { } void test_negative(double POSITIVE) { } void test_nonzero(double NONZERO) { } void test_nonnull(void *NONNULL) { } /* These generated non-portable code and there isn't an obvious fix void test_align8(void *ALIGN8) { } void test_align4(void *ALIGN4) { } void test_align2(void *ALIGN2) { } */ %} swig-3.0.2/Examples/test-suite/r_overload_array.i0000664000175000017500000000065212343605122021736 0ustar williamwilliam%module r_overload_array %include "stl.i" # this tests the situation in which there is a scalar function # corresponding with a vector one %inline %{ class Foo { public: double bar(double w) {return w;}; double bar(double *w) {return w[0];} double bar(std::vector w) {return w[0];} int bar_int(int w) {return w;} int bar_int(int *w) {return w[0];} int bar_int(std::vector w) {return w[0];} }; %} swig-3.0.2/Examples/test-suite/unions.i0000664000175000017500000000126312343605122017716 0ustar williamwilliam/* This testcase checks that unions can be set and read. */ %module unions %{ /* Must undefine small to work on Windows. small is defined as a char in rpcndr.h */ #ifdef small #undef small #endif %} %inline %{ typedef struct SmallStruct { short jill; } SmallStruct; typedef struct BigStruct { int jack; SmallStruct smallstruct; } BigStruct; /* This union is just to check the parser */ typedef union { BigStruct bs; SmallStruct ss; } UnionTest; /* This union checks the parser and will be used in a runtime test */ typedef struct { union { BigStruct big; SmallStruct small; } uni; int number; } EmbeddedUnionTest; %} swig-3.0.2/Examples/test-suite/li_cdata.i0000664000175000017500000000013712343605122020142 0ustar williamwilliam%module li_cdata %include %cdata(int); %cdata(double); void *malloc(size_t size); swig-3.0.2/Examples/test-suite/arrays_global_twodim.i0000664000175000017500000000311212343605122022602 0ustar williamwilliam/* Two dimension arrays */ %module arrays_global_twodim %inline %{ #define ARRAY_LEN_X 2 #define ARRAY_LEN_Y 4 typedef enum {One, Two, Three, Four, Five} finger; typedef struct { double double_field; } SimpleStruct; char array_c [ARRAY_LEN_X][ARRAY_LEN_Y]; signed char array_sc[ARRAY_LEN_X][ARRAY_LEN_Y]; unsigned char array_uc[ARRAY_LEN_X][ARRAY_LEN_Y]; short array_s [ARRAY_LEN_X][ARRAY_LEN_Y]; unsigned short array_us[ARRAY_LEN_X][ARRAY_LEN_Y]; int array_i [ARRAY_LEN_X][ARRAY_LEN_Y]; unsigned int array_ui[ARRAY_LEN_X][ARRAY_LEN_Y]; long array_l [ARRAY_LEN_X][ARRAY_LEN_Y]; unsigned long array_ul[ARRAY_LEN_X][ARRAY_LEN_Y]; long long array_ll[ARRAY_LEN_X][ARRAY_LEN_Y]; float array_f [ARRAY_LEN_X][ARRAY_LEN_Y]; double array_d [ARRAY_LEN_X][ARRAY_LEN_Y]; SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]; SimpleStruct* array_structpointers[ARRAY_LEN_X][ARRAY_LEN_Y]; int* array_ipointers [ARRAY_LEN_X][ARRAY_LEN_Y]; finger array_enum[ARRAY_LEN_X][ARRAY_LEN_Y]; finger* array_enumpointers[ARRAY_LEN_X][ARRAY_LEN_Y]; const int array_const_i[ARRAY_LEN_X][ARRAY_LEN_Y] = { {10, 11, 12, 13}, {14, 15, 16, 17} }; void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]) {} int get_2d_array(int (*array)[ARRAY_LEN_Y], int x, int y){ return array[x][y]; } %} #ifdef __cplusplus %inline { struct Material { }; enum { Size = 32 }; const Material * chitMat[Size][Size]; Material hitMat_val[Size][Size]; Material *hitMat[Size][Size]; } #endif swig-3.0.2/Examples/test-suite/aggregate.i0000664000175000017500000000170012343605122020325 0ustar williamwilliam/* This file tests a few new contract features. First it checks to make sure the constant aggregation macro %aggregate_check() works. This is defined in swig.swg. Next, it checks to make sure a simple contract works. To support contracts, you need to add a macro to the runtime. For Python, it looks like this: #define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg #expr ); goto fail; } else Note: It is used like this: SWIG_contract_assert(x == 1, "Some kind of error message"); Note: Contracts are still experimental. The runtime interface may change in future versions. */ %module aggregate %include %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT) %contract move(int x) { require: check_direction(x); } %inline %{ #define UP 1 #define DOWN 2 #define LEFT 3 #define RIGHT 4 int move(int direction) { return direction; } %} swig-3.0.2/Examples/test-suite/director_namespace_clash.i0000664000175000017500000000047012343605122023403 0ustar williamwilliam%module(directors="1") director_namespace_clash %rename(GreatOne) One::Great; %feature("director"); %inline %{ namespace One { struct Great { virtual void superb(int a) {} virtual ~Great() {} }; } namespace Two { struct Great { virtual void excellent() {} virtual ~Great() {} }; } %} swig-3.0.2/Examples/test-suite/cpp11_rvalue_reference3.i0000664000175000017500000000423412343605122023007 0ustar williamwilliam%module cpp11_rvalue_reference3 %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); %inline %{ #include struct Thing {}; Thing && global_rvalue_ref = Thing(); Thing *&& global_rvalue_ref_ptr1 = 0; Thing const*&& global_rvalue_ref_ptr2 = 0; Thing *const&& global_rvalue_ref_ptr3 = 0; Thing const*const &&global_rvalue_ref_ptr4 = 0; Thing && returnit1() { return std::move(global_rvalue_ref); } Thing *&& returnit2() { return std::move(global_rvalue_ref_ptr1); } Thing const*&& returnit3() { return std::move(global_rvalue_ref_ptr2); } Thing *const&& returnit4() { return std::move(global_rvalue_ref_ptr3); } Thing const*const&& returnit5() { return std::move(global_rvalue_ref_ptr4); } void takeit1(Thing && t) {} void takeit2(Thing *&& t) {} void takeit3(Thing const*&& t) {} void takeit4(Thing *const&& t) {} void takeit5(Thing const*const&& t) {} struct Containing { Thing && member_rvalue_ref; Thing *&& member_rvalue_ref_ptr1 = 0; Thing const*&& member_rvalue_ref_ptr2 = 0; Thing *const&& member_rvalue_ref_ptr3 = 0; Thing const*const &&member_rvalue_ref_ptr4 = 0; Containing() : member_rvalue_ref(Thing()) {} }; %} %inline %{ int && int_global_rvalue_ref = 5; int *&& int_global_rvalue_ref_ptr1 = 0; int const*&& int_global_rvalue_ref_ptr2 = 0; int *const&& int_global_rvalue_ref_ptr3 = 0; int const*const &&int_global_rvalue_ref_ptr4 = 0; int && int_returnit1() { return std::move(int_global_rvalue_ref); } int *&& int_returnit2() { return std::move(int_global_rvalue_ref_ptr1); } int const*&& int_returnit3() { return std::move(int_global_rvalue_ref_ptr2); } int *const&& int_returnit4() { return std::move(int_global_rvalue_ref_ptr3); } int const*const&& int_returnit5() { return std::move(int_global_rvalue_ref_ptr4); } void int_takeit1(int && t) {} void int_takeit2(int *&& t) {} void int_takeit3(int const*&& t) {} void int_takeit4(int *const&& t) {} void int_takeit5(int const*const&& t) {} struct IntContaining { int && member_rvalue_ref; int *&& member_rvalue_ref_ptr1 = 0; int const*&& member_rvalue_ref_ptr2 = 0; int *const&& member_rvalue_ref_ptr3 = 0; int const*const &&member_rvalue_ref_ptr4 = 0; IntContaining() : member_rvalue_ref(55) {} }; %} swig-3.0.2/Examples/test-suite/li_cstring.i0000664000175000017500000000331612343605122020541 0ustar williamwilliam%module li_cstring %include "cstring.i" #ifndef SWIG_CSTRING_UNIMPL %cstring_input_binary(char *str_in, int n); %cstring_bounded_output(char *out1, 512); %cstring_chunk_output(char *out2, 64); %cstring_bounded_mutable(char *out3, 512); %cstring_mutable(char *out4, 32); %cstring_output_maxsize(char *out5, int max); %cstring_output_withsize(char *out6, int *size); #ifdef __cplusplus %cstring_output_allocate(char **out7, delete [] *$1); %cstring_output_allocate_size(char **out8, int *size, delete [] *$1); #else %cstring_output_allocate(char **out7, free(*$1)); %cstring_output_allocate_size(char **out8, int *size, free(*$1)); #endif %inline %{ int count(char *str_in, int n, char c) { int r = 0; while (n > 0) { if (*str_in == c) { r++; } str_in++; --n; } return r; } void test1(char *out1) { strcpy(out1,"Hello World"); } void test2(char *out2) { int i; for (i = 0; i < 64; i++) { *out2 = (char) i + 32; out2++; } } void test3(char *out3) { strcat(out3,"-suffix"); } void test4(char *out4) { strcat(out4,"-suffix"); } void test5(char *out5, int max) { int i; for (i = 0; i < max; i++) { out5[i] = 'x'; } out5[max]='\0'; } void test6(char *out6, int *size) { int i; for (i = 0; i < (*size/2); i++) { out6[i] = 'x'; } *size = (*size/2); } void test7(char **out7) { #ifdef __cplusplus *out7 = new char[64]; #else *out7 = malloc(64); #endif (*out7)[0] = 0; strcat(*out7,"Hello world!"); } void test8(char **out8, int *size) { int i; #ifdef __cplusplus *out8 = new char[64]; #else *out8 = malloc(64); #endif for (i = 0; i < 64; i++) { (*out8)[i] = (char) i+32; } *size = 64; } %} #endif swig-3.0.2/Examples/test-suite/null_pointer.i0000664000175000017500000000033112343605122021110 0ustar williamwilliam%module null_pointer %warnfilter(SWIGWARN_PARSE_KEYWORD) func; // 'func' is a Go keyword, renamed as 'Xfunc' %inline { struct A {}; bool func(A* a) { return !a; } A* getnull() { return 0; } } swig-3.0.2/Examples/test-suite/java_prepost.i0000664000175000017500000000630112343605122021076 0ustar williamwilliam%module java_prepost // Test the pre, post attributes for javain typemaps %include "std_vector.i" %define VECTOR_DOUBLE_JAVAIN_POST " int count$javainput = (int)d$javainput.size(); $javainput = new double[count$javainput]; for (int i=0; i &v "long" // could suppress pgcpp instead of using pgcppname, but not recommended %typemap(jstype) std::vector &v "double[]" %typemap(javain, pre=" DoubleVector d$javainput = new DoubleVector();", post=VECTOR_DOUBLE_JAVAIN_POST, pgcppname="d$javainput") std::vector &v "$javaclassname.getCPtr(d$javainput)" %apply std::vector & v { std::vector & v2 } // pre only in javain typemap //%typemap(jtype, nopgcpp=1) std::vector &vpre "long" // could suppress pgcpp instead of using pgcppname, but not recommended %typemap(jstype) std::vector &vpre "double[]" %typemap(javain, pre=" DoubleVector d$javainput = new DoubleVector();\n for (int i=0; i<$javainput.length; ++i) {\n double d = $javainput[i];\n d$javainput.add(d);\n }", pgcppname="d$javainput") std::vector &vpre "$javaclassname.getCPtr(d$javainput)" // post only in javain typemap %typemap(javain, post=" int size = (int)$javainput.size();\n for (int i=0; i &vpost "$javaclassname.getCPtr($javainput)" %inline %{ bool globalfunction(std::vector & v) { v.push_back(0.0); v.push_back(1.1); v.push_back(2.2); return true; } struct PrePostTest { PrePostTest() { } PrePostTest(std::vector & v) { v.push_back(3.3); v.push_back(4.4); } bool method(std::vector & v) { v.push_back(5.5); v.push_back(6.6); return true; } static bool staticmethod(std::vector & v) { v.push_back(7.7); v.push_back(8.8); return true; } }; // Check pre and post only typemaps and that they coexist okay and that the generated code line spacing looks okay bool globalfunction2(std::vector & v, std::vector &v2, std::vector & vpre, std::vector & vpost) { return true; } struct PrePost2 { PrePost2() { } PrePost2(std::vector & v, std::vector &v2, std::vector & vpre, std::vector & vpost) { } bool method(std::vector & v, std::vector &v2, std::vector & vpre, std::vector & vpost) { return true; } static bool staticmethod(std::vector & v, std::vector &v2, std::vector & vpre, std::vector & vpost) { return true; } }; %} %template(DoubleVector) std::vector; // Check pre post constructor helper deals with checked exceptions, InstantiationException is just a random checked exception %typemap(javain, pre=" if ($javainput == null)\n throw new InstantiationException(\"empty value!!\");", throws="InstantiationException") PrePostTest * "$javaclassname.getCPtr($javainput)" %inline %{ struct PrePostThrows { PrePostThrows(PrePostTest *ppt, bool) { } }; %} swig-3.0.2/Examples/test-suite/cpp11_alignment.i0000664000175000017500000000034412343605122021364 0ustar williamwilliam%module cpp11_alignment %inline %{ struct A { int member; }; const int align1 = alignof(A::member); %} %{ // alignas - not yet working struct alignas(16) S { int num; }; alignas(double) unsigned char c[sizeof(double)]; %} swig-3.0.2/Examples/test-suite/li_std_functors.i0000664000175000017500000000110512343605122021577 0ustar williamwilliam%module li_std_functors %include %include %include %include %include %include %template(Vector ) std::vector ; %template(Deque ) std::deque ; %template(List ) std::list ; %template(Set ) std::set >; %template(Map ) std::map >; swig-3.0.2/Examples/test-suite/class_ignore.i0000664000175000017500000000134612343605122021055 0ustar williamwilliam%module class_ignore %ignore Foo; %ignore *::Bar::foo; %ignore Far::away() const; %inline %{ class Foo { public: virtual ~Foo() { } virtual char *blah() = 0; }; namespace hi { namespace hello { class Bar : public Foo { public: void foo(void) {}; virtual char *blah() { return (char *) "Bar::blah"; } }; } } struct Boo { virtual ~Boo() {} virtual void away() const {} }; struct Far : Boo { virtual void away() const {} }; struct Hoo : Far { virtual void away() const {} }; char *do_blah(Foo *f) { return f->blah(); } class ForwardClass; template class ForwardClassT; template class PatchList; %} swig-3.0.2/Examples/test-suite/template_using.i0000664000175000017500000000045012343605122021420 0ustar williamwilliam%module template_using %inline { namespace foo { template class Foo { }; template T maxk(T a, T b) { return a > b ? a : b; } } using foo::maxk; } %template(maxint) foo::maxk; %template(Foofloat) foo::Foo; %template(maxfloat) maxk; swig-3.0.2/Examples/test-suite/enum_thorough_simple.i0000664000175000017500000000030412343605122022632 0ustar williamwilliam%module "enum_thorough_simple" // Test enum wrapping using simple constants (SWIG-1.3.21 and earlier default enum wrapping for C# and Java) %include "enumsimple.swg" %include "enum_thorough.i" swig-3.0.2/Examples/test-suite/features.i0000664000175000017500000001547712343605122020235 0ustar williamwilliam%module features %warnfilter(SWIGWARN_LANG_IDENTIFIER,SWIGWARN_IGNORE_OPERATOR_PLUSEQ); // This testcase checks that %feature is working for templates and non user supplied constructors/destructors and is just generally working // If the default %exception is used it will not compile. It shouldn't get used. %exception "this_will_not_compile"; // Test 1: Test for no user supplied constructors and destructor %exception Simple::Simple(const Simple&) "$action /*Simple::Simple*/"; %exception Simple::Simple() "$action /*Simple::Simple*/"; %exception Simple::~Simple() "$action /*Simple::~Simple*/"; %inline %{ class Simple {}; %} %exception NS::SimpleNS::SimpleNS(const NS::SimpleNS&) "$action /*NS::SimpleNS::SimpleNS*/"; %exception NS::SimpleNS::SimpleNS() "$action /*NS::SimpleNS::SimpleNS*/"; %exception NS::SimpleNS::~SimpleNS() "$action /*NS::SimpleNS::~SimpleNS*/"; // method tests %exception NS::SimpleNS::method() "_failed_ /*NS::Simple::method() const*/"; %exception NS::SimpleNS::method() const "$action /*NS::Simple::method() const*/"; %exception NS::SimpleNS::afunction() "$action /*NS::Simple::afunction()*/"; %inline %{ namespace NS { class SimpleNS { public: void method() const {} void afunction() {} }; } %} // Test 2: Test templated functions %exception foobar "caca"; %exception foobar(int) "$action /*foobar*/"; %inline %{ template void foobar(T t) {} %} %template(FooBarInt) foobar; // Test 3: Test templates with no user supplied constructors and destructor %exception SimpleTemplate::SimpleTemplate(const SimpleTemplate&) "$action /*SimpleTemplate::SimpleTemplate*/"; %exception SimpleTemplate::SimpleTemplate() "$action /*SimpleTemplate::SimpleTemplate*/"; %exception SimpleTemplate::~SimpleTemplate() "$action /*SimpleTemplate::~SimpleTemplate*/"; %inline %{ template class SimpleTemplate { public: }; %} %template(SimpleInt) SimpleTemplate; // Test 4: Test templates with user supplied constructors and destructor %exception Template::Template() "$action /*Template::Template*/"; %exception Template::Template(const Template&) "$action /*Template::Template(const Template&)*/"; %exception Template::~Template() "$action /*Template::~Template*/"; // method tests %exception Template::foo "$action /*Template::foo*/"; %exception Template::get "$action /*Template::get*/"; %exception Template::set(const int &t) "$action /*Template::set(const int &t)*/"; %exception Template::bar(const int &t) "_failed_ /*Template::bar(const int &t) const*/"; %exception Template::bar(const int &t) const "$action /*Template::bar(const int &t) const*/"; %inline %{ template class Template { public: Template(){} Template(const Template&){} ~Template(){} void foo(){} void bar(const int &t) const {} #ifdef SWIG %extend { T& get(int i) const { throw 1; } void set(const T &t) {} } #endif }; %} %template(TemplateInt) Template; // Test 5: wildcards %exception Space::WildCards::WildCards(const Space::WildCards&) "$action /* Space::WildCards::WildCards() */"; %exception Space::WildCards::WildCards() "$action /* Space::WildCards::WildCards() */"; %exception Space::WildCards::~WildCards() "$action /* Space::WildCards::WildCards() */"; %exception *::incy "_failure_ /* *::incy */"; %exception *::incy(int a) "_failure_ /* *::incy(int a) */"; %exception *::incy(int a) const "$action /* *::incy(int a) const */"; %exception *::wincy(int a) "$action /* *::wincy(int a) */"; %exception *::spider "$action /* *::spider */"; %exception *::spider(int a) "_failure_ /* *::spider(int a) */"; %inline %{ namespace Space { struct WildCards { virtual ~WildCards() {} virtual WildCards* incy(int a) const { return 0; } virtual WildCards* wincy(int a) { return 0; } virtual WildCards* spider(int a) const { return 0; } }; } %} // Test 6: default arguments %exception Space::Animals::Animals(const Space::Animals&) "$action /* Space::Animals::Animals(int a = 0, double d = 0.0) */"; %exception Space::Animals::Animals(int a = 0, double d = 0.0) "$action /* Space::Animals::Animals(int a = 0, double d = 0.0) */"; %exception Space::Animals::~Animals() "$action /* Space::Animals::~Animals() */"; %exception Space::Animals::lions(int a = 0, double d = 0.0) const "$action /* Space::Animals::lions(int a = 0, double d = 0.0) const */"; %exception Space::Animals::leopards(int a = 0, double d = 0.0) "$action /* Space::Animals::leopards(int a = 0, double d = 0.0) */"; %exception *::cheetahs(int a = 0, double d = 0.0) const "$action /* *::cheetahs(int a = 0, double d = 0.0) const */"; %exception *::jackal(int a = 0, double d = 0.0) "$action /* *::jackal(int a = 0, double d = 0.0) */"; %inline %{ namespace Space { struct Animals { Animals(int a = 0, double d = 0.0) {} void* lions(int a = 0, double d = 0.0) const { return 0; } void* leopards(int a = 0, double d = 0.0) { return 0; } int cheetahs(int a = 0, double d = 0.0) const { return 0; } int jackal(int a = 0, double d = 0.0) { return 0; } }; } %} // Test 7: inheritance %exception Space::Base::Base(const Space::Base&) "$action /* Space::Base::Base() */"; %exception Space::Base::Base() "$action /* Space::Base::Base() */"; %exception Space::Base::~Base() "$action /* Space::Base::~Base() */"; %exception Space::Derived::Derived(const Space::Derived&) "$action /* Space::Derived::Derived() */"; %exception Space::Derived::Derived() "$action /* Space::Derived::Derived() */"; %exception Space::Derived::~Derived() "$action /* Space::Derived::~Derived() */"; // The following should apply to both Base and Derived %exception Space::Base::virtualmethod(int a) const "$action /* Space::Base::virtualmethod(int a) const */"; %exception Space::Base::operator+=(int) "$action /* Space::Base::Base() */"; %inline %{ namespace Space { struct Base { int operator+=(int) { return 0; } virtual const char** virtualmethod(int a) const { return 0; } virtual ~Base() {} }; struct Derived : Base { virtual const char** virtualmethod(int a) const { return 0; } }; } %} // Test 8 conversion operators %rename(opbool) operator bool; %rename(opuint) operator unsigned int; %exception ConversionOperators::ConversionOperators() "$action /* ConversionOperators::ConversionOperators() */"; %exception ConversionOperators::~ConversionOperators() "$action /* ConversionOperators::~ConversionOperators() */"; %exception ConversionOperators::operator bool "$action /* ConversionOperators::operator bool */"; %exception ConversionOperators::operator unsigned int "$action /* ConversionOperators::unsigned int*/"; %inline %{ class ConversionOperators { public: operator bool() { return false; } operator unsigned int() { return 0; } }; %} swig-3.0.2/Examples/test-suite/sneaky1.i0000664000175000017500000000042512343605122017755 0ustar williamwilliam%module sneaky1 %{ int add(int x, int y) { return x+y; } int subtract(int x, int y) { return x-y; } int mul(int x, int y) { return x*y; } int divide(int x, int y) { return x/y; } %} %inline %{ typedef int binop(int,int); %} binop add,subtract,mul,divide; swig-3.0.2/Examples/test-suite/allprotected_not.i0000664000175000017500000000174112343605122021746 0ustar williamwilliam// Tests directors and allprotected option when the class does not have the "director" feature // Was previously crashing and/or generating uncompilable code. %module(directors="1", allprotected="1") allprotected_not //%feature("director") AllProtectedNot; %feature("director") AllProtectedNot::ProtectedMethod; %feature("director") AllProtectedNot::StaticNonVirtualProtectedMethod; %feature("director") AllProtectedNot::NonVirtualProtectedMethod; %feature("director") AllProtectedNot::ProtectedVariable; %feature("director") AllProtectedNot::StaticProtectedVariable; %feature("director") AllProtectedNot::PublicMethod; %inline %{ class AllProtectedNot { public: virtual ~AllProtectedNot() {} virtual void PublicMethod() {} protected: virtual void ProtectedMethod() {} static void StaticNonVirtualProtectedMethod() {} void NonVirtualProtectedMethod() {} int ProtectedVariable; static int StaticProtectedVariable; }; int AllProtectedNot::StaticProtectedVariable = 0; %} swig-3.0.2/Examples/test-suite/insert_directive.i0000664000175000017500000000135112343605122021743 0ustar williamwilliam%module insert_directive // check %insert and the order of each insert section is correct %begin %{ // %inserted code %begin int inserted_begin(int i) { return i; } %} %runtime %{ // %inserted code %runtime int inserted_runtime(int i) { return inserted_begin(i); } %} %{ // %inserted code %header int inserted_header1(int i) { return inserted_runtime(i); } %} %header %{ // %inserted code %header int inserted_header2(int i) { return inserted_header1(i); } %} %{ // %inserted code %header int inserted_header3(int i) { return inserted_header2(i); } %} %wrapper %{ // %inserted code %wrapper int inserted_wrapper(int i) { return inserted_header3(i); } %} %init %{ // %inserted code %init int inserted_init_value = inserted_wrapper(0); %} swig-3.0.2/Examples/test-suite/java_director_exception_feature.i0000664000175000017500000001522312343605122025011 0ustar williamwilliam%module(directors="1") java_director_exception_feature %include %warnfilter(SWIGWARN_TYPEMAP_DIRECTORTHROWS_UNDEF) MyNS::Foo::directorthrows_warning; %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif #include %} %include // DEFINE exceptions in header section using std::runtime_error %{ #include #include namespace MyNS { struct Exception1 : public std::runtime_error { Exception1(const std::string& what):runtime_error(what) {} }; struct Exception2 : public std::runtime_error { Exception2(const std::string& what):runtime_error(what) {} }; struct Unexpected : public std::runtime_error { Unexpected(const std::string& what):runtime_error(what) {} }; } %} // Add an explicit handler for Foo::ping, mapping one java exception back to an 'int' %feature("director:except") MyNS::Foo::ping { jthrowable $error = jenv->ExceptionOccurred(); if ($error) { jenv->ExceptionClear(); // clear java exception since mapping to c++ exception if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyJavaException1")) { throw 1; } else if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyJavaException2")) { std::string msg(Swig::JavaExceptionMessage(jenv,$error).message()); throw MyNS::Exception2(msg); } else { std::cerr << "Test failed, unexpected exception thrown: " << Swig::JavaExceptionMessage(jenv,$error).message() << std::endl; throw std::runtime_error("unexpected exception in Foo::ping"); } } } // Use default handler on Foo::pong, with directorthrows typemaps // directorthrows typemaps for java->c++ conversions %typemap(directorthrows) MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected %{ if (Swig::ExceptionMatches(jenv, $error, "$packagepath/$javaclassname")) { std::string msg(Swig::JavaExceptionMessage(jenv,$error).message()); throw $1_type(msg); } %} // Override the director:except feature so exception specification is not violated // (Cannot use built-in default of throw DirectorException) %feature("director:except") MyNS::Foo::pong %{ jthrowable $error = jenv->ExceptionOccurred(); if ($error) { jenv->ExceptionClear(); $directorthrowshandlers throw ::MyNS::Unexpected(Swig::JavaExceptionMessage(jenv,$error).message()); } %} // TODO 'throws' typemap emitted by emit_action (emit.cxx) has no way // to get access to language specific special variables like // $javaclassname or $packagepath ("java_director_exception_feature" here) // throws typemaps for c++->java exception conversions %typemap(throws,throws="MyJavaException1") MyNS::Exception1 %{ (void)$1; jclass excpcls = jenv->FindClass("java_director_exception_feature/MyJavaException1"); if (excpcls) { jenv->ThrowNew(excpcls, $1.what()); } return $null; %} %typemap(throws,throws="MyJavaException1") int %{ (void)$1; jclass excpcls = jenv->FindClass("java_director_exception_feature/MyJavaException1"); if (excpcls) { jenv->ThrowNew(excpcls, "Threw some integer"); } return $null; %} %typemap(throws,throws="MyJavaException2") MyNS::Exception2 %{ jclass excpcls = jenv->FindClass("java_director_exception_feature/MyJavaException2"); if (excpcls) { jenv->ThrowNew(excpcls, $1.what()); } return $null; %} %typemap(throws,throws="MyJavaUnexpected") MyNS::Unexpected %{ jclass excpcls = jenv->FindClass("java_director_exception_feature/MyJavaUnexpected"); if (excpcls) { jenv->ThrowNew(excpcls, $1.what()); } return $null; %} // Use generic exception translation approach like python, ruby %feature("director:except") MyNS::Foo::genericpong { jthrowable $error = jenv->ExceptionOccurred(); if ($error) { jenv->ExceptionClear(); throw Swig::DirectorException(jenv,$error); } } // %exception with throws attribute. Need throws attribute for checked exceptions %feature ("except",throws="Exception") MyNS::Foo::genericpong %{ %} %feature ("except",throws="Exception") MyNS::Bar::genericpong %{ try { $action } catch (Swig::DirectorException & direxcp) { direxcp.raiseJavaException(jenv); // jenv always available in JNI code return $null; } %} %feature("director") Foo; // Rename exceptions on java side to make translation of exceptions more clear %rename(MyJavaException1) MyNS::Exception1; %rename(MyJavaException2) MyNS::Exception2; %rename(MyJavaUnexpected) MyNS::Unexpected; %typemap(javabase) ::MyNS::Exception1,::MyNS::Exception2,::MyNS::Unexpected "java.lang.Exception"; %rename(getMessage) what() const; // Rename all what() methods namespace MyNS { struct Exception1 { Exception1(const std::string& what); const char * what() const; }; struct Exception2 { Exception2(const std::string& what); const char * what() const; }; struct Unexpected { Unexpected(const std::string& what); const char * what() const; }; } // In general it is better to use %catches instead of an exception specification on the method // since violating an exception specification calls terminate() preventing catch-all behavior // like throwing std::runtime_error. But an exception specification must be used if the // actual interface being wrapped does use them. %catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Foo::pong; %catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Bar::pong; %inline %{ namespace MyNS { class Foo { public: virtual ~Foo() {} // ping java implementation throws a java Exception1 or an Exception2 if excp is 1 or 2. // pong java implementation throws Exception1,Exception2,Unexpected,NullPointerException for 1,2,3,4 virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0; virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0; virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0; virtual std::string directorthrows_warning(int excp) throw(double) { return std::string(); } }; // Make a bar from a foo, so a call to Java Bar // goes Java Bar -> C++ Bar -> C++ Foo -> Java Foo Director class Bar { public: Bar(Foo* d) { delegate=d; } virtual std::string ping(int excp) throw(int,MyNS::Exception2) { return delegate->ping(excp); } virtual std::string pong(int excp) /* throws MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected */ { return delegate->pong(excp); } virtual std::string genericpong(int excp) { return delegate->genericpong(excp); } private: Foo * delegate; }; } %} swig-3.0.2/Examples/test-suite/namespace_spaces.i0000664000175000017500000000106212343605122021672 0ustar williamwilliam%module namespace_spaces %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */ #endif %} %inline %{ class Foo { public: Foo(); ~Foo(); typedef int Integer; int blah(int x); int spam(int x); Integer bar(Integer x); void (Foo:: *func_ptr) (int); }; inline Foo :: Foo () {} inline Foo :: ~Foo () {} inline int Foo ::blah(int x) { return 2*x; } inline int Foo :: spam(int x) { return -x; } inline Foo :: Integer Foo :: bar(Foo :: Integer x) { return x; } %} swig-3.0.2/Examples/test-suite/global_functions.i0000664000175000017500000000022412343605122021727 0ustar williamwilliam%module global_functions %inline %{ void global_void(void) {} int global_one(int i) { return i; } int global_two(int i, int j) { return i+j; } %} swig-3.0.2/Examples/test-suite/enum_var.i0000664000175000017500000000011212343605122020207 0ustar williamwilliam%module enum_var %inline %{ enum Fruit { APPLE, PEAR }; Fruit test; %} swig-3.0.2/Examples/test-suite/class_scope_weird.i0000664000175000017500000000202612343605122022071 0ustar williamwilliam%module class_scope_weird // Use this version with extra qualifiers to test SWIG as some compilers accept this class Foo { public: Foo::Foo(void) {} Foo::Foo(int) {} int Foo::bar(int x) { return x; } }; // Remove extra qualifiers for the compiler as some compilers won't compile the extra qaulification (eg gcc-4.1 onwards) %{ class Foo { public: Foo(void) {} Foo(int) {} int bar(int x) { return x; } }; %} %inline %{ class Quat; class matrix4; class tacka3; %} // Use this version with extra qualifiers to test SWIG as some compilers accept this class Quat { public: Quat::Quat(void){} Quat::Quat(float in_w, float x, float y, float z){} Quat::Quat(const tacka3& axis, float angle){} Quat::Quat(const matrix4& m){} }; // Remove extra qualifiers for the compiler as some compilers won't compile the extra qaulification (eg gcc-4.1 onwards) %{ class Quat { public: Quat(void){} Quat(float in_w, float x, float y, float z){} Quat(const tacka3& axis, float angle){} Quat(const matrix4& m){} }; %} swig-3.0.2/Examples/test-suite/enum_thorough_typesafe.i0000664000175000017500000000033612343605122023166 0ustar williamwilliam%module "enum_thorough_typesafe" // Test enum wrapping using the typesafe enum pattern in the target language %include "enumtypesafe.swg" #define SWIG_TEST_NOCSCONST // For C# typesafe enums %include "enum_thorough.i" swig-3.0.2/Examples/test-suite/li_std_multimap.i0000664000175000017500000000044512343605122021572 0ustar williamwilliam%module("templatereduce") li_std_multimap %feature("trackobjects"); %include std_pair.i %include std_multimap.i %inline %{ struct A{ int val; A(int v = 0): val(v) { } }; %} namespace std { %template(pairA) pair; %template(multimapA) multimap; } swig-3.0.2/Examples/test-suite/clientdata_prop_b.i0000664000175000017500000000062512343605122022055 0ustar williamwilliam/* This file tests the clientdata propagation at swig wrapper generation. It tests a bug in the TCL module where the clientdata was not propagated correctly to all classes */ %module clientdata_prop_b %{ #include "clientdata_prop_b.h" %} %import "clientdata_prop_a.i" %include "clientdata_prop_b.h" %types(tA *); %newobject new_t2A; %newobject new_t3A; %newobject new_tD; %newobject new_t2D; swig-3.0.2/Examples/test-suite/typemap_self.i0000664000175000017500000000107212343605122021071 0ustar williamwilliam%module typemap_self // This typemap should be ignored for self? %typemap(in) A* (A* ptr) { if (SWIG_ConvertPtr($input, (void**) &ptr, $1_descriptor, 0) != -1) { $1 = ptr; } else { $1 = new A(); } } // Simple but unsecure current fix //%apply SWIGTYPE* {A* self} %inline %{ class A; int foo(A* self) { return 0; } struct A { static int bar(int, A* self) { return 1; } int val; int foo(A* self, A* b) { return 1; } }; struct B { B(A*) { } }; %} swig-3.0.2/Examples/test-suite/struct_rename.i0000664000175000017500000000013512343605122021253 0ustar williamwilliam%module struct_rename %rename(Bar) Foo; %inline %{ typedef struct { int x; } Foo; %} swig-3.0.2/Examples/test-suite/li_std_containers_int.i0000664000175000017500000000027512343605122022762 0ustar williamwilliam%module li_std_containers_int // // Test containers of type int // %include std_vector.i %include std_list.i %template(vector_int) std::vector; %template(list_int) std::list; swig-3.0.2/Examples/test-suite/redefined.i0000664000175000017500000000304212343605122020325 0ustar williamwilliam%module redefined %warnfilter(SWIGWARN_RUBY_WRONG_NAME) agua; /* no redundant warnings */ %warnfilter(SWIGWARN_PARSE_REDUNDANT); #if 1 // // All these repeated declarations are not redefinitions, // and they are valid C++ code, therefore, we skip // swig redefined warnings. // %define uja aju; %enddef %define uja aju; %enddef %constant int agua = 0; %constant int agua = 0; %inline %{ #define REDUNDANT 1 #define REDUNDANT 1 #define MACROREP(x) x #define MACROREP(x) x class Hello; class Hello; typedef int Int; typedef int Int; inline int hello(int); int hello(int) { return 0; } struct B; struct A { typedef int Int; friend int foo(A*, B*); }; struct B { typedef int Int; friend int foo(A*, B*); }; inline int foo(A*, B*) { return 0; } %} #else // // the %extend and %rename directive ALWAYS emit redefined warnings, // since they are not C/C++/CPP standard. // %extend Hello { int hi(int) { return 0; } } %rename(chao) hi(int); // // All these repeated declarations are really redefinitions, // therefore, swig must produce a redefined warning // %constant int agua = 0; %constant int agua = 1; %inline %{ #define REDEFINED 1 #define REDEFINED 2 #define MACROREP(x) x #define MACROREP(x) x*2 typedef int Int; typedef double Int; int hi(int); int chao(int); int hello(int); inline double hello(int) { return 0; } struct Hello { typedef int Int; typedef double Int; friend short hello(int); int hi(int) { return 0; } }; %} #endif swig-3.0.2/Examples/test-suite/namespace_union.i0000664000175000017500000000213612343605122021547 0ustar williamwilliam%module namespace_union #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS %inline %{ namespace SpatialIndex { class Variant { public: Variant() { }; int varType; union { long lVal; // VT_LONG short iVal; // VT_SHORT float fltVal; // VT_FLOAT double dblVal; // VT_DOUBLE char cVal; // VT_CHAR unsigned short uiVal; // VT_USHORT unsigned long ulVal; // VT_ULONG int intVal; // VT_INT unsigned int uintVal; // VT_UINT bool blVal; // VT_BOOL char* pcVal; // VT_PCHAR void* pvVal; // VT_PVOID } val; }; // Variant } %} swig-3.0.2/Examples/test-suite/operbool.i0000664000175000017500000000022712343605122020223 0ustar williamwilliam%module operbool %rename(operator_bool) operator bool(); %inline %{ class Test { public: operator bool() { return false; } }; %} swig-3.0.2/Examples/test-suite/li_std_auto_ptr.i0000664000175000017500000000212012343605122021567 0ustar williamwilliam%module li_std_auto_ptr %{ #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // auto_ptr deprecation #endif %} #if defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGPYTHON) %include "std_auto_ptr.i" %auto_ptr(Klass) %inline %{ #include #include #include "swig_examples_lock.h" class Klass { public: explicit Klass(const char* label) : m_label(label) { SwigExamples::Lock lock(critical_section); total_count++; } const char* getLabel() const { return m_label.c_str(); } ~Klass() { SwigExamples::Lock lock(critical_section); total_count--; } static int getTotal_count() { return total_count; } private: static SwigExamples::CriticalSection critical_section; static int total_count; std::string m_label; }; SwigExamples::CriticalSection Klass::critical_section; int Klass::total_count = 0; %} %template(KlassAutoPtr) std::auto_ptr; %inline %{ std::auto_ptr makeKlassAutoPtr(const char* label) { return std::auto_ptr(new Klass(label)); } %} #endif swig-3.0.2/Examples/test-suite/compactdefaultargs.i0000664000175000017500000000160312343605122022251 0ustar williamwilliam%module compactdefaultargs // compactdefaultargs off by default // The following should compile with compactdefaultargs off %inline %{ class Defaults1 { static const int PRIVATE_DEFAULT = -1; public: static const double PUBLIC_DEFAULT; Defaults1(int a = PRIVATE_DEFAULT) {} double ret(double d = PUBLIC_DEFAULT) { return d; } }; %} %{ const double Defaults1::PUBLIC_DEFAULT = -1.0; %} // compactdefaultargs now on by default %feature("compactdefaultargs"); // Turn compactdefaultargs off for the constructor which can't work with this feature %feature("compactdefaultargs", "0") Defaults2(int a = PRIVATE_DEFAULT); %inline %{ class Defaults2 { static const int PRIVATE_DEFAULT = -1; public: static const double PUBLIC_DEFAULT; Defaults2(int a = PRIVATE_DEFAULT) {} double ret(double d = PUBLIC_DEFAULT) { return d; } }; %} %{ const double Defaults2::PUBLIC_DEFAULT = -1.0; %} swig-3.0.2/Examples/test-suite/memberin_extend.i0000664000175000017500000000122512343605122021546 0ustar williamwilliam%module memberin_extend // Tests memberin typemap is not used for %extend. // The test extends the struct with a pseudo member variable %inline %{ #include struct ExtendMe { }; %} %{ #include std::map ExtendMeStringMap; void ExtendMe_thing_set(ExtendMe *self, const char *val) { char *old_val = ExtendMeStringMap[self]; delete [] old_val; if (val) { ExtendMeStringMap[self] = new char[strlen(val)+1]; strcpy(ExtendMeStringMap[self], val); } else { ExtendMeStringMap[self] = 0; } } char * ExtendMe_thing_get(ExtendMe *self) { return ExtendMeStringMap[self]; } %} %extend ExtendMe { char *thing; } swig-3.0.2/Examples/test-suite/cpp11_result_of.i0000664000175000017500000000312612343605122021411 0ustar williamwilliam/* This testcase checks whether SWIG correctly uses the new result_of class and its templating capabilities introduced in C++11. */ %module cpp11_result_of %inline %{ #include typedef double(*fn_ptr)(double); %} namespace std { // Forward declaration of result_of template struct result_of; // Add in the required partial specialization of result_of template<> struct result_of< fn_ptr(double) > { typedef double type; }; } %template() std::result_of< fn_ptr(double) >; %inline %{ double square(double x) { return (x * x); } template typename std::result_of::type test_result_impl(Fun fun, Arg arg) { return fun(arg); } std::result_of< fn_ptr(double) >::type test_result_alternative1(double(*fun)(double), double arg) { return fun(arg); } %} %{ // Another alternative approach using decltype (not very SWIG friendly) std::result_of< decltype(square)&(double) >::type test_result_alternative2(double(*fun)(double), double arg) { return fun(arg); } %} %inline %{ #include void cpp_testing() { std::cout << "result: " << test_result_impl(square, 3) << std::endl; std::cout << "result: " << test_result_impl(square, 4) << std::endl; std::cout << "result: " << test_result_impl< fn_ptr, double >(square, 5) << std::endl; std::cout << "result: " << test_result_alternative1(square, 6) << std::endl; std::cout << "result: " << test_result_alternative2(square, 7) << std::endl; } %} %template(test_result) test_result_impl< fn_ptr, double>; %constant double (*SQUARE)(double) = square; swig-3.0.2/Examples/test-suite/typedef_sizet.i0000664000175000017500000000015412343605122021257 0ustar williamwilliam%module typedef_sizet typedef unsigned long long size_t; %inline %{ size_t size(size_t x) {return x; } %} swig-3.0.2/Examples/test-suite/li_std_vector_enum.i0000664000175000017500000000062412343605122022267 0ustar williamwilliam%module li_std_vector_enum %include "std_vector.i" %inline %{ class EnumVector { public: EnumVector() { fill_numbers(); } enum numbers {ten=10, twenty=20, thirty=30}; std::vector nums; void fill_numbers() { nums.push_back(ten); nums.push_back(twenty); nums.push_back(thirty); } }; %} %template(vector_numbers) std::vector; swig-3.0.2/Examples/test-suite/template_typedef_cplx5.i0000664000175000017500000000055712343605122023056 0ustar williamwilliam%module template_typedef_cplx5 %{ #include %} %inline %{ // This typedef triggers an inifinite recursion // in the next test1() nd test2() function declarations typedef std::complex complex; struct A { complex test1() { complex r; return r; } std::complex test2() { std::complex r; return r; } }; %} swig-3.0.2/Examples/test-suite/cpp11_template_double_brackets.i0000664000175000017500000000212312343605122024426 0ustar williamwilliam/* This interface checks whether SWIG supports the new double angled brackets in the template syntax without having a space inbetween. This feature was introduced in new C++11 standard. */ %module cpp11_template_double_brackets %inline %{ #include std::map> map1; std::map< int,std::map > map2; std::map>> map3; std::map>>> map4; %} // Check streaming operators are still okay %rename(ExtractionOperator) operator>>; %rename(InsertionOperator) operator<<; %inline %{ class ABC { public: int a; int operator>>(ABC &) { return 0; } int operator<<(ABC &) { return 0; } }; class DEF { public: int a; int operator<<(DEF &) { return 0; } int operator>>(DEF &) { return 0; } }; template class ABC2 { public: int a; template U operator>>(ABC &); template U operator<<(ABC &); }; %} // Test shifts are still working %inline %{ int shift_init1 = 4 << 2 >> 1; int shift_init2 = 4 >> 2 << 1 << 1 >> 2; %} swig-3.0.2/Examples/test-suite/typedef_class.i0000664000175000017500000000063612343605122021233 0ustar williamwilliam%module typedef_class %inline %{ class RealA { public: int a; }; class B { public: typedef RealA A2; int testA (const A2& a) {return a.a;} }; namespace Space { typedef class AAA { public: AAA() {} } BBB; } typedef class AA { public: AA() {} AA(int x) {} int aa_var; int *aa_method(double d) { return 0; } static int *aa_static_method(bool b) { return 0; } } BB; %} swig-3.0.2/Examples/test-suite/java_throws.i0000664000175000017500000001174112343605122020734 0ustar williamwilliam// Test to check the exception classes in the throws attribute of the typemaps and except feature is working %module java_throws // Exceptions are chosen at random but are ones which have to have a try catch block to compile %typemap(in, throws=" ClassNotFoundException") int num { $1 = (int)$input; } %typemap(freearg, throws="InstantiationException ") int num "/*not written*/" %typemap(argout, throws="CloneNotSupportedException ") int num "/*not written*/" %typemap(check, throws="NoSuchFieldException") int num { if ($input == 10) { jenv->ExceptionClear(); jclass excep = jenv->FindClass("java/lang/NoSuchFieldException"); if (excep) jenv->ThrowNew(excep, "Value of 10 not acceptable"); return $null; } } // Duplicate exceptions should be removed from the generated throws clause %typemap(out, throws="IllegalAccessException, NoSuchFieldException, CloneNotSupportedException ") short { $result = (jshort)$1; } %inline %{ short full_of_exceptions(int num) { return 0; } %} %typemap(throws, throws="IllegalAccessException") int { (void)$1; jclass excep = jenv->FindClass("java/lang/IllegalAccessException"); if (excep) { jenv->ThrowNew(excep, "Test exception"); } return $null; } %inline %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif bool throw_spec_function(int value) throw (int) { throw (int)0; } #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %catches(int) catches_function(int value); %inline %{ bool catches_function(int value) { throw (int)0; } %} // Check newfree typemap throws attribute %newobject makeTestClass; %typemap(newfree, throws="NoSuchMethodException") TestClass* "/*not written*/" %inline %{ class TestClass { int x; public: TestClass(int xx) : x(xx) {} }; TestClass* makeTestClass() { return new TestClass(1000); } %} // javain typemap throws attribute // Will only compile if the fileFunction has a java.io.IOException throws clause as getCanonicalPath() throws this exception %typemap(jstype) char* someFileArgument "java.io.File" %typemap(javain, throws="java.io.IOException") char* someFileArgument "$javainput.getCanonicalPath()" %inline %{ void fileFunction(char* someFileArgument) {} %} // javout typemap throws attribute %typemap(javaout, throws="java.io.IOException") int { int returnValue=$jnicall; if (returnValue==0) throw new java.io.IOException("some IOException"); return returnValue; } %inline %{ int ioTest() { return 0; } %} // except feature (%javaexception) specifying a checked exception class for the throws clause %typemap(javabase) MyException "Throwable"; %typemap(javacode) MyException %{ public static final long serialVersionUID = 0x52151000; // Suppress ecj warning %} %inline %{ struct MyException { MyException(const char *msg) {} }; %} %define JAVAEXCEPTION(METHOD) %javaexception("MyException") METHOD %{ try { $action } catch (MyException) { jclass excep = jenv->FindClass("java_throws/MyException"); if (excep) jenv->ThrowNew(excep, "exception message"); return $null; } %} %enddef JAVAEXCEPTION(FeatureTest::FeatureTest) JAVAEXCEPTION(FeatureTest::method) JAVAEXCEPTION(FeatureTest::staticMethod) %inline %{ struct FeatureTest { static void staticMethod() { throw MyException("no message"); } void method() { throw MyException("no message"); } }; %} // Mixing except feature and typemaps when both generate a class for the throws clause %typemap(in, throws="ClassNotFoundException") int both { $1 = (int)$input; } %javaexception("MyException , NoSuchFieldException") globalFunction %{ try { $action } catch (MyException) { jclass excep = jenv->FindClass("java_throws/MyException"); if (excep) jenv->ThrowNew(excep, "exception message"); return $null; } %} %inline %{ void globalFunction(int both) { throw MyException("no message"); } %} // Test %nojavaexception %javaexception("MyException") %{ /* global exception handler */ try { $action } catch (MyException) { jclass excep = jenv->FindClass("java_throws/MyException"); if (excep) jenv->ThrowNew(excep, "exception message"); return $null; } %} %nojavaexception *::noExceptionPlease(); %nojavaexception NoExceptTest::NoExceptTest(); // Need to handle the checked exception in NoExceptTest.delete() %typemap(javafinalize) SWIGTYPE %{ protected void finalize() { try { delete(); } catch (MyException e) { throw new RuntimeException(e); } } %} %inline %{ struct NoExceptTest { unsigned int noExceptionPlease() { return 123; } unsigned int exceptionPlease() { return 456; } ~NoExceptTest() {} }; %} // Turn global exceptions off (for the implicit destructors/constructors) %nojavaexception; swig-3.0.2/Examples/test-suite/empty.i0000664000175000017500000000001612343605122017534 0ustar williamwilliam%module empty swig-3.0.2/Examples/test-suite/template_default_vw.i0000664000175000017500000000050112343605122022430 0ustar williamwilliam%module template_default_vw %inline %{ class SomeClass{ }; template class Handle { public: Handle( T* t=0 ) { }; // ... }; typedef Handle hSomeClass; class AnotherClass { public: void someFunc( hSomeClass a = hSomeClass() ) { }; }; %} %template() Handle; swig-3.0.2/Examples/test-suite/li_std_string.i0000664000175000017500000000606612343605122021255 0ustar williamwilliam%module li_std_string %include #if defined(SWIGUTL) %apply std::string& INPUT { std::string &input } %apply std::string& INOUT { std::string &inout } #endif %inline %{ std::string test_value(std::string x) { return x; } const std::string& test_const_reference(const std::string &x) { return x; } void test_pointer(std::string *x) { } std::string *test_pointer_out() { static std::string x = "x"; return &x; } void test_const_pointer(const std::string *x) { } const std::string *test_const_pointer_out() { static std::string x = "x"; return &x; } void test_reference(std::string &x) { } std::string& test_reference_out() { static std::string x = "test_reference_out message"; return x; } std::string test_reference_input(std::string &input) { return input; } void test_reference_inout(std::string &inout) { inout += inout; } #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif void test_throw() throw(std::string){ static std::string x = "test_throw message"; throw x; } void test_const_reference_throw() throw(const std::string &){ static std::string x = "test_const_reference_throw message"; throw x; } void test_pointer_throw() throw(std::string *) { throw new std::string("foo"); } void test_const_pointer_throw() throw(const std::string *) { throw new std::string("foo"); } #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} /* Old way, now std::string is a %naturalvar by default %apply const std::string& { std::string *GlobalString2, std::string *MemberString2, std::string *Structure::StaticMemberString2 }; */ %inline %{ std::string GlobalString; std::string GlobalString2 = "global string 2"; const std::string ConstGlobalString = "const global string"; struct Structure { std::string MemberString; std::string MemberString2; static std::string StaticMemberString; static std::string StaticMemberString2; const std::string ConstMemberString; static const std::string ConstStaticMemberString; Structure() : MemberString2("member string 2"), ConstMemberString("const member string") {} }; %} %{ std::string Structure::StaticMemberString = "static member string"; std::string Structure::StaticMemberString2 = "static member string 2"; const std::string Structure::ConstStaticMemberString = "const static member string"; %} %inline %{ class Foo { public: unsigned long long test(unsigned long long l) { return l + 1; } std::string test(std::string l) { return l + "1"; } unsigned long long testl(unsigned long long l) { return l + 1; } }; %} %inline %{ std::string stdstring_empty() { return std::string(); } char *c_empty() { return (char *)""; } char *c_null() { return 0; } const char *get_null(const char *a) { return a == 0 ? a : "non-null"; } %} swig-3.0.2/Examples/test-suite/clientdata_prop_b.h0000664000175000017500000000106412343605122022052 0ustar williamwilliam#include "clientdata_prop_a.h" typedef tA t2A; typedef A t3A; class B : public A { public: void fB() {} }; class C : public tA { public: void fC() {} }; class D : public t2A { public: void fD() {} }; typedef D tD; typedef tD t2D; void test_t2A(t2A *a) {} void test_t3A(t3A *a) {} void test_B(B *b) {} void test_C(C *c) {} void test_D(D *d) {} void test_tD(tD *d) {} void test_t2D(t2D *d) {} t2A *new_t2A() { return new t2A(); } t3A *new_t3A() { return new t3A(); } tD * new_tD () { return new tD (); } t2D *new_t2D() { return new t2D(); } swig-3.0.2/Examples/test-suite/li_std_stack.i0000664000175000017500000000015412343605122021044 0ustar williamwilliam// test of std::stack %module li_std_stack %include std_stack.i %template( IntStack ) std::stack< int >; swig-3.0.2/Examples/test-suite/namespace_template.i0000664000175000017500000000327212343605122022234 0ustar williamwilliam/* Tests the use of %template with namespaces */ %module namespace_template %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) test2::vector; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) test3::vector; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ %{ #ifdef max #undef max #endif %} %{ namespace test { template T max(T a, T b) { return (a > b) ? a : b; } template class vector { public: vector() { } ~vector() { } char * blah(T x) { return (char *) "vector::blah"; } }; } namespace test2 { using namespace test; } namespace test3 { using test::max; using test::vector; } using namespace test2; namespace T4 = test; %} namespace test { template T max(T a, T b) { return (a > b) ? a : b; } template class vector { public: vector() { } ~vector() { } char * blah(T x) { return (char *) "vector::blah"; } }; } using namespace test; %template(maxint) max; %template(vectorint) vector; namespace test2 { using namespace test; %template(maxshort) max; %template(vectorshort) vector; } namespace test3 { using test::max; using test::vector; %template(maxlong) max; %template(vectorlong) vector; } %inline %{ namespace test4 { using namespace test; typedef int Integer; } %} namespace test4 { %template(maxInteger) max; %template(vectorInteger) vector; } swig-3.0.2/Examples/test-suite/typedef_struct.i0000664000175000017500000000130112343605122021440 0ustar williamwilliam%module typedef_struct %inline %{ typedef struct { int numpoints; } LineObj; typedef LineObj MultipointObj; typedef struct { #ifdef SWIG %immutable; #endif char *filename; int numfonts; #ifdef SWIG %mutable; #endif int* fonts; #ifndef SWIG void* map; #endif } FontSetObj; #define MS_NOOVERRIDE -1111 %} %inline %{ typedef struct { int a; int b; } A_t, *B_t; A_t* make_a() { return (A_t*)malloc(sizeof(A_t)); } B_t make_b() { return make_a(); } %} %inline %{ #ifdef __cplusplus extern "C" { #endif typedef struct _Foo { enum { NONAME1, NONAME2 } enumvar; int foovar; void (*fptr)(int); } Foo; #ifdef __cplusplus } #endif %} swig-3.0.2/Examples/test-suite/director_extend.i0000664000175000017500000000227712343605122021573 0ustar williamwilliam %module(directors="1") director_extend %extend SpObject { virtual int dummy() // Had to remove virtual to work { return $self->getFooBar(); } }; %inline %{ #ifndef SWIG_DIRECTORS // dummy definition for non-director languages namespace Swig { typedef int Director; } #endif %} // Some director implementations do not have Swig::director #if !defined(SWIGGO) %extend SpObject { size_t ExceptionMethod() { // Check positioning of director code in wrapper file // Below is what we really want to test, but director exceptions vary too much across across all languages // throw Swig::DirectorException("DirectorException was not in scope!!"); // Instead check definition of Director class as that is defined in the same place as DirectorException (director.swg) size_t size = sizeof(Swig::Director); return size; } } #endif %inline %{ class SpObject { public: SpObject() {} virtual ~SpObject() {} int getFooBar() const { return 666; } private: // Do NOT define the assignment operator SpObject& operator=(const SpObject& rhs); // This class can not be copied. Do NOT define the copy Constructor. SpObject (const SpObject& rhs); }; %} swig-3.0.2/Examples/test-suite/implicittest.i0000664000175000017500000000366112343605122021121 0ustar williamwilliam%module(naturalvar="1") implicittest %implicitconv; %inline { struct B { }; } %inline { struct A { int ii; A(int i) { ii = 1; } A(double d) { ii = 2; } A(const B& b) { ii = 3; } explicit A(char *s) { ii = 4; } int get() const { return ii; } }; int get(const A& a) { return a.ii; } template struct A_T { int ii; A_T(int i) { ii = 1; } A_T(double d) { ii = 2; } A_T(const B& b) { ii = 3; } explicit A_T(char *s) { ii = 4; } int get() const { return ii; } static int sget(const A_T& a) { return a.ii; } }; } %inline { struct Foo { int ii; Foo(){ ii = 0;} Foo(int){ ii = 1;} Foo(double){ ii = 2;} explicit Foo(char *s){ii = 3;} Foo(const Foo& f){ ii = f.ii;} }; struct Bar { int ii; Foo f; Bar() {ii = -1;} Bar(const Foo& ff){ ii = ff.ii;} }; int get_b(const Bar&b) { return b.ii; } Foo foo; } %template(A_int) A_T; /****************** None handling *********************/ %inline { struct BB {}; struct AA { int ii; AA(int i) { ii = 1; } AA(double d) { ii = 2; } AA(const B* b) { ii = 3; } explicit AA(char *s) { ii = 4; } AA(const BB& b) { ii = 5; } int get() const { return ii; } }; int get_AA_val(AA a) { return a.ii; } int get_AA_ref(const AA& a) { return a.ii; } } /****************** Overloading priority *********************/ %inline %{ class BBB { public: BBB(const B &) {} }; class CCC { public: CCC(const BBB &) : checkvalue(0) {} int xx(int i) { return 11; } int xx(const A& i) { return 22; } int yy(int i, int j) { return 111; } int yy(const A& i, const A& j) { return 222; } int checkvalue; }; %} // CCC(const BBB &) was being called instead of this constructor (independent of being added via %extend) %extend CCC { CCC(const B& b) { CCC* ccc = new CCC(b); ccc->checkvalue = 10; return ccc; } }; swig-3.0.2/Examples/test-suite/memberin_extend_c.i0000664000175000017500000000116612343605122022054 0ustar williamwilliam%module memberin_extend_c /* Example from the Manual, section 5.5.6: "Adding member functions to C structures" */ %{ typedef struct { char name[50]; } Person; %} typedef struct { %extend { char name[50]; } } Person; %{ #include #include void make_upper(char *name) { char *c; for (c = name; *c; ++c) *c = (char)toupper((int)*c); } /* Specific implementation of set/get functions forcing capitalization */ char *Person_name_get(Person *p) { make_upper(p->name); return p->name; } void Person_name_set(Person *p, char *val) { strncpy(p->name,val,50); make_upper(p->name); } %} swig-3.0.2/Examples/test-suite/common.mk0000664000175000017500000004435612343605122020064 0ustar williamwilliam####################################################################### # SWIG test suite makefile. # The test suite comprises many different test cases, which have # typically produced bugs in the past. The aim is to have the test # cases compiling for every language modules. Some testcase have # a runtime test which is written in each of the module's language. # # This makefile runs SWIG on the testcases, compiles the c/c++ code # then builds the object code for use by the language. # To complete a test in a language follow these guidelines: # 1) Add testcases to CPP_TEST_CASES (c++) or C_TEST_CASES (c) or # MULTI_CPP_TEST_CASES (multi-module c++ tests) # 2) If not already done, create a makefile which: # a) Defines LANGUAGE matching a language rule in Examples/Makefile, # for example LANGUAGE = java # b) Define rules for %.ctest, %.cpptest, %.multicpptest and %.clean. # c) Define srcdir, top_srcdir and top_builddir (these are the # equivalent to configure's variables of the same name). # 3) One off special commandline options for a testcase can be added. # See custom tests below. # # The 'check' target runs the testcases including SWIG invocation, # C/C++ compilation, target language compilation (if any) and runtime # test (if there is an associated 'runme' test). # The 'partialcheck' target only invokes SWIG. # The 'all' target is the same as the 'check' target but also includes # known broken testcases. # The 'clean' target cleans up. # # Note that the RUNTOOL, COMPILETOOL and SWIGTOOL variables can be used # for invoking tools for the runtime tests and target language # compiler (eg javac), and on SWIG respectively. For example, valgrind # can be used for memory checking of the runtime tests using: # make RUNTOOL="valgrind --leak-check=full" # and valgrind can be used when invoking SWIG using: # make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes" # Note: trace-children needed because of preinst-swig shell wrapper # to the swig executable. # # An individual test run can be debugged easily: # make director_string.cpptest RUNTOOL="gdb --args" # # The variables below can be overridden after including this makefile ####################################################################### ####################################################################### # Variables ####################################################################### ifneq (,$(USE_VALGRIND)) VALGRIND_OPT = --leak-check=full RUNTOOL = valgrind $(VALGRIND_OPT) else RUNTOOL = endif COMPILETOOL= SWIGTOOL = SWIG = $(SWIGTOOL) $(top_builddir)/preinst-swig SWIG_LIB = $(top_srcdir)/Lib TEST_SUITE = test-suite EXAMPLES = Examples CXXSRCS = CSRCS = TARGETPREFIX = TARGETSUFFIX = SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib ACTION = check INTERFACEDIR = ../ SRCDIR = $(srcdir)/ SCRIPTDIR = $(srcdir) # Regenerate Makefile if Makefile.in or config.status have changed. Makefile: $(srcdir)/Makefile.in ../../../config.status cd ../../../ && $(SHELL) ./config.status $(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE)/Makefile # # Please keep test cases in alphabetical order. # Note that any whitespace after the last entry in each list will break make # # Broken C++ test cases. (Can be run individually using: make testcase.cpptest) CPP_TEST_BROKEN += \ constants \ cpp_broken \ exception_partial_info \ extend_variable \ li_std_vector_ptr \ li_boost_shared_ptr_template \ nested_private \ overload_complicated \ rename_camel \ template_default_pointer \ template_private_assignment \ template_expr \ $(CPP11_TEST_BROKEN) # Broken C test cases. (Can be run individually using: make testcase.ctest) C_TEST_BROKEN += \ tag_no_clash_with_variable # C++ test cases. (Can be run individually using: make testcase.cpptest) CPP_TEST_CASES += \ abstract_access \ abstract_inherit \ abstract_inherit_ok \ abstract_signature \ abstract_typedef \ abstract_typedef2 \ abstract_virtual \ access_change \ add_link \ aggregate \ allowexcept \ allprotected \ allprotected_not \ anonymous_bitfield \ apply_signed_char \ apply_strings \ argout \ array_member \ array_typedef_memberin \ arrayref \ arrays_dimensionless \ arrays_global \ arrays_global_twodim \ arrays_scope \ autodoc \ bloody_hell \ bools \ catches \ cast_operator \ casts \ char_binary \ char_strings \ class_forward \ class_ignore \ class_scope_weird \ compactdefaultargs \ const_const_2 \ constant_pointers \ constover \ constructor_copy \ constructor_exception \ constructor_explicit \ constructor_ignore \ constructor_rename \ constructor_value \ contract \ conversion \ conversion_namespace \ conversion_ns_template \ cplusplus_throw \ cpp_basic \ cpp_enum \ cpp_namespace \ cpp_nodefault \ cpp_static \ cpp_typedef \ curiously_recurring_template_pattern \ default_args \ default_arg_values \ default_constructor \ defvalue_constructor \ derived_byvalue \ derived_nested \ destructor_reprotected \ director_abstract \ director_alternating \ director_basic \ director_binary_string \ director_classes \ director_classic \ director_constructor \ director_default \ director_detect \ director_enum \ director_exception \ director_extend \ director_finalizer \ director_frob \ director_ignore \ director_keywords \ director_namespace_clash \ director_nspace \ director_nspace_director_name_collision \ director_nested \ director_overload \ director_overload2 \ director_primitives \ director_protected \ director_protected_overloaded \ director_redefined \ director_smartptr \ director_thread \ director_unroll \ director_using \ director_wombat \ disown \ dynamic_cast \ empty \ enum_ignore \ enum_plus \ enum_rename \ enum_scope_template \ enum_template \ enum_thorough \ enum_var \ equality \ evil_diamond \ evil_diamond_ns \ evil_diamond_prop \ exception_order \ extend \ extend_constructor_destructor \ extend_default \ extend_placement \ extend_special_variables \ extend_template \ extend_template_ns \ extend_typedef_class \ extern_c \ extern_namespace \ extern_throws \ expressions \ features \ fragments \ friends \ funcptr_cpp \ fvirtual \ global_namespace \ global_ns_arg \ global_scope_types \ global_vars \ grouping \ ignore_parameter \ import_nomodule \ inherit \ inherit_missing \ inherit_same_name \ inherit_target_language \ inherit_void_arg \ inline_initializer \ insert_directive \ keyword_rename \ kind \ langobj \ li_attribute \ li_attribute_template \ li_boost_shared_ptr \ li_boost_shared_ptr_bits \ li_boost_shared_ptr_template \ li_boost_shared_ptr_attribute \ li_carrays \ li_cdata \ li_cpointer \ li_std_auto_ptr \ li_stdint \ li_swigtype_inout \ li_typemaps \ li_typemaps_apply \ li_windows \ long_long_apply \ memberin_extend \ member_funcptr_galore \ member_pointer \ member_template \ minherit \ minherit2 \ mixed_types \ multiple_inheritance \ name_cxx \ name_warnings \ namespace_class \ namespace_enum \ namespace_extend \ namespace_forward_declaration \ namespace_nested \ namespace_spaces \ namespace_template \ namespace_typedef_class \ namespace_typemap \ namespace_union \ namespace_virtual_method \ nspace \ nspace_extend \ naturalvar \ naturalvar_more \ naturalvar_onoff \ nested_class \ nested_directors \ nested_comment \ nested_scope \ nested_workaround \ newobject1 \ null_pointer \ operator_overload \ operator_overload_break \ operator_pointer_ref \ operbool \ ordering \ overload_bool \ overload_copy \ overload_extend \ overload_method \ overload_numeric \ overload_rename \ overload_return_type \ overload_simple \ overload_subtype \ overload_template \ overload_template_fast \ pointer_reference \ preproc_constants \ primitive_ref \ private_assign \ protected_rename \ pure_virtual \ redefined \ redefined_not \ refcount \ reference_global_vars \ register_par \ rename1 \ rename2 \ rename3 \ rename4 \ rename_scope \ rename_simple \ rename_strip_encoder \ rename_pcre_encoder \ rename_pcre_enum \ rename_predicates \ restrict_cplusplus \ return_const_value \ return_value_scope \ rname \ samename \ sizet \ smart_pointer_const \ smart_pointer_const2 \ smart_pointer_const_overload \ smart_pointer_extend \ smart_pointer_member \ smart_pointer_multi \ smart_pointer_multi_typedef \ smart_pointer_namespace \ smart_pointer_namespace2 \ smart_pointer_not \ smart_pointer_overload \ smart_pointer_protected \ smart_pointer_rename \ smart_pointer_simple \ smart_pointer_static \ smart_pointer_template_const_overload \ smart_pointer_template_defaults_overload \ smart_pointer_templatemethods \ smart_pointer_templatevariables \ smart_pointer_typedef \ special_variables \ special_variable_macros \ static_array_member \ static_const_member \ static_const_member_2 \ struct_initialization_cpp \ struct_value \ symbol_clash \ template_arg_replace \ template_arg_scope \ template_arg_typename \ template_array_numeric \ template_basic \ template_base_template \ template_classes \ template_const_ref \ template_construct \ template_default \ template_default2 \ template_default_arg \ template_default_arg_virtual_destructor \ template_default_class_parms \ template_default_class_parms_typedef \ template_default_inherit \ template_default_qualify \ template_default_vw \ template_enum \ template_enum_ns_inherit \ template_enum_typedef \ template_explicit \ template_extend1 \ template_extend2 \ template_extend_overload \ template_extend_overload_2 \ template_forward \ template_inherit \ template_inherit_abstract \ template_int_const \ template_methods \ template_namespace_forward_declaration \ template_using_directive_and_declaration_forward \ template_nested \ template_nested_typemaps \ template_ns \ template_ns2 \ template_ns3 \ template_ns4 \ template_ns_enum \ template_ns_enum2 \ template_ns_inherit \ template_ns_scope \ template_partial_arg \ template_partial_specialization \ template_partial_specialization_typedef \ template_qualifier \ template_ref_type \ template_rename \ template_retvalue \ template_specialization \ template_specialization_defarg \ template_specialization_enum \ template_static \ template_tbase_template \ template_template_parameters \ template_typedef \ template_typedef_class_template \ template_typedef_cplx \ template_typedef_cplx2 \ template_typedef_cplx3 \ template_typedef_cplx4 \ template_typedef_cplx5 \ template_typedef_funcptr \ template_typedef_inherit \ template_typedef_ns \ template_typedef_ptr \ template_typedef_rec \ template_typedef_typedef \ template_typemaps \ template_typemaps_typedef \ template_typemaps_typedef2 \ template_using \ template_virtual \ template_whitespace \ threads \ threads_exception \ throw_exception \ typedef_array_member \ typedef_class \ typedef_funcptr \ typedef_inherit \ typedef_mptr \ typedef_reference \ typedef_scope \ typedef_sizet \ typedef_struct \ typedef_typedef \ typemap_arrays \ typemap_array_qualifiers \ typemap_delete \ typemap_directorout \ typemap_global_scope \ typemap_manyargs \ typemap_namespace \ typemap_ns_using \ typemap_numinputs \ typemap_template \ typemap_template_parm_typedef \ typemap_out_optimal \ typemap_qualifier_strip \ typemap_variables \ typemap_various \ typename \ types_directive \ unicode_strings \ union_scope \ using1 \ using2 \ using_composition \ using_directive_and_declaration \ using_directive_and_declaration_forward \ using_extend \ using_inherit \ using_namespace \ using_namespace_loop \ using_pointers \ using_private \ using_protected \ valuewrapper \ valuewrapper_base \ valuewrapper_const \ valuewrapper_opaque \ varargs \ varargs_overload \ virtual_destructor \ virtual_poly \ virtual_vs_nonvirtual_base \ voidtest \ wallkw \ wrapmacro # C++11 test cases. CPP11_TEST_CASES = \ cpp11_alignment \ cpp11_alternate_function_syntax \ cpp11_constexpr \ cpp11_decltype \ cpp11_default_delete \ cpp11_delegating_constructors \ cpp11_explicit_conversion_operators \ cpp11_final_override \ cpp11_function_objects \ cpp11_inheriting_constructors \ cpp11_initializer_list \ cpp11_initializer_list_extend \ cpp11_lambda_functions \ cpp11_noexcept \ cpp11_null_pointer_constant \ cpp11_raw_string_literals \ cpp11_result_of \ cpp11_rvalue_reference \ cpp11_rvalue_reference2 \ cpp11_rvalue_reference3 \ cpp11_sizeof_object \ cpp11_static_assert \ cpp11_thread_local \ cpp11_template_double_brackets \ cpp11_template_explicit \ cpp11_template_typedefs \ cpp11_type_traits \ cpp11_uniform_initialization \ cpp11_unrestricted_unions \ cpp11_userdefined_literals \ # Broken C++11 test cases. CPP11_TEST_BROKEN = \ # cpp11_hash_tables \ # not fully implemented yet # cpp11_strongly_typed_enumerations \ # SWIG not quite getting this right yet in all langs # cpp11_variadic_templates \ # Broken for some languages (such as Java) # cpp11_reference_wrapper \ # No typemaps # # Put all the heavy STD/STL cases here, where they can be skipped if needed # CPP_STD_TEST_CASES += \ director_string \ ignore_template_constructor \ li_std_combinations \ li_std_deque \ li_std_except \ li_std_except_as_class \ li_std_map \ li_std_pair \ li_std_pair_using \ li_std_string \ li_std_vector \ li_std_vector_enum \ li_std_vector_member_var\ naturalvar \ smart_pointer_inherit \ template_typedef_fnc \ template_type_namespace \ template_opaque # li_std_list ifndef SKIP_CPP_STD_CASES CPP_TEST_CASES += ${CPP_STD_TEST_CASES} endif ifneq (,$(HAVE_CXX11_COMPILER)) CPP_TEST_CASES += $(CPP11_TEST_CASES) endif # C test cases. (Can be run individually using: make testcase.ctest) C_TEST_CASES += \ arrays \ bom_utf8 \ c_delete \ c_delete_function \ char_constant \ const_const \ constant_expr \ empty \ enums \ enum_forward \ enum_macro \ enum_missing \ extern_declaration \ funcptr \ function_typedef \ global_functions \ immutable_values \ inctest \ infinity \ integers \ keyword_rename \ lextype \ li_carrays \ li_cdata \ li_cmalloc \ li_constraints \ li_cpointer \ li_math \ long_long \ memberin_extend_c \ name \ nested \ nested_extend_c \ nested_structs \ newobject2 \ overload_extend \ overload_extendc \ preproc \ preproc_constants_c \ preproc_defined \ preproc_include \ preproc_line_file \ ret_by_value \ simple_array \ sizeof_pointer \ sneaky1 \ string_simple \ struct_rename \ struct_initialization \ typedef_struct \ typemap_subst \ union_parameter \ unions # Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest) MULTI_CPP_TEST_CASES += \ clientdata_prop \ imports \ import_stl \ packageoption \ mod \ template_typedef_import \ multi_import # Custom tests - tests with additional commandline options wallkw.cpptest: SWIGOPT += -Wallkw preproc_include.ctest: SWIGOPT += -includeall NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \ $(C_TEST_CASES:=.ctest) \ $(MULTI_CPP_TEST_CASES:=.multicpptest) \ $(EXTRA_TEST_CASES) BROKEN_TEST_CASES = $(CPP_TEST_BROKEN:=.cpptest) \ $(C_TEST_BROKEN:=.ctest) ALL_CLEAN = $(CPP_TEST_CASES:=.clean) \ $(C_TEST_CASES:=.clean) \ $(MULTI_CPP_TEST_CASES:=.clean) \ $(CPP_TEST_BROKEN:=.clean) \ $(C_TEST_BROKEN:=.clean) ####################################################################### # Error test suite has its own set of test cases ####################################################################### ifneq (,$(ERROR_TEST_CASES)) check: $(ERROR_TEST_CASES) else ####################################################################### # The following applies for all module languages ####################################################################### all: $(NOT_BROKEN_TEST_CASES) $(BROKEN_TEST_CASES) broken: $(BROKEN_TEST_CASES) check: $(NOT_BROKEN_TEST_CASES) check-c: $(C_TEST_CASES:=.ctest) check-cpp: $(CPP_TEST_CASES:=.cpptest) check-cpp11: $(CPP11_TEST_CASES:=.cpptest) endif # partialcheck target runs SWIG only, ie no compilation or running of tests (for a subset of languages) partialcheck: $(MAKE) check CC=true CXX=true LDSHARED=true CXXSHARED=true RUNTOOL=true COMPILETOOL=true swig_and_compile_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_c = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT) swig_and_compile_multi_cpp = \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done swig_and_compile_external = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ TARGET="$*_wrap_hdr.h" \ $(LANGUAGE)$(VARIANT)_externalhdr; \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS) $*_external.cxx" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_runtime = \ setup = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \ else \ echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \ fi; ####################################################################### # Clean ####################################################################### clean: $(ALL_CLEAN) distclean: clean @rm -f Makefile .PHONY: all check partialcheck broken clean distclean swig-3.0.2/Examples/test-suite/simutry.i0000664000175000017500000000300712343605122020115 0ustar williamwilliam%module simutry %include "std_vector.i" %inline { namespace simuPOP { // some simple pop class template struct Population { int m_a; Population(int a):m_a(a){} }; // base operator, output pop.m_a template struct Operator { Pop m_pop; Operator(int a):m_pop(a){} virtual ~Operator() { } virtual int func() const { return m_pop.m_a; } }; // derived operator, output double of pop.m_a template struct DerivedOperator: public Operator { DerivedOperator(int a):Operator(a){} virtual int func() const { return 2*this->m_pop.m_a; } }; } } #if 1 namespace simuPOP { %template(population) Population< std::pair >; } %inline { namespace simuPOP { typedef Population< std::pair > pop; } } #else %inline { namespace simuPOP { // %template(population) Population< std::pair >; struct pop { int m_a; pop(int a):m_a(a){} }; } } #endif namespace simuPOP { %template(baseOperator) Operator< pop >; %template(derivedOperator) DerivedOperator< pop >; } namespace std { %template(vectorop) vector< simuPOP::Operator * >; } %inline { namespace simuPOP { // test function, use of a vector of Operator* void test( const std::vector< Operator*>& para) { for( size_t i =0; i < para.size(); ++i) para[i]->func(); } } } swig-3.0.2/Examples/test-suite/arrayref.i0000664000175000017500000000022012343605122020206 0ustar williamwilliam// A function that passes arrays by reference %module arrayref %inline %{ void foo(const int (&x)[10]) { } void bar(int (&x)[10]) { } %} swig-3.0.2/Examples/test-suite/multi_import_c.i0000664000175000017500000000004612343605122021427 0ustar williamwilliamclass XXX { public: int testx(); }; swig-3.0.2/Examples/test-suite/multi_import.h0000664000175000017500000000026512343605122021127 0ustar williamwilliamclass XXX { public: int testx() { return 0;} }; class YYY : public XXX { public: int testy() { return 1;} }; class ZZZ : public XXX { public: int testz() { return 2;} }; swig-3.0.2/Examples/test-suite/li_attribute_template.i0000664000175000017500000000434712343605122022773 0ustar williamwilliam%module li_attribute_template %include //#define SWIG_ATTRIBUTE_TEMPLATE %include %include %inline { class Foo { public: Foo( int _value ) { value = _value; } int value; }; template< class T1, class T2> struct pair{ pair( T1 t1, T2 t2 ): first(t1), second(t2) {;} T1 first; T2 second; }; template< class T1, class T2> struct C { C(int a, int b, int c) : _a(a), _b(b), _c(c), _d(a), _e(b), _f(a,b), _g(b,c) { /* _f.first = _a; _f.second = _b; _g.first = _b; _g.second = _c; */ } int get_value() const { return _a; } void set_value(int aa) { _a = aa; } /* only one ref method */ int& get_ref() { return _b; } Foo get_class_value() const { return _d; } void set_class_value( Foo foo) { _d = foo; } const Foo& get_class_ref() const { return _e; } void set_class_ref( const Foo& foo ) { _e = foo; } pair get_template_value() const { return _f; } void set_template_value( const pair f ) { _f = f; } const pair& get_template_ref() const { return _g; } void set_template_ref( const pair& g ) { _g = g; } std::string get_string() { return str; } void set_string(std::string other) { str = other; } private: int _a; int _b; int _c; Foo _d; Foo _e; pair _f; pair _g; std::string str; }; } %define %instantiate_C( T1, T2 ) %template (pair_ ## T1 ## T2 ) pair; // Primitive types %attribute( %arg(C), int, a, get_value, set_value ); %attributeref( %arg(C), int, b, get_ref ); // Strings %attributestring(%arg(C), std::string, str, get_string, set_string); // Class types %attributeval( %arg(C), Foo, d, get_class_value, set_class_value ); %attribute2( %arg(C), Foo, e, get_class_ref, set_class_ref ); // Moderately templated types %attributeval( %arg(C), %arg(pair), f, get_template_value, set_template_value ); %attribute2( %arg(C), %arg(pair), g, get_template_ref, set_template_ref ); %template (C ## T1 ## T2) C; %enddef %instantiate_C(int,int); swig-3.0.2/Examples/test-suite/li_math.i0000664000175000017500000000026612343605122020022 0ustar williamwilliam%module li_math #ifdef SWIGPHP // PHP already provides these functions with the same names, so just kill that // warning. %warnfilter(SWIGWARN_PARSE_KEYWORD); #endif %include math.i swig-3.0.2/Examples/test-suite/template_arg_replace.i0000664000175000017500000000046212343605122022542 0ustar williamwilliam%module template_arg_replace %warnfilter(SWIGWARN_RUBY_WRONG_NAME) test_Matrix; /* Ruby, wrong class name */ %inline %{ template class test_Matrix { public: void Func(const test_Matrix &m) { }; }; %} %template (matrix33f) test_Matrix; swig-3.0.2/Examples/test-suite/template_specialization_defarg.i0000664000175000017500000000220012343605122024614 0ustar williamwilliam%module template_specialization_defarg %inline %{ template struct C { }; template struct C { int hi() { return 0; } C(int a) { } }; template struct C { int hello() { return 0; } C(double a) { } }; template struct Alloc { }; template struct D { D(int){} }; template <> struct D { D(){} int foo() { return 0; } }; template > struct Vector { Vector(int){} }; template <> struct Vector { Vector(){} int foo() { return 0; } }; %} // // This works fine // %template(C_i) C; // // This one fails // %template(C_dd) C; %template(C_d) C; %template(D_i) D; %template(D_d) D; %template(Vector_i) Vector; %template(Vector_d) Vector >; swig-3.0.2/Examples/test-suite/threads_exception.i0000664000175000017500000000211212343605122022105 0ustar williamwilliam// Throw a lot of exceptions // The Python runtime tests were previously failing with the -threads option on Windows due to SWIG_PYTHON_THREAD_BEGIN_ALLOW not being within the try block. %module(threads="1") threads_exception %{ struct A {}; %} %inline %{ #include #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif class Exc { public: Exc(int c, const char *m) { code = c; strncpy(msg,m,255); msg[255] = 0; } int code; char msg[256]; }; class Test { public: int simple() throw(int) { throw(37); return 1; } int message() throw(const char *) { throw("I died."); return 1; } int hosed() throw(Exc) { throw(Exc(42,"Hosed")); return 1; } int unknown() throw(A*) { static A a; throw &a; return 1; } int multi(int x) throw(int, const char *, Exc) { if (x == 1) throw(37); if (x == 2) throw("Bleah!"); if (x == 3) throw(Exc(42,"No-go-diggy-die")); return 1; } }; %} swig-3.0.2/Examples/test-suite/ordering.i0000664000175000017500000000065512343605122020220 0ustar williamwilliam%module ordering // Ruby used to fail on the ordering of the two Class declarations below struct Klass { int variable; }; %{ struct Klass { int variable; }; %} // Testing the order of various code block sections %runtime %{ class RuntimeSection {}; %} %header %{ class HeaderSection {}; void HeaderMethod(RuntimeSection rs) {} %} %wrapper %{ void WrapperMethod(HeaderSection hs, RuntimeSection rs) {} %} swig-3.0.2/Examples/test-suite/java_lib_arrays.i0000664000175000017500000000353712343605122021541 0ustar williamwilliam/* Testcase for the Java array typemaps which are not used by default. */ %module java_lib_arrays %include "enumtypeunsafe.swg" /* Use the Java library typemaps */ %include "arrays_java.i" JAVA_ARRAYSOFCLASSES(SimpleStruct) %apply ARRAYSOFENUMS[ANY] { finger[ANY] } //%apply signed char[ANY] { char array_c2[ANY] } %include "arrays.i" // This will test the %typemap(javacode) in the JAVA_ARRAYSOFCLASSES works with C structs amongst other things JAVA_ARRAYSOFCLASSES(struct AnotherStruct) %inline %{ struct AnotherStruct { SimpleStruct simple; }; double extract(struct AnotherStruct as[], int index) { return as[index].simple.double_field; } double extract2(struct AnotherStruct as[5], int index) { return as[index].simple.double_field; } %} // Test %apply to pointers JAVA_ARRAYSOFCLASSES(struct YetAnotherStruct) %apply struct YetAnotherStruct[] { struct YetAnotherStruct *yas } //%apply struct YetAnotherStruct[] { struct YetAnotherStruct * } // Note: Does not work unless this is put after the YetAnotherStruct definition %inline %{ struct YetAnotherStruct { SimpleStruct simple; }; double extract_ptr(struct YetAnotherStruct *yas, int index) { return yas[index].simple.double_field; } void modifyYAS(struct YetAnotherStruct yas[], int size) { int i; for (i=0; i eq_f1 = smth -- > eq_f2 = eq_f1 -- then default Lua equality comparison kicks in and considers them equal. Access to global_fptr is actually a -- function call (internally) and it returns new userdata each time. eq_f1 = cb.Bar.global_fptr eq_f2 = cb.Bar.global_fptr assert( eq_f1 == eq_f2 ) swig-3.0.2/Examples/test-suite/lua/import_nomodule_runme.lua0000664000175000017500000000070212343605122024134 0ustar williamwilliamrequire("import") -- the import fn import("import_nomodule") -- import code -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) f = import_nomodule.create_Foo() import_nomodule.test1(f,42) import_nomodule.delete_Foo(f) b = import_nomodule.Bar() import_nomodule.test1(b,37) collectgarbage()swig-3.0.2/Examples/test-suite/lua/overload_template_fast_runme.lua0000664000175000017500000000440112343605122025443 0ustar williamwilliamrequire("import") -- the import fn import("overload_template_fast") -- import code for k,v in pairs(overload_template_fast) do _G[k]=v end -- move to global -- lua has only one numeric type, so maximum(int,int) and maximum(double,double) are the same -- whichever one was wrapper first will be used (which is int) f = foo() a = maximum(3,4) -- mix 1 assert(mix1("hi") == 101) assert(mix1(1.0, 1.0) == 102) assert(mix1(1.0) == 103) -- mix 2 assert(mix2("hi") == 101) assert(mix2(1.0, 1.0) == 102) assert(mix2(1.0) == 103) -- mix 3 assert(mix3("hi") == 101) assert(mix3(1.0, 1.0) == 102) assert(mix3(1.0) == 103) -- Combination 1 assert(overtparams1(100) == 10) assert(overtparams1(100.0, 100) == 20) -- Combination 2 assert(overtparams2(100.0, 100) == 40) -- Combination 3 assert(overloaded() == 60) assert(overloaded(100.0, 100) == 70) -- Combination 4 assert(overloadedagain("hello") == 80) assert(overloadedagain() == 90) -- specializations assert(specialization(10) == 202 or specialization(10.0) == 203) -- only one works assert(specialization(10, 10) == 204 or specialization(10.0, 10.0) == 205) -- ditto assert(specialization("hi", "hi") == 201) -- simple specialization xyz() xyz_int() xyz_double() -- a bit of everything assert(overload("hi") == 0) assert(overload(1) == 10) assert(overload(1, 1) == 20) assert(overload(1, "hello") == 30) k = Klass() assert(overload(k) == 10) assert(overload(k, k) == 20) assert(overload(k, "hello") == 30) -- this one is incorrect: it mactches overload(10.0, "hi") with int overload(T t, const char *c) --print(overload(10.0, "hi")) --assert(overload(10.0, "hi") == 40) assert(overload() == 50) -- everything put in a namespace assert(nsoverload("hi") == 1000,"nsoverload()") assert(nsoverload(1) == 1010,"nsoverload(int t)") assert(nsoverload(1, 1) == 1020,"nsoverload(int t, const int &)") assert(nsoverload(1, "hello") == 1030,"nsoverload(int t, const char *)") assert(nsoverload(k) == 1010,"nsoverload(Klass t)") assert(nsoverload(k, k) == 1020,"nsoverload(Klass t, const Klass &)") assert(nsoverload(k, "hello") == 1030,"nsoverload(Klass t, const char *)") -- again this one fails --assert(nsoverload(10.0, "hi") == 1040,"nsoverload(double t, const char *)") assert(nsoverload() == 1050,"nsoverload(const char *)") A_foo(1) b = B() b:foo(1) swig-3.0.2/Examples/test-suite/lua/friends_runme.lua0000664000175000017500000000114612343605122022355 0ustar williamwilliamrequire("import") -- the import fn import("friends") -- import lib into global f=friends --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) f.globalscope() b1 = f.B(5) a1 = f.A(10) assert(f.get_val1(a1) == 10) assert(f.get_val1(a1, 2) == 12) assert(f.get_val2(a1) == 20) assert(f.get_val3(a1) == 30) assert(f.get_val1(100, 1, 2) == 100) assert(f.mix(a1,b1) == 15); d1 = f.D_i(7) assert(f.get_val1(d1) == 7) f.set(d1,9) assert(f.get_val1(d1) == 9) swig-3.0.2/Examples/test-suite/lua/primitive_ref_runme.lua0000664000175000017500000000103312343605122023562 0ustar williamwilliamrequire("import") -- the import fn import("primitive_ref") -- import code pr=primitive_ref --alias assert(pr.ref_int(3)==3) assert(pr.ref_uint(3) == 3) assert(pr.ref_short(3) == 3) assert(pr.ref_ushort(3) == 3) assert(pr.ref_long(3) == 3) assert(pr.ref_ulong(3) == 3) assert(pr.ref_schar(3) == 3) assert(pr.ref_uchar(3) == 3) assert(pr.ref_float(3.5) == 3.5) assert(pr.ref_double(3.5) == 3.5) assert(pr.ref_bool(true) == true) assert(pr.ref_char('x') == 'x') assert(pr.ref_over(0) == 0) a=pr.A(12) assert(pr.ref_over(a)==12) swig-3.0.2/Examples/test-suite/lua/smart_pointer_inherit_runme.lua0000664000175000017500000000077712343605122025344 0ustar williamwilliamrequire("import") -- the import fn import("smart_pointer_inherit") -- import lib into global spi=smart_pointer_inherit --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) der = spi.Derived(7) ptr = spi.SmartDerived(der) assert(ptr.val == 7) assert(ptr:value() == 7) assert(ptr:value2() == 7) assert(ptr:value3() == 7) assert(ptr:valuehide() == -1) swig-3.0.2/Examples/test-suite/lua/extend_placement_runme.lua0000664000175000017500000000152412343605122024242 0ustar williamwilliamrequire("import") -- the import fn import("extend_placement") -- import lib into global ep=extend_placement --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) function test_obj(main, suppl) assert(main:spam() == 1) assert(main:spam("this_is_string") == 2) assert(main:spam(5) == 5) assert(main:spam(5,6) == 11) assert(main:spam(7,8,9) == 15) assert(main:spam(suppl,12.0) == 0) assert(main:spam(suppl) == 0) end foo1 = ep.Foo(0) foo2 = ep.Foo(1,2) foo3 = ep.Foo() test_obj(foo1,foo2) bar1 = ep.Bar() bar2 = ep.Bar(5) test_obj(bar1,bar2) fti1 = ep.FooTi(0) fti2 = ep.FooTi(1,2) fti3 = ep.FooTi() test_obj(fti1,foo1) bti1 = ep.BarTi() bti2 = ep.BarTi(5) test_obj(bti1,bar1) swig-3.0.2/Examples/test-suite/lua/extend_variable_runme.lua0000664000175000017500000000136212343605122024057 0ustar williamwilliamrequire("import") -- the import fn import("extend_variable") -- import lib into global ev=extend_variable --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) e1 = ev.ExtendMe() answ = 1.0 assert(e1:set(7.0)) --assert(e1:get(answ)) -- doesn't work. Lua can't pass primitive type by non-const reference --assert(answ == 7.0) e1.ExtendVar = 5.0 assert(e1.ExtendVar == 5.0) assert(ev.Foo.Bar == 42) assert(ev.Foo.AllBarOne == 4422) assert(ev.Foo.StaticInt == 1111) ev.Foo.StaticInt = 3333 assert(ev.Foo.StaticInt == 3333) assert(ev.Foo.StaticConstInt == 2222) b1 = ev.Bar() assert(b1.x == 1) swig-3.0.2/Examples/test-suite/lua/abstract_access_runme.lua0000664000175000017500000000103712343605122024046 0ustar williamwilliamrequire("import") -- the import fn import("abstract_access") -- import code -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) -- trying to instantiate pure virual classes -- should fail assert(pcall(abstract_access.A)==false) assert(pcall(abstract_access.B)==false) assert(pcall(abstract_access.C)==false) -- instantiate object d=abstract_access.D() --call fn assert(d:do_x()==1) swig-3.0.2/Examples/test-suite/lua/smart_pointer_multi_runme.lua0000664000175000017500000000106312343605122025021 0ustar williamwilliamrequire("import") -- the import fn import("smart_pointer_multi") -- import lib into global spm=smart_pointer_multi --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) foo = spm.Foo() foo.x = 5 assert(foo:getx() == 5) bar = spm.Bar(foo) spam = spm.Spam(bar) grok = spm.Grok(bar) assert(bar:getx() == 5) assert(spam:getx() == 5) spam.x = 7 assert(grok:getx() == 7) grok.x = 10 assert(foo:getx() == 10) swig-3.0.2/Examples/test-suite/lua/cpp_static_runme.lua0000664000175000017500000000106312343605122023052 0ustar williamwilliam-- demo of lua swig capacilities (operator overloading) require("import") -- the import fn import("cpp_static") -- import lib into global cs=cpp_static --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) cs.StaticMemberTest.static_int = 5; assert(cs.StaticMemberTest.static_int == 5); cs.StaticFunctionTest.static_func() cs.StaticFunctionTest.static_func_2(2) cs.StaticFunctionTest.static_func_3(3,3) swig-3.0.2/Examples/test-suite/lua/equality_runme.lua0000664000175000017500000000213312343605122022555 0ustar williamwilliamrequire("import") -- the import fn import("equality") -- import code eq=equality -- renaming import -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) -- === No equality operator === -- logically same data without equality operator are not equal p1 = eq.MakePoint(10,9); p2 = eq.MakePoint(10,9); assert( p1 ~= p2 ); -- different wrappers for same Point* are equal p3 = eq.GetZeroPointPtr() p4 = eq.GetZeroPointPtr() assert( p3 == p4 ) -- === Logically correct equality operator === ed1 = eq.EqualOpDefined(10) ed2 = eq.EqualOpDefined(10) ed3 = eq.EqualOpDefined(15) assert( ed1 == ed2 ) assert( ed1 ~= ed3 ) -- === Logically incorrect equality operator === ew1 = eq.EqualOpWrong() ew2 = eq.EqualOpWrong() assert( ew1 ~= ew2 ); ew3 = eq.EqualOpWrong.GetStaticObject() ew4 = eq.EqualOpWrong.GetStaticObject() -- Even though these are pointers to same object, operator== overload should -- state that they are not equal assert( ew3 ~= ew4 ) swig-3.0.2/Examples/test-suite/lua/template_default_arg_runme.lua0000664000175000017500000000512712343605122025076 0ustar williamwilliamrequire("import") -- the import fn import("template_default_arg") -- import code --for k,v in pairs(template_default_arg) do _G[k]=v end -- move to global helloInt = template_default_arg.Hello_int() assert(template_default_arg.Hello_int_hi ~= nil) helloInt:foo(template_default_arg.Hello_int_hi) x = template_default_arg.X_int() assert(x:meth(20.0, 200) == 200,"X_int test 1 failed") assert(x:meth(20) == 20,"X_int test 2 failed") assert(x:meth() == 0,"X_int test 3 failed") y = template_default_arg.Y_unsigned() assert(y:meth(20.0, 200) == 200,"Y_unsigned test 1 failed") assert(y:meth(20) == 20,"Y_unsigned test 2 failed") assert(y:meth() == 0,"Y_unsigned test 3 failed") x = template_default_arg.X_longlong() x = template_default_arg.X_longlong(20.0) x = template_default_arg.X_longlong(20.0, 200) -- note: long longs just treated as another number x = template_default_arg.X_int() x = template_default_arg.X_int(20.0) x = template_default_arg.X_int(20.0, 200) x = template_default_arg.X_hello_unsigned() x = template_default_arg.X_hello_unsigned(20.0) x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int()) y = template_default_arg.Y_hello_unsigned() y:meth(20.0, template_default_arg.Hello_int()) y:meth(template_default_arg.Hello_int()) y:meth() fz = template_default_arg.Foo_Z_8() x = template_default_arg.X_Foo_Z_8() fzc = x:meth(fz) -- Templated functions -- plain function: int ott(Foo) assert(template_default_arg.ott(template_default_arg.Foo_int()) == 30,"ott test 1 failed") -- %template(ott) ott assert(template_default_arg.ott() == 10,"ott test 2 failed") assert(template_default_arg.ott(1) == 10,"ott test 3 failed") assert(template_default_arg.ott(1, 1) == 10,"ott test 4 failed") assert(template_default_arg.ott("hi") == 20,"ott test 5 failed") assert(template_default_arg.ott("hi", 1) == 20,"ott test 6 failed") assert(template_default_arg.ott("hi", 1, 1) == 20,"ott test 7 failed") -- %template(ott) ott assert(template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") == 40,"ott test 8 failed") assert(template_default_arg.ottstring(template_default_arg.Hello_int()) == 40,"ott test 9 failed") -- %template(ott) ott assert(template_default_arg.ottint(template_default_arg.Hello_int(), 1) == 50,"ott test 10 failed") assert(template_default_arg.ottint(template_default_arg.Hello_int()) == 50,"ott test 11 failed") -- %template(ott) ott assert(template_default_arg.ott(template_default_arg.Hello_int(), 1.0) == 60,"ott test 12 failed") assert(template_default_arg.ott(template_default_arg.Hello_int()) == 60,"ott test 13 failed") swig-3.0.2/Examples/test-suite/lua/newobject1_runme.lua0000664000175000017500000000053012343605122022760 0ustar williamwilliamrequire("import") -- the import fn import("newobject1") -- import code foo1 = newobject1.Foo_makeFoo() assert(newobject1.Foo_fooCount() == 1) foo2 = foo1:makeMore() assert(newobject1.Foo_fooCount() == 2) foo1 = nil collectgarbage() assert(newobject1.Foo_fooCount() == 1) foo2 = nil collectgarbage() assert(newobject1.Foo_fooCount() == 0) swig-3.0.2/Examples/test-suite/lua/rename_simple_runme.lua0000664000175000017500000000134112343605122023540 0ustar williamwilliamrequire("import") -- the import fn import("rename_simple") -- import lib rs = rename_simple -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(rs.NewStruct ~= nil) assert(rs.NewStruct.NewStaticVariable == 444) assert(rs.NewStruct_NewStaticVariable == 444) assert(rs.NewStruct.NewStaticMethod() == 333) assert(rs.NewStruct_NewStaticMethod() == 333) assert(rs.NewStruct.ONE == 1) assert(rs.NewStruct_ONE == 1) assert(rs.NewFunction() == 555) assert(rs.OldStruct == nil) assert(rs.OldFunction == nil) assert(rs.OldGlobalVariable == nil) assert(rs.OldStruct_ONE == nil) swig-3.0.2/Examples/test-suite/lua/overload_complicated_runme.lua0000664000175000017500000000110312343605122025073 0ustar williamwilliamrequire("import") -- the import fn import("overload_complicated") -- import lib into global oc=overload_complicated --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(oc.foo(1,1,"test",1) == 15) p1 = oc.Pop(nil) p1 = oc.Pop(nil,false) assert(p1:hip(true) == 701) assert(p1:hip(nil) == 702) assert(p1:hop(true) == 801) assert(p1:hop(nil) == 805) assert(oc.muzak(true) == 3001) assert(oc.muzak(nil) == 3002) swig-3.0.2/Examples/test-suite/lua/enum_rename_runme.lua0000664000175000017500000000052712343605122023220 0ustar williamwilliamrequire("import") -- the import fn import("enum_rename") -- import lib er=enum_rename -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(er.M_Jan ~= nil) assert(er.May ~= nil) swig-3.0.2/Examples/test-suite/lua/dynamic_cast_runme.lua0000664000175000017500000000060212343605122023355 0ustar williamwilliamrequire("import") -- the import fn import("dynamic_cast") -- import code f = dynamic_cast.Foo() b = dynamic_cast.Bar() x = f:blah() y = b:blah() -- swig_type is a swiglua specific function which gets the swig_type_info's name assert(swig_type(f)==swig_type(x)) assert(swig_type(b)==swig_type(y)) -- the real test: is y a Foo* or a Bar*? assert(dynamic_cast.do_test(y)=="Bar::test") swig-3.0.2/Examples/test-suite/lua/li_std_string_runme.lua0000664000175000017500000001020112343605122023557 0ustar williamwilliamrequire("import") -- the import fn import("li_std_string") -- import lib for k,v in pairs(li_std_string) do _G[k]=v end -- move to global -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) -- helper to check type function is_std_string(s) return type(s)=='userdata' and swig_type(s)=='std::string *' end -- std::string by value is just a Lua string s=test_value("foo") assert(type(s)=="string" and s=="foo") -- std::string by const ref is also just a Lua string s=test_const_reference("foo") assert(type(s)=="string" and s=="foo") -- std:string* is an object obj=test_pointer_out() assert(is_std_string(obj) and obj:c_str()=="x") -- check type & value test_pointer(obj) -- this wants an object cobj=test_const_pointer_out() assert(is_std_string(cobj) and cobj:c_str()=="x") -- check type & value test_const_pointer(cobj) -- this shouldnt work, but it does -- swig doesnt appear to diff between const object ptrs & object ptrs very well test_pointer(cobj) -- this wants an non const object (give it a const one!) -- refs are also wrappered as ptrs (unless the correct typemaps are applied) robj=test_reference_out() assert(is_std_string(robj) and robj:c_str()=="test_reference_out message") -- check type & value test_reference(robj) test_reference(obj) -- object ptr is ok test_reference(cobj) -- obj const ptr is also ok -- throwing string ok,ex=pcall(test_throw) assert(ok==false and type(ex)=="string") -- failed & threw string ok,ex=pcall(test_const_reference_throw) assert(ok==false and type(ex)=="string") -- failed & threw string -- const ptrs are now converted to lua strings -- they used to be std::string* ok,ex=pcall(test_const_pointer_throw) assert(ok==false and type(ex)=="string") -- failed & threw object -- ditto non const ptrs ok,ex=pcall(test_pointer_throw) assert(ok==false and type(ex)=="string") -- failed & threw object -- testing std::string variables -- Global variables s = "initial string" assert (li_std_string.GlobalString2 == "global string 2") li_std_string.GlobalString2 = s assert (li_std_string.GlobalString2 == s) assert (li_std_string.ConstGlobalString == "const global string") -- Member variables myStructure = Structure() assert(myStructure.MemberString2 == "member string 2") myStructure.MemberString2 = s assert (myStructure.MemberString2 == s) assert (myStructure.ConstMemberString == "const member string") assert (li_std_string.Structure_StaticMemberString2 == "static member string 2") li_std_string.Structure_StaticMemberString2 = s assert (li_std_string.Structure_StaticMemberString2 == s) assert (li_std_string.Structure_ConstStaticMemberString == "const static member string") -- testing the structure (these are some old tests which predated the std::string variable tests above) struc=Structure() assert(type(struc.MemberString2)=="string") -- typemaps make this a string assert(type(struc.ConstMemberString)=="string") -- set a const (should fail with error) assert(pcall(function () struc.ConstMemberString="c" end)==false) --print(struc.MemberString:data(),struc.MemberString2,struc.ConstMemberString:data()) --check type again assert(type(struc.MemberString2)=="string") -- typemaps make this a string assert(type(struc.ConstMemberString)=="string") -- for static types: they are really variables, -- so we must still use the module name -- check static type assert(type(li_std_string.Structure_StaticMemberString2)=="string") assert(type(li_std_string.Structure_ConstStaticMemberString)=="string") -- try setting (should fail with error) --li_std_string.Structure_StaticMemberString2='e' assert(pcall(function () li_std_string.Structure_ConstStaticMemberString='f' end)==false) --[[print(li_std_string.Structure_StaticMemberString:data(), li_std_string.Structure_StaticMemberString2, li_std_string.Structure_ConstStaticMemberString:data())]] -- check static type again assert(type(li_std_string.Structure_StaticMemberString)=="string") assert(type(li_std_string.Structure_StaticMemberString2)=="string") assert(type(li_std_string.Structure_ConstStaticMemberString)=="string") swig-3.0.2/Examples/test-suite/lua/enums_runme.lua0000664000175000017500000000206512343605122022053 0ustar williamwilliamrequire("import") -- the import fn import("enums") -- import lib -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) -- check values assert(enums.CSP_ITERATION_FWD==0) assert(enums.CSP_ITERATION_BWD==11) assert(enums.ABCDE==0) assert(enums.FGHJI==1) assert(enums.boo==0) assert(enums.hoo==5) assert(enums.globalinstance1==0) assert(enums.globalinstance2==1) assert(enums.globalinstance3==30) assert(enums.AnonEnum1==0) assert(enums.AnonEnum2==100) -- In C enums from struct are exported into global namespace (without prefixing with struct name) -- In C++ they are prefixed (as compatibility thing). -- We are emulating xor :) assert(enums.BAR1 ~= enums.Foo_BAR1) -- It is either C style, or C++ style, but not both assert((enums.BAR1 ~= nil ) or (enums.Foo_BAR1 ~= nil)) assert(enums.Phoo ~= enums.iFoo_Phoo) assert((enums.Phoo == 50) or (enums.iFoo_Phoo == 50)) -- no point in checking fns, C will allow any value swig-3.0.2/Examples/test-suite/lua/voidtest_runme.lua0000664000175000017500000000142412343605122022563 0ustar williamwilliam-- demo of lua swig require("import") -- the import fn import("voidtest") -- import lib -- test calling functions voidtest.globalfunc() f = voidtest.Foo() f:memberfunc() -- member fns must have : not a . voidtest.Foo_staticmemberfunc() -- static member fns are still a little messy v1 = voidtest.vfunc1(f) v2 = voidtest.vfunc2(f) assert(swig_equals(v1,v2)) -- a raw equals will not work, we look at the raw pointers v3 = voidtest.vfunc3(v1) assert(swig_equals(v3,f)) v4 = voidtest.vfunc1(f) assert(swig_equals(v4,v1)) v3:memberfunc() -- also testing nil's support -- nil, are acceptable anywhere a pointer is n1 = voidtest.vfunc1(nil) n2 = voidtest.vfunc2(nil) assert(n1==nil) assert(n2==nil) n3 = voidtest.vfunc3(n1) n4 = voidtest.vfunc1(nil) assert(n3==nil) assert(n4==nil) swig-3.0.2/Examples/test-suite/lua/funcptr_cpp_runme.lua0000664000175000017500000000130512343605122023243 0ustar williamwilliamrequire("import") -- the import fn import("funcptr_cpp") -- import lib into global fc=funcptr_cpp --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(fc.addByValue(5,10) == 15) -- These two won't work. Lua will successfully store the answer as userdata, but there is -- no way of accessing the insides of userdata. -- assert(fc.addByPointer(7, 9) == 16) -- assert(fc.addByReference(8, 9) == 17) assert(fc.call1(fc.ADD_BY_VALUE, 5, 10) == 15) assert(fc.call2(fc.ADD_BY_POINTER, 7, 9) == 16) assert(fc.call3(fc.ADD_BY_REFERENCE, 8, 9) == 17) swig-3.0.2/Examples/test-suite/lua/template_extend2_runme.lua0000664000175000017500000000064012343605122024165 0ustar williamwilliamrequire("import") -- the import fn import("template_extend2") -- import lib into global te=template_extend2 --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) lb = te.lBaz() assert(lb:foo() == "lBaz::foo") db = te.dBaz() assert(db:foo() == "dBaz::foo") swig-3.0.2/Examples/test-suite/lua/extend_runme.lua0000664000175000017500000000136612343605122022216 0ustar williamwilliamrequire("import") -- the import fn import("extend") -- import lib into global e=extend --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) base1 = e.Base() assert(base1.value == 0) base2 = e.Base(10) assert(base2.value == 10) assert(base1:method(5) == 5) assert(e.Base.zeroVal() == 0) assert(base2:currentValue() == 10) assert(base2:extendmethod(7) == 14) der1 = e.Derived(0) assert(der1.value == 0) assert(der1:method(5) == 10) der2 = e.Derived(17) assert(der2.value == 34) der2.extendval = 200.0 assert(math.abs(der2.actualval - 2.0) < 0.001) assert(math.abs(der2.extendval - 200.0) < 0.001) swig-3.0.2/Examples/test-suite/lua/template_extend1_runme.lua0000664000175000017500000000064012343605122024164 0ustar williamwilliamrequire("import") -- the import fn import("template_extend1") -- import lib into global te=template_extend1 --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) lb = te.lBaz() assert(lb:foo() == "lBaz::foo") db = te.dBaz() assert(db:foo() == "dBaz::foo") swig-3.0.2/Examples/test-suite/lua/overload_simple_runme.lua0000664000175000017500000000232312343605122024105 0ustar williamwilliamrequire("import") -- the import fn import("overload_simple") -- import code for k,v in pairs(overload_simple) do _G[k]=v end -- move to global -- lua has only one numeric type, foo(int) and foo(double) are the same -- whichever one was wrapper first will be used assert(foo(3)=="foo:int" or foo(3)=="foo:double") -- could be either assert(foo("hello")=="foo:char *") f=Foo() b=Bar() assert(foo(f)=="foo:Foo *") assert(foo(b)=="foo:Bar *") v = malloc_void(32) assert(foo(v) == "foo:void *") s = Spam() assert(s:foo(3) == "foo:int" or s:foo(3.0) == "foo:double") -- could be either assert(s:foo("hello") == "foo:char *") assert(s:foo(f) == "foo:Foo *") assert(s:foo(b) == "foo:Bar *") assert(s:foo(v) == "foo:void *") assert(Spam_bar(3) == "bar:int" or Spam_bar(3.0) == "bar:double") assert(Spam_bar("hello") == "bar:char *") assert(Spam_bar(f) == "bar:Foo *") assert(Spam_bar(b) == "bar:Bar *") assert(Spam_bar(v) == "bar:void *") -- Test constructors s = Spam() assert(s.type == "none") s = Spam(3) assert(s.type == "int" or s.type == "double") s = Spam("hello") assert(s.type == "char *") s = Spam(f) assert(s.type == "Foo *") s = Spam(b) assert(s.type == "Bar *") s = Spam(v) assert(s.type == "void *") free_void(v) swig-3.0.2/Examples/test-suite/lua/inherit_missing_runme.lua0000664000175000017500000000064212343605122024116 0ustar williamwilliamrequire("import") -- the import fn import("inherit_missing") -- import lib im=inherit_missing -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) bar = im.Bar() spam = im.Spam() assert(im.do_blah(bar) == "Bar::blah") assert(im.do_blah(spam) == "Spam::blah") swig-3.0.2/Examples/test-suite/lua/global_namespace_runme.lua0000664000175000017500000000267012343605122024202 0ustar williamwilliamrequire("import") -- the import fn import("global_namespace") -- import lib into global gn=global_namespace --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) k1 = gn.Klass1() k2 = gn.Klass2() k3 = gn.Klass3() k4 = gn.Klass4() k5 = gn.Klass5() k6 = gn.Klass6() k7 = gn.Klass7() gn.KlassMethods.methodA(k1,k2,k3,k4,k5,k6,k7) gn.KlassMethods.methodB(k1,k2,k3,k4,k5,k6,k7) k1 = gn.getKlass1A() k2 = gn.getKlass2A() k3 = gn.getKlass3A() k4 = gn.getKlass4A() k5 = gn.getKlass5A() k6 = gn.getKlass6A() k7 = gn.getKlass7A() gn.KlassMethods.methodA(k1,k2,k3,k4,k5,k6,k7) gn.KlassMethods.methodB(k1,k2,k3,k4,k5,k6,k7) k1 = gn.getKlass1B() k2 = gn.getKlass2B() k3 = gn.getKlass3B() k4 = gn.getKlass4B() k5 = gn.getKlass5B() k6 = gn.getKlass6B() k7 = gn.getKlass7B() gn.KlassMethods.methodA(k1,k2,k3,k4,k5,k6,k7) gn.KlassMethods.methodB(k1,k2,k3,k4,k5,k6,k7) x1 = gn.XYZ1() x2 = gn.XYZ2() x3 = gn.XYZ3() x4 = gn.XYZ4() x5 = gn.XYZ5() x6 = gn.XYZ6() x7 = gn.XYZ7() gn.XYZMethods.methodA(x1,x2,x3,x4,x5,x6,x7) gn.XYZMethods.methodB(x1,x2,x3,x4,x5,x6,x7) gn.AnEnumMethods.methodA(gn.anenum1, gn.anenum2, gn.anenum3) gn.AnEnumMethods.methodB(gn.anenum1, gn.anenum2, gn.anenum3) gn.TheEnumMethods.methodA(gn.theenum1, gn.theenum2, gn.theenum3) gn.TheEnumMethods.methodB(gn.theenum1, gn.theenum2, gn.theenum3) swig-3.0.2/Examples/test-suite/lua/refcount_runme.lua0000664000175000017500000000111112343605122022540 0ustar williamwilliamrequire("import") -- the import fn import("refcount") -- import lib r=refcount -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) a = r.A() assert(a:ref_count() == 1) b1 = r.B(a) assert(a:ref_count() == 2) b2 = r.B.create(a) assert(a:ref_count() == 3) b3 = b2:cloner() assert(a:ref_count() == 4) rca = b1:get_rca() -- RCPtr is not wrapped assert(a:ref_count() == 5) b4 = r.global_create(a) assert(a:ref_count() == 6) swig-3.0.2/Examples/test-suite/lua/enum_plus_runme.lua0000664000175000017500000000063312343605122022732 0ustar williamwilliamrequire("import") -- the import fn import("enum_plus") -- import lib ep=enum_plus -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(ep.iFoo_Phoo == 50) -- Old variant of enum bindings assert(ep.iFoo.Phoo == 50) -- New variant of enum bindings swig-3.0.2/Examples/test-suite/lua/overload_template_runme.lua0000664000175000017500000000436712343605122024441 0ustar williamwilliamrequire("import") -- the import fn import("overload_template") -- import code for k,v in pairs(overload_template) do _G[k]=v end -- move to global -- lua has only one numeric type, so maximum(int,int) and maximum(double,double) are the same -- whichever one was wrapper first will be used (which is int) f = foo() a = maximum(3,4) -- mix 1 assert(mix1("hi") == 101) assert(mix1(1.0, 1.0) == 102) assert(mix1(1.0) == 103) -- mix 2 assert(mix2("hi") == 101) assert(mix2(1.0, 1.0) == 102) assert(mix2(1.0) == 103) -- mix 3 assert(mix3("hi") == 101) assert(mix3(1.0, 1.0) == 102) assert(mix3(1.0) == 103) -- Combination 1 assert(overtparams1(100) == 10) assert(overtparams1(100.0, 100) == 20) -- Combination 2 assert(overtparams2(100.0, 100) == 40) -- Combination 3 assert(overloaded() == 60) assert(overloaded(100.0, 100) == 70) -- Combination 4 assert(overloadedagain("hello") == 80) assert(overloadedagain() == 90) -- specializations assert(specialization(10) == 202 or specialization(10.0) == 203) -- only one works assert(specialization(10, 10) == 204 or specialization(10.0, 10.0) == 205) -- ditto assert(specialization("hi", "hi") == 201) -- simple specialization xyz() xyz_int() xyz_double() -- a bit of everything assert(overload("hi") == 0) assert(overload(1) == 10) assert(overload(1, 1) == 20) assert(overload(1, "hello") == 30) k = Klass() assert(overload(k) == 10) assert(overload(k, k) == 20) assert(overload(k, "hello") == 30) -- this one is incorrect: it mactches overload(10.0, "hi") with int overload(T t, const char *c) --print(overload(10.0, "hi")) --assert(overload(10.0, "hi") == 40) assert(overload() == 50) -- everything put in a namespace assert(nsoverload("hi") == 1000,"nsoverload()") assert(nsoverload(1) == 1010,"nsoverload(int t)") assert(nsoverload(1, 1) == 1020,"nsoverload(int t, const int &)") assert(nsoverload(1, "hello") == 1030,"nsoverload(int t, const char *)") assert(nsoverload(k) == 1010,"nsoverload(Klass t)") assert(nsoverload(k, k) == 1020,"nsoverload(Klass t, const Klass &)") assert(nsoverload(k, "hello") == 1030,"nsoverload(Klass t, const char *)") -- again this one fails --assert(nsoverload(10.0, "hi") == 1040,"nsoverload(double t, const char *)") assert(nsoverload() == 1050,"nsoverload(const char *)") A_foo(1) b = B() b:foo(1) swig-3.0.2/Examples/test-suite/lua/operator_overload_runme.lua0000664000175000017500000000674612343605122024464 0ustar williamwilliam-- demo of lua swig capacities (operator overloading) require("import") -- the import fn import("operator_overload") -- import lib for k,v in pairs(operator_overload) do _G[k]=v end -- move to global -- first check all the operators are implemented correctly from pure C++ code Op_sanity_check() -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) -- test routine: a=Op() b=Op(5) c=Op(b) -- copy construct d=Op(2) dd=d; -- assignment operator -- test equality assert(a~=b) assert(b==c) assert(a~=d) assert(d==dd) -- test < assert(a=c) assert(b>d) assert(b>=d) -- lua does not support += operators: skipping -- test + f=Op(1) g=Op(1) assert(f+g==Op(2)) assert(f-g==Op(0)) assert(f*g==Op(1)) assert(f/g==Op(1)) --assert(f%g==Op(0)) -- lua does not support % -- test unary operators --assert((not a)==true) -- lua does not allow overloading for not operator --assert((not b)==false) -- lua does not allow overloading for not operator --lua 5.0.2 defines that unary - is __unm(self,nil) --lua 5.1.2 defines that unary - is __unm(self,self) --C++ expects unary - as operator-() --however the latest version of SWIG strictly checks the number of args --and will complain if too many args are provided --therefore disabling these tests for now -- (solution will to be not to check args for this test case) assert(-a==a) assert(-b==Op(-5)) -- test [] h=Op(3) assert(h[0]==3) assert(h[1]==0) h[0]=2 -- set assert(h[0]==2) h[1]=2 -- ignored assert(h[0]==2) assert(h[1]==0) -- test () i=Op(3) assert(i()==3) assert(i(1)==4) assert(i(1,2)==6) -- plus add some code to check the __str__ fn assert(tostring(Op(1))=="Op(1)") assert(tostring(Op(-3))=="Op(-3)") -- check that operator overloads are correctly propagated down inheritance hierarchy a_d=OpDerived() b_d=OpDerived(5) c_d=OpDerived(5) d_d=OpDerived(2) -- test equality assert(a_d~=b_d) assert(b_d==c_d) assert(a_d~=d_d) -- test < assert(a_d=c_d) assert(b_d>d_d) assert(b_d>=d_d) -- -- test + inheritance f_d=OpDerived(1) g_d=OpDerived(1) assert(f_d+g_d==Op(2)) assert(f_d-g_d==Op(0)) assert(f_d*g_d==Op(1)) assert(f_d/g_d==Op(1)) -- -- plus add some code to check the __str__ fn inheritance assert(tostring(OpDerived(1))=="Op(1)") assert(tostring(OpDerived(-3))=="Op(-3)") --[[ /* Sample test code in C++ #include #include int main(int argc,char** argv) { // test routine: Op a; Op b=5; Op c=b; // copy construct Op d=2; // test equality assert(a!=b); assert(b==c); assert(a!=d); // test < assert(a=c); assert(b>d); assert(b>=d); // test += Op e=3; e+=d; assert(e==b); e-=c; assert(e==a); e=Op(1); e*=b; assert(e==c); e/=d; assert(e==d); e%=c; assert(e==d); // test + Op f(1),g(1); assert(f+g==Op(2)); assert(f-g==Op(0)); assert(f*g==Op(1)); assert(f/g==Op(1)); assert(f%g==Op(0)); // test unary operators assert(!a==true); assert(!b==false); assert(-a==a); assert(-b==Op(-5)); // test [] Op h=3; assert(h[0]==3); assert(h[1]==0); h[0]=2; // set assert(h[0]==2); h[1]=2; // ignored assert(h[0]==2); assert(h[1]==0); // test () Op i=3; assert(i()==3); assert(i(1)==4); assert(i(1,2)==6); // plus add some code to check the __str__ fn //assert(str(Op(1))=="Op(1)"); //assert(str(Op(-3))=="Op(-3)"); printf("ok\n"); } */ ]] swig-3.0.2/Examples/test-suite/lua/lua_no_module_global_runme.lua0000664000175000017500000000155512343605122025071 0ustar williamwilliam-- require is only available in Lua 5.1 if string.sub(_VERSION,1,7)=='Lua 5.1' then -- Initially the package should not be loaded assert(package.loaded["lua_no_module_global"] == nil) -- Load the module the_module = require "lua_no_module_global" -- require should return the module table assert(the_module.hi_mom ~= nil) assert(the_module.hi_mom() == "hi mom!") -- But it should not end up in the global table _G, subject to -- the -nomoduleglobal swig option. assert(_G["lua_no_module_global"] == nil) -- According to the Lua 5.1 reference manual, require should also -- store the module table into package.loaded["name"] assert(package.loaded["lua_no_module_global"] == the_module) assert(package.loaded["lua_no_module_global"].hi_mom() == "hi mom!") end swig-3.0.2/Examples/test-suite/lua/enum_template_runme.lua0000664000175000017500000000064012343605122023560 0ustar williamwilliamrequire("import") -- the import fn import("enum_template") -- import lib et=enum_template -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(et.eTest0 ~= nil) assert(et.eTest1 ~= nil) et.TakeETest(et.eTest0) res = et.MakeETest() et.TakeETest(res) swig-3.0.2/Examples/test-suite/lua/member_pointer_runme.lua0000664000175000017500000000237312343605122023735 0ustar williamwilliam--Example using pointers to member functions require("import") -- the import fn import("member_pointer") -- import code mp = member_pointer -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) function check(what, expected, actual) assert(expected == actual,"Failed: "..what.." Expected: "..expected.." Actual: "..actual) end -- Get the pointers area_pt = mp.areapt() perim_pt = mp.perimeterpt() -- Create some objects s = mp.Square(10) -- Do some calculations check ("Square area ", 100.0, mp.do_op(s,area_pt)) check ("Square perim", 40.0, mp.do_op(s,perim_pt)) -- Try the variables -- these have to still be part of the 'member_pointer' table memberPtr = mp.areavar memberPtr = mp.perimetervar check ("Square area ", 100.0, mp.do_op(s,mp.areavar)) check ("Square perim", 40.0, mp.do_op(s,mp.perimetervar)) -- Modify one of the variables mp.areavar = perim_pt check ("Square perimeter", 40.0, mp.do_op(s,mp.areavar)) -- Try the constants memberPtr = mp.AREAPT memberPtr = mp.PERIMPT memberPtr = mp.NULLPT check ("Square area ", 100.0, mp.do_op(s,mp.AREAPT)) check ("Square perim", 40.0, mp.do_op(s,mp.PERIMPT)) swig-3.0.2/Examples/test-suite/lua/enum_scope_template_runme.lua0000664000175000017500000000063112343605122024751 0ustar williamwilliamrequire("import") -- the import fn import("enum_scope_template") -- import lib est=enum_scope_template -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(est.TreeInt.Oak ~= nil) assert(est.TreeInt_Oak ~= nil) assert(est.TreeInt.Cedar ~= nil) swig-3.0.2/Examples/test-suite/lua/static_const_member_runme.lua0000664000175000017500000000104112343605122024741 0ustar williamwilliamrequire("import") -- the import fn import("static_const_member") -- import lib into global scm=static_const_member --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(scm.X.PN == 0) assert(scm.X.CN == 1) assert(scm.X.EN == 2) assert(scm.X.CHARTEST == "A") -- Old-style bindings assert(scm.X_PN == 0) assert(scm.X_CN == 1) assert(scm.X_EN == 2) assert(scm.X_CHARTEST == "A") swig-3.0.2/Examples/test-suite/lua/template_inherit_runme.lua0000664000175000017500000000121112343605122024251 0ustar williamwilliamrequire("import") -- the import fn import("template_inherit") -- import lib into global ti=template_inherit --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) fi = ti.FooInt() assert(fi:blah() == "Foo") assert(fi:foomethod() == "foomethod") bi = ti.BarInt() assert(bi:blah() == "Bar") assert(bi:foomethod() == "foomethod") assert(ti.invoke_blah_int(fi) == "Foo") assert(ti.invoke_blah_int(bi) == "Bar") bd = ti.BarDouble() success = pcall(ti.invoke_blah_int, bd) assert(not success) swig-3.0.2/Examples/test-suite/lua/disown_runme.lua0000664000175000017500000000105412343605122022224 0ustar williamwilliamrequire("import") -- the import fn import("disown") -- import code -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) for x=0,100 do a=disown.A() b=disown.B() b:acquire(a) end collectgarbage() -- this will double delete unless the memory is managed properly a=disown.A() a:__disown() b:remove(a) a=nil collectgarbage() -- this will double delete unless the manual disown call worked swig-3.0.2/Examples/test-suite/lua/varargs_runme.lua0000664000175000017500000000111612343605122022365 0ustar williamwilliamrequire("import") -- the import fn import("varargs") -- import lib v=varargs -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(v.test("Hello") == "Hello") assert(v.test_def("Hello",0) == "Hello") assert(v.Foo.statictest("Hello") == "Hello") assert(v.Foo.statictest("Hello",1) == "Hello") assert(v.test_plenty("Hello") == "Hello") assert(v.test_plenty("Hello",1) == "Hello") assert(v.test_plenty("Hello",1,2) == "Hello") swig-3.0.2/Examples/test-suite/lua/template_construct_runme.lua0000664000175000017500000000053112343605122024637 0ustar williamwilliamrequire("import") -- the import fn import("template_construct") -- import lib into global tc=template_construct --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) foo = tc.Foo_int(1) swig-3.0.2/Examples/test-suite/lua/cpp_namespace_runme.lua0000664000175000017500000000121512343605122023516 0ustar williamwilliamrequire("import") -- the import fn import("cpp_namespace") -- import lib into global cn=cpp_namespace --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(cn.fact(4) == 24) assert(cn.Foo == 42) t1 = cn.Test() assert(t1:method() == "Test::method") cn.weird("t1", 4) assert(cn.do_method(t1) == "Test::method") assert(cn.do_method2(t1) == "Test::method") t2 = cn.Test2() assert(t2:method() == "Test2::method") assert(cn.foo3(5) == 5) assert(cn.do_method3(t2, 7) == "Test2::method") swig-3.0.2/Examples/test-suite/lua/arrays_global_runme.lua0000664000175000017500000000073412343605122023546 0ustar williamwilliamrequire("import") -- the import fn import("arrays_global") -- import lib ag = arrays_global -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(ag.BeginString_FIX44a == "FIX.a.a") assert(ag.BeginString_FIX44b == "FIX.b.b") assert(ag.BeginString_FIX44c == "FIX.c.c") assert(ag.BeginString_FIX44d == "FIX.d.d") swig-3.0.2/Examples/test-suite/lua/multi_import_runme.lua0000664000175000017500000000073312343605122023450 0ustar williamwilliamrequire("import") -- the import fn -- note: need to import the base class module before the derived class -- this is because if the derived class is imported first it doesn't get the base class methods import("multi_import_b") -- import code import("multi_import_a") -- import code x = multi_import_b.XXX() assert(x:testx() == 0) y = multi_import_b.YYY() assert(y:testx() == 0) assert(y:testy() == 1) z = multi_import_a.ZZZ() assert(z:testx() == 0) assert(z:testz() == 2) swig-3.0.2/Examples/test-suite/lua/global_vars_runme.lua0000664000175000017500000000146112343605122023216 0ustar williamwilliamrequire("import") -- the import fn import("global_vars") -- import lib gv = global_vars -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) gv.b = "abcde" assert(gv.b == "abcde") gv.a.x = 7 assert(gv.a.x == 7) a1 = gv.A() a1.x = 11 gv.a = a1 assert(gv.a.x == 11) gv.x = 10 assert(gv.x == 10) assert(gv.Hi ~= nil) assert(gv.Hola ~= nil) gv.h = gv.Hi assert(gv.h == gv.Hi) -- It is not clear whether these tests should work or not -- Currently they don't. -- -- assert(gv.c_member == 10) -- -- gv.c_member = 5 -- assert(gv.x == 5) -- -- gv.h = gv.Hi -- assert(gv.hr == gv.Hi) -- -- gv.hr = gv.Hola -- assert(gv.h == gv.Hola) -- assert(gv.hr == gv.Hola) swig-3.0.2/Examples/test-suite/lua/extend_typedef_class_runme.lua0000664000175000017500000000127012343605122025115 0ustar williamwilliamrequire("import") -- the import fn import("extend_typedef_class") -- import lib into global etc=extend_typedef_class --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) function test_obj(obj, const) obj.membervar = const assert(obj:getvar() == const) end a1 = etc.AClass() test_obj(a1,1) b1 = etc.BClass() test_obj(b1,2) c1 = etc.CClass() test_obj(c1,3) d1 = etc.DClass() test_obj(d1,4) a2 = etc.AStruct() test_obj(a2,5) b2 = etc.BStruct() test_obj(b2,6) c2 = etc.CStruct() test_obj(c2,7) d2 = etc.DStruct() test_obj(d2,8) swig-3.0.2/Examples/test-suite/lua/li_typemaps_runme.lua0000664000175000017500000000247512343605122023257 0ustar williamwilliamrequire("import") -- the import fn import("li_typemaps") -- import code -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) -- Check double INPUT typemaps assert(li_typemaps.in_double(22.22) == 22.22) assert(li_typemaps.inr_double(22.22) == 22.22) -- Check double OUTPUT typemaps assert(li_typemaps.out_double(22.22) == 22.22) assert(li_typemaps.outr_double(22.22) == 22.22) -- Check double INOUT typemaps assert(li_typemaps.inout_double(22.22) == 22.22) assert(li_typemaps.inoutr_double(22.22) == 22.22) -- check long long assert(li_typemaps.in_ulonglong(20)==20) assert(li_typemaps.inr_ulonglong(20)==20) assert(li_typemaps.out_ulonglong(20)==20) assert(li_typemaps.outr_ulonglong(20)==20) assert(li_typemaps.inout_ulonglong(20)==20) assert(li_typemaps.inoutr_ulonglong(20)==20) -- check bools assert(li_typemaps.in_bool(true)==true) assert(li_typemaps.inr_bool(false)==false) assert(li_typemaps.out_bool(true)==true) assert(li_typemaps.outr_bool(false)==false) assert(li_typemaps.inout_bool(true)==true) assert(li_typemaps.inoutr_bool(false)==false) -- the others a,b=li_typemaps.inoutr_int2(1,2) assert(a==1 and b==2) f,i=li_typemaps.out_foo(10) assert(f.a==10 and i==20) swig-3.0.2/Examples/test-suite/lua/exception_order_runme.lua0000664000175000017500000000223712343605122024116 0ustar williamwilliam-- demo of lua swig capacilities (operator overloading) require("import") -- the import fn import("exception_order") -- import lib into global eo=exception_order --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) a = eo.A() function try1() a:foo() end function try2() a:bar() end function try3() a:foobar() end -- the following code used to work -- but now no longer works, as the lua bindings don't throw objects any more -- all objects are converted to string & thrown -- it could be made to work, if E1 & E2 were thrown by value (see lua.swg) --[[ ok,ex=pcall(try1) print(ok,ex) assert(ok==false and swig_type(ex)==swig_type(eo.E1())) ok,ex=pcall(try2) assert(ok==false and swig_type(ex)==swig_type(eo.E2())) ]] -- this new code does work, but has to look at the string ok,ex=pcall(try1) assert(ok==false and ex=="object exception:E1") ok,ex=pcall(try2) assert(ok==false and ex=="object exception:E2") -- the SWIG_exception is just an error string ok,ex=pcall(try3) assert(ok==false and type(ex)=="string") swig-3.0.2/Examples/test-suite/lua/valuewrapper_runme.lua0000664000175000017500000000066512343605122023445 0ustar williamwilliamrequire("import") -- the import fn import("valuewrapper") -- import code v=valuewrapper -- renaming import -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(v.Xi ~= nil) assert(v.YXi ~= nil) x1 = v.Xi(5) y1 =v.YXi() assert(y1:spam(x1) == 0) assert(y1:spam() == 0) swig-3.0.2/Examples/test-suite/lua/extend_constructor_destructor_runme.lua0000664000175000017500000000143512343605122027136 0ustar williamwilliamrequire("import") -- the import fn import("extend_constructor_destructor") -- import lib into global ecd=extend_constructor_destructor --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) a1 = ecd.AStruct(101) assert(a1.ivar == 101) assert(ecd.globalVar == 101) b1 = ecd.BStruct(201) assert(b1.ivar == 201) assert(ecd.globalVar == 201) c1 = ecd.CStruct(301) assert(c1.ivar == 301) assert(ecd.globalVar == 301) d1 = ecd.DStruct(401) assert(d1.ivar == 401) assert(ecd.globalVar == 401) e1 = ecd.EStruct(501) assert(e1.ivar == 501) assert(ecd.globalVar == 501) f1 = ecd.FStruct(601) assert(f1.ivar == 601) assert(ecd.globalVar == 601) swig-3.0.2/Examples/test-suite/lua/Makefile.in0000664000175000017500000000315412343605122021060 0ustar williamwilliam####################################################################### # Makefile for lua test-suite ####################################################################### LANGUAGE = lua LUA = @LUABIN@ SCRIPTSUFFIX = _runme.lua srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ # sorry, currently very few test cases work/have been written CPP_TEST_CASES += \ lua_no_module_global \ C_TEST_CASES += \ lua_no_module_global \ include $(srcdir)/../common.mk # Overridden variables here LIBS = -L. # Custom tests - tests with additional commandline options lua_no_module_global.%: SWIGOPT += -nomoduleglobal # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.lua appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LUA_PATH="$(srcdir)/?.lua;" $(RUNTOOL) $(LUA) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra lua code) %.clean: @exit 0 clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" lua_clean cvsignore: @echo '*wrap* *.so *.dll *.exp *.lib' @echo Makefile @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.lua; done @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.lua CVS/Entries ; then echo $${i}_runme.lua; fi; done swig-3.0.2/Examples/test-suite/lua/keyword_rename_runme.lua0000664000175000017500000000062012343605122023732 0ustar williamwilliamrequire("import") -- the import fn import("keyword_rename") -- import lib into global kn=keyword_rename--alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) -- Check renaming of Lua keywords assert(kn.c_end(5) == 5) assert(kn.c_nil(7) == 7) swig-3.0.2/Examples/test-suite/lua/array_member_runme.lua0000664000175000017500000000133612343605122023371 0ustar williamwilliamrequire("import") -- the import fn import("array_member") -- import lib am = array_member -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) assert(am.get_value(am.global_data,0) == 0) assert(am.get_value(am.global_data,7) == 7) foo = am.Foo() foo.data = am.global_data assert(am.get_value(foo.data,0) == 0) for i = 0, 7 do assert(am.get_value(foo.data,i) == am.get_value(am.global_data,i)) end for i = 0, 7 do am.set_value(am.global_data,i,-i) end am.global_data = foo.data for i = 0, 7 do assert(am.get_value(foo.data,i) == am.get_value(am.global_data,i)) end swig-3.0.2/Examples/test-suite/lua/smart_pointer_overload_runme.lua0000664000175000017500000000066112343605122025505 0ustar williamwilliamrequire("import") -- the import fn import("smart_pointer_overload") -- import code for k,v in pairs(smart_pointer_overload) do _G[k]=v end -- move to global f = Foo() b = Bar(f) assert(f:test(3) == 1) --assert(f:test(3.5) == 2) -- won't work due to being unable to overloads assert(f:test("hello") == 3) assert(b:test(3) == 1) --assert(b:test(3.5) == 2) -- won't work due to being unable to overloads assert(b:test("hello") == 3) swig-3.0.2/Examples/test-suite/lua/smart_pointer_rename_runme.lua0000664000175000017500000000076712343605122025150 0ustar williamwilliamrequire("import") -- the import fn import("smart_pointer_rename") -- import lib into global spr=smart_pointer_rename --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) foo = spr.Foo() assert(foo:ftest1(1) == 1) assert(foo:ftest2(1,2) == 2) bar = spr.Bar(foo) assert(bar:test() == 3) assert(bar:ftest1(1) == 1) assert(bar:ftest2(1,2) == 2) swig-3.0.2/Examples/test-suite/lua/import.lua0000664000175000017500000000152312343605122021026 0ustar williamwilliam-- import -- the lua 5.0 loading mechanism is rather poor & relies upon the loadlib() fn -- the lua 5.1 loading mechanism is simplicity itself -- for now we need a bridge which will use the correct version function import_5_0(name) -- imports the file into the program -- for a module 'example' -- this must load 'example.dll' or 'example.so' -- and look for the fn 'luaopen_example()' if rawget(_G,name)~=nil then return end -- module appears to be loaded local lib=loadlib(name..'.dll','luaopen_'..name) or loadlib(name..'.so','luaopen_'..name) assert(lib,"error loading module:"..name) lib() -- execute the function: initialising the lib assert(rawget(_G,name)~=nil,"no module table found") end function import_5_1(name) require(name) end if string.sub(_VERSION,1,7)=='Lua 5.0' then import=import_5_0 else import=import_5_1 end swig-3.0.2/Examples/test-suite/lua/fvirtual_runme.lua0000664000175000017500000000073412343605122022561 0ustar williamwilliamrequire("import") -- the import fn import("fvirtual") -- import lib into global f=fvirtual --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) n1 = f.Node() n2 = f.Node() assert(n1:addChild(n2) == 1) ns = f.NodeSwitch() assert(ns:addChild(n2) == 2) assert(ns:addChild(ns) == 2) assert(ns:addChild(n1, false) == 3) swig-3.0.2/Examples/test-suite/lua/imports_runme.lua0000664000175000017500000000202312343605122022413 0ustar williamwilliamrequire("import") -- the import fn -- need to load two modules import("imports_a") -- import code import("imports_b") -- import code b=imports_b.B() b:hello() -- call member function in A which is in a different SWIG generated library. b:bye() assert (b:member_virtual_test(imports_a.A_memberenum1) == imports_a.A_memberenum2) assert (b:global_virtual_test(imports_a.globalenum1) == imports_a.globalenum2) imports_b.global_test(imports_a.A_memberenum1) --[[ B b = new B(); b.hello(); //call member function in A which is in a different SWIG generated library. B b = new B(); b.hello(); //call member function in A which is in a different SWIG generated library. b.bye(); if (b.member_virtual_test(A.MemberEnum.memberenum1) != A.MemberEnum.memberenum2) throw new Exception("Test 1 failed"); if (b.global_virtual_test(GlobalEnum.globalenum1) != GlobalEnum.globalenum2) throw new Exception("Test 2 failed"); imports_b.global_test(A.MemberEnum.memberenum1); ]] swig-3.0.2/Examples/test-suite/lua/char_strings_runme.lua0000664000175000017500000000065512343605122023415 0ustar williamwilliamrequire("import") -- the import fn import("char_strings") -- import code assert (char_strings.CharPingPong("hi there") == "hi there") assert (char_strings.CharPingPong(nil) == nil) assert (char_strings.CharArrayPingPong("hi there") == "hi there") assert (char_strings.CharArrayPingPong(nil) == nil) assert (char_strings.CharArrayDimsPingPong("hi there") == "hi there") assert (char_strings.CharArrayDimsPingPong(nil) == nil) swig-3.0.2/Examples/test-suite/lua/smart_pointer_not_runme.lua0000664000175000017500000000134612343605122024473 0ustar williamwilliamrequire("import") -- the import fn import("smart_pointer_not") -- import lib into global spn=smart_pointer_not --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) foo = spn.Foo() foo.x = 7 assert(foo:getx() == 7) bar = spn.Bar(foo) success = pcall(bar.getx, bar) -- Bar is not a smart pointer. Call should fail assert(not success) spam = spn.Spam(foo) success = pcall(spam.getx, spam) -- Spam is not a smart pointer. Call should fail assert(not success) grok = spn.Grok(foo) success = pcall(grok.getx, grok) -- Spam is not a smart pointer. Call should fail assert(not success) swig-3.0.2/Examples/test-suite/lua/pointer_reference_runme.lua0000664000175000017500000000053412343605122024421 0ustar williamwilliamrequire("import") -- the import fn import("pointer_reference",true) -- import code s=pointer_reference.get() assert(s.value == 10) ss = pointer_reference.Struct(20); pointer_reference.set(ss); assert(pointer_reference.Struct_instance.value == 20) assert(pointer_reference.overloading(1) == 111) assert(pointer_reference.overloading(ss) == 222) swig-3.0.2/Examples/test-suite/lua/smart_pointer_templatemethods_runme.lua0000664000175000017500000000123312343605122027065 0ustar williamwilliamrequire("import") -- the import fn import("smart_pointer_templatemethods") -- import lib into global spt=smart_pointer_templatemethods --alias -- catching undefined variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) o1 = spt.Objct() iid = spt.InterfaceId() po2 = o1:QueryInterfaceObjct(iid) -- we can't call po2:DisposeObjct, because smart pointer Ptr always return 0 when dereferencing -- (see interface file). So we only check that po2 has necessary method assert(po2.DisposeObjct ~= nil) assert(po2.QueryInterfaceObjct ~= nil) swig-3.0.2/Examples/test-suite/lua/nspace_runme.lua0000664000175000017500000000542512343605122022200 0ustar williamwilliamrequire("import") -- the import fn import("nspace") -- import lib -- catch "undefined" global variables local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) ns = nspace -- Inheritance blue1 = ns.Outer.Inner3.Blue() -- blue1:blueInstanceMethod() blue1:colorInstanceMethod(60.0) blue1.instanceMemberVariable = 4 assert( blue1.instanceMemberVariable == 4 ) -- Constructors color1 = ns.Outer.Inner1.Color() color2 = ns.Outer.Inner1.Color.create() color = ns.Outer.Inner1.Color(color1) color3 = ns.Outer.Inner2.Color.create() color4 = ns.Outer.Inner2.Color.create() color5 = ns.Outer.Inner2.Color.create() mwp2 = ns.Outer.MyWorldPart2() gc = ns.GlobalClass() nnsp = ns.NoNSpacePlease() -- Class methods color:colorInstanceMethod(20.0) ns.Outer.Inner1.Color.colorStaticMethod(30.0) color3:colorInstanceMethod(40.0) ns.Outer.Inner2.Color.colorStaticMethod(50.0) color3:colors(color1, color2, color3, color4, color5) gc:gmethod() -- Class variables color.instanceMemberVariable = 5 color1.instanceMemberVariable = 7 assert( color.instanceMemberVariable == 5 ) assert( color1.instanceMemberVariable == 7 ) assert(ns.Outer.Inner1.Color.staticMemberVariable == 0 ) assert(ns.Outer.Inner2.Color.staticMemberVariable == 0 ) ns.Outer.Inner1.Color.staticMemberVariable = 9 ns.Outer.Inner2.Color.staticMemberVariable = 11 assert(ns.Outer.Inner1.Color.staticMemberVariable == 9) assert(ns.Outer.Inner2.Color.staticMemberVariable == 11) -- Class constants assert( ns.Outer.Inner1.Color.Specular == 0x20 ) assert( ns.Outer.Inner2.Color.Specular == 0x40 ) assert( ns.Outer.Inner1.Color.staticConstMemberVariable == 222 ) assert( ns.Outer.Inner2.Color.staticConstMemberVariable == 333 ) assert( ns.Outer.Inner1.Color.staticConstEnumMemberVariable ~= ns.Outer.Inner2.Color.staticConstEnumMemberVariable ) -- Aggregation sc = ns.Outer.SomeClass() assert( sc:GetInner1ColorChannel() ~= sc:GetInner2Channel() ) assert( sc:GetInner1Channel() ~= sc:GetInner2Channel() ) -- Backward compatibility assert(ns.Outer.Inner1.Diffuse ~= nil) -- Enums within class within namespace shouldn't have backward compatible name. Same for static methods assert(ns.Outer.Inner1.Color_Diffuse == nil) assert(ns.Outer.Inner1.Color_colorStaticMethod == nil) -- Enums and static methods of class marked as %nonspace should have backward compatible name assert(ns.NoNSpacePlease_noNspaceStaticFunc() == 10) assert(ns.Outer.Inner2.NoNSpacePlease_NoNspace == nil) -- ReallyNoNSpaceEnum is wrapped into %nonspace and thus handled correctly. -- NoNSpaceEnum is not (although both of them are in %nonspace-wrapped class) and thus -- handled rather unexpectedly assert(ns.NoNSpacePlease_ReallyNoNspace1 == 1) assert(ns.NoNSpacePlease.ReallyNoNspace2 == 10) swig-3.0.2/Examples/test-suite/mzscheme/0000775000175000017500000000000012343605122020042 5ustar williamwilliamswig-3.0.2/Examples/test-suite/mzscheme/README0000664000175000017500000000020712343605122020721 0ustar williamwilliamSee ../README for common README file. Any testcases which have _runme.scm appended after the testcase name will be detected and run. swig-3.0.2/Examples/test-suite/mzscheme/char_constant_runme.scm0000664000175000017500000000020012343605122024572 0ustar williamwilliam(load-extension "char_constant.so") (if (and (char? (CHAR-CONSTANT)) (string? (STRING-CONSTANT))) (exit 0) (exit 1)) swig-3.0.2/Examples/test-suite/mzscheme/unions_runme.scm0000664000175000017500000000211712343605122023270 0ustar williamwilliam;;; This is the union runtime testcase. It ensures that values within a ;;; union embedded within a struct can be set and read correctly. (load-extension "unions.so") ;; Create new instances of SmallStruct and BigStruct for later use (define small (new-SmallStruct)) (SmallStruct-jill-set small 200) (define big (new-BigStruct)) (BigStruct-smallstruct-set big small) (BigStruct-jack-set big 300) ;; Use SmallStruct then BigStruct to setup EmbeddedUnionTest. ;; Ensure values in EmbeddedUnionTest are set correctly for each. (define eut (new-EmbeddedUnionTest)) ;; First check the SmallStruct in EmbeddedUnionTest (EmbeddedUnionTest-number-set eut 1) (EmbeddedUnionTest-uni-small-set (EmbeddedUnionTest-uni-get eut) small) (let ((Jill1 (SmallStruct-jill-get (EmbeddedUnionTest-uni-small-get (EmbeddedUnionTest-uni-get eut))))) (if (not (= Jill1 200)) (begin (display "Runtime test 1 failed.") (exit 1)))) (let ((Num1 (EmbeddedUnionTest-number-get eut))) (if (not (= Num1 1)) (begin (display "Runtime test 2 failed.") (exit 1)))) ;; that should do (exit 0) swig-3.0.2/Examples/test-suite/mzscheme/imports_runme.scm0000664000175000017500000000074412343605122023456 0ustar williamwilliam;;; This file is part of a test for SF bug #231619. ;;; It shows that the %import directive does not work properly in SWIG ;;; 1.3a5: Type information is not properly generated if a base class ;;; comes from an %import-ed file. (load-extension "imports_a.so") (load-extension "imports_b.so") (define x (new-B)) ;; This fails in 1.3a5 because the SWIG runtime code does not know ;; that x (an instance of class B) can be passed to methods of class A. (A-hello x) (exit 0) swig-3.0.2/Examples/test-suite/mzscheme/name_runme.scm0000664000175000017500000000040312343605122022671 0ustar williamwilliam;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. (load-extension "./name.so") (foo-2) bar-2 Baz-2 (exit 0) swig-3.0.2/Examples/test-suite/mzscheme/casts_runme.scm0000664000175000017500000000011312343605122023064 0ustar williamwilliam(load-extension "casts.so") (define x (new-B)) (A-hello x) (exit 0) swig-3.0.2/Examples/test-suite/mzscheme/integers_runme.scm0000664000175000017500000000032712343605122023576 0ustar williamwilliam(load-extension "integers.so") (require (lib "defmacro.ss")) (define-macro (throws-exception? form) `(with-handlers ((not-break-exn? (lambda (exn) #t))) ,form #f)) (load "../schemerunme/integers.scm") swig-3.0.2/Examples/test-suite/mzscheme/Makefile.in0000664000175000017500000000221012343605122022102 0ustar williamwilliam####################################################################### # Makefile for mzscheme test-suite ####################################################################### LANGUAGE = mzscheme MZSCHEME = mzscheme SCRIPTSUFFIX = _runme.scm srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ include $(srcdir)/../common.mk # Overridden variables here # none! # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.scm appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(MZSCHEME) -r $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean %.clean: @exit 0 clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" mzscheme_clean swig-3.0.2/Examples/test-suite/chicken_ext_test.i0000664000175000017500000000071712343605122021731 0ustar williamwilliam%module chicken_ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ #include "imports_a.h" %} %include "imports_a.h" %{ void test_create(C_word,C_word,C_word) C_noret; %} %init %{ { C_word *space = C_alloc(2 + C_SIZEOF_INTERNED_SYMBOL(11)); sym = C_intern (&space, 11, "test-create"); C_mutate ((C_word*)sym+1, (*space=C_CLOSURE_TYPE|1, space[1]=(C_word)test_create, tmp=(C_word)space, space+=2, tmp)); } %} swig-3.0.2/Examples/test-suite/template_methods.i0000664000175000017500000000551612343605122021746 0ustar williamwilliam// Test %ignore and %rename for templated methods %module template_methods %warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve1(); %warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve3(); %include /////////////////// %ignore convolve1(float a); %inline %{ template int convolve1() { return 0; } template void convolve1(ImageT a) { ImageT t = a; (void)t; } %} %template() convolve1; %template(convolve1Bool) convolve1; /////////////////// %ignore convolve2(float a); %inline %{ template int convolve2() { return 0; } template void convolve2(ImageT a) { ImageT t = a; (void)t; } %} %template(convolve2Float) convolve2; /////////////////// %rename(convolve3FloatRenamed) convolve3(float a); %inline %{ template int convolve3() { return 0; } template void convolve3(ImageT a) { ImageT t = a; (void)t; } %} %template() convolve3; /////////////////// %rename(convolve4FloatRenamed) convolve4(float a); %inline %{ template int convolve4() { return 0; } template void convolve4(ImageT a) { ImageT t = a; (void)t; } %} %template(convolve4Float) convolve4; /////////////////// %rename(convolve5FloatRenamed) convolve5; %ignore convolve5; %inline %{ template int convolve5() { return 0; } template void convolve5(ImageT a) { ImageT t = a; (void)t; } %} %template() convolve5; %template() convolve5; //////////////////////////////////////////////////////////////////////////// %rename(KlassTMethodBoolRenamed) Klass::tmethod(bool); %rename(KlassStaticTMethodBoolRenamed) Klass::statictmethod(bool); %inline %{ struct Klass { template X tmethod(X x) { return x; } template void tmethod() {} template static X statictmethod(X x) { return x; } template static void statictmethod() {} }; %} %template(KlassTMethodBool) Klass::tmethod; %template(KlassStaticTMethodBool) Klass::statictmethod; //////////////////////////////////////////////////////////////////////////// %inline %{ class ComponentProperties{ public: ComponentProperties() {} ~ComponentProperties() {} template void adda(std::string key, T1 val) {} template void adda(std::string key1, T1 val1, std::string key2, T2 val2) {} template void adda(std::string key1, T1 val1, std::string key2, T2 val2, std::string key3, T3 val3) {} }; %} %extend ComponentProperties { %template(adda) adda; %template(adda) adda; // ERROR OCCURS HERE %template(adda) adda; } swig-3.0.2/Examples/test-suite/java_enums.i0000664000175000017500000000323412343605122020533 0ustar williamwilliam // This testcase uses the %javaconst directive to control how enums are initialised %module java_enums %include "enumtypeunsafe.swg" // Some pragmas to add in an interface to the module class %pragma(java) moduleinterfaces="Serializable" %pragma(java) moduleimports=%{ import java.io.*; // For Serializable %} %pragma(java) modulecode=%{ public static final long serialVersionUID = 0x52151001; // Suppress ecj warning %} // Set default Java const code generation %javaconst(1); // Change the default generation so that these enums are generated into an interface instead of a class %typemap(javaclassmodifiers) enum stuff "public interface" %inline %{ enum stuff { FIDDLE = 2*100, STICKS = 5+8, BONGO, DRUMS }; %} // Check that the enum typemaps are working by using a short for the enums instead of int %javaconst(0); // will create compile errors in runme file if short typemaps not used namespace Space { %typemap(jtype) enum nonsense "short" %typemap(jstype) enum nonsense "short" %typemap(javain) enum nonsense "$javainput" %typemap(in) enum nonsense %{ $1 = (enum Space::nonsense)$input; %} %typemap(out) enum nonsense %{ $result = (jshort)$1; %} %typemap(jni) enum nonsense "jshort" %typemap(javaout) enum nonsense { return $jnicall; } } %inline %{ namespace Space { enum nonsense { POPPYCOCK, JUNK }; nonsense test1(nonsense n) { return n; } enum nonsense test2(enum nonsense n) { return n; } } %} // Test the %javaconstvalue directive for enums %{ static const int FOUR = 4; %} %javaconst(1); %javaconstvalue(4) Quattro; %inline %{ enum Numero { Quattro = FOUR }; %} // Test boolean enums %inline %{ typedef enum { PLAY = true, STOP = false } play_state; %} swig-3.0.2/Examples/test-suite/namespace_class.i0000664000175000017500000001046412343605122021527 0ustar williamwilliam%module namespace_class %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Ala::Ola; #ifdef SWIGD %warnfilter(SWIGWARN_IGNORE_OPERATOR_LT); #endif %inline %{ template void foobar(T t) {} namespace test { template void barfoo(T t) {} } %} %template(FooBarInt) ::foobar; %template(BarFooInt) test::barfoo; %inline %{ template struct Bar_T { }; namespace test { enum Hello { Hi }; struct Test; struct Bar { Hello foo(Hello h) { return h; } }; namespace hola { struct Bor; struct Foo; struct Foobar; template struct BarT { }; template class FooT; } template class hola::FooT { public: Hello foo(Hello h) { return h; } T bar(T h) { return h; } }; namespace hola { template <> class FooT; template <> class FooT; } template <> class hola::FooT { public: double moo(double h) { return h; } }; int a; struct hola::Foo : Bar { Hello bar(Hello h) { return h; } }; } struct test::Test { Hello foo(Hello h) { return h; } }; struct test::hola::Bor { Hello foo(Hello h) { return h; } }; namespace test { struct hola::Foobar : Bar { Hello bar(Hello h) { return h; } }; } template <> class test::hola::FooT { public: int quack(int h) { return h; } }; %} namespace test { namespace hola { %template(FooT_i) FooT; } %template(FooT_H) hola::FooT; } %template(FooT_d) ::test::hola::FooT; %template(BarT_H) test::hola::BarT; %inline %{ namespace hi { namespace hello { template struct PooT; } namespace hello { template struct PooT { }; } } %} %template(Poo_i) hi::hello::PooT; %inline %{ template struct BooT { }; namespace test { typedef ::BooT BooT_H; } %} namespace test { %template(BooT_H) ::BooT; } %template(BooT_i) ::BooT; %inline %{ namespace jafar { namespace jmath { class EulerT3D { public: static void hello(){} template static void toFrame(const VecFrame& frame_, const Vec&v_,const VecRes& vRes){} template void operator ()(T& x){} template void operator < (T& x){} template operator Bar_T () {} }; } } %} %template(toFrame) jafar::jmath::EulerT3D::toFrame; %template(callint) jafar::jmath::EulerT3D::operator(); %template(lessint) jafar::jmath::EulerT3D::operator < ; %template(callfooi) jafar::jmath::EulerT3D::operator() >; %template(lessfooi) jafar::jmath::EulerT3D::operator < < test::hola::FooT >; %inline %{ namespace { /* the unnamed namespace is 'private', so, the following declarations shouldn't be wrapped */ class Private1 { }; } namespace a { namespace { class Private2 { }; } } %} %inline %{ class Ala { public : Ala() {} class Ola { public: Ola() {} void eek() {} }; template static void hi() { } }; %} %template(hi) Ala::hi; %extend jafar::jmath::EulerT3D { } %rename(FLACFile) TagLib::FLAC::File; %inline { namespace TagLib { class File { public: File() {} }; class AudioProperties { }; class AudioPropertiesFile { public: typedef TagLib::File File; }; namespace FLAC { class File; class Properties : public AudioProperties { public: Properties(File *) {} }; class PropertiesFile : public AudioPropertiesFile { public: PropertiesFile(File * = 0) {} }; namespace bar { class PropertiesFree : public AudioProperties { public: PropertiesFree(File *) {} }; } class FooFilePrivate : private PropertiesFile { public: FooFilePrivate(File *) {} }; class FooFile : public PropertiesFile { public: FooFile(File *) {} }; class File { public: File() {} }; } } } swig-3.0.2/Examples/test-suite/template_enum_ns_inherit.i0000664000175000017500000000164412343605122023467 0ustar williamwilliam%module template_enum_ns_inherit %inline %{ namespace oss { enum Polarization { UnaryPolarization, BinaryPolarization }; template struct Interface_ { }; template struct Module { }; } %} namespace oss { %template(Interface_UP) Interface_; %template(Module_UPIUP) Module >; } %inline %{ namespace oss { namespace hello { struct HInterface1 : Interface_ // this works (with fullns qualification) { }; struct HInterface2 : Interface_ // this doesn't work { }; struct HModule1 : Module > { }; } } %} swig-3.0.2/Examples/test-suite/cpp11_default_delete.i0000664000175000017500000000425612343605122022362 0ustar williamwilliam/* This testcase checks whether SWIG correctly parses C++11 explicitly defaulted functions and deleted functions */ %module cpp11_default_delete %warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::trivial(trivial&&); %warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::operator =(trivial&&); %rename(Assignment) *::operator=; %inline %{ class NonCopyable { public: NonCopyable& operator=(const NonCopyable&) = delete; /* Removes operator= */ NonCopyable(const NonCopyable&) = delete; /* Removed copy constructor */ NonCopyable() = default; /* Explicitly allows the empty constructor */ void *operator new(size_t) = delete; /* Removes new NonCopyable */ }; struct A1 { void func(int i) {} A1() = default; ~A1() = default; void func(double i) = delete; /* Don't cast double to int. Compiler returns an error */ private: A1(const A1&); }; A1::A1(const A1&) = default; struct A2 { void func(int i) {} virtual void fff(int) = delete; virtual ~A2() = default; template void func(T) = delete; }; struct trivial { trivial() = default; trivial(const trivial&) = default; trivial(trivial&&) = default; trivial& operator=(const trivial&) = default; trivial& operator=(trivial&&) = default; ~trivial() = default; }; struct nontrivial1 { nontrivial1(); }; nontrivial1::nontrivial1() = default; struct sometype { sometype() = delete; sometype(int) = delete; sometype(double); }; sometype::sometype(double) {} /* Not working with prerelease of gcc-4.8 struct nonew { void *operator new(std::size_t) = delete; void *operator new[](std::size_t) = delete; }; */ struct moveonly { moveonly() = default; moveonly(const moveonly&) = delete; moveonly(moveonly&&) = default; moveonly& operator=(const moveonly&) = delete; moveonly& operator=(moveonly&&) = default; ~moveonly() = default; }; struct ConstructorThrow { ConstructorThrow() throw() = default; ConstructorThrow(const ConstructorThrow&) throw() = delete; ConstructorThrow(ConstructorThrow&&) throw() = delete; ConstructorThrow& operator=(const ConstructorThrow&) throw() = delete; ~ConstructorThrow() throw() = default; }; %} swig-3.0.2/Examples/test-suite/nested.i0000664000175000017500000000174012343605122017665 0ustar williamwilliam/* This testcase tests that nested structs/unions work. Named structs/unions declared within a struct produced redefinition errors in SWIG 1.3.6 as reported by SF bug #447488. Also tests reported error when a #define placed in a deeply embedded struct/union. */ %module nested %inline %{ struct TestStruct { int a; }; struct OuterStructNamed { struct InnerStructNamed { double dd; } inner_struct_named; union InnerUnionNamed { double ee; int ff; } inner_union_named; }; struct OuterStructUnnamed { struct { double xx; } inner_struct_unnamed; union { double yy; int zz; } inner_union_unnamed; }; typedef struct OuterStruct { union { struct outer_nested_struct { union inner_nested_union { #define BAD_STYLE 1 int red; struct TestStruct green; } InnerNestedUnion; struct inner_nested_struct { int blue; } InnerNestedStruct; } OuterNestedStruct; } EmbeddedUnion; } OuterStruct; %} swig-3.0.2/Examples/test-suite/destructor_reprotected.i0000664000175000017500000000044312343605122023200 0ustar williamwilliam%module destructor_reprotected %inline { struct A { A() { } virtual ~A() { } }; struct B : A { protected: B() { } ~B() { } }; struct C : B { C() { } ~C() { } }; } swig-3.0.2/Examples/test-suite/director_protected.i0000664000175000017500000000411212343605122022263 0ustar williamwilliam%module(directors="1",dirprot="1") director_protected %{ #include #include %} %include "std_string.i" %feature("director") Foo; %feature("director") Bar; %newobject *::create(); #ifdef SWIGPHP // TODO: Currently we do not track the dynamic type of returned objects // in PHP, so we need the factory helper. %include factory.i %factory(Foo *Bar::create, Bar); #endif %rename(a) Bar::hello; %rename(s) Foo::p; %rename(q) Foo::r; %inline { class Foo { public: virtual ~Foo() {} virtual std::string pong() { return "Foo::pong();" + ping(); } int p(){ return 1;} int r(){ return 1;} protected: typedef int q(); static int s(); Foo() {} virtual std::string ping() = 0; virtual std::string pang() { return "Foo::pang();"; } void hellom() {} virtual std::string used() { return pang() + pong(); } virtual std::string cheer() { return pang() + pong(); } }; class Bar : public Foo { public: Foo* create() { return new Bar(); } std::string callping() { return ping(); } std::string callcheer() { return cheer(); } std::string pong() { return "Bar::pong();" + Foo::pong(); } int hello; using Foo::used; protected: std::string ping() { return "Bar::ping();"; }; using Foo::cheer; enum Hello {hola, chao}; static int a; static const int b; int hi; void him() {} private: int c; }; class PrivateFoo : private Foo { }; } %director A; %director B; %inline %{ class A { public: A() {}; virtual ~A() {}; protected: virtual void draw() {}; }; class B : public A { public: B() {}; virtual ~B() {}; protected: void draw() {}; void draw(int arg1) {}; }; %} %cleardirector; %inline %{ class AA { public: AA() {}; virtual ~AA() {}; protected: virtual void draw() {}; virtual void plot() {}; }; class BB : public AA { public: BB() {}; virtual ~BB() {}; protected: void draw() {}; void draw(int arg1) {}; void plot(int arg1) {}; void plot() {}; }; %} swig-3.0.2/Examples/test-suite/li_factory.i0000664000175000017500000000203312343605122020532 0ustar williamwilliam%module li_factory %include factory.i %newobject Geometry::create; %newobject Geometry::clone; %factory(Geometry *Geometry::create, Point, Circle); %factory(Geometry *Geometry::clone, Point, Circle); #ifdef SWIGPHP %rename(clone_) clone; #endif %factory(Geometry *Point::clone, Point, Circle); %factory(Geometry *Circle::clone, Point, Circle); %inline { struct Geometry { enum GeomType{ POINT, CIRCLE }; virtual ~Geometry() {} virtual int draw() = 0; static Geometry *create(GeomType i); virtual Geometry *clone() = 0; }; struct Point : Geometry { int draw() { return 1; } double width() { return 1.0; } Geometry *clone() { return new Point(); } }; struct Circle : Geometry { int draw() { return 2; } double radius() { return 1.5; } Geometry *clone() { return new Circle(); } }; Geometry *Geometry::create(GeomType type) { switch (type) { case POINT: return new Point(); case CIRCLE: return new Circle(); default: return 0; } } } swig-3.0.2/Examples/test-suite/li_std_string_extra.i0000664000175000017500000000152512343605122022453 0ustar williamwilliam%module li_std_string_extra %naturalvar A; %include %include %inline %{ struct A : std::string { A(const std::string& s) : std::string(s) { } }; struct B { B(const std::string& s) : cname(0), name(s), a(s) { } char *cname; std::string name; A a; }; const char* test_ccvalue(const char* x) { return x; } char* test_cvalue(char* x) { return x; } std::basic_string test_value_basic1(std::basic_string x) { return x; } std::basic_string > test_value_basic2(std::basic_string > x) { return x; } std::basic_string,std::allocator > test_value_basic3(std::basic_string,std::allocator > x) { return x; } %} %include "li_std_string.i" swig-3.0.2/Examples/test-suite/template_specialization_enum.i0000664000175000017500000000171012343605122024335 0ustar williamwilliam%module template_specialization_enum %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hello; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hi; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'hello due to Go name ('Hello) conflict with 'Hello' */ %inline %{ enum Hello { hi, hello }; template struct C { }; template struct Base { }; template struct C : Base { int fhello() { return hello; } protected: C() { } }; template struct C : Base { int fhi() { return hi; } protected: C() { } }; %} %template(Base_dd) Base; %template(Base_ii) Base; %template(C_i) C; %template(C_d) C; swig-3.0.2/Examples/test-suite/preproc_include_b.h0000664000175000017500000000014612343605122022057 0ustar williamwilliam int multiply20(int a); #define PREPROC_INCLUDE_C "preproc_include_c.h" #include PREPROC_INCLUDE_C swig-3.0.2/Examples/test-suite/argout.i0000664000175000017500000000144612343605122017707 0ustar williamwilliam/* This interface file checks how well SWIG handles passing data back through arguments WITHOUT returning it separately; for the cases where maybe multiple values are passed by reference and all want changing */ %module argout %include cpointer.i %pointer_functions(int,intp); %inline %{ // returns old value int incp(int *value) { return (*value)++; } // returns old value int incr(int &value) { return value++; } typedef int & IntRef; // returns old value int inctr(IntRef value) { return value++; } // example of the old DB login type routines where you keep // a void* which it points to its opaque struct when you login // So login function takes a void** void voidhandle(void** handle) { *handle=(void*)"Here it is"; } char * handle(void* handle) { return (char *)handle; } %} swig-3.0.2/Examples/test-suite/ocaml/0000775000175000017500000000000012343605122017322 5ustar williamwilliamswig-3.0.2/Examples/test-suite/ocaml/minherit_runme.ml0000664000175000017500000000720712343605122022707 0ustar williamwilliam(* Stolen from the python tests *) open Swig open Minherit let a = new_Foo C_void let b = new_Bar C_void let c = new_FooBar C_void let d = new_Spam C_void let soci x = (string_of_int (get_int x)) let _ = if (invoke a) "xget" C_void <> (C_int 1) then raise (Failure "Bad attribute value (a.xget)") let _ = if (invoke b) "yget" C_void <> (C_int 2) then raise (Failure "Bad attribute value (b.yget)") let _ = if (invoke c) "xget" C_void <> (C_int 1) || (invoke c) "yget" C_void <> (C_int 2) || (invoke c) "zget" C_void <> (C_int 3) then raise (Failure "Bad attribute value c") let _ = if (invoke d) "xget" C_void <> (C_int 1) || (invoke d) "yget" C_void <> (C_int 2) || (invoke d) "zget" C_void <> (C_int 3) || (invoke d) "wget" C_void <> (C_int 4) then raise (Failure "Bad attribute value d") let xga = _xget a let _ = if xga <> (C_int 1) then raise (Failure ("Bad attribute value (xget a): " ^ (soci xga))) let ygb = _yget b let _ = if ygb <> (C_int 2) then raise (Failure ("Bad attribute value (yget b): " ^ (string_of_int (get_int ygb)))) let xgc = _xget c and ygc = _yget c and zgc = _zget c let _ = if xgc <> (C_int 1) || ygc <> (C_int 2) || zgc <> (C_int 3) then raise (Failure ("Bad attribute value (xgc=" ^ (soci xgc) ^ " (sb 1) ygc=" ^ (soci ygc) ^ " (sb 2) zgc=" ^ (soci zgc) ^ " (sb 3))")) let xgd = _xget d and ygd = _yget d and zgd = _zget d and wgd = _wget d let _ = if xgd <> (C_int 1) || ygd <> (C_int 2) || zgd <> (C_int 3) || wgd <> (C_int 4) then raise (Failure ("Bad attribute value (xgd=" ^ (soci xgd) ^ " (sb 1) ygd=" ^ (soci ygd) ^ " (sb 2) zgd=" ^ (soci zgd) ^ " (sb 3)")) (* Cleanse all of the pointers and see what happens *) let aa = _toFooPtr a let bb = _toBarPtr b let cc = _toFooBarPtr c let dd = _toSpamPtr d let xgaa = (invoke aa) "xget" C_void let _ = if xgaa <> (C_int 1) then raise (Failure ("Bad attribute value xgaa " ^ (soci xgaa))) let ygbb = (invoke bb) "yget" C_void let _ = if ygbb <> (C_int 2) then raise (Failure ("Bad attribute value ygbb " ^ (soci ygbb))) let xgcc = (invoke cc) "xget" C_void and ygcc = (invoke cc) "yget" C_void and zgcc = (invoke cc) "zget" C_void let _ = if xgcc <> (C_int 1) || ygcc <> (C_int 2) || zgcc <> (C_int 3) then raise (Failure ("Bad attribute value (" ^ (soci xgcc) ^ " (sb 1) " ^ (soci ygcc) ^ " (sb 2) " ^ (soci zgcc) ^ " (sb 3))")) let xgdd = (invoke dd) "xget" C_void and ygdd = (invoke dd) "yget" C_void and zgdd = (invoke dd) "zget" C_void and wgdd = (invoke dd) "wget" C_void let _ = if xgdd <> (C_int 1) || ygdd <> (C_int 2) || zgdd <> (C_int 3) || wgdd <> (C_int 4) then raise (Failure ("Bad value: " ^ "xgdd=" ^ (soci xgdd) ^ "ygdd=" ^ (soci ygdd) ^ "zgdd=" ^ (soci zgdd) ^ "wgdd=" ^ (soci wgdd))) let xgaa = _xget aa and ygbb = _yget bb and xgcc = _xget cc and ygcc = _yget cc and zgcc = _zget cc and xgdd = _xget dd and ygdd = _yget dd and zgdd = _zget dd and wgdd = _wget dd let _ = if xgaa <> (C_int 1) then raise (Failure ("Fn xget: xgaa=" ^ (soci xgaa))) let _ = if ygbb <> (C_int 2) then raise (Failure ("Fn yget: ygbb=" ^ (soci ygbb))) let _ = if xgcc <> (C_int 1) || ygcc <> (C_int 2) || zgcc <> (C_int 3) then raise (Failure ("CC with fns: (" ^ (soci xgcc) ^ " " ^ (soci ygcc) ^ " " ^ (soci zgcc))) let _ = if xgdd <> (C_int 1) || ygdd <> (C_int 2) || zgdd <> (C_int 3) || wgdd <> (C_int 4) then raise (Failure ("CC with fns: (" ^ (soci xgdd) ^ " " ^ (soci ygdd) ^ " " ^ (soci zgdd) ^ " " ^ (soci wgdd) ^ ")")) swig-3.0.2/Examples/test-suite/ocaml/README0000664000175000017500000000020612343605122020200 0ustar williamwilliamI stole most of these runme's from the ruby runme scripts, since the current ocaml interface mirrors the ruby interface in many ways. swig-3.0.2/Examples/test-suite/ocaml/class_ignore_runme.ml0000664000175000017500000000024112343605122023527 0ustar williamwilliamopen Swig open Class_ignore let a = new_Bar C_void let _ = (if _do_blah a <> C_string "Bar::blah" then raise (Failure "We didn't really get a bar object.")) swig-3.0.2/Examples/test-suite/ocaml/typedef_mptr_runme.ml0000664000175000017500000000075512343605122023573 0ustar williamwilliamopen Swig open Typedef_mptr let soci x = (string_of_int (get_int x)) let x = new_Foo C_void let add_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _add ]) and sub_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _sub ]) let _ = if add_res <> (C_int 3) || sub_res <> (C_int 1) then raise (Failure ("Bad result:" ^ " (add " ^ (soci add_res) ^ ") " ^ " (sub " ^ (soci sub_res) ^ ")")) let _ = Printf.printf "2 + 1 = %d, 2 - 1 = %d\n" (get_int add_res) (get_int sub_res) swig-3.0.2/Examples/test-suite/ocaml/overload_copy_runme.ml0000664000175000017500000000011112343605122023720 0ustar williamwilliamopen Swig open Overload_copy let f = new_Foo C_void let g = new_Foo f swig-3.0.2/Examples/test-suite/ocaml/voidtest_runme.ml0000664000175000017500000000023112343605122022717 0ustar williamwilliamopen Swig open Voidtest let _ = _globalfunc C_void let f = new_Foo C_void let _ = (invoke f) "memberfunc" C_void let _ = _Foo_staticmemberfunc C_void swig-3.0.2/Examples/test-suite/ocaml/unions_runme.ml0000664000175000017500000000203112343605122022371 0ustar williamwilliam(* Test the unions example... *) open Swig open Unions let a = new_SmallStruct C_void let b = new_BigStruct C_void let c = new_UnionTest C_void let d = new_EmbeddedUnionTest C_void let _ = (invoke a) "jill" (C_short 3) let _ = (invoke b) "jack" (C_char 'a') (* Int conversion *) let _ = (invoke b) "smallstruct" a (* Put a in b *) let _ = (invoke c) "bs" b let _ = if get_int ((invoke a) "jill" C_void) != 3 then raise (Failure "jill value is not preserved") let _ = if get_int ((invoke b) "jack" C_void) != (int_of_char 'a') then raise (Failure "jack value is not preserved") let _ = if get_int ((invoke ((invoke b) "smallstruct" C_void)) "jill" C_void) != 3 then raise (Failure "jill value is not embedded in bigstruct") let _ = if get_int ((invoke ((invoke c) "bs" C_void)) "jack" C_void) != (int_of_char 'a') then raise (Failure "union set of bigstruct did not take") let _ = if get_int ((invoke ((invoke c) "ss" C_void)) "jill" C_void) != (int_of_char 'a') then raise (Failure "corresponding union values are not the same") swig-3.0.2/Examples/test-suite/ocaml/varargs_runme.ml0000664000175000017500000000043412343605122022530 0ustar williamwilliam(* Test case stolen from the python directory *) open Swig open Varargs let _ = if _test (C_string "Hello") <> (C_string "Hello") then raise (Failure "1") let f = new_Foo C_void let _ = if (invoke f) "test" (C_string "Hello") <> (C_string "Hello") then raise (Failure "2") swig-3.0.2/Examples/test-suite/ocaml/makedebugtop0000664000175000017500000000101012343605122021704 0ustar williamwilliam#!/bin/sh # # Usage: makedebugtop test_name.c[pp]test # # Creates an ocaml toplevel for debugging based on a .cpptest or .ctest # file. # OCAMLINC=/usr/local/lib/ocaml swigtest=$1 thetest=`echo $1 | sed -e 's/\.c[p]*test//g'` cppopt="" if echo $swigtest | grep -s cpptest ; then cppopt=-xc++ fi echo "Making the test" make $swigtest echo "Building ${thetest}_top" gcc -c -g $cppopt -I$OCAMLINC ${thetest}_wrap.c ocamlmktop -cclib -g -custom swig.cmo ${thetest}_wrap.o ${thetest}.cmo -o ${thetest}_top -cclib -lstdc++ swig-3.0.2/Examples/test-suite/ocaml/throw_exception_runme.ml0000664000175000017500000000135512343605122024307 0ustar williamwilliam(* Throw exception test *) open Swig open Throw_exception let x = new_Foo C_void ;; let _ = try (invoke x) "test_int" C_void with (Failure "Exception(37): Thrown exception from C++ (int)\n") -> try (invoke x) "test_msg" C_void with (Failure "Exception(0): Dead\n") -> try (invoke x) "test_cls" C_void with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") -> try (invoke x) "test_multi" (C_int 1) with (Failure "Exception(37): Thrown exception from C++ (int)\n") -> try (invoke x) "test_multi" (C_int 2) with (Failure "Exception(0): Dead\n") -> try (invoke x) "test_multi" (C_int 3) with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") -> exit 0 let _ = exit 1 swig-3.0.2/Examples/test-suite/ocaml/newobject1_runme.ml0000664000175000017500000000144212343605122023124 0ustar williamwilliamopen Swig open Newobject1 exception RuntimeError of string * int let foo1 = ref (_Foo_makeFoo C_void) let _ = if get_int (_Foo_fooCount C_void) != 1 then raise (RuntimeError ("(1) Foo.fooCount != 1", get_int (_Foo_fooCount C_void))) let foo2 = ref ((invoke !foo1) "makeMore" C_void) let _ = if get_int (_Foo_fooCount C_void) != 2 then raise (RuntimeError ("(2) Foo.fooCount != 2", get_int (_Foo_fooCount C_void))) let _ = begin foo1 := C_void ; Gc.full_major () ; (if get_int (_Foo_fooCount C_void) != 1 then raise (RuntimeError ("(3) Foo.fooCount != 1", get_int (_Foo_fooCount C_void)))) ; foo2 := C_void ; Gc.full_major () ; (if get_int (_Foo_fooCount C_void) != 0 then raise (RuntimeError ("(4) Foo.fooCount != 0", get_int (_Foo_fooCount C_void)))) ; end swig-3.0.2/Examples/test-suite/ocaml/using_protected_runme.ml0000664000175000017500000000026512343605122024263 0ustar williamwilliamopen Swig open Using_protected let f = new_FooBar C_void let _ = (invoke f) "x" (C_int 3) let _ = if (invoke f) "blah" (C_int 4) <> (C_int 4) then raise (Failure "blah(int)") swig-3.0.2/Examples/test-suite/ocaml/typename_runme.ml0000664000175000017500000000047112343605122022706 0ustar williamwilliam(* Fun with type names -- stolen from the ruby runme *) open Swig open Typename let f = new_Foo C_void let b = new_Bar C_void let x = _twoFoo f let _ = match x with C_double f -> () | _ -> raise (Failure "not a float") let y = _twoBar b let _ = match y with C_int i -> () | _ -> raise (Failure "not an int") swig-3.0.2/Examples/test-suite/ocaml/imports_runme.ml0000664000175000017500000000042412343605122022557 0ustar williamwilliam(* purpose: to receive the hello A method from Imports_a exposed through * a B object derived from A *) open Swig open Imports_a open Imports_b let x = new_B C_void (* Tests conversion of x to a generic value *) let a = swig_val `unknown x let _ = (invoke x) "hello" C_void swig-3.0.2/Examples/test-suite/ocaml/name_runme.ml0000664000175000017500000000020012343605122021772 0ustar williamwilliamopen Swig open Name let _ = if (get_int (_Baz_2 C_void)) - (get_int (_bar_2 C_void)) == 30 then exit 0 else exit 1 swig-3.0.2/Examples/test-suite/ocaml/Makefile.in0000664000175000017500000000426412343605122021375 0ustar williamwilliam####################################################################### # Makefile for ocaml test-suite ####################################################################### LANGUAGE = ocaml OCAMLC = ocamlc VARIANT = _static SCRIPTSUFFIX = _runme.ml srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ C_TEST_CASES = run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \ -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then \ $(COMPILETOOL) $(OCAMLC) -c $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme; \ elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(COMPILETOOL) $(OCAMLC) -c $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \ $(RUNTOOL) ./runme; \ fi ; check_quant: cat /dev/null > testing cat /dev/null > success cat /dev/null > results $(MAKE) check echo "Failed:" >> results for element in `cat testing` ; do \ if grep $$element success >/dev/null 2>/dev/null ; then \ : ; \ else \ echo $$element >> results ; \ fi ; \ done echo "Success:" >> results cat success >> results include $(srcdir)/../common.mk # Overridden variables here # none! # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: echo $@ >> testing $(setup) +$(swig_and_compile_cpp) $(run_testcase) if [ -f $(@:%.cpptest=%_wrap.o) ] ; then \ echo $@ >> success ; \ fi %.ctest: echo $@ >> testing $(setup) +$(swig_and_compile_c) $(run_testcase) if [ -f $(@:%.ctest=%_wrap.o) ] ; then \ echo $@ >> success ; \ fi %.multicpptest: echo $@ >> testing +$(swig_and_compile_multi_cpp) $(setup) $(run_testcase) if [ -f $(@:%.multicpptest=%_runtime_wrap.o) ] ; then \ echo $@ >> success ; \ fi # Clean %.clean: @rm -f $*.ml $*.mli; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" ocaml_clean swig-3.0.2/Examples/test-suite/ocaml/sneaky1_runme.ml0000664000175000017500000000041712343605122022437 0ustar williamwilliam(* Stolen from ruby test cases *) open Swig open Sneaky1 let x = Sneaky1._add (C_list [ C_int 3; C_int 4 ]) let y = Sneaky1._subtract (C_list [ C_int 3; C_int 4 ]) let z = Sneaky1._mul (C_list [ C_int 3; C_int 4 ]) let w = Sneaky1._divide (C_list [ C_int 3; C_int 4 ]) swig-3.0.2/Examples/test-suite/li_boost_intrusive_ptr.i0000664000175000017500000004720412343605122023217 0ustar williamwilliam// This tests intrusive_ptr is working okay. It also checks that there are no memory leaks in the // class that intrusive_ptr is pointing via a counting mechanism in the constructors and destructor of Klass. // In order to test that there are no leaks of the intrusive_ptr class itself (as it is created on the heap) // the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools // like 'top'. There is a wrapper for intrusive_ptr in intrusive_ptr_wrapper.h which enables one to // count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on. // // Also note the debug_shared flag which can be set from the target language. // // Usage of intrusive_ptr_add_ref and intrusive_ptr_release based on boost testing: // http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/test/intrusive_ptr_test.cpp %module li_boost_intrusive_ptr %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived; %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived; %ignore intrusive_ptr_add_ref; %ignore intrusive_ptr_release; %{ #include #include #include // Uncomment macro below to turn on intrusive_ptr memory leak checking as described above //#define INTRUSIVE_PTR_WRAPPER #ifdef INTRUSIVE_PTR_WRAPPER # include "intrusive_ptr_wrapper.h" # include "shared_ptr_wrapper.h" #endif %} %{ #ifndef INTRUSIVE_PTR_WRAPPER # define SwigBoost boost #endif %} %include "std_string.i" #ifndef INTRUSIVE_PTR_WRAPPER # define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost # define SWIG_SHARED_PTR_NAMESPACE SwigBoost #endif #if defined(SWIGJAVA) || defined(SWIGCSHARP) #define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED #endif #if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED) %include %intrusive_ptr(Space::Klass) %intrusive_ptr_no_wrap(Space::KlassWithoutRefCount) %intrusive_ptr(Space::KlassDerived) %intrusive_ptr(Space::KlassDerivedDerived) //For the use_count shared_ptr functions #if defined(SWIGJAVA) %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} %typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong" %typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long" %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass" %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)" %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} %typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong" %typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long" %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived" %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)" %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} %typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong" %typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long" %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived" %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)" #elif defined(SWIGCSHARP) // TODO! #endif #endif // TODO: // const intrusive_ptr // std::vector // Add in generic %extend for the Upcast function for derived classes // Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method %exception { if (debug_shared) { cout << "++++++" << endl << flush; cout << "calling $name" << endl << flush; } $action if (debug_shared) { cout << "------" << endl << flush; } } %ignore IgnoredRefCountingBase; %ignore *::operator=; %newobject pointerownertest(); %newobject smartpointerpointerownertest(); %inline %{ #include using namespace std; static bool debug_shared = false; namespace Space { struct Klass { Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); } Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); } virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); } virtual std::string getValue() const { return value; } void append(const std::string &s) { value += s; } Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); } Klass &operator=(const Klass &other) { value = other.value; return *this; } void addref(void) const { ++count; } void release(void) const { if (--count == 0) delete this; } int use_count(void) const { return count; } static long getTotal_count() { return total_count; } friend void intrusive_ptr_add_ref(const Klass* r) { r->addref(); } friend void intrusive_ptr_release(const Klass* r) { r->release(); } private: static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;} static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;} static boost::detail::atomic_count total_count; std::string value; int array[1024]; mutable boost::detail::atomic_count count; }; struct KlassWithoutRefCount { KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); } KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); } virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); } virtual std::string getValue() const { return value; } void append(const std::string &s) { value += s; } KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); } std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; } KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; } static long getTotal_count() { return total_count; } private: static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;} static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;} static boost::detail::atomic_count total_count; std::string value; int array[1024]; }; struct IgnoredRefCountingBase { IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); } IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); } IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) { return *this; } virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); } void addref(void) const { ++count; } void release(void) const { if (--count == 0) delete this; } int use_count(void) const { return count; } inline friend void intrusive_ptr_add_ref(const IgnoredRefCountingBase* r) { r->addref(); } inline friend void intrusive_ptr_release(const IgnoredRefCountingBase* r) { r->release(); } static long getTotal_count() { return total_count; } private: static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;} static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;} static boost::detail::atomic_count total_count; double d; double e; mutable boost::detail::atomic_count count; }; long getTotal_IgnoredRefCountingBase_count() { return IgnoredRefCountingBase::getTotal_count(); } // For most compilers, this use of multiple inheritance results in different derived and base class // pointer values ... for some more challenging tests :) struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount { KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); } KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); } KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); } virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); } virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; } int use_count(void) const { return IgnoredRefCountingBase::use_count(); } static long getTotal_count() { return total_count; } private: static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;} static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;} static boost::detail::atomic_count total_count; }; struct KlassDerivedDerived : KlassDerived { KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); } KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); } KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); } virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); } virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; } static long getTotal_count() { return total_count; } private: static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;} static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;} static boost::detail::atomic_count total_count; }; KlassDerived* derivedpointertest(KlassDerived* kd) { if (kd) kd->append(" derivedpointertest"); return kd; } KlassDerived derivedvaluetest(KlassDerived kd) { kd.append(" derivedvaluetest"); return kd; } KlassDerived& derivedreftest(KlassDerived& kd) { kd.append(" derivedreftest"); return kd; } SwigBoost::intrusive_ptr derivedsmartptrtest(SwigBoost::intrusive_ptr kd) { if (kd) kd->append(" derivedsmartptrtest"); return kd; } SwigBoost::intrusive_ptr* derivedsmartptrpointertest(SwigBoost::intrusive_ptr* kd) { if (kd && *kd) (*kd)->append(" derivedsmartptrpointertest"); return kd; } SwigBoost::intrusive_ptr* derivedsmartptrreftest(SwigBoost::intrusive_ptr* kd) { if (kd && *kd) (*kd)->append(" derivedsmartptrreftest"); return kd; } SwigBoost::intrusive_ptr*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr*& kd) { if (kd && *kd) (*kd)->append(" derivedsmartptrpointerreftest"); return kd; } SwigBoost::intrusive_ptr factorycreate() { return SwigBoost::intrusive_ptr(new Klass("factorycreate")); } // smart pointer SwigBoost::intrusive_ptr smartpointertest(SwigBoost::intrusive_ptr k) { if (k) k->append(" smartpointertest"); return SwigBoost::intrusive_ptr(k); } SwigBoost::intrusive_ptr* smartpointerpointertest(SwigBoost::intrusive_ptr* k) { if (k && *k) (*k)->append(" smartpointerpointertest"); return k; } SwigBoost::intrusive_ptr& smartpointerreftest(SwigBoost::intrusive_ptr& k) { if (k) k->append(" smartpointerreftest"); return k; } SwigBoost::intrusive_ptr*& smartpointerpointerreftest(SwigBoost::intrusive_ptr*& k) { if (k && *k) (*k)->append(" smartpointerpointerreftest"); return k; } // const SwigBoost::intrusive_ptr constsmartpointertest(SwigBoost::intrusive_ptr k) { return SwigBoost::intrusive_ptr(k); } SwigBoost::intrusive_ptr* constsmartpointerpointertest(SwigBoost::intrusive_ptr* k) { return k; } SwigBoost::intrusive_ptr& constsmartpointerreftest(SwigBoost::intrusive_ptr& k) { return k; } // plain pointer Klass valuetest(Klass k) { k.append(" valuetest"); return k; } Klass *pointertest(Klass *k) { if (k) k->append(" pointertest"); return k; } Klass& reftest(Klass& k) { k.append(" reftest"); return k; } Klass *const& pointerreftest(Klass *const& k) { k->append(" pointerreftest"); return k; } // null std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr* k) { if (k && *k) return "not null"; else if (!k) return "null smartpointer pointer"; else if (!*k) return "null pointer"; else return "also not null"; } // $owner Klass *pointerownertest() { return new Klass("pointerownertest"); } SwigBoost::intrusive_ptr* smartpointerpointerownertest() { return new SwigBoost::intrusive_ptr(new Klass("smartpointerpointerownertest")); } const SwigBoost::intrusive_ptr& ref_1() { static SwigBoost::intrusive_ptr sptr; return sptr; } // overloading tests std::string overload_rawbyval(int i) { return "int"; } std::string overload_rawbyval(Klass k) { return "rawbyval"; } std::string overload_rawbyref(int i) { return "int"; } std::string overload_rawbyref(Klass &k) { return "rawbyref"; } std::string overload_rawbyptr(int i) { return "int"; } std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; } std::string overload_rawbyptrref(int i) { return "int"; } std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; } std::string overload_smartbyval(int i) { return "int"; } std::string overload_smartbyval(SwigBoost::intrusive_ptr k) { return "smartbyval"; } std::string overload_smartbyref(int i) { return "int"; } std::string overload_smartbyref(SwigBoost::intrusive_ptr &k) { return "smartbyref"; } std::string overload_smartbyptr(int i) { return "int"; } std::string overload_smartbyptr(SwigBoost::intrusive_ptr *k) { return "smartbyptr"; } std::string overload_smartbyptrref(int i) { return "int"; } std::string overload_smartbyptrref(SwigBoost::intrusive_ptr *&k) { return "smartbyptrref"; } } // namespace Space %} %{ boost::detail::atomic_count Space::Klass::total_count(0); boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0); boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0); boost::detail::atomic_count Space::KlassDerived::total_count(0); boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0); %} // Member variables %inline %{ struct MemberVariables { MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr()), SmartMemberReference(*(new SwigBoost::intrusive_ptr())), MemberPointer(0), MemberReference(MemberValue) {} virtual ~MemberVariables() { delete SmartMemberPointer; delete &SmartMemberReference; } SwigBoost::intrusive_ptr SmartMemberValue; SwigBoost::intrusive_ptr * SmartMemberPointer; SwigBoost::intrusive_ptr & SmartMemberReference; Space::Klass MemberValue; Space::Klass * MemberPointer; Space::Klass & MemberReference; }; // Global variables SwigBoost::intrusive_ptr GlobalSmartValue; Space::Klass GlobalValue; Space::Klass * GlobalPointer = 0; Space::Klass & GlobalReference = GlobalValue; %} #if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED) // Note: %template after the intrusive_ptr typemaps %intrusive_ptr(Base) %intrusive_ptr(Pair) #endif // Templates %inline %{ template struct Base { Space::Klass klassBase; T1 baseVal1; T2 baseVal2; Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {} virtual std::string getValue() const { return "Base<>"; }; mutable int count; void addref(void) const { count++; } void release(void) const { if (--count == 0) delete this; } int use_count(void) const { return count; } inline friend void intrusive_ptr_add_ref(const Base* r) { r->addref(); } inline friend void intrusive_ptr_release(const Base* r) { r->release(); } }; %} %template(BaseIntDouble) Base; %inline %{ template struct Pair : Base { Space::Klass klassPair; T1 val1; T2 val2; Pair(T1 t1, T2 t2) : Base(t1, t2), val1(t1), val2(t2) {} virtual std::string getValue() const { return "Pair<>"; }; }; Pair pair_id2(Pair p) { return p; } SwigBoost::intrusive_ptr< Pair > pair_id1(SwigBoost::intrusive_ptr< Pair > p) { return p; } long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } %} %template(PairIntDouble) Pair; // For counting the instances of intrusive_ptr (all of which are created on the heap) // intrusive_ptr_wrapper_count() gives overall count %inline %{ namespace SwigBoost { const int NOT_COUNTING = -123456; int intrusive_ptr_wrapper_count() { #ifdef INTRUSIVE_PTR_WRAPPER return SwigBoost::IntrusivePtrWrapper::getTotalCount(); #else return NOT_COUNTING; #endif } #ifdef INTRUSIVE_PTR_WRAPPER template<> std::string show_message(boost::intrusive_ptr*t) { if (!t) return "null intrusive_ptr!!!"; if (*t) return "Klass: " + (*t)->getValue(); else return "Klass: NULL"; } template<> std::string show_message(boost::intrusive_ptr*t) { if (!t) return "null intrusive_ptr!!!"; if (*t) return "Klass: " + (*t)->getValue(); else return "Klass: NULL"; } template<> std::string show_message(boost::intrusive_ptr*t) { if (!t) return "null intrusive_ptr!!!"; if (*t) return "KlassDerived: " + (*t)->getValue(); else return "KlassDerived: NULL"; } template<> std::string show_message(boost::intrusive_ptr*t) { if (!t) return "null intrusive_ptr!!!"; if (*t) return "KlassDerived: " + (*t)->getValue(); else return "KlassDerived: NULL"; } #endif } %} swig-3.0.2/Examples/test-suite/smart_pointer_overload.i0000664000175000017500000000076112343605122023166 0ustar williamwilliam%module smart_pointer_overload #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) test; #endif #ifndef SWIG_NO_OVERLOAD %inline %{ struct Foo { int x; int test(int y) { y = 0; return 1; } int test(double y) { y = 0; return 2; } int test(char *s) { s = 0; return 3; } }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } Foo *operator->() { return f; } }; %} #endif swig-3.0.2/Examples/test-suite/keyword_rename.i0000664000175000017500000000101112343605122021405 0ustar williamwilliam/* * Test reserved keyword renaming */ %module keyword_rename #pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD %inline %{ #define KW(x, y) int x (int y) { return y; } /* Python keywords */ KW(in, except) KW(except, in) KW(pass, in) /* Perl keywords */ KW(tie, die) KW(use, next) /* Java keywords */ KW(implements, native) KW(synchronized, final) /* C# Keywords */ KW(string, out) struct sealed {int i;}; /* Go Keywords */ KW(go, defer) KW(chan, fallthrough) /* Lua keywords */ KW(end, function) KW(nil,local) %} swig-3.0.2/Examples/test-suite/abstract_typedef2.i0000664000175000017500000000163712343605122022015 0ustar williamwilliam%module abstract_typedef2 /* After the fix for abstract_typedef, this simpler example got broken. */ %inline %{ enum FieldDim { UnaryField, BinaryField }; template struct Facet; template struct Base { virtual ~Base() {} typedef unsigned int size_type; typedef Facet* facet_ptr; // This works // virtual Facet* set(size_type) = 0; // This doesn't virtual facet_ptr set(size_type) = 0; }; template struct Facet { }; template struct A : Base { typedef Base base; typedef typename base::size_type size_type; A(int a = 0) { } Facet* set(size_type) { return 0; } }; %} %template(Base_UF) Base; %template(A_UF) A; swig-3.0.2/Examples/test-suite/overload_template.i0000664000175000017500000001266412343605122022120 0ustar williamwilliam%module overload_template #ifdef SWIGLUA // lua only has one numeric type, so most of the overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) foo; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) maximum; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) specialization; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) overload; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) space::nsoverload; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fooT; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) barT; #endif %inline %{ int foo() { return 3; } template int foo(T x) { return (int)x; } template T maximum(T a, T b) { return (a > b) ? a : b; } %} %template(foo) foo; %template(foo) foo; %template(maximum) maximum; %template(maximum) maximum; // Mix template overloading with plain function overload // Mix 1 %inline %{ int mix1(const char* msg) { return 101; } template int mix1(T t, const T& tt) { return 102; } template int mix1(T t) { return 103; } %} %template(mix1) mix1; // Mix 2 %inline %{ template int mix2(T t, const T& tt) { return 102; } int mix2(const char* msg) { return 101; } template int mix2(T t) { return 103; } %} %template(mix2) mix2; // Mix 3 %inline %{ template int mix3(T t, const T& tt) { return 102; } template int mix3(T t) { return 103; } int mix3(const char* msg) { return 101; } %} %template(mix3) mix3; // overloaded by number of templated parameters // Combination 1 %inline %{ template int overtparams1(T t) { return 10; } template int overtparams1(T t, U u) { return 20; } %} %template(overtparams1) overtparams1; %template(overtparams1) overtparams1; // Combination 2 %inline %{ template int overtparams2(T t) { return 30; } template int overtparams2(T t, U u) { return 40; } %} %template(overtparams2) overtparams2; // Combination 3 %inline %{ template int overloaded(T t) { return 50; } int overloaded() { return 60; } template int overloaded(T t, U u) { return 70; } %} %template(overloaded) overloaded; // Combination 4 %inline %{ int overloadedagain(const char* msg) { return 80; } template int overloadedagain() { return 90; } template int overloadedagain(T t, U u) { return 100; } %} %template(overloadedagain) overloadedagain; // simple specialization %inline %{ template void xyz() {} template<> void xyz() {} void xyz() {} %} // We can have xyz(); xyz(); xyz(); in C++, but can't have this type of overloading in target language, so we need to do some renaming %template(xyz_double) xyz; %template(xyz_int) xyz; // specializations %inline %{ template int specialization(T t) { return 200; } template int specialization(T t, U u) { return 201; } template<> int specialization(int t) { return 202; } template<> int specialization(double t) { return 203; } template<> int specialization(int t, int u) { return 204; } template<> int specialization(double t, double u) { return 205; } %} %template(specialization) specialization; %template(specialization) specialization; %template(specialization) specialization; %template(specialization) specialization; %template(specialization) specialization; // a bit of everything %inline %{ int overload(const char *c) { return 0; } template int overload(T t) { return 10; } template int overload(T t, const T &tref) { return 20; } template int overload(T t, const char *c) { return 30; } template<> int overload(double t, const char *c) { return 40; } int overload() { return 50; } class Klass {}; %} %template(overload) overload; %template(overload) overload; %template(overload) overload; // everything put in a namespace %inline %{ namespace space { int nsoverload(const char *c) { return 1000; } template int nsoverload(T t) { return 1010; } template int nsoverload(T t, const T &tref) { return 1020; } template int nsoverload(T t, const char *c) { return 1030; } template<> int nsoverload(double t, const char *c) { return 1040; } int nsoverload() { return 1050; } } %} %template(nsoverload) space::nsoverload; %template(nsoverload) space::nsoverload; %template(nsoverload) space::nsoverload; %inline %{ namespace space { template struct Foo { void bar(T t1) { } void bar(T t1, T t2) { } void bar(int a, int b, int c) { } }; struct A { template static void fooT(Y y) { } }; } template struct Bar { void foo(T t1) { } void foo(T t1, T t2) { } void foo(int a, int b, int c) { } template void fooT(Y y) { } }; struct B { template void barT(Y y) { } }; %} %template(Bar_d) Bar; %template(Foo_d) space::Foo; %template(foo) space::A::fooT; %template(foo) space::A::fooT; %template(foo) space::A::fooT; %template(foo) B::barT; %template(foo) B::barT; %template(foo) B::barT; swig-3.0.2/Examples/test-suite/typemap_namespace.i0000664000175000017500000000243412343605122022077 0ustar williamwilliam%module typemap_namespace /* Secret typedefs */ %{ namespace Foo { typedef char Str1; typedef char Str2; } %} namespace Foo { struct Str1; struct Str2; #ifdef SWIGCSHARP %typemap(ctype) Str1 * = char *; %typemap(imtype) Str1 * = char *; %typemap(cstype) Str1 * = char *; %typemap(csin) Str1 * = char *; %typemap(csout) Str1 * = char *; #endif #ifdef SWIGJAVA %typemap(jni) Str1 * = char *; %typemap(jtype) Str1 * = char *; %typemap(jstype) Str1 * = char *; %typemap(javain) Str1 * = char *; %typemap(javaout) Str1 * = char *; #endif #ifdef SWIGGO %typemap(gotype) Str1 * = char *; #endif #ifdef SWIGD %typemap(ctype) Str1 * = char *; %typemap(imtype) Str1 * = char *; %typemap(dtype) Str1 * = char *; %typemap(din) Str1 * = char *; %typemap(dout) Str1 * = char *; #endif %typemap(in) Str1 * = char *; #if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGGO) || defined(SWIGD)) %typemap(freearg) Str1 * = char *; #endif %typemap(typecheck) Str1 * = char *; %apply char * { Str2 * }; } %inline %{ namespace Foo { char *test1(Str1 *s) { return s; } char *test2(Str2 *s) { return s; } } %} swig-3.0.2/Examples/test-suite/static_const_member.i0000664000175000017500000000102512343605122022423 0ustar williamwilliam/* Swig 1.3.6 does not understand initialization of static class constants like this. SF Bug #445221, reported by Krzysztof Kozminski . */ %module static_const_member #if SWIGJAVA %javaconst(1) EN; %javaconst(1) CHARTEST; #elif SWIGCSHARP %csconst(1) EN; %csconst(1) CHARTEST; #elif SWIGD %dmanifestconst EN; %dmanifestconst CHARTEST; #endif %inline %{ class X { public: static const int PN = 0; static const int CN = 1; static const int EN = 2; static const char CHARTEST = 'A'; }; %} swig-3.0.2/Examples/test-suite/stl_new.i0000664000175000017500000000163012343605122020054 0ustar williamwilliam%module stl_new %include %include %include %include %include %template(Vector ) std::vector ; %template(Deque ) std::deque ; %template(List ) std::list ; %template(Set ) std::set >; %template(Map ) std::map >; // %inline %{ // namespace swig { // void nth_element(swig::Iterator_T< _Iter>& first, // swig::Iterator_T< _Iter>& nth, // swig::Iterator_T< _Iter>& last, // const swig::BinaryPredicate<>& comp = swig::BinaryPredicate<>()) // { // std::nth_element( first, nth, last, comp); // } // } // %} swig-3.0.2/Examples/test-suite/smart_pointer_simple.i0000664000175000017500000000031512343605122022637 0ustar williamwilliam%module smart_pointer_simple %inline %{ struct Foo { int x; int getx() { return x; } }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } Foo *operator->() { return f; } }; %} swig-3.0.2/Examples/test-suite/rename.h0000664000175000017500000000200112343605122017640 0ustar williamwilliam namespace Space { struct Klass { Klass(int i) {} Klass() {} }; } namespace AnotherSpace { class Another {}; } namespace Space { using namespace AnotherSpace; enum Enu { En1, En2, En3 }; template struct NotXYZ {}; template class XYZ { NotXYZ *m_int; T m_t; NotXYZ m_notxyz; public: operator NotXYZ*() const { return m_int; } operator XYZ*() const { return 0; } operator Another() const { Another an; return an; } void templateT(T i) {} void templateNotXYZ(NotXYZ i) {} void templateXYZ(XYZ i) {} operator T() { return m_t; } operator NotXYZ() const { return m_notxyz; } operator XYZ() const { XYZ xyz = XYZ(); return xyz; } }; } namespace Space { // non-templated class using itself in method and operator class ABC { public: void method(ABC a) const {} void method(Klass k) const {} operator ABC() const { ABC a; return a; } operator Klass() const { Klass k; return k; } }; } swig-3.0.2/Examples/test-suite/mod.list0000664000175000017500000000001412343605122017676 0ustar williamwilliammod_a mod_b swig-3.0.2/Examples/test-suite/template_array_numeric.i0000664000175000017500000000054512343605122023140 0ustar williamwilliam%module template_array_numeric %inline %{ template class Arrayf { float a[Len]; public: Arrayf() {} Arrayf(const float l[Len]) { }; }; template Arrayf make_arrayf(const float l[Len]) { Arrayf a(l); return a; } typedef Arrayf<4> Array4f; %} %template(Array4f) Arrayf<4>; %template(make_array4f) make_arrayf<4>; swig-3.0.2/Examples/test-suite/li_boost_shared_ptr_bits.i0000664000175000017500000000507712343605122023460 0ustar williamwilliam%module li_boost_shared_ptr_bits #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) %include %shared_ptr(NonDynamic) #endif #if defined(SWIGPYTHON) %pythonnondynamic NonDynamic; #endif %inline %{ #include struct NonDynamic { int i; }; boost::shared_ptr boing(boost::shared_ptr b) { return b; } %} // vector of shared_ptr %include "std_vector.i" #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) %shared_ptr(IntHolder); #endif %inline %{ #include "boost/shared_ptr.hpp" struct IntHolder { int val; IntHolder(int a) : val(a) {} }; int sum(std::vector< boost::shared_ptr > v) { int sum = 0; for (size_t i=0; ival; return sum; } %} %template(VectorIntHolder) std::vector< boost::shared_ptr >; ///////////////////////////////////////////////// // Test non public destructor - was leading to memory leaks as the destructor was not wrapped // Bug 3024875 ///////////////////////////////////////////////// #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) %shared_ptr(HiddenDestructor) #endif %inline %{ class HiddenDestructor; typedef boost::shared_ptr< HiddenDestructor > FooPtr; class HiddenDestructor { public: static FooPtr create(); virtual void doit(); protected: HiddenDestructor(); static void Foo_body( FooPtr self ); virtual ~HiddenDestructor(); private: HiddenDestructor( const HiddenDestructor& ); class Impl; Impl* impl_; class FooDeleter { public: void operator()(HiddenDestructor* hidden) { delete hidden; } }; }; %} %{ #include using namespace std; /* Impl would generally hold a weak_ptr to HiddenDestructor a.s.o, but this stripped down example should suffice */ class HiddenDestructor::Impl { public: int mymember; }; FooPtr HiddenDestructor::create() { FooPtr hidden( new HiddenDestructor(), HiddenDestructor::FooDeleter() ); Foo_body( hidden ); return hidden; } void HiddenDestructor::doit() { // whatever } HiddenDestructor::HiddenDestructor() { // cout << "HiddenDestructor::HiddenDestructor()" << endl; // always empty } void HiddenDestructor::Foo_body( FooPtr self ) { // init self as you would do in ctor self->impl_ = new Impl(); } HiddenDestructor::~HiddenDestructor() { // cout << "HiddenDestructor::~HiddenDestructor()" << endl; // destruct (e.g. delete Pimpl object) delete impl_; } %} //////////////////////////// swig-3.0.2/Examples/test-suite/nspace_extend.i0000664000175000017500000000272612343605122021230 0ustar williamwilliam// Test the nspace feature and %extend %module nspace_extend // nspace feature only supported by these languages #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT) #if defined(SWIGJAVA) SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) #endif %nspace; %extend Outer::Inner1::Color { Color() { return new Outer::Inner1::Color(); } virtual ~Color() { delete $self; } static Color* create() { return new Outer::Inner1::Color(); } Color(const Color& other) { return new Outer::Inner1::Color(other); } void colorInstanceMethod(double d) {} static void colorStaticMethod(double d) {} } %inline %{ namespace Outer { namespace Inner1 { struct Color { }; } namespace Inner2 { struct Color { }; } } %} %extend Outer::Inner2::Color { Color() { return new Outer::Inner2::Color(); } ~Color() { delete $self; } static Color* create() { return new Outer::Inner2::Color(); } Color(const Color& other) { return new Outer::Inner2::Color(other); } void colorInstanceMethod(double d) {} static void colorStaticMethod(double d) {} void colors(const Inner1::Color& col1a, const Outer::Inner1::Color& col1b, const Color &col2a, const Inner2::Color& col2b, const Outer::Inner2::Color& col2c) {} } #else //#warning nspace feature not yet supported in this target language #endif swig-3.0.2/Examples/test-suite/cpp11_alternate_function_syntax.i0000664000175000017500000000064512343605122024704 0ustar williamwilliam/* This testcase checks whether SWIG correctly uses the new alternate functions declarations and definitions introduced in C++11. */ %module cpp11_alternate_function_syntax %inline %{ struct SomeStruct { int addNormal(int x, int y); auto addAlternate(int x, int y) -> int; }; auto SomeStruct::addAlternate(int x, int y) -> int { return x + y; } int SomeStruct::addNormal(int x, int y) { return x + y; } %} swig-3.0.2/Examples/test-suite/naturalvar_onoff.i0000664000175000017500000000131612343605122021750 0ustar williamwilliam%module naturalvar_onoff // Test naturalvar feature override is working - // naturalvar on the variable name has priority over naturalvar on the variable's type // Use runtime tests to differentiate between the const ref typemaps and pointer typemap - // using the fact that NULL cannot be passed to the ref typemaps %naturalvar Member1; %nonaturalvar Member2; %naturalvar Member3; %nonaturalvar Vars::member3Off; %nonaturalvar Member4; %naturalvar Vars::member4On; %inline %{ struct Member1 {}; struct Member2 {}; struct Member3 {}; struct Member4 {}; struct Vars { Member1 member1On; Member2 member2Off; Member3 member3Off; Member3 member3On; Member4 member4Off; Member4 member4On; }; %} swig-3.0.2/Examples/test-suite/template_default_qualify.i0000664000175000017500000000175312343605122023460 0ustar williamwilliam// Tests typename qualification and constant resolution in default // template arguments. Another Marcelo special.. :-). %module template_default_qualify %warnfilter(SWIGWARN_RUBY_WRONG_NAME) etraits; /* Ruby, wrong class name */ %inline %{ namespace oss { enum Polarization { UnaryPolarization, BinaryPolarization }; template struct Interface_ { }; namespace modules { template > // *** problem here **** struct Module : base { }; } } struct etraits { static const oss::Polarization pmode = oss::UnaryPolarization; }; %} namespace oss { %template(Interface_UP) Interface_; namespace modules { %template(Module_etraits) Module; } } %inline %{ namespace oss { namespace modules { struct HModule1 : Module { }; } } %} swig-3.0.2/Examples/test-suite/contract.i0000664000175000017500000000714312343605122020223 0ustar williamwilliam%module contract %warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, D, Java, PHP multiple inheritance */ #ifdef SWIGCSHARP %ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override #endif #ifdef SWIGD %ignore B::bar; // Prevents getting an error that C.bar does not override any function because multiple inheritance is not supported. #endif %contract test_preassert(int a, int b) { require: a > 0; b > 0; } %contract test_postassert(int a) { ensure: test_postassert > 0; } %contract test_prepost(int a, int b) { require: a > 0; ensure: test_prepost > 0; } %inline %{ int test_preassert(int x, int y) { if ((x > 0) && (y > 0)) return 1; return 0; } int test_postassert(int x) { return x; } int test_prepost(int x, int y) { return x+y; } %} /* Class tests */ %contract Foo::test_preassert(int x, int y) { require: x > 0; y > 0; } %contract Foo::test_postassert(int a) { ensure: test_postassert > 0; } %contract Foo::test_prepost(int a, int b) { require: a > 0; ensure: test_prepost > 0; } %contract Foo::stest_prepost(int a, int b) { require: a > 0; ensure: stest_prepost > 0; } %contract Bar::test_prepost(int c, int d) { require: d > 0; } %inline %{ class Foo { public: virtual ~Foo() { } virtual int test_preassert(int x, int y) { if ((x > 0) && (y > 0)) return 1; return 0; } virtual int test_postassert(int x) { return x; } virtual int test_prepost(int x, int y) { return x+y; } static int stest_prepost(int x, int y) { return x+y; } }; class Bar : public Foo { public: virtual int test_prepost(int x, int y) { return x+y; } }; %} /* Multiple inheritance test */ %contract A::foo(int i, int j, int k, int l, int m) { require: i > 0; j > 0; ensure: foo > 0; } %contract B::bar(int x, int y, int z, int w, int v) { require: w > 0; v > 0; ensure: bar > 0; } %contract C::foo(int a, int b, int c, int d, int e) { require: c > 0; d > 0; ensure: foo > 0; } %contract D::foo(int, int, int, int, int x) { require: x > 0; } %contract D::bar(int a, int b, int c, int, int) { require: a > 0; b > 0; c > 0; } %inline %{ class A { public: virtual ~A() {} virtual int foo(int a, int b, int c, int d, int e) { if ((a > 0) && (b > 0) && (c > 0) && (d > 0) && (e > 0)) { return 1; } return 0; } }; class B { public: virtual ~B() {} virtual int bar(int a, int b, int c, int d, int e) { if ((a > 0) && (b > 0) && (c > 0) && (d > 0) && (e > 0)) { return 1; } return 0; } }; class C : public A, public B { public: virtual int foo(int a, int b, int c, int d, int e) { return A::foo(a,b,c,d,e); } virtual int bar(int a, int b, int c, int d, int e) { return B::bar(a,b,c,d,e); } }; class D : public C { public: virtual int foo(int a, int b, int c, int d, int e) { return C::foo(a,b,c,d,e); } virtual int bar(int a, int b, int c, int d, int e) { return C::bar(a,b,c,d,e); } }; %} %extend E { %contract manipulate_i(int i) { require: i <= $self->m_i; } } %inline %{ struct E { int m_i; void manipulate_i(int i) { } }; %} // Namespace %{ namespace myNames { class myClass { public: myClass(int i) {} }; } %} namespace myNames { %contract myClass::myClass( int i ) { require: i > 0; } class myClass { public: myClass(int i) {} }; } swig-3.0.2/Examples/test-suite/template_rename.i0000664000175000017500000000163012343605122021543 0ustar williamwilliam%module template_rename %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Foo; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Foo; /* Ruby, wrong class name */ %rename(blah_test) Foo::blah(int); %rename(spam_test) Foo::spam(int); %rename(grok_test) Foo::grok(int); %rename(groki_test) Foo::grok(int); %inline %{ template class Foo { public: int blah(int x) { return x; } int spam(int x) { return x; } int grok(int x) { return x; } }; %} %template(iFoo) Foo; %template(dFoo) Foo; // Testing ignore %ignore std::tvector::tvector(size_type); %inline %{ namespace std { template class tvector { public: typedef size_t size_type; tvector() {} tvector(size_type n) { T t = T(); } }; } class Flow { Flow() {} public: Flow(double d) {} }; %} %template(VectFlow) std::tvector; swig-3.0.2/Examples/test-suite/cpp11_delegating_constructors.i0000664000175000017500000000050612343605122024341 0ustar williamwilliam/* This test checks whether SWIG correctly parses the new delegating constructors. */ %module cpp11_delegating_constructors %inline %{ class A { public: int a; int b; int c; A() : A( 10 ) {} A(int aa) : A(aa, 20) {} A(int aa, int bb) : A(aa, bb, 30) {} A(int aa, int bb, int cc) { a=aa; b=bb; c=cc; } }; %} swig-3.0.2/Examples/test-suite/preproc_include_g.h0000664000175000017500000000003112343605122022055 0ustar williamwilliam int multiply70(int a); swig-3.0.2/Examples/test-suite/overload_method.i0000664000175000017500000000050012343605122021547 0ustar williamwilliam/* This test confirms the fix to sourceforge bug #3478922 for R */ %module overload_method %inline %{ class Base { public: Base() : x(42) {} int method() const { return x; } void overloaded_method(int aArg) { x = aArg; } int overloaded_method() const { return x; } private: int x; }; %} swig-3.0.2/Examples/test-suite/typedef_mptr.i0000664000175000017500000000161012343605122021101 0ustar williamwilliam// Tests typedef through member pointers %module typedef_mptr %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */ #pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */ #endif %} #if defined(SWIGPYTHON) || defined(SWIGOCAML) %inline %{ class Foo { public: int add(int x, int y) { return x+y; } int sub(int x, int y) { return x-y; } int do_op(int x, int y, int (Foo::*op)(int, int)) { return (this->*op)(x,y); } }; typedef Foo FooObj; typedef int Integer; Integer do_op(Foo *f, Integer x, Integer y, Integer (FooObj::*op)(Integer, Integer)) { return f->do_op(x,y,op); } %} #endif #if defined(SWIGPYTHON) || defined(SWIGOCAML) %constant int (Foo::*add)(int,int) = &Foo::add; %constant Integer (FooObj::*sub)(Integer,Integer) = &FooObj::sub; #endif swig-3.0.2/Examples/test-suite/template_nested_typemaps.i0000664000175000017500000000242612343605122023504 0ustar williamwilliam#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_TEMPLATE %module template_nested_typemaps // Testing that the typemaps invoked within a class via %template are picked up by appropriate methods template struct Typemap { %typemap(in) T { $1 = -99; } }; template <> struct Typemap { // Note explicit specialization %typemap(in) short { $1 = -77; } }; %inline %{ int globalInt1(int s) { return s; } short globalShort1(short s) { return s; } template struct Breeze { int methodInt1(int s) { return s; } #if defined(SWIG) %template() Typemap; #endif int methodInt2(int s) { return s; } // should pick up the typemap within Typemap void takeIt(T t) {} short methodShort1(short s) { return s; } #if defined(SWIG) %template(TypemapShort) Typemap; // should issue warning SWIGWARN_PARSE_NESTED_TEMPLATE #endif short methodShort2(short s) { return s; } // should pick up the typemap within Typemap }; int globalInt2(int s) { return s; } short globalShort2(short s) { return s; } %} %template(BreezeString) Breeze; %inline %{ int globalInt3(int s) { return s; } // should pick up the typemap within Typemap short globalShort3(short s) { return s; } // should pick up the typemap within Typemap %} swig-3.0.2/Examples/test-suite/abstract_signature.i0000664000175000017500000000107012343605122022263 0ustar williamwilliam%module abstract_signature %warnfilter(SWIGWARN_RUBY_WRONG_NAME) abstract_foo; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) abstract_bar; // Ruby, wrong class name %inline %{ class abstract_foo { public: abstract_foo() { }; virtual ~abstract_foo() { }; virtual int meth(int meth_param) = 0; }; class abstract_bar : public abstract_foo { public: abstract_bar() { }; virtual ~abstract_bar() { }; virtual int meth(int meth_param) = 0; int meth(int meth_param_1, int meth_param_2) { return 0; } }; %} swig-3.0.2/Examples/test-suite/prefix.i0000664000175000017500000000026212343605122017676 0ustar williamwilliam// Test that was failing for PHP - the value of the -prefix option was // ignored %module prefix %inline %{ class Foo { public: Foo *get_self() { return this; } }; %} swig-3.0.2/Examples/test-suite/special_variables.i0000664000175000017500000000601612343605122022054 0ustar williamwilliam%module(directors="1") special_variables %include // will fail to compile if $symname is not expanded %typemap(argout) int i { $symname(99); } %{ #define KKK_testmethod testmethod #define KKK_teststaticmethod KKK::teststaticmethod %} %inline %{ void testmethod(int i) {} struct KKK { void testmethod(int i) {} static void teststaticmethod(int i) {} }; %} %{ std::string ExceptionVars(double i, double j) { return "a1"; } %} %rename(ExceptionVars) Space::exceptionvars; %exception Space::exceptionvars %{ $action result = $symname(1.0,2.0); // Should expand to ExceptionVars result = $name(3.0,4.0); // Should expand to Space::exceptionvars // above will not compile if the variables are not expanded properly result = "$action $name $symname $overname $wrapname $parentclassname $parentclasssymname"; %} %inline %{ namespace Space { std::string exceptionvars(double i, double j) { return "b2"; } } %} %exception Space::overloadedmethod %{ $action result = Space::$symname(1.0); result = $name(); result = $name(2.0); // above will not compile if the variables are not expanded properly result = "$action $name $symname $overname $wrapname $parentclassname $parentclasssymname"; // $decl %} %inline %{ namespace Space { std::string overloadedmethod(double j) { return "c3"; } std::string overloadedmethod() { return "d4"; } } std::string declaration; %} %exception { $action declaration = "$fulldecl $decl"; } %inline %{ namespace SpaceNamespace { struct ABC { ABC(int a, double b) {} ABC() {} static short * staticmethod(int x, bool b) { return 0; } short * instancemethod(int x, bool b = false) { return 0; } short * constmethod(int x) const { return 0; } }; template struct Template { std::string tmethod(T t) { return ""; } }; void globtemplate(Template t) {} } %} %template(TemplateABC) SpaceNamespace::Template; /////////////////////////////////// directors ///////////////////////////////// %{ void DirectorTest_director_testmethod(int i) {} void DirectorTest_director_testmethodSwigExplicitDirectorTest(int i) {} %} %typemap(directorargout) int i { $symname(99); } %feature("director") DirectorTest; %inline %{ void director_testmethod(int i) {} struct DirectorTest { virtual void director_testmethod(int i) {} virtual ~DirectorTest() {} }; %} /////////////////////////////////// parentclasssymname parentclassname ///////////////////////////////// %exception instance_def { $action $parentclasssymname_aaa(); $parentclassname_bbb(); // above will not compile if the variables are not expanded properly } %exception static_def { $action $parentclasssymname_aaa(); $parentclassname_bbb(); // above will not compile if the variables are not expanded properly } %{ void DEFNewName_aaa() {} namespace SpaceNamespace { void DEF_bbb() {} } %} %rename(DEFNewName) DEF; %inline %{ namespace SpaceNamespace { struct DEF : ABC { void instance_def() {} static void static_def() {} }; } %} swig-3.0.2/Examples/test-suite/using1.i0000664000175000017500000000050512343605122017607 0ustar williamwilliam%module using1 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) X::_FooImpl; /* Ruby, wrong class name */ %inline %{ namespace X { typedef int Integer; class _FooImpl { public: typedef Integer value_type; }; typedef _FooImpl Foo; } namespace Y = X; using namespace Y; int spam(Foo::value_type x) { return x; } %} swig-3.0.2/Examples/test-suite/default_arg_values.i0000664000175000017500000000121112343605122022230 0ustar williamwilliam%module default_arg_values %{ struct Display { // Some compilers warn about 'float v = NULL', so only SWIG sees this peculiarity // Bad Python wrappers were being generated when NULL used for primitive type float draw1(float v = 0) { return v; } float draw2(float *v = 0) { return v ? *v : 0; } }; float* createPtr(float v) { static float val; val = v; return &val; } %} struct Display { // Bad Python wrappers were being generated when NULL used for primitive type float draw1(float v = NULL) { return v; } float draw2(float *v = NULL) { return v ? *v : 0; } }; float* createPtr(float v) { static float val; val = v; return &val; } swig-3.0.2/Examples/test-suite/template_construct.i0000664000175000017500000000033412343605122022320 0ustar williamwilliam%module template_construct // Tests templates to make sure an extra <> in a constructor is ok. %inline %{ template class Foo { T y; public: Foo(T x) : y(x) { } }; %} %template(Foo_int) Foo; swig-3.0.2/Examples/test-suite/template_typemaps_typedef2.i0000664000175000017500000001004212343605122023735 0ustar williamwilliam%module template_typemaps_typedef2 // Identical to template_typemaps_typedef, except for %template // Similar to template_typedef_class_template // Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters %inline %{ namespace Standard { template struct Pair { T first; U second; }; } %} %{ namespace Standard { template class Multimap { public: typedef Key key_type; typedef T mapped_type; class iterator { public: mapped_type mm; iterator(mapped_type m = mapped_type()) : mm(m) {} }; mapped_type typemap_test(Standard::Pair pp) { return pp.second.mm; } Standard::Pair* make_dummy_pair() { return new Standard::Pair(); } }; } %} namespace Standard { template class Multimap { public: typedef Key key_type; typedef T mapped_type; class iterator; %typemap(in) Standard::Pair "$1 = default_general< Key, T >();" mapped_type typemap_test(Standard::Pair pii1); Standard::Pair* make_dummy_pair(); }; } // specialization namespace Standard { template<> class Multimap { public: typedef A key_type; typedef int mapped_type; class iterator; // Note uses a different function to the non-specialized version %typemap(in) Standard::Pair "$1 = default_A_int< A, int >();" mapped_type typemap_test(Standard::Pair pii2); Standard::Pair* make_dummy_pair(); }; } %inline %{ struct A { int val; A(int v = 0): val(v) {} }; %} %{ // For < int, A > template Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_general() { Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value; default_value.second.mm = A(1234); return default_value; } // For < A, int > template Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_A_int() { Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value; default_value.second.mm = 4321; return default_value; } %} %inline %{ typedef A AA; namespace Space { typedef AA AB; } %} %template(PairIntA) Standard::Pair; %template(MultimapIntA) Standard::Multimap; %template(PairAInt) Standard::Pair; %template(MultimapAInt) Standard::Multimap; %inline %{ // Extend the test with some typedefs in the template parameters Standard::Multimap< int, AA >::mapped_type typedef_test1(Standard::Pair< Standard::Multimap< int, AA >::iterator, Standard::Multimap< int, AA >::iterator > pp) { return pp.second.mm; } Standard::Multimap< int, A >::mapped_type typedef_test2(Standard::Pair< Standard::Multimap< int, A >::iterator, Standard::Multimap< int, A >::iterator > pp) { return pp.second.mm; } Standard::Multimap< int, AA, int >::mapped_type typedef_test3(Standard::Pair< Standard::Multimap< int, AA, int >::iterator, Standard::Multimap< int, AA, int >::iterator > pp) { return pp.second.mm; } Standard::Multimap< int, A , int >::mapped_type typedef_test4(Standard::Pair< Standard::Multimap< int, A , int >::iterator, Standard::Multimap< int, A , int >::iterator > pp) { return pp.second.mm; } using namespace Space; Standard::Multimap< int, AB >::mapped_type typedef_test5(Standard::Pair< Standard::Multimap< int, AB >::iterator, Standard::Multimap< int, AB >::iterator > pp) { return pp.second.mm; } Standard::Multimap< int, AB, int >::mapped_type typedef_test6(Standard::Pair< Standard::Multimap< int, AB, int >::iterator, Standard::Multimap< int, AB, int >::iterator > pp) { return pp.second.mm; } %} swig-3.0.2/Examples/test-suite/rename_pcre_encoder.i0000664000175000017500000000176612343605122022372 0ustar williamwilliam%module rename_pcre_encoder // strip the wx prefix from all identifiers except those starting with wxEVT %rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; // Change "{Set,Get}Foo" naming convention to "{put,get}_foo" one. %rename("%(regex:/^Set(.*)/put_\\l\\1/)s", %$isfunction) ""; %rename("%(regex:/^Get(.*)/get_\\l\\1/)s", %$isfunction) ""; // Make some words stand out (unfortunately we don't have "global" flag): we // use \U to capitalize the second capture group and then \E to preserve the // case of the rest. %rename("%(regex:/(.*?)(nsa)(.*?)\\2(.*?)\\2(.*?)\\2(.*)/\\1\\U\\2\\E\\3\\U\\2\\E\\4\\U\\2\\E\\5\\U\\2\\E\\6/)s") ""; %inline %{ struct wxSomeWidget { void SetBorderWidth(int width) { m_width = width; } int GetBorderWidth() const { return m_width; } void SetSize(int, int) {} int m_width; }; struct wxAnotherWidget { void DoSomething() {} }; class wxEVTSomeEvent { }; class xUnchangedName { }; inline int StartInsaneAndUnsavoryTransatlanticRansack() { return 42; } %} swig-3.0.2/Examples/test-suite/template_default_arg.i0000664000175000017500000000744312343605122022561 0ustar williamwilliam%module template_default_arg %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hello; /* Ruby, wrong class name */ #ifdef SWIGLUA // lua only has one numeric type, so most of the overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) X; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Z; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) meth; #endif %inline %{ template struct Foo { typedef unsigned int size_type; Foo(size_type n = size_type(0) ) { } }; int foob(Foo h = Foo()) {return 1; } template struct Hello { typedef unsigned int size_type; // This works // Hello(size_type n = Hello::size_type(0) ) { } // This doesn't Hello(size_type n = size_type(0) ) { } enum Hi { hi, hello }; void foo(Hi h = hi) { } }; template struct X { X(const T& t = T()) {} X(double a, const T& t = T(0)) {} T meth(double a, const T& t = T(0)) { return t; } const T& meth(const T& t = T(0)) { return t; } }; template class Y : private X { public: // test using on templated class with default args in the method using X::meth; }; template struct Z { Z(int t = V) {} // and also: Z(double a, int t = V){} }; %} %template(Foo_int) Foo; %template(Hello_int) Hello; %template(X_int) X; %template(X_longlong) X; %template(X_unsigned) X; %template(Y_unsigned) Y; %template(X_hello_unsigned) X >; %template(Y_hello_unsigned) Y >; %template(X_Foo_Foo_int) X > >; %template(Z_8) Z<8>; %template(Foo_Z_8) Foo >; %template(X_Foo_Z_8) X > >; %inline %{ struct Bar : Hello { Bar(size_type n) : Hello(n) { } }; %} // Templated functions %inline %{ // Templated methods which are overloaded and have default args, and %template which // uses the same name as the C++ functions and overload on the template parameters and // specialization thrown in too. Wow, SWIG can handle this insane stuff! template int ott(T t = 0, const U& u = U()) { return 10; } template int ott(const char *msg, T t = 0, const U& u = U()) { return 20; } int ott(Foo) { return 30; } template int ott(Hello h, T t = 0) { return 40; } template<> int ott(Hello h, int t) { return 50; } template<> int ott(Hello h, double t) { return 60; } %} %template(ott) ott; %template(ott) ott; %template(ottint) ott; // default arg requires a rename %template(ottstring) ott; // default arg requires a rename // Above test in namespaces %inline %{ namespace OuterSpace { namespace InnerSpace { // Templated methods which are overloaded and have default args, and %template which // uses the same name as the C++ functions and overload on the template parameters and // specialization thrown in too. Wow, SWIG can handle this insane stuff! template int nsott(T t = 0, const U& u = U()) { return 110; } template int nsott(const char *msg, T t = 0, const U& u = U()) { return 120; } int nsott(Foo) { return 130; } template int nsott(Hello h, T t = 0) { return 140; } template<> int nsott(Hello h, int t) { return 150; } template<> int nsott(Hello h, double t) { return 160; } } } %} %template(nsott) OuterSpace::InnerSpace::nsott; %template(nsott) OuterSpace::InnerSpace::nsott; %template(nsottint) OuterSpace::InnerSpace::nsott; // default arg requires a rename %template(nsottstring) OuterSpace::InnerSpace::nsott; // default arg requires a rename swig-3.0.2/Examples/test-suite/cpp11_noexcept.i0000664000175000017500000000261312343605122021234 0ustar williamwilliam%module cpp11_noexcept %ignore NoExceptClass(NoExceptClass&&); %rename(Assignment) NoExceptClass::operator=; %inline %{ extern "C" void global_noexcept(int, bool) noexcept; struct NoExceptClass { static const bool VeryTrue = true; NoExceptClass() noexcept {} NoExceptClass(const NoExceptClass&) noexcept {} NoExceptClass(NoExceptClass&&) noexcept {} NoExceptClass& operator=(const NoExceptClass&) noexcept {} ~NoExceptClass() noexcept {} void noex0() noexcept {} void noex1() noexcept(sizeof(int) == 4) {} void noex2() noexcept(true) {} void noex3() noexcept(false) {} void noex4() noexcept(VeryTrue) {} template void template_noexcept(T) noexcept {} void noo1() const noexcept {} static void noo2() noexcept {} virtual void noo3() const noexcept {} virtual void noo4() const noexcept = delete; virtual void noo5() const throw() = delete; }; struct NoExceptAbstract { virtual void noo4() const noexcept = 0; virtual ~NoExceptAbstract() noexcept = 0; }; struct NoExceptDefaultDelete { template NoExceptDefaultDelete(T) noexcept = delete; NoExceptDefaultDelete() noexcept = default; NoExceptDefaultDelete(const NoExceptDefaultDelete&) noexcept = delete; NoExceptDefaultDelete(NoExceptDefaultDelete&&) = delete; NoExceptDefaultDelete& operator=(const NoExceptDefaultDelete&) = delete; ~NoExceptDefaultDelete() noexcept = default; }; %} swig-3.0.2/Examples/test-suite/enum_thorough_typeunsafe.i0000664000175000017500000000030712343605122023527 0ustar williamwilliam%module "enum_thorough_typeunsafe" // Test enum wrapping using a type unsafe enum pattern (constant integers in a class for the enum type) %include "enumtypeunsafe.swg" %include "enum_thorough.i" swig-3.0.2/Examples/test-suite/uffi/0000775000175000017500000000000012343605122017160 5ustar williamwilliamswig-3.0.2/Examples/test-suite/uffi/Makefile.in0000664000175000017500000000234512343605122021231 0ustar williamwilliam####################################################################### # Makefile for uffi test-suite ####################################################################### LANGUAGE = uffi UFFI = @UFFIBIN@ SCRIPTSUFFIX = _runme.lisp srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ include $(srcdir)/../common.mk # Overridden variables here # no C++ tests for now CPP_TEST_CASES = #C_TEST_CASES += # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.lisp appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFI) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra uffi code) %.clean: @exit 0 clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" uffi_clean swig-3.0.2/Examples/test-suite/overload_extend.i0000664000175000017500000000177212343605122021572 0ustar williamwilliam%module overload_extend #ifndef __cplusplus %{ #include %} %typemap(default) double y "$1=1000;"; #endif #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_PARSE_REDEFINED, SWIGWARN_LANG_OVERLOAD_SHADOW) Foo::test; #else %warnfilter(SWIGWARN_PARSE_REDEFINED) Foo::test; #endif %extend Foo { int test() { return 0; } int test(int x) { x = 0; return 1; } int test(char *s) { s = 0; return 2; } #ifdef __cplusplus double test(double x, double y = 1000) { return x + y; } #else double test(double x, double y) { return x + y; } #endif }; %inline %{ struct Foo { int variable; #ifdef __cplusplus int test() { return -1; } #endif }; %} %extend Bar { #ifdef __cplusplus Bar() { return new Bar(); } ~Bar() { delete $self; } #else Bar() { return (Bar *) malloc(sizeof(Bar)); } ~Bar() { free($self); } #endif } %inline %{ typedef struct { int variable; } Bar; %} swig-3.0.2/Examples/test-suite/global_namespace.i0000664000175000017500000000437012343605122021661 0ustar williamwilliam%module global_namespace // classes %inline %{ class Klass1 {}; class Klass2 {}; class Klass3 {}; class Klass4 {}; class Klass5 {}; class Klass6 {}; class Klass7 {}; struct KlassMethods { static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, ::Klass7*const& pr) {} static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*const& pr) {} }; %} %inline %{ namespace Space { class XYZ1 {}; class XYZ2 {}; class XYZ3 {}; class XYZ4 {}; class XYZ5 {}; class XYZ6 {}; class XYZ7 {}; } struct XYZMethods { static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, ::Space::XYZ7*const& pr) {} static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*const& pr) {} }; %} //enums %inline %{ enum AnEnum1 { anenum1 }; enum AnEnum2 { anenum2 }; enum AnEnum3 { anenum3 }; struct AnEnumMethods { static void methodA(::AnEnum1 v, const ::AnEnum2 cv, const ::AnEnum3 &cr) {} static void methodB( AnEnum1 v, const AnEnum2 cv, const AnEnum3 &cr) {} }; %} %inline %{ namespace Space { enum TheEnum1 { theenum1 }; enum TheEnum2 { theenum2 }; enum TheEnum3 { theenum3 }; struct TheEnumMethods { static void methodA(::Space::TheEnum1 v, const ::Space::TheEnum2 cv, const ::Space::TheEnum3 &cr) {} static void methodB( Space::TheEnum1 v, const Space::TheEnum2 cv, const Space::TheEnum3 &cr) {} }; } %} %inline %{ Klass1 getKlass1A() { return ::Klass1(); } ::Klass1 getKlass1B() { return ::Klass1(); } Klass2 getKlass2A() { return ::Klass2(); } ::Klass2 getKlass2B() { return ::Klass2(); } Klass3 getKlass3A() { return ::Klass3(); } ::Klass3 getKlass3B() { return ::Klass3(); } Klass4 getKlass4A() { return ::Klass4(); } ::Klass4 getKlass4B() { return ::Klass4(); } Klass5 getKlass5A() { return ::Klass5(); } ::Klass5 getKlass5B() { return ::Klass5(); } Klass6 getKlass6A() { return ::Klass6(); } ::Klass6 getKlass6B() { return ::Klass6(); } Klass7 getKlass7A() { return ::Klass7(); } ::Klass7 getKlass7B() { return ::Klass7(); } %} swig-3.0.2/Examples/test-suite/template_inherit_abstract.i0000664000175000017500000000271412343605122023625 0ustar williamwilliam%module(ruby_minherit="1") template_inherit_abstract %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::test; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, D, Java, PHP multiple inheritance */ %inline %{ namespace oss { template struct Wrap { }; struct ModuleBase { virtual ~ModuleBase() {} virtual int get() = 0; }; template struct Module : C, ModuleBase { virtual ~Module() {} protected: Module() {} }; template struct HModule : Module > { // virtual int get(); // declaration here works protected: HModule() {} }; } struct B { }; %} namespace oss { %template(Wrap_B) Wrap; %template(Module_B) Module >; %template(HModule_B) HModule; } %inline %{ namespace oss { #if defined(SWIG) && (defined(SWIGCSHARP) || defined(SWIGD)) %ignore HModule::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored. #endif struct test : HModule { virtual int get() {return 0;} // declaration here breaks swig }; } %} swig-3.0.2/Examples/test-suite/valuewrapper_const.i0000664000175000017500000000106112343605122022322 0ustar williamwilliam%module valuewrapper_const %inline %{ // B requires swig to use the SwigValueWrapper class B { private: B() { } public: B(const B&){ } }; // A returns a B and a const B class A { B b; public: A(const B& b) : b(b) { } // this one works SwigValueWrapper< B > result; B GetB() { return b; } // this one is incorrect B result; const B GetBconst() const { return b; } ::B GetBGlobalQualifier() { return b; } const ::B GetBconstGlobalGlobalQualifier() const { return b; } }; %} swig-3.0.2/Examples/test-suite/template_typedef_ns.i0000664000175000017500000000040112343605122022427 0ustar williamwilliam%module("templatereduce") template_typedef_ns %inline { namespace Alpha { typedef int Integer; } namespace Beta { template struct Alpha { Value x; }; } } %template(AlphaInt) Beta::Alpha; swig-3.0.2/Examples/test-suite/preproc_include_f withspace.h0000664000175000017500000000003112343605122024024 0ustar williamwilliam int multiply60(int a); swig-3.0.2/Examples/test-suite/enums.i0000664000175000017500000000332212343605122017530 0ustar williamwilliam/* Test whether varios enums in C. */ %module "enums" /* Suppress warning messages from the Ruby module for all of the following.. */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) boo; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hoo; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); %inline %{ typedef enum { CSP_ITERATION_FWD, CSP_ITERATION_BWD = 11 } foo1; typedef enum foo2 { ABCDE = 0, FGHJI = 1 } foo3; void bar1(foo1 x) {} void bar2(enum foo2 x) {} void bar3(foo3 x) {} enum sad { boo, hoo = 5 }; #ifdef __cplusplus /* For Octave and g++ which compiles C test code as C++ */ extern "C" { #endif /* Unnamed enum instance */ enum { globalinstance1, globalinstance2, globalinstance3 = 30 } GlobalInstance; #ifdef __cplusplus } #endif /* Anonymous enum */ enum { AnonEnum1, AnonEnum2 = 100 }; %} %inline %{ typedef struct _Foo { enum { BAR1, BAR2 } e; } Foo; %} %warnfilter(SWIGWARN_RUBY_WRONG_NAME) _iFoo; #ifdef SWIGD /* Work around missing support for proper char quoting due to parser shortcomings. */ %dconstvalue("'a'") _iFoo::Char; #endif #ifndef __cplusplus %inline %{ typedef struct _iFoo { enum { Phoo = +50, Char = 'a' } e; } iFoo; %} #else %inline %{ struct iFoo { enum { Phoo = +50, Char = 'a' }; }; %} #endif // enum declaration and initialization %inline %{ enum Exclamation { goodness, gracious, me } enumInstance = me; enum ContainYourself { slap = 10, mine, thigh } Slap = slap, Mine = mine, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, mine, thigh}; %} swig-3.0.2/Examples/test-suite/csharp/0000775000175000017500000000000012343605122017507 5ustar williamwilliamswig-3.0.2/Examples/test-suite/csharp/overload_complicated_runme.cs0000664000175000017500000000257412343605122025433 0ustar williamwilliamusing System; using overload_complicatedNamespace; public class runme { static void Main() { SWIGTYPE_p_int pInt = null; // Check the correct constructors are available Pop p = new Pop(pInt); p = new Pop(pInt, false); // Check overloaded in const only and pointers/references which target languages cannot disambiguate if (p.hip(false) != 701) throw new Exception("Test 1 failed"); if (p.hip(pInt) != 702) throw new Exception("Test 2 failed"); // Reverse the order for the above if (p.hop(pInt) != 805) throw new Exception("Test 3 failed"); if (p.hop(false) != 801) throw new Exception("Test 4 failed"); // Few more variations and order shuffled if (p.pop(false) != 901) throw new Exception("Test 5 failed"); if (p.pop(pInt) != 902) throw new Exception("Test 6 failed"); if (p.pop() != 905) throw new Exception("Test 7 failed"); // Overload on const only if (p.bop(pInt) != 1001) throw new Exception("Test 8 failed"); if (p.bip(pInt) != 2001) throw new Exception("Test 9 failed"); // Globals if (overload_complicated.muzak(false) != 3001) throw new Exception("Test 10 failed"); if (overload_complicated.muzak(pInt) != 3002) throw new Exception("Test 11 failed"); } } swig-3.0.2/Examples/test-suite/csharp/rename_simple_runme.cs0000664000175000017500000000203412343605122024063 0ustar williamwilliam using System; using rename_simpleNamespace; public class rename_simple_runme { public static void Main() { NewStruct s = new NewStruct(); check(111, s.NewInstanceVariable, "NewInstanceVariable"); check(222, s.NewInstanceMethod(), "NewInstanceMethod"); check(333, NewStruct.NewStaticMethod(), "NewStaticMethod"); check(444, NewStruct.NewStaticVariable, "NewStaticVariable"); check(555, rename_simple.NewFunction(), "NewFunction"); check(666, rename_simple.NewGlobalVariable, "NewGlobalVariable"); s.NewInstanceVariable = 1111; NewStruct.NewStaticVariable = 4444; rename_simple.NewGlobalVariable = 6666; check(1111, s.NewInstanceVariable, "NewInstanceVariable"); check(4444, NewStruct.NewStaticVariable, "NewStaticVariable"); check(6666, rename_simple.NewGlobalVariable, "NewGlobalVariable"); } public static void check(int expected, int actual, string msg) { if (expected != actual) throw new Exception("Failed: Expected: " + expected + " actual: " + actual + " " + msg); } } swig-3.0.2/Examples/test-suite/csharp/long_long_runme.cs0000664000175000017500000000203412343605122023221 0ustar williamwilliam // This is the long_long runtime testcase. It checks that the long long and // unsigned long long types work. using System; using long_longNamespace; public class long_long_runme { public static void Main() { check_ll(0L); check_ll(0x7FFFFFFFFFFFFFFFL); check_ll(-10); check_ull(0); check_ull(127); check_ull(128); check_ull(9223372036854775807); //0x7FFFFFFFFFFFFFFFL check_ull(18446744073709551615); //0xFFFFFFFFFFFFFFFFL } public static void check_ll(long ll) { long_long.ll = ll; long ll_check = long_long.ll; if (ll != ll_check) { string ErrorMessage = "Runtime test using long long failed. ll=" + ll + " ll_check=" + ll_check; throw new Exception(ErrorMessage); } } public static void check_ull(ulong ull) { long_long.ull = ull; ulong ull_check = long_long.ull; if (ull != ull_check) { string ErrorMessage = "Runtime test using unsigned long long failed. ull=" + ull + " ull_check=" + ull_check; throw new Exception(ErrorMessage); } } } swig-3.0.2/Examples/test-suite/csharp/director_classic_runme.cs0000664000175000017500000001432412343605122024564 0ustar williamwilliamusing System; namespace director_classicNamespace { public class runme { static void Main() { { Person person = new Person(); check(person, "Person"); person.Dispose(); } { Person person = new Child(); check(person, "Child"); person.Dispose(); } { Person person = new GrandChild(); check(person, "GrandChild"); person.Dispose(); } { Person person = new TargetLangPerson(); check(person, "TargetLangPerson"); person.Dispose(); } { Person person = new TargetLangChild(); check(person, "TargetLangChild"); person.Dispose(); } { Person person = new TargetLangGrandChild(); check(person, "TargetLangGrandChild"); person.Dispose(); } // Semis - don't override id() in target language { Person person = new TargetLangSemiPerson(); check(person, "Person"); person.Dispose(); } { Person person = new TargetLangSemiChild(); check(person, "Child"); person.Dispose(); } { Person person = new TargetLangSemiGrandChild(); check(person, "GrandChild"); person.Dispose(); } // Orphans - don't override id() in C++ { Person person = new OrphanPerson(); check(person, "Person"); person.Dispose(); } { Person person = new OrphanChild(); check(person, "Child"); person.Dispose(); } { Person person = new TargetLangOrphanPerson(); check(person, "TargetLangOrphanPerson"); person.Dispose(); } { Person person = new TargetLangOrphanChild(); check(person, "TargetLangOrphanChild"); person.Dispose(); } // Duals - id() makes an upcall to the base id() { Person person = new TargetLangDualPerson(); check(person, "TargetLangDualPerson + Person"); person.Dispose(); } { Person person = new TargetLangDualChild(); check(person, "TargetLangDualChild + Child"); person.Dispose(); } { Person person = new TargetLangDualGrandChild(); check(person, "TargetLangDualGrandChild + GrandChild"); person.Dispose(); } // Mix Orphans and Duals { Person person = new TargetLangDualOrphanPerson(); check(person, "TargetLangDualOrphanPerson + Person"); person.Dispose(); } { Person person = new TargetLangDualOrphanChild(); check(person, "TargetLangDualOrphanChild + Child"); person.Dispose(); } } static void check(Person person, String expected) { String ret; // Normal target language polymorphic call ret = person.id(); if (debug) Console.WriteLine(ret); if (ret != expected) throw new Exception("Failed. Received: " + ret + " Expected: " + expected); // Polymorphic call from C++ Caller caller = new Caller(); caller.setCallback(person); ret = caller.call(); if (debug) Console.WriteLine(ret); if (ret != expected) throw new Exception("Failed. Received: " + ret + " Expected: " + expected); // Polymorphic call of object created in target language and passed to C++ and back again Person baseclass = caller.baseClass(); ret = baseclass.id(); if (debug) Console.WriteLine(ret); if (ret != expected) throw new Exception("Failed. Received: " + ret + " Expected: " + expected); caller.resetCallback(); if (debug) Console.WriteLine("----------------------------------------"); } static bool debug = false; } public class TargetLangPerson : Person { public TargetLangPerson() : base() { } public override String id() { String identifier = "TargetLangPerson"; return identifier; } } public class TargetLangChild : Child { public TargetLangChild() : base() { } public override String id() { String identifier = "TargetLangChild"; return identifier; } } public class TargetLangGrandChild : GrandChild { public TargetLangGrandChild() : base() { } public override String id() { String identifier = "TargetLangGrandChild"; return identifier; } } // Semis - don't override id() in target language public class TargetLangSemiPerson : Person { public TargetLangSemiPerson() : base() { } // No id() override } public class TargetLangSemiChild : Child { public TargetLangSemiChild() : base() { } // No id() override } public class TargetLangSemiGrandChild : GrandChild { public TargetLangSemiGrandChild() : base() { } // No id() override } // Orphans - don't override id() in C++ class TargetLangOrphanPerson : OrphanPerson { public TargetLangOrphanPerson() : base() { } public override String id() { String identifier = "TargetLangOrphanPerson"; return identifier; } } class TargetLangOrphanChild : OrphanChild { public TargetLangOrphanChild() : base() { } public override String id() { String identifier = "TargetLangOrphanChild"; return identifier; } } // Duals - id() makes an upcall to the base id() class TargetLangDualPerson : Person { public TargetLangDualPerson() : base() { } public override String id() { String identifier = "TargetLangDualPerson + " + base.id(); return identifier; } } class TargetLangDualChild : Child { public TargetLangDualChild() : base() { } public override String id() { String identifier = "TargetLangDualChild + " + base.id(); return identifier; } } class TargetLangDualGrandChild : GrandChild { public TargetLangDualGrandChild() : base() { } public override String id() { String identifier = "TargetLangDualGrandChild + " + base.id(); return identifier; } } // Mix Orphans and Duals class TargetLangDualOrphanPerson : OrphanPerson { public TargetLangDualOrphanPerson() : base() { } public override String id() { String identifier = "TargetLangDualOrphanPerson + " + base.id(); return identifier; } } class TargetLangDualOrphanChild : OrphanChild { public TargetLangDualOrphanChild() : base() { } public override String id() { String identifier = "TargetLangDualOrphanChild + " + base.id(); return identifier; } } } swig-3.0.2/Examples/test-suite/csharp/README0000664000175000017500000000340312343605122020367 0ustar williamwilliamSWIG testsuite README file -------------------------- This testsuite is here to ensure SWIG can handle a wide range of c/c++ syntax. The testsuite comprises many testcases in this directory. Each test case is tested under each of the language modules thereby thoroughly testing all of SWIG. It ensures that each of the language modules are at a similar standard. Those modules that support shadow classes run the tests producing shadow classes to test the full language module functionality. Some test cases need a runtime test. These need implementing in each of the language modules. The language modules look for a file in the language specific test-suite directory which has _runme appended after the testcase name. If one is found it will be run as part of the test. Some language modules add to this common set of test cases for language specific tests. These can be found in the appropriate language test-suite directory. There is also a README in each of the language module directories. For each testcase a message showing which testcase is being tested is displayed. Nothing else is printed unless the test fails. Some Developer Guidelines ------------------------- Note that the whole test suite need not be run each time a testcase is modified. An individual testcase may be run by going to the language module test-suite directory and using make testcasename.xxx where xxx is the type of test (eg cpptest). See common.mk. make -s doesn't print any junk on the screen and is useful for emulating the way make check works from the SWIG root directory. If there are runtime tests needed, don't print anything unless there is an error in which case stderr is suggested. Please set the name of the module to the same name as the testcase, otherwise modules will not be found. swig-3.0.2/Examples/test-suite/csharp/inherit_target_language_runme.cs0000664000175000017500000000116212343605122026117 0ustar williamwilliamusing System; using inherit_target_languageNamespace; public class inherit_target_language_runme { public static void Main() { new Derived1().targetLanguageBaseMethod(); new Derived2().targetLanguageBaseMethod(); new MultipleDerived1().targetLanguageBaseMethod(); new MultipleDerived2().targetLanguageBaseMethod(); new MultipleDerived3().f(); new MultipleDerived4().g(); BaseX baseX = new BaseX(); baseX.basex(); baseX.targetLanguageBase2Method(); DerivedX derivedX = new DerivedX(); derivedX.basex(); derivedX.derivedx(); derivedX.targetLanguageBase2Method(); } } swig-3.0.2/Examples/test-suite/csharp/enum_thorough_simple_runme.cs0000664000175000017500000010546512343605122025513 0ustar williamwilliamusing System; using enum_thorough_simpleNamespace; public class runme { static void Main() { { // Anonymous enums int i = enum_thorough_simple.AnonEnum1; if (enum_thorough_simple.ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed"); i += enum_thorough_simple.AnonSpaceEnum1; i += AnonStruct.AnonStructEnum1; } { int red = enum_thorough_simple.red; enum_thorough_simple.colourTest1(red); enum_thorough_simple.colourTest2(red); enum_thorough_simple.colourTest3(red); enum_thorough_simple.colourTest4(red); enum_thorough_simple.myColour = red; } { SpeedClass s = new SpeedClass(); int speed = SpeedClass.slow; if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed"); if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed"); if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed"); if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed"); if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed"); if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed"); if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed"); if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed"); if (enum_thorough_simple.speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed"); if (enum_thorough_simple.speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed"); if (enum_thorough_simple.speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed"); if (enum_thorough_simple.speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed"); if (enum_thorough_simple.speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed"); } { SpeedClass s = new SpeedClass(); int slow = SpeedClass.slow; int lightning = SpeedClass.lightning; if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed"); if (s.mySpeedtd1 != 10) throw new Exception("mySpeedtd1 2 failed"); s.mySpeedtd1 = lightning; if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed"); if (s.mySpeedtd1 != 31) throw new Exception("mySpeedtd1 4 failed"); } { if (enum_thorough_simple.namedanonTest1(enum_thorough_simple.NamedAnon2) != enum_thorough_simple.NamedAnon2) throw new Exception("namedanonTest 1 failed"); } { int val = enum_thorough_simple.TwoNames2; if (enum_thorough_simple.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed"); if (enum_thorough_simple.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed"); if (enum_thorough_simple.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed"); } { TwoNamesStruct t = new TwoNamesStruct(); int val = TwoNamesStruct.TwoNamesStruct1; if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed"); if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed"); if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed"); } { int val = enum_thorough_simple.NamedAnonSpace2; if (enum_thorough_simple.namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed"); if (enum_thorough_simple.namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed"); if (enum_thorough_simple.namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed"); if (enum_thorough_simple.namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed"); } { TemplateClassInt t = new TemplateClassInt(); int galileo = TemplateClassInt.galileo; if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed"); if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed"); if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed"); if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed"); if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed"); if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed"); if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed"); if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed"); if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed"); // if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed"); if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed"); // if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed"); if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed"); if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed"); if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed"); if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed"); if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed"); if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed"); if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed"); if (enum_thorough_simple.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed"); if (enum_thorough_simple.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed"); if (enum_thorough_simple.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed"); if (enum_thorough_simple.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed"); if (enum_thorough_simple.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed"); if (enum_thorough_simple.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed"); if (enum_thorough_simple.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed"); if (enum_thorough_simple.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed"); } { TClassInt t = new TClassInt(); int bell = TClassInt.bell; int galileo = TemplateClassInt.galileo; if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed"); if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed"); if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed"); if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed"); if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed"); if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed"); if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed"); if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed"); if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed"); // if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed"); if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed"); // if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed"); if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed"); if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed"); if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed"); if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed"); if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed"); if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed"); if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed"); if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed"); if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed"); if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed"); if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed"); if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed"); if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed"); if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed"); if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed"); if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed"); if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed"); if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed"); if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed"); if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed"); if (enum_thorough_simple.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed"); if (enum_thorough_simple.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed"); if (enum_thorough_simple.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed"); if (enum_thorough_simple.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed"); if (enum_thorough_simple.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed"); if (enum_thorough_simple.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed"); if (enum_thorough_simple.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed"); if (enum_thorough_simple.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed"); if (enum_thorough_simple.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed"); if (enum_thorough_simple.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed"); if (enum_thorough_simple.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed"); if (enum_thorough_simple.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed"); if (enum_thorough_simple.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed"); if (enum_thorough_simple.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed"); if (enum_thorough_simple.scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed"); if (enum_thorough_simple.scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed"); if (enum_thorough_simple.scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed"); if (enum_thorough_simple.scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed"); if (enum_thorough_simple.scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed"); if (enum_thorough_simple.scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed"); if (enum_thorough_simple.scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed"); if (enum_thorough_simple.scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed"); if (enum_thorough_simple.scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed"); if (enum_thorough_simple.scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed"); if (enum_thorough_simple.scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed"); if (enum_thorough_simple.scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed"); if (enum_thorough_simple.scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed"); if (enum_thorough_simple.scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed"); } { int val = enum_thorough_simple.argh; if (enum_thorough_simple.renameTest1(val) != val) throw new Exception("renameTest Global 1 failed"); if (enum_thorough_simple.renameTest2(val) != val) throw new Exception("renameTest Global 2 failed"); } { NewNameStruct n = new NewNameStruct(); if (n.renameTest1(NewNameStruct.bang) != NewNameStruct.bang) throw new Exception("renameTest 1 failed"); if (n.renameTest2(NewNameStruct.bang) != NewNameStruct.bang) throw new Exception("renameTest 2 failed"); if (n.renameTest3(NewNameStruct.simple1) != NewNameStruct.simple1) throw new Exception("renameTest 3 failed"); if (n.renameTest4(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest 4 failed"); if (n.renameTest5(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest 5 failed"); if (n.renameTest6(NewNameStruct.singlename1) != NewNameStruct.singlename1) throw new Exception("renameTest 6 failed"); } { if (enum_thorough_simple.renameTest3(NewNameStruct.bang) != NewNameStruct.bang) throw new Exception("renameTest Global 3 failed"); if (enum_thorough_simple.renameTest4(NewNameStruct.simple1) != NewNameStruct.simple1) throw new Exception("renameTest Global 4 failed"); if (enum_thorough_simple.renameTest5(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest Global 5 failed"); if (enum_thorough_simple.renameTest6(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest Global 6 failed"); if (enum_thorough_simple.renameTest7(NewNameStruct.singlename1) != NewNameStruct.singlename1) throw new Exception("renameTest Global 7 failed"); } { TreesClass t = new TreesClass(); int pine = TreesClass.pine; if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed"); if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed"); if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed"); if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed"); if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed"); if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed"); if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed"); if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed"); if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed"); if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed"); if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed"); if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed"); if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed"); if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed"); if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed"); if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed"); if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed"); if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed"); if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed"); if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed"); if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed"); if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed"); if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed"); if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed"); if (enum_thorough_simple.treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed"); if (enum_thorough_simple.treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed"); if (enum_thorough_simple.treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed"); if (enum_thorough_simple.treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed"); if (enum_thorough_simple.treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed"); if (enum_thorough_simple.treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed"); if (enum_thorough_simple.treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed"); if (enum_thorough_simple.treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed"); if (enum_thorough_simple.treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed"); if (enum_thorough_simple.treesTestA(pine) != pine) throw new Exception("treesTest Global A failed"); if (enum_thorough_simple.treesTestB(pine) != pine) throw new Exception("treesTest Global B failed"); if (enum_thorough_simple.treesTestC(pine) != pine) throw new Exception("treesTest Global C failed"); if (enum_thorough_simple.treesTestD(pine) != pine) throw new Exception("treesTest Global D failed"); if (enum_thorough_simple.treesTestE(pine) != pine) throw new Exception("treesTest Global E failed"); if (enum_thorough_simple.treesTestF(pine) != pine) throw new Exception("treesTest Global F failed"); if (enum_thorough_simple.treesTestG(pine) != pine) throw new Exception("treesTest Global G failed"); if (enum_thorough_simple.treesTestH(pine) != pine) throw new Exception("treesTest Global H failed"); if (enum_thorough_simple.treesTestI(pine) != pine) throw new Exception("treesTest Global I failed"); if (enum_thorough_simple.treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed"); if (enum_thorough_simple.treesTestK(pine) != pine) throw new Exception("treesTest Global K failed"); if (enum_thorough_simple.treesTestL(pine) != pine) throw new Exception("treesTest Global L failed"); if (enum_thorough_simple.treesTestM(pine) != pine) throw new Exception("treesTest Global M failed"); // if (enum_thorough_simple.treesTestN(pine) != pine) throw new Exception("treesTest Global N failed"); if (enum_thorough_simple.treesTestO(pine) != pine) throw new Exception("treesTest Global O failed"); if (enum_thorough_simple.treesTestP(pine) != pine) throw new Exception("treesTest Global P failed"); if (enum_thorough_simple.treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed"); if (enum_thorough_simple.treesTestR(pine) != pine) throw new Exception("treesTest Global R failed"); } { HairStruct h = new HairStruct(); int ginger = HairStruct.ginger; if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed"); if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed"); if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed"); if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed"); if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed"); if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed"); if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed"); if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed"); if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed"); if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed"); if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed"); int red = enum_thorough_simple.red; if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed"); if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed"); if (h.namedanonTest1(enum_thorough_simple.NamedAnon2) != enum_thorough_simple.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed"); if (h.namedanonspaceTest1(enum_thorough_simple.NamedAnonSpace2) != enum_thorough_simple.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed"); int fir = TreesClass.fir; if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed"); if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed"); if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed"); if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed"); } { int blonde = HairStruct.blonde; if (enum_thorough_simple.hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed"); if (enum_thorough_simple.hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed"); if (enum_thorough_simple.hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed"); if (enum_thorough_simple.hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed"); if (enum_thorough_simple.hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed"); if (enum_thorough_simple.hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed"); if (enum_thorough_simple.hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed"); if (enum_thorough_simple.hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed"); if (enum_thorough_simple.hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed"); if (enum_thorough_simple.hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed"); if (enum_thorough_simple.hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed"); if (enum_thorough_simple.hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed"); if (enum_thorough_simple.hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed"); if (enum_thorough_simple.hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed"); if (enum_thorough_simple.hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed"); if (enum_thorough_simple.hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed"); if (enum_thorough_simple.hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed"); if (enum_thorough_simple.hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed"); if (enum_thorough_simple.hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed"); if (enum_thorough_simple.hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed"); if (enum_thorough_simple.hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed"); if (enum_thorough_simple.hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed"); if (enum_thorough_simple.hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed"); if (enum_thorough_simple.hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed"); if (enum_thorough_simple.hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed"); if (enum_thorough_simple.hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed"); if (enum_thorough_simple.hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed"); if (enum_thorough_simple.hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed"); if (enum_thorough_simple.hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed"); if (enum_thorough_simple.hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed"); if (enum_thorough_simple.hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed"); if (enum_thorough_simple.hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed"); if (enum_thorough_simple.hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed"); if (enum_thorough_simple.hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed"); if (enum_thorough_simple.hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed"); if (enum_thorough_simple.hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed"); if (enum_thorough_simple.hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed"); if (enum_thorough_simple.hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed"); if (enum_thorough_simple.hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed"); if (enum_thorough_simple.hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed"); if (enum_thorough_simple.hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed"); if (enum_thorough_simple.hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed"); if (enum_thorough_simple.hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed"); if (enum_thorough_simple.hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed"); if (enum_thorough_simple.hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed"); if (enum_thorough_simple.hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed"); if (enum_thorough_simple.hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed"); if (enum_thorough_simple.hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed"); } { FirStruct f = new FirStruct(); int blonde = HairStruct.blonde; if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed"); if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed"); if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed"); if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed"); if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed"); if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed"); if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed"); if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed"); if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed"); if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed"); } { enum_thorough_simple.GlobalInstance = enum_thorough_simple.globalinstance2; if (enum_thorough_simple.GlobalInstance != enum_thorough_simple.globalinstance2) throw new Exception("GlobalInstance 1 failed"); Instances i = new Instances(); i.MemberInstance = Instances.memberinstance3; if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed"); } // ignore enum item tests start { if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed"); if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed"); if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed"); if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed"); if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed"); if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed"); if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed"); if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed"); if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed"); if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed"); } { if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed"); if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed"); if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed"); if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed"); if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed"); if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed"); } { if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed"); if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed"); if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed"); if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed"); if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed"); if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed"); } { if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed"); if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed"); } { if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed"); if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed"); if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed"); } // ignore enum item tests end { if (enum_thorough_simple.repeatTest(enum_thorough_simple.one) != 1) throw new Exception("repeatTest 1 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.initial) != 1) throw new Exception("repeatTest 2 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.two) != 2) throw new Exception("repeatTest 3 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.three) != 3) throw new Exception("repeatTest 4 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed"); } // different types { if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeint) != 10) throw new Exception("differentTypes 1 failed"); if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed"); if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltrue) != 1) throw new Exception("differentTypes 3 failed"); if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltwo) != 2) throw new Exception("differentTypes 4 failed"); if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typechar) != 'C') throw new Exception("differentTypes 5 failed"); if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed"); int global_enum = enum_thorough_simple.global_typeint; if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed"); global_enum = enum_thorough_simple.global_typeboolfalse; if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed"); global_enum = enum_thorough_simple.global_typebooltrue; if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed"); global_enum = enum_thorough_simple.global_typebooltwo; if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed"); global_enum = enum_thorough_simple.global_typechar; if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed"); global_enum = enum_thorough_simple.global_typedefaultint; if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed"); } } } swig-3.0.2/Examples/test-suite/csharp/li_swigtype_inout_runme.cs0000664000175000017500000000251512343605122025024 0ustar williamwilliam using System; using li_swigtype_inoutNamespace; public class li_swigtype_inout_runme { public static void Main() { XXX xxx = new XXX(999); check_count(1); XXX x1 = null; XXX x2 = null; XXX x3 = null; XXX x4 = null; li_swigtype_inout.ptr_ref_out(out x1, out x2, out x3, out x4); check_value(111, x1.value); check_value(222, x2.value); check_value(333, x3.value); check_value(444, x4.value); check_count(5); x1.Dispose(); x2.Dispose(); x3.Dispose(); x4.Dispose(); xxx.Dispose(); check_count(0); x1 = null; x2 = null; x3 = null; x4 = null; new ConstructorTest(out x1, out x2, out x3, out x4); check_count(4); check_value(111, x1.value); check_value(222, x2.value); check_value(333, x3.value); check_value(444, x4.value); x1.Dispose(); x2.Dispose(); x3.Dispose(); x4.Dispose(); check_count(0); } public static void check_count(int count) { int actual = XXX.count; if( count != actual ) { throw new Exception(String.Format("Count wrong. Expected: {0} Got: {1}", count, actual)); } } public static void check_value(int expected, int actual) { if( expected != actual ) { throw new Exception(String.Format("Wrong value. Expected: {0} Got: {1}", expected, actual)); } } } swig-3.0.2/Examples/test-suite/csharp/aggregate_runme.cs0000664000175000017500000000154712343605122023201 0ustar williamwilliamusing System; using aggregateNamespace; public class runme { static void Main() { // Confirm that move() returns correct results under normal use int result = aggregate.move(aggregate.UP); if (result != aggregate.UP) throw new Exception("UP failed"); result = aggregate.move(aggregate.DOWN); if (result != aggregate.DOWN) throw new Exception("DOWN failed"); result = aggregate.move(aggregate.LEFT); if (result != aggregate.LEFT) throw new Exception("LEFT failed"); result = aggregate.move(aggregate.RIGHT); if (result != aggregate.RIGHT) throw new Exception("RIGHT failed"); // Confirm that move() raises an exception when the contract is violated try { aggregate.move(0); throw new Exception("0 test failed"); } catch (ArgumentOutOfRangeException) { } } } swig-3.0.2/Examples/test-suite/csharp/csharp_exceptions_runme.cs0000664000175000017500000003403412343605122024771 0ustar williamwilliamusing System; using System.Threading; using csharp_exceptionsNamespace; public class runme { static void Main() { // %exception tests try { csharp_exceptions.ThrowByValue(); throw new Exception("ThrowByValue not working"); } catch (DivideByZeroException) { } try { csharp_exceptions.ThrowByReference(); throw new Exception("ThrowByReference not working"); } catch (DivideByZeroException) { } // %csnothrowexception csharp_exceptions.NoThrowException(); csharp_exceptions.NullReference(new Ex("should not throw")); // exception specifications bool testFailed = false; try { csharp_exceptions.ExceptionSpecificationValue(); testFailed = true; } catch (ApplicationException) { } if (testFailed) throw new Exception("ExceptionSpecificationValue not working"); try { csharp_exceptions.ExceptionSpecificationReference(); testFailed = true; } catch (ApplicationException) { } if (testFailed) throw new Exception("ExceptionSpecificationReference not working"); try { csharp_exceptions.ExceptionSpecificationString(); testFailed = true; } catch (ApplicationException e) { if (e.Message != "ExceptionSpecificationString") throw new Exception("ExceptionSpecificationString unexpected message: " + e.Message); } if (testFailed) throw new Exception("ExceptionSpecificationString not working"); try { csharp_exceptions.ExceptionSpecificationInteger(); testFailed = true; } catch (ApplicationException) { } if (testFailed) throw new Exception("ExceptionSpecificationInteger not working"); // null reference exceptions try { csharp_exceptions.NullReference(null); throw new Exception("NullReference not working"); } catch (ArgumentNullException) { } try { csharp_exceptions.NullValue(null); throw new Exception("NullValue not working"); } catch (ArgumentNullException) { } // enums try { csharp_exceptions.ExceptionSpecificationEnumValue(); testFailed = true; } catch (ApplicationException) { } if (testFailed) throw new Exception("ExceptionSpecificationEnumValue not working"); try { csharp_exceptions.ExceptionSpecificationEnumReference(); testFailed = true; } catch (ApplicationException) { } if (testFailed) throw new Exception("ExceptionSpecificationEnumReference not working"); // std::string try { csharp_exceptions.NullStdStringValue(null); throw new Exception("NullStdStringValue not working"); } catch (ArgumentNullException) { } try { csharp_exceptions.NullStdStringReference(null); throw new Exception("NullStdStringReference not working"); } catch (ArgumentNullException) { } try { csharp_exceptions.ExceptionSpecificationStdStringValue(); testFailed = true; } catch (ApplicationException e) { if (e.Message != "ExceptionSpecificationStdStringValue") throw new Exception("ExceptionSpecificationStdStringValue unexpected message: " + e.Message); } if (testFailed) throw new Exception("ExceptionSpecificationStdStringValue not working"); try { csharp_exceptions.ExceptionSpecificationStdStringReference(); testFailed = true; } catch (ApplicationException e) { if (e.Message != "ExceptionSpecificationStdStringReference") throw new Exception("ExceptionSpecificationStdStringReference unexpected message: " + e.Message); } if (testFailed) throw new Exception("ExceptionSpecificationStdStringReference not working"); // Memory leak check (The C++ exception stack was never unwound in the original approach to throwing exceptions from unmanaged code) try { csharp_exceptions.MemoryLeakCheck(); throw new Exception("MemoryLeakCheck not working"); } catch (DivideByZeroException) { } if (Counter.count != 0) throw new Exception("Memory leaks when throwing exception. count: " + Counter.count); // test exception pending in the csconstruct typemap try { new constructor(null); throw new Exception("constructor 1 not working"); } catch (ArgumentNullException) { } try { new constructor(); throw new Exception("constructor 2 not working"); } catch (ApplicationException) { } // test exception pending in the csout typemaps try { csharp_exceptions.ushorttest(); throw new Exception("csout not working"); } catch (IndexOutOfRangeException) { } // test exception pending in the csvarout/csvarin typemaps and canthrow attribute in unmanaged code typemaps (1) global variables // 1) global variables int numberout = 0; try { csharp_exceptions.numberin = -1; throw new Exception("global csvarin not working"); } catch (IndexOutOfRangeException) { } csharp_exceptions.numberin = 5; if (csharp_exceptions.numberin != 5) throw new Exception("global numberin not 5"); csharp_exceptions.numberout = 20; try { numberout += csharp_exceptions.numberout; throw new Exception("global csvarout not working"); } catch (IndexOutOfRangeException) { } // 2) static member variables try { InOutStruct.staticnumberin = -1; throw new Exception("static csvarin not working"); } catch (IndexOutOfRangeException) { } InOutStruct.staticnumberin = 5; if (InOutStruct.staticnumberin != 5) throw new Exception("static staticnumberin not 5"); InOutStruct.staticnumberout = 20; try { numberout += InOutStruct.staticnumberout; throw new Exception("static csvarout not working"); } catch (IndexOutOfRangeException) { } // 3) member variables InOutStruct io = new InOutStruct(); try { io.numberin = -1; throw new Exception("member csvarin not working"); } catch (IndexOutOfRangeException) { } io.numberin = 5; if (io.numberin != 5) throw new Exception("member numberin not 5"); io.numberout = 20; try { numberout += io.numberout; throw new Exception("member csvarout not working"); } catch (IndexOutOfRangeException) { } // test SWIG_exception macro - it must return from unmanaged code without executing any further unmanaged code try { csharp_exceptions.exceptionmacrotest(-1); throw new Exception("exception macro not working"); } catch (IndexOutOfRangeException) { } if (csharp_exceptions.exception_macro_run_flag) throw new Exception("exceptionmacrotest was executed"); // test all the types of exceptions try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedApplicationException); throw new Exception("ApplicationException not caught"); } catch (ApplicationException e) { if (e.Message != "msg") throw new Exception("ApplicationException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArithmeticException); throw new Exception("ArithmeticException not caught"); } catch (ArithmeticException e) { if (e.Message != "msg") throw new Exception("ArithmeticException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedDivideByZeroException); throw new Exception("DivideByZeroException not caught"); } catch (DivideByZeroException e) { if (e.Message != "msg") throw new Exception("DivideByZeroException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedIndexOutOfRangeException); throw new Exception("IndexOutOfRangeException not caught"); } catch (IndexOutOfRangeException e) { if (e.Message != "msg") throw new Exception("IndexOutOfRangeException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedInvalidOperationException); throw new Exception("InvalidOperationException not caught"); } catch (InvalidOperationException e) { if (e.Message != "msg") throw new Exception("InvalidOperationException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedIOException); throw new Exception("IOException not caught"); } catch (System.IO.IOException e) { if (e.Message != "msg") throw new Exception("IOException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedNullReferenceException); throw new Exception("NullReferenceException not caught"); } catch (NullReferenceException e) { if (e.Message != "msg") throw new Exception("NullReferenceException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedOutOfMemoryException); throw new Exception("OutOfMemoryException not caught"); } catch (OutOfMemoryException e) { if (e.Message != "msg") throw new Exception("OutOfMemoryException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedOverflowException); throw new Exception("OverflowException not caught"); } catch (OverflowException e) { if (e.Message != "msg") throw new Exception("OverflowException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedSystemException); throw new Exception("SystemException not caught"); } catch (SystemException e) { if (e.Message != "msg") throw new Exception("SystemException msg incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentException); throw new Exception("ArgumentException not caught"); } catch (ArgumentException e) { if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentException msg incorrect"); if (e.ParamName != "parm") throw new Exception("ArgumentException parm incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentNullException); throw new Exception("ArgumentNullException not caught"); } catch (ArgumentNullException e) { if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentNullException msg incorrect"); if (e.ParamName != "parm") throw new Exception("ArgumentNullException parm incorrect"); } try { csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentOutOfRangeException); throw new Exception("ArgumentOutOfRangeException not caught"); } catch (ArgumentOutOfRangeException e) { if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentOutOfRangeException msg incorrect"); if (e.ParamName != "parm") throw new Exception("ArgumentOutOfRangeException parm incorrect"); } // exceptions in multiple threads test { ThrowsClass throwsClass = new ThrowsClass(1234.5678); const int NUM_THREADS = 8; Thread[] threads = new Thread[NUM_THREADS]; TestThread[] testThreads = new TestThread[NUM_THREADS]; // invoke the threads for (int i=0; i(i.ToString(), i * 18))) throw new Exception("Contains test " + i + " failed"); } // TryGetValue() test int value; bool rc = simap.TryGetValue("3", out value); if (rc != true || value != (3 * 18)) throw new Exception("TryGetValue test 1 failed"); rc = simap.TryGetValue("-1", out value); if (rc != false) throw new Exception("TryGetValue test 2 failed"); // Keys and Values test { IList keys = new List(simap.Keys); IList values = new List(simap.Values); Dictionary check = new Dictionary(); if (keys.Count != collectionSize) throw new Exception("Keys count test failed"); if (values.Count != collectionSize) throw new Exception("Values count test failed"); for (int i = 0; i < keys.Count; i++) { if (simap[keys[i]] != values[i]) throw new Exception("Keys and values test failed for index " + i); check.Add(keys[i], values[i]); } for (int i = 0; i < collectionSize; i++) { if (!check.ContainsKey(i.ToString())) throw new Exception("Keys and Values ContainsKey test " + i + " failed"); } } // Add and Remove test for (int i = 100; i < 103; i++) { simap.Add(i.ToString(), i * 18); if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18)) throw new Exception("Add test failed for index " + i); simap.Remove(i.ToString()); if (simap.ContainsKey(i.ToString())) throw new Exception("Remove test failed for index " + i); } for (int i = 200; i < 203; i++) { simap.Add(new KeyValuePair(i.ToString(), i * 18)); if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18)) throw new Exception("Add explicit test failed for index " + i); simap.Remove(new KeyValuePair(i.ToString(), i * 18)); if (simap.ContainsKey(i.ToString())) throw new Exception("Remove explicit test failed for index " + i); } // Duplicate key test try { simap.Add("3", 0); throw new Exception("Adding duplicate key test failed"); } catch (ArgumentException) { } // CopyTo() test { KeyValuePair[] outputarray = new KeyValuePair[collectionSize]; simap.CopyTo(outputarray); foreach (KeyValuePair val in outputarray) { if (simap[val.Key] != val.Value) throw new Exception("CopyTo (1) test failed, index:" + val.Key); } } { KeyValuePair[] outputarray = new KeyValuePair[midCollection + collectionSize]; simap.CopyTo(outputarray, midCollection); for (int i = midCollection; i < midCollection + collectionSize; i++) { KeyValuePair val = outputarray[i]; if (simap[val.Key] != val.Value) throw new Exception("CopyTo (2) test failed, index:" + val.Key); } } { KeyValuePair[] outputarray = new KeyValuePair[collectionSize - 1]; try { simap.CopyTo(outputarray); throw new Exception("CopyTo (4) test failed"); } catch (ArgumentException) { } } // Clear test simap.Clear(); if (simap.Count != 0) throw new Exception("Clear test failed"); // Test wrapped methods for (int i = 1; i <= 5; i++) { simap[i.ToString()] = i; } double avg = li_std_map.valueAverage(simap); if (avg != 3.0) throw new Exception("Wrapped method valueAverage test failed. Got " + avg); string keyStringified = li_std_map.stringifyKeys(simap); if (keyStringified != " 1 2 3 4 5") throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified); // Test a map with a new complex type (Struct) { IntStructMap ismap = new IntStructMap(); for (int i = 0; i < 10; i++) { ismap.Add(i, new Struct(i * 10.1)); } if (ismap.Count != 10) throw new Exception("Count test on complex type map failed"); foreach (KeyValuePair p in ismap) { if ((p.Key * 10.1) != p.Value.num) throw new Exception("Iteration test on complex type map failed for index " + p.Key); } } // Test a map of pointers { IntStructPtrMap ispmap = new IntStructPtrMap(); for (int i = 0; i < 10; i++) { ispmap.Add(i, new Struct(i * 10.1)); } if (ispmap.Count != 10) throw new Exception("Count test on complex type pointer map failed"); foreach (KeyValuePair p in ispmap) { if ((p.Key * 10.1) != p.Value.num) throw new Exception("Iteration test on complex type pointer map failed for index " + p.Key); } } { IntStructConstPtrMap iscpmap = new IntStructConstPtrMap(); for (int i = 0; i < 10; i++) { iscpmap.Add(i, new Struct(i * 10.1)); } if (iscpmap.Count != 10) throw new Exception("Count test on complex type const pointer map failed"); foreach (KeyValuePair p in iscpmap) { if ((p.Key * 10.1) != p.Value.num) throw new Exception("Iteration test on complex type const pointer map failed for index " + p.Key); } } // Test complex type as key (Struct) { StructIntMap limap = new StructIntMap(); Struct s7 = new Struct(7); Struct s8 = new Struct(8); limap[s7] = 8; if (limap[s7] != 8) throw new Exception("Assignment test on complex key map failed"); if (!limap.ContainsKey(s7)) throw new Exception("Key test (1) on complex key map failed"); if (limap.ContainsKey(s8)) throw new Exception("Key test (2) on complex key map failed"); } // All done } } swig-3.0.2/Examples/test-suite/csharp/director_basic_runme.cs0000664000175000017500000000305312343605122024221 0ustar williamwilliamusing System; namespace director_basicNamespace { public class runme { static void Main() { runme r = new runme(); r.run(); } void run() { director_basic_MyFoo a = new director_basic_MyFoo(); if (a.ping() != "director_basic_MyFoo::ping()") { throw new Exception ( "a.ping()" ); } if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") { throw new Exception ( "a.pong()" ); } Foo b = new Foo(); if (b.ping() != "Foo::ping()") { throw new Exception ( "b.ping()" ); } if (b.pong() != "Foo::pong();Foo::ping()") { throw new Exception ( "b.pong()" ); } A1 a1 = new A1(1, false); a1.Dispose(); { MyOverriddenClass my = new MyOverriddenClass(); my.expectNull = true; if (MyClass.call_pmethod(my, null) != null) throw new Exception("null pointer marshalling problem"); Bar myBar = new Bar(); my.expectNull = false; Bar myNewBar = MyClass.call_pmethod(my, myBar); if (myNewBar == null) throw new Exception("non-null pointer marshalling problem"); myNewBar.x = 10; } } } class director_basic_MyFoo : Foo { public director_basic_MyFoo() : base() { } public override string ping() { return "director_basic_MyFoo::ping()"; } } class MyOverriddenClass : MyClass { public bool expectNull = false; public bool nonNullReceived = false; public override Bar pmethod(Bar b) { if ( expectNull && (b != null) ) throw new Exception("null not received as expected"); return b; } } } swig-3.0.2/Examples/test-suite/csharp/csharp_attributes_runme.cs0000664000175000017500000002705712343605122025005 0ustar williamwilliamusing System; using System.Reflection; using System.ComponentModel; using csharp_attributesNamespace; public class runme { static void Main() { // Custom attributes typemap tests // // cstype typemap attributechecks // // Global function cstype typemap attributes check Type globaltype = typeof(csharp_attributes); { MethodInfo member = (MethodInfo)globaltype.GetMember("GlobalFunction")[0]; if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null) throw new Exception("No IntOut attribute for " + member.Name); ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter if (parameter.Name != "myInt") throw new Exception("Incorrect parameter name"); Attribute attribute = Attribute.GetCustomAttributes(parameter)[0]; if (attribute.GetType() != typeof(IntInAttribute)) throw new Exception("Expecting IntIn attribute"); } // Constant - cstype typemap attributes check { MemberInfo member = (MemberInfo)globaltype.GetMember("TESTMACRO")[0]; if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null) throw new Exception("No IntOut attribute for " + member.Name); } // Non-static method cstype typemap attributes check Type type = typeof(Stations); { MethodInfo member = (MethodInfo)type.GetMember("Reading")[0]; if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null) throw new Exception("No IntOut attribute for " + member.Name); ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter if (parameter.Name != "myInt") throw new Exception("Incorrect parameter name"); Attribute attribute = Attribute.GetCustomAttributes(parameter)[0]; if (attribute.GetType() != typeof(IntInAttribute)) throw new Exception("Expecting IntIn attribute"); } // Static method cstype typemap attributes check { MethodInfo member = (MethodInfo)type.GetMember("Swindon")[0]; if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null) throw new Exception("No IntOut attribute for " + member.Name); ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter if (parameter.Name != "myInt") throw new Exception("Incorrect parameter name"); Attribute attribute = Attribute.GetCustomAttributes(parameter)[0]; if (attribute.GetType() != typeof(IntInAttribute)) throw new Exception("Expecting IntIn attribute"); } // Constructor cstype typemap attributes check { ConstructorInfo member = (ConstructorInfo)type.GetConstructors()[0]; ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter if (parameter.Name != "myInt") throw new Exception("Incorrect parameter name"); Attribute attribute = Attribute.GetCustomAttributes(parameter)[0]; if (attribute.GetType() != typeof(IntInAttribute)) throw new Exception("Expecting IntIn attribute"); } // // imtype typemap attributechecks // // Global function imtype typemap attributes check Type imclasstype = typeof(csharp_attributesPINVOKE); { MethodInfo member = (MethodInfo)imclasstype.GetMember("GlobalFunction")[0]; if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null) throw new Exception("No IntegerOut attribute for " + member.Name); ParameterInfo parameter = member.GetParameters()[0]; // checking 1st parameter Attribute attribute = Attribute.GetCustomAttributes(parameter)[0]; if (attribute.GetType() != typeof(IntegerInAttribute)) throw new Exception("Expecting IntegerIn attribute"); } // Constant - imtype typemap attributes check { MethodInfo member = (MethodInfo)imclasstype.GetMember("TESTMACRO_get")[0]; if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null) throw new Exception("No IntegerOut attribute for " + member.Name); } // Non-static method imtype typemap attributes check { MethodInfo member = (MethodInfo)imclasstype.GetMember("Stations_Reading")[0]; if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null) throw new Exception("No IntegerOut attribute for " + member.Name); ParameterInfo parameter = member.GetParameters()[1]; // checking 2nd parameter Attribute attribute = Attribute.GetCustomAttributes(parameter)[0]; if (attribute.GetType() != typeof(IntegerInAttribute)) throw new Exception("Expecting IntegerIn attribute"); } // Static method imtype typemap attributes check { MethodInfo member = (MethodInfo)imclasstype.GetMember("Stations_Swindon")[0]; if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null) throw new Exception("No IntegerOut attribute for " + member.Name); ParameterInfo parameter = member.GetParameters()[0]; // checking 1st parameter Attribute attribute = Attribute.GetCustomAttributes(parameter)[0]; if (attribute.GetType() != typeof(IntegerInAttribute)) throw new Exception("Expecting IntegerIn attribute"); } // // attributes feature // Type moretype = typeof(MoreStations); // Constructor attributes feature check { ConstructorInfo member = (ConstructorInfo)moretype.GetConstructors()[0]; if (Attribute.GetCustomAttribute(member, typeof(InterCity1Attribute)) == null) throw new Exception("MoreStations::MoreStations attribute failed"); } // Non-static method attributes feature check { MethodInfo member = (MethodInfo)moretype.GetMember("Chippenham")[0]; if (Attribute.GetCustomAttribute(member, typeof(InterCity2Attribute)) == null) throw new Exception("MoreStations::Chippenham attribute failed"); } // Static method attributes feature check { MethodInfo member = (MethodInfo)moretype.GetMember("Bath")[0]; if (Attribute.GetCustomAttribute(member, typeof(InterCity3Attribute)) == null) throw new Exception("MoreStations::Bath attribute failed"); } // Non-static member variable attributes feature check { PropertyInfo member = (PropertyInfo)moretype.GetProperty("Bristol"); if (Attribute.GetCustomAttribute(member, typeof(InterCity4Attribute)) == null) throw new Exception("MoreStations::Bristol attribute failed"); } // Static member variable attributes feature check { PropertyInfo member = (PropertyInfo)moretype.GetProperty("WestonSuperMare"); if (Attribute.GetCustomAttribute(member, typeof(InterCity5Attribute)) == null) throw new Exception("MoreStations::Bristol attribute failed"); } // Global function attributes feature check { MethodInfo member = (MethodInfo)globaltype.GetMember("Paddington")[0]; if (Attribute.GetCustomAttribute(member, typeof(InterCity7Attribute)) == null) throw new Exception("MoreStations::Paddington attribute failed"); } // Global variables attributes feature check { PropertyInfo member = (PropertyInfo)globaltype.GetProperty("DidcotParkway"); if (Attribute.GetCustomAttribute(member, typeof(InterCity8Attribute)) == null) throw new Exception("MoreStations::Paddington attribute failed"); } // // csattribute typemaps // // Class csattribute typemap { Object[] attribs = moretype.GetCustomAttributes(true); Eurostar1Attribute tgv = (Eurostar1Attribute)attribs[0]; if (tgv == null) throw new Exception("No attribute for MoreStations"); } // Nested enum csattribute typemap { MemberInfo member = (MemberInfo)moretype.GetMember("Wales")[0]; if (Attribute.GetCustomAttribute(member, typeof(Eurostar2Attribute)) == null) throw new Exception("No attribute for " + member.Name); } // Enum value attributes Type walesType = typeof(MoreStations.Wales); { MemberInfo member = (MemberInfo)walesType.GetMember("Cardiff")[0]; DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute)); if (attribute == null) throw new Exception("No attribute for " + member.Name); if (attribute.Description != "Cardiff city station") throw new Exception("Incorrect attribute value for " + member.Name); } { MemberInfo member = (MemberInfo)walesType.GetMember("Swansea")[0]; DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute)); if (attribute == null) throw new Exception("No attribute for " + member.Name); if (attribute.Description != "Swansea city station") throw new Exception("Incorrect attribute value for " + member.Name); } // Enum csattribute typemap { Type cymrutype = typeof(Cymru); Object[] attribs = cymrutype.GetCustomAttributes(true); Eurostar3Attribute tgv = (Eurostar3Attribute)attribs[0]; if (tgv == null) throw new Exception("No attribute for Cymru"); } // No runtime test for directorinattributes and directoroutattributes } } // Custom attribute classes [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class IntInAttribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class IntOutAttribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class IntegerInAttribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class IntegerOutAttribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class InterCity1Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class InterCity2Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class InterCity3Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class InterCity4Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class InterCity5Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class InterCity6Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class InterCity7Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class InterCity8Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class Eurostar1Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class Eurostar2Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class Eurostar3Attribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class ThreadSafeAttribute : Attribute { public ThreadSafeAttribute(bool safe) {} public ThreadSafeAttribute() {} } [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class DirectorIntegerOutAttribute : Attribute {} [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] public class DirectorIntegerInAttribute : Attribute {} swig-3.0.2/Examples/test-suite/csharp/sneaky1_runme.cs0000664000175000017500000000073212343605122022621 0ustar williamwilliamusing System; using sneaky1Namespace; public class runme { static void Main() { if (sneaky1.add(30, 2) != 32) throw new Exception("add test failed"); if (sneaky1.subtract(20, 2) != 18) throw new Exception("subtract test failed"); if (sneaky1.mul(20, 2) != 40) throw new Exception("mul test failed"); if (sneaky1.divide(20, 2) != 10) throw new Exception("div test failed"); } } swig-3.0.2/Examples/test-suite/csharp/director_ignore_runme.cs0000664000175000017500000000332212343605122024422 0ustar williamwilliamusing System; namespace director_ignoreNamespace { public class runme { static void Main() { runme r = new runme(); r.run(); } void run() { // Just check the classes can be instantiated and other methods work as expected DIgnoresDerived a = new DIgnoresDerived(); if (a.Triple(5) != 15) throw new Exception("Triple failed"); DAbstractIgnoresDerived b = new DAbstractIgnoresDerived(); if (b.Quadruple(5) != 20) throw new Exception("Quadruple failed"); } } class DIgnoresDerived : DIgnores { public DIgnoresDerived() : base() { } // These will give a warning if the %ignore is not working public virtual int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; } public virtual int OverloadedMethod(int n, int xoffset) { return 0; } public virtual int OverloadedMethod(int n) { return 0; } public virtual int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; } public virtual int OverloadedProtectedMethod(int n, int xoffset) { return 0; } public virtual int OverloadedProtectedMethod(int n) { return 0; } } class DAbstractIgnoresDerived : DAbstractIgnores { public DAbstractIgnoresDerived() : base() { } // These will give a warning if the %ignore is not working public virtual int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; } public virtual int OverloadedMethod(int n, int xoffset) { return 0; } public virtual int OverloadedMethod(int n) { return 0; } public virtual int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; } public virtual int OverloadedProtectedMethod(int n, int xoffset) { return 0; } public virtual int OverloadedProtectedMethod(int n) { return 0; } } } swig-3.0.2/Examples/test-suite/csharp/special_variable_macros_runme.cs0000664000175000017500000000173012343605122026076 0ustar williamwilliamusing System; using special_variable_macrosNamespace; public class runme { static void Main() { Name name = new Name(); if (special_variable_macros.testFred(name) != "none") throw new Exception("test failed"); if (special_variable_macros.testJack(name) != "$specialname") throw new Exception("test failed"); if (special_variable_macros.testJill(name) != "jilly") throw new Exception("test failed"); if (special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap") throw new Exception("test failed"); if (special_variable_macros.testJames(name) != "SWIGTYPE_Name") throw new Exception("test failed"); if (special_variable_macros.testJim(name) != "multiname num") throw new Exception("test failed"); if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123) throw new Exception("test failed"); NewName newName = NewName.factory("factoryname"); name = newName.getStoredName(); } } swig-3.0.2/Examples/test-suite/csharp/sizet_runme.cs0000664000175000017500000000043312343605122022402 0ustar williamwilliam using System; using sizetNamespace; public class sizet_runme { public static void Main() { uint s = 2000; s = sizet.test1(s+1); s = sizet.test2(s+1); s = sizet.test3(s+1); s = sizet.test4(s+1); if (s != 2004) throw new Exception("failed"); } } swig-3.0.2/Examples/test-suite/csharp/li_std_except_runme.cs0000664000175000017500000000303112343605122024067 0ustar williamwilliam// This test tests all the methods in the C# collection wrapper using System; using li_std_exceptNamespace; public class li_std_except_runme { public static void Main() { Test test = new Test(); try { test.throw_bad_exception(); throw new Exception("throw_bad_exception failed"); } catch (ApplicationException) {} try { test.throw_domain_error(); throw new Exception("throw_domain_error failed"); } catch (ApplicationException) {} try { test.throw_exception(); throw new Exception("throw_exception failed"); } catch (ApplicationException) {} try { test.throw_invalid_argument(); throw new Exception("throw_invalid_argument failed"); } catch (ArgumentException) {} try { test.throw_length_error(); throw new Exception("throw_length_error failed"); } catch (IndexOutOfRangeException) {} try { test.throw_logic_error(); throw new Exception("throw_logic_error failed"); } catch (ApplicationException) {} try { test.throw_out_of_range(); throw new Exception("throw_out_of_range failed"); } catch (ArgumentOutOfRangeException) {} try { test.throw_overflow_error(); throw new Exception("throw_overflow_error failed"); } catch (OverflowException) {} try { test.throw_range_error(); throw new Exception("throw_range_error failed"); } catch (IndexOutOfRangeException) {} try { test.throw_runtime_error(); throw new Exception("throw_runtime_error failed"); } catch (ApplicationException) {} try { test.throw_underflow_error(); throw new Exception("throw_underflow_error failed"); } catch (OverflowException) {} } } swig-3.0.2/Examples/test-suite/csharp/director_nspace_runme.cs0000664000175000017500000000141212343605122024406 0ustar williamwilliam using System; using director_nspaceNamespace; public class bools_runme { public static void Main() { } } class director_nspace_MyBarFoo : director_nspaceNamespace.TopLevel.Bar.Foo { public override String ping() { return "director_nspace_MyBarFoo.ping();"; } public override String pong() { return "director_nspace_MyBarFoo.pong();" + ping(); } public override String fooBar(director_nspaceNamespace.TopLevel.Bar.FooBar fooBar) { return fooBar.FooBarDo(); } public override director_nspaceNamespace.TopLevel.Bar.Foo makeFoo() { return new director_nspaceNamespace.TopLevel.Bar.Foo(); } public override director_nspaceNamespace.TopLevel.Bar.FooBar makeFooBar() { return new director_nspaceNamespace.TopLevel.Bar.FooBar(); } } swig-3.0.2/Examples/test-suite/csharp/typemap_out_optimal_runme.cs0000664000175000017500000000031312343605122025334 0ustar williamwilliamusing System; using typemap_out_optimalNamespace; public class typemap_out_optimal_runme { public static XX x = null; public static void Main() { XX.debug = false; x = XX.create(); } } swig-3.0.2/Examples/test-suite/csharp/nested_workaround_runme.cs0000664000175000017500000000107712343605122025006 0ustar williamwilliamusing System; using nested_workaroundNamespace; #pragma warning disable 219 public class runme { static void Main() { { Inner inner = new Inner(5); Outer outer = new Outer(); Inner newInner = outer.doubleInnerValue(inner); if (newInner.getValue() != 10) throw new Exception("inner failed"); } { Outer outer = new Outer(); Inner inner = outer.createInner(3); Inner newInner = outer.doubleInnerValue(inner); if (outer.getInnerValue(newInner) != 6) throw new Exception("inner failed"); } } } swig-3.0.2/Examples/test-suite/csharp/li_attribute_runme.cs0000664000175000017500000000432012343605122023732 0ustar williamwilliam// Ported from Python li_attribute_runme.py using System; using li_attributeNamespace; public class li_attribute_runme { public static void Main() { A aa = new A(1,2,3); if (aa.a != 1) throw new ApplicationException("error"); aa.a = 3; if (aa.a != 3) throw new ApplicationException("error"); if (aa.b != 2) throw new ApplicationException("error"); aa.b = 5; if (aa.b != 5) throw new ApplicationException("error"); if (aa.d != aa.b) throw new ApplicationException("error"); if (aa.c != 3) throw new ApplicationException("error"); //aa.c = 5; //if (aa.c != 3) // throw new ApplicationException("error"); Param_i pi = new Param_i(7); if (pi.value != 7) throw new ApplicationException("error"); pi.value=3; if (pi.value != 3) throw new ApplicationException("error"); B b = new B(aa); if (b.a.c != 3) throw new ApplicationException("error"); // class/struct attribute with get/set methods using return/pass by reference MyFoo myFoo = new MyFoo(); myFoo.x = 8; MyClass myClass = new MyClass(); myClass.Foo = myFoo; if (myClass.Foo.x != 8) throw new ApplicationException("error"); // class/struct attribute with get/set methods using return/pass by value MyClassVal myClassVal = new MyClassVal(); if (myClassVal.ReadWriteFoo.x != -1) throw new ApplicationException("error"); if (myClassVal.ReadOnlyFoo.x != -1) throw new ApplicationException("error"); myClassVal.ReadWriteFoo = myFoo; if (myClassVal.ReadWriteFoo.x != 8) throw new ApplicationException("error"); if (myClassVal.ReadOnlyFoo.x != 8) throw new ApplicationException("error"); // string attribute with get/set methods using return/pass by value MyStringyClass myStringClass = new MyStringyClass("initial string"); if (myStringClass.ReadWriteString != "initial string") throw new ApplicationException("error"); if (myStringClass.ReadOnlyString != "initial string") throw new ApplicationException("error"); myStringClass.ReadWriteString = "changed string"; if (myStringClass.ReadWriteString != "changed string") throw new ApplicationException("error"); if (myStringClass.ReadOnlyString != "changed string") throw new ApplicationException("error"); } } swig-3.0.2/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs0000664000175000017500000011122712343605122026033 0ustar williamwilliamusing System; using enum_thorough_typesafeNamespace; public class runme { static void Main() { { // Anonymous enums int i = enum_thorough_typesafe.AnonEnum1; if (enum_thorough_typesafe.ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed"); i += enum_thorough_typesafe.AnonSpaceEnum1; i += AnonStruct.AnonStructEnum1; } { colour red = colour.red; enum_thorough_typesafe.colourTest1(red); enum_thorough_typesafe.colourTest2(red); enum_thorough_typesafe.colourTest3(red); enum_thorough_typesafe.colourTest4(red); enum_thorough_typesafe.myColour = red; } { SpeedClass s = new SpeedClass(); SpeedClass.speed speed = SpeedClass.speed.slow; if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed"); if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed"); if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed"); if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed"); if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed"); if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed"); if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed"); if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed"); if (enum_thorough_typesafe.speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed"); if (enum_thorough_typesafe.speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed"); if (enum_thorough_typesafe.speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed"); if (enum_thorough_typesafe.speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed"); if (enum_thorough_typesafe.speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed"); } { SpeedClass s = new SpeedClass(); SpeedClass.speed slow = SpeedClass.speed.slow; SpeedClass.speed lightning = SpeedClass.speed.lightning; if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed"); if (s.mySpeedtd1.swigValue != 10) throw new Exception("mySpeedtd1 2 failed"); s.mySpeedtd1 = lightning; if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed"); if (s.mySpeedtd1.swigValue != 31) throw new Exception("mySpeedtd1 4 failed"); } { if (enum_thorough_typesafe.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest 1 failed"); } { twonames val = twonames.TwoNames2; if (enum_thorough_typesafe.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed"); if (enum_thorough_typesafe.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed"); if (enum_thorough_typesafe.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed"); } { TwoNamesStruct t = new TwoNamesStruct(); TwoNamesStruct.twonames val = TwoNamesStruct.twonames.TwoNamesStruct1; if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed"); if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed"); if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed"); } { namedanonspace val = namedanonspace.NamedAnonSpace2; if (enum_thorough_typesafe.namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed"); if (enum_thorough_typesafe.namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed"); if (enum_thorough_typesafe.namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed"); if (enum_thorough_typesafe.namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed"); } { TemplateClassInt t = new TemplateClassInt(); TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo; if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed"); if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed"); if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed"); if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed"); if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed"); if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed"); if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed"); if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed"); if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed"); // if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed"); if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed"); // if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed"); if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed"); if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed"); if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed"); if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed"); if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed"); if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed"); if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed"); if (enum_thorough_typesafe.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed"); if (enum_thorough_typesafe.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed"); if (enum_thorough_typesafe.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed"); if (enum_thorough_typesafe.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed"); if (enum_thorough_typesafe.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed"); if (enum_thorough_typesafe.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed"); if (enum_thorough_typesafe.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed"); if (enum_thorough_typesafe.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed"); } { TClassInt t = new TClassInt(); TClassInt.scientists bell = TClassInt.scientists.bell; TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo; if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed"); if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed"); if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed"); if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed"); if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed"); if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed"); if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed"); if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed"); if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed"); // if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed"); if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed"); // if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed"); if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed"); if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed"); if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed"); if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed"); if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed"); if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed"); if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed"); if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed"); if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed"); if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed"); if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed"); if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed"); if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed"); if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed"); if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed"); if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed"); if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed"); if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed"); if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed"); if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed"); if (enum_thorough_typesafe.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed"); if (enum_thorough_typesafe.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed"); if (enum_thorough_typesafe.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed"); if (enum_thorough_typesafe.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed"); if (enum_thorough_typesafe.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed"); if (enum_thorough_typesafe.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed"); if (enum_thorough_typesafe.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed"); if (enum_thorough_typesafe.scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed"); } { newname val = newname.argh; if (enum_thorough_typesafe.renameTest1(val) != val) throw new Exception("renameTest Global 1 failed"); if (enum_thorough_typesafe.renameTest2(val) != val) throw new Exception("renameTest Global 2 failed"); } { NewNameStruct n = new NewNameStruct(); if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 1 failed"); if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 2 failed"); if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest 3 failed"); if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 4 failed"); if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 5 failed"); if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest 6 failed"); } { if (enum_thorough_typesafe.renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest Global 3 failed"); if (enum_thorough_typesafe.renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest Global 4 failed"); if (enum_thorough_typesafe.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 5 failed"); if (enum_thorough_typesafe.renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 6 failed"); if (enum_thorough_typesafe.renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest Global 7 failed"); } { TreesClass t = new TreesClass(); TreesClass.trees pine = TreesClass.trees.pine; if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed"); if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed"); if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed"); if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed"); if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed"); if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed"); if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed"); if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed"); if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed"); if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed"); if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed"); if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed"); if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed"); if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed"); if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed"); if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed"); if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed"); if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed"); if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed"); if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed"); if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed"); if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed"); if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed"); if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed"); if (enum_thorough_typesafe.treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed"); if (enum_thorough_typesafe.treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed"); if (enum_thorough_typesafe.treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed"); if (enum_thorough_typesafe.treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed"); if (enum_thorough_typesafe.treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed"); if (enum_thorough_typesafe.treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed"); if (enum_thorough_typesafe.treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed"); if (enum_thorough_typesafe.treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed"); if (enum_thorough_typesafe.treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed"); if (enum_thorough_typesafe.treesTestA(pine) != pine) throw new Exception("treesTest Global A failed"); if (enum_thorough_typesafe.treesTestB(pine) != pine) throw new Exception("treesTest Global B failed"); if (enum_thorough_typesafe.treesTestC(pine) != pine) throw new Exception("treesTest Global C failed"); if (enum_thorough_typesafe.treesTestD(pine) != pine) throw new Exception("treesTest Global D failed"); if (enum_thorough_typesafe.treesTestE(pine) != pine) throw new Exception("treesTest Global E failed"); if (enum_thorough_typesafe.treesTestF(pine) != pine) throw new Exception("treesTest Global F failed"); if (enum_thorough_typesafe.treesTestG(pine) != pine) throw new Exception("treesTest Global G failed"); if (enum_thorough_typesafe.treesTestH(pine) != pine) throw new Exception("treesTest Global H failed"); if (enum_thorough_typesafe.treesTestI(pine) != pine) throw new Exception("treesTest Global I failed"); if (enum_thorough_typesafe.treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed"); if (enum_thorough_typesafe.treesTestK(pine) != pine) throw new Exception("treesTest Global K failed"); if (enum_thorough_typesafe.treesTestL(pine) != pine) throw new Exception("treesTest Global L failed"); if (enum_thorough_typesafe.treesTestM(pine) != pine) throw new Exception("treesTest Global M failed"); // if (enum_thorough_typesafe.treesTestN(pine) != pine) throw new Exception("treesTest Global N failed"); if (enum_thorough_typesafe.treesTestO(pine) != pine) throw new Exception("treesTest Global O failed"); if (enum_thorough_typesafe.treesTestP(pine) != pine) throw new Exception("treesTest Global P failed"); if (enum_thorough_typesafe.treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed"); if (enum_thorough_typesafe.treesTestR(pine) != pine) throw new Exception("treesTest Global R failed"); } { HairStruct h = new HairStruct(); HairStruct.hair ginger = HairStruct.hair.ginger; if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed"); if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed"); if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed"); if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed"); if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed"); if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed"); if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed"); if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed"); if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed"); if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed"); if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed"); colour red = colour.red; if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed"); if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed"); if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed"); if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed"); TreesClass.trees fir = TreesClass.trees.fir; if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed"); if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed"); if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed"); if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed"); } { HairStruct.hair blonde = HairStruct.hair.blonde; if (enum_thorough_typesafe.hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed"); if (enum_thorough_typesafe.hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed"); if (enum_thorough_typesafe.hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed"); if (enum_thorough_typesafe.hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed"); if (enum_thorough_typesafe.hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed"); if (enum_thorough_typesafe.hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed"); if (enum_thorough_typesafe.hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed"); if (enum_thorough_typesafe.hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed"); if (enum_thorough_typesafe.hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed"); if (enum_thorough_typesafe.hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed"); if (enum_thorough_typesafe.hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed"); if (enum_thorough_typesafe.hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed"); if (enum_thorough_typesafe.hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed"); if (enum_thorough_typesafe.hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed"); if (enum_thorough_typesafe.hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed"); if (enum_thorough_typesafe.hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed"); if (enum_thorough_typesafe.hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed"); if (enum_thorough_typesafe.hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed"); if (enum_thorough_typesafe.hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed"); if (enum_thorough_typesafe.hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed"); if (enum_thorough_typesafe.hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed"); if (enum_thorough_typesafe.hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed"); if (enum_thorough_typesafe.hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed"); if (enum_thorough_typesafe.hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed"); if (enum_thorough_typesafe.hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed"); if (enum_thorough_typesafe.hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed"); if (enum_thorough_typesafe.hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed"); if (enum_thorough_typesafe.hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed"); if (enum_thorough_typesafe.hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed"); if (enum_thorough_typesafe.hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed"); if (enum_thorough_typesafe.hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed"); if (enum_thorough_typesafe.hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed"); if (enum_thorough_typesafe.hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed"); if (enum_thorough_typesafe.hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed"); if (enum_thorough_typesafe.hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed"); if (enum_thorough_typesafe.hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed"); if (enum_thorough_typesafe.hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed"); if (enum_thorough_typesafe.hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed"); if (enum_thorough_typesafe.hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed"); if (enum_thorough_typesafe.hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed"); if (enum_thorough_typesafe.hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed"); if (enum_thorough_typesafe.hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed"); if (enum_thorough_typesafe.hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed"); if (enum_thorough_typesafe.hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed"); if (enum_thorough_typesafe.hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed"); if (enum_thorough_typesafe.hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed"); if (enum_thorough_typesafe.hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed"); if (enum_thorough_typesafe.hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed"); } { FirStruct f = new FirStruct(); HairStruct.hair blonde = HairStruct.hair.blonde; if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed"); if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed"); if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed"); if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed"); if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed"); if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed"); if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed"); if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed"); if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed"); if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed"); } { enum_thorough_typesafe.GlobalInstance = enum_thorough_typesafe.globalinstance2; if (enum_thorough_typesafe.GlobalInstance != enum_thorough_typesafe.globalinstance2) throw new Exception("GlobalInstance 1 failed"); Instances i = new Instances(); i.MemberInstance = Instances.memberinstance3; if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed"); } // ignore enum item tests start { if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue != 0) throw new Exception("ignoreATest 0 failed"); if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue != 3) throw new Exception("ignoreATest 3 failed"); if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue != 10) throw new Exception("ignoreATest 10 failed"); if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue != 11) throw new Exception("ignoreATest 11 failed"); if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue != 13) throw new Exception("ignoreATest 13 failed"); if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue != 14) throw new Exception("ignoreATest 14 failed"); if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue != 20) throw new Exception("ignoreATest 20 failed"); if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue != 30) throw new Exception("ignoreATest 30 failed"); if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue != 32) throw new Exception("ignoreATest 32 failed"); if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue != 33) throw new Exception("ignoreATest 33 failed"); } { if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue != 11) throw new Exception("ignoreBTest 11 failed"); if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue != 12) throw new Exception("ignoreBTest 12 failed"); if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue != 31) throw new Exception("ignoreBTest 31 failed"); if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue != 32) throw new Exception("ignoreBTest 32 failed"); if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue != 41) throw new Exception("ignoreBTest 41 failed"); if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue != 42) throw new Exception("ignoreBTest 42 failed"); } { if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue != 10) throw new Exception("ignoreCTest 10 failed"); if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue != 12) throw new Exception("ignoreCTest 12 failed"); if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue != 30) throw new Exception("ignoreCTest 30 failed"); if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue != 32) throw new Exception("ignoreCTest 32 failed"); if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue != 40) throw new Exception("ignoreCTest 40 failed"); if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue != 42) throw new Exception("ignoreCTest 42 failed"); } { if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue != 21) throw new Exception("ignoreDTest 21 failed"); if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue != 22) throw new Exception("ignoreDTest 22 failed"); } { if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue != 0) throw new Exception("ignoreETest 0 failed"); if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue != 21) throw new Exception("ignoreETest 21 failed"); if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue != 22) throw new Exception("ignoreETest 22 failed"); } // ignore enum item tests end { if (enum_thorough_typesafe.repeatTest(repeat.one).swigValue != 1) throw new Exception("repeatTest 1 failed"); if (enum_thorough_typesafe.repeatTest(repeat.initial).swigValue != 1) throw new Exception("repeatTest 2 failed"); if (enum_thorough_typesafe.repeatTest(repeat.two).swigValue != 2) throw new Exception("repeatTest 3 failed"); if (enum_thorough_typesafe.repeatTest(repeat.three).swigValue != 3) throw new Exception("repeatTest 4 failed"); if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed"); if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed"); } // different types { if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeint).swigValue != 10) throw new Exception("differentTypes 1 failed"); if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltrue).swigValue != 1) throw new Exception("differentTypes 2 failed"); if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltwo).swigValue != 2) throw new Exception("differentTypes 3 failed"); if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeboolfalse).swigValue != 0) throw new Exception("differentTypes 4 failed"); if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typechar).swigValue != (int)'C') throw new Exception("differentTypes 5 failed"); if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typedefaultint).swigValue != (int)'D') throw new Exception("differentTypes 6 failed"); int global_enum = enum_thorough_typesafe.global_typeint; if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed"); global_enum = enum_thorough_typesafe.global_typeboolfalse; if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed"); global_enum = enum_thorough_typesafe.global_typebooltrue; if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed"); global_enum = enum_thorough_typesafe.global_typebooltwo; if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed"); global_enum = enum_thorough_typesafe.global_typechar; if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed"); global_enum = enum_thorough_typesafe.global_typedefaultint; if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed"); } } } swig-3.0.2/Examples/test-suite/csharp/overload_template_runme.cs0000664000175000017500000001164312343605122024757 0ustar williamwilliamusing System; using overload_templateNamespace; public class runme { static void Main() { int f = overload_template.foo(); f += overload_template.maximum(3,4); double b = overload_template.maximum(3.4,5.2); b++; // warning suppression // mix 1 if (overload_template.mix1("hi") != 101) throw new Exception ("mix1(const char*)"); if (overload_template.mix1(1.0, 1.0) != 102) throw new Exception ("mix1(double, const double &)"); if (overload_template.mix1(1.0) != 103) throw new Exception ("mix1(double)"); // mix 2 if (overload_template.mix2("hi") != 101) throw new Exception ("mix2(const char*)"); if (overload_template.mix2(1.0, 1.0) != 102) throw new Exception ("mix2(double, const double &)"); if (overload_template.mix2(1.0) != 103) throw new Exception ("mix2(double)"); // mix 3 if (overload_template.mix3("hi") != 101) throw new Exception ("mix3(const char*)"); if (overload_template.mix3(1.0, 1.0) != 102) throw new Exception ("mix3(double, const double &)"); if (overload_template.mix3(1.0) != 103) throw new Exception ("mix3(double)"); // Combination 1 if (overload_template.overtparams1(100) != 10) throw new Exception ("overtparams1(int)"); if (overload_template.overtparams1(100.0, 100) != 20) throw new Exception ("overtparams1(double, int)"); // Combination 2 if (overload_template.overtparams2(100.0, 100) != 40) throw new Exception ("overtparams2(double, int)"); // Combination 3 if (overload_template.overloaded() != 60) throw new Exception ("overloaded()"); if (overload_template.overloaded(100.0, 100) != 70) throw new Exception ("overloaded(double, int)"); // Combination 4 if (overload_template.overloadedagain("hello") != 80) throw new Exception ("overloadedagain(const char *)"); if (overload_template.overloadedagain() != 90) throw new Exception ("overloadedagain(double)"); // specializations if (overload_template.specialization(10) != 202) throw new Exception ("specialization(int)"); if (overload_template.specialization(10.0) != 203) throw new Exception ("specialization(double)"); if (overload_template.specialization(10, 10) != 204) throw new Exception ("specialization(int, int)"); if (overload_template.specialization(10.0, 10.0) != 205) throw new Exception ("specialization(double, double)"); if (overload_template.specialization("hi", "hi") != 201) throw new Exception ("specialization(const char *, const char *)"); // simple specialization overload_template.xyz(); overload_template.xyz_int(); overload_template.xyz_double(); // a bit of everything if (overload_template.overload("hi") != 0) throw new Exception ("overload()"); if (overload_template.overload(1) != 10) throw new Exception ("overload(int t)"); if (overload_template.overload(1, 1) != 20) throw new Exception ("overload(int t, const int &)"); if (overload_template.overload(1, "hello") != 30) throw new Exception ("overload(int t, const char *)"); Klass k = new Klass(); if (overload_template.overload(k) != 10) throw new Exception ("overload(Klass t)"); if (overload_template.overload(k, k) != 20) throw new Exception ("overload(Klass t, const Klass &)"); if (overload_template.overload(k, "hello") != 30) throw new Exception ("overload(Klass t, const char *)"); if (overload_template.overload(10.0, "hi") != 40) throw new Exception ("overload(double t, const char *)"); if (overload_template.overload() != 50) throw new Exception ("overload(const char *)"); // everything put in a namespace if (overload_template.nsoverload("hi") != 1000) throw new Exception ("nsoverload()"); if (overload_template.nsoverload(1) != 1010) throw new Exception ("nsoverload(int t)"); if (overload_template.nsoverload(1, 1) != 1020) throw new Exception ("nsoverload(int t, const int &)"); if (overload_template.nsoverload(1, "hello") != 1030) throw new Exception ("nsoverload(int t, const char *)"); if (overload_template.nsoverload(k) != 1010) throw new Exception ("nsoverload(Klass t)"); if (overload_template.nsoverload(k, k) != 1020) throw new Exception ("nsoverload(Klass t, const Klass &)"); if (overload_template.nsoverload(k, "hello") != 1030) throw new Exception ("nsoverload(Klass t, const char *)"); if (overload_template.nsoverload(10.0, "hi") != 1040) throw new Exception ("nsoverload(double t, const char *)"); if (overload_template.nsoverload() != 1050) throw new Exception ("nsoverload(const char *)"); } } swig-3.0.2/Examples/test-suite/csharp/imports_runme.cs0000664000175000017500000000105512343605122022742 0ustar williamwilliamusing System; using importsNamespace; public class runme { static void Main() { B b = new B(); b.hello(); //call member function in A which is in a different SWIG generated library. b.bye(); if (b.member_virtual_test(A.MemberEnum.memberenum1) != A.MemberEnum.memberenum2) throw new Exception("Test 1 failed"); if (b.global_virtual_test(GlobalEnum.globalenum1) != GlobalEnum.globalenum2) throw new Exception("Test 2 failed"); imports_b.global_test(A.MemberEnum.memberenum1); } } swig-3.0.2/Examples/test-suite/csharp/nested_class_runme.cs0000664000175000017500000000500512343605122023713 0ustar williamwilliamusing System; using nested_classNamespace; #pragma warning disable 219 public class runme { static void Main() { Outer outer = new Outer(); outer.a = 1; outer.b = 2; Outer.InnerStruct1 is1 = outer.makeInnerStruct1(); Outer.InnerClass1 ic1 = outer.makeInnerClass1(); Outer.InnerUnion1 iu1 = outer.makeInnerUnion1(); Outer.InnerStruct2 is2 = outer.makeInnerStruct2(); Outer.InnerClass2 ic2 = outer.makeInnerClass2(); Outer.InnerUnion2 iu2 = outer.makeInnerUnion2(); Outer.InnerClass4Typedef ic4 = outer.makeInnerClass4Typedef(); Outer.InnerStruct4Typedef is4 = outer.makeInnerStruct4Typedef(); Outer.InnerUnion4Typedef iu4 = outer.makeInnerUnion4Typedef(); Outer.InnerClass5Typedef ic5 = outer.makeInnerClass5(); Outer.InnerStruct5Typedef is5 = outer.makeInnerStruct5(); Outer.InnerUnion5Typedef iu5 = outer.makeInnerUnion5(); ic5 = outer.makeInnerClass5Typedef(); is5 = outer.makeInnerStruct5Typedef(); iu5 = outer.makeInnerUnion5Typedef(); { Outer.InnerMultiple im1 = outer.MultipleInstance1; Outer.InnerMultiple im2 = outer.MultipleInstance2; Outer.InnerMultiple im3 = outer.MultipleInstance3; Outer.InnerMultiple im4 = outer.MultipleInstance4; } { Outer.InnerMultipleDerived im1 = outer.MultipleDerivedInstance1; Outer.InnerMultipleDerived im2 = outer.MultipleDerivedInstance2; Outer.InnerMultipleDerived im3 = outer.MultipleDerivedInstance3; Outer.InnerMultipleDerived im4 = outer.MultipleDerivedInstance4; } { Outer.InnerMultipleDerived im1 = outer.MultipleDerivedInstance1; Outer.InnerMultipleDerived im2 = outer.MultipleDerivedInstance2; Outer.InnerMultipleDerived im3 = outer.MultipleDerivedInstance3; Outer.InnerMultipleDerived im4 = outer.MultipleDerivedInstance4; } { Outer.InnerMultipleAnonTypedef1 mat1 = outer.makeInnerMultipleAnonTypedef1(); Outer.InnerMultipleAnonTypedef1 mat2 = outer.makeInnerMultipleAnonTypedef2(); SWIGTYPE_p_p_Outer__InnerMultipleAnonTypedef1 mat3 = outer.makeInnerMultipleAnonTypedef3(); Outer.InnerMultipleNamedTypedef1 mnt = outer.makeInnerMultipleNamedTypedef(); Outer.InnerMultipleNamedTypedef1 mnt1 = outer.makeInnerMultipleNamedTypedef1(); Outer.InnerMultipleNamedTypedef1 mnt2 = outer.makeInnerMultipleNamedTypedef2(); SWIGTYPE_p_p_Outer__InnerMultipleNamedTypedef mnt3 = outer.makeInnerMultipleNamedTypedef3(); } { Outer.InnerSameName isn = outer.makeInnerSameName(); } } } swig-3.0.2/Examples/test-suite/csharp/csharp_typemaps_runme.cs0000664000175000017500000000705212343605122024452 0ustar williamwilliamusing System; using System.Threading; using csharp_typemapsNamespace; public class runme { static void Main() { // Test the C# types customisation by modifying the default char * typemaps to return a single char Things things = new Things(); System.Text.StringBuilder initialLetters = new System.Text.StringBuilder(); char myChar = things.start("boo"); initialLetters.Append(myChar); myChar = Things.stop("hiss"); initialLetters.Append(myChar); myChar = csharp_typemaps.partyon("off"); initialLetters.Append(myChar); if (initialLetters.ToString() != "bho") throw new Exception("initial letters failed"); // $csinput expansion csharp_typemaps.myInt = 1; try { csharp_typemaps.myInt = -1; throw new Exception("oops"); } catch (ApplicationException) { } // Eager garbage collector test { const int NUM_THREADS = 8; Thread[] threads = new Thread[NUM_THREADS]; TestThread[] testThreads = new TestThread[NUM_THREADS]; // invoke the threads for (int i=0; i)) (test-A a) (test-tA a) (test-t2A a) (test-t3A a) (fA a) (define b (make )) (test-A b) (test-tA b) (test-t2A b) (test-t3A b) (test-B b) (fA b) (fB b) (define c (make )) (test-A c) (test-tA c) (test-t2A c) (test-t3A c) (test-C c) (fA c) (fC c) (define d (make )) (test-A d) (test-tA d) (test-t2A d) (test-t3A d) (test-D d) (test-tD d) (test-t2D d) (fA d) (fD d) ;; here are the real tests... if the clientdata is correctly ;; propegated, new-tA, new-t2A, should all return wrapped proxy's ;; of class (define a2 (new-tA)) (if (not (eq? (class-of a2) )) (error "Error 1")) (test-A a2) (test-tA a2) (test-t2A a2) (test-t3A a2) (fA a2) (define a3 (new-t2A)) (if (not (eq? (class-of a3) )) (error "Error 2")) (test-A a3) (test-tA a3) (test-t2A a3) (test-t3A a3) (fA a3) (define a4 (new-t3A)) (if (not (eq? (class-of a4) )) (error "Error 3")) (test-A a4) (test-tA a4) (test-t2A a4) (test-t3A a4) (fA a4) (define d2 (new-tD)) (if (not (eq? (class-of d2) )) (error "Error 4")) (test-A d2) (test-tA d2) (test-t2A d2) (test-t3A d2) (test-D d2) (test-tD d2) (fA d2) (fD d2) (define d3 (new-t2D)) (if (not (eq? (class-of d3) )) (error "Error 5")) (test-A d3) (test-tA d3) (test-t2A d3) (test-t3A d3) (test-D d3) (test-tD d3) (fA d3) (fD d3) (exit 0) swig-3.0.2/Examples/test-suite/chicken/README0000664000175000017500000000126112343605122020513 0ustar williamwilliamSee ../README for common README file. Any testcases which have _runme.ss appended after the testcase name will be detected and run. NOTE: I had to use _runme.ss because otherwise it would be hard to implement make clean Since when SWIG runs it generates an example.scm file for every test, to clean those files I needed to add a rm -f *.scm to make clean. But we don't want the runme scripts to disappear as well! Any testcases which have _runme_proxy.ss appended after the testcase name will be detected and run with the -proxy argument passed to SWIG. SWIG will not be run with the -unhide-primitive option, so the _runme_proxy.ss file must use only the tinyclos exported interface. swig-3.0.2/Examples/test-suite/chicken/global_vars_runme_proxy.ss0000664000175000017500000000010512343605122025140 0ustar williamwilliam(require 'global_vars) (load "../schemerunme/global_vars_proxy.scm") swig-3.0.2/Examples/test-suite/chicken/testsuite.ss0000664000175000017500000000103412343605122022231 0ustar williamwilliam(define (lookup-ext-tag tag) (cond ((equal? tag '(quote swig-contract-assertion-failed)) '( ((exn type) #f)) ) (#t '()))) (define-macro (expect-throw tag-form form) `(if (condition-case (begin ,form #t) ,@(lookup-ext-tag tag-form) ((exn) (print "The form threw a different error than expected: " ',form) (exit 1)) (var () (print "The form did not error as expected: " ',form) (exit 1))) (begin (print "The form returned normally when it was expected to throw an error: " ',form) (exit 1)))) swig-3.0.2/Examples/test-suite/chicken/li_std_string_runme_proxy.ss0000664000175000017500000000257612343605122025527 0ustar williamwilliam(load "li_std_string.so") (define x "hello") (if (not (string=? (test-value x) x)) (begin (error "Error 1") (exit 1))) (if (not (string=? (test-const-reference x) x)) (begin (error "Error 2") (exit 1))) (define y (test-pointer-out)) (test-pointer y) (define z (test-const-pointer-out)) (test-const-pointer z) (define a (test-reference-out)) (test-reference a) ;; test global variables (GlobalString "whee") (if (not (string=? (GlobalString) "whee")) (error "Error 3")) (if (not (string=? (GlobalString2) "global string 2")) (error "Error 4")) (define struct (make )) ;; MemberString should be a wrapped class (if (not (string=? (slot-ref struct 'MemberString) "")) (error "Error 4.5")) ;(slot-set! (slot-ref struct 'MemberString) "and how") ;;(if (not (string=? (slot-ref struct 'MemberString) "and how")) ;; (error "Error 5")) (if (not (string=? (slot-ref struct 'MemberString2) "member string 2")) (error "Error 6")) (Structure-StaticMemberString "static str") (if (not (string=? (Structure-StaticMemberString) "static str")) (error "Error 7")) (if (not (string=? (Structure-StaticMemberString2) "static member string 2")) (error "Error 8")) ;(if (not (string=? (Structure-ConstMemberString-get struct) "const member string")) ; (error "Error 9")) (if (not (string=? (Structure-ConstStaticMemberString) "const static member string")) (error "Error 10")) (exit 0) swig-3.0.2/Examples/test-suite/chicken/newobject1_runme_proxy.ss0000664000175000017500000000057712343605122024723 0ustar williamwilliam(require 'newobject1) (define-macro (check-count val) `(if (not (= (Foo-fooCount) ,val)) (error "Error checking val " ,val " != " ,(Foo-fooCount)))) (define f (Foo-makeFoo)) (check-count 1) (define f2 (makeMore f)) (check-count 2) (set! f #f) (gc #t) (check-count 1) (define f3 (makeMore f2)) (check-count 2) (set! f3 #f) (set! f2 #f) (gc #t) (check-count 0) (exit 0) swig-3.0.2/Examples/test-suite/chicken/char_constant_runme.ss0000664000175000017500000000010712343605122024234 0ustar williamwilliam(load "char_constant.so") (include "../schemerunme/char_constant.scm") swig-3.0.2/Examples/test-suite/chicken/newobject2_runme.ss0000664000175000017500000000072212343605122023453 0ustar williamwilliam(load "newobject2.so") (define f (new-Foo)) (Foo-dummy-set f 14) (if (not (= (Foo-dummy-get f) 14)) (error "Bad dummy value")) (if (not (= (fooCount) 0)) (error "Bad foo count 1")) (define f2 (makeFoo)) (if (not (= (fooCount) 1)) (error "Bad foo count 2")) (Foo-dummy-set f2 16) (if (not (= (Foo-dummy-get f2) 16)) (error "Bad dummy value for f2")) (set! f #f) (set! f2 #f) (gc #t) (if (not (= (fooCount) -1)) (error "Bad foo count 3")) (exit 0) swig-3.0.2/Examples/test-suite/chicken/cpp_enum_runme.ss0000664000175000017500000000007512343605122023220 0ustar williamwilliam(load "cpp_enum.so") (include "../schemerunme/cpp_enum.scm") swig-3.0.2/Examples/test-suite/chicken/overload_simple_runme.ss0000664000175000017500000000011312343605122024567 0ustar williamwilliam(load "overload_simple.so") (include "../schemerunme/overload_simple.scm") swig-3.0.2/Examples/test-suite/chicken/overload_simple_runme_proxy.ss0000664000175000017500000000321512343605122026036 0ustar williamwilliam(load "overload_simple.so") (define-macro (check test) `(if (not ,test) (error ',test))) (check (string=? (foo) "foo:")) (check (string=? (foo 3) "foo:int")) (check (string=? (foo 3.01) "foo:double")) (check (string=? (foo "hey") "foo:char *")) (define f (make )) (define b (make )) (define b2 (make 3)) (check (= (slot-ref b 'num) 0)) (check (= (slot-ref b2 'num) 3)) (check (string=? (foo f) "foo:Foo *")) (check (string=? (foo b) "foo:Bar *")) (check (string=? (foo f 3) "foo:Foo *,int")) (check (string=? (foo 3.2 b) "foo:double,Bar *")) ;; now check blah (check (string=? (blah 2.01) "blah:double")) (check (string=? (blah "hey") "blah:char *")) ;; now check spam member functions (define s (make )) (define s2 (make 3)) (define s3 (make 3.2)) (define s4 (make "whee")) (define s5 (make f)) (define s6 (make b)) (check (string=? (slot-ref s 'type) "none")) (check (string=? (slot-ref s2 'type) "int")) (check (string=? (slot-ref s3 'type) "double")) (check (string=? (slot-ref s4 'type) "char *")) (check (string=? (slot-ref s5 'type) "Foo *")) (check (string=? (slot-ref s6 'type) "Bar *")) ;; now check Spam member functions (check (string=? (foo s 2) "foo:int")) (check (string=? (foo s 2.1) "foo:double")) (check (string=? (foo s "hey") "foo:char *")) (check (string=? (foo s f) "foo:Foo *")) (check (string=? (foo s b) "foo:Bar *")) ;; check static member funcs (check (string=? (Spam-bar 3) "bar:int")) (check (string=? (Spam-bar 3.2) "bar:double")) (check (string=? (Spam-bar "hey") "bar:char *")) (check (string=? (Spam-bar f) "bar:Foo *")) (check (string=? (Spam-bar b) "bar:Bar *")) (exit 0) swig-3.0.2/Examples/test-suite/chicken/overload_copy_runme.ss0000664000175000017500000000010712343605122024253 0ustar williamwilliam(load "overload_copy.so") (include "../schemerunme/overload_copy.scm") swig-3.0.2/Examples/test-suite/chicken/typedef_inherit_runme.ss0000664000175000017500000000011312343605122024565 0ustar williamwilliam(load "typedef_inherit.so") (include "../schemerunme/typedef_inherit.scm") swig-3.0.2/Examples/test-suite/chicken/inherit_missing_runme.ss0000664000175000017500000000011312343605122024576 0ustar williamwilliam(load "inherit_missing.so") (include "../schemerunme/inherit_missing.scm") swig-3.0.2/Examples/test-suite/chicken/contract_runme.ss0000664000175000017500000000012612343605122023224 0ustar williamwilliam(load "contract.so") (include "testsuite.ss") (include "../schemerunme/contract.scm") swig-3.0.2/Examples/test-suite/chicken/global_vars_runme.ss0000664000175000017500000000007712343605122023707 0ustar williamwilliam(require 'global_vars) (load "../schemerunme/global_vars.scm") swig-3.0.2/Examples/test-suite/chicken/multivalue_runme.ss0000664000175000017500000000014612343605122023600 0ustar williamwilliam;; this doesn't work yet :( (load "multivalue.so") (include "../schemerunme/multivalue.scm") (exit 0) swig-3.0.2/Examples/test-suite/chicken/list_vector_runme.ss0000664000175000017500000000010312343605122023737 0ustar williamwilliam(load "list_vector.so") (include "../schemerunme/list_vector.scm") swig-3.0.2/Examples/test-suite/chicken/dynamic_cast_runme.ss0000664000175000017500000000010512343605122024042 0ustar williamwilliam(load "dynamic_cast.so") (include "../schemerunme/dynamic_cast.scm") swig-3.0.2/Examples/test-suite/chicken/newobject2_runme_proxy.ss0000664000175000017500000000073712343605122024722 0ustar williamwilliam(load "newobject2.so") (define f (make )) (slot-set! f 'dummy 14) (if (not (= (slot-ref f 'dummy) 14)) (error "Bad dummy value")) (if (not (= (fooCount) 0)) (error "Bad foo count 1")) (define f2 (makeFoo)) (if (not (= (fooCount) 1)) (error "Bad foo count 2")) (slot-set! f2 'dummy 16) (if (not (= (slot-ref f2 'dummy) 16)) (error "Bad dummy value for f2")) (set! f #f) (set! f2 #f) (gc #t) (if (not (= (fooCount) -1)) (error "Bad foo count 3")) (exit 0) swig-3.0.2/Examples/test-suite/chicken/overload_extend_runme_proxy.ss0000664000175000017500000000037212343605122026035 0ustar williamwilliam(load "./overload_extend.so") (define f (make )) (if (not (= (test f 3) 1)) (error "test integer bad")) (if (not (= (test f "hello") 2)) (error "test string bad")) (if (not (= (test f 3.5 2.5) 6.0)) (error "test reals bad")) (exit 0) swig-3.0.2/Examples/test-suite/chicken/throw_exception_runme.ss0000664000175000017500000000211312343605122024626 0ustar williamwilliam(load "throw_exception.so") (define-macro (check-throw expr check) `(if (handle-exceptions exvar (if ,check #f (begin (print "Error executing: " ',expr " " exvar) (exit 1))) ,expr #t) (print "Expression did not throw an error: " ',expr))) (define f (new-Foo)) (check-throw (Foo-test-int f) (= exvar 37)) (check-throw (Foo-test-msg f) (string=? exvar "Dead")) (check-throw (Foo-test-cls f) (test-is-Error exvar)) (check-throw (Foo-test-cls-ptr f) (test-is-Error exvar)) (check-throw (Foo-test-cls-ref f) (test-is-Error exvar)) (check-throw (Foo-test-cls-td f) (test-is-Error exvar)) (check-throw (Foo-test-cls-ptr-td f) (test-is-Error exvar)) (check-throw (Foo-test-cls-ref-td f) (test-is-Error exvar)) (check-throw (Foo-test-enum f) (= exvar (enum2))) ; don't know how to test this... it is returning a SWIG wrapped int * ;(check-throw (Foo-test-array f) (equal? exvar '(0 1 2 3 4 5 6 7 8 9))) (check-throw (Foo-test-multi f 1) (= exvar 37)) (check-throw (Foo-test-multi f 2) (string=? exvar "Dead")) (check-throw (Foo-test-multi f 3) (test-is-Error exvar)) (set! f #f) (gc #t) (exit 0) swig-3.0.2/Examples/test-suite/chicken/name_runme.ss0000664000175000017500000000006512343605122022331 0ustar williamwilliam(load "name.so") (include "../schemerunme/name.scm") swig-3.0.2/Examples/test-suite/chicken/casts_runme.ss0000664000175000017500000000006712343605122022530 0ustar williamwilliam(load "casts.so") (include "../schemerunme/casts.scm") swig-3.0.2/Examples/test-suite/chicken/multiple_inheritance_runme_proxy.ss0000664000175000017500000000012712343605122027055 0ustar williamwilliam(require 'multiple_inheritance) (load "../schemerunme/multiple_inheritance_proxy.scm") swig-3.0.2/Examples/test-suite/chicken/overload_subtype_runme.ss0000664000175000017500000000011512343605122024773 0ustar williamwilliam(load "overload_subtype.so") (include "../schemerunme/overload_subtype.scm") swig-3.0.2/Examples/test-suite/chicken/cpp_namespace_runme.ss0000664000175000017500000000010712343605122024204 0ustar williamwilliam(load "cpp_namespace.so") (include "../schemerunme/cpp_namespace.scm") swig-3.0.2/Examples/test-suite/chicken/reference_global_vars_runme.ss0000664000175000017500000000012712343605122025721 0ustar williamwilliam(load "reference_global_vars.so") (include "../schemerunme/reference_global_vars.scm") swig-3.0.2/Examples/test-suite/chicken/overload_copy_runme_proxy.ss0000664000175000017500000000013112343605122025511 0ustar williamwilliam(load "./overload_copy.so") (define f (make )) (define g (make f)) (exit 0) swig-3.0.2/Examples/test-suite/chicken/li_typemaps_runme.ss0000664000175000017500000000056112343605122023740 0ustar williamwilliam(require 'li_typemaps) (load "../schemerunme/li_typemaps.scm") (call-with-values (lambda () (inoutr-int2 3 -2)) (lambda (a b) (if (not (and (= a 3) (= b -2))) (error "Error in inoutr-int2")))) (call-with-values (lambda () (out-foo 4)) (lambda (a b) (if (not (and (= (Foo-a-get a) 4) (= b 8))) (error "Error in out-foo")))) (exit 0) swig-3.0.2/Examples/test-suite/chicken/typename_runme.ss0000664000175000017500000000007512343605122023234 0ustar williamwilliam(load "typename.so") (include "../schemerunme/typename.scm") swig-3.0.2/Examples/test-suite/chicken/cpp_basic_runme_proxy.ss0000664000175000017500000000351112343605122024574 0ustar williamwilliam(require 'cpp_basic) (define-macro (check test) `(if (not ,test) (error "Error in test " ',test))) (define f (make 4)) (check (= (slot-ref f 'num) 4)) (slot-set! f 'num -17) (check (= (slot-ref f 'num) -17)) (define b (make )) (slot-set! b 'fptr f) (check (= (slot-ref (slot-ref b 'fptr) 'num) -17)) (check (= (test b -3 (slot-ref b 'fptr)) -5)) (slot-set! f 'num 12) (check (= (slot-ref (slot-ref b 'fptr) 'num) 12)) (check (= (slot-ref (slot-ref b 'fref) 'num) -4)) (check (= (test b 12 (slot-ref b 'fref)) 23)) ;; references don't take ownership, so if we didn't define this here it might get garbage collected (define f2 (make 23)) (slot-set! b 'fref f2) (check (= (slot-ref (slot-ref b 'fref) 'num) 23)) (check (= (test b -3 (slot-ref b 'fref)) 35)) (check (= (slot-ref (slot-ref b 'fval) 'num) 15)) (check (= (test b 3 (slot-ref b 'fval)) 33)) (slot-set! b 'fval (make -15)) (check (= (slot-ref (slot-ref b 'fval) 'num) -15)) (check (= (test b 3 (slot-ref b 'fval)) -27)) (define f3 (testFoo b 12 (slot-ref b 'fref))) (check (= (slot-ref f3 'num) 32)) ;; now test global (define f4 (make 6)) (Bar-global-fptr f4) (check (= (slot-ref (Bar-global-fptr) 'num) 6)) (slot-set! f4 'num 8) (check (= (slot-ref (Bar-global-fptr) 'num) 8)) (check (= (slot-ref (Bar-global-fref) 'num) 23)) (Bar-global-fref (make -7)) (check (= (slot-ref (Bar-global-fref) 'num) -7)) (check (= (slot-ref (Bar-global-fval) 'num) 3)) (Bar-global-fval (make -34)) (check (= (slot-ref (Bar-global-fval) 'num) -34)) ;; Now test function pointers (define func1ptr (get-func1-ptr)) (define func2ptr (get-func2-ptr)) (slot-set! f 'num 4) (check (= (func1 f 2) 16)) (check (= (func2 f 2) -8)) (slot-set! f 'func-ptr func1ptr) (check (= (test-func-ptr f 2) 16)) (slot-set! f 'func-ptr func2ptr) (check (= (test-func-ptr f 2) -8)) (exit 0) swig-3.0.2/Examples/test-suite/chicken/unions_runme_proxy.ss0000664000175000017500000000007712343605122024170 0ustar williamwilliam(load "unions.so") (include "../schemerunme/unions_proxy.scm") swig-3.0.2/Examples/test-suite/chicken/li_std_string_runme.ss0000664000175000017500000000010712343605122024252 0ustar williamwilliam(load "li_std_string.so") (include "../schemerunme/li_std_string.scm") swig-3.0.2/Examples/test-suite/chicken/unions_runme.ss0000664000175000017500000000007112343605122022721 0ustar williamwilliam(load "unions.so") (include "../schemerunme/unions.scm") swig-3.0.2/Examples/test-suite/chicken/chicken_ext_test_external.cxx0000664000175000017500000000077712343605122025617 0ustar williamwilliam#include #include void test_create(C_word,C_word,C_word) C_noret; void test_create(C_word argc, C_word closure, C_word continuation) { C_word resultobj; swig_type_info *type; A *newobj; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_trace("test-create"); if (argc!=2) C_bad_argc(argc,2); newobj = new A(); type = SWIG_TypeQuery("A *"); resultobj = SWIG_NewPointerObj(newobj, type, 1); C_kontinue(continuation, resultobj); } swig-3.0.2/Examples/test-suite/chicken/overload_extend_runme.ss0000664000175000017500000000011312343605122024565 0ustar williamwilliam(load "overload_extend.so") (include "../schemerunme/overload_extend.scm") swig-3.0.2/Examples/test-suite/chicken/li_typemaps_runme_proxy.ss0000664000175000017500000000057212343605122025203 0ustar williamwilliam(require 'li_typemaps) (load "../schemerunme/li_typemaps_proxy.scm") (call-with-values (lambda () (inoutr-int2 3 -2)) (lambda (a b) (if (not (and (= a 3) (= b -2))) (error "Error in inoutr-int2")))) (call-with-values (lambda () (out-foo 4)) (lambda (a b) (if (not (and (= (slot-ref a 'a) 4) (= b 8))) (error "Error in out-foo")))) (exit 0) swig-3.0.2/Examples/test-suite/chicken/class_ignore_runme.ss0000664000175000017500000000010512343605122024054 0ustar williamwilliam(load "class_ignore.so") (include "../schemerunme/class_ignore.scm") swig-3.0.2/Examples/test-suite/chicken/chicken_ext_test_runme.ss0000664000175000017500000000010412343605122024726 0ustar williamwilliam(load "chicken_ext_test.so") (define a (test-create)) (A-hello a) swig-3.0.2/Examples/test-suite/chicken/pointer_in_out_runme.ss0000664000175000017500000000011112343605122024436 0ustar williamwilliam(load "pointer_in_out.so") (include "../schemerunme/pointer_in_out.scm") swig-3.0.2/Examples/test-suite/chicken/overload_subtype_runme_proxy.ss0000664000175000017500000000030212343605122026232 0ustar williamwilliam(load "./overload_subtype.so") (define f (make )) (define b (make )) (if (not (= (spam f) 1)) (error "Error in foo")) (if (not (= (spam b) 2)) (error "Error in bar")) (exit 0) swig-3.0.2/Examples/test-suite/chicken/member_pointer_runme.ss0000664000175000017500000000142212343605122024416 0ustar williamwilliam(require 'member_pointer) (define (check-eq? msg expected actual) (if (not (= expected actual)) (error "Error " msg ": expected " expected " got " actual))) (define area-pt (areapt)) (define perim-pt (perimeterpt)) (define s (new-Square 10)) (check-eq? "Square area" 100.0 (do-op s area-pt)) (check-eq? "Square perim" 40.0 (do-op s perim-pt)) (check-eq? "Square area" 100.0 (do-op s (areavar))) (check-eq? "Square perim" 40.0 (do-op s (perimetervar))) ;; Set areavar to return value of function (areavar perim-pt) (check-eq? "Square perim" 40 (do-op s (areavar))) (check-eq? "Square area" 100.0 (do-op s (AREAPT))) (check-eq? "Square perim" 40.0 (do-op s (PERIMPT))) (define test (NULLPT)) (perimetervar (AREAPT)) (check-eq? "Square area" 100.0 (do-op s (perimetervar))) swig-3.0.2/Examples/test-suite/chicken/Makefile.in0000664000175000017500000000502112343605122021676 0ustar williamwilliam####################################################################### # Makefile for chicken test-suite ####################################################################### LANGUAGE = chicken VARIANT = SCRIPTSUFFIX = _runme.ss PROXYSUFFIX = _runme_proxy.ss srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CHICKEN_CSI = @CHICKEN_CSI@ -quiet -batch -no-init SO = @SO@ #C_TEST_CASES = long_long list_vector pointer_in_out multivalue # Skip the STD cases for now, except for li_std_string.i SKIP_CPP_STD_CASES = Yes CPP_TEST_CASES += li_std_string EXTRA_TEST_CASES += chicken_ext_test.externaltest include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -nounit # Custom tests - tests with additional commandline options # If there exists a PROXYSUFFIX runme file, we also generate the wrapper # with the -proxy argument %.cppproxy: SWIGOPT += -proxy %.cppproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) %.cproxy: SWIGOPT += -proxy %.cproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) %.multiproxy: SWIGOPT += -proxy -noclosuses %.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ $(MAKE) $*.cppproxy; \ fi %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ $(MAKE) $*.cproxy; \ fi %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ $(MAKE) $*.multiproxy; \ fi %.externaltest: $(setup) +$(swig_and_compile_external) $(run_testcase) %.cppproxy: echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test) with -proxy" +$(swig_and_compile_cpp) $(run_testcase) %.cproxy: echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test) with -proxy" +$(swig_and_compile_c) $(run_testcase) %.multiproxy: echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test) with -proxy" +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.scm appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean %.clean: @exit 0 clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" chicken_clean rm -f *.scm swig-3.0.2/Examples/test-suite/chicken/import_nomodule_runme.ss0000664000175000017500000000011312343605122024617 0ustar williamwilliam(load "import_nomodule.so") (include "../schemerunme/import_nomodule.scm") swig-3.0.2/Examples/test-suite/chicken/constover_runme.ss0000664000175000017500000000007712343605122023436 0ustar williamwilliam(load "constover.so") (include "../schemerunme/constover.scm") swig-3.0.2/Examples/test-suite/chicken/imports_runme.ss0000664000175000017500000000012312343605122023101 0ustar williamwilliam(load "imports_a.so") (load "imports_b.so") (include "../schemerunme/imports.scm") swig-3.0.2/Examples/test-suite/chicken/overload_complicated_runme.ss0000664000175000017500000000012512343605122025565 0ustar williamwilliam(load "overload_complicated.so") (include "../schemerunme/overload_complicated.scm") swig-3.0.2/Examples/test-suite/valuewrapper.i0000664000175000017500000000036212343605122021117 0ustar williamwilliam// valuewrapper.i %module valuewrapper %inline %{ template struct X { X(int) {} }; template struct Y { Y() {} int spam(T t = T(0)) { return 0; } }; %} %template(Xi) X; %template(YXi) Y< X >; swig-3.0.2/Examples/test-suite/throw_exception.i0000664000175000017500000000346112343605122021626 0ustar williamwilliam%module throw_exception %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum1; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum2; #ifdef SWIGPHP %warnfilter(SWIGWARN_PARSE_KEYWORD) Namespace; #endif // Tests SWIG's automatic exception mechanism %inline %{ class Error { }; void test_is_Error(Error *r) {} namespace Namespace { typedef Error ErrorTypedef; typedef const Error& ErrorRef; typedef const Error* ErrorPtr; typedef int IntArray[10]; enum EnumTest { enum1, enum2 }; } class Foo { public: void test_int() throw(int) { throw 37; } void test_msg() throw(const char *) { throw "Dead"; } void test_cls() throw(Error) { throw Error(); } void test_cls_ptr() throw(Error *) { static Error StaticError; throw &StaticError; } void test_cls_ref() throw(Error &) { static Error StaticError; throw StaticError; } void test_cls_td() throw(Namespace::ErrorTypedef) { throw Error(); } void test_cls_ptr_td() throw(Namespace::ErrorPtr) { static Error StaticError; throw &StaticError; } void test_cls_ref_td() throw(Namespace::ErrorRef) { static Error StaticError; throw StaticError; } void test_array() throw(Namespace::IntArray) { static Namespace::IntArray array; for (int i=0; i<10; i++) { array[i] = i; } throw array; } void test_enum() throw(Namespace::EnumTest) { throw Namespace::enum2; } void test_multi(int x) throw(int, const char *, Error) { if (x == 1) throw 37; if (x == 2) throw "Dead"; if (x == 3) throw Error(); } }; %} swig-3.0.2/Examples/test-suite/typemap_global_scope.i0000664000175000017500000002041612343605122022574 0ustar williamwilliam%module typemap_global_scope // Test global scope operator :: for typemaps. Previously SWIG would not use a typemap that did not specify the global scope // operator for a type that did have it, and vice-versa. %typemap(in) SWIGTYPE "_this_will_not_compile_SWIGTYPE_ \"$type\"" %typemap(in) const SWIGTYPE & "_this_will_not_compile_const_SWIGTYPE_REF_ \"$type\"" %typemap(in) enum SWIGTYPE "_this_will_not_compile_enum_SWIGTYPE_ \"$type\"" %typemap(in) const enum SWIGTYPE & "_this_will_not_compile_const_enum_SWIGTYPE_REF_ \"$type\"" ///////////////////////////////////////////////////////////////////// // Structs ///////////////////////////////////////////////////////////////////// %typemap(in) Test1, ::Test2, Space::Test3, ::Space::Test4 "$1 = $type(); /*in typemap for $type*/" %typemap(in) const Test1 &, const ::Test2 &, const Space::Test3 &, const ::Space::Test4 & "/*in typemap for $type*/" %inline %{ struct Test1 {}; struct Test2 {}; namespace Space { struct Test3 {}; struct Test4 {}; } %} %inline %{ void test1a(Test1 t, const Test1 &tt) {} void test1b(::Test1 t, const ::Test1 &tt) {} void test2a(Test2 t, const Test2 &tt) {} void test2b(::Test2 t, const ::Test2 &tt) {} void test3a(Space::Test3 t, const Space::Test3 &tt) {} void test3b(::Space::Test3 t, const ::Space::Test3 &tt) {} namespace Space { void test3c(Space::Test3 t, const Space::Test3 &tt) {} void test3d(::Space::Test3 t, const ::Space::Test3 &tt) {} void test3e(Test3 t, const Test3 &tt) {} } void test4a(Space::Test4 t, const Space::Test4 &tt) {} void test4b(::Space::Test4 t, const ::Space::Test4 &tt) {} namespace Space { void test4c(Space::Test4 t, const Space::Test4 &tt) {} void test4d(::Space::Test4 t, const ::Space::Test4 &tt) {} void test4e(Test4 t, const Test4 &tt) {} } %} ///////////////////////////////////////////////////////////////////// // Templates ///////////////////////////////////////////////////////////////////// %inline %{ struct XX {}; %} %typemap(in) TemplateTest1< ::XX >, ::TemplateTest2< ::XX >, Space::TemplateTest3< ::XX >, ::Space::TemplateTest4< ::XX > "$1 = $type(); /* in typemap for $type */" %typemap(in) const TemplateTest1< XX > &, const ::TemplateTest2< XX > &, const Space::TemplateTest3< XX > &, const ::Space::TemplateTest4< XX > & "/* in typemap for $type */" %inline %{ template struct TemplateTest1 { T m_t; }; template struct TemplateTest2 { T m_t; }; namespace Space { template struct TemplateTest3 { T m_t; }; template struct TemplateTest4 { T m_t; }; } %} %template(TemplateTest1XX) TemplateTest1< ::XX >; %template(TemplateTest2XX) TemplateTest2< ::XX >; %template(TemplateTest3XX) Space::TemplateTest3< ::XX >; %template(TemplateTest4XX) Space::TemplateTest4< ::XX >; %inline %{ void test_template_1a(TemplateTest1< ::XX > t, const TemplateTest1< ::XX > &tt) {} void test_template_1b(::TemplateTest1< ::XX > t, const ::TemplateTest1< ::XX > &tt) {} void test_template_2a(TemplateTest2< ::XX > t, const TemplateTest2< ::XX > &tt) {} void test_template_2b(::TemplateTest2< ::XX > t, const ::TemplateTest2< ::XX > &tt) {} void test_template_3a(Space::TemplateTest3< ::XX > t, const Space::TemplateTest3< ::XX > &tt) {} void test_template_3b(::Space::TemplateTest3< ::XX > t, const ::Space::TemplateTest3< ::XX > &tt) {} namespace Space { void test_template_3c(Space::TemplateTest3< ::XX > t, const Space::TemplateTest3< ::XX > &tt) {} void test_template_3d(::Space::TemplateTest3< ::XX > t, const ::Space::TemplateTest3< ::XX > &tt) {} void test_template_3e(TemplateTest3< ::XX > t, const TemplateTest3< ::XX > &tt) {} } void test_template_4a(Space::TemplateTest4< ::XX > t, const Space::TemplateTest4< ::XX > &tt) {} void test_template_4b(::Space::TemplateTest4< ::XX > t, const ::Space::TemplateTest4< ::XX > &tt) {} namespace Space { void test_template_4c(Space::TemplateTest4< ::XX > t, const Space::TemplateTest4< ::XX > &tt) {} void test_template_4d(::Space::TemplateTest4< ::XX > t, const ::Space::TemplateTest4< ::XX > &tt) {} void test_template_4e(TemplateTest4< ::XX > t, const TemplateTest4< ::XX > &tt) {} } %} ///////////////////////////////////////////////////////////////////// // Enums ///////////////////////////////////////////////////////////////////// %typemap(in) Enum1, ::Enum2, Space::Enum3, ::Space::Enum4 "$1 = $1_type(); /*in typemap for $type*/" %typemap(in) const Enum1 &, const ::Enum2 &, const Space::Enum3 &, const ::Space::Enum4 & "/*in typemap for $type*/" %inline %{ enum Enum1 { enum_1 }; enum Enum2 { enum_2 }; namespace Space { enum Enum3 { enum_3 }; enum Enum4 { enum_4 }; } %} %inline %{ void test_enum_1a(Enum1 t, const Enum1 &tt) {} void test_enum_1b(::Enum1 t, const ::Enum1 &tt) {} void test_enum_2a(Enum2 t, const Enum2 &tt) {} void test_enum_2b(::Enum2 t, const ::Enum2 &tt) {} void test_enum_3a(Space::Enum3 t, const Space::Enum3 &tt) {} void test_enum_3b(::Space::Enum3 t, const ::Space::Enum3 &tt) {} namespace Space { void test_enum_3c(Space::Enum3 t, const Space::Enum3 &tt) {} void test_enum_3d(::Space::Enum3 t, const ::Space::Enum3 &tt) {} void test_enum_3e(Enum3 t, const Enum3 &tt) {} } void test_enum_4a(Space::Enum4 t, const Space::Enum4 &tt) {} void test_enum_4b(::Space::Enum4 t, const ::Space::Enum4 &tt) {} namespace Space { void test_enum_4c(Space::Enum4 t, const Space::Enum4 &tt) {} void test_enum_4d(::Space::Enum4 t, const ::Space::Enum4 &tt) {} void test_enum_4e(Enum4 t, const Enum4 &tt) {} } %} #if 0 ///////////////////////////////////////////////////////////////////// // Enums with enum specified in typemap ///////////////////////////////////////////////////////////////////// %typemap(in) enum Mune1, enum ::Mune2, enum Space::Mune3, enum ::Space::Mune4 "/*in typemap for $type*/" %typemap(in) const enum Mune1 &, const enum ::Mune2 &, const enum Space::Mune3 &, const enum ::Space::Mune4 & "/*in typemap for $type*/" %inline %{ enum Mune1 { mune_1 }; enum Mune2 { mune_2 }; namespace Space { enum Mune3 { mune_3 }; enum Mune4 { mune_4 }; } %} %inline %{ void test_mune_1a(Mune1 t, const Mune1 &tt) {} void test_mune_1b(::Mune1 t, const ::Mune1 &tt) {} void test_mune_2a(Mune2 t, const Mune2 &tt) {} void test_mune_2b(::Mune2 t, const ::Mune2 &tt) {} void test_mune_3a(Space::Mune3 t, const Space::Mune3 &tt) {} void test_mune_3b(::Space::Mune3 t, const ::Space::Mune3 &tt) {} namespace Space { void test_mune_3c(Space::Mune3 t, const Space::Mune3 &tt) {} void test_mune_3d(::Space::Mune3 t, const ::Space::Mune3 &tt) {} void test_mune_3e(Mune3 t, const Mune3 &tt) {} } void test_mune_4a(Space::Mune4 t, const Space::Mune4 &tt) {} void test_mune_4b(::Space::Mune4 t, const ::Space::Mune4 &tt) {} namespace Space { void test_mune_4c(Space::Mune4 t, const Space::Mune4 &tt) {} void test_mune_4d(::Space::Mune4 t, const ::Space::Mune4 &tt) {} void test_mune_4e(Mune4 t, const Mune4 &tt) {} } %} ///////////////////////////////////////////////////////////////////// // Enums with enum specified in type ///////////////////////////////////////////////////////////////////// %typemap(in) Nemu1, ::Nemu2, Space::Nemu3, ::Space::Nemu4 "/*in typemap for $type*/" %typemap(in) const Nemu1 &, const ::Nemu2 &, const Space::Nemu3 &, const ::Space::Nemu4 & "/*in typemap for $type*/" %inline %{ enum Nemu1 { nemu_1 }; enum Nemu2 { nemu_2 }; namespace Space { enum Nemu3 { nemu_3 }; enum Nemu4 { nemu_4 }; } %} %inline %{ void test_nemu_1a(enum Nemu1 t, const enum Nemu1 &tt) {} void test_nemu_1b(enum ::Nemu1 t, const enum ::Nemu1 &tt) {} void test_nemu_2a(enum Nemu2 t, const enum Nemu2 &tt) {} void test_nemu_2b(enum ::Nemu2 t, const enum ::Nemu2 &tt) {} void test_nemu_3a(enum Space::Nemu3 t, const enum Space::Nemu3 &tt) {} void test_nemu_3b(enum ::Space::Nemu3 t, const enum ::Space::Nemu3 &tt) {} namespace Space { void test_nemu_3c(enum Space::Nemu3 t, const enum Space::Nemu3 &tt) {} void test_nemu_3d(enum ::Space::Nemu3 t, const enum ::Space::Nemu3 &tt) {} void test_nemu_3e(enum Nemu3 t, const enum Nemu3 &tt) {} } void test_nemu_4a(enum Space::Nemu4 t, const enum Space::Nemu4 &tt) {} void test_nemu_4b(enum ::Space::Nemu4 t, const enum ::Space::Nemu4 &tt) {} namespace Space { void test_nemu_4c(enum Space::Nemu4 t, const enum Space::Nemu4 &tt) {} void test_nemu_4d(enum ::Space::Nemu4 t, const enum ::Space::Nemu4 &tt) {} void test_nemu_4e(enum Nemu4 t, const enum Nemu4 &tt) {} } %} #endif swig-3.0.2/Examples/test-suite/template_typedef_cplx.i0000664000175000017500000001115412343605122022764 0ustar williamwilliam%module template_typedef_cplx // // Change this to #if 1 to test the 'test' // #if 0 %{ #include typedef std::complex cmplx; %} %inline %{ typedef cmplx Complex; %} #else %inline %{ #include typedef std::complex Complex; %} #endif %inline %{ namespace vfncs { struct UnaryFunctionBase { }; template struct UnaryFunction; template struct ArithUnaryFunction; template struct UnaryFunction : UnaryFunctionBase { }; template struct ArithUnaryFunction : UnaryFunction { }; template struct unary_func_traits { typedef ArithUnaryFunction base; }; template inline typename unary_func_traits< ArgType, ArgType >::base make_Identity() { return typename unary_func_traits< ArgType, ArgType >::base(); } template struct arith_traits { }; template<> struct arith_traits< double, double > { typedef double argument_type; typedef double result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< Complex, Complex > { typedef Complex argument_type; typedef Complex result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< Complex, double > { typedef double argument_type; typedef Complex result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< double, Complex > { typedef double argument_type; typedef Complex result_type; static const char* const arg_type; static const char* const res_type; }; template inline ArithUnaryFunction::argument_type, typename arith_traits< RF, RG >::result_type > make_Multiplies(const ArithUnaryFunction& f, const ArithUnaryFunction& g) { return ArithUnaryFunction::argument_type, typename arith_traits< RF, RG >::result_type>(); } #ifndef SWIG // Initialize these static class members const char* const arith_traits< double, double >::arg_type = "double"; const char* const arith_traits< double, double >::res_type = "double"; const char* const arith_traits< Complex, Complex >::arg_type = "complex"; const char* const arith_traits< Complex, Complex >::res_type = "complex"; const char* const arith_traits< Complex, double>::arg_type = "double"; const char* const arith_traits< Complex, double >::res_type = "complex"; const char* const arith_traits< double, Complex >::arg_type = "double"; const char* const arith_traits< double, Complex >::res_type = "complex"; #endif } %} namespace vfncs { %template(UnaryFunction_double_double) UnaryFunction; %template(ArithUnaryFunction_double_double) ArithUnaryFunction; %template() unary_func_traits; %template() arith_traits; %template(make_Identity_double) make_Identity; %template(UnaryFunction_complex_complex) UnaryFunction; %template(ArithUnaryFunction_complex_complex) ArithUnaryFunction; %template() unary_func_traits; %template() arith_traits; %template(make_Identity_complex) make_Identity; /* [beazley] Added this part */ %template() unary_func_traits; %template(UnaryFunction_double_complex) UnaryFunction; %template(ArithUnaryFunction_double_complex) ArithUnaryFunction; /* */ %template() arith_traits; %template() arith_traits; %template(make_Multiplies_double_double_complex_complex) make_Multiplies; %template(make_Multiplies_double_double_double_double) make_Multiplies; %template(make_Multiplies_complex_complex_complex_complex) make_Multiplies; %template(make_Multiplies_complex_complex_double_double) make_Multiplies; } swig-3.0.2/Examples/test-suite/primitive_ref.i0000664000175000017500000000123312343605122021244 0ustar williamwilliam// Tests passing of references to primitive datatypes %module primitive_ref %define ref(type,name) %inline %{ const type &ref_##name(const type &x) { static type y = x; return y; } %} %enddef ref(int,int); ref(unsigned int, uint); ref(short, short); ref(unsigned short, ushort); ref(long,long); ref(unsigned long, ulong); ref(signed char, schar); ref(unsigned char, uchar); ref(char, char); ref(float, float); ref(double, double); ref(bool, bool); ref(long long, longlong); ref(unsigned long long, ulonglong); %inline %{ int ref_over(int a) { return a; } struct A { int v; A(int V) :v(V) {} }; int ref_over(const A& a) { return a.v; } %} swig-3.0.2/Examples/test-suite/inherit_target_language.i0000664000175000017500000000511612343605122023257 0ustar williamwilliam// Test using a target language specified base class, primarily for Java/C#/D and possibly other single inheritance languages // Note the multiple inheritance warnings don't appear because of the two techniques used in here: typemaps and %ignore %module inherit_target_language #if defined(SWIGJAVA) # define csbase javabase #elif defined(SWIGD) # define csbase dbase #endif %pragma(csharp) moduleimports=%{ using System; using System.Runtime.InteropServices; public class TargetLanguageBase { public virtual void targetLanguageBaseMethod() {} }; public class TargetLanguageBase2 { public virtual void targetLanguageBase2Method() {} }; %} %pragma(java) moduleimports=%{ class TargetLanguageBase { public void targetLanguageBaseMethod() {} }; class TargetLanguageBase2 { public void targetLanguageBase2Method() {} }; %} %pragma(d) globalproxyimports=%{ private class TargetLanguageBase { public void targetLanguageBaseMethod() {} }; private class TargetLanguageBase2 { public void targetLanguageBase2Method() {} }; %} %typemap(csbase) SWIGTYPE "TargetLanguageBase" // Two ways to replace a C++ base with a completely different target language base %ignore Base1; // another way to use the target language base %typemap(csbase, replace="1") Derived2 "TargetLanguageBase" %inline %{ struct Base1 { virtual ~Base1() {} }; struct Base2 { virtual ~Base2() {} }; struct Derived1 : Base1 {}; struct Derived2 : Base2 {}; %} // Multiple inheritance %ignore MBase1a; %ignore MBase1b; %typemap(csbase, replace="1") MultipleDerived2 "TargetLanguageBase" %inline %{ struct MBase1a { virtual ~MBase1a() {} virtual void a() {} }; struct MBase1b { virtual ~MBase1b() {} virtual void b() {} }; struct MBase2a { virtual ~MBase2a() {} virtual void c() {} }; struct MBase2b { virtual ~MBase2b() {} virtual void d() {} }; struct MultipleDerived1 : MBase1a, MBase1b {}; struct MultipleDerived2 : MBase1a, MBase2b {}; %} %ignore MBase3a; %ignore MBase4b; %typemap(csbase) MultipleDerived3 "" %typemap(csbase) MultipleDerived4 "" %inline %{ struct MBase3a { virtual ~MBase3a() {} virtual void e() {} }; struct MBase3b { virtual ~MBase3b() {} virtual void f() {} }; struct MBase4a { virtual ~MBase4a() {} virtual void g() {} }; struct MBase4b { virtual ~MBase4b() {} virtual void h() {} }; struct MultipleDerived3 : MBase3a, MBase3b {}; struct MultipleDerived4 : MBase4a, MBase4b {}; %} // Replace a C++ base, but only classes that do not have a C++ base %typemap(csbase, notderived="1") SWIGTYPE "TargetLanguageBase2" %inline %{ struct BaseX { virtual ~BaseX() {}; void basex() {} }; struct DerivedX : BaseX { void derivedx() {} }; %} swig-3.0.2/Examples/test-suite/return_const_value.i0000664000175000017500000000160112343605122022320 0ustar williamwilliam/* This test a return by value constant SWIGTYPE. It was reported in bug 899332 by Jermey Brown (jhbrown94) */ %module return_const_value %ignore Foo_ptr::operator=(const Foo_ptr&); %inline %{ class Foo { public: int _val; Foo(int x): _val(x) {} int getVal() const { return _val; } }; class Foo_ptr { Foo *_ptr; mutable bool _own; public: Foo_ptr(Foo *p, bool own = false): _ptr(p), _own(own) {} static Foo_ptr getPtr() { return Foo_ptr(new Foo(17), true); } static const Foo_ptr getConstPtr() { return Foo_ptr(new Foo(17), true); } const Foo *operator->() { return _ptr; } Foo_ptr(const Foo_ptr& f) : _ptr(f._ptr), _own(f._own) { f._own = 0; } Foo_ptr& operator=(const Foo_ptr& f) { _ptr = f._ptr; _own = f._own; f._own = 0; return *this; } ~Foo_ptr() { if(_own) delete _ptr; } }; %} swig-3.0.2/Examples/test-suite/cpp11_variadic_templates.i0000664000175000017500000000330312343605122023244 0ustar williamwilliam/* This testcase checks whether SWIG correctly parses and generates the code for variadic templates. This covers the variadic number of arguments inside the template brackets, new functions sizeof... and multiple inheritance using variadic number of classes. */ %module cpp11_variadic_templates %warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiArgs; %warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) SizeOf; %warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiInherit; //////////////////////// // Variadic templates // //////////////////////// %inline %{ #include #include #include template class MultiArgs { }; class MultiArgs, std::map>> multiArgs; %} // TODO %template (MultiArgs1) MultiArgs, std::map>>; //////////////////////// // Variadic sizeof... // //////////////////////// %inline %{ template struct SizeOf { static const int size = sizeof...(Args); }; %} %template (SizeOf1) SizeOf; ////////////////////////// // Variadic inheritance // ////////////////////////// %inline %{ class A { public: A() { a = 100; } virtual ~A() {} int a; }; class B { public: B() { b = 200; } virtual ~B() {} int b; }; template class MultiInherit : public BaseClasses... { public: MultiInherit(BaseClasses&... baseClasses) : BaseClasses(baseClasses)... {} int InstanceMethod() { return 123; } static int StaticMethod() { return 456; } }; %} // TODO //%template (MultiInherit0) MultiInherit<>; %template (MultiInherit1) MultiInherit; // TODO %template (MultiInherit2) MultiInherit; swig-3.0.2/Examples/test-suite/java_pragmas.i0000664000175000017500000000252112343605122021034 0ustar williamwilliam // Test case uses all the Java pragmas which are for tailoring the generated JNI class and Java module class. %module java_pragmas %pragma(java) jniclassimports=%{ import java.lang.*; // For Exception %} %pragma(java) jniclassclassmodifiers="public class" %pragma(java) jniclassbase="Exception" %pragma(java) jniclassinterfaces="Cloneable" %pragma(java) jniclasscode=%{ // jniclasscode pragma code: Static block so that the JNI class loads the C++ DLL/shared object when the class is loaded static { try { System.loadLibrary("java_pragmas"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static final long serialVersionUID = 0x52151000; // Suppress ecj warning %} %pragma(java) moduleimports=%{ import java.io.*; // For Serializable %} %pragma(java) moduleclassmodifiers="public final class" %pragma(java) modulebase="Object" %pragma(java) moduleinterfaces="Serializable" %pragma(java) modulecode=%{ public static final long serialVersionUID = 0x52151001; // Suppress ecj warning public static void added_function(String s) { // Added function } %} %inline %{ int *get_int_pointer() { static int number = 10; return &number; } %} swig-3.0.2/Examples/test-suite/inctest.i0000664000175000017500000000120612343605122020051 0ustar williamwilliam%module inctest // // This test fails if swig is not able to include // the following two files: // // 'testdir/inctest/subdir1/hello.i' // 'testdir/inctest/subdir2/hello.i' // // since they have the same basename 'hello', swig is only // including one. This is not right, it must include both, // as the well known compilers do. // // Also repeats the test for the import directive in subdirectories %include "testdir/inctest/test.i" // Bug #1162194 %inline %{ typedef struct { #include "inctest.h" } MY_TYPES; %} %{ typedef struct { #include "inctest.h" } MY_THINGS; %} typedef struct { %include "inctest.h" } MY_THINGS; swig-3.0.2/Examples/test-suite/director_protected_overloaded.i0000664000175000017500000000076012343605122024474 0ustar williamwilliam%module(directors="1",dirprot="1") director_protected_overloaded %director IDataObserver; %director DerivedDataObserver; // protected overloaded methods %inline %{ class IDataObserver { public: virtual ~IDataObserver(){} protected: virtual void notoverloaded() = 0; virtual void isoverloaded() = 0; virtual void isoverloaded(int i) = 0; virtual void isoverloaded(int i, double d) = 0; }; class DerivedDataObserver : public IDataObserver { }; %} swig-3.0.2/Examples/test-suite/using_directive_and_declaration.i0000664000175000017500000000341712343605122024760 0ustar williamwilliam%module using_directive_and_declaration // Test using directives combined with using declarations %inline %{ namespace Outer1 { namespace Space1 { class Thing1 {}; } } using namespace Outer1::Space1; using Outer1::Space1::Thing1; void useit1(Thing1 t) {} namespace Outer2 { namespace Space2 { class Thing2 {}; } } using namespace Outer2; using Space2::Thing2; void useit2(Thing2 t) {} namespace Outer3 { namespace Space3 { namespace Middle3 { class Thing3 {}; } } } using namespace Outer3; using namespace Space3; using Middle3::Thing3; void useit3(Thing3 t) {} namespace Outer4 { namespace Space4 { namespace Middle4 { class Thing4 {}; } } } using namespace Outer4::Space4; using Middle4::Thing4; void useit4(Thing4 t) {} namespace Outer5 { namespace Space5 { namespace Middle5 { namespace More5 { class Thing5 {}; } } } } using namespace ::Outer5::Space5; using namespace Middle5; using More5::Thing5; void useit5(Thing5 t) {} %} // Same symbol name in different namespaces %rename(Thing6a) Outer6::Space6a::Thing6; %inline %{ namespace Outer6 { namespace Space6a { struct Thing6 { void a() {} }; } namespace Space6b { struct Thing6 { void b() {} }; } } using namespace Outer6::Space6b; void useit6(Outer6::Space6a::Thing6 ta, Thing6 tb) {} namespace Outer7 { namespace Space7 { namespace Middle7 { class Thing7; } } } using namespace Outer7::Space7; class Middle7::Thing7 {}; using Middle7::Thing7; void useit7(Thing7 t) {} void useit7a(Outer7::Space7::Middle7::Thing7 t) {} void useit7b(::Outer7::Space7::Middle7::Thing7 t) {} void useit7c(Middle7::Thing7 t) {} namespace Outer7 { namespace Space7 { void useit7d(Middle7::Thing7 t) {} } } %} swig-3.0.2/Examples/test-suite/director_exception.i0000664000175000017500000000461712343605122022302 0ustar williamwilliam%module(directors="1") director_exception %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif #include // define dummy director exception classes to prevent spurious errors // in target languages that do not support directors. #ifndef SWIG_DIRECTORS namespace Swig { class DirectorException {}; class DirectorMethodException: public Swig::DirectorException {}; } #ifndef SWIG_fail #define SWIG_fail #endif #endif /* !SWIG_DIRECTORS */ %} %include "std_string.i" #ifdef SWIGPYTHON %feature("director:except") { if ($error != NULL) { throw Swig::DirectorMethodException(); } } %exception { try { $action } catch (Swig::DirectorException &) { SWIG_fail; } } #endif #ifdef SWIGJAVA // Default for director exception warns about unmapped exceptions now in java // Suppress warnings for this older test // %warnfilter(476) Bar; // Default for java is to throw Swig::DirectorException if no // direct:except feature. Since methods below have exception specification // cannot throw director exception. // Change back to old 2.0 default behavior %feature("director:except") { jthrowable $error = jenv->ExceptionOccurred(); if ($error) { // Dont clear exception, still be active when return to java execution // Essentially ignore exception occurred -- old behavior. return $null; } } #endif #ifdef SWIGRUBY %feature("director:except") { throw Swig::DirectorMethodException($error); } %exception { try { $action } catch (Swig::DirectorException &e) { rb_exc_raise(e.getError()); } } #endif %feature("director") Foo; %inline { class Foo { public: virtual ~Foo() {} virtual std::string ping() { return "Foo::ping()"; } virtual std::string pong(int val=3) { return "Foo::pong();" + ping(); } }; Foo *launder(Foo *f) { return f; } } %{ struct Unknown1 { }; struct Unknown2 { }; %} %feature("director") Bar; %inline %{ struct Exception1 { }; struct Exception2 { }; class Base { public: virtual ~Base() throw () {} }; class Bar : public Base { public: virtual std::string ping() throw (Exception1, Exception2&) { return "Bar::ping()"; } virtual std::string pong() throw (Unknown1, int, Unknown2&) { return "Bar::pong();" + ping(); } virtual std::string pang() throw () { return "Bar::pang()"; } }; %} swig-3.0.2/Examples/test-suite/name_warnings.i0000664000175000017500000000245312343605122021235 0ustar williamwilliam%module name_warnings /* This test should produce no warnings at all. It just show the cases where swig was showing unintended warnings before. Right now the test includes some cases for python, java and csharp. */ /* activate all the name warnings */ %warnfilter(+SWIGWARN_PARSE_KEYWORD,+SWIGWARN_PARSE_BUILTIN_NAME,-SWIGWARN_TYPE_ABSTRACT); %{ #ifdef max #undef max #endif %} class string; // csharp keyword namespace std { template class complex; } %inline { class complex; // python built-in typedef complex None; // python built-in struct A { typedef complex None; #ifndef SWIGPHP // clone() *is* an invalid method name in PHP. A* clone(int) { return NULL; } #endif virtual ~A() {} #ifndef SWIGGO // func is a keyword in Go. virtual int func() = 0; #endif private: typedef complex False; }; template T max (T a, T b) { // python 'max' built-in return a > b ? a : b; } struct B : A { B() {} }; } %template(max_i) max; %inline { /* silently rename the parameter names in csharp/java */ #ifdef SWIGR double foo(double inparam, double out) { return 1.0; } #else double foo(double abstract, double out) { return 1.0; } #endif double bar(double native, bool boolean) { return 1.0; } } swig-3.0.2/Examples/test-suite/lua_no_module_global.i0000664000175000017500000000015012343605122022537 0ustar williamwilliam%module lua_no_module_global %{ const char *hi_mom() { return "hi mom!"; } %} const char *hi_mom(); swig-3.0.2/Examples/test-suite/smart_pointer_namespace2.i0000664000175000017500000000201412343605122023362 0ustar williamwilliam %module smart_pointer_namespace2 %{ namespace one { template class Ptr { T* p; public: Ptr(T *tp) : p(tp) {} ~Ptr() { }; T* operator->() { return p; } }; } namespace one { class Obj1 { public: Obj1() {} void donothing() {} }; typedef one::Ptr Obj1_ptr; } namespace two { class Obj2 { public: Obj2() {} void donothing() {} }; typedef one::Ptr Obj2_ptr; } %} namespace one { template class Ptr { T* p; public: Ptr(T *tp) : p(tp) {} ~Ptr() { }; T* operator->() { return p; } }; } %define PTR_DEF(o) typedef one::Ptr o ## _ptr; %template(o ## _ptr) one::Ptr; %enddef namespace one { class Obj1 { public: Obj1() {} void donothing() {} }; PTR_DEF(Obj1) } namespace two { class Obj2 { public: Obj2() {} void donothing() {} }; PTR_DEF(Obj2) } swig-3.0.2/Examples/test-suite/simple_array.i0000664000175000017500000000102612343605122021067 0ustar williamwilliam%module simple_array extern int x[10]; extern double y[7]; %inline %{ struct BarArray { int i; double d; }; extern struct BarArray bars[2]; int x[10]; double y[7]; struct BarArray bars[2]; void initArray() { int i, n; n = sizeof(x)/sizeof(x[0]); for(i = 0; i < n; i++) x[i] = i; n = sizeof(y)/sizeof(y[0]); for(i = 0; i < n; i++) y[i] = ((double) i)/ ((double) n); n = sizeof(bars)/sizeof(bars[0]); for(i = 0; i < n; i++) { bars[i].i = x[i+2]; bars[i].d = y[i+2]; } return; } %} swig-3.0.2/Examples/test-suite/li_std_combinations.i0000664000175000017500000000151512343605122022426 0ustar williamwilliam%module li_std_combinations %include %include %include %template(VectorInt) std::vector; %template(VectorString) std::vector; %template(PairIntString) std::pair; %template(VectorPairIntString) std::vector< std::pair >; %template(PairIntVectorString) std::pair< int, std::vector >; %template(VectorVectorString) std::vector< std::vector >; %template(PairIntPairIntString) std::pair< int, std::pair >; #if defined(SWIGCSHARP) || defined(SWIGD) // Checks macro containing a type with a comma SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >) #endif %template(PairDoubleString) std::pair< double, std::string >; %template(VectorPairDoubleString) std::vector< std::pair >; swig-3.0.2/Examples/test-suite/overload_bool.i0000664000175000017500000000127512343605122021234 0ustar williamwilliam%module overload_bool %inline %{ const char* overloaded(bool value) { return "bool"; } const char* overloaded(int value) { return "int"; } const char* overloaded(const char *value) { return "string"; } const char* boolfunction(bool value) { return value ? "true" : "false"; } const char* intfunction(int value) { return "int"; } // Const references const char* overloaded_ref(bool const& value) { return "bool"; } const char* overloaded_ref(int const& value) { return "int"; } const char* overloaded_ref(const char *value) { return "string"; } const char* boolfunction_ref(bool const& value) { return value ? "true" : "false"; } const char* intfunction_ref(int const& value) { return "int"; } %} swig-3.0.2/Examples/test-suite/extern_declaration.i0000664000175000017500000000151712343605122022257 0ustar williamwilliam%module extern_declaration // Test different calling conventions on Windows. Old versions of SWIG generated // an incorrect extern declaration that wouldn't compile with Windows compilers. #define SWIGEXPORT #define SWIGSTDCALL #define MYDLLIMPORT %{ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # define MYDLLIMPORT __declspec(dllimport) #else # define MYDLLIMPORT #endif %} MYDLLIMPORT extern int externimport(int i); SWIGEXPORT extern int externexport(int); extern int SWIGSTDCALL externstdcall(int); %{ /* externimport ought to be using MYDLLIMPORT and compiled into another dll, but that is a bit tricky to do in the test framework */ SWIGEXPORT extern int externimport(int i) { return i; } SWIGEXPORT extern int externexport(int i) { return i; } extern int SWIGSTDCALL externstdcall(int i) { return i; } %} swig-3.0.2/Examples/test-suite/import_stl_b.i0000664000175000017500000000032412343605122021075 0ustar williamwilliam%module import_stl_b %import "import_stl_a.i" %inline %{ #include std::vector process_vector(const std::vector& v) { std::vector v_new = v; v_new.push_back(4); return v_new; } %} swig-3.0.2/Examples/test-suite/template_extend_overload_2.i0000664000175000017500000000235112343605122023700 0ustar williamwilliam%module template_extend_overload_2 #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) A; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) AT; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) BT; #endif %inline %{ struct A { A() { } A(int) { } int hi() { return 0; } }; template struct AT { AT() { } AT(int) { } int hi() { return 0; } }; template struct BT { BT() { } BT(int) { } int hi() { return 0; } }; %} %extend A { // // this works // int hi(int) { return 0; } A(double i) { A* a = new A(); return a; } } %template(AT_double) AT; %extend AT { // // this doesn't work // int hi(int) { return 1; } AT(double i) { AT* a = new AT(); return a; } } %extend BT { // // this doesn't work either // int hi(int) { return 1; } BT(double i) { BT* a = new BT(); return a; } } %template(BT_double) BT; swig-3.0.2/Examples/test-suite/li_typemaps_apply.i0000664000175000017500000000315512343605122022140 0ustar williamwilliam%module li_typemaps_apply // Test %apply to global primitive type references/pointers to make sure the return types are still okay... mainly for the strongly typed languages. %include "typemaps.i" #if !defined(SWIGJAVA) // Needs asymmetric type marshalling support for this testcase to work %define TMAPS(PRIMTYPE, NAME) %apply PRIMTYPE *INPUT { PRIMTYPE * } %apply PRIMTYPE &INPUT { PRIMTYPE & } %inline %{ PRIMTYPE *input_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; return &stat; } PRIMTYPE &input_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; return stat; } %} %apply PRIMTYPE *OUTPUT { PRIMTYPE * } %apply PRIMTYPE &OUTPUT { PRIMTYPE & } %inline %{ PRIMTYPE *output_ptr_##NAME(PRIMTYPE x, PRIMTYPE *v) { static PRIMTYPE stat; stat = x; *v = x; return &stat; } PRIMTYPE &output_ref_##NAME(PRIMTYPE x, PRIMTYPE &v) { static PRIMTYPE stat; stat = x; v = x; return stat; } %} %apply PRIMTYPE *INOUT { PRIMTYPE * } %apply PRIMTYPE &INOUT { PRIMTYPE & } %inline %{ PRIMTYPE *inout_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; *v = *v; return &stat; } PRIMTYPE &inout_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; v = v; return stat; } %} %enddef TMAPS(bool, bool) TMAPS(int, int) TMAPS(short, short) TMAPS(long, long) TMAPS(unsigned int, uint) TMAPS(unsigned short, ushort) TMAPS(unsigned long, ulong) TMAPS(unsigned char, uchar) TMAPS(signed char, schar) TMAPS(float, float) TMAPS(double, double) TMAPS(long long, longlong) TMAPS(unsigned long long, ulonglong) #endif swig-3.0.2/Examples/test-suite/operator_overload.i0000664000175000017500000002272412343605122022136 0ustar williamwilliam/* File : operator_overload.i */ /* This is a test of all the possible operator overloads see bottom for a set of possible tests */ %module operator_overload #if defined(SWIGPYTHON) %warnfilter(SWIGWARN_IGNORE_OPERATOR_EQ, SWIGWARN_IGNORE_OPERATOR_INDEX, SWIGWARN_IGNORE_OPERATOR_PLUSPLUS, SWIGWARN_IGNORE_OPERATOR_MINUSMINUS, SWIGWARN_IGNORE_OPERATOR_LAND, SWIGWARN_IGNORE_OPERATOR_LOR); #endif #if !defined(SWIGLUA) && !defined(SWIGR) %rename(Equal) operator =; %rename(PlusEqual) operator +=; %rename(MinusEqual) operator -=; %rename(MultiplyEqual) operator *=; %rename(DivideEqual) operator /=; %rename(PercentEqual) operator %=; %rename(Plus) operator +; %rename(Minus) operator -; %rename(Multiply) operator *; %rename(Divide) operator /; %rename(Percent) operator %; %rename(Not) operator !; %rename(IndexIntoConst) operator[](unsigned idx) const; %rename(IndexInto) operator[](unsigned idx); %rename(Functor) operator (); %rename(EqualEqual) operator ==; %rename(NotEqual) operator !=; %rename(LessThan) operator <; %rename(LessThanEqual) operator <=; %rename(GreaterThan) operator >; %rename(GreaterThanEqual) operator >=; %rename(And) operator &&; %rename(Or) operator ||; %rename(PlusPlusPrefix) operator++(); %rename(PlusPlusPostfix) operator++(int); %rename(MinusMinusPrefix) operator--(); %rename(MinusMinusPostfix) operator--(int); #endif %rename(IndexInto) *::operator[](unsigned idx); // some languages have a %rename *::operator[] already in place, which seems to takes precedence over the above %rename operator[]. #ifdef SWIGCSHARP %csmethodmodifiers operator++() "protected"; %csmethodmodifiers operator++(int) "private"; %csmethodmodifiers operator--() "private"; %csmethodmodifiers operator--(int) "protected"; %typemap(cscode) Op %{ public static Op operator++(Op op) { // Unlike C++, operator++ must not modify the parameter and both prefix and postfix operations call this method Op newOp = new Op(op.i); newOp.PlusPlusPostfix(0); return newOp; } public static Op operator--(Op op) { // Unlike C++, operator-- must not modify the parameter and both prefix and postfix operations call this method Op newOp = new Op(op.i); newOp.MinusMinusPrefix(); return newOp; } %} #endif #ifdef SWIGPHP %rename(AndOperator) operator &&; %rename(OrOperator) operator ||; #endif #ifdef SWIG_ALLEGRO_CL %{ #include %} #endif #ifdef SWIGD // Due to the way operator overloading is implemented in D1 and D2, the prefix // increment/decrement operators (D1) resp. the postfix ones (D2) are ignored. %warnfilter(SWIGWARN_IGNORE_OPERATOR_PLUSPLUS, SWIGWARN_IGNORE_OPERATOR_MINUSMINUS); #endif %rename(IntCast) operator int(); %rename(DoubleCast) operator double(); %inline %{ #if defined(_MSC_VER) #include /* for named logical operator, eg 'operator or' */ #endif #include class Op { public: int i; Op(int a=0) : i(a) {} Op(const Op& o) : i(o.i) {} virtual ~Op() {} friend Op operator &&(const Op& a,const Op& b){return Op(a.i&&b.i);} friend Op operator or(const Op& a,const Op& b){return Op(a.i||b.i);} Op &operator=(const Op& o) { i=o.i; return *this; } // +=,-=... are member fns void operator+=(const Op& o){ i+=o.i;} void operator-=(const Op& o){ i-=o.i;} void operator*=(const Op& o){ i*=o.i;} void operator/=(const Op& o){ i/=o.i;} void operator%=(const Op& o){ i%=o.i;} // the +,-,*,... are friends // (just to make life harder) friend Op operator+(const Op& a,const Op& b){return Op(a.i+b.i);} friend Op operator-(const Op& a,const Op& b); friend Op operator*(const Op& a,const Op& b){return Op(a.i*b.i);} friend Op operator/(const Op& a,const Op& b){return Op(a.i/b.i);} friend Op operator%(const Op& a,const Op& b){return Op(a.i%b.i);} // unary operators Op operator-() const {return Op(-i);} bool operator !() const {return !(i);} // overloading the [] operator // need 2 versions: get & set // note: C++ can be a little mixed up upon which version it calls // most of the time it calls the second version int operator[](unsigned idx)const { if (idx==0) return i; return 0;} int& operator[](unsigned idx) { if (idx==0) return i; static int j;j=0; return j;} // overloading the () operator // this can have many parameters so we will test this int operator()(int a=0){return i+a;} int operator()(int a,int b){return i+a+b;} // increment/decrement operators Op& operator++() {++i; return *this;} // prefix ++ Op operator++(int) {Op o = *this; ++(*this); return o;} // postfix ++ Op& operator--() {--i; return *this;} // prefix -- Op operator--(int) {Op o = *this; --(*this); return o;} // postfix -- // TODO: <<,<<= // cast operators operator double() { return i; } virtual operator int() { return i; } // This method just checks that the operators are implemented correctly static void sanity_check(); }; // just to complicate matters // we have a couple of non class operators inline bool operator==(const Op& a,const Op& b){return a.i==b.i;} inline bool operator!=(const Op& a,const Op& b){return a.i!=b.i;} inline bool operator< (const Op& a,const Op& b){return a.i (const Op& a,const Op& b){return a.i>b.i;} inline bool operator>=(const Op& a,const Op& b){return a.i>=b.i;} %} %{ // This one is not declared inline as VC++7.1 gets mixed up with the unary operator- Op operator-(const Op& a,const Op& b){return Op(a.i-b.i);} %} // in order to wrapper this correctly // we need to extend the class // to make the friends & non members part of the class %extend Op{ Op operator &&(const Op& b){return Op($self->i&&b.i);} Op operator or(const Op& b){return Op($self->i||b.i);} Op operator+(const Op& b){return Op($self->i+b.i);} Op operator-(const Op& b){return Op($self->i-b.i);} Op operator*(const Op& b){return Op($self->i*b.i);} Op operator/(const Op& b){return Op($self->i/b.i);} Op operator%(const Op& b){return Op($self->i%b.i);} bool operator==(const Op& b){return $self->i==b.i;} bool operator!=(const Op& b){return $self->i!=b.i;} bool operator< (const Op& b){return $self->ii<=b.i;} bool operator> (const Op& b){return $self->i>b.i;} bool operator>=(const Op& b){return $self->i>=b.i;} // subtraction with reversed arguments Op __rsub__(const int b){return Op(b - $self->i);} // we also add the __str__() fn to the class // this allows it to be converted to a string (so it can be printed) const char* __str__() { static char buffer[255]; sprintf(buffer,"Op(%d)",$self->i); return buffer; } // to get the [] operator working correctly we need to extend with two function // __getitem__ & __setitem__ int __getitem__(unsigned i) { return (*$self)[i]; } void __setitem__(unsigned i,int v) { (*$self)[i]=v; } } /* Suggested list of operator overloads (mainly from python) Operators overloaded with their C++ equivalent __add__,__sub__,__mul__,__div__,__mod__ +,-,*,/,% __iadd__,__isub__,__imul__,__idiv__,__imod__ +=,-=,*=,/=,%= __eq__,__ne__,__lt__,__le__,__gt__,__ge__ ==,!=,<,<=,>,>= __not__,__neg__ unary !, unary - __and__,__or__,__xor__ logical and,logical or,logical xor __rshift__,__lshift__ >>,<< __getitem__,__setitem__ for operator[] Operators overloaded without C++ equivalents __pow__ for power operator __str__ converts object to a string (should return a const char*) __concat__ for concatenation (if language supports) */ %inline %{ class OpDerived : public Op { public: OpDerived(int a=0) : Op(a) {} // overloaded virtual operator int() { return i*2; } }; %} %{ #include void Op::sanity_check() { // test routine: Op a; Op b=5; Op c=b; // copy construct Op d=2; Op dd=d; // assignment operator // test equality assert(a!=b); assert(b==c); assert(a!=d); assert(d==dd); // test < assert(a=c); assert(b>d); assert(b>=d); // test += Op e=3; e+=d; assert(e==b); e-=c; assert(e==a); e=Op(1); e*=b; assert(e==c); e/=d; assert(e==d); e%=c; assert(e==d); // test + Op f(1),g(1); assert(f+g==Op(2)); assert(f-g==Op(0)); assert(f*g==Op(1)); assert(f/g==Op(1)); assert(f%g==Op(0)); // test unary operators assert(!a==true); assert(!b==false); assert(-a==a); assert(-b==Op(-5)); // test [] Op h=3; assert(h[0]==3); assert(h[1]==0); h[0]=2; // set assert(h[0]==2); h[1]=2; // ignored assert(h[0]==2); assert(h[1]==0); // test () Op i=3; assert(i()==3); assert(i(1)==4); assert(i(1,2)==6); // plus add some code to check the __str__ fn //assert(str(Op(1))=="Op(1)"); //assert(str(Op(-3))=="Op(-3)"); // test ++ and -- Op j(100); int original = j.i; { Op newOp = j++; int newInt = original++; assert(j.i == original); assert(newOp.i == newInt); } { Op newOp = j--; int newInt = original--; assert(j.i == original); assert(newOp.i == newInt); } { Op newOp = ++j; int newInt = ++original; assert(j.i == original); assert(newOp.i == newInt); } { Op newOp = --j; int newInt = --original; assert(j.i == original); assert(newOp.i == newInt); } // cast operators Op k=3; int check_k = k; assert (check_k == 3); Op l=4; double check_l = l; assert (check_l == 4); } %} swig-3.0.2/Examples/test-suite/bools.i0000664000175000017500000000227112343605122017521 0ustar williamwilliam// bool typemaps check %module bools %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) constbool; /* Ruby, wrong class name */ // bool constant %constant bool constbool=false; %inline %{ // bool variables bool bool1 = true; bool bool2 = false; bool* pbool = &bool1; bool& rbool = bool2; const bool* const_pbool = pbool; const bool& const_rbool = rbool; static int eax() { return 1024; // NOTE: any number > 255 should do } // bool functions bool bo(bool b) { return b; } bool& rbo(bool& b) { return b; } bool* pbo(bool* b) { return b; } const bool& const_rbo(const bool& b) { return b; } const bool* const_pbo(const bool* b) { return b; } // helper function bool value(bool* b) { return *b; } struct BoolStructure { bool m_bool1; bool m_bool2; bool* m_pbool; bool& m_rbool; const bool* m_const_pbool; const bool& m_const_rbool; BoolStructure() : m_bool1(true), m_bool2(false), m_pbool(&m_bool1), m_rbool(m_bool2), m_const_pbool(m_pbool), m_const_rbool(m_rbool) {} private: BoolStructure& operator=(const BoolStructure &); }; %} swig-3.0.2/Examples/test-suite/extend.i0000664000175000017500000000154412343605122017674 0ustar williamwilliam%module extend %extend Base { ~Base() { delete $self; } static int zeroVal() { return 0; } virtual int currentValue() { return $self->value; } int extendmethod(int v) { int ret = $self->method(v); return ret * 2; } }; %inline %{ struct Base { Base(int v = 0) : value(v) {} int value; virtual int method(int v) { return v; } }; struct Derived : Base { double actualval; }; %} %{ double extendval = 0; double Derived_extendval_get(Derived *self) { return self->actualval * 100; } void Derived_extendval_set(Derived *self, double d) { self->actualval = d/100; } %} %extend Derived { Derived(int v) { Derived *$self = new Derived(); $self->value = v*2; return $self; } virtual int method(int v) { int ret = $self->Base::method(v); return ret * 2; } double extendval; } swig-3.0.2/Examples/test-suite/packageoption_a.i0000664000175000017500000000026512343605122021530 0ustar williamwilliam%module(package="CommonPackage") "packageoption_a"; %inline %{ class A { public: int testInt() { return 2;} }; %} %{ #include "packageoption.h" %} %include "packageoption.h" swig-3.0.2/Examples/test-suite/director_string.i0000664000175000017500000000177312343605122021612 0ustar williamwilliam%module(directors="1") director_string; %include #ifndef SWIG_STL_UNIMPL %include std_vector.i %include std_string.i // Using thread unsafe wrapping %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) A; %{ #include #include %} %feature("director") A; %inline %{ struct A { A(const std::string& first) : m_strings(1, first) {} virtual ~A() {} virtual const std::string& get_first() const { return get(0); } virtual const std::string& get(int n) const { return m_strings[n]; } virtual const std::string& call_get_first() const { return get_first(); } virtual const std::string& call_get(int n) const { return get(n); } virtual int string_length(const std::string & s) const { return (int)s.size(); } std::vector m_strings; virtual void process_text(const char *text) { } void call_process_func() { process_text("hello"); } }; %} %template(StringVector) std::vector; #endif swig-3.0.2/Examples/test-suite/li_std_carray.i0000664000175000017500000000023012343605122021213 0ustar williamwilliam%module li_std_carray %include %template(Vector3) std::carray; %template(Matrix3) std::carray, 3>; swig-3.0.2/Examples/test-suite/nested_private.i0000664000175000017500000000113512343605122021415 0ustar williamwilliam%module nested_private // segfault due to private nested class usage %inline %{ #include class MotorCar { struct DesignOpinion { std::string reason; }; public: struct WindScreen { WindScreen(bool opaque) : opaque(opaque) {} DesignOpinion Opinion(); private: bool opaque; }; std::string WindScreenOpinion() { return MotorCar::WindScreen(true).Opinion().reason; } }; MotorCar::DesignOpinion MotorCar::WindScreen::Opinion() { DesignOpinion opinion; opinion.reason = !opaque ? "great design" : "you can't see out the windscreen"; return opinion; } %} swig-3.0.2/Examples/test-suite/template_opaque.i0000664000175000017500000000130612343605122021566 0ustar williamwilliam%module template_opaque %include "std_vector.i" %{ namespace A { struct OpaqueStruct { int x; }; } enum Hello { hi, hello }; %} %inline { namespace A { struct OpaqueStruct; typedef struct OpaqueStruct OpaqueType; typedef enum Hello Hi; typedef std::vector OpaqueVectorType; typedef std::vector OpaqueVectorEnum; void FillVector(OpaqueVectorType& v) { for (size_t i = 0; i < v.size(); ++i) { v[i] = OpaqueStruct(); } } void FillVector(const OpaqueVectorEnum& v) { } } } #ifndef SWIGCSHARP // C# vector typemaps only ready for simple cases right now %template(OpaqueVectorType) std::vector; #endif swig-3.0.2/Examples/test-suite/arrays_global.i0000664000175000017500000000337112343605122021226 0ustar williamwilliam/* This test case tests that various types of arrays are working. */ %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK,SWIGWARN_TYPEMAP_VARIN_UNDEF); %module arrays_global %inline %{ #define ARRAY_LEN 2 typedef enum {One, Two, Three, Four, Five} finger; typedef struct { double double_field; } SimpleStruct; char array_c [ARRAY_LEN]; signed char array_sc[ARRAY_LEN]; unsigned char array_uc[ARRAY_LEN]; short array_s [ARRAY_LEN]; unsigned short array_us[ARRAY_LEN]; int array_i [ARRAY_LEN]; unsigned int array_ui[ARRAY_LEN]; long array_l [ARRAY_LEN]; unsigned long array_ul[ARRAY_LEN]; long long array_ll[ARRAY_LEN]; float array_f [ARRAY_LEN]; double array_d [ARRAY_LEN]; SimpleStruct array_struct[ARRAY_LEN]; SimpleStruct* array_structpointers[ARRAY_LEN]; int* array_ipointers [ARRAY_LEN]; finger array_enum[ARRAY_LEN]; finger* array_enumpointers[ARRAY_LEN]; const int array_const_i[ARRAY_LEN] = {10, 20}; %} %inline %{ const char BeginString_FIX44a[8] = "FIX.a.a"; char BeginString_FIX44b[8] = "FIX.b.b"; const char BeginString_FIX44c[] = "FIX.c.c"; char BeginString_FIX44d[] = "FIX.d.d"; const char* BeginString_FIX44e = "FIX.e.e"; const char* const BeginString_FIX44f = "FIX.f.f"; typedef char name[8]; typedef char namea[]; char* test_a(char hello[8], char hi[], const char chello[8], const char chi[]) { return hi; } char* test_b(name a, const namea b) { return a; } int test_a(int a) { return a; } int test_b(int a) { return a; } %} #ifdef __cplusplus %inline { struct Material { }; enum { Size = 32 }; const Material * chitMat[Size]; Material hitMat_val[Size]; Material *hitMat[Size]; } #endif swig-3.0.2/Examples/test-suite/smart_pointer_templatevariables.i0000664000175000017500000000211512343605122025052 0ustar williamwilliam%module smart_pointer_templatevariables %inline %{ template struct basic_string { int npos; }; template struct Ptr { Ptr(T *p = 0) : ptr(p) {} ~Ptr() { delete ptr; } T *operator->() const { return ptr; } private: T *ptr; }; template struct DiffImContainer { int id; // static members seem to be can of worms. Note that SWIG wraps them as non-static members. Why? // Note CHANGES entry 10/14/2003. Static const variables are not wrapped as constants but as a read only variable. Why? // static short xyz; // static const short constvar = 555; }; //template short DiffImContainer::xyz = 0; DiffImContainer* create(int id, short xyz) { DiffImContainer *d = new DiffImContainer(); d->id = id; // DiffImContainer::xyz = xyz; return d; } %} %template(BasicString) basic_string; %template(DiffImContainer_D) DiffImContainer; %template(DiffImContainerPtr_D) Ptr >; swig-3.0.2/Examples/test-suite/long_long.i0000664000175000017500000000237412343605122020365 0ustar williamwilliam/* This interface file tests whether SWIG handles the new ISO C long long types. */ %module long_long %warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst1; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst2; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst3; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst4; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst5; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst6; /* Ruby, wrong constant name */ %inline %{ void foo1(long long x) {} void foo2(long long int x) {} void foo3(signed long long int x) {} void foo4(unsigned long long int x) {} void foo5(signed long long x) {} void foo6(unsigned long long x) {} long long bar1() {return 0;} long long int bar2() {return 0;} signed long long int bar3() {return 0;} unsigned long long int bar4() {return 0;} signed long long bar5() {return 0;} unsigned long long bar6() {return 0;} long long ll; unsigned long long ull; %} %constant long long lconst1 = 1234567890LL; %constant unsigned long long lconst2 = 1234567890ULL; %constant lconst3 = 1234567LL; %constant lconst4 = 1234567ULL; #define lconst5 987654321LL #define lconst6 987654321ULL swig-3.0.2/Examples/test-suite/template_typedef_inherit.i0000664000175000017500000000260412343605122023460 0ustar williamwilliam%module template_typedef_inherit // Bug 3378145 %include std_string.i %inline %{ #include // for std::string typedef std::string String; namespace Type { template class TypedInterfaceObject {}; template class TypedCollectionInterfaceObject : public TypedInterfaceObject { public: typedef T ImplementationType; typedef typename ImplementationType::ElementType ImplementationElementType; /** Method add() appends an element to the collection */ void add(const ImplementationElementType & elt) {} }; template class PersistentCollection { public: typedef T ElementType; /** Method add() appends an element to the collection */ inline virtual void add(const T & elt) {} }; } %} %template(StringPersistentCollection) Type::PersistentCollection; %inline %{ namespace Type { class DescriptionImplementation : public PersistentCollection { public: typedef PersistentCollection::ElementType ElementType; DescriptionImplementation() {} }; } %} %template(DescriptionImplementationTypedInterfaceObject) Type::TypedInterfaceObject; %template(DescriptionImplementationTypedCollectionInterfaceObject) Type::TypedCollectionInterfaceObject; swig-3.0.2/Examples/test-suite/python_nondynamic.i0000664000175000017500000000142112343605122022137 0ustar williamwilliam%module python_nondynamic /* Use the %pythonnondynamic directuve to make the wrapped class a nondynamic one, ie, a python class that doesn't dynamically add new attributes. Hence, for the class %pythonnondynamic A; struct A { int a; int b; }; you will get: aa = A() aa.a = 1 # Ok aa.b = 1 # Ok aa.c = 3 # error Since "nondynamic" is a feature, if you use %pythonnondynamic; it will make all the wrapped class nondynamic ones. The implementation is based on the recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158 and works for modern (-modern) and plain python. */ %pythonnondynamic A; %pythondynamic C; %inline %{ struct A { int a; int b; }; struct C { int a; int b; }; %} swig-3.0.2/Examples/test-suite/namespace_nested.i0000664000175000017500000000256212343605122021704 0ustar williamwilliam%module namespace_nested %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hello::hi::hi0; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::hi1; /* Ruby, wrong class name */ %inline %{ namespace hello { namespace hi { struct hi0 { }; } template < class T1 > struct Hi : T1 { }; } %} namespace hello { %template(Hi_hi0) Hi; } %inline %{ namespace hello { // // This works // // typedef Hi Hi0; // // This doesn't work // typedef Hi Hi0; } namespace oss { template struct hi1 : T1 { }; typedef hello::Hi h0; } %} namespace oss { %template(hi1_hi0) hi1; } %rename(MyFoo) geos::algorithm::Foo; %inline { namespace geos { namespace algorithm { class Foo { }; } namespace planargraph { // geos.planargraph namespace algorithm { // geos.planargraph.algorithm class Bar { }; } namespace algorithm { // geos.planargraph.algorithm class Foo { public: typedef int size_type; }; } namespace algorithm { // geos.planargraph.algorithm class ConnectedSubgraphFinder : public Foo { public: ConnectedSubgraphFinder(size_type) { } }; } } } } swig-3.0.2/Examples/test-suite/typemap_template_parm_typedef.i0000664000175000017500000000251312343605122024513 0ustar williamwilliam%module typemap_template_parm_typedef %typemap(in) SWIGTYPE " _in_will_not_compile_ " %typemap(in) SWIGTYPE * " _in_will_not_compile_ " %typemap(out) SWIGTYPE " _out_will_not_compile_ " %typemap(out) SWIGTYPE * " _out_will_not_compile_ " %{ #include #include #include namespace jada { typedef unsigned int uint; void test_no_typedef(std::list bada) {} void test_typedef(std::vector bada) {} std::deque no_typedef_out() { std::deque x; return x; } } %} %typemap(in) std::list (std::list tmp) { $1 = tmp; } %typemap(in) std::vector (std::vector tmp) { $1 = tmp; } %typemap(out) std::list { } // The presennce of this 'out' typemap was hiding the std::vector 'in' typemap in swig-2.0.5 and swig-2.0.6 %typemap(out) std::vector { } // This typemap was not used for no_typedef_out in 2.0.4 and earlier #if defined(SWIGJAVA) || defined(SWIGCSHARP) %typemap(out) std::deque { $result = 0; } #else %typemap(out) std::deque { } #endif namespace jada { typedef unsigned int uint; void test_no_typedef(std::list bada); void test_typedef(std::vector bada); std::deque no_typedef_out(); } swig-3.0.2/Examples/test-suite/li_std_pair_lang_object.i0000664000175000017500000000022212343605122023215 0ustar williamwilliam%module li_std_pair_lang_object %include namespace std { %template(ValuePair) pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; } swig-3.0.2/Examples/test-suite/nested_directors.i0000664000175000017500000000135512343605122021745 0ustar williamwilliam%module(directors="1", allprotected="1") nested_directors %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) NN::Base::Nest; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) NN::Sub::IListener; %feature("director") Base; %feature("director") Sub; %feature("director") Base::Nest; %inline %{ namespace NN { class Base { public: virtual ~Base(){} class Nest { public: virtual ~Nest(){} virtual bool GetValue(){ return false; } }; protected: virtual bool DoNothing() = 0; }; class Sub : public Base { public: class IListener { }; public: virtual ~Sub(){} protected: void DoSomething(){} virtual bool GetValue() const { return true; } }; } %} swig-3.0.2/Examples/test-suite/ignore_parameter.i0000664000175000017500000000217512343605122021731 0ustar williamwilliam// Test for %typemap(ignore) %module ignore_parameter %typemap(in,numinputs=0) char* a "static const char* hi = \"hello\"; $1 = const_cast(hi);"; %typemap(in,numinputs=0) int bb "$1 = 101;"; %typemap(in,numinputs=0) double ccc "$1 = 8.8;"; %typemap(freearg) char* a ""; // ensure freearg is not generated (needed for Java at least) %inline %{ // global function tests char* jaguar(char* a, int b, double c) { return a; } int lotus(char* aa, int bb, double cc) { return bb; } double tvr(char* aaa, int bbb, double ccc) { return ccc; } int ferrari(int bb) { return bb; } // member function tests struct SportsCars { char* daimler(char* a, int b, double c) { return a; } int astonmartin(char* aa, int bb, double cc) { return bb; } double bugatti(char* aaa, int bbb, double ccc) { return ccc; } int lamborghini(int bb) { return bb; } }; // constructor tests struct MiniCooper { MiniCooper(char* a, int b, double c) {} }; struct MorrisMinor { MorrisMinor(char* aa, int bb, double cc) {} }; struct FordAnglia { FordAnglia(char* aaa, int bbb, double ccc) {} }; struct AustinAllegro { AustinAllegro(int bb) {} }; %} swig-3.0.2/Examples/test-suite/cffi/0000775000175000017500000000000012343605122017136 5ustar williamwilliamswig-3.0.2/Examples/test-suite/cffi/Makefile.in0000664000175000017500000000234512343605122021207 0ustar williamwilliam####################################################################### # Makefile for cffi test-suite ####################################################################### LANGUAGE = cffi CFFI = @CFFIBIN@ SCRIPTSUFFIX = _runme.lisp srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ include $(srcdir)/../common.mk # Overridden variables here # no C++ tests for now CPP_TEST_CASES = #C_TEST_CASES += # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.lisp appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra cffi code) %.clean: @exit 0 clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" cffi_clean swig-3.0.2/Examples/test-suite/typedef_funcptr.i0000664000175000017500000000103512343605122021601 0ustar williamwilliam// Tests typedef through function pointers %module typedef_funcptr %warnfilter(SWIGWARN_RUBY_WRONG_NAME) addf; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) subf; /* Ruby, wrong constant name */ %{ int addf(int x, int y) { return x+y; } int subf(int x, int y) { return x-y; } %} %inline %{ typedef int Integer; extern "C" Integer do_op(Integer x, Integer y, Integer (*op)(Integer, Integer)) { return (*op)(x,y); } %} %constant int addf(int x, int y); %constant Integer subf(Integer x, Integer y); swig-3.0.2/Examples/test-suite/template_typedef_class_template.i0000664000175000017500000000310412343605122025012 0ustar williamwilliam%module template_typedef_class_template %inline %{ namespace Standard { template struct Pair { T first; U second; }; } %} // previously these typemaps were erroneously being used as iterator was not correctly scoped in Multimap %typemap(out) Standard::Pair "_this_will_not_compile_iterator_" %typemap(out) Standard::Pair "_this_will_not_compile_const_iterator_" %{ namespace Standard { template class Multimap { public: typedef Key key_type; typedef T mapped_type; class iterator {}; class const_iterator {}; // test usage of a typedef of a nested class in a template Standard::Pair equal_range_1(const key_type& kt1) { return Standard::Pair(); } Standard::Pair equal_range_2(const key_type& kt2) const { return Standard::Pair(); } }; } %} namespace Standard { template class Multimap { public: typedef Key key_type; typedef T mapped_type; class iterator; class const_iterator; // test usage of a typedef of a nested class in a template Standard::Pair equal_range_1(const key_type& kt1) {} Standard::Pair equal_range_2(const key_type& kt2) const {} }; } %inline %{ struct A { int val; A(int v = 0): val(v) {} }; %} %template(PairA) Standard::Pair; %template(MultimapA) Standard::Multimap; swig-3.0.2/Examples/test-suite/inherit_same_name.i0000664000175000017500000000050412343605122022047 0ustar williamwilliam%module inherit_same_name %inline %{ struct Base { Base() : MethodOrVariable(0) {} virtual ~Base() {} protected: int MethodOrVariable; }; struct Derived : Base { virtual void MethodOrVariable() { Base::MethodOrVariable = 10; } }; struct Bottom : Derived { void MethodOrVariable() {} }; %} swig-3.0.2/Examples/test-suite/import_nomodule.h0000664000175000017500000000004412343605122021612 0ustar williamwilliamclass Foo { }; typedef int Integer; swig-3.0.2/Examples/test-suite/li_std_stream.i0000664000175000017500000000147112343605122021235 0ustar williamwilliam%module li_std_stream %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */ #endif %} %inline %{ struct A; %} %include %include %callback(1) A::bar; %inline %{ struct B { virtual ~B() { } }; struct A : B { void __add__(int a) { } void __add__(double a) { } static int bar(int a){ return a; } static int foo(int a, int (*pf)(int a)) { return pf(a); } std::ostream& __rlshift__(std::ostream& out) { out << "A class"; return out; } }; %} %extend std::basic_ostream{ std::basic_ostream& operator<<(const A& a) { *self << "A class"; return *self; } } swig-3.0.2/Examples/test-suite/mod_a.i0000664000175000017500000000027312343605122017462 0ustar williamwilliam%module mod_a %{ #include "mod.h" %} class C; class A { public: A() {} C* GetC() { return NULL; } void DoSomething(A* a) {} }; class B : public A { public: B(); }; swig-3.0.2/Examples/test-suite/template_typedef_typedef.i0000664000175000017500000000155712343605122023464 0ustar williamwilliam%module template_typedef_typedef // Github issue #50 // The Object2::getBlabla2 and Object::getBlabla1 functions were not resolving to the correct template types %inline%{ class Factory; class Base { public: typedef Factory ABCD; }; namespace TT{ template class Object2:public T { public: void getBlabla2(typename T::ABCD::CC2 c) { }; }; template class Object:public T { public: void getBlabla1(typename T::ABCD::CC1 c) { }; }; } class Factory { public: typedef TT::Object CC1; typedef TT::Object2 CC2; void getBlabla4(CC2 c) { }; void getBlabla3(CC1 c) { }; }; %} %template(ObjectBase) TT::Object; %template(Object2Base) TT::Object2; swig-3.0.2/Examples/test-suite/director_using.i0000664000175000017500000000234412343605122021424 0ustar williamwilliam%module(directors="1",dirprot="1") director_using %warnfilter(SWIGWARN_PHP_PUBLIC_BASE) FooBar; %{ #include #include %} %include "std_string.i" %feature("director"); %newobject *::create(); %inline { template class Foo { public: virtual ~Foo() {} std::string advance() { return "Foo::advance;" + do_advance(); } protected: virtual std::string do_advance() = 0; virtual std::string do_step() const = 0; }; } %template(Foo_int) Foo; %inline { class Bar : public Foo { public: std::string step() { return "Bar::step;" + advance(); } using Foo::do_step; protected: std::string do_advance() { return "Bar::do_advance;" + do_step(); } }; template class FooBar : public Bar { public: virtual C get_value() const = 0; using Bar::do_advance; }; } %template(FooBar_int) FooBar; %inline %{ struct SomeBase { virtual ~SomeBase() {} virtual void method1() {} virtual void method2() {} }; struct PrivateDerived : SomeBase { private: virtual void method1() {} using SomeBase::method2; }; %} swig-3.0.2/Examples/test-suite/complextest.i0000664000175000017500000000150712343605122020753 0ustar williamwilliam%module complextest %include #ifdef __cplusplus %{ #include #include #include %} %include #if 1 %template(VectorStdCplx) std::vector >; #endif %inline { std::complex Conj(const std::complex& a) { return std::conj(a); } std::complex Conjf(const std::complex& a) { return std::conj(a); } #if 1 std::vector > Copy_h(const std::vector >& a) { std::vector > b(a.size()/2); std::copy(a.begin(), a.begin()+a.size()/2, b.begin()); return b; } #endif } #else %{ %} %inline { complex Conj(complex a) { return conj(a); } complex float Conjf(float complex a) { return conj(a); } } #endif swig-3.0.2/Examples/test-suite/constructor_copy.i0000664000175000017500000000427412343605122022027 0ustar williamwilliam%module constructor_copy %copyctor; %nocopyctor Foo8; %nocopyctor Bar; %inline %{ struct Foo1 { int x; Foo1(int _x = 2) : x(_x) { } }; struct Foo2 { Foo2() { } }; struct Foo3 { Foo3() { } Foo3(const Foo3& ) { } }; struct Foo4 { Foo4() { } protected: Foo4(const Foo4& ) { } }; struct Foo4a { Foo4a() { } private: Foo4a(const Foo4a& ) { } }; struct Foo5 : Foo4 { }; struct Foo6 : Foo4 { Foo6(const Foo6& f) : Foo4(f) { } }; struct Foo7 : Foo5 { }; struct Foo8 { }; template class Bar { public: int x; Bar(int _x = 0) : x(_x) { } }; %} %template(Bari) Bar; %template(Bard) Bar; #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGUTL) %include "std_vector.i" #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT) #define SWIG_GOOD_VECTOR %ignore std::vector::vector(size_type); %ignore std::vector::resize(size_type); #endif #if defined(SWIGTCL) || defined(SWIGPERL) #define SWIG_GOOD_VECTOR /* here, for languages with bad declaration */ %ignore std::vector::vector(unsigned int); %ignore std::vector::resize(unsigned int); #endif %copyctor; %ignore FlowFlow::FlowFlow; %inline %{ namespace Space { class Flow { int x; public: Flow(int i) : x(i) {} }; class FlowFlow { int x; public: FlowFlow(int i) : x(i) {} }; } %} %template (VectFlow) std::vector; #endif %rename(ABC_Libor_ModelUtils) ABC_Nam::ABC_Libor::ModelUtils; %copyctor; %inline %{ namespace ABC_Nam { namespace ABC_Libor { struct ModelUtils {}; template struct ModelUtils_T {}; } } %} %template(ModelUtils_i) ABC_Nam::ABC_Libor::ModelUtils_T; %rename(Space1Space2_TotalReturnSwap) Space1::Space2::TotalReturnSwap; %copyctor; %inline %{ namespace Space1 { namespace Space2 { class TotalReturnSwap { public: TotalReturnSwap() {} }; template class TotalReturnSwap_T { public: TotalReturnSwap_T() {} }; } } %} %template(Total_i) Space1::Space2::TotalReturnSwap_T; swig-3.0.2/Examples/test-suite/li_attribute.i0000664000175000017500000000457612343605122021104 0ustar williamwilliam%module li_attribute %include //#define SWIG_ATTRIBUTE_TEMPLATE %include %{ // forward reference needed if using SWIG_ATTRIBUTE_TEMPLATE struct A; struct MyFoo; // %attribute2 does not work with templates %} %attribute(A, int, a, get_a, set_a); %attributeref(A, int, b); %attributeref(Param, int, value); %attribute(A, int, c, get_c); /* read-only */ %attributeref(A, int, d, b); /* renames accessor method 'b' to attribute name 'd' */ %attributeref(B, A*, a) %inline { struct A { A(int a, int b, int c) : _a(a), _b(b), _c(c) { } int get_a() const { return _a; } void set_a(int aa) { _a = aa; } /* only one ref method */ int& b() { return _b; } int get_c() const { return _c; } private: int _a; int _b; int _c; }; template struct Param { Param(C v) : _v(v) { } const int& value() const { return _v; } int& value() { return _v; } private: C _v; }; struct B { B(A *a) : mA(a) { } A*& a() { return mA; } protected: A* mA; }; } %template(Param_i) Param; // class/struct attribute with get/set methods using return/pass by reference %attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo); %inline %{ struct MyFoo { MyFoo() : x(-1) {} int x; }; class MyClass { MyFoo foo; public: MyFoo& GetFoo() { return foo; } void SetFoo(const MyFoo& other) { foo = other; } }; %} // class/struct attribute with get/set methods using return/pass by value %attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo); %attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo); %inline %{ class MyClassVal { MyFoo foo; public: MyFoo GetFoo() { return foo; } void SetFoo(MyFoo other) { foo = other; } }; %} // string attribute with get/set methods using return/pass by value %include %attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString); %attributestring(MyStringyClass, std::string, ReadOnlyString, GetString); %inline %{ class MyStringyClass { std::string str; public: MyStringyClass(const std::string &val) : str(val) {} std::string GetString() { return str; } void SetString(std::string other) { str = other; } }; %} swig-3.0.2/Examples/test-suite/pointer_in_out.i0000664000175000017500000000122712343605122021440 0ustar williamwilliam/* This file tests the pointer-in-out typemap library, currently only available for Guile. */ %module pointer_in_out %include "pointer-in-out.i" TYPEMAP_POINTER_INPUT_OUTPUT(int *, int-pointer); int consume_int_pointer(int **INPUT); void produce_int_pointer(int **OUTPUT, int value1, int value2); void frobnicate_int_pointer(int **INOUT); %{ int consume_int_pointer(int **INPUT) { return **INPUT; } void produce_int_pointer(int **OUTPUT, int value1, int value2) { int *foo = malloc(2 * sizeof(int)); foo[0] = value1; foo[1] = value2; *OUTPUT = foo; } void frobnicate_int_pointer(int **INOUT) { /* advance the pointer */ (*INOUT)++; } %} swig-3.0.2/Examples/test-suite/nested_comment.i0000664000175000017500000000135112343605122021405 0ustar williamwilliam%module nested_comment #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS // this example shows a problem with 'dump_nested' (parser.y). // bug #949654 %inline %{ typedef struct s1 { union { int fsc; /* genie structure hiding - Conductor */ int fso; /* genie structure hiding - FSOptions */ struct { double *vals; int size; } vector_val; /* matrix values are mainly used in rlgc models */ char *name; } n ; } s2; %} // comment in nested struct %inline %{ struct a { struct { /*struct*/ struct { int b; /**< v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ } c; } d; }; %} swig-3.0.2/Examples/test-suite/refcount.i0000664000175000017500000000323512343605122020231 0ustar williamwilliam%module refcount %warnfilter(SWIGWARN_IGNORE_OPERATOR_EQ,SWIGWARN_LANG_IDENTIFIER); %{ #include #include "refcount.h" %} // // using the %refobject/%unrefobject directives you can activate the // reference counting for RCObj and all its descendents at once // %refobject RCObj "$this->addref();" %unrefobject RCObj "$this->delref();" %include "refcount.h" %newobject B::create(A* a); %newobject global_create(A* a); %newobject B::cloner(); %newobject Factory::create(A* a); %newobject Factory::create2(A* a); %inline %{ struct A : RCObj { A() {} ~A() { // std::cout << "deleting a" << std::endl; } #ifdef SWIGRUBY // fix strange ruby + virtual derivation problem using RCObjBase::ref_count; #endif }; struct A1 : A { protected: A1() {} }; struct A2 : A { }; struct A3 : A1, private A2 { }; %} #if defined(SWIGPYTHON) %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; #endif %inline %{ struct B : RCObj { B(A* a) : _a(a) {} A* get_a() { return _a; } static B* create(A* a) { return new B(a); } B* cloner() { return new B(_a); } ~B() { // std::cout << "deleting b" << std::endl; } RCPtr get_rca() { return _a; } private: RCPtr _a; }; struct B* global_create(A* a) { return new B(a); } struct Factory { static B* create(A* a) { return new B(a); } B* create2(A* a) { return new B(a); } }; %} #if defined(SWIGPYTHON) || defined(SWIGOCTAVE) %include %template(vector_A) std::vector >; #endif swig-3.0.2/Examples/test-suite/smart_pointer_static.i0000664000175000017500000000057512343605122022645 0ustar williamwilliam%module smart_pointer_static %inline %{ class Foo2; class MyHandle_Foo2 { public: Foo2 * operator -> (); }; class Foo2 { public: virtual ~Foo2() {} virtual int sum(int i, int j) { return i+j; } static int sum(int i, int j, int k); }; %} %{ int Foo2::sum(int i, int j, int k) { return i+j+k; } Foo2 * MyHandle_Foo2::operator -> () { return new Foo2(); } %} swig-3.0.2/Examples/test-suite/li_swigtype_inout.i0000664000175000017500000000246712343605122022167 0ustar williamwilliam%module li_swigtype_inout // Test SWIGTYPE *& typemaps in swigtype_inout.i library #ifdef SWIGCSHARP %include %apply SWIGTYPE *& OUTPUT { SWIGTYPE *& } #endif %ignore XXX::operator=; %inline %{ #include struct XXX { XXX(int v) : value(v) { if (debug) std::cout << "Default Constructor " << value << " " << this << std::endl; count++; } XXX(const XXX &other) { value = other.value; if (debug) std::cout << "Copy Constructor " << value << " " << this << std::endl; count++; } XXX& operator=(const XXX &other) { value = other.value; if (debug) std::cout << "Assignment operator " << value << " " << this << std::endl; return *this; } ~XXX() { if (debug) std::cout << "Destructor " << value << " " << this << std::endl; count--; } void showInfo() { if (debug) std::cout << "Info " << value << " " << this << std::endl; } int value; static const bool debug = false; static int count; }; int XXX::count = 0; void ptr_ref_out(XXX *& x1, XXX *& x2, XXX const*& x3, XXX const*& x4) { x1 = new XXX(111); x2 = new XXX(222); x3 = new XXX(333); x4 = new XXX(444); } struct ConstructorTest { ConstructorTest(XXX *& x1, XXX *& x2, XXX const*& x3, XXX const*& x4) { ptr_ref_out(x1, x2, x3, x4); } }; %} swig-3.0.2/Examples/test-suite/preproc_include.i0000664000175000017500000000226312343605122021561 0ustar williamwilliam%module preproc_include %{ #include "preproc_include_a.h" #include "preproc_include_b.h" int multiply10(int a) { return a*10; } int multiply20(int a) { return a*20; } int multiply30(int a) { return a*30; } int multiply40(int a) { return a*40; } int multiply50(int a) { return a*50; } %} #define INCLUDE_B preproc_include_b.h #define FILE_INCLUDE(FNAME) #FNAME %include FILE_INCLUDE(preproc_include_a.h) // Note that this test uses -includeall, so including preproc_include_b.h also includes preproc_include_c.h %include INCLUDE_B %include"preproc_include_d withspace.h" #define INCLUDE_E "preproc_include_e withspace.h" %include INCLUDE_E %inline %{ #define INCLUDE_F /*comments*/ "preproc_include_f withspace.h"/*testing*/ #include INCLUDE_F #include /*oooo*/"preproc_include_g.h"/*ahhh*/ %} %{ int multiply60(int a) { return a*60; } int multiply70(int a) { return a*70; } %} %define nested_include_1(HEADER) %include

%enddef %define nested_include_2(HEADER) nested_include_1(HEADER); %enddef %define nested_include_3(HEADER) nested_include_2(HEADER); %enddef nested_include_1(preproc_include_h1.i); nested_include_2(preproc_include_h2.i); nested_include_3(preproc_include_h3.i); swig-3.0.2/Examples/test-suite/traits.i0000664000175000017500000000010412343605122017702 0ustar williamwilliam%module traits %include typemaps/traits.swg %fragment("Traits"); swig-3.0.2/Examples/test-suite/java_director_assumeoverride.i0000664000175000017500000000106212343605122024331 0ustar williamwilliam%module(directors="1") java_director_assumeoverride %{ class OverrideMe { public: virtual ~OverrideMe() {} virtual void func() {}; }; #include "java_director_assumeoverride_wrap.h" bool isFuncOverridden(OverrideMe* f) { SwigDirector_OverrideMe* director = dynamic_cast(f); if (!director) { return false; } return director->swig_overrides(0); } %} %feature("director", assumeoverride=1) OverrideMe; class OverrideMe { public: virtual ~OverrideMe(); virtual void func(); }; bool isFuncOverridden(OverrideMe* f); swig-3.0.2/Examples/test-suite/overload_copy.i0000664000175000017500000000024112343605122021243 0ustar williamwilliam// Tests copy constructor %module overload_copy #ifndef SWIG_NO_OVERLOAD %inline %{ class Foo { public: Foo() { } Foo(const Foo &) { } }; %} #endif swig-3.0.2/Examples/test-suite/li_std_queue.i0000664000175000017500000000015412343605122021063 0ustar williamwilliam// test of std::queue %module li_std_queue %include std_queue.i %template( IntQueue ) std::queue< int >; swig-3.0.2/Examples/test-suite/extend_template.i0000664000175000017500000000055412343605122021567 0ustar williamwilliam%module extend_template %module xxx // should be ignored namespace oss { // this doesn't %extend Foo<0> { int test1(int x) { return x; } } } %extend oss::Foo<0> { // this doesn't int test2(int x) { return x; } }; %inline %{ namespace oss { template struct Foo { }; } %} namespace oss { %template(Foo_0) Foo<0>; } swig-3.0.2/Examples/test-suite/using_inherit.i0000664000175000017500000000174512343605122021257 0ustar williamwilliam%module using_inherit #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Foo::test; #endif %inline %{ class Foo { public: int test(int x) { return x; } double test(double x) { return x; }; }; class Bar : public Foo { public: using Foo::test; }; class Bar2 : public Foo { public: int test(int x) { return x*2; } double test(double x) { return x*2; }; using Foo::test; }; class Bar3 : public Foo { public: int test(int x) { return x*2; } double test(double x) { return x*2; }; using Foo::test; }; class Bar4 : public Foo { public: int test(int x) { return x*2; } using Foo::test; double test(double x) { return x*2; }; }; class Fred1 : public Foo { public: using Foo::test; double test(double x) { return x*2; }; }; class Fred2 : public Foo { public: double test(double x) { return x*2; }; using Foo::test; }; %} swig-3.0.2/Examples/test-suite/add_link.i0000664000175000017500000000020112343605122020137 0ustar williamwilliam%module add_link %extend Foo { Foo *blah() { return new Foo(); } }; %inline %{ class Foo { public: Foo() { }; }; %} swig-3.0.2/Examples/test-suite/template_using_directive_and_declaration_forward.i0000664000175000017500000000774012343605122030402 0ustar williamwilliam%module template_using_directive_and_declaration_forward // Test using directives combined with using declarations and forward declarations (templates) %inline %{ namespace Outer1 { namespace Space1 { template class Thing1; } } using namespace Outer1::Space1; using Outer1::Space1::Thing1; #ifdef __clang__ namespace Outer1 { namespace Space1 { template class Thing1 {}; } } #else template class Thing1 {}; #endif void useit1(Thing1 t) {} void useit1a(Outer1::Space1::Thing1 t) {} void useit1b(::Outer1::Space1::Thing1 t) {} namespace Outer1 { void useit1c(Space1::Thing1 t) {} } namespace Outer2 { namespace Space2 { template class Thing2; } } using namespace Outer2; using Space2::Thing2; #ifdef __clang__ namespace Outer2 { namespace Space2 { template class Thing2 {}; } } #else template class Thing2 {}; #endif void useit2(Thing2 t) {} void useit2a(Outer2::Space2::Thing2 t) {} void useit2b(::Outer2::Space2::Thing2 t) {} void useit2c(Space2::Thing2 t) {} namespace Outer2 { void useit2d(Space2::Thing2 t) {} } namespace Outer3 { namespace Space3 { namespace Middle3 { template class Thing3; } } } using namespace Outer3; using namespace Space3; using Middle3::Thing3; #ifdef __clang__ namespace Outer3 { namespace Space3 { namespace Middle3 { template class Thing3 {}; } } } #else template class Thing3 {}; #endif void useit3(Thing3 t) {} void useit3a(Outer3::Space3::Middle3::Thing3 t) {} void useit3b(::Outer3::Space3::Middle3::Thing3 t) {} void useit3c(Middle3::Thing3 t) {} namespace Outer3 { namespace Space3 { void useit3d(Middle3::Thing3 t) {} } } namespace Outer4 { namespace Space4 { namespace Middle4 { template class Thing4; } } } using namespace Outer4::Space4; using Middle4::Thing4; #ifdef __clang__ namespace Outer4 { namespace Space4 { namespace Middle4 { template class Thing4 {}; } } } #else template class Thing4 {}; #endif void useit4(Thing4 t) {} void useit4a(Outer4::Space4::Middle4::Thing4 t) {} void useit4b(::Outer4::Space4::Middle4::Thing4 t) {} void useit4c(Middle4::Thing4 t) {} namespace Outer4 { namespace Space4 { void useit4d(Middle4::Thing4 t) {} } } namespace Outer5 { namespace Space5 { namespace Middle5 { namespace More5 { template class Thing5; } } } } using namespace ::Outer5::Space5; using namespace Middle5; using More5::Thing5; #ifdef __clang__ namespace Outer5 { namespace Space5 { namespace Middle5 { namespace More5 { template class Thing5 {}; } } } } #else template class Thing5 {}; #endif void useit5(Thing5 t) {} void useit5a(Outer5::Space5::Middle5::More5::Thing5 t) {} void useit5b(::Outer5::Space5::Middle5::More5::Thing5 t) {} void useit5c(Middle5::More5::Thing5 t) {} namespace Outer5 { namespace Space5 { void useit5d(Middle5::More5::Thing5 t) {} } } namespace Outer7 { namespace Space7 { namespace Middle7 { template class Thing7; } } } using namespace Outer7::Space7; #ifdef __clang__ namespace Outer7 { namespace Space7 { namespace Middle7 { template class Thing7 {}; } } } #else template class Middle7::Thing7 {}; #endif using Middle7::Thing7; void useit7(Thing7 t) {} void useit7a(Outer7::Space7::Middle7::Thing7 t) {} void useit7b(::Outer7::Space7::Middle7::Thing7 t) {} void useit7c(Middle7::Thing7 t) {} namespace Outer7 { namespace Space7 { void useit7d(Middle7::Thing7 t) {} } } %} %template(Thing1Int) Thing1; %template(Thing2Int) Thing2; %template(Thing3Int) Thing3; %template(Thing4Int) Thing4; %template(Thing5Int) Thing5; %template(Thing7Int) Thing7; swig-3.0.2/Examples/test-suite/csharp_prepost.i0000664000175000017500000001673012343605122021444 0ustar williamwilliam%module (directors="1") csharp_prepost // Test the pre, post, terminate and cshin attributes for csin typemaps %include "std_vector.i" %define VECTOR_DOUBLE_CSIN_POST " int count$csinput = d$csinput.Count; $csinput = new double[count$csinput]; for (int i=0; i &v "out double[]" %typemap(csin, pre=" DoubleVector d$csinput = new DoubleVector();", post=VECTOR_DOUBLE_CSIN_POST, cshin="out $csinput") std::vector &v "$csclassname.getCPtr(d$csinput)" %apply std::vector & v { std::vector & v2 } // pre only in csin typemap %typemap(cstype) std::vector &vpre "ref double[]" %typemap(csin, pre=" DoubleVector d$csinput = new DoubleVector();\n foreach (double d in $csinput) {\n d$csinput.Add(d);\n }", cshin="ref $csinput") std::vector &vpre "$csclassname.getCPtr(d$csinput)" // post only in csin typemap %typemap(csin, post=" int size = $csinput.Count;\n" " for (int i=0; i &vpost "$csclassname.getCPtr($csinput)" %inline %{ bool globalfunction(std::vector & v) { v.push_back(0.0); v.push_back(1.1); v.push_back(2.2); return true; } struct PrePostTest { PrePostTest() { } PrePostTest(std::vector & v) { v.push_back(3.3); v.push_back(4.4); } bool method(std::vector & v) { v.push_back(5.5); v.push_back(6.6); return true; } static bool staticmethod(std::vector & v) { v.push_back(7.7); v.push_back(8.8); return true; } }; // Check pre and post only typemaps and that they coexist okay and that the generated code line spacing looks okay bool globalfunction2(std::vector & v, std::vector &v2, std::vector & vpre, std::vector & vpost) { return true; } struct PrePost2 { PrePost2() { } virtual ~PrePost2() { } PrePost2(std::vector & v, std::vector &v2, std::vector & vpre, std::vector & vpost) { } virtual bool method(std::vector & v, std::vector &v2, std::vector & vpre, std::vector & vpost) { return true; } static bool staticmethod(std::vector & v, std::vector &v2, std::vector & vpre, std::vector & vpost) { return true; } }; %} // Check csdirectorin pre and post attributes // ref param %typemap(csdirectorin, pre=" DoubleVector d$iminput = new DoubleVector($iminput, false);\n" " int count$iminput = d$iminput.Count;\n" " double[] v$iminput = new double[count$iminput];\n" " for (int i=0; i &vpre "ref v$iminput" // post only in csdirectorin typemap %typemap(csdirectorin, post=" DoubleVector d$iminput = new DoubleVector($iminput, false);\n" " int size = d$iminput.Count;\n" " for (int i=0; i &vpost "new $csclassname($iminput, false)" %feature("director") PrePost3; %inline %{ struct PrePost3 { PrePost3() { } virtual ~PrePost3(){} virtual void method(std::vector & vpre, std::vector & vpost) {} virtual int methodint(std::vector & vpre, std::vector & vpost) { return 0; } }; %} %template(DoubleVector) std::vector; // Check attributes in the typemaps %typemap(cstype, inattributes="[CustomInt]") int val "int" %typemap(csin, pre=" int tmp_$csinput = $csinput * 100;") int val "tmp_$csinput" %typemap(imtype, out="global::System.IntPtr/*overridden*/", outattributes="[CustomIntPtr]") CsinAttributes * "global::System.Runtime.InteropServices.HandleRef/*overridden*/" %inline %{ class CsinAttributes { int m_val; public: CsinAttributes(int val) : m_val(val) {} int getVal() { return m_val; } }; %} // test Date marshalling with pre post and terminate typemap attributes (Documented in CSharp.html) %typemap(cstype) const CDate& "System.DateTime" %typemap(csin, pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);" ) const CDate & "$csclassname.getCPtr(temp$csinput)" %typemap(cstype) CDate& "out System.DateTime" %typemap(csin, pre=" CDate temp$csinput = new CDate();", post=" $csinput = new System.DateTime(temp$csinput.getYear()," " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", cshin="out $csinput" ) CDate & "$csclassname.getCPtr(temp$csinput)" %inline %{ class CDate { public: CDate(); CDate(int year, int month, int day); int getYear(); int getMonth(); int getDay(); private: int m_year; int m_month; int m_day; }; struct Action { int doSomething(const CDate &dateIn, CDate &dateOut); Action(const CDate &dateIn, CDate& dateOut); }; %} %{ Action::Action(const CDate &dateIn, CDate& dateOut) {dateOut = dateIn;} int Action::doSomething(const CDate &dateIn, CDate &dateOut) { dateOut = dateIn; return 0; } CDate::CDate() : m_year(0), m_month(0), m_day(0) {} CDate::CDate(int year, int month, int day) : m_year(year), m_month(month), m_day(day) {} int CDate::getYear() { return m_year; } int CDate::getMonth() { return m_month; } int CDate::getDay() { return m_day; } %} %typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime" %typemap(csin, pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", post=" $csinput = new System.DateTime(temp$csinput.getYear()," " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", cshin="ref $csinput" ) CDate * "$csclassname.getCPtr(temp$csinput)" %inline %{ void addYears(CDate *pDate, int years) { *pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay()); } %} %typemap(csin, pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {", post=" $csinput = new System.DateTime(temp$csinput.getYear()," " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", terminator=" } // terminate temp$csinput using block", cshin="ref $csinput" ) CDate * "$csclassname.getCPtr(temp$csinput)" %inline %{ void subtractYears(CDate *pDate, int years) { *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay()); } %} %typemap(csvarin, excode=SWIGEXCODE2) CDate * %{ /* csvarin typemap code */ set { CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day); $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) CDate * %{ /* csvarout typemap code */ get { global::System.IntPtr cPtr = $imcall; CDate tempDate = (cPtr == global::System.IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(), 0, 0, 0); } %} %inline %{ CDate ImportantDate = CDate(1999, 12, 31); struct Person { CDate Birthday; }; %} swig-3.0.2/Examples/test-suite/smart_pointer_inherit.i0000664000175000017500000000372412343605122023017 0ustar williamwilliam%module smart_pointer_inherit #ifdef SWIGCSHARP // Test that the override is removed in the smart pointer for custom method modifiers %csmethodmodifiers hi::Derived::value3 "/*csmethodmodifiers*/ public override"; #endif %inline %{ namespace hi { struct Base { Base(int i) : val(i) {} virtual ~Base() { } virtual int value() = 0; virtual int value2() { return val; } virtual int value3() { return val; } int valuehide() { return val; } int val; }; struct Derived : Base { Derived(int i) : Base(i) {} virtual int value() { return val; } virtual int value3() { return Base::value3(); } int valuehide() { return -1; } }; template struct SmartPtr { SmartPtr(T *t) : ptr(t) {} T * operator->() const { return ptr; } private: T *ptr; }; } %} %template(SmartBase) hi::SmartPtr; %template(SmartDerived) hi::SmartPtr; %include std_vector.i %inline %{ class ItkLevelSetNodeUS2 { int x; }; %} #ifdef SWIGCSHARP // Get rid of C# compiler warnings. // Really the itkVectorContainerUILSNUS2_Pointer class should be manually modified to contain the same %extend methods that are in std_vector.i %csmethodmodifiers std::vector::getitemcopy "protected" %csmethodmodifiers std::vector::getitem "protected" %csmethodmodifiers std::vector::setitem "protected" %csmethodmodifiers std::vector::size "protected" %csmethodmodifiers std::vector::capacity "protected" %csmethodmodifiers std::vector::reserve "protected" #endif %template(VectorLevelSetNodeUS2) std::vector< ItkLevelSetNodeUS2 >; %inline %{ class ItkVectorContainerUILSNUS2 : public std::vector< ItkLevelSetNodeUS2 > { }; class ItkVectorContainerUILSNUS2_Pointer { public: ItkVectorContainerUILSNUS2 * operator->() const { return 0; } }; %} swig-3.0.2/Examples/test-suite/mixed_types.i0000664000175000017500000000633412343605122020741 0ustar williamwilliam%module mixed_types %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hello; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'hello' due to Go name ('Hello') conflict with 'Hello' */ %inline { const void* ref_pointer(const void*& a) { return a; } struct A { }; const A* ref_pointer(A* const& a) { return a; } const A** ref_pointer_1(const A**& a) { return a; } A* pointer_1(A* a) { return a; } const A& ref_const(const A& a) { return a; } enum Hello { hi,hello }; int sint(int a) { return a; } const int& ref_int(const int& a) { return a; } Hello senum(Hello a) { return a; } const Hello& ref_enum(const Hello& a) { return a; } typedef A *Aptr; const Aptr& rptr_const(const Aptr& a) { return a; } const Aptr& rptr_const2(const Aptr& a) { return a; } const void*& rptr_void(const void*& a) { return a; } const A& cref_a(const A& a) { return a; } A& ref_a(A& a) { return a; } template struct NameT { }; typedef char name[8]; typedef char namea[]; typedef NameT name_t[8]; char* test_a(char hello[8], char hi[], const char chello[8], const char chi[]) { return hi; } int test_b(name n2) { return 1; } /* gcc doesn't like this one. Removing until reason resolved.*/ int test_c(const name& n1) { return 1; } int test_d(name* n1) { return 1; } int test_e(const name_t& n1) { return 1; } int test_f(name_t n1) { return 1; } int test_g(name_t* n1) { return 1; } struct Foo { int foo(const Aptr&a); int foon(const char (&a)[8]); }; inline int Foo::foo(A* const& a) { return 1; } } %{ inline int Foo::foon(const name& a) { return a[0]; } %} %inline %{ #define ARRAY_LEN_X 2 #define ARRAY_LEN_Y 4 typedef enum {One, Two, Three, Four, Five} finger; typedef struct { double double_field; } SimpleStruct; char array_c [ARRAY_LEN_X][ARRAY_LEN_Y]; signed char array_sc[ARRAY_LEN_X][ARRAY_LEN_Y]; unsigned char array_uc[ARRAY_LEN_X][ARRAY_LEN_Y]; short array_s [ARRAY_LEN_X][ARRAY_LEN_Y]; unsigned short array_us[ARRAY_LEN_X][ARRAY_LEN_Y]; int array_i [ARRAY_LEN_X][ARRAY_LEN_Y]; unsigned int array_ui[ARRAY_LEN_X][ARRAY_LEN_Y]; long array_l [ARRAY_LEN_X][ARRAY_LEN_Y]; unsigned long array_ul[ARRAY_LEN_X][ARRAY_LEN_Y]; long long array_ll[ARRAY_LEN_X][ARRAY_LEN_Y]; float array_f [ARRAY_LEN_X][ARRAY_LEN_Y]; double array_d [ARRAY_LEN_X][ARRAY_LEN_Y]; SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]; SimpleStruct* array_structpointers[ARRAY_LEN_X][ARRAY_LEN_Y]; int* array_ipointers [ARRAY_LEN_X][ARRAY_LEN_Y]; finger array_enum[ARRAY_LEN_X][ARRAY_LEN_Y]; finger* array_enumpointers[ARRAY_LEN_X][ARRAY_LEN_Y]; const int array_const_i[ARRAY_LEN_X][ARRAY_LEN_Y] = { {10, 11, 12, 13}, {14, 15, 16, 17} }; void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]) {} int get_2d_array(int (*array)[ARRAY_LEN_Y], int x, int y){ return array[x][y]; } %} swig-3.0.2/Examples/test-suite/long_long_apply.i0000664000175000017500000000506512343605122021572 0ustar williamwilliam/* This interface file tests whether SWIG handles the Microsoft __int64 type through the use of applying the long long typemaps. The generated code should not have any instances of long long. */ %module long_long_apply %{ #ifdef _MSC_VER /* Visual C++ */ typedef __int64 LongLong; typedef unsigned __int64 UnsignedLongLong; #else typedef long long LongLong; typedef unsigned long long UnsignedLongLong; #endif %} %apply long long { LongLong }; %apply unsigned long long { UnsignedLongLong }; %apply const long long & { const LongLong & }; %apply const unsigned long long & { const UnsignedLongLong & }; %inline %{ // pass by value LongLong value1(LongLong x) { return x; } UnsignedLongLong value2(UnsignedLongLong x) { return x; } // pass by reference const LongLong &ref1(const LongLong &x) { return x; } const UnsignedLongLong &ref2(const UnsignedLongLong &x) { return x; } // global variables LongLong global1; UnsignedLongLong global2; // global reference variables const LongLong& global_ref1 = global1; const UnsignedLongLong& global_ref2 = global2; %} // typemaps library %include "typemaps.i" %apply long long *INPUT { LongLong *INPUT }; %apply unsigned long long *INPUT { UnsignedLongLong *INPUT }; %apply long long *OUTPUT { LongLong *OUTPUT }; %apply unsigned long long *OUTPUT { UnsignedLongLong *OUTPUT }; %apply long long *INOUT { LongLong *INOUT }; %apply unsigned long long *INOUT { UnsignedLongLong *INOUT }; %apply long long &INPUT { LongLong &INPUT }; %apply unsigned long long &INPUT { UnsignedLongLong &INPUT }; %apply long long &OUTPUT { LongLong &OUTPUT }; %apply unsigned long long &OUTPUT { UnsignedLongLong &OUTPUT }; %apply long long &INOUT { LongLong &INOUT }; %apply unsigned long long &INOUT { UnsignedLongLong &INOUT }; %inline %{ LongLong in_longlong(LongLong *INPUT) { return *INPUT; } UnsignedLongLong in_ulonglong(UnsignedLongLong *INPUT) { return *INPUT; } LongLong inr_longlong(LongLong &INPUT) { return INPUT; } UnsignedLongLong inr_ulonglong(UnsignedLongLong &INPUT) { return INPUT; } void out_longlong(LongLong x, LongLong *OUTPUT) { *OUTPUT = x; } void out_ulonglong(UnsignedLongLong x, UnsignedLongLong *OUTPUT) { *OUTPUT = x; } void outr_longlong(LongLong x, LongLong &OUTPUT) { OUTPUT = x; } void outr_ulonglong(UnsignedLongLong x, UnsignedLongLong &OUTPUT) { OUTPUT = x; } void inout_longlong(LongLong *INOUT) { *INOUT = *INOUT; } void inout_ulonglong(UnsignedLongLong *INOUT) { *INOUT = *INOUT; } void inoutr_longlong(LongLong &INOUT) { INOUT = INOUT; } void inoutr_ulonglong(UnsignedLongLong &INOUT) { INOUT = INOUT; } %} swig-3.0.2/Examples/test-suite/cpp11_initializer_list_extend.i0000664000175000017500000000112212343605122024326 0ustar williamwilliam/* This testcase shows how to replace std_initializer_list with std_vector. */ %module cpp11_initializer_list_extend %ignore Container::Container(std::initializer_list); %include %template(VectorInt) std::vector; %extend Container { Container(const std::vector &elements) { Container *c = new Container(); for (int element : elements) c->push_back(element); return c; } } %inline %{ #include class Container { public: Container(std::initializer_list) {} Container() {} void push_back(const int&) {} }; %} swig-3.0.2/Examples/test-suite/java_director.i0000664000175000017500000000527412343605122021225 0ustar williamwilliam/* * Test Java director typemaps and features */ %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR); /* Thread/reentrant unsafe wrapping, consider returning by value instead. */ %module(directors="1") java_director %typemap(javafinalize) SWIGTYPE %{ protected void finalize() { // System.out.println("Finalizing " + this); delete(); } %} %{ #include #include class Quux { public: Quux() : memb_("default Quux ctor arg") {instances_++; } Quux(const std::string &arg) : memb_(arg) {instances_++;} Quux(const Quux &src) : memb_(src.memb_) {instances_++;} virtual ~Quux() {instances_--;} virtual const std::string &director_method() { return memb_; } const std::string &member() { return memb_; } static int instances() { return instances_; } private: static int instances_; std::string memb_; }; int Quux::instances_ = 0; class QuuxContainer { protected: typedef std::vector quuxvec_t; public: QuuxContainer() : quuxen_() { } ~QuuxContainer() { for (quuxvec_t::iterator iter = quuxen_.begin(); iter != quuxen_.end(); ++iter) { delete *iter; } quuxen_.clear(); } void push(Quux *elem) { quuxen_.push_back(elem); } Quux *get(int idx) { return quuxen_[idx]; } const std::string &invoke(int idx) { return quuxen_[idx]->director_method(); } size_t size() { return quuxen_.size(); } private: quuxvec_t quuxen_; }; %} %include "std_string.i" %feature("director") Quux; SWIG_DIRECTOR_OWNED(Quux) class Quux { public: Quux(); Quux(const std::string &arg); Quux(const Quux &src); virtual ~Quux(); virtual const std::string &director_method(); const std::string &member(); static int instances(); }; class QuuxContainer { public: QuuxContainer(); ~QuuxContainer(); void push(Quux *elem); Quux *get(int idx); const std::string &invoke(int idx); size_t size(); }; %feature("director"); %typemap(javacode) hi::Quux1 %{ public boolean disconnectMethodCalled = false; %} %typemap(directordisconnect, methodname="disconnect_director") hi::Quux1 %{ public void $methodname() { swigCMemOwn = false; $jnicall; // add in a flag to check this method is really called disconnectMethodCalled = true; } %} %inline %{ namespace hi { struct Quux1 : public Quux { Quux1(const std::string& arg) : Quux(arg) {} virtual int ff(int i = 0) {return i;} }; } struct JObjectTest { virtual ~JObjectTest() {} // Test special Java JNI type jobject virtual jobject foo(jobject x) { return x; } }; %} %javaexception("Exception") etest "$action" %inline %{ struct JavaExceptionTest { virtual ~JavaExceptionTest() {} virtual void etest() {} }; %} swig-3.0.2/Examples/test-suite/java_constants.i0000664000175000017500000000121712343605122021417 0ustar williamwilliam // This testcase uses the %javaconst directive to control how constants are initialised %module java_constants %constant short DIPSTICK=100; // Set default Java const code generation %javaconst(1); // Modify the code generation to use JNI function call initialisation for some difficult cases %javaconst(0) TOM; %javaconst(0) ORCHESTRA_STALLS; %javaconst(0) PORKY; %inline %{ #define CHINA 2*100 #define TOM 300ULL #define ORCHESTRA_STALLS 400LL #define JAM_JAR "500" #define OXO '6' #define PORKY !7 %} %constant int BRISTOLS=800; %javaconstvalue(100L) APPLES; %inline %{ #define APPLES 100LL %} %javaconst(0); %constant long long ROSY=900LL; swig-3.0.2/Examples/test-suite/preproc_defined.i0000664000175000017500000000337612343605122021542 0ustar williamwilliam%module preproc_defined // Check 'defined' passes through the preprocessor without being processed like '#if defined(ABC)' would be (SF bug #1940536) %define DEFINED_MACRO %{ int defined(int b) { return b > 10; } int vvv = -1; void fn(int val) { if (defined(val)) vvv = 1; else vvv = 0; } %} %enddef DEFINED_MACRO %{ int checking(void) { int okay; fn(11); okay = (vvv == 1); fn(9); okay = okay && (vvv == 0); return okay; /* should be 1 */ } %} %inline %{ int call_checking(void) { return checking(); } %} /*****************************************************************************/ /* Check #if/#elif defined() macro expansions Also checks #if/#elif defined() works correctly within macros... this is not standard C, but is now relied on in the SWIG library. */ /*****************************************************************************/ #define AAA #define BBB #define CCC #if defined(AAA)\ && defined(BBB) \ && defined(CCC) %{ void thing(int i) {} void stuff(int i) {} struct Defined { int defined; }; void bumpf(int i) {} %} #else #endif %define ANOTHER_MACRO(TYPE) #if defined(AAA) && defined(BBB) && defined(CCC) void thing(TYPE) {} #else void thing_not(TYPE) {} #endif #if defined(AAA) &&\ defined(BBB) \\ && defined(CCC) void stuff(TYPE) {} #else void stuff_not(TYPE); #endif #if defined(0) void defined_not(TYPE); #elif defined(AAA) && defined( BBB ) && defined(CCC) struct Defined { int defined; }; #else void defined_not(TYPE); #endif #if !( defined(AAA) \ defined(BBB) \\ && defined(CCC) ) void bumpf_not(TYPE); #else void bumpf(TYPE) {} #endif %enddef ANOTHER_MACRO(int) %{ void another_macro_checking(void) { struct Defined d; d.defined = 10; thing(10); stuff(10); bumpf(10); } %} swig-3.0.2/Examples/test-suite/ruby_keywords.i0000664000175000017500000000413312343605122021312 0ustar williamwilliam%module ruby_keywords // fix up conflicts with C++ keywords %rename("and") Keywords::and_; %rename("break") Keywords::break_; %rename("case") Keywords::case_; %rename("class") Keywords::class_; %rename("defined?") Keywords::defined_; %rename("do") Keywords::do_; %rename("else") Keywords::else_; %rename("false") Keywords::false_; %rename("for") Keywords::for_; %rename("if") Keywords::if_; %rename("not") Keywords::not_; %rename("return") Keywords::return_; %rename("or") Keywords::or_; %rename("true") Keywords::true_; %rename("while") Keywords::while_; %inline %{ class Keywords { public: Keywords() {} const char* alias() { return "alias"; } const char* and_() { return "and"; } const char* begin() { return "begin"; } const char* break_() { return "break"; } const char* case_() { return "case"; } const char* class_() { return "class"; } const char* def() { return "def"; } const char* defined_() { return "defined?"; } const char* do_() { return "do"; } const char* else_() { return "else"; } const char* elsif() { return "elsif"; } const char* end() { return "end"; } const char* ensure() { return "ensure"; } const char* false_() { return "false"; } const char* for_() { return "for"; } const char* if_() { return "if"; } const char* in() { return "in"; } const char* module() { return "module"; } const char* next() { return "next"; } const char* nil() { return "nil"; } const char* not_() { return "not"; } const char* or_() { return "or"; } const char* redo() { return "redo"; } const char* rescue() { return "rescue"; } const char* retry() { return "retry"; } const char* return_() { return "return"; } const char* self() { return "self"; } const char* super() { return "super"; } const char* then() { return "then"; } const char* true_() { return "true"; } const char* undef() { return "undef"; } const char* under() { return "under"; } const char* unless() { return "unless"; } const char* until() { return "until"; } const char* when() { return "when"; } const char* while_() { return "while"; } const char* yield() { return "yield"; } }; %} swig-3.0.2/Examples/test-suite/template_nested.i0000664000175000017500000000742112343605122021562 0ustar williamwilliam%module template_nested #if !defined(SWIGCSHARP) && !defined(SWIGJAVA) %feature ("flatnested"); #endif // Test nested templates - that is template classes and template methods within a class. namespace ns { template struct ForwardTemplate; } %{ namespace ns { template struct ForwardTemplate { void tmethod(T t) {} }; } %} %inline %{ namespace ns { class NormalClass { public: NormalClass() {} ~NormalClass() {} }; template struct NormalTemplate { void tmethod(T t) {} }; } %} %template(T_NormalTemplateNormalClass) ns::NormalTemplate; %template(T_NormalTemplateInt) ns::NormalTemplate; %template(T_NormalTemplateDouble) ns::NormalTemplate; %inline %{ namespace ns { class OuterClass { public: template struct Inner1 { template struct SuperInner1 { void method1(U t) {} }; template struct SuperInner2 { void method1(V t) {} }; template void tmethod(W w) {} template void tmethodAgain(X x) {} template struct SuperBase : public SuperInner1 { void method1(Y y) {} }; }; Inner1 useInner1(const Inner1& inner) { return inner; } template void InnerTMethod(Z z) {} template class Inner2 : public NormalTemplate { public: template class SuperInner1 { public: SuperInner1() {} void method1(U t) {} }; template struct SuperInner2 { void method1(V t) {} }; int embeddedVar; template void tmethod(X x) {} template struct SuperBase : public SuperInner1 { void method1(Y y) {} }; }; Inner2 useInner2(const Inner2& inner) { return inner; } Inner2 useInner2Again(const Inner2& inner) { return inner; } #ifdef SWIG %template(T_OuterClassInner1Double) Inner1; #endif int iii; }; struct ABC { ABC() {} ~ABC() {} }; struct TemplateFuncs { template X templateMethod1(X x) { return x; } template X templateMethod2(X x) { return x; } }; template struct OuterTemplate { template struct NestedInnerTemplate1 { template void NestedInnerInnerTMethod(Z z) {} void hohum() {} }; template void NestedInnerTMethod(UU u, W w) {} template struct NestedInnerTemplate2 { void hohum() {} }; UU hohum(UU u) { return u; } template struct NestedInnerTemplate3 : public NestedInnerTemplate2 { void hohum() {} }; struct NestedStruct { NestedStruct() {} void hohum() {} }; NestedInnerTemplate1 useNestedInnerTemplate1(const NestedInnerTemplate1& inner) { return inner; } NestedInnerTemplate2 useNestedInnerTemplate2(const NestedInnerTemplate2& inner) { return inner; } NestedInnerTemplate3 useNestedInnerTemplate3(const NestedInnerTemplate3& inner) { return inner; } NestedStruct useNestedStruct(const NestedStruct& inner) { return inner; } }; } %} %extend ns::OuterClass { %template(T_OuterClassInner2Double) Inner2; } %template(T_OuterTMethodNormalClass) ns::OuterClass::InnerTMethod; %template(T_TemplateFuncs1Int) ns::TemplateFuncs::templateMethod1; %template(T_TemplateFuncs2Double) ns::TemplateFuncs::templateMethod2; %template(T_NestedOuterTemplateDouble) ns::OuterTemplate; %template(T_OuterClassInner1Int) ns::OuterClass::Inner1; %template(T_OuterClassInner2NormalClass) ns::OuterClass::Inner2; %template(T_OuterClassInner2Int) ns::OuterClass::Inner2; swig-3.0.2/Examples/test-suite/c_delete_function.i0000664000175000017500000000045412343605122022055 0ustar williamwilliam%module c_delete_function /* check C++ delete keyword is okay in C wrappers */ %warnfilter(SWIGWARN_PARSE_KEYWORD) delete; #if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) /* Octave and Javascript/v8 compiles wrappers as C++ */ %inline %{ double delete(double d) { return d; } %} #endif swig-3.0.2/Examples/test-suite/expressions.i0000664000175000017500000000020712343605122020762 0ustar williamwilliam%module expressions %inline %{ struct A { A() : k( 20/(5-1) ) {} A(int i) : k( 20/(5-1)*i /* comment */ ) {} int k; }; %} swig-3.0.2/Examples/test-suite/inplaceadd.i0000664000175000017500000000067612343605122020476 0ustar williamwilliam%module inplaceadd %{ #include %} %inline %{ struct A { int val; A(int v): val(v) { } A& operator+=(int v) { val += v; return *this; } A& operator+=(const A& a) { val += a.val; return *this; } A& operator-=(int v) { val -= v; return *this; } A& operator*=(int v) { val *= v; return *this; } }; %} swig-3.0.2/Examples/test-suite/valuewrapper_base.i0000664000175000017500000000103612343605122022110 0ustar williamwilliam%module valuewrapper_base %inline %{ namespace oss { enum Polarization { UnaryPolarization, BinaryPolarization }; struct Base { }; template struct Interface_ : Base { Interface_(const Base& b) { }; }; template Result make() { return Result(*new Base()); } } %} namespace oss { // Interface %template(Interface_BP) Interface_; %template(make_Interface_BP) make >; } swig-3.0.2/Examples/test-suite/sym.i0000664000175000017500000000073112343605122017212 0ustar williamwilliam%module sym // make sure different classes are allowed to have methods of the same name // that we properly qualify wrappers in the C namespace to avoid collisions %rename(hulahoops) Flim::Jam(); %inline %{ class Flim { public: Flim() { } const char * Jam() { return "flim-jam"; } const char * Jar() { return "flim-jar"; } }; class Flam { public: Flam() { } const char * Jam() { return "flam-jam"; } const char * Jar() { return "flam-jar"; } }; %} swig-3.0.2/Examples/test-suite/errors/0000775000175000017500000000000012343605122017543 5ustar williamwilliamswig-3.0.2/Examples/test-suite/errors/cpp_private_defvalue.i0000664000175000017500000000013112343605122024077 0ustar williamwilliam%module xxx class foo { static const int BAR = 42; public: int blah(int x = BAR); }; swig-3.0.2/Examples/test-suite/errors/pp_macro_expansion.stderr0000664000175000017500000000010212343605122024645 0ustar williamwilliampp_macro_expansion.i:9: Error: Macro 'MACRO2' expects 2 arguments swig-3.0.2/Examples/test-suite/errors/pp_unterm_string.stderr0000664000175000017500000000011712343605122024366 0ustar williamwilliampp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4 swig-3.0.2/Examples/test-suite/errors/swig_identifier.i0000664000175000017500000000007312343605122023070 0ustar williamwilliam%module xxx %rename("foo bar") foobar; int foobar(int); swig-3.0.2/Examples/test-suite/errors/pp_macro_args.stderr0000664000175000017500000000000012343605122023572 0ustar williamwilliamswig-3.0.2/Examples/test-suite/errors/cpp_missing_rparenthesis.stderr0000664000175000017500000000020712343605122026071 0ustar williamwilliamcpp_missing_rparenthesis.i:5: Error: Missing ')'. Reached end of input. cpp_missing_rparenthesis.i:5: Error: Syntax error in input(3). swig-3.0.2/Examples/test-suite/errors/c_bad_name.i0000664000175000017500000000003712343605122021745 0ustar williamwilliam%module xxx %name() int foo; swig-3.0.2/Examples/test-suite/errors/c_bad_native.stderr0000664000175000017500000000010612343605122023363 0ustar williamwilliamc_bad_native.i:3: Error: %native declaration 'foo' is not a function. swig-3.0.2/Examples/test-suite/errors/cpp_template_repeat.stderr0000664000175000017500000000000012343605122024773 0ustar williamwilliamswig-3.0.2/Examples/test-suite/errors/pp_defined.stderr0000664000175000017500000000015212343605122023063 0ustar williamwilliampp_defined.i:6: Error: No arguments given to defined() pp_defined.i:6: Error: Missing expression for #if. swig-3.0.2/Examples/test-suite/errors/c_deprecated.stderr0000664000175000017500000000021012343605122023363 0ustar williamwilliamc_deprecated.i:3: Warning 102: %val directive deprecated (ignored). c_deprecated.i:3: Warning 103: %out directive deprecated (ignored). swig-3.0.2/Examples/test-suite/errors/cpp_using_not.i0000664000175000017500000000006212343605122022562 0ustar williamwilliam%module xxx int blah; using namespace blah; swig-3.0.2/Examples/test-suite/errors/cpp_template_not.stderr0000664000175000017500000000011212343605122024317 0ustar williamwilliamcpp_template_not.i:5: Error: 'blah' is not defined as a template. (cdecl) swig-3.0.2/Examples/test-suite/errors/cpp_missing_rtemplate.i0000664000175000017500000000005212343605122024302 0ustar williamwilliam%module xxx int foo(vector; swig-3.0.2/Examples/test-suite/errors/cpp_private_inherit.i0000664000175000017500000000013412343605122023751 0ustar williamwilliam%module xxx class Foo { }; class Bar : private Foo { }; class Spam : protected Foo { }; swig-3.0.2/Examples/test-suite/errors/cpp_using_undef.stderr0000664000175000017500000000020212343605122024132 0ustar williamwilliamcpp_using_undef.i:4: Error: Nothing known about namespace 'foo' cpp_using_undef.i:3: Warning 315: Nothing known about 'foo::bar'. swig-3.0.2/Examples/test-suite/errors/c_extra_rblock.i0000664000175000017500000000004412343605122022674 0ustar williamwilliam%module xxx int foo(int x); %} swig-3.0.2/Examples/test-suite/errors/pp_missing_file.i0000664000175000017500000000005412343605122023063 0ustar williamwilliam%module test %include "missing_filename.i" swig-3.0.2/Examples/test-suite/errors/pp_deprecated.stderr0000664000175000017500000000046312343605122023572 0ustar williamwilliampp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead. pp_deprecated.i:4: Error: Unable to find 'ext;' pp_deprecated.i:6: Warning 204: CPP #warning, "Print this warning". pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing. swig-3.0.2/Examples/test-suite/errors/swig_typemap_copy.i0000664000175000017500000000004612343605122023457 0ustar williamwilliam%module xxx %typemap(in) int = blah; swig-3.0.2/Examples/test-suite/errors/c_varargs.stderr0000664000175000017500000000000012343605122022725 0ustar williamwilliamswig-3.0.2/Examples/test-suite/errors/cpp_overload_const.i0000664000175000017500000000046412343605122023604 0ustar williamwilliam%module xxx void check(const int *v) {} void check(int *v) {} void check(int &v) {} void check(const int &v) {} // note: no warning as marshalled by value struct OverStruct {}; void check(const OverStruct *v) {} void check(OverStruct *v) {} void check(OverStruct &v) {} void check(const OverStruct &v) {} swig-3.0.2/Examples/test-suite/errors/pp_macro_rparen.i0000664000175000017500000000004512343605122023063 0ustar williamwilliam%module xxx #define foo(a,x 3 swig-3.0.2/Examples/test-suite/errors/pp_pragma.i0000664000175000017500000000004712343605122021664 0ustar williamwilliam%module xxx #pragma SWIG rubbish() swig-3.0.2/Examples/test-suite/errors/c_deprecated.i0000664000175000017500000000006512343605122022320 0ustar williamwilliam%module xxx int foo(%val int *x, %out int *y); swig-3.0.2/Examples/test-suite/errors/pp_macro_badchar.i0000664000175000017500000000010212343605122023152 0ustar williamwilliam%module xxx #define f@oo(a,x) a + x #define foo(a@,x) a + x swig-3.0.2/Examples/test-suite/errors/pp_macro_defined_unterminated.stderr0000664000175000017500000000011112343605122027016 0ustar williamwilliampp_macro_defined_unterminated.i:4: Error: Unterminated call to 'defined' swig-3.0.2/Examples/test-suite/errors/pp_unterm_char.i0000664000175000017500000000004312343605122022720 0ustar williamwilliam%module xxx const char x = 'H swig-3.0.2/Examples/test-suite/errors/cpp_inherit.i0000664000175000017500000000102212343605122022214 0ustar williamwilliam%module xxx %inline %{ struct A5; int A6; template struct A7 { }; template struct A8 { }; struct A0 : public A1 , A2, private A3 , private A4 , A5 , A6 , A7 , protected A8 { }; struct A1 { }; class B1 {}; class B0 : B1, B2 { }; struct Recursive : Recursive { }; %} template class Base {}; %template() Base; class Derived : public Base {}; class Derived2 : public Base {}; %template(BaseDouble) Base; swig-3.0.2/Examples/test-suite/errors/pp_macro_missing_expression.i0000664000175000017500000000026112343605122025524 0ustar williamwilliam// Test "Missing identifier for ..." errrors %module xxx #ifdef #endif #ifndef #endif #if #endif #if defined(AAA) #elif #endif #define BBB #if !defined(BBB) #elif #endif swig-3.0.2/Examples/test-suite/errors/c_class.i0000664000175000017500000000004412343605122021322 0ustar williamwilliam%module xxx int class(int x); swig-3.0.2/Examples/test-suite/errors/c_enum_badvalue.stderr0000664000175000017500000000010312343605122024073 0ustar williamwilliamc_enum_badvalue.i:6: Error: Type error. Expecting an integral type swig-3.0.2/Examples/test-suite/errors/c_default_error.i0000664000175000017500000000005012343605122023047 0ustar williamwilliam%module xxx int foo(int x = 42 || 3); swig-3.0.2/Examples/test-suite/errors/cpp_inline_namespace.i0000664000175000017500000000010012343605122024040 0ustar williamwilliam%module xxx namespace foo { %inline %{ int bar(int x) { } %} } swig-3.0.2/Examples/test-suite/errors/cpp_nobase.stderr0000664000175000017500000000037212343605122023103 0ustar williamwilliamcpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored. cpp_nobase.i:6: Warning 401: Nothing known about base class 'Bar< int >'. Ignored. cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using %template. swig-3.0.2/Examples/test-suite/errors/pp_defined.i0000664000175000017500000000006612343605122022014 0ustar williamwilliam%module xxx #if defined() #endif #if defined #endif swig-3.0.2/Examples/test-suite/errors/pp_macro_unterminated.stderr0000664000175000017500000000011112343605122025340 0ustar williamwilliampp_macro_unterminated.i:5: Error: Unterminated call invoking macro 'foo' swig-3.0.2/Examples/test-suite/errors/pp_constant.stderr0000664000175000017500000000074712343605122023330 0ustar williamwilliampp_constant.i:9: Warning 305: Bad constant value (ignored). pp_constant.i:15: Warning 305: Bad constant value (ignored). pp_constant.i:23: Warning 305: Bad constant value (ignored). pp_constant.i:29: Warning 305: Bad constant value (ignored). pp_constant.i:35: Warning 305: Bad constant value (ignored). pp_constant.i:42: Warning 305: Bad constant value (ignored). pp_constant.i:46: Warning 305: Bad constant value (ignored). pp_constant.i:49: Warning 305: Bad constant value (ignored). swig-3.0.2/Examples/test-suite/errors/pp_macro_badchar.stderr0000664000175000017500000000010612343605122024231 0ustar williamwilliampp_macro_badchar.i:4: Error: Illegal character in macro argument name swig-3.0.2/Examples/test-suite/errors/swig_typemap_old.stderr0000664000175000017500000000073712343605122024345 0ustar williamwilliamswig_typemap_old.i:6: Warning 450: Deprecated typemap feature ($source/$target). swig_typemap_old.i:6: Warning 450: The use of $source and $target in a typemap declaration is deprecated. For typemaps related to argument input (in,ignore,default,arginit,check), replace $source by $input and $target by $1. For typemaps related to return values (out, argout,ret,except), replace $source by $1 and $target by $result. See the file Doc/Manual/Typemaps.html for complete details. swig-3.0.2/Examples/test-suite/errors/c_extra_rbrace.stderr0000664000175000017500000000007012343605122023730 0ustar williamwilliamc_extra_rbrace.i:5: Error: Syntax error. Extraneous '}' swig-3.0.2/Examples/test-suite/errors/swig_typemap_warn.i0000664000175000017500000000057512343605122023463 0ustar williamwilliam%module xxx %typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name ($1) - argnum: $argnum &1_ltype: $&1_ltype descriptor: $1_descriptor") int "" %typemap(out, warning="1001:Test warning for 'out' typemap for $1_type $1_name ($1) - name: $name symname: $symname &1_ltype: $&1_ltype descriptor: $1_descriptor") double "" double mmm(int abc, short def, int); swig-3.0.2/Examples/test-suite/errors/c_extra_rbrace.i0000664000175000017500000000004012343605122022652 0ustar williamwilliam%module xxx int foo(int); } swig-3.0.2/Examples/test-suite/errors/c_default_error.stderr0000664000175000017500000000000012343605122024115 0ustar williamwilliamswig-3.0.2/Examples/test-suite/errors/pp_missing_enddef.stderr0000664000175000017500000000011512343605122024442 0ustar williamwilliampp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3 swig-3.0.2/Examples/test-suite/errors/pp_misplaced_elif.stderr0000664000175000017500000000014012343605122024422 0ustar williamwilliampp_misplaced_elif.i:4: Error: Misplaced #elif. pp_misplaced_elif.i:6: Error: Extraneous #endif. swig-3.0.2/Examples/test-suite/errors/swig_typemap_copy.stderr0000664000175000017500000000010112343605122024522 0ustar williamwilliamswig_typemap_copy.i:3: Error: Can't copy typemap (in) blah = int swig-3.0.2/Examples/test-suite/errors/swig_fragment_missing.stderr0000664000175000017500000000010312343605122025347 0ustar williamwilliamswig_fragment_missing.i:3: Warning 490: Fragment 'awol' not found. swig-3.0.2/Examples/test-suite/errors/pp_macro_inline_unterminated.stderr0000664000175000017500000000022412343605122026703 0ustar williamwilliampp_macro_inline_unterminated.i:9: Error: Unterminated call invoking macro 'foo' pp_macro_inline_unterminated.i:12: Error: Syntax error in input(3). swig-3.0.2/Examples/test-suite/errors/cpp_extend_undefined.i0000664000175000017500000000006412343605122024067 0ustar williamwilliam%module xxx %extend foo { int bar() { } }; swig-3.0.2/Examples/test-suite/errors/c_missing_rbrace.i0000664000175000017500000000005612343605122023207 0ustar williamwilliam%module xxx int foo(int x) { int y; swig-3.0.2/Examples/test-suite/errors/cpp_inherit.stderr0000664000175000017500000000320112343605122023270 0ustar williamwilliamcpp_inherit.i:18: Warning 309: private inheritance from base 'A3' (ignored). cpp_inherit.i:20: Warning 309: private inheritance from base 'A4' (ignored). cpp_inherit.i:28: Warning 309: protected inheritance from base 'A8< double >' (ignored). cpp_inherit.i:39: Warning 319: No access specifier given for base class 'B1' (ignored). cpp_inherit.i:40: Warning 319: No access specifier given for base class 'B2< int >' (ignored). cpp_inherit.i:15: Warning 401: Base class 'A1' undefined. cpp_inherit.i:33: Warning 401: 'A1' must be defined before it is used as a base class. cpp_inherit.i:17: Warning 401: Nothing known about base class 'A2'. Ignored. cpp_inherit.i:22: Warning 402: Base class 'A5' is incomplete. cpp_inherit.i:4: Warning 402: Only forward declaration 'A5' was found. cpp_inherit.i:24: Error: 'A6' is not a valid base class. cpp_inherit.i:5: Error: See definition of 'A6'. cpp_inherit.i:24: Warning 401: Nothing known about base class 'A6'. Ignored. cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignored. cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template. cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'. cpp_inherit.i:52: Warning 401: Base class 'Base< int >' has no name as it is an empty template instantiated with '%template()'. Ignored. cpp_inherit.i:51: Warning 401: The %template directive must be written before 'Base< int >' is used as a base class and be declared with a name. cpp_inherit.i:53: Warning 401: Base class 'Base< double >' undefined. cpp_inherit.i:54: Warning 401: 'Base< double >' must be defined before it is used as a base class. swig-3.0.2/Examples/test-suite/errors/cpp_extend_destructors.stderr0000664000175000017500000000335512343605122025570 0ustar williamwilliamcpp_extend_destructors.i:8: Warning 302: Identifier '~AStruct' redefined by %extend (ignored), cpp_extend_destructors.i:5: Warning 302: %extend definition of '~AStruct'. cpp_extend_destructors.i:14: Warning 302: Identifier '~BStruct' redefined (ignored), cpp_extend_destructors.i:13: Warning 302: previous definition of '~BStruct'. cpp_extend_destructors.i:87: Warning 302: Identifier '~JStruct' redefined (ignored), cpp_extend_destructors.i:85: Warning 302: previous definition of '~JStruct'. cpp_extend_destructors.i:100: Warning 302: Identifier '~LStruct' redefined (ignored), cpp_extend_destructors.i:98: Warning 302: previous definition of '~LStruct'. cpp_extend_destructors.i:24: Warning 521: Illegal destructor name CStruct::~NOT_CStruct(). Ignored. cpp_extend_destructors.i:30: Warning 521: Illegal destructor name DStruct::~NOT_DStruct(). Ignored. cpp_extend_destructors.i:44: Warning 521: Illegal destructor name EStruct::~NOT_EStruct(). Ignored. cpp_extend_destructors.i:50: Warning 521: Illegal destructor name FStruct::~NOT_FStruct(). Ignored. cpp_extend_destructors.i:65: Warning 521: Illegal destructor name GStruct::~NOT_GStruct(). Ignored. cpp_extend_destructors.i:72: Warning 521: Illegal destructor name HStruct::~NOT_HStruct(). Ignored. cpp_extend_destructors.i:81: Warning 521: Illegal destructor name IStruct::~NOT_IStruct(). Ignored. cpp_extend_destructors.i:86: Warning 521: Illegal destructor name JStruct::~NOT_JStruct(). Ignored. cpp_extend_destructors.i:92: Warning 521: Illegal destructor name KStruct::~NOT_KStruct(). Ignored. cpp_extend_destructors.i:99: Warning 521: Illegal destructor name LStruct< int >::~NOT_LStruct(). Ignored. cpp_extend_destructors.i:99: Warning 521: Illegal destructor name LStruct< short >::~NOT_LStruct(). Ignored. swig-3.0.2/Examples/test-suite/errors/cpp_no_access.i0000664000175000017500000000004212343605122022510 0ustar williamwilliam%module xxx class Bar : foo { }; swig-3.0.2/Examples/test-suite/errors/pp_macro_args.i0000664000175000017500000000006312343605122022530 0ustar williamwilliam%module xxx #define foo(a,x) a x #if foo #endif swig-3.0.2/Examples/test-suite/errors/c_empty_char.stderr0000664000175000017500000000006212343605122023423 0ustar williamwilliamc_empty_char.i:3: Error: Empty character constant swig-3.0.2/Examples/test-suite/errors/cpp_nested_template.stderr0000664000175000017500000000043312343605122025007 0ustar williamwilliamcpp_nested_template.i:9: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template(). cpp_nested_template.i:18: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template(). swig-3.0.2/Examples/test-suite/errors/cpp_overload.stderr0000664000175000017500000000000012343605122023433 0ustar williamwilliamswig-3.0.2/Examples/test-suite/errors/cpp_macro_locator.i0000664000175000017500000000356712343605122023416 0ustar williamwilliam%module xxx // Test the SWIG preprocessor locator effects on reporting line numbers in warnings when processing SWIG (multiline) macros // The ignored overloaded methods warnings should have the correct line number reporting // {} blocks are tested, where the preprocessor expands the macros %define CLASSMACRO(KLASS) class KLASS { public: KLASS() {} void methodX(int *) {} void methodX(const int *) {} }; %enddef %{ #define CLASSMACRO(KLASS) \ class KLASS \ { \ public: \ KLASS() {} \ void methodX(int *) {} \ void methodX(const int *) {} \ }; %} %{ #define VARIABLEMACRO(NAME) double NAME; struct Outer { struct Inner { VARIABLEMACRO(MyInnerVar) }; }; void overload1(int *) {} void overload1(const int *) {} void overload2(int *) {} void overload2(const int *) {} void overload3(int *) {} void overload3(const int *) {} %} %define VARIABLEMACRO(NAME) double NAME; %enddef struct Outer { struct Inner { VARIABLEMACRO(MyInnerVar) }; }; void overload1(int *) {} void overload1(const int *) {} %fragment("FragmentMethod", "header") { void fragmentMethod() { } VARIABLEMACRO(fragVar) } void overload2(int *) {} void overload2(const int *) {} %inline { CLASSMACRO(Klass1) } #warning inline warning message one void overload3(int *) {} void overload3(const int *) {} %{ struct Classic { Classic() { VARIABLEMACRO(inconstructor) } double value; }; void overload4(int *) {} void overload4(const int *) {} void overload5(int *) {} void overload5(const int *) {} %} struct Classic { Classic() { VARIABLEMACRO(inconstructor) } double value; }; void overload4(int *) {} void overload4(const int *) {} %inline { void overloadinline1(int *) {} void overloadinline1(const int *) {} CLASSMACRO(Klass2) #warning an inline warning message 2 void overloadinline2(int *) {} void overloadinline2(const int *) {} } void overload5(int *) {} void overload5(const int *) {} swig-3.0.2/Examples/test-suite/errors/pp_macro_redef.i0000664000175000017500000000017412343605122022664 0ustar williamwilliam%module xxx #define foo(a,x) a+x #define foo 4 /* Should not generate an error */ #define foo 4 swig-3.0.2/Examples/test-suite/errors/pp_macro_unexpected_tokens.i0000664000175000017500000000035012343605122025322 0ustar williamwilliam// Test "Unexpected tokens after ..." errors %module xxx #ifndef AAA #endif rubbish #ifdef AAA #endif rubbish #ifdef AAA #else rubbish #endif #define BBB #ifdef BBB #else #endif rubbish #if !defined(BBB) #else rubbish #endif swig-3.0.2/Examples/test-suite/errors/pp_badeval.stderr0000664000175000017500000000020212343605122023057 0ustar williamwilliampp_badeval.i:4: Warning 202: Could not evaluate expression 'FOO==4+' pp_badeval.i:4: Warning 202: Error: 'Expected an expression' swig-3.0.2/Examples/test-suite/errors/cpp_overload.i0000664000175000017500000000024212343605122022370 0ustar williamwilliam%module xxx int foo(int x); int foo(double x); class Foo { public: int bar(int); int bar(double); }; class Spam { public: Spam(); Spam(int); }; swig-3.0.2/Examples/test-suite/errors/swig_insert_bad.i0000664000175000017500000000005712343605122023062 0ustar williamwilliam%module xxx %insert("foobar") %{ some code %} swig-3.0.2/Examples/test-suite/errors/cpp_nested_template.i0000664000175000017500000000031712343605122023735 0ustar williamwilliam%module xxx template struct Temply { T thing; }; struct A { int var; %template(TemplyInt) Temply; }; struct B { int var; }; %extend B { %template(TemplyDouble) Temply; } swig-3.0.2/Examples/test-suite/errors/pp_pragma.stderr0000664000175000017500000000006512343605122022737 0ustar williamwilliampp_pragma.i:4: Error: Unknown SWIG pragma: rubbish() swig-3.0.2/Examples/test-suite/errors/pp_unterm_string.i0000664000175000017500000000004712343605122023315 0ustar williamwilliam%module xxx const char *x = "Hello swig-3.0.2/Examples/test-suite/errors/cpp_extra_brackets2.stderr0000664000175000017500000000007212343605122024714 0ustar williamwilliamcpp_extra_brackets2.i:6: Error: Syntax error in input(3). swig-3.0.2/Examples/test-suite/errors/cpp_namespace_aliasundef.stderr0000664000175000017500000000007612343605122025764 0ustar williamwilliamcpp_namespace_aliasundef.i:3: Error: Unknown namespace 'blah' swig-3.0.2/Examples/test-suite/errors/pp_missing_rblock.i0000664000175000017500000000003212343605122023414 0ustar williamwilliam%module xxx %{ int x; swig-3.0.2/Examples/test-suite/errors/pp_illegal_argument.stderr0000664000175000017500000000031512343605122025001 0ustar williamwilliampp_illegal_argument.i:6: Error: Illegal macro argument name '..' pp_illegal_argument.i:10: Error: Illegal macro argument name '..' pp_illegal_argument.i:16: Error: Illegal character in macro argument name swig-3.0.2/Examples/test-suite/errors/c_missing_rbrace.stderr0000664000175000017500000000016712343605122024265 0ustar williamwilliamc_missing_rbrace.i:3: Error: Missing '}'. Reached end of input. c_missing_rbrace.i:3: Error: Syntax error in input(1). swig-3.0.2/Examples/test-suite/errors/cpp_extra_brackets.stderr0000664000175000017500000000007112343605122024631 0ustar williamwilliamcpp_extra_brackets.i:5: Error: Syntax error in input(3). swig-3.0.2/Examples/test-suite/errors/pp_deprecated.i0000664000175000017500000000012212343605122022507 0ustar williamwilliam%module xxx %extern ext; #warning Print this warning #error This is an error swig-3.0.2/Examples/test-suite/errors/cpp_namespace_alias.i0000664000175000017500000000011312343605122023657 0ustar williamwilliam%module xxx namespace blah { } namespace B = blah; namespace B { } swig-3.0.2/Examples/test-suite/errors/pp_misplaced_else.stderr0000664000175000017500000000014012343605122024433 0ustar williamwilliampp_misplaced_else.i:4: Error: Misplaced #else. pp_misplaced_else.i:6: Error: Extraneous #endif. swig-3.0.2/Examples/test-suite/errors/pp_missing_file.stderr0000664000175000017500000000010012343605122024126 0ustar williamwilliampp_missing_file.i:3: Error: Unable to find 'missing_filename.i' swig-3.0.2/Examples/test-suite/errors/cpp_using_not.stderr0000664000175000017500000000006512343605122023640 0ustar williamwilliamcpp_using_not.i:4: Error: 'blah' is not a namespace. swig-3.0.2/Examples/test-suite/errors/c_extra_rblock.stderr0000664000175000017500000000006512343605122023752 0ustar williamwilliamc_extra_rblock.i:5: Error: Syntax error in input(1). swig-3.0.2/Examples/test-suite/errors/nomodule.stderr0000664000175000017500000000006312343605122022611 0ustar williamwilliamNo module name specified using %module or -module. swig-3.0.2/Examples/test-suite/errors/pp_misplaced_else.i0000664000175000017500000000004312343605122023362 0ustar williamwilliam%module xxx #else int x; #endif swig-3.0.2/Examples/test-suite/errors/c_bad_name.stderr0000664000175000017500000000020412343605122023014 0ustar williamwilliamc_bad_name.i:3: Warning 121: %name is deprecated. Use %rename instead. c_bad_name.i:3: Error: Missing argument to %name directive. swig-3.0.2/Examples/test-suite/errors/cpp_template_repeat.i0000664000175000017500000000015312343605122023731 0ustar williamwilliam%module xxx template T blah(T x) { }; %template(iblah) blah; %template(iiblah) blah; swig-3.0.2/Examples/test-suite/errors/cpp_template_nargs.stderr0000664000175000017500000000016412343605122024640 0ustar williamwilliamcpp_template_nargs.i:5: Error: Template 'blah' undefined. cpp_template_nargs.i:6: Error: Template 'blah' undefined. swig-3.0.2/Examples/test-suite/errors/cpp_nobase.i0000664000175000017500000000011412343605122022022 0ustar williamwilliam%module xxx class Foo : public Bar { }; class Spam : public Bar { }; swig-3.0.2/Examples/test-suite/errors/pp_macro_rparen.stderr0000664000175000017500000000007412343605122024140 0ustar williamwilliampp_macro_rparen.i:3: Error: Missing ')' in macro parameters swig-3.0.2/Examples/test-suite/errors/pp_missing_enddef.i0000664000175000017500000000004312343605122023367 0ustar williamwilliam%module xxx %define FOO int x; swig-3.0.2/Examples/test-suite/errors/cpp_shared_ptr.i0000664000175000017500000000050612343605122022713 0ustar williamwilliam%module cpp_shared_ptr %include %shared_ptr(B); %shared_ptr(C); %inline %{ #include #include struct A { virtual ~A() {} }; struct B { virtual ~B() {} }; struct C : B, A { virtual ~C() {} }; struct D : C { virtual ~D() {} }; %} swig-3.0.2/Examples/test-suite/errors/cpp_overload_const.stderr0000664000175000017500000000156612343605122024663 0ustar williamwilliamcpp_overload_const.i:4: Warning 509: Overloaded method check(int *) effectively ignored, cpp_overload_const.i:3: Warning 509: as it is shadowed by check(int const *). cpp_overload_const.i:5: Warning 509: Overloaded method check(int &) effectively ignored, cpp_overload_const.i:3: Warning 509: as it is shadowed by check(int const *). cpp_overload_const.i:10: Warning 509: Overloaded method check(OverStruct *) effectively ignored, cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *). cpp_overload_const.i:11: Warning 509: Overloaded method check(OverStruct &) effectively ignored, cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *). cpp_overload_const.i:12: Warning 509: Overloaded method check(OverStruct const &) effectively ignored, cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *). swig-3.0.2/Examples/test-suite/errors/pp_macro_nargs.stderr0000664000175000017500000000035712343605122023767 0ustar williamwilliampp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments pp_macro_nargs.i:8: Error: Macro 'foo' expects 2 arguments pp_macro_nargs.i:10: Error: Macro 'bar' expects 1 argument pp_macro_nargs.i:11: Error: Macro 'spam' expects no arguments swig-3.0.2/Examples/test-suite/errors/pp_missing_endif.stderr0000664000175000017500000000012112343605122024277 0ustar williamwilliampp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3 swig-3.0.2/Examples/test-suite/errors/cpp_template_undef.stderr0000664000175000017500000000007212343605122024625 0ustar williamwilliamcpp_template_undef.i:3: Error: Template 'blah' undefined. swig-3.0.2/Examples/test-suite/errors/cpp_namespace_aliasnot.stderr0000664000175000017500000000007512343605122025462 0ustar williamwilliamcpp_namespace_aliasnot.i:4: Error: 'blah' is not a namespace swig-3.0.2/Examples/test-suite/errors/cpp_extend_destructors.i0000664000175000017500000000240212343605122024505 0ustar williamwilliam%module xxx ///////////////////////////// %extend AStruct { ~AStruct() {} } struct AStruct { ~AStruct() {} }; ///////////////////////////// struct BStruct { ~BStruct() {} ~BStruct() {} }; ///////////////////////////// struct CStruct { }; %extend CStruct { ~NOT_CStruct() { delete $self; } } %extend DStruct { ~NOT_DStruct() { delete $self; } } struct DStruct { }; ///////////////////////////// struct EStruct { ~EStruct() {} }; %extend EStruct { ~NOT_EStruct() { delete $self; } } %extend FStruct { ~NOT_FStruct() { delete $self; } } struct FStruct { ~FStruct() {} }; ///////////////////////////// struct GStruct { }; %extend GStruct { ~GStruct() {} ~NOT_GStruct() { delete $self; } } %extend HStruct { ~HStruct() {} ~NOT_HStruct() { delete $self; } } struct HStruct { }; ///////////////////////////// struct IStruct { ~IStruct() {} ~NOT_IStruct() {} }; struct JStruct { ~JStruct() {} ~NOT_JStruct() {} ~JStruct() {} }; ///////////////////////////// struct KStruct { ~NOT_KStruct() {} }; ///////////////////////////// template struct LStruct { ~LStruct() {} ~NOT_LStruct() {} ~LStruct() {} }; %template(LStructInt) LStruct; %template(LStructShort) LStruct; swig-3.0.2/Examples/test-suite/errors/c_redefine.stderr0000664000175000017500000000061612343605122023056 0ustar williamwilliamc_redefine.i:4: Warning 302: Identifier 'foo' redefined (ignored), c_redefine.i:3: Warning 302: previous definition of 'foo'. c_redefine.i:8: Warning 302: Identifier 'bar' redefined (ignored), c_redefine.i:6: Warning 302: previous definition of 'bar'. c_redefine.i:14: Warning 322: Redundant redeclaration of 'bar' (Renamed from 'spam'), c_redefine.i:6: Warning 322: previous declaration of 'bar'. swig-3.0.2/Examples/test-suite/errors/c_varargs.i0000664000175000017500000000004212343605122021660 0ustar williamwilliam%module xxx int foo(int x, ...); swig-3.0.2/Examples/test-suite/errors/cpp_no_return_type.i0000664000175000017500000000012712343605122023633 0ustar williamwilliam%module xxx struct R {}; struct S { R() {} }; typedef struct U { UU() {} } UU; swig-3.0.2/Examples/test-suite/errors/c_long_short.i0000664000175000017500000000016412343605122022376 0ustar williamwilliam%module xxx int foo(long short x); int bar(short long y); int spam(long long long x); int grok(short short int x); swig-3.0.2/Examples/test-suite/errors/cpp_missing_rparenthesis.i0000664000175000017500000000013312343605122025014 0ustar williamwilliam%module xxx %inline %{ class Klass { Klass(int i) : m_i( { } }; %} void something() { } swig-3.0.2/Examples/test-suite/errors/cpp_recursive_typedef.stderr0000664000175000017500000000017712343605122025366 0ustar williamwilliam:1: Error: Recursive typedef detected resolving 'pds *' to 'std::set< pds > *' to 'std::set< std::set< pds > > *' and so on... swig-3.0.2/Examples/test-suite/errors/cpp_bad_extern.stderr0000664000175000017500000000021412343605122023742 0ustar williamwilliamcpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL". cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL". swig-3.0.2/Examples/test-suite/errors/swig_extend.stderr0000664000175000017500000000207212343605122023311 0ustar williamwilliamswig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name 'StructBName' should be used instead of the typedef name 'StructB'. swig_extend.i:45: Warning 326: Deprecated %extend name used - the struct name 'stru_struct' should be used instead of the typedef name 'stru'. swig_extend.i:56: Warning 326: Deprecated %extend name used - the union name 'uni_union' should be used instead of the typedef name 'uni'. swig_extend.i:34: Warning 303: %extend defined for an undeclared class StructDName. swig_extend.i:50: Warning 522: Use of an illegal constructor name 'stru' in %extend is deprecated, the constructor name should be 'stru_struct'. swig_extend.i:53: Warning 523: Use of an illegal destructor name 'stru' in %extend is deprecated, the destructor name should be 'stru_struct'. swig_extend.i:57: Warning 522: Use of an illegal constructor name 'uni' in %extend is deprecated, the constructor name should be 'uni_union'. swig_extend.i:58: Warning 523: Use of an illegal destructor name 'uni' in %extend is deprecated, the destructor name should be 'uni_union'. swig-3.0.2/Examples/test-suite/errors/pp_misplaced_elif.i0000664000175000017500000000005412343605122023353 0ustar williamwilliam%module xxx #elif foo == 3 int x; #endif swig-3.0.2/Examples/test-suite/errors/pp_illegal_argument.i0000664000175000017500000000021312343605122023723 0ustar williamwilliam%module xxx %define MISSING_DOT1(a, b, ..) xxx %enddef %define MISSING_DOT2(..) xxx %enddef %define BAD_ARGNAME( a, b{c ) xxx %enddef swig-3.0.2/Examples/test-suite/errors/cpp_private_defvalue.stderr0000664000175000017500000000000012343605122025145 0ustar williamwilliamswig-3.0.2/Examples/test-suite/errors/c_missing_semi.stderr0000664000175000017500000000006512343605122023761 0ustar williamwilliamc_missing_semi.i:3: Error: Syntax error in input(1). swig-3.0.2/Examples/test-suite/errors/pp_macro_missing_expression.stderr0000664000175000017500000000054212343605122026601 0ustar williamwilliampp_macro_missing_expression.i:4: Error: Missing identifier for #ifdef. pp_macro_missing_expression.i:7: Error: Missing identifier for #ifndef. pp_macro_missing_expression.i:10: Error: Missing expression for #if. pp_macro_missing_expression.i:14: Error: Missing expression for #elif. pp_macro_missing_expression.i:21: Error: Missing expression for #elif. swig-3.0.2/Examples/test-suite/errors/cpp_extend_redefine.stderr0000664000175000017500000000045312343605122024764 0ustar williamwilliamcpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored), cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'. cpp_extend_redefine.i:14: Warning 322: Redundant redeclaration of 'spam', cpp_extend_redefine.i:10: Warning 322: previous declaration of 'spam'. swig-3.0.2/Examples/test-suite/errors/cpp_namespace_aliasundef.i0000664000175000017500000000004112343605122024701 0ustar williamwilliam%module xxx namespace B = blah; swig-3.0.2/Examples/test-suite/errors/pp_missing_rblock.stderr0000664000175000017500000000012012343605122024465 0ustar williamwilliampp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3 swig-3.0.2/Examples/test-suite/errors/c_empty_char.i0000664000175000017500000000004312343605122022347 0ustar williamwilliam%module xxx int foo(int x = ''); swig-3.0.2/Examples/test-suite/errors/cpp_template_argname.stderr0000664000175000017500000000000012343605122025125 0ustar williamwilliamswig-3.0.2/Examples/test-suite/errors/swig_apply_nargs.i0000664000175000017500000000013312343605122023262 0ustar williamwilliam%module xxx %typemap(in) (char *str, int len) { } %apply (char *str, int len) { int x }; swig-3.0.2/Examples/test-suite/errors/c_bad_native.i0000664000175000017500000000004512343605122022312 0ustar williamwilliam%module xxx %native(foo) int foo; swig-3.0.2/Examples/test-suite/errors/c_missing_semi.i0000664000175000017500000000005412343605122022704 0ustar williamwilliam%module xxx int foo(int) int bar(int,int); swig-3.0.2/Examples/test-suite/errors/pp_macro_unexpected_tokens.stderr0000664000175000017500000000066412343605122026405 0ustar williamwilliampp_macro_unexpected_tokens.i:5: Warning 206: Unexpected tokens after #endif directive. pp_macro_unexpected_tokens.i:8: Warning 206: Unexpected tokens after #endif directive. pp_macro_unexpected_tokens.i:11: Warning 206: Unexpected tokens after #else directive. pp_macro_unexpected_tokens.i:18: Warning 206: Unexpected tokens after #endif directive. pp_macro_unexpected_tokens.i:21: Warning 206: Unexpected tokens after #else directive. swig-3.0.2/Examples/test-suite/errors/pp_macro_unterminated.i0000664000175000017500000000006112343605122024271 0ustar williamwilliam%module xxx #define foo(a,x) a+x foo(3, swig-3.0.2/Examples/test-suite/errors/pp_unterm_comment.i0000664000175000017500000000003112343605122023442 0ustar williamwilliam%module xxx /* Hello swig-3.0.2/Examples/test-suite/errors/cpp_recursive_typedef.i0000664000175000017500000000007312343605122024306 0ustar williamwilliam%module cpp_recursive_typedef typedef std::set pds; swig-3.0.2/Examples/test-suite/errors/cpp_no_access.stderr0000664000175000017500000000013212343605122023563 0ustar williamwilliamcpp_no_access.i:3: Warning 319: No access specifier given for base class 'foo' (ignored). swig-3.0.2/Examples/test-suite/errors/pp_macro_defined_unterminated.i0000664000175000017500000000004412343605122025750 0ustar williamwilliam%module xxx #if defined(a #endif swig-3.0.2/Examples/test-suite/errors/cpp_extra_brackets2.i0000664000175000017500000000025212343605122023641 0ustar williamwilliam%module cpp_extra_brackets // Extra brackets was segfaulting in SWIG-3.0.0 struct ABC { ; ))) int operator<<(ABC &) { return 0; } int operator>>(ABC &) { return 0; } }; swig-3.0.2/Examples/test-suite/errors/pp_macro_nargs.i0000664000175000017500000000021112343605122022701 0ustar williamwilliam%module xxx #define foo(a,x) a x #define bar(x) x #define spam() /**/ foo(3) foo(3,4,5) bar() bar(2,3) spam(1) swig-3.0.2/Examples/test-suite/errors/swig_identifier.stderr0000664000175000017500000000013512343605122024142 0ustar williamwilliamswig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier. swig-3.0.2/Examples/test-suite/errors/pp_badeval.i0000664000175000017500000000006312343605122022011 0ustar williamwilliam%module xxx #if FOO==4 #elif FOO==4+ #endif swig-3.0.2/Examples/test-suite/errors/pp_macro_expansion_multiline.i0000664000175000017500000000075212343605122025667 0ustar williamwilliam%module xxx // Testing macros split over multiple lines - ensure the warning message for the ignored functions contain the correct line numbering #define MYMACRO(NAME, A, B, C) void NAME(int A, int B, int C); MYMACRO(funk, x, y, z ) void foo(int *); void foo(const int *); %define MYSWIGMACRO(A, B, C) MYMACRO(funk1, AA, BB, CC) MYMACRO(funk2, AA, BB, CC) %enddef MYSWIGMACRO(xx, yy, zz) void bar(int *); void bar(const int *); swig-3.0.2/Examples/test-suite/errors/cpp_shared_ptr.stderr0000664000175000017500000000046212343605122023767 0ustar williamwilliamcpp_shared_ptr.i:20: Warning 520: Base class 'A' of 'C' is not similarly marked as a smart pointer. cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'C' is not similarly marked as a smart pointer. cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'B' is not similarly marked as a smart pointer. swig-3.0.2/Examples/test-suite/errors/c_extra_unsigned.i0000664000175000017500000000015312343605122023235 0ustar williamwilliam%module xxx int foo(unsigned unsigned int x); int bar(signed signed y); int spam(unsigned signed int x); swig-3.0.2/Examples/test-suite/errors/swig_typemap_warn.stderr0000664000175000017500000000175112343605122024533 0ustar williamwilliamswig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1001: Test warning for 'out' typemap for double mmm (result) - name: mmm symname: mmm &1_ltype: double * descriptor: SWIGTYPE_double swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int swig-3.0.2/Examples/test-suite/errors/cpp_template_not.i0000664000175000017500000000007012343605122023247 0ustar williamwilliam%module xxx int blah; %template(blahi) blah; swig-3.0.2/Examples/test-suite/errors/c_extra_unsigned.stderr0000664000175000017500000000024112343605122024306 0ustar williamwilliamc_extra_unsigned.i:3: Error: Extra unsigned specifier. c_extra_unsigned.i:4: Error: Extra signed specifier. c_extra_unsigned.i:5: Error: Extra signed specifier. swig-3.0.2/Examples/test-suite/errors/c_insert_missing.stderr0000664000175000017500000000007512343605122024331 0ustar williamwilliamc_insert_missing.i:3: Error: Couldn't find 'missing_file.i'. swig-3.0.2/Examples/test-suite/errors/cpp_using_undef.i0000664000175000017500000000006712343605122023070 0ustar williamwilliam%module xxx using foo::bar; using namespace foo; swig-3.0.2/Examples/test-suite/errors/cpp_namespace_alias.stderr0000664000175000017500000000013412343605122024735 0ustar williamwilliamcpp_namespace_alias.i:8: Warning 308: Namespace alias 'B' not allowed here. Assuming 'blah' swig-3.0.2/Examples/test-suite/errors/cpp_extra_brackets.i0000664000175000017500000000020412343605122023554 0ustar williamwilliam%module cpp_extra_brackets // Extra brackets was segfaulting in SWIG-3.0.0 struct ABC { int operator<<(ABC &))) { return 0; } }; swig-3.0.2/Examples/test-suite/errors/cpp_inline_namespace.stderr0000664000175000017500000000012512343605122025122 0ustar williamwilliamcpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed. swig-3.0.2/Examples/test-suite/errors/swig_fragment_missing.i0000664000175000017500000000004112343605122024275 0ustar williamwilliam%module xxx %fragment("awol"); swig-3.0.2/Examples/test-suite/errors/pp_constant.i0000664000175000017500000000136312343605122022250 0ustar williamwilliam%module xxx /* Test preprocessor comments and their effect on line number reporting on later errors */ #define A1 1234 #define A2 1234 /*C comment*/ #define A3 1234 %constant int aaa=; #define B1 1234 #define B2 1234 //C++ comment #define B3 1234 %constant int bbb=; #define C1 1234 #define C2 1234 /*multiline C comment */ #define C3 1234 %constant int ccc=; #define D1 1234 #define /*C Comment*/ D2 1234 #define D3 1234 %constant int ddd=; #define E1 1234 #/*C comment*/define E2 1234 #define E3 1234 %constant int eee=; #define F1 1234 #define F2 1234 \ // C comment #define F3 1234 %constant int fff=; // Test macro ending in /, that is not a C comment terminator #define G1 1234 #define G2 1234 / #define G3 1234 %constant int ggg=; swig-3.0.2/Examples/test-suite/errors/Makefile.in0000664000175000017500000000413312343605122021611 0ustar williamwilliam####################################################################### # Makefile for errors test-suite # # This test-suite is for checking SWIG errors and warnings and uses # Python as the target language. # # It compares the stderr output from SWIG to the contents of the .stderr # file for each test case. The test cases are different to those used by # the language module test-suites. The .i files in this directory are # used instead of those in the parent directory. # # When adding a new test case, be sure to commit the expected output # file (.stderr) in addition to the test case itself. ####################################################################### LANGUAGE = errors ERROR_EXT = newerr srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ # All .i files with prefix 'cpp_' will be treated as C++ input and remaining .i files as C input ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i))) CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES)) C_ERROR_TEST_CASES := $(filter-out $(CPP_ERROR_TEST_CASES), $(ALL_ERROR_TEST_CASES)) ERROR_TEST_CASES := $(CPP_ERROR_TEST_CASES:=.cpptest) \ $(C_ERROR_TEST_CASES:=.ctest) include $(srcdir)/../common.mk # Portable dos2unix / todos for stripping CR TODOS = tr -d '\r' #TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//' # strip source directory from output, so that diffs compare STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||' # Rules for the different types of tests %.cpptest: echo "$(ACTION)ing errors testcase $*" -$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT) %.ctest: echo "$(ACTION)ing errors testcase $*" -$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT) %.clean: @exit 0 clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean @rm -f *.$(ERROR_EXT) *.py swig-3.0.2/Examples/test-suite/errors/pp_macro_inline_unterminated.i0000664000175000017500000000012712343605122025632 0ustar williamwilliam%module xxx %define foo(a,x) int ii; %enddef %inline %{ struct Struct { foo(2, }; %} swig-3.0.2/Examples/test-suite/errors/pp_variable_args.stderr0000664000175000017500000000012312343605122024264 0ustar williamwilliampp_variable_args.i:6: Error: Variable length macro argument must be last parameter swig-3.0.2/Examples/test-suite/errors/cpp_no_return_type.stderr0000664000175000017500000000026012343605122024704 0ustar williamwilliamcpp_no_return_type.i:6: Warning 504: Function S::R() must have a return type. Ignored. cpp_no_return_type.i:10: Warning 504: Function U::UU() must have a return type. Ignored. swig-3.0.2/Examples/test-suite/errors/c_varargs_neg.stderr0000664000175000017500000000010712343605122023566 0ustar williamwilliamc_varargs_neg.i:3: Error: Argument count in %varargs must be positive. swig-3.0.2/Examples/test-suite/errors/cpp_template_argname.i0000664000175000017500000000005312343605122024062 0ustar williamwilliam%module xxx template T blah(T x); swig-3.0.2/Examples/test-suite/errors/pp_macro_expansion.i0000664000175000017500000000023112343605122023575 0ustar williamwilliam%module xxx /* Test line number reporting for multiple macro expansions */ #define MACRO2(a, b) #define MACRO1(NAME) MACRO2(NAME,2,3) MACRO1(abc) swig-3.0.2/Examples/test-suite/errors/c_insert_missing.i0000664000175000017500000000006112343605122023251 0ustar williamwilliam%module xxx %insert("header") "missing_file.i"; swig-3.0.2/Examples/test-suite/errors/cpp_template_partial.i0000664000175000017500000000006612343605122024110 0ustar williamwilliam%module xxx template class vector { }; swig-3.0.2/Examples/test-suite/errors/cpp_template_partial.stderr0000664000175000017500000000012012343605122025152 0ustar williamwilliamcpp_template_partial.i:3: Warning 317: Specialization of non-template 'vector'. swig-3.0.2/Examples/test-suite/errors/pp_macro_expansion_multiline.stderr0000664000175000017500000000056212343605122026741 0ustar williamwilliampp_macro_expansion_multiline.i:13: Warning 509: Overloaded method foo(int const *) effectively ignored, pp_macro_expansion_multiline.i:12: Warning 509: as it is shadowed by foo(int *). pp_macro_expansion_multiline.i:31: Warning 509: Overloaded method bar(int const *) effectively ignored, pp_macro_expansion_multiline.i:30: Warning 509: as it is shadowed by bar(int *). swig-3.0.2/Examples/test-suite/errors/cpp_missing_rtemplate.stderr0000664000175000017500000000007412343605122025361 0ustar williamwilliamcpp_missing_rtemplate.i:4: Error: Syntax error in input(1). swig-3.0.2/Examples/test-suite/errors/nomodule.i0000664000175000017500000000004312343605122021534 0ustar williamwilliam/* No module name */ int foo(int); swig-3.0.2/Examples/test-suite/errors/c_long_short.stderr0000664000175000017500000000027612343605122023455 0ustar williamwilliamc_long_short.i:3: Error: Extra long specifier. c_long_short.i:4: Error: Extra short specifier. c_long_short.i:5: Error: Extra long specifier. c_long_short.i:6: Error: Extra short specifier. swig-3.0.2/Examples/test-suite/errors/c_varargs_neg.i0000664000175000017500000000010012343605122022504 0ustar williamwilliam%module xxx %varargs(0,int x = 0) foo; int foo(int x, ...); swig-3.0.2/Examples/test-suite/errors/pp_variable_args.i0000664000175000017500000000010012343605122023204 0ustar williamwilliam%module xxx %define VARARGS_WRONG(a, x, ..., b) xxx %enddef swig-3.0.2/Examples/test-suite/errors/cpp_template_nargs.i0000664000175000017500000000016412343605122023565 0ustar williamwilliam%module xxx template T blah(T x) { }; %template(blahi) blah; %template(blahf) blah<>; swig-3.0.2/Examples/test-suite/errors/cpp_bad_extern.i0000664000175000017500000000012712343605122022672 0ustar williamwilliam%module xxx extern "INTERCAL" { int foo(int); }; extern "INTERCAL" int blah(int); swig-3.0.2/Examples/test-suite/errors/cpp_private_inherit.stderr0000664000175000017500000000025412343605122025027 0ustar williamwilliamcpp_private_inherit.i:6: Warning 309: private inheritance from base 'Foo' (ignored). cpp_private_inherit.i:9: Warning 309: protected inheritance from base 'Foo' (ignored). swig-3.0.2/Examples/test-suite/errors/c_enum_badvalue.i0000664000175000017500000000007512343605122023030 0ustar williamwilliam%module xxx enum stuff { FOO = 'x', BAR = 3.14159 }; swig-3.0.2/Examples/test-suite/errors/swig_typemap_old.i0000664000175000017500000000007412343605122023264 0ustar williamwilliam%module xxx %typemap(in) int x { $source; $target; } swig-3.0.2/Examples/test-suite/errors/cpp_namespace_aliasnot.i0000664000175000017500000000005312343605122024403 0ustar williamwilliam%module xxx int blah; namespace B = blah; swig-3.0.2/Examples/test-suite/errors/swig_insert_bad.stderr0000664000175000017500000000011312343605122024126 0ustar williamwilliamswig_insert_bad.i:5: Error: Unknown target 'foobar' for %insert directive. swig-3.0.2/Examples/test-suite/errors/c_class.stderr0000664000175000017500000000021712343605122022377 0ustar williamwilliamc_class.i:3: Warning 301: class keyword used, but not in C++ mode. c_class.i:3: Warning 314: 'class' is a python keyword, renaming to '_class' swig-3.0.2/Examples/test-suite/errors/cpp_extend_undefined.stderr0000664000175000017500000000012412343605122025137 0ustar williamwilliamcpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class foo. swig-3.0.2/Examples/test-suite/errors/swig_extend.i0000664000175000017500000000133612343605122022240 0ustar williamwilliam%module xxx typedef struct { int myint; } StructA; typedef struct StructBName { int myint; } StructB; typedef struct StructC { int myint; } StructC; %extend StructA { void method() {} } %extend StructB { void method() {} } %extend StructC { void method() {} } struct StructD { int myint; }; typedef struct StructD StructDName; %extend StructDName { void method() {} } typedef struct stru_struct { int bar; } stru; typedef union uni_union { int un1; double un2; } uni; %extend stru { stru() { stru* s = (stru*)malloc(sizeof(stru)); s->bar = 11; return s; } ~stru() { free($self); } } %extend uni { uni() { return 0; } ~uni() { free($self); } } swig-3.0.2/Examples/test-suite/errors/swig_apply_nargs.stderr0000664000175000017500000000015312343605122024337 0ustar williamwilliamswig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match. swig-3.0.2/Examples/test-suite/errors/pp_macro_redef.stderr0000664000175000017500000000032612343605122023736 0ustar williamwilliampp_macro_redef.i:4: Error: Macro 'foo' redefined, pp_macro_redef.i:3: Error: previous definition of 'foo'. pp_macro_redef.i:7: Error: Macro 'foo' redefined, pp_macro_redef.i:3: Error: previous definition of 'foo'. swig-3.0.2/Examples/test-suite/errors/cpp_extend_redefine.i0000664000175000017500000000022112343605122023702 0ustar williamwilliam%module xxx %extend foo { int bar() { } }; struct foo { int bar(); int spam(); }; %extend foo { int spam(); }; swig-3.0.2/Examples/test-suite/errors/c_redefine.i0000664000175000017500000000020212343605122021772 0ustar williamwilliam%module xxx int foo(int x, int y); int foo; int bar(int x); struct bar { int y; }; %rename(bar) spam; int spam(int); swig-3.0.2/Examples/test-suite/cpp11_strongly_typed_enumerations.i0000664000175000017500000000336012343605122025266 0ustar williamwilliam/* This testcase checks whether SWIG produces the correct wrapper for the strongly typed enums. Enums with the same type are comparable. Enum classes require support for nested classes. */ %module cpp11_strongly_typed_enumerations %warnfilter(302) Val1; %warnfilter(302) Val2; %warnfilter(302) Val3; %warnfilter(302) Val4; /* Forward declarations (illegally accepted by SWIG - oh well!) */ enum Enum1 : short; enum Enum3; enum ; enum : unsigned short; %inline %{ enum class Enum1 { Val1, Val2, Val3 = 100, Val4 /* = 101 */ }; enum class Enum2 : short { Val1, Val2, Val3 = 100, Val4 }; %} // SWIG should fail this one enum Enum2 : unsigned short; // Illegal in C++11, because Enum2 was previously declared with a different type. %inline %{ /* Forward declarations. */ enum Enum4 : unsigned int; // Legal in C++11. enum class Enum5; // Legal in C++11, because enum class declarations have a default type of "int". enum class Enum6 : unsigned int; // Legal C++11. enum Enum4 : unsigned int { Val1, Val2, Val3 = 100, Val4 }; enum class Enum5 { Val1, Val2, Val3 = 100, Val4 }; enum class Enum6 : unsigned int { Val1, Val2, Val3 = 300, Val4 }; typedef enum class Enum7 : unsigned int { Val1, Val2, Val3 = 300, Val4 } Enum7td; // enum inherits from non-primitive type enum class Enum8 : size_t { Val1, Val2, Val3 = 300, Val4 }; template struct TType { typedef T type_name; }; enum class Enum10 : TType::type_name { Val1, Val2, Val3 = 300, Val4 }; // forward declaration, no definition of enum enum class Enum11 : int; struct UseEnum11 { Enum11 myenum11; }; /* TODO enum class MyClass {AAA, BBB, CCC}; namespace Space { enum MyEnum {XXX, YYY, ZZZ}; } struct SSS { MyClass m; }; */ %} swig-3.0.2/Examples/test-suite/python_varargs_typemap.i0000664000175000017500000000320612343605122023207 0ustar williamwilliam%module python_varargs_typemap /* The typemap and action are taken from the "Variable length arguments" * chapter of the SWIG manual. */ %typemap(in) (...)(char *vargs[10]) { int i; int argc; for (i = 0; i < 10; i++) vargs[i] = 0; argc = PyTuple_Size(varargs); if (argc > 10) { PyErr_SetString(PyExc_ValueError, "Too many arguments"); return NULL; } for (i = 0; i < argc; i++) { PyObject *pyobj = PyTuple_GetItem(varargs, i); char *str = 0; %#if PY_VERSION_HEX>=0x03000000 PyObject *pystr; if (!PyUnicode_Check(pyobj)) { PyErr_SetString(PyExc_ValueError, "Expected a string"); return NULL; } pystr = PyUnicode_AsUTF8String(pyobj); str = strdup(PyBytes_AsString(pystr)); Py_XDECREF(pystr); %#else if (!PyString_Check(pyobj)) { PyErr_SetString(PyExc_ValueError, "Expected a string"); return NULL; } str = PyString_AsString(pyobj); %#endif vargs[i] = str; } $1 = (void *)vargs; } %feature("action") testfunc { char **vargs = (char **) arg3; result = testfunc(arg1, arg2, vargs[0], vargs[1], vargs[2], vargs[3], vargs[4], vargs[5], vargs[6], vargs[7], vargs[8], vargs[9], NULL); } %typemap(freearg) (...) { %#if PY_VERSION_HEX>=0x03000000 int i; for (i = 0; i < 10; i++) { free(vargs$argnum[i]); } %#endif } %inline { char* testfunc (int arg1, double arg2, ...) { va_list ap; char *c; static char buffer[1024]; buffer[0] = 0; va_start(ap, arg2); while ((c = va_arg(ap, char *))) { strcat(buffer, c); } va_end(ap); return buffer; } } %inline %{ char *doublecheck(char *inputval) { return inputval; } %} swig-3.0.2/Examples/test-suite/r_sexp.i0000664000175000017500000000024312343605122017700 0ustar williamwilliam%module r_sexp extern "C" SEXP return_sexp(SEXP x); %inline %{ SEXP return_sexp(SEXP x) { return x; //Rcpp NumericVector is automatically casted to SEXP } %} swig-3.0.2/Examples/test-suite/template_basic.i0000664000175000017500000000214112343605122021353 0ustar williamwilliam/* File: template_basic.i */ %module "template_basic" %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ /* Let's just grab the original header file here */ %{ #ifdef max #undef max #endif %} %inline %{ template T max(const T a, const T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } // This really doesn't do anything except test const handling void testconst(const T x) { } }; %} /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; /* Now try to break constness */ %template(maxintp) max; %template(vecintp) vector; swig-3.0.2/Examples/test-suite/template_arg_scope.i0000664000175000017500000000026712343605122022243 0ustar williamwilliam%module template_arg_scope %inline %{ template class Foo { }; class Bar { public: Bar(); void spam(Foo *x); }; Bar::Bar() {} void Bar::spam(Foo *x) {} %} swig-3.0.2/Examples/test-suite/template_ns_enum2.i0000664000175000017500000000113412343605122022021 0ustar williamwilliam%module template_ns_enum2 %inline %{ namespace hi { enum Hello { Hi, Hola }; template struct traits { }; template <> struct traits { typedef int value_type; }; template <> struct traits { typedef double value_type; }; struct B { const traits::value_type& evaluate(const traits::value_type& e) const; }; const traits::value_type& B::evaluate(const traits::value_type& e) const { return e; } } %} swig-3.0.2/Examples/test-suite/clientdata_prop_a.h0000664000175000017500000000021012343605122022041 0ustar williamwilliam class A { public: void fA() {} }; typedef A tA; void test_A(A *a) {} void test_tA(tA *a) {} tA *new_tA() { return new tA(); } swig-3.0.2/Examples/test-suite/director_binary_string.i0000664000175000017500000000253512343605122023153 0ustar williamwilliam%module(directors="1") director_binary_string; %feature("director") Callback; %apply (char *STRING, size_t LENGTH) { (char *dataBufferAA, int sizeAA) }; %apply (char *STRING, size_t LENGTH) { (char *dataBufferBB, int sizeBB) }; %inline %{ #include #define BUFFER_SIZE_AA 8 #define BUFFER_SIZE_BB 5 class Callback { public: virtual ~Callback() {} virtual void run(char* dataBufferAA, int sizeAA, char* dataBufferBB, int sizeBB) { if (dataBufferAA) memset(dataBufferAA, -1, sizeAA); if (dataBufferBB) memset(dataBufferBB, -1, sizeBB); } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } int call() { int sum = 0; if (_callback) { char* aa = (char*)malloc(BUFFER_SIZE_AA); memset(aa, 9, BUFFER_SIZE_AA); char* bb = (char*)malloc(BUFFER_SIZE_BB); memset(bb, 13, BUFFER_SIZE_BB); _callback->run(aa, BUFFER_SIZE_AA, bb, BUFFER_SIZE_BB); for (int i = 0; i < BUFFER_SIZE_AA; i++) sum += aa[i]; for (int i = 0; i < BUFFER_SIZE_BB; i++) sum += bb[i]; free(aa); free(bb); } return sum; } void call_null() { _callback->run(NULL, 0, NULL, 0); } }; %} swig-3.0.2/Examples/test-suite/cast_operator.i0000664000175000017500000000036012343605122021245 0ustar williamwilliam%module cast_operator %rename(tochar) A::operator char*() const; %inline %{ #include struct A { operator char*() const; }; inline A::operator char*() const { static char hi[16]; strcpy(hi, "hi"); return hi; } %} swig-3.0.2/Examples/test-suite/rename3.i0000664000175000017500000000453112343605122017736 0ustar williamwilliam// Test %rename directive within %extend %module rename3 namespace Space { // Note no namespace nor class qualification %extend XYZ { %rename(opIntPtrA) operator NotXYZ*() const; %rename(opIntPtrB) operator XYZ*() const; } %extend XYZ { // Note use of type T %rename(opAnother1) operator Another() const; %rename(tMethod1) templateT(T i); %rename(tMethodNotXYZ1) templateNotXYZ(NotXYZ); %rename(tMethodXYZ1) templateXYZ(XYZ); %rename(opT1) operator T(); %rename(opNotXYZ1) operator NotXYZ() const; %rename(opXYZ1) operator XYZ() const; } %extend XYZ { %rename(opAnother2) operator Another() const; %rename(tMethod2) templateT(int i); %rename(tMethodNotXYZ2) templateNotXYZ(NotXYZ); %rename(tMethodXYZ2) templateXYZ(XYZ); %rename(opT2) operator int(); %rename(opNotXYZ2) operator NotXYZ() const; %rename(opXYZ2) operator XYZ() const; } %extend XYZ { %rename(opAnother3) operator Another() const; %rename(tMethod3) templateT(Space::Klass i); %rename(tMethodNotXYZ3) templateNotXYZ(NotXYZ); %rename(tMethodXYZ3) templateXYZ(XYZ); %rename(opT3) operator Space::Klass(); %rename(opNotXYZ3) operator NotXYZ() const; %rename(opXYZ3) operator XYZ() const; } %extend XYZ { %rename(opAnother4 )operator Another() const; %rename(tMethod4) templateT(Space::Enu i); %rename(tMethodNotXYZ4) templateNotXYZ(NotXYZ); %rename(tMethodXYZ4) templateXYZ(XYZ); %rename(opT4) operator Space::Enu(); %rename(opNotXYZ4) operator NotXYZ() const; %rename(opXYZ4) operator XYZ() const; } %extend ABC { %rename(methodABC) method(ABC a) const; %rename(opABC) operator ABC() const; %rename(methodKlass) method(Klass k) const; %rename(opKlass) operator Klass() const; } } %{ #include "rename.h" %} %include "rename.h" %template(XYZInt) Space::XYZ; %template(XYZDouble) Space::XYZ; %template(XYZKlass) Space::XYZ; %template(XYZEnu) Space::XYZ; %template(NotXYZInt) Space::NotXYZ; %template(NotXYZDouble) Space::NotXYZ; %template(NotXYZKlass) Space::NotXYZ; %template(NotXYZEnu) Space::NotXYZ; swig-3.0.2/Examples/test-suite/li_windows.i0000664000175000017500000000615712343605122020570 0ustar williamwilliam%module li_windows %include "windows.i" %{ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) // Fix Tcl.h and Windows.h cat and mouse over definition of VOID #if defined(_TCL) && defined(__CYGWIN__) #ifdef VOID #undef VOID #endif #endif #include #else // Use equivalent types for non-windows systems #define __int8 char #define __int16 short #define __int32 int #define __int64 long long #endif %} %inline %{ // Non ISO integral types __int8 int8_val ( __int8 i) { return i; } __int16 int16_val( __int16 i) { return i; } __int32 int32_val( __int32 i) { return i; } __int64 int64_val( __int64 i) { return i; } unsigned __int8 uint8_val (unsigned __int8 i) { return i; } unsigned __int16 uint16_val(unsigned __int16 i) { return i; } unsigned __int32 uint32_val(unsigned __int32 i) { return i; } unsigned __int64 uint64_val(unsigned __int64 i) { return i; } const __int8& int8_ref (const __int8& i) { return i; } const __int16& int16_ref(const __int16& i) { return i; } const __int32& int32_ref(const __int32& i) { return i; } const __int64& int64_ref(const __int64& i) { return i; } const unsigned __int8& uint8_ref (const unsigned __int8& i) { return i; } const unsigned __int16& uint16_ref(const unsigned __int16& i) { return i; } const unsigned __int32& uint32_ref(const unsigned __int32& i) { return i; } const unsigned __int64& uint64_ref(const unsigned __int64& i) { return i; } __int8 int8_global; __int16 int16_global; __int32 int32_global; __int64 int64_global; unsigned __int8 uint8_global; unsigned __int16 uint16_global; unsigned __int32 uint32_global; unsigned __int64 uint64_global; struct WindowsInts { __int8 int8_member; __int16 int16_member; __int32 int32_member; __int64 int64_member; unsigned __int8 uint8_member; unsigned __int16 uint16_member; unsigned __int32 uint32_member; unsigned __int64 uint64_member; }; // Typedef for non ISO integral types typedef __int8 int8; typedef __int16 int16; typedef __int32 int32; typedef __int64 int64; typedef unsigned __int8 uint8; typedef unsigned __int16 uint16; typedef unsigned __int32 uint32; typedef unsigned __int64 uint64; int8 int8_td (int8 i) { return i; } int16 int16_td(int16 i) { return i; } int32 int32_td(int32 i) { return i; } int64 int64_td(int64 i) { return i; } uint8 uint8_td (int8 i) { return i; } uint16 uint16_td(int16 i) { return i; } uint32 uint32_td(int32 i) { return i; } uint64 uint64_td(int64 i) { return i; } %} // Windows calling conventions and some types in windows.h %inline %{ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) #else #define __stdcall #define __declspec(WINDOWS_EXTENDED_ATTRIBUTE) #define DWORD unsigned int #define PSZ char * #endif // Windows calling conventions __declspec(dllexport) int __stdcall declspecstdcall(int i) { return i; } DWORD mefod(DWORD d) { return d; } PSZ funktion(PSZ d) { return d; } %} swig-3.0.2/Examples/test-suite/char_strings.i0000664000175000017500000001116612343605122021074 0ustar williamwilliam/* A test case for testing char based strings. Useful for runtime testing, there were some runtime crashes and leaks in the C# module in some of the scenarios below. */ %module char_strings %warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[] %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory. #ifdef SWIG_ALLEGRO_CL %{ #include %} #endif %{ #define OTHERLAND_MSG "Little message from the safe world." #define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible." static char *global_str = NULL; const int UINT_DIGITS = 10; // max unsigned int is 4294967295 bool check(const char *const str, unsigned int number) { static char expected[256]; sprintf(expected, "%s%d", OTHERLAND_MSG, number); bool matches = (strcmp(str, expected) == 0); if (!matches) printf("Failed: [%s][%s]\n", str, expected); return matches; } %} %immutable global_const_char; %inline %{ // get functions char *GetCharHeapString() { global_str = new char[sizeof(CPLUSPLUS_MSG)+1]; strcpy(global_str, CPLUSPLUS_MSG); return global_str; } const char *GetConstCharProgramCodeString() { return CPLUSPLUS_MSG; } void DeleteCharHeapString() { delete[] global_str; global_str = NULL; } char *GetCharStaticString() { static char str[sizeof(CPLUSPLUS_MSG)+1]; strcpy(str, CPLUSPLUS_MSG); return str; } char *GetCharStaticStringFixed() { static char str[] = CPLUSPLUS_MSG; return str; } const char *GetConstCharStaticStringFixed() { static const char str[] = CPLUSPLUS_MSG; return str; } // set functions bool SetCharHeapString(char *str, unsigned int number) { delete[] global_str; global_str = new char[strlen(str)+UINT_DIGITS+1]; strcpy(global_str, str); return check(global_str, number); } bool SetCharStaticString(char *str, unsigned int number) { static char static_str[] = CPLUSPLUS_MSG; strcpy(static_str, str); return check(static_str, number); } bool SetCharArrayStaticString(char str[], unsigned int number) { static char static_str[] = CPLUSPLUS_MSG; strcpy(static_str, str); return check(static_str, number); } bool SetConstCharHeapString(const char *str, unsigned int number) { delete[] global_str; global_str = new char[strlen(str)+UINT_DIGITS+1]; strcpy(global_str, str); return check(global_str, number); } bool SetConstCharStaticString(const char *str, unsigned int number) { static char static_str[] = CPLUSPLUS_MSG; strcpy(static_str, str); return check(static_str, number); } bool SetConstCharArrayStaticString(const char str[], unsigned int number) { static char static_str[] = CPLUSPLUS_MSG; strcpy(static_str, str); return check(static_str, number); } bool SetCharConstStaticString(char *const str, unsigned int number) { static char static_str[] = CPLUSPLUS_MSG; strcpy(static_str, str); return check(static_str, number); } bool SetConstCharConstStaticString(const char *const str, unsigned int number) { static char static_str[] = CPLUSPLUS_MSG; strcpy(static_str, str); return check(static_str, number); } // get set function char *CharPingPong(char *str) { return str; } char *CharArrayPingPong(char abcstr[]) { return abcstr; } char *CharArrayDimsPingPong(char abcstr[16]) { return abcstr; } // variables char *global_char = NULL; char global_char_array1[] = CPLUSPLUS_MSG; char global_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG; const char *global_const_char = CPLUSPLUS_MSG; const char global_const_char_array1[] = CPLUSPLUS_MSG; const char global_const_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG; %} %typemap(newfree) char *GetNewCharString() { /* hello */ delete[] $1; } %newobject GetNewCharString(); %inline { char *GetNewCharString() { char *nstr = new char[sizeof(CPLUSPLUS_MSG)+1]; strcpy(nstr, CPLUSPLUS_MSG); return nstr; } } %inline { struct Formatpos; struct OBFormat; static int GetNextFormat(Formatpos& itr, const char*& str,OBFormat*& pFormat) { return 0; } } %inline %{ // char *& tests char *&GetCharPointerRef() { static char str[] = CPLUSPLUS_MSG; static char *ptr = str; return ptr; } bool SetCharPointerRef(char *&str, unsigned int number) { static char static_str[] = CPLUSPLUS_MSG; strcpy(static_str, str); return check(static_str, number); } const char *&GetConstCharPointerRef() { static const char str[] = CPLUSPLUS_MSG; static const char *ptr = str; return ptr; } bool SetConstCharPointerRef(const char *&str, unsigned int number) { static char static_str[] = CPLUSPLUS_MSG; strcpy(static_str, str); return check(static_str, number); } %} swig-3.0.2/Examples/test-suite/enum_plus.i0000664000175000017500000000025112343605122020406 0ustar williamwilliam%module enum_plus %warnfilter(SWIGWARN_RUBY_WRONG_NAME) iFoo; /* Ruby, wrong constant name */ %inline %{ struct iFoo { enum { Phoo = +50 }; }; %} swig-3.0.2/Examples/test-suite/mod_b.i0000664000175000017500000000022212343605122017455 0ustar williamwilliam%module mod_b %{ #include "mod.h" %} %import mod_a.i class C : public B { public: C() {} }; class D : public C { public: D() {} }; swig-3.0.2/Examples/test-suite/li_std_map.i0000664000175000017500000000517612343605122020525 0ustar williamwilliam%module("templatereduce") li_std_map %feature("trackobjects"); %inline %{ namespace another { struct map { int val; map(int x) : val(x) {} }; } %} %include "std_pair.i" %include "std_map.i" %include "std_string.i" // Declare some maps to play around with %template(IntIntMap) std::map; %template(StringIntMap) std::map; %ignore Struct::operator<; %ignore Struct::operator==; // Add an inline function to test %inline %{ double valueAverage(std::map m) { if (m.size() == 0) { return 0.0; } double a = 0.0; for (std::map::iterator i = m.begin(); i != m.end(); i++) { a += i->second; } return a / m.size(); } std::string stringifyKeys(std::map m) { std::string a; for (std::map::iterator i = m.begin(); i != m.end(); i++) { a += " " + i->first; } return a; } struct Struct { double num; Struct() : num(0.0) {} Struct(double d) : num(d) {} bool operator<(const Struct &other) const { return num < other.num; } bool operator==(const Struct &other) const { return num == other.num; } }; %} //#if !defined(SWIGR) // Test out some maps with pointer types %template(IntIntPtrMap) std::map; %template(IntConstIntPtrMap) std::map; //#endif // Test out some maps with non-basic types and non-basic pointer types %template(IntStructMap) std::map; %template(IntStructPtrMap) std::map; %template(IntStructConstPtrMap) std::map; %template(StructPtrIntMap) std::map; // Test out a non-specialized map %template(StructIntMap) std::map; // Additional map definitions for Ruby, Python and Octave tests %inline %{ struct A{ int val; A(int v = 0): val(v) { } }; %} namespace std { %template(pairii) pair; %template(pairAA) pair; %template(pairA) pair; %template(mapA) map; %template(paircA1) pair; %template(paircA2) pair; %template(pairiiA) pair >; %template(pairiiAc) pair >; #ifdef SWIGRUBY %template() pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; %template(LanguageMap) map< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; #endif #ifdef SWIGPYTHON %template() pair; %template(pymap) map; #endif } %inline { std::pair p_identa(std::pair p) { return p; } std::map m_identa(const std::map& v) { return v; } } swig-3.0.2/Examples/test-suite/li_std_pair.i0000664000175000017500000000305312343605122020673 0ustar williamwilliam%module li_std_pair %include "std_pair.i" namespace std { %template(IntPair) pair; } %inline %{ /* Test the "out" typemap for pair */ std::pair makeIntPair(int a, int b) { return std::make_pair(a, b); } /** * There is no "out" typemap for a pointer to a pair, so * this should return a wrapped instance of a std::pair * instead of the native "array" type for the target language. */ std::pair * makeIntPairPtr(int a, int b) { static std::pair p = std::make_pair(a, b); return &p; } /** * There is no "out" typemap for a non-const reference to a pair, so * this should return a wrapped instance of a std::pair instead of * the native "array" type for the target language. */ std::pair& makeIntPairRef(int a, int b) { static std::pair p = std::make_pair(a, b); return p; } /** * There is no "out" typemap for a const reference to a pair, so * this should return a wrapped instance of a std::pair * instead of the native "array" type for the target language. */ const std::pair & makeIntPairConstRef(int a, int b) { static std::pair p = std::make_pair(a, b); return p; } /* Test the "in" typemap for pair */ int product1(std::pair p) { return p.first*p.second; } /* Test the "in" typemap for const pair& */ int product2(const std::pair& p) { return p.first*p.second; } /* Test the "in" typemap for const pair* */ int product3(const std::pair *p) { return p->first*p->second; } %} swig-3.0.2/Examples/test-suite/argcargvtest.i0000664000175000017500000000060312343605122021074 0ustar williamwilliam%module argcargvtest %include %apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) } %inline %{ int mainc(size_t argc, const char **argv) { return (int)argc; } const char* mainv(size_t argc, const char **argv, int idx) { return argv[idx]; } void initializeApp(size_t argc, const char **argv, bool setPGid = true, bool isMakeline = false) { } %} swig-3.0.2/Examples/test-suite/octave_dim.i0000664000175000017500000000443612343605122020522 0ustar williamwilliam%module octave_dim %include "std_vector.i" namespace std { %template(IntVector) vector; } %typemap(out) Matrix { $result = $1; } // Code below will not work. Kept for future reference. // Reason: there is no octave_value(Array) constructor //%typemap(out) Array { // $result = octave_value($1,true); //} %inline %{ class Foo45a { public: std::vector __dims__() const { std::vector ret(2); ret[0] = 4; ret[1] = 5; return ret; } }; // doubles are not converted to ints. class Bar1 { public: std::vector __dims__() const { std::vector ret(2); ret[0] = 4; ret[1] = 5; return ret; } }; class Bar2 { public: std::string __dims__() const { return "foo"; } }; class Foo4a { public: std::vector __dims__() const { std::vector ret(1); ret[0] = 4; return ret; } }; class Foo4b { public: int __dims__() const { return 4; } }; class Foo456a { public: std::vector __dims__() const { std::vector ret(3); ret[0] = 4; ret[1] = 5; ret[2] = 6; return ret; } }; class Foo { }; class Baz1 { public: Cell __dims__() const { Cell c(1,2); c(0) = 3; c(1) = 4; return c; } }; class Baz2 { public: Cell __dims__() const { Cell c(2,1); c(0) = 3; c(1) = 4; return c; } }; class Baz3 { public: Matrix __dims__() const { Matrix c(2,1); c(0) = 3; c(1) = 4; return c; } }; class Baz4 { public: Matrix __dims__() const { Matrix c(1,2); c(0) = 3; c(1) = 4; return c; } }; class Baz5 { public: Array __dims__() const { Array c(dim_vector(2,1)); c(0) = 3; c(1) = 4; return c; } }; class Baz6 { public: Array __dims__() const { Array c(dim_vector(1,2)); c(0) = 3; c(1) = 4; return c; } }; // Code below will not work. Kept for future reference. // Reason: there is no octave_value(dim_vector) constructor // class Baz7 { //public: // dim_vector __dims__() const { // octave_value v = dim_vector(3,4); // Array a = v.int_vector_value(); // if (error_state) return dim_vector(1,1); // int mysize = a.numel(); // return dim_vector(3,4); // } //}; %} swig-3.0.2/Examples/test-suite/r_legacy.i0000664000175000017500000000226212343605122020170 0ustar williamwilliam%module r_legacy %inline %{ typedef char *String; typedef struct { int i; double d; char *str; String s; } Obj; Obj *getObject(int i, double d); #include Obj * getObject(int i, double d) { const char *test_string = "a test string"; Obj *obj; obj = (Obj *) calloc(1, sizeof(Obj)); obj->i = i; obj->d = d; /* allocate one extra byte for the null */ obj->str = (char *)malloc(strlen(test_string) + 1); strcpy(obj->str, test_string); return(obj); } %} char *getString(); int getInt(); double getDouble(); float getFloat(); long getLong(); unsigned long getUnsignedLong(); char getChar(); extern unsigned long MyULong; extern const double PiSquared; #if 0 extern float *MyFloatRef; #endif %inline %{ #define PI 3.14159265358979 unsigned long MyULong = 20; static float MyFloat = 1.05f; float *MyFloatRef = &MyFloat; const double PiSquared = PI * PI; char *getString() { return "This is a literal string"; } int getInt() { return 42; } double getDouble() { return PI; } float getFloat() { return (float)PI/2; } long getLong() { return -321313L; } unsigned long getUnsignedLong() { return 23123L; } char getChar() { return('A'); } %} swig-3.0.2/Examples/test-suite/extend_template_ns.i0000664000175000017500000000070012343605122022260 0ustar williamwilliam%module extend_template_ns %inline %{ namespace oss { enum Test {One, Two}; } %} namespace oss { %extend Foo { //************ this doesn't work int test1(int x) { return x; } }; } %extend oss::Foo { //******** this works int test2(int x) { return x; } }; %inline %{ namespace oss { template struct Foo { }; } %} namespace oss { %template(Foo_One) Foo; } swig-3.0.2/Examples/test-suite/java_typemaps_typewrapper.i0000664000175000017500000000343112343605122023707 0ustar williamwilliam/* Contrived example to test the Java specific directives on the type wrapper classes */ %module java_typemaps_typewrapper %typemap(javaimports) SWIGTYPE * "import java.math.*;"; %typemap(javacode) Farewell * %{ public static $javaclassname CreateNullPointer() { return new $javaclassname(); } public void saybye(BigDecimal num_times) { // BigDecimal requires the java.math library } %} %typemap(javaclassmodifiers) Farewell * "public final class"; %typemap(javaimports) Greeting * %{ import java.util.*; // for EventListener import java.lang.*; // for Exception %}; %typemap(javabase) Greeting * "Exception"; %typemap(javainterfaces) Greeting * "EventListener"; %typemap(javacode) Greeting * %{ public static final long serialVersionUID = 0x52151000; // Suppress ecj warning // Pure Java code generated using %typemap(javacode) public static $javaclassname CreateNullPointer() { return new $javaclassname(); } public void sayhello() { $javaclassname.cheerio(new $javaclassname()); } public static void cheerio(EventListener e) { } %} // Create a new getCPtr() function which takes Java null and is public // Make the pointer constructor public %typemap(javabody) Farewell * %{ private long swigCPtr; public $javaclassname(long cPtr, boolean bFutureUse) { swigCPtr = cPtr; } protected $javaclassname() { swigCPtr = 0; } public static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %{ class Greeting {}; class Farewell {}; %} %inline %{ Greeting* solong(Farewell* f) { return NULL; } %} // Illegal special variable crash %typemap(jstype) WasCrashing "$javaclassname /*jstype $*javaclassname*/" // $*javaclassname was causing crash %inline %{ struct WasCrashing {}; void hoop(WasCrashing was) {} %} swig-3.0.2/Examples/test-suite/arrays_dimensionless.i0000664000175000017500000001111712343605122022637 0ustar williamwilliam %module arrays_dimensionless %warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) globalints; /* Unable to set variable of type int [] */ %warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) ints; /* Unable to set variable of type int [] */ %inline %{ int globalints[] = {100, 200, 300}; const int constglobalints[] = {400, 500, 600}; struct Bar { static int ints[]; }; int Bar::ints[] = {700, 800, 900}; double arr_bool(bool array[], int length) { double sum=0.0; int i=0; for(; i using namespace std; %} %inline %{ class Op { public: Op(int n) {k = n;} Op(const Op& other) { std::cerr << "COPY: "<< other.k << std::endl; k = other.k; } bool operator==(const Op& rhs) { std::cerr << "Op: " << k << std::endl; std::cerr << "obj: " << rhs.k << std::endl; return (k == rhs.k); } bool operator==(int i) { std::cerr << "Op: " << k << std::endl; std::cerr << "other: " << i << std::endl; return (k == i); } Op operator+(const Op& rhs) {return Op(k + rhs.k);} Op operator+(int rhs) {return Op(k + rhs);} Op operator-(const Op& rhs) {return Op(k - rhs.k);} Op operator-(int rhs) { std::cerr << "sub: " << rhs << std::endl; return Op(k - rhs); } Op __rsub__(int lhs) { std::cerr << "sub: " << lhs << std::endl; return Op(lhs - k); } Op& operator++() {k++; return *this;} void PrintK() {std::cerr << k << std::endl;} int k; }; %} swig-3.0.2/Examples/test-suite/cpp_enum.i0000664000175000017500000000253712343605122020216 0ustar williamwilliam/* The primary purpose of this testcase is to ensure that enums used along with the 'enum' keyword compile under c++. */ %module cpp_enum %inline %{ enum SOME_ENUM {ENUM_ONE, ENUM_TWO}; struct StructWithEnums { StructWithEnums() : some_enum(ENUM_ONE) {}; enum SOME_ENUM some_enum; void enum_test1(enum SOME_ENUM param1, enum SOME_ENUM* param2, enum SOME_ENUM& param3) {}; void enum_test2(SOME_ENUM param1, SOME_ENUM* param2, SOME_ENUM& param3) {}; SOME_ENUM enum_test3() { return ENUM_ONE; }; enum SOME_ENUM enum_test4() { return ENUM_TWO; }; SOME_ENUM* enum_test5() { return &some_enum; }; enum SOME_ENUM* enum_test6() { return &some_enum; }; SOME_ENUM& enum_test7() { return some_enum; }; enum SOME_ENUM& enum_test8() { return some_enum; }; }; struct Foo { enum {Hi, Hello } hola; Foo() : hola(Hello) { } }; extern "C" { enum {Hi, Hello } hi; } %} // Using true and false in enums is legal in C++. Quoting the standard: // [dcl.enum] // ... The constant-expression shall be of integral or enumeration type. // [basic.fundamental] // ... Types bool, char, wchar_t, and the signed and unsigned integer // types are collectively called integral types. // So this shouldn't lead to a warning, at least in C++ mode. %inline %{ typedef enum { PLAY = true, STOP = false } play_state; %} swig-3.0.2/Examples/test-suite/template_default2.i0000664000175000017500000000172512343605122022007 0ustar williamwilliam%module template_default2 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::traits; // Ruby, wrong class name %inline %{ namespace oss { enum Polarization { UnaryPolarization, BinaryPolarization }; template struct Interface_tpl { }; struct traits { static const Polarization pmode = UnaryPolarization; }; template > // **** problem here ***** struct Module : Base { }; } %} namespace oss { %template(Interface_UP) Interface_tpl; // This works %template(Module_UP1) Module >; // These don't %template(Module_UP2) Module; %template(Module_UP3) Module; } swig-3.0.2/Examples/test-suite/casts.i0000664000175000017500000000022512343605122017515 0ustar williamwilliam%module casts %inline %{ class A { public: A() {} void hello() { } }; class B : public A { public: B() {} }; %} swig-3.0.2/Examples/test-suite/template_inherit.i0000664000175000017500000000155112343605122021740 0ustar williamwilliam/* File : example.i */ %module template_inherit /* This example tests template inheritance to see if it actually works */ %inline %{ template class Foo { public: virtual ~Foo() { } virtual char *blah() { return (char *) "Foo"; } virtual char *foomethod() { return (char *) "foomethod"; } }; template class Bar : public Foo { public: virtual char *blah() { return (char *) "Bar"; } }; template char *invoke_blah(Foo *x) { return x->blah(); } %} %template(FooInt) Foo; %template(FooDouble) Foo; %template(FooUInt) Foo; %template(BarInt) Bar; %template(BarDouble) Bar; %template(BarUInt) Bar; %template(invoke_blah_int) invoke_blah; %template(invoke_blah_double) invoke_blah; %template(invoke_blah_uint) invoke_blah; swig-3.0.2/Examples/test-suite/template_ns3.i0000664000175000017500000000045512343605122021003 0ustar williamwilliam%module template_ns3 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo::bar; /* Ruby, wrong class name */ %inline %{ namespace foo { typedef int Integer; template class bar { public: Integer test(Integer x) { return x; } }; } %} %template(bari) foo::bar; swig-3.0.2/Examples/test-suite/rename_strip_encoder.i0000664000175000017500000000031412343605122022566 0ustar williamwilliam%module rename_strip_encoder // strip the wx prefix from all identifiers %rename("%(strip:[wx])s") ""; %inline %{ class wxSomeWidget { }; struct wxAnotherWidget { void wxDoSomething() {} }; %} swig-3.0.2/Examples/test-suite/using2.i0000664000175000017500000000057212343605122017614 0ustar williamwilliam%module using2 %warnfilter(SWIGWARN_PARSE_USING_UNDEF); using ::baz; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) X::_FooImpl; /* Ruby, wrong class name */ %inline %{ namespace X { typedef int Integer; class _FooImpl { public: typedef Integer value_type; }; typedef _FooImpl Foo; } namespace Y = X; using Y::Foo; int spam(Foo::value_type x) { return x; } %} swig-3.0.2/Examples/test-suite/php/0000775000175000017500000000000012343605122017016 5ustar williamwilliamswig-3.0.2/Examples/test-suite/php/director_classic_runme.php0000664000175000017500000000671312343605122024260 0ustar williamwilliamid(); if ($debug) print $ret . "\n"; check::equal($ret, $expected, "#1 failed"); # Polymorphic call from C++ $caller = new Caller(); $caller->setCallback($person); $ret = $caller->call(); if ($debug) print $ret . "\n"; check::equal($ret, $expected, "#2 failed"); # Polymorphic call of object created in target language and passed to # C++ and back again $baseclass = $caller->baseClass(); $ret = $baseclass->id(); if ($debug) print $ret . "\n"; # TODO: Currently we do not track the dynamic type of returned # objects, so in case it's possible that the dynamic type is not equal # to the static type, we skip this check. if (get_parent_class($person) === false) check::equal($ret, $expected, "#3 failed"); $caller->resetCallback(); if ($debug) print "----------------------------------------\n"; } $person = new Person(); mycheck($person, "Person"); unset($person); $person = new Child(); mycheck($person, "Child"); unset($person); $person = new GrandChild(); mycheck($person, "GrandChild"); unset($person); $person = new TargetLangPerson(); mycheck($person, "TargetLangPerson"); unset($person); $person = new TargetLangChild(); mycheck($person, "TargetLangChild"); unset($person); $person = new TargetLangGrandChild(); mycheck($person, "TargetLangGrandChild"); unset($person); # Semis - don't override id() in target language $person = new TargetLangSemiPerson(); mycheck($person, "Person"); unset($person); $person = new TargetLangSemiChild(); mycheck($person, "Child"); unset($person); $person = new TargetLangSemiGrandChild(); mycheck($person, "GrandChild"); unset($person); # Orphans - don't override id() in C++ $person = new OrphanPerson(); mycheck($person, "Person"); unset($person); $person = new OrphanChild(); mycheck($person, "Child"); unset($person); $person = new TargetLangOrphanPerson(); mycheck($person, "TargetLangOrphanPerson"); unset($person); $person = new TargetLangOrphanChild(); mycheck($person, "TargetLangOrphanChild"); unset($person); check::done(); ?> swig-3.0.2/Examples/test-suite/php/director_default_runme.php0000664000175000017500000000062512343605122024257 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/arrays_global_twodim_runme.php0000664000175000017500000000135012343605122025140 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/typemap_ns_using_runme.php0000664000175000017500000000031612343605122024321 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/newobject1_runme.php0000664000175000017500000000062512343605122023001 0ustar williamwilliammakeMore(); check::equal(get_class($bar), "Foo", "regular failed"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/director_frob_runme.php0000664000175000017500000000146612343605122023567 0ustar williamwilliamabs_method(); check::equal($s, "Bravo::abs_method()", "s failed"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/arrayptr_runme.php0000664000175000017500000000031612343605122022601 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/director_finalizer_runme.php0000664000175000017500000000177212343605122024622 0ustar williamwilliamorStatus(2); if (method_exists(parent, "__destruct")) { parent::__destruct(); } } } resetStatus(); $a = new MyFoo(); unset($a); check::equal(getStatus(), 3, "getStatus() failed #1"); resetStatus(); $a = new MyFoo(); launder($a); check::equal(getStatus(), 0, "getStatus() failed #2"); unset($a); check::equal(getStatus(), 3, "getStatus() failed #3"); resetStatus(); $a = new MyFoo(); $a->thisown = 0; deleteFoo($a); unset($a); check::equal(getStatus(), 3, "getStatus() failed #4"); resetStatus(); $a = new MyFoo(); $a->thisown = 0; deleteFoo(launder($a)); unset($a); check::equal(getStatus(), 3, "getStatus() failed #5"); resetStatus(); check::done(); ?> swig-3.0.2/Examples/test-suite/php/director_unroll_runme.php0000664000175000017500000000066212343605122024147 0ustar williamwilliamset($a); $c = $b->get(); check::equal($a->this, $c->this, "this failed"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/director_profile_runme.php0000664000175000017500000000160212343605122024267 0ustar williamwilliamfi($a); #1 $a = $b->fi($a); #2 $a = $b->fi($a); #3 $a = $b->fi($a); #4 $a = $b->fi($a); #5 $a = $b->fi($a); #6 $a = $b->fi($a); #7 $a = $b->fi($a); #8 $a = $b->fi($a); #9 $a = $b->fi($a); #10 $a = $b->fi($a); #1 $a = $b->fi($a); #2 $a = $b->fi($a); #3 $a = $b->fi($a); #4 $a = $b->fi($a); #5 $a = $b->fi($a); #6 $a = $b->fi($a); #7 $a = $b->fi($a); #8 $a = $b->fi($a); #9 $a = $b->fi($a); #20 $i -= 1; } print $a . "\n"; check::done(); ?> swig-3.0.2/Examples/test-suite/php/casts_runme.php0000664000175000017500000000044612343605122022056 0ustar williamwilliamhello(); check::done(); ?> swig-3.0.2/Examples/test-suite/php/li_std_vector_member_var_runme.php0000664000175000017500000000123212343605122025772 0ustar williamwilliamx, 0, "Test::x != 0"); check::equal($t->v->size(), 0, "Test::v.size() != 0"); $t->f(1); check::equal($t->x, 1, "Test::x != 1"); check::equal($t->v->size(), 1, "Test::v.size() != 1"); $t->f(2); check::equal($t->x, 3, "Test::x != 3"); check::equal($t->v->size(), 2, "Test::v.size() != 2"); $t->f(3); check::equal($t->x, 6, "Test::x != 6"); check::equal($t->v->size(), 3, "Test::v.size() != 3"); $T = new T(); $T->start_t = new S(); $T->length = 7; check::equal($T->start_t->x, 4, "S::x != 4"); check::equal($T->length, 7, "T::length != 7"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/threads_exception_runme.php0000664000175000017500000000147312343605122024452 0ustar williamwilliamunknown(); } catch (Exception $e) { check::equal($e->getMessage(), 'C++ A * exception thrown', ''); } try { $t->simple(); } catch (Exception $e) { check::equal($e->getCode(), 37, ''); } try { $t->message(); } catch (Exception $e) { check::equal($e->getMessage(), 'I died.', ''); } try { $t->hosed(); } catch (Exception $e) { check::equal($e->getMessage(), 'C++ Exc exception thrown', ''); } foreach (Array(1,2,3,4) as $i) { try { $t->multi($i); } catch (Exception $e) { } } swig-3.0.2/Examples/test-suite/php/director_string_runme.php0000664000175000017500000000151712343605122024142 0ustar williamwilliamsmem = "hello"; } } $b = new B("hello"); $b->get(0); check::equal($b->get_first(),"hello world!", "get_first failed"); $b->call_process_func(); check::equal($b->smem, "hello", "smem failed"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/pointer_reference_runme.php0000664000175000017500000000074112343605122024435 0ustar williamwilliamvalue, 10, "pointer_reference::get() failed"); $ss = new Struct(20); pointer_reference::set($ss); $i = Struct::instance(); check::equal($i->value, 20, "pointer_reference::set() failed"); check::equal(pointer_reference::overloading(1), 111, "overload test 1 failed"); check::equal(pointer_reference::overloading($ss), 222, "overload test 2 failed"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/template_arg_typename_runme.php0000664000175000017500000000064112343605122025304 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/extend_template_runme.php0000664000175000017500000000032112343605122024113 0ustar williamwilliamtest1(2),"test1"); check::equal(3,$foo->test2(3),"test2"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/typedef_reference_runme.php0000664000175000017500000000054212343605122024414 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/director_nested_runme.php0000664000175000017500000000312712343605122024115 0ustar williamwilliamstep(), "Bar::step;Foo::advance;Bar::do_advance;A::do_step;", "Bad A virtual resolution"); class B extends FooBar_int { function do_advance() { return "B::do_advance;" . $this->do_step(); } function do_step() { return "B::do_step;"; } function get_value() { return 1; } } $b = new B(); check::equal($b->step(), "Bar::step;Foo::advance;B::do_advance;B::do_step;", "Bad B virtual resolution"); class C extends FooBar_int { function do_advance() { return "C::do_advance;" . parent::do_advance(); } function do_step() { return "C::do_step;"; } function get_value() { return 2; } function get_name() { return parent::get_name() . " hello"; } } $cc = new C(); # TODO: Currently we do not track the dynamic type of returned # objects, so we skip the get_self() call. #$c = Foobar_int::get_self($cc); $c = $cc; $c->advance(); check::equal($c->get_name(), "FooBar::get_name hello", "get_name failed"); check::equal($c->name(), "FooBar::get_name hello", "name failed"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/virtual_vs_nonvirtual_base_runme.php0000664000175000017500000000033712343605122026411 0ustar williamwilliamgetInner()->get(), $fail->getInner()->get(), "should both be 10"); ?> swig-3.0.2/Examples/test-suite/php/li_factory_runme.php0000664000175000017500000000105312343605122023067 0ustar williamwilliamradius(); check::equal($r, 1.5, "r failed"); $point = Geometry::create(Geometry::POINT); $w = $point->width(); check::equal($w, 1.0, "w failed"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/template_construct_runme.php0000664000175000017500000000027512343605122024660 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/director_stl_runme.php0000664000175000017500000000177212343605122023441 0ustar williamwilliamtping("hello"); $a->tpong("hello"); # TODO: automatic conversion between PHP arrays and std::pair or # std::vector is not yet implemented. /*$p = array(1, 2); $a->pident($p); $v = array(3, 4); $a->vident($v); $a->tpident($p); $a->tvident($v); $v1 = array(3, 4); $v2 = array(5, 6); $a->tvsecond($v1, $v2); $vs = array("hi", "hello"); $vs; $a->tvidents($vs);*/ check::done(); ?> swig-3.0.2/Examples/test-suite/php/primitive_ref_runme.php0000664000175000017500000000242312343605122023602 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/conversion_ns_template_runme.php0000664000175000017500000000032412343605122025514 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/class_ignore_runme.php0000664000175000017500000000047212343605122023410 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/add_link_runme.php0000664000175000017500000000065212343605122022505 0ustar williamwilliamblah(); check::is_a($foo_blah,foo); //fails, can't be called as a class method, should allow and make it nil? //$class_foo_blah=foo::blah(); //check::is_a($class_foo_blah,foo); check::done(); ?> swig-3.0.2/Examples/test-suite/php/wrapmacro_runme.php0000664000175000017500000000046612343605122022736 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/director_basic_runme.php0000664000175000017500000000242612343605122023715 0ustar williamwilliamping(), "PhpFoo::ping()", "ping failed"); check::equal($a->pong(), "Foo::pong();PhpFoo::ping()", "pong failed"); $b = new Foo(); check::equal($b->ping(), "Foo::ping()", "ping failed"); check::equal($b->pong(), "Foo::pong();Foo::ping()", "pong failed"); $a = new A1(1); check::equal($a->rg(2), 2, "rg failed"); class PhpClass extends MyClass { function vmethod($b) { $b->x = $b->x + 31; return $b; } } $b = new Bar(3); $d = new MyClass(); $c = new PhpClass(); $cc = MyClass::get_self($c); $dd = MyClass::get_self($d); $bc = $cc->cmethod($b); $bd = $dd->cmethod($b); $cc->method($b); check::equal($bc->x, 34, "bc failed"); check::equal($bd->x, 16, "bd failed"); */ check::done(); ?> swig-3.0.2/Examples/test-suite/php/extend_template_ns_runme.php0000664000175000017500000000035512343605122024622 0ustar williamwilliamtest1(2),"test1"); check::equal(3,$foo->test2(3),"test2"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/director_extend_runme.php0000664000175000017500000000074112343605122024121 0ustar williamwilliamdummy(), 666, "1st call"); check::equal($m->dummy(), 666, "2st call"); // Locked system check::done(); ?> swig-3.0.2/Examples/test-suite/php/overload_rename_runme.php0000664000175000017500000000047012343605122024100 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/import_nomodule_runme.php0000664000175000017500000000062412343605122024153 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/overload_return_type_runme.php0000664000175000017500000000051512343605122025211 0ustar williamwilliamfoo(1), 0, ""); check::classname("A", $b->foo("test")); check::equal(overload_return_type::foo(), 1, "overload_return_type::foo() should be 1"); check::equal(overload_return_type::bar(), 1, "overload_return_type::bar() should be 1"); ?> swig-3.0.2/Examples/test-suite/php/arrays_global_runme.php0000664000175000017500000000164612343605122023565 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/evil_diamond_runme.php0000664000175000017500000000050712343605122023371 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/li_carrays_runme.php0000664000175000017500000000137212343605122023070 0ustar williamwilliamsetitem(0, 7); $d->setitem(5, $d->getitem(0) + 3); check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/abstract_inherit_runme.php0000664000175000017500000000055412343605122024266 0ustar williamwilliamblah(),"spam object method"); //check::equal(0,Spam::blah($spam),"spam class method"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/smart_pointer_rename_runme.php0000664000175000017500000000143012343605122025150 0ustar williamwilliamftest1(1),"foo->ftest1"); check::equal(2,$foo->ftest2(1,2),"foo->ftest2"); # check bar's ftest1, ftest2, ftest check::equal(1,$bar->ftest1(1),"bar->ftest1"); check::equal(2,$bar->ftest2(1,2),"bar->ftest2"); check::equal(3,$bar->test(),"bar->test"); # check deref returns foo check::classname("foo",$bar->__deref__()); check::done(); ?> swig-3.0.2/Examples/test-suite/php/conversion_runme.php0000664000175000017500000000031412343605122023120 0ustar williamwilliamtoFoo(); check::classname("foo",$foo); check::done(); ?> swig-3.0.2/Examples/test-suite/php/valuewrapper_base_runme.php0000664000175000017500000000041712343605122024446 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/using1_runme.php0000664000175000017500000000030412343605122022140 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/using2_runme.php0000664000175000017500000000030412343605122022141 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/prefix_runme.php0000664000175000017500000000050012343605122022225 0ustar williamwilliamget_self(); check::done(); ?> swig-3.0.2/Examples/test-suite/php/arrays_runme.php0000664000175000017500000000170212343605122022236 0ustar williamwilliamarray_c="abc"; check::equal($as->array_c,"a",'$as->array_c=="a"'); check::equal(isset($as->array_const_i),TRUE,'isset($as->array_const_i)'); check::done(); ?> swig-3.0.2/Examples/test-suite/php/director_protected_runme.php0000664000175000017500000000434712343605122024631 0ustar williamwilliamcreate(); $fb = new FooBar(); $fb2 = new FooBar2(); $fb3 = new FooBar3(); check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used"); check::equal($fb2->used(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used"); check::equal($b->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong"); check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong"); check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong"); $method = new ReflectionMethod('Bar', 'ping'); check::equal($method->isProtected(), true, "Foo::ping should be protected"); $method = new ReflectionMethod('Foo', 'ping'); check::equal($method->isProtected(), true, "Foo::ping should be protected"); $method = new ReflectionMethod('FooBar', 'pang'); check::equal($method->isProtected(), true, "FooBar::pang should be protected"); $method = new ReflectionMethod('Bar', 'cheer'); check::equal($method->isProtected(), true, "Bar::cheer should be protected"); $method = new ReflectionMethod('Foo', 'cheer'); check::equal($method->isProtected(), true, "Foo::cheer should be protected"); check::equal($fb3->cheer(), "FooBar3::cheer();", "bad fb3::pong"); check::equal($fb2->callping(), "FooBar2::ping();", "bad fb2::callping"); check::equal($fb2->callcheer(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad fb2::callcheer"); check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping"); check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/autodoc_runme.php0000664000175000017500000000034412343605122022374 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/li_std_string_runme.php0000664000175000017500000000225112343605122023601 0ustar williamwilliamMemberString2, "member string 2", "MemberString2 test 1"); $myStructure->MemberString2 = $s; check::equal($myStructure->MemberString2, $s, "MemberString2 test 2"); check::equal($myStructure->ConstMemberString, "const member string", "ConstMemberString test"); check::equal(Structure::StaticMemberString2(), "static member string 2", "StaticMemberString2 test 1"); Structure::StaticMemberString2($s); check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2"); // below broken ? //check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/arrays_scope_runme.php0000664000175000017500000000042312343605122023426 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/rename_scope_runme.php0000664000175000017500000000116312343605122023376 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/tests.php0000664000175000017500000001643712343605122020704 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/director_thread_runme.php0000664000175000017500000000071612343605122024103 0ustar williamwilliamval = $this->val - 1; } } $d = new Derived(); $d->run(); if ($d->val >= 0) { check::fail($d->val); } $d->stop(); check::done(); ?> swig-3.0.2/Examples/test-suite/php/grouping_runme.php0000664000175000017500000000121212343605122022563 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/director_detect_runme.php0000664000175000017500000000210212343605122024073 0ustar williamwilliamval = $val; } function get_value() { $this->val = $this->val + 1; return $this->val; } function get_class() { $this->val = $this->val + 1; return new A(); } function just_do_it() { $this->val = $this->val + 1; } /* clone is a reserved keyword */ function clone_() { return new MyBar($this->val); } } $b = new MyBar(); $f = $b->baseclass(); $v = $f->get_value(); $a = $f->get_class(); $f->just_do_it(); $c = $b->clone_(); $vc = $c->get_value(); check::equal($v, 3, "f: Bad virtual detection"); check::equal($b->val, 5, "b: Bad virtual detection"); check::equal($vc, 6, "c: Bad virtual detection"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/director_abstract_runme.php0000664000175000017500000000324712343605122024441 0ustar williamwilliamping(), "MyFoo::ping()", "MyFoo::ping failed"); check::equal($a->pong(), "Foo::pong();MyFoo::ping()", "MyFoo::pong failed"); class MyExample1 extends Example1 { function Color($r, $g, $b) { return $r; } } class MyExample2 extends Example1 { function Color($r, $g, $b) { return $g; } } class MyExample3 extends Example1 { function Color($r, $g, $b) { return $b; } } $me1 = new MyExample1(); check::equal($me1->Color(1, 2, 3), 1, "Example1_get_color failed"); $me2 = new MyExample2(1, 2); check::equal($me2->Color(1, 2, 3), 2, "Example2_get_color failed"); $me3 = new MyExample3(); check::equal($me3->Color(1, 2, 3), 3, "Example3_get_color failed"); $class = new ReflectionClass('Example1'); check::equal($class->isAbstract(), true, "Example1 abstractness failed"); $class = new ReflectionClass('Example2'); check::equal($class->isAbstract(), true, "Example2 abstractness failed"); $class = new ReflectionClass('Example3_i'); check::equal($class->isAbstract(), true, "Example3_i abstractness failed"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/abstract_inherit_ok_runme.php0000664000175000017500000000027312343605122024755 0ustar williamwilliamblah(),"spam object method"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/exception_order_runme.php0000664000175000017500000000152512343605122024131 0ustar williamwilliamfoo(); } catch (Exception $e) { check::equal($e->getMessage(), 'C++ E1 exception thrown', ''); } try { $a->bar(); } catch (Exception $e) { check::equal($e->getMessage(), 'C++ E2 exception thrown', ''); } try { $a->foobar(); } catch (Exception $e) { check::equal($e->getMessage(), 'postcatch unknown', ''); } try { $a->barfoo(1); } catch (Exception $e) { check::equal($e->getMessage(), 'C++ E1 exception thrown', ''); } try { $a->barfoo(2); } catch (Exception $e) { check::equal($e->getMessage(), 'C++ E2 * exception thrown', ''); } ?> swig-3.0.2/Examples/test-suite/php/cpp_static_runme.php0000664000175000017500000000054112343605122023066 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/enum_scope_template_runme.php0000664000175000017500000000110312343605122024760 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/sym_runme.php0000664000175000017500000000077512343605122021556 0ustar williamwilliamhulahoops(),"flim-jam","flim()->hulahoops==flim-jam"); check::equal($flim->jar(),"flim-jar","flim()->jar==flim-jar"); check::equal($flam->jam(),"flam-jam","flam()->jam==flam-jam"); check::equal($flam->jar(),"flam-jar","flam()->jar==flam-jar"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/director_exception_runme.php0000664000175000017500000000322312343605122024626 0ustar williamwilliammsg = $a . $b; } } class MyFoo extends Foo { function ping() { throw new Exception("MyFoo::ping() EXCEPTION"); } } class MyFoo2 extends Foo { function ping() { return true; } } class MyFoo3 extends Foo { function ping() { throw new MyException("foo", "bar"); } } # Check that the Exception raised by MyFoo.ping() is returned by # MyFoo.pong(). $ok = 0; $a = new MyFoo(); # TODO: Currently we do not track the dynamic type of returned # objects, so we skip the launder() call. #$b = director_exception::launder($a); $b = $a; try { $b->pong(); } catch (Exception $e) { $ok = 1; check::equal($e->getMessage(), "MyFoo::ping() EXCEPTION", "Unexpected error message #1"); } check::equal($ok, 1, "Got no exception while expected one #1"); # Check that the director can return an exception which requires two # arguments to the constructor, without mangling it. $ok = 0; $a = new MyFoo3(); #$b = director_exception::launder($a); $b = $a; try { $b->pong(); } catch (Exception $e) { $ok = 1; check::equal($e->msg, "foobar", "Unexpected error message #2"); } check::equal($ok, 1, "Got no exception while expected one #2"); try { throw new Exception2(); } catch (Exception2 $e2) { } try { throw new Exception1(); } catch (Exception1 $e1) { } check::done(); ?> swig-3.0.2/Examples/test-suite/php/evil_diamond_prop_runme.php0000664000175000017500000000171712343605122024435 0ustar williamwilliam_foo,"1==foo->_foo"); $bar=new bar(); check::is_a($bar,"bar"); check::equal(1,$bar->_foo,"1==bar->_foo"); check::equal(2,$bar->_bar,"2==bar->_bar"); $baz=new baz(); check::is_a($baz,"baz"); check::equal(1,$baz->_foo,"1==baz->_foo"); check::equal(3,$baz->_baz,"3==baz->_baz"); $spam=new spam(); check::is_a($spam,"spam"); check::equal(1,$spam->_foo,"1==spam->_foo"); check::equal(2,$spam->_bar,"2==spam->_bar"); // multiple inheritance not supported in PHP check::equal(null,$spam->_baz,"null==spam->_baz"); check::equal(4,$spam->_spam,"4==spam->_spam"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/ignore_parameter_runme.php0000664000175000017500000000231112343605122024255 0ustar williamwilliamdaimler(2,3.4),"hello",'$sc->daimler(2,3.4)=="hello"'); check::equal($sc->astonmartin("eek",3.4),101,'$sc->mastonmartin("eek",3.4)==101'); check::equal($sc->bugatti("eek",2),8.8,'$sc->bugatti("eek",2)==8.8'); check::equal($sc->lamborghini(),101,'$sc->lamborghini(2)==101'); $mc=new minicooper(2,3.4); check::classname("minicooper",$mc); $mm=new morrisminor("eek",3.4); check::classname("morrisminor",$mm); $fa=new fordanglia("eek",2); check::classname("fordanglia",$fa); $aa=new austinallegro(); check::classname("austinallegro",$aa); check::done(); ?> swig-3.0.2/Examples/test-suite/php/Makefile.in0000664000175000017500000000515012343605122021064 0ustar williamwilliam####################################################################### # Makefile for php test-suite ####################################################################### LANGUAGE = php SCRIPTSUFFIX = _runme.php srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ php_namewarn_rename \ include $(srcdir)/../common.mk # Overridden variables here TARGETPREFIX =# Should be php_ for Windows, empty otherwise # Custom tests - tests with additional commandline options prefix.cpptest: SWIGOPT += -prefix Project # write out tests without a _runme.php missingcpptests: for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done missingctests: for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done missingtests: missingcpptests missingctests # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) +$(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) +$(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) +$(run_testcase) # Smart target %.test: @echo ' $(C_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\ $(MAKE) $*.ctest @echo ' $(CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\ $(MAKE) $*.cpptest @echo ' $(MULTI_CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\ $(MAKE) $*.multicpptest # Runs the testcase. Tries to run testcase_runme.php, and if that's not # found, runs testcase.php, except for multicpptests. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \ elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \ fi # Clean: remove the generated .php file %.clean: @rm -f $*.php php_$*.h clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" php_clean rm -f clientdata_prop_a.php clientdata_prop_b.php php_clientdata_prop_a.h php_clientdata_prop_b.h rm -f import_stl_a.php import_stl_b.php php_import_stl_a.h php_import_stl_b.h rm -f imports_a.php imports_b.php php_imports_a.h php_imports_b.h rm -f mod_a.php mod_b.php php_mod_a.h php_mod_b.h rm -f multi_import_a.php multi_import_b.php php_multi_import_a.h php_multi_import_b.h rm -f packageoption_a.php packageoption_b.php packageoption_c.php php_packageoption_a.h php_packageoption_b.h php_packageoption_c.h swig-3.0.2/Examples/test-suite/php/skel.php0000664000175000017500000000033312343605122020464 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/argout_runme.php0000664000175000017500000000202012343605122022230 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/evil_diamond_ns_runme.php0000664000175000017500000000056312343605122024073 0ustar williamwilliam swig-3.0.2/Examples/test-suite/php/director_enum_runme.php0000664000175000017500000000104212343605122023571 0ustar williamwilliamsay_hi(director_enum::hello), $b->say_hello(director_enum::hi), "say failed"); check::done(); ?> swig-3.0.2/Examples/test-suite/php/conversion_namespace_runme.php0000664000175000017500000000032612343605122025137 0ustar williamwilliamtoFoo(); check::classname("foo",$foo); check::done(); ?> swig-3.0.2/Examples/test-suite/php/char_strings_runme.php0000664000175000017500000000456712343605122023437 0ustar williamwilliam swig-3.0.2/Examples/test-suite/cpp11_type_traits.i0000664000175000017500000000204612343605122021756 0ustar williamwilliam%module cpp11_type_traits // The example in the CPlusPlus11.html documentation. // This doesn't really directly test functionality in type_traits as it doesn't provide // much for use by target languages, rather it tests usage of it. %inline %{ #include // First way of operating. template< bool B > struct algorithm { template< class T1, class T2 > static int do_it(T1 &, T2 &) { /*...*/ return 1; } }; // Second way of operating. template<> struct algorithm { template< class T1, class T2 > static int do_it(T1, T2) { /*...*/ return 2; } }; // Instantiating 'elaborate' will automatically instantiate the correct way to operate, depending on the types used. template< class T1, class T2 > int elaborate(T1 A, T2 B) { // Use the second way only if 'T1' is an integer and if 'T2' is // a floating point, otherwise use the first way. return algorithm< std::is_integral::value && std::is_floating_point::value >::do_it(A, B); } %} %template(Elaborate) elaborate; %template(Elaborate) elaborate; swig-3.0.2/Examples/test-suite/director_nested.i0000664000175000017500000000267612343605122021571 0ustar williamwilliam%module(directors="1",dirprot="1") director_nested #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR %{ #include #include %} %include "std_string.i" %feature("director") Bar; %feature("director") Foo; %feature("director") FooBar; %newobject *::create(); %inline { template class Foo { public: virtual ~Foo() {} std::string advance() { return "Foo::advance;" + do_advance(); } protected: virtual std::string do_advance() = 0; }; } %template(Foo_int) Foo; %inline { class Bar : public Foo { public: std::string step() { return "Bar::step;" + advance(); } protected: std::string do_advance() { return "Bar::do_advance;" + do_step(); } #if defined(SWIGPYTHON) || defined(SWIGRUBY) || \ defined(SWIGJAVA) || defined(SWIGOCAML) || defined(SWIGCSHARP) virtual std::string do_step() const = 0; #else virtual std::string do_step() const {return "";}; #endif }; template class FooBar : public Bar { public: virtual C get_value() const = 0; virtual const char * get_name() { return "FooBar::get_name"; } const char *name() { return get_name(); } static FooBar *get_self(FooBar *a) { return a; } }; } %template(FooBar_int) FooBar; swig-3.0.2/Examples/test-suite/nspace.i0000664000175000017500000000643712343605122017664 0ustar williamwilliam// Test the nspace feature %module nspace // nspace feature only supported by these languages #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT) #if defined(SWIGJAVA) SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) #endif %nspace; %nonspace Outer::Inner2::NoNSpacePlease; %nonspace Outer::Inner2::NoNSpacePlease::ReallyNoNSpaceEnum; %copyctor; %ignore Outer::Inner2::Color::Color(); #define CONSTANT100 100 %inline %{ namespace Outer { class namespce { }; namespace Inner1 { enum Channel { Diffuse, Specular = 0x10, Transmission1 }; enum { ColorEnumVal1, ColorEnumVal2 = 0x11, ColorEnumVal3 }; struct Color { static Color* create() { return new Color(); } enum Channel { Diffuse, Specular = 0x20, Transmission }; enum { ColorEnumVal1, ColorEnumVal2 = 0x22, ColorEnumVal3 }; int instanceMemberVariable; static int staticMemberVariable; static const int staticConstMemberVariable = 222; static const Channel staticConstEnumMemberVariable = Transmission; void colorInstanceMethod(double d) {} static void colorStaticMethod(double d) {} }; // Color int Color::staticMemberVariable = 0; Color namespaceFunction(Color k) { return k; } int namespaceVar = 0; } // Inner1 namespace Inner2 { enum Channel { Diffuse, Specular = 0x30, Transmission2 }; struct Color { Color() : instanceMemberVariable(0) {} static Color* create() { return new Color(); } enum Channel { Diffuse, Specular = 0x40, Transmission }; enum { ColorEnumVal1, ColorEnumVal2 = 0x33, ColorEnumVal3 }; int instanceMemberVariable; static int staticMemberVariable; static const int staticConstMemberVariable = 333; static const Channel staticConstEnumMemberVariable = Transmission; void colorInstanceMethod(double d) {} static void colorStaticMethod(double d) {} void colors(const Inner1::Color& col1a, const Outer::Inner1::Color& col1b, const Color &col2a, const Inner2::Color& col2b, const Outer::Inner2::Color& col2c) {} }; // Color int Color::staticMemberVariable = 0; class NoNSpacePlease { public: enum NoNSpaceEnum { NoNspace1 = 1, NoNspace2 = 10 }; enum ReallyNoNSpaceEnum { ReallyNoNspace1 = 1, ReallyNoNspace2 = 10 }; static int noNspaceStaticFunc() { return 10; } }; } // Inner2 // Derived class namespace Inner3 { struct Blue : Inner2::Color { void blueInstanceMethod() {} }; } namespace Inner4 { struct Blue : Inner2::Color { void blueInstanceMethod() {} }; } class SomeClass { public: Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; } Inner2::Color::Channel GetInner2ColorChannel() { return Inner2::Color::Transmission; } Inner1::Channel GetInner1Channel() { return Inner1::Transmission1; } Inner2::Channel GetInner2Channel() { return Inner2::Transmission2; } }; // SomeClass } // Outer namespace Outer { struct MyWorldPart2 {}; } struct GlobalClass { void gmethod() {} }; void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {} %} #else //#warning nspace feature not yet supported in this target language #endif swig-3.0.2/Examples/test-suite/pure_virtual.i0000664000175000017500000000310112343605122021115 0ustar williamwilliam/* SF Bug #445219, submitted by Krzysztof Kozminski . Swig 1.3.6 gets confused by pure virtual destructors, as in this file: */ %module(ruby_minherit="1") pure_virtual %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */ %nodefaultctor C; %nodefaultdtor C; %nodefaultctor E; %nodefaultdtor E; %inline %{ class A { public: A() { }; virtual ~A() = 0; virtual void something() = 0; virtual void method() = 0; }; class B : public A { public: B() {}; virtual ~B() { }; virtual void something() { }; virtual void method() { }; }; /* class C is abstract because it doesn't define all methods in A */ class C : public A { public: virtual ~C() { }; virtual void method() { }; } ; /* class D is not abstract, it defines everything */ class D : public C { public: virtual ~D() { }; virtual void something() { }; } ; /* Another abstract class */ class AA { public: virtual ~AA() { } virtual void method2() = 0; }; /* Multiple inheritance between two abstract classes */ class E : public C, public AA { public: virtual void something() { }; }; %} /* Fill in method from AA. This class should be constructable */ #if defined(SWIGCSHARP) || defined(SWIGD) %ignore F::method2(); // Work around for lack of multiple inheritance support - base AA is ignored. #endif %inline %{ class F : public E { public: virtual void method2() { } }; %} %{ A::~A() {} %} swig-3.0.2/Examples/test-suite/exception_order.i0000664000175000017500000000371612343605122021601 0ustar williamwilliam%module exception_order %warnfilter(SWIGWARN_RUBY_WRONG_NAME); #if defined(SWIGGO) && defined(SWIGGO_GCCGO) %{ #ifdef __GNUC__ #include #endif %} #endif %include "exception.i" %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} /* last resource, catch everything but don't override user's throw declarations. */ #if defined(SWIGUTL) %exception { try { $action } catch(...) { SWIG_exception_fail(SWIG_RuntimeError,"postcatch unknown"); } } #elif defined(SWIGGO) && defined(SWIGGO_GCCGO) %exception %{ try { $action #ifdef __GNUC__ } catch (__cxxabiv1::__foreign_exception&) { throw; #endif } catch(...) { SWIG_exception(SWIG_RuntimeError,"postcatch unknown"); } %} #else %exception { try { $action } catch(...) { SWIG_exception(SWIG_RuntimeError,"postcatch unknown"); } } #endif %catches(E1,E2*,ET,ET,...) A::barfoo(int i); %allowexception efoovar; %allowexception A::efoovar; %inline %{ int efoovar; int foovar; const int cfoovar = 1; struct E1 { }; struct E2 { }; struct E3 { }; template struct ET { }; struct A { static int sfoovar; static const int CSFOOVAR = 1; int foovar; int efoovar; /* caught by the user's throw definition */ int foo() throw(E1) { throw E1(); return 0; } int bar() throw(E2) { throw E2(); return 0; } /* caught by %postexception */ int foobar() { throw E3(); return 0; } int barfoo(int i) { if (i == 1) { throw E1(); } else if (i == 2) { static E2 *ep = new E2(); throw ep; } else if (i == 3) { throw ET(); } else { throw ET(); } return 0; } }; int A::sfoovar = 1; %} %template(ET_i) ET; %template(ET_d) ET; swig-3.0.2/Examples/test-suite/overload_complicated.i0000664000175000017500000000560612343605122022567 0ustar williamwilliam// A complicated test of overloaded functions %module overload_complicated #ifndef SWIG_NO_OVERLOAD // Different warning filters needed for scripting languages (eg Python) and for statically typed languages (eg C#). %warnfilter(509, 516) Pop::Pop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used. %warnfilter(509, 516) Pop::hip; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used. %warnfilter(509, 516) Pop::hop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used. %warnfilter(509, 516) Pop::pop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used. %warnfilter(516) Pop::bop; // Overloaded method xxxx ignored. Method at xxx:y used. %warnfilter(516) Pop::bip; // Overloaded method xxxx ignored. Method at xxx:y used. %warnfilter(509, 516) ::muzak; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used. %typemap(in, numinputs=0) int l { $1 = 4711; } %inline %{ double foo(int, int, char *, int) { return 15; } double foo(int i, int j, double k = 17.4, int l = 18, char m = 'P') { return i + j + k + l + (int) m; } struct Pop { Pop(int* i) {} Pop(int& i) {} Pop(const int* i, bool b) {} Pop(const int* i) {} // Check overloaded in const only and pointers/references which target languages cannot disambiguate int hip(bool b) { return 701; } int hip(int* i) { return 702; } int hip(int& i) { return 703; } int hip(int* i) const { return 704; } int hip(const int* i) { return 705; } // Reverse the order for the above int hop(const int* i) { return 805; } int hop(int* i) const { return 804; } int hop(int& i) { return 803; } int hop(int* i) { return 802; } int hop(bool b) { return 801; } // Few more variations and order shuffled int pop(bool b) { return 901; } int pop(int* i) const { return 902; } int pop(int& i) { return 903; } int pop(int* i) { return 904; } int pop() { return 905; } int pop(const int* i) { return 906; } // Overload on const only int bop(int* i) { return 1001; } int bop(int* i) const { return 1002; } int bip(int* i) const { return 2001; } int bip(int* i) { return 2002; } }; // Globals int muzak(bool b) { return 3001; } int muzak(int* i) { return 3002; } int muzak(int& i) { return 3003; } int muzak(const int* i) { return 3004; } %} #endif swig-3.0.2/Examples/test-suite/nested_class.i0000664000175000017500000001373512343605122021061 0ustar williamwilliam%module nested_class #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct1; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass1; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion1; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass2; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct2; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion2; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass4Typedef; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct4Typedef; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion4Typedef; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass5; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct5; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion5; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultiple; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultipleDerived; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultipleAnonTypedef1; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultipleNamedTypedef; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerSameName; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer2::IgnoreMe; %inline %{ struct Outer { typedef int Integer; /////////////////////////////////////////// struct InnerStruct1 { Integer x; }; class InnerClass1 { public: Integer x; }; union InnerUnion1 { Integer x; double y; }; /////////////////////////////////////////// #if defined(__GNUC__) || defined(_MSC_VER) || defined(SWIG) /* some compilers do not accept these */ class { public: Integer a; }; struct { Integer b; }; #endif union { Integer c; double d; }; /////////////////////////////////////////// class InnerClass2 { public: Integer x; } InnerClass2Instance; struct InnerStruct2 { Integer x; } InnerStruct2Instance; union InnerUnion2 { Integer x; double y; } InnerUnion2Instance; /////////////////////////////////////////// class { public: Integer x; } InnerClass3Instance; struct { Integer x; } InnerStruct3Instance; union { Integer x; double y; } InnerUnion3Instance; /////////////////////////////////////////// typedef class { public: Integer x; } InnerClass4Typedef; typedef struct { Integer x; } InnerStruct4Typedef; typedef union { Integer x; double y; } InnerUnion4Typedef; /////////////////////////////////////////// typedef class InnerClass5 { public: Integer x; } InnerClass5Typedef; typedef struct InnerStruct5 { Integer x; } InnerStruct5Typedef; typedef union InnerUnion5 { Integer x; double y; } InnerUnion5Typedef; // bug #909387 - inner declared types are treated as forward declarations InnerStruct1* makeInnerStruct1() { return 0; } InnerClass1* makeInnerClass1() { return 0; } InnerUnion1* makeInnerUnion1() { return 0; } InnerStruct2* makeInnerStruct2() { return 0; } InnerClass2* makeInnerClass2() { return 0; } InnerUnion2* makeInnerUnion2() { return 0; } InnerStruct4Typedef* makeInnerStruct4Typedef() { return 0; } InnerClass4Typedef* makeInnerClass4Typedef() { return 0; } InnerUnion4Typedef* makeInnerUnion4Typedef() { return 0; } InnerStruct5* makeInnerStruct5() { return 0; } InnerClass5* makeInnerClass5() { return 0; } InnerUnion5* makeInnerUnion5() { return 0; } InnerStruct5Typedef* makeInnerStruct5Typedef() { return 0; } InnerClass5Typedef* makeInnerClass5Typedef() { return 0; } InnerUnion5Typedef* makeInnerUnion5Typedef() { return 0; } /////////////////////////////////////////// struct InnerMultiple { Integer x; } MultipleInstance1, MultipleInstance2, *MultipleInstance3, MultipleInstance4[2]; struct InnerMultipleDerived : public InnerMultiple { Integer xx; } MultipleDerivedInstance1, MultipleDerivedInstance2, *MultipleDerivedInstance3, MultipleDerivedInstance4[2]; struct { Integer x; } MultipleInstanceAnon1, MultipleInstanceAnon2, *MultipleInstanceAnon3, MultipleInstanceAnon4[2]; struct : public InnerMultiple { Integer xx; } MultipleInstanceAnonDerived1, MultipleInstanceAnonDerived2, *MultipleInstanceAnonDerived3, MultipleInstanceAnonDerived4[2]; #if defined(__GNUC__) || defined(_MSC_VER) || defined(SWIG) /* some compilers do not accept these */ struct : public InnerMultiple { Integer xx; }; class : public InnerMultiple { public: Integer yy; }; #endif /////////////////////////////////////////// typedef struct { Integer x; } InnerMultipleAnonTypedef1, InnerMultipleAnonTypedef2, *InnerMultipleAnonTypedef3; InnerMultipleAnonTypedef1* makeInnerMultipleAnonTypedef1() { return 0; } InnerMultipleAnonTypedef2* makeInnerMultipleAnonTypedef2() { return 0; } InnerMultipleAnonTypedef3* makeInnerMultipleAnonTypedef3() { return 0; } typedef struct InnerMultipleNamedTypedef { Integer x; } InnerMultipleNamedTypedef1, InnerMultipleNamedTypedef2, *InnerMultipleNamedTypedef3; InnerMultipleNamedTypedef* makeInnerMultipleNamedTypedef() { return 0; } InnerMultipleNamedTypedef1* makeInnerMultipleNamedTypedef1() { return 0; } InnerMultipleNamedTypedef2* makeInnerMultipleNamedTypedef2() { return 0; } InnerMultipleNamedTypedef3* makeInnerMultipleNamedTypedef3() { return 0; } /////////////////////////////////////////// typedef struct InnerSameName { Integer x; struct InnerSameName2 {}; } InnerSameName; InnerSameName* makeInnerSameName() { return 0; } }; #if defined(SWIGCSHARP) || defined (SWIGJAVA) // place a class with the same name as in Outer in global scope, to test language symbol table class InnerSameName {}; class InnerSameName2 {}; #endif %} // Ignore nested struct instance %ignore Outer2::IgnoreMeInstance; %{ struct Outer2 { struct IgnoreMe { int xx; }; }; %} struct Outer2 { struct IgnoreMe { int xx; } IgnoreMeInstance; }; swig-3.0.2/Examples/test-suite/abstract_virtual.i0000664000175000017500000000235612343605122021760 0ustar williamwilliam%module(ruby_minherit="1") abstract_virtual %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, D, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */ %inline %{ #if defined(_MSC_VER) #pragma warning( disable : 4250) // warning C4250: 'D' : inherits 'B::B::foo' via dominance #endif struct A { virtual ~A() { } virtual int foo() = 0; }; struct B : virtual A { int foo() { return 0; } }; struct C: virtual A { protected: C() { } }; // // This case works // struct D : B, C { D() { } }; // // This case doesn't work. // It seems the is_abstract function doesn't // navigate the entire set of base classes, // and therefore, it doesn't detect B::foo() // #ifdef SWIG // Uncommenting this line, of course, make it works // %feature("notabstract") E; #endif // struct E : C, B { E() { } }; %} swig-3.0.2/Examples/test-suite/clisp/0000775000175000017500000000000012343605122017341 5ustar williamwilliamswig-3.0.2/Examples/test-suite/clisp/Makefile.in0000664000175000017500000000235312343605122021411 0ustar williamwilliam####################################################################### # Makefile for clisp test-suite ####################################################################### LANGUAGE = clisp CLISP = @CLISPBIN@ SCRIPTSUFFIX = _runme.lisp srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ include $(srcdir)/../common.mk # Overridden variables here # no C++ tests for now CPP_TEST_CASES = #C_TEST_CASES += # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.lisp appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra clisp code) %.clean: @exit 0 clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" clisp_clean swig-3.0.2/Examples/test-suite/cpp_broken.i0000664000175000017500000000014312343605122020521 0ustar williamwilliam%module cpp_broken // bug #940318 %inline %{ typedef enum { eZero = 0 #define ONE 1 } EFoo; %} swig-3.0.2/Examples/test-suite/profiletest.i0000664000175000017500000000131712343605122020743 0ustar williamwilliam%module profiletest %inline %{ class A { public: A() {} }; class B { A aa; public: B() {} A fn(const A* a) { return *a; } int fi(int a) { return a; } int fj(const A* a) { return 10; } B* fk(int i) { return this; } const char* fl(int i) { return "hello"; } const char* fs(const char *s) { return s; } int fi(int a, int) { return a; } int fi(char *) { return 1; } int fi(double) { return 2; } int fi(A *a) { return 3; } int fi(int a, int, int) { return a; } int fi(int a, int, int, int) { return a; } }; %} swig-3.0.2/Examples/test-suite/preproc_include_h1.i0000664000175000017500000000002112343605122022137 0ustar williamwilliam#define const1 1 swig-3.0.2/Examples/test-suite/abstract_inherit.i0000664000175000017500000000145012343605122021726 0ustar williamwilliam%module abstract_inherit %warnfilter(SWIGWARN_TYPE_ABSTRACT) Spam; %warnfilter(SWIGWARN_TYPE_ABSTRACT) Bar; %inline %{ class Foo { public: virtual ~Foo() { } virtual int blah() = 0; }; class Bar : public Foo { }; class Spam: public Foo { public: Spam() { } }; template class NRFilter { public: virtual ~NRFilter() { } protected: virtual void do_filter() = 0; }; template class NRRCFilter : public NRFilter { }; template class NRRCFilterpro : protected NRFilter { }; template class NRRCFilterpri : private NRFilter { }; %} %template(NRFilter_i) NRFilter; %template(NRRCFilter_i) NRRCFilter; %template(NRRCFilterpro_i) NRRCFilterpro; %template(NRRCFilterpri_i) NRRCFilterpri; swig-3.0.2/Examples/test-suite/preproc_include_e withspace.h0000664000175000017500000000003112343605122024023 0ustar williamwilliam int multiply50(int a); swig-3.0.2/Examples/test-suite/virtual_derivation.i0000664000175000017500000000151412343605122022314 0ustar williamwilliam%module virtual_derivation /* Try to add to your favorite language a runtime test like this: b = B(3) if (b.get_a() != b.get_b()): print "something is wrong" The test runs fine with python, but not with ruby. */ %inline %{ struct A { ~A() { } int m_a; A(int a) :m_a(a) { } int get_a() { return m_a; } }; struct B : virtual A { B(int a): A(a) { } int get_b() { return get_a(); } // in ruby, get_a() returns trash if called from b, unless is // wrapped with the previous get_b or using the 'using' // declaration: // using A::get_a; }; class IndexReader{ public: virtual void norms() = 0; }; class MultiReader : public IndexReader { protected: MultiReader(); }; %} swig-3.0.2/Examples/test-suite/cpp11_null_pointer_constant.i0000664000175000017500000000073012343605122024030 0ustar williamwilliam/* This testcase checks whether SWIG correctly treats the new nullptr_t constant introduced in C++11. */ %module cpp11_null_pointer_constant %feature("autodoc") A::NullPtrMethod; // Triggers conversion of nullptr to None, nil etc in target language %feature("compactdefaultargs") A::NullPtrMethod; %inline %{ const int *const MyIntegerPtr = nullptr; class A { public: A() : _myA(nullptr) { } A *_myA; void NullPtrMethod(double *ptr = nullptr) {} }; %} swig-3.0.2/Examples/test-suite/evil_diamond.i0000664000175000017500000000126112343605122021033 0ustar williamwilliam%module(ruby_minherit="1") evil_diamond %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) bar; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) baz; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C#, D & Java, PHP multiple inheritance %inline %{ class foo { }; class bar : public foo { }; class baz : public foo { }; class spam : public bar, public baz { }; foo *test(foo *f) { return f; } %} swig-3.0.2/Examples/test-suite/fvirtual.i0000664000175000017500000000126612343605122020242 0ustar williamwilliam// This testcase tests corner cases for the -fvirtual optimisation flag. // Note that the test-suite does not actually run with -fvirtual at any point, but this can be tested using the SWIG_FEATURES=-fvirtual env variable. %module fvirtual // Test overloaded methods #1508327 (requires a scripting language runtime test) %inline %{ class Node { public: virtual int addChild( Node *child ) { return 1; } virtual ~Node() {} }; class NodeSwitch : public Node { public : virtual int addChild( Node *child ) { return 2; } // This was hidden with -fvirtual virtual int addChild( Node *child, bool value ) { return 3; } virtual ~NodeSwitch() {} }; %} swig-3.0.2/Examples/test-suite/constover.i0000664000175000017500000000132312343605122020422 0ustar williamwilliam// This test checks SWIG's code generation for C++ functions // and methods that differ only in constness. %module constover %rename(test_pconst) test(const char *); %rename(test_constm) test(char *) const; %rename(test_pconstm) test(const char *) const; %inline %{ char *test(char *x) { return (char *) "test"; } char *test(const char *x) { return (char *) "test_pconst"; } class Foo { public: Foo() { } char *test(char *x) { return (char *) "test"; } char *test(const char *x) { return (char *) "test_pconst"; } char *test(char *x) const { return (char *) "test_constmethod"; } char *test(const char *x) const { return (char *) "test_pconstmethod"; } }; %} swig-3.0.2/Examples/test-suite/enum_missing.i0000664000175000017500000000140612343605122021077 0ustar williamwilliam%module enum_missing // Test when SWIG does not parse the enum definition %{ enum AVPixelFormat { AV_PIX_FMT_NONE = -1, AV_PIX_FMT_YUV420P }; enum AVPixelFormat2 { AV_PIX_FMT_NONE2 = -1, AV_PIX_FMT_YUV420P2 }; %} %inline %{ typedef struct AVCodecContext { enum AVPixelFormat pix_fmt; enum AVPixelFormat2 pix_fmt2; } AVCodecContext; enum AVPixelFormat global_fmt; enum AVPixelFormat2 global_fmt2; enum AVPixelFormat use_pixel_format(enum AVPixelFormat px) { return px; } enum AVPixelFormat * use_pixel_format_ptr(enum AVPixelFormat *px) { return px; } const enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) { return px; } const enum AVPixelFormat2 * use_pixel_format_ptr2(const enum AVPixelFormat2 *px) { return px; } %} swig-3.0.2/Examples/test-suite/r_copy_struct.i0000664000175000017500000000142712343605122021304 0ustar williamwilliam%module r_copy_struct %feature("opaque", "yes") B; %feature("opaque", "yes") C; %inline %{ struct A { int i; unsigned int ui; double d; char* str; int **tmp; }; struct A getA(); struct A* getARef(); typedef struct { int invisible; } B; struct C { int invisible; double blind; }; typedef B C; B* getBRef(); struct C* getCRef(); C* getCCRef(); typedef struct { int x; double u; } D; struct A getA() { struct A a; a.i = 10; a.d = 3.1415; return a; } static struct A fixed = {20, 3, 42.0}; struct A * getARef() { return(&fixed); } static B bb = {101}; B* getBRef() { return(&bb); } struct C cc = {201, 3.14159}; struct C * getCRef() { return(&cc); } C* getCCRef() { return(&bb); } D bar() { D a; a.x = 1; a.u = 0; return(a); } %} swig-3.0.2/Examples/test-suite/enum_rename.i0000664000175000017500000000046512343605122020701 0ustar williamwilliam%module enum_rename %warnfilter(SWIGWARN_PARSE_REDEFINED) S_May; // %rename using regex can do the equivalent of these two renames, which was resulting in uncompileable code %rename(May) M_May; %rename(May) S_May; %inline %{ enum Month { M_Jan, M_May, M_Dec }; enum Severity { S_May, S_Can, S_Must }; %} swig-3.0.2/Examples/test-suite/naturalvar.i0000664000175000017500000000055212343605122020562 0ustar williamwilliam%module(naturalvar) naturalvar #ifdef __cplusplus %include std_string.i %inline { struct Foo { }; Foo f; std::string s; struct Bar { int i; Foo f; std::string s; }; } #else %inline { typedef struct _foo { }Foo; Foo f; char *s; typedef struct _bar { int i; Foo f; char *s; } Bar; } #endif swig-3.0.2/Examples/test-suite/cpp_nodefault.i0000664000175000017500000000072212343605122021225 0ustar williamwilliam// This file tests SWIG pass/return by value for // a class with no default constructor %module cpp_nodefault %inline %{ class Foo { public: int a; Foo(int x, int y) { } ~Foo() {} }; Foo create(int x, int y) { return Foo(x,y); } typedef Foo Foo_t; void consume(Foo f, Foo_t g) {} class Bar { public: void consume(Foo f, Foo_t g) {} Foo create(int x, int y) { return Foo(x,y); } }; %} %{ Foo gvar = Foo(3,4); %} Foo gvar; swig-3.0.2/Examples/test-suite/template_default_inherit.i0000664000175000017500000000100412343605122023435 0ustar williamwilliam%module template_default_inherit %warnfilter(SWIGWARN_RUBY_WRONG_NAME) A::nindex; /* Ruby, wrong constant name */ %inline %{ template struct A { typedef unsigned int size_type; static const size_type nindex = static_cast(-1); }; template struct B : A { typedef typename A::size_type size_type; void say_hi(size_type index = A::nindex) {} }; %} %template(A_int) A; %template(B_int) B; swig-3.0.2/Examples/test-suite/ruby_li_std_speed.i0000664000175000017500000000100512343605122022074 0ustar williamwilliam// A speed test of the ruby stl %module ruby_li_std_speed %include %include %include %include %template(RbList) std::list; %template(RbVector) std::vector; %template(RbDeque) std::deque; %template(RbSet) std::set; %template(RbFloatList) std::list; %template(RbFloatVector) std::vector; %template(RbFloatDeque) std::deque; %template(RbFloatSet) std::set; swig-3.0.2/Examples/test-suite/namespace_extend.i0000664000175000017500000000070712343605122021710 0ustar williamwilliam%module namespace_extend %warnfilter(SWIGWARN_RUBY_WRONG_NAME) bar; /* Ruby, wrong class name */ %{ namespace foo { class bar { public: }; } foo::bar *new_foo_bar() { return new foo::bar; } void delete_foo_bar(foo::bar *self) { delete self; } int foo_bar_blah(foo::bar *self, int x) { return x; } %} namespace foo { class bar { public: %extend { bar(); ~bar(); int blah(int x); }; }; } swig-3.0.2/Examples/test-suite/imports.list0000664000175000017500000000002412343605122020615 0ustar williamwilliamimports_a imports_b swig-3.0.2/Examples/test-suite/typemap_out_optimal.i0000664000175000017500000000216512343605122022500 0ustar williamwilliam// Test the optimal attribute in the out typemap %module typemap_out_optimal // Just the following languages tested #if defined (SWIGCSHARP) || defined (SWIGD) %typemap(out, optimal="1") SWIGTYPE %{ $result = new $1_ltype((const $1_ltype &)$1); %} #elif defined (SWIGJAVA) %typemap(out, optimal="1") SWIGTYPE %{ *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1); %} #elif defined (SWIGUTL) %typemap(out,noblock="1", optimal="1") SWIGTYPE { %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags)); } #endif %ignore XX::operator=; #ifdef SWIGD %rename(trace) XX::debug; #endif %inline %{ #include using namespace std; struct XX { XX() { if (debug) cout << "XX()" << endl; } XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; } XX(const XX &other) { if (debug) cout << "XX(const XX &)" << endl; } XX& operator =(const XX &other) { if (debug) cout << "operator=(const XX &)" << endl; return *this; } ~XX() { if (debug) cout << "~XX()" << endl; } static XX create() { return XX(123); } static bool debug; }; bool XX::debug = true; %} swig-3.0.2/Examples/test-suite/extern_throws.i0000664000175000017500000000047712343605122021324 0ustar williamwilliam%module extern_throws %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %inline %{ #include extern int get() throw(std::exception); %} %{ int get() throw(std::exception) { return 0; } %} swig-3.0.2/Examples/test-suite/ret_by_value.i0000664000175000017500000000045612343605122021066 0ustar williamwilliam/* Simple test to check SWIG's handling of return by value */ %module ret_by_value %warnfilter(SWIGWARN_RUBY_WRONG_NAME) test; /* Ruby, wrong class name */ %inline %{ typedef struct { int myInt; short myShort; } test; test get_test() { test myTest = {100, 200}; return myTest; } %} swig-3.0.2/Examples/test-suite/template_ns_scope.i0000664000175000017500000000111712343605122022105 0ustar williamwilliam%module template_ns_scope // Tests a scoping bug reported by Marcelo Matus. %inline %{ namespace hi { enum Hello { Hi, Hola }; template struct A { public: A() {} // *** Here, the const. breaks swig *** // *** swig works without it *** }; namespace hello { template struct B : A { int say_hi() { return 0; } }; } } %} namespace hi { %template(A_Hi) A; namespace hello { %template(B_Hi) B; } } swig-3.0.2/Examples/test-suite/constant_expr.i0000664000175000017500000000027512343605122021274 0ustar williamwilliam%module constant_expr; /* Tests of constant expressions. */ %inline %{ /* % didn't work in SWIG 1.3.40 and earlier. */ const int X = 123%7; #define FOO 12 % 9 double d_array[12 % 9]; %} swig-3.0.2/Examples/test-suite/enum_template.i0000664000175000017500000000150012343605122021234 0ustar williamwilliam%module enum_template %warnfilter(SWIGWARN_RUBY_WRONG_NAME) eTest0; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) eTest1; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) eTest2; /* Ruby, wrong class name */ /* From bug report 992329: In Python I see >>> import enum_template >>> enum_template.MakeETest() '_60561408_p_ETest' >>> enum_template.TakeETest(0) Traceback (most recent call last): File "", line 1, in ? TypeError: Expected a pointer Without the %template, things work fine: the first function call returns an integer, and the second succeeds. */ %inline %{ enum ETest { eTest0, eTest1, eTest2 }; void TakeETest(ETest test) {} ETest MakeETest(void) {return eTest1;} template class CTempl { }; %} %template(CTempl_ETest) CTempl; swig-3.0.2/Examples/test-suite/typemap_manyargs.i0000664000175000017500000000142712343605122021765 0ustar williamwilliam%module typemap_manyargs %typemap(in,numinputs=0) (int* a1, int* a2, int* a3, int* a4, int* a5, int* a6, int *a7, int *a8, int *a9, int *a10) (int temp1,int temp2,int temp3,int temp4,int temp5,int temp6,int temp7,int temp8, int temp9, int temp10) { $1 = &temp1; // the code generate for this is arg2 = &temp1; $2 = &temp2; // the code generate for this is arg3 = &temp2; $3 = &temp3; // and so on... $4 = &temp4; $5 = &temp5; $6 = &temp6; $7 = &temp7; $8 = &temp8; $9 = &temp9; $10 = &temp10; // the code generated for this was arg20 = &temp10; and arg20 does not exist. int $10_ptr = 0; // Was arg20_ptr } %inline %{ void my_c_function(char * filename,int* a1, int* a2, int* a3, int* a4, int* a5, int* a6, int *a7, int *a8, int *a9, int *a10) {} %} swig-3.0.2/Examples/test-suite/string_simple.i0000664000175000017500000000036612343605122021265 0ustar williamwilliam%module string_simple %newobject copy_string; %inline %{ #include const char* copy_string(const char* str) { size_t len = strlen(str); char* newstring = (char*) malloc(len + 1); strcpy(newstring, str); return newstring; } %} swig-3.0.2/Examples/test-suite/template_base_template.i0000664000175000017500000000145012343605122023101 0ustar williamwilliam%module template_base_template %warnfilter(SWIGWARN_RUBY_WRONG_NAME) traits; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_PARSE_EXPLICIT_TEMPLATE); %inline %{ template struct traits { typedef ArgType arg_type; typedef ResType res_type; }; template struct Funktion { }; // Egad! template struct Klass : Funktion::arg_type, typename traits::res_type> { }; %} %{ template struct Funktion ; template struct Klass ; %} %template(traits_dd) traits ; %template(Funktion_dd) Funktion ; %template(Klass_dd) Klass ; swig-3.0.2/Examples/test-suite/arrays.i0000664000175000017500000000307612343605122017710 0ustar williamwilliam/* This test case tests that various types of arrays are working. */ %module arrays %{ #include %} %inline %{ #define ARRAY_LEN 2 typedef enum {One, Two, Three, Four, Five} finger; typedef struct { double double_field; } SimpleStruct; typedef struct { char array_c [ARRAY_LEN]; signed char array_sc[ARRAY_LEN]; unsigned char array_uc[ARRAY_LEN]; short array_s [ARRAY_LEN]; unsigned short array_us[ARRAY_LEN]; int array_i [ARRAY_LEN]; unsigned int array_ui[ARRAY_LEN]; long array_l [ARRAY_LEN]; unsigned long array_ul[ARRAY_LEN]; long long array_ll[ARRAY_LEN]; float array_f [ARRAY_LEN]; double array_d [ARRAY_LEN]; SimpleStruct array_struct[ARRAY_LEN]; SimpleStruct* array_structpointers[ARRAY_LEN]; int* array_ipointers [ARRAY_LEN]; finger array_enum[ARRAY_LEN]; finger* array_enumpointers[ARRAY_LEN]; const int array_const_i[ARRAY_LEN]; } ArrayStruct; void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN]) {} /* Pointer helper functions used in the Java run test */ int* newintpointer() { return (int*)malloc(sizeof(int)); } void setintfrompointer(int* intptr, int value) { *intptr = value; } int getintfrompointer(int* intptr) { return *intptr; } %} // This tests wrapping of function that involves pointer to array %inline %{ void array_pointer_func(int (*x)[10]) {} %} %inline %{ typedef float FLOAT; typedef FLOAT cartPosition_t[3]; typedef struct { cartPosition_t p; } CartPoseData_t; %} swig-3.0.2/Examples/test-suite/template_default_class_parms_typedef.i0000664000175000017500000000612512343605122026033 0ustar williamwilliam%module template_default_class_parms_typedef // Based on template_default_class_parms testcase but using typedefs in template %feature("python:nondynamic"); %inline %{ namespace Space { struct SomeType {}; struct AnotherType {}; template class Bar { public: typedef CC C; typedef DD D; typedef EE E; C CType; D DType; E EType; // Use typedef with no qualifiers Bar(C c, D d, E e) {} C method(C c, D d, E e) { return c; } // Use typedef with classname qualifiers Bar(bool, typename Bar::C c, typename Bar::D d, typename Bar::E e) {} typename Bar::C method_1(typename Bar::C c, typename Bar::D d, typename Bar::E e) { return c; } // Use typedef with classname and full template parameter qualifiers Bar(bool, bool, typename Bar::C c, typename Bar::D d, typename Bar::E e) {} typename Bar::C method_2(typename Bar::C c, typename Bar::D d, typename Bar::E e) { return c; } // Use typedef with namespace and classname and full template parameter qualifiers Bar(bool, bool, bool, typename Space::Bar::C c, typename Space::Bar::D d, typename Space::Bar::E e) {} typename Space::Bar::C method_3(typename Space::Bar::C c, typename Space::Bar::D d, typename Space::Bar::E e) { return c; } }; template class Foo { public: typedef TT T; T TType; // Use typedef with no qualifiers Foo(T t) {} T method(T t) { return t; } // Use typedef with classname qualifiers Foo(const T &, T t) {} typename Foo::T method_A(typename Foo::T t) { return t; } // Use typedef with classname and full template parameter qualifiers Foo(const typename Foo::T &, const typename Foo::T &, typename Foo::T t) {} typename Foo::T method_B(typename Foo::T t) { return t; } // Use typedef with namespace and classname and full template parameter qualifiers Foo(const typename Foo::T &, const typename Foo::T &, const typename Foo::T &, typename Foo::T t) {} typename Foo::T method_C(typename Foo::T t) { return t; } }; template class ATemplate {}; template struct UsesBar { void use_A(typename Bar::C, typename Bar::D, typename Bar::E) {} void use_B(const typename Bar::C &, const typename Bar::D &, const typename Bar::E &) {} void use_C(typename Space::Bar::C, typename Space::Bar::D, typename Space::Bar::E) {} void use_D(const typename Space::Bar::C &, const typename Space::Bar::D &, const typename Space::Bar::E &) {} }; } %} // Use defaults %template(DefaultBar) Space::Bar; %template(DefaultFoo) Space::Foo<>; // Don't use all defaults %template(BarAnotherTypeBool) Space::Bar; %template(FooAnotherType) Space::Foo; %template() Space::ATemplate<>; %template(UsesBarDouble) Space::UsesBar; swig-3.0.2/Examples/test-suite/namespace_forward_declaration.i0000664000175000017500000000112612343605122024426 0ustar williamwilliam%module namespace_forward_declaration %inline %{ namespace Space1 { namespace Space2 { struct XXX; struct YYY; } struct Space2::YYY { int yyy(int h) { return h; } }; struct Space1::Space2::XXX { int xxx(int h) { return h; } }; void testXXX1(Space1::Space2::XXX xx) { } void testXXX2(Space2::XXX xx) { } void testXXX3(::Space1::Space2::XXX xx) { } void testYYY1(Space1::Space2::YYY yy) { } void testYYY2(Space2::YYY yy) { } void testYYY3(::Space1::Space2::YYY yy) { } } %} swig-3.0.2/Examples/test-suite/multiple_inheritance.i0000664000175000017500000000371512343605122022613 0ustar williamwilliam/* This was broken in the perl module. See bug 962115 It tests basic multiple inheritance */ %module(ruby_minherit="1") multiple_inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, D, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, D, Java, PHP multiple inheritance */ %inline %{ class Bar { public: virtual ~Bar() { } virtual int bar() { return 1; } }; class Foo { public: virtual ~Foo() { } virtual int foo() { return 2; } }; template class Spam { public: virtual ~Spam() { } virtual int spam(const T& t) { return 100; } }; %} %template(SpamInt) Spam; %inline %{ class FooBar : public Foo, public Bar { public: virtual int fooBar() { return 3; } }; class FooBarSpam : public Foo, public Bar, public Spam { public: virtual int fooBarSpam() { return 4; } }; %} // Languages that don't support multiple inheritance should inherit from one of the non-ignored classes %ignore IgnoreMe; %ignore IgnoreMeToo; %inline %{ class IgnoreMe { public: virtual int ignoreme() { return 5; } virtual ~IgnoreMe() {} }; class IgnoreMeToo { public: virtual int ignoremetoo() { return 6; } virtual ~IgnoreMeToo() {} }; class IgnoreDerived1 : public IgnoreMe, public Bar { public: virtual int ignorederived1() { return 7; } }; class IgnoreDerived2 : public IgnoreMe, public IgnoreMeToo, public Bar { public: virtual int ignorederived2() { return 8; } }; class IgnoreDerived3 : public IgnoreMe, public Bar, public IgnoreMeToo { public: virtual int ignorederived3() { return 9; } }; class IgnoreDerived4 : public Bar, public IgnoreMe, public IgnoreMeToo { public: virtual int ignorederived4() { return 10; } }; %} swig-3.0.2/Examples/test-suite/cpp11_uniform_initialization.i0000664000175000017500000000173412343605122024200 0ustar williamwilliam/* This testcase checks whether SWIG syntactically correctly parses the initialization syntax using {} braces for uniform member initialization. */ %module cpp11_uniform_initialization %include %template(VectorInt) std::vector; %inline %{ struct BasicStruct { int x; double y; }; struct AltStruct { AltStruct(int x, double y) : x_{x}, y_{y} {} int getX() { return x_; } double getY() { return y_; } private: int x_; double y_; }; BasicStruct var1{5, 3.2}; // only fills the struct components AltStruct var2{2, 4.3}; // calls the constructor class MoreInit { public: int yarray[5] {1,2,3,4,5}; char *charptr {nullptr}; std::vector vi {1,2,3,4,5}; MoreInit() {} int more1(std::vector vv = {1,2,3,4}) { int sum = 0; for (int i : vv) sum += i; return sum; } }; const int arr1[] = {1,2,3}; const int arr2[]{1,2,3}; const int arr3[][3]{ {1,2,3}, {4,5,6} }; const int arr4[][3] = { {1,2,3}, {4,5,6} }; %} swig-3.0.2/Examples/test-suite/wrapmacro.i0000664000175000017500000000253612343605122020402 0ustar williamwilliam%module wrapmacro #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) SWIGMACRO_maximum; #endif /* Testing technique for wrapping macros */ %{ #ifdef max #undef max #endif %} /* Here, some macros to wrap */ %inline %{ typedef unsigned short guint16; #define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \ (guint16) ((guint16) (val) >> 8) | \ (guint16) ((guint16) (val) << 8))) /* Don't use max(), it's a builtin function for PHP. */ #define maximum(a,b) ((a) > (b) ? (a) : (b)) %} /* Here, the auxiliary macro to wrap a macro */ %define %wrapmacro(type, name, lparams, lnames) %rename(name) SWIGMACRO_##name; %inline %{ type SWIGMACRO_##name(lparams) { return name(lnames); } %} %enddef #define PLIST(...) __VA_ARGS__ /* Here, wrapping the macros */ %wrapmacro(guint16, GUINT16_SWAP_LE_BE_CONSTANT, guint16 val, val); %wrapmacro(size_t, maximum, PLIST(size_t a, const size_t& b), PLIST(a, b)); %wrapmacro(double, maximum, PLIST(double a, double b), PLIST(a, b)); /* Maybe in the future, a swig directive will make this easier: #define max(a,b) ((a) > (b) ? (a) : (b)) %wrapmacro double max(long a, double b); // target name is 'max' %wrapmacro(max_i) int max(int a, int b); // changes target name to 'max_i'. */ %{ #ifdef max #undef max #endif %} swig-3.0.2/Examples/test-suite/inherit.i0000664000175000017500000000046712343605122020052 0ustar williamwilliam// Test that was failing for Perl - the non-member Foo was being called when the member version was intended %module inherit %inline %{ const char* Foo(void) { return "Non-member Foo"; } class CBase { public: const char* Foo(void) { return "CBase::Foo"; } }; class CDerived : public CBase {}; %} swig-3.0.2/Examples/test-suite/director_abstract.i0000664000175000017500000000704712343605122022107 0ustar williamwilliam%module(directors="1") director_abstract %{ #include class Foo { public: virtual ~Foo() {} virtual std::string ping() = 0; virtual std::string pong() { return "Foo::pong();" + ping(); } }; %} %include %feature("director") Foo; class Foo { public: virtual ~Foo() {} virtual std::string ping() = 0; virtual std::string pong() { return "Foo::pong();" + ping(); } }; %feature("director"); %inline %{ class Example0 { protected: int xsize, ysize; public: Example0(int x, int y) : xsize(x), ysize(y) { } Example0() { } public: virtual ~Example0() {} int GetXSize() const { return xsize; } // pure virtual methods that must be overridden virtual int Color(unsigned char r, unsigned char g, unsigned char b) { return 0; } static int get_color(Example0 *ptr, unsigned char r, unsigned char g, unsigned char b) { return ptr->Color(r, g, b); } }; class Example1 { protected: int xsize, ysize; protected: /* this shouldn't be emitted, unless 'dirprot' is used, since they is already a public constructor */ Example1(int x, int y) : xsize(x), ysize(y) { } public: Example1() { } public: virtual ~Example1() {} int GetXSize() const { return xsize; } // pure virtual methods that must be overridden virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0; static int get_color(Example1 *ptr, unsigned char r, unsigned char g, unsigned char b) { return ptr->Color(r, g, b); } }; class Example2 { protected: int xsize, ysize; protected: /* there is no default constructor, hence, all protected constructors should be emitted */ Example2(int x) { } Example2(int x, int y) : xsize(x), ysize(y) { } public: virtual ~Example2() {} int GetXSize() const { return xsize; } // pure virtual methods that must be overridden virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0; static int get_color(Example2 *ptr, unsigned char r, unsigned char g, unsigned char b) { return ptr->Color(r, g, b); } }; class Example4 { protected: int xsize, ysize; protected: Example4() { } /* this is not emitted, unless dirprot is used */ Example4(int x, int y) : xsize(x), ysize(y) { } public: virtual ~Example4() {} int GetXSize() const { return xsize; } // pure virtual methods that must be overridden virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0; static int get_color(Example4 *ptr, unsigned char r, unsigned char g, unsigned char b) { return ptr->Color(r, g, b); } }; namespace ns { template class Example3 { protected: /* the default constructor is always emitter, even when protected, having another public constructor, and 'dirprot' is not used. This is just for Java compatibility */ Example3() { } /* this is no emitted, unless dirprot mode is used */ Example3(int x) { } public: Example3(int x, int y) { } virtual ~Example3() {} // pure virtual methods that must be overridden virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0; static int get_color(Example3 *ptr, unsigned char r, unsigned char g, unsigned char b) { return ptr->Color(r, g, b); } }; } %} %template(Example3_i) ns::Example3; %inline %{ struct A{ virtual ~A() {} friend int g(A* obj); protected: A(const A&){} virtual int f() = 0; }; int g(A* obj) {return 1;} %} swig-3.0.2/Examples/test-suite/python_pybuf.i0000664000175000017500000000224212343605122021127 0ustar williamwilliam%module python_pybuf %include %include /*functions for the test case*/ %pybuffer_mutable_binary(char *buf1, int len); %pybuffer_mutable_string(char *buf2); %pybuffer_binary(const char *buf3, int len); %pybuffer_string(const char *buf4); %inline %{ void func1(char *buf1, int len) { int i; for (i=0; i %include %include %include %include %include %include namespace std { %template(Mapii) map; %template(Multimapii) multimap; %template(IntSet) set; %template(IntMultiset) multiset; %template(IntVector) vector; %template(IntList) list; } swig-3.0.2/Examples/test-suite/director_overload2.i0000664000175000017500000000064112343605122022172 0ustar williamwilliam%module(directors="1") director_overload2 %feature("director"); %inline %{ struct OverloadBase { virtual ~OverloadBase() {} virtual void mmm() {} virtual void nnn(int vvv) {} virtual void nnn() {} }; struct OverloadDerived1 : OverloadBase { virtual void nnn(int vvv) {} // virtual void nnn() {} }; struct OverloadDerived2 : OverloadBase { // virtual void nnn(int vvv) {} virtual void nnn() {} }; %} swig-3.0.2/Examples/test-suite/template_typedef_fnc.i0000664000175000017500000000035512343605122022565 0ustar williamwilliam%module template_typedef_fnc %include "std_vector.i" namespace std { %template(IntVector) vector; }; %inline { typedef void (*RtMidiCallback)(std::vector *message); void setCallback( RtMidiCallback callback) { } } swig-3.0.2/Examples/test-suite/kind.i0000664000175000017500000000203612343605122017327 0ustar williamwilliam/* * This interface file tests whether the language modules handle the kind when declared * with the function/member name, especially when used with proxy classes. */ %module kind %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) bar; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) uni; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) test; /* Ruby, wrong class name */ %inline %{ class foo {}; struct bar {}; union uni {}; struct test { void foofn(class foo myfoo1, foo myfoo2, class foo* myfoo3, foo* myfoo4, class foo& myfoo5, foo& myfoo6) {} void barfn(struct bar mybar1, bar mybar2, struct bar* mybar3, bar* mybar4, struct bar& mybar5, bar& mybar6) {} void unifn(union uni myuni1, uni myuni2, union uni* myuni3, uni* myuni4, union myuni& myuni5, myuni& myuni6) {} class foo myFooMember; struct bar myBarMember; union uni myUniMember; class foo* mypFooMember; struct bar* mypBarMember; union uni* mypUniMember; }; %} swig-3.0.2/Examples/test-suite/naturalvar_more.i0000664000175000017500000000254712343605122021612 0ustar williamwilliam%module naturalvar_more // The instantiation of a template using an enum in the template parameter was not picking up %naturalvar. // These typemaps will be used if %naturalvar is not working %typemap(out) T *te, T *const_te "_should_not_use_this_out_typemap_" %typemap(varout) T *te, T *const_te "_should_not_use_this_varout_typemap_" %typemap(out) Hidden *hidden "_should_not_use_this_out_typemap_" %typemap(varout) Hidden *hidden "_should_not_use_this_varout_typemap_" %naturalvar T; %naturalvar Hidden; %inline %{ template struct T {}; struct K {}; struct Hidden; namespace Ace { int glob; } %} %{ struct Hidden {}; namespace Ace { template struct NoIdea {}; } %} %inline %{ namespace Space { enum E { E1, E2, E3 }; } %} %template(TE) T; %include %include %template(VectorString) std::vector; %inline { using namespace Space; struct S { T te; const T const_te; const std::vector::value_type const_string_member; // check this resolves to std::string which has a naturalvar std::vector::value_type string_member; // check this resolves to std::string which has a naturalvar Hidden hidden; Ace::NoIdea noidea; S() : const_te(), const_string_member("initial string value") {} }; } swig-3.0.2/Examples/test-suite/template_ns_enum.i0000664000175000017500000000047612343605122021747 0ustar williamwilliam%module template_ns_enum %inline %{ namespace hello { enum Hello { Hi, Hola }; template struct traits { typedef double value_type; }; traits::value_type say_hi() { return traits::value_type(1); } } %} swig-3.0.2/Examples/test-suite/template_typedef_ptr.i0000664000175000017500000000115012343605122022616 0ustar williamwilliam%module("templatereduce") template_typedef_ptr %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Test; /* Ruby, wrong constant name */ /* Use the "templatereduce" feature to force swig to reduce the template typedef as much as possible. This fixes cases like this one, but it can prevent some typemaps from working. */ %inline %{ struct C{}; typedef C* pC; template struct Test { Test (A a, B b) { } }; template struct Test { Test (B* a) { } }; %} %template(test_pC) Test; swig-3.0.2/Examples/test-suite/bloody_hell.i0000664000175000017500000000056612343605122020704 0ustar williamwilliam%module bloody_hell %warnfilter(SWIGWARN_RUBY_WRONG_NAME) kMaxIOCTLSpaceParmsSize; #define kMaxIOCTLSpaceParmsSize 128 %{ #define kMaxIOCTLSpaceParmsSize 128 %} %inline %{ typedef struct sm_channel_ix_dump_parms { unsigned data[(kMaxIOCTLSpaceParmsSize - ((4*sizeof(int)) + (2*sizeof(unsigned))))/sizeof(unsigned)]; } SM_CHANNEL_IX_DUMP_PARMS; %} swig-3.0.2/Examples/test-suite/cpp11_raw_string_literals.i0000664000175000017500000000315512343605122023467 0ustar williamwilliam/* This module tests whether SWIG correctly parses: - ordinary strings (char_t) - L wide strings (wchar_t) - u8 unicode8 strings (char_t) - u unicode16 strings (char16_t) - U unicode32 strings (char32_t) This module also tests whether SWIG correctly parses custom string delimiters. */ %module cpp11_raw_string_literals %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) bb; %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) ee; %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) gg; %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) xx; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) dd; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) hh; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ii; %include %inline %{ #include #include using namespace std; int L = 100; int u8 = 100; int u = 100; struct UStruct { static const int U = 100; }; int R = 100; int LR = 100; int u8R = 100; int uR = 100; struct URStruct { static const int UR = 100; }; // New string literals wstring aa = L"Wide string"; const char *bb = u8"UTF-8 string"; const char16_t *cc = u"UTF-16 string"; const char32_t *dd = U"UTF-32 string"; %} /* Raw string literals */ %inline %{ const char *xx = ")I'm an \"ascii\" \\ string."; const char *ee = R"XXX()I'm an "ascii" \ string.)XXX"; wstring ff = LR"XXX(I'm a "raw wide" \ string.)XXX"; const char *gg = u8R"XXX(I'm a "raw UTF-8" \ string.)XXX"; const char16_t *hh = uR"XXX(I'm a "raw UTF-16" \ string.)XXX"; const char32_t *ii = UR"XXX(I'm a "raw UTF-32" \ string.)XXX"; %} swig-3.0.2/Examples/test-suite/cpp11_explicit_conversion_operators.i0000664000175000017500000000131012343605122025564 0ustar williamwilliam/* This interface checks whether SWIG correctly compiles the new explicit conversion operators feature introduced in C++11. */ %module cpp11_explicit_conversion_operators %warnfilter(SWIGWARN_LANG_IDENTIFIER) Testable::operator bool; %rename(AsInteger) Testable::operator int; %inline %{ class U { public: int u; }; class V { public: int v; }; class TestClass { public: //implicit converting constructor TestClass( U const &val ) { t=val.u; } // explicit constructor explicit TestClass( V const &val ) { t=val.v; } int t; }; struct Testable { // explicit conversion operator explicit operator bool() const { return false; } explicit operator int() { return 42; } }; %} swig-3.0.2/Examples/test-suite/li_std_list.i0000664000175000017500000000133512343605122020714 0ustar williamwilliam%module li_std_list %include "std_list.i" %{ #include #include #include %} namespace std { %template(IntList) list; } %template(DoubleList) std::list; %inline %{ typedef float Real; %} namespace std { %template(RealList) list; } %inline %{ double average(std::list v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } void halve_in_place(std::list& v) { std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } struct Struct { double num; Struct() : num(0.0) {} Struct(double d) : num(d) {} // bool operator==(const Struct &other) { return (num == other.num); } }; %} swig-3.0.2/Examples/test-suite/ruby_track_objects.i0000664000175000017500000000327112343605122022262 0ustar williamwilliam%module ruby_track_objects %include typemaps.i %trackobjects Foo; %newobject Bar::get_new_foo; %typemap(in, numinputs=0) Foo** foo (Foo *temp) { /* %typemap(in, numinputs=0) Foo** foo */ $1 = &temp; } %typemap(argout) Foo** foo { /* %typemap(argout) Foo** foo */ $result = SWIG_NewPointerObj((void *) *$1, $*1_descriptor, 0); } %apply SWIGTYPE *DISOWN {Foo* ownedFoo}; %trackobjects ItemA; %trackobjects ItemB; %inline %{ class Foo { public: Foo() {} ~Foo() {} /* Helper method that can be called from Ruby that checks that two Ruby objects are pointing to the same underlying C++ object */ bool cpp_equal(const Foo* other) { return (this == other); } /* Just a simple method to call on Foo*/ const char* say_hello() { return "Hello"; } }; class Bar { private: Foo* owned_; Foo* unowned_; public: Bar(): owned_(new Foo), unowned_(0) { } ~Bar() { delete owned_; } /* Test that track objects works with %newobject */ static Foo* get_new_foo() { return new Foo; } /* Test the same foo Ruby object is created each time */ Foo* get_owned_foo() { return owned_; } /* Test that track objects works with argout parameters.*/ void get_owned_foo_by_argument(Foo** foo) { *foo = owned_; } /* Test that track objects works with the DISOWN typemap.*/ void set_owned_foo(Foo* ownedFoo) { delete owned_; owned_ = ownedFoo; } Foo* get_unowned_foo() { return unowned_; } void set_unowned_foo(Foo* foo) { unowned_ = foo; } }; class ItemA { }; class ItemB: public ItemA { public: }; ItemB* downcast(ItemA* item) { return static_cast(item); } class Factory { public: Factory() {} ItemA* createItem() { return new ItemB; } }; %} swig-3.0.2/Examples/test-suite/smart_pointer_extend.i0000664000175000017500000000317612343605122022645 0ustar williamwilliam%module smart_pointer_extend %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi::CBase::z; /* Ruby, wrong const name */ %inline %{ namespace hi { struct CBase { static int hello() { return 1; } int x; static const int z = 1; }; class CDerived : public CBase { }; class CPtr { public: CDerived* operator->(void) {return 0;} }; int get_hello(CPtr ptr) { return ptr->hello(); } class CPtrConst { public: const CDerived* operator->() const {return 0;}; }; } %} %extend hi::CBase { int foo(void) {return 1;}; int bar(void) {return 2;}; int boo(int i) {return i;}; } %extend hi::CDerived { int foo(void) {return 1;}; } %extend Foo { int extension(int i, int j) { return i; } int extension(int i) { return i; } int extension() { return 1; } } %inline %{ struct Foo { }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } Foo *operator->() { return f; } }; %} %extend CFoo { public: static void StatFun() {}; static void StatFun(int i) {}; static void HoHoHo(int i, int j) {}; } %inline %{ class CFoo { }; class CPtrFoo { public: CFoo* operator->(void) {return 0;}; }; %} %inline %{ namespace foo { class DFoo; class DPtrFoo { DFoo *p; public: DPtrFoo(DFoo *ptr) : p(ptr) { } DFoo* operator->(void) {return p;}; }; class DFoo { public: void F(void) {}; }; } %} %extend foo::DFoo { static int SExt(int i = 1) {return i;}; int Ext(int i = 2) {return i;}; } swig-3.0.2/Examples/test-suite/inctest.h0000664000175000017500000000005012343605122020044 0ustar williamwilliamint IntegerMember; double DoubleMember; swig-3.0.2/Examples/test-suite/csharp_namespace_system_collision.i0000664000175000017500000000115512343605122025356 0ustar williamwilliam%module namespace_system_collision %{ #include namespace TopLevel { namespace System { class Foo { public: virtual ~Foo() {} virtual std::string ping() { return "TopLevel::System::Foo::ping()"; } }; } } %} %include // nspace feature only supported by these languages #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) %nspace; #else //#warning nspace feature not yet supported in this target language #endif namespace TopLevel { namespace System { class Foo { public: virtual ~Foo(); virtual std::string ping(); }; } } swig-3.0.2/Examples/test-suite/director_constructor.i0000664000175000017500000000054312343605122022663 0ustar williamwilliam%module(directors="1") director_constructor %feature("director") Foo; %inline %{ class Foo { public: int a; Foo(int i) { a=i; } virtual ~Foo() { } int do_test() { return test(); } virtual int getit() { return a; } virtual void doubleit() { a = a * 2; } virtual int test() = 0; }; %} swig-3.0.2/Examples/test-suite/director_classic.i0000664000175000017500000000203412343605122021714 0ustar williamwilliam%module(directors="1") director_classic %include "std_string.i" %feature("director"); %inline %{ #include #include #include struct Being { virtual std::string id() { return "Being"; } virtual ~Being() {} }; struct Person : Being { virtual std::string id() { return "Person"; } }; struct Child : Person { virtual std::string id() { return "Child"; } }; struct GrandChild : Child { virtual std::string id() { return "GrandChild"; } }; // Orphans - don't override id() in C++ struct OrphanPerson : Person { // no overridden id() }; struct OrphanChild : Child { // no overridden id() }; class Caller { private: Person *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Person *cb) { delCallback(); _callback = cb; } void resetCallback() { _callback = 0; } std::string call() { if (_callback) return _callback->id(); else return "oops"; } Person* baseClass() { return _callback; } }; %} swig-3.0.2/Examples/test-suite/perl5/0000775000175000017500000000000012343605122017256 5ustar williamwilliamswig-3.0.2/Examples/test-suite/perl5/imports_runme.pl0000664000175000017500000000012212343605122022511 0ustar williamwilliamuse imports_b; use imports_a; $x = imports_bc::new_B(); imports_ac::A_hello($x); swig-3.0.2/Examples/test-suite/perl5/director_constructor_runme.pl0000664000175000017500000000176612343605122025313 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 9; BEGIN { use_ok 'director_constructor' } require_ok 'director_constructor'; { package Test; use base 'director_constructor::Foo'; sub doubleit { my($self) = @_; $self->{a} *= 2; } sub test { 3 } } my $t = Test->new(5); isa_ok $t, 'Test'; is $t->getit, 5; is $t->do_test, 3; $t->doubleit(); is $t->getit, 10; { package Wrong; use base 'director_constructor::Foo'; sub doubleit { my($self) = @_; # calling this should trigger a type error on attribute # assignment $self->{a} = {}; } sub test { # if c++ calls this, retval copyout should trigger a type error return bless {}, 'TotallyBogus'; } } # TODO: these TypeErrors in director classes should be more detailed my $w = Wrong->new(12); is eval { $w->doubleit() }, undef; like $@, qr/TypeError/; is $w->getit(), 12, 'W.a should be unaffected'; # TODO: this is giving an unhandled C++ exception right now #is eval { $W->do_test() }, undef; #like $@, qr/TypeError/; swig-3.0.2/Examples/test-suite/perl5/default_constructor_runme.pl0000664000175000017500000000370012343605122025112 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 20; BEGIN { use_ok('default_constructor') } require_ok('default_constructor'); isa_ok(eval { default_constructor::A->new() }, "default_constructor::A"); isa_ok(eval { default_constructor::AA->new() }, "default_constructor::AA"); is( eval { default_constructor::B->new() }, undef, "private default constructor"); isa_ok(eval { default_constructor::B->new(0, 0) }, "default_constructor::B"); is( eval { default_constructor::BB->new() }, undef, "inherited private default constructor"); is( eval { default_constructor::C->new() }, undef, "protected default constructor"); isa_ok(eval { default_constructor::CC->new() }, "default_constructor::CC"); is( eval { default_constructor::D->new() }, undef, "private constructor"); is( eval { default_constructor::DD->new() }, undef, "inherited private constructor"); { local $TODO = "default_constructor.i disagrees with our result"; is( eval { default_constructor::AD->new() }, undef, "MI on A, D"); } isa_ok(eval { default_constructor::E->new() }, "default_constructor::E"); isa_ok(eval { default_constructor::EE->new() }, "default_constructor::EE"); { local $TODO = "default_constructor.i disagrees with our result"; is( eval { default_constructor::EB->new() }, undef, "MI on E, B"); } { local $TODO = "destructor hiding seems off"; my $hit = 0; eval { my $F = default_constructor::F->new(); undef $F; $hit = 1; }; ok(not($hit), "private destructor"); $hit = 0; eval { my $G = default_constructor::G->new(); undef $G; $hit = 1; }; ok(not($hit), "protected destructor"); $hit = 0; eval { my $G = default_constructor::GG->new(); undef $G; $hit = 1; }; ok(not($hit), "inherited protected destructor"); } isa_ok(eval { default_constructor::HH->new(0, 0) }, "default_constructor::HH"); is( eval { default_constructor::HH->new() }, undef, "templated protected constructor"); # TODO: sort out what needs to be tested from OSRSpatialReferenceShadow swig-3.0.2/Examples/test-suite/perl5/import_nomodule_runme.pl0000664000175000017500000000045112343605122024235 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 4; BEGIN { use_ok('import_nomodule') } require_ok('import_nomodule'); my $f = import_nomodule::create_Foo(); import_nomodule::test1($f,42); ok(1, "basecase"); my $b = new import_nomodule::Bar(); import_nomodule::test1($b,37); ok(1, "testcase"); swig-3.0.2/Examples/test-suite/perl5/wrapmacro_runme.pl0000664000175000017500000000050512343605122023014 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('wrapmacro') } require_ok('wrapmacro'); # adapted from ../python/wrapmacro_runme.py my $a = 2; my $b = -1; is(wrapmacro::maximum($a,$b), 2); is(wrapmacro::maximum($a/7.0, -$b*256), 256); is(wrapmacro::GUINT16_SWAP_LE_BE_CONSTANT(1), 256); swig-3.0.2/Examples/test-suite/perl5/run-perl-test.pl0000664000175000017500000000037312343605122022337 0ustar williamwilliam#!/usr/bin/perl eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if $running_under_some_shell; #!/usr/bin/perl -w use strict; my $command = shift @ARGV; my $output = `$^X $command 2>&1`; die "SWIG Perl test failed: \n\n$output\n" if $?; exit(0); swig-3.0.2/Examples/test-suite/perl5/README0000664000175000017500000000073312343605122020141 0ustar williamwilliamSee ../README for common README file. Any testcases which have _runme.pl appended after the testcase name will be detected and run. Test::More Support == Test::More is a standard perl test harness tool. Support was added for for using Test::More in 1.3.28. If adding a new test to this suite, please use Test::More. There are a few legacy test cases which do not use Test::More and these ought to be converted: disown imports overload_copy profiletest template_ref_type swig-3.0.2/Examples/test-suite/perl5/template_typedef_cplx_runme.pl0000664000175000017500000000251112343605122025401 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 14; BEGIN { use_ok('template_typedef_cplx') } require_ok('template_typedef_cplx'); # adapted from ../python/template_typedef_cplx_runme.py { # kids, don't try this at home (glob hijinks) my $cvar = *template_typedef_cplx::; map { ${*::}{$_} = ${$cvar}{$_} } keys %{$cvar}; } # # double case # my $d = eval { make_Identity_double() }; ok(ref($d), 'is an object'); like(ref($d), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); my $e = eval { make_Multiplies_double_double_double_double($d, $d) }; ok(ref($e), 'is an object'); like(ref($e), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); # # complex case # my $c = eval { make_Identity_complex() }; ok(ref($c), 'is an object'); like(ref($c), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); my $f = eval { make_Multiplies_complex_complex_complex_complex($c, $c) }; ok(ref($f), 'is an object'); like(ref($f), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); # # Mix case # my $g = eval { make_Multiplies_double_double_complex_complex($d, $c) }; ok(ref($f), 'is an object'); like(ref($f), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); my $h = eval { make_Multiplies_complex_complex_double_double($c, $d) }; ok(ref($h), 'is an object'); like(ref($h), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); swig-3.0.2/Examples/test-suite/perl5/member_pointer_runme.pl0000664000175000017500000000253712343605122024037 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 9; # member_pointer using pointers to member functions BEGIN { use_ok('member_pointer') } require_ok('member_pointer'); sub check($;$;$) { my($what, $expected, $actual) = @_; if ($expected != $actual) { die ("Failed: $what Expected: $expected Actual: $actual"); } } # Get the pointers my $area_pt = member_pointer::areapt(); my $perim_pt = member_pointer::perimeterpt(); # Create some objects my $s = new member_pointer::Square(10); # Do some calculations is(100.0, member_pointer::do_op($s,$area_pt), "Square area"); is(40.0, member_pointer::do_op($s,$perim_pt), "Square perim"); no strict; my $memberPtr = $member_pointer::areavar; $memberPtr = $member_pointer::perimetervar; # Try the variables is(100.0, member_pointer::do_op($s,$member_pointer::areavar), "Square area"); is(40.0, member_pointer::do_op($s,$member_pointer::perimetervar), "Square perim"); # Modify one of the variables $member_pointer::areavar = $perim_pt; is(40.0, member_pointer::do_op($s,$member_pointer::areavar), "Square perimeter"); # Try the constants $memberPtr = $member_pointer::AREAPT; $memberPtr = $member_pointer::PERIMPT; $memberPtr = $member_pointer::NULLPT; is(100.0, member_pointer::do_op($s,$member_pointer::AREAPT), "Square area"); is(40.0, member_pointer::do_op($s,$member_pointer::PERIMPT), "Square perim"); swig-3.0.2/Examples/test-suite/perl5/sneaky1_runme.pl0000664000175000017500000000042512343605122022375 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; BEGIN { use_ok('sneaky1') } require_ok('sneaky1'); # adapted from ../python/sneaky1_runme.py is(sneaky1::add(3,4), 7); is(sneaky1::subtract(3,4), -1); is(sneaky1::mul(3,4), 12); is(sneaky1::divide(3,4), 0); swig-3.0.2/Examples/test-suite/perl5/director_default_runme.pl0000664000175000017500000000064112343605122024341 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 6; BEGIN { use_ok 'director_default' } require_ok 'director_default'; my $f; $f = director_default::Foo->new(); isa_ok $f, 'director_default::Foo'; $f = director_default::Foo->new(1); isa_ok $f, 'director_default::Foo'; $f = director_default::Bar->new(); isa_ok $f, 'director_default::Bar'; $f = director_default::Bar->new(1); isa_ok $f, 'director_default::Bar'; swig-3.0.2/Examples/test-suite/perl5/typedef_class_runme.pl0000664000175000017500000000056312343605122023652 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 6; BEGIN { use_ok('typedef_class') } require_ok('typedef_class'); # adapted from ../python/typedef_class_runme.py my $a = typedef_class::RealA->new(); isa_ok($a, 'typedef_class::RealA'); $a->{a} = 3; is($a->{a}, 3); my $b = typedef_class::B->new(); isa_ok($b, 'typedef_class::B'); is($b->testA($a), 3); swig-3.0.2/Examples/test-suite/perl5/array_member_runme.pl0000664000175000017500000000117412343605122023471 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 18; BEGIN { use_ok('array_member') } require_ok('array_member'); my $f = array_member::Foo->new(); $f->{data} = $array_member::global_data; for(my $i=0; $i<8; $i++) { is( array_member::get_value($f->{data},$i), array_member::get_value($array_member::global_data,$i), "array assignment"); } for(my $i=0; $i<8; $i++) { array_member::set_value($f->{data},$i,-$i); } $array_member::global_data = $f->{data}; for(my $i=0; $i<8; $i++) { is(array_member::get_value($f->{data},$i), array_member::get_value($array_member::global_data,$i), "array assignment"); } swig-3.0.2/Examples/test-suite/perl5/director_classic_runme.pl0000664000175000017500000000552712343605122024346 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 41; BEGIN { use_ok('director_classic') } require_ok('director_classic'); { package TargetLangPerson; use base 'director_classic::Person'; sub id { return 'TargetLangPerson' } } { package TargetLangChild; use base 'director_classic::Child'; sub id { return 'TargetLangChild' } } { package TargetLangGrandChild; use base 'director_classic::GrandChild'; sub id { return 'TargetLangGrandChild' } } # Semis - don't override id() in target language { package TargetLangSemiPerson; use base 'director_classic::Person'; # No id() override } { package TargetLangSemiChild; use base 'director_classic::Child'; # No id() override } { package TargetLangSemiGrandChild; use base 'director_classic::GrandChild'; # No id() override } # Orphans - don't override id() in C++ { package TargetLangOrphanPerson; use base 'director_classic::OrphanPerson'; sub id { return "TargetLangOrphanPerson" } } { package TargetLangOrphanChild; use base 'director_classic::OrphanChild'; sub id { return "TargetLangOrphanChild" } } sub check { my($person, $expected) = @_; # Normal target language polymorphic call is($person->id(), $expected, "$expected from Perl"); # Polymorphic call from C++ my $caller = director_classic::Caller->new(); $caller->setCallback($person); is($caller->call(), $expected, "$expected from C++"); # Polymorphic call of object created in target language and passed to C++ and back again my $baseclass = $caller->baseClass(); is($baseclass->id(), $expected, "$expected after bounce"); $caller->resetCallback(); } my $person; $person = director_classic::Person->new(); check($person, "Person"); undef $person; $person = director_classic::Child->new(); check($person, "Child"); undef $person; $person = director_classic::GrandChild->new(); check($person, "GrandChild"); undef $person; $person = TargetLangPerson->new(); check($person, "TargetLangPerson"); undef $person; $person = TargetLangChild->new(); check($person, "TargetLangChild"); undef $person; $person = TargetLangGrandChild->new(); check($person, "TargetLangGrandChild"); undef $person; # Semis - don't override id() in target language $person = TargetLangSemiPerson->new(); check($person, "Person"); undef $person; $person = TargetLangSemiChild->new(); check($person, "Child"); undef $person; $person = TargetLangSemiGrandChild->new(); check($person, "GrandChild"); undef $person; # Orphans - don't override id() in C++ $person = director_classic::OrphanPerson->new(); check($person, "Person"); undef $person; $person = director_classic::OrphanChild->new(); check($person, "Child"); undef $person; $person = TargetLangOrphanPerson->new(); check($person, "TargetLangOrphanPerson"); undef $person; $person = TargetLangOrphanChild->new(); check($person, "TargetLangOrphanChild"); undef $person; swig-3.0.2/Examples/test-suite/perl5/overload_simple_runme.pl0000664000175000017500000001262712343605122024215 0ustar williamwilliam#!/usr/bin/perl -w use overload_simple; use vars qw/$DOWARN/; use strict; use Test::More tests => 75; pass("loaded"); my $f = new overload_simple::Foo(); isa_ok($f, "overload_simple::Foo"); my $b = new overload_simple::Bar(); isa_ok($b, "overload_simple::Bar"); my $v = overload_simple::malloc_void(32); isa_ok($v, "_p_void"); # # Silence warnings about bad types # BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN } } # #these tests should 'fail' # eval { overload_simple::fint("l") }; ok($@, "fint(int) - int"); eval { overload_simple::fint("3.5") }; ok($@, "fint(int) - double"); eval { overload_simple::fdouble("l") }; ok($@, "fint(double) - int"); eval { overload_simple::fdouble("1.5/2.0") }; ok($@, "fint(double) - double"); # #enable the warnings again # $DOWARN =1; # # 'simple' dispatch (no overload) of int and double arguments # is(overload_simple::fint(3), "fint:int", "fint(int) - int"); is(overload_simple::fint("1"), "fint:int", "fint(int) - string int"); is(overload_simple::fint(3.0), "fint:int", "fint(int) - double"); is(overload_simple::fint("3.0"), "fint:int", "fint(int) - string double"); # old bad case that now works my $n = 3; $n = $n + 1; is(overload_simple::fint($n), "fint:int", "fint(int) - int var"); is(overload_simple::fint(4/2), "fint:int", "fint(int) - divide int denom"); is(overload_simple::fint(4/2.0), "fint:int", "fint(int) - divide double denom"); is(overload_simple::fdouble(3), "fdouble:double", "fdouble(double) - int"); is(overload_simple::fdouble("3"), "fdouble:double", "fdouble(double) - string int"); is(overload_simple::fdouble(3.0), "fdouble:double", "fdouble(double) - double"); is(overload_simple::fdouble("3.0"), "fdouble:double", "fdouble(double) - string doubl"); # # Overload between int and double # is(overload_simple::num(3), "num:int", "num(int) - int"); is(overload_simple::num("3"), "num:int", "num(int) - string int"); is(overload_simple::num(3.0), "num:double", "num(int) - double"); is(overload_simple::num("3.0"), "num:double", "num(int) - string double"); # # Overload between int, double, char * and many types. # is(overload_simple::foo(3), "foo:int", "foo:int - int"); is(overload_simple::foo(3.0), "foo:double", "foo:double - double"); is(overload_simple::foo("3"), "foo:char *", "foo:char * - string int"); is(overload_simple::foo("3.0"), "foo:char *", "foo:char * - string double"); is(overload_simple::foo("hello"), "foo:char *", "foo:char * string"); is(overload_simple::foo($f), "foo:Foo *", "foo:Foo *"); is(overload_simple::foo($b), "foo:Bar *", "foo:Bar *"); is(overload_simple::foo($v), "foo:void *", "foo:void *"); is(overload_simple::blah(3), "blah:double", "blah:double"); is(overload_simple::blah("hello"), "blah:char *", "blah:char *"); my $s = new overload_simple::Spam(); is($s->foo(3), "foo:int", "Spam::foo:int"); is($s->foo(3.0), "foo:double", "Spam::foo(double)"); is($s->foo("hello"), "foo:char *", "Spam::foo:char *"); is($s->foo($f), "foo:Foo *", "Spam::foo(Foo *)"); is($s->foo($b), "foo:Bar *", "Spam::foo(Bar *)"); is($s->foo($v), "foo:void *", "Spam::foo(void *)"); is(overload_simple::Spam::bar(3), "bar:int", "Spam::bar(int)"); is(overload_simple::Spam::bar(3.0), "bar:double", "Spam::bar(double)"); is(overload_simple::Spam::bar("hello"), "bar:char *", "Spam::bar(char *)"); is(overload_simple::Spam::bar($f), "bar:Foo *", "Spam::bar(Foo *)"); is(overload_simple::Spam::bar($b), "bar:Bar *", "Spam::bar(Bar *)"); is(overload_simple::Spam::bar($v), "bar:void *", "Spam::bar(void *)"); # Test constructors $s = new overload_simple::Spam(); isa_ok($s, "overload_simple::Spam"); is($s->{type}, "none", "Spam()"); $s = new overload_simple::Spam(3); isa_ok($s, "overload_simple::Spam"); is($s->{type}, "int", "Spam(int)"); $s = new overload_simple::Spam(3.0); isa_ok($s, "overload_simple::Spam"); is($s->{type}, "double", "Spam(double)"); $s = new overload_simple::Spam("hello"); isa_ok($s, "overload_simple::Spam"); is($s->{type}, "char *", "Spam(char *)"); $s = new overload_simple::Spam($f); isa_ok($s, "overload_simple::Spam"); is($s->{type}, "Foo *", "Spam(Foo *)"); $s = new overload_simple::Spam($b); isa_ok($s, "overload_simple::Spam"); is($s->{type}, "Bar *", "Spam(Bar *)"); $s = new overload_simple::Spam($v); isa_ok($s, "overload_simple::Spam"); is($s->{type}, "void *", "Spam(void *)"); # # Combine dispatch # is(overload_simple::fid(3, 3.0), "fid:intdouble", "fid(int,double)"); is(overload_simple::fid(3.0, 3), "fid:doubleint", "fid(double,int)"); is(overload_simple::fid(3.0, 3.0), "fid:doubledouble", "fid(double,double)"); is(overload_simple::fid(3, 3), "fid:intint", "fid(int,int)"); # with strings now is(overload_simple::fid(3, "3.0"), "fid:intdouble", "fid(int,double)"); is(overload_simple::fid("3", 3.0), "fid:intdouble", "fid(int,double)"); is(overload_simple::fid("3", "3.0"), "fid:intdouble", "fid(int,double)"); is(overload_simple::fid(3.0, "3"), "fid:doubleint", "fid(double,int)"); is(overload_simple::fid("3.0", "3.0"), "fid:doubledouble", "fid:doubledouble"); is(overload_simple::fid("3", 3), "fid:intint", "fid:fid(int,int)"); isnt(overload_simple::fbool(0), overload_simple::fbool(1), "fbool(bool)"); is(2, overload_simple::fbool(2), "fbool(int)"); # int and object overload is(overload_simple::int_object(1), 1, "int_object(1)"); is(overload_simple::int_object(0), 0, "int_object(0)"); is(overload_simple::int_object(undef), 999, "int_object(Spam*)"); is(overload_simple::int_object($s), 999, "int_object(Spam*)"); swig-3.0.2/Examples/test-suite/perl5/char_strings_runme.pl0000664000175000017500000000057512343605122023516 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('char_strings') } require_ok('char_strings'); my $val1 = "100"; is(char_strings::CharPingPong($val1), "100", 'cstr1'); my $val2 = "greetings"; is(char_strings::CharPingPong($val2), "greetings", 'cstr2'); # SF#2564192 "this is a test" =~ /(\w+)$/; is(char_strings::CharPingPong($1), "test", "handles Magical"); swig-3.0.2/Examples/test-suite/perl5/typename_runme.pl0000664000175000017500000000064712343605122022652 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 4; BEGIN { use_ok('typename') } require_ok('typename'); # adapted from ../python/typename_runme.py my $f = typename::Foo->new(); my $b = typename::Bar->new(); my $x = typename::twoFoo($f); is($x, 4.3656); my $y = typename::twoBar($b); is($y, 84); # I would like this test better if I could pass in a float to the # integer test and see it lose precision. swig-3.0.2/Examples/test-suite/perl5/operator_overload_runme.pl0000664000175000017500000000727412343605122024561 0ustar williamwilliam#!/usr/bin/perl -w use strict; use Test::More tests => 39; use operator_overload; # Workaround for # ok( not (expression) , "test description" ); # does not working in older versions of Perl, eg 5.004_04 sub ok_not ($;$) { my($test, $name) = @_; $test = not $test; ok($test, $name); } pass("loaded"); # first check all the operators are implemented correctly from pure C++ code operator_overloadc::Op_sanity_check(); my $op = operator_overload::Op->new(); isa_ok($op, "operator_overload::Op"); my $op2 = operator_overload::Op->new(); isa_ok($op2, "operator_overload::Op"); # operator equal $op->{i} = 5; $op2->{i} = 3; ok_not(($op == $op2), "operator equal: not equal"); $op->{i} = 3; ok(($op == $op2), "operator equal: equal"); # operator not equal $op->{i} = 5; $op2->{i} = 3; ok(($op != $op2), "operator not equal: not equal"); $op->{i} = 3; ok_not(($op != $op2), "operator not equal: equal"); # stringify operator $op->{i} = 3; is("Op(3)", "$op", "operator stringify"); # addition operator $op->{i} = 3; $op2->{i} = 3; my $op3 = $op + $op2; is($op3->{i}, 6, "operator addition"); # addition assignment operator $op->{i} = 3; $op2->{i} = 3; $op += $op2; is($op->{i}, 6, "operator additive assignment"); # subtraction operator $op3->{i} = 6; $op2->{i} = 3; $op = $op3 - $op2; is($op->{i}, 3, "operator subtraction"); # reversed subtraction operator (with int) $op3->{i} = 3; $op = 6 - $op3; is($op->{i}, 3, "reversed operator subtraction (with int)"); # subtractive assignment operator $op->{i} = 6; $op2->{i} = 3; $op -= $op2; is($op->{i}, 3, "operator subtractive assignment"); # multiplication operator $op->{i} = 3; $op2->{i} = 3; $op3 = $op * $op2; is($op3->{i}, 9, "operator multiplication"); # division operator $op->{i} = 9; $op2->{i} = 3; $op3 = $op / $op2; is($op3->{i}, 3, "operator division"); # modulus operator $op->{i} = 8; $op2->{i} = 3; $op3 = $op % $op2; is($op3->{i}, 2, "operator modulus"); # greater than operator $op->{i} = 8; $op2->{i} = 3; ok($op > $op2, "operator greater than"); ok_not(($op2 > $op), "operator greater than"); $op->{i} = 3; ok_not(($op2 > $op), "operator greater than"); ok_not(($op > $op2), "operator greater than"); # greater than or equal operator $op->{i} = 8; $op2->{i} = 3; ok($op >= $op2, "operator greater than or equal"); ok_not(($op2 >= $op), "operator greater than or equal"); $op->{i} = 3; ok(($op2 >= $op), "operator greater than or equal"); ok(($op >= $op2), "operator greater than or equal"); # lesser than operator $op2->{i} = 8; $op->{i} = 3; ok($op < $op2, "operator lesser than"); ok_not(($op2 < $op), "operator lesser than"); $op2->{i} = 3; ok_not(($op2 < $op), "operator lesser than"); ok_not(($op < $op2), "operator lesser than"); # less than or equal operator $op2->{i} = 8; $op->{i} = 3; ok($op <= $op2, "operator lesser than or equal"); ok_not(($op2 <= $op), "operator lesser than or equal"); $op2->{i} = 3; ok(($op2 <= $op), "operator less than or equal"); ok(($op <= $op2), "operator less than or equal"); # post-increment operator $op->{i} = 7; $op++; is($op->{i}, 8, "operator post-increment"); # pre-increment operator $op->{i} = 7; ++$op; is($op->{i}, 8, "operator pre-increment"); # post-decrement operator $op->{i} = 7; $op--; is($op->{i}, 6, "operator post-decrement"); # pre-decrement operator $op->{i} = 7; --$op; is($op->{i}, 6, "operator pre-decrement"); # neg operator $op->{i} = 3; $op2 = -$op; is($op2->{i}, -3, "operator neg"); # not operator $op->{i} = 0; is(!$op, !0, "operator not"); $op->{i} = 1; is(!$op, !1, "operator not"); ### # and operator ### $op->{i} = 4; ### $op2->{i} = 2; ### ### is($op & $op2, 4 & 2, "operator and"); ### ### isnt(($op & $op2), (10 & 2), "operator and - false"); # fail("testing failed condition"); swig-3.0.2/Examples/test-suite/perl5/li_std_string_runme.pl0000664000175000017500000001001112343605122023656 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 30; BEGIN { use_ok('li_std_string') } require_ok('li_std_string'); use Devel::Peek; # Checking expected use of %typemap(in) std::string {} li_std_string::test_value("Fee"); # Checking expected result of %typemap(out) std::string {} is(li_std_string::test_value("Fi"), "Fi", "Test 1"); # Verify type-checking for %typemap(in) std::string {} eval { li_std_string::test_value(undef) }; like($@, qr/\bTypeError\b/, "Test 2"); # Checking expected use of %typemap(in) const std::string & {} li_std_string::test_const_reference("Fo"); # Checking expected result of %typemap(out) const std::string& {} is(li_std_string::test_const_reference("Fum"), "Fum", "Test 3"); # Verify type-checking for %typemap(in) const std::string & {} eval { li_std_string::test_const_reference(undef) }; like($@, qr/\bValueError\b/, "Test 4"); # # Input and output typemaps for pointers and non-const references to # std::string are *not* supported; the following tests confirm # that none of these cases are slipping through. # my $stringPtr = undef; $stringPtr = li_std_string::test_pointer_out(); li_std_string::test_pointer($stringPtr); $stringPtr = li_std_string::test_const_pointer_out(); li_std_string::test_const_pointer($stringPtr); $stringPtr = li_std_string::test_reference_out(); li_std_string::test_reference($stringPtr); # Check throw exception specification eval { li_std_string::test_throw() }; like($@, qr/^test_throw message/, "Test 5"); { local $TODO = "why is the error not a Perl string?"; eval { li_std_string::test_const_reference_throw() }; is($@, "", "Test 6"); } # Global variables my $s = "initial string"; is($li_std_string::GlobalString2, "global string 2", "GlobalString2 test 1"); $li_std_string::GlobalString2 = $s; is($li_std_string::GlobalString2, $s, "GlobalString2 test 2"); is($li_std_string::ConstGlobalString, "const global string", "ConstGlobalString test"); # Member variables my $myStructure = new li_std_string::Structure(); is($myStructure->{MemberString2}, "member string 2", "MemberString2 test 1"); $myStructure->{MemberString2} = $s; is($myStructure->{MemberString2}, $s, "MemberString2 test 2"); is($myStructure->{ConstMemberString}, "const member string", "ConstMemberString test"); is($li_std_string::Structure::StaticMemberString2, "static member string 2", "StaticMemberString2 test 1"); $li_std_string::Structure::StaticMemberString2 = $s; is($li_std_string::Structure::StaticMemberString2, $s, "StaticMemberString2 test 2"); is($li_std_string::Structure::ConstStaticMemberString, "const static member string", "ConstStaticMemberString test"); is(li_std_string::test_reference_input("hello"), "hello", "reference_input"); is(li_std_string::test_reference_inout("hello"), "hellohello", "reference_inout"); no strict; my $gen1 = new li_std_string::Foo(); is($gen1->test(1), 2, "ulonglong"); is($gen1->test("1"), "11", "ulonglong"); is($gen1->testl(12345), 12346, "ulonglong small number"); # Note: 32 bit builds of perl will fail this test as the number is stored internally in scientific notation # (USE_64_BIT_ALL probably needs defining when building Perl in order to avoid this) SKIP: { skip "this Perl does not seem to do 64 bit ints", 1 if 9234567890121111114 - 9234567890121111113 != 1; local $TODO; use Config; $TODO = "if we're lucky this might work" unless $Config{use64bitall}; is(eval { $gen1->testl(9234567890121111113) }, 9234567890121111114, "ulonglong big number"); # TODO: I suspect we can get by with "use64bitint", but I'll have to # work that out later. -talby } is($gen1->testl("9234567890121111113"), "9234567890121111114", "ulonglong big number"); is(li_std_string::stdstring_empty(), "", "stdstring_empty"); is(li_std_string::c_empty(), "", "c_empty"); is(li_std_string::c_null(), undef, "c_empty"); is(li_std_string::get_null(li_std_string::c_null()), undef, "c_empty"); is(li_std_string::get_null(li_std_string::c_empty()), "non-null", "c_empty"); is(li_std_string::get_null(li_std_string::stdstring_empty()), "non-null", "stdstring_empty"); swig-3.0.2/Examples/test-suite/perl5/naturalvar_runme.pl0000664000175000017500000000061012343605122023175 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('naturalvar') } require_ok('naturalvar'); # adapted from ../python/naturalvar_runme.py my $f = naturalvar::Foo->new(); isa_ok($f, 'naturalvar::Foo'); my $b = naturalvar::Bar->new(); isa_ok($b, 'naturalvar::Bar'); $b->{f} = $f; $naturalvar::s = "hello"; $b->{s} = "hello"; is($naturalvar::s, $b->{s}); swig-3.0.2/Examples/test-suite/perl5/using2_runme.pl0000664000175000017500000000027312343605122022232 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 3; BEGIN { use_ok('using2') } require_ok('using2'); # adapted from ../python/using2_runme.py is(using2::spam(37), 37); swig-3.0.2/Examples/test-suite/perl5/disown_runme.pl0000664000175000017500000000016012343605122022321 0ustar williamwilliamuse disown; if (1) { $a = new disown::A(); $b = new disown::B(); $c = $b->acquire($a); } swig-3.0.2/Examples/test-suite/perl5/minherit_runme.pl0000664000175000017500000000247512343605122022650 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 38; BEGIN { use_ok('minherit') } require_ok('minherit'); # adapted from ../python/minherit_runme.py my $a = minherit::Foo->new(); my $b = minherit::Bar->new(); my $c = minherit::FooBar->new(); my $d = minherit::Spam->new(); is($a->xget(), 1); is($b->yget(), 2); is($c->xget(), 1); is($c->yget(), 2); is($c->zget(), 3); is($d->xget(), 1); is($d->yget(), 2); is($d->zget(), 3); is($d->wget(), 4); is(minherit::xget($a), 1); is(minherit::yget($b), 2); is(minherit::xget($c), 1); is(minherit::yget($c), 2); is(minherit::zget($c), 3); is(minherit::xget($d), 1); is(minherit::yget($d), 2); is(minherit::zget($d), 3); is(minherit::wget($d), 4); # Cleanse all of the pointers and see what happens my $aa = minherit::toFooPtr($a); my $bb = minherit::toBarPtr($b); my $cc = minherit::toFooBarPtr($c); my $dd = minherit::toSpamPtr($d); is($aa->xget, 1); is($bb->yget(), 2); is($cc->xget(), 1); is($cc->yget(), 2); is($cc->zget(), 3); is($dd->xget(), 1); is($dd->yget(), 2); is($dd->zget(), 3); is($dd->wget(), 4); is(minherit::xget($aa), 1); is(minherit::yget($bb), 2); is(minherit::xget($cc), 1); is(minherit::yget($cc), 2); is(minherit::zget($cc), 3); is(minherit::xget($dd), 1); is(minherit::yget($dd), 2); is(minherit::zget($dd), 3); is(minherit::wget($dd), 4); swig-3.0.2/Examples/test-suite/perl5/director_frob_runme.pl0000664000175000017500000000035712343605122023651 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 4; BEGIN { use_ok 'director_frob' } require_ok 'director_frob'; my $foo = director_frob::Bravo->new(); isa_ok $foo, 'director_frob::Bravo'; is($foo->abs_method(), 'Bravo::abs_method()'); swig-3.0.2/Examples/test-suite/perl5/li_carrays_runme.pl0000664000175000017500000000352712343605122023160 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 38; BEGIN { use_ok('li_carrays') } require_ok('li_carrays'); # array_class { my $length = 5; my $xyArray = new li_carrays::XYArray($length); for (my $i=0; $i<$length; $i++) { my $xy = $xyArray->getitem($i); $xy->{x} = $i*10; $xy->{y} = $i*100; $xyArray->setitem($i, $xy); } for (my $i=0; $i<$length; $i++) { is($xyArray->getitem($i)->{x}, $i*10); is($xyArray->getitem($i)->{y}, $i*100); } } { # global array variable my $length = 5; my $xyArrayPointer = $li_carrays::globalXYArray; my $xyArray = li_carrays::XYArray::frompointer($xyArrayPointer); for (my $i=0; $i<$length; $i++) { my $xy = $xyArray->getitem($i); $xy->{x} = $i*10; $xy->{y} = $i*100; $xyArray->setitem($i, $xy); } for (my $i=0; $i<$length; $i++) { is($xyArray->getitem($i)->{x}, $i*10); is($xyArray->getitem($i)->{y}, $i*100); } } # array_functions { my $length = 5; my $abArray = li_carrays::new_ABArray($length); for (my $i=0; $i<$length; $i++) { my $ab = li_carrays::ABArray_getitem($abArray, $i); $ab->{a} = $i*10; $ab->{b} = $i*100; li_carrays::ABArray_setitem($abArray, $i, $ab); } for (my $i=0; $i<$length; $i++) { is(li_carrays::ABArray_getitem($abArray, $i)->{a}, $i*10); is(li_carrays::ABArray_getitem($abArray, $i)->{b}, $i*100); } li_carrays::delete_ABArray($abArray); } { # global array variable my $length = 3; my $abArray = $li_carrays::globalABArray; for (my $i=0; $i<$length; $i++) { my $ab = li_carrays::ABArray_getitem($abArray, $i); $ab->{a} = $i*10; $ab->{b} = $i*100; li_carrays::ABArray_setitem($abArray, $i, $ab); } for (my $i=0; $i<$length; $i++) { is(li_carrays::ABArray_getitem($abArray, $i)->{a}, $i*10); is(li_carrays::ABArray_getitem($abArray, $i)->{b}, $i*100); } } swig-3.0.2/Examples/test-suite/perl5/director_classes_runme.pl0000664000175000017500000000422112343605122024350 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 29; BEGIN { use_ok 'director_classes' } require_ok 'director_classes'; { package PerlDerived; use base 'director_classes::Base'; sub Val { $_[1] } sub Ref { $_[1] } sub Ptr { $_[1] } sub FullyOverloaded { my $rv = shift->SUPER::FullyOverloaded(@_); $rv =~ s/Base/__PACKAGE__/sge; return $rv; } sub SemiOverloaded { # this is going to be awkward because we can't really # semi-overload in Perl, but we can sort of fake it. return shift->SUPER::SemiOverloaded(@_) unless $_[0] =~ /^\d+/; my $rv = shift->SUPER::SemiOverloaded(@_); $rv =~ s/Base/__PACKAGE__/sge; return $rv; } sub DefaultParms { my $rv = shift->SUPER::DefaultParms(@_); $rv =~ s/Base/__PACKAGE__/sge; return $rv; } } { my $c = director_classes::Caller->new(); makeCalls($c, director_classes::Base->new(100.0)); makeCalls($c, director_classes::Derived->new(200.0)); makeCalls($c, PerlDerived->new(300.0)); } sub makeCalls { my($caller, $base) = @_; my $bname = ref $base; $bname = $1 if $bname =~ /^director_classes::(.*)$/; $caller->set($base); my $dh = director_classes::DoubleHolder->new(444.555); is($caller->ValCall($dh)->{val}, $dh->{val}, "$bname.Val"); is($caller->RefCall($dh)->{val}, $dh->{val}, "$bname.Ref"); is($caller->PtrCall($dh)->{val}, $dh->{val}, "$bname.Ptr"); is($caller->FullyOverloadedCall(1), "${bname}::FullyOverloaded(int)", "$bname.FullyOverloaded(int)"); is($caller->FullyOverloadedCall(''), "${bname}::FullyOverloaded(bool)", "$bname.FullyOverloaded(bool)"); TODO: { local $TODO = 'investigation needed here' if $bname eq 'PerlDerived'; is($caller->SemiOverloadedCall(-678), "${bname}::SemiOverloaded(int)", "$bname.SemiOverloaded(int)"); } is($caller->SemiOverloadedCall(''), "Base::SemiOverloaded(bool)", "$bname.SemiOverloaded(bool)"); is($caller->DefaultParmsCall(10, 2.2), "${bname}::DefaultParms(int, double)", "$bname.DefaultParms(int, double)"); is($caller->DefaultParmsCall(10), "${bname}::DefaultParms(int)", "$bname.DefaultParms(int)"); $caller->reset(); } swig-3.0.2/Examples/test-suite/perl5/enum_thorough_runme.pl0000664000175000017500000005745212343605122023721 0ustar williamwilliam# an adaptation of ../java/enum_thorough_runme.java use strict; use warnings; use Test::More tests => 298; BEGIN { use_ok('enum_thorough') } require_ok('enum_thorough'); is($enum_thorough::ReallyAnInteger, 200, "Test Anon 1"); { my $red = $enum_thorough::red; is(enum_thorough::colourTest1($red), $red, "colourTest1"); is(enum_thorough::colourTest2($red), $red, "colourTest2"); is(enum_thorough::colourTest3($red), $red, "colourTest3"); is(enum_thorough::colourTest4($red), $red, "colourTest4"); isnt($enum_thorough::myColour, $red, "colour global get"); $enum_thorough::myColour = $red; is($enum_thorough::myColour, $red, "colour global set"); } { my $s = enum_thorough::SpeedClass->new(); my $speed = $enum_thorough::SpeedClass::slow; ok(defined($speed), "SpeedClass.slow"); is($s->speedTest1($speed), $speed, "speedTest 1"); is($s->speedTest2($speed), $speed, "speedTest 2"); is($s->speedTest3($speed), $speed, "speedTest 3"); is($s->speedTest4($speed), $speed, "speedTest 4"); is($s->speedTest5($speed), $speed, "speedTest 5"); is($s->speedTest6($speed), $speed, "speedTest 6"); is($s->speedTest7($speed), $speed, "speedTest 7"); is($s->speedTest8($speed), $speed, "speedTest 8"); is(enum_thorough::speedTest1($speed), $speed, "speedTest Global 1"); is(enum_thorough::speedTest2($speed), $speed, "speedTest Global 2"); is(enum_thorough::speedTest3($speed), $speed, "speedTest Global 3"); is(enum_thorough::speedTest4($speed), $speed, "speedTest Global 4"); is(enum_thorough::speedTest5($speed), $speed, "speedTest Global 5"); } { my $s = enum_thorough::SpeedClass->new(); my $slow = $enum_thorough::SpeedClass::slow; my $lightning = $enum_thorough::SpeedClass::lightning; is($s->{mySpeedtd1}, $slow, "mySpeedtd1 1"); is($s->{mySpeedtd1}, 10, "mySpeedtd1 2"); $s->{mySpeedtd1} = $lightning; is($s->{mySpeedtd1}, $lightning, "mySpeedtd1 3"); is($s->{mySpeedtd1}, 31, "mySpeedtd1 4"); } is(enum_thorough::namedanonTest1($enum_thorough::NamedAnon2), $enum_thorough::NamedAnon2, "namedanonTest1"); { my $val = $enum_thorough::TwoNames2; is(enum_thorough::twonamesTest1($val), $val, "twonamesTest 1"); is(enum_thorough::twonamesTest2($val), $val, "twonamesTest 2"); is(enum_thorough::twonamesTest3($val), $val, "twonamesTest 3"); } { local $TODO = "shouldn't namespaces drop into a package?"; my $val = $enum_thorough::AnonSpace::NamedAnonSpace2; ok(defined($val), "found enum value"); SKIP: { skip "enum value not in expected package", 3 unless defined $val; is(enum_thorough::namedanonspaceTest1($val), $val, "namedanonspaceTest 1"); is(enum_thorough::namedanonspaceTest2($val), $val, "namedanonspaceTest 2"); is(enum_thorough::namedanonspaceTest3($val), $val, "namedanonspaceTest 3"); }} { my $t = enum_thorough::TemplateClassInt->new(); my $galileo = $enum_thorough::TemplateClassInt::galileo; is($t->scientistsTest1($galileo), $galileo, "scientistsTest 1"); is($t->scientistsTest2($galileo), $galileo, "scientistsTest 2"); is($t->scientistsTest3($galileo), $galileo, "scientistsTest 3"); is($t->scientistsTest4($galileo), $galileo, "scientistsTest 4"); is($t->scientistsTest5($galileo), $galileo, "scientistsTest 5"); is($t->scientistsTest6($galileo), $galileo, "scientistsTest 6"); is($t->scientistsTest7($galileo), $galileo, "scientistsTest 7"); is($t->scientistsTest8($galileo), $galileo, "scientistsTest 8"); is($t->scientistsTest9($galileo), $galileo, "scientistsTest 9"); is($t->scientistsTestB($galileo), $galileo, "scientistsTest B"); is($t->scientistsTestD($galileo), $galileo, "scientistsTest D"); is($t->scientistsTestE($galileo), $galileo, "scientistsTest E"); is($t->scientistsTestF($galileo), $galileo, "scientistsTest F"); is($t->scientistsTestG($galileo), $galileo, "scientistsTest G"); is($t->scientistsTestH($galileo), $galileo, "scientistsTest H"); is($t->scientistsTestI($galileo), $galileo, "scientistsTest I"); is($t->scientistsTestJ($galileo), $galileo, "scientistsTest J"); is(enum_thorough::scientistsTest1($galileo), $galileo, "scientistsTest Global 1"); is(enum_thorough::scientistsTest2($galileo), $galileo, "scientistsTest Global 2"); is(enum_thorough::scientistsTest3($galileo), $galileo, "scientistsTest Global 3"); is(enum_thorough::scientistsTest4($galileo), $galileo, "scientistsTest Global 4"); is(enum_thorough::scientistsTest5($galileo), $galileo, "scientistsTest Global 5"); is(enum_thorough::scientistsTest6($galileo), $galileo, "scientistsTest Global 6"); is(enum_thorough::scientistsTest7($galileo), $galileo, "scientistsTest Global 7"); is(enum_thorough::scientistsTest8($galileo), $galileo, "scientistsTest Global 8"); } { my $t = enum_thorough::TClassInt->new(); my $bell = $enum_thorough::TClassInt::bell; my $galileo = $enum_thorough::TemplateClassInt::galileo; is($t->scientistsNameTest1($bell), $bell, "scientistsNameTest 1"); is($t->scientistsNameTest2($bell), $bell, "scientistsNameTest 2"); is($t->scientistsNameTest3($bell), $bell, "scientistsNameTest 3"); is($t->scientistsNameTest4($bell), $bell, "scientistsNameTest 4"); is($t->scientistsNameTest5($bell), $bell, "scientistsNameTest 5"); is($t->scientistsNameTest6($bell), $bell, "scientistsNameTest 6"); is($t->scientistsNameTest7($bell), $bell, "scientistsNameTest 7"); is($t->scientistsNameTest8($bell), $bell, "scientistsNameTest 8"); is($t->scientistsNameTest9($bell), $bell, "scientistsNameTest 9"); is($t->scientistsNameTestB($bell), $bell, "scientistsNameTest B"); is($t->scientistsNameTestD($bell), $bell, "scientistsNameTest D"); is($t->scientistsNameTestE($bell), $bell, "scientistsNameTest E"); is($t->scientistsNameTestF($bell), $bell, "scientistsNameTest F"); is($t->scientistsNameTestG($bell), $bell, "scientistsNameTest G"); is($t->scientistsNameTestH($bell), $bell, "scientistsNameTest H"); is($t->scientistsNameTestI($bell), $bell, "scientistsNameTest I"); is($t->scientistsNameSpaceTest1($bell), $bell, "scientistsNameSpaceTest 1"); is($t->scientistsNameSpaceTest2($bell), $bell, "scientistsNameSpaceTest 2"); is($t->scientistsNameSpaceTest3($bell), $bell, "scientistsNameSpaceTest 3"); is($t->scientistsNameSpaceTest4($bell), $bell, "scientistsNameSpaceTest 4"); is($t->scientistsNameSpaceTest5($bell), $bell, "scientistsNameSpaceTest 5"); is($t->scientistsNameSpaceTest6($bell), $bell, "scientistsNameSpaceTest 6"); is($t->scientistsNameSpaceTest7($bell), $bell, "scientistsNameSpaceTest 7"); is($t->scientistsOtherTest1($galileo), $galileo, "scientistsOtherTest 1"); is($t->scientistsOtherTest2($galileo), $galileo, "scientistsOtherTest 2"); is($t->scientistsOtherTest3($galileo), $galileo, "scientistsOtherTest 3"); is($t->scientistsOtherTest4($galileo), $galileo, "scientistsOtherTest 4"); is($t->scientistsOtherTest5($galileo), $galileo, "scientistsOtherTest 5"); is($t->scientistsOtherTest6($galileo), $galileo, "scientistsOtherTest 6"); is($t->scientistsOtherTest7($galileo), $galileo, "scientistsOtherTest 7"); is(enum_thorough::scientistsNameTest1($bell), $bell, "scientistsNameTest Global 1"); is(enum_thorough::scientistsNameTest2($bell), $bell, "scientistsNameTest Global 2"); is(enum_thorough::scientistsNameTest3($bell), $bell, "scientistsNameTest Global 3"); is(enum_thorough::scientistsNameTest4($bell), $bell, "scientistsNameTest Global 4"); is(enum_thorough::scientistsNameTest5($bell), $bell, "scientistsNameTest Global 5"); is(enum_thorough::scientistsNameTest6($bell), $bell, "scientistsNameTest Global 6"); is(enum_thorough::scientistsNameTest7($bell), $bell, "scientistsNameTest Global 7"); is(enum_thorough::scientistsNameSpaceTest1($bell), $bell, "scientistsNameSpaceTest Global 1"); is(enum_thorough::scientistsNameSpaceTest2($bell), $bell, "scientistsNameSpaceTest Global 2"); is(enum_thorough::scientistsNameSpaceTest3($bell), $bell, "scientistsNameSpaceTest Global 3"); is(enum_thorough::scientistsNameSpaceTest4($bell), $bell, "scientistsNameSpaceTest Global 4"); is(enum_thorough::scientistsNameSpaceTest5($bell), $bell, "scientistsNameSpaceTest Global 5"); is(enum_thorough::scientistsNameSpaceTest6($bell), $bell, "scientistsNameSpaceTest Global 6"); is(enum_thorough::scientistsNameSpaceTest7($bell), $bell, "scientistsNameSpaceTest Global 7"); is(enum_thorough::scientistsNameSpaceTest8($bell), $bell, "scientistsNameSpaceTest Global 8"); is(enum_thorough::scientistsNameSpaceTest9($bell), $bell, "scientistsNameSpaceTest Global 9"); is(enum_thorough::scientistsNameSpaceTestA($bell), $bell, "scientistsNameSpaceTest Global A"); is(enum_thorough::scientistsNameSpaceTestB($bell), $bell, "scientistsNameSpaceTest Global B"); is(enum_thorough::scientistsNameSpaceTestC($bell), $bell, "scientistsNameSpaceTest Global C"); is(enum_thorough::scientistsNameSpaceTestD($bell), $bell, "scientistsNameSpaceTest Global D"); is(enum_thorough::scientistsNameSpaceTestE($bell), $bell, "scientistsNameSpaceTest Global E"); is(enum_thorough::scientistsNameSpaceTestF($bell), $bell, "scientistsNameSpaceTest Global F"); is(enum_thorough::scientistsNameSpaceTestG($bell), $bell, "scientistsNameSpaceTest Global G"); is(enum_thorough::scientistsNameSpaceTestH($bell), $bell, "scientistsNameSpaceTest Global H"); is(enum_thorough::scientistsNameSpaceTestI($bell), $bell, "scientistsNameSpaceTest Global I"); is(enum_thorough::scientistsNameSpaceTestJ($bell), $bell, "scientistsNameSpaceTest Global J"); is(enum_thorough::scientistsNameSpaceTestK($bell), $bell, "scientistsNameSpaceTest Global K"); is(enum_thorough::scientistsNameSpaceTestL($bell), $bell, "scientistsNameSpaceTest Global L"); } { my $val = $enum_thorough::argh; is(enum_thorough::renameTest1($val), $val, "renameTest Global 1"); is(enum_thorough::renameTest2($val), $val, "renameTest Global 2"); } { my $n = enum_thorough::NewNameStruct->new(); is($n->renameTest1($enum_thorough::NewNameStruct::bang), $enum_thorough::NewNameStruct::bang, "renameTest 1"); is($n->renameTest2($enum_thorough::NewNameStruct::bang), $enum_thorough::NewNameStruct::bang, "renameTest 2"); is($n->renameTest3($enum_thorough::NewNameStruct::simple1), $enum_thorough::NewNameStruct::simple1, "renameTest 3"); is($n->renameTest4($enum_thorough::NewNameStruct::doublename1), $enum_thorough::NewNameStruct::doublename1, "renameTest 4"); is($n->renameTest5($enum_thorough::NewNameStruct::doublename1), $enum_thorough::NewNameStruct::doublename1, "renameTest 5"); is($n->renameTest6($enum_thorough::NewNameStruct::singlename1), $enum_thorough::NewNameStruct::singlename1, "renameTest 6"); } { is(enum_thorough::renameTest3($enum_thorough::NewNameStruct::bang), $enum_thorough::NewNameStruct::bang, "renameTest Global 3"); is(enum_thorough::renameTest4($enum_thorough::NewNameStruct::simple1), $enum_thorough::NewNameStruct::simple1, "renameTest Global 4"); is(enum_thorough::renameTest5($enum_thorough::NewNameStruct::doublename1), $enum_thorough::NewNameStruct::doublename1, "renameTest Global 5"); is(enum_thorough::renameTest6($enum_thorough::NewNameStruct::doublename1), $enum_thorough::NewNameStruct::doublename1, "renameTest Global 6"); is(enum_thorough::renameTest7($enum_thorough::NewNameStruct::singlename1), $enum_thorough::NewNameStruct::singlename1, "renameTest Global 7"); } { my $t = enum_thorough::TreesClass->new(); my $pine = $enum_thorough::TreesClass::pine; is($t->treesTest1($pine), $pine, "treesTest 1"); is($t->treesTest2($pine), $pine, "treesTest 2"); is($t->treesTest3($pine), $pine, "treesTest 3"); is($t->treesTest4($pine), $pine, "treesTest 4"); is($t->treesTest5($pine), $pine, "treesTest 5"); is($t->treesTest6($pine), $pine, "treesTest 6"); is($t->treesTest7($pine), $pine, "treesTest 7"); is($t->treesTest8($pine), $pine, "treesTest 8"); is($t->treesTest9($pine), $pine, "treesTest 9"); is($t->treesTestA($pine), $pine, "treesTest A"); is($t->treesTestB($pine), $pine, "treesTest B"); is($t->treesTestC($pine), $pine, "treesTest C"); is($t->treesTestD($pine), $pine, "treesTest D"); is($t->treesTestE($pine), $pine, "treesTest E"); is($t->treesTestF($pine), $pine, "treesTest F"); is($t->treesTestG($pine), $pine, "treesTest G"); is($t->treesTestH($pine), $pine, "treesTest H"); is($t->treesTestI($pine), $pine, "treesTest I"); is($t->treesTestJ($pine), $pine, "treesTest J"); is($t->treesTestK($pine), $pine, "treesTest K"); is($t->treesTestL($pine), $pine, "treesTest L"); is($t->treesTestM($pine), $pine, "treesTest M"); is($t->treesTestN($pine), $pine, "treesTest N"); is($t->treesTestO($pine), $pine, "treesTest O"); is(enum_thorough::treesTest1($pine), $pine, "treesTest Global 1"); is(enum_thorough::treesTest2($pine), $pine, "treesTest Global 2"); is(enum_thorough::treesTest3($pine), $pine, "treesTest Global 3"); is(enum_thorough::treesTest4($pine), $pine, "treesTest Global 4"); is(enum_thorough::treesTest5($pine), $pine, "treesTest Global 5"); is(enum_thorough::treesTest6($pine), $pine, "treesTest Global 6"); is(enum_thorough::treesTest7($pine), $pine, "treesTest Global 7"); is(enum_thorough::treesTest8($pine), $pine, "treesTest Global 8"); is(enum_thorough::treesTest9($pine), $pine, "treesTest Global 9"); is(enum_thorough::treesTestA($pine), $pine, "treesTest Global A"); is(enum_thorough::treesTestB($pine), $pine, "treesTest Global B"); is(enum_thorough::treesTestC($pine), $pine, "treesTest Global C"); is(enum_thorough::treesTestD($pine), $pine, "treesTest Global D"); is(enum_thorough::treesTestE($pine), $pine, "treesTest Global E"); is(enum_thorough::treesTestF($pine), $pine, "treesTest Global F"); is(enum_thorough::treesTestG($pine), $pine, "treesTest Global G"); is(enum_thorough::treesTestH($pine), $pine, "treesTest Global H"); is(enum_thorough::treesTestI($pine), $pine, "treesTest Global I"); is(enum_thorough::treesTestJ($pine), $pine, "treesTest Global J"); is(enum_thorough::treesTestK($pine), $pine, "treesTest Global K"); is(enum_thorough::treesTestL($pine), $pine, "treesTest Global L"); is(enum_thorough::treesTestM($pine), $pine, "treesTest Global M"); is(enum_thorough::treesTestO($pine), $pine, "treesTest Global O"); is(enum_thorough::treesTestP($pine), $pine, "treesTest Global P"); is(enum_thorough::treesTestQ($pine), $pine, "treesTest Global Q"); is(enum_thorough::treesTestR($pine), $pine, "treesTest Global R"); } { my $h = enum_thorough::HairStruct->new(); my $ginger = $enum_thorough::HairStruct::ginger; is($h->hairTest1($ginger), $ginger, "hairTest 1"); is($h->hairTest2($ginger), $ginger, "hairTest 2"); is($h->hairTest3($ginger), $ginger, "hairTest 3"); is($h->hairTest4($ginger), $ginger, "hairTest 4"); is($h->hairTest5($ginger), $ginger, "hairTest 5"); is($h->hairTest6($ginger), $ginger, "hairTest 6"); is($h->hairTest7($ginger), $ginger, "hairTest 7"); is($h->hairTest8($ginger), $ginger, "hairTest 8"); is($h->hairTest9($ginger), $ginger, "hairTest 9"); is($h->hairTestA($ginger), $ginger, "hairTest A"); is($h->hairTestB($ginger), $ginger, "hairTest B"); my $red = $enum_thorough::red; is($h->colourTest1($red), $red, "colourTest HairStruct 1"); is($h->colourTest2($red), $red, "colourTest HairStruct 2"); is($h->namedanonTest1($enum_thorough::NamedAnon2), $enum_thorough::NamedAnon2, "namedanonTest HairStruct 1"); { local $TODO = "shouldn't namespaces drop into a package?"; ok(defined($enum_thorough::AnonSpace::NamedAnonSpace2), "found enum value"); SKIP: { skip "enum value not in expected package", 1 unless defined $enum_thorough::AnonSpace::NamedAnonSpace2; is($h->namedanonspaceTest1($enum_thorough::AnonSpace::NamedAnonSpace2), $enum_thorough::AnonSpace::NamedAnonSpace2, "namedanonspaceTest HairStruct 1"); }} my $fir = $enum_thorough::TreesClass::fir; is($h->treesGlobalTest1($fir), $fir, "treesGlobalTest1 HairStruct 1"); is($h->treesGlobalTest2($fir), $fir, "treesGlobalTest1 HairStruct 2"); is($h->treesGlobalTest3($fir), $fir, "treesGlobalTest1 HairStruct 3"); is($h->treesGlobalTest4($fir), $fir, "treesGlobalTest1 HairStruct 4"); } { my $blonde = $enum_thorough::HairStruct::blonde; is(enum_thorough::hairTest1($blonde), $blonde, "hairTest Global 1"); is(enum_thorough::hairTest2($blonde), $blonde, "hairTest Global 2"); is(enum_thorough::hairTest3($blonde), $blonde, "hairTest Global 3"); is(enum_thorough::hairTest4($blonde), $blonde, "hairTest Global 4"); is(enum_thorough::hairTest5($blonde), $blonde, "hairTest Global 5"); is(enum_thorough::hairTest6($blonde), $blonde, "hairTest Global 6"); is(enum_thorough::hairTest7($blonde), $blonde, "hairTest Global 7"); is(enum_thorough::hairTest8($blonde), $blonde, "hairTest Global 8"); is(enum_thorough::hairTest9($blonde), $blonde, "hairTest Global 9"); is(enum_thorough::hairTestA($blonde), $blonde, "hairTest Global A"); is(enum_thorough::hairTestB($blonde), $blonde, "hairTest Global B"); is(enum_thorough::hairTestC($blonde), $blonde, "hairTest Global C"); is(enum_thorough::hairTestA1($blonde), $blonde, "hairTest Global A1"); is(enum_thorough::hairTestA2($blonde), $blonde, "hairTest Global A2"); is(enum_thorough::hairTestA3($blonde), $blonde, "hairTest Global A3"); is(enum_thorough::hairTestA4($blonde), $blonde, "hairTest Global A4"); is(enum_thorough::hairTestA5($blonde), $blonde, "hairTest Global A5"); is(enum_thorough::hairTestA6($blonde), $blonde, "hairTest Global A6"); is(enum_thorough::hairTestA7($blonde), $blonde, "hairTest Global A7"); is(enum_thorough::hairTestA8($blonde), $blonde, "hairTest Global A8"); is(enum_thorough::hairTestA9($blonde), $blonde, "hairTest Global A9"); is(enum_thorough::hairTestAA($blonde), $blonde, "hairTest Global AA"); is(enum_thorough::hairTestAB($blonde), $blonde, "hairTest Global AB"); is(enum_thorough::hairTestAC($blonde), $blonde, "hairTest Global AC"); is(enum_thorough::hairTestB1($blonde), $blonde, "hairTest Global B1"); is(enum_thorough::hairTestB2($blonde), $blonde, "hairTest Global B2"); is(enum_thorough::hairTestB3($blonde), $blonde, "hairTest Global B3"); is(enum_thorough::hairTestB4($blonde), $blonde, "hairTest Global B4"); is(enum_thorough::hairTestB5($blonde), $blonde, "hairTest Global B5"); is(enum_thorough::hairTestB6($blonde), $blonde, "hairTest Global B6"); is(enum_thorough::hairTestB7($blonde), $blonde, "hairTest Global B7"); is(enum_thorough::hairTestB8($blonde), $blonde, "hairTest Global B8"); is(enum_thorough::hairTestB9($blonde), $blonde, "hairTest Global B9"); is(enum_thorough::hairTestBA($blonde), $blonde, "hairTest Global BA"); is(enum_thorough::hairTestBB($blonde), $blonde, "hairTest Global BB"); is(enum_thorough::hairTestBC($blonde), $blonde, "hairTest Global BC"); is(enum_thorough::hairTestC1($blonde), $blonde, "hairTest Global C1"); is(enum_thorough::hairTestC2($blonde), $blonde, "hairTest Global C2"); is(enum_thorough::hairTestC3($blonde), $blonde, "hairTest Global C3"); is(enum_thorough::hairTestC4($blonde), $blonde, "hairTest Global C4"); is(enum_thorough::hairTestC5($blonde), $blonde, "hairTest Global C5"); is(enum_thorough::hairTestC6($blonde), $blonde, "hairTest Global C6"); is(enum_thorough::hairTestC7($blonde), $blonde, "hairTest Global C7"); is(enum_thorough::hairTestC8($blonde), $blonde, "hairTest Global C8"); is(enum_thorough::hairTestC9($blonde), $blonde, "hairTest Global C9"); is(enum_thorough::hairTestCA($blonde), $blonde, "hairTest Global CA"); is(enum_thorough::hairTestCB($blonde), $blonde, "hairTest Global CB"); is(enum_thorough::hairTestCC($blonde), $blonde, "hairTest Global CC"); } { my $f = enum_thorough::FirStruct->new(); my $blonde = $enum_thorough::HairStruct::blonde; is($f->hairTestFir1($blonde), $blonde, "hairTestFir 1"); is($f->hairTestFir2($blonde), $blonde, "hairTestFir 2"); is($f->hairTestFir3($blonde), $blonde, "hairTestFir 3"); is($f->hairTestFir4($blonde), $blonde, "hairTestFir 4"); is($f->hairTestFir5($blonde), $blonde, "hairTestFir 5"); is($f->hairTestFir6($blonde), $blonde, "hairTestFir 6"); is($f->hairTestFir7($blonde), $blonde, "hairTestFir 7"); is($f->hairTestFir8($blonde), $blonde, "hairTestFir 8"); is($f->hairTestFir9($blonde), $blonde, "hairTestFir 9"); is($f->hairTestFirA($blonde), $blonde, "hairTestFir A"); } { $enum_thorough::GlobalInstance = $enum_thorough::globalinstance2; is($enum_thorough::GlobalInstance, $enum_thorough::globalinstance2, "GlobalInstance 1"); my $i = enum_thorough::Instances->new(); $i->{MemberInstance} = $enum_thorough::Instances::memberinstance3; is($i->{MemberInstance}, $enum_thorough::Instances::memberinstance3, "MemberInstance 1"); } # ignore enum item tests start { is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_zero), 0, "ignoreATest 0"); is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_three), 3, "ignoreATest 3"); is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_ten), 10, "ignoreATest 10"); is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_eleven), 11, "ignoreATest 11"); is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirteen), 13, "ignoreATest 13"); is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_fourteen), 14, "ignoreATest 14"); is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_twenty), 20, "ignoreATest 20"); is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty), 30, "ignoreATest 30"); is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty_two), 32, "ignoreATest 32"); is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty_three), 33, "ignoreATest 33"); } { is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_eleven), 11, "ignoreBTest 11"); is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_twelve), 12, "ignoreBTest 12"); is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_thirty_one), 31, "ignoreBTest 31"); is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_thirty_two), 32, "ignoreBTest 32"); is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_forty_one), 41, "ignoreBTest 41"); is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_forty_two), 42, "ignoreBTest 42"); } { is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_ten), 10, "ignoreCTest 10"); is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_twelve), 12, "ignoreCTest 12"); is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_thirty), 30, "ignoreCTest 30"); is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_thirty_two), 32, "ignoreCTest 32"); is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_forty), 40, "ignoreCTest 40"); is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_forty_two), 42, "ignoreCTest 42"); } { is(enum_thorough::ignoreDTest($enum_thorough::IgnoreTest::ignoreD_twenty_one), 21, "ignoreDTest 21"); is(enum_thorough::ignoreDTest($enum_thorough::IgnoreTest::ignoreD_twenty_two), 22, "ignoreDTest 22"); } { is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_zero), 0, "ignoreETest 0"); is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_twenty_one), 21, "ignoreETest 21"); is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_twenty_two), 22, "ignoreETest 22"); } # ignore enum item tests end { is(enum_thorough::repeatTest($enum_thorough::one), 1, "repeatTest 1"); is(enum_thorough::repeatTest($enum_thorough::initial), 1, "repeatTest 2"); is(enum_thorough::repeatTest($enum_thorough::two), 2, "repeatTest 3"); is(enum_thorough::repeatTest($enum_thorough::three), 3, "repeatTest 4"); is(enum_thorough::repeatTest($enum_thorough::llast), 3, "repeatTest 5"); is(enum_thorough::repeatTest($enum_thorough::end), 3, "repeatTest 6"); } # these were the preexisting Perl testcases before the port. # Just test an in and out typemap for enum SWIGTYPE and const enum SWIGTYPE & typemaps is(enum_thorough::speedTest4($enum_thorough::SpeedClass::slow), $enum_thorough::SpeedClass::slow, "speedTest Global 4"); is(enum_thorough::speedTest5($enum_thorough::SpeedClass::slow), $enum_thorough::SpeedClass::slow, "speedTest Global 5"); is(enum_thorough::speedTest4($enum_thorough::SpeedClass::fast), $enum_thorough::SpeedClass::fast, "speedTest Global 4"); is(enum_thorough::speedTest5($enum_thorough::SpeedClass::fast), $enum_thorough::SpeedClass::fast, "speedTest Global 5"); swig-3.0.2/Examples/test-suite/perl5/voidtest_runme.pl0000664000175000017500000000076212343605122022667 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 7; BEGIN { use_ok('voidtest') } require_ok('voidtest'); # adapted from ../python/voidtest_runme.py voidtest::globalfunc(); my $f = voidtest::Foo->new(); is($f->memberfunc(), undef); { local $TODO = "opaque pointers hidden behind layer of indirection"; my $v1 = voidtest::vfunc1($f); my $v2 = voidtest::vfunc2($f); is($v1, $v2); my $v3 = voidtest::vfunc3($v1); is($v3->this, $f->this); my $v4 = voidtest::vfunc4($f); is($v1, $v4); } ok(1, "done"); swig-3.0.2/Examples/test-suite/perl5/director_ignore_runme.pl0000664000175000017500000000077612343605122024211 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 6; BEGIN { use_ok 'director_ignore' } require_ok 'director_ignore'; { package DIgnoresDerived; use base 'director_ignore::DIgnores'; sub PublicMethod1 { return 18.75; } } { package DAbstractIgnoresDerived; use base 'director_ignore::DAbstractIgnores'; } my $a = DIgnoresDerived->new(); isa_ok $a, 'DIgnoresDerived'; is $a->Triple(5), 15; my $b = DAbstractIgnoresDerived->new(); isa_ok $b, 'DAbstractIgnoresDerived'; is $b->Quadruple(5), 20; swig-3.0.2/Examples/test-suite/perl5/contract_runme.pl0000664000175000017500000000501612343605122022640 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 32; BEGIN { use_ok('contract') } require_ok('contract'); # adapted from ../python/contract_runme.py { ok(contract::test_preassert(1,2), "good preassertion"); eval { contract::test_preassert(-1) }; like($@, qr/\bRuntimeError\b/, "bad preassertion"); ok(contract::test_postassert(3), "good postassertion"); eval { contract::test_postassert(-3) }; like($@, qr/\bRuntimeError\b/, "bad postassertion"); ok(contract::test_prepost(2,3), "good prepost"); ok(contract::test_prepost(5,-4), "good prepost"); eval { contract::test_prepost(-3,4); }; like($@, qr/\bRuntimeError\b/, "bad preassertion"); eval { contract::test_prepost(4,-10) }; like($@, qr/\bRuntimeError\b/, "bad postassertion"); } { my $f = contract::Foo->new(); ok($f->test_preassert(4,5), "method pre"); eval { $f->test_preassert(-2,3) }; like($@, qr/\bRuntimeError\b/, "method pre bad"); ok($f->test_postassert(4), "method post"); eval { $f->test_postassert(-4) }; like($@, qr/\bRuntimeError\b/, "method post bad"); ok($f->test_prepost(3,4), "method prepost"); ok($f->test_prepost(4,-3), "method prepost"); eval { $f->test_prepost(-4,2) }; like($@, qr/\bRuntimeError\b/, "method pre bad"); eval { $f->test_prepost(4,-10) }; like($@, qr/\bRuntimeError\b/, "method post bad"); } { ok(contract::Foo::stest_prepost(4,0), "static method prepost"); eval { contract::Foo::stest_prepost(-4,2) }; like($@, qr/\bRuntimeError\b/, "static method pre bad"); eval { contract::Foo::stest_prepost(4,-10) }; like($@, qr/\bRuntimeError\b/, "static method post bad"); } { my $b = contract::Bar->new(); eval { $b->test_prepost(2,-4) }; like($@, qr/\bRuntimeError\b/, "inherit pre bad"); } { my $d = contract::D->new(); eval { $d->foo(-1,1,1,1,1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); eval { $d->foo(1,-1,1,1,1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); eval { $d->foo(1,1,-1,1,1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); eval { $d->foo(1,1,1,-1,1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); eval { $d->foo(1,1,1,1,-1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); eval { $d->bar(-1,1,1,1,1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); eval { $d->bar(1,-1,1,1,1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); eval { $d->bar(1,1,-1,1,1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); eval { $d->bar(1,1,1,-1,1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); eval { $d->bar(1,1,1,1,-1) }; like($@, qr/\bRuntimeError\b/, "inherit pre D"); } swig-3.0.2/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl0000664000175000017500000000262312343605122025467 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 16; BEGIN { use_ok('template_typedef_cplx2') } require_ok('template_typedef_cplx2'); # adapted from ../python/template_typedef_cplx2_runme.py { # kids, don't try this at home (glob hijinks) my $cvar = *template_typedef_cplx2::; map { ${*::}{$_} = ${$cvar}{$_} } keys %{$cvar}; } # # double case # my $d = eval { make_Identity_double() }; ok(ref($d), 'is an object'); like(ref($d), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); my $e = eval { make_Multiplies_double_double_double_double($d, $d) }; ok(ref($e), 'is an object'); like(ref($e), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); # # complex case # my $c = eval { make_Identity_complex() }; ok(ref($c), 'is an object'); like(ref($c), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); my $f = eval { make_Multiplies_complex_complex_complex_complex($c, $c) }; ok(ref($f), 'is an object'); like(ref($f), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); # # Mix case # my $g = eval { make_Multiplies_double_double_complex_complex($d, $c) }; ok(ref($g), 'is an object'); like(ref($g), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); my $h = eval { make_Multiplies_complex_complex_double_double($c, $d) }; ok(ref($h), 'is an object'); like(ref($h), qr/ArithUnaryFunction/, "is an ArithUnaryFunction"); can_ok($g, 'get_value'); ok(eval { $g->get_value() }, 'get_value'); swig-3.0.2/Examples/test-suite/perl5/exception_order_runme.pl0000664000175000017500000000100412343605122024205 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 7; BEGIN { use_ok('exception_order') } require_ok('exception_order'); # adapted from ../python/exception_order_runme.py my $a = exception_order::A->new(); eval { $a->foo() }; isa_ok($@, "exception_order::E1"); eval { $a->bar() }; isa_ok($@, "exception_order::E2"); eval { $a->foobar() }; like($@, qr/\bpostcatch unknown\b/); eval { $a->barfoo(1) }; isa_ok($@, "exception_order::E1"); eval { $a->barfoo(2) }; isa_ok($@, "exception_order::E2"); swig-3.0.2/Examples/test-suite/perl5/typemap_namespace_runme.pl0000664000175000017500000000040112343605122024507 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 4; BEGIN { use_ok('typemap_namespace') } require_ok('typemap_namespace'); is(typemap_namespace::test1("hello"), "hello", "test 1"); is(typemap_namespace::test2("hello"), "hello", "test 1"); swig-3.0.2/Examples/test-suite/perl5/template_default_arg_runme.pl0000664000175000017500000000753212343605122025200 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 34; BEGIN { use_ok('template_default_arg') } require_ok('template_default_arg'); { my $helloInt = new template_default_arg::Hello_int(); $helloInt->foo(0); } { my $x = new template_default_arg::X_int(); is($x->meth(20.0, 200), 200, "X_int test 1"); is($x->meth(20), 20, "X_int test 2"); is($x->meth(), 0, "X_int test 3"); } { my $y = new template_default_arg::Y_unsigned(); is($y->meth(20.0, 200), 200, "Y_unsigned test 1"); is($y->meth(20), 20, "Y_unsigned test 2"); is($y->meth(), 0, "Y_unsigned test 3"); } { my $x = new template_default_arg::X_longlong(); $x = new template_default_arg::X_longlong(20.0); $x = new template_default_arg::X_longlong(20.0, 200); } { my $x = new template_default_arg::X_int(); $x = new template_default_arg::X_int(20.0); $x = new template_default_arg::X_int(20.0, 200); } { my $x = new template_default_arg::X_hello_unsigned(); $x = new template_default_arg::X_hello_unsigned(20.0); $x = new template_default_arg::X_hello_unsigned(20.0, new template_default_arg::Hello_int()); } { my $y = new template_default_arg::Y_hello_unsigned(); $y->meth(20.0, new template_default_arg::Hello_int()); $y->meth(new template_default_arg::Hello_int()); $y->meth(); } { my $fz = new template_default_arg::Foo_Z_8(); my $x = new template_default_arg::X_Foo_Z_8(); my $fzc = $x->meth($fz); } # Templated functions { # plain function: int ott(Foo) is(template_default_arg::ott(new template_default_arg::Foo_int()), 30, "ott test 1"); # %template(ott) ott; is(template_default_arg::ott(), 10, "ott test 2"); is(template_default_arg::ott(1), 10, "ott test 3"); is(template_default_arg::ott(1, 1), 10, "ott test 4"); is(template_default_arg::ott("hi"), 20, "ott test 5"); is(template_default_arg::ott("hi", 1), 20, "ott test 6"); is(template_default_arg::ott("hi", 1, 1), 20,"ott test 7"); # %template(ott) ott; is(template_default_arg::ottstring(new template_default_arg::Hello_int(), "hi"), 40, "ott test 8"); is(template_default_arg::ottstring(new template_default_arg::Hello_int()), 40, "ott test 9"); # %template(ott) ott; is(template_default_arg::ottint(new template_default_arg::Hello_int(), 1), 50, "ott test 10"); is(template_default_arg::ottint(new template_default_arg::Hello_int()), 50, "ott test 11"); # %template(ott) ott; is(template_default_arg::ott(new template_default_arg::Hello_int(), 1.0), 60, "ott test 12"); is(template_default_arg::ott(new template_default_arg::Hello_int()), 60, "ott test 13"); } # Above test in namespaces { # plain function: int nsott(Foo) is(template_default_arg::nsott(new template_default_arg::Foo_int()), 130, "nsott test 1"); # %template(nsott) nsott; is(template_default_arg::nsott(), 110, "nsott test 2"); is(template_default_arg::nsott(1), 110, "nsott test 3"); is(template_default_arg::nsott(1, 1), 110, "nsott test 4"); is(template_default_arg::nsott("hi"), 120, "nsott test 5"); is(template_default_arg::nsott("hi", 1), 120, "nsott test 6"); is(template_default_arg::nsott("hi", 1, 1), 120, "nsott test 7"); # %template(nsott) nsott; is(template_default_arg::nsottstring(new template_default_arg::Hello_int(), "hi"), 140, "nsott test 8"); is(template_default_arg::nsottstring(new template_default_arg::Hello_int()), 140, "nsott test 9"); # %template(nsott) nsott; is(template_default_arg::nsottint(new template_default_arg::Hello_int(), 1), 150, "nsott test 10"); is(template_default_arg::nsottint(new template_default_arg::Hello_int()), 150, "nsott test 11"); # %template(nsott) nsott; is(template_default_arg::nsott(new template_default_arg::Hello_int(), 1.0), 160, "nsott test 12"); is(template_default_arg::nsott(new template_default_arg::Hello_int()), 160, "nsott test 13"); } swig-3.0.2/Examples/test-suite/perl5/template_typedef_cplx3_runme.pl0000664000175000017500000000217712343605122025474 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 16; BEGIN { use_ok('template_typedef_cplx3') } require_ok('template_typedef_cplx3'); # adapted from ../python/template_typedef_cplx3_runme.py { # kids, don't try this at home (glob hijinks) my $cvar = *template_typedef_cplx3::; map { ${*::}{$_} = ${$cvar}{$_} } keys %{$cvar}; } my $s = Sin->new(); is($s->get_base_value(), 0); is($s->get_value(), 1); is($s->get_arith_value(), 2); is(my_func_r($s), 0); isa_ok(make_Multiplies_double_double_double_double($s,$s), "template_typedef_cplx3::ArithUnaryFunction_double_double"); my $z = CSin->new(); is($z->get_base_value(), 0); is($z->get_value(), 1); is($z->get_arith_value(), 2); is(my_func_c($z), 1); isa_ok(make_Multiplies_complex_complex_complex_complex($z,$z), "template_typedef_cplx3::ArithUnaryFunction_complex_complex"); my $d = eval { make_Identity_double() }; isa_ok($d, "template_typedef_cplx3::ArithUnaryFunction_double_double"); is(my_func_r($d), 0); my $c = eval { make_Identity_complex() }; isa_ok($d, "template_typedef_cplx3::ArithUnaryFunction_double_double"); is(my_func_c($c), 1); swig-3.0.2/Examples/test-suite/perl5/overload_copy_runme.pl0000664000175000017500000000012512343605122023664 0ustar williamwilliam use overload_copy; $f = new overload_copy::Foo(); $g = new overload_copy::Foo($f); swig-3.0.2/Examples/test-suite/perl5/director_basic_runme.pl0000664000175000017500000000264312343605122024002 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 12; BEGIN { use_ok 'director_basic' } require_ok 'director_basic'; { package MyFoo; use base 'director_basic::Foo'; sub ping { return 'MyFoo::ping()'; } } { package MyOverriddenClass; use base 'director_basic::MyClass'; use fields qw(expectNull nonNullReceived); sub new { my $self = shift->SUPER::new(@_); $self->{expectNull} = undef; $self->{nonNullReceived} = undef; return $self; } sub pmethod { my($self, $b) = @_; die "null not received as expected" if $self->{expectNull} and defined $b; return $b; } } { my $a = MyFoo->new(); isa_ok $a, 'MyFoo'; is $a->ping(), 'MyFoo::ping()', 'a.ping()'; is $a->pong(), 'Foo::pong();MyFoo::ping()', 'a.pong()'; my $b = director_basic::Foo->new(); isa_ok $b, 'director_basic::Foo'; is $b->ping(), 'Foo::ping()', 'b.ping()'; is $b->pong(), 'Foo::pong();Foo::ping()', 'b.pong()'; my $a1 = director_basic::A1->new(1, undef); isa_ok $a1, 'director_basic::A1'; is $a1->rg(2), 2, 'A1.rg'; my $my = MyOverriddenClass->new(); $my->{expectNull} = 1; is(director_basic::MyClass::call_pmethod($my, undef), undef, 'null pointer marshalling'); my $myBar = director_basic::Bar->new(); $my->{expectNull} = undef; my $myNewBar = director_basic::MyClass::call_pmethod($my, $myBar); isnt($myNewBar, undef, 'non-null pointer marshalling'); $myNewBar->{x} = 10; } swig-3.0.2/Examples/test-suite/perl5/rename_scope_runme.pl0000664000175000017500000000053312343605122023462 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('rename_scope') } require_ok('rename_scope'); # adapted from ../python/rename_scope_runme.py my $a = rename_scope::Natural_UP->new(); is($a->rtest(), 1); my $b = rename_scope::Natural_BP->new(); is($b->rtest(), 1); isa_ok(rename_scope->can('equals'), 'CODE'); swig-3.0.2/Examples/test-suite/perl5/unions_runme.pl0000664000175000017500000000231212343605122022332 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 7; # This is the union runtime testcase. It ensures that values within a # union embedded within a struct can be set and read correctly. BEGIN { use_ok('unions') } require_ok('unions'); # Create new instances of SmallStruct and BigStruct for later use my $small = new unions::SmallStruct(); $small->{jill} = 200; my $big = new unions::BigStruct(); $big->{smallstruct} = $small; $big->{jack} = 300; # Use SmallStruct then BigStruct to setup EmbeddedUnionTest. # Ensure values in EmbeddedUnionTest are set correctly for each. my $eut = new unions::EmbeddedUnionTest(); # First check the SmallStruct in EmbeddedUnionTest $eut->{number} = 1; $eut->{uni}->{small} = $small; my $Jill1 = $eut->{uni}->{small}->{jill}; is($Jill1, 200, "eut.uni.small.jill"); my $Num1 = $eut->{number}; is($Num1, 1, "test2 eut.number"); # Secondly check the BigStruct in EmbeddedUnionTest $eut->{number} = 2; $eut->{uni}->{big} = $big; my $Jack1 = $eut->{uni}->{big}->{jack}; is($Jack1, 300, "test3 eut.uni.big.jack"); my $Jill2 = $eut->{uni}->{big}->{smallstruct}->{jill}; is($Jill2, 200, "test4 eut.uni.big.smallstruct.jill"); my $Num2 = $eut->{number}; is($Num2, 2, "test5 eut.number"); swig-3.0.2/Examples/test-suite/perl5/packageoption_runme.pl0000664000175000017500000000075612343605122023655 0ustar williamwilliam#!/usr/bin/perl -w use strict; use Test::More tests => 4; BEGIN { use_ok('packageoption_a'); } BEGIN { use_ok('packageoption_b'); } # Workaround for # ok( not (expression) , "test description" ); # does not working in older versions of Perl, eg 5.004_04 sub ok_not ($;$) { my($test, $name) = @_; $test = not $test; ok($test, $name); } my $a = CommonPackage::A->new(); isa_ok($a, 'CommonPackage::A'); my $b = CommonPackage::B->new(); isa_ok($b, 'CommonPackage::B'); swig-3.0.2/Examples/test-suite/perl5/multiple_inheritance_runme.pl0000664000175000017500000000046212343605122025227 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('multiple_inheritance') } require_ok('multiple_inheritance'); my $fooBar = new multiple_inheritance::FooBar(); is($fooBar->foo(), 2, "Runtime test1"); is($fooBar->bar(), 1, "Runtime test2"); is($fooBar->fooBar(), 3, "Runtime test3 "); swig-3.0.2/Examples/test-suite/perl5/director_primitives_runme.pl0000664000175000017500000000337712343605122025121 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 27; BEGIN { use_ok 'director_primitives' } require_ok 'director_primitives'; { package PerlDerived; use base 'director_primitives::Base'; sub NoParmsMethod { } sub BoolMethod { my($self, $x) = @_; return $x; } sub IntMethod { my($self, $x) = @_; return $x; } sub UIntMethod { my($self, $x) = @_; return $x; } sub FloatMethod { my($self, $x) = @_; return $x; } sub CharPtrMethod { my($self, $x) = @_; return $x; } sub ConstCharPtrMethod { my($self, $x) = @_; return $x; } sub EnumMethod { my($self, $x) = @_; return $x; } sub ManyParmsMethod { } } my $myCaller = director_primitives::Caller->new(); isa_ok $myCaller, 'director_primitives::Caller'; { my $myBase = director_primitives::Base->new(100.0); makeCalls($myCaller, $myBase); } { my $myBase = director_primitives::Derived->new(200.0); makeCalls($myCaller, $myBase); } { my $myBase = PerlDerived->new(300.0); makeCalls($myCaller, $myBase); } sub makeCalls { my($myCaller, $myBase) = @_; $myCaller->set($myBase); $myCaller->NoParmsMethodCall(); is $myCaller->BoolMethodCall(1), '1'; is $myCaller->BoolMethodCall(0), ''; is $myCaller->IntMethodCall(-123), -123; is $myCaller->UIntMethodCall(123), 123; is $myCaller->FloatMethodCall(-123 / 128), -0.9609375; is $myCaller->CharPtrMethodCall("test string"), "test string"; is $myCaller->ConstCharPtrMethodCall("another string"), "another string"; is $myCaller->EnumMethodCall($director_primitives::HShadowHard), $director_primitives::HShadowHard; $myCaller->ManyParmsMethodCall(1, -123, 123, 123.456, "test string", "another string", $director_primitives::HShadowHard); $myCaller->NotOverriddenMethodCall(); $myCaller->reset(); } swig-3.0.2/Examples/test-suite/perl5/varargs_runme.pl0000664000175000017500000000061112343605122022464 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 7; BEGIN { use_ok('varargs') } require_ok('varargs'); is(varargs::test("Hello"), "Hello"); my $f = new varargs::Foo("BuonGiorno", 1); is($f->{str}, "BuonGiorno"); $f = new varargs::Foo("Greetings"); is($f->{str}, "Greetings"); is($f->test("Hello"), "Hello"); is(varargs::Foo::statictest("Grussen", 1), "Grussen"); swig-3.0.2/Examples/test-suite/perl5/class_ignore_runme.pl0000664000175000017500000000040212343605122023465 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 3; BEGIN { use_ok('class_ignore') } require_ok('class_ignore'); # adapted from ../python/class_ignore_runme.py my $a = class_ignore::Bar->new(); is(class_ignore::do_blah($a), "Bar::blah"); swig-3.0.2/Examples/test-suite/perl5/aggregate_runme.pl0000664000175000017500000000116412343605122022751 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 7; BEGIN { use_ok('aggregate') } require_ok('aggregate'); # adapted from ../java/aggregate_runme.java # Confirm that move() returns correct results under normal use is(aggregate::move($aggregate::UP), $aggregate::UP, "UP"); is(aggregate::move($aggregate::DOWN), $aggregate::DOWN, "DOWN"); is(aggregate::move($aggregate::LEFT), $aggregate::LEFT, "LEFT"); is(aggregate::move($aggregate::RIGHT), $aggregate::RIGHT, "RIGHT"); # Confirm that move() raises an exception when the contract is violated eval { aggregate::move(0) }; like($@, qr/\bRuntimeError\b/); swig-3.0.2/Examples/test-suite/perl5/director_alternating_runme.pl0000664000175000017500000000035712343605122025231 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 3; BEGIN { use_ok('director_alternating') } require_ok('director_alternating'); my $id = director_alternating::getBar()->id(); is($id, director_alternating::idFromGetBar(), "got Bar id"); swig-3.0.2/Examples/test-suite/perl5/director_abstract_runme.pl0000664000175000017500000000255012343605122024521 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 13; BEGIN { use_ok('director_abstract') } require_ok('director_abstract'); { package MyFoo; use base 'director_abstract::Foo'; sub ping { return 'MyFoo::ping()'; } } my $f = MyFoo->new(); is($f->ping, "MyFoo::ping()"); is($f->pong(),"Foo::pong();MyFoo::ping()"); { package MyExample1; use base 'director_abstract::Example1'; sub Color { my($self, $r, $g, $b) = @_; return $r; } } { package MyExample2; use base 'director_abstract::Example2'; sub Color { my($self, $r, $g, $b) = @_; return $g; } } { package MyExample3; use base 'director_abstract::Example3_i'; sub Color { my($self, $r, $g, $b) = @_; return $b; } } my $me1 = MyExample1->new(); isa_ok($me1, 'MyExample1'); is(director_abstract::Example1::get_color($me1, 1, 2, 3), 1, 'me1'); my $me2 = MyExample2->new(1,2); isa_ok($me2, 'MyExample2'); is(director_abstract::Example2::get_color($me2, 1, 2, 3), 2, 'me2'); my $me3 = MyExample3->new(); isa_ok($me3, 'MyExample3'); is(director_abstract::Example3_i::get_color($me3, 1, 2, 3), 3, 'me3'); eval { $me1 = director_abstract::Example1->new() }; like($@, qr/\babstract\b/i, 'E1.new()'); eval { $me2 = director_abstract::Example2->new() }; like($@, qr/Example2/, 'E2.new()'); eval { $me3 = director_abstract::Example3_i->new() }; like($@, qr/\babstract\b/i, 'E3.new()'); swig-3.0.2/Examples/test-suite/perl5/director_protected_runme.pl0000664000175000017500000000246112343605122024710 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 19; BEGIN { use_ok 'director_protected' } require_ok 'director_protected'; { package FooBar; use base 'director_protected::Bar'; sub ping { 'FooBar::ping();' } } { package FooBar2; use base 'director_protected::Bar'; sub ping { 'FooBar2::ping();' } sub pang { 'FooBar2::pang();' } } my $b = director_protected::Bar->new(); isa_ok $b, 'director_protected::Bar'; my $f = $b->create(); my $fb = FooBar->new(); isa_ok $fb, 'FooBar'; my $fb2 = FooBar2->new(); isa_ok $fb2, 'FooBar2'; is $b->used(), "Foo::pang();Bar::pong();Foo::pong();Bar::ping();"; eval { $f->used() }; like $@, qr/protected member/; is $fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();"; is $fb2->used(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();"; is $b->pong(), "Bar::pong();Foo::pong();Bar::ping();"; is $f->pong(), "Bar::pong();Foo::pong();Bar::ping();"; is $fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();"; is $fb2->pong(), "Bar::pong();Foo::pong();FooBar2::ping();"; eval { $b->ping() }; like $@, qr/protected member/; eval { $f->ping () }; like $@, qr/protected member/; is $fb->ping(), 'FooBar::ping();'; is $fb2->ping(), 'FooBar2::ping();'; eval { $b->pang() }; like $@, qr/protected member/; eval { $f->pang() }; like $@, qr/protected member/; swig-3.0.2/Examples/test-suite/perl5/ignore_parameter_runme.pl0000664000175000017500000000252012343605122024343 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 14; BEGIN { use_ok('ignore_parameter') } require_ok('ignore_parameter'); # adapted from ../java/ignore_parameter_runme.java # Runtime test checking the %typemap(ignore) macro # Compilation will ensure the number of arguments and type are correct. # Then check the return value is the same as the value given to the ignored parameter. is(ignore_parameter::jaguar(200, 0.0), "hello", "jaguar()"); is(ignore_parameter::lotus("fast", 0.0), 101, "lotus()"); is(ignore_parameter::tvr("fast", 200), 8.8, "tvr()"); is(ignore_parameter::ferrari(), 101, "ferrari()"); my $sc = new ignore_parameter::SportsCars(); is($sc->daimler(200, 0.0), "hello", "daimler()"); is($sc->astonmartin("fast", 0.0), 101, "astonmartin()"); is($sc->bugatti("fast", 200), 8.8, "bugatti()"); is($sc->lamborghini(), 101, "lamborghini()"); # Check constructors are also generated correctly my $mc = eval { new ignore_parameter::MiniCooper(200, 0.0) }; isa_ok($mc, 'ignore_parameter::MiniCooper'); my $mm = eval { new ignore_parameter::MorrisMinor("slow", 0.0) }; isa_ok($mm, 'ignore_parameter::MorrisMinor'); my $fa = eval { new ignore_parameter::FordAnglia("slow", 200) }; isa_ok($fa, 'ignore_parameter::FordAnglia'); my $aa = eval { new ignore_parameter::AustinAllegro() }; isa_ok($aa, 'ignore_parameter::AustinAllegro'); swig-3.0.2/Examples/test-suite/perl5/li_std_except_runme.pl0000664000175000017500000000363612343605122023657 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 22; BEGIN { use_ok('li_std_except') } require_ok('li_std_except'); # adapted from ../java/li_std_except_runme.java # these are not prescriptive tests, they just match the error classes I # found are currently being issued, we may want to provide a more # granular error api later, so don't let these tests stop code # improvements. my $test = new li_std_except::Test(); eval { $test->throw_bad_exception() }; like($@, qr/\bSystemError\b/, "throw_bad_exception"); eval { $test->throw_domain_error() }; like($@, qr/\bValueError\b/, "throw_domain_error"); like($@, qr/\boops\b/, "throw_domain_error message"); eval { $test->throw_exception() }; like($@, qr/\bSystemError\b/, "throw_exception"); eval { $test->throw_invalid_argument() }; like($@, qr/\bValueError\b/, "throw_invalid_argument"); like($@, qr/\boops\b/, "throw_invalid_argument message"); eval { $test->throw_length_error() }; like($@, qr/\bIndexError\b/, "throw_length_error"); like($@, qr/\boops\b/, "throw_length_error message"); eval { $test->throw_logic_error() }; like($@, qr/\bRuntimeError\b/, "throw_logic_error"); like($@, qr/\boops\b/, "throw_logic_error message"); eval { $test->throw_out_of_range() }; like($@, qr/\bIndexError\b/, "throw_out_of_range"); like($@, qr/\boops\b/, "throw_out_of_range message"); eval { $test->throw_overflow_error() }; like($@, qr/\bOverflowError\b/, "throw_overflow_error"); like($@, qr/\boops\b/, "throw_overflow_error message"); eval { $test->throw_range_error() }; like($@, qr/\bOverflowError\b/, "throw_range_error"); like($@, qr/\boops\b/, "throw_range_error message"); eval { $test->throw_runtime_error() }; like($@, qr/\bRuntimeError\b/, "throw_runtime_error"); like($@, qr/\boops\b/, "throw_runtime_error message"); eval { $test->throw_underflow_error() }; like($@, qr/\bOverflowError\b/, "throw_underflow_error"); like($@, qr/\boops\b/, "throw_underflow_error message"); swig-3.0.2/Examples/test-suite/perl5/return_const_value_runme.pl0000664000175000017500000000047612343605122024751 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 4; BEGIN { use_ok('return_const_value') } require_ok('return_const_value'); # adapted from ../python/return_const_value_runme.py is(return_const_value::Foo_ptr::getPtr()->getVal(), 17); is(return_const_value::Foo_ptr::getConstPtr()->getVal(), 17); swig-3.0.2/Examples/test-suite/perl5/using1_runme.pl0000664000175000017500000000027312343605122022231 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 3; BEGIN { use_ok('using1') } require_ok('using1'); # adapted from ../python/using1_runme.py is(using1::spam(37), 37); swig-3.0.2/Examples/test-suite/perl5/director_finalizer_runme.pl0000664000175000017500000000457412343605122024711 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 13; BEGIN { use_ok('director_finalizer') } require_ok('director_finalizer'); { package MyFoo; use base 'director_finalizer::Foo'; sub DESTROY { my($self, $final) = @_; $self->orStatus(2) if $final; shift->SUPER::DESTROY(@_); } } { director_finalizer::resetStatus(); my $f = MyFoo->new(); undef $f; is(director_finalizer::getStatus(), 3, 'shadow release fires destructor'); } { # again, this time with DESTROY director_finalizer::resetStatus(); my $f = MyFoo->new(); $f->DESTROY(); is(director_finalizer::getStatus(), 3, 'DESTROY method fires destructor'); } { director_finalizer::resetStatus(); my $f = MyFoo->new(); director_finalizer::launder($f); is(director_finalizer::getStatus(), 0, 'wrap release does not fire destructor'); undef $f; is(director_finalizer::getStatus(), 3, 'shadow release still fires destructor'); } { # again, this time with DESTROY director_finalizer::resetStatus(); my $f = MyFoo->new(); director_finalizer::launder($f); is(director_finalizer::getStatus(), 0, 'wrap release does not fire destructor'); $f->DESTROY(); is(director_finalizer::getStatus(), 3, 'DESTROY method still fires destructor'); } { director_finalizer::resetStatus(); my $f = MyFoo->new(); $f->DISOWN(); is(director_finalizer::getStatus(), 0, 'shadow release does not fire destructor of disowned object'); director_finalizer::deleteFoo($f); is(director_finalizer::getStatus(), 3, 'c++ release fires destructors of disowned object'); } { # again, this time with DESTROY my $f = MyFoo->new(); $f->DISOWN(); director_finalizer::deleteFoo($f); director_finalizer::resetStatus(); $f->DESTROY(); is(director_finalizer::getStatus(), 0, 'DESTROY method does not fire destructor of disowned object'); } { director_finalizer::resetStatus(); my $f = MyFoo->new(); $f->DISOWN(); my $g = director_finalizer::launder($f); undef $f; director_finalizer::deleteFoo($g); is(director_finalizer::getStatus(), 3, 'c++ release fires destructors on disowned opaque object'); } { # again, this time with DESTROY director_finalizer::resetStatus(); my $f = MyFoo->new(); $f->DISOWN(); my $g = director_finalizer::launder($f); $f->DESTROY(); director_finalizer::deleteFoo($g); is(director_finalizer::getStatus(), 3, 'c++ release fires destructors on disowned opaque object after DESTROY'); } swig-3.0.2/Examples/test-suite/perl5/template_ref_type_runme.pl0000664000175000017500000000016412343605122024532 0ustar williamwilliamuse template_ref_type; my $xr = template_ref_type::XC->new(); my $y = template_ref_type::Y->new(); $y->find($xr); swig-3.0.2/Examples/test-suite/perl5/inherit_runme.pl0000664000175000017500000000027412343605122022466 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 3; BEGIN { use_ok('inherit') } require_ok('inherit'); my $der = new inherit::CDerived(); is($der->Foo(), "CBase::Foo", "inherit test"); swig-3.0.2/Examples/test-suite/perl5/apply_strings_runme.pl0000664000175000017500000000056012343605122023720 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 4; BEGIN { use_ok('apply_strings') } require_ok('apply_strings'); my $TEST_MESSAGE = "A message from target language to the C++ world and back again."; is(apply_strings::UCharFunction($TEST_MESSAGE), $TEST_MESSAGE, "UCharFunction"); is(apply_strings::SCharFunction($TEST_MESSAGE), $TEST_MESSAGE, "SCharFunction"); swig-3.0.2/Examples/test-suite/perl5/grouping_runme.pl0000664000175000017500000000052712343605122022657 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 6; BEGIN { use_ok('grouping') } require_ok('grouping'); # adapted from ../python/grouping_runme.py is(grouping::test1(42), 42); isnt(eval { grouping::test2(42) }, undef); is(grouping::do_unary(37, $grouping::NEGATE), -37); $grouping::test3 = 42; is($grouping::test3, 42); swig-3.0.2/Examples/test-suite/perl5/inctest_runme.pl0000664000175000017500000000036312343605122022474 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 3; BEGIN { use_ok('inctest') } require_ok('inctest'); my $things = inctest::MY_THINGS->new(); my $i = 0; $things->{IntegerMember} = $i; my $d = $things->{DoubleMember}; ok(1); swig-3.0.2/Examples/test-suite/perl5/operator_overload_break_runme.pl0000664000175000017500000000150612343605122025715 0ustar williamwilliam#!/usr/bin/perl -w use strict; use Test::More tests => 9; use operator_overload_break; # Workaround for # ok( not (expression) , "test description" ); # does not working in older versions of Perl, eg 5.004_04 sub ok_not ($;$) { my($test, $name) = @_; $test = not $test; ok($test, $name); } pass("loaded"); my $op = operator_overload_break::Op->new(5); isa_ok($op, "operator_overload_break::Op"); ok((2 == $op - 3), "subtraction"); $op->{k} = 37; ok((40 == $op + 3), "addition"); $op->{k} = 22; ok((10 == (32 - $op)), "reversed subtraction"); ok_not((3 == $op), 'not equal'); $op->{k} = 3; ++$op; ok(($op == 4), "pre-increment operator"); $op++; ok(($op == 5), "post-increment operator"); my $op2 = ++$op; $op2 = $op++; ok(($op == 7) and ($op2 == 7), "multiple post-increments"); swig-3.0.2/Examples/test-suite/perl5/apply_signed_char_runme.pl0000664000175000017500000000147712343605122024505 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 12; BEGIN { use_ok('apply_signed_char') } require_ok('apply_signed_char'); # adapted from ../java/apply_signed_char_runme.java my $smallnum = -127; is(apply_signed_char::CharValFunction($smallnum), $smallnum); is(apply_signed_char::CCharValFunction($smallnum), $smallnum); is(apply_signed_char::CCharRefFunction($smallnum), $smallnum); $apply_signed_char::globalchar = $smallnum; is($apply_signed_char::globalchar, $smallnum); is($apply_signed_char::globalconstchar, -110); my $d = new apply_signed_char::DirectorTest(); is($d->CharValFunction($smallnum), $smallnum); is($d->CCharValFunction($smallnum), $smallnum); is($d->CCharRefFunction($smallnum), $smallnum); $d->{memberchar} = $smallnum; is($d->{memberchar}, $smallnum); is($d->{memberconstchar}, -112); swig-3.0.2/Examples/test-suite/perl5/inherit_missing_runme.pl0000664000175000017500000000073612343605122024222 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('inherit_missing') } require_ok('inherit_missing'); # adapted from ../python/inherit_missing_runme.py my $a = inherit_missing::new_Foo(); my $b = inherit_missing::Bar->new(); my $c = inherit_missing::Spam->new(); is(inherit_missing::do_blah($a), "Foo::blah"); is(inherit_missing::do_blah($b), "Bar::blah"); is(inherit_missing::do_blah($c), "Spam::blah"); inherit_missing::delete_Foo($a); swig-3.0.2/Examples/test-suite/perl5/ret_by_value_runme.pl0000664000175000017500000000037612343605122023507 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('ret_by_value') } require_ok('ret_by_value'); my $tst = ret_by_value::get_test(); isa_ok($tst, 'ret_by_value::test'); is($tst->{myInt}, 100); is($tst->{myShort}, 200); swig-3.0.2/Examples/test-suite/perl5/director_detect_runme.pl0000664000175000017500000000160012343605122024161 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 9; BEGIN { use_ok 'director_detect' } require_ok 'director_detect'; { package MyBar; use base 'director_detect::Bar'; sub new { my $class = shift; my $val = @_ ? shift : 2; my $self = $class->SUPER::new(); $self->{val} = $val; return $self; } sub get_value { my($self) = @_; $self->{val}++; return $self->{val}; } sub get_class { my($self) = @_; $self->{val}++; return director_detect::A->new(); } sub just_do_it { my($self) = @_; $self->{val}++; } sub clone { my($self) = @_; MyBar->new($self->{val}); } } my $b = MyBar->new(); isa_ok $b, 'MyBar'; my $f = $b->baseclass(); isa_ok $f, 'director_detect::Foo'; is $f->get_value(), 3; isa_ok $f->get_class(), 'director_detect::A'; $f->just_do_it(); my $c = $b->clone(); isa_ok $c, 'MyBar'; is $b->{val}, 5; is $c->get_value(), 6; swig-3.0.2/Examples/test-suite/perl5/director_extend_runme.pl0000664000175000017500000000050112343605122024177 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 5; BEGIN { use_ok 'director_extend' } require_ok 'director_extend'; { package MyObject; use base 'director_extend::SpObject'; sub getFoo { 123 } } my $m = MyObject->new(); isa_ok $m, 'MyObject'; is($m->dummy(), 666, '1st call'); is($m->dummy(), 666, '2nd call'); swig-3.0.2/Examples/test-suite/perl5/director_unroll_runme.pl0000664000175000017500000000052012343605122024224 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 3; BEGIN { use_ok 'director_unroll' }; require_ok 'director_unroll'; { package MyFoo; use base 'director_unroll::Foo'; sub ping { "MyFoo::ping()" } } $a = MyFoo->new(); $b = director_unroll::Bar->new(); $b->set($a); my $c = $b->get(); is(${$a->this}, ${$c->this}, "unrolling"); swig-3.0.2/Examples/test-suite/perl5/primitive_types_runme.pl0000664000175000017500000002317512343605122024265 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 51; BEGIN { use_ok('primitive_types') } require_ok('primitive_types'); primitive_types::var_init(); # assigning globals calls $primitive_types::var_bool = $primitive_types::sct_bool; $primitive_types::var_schar = $primitive_types::sct_schar; $primitive_types::var_uchar = $primitive_types::sct_uchar; $primitive_types::var_int = $primitive_types::sct_int; $primitive_types::var_uint = $primitive_types::sct_uint; $primitive_types::var_short = $primitive_types::sct_short; $primitive_types::var_ushort = $primitive_types::sct_ushort; $primitive_types::var_long = $primitive_types::sct_long; $primitive_types::var_ulong = $primitive_types::sct_ulong; $primitive_types::var_llong = $primitive_types::sct_llong; $primitive_types::var_ullong = $primitive_types::sct_ullong; $primitive_types::var_char = $primitive_types::sct_char; $primitive_types::var_pchar = $primitive_types::sct_pchar; $primitive_types::var_pcharc = $primitive_types::sct_pcharc; $primitive_types::var_pint = $primitive_types::sct_pint; $primitive_types::var_sizet = $primitive_types::sct_sizet; $primitive_types::var_hello = $primitive_types::sct_hello; $primitive_types::var_myint = $primitive_types::sct_myint; $primitive_types::var_namet = $primitive_types::def_namet; $primitive_types::var_parami = $primitive_types::sct_parami; $primitive_types::var_paramd = $primitive_types::sct_paramd; $primitive_types::var_paramc = $primitive_types::sct_paramc; ok(primitive_types::v_check(), "v_check"); #def pyerror(name, val, cte): # print "bad val/cte", name, val, cte # raise RuntimeError # pass is($primitive_types::var_bool, $primitive_types::cct_bool, "bool"); is($primitive_types::var_schar, $primitive_types::cct_schar, "schar"); is($primitive_types::var_uchar, $primitive_types::cct_uchar, "uchar"); is($primitive_types::var_int, $primitive_types::cct_int, "int"); is($primitive_types::var_uint, $primitive_types::cct_uint, "uint"); is($primitive_types::var_short, $primitive_types::cct_short, "short"); is($primitive_types::var_ushort, $primitive_types::cct_ushort, "ushort"); is($primitive_types::var_long, $primitive_types::cct_long, "long"); is($primitive_types::var_ulong, $primitive_types::cct_ulong, "ulong"); is($primitive_types::var_llong, $primitive_types::cct_llong, "llong"); is($primitive_types::var_ullong, $primitive_types::cct_ullong, "ullong"); is($primitive_types::var_char, $primitive_types::cct_char, "char"); is($primitive_types::var_pchar, $primitive_types::cct_pchar, "pchar"); is($primitive_types::var_pcharc, $primitive_types::cct_pcharc, "pchar"); is($primitive_types::var_pint, $primitive_types::cct_pint, "pint"); is($primitive_types::var_sizet, $primitive_types::cct_sizet, "sizet"); is($primitive_types::var_hello, $primitive_types::cct_hello, "hello"); is($primitive_types::var_myint, $primitive_types::cct_myint, "myint"); is($primitive_types::var_namet, $primitive_types::def_namet, "name"); #class PyTest (TestDirector): # def __init__(self): # TestDirector.__init__(self) # pass # def ident(self, x): # return x # # def vval_bool(self, x): return self.ident(x) # def vval_schar(self, x): return self.ident(x) # def vval_uchar(self, x): return self.ident(x) # def vval_int(self, x): return self.ident(x) # def vval_uint(self, x): return self.ident(x) # def vval_short(self, x): return self.ident(x) # def vval_ushort(self, x): return self.ident(x) # def vval_long(self, x): return self.ident(x) # def vval_ulong(self, x): return self.ident(x) # def vval_llong(self, x): return self.ident(x) # def vval_ullong(self, x): return self.ident(x) # def vval_float(self, x): return self.ident(x) # def vval_double(self, x): return self.ident(x) # def vval_char(self, x): return self.ident(x) # def vval_pchar(self, x): return self.ident(x) # def vval_pcharc(self, x): return self.ident(x) # def vval_pint(self, x): return self.ident(x) # def vval_sizet(self, x): return self.ident(x) # def vval_hello(self, x): return self.ident(x) # def vval_myint(self, x): return self.ident(x) # # def vref_bool(self, x): return self.ident(x) # def vref_schar(self, x): return self.ident(x) # def vref_uchar(self, x): return self.ident(x) # def vref_int(self, x): return self.ident(x) # def vref_uint(self, x): return self.ident(x) # def vref_short(self, x): return self.ident(x) # def vref_ushort(self, x): return self.ident(x) # def vref_long(self, x): return self.ident(x) # def vref_ulong(self, x): return self.ident(x) # def vref_llong(self, x): return self.ident(x) # def vref_ullong(self, x): return self.ident(x) # def vref_float(self, x): return self.ident(x) # def vref_double(self, x): return self.ident(x) # def vref_char(self, x): return self.ident(x) # def vref_pchar(self, x): return self.ident(x) # def vref_pcharc(self, x): return self.ident(x) # def vref_pint(self, x): return self.ident(x) # def vref_sizet(self, x): return self.ident(x) # def vref_hello(self, x): return self.ident(x) # def vref_myint(self, x): return self.ident(x) # # pass my $t = primitive_types::Test->new(); #p = PyTest() # # # internal call check #if t.c_check() != p.c_check(): # raise RuntimeError, "bad director" # #p.var_bool = p.stc_bool #p.var_schar = p.stc_schar #p.var_uchar = p.stc_uchar #p.var_int = p.stc_int #p.var_uint = p.stc_uint #p.var_short = p.stc_short #p.var_ushort = p.stc_ushort #p.var_long = p.stc_long #p.var_ulong = p.stc_ulong #p.var_llong = p.stc_llong #p.var_ullong = p.stc_ullong #p.var_char = p.stc_char #p.var_pchar = sct_pchar #p.var_pcharc = sct_pcharc #p.var_pint = sct_pint #p.var_sizet = sct_sizet #p.var_hello = sct_hello #p.var_myint = sct_myint #p.var_namet = def_namet #p.var_parami = sct_parami #p.var_paramd = sct_paramd #p.var_paramc = sct_paramc # #p.v_check() $t->{var_bool} = $primitive_types::Test::stc_bool; $t->{var_schar} = $primitive_types::Test::stc_schar; $t->{var_uchar} = $primitive_types::Test::stc_uchar; $t->{var_int} = $primitive_types::Test::stc_int; $t->{var_uint} = $primitive_types::Test::stc_uint; $t->{var_short} = $primitive_types::Test::stc_short; $t->{var_ushort} = $primitive_types::Test::stc_ushort; $t->{var_long} = $primitive_types::Test::stc_long; $t->{var_ulong} = $primitive_types::Test::stc_ulong; $t->{var_llong} = $primitive_types::Test::stc_llong; $t->{var_ullong} = $primitive_types::Test::stc_ullong; $t->{var_char} = $primitive_types::Test::stc_char; $t->{var_pchar} = $primitive_types::sct_pchar; $t->{var_pcharc} = $primitive_types::sct_pcharc; $t->{var_pint} = $primitive_types::sct_pint; $t->{var_sizet} = $primitive_types::sct_sizet; $t->{var_hello} = $primitive_types::sct_hello; $t->{var_myint} = $primitive_types::sct_myint; $t->{var_namet} = $primitive_types::def_namet; $t->{var_parami} = $primitive_types::sct_parami; $t->{var_paramd} = $primitive_types::sct_paramd; $t->{var_paramc} = $primitive_types::sct_paramc; ok($t->v_check(), 'v_check'); is($primitive_types::def_namet, "hola", "namet"); $t->{var_namet} = $primitive_types::def_namet; is($t->{var_namet}, $primitive_types::def_namet, "namet"); $t->{var_namet} = 'hola'; is($t->{var_namet}, 'hola', "namet"); $t->{var_namet} = 'hol'; is($t->{var_namet}, 'hol', "namet"); $primitive_types::var_char = "\0"; is($primitive_types::var_char, "\0", "char '0' case"); $primitive_types::var_char = 0; is($primitive_types::var_char, "\0", "char '0' case"); $primitive_types::var_namet = "\0"; is($primitive_types::var_namet, '', "char '\\0' case"); $primitive_types::var_namet = ''; is($primitive_types::var_namet, '', "char empty case"); $primitive_types::var_pchar = undef; is($primitive_types::var_pchar, undef, "undef case"); $primitive_types::var_pchar = ''; is($primitive_types::var_pchar, '', "char empty case"); $primitive_types::var_pcharc = undef; is($primitive_types::var_pcharc, undef, "undef case"); $primitive_types::var_pcharc = ''; is($primitive_types::var_pcharc, '', "char empty case"); # # creating a raw char* # my $pc = primitive_types::new_pchar(5); primitive_types::pchar_setitem($pc, 0, 'h'); primitive_types::pchar_setitem($pc, 1, 'o'); primitive_types::pchar_setitem($pc, 2, 'l'); primitive_types::pchar_setitem($pc, 3, 'a'); primitive_types::pchar_setitem($pc, 4, 0); $primitive_types::var_pchar = $pc; is($primitive_types::var_pchar, "hola", "pointer case"); $primitive_types::var_namet = $pc; is($primitive_types::var_namet, "hola", "pointer case"); primitive_types::delete_pchar($pc); # # Now when things should fail # { my $orig = $t->{var_uchar}; eval { $t->{var_uchar} = 10000 }; like($@, qr/\bOverflowError\b/, "uchar typemap"); is($orig, $t->{var_uchar}, "uchar typemap"); } { my $orig = $t->{var_char}; #eval { $t->{var_char} = "23" }; Perl will gladly make a number out of that eval { $t->{var_char} = "twenty-three" }; like($@, qr/\bTypeError\b/, "char typemap"); is($orig, $t->{var_char}, "char typemap"); } { my $orig = $t->{var_uint}; eval { $t->{var_uint} = -1 }; like($@, qr/\bOverflowError\b/, "uint typemap"); is($orig, $t->{var_uint}, "uint typemap"); } { my $orig = $t->{var_namet}; eval { $t->{var_namet} = '123456' }; like($@, qr/\bTypeError\b/, "namet typemap"); is($orig, $t->{var_namet}, "namet typemap"); } #t2 = p.vtest(t) #if t.var_namet != t2.var_namet: # raise RuntimeError, "bad SWIGTYPE* typemap" is($primitive_types::fixsize, "ho\0la\0\0\0", "FIXSIZE typemap"); $primitive_types::fixsize = 'ho'; is($primitive_types::fixsize, "ho\0\0\0\0\0\0", "FIXSIZE typemap"); my $f = primitive_types::Foo->new(3); my $f1 = primitive_types::fptr_val($f); my $f2 = primitive_types::fptr_ref($f); is($f1->{_a}, $f2->{_a}, "const ptr& typemap"); is(primitive_types::char_foo(1,3), 3, "int typemap"); is(primitive_types::char_foo(1,"hello"), "hello", "char* typemap"); is(primitive_types::SetPos(1,3), 4, "int typemap"); swig-3.0.2/Examples/test-suite/perl5/default_args_runme.pl0000664000175000017500000000565712343605122023476 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 40; BEGIN { use_ok('default_args') } require_ok('default_args'); my $true = 1; my $false = ''; is(default_args::anonymous(), 7771, "anonymous (1)"); is(default_args::anonymous(1234), 1234, "anonymous (2)"); is(default_args::booltest(), $true, "booltest (1)"); is(default_args::booltest($true), $true, "booltest (2)"); is(default_args::booltest($false), $false, "booltest (3)"); my $ec = new default_args::EnumClass(); is($ec->blah(), $true, "EnumClass"); is(default_args::casts1(), undef, "casts1"); is(default_args::casts2(), "Hello", "casts2"); is(default_args::casts1("Ciao"), "Ciao", "casts1 not default"); is(default_args::chartest1(), 'x', "chartest1"); is(default_args::chartest2(), "\0", "chartest2"); is(default_args::chartest1('y'), 'y', "chartest1 not default"); is(default_args::reftest1(), 42, "reftest1"); is(default_args::reftest1(400), 400, "reftest1 not default"); is(default_args::reftest2(), "hello", "reftest2"); # rename my $foo = new default_args::Foo(); can_ok($foo, qw(newname renamed3arg renamed2arg renamed1arg)); eval { $foo->newname(); $foo->newname(10); $foo->renamed3arg(10, 10.0); $foo->renamed2arg(10); $foo->renamed1arg(); }; ok(not($@), '%rename handling'); # exception specifications eval { default_args::exceptionspec() }; like($@, qr/^ciao/, "exceptionspec 1"); eval { default_args::exceptionspec(-1) }; like($@, qr/^ciao/, "exceptionspec 2"); eval { default_args::exceptionspec(100) }; like($@, qr/^100/, "exceptionspec 3"); my $ex = new default_args::Except($false); my $hit = 0; eval { $ex->exspec(); $hit = 1; }; # a zero was thrown, an exception occurred, but $@ is false is($hit, 0, "exspec 1"); eval { $ex->exspec(-1) }; like($@, qr/^ciao/, "exspec 2"); eval { $ex->exspec(100) }; like($@, qr/^100/, "exspec 3"); eval { $ex = default_args::Except->new($true) }; like($@, qr/-1/, "Except constructor 1"); eval { $ex = default_args::Except->new($true, -2) }; like($@, qr/-2/, "Except constructor 2"); #Default parameters in static class methods is(default_args::Statics::staticmethod(), 60, "staticmethod 1"); is(default_args::Statics::staticmethod(100), 150, "staticmethod 2"); is(default_args::Statics::staticmethod(100,200,300), 600, "staticmethod 3"); my $tricky = new default_args::Tricky(); is($tricky->privatedefault(), 200, "privatedefault"); is($tricky->protectedint(), 2000, "protectedint"); is($tricky->protecteddouble(), 987.654, "protecteddouble"); is($tricky->functiondefault(), 500, "functiondefault"); is($tricky->contrived(), 'X', "contrived"); is(default_args::constructorcall()->{val}, -1, "constructorcall test 1"); is(default_args::constructorcall(new default_args::Klass(2222))->{val}, 2222, "constructorcall test 2"); is(default_args::constructorcall(new default_args::Klass())->{val}, -1, "constructorcall test 3"); # const methods my $cm = new default_args::ConstMethods(); is($cm->coo(), 20, "coo test 1"); is($cm->coo(1.0), 20, "coo test 2"); swig-3.0.2/Examples/test-suite/perl5/char_binary_runme.pl0000664000175000017500000000136212343605122023304 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 7; BEGIN { use_ok('char_binary') } require_ok('char_binary'); my $t = char_binary::Test->new(); is($t->strlen('hile'), 4, "string typemap"); is($t->strlen("hil\0"), 4, "string typemap"); # # creating a raw char* # my $pc = char_binary::new_pchar(5); char_binary::pchar_setitem($pc, 0, 'h'); char_binary::pchar_setitem($pc, 1, 'o'); char_binary::pchar_setitem($pc, 2, 'l'); char_binary::pchar_setitem($pc, 3, 'a'); char_binary::pchar_setitem($pc, 4, 0); is($t->strlen($pc), 4, "string typemap"); $char_binary::var_pchar = $pc; is($char_binary::var_pchar, "hola", "pointer case"); $char_binary::var_namet = $pc; is($char_binary::var_namet, "hola", "pointer case"); char_binary::delete_pchar($pc); swig-3.0.2/Examples/test-suite/perl5/enum_template_runme.pl0000664000175000017500000000040212343605122023654 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 4; BEGIN { use_ok('enum_template') } require_ok('enum_template'); # adapted from ../python/enum_template_runme.py is(enum_template::MakeETest(), 1); is(enum_template::TakeETest(0), undef); swig-3.0.2/Examples/test-suite/perl5/Makefile.in0000664000175000017500000000257112343605122021330 0ustar williamwilliam####################################################################### # Makefile for perl5 test-suite ####################################################################### LANGUAGE = perl5 PERL = @PERL@ SCRIPTSUFFIX = _runme.pl TEST_RUNNER = $(srcdir)/run-perl-test.pl srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ primitive_types \ li_cdata \ li_cstring \ li_cdata_carrays \ li_reference \ C_TEST_CASES += \ li_cdata \ li_cstring \ li_cdata_carrays \ include $(srcdir)/../common.mk # Overridden variables here # none! # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.pl appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PERL) $(TEST_RUNNER) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: remove the generated .pm file %.clean: @rm -f $*.pm; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" perl5_clean swig-3.0.2/Examples/test-suite/perl5/reference_global_vars_runme.pl0000664000175000017500000000465512343605122025344 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 19; BEGIN { use_ok('reference_global_vars') } require_ok('reference_global_vars'); # adapted from ../python/reference_global_vars_runme.py my $cvar; { # don't try this at home kids... sneaking an import of all symbols # from reference_global_vars to main because my fingers are getting # sore from qualifying all these names. ;) my $cvar = *reference_global_vars::; map { ${*::}{$_} = ${$cvar}{$_} } keys %{$cvar}; } is(getconstTC()->{num}, 33); # primitive reference variables $cvar->{var_bool} = createref_bool(0); is(value_bool($cvar->{var_bool}), ''); $cvar->{var_bool} = createref_bool(1); is(value_bool($cvar->{var_bool}), 1); $cvar->{var_char} = createref_char('w'); is(value_char($cvar->{var_char}), 'w'); $cvar->{var_unsigned_char} = createref_unsigned_char(10); is(value_unsigned_char($cvar->{var_unsigned_char}), 10); $cvar->{var_signed_char} = createref_signed_char(10); is(value_signed_char($cvar->{var_signed_char}), 10); $cvar->{var_short} = createref_short(10); is(value_short($cvar->{var_short}), 10); $cvar->{var_unsigned_short} = createref_unsigned_short(10); is(value_unsigned_short($cvar->{var_unsigned_short}), 10); $cvar->{var_int} = createref_int(10); is(value_int($cvar->{var_int}), 10); $cvar->{var_unsigned_int} = createref_unsigned_int(10); is(value_unsigned_int($cvar->{var_unsigned_int}), 10); $cvar->{var_long} = createref_long(10); is(value_long($cvar->{var_long}), 10); $cvar->{var_unsigned_long} = createref_unsigned_long(10); is(value_unsigned_long($cvar->{var_unsigned_long}), 10); SKIP: { use Math::BigInt qw(); skip "64 bit int support", 1 unless eval { pack 'q', 1 }; # the pack dance is to get plain old IVs out of the # Math::BigInt objects. my $a = unpack 'q', pack 'q', Math::BigInt->new('8070450532247928824'); $cvar->{var_long_long} = createref_long_long($a); is(value_long_long($cvar->{var_long_long}), $a); } #ull = abs(0xFFFFFFF2FFFFFFF0) my $ull = 55834574864; $cvar->{var_unsigned_long_long} = createref_unsigned_long_long($ull); is(value_unsigned_long_long($cvar->{var_unsigned_long_long}), $ull); $cvar->{var_float} = createref_float(10.5); is(value_float($cvar->{var_float}), 10.5); $cvar->{var_double} = createref_double(10.5); is(value_double($cvar->{var_double}), 10.5); # class reference variable $cvar->{var_TestClass} = createref_TestClass( TestClass->new(20) ); is(value_TestClass($cvar->{var_TestClass})->{num}, 20); swig-3.0.2/Examples/test-suite/perl5/director_wombat_runme.pl0000664000175000017500000000312012343605122024201 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 9; BEGIN { use_ok 'director_wombat' } require_ok 'director_wombat'; { package director_wombat_Foo_integers_derived; use base 'director_wombat::Foo_integers'; sub meth { my($self, $param) = @_; return $param + 2; } } { package director_wombat_Foo_integers_derived_2; use base 'director_wombat::Foo_integers'; } { package director_wombat_Bar_derived_1; use base 'director_wombat::Bar'; sub foo_meth_ref { my($self, $foo_obj, $param) = @_; die "foo_obj in foo_meth_ref is not director_wombat_Foo_integers_derived_2" unless $foo_obj->isa('director_wombat_Foo_integers_derived_2'); } sub foo_meth_ptr { my($self, $foo_obj, $param) = @_; die "foo_obj in foo_meth_ptr is not director_wombat_Foo_integers_derived_2" unless $foo_obj->isa('director_wombat_Foo_integers_derived_2'); } sub foo_meth_val { my($self, $foo_obj, $param) = @_; die "foo_obj in foo_meth_val is not director_wombat_Foo_integers_derived_2" unless $foo_obj->isa('director_wombat_Foo_integers_derived_2'); } } my $b = director_wombat::Bar->new(); isa_ok $b, 'director_wombat::Bar'; my $a = $b->meth(); is $a->meth(49), 49; $a = director_wombat_Foo_integers_derived->new(); isa_ok $a, 'director_wombat_Foo_integers_derived'; is $a->meth(62), 62 + 2; $a = director_wombat_Foo_integers_derived_2->new(); isa_ok $a, 'director_wombat_Foo_integers_derived_2'; is $a->meth(37), 37; $b = director_wombat_Bar_derived_1->new(); isa_ok $b, 'director_wombat_Bar_derived_1'; $b->foo_meth_ref($a, 0); $b->foo_meth_ptr($a, 1); $b->foo_meth_val($a, 2); swig-3.0.2/Examples/test-suite/perl5/profiletest_runme.pl0000664000175000017500000000022412343605122023357 0ustar williamwilliamuse profiletest; $a = profiletestc::new_A(); $b = profiletestc::new_B(); for ($i = 0; $i < 100000; $i++) { $a = profiletestc::B_fn($b, $a); } swig-3.0.2/Examples/test-suite/perl5/sizet_runme.pl0000664000175000017500000000056412343605122022164 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 6; BEGIN { use_ok('sizet') } require_ok('sizet'); # adapted from ../java/sizet_runme.java my $s = 2000; $s = sizet::test1($s + 1); is($s, 2001, 'test1'); $s = sizet::test1($s + 1); is($s, 2002, 'test2'); $s = sizet::test1($s + 1); is($s, 2003, 'test3'); $s = sizet::test1($s + 1); is($s, 2004, 'test4'); swig-3.0.2/Examples/test-suite/perl5/global_vars_runme.pl0000664000175000017500000000037412343605122023320 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 4; BEGIN { use_ok('global_vars') } require_ok('global_vars'); my $an = new global_vars::A(); isa_ok($an, 'global_vars::A'); $global_vars::ap = $an; is($global_vars::ap, $an, "global var assignment"); swig-3.0.2/Examples/test-suite/perl5/director_enum_runme.pl0000664000175000017500000000063712343605122023666 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 5; BEGIN { use_ok 'director_enum' } require_ok 'director_enum'; { package MyFoo; use base 'director_enum::Foo'; sub say_hi { my($self, $val) = @_; return $val; } } my $b = director_enum::Foo->new(); isa_ok $b, 'director_enum::Foo'; my $a = MyFoo->new(); isa_ok $a, 'MyFoo'; is $a->say_hi($director_enum::hello), $a->say_hello($director_enum::hi); swig-3.0.2/Examples/test-suite/perl5/preproc_runme.pl0000664000175000017500000000042612343605122022475 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 6; BEGIN { use_ok('preproc') } require_ok('preproc'); # adapted from ../python/preproc_runme.py is($preproc::endif, 1); is($preproc::define, 1); is($preproc::defined, 1); is($preproc::one * 2, $preproc::two); swig-3.0.2/Examples/test-suite/perl5/virtual_poly_runme.pl0000664000175000017500000000124012343605122023547 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 8; BEGIN { use_ok('virtual_poly') } require_ok('virtual_poly'); my $d = virtual_poly::NDouble->new(3.5); my $i = virtual_poly::NInt->new(2); # # the copy methods return the right polymorphic types # my $dc = $d->copy(); my $ic = $i->copy(); is($d->get(), $dc->get()); is($i->get(), $ic->get()); virtual_poly::incr($ic); is($i->get() + 1, $ic->get()); my $dr = $d->ref_this(); is($d->get(), $dr->get()); # # 'narrowing' also works # my $ddc = virtual_poly::NDouble::narrow($d->nnumber()); is($d->get, $ddc->get()); my $dic = virtual_poly::NInt::narrow($i->nnumber()); is($i->get(), $dic->get()); swig-3.0.2/Examples/test-suite/perl5/director_string_runme.pl0000664000175000017500000000132212343605122024220 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 5; BEGIN { use_ok 'director_string' } require_ok 'director_string'; { package B; use base 'director_string::A'; our $in_first = 0; sub get_first { my($self) = @_; die "SUPER RESOLVE BAD" if $in_first; local $in_first = 1; return $self->SUPER::get_first() . " world!"; } our $in_process_text = 0; sub process_text { my($self, $string) = @_; die "SUPER RESOLVE BAD" if $in_process_text; local $in_process_text = 1; $self->SUPER::process_text($string); $self->{'smem'} = "hello"; } } my $b = B->new("hello"); isa_ok $b, 'B'; $b->get(0); is $b->get_first(), "hello world!"; $b->call_process_func(); is $b->{'smem'}, "hello"; swig-3.0.2/Examples/test-suite/perl5/li_typemaps_runme.pl0000664000175000017500000000454212343605122023354 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 415; BEGIN { use_ok('li_typemaps') } require_ok('li_typemaps'); sub batch { my($type, @values) = @_; # this is a little ugly because I'm trying to be clever and save my # wrists from hammering out all these tests. for my $val (@values) { for my $tst (qw( in inr out outr inout inoutr )) { my $func = $tst . '_' . $type; is(eval { li_typemaps->can($func)->($val) }, $val, "$func $val"); if($@) { my $err = $@; $err =~ s/^/#\$\@# /mg; print $err; } } } } batch('bool', '', 1); # let's assume we're at least on a 32 bit machine batch('int', -0x80000000, -1, 0, 1, 12, 0x7fffffff); # long could be bigger, but it's at least this big batch('long', -0x80000000, -1, 0, 1, 12, 0x7fffffff); batch('short', -0x8000, -1, 0, 1, 12, 0x7fff); batch('uint', 0, 1, 12, 0xffffffff); batch('ushort', 0, 1, 12, 0xffff); batch('ulong', 0, 1, 12, 0xffffffff); batch('uchar', 0, 1, 12, 0xff); batch('schar', -0x80, 0, 1, 12, 0x7f); { use Math::BigInt qw(); # the pack dance is to get plain old NVs out of the # Math::BigInt objects. my $inf = unpack 'd', pack 'd', Math::BigInt->new('Inf'); my $nan = unpack 'd', pack 'd', Math::BigInt->new('NaN'); batch('float', -(2 - 2 ** -23) * 2 ** 127, -1, -2 ** -149, 0, 2 ** -149, 1, (2 - 2 ** -23) * 2 ** 127, $nan); { local $TODO = "float typemaps don't pass infinity"; # it seems as though SWIG is unwilling to pass infinity around # because that value always fails bounds checking. I think that # is a bug. batch('float', $inf); } batch('double', -(2 - 2 ** -53) ** 1023, -1, -2 ** -1074, 0, 2 ** 1074, (2 - 2 ** -53) ** 1023, $nan, $inf); } batch('longlong', -1, 0, 1, 12); batch('ulonglong', 0, 1, 12); SKIP: { use Math::BigInt qw(); skip "not a 64bit Perl", 18 unless eval { pack 'q', 1 }; my $a = unpack 'q', pack 'q', Math::BigInt->new('-9223372036854775808'); my $b = unpack 'q', pack 'q', Math::BigInt->new('9223372036854775807'); my $c = unpack 'Q', pack 'Q', Math::BigInt->new('18446744073709551615'); batch('longlong', $a, $b); batch('ulonglong', $c); } my($foo, $int) = li_typemaps::out_foo(10); isa_ok($foo, 'li_typemaps::Foo'); is($foo->{a}, 10); is($int, 20); my($a, $b) = li_typemaps::inoutr_int2(13, 31); is($a, 13); is($b, 31); swig-3.0.2/Examples/test-suite/perl5/director_exception_runme.pl0000664000175000017500000000237112343605122024715 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 7; BEGIN { use_ok 'director_exception' } require_ok 'director_exception'; { package MyFoo; use base 'director_exception::Foo'; sub ping { die "MyFoo::ping() EXCEPTION"; } } { package MyFoo2; use base 'director_exception::Foo'; sub ping { # error should return a string return bless [ 1 ], 'main'; } } { package MyFoo3; use base 'director_exception::Foo'; sub ping { # error should return a string return sub { 1 } } } { my $a = MyFoo->new(); my $b = director_exception::launder($a); eval { $b->pong() }; like($@, qr/\bMyFoo::ping\(\) EXCEPTION\b/, 'MyFoo.pong() error content preserved'); } { my $a = MyFoo2->new(); my $b = director_exception::launder($a); eval { $b->pong() }; like($@, qr/\bTypeError\b/, 'MyFoo2.pong() error content preserved'); } { my $a = MyFoo3->new(); my $b = director_exception::launder($a); eval { $b->pong() }; like($@, qr/\bTypeError\b/, 'MyFoo2.pong() error content preserved'); } eval { die director_exception::Exception1->new() }; isa_ok($@, 'director_exception::Exception1', 'Exception1'); eval { die director_exception::Exception2->new() }; isa_ok($@, 'director_exception::Exception2', 'Exception2'); swig-3.0.2/Examples/test-suite/perl5/dynamic_cast_runme.pl0000664000175000017500000000044712343605122023464 0ustar williamwilliam#!/usr/bin/perl use strict; use warnings; use Test::More tests => 3; BEGIN { use_ok('dynamic_cast') } require_ok('dynamic_cast'); my $f = dynamic_cast::Foo->new(); my $b = dynamic_cast::Bar->new(); my $x = $f->blah(); my $y = $b->blah(); my $a = dynamic_cast::do_test($y); is($a, "Bar::test"); swig-3.0.2/Examples/test-suite/perl5/primitive_ref_runme.pl0000664000175000017500000000130612343605122023665 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 14; BEGIN { use_ok('primitive_ref') } require_ok('primitive_ref'); is(primitive_ref::ref_int(3), 3, "ref_int"); is(primitive_ref::ref_uint(3), 3, "ref_uint"); is(primitive_ref::ref_short(3), 3, "ref_short"); is(primitive_ref::ref_ushort(3), 3, "ref_ushort"); is(primitive_ref::ref_long(3), 3, "ref_long"); is(primitive_ref::ref_ulong(3), 3, "ref_ulong"); is(primitive_ref::ref_schar(3), 3, "ref_schar"); is(primitive_ref::ref_uchar(3), 3, "ref_uchar"); is(primitive_ref::ref_bool(1), 1, "ref_bool"); is(primitive_ref::ref_float(3.5), 3.5, "ref_float"); is(primitive_ref::ref_double(3.5), 3.5, "ref_double"); is(primitive_ref::ref_char('x'), 'x', "ref_char"); swig-3.0.2/Examples/test-suite/perl5/li_cdata_carrays_runme.pl0000664000175000017500000000052612343605122024310 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 4; BEGIN { use_ok('li_cdata_carrays') } require_ok('li_cdata_carrays'); my $ia = li_cdata_carrays::intArray->new(5); for (0..4) { $ia->setitem($_, $_**2); } ok(1, "setitems"); my $x = pack q{I5}, map $_**2, (0..4); my $y = li_cdata_carrays::cdata_int($ia->cast, 5); is($x, $y, "carrays"); swig-3.0.2/Examples/test-suite/perl5/director_nested_runme.pl0000664000175000017500000000261412343605122024201 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 9; BEGIN { use_ok 'director_nested' } require_ok 'director_nested'; { package A; use base 'director_nested::FooBar_int'; sub do_step { 'A::do_step;' } sub get_value { 'A::get_value' } } my $a = A->new(); isa_ok $a, 'A'; is $a->step(), "Bar::step;Foo::advance;Bar::do_advance;A::do_step;", 'A virtual resolution'; { package B; use base 'director_nested::FooBar_int'; sub do_advance { my($self) = @_; return "B::do_advance;" . $self->do_step(); } sub do_step { "B::do_step;" } sub get_value { 1 } } my $b = B->new(); isa_ok $b, 'B'; is $b->step(), "Bar::step;Foo::advance;B::do_advance;B::do_step;", 'B virtual resolution'; { package C; use base 'director_nested::FooBar_int'; our $in_do_advance = 0; sub do_advance { my($self) = @_; # found a case where upcall didn't happen right in a perl space # SUPER:: call. die "SUPERCALL RESOLVE FAILURE" if $in_do_advance; local $in_do_advance = 1; return "C::do_advance;" . $self->SUPER::do_advance(); } sub do_step { "C::do_step;" } sub get_value { 2 } sub get_name { my($self) = @_; return $self->director_nested::FooBar_int::get_name() . " hello"; } } my $cc = C->new(); isa_ok $cc, 'C'; my $c = director_nested::FooBar_int::get_self($cc); $c->advance(); is $c->get_name(), "FooBar::get_name hello"; is $c->name(), "FooBar::get_name hello"; swig-3.0.2/Examples/test-suite/perl5/li_reference_runme.pl0000664000175000017500000000273412343605122023451 0ustar williamwilliamuse strict; use warnings; use Test::More tests => 68; BEGIN { use_ok('li_reference') } require_ok('li_reference'); sub chk { my($type, $call, $v1, $v2) = @_; $li_reference::FrVal = $v1; my $v = $v2; eval { $call->(\$v) }; is($@, '', "$type check"); is($li_reference::ToVal, $v2, "$type out"); is($v, $v1, "$type in"); } chk("double*", \&li_reference::PDouble, 12.2, 18.6); chk("double&", \&li_reference::RDouble, 32.5, 64.8); chk("float*", \&li_reference::PFloat, 64.5, 96.0); chk("float&", \&li_reference::RFloat, 98.5, 6.25); chk("int*", \&li_reference::PInt, 1887, 3356); chk("int&", \&li_reference::RInt, 2622, 9867); chk("short*", \&li_reference::PShort, 4752, 3254); chk("short&", \&li_reference::RShort, 1898, 5757); chk("long*", \&li_reference::PLong, 6687, 7132); chk("long&", \&li_reference::RLong, 8346, 4398); chk("uint*", \&li_reference::PUInt, 6853, 5529); chk("uint&", \&li_reference::RUInt, 5483, 7135); chk("ushort*", \&li_reference::PUShort, 9960, 9930); chk("ushort&", \&li_reference::RUShort, 1193, 4178); chk("ulong*", \&li_reference::PULong, 7960, 4788); chk("ulong&", \&li_reference::RULong, 8829, 1603); chk("uchar*", \&li_reference::PUChar, 110, 239); chk("uchar&", \&li_reference::RUChar, 15, 97); chk("char*", \&li_reference::PChar, -7, 118); chk("char&", \&li_reference::RChar, -3, -107); chk("bool*", \&li_reference::PBool, 0, 1); chk("bool&", \&li_reference::RBool, 1, 0); swig-3.0.2/Examples/test-suite/smart_pointer_templatemethods.i0000664000175000017500000000157112343605122024552 0ustar williamwilliam%module smart_pointer_templatemethods %inline %{ namespace ns { template class Ptr { public: Ptr () {} T *operator -> () { return 0; } }; typedef unsigned short uint16_t; class InterfaceId { public: InterfaceId (uint16_t iid) {} InterfaceId() {} }; template class Objekt { public: Objekt () {} virtual ~Objekt () {} Ptr QueryInterface (InterfaceId iid) const { return Ptr(); } void DisposeObjekt (void) {} }; class Objct { public: Objct () {} virtual ~Objct () {} template Ptr QueryInterface (InterfaceId iid) const { return Ptr(); } void DisposeObjct (void) {} }; #ifdef SWIG %template(PtrObjct) Ptr; %template(PtrInt) Ptr; %template(ObjektInt) Objekt; %template(PtrObjektInt) Ptr >; %template(QueryInterfaceObjct) Objct::QueryInterface; #endif } // namespace %} swig-3.0.2/Examples/test-suite/global_vars.i0000664000175000017500000000070112343605122020672 0ustar williamwilliam%module global_vars %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */ %include std_string.i %inline %{ struct A { int x; }; std::string b; A a; A *ap; const A *cap; A &ar = a; int x; int *xp; int& c_member = x; void *vp; enum Hello { Hi, Hola }; Hello h; Hello *hp; Hello &hr = h; void init() { b = "string b"; x = 1234; } %} swig-3.0.2/Examples/test-suite/template_const_ref.i0000664000175000017500000000035612343605122022262 0ustar williamwilliam%module template_const_ref %inline %{ template class Foo { public: char *bar(const T &obj) { return (char *) "Foo::bar"; } }; class Bar { }; %} %template(Foob) Foo; %template(Fooi) Foo; swig-3.0.2/Examples/test-suite/cpp11_template_typedefs.i0000664000175000017500000000142312343605122023123 0ustar williamwilliam/* This testcase checks whether SWIG correctly parses alias templates. */ %module cpp11_template_typedefs %warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName; %warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) MyIntKeyClass; %warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) PF; %inline %{ template< typename T1, typename T2, int > class SomeType { T1 a; T2 b; int c; }; // template aliasing template< typename T2 > using TypedefName = SomeType; // type aliasing typedef void (*PFD)(double); // Old style using PF = void (*)(double); // New introduced syntax // use of template aliasing template class MyCPP11Class { }; template using MyIntKeyClass = MyCPP11Class; MyIntKeyClass intchar; %} swig-3.0.2/Examples/test-suite/input.i0000664000175000017500000000127112343605122017541 0ustar williamwilliam%module input %apply int *INPUT {int *bar}; %typemap(out, fragment=SWIG_From_frag(int)) int *foo { if ($1) { $result = SWIG_From(int)(*$1); } else { $result = SWIG_Py_Void(); } } %inline { struct Foo { int *foo(int *bar = 0) { if (bar) { *bar *= 2; } return (bar) ? bar : 0; } }; } %include std_string.i %apply std::string *INPUT {std::string *bar}; %typemap(out, fragment=SWIG_From_frag(std::string)) std::string *sfoo { if ($1) { $result = SWIG_From(std::string)(*$1); } else { $result = SWIG_Py_Void(); } } %inline %{ std::string *sfoo(std::string *bar = 0) { if (bar) *bar += " world"; return (bar) ? bar : 0; } %} swig-3.0.2/Examples/test-suite/java_pgcpp.i0000664000175000017500000000354412343605122020521 0ustar williamwilliam// Test the premature garbage collection prevention parameter (pgcpp) for the different ways of passing objects %module java_pgcpp %pragma(java) jniclassclassmodifiers="public class" %typemap(javacode) Space::Classic %{ public long getCPtrValue() { return this.swigCPtr; } %} // Default pointer to pointer typemaps do not use proxy class, so make sure that the pgcpp is generated for these typemaps %typemap(jni) Space::Classic ** "jlong" %typemap(jtype) Space::Classic ** "long" %typemap(jstype) Space::Classic ** " Classic " %typemap(javain) Space::Classic ** "Classic.getCPtr($javainput)" // Default typemaps for pass by value, ref, pointer and pointer const reference should use pgcpp %inline %{ namespace Space { struct Classic { Classic() {} Classic(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {} Classic(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5, bool b) {} void method(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {} void methodconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {} }; void function(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {} void functionconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {} } %} %typemap(jtype) Klassic *k1 "/*a*/ long /*b*/ /*c*/" %typemap(jstype) Klassic *k1 "/*a*/ Classic/*b*/ /*c*/" %typemap(jtype) Klassic *k2 "/*d*/ long" %typemap(jstype) Klassic *k2 "/*d*/ Classic" %typemap(jtype) Klassic *k3 "long/*e*/ " %typemap(jstype) Klassic *k3 "Classic/*e*/ " %typemap(javain) Klassic * "Classic.getCPtr($javainput)" %{ typedef Space::Classic Klassic; %} %inline %{ void comment_in_typemaps(Klassic *k1, Klassic *k2, Klassic *k3) {} %} swig-3.0.2/Examples/test-suite/packageoption_b.i0000664000175000017500000000017012343605122021524 0ustar williamwilliam%module(package="CommonPackage") "packageoption_b"; %inline %{ class B { public: int testInt() { return 4; } }; %} swig-3.0.2/Examples/test-suite/php_namewarn_rename.i0000664000175000017500000000111612343605122022406 0ustar williamwilliam%module php_namewarn_rename #ifdef SWIGPHP %warnfilter(SWIGWARN_PARSE_KEYWORD) Empty(); %warnfilter(SWIGWARN_PARSE_KEYWORD) stdClass; %warnfilter(SWIGWARN_PARSE_KEYWORD) directory; %warnfilter(SWIGWARN_PARSE_KEYWORD) Hello::empty(); #endif %ignore prev::operator++; %extend prev { void next() { ++(*self); } } %inline %{ int Exception() { return 13; } void Empty() {} class stdClass { }; class directory { }; struct Hello { void empty() {} }; struct prev { prev & operator++() { return *this; } prev operator++(int) { return *this; } }; %} swig-3.0.2/Examples/test-suite/cpp11_function_objects.i0000664000175000017500000000131612343605122022744 0ustar williamwilliam/* This testcase checks whether SWIG correctly parses function objects and the templates for the functions (signature). Function objects are objects which overload the operator() function. The std::function does not provide any seamless support in the target languages yet. */ %module cpp11_function_objects %rename(__call__) Test::operator(); %inline %{ struct Test { int value; void operator()(int x, int y) { value=x+y; } Test() : value(0) {} } test; #include std::function pF = test; int testit1(Test new_test, int a, int b) { pF = new_test; pF(a, b); return new_test.value; } int testit2(int a, int b) { test(a, b); return test.value; } %} swig-3.0.2/Examples/test-suite/overload_return_type.i0000664000175000017500000000065412343605122022661 0ustar williamwilliam%module overload_return_type // Regression test for PHP from SF#3168531 (SWIG <= 2.0.1 segfaults). %inline %{ class A { }; class B { public: int foo(int x) { return 0; } A foo(const char * y) { return A(); } }; // Regression test for PHP from SF#3208299 (there bar()'s return type wa // treated as always void). void foo(int i) {} int foo() { return 1; } int bar() { return 1; } void bar(int i) {} %} swig-3.0.2/Examples/test-suite/constructor_explicit.i0000664000175000017500000000044412343605122022671 0ustar williamwilliam/* Swig 1.3.6 fails to understand the "explicit" keyword. SF Bug #445233, reported by Krzysztof Kozminski . */ %module constructor_explicit %inline %{ class Foo { public: explicit Foo() { } explicit Foo(int) {}; }; Foo test(Foo x) { return x; } %} swig-3.0.2/Examples/test-suite/member_funcptr_galore.i0000664000175000017500000000717312343605122022752 0ustar williamwilliam%module member_funcptr_galore %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */ #pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */ #pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */ #endif %} %inline %{ namespace FunkSpace { struct Funktions { int addByValue(const int &a, int b) { return a+b; } int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; } int & addByReference(const int &a, int b) { static int val; val = a+b; return val; } }; } template struct Thing {}; namespace Space { class Shape { public: double x, y; double *z; void move(double dx, double dy); virtual double area(Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)) { return 0.0; } virtual double abc(Thing ts, Thing< const Space::Shape * > tda[]) { return 0.0; } }; } extern double do_op(Space::Shape *s, double (Space::Shape::*m)(void)); /* Functions that return member pointers */ extern double (Space::Shape::*areapt())(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)); extern double (Space::Shape::*abcpt())(Thing, Thing< const Space::Shape * > tda[]); /* Global variables that are member pointers */ extern double (Space::Shape::*areavar)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)); extern double (Space::Shape::*abcvar)(Thing, Thing< const Space::Shape * >[]); %} %{ void Space::Shape::move(double dx, double dy) { x += dx; y += dy; } double do_op(Space::Shape *s, double (Space::Shape::*m)(void)) { return (s->*m)(); } double (Space::Shape::*areapt(Space::Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)))(Space::Shape &, int & (FunkSpace::Funktions::*d)(const int &, int)) { return &Space::Shape::area; } double (Space::Shape::*areapt())(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) { return 0; } double (Space::Shape::*abcpt())(Thing, Thing< const Space::Shape * >[]) { return &Space::Shape::abc; } /* Member pointer variables */ double (Space::Shape::*areavar)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) = &Space::Shape::area; double (Space::Shape::*abcvar)(Thing, Thing< const Space::Shape * >[]) = &Space::Shape::abc; %} /* Some constants */ %constant double (Space::Shape::*AREAPT)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) = &Space::Shape::area; %constant double (Space::Shape::*PERIMPT)(Thing, Thing< const Space::Shape * >[]) = &Space::Shape::abc; %constant double (Space::Shape::*NULLPT)(void) = 0; %inline %{ int call1(int (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { FunkSpace::Funktions f; return (f.*d)(a, b); } int call2(int * (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { FunkSpace::Funktions f; return *(f.*d)(a, b); } int call3(int & (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { FunkSpace::Funktions f; return (f.*d)(a, b); } %} %constant int (FunkSpace::Funktions::*ADD_BY_VALUE)(const int &, int) = &FunkSpace::Funktions::addByValue; %constant int * (FunkSpace::Funktions::*ADD_BY_POINTER)(const int &, int) = &FunkSpace::Funktions::addByPointer; %constant int & (FunkSpace::Funktions::*ADD_BY_REFERENCE)(const int &, int) = &FunkSpace::Funktions::addByReference; %inline %{ // parameter that is a member pointer containing a function ptr, urgh :) int unreal1(double (Space::Shape::*memptr)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int))) { return 0; } int unreal2(double (Space::Shape::*memptr)(Thing)) { return 0; } %} swig-3.0.2/Examples/test-suite/using_namespace.i0000664000175000017500000000256212343605122021547 0ustar williamwilliam%module(ruby_minherit="1") using_namespace %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi::hi0; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi::hi1; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) Hi; // C#, D, Java, PHP multiple inheritance %inline %{ namespace hello { struct Hello { }; template struct Hi : _T1, _T2 { int value1() const { return 1; } int value2() const { return 2; } }; } namespace hi { struct hi0 { }; } %} namespace hello { %template(Hi_hi0) Hi; } %inline %{ namespace hi { struct hi1 : private hello::Hi< hello::Hello, hi0 > { using hello::Hi< hello::Hello, hi::hi0 >::value1; using hello::Hi< hello::Hello, hi0 >::value2; }; } %} %inline { namespace foo { typedef double mytype; } // global namespace typedef float mytype; using namespace foo; struct X { ::mytype d; }; } %inline %{ namespace SpaceMan { typedef double SpaceManDouble; } using namespace ::SpaceMan; // global namespace prefix SpaceManDouble useSpaceMan(SpaceManDouble s) { return s; } %} swig-3.0.2/Examples/test-suite/newobject2.i0000664000175000017500000000125712343605122020450 0ustar williamwilliam/** * The purpose of this test is to confirm that a language module * correctly handles the case when a C function has been tagged with the * %newobject directive. */ %module newobject2 %{ #include %} %{ /* Global initialization (not wrapped) */ int g_fooCount = 0; %} %newobject makeFoo(); %inline %{ /* Struct definition */ typedef struct { int dummy; } Foo; /* Make one */ Foo *makeFoo() { Foo *foo = (Foo *) malloc(sizeof(Foo)); g_fooCount++; return foo; } /* Return the number of instances */ int fooCount() { return g_fooCount; } void do_stuff(Foo *f) { } %} %extend Foo { ~Foo() { free((void *) $self); g_fooCount--; } } swig-3.0.2/Examples/test-suite/bom_utf8.i0000664000175000017500000000015612343605122020126 0ustar williamwilliam%module bom_utf8 /* Test for UTF8 BOM at start of file */ %inline %{ struct NotALotHere { int n; }; %} swig-3.0.2/Examples/test-suite/cpp11_userdefined_literals.i0000664000175000017500000000434612343605122023610 0ustar williamwilliam/* This testcase checks whether SWIG correctly parses the user-defined literals introduced in C++11. */ %module cpp11_userdefined_literals // Unfortunately full declaration is needed for %rename atm, the parameter list cannot be omitted. %rename(MyRawLiteral) operator"" _myRawLiteral(const char * value); %rename(MySuffixIntegral) operator "" _mySuffixIntegral(unsigned long long); %rename(MySuffixFloat) operator "" _mySuffixFloat(long double); %rename(MySuffix1) operator "" _mySuffix1(const char * string_values, size_t num_chars); %rename(MySuffix2) operator "" _mySuffix2(const wchar_t * string_values, size_t num_chars); %rename(MySuffix3) operator "" _mySuffix3(const char16_t * string_values, size_t num_chars); %rename(MySuffix4) operator "" _mySuffix4(const char32_t * string_values, size_t num_chars); %ignore operator "" _myRawLiteralIgnored(const char * value); %inline %{ #include struct OutputType { int val; OutputType(int v) : val(v) {} }; // Raw literal OutputType operator "" _myRawLiteral(const char * value) { return OutputType(10); } // Cooked numeric literals OutputType operator "" _mySuffixIntegral(unsigned long long) { return OutputType(20); } OutputType operator "" _mySuffixFloat(long double) { return OutputType(30); } // Cooked string literals OutputType operator "" _mySuffix1(const char * string_values, size_t num_chars) { return OutputType(100); } OutputType operator "" _mySuffix2(const wchar_t * string_values, size_t num_chars) { return OutputType(200); } OutputType operator "" _mySuffix3(const char16_t * string_values, size_t num_chars) { return OutputType(300); } OutputType operator "" _mySuffix4(const char32_t * string_values, size_t num_chars) { return OutputType(400); } OutputType operator"" _myRawLiteralIgnored(const char * value) { return OutputType(15); } %} %{ // TODO: SWIG cannot parse these OutputType some_variable_a = 1234_myRawLiteral; OutputType some_variable_b = 1234_mySuffixIntegral; OutputType some_variable_c = 3.1416_mySuffixFloat; OutputType some_variable_d = "1234"_mySuffix1; OutputType some_variable_e = u8"1234"_mySuffix1; OutputType some_variable_f = L"1234"_mySuffix2; OutputType some_variable_g = u"1234"_mySuffix3; OutputType some_variable_h = U"1234"_mySuffix4; %} swig-3.0.2/Examples/test-suite/primitive_types.i0000664000175000017500000003067112343605122021644 0ustar williamwilliam// Massive primitive datatype test. %module(directors="1") primitive_types %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} // Ruby constant names #pragma SWIG nowarn=SWIGWARN_RUBY_WRONG_NAME // Using thread unsafe wrapping #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR /* if your language has problems with MyInt* and/or Hello*, you need to change the constant reference typemaps from something like: %typemap(in) const char & (char temp), const signed char & (signed char temp), const unsigned char & (unsigned char temp), const short & (short temp), const unsigned short & (unsigned short temp), const int & (int temp), const unsigned int & (unsigned int temp), const long & (long temp), const unsigned long & (unsigned long temp), const long long & ($*1_ltype temp), const float & (float temp), const double & (double temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} to the following: %typemap(in) const char & ($basetype temp), const signed char & ($basetype temp), const unsigned char & ($basetype temp), const short & ($basetype temp), const unsigned short & ($basetype temp), const int & ($basetype temp), const unsigned int & ($basetype temp), const long & ($basetype temp), const unsigned long & ($basetype temp), const long long & ($basetype temp), const float & ($basetype temp), const double & ($basetype temp) %{ temp = ($basetype)$input; $1 = &temp; %} the other typical change is to add the enum SWIGTYPE to the integer throws typemaps: %typemap(throws) int, long, short, unsigned int, unsigned long, unsigned short, enum SWIGTYPE { Tcl_SetObjResult(interp, Tcl_NewIntObj((long) $1)); SWIG_fail; } or just add the %apply directive after all the typemaps declaration %apply int { enum SWIGTYPE }; Also note that this test should not only compile, if you run the program grep 'resultobj = SWIG_NewPointerObj' primitive_types_wrap.cxx you should get only two calls: resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Test, 1); resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_TestDirector, 1); if you get a lot more, some typemap could be not defined. The same with grep SWIG_ConvertPtr primitive_types_wrap.cxx| egrep -v 'Test' you should only get #define SWIG_ConvertPtr(obj, pp, type, flags) */ // // Try your language module with and without // these nowarn flags. // %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK); %{ #include #include #include %} %feature("director") TestDirector; %{ // Integer class, only visible in C++ struct MyInt { char name[5]; int val; MyInt(int v = 0): val(v) { } operator int() const { return val; } }; // Template primitive type, only visible in C++ template struct Param { char name[5]; T val; Param(T v = 0): val(v) { name[0] = 0; name[1] = 0; name[2] = 0; name[3] = 0; name[4] = 0; } operator T() const { return val; } }; typedef char namet[5]; extern namet gbl_namet; namet gbl_namet; %} // // adding applies for incomplete swig type MyInt // %apply int { MyInt }; %apply const int& { const MyInt& }; %apply int { Param }; %apply char { Param }; %apply float { Param }; %apply double { Param }; %apply const int& { const Param& }; %apply const char& { const Param& }; %apply const float& { const Param& }; %apply const double& { const Param& }; // // These applies shouldn't be needed ....!! // //%apply const int& { const Hello& }; %apply void* { pint }; %apply void* const& { const pint& }; // // Some simple types %apply char FIXSIZE[ANY] {char fixsize[8]}; %inline %{ enum Hello { Hi, Hola }; typedef char namet[5]; typedef char* pchar; typedef const char* pcharc; typedef char* pint; char* const def_pchar = (char *const)"hello"; const char* const def_pcharc = "hija"; const namet def_namet = {'h','o','l','a', 0}; extern namet gbl_namet; char fixsize[8] = {'h','o',0, 'l','a', 0, 0, 0}; %} /* all the primitive types */ #define def_bool 1 #define def_schar 1 #define def_uchar 1 #define def_int 1 #define def_uint 1 #define def_short 1 #define def_ushort 1 #define def_long 1 #define def_ulong 1 #define def_llong 1 #define def_ullong 1 #define def_float 1 #define def_double 1 #define def_char 'H' #define def_pint 0 #define def_sizet 1 #define def_hello Hola #define def_myint 1 #define def_parami 1 #define def_paramd 1 #define def_paramc 'c' /* types that can be declared as static const class members */ %define %test_prim_types_stc(macro, pfx) macro(bool, pfx, bool) macro(signed char, pfx, schar) macro(unsigned char, pfx, uchar) macro(int, pfx, int) macro(unsigned int, pfx, uint) macro(short, pfx, short) macro(unsigned short, pfx, ushort) macro(long, pfx, long) macro(unsigned long, pfx, ulong) macro(long long, pfx, llong) macro(unsigned long long, pfx, ullong) macro(char, pfx, char) %enddef /* types that can be used to test overloading */ %define %test_prim_types_ovr(macro, pfx) %test_prim_types_stc(macro, pfx) macro(pchar, pfx, pchar) %enddef /* all the types */ %define %test_prim_types(macro, pfx) %test_prim_types_ovr(macro, pfx) macro(pcharc, pfx, pcharc) macro(pint, pfx, pint) /* these ones should behave like primitive types too */ macro(Hello, pfx, hello) macro(MyInt, pfx, myint) macro(Param, pfx, parami) macro(Param, pfx, paramd) macro(Param, pfx, paramc) macro(size_t, pfx, sizet) %enddef /* function passing by value */ %define val_decl(type, pfx, name) type pfx##_##name(type x) throw (type) { return x; } %enddef /* function passing by ref */ %define ref_decl(type, pfx, name) const type& pfx##_##name(const type& x) throw (type) { return x; } %enddef /* C++ constant declaration */ %define cct_decl(type, pfx, name) const type pfx##_##name = def##_##name; %enddef /* C++ static constant declaration */ %define stc_decl(type, pfx, name) static const type pfx##_##name = def##_##name; %enddef /* Swig constant declaration */ %define sct_decl(type, pfx, name) %constant type pfx##_##name = def##_##name; %enddef /* variable delaration */ %define var_decl(type, pfx, name) type pfx##_##name; %enddef /* virtual function passing by value */ %define vval_decl(type, pfx, name) virtual val_decl(type, pfx, name) %enddef /* virtual function passing by ref */ %define vref_decl(type, pfx, name) virtual ref_decl(type, pfx, name) %enddef %test_prim_types(sct_decl, sct) %inline { %test_prim_types(val_decl, val) %test_prim_types(ref_decl, ref) %test_prim_types(cct_decl, cct) %test_prim_types(var_decl, var) var_decl(namet, var, namet) void var_init() { var_pchar = 0; var_pcharc = 0; var_pint = 0; var_namet[0] = 'h'; } } /* check variables */ %define var_check(type, pfx, name) if (pfx##_##name != def_##name) { std::ostringstream a; std::ostringstream b; a << pfx##_##name; b << def_##name; if (a.str() != b.str()) { std::cout << "failing in pfx""_""name : " << a.str() << " : " << b.str() << std::endl; // return 0; } } %enddef /* check a function call */ %define call_check(type, pfx, name) type pfx##_##tmp##name = def_##name; if (pfx##_##name(pfx##_##tmp##name) != def_##name) { std::ostringstream a; std::ostringstream b; a << pfx##_##name(pfx##_##tmp##name); b << def_##name; if (a.str() != b.str()) { std::cout << "failing in pfx""_""name : " << a.str() << " : " << b.str() << std::endl; // return 0; } } %enddef %define wrp_decl(type, pfx, name) type wrp##_##pfx##_##name(type x) { return pfx##_##name(x); } %enddef /* function passing by value */ %define ovr_decl(type, pfx, name) virtual int pfx##_##val(type x) { return 1; } virtual int pfx##_##ref(const type& x) { return 1; } %enddef %inline { struct Foo { int _a; Foo (int a) : _a(a) { } Foo(const Foo&) { } Foo copy(Foo x) { return x; } const Foo copy_c(const Foo x) { return x; } const Foo& copy_r(const Foo& x) { return x; } Foo* this_p() { return this; } Foo& this_r() { return *this; } }; typedef Foo* foo_ptr; foo_ptr fptr_val(foo_ptr a) { return a; } const foo_ptr& fptr_ref(const foo_ptr& a) { return a; } struct Test { Test() : var_pchar(0), var_pcharc(0), var_pint(0) { } virtual ~Test() { } %test_prim_types_stc(stc_decl, stc) %test_prim_types(var_decl, var) var_decl(namet, var, namet) const char* val_namet(namet x) throw(namet) { return x; } const char* val_cnamet(const namet x) throw(namet) { return x; } #if 0 /* I have no idea how to define a typemap for const namet&, where namet is a char[ANY] array */ const namet& ref_namet(const namet& x) throw(namet) { return x; } #endif %test_prim_types(val_decl, val) %test_prim_types(ref_decl, ref) int c_check() { %test_prim_types(call_check, val) %test_prim_types(call_check, ref) return 1; } int v_check() { %test_prim_types_stc(var_check, stc) %test_prim_types(var_check, var) var_check(namet, var, namet); return 1; } %test_prim_types_ovr(ovr_decl, ovr) static const double stc_double; static const double stc_float; }; struct TestDirector { TestDirector() : var_pchar(0), var_pcharc(0), var_pint(0) { } virtual ~TestDirector() { var_namet[0]='h'; } virtual const char* vval_namet(namet x) throw(namet) { return x; } virtual const char* vval_cnamet(const namet x) throw(namet) { return x; } #if 0 /* I have no idea how to define a typemap for const namet&, where namet is a char[ANY] array */ virtual const namet& vref_namet(const namet& x) throw(namet) { return x; } #endif %test_prim_types_stc(stc_decl, stc) %test_prim_types(var_decl, var) var_decl(namet, var, namet) %test_prim_types(val_decl, val) %test_prim_types(ref_decl, ref) %test_prim_types(vval_decl, vval) %test_prim_types(vref_decl, vref) %test_prim_types(wrp_decl, vref) %test_prim_types(wrp_decl, vval) int c_check() { %test_prim_types(call_check, vval) %test_prim_types(call_check, vref) return 1; } int v_check() { %test_prim_types_stc(var_check, stc) %test_prim_types(var_check, var) return 1; } %test_prim_types_ovr(ovr_decl, ovr) virtual Test* vtest(Test* t) const throw (Test) { return t; } }; int v_check() { %test_prim_types(var_check, cct) %test_prim_types(var_check, var) var_check(namet, var, namet); return 1; } } %inline %{ const char* char_foo(float f, const char *s) { return s; } int char_foo(double d, int i) { return i; } %} %{ const double Test::stc_double = 1; const double Test::stc_float = 1; %} %inline %{ namespace DCTypes { typedef const unsigned int cuint; } namespace DCSystem { using namespace DCTypes; unsigned int SetPos(cuint& x, cuint& y) {return x + y;} } double val_double_2(double x, const double& y = 3.0) { return x + y; } double val_double(double x) { return x; } float val_float_2(float x, const float& y = 3.0) { return x + y; } // Regression test for bug1699646 - we weren't handling // + or - after e for float constants. float regression_test_for_bug1699646(float f = 1e-02f) { return f; } float val_float(float x) { return x; } %} %apply SWIGTYPE* { char *}; %include "carrays.i" %array_functions(char,pchar); swig-3.0.2/Examples/test-suite/li_std_vector_extra.i0000664000175000017500000000563312343605122022453 0ustar williamwilliam%module li_std_vector_extra %warnfilter(509) overloaded1; %warnfilter(509) overloaded2; %include "std_string.i" %include "std_vector.i" %include "cpointer.i" %include "carrays.i" %{ #include #include #include %} namespace std { %template() vector; %template(IntVector) vector; %template(BoolVector) vector; %template() vector; } %template(DoubleVector) std::vector; %template(sizeVector) std::vector; %{ template struct Param { T val; Param(T v = 0): val(v) { } operator T() const { return val; } }; %} specialize_std_vector(Param,PyInt_Check,PyInt_AsLong,PyInt_FromLong); %template(PIntVector) std::vector >; %inline %{ typedef float Real; %} namespace std { %template(RealVector) vector; } %inline %{ double average(std::vector v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } std::vector half(const std::vector& v) { std::vector w(v); for (std::vector::size_type i=0; i& v) { std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } %} %template(IntPtrVector) std::vector; // // %{ #include %} %inline %{ namespace Test { struct A { virtual ~A() {} virtual int f(const int i) const = 0; }; struct B : public A { int val; B(int i = 0) : val(i) { } int f(const int i) const { return i + val; } }; int vecAptr(const std::vector& v) { return v[0]->f(1); } } std::vector halfs(const std::vector& v) { std::vector w(v); for (std::vector::size_type i=0; i vecStr(std::vector v) { v[0] += v[1]; return v; } %} %template(VecB) std::vector; %template(VecA) std::vector; %pointer_class(int,PtrInt) %array_functions(int,ArrInt) %inline %{ int *makeIntPtr(int v) { return new int(v); } const short *makeConstShortPtr(int v) { return new short(v); } double *makeDoublePtr(double v) { return new double(v); } int extractInt(int *p) { return *p; } short extractConstShort(const short *p) { return *p; } %} %template(pyvector) std::vector; namespace std { %template(ConstShortPtrVector) vector; } %inline %{ std::string overloaded1(std::vector vi) { return "vector"; } std::string overloaded1(std::vector vi) { return "vector"; } std::string overloaded2(std::vector vi) { return "vector"; } std::string overloaded2(std::vector vi) { return "vector"; } std::string overloaded3(std::vector *vi) { return "vector *"; } std::string overloaded3(int i) { return "int"; } %} swig-3.0.2/Examples/test-suite/smart_pointer_multi.i0000664000175000017500000000076012343605122022504 0ustar williamwilliam// Test cases for classes that do *NOT* result in smart-pointer wrapping %module smart_pointer_multi %inline %{ struct Foo { int x; int getx() { return x; } }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } Foo *operator->() { return f; } }; class Spam { Bar *b; public: Spam(Bar *b) : b(b) { } Bar operator->() { return *b; } }; class Grok { Bar *b; public: Grok(Bar *b) : b(b) { } Bar &operator->() { return *b; } }; %} swig-3.0.2/Examples/test-suite/typemap_directorout.i0000664000175000017500000000344412343605122022510 0ustar williamwilliam// Test named output typemaps used in directors are found during the typematch search %module(directors="1") typemap_directorout %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Class1; %feature("director"); %typemap(out) MyType & %{ WILL_NOT_COMPILE %} %typemap(out) MyType &USEME = SWIGTYPE &; %typemap(out) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(out, MyType &USEME) /* special end */ %} %typemap(directorout) MyType & %{ WILL_NOT_COMPILE %} // Can't use the %typemap(directorout) MyType & = SWIGTYPE & approach as non-director languages don't define any directorout typemaps %typemap(directorout) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $input = 0; /* special end */ %} #ifdef SWIGCSHARP %typemap(csdirectorout) MyType & %{ WILL_NOT_COMPILE %} %typemap(csdirectorout) MyType &USEME = SWIGTYPE &; %typemap(csdirectorout) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(csdirectorout, MyType &USEME) /* special end */ %} #endif #ifdef SWIGD %typemap(ddirectorout) MyType & %{ WILL_NOT_COMPILE %} %typemap(ddirectorout) MyType &USEME = SWIGTYPE &; %typemap(ddirectorout) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(ddirectorout, MyType &USEME) /* special end */ %} #endif #ifdef SWIGJAVA %typemap(javadirectorout) MyType & %{ WILL_NOT_COMPILE %} %typemap(javadirectorout) MyType &USEME = SWIGTYPE &; %typemap(javadirectorout) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(javadirectorout, MyType &USEME) /* special end */ %} #endif %inline %{ typedef int MyType; class Class1 { MyType mt; public: Class1() : mt() {} virtual MyType & foo1() { return mt; } virtual MyType & foo2(int parm1) { return mt; } virtual MyType & foo2() { return mt; } virtual ~Class1() {} }; %} swig-3.0.2/Examples/test-suite/template_typedef_cplx4.i0000664000175000017500000000143312343605122023047 0ustar williamwilliam%module template_typedef_cplx4 %{ #include "template_typedef_cplx2.h" %} %include "template_typedef_cplx2.h" %inline %{ typedef vfncs::ArithUnaryFunction RFunction; // **** these two work **** // typedef vfncs::ArithUnaryFunction CFunction; // typedef vfncs::ArithUnaryFunction, std::complex > CFunction; // **** these ones don't *** // typedef vfncs::ArithUnaryFunction > CFunction; typedef vfncs::ArithUnaryFunction, Complex > CFunction; int my_func_r(RFunction* hello) { return 0; } int my_func_c(CFunction* hello) { return 1; } struct Sin : RFunction { }; struct CSin : CFunction { }; %} swig-3.0.2/Examples/test-suite/typedef_scope.i0000664000175000017500000000063212343605122021233 0ustar williamwilliam// Tests some subtle issues of typedef scoping in C++ %module typedef_scope %inline %{ typedef char * FooType; class Bar { public: typedef int FooType; FooType test1(FooType n, ::FooType data) { return n; } ::FooType test2(FooType n, ::FooType data) { return data; } }; class Foo { }; typedef Foo FooBar; class CBaz { public: typedef FooBar Foo; }; %} swig-3.0.2/Examples/test-suite/java_jnitypes.i0000664000175000017500000000220512343605122021246 0ustar williamwilliam // This testcase tests the JNI types %module java_jnitypes %inline %{ jboolean jnifunc_bool(jboolean in) { return in; } /* some JVM implementations won't allow overloading of the jboolean type with some of the others on the c++ level */ jchar jnifunc(jchar in) { return in; } jbyte jnifunc(jbyte in) { return in; } jshort jnifunc(jshort in) { return in; } jint jnifunc(jint in) { return in; } jlong jnifunc(jlong in) { return in; } jfloat jnifunc(jfloat in) { return in; } jdouble jnifunc(jdouble in) { return in; } jstring jnifunc(jstring in) { return in; } jobject jnifunc(jobject in) { return in; } jbooleanArray jnifunc(jbooleanArray in) { return in; } jcharArray jnifunc(jcharArray in) { return in; } jbyteArray jnifunc(jbyteArray in) { return in; } jshortArray jnifunc(jshortArray in) { return in; } jintArray jnifunc(jintArray in) { return in; } jlongArray jnifunc(jlongArray in) { return in; } jfloatArray jnifunc(jfloatArray in) { return in; } jdoubleArray jnifunc(jdoubleArray in) { return in; } jobjectArray jnifunc(jobjectArray in) { return in; } %} swig-3.0.2/Examples/test-suite/template_ref_type.i0000664000175000017500000000051012343605122022105 0ustar williamwilliam%module template_ref_type %inline %{ class X { public: unsigned _i; }; template class Container { public: Container () {} bool reset () { return false ;} }; typedef Container XC; %} %template(XC) Container; %inline %{ class Y { public: Y () {}; bool find (XC &) { return false; } }; %} swig-3.0.2/Examples/test-suite/guile_ext_test.i0000664000175000017500000000060112343605122021422 0ustar williamwilliam%module guile_ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ #include "imports_a.h" %} %include "imports_a.h" %{ SCM test_create(); SCM test_is_pointer(SCM val); %} %init %{ scm_c_define_gsubr("test-create", 0, 0, 0, (swig_guile_proc) test_create); scm_c_define_gsubr("test-is-pointer", 1, 0, 0, (swig_guile_proc) test_is_pointer); %} swig-3.0.2/Examples/test-suite/smart_pointer_member.i0000664000175000017500000000144412343605122022621 0ustar williamwilliam%module smart_pointer_member %warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'foo' due to Go name ('Foo') conflict with 'Foo' */ %inline %{ class Foo { public: int x[4]; int y; static const int z; static const int ZZ = 3; static int zx; static int boo() { return 0;} friend int foo(Foo* foo) { return 0;} }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } Foo *operator->() { return f; } static int bua() { return 0;} }; class CBar { Foo *f; public: CBar(Foo *f) : f(f) { } const Foo *operator->() { return f; } }; int get_y(Bar *b) { return (*b)->y; } int get_z(Bar *b) { return (*b)->z; } %} %{ const int Foo::z = 3; int Foo::zx; %} swig-3.0.2/Examples/test-suite/template_partial_arg.i0000664000175000017500000000051412343605122022561 0ustar williamwilliam%module template_partial_arg %inline %{ template class Foo { public: T bar() { return T(); } T* baz() { return 0; } }; template class Foo { public: T bar() { return T(); } T* baz() { return 0; } }; class Bar {}; %} %template(Foo1) Foo; %template(Foo2) Foo; swig-3.0.2/Examples/test-suite/rename2.i0000664000175000017500000000463512343605122017742 0ustar williamwilliam// Test %rename directive in the Space namespace %module rename2 namespace Space { // Note: no Space:: qualifier %rename(opIntPtrA) XYZ::operator NotXYZ*() const; %rename(opIntPtrB) XYZ::operator XYZ*() const; %rename(opAnother1) XYZ::operator Another() const; %rename(opAnother2) XYZ::operator Another() const; %rename(opAnother3) XYZ::operator Another() const; %rename(opAnother4) XYZ::operator Another() const; %rename(tMethod1) XYZ::templateT(T i); %rename(tMethod2) XYZ::templateT(int i); %rename(tMethod3) XYZ::templateT(Space::Klass i); %rename(tMethod4) XYZ::templateT(Space::Enu i); %rename(tMethodNotXYZ1) XYZ::templateNotXYZ(NotXYZ); %rename(tMethodNotXYZ2) XYZ::templateNotXYZ(NotXYZ); %rename(tMethodNotXYZ3) XYZ::templateNotXYZ(NotXYZ); %rename(tMethodNotXYZ4) XYZ::templateNotXYZ(NotXYZ); %rename(tMethodXYZ1) XYZ::templateXYZ(XYZ); %rename(tMethodXYZ2) XYZ::templateXYZ(XYZ); %rename(tMethodXYZ3) XYZ::templateXYZ(XYZ); %rename(tMethodXYZ4) XYZ::templateXYZ(XYZ); %rename(opT1) XYZ::operator T(); %rename(opT2) XYZ::operator int(); %rename(opT3) XYZ::operator Space::Klass(); %rename(opT4) XYZ::operator Space::Enu(); %rename(opNotXYZ1) XYZ::operator NotXYZ() const; %rename(opNotXYZ2) XYZ::operator NotXYZ() const; %rename(opNotXYZ3) XYZ::operator NotXYZ() const; %rename(opNotXYZ4) XYZ::operator NotXYZ() const; %rename(opXYZ1) XYZ::operator XYZ() const; %rename(opXYZ2) XYZ::operator XYZ() const; %rename(opXYZ3) XYZ::operator XYZ() const; %rename(opXYZ4) XYZ::operator XYZ() const; %rename(methodABC) ABC::method(ABC a) const; %rename(opABC) ABC::operator ABC() const; %rename(methodKlass) ABC::method(Klass k) const; %rename(opKlass) ABC::operator Klass() const; } %{ #include "rename.h" %} %include "rename.h" %template(XYZInt) Space::XYZ; %template(XYZDouble) Space::XYZ; %template(XYZKlass) Space::XYZ; %template(XYZEnu) Space::XYZ; %template(NotXYZInt) Space::NotXYZ; %template(NotXYZDouble) Space::NotXYZ; %template(NotXYZKlass) Space::NotXYZ; %template(NotXYZEnu) Space::NotXYZ; swig-3.0.2/Examples/test-suite/template_default.i0000664000175000017500000000620412343605122021722 0ustar williamwilliam%module template_default %warnfilter(SWIGWARN_RUBY_WRONG_NAME) ns1::Traits::c; /* Ruby, wrong constant name */ namespace ns1 { namespace ns2 { %feature("hello") A; %feature("hello") A; %feature("hi") A; %feature("hi") A; %extend A { int foo() { return 1; } } %extend A { int foo() { return 1; } } %extend A { int bar() { return 1; } } %extend A { int bar() { return 1; } } %extend N { int bar() { return 1; } } } } %inline %{ namespace ns1 { namespace ns2 { struct Parm { }; template class A { #ifdef SWIG %typemap(in) A * { /* in A */ } #ifdef SWIGCSHARP %typemap(out) A * { /* out A */ $result=0; } #else %typemap(out) A * { /* out A */ } #endif #endif }; typedef unsigned int category; const category one = 1; const category two = 1; template class N { #ifdef SWIG %typemap(in) N * { /* in N */ } #ifdef SWIGCSHARP %typemap(out) N * { /* out N */ $result=0; } #else %typemap(out) N * { /* out N */ } #endif #endif }; } } %} %template(A_p) ns1::ns2::A; %template(N_1p) ns1::ns2::N; namespace ns1 { namespace ns2 { %template(A_ii) A; %template(A_d) A; %template(N_d) N; } } %inline %{ namespace ns1 { namespace ns2 { namespace ns3 { struct B : A { }; struct C : N { }; A *get_a1(A *a) { return a; } A *get_a2(A *a) { return a; } } } } %} %inline %{ namespace ns1 { struct Traits { static const ns2::category c = ns2::one; }; namespace ns4 { template struct D : ns2::N { D() { } }; template > struct Base : T2 { }; } } %} %template(Doo) ns1::ns4::D; %template(Boo) ns1::ns4::Base >; %inline %{ namespace ns1 { namespace ns5 { struct Der : ns4::Base { }; } } %} %inline %{ namespace hi { class CFoo { }; template class CTemplate { }; typedef CTemplate TBla; // OK typedef void (*TFunc1)(CFoo arg); // OK typedef void (*TFunc2)(CTemplate arg); // OK typedef void (*TFunc3)(CTemplate* arg); // OK int foo(TFunc1 a, TFunc2 b, TFunc3 c) { return 0; } } %} #ifndef SWIGCHICKEN %include std_vector.i %{ #include %} %inline %{ void g(std::vector* s = 0) {} void q(double = 0) {} %} %constant void (*Bf)(std::vector *p = 0) = g; %constant void (*Cf)(double = 0) = q; #endif swig-3.0.2/Examples/test-suite/shared_ptr_wrapper.h0000664000175000017500000000572212343605122022301 0ustar williamwilliam// defines SwigBoost::shared_ptr, a wrapper around boost::shared_ptr // Use this shared_ptr wrapper for testing memory leaks of shared_ptr. // getTotalCount() should return zero at end of test #include struct SWIG_null_deleter; // forward reference, definition is in shared_ptr.i namespace SwigBoost { // This template can be specialized for better debugging information template std::string show_message(boost::shared_ptr*t) { if (!t) return "null shared_ptr!!!"; if (boost::get_deleter(*t)) return std::string(typeid(t).name()) + " NULL DELETER"; if (*t) return std::string(typeid(t).name()) + " object"; else return std::string(typeid(t).name()) + " NULL"; } namespace SharedPtrWrapper { static SwigExamples::CriticalSection critical_section; static int total_count = 0; template void increment(boost::shared_ptr* ptr) { SwigExamples::Lock lock(critical_section); std::cout << "====SharedPtrWrapper==== + " << ptr << " " << show_message(ptr) << " " << std::endl << std::flush; total_count++; } template void decrement(boost::shared_ptr* ptr) { SwigExamples::Lock lock(critical_section); std::cout << "====SharedPtrWrapper==== - " << ptr << " " << show_message(ptr) << " " << std::endl << std::flush; total_count--; } static int getTotalCount() { return total_count; } } template class shared_ptr { private: typedef shared_ptr this_type; public: typedef typename boost::detail::shared_ptr_traits::reference reference; shared_ptr() : m_shared_ptr() { SharedPtrWrapper::increment(&m_shared_ptr); } template explicit shared_ptr(Y* p) : m_shared_ptr(p) { SharedPtrWrapper::increment(&m_shared_ptr); } template explicit shared_ptr(Y* p, D d) : m_shared_ptr(p, d) { SharedPtrWrapper::increment(&m_shared_ptr); } shared_ptr(shared_ptr const & other) : m_shared_ptr(other.m_shared_ptr) { SharedPtrWrapper::increment(&m_shared_ptr); } template shared_ptr(shared_ptr const & other) : m_shared_ptr(other.m_shared_ptr) { SharedPtrWrapper::increment(&m_shared_ptr); } reference operator*() const { return m_shared_ptr.operator*(); } T* operator->() const { return m_shared_ptr.operator->(); } T* get() const { return m_shared_ptr.get(); } operator bool() const { return m_shared_ptr.get() == 0 ? false : true; } bool unique() const { return m_shared_ptr.unique(); } long use_count() const { return m_shared_ptr.use_count(); } void swap(shared_ptr& other) { std::swap(m_shared_ptr, other.m_shared_ptr); } template bool _internal_less(shared_ptr const & rhs) const { return m_shared_ptr < rhs.m_shared_ptr; } ~shared_ptr() { SharedPtrWrapper::decrement(&m_shared_ptr); } private: template friend class shared_ptr; boost::shared_ptr m_shared_ptr; }; } swig-3.0.2/Examples/test-suite/template_private_assignment.i0000664000175000017500000000146012343605122024177 0ustar williamwilliam%module template_private_assignment /* swig-devel mailing list report problem explained 2014-01-07 A setter for the global variable deleted_bits is generated because there is no template instantiation for the template and hence SWIG does not find the private assignment operator. SwigValueWrapper is probably on by default for templates that are not instantiated for the same reason. The solution is probably to add an instantiation of the template as soon as one is parsed, that is an implicit empty %template(). */ %inline %{ template struct DeletedBits { // DeletedBits& operator=(const DeletedBits&) = delete; private: DeletedBits& operator=(const DeletedBits&); }; DeletedBits deleted_bits; %} // This works around the problem //%template() DeletedBits; swig-3.0.2/Examples/test-suite/d_nativepointers.i0000664000175000017500000000121612343605122021756 0ustar williamwilliam%module d_nativepointers; %inline %{ class SomeClass { }; class OpaqueClass; typedef void (*FuncA)(int **x, char ***y); typedef void (*FuncB)(int **x, SomeClass *y); int *a( int *value ){ return value; } float **b( float **value ){ return value; } char ***c( char ***value ){ return value; } SomeClass *d( SomeClass *value ){ return value; } SomeClass **e( SomeClass **value ){ return value; } OpaqueClass *f( OpaqueClass *value ){ return value; } FuncA g( FuncA value ){ return value; } FuncB* h( FuncB* value ){ return value; } int &refA( int &value ){ return value; } float *&refB( float *&value ){ return value; } %} swig-3.0.2/Examples/test-suite/li_std_deque.i0000664000175000017500000000135112343605122021042 0ustar williamwilliam%module li_std_deque %include "std_deque.i" %{ #include #include #include %} namespace std { %template(IntDeque) deque; } %template(DoubleDeque) std::deque; %inline %{ typedef float Real; %} namespace std { %template(RealDeque) deque; } %inline %{ double average(std::deque v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } std::deque half(const std::deque& v) { std::deque w(v); for (unsigned int i=0; i& v) { std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } %} swig-3.0.2/Examples/test-suite/template_arg_typename.i0000664000175000017500000000075412343605122022755 0ustar williamwilliam%module template_arg_typename %inline %{ template struct UnaryFunction { typedef void* vptr_type; }; template struct BoolUnaryFunction : UnaryFunction { typedef UnaryFunction base; BoolUnaryFunction(const typename base::vptr_type* vptrf) {} }; %} %template(UnaryFunction_bool_bool) UnaryFunction; %template(BoolUnaryFunction_bool) BoolUnaryFunction; swig-3.0.2/Examples/test-suite/symbol_clash.i0000664000175000017500000000060112343605122021055 0ustar williamwilliam%module symbol_clash // ::Vector and ::Text::Vector were incorrectly clashing in the target language symbol tables #if defined(SWIGJAVA) || defined(SWIGCSHARP) #if defined(SWIGJAVA) %include "enumtypeunsafe.swg" #elif defined(SWIGCSHARP) %include "enumsimple.swg" #endif %inline %{ class Vector { }; namespace Text { enum Preference { Raster, Vector }; } %} #endif swig-3.0.2/Examples/test-suite/testdir/0000775000175000017500000000000012343605122017705 5ustar williamwilliamswig-3.0.2/Examples/test-suite/testdir/README0000664000175000017500000000033112343605122020562 0ustar williamwilliamThis is a special directory for testcases that require inputs using subdirectories. Each subdirectory should be named after the testcase. Any desired subdirectory structure can be put under the testcase subdirectory. swig-3.0.2/Examples/test-suite/testdir/inctest/0000775000175000017500000000000012343605122021356 5ustar williamwilliamswig-3.0.2/Examples/test-suite/testdir/inctest/test.i0000664000175000017500000000007412343605122022510 0ustar williamwilliam %include "subdir1/subinc1.i" %include "subdir2/subinc2.i" swig-3.0.2/Examples/test-suite/testdir/inctest/subdir1/0000775000175000017500000000000012343605122022727 5ustar williamwilliamswig-3.0.2/Examples/test-suite/testdir/inctest/subdir1/subinc1.i0000664000175000017500000000017712343605122024452 0ustar williamwilliam// %include twice to check include header guards %include "hello.i" %include "hello.i" %import "imports.i" %import "imports.i" swig-3.0.2/Examples/test-suite/testdir/inctest/subdir1/hello.i0000664000175000017500000000033412343605122024204 0ustar williamwilliam#ifndef subdir1_hello_i_ #define subdir1_hello_i_ %{ typedef int Integer; %} %inline %{ struct A { int aa; }; Integer importtest1(Integer i) { return i + 10; } %} #endif //subdir1_hello_i_ swig-3.0.2/Examples/test-suite/testdir/inctest/subdir1/imports.i0000664000175000017500000000015112343605122024573 0ustar williamwilliam#ifndef subdir1_imports_i_ #define subdir1_imports_i_ typedef int Integer; #endif //subdir1_imports_i_ swig-3.0.2/Examples/test-suite/testdir/inctest/subdir2/0000775000175000017500000000000012343605122022730 5ustar williamwilliamswig-3.0.2/Examples/test-suite/testdir/inctest/subdir2/hello.i0000664000175000017500000000040712343605122024206 0ustar williamwilliam#ifndef subdir2_hello_i_ #define subdir2_hello_i_ %{ typedef char * TypedefString; %} %inline %{ struct B { int bb; }; TypedefString importtest2(TypedefString str) { strcpy(str, "white"); return str; } %} #endif //subdir2_hello_i_ swig-3.0.2/Examples/test-suite/testdir/inctest/subdir2/imports.i0000664000175000017500000000016212343605122024576 0ustar williamwilliam#ifndef subdir2_imports_i_ #define subdir2_imports_i_ typedef char * TypedefString; #endif //subdir2_imports_i_ swig-3.0.2/Examples/test-suite/testdir/inctest/subdir2/subinc2.i0000664000175000017500000000005012343605122024442 0ustar williamwilliam%include "hello.i" %import "imports.i" swig-3.0.2/Examples/test-suite/cpp11_lambda_functions.i0000664000175000017500000000704012343605122022716 0ustar williamwilliam/* This testcase checks whether SWIG correctly parses the lambda expressions and closure syntax introduced in C++11. SWIG supports only lambda syntax and doesn't produce any wrapper code for this. */ %module cpp11_lambda_functions %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda1; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda2; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda3; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda4; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda5; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda6; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda7; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda8; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda9; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda10; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda11; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda12; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda13; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda14; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda15; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda16; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda17; %warnfilter(SWIGWARN_CPP11_LAMBDA) lambda18; %warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::lambda19; %warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::Space2::lambda20; %inline %{ /* Defined lambda function with return value. */ auto lambda1 = [](int x, int y) -> int { return x+y; }; /* Defined lambda function without return value. Return value is calculated by compiler, if the function contains a single statement "return expr;". */ auto lambda2 = [](int x, int y) { return x+y; }; auto lambda3 = [&](int x, int y) { return x+y; }; auto lambda4 = [=](int x, int y) { return x+y; }; int thing = 0; #ifdef SWIG // Not strictly correct as captured variables should have non-automatic storage duration, ie shouldn't capture globals. gcc-4.7 warns about this, but we check that SWIG can parse this anyway. auto lambda5 = [=,&thing]() { return thing; }; #else auto lambda5 = [=]() { return thing; }; #endif void fn() { int stuff = 0; auto lambdaxxxx = [=,&stuff]() { return thing; }; } auto lambda6 = [] (int a, int b) mutable { return a + b; }; auto lambda7 = [] (int x, int y) -> int { return x+y; }; auto lambda8 = [] (int x, int y) throw() -> int { return x+y; }; auto lambda9 = [] (int x, int y) mutable throw() -> int { return x+y; }; auto lambda10 = [] (int x, int y) throw(int) { return x+y; }; auto lambda11 = [] (int x, int y) mutable throw(int) { return x+y; }; auto lambda12 = [] (int a, int b) { return a + b; }(1, 2); auto lambda13 = [] (int a, int b) mutable { return a + b; }(1, 2); auto lambda14 = [] () throw () {}; auto lambda15 = [] () mutable throw () {}; auto lambda16 = [] { return thing; }; auto lambda17 = [] { return thing; }(); constexpr auto lambda18 = [] (int x, int y) mutable throw(int) { return x+y; }; namespace Space1 { constexpr auto lambda19 = [] (int x, int y) mutable throw(int) { return x+y; }; namespace Space2 { constexpr auto lambda20 = [] (int x, int y) mutable throw(int) { return x+y; }; } } int runLambda1() { return lambda1(5,6); } int runLambda2() { return lambda2(5,6); } int runLambda3() { return lambda3(5,6); } int runLambda4() { return lambda4(5,6); } int runLambda5() { thing++; return lambda5(); } /* Inline defined lambda function. */ int runLambdaInline() { auto myLambda = [](int x, int y) { return x+y; }; return myLambda(5,6); } %} %{ // 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; })()); %} swig-3.0.2/Examples/test-suite/tag_no_clash_with_variable.i0000664000175000017500000000074612343605122023731 0ustar williamwilliam/* This is a test case for -*- C -*- mode. */ %module tag_no_clash_with_variable %inline %{ /* error_action is only a tag, not a type... */ enum error_action { ERRACT_ABORT, ERRACT_EXIT, ERRACT_THROW }; /* ... thus it does not clash with a variable of the same name. */ enum error_action error_action; /* Likewise for structs: */ struct buffalo { int foo; }; struct buffalo buffalo; /* And for union */ union onion { int cheese; }; union onion onion; %} swig-3.0.2/Examples/test-suite/swigobject.i0000664000175000017500000000041312343605122020537 0ustar williamwilliam%module swigobject %inline { struct A { char name[4]; }; const char* pointer_str(A *a){ static char result[1024]; sprintf(result,"%p", a); return result; } A *a_ptr(A *a){ return a; } void *v_ptr(void *a){ return a; } } swig-3.0.2/Examples/test-suite/li_typemaps.i0000664000175000017500000001167712343605122020743 0ustar williamwilliam%module li_typemaps %include "typemaps.i" %apply int &INOUT { int &INOUT2 }; %newobject out_foo; %inline %{ struct Foo { int a; }; bool in_bool(bool *INPUT) { return *INPUT; } int in_int(int *INPUT) { return *INPUT; } long in_long(long *INPUT) { return *INPUT; } short in_short(short *INPUT) { return *INPUT; } unsigned int in_uint(unsigned int *INPUT) { return *INPUT; } unsigned short in_ushort(unsigned short *INPUT) { return *INPUT; } unsigned long in_ulong(unsigned long *INPUT) { return *INPUT; } unsigned char in_uchar(unsigned char *INPUT) { return *INPUT; } signed char in_schar(signed char *INPUT) { return *INPUT; } float in_float(float *INPUT) { return *INPUT; } double in_double(double *INPUT) { return *INPUT; } long long in_longlong(long long *INPUT) { return *INPUT; } unsigned long long in_ulonglong(unsigned long long *INPUT) { return *INPUT; } bool inr_bool(bool &INPUT) { return INPUT; } int inr_int(int &INPUT) { return INPUT; } long inr_long(long &INPUT) { return INPUT; } short inr_short(short &INPUT) { return INPUT; } unsigned int inr_uint(unsigned int &INPUT) { return INPUT; } unsigned short inr_ushort(unsigned short &INPUT) { return INPUT; } unsigned long inr_ulong(unsigned long &INPUT) { return INPUT; } unsigned char inr_uchar(unsigned char &INPUT) { return INPUT; } signed char inr_schar(signed char &INPUT) { return INPUT; } float inr_float(float &INPUT) { return INPUT; } double inr_double(double &INPUT) { return INPUT; } long long inr_longlong(long long &INPUT) { return INPUT; } unsigned long long inr_ulonglong(unsigned long long &INPUT) { return INPUT; } void out_bool(bool x, bool *OUTPUT) { *OUTPUT = x; } void out_int(int x, int *OUTPUT) { *OUTPUT = x; } void out_short(short x, short *OUTPUT) { *OUTPUT = x; } void out_long(long x, long *OUTPUT) { *OUTPUT = x; } void out_uint(unsigned int x, unsigned int *OUTPUT) { *OUTPUT = x; } void out_ushort(unsigned short x, unsigned short *OUTPUT) { *OUTPUT = x; } void out_ulong(unsigned long x, unsigned long *OUTPUT) { *OUTPUT = x; } void out_uchar(unsigned char x, unsigned char *OUTPUT) { *OUTPUT = x; } void out_schar(signed char x, signed char *OUTPUT) { *OUTPUT = x; } void out_float(float x, float *OUTPUT) { *OUTPUT = x; } void out_double(double x, double *OUTPUT) { *OUTPUT = x; } void out_longlong(long long x, long long *OUTPUT) { *OUTPUT = x; } void out_ulonglong(unsigned long long x, unsigned long long *OUTPUT) { *OUTPUT = x; } /* Tests a returning a wrapped pointer and an output argument */ struct Foo *out_foo(int a, int *OUTPUT) { struct Foo *f = new struct Foo(); f->a = a; *OUTPUT = a * 2; return f; } void outr_bool(bool x, bool &OUTPUT) { OUTPUT = x; } void outr_int(int x, int &OUTPUT) { OUTPUT = x; } void outr_short(short x, short &OUTPUT) { OUTPUT = x; } void outr_long(long x, long &OUTPUT) { OUTPUT = x; } void outr_uint(unsigned int x, unsigned int &OUTPUT) { OUTPUT = x; } void outr_ushort(unsigned short x, unsigned short &OUTPUT) { OUTPUT = x; } void outr_ulong(unsigned long x, unsigned long &OUTPUT) { OUTPUT = x; } void outr_uchar(unsigned char x, unsigned char &OUTPUT) { OUTPUT = x; } void outr_schar(signed char x, signed char &OUTPUT) { OUTPUT = x; } void outr_float(float x, float &OUTPUT) { OUTPUT = x; } void outr_double(double x, double &OUTPUT) { OUTPUT = x; } void outr_longlong(long long x, long long &OUTPUT) { OUTPUT = x; } void outr_ulonglong(unsigned long long x, unsigned long long &OUTPUT) { OUTPUT = x; } void inout_bool(bool *INOUT) { *INOUT = *INOUT; } void inout_int(int *INOUT) { *INOUT = *INOUT; } void inout_short(short *INOUT) { *INOUT = *INOUT; } void inout_long(long *INOUT) { *INOUT = *INOUT; } void inout_uint(unsigned int *INOUT) { *INOUT = *INOUT; } void inout_ushort(unsigned short *INOUT) { *INOUT = *INOUT; } void inout_ulong(unsigned long *INOUT) { *INOUT = *INOUT; } void inout_uchar(unsigned char *INOUT) { *INOUT = *INOUT; } void inout_schar(signed char *INOUT) { *INOUT = *INOUT; } void inout_float(float *INOUT) { *INOUT = *INOUT; } void inout_double(double *INOUT) { *INOUT = *INOUT; } void inout_longlong(long long *INOUT) { *INOUT = *INOUT; } void inout_ulonglong(unsigned long long *INOUT) { *INOUT = *INOUT; } void inoutr_bool(bool &INOUT) { INOUT = INOUT; } void inoutr_int(int &INOUT) { INOUT = INOUT; } void inoutr_short(short &INOUT) { INOUT = INOUT; } void inoutr_long(long &INOUT) { INOUT = INOUT; } void inoutr_uint(unsigned int &INOUT) { INOUT = INOUT; } void inoutr_ushort(unsigned short &INOUT) { INOUT = INOUT; } void inoutr_ulong(unsigned long &INOUT) { INOUT = INOUT; } void inoutr_uchar(unsigned char &INOUT) { INOUT = INOUT; } void inoutr_schar(signed char &INOUT) { INOUT = INOUT; } void inoutr_float(float &INOUT) { INOUT = INOUT; } void inoutr_double(double &INOUT) { INOUT = INOUT; } void inoutr_longlong(long long &INOUT) { INOUT = INOUT; } void inoutr_ulonglong(unsigned long long &INOUT) { INOUT = INOUT; } void inoutr_int2(int &INOUT, int &INOUT2) { INOUT = INOUT; INOUT2 = INOUT2;} %} swig-3.0.2/Examples/test-suite/static_array_member.i0000664000175000017500000000042012343605122022411 0ustar williamwilliam/* This interface file checks whether the SWIG parser handles static array members of classes. Bug reported by Annalisa Terracina on 2001-07-03. */ %module static_array_member %inline %{ class RB { static char *rberror[]; }; %} swig-3.0.2/Examples/test-suite/java/0000775000175000017500000000000012343605122017150 5ustar williamwilliamswig-3.0.2/Examples/test-suite/java/inctest_runme.java0000664000175000017500000000100312343605122022664 0ustar williamwilliam import inctest.*; public class inctest_runme { static { try { System.loadLibrary("inctest"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { MY_THINGS things = new MY_THINGS(); int i=0; things.setIntegerMember(i); double d = things.getDoubleMember(); } } swig-3.0.2/Examples/test-suite/java/varargs_runme.java0000664000175000017500000000163712343605122022675 0ustar williamwilliam// varargs test import varargs.*; public class varargs_runme { static { try { System.loadLibrary("varargs"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { if (!varargs.test("Hello").equals("Hello")) throw new RuntimeException("Failed"); Foo f = new Foo("BuonGiorno", 1); if (!f.getStr().equals("BuonGiorno")) throw new RuntimeException("Failed"); f = new Foo("Greetings"); if (!f.getStr().equals("Greetings")) throw new RuntimeException("Failed"); if (!f.test("Hello").equals("Hello")) throw new RuntimeException("Failed"); if (!Foo.statictest("Grussen", 1).equals("Grussen")) throw new RuntimeException("Failed"); } } swig-3.0.2/Examples/test-suite/java/ret_by_value_runme.java0000664000175000017500000000172712343605122023710 0ustar williamwilliam // This is the ret_by_value runtime testcase. It checks that SWIG handles // return by value okay. import ret_by_value.*; public class ret_by_value_runme { static { try { System.loadLibrary("ret_by_value"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Get the test class. Note that this constructor will ensure that the memory created // in the wrapper is owned by the test class. test tst = ret_by_value.get_test(); if (tst.getMyInt() != 100 || tst.getMyShort() != 200) { System.err.println("Runtime test failed. myInt=" + tst.getMyInt() + " myShort=" + tst.getMyShort()); System.exit(1); } // Delete memory manually, it should not be deleted again by the test class finalizer tst.delete(); } } swig-3.0.2/Examples/test-suite/java/cpp11_constexpr_runme.java0000664000175000017500000000165212343605122024256 0ustar williamwilliamimport cpp11_constexpr.*; public class cpp11_constexpr_runme { static { try { System.loadLibrary("cpp11_constexpr"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } private static void check(int received, int expected) { if (expected != received) throw new RuntimeException("check failed, expected: " + expected + " received: " + received); } public static void main(String argv[]) { check(cpp11_constexpr.getAAA(), 10); check(cpp11_constexpr.getBBB(), 20); check(cpp11_constexpr.CCC(), 30); check(cpp11_constexpr.DDD(), 40); ConstExpressions ce = new ConstExpressions(); check(ce.JJJ, 100); check(ce.KKK, 200); check(ce.LLL, 300); check(ce.MMM(), 400); check(ce.NNN(), 500); } } swig-3.0.2/Examples/test-suite/java/li_std_vector_runme.java0000664000175000017500000000243112343605122024061 0ustar williamwilliamimport li_std_vector.*; public class li_std_vector_runme { static { try { System.loadLibrary("li_std_vector"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) throws Throwable { IntVector v1 = li_std_vector.vecintptr(new IntVector()); IntPtrVector v2 = li_std_vector.vecintptr(new IntPtrVector()); IntConstPtrVector v3 = li_std_vector.vecintconstptr(new IntConstPtrVector()); v1.add(123); if (v1.get(0) != 123) throw new RuntimeException("v1 test failed"); StructVector v4 = li_std_vector.vecstruct(new StructVector()); StructPtrVector v5 = li_std_vector.vecstructptr(new StructPtrVector()); StructConstPtrVector v6 = li_std_vector.vecstructconstptr(new StructConstPtrVector()); v4.add(new Struct(12)); v5.add(new Struct(34)); v6.add(new Struct(56)); Struct s = null; if (v4.get(0).getNum() != 12) throw new RuntimeException("v4 test failed"); if (v5.get(0).getNum() != 34) throw new RuntimeException("v5 test failed"); if (v6.get(0).getNum() != 56) throw new RuntimeException("v6 test failed"); } } swig-3.0.2/Examples/test-suite/java/using_pointers_runme.java0000664000175000017500000000142712343605122024275 0ustar williamwilliam import using_pointers.*; public class using_pointers_runme { static { try { System.loadLibrary("using_pointers"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { FooBar f = new FooBar(); boolean pass = true; try { f.exception_spec(1); pass = false; } catch (RuntimeException e) { } if (!pass) throw new RuntimeException("Missed exception 1"); try { f.exception_spec(2); pass = false; } catch (RuntimeException e) { } if (!pass) throw new RuntimeException("Missed exception 2"); } } swig-3.0.2/Examples/test-suite/java/overload_complicated_runme.java0000664000175000017500000000340612343605122025403 0ustar williamwilliam import overload_complicated.*; public class overload_complicated_runme { static { try { System.loadLibrary("overload_complicated"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { SWIGTYPE_p_int pInt = null; // Check the correct constructors are available Pop p = new Pop(pInt); p = new Pop(pInt, false); // Check overloaded in const only and pointers/references which target languages cannot disambiguate if (p.hip(false) != 701) throw new RuntimeException("Test 1 failed"); if (p.hip(pInt) != 702) throw new RuntimeException("Test 2 failed"); // Reverse the order for the above if (p.hop(pInt) != 805) throw new RuntimeException("Test 3 failed"); if (p.hop(false) != 801) throw new RuntimeException("Test 4 failed"); // Few more variations and order shuffled if (p.pop(false) != 901) throw new RuntimeException("Test 5 failed"); if (p.pop(pInt) != 902) throw new RuntimeException("Test 6 failed"); if (p.pop() != 905) throw new RuntimeException("Test 7 failed"); // Overload on const only if (p.bop(pInt) != 1001) throw new RuntimeException("Test 8 failed"); if (p.bip(pInt) != 2001) throw new RuntimeException("Test 9 failed"); // Globals if (overload_complicated.muzak(false) != 3001) throw new RuntimeException("Test 10 failed"); if (overload_complicated.muzak(pInt) != 3002) throw new RuntimeException("Test 11 failed"); } } swig-3.0.2/Examples/test-suite/java/README0000664000175000017500000000107612343605122020034 0ustar williamwilliamSee ../README for common README file. The Java implementation of the test-suite is a little different to the other languages in that all of SWIG's output goes into a subdirectory named after the individual test case. This is so that all the shadow classes can be compiled as Java classes which have to go into separate files. Otherwise the Makefile wouldn't know which .java files would be relevant to the testcase. For this to work the testcase must go into a Java package. Any testcases which have _runme.java appended after the testcase name will be detected and run. swig-3.0.2/Examples/test-suite/java/nested_structs_runme.java0000664000175000017500000000330312343605122024271 0ustar williamwilliam import nested_structs.*; public class nested_structs_runme { static { try { System.loadLibrary("nested_structs"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { Outer outer = new Outer(); nested_structs.setValues(outer, 10); Outer_inner1 inner1 = outer.getInner1(); Outer_inner1 inner2 = outer.getInner2(); Outer_inner1 inner3 = outer.getInner3(); Outer_inner1 inner4 = outer.getInner4(); if (inner1.getVal() != 10) throw new RuntimeException("failed inner1"); if (inner2.getVal() != 20) throw new RuntimeException("failed inner2"); if (inner3.getVal() != 20) throw new RuntimeException("failed inner3"); if (inner4.getVal() != 40) throw new RuntimeException("failed inner4"); Named inside1 = outer.getInside1(); Named inside2 = outer.getInside2(); Named inside3 = outer.getInside3(); Named inside4 = outer.getInside4(); if (inside1.getVal() != 100) throw new RuntimeException("failed inside1"); if (inside2.getVal() != 200) throw new RuntimeException("failed inside2"); if (inside3.getVal() != 200) throw new RuntimeException("failed inside3"); if (inside4.getVal() != 400) throw new RuntimeException("failed inside4"); outer.getInner1().setVal(11); if (inner1.getVal() != 11) throw new RuntimeException("failed inner1 assignment"); Named named = new Named(); named.setVal(22); outer.setInside2(named); if (outer.getInside2().getVal() != 22) throw new RuntimeException("failed inside2 assignment"); } } swig-3.0.2/Examples/test-suite/java/java_constants_runme.java0000664000175000017500000000140712343605122024240 0ustar williamwilliam import java_constants.*; public class java_constants_runme { static { try { System.loadLibrary("java_constants"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { int number = 200; // Switch statement will only compile if these constants are initialised // from a constant Java value, that is not from a function call switch(number) { case java_constants.CHINA: break; case java_constants.BRISTOLS: break; default: break; } } } swig-3.0.2/Examples/test-suite/java/java_director_runme.java0000664000175000017500000000503612343605122024041 0ustar williamwilliam// Mainly tests that directors are finalized correctly import java_director.*; public class java_director_runme { static { try { System.loadLibrary("java_director"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } private static void WaitForGC() { System.gc(); System.runFinalization(); try { java.lang.Thread.sleep(10); } catch (java.lang.InterruptedException e) { } } public static void main(String argv[]) { QuuxContainer qc = createContainer(); int instances = Quux.instances(); if (instances != 4) throw new RuntimeException("Quux instances should be 4, actually " + instances); for (int i = 0; i < qc.size(); ++i) { Quux q = qc.get(i); if (!q.director_method().equals(qc.invoke(i))) { throw new RuntimeException ( "q.director_method()/qv.invoke(" + i + ")"); } } qc = null; /* Watch qc get reaped, which causes the C++ object to delete objects from the internal vector */ { int countdown = 500; int expectedCount = 0; while (true) { WaitForGC(); if (--countdown == 0) break; if (Quux.instances() == expectedCount) break; }; int actualCount = Quux.instances(); if (actualCount != expectedCount) throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount); } /* Test Quux1's director disconnect method rename */ Quux1 quux1 = new Quux1("quux1"); if (quux1.disconnectMethodCalled) throw new RuntimeException("Oops"); quux1.delete(); if (!quux1.disconnectMethodCalled) throw new RuntimeException("disconnect method not called"); } public static QuuxContainer createContainer() { QuuxContainer qc = new QuuxContainer(); qc.push(new Quux("element 1")); qc.push(new java_director_MyQuux("element 2")); qc.push(new java_director_MyQuux("element 3")); qc.push(new Quux("element 4")); return qc; } } class java_director_MyQuux extends Quux { public java_director_MyQuux(String arg) { super(arg); } public String director_method() { return "java_director_MyQuux:" + member(); } } class java_director_JavaExceptionTest extends JavaExceptionTest { public java_director_JavaExceptionTest() { super(); } public void etest() throws Exception { super.etest(); } } swig-3.0.2/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java0000664000175000017500000011465012343605122026356 0ustar williamwilliam import enum_thorough_typeunsafe.*; public class enum_thorough_typeunsafe_runme { static { try { System.loadLibrary("enum_thorough_typeunsafe"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { { // Anonymous enums int i = enum_thorough_typeunsafe.AnonEnum1; if (enum_thorough_typeunsafe.ReallyAnInteger != 200) throw new RuntimeException("Test Anon 1 failed"); int j = enum_thorough_typeunsafe.AnonSpaceEnum1; int k = AnonStruct.AnonStructEnum1; } { int red = colour.red; enum_thorough_typeunsafe.colourTest1(red); enum_thorough_typeunsafe.colourTest2(red); enum_thorough_typeunsafe.colourTest3(red); enum_thorough_typeunsafe.colourTest4(red); enum_thorough_typeunsafe.setMyColour(red); } { SpeedClass s = new SpeedClass(); int speed = SpeedClass.speed.slow; if (s.speedTest1(speed) != speed) throw new RuntimeException("speedTest 1 failed"); if (s.speedTest2(speed) != speed) throw new RuntimeException("speedTest 2 failed"); if (s.speedTest3(speed) != speed) throw new RuntimeException("speedTest 3 failed"); if (s.speedTest4(speed) != speed) throw new RuntimeException("speedTest 4 failed"); if (s.speedTest5(speed) != speed) throw new RuntimeException("speedTest 5 failed"); if (s.speedTest6(speed) != speed) throw new RuntimeException("speedTest 6 failed"); if (s.speedTest7(speed) != speed) throw new RuntimeException("speedTest 7 failed"); if (s.speedTest8(speed) != speed) throw new RuntimeException("speedTest 8 failed"); if (enum_thorough_typeunsafe.speedTest1(speed) != speed) throw new RuntimeException("speedTest Global 1 failed"); if (enum_thorough_typeunsafe.speedTest2(speed) != speed) throw new RuntimeException("speedTest Global 2 failed"); if (enum_thorough_typeunsafe.speedTest3(speed) != speed) throw new RuntimeException("speedTest Global 3 failed"); if (enum_thorough_typeunsafe.speedTest4(speed) != speed) throw new RuntimeException("speedTest Global 4 failed"); if (enum_thorough_typeunsafe.speedTest5(speed) != speed) throw new RuntimeException("speedTest Global 5 failed"); } { SpeedClass s = new SpeedClass(); int slow = SpeedClass.speed.slow; int lightning = SpeedClass.speed.lightning; if (s.getMySpeedtd1() != slow) throw new RuntimeException("mySpeedtd1 1 failed"); if (s.getMySpeedtd1() != 10) throw new RuntimeException("mySpeedtd1 2 failed"); s.setMySpeedtd1(lightning); if (s.getMySpeedtd1() != lightning) throw new RuntimeException("mySpeedtd1 3 failed"); if (s.getMySpeedtd1() != 31) throw new RuntimeException("mySpeedtd1 4 failed"); } { if (enum_thorough_typeunsafe.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new RuntimeException("namedanonTest 1 failed"); } { int val = twonames.TwoNames2; if (enum_thorough_typeunsafe.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed"); if (enum_thorough_typeunsafe.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed"); if (enum_thorough_typeunsafe.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed"); } { TwoNamesStruct t = new TwoNamesStruct(); int val = TwoNamesStruct.twonames.TwoNamesStruct1; if (t.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed"); if (t.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed"); if (t.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed"); } { int val = namedanonspace.NamedAnonSpace2; if (enum_thorough_typeunsafe.namedanonspaceTest1(val) != val) throw new RuntimeException("namedanonspaceTest 1 failed"); if (enum_thorough_typeunsafe.namedanonspaceTest2(val) != val) throw new RuntimeException("namedanonspaceTest 2 failed"); if (enum_thorough_typeunsafe.namedanonspaceTest3(val) != val) throw new RuntimeException("namedanonspaceTest 3 failed"); if (enum_thorough_typeunsafe.namedanonspaceTest4(val) != val) throw new RuntimeException("namedanonspaceTest 4 failed"); } { TemplateClassInt t = new TemplateClassInt(); int galileo = TemplateClassInt.scientists.galileo; if (t.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest 1 failed"); if (t.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest 2 failed"); if (t.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest 3 failed"); if (t.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest 4 failed"); if (t.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest 5 failed"); if (t.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest 6 failed"); if (t.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest 7 failed"); if (t.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest 8 failed"); if (t.scientistsTest9(galileo) != galileo) throw new RuntimeException("scientistsTest 9 failed"); // if (t.scientistsTestA(galileo) != galileo) throw new RuntimeException("scientistsTest A failed"); if (t.scientistsTestB(galileo) != galileo) throw new RuntimeException("scientistsTest B failed"); // if (t.scientistsTestC(galileo) != galileo) throw new RuntimeException("scientistsTest C failed"); if (t.scientistsTestD(galileo) != galileo) throw new RuntimeException("scientistsTest D failed"); if (t.scientistsTestE(galileo) != galileo) throw new RuntimeException("scientistsTest E failed"); if (t.scientistsTestF(galileo) != galileo) throw new RuntimeException("scientistsTest F failed"); if (t.scientistsTestG(galileo) != galileo) throw new RuntimeException("scientistsTest G failed"); if (t.scientistsTestH(galileo) != galileo) throw new RuntimeException("scientistsTest H failed"); if (t.scientistsTestI(galileo) != galileo) throw new RuntimeException("scientistsTest I failed"); if (t.scientistsTestJ(galileo) != galileo) throw new RuntimeException("scientistsTest J failed"); if (enum_thorough_typeunsafe.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest Global 1 failed"); if (enum_thorough_typeunsafe.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest Global 2 failed"); if (enum_thorough_typeunsafe.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest Global 3 failed"); if (enum_thorough_typeunsafe.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest Global 4 failed"); if (enum_thorough_typeunsafe.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest Global 5 failed"); if (enum_thorough_typeunsafe.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest Global 6 failed"); if (enum_thorough_typeunsafe.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest Global 7 failed"); if (enum_thorough_typeunsafe.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest Global 8 failed"); } { TClassInt t = new TClassInt(); int bell = TClassInt.scientists.bell; int galileo = TemplateClassInt.scientists.galileo; if (t.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest 1 failed"); if (t.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest 2 failed"); if (t.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest 3 failed"); if (t.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest 4 failed"); if (t.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest 5 failed"); if (t.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest 6 failed"); if (t.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest 7 failed"); if (t.scientistsNameTest8(bell) != bell) throw new RuntimeException("scientistsNameTest 8 failed"); if (t.scientistsNameTest9(bell) != bell) throw new RuntimeException("scientistsNameTest 9 failed"); // if (t.scientistsNameTestA(bell) != bell) throw new RuntimeException("scientistsNameTest A failed"); if (t.scientistsNameTestB(bell) != bell) throw new RuntimeException("scientistsNameTest B failed"); // if (t.scientistsNameTestC(bell) != bell) throw new RuntimeException("scientistsNameTest C failed"); if (t.scientistsNameTestD(bell) != bell) throw new RuntimeException("scientistsNameTest D failed"); if (t.scientistsNameTestE(bell) != bell) throw new RuntimeException("scientistsNameTest E failed"); if (t.scientistsNameTestF(bell) != bell) throw new RuntimeException("scientistsNameTest F failed"); if (t.scientistsNameTestG(bell) != bell) throw new RuntimeException("scientistsNameTest G failed"); if (t.scientistsNameTestH(bell) != bell) throw new RuntimeException("scientistsNameTest H failed"); if (t.scientistsNameTestI(bell) != bell) throw new RuntimeException("scientistsNameTest I failed"); if (t.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 1 failed"); if (t.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 2 failed"); if (t.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 3 failed"); if (t.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 4 failed"); if (t.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 5 failed"); if (t.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 6 failed"); if (t.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 7 failed"); if (t.scientistsOtherTest1(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 1 failed"); if (t.scientistsOtherTest2(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 2 failed"); if (t.scientistsOtherTest3(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 3 failed"); if (t.scientistsOtherTest4(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 4 failed"); if (t.scientistsOtherTest5(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 5 failed"); if (t.scientistsOtherTest6(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 6 failed"); if (t.scientistsOtherTest7(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 7 failed"); if (enum_thorough_typeunsafe.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest Global 1 failed"); if (enum_thorough_typeunsafe.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest Global 2 failed"); if (enum_thorough_typeunsafe.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest Global 3 failed"); if (enum_thorough_typeunsafe.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest Global 4 failed"); if (enum_thorough_typeunsafe.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest Global 5 failed"); if (enum_thorough_typeunsafe.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest Global 6 failed"); if (enum_thorough_typeunsafe.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest Global 7 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 1 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 2 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 3 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 4 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 5 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 6 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 7 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTest8(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 8 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTest9(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 9 failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestA(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global A failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestB(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global B failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestC(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global C failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestD(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global D failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestE(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global E failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestF(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global F failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestG(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global G failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestH(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global H failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestI(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global I failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestJ(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global J failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestK(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global K failed"); if (enum_thorough_typeunsafe.scientistsNameSpaceTestL(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global L failed"); } { int val = newname.argh; if (enum_thorough_typeunsafe.renameTest1(val) != val) throw new RuntimeException("renameTest Global 1 failed"); if (enum_thorough_typeunsafe.renameTest2(val) != val) throw new RuntimeException("renameTest Global 2 failed"); } { NewNameStruct n = new NewNameStruct(); if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest 1 failed"); if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest 2 failed"); if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new RuntimeException("renameTest 3 failed"); if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest 4 failed"); if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest 5 failed"); if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new RuntimeException("renameTest 6 failed"); } { if (enum_thorough_typeunsafe.renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest Global 3 failed"); if (enum_thorough_typeunsafe.renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new RuntimeException("renameTest Global 4 failed"); if (enum_thorough_typeunsafe.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest Global 5 failed"); if (enum_thorough_typeunsafe.renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest Global 6 failed"); if (enum_thorough_typeunsafe.renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new RuntimeException("renameTest Global 7 failed"); } { TreesClass t = new TreesClass(); int pine = TreesClass.trees.pine; if (t.treesTest1(pine) != pine) throw new RuntimeException("treesTest 1 failed"); if (t.treesTest2(pine) != pine) throw new RuntimeException("treesTest 2 failed"); if (t.treesTest3(pine) != pine) throw new RuntimeException("treesTest 3 failed"); if (t.treesTest4(pine) != pine) throw new RuntimeException("treesTest 4 failed"); if (t.treesTest5(pine) != pine) throw new RuntimeException("treesTest 5 failed"); if (t.treesTest6(pine) != pine) throw new RuntimeException("treesTest 6 failed"); if (t.treesTest7(pine) != pine) throw new RuntimeException("treesTest 7 failed"); if (t.treesTest8(pine) != pine) throw new RuntimeException("treesTest 8 failed"); if (t.treesTest9(pine) != pine) throw new RuntimeException("treesTest 9 failed"); if (t.treesTestA(pine) != pine) throw new RuntimeException("treesTest A failed"); if (t.treesTestB(pine) != pine) throw new RuntimeException("treesTest B failed"); if (t.treesTestC(pine) != pine) throw new RuntimeException("treesTest C failed"); if (t.treesTestD(pine) != pine) throw new RuntimeException("treesTest D failed"); if (t.treesTestE(pine) != pine) throw new RuntimeException("treesTest E failed"); if (t.treesTestF(pine) != pine) throw new RuntimeException("treesTest F failed"); if (t.treesTestG(pine) != pine) throw new RuntimeException("treesTest G failed"); if (t.treesTestH(pine) != pine) throw new RuntimeException("treesTest H failed"); if (t.treesTestI(pine) != pine) throw new RuntimeException("treesTest I failed"); if (t.treesTestJ(pine) != pine) throw new RuntimeException("treesTest J failed"); if (t.treesTestK(pine) != pine) throw new RuntimeException("treesTest K failed"); if (t.treesTestL(pine) != pine) throw new RuntimeException("treesTest L failed"); if (t.treesTestM(pine) != pine) throw new RuntimeException("treesTest M failed"); if (t.treesTestN(pine) != pine) throw new RuntimeException("treesTest N failed"); if (t.treesTestO(pine) != pine) throw new RuntimeException("treesTest O failed"); if (enum_thorough_typeunsafe.treesTest1(pine) != pine) throw new RuntimeException("treesTest Global 1 failed"); if (enum_thorough_typeunsafe.treesTest2(pine) != pine) throw new RuntimeException("treesTest Global 2 failed"); if (enum_thorough_typeunsafe.treesTest3(pine) != pine) throw new RuntimeException("treesTest Global 3 failed"); if (enum_thorough_typeunsafe.treesTest4(pine) != pine) throw new RuntimeException("treesTest Global 4 failed"); if (enum_thorough_typeunsafe.treesTest5(pine) != pine) throw new RuntimeException("treesTest Global 5 failed"); if (enum_thorough_typeunsafe.treesTest6(pine) != pine) throw new RuntimeException("treesTest Global 6 failed"); if (enum_thorough_typeunsafe.treesTest7(pine) != pine) throw new RuntimeException("treesTest Global 7 failed"); if (enum_thorough_typeunsafe.treesTest8(pine) != pine) throw new RuntimeException("treesTest Global 8 failed"); if (enum_thorough_typeunsafe.treesTest9(pine) != pine) throw new RuntimeException("treesTest Global 9 failed"); if (enum_thorough_typeunsafe.treesTestA(pine) != pine) throw new RuntimeException("treesTest Global A failed"); if (enum_thorough_typeunsafe.treesTestB(pine) != pine) throw new RuntimeException("treesTest Global B failed"); if (enum_thorough_typeunsafe.treesTestC(pine) != pine) throw new RuntimeException("treesTest Global C failed"); if (enum_thorough_typeunsafe.treesTestD(pine) != pine) throw new RuntimeException("treesTest Global D failed"); if (enum_thorough_typeunsafe.treesTestE(pine) != pine) throw new RuntimeException("treesTest Global E failed"); if (enum_thorough_typeunsafe.treesTestF(pine) != pine) throw new RuntimeException("treesTest Global F failed"); if (enum_thorough_typeunsafe.treesTestG(pine) != pine) throw new RuntimeException("treesTest Global G failed"); if (enum_thorough_typeunsafe.treesTestH(pine) != pine) throw new RuntimeException("treesTest Global H failed"); if (enum_thorough_typeunsafe.treesTestI(pine) != pine) throw new RuntimeException("treesTest Global I failed"); if (enum_thorough_typeunsafe.treesTestJ(pine) != pine) throw new RuntimeException("treesTest Global J failed"); if (enum_thorough_typeunsafe.treesTestK(pine) != pine) throw new RuntimeException("treesTest Global K failed"); if (enum_thorough_typeunsafe.treesTestL(pine) != pine) throw new RuntimeException("treesTest Global L failed"); if (enum_thorough_typeunsafe.treesTestM(pine) != pine) throw new RuntimeException("treesTest Global M failed"); // if (enum_thorough_typeunsafe.treesTestN(pine) != pine) throw new RuntimeException("treesTest Global N failed"); if (enum_thorough_typeunsafe.treesTestO(pine) != pine) throw new RuntimeException("treesTest Global O failed"); if (enum_thorough_typeunsafe.treesTestP(pine) != pine) throw new RuntimeException("treesTest Global P failed"); if (enum_thorough_typeunsafe.treesTestQ(pine) != pine) throw new RuntimeException("treesTest Global Q failed"); if (enum_thorough_typeunsafe.treesTestR(pine) != pine) throw new RuntimeException("treesTest Global R failed"); } { HairStruct h = new HairStruct(); int ginger = HairStruct.hair.ginger; if (h.hairTest1(ginger) != ginger) throw new RuntimeException("hairTest 1 failed"); if (h.hairTest2(ginger) != ginger) throw new RuntimeException("hairTest 2 failed"); if (h.hairTest3(ginger) != ginger) throw new RuntimeException("hairTest 3 failed"); if (h.hairTest4(ginger) != ginger) throw new RuntimeException("hairTest 4 failed"); if (h.hairTest5(ginger) != ginger) throw new RuntimeException("hairTest 5 failed"); if (h.hairTest6(ginger) != ginger) throw new RuntimeException("hairTest 6 failed"); if (h.hairTest7(ginger) != ginger) throw new RuntimeException("hairTest 7 failed"); if (h.hairTest8(ginger) != ginger) throw new RuntimeException("hairTest 8 failed"); if (h.hairTest9(ginger) != ginger) throw new RuntimeException("hairTest 9 failed"); if (h.hairTestA(ginger) != ginger) throw new RuntimeException("hairTest A failed"); if (h.hairTestB(ginger) != ginger) throw new RuntimeException("hairTest B failed"); int red = colour.red; if (h.colourTest1(red) != red) throw new RuntimeException("colourTest HairStruct 1 failed"); if (h.colourTest2(red) != red) throw new RuntimeException("colourTest HairStruct 2 failed"); if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new RuntimeException("namedanonTest HairStruct 1 failed"); if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new RuntimeException("namedanonspaceTest HairStruct 1 failed"); int fir = TreesClass.trees.fir; if (h.treesGlobalTest1(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 1 failed"); if (h.treesGlobalTest2(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 2 failed"); if (h.treesGlobalTest3(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 3 failed"); if (h.treesGlobalTest4(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 4 failed"); } { int blonde = HairStruct.hair.blonde; if (enum_thorough_typeunsafe.hairTest1(blonde) != blonde) throw new RuntimeException("hairTest Global 1 failed"); if (enum_thorough_typeunsafe.hairTest2(blonde) != blonde) throw new RuntimeException("hairTest Global 2 failed"); if (enum_thorough_typeunsafe.hairTest3(blonde) != blonde) throw new RuntimeException("hairTest Global 3 failed"); if (enum_thorough_typeunsafe.hairTest4(blonde) != blonde) throw new RuntimeException("hairTest Global 4 failed"); if (enum_thorough_typeunsafe.hairTest5(blonde) != blonde) throw new RuntimeException("hairTest Global 5 failed"); if (enum_thorough_typeunsafe.hairTest6(blonde) != blonde) throw new RuntimeException("hairTest Global 6 failed"); if (enum_thorough_typeunsafe.hairTest7(blonde) != blonde) throw new RuntimeException("hairTest Global 7 failed"); if (enum_thorough_typeunsafe.hairTest8(blonde) != blonde) throw new RuntimeException("hairTest Global 8 failed"); if (enum_thorough_typeunsafe.hairTest9(blonde) != blonde) throw new RuntimeException("hairTest Global 9 failed"); if (enum_thorough_typeunsafe.hairTestA(blonde) != blonde) throw new RuntimeException("hairTest Global A failed"); if (enum_thorough_typeunsafe.hairTestB(blonde) != blonde) throw new RuntimeException("hairTest Global B failed"); if (enum_thorough_typeunsafe.hairTestC(blonde) != blonde) throw new RuntimeException("hairTest Global C failed"); if (enum_thorough_typeunsafe.hairTestA1(blonde) != blonde) throw new RuntimeException("hairTest Global A1 failed"); if (enum_thorough_typeunsafe.hairTestA2(blonde) != blonde) throw new RuntimeException("hairTest Global A2 failed"); if (enum_thorough_typeunsafe.hairTestA3(blonde) != blonde) throw new RuntimeException("hairTest Global A3 failed"); if (enum_thorough_typeunsafe.hairTestA4(blonde) != blonde) throw new RuntimeException("hairTest Global A4 failed"); if (enum_thorough_typeunsafe.hairTestA5(blonde) != blonde) throw new RuntimeException("hairTest Global A5 failed"); if (enum_thorough_typeunsafe.hairTestA6(blonde) != blonde) throw new RuntimeException("hairTest Global A6 failed"); if (enum_thorough_typeunsafe.hairTestA7(blonde) != blonde) throw new RuntimeException("hairTest Global A7 failed"); if (enum_thorough_typeunsafe.hairTestA8(blonde) != blonde) throw new RuntimeException("hairTest Global A8 failed"); if (enum_thorough_typeunsafe.hairTestA9(blonde) != blonde) throw new RuntimeException("hairTest Global A9 failed"); if (enum_thorough_typeunsafe.hairTestAA(blonde) != blonde) throw new RuntimeException("hairTest Global AA failed"); if (enum_thorough_typeunsafe.hairTestAB(blonde) != blonde) throw new RuntimeException("hairTest Global AB failed"); if (enum_thorough_typeunsafe.hairTestAC(blonde) != blonde) throw new RuntimeException("hairTest Global AC failed"); if (enum_thorough_typeunsafe.hairTestB1(blonde) != blonde) throw new RuntimeException("hairTest Global B1 failed"); if (enum_thorough_typeunsafe.hairTestB2(blonde) != blonde) throw new RuntimeException("hairTest Global B2 failed"); if (enum_thorough_typeunsafe.hairTestB3(blonde) != blonde) throw new RuntimeException("hairTest Global B3 failed"); if (enum_thorough_typeunsafe.hairTestB4(blonde) != blonde) throw new RuntimeException("hairTest Global B4 failed"); if (enum_thorough_typeunsafe.hairTestB5(blonde) != blonde) throw new RuntimeException("hairTest Global B5 failed"); if (enum_thorough_typeunsafe.hairTestB6(blonde) != blonde) throw new RuntimeException("hairTest Global B6 failed"); if (enum_thorough_typeunsafe.hairTestB7(blonde) != blonde) throw new RuntimeException("hairTest Global B7 failed"); if (enum_thorough_typeunsafe.hairTestB8(blonde) != blonde) throw new RuntimeException("hairTest Global B8 failed"); if (enum_thorough_typeunsafe.hairTestB9(blonde) != blonde) throw new RuntimeException("hairTest Global B9 failed"); if (enum_thorough_typeunsafe.hairTestBA(blonde) != blonde) throw new RuntimeException("hairTest Global BA failed"); if (enum_thorough_typeunsafe.hairTestBB(blonde) != blonde) throw new RuntimeException("hairTest Global BB failed"); if (enum_thorough_typeunsafe.hairTestBC(blonde) != blonde) throw new RuntimeException("hairTest Global BC failed"); if (enum_thorough_typeunsafe.hairTestC1(blonde) != blonde) throw new RuntimeException("hairTest Global C1 failed"); if (enum_thorough_typeunsafe.hairTestC2(blonde) != blonde) throw new RuntimeException("hairTest Global C2 failed"); if (enum_thorough_typeunsafe.hairTestC3(blonde) != blonde) throw new RuntimeException("hairTest Global C3 failed"); if (enum_thorough_typeunsafe.hairTestC4(blonde) != blonde) throw new RuntimeException("hairTest Global C4 failed"); if (enum_thorough_typeunsafe.hairTestC5(blonde) != blonde) throw new RuntimeException("hairTest Global C5 failed"); if (enum_thorough_typeunsafe.hairTestC6(blonde) != blonde) throw new RuntimeException("hairTest Global C6 failed"); if (enum_thorough_typeunsafe.hairTestC7(blonde) != blonde) throw new RuntimeException("hairTest Global C7 failed"); if (enum_thorough_typeunsafe.hairTestC8(blonde) != blonde) throw new RuntimeException("hairTest Global C8 failed"); if (enum_thorough_typeunsafe.hairTestC9(blonde) != blonde) throw new RuntimeException("hairTest Global C9 failed"); if (enum_thorough_typeunsafe.hairTestCA(blonde) != blonde) throw new RuntimeException("hairTest Global CA failed"); if (enum_thorough_typeunsafe.hairTestCB(blonde) != blonde) throw new RuntimeException("hairTest Global CB failed"); if (enum_thorough_typeunsafe.hairTestCC(blonde) != blonde) throw new RuntimeException("hairTest Global CC failed"); } { FirStruct f = new FirStruct(); int blonde = HairStruct.hair.blonde; if (f.hairTestFir1(blonde) != blonde) throw new RuntimeException("hairTestFir 1 failed"); if (f.hairTestFir2(blonde) != blonde) throw new RuntimeException("hairTestFir 2 failed"); if (f.hairTestFir3(blonde) != blonde) throw new RuntimeException("hairTestFir 3 failed"); if (f.hairTestFir4(blonde) != blonde) throw new RuntimeException("hairTestFir 4 failed"); if (f.hairTestFir5(blonde) != blonde) throw new RuntimeException("hairTestFir 5 failed"); if (f.hairTestFir6(blonde) != blonde) throw new RuntimeException("hairTestFir 6 failed"); if (f.hairTestFir7(blonde) != blonde) throw new RuntimeException("hairTestFir 7 failed"); if (f.hairTestFir8(blonde) != blonde) throw new RuntimeException("hairTestFir 8 failed"); if (f.hairTestFir9(blonde) != blonde) throw new RuntimeException("hairTestFir 9 failed"); if (f.hairTestFirA(blonde) != blonde) throw new RuntimeException("hairTestFir A failed"); } { enum_thorough_typeunsafe.setGlobalInstance(enum_thorough_typeunsafe.globalinstance2); if (enum_thorough_typeunsafe.getGlobalInstance() != enum_thorough_typeunsafe.globalinstance2) throw new RuntimeException("GlobalInstance 1 failed"); Instances i = new Instances(); i.setMemberInstance(Instances.memberinstance3); if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed"); } // ignore enum item tests start { if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new RuntimeException("ignoreATest 0 failed"); if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new RuntimeException("ignoreATest 3 failed"); if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new RuntimeException("ignoreATest 10 failed"); if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new RuntimeException("ignoreATest 11 failed"); if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new RuntimeException("ignoreATest 13 failed"); if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new RuntimeException("ignoreATest 14 failed"); if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new RuntimeException("ignoreATest 20 failed"); if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new RuntimeException("ignoreATest 30 failed"); if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new RuntimeException("ignoreATest 32 failed"); if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new RuntimeException("ignoreATest 33 failed"); } { if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new RuntimeException("ignoreBTest 11 failed"); if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new RuntimeException("ignoreBTest 12 failed"); if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new RuntimeException("ignoreBTest 31 failed"); if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new RuntimeException("ignoreBTest 32 failed"); if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new RuntimeException("ignoreBTest 41 failed"); if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new RuntimeException("ignoreBTest 42 failed"); } { if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new RuntimeException("ignoreCTest 10 failed"); if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new RuntimeException("ignoreCTest 12 failed"); if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new RuntimeException("ignoreCTest 30 failed"); if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new RuntimeException("ignoreCTest 32 failed"); if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new RuntimeException("ignoreCTest 40 failed"); if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new RuntimeException("ignoreCTest 42 failed"); } { if (enum_thorough_typeunsafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new RuntimeException("ignoreDTest 21 failed"); if (enum_thorough_typeunsafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new RuntimeException("ignoreDTest 22 failed"); } { if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new RuntimeException("ignoreETest 0 failed"); if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new RuntimeException("ignoreETest 21 failed"); if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new RuntimeException("ignoreETest 22 failed"); } // ignore enum item tests end { if (enum_thorough_typeunsafe.repeatTest(repeat.one) != 1) throw new RuntimeException("repeatTest 1 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.initial) != 1) throw new RuntimeException("repeatTest 2 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.two) != 2) throw new RuntimeException("repeatTest 3 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.three) != 3) throw new RuntimeException("repeatTest 4 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed"); } // different types { if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeint) != 10) throw new RuntimeException("differentTypes 1 failed"); if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed"); if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed"); if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed"); if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed"); if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed"); int global_enum = enum_thorough_typeunsafe.global_typeint; if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed"); global_enum = enum_thorough_typeunsafe.global_typeboolfalse; if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed"); global_enum = enum_thorough_typeunsafe.global_typebooltrue; if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed"); global_enum = enum_thorough_typeunsafe.global_typebooltwo; if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed"); global_enum = enum_thorough_typeunsafe.global_typechar; if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed"); global_enum = enum_thorough_typeunsafe.global_typedefaultint; if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed"); } } } swig-3.0.2/Examples/test-suite/java/inherit_target_language_runme.java0000664000175000017500000000162712343605122026102 0ustar williamwilliam import inherit_target_language.*; public class inherit_target_language_runme { static { try { System.loadLibrary("inherit_target_language"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { new Derived1().targetLanguageBaseMethod(); new Derived2().targetLanguageBaseMethod(); new MultipleDerived1().targetLanguageBaseMethod(); new MultipleDerived2().targetLanguageBaseMethod(); new MultipleDerived3().f(); new MultipleDerived4().g(); BaseX baseX = new BaseX(); baseX.basex(); baseX.targetLanguageBase2Method(); DerivedX derivedX = new DerivedX(); derivedX.basex(); derivedX.derivedx(); derivedX.targetLanguageBase2Method(); } } swig-3.0.2/Examples/test-suite/java/java_throws_runme.java0000664000175000017500000000601412343605122023551 0ustar williamwilliam import java_throws.*; public class java_throws_runme { static { try { System.loadLibrary("java_throws"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Check the exception classes in the main typemaps boolean pass = false; // This won't compile unless all of these exceptions are in the throw clause try { short s = java_throws.full_of_exceptions(10); } catch (ClassNotFoundException e) {} catch (NoSuchFieldException e) { pass = true; } catch (InstantiationException e) {} catch (CloneNotSupportedException e) {} catch (IllegalAccessException e) {} if (!pass) throw new RuntimeException("Test 1 failed"); // Check the exception class in the throw typemap pass = false; try { java_throws.throw_spec_function(100); } catch (IllegalAccessException e) { pass = true; } if (!pass) throw new RuntimeException("Test 2 failed"); // Check the exception class is used with %catches pass = false; try { java_throws.catches_function(100); } catch (IllegalAccessException e) { pass = true; } if (!pass) throw new RuntimeException("Test 3 failed"); // Check newfree typemap throws attribute try { TestClass tc = java_throws.makeTestClass(); } catch (NoSuchMethodException e) {} // Check javaout typemap throws attribute pass = false; try { int myInt = java_throws.ioTest(); } catch (java.io.IOException e) { pass = true; } if (!pass) throw new RuntimeException("Test 4 failed"); // Check except feature throws attribute... // Static method pass = false; try { FeatureTest.staticMethod(); } catch (MyException e) { pass = true; } if (!pass) throw new RuntimeException("Test 5 failed"); FeatureTest f = null; try { f = new FeatureTest(); } catch (MyException e) {} // Instance method pass = false; try { f.method(); } catch (MyException e) { pass = true; } if (!pass) throw new RuntimeException("Test 6 failed"); // Global function pass = false; try { java_throws.globalFunction(10); } catch (MyException e) { pass = true; } catch (ClassNotFoundException e) {} catch (NoSuchFieldException e) {} if (!pass) throw new RuntimeException("Test 7 failed"); // Test %nojavaexception NoExceptTest net = new NoExceptTest(); pass = false; try { net.exceptionPlease(); pass = true; } catch (MyException e) {} if (!pass) throw new RuntimeException("Test 8 failed"); net.noExceptionPlease(); } } swig-3.0.2/Examples/test-suite/java/java_lib_arrays_dimensionless_runme.java0000664000175000017500000001077212343605122027314 0ustar williamwilliam import java_lib_arrays_dimensionless.*; public class java_lib_arrays_dimensionless_runme { static { try { System.loadLibrary("java_lib_arrays_dimensionless"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { boolean bools[] = {true, false, true, false, true}; byte schars[] = {5, 10, 15, 20, 25}; short uchars[] = {5, 10, 15, 20, 25}; short shorts[] = {5, 10, 15, 20, 25}; int ushorts[] = {5, 10, 15, 20, 25}; int ints[] = {5, 10, 15, 20, 25}; long uints[] = {5, 10, 15, 20, 25}; int longs[] = {5, 10, 15, 20, 25}; long ulongs[] = {5, 10, 15, 20, 25}; long lls[] = {5, 10, 15, 20, 25}; //java.math.BigInteger ulls[] = {5, 10, 15, 20, 25}; float floats[] = {5, 10, 15, 20, 25}; double doubles[] = {5, 10, 15, 20, 25}; if (java_lib_arrays_dimensionless.arr_bool(bools, bools.length) != 3) throw new RuntimeException("test bools 1 failed"); if (java_lib_arrays_dimensionless.ptr_bool(bools, bools.length) != 2) throw new RuntimeException("test bools 2 failed"); // if (java_lib_arrays_dimensionless.arr_char(chars, chars.length) != 75) throw new RuntimeException("test chars 1 failed"); // if (java_lib_arrays_dimensionless.ptr_char(chars, chars.length) != 150) throw new RuntimeException("test chars 2 failed"); if (java_lib_arrays_dimensionless.arr_schar(schars, schars.length) != 75) throw new RuntimeException("test schars 1 failed"); if (java_lib_arrays_dimensionless.ptr_schar(schars, schars.length) != 150) throw new RuntimeException("test schars 2 failed"); if (java_lib_arrays_dimensionless.arr_uchar(uchars, uchars.length) != 75) throw new RuntimeException("test uchars 1 failed"); if (java_lib_arrays_dimensionless.ptr_uchar(uchars, uchars.length) != 150) throw new RuntimeException("test uchars 2 failed"); if (java_lib_arrays_dimensionless.arr_short(shorts, shorts.length) != 75) throw new RuntimeException("test shorts 1 failed"); if (java_lib_arrays_dimensionless.ptr_short(shorts, shorts.length) != 150) throw new RuntimeException("test shorts 2 failed"); if (java_lib_arrays_dimensionless.arr_ushort(ushorts, ushorts.length) != 75) throw new RuntimeException("test ushorts 1 failed"); if (java_lib_arrays_dimensionless.ptr_ushort(ushorts, ushorts.length) != 150) throw new RuntimeException("test ushorts 2 failed"); if (java_lib_arrays_dimensionless.arr_int(ints, ints.length) != 75) throw new RuntimeException("test ints 1 failed"); if (java_lib_arrays_dimensionless.ptr_int(ints, ints.length) != 150) throw new RuntimeException("test ints 2 failed"); if (java_lib_arrays_dimensionless.arr_uint(uints, uints.length) != 75) throw new RuntimeException("test uints 1 failed"); if (java_lib_arrays_dimensionless.ptr_uint(uints, uints.length) != 150) throw new RuntimeException("test uints 2 failed"); if (java_lib_arrays_dimensionless.arr_long(longs, longs.length) != 75) throw new RuntimeException("test longs 1 failed"); if (java_lib_arrays_dimensionless.ptr_long(longs, longs.length) != 150) throw new RuntimeException("test longs 2 failed"); if (java_lib_arrays_dimensionless.arr_ulong(ulongs, ulongs.length) != 75) throw new RuntimeException("test ulongs 1 failed"); if (java_lib_arrays_dimensionless.ptr_ulong(ulongs, ulongs.length) != 150) throw new RuntimeException("test ulongs 2 failed"); // if (java_lib_arrays_dimensionless.arr_ll(lls, lls.length) != 75) throw new RuntimeException("test lls 1 failed"); // if (java_lib_arrays_dimensionless.ptr_ll(lls, lls.length) != 150) throw new RuntimeException("test lls 2 failed"); // if (java_lib_arrays_dimensionless.arr_ull(ulls, ulls.length) != 75) throw new RuntimeException("test ulls 1 failed"); // if (java_lib_arrays_dimensionless.ptr_ull(ulls, ulls.length) != 150) throw new RuntimeException("test ulls 2 failed"); if (java_lib_arrays_dimensionless.arr_float(floats, floats.length) != 75) throw new RuntimeException("test floats 1 failed"); if (java_lib_arrays_dimensionless.ptr_float(floats, floats.length) != 150) throw new RuntimeException("test floats 2 failed"); if (java_lib_arrays_dimensionless.arr_double(doubles, doubles.length) != 75) throw new RuntimeException("test doubles 1 failed"); if (java_lib_arrays_dimensionless.ptr_double(doubles, doubles.length) != 150) throw new RuntimeException("test doubles 2 failed"); } } swig-3.0.2/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java0000664000175000017500000000543412343605122033220 0ustar williamwilliam import template_using_directive_and_declaration_forward.*; public class template_using_directive_and_declaration_forward_runme { static { try { System.loadLibrary("template_using_directive_and_declaration_forward"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { template_using_directive_and_declaration_forward.useit1(new Thing1Int()); template_using_directive_and_declaration_forward.useit1a(new Thing1Int()); template_using_directive_and_declaration_forward.useit1b(new Thing1Int()); template_using_directive_and_declaration_forward.useit1c(new Thing1Int()); //BROKEN template_using_directive_and_declaration_forward.useit2(new Thing2Int()); template_using_directive_and_declaration_forward.useit2a(new Thing2Int()); template_using_directive_and_declaration_forward.useit2b(new Thing2Int()); template_using_directive_and_declaration_forward.useit2c(new Thing2Int()); template_using_directive_and_declaration_forward.useit2d(new Thing2Int()); //BROKEN template_using_directive_and_declaration_forward.useit3(new Thing3Int()); template_using_directive_and_declaration_forward.useit3a(new Thing3Int()); template_using_directive_and_declaration_forward.useit3b(new Thing3Int()); template_using_directive_and_declaration_forward.useit3c(new Thing3Int()); template_using_directive_and_declaration_forward.useit3d(new Thing3Int()); //BROKEN template_using_directive_and_declaration_forward.useit4(new Thing4Int()); template_using_directive_and_declaration_forward.useit4a(new Thing4Int()); template_using_directive_and_declaration_forward.useit4b(new Thing4Int()); template_using_directive_and_declaration_forward.useit4c(new Thing4Int()); template_using_directive_and_declaration_forward.useit4d(new Thing4Int()); //BROKEN template_using_directive_and_declaration_forward.useit5(new Thing5Int()); template_using_directive_and_declaration_forward.useit5a(new Thing5Int()); template_using_directive_and_declaration_forward.useit5b(new Thing5Int()); template_using_directive_and_declaration_forward.useit5c(new Thing5Int()); template_using_directive_and_declaration_forward.useit5d(new Thing5Int()); //BROKEN template_using_directive_and_declaration_forward.useit7(new Thing7Int()); template_using_directive_and_declaration_forward.useit7a(new Thing7Int()); template_using_directive_and_declaration_forward.useit7b(new Thing7Int()); template_using_directive_and_declaration_forward.useit7c(new Thing7Int()); template_using_directive_and_declaration_forward.useit7d(new Thing7Int()); } } swig-3.0.2/Examples/test-suite/java/java_enums_runme.java0000664000175000017500000000276112343605122023357 0ustar williamwilliam import java_enums.*; public class java_enums_runme implements stuff { static { try { System.loadLibrary("java_enums"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { int number = 200; // Switch statement will only compile if these enums are initialised // from a constant Java value, that is not from a function call switch(number) { case stuff.FIDDLE: break; case stuff.STICKS: break; case stuff.BONGO: break; case stuff.DRUMS: break; default: break; } if (stuff.DRUMS != 15) throw new RuntimeException("Incorrect value for DRUMS"); // check typemaps use short for this enum short poppycock = nonsense.POPPYCOCK; short tst1 = java_enums.test1(poppycock); short tst2 = java_enums.test2(poppycock); // Check that stuff is an interface and not a class - we can drop the stuff keyword as this class implements the stuff interface switch(number) { case FIDDLE: break; case STICKS: break; case BONGO: break; case DRUMS: break; default: break; } } } swig-3.0.2/Examples/test-suite/java/template_namespace_forward_declaration_runme.java0000664000175000017500000000156412343605122031147 0ustar williamwilliam import template_namespace_forward_declaration.*; public class template_namespace_forward_declaration_runme { static { try { System.loadLibrary("template_namespace_forward_declaration"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { XXXInt xxx = new XXXInt(); template_namespace_forward_declaration.testXXX1(xxx); template_namespace_forward_declaration.testXXX2(xxx); template_namespace_forward_declaration.testXXX3(xxx); YYYInt yyy = new YYYInt(); template_namespace_forward_declaration.testYYY1(yyy); template_namespace_forward_declaration.testYYY2(yyy); template_namespace_forward_declaration.testYYY3(yyy); } } swig-3.0.2/Examples/test-suite/java/smart_pointer_const_overload_runme.java0000664000175000017500000000464112343605122027215 0ustar williamwilliamimport smart_pointer_const_overload.*; public class smart_pointer_const_overload_runme { static int CONST_ACCESS = 1; static int MUTABLE_ACCESS = 2; static { System.loadLibrary("smart_pointer_const_overload"); } public static void test(Bar b, Foo f) { Assert(f.getX() == 0); // Test member variable get Assert(b.getX() == 0); Assert(f.getAccess() == CONST_ACCESS); // Test member variable set b.setX(1); Assert(f.getX() == 1); Assert(f.getAccess() == MUTABLE_ACCESS); // Test const method Assert(b.getx() == 1); Assert(f.getAccess() == CONST_ACCESS); // Test mutable method b.setx(2); Assert(f.getX() == 2); Assert(f.getAccess() == MUTABLE_ACCESS); // Test extended const method Assert(b.getx2() == 2); Assert(f.getAccess() == CONST_ACCESS); // Test extended mutable method b.setx2(3); Assert(f.getX() == 3); Assert(f.getAccess() == MUTABLE_ACCESS); // Test static method b.stat(); Assert(f.getAccess() == CONST_ACCESS); // Test const member f.setAccess(MUTABLE_ACCESS); Assert(b.getY() == 0); Assert(f.getAccess() == CONST_ACCESS); // Test get through mutable pointer to const member f.setAccess(MUTABLE_ACCESS); Assert(smart_pointer_const_overload.get_int(b.getYp()) == 0); Assert(f.getAccess() == CONST_ACCESS); // Test get through const pointer to mutable member f.setX(4); f.setAccess(MUTABLE_ACCESS); Assert(smart_pointer_const_overload.get_int(b.getXp()) == 4); Assert(f.getAccess() == CONST_ACCESS); // Test set through const pointer to mutable member f.setAccess(MUTABLE_ACCESS); smart_pointer_const_overload.set_int(b.getXp(), 5); Assert(f.getX() == 5); Assert(f.getAccess() == CONST_ACCESS); // Test set pointer to const member b.setYp(smart_pointer_const_overload.new_int(6)); Assert(f.getY() == 0); Assert(smart_pointer_const_overload.get_int(f.getYp()) == 6); Assert(f.getAccess() == MUTABLE_ACCESS); smart_pointer_const_overload.delete_int(f.getYp()); } public static void main(String argv[]) { Foo f = new Foo(); Bar b = new Bar(f); //Foo f2 = new Foo(); //Bar b2 = new Bar2(f2); test(b, f); //test(b2, f2); } public static void Assert(boolean b) { if (!b) throw new RuntimeException("Assertion failed"); } } swig-3.0.2/Examples/test-suite/java/typemap_out_optimal_runme.java0000664000175000017500000000075312343605122025321 0ustar williamwilliam import typemap_out_optimal.*; public class typemap_out_optimal_runme { static { try { System.loadLibrary("typemap_out_optimal"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static XX x = null; public static void main(String argv[]) { XX.setDebug(false); x = XX.create(); } } swig-3.0.2/Examples/test-suite/java/member_pointer_runme.java0000664000175000017500000000352412343605122024234 0ustar williamwilliamimport member_pointer.*; public class member_pointer_runme { static { try { System.loadLibrary("member_pointer"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static SWIGTYPE_m_Shape__f_void__double memberPtr = null; public static void main(String argv[]) { // Get the pointers SWIGTYPE_m_Shape__f_void__double area_pt = member_pointer.areapt(); SWIGTYPE_m_Shape__f_void__double perim_pt = member_pointer.perimeterpt(); // Create some objects Square s = new Square(10); // Do some calculations check( "Square area ", 100.0, member_pointer.do_op(s,area_pt) ); check( "Square perim", 40.0, member_pointer.do_op(s,perim_pt) ); memberPtr = member_pointer.getAreavar(); memberPtr = member_pointer.getPerimetervar(); // Try the variables check( "Square area ", 100.0, member_pointer.do_op(s,member_pointer.getAreavar()) ); check( "Square perim", 40.0, member_pointer.do_op(s,member_pointer.getPerimetervar()) ); // Modify one of the variables member_pointer.setAreavar(perim_pt); check( "Square perimeter", 40.0, member_pointer.do_op(s,member_pointer.getAreavar()) ); // Try the constants memberPtr = member_pointer.AREAPT; memberPtr = member_pointer.PERIMPT; memberPtr = member_pointer.NULLPT; check( "Square area ", 100.0, member_pointer.do_op(s,member_pointer.AREAPT) ); check( "Square perim", 40.0, member_pointer.do_op(s,member_pointer.PERIMPT) ); } private static void check(String what, double expected, double actual) { if (expected != actual) throw new RuntimeException("Failed: " + what + " Expected: " + expected + " Actual: " + actual); } } swig-3.0.2/Examples/test-suite/java/java_lib_various_runme.java0000664000175000017500000000607612343605122024551 0ustar williamwilliam // Test case to check typemaps in various.i import java_lib_various.*; public class java_lib_various_runme { static { try { System.loadLibrary("java_lib_various"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // STRING_ARRAY typemap parameter String animals[] = {"Cat","Dog","Cow","Goat"}; if (java_lib_various.check_animals(animals) != 1) throw new RuntimeException("check_animals failed"); // STRING_ARRAY typemap return value String expected[] = { "Dave", "Mike", "Susan", "John", "Michelle" }; String got[] = java_lib_various.get_names(); for (int i=0; i= 0) { throw new RuntimeException("Failed. Val: " + d.getVal()); } } } class director_thread_Derived extends Foo { director_thread_Derived() { super(); } public void do_foo() { setVal(getVal() - 1); } } swig-3.0.2/Examples/test-suite/java/dynamic_cast_runme.java0000664000175000017500000000125712343605122023664 0ustar williamwilliam import dynamic_cast.*; public class dynamic_cast_runme { static { try { System.loadLibrary("dynamic_cast"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { Foo f = new Foo(); Bar b = new Bar(); Foo x = f.blah(); Foo y = b.blah(); // Note it is possible to downcast y with a Java cast. String a = dynamic_cast.do_test((Bar)y); if (!a.equals("Bar::test")) { throw new RuntimeException("Failed!"); } } } swig-3.0.2/Examples/test-suite/java/template_default_arg_runme.java0000664000175000017500000001231712343605122025375 0ustar williamwilliam import template_default_arg.*; public class template_default_arg_runme { static { try { System.loadLibrary("template_default_arg"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { { Hello_int helloInt = new Hello_int(); helloInt.foo(Hello_int.Hi.hi); } { X_int x = new X_int(); if (x.meth(20.0, 200) != 200) throw new RuntimeException("X_int test 1 failed"); if (x.meth(20) != 20) throw new RuntimeException("X_int test 2 failed"); if (x.meth() != 0) throw new RuntimeException("X_int test 3 failed"); } { Y_unsigned y = new Y_unsigned(); if (y.meth(20.0, 200) != 200) throw new RuntimeException("Y_unsigned test 1 failed"); if (y.meth(20) != 20) throw new RuntimeException("Y_unsigned test 2 failed"); if (y.meth() != 0) throw new RuntimeException("Y_unsigned test 3 failed"); } { X_longlong x = new X_longlong(); x = new X_longlong(20.0); x = new X_longlong(20.0, 200L); } { X_int x = new X_int(); x = new X_int(20.0); x = new X_int(20.0, 200); } { X_hello_unsigned x = new X_hello_unsigned(); x = new X_hello_unsigned(20.0); x = new X_hello_unsigned(20.0, new Hello_int()); } { Y_hello_unsigned y = new Y_hello_unsigned(); y.meth(20.0, new Hello_int()); y.meth(new Hello_int()); y.meth(); } { Foo_Z_8 fz = new Foo_Z_8(); X_Foo_Z_8 x = new X_Foo_Z_8(); Foo_Z_8 fzc = x.meth(fz); } // Templated functions { // plain function: int ott(Foo) if (template_default_arg.ott(new Foo_int()) != 30) throw new RuntimeException("ott test 1 failed"); // %template(ott) ott; if (template_default_arg.ott() != 10) throw new RuntimeException("ott test 2 failed"); if (template_default_arg.ott(1) != 10) throw new RuntimeException("ott test 3 failed"); if (template_default_arg.ott(1, 1) != 10) throw new RuntimeException("ott test 4 failed"); if (template_default_arg.ott("hi") != 20) throw new RuntimeException("ott test 5 failed"); if (template_default_arg.ott("hi", 1) != 20) throw new RuntimeException("ott test 6 failed"); if (template_default_arg.ott("hi", 1, 1) != 20) throw new RuntimeException("ott test 7 failed"); // %template(ott) ott; if (template_default_arg.ottstring(new Hello_int(), "hi") != 40) throw new RuntimeException("ott test 8 failed"); if (template_default_arg.ottstring(new Hello_int()) != 40) throw new RuntimeException("ott test 9 failed"); // %template(ott) ott; if (template_default_arg.ottint(new Hello_int(), 1) != 50) throw new RuntimeException("ott test 10 failed"); if (template_default_arg.ottint(new Hello_int()) != 50) throw new RuntimeException("ott test 11 failed"); // %template(ott) ott; if (template_default_arg.ott(new Hello_int(), 1.0) != 60) throw new RuntimeException("ott test 12 failed"); if (template_default_arg.ott(new Hello_int()) != 60) throw new RuntimeException("ott test 13 failed"); } // Above test in namespaces { // plain function: int nsott(Foo) if (template_default_arg.nsott(new Foo_int()) != 130) throw new RuntimeException("nsott test 1 failed"); // %template(nsott) nsott; if (template_default_arg.nsott() != 110) throw new RuntimeException("nsott test 2 failed"); if (template_default_arg.nsott(1) != 110) throw new RuntimeException("nsott test 3 failed"); if (template_default_arg.nsott(1, 1) != 110) throw new RuntimeException("nsott test 4 failed"); if (template_default_arg.nsott("hi") != 120) throw new RuntimeException("nsott test 5 failed"); if (template_default_arg.nsott("hi", 1) != 120) throw new RuntimeException("nsott test 6 failed"); if (template_default_arg.nsott("hi", 1, 1) != 120) throw new RuntimeException("nsott test 7 failed"); // %template(nsott) nsott; if (template_default_arg.nsottstring(new Hello_int(), "hi") != 140) throw new RuntimeException("nsott test 8 failed"); if (template_default_arg.nsottstring(new Hello_int()) != 140) throw new RuntimeException("nsott test 9 failed"); // %template(nsott) nsott; if (template_default_arg.nsottint(new Hello_int(), 1) != 150) throw new RuntimeException("nsott test 10 failed"); if (template_default_arg.nsottint(new Hello_int()) != 150) throw new RuntimeException("nsott test 11 failed"); // %template(nsott) nsott; if (template_default_arg.nsott(new Hello_int(), 1.0) != 160) throw new RuntimeException("nsott test 12 failed"); if (template_default_arg.nsott(new Hello_int()) != 160) throw new RuntimeException("nsott test 13 failed"); } } } swig-3.0.2/Examples/test-suite/java/director_primitives_runme.java0000664000175000017500000001133112343605122025306 0ustar williamwilliam/* This test program shows a C# class JavaDerived inheriting from Base. Three types of classes are created and the virtual methods called to demonstrate: 1) Wide variety of primitive types 2) Calling methods with zero, one or more parameters 3) Director methods that are not overridden in C# 4) Director classes that are not overridden at all in C#, ie non-director behaviour is as expected for director classes 5) Inheritance hierarchy using director methods 6) Return types working as well as parameters The Caller class is a tester class, which calls the virtual functions from C++. */ import director_primitives.*; public class director_primitives_runme { static { try { System.loadLibrary("director_primitives"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) throws Throwable { director_primitives_runme r = new director_primitives_runme(); r.run(); } void run() { if (director_primitives.getPrintDebug()) System.out.println("------------ Start ------------ "); Caller myCaller = new Caller(); // test C++ base class { Base myBase = new Base(100.0); makeCalls(myCaller, myBase); myBase.delete(); } if (director_primitives.getPrintDebug()) System.out.println("--------------------------------"); // test vanilla C++ wrapped derived class { Base myBase = new Derived(200.0); makeCalls(myCaller, myBase); myBase.delete(); } if (director_primitives.getPrintDebug()) System.out.println("--------------------------------"); // test director / C# derived class { Base myBase = new JavaDerived(300.0); makeCalls(myCaller, myBase); myBase.delete(); } if (director_primitives.getPrintDebug()) System.out.println("------------ Finish ------------ "); } void makeCalls(Caller myCaller, Base myBase) { myCaller.set(myBase); myCaller.NoParmsMethodCall(); if (myCaller.BoolMethodCall(true) != true) throw new RuntimeException("failed"); if (myCaller.BoolMethodCall(false) != false) throw new RuntimeException("failed"); if (myCaller.IntMethodCall(-123) != -123) throw new RuntimeException("failed"); if (myCaller.UIntMethodCall(123) != 123) throw new RuntimeException("failed"); if (myCaller.FloatMethodCall((float)-123.456) != (float)-123.456) throw new RuntimeException("failed"); if (!myCaller.CharPtrMethodCall("test string").equals("test string")) throw new RuntimeException("failed"); if (!myCaller.ConstCharPtrMethodCall("another string").equals("another string")) throw new RuntimeException("failed"); if (myCaller.EnumMethodCall(HShadowMode.HShadowHard) != HShadowMode.HShadowHard) throw new RuntimeException("failed"); myCaller.ManyParmsMethodCall(true, -123, 123, (float)123.456, "test string", "another string", HShadowMode.HShadowHard); myCaller.NotOverriddenMethodCall(); myCaller.reset(); } } class JavaDerived extends Base { public JavaDerived(double dd) { super(dd); } public void NoParmsMethod() { if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - NoParmsMethod()"); } public boolean BoolMethod(boolean x) { if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - BoolMethod(" + x + ")"); return x; } public int IntMethod(int x) { if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - IntMethod(" + x + ")"); return x; } public long UIntMethod(long x) { if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - UIntMethod(" + x + ")"); return x; } public float FloatMethod(float x) { if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - FloatMethod(" + x + ")"); return x; } public String CharPtrMethod(String x) { if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - CharPtrMethod(" + x + ")"); return x; } public String ConstCharPtrMethod(String x) { if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - ConstCharPtrMethod(" + x + ")"); return x; } public HShadowMode EnumMethod(HShadowMode x) { if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - EnumMethod(" + x + ")"); return x; } public void ManyParmsMethod(boolean b, int i, long u, float f, String c, String cc, HShadowMode h) { if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - ManyParmsMethod(" + b + ", " + i + ", " + u + ", " + f + ", " + c + ", " + cc + ", " + h); } } swig-3.0.2/Examples/test-suite/java/rname_runme.java0000664000175000017500000000166312343605122022331 0ustar williamwilliam import rname.*; public class rname_runme { static { try { System.loadLibrary("rname"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { rname.foo_i(10); rname.foo_d(10.0); rname.foo_s((short)10); rname.foo((long)10); Bar bar = new Bar(); bar.foo_i(10); bar.foo_d(10.0); bar.foo((short)10); bar.foo_u((long)10); RenamedBase base = new RenamedBase(); base.fn(base, base, base); if (!base.newname(10.0).equals("Base")) throw new RuntimeException("base.newname"); RenamedDerived derived = new RenamedDerived(); derived.Xfunc(base, base, base); if (!derived.newname(10.0).equals("Derived")) throw new RuntimeException("derived.newname"); } } swig-3.0.2/Examples/test-suite/java/director_string_runme.java0000664000175000017500000000266212343605122024430 0ustar williamwilliam import director_string.*; public class director_string_runme { static { try { System.loadLibrary("director_string"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { String s; director_string_A c = new director_string_A("hi"); for (int i=0; i<3; i++) { s = c.call_get(i); if (!s.equals(new Integer(i).toString())) throw new RuntimeException("director_string_A.get(" + i + ") failed. Got:" + s); } director_string_B b = new director_string_B("hello"); s = b.call_get_first(); if (!s.equals("director_string_B.get_first")) throw new RuntimeException("call_get_first() failed"); s = b.call_get(0); if (!s.equals("director_string_B.get: hello")) throw new RuntimeException("get(0) failed"); } } class director_string_B extends A { public director_string_B(String first) { super(first); } public String get_first() { return "director_string_B.get_first"; } public String get(int n) { return "director_string_B.get: " + super.get(n); } } class director_string_A extends A { public director_string_A(String first) { super(first); } public String get(int n) { return new Integer(n).toString(); } } swig-3.0.2/Examples/test-suite/java/curiously_recurring_template_pattern_runme.java0000664000175000017500000000156712343605122031000 0ustar williamwilliam import curiously_recurring_template_pattern.*; public class curiously_recurring_template_pattern_runme { static { try { System.loadLibrary("curiously_recurring_template_pattern"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { Derived d = new Derived(); d.setBase1Param(1).setDerived1Param(10).setDerived2Param(20).setBase2Param(2); if (d.getBase1Param() != 1) throw new RuntimeException("fail"); if (d.getDerived1Param() != 10) throw new RuntimeException("fail"); if (d.getBase2Param() != 2) throw new RuntimeException("fail"); if (d.getDerived2Param() != 20) throw new RuntimeException("fail"); } } swig-3.0.2/Examples/test-suite/java/java_director_exception_feature_nspace_runme.java0000664000175000017500000002027312343605122031163 0ustar williamwilliamimport java_director_exception_feature_nspacePackage.*; import java_director_exception_feature_nspacePackage.MyNS.*; class java_director_exception_feature_nspace_Consts { public static final String PINGEXCP1 = "Ping MyJavaException1"; // should get translated through an int on ping public static final String PINGEXCP2 = "Ping MyJavaException2"; public static final String PONGEXCP1 = "Pong MyJavaException1"; public static final String PONGEXCP2 = "Pong MyJavaException2"; public static final String PONGUNEXPECTED = "Pong MyJavaUnexpected"; public static final String TRANSLATED_NPE = "Pong Translated NPE"; public static final String GENERICPONGEXCP1 = "GenericPong Wrapped MyJavaException1"; public static final String GENERICPONGEXCP2 = "GenericPong New Checked Exception"; public static final String GENERICPONGEXCP3 = "GenericPong New Unchecked Exception"; public static final String GENERICPONGEXCP4 = "GenericPong New Exception Without String ctor"; } // an exception not mentioned or wrapped by the swig interface, // to reconstruct using generic DirectorException handling class java_director_exception_feature_nspace_NewCheckedException extends Exception { public java_director_exception_feature_nspace_NewCheckedException(String s) { super(s); } } // an exception not mentioned or wrapped by the swig interface, // to reconstruct using generic DirectorException handling class java_director_exception_feature_nspace_NewUncheckedException extends RuntimeException { public java_director_exception_feature_nspace_NewUncheckedException(String s) { super(s); } } // an exception not constructible from a string, // to test DirectorException fallback reconstruction class java_director_exception_feature_nspace_UnconstructibleException extends Exception { private int extrastate; public java_director_exception_feature_nspace_UnconstructibleException(int a, String s) { super(s); extrastate = a; } } class java_director_exception_feature_nspace_MyFooDirectorImpl extends Foo { public java_director_exception_feature_nspace_MyFooDirectorImpl() { }; @Override public String ping(int excp) throws MyJavaException1, MyJavaException2 { if (excp == 1) throw new MyJavaException1(java_director_exception_feature_nspace_Consts.PINGEXCP1); if (excp == 2) throw new MyJavaException2(java_director_exception_feature_nspace_Consts.PINGEXCP2); return "Ping director returned"; } @Override public String pong(int excp) throws MyJavaException1, MyJavaException2, MyJavaUnexpected { if (excp == 1) throw new MyJavaException1(java_director_exception_feature_nspace_Consts.PONGEXCP1); if (excp == 2) throw new MyJavaException2(java_director_exception_feature_nspace_Consts.PONGEXCP2); if (excp == 3) throw new MyJavaUnexpected(java_director_exception_feature_nspace_Consts.PONGUNEXPECTED); if (excp == 4) throw new java.lang.NullPointerException(java_director_exception_feature_nspace_Consts.TRANSLATED_NPE); // should be translated to ::Unexpected return "Pong director returned"; } @Override public String genericpong(int excp) throws MyJavaException1, java_director_exception_feature_nspace_NewCheckedException, java_director_exception_feature_nspace_UnconstructibleException { if (excp == 1) throw new MyJavaException1(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP1); if (excp == 2) throw new java_director_exception_feature_nspace_NewCheckedException(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP2); if (excp == 3) throw new java_director_exception_feature_nspace_NewUncheckedException(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP3); if (excp == 4) throw new java_director_exception_feature_nspace_UnconstructibleException(1, java_director_exception_feature_nspace_Consts.GENERICPONGEXCP4); return "GenericPong director returned"; } } public class java_director_exception_feature_nspace_runme { static { try { System.loadLibrary("java_director_exception_feature_nspace"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void fail(String msg) { System.err.println(msg); System.exit(1); } public static void failif(boolean cond, String msg) { if (cond) fail(msg); } public static void main(String argv[]) { Bar b = new Bar(new java_director_exception_feature_nspace_MyFooDirectorImpl()); try { try { b.ping(0); } catch (Exception e) { fail("Exception should not have been thrown: " + e + " from ping(0)"); } try { b.ping(1); fail("No exception thrown in ping(1)"); } catch (MyJavaException1 e) // Should say "Threw some integer", see java_director_exception_feature.i Foo::ping throws a "1" { failif( ! "Threw some integer".equals(e.getMessage()), "Ping exception not translated through int: '" + e.getMessage() + "'"); } try { b.ping(2); fail("No exception thrown in ping(2)"); } catch (MyJavaException2 e) { failif( ! java_director_exception_feature_nspace_Consts.PINGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.pong(0); } catch (Exception e) { fail("Exception should not have been thrown: " + e + " from pong(0)"); } try { b.pong(1); fail("No exception thrown in pong(1)"); } catch (MyJavaException1 e) { failif( ! java_director_exception_feature_nspace_Consts.PONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.pong(2); fail("No exception thrown in pong(2)");} catch (MyJavaException2 e) { failif( ! java_director_exception_feature_nspace_Consts.PONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.pong(3); fail("No exception thrown in pong(3)");} catch (MyJavaUnexpected e) { failif( ! java_director_exception_feature_nspace_Consts.PONGUNEXPECTED.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.pong(4); fail("No exception thrown in pong(4)"); } catch (MyJavaUnexpected e) { failif( ! java_director_exception_feature_nspace_Consts.TRANSLATED_NPE.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.genericpong(0); } catch (Exception e) { fail("Exception should not have been thrown: " + e + " from genericpong(0)"); } try { b.genericpong(1); fail("No exception thrown in genericpong(1)"); } catch (MyJavaException1 e) { failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.genericpong(2); fail("No exception thrown in genericpong(2)");} catch (java_director_exception_feature_nspace_NewCheckedException e) { failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.genericpong(3); fail("No exception thrown in genericpong(3)");} catch (java_director_exception_feature_nspace_NewUncheckedException e) { failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP3.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.genericpong(4); fail("No exception thrown in genericpong(4)");} catch (RuntimeException e) { failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RumtimeException"); failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP4.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } } catch (Exception e) { e.printStackTrace(); fail("Unexpected exception thrown or exception not mapped properly"); } } } swig-3.0.2/Examples/test-suite/java/li_boost_shared_ptr_attribute_runme.java0000664000175000017500000000221712343605122027333 0ustar williamwilliamimport li_boost_shared_ptr_attribute.*; public class li_boost_shared_ptr_attribute_runme { static { try { System.loadLibrary("li_boost_shared_ptr_attribute"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void check(GetSetMe g, int expected) { int got = g.getN(); if (got != expected) throw new RuntimeException("GetSetMe value is " + got + " but should be " + expected); } public static void check(GetMe g, int expected) { int got = g.getN(); if (got != expected) throw new RuntimeException("GetMe value is " + got + " but should be " + expected); } public static void main(String argv[]) { GetterSetter gs = new GetterSetter(5); check(gs.getMyval(), 25); check(gs.getAddedAttrib(), 25); gs.setAddedAttrib(new GetSetMe(6)); check(gs.getMyval(), 6); check(gs.getAddedAttrib(), 6); GetterOnly g = new GetterOnly(4); check(g.getMyval(), 16); check(g.getAddedAttrib(), 16); } } swig-3.0.2/Examples/test-suite/java/imports_runme.java0000664000175000017500000000116412343605122022720 0ustar williamwilliam // This is the imports runtime testcase. It shows that the %import directive // is working correctly import imports.*; public class imports_runme { static { try { System.loadLibrary("imports_a"); System.loadLibrary("imports_b"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { B b = new B(); b.hello(); //call member function in A which is in a different SWIG generated library. } } swig-3.0.2/Examples/test-suite/java/li_std_except_runme.java0000664000175000017500000000522512343605122024053 0ustar williamwilliamimport li_std_except.*; public class li_std_except_runme { static { try { System.loadLibrary("li_std_except"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) throws Throwable { Test test = new Test(); try { test.throw_bad_exception(); throw new RuntimeException("throw_bad_exception failed"); } catch (RuntimeException e) {} try { test.throw_domain_error(); throw new RuntimeException("throw_domain_error failed"); } catch (RuntimeException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); } try { test.throw_exception(); throw new RuntimeException("throw_exception failed"); } catch (RuntimeException e) {} try { test.throw_invalid_argument(); throw new RuntimeException("throw_invalid_argument failed"); } catch (IllegalArgumentException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); } try { test.throw_length_error(); throw new RuntimeException("throw_length_error failed"); } catch (IndexOutOfBoundsException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); } try { test.throw_logic_error(); throw new RuntimeException("throw_logic_error failed"); } catch (RuntimeException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); } try { test.throw_out_of_range(); throw new RuntimeException("throw_out_of_range failed"); } catch (IndexOutOfBoundsException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); } try { test.throw_overflow_error(); throw new RuntimeException("throw_overflow_error failed"); } catch (ArithmeticException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); } try { test.throw_range_error(); throw new RuntimeException("throw_range_error failed"); } catch (IndexOutOfBoundsException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); } try { test.throw_runtime_error(); throw new RuntimeException("throw_runtime_error failed"); } catch (RuntimeException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); } try { test.throw_underflow_error(); throw new RuntimeException("throw_underflow_error failed"); } catch (ArithmeticException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); } } } swig-3.0.2/Examples/test-suite/java/template_partial_specialization_typedef_runme.java0000664000175000017500000000217512343605122031373 0ustar williamwilliamimport template_partial_specialization_typedef.*; public class template_partial_specialization_typedef_runme { static { try { System.loadLibrary("template_partial_specialization_typedef"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // One parameter tests new A().a(); new B().b(); new C().c(); new D().d(); new E().e(); new F().f(); new G().g(); new H().h(); new I().i(); new J().j(); new K().k(); new L().l(); new BB().b(); new BBB().b(); new BBBB().b(); new BBBBB().b(); new B1().b(); new B2().b(); new B3().b(); new B4().b(); // Two parameter tests new A_().a(); new B_().b(); new C_().c(); new D_().d(); new E_().e(); new F_().f(); new G_().g(); new C1_().c(); new C2_().c(); new C3_().c(); new C4_().c(); new B1_().b(); new E1_().e(); new E2_().e(); } } swig-3.0.2/Examples/test-suite/java/cpp11_result_of_runme.java0000664000175000017500000000154012343605122024227 0ustar williamwilliamimport cpp11_result_of.*; public class cpp11_result_of_runme { static { try { System.loadLibrary("cpp11_result_of"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { double result = cpp11_result_of.test_result(cpp11_result_ofConstants.SQUARE, 3.0); if (result != 9.0) throw new RuntimeException("test_result(square, 3.0) is not 9.0. Got: " + Double.toString(result)); result = cpp11_result_of.test_result_alternative1(cpp11_result_ofConstants.SQUARE, 3.0); if (result != 9.0) throw new RuntimeException("test_result_alternative1(square, 3.0) is not 9.0. Got: " + Double.toString(result)); } } swig-3.0.2/Examples/test-suite/java/director_exception_runme.java0000664000175000017500000000153212343605122025113 0ustar williamwilliam import director_exception.*; public class director_exception_runme { static { try { System.loadLibrary("director_exception"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { director_exception_MyFoo a = new director_exception_MyFoo(); Foo b = director_exception.launder(a); try { a.pong(); throw new RuntimeException ( "Failed to catch exception" ); } catch (UnsupportedOperationException e) { } } } class director_exception_MyFoo extends Foo { public String ping() { throw new UnsupportedOperationException("Foo::ping not implemented"); } } swig-3.0.2/Examples/test-suite/java/memberin_extend_runme.java0000664000175000017500000000137612343605122024375 0ustar williamwilliam import memberin_extend.*; public class memberin_extend_runme { static { try { System.loadLibrary("memberin_extend"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { ExtendMe em1 = new ExtendMe(); ExtendMe em2 = new ExtendMe(); em1.setThing("em1thing"); em2.setThing("em2thing"); if (!em1.getThing().equals("em1thing")) throw new RuntimeException("wrong: " + em1.getThing()); if (!em2.getThing().equals("em2thing")) throw new RuntimeException("wrong: " + em2.getThing()); } } swig-3.0.2/Examples/test-suite/java/namespace_forward_declaration_runme.java0000664000175000017500000000142712343605122027252 0ustar williamwilliam import namespace_forward_declaration.*; public class namespace_forward_declaration_runme { static { try { System.loadLibrary("namespace_forward_declaration"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { XXX xxx = new XXX(); namespace_forward_declaration.testXXX1(xxx); namespace_forward_declaration.testXXX2(xxx); namespace_forward_declaration.testXXX3(xxx); YYY yyy = new YYY(); namespace_forward_declaration.testYYY1(yyy); namespace_forward_declaration.testYYY2(yyy); namespace_forward_declaration.testYYY3(yyy); } } swig-3.0.2/Examples/test-suite/java/director_protected_runme.java0000664000175000017500000000742312343605122025113 0ustar williamwilliam import director_protected.*; import java.lang.reflect.*; public class director_protected_runme { static { try { System.loadLibrary("director_protected"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { Bar b = new Bar(); Foo f = b.create(); director_protected_FooBar fb = new director_protected_FooBar(); director_protected_FooBar2 fb2 = new director_protected_FooBar2(); director_protected_FooBar3 fb3 = new director_protected_FooBar3(); { String s = fb.used(); if (!s.equals("Foo::pang();Bar::pong();Foo::pong();director_protected_FooBar::ping();")) throw new RuntimeException( "bad director_protected_FooBar::used" ); } { String s = fb2.used(); if (!s.equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();")) throw new RuntimeException( "bad director_protected_FooBar2::used" ); } { String s = b.pong(); if (!s.equals("Bar::pong();Foo::pong();Bar::ping();")) throw new RuntimeException( "bad Bar::pong" ); } { String s = f.pong(); if (!s.equals("Bar::pong();Foo::pong();Bar::ping();")) throw new RuntimeException(" bad Foo::pong" ); } { String s3 = fb.pong(); if (!s3.equals("Bar::pong();Foo::pong();director_protected_FooBar::ping();")) throw new RuntimeException(" bad director_protected_FooBar::pong" ); } try { Method method = b.getClass().getDeclaredMethod("ping", (java.lang.Class[])null); if ( !Modifier.isProtected(method.getModifiers()) ) throw new RuntimeException("Bar::ping should be protected" ); method = f.getClass().getDeclaredMethod("ping", (java.lang.Class[])null); if ( !Modifier.isProtected(method.getModifiers()) ) throw new RuntimeException("Foo::ping should be protected" ); method = b.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null); if ( !Modifier.isProtected(method.getModifiers()) ) throw new RuntimeException("Bar::cheer should be protected" ); method = f.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null); if ( !Modifier.isProtected(method.getModifiers()) ) throw new RuntimeException("Foo::cheer should be protected" ); } catch (NoSuchMethodException n) { throw new RuntimeException(n); } catch (SecurityException s) { throw new RuntimeException("SecurityException caught. Test failed."); } if (!fb3.cheer().equals("director_protected_FooBar3::cheer();")) throw new RuntimeException("bad fb3::cheer"); if (!fb2.callping().equals("director_protected_FooBar2::ping();")) throw new RuntimeException("bad fb2.callping"); if (!fb2.callcheer().equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();")) throw new RuntimeException("bad fb2.callcheer"); if (!fb3.callping().equals("Bar::ping();")) throw new RuntimeException("bad fb3.callping"); if (!fb3.callcheer().equals("director_protected_FooBar3::cheer();")) throw new RuntimeException("bad fb3.callcheer"); } } class director_protected_FooBar extends Bar { public String ping() { return "director_protected_FooBar::ping();"; } } class director_protected_FooBar2 extends Bar { public String ping() { return "director_protected_FooBar2::ping();"; } public String pang() { return "director_protected_FooBar2::pang();"; } } class director_protected_FooBar3 extends Bar { public String cheer() { return "director_protected_FooBar3::cheer();"; } } swig-3.0.2/Examples/test-suite/java/template_methods_runme.java0000664000175000017500000000240012343605122024553 0ustar williamwilliam import template_methods.*; public class template_methods_runme { static { try { System.loadLibrary("template_methods"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { float num = (float)1.1; // Global templated functions int i = template_methods.convolve1Bool(); template_methods.convolve1Bool(true); i = template_methods.convolve2Float(); template_methods.convolve3FloatRenamed(num); i = template_methods.convolve4Float(); template_methods.convolve4FloatRenamed(num); i = template_methods.convolve5FloatRenamed(); template_methods.convolve5FloatRenamed(num); // Static templated methods Klass k = new Klass(); boolean b = k.KlassTMethodBoolRenamed(true); k.KlassTMethodBool(); b = Klass.KlassStaticTMethodBoolRenamed(true); Klass.KlassStaticTMethodBool(); // ComponentProperties cp = new ComponentProperties(); cp.adda("key1", "val1", "key2", 22.2); cp.adda("key1", "val1", "key2", "val2", "key3", "val3"); cp.adda("key1", 1, "key2", 2, "key3", 3); } } swig-3.0.2/Examples/test-suite/java/wallkw_runme.java0000664000175000017500000000156012343605122022524 0ustar williamwilliam import wallkw.*; public class wallkw_runme { static { try { System.loadLibrary("wallkw"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { if (!wallkw.c_clone().equals("clone")) throw new RuntimeException("clone_c keyword fail"); if (!wallkw._delegate().equals("delegate")) throw new RuntimeException("delegate keyword fail"); if (!wallkw._pass().equals("pass")) throw new RuntimeException("pass keyword fail"); if (!wallkw._alias().equals("alias")) throw new RuntimeException("alias keyword fail"); if (!wallkw.C_rescue().equals("rescue")) throw new RuntimeException("rescue keyword fail"); } } swig-3.0.2/Examples/test-suite/java/director_nspace_runme.java0000664000175000017500000000233712343605122024372 0ustar williamwilliam// Make sure that directors are connected and disconnected when used inconjunction with // the %nspace feature public class director_nspace_runme { static { try { System.loadLibrary("director_nspace"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { director_nspace_MyBarFoo myBarFoo = new director_nspace_MyBarFoo(); } } class director_nspace_MyBarFoo extends director_nspacePackage.TopLevel.Bar.Foo { @Override public String ping() { return "director_nspace_MyBarFoo.ping();"; } @Override public String pong() { return "director_nspace_MyBarFoo.pong();" + ping(); } @Override public String fooBar(director_nspacePackage.TopLevel.Bar.FooBar fooBar) { return fooBar.FooBarDo(); } @Override public director_nspacePackage.TopLevel.Bar.Foo makeFoo() { return new director_nspacePackage.TopLevel.Bar.Foo(); } @Override public director_nspacePackage.TopLevel.Bar.FooBar makeFooBar() { return new director_nspacePackage.TopLevel.Bar.FooBar(); } } swig-3.0.2/Examples/test-suite/java/cpp11_thread_local_runme.java0000664000175000017500000000273312343605122024653 0ustar williamwilliamimport cpp11_thread_local.*; public class cpp11_thread_local_runme { static { try { System.loadLibrary("cpp11_thread_local"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { if (ThreadLocals.getStval() != 11) throw new RuntimeException(); if (ThreadLocals.getTsval() != 22) throw new RuntimeException(); if (ThreadLocals.tscval99 != 99) throw new RuntimeException(); cpp11_thread_local.setEtval(-11); if (cpp11_thread_local.getEtval() != -11) throw new RuntimeException(); cpp11_thread_local.setStval(-22); if (cpp11_thread_local.getStval() != -22) throw new RuntimeException(); cpp11_thread_local.setTsval(-33); if (cpp11_thread_local.getTsval() != -33) throw new RuntimeException(); cpp11_thread_local.setEtval(-44); if (cpp11_thread_local.getEtval() != -44) throw new RuntimeException(); cpp11_thread_local.setTeval(-55); if (cpp11_thread_local.getTeval() != -55) throw new RuntimeException(); cpp11_thread_local.setEctval(-55); if (cpp11_thread_local.getEctval() != -55) throw new RuntimeException(); cpp11_thread_local.setEcpptval(-66); if (cpp11_thread_local.getEcpptval() != -66) throw new RuntimeException(); } } swig-3.0.2/Examples/test-suite/java/li_typemaps_runme.java0000664000175000017500000000715712343605122023561 0ustar williamwilliam // Check a few of the INPUT, OUTPUT and INOUT typemaps. import li_typemaps.*; import java.math.*; public class li_typemaps_runme { static { try { System.loadLibrary("li_typemaps"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Check double INPUT typemaps if (li_typemaps.in_double(22.22) != 22.22) exit_test("in_double"); if (li_typemaps.inr_double(22.22) != 22.22) exit_test("inr_double"); // Check double OUTPUT typemaps { double[] var = {44.44}; li_typemaps.out_double(22.22, var); if (var[0] != 22.22) exit_test("out_double"); } { double[] var = {44.44}; li_typemaps.outr_double(22.22, var); if (var[0] != 22.22) exit_test("outr_double"); } try { double[] var = null; li_typemaps.out_double(22.22, var); exit_test("null out_double"); } catch (NullPointerException e) { } // Check double INOUT typemaps { double[] var = {44.44}; li_typemaps.inout_double(var); if (var[0] != 44.44) exit_test("inout_double"); } { double[] var = {44.44}; li_typemaps.inoutr_double(var); if (var[0] != 44.44) exit_test("inoutr_double"); } try { double[] var = null; li_typemaps.inout_double(var); exit_test("null inout_double"); } catch (NullPointerException e) { } // Check unsigned long long INPUT typemaps BigInteger forty = new BigInteger("40"); BigInteger twenty = new BigInteger("20"); if (!li_typemaps.in_ulonglong(twenty).equals(twenty)) exit_test("in_ulonglong"); if (!li_typemaps.inr_ulonglong(twenty).equals(twenty)) exit_test("inr_ulonglong"); try { li_typemaps.in_ulonglong(null); exit_test("null in_ulonglong"); } catch (NullPointerException e) { } // Check unsigned long long OUTPUT typemaps { BigInteger[] var = {new BigInteger("40")}; li_typemaps.out_ulonglong(twenty, var); if (!var[0].equals(twenty)) exit_test("out_ulonglong"); } { BigInteger[] var = {new BigInteger("40")}; li_typemaps.outr_ulonglong(twenty, var); if (!var[0].equals(twenty)) exit_test("outr_ulonglong"); } try { BigInteger[] var = null; li_typemaps.out_ulonglong(twenty, var); exit_test("null out_ulonglong"); } catch (NullPointerException e) { } { BigInteger[] var = { null }; li_typemaps.out_ulonglong(twenty, var); if (!var[0].equals(twenty)) exit_test("null element out_ulonglong"); } // Check unsigned long long INOUT typemaps { BigInteger[] var = {new BigInteger("40")}; li_typemaps.inout_ulonglong(var); if (!var[0].equals(forty)) exit_test("inout_ulonglong"); } { BigInteger[] var = {new BigInteger("40")}; li_typemaps.inoutr_ulonglong(var); if (!var[0].equals(forty)) exit_test("inoutr_ulonglong"); } try { BigInteger[] var = null; li_typemaps.inout_ulonglong(var); exit_test("null inout_ulonglong"); } catch (NullPointerException e) { } try { BigInteger[] var = { null }; li_typemaps.inout_ulonglong(var); exit_test("null element inout_ulonglong"); } catch (NullPointerException e) { } } private static void exit_test(String funcName) { throw new RuntimeException("Test FAILED in function " + funcName); } } swig-3.0.2/Examples/test-suite/java/char_strings_runme.java0000664000175000017500000001323312343605122023711 0ustar williamwilliamimport char_strings.*; public class char_strings_runme { static { try { System.loadLibrary("char_strings"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } private static String CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; private static String OTHERLAND_MSG = "Little message from the safe world."; public static void main(String argv[]) { long count = 10000; long i = 0; // get functions for (i=0; i; %feature("valuewrapper") TemplateClass; template class TemplateClass; %feature("valuewrapper") BB; class BB; %inline %{ struct A { A(int){} }; class D {}; class Klass {}; TemplateClass getKlass(Klass k) { TemplateClass t(k); return t; } TemplateClass getA(A a) { TemplateClass t(a); return t; } TemplateClass getA(B b) { TemplateClass t(b); return t; } TemplateClass getC(C a) { TemplateClass t(a); return t; } TemplateClass getInt(int a) { TemplateClass t(a); return t; } A sgetA(A a) { return a; } Klass sgetKlass(Klass a) { return a; } template struct auto_ptr { auto_ptr(T a){} }; auto_ptr getPtrA(auto_ptr a) { return a; } B getB(B a) { return a; } D getD(D a) { return a; } %} %template() auto_ptr; /***** Another strange case, member var + opaque, bug #901706 ******/ %{ class BB { friend class AA; protected: BB(int aa) { this->a = aa; }; BB() {}; int a; }; %} %inline %{ class AA { public: AA(){} BB innerObj; }; %} %{ class Foobar { public: Foobar() { } char *foo_method() { return 0; } }; class Quux { public: Quux() { } Foobar method() { return Foobar(); } }; %} %feature("novaluewrapper") Foobar; class Foobar; class Quux { public: Quux(); Foobar method(); }; #if defined(SWIGPYTHON) /* This case can't be fixed by using the valuewrapper feature and the old mechanismbut it works fine with the new mechanism */ %{ // Template primitive type, only visible in C++ template struct Param { T val; // This case is disabled by now // Param(T v): val(v) {} Param(T v = T()): val(v) {} operator T() const { return val; } }; %} /* Several languages have 'not 100% safe' typemaps, where the following %applies don't work. */ %apply int { Param }; %apply const int& { const Param& }; %apply double { Param }; %apply const double& { const Param& }; %inline %{ template T getv(const Param& p) { return p.val; } template Param getp(const T& v) { return Param(v); } %} %template(getv_i) getv; %template(getp_i) getp; %template(getv_d) getv; %template(getp_d) getp; #endif swig-3.0.2/Examples/test-suite/inherit_missing.i0000664000175000017500000000145412343605122021600 0ustar williamwilliam// Tests handling of inheritance when a base class isn't provided to SWIG %module inherit_missing %warnfilter(402); %{ /* Define the class internally, but don't tell SWIG about it */ class Foo { public: virtual ~Foo() {} virtual char *blah() { return (char *) "Foo::blah"; } }; %} /* Forward declaration. Says that Foo is a class, but doesn't provide a definition */ class Foo; %newobject new_Foo; %delobject delete_Foo; %inline %{ class Bar : public Foo { public: virtual ~Bar() {} virtual char *blah() { return (char *) "Bar::blah"; }; }; class Spam : public Bar { public: virtual char *blah() { return (char *) "Spam::blah"; }; }; Foo *new_Foo() { return new Foo(); } void delete_Foo(Foo *f) { delete f; } char *do_blah(Foo *f) { return f->blah(); } %} swig-3.0.2/Examples/test-suite/overload_simple.i0000664000175000017500000000715612343605122021576 0ustar williamwilliam// Simple tests of overloaded functions %module overload_simple #ifdef SWIGCHICKEN %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fbool; #endif #ifdef SWIGLUA // lua only has one numeric type, so most of the overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) foo; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) bar; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Spam; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) num; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fid; #endif #ifdef SWIGGO %warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype' %rename(Foos) Foo; #endif #ifndef SWIG_NO_OVERLOAD %immutable Spam::type; %inline %{ struct Foo { }; class Bar { public: Bar(int i = 0) { num = i; } static int foo(int a=0, int b=0) {return 0;} int num; }; char *foo() { return (char *) "foo:"; } char *foo(int) { return (char*) "foo:int"; } char *foo(double) { return (char*) "foo:double"; } char *foo(char *) { return (char*) "foo:char *"; } char *foo(Foo *) { return (char*) "foo:Foo *"; } char *foo(Bar *) { return (char *) "foo:Bar *"; } char *foo(void *) { return (char *) "foo:void *"; } char *foo(Foo *, int) { return (char *) "foo:Foo *,int"; } char *foo(double, Bar *) { return (char *) "foo:double,Bar *"; } char *blah(double) { return (char *) "blah:double"; } char *blah(char *) { return (char *) "blah:char *"; } class Spam { public: Spam() { type = "none"; } Spam(int) { type = "int"; } Spam(double) { type = "double"; } Spam(char *) { type = "char *"; } Spam(Foo *) { type = "Foo *"; } Spam(Bar *) { type = "Bar *"; } Spam(void *) { type = "void *"; } const char *type; char *foo(int) { return (char*) "foo:int"; } char *foo(double) { return (char*) "foo:double"; } char *foo(char *) { return (char*) "foo:char *"; } char *foo(Foo *) { return (char*) "foo:Foo *"; } char *foo(Bar *) { return (char *) "foo:Bar *"; } char *foo(void *) { return (char *) "foo:void *"; } static char *bar(int) { return (char*) "bar:int"; } static char *bar(double) { return (char*) "bar:double"; } static char *bar(char *) { return (char*) "bar:char *"; } static char *bar(Foo *) { return (char*) "bar:Foo *"; } static char *bar(Bar *) { return (char *) "bar:Bar *"; } static char *bar(void *) { return (char *) "bar:void *"; } }; bool fbool(bool b) { return b; } int fbool(int b) { return b; } char *fint(int) { return (char*) "fint:int"; } char *fdouble(double) { return (char*) "fdouble:double"; } char *num(int) { return (char*) "num:int"; } char *num(double) { return (char*) "num:double"; } char *fid(int, int) { return (char*) "fid:intint"; } char *fid(int, double) { return (char*) "fid:intdouble"; } char *fid(double, int) { return (char*) "fid:doubleint"; } char *fid(double, double) { return (char*) "fid:doubledouble"; } %} %inline %{ unsigned long long ull() { return 0ULL; } unsigned long long ull(unsigned long long ull) { return ull; } long long ll() { return 0LL; } long long ll(long long ull) { return ull; } %} %include cmalloc.i %malloc(void); %free(void); #endif %inline { class ClassA { public: ClassA() {} int method1( ) {return 0;} int method1( int arg1 ) {return arg1;} protected: int method1( int arg1, int arg2 ) {return arg1 + arg2;} }; } #ifdef SWIGPYTHON %inline { class Graph { public: int val; Graph(int i) : val(i) {}; }; } %extend Graph { Graph(PyObject* p) { return new Graph(123);} } #endif %inline %{ int int_object(Spam *s) { return 999; } int int_object(int c) { return c; } %} swig-3.0.2/Examples/test-suite/multivalue.i0000664000175000017500000000221612343605122020571 0ustar williamwilliam/* -*- c -*- */ %module multivalue #ifdef SWIGGUILE /* Multiple values as lists. By default, if more than one value is to be returned, a list of the values is created and returned; to switch back to this behavior, use: */ %values_as_list; void divide_l(int a, int b, int *OUTPUT, int *OUTPUT); /* Multiple values as vectors. By issueing: */ %values_as_vector; /* vectors instead of lists will be used. */ void divide_v(int a, int b, int *OUTPUT, int *OUTPUT); /* Multiple values for multiple-value continuations. (This is the most elegant way.) By issueing: */ %multiple_values; /* multiple values are passed to the multiple-value continuation, as created by `call-with-values' or the convenience macro `receive'. (See the Scheme file.) */ void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT); #endif %{ void divide_l(int a, int b, int *quotient_p, int *remainder_p) { *quotient_p = a/b; *remainder_p = a%b; } void divide_v(int a, int b, int *quotient_p, int *remainder_p) { *quotient_p = a/b; *remainder_p = a%b; } void divide_mv(int a, int b, int *quotient_p, int *remainder_p) { *quotient_p = a/b; *remainder_p = a%b; } %} swig-3.0.2/Examples/test-suite/defvalue_constructor.i0000664000175000017500000000023612343605122022642 0ustar williamwilliam%module defvalue_constructor %inline %{ namespace Foo { class Bar {}; class Baz { public: Baz(Bar b = Bar()) {} }; } %} swig-3.0.2/Examples/test-suite/cpp_static.i0000664000175000017500000000064112343605122020533 0ustar williamwilliam/* Testcase to test c++ static member variables and static functions. Tests Sourceforge bug #444748. */ %module cpp_static %inline %{ class StaticMemberTest { public: static int static_int; }; class StaticFunctionTest { public: static void static_func() {}; static void static_func_2(int param_1) {}; static void static_func_3(int param_1, int param_2) {}; }; %} %{ int StaticMemberTest::static_int; %} swig-3.0.2/Examples/test-suite/overload_numeric.i0000664000175000017500000000221312343605122021734 0ustar williamwilliam%module overload_numeric // Tests overloading of integral and floating point types to verify the range checking required // for dispatch to the correct overloaded method #ifdef SWIGLUA // lua only has one numeric type, so most of the overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Nums::over; #endif %{ #include %} %inline %{ #include #include struct Limits { signed char schar_min() { return SCHAR_MIN; } signed char schar_max() { return SCHAR_MAX; } short shrt_min() { return SHRT_MIN; } short shrt_max() { return SHRT_MAX; } int int_min() { return INT_MIN; } int int_max() { return INT_MAX; } float flt_min() { return FLT_MIN; } float flt_max() { return FLT_MAX; } double dbl_max() { return DBL_MAX; } }; struct Nums { const char * over(signed char v) { return "signed char"; } const char * over(short v) { return "short"; } const char * over(int v) { return "int"; } const char * over(float v) { return "float"; } const char * over(double v) { return "double"; } double doublebounce(double v) { return v; } }; %} swig-3.0.2/Examples/test-suite/tcl/0000775000175000017500000000000012343605122017011 5ustar williamwilliamswig-3.0.2/Examples/test-suite/tcl/enum_thorough_runme.tcl0000664000175000017500000000065112343605122023610 0ustar williamwilliam if [ catch { load ./enum_thorough[info sharedlibextension] enum_thorough} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } if { [speedTest0 $SpeedClass_slow] != $SpeedClass_slow } { puts stderr "speedTest0 failed" } if { [speedTest4 $SpeedClass_slow] != $SpeedClass_slow } { puts stderr "speedTest4 failed" } if { [speedTest5 $SpeedClass_slow] != $SpeedClass_slow } { puts stderr "speedTest5 failed" } swig-3.0.2/Examples/test-suite/tcl/README0000664000175000017500000000020712343605122017670 0ustar williamwilliamSee ../README for common README file. Any testcases which have _runme.tcl appended after the testcase name will be detected and run. swig-3.0.2/Examples/test-suite/tcl/li_std_string_runme.tcl0000664000175000017500000000143112343605122023566 0ustar williamwilliam if [ catch { load ./li_std_string[info sharedlibextension] li_std_string} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } Structure s if {"[s cget -MemberString2]" != "member string 2"} { error "bad string map"} s configure -MemberString2 "hello" if {"[s cget -MemberString2]" != "hello"} { error "bad string map"} if {"[s cget -ConstMemberString]" != "const member string"} { error "bad string map"} if {"$GlobalString2" != "global string 2"} { error "bad string map"} if {"$Structure_StaticMemberString2" != "static member string 2"} { error "bad string map"} set GlobalString2 "hello" if {"$GlobalString2" != "hello"} { error "bad string map"} set Structure_StaticMemberString2 "hello" if {"$Structure_StaticMemberString2" != "hello"} { error "bad string map"} swig-3.0.2/Examples/test-suite/tcl/overload_simple_runme.tcl0000664000175000017500000000522712343605122024115 0ustar williamwilliam if [ catch { load ./overload_simple[info sharedlibextension] overload_simple} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } set f [new_Foo] set b [new_Bar] set v [malloc_void 32] set x [foo 3] if {$x != "foo:int"} { puts stderr "foo(int) test failed $x" exit 1 } set x [foo 3.4] if {$x != "foo:double"} { puts stderr "foo(double) test failed" exit 1 } set x [foo hello] if {$x != "foo:char *"} { puts stderr "foo(char *) test failed" exit 1 } set x [foo $f] if {$x != "foo:Foo *"} { puts stderr "foo(Foo *) test failed" exit 1 } set x [foo $b] if {$x != "foo:Bar *"} { puts stderr "foo(Bar *) test failed" exit 1 } set x [foo $v] if {$x != "foo:void *"} { puts stderr "foo(void *) test failed" exit 1 } Spam s set x [s foo 3] if {$x != "foo:int"} { puts stderr "Spam::foo(int) test failed" exit 1 } set x [s foo 3.4] if {$x != "foo:double"} { puts stderr "Spam::foo(double) test failed" exit 1 } set x [s foo hello] if {$x != "foo:char *"} { puts stderr "Spam::foo(char *) test failed" exit 1 } set x [s foo $f] if {$x != "foo:Foo *"} { puts stderr "Spam::foo(Foo *) test failed" exit 1 } set x [s foo $b] if {$x != "foo:Bar *"} { puts stderr "Spam::foo(Bar *) test failed" exit 1 } set x [s foo $v] if {$x != "foo:void *"} { puts stderr "Spam::foo(void *) test failed" exit 1 } set x [Spam_bar 3] if {$x != "bar:int"} { puts stderr "Spam::bar(int) test failed" exit 1 } set x [Spam_bar 3.4] if {$x != "bar:double"} { puts stderr "Spam::bar(double) test failed" exit 1 } set x [Spam_bar hello] if {$x != "bar:char *"} { puts stderr "Spam::bar(char *) test failed" exit 1 } set x [Spam_bar $f] if {$x != "bar:Foo *"} { puts stderr "Spam::bar(Foo *) test failed" exit 1 } set x [Spam_bar $b] if {$x != "bar:Bar *"} { puts stderr "Spam::bar(Bar *) test failed" exit 1 } set x [Spam_bar $v] if {$x != "bar:void *"} { puts stderr "Spam::bar(void *) test failed" exit 1 } Spam s set x [s cget -type] if {$x != "none"} { puts stderr "Spam() test failed" } Spam s 3 set x [s cget -type] if {$x != "int"} { puts stderr "Spam(int) test failed" } Spam s 3.4 set x [s cget -type] if {$x != "double"} { puts stderr "Spam(double) test failed" } Spam s hello set x [s cget -type] if {$x != "char *"} { puts stderr "Spam(char *) test failed" } Spam s $f set x [s cget -type] if {$x != "Foo *"} { puts stderr "Spam(Foo *) test failed" } Spam s $b set x [s cget -type] if {$x != "Bar *"} { puts stderr "Spam(Bar *) test failed" } Spam s $v set x [s cget -type] if {$x != "void *"} { puts stderr "Spam(void *) test failed" } free_void $v swig-3.0.2/Examples/test-suite/tcl/member_pointer_runme.tcl0000664000175000017500000000200412343605122023726 0ustar williamwilliam# Example using pointers to member functions if [ catch { load ./member_pointer[info sharedlibextension] member_pointer} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } proc check {what expected actual} { if {$expected != $actual } { error "Failed: $what , Expected: $expected , Actual: $actual" } } # Get the pointers set area_pt [ areapt ] set perim_pt [ perimeterpt ] # Create some objects set s [Square -args 10] # Do some calculations check "Square area " 100.0 [do_op $s $area_pt] check "Square perim" 40.0 [do_op $s $perim_pt] set memberPtr $areavar set memberPtr $perimetervar # Try the variables check "Square area " 100.0 [do_op $s $areavar] check "Square perim" 40.0 [do_op $s $perimetervar] # Modify one of the variables set areavar $perim_pt check "Square perimeter" 40.0 [do_op $s $areavar] # Try the constants set memberPtr $AREAPT set memberPtr $PERIMPT set memberPtr $NULLPT check "Square area " 100.0 [do_op $s $AREAPT] check "Square perim" 40.0 [do_op $s $PERIMPT] swig-3.0.2/Examples/test-suite/tcl/newobject2_runme.tcl0000664000175000017500000000102512343605122022763 0ustar williamwilliamif [ catch { load ./newobject2[info sharedlibextension] newobject2} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } set foo1 [makeFoo] if {[fooCount] != 1} { puts stderr "newobject2 test 1 failed" exit 1 } set foo2 [makeFoo] if {[fooCount] != 2} { puts stderr "newobject2 test 2 failed" exit 1 } #$foo1 -delete #if {[fooCount] != 1} { # puts stderr "newobject2 test 3 failed" # exit 1 #} #$foo2 -delete #if {[fooCount] != 0} { # puts stderr "newobject2 test 4 failed" # exit 1 #} swig-3.0.2/Examples/test-suite/tcl/primitive_ref_runme.tcl0000664000175000017500000000163012343605122023567 0ustar williamwilliam# Primitive ref testcase. Tests to make sure references to # primitive types are passed by value if [ catch { load ./primitive_ref[info sharedlibextension] primitive_ref} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } if { [ref_int 3] != 3 } { puts stderr "ref_int failed" } if { [ref_uint 3] != 3 } { puts stderr "ref_uint failed" } if { [ref_short 3] != 3 } { puts stderr "ref_short failed" } if { [ref_ushort 3] != 3 } { puts stderr "ref_ushort failed" } if { [ref_long 3] != 3 } { puts stderr "ref_long failed" } if { [ref_ulong 3] != 3 } { puts stderr "ref_ulong failed" } if { [ref_schar 3] != 3 } { puts stderr "ref_schar failed" } if { [ref_uchar 3] != 3 } { puts stderr "ref_uchar failed" } if { [ref_float 3.5] != 3.5 } { puts stderr "ref_float failed" } if { [ref_double 3.5] != 3.5 } { puts stderr "ref_double failed" } if { [ref_char x] != "x" } { puts stderr "ref_char failed" } swig-3.0.2/Examples/test-suite/tcl/import_nomodule_runme.tcl0000664000175000017500000000022412343605122024135 0ustar williamwilliam if [ catch { load ./import_nomodule[info sharedlibextension] import_nomodule} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } swig-3.0.2/Examples/test-suite/tcl/overload_copy_runme.tcl0000664000175000017500000000026112343605122023567 0ustar williamwilliam if [ catch { load ./overload_copy[info sharedlibextension] overload_copy} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } Foo f Foo g [f cget -this] swig-3.0.2/Examples/test-suite/tcl/union_parameter_runme.tcl0000664000175000017500000000214612343605122024116 0ustar williamwilliamif [ catch { load ./union_parameter[info sharedlibextension] union_parameter} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } set event [SDL_Event] for { set i 0 } { $i < 2 } { incr i } { # puts -nonewline "Loop $i: " set evAvailable [SDL_PollEvent $event] set evType [$event cget -type] # puts "evType = $evType" if { $evType == 1 } { set specEvent [$event cget -active] # puts "specEvent = $specEvent" set type [$specEvent cget -type] if { $type != $evType } { error "Type $type should be $evType" } set gain [$specEvent cget -gain] set state [$specEvent cget -state] # puts "gain=$gain state=$state" } if { $evType == 2 } { set specEvent [$event cget -key] # puts "specEvent = $specEvent" set type [$specEvent cget -type] if { $type != $evType } { error "Type $type should be $evType" } set which [$specEvent cget -which] set state [$specEvent cget -state] # puts "which=$which state=$state" } # puts "" } swig-3.0.2/Examples/test-suite/tcl/clientdata_prop_runme.tcl0000664000175000017500000000202412343605122024071 0ustar williamwilliam if [ catch { load ./clientdata_prop_b[info sharedlibextension] clientdata_prop_b} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" exit 1 } if [ catch { load ./clientdata_prop_a[info sharedlibextension] clientdata_prop_a} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" exit 1 } A a test_A a test_tA a test_t2A a test_t3A a a fA B b test_A b test_tA b test_t2A b test_t3A b test_B b b fA b fB C c test_A c test_tA c test_t2A c test_t3A c test_C c c fA c fC D d test_A d test_tA d test_t2A d test_t3A d test_D d test_tD d test_t2D d d fA d fD set a2 [new_tA] test_A $a2 test_tA $a2 test_t2A $a2 test_t3A $a2 $a2 fA set a3 [new_t2A] test_A $a3 test_tA $a3 test_t2A $a3 test_t3A $a3 $a3 fA set a4 [new_t3A] test_A $a4 test_tA $a4 test_t2A $a4 test_t3A $a4 $a4 fA set d2 [new_tD] test_A $d2 test_tA $d2 test_t2A $d2 test_t3A $d2 test_D $d2 test_tD $d2 test_t2D $d2 $d2 fA $d2 fD set d3 [new_t2D] test_A $d3 test_tA $d3 test_t2A $d3 test_t3A $d3 test_D $d3 test_tD $d3 test_t2D $d3 $d3 fA $d3 fD swig-3.0.2/Examples/test-suite/tcl/imports_runme.tcl0000664000175000017500000000105412343605122022420 0ustar williamwilliam # This is the imports runtime testcase. proc import {} { if [ catch { load ./imports_b[info sharedlibextension] imports_b} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" exit 1 } if [ catch { load ./imports_a[info sharedlibextension] imports_a} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" exit 1 } } import set x [new_B] A_hello $x if [ catch { $x nonexistant } ] { } else { puts stderr "nonexistant method did not throw exception\n" exit 1 } swig-3.0.2/Examples/test-suite/tcl/disown_runme.tcl0000664000175000017500000000052512343605122022230 0ustar williamwilliam # This is the union runtime testcase. It ensures that values within a # union embedded within a struct can be set and read correctly. if [ catch { load ./disown[info sharedlibextension] disown} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } set x 0 while {$x<100} { set a [new_A] B b b acquire $a incr x } swig-3.0.2/Examples/test-suite/tcl/profiletest_runme.tcl0000664000175000017500000000024412343605122023263 0ustar williamwilliamcatch { load ./profiletest[info sharedlibextension] profiletest} set a [new_A] set b [new_B] for {set i 0} {$i < 1000000} {incr i 1} { set a [B_fn $b $a] } swig-3.0.2/Examples/test-suite/tcl/unions_runme.tcl0000664000175000017500000000372212343605122022242 0ustar williamwilliam # This is the union runtime testcase. It ensures that values within a # union embedded within a struct can be set and read correctly. if [ catch { load ./unions[info sharedlibextension] unions} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } # Create new instances of SmallStruct and BigStruct for later use SmallStruct small small configure -jill 200 BigStruct big big configure -smallstruct [small cget -this] big configure -jack 300 # Use SmallStruct then BigStruct to setup EmbeddedUnionTest. # Ensure values in EmbeddedUnionTest are set correctly for each. EmbeddedUnionTest eut # First check the SmallStruct in EmbeddedUnionTest eut configure -number 1 #eut.uni.small = small EmbeddedUnionTest_uni_small_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [small cget -this] #Jill1 = eut.uni.small.jill set Jill1 [SmallStruct_jill_get [EmbeddedUnionTest_uni_small_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ] if {$Jill1 != 200} { puts stderr "Runtime test1 failed. eut.uni.small.jill=$Jill1" exit 1 } set Num1 [eut cget -number] if {$Num1 != 1} { puts stderr "Runtime test2 failed. eut.number=$Num1" exit 1 } # Secondly check the BigStruct in EmbeddedUnionTest eut configure -number 2 #eut.uni.big = big EmbeddedUnionTest_uni_big_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [big cget -this] #Jack1 = eut.uni.big.jack set Jack1 [BigStruct_jack_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ] if {$Jack1 != 300} { puts stderr "Runtime test3 failed. eut.uni.big.jack=$Jack1" exit 1 } #Jill2 = eut.uni.big.smallstruct.jill set Jill2 [SmallStruct_jill_get [BigStruct_smallstruct_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ] ] if {$Jill2 != 200} { puts stderr "Runtime test4 failed. eut.uni.big.smallstruct.jill=$Jill2" exit 1 } set Num2 [eut cget -number] if {$Num2 != 2} { puts stderr "Runtime test5 failed. eut.number=$Num2" exit 1 } swig-3.0.2/Examples/test-suite/tcl/reference_global_vars_runme.tcl0000664000175000017500000000464412343605122025244 0ustar williamwilliamif [ catch { load ./reference_global_vars[info sharedlibextension] reference_global_vars} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } # const class reference variable if {[ [getconstTC ] cget -num] != 33 } { puts stderr "test 1 failed" exit 1 } # primitive reference variables set var_bool [createref_bool 0] if {[value_bool $var_bool] != 0} { puts stderr "test 2 failed" exit 1 } set var_bool [createref_bool 1] if {[value_bool $var_bool] != 1} { puts stderr "test 3 failed" exit 1 } set var_char [createref_char "w"] if {[value_char $var_char] != "w"} { puts stderr "test 4 failed" exit 1 } set var_unsigned_char [createref_unsigned_char 10] if {[value_unsigned_char $var_unsigned_char] != 10} { puts stderr "test 5 failed" exit 1 } set var_signed_char [createref_signed_char 10] if {[value_signed_char $var_signed_char] != 10} { puts stderr "test 6 failed" exit 1 } set var_short [createref_short 10] if {[value_short $var_short] != 10} { puts stderr "test 7 failed" exit 1 } set var_unsigned_short [createref_unsigned_short 10] if {[value_unsigned_short $var_unsigned_short] != 10} { puts stderr "test 8 failed" exit 1 } set var_int [createref_int 10] if {[value_int $var_int] != 10} { puts stderr "test 9 failed" exit 1 } set var_unsigned_int [createref_unsigned_int 10] if {[value_unsigned_int $var_unsigned_int] != 10} { puts stderr "test 10 failed" exit 1 } set var_long [createref_long 10] if {[value_long $var_long] != 10} { puts stderr "test 11 failed" exit 1 } set var_unsigned_long [createref_unsigned_long 10] if {[value_unsigned_long $var_unsigned_long] != 10} { puts stderr "test 12 failed" exit 1 } set var_long_long [createref_long_long 10] if {[value_long_long $var_long_long] != 10} { puts stderr "test 13 failed" exit 1 } set var_unsigned_long_long [createref_unsigned_long_long 10] if {[value_unsigned_long_long $var_unsigned_long_long] != 10} { puts stderr "test 14 failed" exit 1 } set var_float [createref_float 10.5] if {[value_float $var_float] != 10.5} { puts stderr "test 15 failed" exit 1 } set var_double [createref_double 10.5] if {[value_double $var_double] != 10.5} { puts stderr "test 16 failed" exit 1 } # class reference variable set var_TestClass [createref_TestClass [TestClass tc 20] ] if {[ [value_TestClass $var_TestClass] cget -num] != 20} { puts stderr "test 17 failed" exit 1 } swig-3.0.2/Examples/test-suite/tcl/null_pointer_runme.tcl0000664000175000017500000000066612343605122023445 0ustar williamwilliamif [ catch { load ./null_pointer[info sharedlibextension] null_pointer} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } set a [A] if {[func $a] != 0} { puts stderr "null_pointer test 1 failed" exit 1 } set null [getnull] if {$null != "NULL"} { puts stderr "null_pointer test 2 failed" exit 1 } if {[llength [info commands "NULL"]] != 0} { puts stderr "null_pointer test 3 failed" exit 1 } swig-3.0.2/Examples/test-suite/tcl/Makefile.in0000664000175000017500000000234112343605122021056 0ustar williamwilliam####################################################################### # Makefile for tcl test-suite ####################################################################### LANGUAGE = tcl TCLSH = tclsh SCRIPTSUFFIX = _runme.tcl srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ primitive_types \ li_cstring \ li_cwstring C_TEST_CASES += \ li_cstring \ li_cwstring include $(srcdir)/../common.mk # Overridden variables here # none! # Custom tests - tests with additional commandline options # none! # Rules for the different types of tests %.cpptest: $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.tcl appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean %.clean: @exit 0 clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" tcl_clean swig-3.0.2/Examples/test-suite/tcl/primitive_types_runme.tcl0000664000175000017500000000176212343605122024165 0ustar williamwilliam if [ catch { load ./primitive_types[info sharedlibextension] primitive_types} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } if {[val_int 10] != 10 } { error "bad int map" } if {[val_schar 10] != 10 } { error "bad char map" } if {[val_short 10] != 10 } { error "bad schar map" } if [catch { val_schar 10000 } ] {} else { error "bad schar map" } if [catch { val_uint -100 } ] {} else { error "bad uint map" } if [catch { val_uchar -100 } ] {} else { error "bad uchar map" } if {[val_uint 10] != 10 } { error "bad uint map" } if {[val_uchar 10] != 10 } { error "bad uchar map" } if {[val_ushort 10] != 10 } { error "bad ushort map" } if {[val_double 10] != 10 } { error "bad double map" } if {[val_float 10] != 10 } { error "bad double map" } if [catch { val_float hello } ] {} else { error "bad double map" } if {[val_char c] != "c" } { error "bad char map" } if {[val_char "c"] != "c" } { error "bad char map" } if {[val_char 101] != "e" } { error "bad char map" } swig-3.0.2/Examples/test-suite/tcl/newobject1_runme.tcl0000664000175000017500000000117012343605122022763 0ustar williamwilliamif [ catch { load ./newobject1[info sharedlibextension] newobject1} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } set foo1 [Foo_makeFoo] if {[Foo_fooCount] != 1} { puts stderr "newobject1 test 1 failed" exit 1 } set foo2 [$foo1 makeMore] if {[Foo_fooCount] != 2} { puts stderr "newobject1 test 2 failed" exit 1 } # Disable test while we solve the problem of premature object deletion #$foo1 -delete #if {[Foo_fooCount] != 1} { # puts stderr "newobject1 test 3 failed" # exit 1 #} # #$foo2 -delete #if {[Foo_fooCount] != 0} { # puts stderr "newobject1 test 4 failed" # exit 1 #} swig-3.0.2/Examples/test-suite/tcl/bools_runme.tcl0000664000175000017500000000255312343605122022046 0ustar williamwilliam if [ catch { load ./bools[info sharedlibextension] bools} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } # bool constant check if {$constbool != 0} { puts stderr "Runtime test 1 failed" exit 1 } # bool variables check if {$bool1 != 1} { puts stderr "Runtime test 2 failed" exit 1 } if {$bool2 != 0} { puts stderr "Runtime test 3 failed" exit 1 } if { [ value $pbool ] != $bool1} { puts stderr "Runtime test 4 failed" exit 1 } if { [ value $rbool ] != $bool2} { puts stderr "Runtime test 5 failed" exit 1 } if { [ value $const_pbool ] != $bool1} { puts stderr "Runtime test 6 failed" exit 1 } if { $const_rbool != $bool2} { puts stderr "Runtime test 7 failed" exit 1 } # bool functions check if { [ bo 0 ] != 0} { puts stderr "Runtime test 8 failed" exit 1 } if { [ bo 1 ] != 1} { puts stderr "Runtime test 9 failed" exit 1 } if { [ value [ rbo $rbool ] ] != [ value $rbool ]} { puts stderr "Runtime test 10 failed" exit 1 } if { [ value [ pbo $pbool ] ] != [ value $pbool ]} { puts stderr "Runtime test 11 failed" exit 1 } if { [ const_rbo $const_rbool ] != $const_rbool } { puts stderr "Runtime test 12 failed" exit 1 } if { [ value [ const_pbo $const_pbool ] ] != [ value $const_pbool ]} { puts stderr "Runtime test 13 failed" exit 1 } swig-3.0.2/Examples/test-suite/protected_rename.i0000664000175000017500000000046412343605122021725 0ustar williamwilliam%module protected_rename /** * We should be able to rename Foo::y() to 'x' since the protected * member variable of the same name is not wrapped. Thus this test * case shouldn't generate any warnings. */ %rename(x) Foo::y(); %inline %{ class Foo { protected: int x; public: void y() {} }; %} swig-3.0.2/Examples/test-suite/template_static.i0000664000175000017500000000110212343605122021555 0ustar williamwilliam%module template_static %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; /* Ruby, wrong class name */ %inline %{ template class foo { public: static int test; }; template int foo::test = 0; %} %template(foo_i) foo; %template(foo_d) foo; %inline %{ namespace toto { class Foo { public: template static double bar(int i) { return 1.0; } private: int i; }; } %} %template(bar_double) toto::Foo::bar; swig-3.0.2/Examples/test-suite/varargs.i0000664000175000017500000000165512343605122020055 0ustar williamwilliam// Tests SWIG's *default* handling of varargs (function varargs, not preprocessor varargs). // The default behavior is to simply ignore the varargs. %module varargs %varargs(int mode = 0) test_def; %varargs(int mode = 0) Foo::Foo; %varargs(int mode = 0) Foo::statictest(const char*fmt, ...); %varargs(2, int mode = 0) test_plenty(const char*fmt, ...); %inline %{ char *test(const char *fmt, ...) { return (char *) fmt; } const char *test_def(const char *fmt, ...) { return fmt; } class Foo { public: char *str; Foo() { str = NULL; } Foo(const char *fmt, ...) { str = new char[strlen(fmt) + 1]; strcpy(str, fmt); } ~Foo() { delete [] str; } char *test(const char *fmt, ...) { return (char *) fmt; } static char *statictest(const char *fmt, ...) { return (char *) fmt; } }; const char *test_plenty(const char *fmt, ...) { return fmt; } %} swig-3.0.2/Examples/test-suite/python_richcompare.i0000664000175000017500000000232312343605122022276 0ustar williamwilliam/* Test the tp_richcompare functions generated with the -builtin option */ %module python_richcompare %inline { class BaseClass { public: BaseClass (int i_) : i(i_) {} ~BaseClass () {} int getValue () const { return i; } bool operator< (const BaseClass& x) const { return this->i < x.i; } bool operator> (const BaseClass& x) const { return this->i > x.i; } bool operator<= (const BaseClass& x) const { return this->i <= x.i; } bool operator>= (const BaseClass& x) const { return this->i >= x.i; } bool operator== (const BaseClass& x) const { return this->i == x.i; } bool operator!= (const BaseClass& x) const { return this->i != x.i; } int i; }; class SubClassA : public BaseClass { public: SubClassA (int i_) : BaseClass(i_) {} ~SubClassA () {} bool operator== (const SubClassA& x) const { return true; } bool operator== (const BaseClass& x) const { return false; } }; class SubClassB : public BaseClass { public: SubClassB (int i_) : BaseClass(i_) {} ~SubClassB () {} bool operator== (const SubClassB& x) const { return true; } bool operator== (const SubClassA& x) const { return false; } }; } swig-3.0.2/Examples/test-suite/namespace_virtual_method.i0000664000175000017500000000106712343605122023447 0ustar williamwilliam%module namespace_virtual_method %warnfilter(515); %inline %{ namespace A { namespace B { class Foo; } namespace C { class Foo { public: Foo() { }; virtual ~Foo() { }; virtual int bar(const A::B::Foo &x) = 0; }; } } namespace A { namespace C { class Spam : public Foo { public: Spam() { } virtual ~Spam() { } virtual int bar(const B::Foo &x) { return 1; } }; } } %} %{ namespace A { namespace B { class Foo { }; } } %} swig-3.0.2/Examples/test-suite/imports_a.h0000664000175000017500000000112712343605122020376 0ustar williamwilliam#ifndef a_h #define a_h enum GlobalEnum { globalenum1=1, globalenum2 }; /* This function should be static as it will be emitted into the code for * every module. All _static targets would fail here with a multiple * definition if this is not static. */ static GlobalEnum global_test(GlobalEnum e) { return e; } class A { public: A() {} virtual ~A() {} void hello() {} enum MemberEnum { memberenum1=10, memberenum2 }; virtual MemberEnum member_virtual_test(MemberEnum e) { return e; } virtual GlobalEnum global_virtual_test(GlobalEnum e) { return global_test(e); } }; #endif swig-3.0.2/Examples/test-suite/using_directive_and_declaration_forward.i0000664000175000017500000000645712343605122026513 0ustar williamwilliam%module using_directive_and_declaration_forward // Test using directives combined with using declarations and forward declarations %inline %{ namespace Outer1 { namespace Space1 { class Thing1; } } using namespace Outer1::Space1; using Outer1::Space1::Thing1; #ifdef __clang__ namespace Outer1 { namespace Space1 { class Thing1 {}; } } #else class Thing1 {}; #endif void useit1(Thing1 t) {} void useit1a(Outer1::Space1::Thing1 t) {} void useit1b(::Outer1::Space1::Thing1 t) {} namespace Outer1 { void useit1c(Space1::Thing1 t) {} } namespace Outer2 { namespace Space2 { class Thing2; } } using namespace Outer2; using Space2::Thing2; using namespace Outer1::Space1; using Outer1::Space1::Thing1; #ifdef __clang__ namespace Outer2 { namespace Space2 { class Thing2 {}; } } #else class Thing2 {}; #endif void useit2(Thing2 t) {} void useit2a(Outer2::Space2::Thing2 t) {} void useit2b(::Outer2::Space2::Thing2 t) {} void useit2c(Space2::Thing2 t) {} namespace Outer2 { void useit2d(Space2::Thing2 t) {} } namespace Outer3 { namespace Space3 { namespace Middle3 { class Thing3; } } } using namespace Outer3; using namespace Space3; using Middle3::Thing3; #ifdef __clang__ namespace Outer3 { namespace Space3 { namespace Middle3 { class Thing3 {}; } } } #else class Thing3 {}; #endif void useit3(Thing3 t) {} void useit3a(Outer3::Space3::Middle3::Thing3 t) {} void useit3b(::Outer3::Space3::Middle3::Thing3 t) {} void useit3c(Middle3::Thing3 t) {} namespace Outer3 { namespace Space3 { void useit3d(Middle3::Thing3 t) {} } } namespace Outer4 { namespace Space4 { namespace Middle4 { class Thing4; } } } using namespace Outer4::Space4; using Middle4::Thing4; #ifdef __clang__ namespace Outer4 { namespace Space4 { namespace Middle4 { class Thing4 {}; } } } #else class Thing4 {}; #endif void useit4(Thing4 t) {} void useit4a(Outer4::Space4::Middle4::Thing4 t) {} void useit4b(::Outer4::Space4::Middle4::Thing4 t) {} void useit4c(Middle4::Thing4 t) {} namespace Outer4 { namespace Space4 { void useit4d(Middle4::Thing4 t) {} } } namespace Outer5 { namespace Space5 { namespace Middle5 { namespace More5 { class Thing5; } } } } using namespace ::Outer5::Space5; using namespace Middle5; using More5::Thing5; #ifdef __clang__ namespace Outer5 { namespace Space5 { namespace Middle5 { namespace More5 { class Thing5 {}; } } } } #else class Thing5 {}; #endif void useit5(Thing5 t) {} void useit5a(Outer5::Space5::Middle5::More5::Thing5 t) {} void useit5b(::Outer5::Space5::Middle5::More5::Thing5 t) {} void useit5c(Middle5::More5::Thing5 t) {} namespace Outer5 { namespace Space5 { void useit5d(Middle5::More5::Thing5 t) {} } } namespace Outer7 { namespace Space7 { namespace Middle7 { class Thing7; } } } using namespace Outer7::Space7; #ifdef __clang__ namespace Outer7 { namespace Space7 { namespace Middle7 { class Thing7 {}; } } } #else class Middle7::Thing7 {}; #endif using Middle7::Thing7; void useit7(Thing7 t) {} void useit7a(Outer7::Space7::Middle7::Thing7 t) {} void useit7b(::Outer7::Space7::Middle7::Thing7 t) {} void useit7c(Middle7::Thing7 t) {} namespace Outer7 { namespace Space7 { void useit7d(Middle7::Thing7 t) {} } } %} swig-3.0.2/Examples/test-suite/typemap_qualifier_strip.i0000664000175000017500000000234312343605122023344 0ustar williamwilliam%module typemap_qualifier_strip %typemap(freearg) int *ptr "" %typemap(freearg) int *const ptrConst "" %typemap(freearg) int const* constPtr "" %typemap(in) int *ptr { int temp = 1234; $1 = &temp; } %typemap(in) int *const ptrConst { int temp = 5678; $1 = &temp; } %typemap(in) int const* constPtr { int temp = 3456; $1 = &temp; } %inline %{ int *create_int(int newval) { static int val = 0; val = newval; return &val; } int testA1(int const*const ptr) { return *ptr; } int testA2(int const* ptr) { return *ptr; } int testA3(int *const ptr) { return *ptr; } int testA4(int * ptr) { return *ptr; } int testB1(int const*const p) { return *p; } int testB2(int const* p) { return *p; } int testB3(int *const p) { return *p; } int testB4(int * p) { return *p; } int testC1(int const*const ptrConst) { return *ptrConst; } int testC2(int const* ptrConst) { return *ptrConst; } int testC3(int *const ptrConst) { return *ptrConst; } int testC4(int * ptrConst) { return *ptrConst; } int testD1(int const*const constPtr) { return *constPtr; } int testD2(int const* constPtr) { return *constPtr; } int testD3(int *const constPtr) { return *constPtr; } int testD4(int * constPtr) { return *constPtr; } %} swig-3.0.2/Examples/test-suite/li_boost_shared_ptr_template.i0000664000175000017500000000400012343605122024313 0ustar williamwilliam%module li_boost_shared_ptr_template // First test- Bug 3333549 - using INTEGER typedef in %shared_ptr before typedef defined %{ #include #ifdef SWIGR // remove naming conflict with R symbol #define INTEGER MYINTEGER #endif typedef int INTEGER; template class Base { public: virtual T bar() {return 1;} }; template class Derived : public Base { public: virtual T bar() {return 2;} }; INTEGER bar_getter(Base& foo) { return foo.bar(); } %} #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) %include %shared_ptr(Base) %shared_ptr(Derived) #endif typedef int INTEGER; template class Base { public: virtual T bar() {return 1;} }; template class Derived : public Base { public: virtual T bar() {return 2;} }; INTEGER bar_getter(Base& foo) { return foo.bar(); } %template(BaseINTEGER) Base; %template(DerivedINTEGER) Derived; // 2nd test - templates with default template parameters #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) %shared_ptr(Space::BaseDefault) %shared_ptr(Space::DerivedDefault) %shared_ptr(Space::DerivedDefault2) #endif %inline %{ namespace Space { typedef int INT_TYPEDEF; template class BaseDefault { public: virtual T bar2() {return 3;} }; template class DerivedDefault : public BaseDefault { public: virtual T bar2() {return 4;} }; template class DerivedDefault2 : public BaseDefault { public: virtual int bar2() {return 4;} }; int bar2_getter(BaseDefault& foo) { return foo.bar2(); } } %} %template(BaseDefaultInt) Space::BaseDefault; %template(DerivedDefaultInt) Space::DerivedDefault; %template(DerivedDefaultInt2) Space::DerivedDefault2; swig-3.0.2/Examples/test-suite/autodoc.i0000664000175000017500000000717512343605122020051 0ustar williamwilliam%module(docstring="hello") autodoc %feature("autodoc"); // special typemap and its docs %typemap(in) (int c, int d) "$1 = 0; $2 = 0;"; %typemap(doc,name="hello",type="Tuple") (int c, int d) "hello: int tuple[2]"; // testing for different documentation levels %feature("autodoc","0") A::func0; // names %feature("autodoc","1") A::func1; // names + types %feature("autodoc","2") A::func2; // extended %feature("autodoc","3") A::func3; // extended + types %feature("autodoc","0") A::func0default; // names %feature("autodoc","1") A::func1default; // names + types %feature("autodoc","2") A::func2default; // extended %feature("autodoc","3") A::func3default; // extended + types %feature("autodoc","0") A::func0static; // names %feature("autodoc","1") A::func1static; // names + types %feature("autodoc","2") A::func2static; // extended %feature("autodoc","3") A::func3static; // extended + types %feature("autodoc","0") A::variable_a; // names %feature("autodoc","1") A::variable_b; // names + types %feature("autodoc","2") A::variable_c; // extended %feature("autodoc","3") A::variable_d; // extended + types %feature("autodoc","just a string") A::funk; // names %inline { enum Hola { hi, hello }; struct A { A(int a, short b, Hola h) {} int funk(int a) { return a; } int func0(short, int c, int d) { return c; } int func1(short, int c, int d) { return c; } int func2(short, int c, int d) { return c; } int func3(short, int c, int d) { return c; } int func0default(A *e, short, int c, int d, double f = 2) { return 0; } int func1default(A *e, short, int c, int d, double f = 2) { return 0; } int func2default(A *e, short, int c, int d, double f = 2) { return 0; } int func3default(A *e, short, int c, int d, double f = 2) { return 0; } static int func0static(A *e, short, int c, int d, double f = 2) { return 0; } static int func1static(A *e, short, int c, int d, double f = 2) { return 0; } static int func2static(A *e, short, int c, int d, double f = 2) { return 0; } static int func3static(A *e, short, int c, int d, double f = 2) { return 0; } int variable_a; int variable_b; int variable_c; int variable_d; }; } // deleting typemaps and docs %typemap(in) (int c, int d) ; %typemap(doc) (int c, int d); // docs for some parameters %typemap(doc) int a "a: special comment for parameter a"; %typemap(doc) int b "b: another special comment for parameter b"; %feature("autodoc","0") C::C(int a, int b, Hola h); // names %feature("autodoc","1") D::D(int a, int b, Hola h); // names + types %feature("autodoc","2") E::E(int a, int b, Hola h); // extended %feature("autodoc","3") F::F(int a, int b, Hola h); // extended + types %inline { struct B { B(int a, int b, Hola h) {} int funk(int c, int d) { return c; } }; struct C { C(int a, int b, Hola h) {} }; struct D { D(int a, int b, Hola h) {} }; struct E { E(int a, int b, Hola h) {} }; struct F { F(int a, int b, Hola h) {} }; int funk(A *e, short, int c, int d) { return c; } int funkdefaults(A *e, short, int c, int d, double f = 2) { return c; } } %include %inline %{ int func_input(int *INPUT) { return 1; } int func_output(int *OUTPUT) { *OUTPUT = 2; return 1; } int func_inout(int *INOUT) { *INOUT += 1; return 1; } %} %callback("%(uppercase)s_CALLBACK") func_cb; %inline { int func_cb(int c, int d) { return c; } } // Bug 3310528 %feature("autodoc","1") banana; // names + types %inline %{ typedef struct tagS { int a; char b; } S; typedef int Integer; void banana(S *a, const struct tagS *b, int c, Integer d) {} %} swig-3.0.2/Examples/test-suite/array_typedef_memberin.i0000664000175000017500000000166012343605122023120 0ustar williamwilliam%module array_typedef_memberin %inline %{ typedef short Eight[8]; typedef const short ConstEight[8]; namespace ArrayExample { class ExampleDetail { 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) {} void fn3(ConstEight a) {} void fn4(Eight* a) {} void fn5(ConstEight* a) {} void fn6(const ConstEight* a) {} void fn7(Eight*& a) {} void fn8(ConstEight*& a) {} void fn9(const ConstEight*& a) {} }; } typedef int Four[4]; typedef const int ConstFour[4]; void test_1(int (*v)[4]) {} void test_2(Four *v) {} void test_3(const Four *v) {} void test_4(ConstFour *v) {} void test_5(const int (*v)[4]) {} void test_3r(const Four *&v) {} void test_4r(ConstFour *&v) {} %} swig-3.0.2/Examples/test-suite/packageoption.list0000664000175000017500000000006012343605122021744 0ustar williamwilliampackageoption_a packageoption_b packageoption_c swig-3.0.2/Examples/test-suite/li_implicit.i0000664000175000017500000000051212343605122020675 0ustar williamwilliam%module("nocastmode") li_implicit #pragma SWIG nowarn=SWIGWARN_PP_CPP_WARNING %include implicit.i %inline { struct B { }; } %implicit(A, int, double, B); %inline { struct A { int ii; A(int i) { ii = 1; } A(double d) { ii = 2; } A(const B& b) { ii = 3; } }; int get(const A& a) { return a.ii; } } swig-3.0.2/Examples/test-suite/director_classes.i0000664000175000017500000001115112343605122021730 0ustar williamwilliam// Tests classes passed by value, pointer and reference // Note: C# module has a large runtime test %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ref; %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ptr; %module(directors="1") director_classes %feature("director") Base; %feature("director") Derived; %include "std_string.i" %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, hidevf) #endif %} %inline %{ #include #include // Use for debugging bool PrintDebug = false; struct DoubleHolder { DoubleHolder(double v = 0.0) : val(v) {} double val; }; class Base { protected: double m_dd; public: Base(double dd) : m_dd(dd) {} virtual ~Base() {} virtual DoubleHolder Val(DoubleHolder x) { if (PrintDebug) std::cout << "Base - Val(" << x.val << ")" << std::endl; return x; } virtual DoubleHolder& Ref(DoubleHolder& x) { if (PrintDebug) std::cout << "Base - Ref(" << x.val << ")" << std::endl; return x; } virtual DoubleHolder* Ptr(DoubleHolder* x) { if (PrintDebug) std::cout << "Base - Ptr(" << x->val << ")" << std::endl; return x; } virtual std::string FullyOverloaded(int x) { if (PrintDebug) std::cout << "Base - FullyOverloaded(int " << x << ")" << std::endl; return "Base::FullyOverloaded(int)"; } virtual std::string FullyOverloaded(bool x) { if (PrintDebug) std::cout << "Base - FullyOverloaded(bool " << x << ")" << std::endl; return "Base::FullyOverloaded(bool)"; } virtual std::string SemiOverloaded(int x) { if (PrintDebug) std::cout << "Base - SemiOverloaded(int " << x << ")" << std::endl; return "Base::SemiOverloaded(int)"; } virtual std::string SemiOverloaded(bool x) { if (PrintDebug) std::cout << "Base - SemiOverloaded(bool " << x << ")" << std::endl; return "Base::SemiOverloaded(bool)"; } virtual std::string DefaultParms(int x, double y = 1.1) { if (PrintDebug) std::cout << "Base - DefaultParms(" << x << ", " << y << ")" << std::endl; std::string ret("Base::DefaultParms(int"); if (y!=1.1) ret = ret + std::string(", double"); ret = ret + std::string(")"); return ret; } }; class Derived : public Base { public: Derived(double dd) : Base(dd) {} virtual ~Derived() {} virtual DoubleHolder Val(DoubleHolder x) { if (PrintDebug) std::cout << "Derived - Val(" << x.val << ")" << std::endl; return x; } virtual DoubleHolder& Ref(DoubleHolder& x) { if (PrintDebug) std::cout << "Derived - Ref(" << x.val << ")" << std::endl; return x; } virtual DoubleHolder* Ptr(DoubleHolder* x) { if (PrintDebug) std::cout << "Derived - Ptr(" << x->val << ")" << std::endl; return x; } virtual std::string FullyOverloaded(int x) { if (PrintDebug) std::cout << "Derived - FullyOverloaded(int " << x << ")" << std::endl; return "Derived::FullyOverloaded(int)"; } virtual std::string FullyOverloaded(bool x) { if (PrintDebug) std::cout << "Derived - FullyOverloaded(bool " << x << ")" << std::endl; return "Derived::FullyOverloaded(bool)"; } virtual std::string SemiOverloaded(int x) { if (PrintDebug) std::cout << "Derived - SemiOverloaded(int " << x << ")" << std::endl; return "Derived::SemiOverloaded(int)"; } // No SemiOverloaded(bool x) virtual std::string DefaultParms(int x, double y = 1.1) { if (PrintDebug) std::cout << "Derived - DefaultParms(" << x << ", " << y << ")" << std::endl; std::string ret("Derived::DefaultParms(int"); if (y!=1.1) ret = ret + std::string(", double"); ret = ret + std::string(")"); return ret; } }; class Caller { private: Base *m_base; void delBase() { delete m_base; m_base = 0; } public: Caller(): m_base(0) {} ~Caller() { delBase(); } void set(Base *b) { delBase(); m_base = b; } void reset() { m_base = 0; } DoubleHolder ValCall(DoubleHolder x) { return m_base->Val(x); } DoubleHolder& RefCall(DoubleHolder& x) { return m_base->Ref(x); } DoubleHolder* PtrCall(DoubleHolder* x) { return m_base->Ptr(x); } std::string FullyOverloadedCall(int x) { return m_base->FullyOverloaded(x); } std::string FullyOverloadedCall(bool x) { return m_base->FullyOverloaded(x); } std::string SemiOverloadedCall(int x) { return m_base->SemiOverloaded(x); } std::string SemiOverloadedCall(bool x) { return m_base->SemiOverloaded(x); } std::string DefaultParmsCall(int x) { return m_base->DefaultParms(x); } std::string DefaultParmsCall(int x, double y) { return m_base->DefaultParms(x, y); } }; %} %feature(director) BaseClass; %feature(director) DerivedClass; %inline %{ class BaseClass { public: virtual ~BaseClass() {}; virtual int dofoo(int& one, int& two, int& three) {return 0;} }; class DerivedClass : public BaseClass { }; %} swig-3.0.2/Examples/test-suite/director_ignore.i0000664000175000017500000000731212343605122021562 0ustar williamwilliam%module(directors="1") director_ignore %warnfilter(SWIGWARN_LANG_DIRECTOR_ABSTRACT) DIgnoreOnlyConstructor; %include "std_string.i" %feature("director"); %ignore OverloadedMethod(int n, int xoffset = 0, int yoffset = 0); %ignore OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0); %ignore DIgnoreConstructor(bool b); %ignore DIgnoreOnlyConstructor(bool b); %ignore Pointers; %ignore References; %ignore PublicMethod1; %ignore PublicMethod2; %ignore PublicPureVirtualMethod1; %ignore PublicPureVirtualMethod2; %ignore ProtectedMethod1; %ignore ProtectedMethod2; %ignore ProtectedPureVirtualMethod1; %ignore ProtectedPureVirtualMethod2; %typemap(imtype, inattributes="[inattributes should not be used]", outattributes="[outattributes should not be used]", directorinattributes="[directorinattributes should not be used]", directoroutattributes="[directoroutattributes should not be used]" ) int& "imtype should not be used" %inline %{ #include class DIgnores { public: virtual ~DIgnores() {} virtual void OverloadedMethod(int n, int xoffset = 0, int yoffset = 0) {} virtual void OverloadedMethod(bool b) {} virtual int Triple(int n) { return n*3; } virtual int& References(int& n) { static int nn; nn=n; return nn; } virtual int* Pointers(int* n) { static int nn; nn=*n; return &nn; } virtual double PublicMethod1() { return 0.0; } virtual double PublicPureVirtualMethod1() = 0; virtual void PublicMethod2() {} virtual void PublicPureVirtualMethod2() = 0; virtual void TempMethod() = 0; protected: virtual void OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0) {} virtual void OverloadedProtectedMethod() {} virtual double ProtectedMethod1() { return 0.0; } virtual double ProtectedPureVirtualMethod1() = 0; virtual void ProtectedMethod2() {} virtual void ProtectedPureVirtualMethod2() = 0; }; class DAbstractIgnores { public: virtual ~DAbstractIgnores() {} virtual double OverloadedMethod(int n, int xoffset = 0, int yoffset = 0) = 0; virtual double OverloadedMethod(bool b) = 0; virtual int Quadruple(int n) { return n*4; } virtual int& References(int& n) { static int nn; nn=n; return nn; } virtual int* Pointers(int* n) { static int nn; nn=*n; return &nn; } protected: virtual double OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0) = 0; virtual double OverloadedProtectedMethod() = 0; }; template class DTemplateAbstractIgnores { T t; public: virtual ~DTemplateAbstractIgnores() {} virtual double OverloadedMethod(int n, int xoffset = 0, int yoffset = 0) = 0; virtual double OverloadedMethod(bool b) = 0; virtual int Quadruple(int n) { return n*4; } virtual int& References(int& n) { static int nn; nn=n; return nn; } virtual int* Pointers(int* n) { static int nn; nn=*n; return &nn; } protected: virtual double OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0) = 0; virtual double OverloadedProtectedMethod() = 0; }; %} %template(DTemplateAbstractIgnoresInt) DTemplateAbstractIgnores; class DIgnoreConstructor { public: virtual ~DIgnoreConstructor() {} DIgnoreConstructor(std::string s, int i) {} DIgnoreConstructor(bool b) {} }; class DIgnoreOnlyConstructor { public: virtual ~DIgnoreOnlyConstructor() {} DIgnoreOnlyConstructor(bool b) {} }; %{ class DIgnoreConstructor { public: virtual ~DIgnoreConstructor() {} DIgnoreConstructor(std::string s, int i) {} private: // Hide constructor DIgnoreConstructor(bool b) {} }; class DIgnoreOnlyConstructor { public: virtual ~DIgnoreOnlyConstructor() {} private: // Hide constructor DIgnoreOnlyConstructor(bool b) {} }; %} swig-3.0.2/Examples/test-suite/template_namespace_forward_declaration.i0000664000175000017500000000144212343605122026322 0ustar williamwilliam%module template_namespace_forward_declaration %inline %{ namespace Space1 { namespace Space2 { template struct XXX; template struct YYY; } template struct Space2::YYY { T yyy(T h) { return h; } }; template struct Space1::Space2::XXX { T xxx(T h) { return h; } }; void testXXX1(Space1::Space2::XXX xx) { } void testXXX2(Space2::XXX xx) { } void testXXX3(::Space1::Space2::XXX xx) { } void testYYY1(Space1::Space2::YYY yy) { } void testYYY2(Space2::YYY yy) { } void testYYY3(::Space1::Space2::YYY yy) { } } %} %template(XXXInt) Space1::Space2::XXX; %template(YYYInt) Space1::Space2::YYY; swig-3.0.2/Examples/test-suite/smart_pointer_not.i0000664000175000017500000000114512343605122022150 0ustar williamwilliam// Test cases for classes that do *NOT* result in smart-pointer wrapping %module smart_pointer_not %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, arrowrtn) /* Questionable return type for ... */ #endif %} %inline %{ struct Foo { int x; int getx() { return x; } }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } Foo operator->() { return *f; } }; class Spam { Foo *f; public: Spam(Foo *f) : f(f) { } Foo &operator->() { return *f; } }; class Grok { Foo *f; public: Grok(Foo *f) : f(f) { } Foo **operator->() { return &f; } }; %} swig-3.0.2/Examples/test-suite/imports_b.h0000664000175000017500000000070012343605122020373 0ustar williamwilliam#include "imports_a.h" class B : public A { public: B() {}; void bye() {} ; virtual MemberEnum member_virtual_test(MemberEnum e) { return memberenum2; } virtual GlobalEnum global_virtual_test(GlobalEnum e) { return globalenum2; } }; A::MemberEnum global_test(A::MemberEnum e) { return e; } struct C : A { typedef A a_type; A* get_a(A* a) { return a; } a_type* get_a_type(a_type* a) { return a; } }; swig-3.0.2/Examples/test-suite/enum_scope_template.i0000664000175000017500000000060512343605122022432 0ustar williamwilliam%module enum_scope_template #ifdef SWIGPHP // php internal naming conflict %rename (chops) chop; #endif %inline %{ template class Tree { public: enum types {Oak, Fir, Cedar}; void chop(enum types type) {} }; enum Tree::types chop(enum Tree::types type) { return type; } %} %template(TreeInt) Tree; swig-3.0.2/Examples/test-suite/director_default.i0000664000175000017500000000262712343605122021727 0ustar williamwilliam%module(directors="1") director_default %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DefaultsBase; %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DefaultsDerived; %{ #include class Foo { public: Foo(int i = -1) {} virtual ~Foo() {} virtual std::string Msg(std::string msg = "default") { return "Foo-" + msg; } std::string GetMsg() { return Msg(); } std::string GetMsg(std::string msg) { return Msg(msg); } }; %} %include %feature("director") Foo; class Foo { public: Foo(int i = -1) {} virtual ~Foo() {} virtual std::string Msg(std::string msg = "default") { return msg; } std::string GetMsg() { return Msg(); } std::string GetMsg(std::string msg) { return Msg(msg); } }; %inline %{ class Bar { public: Bar() {} Bar(int i) {} virtual ~Bar() {} virtual std::string Msg(std::string msg = "default") { return "Bar-" + msg; } std::string GetMsg() { return Msg(); } std::string GetMsg(std::string msg) { return Msg(msg); } }; %} %feature("director") DefaultsBase; %feature("director") DefaultsDerived; %inline %{ typedef int* IntegerPtr; typedef double Double; struct DefaultsBase { virtual IntegerPtr defaultargs(double d, int * a = 0) = 0; virtual ~DefaultsBase() {} }; struct DefaultsDerived : DefaultsBase { int * defaultargs(Double d, IntegerPtr a = 0) { return 0; } }; %} swig-3.0.2/Examples/test-suite/java_nspacewithoutpackage.i0000664000175000017500000000127512343605122023620 0ustar williamwilliam%module java_nspacewithoutpackage %warnfilter(SWIGWARN_JAVA_NSPACE_WITHOUT_PACKAGE) TopLevel::Foo; %warnfilter(SWIGWARN_JAVA_NSPACE_WITHOUT_PACKAGE) TopLevel::Bar; %pragma(java) jniclasspackage="PragmaDefinedPackage" SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) %include %nspace TopLevel::Foo; %nspace TopLevel::Bar; %{ #include %} %inline %{ namespace TopLevel { class Foo { public: virtual ~Foo() {} virtual std::string ping() { return "TopLevel::Foo::ping()"; } }; class Bar { public: virtual ~Bar() {} virtual std::string pong() { return "TopLevel::Bar::pong()"; } }; } %} swig-3.0.2/Examples/test-suite/li_std_except.i0000664000175000017500000000315212343605122021230 0ustar williamwilliam%module li_std_except %include %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %inline %{ struct E1 : public std::exception { }; struct E2 { }; struct Test { int foo1() throw(std::bad_exception) { return 0; } int foo2() throw(std::logic_error) { return 0; } int foo3() throw(E1) { return 0; } int foo4() throw(E2) { return 0; } // all the STL exceptions... void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); } void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); } void throw_exception() throw(std::exception) { throw std::exception(); } void throw_invalid_argument() throw(std::invalid_argument) { throw std::invalid_argument("oops"); } void throw_length_error() throw(std::length_error) { throw std::length_error("oops"); } void throw_logic_error() throw(std::logic_error) { throw std::logic_error("oops"); } void throw_out_of_range() throw(std::out_of_range) { throw std::out_of_range("oops"); } void throw_overflow_error() throw(std::overflow_error) { throw std::overflow_error("oops"); } void throw_range_error() throw(std::range_error) { throw std::range_error("oops"); } void throw_runtime_error() throw(std::runtime_error) { throw std::runtime_error("oops"); } void throw_underflow_error() throw(std::underflow_error) { throw std::underflow_error("oops"); } }; %} swig-3.0.2/Examples/test-suite/template_partial_specialization_typedef.i0000664000175000017500000001162412343605122026552 0ustar williamwilliam// This testcase is almost identical to template_partial_specialization but uses typedefs for %template %module template_partial_specialization_typedef %inline %{ namespace TypeDef { typedef double Double; typedef int * IntPtr; typedef double * DoublePtr; typedef double & DoubleRef; typedef const double & ConstDoubleRef; typedef double * const & DoublePtrConstRef; typedef int Int; typedef int * const & IntPtrConstRef; typedef int ** IntPtrPtr; typedef float Float; typedef float * FloatPtr; typedef float ** FloatPtrPtr; typedef float *** FloatPtrPtrPtr; typedef bool * BoolPtr; typedef char * CharPtr; typedef short * ShortPtr; typedef long * LongPtr; typedef unsigned int ** UnsignedIntPtrPtr; typedef unsigned int *** UnsignedIntPtrPtrPtr; typedef const unsigned int ** ConstUnsignedIntPtr; typedef const unsigned int *** ConstUnsignedIntPtrPtr; } namespace One { template struct OneParm { void a() {} }; template struct OneParm { void b() {} }; template struct OneParm { void c() {} }; template struct OneParm { void d() {} }; template struct OneParm { void e() {} }; template <> struct OneParm { void f() {} }; template <> struct OneParm { void g() {} }; template <> struct OneParm { void h() {} }; template <> struct OneParm { void i() {} }; template <> struct OneParm { void j() {} }; template <> struct OneParm { void k() {} }; template <> struct OneParm { void l() {} }; } %} // partial specializations %template(A) One::OneParm; %template(B) One::OneParm; %template(C) One::OneParm; %template(D) One::OneParm; %template(E) One::OneParm; // explicit specializations %template(F) One::OneParm; %template(G) One::OneParm; %template(H) One::OneParm; // %template scope explicit specializations namespace ONE { %template(I) One::OneParm; %template(J) ::One::OneParm; } %template(K) ::One::OneParm; namespace One { %template(L) OneParm; } // %template scope partial specializations namespace ONE { %template(BB) One::OneParm; %template(BBB) ::One::OneParm; } %template(BBBB) ::One::OneParm; namespace One { %template(BBBBB) OneParm; } // non-exact match %template(B1) One::OneParm; %template(B2) One::OneParm; %template(B3) One::OneParm; %template(B4) One::OneParm; // Two parameter specialization tests %inline %{ struct Concrete {}; namespace Two { template struct TwoParm { void a() {} }; template struct TwoParm { void b() {} }; template struct TwoParm { void c() {} }; template struct TwoParm { void d() {} }; template struct TwoParm { void e() {} }; template struct TwoParm { void f() {} }; template <> struct TwoParm { void g() {} }; } %} %inline %{ namespace TypeDef { typedef const double * ConstDoublePtr; typedef const int * ConstIntPtr; typedef int * IntPtr; typedef Concrete * ConcretePtr; typedef const Concrete * ConstConcretePtr; typedef void * VoidPtr; } %} namespace Two { %template(A_) TwoParm; %template(B_) TwoParm; %template(C_) TwoParm; %template(D_) TwoParm; %template(E_) TwoParm; %template(F_) TwoParm; %template(G_) TwoParm; %template(C1_) TwoParm; %template(C2_) TwoParm; } %template(C3_) Two::TwoParm; %template(C4_) ::Two::TwoParm; %template(B1_) ::Two::TwoParm; %template(E1_) Two::TwoParm; %template(E2_) Two::TwoParm; swig-3.0.2/Examples/test-suite/imports_a.i0000664000175000017500000000073312343605122020401 0ustar williamwilliam/* This file is part of a test for SF bug #231619. It shows that the %import directive does not work properly in SWIG 1.3a5: Type information is not properly generated if a base class comes from an %import-ed file. */ %module imports_a %warnfilter(SWIGWARN_RUBY_WRONG_NAME) A::MemberEnum; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) GlobalEnum; /* Ruby, wrong constant name */ %{ #include "imports_a.h" %} %include "imports_a.h" swig-3.0.2/Examples/test-suite/director_wstring.i0000664000175000017500000000237012343605122021773 0ustar williamwilliam%module(directors="1") director_wstring; %include #ifndef SWIG_STL_UNIMPL %include std_vector.i %include std_wstring.i // Using thread unsafe wrapping %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) A; %{ #include #include %} %feature("director") A; %inline %{ struct A { A(const std::wstring& first) : m_strings(1, first) {} virtual ~A() {} virtual const std::wstring& get_first() const { return get(0); } virtual const std::wstring& get(int n) const { return m_strings[n]; } virtual const std::wstring& call_get_first() const { return get_first(); } virtual const std::wstring& call_get(int n) const { return get(n); } std::vector m_strings; virtual void process_text(const wchar_t *text) { } virtual std::wstring multiple_params_val(const std::wstring& p1, const std::wstring& p2, std::wstring p3, std::wstring p4) const { return get_first(); } virtual const std::wstring& multiple_params_ref(const std::wstring& p1, const std::wstring& p2, std::wstring p3, std::wstring p4) const { return get_first(); } void call_process_func() { process_text(L"hello"); } }; %} %template(StringVector) std::vector; #endif swig-3.0.2/Examples/test-suite/typemap_array_qualifiers.i0000664000175000017500000000357512343605122023514 0ustar williamwilliam%module typemap_array_qualifiers %define CLEAR_SWIGTYPE_TYPEMAPS %typemap(in) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE *const&, const SWIGTYPE *, const SWIGTYPE *const, const SWIGTYPE *const&, const volatile SWIGTYPE *, const volatile SWIGTYPE *const, const volatile SWIGTYPE *const&, SWIGTYPE [], SWIGTYPE [ANY], const SWIGTYPE [], const SWIGTYPE [ANY], const volatile SWIGTYPE [], const volatile SWIGTYPE [ANY], SWIGTYPE &, const SWIGTYPE &, const volatile SWIGTYPE & { %#error Incorrect typemap for $symname: $type } %enddef %inline %{ typedef struct { int a; } SomeType; typedef SomeType myarray[3]; typedef const SomeType myconstarray[4]; typedef volatile SomeType ** mycrazyarray[5]; typedef volatile SomeType (mycrazyfunc)(SomeType); typedef volatile SomeType (*mycrazyfuncptr)(SomeType); %} CLEAR_SWIGTYPE_TYPEMAPS; %typemap(in) SWIGTYPE [ANY] { $1 = 0; /* Correct typemap for $symname: $type */ } %inline %{ void func1a(myarray x) {} void func1b(volatile myarray x) {} %} CLEAR_SWIGTYPE_TYPEMAPS; %typemap(in) const SWIGTYPE [ANY] { $1 = 0; /* Correct typemap for $symname: $type */ } %typemap(in) const volatile SWIGTYPE [ANY] { $1 = 0; /* Correct typemap for $symname: $type */ } %inline %{ void func2a(const myarray x) {} void func2b(const myconstarray x) {} void func2c(const volatile myconstarray x) {} %} CLEAR_SWIGTYPE_TYPEMAPS; %typemap(in) volatile SWIGTYPE **const [ANY] { $1 = 0; /* Correct typemap for $symname: $type */ } %typemap(in) volatile SWIGTYPE **const [ANY][ANY] { $1 = 0; /* Correct typemap for $symname: $type */ } %inline %{ void func3a(const mycrazyarray x, const mycrazyarray y[7]) {} %} CLEAR_SWIGTYPE_TYPEMAPS; %typemap(in) SWIGTYPE (*const) (ANY) { $1 = 0; /* Correct typemap for $symname: $type */ } %inline %{ void func4a(mycrazyfunc *const x, const mycrazyfuncptr y) {} %} swig-3.0.2/Examples/test-suite/using_protected.i0000664000175000017500000000054012343605122021576 0ustar williamwilliam%module using_protected %inline %{ class Foo { protected: int x; int blah(int xx) { return xx; } virtual int vmethod(int xx) { return xx; } }; class FooBar : public Foo { public: using Foo::blah; using Foo::x; using Foo::vmethod; }; class FooBaz : public Foo { protected: using Foo::blah; using Foo::x; using Foo::vmethod; }; %} swig-3.0.2/Examples/test-suite/funcptr.i0000664000175000017500000000205112343605122020060 0ustar williamwilliam%module funcptr /* Complicated one that should defeat just reading , to find the number of arguments expected in the function pointer. extern void do(int (*op)(int (*i)(double, double), int j)); */ %inline %{ typedef double (*DistFun)(double* data, int r, int c, int i, int j, void *xdata); void distance(double *data, int *dim, DistFun fun, double *output) { } typedef int (*Operator)(int i,int j); int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int subtract(int a, int b) { return a-b; } int multiply(int a, int b) { return a*b; } int *nowt() { return 0; } int *nowt2(void) { return 0; } struct MyStruct { int i; }; typedef struct MyStruct * MyStructPtr; MyStructPtr mystructptr() { return 0; } typedef int * Integer; int (*funcvar)(int,int) = add; int * (*funcvar2)() = nowt; int * (*funcvar3)(void) = nowt2; Integer (*funcvar4)() = nowt; MyStructPtr (*funcvar5)() = mystructptr; void (*pfunc0)(); int (*pfuncA)(); void (*pfunc1)(int); void (*pfunc2)(int, double); %} swig-3.0.2/Examples/test-suite/constructor_ignore.i0000664000175000017500000000105012343605122022325 0ustar williamwilliam%module constructor_ignore %ignore Space::Delta1::Delta1(); %ignore Space::Delta2::Delta2(int i); %ignore Space::Delta3::Delta3; %ignore Space::Delta4::Delta4; %inline %{ namespace Space { struct Delta1 { }; struct Delta2 { Delta2(int i) {} }; struct Delta3 { Delta3(const Delta3&) {} Delta3() {} Delta3(int i) {} }; struct Delta4 { }; } %} %copyctor; %ignore Space::Delta5::Delta5; %ignore Space::Delta6::Delta6(const Space::Delta6&); %inline %{ namespace Space { struct Delta5 { }; struct Delta6 { }; } %} swig-3.0.2/Examples/test-suite/template_typedef_rec.i0000664000175000017500000000346412343605122022574 0ustar williamwilliam%module template_typedef_rec %inline %{ // --- includes required to compile the wrapper code --- typedef size_t MY_sizeT; typedef long MY_intT; typedef double MY_floatT; class test_Array { public: typedef MY_intT intT; typedef MY_sizeT sizeT; }; template class ArrayIterator_ { public: typedef test_Array::intT intT; }; template class ArrayReverseIterator { public: typedef test_Array::intT intT; }; template class ArrayPrimitiveT : public test_Array { public: typedef T ValueT; typedef T valueT; typedef ArrayIterator_ Iterator; typedef ArrayIterator_ ConstIterator; typedef ArrayReverseIterator ReverseIterator; typedef ArrayReverseIterator ConstReverseIterator; }; template class TreeNode { public: typedef T ValueT; typedef T valueT; typedef MY_intT intT; typedef MY_sizeT sizeT; }; template struct ArrayPointerT { }; template class TreeIterator { public: typedef MY_intT intT; typedef MY_sizeT sizeT; typedef ArrayPointerT< T* > NodeArrayT; }; template class Tree { public: typedef T ValueT; typedef T valueT; typedef MY_intT intT; typedef MY_sizeT sizeT; typedef TreeNode NodeT; typedef ArrayPointerT< NodeT* > NodeArrayT; typedef TreeIterator Iterator; typedef TreeIterator ConstIterator; }; class ModelNode { typedef MY_intT intT; typedef MY_floatT floatT; typedef MY_sizeT sizeT; }; class Model { typedef MY_intT intT; typedef MY_sizeT sizeT; typedef Tree TreeT; typedef TreeT::NodeT TreeNodeT; typedef TreeT::Iterator TreeIteratorT; }; %} // --- define ANSI C/C++ declarations to be interfaced --- %template(ModelTree) Tree; swig-3.0.2/Examples/test-suite/fragments.i0000664000175000017500000000061612343605122020372 0ustar williamwilliam%module fragments %fragment("Hello","header") %{ /* hello!!! */ int foobar(int a) { return a; } %} /* this fragment include the previous fragment if needed. */ %fragment("Hi","header",fragment="Hello") %{ /* hi!!! */ int bar(int a) { return foobar(a); } %} %typemap(in,fragment="Hi") int hola "$1 = 123;"; %inline %{ int bar(int a); int foo(int hola) { return bar(hola); } %} swig-3.0.2/Examples/test-suite/cpp11_thread_local.i0000664000175000017500000000164312343605122022032 0ustar williamwilliam/* This testcase checks whether SWIG correctly parses the 'thread_local' storage specifier */ %module cpp11_thread_local %inline %{ struct ThreadLocals { // thread_local int tval; // members must also be declared static static thread_local int stval; thread_local static int tsval; static thread_local const int stcval88 = 88; thread_local static const int tscval99 = 99; }; thread_local int tval; static thread_local int stval; thread_local static int tsval; extern thread_local int etval; thread_local extern int teval; extern "C" thread_local int ectval; extern "C++" thread_local int ecpptval; thread_local int ThreadLocals::stval = 11; thread_local int ThreadLocals::tsval = 22; thread_local const int ThreadLocals::stcval88; thread_local const int ThreadLocals::tscval99; %} %{ // externs thread_local int etval = 33; thread_local int teval = 44; thread_local int ectval = 55; thread_local int ecpptval = 66; %} swig-3.0.2/Examples/test-suite/conversion_namespace.i0000664000175000017500000000030512343605122022600 0ustar williamwilliam%module conversion_namespace %rename(toFoo) oss::Bar::operator Foo(); %inline %{ namespace oss { struct Foo { }; struct Bar { operator Foo () { return Foo(); } }; } %} swig-3.0.2/Examples/test-suite/director_redefined.i0000664000175000017500000000120412343605122022216 0ustar williamwilliam%module(directors="1") director_redefined /* This example generates two 'get_val' virtual members in the director, and since they are equivalent, the compilation fails. */ %feature("director") B; %inline { typedef int Int; struct A { virtual ~A() { } virtual int get_val(Int a) { return 0; } virtual int get_rval(const Int& a) { return 0; } }; struct B : A { int get_val(int a) { return 1; } int get_rval(const int& a) { return 1; } const int& get_rrval(const int& a) { return a; } }; } swig-3.0.2/Examples/test-suite/inout.i0000664000175000017500000000174412343605122017545 0ustar williamwilliam%module inout %include "typemaps.i" %include "std_pair.i" %{ inline void AddOne3(double* a, double* b, double* c) { *a += 1; *b += 1; *c += 1; } inline void AddOne1(double* a) { *a += 1; } inline void AddOne1p(std::pair* p) { p->first += 1; p->second += 1; } inline void AddOne2p(std::pair* p,double* a) { *a += 1; p->first += 1; p->second += 1; } inline void AddOne3p(double* a, std::pair* p,double* b) { *a += 1; *b += 1; p->first += 1; p->second += 1; } inline void AddOne1r(double& a) { a += 1; } %} %template() std::pair; void AddOne1(double* INOUT); void AddOne3(double* INOUT, double* INOUT, double* INOUT); void AddOne1p(std::pair* INOUT); void AddOne2p(std::pair* INOUT, double* INOUT); void AddOne3p(double* INOUT, std::pair* INOUT, double* INOUT); void AddOne1r(double& INOUT); swig-3.0.2/Examples/test-suite/typemap_ns_using.i0000664000175000017500000000047112343605122021767 0ustar williamwilliam%module typemap_ns_using %warnfilter(SWIGWARN_RUBY_WRONG_NAME) X::_FooImpl; /* Ruby, wrong class name */ %inline %{ namespace X { typedef int Integer; class _FooImpl { public: typedef Integer value_type; }; typedef _FooImpl Foo; } using X::Foo; int spam(Foo::value_type x) { return x; } %} swig-3.0.2/Examples/test-suite/template_default_class_parms.i0000664000175000017500000000140112343605122024303 0ustar williamwilliam%module template_default_class_parms %inline %{ namespace Space { struct SomeType {}; struct AnotherType {}; template class Bar { public: C CType; D DType; E EType; Bar(C c, D d, E e) {} C method(C c, D d, E e) { return c; } }; template class Foo { public: T TType; Foo(T t) {} T method(T t) { return t; } }; template class ATemplate {}; } %} // Use defaults %template(DefaultBar) Space::Bar; %template(DefaultFoo) Space::Foo<>; // Don't use all defaults %template(BarAnotherTypeBool) Space::Bar; %template(FooAnotherType) Space::Foo; %template() Space::ATemplate<>; swig-3.0.2/Examples/test-suite/using_composition.i0000664000175000017500000000265412343605122022160 0ustar williamwilliam%module(ruby_minherit="1") using_composition %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, D, Java, PHP multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar2; // C#, D, Java, PHP multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar3; // C#, D, Java, PHP multiple inheritance #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah; #endif %inline %{ class Foo { public: int blah(int x) { return x; } char *blah(char *x) { return x; } }; class Bar { public: double blah(double x) { return x; } }; class FooBar : public Foo, public Bar { public: using Foo::blah; using Bar::blah; char *blah(char *x) { return x; } }; class FooBar2 : public Foo, public Bar { public: char *blah(char *x) { return x; } using Foo::blah; using Bar::blah; }; class FooBar3 : public Foo, public Bar { public: using Foo::blah; char *blah(char *x) { return x; } using Bar::blah; }; %} swig-3.0.2/Examples/test-suite/cpp11_sizeof_object.i0000664000175000017500000000047312343605122022236 0ustar williamwilliam/* This testcase checks whether SWIG correctly uses the sizeof() on the concrete objects and not only types introduced in C++11. */ %module cpp11_sizeof_object %inline %{ struct B { unsigned long member1; long long member2; char member3; }; struct A { B member; }; const int a = sizeof(A::member); %} swig-3.0.2/Examples/test-suite/rename4.i0000664000175000017500000000637512343605122017747 0ustar williamwilliam// Test %rename directive with the 'using' keyword and within the class definition %module rename4 %{ #include "rename.h" %} namespace Space { struct Klass { Klass(int i) {} Klass() {} }; } namespace AnotherSpace { class Another {}; } namespace Space { %rename(opAnother1) XYZ::operator Another() const; %rename(opAnother2) XYZ::operator Another() const; %rename(opAnother3) XYZ::operator Another() const; %rename(opAnother4) XYZ::operator Another() const; } // Test %rename - no namespace, but specific templated type in the parameter, is used over the generic type T %rename(tMethod2) templateT(int i); %rename(tMethodNotXYZ2) templateNotXYZ(NotXYZ); %rename(tMethodXYZ2) templateXYZ(XYZ); %rename(opT2) operator int(); %rename(opNotXYZ2) operator NotXYZ() const; %rename(opXYZ2) operator XYZ() const; %rename(tMethod3) templateT(Space::Klass i); %rename(tMethodNotXYZ3) templateNotXYZ(NotXYZ); %rename(tMethodXYZ3) templateXYZ(XYZ); %rename(opT3) operator Space::Klass(); %rename(opNotXYZ3) operator NotXYZ() const; %rename(opXYZ3) operator XYZ() const; %rename(tMethod4) templateT(Space::Enu i); %rename(tMethodNotXYZ4) templateNotXYZ(NotXYZ); %rename(tMethodXYZ4) templateXYZ(XYZ); %rename(opT4) operator Space::Enu(); %rename(opNotXYZ4) operator NotXYZ() const; %rename(opXYZ4) operator XYZ() const; namespace Space { using namespace AnotherSpace; enum Enu { En1, En2, En3 }; template struct NotXYZ {}; template class XYZ { // Test %rename within the class %rename(opIntPtrA) operator NotXYZ*() const; %rename(opIntPtrB) operator XYZ*() const; %rename(tMethod1) templateT(T i); %rename(tMethodNotXYZ1) templateNotXYZ(NotXYZ); %rename(tMethodXYZ1) templateXYZ(XYZ); %rename(opT1) operator T(); %rename(opNotXYZ1) operator NotXYZ() const; %rename(opXYZ1) operator XYZ() const; NotXYZ *m_int; T m_t; NotXYZ m_notxyz; public: operator NotXYZ*() const { return m_int; } operator XYZ*() const { return 0; } operator Another() const { Another an; return an; } void templateT(T i) {} void templateNotXYZ(NotXYZ i) {} void templateXYZ(XYZ i) {} operator T() { return m_t; } operator NotXYZ() const { return m_notxyz; } operator XYZ() const { XYZ xyz; return xyz; } }; } namespace Space { // non-templated class using itself in method and operator class ABC { public: %rename(methodABC) method(ABC a) const; %rename(opABC) operator ABC() const; %rename(methodKlass) method(Klass k) const; %rename(opKlass) operator Klass() const; void method(ABC a) const {} void method(Klass k) const {} operator ABC() const { ABC a; return a; } operator Klass() const { Klass k; return k; } }; } %template(XYZInt) Space::XYZ; %template(XYZDouble) Space::XYZ; %template(XYZKlass) Space::XYZ; %template(XYZEnu) Space::XYZ; %template(NotXYZInt) Space::NotXYZ; %template(NotXYZDouble) Space::NotXYZ; %template(NotXYZKlass) Space::NotXYZ; %template(NotXYZEnu) Space::NotXYZ; swig-3.0.2/Examples/test-suite/function_typedef.i0000664000175000017500000000041512343605122021746 0ustar williamwilliam%module function_typedef %inline %{ typedef int binop_t(int, int); int do_binop1(binop_t f, int x, int y) { return f(x,y); } int do_binop2(binop_t *f, int x, int y) { return (*f)(x,y); } int do_binop3(int f(int,int), int x, int y) { return f(x,y); } %} swig-3.0.2/Examples/test-suite/template_virtual.i0000664000175000017500000000146212343605122021765 0ustar williamwilliam%module template_virtual // Submitted by Marcelo Matus // assertion emmitted with templates + derivation + pure virtual member // allocate.cxx:47: int Allocate::is_abstract_inherit(Node*, Node*): // Assertion `dn' failed. %inline %{ template class A { public: virtual ~A() { } virtual void say_hi() = 0; // only fails with pure virtual methods virtual void say_hello() {} // this works fine protected: A() { } // defined protected as swig generates constructor by default }; template class B : public A { protected: B() { } // defined protected as swig generates constructor by default }; %} %template(A_int) A; %template(B_int) B; // !!!! it crashes right here !!!!! swig-3.0.2/Examples/test-suite/namespace_enum.i0000664000175000017500000000034712343605122021365 0ustar williamwilliam%module namespace_enum %inline %{ namespace Foo { enum Swig { LAGER, STOUT, ALE }; class Bar { public: enum Speed { SLOW, FAST }; }; } %} swig-3.0.2/Examples/test-suite/overload_extendc.i0000664000175000017500000000067512343605122021736 0ustar williamwilliam%module overload_extendc %typemap(default) int int2 "$1=1000;"; %inline %{ typedef struct Foo { int dummy; } Foo; %} %extend Foo { int test(int x) { x = 0; return 1; } int test(char *s) { s = 0; return 2; } int test(double x, double y) { x = 0; y = 0; return 3; } int test(char *s, int int1, int int2) { s = 0; return int1+int2; } /* C default arguments */ int test(Foo* f, int i=10, int j=20) { return i+j; } }; swig-3.0.2/Examples/test-suite/template_ns4.i0000664000175000017500000000312212343605122020776 0ustar williamwilliam%module template_ns4 %inline %{ namespace hello { class Double { }; template struct Function_ { char *test() { return (char *) "test"; } }; template struct ArithFunction : Function_ { }; template struct traits { }; template struct traits { typedef ArgType arg_type; typedef double res_type; typedef ArithFunction base; }; template struct traits { typedef ArgType arg_type; typedef Double res_type; typedef ArithFunction base; }; template class Class_ : public ArithFunction< typename traits::arg_type, typename traits::res_type > { }; template typename traits::base make_Class() { return Class_(); } } %} %{ namespace hello { template struct Function_ ; template struct ArithFunction ; template class Class_ ; } %} namespace hello { // // This complains only when using a namespace // %template() traits; %template(Function_DD) Function_ ; %template(ArithFunction_DD) ArithFunction ; %template(Class_DD) Class_ ; %template(make_Class_DD) make_Class ; } swig-3.0.2/Examples/test-suite/curiously_recurring_template_pattern.i0000664000175000017500000000200712343605122026146 0ustar williamwilliam%module curiously_recurring_template_pattern // Test Curiously Recurring Template Pattern - CRTP %inline %{ template class Base { int base1Param; int base2Param; public: Base() : base1Param(0) {} int getBase1Param() { return base1Param; } T& setBase1Param(int value) { base1Param = value; return *static_cast(this); } int getBase2Param() { return base2Param; } T& setBase2Param(int value) { base2Param = value; return *static_cast(this); } virtual ~Base() {} }; %} %template(basederived) Base; %inline %{ class Derived : public Base { int derived1Param; int derived2Param; public: Derived() : derived1Param(0), derived2Param(0) {} int getDerived1Param() { return derived1Param; } Derived& setDerived1Param(int value) { derived1Param = value; return *this; } int getDerived2Param() { return derived2Param; } Derived& setDerived2Param(int value) { derived2Param = value; return *this; } }; %} swig-3.0.2/Examples/test-suite/javascript/0000775000175000017500000000000012343605122020375 5ustar williamwilliamswig-3.0.2/Examples/test-suite/javascript/abstract_typedef2_runme.js0000664000175000017500000000020312343605122025541 0ustar williamwilliamvar abstract_typedef2 = require("abstract_typedef2"); var a = new abstract_typedef2.A_UF(); if (a == undefined) throw "Error"; swig-3.0.2/Examples/test-suite/javascript/rename3_runme.js0000664000175000017500000000240012343605122023467 0ustar williamwilliamvar rename = require("rename3"); function part1() { var xyz = new rename.XYZInt(); notxyz = new rename.NotXYZInt(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother2(); xyz.opT2(); xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); xyz.opXYZ2(); } function part2() { var xyz = new rename.XYZDouble(); var notxyz = new rename.NotXYZDouble(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother1(); xyz.opT1(); xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); xyz.opXYZ1(); } function part3(){ var xyz = new rename.XYZKlass(); var notxyz = new rename.NotXYZKlass(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother3(); xyz.opT3(); xyz.tMethod3(new rename.Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); xyz.opXYZ3(); } function part4() { var xyz = new rename.XYZEnu(); var notxyz = new rename.NotXYZEnu(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother4(); xyz.opT4(); xyz.tMethod4(rename.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); xyz.opXYZ4(); } function part5() { var abc = new rename.ABC(); abc.methodABC(abc); var k = new rename.Klass(); abc.methodKlass(k); var a = abc.opABC(); k = abc.opKlass(); } part1(); part2(); part3(); part4(); part5(); swig-3.0.2/Examples/test-suite/javascript/abstract_inherit_runme.js0000664000175000017500000000153412343605122025471 0ustar williamwilliamvar abstract_inherit = require("abstract_inherit"); // Shouldn't be able to instantiate any of these classes // since none of them implements the pure virtual function // declared in the base class (Foo). var Foo = abstract_inherit.Foo; var Bar = abstract_inherit.Bar; var Spam = abstract_inherit.Spam; var caughtException = false; try { new Foo(); } catch (err) { caughtException = true; } if (!caughtException) { throw new Error("Foo should be instantiated as it is abstract"); } caughtException = false; try { new Bar(); } catch (err) { caughtException = true; } if (!caughtException) { throw new Error("Bar should be instantiated as it is abstract"); } caughtException = false; try { new Spam(); } catch (err) { caughtException = true; } if (!caughtException) { throw new Error("Spam should be instantiated as it is abstract"); } swig-3.0.2/Examples/test-suite/javascript/enum_template_runme.js0000664000175000017500000000025512343605122025002 0ustar williamwilliamvar enum_template = require("enum_template"); if (enum_template.MakeETest() != 1) throw "RuntimeError"; if (enum_template.TakeETest(0) != null) throw "RuntimeError"; swig-3.0.2/Examples/test-suite/javascript/typemap_ns_using_runme.js0000664000175000017500000000016412343605122025526 0ustar williamwilliamvar typemap_ns_using = require("typemap_ns_using"); if (typemap_ns_using.spam(37) != 37) throw "RuntimeError"; swig-3.0.2/Examples/test-suite/javascript/preproc_include_runme.js0000664000175000017500000000101712343605122025315 0ustar williamwilliamvar preproc_include = require("preproc_include"); if (preproc_include.multiply10(10) != 100) throw "RuntimeError"; if (preproc_include.multiply20(10) != 200) throw "RuntimeError"; if (preproc_include.multiply30(10) != 300) throw "RuntimeError"; if (preproc_include.multiply40(10) != 400) throw "RuntimeError"; if (preproc_include.multiply50(10) != 500) throw "RuntimeError"; if (preproc_include.multiply60(10) != 600) throw "RuntimeError"; if (preproc_include.multiply70(10) != 700) throw "RuntimeError"; swig-3.0.2/Examples/test-suite/javascript/char_binary_runme.js0000664000175000017500000000150212343605122024420 0ustar williamwilliamvar char_binary = require("char_binary"); var t = new char_binary.Test(); if (t.strlen('hile') != 4) { print(t.strlen('hile')); throw("bad multi-arg typemap 1"); } if (t.strlen('hil\0') != 4) { throw("bad multi-arg typemap 2"); } /* * creating a raw char* */ var pc = char_binary.new_pchar(5); char_binary.pchar_setitem(pc, 0, 'h'); char_binary.pchar_setitem(pc, 1, 'o'); char_binary.pchar_setitem(pc, 2, 'l'); char_binary.pchar_setitem(pc, 3, 'a'); char_binary.pchar_setitem(pc, 4, 0); if (t.strlen(pc) != 4) { throw("bad multi-arg typemap (3)"); } char_binary.var_pchar = pc; if (char_binary.var_pchar != "hola") { print(char_binary.var_pchar); throw("bad pointer case (1)"); } char_binary.var_namet = pc; if (char_binary.var_namet != "hola") { throw("bad pointer case (2)"); } char_binary.delete_pchar(pc); swig-3.0.2/Examples/test-suite/javascript/typemap_delete_runme.js0000664000175000017500000000017712343605122025147 0ustar williamwilliamvar typemap_delete = require("typemap_delete"); r = new typemap_delete.Rect(123); if (r.val != 123) throw "RuntimeError"; swig-3.0.2/Examples/test-suite/javascript/namespace_virtual_method_runme.js0000664000175000017500000000015612343605122027205 0ustar williamwilliamvar namespace_virtual_method = require("namespace_virtual_method"); x = new namespace_virtual_method.Spam(); swig-3.0.2/Examples/test-suite/javascript/typemap_arrays_runme.js0000664000175000017500000000017712343605122025206 0ustar williamwilliamvar typemap_arrays = require("typemap_arrays"); if (typemap_arrays.sumA(null) != 60) throw "RuntimeError, Sum is wrong"; swig-3.0.2/Examples/test-suite/javascript/rename2_runme.js0000664000175000017500000000240012343605122023466 0ustar williamwilliamvar rename = require("rename2"); function part1() { var xyz = new rename.XYZInt(); notxyz = new rename.NotXYZInt(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother2(); xyz.opT2(); xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); xyz.opXYZ2(); } function part2() { var xyz = new rename.XYZDouble(); var notxyz = new rename.NotXYZDouble(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother1(); xyz.opT1(); xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); xyz.opXYZ1(); } function part3(){ var xyz = new rename.XYZKlass(); var notxyz = new rename.NotXYZKlass(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother3(); xyz.opT3(); xyz.tMethod3(new rename.Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); xyz.opXYZ3(); } function part4() { var xyz = new rename.XYZEnu(); var notxyz = new rename.NotXYZEnu(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother4(); xyz.opT4(); xyz.tMethod4(rename.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); xyz.opXYZ4(); } function part5() { var abc = new rename.ABC(); abc.methodABC(abc); var k = new rename.Klass(); abc.methodKlass(k); var a = abc.opABC(); k = abc.opKlass(); } part1(); part2(); part3(); part4(); part5(); swig-3.0.2/Examples/test-suite/javascript/typedef_scope_runme.js0000664000175000017500000000031612343605122024772 0ustar williamwilliamvar typedef_scope = require("typedef_scope"); b = new typedef_scope.Bar(); x = b.test1(42,"hello"); if (x != 42) print("Failed!!"); x = b.test2(42,"hello"); if (x != "hello") print("Failed!!"); swig-3.0.2/Examples/test-suite/javascript/rename1_runme.js0000664000175000017500000000240012343605122023465 0ustar williamwilliamvar rename = require("rename1"); function part1() { var xyz = new rename.XYZInt(); notxyz = new rename.NotXYZInt(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother2(); xyz.opT2(); xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); xyz.opXYZ2(); } function part2() { var xyz = new rename.XYZDouble(); var notxyz = new rename.NotXYZDouble(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother1(); xyz.opT1(); xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); xyz.opXYZ1(); } function part3(){ var xyz = new rename.XYZKlass(); var notxyz = new rename.NotXYZKlass(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother3(); xyz.opT3(); xyz.tMethod3(new rename.Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); xyz.opXYZ3(); } function part4() { var xyz = new rename.XYZEnu(); var notxyz = new rename.NotXYZEnu(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother4(); xyz.opT4(); xyz.tMethod4(rename.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); xyz.opXYZ4(); } function part5() { var abc = new rename.ABC(); abc.methodABC(abc); var k = new rename.Klass(); abc.methodKlass(k); var a = abc.opABC(); k = abc.opKlass(); } part1(); part2(); part3(); part4(); part5(); swig-3.0.2/Examples/test-suite/javascript/overload_copy_runme.js0000664000175000017500000000015212343605122025004 0ustar williamwilliamvar overload_copy = require("overload_copy"); f = new overload_copy.Foo(); g = new overload_copy.Foo(f); swig-3.0.2/Examples/test-suite/javascript/null_pointer_runme.js0000664000175000017500000000040612343605122024653 0ustar williamwilliamvar null_pointer = require("null_pointer"); if (!null_pointer.func(null)) { throw new Error("Javascript 'null' should be converted into NULL."); } if (null_pointer.getnull() != null) { throw new Error("NULL should be converted into Javascript 'null'."); } swig-3.0.2/Examples/test-suite/javascript/complextest_runme.js0000664000175000017500000000065512343605122024516 0ustar williamwilliamvar complextest = require("complextest"); a = [-1,2]; expected = [-1, -2]; a_c = complextest.Conj(a); if (a_c.toString() != expected.toString()) throw "Error in Conj(a)"; a_c_f = complextest.Conjf(a); if (a_c_f.toString() != expected.toString()) throw "Error in Conjf(a)"; v = new complextest.VectorStdCplx(); v.add([1,2]); v.add([2,3]); v.add([4,3]); v.add(1); // TODO: how to check validity? complextest.Copy_h(v); swig-3.0.2/Examples/test-suite/javascript/abstract_access_runme.js0000664000175000017500000000017412343605122025267 0ustar williamwilliamvar abstract_access = require("abstract_access"); var d = new abstract_access.D() if (d.do_x() != 1) { throw "Error"; } swig-3.0.2/Examples/test-suite/javascript/typedef_class_runme.js0000664000175000017500000000017712343605122024773 0ustar williamwilliamvar typedef_class = require("typedef_class"); a = new typedef_class.RealA(); a.a = 3; b = new typedef_class.B(); b.testA(a); swig-3.0.2/Examples/test-suite/javascript/infinity_runme.js0000664000175000017500000000023612343605122023773 0ustar williamwilliamvar infinity = require("infinity"); infinity.initialise_MYINFINITY(); var my_infinity = infinity.INFINITY; var ret_val = infinity.use_infinity(my_infinity); swig-3.0.2/Examples/test-suite/javascript/rename4_runme.js0000664000175000017500000000240012343605122023470 0ustar williamwilliamvar rename = require("rename4"); function part1() { var xyz = new rename.XYZInt(); notxyz = new rename.NotXYZInt(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother2(); xyz.opT2(); xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); xyz.opXYZ2(); } function part2() { var xyz = new rename.XYZDouble(); var notxyz = new rename.NotXYZDouble(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother1(); xyz.opT1(); xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); xyz.opXYZ1(); } function part3(){ var xyz = new rename.XYZKlass(); var notxyz = new rename.NotXYZKlass(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother3(); xyz.opT3(); xyz.tMethod3(new rename.Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); xyz.opXYZ3(); } function part4() { var xyz = new rename.XYZEnu(); var notxyz = new rename.NotXYZEnu(); xyz.opIntPtrA(); xyz.opIntPtrB(); xyz.opAnother4(); xyz.opT4(); xyz.tMethod4(rename.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); xyz.opXYZ4(); } function part5() { var abc = new rename.ABC(); abc.methodABC(abc); var k = new rename.Klass(); abc.methodKlass(k); var a = abc.opABC(); k = abc.opKlass(); } part1(); part2(); part3(); part4(); part5(); swig-3.0.2/Examples/test-suite/javascript/using2_runme.js0000664000175000017500000000012612343605122023347 0ustar williamwilliamvar using2 = require("using2"); if (using2.spam(37) != 37) throw "RuntimeError"; swig-3.0.2/Examples/test-suite/javascript/abstract_virtual_runme.js0000664000175000017500000000027412343605122025515 0ustar williamwilliamvar abstract_virtual = require("abstract_virtual"); d = new abstract_virtual.D() if (d == undefined) throw "Error"; e = new abstract_virtual.E() if (e == undefined) throw "Error"; swig-3.0.2/Examples/test-suite/javascript/typemap_namespace_runme.js0000664000175000017500000000031612343605122025634 0ustar williamwilliamvar typemap_namespace = require("typemap_namespace"); if (typemap_namespace.test1("hello") != "hello") throw "RuntimeError"; if (typemap_namespace.test2("hello") != "hello") throw "RuntimeError"; swig-3.0.2/Examples/test-suite/javascript/rename_simple_runme.js0000664000175000017500000000320612343605122024762 0ustar williamwilliamvar rename_simple = require("rename_simple"); var NewStruct = rename_simple.NewStruct; var s = new NewStruct(); // renamed instance variable if (s.NewInstanceVariable !== 111) { throw new Error("NewInstanceVariable: Expected 111, was " + s.NewInstanceVariable); } // renamed instance method if (s.NewInstanceMethod() !== 222) { throw new Error("NewInstanceMethod(): Expected 222, was " + s.NewInstanceMethod()); } // renamed static method if (NewStruct.NewStaticMethod() !== 333) { throw new Error("NewInstanceMethod(): Expected 333, was " + NewStruct.NewStaticMethod()); } // renamed static variable if (NewStruct.NewStaticVariable !== 444) { throw new Error("NewInstanceMethod(): Expected 444, was " + NewStruct.NewStaticVariable); } // renamed global function if (rename_simple.NewFunction() !== 555) { throw new Error("rename_simple.NewFunction(): Expected 555, was " + rename_simple.NewFunction()); } // renamed global variable if (rename_simple.NewGlobalVariable !== 666) { throw new Error("rename_simple.NewGlobalVariable: Expected 666, was " + rename_simple.NewGlobalVariable); } // setting renamed variables s.NewInstanceVariable = 1111; if (s.NewInstanceVariable !== 1111) { throw new Error("NewInstanceVariable: Expected 1111, was " + s.NewInstanceVariable); } NewStruct.NewStaticVariable = 4444; if (NewStruct.NewStaticVariable !== 4444) { throw new Error("NewInstanceMethod(): Expected 4444, was " + NewStruct.NewStaticVariable); } rename_simple.NewGlobalVariable = 6666; if (rename_simple.NewGlobalVariable !== 6666) { throw new Error("rename_simple.NewGlobalVariable: Expected 6666, was " + rename_simple.NewGlobalVariable); } swig-3.0.2/Examples/test-suite/javascript/ret_by_value_runme.js0000664000175000017500000000025112343605122024617 0ustar williamwilliamvar ret_by_value = require("ret_by_value"); a = ret_by_value.get_test(); if (a.myInt != 100) throw "RuntimeError"; if (a.myShort != 200) throw "RuntimeError"; swig-3.0.2/Examples/test-suite/javascript/dynamic_cast_runme.js0000664000175000017500000000035412343605122024601 0ustar williamwilliamvar dynamic_cast = require("dynamic_cast"); var f = new dynamic_cast.Foo(); var b = new dynamic_cast.Bar(); var x = f.blah(); var y = b.blah(); var a = dynamic_cast.do_test(y); if (a != "Bar::test") { throw new Error("Failed."); } swig-3.0.2/Examples/test-suite/javascript/class_ignore_runme.js0000664000175000017500000000021112343605122024603 0ustar williamwilliamvar class_ignore = require("class_ignore"); a = new class_ignore.Bar(); if (class_ignore.do_blah(a) != "Bar::blah") throw "Error"; swig-3.0.2/Examples/test-suite/javascript/disown_runme.js0000664000175000017500000000055512343605122023451 0ustar williamwilliamvar disown = require("disown"); var a = new disown.A(); var tmp = a.thisown; a.thisown = 0 if (a.thisown) { throw new Error("Failed."); } a.thisown = 1 if (!a.thisown) { throw new Error("Failed."); } a.thisown = tmp if (a.thisown != tmp) { throw new Error("Failed."); } var b = new disown.B(); b.acquire(a); if (a.thisown) { throw new Error("Failed."); } swig-3.0.2/Examples/test-suite/javascript/constover_runme.js0000664000175000017500000000114512343605122024164 0ustar williamwilliamvar constover = require("constover"); p = constover.test("test"); if (p != "test") { throw "test failed!"; } p = constover.test_pconst("test"); if (p != "test_pconst") { throw "test_pconst failed!"; } f = new constover.Foo(); p = f.test("test"); if (p != "test") { throw "member-test failed!"; } p = f.test_pconst("test"); if (p != "test_pconst") { throw "member-test_pconst failed!"; } p = f.test_constm("test"); if (p != "test_constmethod") { throw "member-test_constm failed!"; } p = f.test_pconstm("test"); if (p != "test_pconstmethod") { throw "member-test_pconstm failed!"; } swig-3.0.2/Examples/test-suite/javascript/class_scope_weird_runme.js0000664000175000017500000000024512343605122025632 0ustar williamwilliamvar class_scope_weird = require("class_scope_weird"); f = new class_scope_weird.Foo(); g = new class_scope_weird.Foo(3); if (f.bar(3) != 3) throw RuntimeError; swig-3.0.2/Examples/test-suite/javascript/template_static_runme.js0000664000175000017500000000012612343605122025322 0ustar williamwilliamvar template_static = require("template_static"); template_static.Foo.bar_double(1); swig-3.0.2/Examples/test-suite/javascript/nspace_runme.js0000664000175000017500000000415712343605122023421 0ustar williamwilliamvar nspace = require("nspace"); var color1 = new nspace.Outer.Inner1.Color(); var color = new nspace.Outer.Inner1.Color(color1); delete color1; // class methods color.colorInstanceMethod(20.0); nspace.Outer.Inner1.Color.colorStaticMethod(20.0); var created = nspace.Outer.Inner1.Color.create(); // class enums var someClass = new nspace.Outer.SomeClass(); var channel = someClass.GetInner1ColorChannel(); if (channel != nspace.Outer.Inner1.Color.Transmission) { throw new Error("Failed."); } // class anonymous enums var val1 = nspace.Outer.Inner1.Color.ColorEnumVal1; var val2 = nspace.Outer.Inner1.Color.ColorEnumVal2; if (val1 !== 0 || val2 !== 0x22) { throw new Error("Failed."); } // instance member variables color.instanceMemberVariable = 123; if (color.instanceMemberVariable !== 123) { throw new Error("Failed."); } // static member variables nspace.Outer.Inner1.Color.staticMemberVariable = 789; if (nspace.Outer.Inner1.Color.staticMemberVariable !== 789) { throw new Error("Failed."); } if (nspace.Outer.Inner1.Color.staticConstMemberVariable !== 222) { throw new Error("Failed."); } if (nspace.Outer.Inner1.Color.staticConstEnumMemberVariable !== nspace.Outer.Inner1.Color.Transmission) { throw new Error("Failed."); } // Same class different namespaces var col1 = new nspace.Outer.Inner1.Color(); var col2 = nspace.Outer.Inner2.Color.create(); col2.colors(col1, col1, col2, col2, col2); nspace.Outer.Inner1.namespaceFunction(color); nspace.Outer.Inner1.namespaceVar = 111; if (nspace.Outer.Inner1.namespaceVar !== 111) { throw new Error("Failed."); } // global enums var outerChannel1 = someClass.GetInner1Channel(); if (outerChannel1 != nspace.Outer.Inner1.Transmission1) { throw new Error("Failed."); } var outerChannel2 = someClass.GetInner2Channel(); if (outerChannel2 !== nspace.Outer.Inner2.Transmission2) { throw new Error("Failed."); } // turn feature off / ignoring var ns = new nspace.Outer.namespce(); var nons = new nspace.NoNSpacePlease(); // Derived class var blue3 = new nspace.Outer.Inner3.Blue(); blue3.blueInstanceMethod(); var blue4 = new nspace.Outer.Inner4.Blue(); blue4.blueInstanceMethod(); swig-3.0.2/Examples/test-suite/javascript/constructor_copy_runme.js0000664000175000017500000000135012343605122025557 0ustar williamwilliamvar constructor_copy = require("constructor_copy"); f1 = new constructor_copy.Foo1(3); f11 = new constructor_copy.Foo1(f1); if (f1.x != f11.x) { throw "error in ctor copy for Foo1"; } var good = 0; f8 = new constructor_copy.Foo8() try { f81 = new constructor_copy.Foo8(f8); good = 0; } catch (err) { good = 1; } if (good == 0) { throw "Error: should not allow calling copy ctor for Foo8"; } bi = new constructor_copy.Bari(5); bc = new constructor_copy.Bari(bi); if (bi.x != bc.x) { throw "Error in copy ctor of Bari"; } bd = new constructor_copy.Bard(5); try { bc = new constructor_copy.Bard(bd); good = 0; } catch (err) { good = 1; } if (good == 0) { throw "Error: should not allow calling copy ctor for Bard"; } swig-3.0.2/Examples/test-suite/javascript/preproc_runme.js0000664000175000017500000000036412343605122023616 0ustar williamwilliamvar preproc = require("preproc"); if (preproc.endif != 1) throw "RuntimeError"; if (preproc.define != 1) throw "RuntimeError"; if (preproc.defined != 1) throw "RuntimeError"; if (2*preproc.one != preproc.two) throw "RuntimeError"; swig-3.0.2/Examples/test-suite/javascript/array_member_runme.js0000664000175000017500000000104512343605122024606 0ustar williamwilliamvar array_member = require("array_member"); var f = new array_member.Foo(); f.data = array_member.global_data; for (var i=0; i<8; i++) { if (array_member.get_value(f.data,i) != array_member.get_value(array_member.global_data,i)) { throw "Bad array assignment (1)"; } } for (var i=0; i<8; i++) { array_member.set_value(f.data,i,-i); } array_member.global_data = f.data; for (var i=0; i<8; i++){ if (array_member.get_value(f.data,i) != array_member.get_value(array_member.global_data,i)) { throw "Bad array assignment (2)"; } } swig-3.0.2/Examples/test-suite/javascript/callback_runme.js0000664000175000017500000000151512343605122023677 0ustar williamwilliamvar callback = require("callback"); if (callback.foo(2) !== 2) { throw new Error("Failed."); } if (callback.A_bar(2) !== 4) { throw new Error("Failed."); } if (callback.foobar(3, callback.foo) != callback.foo(3)) { throw new Error("Failed."); } if (callback.foobar(3, foo) != callback.foo(3)) { throw new Error("Failed."); } if (callback.foobar(3, callback.A_bar) != callback.A_bar(3)) { throw new Error("Failed."); } if (callback.foobar(3, callback.foof) != callback.foof(3)) { throw new Error("Failed."); } if (callback.foobar_i(3, callback.foo_i) != callback.foo_i(3)) { throw new Error("Failed."); } if (callback.foobar_d(3.5, callback.foo_d) != callback.foo_d(3.5)) { throw new Error("Failed."); } var a = new callback.A(); if (callback.foobarm(3, a, callback.A.foom_cb_ptr) != a.foom(3)) { throw new Error("Failed."); } swig-3.0.2/Examples/test-suite/javascript/char_strings_runme.js0000664000175000017500000000062212343605122024627 0ustar williamwilliamvar char_strings = require("char_strings"); var assertIsEqual = function(expected, actual) { if (expected !== actual) { throw new Error("Expected "+expected+", was "+actual); } }; assertIsEqual("hi there", char_strings.CharPingPong("hi there")); assertIsEqual("hi there", char_strings.CharArrayPingPong("hi there")); assertIsEqual("hi there", char_strings.CharArrayDimsPingPong("hi there")); swig-3.0.2/Examples/test-suite/javascript/varargs_runme.js0000664000175000017500000000146212343605122023611 0ustar williamwilliamvar varargs = require("varargs"); if (varargs.test("Hello") != "Hello") { throw new Error("Failed"); } var f = new varargs.Foo("Greetings") if (f.str != "Greetings") { throw new Error("Failed"); } if (f.test("Hello") != "Hello") { throw new Error("Failed"); } if (varargs.test_def("Hello",1) != "Hello") { throw new Error("Failed"); } if (varargs.test_def("Hello") != "Hello") { throw new Error("Failed"); } if (varargs.test_plenty("Hello") != "Hello") { throw new Error("Failed"); } if (varargs.test_plenty("Hello", 1) != "Hello") { throw new Error("Failed"); } if (varargs.test_plenty("Hello", 1, 2) != "Hello") { throw new Error("Failed"); } var thrown = false; try { varargs.test_plenty("Hello", 1, 2, 3); } catch (err) { thrown = true; } if (!thrown) { throw new Error("Failed"); } swig-3.0.2/Examples/test-suite/javascript/cpp_enum_runme.js0000664000175000017500000000066312343605122023754 0ustar williamwilliamvar cpp_enum = require("cpp_enum"); var f = new cpp_enum.Foo() if(f.hola != cpp_enum.Hello){ print(f.hola); throw "Error"; } f.hola = cpp_enum.Foo.Hi if(f.hola != cpp_enum.Foo.Hi){ print(f.hola); throw "Error"; } f.hola = cpp_enum.Hello if(f.hola != cpp_enum.Hello){ print(f.hola); throw "Error"; } cpp_enum.Foo.hi = cpp_enum.Hello if(cpp_enum.Foo.hi != cpp_enum.Hello){ print(cpp_enum.Foo.hi); throw "Error"; } swig-3.0.2/Examples/test-suite/javascript/node_template/0000775000175000017500000000000012343605122023215 5ustar williamwilliamswig-3.0.2/Examples/test-suite/javascript/node_template/index.js.in0000664000175000017500000000006712343605122025272 0ustar williamwilliammodule.exports = require('./build/Release/$testcase'); swig-3.0.2/Examples/test-suite/javascript/node_template/binding.gyp.in0000664000175000017500000000162212343605122025756 0ustar williamwilliam{ "targets": [ { "target_name": "$testcase", "sources":[ "../$testcase_wrap.cxx" ], "include_dirs": ["../$srcdir/.."], 'defines': [ 'BUILDING_NODE_EXTENSION=1', ], 'conditions': [ ['OS=="mac"', { 'xcode_settings': { 'GCC_ENABLE_CPP_RTTI': 'YES', 'GCC_ENABLE_CPP_EXCEPTIONS' : 'YES' } } ], ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', { 'cflags': [ "-Wno-unused-variable", "-Wno-unused-but-set-variable", "-Wno-unused-but-set-parameter", $cflags], 'cflags_cc': [ "-Wno-unused-variable", "-Wno-unused-but-set-variable", "-Wno-unused-but-set-parameter", $cflags], 'cflags!': [ '-fno-exceptions' ], 'cflags_cc!': [ '-fno-exceptions', '-fno-rtti' ] } ] ], } ], } swig-3.0.2/Examples/test-suite/javascript/director_alternating_runme.js0000664000175000017500000000030212343605122026337 0ustar williamwilliamvar director_alternating = require("director_alternating"); id = director_alternating.getBar().id(); if (id != director_alternating.idFromGetBar()) throw ("Error, Got wrong id: " + str(id)); swig-3.0.2/Examples/test-suite/javascript/string_simple_runme.js0000664000175000017500000000033512343605122025021 0ustar williamwilliamvar string_simple = require("string_simple"); // Test unicode string var str = "olé"; var copy = string_simple.copy_string(str); if (str !== copy) { throw "Error: copy is not equal: original="+str+", copy="+copy; } swig-3.0.2/Examples/test-suite/javascript/cpp_static_runme.js0000664000175000017500000000044712343605122024277 0ustar williamwilliamvar cpp_static = require("cpp_static"); cpp_static.StaticFunctionTest.static_func(); cpp_static.StaticFunctionTest.static_func_2(1); cpp_static.StaticFunctionTest.static_func_3(1,2); cpp_static.StaticMemberTest.static_int = 10; if (cpp_static.StaticMemberTest.static_int != 10) throw "error"; swig-3.0.2/Examples/test-suite/javascript/rename_scope_runme.js0000664000175000017500000000064012343605122024601 0ustar williamwilliamvar rename_scope = require("rename_scope"); var a = new rename_scope.Natural_UP(); var b = new rename_scope.Natural_BP(); if (a.rtest() !== 1) { throw new Error("a.rtest(): Expected 1, was " + a.rtest()); } if (b.rtest() !== 1) { throw new Error("b.rtest(): Expected 1, was " + b.rtest()); } var f = rename_scope.equals; if (f === undefined) { throw new Error("Equality operator has not been renamed."); } swig-3.0.2/Examples/test-suite/javascript/using1_runme.js0000664000175000017500000000012612343605122023346 0ustar williamwilliamvar using1 = require("using1"); if (using1.spam(37) != 37) throw "RuntimeError"; swig-3.0.2/Examples/test-suite/javascript/Makefile.in0000664000175000017500000000614212343605122022445 0ustar williamwilliam####################################################################### # Makefile for javascript test-suite ####################################################################### LANGUAGE = javascript NODEGYP = @NODEGYP@ NODEJS = @NODEJS@ SCRIPTSUFFIX = _runme.js srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ SWIG = $(top_builddir)/preinst_swig ifneq (, $(ENGINE)) JSENGINE=$(ENGINE) else JSENGINE=node endif include $(srcdir)/../common.mk _setup = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ echo "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $* (with run test)" ; \ else \ echo "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $*" ; \ fi; ifeq (node,$(JSENGINE)) SWIGOPT += -v8 -DBUILDING_NODE_EXTENSION=1 # shut up some warnings # contract macro has an empty 'else' at the end... aggregate.cpptest: GYP_CFLAGS = \"-Wno-empty-body\" contract.cpptest: GYP_CFLAGS = \"-Wno-empty-body\" # dunno... ignoring generously apply_signed_char.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" constant_pointers.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" setup_node = \ test -d $* || mkdir $*; \ sed -e 's|$$testcase|$*|g; s|$$cflags|$(GYP_CFLAGS)|g; s|$$srcdir|$(srcdir)|g' \ $(srcdir)/node_template/binding.gyp.in > $*/binding.gyp; \ sed -e 's|$$testcase|$*|g;' \ $(srcdir)/node_template/index.js.in > $*/index.js # Note: we need to use swig in C parse mode, but make node-gyp believe it is c++ (via file extension) swig_and_compile_c = \ $(setup_node); \ $(SWIG) -javascript $(SWIGOPT) -o $*_wrap.cxx $(srcdir)/../$*.i; \ $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null swig_and_compile_cpp = \ $(setup_node); \ $(SWIG) -c++ -javascript $(SWIGOPT) $(srcdir)/../$*.i; \ $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null run_testcase = \ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ env NODE_PATH=$$PWD:$(srcdir) $(NODEJS) $(srcdir)/$*$(SCRIPTSUFFIX); \ fi %.ctest: $(_setup) $(swig_and_compile_c) $(run_testcase) %.cpptest: $(_setup) $(swig_and_compile_cpp) $(run_testcase) %.multicpptest: $(_setup) else SWIGOPT += -$(JSENGINE) run_testcase = \ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ $(RUNTOOL) $(top_builddir)/Tools/javascript/javascript -$(JSENGINE) $(srcdir)/$*$(SCRIPTSUFFIX); \ fi %.ctest: $(_setup) +$(swig_and_compile_c) $(run_testcase) %.cpptest: $(_setup) +$(swig_and_compile_cpp) $(run_testcase) %.multicpptest: $(_setup) +$(swig_and_compile_multi_cpp) $(run_testcase) endif %.clean: @rm -rf $* @rm -f $*_wrap.* $*.so $*.o clean: for ext in _wrap.cxx _wrap.o .so; do \ rm -f clientdata_prop_a$${ext} clientdata_prop_b$${ext}; \ rm -f imports_a$${ext} imports_b$${ext}; \ rm -f import_stl_a$${ext} import_stl_b$${ext}; \ rm -f mod_a$${ext} mod_b$${ext}; \ rm -f multi_import_a$${ext} multi_import_b$${ext}; \ rm -f packageoption_a$${ext} packageoption_b$${ext} packageoption_c$${ext}; \ done swig-3.0.2/Examples/test-suite/javascript/nspace_extend_runme.js0000664000175000017500000000155112343605122024763 0ustar williamwilliamvar nspace_extend = require("nspace_extend"); // constructors and destructors var color1 = new nspace_extend.Outer.Inner1.Color(); var color = new nspace_extend.Outer.Inner1.Color(color1); delete color1; // class methods color.colorInstanceMethod(20.0); nspace_extend.Outer.Inner1.Color.colorStaticMethod(20.0); var created = nspace_extend.Outer.Inner1.Color.create(); // constructors and destructors var color2 = new nspace_extend.Outer.Inner2.Color(); color = new nspace_extend.Outer.Inner2.Color(color2); delete color2; // class methods color.colorInstanceMethod(20.0); nspace_extend.Outer.Inner2.Color.colorStaticMethod(20.0); created = nspace_extend.Outer.Inner2.Color.create(); // Same class different namespaces var col1 = new nspace_extend.Outer.Inner1.Color(); var col2 = nspace_extend.Outer.Inner2.Color.create(); col2.colors(col1, col1, col2, col2, col2); swig-3.0.2/Examples/test-suite/javascript/empty_runme.js0000664000175000017500000000003512343605122023275 0ustar williamwilliamvar empty = require("empty");swig-3.0.2/Examples/test-suite/javascript/arrays_global_runme.js0000664000175000017500000000104512343605122024762 0ustar williamwilliamvar arrays_global = require("arrays_global"); arrays_global.array_i = arrays_global.array_const_i; arrays_global.BeginString_FIX44a; arrays_global.BeginString_FIX44b; arrays_global.BeginString_FIX44c; arrays_global.BeginString_FIX44d; arrays_global.BeginString_FIX44d; arrays_global.BeginString_FIX44b = "12"+'\0'+"45"; arrays_global.BeginString_FIX44b; arrays_global.BeginString_FIX44d; arrays_global.BeginString_FIX44e; arrays_global.BeginString_FIX44f; arrays_global.test_a("hello","hi","chello","chi"); arrays_global.test_b("1234567","hi"); swig-3.0.2/Examples/test-suite/javascript/cpp_namespace_runme.js0000664000175000017500000000217612343605122024745 0ustar williamwilliamvar cpp_namespace = require("cpp_namespace"); var n = cpp_namespace.fact(4); if (n != 24){ throw ("Bad return value error!"); } if (cpp_namespace.Foo != 42){ throw ("Bad variable value error!"); } t = new cpp_namespace.Test(); if (t.method() != "Test::method"){ throw ("Bad method return value error!"); } if (cpp_namespace.do_method(t) != "Test::method"){ throw ("Bad return value error!"); } if (cpp_namespace.do_method2(t) != "Test::method"){ throw ("Bad return value error!"); } cpp_namespace.weird("hello", 4); delete t; t2 = new cpp_namespace.Test2(); t3 = new cpp_namespace.Test3(); t4 = new cpp_namespace.Test4(); t5 = new cpp_namespace.Test5(); if (cpp_namespace.foo3(42) != 42){ throw ("Bad return value error!"); } if (cpp_namespace.do_method3(t2,40) != "Test2::method"){ throw ("Bad return value error!"); } if (cpp_namespace.do_method3(t3,40) != "Test3::method"){ throw ("Bad return value error!"); } if (cpp_namespace.do_method3(t4,40) != "Test4::method"){ throw ("Bad return value error!"); } if (cpp_namespace.do_method3(t5,40) != "Test5::method"){ throw ("Bad return value error!"); } swig-3.0.2/Examples/test-suite/javascript/struct_value_runme.js0000664000175000017500000000025412343605122024662 0ustar williamwilliamvar struct_value = require("struct_value"); b = new struct_value.Bar(); b.a.x = 3; if (b.a.x != 3) throw "RuntimeError"; b.b.x = 3; if (b.b.x != 3) throw "RuntimeError" swig-3.0.2/Examples/test-suite/javascript/abstract_typedef_runme.js0000664000175000017500000000025012343605122025461 0ustar williamwilliamvar abstract_typedef = require("abstract_typedef"); var e = new abstract_typedef.Engine(); var a = new abstract_typedef.A() if (a.write(e) != 1) { throw "Error"; } swig-3.0.2/Examples/test-suite/javascript/typedef_inherit_runme.js0000664000175000017500000000103712343605122025324 0ustar williamwilliamvar typedef_inherit = require("typedef_inherit"); a = new typedef_inherit.Foo(); b = new typedef_inherit.Bar(); x = typedef_inherit.do_blah(a); if (x != "Foo::blah") print("Whoa! Bad return" + x); x = typedef_inherit.do_blah(b); if (x != "Bar::blah") print("Whoa! Bad return" + x); c = new typedef_inherit.Spam(); d = new typedef_inherit.Grok(); x = typedef_inherit.do_blah2(c); if (x != "Spam::blah") print("Whoa! Bad return" + x); x = typedef_inherit.do_blah2(d); if (x != "Grok::blah") print ("Whoa! Bad return" + x); swig-3.0.2/Examples/test-suite/rename_scope.i0000664000175000017500000000223612343605122021044 0ustar williamwilliam%module rename_scope %inline %{ namespace oss { enum Polarization { UnaryPolarization, BinaryPolarization }; template struct Interface_ { }; } %} namespace oss { // Interface_ %template(Interface_UP) Interface_; %template(Interface_BP) Interface_; } %inline %{ namespace oss { namespace interfaces { template struct Natural : Interface_

{ int test(void) { return 1; } }; } } %} namespace oss { namespace interfaces { %rename(rtest) Natural::test; %rename(rtest) Natural::test; // Natural %template(Natural_UP) Natural; %template(Natural_BP) Natural; } } %rename("equals") operator==; %inline %{ namespace Utilities { class Bucket { public: Bucket() : m_left(0) {} friend bool operator==(const Bucket& lhs, const Bucket& rhs){ return ( rhs.m_left == lhs.m_left ); } private: int m_left; }; } %} swig-3.0.2/Examples/test-suite/apply_strings.i0000664000175000017500000000441712343605122021305 0ustar williamwilliam/* Test %apply for char *, signed char *, unsigned char * This won't work in all situations, so does not necessarily have to be implemented. See http://groups.google.com.ai/group/comp.lang.c++.moderated/browse_thread/thread/ad5873ce25d49324/0ae94552452366be?lnk=raot */ %module(directors="1") apply_strings %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DirectorTest; %warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) DigitsGlobalB; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) DigitsGlobalC; %apply char * {UCharPtr}; %apply char * {SCharPtr}; %apply const char * {CUCharPtr}; %apply const char * {CSCharPtr}; %inline %{ typedef unsigned char* UCharPtr; typedef signed char* SCharPtr; typedef const unsigned char* CUCharPtr; typedef const signed char* CSCharPtr; UCharPtr UCharFunction(UCharPtr str) { return str; } SCharPtr SCharFunction(SCharPtr str) { return str; } CUCharPtr CUCharFunction(CUCharPtr str) { return str; } CSCharPtr CSCharFunction(CSCharPtr str) { return str; } %} %typemap(freearg) SWIGTYPE * "" %apply SWIGTYPE* {CharPtr}; %apply SWIGTYPE* {CCharPtr}; %inline %{ typedef char* CharPtr; typedef const char* CCharPtr; CharPtr CharFunction(CharPtr buffer) { return buffer; } CCharPtr CCharFunction(CCharPtr buffer) { return buffer; } %} // unsigned char* as strings #if defined(SWIGJAVA) || defined(SWIGCSHARP) /* Note: Chicken does not allow unsigned char * in strings */ %apply char [ANY] {TAscii[ANY]} %apply char [] {TAscii []} %apply char * {TAscii *} #endif %inline %{ typedef unsigned char TAscii; typedef struct { TAscii DigitsMemberA[20]; TAscii *DigitsMemberB; } TNumber; TAscii DigitsGlobalA[20]; TAscii DigitsGlobalB[] = {(unsigned char)'A', (unsigned char)'B', 0}; TAscii *DigitsGlobalC; %} // Director test %feature("director"); %inline %{ struct DirectorTest { virtual UCharPtr UCharFunction(UCharPtr str) { return str; } virtual SCharPtr SCharFunction(SCharPtr str) { return str; } virtual CUCharPtr CUCharFunction(CUCharPtr str) { return str; } virtual CSCharPtr CSCharFunction(CSCharPtr str) { return str; } virtual CharPtr CharFunction(CharPtr buffer) { return buffer; } virtual CCharPtr CCharFunction(CCharPtr buffer) { return buffer; } virtual ~DirectorTest() {} }; %} swig-3.0.2/Examples/test-suite/preproc_include_c.h0000664000175000017500000000003112343605122022051 0ustar williamwilliam int multiply30(int a); swig-3.0.2/Examples/test-suite/director_wombat.i0000664000175000017500000000233212343605122021565 0ustar williamwilliam%module(directors="1") director_wombat #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR %feature(director) Bar; %feature(director) Foo; %inline %{ template class Foo { public: Foo() { /* NOP */ } virtual ~Foo() { /* NOP */ } virtual int meth(T param) { return param; } }; typedef Foo Foo_int; class Bar { public: virtual ~Bar(); virtual Foo_int *meth(); virtual void foo_meth_ref(Foo_int &, int); virtual void foo_meth_ptr(Foo_int *, int); virtual void foo_meth_val(Foo_int, int); virtual void foo_meth_cref(const Foo_int &, int); virtual void foo_meth_cptr(const Foo_int *, int); }; Bar::~Bar() { /* NOP */ } Foo_int * Bar::meth() { return new Foo_int(); } void Bar::foo_meth_ref(Foo_int &arg, int param) { } void Bar::foo_meth_ptr(Foo_int *arg, int param) { } void Bar::foo_meth_val(Foo_int arg, int param) { } void Bar::foo_meth_cref(const Foo_int &arg, int param) { } void Bar::foo_meth_cptr(const Foo_int *arg, int param) { } %} %template(Foo_integers) Foo; swig-3.0.2/Examples/test-suite/preproc_include_h3.i0000664000175000017500000000002112343605122022141 0ustar williamwilliam#define const3 3 swig-3.0.2/Examples/test-suite/abstract_typedef.i0000664000175000017500000000201712343605122021724 0ustar williamwilliam%module abstract_typedef %inline %{ struct Engine { }; struct AbstractBaseClass { virtual ~AbstractBaseClass() { } virtual bool write(Engine& archive) const = 0; }; typedef Engine PersEngine; typedef AbstractBaseClass PersClassBase; class A : public PersClassBase { // This works always // bool write(Engine& archive) const; // This doesn't with Swig 1.3.17. // But it works fine with 1.3.16 bool write(PersEngine& archive) const { return true; } }; %} /* Problem related to the direct comparison of strings in the file allocate.cxx (line 55) ...... String *local_decl = Getattr(dn,"decl"); if (local_decl && !Strcmp(local_decl, base_decl)) { ...... with the direct string comparison, no equivalent types are checked and the two 'write' functions appear to be different because "q(const).f(r.bss::PersEngine)." != "q(const).f(r.bss::Engine)." */ swig-3.0.2/Examples/test-suite/template_typedef_funcptr.i0000664000175000017500000000241712343605122023501 0ustar williamwilliam%module template_typedef_funcptr //Bug #1832613 #if !defined(SWIGR) // R Swig fails on this test. Because it tries to return a nil SEXP in // an error %include %inline %{ #include template class Ptr {}; class MCContract {}; typedef Ptr MCContractPtr; %} %template() Ptr; %inline %{ template class ContractFactory { public: static ContractFactory &getInstance() { static ContractFactory instance; return instance; } }; /** * CreateXXContractCallback is a pointer to a function taking no arguments and * returning a pointer to an XXContract. */ typedef MCContractPtr (*CreateMCContractCallback)(); %} //Get around it by changing this: %template(MCContractFactory) ContractFactory; //to a form which expands the typedef: //%template(MCContractFactory) ContractFactory(*)()>; %inline %{ typedef MCContractPtr* ContractPtrPtr; %} // Plain pointers were also causing problems... %template(MCContractFactory2) ContractFactory; #endif swig-3.0.2/Examples/test-suite/overload_template_fast.i0000664000175000017500000000011512343605122023121 0ustar williamwilliam%module overload_template_fast %fastdispatch; %include overload_template.i swig-3.0.2/Examples/test-suite/special_variable_macros.i0000664000175000017500000001464312343605122023242 0ustar williamwilliam%module special_variable_macros // test $typemap() special variable function // these tests are not typical of how $typemap() should be used, but it checks that it is mostly working %warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'NewName' due to Go name ('NewName') conflict with 'Name' */ %{ #if defined(_MSC_VER) #pragma warning(disable: 4996) // 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. #endif %} %ignore Name::operator=; %inline %{ struct Name { Name(const char *n="none") : name(strdup(n ? n : "")) {} Name(const Name& x) : name(strdup(x.name)) {} Name& operator= (const Name& x) { if (this != &x) { free(this->name); this->name = strdup(x.name); } return *this; } ~Name () { free(this->name); } const char *getName() const { return name; }; Name *getNamePtr() { return this; }; private: char *name; }; struct NameWrap { NameWrap(const char *n="casternone") : name(n) {} Name *getNamePtr() { return &name; }; private: Name name; }; %} // check $1 and $input get expanded properly when used from $typemap() %typemap(in) Name *GENERIC ($*1_type temp) %{ /*%typemap(in) Name *GENERIC start */ temp = Name("$specialname"); (void)$input; $1 = ($1_ltype) &temp; /*%typemap(in) Name *GENERIC end */ %} // This would never be done in real code, it is just a test of what madness can be done. // Note that the special variable substitutions $*1_type, $descriptor etc are for NameWrap // even when used within the Name typemap via $typemap. I can't think of any useful use cases // for this behaviour in the C/C++ typemaps, but it is possible. %typemap(in) NameWrap *NAMEWRAP ($*1_type temp) %{ /*%typemap(in) NameWrap *NAMEWRAP start */ temp = $*1_ltype("$descriptor"); (void)$input; $1 = temp.getNamePtr(); /*%typemap(in) NameWrap *NAMEWRAP end */ %} // check $descriptor gets expanded properly when used in a fragment %fragment("nameDescriptor", "header") %{ /*%fragment("getNameDescriptor", "header") start */ static const char *nameDescriptor = "$descriptor(Name)"; /*%fragment("getNameDescriptor", "header") end */ %} ////////////////////////////////////////////////////////////////////////////////////// // This should use Name *GENERIC typemap which ignores passed in Name * and instead uses a newly a newly constructed Name // held in a typemap variable with name="$specialname" %typemap(in) Name *jack { // %typemap(in) Name *jack start $typemap(in, Name *GENERIC) // %typemap(in) Name *jack end } // as above, but also perform variable substitution %typemap(in) Name *jill { // %typemap(in) Name *jill start $typemap(in, Name *GENERIC, specialname=jilly) // %typemap(in) Name *jill end } %typemap(in) Name *mary { // %typemap(in) Name *mary start $typemap(in, NameWrap *NAMEWRAP) // %typemap(in) Name *mary end } %typemap(in, fragment="nameDescriptor") Name *james (Name temp) { // %typemap(in) Name *james start temp = Name(nameDescriptor); (void)$input; $1 = &temp; // %typemap(in) Name *james end } %inline %{ const char * testFred(Name *fred) { return fred->getName(); } const char * testJack(Name *jack) { return jack->getName(); } const char * testJill(Name *jill) { return jill->getName(); } const char * testMary(Name *mary) { return mary->getName(); } const char * testJames(Name *james) { return james->getName(); } %} ////////////////////////////////////////////////////////////////////////////////////// // Multi-arg typemap lookup // One would never do something like this in reality, it just checks $typemap with multi-arg typemaps %typemap(in) (Name *multiname, int num)($*1_type temp_name, $2_ltype temp_count) %{ /*%typemap(in) (Name *multiname, int num) start */ temp_name = $*1_ltype("multiname num"); temp_count = (int)strlen(temp_name.getNamePtr()->getName()); (void)$input; $1 = temp_name.getNamePtr(); $2 = temp_count + 100; /*%typemap(in) (Name *multiname, int num) end */ %} %typemap(in) (Name *jim, int count) { // %typemap(in) Name *jim start $typemap(in, (Name *multiname, int num)) // %typemap(in) Name *jim end } %inline %{ const char * testJim(Name *jim, int count) { if (count != (int)strlen(jim->getNamePtr()->getName()) + 100) return "size check failed"; else return jim->getName(); } %} ////////////////////////////////////////////////////////////////////////////////////// // Template types with more than one template parameter // check $1 and $input get expanded properly when used from $typemap() %typemap(in) Space::Pair PAIR_INT_BOOL ($1_type temp) %{ /*%typemap(in) Name *GENERIC start */ temp = Space::Pair(123, true); (void)$input; $1 = ($1_ltype)temp; /*%typemap(in) Name *GENERIC end */ %} %typemap(in) Space::Pair john { // %typemap(in) Name *john start $typemap(in, Space::Pair PAIR_INT_BOOL) // %typemap(in) Name *john end } %inline %{ namespace Space { template struct Pair { Pair(T1 f, T2 s) : first(f), second(s) {} Pair() {} T1 first; T2 second; }; int testJohn(Space::Pair john) { return john.first; } } %} %template(PairIntBool) Space::Pair; ////////////////////////////////////////////////////////////////////////////////////// // A real use case for $typemap #if defined(SWIGCSHARP) %typemap(cscode) Space::RenameMe %{ public static NewName factory(System.String s) { //below should expand to: //return new NewName( new Name(s) ); return new $typemap(cstype, Space::RenameMe)( new $typemap(cstype, Name)(s) ); } %} #elif defined(SWIGJAVA) %typemap(javacode) Space::RenameMe %{ public static NewName factory(String s) { //below should expand to: //return new NewName( new Name(s) ); return new $typemap(jstype, Space::RenameMe)( new $typemap(jstype, Name)(s) ); } %} #elif defined(SWIGD) #if (SWIG_D_VERSION == 1) %typemap(dcode) Space::RenameMe %{ public static NewName factory(char[] s) { return new $typemap(dtype, Space::RenameMe)( new $typemap(dtype, Name)(s) ); } %} #else %typemap(dcode) Space::RenameMe %{ public static NewName factory(string s) { return new $typemap(dtype, Space::RenameMe)( new $typemap(dtype, Name)(s) ); } %} #endif #endif %rename(NewName) Space::RenameMe; %inline %{ namespace Space { struct RenameMe { RenameMe(Name n) : storedName(n) {} Name getStoredName() { return storedName; } private: Name storedName; }; } %} swig-3.0.2/Examples/test-suite/return_value_scope.i0000664000175000017500000000043312343605122022305 0ustar williamwilliam%module return_value_scope %inline %{ namespace Hell { class Foo { public: Foo(int) { }; }; class Bar { public: typedef Foo fooref; }; class Spam { public: typedef Bar base; typedef base::fooref rettype; rettype test() { return rettype(1); } }; } %} swig-3.0.2/Examples/test-suite/static_const_member_2.i0000664000175000017500000000261712343605122022654 0ustar williamwilliam%module static_const_member_2 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::CavityPackFlags::forward_field; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::CavityPackFlags::backward_field; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::Test::current_profile; %inline %{ namespace oss { namespace modules { struct CavityPackFlags { typedef unsigned int viewflags; static const viewflags forward_field = 1 << 0; static const viewflags backward_field = 1 << 1; static const viewflags cavity_flags; static viewflags flags; static const int &reftest; }; template struct Test : CavityPackFlags { enum {LeftIndex, RightIndex}; static const viewflags current_profile = 1 << 2; }; } } %} %{ int refvalue = 42; const int &oss::modules::CavityPackFlags::reftest = refvalue; %} %{ using oss::modules::CavityPackFlags; const CavityPackFlags::viewflags CavityPackFlags::cavity_flags = CavityPackFlags::forward_field | CavityPackFlags::backward_field; CavityPackFlags::viewflags CavityPackFlags::flags = 0; %} %template(Test_int) oss::modules::Test; %inline %{ class Foo { public: int val; Foo(int v) : val(v) { } static const Foo BAR; static const Foo BAZ; }; %} %{ const Foo Foo::BAR = Foo(1); const Foo Foo::BAZ = Foo(2); %} swig-3.0.2/Examples/test-suite/struct_initialization_cpp.i0000664000175000017500000000021612343605122023675 0ustar williamwilliam// Test declaration and initialization of structs (C++ code) %module struct_initialization_cpp %include "struct_initialization.i" // C code swig-3.0.2/Examples/test-suite/director_detect.i0000664000175000017500000000206512343605122021547 0ustar williamwilliam%module(directors="1") director_detect #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR %warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) cloner; /* Java, C# covariant return types */ %{ #include #include %} %include %feature("director") Bar; %feature("director") Foo; %newobject Foo::cloner(); %newobject Foo::get_class(); %newobject Bar::cloner(); %newobject Bar::get_class(); %inline { namespace foo { typedef int Int; } struct A { }; typedef A B; struct Foo { virtual ~Foo() {} virtual Foo* cloner() = 0; virtual int get_value() = 0; virtual A* get_class() = 0; virtual void just_do_it() = 0; }; class Bar : public Foo { public: Foo* baseclass() { return this; } Bar* cloner() { return new Bar(); } foo::Int get_value() { return 1; } B* get_class() { return new B(); } void just_do_it() { } }; } swig-3.0.2/Examples/test-suite/exception_partial_info.i0000664000175000017500000000162112343605122023126 0ustar williamwilliam%module exception_partial_info // This produced compileable code for Tcl, Python in 1.3.27, fails in 1.3.29 %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} %{ class myException { public: virtual const char *name() = 0; }; class ex1 : public myException { public: virtual const char *name() { return "ex1"; } }; class ex2 : public myException { public: virtual const char *name() { return "ex2"; } }; %} #if !defined(SWIGUTL) #if !defined(SWIGCHICKEN) %inline %{ class Impl { public: void f1() throw (myException) { ex1 e; throw e; } void f2() throw (myException) { ex2 e; throw e; } }; %} #else #warning "Chicken needs fixing for partial exception information" #endif #else #warning "UTL needs fixing for partial exception information" #endif swig-3.0.2/Examples/test-suite/inline_initializer.i0000664000175000017500000000016712343605122022266 0ustar williamwilliam%module inline_initializer %inline %{ class Foo { int x; public: Foo(int a); }; Foo::Foo(int a) : x(a) { } %} swig-3.0.2/Examples/test-suite/template_enum.i0000664000175000017500000000164612343605122021247 0ustar williamwilliam%module template_enum %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; /* Ruby, wrong class name */ %inline %{ template class foo { public: enum { FOO, BAR }; }; %} %template(foo_i) foo; %template(foo_d) foo; #ifdef SWIGD // Workaround for the D module which uses the literal value in the generated wrapper code. %dconstvalue("3") Manta::ColorSpace::NumComponents; #endif %inline { namespace Manta { template class ColorSpace { public: typedef typename Traits::ComponentType ComponentType; enum { NumComponents = Traits::NumComponents}; ComponentType data[NumComponents]; }; } namespace Manta { class RGBTraits { public: typedef float ComponentType; enum {NumComponents = 3}; }; } } namespace Manta { %template(Color) ColorSpace; }; swig-3.0.2/Examples/test-suite/li_std_map_member.i0000664000175000017500000000044312343605122022044 0ustar williamwilliam%module li_std_map_member %inline %{ int i; class TestA { public: TestA() { i = 1; } int i; }; %} %include std_pair.i %include std_map.i namespace std { %template(pairii) pair; %template(mapii) map; %template(pairita) pair; %template(mapita) map; } swig-3.0.2/Examples/test-suite/multi_import.list0000664000175000017500000000003612343605122021647 0ustar williamwilliammulti_import_a multi_import_b swig-3.0.2/Examples/test-suite/minherit.i0000664000175000017500000000300412343605122020215 0ustar williamwilliam// This module tests multiple inheritance, typedef handling, and some // truly horrible parts of the SWIG type system. This is only tested // for Python since not all language modules support multiple-inheritance. // However, if it works for Python, things should be working for other // modules. %module(ruby_minherit="1") minherit #if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) || defined(SWIGGO) %inline %{ class Foo { private: int x; public: Foo() { x = 1; } virtual ~Foo() {} virtual int xget() { return x; }; }; typedef Foo *FooPtr; FooPtr toFooPtr(Foo *f) { return f; } class Bar { private: int y; public: Bar() { y = 2; } virtual ~Bar() {} virtual int yget() { return y; } }; typedef Bar *BarPtr; BarPtr toBarPtr(Bar *f) { return f; } class FooBar : public Foo, public Bar { private: int z; public: FooBar() { z = 3; } virtual int zget() { return z; } }; typedef FooBar *FooBarPtr; FooBarPtr toFooBarPtr(FooBar *f) { return f; } class Spam: public FooBar { private: int w; public: Spam() { w = 4; } virtual int wget() { return w; } }; typedef Spam *SpamPtr; SpamPtr toSpamPtr(Spam *f) { return f; } int xget(FooPtr f) { return f->xget(); } int yget(BarPtr f) { return f->yget(); } int zget(FooBarPtr f) { return f->zget(); } int wget(SpamPtr f) { return f->wget(); } %} #endif // Was causing runtime error in Ruby %include %template(IntVector) std::vector; swig-3.0.2/Examples/test-suite/union_parameter.i0000664000175000017500000000205612343605122021574 0ustar williamwilliam%module union_parameter %warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype' %inline %{ typedef unsigned char Uint8; typedef struct SDL_ActiveEvent { Uint8 type; /* SDL_ACTIVEEVENT */ Uint8 gain; /* Whether given states were gained or lost (1/0) */ Uint8 state; /* A mask of the focus states */ } SDL_ActiveEvent; /* Keyboard event structure */ typedef struct SDL_KeyboardEvent { Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */ int which; /* The keyboard device index */ int state; /* SDL_PRESSED or SDL_RELEASED */ } SDL_KeyboardEvent; typedef union { Uint8 type; SDL_ActiveEvent active; SDL_KeyboardEvent key; } SDL_Event; int SDL_PollEvent (SDL_Event *ev) { static int toggle = 0; if (toggle == 0) { ev->type = 1; ev->active.gain = 20; ev->active.state = 30; } else { ev->type = 2; ev->key.which = 2000; ev->key.state = 3000; } toggle = 1 - toggle; return 1; } %} swig-3.0.2/Examples/test-suite/csharp_attributes.i0000664000175000017500000000407012343605122022130 0ustar williamwilliam%module(directors="1") csharp_attributes // Test the inattributes and outattributes typemaps %typemap(cstype, outattributes="[IntOut]", inattributes="[IntIn]") int "int" %typemap(imtype, outattributes="[IntegerOut]", inattributes="[IntegerIn]") int "int" %inline %{ class Stations { public: Stations(int myInt) { } int Reading(int myInt) { return myInt; } static int Swindon(int myInt) { return myInt; } }; #define TESTMACRO 10 int GlobalFunction(int myInt) { return myInt; } %} //%include "enumsimple.swg" //%include "enumtypesafe.swg" // Test the attributes feature %csattributes MoreStations::MoreStations() "[InterCity1]" %csattributes MoreStations::Chippenham() "[InterCity2]" %csattributes MoreStations::Bath() "[InterCity3]" %csattributes Bristol "[InterCity4]" %csattributes WestonSuperMare "[InterCity5]" %csattributes Wales "[InterCity6]" %csattributes Paddington() "[InterCity7]" %csattributes DidcotParkway "[InterCity8]" %csattributes MoreStations::Cardiff "[System.ComponentModel.Description(\"Cardiff city station\")]" %csattributes Swansea "[System.ComponentModel.Description(\"Swansea city station\")]" %typemap(csattributes) MoreStations "[Eurostar1]" %typemap(csattributes) MoreStations::Wales "[Eurostar2]" %typemap(csattributes) Cymru "[Eurostar3]" %inline %{ struct MoreStations { MoreStations() : Bristol(0) {} void Chippenham() {} static void Bath() {} int Bristol; static double WestonSuperMare; enum Wales { Cardiff = 1, Swansea }; }; void Paddington() {} float DidcotParkway; enum Cymru { Llanelli }; double MoreStations::WestonSuperMare = 0.0; %} // Test directorinattributes and directoroutattributes %typemap(imtype, directoroutattributes="[DirectorIntegerOut]", directorinattributes="[DirectorIntegerIn]") int "int" %feature("director") YetMoreStations; %inline %{ struct YetMoreStations { virtual int Slough(int x) { return x; } virtual ~YetMoreStations() {} }; %} swig-3.0.2/Examples/test-suite/typemap_numinputs.i0000664000175000017500000000072012343605122022201 0ustar williamwilliam%module typemap_numinputs %typemap(in, numinputs=1) (char *STR, int LEN)(int temp = 0) { temp = 1; $2 = 0; $1 = 0; } %typemap(in) (int *OUTPUT) (int temp = 0) { temp = 2; $1 = &temp; } %typemap(argout) (int *OUTPUT) { ++temp$argnum; } %typemap(argout, numinputs=1) (char *STR, int LEN) { ++temp$argnum; } %typemap(in) int hello { $1 = 0; } %inline %{ int this_breaks(int hello, char *STR, int LEN, int *OUTPUT) { return LEN; } %} swig-3.0.2/Examples/test-suite/friends.i0000664000175000017500000000575212343605122020044 0ustar williamwilliam%module friends %{ #include %} %warnfilter(SWIGWARN_LANG_IDENTIFIER); %inline { void globalscope(); // forward declaration needed for some compilers struct A; struct B { B(int i) : v(i) { } friend void ::globalscope(); friend int mix(A* a, B *b); virtual ~B() { } private: int v; }; void globalscope() { B b(0); b.v=10; } struct A { A(int v) : val(v) { } friend int get_val1(const A& a) { return a.val; } /* simple overloading */ friend int get_val1(const A& a, int o) { return a.val + o; } /* note that operators << and >> are ignored, as they should, since no rename is performed. */ friend std::istream& operator>>(std::istream& in, A& a); /* already declare at B */ friend int mix(A* a, B *b); protected: friend int get_val2(const A& a) { return a.val*2; } private: friend int get_val3(const A& a); /* this should be ignored */ friend std::ostream& operator<<(std::ostream& out, const A& a) { out << a.val; return out; } int val; }; /* 'mix' is an interesting case, this is the third declaration swig is getting (two friends + one inline). */ inline int mix(A* a, B *b) { return a->val + b->v; } /* this should be ignored */ inline std::istream& operator>>(std::istream& in, A& a) { int v; in >> v; a = A(v); return in; } inline int get_val3(const A& a) { return a.val*3; } /* another overloading */ inline int get_val1(int i, int a, int b) { return i; } /* sit and watch how well this case works, is just incredible!!, also note that there is no special code added to manage friends and templates (or overloading), this is just old swig magic working at its best. */ template struct D { D(C v) : val(v) {} /* note that here we are overloading the already super overloaded 'get_val1' */ friend C get_val1(D& b) { return b.val; } /* here set will be 'auto' overloaded, depending of the %template instantiations. */ friend void set(D& b, C v) { b.val = v; } private: C val; }; namespace ns1 { void bas() {} void baz() {} } } // Use this version with extra qualifiers to test SWIG as some compilers accept this namespace ns1 { namespace ns2 { class Foo { public: Foo::Foo() {}; friend void bar(); friend void ns1::baz(); void Foo::member() { } }; void bar() {} } } // Remove extra qualifiers for the compiler as some compilers won't compile the extra qaulification (eg gcc-4.1 onwards) %{ namespace ns1 { namespace ns2 { class Foo { public: Foo() {}; friend void bar(); friend void ns1::baz(); void member() { } }; void bar() {} } } %} %template(D_i) D; %template(D_d) D; swig-3.0.2/Examples/test-suite/imports_b.i0000664000175000017500000000177112343605122020405 0ustar williamwilliam/* This file is part of a test for SF bug #231619. It shows that the %import directive does not work properly in SWIG 1.3a5: Type information is not properly generated if a base class comes from an %import-ed file. Extra tests added for enums to test languages that have enum types. */ %module imports_b %{ #include "imports_b.h" %} /* To import, you can use either %import "imports_a.i" or %import(module="imports_a") "imports_a.h" In the first case, imports_a.i should declare the module name using the %module directive. In the second case, the file could be either a .h file, where no %module directive will be found, or a swig interface file, where the module option will take priority over any %module directive inside the imported file. */ #if 0 %import "imports_a.i" #else # if 0 // Test Warning 401 (Python only) %import "imports_a.h" # else %import(module="imports_a") "imports_a.h" # endif #endif %include "imports_b.h" swig-3.0.2/Examples/test-suite/constant_pointers.i0000664000175000017500000000715312343605122022163 0ustar williamwilliam/* This testcase primarily test constant pointers, eg int* const. Only a getter is expected to be produced when wrapping constant pointer variables. A number of other const issues are also tested. */ %module constant_pointers %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */ %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */ %inline %{ int GlobalInt; const int ConstInt=2; int* GlobalIntPtr=&GlobalInt; int* const GlobalConstIntPtr=&GlobalInt; #define ARRAY_SIZE 2 class ParametersTest { public: void param1(int* a) {} void param2(const int* a) {} void param3(int* const a) {} void param4(int const a) {} void param5(const int a) {} void param6(int& a) {} void param7(const int& a) {} void param8(int const& a) {} void param9(int*& a) {} void param10(int* const& a) {} void param11(const int* const a) {} void param_array1(int* a[ARRAY_SIZE]) {} void param_array2(const int* a[ARRAY_SIZE]) {} void param_array3(int* const a[ARRAY_SIZE]) {} void param_array4(int const a[ARRAY_SIZE]) {} void param_array5(const int a[ARRAY_SIZE]) {} void param_array6(const int* const a[ARRAY_SIZE]) {} }; class MemberVariablesTest { public: int* member1; ParametersTest* member2; int* const member3; ParametersTest* const member4; int* array_member1[ARRAY_SIZE]; ParametersTest* array_member2[ARRAY_SIZE]; MemberVariablesTest() : member3(NULL), member4(NULL) {} private: MemberVariablesTest& operator=(const MemberVariablesTest&); }; void foofunction(const int *const i) {} typedef int *typedef1, typedef2, *const typedef3; int int1, int2=2, *int3, *const int4 = &GlobalInt; int* const global_const_int_ptr_array[ARRAY_SIZE] = { &int1, &int2 }; ParametersTest* const array_member4[ARRAY_SIZE] = { new ParametersTest(), new ParametersTest() }; class ReturnValuesTest { public: typedef1 td1; typedef2 td2; int int1, int2, *const int3, *int4, array1[ARRAY_SIZE]; int ret1() {return 5;} const int ret2() {return 5;} int ret3() {return 5;} const int* ret4() {return &ConstInt;} int* const ret5() {return &GlobalInt;} void ret6(int*& a) {} int*& ret7() {return GlobalIntPtr;} void ret8(int*const& a) {} int*const& ret9() {return GlobalIntPtr;} ReturnValuesTest() : int3(NULL) {} private: ReturnValuesTest& operator=(const ReturnValuesTest&); }; const int* globalRet1() {return &GlobalInt;} int* const globalRet2() {return &GlobalInt;} %} %{ struct A { }; %} %inline { typedef const A* Acptr; Acptr opaque(Acptr aptr) { return aptr; } struct B { B() : ca() {} const A ca; A a; A* ap; const A* cap; Acptr acptr; private: B& operator=(const B&); }; const B* bar(const B* b) { return b; } B *const& cbar(B *const& b) { return b; } } %{ static int wxEVT_COMMAND_BUTTON_CLICKEDv; static int *wxEVT_COMMAND_BUTTON_CLICKEDp; static int **wxEVT_COMMAND_BUTTON_CLICKEDpp = &wxEVT_COMMAND_BUTTON_CLICKEDp; #if defined(SWIGR) #undef lang1 /* conflicts with symbol in R internals */ #endif char lang1[16] = "Hello"; char *langs[] ={ lang1 }; %} %inline { #define EWXWEXPORT_VAR const int* wxEVENT_COMMAND_BUTTON_CLICKEDr = (int*) &wxEVT_COMMAND_BUTTON_CLICKEDv; const int* wxEVENT_COMMAND_BUTTON_CLICKEDp = (int*) *wxEVT_COMMAND_BUTTON_CLICKEDpp; char **languages1 = &langs[0]; char **languages2 = (char **)&langs[0]; } %inline %{ struct Foo { const int *icap; }; const int* icap; const Foo *cap; %} swig-3.0.2/Examples/test-suite/java_lib_various.i0000664000175000017500000000230612343605122021721 0ustar williamwilliam/* Java various.i library tests */ %module java_lib_various %include "various.i" %apply char **STRING_ARRAY { char **received }; %apply char **STRING_ARRAY { char **get_names }; %apply char **STRING_ARRAY { char **languages }; %apply char *BYTE { char *chars }; %apply char **STRING_OUT { char **string_ptr }; %typemap(freearg) char **languages "" // don't delete memory when setting global variable %{ char *langs[] = { (char *)"Hungarian", (char *)"Afrikaans", (char *)"Norwegian", NULL }; %} %inline %{ char **languages = &langs[0]; %} %inline %{ int check_animals(char **received) { const char *expected[] = {"Cat","Dog","Cow","Goat", 0}; int strings_match = 1; int i=0; while (expected[i]) { if (strcmp(received[i], expected[i]) != 0) strings_match = 0; i++; } return strings_match; } char **get_names() { static char *values[] = { (char *)"Dave", (char *)"Mike", (char *)"Susan", (char *)"John", (char *)"Michelle", NULL}; return &values[0]; } void charout(char *chars) { if(chars != NULL) sprintf(chars, "by jove"); } void char_ptr_ptr_out(char **string_ptr) { static char ret[] = "returned string"; *string_ptr = ret; } %} swig-3.0.2/Examples/test-suite/template_forward.i0000664000175000017500000000312712343605122021743 0ustar williamwilliam%module template_forward %{ namespace foo { template class bar { }; } %} namespace foo { template class bar; }; %inline %{ namespace foo { double test1(const bar &x) { return 0; } bar test2() { return bar(); } } %} %inline { // Forward declarations template class LinearOpBase; template class VectorBase; } %inline { // Class Describable class Describable { public: void describe() {} }; // Class LinearOpBase template class LinearOpBase : virtual public Describable { public: }; // end class LinearOpBase // Class VectorBase template class VectorBase : virtual public LinearOpBase { public: using LinearOpBase::describe; }; // end class VectorBase } %template (LinearOpBase_double) LinearOpBase; %template (VectorBase_double) VectorBase; %template (LinearOpBase_int) LinearOpBase; %template (VectorBase_int) VectorBase; // Template forward class declarations mixing class and typename without always naming the templated parameter name %inline %{ template class TClass1; template class TClass2; template class TClass3; template class TClass4; template class TClass5; template class TClass6; template class TClass7; %} swig-3.0.2/Examples/test-suite/template_classes.i0000664000175000017500000000106712343605122021735 0ustar williamwilliam/* File : template_classes.i */ /* Tests the use of one templated class within another */ %module template_classes %inline %{ template class Point { public: T getX() {return x;} private: T x; }; template class RectangleTest { public: Point& getPoint() {return point;} void setPoint(Point& value) {point = value;} private: Point point; template struct pair2nd_eq { }; struct Foo : Point { }; Foo foo; }; %} %template(PointInt) Point; %template(RectangleInt) RectangleTest; swig-3.0.2/Examples/test-suite/template_whitespace.i0000664000175000017500000000107712343605122022435 0ustar williamwilliam/* This interface file tests whether whitespace in angle brackets affects the SWIG types. SF Bug #221917, reported by burchanb@cs.tamu.edu. */ %module template_whitespace %{ template class vector { }; template class map { }; %} //%typemap(in) vector "$target = new vector();"; //%typemap(in) vector "$target = new vector();"; //%typemap(in) map "$target = new map();"; %inline %{ void foo(vector v) {} void bar(vector v) {} void baz(map < int , int > p) {} %} swig-3.0.2/Examples/test-suite/rename_camel.i0000664000175000017500000000223012343605122021006 0ustar williamwilliam%module rename_camel %rename("%(utitle)s",%$isfunction,%$ismember) ""; %rename("%(ctitle)s",%$isvariable,%$ismember) ""; %inline { struct GeometryFactory { void createPointFromInternalCoord(int); void BIG_METHOD(int); }; class ByteOrderValues { public: void readHEX(); static int ENDIAN_BIG; }; } %define SedCmd "%(command:sed -e 's/\([a-z]\)/\U\\1/' -e 's/\(_\)\([a-z]\)/\U\\2/g' <<<)s" %enddef %rename(CamelCase1) camel_case_1; %rename(SedCmd) camel_case_2; %rename("%(ctitle)s") camel_case_3; %rename("%(utitle)s") CamelCase_5; %define awk_cmd "%(command:awk '/^i/{print toupper($1)}' <<<)s" %enddef %rename(awk_cmd) ""; %rename("%(title)s",regexmatch$parentNode$type="enum .*") ""; %inline { int camel_case_1(int); int camel_case_2(int); int camel_case_3(int); int camel_case_4(int); int camel_case(int); int CamelCase_5(int); int also_works_here(int); enum HelloEnum { hello, hi_there }; enum ChaoEnum { bye, see_you }; int import(int); int foo(int); } %rename("%(lowercase)s",sourcefmt="%(regex:/GSL_(.*)/\\1/)s",%$isfunction) ""; %inline { void GSL_Hello() {} } swig-3.0.2/Examples/d/0000775000175000017500000000000012343605122014344 5ustar williamwilliamswig-3.0.2/Examples/d/class/0000775000175000017500000000000012343605122015451 5ustar williamwilliamswig-3.0.2/Examples/d/class/d1/0000775000175000017500000000000012343605122015755 5ustar williamwilliamswig-3.0.2/Examples/d/class/d1/runme.d0000664000175000017500000000345412343605122017256 0ustar williamwilliam// This example illustrates how C++ classes can be used from D using SWIG. // The D class gets mapped onto the C++ class and behaves as if it is a D class. module runme; import tango.io.Stdout; import example; void main() { // ----- Object creation ----- Stdout( "Creating some objects:" ).newline; { scope Square s = new Square(10); scope Circle c = new Circle(10); // ----- Access a static member ----- Stdout.format( "{} shapes were created.", Shape.nshapes ).newline; // ----- Member data access ----- // Notice how we can do this using functions specific to // the 'Circle' class. c.x = 20; c.y = 30; // Now use the same functions in the base class Shape shape = s; shape.x = -10; shape.y = 5; Stdout( "\nHere is their current position:" ).newline; Stdout.format( " Circle = ( {}, {} )", c.x, c.y ).newline; Stdout.format( " Square = ( {}, {} )", s.x, s.y ).newline; // ----- Call some methods ----- Stdout( "\nHere are some properties of the shapes:" ).newline; Shape[] shapes = [ cast(Shape) c, cast(Shape) s ]; foreach ( currentShape; shapes ) { Stdout.format( " {}", currentShape.classinfo.name ).newline; Stdout.format( " area = {}", currentShape.area() ).newline; Stdout.format( " perimeter = {}", currentShape.perimeter() ).newline; } // Notice how the area() and perimeter() functions really // invoke the appropriate virtual method on each object. // ----- Delete everything ----- Stdout( "\nGuess I'll clean up now:" ).newline; // Note: when this using scope is exited the D destructors are called which // in turn call the C++ destructors. } Stdout.format( "{} shapes remain", Shape.nshapes ).newline; Stdout( "\nGoodbye!" ).newline; } swig-3.0.2/Examples/d/class/example.h0000664000175000017500000000107612343605122017261 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/d/class/example.i0000664000175000017500000000021512343605122017254 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/d/class/example.cxx0000664000175000017500000000065012343605122017631 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/d/class/Makefile0000664000175000017500000000146712343605122017121 0ustar williamwilliamifeq (2,$(D_VERSION)) WORKING_DIR = d2/ else WORKING_DIR = d1/ endif TOP = ../../.. SWIG = $(TOP)/../preinst-swig EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx EXTRA_LDFLAGS = example.o example_wrap.o TARGET = example_wrap SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme check: build cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean swig-3.0.2/Examples/d/class/d2/0000775000175000017500000000000012343605122015756 5ustar williamwilliamswig-3.0.2/Examples/d/class/d2/runme.d0000664000175000017500000000325012343605122017251 0ustar williamwilliam// This example illustrates how C++ classes can be used from D using SWIG. // The D class gets mapped onto the C++ class and behaves as if it is a D class. module runme; import std.stdio; import example; void main() { // ----- Object creation ----- writeln( "Creating some objects:" ); { scope Square s = new Square(10); scope Circle c = new Circle(10); // ----- Access a static member ----- writefln( "%s shapes were created.", Shape.nshapes ); // ----- Member data access ----- // Notice how we can do this using functions specific to // the 'Circle' class. c.x = 20; c.y = 30; // Now use the same functions in the base class Shape shape = s; shape.x = -10; shape.y = 5; writeln( "\nHere is their current position:" ); writefln( " Circle = ( %s, %s )", c.x, c.y ); writefln( " Square = ( %s, %s )", s.x, s.y ); // ----- Call some methods ----- writeln( "\nHere are some properties of the shapes:" ); Shape[] shapes = [ cast(Shape) c, cast(Shape) s ]; foreach ( currentShape; shapes ) { writefln( " %s", currentShape.classinfo.name ); writefln( " area = %s", currentShape.area() ); writefln( " perimeter = %s", currentShape.perimeter() ); } // Notice how the area() and perimeter() functions really // invoke the appropriate virtual method on each object. // ----- Delete everything ----- writeln( "\nGuess I'll clean up now:" ); // Note: when this using scope is exited the D destructors are called which // in turn call the C++ destructors. } writefln( "%s shapes remain", Shape.nshapes ); writeln( "\nGoodbye!" ); } swig-3.0.2/Examples/d/enum/0000775000175000017500000000000012343605122015310 5ustar williamwilliamswig-3.0.2/Examples/d/enum/d1/0000775000175000017500000000000012343605122015614 5ustar williamwilliamswig-3.0.2/Examples/d/enum/d1/runme.d0000664000175000017500000000203512343605122017107 0ustar williamwilliammodule runme; import tango.io.Stdout; import example; void main() { Stdout( "Printing out some enum values:" ).newline; Stdout(" color:").newline; Stdout.formatln(" {} = {}", color.RED, cast(int)color.RED); Stdout.formatln(" {} = {}", color.BLUE, cast(int)color.BLUE); Stdout.formatln(" {} = {}", color.GREEN, cast(int)color.GREEN); Stdout("\n Foo.speed:").newline; Stdout.formatln(" Foo.{} = {}", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE); Stdout.formatln(" Foo.{} = {}", Foo.speed.WARP, cast(int)Foo.speed.WARP); Stdout.formatln(" Foo.{} = {}", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS); Stdout("\nTesting use of enums with functions:").newline; example.enum_test(color.RED, Foo.speed.IMPULSE); example.enum_test(color.BLUE, Foo.speed.WARP); example.enum_test(color.GREEN, Foo.speed.LUDICROUS); Stdout( "\nTesting use of enum with class method:" ).newline; scope f = new Foo(); f.enum_test(Foo.speed.IMPULSE); f.enum_test(Foo.speed.WARP); f.enum_test(Foo.speed.LUDICROUS); } swig-3.0.2/Examples/d/enum/example.h0000664000175000017500000000032612343605122017115 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/d/enum/example.i0000664000175000017500000000021712343605122017115 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/d/enum/example.cxx0000664000175000017500000000151112343605122017465 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/d/enum/Makefile0000664000175000017500000000146712343605122016760 0ustar williamwilliamifeq (2,$(D_VERSION)) WORKING_DIR = d2/ else WORKING_DIR = d1/ endif TOP = ../../.. SWIG = $(TOP)/../preinst-swig EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx EXTRA_LDFLAGS = example.o example_wrap.o TARGET = example_wrap SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme check: build cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean swig-3.0.2/Examples/d/enum/d2/0000775000175000017500000000000012343605122015615 5ustar williamwilliamswig-3.0.2/Examples/d/enum/d2/runme.d0000664000175000017500000000171212343605122017111 0ustar williamwilliammodule runme; import std.stdio; import example; void main() { writeln( "Printing out some enum values:" ); writeln(" color:"); writefln(" %s = %s", color.RED, cast(int)color.RED); writefln(" %s = %s", color.BLUE, cast(int)color.BLUE); writefln(" %s = %s", color.GREEN, cast(int)color.GREEN); writeln("\n Foo.speed:"); writefln(" Foo.%s = %s", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE); writefln(" Foo.%s = %s", Foo.speed.WARP, cast(int)Foo.speed.WARP); writefln(" Foo.%s = %s", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS); writeln("\nTesting use of enums with functions:"); example.enum_test(color.RED, Foo.speed.IMPULSE); example.enum_test(color.BLUE, Foo.speed.WARP); example.enum_test(color.GREEN, Foo.speed.LUDICROUS); writeln( "\nTesting use of enum with class method:" ); scope f = new Foo(); f.enum_test(Foo.speed.IMPULSE); f.enum_test(Foo.speed.WARP); f.enum_test(Foo.speed.LUDICROUS); } swig-3.0.2/Examples/d/simple/0000775000175000017500000000000012343605122015635 5ustar williamwilliamswig-3.0.2/Examples/d/simple/example.c0000664000175000017500000000036712343605122017442 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/d/simple/d1/0000775000175000017500000000000012343605122016141 5ustar williamwilliamswig-3.0.2/Examples/d/simple/d1/runme.d0000664000175000017500000000101112343605122017425 0ustar williamwilliammodule runme; import tango.io.Stdout; static import example; void main() { /* * Call our gcd() function. */ int x = 42; int y = 105; int g = example.gcd( x, y ); Stdout.format( "The gcd of {} and {} is {}.", x, y, g ).newline; /* * Manipulate the Foo global variable. */ // Output its current value Stdout.format( "Foo = {}", example.Foo ).newline; // Change its value example.Foo = 3.1415926; // See if the change took effect Stdout.format( "Foo = {}", example.Foo ).newline; } swig-3.0.2/Examples/d/simple/example.i0000664000175000017500000000015212343605122017440 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/d/simple/Makefile0000664000175000017500000000145712343605122017304 0ustar williamwilliamifeq (2,$(D_VERSION)) WORKING_DIR = d2/ else WORKING_DIR = d1/ endif TOP = ../../.. SWIG = $(TOP)/../preinst-swig EXTRA_CFLAGS = -I../ ../example.c example_wrap.c EXTRA_LDFLAGS = example.o example_wrap.o TARGET = example_wrap SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme check: build cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean swig-3.0.2/Examples/d/simple/d2/0000775000175000017500000000000012343605122016142 5ustar williamwilliamswig-3.0.2/Examples/d/simple/d2/runme.d0000664000175000017500000000072412343605122017440 0ustar williamwilliammodule runme; import std.stdio; static import example; void main() { /* * Call our gcd() function. */ int x = 42; int y = 105; int g = example.gcd(x, y); writefln("The gcd of %s and %s is %s.", x, y, g); /* * Manipulate the Foo global variable. */ // Output its current value writefln("Foo = %s", example.Foo); // Change its value example.Foo = 3.1415926; // See if the change took effect writefln("Foo = %s", example.Foo); } swig-3.0.2/Examples/d/constants/0000775000175000017500000000000012343605122016360 5ustar williamwilliamswig-3.0.2/Examples/d/constants/d1/0000775000175000017500000000000012343605122016664 5ustar williamwilliamswig-3.0.2/Examples/d/constants/d1/runme.d0000664000175000017500000000211212343605122020153 0ustar williamwilliammodule runme; import tango.io.Stdout; static import example; void main() { Stdout.formatln("ICONST = {} (should be 42)", example.ICONST); Stdout.formatln("FCONST = {} (should be 2.18)", example.FCONST); Stdout.formatln("CCONST = {} (should be 'x')", example.CCONST); Stdout.formatln("CCONST2 = {} (this should be on a new line)", example.CCONST2); Stdout.formatln("SCONST = {} (should be 'Hello World')", example.SCONST); Stdout.formatln("SCONST2 = {} (should be '\"Hello World\"')", example.SCONST2); Stdout.formatln("EXPR = {} (should be 48.55)", example.EXPR); Stdout.formatln("iconst = {} (should be 37)", example.iconst); Stdout.formatln("fconst = {} (should be 3.14)", example.fconst); static if (is(typeof(example.EXTERN))) { Stdout.formatln("EXTERN should not be defined, but is: {}.", example.EXTERN ); } else { Stdout.formatln("EXTERN isn't defined (good)"); } static if (is(typeof(example.FOO))) { Stdout.formatln("FOO should not be defined, but is: {}.", example.FOO); } else { Stdout.formatln("FOO isn't defined (good)"); } } swig-3.0.2/Examples/d/constants/example.i0000664000175000017500000000144212343605122020166 0ustar williamwilliam/* File : example.i */ %module example /* Force the generated D code to use the C constant values rather than retrieving them at runtime. You can also try disabling the feature and compare the generated code. */ %dmanifestconst; /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/d/constants/Makefile0000664000175000017500000000143012343605122020016 0ustar williamwilliamifeq (2,$(D_VERSION)) WORKING_DIR = d2/ else WORKING_DIR = d1/ endif TOP = ../../.. SWIG = $(TOP)/../preinst-swig EXTRA_CFLAGS = -I../ example_wrap.c EXTRA_LDFLAGS = example_wrap.o TARGET = example_wrap SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme check: build cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean swig-3.0.2/Examples/d/constants/d2/0000775000175000017500000000000012343605122016665 5ustar williamwilliamswig-3.0.2/Examples/d/constants/d2/runme.d0000664000175000017500000000175312343605122020166 0ustar williamwilliammodule runme; import std.stdio; static import example; void main() { writefln("ICONST = %s (should be 42)", example.ICONST); writefln("FCONST = %s (should be 2.1828)", example.FCONST); writefln("CCONST = %s (should be 'x')", example.CCONST); writefln("CCONST2 = %s (this should be on a new line)", example.CCONST2); writefln("SCONST = %s (should be 'Hello World')", example.SCONST); writefln("SCONST2 = %s (should be '\"Hello World\"')", example.SCONST2); writefln("EXPR = %s (should be 48.5484)", example.EXPR); writefln("iconst = %s (should be 37)", example.iconst); writefln("fconst = %s (should be 3.14)", example.fconst); static if (is(typeof(example.EXTERN))) { writefln("EXTERN should not be defined, but is: %s.", example.EXTERN ); } else { writeln("EXTERN isn't defined (good)"); } static if (is(typeof(example.FOO))) { writefln("FOO should not be defined, but is: %s.", example.FOO); } else { writeln("FOO isn't defined (good)"); } } swig-3.0.2/Examples/d/constants/example.d0000664000175000017500000000142312343605122020160 0ustar williamwilliam/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 1.3.41 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ module example; static import example_wrap; static import tango.stdc.stringz; public const int ICONST = 42; public const double FCONST = 2.1828; public const char CCONST = 'x'; public const char CCONST2 = '\n'; public const char[] SCONST = "Hello World"; public const char[] SCONST2 = "\"Hello World\""; public const double EXPR = 42+3*(2.1828); public const int iconst = 37; public const double fconst = 3.14; swig-3.0.2/Examples/d/extend/0000775000175000017500000000000012343605122015633 5ustar williamwilliamswig-3.0.2/Examples/d/extend/d1/0000775000175000017500000000000012343605122016137 5ustar williamwilliamswig-3.0.2/Examples/d/extend/d1/runme.d0000664000175000017500000000620012343605122017430 0ustar williamwilliam/// This file illustrates the cross language polymorphism using directors. module runme; import example; import tango.io.Stdout; // CEO class, which overrides Employee.getPosition(). class CEO : Manager { public: this( char[] name ) { super( name ); } override char[] getPosition() { return "CEO"; } // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory. void disownMemory() { swigCMemOwn = false; } } void main() { // Create an instance of CEO, a class derived from the D proxy of the // underlying C++ class. The calls to getName() and getPosition() are standard, // the call to getTitle() uses the director wrappers to call CEO.getPosition(). auto e = new CEO( "Alice" ); Stdout.formatln( "{} is a {}.", e.getName(), e.getPosition() ); Stdout.formatln( "Just call her '{}'.", e.getTitle() ); Stdout( "----------------------" ).newline; { // Create a new EmployeeList instance. This class does not have a C++ // director wrapper, but can be used freely with other classes that do. scope auto list = new EmployeeList(); // EmployeeList owns its items, so we must surrender ownership of objects we add. e.disownMemory(); list.addEmployee(e); Stdout( "----------------------" ).newline; // Now we access the first four items in list (three are C++ objects that // EmployeeList's constructor adds, the last is our CEO). The virtual // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in D. The call to getPosition is // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, D resolved the call // immediately in CEO, but now D thinks the object is an instance of // class Employee. So the call passes through the // Employee proxy class and on to the C wrappers and C++ director, // eventually ending up back at the D CEO implementation of getPosition(). // The call to getTitle() for item 3 runs the C++ Employee::getTitle() // method, which in turn calls getPosition(). This virtual method call // passes down through the C++ director class to the D implementation // in CEO. All this routing takes place transparently. Stdout( "(position, title) for items 0-3:" ).newline; Stdout.formatln( " {}, '{}'", list.getItem(0).getPosition(), list.getItem(0).getTitle() ); Stdout.formatln( " {}, '{}'", list.getItem(1).getPosition(), list.getItem(1).getTitle() ); Stdout.formatln( " {}, '{}'", list.getItem(2).getPosition(), list.getItem(2).getTitle() ); Stdout.formatln( " {}, '{}'", list.getItem(3).getPosition(), list.getItem(3).getTitle() ); Stdout( "----------------------" ).newline; // All Employees will be destroyed when the EmployeeList goes out of scope, // including the CEO instance. } Stdout( "----------------------" ).newline; // All done. Stdout( "Exiting cleanly from D code." ).newline; } swig-3.0.2/Examples/d/extend/example.h0000664000175000017500000000260212343605122017437 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *getItem(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; swig-3.0.2/Examples/d/extend/example.i0000664000175000017500000000035312343605122017441 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; %include "example.h" swig-3.0.2/Examples/d/extend/example.cxx0000664000175000017500000000006012343605122020006 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/d/extend/Makefile0000664000175000017500000000146712343605122017303 0ustar williamwilliamifeq (2,$(D_VERSION)) WORKING_DIR = d2/ else WORKING_DIR = d1/ endif TOP = ../../.. SWIG = $(TOP)/../preinst-swig EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx EXTRA_LDFLAGS = example.o example_wrap.o TARGET = example_wrap SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme check: build cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean swig-3.0.2/Examples/d/extend/d2/0000775000175000017500000000000012343605122016140 5ustar williamwilliamswig-3.0.2/Examples/d/extend/d2/runme.d0000664000175000017500000000605412343605122017440 0ustar williamwilliam/// This file illustrates the cross language polymorphism using directors. module runme; import std.stdio; import example; // CEO class, which overrides Employee.getPosition(). class CEO : Manager { public: this( string name ) { super( name ); } override string getPosition() const { return "CEO"; } // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory. void disownMemory() { swigCMemOwn = false; } } void main() { // Create an instance of CEO, a class derived from the D proxy of the // underlying C++ class. The calls to getName() and getPosition() are standard, // the call to getTitle() uses the director wrappers to call CEO.getPosition(). auto e = new CEO( "Alice" ); writefln( "%s is a %s.", e.getName(), e.getPosition() ); writefln( "Just call her '%s'.", e.getTitle() ); writeln( "----------------------" ); { // Create a new EmployeeList instance. This class does not have a C++ // director wrapper, but can be used freely with other classes that do. scope auto list = new EmployeeList(); // EmployeeList owns its items, so we must surrender ownership of objects we add. e.disownMemory(); list.addEmployee(e); writeln( "----------------------" ); // Now we access the first four items in list (three are C++ objects that // EmployeeList's constructor adds, the last is our CEO). The virtual // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in D. The call to getPosition is // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, D resolved the call // immediately in CEO, but now D thinks the object is an instance of // class Employee. So the call passes through the // Employee proxy class and on to the C wrappers and C++ director, // eventually ending up back at the D CEO implementation of getPosition(). // The call to getTitle() for item 3 runs the C++ Employee::getTitle() // method, which in turn calls getPosition(). This virtual method call // passes down through the C++ director class to the D implementation // in CEO. All this routing takes place transparently. writeln( "(position, title) for items 0-3:" ); writefln( " %s, '%s'", list.getItem(0).getPosition(), list.getItem(0).getTitle() ); writefln( " %s, '%s'", list.getItem(1).getPosition(), list.getItem(1).getTitle() ); writefln( " %s, '%s'", list.getItem(2).getPosition(), list.getItem(2).getTitle() ); writefln( " %s, '%s'", list.getItem(3).getPosition(), list.getItem(3).getTitle() ); writeln( "----------------------" ); // All Employees will be destroyed when the EmployeeList goes out of scope, // including the CEO instance. } writeln( "----------------------" ); // All done. writeln( "Exiting cleanly from D code." ); } swig-3.0.2/Examples/d/check.list0000664000175000017500000000013312343605122016313 0ustar williamwilliam# See top-level Makefile.in. callback class constants enum extend funcptr simple variables swig-3.0.2/Examples/d/funcptr/0000775000175000017500000000000012343605122016025 5ustar williamwilliamswig-3.0.2/Examples/d/funcptr/example.c0000664000175000017500000000037012343605122017624 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/d/funcptr/d1/0000775000175000017500000000000012343605122016331 5ustar williamwilliamswig-3.0.2/Examples/d/funcptr/d1/runme.d0000664000175000017500000000241212343605122017623 0ustar williamwilliammodule runme; import tango.io.Stdout; static import example; extern(C) int add(int a, int b) { return a + b; } extern(C) int sub(int a, int b) { return a - b; } extern(C) int mul(int a, int b) { return a * b; } void main() { int a = 37; int b = 42; Stdout( "a = " )( a ).newline; Stdout( "b = " )( b ).newline; Stdout( "Trying some C callback functions:" ).newline; Stdout( " ADD(a,b) = " )( example.do_op( a, b, example.ADD ) ).newline; Stdout( " SUB(a,b) = " )( example.do_op( a, b, example.SUB ) ).newline; Stdout( " MUL(a,b) = " )( example.do_op( a, b, example.MUL ) ).newline; version (LDC) { // Currently, there is no way to specify the calling convention for // function pointer parameters in D, but LDC does strict typechecking for // them (which is reasonable, but not covered by the language spec yet). // As a result, there is no way to make the code below compile with LDC at // the moment, so just skip it. } else { Stdout( "Now the same with callback functions defined in D:" ).newline; Stdout( " add(a,b) = " )( example.do_op( a, b, &add ) ).newline; Stdout( " sub(a,b) = " )( example.do_op( a, b, &sub ) ).newline; Stdout( " mul(a,b) = " )( example.do_op( a, b, &mul ) ).newline; } } swig-3.0.2/Examples/d/funcptr/example.h0000664000175000017500000000026312343605122017632 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/d/funcptr/example.i0000664000175000017500000000056012343605122017633 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); swig-3.0.2/Examples/d/funcptr/Makefile0000664000175000017500000000152012343605122017463 0ustar williamwilliamifeq (2,$(D_VERSION)) WORKING_DIR = d2/ else WORKING_DIR = d1/ endif TOP = ../../.. SWIG = $(TOP)/../preinst-swig EXTRA_CFLAGS = -I../ ../example.c example_wrap.c EXTRA_LDFLAGS = example.o example_wrap.o TARGET = example_wrap SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme check: build cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean swig-3.0.2/Examples/d/funcptr/d2/0000775000175000017500000000000012343605122016332 5ustar williamwilliamswig-3.0.2/Examples/d/funcptr/d2/runme.d0000664000175000017500000000150712343605122017630 0ustar williamwilliammodule runme; import std.stdio; static import example; extern(C) int add(int a, int b) { return a + b; } extern(C) int sub(int a, int b) { return a - b; } extern(C) int mul(int a, int b) { return a * b; } void main() { int a = 37; int b = 42; writefln( "a = %s", a ); writefln( "b = %s", b ); writeln( "Trying some C callback functions:" ); writefln( " ADD(a,b) = %s", example.do_op( a, b, example.ADD ) ); writefln( " SUB(a,b) = %s", example.do_op( a, b, example.SUB ) ); writefln( " MUL(a,b) = %s", example.do_op( a, b, example.MUL ) ); writeln( "Now the same with callback functions defined in D:" ); writefln( " add(a,b) = %s", example.do_op( a, b, &add ) ); writefln( " sub(a,b) = %s", example.do_op( a, b, &sub ) ); writefln( " mul(a,b) = %s", example.do_op( a, b, &mul ) ); } swig-3.0.2/Examples/d/callback/0000775000175000017500000000000012343605122016100 5ustar williamwilliamswig-3.0.2/Examples/d/callback/d1/0000775000175000017500000000000012343605122016404 5ustar williamwilliamswig-3.0.2/Examples/d/callback/d1/runme.d0000664000175000017500000000142312343605122017677 0ustar williamwilliammodule runme; import tango.io.Stdout; import example; public class DCallback : Callback { public override void run() { Stdout( "DCallback.run()" ).newline; } } void main() { auto caller = new Caller(); Stdout( "Adding and calling a normal C++ callback" ).newline; Stdout( "----------------------------------------" ).newline; { scope auto callback = new Callback(); caller.setCallback(callback); caller.call(); caller.resetCallback(); } Stdout.newline; Stdout( "Adding and calling a D callback" ).newline; Stdout( "-------------------------------" ).newline; { scope auto callback = new DCallback(); caller.setCallback(callback); caller.call(); caller.resetCallback(); } Stdout.newline; Stdout( "D exit" ).newline; } swig-3.0.2/Examples/d/callback/example.h0000664000175000017500000000107112343605122017703 0ustar williamwilliam/* File : example.h */ #include #include class Callback { public: virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void resetCallback() { _callback = 0; } void call() { if (_callback) _callback->run(); } }; swig-3.0.2/Examples/d/callback/example.i0000664000175000017500000000031212343605122017701 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_string.i" /* turn on director wrapping Callback */ %feature("director") Callback; %include "example.h" swig-3.0.2/Examples/d/callback/example.cxx0000664000175000017500000000006012343605122020253 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/d/callback/Makefile0000664000175000017500000000146712343605122017550 0ustar williamwilliamifeq (2,$(D_VERSION)) WORKING_DIR = d2/ else WORKING_DIR = d1/ endif TOP = ../../.. SWIG = $(TOP)/../preinst-swig EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx EXTRA_LDFLAGS = example.o example_wrap.o TARGET = example_wrap SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme check: build cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean swig-3.0.2/Examples/d/callback/d2/0000775000175000017500000000000012343605122016405 5ustar williamwilliamswig-3.0.2/Examples/d/callback/d2/runme.d0000664000175000017500000000133112343605122017676 0ustar williamwilliammodule runme; import std.stdio; import example; public class DCallback : Callback { public override void run() { writeln( "DCallback.run()" ); } } void main() { auto caller = new Caller(); writeln( "Adding and calling a normal C++ callback" ); writeln( "----------------------------------------" ); { scope auto callback = new Callback(); caller.setCallback(callback); caller.call(); caller.resetCallback(); } writeln(); writeln( "Adding and calling a D callback" ); writeln( "-------------------------------" ); { scope auto callback = new DCallback(); caller.setCallback(callback); caller.call(); caller.resetCallback(); } writeln(); writeln( "D exit" ); } swig-3.0.2/Examples/d/variables/0000775000175000017500000000000012343605122016314 5ustar williamwilliamswig-3.0.2/Examples/d/variables/example.c0000664000175000017500000000453512343605122020122 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d, %d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/d/variables/d1/0000775000175000017500000000000012343605122016620 5ustar williamwilliamswig-3.0.2/Examples/d/variables/d1/runme.d0000664000175000017500000000516012343605122020115 0ustar williamwilliam// This example illustrates global variable access from C#. module runme; import tango.io.Stdout; static import example; void main() { // Try to set the values of some global variables example.ivar = 42; example.svar = -31000; example.lvar = 65537; example.uivar = 123456; example.usvar = 61000; example.ulvar = 654321; example.scvar = -13; example.ucvar = 251; example.cvar = 'S'; example.fvar = 3.14159f; example.dvar = 2.1828; example.strvar = "Hello World"; example.iptrvar = example.new_int(37); example.ptptr = example.new_Point(37,42); example.name = "Bill"; // Now print out the values of the variables Stdout.formatln( "Variables (printed from D):" ); Stdout.formatln( "ivar = {}", example.ivar ); Stdout.formatln( "svar = {}", example.svar ); Stdout.formatln( "lvar = {}", example.lvar ); Stdout.formatln( "uivar = {}", example.uivar ); Stdout.formatln( "usvar = {}", example.usvar ); Stdout.formatln( "ulvar = {}", example.ulvar ); Stdout.formatln( "scvar = {}", example.scvar ); Stdout.formatln( "ucvar = {}", example.ucvar ); Stdout.formatln( "fvar = {}", example.fvar ); Stdout.formatln( "dvar = {}", example.dvar ); Stdout.formatln( "cvar = {}", example.cvar ); Stdout.formatln( "strvar = {}", example.strvar ); Stdout.formatln( "cstrvar = {}", example.cstrvar ); Stdout.formatln( "iptrvar = {}", example.iptrvar ); Stdout.formatln( "name = {}", example.name ); Stdout.formatln( "ptptr = {} {}", example.ptptr, example.Point_print(example.ptptr) ); Stdout.formatln( "pt = {} {}", example.pt, example.Point_print(example.pt) ); Stdout.formatln( "status = {}", example.status ); Stdout.formatln( "\nVariables (printed from the C library):" ); example.print_vars(); Stdout.formatln( "\nNow I'm going to try and modify some read only variables:" ); Stdout.formatln( "Checking that the read only variables are readonly..." ); Stdout( " 'path'..." ); static if ( is( typeof( example.path = "a" ) ) ) Stdout.formatln("Oh dear, this variable is not read only!"); else Stdout.formatln("Good."); Stdout( " 'status'..." ); static if ( is( typeof( example.status = 2 ) ) ) Stdout.formatln("Oh dear, this variable is not read only!"); else Stdout.formatln("Good."); Stdout.formatln( "\nI'm going to try and update a structure variable:" ); example.pt = example.ptptr; Stdout( "The new value is " ).flush; example.pt_print(); Stdout.formatln( "You should see the value {}", example.Point_print(example.ptptr) ); } swig-3.0.2/Examples/d/variables/example.h0000664000175000017500000000007512343605122020122 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/d/variables/example.i0000664000175000017500000000174512343605122020130 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/d/variables/Makefile0000664000175000017500000000145712343605122017763 0ustar williamwilliamifeq (2,$(D_VERSION)) WORKING_DIR = d2/ else WORKING_DIR = d1/ endif TOP = ../../.. SWIG = $(TOP)/../preinst-swig EXTRA_CFLAGS = -I../ ../example.c example_wrap.c EXTRA_LDFLAGS = example.o example_wrap.o TARGET = example_wrap SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme check: build cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean swig-3.0.2/Examples/d/variables/d2/0000775000175000017500000000000012343605122016621 5ustar williamwilliamswig-3.0.2/Examples/d/variables/d2/runme.d0000664000175000017500000000466312343605122020125 0ustar williamwilliam// This example illustrates global variable access from C#. module runme; import std.stdio; static import example; void main() { // Try to set the values of some global variables example.ivar = 42; example.svar = -31000; example.lvar = 65537; example.uivar = 123456; example.usvar = 61000; example.ulvar = 654321; example.scvar = -13; example.ucvar = 251; example.cvar = 'S'; example.fvar = 3.14159f; example.dvar = 2.1828; example.strvar = "Hello World"; example.iptrvar = example.new_int(37); example.ptptr = example.new_Point(37,42); example.name = "Bill"; // Now print out the values of the variables writefln( "Variables (printed from D):" ); writefln( "ivar = %s", example.ivar ); writefln( "svar = %s", example.svar ); writefln( "lvar = %s", example.lvar ); writefln( "uivar = %s", example.uivar ); writefln( "usvar = %s", example.usvar ); writefln( "ulvar = %s", example.ulvar ); writefln( "scvar = %s", example.scvar ); writefln( "ucvar = %s", example.ucvar ); writefln( "fvar = %s", example.fvar ); writefln( "dvar = %s", example.dvar ); writefln( "cvar = %s", example.cvar ); writefln( "strvar = %s", example.strvar ); writefln( "cstrvar = %s", example.cstrvar ); writefln( "iptrvar = %s", example.iptrvar ); writefln( "name = %s", example.name ); writefln( "ptptr = %s %s", example.ptptr, example.Point_print(example.ptptr) ); writefln( "pt = %s %s", example.pt, example.Point_print(example.pt) ); writefln( "status = %s", example.status ); writefln( "\nVariables (printed from the C library):" ); example.print_vars(); writefln( "\nNow I'm going to try and modify some read only variables:" ); writefln( "Checking that the read only variables are readonly..." ); writeln( " 'path'..." ); static if ( is( typeof( example.path = "a" ) ) ) writefln("Oh dear, this variable is not read only!"); else writefln("Good."); writeln( " 'status'..." ); static if ( is( typeof( example.status = 2 ) ) ) writefln("Oh dear, this variable is not read only!"); else writefln("Good."); writefln( "\nI'm going to try and update a structure variable:" ); example.pt = example.ptptr; write( "The new value is " ); stdout.flush(); example.pt_print(); writefln( "You should see the value %s", example.Point_print(example.ptptr) ); } swig-3.0.2/Examples/modula3/0000775000175000017500000000000012343605122015465 5ustar williamwilliamswig-3.0.2/Examples/modula3/class/0000775000175000017500000000000012343605122016572 5ustar williamwilliamswig-3.0.2/Examples/modula3/class/example.h0000664000175000017500000000107612343605122020402 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/modula3/class/example.i0000664000175000017500000000206612343605122020403 0ustar williamwilliam/* File : example.i */ %module Example %{ #include "example.h" %} %insert(m3makefile) %{template("../swig") cxx_source("example_wrap")%} %typemap(m3rawinmode) Shape *, Circle *, Square * "" %typemap(m3rawrettype) Shape *, Circle *, Square * "$1_basetype" %typemap(m3wrapinmode) Shape *, Circle *, Square * "" %typemap(m3wrapargraw) Shape *, Circle *, Square * "self.cxxObj" %typemap(m3wrapretvar) Circle *, Square * "cxxObj : ExampleRaw.$1_basetype;" %typemap(m3wrapretraw) Circle *, Square * "cxxObj" %typemap(m3wrapretconv) Circle *, Square * "NEW($1_basetype,cxxObj:=cxxObj)" %typemap(m3wraprettype) Circle *, Square * "$1_basetype" /* Should work with and without renaming %rename(M3Shape) Shape; %rename(M3Circle) Circle; %rename(M3Square) Square; %typemap(m3wrapintype) Shape *, Circle *, Square * "M3$1_basetype" %typemap(m3wraprettype) Shape *, Circle *, Square * "M3$1_basetype" %typemap(m3wrapretconv) Circle *, Square * "NEW(M3$1_basetype,cxxObj:=cxxObj)" */ /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/modula3/class/example.cxx0000664000175000017500000000065012343605122020752 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/modula3/class/Makefile0000664000175000017500000000125212343605122020232 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example PLATFORM = LINUXLIBC6 INTERFACE = example.i SWIGOPT = -c++ MODULA3SRCS = *.[im]3 check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) # compilation of example_wrap.cxx is started by cm3 # $(CXX) -c $(TARGET)_wrap.cxx mv example_wrap.cxx m3makefile $(MODULA3SRCS) src/ ln -sf ../example.h src/example.h cm3 clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean swig-3.0.2/Examples/modula3/class/swig.tmpl0000664000175000017500000000037312343605122020444 0ustar williamwilliam readonly proc cxx_source (X) is local cxxfile = X&".cxx" local objfile = X&".o" %exec("echo $PWD") if stale(objfile,cxxfile) exec("cd",path(),"; g++ -I.. -c -o",objfile,cxxfile) end import_obj(X) %unlink_file(path()&SL&objfile) end swig-3.0.2/Examples/modula3/enum/0000775000175000017500000000000012343605122016431 5ustar williamwilliamswig-3.0.2/Examples/modula3/enum/example.h0000664000175000017500000000421612343605122020240 0ustar williamwilliam/* File : example.h */ #define PI 3.141 #define DAY_MONDAY 0 #define DAY_TUESDAY 1 #define DAY_WEDNESDAY 2 #define DAY_THURSDAY 3 #define DAY_FRIDAY 4 #define DAY_SATURDAY 5 #define DAY_SUNDAY 6 enum color { BLUE, RED, GREEN }; #define CLB_BLACK 0 #define CLB_BLUE 1 #define CLB_RED 2 #define CLB_MAGENTA 3 #define CLB_GREEN 4 #define CLB_CYAN 5 #define CLB_YELLOW 6 #define CLB_WHITE 7 /* Using this would be good style which cannot be expected for general C header files. Instead I want to demonstrate how to live without it. enum month { MTHF_JANUARY, MTHF_FEBRUARY, MTHF_MARCH, MTHF_APRIL, MTHF_MAY, MTHF_JUNE, MTHF_JULY, MTHF_AUGUST, MTHF_SEPTEMBER, MTHF_OCTOBER, MTHF_NOVEMBER, MTHF_DECEMBER, } */ /* Since there are no compile time constants in C / C++ it is a common abuse to declare bit set (flag) constants as enumerations. */ enum calendar { MTHB_JANUARY = 1 << 0, /* 1 << MTHF_JANUARY, */ MTHB_FEBRUARY = 1 << 1, /* 1 << MTHF_FEBRUARY, */ MTHB_MARCH = 1 << 2, /* 1 << MTHF_MARCH, */ MTHB_APRIL = 1 << 3, /* 1 << MTHF_APRIL, */ MTHB_MAY = 1 << 4, /* 1 << MTHF_MAY, */ MTHB_JUNE = 1 << 5, /* 1 << MTHF_JUNE, */ MTHB_JULY = 1 << 6, /* 1 << MTHF_JULY, */ MTHB_AUGUST = 1 << 7, /* 1 << MTHF_AUGUST, */ MTHB_SEPTEMBER = 1 << 8, /* 1 << MTHF_SEPTEMBER, */ MTHB_OCTOBER = 1 << 9, /* 1 << MTHF_OCTOBER, */ MTHB_NOVEMBER = 1 << 10, /* 1 << MTHF_NOVEMBER, */ MTHB_DECEMBER = 1 << 11, /* 1 << MTHF_DECEMBER, */ MTHB_SPRING = MTHB_MARCH | MTHB_APRIL | MTHB_MAY, MTHB_SUMMER = MTHB_JUNE | MTHB_JULY | MTHB_AUGUST, MTHB_AUTUMN = MTHB_SEPTEMBER | MTHB_OCTOBER | MTHB_NOVEMBER, MTHB_WINTER = MTHB_DECEMBER | MTHB_JANUARY | MTHB_FEBRUARY, }; namespace Answer { enum { UNIVERSE_AND_EVERYTHING = 42, SEVENTEEN_AND_FOUR = 21, TWOHUNDRED_PERCENT_OF_NOTHING = 0, }; class Foo { public: Foo() { } enum speed { IMPULSE = -2, WARP = 0, HYPER, LUDICROUS = 3}; void enum_test(speed s); }; }; void enum_test(color c, Answer::Foo::speed s); swig-3.0.2/Examples/modula3/enum/example.i0000664000175000017500000000572112343605122020243 0ustar williamwilliam/* File : example.i */ %module Example %{ #include "example.h" %} %include "example_const.i" // such features are generated by the following pragmas #if 0 %feature("modula3:enumitem:enum","Days") DAY_MONDAY; %feature("modula3:enumitem:name","monday") DAY_MONDAY; %feature("modula3:enumitem:conv","int:int") DAY_MONDAY; %feature("modula3:enumitem:enum","Month") MTHB_JANUARY; %feature("modula3:enumitem:name","january") MTHB_JANUARY; %feature("modula3:enumitem:conv","set:int") MTHB_JANUARY; //%feature("modula3:constset:type","MonthSet") MTHB_JANUARY; /*type in the constant definition*/ %feature("modula3:constset:set", "MonthSet") MTHB_JANUARY; /*remarks that the 'type' is a set type*/ %feature("modula3:constset:base","Month") MTHB_JANUARY; %feature("modula3:constset:name","monthsJanuary") MTHB_JANUARY; %feature("modula3:constset:conv","set:set") MTHB_JANUARY; /*conversion of the bit pattern: no change*/ %feature("modula3:enumitem:enum","Color") BLUE; %feature("modula3:enumitem:name","blue") BLUE; %feature("modula3:enumitem:conv","int:int") BLUE; %feature("modula3:constint:type","INTEGER") Foo::IMPULSE; %feature("modula3:constint:name","impulse") Foo::IMPULSE; %feature("modula3:constint:conv","int:int") Foo::IMPULSE; #endif %rename(pi) PI; %pragma(modula3) enumitem="prefix=DAY_;int;srcstyle=underscore;Day"; %pragma(modula3) enumitem="enum=color;int;srcstyle=underscore;Color"; %pragma(modula3) makesetofenum="Color"; %pragma(modula3) constset="prefix=CLB_;set;srcstyle=underscore,prefix=clb;ColorSet,Color"; %pragma(modula3) enumitem="prefix=MTHB_,enum=calendar;set;srcstyle=underscore;Month"; %pragma(modula3) makesetofenum="Month"; %pragma(modula3) constset="prefix=MTHB_,enum=calendar;set;srcstyle=underscore,prefix=monthset;MonthSet,Month"; %pragma(modula3) constint="prefix=Answer::Foo::,enum=Answer::Foo::speed;int;srcstyle=underscore,prefix=speed;INTEGER"; %pragma(modula3) constint="prefix=Answer::,enum=Answer::;int;srcstyle=underscore,prefix=answer;CARDINAL"; %rename(AnswerFoo) Answer::Foo; %typemap("m3rawrettype") Answer::Foo * %{AnswerFoo%} %typemap("m3rawintype") Answer::Foo * %{AnswerFoo%} %typemap("m3rawinmode") Answer::Foo * %{%} %typemap("m3wraprettype") Answer::Foo * %{AnswerFoo%} %typemap("m3wrapintype") Answer::Foo * %{AnswerFoo%} %typemap("m3wrapinmode") Answer::Foo * %{%} %typemap("m3wrapargraw") Answer::Foo * %{self.cxxObj%} %typemap("m3wrapretvar") Answer::Foo * %{cxxObj : ExampleRaw.AnswerFoo;%} %typemap("m3wrapretraw") Answer::Foo * %{cxxObj%} %typemap("m3wrapretconv") Answer::Foo * %{NEW(AnswerFoo,cxxObj:=cxxObj)%} %typemap("m3rawintype") Answer::Foo::speed %{C.int%}; %typemap("m3rawintype:import") Answer::Foo::speed %{Ctypes AS C%}; %typemap("m3wrapintype") Answer::Foo::speed %{[-2..3]%}; %typemap("m3wrapintype") color %{Color%}; %typemap("m3wrapargraw") color %{ORD($1_name)%}; /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/modula3/enum/example.cxx0000664000175000017500000000122712343605122020612 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else if (s == HYPER) { printf("HYPER speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } Foo obj; obj.enum_test(s); } swig-3.0.2/Examples/modula3/enum/Makefile0000664000175000017500000000133312343605122020071 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i CONSTNUMERIC = example_const SWIGOPT = -c++ MODULA3SRCS = *.[im]3 check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: $(SWIG) -modula3 $(SWIGOPT) -module Example -generateconst $(CONSTNUMERIC) $(TARGET).h $(CXX) -Wall $(CONSTNUMERIC).c -o $(CONSTNUMERIC) $(CONSTNUMERIC) >$(CONSTNUMERIC).i $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean swig-3.0.2/Examples/modula3/simple/0000775000175000017500000000000012343605122016756 5ustar williamwilliamswig-3.0.2/Examples/modula3/simple/example.c0000664000175000017500000000036712343605122020563 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/modula3/simple/example.i0000664000175000017500000000015212343605122020561 0ustar williamwilliam/* File : example.i */ %module Example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/modula3/simple/Makefile0000664000175000017500000000100612343605122020413 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = MODULA3SRCS = *.[im]3 check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean swig-3.0.2/Examples/modula3/typemap/0000775000175000017500000000000012343605122017144 5ustar williamwilliamswig-3.0.2/Examples/modula3/typemap/example.i0000664000175000017500000000660412343605122020757 0ustar williamwilliam/* File : example.i */ %module Example %pragma(modula3) unsafe="true"; %insert(m3wrapintf) %{FROM ExampleRaw IMPORT Window, Point; %} %insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Window, Point; IMPORT M3toC; IMPORT Ctypes AS C; %} /* Typemap applied to patterns of multiple arguments */ %typemap(m3rawinmode) (char *outstr) %{VAR%} %typemap(m3rawintype) (char *outstr) %{CHAR%} %typemap(m3wrapinmode) (char *outstr, int size) %{VAR%} %typemap(m3wrapintype) (char *outstr, int size) %{ARRAY OF CHAR%} %typemap(m3wrapargraw) (char *outstr, int size) %{$1_name[0], NUMBER($1_name)%} %typemap(m3rawinmode) (const struct Window *) %{READONLY%} %typemap(m3wrapinmode) (const struct Window *) %{READONLY%} %typemap(m3rawintype) ( struct Window *) %{Window%} %typemap(m3wrapintype) ( struct Window *) %{Window%} %typemap(m3rawinmode) (const char *str []) %{READONLY%} %typemap(m3wrapinmode) (const char *str []) %{READONLY%} %typemap(m3rawintype) (const char *str []) %{(*ARRAY OF*) C.char_star%} %typemap(m3wrapintype) (const char *str []) %{ARRAY OF TEXT%} %typemap(m3wrapargvar) (const char *str []) %{$1: REF ARRAY OF C.char_star;%} %typemap(m3wrapargraw) (const char *str []) %{$1[0]%} %typemap(m3wrapinconv) (const char *str []) %{$1:= NEW(REF ARRAY OF C.char_star,NUMBER($1_name)); FOR i:=FIRST($1_name) TO LAST($1_name) DO $1[i]:=M3toC.SharedTtoS($1_name[i]); END;%} %typemap(m3wrapfreearg) (const char *str []) %{FOR i:=FIRST($1_name) TO LAST($1_name) DO M3toC.FreeSharedS($1_name[i],$1[i]); END;%} %typemap(m3wraprettype) char * %{TEXT%} %typemap(m3wrapretvar) char * %{result_string: C.char_star;%} %typemap(m3wrapretraw) char * %{result_string%} %typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result_string)%} struct Window { char *label; int left,top,width,height; }; %typemap(m3wrapinname) (int x, int y) %{p%} %typemap(m3wrapinmode) (int x, int y) %{READONLY%} %typemap(m3wrapintype) (int x, int y) %{Point%} %typemap(m3wrapargraw) (int x, int y) %{p.$1_name, p.$2_name%} %typemap(m3wrapargraw) (int &x, int &y) %{p.$1_name, p.$2_name%} %typemap(m3wrapintype) (int &x, int &y) %{Point%} %typemap(m3wrapoutname) (int &x, int &y) %{p%} %typemap(m3wrapouttype) (int &x, int &y) %{Point%} %typemap(m3wrapargdir) (int &x, int &y) "out" %typemap(m3wrapargvar) int &left, int &top, int &width, int &height "$1:C.int;" %typemap(m3wrapargraw) int &left, int &top, int &width, int &height "$1" %typemap(m3wrapoutconv) int &left, int &top, int &width, int &height "$1" %typemap(m3wrapargdir) int &left, int &top "out" %typemap(m3wrapouttype) int &width, int &height "CARDINAL" %typemap(m3wrapargdir) int &width, int &height "out" struct Point { int x,y; }; %m3multiretval get_box; void set_label ( struct Window *win, const char *str, bool activate); void set_multi_label ( struct Window *win, const char *str []); void write_label (const struct Window *win, char *outstr, int size); int get_label (const struct Window *win, char *outstr, int size); char *get_label_ptr (const struct Window *win); void move(struct Window *win, int x, int y); int get_area(const struct Window *win); void get_box(const struct Window *win, int &left, int &top, int &width, int &height); void get_left(const struct Window *win, int &left); void get_mouse(const struct Window *win, int &x, int &y); int get_attached_data(const struct Window *win, const char *id); swig-3.0.2/Examples/modula3/typemap/Makefile0000664000175000017500000000100612343605122020601 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = MODULA3SRCS = *.[im]3 check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean swig-3.0.2/Examples/modula3/reference/0000775000175000017500000000000012343605122017423 5ustar williamwilliamswig-3.0.2/Examples/modula3/reference/example.h0000664000175000017500000000061712343605122021233 0ustar williamwilliam/* File : example.h */ struct Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; Vector operator+(const Vector &b) const; char *print(); }; struct VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/modula3/reference/example.i0000664000175000017500000000130612343605122021230 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module Example %{ #include "example.h" %} %pragma(modula3) unsafe="1"; %insert(m3wrapintf) %{FROM ExampleRaw IMPORT Vector, VectorArray;%} %insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Vector, VectorArray;%} %typemap(m3wrapretvar) Vector %{vec: UNTRACED REF Vector;%} %typemap(m3wrapretraw) Vector %{vec%} %typemap(m3wrapretconv) Vector %{vec^%} /* This helper function calls an overloaded operator */ %inline %{ Vector addv(const Vector &a, const Vector &b) { return a+b; } %} %rename(Vector_Clear) Vector::Vector(); %rename(Add) Vector::operator+; %rename(GetItem) VectorArray::operator[]; %include "example.h" swig-3.0.2/Examples/modula3/reference/example.cxx0000664000175000017500000000161412343605122021604 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/modula3/reference/Makefile0000664000175000017500000000101312343605122021056 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = -c++ MODULA3SRCS = *.[im]3 check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean swig-3.0.2/Examples/modula3/check.list0000664000175000017500000000011212343605122017431 0ustar williamwilliam# see top-level Makefile.in class enum exception reference simple typemap swig-3.0.2/Examples/modula3/exception/0000775000175000017500000000000012343605122017463 5ustar williamwilliamswig-3.0.2/Examples/modula3/exception/example.h0000664000175000017500000000123012343605122021263 0ustar williamwilliam/* File : example.h */ enum error {OK, OVERFLOW, DIVISION_BY_ZERO, NEGATIVE_RADICAND, NEGATIVE_BASE}; typedef error errorstate; /* just to separate the typemaps */ error acc_add (double &x, double y); error acc_sub (double &x, double y); error acc_mul (double &x, double y); error acc_div (double &x, double y); double op_add (double x, double y, errorstate &err); double op_sub (double x, double y, errorstate &err); double op_mul (double x, double y, errorstate &err); double op_div (double x, double y, errorstate &err); double op_sqrt (double x, errorstate &err); double op_pow (double x, double y, errorstate &err); double op_noexc (double x, double y); swig-3.0.2/Examples/modula3/exception/example.i0000664000175000017500000000205312343605122021270 0ustar williamwilliam/* File : example.i */ %module Example %{ #include "example.h" %} %insert(m3wrapintf) %{ EXCEPTION E(Error); %} %insert(m3wrapimpl) %{ IMPORT Ctypes AS C; %} %pragma(modula3) enumitem="enum=error;int;srcstyle=underscore;Error"; %typemap("m3rawintype") double & %{C.double%}; %typemap("m3wrapintype") double & %{LONGREAL%}; %typemap("m3wraprettype") error "" %typemap("m3wrapretvar") error "rawerr: C.int;" %typemap("m3wrapretraw") error "rawerr" %typemap("m3wrapretcheck:throws") error "E" %typemap("m3wrapretcheck") error %{VAR err := VAL(rawerr, Error); BEGIN IF err # Error.ok THEN RAISE E(err); END; END;%} %typemap("m3rawintype") errorstate & %{C.int%}; %typemap("m3wrapintype",numinputs=0) errorstate & %{%}; %typemap("m3wrapargvar") errorstate & %{err:C.int:=ORD(Error.ok);%}; %typemap("m3wrapoutcheck:throws") errorstate & "E"; %typemap("m3wrapoutcheck") errorstate & %{IF VAL(err,Error) # Error.ok THEN RAISE E(VAL(err,Error)); END;%} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/modula3/exception/Makefile0000664000175000017500000000125712343605122021130 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = MODULA3SRCS = *.[im]3 MODULA3FLAGS= -o runme check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3_cpp # $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean swig-3.0.2/Examples/README0000664000175000017500000000305212343605122015001 0ustar williamwilliamSWIG Examples The subdirectories of "Examples" named after SWIG's language backends contain a number of simple examples that are primarily used for testing. The file 'index.html' is the top of a hyperlinked document that contains information about all of the examples along with various notes related to each example. Note: All of the examples rely upon the Makefile in this directory. You may need to edit it to reflect the configuration of your machine in case the configure script guesses incorrect settings. *** Special note concerning C++ *** The configure script is currently unable to handle all of the possible options for producing dynamically loadable C++ extensions. Here are the rules of thumb for making C++ work: - Try using the C++ as the linker for the shared library. For example: g++ -shared $(OBJS) -o module.so - If that doesn't work, you may need to explicitly link against some kind of C++ runtime library. For example: ld -G $(OBJS) -L/opt/SUNWspro/lib -lCrun -o module.so This can be set by modifying the setting of CPP_DLLIBS in the Makefile. *** Special note for SWIG Maintainers *** When you add an example, consider arranging for the example to be also useful as part of the SWIG testing framework. To do this, include in the example makefile a target "check" ("check: all" is sufficient for a first pass), and add an invocation to ../Makefile.in under target "check-examples" (or whatever is appropriate). Later, we can add or expand the actions under target "check" to do more in-depth testing. swig-3.0.2/Examples/python/0000775000175000017500000000000012343605122015442 5ustar williamwilliamswig-3.0.2/Examples/python/std_vector/0000775000175000017500000000000012343605122017616 5ustar williamwilliamswig-3.0.2/Examples/python/std_vector/example.h0000664000175000017500000000111612343605122021421 0ustar williamwilliam/* File : example.h */ #include #include #include #include double average(std::vector v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } std::vector half(const std::vector& v) { std::vector w(v); for (unsigned int i=0; i& v) { // would you believe this is the same as the above? std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } swig-3.0.2/Examples/python/std_vector/example.i0000664000175000017500000000047512343605122021431 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include stl.i /* instantiate the required template specializations */ namespace std { %template(IntVector) vector; %template(DoubleVector) vector; } /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/python/std_vector/Makefile0000664000175000017500000000121012343605122021250 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/std_vector/runme.py0000664000175000017500000000114512343605122021317 0ustar williamwilliam# file: runme.py import example # Call average with a Python list... print example.average([1,2,3,4]) # ... or a wrapped std::vector v = example.IntVector(4) for i in range(len(v)): v[i] = i+1 print example.average(v) # half will return a Python list. # Call it with a Python tuple... print example.half((1.0, 1.5, 2.0, 2.5, 3.0)) # ... or a wrapped std::vector v = example.DoubleVector() for i in [1,2,3,4]: v.append(i) print example.half(v) # now halve a wrapped std::vector in place example.halve_in_place(v) for i in range(len(v)): print v[i], "; ", print swig-3.0.2/Examples/python/varargs/0000775000175000017500000000000012343605122017107 5ustar williamwilliamswig-3.0.2/Examples/python/varargs/example.i0000664000175000017500000000332112343605122020713 0ustar williamwilliam/* File : example.i */ %module example %{ #include %} /* This example illustrates SWIG's handling of varargs functions. By default, variable length arguments are simply ignored. This is generally appropriate for wrapping I/O functions like printf. You can simply format a string in the scripting language, and pass it directly */ int printf(const char *fmt, ...); /* Since passing a format string might be dangerous. Here is a slightly different way of wrapping a printf style function */ #if 1 /* Replace ... with char *. */ %varargs(char *) fprintf; /* Ignore the format string, but set it to %s */ %typemap(in,numinputs=0) const char *fmt { $1 = "%s"; } #else /* An alternative approach using typemaps */ %typemap(in) (const char *fmt, ...) { $1 = "%s"; $2 = (void *) PyString_AsString($input); } #endif int fprintf(FILE *, const char *fmt, ...); /* Here is somewhat different example. A variable length argument function that takes a NULL-terminated list of arguments. We can use a slightly different form of %varargs that specifies a default value and a maximum number of arguments. */ /* Maximum of 20 arguments with default value NULL */ %varargs(20, char *x = NULL) printv; %inline %{ /* In Python 2 we could use PyFile_AsFile for converting Python sys.stdout to C's stdout. This API disappeared in Python 3, so instead we use a helper function to get stdout */ FILE * stdout_stream(void) { return stdout; } void printv(char *s, ...) { va_list ap; char *x; fputs(s,stdout); fputc(' ',stdout); va_start(ap, s); while ((x = va_arg(ap, char *))) { fputs(x,stdout); fputc(' ',stdout); } va_end(ap); fputc('\n',stdout); } %} swig-3.0.2/Examples/python/varargs/Makefile0000664000175000017500000000105412343605122020547 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/varargs/runme.py0000664000175000017500000000130012343605122020601 0ustar williamwilliam# file: runme.py import sys 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): example.printf("i is %d\n" % i) # This will probably be garbled because %d is interpreted by C 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) # This won't be garbled since %d is not interpreted example.fprintf(stdout,"The value is %d\n") # This function calls our NULL-terminated function example.printv("Hello","World","this","is","a","test.") swig-3.0.2/Examples/python/smartptr/0000775000175000017500000000000012343605122017316 5ustar williamwilliamswig-3.0.2/Examples/python/smartptr/example.h0000664000175000017500000000111512343605122021120 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { }; virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/python/smartptr/example.i0000664000175000017500000000044712343605122021130 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" #include "smartptr.h" %} /* Let's just grab the original header file here */ %include "example.h" /* Grab smart pointer template */ %include "smartptr.h" /* Instantiate smart-pointers */ %template(ShapePtr) SmartPtr; swig-3.0.2/Examples/python/smartptr/example.cxx0000664000175000017500000000071612343605122021501 0ustar williamwilliam/* File : example.c */ #include "example.h" #include #ifndef M_PI # define M_PI 3.14159265358979323846 #endif /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/python/smartptr/smartptr.h0000664000175000017500000000034712343605122021347 0ustar williamwilliamtemplate class SmartPtr { public: SmartPtr(T *realPtr = 0) { pointee = realPtr; } T *operator->() const { return pointee; } T &operator*() const { return *pointee; } private: T *pointee; }; swig-3.0.2/Examples/python/smartptr/Makefile0000664000175000017500000000122412343605122020755 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/smartptr/runme.py0000664000175000017500000000205512343605122021020 0ustar williamwilliam# file: runme.py # This file illustrates the proxy class C++ interface generated # by SWIG. import example # ----- Object creation ----- print "Creating some objects:" cc = example.Circle(10) c = example.ShapePtr(cc) print " Created circle", c ss = example.Square(10) s = example.ShapePtr(ss) print " Created square", s # ----- Access a static member ----- print "\nA total of", example.cvar.Shape_nshapes,"shapes were created" # ----- Member data access ----- # Set the location of the object c.x = 20 c.y = 30 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) # ----- 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() print "\nGuess I'll clean up now" # Note: this invokes the virtual destructor del c del s del cc del ss s = 3 print example.cvar.Shape_nshapes,"shapes remain" print "Goodbye" swig-3.0.2/Examples/python/import_template/0000775000175000017500000000000012343605122020647 5ustar williamwilliamswig-3.0.2/Examples/python/import_template/spam.h0000664000175000017500000000066612343605122021770 0ustar williamwilliam#include "bar.h" template class Spam : public Bar { public: Spam() { } ~Spam() { } virtual void A() { printf("I'm Spam::A\n"); } void B() { printf("I'm Spam::B\n"); } virtual Base *toBase() { return static_cast *>(this); } virtual Bar *toBar() { return static_cast *>(this); } static Spam *fromBase(Base *b) { return dynamic_cast *>(b); } }; swig-3.0.2/Examples/python/import_template/README0000664000175000017500000000165212343605122021533 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. Use 'python runme.py' to run a test. Overview: --------- The example defines 4 different extension modules--each wrapping a separate C++ class. base.i - Base class foo.i - Foo class derived from Base bar.i - Bar class derived from Base spam.i - Spam class derived from Bar Each module uses %import to refer to another module. For example, the 'foo.i' module uses '%import base.i' to get definitions for its base class. If everything is okay, all of the modules will load properly and type checking will work correctly. Caveat: Some compilers, for example gcc-3.2.x, generate broken vtables with the inline methods in this test. This is not a SWIG problem and can usually be solved with non-inlined destructors compiled into separate shared objects/DLLs. Unix: ----- - Run make - Run the test as described above swig-3.0.2/Examples/python/import_template/spam.i0000664000175000017500000000014612343605122021762 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" %template(intSpam) Spam; swig-3.0.2/Examples/python/import_template/bar.i0000664000175000017500000000014312343605122021563 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" %template(intBar) Bar; swig-3.0.2/Examples/python/import_template/base.i0000664000175000017500000000012412343605122021730 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h %template(intBase) Base; swig-3.0.2/Examples/python/import_template/foo.i0000664000175000017500000000014212343605122021601 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" %template(intFoo) Foo; swig-3.0.2/Examples/python/import_template/foo.h0000664000175000017500000000055112343605122021604 0ustar williamwilliam#include "base.h" template class Foo : public Base { public: Foo() { } ~Foo() { } virtual void A() { printf("I'm Foo::A\n"); } void B() { printf("I'm Foo::B\n"); } virtual Base *toBase() { return static_cast *>(this); } static Foo *fromBase(Base *b) { return dynamic_cast *>(b); } }; swig-3.0.2/Examples/python/import_template/base.h0000664000175000017500000000050112343605122021726 0ustar williamwilliam#include template class Base { public: Base() { }; virtual ~Base() { }; virtual void A() { printf("I'm Base::A\n"); } void B() { printf("I'm Base::B\n"); } virtual Base *toBase() { return static_cast *>(this); } }; swig-3.0.2/Examples/python/import_template/Makefile0000664000175000017500000000153612343605122022314 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean rm -f foo.py bar.py spam.py base.py swig-3.0.2/Examples/python/import_template/bar.h0000664000175000017500000000055212343605122021566 0ustar williamwilliam#include "base.h" template class Bar : public Base { public: Bar() { } ~Bar() { } virtual void A() { printf("I'm Bar::A\n"); } void B() { printf("I'm Bar::B\n"); } virtual Base *toBase() { return static_cast *>(this); } static Bar *fromBase(Base *b) { return dynamic_cast *>(b); } }; swig-3.0.2/Examples/python/import_template/runme.py0000664000175000017500000000335212343605122022352 0ustar williamwilliam# file: runme.py # Test various properties of classes defined in separate modules print "Testing the %import directive with templates" import base import foo import bar import spam # Create some objects print "Creating some objects" a = base.intBase() b = foo.intFoo() c = bar.intBar() d = spam.intSpam() # Try calling some methods print "Testing some methods" print "", print "Should see 'Base::A' ---> ", a.A() print "Should see 'Base::B' ---> ", a.B() print "Should see 'Foo::A' ---> ", b.A() print "Should see 'Foo::B' ---> ", b.B() print "Should see 'Bar::A' ---> ", c.A() print "Should see 'Bar::B' ---> ", c.B() print "Should see 'Spam::A' ---> ", d.A() print "Should see 'Spam::B' ---> ", d.B() # Try some casts print "\nTesting some casts\n" print "", x = a.toBase() print "Should see 'Base::A' ---> ", x.A() print "Should see 'Base::B' ---> ", x.B() x = b.toBase() print "Should see 'Foo::A' ---> ", x.A() print "Should see 'Base::B' ---> ", x.B() x = c.toBase() print "Should see 'Bar::A' ---> ", x.A() print "Should see 'Base::B' ---> ", x.B() x = d.toBase() print "Should see 'Spam::A' ---> ", x.A() print "Should see 'Base::B' ---> ", x.B() x = d.toBar() print "Should see 'Bar::B' ---> ", x.B() print "\nTesting some dynamic casts\n" x = d.toBase() print " Spam -> Base -> Foo : ", y = foo.intFoo_fromBase(x) if y: print "bad swig" else: print "good swig" print " Spam -> Base -> Bar : ", y = bar.intBar_fromBase(x) if y: print "good swig" else: print "bad swig" print " Spam -> Base -> Spam : ", y = spam.intSpam_fromBase(x) if y: print "good swig" else: print "bad swig" print " Foo -> Spam : ", y = spam.intSpam_fromBase(b) if y: print "bad swig" else: print "good swig" swig-3.0.2/Examples/python/template/0000775000175000017500000000000012343605122017255 5ustar williamwilliamswig-3.0.2/Examples/python/template/example.h0000664000175000017500000000077712343605122021074 0ustar williamwilliam/* File : example.h */ // Some template definitions template T max(T a, T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } #ifdef SWIG %extend { T getitem(int index) { return $self->get(index); } void setitem(int index, T val) { $self->set(index,val); } } #endif }; swig-3.0.2/Examples/python/template/example.i0000664000175000017500000000051412343605122021062 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; swig-3.0.2/Examples/python/template/Makefile0000664000175000017500000000121012343605122020707 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/template/runme.py0000664000175000017500000000074212343605122020760 0ustar williamwilliam# file: runme.py import example # Call some templated functions 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,1000): dv.setitem(i, 1.0/(i+1)) sum = 0 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) print sum del iv del dv swig-3.0.2/Examples/python/contract/0000775000175000017500000000000012343605122017257 5ustar williamwilliamswig-3.0.2/Examples/python/contract/example.c0000664000175000017500000000047212343605122021061 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int fact(int n) { if (n <= 0) return 1; return n*fact(n-1); } swig-3.0.2/Examples/python/contract/example.i0000664000175000017500000000040212343605122021060 0ustar williamwilliam/* File : example.i */ %module example %contract gcd(int x, int y) { require: x >= 0; y >= 0; } %contract fact(int n) { require: n >= 0; ensure: fact >= 1; } %inline %{ extern int gcd(int x, int y); extern int fact(int n); extern double Foo; %} swig-3.0.2/Examples/python/contract/example.dsp0000664000175000017500000001210112343605122021415 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -python "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -python "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/python/contract/Makefile0000664000175000017500000000115512343605122020721 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/contract/runme.py0000664000175000017500000000055612343605122020765 0ustar williamwilliam# file: runme.py 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) # Manipulate the Foo global variable # Output its current value print "Foo = ", example.cvar.Foo # Change its value example.cvar.Foo = 3.1415926 # See if the change took effect print "Foo = ", example.cvar.Foo swig-3.0.2/Examples/python/class/0000775000175000017500000000000012343605122016547 5ustar williamwilliamswig-3.0.2/Examples/python/class/example.h0000664000175000017500000000107612343605122020357 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/python/class/example.i0000664000175000017500000000021512343605122020352 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/python/class/example.cxx0000664000175000017500000000065012343605122020727 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/python/class/index.html0000664000175000017500000000543512343605122020553 0ustar williamwilliam SWIG:Examples:python:class SWIG/Examples/python/class/


Wrapping a simple C++ class

This example illustrates wrapping a simple C++ class to give a Python class.

The C++ Code

Suppose you have some C++ classes described by the following (and admittedly lame) header file:
/* File : example.h */

class Shape {
public:
  Shape() {
    nshapes++;
  }
  virtual ~Shape() {
    nshapes--;
  }
  double  x, y;
  void    move(double dx, double dy);
  virtual double area() = 0;
  virtual double perimeter() = 0;
  static  int nshapes;
};

class Circle : public Shape {
private:
  double radius;
public:
  Circle(double r) : radius(r) { }
  virtual double area();
  virtual double perimeter();
};

class Square : public Shape {
private:
  double width;
public:
  Square(double w) : width(w) { }
  virtual double area();
  virtual double perimeter();
};

The SWIG interface

A simple SWIG interface for this can be built by simply grabbing the header file like this:
/* File : example.i */
%module example

%{
#include "example.h"
%}

/* Let's just grab the original header file here */
%include "example.h"
Note: when creating a C++ extension, you must run SWIG with the -c++ option like this:
% swig -c++ -python example.i

A sample Python script

Click
here to see a script that calls the C++ functions from Python.

Key points

  • To create a new object, you call a constructor like this:
    c = example.new_Circle(10.0)
    

  • Member variables of the C++ class are wrapped as attributes of the Python class. For example:
    c.x = 15   # Set member data
    x = c.x    # Get member data
    

  • Member function are invoked as you would expect:
    print "The area is ", c.area()
    

  • To invoke a destructor, simply call del on the object:
    del c    # Deletes a shape
    

  • Static member variables are wrapped as C global variables. For example:
    n = example.cvar.Shape_nshapes     # Get a static data member
    example.cvar.Shapes_nshapes = 13   # Set a static data member
    

General Comments

  • SWIG does know how to properly perform upcasting of objects in an inheritance hierarchy (including multiple inheritance). Therefore it is perfectly safe to pass an object of a derived class to any function involving a base class.
  • C++ Namespaces - %nspace isn't yet supported for Python.

swig-3.0.2/Examples/python/class/example.dsp0000664000175000017500000001222112343605122020710 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/python/class/Makefile0000664000175000017500000000113512343605122020207 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/class/runme.py0000664000175000017500000000205712343605122020253 0ustar williamwilliam# file: runme.py # This file illustrates the proxy class C++ interface generated # by SWIG. import example # ----- Object creation ----- print "Creating some objects:" c = example.Circle(10) print " Created circle", c s = example.Square(10) print " Created square", s # ----- Access a static member ----- print "\nA total of", example.cvar.Shape_nshapes,"shapes were created" # ----- Member data access ----- # Set the location of the object c.x = 20 c.y = 30 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) # ----- 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() # prevent o from holding a reference to the last object looked at o = None print "\nGuess I'll clean up now" # Note: this invokes the virtual destructor del c del s print example.cvar.Shape_nshapes,"shapes remain" print "Goodbye" swig-3.0.2/Examples/python/pointer/0000775000175000017500000000000012343605122017122 5ustar williamwilliamswig-3.0.2/Examples/python/pointer/example.c0000664000175000017500000000036112343605122020721 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void sub(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/python/pointer/example.i0000664000175000017500000000117612343605122020734 0ustar williamwilliam/* File : example.i */ %module example %{ extern void add(int *, int *, int *); extern void sub(int *, int *, int *); extern int divide(int, int, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); swig-3.0.2/Examples/python/pointer/index.html0000664000175000017500000000657512343605122021134 0ustar williamwilliam SWIG:Examples:python:pointer SWIG/Examples/python/pointer/

Simple Pointer Handling

This example illustrates a couple of techniques for handling simple pointers in SWIG. The prototypical example is a C function that operates on pointers such as this:

void add(int *x, int *y, int *r) { 
    *r = *x + *y;
}
By default, SWIG wraps this function exactly as specified and creates an interface that expects pointer objects for arguments. The only problem is how does one go about creating these objects from a script?

Possible Solutions

  • Write some helper functions to explicitly create objects. For example:
    int *new_int(int ivalue) {
      int *i = (int *) malloc(sizeof(ivalue));
      *i = ivalue;
      return i;
    }
    int get_int(int *i) {
      return *i;
    }
    
    void delete_int(int *i) {
      free(i);
    }
    
    Now, in a script you would do this:
    a = new_int(37)
    b = new_int(42)
    c = new_int(0)
    add(a,b,c)
    r = get_int(c);
    print "Result =",r
    delete_int(a)
    delete_int(b)
    delete_int(c)
    

  • Use the SWIG pointer library. For example, in the interface file you would do this:
    %include "pointer.i"
    
    a = ptrcreate("int",37)
    b = ptrcreate("int",42)
    c = ptrcreate("int")
    add(a,b,c)
    r = ptrvalue(c)
    print "Result =",r
    ptrfree(a)
    ptrfree(b)
    ptrfree(c)
    
    The advantage to using the pointer library is that it unifies some of the helper functions behind a common set of names. For example, the same set of functions work with int, double, float, and other fundamental types.

  • Use the SWIG typemap library. This library allows you to completely change the way arguments are processed by SWIG. For example:
    %include "typemaps.i"
    void add(int *INPUT, int *INPUT, int *OUTPUT);
    
    And in a script:
    r = add(37,42)
    print "Result =",r
    
    Needless to say, this is substantially easier.

  • A final alternative is to use the typemaps library in combination with the %apply directive. This allows you to change the names of parameters that behave as input or output parameters. For example:
    %include "typemaps.i"
    %apply int *INPUT {int *x, int *y};
    %apply int *OUTPUT {int *r};
    
    void add(int *x, int *y, int *r);
    void sub(int *x, int *y, int *r);
    void mul(int *x, int *y, int *r);
    ... etc ...
    

Example

The following example illustrates the use of these features for pointer extraction.

Notes

  • Since pointers are used for so many different things (arrays, output values, etc...) the complexity of pointer handling can be as complicated as you want to make it.

  • More documentation on the typemaps.i and pointer.i library files can be found in the SWIG user manual. The files also contain documentation.

  • The pointer.i library is designed primarily for convenience. If you are concerned about performance, you probably want to use a different approach.

swig-3.0.2/Examples/python/pointer/Makefile0000664000175000017500000000106612343605122020565 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/pointer/runme.py0000664000175000017500000000162612343605122020627 0ustar williamwilliam# file: runme.py 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 " a =",a print " b =",b print " c =",c # Call the add() function with some pointers example.add(a,b,c) # Now get the result r = example.intp_value(c) print " 37 + 42 =",r # Clean up the pointers example.delete_intp(a) example.delete_intp(b) example.delete_intp(c) # Now try the typemap library # 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 # 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) swig-3.0.2/Examples/python/swigrun/0000775000175000017500000000000012343605122017140 5ustar williamwilliamswig-3.0.2/Examples/python/swigrun/example.h0000664000175000017500000000266212343605122020752 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *get_item(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; Manager* convert_to_Manager(PyObject *obj); swig-3.0.2/Examples/python/swigrun/example.i0000664000175000017500000000040312343605122020742 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_vector.i" %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; %include "example.h" swig-3.0.2/Examples/python/swigrun/example.cxx0000664000175000017500000000060512343605122021320 0ustar williamwilliam/* File : example.cxx */ #include #include "swigpyrun.h" #include "example.h" Manager* convert_to_Manager(PyObject *py_obj) { Manager* c_ptr; swig_type_info *ty = SWIG_TypeQuery("Manager *"); printf("manager ty %p \n", (void *)ty); if (SWIG_ConvertPtr(py_obj, (void **) &c_ptr, ty, 0) == -1) { c_ptr = 0; } else { Py_XINCREF(py_obj); } return c_ptr; } swig-3.0.2/Examples/python/swigrun/Makefile0000664000175000017500000000134012343605122020576 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(SWIG) -python -external-runtime $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean rm -f swigpyrun.h swig-3.0.2/Examples/python/swigrun/runme.py0000664000175000017500000000121612343605122020640 0ustar williamwilliam# file: runme.py # This file illustrates the cross language polymorphism using directors. 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 __del__(self): print "CEO.__del__(),", self.getName() # for proxy class extensions that are not "disowned" and # define a __del__ method, it is very important to call the # base class __del__. otherwise the c++ objects will never # be deleted. example.Manager.__del__(self) e = CEO("Alice") m = example.convert_to_Manager(e) print m swig-3.0.2/Examples/python/docstrings/0000775000175000017500000000000012343605122017621 5ustar williamwilliamswig-3.0.2/Examples/python/docstrings/example.h0000664000175000017500000000005412343605122021424 0ustar williamwilliamclass Foo { public: void bar(); }; swig-3.0.2/Examples/python/docstrings/example.i0000664000175000017500000000042412343605122021426 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* %feature("docstring") has to come before the declaration of the method to * SWIG. */ %feature("docstring") Foo::bar "No comment" /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/python/docstrings/example.cxx0000664000175000017500000000005212343605122021775 0ustar williamwilliam#include "example.h" void Foo::bar() {} swig-3.0.2/Examples/python/docstrings/Makefile0000664000175000017500000000123512343605122021262 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = -O check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/docstrings/runme.py0000664000175000017500000000020212343605122021313 0ustar williamwilliam# file: runme.py import example print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')" swig-3.0.2/Examples/python/enum/0000775000175000017500000000000012343605122016406 5ustar williamwilliamswig-3.0.2/Examples/python/enum/example.h0000664000175000017500000000031512343605122020211 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE, WARP, LUDICROUS }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/python/enum/example.i0000664000175000017500000000021712343605122020213 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/python/enum/example.cxx0000664000175000017500000000150712343605122020570 0ustar williamwilliam/* File : example.c */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/python/enum/index.html0000664000175000017500000000146612343605122020412 0ustar williamwilliam SWIG:Examples:python:enum SWIG/Examples/python/enum/

Wrapping enumerations

This example tests SWIG's ability to wrap enumerations. By default, SWIG converts enumeration specifications into integer constants. Further use of enumerated types are handled as integers.

Notes

  • SWIG allows arbitrary integers to be passed as enum values. However, the result of passing an integer not corresponding to any of the values specified in the enum specification is undefined.

swig-3.0.2/Examples/python/enum/Makefile0000664000175000017500000000113512343605122020046 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/enum/runme.py0000664000175000017500000000145112343605122020107 0ustar williamwilliam# file: runme.py import example # ----- Object creation ----- # Print out the value of some enums print "*** color ***" print " RED =", example.RED print " BLUE =", example.BLUE print " GREEN =", example.GREEN print "\n*** Foo::speed ***" print " Foo_IMPULSE =", example.Foo.IMPULSE print " Foo_WARP =", example.Foo.WARP 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.GREEN, example.Foo.LUDICROUS) example.enum_test(1234,5678) print "\nTesting use of enum with class method" f = example.Foo() f.enum_test(example.Foo.IMPULSE) f.enum_test(example.Foo.WARP) f.enum_test(example.Foo.LUDICROUS) swig-3.0.2/Examples/python/exceptproxy/0000775000175000017500000000000012343605122020034 5ustar williamwilliamswig-3.0.2/Examples/python/exceptproxy/example.h0000664000175000017500000000207012343605122021637 0ustar williamwilliam/* File : example.h */ // A simple exception class EmptyError { }; class FullError { public: int maxsize; FullError(int m) : maxsize(m) { } }; #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif template class Queue { int maxsize; T *items; int nitems; int last; public: Queue(int size) { maxsize = size; items = new T[size]; nitems = 0; last = 0; } ~Queue() { delete [] items; } void enqueue(T x) throw(FullError) { if (nitems == maxsize) { throw FullError(maxsize); } items[last] = x; last = (last + 1) % maxsize; nitems++; } T dequeue() { T x; if (nitems == 0) throw EmptyError(); x = items[(last + maxsize - nitems) % maxsize]; nitems--; return x; } int length() { return nitems; } }; #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif swig-3.0.2/Examples/python/exceptproxy/example.i0000664000175000017500000000645412343605122021652 0ustar williamwilliam/* This is a rather sophisticated example that illustrates exception handling, templates, and proxy classes. (i) The %exception directive is used to attach exception handlers to specific methods. (ii) Exception classes are automatically converted to proxy class objects. (iii) The %template directive is used to expand the templates */ %module example %{ #include "example.h" %} /* Define some exception handlers for specific methods. In the header file, the enqueue method throws FullError and the dequeue method throws EmptyError. Since we don't want to define an exception handler for everything, we simply write a handler each method individually. Note: the *::enqueue syntax means that we simply define the handler for any class with this method defined. */ /* First we need to 'disable' the default swig throw mechanism for the FullError class. We do this by rethrowing the exception. Note that this is necessary since the class appears in a throw declaration: void enqueue(T x) throw(FullError); hence, swig recognizes it as an exception class and it will generate the necessary code to catch it and rethrow it to the python side. */ %typemap(throws) FullError "(void)$1; throw;"; %exception *::enqueue { try { $action } catch(FullError& e) { FullError *ecopy = new FullError(e); PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_FullError, 1); PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p_FullError), err); SWIG_fail; } } /* Some notes about the code above: (0) $action gets replaced with the actual method call. (1) We are going to return a copy of the exception object (FullError) to pass back to the Python interpreter. This is why the copy constructor is being called. (2) The SWIG_NewPointerObj() call automatically wraps the exception object into a proxy class. The SWIGTYPE_p_FullError is the type-descriptor used for type checking. The "1" indicates that Python will have ownership of the resulting object. (3) The PyErr_SetObject call sets the Python exception. However, the SWIGTYPE_p_FullError->clientdata reference may not be obvious. This is actually the Python proxy class object for FullError. Recall that in Python, exceptions are defined as classes. Therefore, this works perfectly as the argument to PyErr_SetObject()! A neat trick perhaps. */ /* Now, the EmpytError doesn't appear in a throw declaration, and hence we need to 'mark' it as an exception class. In python, classes that are used as exception are 'special', and need to be wrapped as 'classic' ones. This is a python issue, and if you don't mark the class, you will see 'interesting' behaviours at the python side. */ %exceptionclass EmptyError; %exceptionclass FullError; %exception *::dequeue { try { $action } catch(EmptyError& e) { EmptyError *ecopy = new EmptyError(e); PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_EmptyError, 1); PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p_EmptyError), err); SWIG_fail; } } /* Grab the original header file */ %include "example.h" /* Instantiate a few templates */ %template(intQueue) Queue; %template(doubleQueue) Queue; swig-3.0.2/Examples/python/exceptproxy/Makefile0000664000175000017500000000121012343605122021466 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/exceptproxy/runme.py0000664000175000017500000000121712343605122021535 0ustar williamwilliam# file: runme.py import example q = example.intQueue(10) print "Inserting items into intQueue" try: 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 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 print "Removing items" try: while 1: q.dequeue() except example.EmptyError,e: pass swig-3.0.2/Examples/python/simple/0000775000175000017500000000000012343605122016733 5ustar williamwilliamswig-3.0.2/Examples/python/simple/example.c0000664000175000017500000000036712343605122020540 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/python/simple/example.i0000664000175000017500000000015212343605122020536 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/python/simple/index.html0000664000175000017500000000325612343605122020736 0ustar williamwilliam SWIG:Examples:python:simple SWIG/Examples/python/simple/

Simple Python Example

This example illustrates how you can hook Python to a very simple C program containing a function and a global variable.

The C Code

Suppose you have the following C code:
/* File : example.c */

/* A global variable */
double Foo = 3.0;

/* Compute the greatest common divisor of positive integers */
int gcd(int x, int y) {
  int g;
  g = y;
  while (x > 0) {
    g = x;
    x = y % x;
    y = g;
  }
  return g;
}

The SWIG interface

Here is a simple SWIG interface file:
/* File: example.i */
%module example

extern int gcd(int x, int y);
extern double Foo;

Compilation

  1. swig -python example.i

  2. Compile example_wrap.c and example.c to create the extension examplemodule.so.

Using the extension

Click here to see a script that calls our C functions from Python.

Key points

  • Use the import statement to load your extension module from Python. For example:
    import example
    
  • C functions work just like Python functions. For example:
    g = example.gcd(42,105)
    
  • C global variables are accessed through a special variable called 'cvar'. For example:
    a = example.cvar.Foo
    

swig-3.0.2/Examples/python/simple/example.dsp0000664000175000017500000001210112343605122021071 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -python "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -python "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/python/simple/Makefile0000664000175000017500000000106612343605122020376 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/simple/runme.py0000664000175000017500000000055612343605122020441 0ustar williamwilliam# file: runme.py 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) # Manipulate the Foo global variable # Output its current value print "Foo = ", example.cvar.Foo # Change its value example.cvar.Foo = 3.1415926 # See if the change took effect print "Foo = ", example.cvar.Foo swig-3.0.2/Examples/python/constants/0000775000175000017500000000000012343605122017456 5ustar williamwilliamswig-3.0.2/Examples/python/constants/example.i0000664000175000017500000000113512343605122021263 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/python/constants/index.html0000664000175000017500000000363212343605122021457 0ustar williamwilliam SWIG:Examples:python:constants SWIG/Examples/python/constants/

Wrapping C Constants

When SWIG encounters C preprocessor macros and C declarations that look like constants, it creates Python variables with an identical value. Click here to see a SWIG interface with some constant declarations in it.

Accessing Constants from Python

Click here to see a script that prints out the values of the constants contained in the above file.

Key points

  • The values of preprocessor macros are converted into Python constants.
  • Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
  • Character constants such as 'x' are converted into Python strings.
  • C string literals such as "Hello World" are converted into Python strings.
  • Macros that are not fully defined are simply ignored. For example:
    #define EXTERN extern
    
    is ignored because SWIG has no idea what type of variable this would be.

  • Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
  • Certain C declarations involving 'const' are also turned into Python constants.
  • The Python variables that SWIG creates are not protected from modification. For example, even if you had this:
    #define FOO 73
    
    a user could come along in a script and type
    example.FOO = 13
    
    Unfortunately, there's no easy way to prevent this.

  • The constants that appear in a SWIG interface file do not have to appear in any sort of matching C source file since the creation of a constant does not require linkage to a stored value (i.e., a value held in a C global variable or memory location).

swig-3.0.2/Examples/python/constants/Makefile0000664000175000017500000000105412343605122021116 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/constants/runme.py0000664000175000017500000000152312343605122021157 0ustar williamwilliam# file: runme.py import example print "ICONST =", example.ICONST, "(should be 42)" print "FCONST =", example.FCONST, "(should be 2.1828)" 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 "iconst =", example.iconst, "(should be 37)" print "fconst =", example.fconst, "(should be 3.14)" try: print "EXTERN = ", example.EXTERN, "(Arg! This shouldn't print anything)" except AttributeError: print "EXTERN isn't defined (good)" try: print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)" except AttributeError: print "FOO isn't defined (good)" swig-3.0.2/Examples/python/extend/0000775000175000017500000000000012343605122016731 5ustar williamwilliamswig-3.0.2/Examples/python/extend/example.h0000664000175000017500000000260512343605122020540 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *get_item(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; swig-3.0.2/Examples/python/extend/example.i0000664000175000017500000000040312343605122020533 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_vector.i" %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; %include "example.h" swig-3.0.2/Examples/python/extend/example.cxx0000664000175000017500000000006012343605122021104 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/python/extend/index.html0000664000175000017500000000045412343605122020731 0ustar williamwilliam SWIG:Examples:python:extend SWIG/Examples/python/extend/

Extending a simple C++ class in Python

This example illustrates the extending of a C++ class with cross language polymorphism.


swig-3.0.2/Examples/python/extend/Makefile0000664000175000017500000000125212343605122020371 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/extend/runme.py0000664000175000017500000000627512343605122020443 0ustar williamwilliam# file: runme.py # This file illustrates the cross language polymorphism using directors. 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" # Create an instance of our employee extension class, CEO. The calls to # getName() and getPosition() are standard, the call to getTitle() uses # the director wrappers to call CEO.getPosition. e = CEO("Alice") e = CEO("Alice") print e.getName(), "is a", e.getPosition() print "Just call her \"%s\"" % e.getTitle() print "----------------------" # Create a new EmployeeList instance. This class does not have a C++ # director wrapper, but can be used freely with other classes that do. list = example.EmployeeList() # EmployeeList owns its items, so we must surrender ownership of objects # we add. This involves first calling the __disown__ method to tell the # C++ director to start reference counting. We reassign the resulting # weakref.proxy to e so that no hard references remain. This can also be # done when the object is constructed, as in: e = # CEO("Alice").__disown__() e = e.__disown__() list.addEmployee(e) print "----------------------" # Now we access the first four items in list (three are C++ objects that # EmployeeList's constructor adds, the last is our CEO). The virtual # methods of all these instances are treated the same. For items 0, 1, and # 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls # getPosition which resolves in Python. The call to getPosition is # slightly different, however, from the e.getPosition() call above, since # now the object reference has been "laundered" by passing through # EmployeeList as an Employee*. Previously, Python resolved the call # immediately in CEO, but now Python thinks the object is an instance of # class Employee (actually EmployeePtr). So the call passes through the # Employee proxy class and on to the C wrappers and C++ director, # eventually ending up back at the CEO implementation of getPosition(). # The call to getTitle() for item 3 runs the C++ Employee::getTitle() # method, which in turn calls getPosition(). This virtual method call # passes down through the C++ director class to the Python implementation # in CEO. All this routing takes place transparently. print "(position, title) for items 0-3:" print " %s, \"%s\"" % (list.get_item(0).getPosition(), list.get_item(0).getTitle()) print " %s, \"%s\"" % (list.get_item(1).getPosition(), list.get_item(1).getTitle()) print " %s, \"%s\"" % (list.get_item(2).getPosition(), list.get_item(2).getTitle()) print " %s, \"%s\"" % (list.get_item(3).getPosition(), list.get_item(3).getTitle()) print "----------------------" # Time to delete the EmployeeList, which will delete all the Employee* # items it contains. The last item is our CEO, which gets destroyed as its # reference count goes to zero. The Python destructor runs, and is still # able to call self.getName() since the underlying C++ object still # exists. After this destructor runs the remaining C++ destructors run as # usual to destroy the object. del list print "----------------------" # All done. print "python exit" swig-3.0.2/Examples/python/import_packages/0000775000175000017500000000000012343605122020612 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/0000775000175000017500000000000012343605122022662 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/README0000664000175000017500000000461112343605122023544 0ustar williamwilliamThis example tests the %import directive and python import from __init__.py. This case is not correctly handled by swig 2. The issue was reported as Source Forge bug #1297 and later as GitHub issue #7. Use 'python runme.py' to run a test. Overview: --------- The example defines 2 different extension modules--each wrapping a separate C++ class. pyX/pkg2/pkg3/foo.i - Pkg3_Foo class pyX/pkg2/bar.i - Pkg2_Bar class derived from Pkg3_Foo and the package pyX.pkg2 has: pyX/pkg2/__init__.py - which imports something from "bar" module For example with python 2.x the py2/pkg2/__init__.py imports Pkg2_Bar class as follows from bar import Pkg2_Bar # [1] Such cases doesn't work when fully qualified python module names are used by swig to generate python import directives (SF bug #1297). The generated file "py2/pkg2/bar.py" has following lines: import py2.pkg2.pkg3.foo # [2] class Pkg2_Bar(py2.pkg2.pkg3.foo.Pkg3_Foo): # [3] and it's not possible to import anything from py2.pkg2 subpackage, e.g. import py2.pkg2 fails with the following exception: Traceback (most recent call last): File "runme.py", line 3, in import py2.pkg2 File "py2/pkg2/__init__.py", line 4, in from bar import Pkg2_Bar File "py2/pkg2/bar.py", line 71, in class Pkg2_Bar(py2.pkg2.pkg3.foo.Pkg3_Foo): AttributeError: 'module' object has no attribute 'pkg2' It seems like during the import [1], the subpackage pkg2 is not yet fully initialized, so pyX.pkg2 is not known. The above exception is raised at line [3]. The problem disappears, for example, if we force swig to use relative package names. The difference between this ('from_init2') case and the case 'from_init1' is that here it's not sufficient to import relative module by just ignoring the package part of the fully qualified module name. IOW it is not correct to force swig to put: import foo class Pkg2_Bar(foo.Pkg3_Foo) into pyX/pkg2/bar.py (note, that this would work for 'from_init1' case). The import directive shall be rather: import pkg3.foo for python 2.x and: from . import pkg3 import pkg3.foo for python 3, and the class definition shall begin with: class Pkg2_Bar(pkg3.foo.Pkg3_Foo) If everything works well, the package pyX.pkg2 shall load properly. Unix: ----- - Run make - Run the test as described above swig-3.0.2/Examples/python/import_packages/from_init2/py2/0000775000175000017500000000000012343605122023374 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py2/__init__.py0000664000175000017500000000000012343605122025473 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/0000775000175000017500000000000012343605122024237 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/bar.i0000664000175000017500000000021712343605122025155 0ustar williamwilliam%module(package="py2.pkg2") bar %{ #include "../../py2/pkg2/bar.hpp" %} %import "../../py2/pkg2/pkg3/foo.i" %include "../../py2/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/bar.hpp0000664000175000017500000000022612343605122025514 0ustar williamwilliam#ifndef PY2_PKG2_BAR_HPP #define PY2_PKG2_BAR_HPP #include "../../py2/pkg2/pkg3/foo.hpp" struct Pkg2_Bar : Pkg3_Foo {}; #endif /* PY2_PKG2_BAR_HPP */ swig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/__init__.py0000664000175000017500000000003112343605122026342 0ustar williamwilliamfrom bar import Pkg2_Bar swig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/0000775000175000017500000000000012343605122025103 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/__init__.py0000664000175000017500000000000012343605122027202 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/foo.i0000664000175000017500000000017712343605122026045 0ustar williamwilliam%module(package="py2.pkg2.pkg3") foo %{ #include "../../../py2/pkg2/pkg3/foo.hpp" %} %include "../../../py2/pkg2/pkg3/foo.hpp" swig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile0000664000175000017500000000076012343605122026546 0ustar williamwilliamTOP = ../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/foo.hpp0000664000175000017500000000016312343605122026377 0ustar williamwilliam#ifndef PY2_PKG2_PKG3_FOO_HPP #define PY2_PKG2_PKG3_FOO_HPP struct Pkg3_Foo {}; #endif /* PY2_PKG2_PKG3_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/from_init2/py2/pkg2/Makefile0000664000175000017500000000123312343605122025676 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean cd pkg3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init2/py2/Makefile0000664000175000017500000000055512343605122025041 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init2/py3/0000775000175000017500000000000012343605122023375 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py3/__init__.py0000664000175000017500000000000012343605122025474 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/0000775000175000017500000000000012343605122024240 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/bar.i0000664000175000017500000000021712343605122025156 0ustar williamwilliam%module(package="py3.pkg2") bar %{ #include "../../py3/pkg2/bar.hpp" %} %import "../../py3/pkg2/pkg3/foo.i" %include "../../py3/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/bar.hpp0000664000175000017500000000022612343605122025515 0ustar williamwilliam#ifndef PY3_PKG2_BAR_HPP #define PY3_PKG2_BAR_HPP #include "../../py3/pkg2/pkg3/foo.hpp" struct Pkg2_Bar : Pkg3_Foo {}; #endif /* PY3_PKG2_BAR_HPP */ swig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/__init__.py0000664000175000017500000000003212343605122026344 0ustar williamwilliamfrom .bar import Pkg2_Bar swig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/0000775000175000017500000000000012343605122025104 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/__init__.py0000664000175000017500000000000012343605122027203 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/foo.i0000664000175000017500000000017712343605122026046 0ustar williamwilliam%module(package="py3.pkg2.pkg3") foo %{ #include "../../../py3/pkg2/pkg3/foo.hpp" %} %include "../../../py3/pkg2/pkg3/foo.hpp" swig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile0000664000175000017500000000076012343605122026547 0ustar williamwilliamTOP = ../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/foo.hpp0000664000175000017500000000016312343605122026400 0ustar williamwilliam#ifndef PY3_PKG2_PKG3_FOO_HPP #define PY3_PKG2_PKG3_FOO_HPP struct Pkg3_Foo {}; #endif /* PY3_PKG2_PKG3_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/from_init2/py3/pkg2/Makefile0000664000175000017500000000123312343605122025677 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean cd pkg3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init2/py3/Makefile0000664000175000017500000000055512343605122025042 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init2/Makefile0000664000175000017500000000110412343605122024316 0ustar williamwilliamTOP = ../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = PY3 = ifeq (,$(PY3)) PKG1DIR = "py2" else PKG1DIR = "py3" endif check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd py2 && $(MAKE) clean cd py3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init2/runme.py0000664000175000017500000000044112343605122024361 0ustar williamwilliam# Test import of modules content from within __init__.py print "Testing %module(package=...) + python 'import' in __init__.py" import sys if sys.version_info < (3,0): import py2.pkg2 print " Finished importing py2.pkg2" else: import py3.pkg2 print " Finished importing py3.pkg2" swig-3.0.2/Examples/python/import_packages/README0000664000175000017500000000015612343605122021474 0ustar williamwilliamThese are actually regression tests for SF bug #1297 (GH issue #7). See individual READMEs in subdirectories. swig-3.0.2/Examples/python/import_packages/relativeimport2/0000775000175000017500000000000012343605122023742 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/README0000664000175000017500000000112412343605122024620 0ustar williamwilliamThis example tests the %import directive and -relativeimport option. Use 'python runme.py' to run a test. Overview: --------- The example defines 2 different extension modules--each wrapping a separate C++ class. pyX/pkg2/pkg3/pkg4/foo.i - Pkg4_Foo class pyX/pkg2/bar.i - Pkg2_Bar class derived from Pkg4_Foo The difference between this ('relativeimport2') case and the case 'relativeimport1' is the "distance" between importer and importee. If everything works well, the package pyX.pkg2 shall load properly. Unix: ----- - Run make - Run the test as described above swig-3.0.2/Examples/python/import_packages/relativeimport2/runme3.py0000664000175000017500000000046512343605122025532 0ustar williamwilliam# Test import of modules content from within __init__.py print("Testing %module(package=...) + python 'import' in __init__.py") import sys 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") swig-3.0.2/Examples/python/import_packages/relativeimport2/py2/0000775000175000017500000000000012343605122024454 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py2/__init__.py0000664000175000017500000000000012343605122026553 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/0000775000175000017500000000000012343605122025317 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/bar.i0000664000175000017500000000022412343605122026233 0ustar williamwilliam%module(package="py2.pkg2") bar %{ #include "../../py2/pkg2/bar.hpp" %} %import "../../py2/pkg2/pkg3/pkg4/foo.i" %include "../../py2/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/bar.hpp0000664000175000017500000000021712343605122026574 0ustar williamwilliam#ifndef PY2_PKG2_HPP #define PY2_PKG2_HPP #include "../../py2/pkg2/pkg3/pkg4/foo.hpp" struct Pkg2_Bar : Pkg4_Foo {}; #endif /* PY2_PKG2_HPP */ swig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/__init__.py0000664000175000017500000000000012343605122027416 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/0000775000175000017500000000000012343605122026163 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/0000775000175000017500000000000012343605122027030 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/__init__.py0000664000175000017500000000000012343605122031127 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/foo.i0000664000175000017500000000022412343605122027763 0ustar williamwilliam%module(package="py2.pkg2.pkg3.pkg4") foo %{ #include "../../../../py2/pkg2/pkg3/pkg4/foo.hpp" %} %include "../../../../py2/pkg2/pkg3/pkg4/foo.hpp" swig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile0000664000175000017500000000076312343605122030476 0ustar williamwilliamTOP = ../../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/foo.hpp0000664000175000017500000000015212343605122030322 0ustar williamwilliam#ifndef PY2_PKG2_PKG3_PKG4 #define PY2_PKG2_PKG3_PKG4 struct Pkg4_Foo {}; #endif /* PY2_PKG2_PKG3_PKG4 */ swig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/__init__.py0000664000175000017500000000000012343605122030262 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/Makefile0000664000175000017500000000056312343605122027627 0ustar williamwilliamTOP = ../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg4 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile0000664000175000017500000000123312343605122026756 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean cd pkg3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport2/py2/Makefile0000664000175000017500000000055512343605122026121 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport2/py3/0000775000175000017500000000000012343605122024455 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py3/__init__.py0000664000175000017500000000000012343605122026554 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/0000775000175000017500000000000012343605122025320 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/bar.i0000664000175000017500000000022412343605122026234 0ustar williamwilliam%module(package="py3.pkg2") bar %{ #include "../../py3/pkg2/bar.hpp" %} %import "../../py3/pkg2/pkg3/pkg4/foo.i" %include "../../py3/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/bar.hpp0000664000175000017500000000021712343605122026575 0ustar williamwilliam#ifndef PY3_PKG2_HPP #define PY3_PKG2_HPP #include "../../py3/pkg2/pkg3/pkg4/foo.hpp" struct Pkg2_Bar : Pkg4_Foo {}; #endif /* PY3_PKG2_HPP */ swig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/__init__.py0000664000175000017500000000000012343605122027417 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/0000775000175000017500000000000012343605122026164 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/0000775000175000017500000000000012343605122027031 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/__init__.py0000664000175000017500000000000012343605122031130 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/foo.i0000664000175000017500000000022412343605122027764 0ustar williamwilliam%module(package="py3.pkg2.pkg3.pkg4") foo %{ #include "../../../../py3/pkg2/pkg3/pkg4/foo.hpp" %} %include "../../../../py3/pkg2/pkg3/pkg4/foo.hpp" swig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile0000664000175000017500000000076312343605122030477 0ustar williamwilliamTOP = ../../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/foo.hpp0000664000175000017500000000015212343605122030323 0ustar williamwilliam#ifndef PY3_PKG2_PKG3_PKG4 #define PY3_PKG2_PKG3_PKG4 struct Pkg4_Foo {}; #endif /* PY3_PKG2_PKG3_PKG4 */ swig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/__init__.py0000664000175000017500000000000012343605122030263 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/Makefile0000664000175000017500000000056312343605122027630 0ustar williamwilliamTOP = ../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg4 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile0000664000175000017500000000123312343605122026757 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean cd pkg3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport2/py3/Makefile0000664000175000017500000000055512343605122026122 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport2/Makefile0000664000175000017500000000110412343605122025376 0ustar williamwilliamTOP = ../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = PY3 = ifeq (,$(PY3)) PKG1DIR = "py2" else PKG1DIR = "py3" endif check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd py2 && $(MAKE) clean cd py3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport2/runme.py0000664000175000017500000000046112343605122025443 0ustar williamwilliam# Test import of modules content from within __init__.py print "Testing %module(package=...) + python 'import' in __init__.py" import sys 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" swig-3.0.2/Examples/python/import_packages/same_modnames1/0000775000175000017500000000000012343605122023503 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames1/README0000664000175000017500000000127412343605122024367 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. There are two modules having same name but belonging to different packages. This case is not correctly handled by swig 2. The issue was reported as Source Forge bug #1297 and later as GitHub issue #7. Use 'python runme.py' to run a test. Overview: --------- The example defines 2 different extension modules--each wrapping a separate C++ class. pkg1/foo.i - Pkg1_Foo class. pkg2/foo.i - Pkg2_Foo class (derived from Pkg1_Foo). The pkg2/foo.i module uses %import to refer to pkg1/foo.i. If everything works well, the module pkg2.foo shall load properly. Unix: ----- - Run make - Run the test as described above. swig-3.0.2/Examples/python/import_packages/same_modnames1/pkg2/0000775000175000017500000000000012343605122024346 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames1/pkg2/__init__.py0000664000175000017500000000000012343605122026445 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames1/pkg2/foo.i0000664000175000017500000000016112343605122025301 0ustar williamwilliam%module(package="pkg2") foo %{ #include "../pkg2/foo.hpp" %} %import "../pkg1/foo.i" %include "../pkg2/foo.hpp" swig-3.0.2/Examples/python/import_packages/same_modnames1/pkg2/Makefile0000664000175000017500000000075212343605122026012 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/same_modnames1/pkg2/foo.hpp0000664000175000017500000000020412343605122025636 0ustar williamwilliam#ifndef PKG2_FOO_HPP #define PKG2_FOO_HPP #include "../pkg1/foo.hpp" struct Pkg2_Foo : public Pkg1_Foo{}; #endif /* PKG2_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/same_modnames1/Makefile0000664000175000017500000000114712343605122025146 0ustar williamwilliamTOP = ../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg1 && $(MAKE) clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/same_modnames1/pkg1/0000775000175000017500000000000012343605122024345 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames1/pkg1/__init__.py0000664000175000017500000000000012343605122026444 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames1/pkg1/foo.i0000664000175000017500000000013012343605122025274 0ustar williamwilliam%module(package="pkg1") foo %{ #include "../pkg1/foo.hpp" %} %include "../pkg1/foo.hpp" swig-3.0.2/Examples/python/import_packages/same_modnames1/pkg1/Makefile0000664000175000017500000000075212343605122026011 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/same_modnames1/pkg1/foo.hpp0000664000175000017500000000012712343605122025641 0ustar williamwilliam#ifndef PKG1_FOO_HPP #define PKG1_FOO_HPP struct Pkg1_Foo{}; #endif /* PKG1_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/same_modnames1/runme.py0000664000175000017500000000061312343605122025203 0ustar williamwilliam# Test import of same modules from different packages print "Testing %module(package=...) + %import + same modules in different packages" import pkg2.foo 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))) print " Successfully created object pkg2.foo.Pkg2_Foo" swig-3.0.2/Examples/python/import_packages/from_init1/0000775000175000017500000000000012343605122022661 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init1/README0000664000175000017500000000372412343605122023547 0ustar williamwilliamThis example tests the %import directive and python import from __init__.py. This case is not correctly handled by swig 2. The issue was reported as Source Forge bug #1297 and later as GitHub issue #7. Use 'python runme.py' to run a test. Overview: --------- The example defines 2 different extension modules--each wrapping a separate C++ class. pyX/pkg2/foo.i - Pkg2_Foo class pyX/pkg2/bar.i - Pkg2_Bar class derived from Pkg2_Foo and the package pyX.pkg2 has: pyX/pkg2/__init__.py - which imports something from "bar" module (we import Pkg2_Bar class, but it is not the clue, the clue is the 'from' keyword) For example with python2.x the py2/pkg2/__init__.py imports Pkg2_Bar class as follows from bar import Pkg2_Bar # [1] Such cases doesn't work when fully qualified python module names are used by swig (swig 2.0.10, e.g.) to generate python import directives (SF bug #1297). The generated file "py2/pkg2/bar.py" has following lines: import py2.pkg2.foo # [2] class Pkg2_Bar(py2.pkg2.foo.Pkg2_Foo): # [3] but it's not possible to import anything from py2.pkg2 subpackage, e.g. import py2.pkg2 fails with the following exception: Traceback (most recent call last): File "runme.py", line 3, in import py2.pkg2 File "py2/pkg2/__init__.py", line 7, in from .bar import Pkg2_Bar File "py2/pkg2/bar.py", line 71, in class Pkg2_Bar(py2.pkg2.foo.Pkg2_Foo): AttributeError: 'module' object has no attribute 'pkg2' It seems like during the import [1], the sub-package pkg2 is not yet fully initialized, so py2.pkg2 is not known. The above exception is raised at line [3]. The problem disappears, for example, if we force swig to use relative package names. If everything works well, the package py2.pkg2 shall load properly. Unix: ----- - Run make - Run the test as described above swig-3.0.2/Examples/python/import_packages/from_init1/py2/0000775000175000017500000000000012343605122023373 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init1/py2/__init__.py0000664000175000017500000000000012343605122025472 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init1/py2/pkg2/0000775000175000017500000000000012343605122024236 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init1/py2/pkg2/bar.i0000664000175000017500000000021212343605122025147 0ustar williamwilliam%module(package="py2.pkg2") bar %{ #include "../../py2/pkg2/bar.hpp" %} %import "../../py2/pkg2/foo.i" %include "../../py2/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/from_init1/py2/pkg2/bar.hpp0000664000175000017500000000022112343605122025506 0ustar williamwilliam#ifndef PY2_PKG2_BAR_HPP #define PY2_PKG2_BAR_HPP #include "../../py2/pkg2/foo.hpp" struct Pkg2_Bar : Pkg2_Foo {}; #endif /* PY2_PKG2_BAR_HPP */ swig-3.0.2/Examples/python/import_packages/from_init1/py2/pkg2/__init__.py0000664000175000017500000000003112343605122026341 0ustar williamwilliamfrom bar import Pkg2_Bar swig-3.0.2/Examples/python/import_packages/from_init1/py2/pkg2/foo.i0000664000175000017500000000015212343605122025171 0ustar williamwilliam%module(package="py2.pkg2") foo %{ #include "../../py2/pkg2/foo.hpp" %} %include "../../py2/pkg2/foo.hpp" swig-3.0.2/Examples/python/import_packages/from_init1/py2/pkg2/Makefile0000664000175000017500000000153412343605122025701 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp_static clean:: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean swig-3.0.2/Examples/python/import_packages/from_init1/py2/pkg2/foo.hpp0000664000175000017500000000014412343605122025531 0ustar williamwilliam#ifndef PY2_PKG2_FOO_HPP #define PY2_PKG2_FOO_HPP struct Pkg2_Foo {}; #endif /* PY2_PKG2_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/from_init1/py2/Makefile0000664000175000017500000000055512343605122025040 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init1/py3/0000775000175000017500000000000012343605122023374 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init1/py3/__init__.py0000664000175000017500000000000012343605122025473 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init1/py3/pkg2/0000775000175000017500000000000012343605122024237 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init1/py3/pkg2/bar.i0000664000175000017500000000021212343605122025150 0ustar williamwilliam%module(package="py3.pkg2") bar %{ #include "../../py3/pkg2/bar.hpp" %} %import "../../py3/pkg2/foo.i" %include "../../py3/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/from_init1/py3/pkg2/bar.hpp0000664000175000017500000000022112343605122025507 0ustar williamwilliam#ifndef PY3_PKG2_BAR_HPP #define PY3_PKG2_BAR_HPP #include "../../py3/pkg2/foo.hpp" struct Pkg2_Bar : Pkg2_Foo {}; #endif /* PY3_PKG2_BAR_HPP */ swig-3.0.2/Examples/python/import_packages/from_init1/py3/pkg2/__init__.py0000664000175000017500000000003212343605122026343 0ustar williamwilliamfrom .bar import Pkg2_Bar swig-3.0.2/Examples/python/import_packages/from_init1/py3/pkg2/foo.i0000664000175000017500000000015212343605122025172 0ustar williamwilliam%module(package="py3.pkg2") foo %{ #include "../../py3/pkg2/foo.hpp" %} %include "../../py3/pkg2/foo.hpp" swig-3.0.2/Examples/python/import_packages/from_init1/py3/pkg2/Makefile0000664000175000017500000000153412343605122025702 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp_static clean:: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean swig-3.0.2/Examples/python/import_packages/from_init1/py3/pkg2/foo.hpp0000664000175000017500000000014412343605122025532 0ustar williamwilliam#ifndef PY3_PKG2_FOO_HPP #define PY3_PKG2_FOO_HPP struct Pkg2_Foo {}; #endif /* PY3_PKG2_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/from_init1/py3/Makefile0000664000175000017500000000055512343605122025041 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init1/Makefile0000664000175000017500000000110412343605122024315 0ustar williamwilliamTOP = ../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = PY3 = ifeq (,$(PY3)) PKG1DIR = "py2" else PKG1DIR = "py3" endif check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd py2 && $(MAKE) clean cd py3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init1/runme.py0000664000175000017500000000044112343605122024360 0ustar williamwilliam# Test import of modules content from within __init__.py print "Testing %module(package=...) + python 'import' in __init__.py" import sys if sys.version_info < (3,0): import py2.pkg2 print " Finished importing py2.pkg2" else: import py3.pkg2 print " Finished importing py3.pkg2" swig-3.0.2/Examples/python/import_packages/relativeimport1/0000775000175000017500000000000012343605122023741 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/README0000664000175000017500000000106612343605122024624 0ustar williamwilliamThis example tests the %import directive and -relativeimport swig option. Use 'python runme.py' to run a test. Overview: --------- The example defines 2 different extension modules--each wrapping a separate C++ class. pyX/pkg2/pkg3/foo.i - Pkg3_Foo class pyX/pkg2/bar.i - Pkg2_Bar class derived from Pkg3_Foo The code is processed by swig with -relativeimport flag. The runtime test imports pyX.pkg2.bar module. If everything works well, the module pyX.pkg2.bar shall load properly. Unix: ----- - Run make - Run the test as described above swig-3.0.2/Examples/python/import_packages/relativeimport1/py2/0000775000175000017500000000000012343605122024453 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py2/__init__.py0000664000175000017500000000000012343605122026552 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/0000775000175000017500000000000012343605122025316 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/bar.i0000664000175000017500000000021712343605122026234 0ustar williamwilliam%module(package="py2.pkg2") bar %{ #include "../../py2/pkg2/bar.hpp" %} %import "../../py2/pkg2/pkg3/foo.i" %include "../../py2/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/bar.hpp0000664000175000017500000000022612343605122026573 0ustar williamwilliam#ifndef PY2_PKG2_BAR_HPP #define PY2_PKG2_BAR_HPP #include "../../py2/pkg2/pkg3/foo.hpp" struct Pkg2_Bar : Pkg3_Foo {}; #endif /* PY2_PKG2_BAR_HPP */ swig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/__init__.py0000664000175000017500000000000012343605122027415 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/0000775000175000017500000000000012343605122026162 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/__init__.py0000664000175000017500000000000012343605122030261 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/foo.i0000664000175000017500000000017712343605122027124 0ustar williamwilliam%module(package="py2.pkg2.pkg3") foo %{ #include "../../../py2/pkg2/pkg3/foo.hpp" %} %include "../../../py2/pkg2/pkg3/foo.hpp" swig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile0000664000175000017500000000076012343605122027625 0ustar williamwilliamTOP = ../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/foo.hpp0000664000175000017500000000016312343605122027456 0ustar williamwilliam#ifndef PY2_PKG2_PKG3_FOO_HPP #define PY2_PKG2_PKG3_FOO_HPP struct Pkg3_Foo {}; #endif /* PY2_PKG2_PKG3_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile0000664000175000017500000000123312343605122026755 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean cd pkg3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport1/py2/Makefile0000664000175000017500000000055512343605122026120 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport1/py3/0000775000175000017500000000000012343605122024454 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py3/__init__.py0000664000175000017500000000000012343605122026553 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/0000775000175000017500000000000012343605122025317 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/bar.i0000664000175000017500000000021712343605122026235 0ustar williamwilliam%module(package="py3.pkg2") bar %{ #include "../../py3/pkg2/bar.hpp" %} %import "../../py3/pkg2/pkg3/foo.i" %include "../../py3/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/bar.hpp0000664000175000017500000000022612343605122026574 0ustar williamwilliam#ifndef PY3_PKG2_BAR_HPP #define PY3_PKG2_BAR_HPP #include "../../py3/pkg2/pkg3/foo.hpp" struct Pkg2_Bar : Pkg3_Foo {}; #endif /* PY3_PKG2_BAR_HPP */ swig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/__init__.py0000664000175000017500000000000012343605122027416 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/0000775000175000017500000000000012343605122026163 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/__init__.py0000664000175000017500000000000012343605122030262 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/foo.i0000664000175000017500000000017712343605122027125 0ustar williamwilliam%module(package="py3.pkg2.pkg3") foo %{ #include "../../../py3/pkg2/pkg3/foo.hpp" %} %include "../../../py3/pkg2/pkg3/foo.hpp" swig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile0000664000175000017500000000076012343605122027626 0ustar williamwilliamTOP = ../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/foo.hpp0000664000175000017500000000016312343605122027457 0ustar williamwilliam#ifndef PY3_PKG2_PKG3_FOO_HPP #define PY3_PKG2_PKG3_FOO_HPP struct Pkg3_Foo {}; #endif /* PY3_PKG2_PKG3_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile0000664000175000017500000000123312343605122026756 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean cd pkg3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport1/py3/Makefile0000664000175000017500000000055512343605122026121 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport1/Makefile0000664000175000017500000000110412343605122025375 0ustar williamwilliamTOP = ../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = PY3 = ifeq (,$(PY3)) PKG1DIR = "py2" else PKG1DIR = "py3" endif check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd py2 && $(MAKE) clean cd py3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/relativeimport1/runme.py0000664000175000017500000000044512343605122025444 0ustar williamwilliam# Test import of modules content from within __init__.py print "Testing %module(package=...) with -relativeimport" import sys 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" swig-3.0.2/Examples/python/import_packages/from_init3/0000775000175000017500000000000012343605122022663 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/README0000664000175000017500000000444212343605122023547 0ustar williamwilliamThis example tests the %import directive and python import from __init__.py. This case is not correctly handled by swig 2. The issue was reported as Source Forge bug #1297 and later as GitHub issue #7. Use 'python runme.py' to run a test. Overview: --------- The example defines 2 different extension modules--each wrapping a separate C++ class. pyX/pkg2/pkg3/pkg4/foo.i - Pkg4_Foo class pyX/pkg2/bar.i - Pkg2_Bar class derived from Pkg4_Foo and the package pyX.pkg2 has: pyX/pkg2/__init__.py - which imports something from "bar" module For example with python 2.x the py2/pkg2/__init__.py imports Pkg2_Bar class as follows from bar import Pkg2_Bar # [1] Such cases doesn't work when fully qualified python module names are used by swig to generate python import directives (SF bug 1297). The generated file "py2/pkg2/bar.py" has following lines: import py2.pkg2.pkg3.pkg4.foo # [2] class Pkg2_Bar(py2.pkg2.pkg3.pkg4.foo.P1_S1_S2_Foo): # [3] and it's not possible to import anything from py2.pkg2 subpackage, e.g. import py2.pkg2 fails with the following exception: Traceback (most recent call last): File "runme.py", line 3, in import py2.pkg2 File "py2/pkg2/__init__.py", line 4, in from bar import Pkg2_Bar File "py2/pkg2/bar.py", line 71, in class Pkg2_Bar(py2.pkg2.pkg3.pkg4.foo.Pkg4_Foo): AttributeError: 'module' object has no attribute 'pkg2' It seems like during the import [1], the subpackage pkg2 is not yet fully initialized, so py2.pkg2 can't be used. The above exception is raised at line [3]. The problem disappears, for example, if we force swig to use relative package names. The difference between this ('from_init3') case and the case 'from_init2' is that here we import base class from module pyX.pkg2.pkg3.pkg4.foo, which is nested deeper than it was in 'from_init2'. This is just to ensure, that two (and more) levels of subpackages get imported correctly by generated python code, i.e, not only 'pkg3.foo' is handled properly (one-level subpackage) but the code works also for 'pkg3.pkg4.foo', and so on. If everything works well, the package pyX.pkg2 shall load properly. Unix: ----- - Run make - Run the test as described above swig-3.0.2/Examples/python/import_packages/from_init3/py2/0000775000175000017500000000000012343605122023375 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py2/__init__.py0000664000175000017500000000000012343605122025474 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/0000775000175000017500000000000012343605122024240 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/bar.i0000664000175000017500000000022412343605122025154 0ustar williamwilliam%module(package="py2.pkg2") bar %{ #include "../../py2/pkg2/bar.hpp" %} %import "../../py2/pkg2/pkg3/pkg4/foo.i" %include "../../py2/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/bar.hpp0000664000175000017500000000021712343605122025515 0ustar williamwilliam#ifndef PY2_PKG2_HPP #define PY2_PKG2_HPP #include "../../py2/pkg2/pkg3/pkg4/foo.hpp" struct Pkg2_Bar : Pkg4_Foo {}; #endif /* PY2_PKG2_HPP */ swig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/__init__.py0000664000175000017500000000003112343605122026343 0ustar williamwilliamfrom bar import Pkg2_Bar swig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/0000775000175000017500000000000012343605122025104 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/0000775000175000017500000000000012343605122025751 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/__init__.py0000664000175000017500000000000012343605122030050 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/foo.i0000664000175000017500000000022412343605122026704 0ustar williamwilliam%module(package="py2.pkg2.pkg3.pkg4") foo %{ #include "../../../../py2/pkg2/pkg3/pkg4/foo.hpp" %} %include "../../../../py2/pkg2/pkg3/pkg4/foo.hpp" swig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile0000664000175000017500000000076312343605122027417 0ustar williamwilliamTOP = ../../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/foo.hpp0000664000175000017500000000015212343605122027243 0ustar williamwilliam#ifndef PY2_PKG2_PKG3_PKG4 #define PY2_PKG2_PKG3_PKG4 struct Pkg4_Foo {}; #endif /* PY2_PKG2_PKG3_PKG4 */ swig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/__init__.py0000664000175000017500000000000012343605122027203 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/Makefile0000664000175000017500000000056312343605122026550 0ustar williamwilliamTOP = ../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg4 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init3/py2/pkg2/Makefile0000664000175000017500000000123312343605122025677 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean cd pkg3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init3/py2/Makefile0000664000175000017500000000055512343605122025042 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init3/py3/0000775000175000017500000000000012343605122023376 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py3/__init__.py0000664000175000017500000000000012343605122025475 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/0000775000175000017500000000000012343605122024241 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/bar.i0000664000175000017500000000022412343605122025155 0ustar williamwilliam%module(package="py3.pkg2") bar %{ #include "../../py3/pkg2/bar.hpp" %} %import "../../py3/pkg2/pkg3/pkg4/foo.i" %include "../../py3/pkg2/bar.hpp" swig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/bar.hpp0000664000175000017500000000021712343605122025516 0ustar williamwilliam#ifndef PY3_PKG2_HPP #define PY3_PKG2_HPP #include "../../py3/pkg2/pkg3/pkg4/foo.hpp" struct Pkg2_Bar : Pkg4_Foo {}; #endif /* PY3_PKG2_HPP */ swig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/__init__.py0000664000175000017500000000003212343605122026345 0ustar williamwilliamfrom .bar import Pkg2_Bar swig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/0000775000175000017500000000000012343605122025105 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/0000775000175000017500000000000012343605122025752 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/__init__.py0000664000175000017500000000000012343605122030051 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/foo.i0000664000175000017500000000022412343605122026705 0ustar williamwilliam%module(package="py3.pkg2.pkg3.pkg4") foo %{ #include "../../../../py3/pkg2/pkg3/pkg4/foo.hpp" %} %include "../../../../py3/pkg2/pkg3/pkg4/foo.hpp" swig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile0000664000175000017500000000076312343605122027420 0ustar williamwilliamTOP = ../../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/foo.hpp0000664000175000017500000000015212343605122027244 0ustar williamwilliam#ifndef PY3_PKG2_PKG3_PKG4 #define PY3_PKG2_PKG3_PKG4 struct Pkg4_Foo {}; #endif /* PY3_PKG2_PKG3_PKG4 */ swig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/__init__.py0000664000175000017500000000000012343605122027204 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/Makefile0000664000175000017500000000056312343605122026551 0ustar williamwilliamTOP = ../../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg4 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init3/py3/pkg2/Makefile0000664000175000017500000000123312343605122025700 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean cd pkg3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init3/py3/Makefile0000664000175000017500000000055512343605122025043 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init3/Makefile0000664000175000017500000000110412343605122024317 0ustar williamwilliamTOP = ../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = PY3 = ifeq (,$(PY3)) PKG1DIR = "py2" else PKG1DIR = "py3" endif check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd py2 && $(MAKE) clean cd py3 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/from_init3/runme.py0000664000175000017500000000044112343605122024362 0ustar williamwilliam# Test import of modules content from within __init__.py print "Testing %module(package=...) + python 'import' in __init__.py" import sys if sys.version_info < (3,0): import py2.pkg2 print " Finished importing py2.pkg2" else: import py3.pkg2 print " Finished importing py3.pkg2" swig-3.0.2/Examples/python/import_packages/Makefile0000664000175000017500000000210612343605122022251 0ustar williamwilliamTOP = ../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = PY3 = import_packages_subdirs = \ same_modnames1 \ same_modnames2 \ from_init1 \ from_init2 \ from_init3 \ relativeimport1 \ relativeimport1 check: build if test "x$(SRCDIR)" != x; then \ for file in `cd $(SRCDIR) && find . -type f -name __init__.py`; do \ cp "${SRCDIR}$$file" "$$file" || exit 1; \ done; \ fi; \ for s in $(import_packages_subdirs); do \ (cd $$s && $(MAKE) check); \ done build: for s in $(import_packages_subdirs); do \ (cd $$s && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \ done static: for s in $(import_packages_subdirs); do \ (cd $$s && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \ done clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean if test "x$(SRCDIR)" != x; then \ for file in `cd $(SRCDIR) && find . -type f -name __init__.py`; do \ rm -f "$$file" || exit 1; \ done; \ fi; \ for s in $(import_packages_subdirs); do \ (cd $$s && $(MAKE) clean); \ done swig-3.0.2/Examples/python/import_packages/same_modnames2/0000775000175000017500000000000012343605122023504 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames2/README0000664000175000017500000000132112343605122024361 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. There are two modules having same name but belonging to different packages. This case is not correctly handled by swig 2. The issue was reported as Source Forge bug #1297 and later as GitHub issue #7. Use 'python runme.py' to run a test. Overview: --------- The example defines 2 different extension modules--each wrapping a separate C++ class. pkg1/foo.i - Pkg1_Foo class pkg1/pkg2/foo.i - Pkg2_Foo class derived from Pkg1_Foo The pkg1/pkg2/foo module uses %import to refer to pkg1/foo. If everything works well, the module pkg1.pkg2.foo shall load properly. Unix: ----- - Run make - Run the test as described above swig-3.0.2/Examples/python/import_packages/same_modnames2/Makefile0000664000175000017500000000116612343605122025150 0ustar williamwilliamTOP = ../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build cd pkg1/pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static cd pkg1/pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean cd pkg1 && $(MAKE) clean cd pkg1/pkg2 && $(MAKE) clean swig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/0000775000175000017500000000000012343605122024346 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/__init__.py0000664000175000017500000000000012343605122026445 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/foo.i0000664000175000017500000000013012343605122025275 0ustar williamwilliam%module(package="pkg1") foo %{ #include "../pkg1/foo.hpp" %} %include "../pkg1/foo.hpp" swig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/pkg2/0000775000175000017500000000000012343605122025211 5ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/pkg2/__init__.py0000664000175000017500000000000012343605122027310 0ustar williamwilliamswig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/pkg2/foo.i0000664000175000017500000000021112343605122026140 0ustar williamwilliam%module(package="pkg1.pkg2") foo %{ #include "../../pkg1/pkg2/foo.hpp" %} %import "../../pkg1/foo.i" %include "../../pkg1/pkg2/foo.hpp" swig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile0000664000175000017500000000075512343605122026660 0ustar williamwilliamTOP = ../../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/pkg2/foo.hpp0000664000175000017500000000022612343605122026505 0ustar williamwilliam#ifndef PKG1_PKG2_FOO_HPP #define PKG1_PKG2_FOO_HPP #include "../../pkg1/foo.hpp" struct Pkg2_Foo : public Pkg1_Foo{}; #endif /* PKG1_PKG2_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/Makefile0000664000175000017500000000075212343605122026012 0ustar williamwilliamTOP = ../../../.. SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean swig-3.0.2/Examples/python/import_packages/same_modnames2/pkg1/foo.hpp0000664000175000017500000000012712343605122025642 0ustar williamwilliam#ifndef PKG1_FOO_HPP #define PKG1_FOO_HPP struct Pkg1_Foo{}; #endif /* PKG1_FOO_HPP */ swig-3.0.2/Examples/python/import_packages/same_modnames2/runme.py0000664000175000017500000000043312343605122025204 0ustar williamwilliamimport pkg1.pkg2.foo print " Finished importing pkg1.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))) print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo" swig-3.0.2/Examples/python/performance/0000775000175000017500000000000012343605122017743 5ustar williamwilliamswig-3.0.2/Examples/python/performance/harness.py0000664000175000017500000000142512343605122021762 0ustar williamwilliamimport sys import time import imp from subprocess import * def run (proc) : try : mod = imp.find_module(sys.argv[1]) mod = imp.load_module(sys.argv[1], *mod) t1 = time.clock() proc(mod) t2 = time.clock() print "%s took %f seconds" % (mod.__name__, t2 - t1) 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) (stdout, stderr) = proc.communicate() print stdout proc = Popen([sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE) (stdout, stderr) = proc.communicate() print stdout swig-3.0.2/Examples/python/performance/func/0000775000175000017500000000000012343605122020676 5ustar williamwilliamswig-3.0.2/Examples/python/performance/func/Simple.i0000664000175000017500000000014212343605122022276 0ustar williamwilliam%inline %{ class MyClass { public: MyClass () {} ~MyClass () {} void func () {} }; %} swig-3.0.2/Examples/python/performance/func/Makefile0000664000175000017500000000163612343605122022344 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-3.0.2/Examples/python/performance/func/runme.py0000664000175000017500000000023312343605122022374 0ustar williamwilliamimport sys sys.path.append('..') import harness def proc (mod) : x = mod.MyClass() for i in range(10000000) : x.func() harness.run(proc) swig-3.0.2/Examples/python/performance/constructor/0000775000175000017500000000000012343605122022330 5ustar williamwilliamswig-3.0.2/Examples/python/performance/constructor/Simple.i0000664000175000017500000000014212343605122023730 0ustar williamwilliam%inline %{ class MyClass { public: MyClass () {} ~MyClass () {} void func () {} }; %} swig-3.0.2/Examples/python/performance/constructor/Makefile0000664000175000017500000000163612343605122023776 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-3.0.2/Examples/python/performance/constructor/runme.py0000664000175000017500000000021512343605122024026 0ustar williamwilliamimport sys sys.path.append('..') import harness def proc (mod) : for i in range(1000000) : x = mod.MyClass() harness.run(proc) swig-3.0.2/Examples/python/performance/hierarchy/0000775000175000017500000000000012343605122021721 5ustar williamwilliamswig-3.0.2/Examples/python/performance/hierarchy/Simple.i0000664000175000017500000000075012343605122023326 0ustar williamwilliam%inline %{ class A { public: A () {} ~A () {} void func () {} }; class B : public A { public: B () {} ~B () {} }; class C : public B { public: C () {} ~C () {} }; class D : public C { public: D () {} ~D () {} }; class E : public D { public: E () {} ~E () {} }; class F : public E { public: F () {} ~F () {} }; class G : public F { public: G () {} ~G () {} }; class H : public G { public: H () {} ~H () {} }; %} swig-3.0.2/Examples/python/performance/hierarchy/Makefile0000664000175000017500000000163612343605122023367 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-3.0.2/Examples/python/performance/hierarchy/runme.py0000664000175000017500000000022512343605122023420 0ustar williamwilliamimport sys sys.path.append('..') import harness def proc (mod) : x = mod.H() for i in range(10000000) : x.func() harness.run(proc) swig-3.0.2/Examples/python/performance/Makefile0000664000175000017500000000144512343605122021407 0ustar williamwilliamcheck: all include ../../Makefile SUBDIRS := constructor func hierarchy operator hierarchy_operator .PHONY : all $(SUBDIRS) all: $(SUBDIRS:%=%-build) @for subdir in $(SUBDIRS); do \ echo Running $$subdir test... ; \ echo -------------------------------------------------------------------------------- ; \ cd $$subdir; \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT); \ cd ..; \ done $(SUBDIRS): $(MAKE) -C $@ @echo Running $$subdir test... @echo -------------------------------------------------------------------------------- cd $@ && env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) %-build: $(MAKE) -C $* %-clean: $(MAKE) -s -C $* clean clean: $(SUBDIRS:%=%-clean) rm -f *.pyc swig-3.0.2/Examples/python/performance/operator/0000775000175000017500000000000012343605122021576 5ustar williamwilliamswig-3.0.2/Examples/python/performance/operator/Simple.i0000664000175000017500000000017712343605122023206 0ustar williamwilliam%inline %{ class MyClass { public: MyClass () {} ~MyClass () {} MyClass& operator+ (int i) { return *this; } }; %} swig-3.0.2/Examples/python/performance/operator/Makefile0000664000175000017500000000163612343605122023244 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-3.0.2/Examples/python/performance/operator/runme.py0000664000175000017500000000023412343605122023275 0ustar williamwilliamimport sys sys.path.append('..') import harness def proc (mod) : x = mod.MyClass() for i in range(10000000) : x = x + i harness.run(proc) swig-3.0.2/Examples/python/performance/hierarchy_operator/0000775000175000017500000000000012343605122023634 5ustar williamwilliamswig-3.0.2/Examples/python/performance/hierarchy_operator/Simple.i0000664000175000017500000000102412343605122025234 0ustar williamwilliam%inline %{ class A { public: A () {} ~A () {} void func () {} A& operator+= (int i) { return *this; } }; class B : public A { public: B () {} ~B () {} }; class C : public B { public: C () {} ~C () {} }; class D : public C { public: D () {} ~D () {} }; class E : public D { public: E () {} ~E () {} }; class F : public E { public: F () {} ~F () {} }; class G : public F { public: G () {} ~G () {} }; class H : public G { public: H () {} ~H () {} }; %} swig-3.0.2/Examples/python/performance/hierarchy_operator/Makefile0000664000175000017500000000163612343605122025302 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-3.0.2/Examples/python/performance/hierarchy_operator/runme.py0000664000175000017500000000022312343605122025331 0ustar williamwilliamimport sys sys.path.append('..') import harness def proc (mod) : x = mod.H() for i in range(10000000) : x += i harness.run(proc) swig-3.0.2/Examples/python/reference/0000775000175000017500000000000012343605122017400 5ustar williamwilliamswig-3.0.2/Examples/python/reference/example.h0000664000175000017500000000064512343605122021211 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; friend Vector operator+(const Vector &a, const Vector &b); char *print(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/python/reference/example.i0000664000175000017500000000134412343605122021207 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module example %{ #include "example.h" %} %rename(cprint) print; class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.2/Examples/python/reference/example.cxx0000664000175000017500000000161412343605122021561 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/python/reference/index.html0000664000175000017500000000633512343605122021404 0ustar williamwilliam SWIG:Examples:python:reference SWIG/Examples/python/reference/

C++ Reference Handling

This example tests SWIG's handling of C++ references. Since C++ references are closely related to pointers (as both refer to a location in memory), SWIG simply collapses all references into pointers when creating wrappers.

Some examples

References are most commonly used as function parameter. For example, you might have an operator like this:
Vector operator+(const Vector &a, const Vector &b) {
   Vector result;
   result.x = a.x + b.x;
   result.y = a.y + b.y;
   result.z = a.z + b.z;
   return result;
}
or a function:
Vector addv(const Vector &a, const Vector &b) {
   Vector result;
   result.x = a.x + b.x;
   result.y = a.y + b.y;
   result.z = a.z + b.z;
   return result;
}
In these cases, SWIG transforms everything into a pointer and creates a wrapper that looks like this:
Vector wrap_addv(Vector *a, Vector *b) {
    return addv(*a,*b);
}
Occasionally, a reference is used as a return value of a function when the return result is to be used as an lvalue in an expression. The prototypical example is an operator like this:
Vector &operator[](int index);
or a method:
Vector &get(int index);
For functions returning references, a wrapper like this is created:
Vector *wrap_Object_get(Object *self, int index) {
    Vector &result = self->get(index);
    return &result;
}
The following header file contains some class definitions with some operators and use of references.

SWIG Interface

SWIG does NOT support overloaded operators so it can not directly build an interface to the classes in the above file. However, a number of workarounds can be made. For example, an overloaded operator can be stuck behind a function call such as the addv() function above. Array access can be handled with a pair of set/get functions like this:
class VectorArray {
public:
 ...
   %addmethods {
    Vector &get(int index) {
      return (*self)[index];
    }
    void set(int index, Vector &a) {
      (*self)[index] = a;
    }
   }
   ...
}
Click here to see a SWIG interface file with these additions.

Sample Python script

Click here to see a script that manipulates some C++ references.

Notes:

  • C++ references primarily provide notational convenience for C++ source code. However, Python only supports the 'x.a' notation so it doesn't much matter.

  • When a program returns a reference, a pointer is returned. Unlike return by value, memory is not allocated to hold the return result.

  • SWIG has particular trouble handling various combinations of references and pointers. This is side effect of an old parsing scheme and type representation that will be replaced in future versions.

swig-3.0.2/Examples/python/reference/Makefile0000664000175000017500000000113512343605122021040 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/reference/runme.py0000664000175000017500000000240312343605122021077 0ustar williamwilliam# file: runme.py # This file illustrates the manipulation of C++ references in Python import example # ----- Object creation ----- print "Creating some objects:" a = example.Vector(3,4,5) b = example.Vector(10,11,12) 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 &) # # It returns a new allocated object. print "Adding a+b" c = example.addv(a,b) print " a+b =", c.cprint() # Note: Unless we free the result, a memory leak will occur del c # ----- Create a vector array ----- # Note: Using the high-level interface here print "Creating an array of vectors" va = example.VectorArray(10) 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(2,example.addv(a,b)) # Get some values from the array print "Getting some array values" 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): c = va.get(i % 10) # ----- Clean up ----- print "Cleaning up" del va del a del b swig-3.0.2/Examples/python/functor/0000775000175000017500000000000012343605122017122 5ustar williamwilliamswig-3.0.2/Examples/python/functor/example.i0000664000175000017500000000111312343605122020723 0ustar williamwilliam/* File : example.i */ %module example %inline %{ // From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514 template class Sum { T res; public: Sum(T i = 0) : res(i) { } void operator() (T x) { res += x; } T result() const { return res; } }; %} // Rename the application operator to __call__ for python. // Note: this is normally automatic, but if you had to do it yourself // you would use this directive: // // %rename(__call__) *::operator(); // Instantiate a few versions %template(intSum) Sum; %template(doubleSum) Sum; swig-3.0.2/Examples/python/functor/Makefile0000664000175000017500000000116312343605122020563 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/functor/runme.py0000664000175000017500000000053112343605122020621 0ustar williamwilliam# Operator overloading example import example import math a = example.intSum(0) b = example.doubleSum(100.0) # Use the objects. They should be callable just like a normal # python function. for i in range(0,100): a(i) # Note: function call b(math.sqrt(i)) # Note: function call print a.result() print b.result() swig-3.0.2/Examples/python/libffi/0000775000175000017500000000000012343605122016675 5ustar williamwilliamswig-3.0.2/Examples/python/libffi/example.i0000664000175000017500000000763212343605122020512 0ustar williamwilliam/* File : example.i */ %module example %{ #include #include %} /* A wrapper for execlp() using libffi to handle an arbitrary number of arguments */ %typemap(in) (...) { char **argv; int argc; int i; argc = PyTuple_Size(varargs); argv = (char **) malloc(sizeof(char *)*(argc+1)); for (i = 0; i < argc; i++) { PyObject *o = PyTuple_GetItem(varargs,i); if (!PyString_Check(o)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); return NULL; } argv[i] = PyString_AsString(o); } argv[i] = NULL; $1 = (void *) argv; } /* Rewrite the function call, using libffi */ %feature("action") execlp { int i, vc; ffi_cif cif; ffi_type **types; void **values; char **args; vc = PyTuple_Size(varargs); types = (ffi_type **) malloc((vc+3)*sizeof(ffi_type *)); values = (void **) malloc((vc+3)*sizeof(void *)); args = (char **) arg3; /* Set up path parameter */ types[0] = &ffi_type_pointer; values[0] = &arg1; /* Set up first argument */ types[1] = &ffi_type_pointer; values[1] = &arg2; /* Set up rest of parameters */ for (i = 0; i <= vc; i++) { types[2+i] = &ffi_type_pointer; values[2+i] = &args[i]; } if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, vc+3, &ffi_type_uint, types) == FFI_OK) { ffi_call(&cif, (void (*)()) execlp, &result, values); } else { PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!"); free(types); free(values); free(arg3); return NULL; } free(types); free(values); free(arg3); } int execlp(const char *path, const char *arg1, ...); /* A wrapper for printf() using libffi */ %{ typedef struct { int type; union { int ivalue; double dvalue; void *pvalue; } val; } vtype; enum { VT_INT, VT_DOUBLE, VT_POINTER }; %} %typemap(in) (const char *fmt, ...) { vtype *argv; int argc; int i; $1 = PyString_AsString($input); argc = PyTuple_Size(varargs); argv = (vtype *) malloc(argc*sizeof(vtype)); for (i = 0; i < argc; i++) { PyObject *o = PyTuple_GetItem(varargs,i); if (PyInt_Check(o)) { argv[i].type = VT_INT; argv[i].val.ivalue = PyInt_AsLong(o); } else if (PyFloat_Check(o)) { argv[i].type = VT_DOUBLE; argv[i].val.dvalue = PyFloat_AsDouble(o); } else if (PyString_Check(o)) { argv[i].type = VT_POINTER; argv[i].val.pvalue = (void *) PyString_AsString(o); } else { PyErr_SetString(PyExc_ValueError,"Unsupported argument type"); free(argv); return NULL; } } $2 = (void *) argv; } /* Rewrite the function call, using libffi */ %feature("action") printf { int i, vc; ffi_cif cif; ffi_type **types; void **values; vtype *args; vc = PyTuple_Size(varargs); types = (ffi_type **) malloc((vc+1)*sizeof(ffi_type *)); values = (void **) malloc((vc+1)*sizeof(void *)); args = (vtype *) arg2; /* Set up fmt parameter */ types[0] = &ffi_type_pointer; values[0] = &arg1; /* Set up rest of parameters */ for (i = 0; i < vc; i++) { switch(args[i].type) { case VT_INT: types[1+i] = &ffi_type_uint; values[1+i] = &args[i].val.ivalue; break; case VT_DOUBLE: types[1+i] = &ffi_type_double; values[1+i] = &args[i].val.dvalue; break; case VT_POINTER: types[1+i] = &ffi_type_pointer; values[1+i] = &args[i].val.pvalue; break; default: abort(); /* Whoa! We're seriously hosed */ break; } } if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, vc+1, &ffi_type_uint, types) == FFI_OK) { ffi_call(&cif, (void (*)()) printf, &result, values); } else { PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!"); free(types); free(values); free(args); return NULL; } free(types); free(values); free(args); } int printf(const char *fmt, ...); swig-3.0.2/Examples/python/libffi/Makefile0000664000175000017500000000111212343605122020330 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-L/usr/local/lib -lffi' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/check.list0000664000175000017500000000044212343605122017414 0ustar williamwilliam# see top-level Makefile.in callback class constants contract docstrings enum exception exceptproxy extend funcptr funcptr2 functor import import_template import_packages java #libffi multimap operator pointer reference simple smartptr std_vector std_map swigrun template varargs variables swig-3.0.2/Examples/python/funcptr2/0000775000175000017500000000000012343605122017205 5ustar williamwilliamswig-3.0.2/Examples/python/funcptr2/example.c0000664000175000017500000000037012343605122021004 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/python/funcptr2/example.h0000664000175000017500000000026312343605122021012 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/python/funcptr2/example.i0000664000175000017500000000053712343605122021017 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %callback("%(upper)s"); int add(int, int); int sub(int, int); int mul(int, int); %nocallback; extern int (*funcvar)(int,int); swig-3.0.2/Examples/python/funcptr2/Makefile0000664000175000017500000000106612343605122020650 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/funcptr2/runme.py0000664000175000017500000000123112343605122020702 0ustar williamwilliam# file: runme.py import example a = 37 b = 42 # Now call our C function with a bunch of callbacks 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 "Here is what the C callback function objects look like in Python" print " ADD =", example.ADD 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) swig-3.0.2/Examples/python/index.html0000664000175000017500000000615712343605122017450 0ustar williamwilliam SWIG:Examples:python

SWIG Python Examples

The following examples illustrate the use of SWIG with Python.

  • simple. A minimal example showing how SWIG can be used to wrap a C function, a global variable, and a constant.
  • constants. This shows how preprocessor macros and certain C declarations are turned into constants.
  • variables. An example showing how to access C global variables from Python.
  • value. How to pass and return structures by value.
  • class. Wrapping a simple C++ class.
  • reference. C++ references.
  • pointer. Simple pointer handling.
  • funcptr. Pointers to functions.

Compilation Issues

  • To create a Python extension, SWIG is run with the following options:
    % swig -python interface.i
    
  • Please see the Windows page in the main manual for information on using the examples on Windows.

  • On Unix the compilation of examples is done using the file Example/Makefile. This makefile performs a manual module compilation which is platform specific. Typically, the steps look like this (Linux):
    % swig -python interface.i
    % gcc -fpic -c interface_wrap.c -I/usr/local/include/python1.5
    % gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so 
    % python
    Python 1.5.2 (#3, Oct  9 1999, 22:09:34)  [GCC 2.95.1 19990816 (release)] on linux2
    Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
    >>> import interface
    >>> interface.blah(...)
    ...
    
  • The politically "correct" way to compile a Python extension is to follow the steps described at www.python.org:

    1. Create a file called Setup that looks like the following where $(SRCS) is filled in with any other source files you need to build the extension:
      *shared*
      interface interface_wrap.c $(SRCS)
      
    2. Copy the file Makefile.pre.in from the Python distribution. Usually it's located in the directory /usr/local/lib/python1.5/config on a Unix machine.

    3. Type the following to build the extension:
      % make -f Makefile.pre.in boot
      % make
      
    4. And that's it. If you are preparing an extension for distribution, you may want to look at the distutils.

Compatibility

For Python 3, set the environment variable PY3=1. This will ensure the 2to3 program is run prior to running any example.

Your mileage may vary. If you experience a problem, please let us know by contacting us on the mailing lists. swig-3.0.2/Examples/python/exception/0000775000175000017500000000000012343605122017440 5ustar williamwilliamswig-3.0.2/Examples/python/exception/example.h0000664000175000017500000000201312343605122021240 0ustar williamwilliam/* File : example.h */ #include #ifndef SWIG struct A { }; #endif class Exc { public: Exc(int c, const char *m) { code = c; strncpy(msg,m,256); } int code; char msg[256]; }; #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif class Test { public: int simple() throw(int) { throw(37); return 1; } int message() throw(const char *) { throw("I died."); return 1; } int hosed() throw(Exc) { throw(Exc(42,"Hosed")); return 1; } int unknown() throw(A*) { static A a; throw &a; return 1; } int multi(int x) throw(int, const char *, Exc) { if (x == 1) throw(37); if (x == 2) throw("Bleah!"); if (x == 3) throw(Exc(42,"No-go-diggy-die")); return 1; } }; #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif swig-3.0.2/Examples/python/exception/example.i0000664000175000017500000000024712343605122021250 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include "std_string.i" /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/python/exception/Makefile0000664000175000017500000000112112343605122021073 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/exception/runme.py0000664000175000017500000000104712343605122021142 0ustar williamwilliam# file: runme.py # Throw a lot of exceptions import example t = example.Test() try: t.unknown() except RuntimeError,e: print "incomplete type", e.args[0] try: t.simple() except RuntimeError,e: print e.args[0] try: t.message() except RuntimeError,e: print e.args[0] try: t.hosed() 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 swig-3.0.2/Examples/python/funcptr/0000775000175000017500000000000012343605122017123 5ustar williamwilliamswig-3.0.2/Examples/python/funcptr/example.c0000664000175000017500000000037012343605122020722 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/python/funcptr/example.h0000664000175000017500000000026312343605122020730 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/python/funcptr/example.i0000664000175000017500000000056012343605122020731 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); swig-3.0.2/Examples/python/funcptr/index.html0000664000175000017500000000370612343605122021126 0ustar williamwilliam SWIG:Examples:python:funcptr SWIG/Examples/python/funcptr/


Pointers to Functions

Okay, just what in the heck does SWIG do with a declaration like this?

int do_op(int a, int b, int (*op)(int, int));
Well, it creates a wrapper as usual. Of course, that does raise some questions about the third argument (the pointer to a function).

In this case, SWIG will wrap the function pointer as it does for all other pointers. However, in order to actually call this function from a script, you will need to pass some kind of C function pointer object. In C, this is easy, you just supply a function name as an argument like this:

/* Some callback function */
int add(int a, int b) {
   return a+b;
} 
...
int r = do_op(x,y,add);
To make this work with SWIG, you will need to do a little extra work. Specifically, you need to create some function pointer objects using the %constant directive like this:
%constant(int (*)(int,int)) ADD = add;
Now, in a script, you would do this:
r = do_op(x,y, ADD)

An Example

Here are some files that illustrate this with a simple example:

Notes

  • The value of a function pointer must correspond to a function written in C or C++. It is not possible to pass an arbitrary Python function object in as a substitute for a C function pointer.

  • A python function can be used as a C/C++ callback if you write some clever typemaps and are very careful about how you create your extension. This is an advanced topic not covered here.

swig-3.0.2/Examples/python/funcptr/Makefile0000664000175000017500000000106612343605122020566 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/funcptr/runme.py0000664000175000017500000000103712343605122020624 0ustar williamwilliam# file: runme.py import example a = 37 b = 42 # Now call our C function with a bunch of callbacks 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 "Here is what the C callback function objects look like in Python" print " ADD =", example.ADD print " SUB =", example.SUB print " MUL =", example.MUL swig-3.0.2/Examples/python/java/0000775000175000017500000000000012343605122016363 5ustar williamwilliamswig-3.0.2/Examples/python/java/example.i0000664000175000017500000000016712343605122020174 0ustar williamwilliam%module example %include %{ #include "Example.h" %} %include Example.h %extend Example { ~Example() {} } swig-3.0.2/Examples/python/java/Makefile0000664000175000017500000000124112343605122020021 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: Example.class Example.h $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean rm -f $(TARGET).py rm -f *.class Example.h Example.class Example.h: $(SRCDIR)Example.java gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java gcjh Example.class swig-3.0.2/Examples/python/java/Example.java0000664000175000017500000000075012343605122020623 0ustar williamwilliampublic class Example { public int mPublicInt; public Example() { mPublicInt = 0; } public Example(int IntVal) { mPublicInt = IntVal; } public int Add(int a, int b) { return (a+b); } public float Add(float a, float b) { return (a+b); } public String Add(String a, String b) { return (a+b); } public Example Add(Example a, Example b) { return new Example(a.mPublicInt + b.mPublicInt); } } swig-3.0.2/Examples/python/java/runme.py0000664000175000017500000000035712343605122020070 0ustar williamwilliamfrom example import * JvCreateJavaVM(None) 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 e3.mPublicInt print e1.Add("1","2") JvDetachCurrentThread() swig-3.0.2/Examples/python/std_map/0000775000175000017500000000000012343605122017071 5ustar williamwilliamswig-3.0.2/Examples/python/std_map/example.h0000664000175000017500000000053012343605122020673 0ustar williamwilliam/* File : example.h */ #include #include template std::map half_map(const std::map& v) { typedef typename std::map::const_iterator iter; std::map w; for (iter i = v.begin(); i != v.end(); ++i) { w[i->first] = (i->second)/2; } return w; } swig-3.0.2/Examples/python/std_map/example.i0000664000175000017500000000121612343605122020676 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include std_string.i %include std_pair.i %include std_map.i /* instantiate the required template specializations */ namespace std { /* remember to instantiate the key,value pair! */ %template(DoubleMap) map; %template() map; } /* Let's just grab the original header file here */ %include "example.h" %template(halfd) half_map; %template(halfi) half_map; %template() std::pair; %template(pymap) std::map; swig-3.0.2/Examples/python/std_map/Makefile0000664000175000017500000000121012343605122020523 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/std_map/runme.py0000664000175000017500000000207612343605122020576 0ustar williamwilliam# file: runme.py import example pmap = example.pymap() pmap["hi"] = 1 pmap["hello"] = 2 dmap = {} dmap["hello"] = 1.0 dmap["hi"] = 2.0 print dmap.items() print dmap.keys() print dmap.values() print dmap hmap = example.halfd(dmap) dmap = hmap print dmap for i in dmap.iterkeys(): print "key", i for i in dmap.itervalues(): print "val", i for k,v in dmap.iteritems(): print "item", k,v dmap = example.DoubleMap() dmap["hello"] = 1.0 dmap["hi"] = 2.0 for i in dmap.iterkeys(): print "key", i for i in dmap.itervalues(): print "val", i for k,v in dmap.iteritems(): print "item", k,v print dmap.items() print dmap.keys() print dmap.values() hmap = example.halfd(dmap) print hmap.keys() print hmap.values() dmap = {} dmap["hello"] = 2 dmap["hi"] = 4 hmap = example.halfi(dmap) print hmap print hmap.keys() print hmap.values() dmap = hmap for i in dmap.iterkeys(): print "key", i for i in dmap.itervalues(): print "val", i for i in dmap.iteritems(): print "item", i for k,v in dmap.iteritems(): print "item", k,v print dmap swig-3.0.2/Examples/python/multimap/0000775000175000017500000000000012343605122017272 5ustar williamwilliamswig-3.0.2/Examples/python/multimap/example.c0000664000175000017500000000164012343605122021072 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.2/Examples/python/multimap/example.i0000664000175000017500000000674512343605122021113 0ustar williamwilliam/* File : example.i */ %module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} %include exception.i %include typemaps.i extern int gcd(int x, int y); %typemap(in,fragment="t_output_helper") (int argc, char *argv[]) { int i; if (!PyList_Check($input)) { SWIG_exception(SWIG_ValueError, "Expecting a list"); } $1 = PyList_Size($input); if ($1 == 0) { SWIG_exception(SWIG_ValueError, "List must contain at least 1 element"); } $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++) { PyObject *s = PyList_GetItem($input,i); %#if PY_VERSION_HEX >= 0x03000000 if (!PyUnicode_Check(s)) %#else if (!PyString_Check(s)) %#endif { free($2); SWIG_exception(SWIG_ValueError, "List items must be strings"); } %#if PY_VERSION_HEX >= 0x03000000 { PyObject *utf8str = PyUnicode_AsUTF8String(s); const char *cstr = PyBytes_AsString(utf8str); $2[i] = strdup(cstr); Py_DECREF(utf8str); } %#else $2[i] = PyString_AsString(s); %#endif } $2[i] = 0; } %typemap(freearg) (int argc, char *argv[]) { %#if PY_VERSION_HEX >= 0x03000000 int i; for (i = 0; i < $1; i++) { free($2[i]); } %#endif } extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { %#if PY_VERSION_HEX >= 0x03000000 char *cstr; Py_ssize_t len; PyObject *utf8str; if (!PyUnicode_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); return NULL; } utf8str = PyUnicode_AsUTF8String($input); PyBytes_AsStringAndSize(utf8str, &cstr, &len); $1 = strndup(cstr, (size_t)len); $2 = (int)len; Py_DECREF(utf8str); %#else if (!PyString_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); return NULL; } $1 = PyString_AsString($input); $2 = PyString_Size($input); %#endif } %typemap(freearg) (char *bytes, int len) { %#if PY_VERSION_HEX >= 0x03000000 free($1); %#endif } extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a string */ /* Since str is modified, we make a copy of the Python object so that we don't violate its mutability */ %typemap(in) (char *str, int len) { %#if PY_VERSION_HEX >= 0x03000000 char *cstr; Py_ssize_t len; PyObject *utf8str = PyUnicode_AsUTF8String($input); PyBytes_AsStringAndSize(utf8str, &cstr, &len); $1 = strndup(cstr, (size_t)len); $2 = (int)len; Py_DECREF(utf8str); %#else $2 = PyString_Size($input); $1 = (char *) malloc($2+1); memmove($1,PyString_AsString($input),$2); %#endif } /* Return the mutated string as a new object. The t_output_helper function takes an object and appends it to the output object to create a tuple */ %typemap(argout) (char *str, int len) { PyObject *o; %#if PY_VERSION_HEX >= 0x03000000 o = PyUnicode_FromStringAndSize($1,$2); %#else o = PyString_FromStringAndSize($1,$2); %#endif $result = t_output_helper($result,o); free($1); } extern void capitalize(char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); } } extern void circle(double cx, double cy); swig-3.0.2/Examples/python/multimap/example.dsp0000664000175000017500000001210112343605122021430 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -python "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -python "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/python/multimap/Makefile0000664000175000017500000000106612343605122020735 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/multimap/runme.py0000664000175000017500000000055112343605122020773 0ustar williamwilliam# file: runme.py 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) # Call the gcdmain() function example.gcdmain(["gcdmain","42","105"]) # Call the count function print example.count("Hello World", "l") # Call the capitalize function print example.capitalize("hello world") swig-3.0.2/Examples/python/operator/0000775000175000017500000000000012343605122017275 5ustar williamwilliamswig-3.0.2/Examples/python/operator/example.h0000664000175000017500000000147312343605122021106 0ustar williamwilliam/* File : example.h */ #include class Complex { private: double rpart, ipart; public: Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { } Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { } Complex &operator=(const Complex &c) { rpart = c.rpart; ipart = c.ipart; return *this; } Complex operator+(const Complex &c) const { return Complex(rpart+c.rpart, ipart+c.ipart); } Complex operator-(const Complex &c) const { return Complex(rpart-c.rpart, ipart-c.ipart); } Complex operator*(const Complex &c) const { return Complex(rpart*c.rpart - ipart*c.ipart, rpart*c.ipart + c.rpart*ipart); } Complex operator-() const { return Complex(-rpart, -ipart); } double re() const { return rpart; } double im() const { return ipart; } }; swig-3.0.2/Examples/python/operator/example.i0000664000175000017500000000127112343605122021103 0ustar williamwilliam/* File : example.i */ %module example #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ %{ #include "example.h" %} /* This header file is a little tough to handle because it has overloaded operators and constructors. We're going to try and deal with that here */ /* This turns the copy constructor in a function ComplexCopy() that can be called */ %rename(ComplexCopy) Complex::Complex(Complex const &); /* Now grab the original header file */ %include "example.h" /* An output method that turns a complex into a short string */ %extend Complex { char *__str__() { static char temp[512]; sprintf(temp,"(%g,%g)", $self->re(), $self->im()); return temp; } }; swig-3.0.2/Examples/python/operator/Makefile0000664000175000017500000000116312343605122020736 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/operator/runme.py0000664000175000017500000000045712343605122021003 0ustar williamwilliam# Operator overloading example import example a = example.Complex(2,3) b = example.Complex(-5,10) print "a =",a print "b =",b c = a + b print "c =",c print "a*b =",a*b print "a-c =",a-c e = example.ComplexCopy(a-c) print "e =",e # Big expression f = ((a+b)*(c+b*e)) + (-a) print "f =",f swig-3.0.2/Examples/python/callback/0000775000175000017500000000000012343605122017176 5ustar williamwilliamswig-3.0.2/Examples/python/callback/example.h0000664000175000017500000000077612343605122021014 0ustar williamwilliam/* File : example.h */ #include class Callback { public: virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } }; swig-3.0.2/Examples/python/callback/example.i0000664000175000017500000000031212343605122020777 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_string.i" /* turn on director wrapping Callback */ %feature("director") Callback; %include "example.h" swig-3.0.2/Examples/python/callback/example.cxx0000664000175000017500000000006012343605122021351 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/python/callback/index.html0000664000175000017500000000045012343605122021172 0ustar williamwilliam SWIG:Examples:python:callback SWIG/Examples/python/extend/

Implementing C++ callbacks in Python

This example illustrates how to use directors to implement C++ callbacks in Python.


swig-3.0.2/Examples/python/callback/Makefile0000664000175000017500000000125212343605122020636 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/callback/runme.py0000664000175000017500000000230212343605122020673 0ustar williamwilliam# file: runme.py # This file illustrates the cross language polymorphism using directors. import example class PyCallback(example.Callback): def __init__(self): example.Callback.__init__(self) def run(self): print "PyCallback.run()" # Create an Caller instance caller = example.Caller() # Add a simple C++ callback (caller owns the callback, so # we disown it first by clearing the .thisown flag). print "Adding and calling a normal C++ callback" print "----------------------------------------" callback = example.Callback() callback.thisown = 0 caller.setCallback(callback) caller.call() caller.delCallback(); print print "Adding and calling a Python callback" print "------------------------------------" # Add a Python callback (caller owns the callback, so we # disown it first by calling __disown__). caller.setCallback(PyCallback().__disown__()) caller.call() caller.delCallback() print print "Adding and calling another Python callback" print "------------------------------------------" # Let's do the same but use the weak reference this time. callback = PyCallback().__disown__() caller.setCallback(callback) caller.call() caller.delCallback() # All done. print print "python exit" swig-3.0.2/Examples/python/import/0000775000175000017500000000000012343605122016754 5ustar williamwilliamswig-3.0.2/Examples/python/import/spam.dsp0000664000175000017500000001162212343605122020426 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=spam - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "spam.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "spam - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_spam.pyd" /pdbtype:sept !ELSEIF "$(CFG)" == "spam - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_spam.pyd" !ENDIF # Begin Target # Name "spam - Win32 Debug" # Name "spam - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\spam_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\spam.h # End Source File # End Group # Begin Source File SOURCE=.\spam.i !IF "$(CFG)" == "spam - Win32 Debug" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "spam - Win32 Release" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/python/import/spam.h0000664000175000017500000000061412343605122020066 0ustar williamwilliam#include "bar.h" class Spam : public Bar { public: Spam() { } ~Spam() { } virtual void A() { printf("I'm Spam::A\n"); } void B() { printf("I'm Spam::B\n"); } virtual Base *toBase() { return static_cast(this); } virtual Bar *toBar() { return static_cast(this); } static Spam *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/python/import/README0000664000175000017500000000242112343605122017633 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. Use 'python runme.py' to run a test. Overview: --------- The example defines 4 different extension modules--each wrapping a separate C++ class. base.i - Base class foo.i - Foo class derived from Base bar.i - Bar class derived from Base spam.i - Spam class derived from Bar Each module uses %import to refer to another module. For example, the 'foo.i' module uses '%import base.i' to get definitions for its base class. If everything is okay, all of the modules will load properly and type checking will work correctly. Caveat: Some compilers, for example gcc-3.2.x, generate broken vtables with the inline methods in this test. This is not a SWIG problem and can usually be solved with non-inlined destructors compiled into separate shared objects/DLLs. Unix: ----- - Run make - Run the test as described above Windows: -------- - Use the Visual C++ 6 workspace file (example.dsw). Build the runtime project DLL first followed by the other 4 DLLs as they all have a dependency on the runtime DLL. The Batch build option in the Build menu is usually the easiest way to do this. Only use the Release builds not the Debug builds. - Run the test as described above swig-3.0.2/Examples/python/import/spam.i0000664000175000017500000000011012343605122020056 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-3.0.2/Examples/python/import/bar.i0000664000175000017500000000010612343605122017667 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-3.0.2/Examples/python/import/base.i0000664000175000017500000000006612343605122020042 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h swig-3.0.2/Examples/python/import/foo.dsp0000664000175000017500000001157012343605122020253 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=foo - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "foo.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "foo - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_foo.pyd" /pdbtype:sept !ELSEIF "$(CFG)" == "foo - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_foo.pyd" !ENDIF # Begin Target # Name "foo - Win32 Debug" # Name "foo - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\foo_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\foo.h # End Source File # End Group # Begin Source File SOURCE=.\foo.i !IF "$(CFG)" == "foo - Win32 Debug" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "foo - Win32 Release" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/python/import/base.dsp0000664000175000017500000001162212343605122020400 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=base - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "base.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "base - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_base.pyd" /pdbtype:sept !ELSEIF "$(CFG)" == "base - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_base.pyd" !ENDIF # Begin Target # Name "base - Win32 Debug" # Name "base - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\base_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\base.h # End Source File # End Group # Begin Source File SOURCE=.\base.i !IF "$(CFG)" == "base - Win32 Debug" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "base - Win32 Release" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/python/import/foo.i0000664000175000017500000000010512343605122017705 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-3.0.2/Examples/python/import/foo.h0000664000175000017500000000050512343605122017710 0ustar williamwilliam#include "base.h" class Foo : public Base { public: Foo() { } ~Foo() { } virtual void A() { printf("I'm Foo::A\n"); } void B() { printf("I'm Foo::B\n"); } virtual Base *toBase() { return static_cast(this); } static Foo *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/python/import/base.h0000664000175000017500000000045112343605122020037 0ustar williamwilliam#include class Base { public: Base() { }; virtual ~Base() { }; virtual void A() { printf("I'm Base::A\n"); } void B() { printf("I'm Base::B\n"); } virtual Base *toBase() { return static_cast(this); } }; swig-3.0.2/Examples/python/import/Makefile0000664000175000017500000000153612343605122020421 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean rm -f foo.py bar.py spam.py base.py swig-3.0.2/Examples/python/import/example.dsw0000664000175000017500000000206412343605122021130 0ustar williamwilliamMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "bar"=.\bar.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "base"=.\base.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "foo"=.\foo.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "spam"=.\spam.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### swig-3.0.2/Examples/python/import/bar.h0000664000175000017500000000050612343605122017672 0ustar williamwilliam#include "base.h" class Bar : public Base { public: Bar() { } ~Bar() { } virtual void A() { printf("I'm Bar::A\n"); } void B() { printf("I'm Bar::B\n"); } virtual Base *toBase() { return static_cast(this); } static Bar *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/python/import/runme.py0000664000175000017500000000330312343605122020453 0ustar williamwilliam# file: runme.py # Test various properties of classes defined in separate modules print "Testing the %import directive" import base import foo import bar import spam # Create some objects print "Creating some objects" a = base.Base() b = foo.Foo() c = bar.Bar() d = spam.Spam() # Try calling some methods print "Testing some methods" print "", print "Should see 'Base::A' ---> ", a.A() print "Should see 'Base::B' ---> ", a.B() print "Should see 'Foo::A' ---> ", b.A() print "Should see 'Foo::B' ---> ", b.B() print "Should see 'Bar::A' ---> ", c.A() print "Should see 'Bar::B' ---> ", c.B() print "Should see 'Spam::A' ---> ", d.A() print "Should see 'Spam::B' ---> ", d.B() # Try some casts print "\nTesting some casts\n" print "", x = a.toBase() print "Should see 'Base::A' ---> ", x.A() print "Should see 'Base::B' ---> ", x.B() x = b.toBase() print "Should see 'Foo::A' ---> ", x.A() print "Should see 'Base::B' ---> ", x.B() x = c.toBase() print "Should see 'Bar::A' ---> ", x.A() print "Should see 'Base::B' ---> ", x.B() x = d.toBase() print "Should see 'Spam::A' ---> ", x.A() print "Should see 'Base::B' ---> ", x.B() x = d.toBar() print "Should see 'Bar::B' ---> ", x.B() print "\nTesting some dynamic casts\n" x = d.toBase() print " Spam -> Base -> Foo : ", y = foo.Foo_fromBase(x) if y: print "bad swig" else: print "good swig" print " Spam -> Base -> Bar : ", y = bar.Bar_fromBase(x) if y: print "good swig" else: print "bad swig" print " Spam -> Base -> Spam : ", y = spam.Spam_fromBase(x) if y: print "good swig" else: print "bad swig" print " Foo -> Spam : ", y = spam.Spam_fromBase(b) if y: print "bad swig" else: print "good swig" swig-3.0.2/Examples/python/import/bar.dsp0000664000175000017500000001157012343605122020234 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=bar - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "bar.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "bar - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_bar.pyd" /pdbtype:sept !ELSEIF "$(CFG)" == "bar - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_bar.pyd" !ENDIF # Begin Target # Name "bar - Win32 Debug" # Name "bar - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\bar_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\bar.h # End Source File # End Group # Begin Source File SOURCE=.\bar.i !IF "$(CFG)" == "bar - Win32 Debug" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "bar - Win32 Release" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on ..\..\..\swig.exe -c++ -python "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/python/variables/0000775000175000017500000000000012343605122017412 5ustar williamwilliamswig-3.0.2/Examples/python/variables/example.c0000664000175000017500000000456012343605122021216 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/python/variables/example.h0000664000175000017500000000007512343605122021220 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/python/variables/example.i0000664000175000017500000000203012343605122021212 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} #pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/python/variables/index.html0000664000175000017500000000756212343605122021421 0ustar williamwilliam SWIG:Examples:python:variables SWIG/Examples/python/variables/

Wrapping C Global Variables

When a C global variable appears in an interface file, SWIG tries to wrap it using a technique known as "variable linking." The idea is pretty simple---we try to create a Python variable that magically retrieves or updates the value of the underlying C variable when it is accessed. Click here to see a SWIG interface with some variable declarations in it.

Manipulating Variables from Python

Before going any further, it is important to understand some important differences between C and Python variables. In C, a variable is simply a name that refers to a specific location in memory. For example, when you declare a global variable 'double a' you know that somewhere in memory, 8 bytes have been set aside to hold a double and that a is bound to this location for the life of the program. In Python, variable creation is nothing more than a naming operation. For example, when you say 'a = 3', 'a' becomes a name that refers to some object '3'. Later on, if you say 'a = 7.5, the name 'a' is bound to an entirely different object containing the value '7.5' (the contents of the original object are not changed). The end result of this is that a variable in Python can refer to a virtually unlimited number of different objects (memory locations) over the lifetime of a program.

Because of Python's somewhat unusual variable assignment semantics, it is not possible to directly link a C global variable into an equivalent Python variable. Instead, all C global variables are accessed as attributes of a special object called 'cvar'. For example, if you had a global variable

double foo;
it will be accessed in the Python module as cvar.foo. Click here to see a script that updates and prints out the values of the variables using this technique.

Key points

  • When a global variable has the type "char *", SWIG manages it as a character string. However, whenever the value of such a variable is set from Python, the old value is destroyed using free() or delete (the choice of which depends on whether or not SWIG was run with the -c++ option).
  • signed char and unsigned char are handled as small 8-bit integers.
  • String array variables such as 'char name[256]' are managed as Python strings, but when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
  • When structures and classes are used as global variables, they are mapped into pointers. Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global.

Creating read-only variables

The %immutable and %mutable directives can be used to specify a collection of read-only variables. For example:
%immutable;
int    status;
double blah;
...
%mutable;
The %immutable directive remains in effect until it is explicitly disabled using the %mutable directive.

Comments

  • Management of global variables is one of the most problematic aspects of C/C++ wrapping because the scripting interface and resulting memory management is much trickier than simply creating a wrapper function.

  • Because of the potential for a namespace conflict, you should not use the from module import * statement for a SWIG module with global variables. Doing so will cause a collision on the 'cvar' object should more than one module be loaded in this manner.

swig-3.0.2/Examples/python/variables/Makefile0000664000175000017500000000106612343605122021055 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean swig-3.0.2/Examples/python/variables/runme.py0000664000175000017500000000402712343605122021115 0ustar williamwilliam# file: runme.py 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" # Now print out the values of the variables print "Variables (values printed from Python)" print "ivar =", example.cvar.ivar print "svar =", example.cvar.svar print "lvar =", example.cvar.lvar print "uivar =", example.cvar.uivar print "usvar =", example.cvar.usvar print "ulvar =", example.cvar.ulvar print "scvar =", example.cvar.scvar print "ucvar =", example.cvar.ucvar print "fvar =", example.cvar.fvar print "dvar =", example.cvar.dvar print "cvar =", example.cvar.cvar print "strvar =", example.cvar.strvar print "cstrvar =", example.cvar.cstrvar print "iptrvar =", example.cvar.iptrvar print "name =", example.cvar.name print "ptptr =", example.cvar.ptptr, example.Point_print(example.cvar.ptptr) print "pt =", example.cvar.pt, example.Point_print(example.cvar.pt) print "\nVariables (values printed from C)" example.print_vars() print "\nNow I'm going to try and modify some read only variables"; 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'"; try: example.cvar.status = 0 print "Hey, what's going on?!?! This shouldn't work" except: print "Good." print "\nI'm going to try and update a structure variable.\n" 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) swig-3.0.2/Examples/octave/0000775000175000017500000000000012343605122015402 5ustar williamwilliamswig-3.0.2/Examples/octave/template/0000775000175000017500000000000012343605122017215 5ustar williamwilliamswig-3.0.2/Examples/octave/template/example.h0000664000175000017500000000077612343605122021033 0ustar williamwilliam/* File : example.h */ // Some template definitions template T max(T a, T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } #ifdef SWIG %extend { T getitem(int index) { return $self->get(index); } void setitem(int index, T val) { $self->set(index,val); } } #endif }; swig-3.0.2/Examples/octave/template/example.i0000664000175000017500000000051712343605122021025 0ustar williamwilliam/* File : example.i */ %module swigexample %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; swig-3.0.2/Examples/octave/template/Makefile0000664000175000017500000000005212343605122020652 0ustar williamwilliamCXXSRCS = include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/template/runme.m0000664000175000017500000000066312343605122020526 0ustar williamwilliam# file: runme.m swigexample # Call some templated functions swigexample.maxint(3,7) swigexample.maxdouble(3.14,2.18) # Create some class iv = swigexample.vecint(100) dv = swigexample.vecdouble(1000) for i=0:99, iv.setitem(i,2*i); end for i=0:999, dv.setitem(i, 1.0/(i+1)); end; sum = 0; for i=0:99 sum = sum + iv.getitem(i); end sum sum = 0.0; for i=0:999, sum = sum + dv.getitem(i); end sum clear iv clear dv swig-3.0.2/Examples/octave/contract/0000775000175000017500000000000012343605122017217 5ustar williamwilliamswig-3.0.2/Examples/octave/contract/example.c0000664000175000017500000000047012343605122021017 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int fact(int n) { if (n <= 0) return 1; return n*fact(n-1); } swig-3.0.2/Examples/octave/contract/example.i0000664000175000017500000000040612343605122021024 0ustar williamwilliam/* File : example.i */ %module swigexample %contract gcd(int x, int y) { require: x >= 0; y >= 0; } %contract fact(int n) { require: n >= 0; ensure: fact >= 1; } %inline %{ extern int gcd(int x, int y); extern int fact(int n); extern double Foo; %} swig-3.0.2/Examples/octave/contract/Makefile0000664000175000017500000000006112343605122020654 0ustar williamwilliamSRCS = example.c include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/contract/runme.m0000664000175000017500000000060312343605122020522 0ustar williamwilliam# file: runme.m swigexample # Call our gcd() function x = 42; y = 105; g = swigexample.gcd(x,y); printf("The gcd of %d and %d is %d\n",x,y,g); # Manipulate the Foo global variable # Output its current value printf("Foo = %f\n", swigexample.cvar.Foo); # Change its value swigexample.cvar.Foo = 3.1415926; # See if the change took effect printf("Foo = %f\n", swigexample.cvar.Foo); swig-3.0.2/Examples/octave/class/0000775000175000017500000000000012343605122016507 5ustar williamwilliamswig-3.0.2/Examples/octave/class/example.h0000664000175000017500000000107612343605122020317 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/octave/class/example.i0000664000175000017500000000022112343605122020307 0ustar williamwilliam/* File : example.i */ %module swigexample %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/octave/class/example.cxx0000664000175000017500000000065012343605122020667 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/octave/class/Makefile0000664000175000017500000000006612343605122020151 0ustar williamwilliamCXXSRCS = example.cxx include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/class/runme.m0000664000175000017500000000177112343605122020021 0ustar williamwilliam# file: runme.m # This file illustrates the proxy class C++ interface generated # by SWIG. swigexample # ----- Object creation ----- printf("Creating some objects:\n"); c = swigexample.Circle(10) s = swigexample.Square(10) # ----- Access a static member ----- printf("\nA total of %i shapes were created\n", swigexample.Shape.nshapes); # ----- Member data access ----- # Set the location of the object c.x = 20 c.y = 30 s.x = -10 s.y = 5 printf("\nHere is their current position:\n"); printf(" Circle = (%f, %f)\n",c.x,c.y); printf(" Square = (%f, %f)\n",s.x,s.y); # ----- Call some methods ----- printf("\nHere are some properties of the shapes:\n"); function print_shape(o) o printf(" area = %f\n", o.area()); printf(" perimeter = %f\n", o.perimeter()); end; print_shape(c); print_shape(s); printf("\nGuess I'll clean up now\n"); # Note: this invokes the virtual destructor clear c clear s printf("%i shapes remain\n", swigexample.Shape.nshapes); printf("Goodbye\n"); swig-3.0.2/Examples/octave/pointer/0000775000175000017500000000000012343605122017062 5ustar williamwilliamswig-3.0.2/Examples/octave/pointer/example.c0000664000175000017500000000036112343605122020661 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void sub(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/octave/pointer/example.i0000664000175000017500000000117612343605122020674 0ustar williamwilliam/* File : example.i */ %module swigexample %{ extern void add(int *, int *, int *); extern void sub(int *, int *, int *); extern int divide(int, int, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); swig-3.0.2/Examples/octave/pointer/Makefile0000664000175000017500000000006112343605122020517 0ustar williamwilliamSRCS = example.c include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/pointer/runme.m0000664000175000017500000000166212343605122020373 0ustar williamwilliam# file: runme.m swigexample; # First create some objects using the pointer library. printf("Testing the pointer library\n"); a = swigexample.new_intp(); b = swigexample.new_intp(); c = swigexample.new_intp(); swigexample.intp_assign(a,37); swigexample.intp_assign(b,42); a,b,c # Call the add() function with some pointers swigexample.add(a,b,c); # Now get the result r = swigexample.intp_value(c); printf(" 37 + 42 = %i\n",r); # Clean up the pointers swigexample.delete_intp(a); swigexample.delete_intp(b); swigexample.delete_intp(c); # Now try the typemap library # This should be much easier. Now how it is no longer # necessary to manufacture pointers. printf("Trying the typemap library\n"); r = swigexample.sub(37,42); printf(" 37 - 42 = %i\n",r); # Now try the version with multiple return values printf("Testing multiple return values\n"); [q,r] = swigexample.divide(42,37); printf(" 42/37 = %d remainder %d\n",q,r); swig-3.0.2/Examples/octave/enum/0000775000175000017500000000000012343605122016346 5ustar williamwilliamswig-3.0.2/Examples/octave/enum/example.h0000664000175000017500000000031412343605122020150 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE, WARP, LUDICROUS }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/octave/enum/example.i0000664000175000017500000000022212343605122020147 0ustar williamwilliam/* File : example.i */ %module swigexample %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/octave/enum/example.cxx0000664000175000017500000000150712343605122020530 0ustar williamwilliam/* File : example.c */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/octave/enum/Makefile0000664000175000017500000000006612343605122020010 0ustar williamwilliamCXXSRCS = example.cxx include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/enum/runme.m0000664000175000017500000000167512343605122017663 0ustar williamwilliam# file: runme.m swigexample # ----- Object creation ----- # Print out the value of some enums printf("*** color ***\n"); printf(" RED = %i\n", swigexample.RED); printf(" BLUE = %i\n", swigexample.BLUE); printf(" GREEN = %i\n", swigexample.GREEN); printf("\n*** Foo::speed ***\n"); printf(" Foo_IMPULSE = %i\n", swigexample.Foo_IMPULSE); printf(" Foo_WARP = %i\n", swigexample.Foo_WARP); printf(" Foo_LUDICROUS = %i\n", swigexample.Foo_LUDICROUS); printf("\nTesting use of enums with functions\n"); swigexample.enum_test(swigexample.RED, swigexample.Foo_IMPULSE); swigexample.enum_test(swigexample.BLUE, swigexample.Foo_WARP); swigexample.enum_test(swigexample.GREEN, swigexample.Foo_LUDICROUS); swigexample.enum_test(1234,5678) printf("\nTesting use of enum with class method\n"); f = swigexample.Foo(); f.enum_test(swigexample.Foo_IMPULSE); f.enum_test(swigexample.Foo_WARP); f.enum_test(swigexample.Foo_LUDICROUS); swig-3.0.2/Examples/octave/module_load/0000775000175000017500000000000012343605122017666 5ustar williamwilliamswig-3.0.2/Examples/octave/module_load/example.c0000664000175000017500000000013512343605122021464 0ustar williamwilliam/* File : example.c */ #include "example.h" int ivar = 47; int ifunc() { return ivar; } swig-3.0.2/Examples/octave/module_load/example.h0000664000175000017500000000006612343605122021474 0ustar williamwilliam/* File: example.h */ extern int ivar; int ifunc(); swig-3.0.2/Examples/octave/module_load/example.i0000664000175000017500000000017112343605122021472 0ustar williamwilliam/* File : example.i */ /* module name given on cmdline */ %{ #include "example.h" %} extern "C" int ivar; int ifunc(); swig-3.0.2/Examples/octave/module_load/Makefile0000664000175000017500000000025612343605122021331 0ustar williamwilliamSRCS = example.c TARGET = swigexample SWIGOPT = -module swigexample TARGET2 = swigexample2 SWIGOPT2 = -module swigexample2 -globals . include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/module_load/runme.m0000664000175000017500000000317612343605122021201 0ustar williamwilliam# file: runme_args.m # load module clear all; swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); clear all swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); clear all # load module in a function globally before base context clear all; function testme swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); endfunction testme testme swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); clear all function testme swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); endfunction testme testme swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); clear all # load module in a function globally after base context clear all; swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); function testme swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); endfunction testme testme clear all swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); function testme swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); endfunction testme testme clear all # octave 3.0.5 randomly crashes on the remaining tests, so skip them api_version = sscanf(octave_config_info("api_version"), "api-v%i"); if api_version < 37 exit endif # load module with no cvar clear all; swigexample2; assert(swigexample2.ivar == ifunc); assert(exist("swigexample2","var")); assert(!isglobal("cvar")) clear all swigexample2; assert(swigexample2.ivar == ifunc); assert(exist("swigexample2","var")); assert(!isglobal("cvar")) clear all swig-3.0.2/Examples/octave/simple/0000775000175000017500000000000012343605122016673 5ustar williamwilliamswig-3.0.2/Examples/octave/simple/example.c0000664000175000017500000000036512343605122020476 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/octave/simple/example.i0000664000175000017500000000015612343605122020502 0ustar williamwilliam/* File : example.i */ %module swigexample %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/octave/simple/Makefile0000664000175000017500000000006112343605122020330 0ustar williamwilliamSRCS = example.c include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/simple/runme.m0000664000175000017500000000055012343605122020177 0ustar williamwilliam# file: runme.m swigexample # Call our gcd() function x = 42 y = 105 g = swigexample.gcd(x,y) printf("The gcd of %d and %d is %d\n",x,y,g); # Manipulate the Foo global variable # Output its current value swigexample.cvar.Foo # Change its value swigexample.cvar.Foo = 3.1415926 # See if the change took effect printf("Foo = %f\n", swigexample.cvar.Foo); swig-3.0.2/Examples/octave/constants/0000775000175000017500000000000012343605122017416 5ustar williamwilliamswig-3.0.2/Examples/octave/constants/example.i0000664000175000017500000000113712343605122021225 0ustar williamwilliam/* File : example.i */ %module swigexample /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/octave/constants/Makefile0000664000175000017500000000005212343605122021053 0ustar williamwilliamCXXSRCS = include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/constants/runme.m0000664000175000017500000000165512343605122020731 0ustar williamwilliam# file: runme.m swigexample printf("ICONST = %i (should be 42)\n", swigexample.ICONST); printf("FCONST = %f (should be 2.1828)\n", swigexample.FCONST); printf("CCONST = %s (should be 'x')\n", swigexample.CCONST); printf("CCONST2 = %s (this should be on a new line)\n", swigexample.CCONST2); printf("SCONST = %s (should be 'Hello World')\n", swigexample.SCONST); printf("SCONST2 = %s (should be '\"Hello World\"')\n", swigexample.SCONST2); printf("EXPR = %f (should be 48.5484)\n", swigexample.EXPR); printf("iconst = %i (should be 37)\n", swigexample.iconst); printf("fconst = %f (should be 3.14)\n", swigexample.fconst); try printf("EXTERN = %s (Arg! This shouldn't printf(anything)\n", swigexample.EXTERN); catch printf("EXTERN isn't defined (good)\n"); end_try_catch try printf("FOO = %i (Arg! This shouldn't printf(anything)\n", swigexample.FOO); catch printf("FOO isn't defined (good)\n"); end_try_catch swig-3.0.2/Examples/octave/example.mk0000664000175000017500000000212312343605122017364 0ustar williamwilliam# Note: as a convention an example must be in a child directory of this. # These paths are relative to such an example directory TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = swigexample INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run build: ifneq (,$(SRCS)) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave else $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp endif ifneq (,$(TARGET2)$(SWIGOPT2)) ifneq (,$(SRCS)) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave else $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave_cpp endif endif clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean swig-3.0.2/Examples/octave/extend/0000775000175000017500000000000012343605122016671 5ustar williamwilliamswig-3.0.2/Examples/octave/extend/example.h0000664000175000017500000000260312343605122020476 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *get_item(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; swig-3.0.2/Examples/octave/extend/example.i0000664000175000017500000000040612343605122020476 0ustar williamwilliam/* File : example.i */ %module(directors="1") swigexample %{ #include "example.h" %} %include "std_vector.i" %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; %include "example.h" swig-3.0.2/Examples/octave/extend/example.cxx0000664000175000017500000000005712343605122021052 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/octave/extend/Makefile0000664000175000017500000000006612343605122020333 0ustar williamwilliamCXXSRCS = example.cxx include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/extend/runme.m0000664000175000017500000000570412343605122020203 0ustar williamwilliam# file: runme.m # This file illustrates the cross language polymorphism using directors. swigexample # CEO class, which overrides Employee::getPosition(). CEO=@(name) subclass(swigexample.Manager(name),'getPosition',@(self) "CEO"); # Create an instance of our employee extension class, CEO. The calls to # getName() and getPosition() are standard, the call to getTitle() uses # the director wrappers to call CEO.getPosition. e = CEO("Alice") e = CEO("Alice"); printf("%s is a %s\n",e.getName(),e.getPosition()); printf("Just call her \"%s\"\n",e.getTitle()); printf("----------------------\n"); # Create a new EmployeeList instance. This class does not have a C++ # director wrapper, but can be used freely with other classes that do. list = swigexample.EmployeeList(); # EmployeeList owns its items, so we must surrender ownership of objects # we add. This involves first calling the __disown__ method to tell the # C++ director to start reference counting. We reassign the resulting # weakref.proxy to e so that no hard references remain. This can also be # done when the object is constructed, as in: e = # CEO("Alice").__disown() e = e.__disown(); list.addEmployee(e); printf("----------------------\n"); # Now we access the first four items in list (three are C++ objects that # EmployeeList's constructor adds, the last is our CEO). The virtual # methods of all these instances are treated the same. For items 0, 1, and # 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls # getPosition which resolves in Octave. The call to getPosition is # slightly different, however, from the e.getPosition() call above, since # now the object reference has been "laundered" by passing through # EmployeeList as an Employee*. Previously, Octave resolved the call # immediately in CEO, but now Octave thinks the object is an instance of # class Employee (actually EmployeePtr). So the call passes through the # Employee proxy class and on to the C wrappers and C++ director, # eventually ending up back at the CEO implementation of getPosition(). # The call to getTitle() for item 3 runs the C++ Employee::getTitle() # method, which in turn calls getPosition(). This virtual method call # passes down through the C++ director class to the Octave implementation # in CEO. All this routing takes place transparently. printf("(position, title) for items 0-3:\n"); for i=0:3, printf(" %s, \"%s\"\n",list.get_item(i).getPosition(), list.get_item(i).getTitle()); endfor printf("----------------------\n"); # Time to delete the EmployeeList, which will delete all the Employee* # items it contains. The last item is our CEO, which gets destroyed as its # reference count goes to zero. The Octave destructor runs, and is still # able to call self.getName() since the underlying C++ object still # exists. After this destructor runs the remaining C++ destructors run as # usual to destroy the object. clear list; printf("----------------------\n"); # All done. printf("octave exit\n"); swig-3.0.2/Examples/octave/reference/0000775000175000017500000000000012343605122017340 5ustar williamwilliamswig-3.0.2/Examples/octave/reference/example.h0000664000175000017500000000063712343605122021152 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; friend Vector operator+(const Vector &a, const Vector &b); char *print(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/octave/reference/example.i0000664000175000017500000000134212343605122021145 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module swigexample %{ #include "example.h" %} %rename(cprint) print; class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.2/Examples/octave/reference/example.cxx0000664000175000017500000000161312343605122021520 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/octave/reference/Makefile0000664000175000017500000000006612343605122021002 0ustar williamwilliamCXXSRCS = example.cxx include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/reference/runme.m0000664000175000017500000000237312343605122020651 0ustar williamwilliam# file: runme.m # This file illustrates the manipulation of C++ references in Octave swigexample # ----- Object creation ----- printf("Creating some objects:\n"); a = swigexample.Vector(3,4,5) b = swigexample.Vector(10,11,12) printf(" Created %s\n",a.cprint()); printf(" Created %s\n",b.cprint()); # ----- Call an overloaded operator ----- # This calls the wrapper we placed around # # operator+(const Vector &a, const Vector &) # # It returns a new allocated object. printf("Adding a+b\n"); c = swigexample.addv(a,b); printf(" a+b = %s\n", c.cprint()); clear c # ----- Create a vector array ----- # Note: Using the high-level interface here printf("Creating an array of vectors\n"); va = swigexample.VectorArray(10) # ----- 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(2,swigexample.addv(a,b)) # Get some values from the array printf("Getting some array values\n"); for i=0:4, printf(" va(%d) = %s\n",i,va.get(i).cprint()); end; # Watch under resource meter to check on this printf("Making sure we don't leak memory.\n"); for i=0:1000000-1, c = va.get(mod(i,10)); end # ----- Clean up ----- printf("Cleaning up\n"); clear va clear a clear b swig-3.0.2/Examples/octave/functor/0000775000175000017500000000000012343605122017062 5ustar williamwilliamswig-3.0.2/Examples/octave/functor/example.i0000664000175000017500000000111312343605122020663 0ustar williamwilliam/* File : example.i */ %module swigexample %inline %{ // From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514 template class Sum { T res; public: Sum(T i = 0) : res(i) { } void operator() (T x) { res += x; } T result() const { return res; } }; %} // Rename the application operator to __call__ for python. // Note: this is normally automatic, but if you had to do it yourself // you would use this directive: // // %rename(__call__) *::operator(); // Instantiate a few versions %template(intSum) Sum; %template(doubleSum) Sum; swig-3.0.2/Examples/octave/functor/Makefile0000664000175000017500000000005212343605122020517 0ustar williamwilliamCXXSRCS = include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/functor/runme.m0000664000175000017500000000047612343605122020375 0ustar williamwilliam# Operator overloading example swigexample a = swigexample.intSum(0); b = swigexample.doubleSum(100.0); # Use the objects. They should be callable just like a normal # python function. for i=0:100-1, a(i); # Note: function call b(sqrt(i)); # Note: function call endfor a.result() b.result() swig-3.0.2/Examples/octave/check.list0000664000175000017500000000024412343605122017354 0ustar williamwilliam# see top-level Makefile.in callback class constants contract enum extend funcptr funcptr2 functor operator module_load pointer reference simple template variables swig-3.0.2/Examples/octave/funcptr2/0000775000175000017500000000000012343605122017145 5ustar williamwilliamswig-3.0.2/Examples/octave/funcptr2/example.c0000664000175000017500000000037012343605122020744 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/octave/funcptr2/example.h0000664000175000017500000000026212343605122020751 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/octave/funcptr2/example.i0000664000175000017500000000054212343605122020753 0ustar williamwilliam/* File : example.i */ %module swigexample %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %callback("%(upper)s"); int add(int, int); int sub(int, int); int mul(int, int); %nocallback; extern int (*funcvar)(int,int); swig-3.0.2/Examples/octave/funcptr2/Makefile0000664000175000017500000000006112343605122020602 0ustar williamwilliamSRCS = example.c include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/funcptr2/runme.m0000664000175000017500000000127712343605122020460 0ustar williamwilliam# file: runme.m swigexample a = 37 b = 42 # Now call our C function with a bunch of callbacks printf("Trying some C callback functions\n"); printf(" a = %i\n", a); printf(" b = %i\n", b); printf(" ADD(a,b) = %i\n", swigexample.do_op(a,b,swigexample.ADD)); printf(" SUB(a,b) = %i\n", swigexample.do_op(a,b,swigexample.SUB)); printf(" MUL(a,b) = %i\n", swigexample.do_op(a,b,swigexample.MUL)); printf("Here is what the C callback function objects look like in Octave\n"); swigexample.ADD swigexample.SUB swigexample.MUL printf("Call the functions directly...\n"); printf(" add(a,b) = %i\n", swigexample.add(a,b)); printf(" sub(a,b) = %i\n", swigexample.sub(a,b)); swig-3.0.2/Examples/octave/funcptr/0000775000175000017500000000000012343605122017063 5ustar williamwilliamswig-3.0.2/Examples/octave/funcptr/example.c0000664000175000017500000000037012343605122020662 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/octave/funcptr/example.h0000664000175000017500000000026212343605122020667 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/octave/funcptr/example.i0000664000175000017500000000056312343605122020674 0ustar williamwilliam/* File : example.i */ %module swigexample %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); swig-3.0.2/Examples/octave/funcptr/Makefile0000664000175000017500000000006112343605122020520 0ustar williamwilliamSRCS = example.c include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/funcptr/runme.m0000664000175000017500000000105012343605122020363 0ustar williamwilliam# file: runme.m swigexample a = 37 b = 42 # Now call our C function with a bunch of callbacks printf("Trying some C callback functions\n"); printf(" a = %i\n", a); printf(" b = %i\n", b); printf(" ADD(a,b) = %i\n", swigexample.do_op(a,b,swigexample.ADD)); printf(" SUB(a,b) = %i\n", swigexample.do_op(a,b,swigexample.SUB)); printf(" MUL(a,b) = %i\n", swigexample.do_op(a,b,swigexample.MUL)); printf("Here is what the C callback function objects look like in Octave\n"); swigexample.ADD swigexample.SUB swigexample.MUL swig-3.0.2/Examples/octave/operator/0000775000175000017500000000000012343605122017235 5ustar williamwilliamswig-3.0.2/Examples/octave/operator/example.h0000664000175000017500000000171612343605122021046 0ustar williamwilliam/* File : example.h */ #include class ComplexVal { private: double rpart, ipart; public: ComplexVal(double r = 0, double i = 0) : rpart(r), ipart(i) { } ComplexVal(const ComplexVal &c) : rpart(c.rpart), ipart(c.ipart) { } ComplexVal &operator=(const ComplexVal &c) { rpart = c.rpart; ipart = c.ipart; return *this; } ComplexVal operator+(const ComplexVal &c) const { return ComplexVal(rpart+c.rpart, ipart+c.ipart); } ComplexVal operator-(const ComplexVal &c) const { return ComplexVal(rpart-c.rpart, ipart-c.ipart); } ComplexVal operator*(const ComplexVal &c) const { return ComplexVal(rpart*c.rpart - ipart*c.ipart, rpart*c.ipart + c.rpart*ipart); } ComplexVal operator-() const { return ComplexVal(-rpart, -ipart); } double re() const { return rpart; } double im() const { return ipart; } }; ComplexVal operator*(const double &s, const ComplexVal &c) { return ComplexVal(s*c.re(), s*c.im()); } swig-3.0.2/Examples/octave/operator/example.i0000664000175000017500000000113412343605122021041 0ustar williamwilliam/* File : example.i */ %module swigexample #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ %{ #include "example.h" %} /* Rename friend operator */ %rename(op_scalar_mul_ComplexVal) operator*(const double&, const ComplexVal&); /* Now grab the original header file */ %include "example.h" /* An output method that turns a complex into a short string */ %extend ComplexVal { char *__str__() { static char temp[512]; sprintf(temp,"(%g,%g)", $self->re(), $self->im()); return temp; } ComplexVal __paren__(int j) { return ComplexVal($self->re()*j,$self->im()*j); } }; swig-3.0.2/Examples/octave/operator/Makefile0000664000175000017500000000005212343605122020672 0ustar williamwilliamCXXSRCS = include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/operator/runme.m0000664000175000017500000000101412343605122020535 0ustar williamwilliam# Operator overloading example swigexample a = swigexample.ComplexVal(2,3); b = swigexample.ComplexVal(-5,10); printf("a = %s\n",disp(a)); printf("b = %s\n",disp(b)); c = a + b; printf("c = %s\n",disp(c)); printf("a*b = %s\n",disp(a*b)); printf("a-c = %s\n",disp(a-c)); e = swigexample.ComplexVal(a-c); printf("e = %s\n",disp(e)); # Big expression f = ((a+b)*(c+b*e)) + (-a); printf("f = %s\n",disp(f)); # paren overloading printf("a(3)= %s\n",disp(a(3))); # friend operator printf("2*a = %s\n",disp(2*a)); swig-3.0.2/Examples/octave/callback/0000775000175000017500000000000012343605122017136 5ustar williamwilliamswig-3.0.2/Examples/octave/callback/example.h0000664000175000017500000000101712343605122020741 0ustar williamwilliam/* File : example.h */ #include #include class Callback { public: virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } }; swig-3.0.2/Examples/octave/callback/example.i0000664000175000017500000000031512343605122020742 0ustar williamwilliam/* File : example.i */ %module(directors="1") swigexample %{ #include "example.h" %} %include "std_string.i" /* turn on director wrapping Callback */ %feature("director") Callback; %include "example.h" swig-3.0.2/Examples/octave/callback/example.cxx0000664000175000017500000000005712343605122021317 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/octave/callback/Makefile0000664000175000017500000000006612343605122020600 0ustar williamwilliamCXXSRCS = example.cxx include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/callback/runme.m0000664000175000017500000000305312343605122020443 0ustar williamwilliam# file: runme.m # This file illustrates the cross language polymorphism using directors. swigexample OctCallback=@() subclass(swigexample.Callback(),"run",@(self) printf("OctCallback.run()\n")); # Create an Caller instance caller = swigexample.Caller(); # Add a simple C++ callback (caller owns the callback, so # we disown it first) printf("Adding and calling a normal C++ callback\n"); printf("----------------------------------------\n"); callback = swigexample.Callback().__disown(); caller.setCallback(callback); caller.call(); caller.delCallback(); printf("Adding and calling a Octave callback\n"); printf("------------------------------------\n"); # Add a Octave callback (caller owns the callback, so we # disown it first by calling __disown). caller.setCallback(OctCallback().__disown()) caller.call(); caller.delCallback(); printf("Adding and calling another Octave callback\n"); printf("------------------------------------------\n"); # Let's do the same but use the weak reference this time. callback = OctCallback().__disown(); caller.setCallback(callback); caller.call(); caller.delCallback(); # careful-- using callback here may cause problems; octave_swig_type still # exists, but is holding a destroyed object (the C++ swigexample.Callback). # to manually drop the octave-side reference, you can use clear callback; # Let's call them directly now printf("Calling Octave and C++ callbacks directly\n"); printf("------------------------------------------\n"); a = OctCallback(); a.run(); a.Callback.run(); # All done. printf("octave exit\n"); swig-3.0.2/Examples/octave/variables/0000775000175000017500000000000012343605122017352 5ustar williamwilliamswig-3.0.2/Examples/octave/variables/example.c0000664000175000017500000000453412343605122021157 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/octave/variables/example.h0000664000175000017500000000007412343605122021157 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/octave/variables/example.i0000664000175000017500000000217012343605122021157 0ustar williamwilliam/* File : example.i */ %module swigexample %{ #include "example.h" %} #pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK /* Some global variable declarations */ %inline %{ extern "C" { extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; // extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; } %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/octave/variables/Makefile0000664000175000017500000000006112343605122021007 0ustar williamwilliamSRCS = example.c include $(SRCDIR)../example.mk swig-3.0.2/Examples/octave/variables/runme.m0000664000175000017500000000446012343605122020662 0ustar williamwilliam# file: runme.m swigexample # Try to set the values of some global variables swigexample.cvar.ivar = 42; swigexample.cvar.svar = -31000; swigexample.cvar.lvar = 65537; swigexample.cvar.uivar = 123456; swigexample.cvar.usvar = 61000; swigexample.cvar.ulvar = 654321; swigexample.cvar.scvar = -13; swigexample.cvar.ucvar = 251; swigexample.cvar.cvar = "S"; swigexample.cvar.fvar = 3.14159; swigexample.cvar.dvar = 2.1828; swigexample.cvar.strvar = "Hello World"; swigexample.cvar.iptrvar= swigexample.new_int(37); swigexample.cvar.ptptr = swigexample.new_Point(37,42); swigexample.cvar.name = "Bill"; # Now print out the values of the variables printf("Variables (values printed from Octave)\n"); printf("ivar = %i\n", swigexample.cvar.ivar); printf("svar = %i\n", swigexample.cvar.svar); printf("lvar = %i\n", swigexample.cvar.lvar); printf("uivar = %i\n", swigexample.cvar.uivar); printf("usvar = %i\n", swigexample.cvar.usvar); printf("ulvar = %i\n", swigexample.cvar.ulvar); printf("scvar = %i\n", swigexample.cvar.scvar); printf("ucvar = %i\n", swigexample.cvar.ucvar); printf("fvar = %i\n", swigexample.cvar.fvar); printf("dvar = %i\n", swigexample.cvar.dvar); printf("cvar = %s\n", swigexample.cvar.cvar); printf("strvar = %s\n", swigexample.cvar.strvar); #printf("cstrvar = %s\n", swigexample.cvar.cstrvar); swigexample.cvar.iptrvar printf("name = %i\n", swigexample.cvar.name); printf("ptptr = %s\n", swigexample.Point_print(swigexample.cvar.ptptr)); #printf("pt = %s\n", swigexample.cvar.Point_print(swigexample.cvar.pt)); printf("\nVariables (values printed from C)\n"); swigexample.print_vars(); printf("\nNow I'm going to try and modify some read only variables\n"); printf(" Tring to set 'path'\n"); try swigexample.cvar.path = "Whoa!"; printf("Hey, what's going on?!?! This shouldn't work\n"); catch printf("Good.\n"); end_try_catch printf(" Trying to set 'status'\n"); try swigexample.cvar.status = 0; printf("Hey, what's going on?!?! This shouldn't work\n"); catch printf("Good.\n"); end_try_catch printf("\nI'm going to try and update a structure variable.\n"); swigexample.cvar.pt = swigexample.cvar.ptptr; printf("The new value is %s\n", swigexample.Point_print(swigexample.cvar.pt)); swig-3.0.2/Examples/contract/0000775000175000017500000000000012343605122015736 5ustar williamwilliamswig-3.0.2/Examples/contract/simple_cxx/0000775000175000017500000000000012343605122020111 5ustar williamwilliamswig-3.0.2/Examples/contract/simple_cxx/runme3.py0000664000175000017500000000222512343605122021675 0ustar williamwilliamimport example # Create the Circle object r = 2; print " Creating circle (radium: %d) :" % r c = example.Circle(r) # Set the location of the object c.x = 20 c.y = 30 print " Here is its current position:" print " Circle = (%f, %f)" % (c.x,c.y) # ----- Call some methods ----- print "\n Here are some properties of the Circle:" print " area = ", c.area() print " perimeter = ", c.perimeter() dx = 1; dy = 1; print " Moving with (%d, %d)..." % (dx, dy) c.move(dx, dy) del c print "===================================" # test move function */ r = 2; print " Creating circle (radium: %d) :" % r c = example.Circle(r) # Set the location of the object c.x = 20 c.y = 30 print " Here is its current position:" print " Circle = (%f, %f)" % (c.x,c.y) # ----- Call some methods ----- print "\n Here are some properties of the Circle:" print " area = ", c.area() print " perimeter = ", c.perimeter() # no error for Circle's pre-assertion dx = 1; dy = -1; print " Moving with (%d, %d)..." % (dx, dy) c.move(dx, dy) # error with Shape's pre-assertion dx = -1; dy = 1; print " Moving with (%d, %d)..." % (dx, dy) c.move(dx, dy) swig-3.0.2/Examples/contract/simple_cxx/example.h0000664000175000017500000000113412343605122021714 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; virtual double area(void); virtual double perimeter(void); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { }; virtual double area(void); virtual double perimeter(void); }; swig-3.0.2/Examples/contract/simple_cxx/runme2.py0000664000175000017500000000160412343605122021674 0ustar williamwilliamimport example # Create the Circle object r = 2; print " Creating circle (radium: %d) :" % r c = example.Circle(r) # Set the location of the object c.x = 20 c.y = 30 print " Here is its current position:" print " Circle = (%f, %f)" % (c.x,c.y) # ----- Call some methods ----- print "\n Here are some properties of the Circle:" print " area = ", c.area() print " perimeter = ", c.perimeter() dx = 1; dy = 1; print " Moving with (%d, %d)..." % (dx, dy) c.move(dx, dy) del c print "===================================" # test area function */ r = 1; print " Creating circle (radium: %d) :" % r c = example.Circle(r) # Set the location of the object c.x = 20 c.y = 30 print " Here is its current position:" print " Circle = (%f, %f)" % (c.x,c.y) # ----- Call some methods ----- print "\n Here are some properties of the Circle:" print " area = ", c.area() swig-3.0.2/Examples/contract/simple_cxx/example.i0000664000175000017500000000066312343605122021723 0ustar williamwilliam%module example %contract Circle::Circle(double radius) { require: radius > 0; } %contract Circle::area(void) { ensure: area > 0; } %contract Shape::move(double dx, double dy) { require: dx > 0; } /* should be no effect, since there is no move() for class Circle */ %contract Circle::move(double dx, double dy) { require: dy > 1; } # include must be after contracts %{ #include "example.h" %} %include "example.h" swig-3.0.2/Examples/contract/simple_cxx/runme1.py0000664000175000017500000000120512343605122021670 0ustar williamwilliamimport example # Create the Circle object r = 2; print " Creating circle (radium: %d) :" % r c = example.Circle(r) # Set the location of the object c.x = 20 c.y = 30 print " Here is its current position:" print " Circle = (%f, %f)" % (c.x,c.y) # ----- Call some methods ----- print "\n Here are some properties of the Circle:" print " area = ", c.area() print " perimeter = ", c.perimeter() dx = 1; dy = 1; print " Moving with (%d, %d)..." % (dx, dy) c.move(dx, dy) del c print "===================================" # test construction */ r = -1; print " Creating circle (radium: %d) :" % r c = example.Circle(r) swig-3.0.2/Examples/contract/simple_cxx/example.cxx0000664000175000017500000000075512343605122022277 0ustar williamwilliam#include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area(void) { /* return -1 is to test post-assertion */ if (radius == 1) return -1; return M_PI*radius*radius; } double Circle::perimeter(void) { return 2*M_PI*radius; } double Square::area(void) { return width*width; } double Square::perimeter(void) { return 4*width; } swig-3.0.2/Examples/contract/simple_c/0000775000175000017500000000000012343605122017531 5ustar williamwilliamswig-3.0.2/Examples/contract/simple_c/example.c0000664000175000017500000000034012343605122021325 0ustar williamwilliam#include int Circle (int x, int y, int radius) { /* Draw Circle */ printf("Drawing the circle...\n"); /* Return -1 to test contract post assertion */ if (radius == 2) return -1; else return 1; } swig-3.0.2/Examples/contract/simple_c/runme2.py0000664000175000017500000000047012343605122021314 0ustar williamwilliamimport example # Call the Circle() function correctly x = 1; y = 1; r = 3; c = example.Circle(x, y, r) print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c) # test pre-assertion x = 1; y = -1; r = 3; c = example.Circle(x, y, r) print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c) swig-3.0.2/Examples/contract/simple_c/example.i0000664000175000017500000000050112343605122021332 0ustar williamwilliam/* File : example.i */ /* Basic C example for swig contract */ /* Tiger, University of Chicago, 2003 */ %module example %contract Circle (int x, int y, int radius) { require: x >= 0; y >= 0; radius > x; ensure: Circle >= 0; } %inline %{ extern int Circle (int x, int y, int radius); %} swig-3.0.2/Examples/contract/simple_c/runme1.py0000664000175000017500000000036512343605122021316 0ustar williamwilliamimport example # Call the Circle() function correctly x = 1; y = 1; r = 3; c = example.Circle(x, y, r) # test post-assertion x = 1; y = 1; r = 2; c = example.Circle(x, y, r) print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c) swig-3.0.2/Examples/guile/0000775000175000017500000000000012343605122015226 5ustar williamwilliamswig-3.0.2/Examples/guile/std_vector/0000775000175000017500000000000012343605122017402 5ustar williamwilliamswig-3.0.2/Examples/guile/std_vector/example.h0000664000175000017500000000111612343605122021205 0ustar williamwilliam/* File : example.h */ #include #include #include #include double average(std::vector v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } std::vector half(const std::vector& v) { std::vector w(v); for (unsigned int i=0; i& v) { // would you believe this is the same as the above? std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } swig-3.0.2/Examples/guile/std_vector/example.i0000664000175000017500000000047512343605122021215 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include stl.i /* instantiate the required template specializations */ namespace std { %template(IntVector) vector; %template(DoubleVector) vector; } /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/guile/std_vector/runme.scm0000664000175000017500000000250212343605122021233 0ustar williamwilliam (load-extension "./libexample" "scm_init_example_module") ; repeatedly invoke a procedure with v and an index as arguments (define (with-vector v proc size-proc) (let ((size (size-proc v))) (define (with-vector-item v i) (if (< i size) (begin (proc v i) (with-vector-item v (+ i 1))))) (with-vector-item v 0))) (define (with-IntVector v proc) (with-vector v proc IntVector-length)) (define (with-DoubleVector v proc) (with-vector v proc DoubleVector-length)) (define (print-DoubleVector v) (with-DoubleVector v (lambda (v i) (display (DoubleVector-ref v i)) (display " "))) (newline)) ; Call average with a Scheme list... (display (average '(1 2 3 4))) (newline) ; ... or a wrapped std::vector (define v (new-IntVector 4)) (with-IntVector v (lambda (v i) (IntVector-set! v i (+ i 1)))) (display (average v)) (newline) (delete-IntVector v) ; half will return a Scheme vector. ; Call it with a Scheme vector... (display (half #(1 1.5 2 2.5 3))) (newline) ; ... or a wrapped std::vector (define v (new-DoubleVector)) (map (lambda (i) (DoubleVector-push! v i)) '(1 2 3 4)) (display (half v)) (newline) ; now halve a wrapped std::vector in place (halve-in-place v) (print-DoubleVector v) (delete-DoubleVector v) (exit 0) swig-3.0.2/Examples/guile/std_vector/Makefile0000664000175000017500000000107412343605122021044 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean swig-3.0.2/Examples/guile/README0000664000175000017500000000111212343605122016101 0ustar williamwilliamThis directory contains examples for Guile. constants -- handling #define and %constant literals class -- classic c++ class example matrix -- a very simple Matrix example multimap -- typemaps with multiple sub-types multivalue -- using the %values_as_list directive port -- scheme ports as temporary FILE streams simple -- the simple example from the user manual std_vector -- C++ STL vector and vector Note that the examples in this directory build a special version of Guile which includes the wrapped functions in the top-level module. swig-3.0.2/Examples/guile/port/0000775000175000017500000000000012343605122016212 5ustar williamwilliamswig-3.0.2/Examples/guile/port/README0000664000175000017500000000020712343605122017071 0ustar williamwilliamThis example illustrates the translation from Scheme file ports to temporary FILE streams. Read the source and run ./port -s runme.scm swig-3.0.2/Examples/guile/port/example.c0000664000175000017500000000045212343605122020012 0ustar williamwilliam#include #include void print_int(FILE *f, int i) { if (fprintf(f, "%d\n", i)<0) perror("print_int"); } int read_int(FILE *f) { int i; if (fscanf(f, "%d", &i)!=1) { fprintf(stderr, "read_int: error reading from file\n"); perror("read_int"); } return i; } swig-3.0.2/Examples/guile/port/example.i0000664000175000017500000000030012343605122020010 0ustar williamwilliam%module port %include guilemain.i /* Include the required FILE * typemaps */ %include ports.i %{ #include %} %inline %{ void print_int(FILE *f, int i); int read_int(FILE *f); %} swig-3.0.2/Examples/guile/port/runme.scm0000664000175000017500000000221712343605122020046 0ustar williamwilliam;; Call with standard output (print-int (current-output-port) 314159) ;; Redirection to a file. Note that the port is automatically flushed ;; (via force-output) before calling the C function, and that the C ;; function gets a temporary "FILE" stream, which is closed after the ;; call. So you can simply mix Scheme and C output. (with-output-to-file "test.out" (lambda () (display 4711) (newline) (print-int (current-output-port) 314159) (display 815) (newline))) ;; Redirection to a string or soft port won't work -- ;; we can only handle file ports. (catch #t (lambda () (with-output-to-string (lambda () (print-int (current-output-port) 314159)))) (lambda args (display "Below shows that attempting to write to a string or soft port will result in a wrong-type-error...") (newline) (write args) (newline))) ;; Read from a file port. Note that it is a bad idea to mix Scheme and ;; C input because of buffering, hence the call to seek to rewind the file. (with-input-from-file "test.out" (lambda () (seek (current-input-port) 0 SEEK_SET) (display (read-int (current-input-port))) (newline))) swig-3.0.2/Examples/guile/port/Makefile0000664000175000017500000000072512343605122017656 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = port INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean rm -f test.out swig-3.0.2/Examples/guile/class/0000775000175000017500000000000012343605122016333 5ustar williamwilliamswig-3.0.2/Examples/guile/class/example.h0000664000175000017500000000107612343605122020143 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/guile/class/example.i0000664000175000017500000000021512343605122020136 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/guile/class/example.cxx0000664000175000017500000000065012343605122020513 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/guile/class/runme.scm0000664000175000017500000000300412343605122020162 0ustar williamwilliam; file: runme.scm ; This file illustrates the proxy class C++ interface generated ; by SWIG. (load-extension "./libexample" "scm_init_example_module") ; Convenience wrapper around the display function ; (which only accepts one argument at the time) (define (mdisplay-newline . args) (for-each display args) (newline)) ; ----- Object creation ----- (mdisplay-newline "Creating some objects:") (define c (new-Circle 10)) (mdisplay-newline " Created circle " c) (define s (new-Square 10)) (mdisplay-newline " Created square " s) ; ----- Access a static member ----- (mdisplay-newline "\nA total of " (Shape-nshapes) " shapes were created") ; ----- Member data access ----- ; Set the location of the object (Shape-x-set c 20) (Shape-y-set c 30) (Shape-x-set s -10) (Shape-y-set s 5) (mdisplay-newline "\nHere is their current position:") (mdisplay-newline " Circle = (" (Shape-x-get c) "," (Shape-y-get c) ")") (mdisplay-newline " Square = (" (Shape-x-get s) "," (Shape-y-get s) ")") ; ----- Call some methods ----- (mdisplay-newline "\nHere are some properties of the shapes:") (define (shape-props o) (mdisplay-newline " " o) (mdisplay-newline " area = " (Shape-area o)) (mdisplay-newline " perimeter = " (Shape-perimeter o))) (for-each shape-props (list c s)) (mdisplay-newline "\nGuess I'll clean up now") ; Note: this invokes the virtual destructor (delete-Shape c) (delete-Shape s) (define s 3) (mdisplay-newline (Shape-nshapes) " shapes remain") (mdisplay-newline "Goodbye") (exit 0) swig-3.0.2/Examples/guile/class/Makefile0000664000175000017500000000111012343605122017764 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean swig-3.0.2/Examples/guile/simple/0000775000175000017500000000000012343605122016517 5ustar williamwilliamswig-3.0.2/Examples/guile/simple/README0000664000175000017500000000025012343605122017374 0ustar williamwilliamA very simple example. To run it, start the program 'my-guile' and type: (load "runme.scm") Alternatively, you can use the shell command: ./my-guile -s runme.scm swig-3.0.2/Examples/guile/simple/example.c0000664000175000017500000000045612343605122020323 0ustar williamwilliam/* Simple example from documentation */ /* File : example.c */ #include double My_variable = 3.0; int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } int mod(int n, int m) { return (n % m); } char *get_time() { long ltime; time(<ime); return ctime(<ime); } swig-3.0.2/Examples/guile/simple/example.i0000664000175000017500000000036512343605122020330 0ustar williamwilliam/* File : example.i */ %module Example %{ /* Put headers and other declarations here */ %} %inline %{ extern double My_variable; extern int fact(int); extern int mod(int n, int m); extern char *get_time(); %} %include guile/guilemain.i swig-3.0.2/Examples/guile/simple/runme.scm0000664000175000017500000000117012343605122020350 0ustar williamwilliam (define (mdisplay-newline . args) ; does guile-1.3.4 have `format #t'? (for-each display args) (newline)) (mdisplay-newline (get-time) "My variable = " (My-variable)) (do ((i 0 (1+ i))) ((= 14 i)) (mdisplay-newline i " factorial is " (fact i))) (define (mods i imax j jmax) (if (< i imax) (if (< j jmax) (begin (My-variable (+ (My-variable) (mod i j))) (mods i imax (+ j 1) jmax)) (mods (+ i 1) imax 1 jmax)))) (mods 1 150 1 150) (mdisplay-newline "My-variable = " (My-variable)) (exit (and (= 1932053504 (fact 13)) (= 745470.0 (My-variable)))) swig-3.0.2/Examples/guile/simple/Makefile0000664000175000017500000000071112343605122020156 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my-guile INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean swig-3.0.2/Examples/guile/constants/0000775000175000017500000000000012343605122017242 5ustar williamwilliamswig-3.0.2/Examples/guile/constants/example.i0000664000175000017500000000116112343605122021046 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; %include guilemain.i swig-3.0.2/Examples/guile/constants/runme.scm0000664000175000017500000000217012343605122021074 0ustar williamwilliam(or (= (ICONST) 42) (exit 1)) (display "ICONST = ")(display (ICONST))(display " (should be 42)\n") (or (< (abs (- (FCONST) 2.1828)) 0.00001) (exit 1)) (display "FCONST = ")(display (FCONST))(display " (should be 2.1828)\n") (or (char=? (CCONST) #\x) (exit 1)) (display "CCONST = ")(display (CCONST))(display " (should be 'x')\n") (or (char=? (CCONST2) #\newline) (exit 1)) (display "CCONST2 = ")(display (CCONST2))(display " (this should be on a new line)\n") (or (string=? (SCONST) "Hello World") (exit 1)) (display "SCONST = ")(display (SCONST))(display " (should be 'Hello World')\n") (or (string=? (SCONST2) "\"Hello World\"") (exit 1)) (display "SCONST2 = ")(display (SCONST2))(display " (should be \"Hello World\")\n") (or (< (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))) 0.00001) (exit 1)) (display "EXPR = ")(display (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))))(display " (should round to 0.0)\n") (or (= (iconst) 37) (exit 1)) (display "iconst = ")(display (iconst))(display " (should be 37)\n") (or (< (abs (- (fconst) 3.14)) 0.00001) (exit 1)) (display "fconst = ")(display (fconst))(display " (should be 3.14)\n") (exit 0) swig-3.0.2/Examples/guile/constants/Makefile0000664000175000017500000000067712343605122020714 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = my-guile INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean swig-3.0.2/Examples/guile/multivalue/0000775000175000017500000000000012343605122017415 5ustar williamwilliamswig-3.0.2/Examples/guile/multivalue/example.c0000664000175000017500000000051612343605122021216 0ustar williamwilliamvoid divide_l(int a, int b, int *quotient_p, int *remainder_p) { *quotient_p = a/b; *remainder_p = a%b; } void divide_v(int a, int b, int *quotient_p, int *remainder_p) { *quotient_p = a/b; *remainder_p = a%b; } void divide_mv(int a, int b, int *quotient_p, int *remainder_p) { *quotient_p = a/b; *remainder_p = a%b; } swig-3.0.2/Examples/guile/multivalue/example.i0000664000175000017500000000174412343605122021230 0ustar williamwilliam/* -*- c -*- */ %module example; %{ void divide_l(int a, int b, int *quotient_p, int *remainder_p); void divide_v(int a, int b, int *quotient_p, int *remainder_p); void divide_mv(int a, int b, int *quotient_p, int *remainder_p); %} /* Multiple values as lists. By default, if more than one value is to be returned, a list of the values is created and returned; to switch back to this behavior, use: */ %values_as_list; void divide_l(int a, int b, int *OUTPUT, int *OUTPUT); /* Multiple values as vectors. By issueing: */ %values_as_vector; /* vectors instead of lists will be used. */ void divide_v(int a, int b, int *OUTPUT, int *OUTPUT); /* Multiple values for multiple-value continuations. (This is the most elegant way.) By issueing: */ %multiple_values; /* multiple values are passed to the multiple-value continuation, as created by `call-with-values' or the convenience macro `receive'. (See the Scheme file.) */ void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT); swig-3.0.2/Examples/guile/multivalue/runme.scm0000664000175000017500000000411112343605122021244 0ustar williamwilliam;;;; Show the three different ways to deal with multiple return values (load-extension "./libexample" "scm_init_example_module") ;;; Multiple values as lists. By default, if more than one value is to ;;; be returned, a list of the values is created and returned. The ;;; procedure divide-l does so: (let* ((quotient/remainder (divide-l 37 5)) ;; divide-l returns a list of the two values, so get them: (quotient (car quotient/remainder)) (remainder (cadr quotient/remainder))) (display "37 divided by 5 is ") (display quotient) (display ", remainder ") (display remainder) (newline)) ;;; Multiple values as vectors. You can get vectors instead of lists ;;; if you want: (let* ((quotient-remainder-vector (divide-v 40 7)) ;; divide-v returns a vector of two values, so get them: (quotient (vector-ref quotient-remainder-vector 0)) (remainder (vector-ref quotient-remainder-vector 1))) (display "40 divided by 7 is ") (display quotient) (display ", remainder ") (display remainder) (newline)) ;;; Multiple values for multiple-value continuations. (The most ;;; elegant way.) You can get multiple values passed to the ;;; multiple-value continuation, as created by `call-with-values'. (call-with-values (lambda () ;; the "producer" procedure (divide-mv 91 13)) (lambda (quotient remainder) ;; the "consumer" procedure (display "91 divided by 13 is ") (display quotient) (display ", remainder ") (display remainder) (newline))) ;;; SRFI-8 has a very convenient macro for this construction: (use-modules (srfi srfi-8)) ;;; If your Guile is too old, you can define the receive macro yourself: ;;; ;;; (define-macro (receive vars vals . body) ;;; `(call-with-values (lambda () ,vals) ;;; (lambda ,vars ,@body))) (receive (quotient remainder) (divide-mv 111 19) ; the "producer" form ;; In the body, `quotient' and `remainder' are bound to the two ;; values. (display "111 divided by 19 is ") (display quotient) (display ", remainder ") (display remainder) (newline)) (exit 0) swig-3.0.2/Examples/guile/multivalue/Makefile0000664000175000017500000000106212343605122021054 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean swig-3.0.2/Examples/guile/matrix/0000775000175000017500000000000012343605122016532 5ustar williamwilliamswig-3.0.2/Examples/guile/matrix/README0000664000175000017500000000040412343605122017410 0ustar williamwilliamMatrix example. To run the example, execute the program 'matrix' and type the following : (load "runme.scm") (do-test 0) Alternatively, use the command-line: ./matrix -e do-test -s runme.scm Or, if your operating system is spiffy enough: ./runme.scm swig-3.0.2/Examples/guile/matrix/example.i0000664000175000017500000000040312343605122020334 0ustar williamwilliam/*** Matrix and vector example ***/ %module Matrix %{ #include %} %include guilemain.i %include matrix.i %include vector.i // Include the math library so we can get some random numbers and // other stuff %include math.i extern double drand48(); swig-3.0.2/Examples/guile/matrix/vector.h0000664000175000017500000000014012343605122020200 0ustar williamwilliam #include typedef struct { double x; double y; double z; double w; } Vector; swig-3.0.2/Examples/guile/matrix/vector.i0000664000175000017500000000062012343605122020204 0ustar williamwilliam// // FILE : vector.i %{ #include "vector.h" %} %inline { extern Vector *createv(double x,double y,double z,double w); /* Creates a new vector v(x,y,z,w) */ extern void destroyv(Vector *v); /* Destroys the vector v */ extern void printv(Vector *v); /* Prints out the vector v */ extern void transform(double **T, Vector *v, Vector *t); /* Transforms vector c to vector t by M*v --> t */ } swig-3.0.2/Examples/guile/matrix/matrix.c0000664000175000017500000000156012343605122020204 0ustar williamwilliam/* FILE : matrix.c : some simple 4x4 matrix operations */ #include #include double **new_matrix() { int i; double **M; M = (double **) malloc(4*sizeof(double *)); M[0] = (double *) malloc(16*sizeof(double)); for (i = 0; i < 4; i++) { M[i] = M[0] + 4*i; } return M; } void destroy_matrix(double **M) { free(M[0]); free(M); } void print_matrix(double **M) { int i,j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { printf("%10g ", M[i][j]); } printf("\n"); } } void mat_mult(double **m1, double **m2, double **m3) { int i,j,k; double temp[4][4]; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { temp[i][j] = 0; for (k = 0; k < 4; k++) temp[i][j] += m1[i][k]*m2[k][j]; } for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) m3[i][j] = temp[i][j]; } swig-3.0.2/Examples/guile/matrix/runme.scm0000664000175000017500000001222012343605122020361 0ustar williamwilliam#!./matrix \ -e do-test -s !# ;;; Authors: David Beazley , 1999 ;;; Martin Froehlich , 2000 ;;; ;;; PURPOSE OF THIS FILE: This file is an example for how to use the guile ;;; scripting options with a little more than trivial script. Example ;;; derived from David Beazley's matrix evaluation example. David ;;; Beazley's annotation: >>Guile script for testing out matrix ;;; operations. Disclaimer : I'm not a very good scheme ;;; programmer<<. Martin Froehlich's annotation: >>I'm not a very good ;;; scheme programmer, too<<. ;;; ;;; Explanation: The three lines at the beginning of this script are ;;; telling the kernel to load the enhanced guile interpreter named ;;; "matrix"; to execute the function "do-test" (-e option) after loading ;;; this script (-s option). There are a lot more options wich allow for ;;; even finer tuning. SEE ALSO: Section "Guile Scripts" in the "Guile ;;; reference manual -- Part I: Preliminaries". ;;; ;;; ;;; This program is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ;;; Create a zero matrix (define (zero M) (define (zero-loop M i j) (if (< i 4) (if (< j 4) (begin (set-m M i j 0.0) (zero-loop M i (+ j 1))) (zero-loop M (+ i 1) 0)))) (zero-loop M 0 0)) ;;; Create an identity matrix (define (identity M) (define (iloop M i) (if (< i 4) (begin (set-m M i i 1.0) (iloop M (+ i 1))))) (zero M) (iloop M 0)) ;;; Rotate around x axis (define (rotx M r) (define temp (new-matrix)) (define rd (/ (* r 3.14159) 180.0)) (zero temp) (set-m temp 0 0 1.0) (set-m temp 1 1 (cos rd)) (set-m temp 1 2 (- 0 (sin rd))) (set-m temp 2 1 (sin rd)) (set-m temp 2 2 (cos rd)) (set-m temp 3 3 1.0) (mat-mult M temp M) (destroy-matrix temp)) ;;; Rotate around y axis (define (roty M r) (define temp (new-matrix)) (define rd (/ (* r 3.14159) 180.0)) (zero temp) (set-m temp 1 1 1.0) (set-m temp 0 0 (cos rd)) (set-m temp 0 2 (sin rd)) (set-m temp 2 0 (- 0 (sin rd))) (set-m temp 2 2 (cos rd)) (set-m temp 3 3 1.0) (mat-mult M temp M) (destroy-matrix temp)) ;;; Rotate around z axis (define (rotz M r) (define temp (new-matrix)) (define rd (/ (* r 3.14159) 180.0)) (zero temp) (set-m temp 0 0 (cos rd)) (set-m temp 0 1 (- 0 (sin rd))) (set-m temp 1 0 (sin rd)) (set-m temp 1 1 (cos rd)) (set-m temp 2 2 1.0) (set-m temp 3 3 1.0) (mat-mult M temp M) (destroy-matrix temp)) ;;; Scale a matrix (define (scale M s) (define temp (new-matrix)) (define (sloop m i s) (if (< i 4) (begin (set-m m i i s) (sloop m (+ i 1) s)))) (zero temp) (sloop temp 0 s) (mat-mult M temp M) (destroy-matrix temp)) ;;; Make a matrix with random elements (define (randmat M) (define (rand-loop M i j) (if (< i 4) (if (< j 4) (begin (set-m M i j (drand48)) (rand-loop M i (+ j 1))) (rand-loop M (+ i 1) 0)))) (rand-loop M 0 0)) ;;; stray definitions collected here (define (rot-test M v t i) (if (< i 360) (begin (rotx M 1) (rotz M -0.5) (transform M v t) (rot-test M v t (+ i 1))))) (define (create-matrix) ; Create some matrices (let loop ((i 0) (result '())) (if (< i 200) (loop (+ i 1) (cons (new-matrix) result)) result))) (define (add-mat M ML) (define (add-two m1 m2 i j) (if (< i 4) (if (< j 4) (begin (set-m m1 i j (+ (get-m m1 i j) (get-m m2 i j))) (add-two m1 m2 i (+ j 1))) (add-two m1 m2 (+ i 1) 0)))) (if (null? ML) *unspecified* (begin (add-two M (car ML) 0 0) (add-mat M (cdr ML))))) (define (cleanup ML) (if (null? ML) *unspecified* (begin (destroy-matrix (car ML)) (cleanup (cdr ML))))) (define (make-random ML) ; Put random values in them (if (null? ML) *unspecified* (begin (randmat (car ML)) (make-random (cdr ML))))) (define (mul-mat m ML) (if (null? ML) *unspecified* (begin (mat-mult m (car ML) m) (mul-mat m (cdr ML))))) ;;; Now we'll hammer on things a little bit just to make ;;; sure everything works. (define M1 (new-matrix)) ; a matrix (define v (createv 1 2 3 4)) ; a vector (define t (createv 0 0 0 0)) ; the zero-vector (define M-list (create-matrix)) ; get list of marices (define M (new-matrix)) ; yet another matrix (display "variables defined\n") (define (do-test x) (display "Testing matrix program...\n") (identity M1) (print-matrix M1) (display "Rotate-x 45 degrees\n") (rotx M1 45) (print-matrix M1) (display "Rotate y 30 degrees\n") (roty M1 30) (print-matrix M1) (display "Rotate z 15 degrees\n") (rotz M1 15) (print-matrix M1) (display "Scale 0.5\n") (scale M1 0.5) (print-matrix M1) ;; Rotating ... (display "Rotating...\n") (rot-test M1 v t 0) (printv t) (make-random M-list) (zero M1) (display "Adding them together (in Guile)\n") (add-mat M1 M-list) (print-matrix M1) (display "Doing 200 multiplications (mostly in C)\n") (randmat M) (mul-mat M M-list) (display "Cleaning up\n") (cleanup M-list)) swig-3.0.2/Examples/guile/matrix/vector.c0000664000175000017500000000144112343605122020200 0ustar williamwilliam/* File : vector.c */ #include #include #include "vector.h" Vector *createv(double x, double y, double z, double w) { Vector *n; n = (Vector *) malloc(sizeof(Vector)); n->x = x; n->y = y; n->z = z; n->w = w; return n; } /* Destroy vector */ void destroyv(Vector *v) { free(v); } /* Print a vector */ void printv(Vector *v) { printf("x = %g, y = %g, z = %g, w = %g\n", v->x, v->y, v->z, v->w); } /* Do a transformation */ void transform(double **m, Vector *v, Vector *r) { r->x = m[0][0]*v->x + m[0][1]*v->y + m[0][2]*v->z + m[0][3]*v->w; r->y = m[1][0]*v->x + m[1][1]*v->y + m[1][2]*v->z + m[1][3]*v->w; r->z = m[2][0]*v->x + m[2][1]*v->y + m[2][2]*v->z + m[2][3]*v->w; r->w = m[3][0]*v->x + m[3][1]*v->y + m[3][2]*v->z + m[3][3]*v->w; } swig-3.0.2/Examples/guile/matrix/Makefile0000664000175000017500000000077012343605122020176 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = matrix.c vector.c TARGET = matrix INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' GUILE_RUNOPTIONS='-e do-test' guile_augmented_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-lm' guile_augmented clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean swig-3.0.2/Examples/guile/matrix/matrix.i0000664000175000017500000000127612343605122020216 0ustar williamwilliam// // FILE : matrix.i %{ void set_m(double **M, int i, int j, double val) { M[i][j] = val; } double get_m(double **M, int i, int j) { return M[i][j]; } %} %inline { /*** Matrix Operations ***/ extern double **new_matrix(); /* Creates a new matrix and returns a pointer to it */ extern void destroy_matrix(double **M); /* Destroys the matrix M */ extern void print_matrix(double **M); /* Prints out the matrix M */ extern void set_m(double **M, int i, int j, double val); /* Sets M[i][j] = val*/ extern double get_m(double **M, int i, int j); /* Returns M[i][j] */ extern void mat_mult(double **a, double **b, double **c); /* Multiplies matrix a by b and places the result in c*/ } swig-3.0.2/Examples/guile/check.list0000664000175000017500000000013612343605122017200 0ustar williamwilliam# see top-level Makefile.in constants class port simple std_vector matrix multimap multivalue swig-3.0.2/Examples/guile/multimap/0000775000175000017500000000000012343605122017056 5ustar williamwilliamswig-3.0.2/Examples/guile/multimap/example.c0000664000175000017500000000164012343605122020656 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.2/Examples/guile/multimap/example.i0000664000175000017500000000447512343605122020675 0ustar williamwilliam/* File : example.i */ %module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} %include exception.i %include typemaps.i extern int gcd(int x, int y); %typemap(in) (int argc, char *argv[]) %{ scm_t_array_handle handle; size_t i; size_t lenp; ssize_t inc; const SCM *v; if (!(SCM_NIMP($input) && scm_is_vector($input))) { SWIG_exception(SWIG_ValueError, "Expecting a vector"); return 0; } v = scm_vector_elements($input, &handle, &lenp, &inc); $1 = (int)lenp; if ($1 == 0) { SWIG_exception(SWIG_ValueError, "Vector must contain at least 1 element"); } $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++, v +=inc ) { if (!(SCM_NIMP(*v) && scm_is_string(*v))) { free($2); SWIG_exception(SWIG_ValueError, "Vector items must be strings"); return 0; } $2[i] = scm_to_locale_string(*v); } $2[i] = 0; scm_array_handle_release (&handle); %} %typemap(freearg) (int argc, char *argv[]) %{ for (i = 0; i < $1; i++) { free($2[i]); } free($2); %} extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) %{ if (!(SCM_NIMP($input) && scm_is_string($input))) { SWIG_exception(SWIG_ValueError, "Expecting a string"); } $1 = scm_to_locale_string($input); $2 = scm_c_string_length($input); %} %typemap(freearg) (char *bytes, int len) %{ free($1); %} extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a string */ %typemap(in) (char *str, int len) { size_t temp; $1 = SWIG_Guile_scm2newstr($input,&temp); $2 = temp; } /* Return the mutated string as a new object. */ %typemap(argout) (char *str, int len) { SWIG_APPEND_VALUE(scm_from_locale_stringn($1,$2)); if ($1) SWIG_free($1); } extern void capitalize(char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); } } extern void circle(double cx, double cy); swig-3.0.2/Examples/guile/multimap/runme.scm0000664000175000017500000000077712343605122020723 0ustar williamwilliam;;; Test out some multi-argument typemaps (load-extension "./libexample" "scm_init_example_module") ; Call the GCD function (define x 42) (define y 105) (define g (gcd x y)) (display "The gcd of ") (display x) (display " and ") (display y) (display " is ") (display g) (newline) ; Call the gcdmain() function (gcdmain #("gcdmain" "42" "105")) ; Call the count function (display (count "Hello World" #\l)) (newline) ; Call the capitalize function (display (capitalize "hello world")) (newline) (exit 0) swig-3.0.2/Examples/guile/multimap/Makefile0000664000175000017500000000106212343605122020515 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean swig-3.0.2/Examples/go/0000775000175000017500000000000012343605122014526 5ustar williamwilliamswig-3.0.2/Examples/go/template/0000775000175000017500000000000012343605122016341 5ustar williamwilliamswig-3.0.2/Examples/go/template/runme.go0000664000175000017500000000116712343605122020023 0ustar williamwilliam// This example illustrates how C++ templates can be used from Go. package main import ( . "./example" "fmt" ) func main() { // Call some templated functions fmt.Println(Maxint(3, 7)) fmt.Println(Maxdouble(3.14, 2.18)) // Create some class iv := NewVecint(100) dv := NewVecdouble(1000) for i := 0; i < 100; i++ { iv.Setitem(i, 2*i) } for i := 0; i < 1000; i++ { dv.Setitem(i, 1.0/float64(i+1)) } { sum := 0 for i := 0; i < 100; i++ { sum = sum + iv.Getitem(i) } fmt.Println(sum) } { sum := float64(0.0) for i := 0; i < 1000; i++ { sum = sum + dv.Getitem(i) } fmt.Println(sum) } } swig-3.0.2/Examples/go/template/example.h0000664000175000017500000000077712343605122020160 0ustar williamwilliam/* File : example.h */ // Some template definitions template T max(T a, T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } #ifdef SWIG %extend { T getitem(int index) { return $self->get(index); } void setitem(int index, T val) { $self->set(index,val); } } #endif }; swig-3.0.2/Examples/go/template/example.i0000664000175000017500000000051412343605122020146 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; swig-3.0.2/Examples/go/template/index.html0000664000175000017500000000444112343605122020341 0ustar williamwilliam SWIG:Examples:go:template SWIG/Examples/go/template/

C++ template support

This example illustrates how C++ templates can be used from Go using SWIG.

The C++ Code

Let's take a templated function and a templated class as follows:
/* File : example.h */

// Some template definitions

template T max(T a, T b) { return  a>b ? a : b; }

template class vector {
  T *v;
  int sz;
 public:
  vector(int _sz) {
    v = new T[_sz];
    sz = _sz;
  }
  T &get(int index) {
    return v[index];
  }
  void set(int index, T &val) {
    v[index] = val;
  }
#ifdef SWIG
  %addmethods {
    T getitem(int index) {
      return self->get(index);
    }
    void setitem(int index, T val) {
      self->set(index,val);
    }
  }
#endif
};
The %addmethods is used for a neater interface from Go as the functions get and set use C++ references to primitive types. These are tricky to use from Go as they end up as pointers, which only work when the C++ and Go types correspond precisely.

The SWIG interface

A simple SWIG interface for this can be built by simply grabbing the header file like this:
/* File : example.i */
%module example

%{
#include "example.h"
%}

/* Let's just grab the original header file here */
%include "example.h"

/* Now instantiate some specific template declarations */

%template(maxint) max;
%template(maxdouble) max;
%template(vecint) vector;
%template(vecdouble) vector;
Note that SWIG parses the templated function max and templated class vector and so knows about them. However to generate code for use from Go, SWIG has to be told which class/type to use as the template parameter. The SWIG directive %template is used for this.

A sample Go program

Click here to see a Go program that calls the C++ functions from Go.

Notes

Use templated classes just like you would any other SWIG generated Go class. Use the classnames specified by the %template directive.
vecdouble dv = new vecdouble(1000);
dv.setitem(i, 12.34));

swig-3.0.2/Examples/go/template/Makefile0000664000175000017500000000100112343605122017771 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/class/0000775000175000017500000000000012343605122015633 5ustar williamwilliamswig-3.0.2/Examples/go/class/runme.go0000664000175000017500000000303712343605122017313 0ustar williamwilliam// This example illustrates how C++ classes can be used from Go using SWIG. package main import ( . "./example" "fmt" ) func main() { // ----- Object creation ----- fmt.Println("Creating some objects:") c := NewCircle(10) fmt.Println(" Created circle", c) s := NewSquare(10) fmt.Println(" Created square", s) // ----- Access a static member ----- fmt.Println("\nA total of", GetShapeNshapes(), "shapes were created") // ----- Member data access ----- // Notice how we can do this using functions specific to // the 'Circle' class. c.SetX(20) c.SetY(30) // Now use the same functions in the base class var shape Shape = s shape.SetX(-10) shape.SetY(5) fmt.Println("\nHere is their current position:") fmt.Println(" Circle = (", c.GetX(), " ", c.GetY(), ")") fmt.Println(" Square = (", s.GetX(), " ", s.GetY(), ")") // ----- Call some methods ----- fmt.Println("\nHere are some properties of the shapes:") shapes := []Shape{c, s} for i := 0; i < len(shapes); i++ { fmt.Println(" ", shapes[i]) fmt.Println(" area = ", shapes[i].Area()) fmt.Println(" perimeter = ", shapes[i].Perimeter()) } // Notice how the area() and perimeter() functions really // invoke the appropriate virtual method on each object. // ----- Delete everything ----- fmt.Println("\nGuess I'll clean up now") // Note: this invokes the virtual destructor // You could leave this to the garbage collector DeleteCircle(c) DeleteSquare(s) fmt.Println(GetShapeNshapes(), " shapes remain") fmt.Println("Goodbye") } swig-3.0.2/Examples/go/class/example.h0000664000175000017500000000107612343605122017443 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/go/class/example.i0000664000175000017500000000021512343605122017436 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/go/class/index.html0000664000175000017500000001077412343605122017641 0ustar williamwilliam SWIG:Examples:go:class SWIG/Examples/go/class/

Wrapping a simple C++ class

This example illustrates the most primitive form of C++ class wrapping performed by SWIG. In this case, C++ classes are simply transformed into a collection of C-style functions that provide access to class members.

The C++ Code

Suppose you have some C++ classes described by the following (and admittedly lame) header file:
/* File : example.h */

class Shape {
public:
  Shape() {
    nshapes++;
  }
  virtual ~Shape() {
    nshapes--;
  }
  double  x, y;
  void    move(double dx, double dy);
  virtual double area() = 0;
  virtual double perimeter() = 0;
  static  int nshapes;
};

class Circle : public Shape {
private:
  double radius;
public:
  Circle(double r) : radius(r) { }
  virtual double area();
  virtual double perimeter();
};

class Square : public Shape {
private:
  double width;
public:
  Square(double w) : width(w) { }
  virtual double area();
  virtual double perimeter();
};

The SWIG interface

A simple SWIG interface for this can be built by simply grabbing the header file like this:
/* File : example.i */
%module example

%{
#include "example.h"
%}

/* Let's just grab the original header file here */
%include "example.h"
Note: when creating a C++ extension, you must run SWIG with the -c++ option like this:
% swig -c++ -go example.i

A sample Go script

See example.go for a program that calls the C++ functions from Go.

Key points

  • To create a new object, you call a constructor like this:
    c := example.NewCircle(10.0)
    
    The name of the constructor is New followed by the name of the class, capitalized.

  • The constructor returns a value of interface type. The methods of the interface will be the methods of the C++ class, plus member accessor functions.

  • To access member data, a pair of accessor methods are used. For example:
    c.SetX(15)          # Set member data
    x := c.GetX()       # Get member data.
    
    These are methods on the type returned by the constructor. The getter is named Get followed by the name of the member, capitalized. The setter is similar but uses Set.

  • To invoke a member function, you simply do this
    fmt.Println("The area is", example.c.Area())
    
  • To invoke a destructor, simply do this
    example.DeleteShape(c)     # Deletes a shape
    
    The name of the destructor is Delete followed by the name of the class, capitalized. (Note: destructors are currently not inherited. This might change later).

  • Static member variables are wrapped much like C global variables. For example:
    n := GetShapeNshapes()     # Get a static data member
    SetShapeNshapes(13)        # Set a static data member
    
    The name is Get or Set, followed by the name of the class, capitalized, followed by the name of the member, capitalized.

General Comments

  • This low-level interface is not the only way to handle C++ code. Director classes provide a much higher-level interface.

  • Because C++ and Go implement inheritance quite differently, you can not simply upcast an object in Go code when using multiple inheritance. When using only single inheritance, you can simply pass a class to a function expecting a parent class. When using multiple inheritance, you have to call an automatically generated getter function named Get followed by the capitalized name of the immediate parent. This will return the same object converted to the parent class.

  • Overloaded methods should normally work. However, when calling an overloaded method you must explicitly convert constants to the expected type when it is not int or float. In particular, a floating point constant will default to type float, but C++ functions typically expect the C++ type double which is equivalent to the Go type float64 So calling an overloaded method with a floating point constant typically requires an explicit conversion to float64.

  • Namespaces are not supported in any very coherent way.

swig-3.0.2/Examples/go/class/class.cxx0000664000175000017500000000064612343605122017472 0ustar williamwilliam/* File : class.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/go/class/Makefile0000664000175000017500000000077212343605122017301 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = class.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/pointer/0000775000175000017500000000000012343605122016206 5ustar williamwilliamswig-3.0.2/Examples/go/pointer/runme.go0000664000175000017500000000174112343605122017666 0ustar williamwilliampackage main import ( . "./example" "fmt" ) func main() { // First create some objects using the pointer library. fmt.Println("Testing the pointer library") a := New_intp() b := New_intp() c := New_intp() Intp_assign(a, 37) Intp_assign(b, 42) fmt.Println(" a =", a) fmt.Println(" b =", b) fmt.Println(" c =", c) // Call the add() function with some pointers Add(a, b, c) // Now get the result res := Intp_value(c) fmt.Println(" 37 + 42 =", res) // Clean up the pointers Delete_intp(a) Delete_intp(b) Delete_intp(c) // Now try the typemap library // Now it is no longer necessary to manufacture pointers. // Instead we use a single element slice which in Go is modifiable. fmt.Println("Trying the typemap library") r := []int{0} Sub(37, 42, r) fmt.Println(" 37 - 42 = ", r[0]) // Now try the version with return value fmt.Println("Testing return value") q := Divide(42, 37, r) fmt.Println(" 42/37 = ", q, " remainder ", r[0]) } swig-3.0.2/Examples/go/pointer/example.i0000664000175000017500000000117612343605122020020 0ustar williamwilliam/* File : example.i */ %module example %{ extern void add(int *, int *, int *); extern void sub(int *, int *, int *); extern int divide(int, int, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); swig-3.0.2/Examples/go/pointer/index.html0000664000175000017500000000567512343605122020220 0ustar williamwilliam SWIG:Examples:go:pointer SWIG/Examples/go/pointer/

Simple Pointer Handling

This example illustrates a couple of techniques for handling simple pointers in SWIG. The prototypical example is a C function that operates on pointers such as this:

void add(int *x, int *y, int *r) { 
    *r = *x + *y;
}
By default, SWIG wraps this function exactly as specified and creates an interface that expects pointer objects for arguments. This only works when there is a precise correspondence between the C type and some Go type.

Other approaches

  • The SWIG pointer library provides a different, safer, way to handle pointers. For example, in the interface file you would do this:
    %include cpointer.i
    %pointer_functions(int, intp);
    
    and from Go you would use pointers like this:
    a := example.New_intp()
    b := example.New_intp()
    c := example.New_intp()
    Intp_Assign(a, 37)
    Intp_Assign(b, 42)
    
    fmt.Println("     a =", a)
    fmt.Println("     b =", b)
    fmt.Println("     c =", c)
    
    // Call the add() function with some pointers
    example.Add(a,b,c)
    
    // Now get the result
    res := example.Intp_value(c)
    fmt.Println("     37 + 42 =", res)
    
    // Clean up the pointers
    example.Delete_intp(a)
    example.Delete_intp(b)
    example.Delete_intp(c)
    

  • Use the SWIG typemap library. This library allows you to completely change the way arguments are processed by SWIG. For example:
    %include "typemaps.i"
    void add(int *INPUT, int *INPUT, int *OUTPUT);
    
    And in a Go program:
    r := []int{0}
    example.Sub(37,42,r)
    fmt.Println("Result =", r[0])
    
    Needless to say, this is substantially easier although a bit unusual.

  • A final alternative is to use the typemaps library in combination with the %apply directive. This allows you to change the names of parameters that behave as input or output parameters. For example:
    %include "typemaps.i"
    %apply int *INPUT {int *x, int *y};
    %apply int *OUTPUT {int *r};
    
    void add(int *x, int *y, int *r);
    void sub(int *x, int *y, int *r);
    void mul(int *x, int *y, int *r);
    ... etc ...
    

    Example

    The following example illustrates the use of these features for pointer extraction.

    Notes

    • Since pointers are used for so many different things (arrays, output values, etc...) the complexity of pointer handling can be as complicated as you want to make it.

    • More documentation on the typemaps.i and cpointer.i library files can be found in the SWIG user manual. The files also contain documentation.

    swig-3.0.2/Examples/go/pointer/Makefile0000664000175000017500000000077312343605122017655 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = pointer.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/pointer/pointer.c0000664000175000017500000000036112343605122020032 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void sub(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/go/enum/0000775000175000017500000000000012343605122015472 5ustar williamwilliamswig-3.0.2/Examples/go/enum/runme.go0000664000175000017500000000130112343605122017142 0ustar williamwilliampackage main import ( . "./example" "fmt" ) func main() { // Print out the value of some enums fmt.Println("*** color ***") fmt.Println(" RED = ", RED) fmt.Println(" BLUE = ", BLUE) fmt.Println(" GREEN = ", GREEN) fmt.Println("\n*** Foo::speed ***") fmt.Println(" Foo::IMPULSE = ", FooIMPULSE) fmt.Println(" Foo::WARP = ", FooWARP) fmt.Println(" Foo::LUDICROUS = ", FooLUDICROUS) fmt.Println("\nTesting use of enums with functions\n") Enum_test(RED, FooIMPULSE) Enum_test(BLUE, FooWARP) Enum_test(GREEN, FooLUDICROUS) fmt.Println("\nTesting use of enum with class method") f := NewFoo() f.Enum_test(FooIMPULSE) f.Enum_test(FooWARP) f.Enum_test(FooLUDICROUS) } swig-3.0.2/Examples/go/enum/example.h0000664000175000017500000000032612343605122017277 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/go/enum/enum.cxx0000664000175000017500000000151112343605122017160 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/go/enum/example.i0000664000175000017500000000021712343605122017277 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/go/enum/index.html0000664000175000017500000000170512343605122017472 0ustar williamwilliam SWIG:Examples:go:enum SWIG/Examples/go/enum/

    Wrapping enumerations

    This example tests SWIG's ability to wrap enumerations.

    • Enum values are expressed as constants or variables in GO.
    • If the enum is named, then that name, capitalized, as defined as a new type name for int. All the enum values will be defined to have that type.
    • If the enum is declared at global level, then the name in Go is simply the enum value, capitalized.
    • If the enum is declared within a C++ class or struct, then the name in Go is the capitalized name of the class or struct followed by the capitalized name of the enum value.


    swig-3.0.2/Examples/go/enum/Makefile0000664000175000017500000000101212343605122017124 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = enum.cxx TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/simple/0000775000175000017500000000000012343605122016017 5ustar williamwilliamswig-3.0.2/Examples/go/simple/runme.go0000664000175000017500000000064012343605122017474 0ustar williamwilliampackage main import ( "./example" "fmt" ) func main() { // Call our gcd() function x := 42 y := 105 g := example.Gcd(x, y) fmt.Println("The gcd of", x, "and", y, "is", g) // Manipulate the Foo global variable // Output its current value fmt.Println("Foo =", example.GetFoo()) // Change its value example.SetFoo(3.1415926) // See if the change took effect fmt.Println("Foo =", example.GetFoo()) } swig-3.0.2/Examples/go/simple/simple.c0000664000175000017500000000036712343605122017462 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/go/simple/example.i0000664000175000017500000000015212343605122017622 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/go/simple/index.html0000664000175000017500000000617212343605122020022 0ustar williamwilliam SWIG:Examples:go:simple SWIG/Examples/go/simple/

    Simple Go Example

    This example illustrates how you can hook Go to a very simple C program containing a function and a global variable.

    The C Code

    Suppose you have the following C code:
    /* File : example.c */
    
    /* A global variable */
    double Foo = 3.0;
    
    /* Compute the greatest common divisor of positive integers */
    int gcd(int x, int y) {
      int g;
      g = y;
      while (x > 0) {
        g = x;
        x = y % x;
        y = g;
      }
      return g;
    }
    

    The SWIG interface

    Here is a simple SWIG interface file:
    /* File: example.i */
    %module example
    
    extern int gcd(int x, int y);
    extern double Foo;
    

    Compilation

    These are the instructions if you are using 6g/8g rather than gccgo.
    1. Run swig -go example.i. This will create the three files example.go, example_gc.c, and example_wrap.c.
    2. Compile example.go using 6g or 8g; e.g., 6g example.go.
    3. Compile example_gc.c using 6c or 8c; e.g., 6c example_gc.c.
    4. Put the two object files together into an archive named example.a; e.g., gopack grc example.a example.6 example_gc.6.
    5. Compile the example_wrap.c file using your standard C compiler with the -fpic option; e.g., gcc -c -O -fpic example_wrap.c.
    6. Also compile the actual code, not generated by SWIG; e.g., gcc -c -O -fpic example.c.
    7. Put the gcc compiled object files into a shared library; e.g., gcc -shared -o example.so example_wrap.o example.o.
    8. Compile the program which demonstrates how to use the library; e.g., 6g runme.go.
    9. Link the program; e.g., 6l -o runme runme.6.
    10. Now you should have a program runme.

    Using the extension

    The Go program which demonstrates calling the C functions from Go is runme.go.

    Key points

    • Use the import statement to load your extension module from Go. For example:
      import "example"
      
    • C functions work just like Go functions. However, the function names are automatically capitalized in order to make the names visible from other Go packages. For example:
      g := example.Gcd(42,105)
      
      (If there are name conflicts, you can use the %rename directive in the .i file or the -rename option to Go to rename one or the other symbol).
    • C global variables are accessed using getter and setter functions. The getter function is named Get followed by the capitalized name of the C variable. The Setter function uses Set instead of Get.
      a = example.GetFoo()
      

    swig-3.0.2/Examples/go/simple/Makefile0000664000175000017500000000073012343605122017457 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = simple.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/constants/0000775000175000017500000000000012343605122016542 5ustar williamwilliamswig-3.0.2/Examples/go/constants/runme.go0000664000175000017500000000123712343605122020222 0ustar williamwilliampackage main import ( "./example" "fmt" ) func main() { fmt.Println("ICONST = ", example.ICONST, " (should be 42)") fmt.Println("FCONST = ", example.FCONST, " (should be 2.1828)") fmt.Printf("CCONST = %c (should be 'x')\n", example.CCONST) fmt.Printf("CCONST2 = %c(this should be on a new line)\n", example.CCONST2) fmt.Println("SCONST = ", example.SCONST, " (should be 'Hello World')") fmt.Println("SCONST2 = ", example.SCONST2, " (should be '\"Hello World\"')") fmt.Println("EXPR = ", example.EXPR, " (should be 48.5484)") fmt.Println("iconst = ", example.Iconst, " (should be 37)") fmt.Println("fconst = ", example.Fconst, " (should be 3.14)") } swig-3.0.2/Examples/go/constants/example.i0000664000175000017500000000113312343605122020345 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/go/constants/index.html0000664000175000017500000000313012343605122020534 0ustar williamwilliam SWIG:Examples:go:constants SWIG/Examples/go/constants/

    Wrapping C Constants

    When SWIG encounters C preprocessor macros and C declarations that look like constants, it creates a Go constant with an identical value. Click here to see a SWIG interface with some constant declarations in it.

    Accessing Constants from Go

    Click here for the section on constants in the SWIG and Go documentation.

    Click here to see a Go program that prints out the values of the constants contained in the above file.

    Key points

    • All names are capitalized to make them visible.
    • The values of preprocessor macros are converted into Go constants.
    • C string literals such as "Hello World" are converted into Go strings.
    • Macros that are not fully defined are simply ignored. For example:
      #define EXTERN extern
      
      is ignored because SWIG has no idea what type of variable this would be.

    • Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
    • Certain C declarations involving 'const' are also turned into Go constants.
    • The constants that appear in a SWIG interface file do not have to appear in any sort of matching C source file since the creation of a constant does not require linkage to a stored value (i.e., a value held in a C global variable or memory location).

    swig-3.0.2/Examples/go/constants/Makefile0000664000175000017500000000077512343605122020213 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/extend/0000775000175000017500000000000012343605122016015 5ustar williamwilliamswig-3.0.2/Examples/go/extend/runme.go0000664000175000017500000000545512343605122017503 0ustar williamwilliam// This file illustrates the cross language polymorphism using directors. package main import ( . "./example" "fmt" ) type CEO struct{} func (p *CEO) GetPosition() string { return "CEO" } func main() { // Create an instance of CEO, a class derived from the Go // proxy of the underlying C++ class. The calls to getName() // and getPosition() are standard, the call to getTitle() uses // the director wrappers to call CEO.getPosition(). e := NewDirectorManager(new(CEO), "Alice") fmt.Println(e.GetName(), " is a ", e.GetPosition()) fmt.Println("Just call her \"", e.GetTitle(), "\"") fmt.Println("----------------------") // Create a new EmployeeList instance. This class does not // have a C++ director wrapper, but can be used freely with // other classes that do. list := NewEmployeeList() // EmployeeList owns its items, so we must surrender ownership // of objects we add. // e.DisownMemory() list.AddEmployee(e) fmt.Println("----------------------") // Now we access the first four items in list (three are C++ // objects that EmployeeList's constructor adds, the last is // our CEO). The virtual methods of all these instances are // treated the same. For items 0, 1, and 2, all methods // resolve in C++. For item 3, our CEO, GetTitle calls // GetPosition which resolves in Go. The call to GetPosition // is slightly different, however, because of the overridden // GetPosition() call, since now the object reference has been // "laundered" by passing through EmployeeList as an // Employee*. Previously, Go resolved the call immediately in // CEO, but now Go thinks the object is an instance of class // Employee. So the call passes through the Employee proxy // class and on to the C wrappers and C++ director, eventually // ending up back at the Java CEO implementation of // getPosition(). The call to GetTitle() for item 3 runs the // C++ Employee::getTitle() method, which in turn calls // GetPosition(). This virtual method call passes down // through the C++ director class to the Java implementation // in CEO. All this routing takes place transparently. fmt.Println("(position, title) for items 0-3:") fmt.Println(" ", list.Get_item(0).GetPosition(), ", \"", list.Get_item(0).GetTitle(), "\"") fmt.Println(" ", list.Get_item(1).GetPosition(), ", \"", list.Get_item(1).GetTitle(), "\"") fmt.Println(" ", list.Get_item(2).GetPosition(), ", \"", list.Get_item(2).GetTitle(), "\"") fmt.Println(" ", list.Get_item(3).GetPosition(), ", \"", list.Get_item(3).GetTitle(), "\"") fmt.Println("----------------------") // Time to delete the EmployeeList, which will delete all the // Employee* items it contains. The last item is our CEO, // which gets destroyed as well. DeleteEmployeeList(list) fmt.Println("----------------------") // All done. fmt.Println("Go exit") } swig-3.0.2/Examples/go/extend/example.h0000664000175000017500000000260512343605122017624 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *get_item(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; swig-3.0.2/Examples/go/extend/example.i0000664000175000017500000000040312343605122017617 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_vector.i" %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; %include "example.h" swig-3.0.2/Examples/go/extend/extend.cxx0000664000175000017500000000006012343605122020024 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/go/extend/index.html0000664000175000017500000000075312343605122020017 0ustar williamwilliam SWIG:Examples:go:extend SWIG/Examples/go/extend/

    Extending a simple C++ class in Go

    This example illustrates the extending of a C++ class with cross language polymorphism.


    swig-3.0.2/Examples/go/extend/Makefile0000664000175000017500000000101412343605122017451 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = extend.cxx TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/reference/0000775000175000017500000000000012343605122016464 5ustar williamwilliamswig-3.0.2/Examples/go/reference/runme.go0000664000175000017500000000316012343605122020141 0ustar williamwilliam// This example illustrates the manipulation of C++ references in Java. package main import ( . "./example" "fmt" ) func main() { fmt.Println("Creating some objects:") a := NewVector(3, 4, 5) b := NewVector(10, 11, 12) fmt.Println(" Created ", a.Print()) fmt.Println(" Created ", b.Print()) // ----- Call an overloaded operator ----- // This calls the wrapper we placed around // // operator+(const Vector &a, const Vector &) // // It returns a new allocated object. fmt.Println("Adding a+b") c := Addv(a, b) fmt.Println(" a+b = " + c.Print()) // Because addv returns a reference, Addv will return a // pointer allocated using Go's memory allocator. That means // that it will be freed by Go's garbage collector, and we can // not use DeleteVector to release it. c = nil // ----- Create a vector array ----- fmt.Println("Creating an array of vectors") va := NewVectorArray(10) fmt.Println(" va = ", va) // ----- Set some values in the array ----- // These operators copy the value of Vector a and Vector b to // the vector array va.Set(0, a) va.Set(1, b) va.Set(2, Addv(a, b)) // Get some values from the array fmt.Println("Getting some array values") for i := 0; i < 5; i++ { fmt.Println(" va(", i, ") = ", va.Get(i).Print()) } // Watch under resource meter to check on this fmt.Println("Making sure we don't leak memory.") for i := 0; i < 1000000; i++ { c = va.Get(i % 10) } // ----- Clean up ----- This could be omitted. The garbage // collector would then clean up for us. fmt.Println("Cleaning up") DeleteVectorArray(va) DeleteVector(a) DeleteVector(b) } swig-3.0.2/Examples/go/reference/example.h0000664000175000017500000000064512343605122020275 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; friend Vector operator+(const Vector &a, const Vector &b); char *print(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/go/reference/example.i0000664000175000017500000000131012343605122020264 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module example %{ #include "example.h" %} class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.2/Examples/go/reference/index.html0000664000175000017500000000627612343605122020474 0ustar williamwilliam SWIG:Examples:go:reference SWIG/Examples/go/reference/

    C++ Reference Handling

    This example tests SWIG's handling of C++ references. A reference in C++ is much like a pointer. Go represents C++ classes as pointers which are stored in interface values. Therefore, a reference to a class in C++ simply becomes an object of the class type in Go. For types which are not classes, a reference in C++ is represented as a pointer in Go.

    Some examples

    References are most commonly used as function parameters. For example, you might have a function like this:
    Vector addv(const Vector &a, const Vector &b) {
       Vector result;
       result.x = a.x + b.x;
       result.y = a.y + b.y;
       result.z = a.z + b.z;
       return result;
    }
    
    In these cases, SWIG transforms everything into a pointer and creates a wrapper that looks like this in C++.
    Vector wrap_addv(Vector *a, Vector *b);
    
    or like this in Go:
    func Addv(arg1 Vector, arg2 Vector) Vector
    
    Occasionally, a reference is used as a return value of a function when the return result is to be used as an lvalue in an expression. The prototypical example is an operator like this:
    Vector &operator[](int index);
    
    or a method:
    Vector &get(int index);
    
    For functions returning references, a wrapper like this is created:
    Vector *wrap_Object_get(Object *self, int index) {
        Vector &result = self->get(index);
        return &result;
    }
    
    The following header file contains some class definitions with some operators and use of references.

    SWIG Interface

    SWIG does NOT support overloaded operators so it can not directly build an interface to the classes in the above file. However, a number of workarounds can be made. For example, an overloaded operator can be stuck behind a function call such as the addv function above. Array access can be handled with a pair of set/get functions like this:
    class VectorArray {
    public:
     ...
       %addmethods {
        Vector &get(int index) {
          return (*self)[index];
        }
        void set(int index, Vector &a) {
          (*self)[index] = a;
        }
       }
       ...
    }
    
    Click here to see a SWIG interface file with these additions.

    Sample Go program

    Click here to see a Go program that manipulates some C++ references.

    Notes:

    • C++ references primarily provide notational convenience for C++ source code. However, Go only supports the 'x.a' notation so it doesn't much matter.

    • When a program returns a reference, a pointer is returned. Unlike return by value, memory is not allocated to hold the return result.

    • SWIG has particular trouble handling various combinations of references and pointers. This is side effect of an old parsing scheme and type representation that will be replaced in future versions.

    swig-3.0.2/Examples/go/reference/reference.cxx0000664000175000017500000000161412343605122021150 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/go/reference/Makefile0000664000175000017500000000101712343605122020123 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = reference.cxx TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/check.list0000664000175000017500000000017612343605122016504 0ustar williamwilliam# see top-level Makefile.in callback class constants enum extend funcptr multimap pointer reference simple template variables swig-3.0.2/Examples/go/index.html0000664000175000017500000000467512343605122016537 0ustar williamwilliam SWIG:Examples:Go

    SWIG Go Examples

    The following examples illustrate the use of SWIG with Go.

    • simple. A minimal example showing how SWIG can be used to wrap a C function, a global variable, and a constant.
    • constants. This shows how preprocessor macros and certain C declarations are turned into constants.
    • variables. An example showing how to access C global variables from Go.
    • enum. Wrapping enumerations.
    • class. Wrapping a simple C++ class.
    • reference. C++ references.
    • pointer. Simple pointer handling.
    • funcptr. Pointers to functions.
    • template. C++ templates.
    • callback. C++ callbacks using directors.
    • extend. Polymorphism using directors.

    Compilation Issues

    • To create a Go extension, SWIG is run with the following options:
      % swig -go interface.i
      
    • On Unix the compilation of examples is done using the file Example/Makefile. This makefile performs a manual module compilation which is platform specific. When using the 6g or 8g compiler, the steps look like this (GNU/Linux):
      % swig -go interface.i
      % gcc -fpic -c interface_wrap.c
      % gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so 
      % 6g interface.go
      % 6c interface_gc.c
      % gopack grc interface.a interface.6 interface_gc.6
      % 6l program.6
      
    • When using the gccgo compiler, the steps look like this:
      % swig -go interface.i
      % gcc -c interface_wrap.c
      % gccgo -c interface.go
      % gccgo program.o interface.o interface_wrap.o
      

      Compatibility

      The examples have been extensively tested on the following platforms:
      • GNU/Linux
      All of the examples were last tested with the following configuration (10 May 2010):
      • Ubuntu Hardy
      • gcc-4.2.4
      Your mileage may vary. If you experience a problem, please let us know by contacting us on the mailing lists. swig-3.0.2/Examples/go/funcptr/0000775000175000017500000000000012343605122016207 5ustar williamwilliamswig-3.0.2/Examples/go/funcptr/funcptr.c0000664000175000017500000000037012343605122020034 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/go/funcptr/runme.go0000664000175000017500000000112512343605122017663 0ustar williamwilliampackage main import ( . "./example" "fmt" ) func main() { a := 37 b := 42 // Now call our C function with a bunch of callbacks fmt.Println("Trying some C callback functions") fmt.Println(" a = ", a) fmt.Println(" b = ", b) fmt.Println(" ADD(a,b) = ", Do_op(a, b, ADD)) fmt.Println(" SUB(a,b) = ", Do_op(a, b, SUB)) fmt.Println(" MUL(a,b) = ", Do_op(a, b, MUL)) fmt.Println("Here is what the C callback function classes are called in Go") fmt.Println(" ADD = ", ADD) fmt.Println(" SUB = ", SUB) fmt.Println(" MUL = ", MUL) } swig-3.0.2/Examples/go/funcptr/example.h0000664000175000017500000000026312343605122020014 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/go/funcptr/example.i0000664000175000017500000000056012343605122020015 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); swig-3.0.2/Examples/go/funcptr/index.html0000664000175000017500000000345412343605122020212 0ustar williamwilliam SWIG:Examples:go:funcptr SWIG/Examples/go/funcptr/

      Pointers to Functions

      Okay, just what in the heck does SWIG do with a declaration like this?

      int do_op(int a, int b, int (*op)(int, int));
      
      Well, it creates a wrapper as usual. Of course, that does raise some questions about the third argument (the pointer to a function).

      In this case, SWIG will wrap the function pointer as it does for all other pointers. However, in order to actually call this function from a Go program, you will need to pass some kind of C function pointer object. In C, this is easy, you just supply a function name as an argument like this:

      /* Some callback function */
      int add(int a, int b) {
         return a+b;
      } 
      ...
      int r = do_op(x,y,add);
      
      To make this work with SWIG, you will need to do a little extra work. Specifically, you need to create some function pointer objects using the %constant directive like this:
      %constant(int (*)(int,int)) ADD = add;
      
      Now, in a Go program, you would do this:
      int r = do_op(x,y, example.ADD)
      
      where example is the module name.

      An Example

      Here are some files that illustrate this with a simple example:

      Notes

      • The value of a function pointer must correspond to a function written in C or C++. It is not possible to pass an arbitrary Go function in as a substitute for a C function pointer.

      swig-3.0.2/Examples/go/funcptr/Makefile0000664000175000017500000000077312343605122017656 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = funcptr.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/multimap/0000775000175000017500000000000012343605122016356 5ustar williamwilliamswig-3.0.2/Examples/go/multimap/multimap.c0000664000175000017500000000164012343605122020353 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.2/Examples/go/multimap/runme.go0000664000175000017500000000072712343605122020041 0ustar williamwilliampackage main import ( . "./example" "fmt" ) func main() { // Call our gcd() function x := 42 y := 105 g := Gcd(x, y) fmt.Println("The gcd of ", x, " and ", y, " is ", g) // Call the gcdmain() function args := []string{"gcdmain", "42", "105"} Gcdmain(args) // Call the count function fmt.Println(Count("Hello World", 'l')) // Call the capitalize function capitalizeMe := []string{"hello world"} Capitalize(capitalizeMe) fmt.Println(capitalizeMe[0]) } swig-3.0.2/Examples/go/multimap/example.i0000664000175000017500000000413612343605122020167 0ustar williamwilliam/* File : example.i */ %module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} extern int gcd(int x, int y); %typemap(gotype) (int argc, char *argv[]) "[]string" %typemap(in) (int argc, char *argv[]) %{ { int i; _gostring_* a; $1 = $input.len; a = (_gostring_*) $input.array; $2 = (char **) malloc (($1 + 1) * sizeof (char *)); for (i = 0; i < $1; i++) { _gostring_ *ps = &a[i]; $2[i] = (char *) ps->p; } $2[i] = NULL; } %} %typemap(argout) (int argc, char *argv[]) "" /* override char *[] default */ %typemap(freearg) (int argc, char *argv[]) %{ free($2); %} extern int gcdmain(int argc, char *argv[]); %typemap(gotype) (char *bytes, int len) "string" %typemap(in) (char *bytes, int len) %{ $1 = $input.p; $2 = $input.n; %} extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a c string. A one * element Go string slice is used so that the string can be returned * modified. */ %typemap(gotype) (char *str, int len) "[]string" %typemap(in) (char *str, int len) %{ { _gostring_ *a; char *p; int n; a = (_gostring_*) $input.array; p = a[0].p; n = a[0].n; $1 = malloc(n + 1); $2 = n; memcpy($1, p, n); } %} /* Return the mutated string as a modified element in the array. */ %typemap(argout) (char *str, int len) %{ { _gostring_ *a; a = (_gostring_*) $input.array; a[0] = _swig_makegostring($1, $2); } %} %typemap(freearg) (char *str, int len) %{ free($1); %} extern void capitalize(char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) %{ { double a = $1*$1 + $2*$2; if (a > 1.0) { _swig_gopanic("$1_name and $2_name must be in unit circle"); return; } } %} extern void circle(double cx, double cy); swig-3.0.2/Examples/go/multimap/Makefile0000664000175000017500000000077412343605122020026 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = multimap.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/callback/0000775000175000017500000000000012343605122016262 5ustar williamwilliamswig-3.0.2/Examples/go/callback/runme.go0000664000175000017500000000144512343605122017743 0ustar williamwilliampackage main import ( . "./example" "fmt" ) func main() { fmt.Println("Adding and calling a normal C++ callback") fmt.Println("----------------------------------------") caller := NewCaller() callback := NewCallback() caller.SetCallback(callback) caller.Call() caller.DelCallback() callback = NewDirectorCallback(new(GoCallback)) fmt.Println() fmt.Println("Adding and calling a Go callback") fmt.Println("------------------------------------") caller.SetCallback(callback) caller.Call() caller.DelCallback() // Test that a double delete does not occur as the object has // already been deleted from the C++ layer. DeleteDirectorCallback(callback) fmt.Println() fmt.Println("Go exit") } type GoCallback struct{} func (p *GoCallback) Run() { fmt.Println("GoCallback.Run") } swig-3.0.2/Examples/go/callback/example.h0000664000175000017500000000102012343605122020057 0ustar williamwilliam/* File : example.h */ #include #include class Callback { public: virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } }; swig-3.0.2/Examples/go/callback/example.i0000664000175000017500000000031212343605122020063 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_string.i" /* turn on director wrapping Callback */ %feature("director") Callback; %include "example.h" swig-3.0.2/Examples/go/callback/callback.cxx0000664000175000017500000000006012343605122020536 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/go/callback/index.html0000664000175000017500000000416612343605122020266 0ustar williamwilliam SWIG:Examples:go:callback SWIG/Examples/go/callback/

      Implementing C++ callbacks in Go

      This example illustrates how to use directors to implement C++ callbacks in Go.

      Because Go and C++ use inheritance differently, you must call a different function to create a class which uses callbacks. Instead of calling the usual constructor function whose name is New followed by the capitalized name of the class, you call a function named NewDirector followed by the capitalized name of the class.

      The first argument to the NewDirector function is an instance of a type. The NewDirector function will return an interface value as usual. However, when calling any method on the returned value, the program will first check whether the value passed to NewDirector implements that method. If it does, the method will be called in Go. This is true whether the method is called from Go code or C++ code.

      Note that the Go code will be called with just the Go value, not the C++ value. If the Go code needs to call a C++ method on itself, you need to get a copy of the C++ object. This is typically done as follows:

      type Child struct { abi Parent }
      func (p *Child) ChildMethod() {
      	p.abi.ParentMethod()
      }
      func f() {
      	p := &Child{nil}
      	d := NewDirectorParent(p)
      	p.abi = d
      	...
      }
      
      In other words, we first create the Go value. We pass that to the NewDirector function to create the C++ value; this C++ value will be created with an association to the Go value. We then store the C++ value in the Go value, giving us the reverse association. That permits us to call parent methods from the child.

      To delete a director object, use the function DeleteDirector followed by the capitalized name of the class.


      swig-3.0.2/Examples/go/callback/Makefile0000664000175000017500000000101612343605122017720 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = callback.cxx TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/go/variables/0000775000175000017500000000000012343605122016476 5ustar williamwilliamswig-3.0.2/Examples/go/variables/runme.go0000664000175000017500000000410012343605122020146 0ustar williamwilliam// This example illustrates global variable access from Go. package main import ( "./example" "fmt" ) func main() { // Try to set the values of some global variables example.SetIvar(42) example.SetSvar(-31000) example.SetLvar(65537) example.SetUivar(123456) example.SetUsvar(61000) example.SetUlvar(654321) example.SetScvar(-13) example.SetUcvar(251) example.SetCvar('S') example.SetFvar(3.14159) example.SetDvar(2.1828) example.SetStrvar("Hello World") example.SetIptrvar(example.New_int(37)) example.SetPtptr(example.New_Point(37, 42)) example.SetName("Bill") // Now print out the values of the variables fmt.Println("Variables (values printed from Go)") fmt.Println("ivar =", example.GetIvar()) fmt.Println("svar =", example.GetSvar()) fmt.Println("lvar =", example.GetLvar()) fmt.Println("uivar =", example.GetUivar()) fmt.Println("usvar =", example.GetUsvar()) fmt.Println("ulvar =", example.GetUlvar()) fmt.Println("scvar =", example.GetScvar()) fmt.Println("ucvar =", example.GetUcvar()) fmt.Println("fvar =", example.GetFvar()) fmt.Println("dvar =", example.GetDvar()) fmt.Printf("cvar = %c\n", example.GetCvar()) fmt.Println("strvar =", example.GetStrvar()) fmt.Println("cstrvar =", example.GetCstrvar()) fmt.Println("iptrvar =", example.GetIptrvar()) fmt.Println("name =", example.GetName()) fmt.Println("ptptr =", example.GetPtptr(), example.Point_print(example.GetPtptr())) fmt.Println("pt =", example.GetPt(), example.Point_print(example.GetPt())) fmt.Println("\nVariables (values printed from C)") example.Print_vars() // This line would not compile: since status is marked with // %immutable, there is no SetStatus function. // fmt.Println("\nNow I'm going to try and modify some read only variables") // example.SetStatus(0) fmt.Println("\nI'm going to try and update a structure variable.\n") example.SetPt(example.GetPtptr()) fmt.Println("The new value is") example.Pt_print() fmt.Println("You should see the value", example.Point_print(example.GetPtptr())) } swig-3.0.2/Examples/go/variables/example.h0000664000175000017500000000007512343605122020304 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/go/variables/variables.c0000664000175000017500000000454012343605122020615 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/go/variables/example.i0000664000175000017500000000174512343605122020312 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/go/variables/index.html0000664000175000017500000000450512343605122020477 0ustar williamwilliam SWIG:Examples:go:variables SWIG/Examples/go/variables/

      Wrapping C Global Variables

      When a C global variable appears in an interface file, SWIG provides getter and setter functions for the variable. The getter function is named Get followed by the capitalized name of the variable. The setter variable starts with Set instead. The getter function takes no parameters and returns the value of the variable. The setter function takes a single parameter with the same type as the variable, and returns nothing.

      Click here to see a SWIG interface with some variable declarations in it.

      Manipulating Variables from Go

      For example, if the package is called example, the global variable
      double foo;
      
      will be accessed from Go as
      example.GetFoo();
      example.SetFoo(12.3);
      
      Click here to see the example program that updates and prints out the values of the variables using this technique.

      Key points

      • The name of the variable is capitalized.
      • When a global variable has the type "char *", SWIG manages it as a character string.
      • signed char and unsigned char are handled as small 8-bit integers.
      • String array variables such as 'char name[256]' are managed as Go strings, but when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
      • When structures and classes are used as global variables, they are mapped into pointers. Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global.

      Creating read-only variables

      The %immutable and %mutable directives can be used to specify a collection of read-only variables. A read only variable will have a getter function but no setter function. For example:
      %immutable;
      int    status;
      double blah;
      ...
      %mutable;
      
      The %immutable directive remains in effect until it is explicitly disabled using the %mutable directive.
      swig-3.0.2/Examples/go/variables/Makefile0000664000175000017500000000077512343605122020147 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = variables.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean swig-3.0.2/Examples/lua/0000775000175000017500000000000012343605122014702 5ustar williamwilliamswig-3.0.2/Examples/lua/embed2/0000775000175000017500000000000012343605122016040 5ustar williamwilliamswig-3.0.2/Examples/lua/embed2/embed2.c0000664000175000017500000001641512343605122017351 0ustar williamwilliam/* embed2.c some more tests for an embedded interpreter This will go a bit further as it will pass values to and from the lua code. It uses less of the SWIG code, and more of the raw lua API's What it will do is load the wrapped lib, load runme.lua and then call some functions. To make life easier, all the printf's have either [C] or [Lua] at the start so you can see where they are coming from. We will be using the luaL_dostring()/lua_dostring() function to call into lua */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) # define _SCL_SECURE_NO_DEPRECATE #endif #include #include #include #include #include #include #include #include #if LUA_VERSION_NUM > 501 #define lua_open luaL_newstate #endif /* the SWIG wrapped library */ extern int luaopen_example(lua_State*L); /* This is an example of how to call the Lua function int add(int,int) its very tedious, but gives you an idea of the issues involved. (look below for a better idea) */ int call_add(lua_State *L,int a,int b,int* res) { int top; /* ok, here we go: push a, push b, call 'add' check & return res */ top=lua_gettop(L); /* for later */ lua_getglobal(L, "add"); /* function to be called */ if (!lua_isfunction(L,-1)) { printf("[C] error: cannot find function 'add'\n"); lua_settop(L,top); return 0; } lua_pushnumber(L,a); lua_pushnumber(L,b); if (lua_pcall(L, 2, 1, 0) != 0) /* call function with 2 arguments and 1 result */ { printf("[C] error running function `add': %s\n",lua_tostring(L, -1)); lua_settop(L,top); return 0; } /* check results */ if (!lua_isnumber(L,-1)) { printf("[C] error: returned value is not a number\n"); lua_settop(L,top); return 0; } *res=(int)lua_tonumber(L,-1); lua_settop(L,top); /* reset stack */ return 1; } /* This is a variargs call function for calling from C into Lua. Original Code from Programming in Lua (PIL) by Roberto Ierusalimschy ISBN 85-903798-1-7 http://www.lua.org/pil/25.3.html This has been modified slightly to make it compile, and it's still a bit rough. But it gives the idea of how to make it work. */ int call_va (lua_State *L,const char *func, const char *sig, ...) { va_list vl; int narg, nres; /* number of arguments and results */ int top; top=lua_gettop(L); /* for later */ va_start(vl, sig); lua_getglobal(L, func); /* get function */ /* push arguments */ narg = 0; while (*sig) { /* push arguments */ switch (*sig++) { case 'd': /* double argument */ lua_pushnumber(L, va_arg(vl, double)); break; case 'i': /* int argument */ lua_pushnumber(L, va_arg(vl, int)); break; case 's': /* string argument */ lua_pushstring(L, va_arg(vl, char *)); break; case '>': goto endwhile; default: printf("invalid option (%c)\n", *(sig - 1)); goto fail; } narg++; /* do we need this?*/ /* luaL_checkstack(L, 1, "too many arguments"); */ } endwhile: /* do the call */ nres = (int)strlen(sig); /* number of expected results */ if (lua_pcall(L, narg, nres, 0) != 0) /* do the call */ { printf("error running function `%s': %s\n",func, lua_tostring(L, -1)); goto fail; } /* retrieve results */ nres = -nres; /* stack index of first result */ while (*sig) { /* get results */ switch (*sig++) { case 'd': /* double result */ if (!lua_isnumber(L, nres)) { printf("wrong result type\n"); goto fail; } *va_arg(vl, double *) = lua_tonumber(L, nres); break; case 'i': /* int result */ if (!lua_isnumber(L, nres)) { printf("wrong result type\n"); goto fail; } *va_arg(vl, int *) = (int)lua_tonumber(L, nres); break; case 's': /* string result */ if (!lua_isstring(L, nres)) { printf("wrong result type\n"); goto fail; } strcpy(va_arg(vl, char *),lua_tostring(L, nres));/* WARNING possible buffer overflow */ break; default: { printf("invalid option (%c)", *(sig - 1)); goto fail; } } nres++; } va_end(vl); lua_settop(L,top); /* reset stack */ return 1; /* ok */ fail: lua_settop(L,top); /* reset stack */ return 0; /* error */ } int main(int argc,char* argv[]) { lua_State *L; int ok; int res; char str[80]; printf("[C] Welcome to the simple embedded Lua example v2\n"); printf("[C] We are in C\n"); printf("[C] opening a Lua state & loading the libraries\n"); L=lua_open(); luaopen_base(L); luaopen_string(L); luaopen_math(L); printf("[C] now loading the SWIG wrappered library\n"); luaopen_example(L); printf("[C] all looks ok\n"); printf("\n"); if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) { printf("[C] ERROR: no lua file given on command line\n"); exit(3); } printf("[C] let's load the file '%s'\n", argv[1]); printf("[C] any lua code in this file will be executed\n"); if (luaL_loadfile(L, argv[1]) || lua_pcall(L, 0, 0, 0)) { printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1)); exit(3); } printf("[C] We are now back in C, all looks ok\n"); printf("\n"); printf("[C] let's call the Lua function 'add(1,1)'\n"); printf("[C] using the C function 'call_add'\n"); ok=call_add(L,1,1,&res); printf("[C] the function returned %d with value %d\n",ok,res); printf("\n"); printf("[C] let's do this rather easier\n"); printf("[C] we will call the same Lua function using a generic C function 'call_va'\n"); ok=call_va(L,"add","ii>i",1,1,&res); printf("[C] the function returned %d with value %d\n",ok,res); printf("\n"); printf("[C] we will now use the same generic C function to call 'append(\"cat\",\"dog\")'\n"); ok=call_va(L,"append","ss>s","cat","dog",str); printf("[C] the function returned %d with value %s\n",ok,str); printf("\n"); printf("[C] we can also make some bad calls to ensure the code doesn't fail\n"); printf("[C] calling adds(1,2)\n"); ok=call_va(L,"adds","ii>i",1,2,&res); printf("[C] the function returned %d with value %d\n",ok,res); printf("[C] calling add(1,'fred')\n"); ok=call_va(L,"add","is>i",1,"fred",&res); printf("[C] the function returned %d with value %d\n",ok,res); printf("\n"); printf("[C] Note: no protection if you mess up the va-args, this is C\n"); printf("\n"); printf("[C] Finally we will call the wrappered gcd function gdc(6,9):\n"); printf("[C] This will pass the values to Lua, then call the wrappered function\n"); printf(" Which will get the values from Lua, call the C code \n"); printf(" and return the value to Lua and eventually back to C\n"); printf("[C] Certainly not the best way to do it :-)\n"); ok=call_va(L,"gcd","ii>i",6,9,&res); printf("[C] the function returned %d with value %d\n",ok,res); printf("\n"); printf("[C] all finished, closing the lua state\n"); lua_close(L); return 0; } swig-3.0.2/Examples/lua/embed2/example.c0000664000175000017500000000052212343605122017636 0ustar williamwilliam/* File : example.c */ #include /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } void greeting() { printf("Hello from the C function 'greeting'\n"); } swig-3.0.2/Examples/lua/embed2/runme.lua0000664000175000017500000000131112343605122017665 0ustar williamwilliamprint "[lua] This is runme.lua" -- test program for embedded lua -- we do not need to load the library, as it was already in the interpreter -- but let's check anyway assert(type(example)=='table',"Don't appear to have loaded the example module") -- note: we will copy the functions from example table into global -- this will help us later for k,v in pairs(example) do _G[k]=v end -- our add function -- we will be calling this from C function add(a,b) print("[lua] this is function add(",a,b,")") c=a+b print("[lua] returning",c) return c end function append(a,b) print("[lua] this is function append(",a,b,")") c=a..b print("[lua] returning",c) return c end swig-3.0.2/Examples/lua/embed2/example.i0000664000175000017500000000020112343605122017636 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; extern void greeting(); %}swig-3.0.2/Examples/lua/embed2/Makefile0000664000175000017500000000122312343605122017476 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed2 SRCS = example.c INTERFACE = example.i LUA_INTERP = embed2.c LIBS = -lm # this is a little different to normal as we have our own special interpreter # which we want to static link check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean rm -f $(TARGET) swig-3.0.2/Examples/lua/arrays/0000775000175000017500000000000012343605122016203 5ustar williamwilliamswig-3.0.2/Examples/lua/arrays/example.c0000664000175000017500000000077312343605122020011 0ustar williamwilliam/* File : example.c */ #include /* we are using the qsort function, which needs a helper function to sort */ int compare_int(const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } void sort_int(int* arr, int len) { qsort(arr, len, sizeof(int), compare_int); } /* ditto doubles */ int compare_double(const void * a, const void * b) { return (int)( *(double*)a - *(double*)b ); } void sort_double(double* arr, int len) { qsort(arr, len, sizeof(double), compare_double); } swig-3.0.2/Examples/lua/arrays/runme.lua0000664000175000017500000000336112343605122020037 0ustar williamwilliam---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end -- a helper to print a Lua table function print_table(t) print(table.concat(t,",")) end -- a helper to print a C array function print_array(arr,len) for i=0,len-1 do io.write(example.int_getitem(arr,i),",") end io.write("\n") end math.randomseed(0) -- init random --[[ version 1: passing a C array to the code let's test call sort_int() this requires a C array, so is the hardest to use]] ARRAY_SIZE=10 arr=example.new_int(ARRAY_SIZE) for i=0,ARRAY_SIZE-1 do example.int_setitem(arr,i,math.random(1000)) end print "unsorted" print_array(arr,ARRAY_SIZE) example.sort_int(arr,ARRAY_SIZE) print "sorted" print_array(arr,ARRAY_SIZE) example.delete_int(arr) -- must delete it print "" --[[ version 2: using %luacode to write a helper a simpler way is to use a %luacode which is a lua function added into the module this can do the conversion for us so we can just add a lua table directly (what we do is move the lua code into the module instead) ]] t={} for i=1,ARRAY_SIZE do t[i]=math.random(1000) end print "unsorted" print_table(t) example.sort_int2(t) -- calls lua helper which then calls C print "sorted" print_table(t) print "" --[[ version 3: use a typemap this is the best way it uses the SWIG-Lua typemaps to do the work one item of note: the typemap creates a copy, rather than edit-in-place]] t={} for i=1,ARRAY_SIZE do t[i]=math.random(1000)/10 end print "unsorted" print_table(t) t=example.sort_double(t) -- replace t with the result print "sorted" print_table(t) swig-3.0.2/Examples/lua/arrays/example.i0000664000175000017500000000234712343605122020016 0ustar williamwilliam/* File : example.i */ %module example /* in this file there are two sorting functions and three different ways to wrap them. See the lua code for how they are called */ %include // array helpers // this declares a batch of function for manipulating C integer arrays %array_functions(int,int) // this adds some lua code directly into the module // warning: you need the example. prefix if you want it added into the module // addmittedly this code is a bit tedious, but its a one off effort %luacode { function example.sort_int2(t) local len=table.maxn(t) -- the len local arr=example.new_int(len) for i=1,len do example.int_setitem(arr,i-1,t[i]) -- note: C index is one less then lua indea end example.sort_int(arr,len) -- call the fn -- copy back for i=1,len do t[i]=example.int_getitem(arr,i-1) -- note: C index is one less then lua indea end example.delete_int(arr) -- must delete it end } // this way uses the SWIG-Lua typemaps to do the conversion for us // the %apply command states to apply this wherever the argument signature matches %include %apply (double *INOUT,int) {(double* arr,int len)}; %inline %{ extern void sort_int(int* arr, int len); extern void sort_double(double* arr, int len); %} swig-3.0.2/Examples/lua/arrays/Makefile0000664000175000017500000000102412343605122017640 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/funcptr3/0000775000175000017500000000000012343605122016446 5ustar williamwilliamswig-3.0.2/Examples/lua/funcptr3/example.c0000664000175000017500000000037012343605122020245 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/lua/funcptr3/runme.lua0000664000175000017500000000262412343605122020303 0ustar williamwilliam---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end a = 37 b = 42 -- Now call our C function print("Trying some C functions") print(" a =", a) print(" b =", b) print(" add(a,b) =", example.add(a,b)) print(" sub(a,b) =", example.sub(a,b)) print(" mul(a,b) =", example.mul(a,b)) print("Calling them using the my_func()") print(" add(a,b) =", example.callback(a,b,example.add)) print(" sub(a,b) =", example.callback(a,b,example.sub)) print(" mul(a,b) =", example.callback(a,b,example.mul)) print("Now let us write our own function") function foo(a,b) return 101 end print(" foo(a,b) =", example.callback(a,b,foo)) print("Now let us try something that will fail") local ok,c=pcall(example.callback,a,b,print) if ok==false then print("this failed as expected, error:",c) else print("oops, that worked! result:",c) end -- part2 stored function print("trying a stored fn") print("the_func=",example.the_func) print("setting to print") example.the_func=print print("the_func=",example.the_func) print("call_the_func(5)") example.call_the_func(5) function bar(i) print("bar",i) end print("setting to bar") example.the_func=bar print("call_the_func(5)") example.call_the_func(5) swig-3.0.2/Examples/lua/funcptr3/example.h0000664000175000017500000000026312343605122020253 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/lua/funcptr3/example.i0000664000175000017500000000306712343605122020261 0ustar williamwilliam/* File : example.i */ /* This demonstrates how to pass a lua function, into some C code and then call it. There are two examples, the first is as a parameter, the second as a global variable. */ %module example %{ #include "example.h" %} /* the extra wrappers for lua functions, see SWIG/Lib/lua/lua_fnptr.i for more details */ %include "lua_fnptr.i" /* these are a bunch of C functions which we want to be able to call from lua */ extern int add(int,int); extern int sub(int,int); extern int mul(int,int); /* this function takes a lua function as a parameter and calls it. As this is takes a lua fn it needs lua code */ %inline %{ int callback(int a, int b, SWIGLUA_FN fn) { SWIGLUA_FN_GET(fn); lua_pushnumber(fn.L,a); lua_pushnumber(fn.L,b); lua_call(fn.L,2,1); /* 2 in, 1 out */ return (int)luaL_checknumber(fn.L,-1); } %} /****************** Second code uses a stored reference. *******************/ %inline %{ /* note: this is not so good to just have it as a raw ref people could set anything to this a better solution would to be to have a fn which wants a SWIGLUA_FN, then checks the type & converts to a SWIGLUA_REF. */ SWIGLUA_REF the_func={0,0}; void call_the_func(int a) { int i; if (the_func.L==0){ printf("the_func is zero\n"); return; } swiglua_ref_get(&the_func); if (!lua_isfunction(the_func.L,-1)) { printf("the_func is not a function\n"); return; } lua_pop(the_func.L,1); /* tidy stack */ for(i=0;i #include #include #include #include #include #if LUA_VERSION_NUM > 501 #define lua_open luaL_newstate #endif /* the SWIG wrappered library */ extern int luaopen_example(lua_State*L); /* a really simple way of calling lua from C just give it a lua state & a string to execute Unfortunately lua keeps changing its API's. In lua 5.0.X it's lua_dostring() In lua 5.1.X it's luaL_dostring() so we have a few extra compiles */ int dostring(lua_State *L, char* str) { int ok; #if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501)) ok=luaL_dostring(L,str); /* looks like this is lua 5.1.X or later, good */ #else ok=lua_dostring(L,str); /* might be lua 5.0.x, using lua_dostring */ #endif if (ok!=0) printf("[C] ERROR in dostring: %s\n",lua_tostring(L,-1)); return ok; } int main(int argc,char* argv[]) { lua_State *L; int ok; printf("[C] Welcome to the simple embedded lua example\n"); printf("[C] We are in C\n"); printf("[C] opening a lua state & loading the libraries\n"); L=lua_open(); luaopen_base(L); luaopen_string(L); luaopen_math(L); printf("[C] now loading the SWIG wrapped library\n"); luaopen_example(L); printf("[C] all looks ok\n"); printf("\n"); if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) { printf("[C] ERROR: no lua file given on command line\n"); exit(3); } printf("[C] let's load the file '%s'\n", argv[1]); printf("[C] any lua code in this file will be executed\n"); if (luaL_loadfile(L, argv[1]) || lua_pcall(L, 0, 0, 0)) { printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1)); exit(3); } printf("[C] We are now back in C, all looks ok\n"); printf("\n"); printf("[C] let's call the function 'do_tests()'\n"); ok=dostring(L,"do_tests()"); printf("[C] We are back in C, the dostring() function returned %d\n",ok); printf("\n"); printf("[C] Let's call lua again, but create an error\n"); ok=dostring(L,"no_such_function()"); printf("[C] We are back in C, the dostring() function returned %d\n",ok); printf("[C] it should also have returned 1 and printed an error message\n"); printf("\n"); printf("[C] Let's call lua again, calling the greeting function\n"); ok=dostring(L,"call_greeting()"); printf("[C] This was C=>Lua=>C (getting a bit complex)\n"); printf("\n"); printf("[C] all finished, closing the lua state\n"); lua_close(L); return 0; } swig-3.0.2/Examples/lua/embed/example.c0000664000175000017500000000052212343605122017554 0ustar williamwilliam/* File : example.c */ #include /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } void greeting() { printf("Hello from the C function 'greeting'\n"); } swig-3.0.2/Examples/lua/embed/runme.lua0000664000175000017500000000176112343605122017614 0ustar williamwilliamprint "[lua] This is runme.lua" -- test program for embedded lua -- we do not need to load the library, as it was already in the interpreter -- but let's check anyway assert(type(example)=='table',"Don't appear to have loaded the example module") -- a test function to run the tests function do_tests() print("[lua] We are now in Lua, inside the do_tests() function") print("[lua] We will be calling example.gcd() and changing example.Foo") -- Call our gcd() function x = 42 y = 105 g = example.gcd(x,y) print("[lua] The gcd of",x,"and",y,"is",g) -- Manipulate the Foo global variable -- Output its current value print("[lua] Foo = ", example.Foo) -- Change its value example.Foo = 3.1415926 -- See if the change took effect print("[lua] Foo = ", example.Foo) print("[lua] ending the do_tests() function") end function call_greeting() print("[lua] We are now in Lua, inside the call_greeting() function") example.greeting() print("[lua] ending the call_greeting() function") end swig-3.0.2/Examples/lua/embed/example.i0000664000175000017500000000020112343605122017554 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; extern void greeting(); %}swig-3.0.2/Examples/lua/embed/Makefile0000664000175000017500000000122112343605122017412 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed SRCS = example.c INTERFACE = example.i LUA_INTERP = embed.c LIBS = -lm # this is a little different to normal as we have our own special interpreter # which we want to static link check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean rm -f $(TARGET) swig-3.0.2/Examples/lua/embed3/0000775000175000017500000000000012343605122016041 5ustar williamwilliamswig-3.0.2/Examples/lua/embed3/runme.lua0000664000175000017500000000210312343605122017666 0ustar williamwilliamprint "[lua] This is runme.lua" -- test program for embedded lua -- we do not need to load the library, as it was already in the interpreter -- but let's check anyway assert(type(example)=='table',"Don't appear to have loaded the example module. Do not run this file directly, run the embed3 executable") print "[lua] looking to see if we have a pointer to the engine" if type(pEngine)=="userdata" then print "[lua] looks good" else print "[lua] nope, no signs of it" end -- the embedded program expects a function void onEvent(Event) -- this is it function onEvent(e) print("[Lua] onEvent with event",e.mType) -- let's do something with the Engine -- nothing clever, but ... if e.mType==example.Event_STARTUP then pEngine:start() elseif e.mType==example.Event_KEYPRESS then pEngine:accelerate(0.4) elseif e.mType==example.Event_MOUSEPRESS then pEngine:decelerate(0.4) elseif e.mType==example.Event_SHUTDOWN then pEngine:stop() else error("unknown event type") end print("[Lua] ending onEvent") endswig-3.0.2/Examples/lua/embed3/example.h0000664000175000017500000000065012343605122017646 0ustar williamwilliam/* File : example.h */ /* This is some kind of engine of some kind we will give it some dummy methods for Lua to call*/ class Engine { public: void start(); void stop(); void accelerate(float f); void decelerate(float f); }; /* We also want to pass some events to Lua, so let's have a few classes to do this. */ class Event { public: enum {STARTUP,KEYPRESS,MOUSEPRESS,SHUTDOWN} mType; // etc }; swig-3.0.2/Examples/lua/embed3/example.i0000664000175000017500000000013112343605122017641 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include "example.h" swig-3.0.2/Examples/lua/embed3/Makefile0000664000175000017500000000143412343605122017503 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed3 SRCS = example.cpp INTERFACE = example.i LUA_INTERP = embed3.cpp # this is a little different to normal as we have our own special interpreter # which we want to static link # we also need the external runtime, so we can get access to certain internals of SWIG check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: $(SWIG) -c++ -lua $(SWIGOPT) -external-runtime swigluarun.h $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean rm -f swigluarun.h $(TARGET) swig-3.0.2/Examples/lua/embed3/example.cpp0000664000175000017500000000055712343605122020207 0ustar williamwilliam/* File : example.cpp */ #include #include "example.h" void Engine::start() { printf("[C++] Engine::start()\n"); } void Engine::stop() { printf("[C++] Engine::stop()\n"); } void Engine::accelerate(float f) { printf("[C++] Engine::accelerate(%f)\n",f); } void Engine::decelerate(float f) { printf("[C++] Engine::decelerate(%f)\n",f); } swig-3.0.2/Examples/lua/embed3/embed3.cpp0000664000175000017500000001174112343605122017710 0ustar williamwilliam/* embed3.cpp A C++ embedded interpreter This will register a C++ class with Lua, and then call a Lua function passing C++ objects to this function. */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) # define _SCL_SECURE_NO_DEPRECATE #endif #include #include #include #include extern "C" { #include #include #include } #if LUA_VERSION_NUM > 501 #define lua_open luaL_newstate #endif /* The SWIG external runtime is generated by using. swig -lua -externalruntime swigluarun.h It contains useful function used by SWIG in its wrapper SWIG_TypeQuery() SWIG_NewPointerObj() */ #include "swigluarun.h" // the SWIG external runtime /* the SWIG wrapped library */ extern "C" int luaopen_example(lua_State*L); // the code itself #include "example.h" // this code pushes a C++ pointer as well as the SWIG type onto the Lua stack bool push_pointer(lua_State*L, void* ptr, const char* type_name, int owned = 0) { // task 1: get the object 'type' which is registered with SWIG // you need to call SWIG_TypeQuery() with the class name // (normally, just look in the wrapper file to get this) swig_type_info * pTypeInfo = SWIG_TypeQuery(L, type_name); if (pTypeInfo == 0) return false; // error // task 2: push the pointer to the Lua stack // this requires a pointer & the type // the last param specifies if Lua is responsible for deleting the object SWIG_NewPointerObj(L, ptr, pTypeInfo, owned); return true; } /* This is an example of how to call the Lua function void onEvent(Event e) its very tedious, but gives you an idea of the issues involed. */ int call_onEvent(lua_State *L, Event e) { int top; /* ok, here we go: push a, push b, call 'add' check & return res */ top = lua_gettop(L); /* for later */ lua_getglobal(L, "onEvent"); /* function to be called */ if (!lua_isfunction(L, -1)) { printf("[C++] error: cannot find function 'OnEvent'\n"); lua_settop(L, top); // reset return 0; } // push the event object push_pointer(L, &e, "Event *", 0); if (lua_pcall(L, 1, 0, 0) != 0) /* call function with 1 arguments and no result */ { printf("[C++] error running function `OnEvent': %s\n", lua_tostring(L, -1)); lua_settop(L, top); // reset return 0; } lua_settop(L, top); /* reset stack */ return 1; // ok } int main(int argc, char* argv[]) { printf("[C++] Welcome to the simple embedded Lua example v3\n"); printf("[C++] We are in C++\n"); printf("[C++] opening a Lua state & loading the libraries\n"); lua_State *L = lua_open(); luaopen_base(L); luaopen_string(L); luaopen_math(L); printf("[C++] now loading the SWIG wrappered library\n"); luaopen_example(L); printf("[C++] all looks ok\n"); printf("\n"); printf("[C++] let's create an Engine and pass a pointer to Lua\n"); Engine engine; /* this code will pass a pointer into lua, but C++ still owns the object this is a little tedious, to do, but let's do it we need to pass the pointer (obviously), the type name and a flag which states if Lua should delete the pointer once its finished with it The type name is a class name string which is registered with SWIG (normally, just look in the wrapper file to get this) in this case we don't want Lua to delete the pointer so the ownership flag is 0 */ push_pointer(L,&engine,"Engine *",0); lua_setglobal(L, "pEngine"); // set as global variable if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) { printf("[C++] ERROR: no lua file given on command line\n"); exit(3); } printf("[C++] now let's load the file '%s'\n", argv[1]); printf("[C++] any lua code in this file will be executed\n"); if (luaL_loadfile(L, argv[1]) || lua_pcall(L, 0, 0, 0)) { printf("[C++] ERROR: cannot run lua file: %s",lua_tostring(L, -1)); exit(3); } printf("[C++] We are now back in C++, all looks ok\n"); printf("\n"); printf("[C++] Let's call the Lua function onEvent(e)\n"); printf("[C++] We will give it different events, as we wish\n"); printf("[C++] Starting with STARTUP\n"); Event ev; ev.mType = Event::STARTUP; call_onEvent(L, ev); printf("[C++] ok\n"); printf("[C++] now we will try MOUSEPRESS,KEYPRESS,MOUSEPRESS\n"); ev.mType = Event::MOUSEPRESS; call_onEvent(L, ev); ev.mType = Event::KEYPRESS; call_onEvent(L, ev); ev.mType = Event::MOUSEPRESS; call_onEvent(L, ev); printf("[C++] ok\n"); printf("[C++] Finally we will SHUTDOWN\n"); ev.mType = Event::SHUTDOWN; call_onEvent(L, ev); printf("[C++] ok\n"); printf("\n"); printf("[C++] all finished, closing the lua state\n"); lua_close(L); return 0; } swig-3.0.2/Examples/lua/functest/0000775000175000017500000000000012343605122016535 5ustar williamwilliamswig-3.0.2/Examples/lua/functest/example.c0000664000175000017500000000041312343605122020332 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; int add1(int x, int y) { return x+y; } void add2(int x, int *y, int *z) { *z = x+*y; } int add3(int x, int y, int *z) { *z = x-y; return x+y; } void add4(int x, int *y) { *y += x; } swig-3.0.2/Examples/lua/functest/runme.lua0000664000175000017500000000122512343605122020366 0ustar williamwilliam---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end x,y = 42,105 print("add1 - simple arg passing and single return value -- ") print(example.add1(x,y)) print("add2 - pointer arg passing and single return value through pointer arg -- ") print(example.add2(x,y)) print("add3 - simple arg passing and double return value through return and ptr arg -- ") print(example.add3(x,y)) print("add4 - dual use arg and return value -- ") print(example.add4(x,y)) swig-3.0.2/Examples/lua/functest/example.i0000664000175000017500000000067012343605122020345 0ustar williamwilliam/* File : example.i */ %module example %include "typemaps.i" %inline %{ extern int add1(int x, int y); /* return x+y -- basic function test */ extern void add2(int x, int *INPUT, int *OUTPUT); /* *z = x+*y -- argin and argout test */ extern int add3(int x, int y, int *OUTPUT); /* return x+y, *z=x-y -- returning 2 values */ extern void add4(int x, int *INOUT); /* *y += x -- INOUT dual purpose variable */ %} swig-3.0.2/Examples/lua/functest/Makefile0000664000175000017500000000104112343605122020171 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/class/0000775000175000017500000000000012343605122016007 5ustar williamwilliamswig-3.0.2/Examples/lua/class/runme.lua0000664000175000017500000000245712343605122017650 0ustar williamwilliam-- file: runme.lua -- This file illustrates class C++ interface generated -- by SWIG. ---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end ----- Object creation ----- print("Creating some objects:") c = example.Circle(10) print(" Created circle", c) s = example.Square(10) print(" Created square", s) ----- Access a static member ----- print("\nA total of",example.Shape_nshapes,"shapes were created") ----- Member data access ----- -- Set the location of the object c.x = 20 c.y = 30 s.x = -10 s.y = 5 print("\nHere is their current position:") print(string.format(" Circle = (%f, %f)",c.x,c.y)) print(string.format(" Square = (%f, %f)",s.x,s.y)) ----- Call some methods ----- print("\nHere are some properties of the shapes:") for _,o in pairs({c,s}) do print(" ", o) print(" area = ", o:area()) print(" perimeter = ", o:perimeter()) end print("\nGuess I'll clean up now") -- Note: this invokes the virtual destructor c=nil s=nil -- call gc to make sure they are collected collectgarbage() print(example.Shape_nshapes,"shapes remain") print "Goodbye" swig-3.0.2/Examples/lua/class/example.h0000664000175000017500000000107612343605122017617 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/lua/class/example.i0000664000175000017500000000021512343605122017612 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/lua/class/example.cxx0000664000175000017500000000065012343605122020167 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/lua/class/Makefile0000664000175000017500000000107312343605122017450 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/pointer/0000775000175000017500000000000012343605122016362 5ustar williamwilliamswig-3.0.2/Examples/lua/pointer/example.c0000664000175000017500000000036112343605122020161 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void sub(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/lua/pointer/runme.lua0000664000175000017500000000233212343605122020213 0ustar williamwilliam---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end -- 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(" a = "..tostring(a)) print(" b = "..tostring(b)) print(" c = "..tostring(c)) -- Call the add() function with some pointers example.add(a,b,c) -- Now get the result r = example.intp_value(c) print(" 37 + 42 = "..r) -- Clean up the pointers -- since this is C-style pointers you must clean it up example.delete_intp(a) example.delete_intp(b) example.delete_intp(c) -- Now try the typemap library -- 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) -- Now try the version with multiple return values print("Testing multiple return values") q,r = example.divide(42,37) print(" 42/37 = "..q.." remainder "..r) swig-3.0.2/Examples/lua/pointer/example.i0000664000175000017500000000115512343605122020171 0ustar williamwilliam/* File : example.i */ %module example %{ #include %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ %inline %{ extern void add(int *x, int *y, int *result); %} %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); %{ extern void sub(int *, int *, int *); %} /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; %inline %{ extern int divide(int n, int d, int *r); %} swig-3.0.2/Examples/lua/pointer/Makefile0000664000175000017500000000104112343605122020016 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/lua.c0000664000175000017500000002335512343605122015637 0ustar williamwilliam/* ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ #include #include #include #include #define lua_c #include "lua.h" #include "lauxlib.h" #include "lualib.h" /* ** generic extra include file */ #ifdef LUA_USERCONFIG #include LUA_USERCONFIG #endif /* ** definition of `isatty' */ #ifdef _POSIX_C_SOURCE #include #define stdin_is_tty() isatty(0) #else #define stdin_is_tty() 1 /* assume stdin is a tty */ #endif #ifndef PROMPT #define PROMPT "> " #endif #ifndef PROMPT2 #define PROMPT2 ">> " #endif #ifndef PROGNAME #define PROGNAME "lua" #endif #ifndef lua_userinit #define lua_userinit(L) openstdlibs(L) #endif #ifndef LUA_EXTRALIBS #define LUA_EXTRALIBS /* empty */ #endif static lua_State *L = NULL; static const char *progname = PROGNAME; extern int Example_Init(lua_State* L); static const luaL_reg lualibs[] = { {"base", luaopen_base}, {"table", luaopen_table}, {"io", luaopen_io}, {"string", luaopen_string}, {"math", luaopen_math}, {"debug", luaopen_debug}, {"loadlib", luaopen_loadlib}, /* add your libraries here */ {"example", Example_Init}, LUA_EXTRALIBS {NULL, NULL} }; static void lstop (lua_State *l, lua_Debug *ar) { (void)ar; /* unused arg. */ lua_sethook(l, NULL, 0, 0); luaL_error(l, "interrupted!"); } static void laction (int i) { signal(i, SIG_DFL); /* if another SIGINT happens before lstop, terminate process (default action) */ lua_sethook(L, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); } static void print_usage (void) { fprintf(stderr, "usage: %s [options] [script [args]].\n" "Available options are:\n" " - execute stdin as a file\n" " -e stat execute string `stat'\n" " -i enter interactive mode after executing `script'\n" " -l name load and run library `name'\n" " -v show version information\n" " -- stop handling options\n" , progname); } static void l_message (const char *pname, const char *msg) { if (pname) fprintf(stderr, "%s: ", pname); fprintf(stderr, "%s\n", msg); } static int report (int status) { const char *msg; if (status) { msg = lua_tostring(L, -1); if (msg == NULL) msg = "(error with no message)"; l_message(progname, msg); lua_pop(L, 1); } return status; } static int lcall (int narg, int clear) { int status; int base = lua_gettop(L) - narg; /* function index */ lua_pushliteral(L, "_TRACEBACK"); lua_rawget(L, LUA_GLOBALSINDEX); /* get traceback function */ lua_insert(L, base); /* put it under chunk and args */ signal(SIGINT, laction); status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); signal(SIGINT, SIG_DFL); lua_remove(L, base); /* remove traceback function */ return status; } static void print_version (void) { l_message(NULL, LUA_VERSION " " LUA_COPYRIGHT); } static void getargs (char *argv[], int n) { int i; lua_newtable(L); for (i=0; argv[i]; i++) { lua_pushnumber(L, i - n); lua_pushstring(L, argv[i]); lua_rawset(L, -3); } /* arg.n = maximum index in table `arg' */ lua_pushliteral(L, "n"); lua_pushnumber(L, i-n-1); lua_rawset(L, -3); } static int docall (int status) { if (status == 0) status = lcall(0, 1); return report(status); } static int file_input (const char *name) { return docall(luaL_loadfile(L, name)); } static int dostring (const char *s, const char *name) { return docall(luaL_loadbuffer(L, s, strlen(s), name)); } static int load_file (const char *name) { lua_pushliteral(L, "require"); lua_rawget(L, LUA_GLOBALSINDEX); if (!lua_isfunction(L, -1)) { /* no `require' defined? */ lua_pop(L, 1); return file_input(name); } else { lua_pushstring(L, name); return report(lcall(1, 1)); } } /* ** this macro can be used by some `history' system to save lines ** read in manual input */ #ifndef lua_saveline #define lua_saveline(L,line) /* empty */ #endif /* ** this macro defines a function to show the prompt and reads the ** next line for manual input */ #ifndef lua_readline #define lua_readline(L,prompt) readline(L,prompt) /* maximum length of an input line */ #ifndef MAXINPUT #define MAXINPUT 512 #endif static int readline (lua_State *l, const char *prompt) { static char buffer[MAXINPUT]; if (prompt) { fputs(prompt, stdout); fflush(stdout); } if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 0; /* read fails */ else { lua_pushstring(l, buffer); return 1; } } #endif static const char *get_prompt (int firstline) { const char *p = NULL; lua_pushstring(L, firstline ? "_PROMPT" : "_PROMPT2"); lua_rawget(L, LUA_GLOBALSINDEX); p = lua_tostring(L, -1); if (p == NULL) p = (firstline ? PROMPT : PROMPT2); lua_pop(L, 1); /* remove global */ return p; } static int incomplete (int status) { if (status == LUA_ERRSYNTAX && strstr(lua_tostring(L, -1), "near `'") != NULL) { lua_pop(L, 1); return 1; } else return 0; } static int load_string (void) { int status; lua_settop(L, 0); if (lua_readline(L, get_prompt(1)) == 0) /* no input? */ return -1; if (lua_tostring(L, -1)[0] == '=') { /* line starts with `=' ? */ lua_pushfstring(L, "return %s", lua_tostring(L, -1)+1);/* `=' -> `return' */ lua_remove(L, -2); /* remove original line */ } for (;;) { /* repeat until gets a complete line */ status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); if (!incomplete(status)) break; /* cannot try to add lines? */ if (lua_readline(L, get_prompt(0)) == 0) /* no more input? */ return -1; lua_concat(L, lua_gettop(L)); /* join lines */ } lua_saveline(L, lua_tostring(L, 1)); lua_remove(L, 1); /* remove line */ return status; } static void manual_input (void) { int status; const char *oldprogname = progname; progname = NULL; while ((status = load_string()) != -1) { if (status == 0) status = lcall(0, 0); report(status); if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ lua_getglobal(L, "print"); lua_insert(L, 1); if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) l_message(progname, lua_pushfstring(L, "error calling `print' (%s)", lua_tostring(L, -1))); } } lua_settop(L, 0); /* clear stack */ fputs("\n", stdout); progname = oldprogname; } static int handle_argv (char *argv[], int *interactive) { if (argv[1] == NULL) { /* no more arguments? */ if (stdin_is_tty()) { print_version(); manual_input(); } else file_input(NULL); /* executes stdin as a file */ } else { /* other arguments; loop over them */ int i; for (i = 1; argv[i] != NULL; i++) { if (argv[i][0] != '-') break; /* not an option? */ switch (argv[i][1]) { /* option */ case '-': { /* `--' */ if (argv[i][2] != '\0') { print_usage(); return 1; } i++; /* skip this argument */ goto endloop; /* stop handling arguments */ } case '\0': { file_input(NULL); /* executes stdin as a file */ break; } case 'i': { *interactive = 1; break; } case 'v': { print_version(); break; } case 'e': { const char *chunk = argv[i] + 2; if (*chunk == '\0') chunk = argv[++i]; if (chunk == NULL) { print_usage(); return 1; } if (dostring(chunk, "=") != 0) return 1; break; } case 'l': { const char *filename = argv[i] + 2; if (*filename == '\0') filename = argv[++i]; if (filename == NULL) { print_usage(); return 1; } if (load_file(filename)) return 1; /* stop if file fails */ break; } case 'c': { l_message(progname, "option `-c' is deprecated"); break; } case 's': { l_message(progname, "option `-s' is deprecated"); break; } default: { print_usage(); return 1; } } } endloop: if (argv[i] != NULL) { const char *filename = argv[i]; getargs(argv, i); /* collect arguments */ lua_setglobal(L, "arg"); return file_input(filename); /* stop scanning arguments */ } } return 0; } static void openstdlibs (lua_State *l) { const luaL_reg *lib = lualibs; for (; lib->func; lib++) { lib->func(l); /* open library */ lua_settop(l, 0); /* discard any results */ } } static int handle_luainit (void) { const char *init = getenv("LUA_INIT"); if (init == NULL) return 0; /* status OK */ else if (init[0] == '@') return file_input(init+1); else return dostring(init, "=LUA_INIT"); } struct Smain { int argc; char **argv; int status; }; static int pmain (lua_State *l) { struct Smain *s = (struct Smain *)lua_touserdata(l, 1); int status; int interactive = 0; if (s->argv[0] && s->argv[0][0]) progname = s->argv[0]; L = l; lua_userinit(l); /* open libraries */ status = handle_luainit(); if (status == 0) { status = handle_argv(s->argv, &interactive); if (status == 0 && interactive) manual_input(); } s->status = status; return 0; } int main (int argc, char *argv[]) { int status; struct Smain s; lua_State *l = lua_open(); /* create state */ if (l == NULL) { l_message(argv[0], "cannot create state: not enough memory"); return EXIT_FAILURE; } s.argc = argc; s.argv = argv; status = lua_cpcall(l, &pmain, &s); report(status); lua_close(l); return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; } swig-3.0.2/Examples/lua/dual/0000775000175000017500000000000012343605122015627 5ustar williamwilliamswig-3.0.2/Examples/lua/dual/example.i0000664000175000017500000000013512343605122017433 0ustar williamwilliam/* File : example.i */ %module example %inline %{ struct Foo{ int i; }; %} swig-3.0.2/Examples/lua/dual/example2.i0000664000175000017500000000012212343605122017511 0ustar williamwilliam/* File : example2.i */ %module example2 %inline %{ struct Bar{ int i; }; %} swig-3.0.2/Examples/lua/dual/Makefile0000664000175000017500000000150312343605122017266 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = dual GENCXXSRCS = example2_wrap.cxx INTERFACE = dual.i LUA_INTERP = dual.cpp # This is a little different to normal as we need to static link two modules and a custom interpreter # We need the external runtime, then swig examples2, and build the module as normal check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: $(SWIG) -lua -external-runtime $(SWIG) -c++ -lua $(SWIGOPT) -o $(GENCXXSRCS) $(SRCDIR)example2.i $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) GENCXXSRCS='$(GENCXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean rm -f swigluarun.h $(TARGET) swig-3.0.2/Examples/lua/dual/dual.cpp0000664000175000017500000000625712343605122017272 0ustar williamwilliam/* dual.cpp a test for multiple modules and multiple interpreters statically linked together. Earlier version of lua bindings for SWIG would fail if statically linked. What is happening is as follows: example.i declares a type Foo examples2.i declares Bar The first lua state will load example.i and check to see if types Foo and Bar are registered with it (Foo should be & Bar should not) The second lua state will load example2.i and check to see if types Foo and Bar are registered with it (Bar should be & Foo should not) Note: Though both the modules exist and are loaded, they are not linked together, as they are connected to seperate lua interpreters. When the third lua state loads both example.i and example2.i, the two modules are now linked together, and all can now find both Foo and Bar. */ #include "swigluarun.h" // the swig runtimes #include #include // the 2 libraries which are wrapped via SWIG extern "C" int luaopen_example(lua_State*L); extern "C" int luaopen_example2(lua_State*L); #define DEBUG(X) {printf(X);fflush(stdout);} #define DEBUG2(X,Y) {printf(X,Y);fflush(stdout);} #define DEBUG3(X,Y,Z) {printf(X,Y,Z);fflush(stdout);} #if LUA_VERSION_NUM > 501 #define lua_open luaL_newstate #endif void testModule(lua_State *L) { swig_type_info *pTypeInfo=0,*pTypeInfo2=0; swig_module_info *pModule=0; pModule=SWIG_GetModule(L); DEBUG2(" SWIG_GetModule() returns %p\n", (void *)pModule) if(pModule==0) return; pTypeInfo = SWIG_TypeQuery(L,"Foo *"); DEBUG2(" Type (Foo*) is %s\n",pTypeInfo==0?"unknown":"known"); DEBUG3(" Module %p typeinfo(Foo*) %p\n", (void *)pModule, (void *)pTypeInfo); pTypeInfo2 = SWIG_TypeQuery(L,"Bar *"); DEBUG2(" Type (Bar*) is %s\n",pTypeInfo2==0?"unknown":"known"); DEBUG3(" Module %p typeinfo(Bar*) %p\n", (void *)pModule, (void *)pTypeInfo2); } int main(int argc,char* argv[]) { lua_State *L1=0,*L2=0,*L3=0; printf("This is a test of having two SWIG'ed modules and three lua states\n" "statically linked together.\n" "Its mainly to check that all the types are correctly managed\n\n"); DEBUG("creating lua states(L1,L2,L3)"); L1=lua_open(); L2=lua_open(); L3=lua_open(); DEBUG("ok\n\n"); DEBUG("luaopen_example(L1).."); luaopen_example(L1); DEBUG("ok\n"); DEBUG("Testing Module L1\n"); DEBUG("This module should know about Foo* but not Bar*\n"); testModule(L1); DEBUG("End Testing Module L1\n\n"); DEBUG("luaopen_example2(L2).."); luaopen_example2(L2); DEBUG("ok\n"); DEBUG("Testing Module L2\n"); DEBUG("This module should know about Bar* but not Foo*\n"); testModule(L2); DEBUG("End Testing Module L2\n\n"); DEBUG("luaopen_example(L3).."); luaopen_example(L3); DEBUG("ok\n"); DEBUG("luaopen_example2(L3).."); luaopen_example2(L3); DEBUG("ok\n"); DEBUG("Testing Module L3\n"); DEBUG("This module should know about Foo* and Bar*\n"); testModule(L3); DEBUG("End Testing Module L3\n\n"); DEBUG("Testing Module L1 again\n"); DEBUG("It now should know about Foo* and Bar*\n"); testModule(L1); DEBUG("End Testing Module L1 again\n\n"); DEBUG("close all.."); lua_close(L1); lua_close(L2); lua_close(L3); DEBUG("ok, exiting\n"); return 0; } swig-3.0.2/Examples/lua/simple/0000775000175000017500000000000012343605122016173 5ustar williamwilliamswig-3.0.2/Examples/lua/simple/example.c0000664000175000017500000000036712343605122020000 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/lua/simple/runme.lua0000664000175000017500000000107612343605122020030 0ustar williamwilliam---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end -- Call our gcd() function x = 42 y = 105 g = example.gcd(x,y) print("The gcd of",x,"and",y,"is",g) -- Manipulate the Foo global variable -- Output its current value print("Foo = ", example.Foo) -- Change its value example.Foo = 3.1415926 -- See if the change took effect print("Foo = ", example.Foo) swig-3.0.2/Examples/lua/simple/example.i0000664000175000017500000000015112343605122017775 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %}swig-3.0.2/Examples/lua/simple/Makefile0000664000175000017500000000102412343605122017630 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/constants/0000775000175000017500000000000012343605122016716 5ustar williamwilliamswig-3.0.2/Examples/lua/constants/runme.lua0000664000175000017500000000230512343605122020547 0ustar williamwilliam-- file: example.lua ---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end print("ICONST = "..example.ICONST.." (should be 42)") print("FCONST = "..example.FCONST.." (should be 2.1828)") 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("iconst = "..example.iconst.." (should be 37)") print("fconst = "..example.fconst.." (should be 3.14)") -- helper to check that a fn failed function checkfail(fn) if pcall(fn)==true then print("that shouldn't happen, it worked") else print("function failed as expected") end end -- these should fail -- example.EXTERN is a nil value, so concatentatin will make it fail checkfail(function() print("EXTERN = "..example.EXTERN) end) checkfail(function() print("FOO = "..example.FOO) end) swig-3.0.2/Examples/lua/constants/example.i0000664000175000017500000000113512343605122020523 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/lua/constants/Makefile0000664000175000017500000000104312343605122020354 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/functor/0000775000175000017500000000000012343605122016362 5ustar williamwilliamswig-3.0.2/Examples/lua/functor/runme.lua0000664000175000017500000000122312343605122020211 0ustar williamwilliam-- Operator overloading example ---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end a = example.intSum(0) b = example.doubleSum(100.0) -- Use the objects. They should be callable just like a normal -- lua function. for i=0,100 do a(i) -- Note: function call b(math.sqrt(i)) -- Note: function call end print("int sum 0..100 is",a:result(),"(expected 5050)") print("double sum 0..100 is",b:result(),"(expected ~771.46)") swig-3.0.2/Examples/lua/functor/example.i0000664000175000017500000000112412343605122020165 0ustar williamwilliam/* File : example.i */ %module example %inline %{ // From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514 template class Sum { T res; public: Sum(T i = 0) : res(i) { } void operator() (T x) { res += x; } T result() const { return res; } }; %} // Rename the application operator to __call. // Note: this is normally automatic, but if you had to do it yourself // you would use this directive: // // %rename(__call) *::operator(); // the fn call operator // Instantiate a few versions %template(intSum) Sum; %template(doubleSum) Sum; swig-3.0.2/Examples/lua/functor/Makefile0000664000175000017500000000112112343605122020015 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/check.list0000664000175000017500000000023512343605122016654 0ustar williamwilliam# see top-level Makefile.in arrays class constants dual embed embed2 embed3 exception funcptr3 functest functor import nspace owner pointer simple variables swig-3.0.2/Examples/lua/exception/0000775000175000017500000000000012343605122016700 5ustar williamwilliamswig-3.0.2/Examples/lua/exception/runme.lua0000664000175000017500000000422012343605122020527 0ustar williamwilliam-- file: example.lua ---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end -- throw a lot of exceptions: -- you must catch exceptions using pcall and then checking the result t = example.Test() print "calling t:unknown()" ok,res=pcall(function() t:unknown() end) if ok then print " that worked! Funny" else print(" call failed with error:",res) end print "calling t:simple()" ok,res=pcall(function() t:simple() end) if ok then print " that worked! Funny" else print(" call failed with error:",res) end print "calling t:message()" ok,res=pcall(function() t:message() end) if ok then print " that worked! Funny" else print(" call failed with error:",res) end print "calling t:hosed()" ok,res=pcall(function() t:hosed() end) if ok then print " that worked! Funny" else print(" call failed with error:",res.code,res.msg) end -- this is a rather strange way to perform the multiple catch of exceptions print "calling t:mutli()" for i=1,3 do ok,res=pcall(function() t:multi(i) end) if ok then print " that worked! Funny" else if swig_type(res)=="Exc *" then print(" call failed with Exc exception:",res.code,res.msg) else print(" call failed with error:",res) end end end -- this is a bit crazy, but it shows obtaining of the stacktrace function a() b() end function b() t:message() end print [[ Now let's call function a() which calls b() which calls into C++ which will throw an exception!]] ok,res=pcall(a) if ok then print " that worked! Funny" else print(" call failed with error:",res) end print "Now let's do the same using xpcall(a,debug.traceback)" ok,res=xpcall(a,debug.traceback) if ok then print " that worked! Funny" else print(" call failed with error:",res) end print "As you can see, the xpcall gives a nice stacktrace to work with" ok,res=pcall(a) print(ok,res) ok,res=xpcall(a,debug.traceback) print(ok,res) swig-3.0.2/Examples/lua/exception/example.h0000664000175000017500000000201412343605122020501 0ustar williamwilliam/* File : example.h */ #include #ifndef SWIG struct A { }; #endif class Exc { public: Exc(int c, const char *m) { code = c; strncpy(msg,m,256); } int code; char msg[256]; }; #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif class Test { public: int simple() throw(int&) { throw(37); return 1; } int message() throw(const char *) { throw("I died."); return 1; } int hosed() throw(Exc) { throw(Exc(42,"Hosed")); return 1; } int unknown() throw(A*) { static A a; throw &a; return 1; } int multi(int x) throw(int, const char *, Exc) { if (x == 1) throw(37); if (x == 2) throw("Bleah!"); if (x == 3) throw(Exc(42,"No-go-diggy-die")); return 1; } }; #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif swig-3.0.2/Examples/lua/exception/example.i0000664000175000017500000000051412343605122020505 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include "std_string.i" // we want to return Exc objects to the interpreter // therefore we add this typemap // note: only works if Exc is copyable %apply SWIGTYPE EXCEPTION_BY_VAL {Exc}; /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/lua/exception/Makefile0000664000175000017500000000105712343605122020343 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/nspace/0000775000175000017500000000000012343605122016153 5ustar williamwilliamswig-3.0.2/Examples/lua/nspace/runme.lua0000664000175000017500000000303012343605122020000 0ustar williamwilliam-- file: runme.lua -- This file illustrates class C++ interface generated -- by SWIG. ---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end ex = example -- Calling a module function ( aka global function ) assert( ex.module_function() == 7 ) print("example.module_function(): ", ex.module_function()) -- Accessing a module (aka global) variable assert( ex.module_variable == 9 ) print("example.module_variable: ", ex.module_variable) -- Creating an instance of the class w1 = ex.MyWorld.World() print("Creating class instance: w1 = ex.MyWorld.World(): ", w1) -- Accessing class members assert( ex.MyWorld.World():create_world() == 17 ) print( "w1:create_world() = ", w1:create_world() ) assert( w1:create_world() == 17 ) print( "w1:world_max_count = ", w1.world_max_count ) assert( w1.world_max_count == 9 ) -- Accessing enums from class within namespace print( "Accessing enums: ex.MyWorld.Nested.Dweller.MALE = ", ex.MyWorld.Nested.Dweller.MALE ) assert( ex.MyWorld.Nested.Dweller.MALE == 0 ) print( "Accessing enums: ex.MyWorld.Nested.Dweller.FEMALE = ", ex.MyWorld.Nested.Dweller.FEMALE ) assert( ex.MyWorld.Nested.Dweller.FEMALE == 1 ) -- Accessing static member function print( "Accessing static member function: ex.MyWorld.Nested.Dweller.count() = ", ex.MyWorld.Nested.Dweller.count() ) assert( ex.MyWorld.Nested.Dweller.count() == 19 ) swig-3.0.2/Examples/lua/nspace/example.h0000664000175000017500000000067412343605122017766 0ustar williamwilliam#ifndef _example_guardian_ #define _example_guardian_ int module_function() { return 7; } int module_variable = 9; namespace MyWorld { class World { public: World() : world_max_count(9) {} int create_world() { return 17; } const int world_max_count; // = 9 }; namespace Nested { class Dweller { public: enum Gender { MALE = 0, FEMALE = 1 }; static int count() { return 19; } }; } } #endif swig-3.0.2/Examples/lua/nspace/example.i0000664000175000017500000000017512343605122017763 0ustar williamwilliam%module example %{ #include "example.h" %} %nspace MyWorld::Nested::Dweller; %nspace MyWorld::World; %include "example.h" swig-3.0.2/Examples/lua/nspace/Makefile0000664000175000017500000000103612343605122017613 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/import.lua0000664000175000017500000000234212343605122016720 0ustar williamwilliam-- import -- the lua 5.0 loading mechanism is rather poor & relies upon the loadlib() fn -- the lua 5.1 loading mechanism is simplicity itself -- for now we need a bridge which will use the correct version function import_5_0(module) -- imports the file into the program -- for a module 'example' -- this must load 'example.dll' or 'example.so' -- and look for the fn 'Example_Init()' (note the capitalisation) if rawget(_G,module)~=nil then return end -- module appears to be loaded -- capitalising the first letter local c=string.upper(string.sub(module,1,1)) local fnname=c..string.sub(module,2).."_Init" local suffix,lib -- note: as there seems to be no way in lua to determine the platform -- we will try loading all possible names -- providing one works, we can load for _,suffix in pairs{".dll",".so"} do lib=loadlib(module..suffix,fnname) if lib then -- found break end end assert(lib,"error loading module:"..module) lib() -- execute the function: initialising the lib local m=rawget(_G,module) -- gets the module object assert(m~=nil,"no module table found") end function import_5_1(module) require(module) end if string.sub(_VERSION,1,7)=='Lua 5.0' then import=import_5_0 else import=import_5_1 end swig-3.0.2/Examples/lua/owner/0000775000175000017500000000000012343605122016034 5ustar williamwilliamswig-3.0.2/Examples/lua/owner/runme.lua0000664000175000017500000000627712343605122017701 0ustar williamwilliam-- Operator overloading example ---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end print "ok, let's test Lua's ownership of C++ objects" print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)") print "\nLet's make a couple" a=example.Square(10) b=example.Circle(1) print("Currently there are",example.Shape_nshapes,"shapes (there should be 2)") print "\nNote let's use the createX functions" c=example.createCircle(5) d=example.createSquare(3) print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)") print "\nWe will run the garbage collector & see if they are till here" collectgarbage() print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)") print "\nLet's get rid of them all, collect garbage & see if they are till here" a,b,c,d=nil,nil,nil,nil collectgarbage() print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)") print "\nLet's start putting stuff into the ShapeOwner" print "The ShapeOwner now owns the shapes, but Lua still has pointers to them" o=example.ShapeOwner() a=example.Square(10) b=example.Circle(1) o:add(a) o:add(b) o:add(example.createSquare(5)) print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)") print "\nWe will nil our references,run the garbage collector & see if they are still here" print "they should be, as the ShapeOwner owns them" a,b=nil,nil collectgarbage() print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)") print "\nWe will access them and check that they are still valid" a=o:get(0) b=o:get(1) print(" Area's are",a:area(),b:area(),o:get(2):area()) collectgarbage() print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)") print "\nWe will remove one from the C++ owner & pass its ownership to Lua," print " then check that they are still unchanged" a,b=nil,nil a=o:remove(0) -- a now owns it collectgarbage() print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)") print "\nDelete the ShapeOwner (this should destroy two shapes)," print " but we have one left in Lua" o=nil collectgarbage() print("Currently there are",example.Shape_nshapes,"shapes (there should be 1)") print "\nFinal tidy up " a=nil collectgarbage() print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)") print "Final test, we will create some Shapes & pass them around like mad" print "If there is any memory leak, you will see it in the memory usage" io.flush() sh={} -- make some objects for i=0,10 do a=example.Circle(i) b=example.Square(i) sh[a]=true sh[b]=true end o=example.ShapeOwner() for i=0,10000 do for k,_ in pairs(sh) do o:add(k) end sh={} -- clear it while true do a=o:remove(0) if a==nil then break end sh[a]=true end if i%100==0 then collectgarbage() end end print "done" o,sh=nil,nil collectgarbage() print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)") print "that's all folks!" swig-3.0.2/Examples/lua/owner/example.h0000664000175000017500000000227512343605122017646 0ustar williamwilliam/* File : example.h */ #include class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; virtual double area(void); virtual double perimeter(void); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { }; virtual double area(void); virtual double perimeter(void); }; Circle* createCircle(double w); // this method creates a new object Square* createSquare(double w); // this method creates a new object class ShapeOwner { private: std::vector shapes; ShapeOwner(const ShapeOwner&); // no copying ShapeOwner& operator=(const ShapeOwner&); // no copying public: ShapeOwner(); ~ShapeOwner(); void add(Shape* ptr); // this method takes ownership of the object Shape* get(int idx); // this pointer is still owned by the class (assessor) Shape* remove(int idx); // this method returns memory which must be deleted }; swig-3.0.2/Examples/lua/owner/example.i0000664000175000017500000000141412343605122017641 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} // before we grab the header file, we must warn SWIG about some of these functions. // these functions create data, so must be managed %newobject createCircle; %newobject createSquare; // this method returns as pointer which must be managed %newobject ShapeOwner::remove; // you cannot use %delobject on ShapeOwner::add() // as this disowns the ShapeOwner, not the Shape (oops) //%delobject ShapeOwner::add(Shape*); DO NOT USE // either you can use a new function (such as this) /*%delobject add_Shape; %inline %{ void add_Shape(Shape* s,ShapeOwner* own){own->add(s);} %}*/ // or a better solution is a typemap %apply SWIGTYPE *DISOWN {Shape* ptr}; // now we can grab the header file %include "example.h" swig-3.0.2/Examples/lua/owner/example.cxx0000664000175000017500000000251612343605122020217 0ustar williamwilliam/* File : example.c */ #include "example.h" #include #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area(void) { return M_PI*radius*radius; } double Circle::perimeter(void) { return 2*M_PI*radius; } double Square::area(void) { return width*width; } double Square::perimeter(void) { return 4*width; } Circle* createCircle(double w) { return new Circle(w); } Square* createSquare(double w) { return new Square(w); } ShapeOwner::ShapeOwner() { printf(" ShapeOwner(%p)\n", (void *)this); } ShapeOwner::~ShapeOwner() { printf(" ~ShapeOwner(%p)\n", (void *)this); for(unsigned i=0;i= static_cast(shapes.size())) return NULL; return shapes[idx]; } Shape* ShapeOwner::remove(int idx) // this method returns memory which must be deleted { if (idx < 0 || idx >= static_cast(shapes.size())) return NULL; Shape* ptr=shapes[idx]; shapes.erase(shapes.begin()+idx); return ptr; } swig-3.0.2/Examples/lua/owner/Makefile0000664000175000017500000000107312343605122017475 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/import/0000775000175000017500000000000012343605122016214 5ustar williamwilliamswig-3.0.2/Examples/lua/import/spam.h0000664000175000017500000000063212343605122017326 0ustar williamwilliam#include "bar.h" class Spam : public Bar { public: Spam() { } ~Spam() { } virtual const char * A() const { return "Spam::A"; } const char * B() const { return "Spam::B"; } virtual Base *toBase() { return static_cast(this); } virtual Bar *toBar() { return static_cast(this); } static Spam *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/lua/import/README0000664000175000017500000000211512343605122017073 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. Use 'lua runme.lua' to run a test. Overview: --------- The example defines 4 different extension modules--each wrapping a separate C++ class. base.i - Base class foo.i - Foo class derived from Base bar.i - Bar class derived from Base spam.i - Spam class derived from Bar Each module uses %import to refer to another module. For example, the 'foo.i' module uses '%import base.i' to get definitions for its base class. If everything is okay, all of the modules will load properly and type checking will work correctly. Caveat: Some compilers, for example gcc-3.2.x, generate broken vtables with the inline methods in this test. This is not a SWIG problem and can usually be solved with non-inlined destructors compiled into separate shared objects/DLLs. Unix: ----- - Run make - Run the test as described above Windows: -------- Sorry, no files here. If you know how, you could copy the python or ruby example dsw & dsp and try editing that swig-3.0.2/Examples/lua/import/runme.lua0000664000175000017500000000375212343605122020054 0ustar williamwilliam# Test various properties of classes defined in separate modules print("Testing the %import directive") if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this function loadit(a) lib=loadlib(a..'.dll','luaopen_'..a) or loadlib(a..'.so','luaopen_'..a) assert(lib)() end loadit('base') loadit('foo') loadit('bar') loadit('spam') else -- lua 5.1 does require 'base' require 'foo' require 'bar' require 'spam' end -- Create some objects print("Creating some objects") a = base.Base() b = foo.Foo() c = bar.Bar() d = spam.Spam() -- Try calling some methods print("Testing some methods") print("Should see 'Base::A' ---> ",a:A()) print("Should see 'Base::B' ---> ",a:B()) print("Should see 'Foo::A' ---> ",b:A()) print("Should see 'Foo::B' ---> ",b:B()) print("Should see 'Bar::A' ---> ",c:A()) print("Should see 'Bar::B' ---> ",c:B()) print("Should see 'Spam::A' ---> ",d:A()) print("Should see 'Spam::B' ---> ",d:B()) -- Try some casts print("\nTesting some casts") x = a:toBase() print("Should see 'Base::A' ---> ",x:A()) print("Should see 'Base::B' ---> ",x:B()) x = b:toBase() print("Should see 'Foo::A' ---> ",x:A()) print("Should see 'Base::B' ---> ",x:B()) x = c:toBase() print("Should see 'Bar::A' ---> ",x:A()) print("Should see 'Base::B' ---> ",x:B()) x = d:toBase() print("Should see 'Spam::A' ---> ",x:A()) print("Should see 'Base::B' ---> ",x:B()) x = d:toBar() print("Should see 'Bar::B' ---> ",x:B()) print "\nTesting some dynamic casts\n" x = d:toBase() print " Spam -> Base -> Foo : " y = foo.Foo_fromBase(x) if y then print "bad swig" else print "good swig" end print " Spam -> Base -> Bar : " y = bar.Bar_fromBase(x) if y then print "good swig" else print "bad swig" end print " Spam -> Base -> Spam : " y = spam.Spam_fromBase(x) if y then print "good swig" else print "bad swig" end print " Foo -> Spam : " y = spam.Spam_fromBase(b) if y then print "bad swig" else print "good swig" end swig-3.0.2/Examples/lua/import/spam.i0000664000175000017500000000011012343605122017316 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-3.0.2/Examples/lua/import/bar.i0000664000175000017500000000010612343605122017127 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-3.0.2/Examples/lua/import/base.i0000664000175000017500000000006612343605122017302 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h swig-3.0.2/Examples/lua/import/foo.i0000664000175000017500000000010512343605122017145 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-3.0.2/Examples/lua/import/foo.h0000664000175000017500000000052312343605122017150 0ustar williamwilliam#include "base.h" class Foo : public Base { public: Foo() { } ~Foo() { } virtual const char * A() const { return "Foo::A"; } const char * B() const { return "Foo::B"; } virtual Base *toBase() { return static_cast(this); } static Foo *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/lua/import/base.h0000664000175000017500000000044312343605122017300 0ustar williamwilliamclass Base { public: Base() { }; virtual ~Base() { }; virtual const char * A() const { return "Base::A"; } const char * B() const { return "Base::B"; } virtual Base *toBase() { return static_cast(this); } }; swig-3.0.2/Examples/lua/import/Makefile0000664000175000017500000000142312343605122017654 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' lua_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' lua_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' lua_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' lua_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/lua/import/bar.h0000664000175000017500000000052312343605122017131 0ustar williamwilliam#include "base.h" class Bar : public Base { public: Bar() { } ~Bar() { } virtual const char * A() const { return "Bar::A"; } const char * B() const { return "Bar::B"; } virtual Base *toBase() { return static_cast(this); } static Bar *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/lua/variables/0000775000175000017500000000000012343605122016652 5ustar williamwilliamswig-3.0.2/Examples/lua/variables/example.c0000664000175000017500000000456012343605122020456 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/lua/variables/runme.lua0000664000175000017500000000450112343605122020503 0ustar williamwilliam---- importing ---- if string.sub(_VERSION,1,7)=='Lua 5.0' then -- lua5.0 doesnt have a nice way to do this lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example') assert(lib)() else -- lua 5.1 does require('example') end -- Try to set the values of some global variables example.ivar = 42 example.svar = -31000 example.lvar = 65537 example.uivar = 123456 example.usvar = 61000 example.ulvar = 654321 example.scvar = -13 example.ucvar = 251 example.cvar = "S" example.fvar = 3.14159 example.dvar = 2.1828 example.strvar = "Hello World" example.iptrvar= example.new_int(37) example.ptptr = example.new_Point(37,42) example.name = "Bill" -- Now print out the values of the variables print("Variables (values printed from Lua)") print("ivar =", example.ivar) print("svar =", example.svar) print("lvar =", example.lvar) print("uivar =", example.uivar) print("usvar =", example.usvar) print("ulvar =", example.ulvar) print("scvar =", example.scvar) print("ucvar =", example.ucvar) print("fvar =", example.fvar) print("dvar =", example.dvar) print("cvar =", example.cvar) print("strvar =", example.strvar) print("cstrvar =", example.cstrvar) print("iptrvar =", example.iptrvar) print("name =", example.name) print("ptptr =", example.ptptr, example.Point_print(example.ptptr)) print("pt =", example.pt, example.Point_print(example.pt)) print("\nVariables (values printed from C)") example.print_vars() print "\nNow I'm going to try and modify some read only variables"; print " Tring to set 'path' to 'Whoa!'"; if pcall(function() example.path = "Whoa!" end)==true then print " Thats funny, it didn't give an error!" else print " It gave an error, as it should" end print(" Just checking the value: path =", example.path) print " Trying to set 'status' to '0'"; if pcall(function() example.status = 0 end)==true then print " Thats funny, it didn't give an error!" else print " It gave an error, as it should" end print(" Just checking the value: status =", example.status) print "\nI'm going to try and update a structure variable.\n" example.pt = example.ptptr print "The new value is" example.pt_print() print("You should see the value", example.Point_print(example.ptptr)) swig-3.0.2/Examples/lua/variables/example.h0000664000175000017500000000007512343605122020460 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/lua/variables/example.i0000664000175000017500000000174512343605122020466 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/lua/variables/Makefile0000664000175000017500000000102412343605122020307 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean swig-3.0.2/Examples/mzscheme/0000775000175000017500000000000012343605122015734 5ustar williamwilliamswig-3.0.2/Examples/mzscheme/std_vector/0000775000175000017500000000000012343605122020110 5ustar williamwilliamswig-3.0.2/Examples/mzscheme/std_vector/example.h0000664000175000017500000000111612343605122021713 0ustar williamwilliam/* File : example.h */ #include #include #include #include double average(std::vector v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } std::vector half(const std::vector& v) { std::vector w(v); for (unsigned int i=0; i& v) { // would you believe this is the same as the above? std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } swig-3.0.2/Examples/mzscheme/std_vector/example.i0000664000175000017500000000047512343605122021723 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include stl.i /* instantiate the required template specializations */ namespace std { %template(IntVector) vector; %template(DoubleVector) vector; } /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/mzscheme/std_vector/runme.scm0000664000175000017500000000247712343605122021754 0ustar williamwilliam;; run with mzscheme -r runme.scm (load-extension "example.so") ; repeatedly invoke a procedure with v and an index as arguments (define (with-vector v proc size-proc) (let ((size (size-proc v))) (define (with-vector-item v i) (if (< i size) (begin (proc v i) (with-vector-item v (+ i 1))))) (with-vector-item v 0))) (define (with-intvector v proc) (with-vector v proc intvector-length)) (define (with-doublevector v proc) (with-vector v proc doublevector-length)) (define (print-doublevector v) (with-doublevector v (lambda (v i) (display (doublevector-ref v i)) (display " "))) (newline)) ; Call average with a Scheme list... (display (average '(1 2 3 4))) (newline) ; ... or a wrapped std::vector (define v (new-intvector 4)) (with-intvector v (lambda (v i) (intvector-set! v i (+ i 1)))) (display (average v)) (newline) (delete-intvector v) ; half will return a Scheme vector. ; Call it with a Scheme vector... (display (half #(1 1.5 2 2.5 3))) (newline) ; ... or a wrapped std::vector (define v (new-doublevector)) (map (lambda (i) (doublevector-push! v i)) '(1 2 3 4)) (display (half v)) (newline) ; now halve a wrapped std::vector in place (halve-in-place v) (print-doublevector v) (delete-doublevector v) swig-3.0.2/Examples/mzscheme/std_vector/Makefile0000664000175000017500000000101012343605122021540 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = GPP = `which g++` MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run build: $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE) $(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx $(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean swig-3.0.2/Examples/mzscheme/simple/0000775000175000017500000000000012343605122017225 5ustar williamwilliamswig-3.0.2/Examples/mzscheme/simple/README0000664000175000017500000000004212343605122020101 0ustar williamwilliamSimple example from users manual. swig-3.0.2/Examples/mzscheme/simple/example.c0000664000175000017500000000056612343605122021033 0ustar williamwilliam/* Simple example from documentation */ /* File : example.c */ #include double My_variable = 3.0; /* Compute factorial of n */ int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } /* Compute n mod m */ int my_mod(int n, int m) { return (n % m); } char *get_time() { long ltime; time(<ime); return ctime(<ime); } swig-3.0.2/Examples/mzscheme/simple/example.i0000664000175000017500000000041012343605122021025 0ustar williamwilliam/* File : example.i */ %module example %{ /* Put headers and other declarations here */ %} %include typemaps.i %rename(mod) my_mod; %inline %{ extern double My_variable; extern int fact(int); extern int my_mod(int n, int m); extern char *get_time(); %} swig-3.0.2/Examples/mzscheme/simple/runme.scm0000664000175000017500000000076612343605122021070 0ustar williamwilliam;; run with mzscheme -r runme.scm (load-extension "example.so") (display (get-time)) (printf "My-variable = ~a~n" (my-variable)) (let loop ((i 0)) (when (< i 14) (begin (display i) (display " factorial is ") (display (fact i)) (newline) (loop (+ i 1))))) (let loop ((i 1)) (when (< i 250) (begin (let loopi ((j 1)) (when (< j 250) (begin (my-variable (+ (my-variable) (mod i j))) (loopi (+ j 1))))) (loop (+ i 1))))) (printf "My-variable = ~a~n" (my-variable)) swig-3.0.2/Examples/mzscheme/simple/Makefile0000664000175000017500000000067012343605122020670 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean swig-3.0.2/Examples/mzscheme/check.list0000664000175000017500000000006712343605122017711 0ustar williamwilliam# see top-level Makefile.in multimap simple std_vector swig-3.0.2/Examples/mzscheme/multimap/0000775000175000017500000000000012343605122017564 5ustar williamwilliamswig-3.0.2/Examples/mzscheme/multimap/example.c0000664000175000017500000000164012343605122021364 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.2/Examples/mzscheme/multimap/example.i0000664000175000017500000000420512343605122021372 0ustar williamwilliam/* File : example.i */ %module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} %include exception.i %include typemaps.i extern int gcd(int x, int y); %typemap(in) (int argc, char *argv[]) { int i; Scheme_Object **elms; if (!SCHEME_VECTORP($input)) { scheme_wrong_type("$name","vector",$argnum,argc,argv); } $1 = SCHEME_VEC_SIZE($input); elms = SCHEME_VEC_ELS($input); if ($1 == 0) { scheme_wrong_type("$name","vector",$argnum,argc,argv); } $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++) { if (!SCHEME_STRINGP(elms[i])) { free($2); scheme_wrong_type("$name","vector",$argnum,argc,argv); } $2[i] = SCHEME_STR_VAL(elms[i]); } $2[i] = 0; } %typemap(freearg) (int argc, char *argv[]) { free($2); } extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { if (!SCHEME_STRINGP($input)) { scheme_wrong_type("$name","string",1,argc,argv); } $1 = SCHEME_STR_VAL($input); $2 = SCHEME_STRLEN_VAL($input); } extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a string */ %typemap(in) (char *str, int len) { if (!SCHEME_STRINGP($input)) { scheme_wrong_type("$name","string",1,argc,argv); } $2 = SCHEME_STRLEN_VAL($input); $1 = (char *) malloc($2+1); memmove($1,SCHEME_STR_VAL($input),$2); } /* Return the mutated string as a new object. */ %typemap(argout) (char *str, int len) { Scheme_Object *s; s = scheme_make_sized_string($1,$2,1); SWIG_APPEND_VALUE(s); free($1); } extern void capitalize(char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); return NULL; } } extern void circle(double cx, double cy); swig-3.0.2/Examples/mzscheme/multimap/runme.scm0000664000175000017500000000063112343605122021416 0ustar williamwilliam;; run with mzscheme -r runme.scm (load-extension "example.so") ; Call the GCD function (define x 42) (define y 105) (define g (gcd x y)) (display "The gcd of ") (display x) (display " and ") (display y) (display " is ") (display g) (newline) ; Call the gcdmain() function (gcdmain #("gcdmain" "42" "105")) (display (count "Hello World" #\l)) (newline) (display (capitalize "hello world")) (newline) swig-3.0.2/Examples/mzscheme/multimap/Makefile0000664000175000017500000000067012343605122021227 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean swig-3.0.2/Examples/ocaml/0000775000175000017500000000000012343605122015214 5ustar williamwilliamswig-3.0.2/Examples/ocaml/std_string/0000775000175000017500000000000012343605122017374 5ustar williamwilliamswig-3.0.2/Examples/ocaml/std_string/README0000664000175000017500000000117012343605122020253 0ustar williamwilliam--- New --- It's not possible to access std::(w)string at the moment as it breaks other string examples. --- Old --- This example shows how to use both std::string and std::wstring in Ocaml, and also demonstrates that one might use this to make a locale-obedient Ocaml program. These are two sample runs; note that the output is different based on the locale chosen to perform the conversion to wchar_t. bash-2.05a$ ./example ja_JP.EUC-JP the original string contains 2 the new string contains 1 : [ 29494; ] bash-2.05a$ ./example en_US the original string contains 2 the new string contains 2 : [ 205; 177; ] swig-3.0.2/Examples/ocaml/std_string/runme.ml0000664000175000017500000000115112343605122021052 0ustar williamwilliam(* This example was mostly lifted from the guile example directory *) open Swig open Example let y = "\205\177" let z = _to_wstring_with_locale '((y to string),(Sys.argv.(1) to string)) let _ = begin print_string "the original string contains " ; print_int (String.length y) ; print_newline () ; print_string "the new string contains " ; print_int (z -> size () as int) ; print_string " : [ " ; for i = 0 to (pred ((z -> size ()) as int)) do print_int ((z '[i to int]) as int) ; print_string "; " ; done ; print_string "]" ; print_newline () ; end swig-3.0.2/Examples/ocaml/std_string/example.h0000664000175000017500000000225612343605122021205 0ustar williamwilliam/* File : example.h -- stolen from the guile std_vector example */ #include #include #include #include #include #include std::string from_wstring_with_locale( const std::wstring source, const std::string locale ) { const char *current_locale = setlocale( LC_CTYPE, locale.c_str() ); int required_chars = wcstombs( NULL, source.c_str(), 0 ); std::string s; char *temp_chars = new char[required_chars + 1]; temp_chars[0] = 0; wcstombs( temp_chars, source.c_str(), required_chars + 1 ); s = temp_chars; delete [] temp_chars; setlocale( LC_CTYPE, current_locale ); return s; } std::wstring to_wstring_with_locale( const std::string source, const std::string locale ) { const char *current_locale = setlocale( LC_CTYPE, locale.c_str() ); int required_chars = mbstowcs( NULL, source.c_str(), 0 ); std::wstring s; wchar_t *temp_chars = new wchar_t[required_chars + 1]; temp_chars[0] = 0; mbstowcs( temp_chars, source.c_str(), required_chars + 1 ); s = temp_chars; delete [] temp_chars; setlocale( LC_CTYPE, current_locale ); return s; } swig-3.0.2/Examples/ocaml/std_string/example.i0000664000175000017500000000033312343605122021200 0ustar williamwilliam/* -*- C++ -*- */ /* File : example.i -- stolen from the guile std_vector example */ %module example %{ #include "example.h" %} %include stl.i /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/ocaml/std_string/Makefile0000664000175000017500000000124712343605122021040 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean swig-3.0.2/Examples/ocaml/std_vector/0000775000175000017500000000000012343605122017370 5ustar williamwilliamswig-3.0.2/Examples/ocaml/std_vector/runme.ml0000664000175000017500000000140312343605122021046 0ustar williamwilliam(* This example was mostly lifted from the guile example directory *) open Swig open Example let with_vector v f = for i = 0 to ((v -> size()) as int) - 1 do f v i done let print_DoubleVector v = begin with_vector v (fun v i -> print_float ((v '[i to int]) as float) ; print_string " ") ; print_endline end (* Call average with a Ocaml array... *) let v = new_DoubleVector '() let rec fill_dv v x = if x < 0.0001 then v else begin v -> push_back ((x to float)) ; fill_dv v (x *. x) end let _ = fill_dv v 0.999 let _ = print_DoubleVector v ; print_endline "" let u = new_IntVector '() let _ = for i = 1 to 4 do u -> push_back ((i to int)) done let _ = (print_float ((_average u) as float) ; print_newline ()) swig-3.0.2/Examples/ocaml/std_vector/example.h0000664000175000017500000000117212343605122021175 0ustar williamwilliam/* File : example.h -- stolen from the guile std_vector example */ #include #include #include #include double average(std::vector v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } std::vector half(const std::vector& v) { std::vector w(v); for (unsigned int i=0; i& v) { // would you believe this is the same as the above? std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } swig-3.0.2/Examples/ocaml/std_vector/example.i0000664000175000017500000000055212343605122021177 0ustar williamwilliam/* -*- C++ -*- */ /* File : example.i -- stolen from the guile std_vector example */ %module example %{ #include "example.h" %} %include stl.i /* instantiate the required template specializations */ %template(IntVector) std::vector; %template(DoubleVector) std::vector; /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/ocaml/std_vector/Makefile0000664000175000017500000000124712343605122021034 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean swig-3.0.2/Examples/ocaml/contract/0000775000175000017500000000000012343605122017031 5ustar williamwilliamswig-3.0.2/Examples/ocaml/contract/example.i0000664000175000017500000000040312343605122020633 0ustar williamwilliam%module example %{ #include %} /* File : example.i */ %module example %contract cos(double d) { require: d >= -3.14159265358979323845254338327950; d < 3.14159265358979323846264338327950; ensure: cos >= -1.0; cos <= 1.0; } double cos(double d);swig-3.0.2/Examples/ocaml/contract/example_prog.ml0000664000175000017500000000035312343605122022046 0ustar williamwilliamopen Swig open Example let _ = print_endline "This won't throw." let _ = Printf.printf "Cos 1.0 is %f\n" (_cos '(1.0) as float) let _ = print_endline "This will throw." let _ = Printf.printf "Cos 5.0 is %f\n" (_cos '(5.0) as float) swig-3.0.2/Examples/ocaml/contract/Makefile0000664000175000017500000000176112343605122020476 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i MLFILE = example.ml PROGFILE = example_prog.ml OBJS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean swig-3.0.2/Examples/ocaml/argout_ref/0000775000175000017500000000000012343605122017351 5ustar williamwilliamswig-3.0.2/Examples/ocaml/argout_ref/example.c0000664000175000017500000000046712343605122021157 0ustar williamwilliam/* File : example.c */ /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } extern "C" void factor( int &x, int &y ) { int gcd_xy = gcd( x,y ); x /= gcd_xy; y /= gcd_xy; } swig-3.0.2/Examples/ocaml/argout_ref/example.i0000664000175000017500000000020312343605122021151 0ustar williamwilliam/* File : example.i */ %module example %{ extern "C" void factor(int &x, int &y); %} extern "C" void factor(int &x, int &y); swig-3.0.2/Examples/ocaml/argout_ref/example_prog.ml0000664000175000017500000000125512343605122022370 0ustar williamwilliam(* example_prog.ml *) open Swig open Example exception BadReturn let _ = if Array.length Sys.argv < 3 then begin print_endline ("Usage: " ^ Sys.argv.(0) ^ " n1 n2\n" ^ " Displays the least factors of the numbers that have the same\n" ^ " relationship, 16 12 -> 4 3\n") ; exit 0 end let x = int_of_string Sys.argv.(1) let y = int_of_string Sys.argv.(2) let (xf,yf) = match _factor '((x to int),(y to int)) with C_list [ C_int a ; C_int b ] -> a,b | _ -> raise BadReturn let _ = print_endline ("Factorization of " ^ (string_of_int x) ^ " and " ^ (string_of_int y) ^ " is " ^ (string_of_int xf) ^ " and " ^ (string_of_int yf)) swig-3.0.2/Examples/ocaml/argout_ref/Makefile0000664000175000017500000000146112343605122021013 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i MLFILE = example.ml PROGFILE = example_prog.ml OBJS = example.o check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean swig-3.0.2/Examples/ocaml/string_from_ptr/0000775000175000017500000000000012343605122020432 5ustar williamwilliamswig-3.0.2/Examples/ocaml/string_from_ptr/foolib.i0000664000175000017500000000045012343605122022055 0ustar williamwilliam%module foolib %{ static int foo( char **buf ) { *buf = "string from c"; return 0; } %} %typemap(in,numinputs=0) char **buf (char *temp) { $1 = &temp; } %typemap(argout) char **buf { swig_result = caml_list_append(swig_result,caml_val_string((char *)*$1)); } int foo( char **buf ); swig-3.0.2/Examples/ocaml/string_from_ptr/example_prog.ml0000664000175000017500000000164112343605122023450 0ustar williamwilliam(* foo_program.ml -- the program using foolib *) open Swig (* Give access to the swig library *) open Foolib (* This is the name of your swig output *) let results = _foo '() (* Function names are prefixed with _ in order to make them lex as identifiers in ocaml. Consider that uppercase identifiers are module names in ocaml. NOTE: the '() syntax is part of swigp4. You can do: let results = _foo C_void *) (* Since your function has a return value in addition to the string output, you'll need to match them as a list *) let result_string = match results with C_list [ C_string result_string ; C_int 0 ] -> (* The return value is last when out arguments appear, but this too can be customized. We're also checking that the function succeeded. *) result_string | _ -> raise (Failure "Expected string, int reply from _foo") let _ = print_endline result_string swig-3.0.2/Examples/ocaml/string_from_ptr/Makefile0000664000175000017500000000212712343605122022074 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = -c++ SRCS = TARGET = example INTERFACE = foolib.i MLFILE = foolib.ml PROGFILE = example_prog.ml OBJS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static static_top static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp static_top: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean swig-3.0.2/Examples/ocaml/scoped_enum/0000775000175000017500000000000012343605122017515 5ustar williamwilliamswig-3.0.2/Examples/ocaml/scoped_enum/README0000664000175000017500000000011112343605122020366 0ustar williamwilliamThis tests our handling of scoped enums. Run with argument Tag1 or Tag2.swig-3.0.2/Examples/ocaml/scoped_enum/example.i0000664000175000017500000000007112343605122021320 0ustar williamwilliam%module example %{ #include "foo.h" %} %include "foo.h"swig-3.0.2/Examples/ocaml/scoped_enum/example_prog.ml0000664000175000017500000000013412343605122022527 0ustar williamwilliamopen Swig open Example let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | _ -> ``Tag2) swig-3.0.2/Examples/ocaml/scoped_enum/foo.h0000664000175000017500000000015512343605122020452 0ustar williamwilliamnamespace foo { enum Bar { Tag1, Tag2 }; static void f( Bar b ) { printf( "b = %d\n", (int)b ); } } swig-3.0.2/Examples/ocaml/scoped_enum/Makefile0000664000175000017500000000177512343605122021167 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i MLFILE = example.ml PROGFILE = example_prog.ml OBJS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean swig-3.0.2/Examples/ocaml/simple/0000775000175000017500000000000012343605122016505 5ustar williamwilliamswig-3.0.2/Examples/ocaml/simple/example.c0000664000175000017500000000036712343605122020312 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/ocaml/simple/example.i0000664000175000017500000000015212343605122020310 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/ocaml/simple/example_prog.ml0000664000175000017500000000100712343605122021517 0ustar williamwilliam(* example_prog.ml *) open Swig open Example (* Call our gcd() function *) exception NoReturn let x = 42 to int let y = 105 to int let g = _gcd '(x,y) as int let _ = Printf.printf "The gcd of %d and %d is %d\n" (x as int) (y as int) g (* Manipulate the Foo global variable *) (* Output its current value *) let _ = Printf.printf "Foo = %f\n" (_Foo '() as float) (* Change its value *) let _ = _Foo '(3.1415926) (* See if the change took effect *) let _ = Printf.printf "Foo = %f\n" (_Foo '() as float) swig-3.0.2/Examples/ocaml/simple/index.html0000664000175000017500000000325612343605122020510 0ustar williamwilliam SWIG:Examples:python:simple SWIG/Examples/python/simple/

      Simple Python Example

      This example illustrates how you can hook Python to a very simple C program containing a function and a global variable.

      The C Code

      Suppose you have the following C code:
      /* File : example.c */
      
      /* A global variable */
      double Foo = 3.0;
      
      /* Compute the greatest common divisor of positive integers */
      int gcd(int x, int y) {
        int g;
        g = y;
        while (x > 0) {
          g = x;
          x = y % x;
          y = g;
        }
        return g;
      }
      

      The SWIG interface

      Here is a simple SWIG interface file:
      /* File: example.i */
      %module example
      
      extern int gcd(int x, int y);
      extern double Foo;
      

      Compilation

      1. swig -python example.i

      2. Compile example_wrap.c and example.c to create the extension examplemodule.so.

      Using the extension

      Click here to see a script that calls our C functions from Python.

      Key points

      • Use the import statement to load your extension module from Python. For example:
        import example
        
      • C functions work just like Python functions. For example:
        g = example.gcd(42,105)
        
      • C global variables are accessed through a special variable called 'cvar'. For example:
        a = example.cvar.Foo
        

      swig-3.0.2/Examples/ocaml/simple/Makefile0000664000175000017500000000200512343605122020142 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i MLFILE = example.ml PROGFILE = example_prog.ml OBJS = example.o check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean swig-3.0.2/Examples/ocaml/shapes/0000775000175000017500000000000012343605122016477 5ustar williamwilliamswig-3.0.2/Examples/ocaml/shapes/example.c0000664000175000017500000000244712343605122020305 0ustar williamwilliam/* File : example.c */ #include #include "example.h" shape::~shape() { } bool shape::cover( double x, double y ) { return false; } void draw_shape_coverage( shape *s, int div_x, int div_y ) { double i,j; for( i = 0; i < 1.0; i += 1.0 / ((float)div_y) ) { for( j = 0; j < 1.0; j += 1.0 / ((float)div_x) ) { if( s->cover( j,i ) ) putchar( 'x' ); else putchar( ' ' ); } printf( "\n" ); } } void draw_depth_map( volume *v, int div_x, int div_y ) { double i,j; char depth_map_chars[] = "#*+o;:,. "; double lowbound, highbound; double current = 0.0; bool bounds_set = false; for( i = 0; i < 1.0; i += 1.0 / ((float)div_y) ) { for( j = 0; j < 1.0; j += 1.0 / ((float)div_x) ) { current = v->depth( j,i ); if( !bounds_set ) { lowbound = current; highbound = current; bounds_set = true; } if( current < lowbound ) lowbound = current; if( current > highbound ) highbound = current; } } for( i = 0; i < 1.0; i += 1.0 / ((float)div_y) ) { for( j = 0; j < 1.0; j += 1.0 / ((float)div_x) ) { current = ((v->depth( j,i ) - lowbound) / (highbound - lowbound)) * 8; putchar(depth_map_chars[(int)current]); } putchar('\n'); } } double volume::depth( double x, double y ) { return 0.0; } volume::~volume() { } swig-3.0.2/Examples/ocaml/shapes/example.h0000664000175000017500000000062712343605122020310 0ustar williamwilliam#ifndef EXAMPLE_H #define EXAMPLE_H class shape { public: virtual ~shape(); virtual bool cover( double x, double y ); // does this shape cover this point? }; class volume { public: virtual double depth( double x, double y ); virtual ~volume(); }; extern void draw_shape_coverage( shape *s, int div_x, int div_y ); extern void draw_depth_map( volume *v, int div_x, int div_y ); #endif//EXAMPLE_H swig-3.0.2/Examples/ocaml/shapes/example.i0000664000175000017500000000022612343605122020304 0ustar williamwilliam/* File : example.i */ %module(directors="1") example #ifndef SWIGSEXP %{ #include "example.h" %} #endif %feature("director"); %include "example.h" swig-3.0.2/Examples/ocaml/shapes/example_prog.ml0000664000175000017500000000405512343605122021517 0ustar williamwilliam(* example_prog.ml *) open Swig ;; open Example ;; let side_length (ax,ay) (bx,by) = sqrt (((bx -. ax) ** 2.0) +. ((by -. ay) ** 2.0)) ;; let triangle_area a_pt b_pt c_pt = let a = (side_length a_pt b_pt) and b = (side_length b_pt c_pt) and c = (side_length c_pt a_pt) in let s = (a +. b +. c) /. 2.0 in sqrt (s *. (s -. a) *. (s -. b) *. (s -. c)) ;; let point_in_triangle (pta,ptb,ptc) x y = let delta = 0.0000001 in (* Error *) let ptx = (x,y) in begin let a_area = triangle_area pta ptb ptx and b_area = triangle_area ptb ptc ptx and c_area = triangle_area ptc pta ptx and x_area = triangle_area pta ptb ptc in let result = (abs_float (a_area +. b_area +. c_area -. x_area)) < delta in result end ;; let triangle_class pts ob meth args = match meth with "cover" -> (match args with C_list [ x_arg ; y_arg ] -> let xa = x_arg as float and ya = y_arg as float in (point_in_triangle pts xa ya) to bool | _ -> raise (Failure "cover needs two double arguments.")) | _ -> (invoke ob) meth args ;; let dist (ax,ay) (bx,by) = let dx = ax -. bx and dy = ay -. by in sqrt ((dx *. dx) +. (dy *. dy)) let waveplot_depth events distance pt = (List.fold_left (+.) 0.0 (List.map (fun (x,y,d) -> let t = dist pt (x,y) in ((sin t) /. t) *. d) events)) +. distance let waveplot_class events distance ob meth args = match meth with "depth" -> (match args with C_list [ x_arg ; y_arg ] -> let xa = x_arg as float and ya = y_arg as float in (waveplot_depth events distance (xa,ya)) to float | _ -> raise (Failure "cover needs two double arguments.")) | _ -> (invoke ob) meth args ;; let triangle = new_derived_object new_shape (triangle_class ((0.0,0.0),(0.5,1.0),(1.0,0.6))) '() ;; let waveplot = new_derived_object new_volume (waveplot_class [ 0.01,0.01,3.0 ; 1.01,-2.01,1.5 ] 5.0) '() ;; let _ = _draw_shape_coverage '(triangle, 60, 20) ;; let _ = _draw_depth_map '(waveplot, 60, 20) ;; swig-3.0.2/Examples/ocaml/shapes/Makefile0000664000175000017500000000215012343605122020135 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = SRCS = example.c TARGET = example INTERFACE = example.i MLFILE = example.ml PROGFILE = example_prog.ml OBJS = example.o check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static static_top static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp static_top: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean swig-3.0.2/Examples/ocaml/strings_test/0000775000175000017500000000000012343605122017744 5ustar williamwilliamswig-3.0.2/Examples/ocaml/strings_test/runme.ml0000664000175000017500000000117212343605122021425 0ustar williamwilliam(* This example is meant to reach every case in cstring.i *) open Swig open Example let _ = _takes_std_string (C_string "foo") let _ = print_endline ("_gives_std_string <<" ^ (get_string (_gives_std_string C_void)) ^ " >>") let _ = _takes_char_ptr (C_string "bar") let _ = print_endline ("_gives_char_ptr << " ^ (get_string (_gives_char_ptr C_void)) ^ " >>") let _ = print_endline ("_takes_and_gives_std_string << " ^ (get_string (_takes_and_gives_std_string (C_string "foo"))) ^ " >>") let _ = print_endline ("_takes_and_gives_char_ptr << " ^ (get_string (_takes_and_gives_char_ptr (C_string "bar.bar"))) ^ " >>") swig-3.0.2/Examples/ocaml/strings_test/example.h0000664000175000017500000000154712343605122021557 0ustar williamwilliam/* -*- mode: c++ -*- */ /* File : example.h -- Tests all string typemaps */ #include #include void takes_std_string( std::string in ) { cout << "takes_std_string( \"" << in << "\" );" << endl; } std::string gives_std_string() { struct timeval tv; gettimeofday(&tv, NULL); return std::string( asctime( localtime( &tv.tv_sec ) ) ); } void takes_char_ptr( char *p ) { cout << "takes_char_ptr( \"" << p << "\" );" << endl; } char *gives_char_ptr() { return "foo"; } void takes_and_gives_std_string( std::string &inout ) { inout.insert( inout.begin(), '[' ); inout.insert( inout.end(), ']' ); } void takes_and_gives_char_ptr( char *&inout ) { char *pout = strchr( inout, '.' ); if( pout ) inout = pout + 1; else inout = "foo"; } /* * Local-Variables: * c-indentation-style: "stroustrup" * End: */ swig-3.0.2/Examples/ocaml/strings_test/example.i0000664000175000017500000000025412343605122021552 0ustar williamwilliam%module example %{ #include #include using std::cin; using std::cout; using std::endl; using std::string; #include "example.h" %} %include example.h swig-3.0.2/Examples/ocaml/strings_test/Makefile0000664000175000017500000000154012343605122021404 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static top static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp top: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean swig-3.0.2/Examples/ocaml/check.list0000664000175000017500000000016412343605122017167 0ustar williamwilliam# see top-level Makefile.in simple std_string std_vector stl argout_ref shapes contract scoped_enum string_from_ptr swig-3.0.2/Examples/ocaml/stl/0000775000175000017500000000000012343605122016016 5ustar williamwilliamswig-3.0.2/Examples/ocaml/stl/runme.ml0000664000175000017500000000042412343605122017476 0ustar williamwilliam(* This example was mostly lifted from the guile example directory *) open Swig open Example let v = new_StringVector '() let _ = for i = 0 to (Array.length Sys.argv) - 1 do let str = (Sys.argv.(i)) to string in v -> push_back (str) done let _ = _vec_write '(v) swig-3.0.2/Examples/ocaml/stl/example.h0000664000175000017500000000055612343605122017630 0ustar williamwilliam/* File : example.h -- stolen from the guile std_vector example */ #include #include #include #include #include using std::string; double vec_write(std::vector v) { int n = 0; for( std::vector::iterator i = v.begin(); i != v.end(); i++ ) printf( "%04d: %s\n", ++n, i->c_str() ); } swig-3.0.2/Examples/ocaml/stl/example.i0000664000175000017500000000024012343605122017617 0ustar williamwilliam%module example %{ #include "example.h" %} #define ENABLE_CHARPTR_ARRAY #define ENABLE_STRING_VECTOR %include stl.i %feature("director"); %include example.h swig-3.0.2/Examples/ocaml/stl/Makefile0000664000175000017500000000203412343605122017455 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run build: static static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp director: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_director dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean swig-3.0.2/Examples/csharp/0000775000175000017500000000000012343605122015401 5ustar williamwilliamswig-3.0.2/Examples/csharp/arrays/0000775000175000017500000000000012343605122016702 5ustar williamwilliamswig-3.0.2/Examples/csharp/arrays/example.c0000664000175000017500000000076512343605122020511 0ustar williamwilliam/* File : example.c */ #include "example.h" /* copy the contents of the first array to the second */ void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) { int i; for ( i = 0; i < nitems; i++ ) { targetArray[ i ] = sourceArray[ i ]; } } /* swap the contents of the two arrays */ void myArraySwap( int* array1, int* array2, int nitems ) { int i, temp; for ( i = 0; i < nitems; i++ ) { temp = array1[ i ]; array1[ i ] = array2[ i ]; array2[ i ] = temp; } } swig-3.0.2/Examples/csharp/arrays/example.h0000664000175000017500000000020012343605122020476 0ustar williamwilliam void myArrayCopy( int *sourceArray, int* targetArray, int nitems ); void myArraySwap( int* array1, int* array2, int nitems ); swig-3.0.2/Examples/csharp/arrays/example.i0000664000175000017500000000165112343605122020512 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include "arrays_csharp.i" %apply int INPUT[] { int* sourceArray } %apply int OUTPUT[] { int* targetArray } %apply int INOUT[] { int* array1 } %apply int INOUT[] { int* array2 } %include "example.h" %clear int* sourceArray; %clear int* targetArray; %clear int* array1; %clear int* array2; // Below replicates the above array handling but this time using the pinned (fixed) array typemaps %csmethodmodifiers "public unsafe"; %apply int FIXED[] { int* sourceArray } %apply int FIXED[] { int* targetArray } %inline %{ void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) { myArrayCopy(sourceArray, targetArray, nitems); } %} %apply int FIXED[] { int* array1 } %apply int FIXED[] { int* array2 } %inline %{ void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) { myArraySwap(array1, array2, nitems); } %} swig-3.0.2/Examples/csharp/arrays/example.sln0000664000175000017500000000413112343605122021052 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/arrays/runme.cs0000664000175000017500000000226512343605122020364 0ustar williamwilliamusing System; public class runme { static void Main() { int[] source = { 1, 2, 3 }; int[] target = new int[ source.Length ]; example.myArrayCopy( source, target, target.Length ); Console.WriteLine( "Contents of copy target array using default marshaling" ); PrintArray( target ); target = new int[ source.Length ]; example.myArrayCopyUsingFixedArrays( source, target, target.Length ); Console.WriteLine( "Contents of copy target array using fixed arrays" ); PrintArray( target ); target = new int[] { 4, 5, 6 }; example.myArraySwap( source, target, target.Length ); Console.WriteLine( "Contents of arrays after swapping using default marshaling" ); PrintArray( source ); PrintArray( target ); source = new int[] { 1, 2, 3 }; target = new int[] { 4, 5, 6 }; example.myArraySwapUsingFixedArrays( source, target, target.Length ); Console.WriteLine( "Contents of arrays after swapping using fixed arrays" ); PrintArray( source ); PrintArray( target ); } static void PrintArray( int[] a ) { foreach ( int i in a ) Console.Write( "{0} ", i ); Console.WriteLine(); } } swig-3.0.2/Examples/csharp/arrays/Makefile0000664000175000017500000000115712343605122020346 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -unsafe -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/arrays/example-cs.csproj0000664000175000017500000000675212343605122022174 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt true bin\x86\Release\ TRACE 285212672 true x86 prompt true true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt true bin\x64\Release\ TRACE 285212672 true x64 prompt true Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/arrays/example-vc.vcproj0000664000175000017500000002343012343605122022172 0ustar williamwilliam swig-3.0.2/Examples/csharp/template/0000775000175000017500000000000012343605122017214 5ustar williamwilliamswig-3.0.2/Examples/csharp/template/example.h0000664000175000017500000000077712343605122021033 0ustar williamwilliam/* File : example.h */ // Some template definitions template T max(T a, T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } #ifdef SWIG %extend { T getitem(int index) { return $self->get(index); } void setitem(int index, T val) { $self->set(index,val); } } #endif }; swig-3.0.2/Examples/csharp/template/example.i0000664000175000017500000000051412343605122021021 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; swig-3.0.2/Examples/csharp/template/example.sln0000664000175000017500000000413112343605122021364 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/template/runme.cs0000664000175000017500000000145512343605122020676 0ustar williamwilliam// This example illustrates how C++ templates can be used from C#. using System; public class runme { public static void Main() { // Call some templated functions Console.WriteLine(example.maxint(3,7)); Console.WriteLine(example.maxdouble(3.14,2.18)); // Create some class vecint iv = new vecint(100); vecdouble dv = new vecdouble(1000); for (int i=0; i<100; i++) iv.setitem(i,2*i); for (int i=0; i<1000; i++) dv.setitem(i, 1.0/(i+1)); { int sum = 0; for (int i=0; i<100; i++) sum = sum + iv.getitem(i); Console.WriteLine(sum); } { double sum = 0.0; for (int i=0; i<1000; i++) sum = sum + dv.getitem(i); Console.WriteLine(sum); } } } swig-3.0.2/Examples/csharp/template/Makefile0000664000175000017500000000114712343605122020657 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/template/example-cs.csproj0000664000175000017500000000672012343605122022501 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/template/example-vc.vcproj0000664000175000017500000002337312343605122022512 0ustar williamwilliam swig-3.0.2/Examples/csharp/class/0000775000175000017500000000000012343605122016506 5ustar williamwilliamswig-3.0.2/Examples/csharp/class/example.h0000664000175000017500000000107612343605122020316 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/csharp/class/example.i0000664000175000017500000000021512343605122020311 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/csharp/class/example.sln0000664000175000017500000000413112343605122020656 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/class/example.cxx0000664000175000017500000000065012343605122020666 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/csharp/class/runme.cs0000664000175000017500000000432712343605122020171 0ustar williamwilliam// This example illustrates how C++ classes can be used from C# using SWIG. // The C# class gets mapped onto the C++ class and behaves as if it is a C# class. using System; public class runme { static void Main() { // ----- Object creation ----- Console.WriteLine( "Creating some objects:" ); using (Square s = new Square(10)) using (Circle c = new Circle(10)) { Console.WriteLine( " Created circle " + c ); Console.WriteLine( " Created square " + s ); // ----- Access a static member ----- Console.WriteLine( "\nA total of " + Shape.nshapes + " shapes were created" ); // ----- Member data access ----- // Notice how we can do this using functions specific to // the 'Circle' class. c.x = 20; c.y = 30; // Now use the same functions in the base class Shape shape = s; shape.x = -10; shape.y = 5; Console.WriteLine( "\nHere is their current position:" ); Console.WriteLine( " Circle = (" + c.x + " " + c.y + ")" ); Console.WriteLine( " Square = (" + s.x + " " + s.y + ")" ); // ----- Call some methods ----- Console.WriteLine( "\nHere are some properties of the shapes:" ); Shape[] shapes = {c,s}; // for (int i=0; i Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/class/example-vc.vcproj0000664000175000017500000002347012343605122022002 0ustar williamwilliam swig-3.0.2/Examples/csharp/nested/0000775000175000017500000000000012343605122016663 5ustar williamwilliamswig-3.0.2/Examples/csharp/nested/example.h0000664000175000017500000000213512343605122020470 0ustar williamwilliam#include /** Design a motor car from various components */ struct MotorCar { /** Information about an opinion of the design of a car component */ struct DesignOpinion { bool itrocks; std::string reason; static int AceDesignCount; static int TotalDesignCount; static int PercentScore(); }; /** Wheels component */ struct Wheels { enum Shape { Round, Square }; Wheels(Shape shape, size_t count); DesignOpinion Opinion(); private: Shape shape; size_t count; }; /** Windscreen component */ struct WindScreen { WindScreen(bool opaque); DesignOpinion Opinion(); private: bool opaque; }; /** Factory method for creating a car */ static MotorCar DesignFromComponents(const std::string &name, const Wheels &wheels, const WindScreen &windscreen); std::string Name() { return name; } /** Get an overall opinion on the car design */ std::string WillItWork(); private: MotorCar(const std::string &name, const Wheels &wheels, const WindScreen &windscreen); std::string name; Wheels wheels; WindScreen windscreen; }; swig-3.0.2/Examples/csharp/nested/example.i0000664000175000017500000000036612343605122020475 0ustar williamwilliam%module example // This example shows how wrappers for numerous aspects of C++ nested classes work: // Nested static and instance variables and methods and nested enums %include %{ #include "example.h" %} %include "example.h" swig-3.0.2/Examples/csharp/nested/example.sln0000664000175000017500000000413112343605122021033 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/nested/example.cxx0000664000175000017500000000407412343605122021047 0ustar williamwilliam#include "example.h" int MotorCar::DesignOpinion::AceDesignCount = 0; int MotorCar::DesignOpinion::TotalDesignCount = 0; int MotorCar::DesignOpinion::PercentScore() { return AceDesignCount*100/TotalDesignCount; } MotorCar::Wheels::Wheels(Shape shape, size_t count) : shape(shape), count(count) {} MotorCar::WindScreen::WindScreen(bool opaque) : opaque(opaque) {} MotorCar::MotorCar(const std::string &name, const Wheels &wheels, const WindScreen &windscreen) : name(name), wheels(wheels), windscreen(windscreen) {} MotorCar MotorCar::DesignFromComponents(const std::string &name, const Wheels &wheels, const WindScreen &windscreen) { MotorCar car = MotorCar(name, wheels, windscreen); DesignOpinion::TotalDesignCount++; if (car.wheels.Opinion().itrocks && car.windscreen.Opinion().itrocks) DesignOpinion::AceDesignCount++; return car; } MotorCar::DesignOpinion MotorCar::Wheels::Opinion() { DesignOpinion opinion; opinion.itrocks = true; if (shape == Square) { opinion.itrocks = false; opinion.reason = "you'll have a few issues with wheel rotation"; } if (count <= 2) { opinion.reason += opinion.itrocks ? "" : " and "; opinion.itrocks = false; opinion.reason += "a few more wheels are needed for stability"; } if (opinion.itrocks) opinion.reason = "your choice of wheels was top notch"; return opinion; } MotorCar::DesignOpinion MotorCar::WindScreen::Opinion() { DesignOpinion opinion; opinion.itrocks = !opaque; opinion.reason = opinion.itrocks ? "the driver will have a commanding view out the window" : "you can't see out the windscreen"; return opinion; } std::string MotorCar::WillItWork() { DesignOpinion wh = wheels.Opinion(); DesignOpinion ws = windscreen.Opinion(); std::string willit; if (wh.itrocks && ws.itrocks) { willit = "Great car design because " + wh.reason + " and " + ws.reason; } else { willit = "You need a rethink because "; willit += wh.itrocks ? "" : wh.reason; willit += (!wh.itrocks && !ws.itrocks) ? " and " : ""; willit += ws.itrocks ? "" : ws.reason; } return willit; } swig-3.0.2/Examples/csharp/nested/runme.cs0000664000175000017500000000306612343605122020345 0ustar williamwilliam// This example illustrates how C++ classes can be used from C# using SWIG. // The C# class gets mapped onto the C++ class and behaves as if it is a C# class. using System; public class runme { static void Main() { MotorCar car1 = MotorCar.DesignFromComponents("Bumpy", new MotorCar.Wheels(MotorCar.Wheels.Shape.Square, 4), new MotorCar.WindScreen(false)); MotorCar car2 = MotorCar.DesignFromComponents("Wobbly", new MotorCar.Wheels(MotorCar.Wheels.Shape.Round, 2), new MotorCar.WindScreen(false)); MotorCar car3 = MotorCar.DesignFromComponents("Batty", new MotorCar.Wheels(MotorCar.Wheels.Shape.Round, 4), new MotorCar.WindScreen(true)); MotorCar car4 = MotorCar.DesignFromComponents("Spiffing", new MotorCar.Wheels(MotorCar.Wheels.Shape.Round, 4), new MotorCar.WindScreen(false)); Console.WriteLine("Expert opinion on " + car1.Name() + " : \n " + car1.WillItWork()); Console.WriteLine("Expert opinion on " + car2.Name() + " : \n " + car2.WillItWork()); Console.WriteLine("Expert opinion on " + car3.Name() + " : \n " + car3.WillItWork()); Console.WriteLine("Expert opinion on " + car4.Name() + " : \n " + car4.WillItWork()); int count = MotorCar.DesignOpinion.AceDesignCount; int total = MotorCar.DesignOpinion.TotalDesignCount; int percent = MotorCar.DesignOpinion.PercentScore(); Console.WriteLine("Overall opinion rating on car design is " + count + "/" + total + " = " + percent + "%"); Console.WriteLine("Single square wheel thoughts: " + new MotorCar.Wheels(MotorCar.Wheels.Shape.Square, 1).Opinion().reason); } } swig-3.0.2/Examples/csharp/nested/Makefile0000664000175000017500000000116312343605122020324 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/nested/example-cs.csproj0000664000175000017500000000651512343605122022152 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/nested/example-vc.vcproj0000664000175000017500000002347012343605122022157 0ustar williamwilliam swig-3.0.2/Examples/csharp/enum/0000775000175000017500000000000012343605122016345 5ustar williamwilliamswig-3.0.2/Examples/csharp/enum/example.h0000664000175000017500000000032612343605122020152 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/csharp/enum/example.i0000664000175000017500000000021712343605122020152 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/csharp/enum/example.sln0000664000175000017500000000413112343605122020515 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/enum/example.cxx0000664000175000017500000000151112343605122020522 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/csharp/enum/runme.cs0000664000175000017500000000223312343605122020022 0ustar williamwilliamusing System; public class runme { static void Main() { // Print out the value of some enums Console.WriteLine("*** color ***"); Console.WriteLine(" " + color.RED + " = " + (int)color.RED); Console.WriteLine(" " + color.BLUE + " = " + (int)color.BLUE); Console.WriteLine(" " + color.GREEN + " = " + (int)color.GREEN); Console.WriteLine("\n*** Foo::speed ***"); Console.WriteLine(" Foo::" + Foo.speed.IMPULSE + " = " + (int)Foo.speed.IMPULSE); Console.WriteLine(" Foo::" + Foo.speed.WARP + " = " + (int)Foo.speed.WARP); Console.WriteLine(" Foo::" + Foo.speed.LUDICROUS + " = " + (int)Foo.speed.LUDICROUS); Console.WriteLine("\nTesting use of enums with functions\n"); example.enum_test(color.RED, Foo.speed.IMPULSE); example.enum_test(color.BLUE, Foo.speed.WARP); example.enum_test(color.GREEN, Foo.speed.LUDICROUS); Console.WriteLine( "\nTesting use of enum with class method" ); Foo f = new Foo(); f.enum_test(Foo.speed.IMPULSE); f.enum_test(Foo.speed.WARP); f.enum_test(Foo.speed.LUDICROUS); } } swig-3.0.2/Examples/csharp/enum/Makefile0000664000175000017500000000116312343605122020006 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/enum/example-cs.csproj0000664000175000017500000000655412343605122021637 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/enum/example-vc.vcproj0000664000175000017500000002347012343605122021641 0ustar williamwilliam swig-3.0.2/Examples/csharp/simple/0000775000175000017500000000000012343605122016672 5ustar williamwilliamswig-3.0.2/Examples/csharp/simple/example.c0000664000175000017500000000036712343605122020477 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/csharp/simple/example.i0000664000175000017500000000015212343605122020475 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/csharp/simple/example.sln0000664000175000017500000000413112343605122021042 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/simple/runme.cs0000664000175000017500000000104412343605122020346 0ustar williamwilliamusing System; public class runme { static void Main() { // Call our gcd() function int x = 42; int y = 105; int g = example.gcd(x,y); Console.WriteLine("The gcd of " + x + " and " + y + " is " + g); // Manipulate the Foo global variable // Output its current value Console.WriteLine("Foo = " + example.Foo); // Change its value example.Foo = 3.1415926; // See if the change took effect Console.WriteLine("Foo = " + example.Foo); } } swig-3.0.2/Examples/csharp/simple/Makefile0000664000175000017500000000114712343605122020335 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/simple/example-cs.csproj0000664000175000017500000000644612343605122022164 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/simple/example-vc.vcproj0000664000175000017500000002333512343605122022166 0ustar williamwilliam swig-3.0.2/Examples/csharp/extend/0000775000175000017500000000000012343605122016670 5ustar williamwilliamswig-3.0.2/Examples/csharp/extend/example.h0000664000175000017500000000260512343605122020477 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *get_item(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; swig-3.0.2/Examples/csharp/extend/example.i0000664000175000017500000000040312343605122020472 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_vector.i" %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; %include "example.h" swig-3.0.2/Examples/csharp/extend/example.sln0000664000175000017500000000413112343605122021040 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/extend/example.cxx0000664000175000017500000000006012343605122021043 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/csharp/extend/runme.cs0000664000175000017500000000646312343605122020356 0ustar williamwilliam// This file illustrates the cross language polymorphism using directors. using System; // CEO class, which overrides Employee::getPosition(). class CEO : Manager { public CEO(String name) : base(name) { } public override String getPosition() { return "CEO"; } // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory. public void disownMemory() { swigCMemOwn = false; } } public class runme { static void Main() { // Create an instance of CEO, a class derived from the C# proxy of the // underlying C++ class. The calls to getName() and getPosition() are standard, // the call to getTitle() uses the director wrappers to call CEO.getPosition(). CEO e = new CEO("Alice"); Console.WriteLine( e.getName() + " is a " + e.getPosition() ); Console.WriteLine( "Just call her \"" + e.getTitle() + "\"" ); Console.WriteLine( "----------------------" ); // Create a new EmployeeList instance. This class does not have a C++ // director wrapper, but can be used freely with other classes that do. using (EmployeeList list = new EmployeeList()) { // EmployeeList owns its items, so we must surrender ownership of objects we add. e.disownMemory(); list.addEmployee(e); Console.WriteLine( "----------------------" ); // Now we access the first four items in list (three are C++ objects that // EmployeeList's constructor adds, the last is our CEO). The virtual // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in C#. The call to getPosition is // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, C# resolved the call // immediately in CEO, but now C# thinks the object is an instance of // class Employee. So the call passes through the // Employee proxy class and on to the C wrappers and C++ director, // eventually ending up back at the C# CEO implementation of getPosition(). // The call to getTitle() for item 3 runs the C++ Employee::getTitle() // method, which in turn calls getPosition(). This virtual method call // passes down through the C++ director class to the C# implementation // in CEO. All this routing takes place transparently. Console.WriteLine( "(position, title) for items 0-3:" ); Console.WriteLine( " " + list.get_item(0).getPosition() + ", \"" + list.get_item(0).getTitle() + "\"" ); Console.WriteLine( " " + list.get_item(1).getPosition() + ", \"" + list.get_item(1).getTitle() + "\"" ); Console.WriteLine( " " + list.get_item(2).getPosition() + ", \"" + list.get_item(2).getTitle() + "\"" ); Console.WriteLine( " " + list.get_item(3).getPosition() + ", \"" + list.get_item(3).getTitle() + "\"" ); Console.WriteLine( "----------------------" ); // The using statement ensures the EmployeeList.Dispose() will be called, which will delete all the Employee* // items it contains. The last item is our CEO, which gets destroyed as well. } Console.WriteLine( "----------------------" ); // All done. Console.WriteLine( "C# exit" ); } } swig-3.0.2/Examples/csharp/extend/Makefile0000664000175000017500000000116312343605122020331 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/extend/example-cs.csproj0000664000175000017500000000663612343605122022163 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/extend/example-vc.vcproj0000664000175000017500000002357012343605122022165 0ustar williamwilliam swig-3.0.2/Examples/csharp/reference/0000775000175000017500000000000012343605122017337 5ustar williamwilliamswig-3.0.2/Examples/csharp/reference/example.h0000664000175000017500000000064512343605122021150 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; friend Vector operator+(const Vector &a, const Vector &b); char *print(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/csharp/reference/example.i0000664000175000017500000000131412343605122021143 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module example %{ #include "example.h" %} class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.2/Examples/csharp/reference/example.sln0000664000175000017500000000413112343605122021507 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/reference/example.cxx0000664000175000017500000000161412343605122021520 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/csharp/reference/runme.cs0000664000175000017500000000464512343605122021025 0ustar williamwilliam// This example illustrates the manipulation of C++ references in C#. using System; public class runme { public static void Main() { Console.WriteLine( "Creating some objects:" ); Vector a = new Vector(3,4,5); Vector b = new Vector(10,11,12); Console.WriteLine( " Created " + a.print() ); Console.WriteLine( " Created " + b.print() ); // ----- Call an overloaded operator ----- // This calls the wrapper we placed around // // operator+(const Vector &a, const Vector &) // // It returns a new allocated object. Console.WriteLine( "Adding a+b" ); Vector c = example.addv(a,b); Console.WriteLine( " a+b = " + c.print() ); // Note: Unless we free the result, a memory leak will occur if the -noproxy commandline // is used as the proxy classes define finalizers which call the Dispose() method. When // -noproxy is not specified the memory management is controlled by the garbage collector. // You can still call Dispose(). It will free the c++ memory immediately, but not the // C# memory! You then must be careful not to call any member functions as it will // use a NULL c pointer on the underlying c++ object. We set the C# object to null // which will then throw a C# exception should we attempt to use it again. c.Dispose(); c = null; // ----- Create a vector array ----- Console.WriteLine( "Creating an array of vectors" ); VectorArray va = new VectorArray(10); Console.WriteLine( " va = " + va.ToString() ); // ----- Set some values in the array ----- // These operators copy the value of Vector a and Vector b to the vector array va.set(0,a); va.set(1,b); // This works, but it would cause a memory leak if -noproxy was used! va.set(2,example.addv(a,b)); // Get some values from the array Console.WriteLine( "Getting some array values" ); for (int i=0; i<5; i++) Console.WriteLine( " va(" + i + ") = " + va.get(i).print() ); // Watch under resource meter to check on this Console.WriteLine( "Making sure we don't leak memory." ); for (int i=0; i<1000000; i++) c = va.get(i%10); // ----- Clean up ----- // This could be omitted. The garbage collector would then clean up for us. Console.WriteLine( "Cleaning up" ); va.Dispose(); a.Dispose(); b.Dispose(); } } swig-3.0.2/Examples/csharp/reference/Makefile0000664000175000017500000000116312343605122021000 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/reference/example-cs.csproj0000664000175000017500000000656512343605122022633 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/reference/example-vc.vcproj0000664000175000017500000002347012343605122022633 0ustar williamwilliam swig-3.0.2/Examples/csharp/check.list0000664000175000017500000000016112343605122017351 0ustar williamwilliam# see top-level Makefile.in arrays callback class enum extend funcptr nested reference simple template variables swig-3.0.2/Examples/csharp/funcptr/0000775000175000017500000000000012343605122017062 5ustar williamwilliamswig-3.0.2/Examples/csharp/funcptr/example.c0000664000175000017500000000037012343605122020661 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/csharp/funcptr/example.h0000664000175000017500000000026312343605122020667 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/csharp/funcptr/example.i0000664000175000017500000000056012343605122020670 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); swig-3.0.2/Examples/csharp/funcptr/example.sln0000664000175000017500000000413112343605122021232 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/funcptr/runme.cs0000664000175000017500000000157012343605122020542 0ustar williamwilliam using System; using System.Reflection; public class runme { public static void Main(String[] args) { int a = 37; int b = 42; // Now call our C function with a bunch of callbacks Console.WriteLine( "Trying some C callback functions" ); Console.WriteLine( " a = " + a ); Console.WriteLine( " b = " + b ); Console.WriteLine( " ADD(a,b) = " + example.do_op(a,b,example.ADD) ); Console.WriteLine( " SUB(a,b) = " + example.do_op(a,b,example.SUB) ); Console.WriteLine( " MUL(a,b) = " + example.do_op(a,b,example.MUL) ); Console.WriteLine( "Here is what the C callback function classes are called in C#" ); Console.WriteLine( " ADD = " + example.ADD.GetType() ); Console.WriteLine( " SUB = " + example.SUB.GetType() ); Console.WriteLine( " MUL = " + example.MUL.GetType() ); } } swig-3.0.2/Examples/csharp/funcptr/Makefile0000664000175000017500000000114712343605122020525 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/funcptr/example-cs.csproj0000664000175000017500000000653612343605122022354 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/funcptr/example-vc.vcproj0000664000175000017500000002343012343605122022352 0ustar williamwilliam swig-3.0.2/Examples/csharp/callback/0000775000175000017500000000000012343605122017135 5ustar williamwilliamswig-3.0.2/Examples/csharp/callback/example.h0000664000175000017500000000107112343605122020740 0ustar williamwilliam/* File : example.h */ #include #include class Callback { public: virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void resetCallback() { _callback = 0; } void call() { if (_callback) _callback->run(); } }; swig-3.0.2/Examples/csharp/callback/example.i0000664000175000017500000000031212343605122020736 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_string.i" /* turn on director wrapping Callback */ %feature("director") Callback; %include "example.h" swig-3.0.2/Examples/csharp/callback/example.sln0000664000175000017500000000413112343605122021305 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/callback/example.cxx0000664000175000017500000000006012343605122021310 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/csharp/callback/runme.cs0000664000175000017500000000163112343605122020613 0ustar williamwilliamusing System; public class runme { static void Main() { Console.WriteLine("Adding and calling a normal C++ callback"); Console.WriteLine("----------------------------------------"); Caller caller = new Caller(); using (Callback callback = new Callback()) { caller.setCallback(callback); caller.call(); caller.resetCallback(); } Console.WriteLine(); Console.WriteLine("Adding and calling a C# callback"); Console.WriteLine("------------------------------------"); using (Callback callback = new CSharpCallback()) { caller.setCallback(callback); caller.call(); caller.resetCallback(); } Console.WriteLine(); Console.WriteLine("C# exit"); } } public class CSharpCallback : Callback { public CSharpCallback() : base() { } public override void run() { Console.WriteLine("CSharpCallback.run()"); } } swig-3.0.2/Examples/csharp/callback/Makefile0000664000175000017500000000116312343605122020576 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/callback/example-cs.csproj0000664000175000017500000000656212343605122022426 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/callback/example-vc.vcproj0000664000175000017500000002357012343605122022432 0ustar williamwilliam swig-3.0.2/Examples/csharp/variables/0000775000175000017500000000000012343605122017351 5ustar williamwilliamswig-3.0.2/Examples/csharp/variables/example.c0000664000175000017500000000456012343605122021155 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/csharp/variables/example.h0000664000175000017500000000007512343605122021157 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/csharp/variables/example.i0000664000175000017500000000174512343605122021165 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/csharp/variables/example.sln0000664000175000017500000000413112343605122021521 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" ProjectSection(ProjectDependencies) = postProject {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-3.0.2/Examples/csharp/variables/runme.cs0000664000175000017500000000544412343605122021035 0ustar williamwilliam// This example illustrates global variable access from C#. using System; using System.Reflection; public class runme { public static void Main() { // Try to set the values of some global variables example.ivar = 42; example.svar = -31000; example.lvar = 65537; example.uivar = 123456; example.usvar = 61000; example.ulvar = 654321; example.scvar = -13; example.ucvar = 251; example.cvar = 'S'; example.fvar = (float)3.14159; example.dvar = 2.1828; example.strvar = "Hello World"; example.iptrvar= example.new_int(37); example.ptptr = example.new_Point(37,42); example.name = "Bill"; // Now print out the values of the variables Console.WriteLine( "Variables (values printed from C#)" ); Console.WriteLine( "ivar =" + example.ivar ); Console.WriteLine( "svar =" + example.svar ); Console.WriteLine( "lvar =" + example.lvar ); Console.WriteLine( "uivar =" + example.uivar ); Console.WriteLine( "usvar =" + example.usvar ); Console.WriteLine( "ulvar =" + example.ulvar ); Console.WriteLine( "scvar =" + example.scvar ); Console.WriteLine( "ucvar =" + example.ucvar ); Console.WriteLine( "fvar =" + example.fvar ); Console.WriteLine( "dvar =" + example.dvar ); Console.WriteLine( "cvar =" + example.cvar ); Console.WriteLine( "strvar =" + example.strvar ); Console.WriteLine( "cstrvar =" + example.cstrvar ); Console.WriteLine( "iptrvar =" + example.iptrvar ); Console.WriteLine( "name =" + example.name ); Console.WriteLine( "ptptr =" + example.ptptr + example.Point_print(example.ptptr) ); Console.WriteLine( "pt =" + example.pt + example.Point_print(example.pt) ); Console.WriteLine( "\nVariables (values printed from C)" ); example.print_vars(); Console.WriteLine( "\nNow I'm going to try and modify some read only variables" ); Console.WriteLine( "\nChecking that the read only variables are readonly..." ); example ex = new example(); Type t = ex.GetType(); Console.WriteLine( " 'path'" ); PropertyInfo pi = t.GetProperty("path"); if (pi.CanWrite) Console.WriteLine("Oh dear this variable is not read only\n"); else Console.WriteLine("Good."); Console.WriteLine( " 'status'" ); pi = t.GetProperty("status"); if (pi.CanWrite) Console.WriteLine("Oh dear this variable is not read only"); else Console.WriteLine("Good."); Console.WriteLine( "\nI'm going to try and update a structure variable.\n" ); example.pt = example.ptptr; Console.WriteLine( "The new value is" ); example.pt_print(); Console.WriteLine( "You should see the value" + example.Point_print(example.ptptr) ); } } swig-3.0.2/Examples/csharp/variables/Makefile0000664000175000017500000000114712343605122021014 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -debug+ -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean swig-3.0.2/Examples/csharp/variables/example-cs.csproj0000664000175000017500000000660212343605122022635 0ustar williamwilliam Local 8.0.50727 2.0 {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A} Debug x86 runme JScript Grid IE50 false Exe runme OnBuildSuccess true bin\x86\Debug\ DEBUG;TRACE 285212672 full x86 prompt bin\x86\Release\ TRACE 285212672 true x86 prompt true bin\x64\Debug\ DEBUG;TRACE 285212672 full x64 prompt bin\x64\Release\ TRACE 285212672 true x64 prompt Code Code Code copy runme.exe "$(SolutionDir)runme.exe" echo Run the example from the root directory $(SolutionDir) and ensure example.dll is also in this directory swig-3.0.2/Examples/csharp/variables/example-vc.vcproj0000664000175000017500000002343012343605122022641 0ustar williamwilliam swig-3.0.2/Examples/chicken/0000775000175000017500000000000012343605122015525 5ustar williamwilliamswig-3.0.2/Examples/chicken/README0000664000175000017500000000106312343605122016405 0ustar williamwilliamThis directory contains examples for CHICKEN. class -- illustrates the proxy class C++ interface constants -- handling #define and %constant literals egg -- examples of building chicken extension libraries multimap -- typemaps with multiple sub-types overload -- C++ function overloading simple -- the simple example from the user manual zlib -- a wrapping of the zlib compression library You should be able to run make in each of the examples. By default, a shared library will be built. Run make check to execute the test. swig-3.0.2/Examples/chicken/class/0000775000175000017500000000000012343605122016632 5ustar williamwilliamswig-3.0.2/Examples/chicken/class/example.h0000664000175000017500000000121412343605122020434 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; enum SomeEnum { First = 0, Second, Third, Last = 1000 }; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/chicken/class/runme-lowlevel.scm0000664000175000017500000000310612343605122022313 0ustar williamwilliam;; This file illustrates the low-level C++ interface generated ;; by SWIG. (load-library 'example "class.so") (declare (uses example)) ;; ----- Object creation ----- (display "Creating some objects:\n") (define c (new-Circle 10.0)) (display " Created circle ") (display c) (display "\n") (define s (new-Square 10.0)) (display " Created square ") (display s) (display "\n") ;; ----- Access a static member ----- (display "\nA total of ") (display (Shape-nshapes)) (display " shapes were created\n") ;; ----- Member data access ----- ;; Set the location of the object (Shape-x-set c 20.0) (Shape-y-set c 30.0) (Shape-x-set s -10.0) (Shape-y-set s 5.0) (display "\nHere is their current position:\n") (display " Circle = (") (display (Shape-x-get c)) (display ", ") (display (Shape-y-get c)) (display ")\n") (display " Square = (") (display (Shape-x-get s)) (display ", ") (display (Shape-y-get s)) (display ")\n") ;; ----- Call some methods ----- (display "\nHere are some properties of the shapes:\n") (let ((disp (lambda (o) (display " ") (display o) (display "\n") (display " area = ") (display (Shape-area o)) (display "\n") (display " perimeter = ") (display (Shape-perimeter o)) (display "\n")))) (disp c) (disp s)) (display "\nGuess I'll clean up now\n") ;; Note: this invokes the virtual destructor (set! c #f) (set! s #f) (gc #t) (set! s 3) (display (Shape-nshapes)) (display " shapes remain\n") (display "Goodbye\n") (exit) swig-3.0.2/Examples/chicken/class/example.i0000664000175000017500000000021512343605122020435 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/chicken/class/example.cxx0000664000175000017500000000065012343605122021012 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/chicken/class/Makefile0000664000175000017500000000251012343605122020270 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = CXXSRCS = example.cxx TARGET = class INCLUDE = SWIGOPT = VARIANT = # uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines) #CHICKEN_MAIN = runme-lowlevel.scm #CHICKEN_MAIN = runme-tinyclos.scm #VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CHICKEN_SCRIPT='runme-tinyclos.scm' chicken_run build: $(TARGET) $(TARGET)_proxy $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp $(TARGET)_proxy: $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean rm -f example.scm rm -f $(TARGET) swig-3.0.2/Examples/chicken/class/runme-tinyclos.scm0000664000175000017500000000315612343605122022333 0ustar williamwilliam;; This file illustrates the proxy C++ interface generated ;; by SWIG. (load-library 'example "class_proxy.so") (declare (uses example)) (declare (uses tinyclos)) ;; ----- Object creation ----- (display "Creating some objects:\n") (define c (make 10.0)) (display " Created circle ") (display c) (display "\n") (define s (make 10.0)) (display " Created square ") (display s) (display "\n") ;; ----- Access a static member ----- (display "\nA total of ") (display (Shape-nshapes)) (display " shapes were created\n") ;; ----- Member data access ----- ;; Set the location of the object (slot-set! c 'x 20.0) (slot-set! c 'y 30.0) (slot-set! s 'x -10.0) (slot-set! s 'y 5.0) (display "\nHere is their current position:\n") (display " Circle = (") (display (slot-ref c 'x)) (display ", ") (display (slot-ref c 'y)) (display ")\n") (display " Square = (") (display (slot-ref s 'x)) (display ", ") (display (slot-ref s 'y)) (display ")\n") ;; ----- Call some methods ----- (display "\nHere are some properties of the shapes:\n") (let ((disp (lambda (o) (display " ") (display o) (display "\n") (display " area = ") (display (area o)) (display "\n") (display " perimeter = ") (display (perimeter o)) (display "\n")))) (disp c) (disp s)) (display "\nGuess I'll clean up now\n") ;; Note: Invoke the virtual destructors by forcing garbage collection (set! c 77) (set! s 88) (gc #t) (display (Shape-nshapes)) (display " shapes remain\n") (display "Goodbye\n") (exit) swig-3.0.2/Examples/chicken/simple/0000775000175000017500000000000012343605122017016 5ustar williamwilliamswig-3.0.2/Examples/chicken/simple/README0000664000175000017500000000004212343605122017672 0ustar williamwilliamSimple example from users manual. swig-3.0.2/Examples/chicken/simple/example.c0000664000175000017500000000056612343605122020624 0ustar williamwilliam/* Simple example from documentation */ /* File : example.c */ #include double My_variable = 3.0; /* Compute factorial of n */ int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } /* Compute n mod m */ int my_mod(int n, int m) { return (n % m); } char *get_time() { long ltime; time(<ime); return ctime(<ime); } swig-3.0.2/Examples/chicken/simple/example.i0000664000175000017500000000041012343605122020616 0ustar williamwilliam/* File : example.i */ %module example %{ /* Put headers and other declarations here */ %} %include typemaps.i %rename(mod) my_mod; %inline %{ extern double My_variable; extern int fact(int); extern int my_mod(int n, int m); extern char *get_time(); %} swig-3.0.2/Examples/chicken/simple/runme.scm0000664000175000017500000000075712343605122020661 0ustar williamwilliam;; feel free to uncomment and comment sections (load-library 'example "simple.so") (display "(My-variable): ") (display (My-variable)) (display "\n") (display "(My-variable 3.141259): ") (display (My-variable 3.141259)) (display "\n") (display "(My-variable): ") (display (My-variable)) (display "\n") (display "(fact 5): ") (display (fact 5)) (display "\n") (display "(mod 75 7): ") (display (mod 75 7)) (display "\n") (display "(get-time): ") (display (get-time)) (display "\n") (exit) swig-3.0.2/Examples/chicken/simple/Makefile0000664000175000017500000000147412343605122020464 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = example.c CXXSRCS = TARGET = simple INCLUDE = SWIGOPT = VARIANT = # uncomment the following two lines to build a static exe #CHICKEN_MAIN = runme.scm #VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean rm -f example.scm example-generic.scm example-clos.scm rm -f $(TARGET) swig-3.0.2/Examples/chicken/constants/0000775000175000017500000000000012343605122017541 5ustar williamwilliamswig-3.0.2/Examples/chicken/constants/example.i0000664000175000017500000000133112343605122021344 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants. Remember that CHICKEN is normally case-insensitive, so don't rely on differing case to differentiate variable names */ %constant int iconstX = 37; %constant double fconstX = 3.14; swig-3.0.2/Examples/chicken/constants/runme.scm0000664000175000017500000000114612343605122021375 0ustar williamwilliam;; feel free to uncomment and comment sections (load-library 'example "./constants.so") (display "starting test ... you will see 'finished' if successful.\n") (or (= (ICONST) 42) (exit 1)) (or (< (abs (- (FCONST) 2.1828)) 0.00001) (exit 1)) (or (char=? (CCONST) #\x) (exit 1)) (or (char=? (CCONST2) #\newline) (exit 1)) (or (string=? (SCONST) "Hello World") (exit 1)) (or (string=? (SCONST2) "\"Hello World\"") (exit 1)) (or (< (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))) 0.00001) (exit 1)) (or (= (iconstX) 37) (exit 1)) (or (< (abs (- (fconstX) 3.14)) 0.00001) (exit 1)) (display "finished test.\n") (exit 0) swig-3.0.2/Examples/chicken/constants/Makefile0000664000175000017500000000142012343605122021176 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = CXXSRCS = TARGET = constants INCLUDE = SWIGOPT = VARIANT = # uncomment the following two lines to build a static exe #CHICKEN_MAIN = runme.scm #VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean rm -f example.scm rm -f $(TARGET) swig-3.0.2/Examples/chicken/egg/0000775000175000017500000000000012343605122016267 5ustar williamwilliamswig-3.0.2/Examples/chicken/egg/README0000664000175000017500000000134112343605122017146 0ustar williamwilliamThese examples show how to build a chicken extension module in the form of an egg. There are two eggs that get built, single.egg which contains a single module which is built with -nounit and multi.egg, which contains two modules mod1 and mod2. These are built normally, and multi_init.scm loads them both. Read section "17.4.2 Building chicken extension libraries" in the manual for a description of these two techniques. To build: $ make $ make setup $ make run $ make clean The eggs are built into an eggs subdirectory, because chicken-setup has problems installing eggs when there are other files named similar in the same directory. The make setup step runs chicken-setup to install the eggs into the eggs/install directory. swig-3.0.2/Examples/chicken/egg/multi.setup0000664000175000017500000000020112343605122020474 0ustar williamwilliam(run (csc -s -o multi.so multi_init.scm mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx)) (install-extension 'multi '("multi.so")) swig-3.0.2/Examples/chicken/egg/single.setup0000664000175000017500000000014212343605122020627 0ustar williamwilliam(run (csc -s -o single.so single.scm single_wrap.cxx)) (install-extension 'single '("single.so")) swig-3.0.2/Examples/chicken/egg/single.i0000664000175000017500000000010212343605122017713 0ustar williamwilliam%module single %inline %{ class Foo { public: int a; }; %} swig-3.0.2/Examples/chicken/egg/multi_init.scm0000664000175000017500000000005412343605122021147 0ustar williamwilliam(declare (uses mod1)) (declare (uses mod2)) swig-3.0.2/Examples/chicken/egg/mod2.i0000664000175000017500000000022312343605122017277 0ustar williamwilliam%module mod2 %import "mod1.i" %{ class Bar { public: int b; }; %} %inline %{ class Bar2 : public Bar { public: int c; }; %} swig-3.0.2/Examples/chicken/egg/Makefile0000664000175000017500000000212312343605122017725 0ustar williamwilliamSWIG = ../../../preinst-swig check: build cd eggs/install && csi ../../test.scm build: single multi # This creates an egg which contains only the single module. Any additional implementation files # that implement the interface being wrapped should also be added to this egg single: single_wrap.cxx mkdir -p eggs tar czf eggs/single.egg single.setup single.scm single_wrap.cxx rm -f single.scm single_wrap.cxx # compile the single module with -nounit single_wrap.cxx: single.i $(SWIG) -chicken -c++ -proxy -nounit single.i # Now build both mod1 and mod2 into a single egg multi: mod1_wrap.cxx mod2_wrap.cxx mkdir -p eggs tar czf eggs/multi.egg multi.setup multi_init.scm mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx rm -f mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx mod1_wrap.cxx: mod1.i $(SWIG) -chicken -c++ -proxy mod1.i mod2_wrap.cxx: mod2.i $(SWIG) -chicken -c++ -proxy mod2.i clean: rm -rf eggs # this part is for testing... setup: cd eggs && \ mkdir -p install && \ chicken-setup -repository `pwd`/install single.egg && \ chicken-setup -repository `pwd`/install multi.egg swig-3.0.2/Examples/chicken/egg/mod1.i0000664000175000017500000000010012343605122017270 0ustar williamwilliam%module mod1 %inline %{ class Bar { public: int b; }; %} swig-3.0.2/Examples/chicken/egg/test.scm0000664000175000017500000000047412343605122017757 0ustar williamwilliam(require-extension single) (require-extension multi) (define f (make )) (slot-set! f 'a 3) (print (slot-ref f 'a)) (define b (make )) (slot-set! b 'b 2) (print (slot-ref b 'b)) (define b2 (make )) (slot-set! b2 'b 4) (slot-set! b2 'c 6) (print (slot-ref b2 'b)) (print (slot-ref b2 'c)) (exit 0) swig-3.0.2/Examples/chicken/overload/0000775000175000017500000000000012343605122017340 5ustar williamwilliamswig-3.0.2/Examples/chicken/overload/README0000664000175000017500000000012212343605122020213 0ustar williamwilliamOverloading example from Chapter 5.14 of SWIG Core Documentation for version 1.3. swig-3.0.2/Examples/chicken/overload/example.h0000664000175000017500000000033612343605122021146 0ustar williamwilliam/* File : example.h */ extern void foo (int x); extern void foo (char *x); class Foo { private: int myvar; public: Foo(); Foo(const Foo &); // Copy constructor void bar(int x); void bar(char *s, int y); }; swig-3.0.2/Examples/chicken/overload/example.i0000664000175000017500000000053512343605122021150 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let "Foo" objects be converted back and forth from TinyCLOS into low-level CHICKEN SWIG procedures */ %typemap(clos_in) Foo * = SIMPLE_CLOS_OBJECT *; %typemap(clos_out) Foo * = SIMPLE_CLOS_OBJECT *; /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/chicken/overload/example.cxx0000664000175000017500000000104112343605122021513 0ustar williamwilliam/* File : example.c */ #include "example.h" #include void foo(int x) { printf("x is %d\n", x); } void foo(char *x) { printf("x is '%s'\n", x); } Foo::Foo () { myvar = 55; printf ("Foo constructor called\n"); } Foo::Foo (const Foo &) { myvar = 66; printf ("Foo copy constructor called\n"); } void Foo::bar (int x) { printf ("Foo::bar(x) method ... \n"); printf("x is %d\n", x); } void Foo::bar (char *s, int y) { printf ("Foo::bar(s,y) method ... \n"); printf ("s is '%s'\n", s); printf ("y is %d\n", y); } swig-3.0.2/Examples/chicken/overload/runme.scm0000664000175000017500000000204512343605122021173 0ustar williamwilliam;; This file demonstrates the overloading capabilities of SWIG (load-library 'example "overload.so") ;; Low level ;; --------- (display " Trying low level code ... (foo 1) (foo \"some string\") (define A-FOO (new-Foo)) (define ANOTHER-FOO (new-Foo A-FOO)) ;; copy constructor (Foo-bar A-FOO 2) (Foo-bar ANOTHER-FOO \"another string\" 3) ") (primitive:foo 1) (primitive:foo "some string") (define A-FOO (slot-ref (primitive:new-Foo) 'swig-this)) (define ANOTHER-FOO (slot-ref (primitive:new-Foo A-FOO) 'swig-this)) ;; copy constructor (primitive:Foo-bar A-FOO 2) (primitive:Foo-bar ANOTHER-FOO "another string" 3) ;; TinyCLOS ;; -------- (display " Trying TinyCLOS code ... (+foo+ 1) (+foo+ \"some string\") (define A-FOO (make )) (define ANOTHER-FOO (make A-FOO)) ;; copy constructor (-bar- A-FOO 2) (-bar- ANOTHER-FOO \"another string\" 3) ") (foo 1) (foo "some string") (define A-FOO (make )) (define ANOTHER-FOO (make A-FOO)) ;; copy constructor (bar A-FOO 2) (bar ANOTHER-FOO "another string" 3) (exit) swig-3.0.2/Examples/chicken/overload/Makefile0000664000175000017500000000146312343605122021004 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = CXXSRCS = example.cxx TARGET = overload INCLUDE = SWIGOPT = -proxy -unhideprimitive VARIANT = # uncomment the following lines to build a static exe #CHICKEN_MAIN = runme.scm #VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean rm -f example.scm rm -f $(TARGET) swig-3.0.2/Examples/chicken/check.list0000664000175000017500000000010512343605122017473 0ustar williamwilliam# see top-level Makefile.in class constants multimap overload simple swig-3.0.2/Examples/chicken/multimap/0000775000175000017500000000000012343605122017355 5ustar williamwilliamswig-3.0.2/Examples/chicken/multimap/example.c0000664000175000017500000000164012343605122021155 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.2/Examples/chicken/multimap/example.i0000664000175000017500000000463412343605122021171 0ustar williamwilliam/* File : example.i */ %module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} %include exception.i %include typemaps.i extern int gcd(int x, int y); %typemap(in) (int argc, char *argv[]) { int i; if (!C_swig_is_vector ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a vector"); } $1 = C_header_size ($input); $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++) { C_word o = C_block_item ($input, i); if (!C_swig_is_string (o)) { char err[50]; free($2); sprintf (err, "$input[%d] is not a string", i); swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, err); } $2[i] = C_c_string (o); } $2[i] = 0; } %typemap(freearg) (int argc, char *argv[]) { free($2); } extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string"); } $1 = C_c_string ($input); $2 = C_header_size ($input); } extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a string */ %typemap(in) (char *str, int len) %{ if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string"); } $2 = C_header_size ($input); $1 = (char *) malloc ($2+1); memmove ($1, C_c_string ($input), $2); %} /* Return the mutated string as a new object. Notice the if MANY construct ... they must be at column 0. */ %typemap(argout) (char *str, int len) (C_word *scmstr) %{ scmstr = C_alloc (C_SIZEOF_STRING ($2)); SWIG_APPEND_VALUE(C_string (&scmstr, $2, $1)); free ($1); %} extern void capitalize (char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { SWIG_exception (SWIG_ValueError, "cx and cy must be in unit circle"); } } extern void circle (double cx, double cy); /* Test out multiple return values */ extern int squareCubed (int n, int *OUTPUT); %{ /* Returns n^3 and set n2 to n^2 */ int squareCubed (int n, int *n2) { *n2 = n * n; return (*n2) * n; }; %} swig-3.0.2/Examples/chicken/multimap/runme.scm0000664000175000017500000000270612343605122021214 0ustar williamwilliam;; feel free to uncomment and comment sections (load-library 'example "multimap.so") (display "(gcd 90 12): ") (display (gcd 90 12)) (display "\n") (display "(circle 0.5 0.5): ") (display (circle 0.5 0.5)) (display "\n") (display "(circle 1.0 1.0): ") (handle-exceptions exvar (if (= (car exvar) 9) (display "success: exception thrown") (display "an incorrect exception was thrown")) (begin (circle 1.0 1.0) (display "an exception was not thrown when it should have been"))) (display "\n") (display "(circle 1 1): ") (handle-exceptions exvar (if (= (car exvar) 9) (display "success: exception thrown") (display "an incorrect exception was thrown")) (begin (circle 1 1) (display "an exception was not thrown when it should have been"))) (display "\n") (display "(capitalize \"will this be all capital letters?\"): ") (display (capitalize "will this be all capital letters?")) (display "\n") (display "(count \"jumpity little spider\" #\\t): ") (display (count "jumpity little spider" #\t)) (display "\n") (display "(gcdmain '#(\"hi\" \"there\")): ") (display (gcdmain '#("hi" "there"))) (display "\n") (display "(gcdmain '#(\"gcd\" \"9\" \"28\")): ") (gcdmain '#("gcd" "9" "28")) (display "\n") (display "(gcdmain '#(\"gcd\" \"12\" \"90\")): ") (gcdmain '#("gcd" "12" "90")) (display "\n") (display "squarecubed 3: ") (call-with-values (lambda() (squareCubed 3)) (lambda (a b) (printf "~A ~A" a b))) (display "\n") (exit) swig-3.0.2/Examples/chicken/multimap/Makefile0000664000175000017500000000143112343605122021014 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = example.c CXXSRCS = TARGET = multimap INCLUDE = SWIGOPT = VARIANT = # uncomment the following two lines to build a static exe #CHICKEN_MAIN = runme.scm #VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean rm -f example.scm rm -f $(TARGET) swig-3.0.2/Examples/php/0000775000175000017500000000000012343605122014710 5ustar williamwilliamswig-3.0.2/Examples/php/class/0000775000175000017500000000000012343605122016015 5ustar williamwilliamswig-3.0.2/Examples/php/class/example.h0000664000175000017500000000107612343605122017625 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/php/class/example.i0000664000175000017500000000021512343605122017620 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/php/class/example.cxx0000664000175000017500000000065012343605122020175 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/php/class/runme.php0000664000175000017500000000256512343605122017664 0ustar williamwilliamx = 20; $c->y = 30; $s->x = -10; $s->y = 5; print "\nHere is their current position:\n"; print " Circle = ({$c->x},{$c->y})\n"; print " Square = ({$s->x},{$s->y})\n"; # ----- Call some methods ----- # Notice how the Shape_area() and Shape_perimeter() functions really # invoke the appropriate virtual method on each object. print "\nHere are some properties of the shapes:\n"; foreach (array($c,$s) as $o) { print " ". get_class($o) . "\n"; print " area = {$o->area()}\n"; print " perimeter = {$o->perimeter()}\n"; } # ----- Delete everything ----- print "\nGuess I'll clean up now\n"; # Note: this invokes the virtual destructor $c = NULL; $s = NULL; # and don't forget the $o from the for loop above. It still refers to # the square. $o = NULL; print Shape::nshapes() . " shapes remain\n"; print "Goodbye\n"; ?> swig-3.0.2/Examples/php/class/Makefile0000664000175000017500000000116412343605122017457 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/pragmas/0000775000175000017500000000000012343605122016342 5ustar williamwilliamswig-3.0.2/Examples/php/pragmas/example.i0000664000175000017500000000073612343605122020155 0ustar williamwilliam/* File : example.i */ %module example %init{ zend_printf("This was %%init\n"); } %minit{ zend_printf("This was %%minit\n"); } %mshutdown{ zend_printf("This was %%shutdown\n"); } %rinit{ zend_printf("This was %%rinit\n"); } %rshutdown{ zend_printf("This was %%rshutdown\n"); } %pragma(php) include="include.php"; %pragma(php) code=" # This code is inserted into example.php echo \"this was php code\\n\"; " %pragma(php) phpinfo="php_info_print_table_start();" swig-3.0.2/Examples/php/pragmas/include.php0000664000175000017500000000012312343605122020472 0ustar williamwilliam swig-3.0.2/Examples/php/pragmas/runme.php0000664000175000017500000000004212343605122020175 0ustar williamwilliam swig-3.0.2/Examples/php/pragmas/Makefile0000664000175000017500000000112412343605122020000 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/pointer/0000775000175000017500000000000012343605122016370 5ustar williamwilliamswig-3.0.2/Examples/php/pointer/example.c0000664000175000017500000000037312343605122020172 0ustar williamwilliam/* File : example.c */ void add(double *x, double *y, double *result) { *result = *x + *y; } void sub(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/php/pointer/example.i0000664000175000017500000000117212343605122020176 0ustar williamwilliam/* File : example.i */ %module example %{ extern void add(double *, double *, double *); extern void sub(int *, int *, int *); extern int divide(int, int, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ %include phppointers.i /* First we'll use the pointer library */ extern void add(double *REF, double *REF, double *REF); /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ //%apply int *OUTPUT { int *r }; //extern int divide(int n, int d, int *r); swig-3.0.2/Examples/php/pointer/runme.php0000664000175000017500000000133512343605122020231 0ustar williamwilliam swig-3.0.2/Examples/php/pointer/Makefile0000664000175000017500000000113612343605122020031 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/enum/0000775000175000017500000000000012343605122015654 5ustar williamwilliamswig-3.0.2/Examples/php/enum/example.h0000664000175000017500000000031512343605122017457 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE, WARP, LUDICROUS }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/php/enum/example.i0000664000175000017500000000022012343605122017453 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/php/enum/example.cxx0000664000175000017500000000151112343605122020031 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/php/enum/runme.php0000664000175000017500000000126612343605122017520 0ustar williamwilliam swig-3.0.2/Examples/php/enum/Makefile0000664000175000017500000000117512343605122017320 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = -noproxy check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/simple/0000775000175000017500000000000012343605122016201 5ustar williamwilliamswig-3.0.2/Examples/php/simple/example.c0000664000175000017500000000050312343605122017776 0ustar williamwilliam/* File : example.c */ #include /* A global variable */ double Foo = 3.0; void print_Foo() { printf("In C, Foo = %f\n",Foo); } /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/php/simple/example.i0000664000175000017500000000017412343605122020010 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; void print_Foo(); %} swig-3.0.2/Examples/php/simple/runme.php0000664000175000017500000000065712343605122020050 0ustar williamwilliam swig-3.0.2/Examples/php/simple/Makefile0000664000175000017500000000113612343605122017642 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/constants/0000775000175000017500000000000012343605122016724 5ustar williamwilliamswig-3.0.2/Examples/php/constants/example.i0000664000175000017500000000114112343605122020526 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following statements also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/php/constants/runme.php0000664000175000017500000000162012343605122020562 0ustar williamwilliam swig-3.0.2/Examples/php/constants/Makefile0000664000175000017500000000112412343605122020362 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/extend/0000775000175000017500000000000012343605122016177 5ustar williamwilliamswig-3.0.2/Examples/php/extend/example.h0000664000175000017500000000260512343605122020006 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *get_item(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; swig-3.0.2/Examples/php/extend/example.i0000664000175000017500000000040312343605122020001 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_vector.i" %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; %include "example.h" swig-3.0.2/Examples/php/extend/example.cxx0000664000175000017500000000006012343605122020352 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/php/extend/index.html0000664000175000017500000000044312343605122020175 0ustar williamwilliam SWIG:Examples:php:extend SWIG/Examples/php/extend/

      Extending a simple C++ class in PHP

      This example illustrates the extending of a C++ class with cross language polymorphism.


      swig-3.0.2/Examples/php/extend/runme.php0000664000175000017500000000601012343605122020033 0ustar williamwilliamgetName() . " is a " . $e->getPosition() . "\n"; printf("Just call her \"%s\"\n", $e->getTitle()); print "----------------------\n"; # Create a new EmployeeList instance. This class does not have a C++ # director wrapper, but can be used freely with other classes that do. $list = new EmployeeList(); # EmployeeList owns its items, so we must surrender ownership of objects # we add. This involves first clearing the ->disown member to tell the # C++ director to start reference counting. $e->thisown = 0; $list->addEmployee($e); print "----------------------\n"; # Now we access the first four items in list (three are C++ objects that # EmployeeList's constructor adds, the last is our CEO). The virtual # methods of all these instances are treated the same. For items 0, 1, and # 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls # getPosition which resolves in PHP. The call to getPosition is # slightly different, however, from the e.getPosition() call above, since # now the object reference has been "laundered" by passing through # EmployeeList as an Employee*. Previously, PHP resolved the call # immediately in CEO, but now PHP thinks the object is an instance of # class Employee (actually EmployeePtr). So the call passes through the # Employee proxy class and on to the C wrappers and C++ director, # eventually ending up back at the CEO implementation of getPosition(). # The call to getTitle() for item 3 runs the C++ Employee::getTitle() # method, which in turn calls getPosition(). This virtual method call # passes down through the C++ director class to the PHP implementation # in CEO. All this routing takes place transparently. print "(position, title) for items 0-3:\n"; printf(" %s, \"%s\"\n", $list->get_item(0)->getPosition(), $list->get_item(0)->getTitle()); printf(" %s, \"%s\"\n", $list->get_item(1)->getPosition(), $list->get_item(1)->getTitle()); printf(" %s, \"%s\"\n", $list->get_item(2)->getPosition(), $list->get_item(2)->getTitle()); printf(" %s, \"%s\"\n", $list->get_item(3)->getPosition(), $list->get_item(3)->getTitle()); print "----------------------\n"; # Time to delete the EmployeeList, which will delete all the Employee* # items it contains. The last item is our CEO, which gets destroyed as its # reference count goes to zero. The PHP destructor runs, and is still # able to call the getName() method since the underlying C++ object still # exists. After this destructor runs the remaining C++ destructors run as # usual to destroy the object. unset($list); print "----------------------\n"; # All done. print "php exit\n"; ?> swig-3.0.2/Examples/php/extend/Makefile0000664000175000017500000000121012343605122017631 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/cpointer/0000775000175000017500000000000012343605122016533 5ustar williamwilliamswig-3.0.2/Examples/php/cpointer/example.c0000664000175000017500000000036212343605122020333 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void sub(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/php/cpointer/example.i0000664000175000017500000000114012343605122020334 0ustar williamwilliam/* File : example.i */ %module example %{ extern void add(int *, int *, int *); extern void sub(int *, int *, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ //%apply int *OUTPUT { int *r }; //extern int divide(int n, int d, int *r); swig-3.0.2/Examples/php/cpointer/runme.php0000664000175000017500000000176212343605122020400 0ustar williamwilliam swig-3.0.2/Examples/php/cpointer/Makefile0000664000175000017500000000113612343605122020174 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/reference/0000775000175000017500000000000012343605122016646 5ustar williamwilliamswig-3.0.2/Examples/php/reference/example.h0000664000175000017500000000065112343605122020454 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; friend Vector operator+(const Vector &a, const Vector &b); char *as_string(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/php/reference/example.i0000664000175000017500000000164112343605122020455 0ustar williamwilliam/* File : example.i */ /* This example has nothing to do with references but the name is used by all * the other languages so it's hard to rename to something more meaningful. * * Mostly it shows how to use %extend. */ %module example %{ #include "example.h" %} class Vector { public: Vector(double x, double y, double z); ~Vector(); char *as_string(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { printf("VectorArray extended get: %p %d\n", (void *)$self, index); return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.2/Examples/php/reference/example.cxx0000664000175000017500000000220312343605122021022 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::as_string() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; printf("VectorArray new: self=%p\n", (void *)this); } VectorArray::~VectorArray() { printf("VectorArray delete: self=%p\n", (void *)this); delete [] items; } Vector &VectorArray::operator[](int index) { printf("VectorArray: read[%d] self=%p\n", index, (void *)this); if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { printf("VectorArray: size %d self=%p\n", maxsize, (void *)this); return maxsize; } swig-3.0.2/Examples/php/reference/runme.php0000664000175000017500000000203612343605122020506 0ustar williamwilliamas_string()}\n"; print " Created b: {$b->as_string()}\n"; # ----- Call an overloaded operator ----- # This calls the wrapper we placed around # # operator+(const Vector &a, const Vector &) # # It returns a new allocated object. print "Adding a+b\n"; $c = example::addv($a, $b); print " a+b ={$c->as_string()}\n"; # ----- Create a vector array ----- print "Creating an array of vectors\n"; $va = new VectorArray(10); print " va: size={$va->size()}\n"; # ----- 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(2, addv($a, $b)); # Get some values from the array print "Getting some array values\n"; for ($i = 0; $i < 5; $i++) { print " va[$i] = {$va->get($i)->as_string()}\n"; } ?> swig-3.0.2/Examples/php/reference/Makefile0000664000175000017500000000116412343605122020310 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/sync/0000775000175000017500000000000012343605122015664 5ustar williamwilliamswig-3.0.2/Examples/php/sync/example.h0000664000175000017500000000014212343605122017465 0ustar williamwilliamextern char *s; extern int x; class Sync { public: int x; char *s; void printer(void); }; swig-3.0.2/Examples/php/sync/example.i0000664000175000017500000000010212343605122017462 0ustar williamwilliam%module example %{ #include "example.h" %} %include "example.h" swig-3.0.2/Examples/php/sync/example.cxx0000664000175000017500000000044012343605122020041 0ustar williamwilliam#include "example.h" #include int x = 42; char *s = (char *)"Test"; void Sync::printer(void) { printf("The value of global s is %s\n", s); printf("The value of global x is %d\n", x); printf("The value of class s is %s\n", s); printf("The value of class x is %d\n", x); } swig-3.0.2/Examples/php/sync/runme.php0000664000175000017500000000027412343605122017526 0ustar williamwilliamprinter(); ?> swig-3.0.2/Examples/php/sync/Makefile0000664000175000017500000000116412343605122017326 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/check.list0000664000175000017500000000031412343605122016660 0ustar williamwilliam# see top-level Makefile.in # (see also top-level configure.ac kludge) callback class constants cpointer disown enum extend funcptr overloading pointer pragmas proxy reference simple sync value variables swig-3.0.2/Examples/php/proxy/0000775000175000017500000000000012343605122016071 5ustar williamwilliamswig-3.0.2/Examples/php/proxy/example.h0000664000175000017500000000136412343605122017701 0ustar williamwilliam/* File : example.h */ #include class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; static int get_nshapes(); }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; ~Circle() { }; void set_radius( double r ); virtual double area(void); virtual double perimeter(void); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { }; ~Square() { } virtual double area(void); virtual double perimeter(void); }; Circle *CircleFactory( double r ); swig-3.0.2/Examples/php/proxy/example.i0000664000175000017500000000025112343605122017674 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %newobject CircleFactory; %include "example.h" swig-3.0.2/Examples/php/proxy/example.cxx0000664000175000017500000000120412343605122020245 0ustar williamwilliam/* File : example.c */ #include "example.h" #include #ifndef M_PI # define M_PI 3.14159265358979323846 #endif int Shape::get_nshapes() { return nshapes; } /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; void Circle::set_radius( double r ) { radius = r; } double Circle::area(void) { return M_PI*radius*radius; } double Circle::perimeter(void) { return 2*M_PI*radius; } double Square::area(void) { return width*width; } double Square::perimeter(void) { return 4*width; } Circle *CircleFactory( double r ) { return new Circle(r); } swig-3.0.2/Examples/php/proxy/runme.php0000664000175000017500000000314612343605122017734 0ustar williamwilliamarea() ."\n"; $s = new Square(10); print " Created square \$s\n"; # ----- Access a static member ----- print "\nA total of " . Shape::nshapes() . " shapes were created\n"; # ----- Member data access ----- # Set the location of the object. # Note: methods in the base class Shape are used since # x and y are defined there. $c->x = 20; $c->y = 30; $s->x = -10; $s->y = 5; print "\nHere is their current position:\n"; print " Circle = (" . $c->x . "," . $c->y . ")\n"; print " Square = (" . $s->x . "," . $s->y . ")\n"; # ----- Call some methods ----- print "\nHere are some properties of the shapes:\n"; foreach (array($c,$s) as $o) { print " ".get_class($o)." \$o\n"; print " x = " . $o->x . "\n"; print " y = " . $o->y . "\n"; print " area = " . $o->area() . "\n"; print " perimeter = " . $o->perimeter() . "\n"; } # Need to unset($o) or else we hang on to a reference to the Square object. unset($o); # ----- Delete everything ----- print "\nGuess I'll clean up now\n"; # Note: this invokes the virtual destructor unset($c); $s = 42; print Shape::nshapes() . " shapes remain\n"; print "Manually setting nshapes\n"; Shape::nshapes(42); print Shape::get_nshapes() ." == 42\n"; print "Goodbye\n"; ?> swig-3.0.2/Examples/php/proxy/Makefile0000664000175000017500000000116412343605122017533 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/overloading/0000775000175000017500000000000012343605122017221 5ustar williamwilliamswig-3.0.2/Examples/php/overloading/example.h0000664000175000017500000000155312343605122021031 0ustar williamwilliam/* File : example.h */ #include class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; static int get_nshapes(); }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } ~Circle() { } virtual double area(void); virtual double perimeter(void); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } ~Square() { } virtual double area(void); virtual double perimeter(void); }; const char *overloaded( int i ); const char *overloaded( double d ); const char *overloaded( const char * str ); const char *overloaded( const Circle& ); const char *overloaded( const Shape& ); swig-3.0.2/Examples/php/overloading/example.i0000664000175000017500000000013112343605122021021 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include "example.h" swig-3.0.2/Examples/php/overloading/example.cxx0000664000175000017500000000161112343605122021377 0ustar williamwilliam/* File : example.c */ #include "example.h" #include #ifndef M_PI # define M_PI 3.14159265358979323846 #endif int Shape::get_nshapes() { return nshapes; } /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area(void) { return M_PI*radius*radius; } double Circle::perimeter(void) { return 2*M_PI*radius; } double Square::area(void) { return width*width; } double Square::perimeter(void) { return 4*width; } const char *overloaded(int i) { return "Overloaded with int"; } const char *overloaded(double d) { return "Overloaded with double"; } const char *overloaded(const char * str) { return "Overloaded with char *"; } const char *overloaded( const Circle& ) { return "Overloaded with Circle"; } const char *overloaded( const Shape& ) { return "Overloaded with Shape"; } swig-3.0.2/Examples/php/overloading/runme.php0000664000175000017500000000243412343605122021063 0ustar williamwilliamx = 20; $c->y = 30; $s->x = -10; $s->y = 5; print "\nHere is their current position:\n"; print " Circle = (" . $c->x . "," . $c->y . ")\n"; print " Square = (" . $s->x . "," . $s->y . ")\n"; # ----- Call some methods ----- print "\nCall some overloaded methods:\n"; foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) { print " overloaded = " . overloaded($o) . "\n"; } # Need to unset($o) or else we hang on to a reference to the Square object. unset($o); # ----- Delete everything ----- print "\nGuess I'll clean up now\n"; # Note: this invokes the virtual destructor unset($c); $s = 42; print Shape::nshapes() . " shapes remain\n"; print "Goodbye\n"; ?> swig-3.0.2/Examples/php/overloading/Makefile0000664000175000017500000000116412343605122020663 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/disown/0000775000175000017500000000000012343605122016213 5ustar williamwilliamswig-3.0.2/Examples/php/disown/example.h0000664000175000017500000000163412343605122020023 0ustar williamwilliam/* File : example.h */ #include class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; static int get_nshapes(); }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; ~Circle() { }; void set_radius( double r ); virtual double area(void); virtual double perimeter(void); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { }; ~Square() { } virtual double area(void); virtual double perimeter(void); }; class ShapeContainer { private: typedef std::vector::iterator iterator; std::vector shapes; public: ShapeContainer() : shapes() {}; ~ShapeContainer(); void addShape( Shape *s ); }; swig-3.0.2/Examples/php/disown/example.i0000664000175000017500000000026512343605122020023 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %apply SWIGTYPE *DISOWN {(Shape *s)}; /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/php/disown/example.cxx0000664000175000017500000000144312343605122020374 0ustar williamwilliam/* File : example.c */ #include "example.h" #include #ifndef M_PI # define M_PI 3.14159265358979323846 #endif int Shape::get_nshapes() { return nshapes; } /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; void Circle::set_radius( double r ) { radius = r; } double Circle::area(void) { return M_PI*radius*radius; } double Circle::perimeter(void) { return 2*M_PI*radius; } double Square::area(void) { return width*width; } double Square::perimeter(void) { return 4*width; } ShapeContainer::~ShapeContainer() { iterator i=shapes.begin(); for( iterator i = shapes.begin(); i != shapes.end(); ++i ) { delete *i; } } void ShapeContainer::addShape( Shape *s ) { shapes.push_back( s ); } swig-3.0.2/Examples/php/disown/runme.php0000664000175000017500000000213212343605122020050 0ustar williamwilliamaddShape($c); $container->addShape($s); # ----- Access a static member ----- print "\nA total of " . Shape::nshapes() . " shapes were created\n"; # ----- Delete by the old references ----- # This should not truely delete the shapes because they are now owned # by the ShapeContainer. print "Delete the old references."; # Note: this invokes the virtual destructor $c = NULL; $s = NULL; print "\nA total of " . Shape::nshapes() . " shapes remain\n"; # ----- Delete by the container ----- # This should truely delete the shapes print "Delete the container."; $container = NULL; print "\nA total of " . Shape::nshapes() . " shapes remain\n"; print "Goodbye\n"; ?> swig-3.0.2/Examples/php/disown/Makefile0000664000175000017500000000116412343605122017655 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/funcptr/0000775000175000017500000000000012343605122016371 5ustar williamwilliamswig-3.0.2/Examples/php/funcptr/example.c0000664000175000017500000000033012343605122020164 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } swig-3.0.2/Examples/php/funcptr/example.h0000664000175000017500000000022212343605122020171 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); swig-3.0.2/Examples/php/funcptr/example.i0000664000175000017500000000052012343605122020173 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; swig-3.0.2/Examples/php/funcptr/runme.php0000664000175000017500000000116212343605122020230 0ustar williamwilliam swig-3.0.2/Examples/php/funcptr/Makefile0000664000175000017500000000113612343605122020032 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/value/0000775000175000017500000000000012343605122016024 5ustar williamwilliamswig-3.0.2/Examples/php/value/example.c0000664000175000017500000000040512343605122017622 0ustar williamwilliam/* File : example.c */ #include "example.h" double dot_product(Vector a, Vector b) { return (a.x*b.x + a.y*b.y + a.z*b.z); } void vector_add(Vector a, Vector b, Vector* result) { result->x = a.x + b.x; result->y = a.y + b.y; result->z = a.z + b.z; } swig-3.0.2/Examples/php/value/example.h0000664000175000017500000000024612343605122017632 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; double dot_product(Vector a, Vector b); void vector_add(Vector a, Vector b, Vector* result); swig-3.0.2/Examples/php/value/example.i0000664000175000017500000000044712343605122017636 0ustar williamwilliam// Tests SWIG's handling of pass-by-value for complex datatypes %module example %{ #include "example.h" %} %include "example.h" /* Some helper functions for our interface */ %inline %{ void vector_print(Vector *v) { printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z); } %} swig-3.0.2/Examples/php/value/runme.php0000664000175000017500000000134012343605122017661 0ustar williamwilliam swig-3.0.2/Examples/php/value/Makefile0000664000175000017500000000114712343605122017467 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = -noproxy check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/callback/0000775000175000017500000000000012343605122016444 5ustar williamwilliamswig-3.0.2/Examples/php/callback/example.h0000664000175000017500000000077612343605122020262 0ustar williamwilliam/* File : example.h */ #include class Callback { public: virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } }; swig-3.0.2/Examples/php/callback/example.i0000664000175000017500000000031212343605122020245 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_string.i" /* turn on director wrapping Callback */ %feature("director") Callback; %include "example.h" swig-3.0.2/Examples/php/callback/example.cxx0000664000175000017500000000006012343605122020617 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/php/callback/index.html0000664000175000017500000000043612343605122020444 0ustar williamwilliam SWIG:Examples:php:callback SWIG/Examples/php/callback/

      Implementing C++ callbacks in PHP

      This example illustrates how to use directors to implement C++ callbacks in PHP.


      swig-3.0.2/Examples/php/callback/runme.php0000664000175000017500000000165512343605122020312 0ustar williamwilliamthisown = 0; $caller->setCallback($callback); $caller->call(); $caller->delCallback(); print "\n"; print "Adding and calling a PHP callback\n"; print "------------------------------------\n"; # Add a PHP callback. $callback = new PhpCallback(); $callback->thisown = 0; $caller->setCallback($callback); $caller->call(); $caller->delCallback(); # All done. print "php exit\n"; ?> swig-3.0.2/Examples/php/callback/Makefile0000664000175000017500000000121012343605122020076 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/php/variables/0000775000175000017500000000000012343605122016660 5ustar williamwilliamswig-3.0.2/Examples/php/variables/example.c0000664000175000017500000000465512343605122020471 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[5] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]); printf("ptptr = %p %s\n", (void *)ptptr, Point_print( ptptr ) ); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } int value_int(int *value) { return *value; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/php/variables/example.h0000664000175000017500000000147712343605122020475 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; /* Some global variable declarations */ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[5]; extern Point *ptptr; extern Point pt; extern int status; extern char path[256]; extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); swig-3.0.2/Examples/php/variables/example.i0000664000175000017500000000167212343605122020473 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Some global variable declarations */ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[5]; extern Point *ptptr; extern Point pt; /* Some read-only variables */ %immutable; extern int status; extern char path[256]; %mutable; /* Some helper functions to make it easier to test */ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); swig-3.0.2/Examples/php/variables/runme.php0000664000175000017500000000453412343605122020525 0ustar williamwilliam swig-3.0.2/Examples/php/variables/Makefile0000664000175000017500000000113612343605122020321 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean swig-3.0.2/Examples/index.html0000664000175000017500000000271212343605122016120 0ustar williamwilliam SWIG Examples

      SWIG Examples

      Welcome to the browsable SWIG Examples directory. This directory contains a collection of examples that illustrate various SWIG features for a variety of target languages. First, it is important to cover a few preliminaries:

      • All of the examples depend on the file Examples/Makefile found within the SWIG distribution. This file is created by 'configure' and usually requires no modifications. However, if you have an usual installation of packages or experience compilation problems, you may need to make a few modifications.

      • The examples directory is a work in progress and will probably remain somewhat incomplete. At this time, the Examples directory is somewhat sparse since it is being rewritten and reoganized.

      • The SWIG user manual also contains a large variety of examples.

      Fundamentals

      Follow one of these links to see some simple examples for a specific target language: If your target platform is Windows, make sure you also see the Windows page in the main manual. swig-3.0.2/Examples/perl5/0000775000175000017500000000000012343605122015150 5ustar williamwilliamswig-3.0.2/Examples/perl5/class/0000775000175000017500000000000012343605122016255 5ustar williamwilliamswig-3.0.2/Examples/perl5/class/example.h0000664000175000017500000000134312343605122020062 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; typedef Square TSquare; class CFoo { public: static Square MakeSquare(void) {return Square(4.0);} static TSquare MakeTSquare(void) {return Square(4.0);} }; swig-3.0.2/Examples/perl5/class/example.i0000664000175000017500000000021512343605122020060 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/perl5/class/example.cxx0000664000175000017500000000065012343605122020435 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/perl5/class/index.html0000664000175000017500000000551712343605122020262 0ustar williamwilliam SWIG:Examples:perl5:class SWIG/Examples/perl5/class/

      Wrapping a simple C++ class

      This example illustrates the most primitive form of C++ class wrapping performed by SWIG. In this case, C++ classes are simply transformed into a collection of C-style functions that provide access to class members.

      The C++ Code

      Suppose you have some C++ classes described by the following (and admittedly lame) header file:
      /* File : example.h */
      
      class Shape {
      public:
        Shape() {
          nshapes++;
        }
        virtual ~Shape() {
          nshapes--;
        }
        double  x, y;
        void    move(double dx, double dy);
        virtual double area() = 0;
        virtual double perimeter() = 0;
        static  int nshapes;
      };
      
      class Circle : public Shape {
      private:
        double radius;
      public:
        Circle(double r) : radius(r) { }
        virtual double area();
        virtual double perimeter();
      };
      
      class Square : public Shape {
      private:
        double width;
      public:
        Square(double w) : width(w) { }
        virtual double area();
        virtual double perimeter();
      };
      

      The SWIG interface

      A simple SWIG interface for this can be built by simply grabbing the header file like this:
      /* File : example.i */
      %module example
      
      %{
      #include "example.h"
      %}
      
      /* Let's just grab the original header file here */
      %include "example.h"
      
      Note: when creating a C++ extension, you must run SWIG with the -c++ option like this:
      % swig -c++ -perl example.i
      

      A sample Perl script

      Click here to see a script that calls the C++ functions from Perl.

      Key points

      • To create a new object, you call a constructor like this:
        $c = new example::Circle(10.0);
        

      • You can access member data like so:
        $c->{x} = 15;    # Set member data
        $x = $c->{x};    # Get member data
        

      • To invoke a member function, you simply do this:
        print "The area is ", $c->area();
        

      • To invoke a destructor, simply do this:
        $c->DESTROY();   # Deletes a shape
        

      • Static member variables are wrapped like so:
        $n = $example::Shape::nshapes;    # Get a static data member
        $example::Shapes::nshapes = 13;   # Set a static data member
        

      General Comments

      • SWIG does know how to properly perform upcasting of objects in an inheritance hierarchy (including multiple inheritance). Therefore it is perfectly safe to pass an object of a derived class to any function involving a base class.
      • C++ Namespaces - %nspace isn't yet supported for Perl.

      swig-3.0.2/Examples/perl5/class/example.dsp0000664000175000017500000001213312343605122020420 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/perl5/class/runme.pl0000664000175000017500000000264412343605122017746 0ustar williamwilliam# file: runme.pl # This file illustrates the low-level C++ interface # created by SWIG. In this case, all of our C++ classes # get converted into function calls. use example; # ----- Object creation ----- print "Creating some objects:\n"; $c = new example::Circle(10); print " Created circle $c\n"; $s = new example::Square(10); print " Created square $s\n"; # ----- Access a static member ----- print "\nA total of $example::Shape::nshapes shapes were created\n"; # ----- Member data access ----- # Set the location of the object. # Note: methods in the base class Shape are used since # x and y are defined there. $c->{x} = 20; $c->{y} = 30; $s->{x} = -10; $s->{y} = 5; print "\nHere is their current position:\n"; print " Circle = (",$c->{x},",", $c->{y},")\n"; print " Square = (",$s->{x},",", $s->{y},")\n"; # ----- Call some methods ----- print "\nHere are some properties of the shapes:\n"; foreach $o ($c,$s) { print " $o\n"; print " area = ", $o->area(), "\n"; print " perimeter = ", $o->perimeter(), "\n"; } # ----- Delete everything ----- print "\nGuess I'll clean up now\n"; # Note: this invokes the virtual destructor $c->DESTROY(); $s->DESTROY(); print $example::Shape::nshapes," shapes remain\n"; $square = example::CFoo::MakeSquare(); $tsquare = example::CFoo::MakeTSquare(); print "Areas ", $square->area(), " ", $tsquare->area(),"\n"; print "Goodbye\n"; swig-3.0.2/Examples/perl5/class/Makefile0000664000175000017500000000110412343605122017711 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/pointer/0000775000175000017500000000000012343605122016630 5ustar williamwilliamswig-3.0.2/Examples/perl5/pointer/example.c0000664000175000017500000000036612343605122020434 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void subtract(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/perl5/pointer/example.i0000664000175000017500000000121012343605122020427 0ustar williamwilliam/* File : example.i */ %module example %{ extern void add(int *, int *, int *); extern void subtract(int *, int *, int *); extern int divide(int, int, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void subtract(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); swig-3.0.2/Examples/perl5/pointer/index.html0000664000175000017500000000665512343605122020641 0ustar williamwilliam SWIG:Examples:perl5:pointer SWIG/Examples/perl5/pointer/

      Simple Pointer Handling

      This example illustrates a couple of techniques for handling simple pointers in SWIG. The prototypical example is a C function that operates on pointers such as this:

      void add(int *x, int *y, int *r) { 
          *r = *x + *y;
      }
      
      By default, SWIG wraps this function exactly as specified and creates an interface that expects pointer objects for arguments. The only problem is how does one go about creating these objects from a script?

      Possible Solutions

      • Write some helper functions to explicitly create objects. For example:
        int *new_int(int ivalue) {
          int *i = (int *) malloc(sizeof(ivalue));
          *i = ivalue;
          return i;
        }
        int get_int(int *i) {
          return *i;
        }
        
        void delete_int(int *i) {
          free(i);
        }
        
        Now, in a script you would do this:
        $a = new_int(37);
        $b = new_int(42);
        $c = new_int(0):
        add($a,$b,$c);
        $r = get_int($c);
        print "Result = $r\n";
        delete_int($a);
        delete_int($b);
        delete_int($c);
        

      • Use the SWIG pointer library. For example, in the interface file you would do this:
        %include "pointer.i"
        
        $a = ptrcreate("int",37);
        $b = ptrcreate("int",42);
        $c = ptrcreate("int");
        add($a,$b,$c);
        $r = ptrvalue($c);
        print "Result = $r\n";
        ptrfree($a);
        ptrfree($b);
        ptrfree($c);
        
        The advantage to using the pointer library is that it unifies some of the helper functions behind a common set of names. For example, the same set of functions work with int, double, float, and other fundamental types.

      • Use the SWIG typemap library. This library allows you to completely change the way arguments are processed by SWIG. For example:
        %include "typemaps.i"
        void add(int *INPUT, int *INPUT, int *OUTPUT);
        
        And in a script:
        $r = add(37,42);
        print "Result = $r\n";
        
        Needless to say, this is substantially easier.

      • A final alternative is to use the typemaps library in combination with the %apply directive. This allows you to change the names of parameters that behave as input or output parameters. For example:
        %include "typemaps.i"
        %apply int *INPUT {int *x, int *y};
        %apply int *OUTPUT {int *r};
        
        void add(int *x, int *y, int *r);
        void subtract(int *x, int *y, int *r);
        void mul(int *x, int *y, int *r);
        ... etc ...
        

      Example

      The following example illustrates the use of these features for pointer extraction.

      Notes

      • Since pointers are used for so many different things (arrays, output values, etc...) the complexity of pointer handling can be as complicated as you want to make it.

      • More documentation on the typemaps.i and pointer.i library files can be found in the SWIG user manual. The files also contain documentation.

      • The pointer.i library is designed primarily for convenience. If you are concerned about performance, you probably want to use a different approach.

      swig-3.0.2/Examples/perl5/pointer/runme.pl0000664000175000017500000000172212343605122020315 0ustar williamwilliam# file: runme.pl use example; # First create some objects using the pointer library. print "Testing the pointer library\n"; $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\n"; print " b = $b\n"; print " c = $c\n"; # Call the add() function with some pointers example::add($a,$b,$c); # Now get the result $r = example::intp_value($c); print " 37 + 42 = $r\n"; # Clean up the pointers example::delete_intp($a); example::delete_intp($b); example::delete_intp($c); # Now try the typemap library # This should be much easier. Now how it is no longer # necessary to manufacture pointers. print "Trying the typemap library\n"; $r = example::subtract(37,42); print " 37 - 42 = $r\n"; # Now try the version with multiple return values print "Testing multiple return values\n"; ($q,$r) = example::divide(42,37); print " 42/37 = $q remainder $r\n"; swig-3.0.2/Examples/perl5/pointer/Makefile0000664000175000017500000000112412343605122020266 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/simple/0000775000175000017500000000000012343605122016441 5ustar williamwilliamswig-3.0.2/Examples/perl5/simple/example.c0000664000175000017500000000036712343605122020246 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/perl5/simple/example.i0000664000175000017500000000015212343605122020244 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/perl5/simple/index.html0000664000175000017500000000342312343605122020440 0ustar williamwilliam SWIG:Examples:perl5:simple SWIG/Examples/perl5/simple/

      Simple Perl5 Example

      This example illustrates how you can hook Perl to a very simple C program containing a function and a global variable.

      The C Code

      Suppose you have the following C code:
      /* File : example.c */
      
      /* A global variable */
      double Foo = 3.0;
      
      /* Compute the greatest common divisor of positive integers */
      int gcd(int x, int y) {
        int g;
        g = y;
        while (x > 0) {
          g = x;
          x = y % x;
          y = g;
        }
        return g;
      }
      

      The SWIG interface

      Here is a simple SWIG interface file:
      /* File: example.i */
      %module example
      
      extern int gcd(int x, int y);
      extern double Foo;
      

      Compilation

      1. swig -perl5 example.i

      2. This produces two files: example_wrap.c and example.pm.

      3. Compile example_wrap.c and example.c to create the extension example.so.

      Using the extension

      Click here to see a script that calls our C functions from Perl.

      Key points

      • Use the use statement to load your extension module from Perl. For example:
        use example;
        
      • C functions work just like Perl functions. For example:
        $g = example::gcd(42,105);
        
      • C global variables are accessed like ordinary Perl variables. For example:
        $a = $example::Foo;
        

      swig-3.0.2/Examples/perl5/simple/example.dsp0000664000175000017500000001201312343605122020601 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/perl5/simple/runme.pl0000664000175000017500000000057212343605122020130 0ustar williamwilliam# # Perl5 script for testing simple example use example; # Call our gcd() function $x = 42; $y = 105; $g = example::gcd($x,$y); print "The gcd of $x and $y is $g\n"; # Manipulate the Foo global variable # Output its current value print "Foo = $example::Foo\n"; # Change its value $example::Foo = 3.1415926; # See if the change took effect print "Foo = $example::Foo\n"; swig-3.0.2/Examples/perl5/simple/Makefile0000664000175000017500000000112412343605122020077 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/constants/0000775000175000017500000000000012343605122017164 5ustar williamwilliamswig-3.0.2/Examples/perl5/constants/example.i0000664000175000017500000000113512343605122020771 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/perl5/constants/index.html0000664000175000017500000000310612343605122021161 0ustar williamwilliam SWIG:Examples:perl5:constants SWIG/Examples/perl5/constants/

      Wrapping C Constants

      When SWIG encounters C preprocessor macros and C declarations that look like constants, it creates Perl5 variables with an identical value. Click here to see a SWIG interface with some constant declarations in it.

      Accessing Constants from Perl

      Click here to see a script that prints out the values of the constants contained in the above file.

      Key points

      • The values of preprocessor macros are converted into Perl constants.
      • Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
      • Character constants such as 'x' are converted into Perl strings.
      • C string literals such as "Hello World" are converted into Perl strings.
      • Macros that are not fully defined are simply ignored. For example:
        #define EXTERN extern
        
        is ignored because SWIG has no idea what type of variable this would be.

      • Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
      • Certain C declarations involving 'const' are also turned into Perl constants.

      • The constants that appear in a SWIG interface file do not have to appear in any sort of matching C source file since the creation of a constant does not require linkage to a stored value (i.e., a value held in a C global variable or memory location).

      swig-3.0.2/Examples/perl5/constants/runme.pl0000664000175000017500000000164612343605122020656 0ustar williamwilliam# file: runme.pl use example; print "ICONST = ", $example::ICONST, " (should be 42)\n"; print "FCONST = ", $example::FCONST, " (should be 2.1828)\n"; print "CCONST = ", $example::CCONST, " (should be 'x')\n"; print "CCONST2 = ", $example::CCONST2," (this should be on a new line)\n"; print "SCONST = ", $example::SCONST, " (should be 'Hello World')\n"; print "SCONST2 = ", $example::SCONST2, " (should be '\"Hello World\"')\n"; print "EXPR = ", $example::EXPR, " (should be 48.5484)\n"; print "iconst = ", $example::iconst, " (should be 37)\n"; print "fconst = ", $example::fconst, " (should be 3.14)\n"; if ($example::EXTERN) { print "EXTERN = ", example.EXTERN, " (Arg! This shouldn't print anything)\n"; } else { print "EXTERN isn't defined (good)\n"; } if ($example::FOO) { print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)\n"; } else { print "FOO isn't defined (good)\n"; } swig-3.0.2/Examples/perl5/constants/Makefile0000664000175000017500000000111212343605122020617 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/constants2/0000775000175000017500000000000012343605122017246 5ustar williamwilliamswig-3.0.2/Examples/perl5/constants2/example.i0000664000175000017500000000113512343605122021053 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/perl5/constants2/runme.pl0000664000175000017500000000114412343605122020731 0ustar williamwilliam# file: runme.pl use example; print "ICONST = ", example::ICONST, " (should be 42)\n"; print "FCONST = ", example::FCONST, " (should be 2.1828)\n"; print "CCONST = ", example::CCONST, " (should be 'x')\n"; print "CCONST2 = ", example::CCONST2," (this should be on a new line)\n"; print "SCONST = ", example::SCONST, " (should be 'Hello World')\n"; print "SCONST2 = ", example::SCONST2, " (should be '\"Hello World\"')\n"; print "EXPR = ", example::EXPR, " (should be 48.5484)\n"; print "iconst = ", example::iconst, " (should be 37)\n"; print "fconst = ", example::fconst, " (should be 3.14)\n"; swig-3.0.2/Examples/perl5/constants2/Makefile0000664000175000017500000000112112343605122020701 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = -const check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/extend/0000775000175000017500000000000012343605122016437 5ustar williamwilliamswig-3.0.2/Examples/perl5/extend/example.h0000664000175000017500000000260512343605122020246 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *get_item(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; swig-3.0.2/Examples/perl5/extend/example.i0000664000175000017500000000070612343605122020247 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_vector.i" %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; /* EmployeeList::addEmployee(Employee *p) gives ownership of the * employee to the EmployeeList object. The wrapper code should * understand this. */ %apply SWIGTYPE *DISOWN { Employee *p }; %include "example.h" swig-3.0.2/Examples/perl5/extend/example.cxx0000664000175000017500000000006012343605122020612 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/perl5/extend/index.html0000664000175000017500000000044012343605122020432 0ustar williamwilliam SWIG:Examples:perl5:extend SWIG/Examples/perl5/extend/

      Extending a simple C++ class

      This example illustrates the extending of a C++ class with cross language polymorphism.


      swig-3.0.2/Examples/perl5/extend/runme.pl0000664000175000017500000000604412343605122020126 0ustar williamwilliam# file: runme.pl # This file illustrates the cross language polymorphism using directors. use example; # CEO class, which overrides Employee::getPosition(). { package CEO; use base 'example::Manager'; sub getPosition { return "CEO"; } } # Create an instance of our employee extension class, CEO. The calls to # getName() and getPosition() are standard, the call to getTitle() uses # the director wrappers to call CEO->getPosition. $e = CEO->new("Alice") $e = CEO->new("Alice"); print $e->getName(), " is a ", $e->getPosition(), "\n"; printf "Just call her \"%s\"\n", $e->getTitle(); print "----------------------\n"; # Create a new EmployeeList instance. This class does not have a C++ # director wrapper, but can be used freely with other classes that do. $list = example::EmployeeList->new(); # EmployeeList owns its items, so we must surrender ownership of objects # we add. This involves calling the DISOWN method to tell the # C++ director to start reference counting. $e->DISOWN(); $list->addEmployee($e); print "----------------------\n"; # Now we access the first four items in list (three are C++ objects that # EmployeeList's constructor adds, the last is our CEO). The virtual # methods of all these instances are treated the same. For items 0, 1, and # 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls # getPosition which resolves in Perl. The call to getPosition is # slightly different, however, from the $e->getPosition() call above, since # now the object reference has been "laundered" by passing through # EmployeeList as an Employee*. Previously, Perl resolved the call # immediately in CEO, but now Perl thinks the object is an instance of # class Employee (actually EmployeePtr). So the call passes through the # Employee proxy class and on to the C wrappers and C++ director, # eventually ending up back at the CEO implementation of getPosition(). # The call to getTitle() for item 3 runs the C++ Employee::getTitle() # method, which in turn calls getPosition(). This virtual method call # passes down through the C++ director class to the Perl implementation # in CEO. All this routing takes place transparently. print "(position, title) for items 0-3:\n"; printf " %s, \"%s\"\n", $list->get_item(0)->getPosition(), $list->get_item(0)->getTitle(); printf " %s, \"%s\"\n", $list->get_item(1)->getPosition(), $list->get_item(1)->getTitle(); printf " %s, \"%s\"\n", $list->get_item(2)->getPosition(), $list->get_item(2)->getTitle(); printf " %s, \"%s\"\n", $list->get_item(3)->getPosition(), $list->get_item(3)->getTitle(); print "----------------------\n"; # Time to delete the EmployeeList, which will delete all the Employee* # items it contains. The last item is our CEO, which gets destroyed as its # reference count goes to zero. The Perl destructor runs, and is still # able to call self.getName() since the underlying C++ object still # exists. After this destructor runs the remaining C++ destructors run as # usual to destroy the object. undef $list; print "----------------------\n"; # All done. print "perl exit\n"; swig-3.0.2/Examples/perl5/extend/Makefile0000664000175000017500000000110412343605122020073 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/reference/0000775000175000017500000000000012343605122017106 5ustar williamwilliamswig-3.0.2/Examples/perl5/reference/example.h0000664000175000017500000000064512343605122020717 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; friend Vector operator+(const Vector &a, const Vector &b); char *print(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/perl5/reference/example.i0000664000175000017500000000131412343605122020712 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module example %{ #include "example.h" %} class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.2/Examples/perl5/reference/example.cxx0000664000175000017500000000161412343605122021267 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/perl5/reference/index.html0000664000175000017500000000626312343605122021112 0ustar williamwilliam SWIG:Examples:perl5:reference SWIG/Examples/perl5/reference/

      C++ Reference Handling

      This example tests SWIG's handling of C++ references. Since C++ references are closely related to pointers (as both refer to a location in memory), SWIG simply collapses all references into pointers when creating wrappers.

      Some examples

      References are most commonly used as function parameter. For example, you might have an operator like this:
      Vector operator+(const Vector &a, const Vector &b) {
         Vector result;
         result.x = a.x + b.x;
         result.y = a.y + b.y;
         result.z = a.z + b.z;
         return result;
      }
      
      or a function:
      Vector addv(const Vector &a, const Vector &b) {
         Vector result;
         result.x = a.x + b.x;
         result.y = a.y + b.y;
         result.z = a.z + b.z;
         return result;
      }
      
      In these cases, SWIG transforms everything into a pointer and creates a wrapper that looks like this:
      Vector wrap_addv(Vector *a, Vector *b) {
          return addv(*a,*b);
      }
      
      Occasionally, a reference is used as a return value of a function when the return result is to be used as an lvalue in an expression. The prototypical example is an operator like this:
      Vector &operator[](int index);
      
      or a method:
      Vector &get(int index);
      
      For functions returning references, a wrapper like this is created:
      Vector *wrap_Object_get(Object *self, int index) {
          Vector &result = self->get(index);
          return &result;
      }
      
      The following header file contains some class definitions with some operators and use of references.

      SWIG Interface

      SWIG does NOT support overloaded operators so it can not directly build an interface to the classes in the above file. However, a number of workarounds can be made. For example, an overloaded operator can be stuck behind a function call such as the addv() function above. Array access can be handled with a pair of set/get functions like this:
      class VectorArray {
      public:
       ...
         %addmethods {
          Vector &get(int index) {
            return (*self)[index];
          }
          void set(int index, Vector &a) {
            (*self)[index] = a;
          }
         }
         ...
      }
      
      Click here to see a SWIG interface file with these additions.

      Sample Perl script

      Click here to see a script that manipulates some C++ references.

      Notes:

      • C++ references primarily provide notational convenience for C++ source code. However, it doesn't much matter to Perl.

      • When a program returns a reference, a pointer is returned. Unlike return by value, memory is not allocated to hold the return result.

      • SWIG has particular trouble handling various combinations of references and pointers. This is side effect of an old parsing scheme and type representation that will be replaced in future versions.

      swig-3.0.2/Examples/perl5/reference/runme.pl0000664000175000017500000000353112343605122020573 0ustar williamwilliam# file: runme.pl # This file illustrates the manipulation of C++ references in Perl. # This uses the low-level interface. Proxy classes work differently. use example; # ----- Object creation ----- print "Creating some objects:\n"; $a = example::new_Vector(3,4,5); $b = example::new_Vector(10,11,12); print " Created",example::Vector_print($a),"\n"; print " Created",example::Vector_print($b),"\n"; # ----- Call an overloaded operator ----- # This calls the wrapper we placed around # # operator+(const Vector &a, const Vector &) # # It returns a new allocated object. print "Adding a+b\n"; $c = example::addv($a,$b); print " a+b =", example::Vector_print($c),"\n"; # Note: Unless we free the result, a memory leak will occur example::delete_Vector($c); # ----- Create a vector array ----- # Note: Using the high-level interface here print "Creating an array of vectors\n"; $va = example::new_VectorArray(10); print " va = $va\n"; # ----- Set some values in the array ----- # These operators copy the value of $a and $b to the vector array example::VectorArray_set($va,0,$a); example::VectorArray_set($va,1,$b); # This will work, but it will cause a memory leak! example::VectorArray_set($va,2,example::addv($a,$b)); # The non-leaky way to do it $c = example::addv($a,$b); example::VectorArray_set($va,3,$c); example::delete_Vector($c); # Get some values from the array print "Getting some array values\n"; for ($i = 0; $i < 5; $i++) { print " va($i) = ", example::Vector_print(example::VectorArray_get($va,$i)), "\n"; } # Watch under resource meter to check on this print "Making sure we don't leak memory.\n"; for ($i = 0; $i < 1000000; $i++) { $c = example::VectorArray_get($va,$i % 10); } # ----- Clean up ----- print "Cleaning up\n"; example::delete_VectorArray($va); example::delete_Vector($a); example::delete_Vector($b); swig-3.0.2/Examples/perl5/reference/Makefile0000664000175000017500000000120412343605122020543 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = -noproxy check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/check.list0000664000175000017500000000024212343605122017120 0ustar williamwilliam# see top-level Makefile.in callback class constants constants2 extend funcptr import java multimap multiple_inheritance pointer reference simple value variables swig-3.0.2/Examples/perl5/index.html0000664000175000017500000000507212343605122017151 0ustar williamwilliam SWIG:Examples:perl5

      SWIG Perl Examples

      The following examples illustrate the use of SWIG with Perl.

      • simple. A minimal example showing how SWIG can be used to wrap a C function and a global variable.
      • constants. This shows how preprocessor macros and certain C declarations are turned into constants.
      • variables. This example shows how to access C global variables from Perl.
      • value. How to pass and return structures by value.
      • class. How to wrap a simple C++ class.
      • reference. C++ references.
      • pointer. Simple pointer handling.
      • funcptr. Pointers to functions.
      • callback. C++ callbacks using directors.
      • extend. Extending a simple C++ class.

      Compilation Issues

      • To create a Perl extension, SWIG is run with the following options:
        % swig -perl5 interface.i
        
      • The compilation of examples is done using the file Example/Makefile. This makefile performs a manual module compilation which is platform specific. Typically, the steps look like this (Linux):
        % swig -perl5 interface.i
        % gcc -fpic -c -Dbool=char -I/usr/lib/perl5/5.00503/i386-linux/CORE interface_wrap.c
        % gcc -shared interface_wrap.o $(OBJS) -o interface.so 
        % perl
        use interface;
        ...
        
      • The politically "correct" way to compile a Perl extension module is to use MakeMaker and related tools (especially if you are considering third-party distribution). Consult a book such as Advanced Perl Programming for details.

      Compatibility

      The examples have been extensively tested on the following platforms:

      • Linux
      • Solaris
      Please see the Windows page in the main manual for information on using the examples on Windows.

      Due to wide variations in the Perl C API and differences between versions such as the ActivePerl release for Windows, the code generated by SWIG is extremely messy. If the code doesn't compile or work with your version of Perl, please let us know by contacting us on the mailing lists. Better yet, send us a patch. swig-3.0.2/Examples/perl5/funcptr/0000775000175000017500000000000012343605122016631 5ustar williamwilliamswig-3.0.2/Examples/perl5/funcptr/example.c0000664000175000017500000000037012343605122020430 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/perl5/funcptr/example.h0000664000175000017500000000026312343605122020436 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/perl5/funcptr/example.i0000664000175000017500000000056012343605122020437 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); swig-3.0.2/Examples/perl5/funcptr/index.html0000664000175000017500000000370112343605122020627 0ustar williamwilliam SWIG:Examples:perl5:funcptr SWIG/Examples/perl5/funcptr/


      Pointers to Functions

      Okay, just what in the heck does SWIG do with a declaration like this?

      int do_op(int a, int b, int (*op)(int, int));
      
      Well, it creates a wrapper as usual. Of course, that does raise some questions about the third argument (the pointer to a function).

      In this case, SWIG will wrap the function pointer as it does for all other pointers. However, in order to actually call this function from a script, you will need to pass some kind of C function pointer object. In C, this is easy, you just supply a function name as an argument like this:

      /* Some callback function */
      int add(int a, int b) {
         return a+b;
      } 
      ...
      int r = do_op(x,y,add);
      
      To make this work with SWIG, you will need to do a little extra work. Specifically, you need to create some function pointer objects using the %constant directive like this:
      %constant(int (*)(int,int)) ADD = add;
      
      Now, in a script, you would do this:
      $r = do_op($x,$y, $ADD);
      

      An Example

      Here are some files that illustrate this with a simple example:

      Notes

      • The value of a function pointer must correspond to a function written in C or C++. It is not possible to pass an arbitrary Perl function object in as a substitute for a C function pointer.

      • A perl function can be used as a C/C++ callback if you write some clever typemaps and are very careful about how you create your extension. This is an advanced topic not covered here.

      swig-3.0.2/Examples/perl5/funcptr/runme.pl0000664000175000017500000000113312343605122020312 0ustar williamwilliam# file: runme.pl use example; $a = 37; $b = 42; # Now call our C function with a bunch of callbacks print "Trying some C callback functions\n"; print " a = $a\n"; print " b = $b\n"; print " ADD(a,b) = ", example::do_op($a,$b,$example::ADD),"\n"; print " SUB(a,b) = ", example::do_op($a,$b,$example::SUB),"\n"; print " MUL(a,b) = ", example::do_op($a,$b,$example::MUL),"\n"; print "Here is what the C callback function objects look like in Perl\n"; print " ADD = $example::ADD\n"; print " SUB = $example::SUB\n"; print " MUL = $example::MUL\n"; swig-3.0.2/Examples/perl5/funcptr/Makefile0000664000175000017500000000112412343605122020267 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/xmlstring/0000775000175000017500000000000012343605122017177 5ustar williamwilliamswig-3.0.2/Examples/perl5/xmlstring/example.h0000664000175000017500000000071112343605122021002 0ustar williamwilliam#include class XMLChTest { XMLCh *_val; public: XMLChTest() : _val(0) { } void set(const XMLCh *v) { size_t len = XERCES_CPP_NAMESPACE::XMLString::stringLen(v); delete[] _val; _val = new XMLCh[len + 1]; for (int i = 0; i < len; ++i) { _val[i] = v[i]; } _val[len] = 0; } const XMLCh *get() { return _val; } XMLCh get_first() { return _val[0]; } }; swig-3.0.2/Examples/perl5/xmlstring/example.i0000664000175000017500000000013112343605122020777 0ustar williamwilliam%module example %include %{ #include "example.h" %} %include example.h swig-3.0.2/Examples/perl5/xmlstring/example.cxx0000664000175000017500000000002512343605122021353 0ustar williamwilliam#include "example.h" swig-3.0.2/Examples/perl5/xmlstring/xmlstring.i0000664000175000017500000000665012343605122021407 0ustar williamwilliam%include %fragment("","header") %{ #include #include #include %} %fragment("SWIG_UTF8Transcoder","header",fragment="") { SWIGINTERN XERCES_CPP_NAMESPACE::XMLTranscoder* SWIG_UTF8Transcoder() { using namespace XERCES_CPP_NAMESPACE; static int init = 0; static XMLTranscoder* UTF8_TRANSCODER = NULL; static XMLCh* UTF8_ENCODING = NULL; if (!init) { XMLTransService::Codes failReason; XMLPlatformUtils::Initialize(); // first we must create the transservice UTF8_ENCODING = XMLString::transcode("UTF-8"); UTF8_TRANSCODER = XMLPlatformUtils::fgTransService->makeNewTranscoderFor(UTF8_ENCODING, failReason, 1024); init = 1; } return UTF8_TRANSCODER; } } %fragment("SWIG_AsXMLChPtrAndSize","header",fragment="SWIG_AsCharPtrAndSize",fragment="SWIG_UTF8Transcoder") { SWIGINTERN int SWIG_AsXMLChPtrAndSize(SV *obj, XMLCh **val, size_t* psize, int *alloc) { if (!val) { return SWIG_AsCharPtrAndSize(obj, 0, 0, 0); } else { size_t size; char *cptr = 0; int calloc = SWIG_OLDOBJ; int res = SWIG_AsCharPtrAndSize(obj, &cptr, &size, &calloc); if (SWIG_IsOK(res)) { STRLEN length = size - 1; if (SvUTF8(obj)) { unsigned int charsEaten = 0; unsigned char* sizes = %new_array(size, unsigned char); *val = %new_array(size, XMLCh); unsigned int chars_stored = SWIG_UTF8Transcoder()->transcodeFrom((const XMLByte*) cptr, (unsigned int) length, (XMLCh*) *val, (unsigned int) length, charsEaten, (unsigned char*)sizes ); %delete_array(sizes); // indicate the end of the string (*val)[chars_stored] = '\0'; } else { *val = XERCES_CPP_NAMESPACE::XMLString::transcode(cptr); } if (psize) *psize = size; if (alloc) *alloc = SWIG_NEWOBJ; if (calloc == SWIG_NEWOBJ) %delete_array(cptr); return SWIG_NEWOBJ; } else { return res; } } } } %fragment("SWIG_FromXMLChPtrAndSize","header",fragment="SWIG_UTF8Transcoder") { SWIGINTERNINLINE SV * SWIG_FromXMLChPtrAndSize(const XMLCh* input, size_t size) { SV *output = sv_newmortal(); unsigned int charsEaten = 0; int length = size; // string length XMLByte* res = %new_array(length * UTF8_MAXLEN, XMLByte); // output string unsigned int total_chars = SWIG_UTF8Transcoder()->transcodeTo((const XMLCh*) input, (unsigned int) length, (XMLByte*) res, (unsigned int) length*UTF8_MAXLEN, charsEaten, XERCES_CPP_NAMESPACE::XMLTranscoder::UnRep_Throw ); res[total_chars] = '\0'; sv_setpv((SV*)output, (char *)res ); SvUTF8_on((SV*)output); %delete_array(res); return output; } } %fragment("SWIG_XMLStringNLen","header") { size_t SWIG_XMLStringNLen(const XMLCh* s, size_t maxlen) { const XMLCh *p; for (p = s; maxlen-- && *p; p++) ; return p - s; } } %init { if (!SWIG_UTF8Transcoder()) { croak("ERROR: XML::Xerces: INIT: Could not create UTF-8 transcoder"); } } %include %typemaps_string(%checkcode(UNISTRING), %checkcode(UNICHAR), XMLCh, XMLCh, SWIG_AsXMLChPtrAndSize, SWIG_FromXMLChPtrAndSize, XERCES_CPP_NAMESPACE::XMLString::stringLen, SWIG_XMLStringNLen, "", INT_MIN, INT_MAX); swig-3.0.2/Examples/perl5/xmlstring/runme.pl0000664000175000017500000000016712343605122020666 0ustar williamwilliamuse example; $e1 = new example::XMLChTest(); $e1->set("hello"); print $e1->get(),"\n"; print $e1->get_first(),"\n"; swig-3.0.2/Examples/perl5/xmlstring/Makefile0000664000175000017500000000117212343605122020640 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lxerces-c -lxerces-depdom -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS=$(LIBS) CXX="g++ -g3" perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/java/0000775000175000017500000000000012343605122016071 5ustar williamwilliamswig-3.0.2/Examples/perl5/java/example.i0000664000175000017500000000012312343605122017672 0ustar williamwilliam%module example %include %{ #include "Example.h" %} %include Example.h swig-3.0.2/Examples/perl5/java/runme.pl0000664000175000017500000000072012343605122017553 0ustar williamwilliamuse example; example::JvCreateJavaVM(undef); example::JvAttachCurrentThread(undef, undef); $e1 = new example::Example(1); print $e1->{mPublicInt},"\n"; $e2 = new example::Example(2); print $e2->{mPublicInt},"\n"; $i = $e1->Add(1,2); print $i,"\n"; $d = $e2->Add(1.0,2.0); print $d,"\n"; $d = $e2->Add("1","2"); print $d,"\n"; $e3 = $e1->Add($e1,$e2); print $e3->{mPublicInt},"\n"; $s = $e2->Add("a","b"); print $s,"\n"; example::JvDetachCurrentThread() swig-3.0.2/Examples/perl5/java/Makefile0000664000175000017500000000124012343605122017526 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: Example.class Example.h $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean rm -f *.class Example.h Example.class Example.h: $(SRCDIR)Example.java gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java gcjh Example.class swig-3.0.2/Examples/perl5/java/Example.java0000664000175000017500000000075012343605122020331 0ustar williamwilliampublic class Example { public int mPublicInt; public Example() { mPublicInt = 0; } public Example(int IntVal) { mPublicInt = IntVal; } public int Add(int a, int b) { return (a+b); } public float Add(float a, float b) { return (a+b); } public String Add(String a, String b) { return (a+b); } public Example Add(Example a, Example b) { return new Example(a.mPublicInt + b.mPublicInt); } } swig-3.0.2/Examples/perl5/multimap/0000775000175000017500000000000012343605122017000 5ustar williamwilliamswig-3.0.2/Examples/perl5/multimap/example.c0000664000175000017500000000164012343605122020600 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.2/Examples/perl5/multimap/example.i0000664000175000017500000000400712343605122020606 0ustar williamwilliam/* File : example.i */ %module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} %include exception.i %include typemaps.i extern int gcd(int x, int y); %typemap(arginit) (int argc, char *argv[]) "$2 = 0;"; %typemap(in) (int argc, char *argv[]) { AV *tempav; SV **tv; I32 len; int i; if (!SvROK($input)) { SWIG_exception(SWIG_ValueError,"$input is not an array."); } if (SvTYPE(SvRV($input)) != SVt_PVAV) { SWIG_exception(SWIG_ValueError,"$input is not an array."); } tempav = (AV*)SvRV($input); len = av_len(tempav); $1 = (int) len+1; $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++) { tv = av_fetch(tempav, i, 0); $2[i] = (char *) SvPV(*tv,PL_na); } $2[i] = 0; } %typemap(freearg) (int argc, char *argv[]) { free($2); } extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { STRLEN temp; $1 = (char *) SvPV($input, temp); $2 = (int) temp; } extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a string */ %typemap(in) (char *str, int len) { STRLEN templen; char *temp; temp = (char *) SvPV($input,templen); $2 = (int) templen; $1 = (char *) malloc($2+1); memmove($1,temp,$2); } /* Return the mutated string as a new object. */ %typemap(argout) (char *str, int len) { if (argvi >= items) { EXTEND(sp,1); } $result = sv_newmortal(); sv_setpvn((SV*)ST(argvi++),$1,$2); free($1); } extern void capitalize(char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); } } extern void circle(double cx, double cy); swig-3.0.2/Examples/perl5/multimap/example.dsp0000664000175000017500000001201312343605122021140 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/perl5/multimap/runme.pl0000664000175000017500000000060012343605122020457 0ustar williamwilliam# file: runme.pl use example; # Call our gcd() function $x = 42; $y = 105; $g = example::gcd($x,$y); print "The gcd of $x and $y is $g\n"; # Call the gcdmain() function @a = ("gcdmain","42","105"); example::gcdmain(\@a); # Call the count function print example::count("Hello World", "l"),"\n"; # Call the capitize function print example::capitalize("hello world"),"\n"; swig-3.0.2/Examples/perl5/multimap/Makefile0000664000175000017500000000112412343605122020436 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/multiple_inheritance/0000775000175000017500000000000012343605122021354 5ustar williamwilliamswig-3.0.2/Examples/perl5/multiple_inheritance/example.h0000664000175000017500000000061012343605122023155 0ustar williamwilliam/* File : example.h */ #include using namespace std; class Bar { public: virtual void bar () { cout << "bar" << endl; } virtual ~Bar() {} }; class Foo { public: virtual void foo () { cout << "foo" << endl; } virtual ~Foo() {} }; class Foo_Bar : public Foo, public Bar { public: virtual void fooBar () { cout << "foobar" << endl; } }; swig-3.0.2/Examples/perl5/multiple_inheritance/example.i0000664000175000017500000000021512343605122023157 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/perl5/multiple_inheritance/runme.pl0000664000175000017500000000035312343605122023040 0ustar williamwilliam# file: runme.pl # This file test multiple inheritance use example; $foo_Bar = new example::Foo_Bar(); print "must be foo: "; $foo_Bar->foo(); print "must be bar: "; $foo_Bar->bar(); print "must be foobar: "; $foo_Bar->fooBar(); swig-3.0.2/Examples/perl5/multiple_inheritance/Makefile0000664000175000017500000000106412343605122023015 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/inline/0000775000175000017500000000000012343605122016426 5ustar williamwilliamswig-3.0.2/Examples/perl5/inline/README0000664000175000017500000000006112343605122017303 0ustar williamwilliamThis example requires the Inline::SWIG package. swig-3.0.2/Examples/perl5/inline/runme.pl0000664000175000017500000000133312343605122020111 0ustar williamwilliamuse Inline SWIG => <<"END_CODE", SWIG_ARGS => '-c++ -proxy', CC => 'g++', LD=>'g++'; class Foo { public: int meaning() { return 42; }; }; END_CODE my $o = new Foo(); print $o->meaning(),"\n"; use Inline SWIG => ' ', SWIG_INTERFACE => <<"END_CODE", SWIG_ARGS => '-c++', CC => "g++", LD => "g++"; %include std_string.i %inline { template class Bar { Type _val; public: Bar(Type v) : _val(v) {} Type meaning() { return _val; } }; } %template(Bar_i) Bar; %template(Bar_d) Bar; %template(Bar_s) Bar; END_CODE my $o = new Bar_i(1); print $o->meaning(),"\n"; my $o = new Bar_d(2); print $o->meaning(),"\n"; my $o = new Bar_s("hello"); print $o->meaning(),"\n"; swig-3.0.2/Examples/perl5/inline/Makefile0000664000175000017500000000022112343605122020061 0ustar williamwilliamrun: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean rm -rf _Inline swig-3.0.2/Examples/perl5/value/0000775000175000017500000000000012343605122016264 5ustar williamwilliamswig-3.0.2/Examples/perl5/value/example.c0000664000175000017500000000037512343605122020070 0ustar williamwilliam/* File : example.c */ #include "example.h" double dot_product(Vector a, Vector b) { return (a.x*b.x + a.y*b.y + a.z*b.z); } Vector vector_add(Vector a, Vector b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } swig-3.0.2/Examples/perl5/value/example.h0000664000175000017500000000011012343605122020060 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; swig-3.0.2/Examples/perl5/value/example.i0000664000175000017500000000125312343605122020072 0ustar williamwilliam// Tests SWIG's handling of pass-by-value for complex datatypes %module example %{ #include "example.h" %} /* Some functions that manipulate Vectors by value */ %inline %{ extern double dot_product(Vector a, Vector b); extern Vector vector_add(Vector a, Vector b); %} /* Include this because the vector_add() function will leak memory */ void free(void *); /* Some helper functions for our interface */ %inline %{ Vector *new_Vector(double x, double y, double z) { Vector *v = (Vector *) malloc(sizeof(Vector)); v->x = x; v->y = y; v->z = z; return v; } void vector_print(Vector *v) { printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z); } %} swig-3.0.2/Examples/perl5/value/index.html0000664000175000017500000000554412343605122020271 0ustar williamwilliam SWIG:Examples:perl5:value SWIG/Examples/perl5/value/

      Passing and Returning Structures by Value

      Occasionally, a C program will manipulate structures by value such as shown in the following code:

      /* File : example.c */
      
      typedef struct Vector {
         double x, y, z;
      } Vector;
      
      double dot_product(Vector a, Vector b) {
        return (a.x*b.x + a.y*b.y + a.z*b.z);
      }
      
      Vector vector_add(Vector a, Vector b) {
        Vector r;
        r.x = a.x + b.x;
        r.y = a.y + b.y;
        r.z = a.z + b.z;
        return r;
      }
      
      Since SWIG only knows how to manage pointers to structures (not their internal representation), the following translations are made when wrappers are created:
      double wrap_dot_product(Vector *a, Vector *b) {
          return dot_product(*a,*b);
      }
      
      Vector *wrap_vector_add(Vector *a, Vector *b) {
          Vector *r = (Vector *) malloc(sizeof(Vector));
          *r = vector_add(*a,*b);
          return r;
      }
      
      The functions are then called using pointers from the scripting language interface. It should also be noted that any function that returns a structure by value results in an implicit memory allocation. This will be a memory leak unless you take steps to free the result (see below).

      The SWIG interface

      Click here to see a SWIG interface file that wraps these two functions. In this file, there are a few essential features:
      • A wrapper for the free() function is created so that we can clean up the return result created by vector_add() function.

      • The %inline directive is used to create a few helper functions for creating new Vector objects and to print out the value (for debugging purposes).

      A Perl Script

      Click here to see a script that uses these functions from Perl.

      Notes

      • When the '-c++' option is used, the resulting wrapper code for the return value changes to the following:
        Vector *wrap_vector_add(Vector *a, Vector *b) {
            Vector *r = new Vector(vector_add(*a,*b));
            return r;
        }
        
        Similarly, it would be a mistake to use the free() function from C++. A safer approach would be to write a helper function like this:
        %inline %{
           void delete_Vector(Vector *v) {
               delete v;
           }
        %}
        

      • If you use proxy classes and are careful, the SWIG generated wrappers can automatically clean up the result of return-by-reference when the scripting variable goes out of scope.

      • Passing parameters by value like this really isn't the best C programming style. If possible, you might change your application to use pointers.

      • Similar translations are made when C++ references are used.

      swig-3.0.2/Examples/perl5/value/runme.pl0000664000175000017500000000133712343605122017753 0ustar williamwilliam# file: runme.pl use example; # Create a couple of a vectors $v = example::new_Vector(1,2,3); $w = example::new_Vector(10,11,12); print "I just created the following vectors\n"; example::vector_print($v); example::vector_print($w); # Now call some of our functions print "\nNow I'm going to compute the dot product\n"; $d = example::dot_product($v,$w); print "dot product = $d (should be 68)\n"; # Add the vectors together print "\nNow I'm going to add the vectors together\n"; $r = example::vector_add($v,$w); example::vector_print($r); print "The value should be (11,13,15)\n"; # Now I'd better clean up the return result r print "\nNow I'm going to clean up the return result\n"; example::free($r); print "Good\n"; swig-3.0.2/Examples/perl5/value/Makefile0000664000175000017500000000112412343605122017722 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/callback/0000775000175000017500000000000012343605122016704 5ustar williamwilliamswig-3.0.2/Examples/perl5/callback/example.h0000664000175000017500000000102012343605122020501 0ustar williamwilliam/* File : example.h */ #include #include class Callback { public: virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } }; swig-3.0.2/Examples/perl5/callback/example.i0000664000175000017500000000057312343605122020516 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_string.i" /* turn on director wrapping Callback */ %feature("director") Callback; /* Caller::setCallback(Callback *cb) gives ownership of the cb to the * Caller object. The wrapper code should understand this. */ %apply SWIGTYPE *DISOWN { Callback *cb }; %include "example.h" swig-3.0.2/Examples/perl5/callback/example.cxx0000664000175000017500000000006012343605122021057 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/perl5/callback/index.html0000664000175000017500000000044012343605122020677 0ustar williamwilliam SWIG:Examples:perl5:callback SWIG/Examples/perl/callback/

      Implementing C++ callbacks in Perl

      This example illustrates how to use directors to implement C++ callbacks.


      swig-3.0.2/Examples/perl5/callback/runme.pl0000664000175000017500000000175212343605122020374 0ustar williamwilliam# file: runme.pl # This file illustrates the cross language polymorphism using directors. use example; { package PlCallback; use base 'example::Callback'; sub run { print "PlCallback->run()\n"; } } # Create an Caller instance $caller = example::Caller->new(); # Add a simple C++ callback (caller owns the callback, so # we disown it first by clearing the .thisown flag). print "Adding and calling a normal C++ callback\n"; print "----------------------------------------\n"; $callback = example::Callback->new(); $callback->DISOWN(); $caller->setCallback($callback); $caller->call(); $caller->delCallback(); print "\n"; print "Adding and calling a Perl callback\n"; print "----------------------------------\n"; # Add a Perl callback (caller owns the callback, so we # disown it first by calling DISOWN). $callback = PlCallback->new(); $callback->DISOWN(); $caller->setCallback($callback); $caller->call(); $caller->delCallback(); # All done. print "\n"; print "perl exit\n"; swig-3.0.2/Examples/perl5/callback/Makefile0000664000175000017500000000110412343605122020340 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/import/0000775000175000017500000000000012343605122016462 5ustar williamwilliamswig-3.0.2/Examples/perl5/import/spam.dsp0000664000175000017500000001153412343605122020136 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=spam - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "spam.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "spam - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"spam.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "spam - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"spam.dll" !ENDIF # Begin Target # Name "spam - Win32 Debug" # Name "spam - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\spam_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\spam.h # End Source File # End Group # Begin Source File SOURCE=.\spam.i !IF "$(CFG)" == "spam - Win32 Debug" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "spam - Win32 Release" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/perl5/import/spam.h0000664000175000017500000000061412343605122017574 0ustar williamwilliam#include "bar.h" class Spam : public Bar { public: Spam() { } ~Spam() { } virtual void A() { printf("I'm Spam::A\n"); } void B() { printf("I'm Spam::B\n"); } virtual Base *toBase() { return static_cast(this); } virtual Bar *toBar() { return static_cast(this); } static Spam *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/perl5/import/README0000664000175000017500000000241712343605122017346 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. Use 'perl runme.pl' to run a test. Overview: --------- The example defines 4 different extension modules--each wrapping a separate C++ class. base.i - Base class foo.i - Foo class derived from Base bar.i - Bar class derived from Base spam.i - Spam class derived from Bar Each module uses %import to refer to another module. For example, the 'foo.i' module uses '%import base.i' to get definitions for its base class. If everything is okay, all of the modules will load properly and type checking will work correctly. Caveat: Some compilers, for example gcc-3.2.x, generate broken vtables with the inline methods in this test. This is not a SWIG problem and can usually be solved with non-inlined destructors compiled into separate shared objects/DLLs. Unix: ----- - Run make - Run the test as described above Windows: -------- - Use the Visual C++ 6 workspace file (example.dsw). Build the runtime project DLL first followed by the other 4 DLLs as they all have a dependency on the runtime DLL. The Batch build option in the Build menu is usually the easiest way to do this. Only use the Release builds not the Debug builds. - Run the test as described above swig-3.0.2/Examples/perl5/import/spam.i0000664000175000017500000000011012343605122017564 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-3.0.2/Examples/perl5/import/bar.i0000664000175000017500000000010612343605122017375 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-3.0.2/Examples/perl5/import/base.i0000664000175000017500000000007312343605122017546 0ustar williamwilliam%module baseclass %{ #include "base.h" %} %include base.h swig-3.0.2/Examples/perl5/import/foo.dsp0000664000175000017500000001150212343605122017754 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=foo - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "foo.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "foo - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"foo.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "foo - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"foo.dll" !ENDIF # Begin Target # Name "foo - Win32 Debug" # Name "foo - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\foo_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\foo.h # End Source File # End Group # Begin Source File SOURCE=.\foo.i !IF "$(CFG)" == "foo - Win32 Debug" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "foo - Win32 Release" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/perl5/import/base.dsp0000664000175000017500000001154612343605122020113 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=base - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "base.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "base - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"baseclass.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "base - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"baseclass.dll" !ENDIF # Begin Target # Name "base - Win32 Debug" # Name "base - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\base_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\base.h # End Source File # End Group # Begin Source File SOURCE=.\base.i !IF "$(CFG)" == "base - Win32 Debug" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "base - Win32 Release" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/perl5/import/foo.i0000664000175000017500000000010512343605122017413 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-3.0.2/Examples/perl5/import/foo.h0000664000175000017500000000050512343605122017416 0ustar williamwilliam#include "base.h" class Foo : public Base { public: Foo() { } ~Foo() { } virtual void A() { printf("I'm Foo::A\n"); } void B() { printf("I'm Foo::B\n"); } virtual Base *toBase() { return static_cast(this); } static Foo *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/perl5/import/base.h0000664000175000017500000000045112343605122017545 0ustar williamwilliam#include class Base { public: Base() { }; virtual ~Base() { }; virtual void A() { printf("I'm Base::A\n"); } void B() { printf("I'm Base::B\n"); } virtual Base *toBase() { return static_cast(this); } }; swig-3.0.2/Examples/perl5/import/runme.pl0000664000175000017500000000357112343605122020153 0ustar williamwilliam# file: runme.pl # Test various properties of classes defined in separate modules print "Testing the %import directive\n"; use baseclass; use foo; use bar; use spam; # Create some objects print "Creating some objects\n"; $a = new baseclass::Base(); $b = new foo::Foo(); $c = new bar::Bar(); $d = new spam::Spam(); # Try calling some methods print "Testing some methods\n"; print "Should see 'Base::A' ---> "; $a->A(); print "Should see 'Base::B' ---> "; $a->B(); print "Should see 'Foo::A' ---> "; $b->A(); print "Should see 'Foo::B' ---> "; $b->B(); print "Should see 'Bar::A' ---> "; $c->A(); print "Should see 'Bar::B' ---> "; $c->B(); print "Should see 'Spam::A' ---> "; $d->A(); print "Should see 'Spam::B' ---> "; $d->B(); # Try some casts print "\nTesting some casts\n"; $x = $a->toBase(); print "Should see 'Base::A' ---> "; $x->A(); print "Should see 'Base::B' ---> "; $x->B(); $x = $b->toBase(); print "Should see 'Foo::A' ---> "; $x->A(); print "Should see 'Base::B' ---> "; $x->B(); $x = $c->toBase(); print "Should see 'Bar::A' ---> "; $x->A(); print "Should see 'Base::B' ---> "; $x->B(); $x = $d->toBase(); print "Should see 'Spam::A' ---> "; $x->A(); print "Should see 'Base::B' ---> "; $x->B(); $x = $d->toBar(); print "Should see 'Bar::B' ---> "; $x->B(); print "\nTesting some dynamic casts\n"; $x = $d->toBase(); print " Spam -> Base -> Foo : "; $y = foo::Foo::fromBase($x); if ($y) { print "bad swig\n"; } else { print "good swig\n"; } print " Spam -> Base -> Bar : "; $y = bar::Bar::fromBase($x); if ($y) { print "good swig\n"; } else { print "bad swig\n"; } print " Spam -> Base -> Spam : "; $y = spam::Spam::fromBase($x); if ($y) { print "good swig\n"; } else { print "bad swig\n"; } print " Foo -> Spam : "; #print $b; $y = spam::Spam::fromBase($b); print $y; if ($y) { print "bad swig\n"; } else { print "good swig\n"; } swig-3.0.2/Examples/perl5/import/Makefile0000664000175000017500000000144412343605122020125 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='baseclass' INTERFACE='base.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' perl5_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/perl5/import/example.dsw0000664000175000017500000000206412343605122020636 0ustar williamwilliamMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "bar"=.\bar.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "base"=.\base.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "foo"=.\foo.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "spam"=.\spam.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### swig-3.0.2/Examples/perl5/import/bar.h0000664000175000017500000000050612343605122017400 0ustar williamwilliam#include "base.h" class Bar : public Base { public: Bar() { } ~Bar() { } virtual void A() { printf("I'm Bar::A\n"); } void B() { printf("I'm Bar::B\n"); } virtual Base *toBase() { return static_cast(this); } static Bar *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/perl5/import/bar.dsp0000664000175000017500000001150212343605122017735 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=bar - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "bar.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "bar - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"bar.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "bar - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"bar.dll" !ENDIF # Begin Target # Name "bar - Win32 Debug" # Name "bar - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\bar_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\bar.h # End Source File # End Group # Begin Source File SOURCE=.\bar.i !IF "$(CFG)" == "bar - Win32 Debug" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "bar - Win32 Release" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/perl5/variables/0000775000175000017500000000000012343605122017120 5ustar williamwilliamswig-3.0.2/Examples/perl5/variables/example.c0000664000175000017500000000456012343605122020724 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/perl5/variables/example.h0000664000175000017500000000007512343605122020726 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/perl5/variables/example.i0000664000175000017500000000203012343605122020720 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} #pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/perl5/variables/index.html0000664000175000017500000000434112343605122021117 0ustar williamwilliam SWIG:Examples:perl5:variables SWIG/Examples/perl5/variables/

      Wrapping C Global Variables

      When a C global variable appears in an interface file, SWIG tries to wrap it using a technique known as "variable linking." The idea is pretty simple---we try to create a Perl variable that magically retrieves or updates the value of the underlying C variable when it is accessed. Click here to see a SWIG interface with some variable declarations in it.

      Manipulating Variables from Perl

      Accessing a C global variable from Perl is easy---just reference it like a normal Perl variable. Click here to see a script that updates and prints some global variables.

      Creating read-only variables

      The %immutable and %mutable directives can be used to specify a collection of read-only variables. For example:
      %immutable;
      int    status;
      double blah;
      ...
      %mutable;
      
      The %immutable directive remains in effect until it is explicitly disabled using the %mutable directive.

      Notes:

      • When a global variable has the type "char *", SWIG manages it as a character string. However, whenever the value of such a variable is set from Perl, the old value is destroyed using free() or delete (the choice of which depends on whether or not SWIG was run with the -c++ option).
      • signed char and unsigned char are handled as small 8-bit integers.
      • String array variables such as 'char name[256]' are managed as Perl strings, but when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
      • When structures and classes are used as global variables, they are mapped into pointers. Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global.
      • Variables are linked using Perl's magic mechanism. Take a look at the Advanced Perl Programming book to find out more about this feature.

      swig-3.0.2/Examples/perl5/variables/runme.pl0000664000175000017500000000373412343605122020612 0ustar williamwilliam# file: runme.pl use example; # Try to set the values of some global variables $example::ivar = 42; $example::svar = -31000; $example::lvar = 65537; $example::uivar = 123456; $example::usvar = 61000; $example::ulvar = 654321; $example::scvar = -13; $example::ucvar = 251; $example::cvar = "S"; $example::fvar = 3.14159; $example::dvar = 2.1828; $example::strvar = "Hello World"; $example::iptrvar= example::new_int(37); $example::ptptr = example::new_Point(37,42); $example::name = "Bill"; # Now print out the values of the variables print "Variables (values printed from Perl)\n"; print "ivar = $example::ivar\n"; print "svar = $example::svar\n"; print "lvar = $example::lvar\n"; print "uivar = $example::uivar\n"; print "usvar = $example::usvar\n"; print "ulvar = $example::ulvar\n"; print "scvar = $example::scvar\n"; print "ucvar = $example::ucvar\n"; print "fvar = $example::fvar\n"; print "dvar = $example::dvar\n"; print "cvar = $example::cvar\n"; print "strvar = $example::strvar\n"; print "cstrvar = $example::cstrvar\n"; print "iptrvar = $example::iptrvar\n"; print "name = $example::name\n"; print "ptptr = $example::ptptr", example::Point_print($example::ptptr), "\n"; print "pt = $example::pt", example::Point_print($example::pt), "\n"; print "\nVariables (values printed from C)\n"; example::print_vars(); print "\nI'm going to try and update a structure variable.\n"; $example::pt = $example::ptptr; print "The new value is "; example::pt_print(); print "You should see the value", example::Point_print($example::ptptr), "\n"; print "\nNow I'm going to try and modify some read only variables\n"; print " Trying to set 'status'\n"; eval { $example::status = 0; }; if (!$@) { die("status"); } print " get error for 'status'\n"; print " Tring to set 'path'\n"; eval { $example::path = "Whoa!";}; if (!$@) { die("path"); } print " get error for 'path'\n"; swig-3.0.2/Examples/perl5/variables/Makefile0000664000175000017500000000112412343605122020556 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.2/Examples/java/0000775000175000017500000000000012343605122015042 5ustar williamwilliamswig-3.0.2/Examples/java/template/0000775000175000017500000000000012343605122016655 5ustar williamwilliamswig-3.0.2/Examples/java/template/runme.java0000664000175000017500000000207012343605122020645 0ustar williamwilliam// This example illustrates how C++ templates can be used from Java. public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Call some templated functions System.out.println(example.maxint(3,7)); System.out.println(example.maxdouble(3.14,2.18)); // Create some class vecint iv = new vecint(100); vecdouble dv = new vecdouble(1000); for (int i=0; i<100; i++) iv.setitem(i,2*i); for (int i=0; i<1000; i++) dv.setitem(i, 1.0/(i+1)); { int sum = 0; for (int i=0; i<100; i++) sum = sum + iv.getitem(i); System.out.println(sum); } { double sum = 0.0; for (int i=0; i<1000; i++) sum = sum + dv.getitem(i); System.out.println(sum); } } } swig-3.0.2/Examples/java/template/example.h0000664000175000017500000000077712343605122020474 0ustar williamwilliam/* File : example.h */ // Some template definitions template T max(T a, T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } #ifdef SWIG %extend { T getitem(int index) { return $self->get(index); } void setitem(int index, T val) { $self->set(index,val); } } #endif }; swig-3.0.2/Examples/java/template/example.i0000664000175000017500000000051412343605122020462 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; swig-3.0.2/Examples/java/template/index.html0000664000175000017500000000441412343605122020655 0ustar williamwilliam SWIG:Examples:java:template SWIG/Examples/java/template/

      C++ template support

      This example illustrates how C++ templates can be used from Java using SWIG.

      The C++ Code

      Let's take a templated function and a templated class as follows:
      /* File : example.h */
      
      // Some template definitions
      
      template T max(T a, T b) { return  a>b ? a : b; }
      
      template class vector {
        T *v;
        int sz;
       public:
        vector(int _sz) {
          v = new T[_sz];
          sz = _sz;
        }
        T &get(int index) {
          return v[index];
        }
        void set(int index, T &val) {
          v[index] = val;
        }
      #ifdef SWIG
        %addmethods {
          T getitem(int index) {
            return self->get(index);
          }
          void setitem(int index, T val) {
            self->set(index,val);
          }
        }
      #endif
      };
      
      The %addmethods is used for a neater interface from Java as the functions get and set use C++ references to primitive types. These are tricky to use from Java as they end up as a pointer in Java (Java long).

      The SWIG interface

      A simple SWIG interface for this can be built by simply grabbing the header file like this:
      /* File : example.i */
      %module example
      
      %{
      #include "example.h"
      %}
      
      /* Let's just grab the original header file here */
      %include "example.h"
      
      /* Now instantiate some specific template declarations */
      
      %template(maxint) max;
      %template(maxdouble) max;
      %template(vecint) vector;
      %template(vecdouble) vector;
      
      Note that SWIG parses the templated function max and templated class vector and so knows about them. However to generate code for use from Java, SWIG has to be told which class/type to use as the template parameter. The SWIG directive %template is used for this.

      A sample Java program

      Click here to see a Java program that calls the C++ functions from Java.

      Notes

      Use templated classes just like you would any other SWIG generated Java class. Use the classnames specified by the %template directive.
      vecdouble dv = new vecdouble(1000);
      dv.setitem(i, 12.34));
      

      swig-3.0.2/Examples/java/template/Makefile0000664000175000017500000000105512343605122020316 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/class/0000775000175000017500000000000012343605122016147 5ustar williamwilliamswig-3.0.2/Examples/java/class/runme.java0000664000175000017500000000443112343605122020142 0ustar williamwilliam// This example illustrates how C++ classes can be used from Java using SWIG. // The Java class gets mapped onto the C++ class and behaves as if it is a Java class. public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // ----- Object creation ----- System.out.println( "Creating some objects:" ); Circle c = new Circle(10); System.out.println( " Created circle " + c ); Square s = new Square(10); System.out.println( " Created square " + s ); // ----- Access a static member ----- System.out.println( "\nA total of " + Shape.getNshapes() + " shapes were created" ); // ----- Member data access ----- // Notice how we can do this using functions specific to // the 'Circle' class. c.setX(20); c.setY(30); // Now use the same functions in the base class Shape shape = s; shape.setX(-10); shape.setY(5); System.out.println( "\nHere is their current position:" ); System.out.println( " Circle = (" + c.getX() + " " + c.getY() + ")" ); System.out.println( " Square = (" + s.getX() + " " + s.getY() + ")" ); // ----- Call some methods ----- System.out.println( "\nHere are some properties of the shapes:" ); Shape[] shapes = {c,s}; for (int i=0; i SWIG:Examples:java:class SWIG/Examples/java/class/

      Wrapping a simple C++ class

      This example illustrates the high level form of C++ class wrapping performed by SWIG. In this case, a C++ class has a proxy Java class, which provides access to C++ class members.

      The C++ Code

      Suppose you have some C++ classes described by the following (and admittedly lame) header file:
      /* File : example.h */
      
      class Shape {
      public:
        Shape() {
          nshapes++;
        }
        virtual ~Shape() {
          nshapes--;
        }
        double  x, y;
        void    move(double dx, double dy);
        virtual double area() = 0;
        virtual double perimeter() = 0;
        static  int nshapes;
      };
      
      class Circle : public Shape {
      private:
        double radius;
      public:
        Circle(double r) : radius(r) { }
        virtual double area();
        virtual double perimeter();
      };
      
      class Square : public Shape {
      private:
        double width;
      public:
        Square(double w) : width(w) { }
        virtual double area();
        virtual double perimeter();
      };
      

      The SWIG interface

      A simple SWIG interface for this can be built by simply grabbing the header file like this:
      /* File : example.i */
      %module example
      
      %{
      #include "example.h"
      %}
      
      /* Let's just grab the original header file here */
      %include "example.h"
      
      Note: when creating a C++ extension, you must run SWIG with the -c++ option like this:
      % swig -c++ -java example.i
      

      A sample Java program

      Click here to see a Java program that calls the C++ functions from Java.

      Key points

      • To create a new object, you call a constructor like this:
        Circle c = new Circle(10);
        

      • To access member data, a pair of accessor functions are used. For example:
        c.setX(15);        // Set member data
        x = c.getX();      // Get member data
        

      • To invoke a member function, you simply do this
        System.out.println( "The area is " + c.area() );
        

      • To invoke a destructor, simply do this
        c.delete();     // Deletes a shape
        

      • Static member variables are wrapped with java static get and set access functions. For example:
        n = Shape.getNshapes();     // Get a static data member
        Shape.setNshapes(13);       // Set a static data member
        

      General Comments

      • This high-level interface using proxy classes is not the only way to handle C++ code. A low level interface using C functions to access member variables and member functions is the alternative SWIG approach. This entails passing around the C pointer or C++ 'this' pointer and as such it is not difficult to crash the JVM. The abstraction of the underlying pointer by the java proxy classes far better fits the java programming paradigm.

      • SWIG does know how to properly perform upcasting of objects in an inheritance hierarchy (including multiple inheritance). However Java classes can only derive from one base class so multiple inheritance is not implemented. Java classes can implement more than one interface so there is scope for improvement in the future.

      swig-3.0.2/Examples/java/class/example.dsp0000664000175000017500000001267712343605122020327 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Java compile post-build step PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java # End Special Build Tool !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll" # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Java compile post-build step PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java # End Special Build Tool !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on ..\..\..\swig.exe -c++ -java "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on ..\..\..\swig.exe -c++ -java "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/java/class/Makefile0000664000175000017500000000107112343605122017606 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/pointer/0000775000175000017500000000000012343605122016522 5ustar williamwilliamswig-3.0.2/Examples/java/pointer/runme.java0000664000175000017500000000337312343605122020521 0ustar williamwilliam public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // First create some objects using the pointer library. System.out.println("Testing the pointer library"); SWIGTYPE_p_int a = example.new_intp(); SWIGTYPE_p_int b = example.new_intp(); SWIGTYPE_p_int c = example.new_intp(); example.intp_assign(a,37); example.intp_assign(b,42); // Note that getCPtr() has package access by default System.out.println(" a =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(a))); System.out.println(" b =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(b))); System.out.println(" c =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(c))); // Call the add() function with some pointers example.add(a,b,c); // Now get the result int res = example.intp_value(c); System.out.println(" 37 + 42 =" + res); // Clean up the pointers example.delete_intp(a); example.delete_intp(b); example.delete_intp(c); // Now try the typemap library // Now it is no longer necessary to manufacture pointers. // Instead we use a single element array which in Java is modifiable. System.out.println("Trying the typemap library"); int[] r = {0}; example.sub(37,42,r); System.out.println(" 37 - 42 = " + r[0]); // Now try the version with return value System.out.println("Testing return value"); int q = example.divide(42,37,r); System.out.println(" 42/37 = " + q + " remainder " + r[0]); } } swig-3.0.2/Examples/java/pointer/example.c0000664000175000017500000000036112343605122020321 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void sub(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/java/pointer/example.i0000664000175000017500000000117612343605122020334 0ustar williamwilliam/* File : example.i */ %module example %{ extern void add(int *, int *, int *); extern void sub(int *, int *, int *); extern int divide(int, int, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); swig-3.0.2/Examples/java/pointer/index.html0000664000175000017500000000713312343605122020523 0ustar williamwilliam SWIG:Examples:java:pointer SWIG/Examples/java/pointer/

      Simple Pointer Handling

      This example illustrates a couple of techniques for handling simple pointers in SWIG. The prototypical example is a C function that operates on pointers such as this:

      void add(int *x, int *y, int *r) { 
          *r = *x + *y;
      }
      
      By default, SWIG wraps this function exactly as specified and creates an interface that expects pointer objects for arguments. SWIG wraps a C pointer with a type wrapper class, for example, SWIGTYPE_p_int for an int*. The only problem is how does one go about creating these objects from a Java program?

      Possible Solutions

      • Write some helper functions to explicitly create objects. For example:
        int *new_int(int ivalue) {
          int *i = (int *) malloc(sizeof(ivalue));
          *i = ivalue;
          return i;
        }
        int get_int(int *i) {
          return *i;
        }
        
        void delete_int(int *i) {
          free(i);
        }
        

      • The SWIG pointer library provides an easier way.
        For example, in the interface file you would do this:
        %include cpointer.i
        %pointer_functions(int, intp);
        
        and from Java you would use pointers like this:
        SWIGTYPE_p_int a = example.new_intp();
        SWIGTYPE_p_int b = example.new_intp();
        SWIGTYPE_p_int c = example.new_intp();
        example.intp_assign(a,37);
        example.intp_assign(b,42);
        
        // Note that getCPtr() has package access by default
        System.out.println("     a =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(a)));
        System.out.println("     b =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(b)));
        System.out.println("     c =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(c)));
        
        // Call the add() function with some pointers
        example.add(a,b,c);
        
        // Now get the result
        int res = example.intp_value(c);
        System.out.println("     37 + 42 =" + res);
        
        // Clean up the pointers
        example.delete_intp(a);
        example.delete_intp(b);
        example.delete_intp(c);
        

      • Use the SWIG typemap library. This library allows you to completely change the way arguments are processed by SWIG. For example:
        %include "typemaps.i"
        void add(int *INPUT, int *INPUT, int *OUTPUT);
        
        And in a Java program:
        int[] r = {0};
        example.sub(37,42,r);
        System.out.println("Result =" + r[0]);
        
        Needless to say, this is substantially easier although a bit unusual.

      • A final alternative is to use the typemaps library in combination with the %apply directive. This allows you to change the names of parameters that behave as input or output parameters. For example:
        %include "typemaps.i"
        %apply int *INPUT {int *x, int *y};
        %apply int *OUTPUT {int *r};
        
        void add(int *x, int *y, int *r);
        void sub(int *x, int *y, int *r);
        void mul(int *x, int *y, int *r);
        ... etc ...
        

      Example

      The following example illustrates the use of these features for pointer extraction.

      Notes

      • Since pointers are used for so many different things (arrays, output values, etc...) the complexity of pointer handling can be as complicated as you want to make it.

      • More documentation on the typemaps.i and cpointer.i library files can be found in the SWIG user manual. The files also contain documentation.

      swig-3.0.2/Examples/java/pointer/Makefile0000664000175000017500000000105512343605122020163 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/nested/0000775000175000017500000000000012343605122016324 5ustar williamwilliamswig-3.0.2/Examples/java/nested/runme.java0000664000175000017500000000341412343605122020317 0ustar williamwilliam// This example illustrates wrapping of nested C++ classes public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { MotorCar car1 = MotorCar.DesignFromComponents("Bumpy", new MotorCar.Wheels(MotorCar.Wheels.Shape.Square, 4), new MotorCar.WindScreen(false)); MotorCar car2 = MotorCar.DesignFromComponents("Wobbly", new MotorCar.Wheels(MotorCar.Wheels.Shape.Round, 2), new MotorCar.WindScreen(false)); MotorCar car3 = MotorCar.DesignFromComponents("Batty", new MotorCar.Wheels(MotorCar.Wheels.Shape.Round, 4), new MotorCar.WindScreen(true)); MotorCar car4 = MotorCar.DesignFromComponents("Spiffing", new MotorCar.Wheels(MotorCar.Wheels.Shape.Round, 4), new MotorCar.WindScreen(false)); System.out.println("Expert opinion on " + car1.Name() + " : \n " + car1.WillItWork()); System.out.println("Expert opinion on " + car2.Name() + " : \n " + car2.WillItWork()); System.out.println("Expert opinion on " + car3.Name() + " : \n " + car3.WillItWork()); System.out.println("Expert opinion on " + car4.Name() + " : \n " + car4.WillItWork()); int count = MotorCar.DesignOpinion.getAceDesignCount(); int total = MotorCar.DesignOpinion.getTotalDesignCount(); int percent = MotorCar.DesignOpinion.PercentScore(); System.out.println("Overall opinion rating on car design is " + count + "/" + total + " = " + percent + "%"); System.out.println("Single square wheel thoughts: " + new MotorCar.Wheels(MotorCar.Wheels.Shape.Square, 1).Opinion().getReason()); } } swig-3.0.2/Examples/java/nested/example.h0000664000175000017500000000213512343605122020131 0ustar williamwilliam#include /** Design a motor car from various components */ struct MotorCar { /** Information about an opinion of the design of a car component */ struct DesignOpinion { bool itrocks; std::string reason; static int AceDesignCount; static int TotalDesignCount; static int PercentScore(); }; /** Wheels component */ struct Wheels { enum Shape { Round, Square }; Wheels(Shape shape, size_t count); DesignOpinion Opinion(); private: Shape shape; size_t count; }; /** Windscreen component */ struct WindScreen { WindScreen(bool opaque); DesignOpinion Opinion(); private: bool opaque; }; /** Factory method for creating a car */ static MotorCar DesignFromComponents(const std::string &name, const Wheels &wheels, const WindScreen &windscreen); std::string Name() { return name; } /** Get an overall opinion on the car design */ std::string WillItWork(); private: MotorCar(const std::string &name, const Wheels &wheels, const WindScreen &windscreen); std::string name; Wheels wheels; WindScreen windscreen; }; swig-3.0.2/Examples/java/nested/example.i0000664000175000017500000000036612343605122020136 0ustar williamwilliam%module example // This example shows how wrappers for numerous aspects of C++ nested classes work: // Nested static and instance variables and methods and nested enums %include %{ #include "example.h" %} %include "example.h" swig-3.0.2/Examples/java/nested/example.cxx0000664000175000017500000000407412343605122020510 0ustar williamwilliam#include "example.h" int MotorCar::DesignOpinion::AceDesignCount = 0; int MotorCar::DesignOpinion::TotalDesignCount = 0; int MotorCar::DesignOpinion::PercentScore() { return AceDesignCount*100/TotalDesignCount; } MotorCar::Wheels::Wheels(Shape shape, size_t count) : shape(shape), count(count) {} MotorCar::WindScreen::WindScreen(bool opaque) : opaque(opaque) {} MotorCar::MotorCar(const std::string &name, const Wheels &wheels, const WindScreen &windscreen) : name(name), wheels(wheels), windscreen(windscreen) {} MotorCar MotorCar::DesignFromComponents(const std::string &name, const Wheels &wheels, const WindScreen &windscreen) { MotorCar car = MotorCar(name, wheels, windscreen); DesignOpinion::TotalDesignCount++; if (car.wheels.Opinion().itrocks && car.windscreen.Opinion().itrocks) DesignOpinion::AceDesignCount++; return car; } MotorCar::DesignOpinion MotorCar::Wheels::Opinion() { DesignOpinion opinion; opinion.itrocks = true; if (shape == Square) { opinion.itrocks = false; opinion.reason = "you'll have a few issues with wheel rotation"; } if (count <= 2) { opinion.reason += opinion.itrocks ? "" : " and "; opinion.itrocks = false; opinion.reason += "a few more wheels are needed for stability"; } if (opinion.itrocks) opinion.reason = "your choice of wheels was top notch"; return opinion; } MotorCar::DesignOpinion MotorCar::WindScreen::Opinion() { DesignOpinion opinion; opinion.itrocks = !opaque; opinion.reason = opinion.itrocks ? "the driver will have a commanding view out the window" : "you can't see out the windscreen"; return opinion; } std::string MotorCar::WillItWork() { DesignOpinion wh = wheels.Opinion(); DesignOpinion ws = windscreen.Opinion(); std::string willit; if (wh.itrocks && ws.itrocks) { willit = "Great car design because " + wh.reason + " and " + ws.reason; } else { willit = "You need a rethink because "; willit += wh.itrocks ? "" : wh.reason; willit += (!wh.itrocks && !ws.itrocks) ? " and " : ""; willit += ws.itrocks ? "" : ws.reason; } return willit; } swig-3.0.2/Examples/java/nested/example.dsp0000664000175000017500000001267712343605122020504 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Java compile post-build step PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java # End Special Build Tool !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll" # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Java compile post-build step PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java # End Special Build Tool !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on ..\..\..\swig.exe -c++ -java "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on ..\..\..\swig.exe -c++ -java "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/java/nested/Makefile0000664000175000017500000000107112343605122017763 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/enum/0000775000175000017500000000000012343605122016006 5ustar williamwilliamswig-3.0.2/Examples/java/enum/runme.java0000664000175000017500000000264712343605122020010 0ustar williamwilliam public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Print out the value of some enums System.out.println("*** color ***"); System.out.println(" " + color.RED + " = " + color.RED.swigValue()); System.out.println(" " + color.BLUE + " = " + color.BLUE.swigValue()); System.out.println(" " + color.GREEN + " = " + color.GREEN.swigValue()); System.out.println("\n*** Foo::speed ***"); System.out.println(" Foo::" + Foo.speed.IMPULSE + " = " + Foo.speed.IMPULSE.swigValue()); System.out.println(" Foo::" + Foo.speed.WARP + " = " + Foo.speed.WARP.swigValue()); System.out.println(" Foo::" + Foo.speed.LUDICROUS + " = " + Foo.speed.LUDICROUS.swigValue()); System.out.println("\nTesting use of enums with functions\n"); example.enum_test(color.RED, Foo.speed.IMPULSE); example.enum_test(color.BLUE, Foo.speed.WARP); example.enum_test(color.GREEN, Foo.speed.LUDICROUS); System.out.println( "\nTesting use of enum with class method" ); Foo f = new Foo(); f.enum_test(Foo.speed.IMPULSE); f.enum_test(Foo.speed.WARP); f.enum_test(Foo.speed.LUDICROUS); } } swig-3.0.2/Examples/java/enum/example.h0000664000175000017500000000032612343605122017613 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/java/enum/example.i0000664000175000017500000000037212343605122017615 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Force the generated Java code to use the C enum values rather than making a JNI call */ %javaconst(1); /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/java/enum/example.cxx0000664000175000017500000000151112343605122020163 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/java/enum/index.html0000664000175000017500000000125412343605122020005 0ustar williamwilliam SWIG:Examples:java:enum SWIG/Examples/java/enum/

      Wrapping enumerations

      This example tests SWIG's ability to wrap enumerations. SWIG wraps enums in numerous different ways. The default approach is to wrap each enum with the typesafe enum pattern. Enums are handled as integers in the JNI layer. See the documentation for the other approaches for wrapping enums.


      swig-3.0.2/Examples/java/enum/Makefile0000664000175000017500000000107112343605122017445 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/simple/0000775000175000017500000000000012343605122016333 5ustar williamwilliamswig-3.0.2/Examples/java/simple/runme.java0000664000175000017500000000145612343605122020332 0ustar williamwilliam public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Call our gcd() function int x = 42; int y = 105; int g = example.gcd(x,y); System.out.println("The gcd of " + x + " and " + y + " is " + g); // Manipulate the Foo global variable // Output its current value System.out.println("Foo = " + example.getFoo()); // Change its value example.setFoo(3.1415926); // See if the change took effect System.out.println("Foo = " + example.getFoo()); } } swig-3.0.2/Examples/java/simple/example.c0000664000175000017500000000036712343605122020140 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/java/simple/example.i0000664000175000017500000000015212343605122020136 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/java/simple/index.html0000664000175000017500000000420712343605122020333 0ustar williamwilliam SWIG:Examples:java:simple SWIG/Examples/java/simple/

      Simple Java Example

      This example illustrates how you can hook Java to a very simple C program containing a function and a global variable.

      The C Code

      Suppose you have the following C code:
      /* File : example.c */
      
      /* A global variable */
      double Foo = 3.0;
      
      /* Compute the greatest common divisor of positive integers */
      int gcd(int x, int y) {
        int g;
        g = y;
        while (x > 0) {
          g = x;
          x = y % x;
          y = g;
        }
        return g;
      }
      

      The SWIG interface

      Here is a simple SWIG interface file:
      /* File: example.i */
      %module example
      
      extern int gcd(int x, int y);
      extern double Foo;
      

      Compilation

      1. swig -java example.i

      2. Compile example_wrap.c and example.c to create the extension libexample.so (unix).

      Using the extension

      Click here to see a program that calls our C functions from Java.

      Compile the java files example.java and runme.java to create the class files example.class and runme.class before running runme in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:

      export LD_LIBRARY_PATH=. #ksh 
      javac *.java
      java runme
      

      Key points

      • Use the loadLibrary statement from java to load and access the generated java classes. For example:
        System.loadLibrary("example");
        
      • C functions work just like Java functions. For example:
        int g = example.gcd(42,105);
        
      • C global variables are accessed through get and set functions in the module class. For example:
        double a = example.get_Foo();
        example.set_Foo(20.0);
        

      swig-3.0.2/Examples/java/simple/example.dsp0000664000175000017500000001255712343605122020510 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Java compile post-build step PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java # End Special Build Tool !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll" # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Java compile post-build step PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java # End Special Build Tool !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on ..\..\..\swig.exe -java "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on ..\..\..\swig.exe -java "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/java/simple/Makefile0000664000175000017500000000105512343605122017774 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/constants/0000775000175000017500000000000012343605122017056 5ustar williamwilliamswig-3.0.2/Examples/java/constants/runme.java0000664000175000017500000000320012343605122021042 0ustar williamwilliamimport java.lang.reflect.*; public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { System.out.println("ICONST = " + example.ICONST + " (should be 42)"); System.out.println("FCONST = " + example.FCONST + " (should be 2.1828)"); System.out.println("CCONST = " + example.CCONST + " (should be 'x')"); System.out.println("CCONST2 = " + example.CCONST2 + " (this should be on a new line)"); System.out.println("SCONST = " + example.SCONST + " (should be 'Hello World')"); System.out.println("SCONST2 = " + example.SCONST2 + " (should be '\"Hello World\"')"); System.out.println("EXPR = " + example.EXPR + " (should be 48.5484)"); System.out.println("iconst = " + example.iconst + " (should be 37)"); System.out.println("fconst = " + example.fconst + " (should be 3.14)"); // Use reflection to check if these variables are defined: try { System.out.println("EXTERN = " + example.class.getField("EXTERN") + " (Arg! This shouldn't print anything)"); } catch (NoSuchFieldException e) { System.out.println("EXTERN isn't defined (good)"); } try { System.out.println("FOO = " + example.class.getField("FOO") + " (Arg! This shouldn't print anything)"); } catch (NoSuchFieldException e) { System.out.println("FOO isn't defined (good)"); } } } swig-3.0.2/Examples/java/constants/example.i0000664000175000017500000000131412343605122020662 0ustar williamwilliam/* File : example.i */ %module example /* Force the generated Java code to use the C constant values rather than making a JNI call */ %javaconst(1); /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/java/constants/index.html0000664000175000017500000000331612343605122021056 0ustar williamwilliam SWIG:Examples:java:constants SWIG/Examples/java/constants/

      Wrapping C Constants

      When SWIG encounters C preprocessor macros and C declarations that look like constants, it creates Java constant with an identical value. Click here to see a SWIG interface with some constant declarations in it.

      Accessing Constants from Java

      Click here for the section on constants in the SWIG and Java documentation.

      Click here to see a Java program that prints out the values of the constants contained in the above file.

      Key points

      • The values of preprocessor macros are converted into Java constants.
      • Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
      • Character constants such as 'x' are converted into Java strings.
      • C string literals such as "Hello World" are converted into Java strings.
      • Macros that are not fully defined are simply ignored. For example:
        #define EXTERN extern
        
        is ignored because SWIG has no idea what type of variable this would be.

      • Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
      • Certain C declarations involving 'const' are also turned into Java constants.
      • The constants that appear in a SWIG interface file do not have to appear in any sort of matching C source file since the creation of a constant does not require linkage to a stored value (i.e., a value held in a C global variable or memory location).

      swig-3.0.2/Examples/java/constants/Makefile0000664000175000017500000000105512343605122020517 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/typemap/0000775000175000017500000000000012343605122016521 5ustar williamwilliamswig-3.0.2/Examples/java/typemap/runme.java0000664000175000017500000000123712343605122020515 0ustar williamwilliam public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { String s = "brave new world"; example.f1(s); System.out.println("f1(String): " + s); byte b[] = new byte[25]; example.f2(b); System.out.println("f2(byte[]): " + new String(b)); StringBuffer sb = new StringBuffer(20); example.f3(sb); System.out.println("f3(StringBuffer): " + sb); } } swig-3.0.2/Examples/java/typemap/example.i0000664000175000017500000000563212343605122020334 0ustar williamwilliam/* File : example.i */ %module example %{ /* example of a function that returns a value in the char * argument normally used like: char buf[bigenough]; f1(buf); */ void f1(char *s) { if(s != NULL) { sprintf(s, "hello world"); } } void f2(char *s) { f1(s); } void f3(char *s) { f1(s); } %} /* default behaviour is that of input arg, Java cannot return a value in a * string argument, so any changes made by f1(char*) will not be seen in the Java * string passed to the f1 function. */ void f1(char *s); %include various.i /* use the BYTE argout typemap to get around this. Changes in the string by * f2 can be seen in Java. */ void f2(char *BYTE); /* Alternative approach uses a StringBuffer typemap for argout */ /* Define the types to use in the generated JNI C code and Java code */ %typemap(jni) char *SBUF "jobject" %typemap(jtype) char *SBUF "StringBuffer" %typemap(jstype) char *SBUF "StringBuffer" /* How to convert Java(JNI) type to requested C type */ %typemap(in) char *SBUF { $1 = NULL; if($input != NULL) { /* Get the String from the StringBuffer */ jmethodID setLengthID; jclass sbufClass = (*jenv)->GetObjectClass(jenv, $input); jmethodID toStringID = (*jenv)->GetMethodID(jenv, sbufClass, "toString", "()Ljava/lang/String;"); jstring js = (jstring) (*jenv)->CallObjectMethod(jenv, $input, toStringID); /* Convert the String to a C string */ const char *pCharStr = (*jenv)->GetStringUTFChars(jenv, js, 0); /* Take a copy of the C string as the typemap is for a non const C string */ jmethodID capacityID = (*jenv)->GetMethodID(jenv, sbufClass, "capacity", "()I"); jint capacity = (*jenv)->CallIntMethod(jenv, $input, capacityID); $1 = (char *) malloc(capacity+1); strcpy($1, pCharStr); /* Release the UTF string we obtained with GetStringUTFChars */ (*jenv)->ReleaseStringUTFChars(jenv, js, pCharStr); /* Zero the original StringBuffer, so we can replace it with the result */ setLengthID = (*jenv)->GetMethodID(jenv, sbufClass, "setLength", "(I)V"); (*jenv)->CallVoidMethod(jenv, $input, setLengthID, (jint) 0); } } /* How to convert the C type to the Java(JNI) type */ %typemap(argout) char *SBUF { if($1 != NULL) { /* Append the result to the empty StringBuffer */ jstring newString = (*jenv)->NewStringUTF(jenv, $1); jclass sbufClass = (*jenv)->GetObjectClass(jenv, $input); jmethodID appendStringID = (*jenv)->GetMethodID(jenv, sbufClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); (*jenv)->CallObjectMethod(jenv, $input, appendStringID, newString); /* Clean up the string object, no longer needed */ free($1); $1 = NULL; } } /* Prevent the default freearg typemap from being used */ %typemap(freearg) char *SBUF "" /* Convert the jstype to jtype typemap type */ %typemap(javain) char *SBUF "$javainput" /* apply the new typemap to our function */ void f3(char *SBUF); swig-3.0.2/Examples/java/typemap/index.html0000664000175000017500000000120512343605122020514 0ustar williamwilliam SWIG:Examples:java:typemap SWIG/Examples/java/typemap/

      Typemaps in Java

      This example shows how typemaps can be used to modify the default behaviour of the Java SWIG module.

      Notes

      • Shows how to pass strings to Java from c and visa versa.
      • Typemaps can modify the default behaviour of the Java SWIG module.
      • The default c to java mapping can be modified using typemaps.

      swig-3.0.2/Examples/java/typemap/Makefile0000664000175000017500000000104312343605122020157 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/extend/0000775000175000017500000000000012343605122016331 5ustar williamwilliamswig-3.0.2/Examples/java/extend/runme.java0000664000175000017500000000713112343605122020324 0ustar williamwilliam// This file illustrates the cross language polymorphism using directors. // CEO class, which overrides Employee::getPosition(). class CEO extends Manager { public CEO(String name) { super(name); } public String getPosition() { return "CEO"; } // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory. public void disownMemory() { swigCMemOwn = false; } } public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Create an instance of CEO, a class derived from the Java proxy of the // underlying C++ class. The calls to getName() and getPosition() are standard, // the call to getTitle() uses the director wrappers to call CEO.getPosition(). CEO e = new CEO("Alice"); System.out.println( e.getName() + " is a " + e.getPosition() ); System.out.println( "Just call her \"" + e.getTitle() + "\"" ); System.out.println( "----------------------" ); // Create a new EmployeeList instance. This class does not have a C++ // director wrapper, but can be used freely with other classes that do. EmployeeList list = new EmployeeList(); // EmployeeList owns its items, so we must surrender ownership of objects we add. e.disownMemory(); list.addEmployee(e); System.out.println( "----------------------" ); // Now we access the first four items in list (three are C++ objects that // EmployeeList's constructor adds, the last is our CEO). The virtual // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in Java. The call to getPosition is // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, Java resolved the call // immediately in CEO, but now Java thinks the object is an instance of // class Employee. So the call passes through the // Employee proxy class and on to the C wrappers and C++ director, // eventually ending up back at the Java CEO implementation of getPosition(). // The call to getTitle() for item 3 runs the C++ Employee::getTitle() // method, which in turn calls getPosition(). This virtual method call // passes down through the C++ director class to the Java implementation // in CEO. All this routing takes place transparently. System.out.println( "(position, title) for items 0-3:" ); System.out.println( " " + list.get_item(0).getPosition() + ", \"" + list.get_item(0).getTitle() + "\"" ); System.out.println( " " + list.get_item(1).getPosition() + ", \"" + list.get_item(1).getTitle() + "\"" ); System.out.println( " " + list.get_item(2).getPosition() + ", \"" + list.get_item(2).getTitle() + "\"" ); System.out.println( " " + list.get_item(3).getPosition() + ", \"" + list.get_item(3).getTitle() + "\"" ); System.out.println( "----------------------" ); // Time to delete the EmployeeList, which will delete all the Employee* // items it contains. The last item is our CEO, which gets destroyed as well. list.delete(); System.out.println( "----------------------" ); // All done. System.out.println( "java exit" ); } } swig-3.0.2/Examples/java/extend/example.h0000664000175000017500000000260512343605122020140 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *get_item(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; swig-3.0.2/Examples/java/extend/example.i0000664000175000017500000000040312343605122020133 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_vector.i" %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; %include "example.h" swig-3.0.2/Examples/java/extend/example.cxx0000664000175000017500000000006012343605122020504 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/java/extend/index.html0000664000175000017500000000044612343605122020332 0ustar williamwilliam SWIG:Examples:java:extend SWIG/Examples/java/extend/

      Extending a simple C++ class in Java

      This example illustrates the extending of a C++ class with cross language polymorphism.


      swig-3.0.2/Examples/java/extend/Makefile0000664000175000017500000000107112343605122017770 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/reference/0000775000175000017500000000000012343605122017000 5ustar williamwilliamswig-3.0.2/Examples/java/reference/runme.java0000664000175000017500000000531712343605122020777 0ustar williamwilliam// This example illustrates the manipulation of C++ references in Java. public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { System.out.println( "Creating some objects:" ); Vector a = new Vector(3,4,5); Vector b = new Vector(10,11,12); System.out.println( " Created " + a.print() ); System.out.println( " Created " + b.print() ); // ----- Call an overloaded operator ----- // This calls the wrapper we placed around // // operator+(const Vector &a, const Vector &) // // It returns a new allocated object. System.out.println( "Adding a+b" ); Vector c = example.addv(a,b); System.out.println( " a+b = " + c.print() ); // Note: Unless we free the result, a memory leak will occur if the -noproxy commandline // is used as the proxy classes define finalizers which call the delete() method. When // -noproxy is not specified the memory management is controlled by the garbage collector. // You can still call delete(). It will free the c++ memory immediately, but not the // Java memory! You then must be careful not to call any member functions as it will // use a NULL c pointer on the underlying c++ object. We set the Java object to null // which will then throw a Java exception should we attempt to use it again. c.delete(); c = null; // ----- Create a vector array ----- System.out.println( "Creating an array of vectors" ); VectorArray va = new VectorArray(10); System.out.println( " va = " + va.toString() ); // ----- Set some values in the array ----- // These operators copy the value of Vector a and Vector b to the vector array va.set(0,a); va.set(1,b); // This works, but it would cause a memory leak if -noproxy was used! va.set(2,example.addv(a,b)); // Get some values from the array System.out.println( "Getting some array values" ); for (int i=0; i<5; i++) System.out.println( " va(" + i + ") = " + va.get(i).print() ); // Watch under resource meter to check on this System.out.println( "Making sure we don't leak memory." ); for (int i=0; i<1000000; i++) c = va.get(i%10); // ----- Clean up ----- // This could be omitted. The garbage collector would then clean up for us. System.out.println( "Cleaning up" ); va.delete(); a.delete(); b.delete(); } } swig-3.0.2/Examples/java/reference/example.h0000664000175000017500000000064512343605122020611 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; friend Vector operator+(const Vector &a, const Vector &b); char *print(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/java/reference/example.i0000664000175000017500000000131412343605122020604 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module example %{ #include "example.h" %} class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.2/Examples/java/reference/example.cxx0000664000175000017500000000161412343605122021161 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/java/reference/index.html0000664000175000017500000000633412343605122021003 0ustar williamwilliam SWIG:Examples:java:reference SWIG/Examples/java/reference/

      C++ Reference Handling

      This example tests SWIG's handling of C++ references. Since C++ references are closely related to pointers (as both refer to a location in memory), SWIG simply collapses all references into pointers when creating wrappers.

      Some examples

      References are most commonly used as function parameter. For example, you might have an operator like this:
      Vector operator+(const Vector &a, const Vector &b) {
         Vector result;
         result.x = a.x + b.x;
         result.y = a.y + b.y;
         result.z = a.z + b.z;
         return result;
      }
      
      or a function:
      Vector addv(const Vector &a, const Vector &b) {
         Vector result;
         result.x = a.x + b.x;
         result.y = a.y + b.y;
         result.z = a.z + b.z;
         return result;
      }
      
      In these cases, SWIG transforms everything into a pointer and creates a wrapper that looks like this:
      Vector wrap_addv(Vector *a, Vector *b) {
          return addv(*a,*b);
      }
      
      Occasionally, a reference is used as a return value of a function when the return result is to be used as an lvalue in an expression. The prototypical example is an operator like this:
      Vector &operator[](int index);
      
      or a method:
      Vector &get(int index);
      
      For functions returning references, a wrapper like this is created:
      Vector *wrap_Object_get(Object *self, int index) {
          Vector &result = self->get(index);
          return &result;
      }
      
      The following header file contains some class definitions with some operators and use of references.

      SWIG Interface

      SWIG does NOT support overloaded operators so it can not directly build an interface to the classes in the above file. However, a number of workarounds can be made. For example, an overloaded operator can be stuck behind a function call such as the addv() function above. Array access can be handled with a pair of set/get functions like this:
      class VectorArray {
      public:
       ...
         %addmethods {
          Vector &get(int index) {
            return (*self)[index];
          }
          void set(int index, Vector &a) {
            (*self)[index] = a;
          }
         }
         ...
      }
      
      Click here to see a SWIG interface file with these additions.

      Sample Java program

      Click here to see a Java program that manipulates some C++ references.

      Notes:

      • C++ references primarily provide notational convenience for C++ source code. However, Java only supports the 'x.a' notation so it doesn't much matter.

      • When a program returns a reference, a pointer is returned. Unlike return by value, memory is not allocated to hold the return result.

      • SWIG has particular trouble handling various combinations of references and pointers. This is side effect of an old parsing scheme and type representation that will be replaced in future versions.

      swig-3.0.2/Examples/java/reference/Makefile0000664000175000017500000000107112343605122020437 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/native/0000775000175000017500000000000012343605122016330 5ustar williamwilliamswig-3.0.2/Examples/java/native/runme.java0000664000175000017500000000122112343605122020315 0ustar williamwilliam public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { SWIGTYPE_p_Point p = example.point_create(1, 2); System.out.println("auto wrapped : " + example.point_toString1(p)); System.out.println("manual wrapped: " + example.point_toString2(p)); example.free(new SWIGTYPE_p_void(SWIGTYPE_p_Point.getCPtr(p), false)); //clean up c allocated memory } } swig-3.0.2/Examples/java/native/example.i0000664000175000017500000000201612343605122020134 0ustar williamwilliam/* File : example.i */ %module example %{ #include typedef struct point { int x; int y; } Point; Point *point_create(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } static char *point_toString(char *format, Point *p) { static char buf[80]; sprintf(buf, format, p->x, p->y); return buf; } /* this function will be wrapped by SWIG */ char *point_toString1(Point *p) { return point_toString("(%d,%d)", p); } /* this one we wrapped manually*/ JNIEXPORT jstring JNICALL Java_exampleJNI_point_1toString2(JNIEnv *jenv, jclass jcls, jlong jpoint) { Point * p; jstring result; (void)jcls; p = *(Point **)&jpoint; result = (*jenv)->NewStringUTF(jenv, point_toString("[%d,%d]", p)); return result; } %} Point *point_create(int x, int y); char *point_toString1(Point *p); /* give access to free() for memory cleanup of the malloc'd Point */ extern void free(void *memblock); %native(point_toString2) char *point_toString2(Point *p); swig-3.0.2/Examples/java/native/index.html0000664000175000017500000000172112343605122020326 0ustar williamwilliam SWIG:Examples:java:native SWIG/Examples/java/native/

      SWIG wrapped and manually wrapped functions in Java

      Click here for the relevant section in the SWIG and Java documentation.

      This example compares wrapping a c global function using the manual way and the SWIG way.

      • example.i. Interface file comparing code wrapped by SWIG and wrapped manually.
      • runme.java. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions.

      Notes

      • SWIG writes all the awkward JNI code for you. You just have to tell SWIG which functions to wrap.
      • If memory is allocated in c it needs to be free'd. A function, such as free(), can be provided with access from Java to free the memory.

      swig-3.0.2/Examples/java/native/Makefile0000664000175000017500000000104312343605122017766 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/check.list0000664000175000017500000000022412343605122017012 0ustar williamwilliam# see top-level Makefile.in callback class constants enum extend funcptr multimap native nested pointer reference simple template typemap variables swig-3.0.2/Examples/java/index.html0000664000175000017500000000477512343605122017054 0ustar williamwilliam SWIG:Examples:java

      SWIG Java Examples

      The following examples illustrate the use of SWIG with Java.

      • simple. A minimal example showing how SWIG can be used to wrap a C function, a global variable, and a constant.
      • native. Comparing the manual and the SWIG approach to calling native code.
      • typemap. Modifying the Java module's default behaviour by using typemaps.
      • constants. This shows how preprocessor macros and certain C declarations are turned into constants.
      • variables. An example showing how to access C global variables.
      • enum. Wrapping enumerations.
      • class. How to wrap a simple C++ class.
      • reference. C++ references.
      • pointer. Simple pointer handling.
      • template. C++ templates.
      • funcptr. Pointers to functions.
      • callback. C++ callbacks using directors.
      • extend. Polymorphism using directors.

      Running the examples

      Please see the Windows page in the main manual for information on using the examples on Windows.

      On Unix most of the examples work by making the Makefile before executing the program runme.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac.

      Ensure that the dynamic link library file is in the appropriate path before executing the Java program. For example in Unix, libexample.so must be in the LD_LIBRARY_PATH.

      A Unix example:

      $ make
      $ export LD_LIBRARY_PATH=. #ksh 
      $ java runme
      

    Compatibility

    The examples have been extensively tested on the following platforms:
    • Solaris
    • Linux
    • Cygwin
    • Windows
    Your mileage may vary. If you experience a problem, please let us know by contacting us on the mailing lists. swig-3.0.2/Examples/java/funcptr/0000775000175000017500000000000012343605122016523 5ustar williamwilliamswig-3.0.2/Examples/java/funcptr/runme.java0000664000175000017500000000222612343605122020516 0ustar williamwilliam public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { int a = 37; int b = 42; // Now call our C function with a bunch of callbacks System.out.println( "Trying some C callback functions" ); System.out.println( " a = " + a ); System.out.println( " b = " + b ); System.out.println( " ADD(a,b) = " + example.do_op(a,b,example.ADD) ); System.out.println( " SUB(a,b) = " + example.do_op(a,b,example.SUB) ); System.out.println( " MUL(a,b) = " + example.do_op(a,b,example.MUL) ); System.out.println( "Here is what the C callback function classes are called in Java" ); System.out.println( " ADD = " + example.ADD.getClass().getName() ); System.out.println( " SUB = " + example.SUB.getClass().getName() ); System.out.println( " MUL = " + example.MUL.getClass().getName() ); } } swig-3.0.2/Examples/java/funcptr/example.c0000664000175000017500000000037012343605122020322 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/java/funcptr/example.h0000664000175000017500000000026312343605122020330 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/java/funcptr/example.i0000664000175000017500000000056012343605122020331 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); swig-3.0.2/Examples/java/funcptr/index.html0000664000175000017500000000377312343605122020532 0ustar williamwilliam SWIG:Examples:java:funcptr SWIG/Examples/java/funcptr/

    Pointers to Functions

    Okay, just what in the heck does SWIG do with a declaration like this?

    int do_op(int a, int b, int (*op)(int, int));
    
    Well, it creates a wrapper as usual. Of course, that does raise some questions about the third argument (the pointer to a function).

    In this case, SWIG will wrap the function pointer as it does for all other pointers. However, in order to actually call this function from a Java program, you will need to pass some kind of C function pointer object. In C, this is easy, you just supply a function name as an argument like this:

    /* Some callback function */
    int add(int a, int b) {
       return a+b;
    } 
    ...
    int r = do_op(x,y,add);
    
    To make this work with SWIG, you will need to do a little extra work. Specifically, you need to create some function pointer objects using the %constant directive like this:
    %constant(int (*)(int,int)) ADD = add;
    
    Now, in a Java program, you would do this:
    int r = do_op(x,y, example.ADD)
    
    where example is the module name.

    An Example

    Here are some files that illustrate this with a simple example:

    Notes

    • The value of a function pointer must correspond to a function written in C or C++. It is not possible to pass an arbitrary Java function in as a substitute for a C function pointer.

    • A Java function can be used as a C/C++ callback if you write some clever typemaps and are very careful about how you create your extension. This is an advanced topic not covered here.

    swig-3.0.2/Examples/java/funcptr/Makefile0000664000175000017500000000105512343605122020164 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/multimap/0000775000175000017500000000000012343605122016672 5ustar williamwilliamswig-3.0.2/Examples/java/multimap/runme.java0000664000175000017500000000160512343605122020665 0ustar williamwilliam public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Call our gcd() function int x = 42; int y = 105; int g = example.gcd(x,y); System.out.println("The gcd of " + x + " and " + y + " is " + g); // Call the gcdmain() function String[] args = {"gcdmain","42","105"}; example.gcdmain(args); // Call the count function System.out.println(example.count("Hello World", 'l')); // Call the capitalize function String[] capitalizeMe = {"hello world"}; example.capitalize(capitalizeMe); System.out.println(capitalizeMe[0]); } } swig-3.0.2/Examples/java/multimap/example.c0000664000175000017500000000164012343605122020472 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.2/Examples/java/multimap/example.i0000664000175000017500000000626612343605122020511 0ustar williamwilliam/* File : example.i */ %module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} extern int gcd(int x, int y); %typemap(jni) (int argc, char *argv[]) "jobjectArray" %typemap(jtype) (int argc, char *argv[]) "String[]" %typemap(jstype) (int argc, char *argv[]) "String[]" %typemap(javain) (int argc, char *argv[]) "$javainput" %typemap(in) (int argc, char *argv[]) (jstring *jsarray) { int i; $1 = (*jenv)->GetArrayLength(jenv, $input); if ($1 == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } $2 = (char **) malloc(($1+1)*sizeof(char *)); jsarray = (jstring *) malloc($1*sizeof(jstring)); for (i = 0; i < $1; i++) { jsarray[i] = (jstring) (*jenv)->GetObjectArrayElement(jenv, $input, i); $2[i] = (char *) (*jenv)->GetStringUTFChars(jenv, jsarray[i], 0); } $2[i] = 0; } %typemap(argout) (int argc, char *argv[]) "" /* override char *[] default */ %typemap(freearg) (int argc, char *argv[]) { int i; for (i = 0; i < $1; i++) { (*jenv)->ReleaseStringUTFChars(jenv, jsarray$argnum[i], $2[i]); } free($2); } extern int gcdmain(int argc, char *argv[]); %typemap(jni) (char *bytes, int len) "jstring" %typemap(jtype) (char *bytes, int len) "String" %typemap(jstype) (char *bytes, int len) "String" %typemap(javain) (char *bytes, int len) "$javainput" %typemap(in) (char *bytes, int len) { $1 = ($1_type)(*jenv)->GetStringUTFChars(jenv, $input, 0); $2 = (*jenv)->GetStringUTFLength(jenv, $input); } %typemap(freearg) (char *bytes, int len) %{ (*jenv)->ReleaseStringUTFChars(jenv, $input, $1); %} extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a c string. A one * element Java string array is used so that the string can be returned modified.*/ %typemap(jni) (char *str, int len) "jobjectArray" %typemap(jtype) (char *str, int len) "String[]" %typemap(jstype) (char *str, int len) "String[]" %typemap(javain) (char *str, int len) "$javainput" %typemap(in) (char *str, int len) (jstring js) { int index = 0; js = (jstring) (*jenv)->GetObjectArrayElement(jenv, $input, index); $1 = (char *) (*jenv)->GetStringUTFChars(jenv, js, 0); $2 = (*jenv)->GetStringUTFLength(jenv, js); } /* Return the mutated string as a modified element in the array. */ %typemap(argout) (char *str, int len) { jstring newstring = (*jenv)->NewStringUTF(jenv, $1); (*jenv)->SetObjectArrayElement(jenv, $input, 0, newstring); } /* Release memory */ %typemap(freearg) (char *str, int len) { (*jenv)->ReleaseStringUTFChars(jenv, js$argnum, $1); } extern void capitalize(char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "$1_name and $2_name must be in unit circle"); return; } } extern void circle(double cx, double cy); swig-3.0.2/Examples/java/multimap/example.dsp0000664000175000017500000001255712343605122021047 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Java compile post-build step PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java # End Special Build Tool !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll" # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Java compile post-build step PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java # End Special Build Tool !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on ..\..\..\swig.exe -java "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on ..\..\..\swig.exe -java "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/java/multimap/Makefile0000664000175000017500000000105512343605122020333 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/callback/0000775000175000017500000000000012343605122016576 5ustar williamwilliamswig-3.0.2/Examples/java/callback/runme.java0000664000175000017500000000265212343605122020574 0ustar williamwilliampublic class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String[] args) { System.out.println("Adding and calling a normal C++ callback"); System.out.println("----------------------------------------"); Caller caller = new Caller(); Callback callback = new Callback(); caller.setCallback(callback); caller.call(); caller.delCallback(); callback = new JavaCallback(); System.out.println(); System.out.println("Adding and calling a Java callback"); System.out.println("------------------------------------"); caller.setCallback(callback); caller.call(); caller.delCallback(); // Test that a double delete does not occur as the object has already been deleted from the C++ layer. // Note that the garbage collector can also call the delete() method via the finalizer (callback.finalize()) // at any point after here. callback.delete(); System.out.println(); System.out.println("java exit"); } } class JavaCallback extends Callback { public JavaCallback() { super(); } public void run() { System.out.println("JavaCallback.run()"); } } swig-3.0.2/Examples/java/callback/example.h0000664000175000017500000000102012343605122020373 0ustar williamwilliam/* File : example.h */ #include #include class Callback { public: virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } }; swig-3.0.2/Examples/java/callback/example.i0000664000175000017500000000031212343605122020377 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_string.i" /* turn on director wrapping Callback */ %feature("director") Callback; %include "example.h" swig-3.0.2/Examples/java/callback/example.cxx0000664000175000017500000000006012343605122020751 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.2/Examples/java/callback/index.html0000664000175000017500000000044712343605122020600 0ustar williamwilliam SWIG:Examples:java:callback SWIG/Examples/python/extend/

    Implementing C++ callbacks in Java

    This example illustrates how to use directors to implement C++ callbacks in Java.


    swig-3.0.2/Examples/java/callback/Makefile0000664000175000017500000000107112343605122020235 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/java/variables/0000775000175000017500000000000012343605122017012 5ustar williamwilliamswig-3.0.2/Examples/java/variables/runme.java0000664000175000017500000000734212343605122021011 0ustar williamwilliam// This example illustrates global variable access from Java. import java.lang.reflect.*; public class runme { static { try { System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Try to set the values of some global variables example.setIvar(42); example.setSvar((short)-31000); example.setLvar(65537); example.setUivar(123456); example.setUsvar(61000); example.setUlvar(654321); example.setScvar((byte)-13); example.setUcvar((short)251); example.setCvar('S'); example.setFvar((float)3.14159); example.setDvar(2.1828); example.setStrvar("Hello World"); example.setIptrvar(example.new_int(37)); example.setPtptr(example.new_Point(37,42)); example.setName("Bill"); // Now print out the values of the variables System.out.println( "Variables (values printed from Java)" ); System.out.println( "ivar =" + example.getIvar() ); System.out.println( "svar =" + example.getSvar() ); System.out.println( "lvar =" + example.getLvar() ); System.out.println( "uivar =" + example.getUivar() ); System.out.println( "usvar =" + example.getUsvar() ); System.out.println( "ulvar =" + example.getUlvar() ); System.out.println( "scvar =" + example.getScvar() ); System.out.println( "ucvar =" + example.getUcvar() ); System.out.println( "fvar =" + example.getFvar() ); System.out.println( "dvar =" + example.getDvar() ); System.out.println( "cvar =" + (char)example.getCvar() ); System.out.println( "strvar =" + example.getStrvar() ); System.out.println( "cstrvar =" + example.getCstrvar() ); System.out.println( "iptrvar =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(example.getIptrvar())) ); System.out.println( "name =" + example.getName() ); System.out.println( "ptptr =" + Long.toHexString(SWIGTYPE_p_Point.getCPtr(example.getPtptr())) + example.Point_print(example.getPtptr()) ); System.out.println( "pt =" + Long.toHexString(SWIGTYPE_p_Point.getCPtr(example.getPt())) + example.Point_print(example.getPt()) ); System.out.println( "\nVariables (values printed from C)" ); example.print_vars(); System.out.println( "\nNow I'm going to try and modify some read only variables" ); System.out.println( " Trying to set 'path'" ); try { Method m = example.class.getDeclaredMethod("setPath", new Class[] {String.class}); m.invoke(example.class, new Object[] {"Whoa!"} ); System.out.println( "Hey, what's going on?!?! This shouldn't work" ); } catch (NoSuchMethodException e) { System.out.println( "Good." ); } catch (Throwable t) { System.out.println( "You shouldn't see this!" ); } System.out.println( " Trying to set 'status'" ); try { Method m = example.class.getDeclaredMethod("setStatus", new Class[] {Integer.class}); m.invoke(example.class, new Object[] {new Integer(0)} ); System.out.println( "Hey, what's going on?!?! This shouldn't work" ); } catch (NoSuchMethodException e) { System.out.println( "Good." ); } catch (Throwable t) { System.out.println( "You shouldn't see this!" ); } System.out.println( "\nI'm going to try and update a structure variable.\n" ); example.setPt(example.getPtptr()); System.out.println( "The new value is" ); example.pt_print(); System.out.println( "You should see the value" + example.Point_print(example.getPtptr()) ); } } swig-3.0.2/Examples/java/variables/example.c0000664000175000017500000000456012343605122020616 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/java/variables/example.h0000664000175000017500000000007512343605122020620 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/java/variables/example.i0000664000175000017500000000174512343605122020626 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/java/variables/index.html0000664000175000017500000000564212343605122021016 0ustar williamwilliam SWIG:Examples:java:variables SWIG/Examples/java/variables/

    Wrapping C Global Variables

    When a C global variable appears in an interface file, SWIG tries to wrap it using a technique known as "variable linking." The idea is pretty simple---we try to create a Java variable that magically retrieves or updates the value of the underlying C variable when it is accessed. Click here to see a SWIG interface with some variable declarations in it.

    Click here for the section on global variables in the SWIG and Java documentation.

    Manipulating Variables from Java

    C variables are accessed through getters and setters from Java. Unfortunately this is the only way to get current values from variables because it is not possible to overload the dot operator in Java. All global variables are accessible from the module class. For example if the module class is called 'example', the global variable
    double foo;
    
    will be accessed in the Java module as
    example.get_foo();
    example.set_foo(12.3);
    
    Click here to see the example program that updates and prints out the values of the variables using this technique.

    Key points

    • When a global variable has the type "char *", SWIG manages it as a character string. However, whenever the value of such a variable is set from Java, the old value is destroyed using free() or delete (the choice of which depends on whether or not SWIG was run with the -c++ option).
    • signed char and unsigned char are handled as small 8-bit integers.
    • String array variables such as 'char name[256]' are managed as Java strings, but when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
    • When structures and classes are used as global variables, they are mapped into pointers. Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global.

    Creating read-only variables

    The %immutable and %mutable directives can be used to specify a collection of read-only variables. For example:
    %immutable;
    int    status;
    double blah;
    ...
    %mutable;
    
    The %immutable directive remains in effect until it is explicitly disabled using the %mutable directive.

    Comments

    • Management of global variables is one of the most problematic aspects of C/C++ wrapping because the Java interface and resulting memory management is much trickier than simply creating a wrapper function.

    swig-3.0.2/Examples/java/variables/Makefile0000664000175000017500000000105512343605122020453 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean swig-3.0.2/Examples/Makefile.in0000664000175000017500000022052312343605122016172 0ustar williamwilliam# ------------------------------------------------------------ # SWIG Examples Makefile # # This file is used by the examples to build modules. Assuming # you ran configure, this file will probably work. However, # it's not perfect so you might need to do some hand tweaking. # # Other notes: # # 1. Take a look at the prefixes below. Since SWIG works with # multiple target languages, you may need to find out where # certain packages have been installed. Set the prefixes # accordingly. # # 2. To use this makefile, set required variables, eg SRCS, INTERFACE, # INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a # $(MAKE) -f Makefile.template.in SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ # INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \ # INTERFACEDIR='$(INTERFACEDIR)' TARGET='$(TARGET)' method # # 'method' describes what is being built. #--------------------------------------------------------------- # Regenerate Makefile if Makefile.in or config.status have changed. Makefile: @srcdir@/Makefile.in ../config.status cd .. && $(SHELL) ./config.status Examples/Makefile # SRCDIR is the relative path to the current source directory # - For in-source-tree builds, SRCDIR with be either '' or './', but # '../' for the test suites that build in a subdir (e.g. C#, Java) # - For out-of-source-tree builds, SRCDIR will be a relative # path ending with a '/' # SRCDIR_SRCS, etc. are $(SRCS), etc. with $(SRCDIR) prepended SRCDIR_SRCS = $(addprefix $(SRCDIR),$(SRCS)) SRCDIR_CSRCS = $(addprefix $(SRCDIR),$(CSRCS)) SRCDIR_CXXSRCS = $(addprefix $(SRCDIR),$(CXXSRCS)) ifeq (,$(SRCDIR)) SRCDIR_INCLUDE = -I. else SRCDIR_INCLUDE = -I. -I$(SRCDIR) endif TARGET = CC = @CC@ CXX = @CXX@ CPPFLAGS = $(SRCDIR_INCLUDE) CFLAGS = @PLATCFLAGS@ CXXFLAGS = @BOOST_CPPFLAGS@ @PLATCXXFLAGS@ LDFLAGS = prefix = @prefix@ exec_prefix= @exec_prefix@ SRCS = INCLUDES = LIBS = INTERFACE = INTERFACEDIR = INTERFACEPATH = $(SRCDIR)$(INTERFACEDIR)$(INTERFACE) SWIGOPT = SWIG = swig LIBM = @LIBM@ LIBC = @LIBC@ LIBCRYPT = @LIBCRYPT@ SYSLIBS = $(LIBM) $(LIBC) $(LIBCRYPT) LIBPREFIX = # RUNTOOL is for use with runtime tools, eg set it to valgrind RUNTOOL = # COMPILETOOL is a way to run the compiler under another tool, or more commonly just to stop the compiler executing COMPILETOOL= # RUNPIPE is for piping output of running interpreter/compiled code somewhere, eg RUNPIPE=\>/dev/null RUNPIPE= RUNME = runme IWRAP = $(INTERFACE:.i=_wrap.i) ISRCS = $(IWRAP:.i=.c) ICXXSRCS = $(IWRAP:.i=.cxx) IOBJS = $(IWRAP:.i=.@OBJEXT@) ################################################################## # Some options for silent output ################################################################## ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS)))) # make -s detected SILENT=1 else SILENT= endif ifneq (,$(SILENT)) SILENT_OPTION = -s SILENT_PIPE = >/dev/null ANT_QUIET = -q -logfile /dev/null else SILENT_OPTION = SILENT_PIPE = ANT_QUIET = endif ################################################################## # Dynamic loading for C++ # If you are going to be building dynamic loadable modules in C++, # you may need to edit this line appropriately. # # This line works for g++, but I'm not sure what it might be # for other C++ compilers ################################################################## CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc # Solaris workshop 5.0 # CPP_DLLIBS = -L/opt/SUNWspro/lib -lCrun # Symbols used for using shared libraries SO= @SO@ LDSHARED= @LDSHARED@ CCSHARED= @CCSHARED@ CXXSHARED= @CXXSHARED@ # This is used for building shared libraries with a number of C++ # compilers. If it doesn't work, comment it out. @TRYLINKINGWITHCXX@ OBJS = $(SRCS:.c=.@OBJEXT@) $(CXXSRCS:.cxx=.@OBJEXT@) distclean: rm -f Makefile rm -f xml/Makefile ################################################################## ##### Tcl/Tk ###### ################################################################## # Set these to your local copy of Tcl/Tk. TCLSH = tclsh TCL_INCLUDE = @TCLINCLUDE@ TCL_LIB = @TCLLIB@ TCL_OPTS = @LIBS@ TK_OPTS = -ltk -ltcl @LIBS@ # Extra Tcl specific dynamic linking options TCL_DLNK = @TCLDYNAMICLINKING@ TCL_SO = @TCL_SO@ TCLLDSHARED = @TCLLDSHARED@ TCLCXXSHARED = @TCLCXXSHARED@ TCL_SCRIPT = $(SRCDIR)$(RUNME).tcl # ----------------------------------------------------------- # Build a new version of the tclsh shell # ----------------------------------------------------------- tclsh: $(SRCDIR_SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i -o $(ISRCS) $(INTERFACEPATH) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) tclsh_cpp: $(SRCDIR_SRCS) $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) # ----------------------------------------------------------- # Build a Tcl dynamic loadable module (you might need to tweak this) # ----------------------------------------------------------- tcl: $(SRCDIR_SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLLDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------- # Build a Tcl7.5 dynamic loadable module for C++ # ----------------------------------------------------------- tcl_cpp: $(SRCDIR_SRCS) $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLCXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------------- # Run Tcl example # ----------------------------------------------------------------- tcl_run: $(RUNTOOL) $(TCLSH) $(TCL_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- tcl_version: echo 'puts $$tcl_version;exit 0' | $(TCLSH) # ----------------------------------------------------------------- # Cleaning the Tcl examples # ----------------------------------------------------------------- tcl_clean: rm -f *_wrap* *~ .~* mytclsh@EXEEXT@ rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *$(TCL_SO) ################################################################## ##### PERL 5 ###### ################################################################## # You need to set this variable to the Perl5 directory containing the # files "perl.h", "EXTERN.h" and "XSUB.h". With Perl5.003, it's # usually something like /usr/local/lib/perl5/arch-osname/5.003/CORE. PERL5_INCLUDE= @PERL5EXT@ # Extra Perl specific dynamic linking options PERL5_DLNK = @PERL5DYNAMICLINKING@ PERL5_CCFLAGS = @PERL5CCFLAGS@ PERL5_CCDLFLAGS = @PERL5CCDLFLAGS@ PERL5_CCCDLFLAGS = @PERL5CCCDLFLAGS@ PERL5_LDFLAGS = @PERL5LDFLAGS@ PERL = @PERL@ PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) PERL5_SCRIPT = $(SRCDIR)$(RUNME).pl # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C) # ---------------------------------------------------------------- perl5: $(SRCDIR_SRCS) $(SWIG) -perl5 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c -Dbool=char $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C++) # ---------------------------------------------------------------- perl5_cpp: $(SRCDIR_SRCS) $(SWIG) -perl5 -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a module from existing XS C source code. (ie. from xsubpp). # ---------------------------------------------------------------- perl5_xs: $(SRCDIR_SRCS) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $(TARGET)$(SO) # ---------------------------------------------------------------- # Build a statically linked Perl5 executable # ---------------------------------------------------------------- perl5_static: $(SRCDIR_SRCS) $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Dbool=char $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) perl5_static_cpp: $(SRCDIR_SRCS) $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) # ----------------------------------------------------------------- # Running a Perl5 example # ----------------------------------------------------------------- perl5_run: $(RUNTOOL) $(PERL) $(PERL5_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- perl5_version: $(PERL) -v | grep "This is" # ----------------------------------------------------------------- # Cleaning the Perl5 examples # ----------------------------------------------------------------- perl5_clean: rm -f *_wrap* *~ .~* myperl@EXEEXT@ *.pm rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ ################################################################## ##### PYTHON ###### ################################################################## PYTHON_FLAGS = # Make sure these locate your Python installation ifeq (,$(PY3)) PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ PYTHON_LIB = @PYLIB@ PYTHON = @PYTHON@ $(PYTHON_FLAGS) else PYTHON_INCLUDE= $(DEFS) @PY3INCLUDE@ PYTHON_LIB = @PY3LIB@ PYTHON = @PYTHON3@ $(PYTHON_FLAGS) endif # Extra Python specific linking options ifeq (,$(PY3)) PYTHON_DLNK = @PYTHONDYNAMICLINKING@ PYTHON_LINK = @PYLINK@ else PYTHON_DLNK = @PYTHON3DYNAMICLINKING@ PYTHON_LINK = @PY3LINK@ endif PYTHON_SO = @PYTHON_SO@ # SWIG option for Python ifeq (,$(PY3)) SWIGPYTHON = $(SWIG) -python else SWIGPYTHON = $(SWIG) -python -py3 endif # ---------------------------------------------------------------- # Build a C dynamically loadable module # ---------------------------------------------------------------- python: $(SRCDIR_SRCS) $(SWIGPYTHON) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- python_cpp: $(SRCDIR_SRCS) $(SWIGPYTHON) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) # ----------------------------------------------------------------- # Build statically linked Python interpreter # # These should only be used in conjunction with the %include embed.i # library file # ----------------------------------------------------------------- #TKINTER = -L/usr/X11R6.3/lib -L/usr/local/compat/lib -ltk4.0 -ltcl7.4 -lX11 TKINTER = PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS) python_static: $(SRCDIR_SRCS) $(SWIGPYTHON) -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) python_static_cpp: $(SRCDIR_SRCS) $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) # ----------------------------------------------------------------- # Running a Python example # ----------------------------------------------------------------- ifeq (,$(PY3)) PYSCRIPT = $(RUNME).py else PYSCRIPT = $(RUNME)3.py 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 (,$(SRCDIR)) $(RUNME).py: $(SRCDIR)$(RUNME).py cp $< $@ endif $(RUNME)3.py: $(SRCDIR)$(RUNME).py cp $< $@ $(PY2TO3) -w $@ >/dev/null 2>&1 # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- python_version: $(PYTHON) -V # ----------------------------------------------------------------- # Cleaning the python examples # ----------------------------------------------------------------- python_clean: rm -rf __pycache__ rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *$(PYTHON_SO) rm -f $(TARGET).py if test -f $(SRCDIR)$(RUNME).py; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi case "x$(SRCDIR)" in x|x./);; *) rm -f $(RUNME).py;; esac ################################################################## ##### OCTAVE ###### ################################################################## # Make sure these locate your Octave installation OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@ OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@ # Extra Octave specific dynamic linking options OCTAVE_DLNK = @OCTAVE_LDFLAGS@ OCTAVE_SO = @OCTAVE_SO@ OCTAVE_SCRIPT = $(SRCDIR)$(RUNME).m # ---------------------------------------------------------------- # Build a C dynamically loadable module # Note: Octave requires C++ compiler when compiling C wrappers # ---------------------------------------------------------------- octave: $(SRCDIR_SRCS) $(SWIG) -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX) $(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- octave_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX) $(CXXSHARED) -g $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) # ----------------------------------------------------------------- # Running an Octave example # ----------------------------------------------------------------- octave_run: $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- octave_version: $(OCTAVE) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the Octave examples # ----------------------------------------------------------------- octave_clean: rm -rf __pycache__ rm -f *_wrap* *~ .~* myoctave@EXEEXT@ *.pyc rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *$(OCTAVE_SO) ################################################################## ##### GUILE ###### ################################################################## # Make sure these locate your Guile installation GUILE = @GUILE@ GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_SO = @GUILE_SO@ GUILE_LIBS = @GUILE_LIBS@ GUILE_LIBOPTS = @LIBS@ $(SYSLIBS) GUILE_LIBPREFIX = lib GUILE_SCRIPT = $(SRCDIR)$(RUNME).scm #------------------------------------------------------------------ # Build a dynamically loaded module with passive linkage #------------------------------------------------------------------ guile: $(SRCDIR_SRCS) $(SWIG) -guile -Linkage passive $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCDIR_SRCS) $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@ guile_externalhdr: $(SWIG) -guile -external-runtime $(TARGET) # ----------------------------------------------------------------- # Build Guile interpreter augmented with extra functions # ----------------------------------------------------------------- guile_augmented: $(SRCDIR_SRCS) $(SWIG) -guile $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET) # ----------------------------------------------------------------- # Build statically linked Guile interpreter # ----------------------------------------------------------------- guile_static: $(SRCDIR_SRCS) $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_static_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple: $(SRCDIR_SRCS) $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \ $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \ $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile # ----------------------------------------------------------------- # Running a Guile example # ----------------------------------------------------------------- guile_run: env GUILE_AUTO_COMPILE=0 $(RUNTOOL) $(GUILE) -l $(GUILE_SCRIPT) $(RUNPIPE) guile_augmented_run: env GUILE_AUTO_COMPILE=0 $(RUNTOOL) ./$(TARGET) $(GUILE_RUNOPTIONS) -s $(GUILE_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- guile_version: $(GUILE) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the Guile examples # ----------------------------------------------------------------- guile_clean: rm -f *_wrap* *~ .~* my-guile@EXEEXT@ $(TARGET)@EXEEXT@ rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *$(GUILE_SO) ################################################################## ##### JAVA ###### ################################################################## # You need to set this variable to the java directories containing the # files "jni.h" and "md.h" # usually something like /usr/java/include and /usr/java/include/. JAVA_INCLUDE= @JAVAINC@ # Extra Java specific dynamic linking options JAVA_DLNK = @JAVADYNAMICLINKING@ JAVA_LIBPREFIX = @JAVALIBRARYPREFIX@ JAVASO =@JAVASO@ JAVALDSHARED = @JAVALDSHARED@ JAVACXXSHARED = @JAVACXXSHARED@ JAVACFLAGS = @JAVACFLAGS@ JAVA = @JAVA@ JAVAC = @JAVAC@ -d . # ---------------------------------------------------------------- # Build a java dynamically loadable module (C) # ---------------------------------------------------------------- java: $(SRCDIR_SRCS) $(SWIG) -java $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(JAVACFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVALDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) # ---------------------------------------------------------------- # Build a java dynamically loadable module (C++) # ---------------------------------------------------------------- java_cpp: $(SRCDIR_SRCS) $(SWIG) -java -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(JAVACFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVACXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) # ---------------------------------------------------------------- # Compile java files # ---------------------------------------------------------------- java_compile: $(SRCDIR_SRCS) $(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(addprefix $(SRCDIR),$(JAVASRCS)) # ----------------------------------------------------------------- # Run java example # ----------------------------------------------------------------- java_run: env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- java_version: $(JAVA) -version $(JAVAC) -version || echo "Unknown javac version" # ----------------------------------------------------------------- # Cleaning the java examples # ----------------------------------------------------------------- java_clean: rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v $(RUNME).java` rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@JAVASO@ ################################################################## ##### JAVASCRIPT ###### ################################################################## # Note: These targets are also from within Makefiles in the Example directories. # There is a common makefile, 'Examples/javascript/js_example.mk' to simplify # create a configuration for a new example. ROOT_DIR = @ROOT_DIR@ JSINCLUDES = @JSCOREINC@ @JSV8INC@ JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@ JSSO =@JSSO@ JSLDSHARED = @JSLDSHARED@ JSCXXSHARED = @JSCXXSHARED@ NODEJS = @NODEJS@ NODEGYP = @NODEGYP@ # ---------------------------------------------------------------- # Creating and building Javascript wrappers # ---------------------------------------------------------------- javascript_wrapper: $(SWIG) -javascript $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH) javascript_wrapper_cpp: $(SRCDIR_SRCS) $(SWIG) -javascript -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cxx $(INTERFACEPATH) javascript_build: $(SRCDIR_SRCS) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(JSINCLUDES) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) javascript_build_cpp: $(SRCDIR_SRCS) ifeq (node,$(JSENGINE)) sed -e 's|$$srcdir|./$(SRCDIR)|g' $(SRCDIR)binding.gyp.in > binding.gyp $(NODEGYP) --loglevel=silent configure build 1>>/dev/null else $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) endif # These targets are used by the test-suite: javascript: $(SRCDIR_SRCS) javascript_custom_interpreter $(SWIG) -javascript $(SWIGOPT) $(INTERFACEPATH) ifeq (jsc, $(ENGINE)) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(JSINCLUDES) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) else # (v8 | node) # v8 and node must be compiled as c++ $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) endif javascript_cpp: $(SRCDIR_SRCS) javascript_custom_interpreter $(SWIG) -javascript -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ----------------------------------------------------------------- # Running a Javascript example # ----------------------------------------------------------------- javascript_custom_interpreter: (cd $(ROOT_DIR)/Tools/javascript && $(MAKE) JSENGINE='$(JSENGINE)') ifeq (node,$(JSENGINE)) javascript_run: env NODE_PATH=$$PWD:$(SRCDIR) $(RUNTOOL) $(NODEJS) $(SRCDIR)$(RUNME).js $(RUNPIPE) else javascript_run: javascript_custom_interpreter $(RUNTOOL) $(ROOT_DIR)/Tools/javascript/javascript -$(JSENGINE) -L $(TARGET) $(SRCDIR)$(RUNME).js $(RUNPIPE) endif # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- javascript_version: ifeq (, $(ENGINE)) @if [ "$(NODEJS)" != "" ]; then \ echo "Node.js: `($(NODEJS) --version)`"; \ echo "node-gyp: `($(NODEGYP) --version)`"; \ else \ echo "Version depends on the interpreter"; \ fi endif ifeq (node, $(ENGINE)) echo "Node.js: `($(NODEJS) --version)`" echo "node-gyp: `($(NODEGYP) --version)`" endif ifeq (jsc, $(ENGINE)) @if [ "@JSCOREVERSION@" != "" ]; then \ echo "@JSCOREVERSION@"; \ else \ echo "Unknown JavascriptCore version."; \ fi endif ifeq (v8, $(ENGINE)) echo "Unknown v8 version." endif # ----------------------------------------------------------------- # Cleaning the Javascript examples # ----------------------------------------------------------------- javascript_clean: rm -rf build rm -f *_wrap* $(RUNME) rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@JSSO@ *.$(SO) rm -f binding.gyp example-gypcopy.cxx cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean ################################################################## ##### ANDROID ###### ################################################################## ANDROID = android ANDROID_NDK_BUILD = ndk-build ANDROID_ADB = adb ANT = ant TARGETID = 1 # ---------------------------------------------------------------- # Build an Android dynamically loadable module (C) # ---------------------------------------------------------------- android: $(SRCDIR_SRCS) $(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path . $(SWIG) -java $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH) +$(ANDROID_NDK_BUILD) $(SILENT_PIPE) $(ANT) $(ANT_QUIET) debug # ---------------------------------------------------------------- # Build an Android dynamically loadable module (C++) # ---------------------------------------------------------------- android_cpp: $(SRCDIR_SRCS) $(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path . $(SWIG) -java -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cpp $(INTERFACEPATH) +$(ANDROID_NDK_BUILD) $(SILENT_PIPE) $(ANT) $(ANT_QUIET) debug # ---------------------------------------------------------------- # Android install # ---------------------------------------------------------------- android_install: -$(ANDROID_ADB) uninstall $(PACKAGENAME) $(ANDROID_ADB) install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- android_version: $(ANDROID_ADB) version # ----------------------------------------------------------------- # Cleaning the Android examples # ----------------------------------------------------------------- android_clean: test -n "$(SRCDIR)" && cd $(SRCDIR) ; ant -q -logfile /dev/null clean rm -f $(INTERFACEDIR)$(TARGET)_wrap.* rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` rm -rf obj ################################################################## ##### MODULA3 ###### ################################################################## MODULA3_INCLUDE= @MODULA3INC@ # ---------------------------------------------------------------- # Build a modula3 dynamically loadable module (C) # ---------------------------------------------------------------- modula3: $(SRCDIR_SRCS) $(SWIG) -modula3 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) modula3_cpp: $(SRCDIR_SRCS) $(SWIG) -modula3 -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) # ----------------------------------------------------------------- # Run modula3 example # ----------------------------------------------------------------- modula3_run: $(RUNTOOL) false $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- modula3_version: echo "Unknown modula3 version" # ----------------------------------------------------------------- # Cleaning the modula3 examples # ----------------------------------------------------------------- modula3_clean: rm -f *_wrap* *.i3 *.m3 rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ ################################################################## ##### MZSCHEME ###### ################################################################## MZSCHEME = mzscheme MZC = @MZC@ MZDYNOBJ = @MZDYNOBJ@ MZSCHEME_SO = @MZSCHEME_SO@ MZSCHEME_SCRIPT = $(RUNME).scm # ---------------------------------------------------------------- # Build a C/C++ dynamically loadable module # ---------------------------------------------------------------- mzscheme: $(SRCDIR_SRCS) $(SWIG) -mzscheme $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCDIR_SRCS) $(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) mzscheme_cpp: $(SRCDIR_SRCS) $(SWIG) -mzscheme -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) # ----------------------------------------------------------------- # Run mzscheme example # ----------------------------------------------------------------- mzscheme_run: env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- mzscheme_version: $(MZSCHEME) -v $(MZC) -v # ----------------------------------------------------------------- # Cleaning the mzscheme examples # ----------------------------------------------------------------- mzscheme_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *$(MZSCHEME_SO) ################################################################## ##### Ocaml ##### ################################################################## OCC=@OCAMLC@ OCAMLDLGEN=@OCAMLDLGEN@ OCAMLFIND=@OCAMLFIND@ OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE) NOLINK ?= false OCAMLPP= -pp "camlp4o ./swigp4.cmo" OCAMLP4WHERE=`$(COMPILETOOL) camlp4 -where` OCAMLCORE=\ rm -rf swig.mli swig.ml swigp4.ml && \ $(SWIG) -ocaml -co swig.mli 2>/dev/null && \ $(SWIG) -ocaml -co swig.ml 2>/dev/null && \ $(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \ $(OCC) -c swig.mli && \ $(OCC) -c swig.ml && \ $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" \ -c swigp4.ml ocaml_static: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \ $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) \ swig.cmo \ $(INTERFACE:%.i=%.cmo) \ $(PROGFILE:%.ml=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" ocaml_dynamic: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS) $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(CCSHARED) -o $(INTERFACE:%.i=%@SO@) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS) $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \ $(INTERFACE:%.i=%_dynamic.ml) mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml) rm $(INTERFACE:%.i=%.mli) $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \ $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLFIND) \ $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) \ swig.cmo \ -package dl -linkpkg \ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) ocaml_static_toplevel: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \ $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) \ swig.cmo \ -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \ $(INTERFACE:%.i=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" ocaml_static_cpp: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \ $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) \ swig.cmo \ $(INTERFACE:%.i=%.cmo) \ $(PROGFILE:%.ml=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \ -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' ocaml_static_cpp_toplevel: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \ $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) \ swig.cmo \ -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo \ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \ $(INTERFACE:%.i=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \ -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' ocaml_dynamic_cpp: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) -ccopt -fPIC $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(INTERFACE:%.i=%@SO@) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \ $(CPP_DLLIBS) $(LIBS) $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \ $(INTERFACE:%.i=%_dynamic.ml) mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml) rm $(INTERFACE:%.i=%.mli) $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \ $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLFIND) \ swig.cmo \ $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom \ -o $(TARGET) \ -package dl -linkpkg \ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings' # ----------------------------------------------------------------- # Run ocaml example # ----------------------------------------------------------------- ocaml_run: $(RUNTOOL) ./$(TARGET) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- ocaml_version: $(OCC) -version # ----------------------------------------------------------------- # Cleaning the Ocaml examples # ----------------------------------------------------------------- ocaml_clean: rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ ################################################################## ##### RUBY ###### ################################################################## # Make sure these locate your Ruby installation RUBY_CFLAGS= @RUBYCCDLFLAGS@ $(DEFS) RUBY_INCLUDE= @RUBYINCLUDE@ RUBY_LIB = @RUBYLIB@ RUBY_DLNK = @RUBYDYNAMICLINKING@ RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) RUBY_SO = @RUBYSO@ RUBY = @RUBY@ RUBY_SCRIPT = $(SRCDIR)$(RUNME).rb # ---------------------------------------------------------------- # Build a C dynamically loadable module # ---------------------------------------------------------------- ruby: $(SRCDIR_SRCS) $(SWIG) -ruby $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(RUBY_INCLUDE) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- ruby_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -ruby $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO) # ----------------------------------------------------------------- # Build statically linked Ruby interpreter # # These should only be used in conjunction with the %include embed.i # library file # ----------------------------------------------------------------- ruby_static: $(SRCDIR_SRCS) $(SWIG) -ruby -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) ruby_cpp_static: $(SRCDIR_SRCS) $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) # ----------------------------------------------------------------- # Run Ruby example # ----------------------------------------------------------------- ruby_run: $(RUNTOOL) $(RUBY) -I. $(RUBY_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- ruby_version: $(RUBY) -v # ----------------------------------------------------------------- # Cleaning the Ruby examples # ----------------------------------------------------------------- ruby_clean: rm -f *_wrap* *~ .~* myruby@EXEEXT@ *.pm rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *$(RUBY_SO) ################################################################## ##### PHP ###### ################################################################## PHP = @PHP@ PHP_INCLUDE = @PHPINC@ PHP_SO = @PHP_SO@ PHP_SCRIPT = $(SRCDIR)$(RUNME).php # ------------------------------------------------------------------- # Build a PHP dynamically loadable module (C) # ------------------------------------------------------------------- php: $(SRCDIR_SRCS) $(SWIG) -php $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO) # -------------------------------------------------------------------- # Build a PHP dynamically loadable module (C++) # -------------------------------------------------------------------- php_cpp: $(SRCDIR_SRCS) $(SWIG) -php -cppext cxx -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO) # ----------------------------------------------------------------- # Running a PHP example # ----------------------------------------------------------------- php_run: $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHP_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- php_version: $(PHP) -v | head -n 1 # ----------------------------------------------------------------- # Cleaning the PHP examples # ----------------------------------------------------------------- php_clean: rm -f *_wrap* *~ .~* example.php php_example.h rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *$(PHP_SO) ################################################################## ##### Pike ###### ################################################################## # Make sure these locate your Pike installation PIKE = pike PIKE_CFLAGS = @PIKECCDLFLAGS@ -DHAVE_CONFIG_H PIKE_INCLUDE = @PIKEINCLUDE@ PIKE_LIB = @PIKELIB@ PIKE_DLNK = @PIKEDYNAMICLINKING@ PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) PIKE_SCRIPT = $(RUNME).pike # ---------------------------------------------------------------- # Build a C dynamically loadable module # ---------------------------------------------------------------- pike: $(SRCDIR_SRCS) $(SWIG) -pike $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PIKE_INCLUDE) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- pike_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -pike $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ----------------------------------------------------------------- # Build statically linked Pike interpreter # # These should only be used in conjunction with the %include embed.i # library file # ----------------------------------------------------------------- pike_static: $(SRCDIR_SRCS) $(SWIG) -pike -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) pike_cpp_static: $(SRCDIR_SRCS) $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) # ----------------------------------------------------------------- # Run pike example # ----------------------------------------------------------------- pike_run: $(RUNTOOL) $(PIKE) $(PIKE_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- pike_version: $(PIKE) -v 2>&1 | head -n 1 # ----------------------------------------------------------------- # Cleaning the Pike examples # ----------------------------------------------------------------- pike_clean: rm -f *_wrap* *~ .~* mypike@EXEEXT@ rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ ################################################################## ##### Chicken ###### ################################################################## CHICKEN = @CHICKEN@ CHICKEN_CSC = @CHICKEN_CSC@ CHICKEN_CSI = @CHICKEN_CSI@ CHICKEN_LIBOPTS = @CHICKENLIB@ $(SYSLIBS) CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS) CHICKEN_CFLAGS = @CHICKENOPTS@ CHICKENOPTS = -quiet CHICKEN_MAIN = CHICKEN_SCRIPT = $(RUNME).scm # SWIG produces $(ISRCS) (the C wrapper file) # and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file): CHICKEN_GENERATED_SCHEME = $(INTERFACE:.i=.scm) CHICKEN_COMPILED_SCHEME = $(INTERFACE:.i=_chicken.c) CHICKEN_COMPILED_OBJECT = $(CHICKEN_COMPILED_SCHEME:.c=.@OBJEXT@) # flags for the main chicken sources (only used when compiling statically) CHICKEN_COMPILED_MAIN = $(CHICKEN_MAIN:.scm=_chicken.c) CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@) # ----------------------------------------------------------------- # Build a CHICKEN dynamically loadable module # ----------------------------------------------------------------- # This is the old way to build chicken, but it does not work correctly with exceptions chicken_direct: $(SRCDIR_SRCS) $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -dynamic -feature chicken-compile-shared \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CHICKEN_CFLAGS) \ $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCDIR_SRCS) $(CHICKEN_COMPILED_SCHEME) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \ $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO) chicken_direct_cpp: $(SRCDIR_CXXSRCS) $(CHICKSRCS) $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -dynamic -feature chicken-compile-shared \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CHICKEN_CFLAGS) \ $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(CHICKEN_COMPILED_SCHEME) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \ $(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO) # ----------------------------------------------------------------- # Build statically linked CHICKEN interpreter # ----------------------------------------------------------------- # The following two targets are also used by the test suite chicken_static: $(SRCDIR_SRCS) $(CHICKSRCS) $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ -output-file $(CHICKEN_MAIN:.scm=_chicken.c) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CHICKEN_CFLAGS) \ $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCDIR_SRCS) \ $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN) $(CC) $(CFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \ $(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET) chicken_static_cpp: $(SRCDIR_CXXSRCS) $(CHICKSRCS) $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ -output-file $(CHICKEN_MAIN:.scm=_chicken.c) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CHICKEN_CFLAGS) \ $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) \ $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN) $(CXX) $(CXXFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \ $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET) # ---------------------------------------------------------------- # Build a shared library using csc # ---------------------------------------------------------------- chicken: $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCDIR_SRCS) $(ISRCS) -o $(TARGET)$(SO) chicken_cpp: $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCDIR_SRCS) $(ICXXSRCS) $(SRCDIR_CXXSRCS) -o $(TARGET)$(SO) chicken_externalhdr: $(SWIG) -chicken -external-runtime $(TARGET) # ----------------------------------------------------------------- # Run CHICKEN example # ----------------------------------------------------------------- chicken_run: env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- chicken_version: $(CHICKEN) -version | grep -i version # ----------------------------------------------------------------- # Cleaning the CHICKEN examples # ----------------------------------------------------------------- chicken_clean: rm -f *_wrap* *~ .~* *_chicken* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ ################################################################## ##### CSHARP ###### ################################################################## # Extra CSharp specific dynamic linking options CSHARP_DLNK = @CSHARPDYNAMICLINKING@ CSHARP_LIBPREFIX = @CSHARPLIBRARYPREFIX@ CSHARPCOMPILER = @CSHARPCOMPILER@ CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@ CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@ CSHARPCFLAGS = @CSHARPCFLAGS@ CSHARPSO = @CSHARPSO@ CSHARP_RUNME = $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$(RUNME).exe # ---------------------------------------------------------------- # Build a CSharp dynamically loadable module (C) # ---------------------------------------------------------------- csharp: $(SRCDIR_SRCS) $(SWIG) -csharp $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CSHARPCFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) # ---------------------------------------------------------------- # Build a CSharp dynamically loadable module (C++) # ---------------------------------------------------------------- csharp_cpp: $(SRCDIR_SRCS) $(SWIG) -csharp -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CSHARPCFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) # ---------------------------------------------------------------- # Compile CSharp files # ---------------------------------------------------------------- ifneq (,$(SRCDIR)) SRCDIR_CSHARPSRCS = $(addprefix $(SRCDIR),$(CSHARPSRCS)) else SRCDIR_CSHARPSRCS = endif csharp_compile: $(SRCDIR_SRCS) $(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS) $(SRCDIR_CSHARPSRCS) # ----------------------------------------------------------------- # Run CSharp example # ----------------------------------------------------------------- csharp_run: env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CSHARP_RUNME) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- # Version check below also works with MS csc.exe which does not understand --version csharp_version: $(CSHARPCOMPILER) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the CSharp examples # ----------------------------------------------------------------- csharp_clean: rm -f *_wrap* *~ .~* $(RUNME) $(RUNME).exe *.exe.mdb gc.log `find . -name \*.cs | grep -v $(RUNME).cs` rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@CSHARPSO@ ################################################################## ##### LUA ###### ################################################################## # lua flags LUA_INCLUDE= @LUAFLAGS@ LUA_LIB = @LUALINK@ # Extra specific dynamic linking options LUA_DLNK = @LUADYNAMICLINKING@ LUA_SO = @LUA_SO@ LUA = @LUABIN@ LUA_SCRIPT = $(SRCDIR)$(RUNME).lua # Extra code for lua static link LUA_INTERP = ../lua.c # ---------------------------------------------------------------- # Build a C dynamically loadable module # ---------------------------------------------------------------- lua: $(SRCDIR_SRCS) $(SWIG) -lua $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(LUA_INCLUDE) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- lua_cpp: $(SRCDIR_SRCS) $(GENCXXSRCS) $(SWIG) -c++ -lua $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(GENCXXSRCS) $(INCLUDES) $(LUA_INCLUDE) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) # ----------------------------------------------------------------- # Build statically linked Lua interpreter # ----------------------------------------------------------------- lua_static: $(SRCDIR_SRCS) $(SWIG) -lua -module example $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR)$(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) lua_static_cpp: $(SRCDIR_SRCS) $(GENCXXSRCS) $(SWIG) -c++ -lua -module example $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(GENCXXSRCS) $(SRCDIR)$(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) # ----------------------------------------------------------------- # Run Lua example # ----------------------------------------------------------------- lua_run: $(RUNTOOL) $(LUA) $(LUA_SCRIPT) $(RUNPIPE) lua_embed_run: $(RUNTOOL) ./$(TARGET) $(LUA_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- lua_version: $(LUA) -v | head -n 1 # ----------------------------------------------------------------- # Cleaning the lua examples # ----------------------------------------------------------------- lua_clean: rm -f *_wrap* *~ .~* mylua@EXEEXT@ rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *$(LUA_SO) ################################################################## ##### ALLEGRO CL ###### ################################################################## ALLEGROCL = @ALLEGROCLBIN@ ALLEGROCL_SCRIPT=$(RUNME).lisp allegrocl: $(SRCDIR_SRCS) $(SWIG) -allegrocl -cwrap $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) allegrocl_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -allegrocl $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ----------------------------------------------------------------- # Run ALLEGRO CL example # ----------------------------------------------------------------- allegrocl_run: $(RUNTOOL) $(ALLEGROCL) -batch -s $(ALLEGROCL_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- allegrocl_version: $(ALLEGROCL) --version # ----------------------------------------------------------------- # Cleaning the ALLEGRO CL examples # ----------------------------------------------------------------- allegrocl_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ ################################################################## ##### CLISP ###### ################################################################## CLISP = @CLISPBIN@ CLISP_SCRIPT=$(RUNME).lisp clisp: $(SRCDIR_SRCS) $(SWIG) -clisp $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) clisp_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -clisp $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) # ----------------------------------------------------------------- # Run CLISP example # ----------------------------------------------------------------- clisp_run: $(RUNTOOL) $(CLISP) -batch -s $(CLISP_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- clisp_version: $(CLISP) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the CLISP examples # ----------------------------------------------------------------- clisp_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ ################################################################## ##### CFFI ###### ################################################################## CFFI = @CFFIBIN@ CFFI_SCRIPT=$(RUNME).lisp cffi: $(SRCDIR_SRCS) $(SWIG) -cffi $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS) # $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) cffi_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -cffi $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ----------------------------------------------------------------- # Run CFFI example # ----------------------------------------------------------------- cffi_run: $(RUNTOOL) $(CFFI) -batch -s $(CFFI_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- cffi_version: $(CFFI) --version # ----------------------------------------------------------------- # Cleaning the CFFI examples # ----------------------------------------------------------------- cffi_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ ################################################################## ##### UFFI ###### ################################################################## UFFI = @UFFIBIN@ UFFI_SCRIPT=$(RUNME).lisp uffi: $(SRCDIR_SRCS) $(SWIG) -uffi $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS) # $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) uffi_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -uffi $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) # $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ----------------------------------------------------------------- # Run UFFI example # ----------------------------------------------------------------- uffi_run: $(RUNTOOL) $(UFFI) -batch -s $(UFFI_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- uffi_version: $(UFFI) --version # ----------------------------------------------------------------- # Cleaning the UFFI examples # ----------------------------------------------------------------- uffi_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ ################################################################## ##### R ###### ################################################################## R = R RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx RRSRC = $(INTERFACE:.i=.R) R_CFLAGS=-fPIC R_SCRIPT=$(RUNME).R # need to compile .cxx files outside of R build system to make sure that # we get -fPIC # CMD SHLIB stdout is piped to /dev/null to prevent echo of compiler command # ---------------------------------------------------------------- # Build a R dynamically loadable module (C) # ---------------------------------------------------------------- r: $(SRCDIR_SRCS) $(SWIG) -r $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) ifneq ($(SRCDIR_SRCS),) $(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(R_CFLAGS) $(SRCDIR_SRCS) $(INCLUDES) endif +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) # ---------------------------------------------------------------- # Build a R dynamically loadable module (C++) # ---------------------------------------------------------------- r_cpp: $(SRCDIR_CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) ifneq ($(SRCDIR_CXXSRCS),) $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(R_CFLAGS) $(SRCDIR_CXXSRCS) $(INCLUDES) endif +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) # ----------------------------------------------------------------- # Run R example # ----------------------------------------------------------------- r_run: $(RUNTOOL) $(R) CMD BATCH $(R_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- r_version: $(R) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the R examples # ----------------------------------------------------------------- r_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ NAMESPACE rm -f $(RRSRC) $(RUNME).Rout .RData ################################################################## ##### Go ###### ################################################################## GO = @GO@ GOGCC = @GOGCC@ GO1 = @GO1@ GO12 = @GO12@ GO13 = @GO13@ GOC = @GOC@ GOOPT = @GOOPT@ 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` GOSRCS = $(INTERFACE:.i=.go) GOCSRCS = $(INTERFACE:.i=_gc.c) GOLD = $(GOC:c=l) GOTOOL = `if $(GO1) ; then echo go tool; fi` GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi` GOPACKAGE = $(INTERFACE:.i=.a) GOOBJEXT = $(GOC:c=) GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT)) GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@) # ---------------------------------------------------------------- # Build a Go module (C) # ---------------------------------------------------------------- go: $(SRCDIR_SRCS) $(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) if $(GO12) || $(GO13) || $(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 \ $(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} $(GOCSRCS); \ rm -f $(GOPACKAGE); \ if $(GO13); then \ cp $(GOGCOBJS) $(GOPACKAGE); \ $(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \ elif $(GO12); then \ $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \ else \ $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ 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) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \ fi; \ fi # ---------------------------------------------------------------- # Build a Go module (C++) # ---------------------------------------------------------------- go_cpp: $(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); \ 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); \ rm -f $(GOPACKAGE); \ if $(GO13); then \ cp $(GOGCOBJS) $(GOPACKAGE); \ $(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \ elif $(GO12); then \ $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \ else \ $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ 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) -lstdc++; \ elif $(GO12) || $(GO13); then \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \ fi; \ fi # ----------------------------------------------------------------- # Running Go example # ----------------------------------------------------------------- go_run: env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) ./$(RUNME) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- go_version: $(GO) $(GOVERSIONOPTION) # ----------------------------------------------------------------- # Cleaning the Go examples # ----------------------------------------------------------------- go_clean: rm -f *_wrap* *_gc* .~* $(RUNME) $(GOSRCS) rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *.[568] *.a *@SO@ ################################################################## ##### D ###### ################################################################## DLIBPREFIX = @DLIBPREFIX@ ifeq (,$(D_VERSION)) D_VERSION = @DDEFAULTVERSION@ endif ifeq (2,$(D_VERSION)) SWIGD = $(SWIG) -d -d2 DCOMPILER = @D2COMPILER@ else SWIGD = $(SWIG) -d DCOMPILER = @D1COMPILER@ endif D_RUNME = ./$(RUNME) # ---------------------------------------------------------------- # Build a dynamically loadable D wrapper for a C module # ---------------------------------------------------------------- d: $(SRCDIR_SRCS) $(SWIGD) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a dynamically loadable D wrapper for a C++ module # ---------------------------------------------------------------- d_cpp: $(SRCDIR_SRCS) $(SWIGD) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Compile D files # ---------------------------------------------------------------- # Clear the DFLAGS environment variable for the compiler call itself # to work around a discrepancy in argument handling between DMD and LDC. d_compile: $(SRCDIR_SRCS) DFLAGS="" $(COMPILETOOL) $(DCOMPILER) $(DFLAGS) $(DSRCS) # ----------------------------------------------------------------- # Run D example # ----------------------------------------------------------------- d_run: $(RUNTOOL) $(D_RUNME) $(RUNPIPE) # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- d_version: # Needs improvement! echo D version guess - $(D_VERSION) # ----------------------------------------------------------------- # Clean the D examples # ----------------------------------------------------------------- d_clean: rm -f *_wrap* *~ .~* $(RUNME) $(RUNME).exe `find . -name \*.d | grep -v $(RUNME).d` rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ swig-3.0.2/Examples/ruby/0000775000175000017500000000000012343605122015102 5ustar williamwilliamswig-3.0.2/Examples/ruby/exception_class/0000775000175000017500000000000012343605122020265 5ustar williamwilliamswig-3.0.2/Examples/ruby/exception_class/example.h0000664000175000017500000000140112343605122022065 0ustar williamwilliam/* File : example.h */ // A simple exception class EmptyError { }; class FullError { public: int maxsize; FullError(int m) : maxsize(m) { } }; template class Queue { int maxsize; T *items; int nitems; int last; public: Queue(int size) { maxsize = size; items = new T[size]; nitems = 0; last = 0; } ~Queue() { delete [] items; } void enqueue(T x) throw(FullError) { if (nitems == maxsize) { throw FullError(maxsize); } items[last] = x; last = (last + 1) % maxsize; nitems++; } T dequeue() { T x; if (nitems == 0) throw EmptyError(); x = items[(last + maxsize - nitems) % maxsize]; nitems--; return x; } int length() { return nitems; } }; swig-3.0.2/Examples/ruby/exception_class/example.i0000664000175000017500000000311012343605122022065 0ustar williamwilliam/* This example illustrates the use of the %exceptionclass feature. By default, if a method has a throws specification then SWIG will generate code to catch the exception and pass it on the scripting language. If a method does not have a throws specification, but does throw an exception, then the %exceptionclass feature can be used to tell SWIG about the exception class so it can be properly added to Ruby. This is done by making the exception class inherit from rb_eRuntimeError.*/ %module example %{ #include "example.h" %} /* The EmpytError doesn't appear in a throw declaration, and hence we need to tell SWIG that the dequeue method throws it. This can now be done via the %catchs feature. */ %catches(EmptyError) *::dequeue(); /* What the catches clause is doing under the covers is this: %exceptionclass EmptyError; %exception *::dequeue { try { $action } catch(EmptyError& e) { // Create a new instance of the EmptyError, wrap it as a Ruby object that Ruby owns, // and return it as the exception. For this to work EmtpyError must inherit from // a standard Ruby exception class such as rb_eRuntimeError. SWIG automatically does // this when the class is marked as %exceptionclass or is a throws specification. %raise(SWIG_NewPointerObj(new EmptyError(e),SWIGTYPE_p_EmptyError, SWIG_POINTER_OWN), "EmptyError", SWIGTYPE_p_EmptyError); } } */ /* Grab the original header file */ %include "example.h" /* Instantiate a few templates */ %template(IntQueue) Queue; %template(DoubleQueue) Queue; swig-3.0.2/Examples/ruby/exception_class/Makefile0000664000175000017500000000106412343605122021726 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/exception_class/runme.rb0000664000175000017500000000117512343605122021744 0ustar williamwilliamrequire 'example' q = Example::IntQueue.new(10) puts "Inserting items into intQueue" begin 0.upto(100) do |i| q.enqueue(i) end rescue Example::FullError => e puts "Maxsize is: #{e.maxsize}" end puts "Removing items" begin loop do q.dequeue() end rescue Example::EmptyError => e ## do nothing end q = Example::DoubleQueue.new(1000) puts "Inserting items into doubleQueue" begin 0.upto(100) do |i| q.enqueue(i*1.5) end rescue Example::FullError => e puts "Maxsize is: #{e.maxsize}" end puts "Removing items" begin loop do q.dequeue() end rescue Example::EmptyError => e # do nothing end swig-3.0.2/Examples/ruby/std_vector/0000775000175000017500000000000012343605122017256 5ustar williamwilliamswig-3.0.2/Examples/ruby/std_vector/example.h0000664000175000017500000000111612343605122021061 0ustar williamwilliam/* File : example.h */ #include #include #include #include double average(std::vector v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } std::vector half(const std::vector& v) { std::vector w(v); for (unsigned int i=0; i& v) { // would you believe this is the same as the above? std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } swig-3.0.2/Examples/ruby/std_vector/example.i0000664000175000017500000000047512343605122021071 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include stl.i /* instantiate the required template specializations */ namespace std { %template(IntVector) vector; %template(DoubleVector) vector; } /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/ruby/std_vector/Makefile0000664000175000017500000000115312343605122020716 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/std_vector/runme.rb0000664000175000017500000000126412343605122020734 0ustar williamwilliam# file: runme.rb require 'example' # Call average with a Ruby array... puts Example::average([1,2,3,4]) # ... or a wrapped std::vector v = Example::IntVector.new(4) 0.upto(v.size-1) { |i| v[i] = i+1 } puts Example::average(v) # half will return a Ruby array. # Call it with a Ruby array... w = Example::half([1.0, 1.5, 2.0, 2.5, 3.0]) 0.upto(w.size-1) { |i| print w[i],"; " } puts # ... or a wrapped std::vector v = Example::DoubleVector.new [1,2,3,4].each { |i| v.push(i) } w = Example::half(v) 0.upto(w.size-1) { |i| print w[i],"; " } puts # now halve a wrapped std::vector in place Example::halve_in_place(v) 0.upto(v.size-1) { |i| print v[i],"; " } puts swig-3.0.2/Examples/ruby/import_template/0000775000175000017500000000000012343605122020307 5ustar williamwilliamswig-3.0.2/Examples/ruby/import_template/spam.h0000664000175000017500000000070412343605122021421 0ustar williamwilliam#include "bar.h" template class Spam : public Bar { public: Spam() { } ~Spam() { } virtual const char * A() const { return "Spam::A"; } const char * B() const { return "Spam::B"; } virtual Base *toBase() { return static_cast *>(this); } virtual Bar *toBar() { return static_cast *>(this); } static Spam *fromBase(Base *b) { return dynamic_cast *>(b); } }; swig-3.0.2/Examples/ruby/import_template/README0000664000175000017500000000165012343605122021171 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. Use 'ruby runme.rb' to run a test. Overview: --------- The example defines 4 different extension modules--each wrapping a separate C++ class. base.i - Base class foo.i - Foo class derived from Base bar.i - Bar class derived from Base spam.i - Spam class derived from Bar Each module uses %import to refer to another module. For example, the 'foo.i' module uses '%import base.i' to get definitions for its base class. If everything is okay, all of the modules will load properly and type checking will work correctly. Caveat: Some compilers, for example gcc-3.2.x, generate broken vtables with the inline methods in this test. This is not a SWIG problem and can usually be solved with non-inlined destructors compiled into separate shared objects/DLLs. Unix: ----- - Run make - Run the test as described above swig-3.0.2/Examples/ruby/import_template/spam.i0000664000175000017500000000014612343605122021422 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" %template(IntSpam) Spam; swig-3.0.2/Examples/ruby/import_template/bar.i0000664000175000017500000000014312343605122021223 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" %template(IntBar) Bar; swig-3.0.2/Examples/ruby/import_template/base.i0000664000175000017500000000012412343605122021370 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h %template(IntBase) Base; swig-3.0.2/Examples/ruby/import_template/foo.i0000664000175000017500000000014212343605122021241 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" %template(IntFoo) Foo; swig-3.0.2/Examples/ruby/import_template/foo.h0000664000175000017500000000056712343605122021253 0ustar williamwilliam#include "base.h" template class Foo : public Base { public: Foo() { } ~Foo() { } virtual const char * A() const { return "Foo::A"; } const char * B() const { return "Foo::B"; } virtual Base *toBase() { return static_cast *>(this); } static Foo *fromBase(Base *b) { return dynamic_cast *>(b); } }; swig-3.0.2/Examples/ruby/import_template/base.h0000664000175000017500000000051712343605122021375 0ustar williamwilliam#include template class Base { public: Base() { }; virtual ~Base() { }; virtual const char * A() const { return "Base::A"; } const char * B() const { return "Base::B"; } virtual Base *toBase() { return static_cast *>(this); } }; swig-3.0.2/Examples/ruby/import_template/Makefile0000664000175000017500000000143112343605122021746 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/import_template/runme.rb0000664000175000017500000000333512343605122021766 0ustar williamwilliam# file: runme.rb # Test various properties of classes defined in separate modules puts "Testing the %import directive with templates" require 'base' require 'foo' require 'bar' require 'spam' # Create some objects puts "Creating some objects" a = Base::IntBase.new b = Foo::IntFoo.new c = Bar::IntBar.new d = Spam::IntSpam.new # Try calling some methods puts "Testing some methods" puts "" puts "Should see 'Base::A' ---> #{a.A}" puts "Should see 'Base::B' ---> #{a.B}" puts "Should see 'Foo::A' ---> #{b.A}" puts "Should see 'Foo::B' ---> #{b.B}" puts "Should see 'Bar::A' ---> #{c.A}" puts "Should see 'Bar::B' ---> #{c.B}" puts "Should see 'Spam::A' ---> #{d.A}" puts "Should see 'Spam::B' ---> #{d.B}" # Try some casts puts "\nTesting some casts\n" puts "" x = a.toBase puts "Should see 'Base::A' ---> #{x.A}" puts "Should see 'Base::B' ---> #{x.B}" x = b.toBase puts "Should see 'Foo::A' ---> #{x.A}" puts "Should see 'Base::B' ---> #{x.B}" x = c.toBase puts "Should see 'Bar::A' ---> #{x.A}" puts "Should see 'Base::B' ---> #{x.B}" x = d.toBase puts "Should see 'Spam::A' ---> #{x.A}" puts "Should see 'Base::B' ---> #{x.B}" x = d.toBar puts "Should see 'Bar::B' ---> #{x.B}" puts "\nTesting some dynamic casts\n" x = d.toBase puts " Spam -> Base -> Foo : " y = Foo::IntFoo.fromBase(x) if y != nil puts "bad swig" else puts "good swig" end puts " Spam -> Base -> Bar : " y = Bar::IntBar.fromBase(x) if y != nil puts "good swig" else puts "bad swig" end puts " Spam -> Base -> Spam : " y = Spam::IntSpam.fromBase(x) if y != nil puts "good swig" else puts "bad swig" end puts " Foo -> Spam : " y = Spam::IntSpam.fromBase(b) if y != nil puts "bad swig" else puts "good swig" end swig-3.0.2/Examples/ruby/import_template/bar.h0000664000175000017500000000057012343605122021226 0ustar williamwilliam#include "base.h" template class Bar : public Base { public: Bar() { } ~Bar() { } virtual const char * A() const { return "Bar::A"; } const char * B() const { return "Bar::B"; } virtual Base *toBase() { return static_cast *>(this); } static Bar *fromBase(Base *b) { return dynamic_cast *>(b); } }; swig-3.0.2/Examples/ruby/template/0000775000175000017500000000000012343605122016715 5ustar williamwilliamswig-3.0.2/Examples/ruby/template/example.h0000664000175000017500000000077712343605122020534 0ustar williamwilliam/* File : example.h */ // Some template definitions template T max(T a, T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } #ifdef SWIG %extend { T getitem(int index) { return $self->get(index); } void setitem(int index, T val) { $self->set(index,val); } } #endif }; swig-3.0.2/Examples/ruby/template/example.i0000664000175000017500000000055212343605122020524 0ustar williamwilliam/* File : example.i */ %module example %{ #ifdef max #undef max #endif #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(Vecint) vector; %template(Vecdouble) vector; swig-3.0.2/Examples/ruby/template/Makefile0000664000175000017500000000115312343605122020355 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/template/runme.rb0000664000175000017500000000065512343605122020376 0ustar williamwilliam# file: runme.rb require 'example' # Call some templated functions puts Example::maxint(3, 7) puts Example::maxdouble(3.14, 2.18) # Create some class iv = Example::Vecint.new(100) dv = Example::Vecdouble.new(1000) 100.times { |i| iv.setitem(i, 2*i) } 1000.times { |i| dv.setitem(i, 1.0/(i+1)) } sum = 0 100.times { |i| sum = sum + iv.getitem(i) } puts sum sum = 0.0 1000.times { |i| sum = sum + dv.getitem(i) } puts sum swig-3.0.2/Examples/ruby/class/0000775000175000017500000000000012343605122016207 5ustar williamwilliamswig-3.0.2/Examples/ruby/class/example.h0000664000175000017500000000107612343605122020017 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/ruby/class/example.i0000664000175000017500000000021512343605122020012 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/ruby/class/example.cxx0000664000175000017500000000065012343605122020367 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/ruby/class/index.html0000664000175000017500000000562412343605122020213 0ustar williamwilliam SWIG:Examples:ruby:class SWIG/Examples/ruby/class/

    Wrapping a simple C++ class

    This example illustrates wrapping a simple C++ class to give a Ruby class.

    The C++ Code

    Suppose you have some C++ classes described by the following (and admittedly lame) header file:
    /* File : example.h */
    
    class Shape {
    public:
      Shape() {
        nshapes++;
      }
      virtual ~Shape() {
        nshapes--;
      }
      double  x, y;
      void    move(double dx, double dy);
      virtual double area() = 0;
      virtual double perimeter() = 0;
      static  int nshapes;
    };
    
    class Circle : public Shape {
    private:
      double radius;
    public:
      Circle(double r) : radius(r) { }
      virtual double area();
      virtual double perimeter();
    };
    
    class Square : public Shape {
    private:
      double width;
    public:
      Square(double w) : width(w) { }
      virtual double area();
      virtual double perimeter();
    };
    

    The SWIG interface

    A simple SWIG interface for this can be built by simply grabbing the header file like this:
    /* File : example.i */
    %module example
    
    %{
    #include "example.h"
    %}
    
    /* Let's just grab the original header file here */
    %include "example.h"
    
    Note: when creating a C++ extension, you must run SWIG with the -c++ option like this:
    % swig -c++ -ruby example.i
    

    A sample Ruby script

    Click here to see a script that calls the C++ functions from Ruby.

    Key points

    • To create a new object, you call a constructor like this:
      c = Example::Circle.new(10)
      

    • To access member data, a pair of accessor methods are used. For example:
      c.x = 15    # Set member data
      x = c.x     # Get member data
      

    • To invoke a member function, you simply do this
      print "The area is ", c.area, "\n"
      

    • When a instance of Ruby level wrapper class is garbage collected by the Ruby interpreter, the corresponding C++ destructor is automatically invoked.

    • Static member variables are wrapped as Ruby class accessor methods. For example:
      n = Shape.nshapes     # Get a static data member
      Shapes.nshapes = 13   # Set a static data member
      

    General Comments

    • Ruby module of SWIG differs from other language modules in wrapping C++ interfaces. They provide lower-level interfaces and optional higher-level interfaces know as proxy classes. Ruby module needs no such redundancy due to Ruby's sophisticated extension API.
    • SWIG does know how to properly perform upcasting of objects in an inheritance hierarchy except for multiple inheritance.
    • C++ Namespaces - %nspace isn't yet supported for Ruby.

    swig-3.0.2/Examples/ruby/class/example.dsp0000664000175000017500000001225712343605122020361 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/ruby/class/Makefile0000664000175000017500000000110012343605122017637 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/class/runme.rb0000664000175000017500000000246712343605122017673 0ustar williamwilliam# file: runme.rb # This file illustrates the C++ interface created by SWIG. # All of our C++ classes get converted into Ruby classes. require 'example' # ----- Object creation ----- print "Creating some objects:\n" c = Example::Circle.new(10) print " Created circle #{c}\n" s = Example::Square.new(10) print " Created square #{s}\n" # ----- Access a static member ----- print "\nA total of #{Example::Shape.nshapes} shapes were created\n" # ----- Member data access ----- # Set the location of the object # Notice how we can do this using functions specific to # the 'Circle' class. c.x = 20 c.y = 30 # Now use the same functions in the base class s.x = -10 s.y = 5 print "\nHere is their current position:\n" print " Circle = (", c.x, ",", c.y, ")\n" print " Square = (", s.x, ",", s.y, ")\n" # ----- Call some methods ----- print "\nHere are some properties of the shapes:\n" for o in [c, s] print " #{o}\n" print " area = ", o.area, "\n" print " perimeter = ", o.perimeter, "\n" end # Notice how the Shape#area() and Shape#perimeter() functions really # invoke the appropriate virtual method on each object. # Remove references to the object and force a garbage collection run. c = s = o = nil GC.start() print "\n", Example::Shape.nshapes," shapes remain\n" print "Goodbye\n" swig-3.0.2/Examples/ruby/pointer/0000775000175000017500000000000012343605122016562 5ustar williamwilliamswig-3.0.2/Examples/ruby/pointer/example.c0000664000175000017500000000036112343605122020361 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void sub(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/ruby/pointer/example.i0000664000175000017500000000117612343605122020374 0ustar williamwilliam/* File : example.i */ %module example %{ extern void add(int *, int *, int *); extern void sub(int *, int *, int *); extern int divide(int, int, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); swig-3.0.2/Examples/ruby/pointer/index.html0000664000175000017500000000660112343605122020562 0ustar williamwilliam SWIG:Examples:ruby:pointer SWIG/Examples/ruby/pointer/

    Simple Pointer Handling

    This example illustrates a couple of techniques for handling simple pointers in SWIG. The prototypical example is a C function that operates on pointers such as this:

    void add(int *x, int *y, int *r) { 
        *r = *x + *y;
    }
    
    By default, SWIG wraps this function exactly as specified and creates an interface that expects pointer objects for arguments. The only problem is how does one go about creating these objects from a script?

    Possible Solutions

    • Write some helper functions to explicitly create objects. For example:
      int *new_int(int ivalue) {
        int *i = (int *) malloc(sizeof(ivalue));
        *i = ivalue;
        return i;
      }
      int get_int(int *i) {
        return *i;
      }
      
      void delete_int(int *i) {
        free(i);
      }
      
      Now, in a script you would do this:
      a = new_int(37)
      b = new_int(42)
      c = new_int(0)
      add(a,b,c)
      r = get_int(c)
      print "Result = #{r}\n"
      delete_int(a)
      delete_int(b)
      delete_int(c)
      

    • Use the SWIG pointer library. For example, in the interface file you would do this:
      %include "pointer.i"
      
      and in a script you would do this:
      a = ptrcreate("int",37)
      b = ptrcreate("int",42)
      c = ptrcreate("int")
      add(a,b,c)
      r = ptrvalue(c)
      print "Result = #{r}\n"
      ptrfree(a)
      ptrfree(b)
      ptrfree(c)
      
      The advantage to using the pointer library is that it unifies some of the helper functions behind a common set of names. For example, the same set of functions work with int, double, float, and other fundamental types.

    • Use the SWIG typemap library. This library allows you to completely change the way arguments are processed by SWIG. For example:
      %include "typemaps.i"
      void add(int *INPUT, int *INPUT, int *OUTPUT);
      
      And in a script:
      r = add(37,42)
      print "Result = #{r}\n"
      
      Needless to say, this is substantially easier.

    • A final alternative is to use the typemaps library in combination with the %apply directive. This allows you to change the names of parameters that behave as input or output parameters. For example:
      %include "typemaps.i"
      %apply int *INPUT {int *x, int *y};
      %apply int *OUTPUT {int *r};
      
      void add(int *x, int *y, int *r);
      void sub(int *x, int *y, int *r);
      void mul(int *x, int *y, int *r);
      ... etc ...
      

    Example

    The following example illustrates the use of these features for pointer extraction.

    Notes

    • Since pointers are used for so many different things (arrays, output values, etc...) the complexity of pointer handling can be as complicated as you want to make it.

    • More documentation on the typemaps.i and pointer.i library files can be found in the SWIG user manual. The files also contain documentation.

    • The pointer.i library is designed primarily for convenience. If you are concerned about performance, you probably want to use a different approach.

    swig-3.0.2/Examples/ruby/pointer/Makefile0000664000175000017500000000103112343605122020215 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/pointer/runme.rb0000664000175000017500000000167712343605122020250 0ustar williamwilliam# file: runme.rb require 'example' # First create some objects using the pointer library. print "Testing the pointer library\n" 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}\n" print " b = #{b}\n" print " c = #{c}\n" # Call the add() function with some pointers Example::add(a, b, c) # Now get the result r = Example::intp_value(c) print " 37 + 42 = #{r}\n" # Clean up the pointers Example::delete_intp(a) Example::delete_intp(b) Example::delete_intp(c) # Now try the typemap library # This should be much easier. Now how it is no longer # necessary to manufacture pointers. print "Trying the typemap library\n" r = Example::sub(37, 42) print " 37 - 42 = #{r}\n" # Now try the version with multiple return values print "Testing multiple return values\n" q, r = Example::divide(42, 37) print " 42/37 = #{q} remainder #{r}\n" swig-3.0.2/Examples/ruby/enum/0000775000175000017500000000000012343605122016046 5ustar williamwilliamswig-3.0.2/Examples/ruby/enum/example.h0000664000175000017500000000031512343605122017651 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE, WARP, LUDICROUS }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/ruby/enum/example.i0000664000175000017500000000021712343605122017653 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/ruby/enum/example.cxx0000664000175000017500000000150712343605122020230 0ustar williamwilliam/* File : example.c */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/ruby/enum/index.html0000664000175000017500000000145412343605122020047 0ustar williamwilliam SWIG:Examples:ruby:enum SWIG/Examples/ruby/enum/

    Wrapping enumerations

    This example tests SWIG's ability to wrap enumerations. By default, SWIG converts enumeration specifications into integer constants. Further use of enumerated types are handled as integers.

    Notes

    • SWIG allows arbitrary integers to be passed as enum values. However, the result of passing an integer not corresponding to any of the values specified in the enum specification is undefined.

    swig-3.0.2/Examples/ruby/enum/Makefile0000664000175000017500000000110012343605122017476 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/enum/runme.rb0000664000175000017500000000156012343605122017523 0ustar williamwilliam# file: runme.rb require 'example' # ----- Object creation ----- # Print out the value of some enums print "*** color ***\n" print " RED = #{Example::RED}\n" print " BLUE = #{Example::BLUE}\n" print " GREEN = #{Example::GREEN}\n" print "\n*** Foo::speed ***\n" print " Foo::IMPULSE = #{Example::Foo::IMPULSE}\n" print " Foo::WARP = #{Example::Foo::WARP}\n" print " Foo::LUDICROUS = #{Example::Foo::LUDICROUS}\n" print "\nTesting use of enums with functions\n\n" Example::enum_test(Example::RED, Example::Foo::IMPULSE) Example::enum_test(Example::BLUE, Example::Foo::WARP) Example::enum_test(Example::GREEN, Example::Foo::LUDICROUS) Example::enum_test(1234, 5678) print "\nTesting use of enum with class method\n" f = Example::Foo.new() f.enum_test(Example::Foo::IMPULSE) f.enum_test(Example::Foo::WARP) f.enum_test(Example::Foo::LUDICROUS) swig-3.0.2/Examples/ruby/simple/0000775000175000017500000000000012343605122016373 5ustar williamwilliamswig-3.0.2/Examples/ruby/simple/example.c0000664000175000017500000000036712343605122020200 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/ruby/simple/example.i0000664000175000017500000000015212343605122020176 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/ruby/simple/index.html0000664000175000017500000000320012343605122020363 0ustar williamwilliam SWIG:Examples:ruby:simple SWIG/Examples/ruby/simple/

    Simple Ruby Example

    This example illustrates how you can hook Ruby to a very simple C program containing a function and a global variable.

    The C Code

    Suppose you have the following C code:
    /* File : example.c */
    
    /* A global variable */
    double Foo = 3.0;
    
    /* Compute the greatest common divisor of positive integers */
    int gcd(int x, int y) {
      int g;
      g = y;
      while (x > 0) {
        g = x;
        x = y % x;
        y = g;
      }
      return g;
    }
    

    The SWIG interface

    Here is a simple SWIG interface file:
    /* File: example.i */
    %module example
    
    extern int gcd(int x, int y);
    extern double Foo;
    

    Compilation

    1. swig -ruby example.i

    2. Compile example_wrap.c and example.c to create the extension example.so.

    Using the extension

    Click here to see a script that calls our C functions from Ruby.

    Key points

    • Use the require function to load your extension library from Ruby. For example:
      require 'example'
      
    • C functions work just like Ruby functions. For example:
      g = Example.gcd(42,105)
      
    • C global variables are accessed through module method. For example:
      a = Example.Foo
      

    swig-3.0.2/Examples/ruby/simple/example.dsp0000664000175000017500000001213712343605122020542 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -ruby "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -ruby "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/ruby/simple/Makefile0000664000175000017500000000103112343605122020026 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/simple/runme.rb0000664000175000017500000000054312343605122020050 0ustar williamwilliam# file: runme.rb require 'example' # Call our gcd() function x = 42 y = 105 g = Example.gcd(x,y) printf "The gcd of %d and %d is %d\n",x,y,g # Manipulate the Foo global variable # Output its current value print "Foo = ", Example.Foo, "\n" # Change its value Example.Foo = 3.1415926 # See if the change took effect print "Foo = ", Example.Foo, "\n" swig-3.0.2/Examples/ruby/constants/0000775000175000017500000000000012343605122017116 5ustar williamwilliamswig-3.0.2/Examples/ruby/constants/example.i0000664000175000017500000000113512343605122020723 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int Iconst = 37; %constant double Fconst = 3.14; swig-3.0.2/Examples/ruby/constants/index.html0000664000175000017500000000351612343605122021120 0ustar williamwilliam SWIG:Examples:ruby:constants SWIG/Examples/ruby/constants/

    Wrapping C Constants

    When SWIG encounters C preprocessor macros and C declarations that look like constants, it creates Ruby constants with an identical value. Click here to see a SWIG interface with some constant declarations in it.

    Accessing Constants from Ruby

    Click here to see a script that prints out the values of the constants contained in the above file.

    Key points

    • The values of preprocessor macros are converted into Ruby constants.
    • Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
    • Character constants such as 'x' are converted into Ruby strings.
    • C string literals such as "Hello World" are converted into Ruby strings.
    • Macros that are not fully defined are simply ignored. For example:
      #define EXTERN extern
      
      is ignored because SWIG has no idea what type of variable this would be.

    • Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
    • Certain C declarations involving 'const' are also turned into Ruby constants.
    • Constants that begin with lower case character are automatically capitalized. For example:
      const int     iconst = 37;
      
      is capitalized as Example::Iconst because Ruby constants name must begin with upper case character.
    • The constants that appear in a SWIG interface file do not have to appear in any sort of matching C source file since the creation of a constant does not require linkage to a stored value (i.e., a value held in a C global variable or memory location).

    swig-3.0.2/Examples/ruby/constants/Makefile0000664000175000017500000000101712343605122020555 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/constants/runme.rb0000664000175000017500000000160712343605122020575 0ustar williamwilliam# file: runme.rb require 'example' print "ICONST = ", Example::ICONST, " (should be 42)\n" print "FCONST = ", Example::FCONST, " (should be 2.1828)\n" print "CCONST = ", Example::CCONST, " (should be 'x')\n" print "CCONST2 = ", Example::CCONST2, " (this should be on a new line)\n" print "SCONST = ", Example::SCONST, " (should be 'Hello World')\n" print "SCONST2 = ", Example::SCONST2, " (should be '\"Hello World\"')\n" print "EXPR = ", Example::EXPR, " (should be 48.5484)\n" print "iconst = ", Example::Iconst, " (should be 37)\n" print "fconst = ", Example::Fconst, " (should be 3.14)\n" begin print "EXTERN = ", Example::EXTERN, " (Arg! This shouldn't print anything)\n" rescue NameError print "EXTERN isn't defined (good)\n" end begin print "FOO = ", Example::FOO, " (Arg! This shouldn't print anything)\n" rescue NameError print "FOO isn't defined (good)\n" end swig-3.0.2/Examples/ruby/free_function/0000775000175000017500000000000012343605122017730 5ustar williamwilliamswig-3.0.2/Examples/ruby/free_function/example.h0000664000175000017500000000154612343605122021542 0ustar williamwilliam#ifndef _EXAMPLE_H_ #define _EXAMPLE_H_ #include #include class Animal { protected: std::string name_; public: // Construct an animal with a name Animal(const char* name); // Destruct an animal ~Animal(); // Return the animal's name const char* get_name() const; }; class Zoo { private: typedef std::vector AnimalsType; typedef AnimalsType::iterator IterType; protected: AnimalsType animals; public: Zoo(); ~Zoo(); /* Create a new animal */ static Animal* create_animal(const char* name); /* Add a new animal to the zoo */ void add_animal(Animal* animal); /* Remove an animal from the zoo */ Animal* remove_animal(size_t i); /* Return the number of animals in the zoo */ size_t get_num_animals() const; /* Return a pointer to the ith animal */ Animal* get_animal(size_t i) const; }; #endif /*_EXAMPLE_H_*/ swig-3.0.2/Examples/ruby/free_function/example.i0000664000175000017500000000161512343605122021540 0ustar williamwilliam%module example %{ #include "example.h" %} /* Specify that ownership is transferred to the zoo when calling add_animal */ %apply SWIGTYPE *DISOWN { Animal* animal }; /* Track objects */ %trackobjects; /* Specify the mark function */ %freefunc Zoo "free_Zoo"; %include "example.h" %header %{ static void free_Zoo(void* ptr) { Zoo* zoo = (Zoo*) ptr; /* Loop over each object and call SWIG_RubyRemoveTracking */ int count = zoo->get_num_animals(); for(int i = 0; i < count; ++i) { /* Get an animal */ Animal* animal = zoo->get_animal(i); /* Unlink the Ruby object from the C++ object */ SWIG_RubyUnlinkObjects(animal); /* Now remove the tracking for this animal */ SWIG_RubyRemoveTracking(animal); } /* Now call SWIG_RubyRemoveTracking for the zoo */ SWIG_RubyRemoveTracking(ptr); /* Now free the zoo which will free the animals it contains */ delete zoo; } %} swig-3.0.2/Examples/ruby/free_function/example.cxx0000664000175000017500000000206412343605122022111 0ustar williamwilliam#include "example.h" Animal::Animal(const char* name) : name_(name) { } Animal::~Animal() { } /* Return the animal's name */ const char* Animal::get_name() const { return name_.c_str(); } Zoo::Zoo() { } Zoo::~Zoo() { IterType iter = this->animals.begin(); IterType end = this->animals.end(); for(; iter != end; ++iter) { Animal* animal = *iter; delete animal; } } /* Create a new animal. */ Animal* Zoo::create_animal(const char* name) { return new Animal(name); } /* Add a new animal to the zoo. */ void Zoo::add_animal(Animal* animal) { animals.push_back(animal); } Animal* Zoo::remove_animal(size_t i) { /* Note a production implementation should check for out of range errors. */ Animal* result = this->animals[i]; IterType iter = this->animals.begin(); std::advance(iter, i); this->animals.erase(iter); return result; } /* Return the number of animals in the zoo. */ size_t Zoo::get_num_animals() const { return animals.size(); } /* Return a pointer to the ith animal */ Animal* Zoo::get_animal(size_t i) const { return animals[i]; } swig-3.0.2/Examples/ruby/free_function/example.dsp0000664000175000017500000001225712343605122022102 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/ruby/free_function/Makefile0000664000175000017500000000110012343605122021360 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/free_function/runme.rb0000664000175000017500000000166512343605122021413 0ustar williamwilliamrequire 'example' begin begin # Create an animal and zoo tiger1 = Example::Animal.new("tiger1") zoo = Example::Zoo.new # At the animal to the zoo - this will transfer ownership # of the underlying C++ object to the C++ zoo object zoo.add_animal(tiger1) # get the id of the tiger id1 = tiger1.object_id # Unset the tiger tiger1 = nil end # Force a gc GC.start # Get the tiger and its id tiger2 = zoo.get_animal(0) id2 = tiger2.object_id # The ids should not be the same if id1==id2 # Not working - needs checking/fixing # raise RuntimeError, "Id's should not be the same" end zoo = nil end GC.start # This method is no longer valid since the zoo freed the underlying # C++ object ok = false begin puts tiger2.get_name rescue ObjectPreviouslyDeleted => error ok = true end raise(RuntimeError, "Incorrect exception raised - should be ObjectPreviouslyDeleted") unless ok swig-3.0.2/Examples/ruby/reference/0000775000175000017500000000000012343605122017040 5ustar williamwilliamswig-3.0.2/Examples/ruby/reference/example.h0000664000175000017500000000064512343605122020651 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; friend Vector operator+(const Vector &a, const Vector &b); char *print(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/ruby/reference/example.i0000664000175000017500000000131412343605122020644 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module example %{ #include "example.h" %} class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.2/Examples/ruby/reference/example.cxx0000664000175000017500000000161412343605122021221 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/ruby/reference/index.html0000664000175000017500000000632312343605122021041 0ustar williamwilliam SWIG:Examples:ruby:reference SWIG/Examples/ruby/reference/

    C++ Reference Handling

    This example tests SWIG's handling of C++ references. Since C++ references are closely related to pointers (as both refer to a location in memory), SWIG simply collapses all references into pointers when creating wrappers.

    Some examples

    References are most commonly used as function parameter. For example, you might have an operator like this:
    Vector operator+(const Vector &a, const Vector &b) {
       Vector result;
       result.x = a.x + b.x;
       result.y = a.y + b.y;
       result.z = a.z + b.z;
       return result;
    }
    
    or a function:
    Vector addv(const Vector &a, const Vector &b) {
       Vector result;
       result.x = a.x + b.x;
       result.y = a.y + b.y;
       result.z = a.z + b.z;
       return result;
    }
    
    In these cases, SWIG transforms everything into a pointer and creates a wrapper that looks like this:
    Vector wrap_addv(Vector *a, Vector *b) {
        return addv(*a,*b);
    }
    
    Occasionally, a reference is used as a return value of a function when the return result is to be used as an lvalue in an expression. The prototypical example is an operator like this:
    Vector &operator[](int index);
    
    or a method:
    Vector &get(int index);
    
    For functions returning references, a wrapper like this is created:
    Vector *wrap_Object_get(Object *self, int index) {
        Vector &result = self->get(index);
        return &result;
    }
    
    The following header file contains some class definitions with some operators and use of references.

    SWIG Interface

    SWIG does NOT support overloaded operators so it can not directly build an interface to the classes in the above file. However, a number of workarounds can be made. For example, an overloaded operator can be stuck behind a function call such as the addv() function above. Array access can be handled with a pair of set/get functions like this:
    class VectorArray {
    public:
     ...
       %addmethods {
        Vector &get(int index) {
          return (*self)[index];
        }
        void set(int index, Vector &a) {
          (*self)[index] = a;
        }
       }
       ...
    }
    
    Click here to see a SWIG interface file with these additions.

    Sample Ruby script

    Click here to see a script that manipulates some C++ references.

    Notes:

    • C++ references primarily provide notational convenience for C++ source code. However, Ruby only supports the 'x.a' notation so it doesn't much matter.

    • When a program returns a reference, a pointer is returned. Unlike return by value, memory is not allocated to hold the return result.

    • SWIG has particular trouble handling various combinations of references and pointers. This is side effect of an old parsing scheme and type representation that will be replaced in future versions.

    swig-3.0.2/Examples/ruby/reference/Makefile0000664000175000017500000000110012343605122020470 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/reference/runme.rb0000664000175000017500000000231112343605122020510 0ustar williamwilliam# file: runme.rb # This file illustrates the manipulation of C++ references in Ruby. require 'example' # ----- Object creation ----- print "Creating some objects:\n" a = Example::Vector.new(3,4,5) b = Example::Vector.new(10,11,12) print " Created ", a.print, "\n" print " Created ", b.print, "\n" # ----- Call an overloaded operator ----- # This calls the wrapper we placed around # # operator+(const Vector &a, const Vector &) # # It returns a new allocated object. print "Adding a+b\n" c = Example::addv(a, b) print " a+b = ", c.print, "\n" # ----- Create a vector array ----- print "Creating an array of vectors\n" va = Example::VectorArray.new(10) print " va = #{va}\n" # ----- 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(2, Example::addv(a,b)) c = Example::addv(a,b) va.set(3, c) =begin commented out due to GC issue # Get some values from the array print "Getting some array values\n" for i in 0...5 print " va(#{i}) = ", va.get(i).print, "\n" end # Watch under resource meter to check on this print "Making sure we don't leak memory.\n" for i in 0...1000000 c = va.get(i % 10) end =end swig-3.0.2/Examples/ruby/mark_function/0000775000175000017500000000000012343605122017741 5ustar williamwilliamswig-3.0.2/Examples/ruby/mark_function/example.h0000664000175000017500000000154612343605122021553 0ustar williamwilliam#ifndef _EXAMPLE_H_ #define _EXAMPLE_H_ #include #include class Animal { protected: std::string name_; public: // Construct an animal with a name Animal(const char* name); // Destruct an animal ~Animal(); // Return the animal's name const char* get_name() const; }; class Zoo { private: typedef std::vector AnimalsType; typedef AnimalsType::iterator IterType; protected: AnimalsType animals; public: Zoo(); ~Zoo(); /* Create a new animal */ static Animal* create_animal(const char* name); /* Add a new animal to the zoo */ void add_animal(Animal* animal); /* Remove an animal from the zoo */ Animal* remove_animal(size_t i); /* Return the number of animals in the zoo */ size_t get_num_animals() const; /* Return a pointer to the ith animal */ Animal* get_animal(size_t i) const; }; #endif /*_EXAMPLE_H_*/ swig-3.0.2/Examples/ruby/mark_function/example.i0000664000175000017500000000136112343605122021547 0ustar williamwilliam%module example %{ #include "example.h" %} /* Tell SWIG that create_animal creates a new object */ %newobject Zoo::create_animal; /* Keep track of mappings between C/C++ structs/classes and Ruby objects so we can implement a mark function. */ %trackobjects; /* Specify the mark function */ %markfunc Zoo "mark_Zoo"; %include "example.h" %header %{ static void mark_Zoo(void* ptr) { Zoo* zoo = (Zoo*) ptr; /* Loop over each object and tell the garbage collector that we are holding a reference to them. */ int count = zoo->get_num_animals(); for(int i = 0; i < count; ++i) { Animal* animal = zoo->get_animal(i); VALUE object = SWIG_RubyInstanceFor(animal); if (object != Qnil) { rb_gc_mark(object); } } } %} swig-3.0.2/Examples/ruby/mark_function/example.cxx0000664000175000017500000000167012343605122022124 0ustar williamwilliam#include "example.h" Animal::Animal(const char* name) : name_(name) { } Animal::~Animal() { name_ = "Destroyed"; } /* Return the animal's name */ const char* Animal::get_name() const { return name_.c_str(); } Zoo::Zoo() { } Zoo::~Zoo() { return; } /* Create a new animal. */ Animal* Zoo::create_animal(const char* name) { return new Animal(name); } /* Add a new animal to the zoo. */ void Zoo::add_animal(Animal* animal) { animals.push_back(animal); } Animal* Zoo::remove_animal(size_t i) { /* Note a production implementation should check for out of range errors. */ Animal* result = this->animals[i]; IterType iter = this->animals.begin(); std::advance(iter, i); this->animals.erase(iter); return result; } /* Return the number of animals in the zoo. */ size_t Zoo::get_num_animals() const { return animals.size(); } /* Return a pointer to the ith animal */ Animal* Zoo::get_animal(size_t i) const { return animals[i]; } swig-3.0.2/Examples/ruby/mark_function/example.dsp0000664000175000017500000001225712343605122022113 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/ruby/mark_function/Makefile0000664000175000017500000000110012343605122021371 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/mark_function/runme.rb0000664000175000017500000000065512343605122021422 0ustar williamwilliamrequire 'example' # create a zoo zoo = Example::Zoo.new begin # Add in an couple of animals tiger1 = Example::Animal.new("tiger1") zoo.add_animal(tiger1) # unset variables to force gc tiger = nil end GC.start # Now get the tiger again tiger2 = zoo.get_animal(0) # Call a method to verify the animal is still valid and not gc'ed if tiger2.get_name != "tiger1" raise RuntimeError, "Wrong animal name" end swig-3.0.2/Examples/ruby/functor/0000775000175000017500000000000012343605122016562 5ustar williamwilliamswig-3.0.2/Examples/ruby/functor/example.i0000664000175000017500000000111312343605122020363 0ustar williamwilliam/* File : example.i */ %module example %inline %{ // From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514 template class Sum { T res; public: Sum(T i = 0) : res(i) { } void operator() (T x) { res += x; } T result() const { return res; } }; %} /** * Rename the application operator to call() for Ruby. * Note: this is normally automatic, but if you had to do it yourself * you would use this directive: * * %rename(call) *::operator(); */ // Instantiate a few versions %template(IntSum) Sum; %template(DoubleSum) Sum; swig-3.0.2/Examples/ruby/functor/Makefile0000664000175000017500000000104712343605122020224 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/functor/runme.rb0000664000175000017500000000052612343605122020240 0ustar williamwilliam# Operator overloading example require 'example' a = Example::IntSum.new(0) b = Example::DoubleSum.new(100.0) # Use the objects. They should be callable just like a normal # Ruby function. (0..100).each do |i| a.call(i) # note: function call b.call(Math.sqrt(i)) # note: function call end puts a.result puts b.result swig-3.0.2/Examples/ruby/check.list0000664000175000017500000000034712343605122017060 0ustar williamwilliam# see top-level Makefile.in class constants enum #free_function funcptr funcptr2 functor hashargs import import_template java mark_function multimap operator overloading pointer reference simple std_vector template value variables swig-3.0.2/Examples/ruby/funcptr2/0000775000175000017500000000000012343605122016645 5ustar williamwilliamswig-3.0.2/Examples/ruby/funcptr2/example.c0000664000175000017500000000037012343605122020444 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/ruby/funcptr2/example.h0000664000175000017500000000026312343605122020452 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/ruby/funcptr2/example.i0000664000175000017500000000053712343605122020457 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %callback("%(upper)s"); int add(int, int); int sub(int, int); int mul(int, int); %nocallback; extern int (*funcvar)(int,int); swig-3.0.2/Examples/ruby/funcptr2/Makefile0000664000175000017500000000103112343605122020300 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/funcptr2/runme.rb0000664000175000017500000000122412343605122020317 0ustar williamwilliamrequire 'example' a = 37 b = 42 # Now call our C function with a bunch of callbacks puts "Trying some C callback functions" puts " a = #{a}" puts " b = #{b}" puts " ADD(a,b) = #{Example.do_op(a,b,Example::ADD)}" puts " SUB(a,b) = #{Example.do_op(a,b,Example::SUB)}" puts " MUL(a,b) = #{Example.do_op(a,b,Example::MUL)}" puts "Here is what the C callback function objects look like in Ruby" puts " ADD = #{Example::ADD}" puts " SUB = #{Example::SUB}" puts " MUL = #{Example::MUL}" puts "Call the functions directly..." puts " add(a,b) = #{Example.add(a,b)}" puts " sub(a,b) = #{Example.sub(a,b)}" swig-3.0.2/Examples/ruby/overloading/0000775000175000017500000000000012343605122017413 5ustar williamwilliamswig-3.0.2/Examples/ruby/overloading/example.h0000664000175000017500000000132512343605122021220 0ustar williamwilliam#ifndef EXAMPLE_H #define EXAMPLE_H class Bar { public: Bar(); Bar(const Bar&); Bar(double); Bar(double, char *); Bar(int, int); Bar(char *); Bar(long); Bar(int); Bar(Bar *); void foo(const Bar&); void foo(double); void foo(double, char *); void foo(int, int); void foo(char *); void foo(long); void foo(int); void foo(Bar *); void spam(int x, int y=2, int z=3); void spam(double x, int y=2, int z=3); }; void foo(const Bar&); void foo(double); void foo(double, char *); void foo(int, int); void foo(char *); void foo(int); void foo(long); void foo(Bar *); void spam(int x, int y=2, int z=3); void spam(double x, int y=2, int z=3); #endif swig-3.0.2/Examples/ruby/overloading/example.i0000664000175000017500000000105312343605122021217 0ustar williamwilliam%module example %{ #include "example.h" %} /** * These overloaded declarations conflict with other overloads (as far as * SWIG's Ruby module's implementation for overloaded methods is concerned). * One option is use the %rename directive to rename the conflicting methods; * here, we're just using %ignore to avoid wrapping some of the overloaded * functions altogether. */ %ignore Bar::Bar(Bar *); %ignore Bar::Bar(long); %ignore Bar::foo(const Bar&); %ignore Bar::foo(long); %ignore ::foo(const Bar&); %ignore ::foo(int); %include example.h swig-3.0.2/Examples/ruby/overloading/example.cxx0000664000175000017500000000643212343605122021577 0ustar williamwilliam#include #include "example.h" // Overloaded constructors for class Bar Bar::Bar() { std::cout << "Called Bar::Bar()" << std::endl; } Bar::Bar(const Bar&) { std::cout << "Called Bar::Bar(const Bar&)" << std::endl; } Bar::Bar(double x) { std::cout << "Called Bar::Bar(double) with x = " << x << std::endl; } Bar::Bar(double x, char *y) { std::cout << "Called Bar::Bar(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; } Bar::Bar(int x, int y) { std::cout << "Called Bar::Bar(int, int) with x, y = " << x << ", " << y << std::endl; } Bar::Bar(char *x) { std::cout << "Called Bar::Bar(char *) with x = \"" << x << "\"" << std::endl; } Bar::Bar(int x) { std::cout << "Called Bar::Bar(int) with x = " << x << std::endl; } Bar::Bar(long x) { std::cout << "Called Bar::Bar(long) with x = " << x << std::endl; } Bar::Bar(Bar *x) { std::cout << "Called Bar::Bar(Bar *) with x = " << x << std::endl; } // Overloaded member functions void Bar::foo(const Bar& x) { std::cout << "Called Bar::foo(const Bar&) with &x = " << &x << std::endl; } void Bar::foo(double x) { std::cout << "Called Bar::foo(double) with x = " << x << std::endl; } void Bar::foo(double x, char *y) { std::cout << "Called Bar::foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; } void Bar::foo(int x, int y) { std::cout << "Called Bar::foo(int, int) with x, y = " << x << ", " << y << std::endl; } void Bar::foo(char *x) { std::cout << "Called Bar::foo(char *) with x = \"" << x << "\"" << std::endl; } void Bar::foo(int x) { std::cout << "Called Bar::foo(int) with x = " << x << std::endl; } void Bar::foo(long x) { std::cout << "Called Bar::foo(long) with x = " << x << std::endl; } void Bar::foo(Bar *x) { std::cout << "Called Bar::foo(Bar *) with x = " << x << std::endl; } void Bar::spam(int x, int y, int z) { std::cout << "Called Bar::spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; } void Bar::spam(double x, int y, int z) { std::cout << "Called Bar::spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; } // Overloaded global methods void foo(const Bar& x) { std::cout << "Called foo(const Bar& x) with &x = " << &x << std::endl; } void foo(double x) { std::cout << "Called foo(double) with x = " << x << std::endl; } void foo(double x, char *y) { std::cout << "Called foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; } void foo(int x, int y) { std::cout << "Called foo(int, int) with x, y = " << x << ", " << y << std::endl; } void foo(char *x) { std::cout << "Called foo(char *) with x = \"" << x << "\"" << std::endl; } void foo(int x) { std::cout << "Called foo(int) with x = " << x << std::endl; } void foo(long x) { std::cout << "Called foo(long) with x = " << x << std::endl; } void foo(Bar *x) { std::cout << "Called foo(Bar *) with x = " << x << std::endl; } // Overloaded global spam() functions void spam(int x, int y, int z) { std::cout << "Called spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; } void spam(double x, int y, int z) { std::cout << "Called spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; } swig-3.0.2/Examples/ruby/overloading/Makefile0000664000175000017500000000110012343605122021043 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/overloading/runme.rb0000664000175000017500000000347212343605122021074 0ustar williamwilliamrequire 'example' # This should invoke foo(double) Example.foo(3.14159) # This should invoke foo(double, char *) Example.foo(3.14159, "Pi") # This should invoke foo(int, int) Example.foo(3, 4) # This should invoke foo(char *) Example.foo("This is a test") # This should invoke foo(long) Example.foo(42) # This should invoke Bar::Bar() followed by foo(Bar *) Example.foo(Example::Bar.new) # Skip a line puts "" # Each of the following three calls should invoke spam(int, int, int) Example.spam(3) Example.spam(3, 4) Example.spam(3, 4, 5) # Skip a line puts "" # Each of the following three calls should invoke spam(double, int, int) Example.spam(3.0) Example.spam(3.0, 4) Example.spam(3.0, 4, 5) # Skip a line puts "" # This should invoke Bar::Bar(double) Example::Bar.new(3.14159) # This should invoke Bar::Bar(double, char *) Example::Bar.new(3.14159, "Pi") # This should invoke Bar::Bar(int, int) Example::Bar.new(3, 4) # This should invoke Bar::Bar(char *) Example::Bar.new("This is a test") # This should invoke Bar::Bar(int) Example::Bar.new(42) # This should invoke Bar::Bar() for the input argument, # followed by Bar::Bar(const Bar&). Example::Bar.new(Example::Bar.new) # Skip a line puts "" # Construct a new Bar instance (invokes Bar::Bar()) bar = Example::Bar.new # This should invoke Bar::foo(double) bar.foo(3.14159) # This should invoke Bar::foo(double, char *) bar.foo(3.14159, "Pi") # This should invoke Bar::foo(int, int) bar.foo(3, 4) # This should invoke Bar::foo(char *) bar.foo("This is a test") # This should invoke Bar::foo(int) bar.foo(42) # This should invoke Bar::Bar() to construct the input # argument, followed by Bar::foo(Bar *). bar.foo(Example::Bar.new) # This should invoke Bar::spam(int x, int y, int z) bar.spam(1) # This should invoke Bar::spam(double x, int y, int z) bar.spam(3.14159) swig-3.0.2/Examples/ruby/hashargs/0000775000175000017500000000000012343605122016702 5ustar williamwilliamswig-3.0.2/Examples/ruby/hashargs/example.i0000664000175000017500000000201712343605122020507 0ustar williamwilliam%module example %typemap(in) (int nattributes, const char **names, const int *values) (VALUE keys_ary, int i, VALUE key, VALUE val) { Check_Type($input, T_HASH); $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL)); $2 = NULL; $3 = NULL; if ($1 > 0) { $2 = (char **) malloc($1*sizeof(char *)); $3 = (int *) malloc($1*sizeof(int)); keys_ary = rb_funcall($input, rb_intern("keys"), 0, NULL); for (i = 0; i < $1; i++) { key = rb_ary_entry(keys_ary, i); val = rb_hash_aref($input, key); Check_Type(key, T_STRING); Check_Type(val, T_FIXNUM); $2[i] = StringValuePtr(key); $3[i] = NUM2INT(val); } } } %typemap(freearg) (int nattributes, const char **names, const int *values) { free((void *) $2); free((void *) $3); } %inline %{ void setVitalStats(const char *person, int nattributes, const char **names, const int *values) { int i; printf("Name: %s\n", person); for (i = 0; i < nattributes; i++) { printf(" %s => %d\n", names[i], values[i]); } } %} swig-3.0.2/Examples/ruby/hashargs/Makefile0000664000175000017500000000110212343605122020334 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/hashargs/runme.rb0000664000175000017500000000076112343605122020361 0ustar williamwilliamrequire 'example' include Example # Pass arguments in as one or more key-value pairs setVitalStats("Fred", 'age' => 42, 'weight' => 270 ) # The order doesn't matter setVitalStats("Sally", 'age' => 29, 'weight' => 115, 'height' => 72 ) # Can also pass a hash directly params = { 'ears' => 2, 'eyes' => 2 } setVitalStats("Bob", params) # An empty hash is fine too setVitalStats("Joe", {}) swig-3.0.2/Examples/ruby/index.html0000664000175000017500000000473112343605122017104 0ustar williamwilliam SWIG:Examples:ruby

    SWIG Ruby Examples

    The following examples illustrate the use of SWIG with Ruby.

    • simple. A minimal example showing how SWIG can be used to wrap a C function, a global variable, and a constant.
    • constants. This shows how preprocessor macros and certain C declarations are turned into constants.
    • variables. An example showing how to access C global variables from Ruby.
    • value. How to pass and return structures by value.
    • class. Wrapping a simple C++ class.
    • reference. C++ references.
    • pointer. Simple pointer handling.
    • funcptr. Pointers to functions.
    • enum. Enumeration.

    Compilation Issues

    • To create a Ruby extension, SWIG is run with the following options:
      % swig -ruby interface.i
      
    • Please see the Windows page in the main manual for information on using the examples on Windows.

    • On Unix the compilation of examples is done using the file Example/Makefile. This makefile performs a manual module compilation which is platform specific. Typically, the steps look like this (Linux):
      % swig -ruby interface.i
      % gcc -fpic -c interface_wrap.c -I/usr/local/lib/ruby/1.4/i686-linux
      % gcc -shared interface_wrap.o $(OBJS) -o interface.so 
      % ruby
      require 'interface'
      Interface.blah(...)
      ...
      
    • The politically "correct" way to compile a Ruby extension is to follow the steps described README.EXT in Ruby distribution:

      1. Create a file called extconf.rb that looks like the following:
        require 'mkmf'
        create_makefile('interface')
        
      2. Type the following to build the extension:
        % ruby extconf.rb
        % make
        

    Compatibility

    The examples have been extensively tested on the following platforms:
    • Linux
    Your mileage may vary. If you experience a problem, please let us know by contacting us on the mailing lists. swig-3.0.2/Examples/ruby/funcptr/0000775000175000017500000000000012343605122016563 5ustar williamwilliamswig-3.0.2/Examples/ruby/funcptr/example.c0000664000175000017500000000033012343605122020356 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } swig-3.0.2/Examples/ruby/funcptr/example.h0000664000175000017500000000026312343605122020370 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/ruby/funcptr/example.i0000664000175000017500000000052012343605122020365 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; swig-3.0.2/Examples/ruby/funcptr/index.html0000664000175000017500000000366212343605122020567 0ustar williamwilliam SWIG:Examples:ruby:funcptr SWIG/Examples/ruby/funcptr/

    Pointers to Functions

    Okay, just what in the heck does SWIG do with a declaration like this?

    int do_op(int a, int b, int (*op)(int, int));
    
    Well, it creates a wrapper as usual. Of course, that does raise some questions about the third argument (the pointer to a function).

    In this case, SWIG will wrap the function pointer as it does for all other pointers. However, in order to actually call this function from a script, you will need to pass some kind of C function pointer object. In C, this is easy, you just supply a function name as an argument like this:

    /* Some callback function */
    int add(int a, int b) {
       return a+b;
    } 
    ...
    int r = do_op(x,y,add);
    
    To make this work with SWIG, you will need to do a little extra work. Specifically, you need to create some function pointer objects using the %constant directive like this:
    %constant(int (*)(int,int)) ADD = add;
    
    Now, in a script, you would do this:
    r = do_op(x,y, ADD)
    

    An Example

    Here are some files that illustrate this with a simple example:

    Notes

    • The value of a function pointer must correspond to a function written in C or C++. It is not possible to pass an arbitrary Ruby proc object in as a substitute for a C function pointer.

    • A ruby proc can be used as a C/C++ callback if you write some clever typemaps and are very careful about how you create your extension. This is an advanced topic not covered here.

    swig-3.0.2/Examples/ruby/funcptr/Makefile0000664000175000017500000000103112343605122020216 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/funcptr/runme.rb0000664000175000017500000000112312343605122020233 0ustar williamwilliam# file: runme.rb require 'example' a = 37 b = 42 # Now call our C function with a bunch of callbacks print "Trying some C callback functions\n" print " a = #{a}\n" print " b = #{b}\n" print " ADD(a,b) = ", Example::do_op(a,b,Example::ADD),"\n" print " SUB(a,b) = ", Example::do_op(a,b,Example::SUB),"\n" print " MUL(a,b) = ", Example::do_op(a,b,Example::MUL),"\n" print "Here is what the C callback function objects look like in Ruby\n" print " ADD = #{Example::ADD}\n" print " SUB = #{Example::SUB}\n" print " MUL = #{Example::MUL}\n" swig-3.0.2/Examples/ruby/java/0000775000175000017500000000000012343605122016023 5ustar williamwilliamswig-3.0.2/Examples/ruby/java/example.i0000664000175000017500000000012212343605122017623 0ustar williamwilliam%module example %include %{ #include "Example.h" %} %include Example.h swig-3.0.2/Examples/ruby/java/Makefile0000664000175000017500000000120712343605122017463 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: Example.class Example.h $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean rm -f *.class Example.h Example.class Example.h: $(SRCDIR)Example.java gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java gcjh Example.class swig-3.0.2/Examples/ruby/java/runme.rb0000664000175000017500000000046012343605122017476 0ustar williamwilliamrequire 'example' Example.JvCreateJavaVM(nil) Example.JvAttachCurrentThread(nil, nil) e1 = Example::Example.new(1) e2 = Example::Example.new(2) print e1.Add(1,2),"\n" print e1.Add(1.0,2.0),"\n" e3 = e1.Add(e1,e2) print e3.mPublicInt,"\n" print e1.Add("1","2"),"\n" Example.JvDetachCurrentThread() swig-3.0.2/Examples/ruby/java/Example.java0000664000175000017500000000075012343605122020263 0ustar williamwilliampublic class Example { public int mPublicInt; public Example() { mPublicInt = 0; } public Example(int IntVal) { mPublicInt = IntVal; } public int Add(int a, int b) { return (a+b); } public float Add(float a, float b) { return (a+b); } public String Add(String a, String b) { return (a+b); } public Example Add(Example a, Example b) { return new Example(a.mPublicInt + b.mPublicInt); } } swig-3.0.2/Examples/ruby/multimap/0000775000175000017500000000000012343605122016732 5ustar williamwilliamswig-3.0.2/Examples/ruby/multimap/example.c0000664000175000017500000000164012343605122020532 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.2/Examples/ruby/multimap/example.i0000664000175000017500000000416612343605122020546 0ustar williamwilliam%module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} %include exception.i %include typemaps.i extern int gcd(int x, int y); %typemap(in) (int argc, char *argv[]) { int i; if (TYPE($input) != T_ARRAY) { SWIG_exception(SWIG_ValueError, "Expected an array"); } $1 = RARRAY_LEN($input); if ($1 == 0) { SWIG_exception(SWIG_ValueError, "List must contain at least 1 element"); } $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++) { VALUE s = rb_ary_entry($input,i); if (TYPE(s) != T_STRING) { free($2); SWIG_exception(SWIG_ValueError, "List items must be strings"); } $2[i] = StringValuePtr(s); } $2[i] = 0; } %typemap(freearg) (int argc, char *argv[]) { free($2); } extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { if (TYPE($input) != T_STRING) { SWIG_exception(SWIG_ValueError, "Expected a string"); } $1 = StringValuePtr($input); $2 = RSTRING_LEN($input); } extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a string */ %typemap(in) (char *str, int len) { char *temp; if (TYPE($input) != T_STRING) { SWIG_exception(SWIG_ValueError,"Expected a string"); } temp = StringValuePtr($input); $2 = RSTRING_LEN($input); $1 = (char *) malloc($2+1); memmove($1,temp,$2); } /* Return the mutated string as a new object. */ %typemap(argout, fragment="output_helper") (char *str, int len) { VALUE o; o = rb_str_new($1,$2); $result = output_helper($result,o); free($1); } extern void capitalize(char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); } } extern void circle(double cx, double cy); swig-3.0.2/Examples/ruby/multimap/example.dsp0000664000175000017500000001213712343605122021101 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -ruby "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -ruby "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/ruby/multimap/Makefile0000664000175000017500000000103112343605122020365 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/multimap/runme.rb0000664000175000017500000000056412343605122020412 0ustar williamwilliam# file: runme.rb require 'example' # Call our gcd() function x = 42 y = 105 g = Example.gcd(x,y) printf "The gcd of %d and %d is %d\n",x,y,g # Call the gcdmain() function Example.gcdmain(["gcdmain","42","105"]) # Call the count function printf "%d\n",Example.count("Hello World","l") # Call the capitalize function printf "%s\n",Example.capitalize("hello world") swig-3.0.2/Examples/ruby/operator/0000775000175000017500000000000012343605122016735 5ustar williamwilliamswig-3.0.2/Examples/ruby/operator/example.h0000664000175000017500000000147312343605122020546 0ustar williamwilliam/* File : example.h */ #include class Complex { private: double rpart, ipart; public: Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { } Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { } Complex &operator=(const Complex &c) { rpart = c.rpart; ipart = c.ipart; return *this; } Complex operator+(const Complex &c) const { return Complex(rpart+c.rpart, ipart+c.ipart); } Complex operator-(const Complex &c) const { return Complex(rpart-c.rpart, ipart-c.ipart); } Complex operator*(const Complex &c) const { return Complex(rpart*c.rpart - ipart*c.ipart, rpart*c.ipart + c.rpart*ipart); } Complex operator-() const { return Complex(-rpart, -ipart); } double re() const { return rpart; } double im() const { return ipart; } }; swig-3.0.2/Examples/ruby/operator/example.i0000664000175000017500000000104012343605122020535 0ustar williamwilliam/* File : example.i */ %module example %warnfilter(SWIGWARN_IGNORE_OPERATOR_EQ); %{ #include "example.h" %} /* This header file is a little tough to handle because it has overloaded operators and constructors. We're going to try and deal with that here */ /* Grab the original header file */ %include "example.h" /* An output method that turns a complex into a short string */ %extend Complex { char *__str__() { static char temp[512]; sprintf(temp,"(%g,%g)", $self->re(), $self->im()); return temp; } }; swig-3.0.2/Examples/ruby/operator/Makefile0000664000175000017500000000112612343605122020375 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/operator/runme.rb0000664000175000017500000000063012343605122020407 0ustar williamwilliam# Operator overloading example require 'example' include Example a = Example::Complex.new(2, 3) b = Example::Complex.new(-5, 10) puts "a = #{a}" puts "b = #{b}" c = a + b puts "c = #{c}" puts "a*b = #{a*b}" puts "a-c = #{a-c}" # This should invoke Complex's copy constructor e = Example::Complex.new(a-c) e = a - c puts "e = #{e}" # Big expression f = ((a+b)*(c+b*e)) + (-a) puts "f = #{f}" swig-3.0.2/Examples/ruby/value/0000775000175000017500000000000012343605122016216 5ustar williamwilliamswig-3.0.2/Examples/ruby/value/example.c0000664000175000017500000000037512343605122020022 0ustar williamwilliam/* File : example.c */ #include "example.h" double dot_product(Vector a, Vector b) { return (a.x*b.x + a.y*b.y + a.z*b.z); } Vector vector_add(Vector a, Vector b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } swig-3.0.2/Examples/ruby/value/example.h0000664000175000017500000000011012343605122020012 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; swig-3.0.2/Examples/ruby/value/example.i0000664000175000017500000000125312343605122020024 0ustar williamwilliam// Tests SWIG's handling of pass-by-value for complex datatypes %module example %{ #include "example.h" %} /* Some functions that manipulate Vectors by value */ %inline %{ extern double dot_product(Vector a, Vector b); extern Vector vector_add(Vector a, Vector b); %} /* Include this because the vector_add() function will leak memory */ void free(void *); /* Some helper functions for our interface */ %inline %{ Vector *new_Vector(double x, double y, double z) { Vector *v = (Vector *) malloc(sizeof(Vector)); v->x = x; v->y = y; v->z = z; return v; } void vector_print(Vector *v) { printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z); } %} swig-3.0.2/Examples/ruby/value/index.html0000664000175000017500000000515112343605122020215 0ustar williamwilliam SWIG:Examples:ruby:value SWIG/Examples/ruby/value/

    Passing and Returning Structures by Value

    Occasionally, a C program will manipulate structures by value such as shown in the following code:

    /* File : example.c */
    
    typedef struct Vector {
       double x, y, z;
    } Vector;
    
    double dot_product(Vector a, Vector b) {
      return (a.x*b.x + a.y*b.y + a.z*b.z);
    }
    
    Vector vector_add(Vector a, Vector b) {
      Vector r;
      r.x = a.x + b.x;
      r.y = a.y + b.y;
      r.z = a.z + b.z;
      return r;
    }
    
    Since SWIG only knows how to manage pointers to structures (not their internal representation), the following translations are made when wrappers are created:
    double wrap_dot_product(Vector *a, Vector *b) {
        return dot_product(*a,*b);
    }
    
    Vector *wrap_vector_add(Vector *a, Vector *b) {
        Vector *r = (Vector *) malloc(sizeof(Vector));
        *r = vector_add(*a,*b);
        return r;
    }
    
    The functions are then called using pointers from the scripting language interface. It should also be noted that any function that returns a structure by value results in an implicit memory allocation. This will be a memory leak unless you take steps to free the result (see below).

    The SWIG interface

    Click here to see a SWIG interface file that wraps these two functions. In this file, there are a few essential features:
    • A wrapper for the free() function is created so that we can clean up the return result created by vector_add() function.

    • The %inline directive is used to create a few helper functions for creating new Vector objects and to print out the value (for debugging purposes).

    A Ruby Script

    Click here to see a script that uses these functions from Ruby.

    Notes

    • When the '-c++' option is used, the resulting wrapper code for the return value changes to the following:
      Vector *wrap_vector_add(Vector *a, Vector *b) {
          Vector *r = new Vector(vector_add(*a,*b));
          return r;
      }
      

    • If you define C structure (or C++ class with '-c++' option) in the interface file, the SWIG generated wrappers can automaticallyclean up the result of return-by-reference by GC.

    • Passing parameters by value like this really isn't the best C programming style. If possible, you might change your application to use pointers.

    • Similar translations are made when C++ references are used.

    swig-3.0.2/Examples/ruby/value/Makefile0000664000175000017500000000103112343605122017651 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/value/runme.rb0000664000175000017500000000131312343605122017667 0ustar williamwilliam# file: runme.rb require 'example' # Create a couple of a vectors v = Example::new_Vector(1, 2, 3) w = Example::new_Vector(10, 11, 12) print "I just created the following vectors\n" Example::vector_print(v) Example::vector_print(w) # Now call some of our functions print "\nNow I'm going to compute the dot product\n" d = Example::dot_product(v,w) print "dot product = #{d} (should be 68)\n" # Add the vectors together print "\nNow I'm going to add the vectors together\n" r = Example::vector_add(v,w) Example::vector_print(r) print "The value should be (11, 13, 15)\n" # Now I'd better clean up the return result r print "\nNow I'm going to clean up the return result\n" Example::free(r) print "Good\n" swig-3.0.2/Examples/ruby/import/0000775000175000017500000000000012343605122016414 5ustar williamwilliamswig-3.0.2/Examples/ruby/import/spam.dsp0000664000175000017500000001166012343605122020070 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=spam - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "spam.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "spam - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"spam.dll" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "spam - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"spam.dll" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "spam - Win32 Debug" # Name "spam - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\spam_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\spam.h # End Source File # End Group # Begin Source File SOURCE=.\spam.i !IF "$(CFG)" == "spam - Win32 Debug" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "spam - Win32 Release" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/ruby/import/spam.h0000664000175000017500000000063212343605122017526 0ustar williamwilliam#include "bar.h" class Spam : public Bar { public: Spam() { } ~Spam() { } virtual const char * A() const { return "Spam::A"; } const char * B() const { return "Spam::B"; } virtual Base *toBase() { return static_cast(this); } virtual Bar *toBar() { return static_cast(this); } static Spam *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/ruby/import/README0000664000175000017500000000241712343605122017300 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. Use 'ruby runme.rb' to run a test. Overview: --------- The example defines 4 different extension modules--each wrapping a separate C++ class. base.i - Base class foo.i - Foo class derived from Base bar.i - Bar class derived from Base spam.i - Spam class derived from Bar Each module uses %import to refer to another module. For example, the 'foo.i' module uses '%import base.i' to get definitions for its base class. If everything is okay, all of the modules will load properly and type checking will work correctly. Caveat: Some compilers, for example gcc-3.2.x, generate broken vtables with the inline methods in this test. This is not a SWIG problem and can usually be solved with non-inlined destructors compiled into separate shared objects/DLLs. Unix: ----- - Run make - Run the test as described above Windows: -------- - Use the Visual C++ 6 workspace file (example.dsw). Build the runtime project DLL first followed by the other 4 DLLs as they all have a dependency on the runtime DLL. The Batch build option in the Build menu is usually the easiest way to do this. Only use the Release builds not the Debug builds. - Run the test as described above swig-3.0.2/Examples/ruby/import/spam.i0000664000175000017500000000011012343605122017516 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-3.0.2/Examples/ruby/import/bar.i0000664000175000017500000000010612343605122017327 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-3.0.2/Examples/ruby/import/base.i0000664000175000017500000000006612343605122017502 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h swig-3.0.2/Examples/ruby/import/foo.dsp0000664000175000017500000001162612343605122017715 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=foo - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "foo.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "foo - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"foo.dll" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "foo - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"foo.dll" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "foo - Win32 Debug" # Name "foo - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\foo_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\foo.h # End Source File # End Group # Begin Source File SOURCE=.\foo.i !IF "$(CFG)" == "foo - Win32 Debug" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "foo - Win32 Release" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/ruby/import/base.dsp0000664000175000017500000001166012343605122020042 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=base - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "base.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "base - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"base.dll" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "base - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"base.dll" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "base - Win32 Debug" # Name "base - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\base_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\base.h # End Source File # End Group # Begin Source File SOURCE=.\base.i !IF "$(CFG)" == "base - Win32 Debug" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "base - Win32 Release" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/ruby/import/foo.i0000664000175000017500000000010512343605122017345 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-3.0.2/Examples/ruby/import/foo.h0000664000175000017500000000052312343605122017350 0ustar williamwilliam#include "base.h" class Foo : public Base { public: Foo() { } ~Foo() { } virtual const char * A() const { return "Foo::A"; } const char * B() const { return "Foo::B"; } virtual Base *toBase() { return static_cast(this); } static Foo *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/ruby/import/base.h0000664000175000017500000000044312343605122017500 0ustar williamwilliamclass Base { public: Base() { }; virtual ~Base() { }; virtual const char * A() const { return "Base::A"; } const char * B() const { return "Base::B"; } virtual Base *toBase() { return static_cast(this); } }; swig-3.0.2/Examples/ruby/import/Makefile0000664000175000017500000000143112343605122020053 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/import/runme.rb0000664000175000017500000000321412343605122020067 0ustar williamwilliam# file: runme.rb # Test various properties of classes defined in separate modules puts "Testing the %import directive" require 'base' require 'foo' require 'bar' require 'spam' # Create some objects puts "Creating some objects" a = Base::Base.new b = Foo::Foo.new c = Bar::Bar.new d = Spam::Spam.new # Try calling some methods puts "Testing some methods" puts "Should see 'Base::A' ---> #{a.A}" puts "Should see 'Base::B' ---> #{a.B}" puts "Should see 'Foo::A' ---> #{b.A}" puts "Should see 'Foo::B' ---> #{b.B}" puts "Should see 'Bar::A' ---> #{c.A}" puts "Should see 'Bar::B' ---> #{c.B}" puts "Should see 'Spam::A' ---> #{d.A}" puts "Should see 'Spam::B' ---> #{d.B}" # Try some casts puts "\nTesting some casts\n" x = a.toBase puts "Should see 'Base::A' ---> #{x.A}" puts "Should see 'Base::B' ---> #{x.B}" x = b.toBase puts "Should see 'Foo::A' ---> #{x.A}" puts "Should see 'Base::B' ---> #{x.B}" x = c.toBase puts "Should see 'Bar::A' ---> #{x.A}" puts "Should see 'Base::B' ---> #{x.B}" x = d.toBase puts "Should see 'Spam::A' ---> #{x.A}" puts "Should see 'Base::B' ---> #{x.B}" x = d.toBar puts "Should see 'Bar::B' ---> #{x.B}" puts "\nTesting some dynamic casts\n" x = d.toBase puts " Spam -> Base -> Foo : " y = Foo::Foo.fromBase(x) if y != nil puts "bad swig" else puts "good swig" end puts " Spam -> Base -> Bar : " y = Bar::Bar.fromBase(x) if y != nil puts "good swig" else puts "bad swig" end puts " Spam -> Base -> Spam : " y = Spam::Spam.fromBase(x) if y != nil puts "good swig" else puts "bad swig" end puts " Foo -> Spam : " y = Spam::Spam.fromBase(b) if y != nil puts "bad swig" else puts "good swig" end swig-3.0.2/Examples/ruby/import/example.dsw0000664000175000017500000000206412343605122020570 0ustar williamwilliamMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "bar"=.\bar.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "base"=.\base.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "foo"=.\foo.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "spam"=.\spam.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### swig-3.0.2/Examples/ruby/import/bar.h0000664000175000017500000000052312343605122017331 0ustar williamwilliam#include "base.h" class Bar : public Base { public: Bar() { } ~Bar() { } virtual const char * A() const { return "Bar::A"; } const char * B() const { return "Bar::B"; } virtual Base *toBase() { return static_cast(this); } static Bar *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/ruby/import/bar.dsp0000664000175000017500000001162612343605122017676 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=bar - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "bar.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "bar - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"bar.dll" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "bar - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"bar.dll" # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "bar - Win32 Debug" # Name "bar - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\bar_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\bar.h # End Source File # End Group # Begin Source File SOURCE=.\bar.i !IF "$(CFG)" == "bar - Win32 Debug" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "bar - Win32 Release" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on ..\..\..\swig.exe -c++ -ruby "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/ruby/variables/0000775000175000017500000000000012343605122017052 5ustar williamwilliamswig-3.0.2/Examples/ruby/variables/example.c0000664000175000017500000000456012343605122020656 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/ruby/variables/example.h0000664000175000017500000000007512343605122020660 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/ruby/variables/example.i0000664000175000017500000000202712343605122020660 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} #pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/ruby/variables/index.html0000664000175000017500000000675212343605122021061 0ustar williamwilliam SWIG:Examples:ruby:variables SWIG/Examples/ruby/variables/

    Wrapping C Global Variables

    When a C global variable appears in an interface file, SWIG tries to wrap it using a technique known as "variable linking." The idea is pretty simple---we try to create a Ruby variable (actually module method) that magically retrieves or updates the value of the underlying C variable when it is accessed. Click here to see a SWIG interface with some variable declarations in it.

    Manipulating Variables from Ruby

    Before going any further, it is important to understand some important differences between C and Ruby variables. In C, a variable is simply a name that refers to a specific location in memory. For example, when you declare a global variable 'double a' you know that somewhere in memory, 8 bytes have been set aside to hold a double and that a is bound to this location for the life of the program. In Ruby, variable creation is nothing more than a naming operation. For example, when you say 'a = 3', 'a' becomes a name that refers to some object '3'. Later on, if you say 'a = 7.5, the name 'a' is bound to an entirely different object containing the value '7.5' (the contents of the original object are not changed). The end result of this is that a variable in Ruby can refer to a virtually unlimited number of different objects (memory locations) over the lifetime of a program.

    Because of Ruby's somewhat unusual variable assignment semantics, it is not possible to directly link a C global variable into an equivalent Ruby variable. Instead, all C global variables are accessed as attributes of the module. For example, if you had a global variable

    double foo;
    
    it will be accessed in the Ruby module as Example.foo. Click here to see a script that updates and prints out the values of the variables using this technique.

    Key points

    • When a global variable has the type "char *", SWIG manages it as a character string. However, whenever the value of such a variable is set from Ruby, the old value is destroyed using free().
    • signed char and unsigned char are handled as small 8-bit integers.
    • String array variables such as 'char name[256]' are managed as Ruby strings, but when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
    • When structures and classes are used as global variables, they are mapped into pointers. Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global.

    Creating read-only variables

    The %immutable and %mutable directives can be used to specify a collection of read-only variables. For example:
    %immutable;
    int    status;
    double blah;
    ...
    %mutable;
    
    The %immutable directive remains in effect until it is explicitly disabled using the %mutable directive.

    Comments

    • Management of global variables is one of the most problematic aspects of C/C++ wrapping because the scripting interface and resulting memory management is much trickier than simply creating a wrapper function.

    swig-3.0.2/Examples/ruby/variables/Makefile0000664000175000017500000000103112343605122020505 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean swig-3.0.2/Examples/ruby/variables/runme.rb0000664000175000017500000000356412343605122020535 0ustar williamwilliam# file: runme.rb require 'example' # Try to set the values of some global variables Example.ivar = 42 Example.svar = -31000 Example.lvar = 65537 Example.uivar = 123456 Example.usvar = 61000 Example.ulvar = 654321 Example.scvar = -13 Example.ucvar = 251 Example.cvar = "S" Example.fvar = 3.14159 Example.dvar = 2.1828 Example.strvar = "Hello World" Example.iptrvar= Example.new_int(37) Example.ptptr = Example.new_Point(37,42) Example.name = "Bill" # Now print out the values of the variables puts "Variables (values printed from Ruby)" puts "ivar = #{Example.ivar}" puts "svar = #{Example.svar}" puts "lvar = #{Example.lvar}" puts "uivar = #{Example.uivar}" puts "usvar = #{Example.usvar}" puts "ulvar = #{Example.ulvar}" puts "scvar = #{Example.scvar}" puts "ucvar = #{Example.ucvar}" puts "fvar = #{Example.fvar}" puts "dvar = #{Example.dvar}" puts "cvar = #{Example.cvar}" puts "strvar = #{Example.strvar}" puts "cstrvar = #{Example.cstrvar}" puts "iptrvar = #{Example.iptrvar}" puts "name = #{Example.name}" puts "ptptr = #{Example.ptptr} (#{Example.Point_print(Example.ptptr)})" puts "pt = #{Example.pt} (#{Example.Point_print(Example.pt)})" puts "\nVariables (values printed from C)" Example.print_vars() puts "\nNow I'm going to try and modify some read only variables"; puts " Tring to set 'path'"; begin Example.path = "Whoa!" puts "Hey, what's going on?!?! This shouldn't work" rescue NameError puts "Good." end puts " Trying to set 'status'"; begin Example.status = 0 puts "Hey, what's going on?!?! This shouldn't work" rescue NameError puts "Good." end puts "\nI'm going to try and update a structure variable.\n" Example.pt = Example.ptptr puts "The new value is" Example.pt_print() puts "You should see the value #{Example.Point_print(Example.ptptr)}" swig-3.0.2/Examples/tcl/0000775000175000017500000000000012343605122014703 5ustar williamwilliamswig-3.0.2/Examples/tcl/std_vector/0000775000175000017500000000000012343605122017057 5ustar williamwilliamswig-3.0.2/Examples/tcl/std_vector/runme.tcl0000664000175000017500000000174512343605122020720 0ustar williamwilliam# file: runme.tcl catch { load ./example[info sharedlibextension] example} # Exercise IntVector set iv [IntVector] $iv push 1 $iv push 3 $iv push 5 puts "IntVector size: [$iv size] (should be 3)" puts "IntVector average: [average $iv] (should be 3.0)" puts "IntVector pop: [$iv pop] (should be 5)" puts "IntVector pop: [$iv pop] (should be 3)" puts "IntVector get 0: [$iv get 0] (should be 1)" puts "" # Exercise DoubleVector set dv [DoubleVector] $dv push 2 $dv push 4 $dv push 6 puts "DoubleVector size: [$dv size] (should be 3)" puts "DoubleVector data: [$dv get 0] [$dv get 1] [$dv get 2] (should be 2.0 4.0 6.0)" halve_in_place $dv puts "DoubleVector halved: [$dv get 0] [$dv get 1] [$dv get 2] (should be 1.0 2.0 3.0)" puts "" # Complain if unknown is called rename unknown unknown_orig proc unknown {args} { puts "ERROR: unknown called with: $args" uplevel 1 unknown_orig $args } puts "average \"1 2 3\": [average [list 1 2 3]]" swig-3.0.2/Examples/tcl/std_vector/example.h0000664000175000017500000000111612343605122020662 0ustar williamwilliam/* File : example.h */ #include #include #include #include double average(std::vector v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } std::vector half(const std::vector& v) { std::vector w(v); for (unsigned int i=0; i& v) { // would you believe this is the same as the above? std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } swig-3.0.2/Examples/tcl/std_vector/example.i0000664000175000017500000000047512343605122020672 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include stl.i /* instantiate the required template specializations */ namespace std { %template(IntVector) vector; %template(DoubleVector) vector; } /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/tcl/std_vector/Makefile0000664000175000017500000000111512343605122020515 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = my_tclsh DLTARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/contract/0000775000175000017500000000000012343605122016520 5ustar williamwilliamswig-3.0.2/Examples/tcl/contract/runme.tcl0000664000175000017500000000057712343605122020363 0ustar williamwilliam# file: runme.tcl # Try to load as a dynamic module. catch { load ./example[info sharedlibextension] example} # Call our gcd() function set x 42 set y 105 set g [gcd $x $y] puts "The gcd of $x and $y is $g" # Manipulate the Foo global variable # Output its current value puts "Foo = $Foo" # Change its value set Foo 3.1415926 # See if the change took effect puts "Foo = $Foo" swig-3.0.2/Examples/tcl/contract/example.c0000664000175000017500000000047212343605122020322 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int fact(int n) { if (n <= 0) return 1; return n*fact(n-1); } swig-3.0.2/Examples/tcl/contract/example.i0000664000175000017500000000040212343605122020321 0ustar williamwilliam/* File : example.i */ %module example %contract gcd(int x, int y) { require: x >= 0; y >= 0; } %contract fact(int n) { require: n >= 0; ensure: fact >= 1; } %inline %{ extern int gcd(int x, int y); extern int fact(int n); extern double Foo; %} swig-3.0.2/Examples/tcl/contract/example.dsp0000664000175000017500000001176112343605122020671 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -tcl8 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -tcl8 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/tcl/contract/Makefile0000664000175000017500000000114212343605122020156 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/class/0000775000175000017500000000000012343605122016010 5ustar williamwilliamswig-3.0.2/Examples/tcl/class/runme.tcl0000664000175000017500000000213612343605122017644 0ustar williamwilliam# file: runme.tcl # This file illustrates the high level C++ interface. # In this case C++ classes work kind of like Tk widgets catch { load ./example[info sharedlibextension] example} # ----- Object creation ----- puts "Creating some objects:" Circle c 10 puts " Created circle [c cget -this]" Square s 10 puts " Created square [s cget -this]" # ----- Access a static member ----- puts "\nA total of $Shape_nshapes shapes were created" # ----- Member data access ----- # Set the location of the object c configure -x 20 -y 30 s configure -x -10 -y 5 puts "\nHere is their current position:" puts " Circle = ([c cget -x], [c cget -y])" puts " Square = ([s cget -x], [s cget -y])" # ----- Call some methods ----- puts "\nHere are some properties of the shapes:" foreach o "c s" { puts " [$o cget -this]" puts " area = [$o area]" puts " perimeter = [$o perimeter]" } # ----- Delete everything ----- puts "\nGuess I'll clean up now" # Note: this invokes the virtual destructor rename c "" rename s "" puts "$Shape_nshapes shapes remain" puts "Goodbye" swig-3.0.2/Examples/tcl/class/example.h0000664000175000017500000000107612343605122017620 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/tcl/class/example.i0000664000175000017500000000021512343605122017613 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/tcl/class/example.cxx0000664000175000017500000000065012343605122020170 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/tcl/class/index.html0000664000175000017500000001120212343605122020001 0ustar williamwilliam SWIG:Examples:tcl:class SWIG/Examples/tcl/class/

    Wrapping a simple C++ class

    This example illustrates the most primitive form of C++ class wrapping performed by SWIG. In this case, C++ classes are simply transformed into a collection of C-style functions that provide access to class members.

    The C++ Code

    Suppose you have some C++ classes described by the following (and admittedly lame) header file:
    /* File : example.h */
    
    class Shape {
    public:
      Shape() {
        nshapes++;
      }
      virtual ~Shape() {
        nshapes--;
      }
      double  x, y;
      void    move(double dx, double dy);
      virtual double area() = 0;
      virtual double perimeter() = 0;
      static  int nshapes;
    };
    
    class Circle : public Shape {
    private:
      double radius;
    public:
      Circle(double r) : radius(r) { }
      virtual double area();
      virtual double perimeter();
    };
    
    class Square : public Shape {
    private:
      double width;
    public:
      Square(double w) : width(w) { }
      virtual double area();
      virtual double perimeter();
    };
    

    The SWIG interface

    A simple SWIG interface for this can be built by simply grabbing the header file like this:
    /* File : example.i */
    %module example
    
    %{
    #include "example.h"
    %}
    
    /* Let's just grab the original header file here */
    %include "example.h"
    
    Note: when creating a C++ extension, you must run SWIG with the -c++ option like this:
    % swig -c++ -tcl example.i
    

    Some sample Tcl scripts

    SWIG performs two forms of C++ wrapping-- a low level interface and a high level widget-like interface.
    • Click here to see a script that calls the C++ functions using the low-level interface.
    • Click here to see the same script written with the high-level interface.

    Key points

    • The low-level C++ interface works like this:

      • To create a new object, you call a constructor like this:
        set c [new_Circle 10.0]
        

      • To access member data, a pair of accessor functions are used. For example:
        Shape_x_set $c 15        ;# Set member data
        set x [Shape_x_get $c]   ;# Get member data
        
        Note: when accessing member data, the name of the base class must be used such as Shape_x_get

      • To invoke a member function, you simply do this
        puts "The area is [Shape_area $c]"
        

      • Type checking knows about the inheritance structure of C++. For example:
        Shape_area $c       # Works (c is a Shape)
        Circle_area $c      # Works (c is a Circle)
        Square_area $c      # Fails (c is definitely not a Square)
        

      • To invoke a destructor, simply do this
        delete_Shape $c     # Deletes a shape
        

      • Static member variables are wrapped as C global variables. For example:
        set n $Shape_nshapes    # Get a static data member
        set Shapes_nshapes 13   # Set a static data member
        

    • The high-level interface works like a Tk widget

      • To create a new object, you call a constructor like this:
        Circle c 10      # c becomes a name for the Circle object
        

      • To access member data, use cget and configure methods. For example:
        c configure -x 15        ;# Set member data
        set x [c cget -x]        ;# Get member data
        

      • To invoke a member function, you simply do this
        puts "The area is [c area]"
        

      • To invoke a destructor, simply destroy the object name like this:
        rename c ""         # c goes away
        

      • Static member variables are wrapped as C global variables. For example:
        set n $Shape_nshapes    # Get a static data member
        set Shapes_nshapes 13   # Set a static data member
        

    General Comments

    • The low-level function interface is much faster than the high-level interface. In fact, all the higher level interface does is call functions in the low-level interface.
    • SWIG does know how to properly perform upcasting of objects in an inheritance hierarchy (including multiple inheritance). Therefore it is perfectly safe to pass an object of a derived class to any function involving a base class.
    • C++ Namespaces - %nspace isn't yet supported for Tcl.

    swig-3.0.2/Examples/tcl/class/example.dsp0000664000175000017500000001210112343605122020146 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/tcl/class/Makefile0000664000175000017500000000107712343605122017455 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/class/runme2.tcl0000664000175000017500000000323312343605122017725 0ustar williamwilliam# file: runme2.tcl # This file illustrates the low-level C++ interface # created by SWIG. In this case, all of our C++ classes # get converted into function calls. catch { load ./example[info sharedlibextension] example} # ----- Object creation ----- puts "Creating some objects:" set c [new_Circle 10] puts " Created circle $c" set s [new_Square 10] puts " Created square $s" # ----- Access a static member ----- puts "\nA total of $Shape_nshapes shapes were created" # ----- Member data access ----- # Set the location of the object # Note: the base class must be used since that's where x and y # were declared. Shape_x_set $c 20 Shape_y_set $c 30 Shape_x_set $s -10 Shape_y_set $s 5 puts "\nHere is their current position:" puts " Circle = ([Shape_x_get $c], [Shape_y_get $c])" puts " Square = ([Shape_x_get $s], [Shape_y_get $s])" # ----- Call some methods ----- puts "\nHere are some properties of the shapes:" foreach o "$c $s" { puts " $o" puts " area = [Shape_area $o]" puts " perimeter = [Shape_perimeter $o]" } # Notice how the Shape_area() and Shape_perimeter() functions really # invoke the appropriate virtual method on each object. # ----- Try to cause a type error ----- puts "\nI'm going to try and break the type system" if { [catch { # Bad script! Square_area $c # Try to invoke Square method on a Circle puts " Bad bad SWIG!" }]} { puts " Well, it didn't work. Good SWIG." } # ----- Delete everything ----- puts "\nGuess I'll clean up now" # Note: this invokes the virtual destructor delete_Shape $c delete_Shape $s puts "$Shape_nshapes shapes remain" puts "Goodbye" swig-3.0.2/Examples/tcl/pointer/0000775000175000017500000000000012343605122016363 5ustar williamwilliamswig-3.0.2/Examples/tcl/pointer/runme.tcl0000664000175000017500000000164312343605122020221 0ustar williamwilliam# file: runme.tcl catch { load ./example[info sharedlibextension] example} # First create some objects using the pointer library. puts "Testing the pointer library" set a [new_intp] set b [new_intp] set c [new_intp] ;# Memory for result intp_assign $a 37 intp_assign $b 42 puts " a = $a" puts " b = $b" puts " c = $c" # Call the add() function with some pointers add $a $b $c # Now get the result set r [intp_value $c] puts " 37 + 42 = $r" # Clean up the pointers delete_intp $a delete_intp $b delete_intp $c # Now try the typemap library # This should be much easier. Now how it is no longer # necessary to manufacture pointers. puts "Trying the typemap library" set r [sub 37 42] puts " 37 - 42 = $r" # Now try the version with multiple return values puts "Testing multiple return values" set qr [divide 42 37] set q [lindex $qr 0] set r [lindex $qr 1] puts " 42/37 = $q remainder $r" swig-3.0.2/Examples/tcl/pointer/example.c0000664000175000017500000000036112343605122020162 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void sub(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.2/Examples/tcl/pointer/example.i0000664000175000017500000000117712343605122020176 0ustar williamwilliam/* File : example.i */ %module example %{ extern void add(int *, int *, int *); extern void sub(int *, int *, int *); extern int divide(int, int, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void sub(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); swig-3.0.2/Examples/tcl/pointer/index.html0000664000175000017500000000661412343605122020367 0ustar williamwilliam SWIG:Examples:tcl:pointer SWIG/Examples/tcl/pointer/

    Simple Pointer Handling

    This example illustrates a couple of techniques for handling simple pointers in SWIG. The prototypical example is a C function that operates on pointers such as this:

    void add(int *x, int *y, int *r) { 
        *r = *x + *y;
    }
    
    By default, SWIG wraps this function exactly as specified and creates an interface that expects pointer objects for arguments. The only problem is how does one go about creating these objects from a script?

    Possible Solutions

    • Write some helper functions to explicitly create objects. For example:
      int *new_int(int ivalue) {
        int *i = (int *) malloc(sizeof(ivalue));
        *i = ivalue;
        return i;
      }
      int get_int(int *i) {
        return *i;
      }
      
      void delete_int(int *i) {
        free(i);
      }
      
      Now, in a script you would do this:
      set a [new_int 37]
      set b [new_int 42]
      set c [new_int 0]
      add $a $b $c
      set r [get_int $c]
      puts "Result = $r"
      delete_int $a
      delete_int $b
      delete_int $c
      

    • Use the SWIG pointer library. For example, in the interface file you would do this:
      %include "pointer.i"
      
      set a [ptrcreate int 37]
      set b [ptrcreate int 42]
      set c [ptrcreate int]
      add $a $b $c
      set r [ptrvalue $c]
      puts "Result = $r"
      ptrfree $a
      ptrfree $b
      ptrfree $c
      
      The advantage to using the pointer library is that it unifies some of the helper functions behind a common set of names. For example, the same set of functions work with int, double, float, and other fundamental types.

    • Use the SWIG typemap library. This library allows you to completely change the way arguments are processed by SWIG. For example:
      %include "typemaps.i"
      void add(int *INPUT, int *INPUT, int *OUTPUT);
      
      And in a script:
      set r [add 37 42]
      puts "Result = $r"
      
      Needless to say, this is substantially easier.

    • A final alternative is to use the typemaps library in combination with the %apply directive. This allows you to change the names of parameters that behave as input or output parameters. For example:
      %include "typemaps.i"
      %apply int *INPUT {int *x, int *y};
      %apply int *OUTPUT {int *r};
      
      void add(int *x, int *y, int *r);
      void sub(int *x, int *y, int *r);
      void mul(int *x, int *y, int *r);
      ... etc ...
      

    Example

    The following example illustrates the use of these features for pointer extraction.

    Notes

    • Since pointers are used for so many different things (arrays, output values, etc...) the complexity of pointer handling can be as complicated as you want to make it.

    • More documentation on the typemaps.i and pointer.i library files can be found in the SWIG user manual. The files also contain documentation.

    • The pointer.i library is designed primarily for convenience. If you are concerned about performance, you probably want to use a different approach.

    swig-3.0.2/Examples/tcl/pointer/Makefile0000664000175000017500000000105312343605122020022 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/enum/0000775000175000017500000000000012343605122015647 5ustar williamwilliamswig-3.0.2/Examples/tcl/enum/runme.tcl0000664000175000017500000000125212343605122017501 0ustar williamwilliam# file: runme.tcl catch { load ./example[info sharedlibextension] example} # ----- Object creation ----- # Print out the value of some enums puts "*** color ***" puts " RED = $RED" puts " BLUE = $BLUE" puts " GREEN = $GREEN" puts "\n*** Foo::speed ***" puts " Foo_IMPULSE = $Foo_IMPULSE" puts " Foo_WARP = $Foo_WARP" puts " Foo_LUDICROUS = $Foo_LUDICROUS" puts "\nTesting use of enums with functions\n" enum_test $RED $Foo_IMPULSE enum_test $BLUE $Foo_WARP enum_test $GREEN $Foo_LUDICROUS enum_test 1234 5678 puts "\nTesting use of enum with class method" Foo f f enum_test $Foo_IMPULSE f enum_test $Foo_WARP f enum_test $Foo_LUDICROUS swig-3.0.2/Examples/tcl/enum/example.h0000664000175000017500000000031512343605122017452 0ustar williamwilliam/* File : example.h */ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } enum speed { IMPULSE, WARP, LUDICROUS }; void enum_test(speed s); }; void enum_test(color c, Foo::speed s); swig-3.0.2/Examples/tcl/enum/example.i0000664000175000017500000000021712343605122017454 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/tcl/enum/example.cxx0000664000175000017500000000150712343605122020031 0ustar williamwilliam/* File : example.c */ #include "example.h" #include void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/tcl/enum/index.html0000664000175000017500000000145312343605122017647 0ustar williamwilliam SWIG:Examples:tcl:enum SWIG/Examples/tcl/enum/

    Wrapping enumerations

    This example tests SWIG's ability to wrap enumerations. By default, SWIG converts enumeration specifications into integer constants. Further use of enumerated types are handled as integers.

    Notes

    • SWIG allows arbitrary integers to be passed as enum values. However, the result of passing an integer not corresponding to any of the values specified in the enum specification is undefined.

    swig-3.0.2/Examples/tcl/enum/Makefile0000664000175000017500000000107712343605122017314 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/simple/0000775000175000017500000000000012343605122016174 5ustar williamwilliamswig-3.0.2/Examples/tcl/simple/runme.tcl0000664000175000017500000000057712343605122020037 0ustar williamwilliam# file: runme.tcl # Try to load as a dynamic module. catch { load ./example[info sharedlibextension] example} # Call our gcd() function set x 42 set y 105 set g [gcd $x $y] puts "The gcd of $x and $y is $g" # Manipulate the Foo global variable # Output its current value puts "Foo = $Foo" # Change its value set Foo 3.1415926 # See if the change took effect puts "Foo = $Foo" swig-3.0.2/Examples/tcl/simple/example.c0000664000175000017500000000036712343605122020001 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/tcl/simple/example.i0000664000175000017500000000015212343605122017777 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.2/Examples/tcl/simple/index.html0000664000175000017500000000317212343605122020174 0ustar williamwilliam SWIG:Examples:tcl:simple SWIG/Examples/tcl/simple/

    Simple Tcl Example

    This example illustrates how you can hook Tcl to a very simple C program containing a function and a global variable.

    The C Code

    Suppose you have the following C code:
    /* File : example.c */
    
    /* A global variable */
    double Foo = 3.0;
    
    /* Compute the greatest common divisor of positive integers */
    int gcd(int x, int y) {
      int g;
      g = y;
      while (x > 0) {
        g = x;
        x = y % x;
        y = g;
      }
      return g;
    }
    

    The SWIG interface

    Here is a simple SWIG interface file:
    /* File: example.i */
    %module example
    
    extern int gcd(int x, int y);
    extern double Foo;
    

    Compilation

    1. swig -tcl example.i

    2. Compile example_wrap.c and example.c to create the extension example.so.

    Using the extension

    Click here to see a script that calls our C functions from Tcl.

    Key points

    • Use the load statement to load your extension module into Tcl. For example:
      load ./example.so
      
    • C functions work just like Tcl functions. For example:
      set g [gcd 42 105]
      
    • C global variables are accessed as Tcl variables. For example:
      set a $Foo
      set Foo $newvalue
      

    swig-3.0.2/Examples/tcl/simple/example.dsp0000664000175000017500000001176112343605122020345 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -tcl8 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -tcl8 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/tcl/simple/Makefile0000664000175000017500000000105312343605122017633 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/constants/0000775000175000017500000000000012343605122016717 5ustar williamwilliamswig-3.0.2/Examples/tcl/constants/runme.tcl0000664000175000017500000000135212343605122020552 0ustar williamwilliam# file: runme.tcl catch { load ./example[info sharedlibextension] example} puts "ICONST = $ICONST (should be 42)" puts "FCONST = $FCONST (should be 2.1828)" puts "CCONS T = $CCONST (should be 'x')" puts "CCONST2 = $CCONST2 (this should be on a separate line)" puts "SCONST = $SCONST (should be 'Hello World')" puts "SCONST2 = $SCONST2 (should be '\"Hello World\"')" puts "EXPR = $EXPR (should be 48.5484)" puts "iconst = $iconst (should be 37)" puts "fconst = $fconst (should be 3.14)" if { [catch { puts "EXTERN = $EXTERN (Arg! This shouldn't print anything)" }]} { puts "EXTERN isn't defined (good)" } if { [catch { puts "FOO = $FOO (Arg! This shouldn't print anything)" }]} { puts "FOO isn't defined (good)" } swig-3.0.2/Examples/tcl/constants/example.i0000664000175000017500000000113512343605122020524 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/tcl/constants/index.html0000664000175000017500000000346512343605122020724 0ustar williamwilliam SWIG:Examples:tcl:constants SWIG/Examples/tcl/constants/

    Wrapping C Constants

    When SWIG encounters C preprocessor macros and C declarations that look like constants, it creates Tcl variables with an identical value. Click here to see a SWIG interface with some constant declarations in it.

    Accessing Constants from Tcl

    Click here to see a script that prints out the values of the constants contained in the above file.

    Key points

    • The values of preprocessor macros are converted into Tcl read-only variables.
    • Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
    • Character constants such as 'x' are converted into strings.
    • C string literals such as "Hello World" are converted into strings.
    • Macros that are not fully defined are simply ignored. For example:
      #define EXTERN extern
      
      is ignored because SWIG has no idea what type of variable this would be.

    • Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
    • Certain C declarations involving 'const' are also turned into Tcl constants.
    • The constants that appear in a SWIG interface file do not have to appear in any sort of matching C source file since the creation of a constant does not require linkage to a stored value (i.e., a value held in a C global variable or memory location).
    • Since constants are turned into Tcl variables, you have to use the global statement when accessing from a procedure. For example:
      proc foo {} {
          global ICONST          # Some C constant
          puts $ICONST
      }
      

    swig-3.0.2/Examples/tcl/constants/Makefile0000664000175000017500000000104112343605122020353 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/reference/0000775000175000017500000000000012343605122016641 5ustar williamwilliamswig-3.0.2/Examples/tcl/reference/runme.tcl0000664000175000017500000000300512343605122020471 0ustar williamwilliam# file: runme.tcl # This file illustrates the manipulation of C++ references in Tcl catch { load ./example[info sharedlibextension] example} # ----- Object creation ----- puts "Creating some objects:" set a [new_Vector 3 4 5] set b [new_Vector 10 11 12] puts " Created [Vector_print $a]" puts " Created [Vector_print $b]" # ----- Call an overloaded operator ----- # This calls the wrapper we placed around # # operator+(const Vector &a, const Vector &) # # It returns a new allocated object. puts "Adding a+b" set c [addv $a $b] puts " a+b = [Vector_print $c]" # Note: Unless we free the result, a memory leak will occur delete_Vector $c # ----- Create a vector array ----- # Note: Using the high-level interface here puts "Creating an array of vectors" VectorArray va 10 puts " va = [va cget -this]" # ----- 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 # This will work, but it will cause a memory leak! va set 2 [addv $a $b] # The non-leaky way to do it set c [addv $a $b] va set 3 $c delete_Vector $c # Get some values from the array puts "Getting some array values" for {set i 0} {$i < 5} {incr i 1} { puts " va($i) = [Vector_print [va get $i]]" } # Watch under resource meter to check on this puts "Making sure we don't leak memory." for {set i 0} {$i < 1000000} {incr i 1} { set c [va get [expr {$i % 10}]] } # ----- Clean up ----- puts "Cleaning up" rename va "" delete_Vector $a delete_Vector $b swig-3.0.2/Examples/tcl/reference/example.h0000664000175000017500000000064512343605122020452 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { }; Vector(double x, double y, double z) : x(x), y(y), z(z) { }; friend Vector operator+(const Vector &a, const Vector &b); char *print(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.2/Examples/tcl/reference/example.i0000664000175000017500000000131412343605122020445 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module example %{ #include "example.h" %} class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.2/Examples/tcl/reference/example.cxx0000664000175000017500000000161412343605122021022 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/tcl/reference/index.html0000664000175000017500000000633312343605122020643 0ustar williamwilliam SWIG:Examples:tcl:reference SWIG/Examples/tcl/reference/

    C++ Reference Handling

    This example tests SWIG's handling of C++ references. Since C++ references are closely related to pointers (as both refer to a location in memory), SWIG simply collapses all references into pointers when creating wrappers.

    Some examples

    References are most commonly used as function parameter. For example, you might have an operator like this:
    Vector operator+(const Vector &a, const Vector &b) {
       Vector result;
       result.x = a.x + b.x;
       result.y = a.y + b.y;
       result.z = a.z + b.z;
       return result;
    }
    
    or a function:
    Vector addv(const Vector &a, const Vector &b) {
       Vector result;
       result.x = a.x + b.x;
       result.y = a.y + b.y;
       result.z = a.z + b.z;
       return result;
    }
    
    In these cases, SWIG transforms everything into a pointer and creates a wrapper that looks like this:
    Vector wrap_addv(Vector *a, Vector *b) {
        return addv(*a,*b);
    }
    
    Occasionally, a reference is used as a return value of a function when the return result is to be used as an lvalue in an expression. The prototypical example is an operator like this:
    Vector &operator[](int index);
    
    or a method:
    Vector &get(int index);
    
    For functions returning references, a wrapper like this is created:
    Vector *wrap_Object_get(Object *self, int index) {
        Vector &result = self->get(index);
        return &result;
    }
    
    The following header file contains some class definitions with some operators and use of references.

    SWIG Interface

    SWIG does NOT support overloaded operators so it can not directly build an interface to the classes in the above file. However, a number of workarounds can be made. For example, an overloaded operator can be stuck behind a function call such as the addv() function above. Array access can be handled with a pair of set/get functions like this:
    class VectorArray {
    public:
     ...
       %addmethods {
        Vector &get(int index) {
          return (*self)[index];
        }
        void set(int index, Vector &a) {
          (*self)[index] = a;
        }
       }
       ...
    }
    
    Click here to see a SWIG interface file with these additions.

    Sample Tcl scripts

    Click here to see a script that manipulates some C++ references.

    Notes:

    • C++ references primarily provide notational convenience for C++ source code. However, Tcl has neither the 'x.a' or 'x->a' notation so it doesn't much matter.

    • When a program returns a reference, a pointer is returned. Unlike return by value, memory is not allocated to hold the return result.

    • SWIG has particular trouble handling various combinations of references and pointers. This is side effect of an old parsing scheme and type representation that will be replaced in future versions.

    swig-3.0.2/Examples/tcl/reference/Makefile0000664000175000017500000000107712343605122020306 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/check.list0000664000175000017500000000022412343605122016653 0ustar williamwilliam# see top-level Makefile.in class constants contract enum funcptr import java multimap operator pointer reference simple std_vector value variables swig-3.0.2/Examples/tcl/index.html0000664000175000017500000000373012343605122016703 0ustar williamwilliam SWIG:Examples:tcl

    SWIG Tcl Examples

    The following examples illustrate the use of SWIG with Tcl.

    • simple. A minimal example showing how SWIG can be used to wrap a C function and a global variable.
    • constants. This shows how preprocessor macros and certain C declarations are turned into constants.
    • variables. How SWIG can be used to wrap C global variables.
    • value. How to pass and return structures by value.
    • class. How wrap a simple C++ class.
    • reference. C++ references.
    • pointer. Simple pointer handling.
    • funcptr. Pointers to functions.

    Compilation Issues

    • To create a Tcl extension, SWIG is run with the following options:
      % swig -tcl interface.i
      
    • Please see the Windows page in the main manual for information on using the examples on Windows.

    • The compilation of examples is done using the file Example/Makefile. This makefile performs a manual module compilation which is platform specific. Typically, the steps look like this (Linux):
      unix % swig -tcl interface.i
      unix % gcc -fpic -c interface_wrap.c -I/usr/local/include
      unix % gcc -shared interface_wrap.o $(OBJS) -o interface.so
      unix % tclsh8.3
      % load ./interface.so
      % blah ...
      

    Compatibility

    The examples have been extensively tested on the following platforms:
    • Linux
    • Solaris
    Your mileage may vary. If you experience a problem, please let us know by contacting us on the mailing lists. swig-3.0.2/Examples/tcl/funcptr/0000775000175000017500000000000012343605122016364 5ustar williamwilliamswig-3.0.2/Examples/tcl/funcptr/runme.tcl0000664000175000017500000000100212343605122020207 0ustar williamwilliam# file: runme.tcl catch { load ./example[info sharedlibextension] example} set a 37 set b 42 # Now call our C function with a bunch of callbacks puts "Trying some C callback functions" puts " a = $a" puts " b = $b" puts " ADD(a,b) = [do_op $a $b $ADD]" puts " SUB(a,b) = [do_op $a $b $SUB]" puts " MUL(a,b) = [do_op $a $b $MUL]" puts "Here is what the C callback function objects look like in Tcl" puts " ADD = $ADD" puts " SUB = $SUB" puts " MUL = $MUL" swig-3.0.2/Examples/tcl/funcptr/example.c0000664000175000017500000000037012343605122020163 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.2/Examples/tcl/funcptr/example.h0000664000175000017500000000026312343605122020171 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.2/Examples/tcl/funcptr/example.i0000664000175000017500000000056012343605122020172 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); swig-3.0.2/Examples/tcl/funcptr/index.html0000664000175000017500000000367512343605122020374 0ustar williamwilliam SWIG:Examples:tcl:funcptr SWIG/Examples/tcl/funcptr/

    Pointers to Functions

    Okay, just what in the heck does SWIG do with a declaration like this?

    int do_op(int a, int b, int (*op)(int, int));
    
    Well, it creates a wrapper as usual. Of course, that does raise some questions about the third argument (the pointer to a function).

    In this case, SWIG will wrap the function pointer as it does for all other pointers. However, in order to actually call this function from a script, you will need to pass some kind of C function pointer object. In C, this is easy, you just supply a function name as an argument like this:

    /* Some callback function */
    int add(int a, int b) {
       return a+b;
    } 
    ...
    int r = do_op(x,y,add);
    
    To make this work with SWIG, you will need to do a little extra work. Specifically, you need to create some function pointer objects using the %constant directive like this:
    %constant(int (*)(int,int)) ADD = add;
    
    Now, in a script, you would do this:
    set r [do_op $x $y $ADD]
    

    An Example

    Here are some files that illustrate this with a simple example:

    Notes

    • The value of a function pointer must correspond to a function written in C or C++. It is not possible to pass an arbitrary Tcl function object in as a substitute for a C function pointer.

    • A Tcl function can be used as a C/C++ callback if you write some clever typemaps and are very careful about how you create your extension. This is an advanced topic not covered here.

    swig-3.0.2/Examples/tcl/funcptr/Makefile0000664000175000017500000000105312343605122020023 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/java/0000775000175000017500000000000012343605122015624 5ustar williamwilliamswig-3.0.2/Examples/tcl/java/runme.tcl0000664000175000017500000000044012343605122017454 0ustar williamwilliamcatch { load ./example[info sharedlibextension] example} JvCreateJavaVM NULL JvAttachCurrentThread NULL NULL Example e1 1 Example e2 2 puts "[e1 cget -mPublicInt]" puts "[e2 cget -mPublicInt]" puts "[e2 Add 1 2]" puts "[e2 Add 1.0 2.0]" puts "[e2 Add '1' '2']" JvDetachCurrentThread swig-3.0.2/Examples/tcl/java/example.i0000664000175000017500000000012112343605122017423 0ustar williamwilliam%module example %include %{ #include "Example.h" %} %include Example.h swig-3.0.2/Examples/tcl/java/Makefile0000664000175000017500000000121012343605122017256 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: Example.class Example.h $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ TCLCXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean rm -f *.class Example.h Example.class Example.h: $(SRCDIR)Example.java gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java gcjh Example.class swig-3.0.2/Examples/tcl/java/Example.java0000664000175000017500000000075012343605122020064 0ustar williamwilliampublic class Example { public int mPublicInt; public Example() { mPublicInt = 0; } public Example(int IntVal) { mPublicInt = IntVal; } public int Add(int a, int b) { return (a+b); } public float Add(float a, float b) { return (a+b); } public String Add(String a, String b) { return (a+b); } public Example Add(Example a, Example b) { return new Example(a.mPublicInt + b.mPublicInt); } } swig-3.0.2/Examples/tcl/multimap/0000775000175000017500000000000012343605122016533 5ustar williamwilliamswig-3.0.2/Examples/tcl/multimap/runme.tcl0000664000175000017500000000056012343605122020366 0ustar williamwilliam# file: runme.tcl # Try to load as a dynamic module. catch { load ./example[info sharedlibextension] example} # Call our gcd() function set x 42 set y 105 set g [gcd $x $y] puts "The gcd of $x and $y is $g" # call the gcdmain gcdmain "gcdmain 42 105" # call count set c [count "Hello World" l] puts $c # call capitalize set c [capitalize "helloworld"] puts $c swig-3.0.2/Examples/tcl/multimap/example.c0000664000175000017500000000164012343605122020333 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.2/Examples/tcl/multimap/example.i0000664000175000017500000000344412343605122020345 0ustar williamwilliam/* File : example.i */ %module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} %include exception.i extern int gcd(int x, int y); %typemap(arginit) (int argc, char *argv[]) "$2 = 0;"; %typemap(in) (int argc, char *argv[]) { Tcl_Obj **listobjv = 0; int i; if (Tcl_ListObjGetElements(interp,$input, &$1, &listobjv) == TCL_ERROR) { SWIG_exception(SWIG_ValueError,"Expected a list"); return TCL_ERROR; } $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++) { $2[i] = Tcl_GetStringFromObj(listobjv[i],0); } $2[i] = 0; } %typemap(freearg) char *argv[] { if ($1) { free($1); } } extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { $1 = Tcl_GetStringFromObj($input,&$2); } extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a string */ %typemap(in) (char *str, int len) { char *temp; temp = Tcl_GetStringFromObj($input,&$2); $1 = (char *) malloc($2+1); memmove($1,temp,$2); } /* Return the mutated string as a new object. */ %typemap(argout) (char *str, int len) { Tcl_Obj *o; o = Tcl_NewStringObj($1,$2); Tcl_ListObjAppendElement(interp,$result,o); free($1); } extern void capitalize(char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); return TCL_ERROR; } } extern void circle(double cx, double cy); swig-3.0.2/Examples/tcl/multimap/example.dsp0000664000175000017500000001176112343605122020704 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -tcl8 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -tcl8 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/tcl/multimap/Makefile0000664000175000017500000000105312343605122020172 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/operator/0000775000175000017500000000000012343605122016536 5ustar williamwilliamswig-3.0.2/Examples/tcl/operator/runme.tcl0000664000175000017500000000073512343605122020375 0ustar williamwilliam# Operator overloading example catch { load ./example[info sharedlibextension] example} set a [Complex -args 2 3] set b [Complex -args -5 10] puts "a = $a [$a str]" puts "b = $b [$b str]" set c [$a + $b] puts "c = $c [$c str]" set d [$a * $b] puts "a*b = [$d str]" # Alternative calling convention set e [Complex_- $a $c] puts "a-c = [Complex_str $e]" set f [new_ComplexCopy $e] puts "f = [$f str]" # Call assignment operator $c = $f puts "c = [$c str]" swig-3.0.2/Examples/tcl/operator/example.h0000664000175000017500000000147312343605122020347 0ustar williamwilliam/* File : example.h */ #include class Complex { private: double rpart, ipart; public: Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { } Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { } Complex &operator=(const Complex &c) { rpart = c.rpart; ipart = c.ipart; return *this; } Complex operator+(const Complex &c) const { return Complex(rpart+c.rpart, ipart+c.ipart); } Complex operator-(const Complex &c) const { return Complex(rpart-c.rpart, ipart-c.ipart); } Complex operator*(const Complex &c) const { return Complex(rpart*c.rpart - ipart*c.ipart, rpart*c.ipart + c.rpart*ipart); } Complex operator-() const { return Complex(-rpart, -ipart); } double re() const { return rpart; } double im() const { return ipart; } }; swig-3.0.2/Examples/tcl/operator/example.i0000664000175000017500000000120612343605122020342 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* This header file is a little tough to handle because it has overloaded operators and constructors. We're going to try and deal with that here */ /* This turns the copy constructor in a function ComplexCopy() that can be called */ %rename(ComplexCopy) Complex::Complex(Complex const &); /* Now grab the original header file */ %include "example.h" /* An output method that turns a complex into a short string */ %extend Complex { char *str() { static char temp[512]; sprintf(temp,"(%g,%g)", $self->re(), $self->im()); return temp; } }; swig-3.0.2/Examples/tcl/operator/Makefile0000664000175000017500000000106312343605122020176 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/value/0000775000175000017500000000000012343605122016017 5ustar williamwilliamswig-3.0.2/Examples/tcl/value/runme.tcl0000664000175000017500000000130712343605122017652 0ustar williamwilliam# file: runme.tcl # Try to load as a dynamic module. catch { load ./example[info sharedlibextension] example} # Create a couple of a vectors set v [new_Vector 1 2 3] set w [new_Vector 10 11 12] puts "I just created the following vectors" vector_print $v vector_print $w # Now call some of our functions puts "\nNow I'm going to compute the dot product" set d [dot_product $v $w] puts "dot product = $d (should be 68)" # Add the vectors together puts "\nNow I'm going to add the vectors together" set r [vector_add $v $w] vector_print $r puts "The value should be (11,13,15)" # Now I'd better clean up the return result r puts "\nNow I'm going to clean up the return result" free $r puts "Good" swig-3.0.2/Examples/tcl/value/example.c0000664000175000017500000000037512343605122017623 0ustar williamwilliam/* File : example.c */ #include "example.h" double dot_product(Vector a, Vector b) { return (a.x*b.x + a.y*b.y + a.z*b.z); } Vector vector_add(Vector a, Vector b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } swig-3.0.2/Examples/tcl/value/example.h0000664000175000017500000000011012343605122017613 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; swig-3.0.2/Examples/tcl/value/example.i0000664000175000017500000000125312343605122017625 0ustar williamwilliam// Tests SWIG's handling of pass-by-value for complex datatypes %module example %{ #include "example.h" %} /* Some functions that manipulate Vectors by value */ %inline %{ extern double dot_product(Vector a, Vector b); extern Vector vector_add(Vector a, Vector b); %} /* Include this because the vector_add() function will leak memory */ void free(void *); /* Some helper functions for our interface */ %inline %{ Vector *new_Vector(double x, double y, double z) { Vector *v = (Vector *) malloc(sizeof(Vector)); v->x = x; v->y = y; v->z = z; return v; } void vector_print(Vector *v) { printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z); } %} swig-3.0.2/Examples/tcl/value/index.html0000664000175000017500000000524412343605122020021 0ustar williamwilliam SWIG:Examples:tcl:value SWIG/Examples/tcl/value/

    Passing and Returning Structures by Value

    Occasionally, a C program will manipulate structures by value such as shown in the following code:

    /* File : example.c */
    
    typedef struct Vector {
       double x, y, z;
    } Vector;
    
    double dot_product(Vector a, Vector b) {
      return (a.x*b.x + a.y*b.y + a.z*b.z);
    }
    
    Vector vector_add(Vector a, Vector b) {
      Vector r;
      r.x = a.x + b.x;
      r.y = a.y + b.y;
      r.z = a.z + b.z;
      return r;
    }
    
    Since SWIG only knows how to manage pointers to structures (not their internal representation), the following translations are made when wrappers are created:
    double wrap_dot_product(Vector *a, Vector *b) {
        return dot_product(*a,*b);
    }
    
    Vector *wrap_vector_add(Vector *a, Vector *b) {
        Vector *r = (Vector *) malloc(sizeof(Vector));
        *r = vector_add(*a,*b);
        return r;
    }
    
    The functions are then called using pointers from the scripting language interface. It should also be noted that any function that returns a structure by value results in an implicit memory allocation. This will be a memory leak unless you take steps to free the result (see below).

    The SWIG interface

    Click here to see a SWIG interface file that wraps these two functions. In this file, there are a few essential features:
    • A wrapper for the free() function is created so that we can clean up the return result created by vector_add() function.

    • The %inline directive is used to create a few helper functions for creating new Vector objects and to print out the value (for debugging purposes).

    A Tcl Script

    Click here to see a script that uses these functions from Tcl.

    Notes

    • When the '-c++' option is used, the resulting wrapper code for the return value changes to the following:
      Vector *wrap_vector_add(Vector *a, Vector *b) {
          Vector *r = new Vector(vector_add(*a,*b));
          return r;
      }
      
      Similarly, it would be a mistake to use the free() function from C++. A safer approach would be to write a helper function like this:
      %inline %{
         void delete_Vector(Vector *v) {
             delete v;
         }
      %}
      

    • Passing parameters by value like this really isn't the best C programming style. If possible, you might change your application to use pointers.

    • Similar translations are made when C++ references are used.

    swig-3.0.2/Examples/tcl/value/Makefile0000664000175000017500000000105312343605122017456 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/import/0000775000175000017500000000000012343605122016215 5ustar williamwilliamswig-3.0.2/Examples/tcl/import/spam.dsp0000664000175000017500000001147712343605122017677 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=spam - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "spam.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For spam: !MESSAGE !MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "spam - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"spam.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "spam - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"spam.dll" !ENDIF # Begin Target # Name "spam - Win32 Debug" # Name "spam - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\spam_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\spam.h # End Source File # End Group # Begin Source File SOURCE=.\spam.i !IF "$(CFG)" == "spam - Win32 Debug" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "spam - Win32 Release" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/tcl/import/runme.tcl0000664000175000017500000000371012343605122020050 0ustar williamwilliam# file: runme.tcl # Test various properties of classes defined in separate modules puts "Testing the %import directive" catch { load ./base[info sharedlibextension] base} catch { load ./foo[info sharedlibextension] foo} catch { load ./bar[info sharedlibextension] bar} catch { load ./spam[info sharedlibextension] spam} # Create some objects puts "Creating some objects" set a [Base] set b [Foo] set c [Bar] set d [Spam] # Try calling some methods puts "Testing some methods" puts "Should see 'Base::A' ---> " $a A puts "Should see 'Base::B' ---> " $a B puts "Should see 'Foo::A' ---> " $b A puts "Should see 'Foo::B' ---> " $b B puts "Should see 'Bar::A' ---> " $c A puts "Should see 'Bar::B' ---> " $c B puts "Should see 'Spam::A' ---> " $d A puts "Should see 'Spam::B' ---> " $d B # Try some casts puts "\nTesting some casts\n" Base x -this [$a toBase] puts "Should see 'Base::A' ---> " x A puts "Should see 'Base::B' ---> " x B rename x "" Base x -this [$b toBase] puts "Should see 'Foo::A' ---> " x A puts "Should see 'Base::B' ---> " x B rename x "" Base x -this [$c toBase] puts "Should see 'Bar::A' ---> " x A puts "Should see 'Base::B' ---> " x B rename x "" Base x -this [$d toBase] puts "Should see 'Spam::A' ---> " x A puts "Should see 'Base::B' ---> " x B rename x "" Bar x -this [$d toBar] puts "Should see 'Bar::B' ---> " x B rename x "" puts "\nTesting some dynamic casts\n" Base x -this [$d toBase] puts "Spam -> Base -> Foo : " set y [Foo_fromBase [x cget -this]] if {$y != "NULL"} { puts "bad swig" } { puts "good swig" } puts "Spam -> Base -> Bar : " set y [Bar_fromBase [x cget -this]] if {$y != "NULL"} { puts "good swig" } { puts "bad swig" } puts "Spam -> Base -> Spam : " set y [Spam_fromBase [x cget -this]] if {$y != "NULL"} { puts "good swig" } { puts "bad swig" } puts "Foo -> Spam : " set y [Spam_fromBase $b] if {$y != "NULL"} { puts "bad swig" } { puts "good swig" } swig-3.0.2/Examples/tcl/import/spam.h0000664000175000017500000000061412343605122017327 0ustar williamwilliam#include "bar.h" class Spam : public Bar { public: Spam() { } ~Spam() { } virtual void A() { printf("I'm Spam::A\n"); } void B() { printf("I'm Spam::B\n"); } virtual Base *toBase() { return static_cast(this); } virtual Bar *toBar() { return static_cast(this); } static Spam *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/tcl/import/README0000664000175000017500000000223212343605122017074 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. Use 'tclsh runme.tcl' to run a test. Overview: --------- The example defines 4 different extension modules--each wrapping a separate C++ class. base.i - Base class foo.i - Foo class derived from Base bar.i - Bar class derived from Base spam.i - Spam class derived from Bar Each module used %import to refer to another module. For example, the 'foo.i' module uses '%import base.i' to get definitions for its base class. If everything is okay, all of the modules will load properly and type checking will work correctly. Caveat: Some compilers, for example gcc-3.2.x, generate broken vtables with the inline methods in this test. This is not a SWIG problem and can usually be solved with non-inlined destructors compiled into separate shared objects/DLLs. Unix: ----- - Run make - Run the test as described above Windows: -------- - Use the Visual C++ 6 workspace file (example.dsw). The Batch build option in the Build menu is usually the easiest way to do this. Only use the Release builds not the Debug builds. - Run the test as described above swig-3.0.2/Examples/tcl/import/spam.i0000664000175000017500000000011012343605122017317 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-3.0.2/Examples/tcl/import/bar.i0000664000175000017500000000010612343605122017130 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-3.0.2/Examples/tcl/import/base.i0000664000175000017500000000006612343605122017303 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h swig-3.0.2/Examples/tcl/import/foo.dsp0000664000175000017500000001145012343605122017511 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=foo - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "foo.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "foo - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"foo.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "foo - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"foo.dll" !ENDIF # Begin Target # Name "foo - Win32 Debug" # Name "foo - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\foo_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\foo.h # End Source File # End Group # Begin Source File SOURCE=.\foo.i !IF "$(CFG)" == "foo - Win32 Debug" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "foo - Win32 Release" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/tcl/import/base.dsp0000664000175000017500000001150212343605122017636 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=base - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "base.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "base - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"base.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "base - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"base.dll" !ENDIF # Begin Target # Name "base - Win32 Debug" # Name "base - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\base_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\base.h # End Source File # End Group # Begin Source File SOURCE=.\base.i !IF "$(CFG)" == "base - Win32 Debug" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "base - Win32 Release" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/tcl/import/foo.i0000664000175000017500000000010512343605122017146 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-3.0.2/Examples/tcl/import/foo.h0000664000175000017500000000050512343605122017151 0ustar williamwilliam#include "base.h" class Foo : public Base { public: Foo() { } ~Foo() { } virtual void A() { printf("I'm Foo::A\n"); } void B() { printf("I'm Foo::B\n"); } virtual Base *toBase() { return static_cast(this); } static Foo *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/tcl/import/base.h0000664000175000017500000000045112343605122017300 0ustar williamwilliam#include class Base { public: Base() { }; virtual ~Base() { }; virtual void A() { printf("I'm Base::A\n"); } void B() { printf("I'm Base::B\n"); } virtual Base *toBase() { return static_cast(this); } }; swig-3.0.2/Examples/tcl/import/Makefile0000664000175000017500000000142412343605122017656 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' tcl_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' tcl_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' tcl_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' tcl_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/tcl/import/example.dsw0000664000175000017500000000206412343605122020371 0ustar williamwilliamMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "bar"=.\bar.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "base"=.\base.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "foo"=.\foo.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "spam"=.\spam.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### swig-3.0.2/Examples/tcl/import/bar.h0000664000175000017500000000050612343605122017133 0ustar williamwilliam#include "base.h" class Bar : public Base { public: Bar() { } ~Bar() { } virtual void A() { printf("I'm Bar::A\n"); } void B() { printf("I'm Bar::B\n"); } virtual Base *toBase() { return static_cast(this); } static Bar *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.2/Examples/tcl/import/bar.dsp0000664000175000017500000001145012343605122017472 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=bar - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "bar.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "bar - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"bar.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "bar - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"bar.dll" !ENDIF # Begin Target # Name "bar - Win32 Debug" # Name "bar - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\bar_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\bar.h # End Source File # End Group # Begin Source File SOURCE=.\bar.i !IF "$(CFG)" == "bar - Win32 Debug" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "bar - Win32 Release" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on ..\..\..\swig.exe -c++ -tcl8 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.2/Examples/tcl/variables/0000775000175000017500000000000012343605122016653 5ustar williamwilliamswig-3.0.2/Examples/tcl/variables/runme.tcl0000664000175000017500000000304712343605122020511 0ustar williamwilliam# file: runme.tcl catch { load ./example[info sharedlibextension] example} # Try to set the values of some global variables set ivar 42 set svar -31000 set lvar 65537 set uivar 123456 set usvar 61000 set ulvar 654321 set scvar -13 set ucvar 251 set cvar "S" set fvar 3.14159 set dvar 2.1828 set strvar "Hello World" set iptrvar [new_int 37] set ptptr [new_Point 37 42] set name "Bill" # Now print out the values of the variables puts "Variables (values printed from Tcl)" puts "ivar = $ivar" puts "svar = $svar" puts "lvar = $lvar" puts "uivar = $uivar" puts "usvar = $usvar" puts "ulvar = $ulvar" puts "scvar = $scvar" puts "ucvar = $ucvar" puts "fvar = $fvar" puts "dvar = $dvar" puts "cvar = $cvar" puts "strvar = $strvar" puts "cstrvar = $cstrvar" puts "iptrvar = $iptrvar" puts "name = $name" puts "ptptr = $ptptr [Point_print $ptptr]" puts "pt = $pt [Point_print $pt]" puts "\nVariables (values printed from C)" print_vars puts "\nNow I'm going to try and modify some read only variables"; puts " Tring to set 'path'"; if { [catch { set path "Whoa!" puts "Hey, what's going on?!?! This shouldn't work" }]} { puts "Good." } puts " Trying to set 'status'"; if { [catch { set status 0 puts "Hey, what's going on?!?! This shouldn't work" }]} { puts "Good." } puts "\nI'm going to try and update a structure variable.\n" set pt $ptptr puts "The new value is" pt_print puts "You should see the value [Point_print $ptptr]" swig-3.0.2/Examples/tcl/variables/example.c0000664000175000017500000000456012343605122020457 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/tcl/variables/example.h0000664000175000017500000000007512343605122020461 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/tcl/variables/example.i0000664000175000017500000000203012343605122020453 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} #pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/tcl/variables/index.html0000664000175000017500000000555312343605122020660 0ustar williamwilliam SWIG:Examples:tcl:variables SWIG/Examples/tcl/variables/

    Wrapping C Global Variables

    When a C global variable appears in an interface file, SWIG tries to wrap it using a technique known as "variable linking." The idea is pretty simple---we try to create a Tcl variable that works exactly like you would expect in a Tcl script, but which magically retrieves or updates the value of the underlying C variable. Click here to see a SWIG interface with some variable declarations in it.

    Manipulating Variables from Tcl

    Click here to see a script that updates and prints out the values of the variables defined in the above file. Notice how the C global variables work just like normal Tcl variables.

    Key points

    • The set statement changes the value of the corresponding C global variable.
    • Whenever you access the value of a variable such as $ivar, the value of the C global variable is read.
    • If a C program changes a global variable independently of Tcl, this change is automatically reflected in the Tcl variable (i.e., reads will always return the most up to date value of the variable).
    • When a global variable has the type "char *", SWIG manages it as a character string. However, whenever the value of such a variable is set from Tcl, the old value is destroyed using free() or delete (the choice of which depends on whether or not SWIG was run with the -c++ option).
    • signed char and unsigned char are handled as small 8-bit integers.
    • String array variables such as 'char name[256]' are managed as Tcl strings, but when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
    • When structures and classes are used as global variables, they are mapped into pointers. Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global.

    Creating read-only variables

    The %immutable and %mutable directives can be used to specify a collection of read-only variables. For example:
    %immutable;
    int    status;
    double blah;
    ...
    %mutable;
    
    The %immutable directive remains in effect until it is explicitly disabled using the %mutable directive.

    Comments

    • Management of global variables is one of the most problematic aspects of C/C++ wrapping because the scripting interface and resulting memory management is much trickier than simply creating a wrapper function.

    • You may be better off hiding global variables behind a function based interface.

    swig-3.0.2/Examples/tcl/variables/Makefile0000664000175000017500000000105312343605122020312 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean swig-3.0.2/Examples/javascript/0000775000175000017500000000000012343605122016267 5ustar williamwilliamswig-3.0.2/Examples/javascript/constant/0000775000175000017500000000000012343605122020120 5ustar williamwilliamswig-3.0.2/Examples/javascript/constant/example.js0000664000175000017500000000006312343605122022110 0ustar williamwilliammodule.exports = require("build/Release/example"); swig-3.0.2/Examples/javascript/constant/example.h0000664000175000017500000000040112343605122021717 0ustar williamwilliam#define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" #define EXTERN extern #define FOO (ICONST + BAR) swig-3.0.2/Examples/javascript/constant/runme.js0000664000175000017500000000147012343605122021606 0ustar williamwilliamvar example = require("example"); console.log("ICONST = " + example.ICONST + " (should be 42)"); console.log("FCONST = " + example.FCONST + " (should be 2.1828)"); console.log("CCONST = " + example.CCONST + " (should be 'x')"); console.log("CCONST2 = " + example.CCONST2 + " (this should be on a new line)"); console.log("SCONST = " + example.SCONST + " (should be 'Hello World')"); console.log("SCONST2 = " + example.SCONST2 + " (should be '\"Hello World\"')"); console.log("EXPR = " + example.EXPR + " (should be 48.5484)"); console.log("iconst = " + example.iconst + " (should be 37)"); console.log("fconst = " + example.fconst + " (should be 3.14)"); console.log("EXTERN = " + example.EXTERN + " (should be undefined)"); console.log("FOO = " + example.FOO + " (should be undefined)"); swig-3.0.2/Examples/javascript/constant/example.i0000664000175000017500000000113212343605122021722 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.2/Examples/javascript/constant/binding.gyp.in0000664000175000017500000000021612343605122022657 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ "example_wrap.cxx" ], "include_dirs": ["$srcdir"] } ] } swig-3.0.2/Examples/javascript/constant/Makefile0000664000175000017500000000004712343605122021561 0ustar williamwilliamSRCS = include $(SRCDIR)../example.mk swig-3.0.2/Examples/javascript/template/0000775000175000017500000000000012343605122020102 5ustar williamwilliamswig-3.0.2/Examples/javascript/template/example.js0000664000175000017500000000006312343605122022072 0ustar williamwilliammodule.exports = require("build/Release/example"); swig-3.0.2/Examples/javascript/template/example.h0000664000175000017500000000077712343605122021721 0ustar williamwilliam/* File : example.h */ // Some template definitions template T max(T a, T b) { return a>b ? a : b; } template class vector { T *v; int sz; public: vector(int _sz) { v = new T[_sz]; sz = _sz; } T &get(int index) { return v[index]; } void set(int index, T &val) { v[index] = val; } #ifdef SWIG %extend { T getitem(int index) { return $self->get(index); } void setitem(int index, T val) { $self->set(index,val); } } #endif }; swig-3.0.2/Examples/javascript/template/runme.js0000664000175000017500000000101012343605122021556 0ustar williamwilliamvar example = require("example"); //Call some templated functions console.log(example.maxint(3,7)); console.log(example.maxdouble(3.14,2.18)); // Create some class iv = new example.vecint(100); dv = new example.vecdouble(1000); for(i=0;i<=100;i++) iv.setitem(i,2*i); for(i=0;i<=1000;i++) dv.setitem(i, 1.0/(i+1)); sum = 0; for(i=0;i<=100;i++) sum = sum + iv.getitem(i); console.log(sum); sum = 0.0; for(i=0;i<=1000;i++) sum = sum + dv.getitem(i); console.log(sum); delete iv; delete dv; swig-3.0.2/Examples/javascript/template/example.i0000664000175000017500000000051412343605122021707 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" /* Now instantiate some specific template declarations */ %template(maxint) max; %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; swig-3.0.2/Examples/javascript/template/binding.gyp.in0000664000175000017500000000021612343605122022641 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ "example_wrap.cxx" ], "include_dirs": ["$srcdir"] } ] } swig-3.0.2/Examples/javascript/template/Makefile0000664000175000017500000000004712343605122021543 0ustar williamwilliamSRCS = include $(SRCDIR)../example.mk swig-3.0.2/Examples/javascript/class/0000775000175000017500000000000012343605122017374 5ustar williamwilliamswig-3.0.2/Examples/javascript/class/example.js0000664000175000017500000000006312343605122021364 0ustar williamwilliammodule.exports = require("build/Release/example"); swig-3.0.2/Examples/javascript/class/example.h0000664000175000017500000000110112343605122021171 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; swig-3.0.2/Examples/javascript/class/runme.js0000664000175000017500000000244512343605122021065 0ustar williamwilliamvar example = require("example"); // ----- Object creation ----- console.log("Creating some objects:"); c = new example.Circle(10); console.log("Created circle " + c); s = new example.Square(10); console.log("Created square " + s); // ----- Access a static member ----- console.log("\nA total of " + example.Shape.nshapes + " shapes were created"); // access static member as properties of the class object // ----- Member data access ----- // Set the location of the object. // Note: methods in the base class Shape are used since // x and y are defined there. c.x = 20; c.y = 30; s.x = -10; s.y = 5; console.log("\nHere is their new position:"); console.log("Circle = (" + c.x + "," + c.y + ")"); console.log("Square = (" + s.x + "," + s.y + ")"); // ----- Call some methods ----- console.log("\nHere are some properties of the shapes:"); console.log("Circle:"); console.log("area = " + c.area() + ""); console.log("perimeter = " + c.perimeter() + ""); console.log("\n"); console.log("Square:"); console.log("area = " + s.area() + ""); console.log("perimeter = " + s.perimeter() + ""); // ----- Delete everything ----- console.log("\nGuess I'll clean up now"); // Note: this invokes the virtual destructor delete c; delete s; console.log(example.Shape.nshapes + " shapes remain"); console.log("Goodbye"); swig-3.0.2/Examples/javascript/class/example.i0000664000175000017500000000021512343605122021177 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/javascript/class/example.cxx0000664000175000017500000000065012343605122021554 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.2/Examples/javascript/class/binding.gyp.in0000664000175000017500000000033412343605122022134 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ " void Foo::enum_test(speed s) { if (s == IMPULSE) { printf("IMPULSE speed\n"); } else if (s == WARP) { printf("WARP speed\n"); } else if (s == LUDICROUS) { printf("LUDICROUS speed\n"); } else { printf("Unknown speed\n"); } } void enum_test(color c, Foo::speed s) { if (c == RED) { printf("color = RED, "); } else if (c == BLUE) { printf("color = BLUE, "); } else if (c == GREEN) { printf("color = GREEN, "); } else { printf("color = Unknown color!, "); } if (s == Foo::IMPULSE) { printf("speed = IMPULSE speed\n"); } else if (s == Foo::WARP) { printf("speed = WARP speed\n"); } else if (s == Foo::LUDICROUS) { printf("speed = LUDICROUS speed\n"); } else { printf("speed = Unknown speed!\n"); } } swig-3.0.2/Examples/javascript/enum/binding.gyp.in0000664000175000017500000000033412343605122021773 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ " 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.2/Examples/javascript/simple/binding.gyp.in0000664000175000017500000000033412343605122022320 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ " #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.2/Examples/javascript/reference/binding.gyp.in0000664000175000017500000000033412343605122022765 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ " class Sum { T res; public: Sum(T i = 0) : res(i) { } void operator() (T x) { res += x; } T result() const { return res; } }; %} %rename(call) *::operator(); // the fn call operator // Instantiate a few versions %template(intSum) Sum; %template(doubleSum) Sum; swig-3.0.2/Examples/javascript/functor/binding.gyp.in0000664000175000017500000000021612343605122022506 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ "example_wrap.cxx" ], "include_dirs": ["$srcdir"] } ] } swig-3.0.2/Examples/javascript/functor/Makefile0000664000175000017500000000004712343605122021410 0ustar williamwilliamSRCS = include $(SRCDIR)../example.mk swig-3.0.2/Examples/javascript/overload/0000775000175000017500000000000012343605122020102 5ustar williamwilliamswig-3.0.2/Examples/javascript/overload/example.js0000664000175000017500000000006312343605122022072 0ustar williamwilliammodule.exports = require("build/Release/example"); swig-3.0.2/Examples/javascript/overload/example.h0000664000175000017500000000100612343605122021703 0ustar williamwilliam#include void f() { std::cout << "Called f()." << std::endl; } void f(int val) { std::cout << "Called f(int)." << std::endl; } void f(int val1, int val2) { std::cout << "Called f(int, int)." << std::endl; } void f(const char* s) { std::cout << "Called f(const char*)." << std::endl; } void f(bool val) { std::cout << "Called f(bool)." << std::endl; } void f(long val) { std::cout << "Called f(long)." << std::endl; } void f(double val) { std::cout << "Called f(double)." << std::endl; } swig-3.0.2/Examples/javascript/overload/runme.js0000664000175000017500000000024212343605122021564 0ustar williamwilliamvar example = require("example"); example.f(); example.f(1); example.f(1, 2); example.f("bla"); example.f(false); example.f(11111111111); example.f_double(1.0); swig-3.0.2/Examples/javascript/overload/example.i0000664000175000017500000000054612343605122021714 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Note: overloading is implemented in a sloppy way currently i.e., only the number of arguments is taken into conideration for dispatching. To solve the problem one has to rename such conflicting methods. */ %rename(f_double) f(double val); %include "example.h" swig-3.0.2/Examples/javascript/overload/binding.gyp.in0000664000175000017500000000021612343605122022641 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ "example_wrap.cxx" ], "include_dirs": ["$srcdir"] } ] } swig-3.0.2/Examples/javascript/overload/Makefile0000664000175000017500000000004712343605122021543 0ustar williamwilliamSRCS = include $(SRCDIR)../example.mk swig-3.0.2/Examples/javascript/check.list0000664000175000017500000000015412343605122020241 0ustar williamwilliamclass constant enum exception functor nspace operator overload pointer #reference simple template variables swig-3.0.2/Examples/javascript/exception/0000775000175000017500000000000012343605122020265 5ustar williamwilliamswig-3.0.2/Examples/javascript/exception/example.js0000664000175000017500000000006312343605122022255 0ustar williamwilliammodule.exports = require("build/Release/example"); swig-3.0.2/Examples/javascript/exception/example.h0000664000175000017500000000201512343605122022067 0ustar williamwilliam/* File : example.h */ #include #ifndef SWIG struct A { }; #endif class Exc { public: Exc(int c, const char *m) { code = c; strncpy(msg,m,256); } int code; char msg[256]; }; #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif class Test { public: int simple() throw(int) { throw(37); return 1; } int message() throw(const char *) { throw("I died."); return 1; } int hosed() throw(Exc) { throw(Exc(42,"Hosed")); return 1; } int unknown() throw(A*) { static A a; throw &a; return 1; } int multi(int x) throw(int, const char *, Exc) { if (x == 1) throw(37); if (x == 2) throw("Bleah!"); if (x == 3) throw(Exc(42,"No-go-diggy-die")); return 1; } }; #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif swig-3.0.2/Examples/javascript/exception/runme.js0000664000175000017500000000221412343605122021750 0ustar williamwilliamvar example = require("example"); console.log("Trying to catch some exceptions."); t = new example.Test(); try{ t.unknown(); throw -1; } catch(error) { if(error == -1) { console.log("t.unknown() didn't throw"); } else { console.log("successfully catched throw in Test::unknown()."); } } try{ t.simple(); throw -1; } catch(error){ if(error == -1) { console.log("t.simple() did not throw"); } else { console.log("successfully catched throw in Test::simple()."); } } try{ t.message(); throw -1; } catch(error){ if(error == -1) { console.log("t.message() did not throw"); } else { console.log("successfully catched throw in Test::message()."); } } try{ t.hosed(); throw -1; } catch(error){ if(error == -1) { console.log("t.hosed() did not throw"); } else { console.log("successfully catched throw in Test::hosed()."); } } for (var i=1; i<4; i++) { try{ t.multi(i); throw -1; } catch(error){ if(error == -1) { console.log("t.multi(" + i + ") did not throw"); } else { console.log("successfully catched throw in Test::multi()."); } } } swig-3.0.2/Examples/javascript/exception/example.i0000664000175000017500000000024712343605122022075 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include "std_string.i" /* Let's just grab the original header file here */ %include "example.h" swig-3.0.2/Examples/javascript/exception/example.cxx0000664000175000017500000000000112343605122022433 0ustar williamwilliam swig-3.0.2/Examples/javascript/exception/binding.gyp.in0000664000175000017500000000170012343605122023023 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ " class Complex { private: double rpart, ipart; public: Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { } Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { } Complex &operator=(const Complex &c) { rpart = c.rpart; ipart = c.ipart; return *this; } Complex operator+(const Complex &c) const { return Complex(rpart+c.rpart, ipart+c.ipart); } Complex operator-(const Complex &c) const { return Complex(rpart-c.rpart, ipart-c.ipart); } Complex operator*(const Complex &c) const { return Complex(rpart*c.rpart - ipart*c.ipart, rpart*c.ipart + c.rpart*ipart); } Complex operator-() const { return Complex(-rpart, -ipart); } double re() const { return rpart; } double im() const { return ipart; } }; swig-3.0.2/Examples/javascript/operator/runme.js0000664000175000017500000000066412343605122021614 0ustar williamwilliamvar example = require("example"); a = new example.Complex(2,3); b = new example.Complex(-5,10); console.log ("a =" + a); console.log ("b =" + b); c = a.plus(b); console.log("c =" + c); console.log("a*b =" + a.times(b)); console.log("a-c =" + a.minus(c)); e = example.Complex.copy(a.minus(c)); console.log("e =" + e); // Big expression f = a.plus(b).times(c.plus(b.times(e))).plus(a.uminus()); console.log("f =" + f); swig-3.0.2/Examples/javascript/operator/example.i0000664000175000017500000000160712343605122021733 0ustar williamwilliam/* File : example.i */ %module example #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ %{ #include "example.h" %} /* This header file is a little tough to handle because it has overloaded operators and constructors. We're going to try and deal with that here */ /* This turns the copy constructor in a function ComplexCopy() that can be called */ %rename(assign) Complex::operator=; %rename(plus) Complex::operator+; %rename(minus) Complex::operator-(const Complex &) const; %rename(uminus) Complex::operator-() const; %rename(times) Complex::operator*; /* Now grab the original header file */ %include "example.h" /* An output method that turns a complex into a short string */ %extend Complex { char *toString() { static char temp[512]; sprintf(temp,"(%g,%g)", $self->re(), $self->im()); return temp; } static Complex* copy(const Complex& c) { return new Complex(c); } }; swig-3.0.2/Examples/javascript/operator/binding.gyp.in0000664000175000017500000000021612343605122022661 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ "example_wrap.cxx" ], "include_dirs": ["$srcdir"] } ] } swig-3.0.2/Examples/javascript/operator/Makefile0000664000175000017500000000004712343605122021563 0ustar williamwilliamSRCS = include $(SRCDIR)../example.mk swig-3.0.2/Examples/javascript/variables/0000775000175000017500000000000012343605122020237 5ustar williamwilliamswig-3.0.2/Examples/javascript/variables/example.js0000664000175000017500000000006312343605122022227 0ustar williamwilliammodule.exports = require("build/Release/example"); swig-3.0.2/Examples/javascript/variables/example.h0000664000175000017500000000007512343605122022045 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.2/Examples/javascript/variables/runme.js0000664000175000017500000000421112343605122021721 0ustar williamwilliamvar example = require("example"); // Try to set the values of some global variables example.ivar = 42; example.svar = -31000; example.lvar = 65537; example.uivar = 123456; example.usvar = 61000; example.ulvar = 654321; example.scvar = -13; example.ucvar = 251; example.cvar = "S"; example.fvar = 3.14159; example.dvar = 2.1828; example.strvar = "Hello World"; example.iptrvar= example.new_int(37); example.ptptr = example.new_Point(37,42); example.name = "Bill"; // Now console.log out the values of the variables console.log("Variables (values printed from Javascript)"); console.log("ivar = " + example.ivar); console.log("svar = " + example.svar); console.log("lvar = " + example.lvar); console.log("uivar = " + example.uivar); console.log("usvar = " + example.usvar); console.log("ulvar = " + example.ulvar); console.log("scvar = " + example.scvar); console.log("ucvar = " + example.ucvar); console.log("fvar = " + example.fvar); console.log("dvar = " + example.dvar); console.log("cvar = " + example.cvar); console.log("strvar = " + example.strvar); console.log("cstrvar = " + example.cstrvar); console.log("iptrvar = " + example.iptrvar); console.log("name = " + example.name); console.log("ptptr = " + example.ptptr + ": " + example.Point_print(example.ptptr)); console.log("pt = " + example.pt + ": " + example.Point_print(example.pt)); console.log("\nVariables (values printed from C)"); example.print_vars(); console.log("\nNow I'm going to try and modify some read only variables"); console.log("Tring to set 'path'"); try{ example.path = "Whoa!"; console.log("Hey, what's going on?!?! This shouldn't work"); } catch(e){ console.log("Good."); } console.log("Trying to set 'status'"); try{ example.status = 0; console.log("Hey, what's going on?!?! This shouldn't work"); } catch(e){ console.log("Good."); } console.log("\nI'm going to try and update a structure variable."); example.pt = example.ptptr; console.log("The new value is: "); example.pt_print(); console.log("You should see the value: " + example.Point_print(example.ptptr)); swig-3.0.2/Examples/javascript/variables/example.i0000664000175000017500000000174512343605122022053 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.2/Examples/javascript/variables/example.cxx0000664000175000017500000000501412343605122022416 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; #ifdef __cplusplus // Note: for v8 this must be linkable with g++, without extern cstrvar is mangled extern const char cstrvar[] = "Goodbye"; #else const char cstrvar[] = "Goodbye"; #endif const int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.2/Examples/javascript/variables/binding.gyp.in0000664000175000017500000000033412343605122022777 0ustar williamwilliam{ "targets": [ { "target_name": "example", "sources": [ " (eval-when (:compile-toplevel :load-toplevel :execute) (require 'port) ; from CLOCC (require 'uffi)) (in-package :cl-user) ;; Interaction with the SWIG binary (defvar *swig-source-directory* #p"/home/mkoeppe/s/swig1.3/") (defvar *swig-program* (merge-pathnames "preinst-swig" *swig-source-directory*)) (defun run-swig (swig-interface-file-name &key directory-search-list module ignore-errors c++) (let ((temp-file-name "/tmp/swig.lsp")) (let ((process (port:run-prog (namestring *swig-program*) :output t :args `(,@(and c++ '("-c++")) "-sexp" ,@(mapcar (lambda (dir) (concatenate 'string "-I" (namestring dir))) directory-search-list) ,@(and module `("-module" ,module)) "-o" ,temp-file-name ,(namestring swig-interface-file-name))))) #+cmu (unless (or (zerop (ext:process-exit-code process)) ignore-errors) (error "Process swig exited abnormally")) (with-open-file (s temp-file-name) (read s))))) ;; Type system (defun parse-swigtype (type-string &key start end junk-ok) "Parse TYPE-STRING as SWIG's internal representation of C/C++ types. Return two values: The type description (an improper list) and the terminating index into TYPE-STRING." ;; SWIG's internal representation is described in Source/Swig/stype.c (unless start (setq start 0)) (unless end (setq end (length type-string))) (flet ((prefix-match (prefix) (let ((position (mismatch prefix type-string :start2 start :end2 end))) (or (not position) (= position (length prefix))))) (bad-type-error (reason) (error "Bad SWIG type (~A): ~A" reason (subseq type-string start end))) (type-char (index) (and (< index (length type-string)) (char type-string index))) (cons-and-recurse (prefix start end) (multiple-value-bind (type-description index) (parse-swigtype type-string :start start :end end :junk-ok junk-ok) (values (cons prefix type-description) index)))) (cond ((prefix-match "p.") ; pointer (cons-and-recurse '* (+ start 2) end)) ((prefix-match "r.") ; C++ reference (cons-and-recurse '& (+ start 2) end)) ((prefix-match "a(") ; array (let ((closing-paren (position #\) type-string :start (+ start 2) :end end))) (unless closing-paren (bad-type-error "missing right paren")) (unless (eql (type-char (+ closing-paren 1)) #\.) (bad-type-error "missing dot")) (cons-and-recurse (list 'ARRAY (subseq type-string (+ start 2) closing-paren)) (+ closing-paren 2) end))) ((prefix-match "q(") ; qualifier (const, volatile) (let ((closing-paren (position #\) type-string :start (+ start 2) :end end))) (unless closing-paren (bad-type-error "missing right paren")) (unless (eql (type-char (+ closing-paren 1)) #\.) (bad-type-error "missing dot")) (cons-and-recurse (list 'QUALIFIER (subseq type-string (+ start 2) closing-paren)) (+ closing-paren 2) end))) ((prefix-match "m(") ; C++ member pointer (multiple-value-bind (class-type class-end-index) (parse-swigtype type-string :junk-ok t :start (+ start 2) :end end) (unless (eql (type-char class-end-index) #\)) (bad-type-error "missing right paren")) (unless (eql (type-char (+ class-end-index 1)) #\.) (bad-type-error "missing dot")) (cons-and-recurse (list 'MEMBER-POINTER class-type) (+ class-end-index 2) end))) ((prefix-match "f(") ; function (loop with index = (+ start 2) until (eql (type-char index) #\)) collect (multiple-value-bind (arg-type arg-end-index) (parse-swigtype type-string :junk-ok t :start index :end end) (case (type-char arg-end-index) (#\, (setq index (+ arg-end-index 1))) (#\) (setq index arg-end-index)) (otherwise (bad-type-error "comma or right paren expected"))) arg-type) into arg-types finally (unless (eql (type-char (+ index 1)) #\.) (bad-type-error "missing dot")) (return (cons-and-recurse (cons 'FUNCTION arg-types) (+ index 2) end)))) ((prefix-match "v(") ;varargs (let ((closing-paren (position #\) type-string :start (+ start 2) :end end))) (unless closing-paren (bad-type-error "missing right paren")) (values (list 'VARARGS (subseq type-string (+ start 2) closing-paren)) (+ closing-paren 1)))) (t (let ((junk-position (position-if (lambda (char) (member char '(#\, #\( #\) #\.))) type-string :start start :end end))) (cond (junk-position ; found junk (unless junk-ok (bad-type-error "trailing junk")) (values (subseq type-string start junk-position) junk-position)) (t (values (subseq type-string start end) end)))))))) (defun swigtype-function-p (swigtype) "Check whether SWIGTYPE designates a function. If so, the second value is the list of argument types, and the third value is the return type." (if (and (consp swigtype) (consp (first swigtype)) (eql (first (first swigtype)) 'FUNCTION)) (values t (rest (first swigtype)) (rest swigtype)) (values nil nil nil))) ;; UFFI (defvar *uffi-definitions* '()) (defconstant *uffi-default-primitive-type-alist* '(("char" . :char) ("unsigned char" . :unsigned-byte) ("signed char" . :byte) ("short" . :short) ("signed short" . :short) ("unsigned short" . :unsigned-short) ("int" . :int) ("signed int" . :int) ("unsigned int" . :unsigned-int) ("long" . :long) ("signed long" . :long) ("unsigned long" . :unsigned-long) ("float" . :float) ("double" . :double) ((* . "char") . :cstring) ((* . "void") . :pointer-void) ("void" . :void))) (defvar *uffi-primitive-type-alist* *uffi-default-primitive-type-alist*) (defun uffi-type-spec (type-list) "Return the UFFI type spec equivalent to TYPE-LIST, or NIL if there is no representation." (let ((primitive-type-pair (assoc type-list *uffi-primitive-type-alist* :test 'equal))) (cond (primitive-type-pair (cdr primitive-type-pair)) ((and (consp type-list) (eql (first type-list) '*)) (let ((base-type-spec (uffi-type-spec (rest type-list)))) (cond ((not base-type-spec) :pointer-void) (t (list '* base-type-spec))))) (t nil)))) ;; Parse tree (defvar *uffi-output* nil) (defun emit-uffi-definition (uffi-definition) (format *uffi-output* "~&~S~%" uffi-definition) (push uffi-definition *uffi-definitions*)) (defun make-cl-symbol (c-identifier &key uninterned) (let ((name (substitute #\- #\_ (string-upcase c-identifier)))) (if uninterned (make-symbol name) (intern name)))) (defvar *class-scope* '() "A stack of names of nested C++ classes.") (defvar *struct-fields* '()) (defvar *linkage* :C "NIL or :C") (defgeneric handle-node (node-type &key &allow-other-keys) (:documentation "Handle a node of SWIG's parse tree of a C/C++ program")) (defmethod handle-node ((node-type t) &key &allow-other-keys) ;; do nothing for unknown node types nil) (defmethod handle-node ((node-type (eql 'cdecl)) &key name decl storage parms type &allow-other-keys) (let ((swigtype (parse-swigtype (concatenate 'string decl type)))) (let ((*print-pretty* nil) ; or FUNCTION would be printed as #' by cmucl (*print-circle* t)) (format *uffi-output* "~&;; C Declaration: ~A ~A ~A ~A~%;; with-parms ~W~%;; of-type ~W~%" storage type name decl parms swigtype)) (multiple-value-bind (function-p arg-swigtype-list return-swigtype) (swigtype-function-p swigtype) (declare (ignore arg-swigtype-list)) (cond ((and (null *class-scope*) function-p (or (eql *linkage* :c) (string= storage "externc"))) ;; ordinary top-level function with C linkage (let ((argnum 0) (argname-list '())) (flet ((unique-argname (name) ;; Sometimes the functions in SWIG interfaces ;; do not have unique names. Make them unique ;; by adding a suffix. Also avoid symbols ;; that are specially bound. (unless name (setq name (format nil "arg~D" argnum))) (let ((argname (make-cl-symbol name))) (when (boundp argname) ;specially bound (setq argname (make-cl-symbol name :uninterned t))) (push argname argname-list) argname))) (let ((uffi-arg-list (mapcan (lambda (param) (incf argnum) (destructuring-bind (&key name type &allow-other-keys) param (let ((uffi-type (uffi-type-spec (parse-swigtype type)))) (cond ((not uffi-type) (format *uffi-output* "~&;; Warning: Cannot handle type ~S of argument `~A'~%" type name) (return-from handle-node)) ((eq uffi-type :void) '()) (t (let ((symbol (unique-argname name))) (list `(,symbol ,uffi-type)))))))) parms)) (uffi-return-type (uffi-type-spec return-swigtype))) (unless uffi-return-type (format *uffi-output* "~&;; Warning: Cannot handle return type `~S'~%" return-swigtype) (return-from handle-node)) (emit-uffi-definition `(UFFI:DEF-FUNCTION ,name ,uffi-arg-list :RETURNING ,uffi-return-type)))))) ((and (not (null *class-scope*)) (null (rest *class-scope*)) (not function-p)) ; class/struct member (no nested structs) (let ((uffi-type (uffi-type-spec swigtype))) (unless uffi-type (format *uffi-output* "~&;; Warning: Cannot handle type ~S of struct field `~A'~%" type name) (return-from handle-node)) (push `(,(make-cl-symbol name) ,uffi-type) *struct-fields*))))))) (defmethod handle-node ((node-type (eql 'class)) &key name children kind &allow-other-keys) (format *uffi-output* "~&;; Class ~A~%" name) (let ((*class-scope* (cons name *class-scope*)) (*struct-fields* '())) (dolist (child children) (apply 'handle-node child)) (emit-uffi-definition `(,(if (string= kind "union") 'UFFI:DEF-UNION 'UFFI:DEF-STRUCT) ,(make-cl-symbol name) ,@(nreverse *struct-fields*))))) (defmethod handle-node ((node-type (eql 'top)) &key children &allow-other-keys) (dolist (child children) (apply 'handle-node child))) (defmethod handle-node ((node-type (eql 'include)) &key name children &allow-other-keys) (format *uffi-output* ";; INCLUDE ~A~%" name) (dolist (child children) (apply 'handle-node child))) (defmethod handle-node ((node-type (eql 'extern)) &key name children &allow-other-keys) (format *uffi-output* ";; EXTERN \"C\" ~A~%" name) (let ((*linkage* :c)) (dolist (child children) (apply 'handle-node child)))) ;;(defun compute-uffi-definitions (swig-interface) ;; (let ((*uffi-definitions* '())) ;; (handle-node swig-interface) ;; *uffi-definitions*)) ;; Test instances ;;; Link to SWIG itself #|| (defparameter *c++-compiler* "g++") (defun stdc++-library (&key env) (let ((error-output (make-string-output-stream))) (let ((name-output (make-string-output-stream))) (let ((proc (ext:run-program *c++-compiler* '("-print-file-name=libstdc++.so") :env env :input nil :output name-output :error error-output))) (unless proc (error "Could not run ~A" *c++-compiler*)) (unless (zerop (ext:process-exit-code proc)) (system:serve-all-events 0) (error "~A failed:~%~A" *c++-compiler* (get-output-stream-string error-output)))) (string-right-trim '(#\Newline) (get-output-stream-string name-output))))) (defvar *swig-interface* nil) (defvar *swig-uffi-pathname* #p"/tmp/swig-uffi.lisp") (defun link-swig () (setq *swig-interface* (run-swig (merge-pathnames "Source/swig.i" *swig-source-directory*) :directory-search-list (list (merge-pathnames "Source/" *swig-source-directory*)) :module "swig" :ignore-errors t :c++ t)) (with-open-file (f *swig-uffi-pathname* :direction :output) (let ((*linkage* :c++) (*uffi-definitions* '()) (*uffi-output* f) (*uffi-primitive-type-alist* *uffi-default-primitive-type-alist*)) (apply 'handle-node *swig-interface*))) (compile-file *swig-uffi-pathname*) (alien:load-foreign (merge-pathnames "Source/libswig.a" *swig-source-directory*) :libraries (list (stdc++-library))) ;; FIXME: UFFI stuffes a "-l" in front of the passed library names ;; (uffi:load-foreign-library (merge-pathnames "Source/libswig.a" ;; *swig-source-directory*) ;; :supporting-libraries ;; (list (stdc++-library))) (load (compile-file-pathname *swig-uffi-pathname*))) ||# ;;;; TODO: ;; * How to do type lookups? Is everything important that SWIG knows ;; about the types written out? What to make of typemaps? ;; ;; * Wrapped functions should probably automatically COERCE their ;; arguments (as of type DOUBLE-FLOAT), to make the functions more ;; flexible? ;; ;; * Why are the functions created by FFI interpreted? ;; ;; * We can't deal with more complicated structs and C++ classes ;; directly with the FFI; we have to emit SWIG wrappers that access ;; those classes. ;; ;; * A CLOS layer where structure fields are mapped as slots. It ;; looks like we need MOP functions to implement this. ;; ;; * Maybe modify SWIG so that key-value hashes are distinguished from ;; value-value hashes. swig-3.0.2/Examples/android/0000775000175000017500000000000012343605122015541 5ustar williamwilliamswig-3.0.2/Examples/android/class/0000775000175000017500000000000012343605122016646 5ustar williamwilliamswig-3.0.2/Examples/android/class/res/0000775000175000017500000000000012343605122017437 5ustar williamwilliamswig-3.0.2/Examples/android/class/res/values/0000775000175000017500000000000012343605122020736 5ustar williamwilliamswig-3.0.2/Examples/android/class/res/values/strings.xml0000664000175000017500000000015712343605122023154 0ustar williamwilliam SwigClass swig-3.0.2/Examples/android/class/res/layout/0000775000175000017500000000000012343605122020754 5ustar williamwilliamswig-3.0.2/Examples/android/class/res/layout/main.xml0000664000175000017500000000132212343605122022420 0ustar williamwilliam